From 79a9e1708163849dbff279586d8027a5f86476c7 Mon Sep 17 00:00:00 2001 From: luigi Date: Tue, 16 Jun 2015 12:48:12 +0000 Subject: [PATCH] sync with trunk git-svn-id: https://foundry.supelec.fr/svn/luatex/trunk@5270 0b2b3880-5936-4365-a048-eb17d2e5a6bf --- source/ChangeLog | 7 +- source/build-aux/missing | 2 +- source/build-aux/texinfo.tex | 38 +- source/build-aux/ylwrap | 2 +- source/configure | 172 +- source/libs/README | 10 +- source/libs/cairo/cairo-1.14.2-PATCHES/ChangeLog | 0 source/libs/cairo/cairo-1.14.2-PATCHES/TL-Changes | 0 source/libs/cairo/cairo-1.14.2/AUTHORS | 0 source/libs/cairo/cairo-1.14.2/BIBLIOGRAPHY | 0 source/libs/cairo/cairo-1.14.2/BUGS | 0 source/libs/cairo/cairo-1.14.2/CODING_STYLE | 0 source/libs/cairo/cairo-1.14.2/COPYING | 0 source/libs/cairo/cairo-1.14.2/COPYING-LGPL-2.1 | 0 source/libs/cairo/cairo-1.14.2/COPYING-MPL-1.1 | 0 source/libs/cairo/cairo-1.14.2/HACKING | 0 source/libs/cairo/cairo-1.14.2/INSTALL | 0 source/libs/cairo/cairo-1.14.2/KNOWN_ISSUES | 0 source/libs/cairo/cairo-1.14.2/Makefile.am | 0 source/libs/cairo/cairo-1.14.2/Makefile.win32 | 0 source/libs/cairo/cairo-1.14.2/NEWS | 0 source/libs/cairo/cairo-1.14.2/PORTING_GUIDE | 0 source/libs/cairo/cairo-1.14.2/README | 0 source/libs/cairo/cairo-1.14.2/README.win32 | 0 source/libs/cairo/cairo-1.14.2/RELEASING | 0 source/libs/cairo/cairo-1.14.2/acinclude.m4 | 0 .../cairo/cairo-1.14.2/build/Makefile.am.analysis | 0 .../cairo/cairo-1.14.2/build/Makefile.am.changelog | 0 .../cairo/cairo-1.14.2/build/Makefile.am.common | 0 .../cairo/cairo-1.14.2/build/Makefile.am.gtk-doc | 0 .../cairo/cairo-1.14.2/build/Makefile.am.releasing | 0 .../cairo/cairo-1.14.2/build/Makefile.win32.common | 0 .../cairo-1.14.2/build/Makefile.win32.features | 0 .../cairo-1.14.2/build/Makefile.win32.features-h | 0 .../cairo/cairo-1.14.2/build/Makefile.win32.inform | 0 .../libs/cairo/cairo-1.14.2/build/aclocal.cairo.m4 | 0 .../cairo/cairo-1.14.2/build/aclocal.compare.m4 | 0 .../cairo/cairo-1.14.2/build/aclocal.enable.m4 | 0 .../libs/cairo/cairo-1.14.2/build/aclocal.float.m4 | 0 .../cairo/cairo-1.14.2/build/aclocal.makefile.m4 | 0 .../libs/cairo/cairo-1.14.2/build/aclocal.pkg.m4 | 0 .../cairo/cairo-1.14.2/build/configure.ac.analysis | 0 .../cairo/cairo-1.14.2/build/configure.ac.features | 0 .../cairo-1.14.2/build/configure.ac.noversion | 0 .../cairo/cairo-1.14.2/build/configure.ac.pthread | 0 .../cairo/cairo-1.14.2/build/configure.ac.system | 0 .../cairo/cairo-1.14.2/build/configure.ac.tools | 0 .../cairo/cairo-1.14.2/build/configure.ac.version | 0 .../cairo/cairo-1.14.2/build/configure.ac.warnings | 0 source/libs/cairo/cairo-1.14.2/build/gtk-doc.m4 | 0 source/libs/cairo/cairo-1.14.2/cairo-version.h | 0 source/libs/cairo/cairo-1.14.2/config.h.in | 0 source/libs/cairo/cairo-1.14.2/configure.ac | 0 source/libs/cairo/cairo-1.14.2/src/Makefile.am | 0 .../cairo/cairo-1.14.2/src/Makefile.am.analysis | 0 .../cairo/cairo-1.14.2/src/Makefile.am.features | 0 .../libs/cairo/cairo-1.14.2/src/Makefile.sources | 0 source/libs/cairo/cairo-1.14.2/src/Makefile.win32 | 0 .../cairo/cairo-1.14.2/src/Makefile.win32.features | 0 source/libs/cairo/cairo-1.14.2/src/README | 0 .../src/cairo-analysis-surface-private.h | 0 .../cairo-1.14.2/src/cairo-analysis-surface.c | 0 .../cairo/cairo-1.14.2/src/cairo-arc-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-arc.c | 0 .../cairo/cairo-1.14.2/src/cairo-array-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-array.c | 0 .../cairo/cairo-1.14.2/src/cairo-atomic-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-atomic.c | 0 .../cairo/cairo-1.14.2/src/cairo-backend-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-base64-stream.c | 0 .../cairo/cairo-1.14.2/src/cairo-base85-stream.c | 0 .../src/cairo-bentley-ottmann-rectangular.c | 0 .../src/cairo-bentley-ottmann-rectilinear.c | 0 .../cairo/cairo-1.14.2/src/cairo-bentley-ottmann.c | 0 .../cairo/cairo-1.14.2/src/cairo-beos-surface.cpp | 0 source/libs/cairo/cairo-1.14.2/src/cairo-beos.h | 0 .../cairo-1.14.2/src/cairo-botor-scan-converter.c | 0 .../libs/cairo/cairo-1.14.2/src/cairo-box-inline.h | 0 .../cairo/cairo-1.14.2/src/cairo-boxes-intersect.c | 0 .../cairo/cairo-1.14.2/src/cairo-boxes-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-boxes.c | 0 .../cairo/cairo-1.14.2/src/cairo-cache-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-cache.c | 0 .../libs/cairo/cairo-1.14.2/src/cairo-cff-subset.c | 0 .../libs/cairo/cairo-1.14.2/src/cairo-clip-boxes.c | 0 .../cairo/cairo-1.14.2/src/cairo-clip-inline.h | 0 .../cairo/cairo-1.14.2/src/cairo-clip-polygon.c | 0 .../cairo/cairo-1.14.2/src/cairo-clip-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-clip-region.c | 0 .../cairo/cairo-1.14.2/src/cairo-clip-surface.c | 0 .../src/cairo-clip-tor-scan-converter.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-clip.c | 0 .../cairo-1.14.2/src/cairo-cogl-context-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-cogl-context.c | 0 .../cairo-1.14.2/src/cairo-cogl-gradient-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-cogl-gradient.c | 0 .../cairo/cairo-1.14.2/src/cairo-cogl-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-cogl-surface.c | 0 .../cairo-1.14.2/src/cairo-cogl-utils-private.h | 0 .../libs/cairo/cairo-1.14.2/src/cairo-cogl-utils.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-cogl.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-color.c | 0 .../cairo/cairo-1.14.2/src/cairo-combsort-inline.h | 0 .../cairo-1.14.2/src/cairo-compiler-private.h | 0 .../src/cairo-composite-rectangles-private.h | 0 .../cairo-1.14.2/src/cairo-composite-rectangles.c | 0 .../cairo-1.14.2/src/cairo-compositor-private.h | 0 .../libs/cairo/cairo-1.14.2/src/cairo-compositor.c | 0 .../cairo/cairo-1.14.2/src/cairo-contour-inline.h | 0 .../cairo/cairo-1.14.2/src/cairo-contour-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-contour.c | 0 .../cairo/cairo-1.14.2/src/cairo-damage-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-damage.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-debug.c | 0 .../src/cairo-default-context-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-default-context.c | 0 .../cairo/cairo-1.14.2/src/cairo-deflate-stream.c | 0 .../libs/cairo/cairo-1.14.2/src/cairo-deprecated.h | 0 .../cairo/cairo-1.14.2/src/cairo-device-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-device.c | 0 .../cairo-1.14.2/src/cairo-directfb-surface.c | 0 .../libs/cairo/cairo-1.14.2/src/cairo-directfb.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-drm.h | 0 .../cairo/cairo-1.14.2/src/cairo-egl-context.c | 0 .../cairo/cairo-1.14.2/src/cairo-error-inline.h | 0 .../cairo/cairo-1.14.2/src/cairo-error-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-error.c | 0 .../cairo-1.14.2/src/cairo-fallback-compositor.c | 0 .../src/cairo-features-uninstalled.pc.in | 0 .../cairo/cairo-1.14.2/src/cairo-features.pc.in | 0 .../cairo/cairo-1.14.2/src/cairo-fixed-private.h | 0 .../cairo-1.14.2/src/cairo-fixed-type-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-fixed.c | 0 .../cairo-1.14.2/src/cairo-font-face-twin-data.c | 0 .../cairo/cairo-1.14.2/src/cairo-font-face-twin.c | 0 .../libs/cairo/cairo-1.14.2/src/cairo-font-face.c | 0 .../cairo/cairo-1.14.2/src/cairo-font-options.c | 0 .../cairo-1.14.2/src/cairo-fontconfig-private.h | 0 .../cairo-1.14.2/src/cairo-freed-pool-private.h | 0 .../libs/cairo/cairo-1.14.2/src/cairo-freed-pool.c | 0 .../cairo-1.14.2/src/cairo-freelist-private.h | 0 .../cairo-1.14.2/src/cairo-freelist-type-private.h | 0 .../libs/cairo/cairo-1.14.2/src/cairo-freelist.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-ft-font.c | 0 .../libs/cairo/cairo-1.14.2/src/cairo-ft-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-ft.h | 0 .../cairo/cairo-1.14.2/src/cairo-gl-composite.c | 0 .../libs/cairo/cairo-1.14.2/src/cairo-gl-device.c | 0 .../cairo-1.14.2/src/cairo-gl-dispatch-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-gl-dispatch.c | 0 .../cairo-1.14.2/src/cairo-gl-ext-def-private.h | 0 .../libs/cairo/cairo-1.14.2/src/cairo-gl-glyphs.c | 0 .../cairo-1.14.2/src/cairo-gl-gradient-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-gl-gradient.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-gl-info.c | 0 .../cairo-1.14.2/src/cairo-gl-msaa-compositor.c | 0 .../libs/cairo/cairo-1.14.2/src/cairo-gl-operand.c | 0 .../libs/cairo/cairo-1.14.2/src/cairo-gl-private.h | 0 .../libs/cairo/cairo-1.14.2/src/cairo-gl-shaders.c | 0 .../libs/cairo/cairo-1.14.2/src/cairo-gl-source.c | 0 .../cairo-1.14.2/src/cairo-gl-spans-compositor.c | 0 .../libs/cairo/cairo-1.14.2/src/cairo-gl-surface.c | 0 .../cairo-1.14.2/src/cairo-gl-traps-compositor.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-gl.h | 0 .../cairo/cairo-1.14.2/src/cairo-glx-context.c | 0 .../cairo/cairo-1.14.2/src/cairo-gstate-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-gstate.c | 0 .../cairo/cairo-1.14.2/src/cairo-hash-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-hash.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-hull.c | 0 .../cairo-1.14.2/src/cairo-image-compositor.c | 0 .../cairo-1.14.2/src/cairo-image-info-private.h | 0 .../libs/cairo/cairo-1.14.2/src/cairo-image-info.c | 0 .../cairo/cairo-1.14.2/src/cairo-image-source.c | 0 .../cairo-1.14.2/src/cairo-image-surface-inline.h | 0 .../cairo-1.14.2/src/cairo-image-surface-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-image-surface.c | 0 .../cairo/cairo-1.14.2/src/cairo-line-inline.h | 0 .../cairo/cairo-1.14.2/src/cairo-line-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-line.c | 0 .../cairo/cairo-1.14.2/src/cairo-list-inline.h | 0 .../cairo/cairo-1.14.2/src/cairo-list-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-lzw.c | 0 .../cairo/cairo-1.14.2/src/cairo-malloc-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-mask-compositor.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-matrix.c | 0 .../cairo/cairo-1.14.2/src/cairo-mempool-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-mempool.c | 0 .../src/cairo-mesh-pattern-rasterizer.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-misc.c | 0 .../cairo-1.14.2/src/cairo-mono-scan-converter.c | 0 .../cairo-1.14.2/src/cairo-mutex-impl-private.h | 0 .../cairo-1.14.2/src/cairo-mutex-list-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-mutex-private.h | 0 .../cairo-1.14.2/src/cairo-mutex-type-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-mutex.c | 0 .../cairo/cairo-1.14.2/src/cairo-no-compositor.c | 0 .../libs/cairo/cairo-1.14.2/src/cairo-observer.c | 0 .../cairo/cairo-1.14.2/src/cairo-os2-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-os2-surface.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-os2.h | 0 .../cairo-1.14.2/src/cairo-output-stream-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-output-stream.c | 0 .../cairo-1.14.2/src/cairo-paginated-private.h | 0 .../src/cairo-paginated-surface-private.h | 0 .../cairo-1.14.2/src/cairo-paginated-surface.c | 0 .../cairo/cairo-1.14.2/src/cairo-path-bounds.c | 0 .../libs/cairo/cairo-1.14.2/src/cairo-path-fill.c | 0 .../cairo-1.14.2/src/cairo-path-fixed-private.h | 0 .../libs/cairo/cairo-1.14.2/src/cairo-path-fixed.c | 0 .../cairo/cairo-1.14.2/src/cairo-path-in-fill.c | 0 .../cairo/cairo-1.14.2/src/cairo-path-private.h | 0 .../cairo-1.14.2/src/cairo-path-stroke-boxes.c | 0 .../cairo-1.14.2/src/cairo-path-stroke-polygon.c | 0 .../cairo-1.14.2/src/cairo-path-stroke-traps.c | 0 .../cairo-1.14.2/src/cairo-path-stroke-tristrip.c | 0 .../cairo/cairo-1.14.2/src/cairo-path-stroke.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-path.c | 0 .../cairo/cairo-1.14.2/src/cairo-pattern-inline.h | 0 .../cairo/cairo-1.14.2/src/cairo-pattern-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-pattern.c | 0 .../cairo-1.14.2/src/cairo-pdf-operators-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-pdf-operators.c | 0 .../cairo-1.14.2/src/cairo-pdf-shading-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-pdf-shading.c | 0 .../cairo-1.14.2/src/cairo-pdf-surface-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-pdf-surface.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-pdf.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-pen.c | 0 .../cairo/cairo-1.14.2/src/cairo-pixman-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-png.c | 0 .../cairo-1.14.2/src/cairo-polygon-intersect.c | 0 .../cairo/cairo-1.14.2/src/cairo-polygon-reduce.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-polygon.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-private.h | 0 .../cairo-1.14.2/src/cairo-ps-surface-private.h | 0 .../libs/cairo/cairo-1.14.2/src/cairo-ps-surface.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-ps.h | 0 .../cairo/cairo-1.14.2/src/cairo-qt-surface.cpp | 0 source/libs/cairo/cairo-1.14.2/src/cairo-qt.h | 0 .../cairo/cairo-1.14.2/src/cairo-quartz-font.c | 0 .../cairo-1.14.2/src/cairo-quartz-image-surface.c | 0 .../cairo/cairo-1.14.2/src/cairo-quartz-image.h | 0 .../cairo/cairo-1.14.2/src/cairo-quartz-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-quartz-surface.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-quartz.h | 0 .../cairo-1.14.2/src/cairo-raster-source-pattern.c | 0 .../src/cairo-recording-surface-inline.h | 0 .../src/cairo-recording-surface-private.h | 0 .../cairo-1.14.2/src/cairo-recording-surface.c | 0 .../libs/cairo/cairo-1.14.2/src/cairo-rectangle.c | 0 .../src/cairo-rectangular-scan-converter.c | 0 .../src/cairo-reference-count-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-region-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-region.c | 0 .../cairo/cairo-1.14.2/src/cairo-rtree-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-rtree.c | 0 .../cairo-1.14.2/src/cairo-scaled-font-private.h | 0 .../src/cairo-scaled-font-subsets-private.h | 0 .../cairo-1.14.2/src/cairo-scaled-font-subsets.c | 0 .../cairo/cairo-1.14.2/src/cairo-scaled-font.c | 0 .../cairo/cairo-1.14.2/src/cairo-script-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-script-surface.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-script.h | 0 .../cairo-1.14.2/src/cairo-shape-mask-compositor.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-skia.h | 0 .../cairo/cairo-1.14.2/src/cairo-slope-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-slope.c | 0 .../src/cairo-spans-compositor-private.h | 0 .../cairo-1.14.2/src/cairo-spans-compositor.c | 0 .../cairo/cairo-1.14.2/src/cairo-spans-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-spans.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-spline.c | 0 .../cairo-1.14.2/src/cairo-stroke-dash-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-stroke-dash.c | 0 .../cairo/cairo-1.14.2/src/cairo-stroke-style.c | 0 .../src/cairo-surface-backend-private.h | 0 .../src/cairo-surface-clipper-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-surface-clipper.c | 0 .../src/cairo-surface-fallback-private.h | 0 .../cairo-1.14.2/src/cairo-surface-fallback.c | 0 .../cairo/cairo-1.14.2/src/cairo-surface-inline.h | 0 .../src/cairo-surface-observer-inline.h | 0 .../src/cairo-surface-observer-private.h | 0 .../cairo-1.14.2/src/cairo-surface-observer.c | 0 .../src/cairo-surface-offset-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-surface-offset.c | 0 .../cairo/cairo-1.14.2/src/cairo-surface-private.h | 0 .../src/cairo-surface-snapshot-inline.h | 0 .../src/cairo-surface-snapshot-private.h | 0 .../cairo-1.14.2/src/cairo-surface-snapshot.c | 0 .../src/cairo-surface-subsurface-inline.h | 0 .../src/cairo-surface-subsurface-private.h | 0 .../cairo-1.14.2/src/cairo-surface-subsurface.c | 0 .../src/cairo-surface-wrapper-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-surface-wrapper.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-surface.c | 0 .../cairo-1.14.2/src/cairo-svg-surface-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-svg-surface.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-svg.h | 0 .../cairo-1.14.2/src/cairo-tee-surface-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-tee-surface.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-tee.h | 0 .../cairo/cairo-1.14.2/src/cairo-time-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-time.c | 0 .../cairo-1.14.2/src/cairo-tor-scan-converter.c | 0 .../cairo-1.14.2/src/cairo-tor22-scan-converter.c | 0 .../cairo/cairo-1.14.2/src/cairo-toy-font-face.c | 0 .../cairo-1.14.2/src/cairo-traps-compositor.c | 0 .../cairo/cairo-1.14.2/src/cairo-traps-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-traps.c | 0 .../cairo-1.14.2/src/cairo-tristrip-private.h | 0 .../libs/cairo/cairo-1.14.2/src/cairo-tristrip.c | 0 .../src/cairo-truetype-subset-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-truetype-subset.c | 0 .../cairo/cairo-1.14.2/src/cairo-type1-fallback.c | 0 .../cairo-1.14.2/src/cairo-type1-glyph-names.c | 0 .../cairo/cairo-1.14.2/src/cairo-type1-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-type1-subset.c | 0 .../src/cairo-type3-glyph-surface-private.h | 0 .../cairo-1.14.2/src/cairo-type3-glyph-surface.c | 0 .../cairo/cairo-1.14.2/src/cairo-types-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-unicode.c | 0 .../cairo/cairo-1.14.2/src/cairo-uninstalled.pc.in | 0 .../cairo-1.14.2/src/cairo-user-font-private.h | 0 .../libs/cairo/cairo-1.14.2/src/cairo-user-font.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-version.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-version.h | 0 .../libs/cairo/cairo-1.14.2/src/cairo-vg-surface.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-vg.h | 0 .../cairo/cairo-1.14.2/src/cairo-wgl-context.c | 0 .../cairo/cairo-1.14.2/src/cairo-wideint-private.h | 0 .../cairo-1.14.2/src/cairo-wideint-type-private.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-wideint.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-win32.h | 0 .../cairo-1.14.2/src/cairo-xcb-connection-core.c | 0 .../cairo-1.14.2/src/cairo-xcb-connection-render.c | 0 .../cairo-1.14.2/src/cairo-xcb-connection-shm.c | 0 .../cairo/cairo-1.14.2/src/cairo-xcb-connection.c | 0 .../cairo/cairo-1.14.2/src/cairo-xcb-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-xcb-resources.c | 0 .../libs/cairo/cairo-1.14.2/src/cairo-xcb-screen.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-xcb-shm.c | 0 .../cairo-1.14.2/src/cairo-xcb-surface-core.c | 0 .../cairo-1.14.2/src/cairo-xcb-surface-render.c | 0 .../cairo/cairo-1.14.2/src/cairo-xcb-surface.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-xcb.h | 0 .../cairo-1.14.2/src/cairo-xlib-core-compositor.c | 0 .../cairo/cairo-1.14.2/src/cairo-xlib-display.c | 0 .../src/cairo-xlib-fallback-compositor.c | 0 .../cairo/cairo-1.14.2/src/cairo-xlib-private.h | 0 .../src/cairo-xlib-render-compositor.c | 0 .../cairo/cairo-1.14.2/src/cairo-xlib-screen.c | 0 .../cairo/cairo-1.14.2/src/cairo-xlib-source.c | 0 .../cairo-1.14.2/src/cairo-xlib-surface-private.h | 0 .../cairo-1.14.2/src/cairo-xlib-surface-shm.c | 0 .../cairo/cairo-1.14.2/src/cairo-xlib-surface.c | 0 .../cairo/cairo-1.14.2/src/cairo-xlib-visual.c | 0 .../cairo-1.14.2/src/cairo-xlib-xcb-surface.c | 0 .../cairo-1.14.2/src/cairo-xlib-xrender-private.h | 0 .../cairo/cairo-1.14.2/src/cairo-xlib-xrender.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo-xlib.h | 0 .../cairo/cairo-1.14.2/src/cairo-xml-surface.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo-xml.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo.c | 0 source/libs/cairo/cairo-1.14.2/src/cairo.h | 0 source/libs/cairo/cairo-1.14.2/src/cairo.pc.in | 0 source/libs/cairo/cairo-1.14.2/src/cairoint.h | 0 .../cairo/cairo-1.14.2/src/check-doc-syntax.awk | 0 .../cairo-1.14.2/src/check-has-hidden-symbols.c | 0 source/libs/cairo/cairo-1.14.2/src/check-link.c | 0 .../src/test-base-compositor-surface.c | 0 .../src/test-compositor-surface-private.h | 0 .../cairo-1.14.2/src/test-compositor-surface.c | 0 .../cairo-1.14.2/src/test-compositor-surface.h | 0 .../src/test-null-compositor-surface.c | 0 .../src/test-null-compositor-surface.h | 0 .../cairo-1.14.2/src/test-paginated-surface.c | 0 .../cairo-1.14.2/src/test-paginated-surface.h | 0 source/libs/cairo/configure | 6 +- source/libs/configure | 104 +- source/libs/gmp/configure | 6 +- source/libs/gmp/native/configure | 6 +- source/libs/libpng/configure | 6 +- source/libs/libpng/libpng-1.6.17-PATCHES/ChangeLog | 0 .../libs/libpng/libpng-1.6.17-PATCHES/TL-Changes | 0 source/libs/libpng/libpng-1.6.17/ANNOUNCE | 0 source/libs/libpng/libpng-1.6.17/CHANGES | 0 source/libs/libpng/libpng-1.6.17/CMakeLists.txt | 0 source/libs/libpng/libpng-1.6.17/INSTALL | 0 source/libs/libpng/libpng-1.6.17/LICENSE | 0 source/libs/libpng/libpng-1.6.17/Makefile.am | 0 source/libs/libpng/libpng-1.6.17/README | 0 source/libs/libpng/libpng-1.6.17/TODO | 0 source/libs/libpng/libpng-1.6.17/arm/arm_init.c | 0 source/libs/libpng/libpng-1.6.17/arm/filter_neon.S | 0 .../libpng-1.6.17/arm/filter_neon_intrinsics.c | 0 source/libs/libpng/libpng-1.6.17/config.h.in | 0 source/libs/libpng/libpng-1.6.17/configure.ac | 0 .../libs/libpng/libpng-1.6.17/contrib/README.txt | 0 .../libpng/libpng-1.6.17/contrib/arm-neon/README | 0 .../libpng-1.6.17/contrib/arm-neon/android-ndk.c | 0 .../libpng-1.6.17/contrib/arm-neon/linux-auxv.c | 0 .../libpng/libpng-1.6.17/contrib/arm-neon/linux.c | 0 .../libpng/libpng-1.6.17/contrib/conftest/README | 0 .../libpng/libpng-1.6.17/contrib/conftest/read.dfa | 0 .../libpng-1.6.17/contrib/conftest/s_read.dfa | 0 .../libpng-1.6.17/contrib/conftest/s_write.dfa | 0 .../libpng-1.6.17/contrib/conftest/simple.dfa | 0 .../libpng-1.6.17/contrib/conftest/write.dfa | 0 .../libpng-1.6.17/contrib/examples/README.txt | 0 .../libpng-1.6.17/contrib/examples/iccfrompng.c | 0 .../libpng-1.6.17/contrib/examples/pngpixel.c | 0 .../libpng-1.6.17/contrib/examples/pngtopng.c | 0 .../libpng/libpng-1.6.17/contrib/gregbook/COPYING | 0 .../libpng/libpng-1.6.17/contrib/gregbook/LICENSE | 0 .../contrib/gregbook/Makefile.mingw32 | 0 .../libpng-1.6.17/contrib/gregbook/Makefile.sgi | 0 .../libpng-1.6.17/contrib/gregbook/Makefile.unx | 0 .../libpng-1.6.17/contrib/gregbook/Makefile.w32 | 0 .../libpng/libpng-1.6.17/contrib/gregbook/README | 0 .../libpng-1.6.17/contrib/gregbook/makevms.com | 0 .../libpng-1.6.17/contrib/gregbook/readpng.c | 0 .../libpng-1.6.17/contrib/gregbook/readpng.h | 0 .../libpng-1.6.17/contrib/gregbook/readpng2.c | 0 .../libpng-1.6.17/contrib/gregbook/readpng2.h | 0 .../libpng-1.6.17/contrib/gregbook/readppm.c | 0 .../libpng-1.6.17/contrib/gregbook/rpng-win.c | 0 .../libpng/libpng-1.6.17/contrib/gregbook/rpng-x.c | 0 .../libpng-1.6.17/contrib/gregbook/rpng2-win.c | 0 .../libpng-1.6.17/contrib/gregbook/rpng2-x.c | 0 .../libpng-1.6.17/contrib/gregbook/toucan.png | Bin .../libpng/libpng-1.6.17/contrib/gregbook/wpng.c | 0 .../libpng-1.6.17/contrib/gregbook/writepng.c | 0 .../libpng-1.6.17/contrib/gregbook/writepng.h | 0 .../libpng-1.6.17/contrib/libtests/fakepng.c | 0 .../libpng-1.6.17/contrib/libtests/makepng.c | 0 .../libpng-1.6.17/contrib/libtests/pngimage.c | 0 .../libpng-1.6.17/contrib/libtests/pngstest.c | 0 .../libpng-1.6.17/contrib/libtests/pngunknown.c | 0 .../libpng-1.6.17/contrib/libtests/pngvalid.c | 0 .../libpng-1.6.17/contrib/libtests/readpng.c | 0 .../libpng/libpng-1.6.17/contrib/libtests/tarith.c | 0 .../libpng-1.6.17/contrib/libtests/timepng.c | 0 .../libpng/libpng-1.6.17/contrib/pngminim/README | 0 .../libpng-1.6.17/contrib/pngminim/decoder/README | 0 .../contrib/pngminim/decoder/makefile | 0 .../contrib/pngminim/decoder/pngusr.dfa | 0 .../contrib/pngminim/decoder/pngusr.h | 0 .../libpng-1.6.17/contrib/pngminim/encoder/README | 0 .../contrib/pngminim/encoder/makefile | 0 .../contrib/pngminim/encoder/pngusr.dfa | 0 .../contrib/pngminim/encoder/pngusr.h | 0 .../libpng-1.6.17/contrib/pngminim/preader/README | 0 .../contrib/pngminim/preader/makefile | 0 .../contrib/pngminim/preader/pngusr.dfa | 0 .../contrib/pngminim/preader/pngusr.h | 0 .../libpng/libpng-1.6.17/contrib/pngminus/README | 0 .../libpng-1.6.17/contrib/pngminus/makefile.std | 0 .../libpng-1.6.17/contrib/pngminus/makefile.tc3 | 0 .../libpng-1.6.17/contrib/pngminus/makevms.com | 0 .../libpng-1.6.17/contrib/pngminus/png2pnm.bat | 0 .../libpng-1.6.17/contrib/pngminus/png2pnm.c | 0 .../libpng-1.6.17/contrib/pngminus/pngminus.bat | 0 .../libpng-1.6.17/contrib/pngminus/pnm2png.bat | 0 .../libpng-1.6.17/contrib/pngminus/pnm2png.c | 0 .../libpng/libpng-1.6.17/contrib/pngsuite/README | 0 .../libpng-1.6.17/contrib/pngsuite/basn0g01.png | Bin .../libpng-1.6.17/contrib/pngsuite/basn0g02.png | Bin .../libpng-1.6.17/contrib/pngsuite/basn0g04.png | Bin .../libpng-1.6.17/contrib/pngsuite/basn0g08.png | Bin .../libpng-1.6.17/contrib/pngsuite/basn0g16.png | Bin .../libpng-1.6.17/contrib/pngsuite/basn2c08.png | Bin .../libpng-1.6.17/contrib/pngsuite/basn2c16.png | Bin .../libpng-1.6.17/contrib/pngsuite/basn3p01.png | Bin .../libpng-1.6.17/contrib/pngsuite/basn3p02.png | Bin .../libpng-1.6.17/contrib/pngsuite/basn3p04.png | Bin .../libpng-1.6.17/contrib/pngsuite/basn3p08.png | Bin .../libpng-1.6.17/contrib/pngsuite/basn4a08.png | Bin .../libpng-1.6.17/contrib/pngsuite/basn4a16.png | Bin .../libpng-1.6.17/contrib/pngsuite/basn6a08.png | Bin .../libpng-1.6.17/contrib/pngsuite/basn6a16.png | Bin .../libpng-1.6.17/contrib/pngsuite/ftbbn0g01.png | Bin .../libpng-1.6.17/contrib/pngsuite/ftbbn0g02.png | Bin .../libpng-1.6.17/contrib/pngsuite/ftbbn0g04.png | Bin .../libpng-1.6.17/contrib/pngsuite/ftbbn2c16.png | Bin .../libpng-1.6.17/contrib/pngsuite/ftbbn3p08.png | Bin .../libpng-1.6.17/contrib/pngsuite/ftbgn2c16.png | Bin .../libpng-1.6.17/contrib/pngsuite/ftbgn3p08.png | Bin .../libpng-1.6.17/contrib/pngsuite/ftbrn2c08.png | Bin .../libpng-1.6.17/contrib/pngsuite/ftbwn0g16.png | Bin .../libpng-1.6.17/contrib/pngsuite/ftbwn3p08.png | Bin .../libpng-1.6.17/contrib/pngsuite/ftbyn3p08.png | Bin .../libpng-1.6.17/contrib/pngsuite/ftp0n0g08.png | Bin .../libpng-1.6.17/contrib/pngsuite/ftp0n2c08.png | Bin .../libpng-1.6.17/contrib/pngsuite/ftp0n3p08.png | Bin .../libpng-1.6.17/contrib/pngsuite/ftp1n3p08.png | Bin .../libpng/libpng-1.6.17/contrib/tools/README.txt | 0 .../libpng-1.6.17/contrib/tools/checksum-icc.c | 0 .../libs/libpng/libpng-1.6.17/contrib/tools/chkfmt | 0 .../libpng/libpng-1.6.17/contrib/tools/cvtcolor.c | 0 .../libpng/libpng-1.6.17/contrib/tools/makesRGB.c | 0 .../libpng-1.6.17/contrib/tools/png-fix-itxt.c | 0 .../libpng/libpng-1.6.17/contrib/tools/pngfix.c | 0 .../libs/libpng/libpng-1.6.17/contrib/tools/sRGB.h | 0 .../libpng/libpng-1.6.17/contrib/visupng/PngFile.c | 0 .../libpng/libpng-1.6.17/contrib/visupng/PngFile.h | 0 .../libpng-1.6.17/contrib/visupng/README.txt | 0 .../libpng-1.6.17/contrib/visupng/VisualPng.c | 0 .../libpng-1.6.17/contrib/visupng/VisualPng.dsp | 0 .../libpng-1.6.17/contrib/visupng/VisualPng.dsw | 0 .../libpng-1.6.17/contrib/visupng/VisualPng.ico | Bin .../libpng-1.6.17/contrib/visupng/VisualPng.png | Bin .../libpng-1.6.17/contrib/visupng/VisualPng.rc | 0 .../libpng/libpng-1.6.17/contrib/visupng/cexcept.h | 0 .../libpng-1.6.17/contrib/visupng/resource.h | 0 source/libs/libpng/libpng-1.6.17/example.c | 0 source/libs/libpng/libpng-1.6.17/libpng-config.in | 0 source/libs/libpng/libpng-1.6.17/libpng-manual.txt | 0 source/libs/libpng/libpng-1.6.17/libpng.3 | 0 source/libs/libpng/libpng-1.6.17/libpng.pc.in | 0 source/libs/libpng/libpng-1.6.17/libpngpf.3 | 0 source/libs/libpng/libpng-1.6.17/png.5 | 0 source/libs/libpng/libpng-1.6.17/png.c | 0 source/libs/libpng/libpng-1.6.17/png.h | 0 source/libs/libpng/libpng-1.6.17/pngbar.jpg | Bin source/libs/libpng/libpng-1.6.17/pngbar.png | Bin source/libs/libpng/libpng-1.6.17/pngconf.h | 0 source/libs/libpng/libpng-1.6.17/pngdebug.h | 0 source/libs/libpng/libpng-1.6.17/pngerror.c | 0 source/libs/libpng/libpng-1.6.17/pngget.c | 0 source/libs/libpng/libpng-1.6.17/pnginfo.h | 0 source/libs/libpng/libpng-1.6.17/pnglibconf.h | 0 source/libs/libpng/libpng-1.6.17/pngmem.c | 0 source/libs/libpng/libpng-1.6.17/pngnow.png | Bin source/libs/libpng/libpng-1.6.17/pngpread.c | 0 source/libs/libpng/libpng-1.6.17/pngpriv.h | 0 source/libs/libpng/libpng-1.6.17/pngread.c | 0 source/libs/libpng/libpng-1.6.17/pngrio.c | 0 source/libs/libpng/libpng-1.6.17/pngrtran.c | 0 source/libs/libpng/libpng-1.6.17/pngrutil.c | 0 source/libs/libpng/libpng-1.6.17/pngset.c | 0 source/libs/libpng/libpng-1.6.17/pngstruct.h | 0 source/libs/libpng/libpng-1.6.17/pngtest.c | 0 source/libs/libpng/libpng-1.6.17/pngtest.png | Bin source/libs/libpng/libpng-1.6.17/pngtrans.c | 0 source/libs/libpng/libpng-1.6.17/pngusr.dfa | 0 source/libs/libpng/libpng-1.6.17/pngwio.c | 0 source/libs/libpng/libpng-1.6.17/pngwrite.c | 0 source/libs/libpng/libpng-1.6.17/pngwtran.c | 0 source/libs/libpng/libpng-1.6.17/pngwutil.c | 0 .../libpng-1.6.17/projects/owatcom/libpng.tgt | 0 .../libpng-1.6.17/projects/owatcom/libpng.wpj | 0 .../libpng-1.6.17/projects/owatcom/pngconfig.mak | 0 .../libpng-1.6.17/projects/owatcom/pngstest.tgt | 0 .../libpng-1.6.17/projects/owatcom/pngtest.tgt | 0 .../libpng-1.6.17/projects/owatcom/pngvalid.tgt | 0 .../libpng-1.6.17/projects/visualc71/PRJ0041.mak | 0 .../libpng-1.6.17/projects/visualc71/README.txt | 0 .../projects/visualc71/README_zlib.txt | 0 .../libpng-1.6.17/projects/visualc71/libpng.sln | 0 .../libpng-1.6.17/projects/visualc71/libpng.vcproj | 0 .../projects/visualc71/pngtest.vcproj | 0 .../libpng-1.6.17/projects/visualc71/zlib.vcproj | 0 .../libpng/libpng-1.6.17/projects/vstudio/WARNING | 0 .../projects/vstudio/libpng/libpng.vcxproj | 0 .../projects/vstudio/pnglibconf/pnglibconf.vcxproj | 0 .../projects/vstudio/pngstest/pngstest.vcxproj | 0 .../projects/vstudio/pngtest/pngtest.vcxproj | 0 .../projects/vstudio/pngunknown/pngunknown.vcxproj | 0 .../projects/vstudio/pngvalid/pngvalid.vcxproj | 0 .../libpng-1.6.17/projects/vstudio/readme.txt | 0 .../libpng-1.6.17/projects/vstudio/vstudio.sln | 0 .../libpng-1.6.17/projects/vstudio/zlib.props | 0 .../projects/vstudio/zlib/zlib.vcxproj | 0 .../libs/libpng/libpng-1.6.17/scripts/README.txt | 0 .../libpng/libpng-1.6.17/scripts/SCOPTIONS.ppc | 0 .../libs/libpng/libpng-1.6.17/scripts/checksym.awk | 0 source/libs/libpng/libpng-1.6.17/scripts/def.c | 0 .../libs/libpng/libpng-1.6.17/scripts/descrip.mms | 0 source/libs/libpng/libpng-1.6.17/scripts/dfn.awk | 0 .../libs/libpng/libpng-1.6.17/scripts/intprefix.c | 0 .../libpng-1.6.17/scripts/libpng-config-body.in | 0 .../libpng-1.6.17/scripts/libpng-config-head.in | 0 .../libs/libpng/libpng-1.6.17/scripts/libpng.pc.in | 0 .../libs/libpng/libpng-1.6.17/scripts/libtool.m4 | 0 .../libs/libpng/libpng-1.6.17/scripts/ltoptions.m4 | 0 .../libs/libpng/libpng-1.6.17/scripts/ltsugar.m4 | 0 .../libs/libpng/libpng-1.6.17/scripts/ltversion.m4 | 0 .../libpng/libpng-1.6.17/scripts/lt~obsolete.m4 | 0 source/libs/libpng/libpng-1.6.17/scripts/macro.lst | 0 .../libpng/libpng-1.6.17/scripts/makefile.32sunu | 0 .../libpng/libpng-1.6.17/scripts/makefile.64sunu | 0 .../libpng/libpng-1.6.17/scripts/makefile.acorn | 0 .../libs/libpng/libpng-1.6.17/scripts/makefile.aix | 0 .../libpng/libpng-1.6.17/scripts/makefile.amiga | 0 .../libpng/libpng-1.6.17/scripts/makefile.atari | 0 .../libpng/libpng-1.6.17/scripts/makefile.bc32 | 0 .../libpng/libpng-1.6.17/scripts/makefile.beos | 0 .../libs/libpng/libpng-1.6.17/scripts/makefile.bor | 0 .../libpng/libpng-1.6.17/scripts/makefile.cegcc | 0 .../libpng/libpng-1.6.17/scripts/makefile.darwin | 0 .../libs/libpng/libpng-1.6.17/scripts/makefile.dec | 0 .../libs/libpng/libpng-1.6.17/scripts/makefile.dj2 | 0 .../libpng/libpng-1.6.17/scripts/makefile.freebsd | 0 .../libs/libpng/libpng-1.6.17/scripts/makefile.gcc | 0 .../libpng/libpng-1.6.17/scripts/makefile.hp64 | 0 .../libpng/libpng-1.6.17/scripts/makefile.hpgcc | 0 .../libpng/libpng-1.6.17/scripts/makefile.hpux | 0 .../libpng/libpng-1.6.17/scripts/makefile.ibmc | 0 .../libpng/libpng-1.6.17/scripts/makefile.intel | 0 .../libs/libpng/libpng-1.6.17/scripts/makefile.knr | 0 .../libpng/libpng-1.6.17/scripts/makefile.linux | 0 .../libpng/libpng-1.6.17/scripts/makefile.mips | 0 .../libs/libpng/libpng-1.6.17/scripts/makefile.msc | 0 .../libpng/libpng-1.6.17/scripts/makefile.msys | 0 .../libpng/libpng-1.6.17/scripts/makefile.ne12bsd | 0 .../libpng/libpng-1.6.17/scripts/makefile.netbsd | 0 .../libpng/libpng-1.6.17/scripts/makefile.openbsd | 0 .../libs/libpng/libpng-1.6.17/scripts/makefile.sco | 0 .../libpng/libpng-1.6.17/scripts/makefile.sggcc | 0 .../libs/libpng/libpng-1.6.17/scripts/makefile.sgi | 0 .../libs/libpng/libpng-1.6.17/scripts/makefile.so9 | 0 .../libpng/libpng-1.6.17/scripts/makefile.solaris | 0 .../libpng-1.6.17/scripts/makefile.solaris-x86 | 0 .../libs/libpng/libpng-1.6.17/scripts/makefile.std | 0 .../libpng/libpng-1.6.17/scripts/makefile.sunos | 0 .../libs/libpng/libpng-1.6.17/scripts/makefile.tc3 | 0 .../libpng/libpng-1.6.17/scripts/makefile.vcwin32 | 0 .../libs/libpng/libpng-1.6.17/scripts/makevms.com | 0 .../libs/libpng/libpng-1.6.17/scripts/options.awk | 0 .../libpng/libpng-1.6.17/scripts/pnglibconf.dfa | 0 .../libpng-1.6.17/scripts/pnglibconf.h.prebuilt | 0 .../libpng/libpng-1.6.17/scripts/pnglibconf.mak | 0 source/libs/libpng/libpng-1.6.17/scripts/pngwin.rc | 0 source/libs/libpng/libpng-1.6.17/scripts/prefix.c | 0 .../libpng/libpng-1.6.17/scripts/smakefile.ppc | 0 source/libs/libpng/libpng-1.6.17/scripts/sym.c | 0 source/libs/libpng/libpng-1.6.17/scripts/symbols.c | 0 .../libs/libpng/libpng-1.6.17/scripts/symbols.def | 0 source/libs/libpng/libpng-1.6.17/scripts/vers.c | 0 .../libs/libpng/libpng-1.6.17/tests/pngimage-full | 0 .../libs/libpng/libpng-1.6.17/tests/pngimage-quick | 0 source/libs/libpng/libpng-1.6.17/tests/pngstest | 0 .../libs/libpng/libpng-1.6.17/tests/pngstest-0g01 | 0 .../libs/libpng/libpng-1.6.17/tests/pngstest-0g02 | 0 .../libs/libpng/libpng-1.6.17/tests/pngstest-0g04 | 0 .../libs/libpng/libpng-1.6.17/tests/pngstest-0g08 | 0 .../libs/libpng/libpng-1.6.17/tests/pngstest-0g16 | 0 .../libs/libpng/libpng-1.6.17/tests/pngstest-2c08 | 0 .../libs/libpng/libpng-1.6.17/tests/pngstest-2c16 | 0 .../libs/libpng/libpng-1.6.17/tests/pngstest-3p01 | 0 .../libs/libpng/libpng-1.6.17/tests/pngstest-3p02 | 0 .../libs/libpng/libpng-1.6.17/tests/pngstest-3p04 | 0 .../libs/libpng/libpng-1.6.17/tests/pngstest-3p08 | 0 .../libs/libpng/libpng-1.6.17/tests/pngstest-4a08 | 0 .../libs/libpng/libpng-1.6.17/tests/pngstest-4a16 | 0 .../libs/libpng/libpng-1.6.17/tests/pngstest-6a08 | 0 .../libs/libpng/libpng-1.6.17/tests/pngstest-6a16 | 0 .../libs/libpng/libpng-1.6.17/tests/pngstest-error | 0 source/libs/libpng/libpng-1.6.17/tests/pngtest | 0 .../libpng/libpng-1.6.17/tests/pngunknown-IDAT | 0 .../libpng/libpng-1.6.17/tests/pngunknown-discard | 0 .../libpng/libpng-1.6.17/tests/pngunknown-if-safe | 0 .../libpng/libpng-1.6.17/tests/pngunknown-sAPI | 0 .../libpng/libpng-1.6.17/tests/pngunknown-sTER | 0 .../libpng/libpng-1.6.17/tests/pngunknown-save | 0 .../libpng/libpng-1.6.17/tests/pngunknown-vpAg | 0 .../libpng-1.6.17/tests/pngvalid-gamma-16-to-8 | 0 .../libpng-1.6.17/tests/pngvalid-gamma-alpha-mode | 0 .../libpng-1.6.17/tests/pngvalid-gamma-background | 0 .../tests/pngvalid-gamma-expand16-alpha-mode | 0 .../tests/pngvalid-gamma-expand16-background | 0 .../tests/pngvalid-gamma-expand16-transform | 0 .../libpng/libpng-1.6.17/tests/pngvalid-gamma-sbit | 0 .../libpng-1.6.17/tests/pngvalid-gamma-threshold | 0 .../libpng-1.6.17/tests/pngvalid-gamma-transform | 0 .../tests/pngvalid-progressive-interlace-size | 0 .../tests/pngvalid-progressive-interlace-standard | 0 .../tests/pngvalid-progressive-interlace-transform | 0 .../tests/pngvalid-progressive-standard | 0 .../libpng/libpng-1.6.17/tests/pngvalid-standard | 0 source/libs/lua52/configure | 6 +- source/libs/luajit/ChangeLog | 5 + .../luajit/LuaJIT-2.0.3-PATCHES/patch-01-LuaJITTeX | 175 - .../luajit/LuaJIT-2.0.3-PATCHES/patch-05-LuaJITTeX | 107 - .../LuaJIT-2.0.3-PATCHES/patch-06-ppc-darwin | 24 - source/libs/luajit/LuaJIT-2.0.3/COPYRIGHT | 56 - source/libs/luajit/LuaJIT-2.0.3/Makefile | 151 - source/libs/luajit/LuaJIT-2.0.3/README | 16 - .../luajit/LuaJIT-2.0.3/doc/bluequad-print.css | 166 - source/libs/luajit/LuaJIT-2.0.3/doc/bluequad.css | 325 - source/libs/luajit/LuaJIT-2.0.3/doc/changes.html | 928 - source/libs/luajit/LuaJIT-2.0.3/doc/contact.html | 102 - source/libs/luajit/LuaJIT-2.0.3/doc/ext_c_api.html | 187 - source/libs/luajit/LuaJIT-2.0.3/doc/ext_ffi.html | 330 - .../libs/luajit/LuaJIT-2.0.3/doc/ext_ffi_api.html | 566 - .../luajit/LuaJIT-2.0.3/doc/ext_ffi_semantics.html | 1245 - .../luajit/LuaJIT-2.0.3/doc/ext_ffi_tutorial.html | 601 - source/libs/luajit/LuaJIT-2.0.3/doc/ext_jit.html | 199 - .../libs/luajit/LuaJIT-2.0.3/doc/extensions.html | 408 - source/libs/luajit/LuaJIT-2.0.3/doc/faq.html | 184 - source/libs/luajit/LuaJIT-2.0.3/doc/install.html | 631 - source/libs/luajit/LuaJIT-2.0.3/doc/luajit.html | 228 - source/libs/luajit/LuaJIT-2.0.3/doc/running.html | 306 - source/libs/luajit/LuaJIT-2.0.3/doc/status.html | 125 - source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_arm.h | 456 - .../libs/luajit/LuaJIT-2.0.3/dynasm/dasm_arm.lua | 1122 - source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_mips.h | 416 - .../libs/luajit/LuaJIT-2.0.3/dynasm/dasm_mips.lua | 953 - source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_ppc.h | 412 - .../libs/luajit/LuaJIT-2.0.3/dynasm/dasm_ppc.lua | 1249 - .../libs/luajit/LuaJIT-2.0.3/dynasm/dasm_proto.h | 83 - .../libs/luajit/LuaJIT-2.0.3/dynasm/dasm_x64.lua | 12 - source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_x86.h | 471 - .../libs/luajit/LuaJIT-2.0.3/dynasm/dasm_x86.lua | 1937 - source/libs/luajit/LuaJIT-2.0.3/dynasm/dynasm.lua | 1094 - source/libs/luajit/LuaJIT-2.0.3/etc/luajit.1 | 88 - source/libs/luajit/LuaJIT-2.0.3/etc/luajit.pc | 25 - source/libs/luajit/LuaJIT-2.0.3/src/Makefile | 686 - source/libs/luajit/LuaJIT-2.0.3/src/Makefile.dep | 227 - source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm.c | 516 - source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm.h | 104 - .../luajit/LuaJIT-2.0.3/src/host/buildvm_asm.c | 313 - .../luajit/LuaJIT-2.0.3/src/host/buildvm_fold.c | 229 - .../luajit/LuaJIT-2.0.3/src/host/buildvm_lib.c | 398 - .../luajit/LuaJIT-2.0.3/src/host/buildvm_peobj.c | 368 - .../luajit/LuaJIT-2.0.3/src/host/genminilua.lua | 428 - source/libs/luajit/LuaJIT-2.0.3/src/jit/bc.lua | 191 - source/libs/luajit/LuaJIT-2.0.3/src/jit/bcsave.lua | 659 - .../libs/luajit/LuaJIT-2.0.3/src/jit/dis_arm.lua | 689 - .../libs/luajit/LuaJIT-2.0.3/src/jit/dis_mips.lua | 428 - .../luajit/LuaJIT-2.0.3/src/jit/dis_mipsel.lua | 20 - .../libs/luajit/LuaJIT-2.0.3/src/jit/dis_ppc.lua | 591 - .../libs/luajit/LuaJIT-2.0.3/src/jit/dis_x64.lua | 20 - .../libs/luajit/LuaJIT-2.0.3/src/jit/dis_x86.lua | 836 - source/libs/luajit/LuaJIT-2.0.3/src/jit/dump.lua | 699 - source/libs/luajit/LuaJIT-2.0.3/src/jit/v.lua | 167 - source/libs/luajit/LuaJIT-2.0.3/src/lib_aux.c | 356 - source/libs/luajit/LuaJIT-2.0.3/src/lib_base.c | 683 - source/libs/luajit/LuaJIT-2.0.3/src/lib_bit.c | 74 - source/libs/luajit/LuaJIT-2.0.3/src/lib_debug.c | 405 - source/libs/luajit/LuaJIT-2.0.3/src/lib_ffi.c | 850 - source/libs/luajit/LuaJIT-2.0.3/src/lib_init.c | 56 - source/libs/luajit/LuaJIT-2.0.3/src/lib_io.c | 539 - source/libs/luajit/LuaJIT-2.0.3/src/lib_jit.c | 663 - source/libs/luajit/LuaJIT-2.0.3/src/lib_math.c | 233 - source/libs/luajit/LuaJIT-2.0.3/src/lib_os.c | 280 - source/libs/luajit/LuaJIT-2.0.3/src/lib_package.c | 640 - source/libs/luajit/LuaJIT-2.0.3/src/lib_string.c | 940 - source/libs/luajit/LuaJIT-2.0.3/src/lib_table.c | 300 - source/libs/luajit/LuaJIT-2.0.3/src/lj_alloc.c | 1390 - source/libs/luajit/LuaJIT-2.0.3/src/lj_api.c | 1200 - source/libs/luajit/LuaJIT-2.0.3/src/lj_arch.h | 426 - source/libs/luajit/LuaJIT-2.0.3/src/lj_asm.c | 1914 - source/libs/luajit/LuaJIT-2.0.3/src/lj_asm.h | 17 - source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_arm.h | 2361 - source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_mips.h | 1977 - source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_ppc.h | 2167 - source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_x86.h | 2794 - source/libs/luajit/LuaJIT-2.0.3/src/lj_bc.c | 14 - source/libs/luajit/LuaJIT-2.0.3/src/lj_bc.h | 261 - source/libs/luajit/LuaJIT-2.0.3/src/lj_bcdump.h | 66 - source/libs/luajit/LuaJIT-2.0.3/src/lj_bcread.c | 476 - source/libs/luajit/LuaJIT-2.0.3/src/lj_bcwrite.c | 396 - source/libs/luajit/LuaJIT-2.0.3/src/lj_carith.c | 351 - source/libs/luajit/LuaJIT-2.0.3/src/lj_carith.h | 27 - source/libs/luajit/LuaJIT-2.0.3/src/lj_ccall.c | 900 - source/libs/luajit/LuaJIT-2.0.3/src/lj_ccall.h | 171 - source/libs/luajit/LuaJIT-2.0.3/src/lj_ccallback.c | 644 - source/libs/luajit/LuaJIT-2.0.3/src/lj_ccallback.h | 25 - source/libs/luajit/LuaJIT-2.0.3/src/lj_cconv.c | 751 - source/libs/luajit/LuaJIT-2.0.3/src/lj_cconv.h | 70 - source/libs/luajit/LuaJIT-2.0.3/src/lj_cdata.c | 285 - source/libs/luajit/LuaJIT-2.0.3/src/lj_cdata.h | 75 - source/libs/luajit/LuaJIT-2.0.3/src/lj_clib.c | 409 - source/libs/luajit/LuaJIT-2.0.3/src/lj_clib.h | 29 - source/libs/luajit/LuaJIT-2.0.3/src/lj_cparse.c | 1872 - source/libs/luajit/LuaJIT-2.0.3/src/lj_cparse.h | 65 - source/libs/luajit/LuaJIT-2.0.3/src/lj_crecord.c | 1653 - source/libs/luajit/LuaJIT-2.0.3/src/lj_crecord.h | 31 - source/libs/luajit/LuaJIT-2.0.3/src/lj_ctype.c | 634 - source/libs/luajit/LuaJIT-2.0.3/src/lj_ctype.h | 461 - source/libs/luajit/LuaJIT-2.0.3/src/lj_debug.c | 603 - source/libs/luajit/LuaJIT-2.0.3/src/lj_debug.h | 61 - source/libs/luajit/LuaJIT-2.0.3/src/lj_def.h | 349 - source/libs/luajit/LuaJIT-2.0.3/src/lj_dispatch.c | 494 - source/libs/luajit/LuaJIT-2.0.3/src/lj_dispatch.h | 131 - source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_arm.h | 356 - source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_mips.h | 211 - source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_ppc.h | 238 - source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_x86.h | 466 - source/libs/luajit/LuaJIT-2.0.3/src/lj_err.c | 785 - source/libs/luajit/LuaJIT-2.0.3/src/lj_err.h | 41 - source/libs/luajit/LuaJIT-2.0.3/src/lj_errmsg.h | 193 - source/libs/luajit/LuaJIT-2.0.3/src/lj_ff.h | 18 - source/libs/luajit/LuaJIT-2.0.3/src/lj_ffrecord.c | 888 - source/libs/luajit/LuaJIT-2.0.3/src/lj_ffrecord.h | 24 - source/libs/luajit/LuaJIT-2.0.3/src/lj_frame.h | 183 - source/libs/luajit/LuaJIT-2.0.3/src/lj_func.c | 185 - source/libs/luajit/LuaJIT-2.0.3/src/lj_func.h | 24 - source/libs/luajit/LuaJIT-2.0.3/src/lj_gc.c | 849 - source/libs/luajit/LuaJIT-2.0.3/src/lj_gc.h | 134 - source/libs/luajit/LuaJIT-2.0.3/src/lj_gdbjit.c | 793 - source/libs/luajit/LuaJIT-2.0.3/src/lj_gdbjit.h | 22 - source/libs/luajit/LuaJIT-2.0.3/src/lj_ir.c | 501 - source/libs/luajit/LuaJIT-2.0.3/src/lj_ir.h | 551 - source/libs/luajit/LuaJIT-2.0.3/src/lj_ircall.h | 271 - source/libs/luajit/LuaJIT-2.0.3/src/lj_iropt.h | 161 - source/libs/luajit/LuaJIT-2.0.3/src/lj_jit.h | 416 - source/libs/luajit/LuaJIT-2.0.3/src/lj_lex.c | 481 - source/libs/luajit/LuaJIT-2.0.3/src/lj_lex.h | 85 - source/libs/luajit/LuaJIT-2.0.3/src/lj_lib.c | 258 - source/libs/luajit/LuaJIT-2.0.3/src/lj_lib.h | 112 - source/libs/luajit/LuaJIT-2.0.3/src/lj_load.c | 168 - source/libs/luajit/LuaJIT-2.0.3/src/lj_mcode.c | 373 - source/libs/luajit/LuaJIT-2.0.3/src/lj_mcode.h | 30 - source/libs/luajit/LuaJIT-2.0.3/src/lj_meta.c | 466 - source/libs/luajit/LuaJIT-2.0.3/src/lj_meta.h | 37 - source/libs/luajit/LuaJIT-2.0.3/src/lj_obj.c | 35 - source/libs/luajit/LuaJIT-2.0.3/src/lj_obj.h | 856 - source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_dce.c | 77 - source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_fold.c | 2297 - source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_loop.c | 436 - source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_mem.c | 917 - .../libs/luajit/LuaJIT-2.0.3/src/lj_opt_narrow.c | 648 - source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_sink.c | 245 - source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_split.c | 731 - source/libs/luajit/LuaJIT-2.0.3/src/lj_parse.c | 2752 - source/libs/luajit/LuaJIT-2.0.3/src/lj_parse.h | 18 - source/libs/luajit/LuaJIT-2.0.3/src/lj_record.c | 2248 - source/libs/luajit/LuaJIT-2.0.3/src/lj_record.h | 44 - source/libs/luajit/LuaJIT-2.0.3/src/lj_snap.c | 865 - source/libs/luajit/LuaJIT-2.0.3/src/lj_snap.h | 34 - source/libs/luajit/LuaJIT-2.0.3/src/lj_state.c | 287 - source/libs/luajit/LuaJIT-2.0.3/src/lj_state.h | 35 - source/libs/luajit/LuaJIT-2.0.3/src/lj_str.c | 366 - source/libs/luajit/LuaJIT-2.0.3/src/lj_str.h | 50 - source/libs/luajit/LuaJIT-2.0.3/src/lj_strscan.c | 497 - source/libs/luajit/LuaJIT-2.0.3/src/lj_strscan.h | 39 - source/libs/luajit/LuaJIT-2.0.3/src/lj_tab.c | 631 - source/libs/luajit/LuaJIT-2.0.3/src/lj_tab.h | 70 - source/libs/luajit/LuaJIT-2.0.3/src/lj_target.h | 162 - .../libs/luajit/LuaJIT-2.0.3/src/lj_target_arm.h | 274 - .../libs/luajit/LuaJIT-2.0.3/src/lj_target_mips.h | 257 - .../libs/luajit/LuaJIT-2.0.3/src/lj_target_ppc.h | 280 - .../libs/luajit/LuaJIT-2.0.3/src/lj_target_x86.h | 342 - source/libs/luajit/LuaJIT-2.0.3/src/lj_trace.c | 815 - source/libs/luajit/LuaJIT-2.0.3/src/lj_trace.h | 53 - source/libs/luajit/LuaJIT-2.0.3/src/lj_traceerr.h | 61 - source/libs/luajit/LuaJIT-2.0.3/src/lj_udata.c | 34 - source/libs/luajit/LuaJIT-2.0.3/src/lj_udata.h | 14 - source/libs/luajit/LuaJIT-2.0.3/src/lj_vm.h | 116 - source/libs/luajit/LuaJIT-2.0.3/src/lj_vmevent.c | 57 - source/libs/luajit/LuaJIT-2.0.3/src/lj_vmevent.h | 59 - source/libs/luajit/LuaJIT-2.0.3/src/lj_vmmath.c | 140 - source/libs/luajit/LuaJIT-2.0.3/src/ljamalg.c | 93 - source/libs/luajit/LuaJIT-2.0.3/src/luaconf.h | 156 - source/libs/luajit/LuaJIT-2.0.3/src/luajit.c | 571 - source/libs/luajit/LuaJIT-2.0.3/src/luajit.h | 70 - source/libs/luajit/LuaJIT-2.0.3/src/lualib.h | 47 - source/libs/luajit/LuaJIT-2.0.3/src/msvcbuild.bat | 113 - source/libs/luajit/LuaJIT-2.0.3/src/vm_arm.dasc | 4487 -- source/libs/luajit/LuaJIT-2.0.3/src/vm_mips.dasc | 4241 -- source/libs/luajit/LuaJIT-2.0.3/src/vm_ppc.dasc | 5137 -- source/libs/luajit/LuaJIT-2.0.3/src/vm_ppcspe.dasc | 3691 -- source/libs/luajit/LuaJIT-2.0.3/src/vm_x86.dasc | 6374 -- .../ChangeLog | 0 .../TL-Changes | 0 .../luajit/LuaJIT-2.0.4-PATCHES/patch-01-LuaJITTeX | 176 + .../luajit/LuaJIT-2.0.4-PATCHES/patch-05-LuaJITTeX | 108 + .../LuaJIT-2.0.4-PATCHES/patch-06-ppc-darwin | 26 + source/libs/luajit/LuaJIT-2.0.4/COPYRIGHT | 56 + source/libs/luajit/LuaJIT-2.0.4/Makefile | 151 + source/libs/luajit/LuaJIT-2.0.4/README | 16 + .../luajit/LuaJIT-2.0.4/doc/bluequad-print.css | 166 + source/libs/luajit/LuaJIT-2.0.4/doc/bluequad.css | 325 + source/libs/luajit/LuaJIT-2.0.4/doc/changes.html | 978 + source/libs/luajit/LuaJIT-2.0.4/doc/contact.html | 102 + source/libs/luajit/LuaJIT-2.0.4/doc/ext_c_api.html | 187 + source/libs/luajit/LuaJIT-2.0.4/doc/ext_ffi.html | 330 + .../libs/luajit/LuaJIT-2.0.4/doc/ext_ffi_api.html | 566 + .../luajit/LuaJIT-2.0.4/doc/ext_ffi_semantics.html | 1245 + .../luajit/LuaJIT-2.0.4/doc/ext_ffi_tutorial.html | 601 + source/libs/luajit/LuaJIT-2.0.4/doc/ext_jit.html | 199 + .../libs/luajit/LuaJIT-2.0.4/doc/extensions.html | 408 + source/libs/luajit/LuaJIT-2.0.4/doc/faq.html | 184 + .../doc/img/contact.png | Bin source/libs/luajit/LuaJIT-2.0.4/doc/install.html | 646 + source/libs/luajit/LuaJIT-2.0.4/doc/luajit.html | 234 + source/libs/luajit/LuaJIT-2.0.4/doc/running.html | 306 + source/libs/luajit/LuaJIT-2.0.4/doc/status.html | 116 + source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_arm.h | 456 + .../libs/luajit/LuaJIT-2.0.4/dynasm/dasm_arm.lua | 1125 + source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_mips.h | 416 + .../libs/luajit/LuaJIT-2.0.4/dynasm/dasm_mips.lua | 953 + source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_ppc.h | 412 + .../libs/luajit/LuaJIT-2.0.4/dynasm/dasm_ppc.lua | 1249 + .../libs/luajit/LuaJIT-2.0.4/dynasm/dasm_proto.h | 83 + .../libs/luajit/LuaJIT-2.0.4/dynasm/dasm_x64.lua | 12 + source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_x86.h | 471 + .../libs/luajit/LuaJIT-2.0.4/dynasm/dasm_x86.lua | 1945 + source/libs/luajit/LuaJIT-2.0.4/dynasm/dynasm.lua | 1094 + source/libs/luajit/LuaJIT-2.0.4/etc/luajit.1 | 88 + source/libs/luajit/LuaJIT-2.0.4/etc/luajit.pc | 25 + source/libs/luajit/LuaJIT-2.0.4/src/Makefile | 684 + source/libs/luajit/LuaJIT-2.0.4/src/Makefile.dep | 227 + .../{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/host/README | 0 source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm.c | 516 + source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm.h | 104 + .../luajit/LuaJIT-2.0.4/src/host/buildvm_asm.c | 313 + .../luajit/LuaJIT-2.0.4/src/host/buildvm_fold.c | 229 + .../luajit/LuaJIT-2.0.4/src/host/buildvm_lib.c | 398 + .../luajit/LuaJIT-2.0.4/src/host/buildvm_peobj.c | 368 + .../luajit/LuaJIT-2.0.4/src/host/genminilua.lua | 428 + .../src/host/minilua.c | 0 source/libs/luajit/LuaJIT-2.0.4/src/jit/bc.lua | 191 + source/libs/luajit/LuaJIT-2.0.4/src/jit/bcsave.lua | 659 + .../libs/luajit/LuaJIT-2.0.4/src/jit/dis_arm.lua | 689 + .../libs/luajit/LuaJIT-2.0.4/src/jit/dis_mips.lua | 428 + .../luajit/LuaJIT-2.0.4/src/jit/dis_mipsel.lua | 20 + .../libs/luajit/LuaJIT-2.0.4/src/jit/dis_ppc.lua | 591 + .../libs/luajit/LuaJIT-2.0.4/src/jit/dis_x64.lua | 20 + .../libs/luajit/LuaJIT-2.0.4/src/jit/dis_x86.lua | 836 + source/libs/luajit/LuaJIT-2.0.4/src/jit/dump.lua | 699 + source/libs/luajit/LuaJIT-2.0.4/src/jit/v.lua | 167 + .../{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/lauxlib.h | 0 .../{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/lbitlib.c | 0 source/libs/luajit/LuaJIT-2.0.4/src/lib_aux.c | 356 + source/libs/luajit/LuaJIT-2.0.4/src/lib_base.c | 683 + source/libs/luajit/LuaJIT-2.0.4/src/lib_bit.c | 74 + source/libs/luajit/LuaJIT-2.0.4/src/lib_debug.c | 405 + source/libs/luajit/LuaJIT-2.0.4/src/lib_ffi.c | 851 + source/libs/luajit/LuaJIT-2.0.4/src/lib_init.c | 56 + source/libs/luajit/LuaJIT-2.0.4/src/lib_io.c | 539 + source/libs/luajit/LuaJIT-2.0.4/src/lib_jit.c | 663 + source/libs/luajit/LuaJIT-2.0.4/src/lib_math.c | 233 + source/libs/luajit/LuaJIT-2.0.4/src/lib_os.c | 287 + source/libs/luajit/LuaJIT-2.0.4/src/lib_package.c | 640 + source/libs/luajit/LuaJIT-2.0.4/src/lib_string.c | 940 + source/libs/luajit/LuaJIT-2.0.4/src/lib_table.c | 300 + .../{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/lj.supp | 0 source/libs/luajit/LuaJIT-2.0.4/src/lj_alloc.c | 1396 + .../{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/lj_alloc.h | 0 source/libs/luajit/LuaJIT-2.0.4/src/lj_api.c | 1200 + source/libs/luajit/LuaJIT-2.0.4/src/lj_arch.h | 437 + source/libs/luajit/LuaJIT-2.0.4/src/lj_asm.c | 1920 + source/libs/luajit/LuaJIT-2.0.4/src/lj_asm.h | 17 + source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_arm.h | 2361 + source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_mips.h | 1977 + source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_ppc.h | 2169 + source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_x86.h | 2806 + source/libs/luajit/LuaJIT-2.0.4/src/lj_bc.c | 14 + source/libs/luajit/LuaJIT-2.0.4/src/lj_bc.h | 261 + source/libs/luajit/LuaJIT-2.0.4/src/lj_bcdump.h | 66 + source/libs/luajit/LuaJIT-2.0.4/src/lj_bcread.c | 476 + source/libs/luajit/LuaJIT-2.0.4/src/lj_bcwrite.c | 396 + source/libs/luajit/LuaJIT-2.0.4/src/lj_carith.c | 353 + source/libs/luajit/LuaJIT-2.0.4/src/lj_carith.h | 27 + source/libs/luajit/LuaJIT-2.0.4/src/lj_ccall.c | 900 + source/libs/luajit/LuaJIT-2.0.4/src/lj_ccall.h | 171 + source/libs/luajit/LuaJIT-2.0.4/src/lj_ccallback.c | 644 + source/libs/luajit/LuaJIT-2.0.4/src/lj_ccallback.h | 25 + source/libs/luajit/LuaJIT-2.0.4/src/lj_cconv.c | 752 + source/libs/luajit/LuaJIT-2.0.4/src/lj_cconv.h | 70 + source/libs/luajit/LuaJIT-2.0.4/src/lj_cdata.c | 285 + source/libs/luajit/LuaJIT-2.0.4/src/lj_cdata.h | 75 + .../{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/lj_char.c | 0 .../{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/lj_char.h | 0 source/libs/luajit/LuaJIT-2.0.4/src/lj_clib.c | 409 + source/libs/luajit/LuaJIT-2.0.4/src/lj_clib.h | 29 + source/libs/luajit/LuaJIT-2.0.4/src/lj_cparse.c | 1872 + source/libs/luajit/LuaJIT-2.0.4/src/lj_cparse.h | 65 + source/libs/luajit/LuaJIT-2.0.4/src/lj_crecord.c | 1671 + source/libs/luajit/LuaJIT-2.0.4/src/lj_crecord.h | 31 + source/libs/luajit/LuaJIT-2.0.4/src/lj_ctype.c | 634 + source/libs/luajit/LuaJIT-2.0.4/src/lj_ctype.h | 461 + source/libs/luajit/LuaJIT-2.0.4/src/lj_debug.c | 605 + source/libs/luajit/LuaJIT-2.0.4/src/lj_debug.h | 61 + source/libs/luajit/LuaJIT-2.0.4/src/lj_def.h | 353 + source/libs/luajit/LuaJIT-2.0.4/src/lj_dispatch.c | 494 + source/libs/luajit/LuaJIT-2.0.4/src/lj_dispatch.h | 131 + source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_arm.h | 356 + source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_mips.h | 211 + source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_ppc.h | 238 + source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_x86.h | 466 + source/libs/luajit/LuaJIT-2.0.4/src/lj_err.c | 800 + source/libs/luajit/LuaJIT-2.0.4/src/lj_err.h | 41 + source/libs/luajit/LuaJIT-2.0.4/src/lj_errmsg.h | 193 + source/libs/luajit/LuaJIT-2.0.4/src/lj_ff.h | 18 + source/libs/luajit/LuaJIT-2.0.4/src/lj_ffrecord.c | 888 + source/libs/luajit/LuaJIT-2.0.4/src/lj_ffrecord.h | 24 + source/libs/luajit/LuaJIT-2.0.4/src/lj_frame.h | 183 + source/libs/luajit/LuaJIT-2.0.4/src/lj_func.c | 185 + source/libs/luajit/LuaJIT-2.0.4/src/lj_func.h | 24 + source/libs/luajit/LuaJIT-2.0.4/src/lj_gc.c | 849 + source/libs/luajit/LuaJIT-2.0.4/src/lj_gc.h | 134 + source/libs/luajit/LuaJIT-2.0.4/src/lj_gdbjit.c | 795 + source/libs/luajit/LuaJIT-2.0.4/src/lj_gdbjit.h | 22 + source/libs/luajit/LuaJIT-2.0.4/src/lj_ir.c | 501 + source/libs/luajit/LuaJIT-2.0.4/src/lj_ir.h | 551 + source/libs/luajit/LuaJIT-2.0.4/src/lj_ircall.h | 277 + source/libs/luajit/LuaJIT-2.0.4/src/lj_iropt.h | 161 + source/libs/luajit/LuaJIT-2.0.4/src/lj_jit.h | 417 + source/libs/luajit/LuaJIT-2.0.4/src/lj_lex.c | 482 + source/libs/luajit/LuaJIT-2.0.4/src/lj_lex.h | 85 + source/libs/luajit/LuaJIT-2.0.4/src/lj_lib.c | 258 + source/libs/luajit/LuaJIT-2.0.4/src/lj_lib.h | 112 + source/libs/luajit/LuaJIT-2.0.4/src/lj_load.c | 168 + source/libs/luajit/LuaJIT-2.0.4/src/lj_mcode.c | 386 + source/libs/luajit/LuaJIT-2.0.4/src/lj_mcode.h | 30 + source/libs/luajit/LuaJIT-2.0.4/src/lj_meta.c | 466 + source/libs/luajit/LuaJIT-2.0.4/src/lj_meta.h | 37 + source/libs/luajit/LuaJIT-2.0.4/src/lj_obj.c | 35 + source/libs/luajit/LuaJIT-2.0.4/src/lj_obj.h | 856 + source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_dce.c | 78 + source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_fold.c | 2304 + source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_loop.c | 436 + source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_mem.c | 916 + .../libs/luajit/LuaJIT-2.0.4/src/lj_opt_narrow.c | 656 + source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_sink.c | 245 + source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_split.c | 731 + source/libs/luajit/LuaJIT-2.0.4/src/lj_parse.c | 2754 + source/libs/luajit/LuaJIT-2.0.4/src/lj_parse.h | 18 + source/libs/luajit/LuaJIT-2.0.4/src/lj_record.c | 2252 + source/libs/luajit/LuaJIT-2.0.4/src/lj_record.h | 44 + source/libs/luajit/LuaJIT-2.0.4/src/lj_snap.c | 866 + source/libs/luajit/LuaJIT-2.0.4/src/lj_snap.h | 34 + source/libs/luajit/LuaJIT-2.0.4/src/lj_state.c | 287 + source/libs/luajit/LuaJIT-2.0.4/src/lj_state.h | 35 + source/libs/luajit/LuaJIT-2.0.4/src/lj_str.c | 366 + source/libs/luajit/LuaJIT-2.0.4/src/lj_str.h | 50 + source/libs/luajit/LuaJIT-2.0.4/src/lj_strscan.c | 498 + source/libs/luajit/LuaJIT-2.0.4/src/lj_strscan.h | 39 + source/libs/luajit/LuaJIT-2.0.4/src/lj_tab.c | 631 + source/libs/luajit/LuaJIT-2.0.4/src/lj_tab.h | 70 + source/libs/luajit/LuaJIT-2.0.4/src/lj_target.h | 162 + .../libs/luajit/LuaJIT-2.0.4/src/lj_target_arm.h | 274 + .../libs/luajit/LuaJIT-2.0.4/src/lj_target_mips.h | 257 + .../libs/luajit/LuaJIT-2.0.4/src/lj_target_ppc.h | 280 + .../libs/luajit/LuaJIT-2.0.4/src/lj_target_x86.h | 342 + source/libs/luajit/LuaJIT-2.0.4/src/lj_trace.c | 816 + source/libs/luajit/LuaJIT-2.0.4/src/lj_trace.h | 53 + source/libs/luajit/LuaJIT-2.0.4/src/lj_traceerr.h | 61 + source/libs/luajit/LuaJIT-2.0.4/src/lj_udata.c | 34 + source/libs/luajit/LuaJIT-2.0.4/src/lj_udata.h | 14 + source/libs/luajit/LuaJIT-2.0.4/src/lj_vm.h | 116 + source/libs/luajit/LuaJIT-2.0.4/src/lj_vmevent.c | 57 + source/libs/luajit/LuaJIT-2.0.4/src/lj_vmevent.h | 59 + source/libs/luajit/LuaJIT-2.0.4/src/lj_vmmath.c | 140 + source/libs/luajit/LuaJIT-2.0.4/src/ljamalg.c | 93 + .../{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/lua.h | 0 .../{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/lua.hpp | 0 source/libs/luajit/LuaJIT-2.0.4/src/luaconf.h | 156 + source/libs/luajit/LuaJIT-2.0.4/src/luajit.c | 571 + source/libs/luajit/LuaJIT-2.0.4/src/luajit.h | 70 + source/libs/luajit/LuaJIT-2.0.4/src/lualib.h | 47 + source/libs/luajit/LuaJIT-2.0.4/src/msvcbuild.bat | 113 + .../src/ps4build.bat | 0 .../libs/luajit/LuaJIT-2.0.4/src/psvitabuild.bat | 93 + source/libs/luajit/LuaJIT-2.0.4/src/vm_arm.dasc | 4486 ++ source/libs/luajit/LuaJIT-2.0.4/src/vm_mips.dasc | 4241 ++ source/libs/luajit/LuaJIT-2.0.4/src/vm_ppc.dasc | 5160 ++ source/libs/luajit/LuaJIT-2.0.4/src/vm_ppcspe.dasc | 3691 ++ source/libs/luajit/LuaJIT-2.0.4/src/vm_x86.dasc | 6377 ++ .../src/xedkbuild.bat | 0 source/libs/luajit/configure | 36 +- source/libs/luajit/native/configure | 30 +- source/libs/luajit/version.ac | 4 +- source/libs/mpfr/configure | 6 +- source/libs/pixman/configure | 6 +- source/libs/poppler/ChangeLog | 5 + source/libs/poppler/Makefile.in | 4 +- source/libs/poppler/configure | 38 +- .../libs/poppler/poppler-0.32.0-PATCHES/ChangeLog | 256 - .../libs/poppler/poppler-0.32.0-PATCHES/TL-Changes | 30 - .../poppler-0.32.0-PATCHES/patch-02-LLONG_MAX | 25 - source/libs/poppler/poppler-0.32.0/CMakeLists.txt | 735 - source/libs/poppler/poppler-0.32.0/ChangeLog | 57375 ------------------ source/libs/poppler/poppler-0.32.0/NEWS | 2296 - source/libs/poppler/poppler-0.32.0/configure.ac | 991 - .../libs/poppler/poppler-0.32.0/poppler/Annot.cc | 6850 --- source/libs/poppler/poppler-0.32.0/poppler/Annot.h | 1439 - .../poppler-0.32.0/poppler/CairoFontEngine.cc | 825 - .../libs/poppler/poppler-0.32.0/poppler/GfxFont.cc | 2632 - .../libs/poppler/poppler-0.32.0/poppler/GfxFont.h | 442 - .../poppler/poppler-0.32.0/poppler/Makefile.am | 317 - .../poppler/poppler-0.32.0/poppler/PSOutputDev.cc | 7483 --- .../poppler/poppler-0.32.0/poppler/PSOutputDev.h | 541 - source/libs/poppler/poppler-0.32.0/poppler/Page.cc | 846 - .../poppler-0.32.0/poppler/SplashOutputDev.cc | 4467 -- .../poppler-0.32.0/poppler/TextOutputDev.cc | 5625 -- .../poppler/poppler-0.32.0/poppler/TextOutputDev.h | 851 - .../libs/poppler/poppler-0.33.0-PATCHES/ChangeLog | 263 + .../libs/poppler/poppler-0.33.0-PATCHES/TL-Changes | 30 + .../poppler-0.33.0-PATCHES/patch-02-LLONG_MAX | 25 + .../{poppler-0.32.0 => poppler-0.33.0}/AUTHORS | 0 source/libs/poppler/poppler-0.33.0/CMakeLists.txt | 735 + .../{poppler-0.32.0 => poppler-0.33.0}/COPYING | 0 source/libs/poppler/poppler-0.33.0/ChangeLog | 57589 +++++++++++++++++++ .../ConfigureChecks.cmake | 0 .../{poppler-0.32.0 => poppler-0.33.0}/INSTALL | 0 .../{poppler-0.32.0 => poppler-0.33.0}/Makefile.am | 0 source/libs/poppler/poppler-0.33.0/NEWS | 2321 + .../{poppler-0.32.0 => poppler-0.33.0}/README | 0 .../{poppler-0.32.0 => poppler-0.33.0}/README-XPDF | 0 .../{poppler-0.32.0 => poppler-0.33.0}/TODO | 0 .../config.h.cmake | 0 .../{poppler-0.32.0 => poppler-0.33.0}/config.h.in | 0 source/libs/poppler/poppler-0.33.0/configure.ac | 991 + .../fofi/FoFiBase.cc | 0 .../fofi/FoFiBase.h | 0 .../fofi/FoFiEncodings.cc | 0 .../fofi/FoFiEncodings.h | 0 .../fofi/FoFiIdentifier.cc | 0 .../fofi/FoFiIdentifier.h | 0 .../fofi/FoFiTrueType.cc | 0 .../fofi/FoFiTrueType.h | 0 .../fofi/FoFiType1.cc | 0 .../fofi/FoFiType1.h | 0 .../fofi/FoFiType1C.cc | 0 .../fofi/FoFiType1C.h | 0 .../fofi/Makefile.am | 0 .../goo/FixedPoint.cc | 0 .../goo/FixedPoint.h | 0 .../goo/GooHash.cc | 0 .../goo/GooHash.h | 0 .../goo/GooLikely.h | 0 .../goo/GooList.cc | 0 .../goo/GooList.h | 0 .../goo/GooMutex.h | 0 .../goo/GooString.cc | 0 .../goo/GooString.h | 0 .../goo/GooTimer.cc | 0 .../goo/GooTimer.h | 0 .../goo/ImgWriter.cc | 0 .../goo/ImgWriter.h | 0 .../goo/JpegWriter.cc | 0 .../goo/JpegWriter.h | 0 .../goo/Makefile.am | 0 .../goo/NetPBMWriter.cc | 0 .../goo/NetPBMWriter.h | 0 .../goo/PNGWriter.cc | 0 .../goo/PNGWriter.h | 0 .../goo/TiffWriter.cc | 0 .../goo/TiffWriter.h | 0 .../goo/gfile.cc | 0 .../{poppler-0.32.0 => poppler-0.33.0}/goo/gfile.h | 0 .../{poppler-0.32.0 => poppler-0.33.0}/goo/gmem.cc | 0 .../{poppler-0.32.0 => poppler-0.33.0}/goo/gmem.h | 0 .../goo/gmempp.cc | 0 .../goo/grandom.cc | 0 .../goo/grandom.h | 0 .../goo/gstrtod.cc | 0 .../goo/gstrtod.h | 0 .../goo/gtypes.h | 0 .../goo/gtypes_p.h | 0 .../gtk-doc.make | 0 .../poppler-cairo-uninstalled.pc.in | 0 .../poppler-cairo.pc.cmake | 0 .../poppler-cairo.pc.in | 0 .../poppler-cpp-uninstalled.pc.in | 0 .../poppler-cpp.pc.cmake | 0 .../poppler-cpp.pc.in | 0 .../poppler-glib-uninstalled.pc.in | 0 .../poppler-glib.pc.cmake | 0 .../poppler-glib.pc.in | 0 .../poppler-qt4-uninstalled.pc.in | 0 .../poppler-qt4.pc.cmake | 0 .../poppler-qt4.pc.in | 0 .../poppler-qt5-uninstalled.pc.in | 0 .../poppler-qt5.pc.cmake | 0 .../poppler-qt5.pc.in | 0 .../poppler-splash-uninstalled.pc.in | 0 .../poppler-splash.pc.cmake | 0 .../poppler-splash.pc.in | 0 .../poppler-uninstalled.pc.in | 0 .../poppler.pc.cmake | 0 .../poppler.pc.in | 0 .../libs/poppler/poppler-0.33.0/poppler/Annot.cc | 6870 +++ source/libs/poppler/poppler-0.33.0/poppler/Annot.h | 1439 + .../poppler/Array.cc | 0 .../poppler/Array.h | 0 .../poppler/BuiltinFont.cc | 0 .../poppler/BuiltinFont.h | 0 .../poppler/BuiltinFontTables.cc | 0 .../poppler/BuiltinFontTables.h | 0 .../poppler/CMap.cc | 0 .../poppler/CMap.h | 0 .../poppler/CachedFile.cc | 0 .../poppler/CachedFile.h | 0 .../poppler-0.33.0/poppler/CairoFontEngine.cc | 832 + .../poppler/CairoFontEngine.h | 0 .../poppler/CairoOutputDev.cc | 0 .../poppler/CairoOutputDev.h | 0 .../poppler/CairoRescaleBox.cc | 0 .../poppler/CairoRescaleBox.h | 0 .../poppler/Catalog.cc | 0 .../poppler/Catalog.h | 0 .../poppler/CharCodeToUnicode.cc | 0 .../poppler/CharCodeToUnicode.h | 0 .../poppler/CharTypes.h | 0 .../poppler/CompactFontTables.h | 0 .../poppler/CurlCachedFile.cc | 0 .../poppler/CurlCachedFile.h | 0 .../poppler/CurlPDFDocBuilder.cc | 0 .../poppler/CurlPDFDocBuilder.h | 0 .../poppler/DCTStream.cc | 0 .../poppler/DCTStream.h | 0 .../poppler/DateInfo.cc | 0 .../poppler/DateInfo.h | 0 .../poppler/Decrypt.cc | 0 .../poppler/Decrypt.h | 0 .../poppler/Dict.cc | 0 .../poppler/Dict.h | 0 .../poppler/Error.cc | 0 .../poppler/Error.h | 0 .../poppler/ErrorCodes.h | 0 .../poppler/FileSpec.cc | 0 .../poppler/FileSpec.h | 0 .../poppler/FlateStream.cc | 0 .../poppler/FlateStream.h | 0 .../poppler/FontEncodingTables.cc | 0 .../poppler/FontEncodingTables.h | 0 .../poppler/FontInfo.cc | 0 .../poppler/FontInfo.h | 0 .../poppler/Form.cc | 0 .../poppler/Form.h | 0 .../poppler/Function.cc | 0 .../poppler/Function.h | 0 .../poppler/Gfx.cc | 0 .../poppler/Gfx.h | 0 .../libs/poppler/poppler-0.33.0/poppler/GfxFont.cc | 2620 + .../libs/poppler/poppler-0.33.0/poppler/GfxFont.h | 444 + .../poppler/GfxState.cc | 0 .../poppler/GfxState.h | 0 .../poppler/GfxState_helpers.h | 0 .../poppler/GlobalParams.cc | 0 .../poppler/GlobalParams.h | 0 .../poppler/GlobalParamsWin.cc | 0 .../poppler/Hints.cc | 0 .../poppler/Hints.h | 0 .../poppler/JArithmeticDecoder.cc | 0 .../poppler/JArithmeticDecoder.h | 0 .../poppler/JBIG2Stream.cc | 0 .../poppler/JBIG2Stream.h | 0 .../poppler/JPEG2000Stream.cc | 0 .../poppler/JPEG2000Stream.h | 0 .../poppler/JPXStream.cc | 0 .../poppler/JPXStream.h | 0 .../poppler/Lexer.cc | 0 .../poppler/Lexer.h | 0 .../poppler/Linearization.cc | 0 .../poppler/Linearization.h | 0 .../poppler/Link.cc | 0 .../poppler/Link.h | 0 .../poppler/LocalPDFDocBuilder.cc | 0 .../poppler/LocalPDFDocBuilder.h | 0 .../poppler/poppler-0.33.0/poppler/Makefile.am | 317 + .../poppler/MarkedContentOutputDev.cc | 0 .../poppler/MarkedContentOutputDev.h | 0 .../poppler/Movie.cc | 0 .../poppler/Movie.h | 0 .../poppler/NameToCharCode.cc | 0 .../poppler/NameToCharCode.h | 0 .../poppler/NameToUnicodeTable.h | 0 .../poppler/Object.cc | 0 .../poppler/Object.h | 0 .../poppler/OptionalContent.cc | 0 .../poppler/OptionalContent.h | 0 .../poppler/Outline.cc | 0 .../poppler/Outline.h | 0 .../poppler/OutputDev.cc | 0 .../poppler/OutputDev.h | 0 .../poppler/PDFDoc.cc | 0 .../poppler/PDFDoc.h | 0 .../poppler/PDFDocBuilder.h | 0 .../poppler/PDFDocEncoding.cc | 0 .../poppler/PDFDocEncoding.h | 0 .../poppler/PDFDocFactory.cc | 0 .../poppler/PDFDocFactory.h | 0 .../poppler/poppler-0.33.0/poppler/PSOutputDev.cc | 7521 +++ .../poppler/poppler-0.33.0/poppler/PSOutputDev.h | 546 + .../poppler/PSTokenizer.cc | 0 .../poppler/PSTokenizer.h | 0 source/libs/poppler/poppler-0.33.0/poppler/Page.cc | 860 + .../poppler/Page.h | 0 .../poppler/PageLabelInfo.cc | 0 .../poppler/PageLabelInfo.h | 0 .../poppler/PageLabelInfo_p.h | 0 .../poppler/PageTransition.cc | 0 .../poppler/PageTransition.h | 0 .../poppler/Parser.cc | 0 .../poppler/Parser.h | 0 .../poppler/PopplerCache.cc | 0 .../poppler/PopplerCache.h | 0 .../poppler/PreScanOutputDev.cc | 0 .../poppler/PreScanOutputDev.h | 0 .../poppler/ProfileData.cc | 0 .../poppler/ProfileData.h | 0 .../poppler/Rendition.cc | 0 .../poppler/Rendition.h | 0 .../poppler/SecurityHandler.cc | 0 .../poppler/SecurityHandler.h | 0 .../poppler/Sound.cc | 0 .../poppler/Sound.h | 0 .../poppler-0.33.0/poppler/SplashOutputDev.cc | 4479 ++ .../poppler/SplashOutputDev.h | 0 .../poppler/StdinCachedFile.cc | 0 .../poppler/StdinCachedFile.h | 0 .../poppler/StdinPDFDocBuilder.cc | 0 .../poppler/StdinPDFDocBuilder.h | 0 .../poppler/Stream-CCITT.h | 0 .../poppler/Stream.cc | 0 .../poppler/Stream.h | 0 .../poppler/StructElement.cc | 0 .../poppler/StructElement.h | 0 .../poppler/StructTreeRoot.cc | 0 .../poppler/StructTreeRoot.h | 0 .../poppler-0.33.0/poppler/TextOutputDev.cc | 5818 ++ .../poppler/poppler-0.33.0/poppler/TextOutputDev.h | 880 + .../poppler/UTF.cc | 0 .../poppler/UTF.h | 0 .../poppler/UTF8.h | 0 .../poppler/UnicodeCClassTables.h | 0 .../poppler/UnicodeCompTables.h | 0 .../poppler/UnicodeDecompTables.h | 0 .../poppler/UnicodeMap.cc | 0 .../poppler/UnicodeMap.h | 0 .../poppler/UnicodeMapTables.h | 0 .../poppler/UnicodeTypeTable.cc | 0 .../poppler/UnicodeTypeTable.h | 0 .../poppler/ViewerPreferences.cc | 0 .../poppler/ViewerPreferences.h | 0 .../poppler/XRef.cc | 0 .../poppler/XRef.h | 0 .../poppler/XpdfPluginAPI.cc | 0 .../poppler/XpdfPluginAPI.h | 0 .../poppler/gen-unicode-tables.py | 0 .../poppler/poppler-config.h.cmake | 0 .../poppler/poppler-config.h.in | 0 .../poppler/strtok_r.cpp | 0 .../splash/Makefile.am | 0 .../splash/Splash.cc | 0 .../splash/Splash.h | 0 .../splash/SplashBitmap.cc | 0 .../splash/SplashBitmap.h | 0 .../splash/SplashClip.cc | 0 .../splash/SplashClip.h | 0 .../splash/SplashErrorCodes.h | 0 .../splash/SplashFTFont.cc | 0 .../splash/SplashFTFont.h | 0 .../splash/SplashFTFontEngine.cc | 0 .../splash/SplashFTFontEngine.h | 0 .../splash/SplashFTFontFile.cc | 0 .../splash/SplashFTFontFile.h | 0 .../splash/SplashFont.cc | 0 .../splash/SplashFont.h | 0 .../splash/SplashFontEngine.cc | 0 .../splash/SplashFontEngine.h | 0 .../splash/SplashFontFile.cc | 0 .../splash/SplashFontFile.h | 0 .../splash/SplashFontFileID.cc | 0 .../splash/SplashFontFileID.h | 0 .../splash/SplashGlyphBitmap.h | 0 .../splash/SplashMath.h | 0 .../splash/SplashPath.cc | 0 .../splash/SplashPath.h | 0 .../splash/SplashPattern.cc | 0 .../splash/SplashPattern.h | 0 .../splash/SplashScreen.cc | 0 .../splash/SplashScreen.h | 0 .../splash/SplashState.cc | 0 .../splash/SplashState.h | 0 .../splash/SplashT1Font.cc | 0 .../splash/SplashT1Font.h | 0 .../splash/SplashT1FontEngine.cc | 0 .../splash/SplashT1FontEngine.h | 0 .../splash/SplashT1FontFile.cc | 0 .../splash/SplashT1FontFile.h | 0 .../splash/SplashTypes.h | 0 .../splash/SplashXPath.cc | 0 .../splash/SplashXPath.h | 0 .../splash/SplashXPathScanner.cc | 0 .../splash/SplashXPathScanner.h | 0 source/libs/poppler/version.ac | 2 +- source/libs/zlib/configure | 6 +- source/libs/zziplib/configure | 6 +- source/m4/ChangeLog | 8 + source/m4/kpse-common.m4 | 3 + source/m4/kpse-poppler-flags.m4 | 2 +- source/m4/kpse-setup.m4 | 8 +- source/m4/kpse-warnings.m4 | 10 +- source/m4/kpse-web2c.m4 | 3 + source/tardate.ac | 2 +- source/texk/configure | 104 +- source/texk/kpathsea/ChangeLog | 9 + source/texk/kpathsea/NEWS | 2 +- source/texk/kpathsea/c-auto.in | 2 +- source/texk/kpathsea/configure | 149 +- source/texk/kpathsea/configure.ac | 3 - source/texk/kpathsea/version.ac | 2 +- source/texk/texlive/configure | 20 +- source/texk/texlive/linked_scripts/Makefile.am | 1 + source/texk/texlive/linked_scripts/Makefile.in | 1 + source/texk/texlive/tl_scripts/fmtutil.cnf | 13 +- source/texk/web2c/ChangeLog | 12 + source/texk/web2c/Makefile.am | 6 + source/texk/web2c/Makefile.in | 1229 +- source/texk/web2c/NEWS | 2 +- source/texk/web2c/ac/web2c.ac | 4 +- source/texk/web2c/c-auto.in | 4 + source/texk/web2c/configure | 262 +- source/texk/web2c/lib/ChangeLog | 5 + source/texk/web2c/lib/texmfmp.c | 17 + source/texk/web2c/mfluadir/am/mflua.am | 133 + source/texk/web2c/mfluajitdir/am/mfluajit.am | 129 + source/texk/web2c/mplibdir/mp.w | 2 +- source/texk/web2c/tangle-sh.in | 2 +- source/texk/web2c/texmfmp-help.h | 96 +- source/texk/web2c/texmfmp.h | 10 +- source/texk/web2c/triptrap-sh | 4 +- source/texk/web2c/web2c/ChangeLog | 5 + source/texk/web2c/web2c/coerce.h | 5 +- source/texk/web2c/web2c/configure | 130 +- source/texk/web2c/web2c/convert | 14 +- source/texk/web2c/web2c/splitup.c | 10 +- source/utils/README | 4 +- source/utils/configure | 104 +- source/version.ac | 2 +- 1430 files changed, 202861 insertions(+), 200434 deletions(-) mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2-PATCHES/ChangeLog mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2-PATCHES/TL-Changes mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/AUTHORS mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/BIBLIOGRAPHY mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/BUGS mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/CODING_STYLE mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/COPYING mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/COPYING-LGPL-2.1 mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/COPYING-MPL-1.1 mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/HACKING mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/INSTALL mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/KNOWN_ISSUES mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/Makefile.am mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/Makefile.win32 mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/NEWS mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/PORTING_GUIDE mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/README mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/README.win32 mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/RELEASING mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/acinclude.m4 mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/Makefile.am.analysis mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/Makefile.am.changelog mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/Makefile.am.common mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/Makefile.am.gtk-doc mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/Makefile.am.releasing mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/Makefile.win32.common mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/Makefile.win32.features mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/Makefile.win32.features-h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/Makefile.win32.inform mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/aclocal.cairo.m4 mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/aclocal.compare.m4 mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/aclocal.enable.m4 mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/aclocal.float.m4 mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/aclocal.makefile.m4 mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/aclocal.pkg.m4 mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/configure.ac.analysis mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/configure.ac.features mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/configure.ac.noversion mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/configure.ac.pthread mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/configure.ac.system mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/configure.ac.tools mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/configure.ac.version mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/configure.ac.warnings mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/build/gtk-doc.m4 mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/cairo-version.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/config.h.in mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/configure.ac mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/Makefile.am mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/Makefile.am.analysis mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/Makefile.am.features mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/Makefile.sources mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/Makefile.win32 mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/Makefile.win32.features mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/README mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-analysis-surface-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-analysis-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-arc-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-arc.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-array-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-array.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-atomic-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-atomic.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-backend-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-base64-stream.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-base85-stream.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-bentley-ottmann-rectangular.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-bentley-ottmann-rectilinear.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-bentley-ottmann.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-beos-surface.cpp mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-beos.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-botor-scan-converter.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-box-inline.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-boxes-intersect.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-boxes-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-boxes.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-cache-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-cache.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-cff-subset.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-clip-boxes.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-clip-inline.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-clip-polygon.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-clip-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-clip-region.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-clip-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-clip-tor-scan-converter.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-clip.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-cogl-context-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-cogl-context.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-cogl-gradient-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-cogl-gradient.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-cogl-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-cogl-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-cogl-utils-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-cogl-utils.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-cogl.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-color.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-combsort-inline.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-compiler-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-composite-rectangles-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-composite-rectangles.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-compositor-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-compositor.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-contour-inline.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-contour-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-contour.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-damage-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-damage.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-debug.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-default-context-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-default-context.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-deflate-stream.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-deprecated.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-device-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-device.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-directfb-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-directfb.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-drm.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-egl-context.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-error-inline.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-error-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-error.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-fallback-compositor.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-features-uninstalled.pc.in mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-features.pc.in mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-fixed-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-fixed-type-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-fixed.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-font-face-twin-data.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-font-face-twin.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-font-face.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-font-options.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-fontconfig-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-freed-pool-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-freed-pool.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-freelist-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-freelist-type-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-freelist.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-ft-font.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-ft-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-ft.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gl-composite.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gl-device.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gl-dispatch-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gl-dispatch.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gl-ext-def-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gl-glyphs.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gl-gradient-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gl-gradient.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gl-info.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gl-msaa-compositor.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gl-operand.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gl-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gl-shaders.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gl-source.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gl-spans-compositor.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gl-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gl-traps-compositor.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gl.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-glx-context.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gstate-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-gstate.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-hash-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-hash.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-hull.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-image-compositor.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-image-info-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-image-info.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-image-source.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-image-surface-inline.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-image-surface-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-image-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-line-inline.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-line-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-line.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-list-inline.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-list-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-lzw.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-malloc-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-mask-compositor.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-matrix.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-mempool-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-mempool.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-mesh-pattern-rasterizer.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-misc.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-mono-scan-converter.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-mutex-impl-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-mutex-list-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-mutex-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-mutex-type-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-mutex.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-no-compositor.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-observer.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-os2-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-os2-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-os2.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-output-stream-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-output-stream.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-paginated-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-paginated-surface-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-paginated-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-path-bounds.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-path-fill.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-path-fixed-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-path-fixed.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-path-in-fill.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-path-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-path-stroke-boxes.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-path-stroke-polygon.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-path-stroke-traps.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-path-stroke-tristrip.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-path-stroke.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-path.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-pattern-inline.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-pattern-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-pattern.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-pdf-operators-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-pdf-operators.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-pdf-shading-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-pdf-shading.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-pdf-surface-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-pdf-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-pdf.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-pen.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-pixman-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-png.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-polygon-intersect.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-polygon-reduce.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-polygon.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-ps-surface-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-ps-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-ps.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-qt-surface.cpp mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-qt.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-quartz-font.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-quartz-image-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-quartz-image.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-quartz-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-quartz-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-quartz.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-raster-source-pattern.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-recording-surface-inline.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-recording-surface-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-recording-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-rectangle.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-rectangular-scan-converter.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-reference-count-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-region-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-region.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-rtree-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-rtree.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-scaled-font-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-scaled-font-subsets-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-scaled-font-subsets.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-scaled-font.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-script-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-script-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-script.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-shape-mask-compositor.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-skia.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-slope-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-slope.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-spans-compositor-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-spans-compositor.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-spans-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-spans.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-spline.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-stroke-dash-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-stroke-dash.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-stroke-style.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-backend-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-clipper-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-clipper.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-fallback-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-fallback.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-inline.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-observer-inline.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-observer-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-observer.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-offset-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-offset.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-snapshot-inline.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-snapshot-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-snapshot.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-subsurface-inline.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-subsurface-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-subsurface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-wrapper-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface-wrapper.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-svg-surface-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-svg-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-svg.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-tee-surface-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-tee-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-tee.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-time-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-time.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-tor-scan-converter.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-tor22-scan-converter.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-toy-font-face.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-traps-compositor.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-traps-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-traps.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-tristrip-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-tristrip.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-truetype-subset-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-truetype-subset.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-type1-fallback.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-type1-glyph-names.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-type1-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-type1-subset.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-type3-glyph-surface-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-type3-glyph-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-types-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-unicode.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-uninstalled.pc.in mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-user-font-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-user-font.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-version.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-version.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-vg-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-vg.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-wgl-context.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-wideint-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-wideint-type-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-wideint.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-win32.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xcb-connection-core.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xcb-connection-render.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xcb-connection-shm.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xcb-connection.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xcb-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xcb-resources.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xcb-screen.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xcb-shm.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xcb-surface-core.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xcb-surface-render.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xcb-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xcb.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xlib-core-compositor.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xlib-display.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xlib-fallback-compositor.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xlib-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xlib-render-compositor.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xlib-screen.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xlib-source.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xlib-surface-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xlib-surface-shm.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xlib-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xlib-visual.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xlib-xcb-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xlib-xrender-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xlib-xrender.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xlib.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xml-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo-xml.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairo.pc.in mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/cairoint.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/check-doc-syntax.awk mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/check-has-hidden-symbols.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/check-link.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/test-base-compositor-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/test-compositor-surface-private.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/test-compositor-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/test-compositor-surface.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/test-null-compositor-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/test-null-compositor-surface.h mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/test-paginated-surface.c mode change 100755 => 100644 source/libs/cairo/cairo-1.14.2/src/test-paginated-surface.h mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17-PATCHES/ChangeLog mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17-PATCHES/TL-Changes mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/ANNOUNCE mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/CHANGES mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/CMakeLists.txt mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/INSTALL mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/LICENSE mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/Makefile.am mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/README mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/TODO mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/arm/arm_init.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/arm/filter_neon.S mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/arm/filter_neon_intrinsics.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/config.h.in mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/configure.ac mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/README.txt mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/arm-neon/README mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/arm-neon/android-ndk.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/arm-neon/linux-auxv.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/arm-neon/linux.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/conftest/README mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/conftest/read.dfa mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/conftest/s_read.dfa mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/conftest/s_write.dfa mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/conftest/simple.dfa mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/conftest/write.dfa mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/examples/README.txt mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/examples/iccfrompng.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/examples/pngpixel.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/examples/pngtopng.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/COPYING mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/LICENSE mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/Makefile.mingw32 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/Makefile.sgi mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/Makefile.unx mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/Makefile.w32 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/README mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/makevms.com mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/readpng.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/readpng.h mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/readpng2.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/readpng2.h mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/readppm.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/rpng-win.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/rpng-x.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/rpng2-win.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/rpng2-x.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/toucan.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/wpng.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/writepng.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/gregbook/writepng.h mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/libtests/fakepng.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/libtests/makepng.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/libtests/pngimage.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/libtests/pngstest.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/libtests/pngunknown.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/libtests/pngvalid.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/libtests/readpng.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/libtests/tarith.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/libtests/timepng.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminim/README mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminim/decoder/README mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminim/decoder/makefile mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminim/decoder/pngusr.dfa mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminim/decoder/pngusr.h mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminim/encoder/README mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminim/encoder/makefile mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminim/encoder/pngusr.dfa mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminim/encoder/pngusr.h mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminim/preader/README mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminim/preader/makefile mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminim/preader/pngusr.dfa mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminim/preader/pngusr.h mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminus/README mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminus/makefile.std mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminus/makefile.tc3 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminus/makevms.com mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminus/png2pnm.bat mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminus/png2pnm.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminus/pngminus.bat mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminus/pnm2png.bat mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngminus/pnm2png.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/README mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn0g01.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn0g02.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn0g04.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn0g08.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn0g16.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn2c08.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn2c16.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn3p01.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn3p02.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn3p04.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn3p08.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn4a08.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn4a16.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn6a08.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn6a16.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbbn0g01.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbbn0g02.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbbn0g04.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbbn2c16.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbbn3p08.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbgn2c16.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbgn3p08.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbrn2c08.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbwn0g16.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbwn3p08.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbyn3p08.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftp0n0g08.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftp0n2c08.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftp0n3p08.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftp1n3p08.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/tools/README.txt mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/tools/checksum-icc.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/tools/chkfmt mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/tools/cvtcolor.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/tools/makesRGB.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/tools/png-fix-itxt.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/tools/pngfix.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/tools/sRGB.h mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/visupng/PngFile.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/visupng/PngFile.h mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/visupng/README.txt mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/visupng/VisualPng.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/visupng/VisualPng.dsp mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/visupng/VisualPng.dsw mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/visupng/VisualPng.ico mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/visupng/VisualPng.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/visupng/VisualPng.rc mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/visupng/cexcept.h mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/contrib/visupng/resource.h mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/example.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/libpng-config.in mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/libpng-manual.txt mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/libpng.3 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/libpng.pc.in mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/libpngpf.3 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/png.5 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/png.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/png.h mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngbar.jpg mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngbar.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngconf.h mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngdebug.h mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngerror.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngget.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pnginfo.h mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pnglibconf.h mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngmem.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngnow.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngpread.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngpriv.h mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngread.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngrio.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngrtran.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngrutil.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngset.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngstruct.h mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngtest.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngtest.png mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngtrans.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngusr.dfa mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngwio.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngwrite.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngwtran.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/pngwutil.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/owatcom/libpng.tgt mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/owatcom/libpng.wpj mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/owatcom/pngconfig.mak mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/owatcom/pngstest.tgt mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/owatcom/pngtest.tgt mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/owatcom/pngvalid.tgt mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/visualc71/PRJ0041.mak mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/visualc71/README.txt mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/visualc71/README_zlib.txt mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/visualc71/libpng.sln mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/visualc71/libpng.vcproj mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/visualc71/pngtest.vcproj mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/visualc71/zlib.vcproj mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/vstudio/WARNING mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/vstudio/libpng/libpng.vcxproj mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/vstudio/pnglibconf/pnglibconf.vcxproj mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/vstudio/pngstest/pngstest.vcxproj mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/vstudio/pngtest/pngtest.vcxproj mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/vstudio/pngunknown/pngunknown.vcxproj mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/vstudio/pngvalid/pngvalid.vcxproj mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/vstudio/readme.txt mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/vstudio/vstudio.sln mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/vstudio/zlib.props mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/projects/vstudio/zlib/zlib.vcxproj mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/README.txt mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/SCOPTIONS.ppc mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/checksym.awk mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/def.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/descrip.mms mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/dfn.awk mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/intprefix.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/libpng-config-body.in mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/libpng-config-head.in mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/libpng.pc.in mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/libtool.m4 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/ltoptions.m4 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/ltsugar.m4 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/ltversion.m4 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/lt~obsolete.m4 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/macro.lst mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.32sunu mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.64sunu mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.acorn mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.aix mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.amiga mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.atari mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.bc32 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.beos mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.bor mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.cegcc mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.darwin mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.dec mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.dj2 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.freebsd mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.gcc mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.hp64 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.hpgcc mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.hpux mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.ibmc mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.intel mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.knr mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.linux mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.mips mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.msc mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.msys mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.ne12bsd mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.netbsd mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.openbsd mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.sco mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.sggcc mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.sgi mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.so9 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.solaris mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.solaris-x86 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.std mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.sunos mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.tc3 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makefile.vcwin32 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/makevms.com mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/options.awk mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/pnglibconf.dfa mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/pnglibconf.h.prebuilt mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/pnglibconf.mak mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/pngwin.rc mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/prefix.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/smakefile.ppc mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/sym.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/symbols.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/symbols.def mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/scripts/vers.c mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngimage-full mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngimage-quick mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngstest mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngstest-0g01 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngstest-0g02 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngstest-0g04 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngstest-0g08 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngstest-0g16 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngstest-2c08 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngstest-2c16 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngstest-3p01 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngstest-3p02 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngstest-3p04 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngstest-3p08 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngstest-4a08 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngstest-4a16 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngstest-6a08 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngstest-6a16 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngstest-error mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngtest mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngunknown-IDAT mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngunknown-discard mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngunknown-if-safe mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngunknown-sAPI mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngunknown-sTER mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngunknown-save mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngunknown-vpAg mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-16-to-8 mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-alpha-mode mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-background mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-expand16-alpha-mode mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-expand16-background mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-expand16-transform mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-sbit mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-threshold mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-transform mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngvalid-progressive-interlace-size mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngvalid-progressive-interlace-standard mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngvalid-progressive-interlace-transform mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngvalid-progressive-standard mode change 100755 => 100644 source/libs/libpng/libpng-1.6.17/tests/pngvalid-standard delete mode 100644 source/libs/luajit/LuaJIT-2.0.3-PATCHES/patch-01-LuaJITTeX delete mode 100644 source/libs/luajit/LuaJIT-2.0.3-PATCHES/patch-05-LuaJITTeX delete mode 100644 source/libs/luajit/LuaJIT-2.0.3-PATCHES/patch-06-ppc-darwin delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/COPYRIGHT delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/Makefile delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/README delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/doc/bluequad-print.css delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/doc/bluequad.css delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/doc/changes.html delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/doc/contact.html delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/doc/ext_c_api.html delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/doc/ext_ffi.html delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/doc/ext_ffi_api.html delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/doc/ext_ffi_semantics.html delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/doc/ext_ffi_tutorial.html delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/doc/ext_jit.html delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/doc/extensions.html delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/doc/faq.html delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/doc/install.html delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/doc/luajit.html delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/doc/running.html delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/doc/status.html delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_arm.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_arm.lua delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_mips.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_mips.lua delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_ppc.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_ppc.lua delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_proto.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_x64.lua delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_x86.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_x86.lua delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/dynasm/dynasm.lua delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/etc/luajit.1 delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/etc/luajit.pc delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/Makefile delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/Makefile.dep delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm_asm.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm_fold.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm_lib.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm_peobj.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/host/genminilua.lua delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/jit/bc.lua delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/jit/bcsave.lua delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_arm.lua delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_mips.lua delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_mipsel.lua delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_ppc.lua delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_x64.lua delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_x86.lua delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/jit/dump.lua delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/jit/v.lua delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lib_aux.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lib_base.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lib_bit.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lib_debug.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lib_ffi.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lib_init.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lib_io.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lib_jit.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lib_math.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lib_os.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lib_package.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lib_string.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lib_table.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_alloc.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_api.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_arch.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_asm.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_asm.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_arm.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_mips.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_ppc.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_x86.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_bc.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_bc.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_bcdump.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_bcread.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_bcwrite.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_carith.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_carith.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_ccall.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_ccall.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_ccallback.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_ccallback.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_cconv.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_cconv.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_cdata.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_cdata.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_clib.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_clib.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_cparse.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_cparse.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_crecord.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_crecord.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_ctype.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_ctype.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_debug.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_debug.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_def.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_dispatch.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_dispatch.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_arm.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_mips.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_ppc.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_x86.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_err.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_err.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_errmsg.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_ff.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_ffrecord.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_ffrecord.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_frame.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_func.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_func.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_gc.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_gc.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_gdbjit.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_gdbjit.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_ir.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_ir.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_ircall.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_iropt.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_jit.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_lex.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_lex.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_lib.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_lib.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_load.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_mcode.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_mcode.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_meta.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_meta.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_obj.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_obj.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_dce.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_fold.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_loop.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_mem.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_narrow.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_sink.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_split.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_parse.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_parse.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_record.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_record.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_snap.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_snap.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_state.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_state.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_str.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_str.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_strscan.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_strscan.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_tab.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_tab.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_target.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_target_arm.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_target_mips.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_target_ppc.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_target_x86.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_trace.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_trace.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_traceerr.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_udata.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_udata.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_vm.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_vmevent.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_vmevent.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lj_vmmath.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/ljamalg.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/luaconf.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/luajit.c delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/luajit.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/lualib.h delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/msvcbuild.bat delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/vm_arm.dasc delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/vm_mips.dasc delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/vm_ppc.dasc delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/vm_ppcspe.dasc delete mode 100644 source/libs/luajit/LuaJIT-2.0.3/src/vm_x86.dasc rename source/libs/luajit/{LuaJIT-2.0.3-PATCHES => LuaJIT-2.0.4-PATCHES}/ChangeLog (100%) rename source/libs/luajit/{LuaJIT-2.0.3-PATCHES => LuaJIT-2.0.4-PATCHES}/TL-Changes (100%) create mode 100644 source/libs/luajit/LuaJIT-2.0.4-PATCHES/patch-01-LuaJITTeX create mode 100644 source/libs/luajit/LuaJIT-2.0.4-PATCHES/patch-05-LuaJITTeX create mode 100644 source/libs/luajit/LuaJIT-2.0.4-PATCHES/patch-06-ppc-darwin create mode 100644 source/libs/luajit/LuaJIT-2.0.4/COPYRIGHT create mode 100644 source/libs/luajit/LuaJIT-2.0.4/Makefile create mode 100644 source/libs/luajit/LuaJIT-2.0.4/README create mode 100644 source/libs/luajit/LuaJIT-2.0.4/doc/bluequad-print.css create mode 100644 source/libs/luajit/LuaJIT-2.0.4/doc/bluequad.css create mode 100644 source/libs/luajit/LuaJIT-2.0.4/doc/changes.html create mode 100644 source/libs/luajit/LuaJIT-2.0.4/doc/contact.html create mode 100644 source/libs/luajit/LuaJIT-2.0.4/doc/ext_c_api.html create mode 100644 source/libs/luajit/LuaJIT-2.0.4/doc/ext_ffi.html create mode 100644 source/libs/luajit/LuaJIT-2.0.4/doc/ext_ffi_api.html create mode 100644 source/libs/luajit/LuaJIT-2.0.4/doc/ext_ffi_semantics.html create mode 100644 source/libs/luajit/LuaJIT-2.0.4/doc/ext_ffi_tutorial.html create mode 100644 source/libs/luajit/LuaJIT-2.0.4/doc/ext_jit.html create mode 100644 source/libs/luajit/LuaJIT-2.0.4/doc/extensions.html create mode 100644 source/libs/luajit/LuaJIT-2.0.4/doc/faq.html rename source/libs/luajit/{LuaJIT-2.0.3 => LuaJIT-2.0.4}/doc/img/contact.png (100%) create mode 100644 source/libs/luajit/LuaJIT-2.0.4/doc/install.html create mode 100644 source/libs/luajit/LuaJIT-2.0.4/doc/luajit.html create mode 100644 source/libs/luajit/LuaJIT-2.0.4/doc/running.html create mode 100644 source/libs/luajit/LuaJIT-2.0.4/doc/status.html create mode 100644 source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_arm.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_arm.lua create mode 100644 source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_mips.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_mips.lua create mode 100644 source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_ppc.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_ppc.lua create mode 100644 source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_proto.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_x64.lua create mode 100644 source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_x86.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_x86.lua create mode 100644 source/libs/luajit/LuaJIT-2.0.4/dynasm/dynasm.lua create mode 100644 source/libs/luajit/LuaJIT-2.0.4/etc/luajit.1 create mode 100644 source/libs/luajit/LuaJIT-2.0.4/etc/luajit.pc create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/Makefile create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/Makefile.dep rename source/libs/luajit/{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/host/README (100%) create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm_asm.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm_fold.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm_lib.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm_peobj.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/host/genminilua.lua rename source/libs/luajit/{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/host/minilua.c (100%) create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/jit/bc.lua create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/jit/bcsave.lua create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_arm.lua create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_mips.lua create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_mipsel.lua create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_ppc.lua create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_x64.lua create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_x86.lua create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/jit/dump.lua create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/jit/v.lua rename source/libs/luajit/{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/lauxlib.h (100%) rename source/libs/luajit/{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/lbitlib.c (100%) create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lib_aux.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lib_base.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lib_bit.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lib_debug.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lib_ffi.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lib_init.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lib_io.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lib_jit.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lib_math.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lib_os.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lib_package.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lib_string.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lib_table.c rename source/libs/luajit/{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/lj.supp (100%) create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_alloc.c rename source/libs/luajit/{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/lj_alloc.h (100%) create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_api.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_arch.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_asm.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_asm.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_arm.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_mips.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_ppc.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_x86.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_bc.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_bc.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_bcdump.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_bcread.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_bcwrite.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_carith.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_carith.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_ccall.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_ccall.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_ccallback.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_ccallback.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_cconv.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_cconv.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_cdata.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_cdata.h rename source/libs/luajit/{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/lj_char.c (100%) rename source/libs/luajit/{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/lj_char.h (100%) create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_clib.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_clib.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_cparse.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_cparse.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_crecord.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_crecord.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_ctype.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_ctype.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_debug.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_debug.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_def.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_dispatch.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_dispatch.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_arm.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_mips.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_ppc.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_x86.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_err.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_err.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_errmsg.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_ff.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_ffrecord.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_ffrecord.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_frame.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_func.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_func.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_gc.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_gc.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_gdbjit.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_gdbjit.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_ir.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_ir.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_ircall.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_iropt.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_jit.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_lex.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_lex.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_lib.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_lib.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_load.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_mcode.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_mcode.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_meta.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_meta.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_obj.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_obj.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_dce.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_fold.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_loop.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_mem.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_narrow.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_sink.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_split.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_parse.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_parse.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_record.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_record.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_snap.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_snap.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_state.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_state.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_str.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_str.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_strscan.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_strscan.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_tab.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_tab.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_target.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_target_arm.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_target_mips.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_target_ppc.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_target_x86.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_trace.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_trace.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_traceerr.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_udata.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_udata.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_vm.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_vmevent.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_vmevent.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lj_vmmath.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/ljamalg.c rename source/libs/luajit/{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/lua.h (100%) rename source/libs/luajit/{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/lua.hpp (100%) create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/luaconf.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/luajit.c create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/luajit.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/lualib.h create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/msvcbuild.bat rename source/libs/luajit/{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/ps4build.bat (100%) create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/psvitabuild.bat create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/vm_arm.dasc create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/vm_mips.dasc create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/vm_ppc.dasc create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/vm_ppcspe.dasc create mode 100644 source/libs/luajit/LuaJIT-2.0.4/src/vm_x86.dasc rename source/libs/luajit/{LuaJIT-2.0.3 => LuaJIT-2.0.4}/src/xedkbuild.bat (100%) delete mode 100755 source/libs/poppler/poppler-0.32.0-PATCHES/ChangeLog delete mode 100755 source/libs/poppler/poppler-0.32.0-PATCHES/TL-Changes delete mode 100755 source/libs/poppler/poppler-0.32.0-PATCHES/patch-02-LLONG_MAX delete mode 100755 source/libs/poppler/poppler-0.32.0/CMakeLists.txt delete mode 100755 source/libs/poppler/poppler-0.32.0/ChangeLog delete mode 100755 source/libs/poppler/poppler-0.32.0/NEWS delete mode 100755 source/libs/poppler/poppler-0.32.0/configure.ac delete mode 100755 source/libs/poppler/poppler-0.32.0/poppler/Annot.cc delete mode 100755 source/libs/poppler/poppler-0.32.0/poppler/Annot.h delete mode 100755 source/libs/poppler/poppler-0.32.0/poppler/CairoFontEngine.cc delete mode 100755 source/libs/poppler/poppler-0.32.0/poppler/GfxFont.cc delete mode 100755 source/libs/poppler/poppler-0.32.0/poppler/GfxFont.h delete mode 100755 source/libs/poppler/poppler-0.32.0/poppler/Makefile.am delete mode 100755 source/libs/poppler/poppler-0.32.0/poppler/PSOutputDev.cc delete mode 100755 source/libs/poppler/poppler-0.32.0/poppler/PSOutputDev.h delete mode 100755 source/libs/poppler/poppler-0.32.0/poppler/Page.cc delete mode 100755 source/libs/poppler/poppler-0.32.0/poppler/SplashOutputDev.cc delete mode 100755 source/libs/poppler/poppler-0.32.0/poppler/TextOutputDev.cc delete mode 100755 source/libs/poppler/poppler-0.32.0/poppler/TextOutputDev.h create mode 100644 source/libs/poppler/poppler-0.33.0-PATCHES/ChangeLog create mode 100644 source/libs/poppler/poppler-0.33.0-PATCHES/TL-Changes create mode 100644 source/libs/poppler/poppler-0.33.0-PATCHES/patch-02-LLONG_MAX rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/AUTHORS (100%) mode change 100755 => 100644 create mode 100644 source/libs/poppler/poppler-0.33.0/CMakeLists.txt rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/COPYING (100%) mode change 100755 => 100644 create mode 100644 source/libs/poppler/poppler-0.33.0/ChangeLog rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/ConfigureChecks.cmake (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/INSTALL (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/Makefile.am (100%) mode change 100755 => 100644 create mode 100644 source/libs/poppler/poppler-0.33.0/NEWS rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/README (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/README-XPDF (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/TODO (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/config.h.cmake (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/config.h.in (100%) mode change 100755 => 100644 create mode 100644 source/libs/poppler/poppler-0.33.0/configure.ac rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/fofi/FoFiBase.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/fofi/FoFiBase.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/fofi/FoFiEncodings.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/fofi/FoFiEncodings.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/fofi/FoFiIdentifier.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/fofi/FoFiIdentifier.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/fofi/FoFiTrueType.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/fofi/FoFiTrueType.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/fofi/FoFiType1.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/fofi/FoFiType1.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/fofi/FoFiType1C.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/fofi/FoFiType1C.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/fofi/Makefile.am (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/FixedPoint.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/FixedPoint.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/GooHash.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/GooHash.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/GooLikely.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/GooList.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/GooList.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/GooMutex.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/GooString.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/GooString.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/GooTimer.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/GooTimer.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/ImgWriter.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/ImgWriter.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/JpegWriter.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/JpegWriter.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/Makefile.am (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/NetPBMWriter.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/NetPBMWriter.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/PNGWriter.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/PNGWriter.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/TiffWriter.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/TiffWriter.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/gfile.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/gfile.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/gmem.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/gmem.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/gmempp.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/grandom.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/grandom.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/gstrtod.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/gstrtod.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/gtypes.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/goo/gtypes_p.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/gtk-doc.make (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler-cairo-uninstalled.pc.in (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler-cairo.pc.cmake (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler-cairo.pc.in (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler-cpp-uninstalled.pc.in (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler-cpp.pc.cmake (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler-cpp.pc.in (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler-glib-uninstalled.pc.in (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler-glib.pc.cmake (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler-glib.pc.in (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler-qt4-uninstalled.pc.in (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler-qt4.pc.cmake (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler-qt4.pc.in (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler-qt5-uninstalled.pc.in (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler-qt5.pc.cmake (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler-qt5.pc.in (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler-splash-uninstalled.pc.in (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler-splash.pc.cmake (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler-splash.pc.in (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler-uninstalled.pc.in (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler.pc.cmake (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler.pc.in (100%) mode change 100755 => 100644 create mode 100644 source/libs/poppler/poppler-0.33.0/poppler/Annot.cc create mode 100644 source/libs/poppler/poppler-0.33.0/poppler/Annot.h rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Array.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Array.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/BuiltinFont.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/BuiltinFont.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/BuiltinFontTables.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/BuiltinFontTables.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/CMap.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/CMap.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/CachedFile.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/CachedFile.h (100%) mode change 100755 => 100644 create mode 100644 source/libs/poppler/poppler-0.33.0/poppler/CairoFontEngine.cc rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/CairoFontEngine.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/CairoOutputDev.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/CairoOutputDev.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/CairoRescaleBox.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/CairoRescaleBox.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Catalog.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Catalog.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/CharCodeToUnicode.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/CharCodeToUnicode.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/CharTypes.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/CompactFontTables.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/CurlCachedFile.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/CurlCachedFile.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/CurlPDFDocBuilder.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/CurlPDFDocBuilder.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/DCTStream.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/DCTStream.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/DateInfo.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/DateInfo.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Decrypt.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Decrypt.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Dict.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Dict.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Error.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Error.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/ErrorCodes.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/FileSpec.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/FileSpec.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/FlateStream.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/FlateStream.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/FontEncodingTables.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/FontEncodingTables.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/FontInfo.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/FontInfo.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Form.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Form.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Function.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Function.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Gfx.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Gfx.h (100%) mode change 100755 => 100644 create mode 100644 source/libs/poppler/poppler-0.33.0/poppler/GfxFont.cc create mode 100644 source/libs/poppler/poppler-0.33.0/poppler/GfxFont.h rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/GfxState.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/GfxState.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/GfxState_helpers.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/GlobalParams.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/GlobalParams.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/GlobalParamsWin.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Hints.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Hints.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/JArithmeticDecoder.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/JArithmeticDecoder.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/JBIG2Stream.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/JBIG2Stream.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/JPEG2000Stream.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/JPEG2000Stream.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/JPXStream.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/JPXStream.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Lexer.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Lexer.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Linearization.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Linearization.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Link.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Link.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/LocalPDFDocBuilder.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/LocalPDFDocBuilder.h (100%) mode change 100755 => 100644 create mode 100644 source/libs/poppler/poppler-0.33.0/poppler/Makefile.am rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/MarkedContentOutputDev.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/MarkedContentOutputDev.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Movie.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Movie.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/NameToCharCode.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/NameToCharCode.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/NameToUnicodeTable.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Object.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Object.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/OptionalContent.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/OptionalContent.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Outline.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Outline.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/OutputDev.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/OutputDev.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/PDFDoc.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/PDFDoc.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/PDFDocBuilder.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/PDFDocEncoding.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/PDFDocEncoding.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/PDFDocFactory.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/PDFDocFactory.h (100%) mode change 100755 => 100644 create mode 100644 source/libs/poppler/poppler-0.33.0/poppler/PSOutputDev.cc create mode 100644 source/libs/poppler/poppler-0.33.0/poppler/PSOutputDev.h rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/PSTokenizer.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/PSTokenizer.h (100%) mode change 100755 => 100644 create mode 100644 source/libs/poppler/poppler-0.33.0/poppler/Page.cc rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Page.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/PageLabelInfo.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/PageLabelInfo.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/PageLabelInfo_p.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/PageTransition.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/PageTransition.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Parser.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Parser.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/PopplerCache.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/PopplerCache.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/PreScanOutputDev.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/PreScanOutputDev.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/ProfileData.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/ProfileData.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Rendition.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Rendition.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/SecurityHandler.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/SecurityHandler.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Sound.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Sound.h (100%) mode change 100755 => 100644 create mode 100644 source/libs/poppler/poppler-0.33.0/poppler/SplashOutputDev.cc rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/SplashOutputDev.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/StdinCachedFile.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/StdinCachedFile.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/StdinPDFDocBuilder.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/StdinPDFDocBuilder.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Stream-CCITT.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Stream.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/Stream.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/StructElement.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/StructElement.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/StructTreeRoot.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/StructTreeRoot.h (100%) mode change 100755 => 100644 create mode 100644 source/libs/poppler/poppler-0.33.0/poppler/TextOutputDev.cc create mode 100644 source/libs/poppler/poppler-0.33.0/poppler/TextOutputDev.h rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/UTF.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/UTF.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/UTF8.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/UnicodeCClassTables.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/UnicodeCompTables.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/UnicodeDecompTables.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/UnicodeMap.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/UnicodeMap.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/UnicodeMapTables.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/UnicodeTypeTable.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/UnicodeTypeTable.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/ViewerPreferences.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/ViewerPreferences.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/XRef.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/XRef.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/XpdfPluginAPI.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/XpdfPluginAPI.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/gen-unicode-tables.py (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/poppler-config.h.cmake (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/poppler-config.h.in (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/poppler/strtok_r.cpp (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/Makefile.am (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/Splash.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/Splash.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashBitmap.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashBitmap.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashClip.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashClip.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashErrorCodes.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashFTFont.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashFTFont.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashFTFontEngine.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashFTFontEngine.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashFTFontFile.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashFTFontFile.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashFont.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashFont.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashFontEngine.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashFontEngine.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashFontFile.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashFontFile.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashFontFileID.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashFontFileID.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashGlyphBitmap.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashMath.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashPath.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashPath.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashPattern.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashPattern.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashScreen.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashScreen.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashState.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashState.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashT1Font.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashT1Font.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashT1FontEngine.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashT1FontEngine.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashT1FontFile.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashT1FontFile.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashTypes.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashXPath.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashXPath.h (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashXPathScanner.cc (100%) mode change 100755 => 100644 rename source/libs/poppler/{poppler-0.32.0 => poppler-0.33.0}/splash/SplashXPathScanner.h (100%) mode change 100755 => 100644 create mode 100644 source/texk/web2c/mfluadir/am/mflua.am create mode 100644 source/texk/web2c/mfluajitdir/am/mfluajit.am diff --git a/source/ChangeLog b/source/ChangeLog index e165a55a7..d568f27bb 100644 --- a/source/ChangeLog +++ b/source/ChangeLog @@ -1,3 +1,8 @@ +2015-06-12 Peter Breitenlohner + + * version.ac: Switch 2015 => 2016/dev. + * tardate.ac: Switch to 2015-06-12. + 2015-05-28 Peter Breitenlohner * README.solaris (removed): Moved from here to doc/. @@ -41,7 +46,7 @@ 2014-06-16 Peter Breitenlohner - * version.ac: Switch 2014 => 2015/dev' + * version.ac: Switch 2014 => 2015/dev. * tardate.ac: Switch to 2014-06-16. 2014-04-28 Peter Breitenlohner diff --git a/source/build-aux/missing b/source/build-aux/missing index db98974ff..f62bbae30 100644 --- a/source/build-aux/missing +++ b/source/build-aux/missing @@ -3,7 +3,7 @@ scriptversion=2013-10-28.13; # UTC -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2014 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify diff --git a/source/build-aux/texinfo.tex b/source/build-aux/texinfo.tex index dc53be821..1a4741d15 100644 --- a/source/build-aux/texinfo.tex +++ b/source/build-aux/texinfo.tex @@ -3,7 +3,7 @@ % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % -\def\texinfoversion{2015-04-29.11} +\def\texinfoversion{2015-06-01.15} % % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, @@ -304,6 +304,7 @@ % Avoid "undefined control sequence" errors. \def\lastchapterdefs{} \def\lastsectiondefs{} +\def\lastsection{} \def\prevchapterdefs{} \def\prevsectiondefs{} \def\lastcolordefs{} @@ -3022,11 +3023,16 @@ end \TeX } -% Some math mode symbols. -\def\bullet{$\ptexbullet$} -\def\geq{\ifmmode \ge\else $\ge$\fi} -\def\leq{\ifmmode \le\else $\le$\fi} -\def\minus{\ifmmode -\else $-$\fi} +% Some math mode symbols. Define \ensuremath to switch into math mode +% unless we are already there. Expansion tricks may not be needed here, +% but safer, and can't hurt. +\def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi} +\def\ensuredmath#1{$\relax#1$} +% +\def\bullet{\ensuremath\ptexbullet} +\def\geq{\ensuremath\ge} +\def\leq{\ensuremath\le} +\def\minus{\ensuremath-} % @dots{} outputs an ellipsis using the current font. % We do .5em per period so that it has the same spacing in the cm @@ -7602,7 +7608,7 @@ end \long\def\nillm@{\nil@}% % This macro is expanded during the Texinfo macro expansion, not during its -% definition. It gets all the arguments values and assigns them to macros +% definition. It gets all the arguments' values and assigns them to macros % macarg.ARGNAME % % #1 is the macro name @@ -8949,7 +8955,6 @@ directory should work if nowhere else does.} \catcode\count255=#1\relax \advance\count255 by 1 \repeat - } % @documentencoding sets the definition of non-ASCII characters @@ -9038,7 +9043,7 @@ directory should work if nowhere else does.} \gdef^^b4{\'{}} \gdef^^b5{$\mu$} \gdef^^b6{\P} - \gdef^^b7{\ifmmode\cdot\else $\cdot$\fi} + \gdef^^b7{\ensuremath\cdot} \gdef^^b8{\cedilla\ } \gdef^^b9{$^1$} \gdef^^ba{\ordm} @@ -9397,19 +9402,19 @@ directory should work if nowhere else does.} \DeclareUnicodeCharacter{00A9}{\copyright} \DeclareUnicodeCharacter{00AA}{\ordf} \DeclareUnicodeCharacter{00AB}{\guillemetleft} - \DeclareUnicodeCharacter{00AC}{\ifmmode\lnot\else $\lnot$\fi} + \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot} \DeclareUnicodeCharacter{00AD}{\-} \DeclareUnicodeCharacter{00AE}{\registeredsymbol} \DeclareUnicodeCharacter{00AF}{\={ }} \DeclareUnicodeCharacter{00B0}{\ringaccent{ }} - \DeclareUnicodeCharacter{00B1}{\ifmmode\pm\else $\pm$\fi} + \DeclareUnicodeCharacter{00B1}{\ensuremath\pm} \DeclareUnicodeCharacter{00B2}{$^2$} \DeclareUnicodeCharacter{00B3}{$^3$} \DeclareUnicodeCharacter{00B4}{\'{ }} \DeclareUnicodeCharacter{00B5}{$\mu$} \DeclareUnicodeCharacter{00B6}{\P} - \DeclareUnicodeCharacter{00B7}{\ifmmode\cdot\else $\cdot$\fi} + \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot} \DeclareUnicodeCharacter{00B8}{\cedilla{ }} \DeclareUnicodeCharacter{00B9}{$^1$} \DeclareUnicodeCharacter{00BA}{\ordm} @@ -9443,7 +9448,7 @@ directory should work if nowhere else does.} \DeclareUnicodeCharacter{00D4}{\^O} \DeclareUnicodeCharacter{00D5}{\~O} \DeclareUnicodeCharacter{00D6}{\"O} - \DeclareUnicodeCharacter{00D7}{\ifmmode\times\else $\times$\fi} + \DeclareUnicodeCharacter{00D7}{\ensuremath\times} \DeclareUnicodeCharacter{00D8}{\O} \DeclareUnicodeCharacter{00D9}{\`U} \DeclareUnicodeCharacter{00DA}{\'U} @@ -9477,7 +9482,7 @@ directory should work if nowhere else does.} \DeclareUnicodeCharacter{00F4}{\^o} \DeclareUnicodeCharacter{00F5}{\~o} \DeclareUnicodeCharacter{00F6}{\"o} - \DeclareUnicodeCharacter{00F7}{\ifmmode\div\else $\div$\fi} + \DeclareUnicodeCharacter{00F7}{\ensuremath\div} \DeclareUnicodeCharacter{00F8}{\o} \DeclareUnicodeCharacter{00F9}{\`u} \DeclareUnicodeCharacter{00FA}{\'u} @@ -9546,7 +9551,7 @@ directory should work if nowhere else does.} \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}} \DeclareUnicodeCharacter{0136}{\cedilla{K}} \DeclareUnicodeCharacter{0137}{\cedilla{k}} - \DeclareUnicodeCharacter{0138}{\ifmmode\kappa\else $\kappa$\fi} + \DeclareUnicodeCharacter{0138}{\ensuremath\kappa} \DeclareUnicodeCharacter{0139}{\'L} \DeclareUnicodeCharacter{013A}{\'l} \DeclareUnicodeCharacter{013B}{\cedilla{L}} @@ -9813,6 +9818,8 @@ directory should work if nowhere else does.} \DeclareUnicodeCharacter{201C}{\quotedblleft} \DeclareUnicodeCharacter{201D}{\quotedblright} \DeclareUnicodeCharacter{201E}{\quotedblbase} + \DeclareUnicodeCharacter{2020}{\ensuremath\dagger} + \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger} \DeclareUnicodeCharacter{2022}{\bullet} \DeclareUnicodeCharacter{2026}{\dots} \DeclareUnicodeCharacter{2039}{\guilsinglleft} @@ -9824,6 +9831,7 @@ directory should work if nowhere else does.} \DeclareUnicodeCharacter{2212}{\minus} \DeclareUnicodeCharacter{2217}{\point} + \DeclareUnicodeCharacter{2225}{\ensuremath\parallel} \DeclareUnicodeCharacter{2261}{\equiv} }% end of \utfeightchardefs diff --git a/source/build-aux/ylwrap b/source/build-aux/ylwrap index 8f072a8e9..7c2d927f7 100644 --- a/source/build-aux/ylwrap +++ b/source/build-aux/ylwrap @@ -3,7 +3,7 @@ scriptversion=2013-01-12.17; # UTC -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2014 Free Software Foundation, Inc. # # Written by Tom Tromey . # diff --git a/source/configure b/source/configure index 3314ebc9b..8e4e9412f 100755 --- a/source/configure +++ b/source/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for TeX Live 2015-03-07. +# Generated by GNU Autoconf 2.69 for TeX Live 2015-06-12. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='TeX Live' PACKAGE_TARNAME='tex-live' -PACKAGE_VERSION='2015-03-07' -PACKAGE_STRING='TeX Live 2015-03-07' +PACKAGE_VERSION='2015-06-12' +PACKAGE_STRING='TeX Live 2015-06-12' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' @@ -815,6 +815,10 @@ enable_xetex enable_xetex_synctex enable_mf enable_mf_nowin +enable_mflua +enable_mflua_nowin +enable_mfluajit +enable_mfluajit_nowin with_mf_x_toolkit enable_epsfwin enable_hp2627win @@ -1422,7 +1426,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures TeX Live 2015-03-07 to adapt to many kinds of systems. +\`configure' configures TeX Live 2015-06-12 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1496,7 +1500,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of TeX Live 2015-03-07:";; + short | recursive ) echo "Configuration of TeX Live 2015-06-12:";; esac cat <<\_ACEOF @@ -1544,6 +1548,10 @@ Optional Features: --disable-mf do not compile and install METAFONT --disable-mf-nowin do not build a separate non-window-capable METAFONT + --disable-mflua do not compile and install MFLua + --enable-mflua-nowin build a separate non-window-capable MFLua + --disable-mfluajit do not compile and install MFLuaJIT + --enable-mfluajit-nowin build a separate non-window-capable MFLuaJIT --enable-epsfwin include EPSF pseudo window support --enable-hp2627win include HP 2627 window support --enable-mftalkwin include mftalk (generic server) window support @@ -1705,7 +1713,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -TeX Live configure 2015-03-07 +TeX Live configure 2015-06-12 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2255,6 +2263,52 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_find_uintX_t +# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES +# --------------------------------------------- +# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR +# accordingly. +ac_fn_c_check_decl () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + as_decl_name=`echo $2|sed 's/ *(.*//'` + as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 +$as_echo_n "checking whether $as_decl_name is declared... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +#ifndef $as_decl_name +#ifdef __cplusplus + (void) $as_decl_use; +#else + (void) $as_decl_name; +#endif +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_decl + # ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES # ---------------------------------------------------- # Tries to find if the field MEMBER exists in type AGGR, after including @@ -2436,7 +2490,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by TeX Live $as_me 2015-03-07, which was +It was created by TeX Live $as_me 2015-06-12, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3935,6 +3989,20 @@ $as_echo "$as_me: $host -> \`--disable-luajittex'" >&6;} ;; esac ;; esac +case $enable_mfluajit in #( + yes | no) : + : ;; #( + *) : + case $host in #( + alpha* | sparc* | x86_64-*-cygwin | powerpc-*-darwin* ) : + { $as_echo "$as_me:${as_lineno-$LINENO}: $host -> \`--disable-mfluajit'" >&5 +$as_echo "$as_me: $host -> \`--disable-mfluajit'" >&6;} + ac_configure_args="$ac_configure_args '--disable-mfluajit'" ;; #( + *) : + ;; +esac ;; +esac + ## texk/web2c/ac/withenable.ac: configure.ac fragment for the TeX Live subdirectory texk/web2c/ ## configure options and TL libraries required for web2c @@ -4247,6 +4315,62 @@ esac if test "${enable_mf_nowin+set}" = set; then : enableval=$enable_mf_nowin; fi +case $enable_mf_nowin in #( + yes | no) : + ;; #( + *) : + enable_mf_nowin=yes ;; +esac +# Check whether --enable-mflua was given. +if test "${enable_mflua+set}" = set; then : + enableval=$enable_mflua; +fi +case $enable_mflua in #( + yes | no) : + ;; #( + *) : + enable_mflua=yes ;; +esac + +# Check whether --enable-mflua-nowin was given. +if test "${enable_mflua_nowin+set}" = set; then : + enableval=$enable_mflua_nowin; +fi +case $enable_mflua_nowin in #( + yes | no) : + ;; #( + *) : + enable_mflua_nowin=no ;; +esac + +test "x$enable_web2c:$enable_mflua" = xyes:yes && { + need_lua52=yes +} +# Check whether --enable-mfluajit was given. +if test "${enable_mfluajit+set}" = set; then : + enableval=$enable_mfluajit; +fi +case $enable_mfluajit in #( + yes | no) : + ;; #( + *) : + enable_mfluajit=yes ;; +esac + +# Check whether --enable-mfluajit-nowin was given. +if test "${enable_mfluajit_nowin+set}" = set; then : + enableval=$enable_mfluajit_nowin; +fi +case $enable_mfluajit_nowin in #( + yes | no) : + ;; #( + *) : + enable_mfluajit_nowin=no ;; +esac + +test "x$enable_web2c:$enable_mfluajit" = xyes:yes && { + need_luajit=yes +} # Check whether --with-mf-x-toolkit was given. if test "${with_mf_x_toolkit+set}" = set; then : @@ -8987,7 +9111,7 @@ fi # Define the identity of the package. PACKAGE='tex-live' - VERSION='2015-03-07' + VERSION='2015-06-12' cat >>confdefs.h <<_ACEOF @@ -9355,13 +9479,13 @@ else if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_cflags="-Wimplicit -Wreturn-type" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement" ;; #( *) : ;; esac case `$CC -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -9373,7 +9497,7 @@ esac kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition" ;; #( *) : ;; @@ -14780,6 +14904,18 @@ case :$ac_cv_c_int64_t:$ac_cv_c_int64_t: in #( *) : ;; esac +ac_fn_c_check_decl "$LINENO" "isascii" "ac_cv_have_decl_isascii" "#include +" +if test "x$ac_cv_have_decl_isascii" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_ISASCII $ac_have_decl +_ACEOF + ac_fn_c_check_member "$LINENO" "struct stat" "st_mtim" "ac_cv_member_struct_stat_st_mtim" "$ac_includes_default" if test "x$ac_cv_member_struct_stat_st_mtim" = xyes; then : @@ -15884,7 +16020,7 @@ if test "x$enable_compiler_warnings" != xno; then ;; esac case `$CXX -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cxxflags="$kpse_cv_warning_cxxflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -19583,11 +19719,11 @@ if test "x$with_mpfr_libdir" != x && test "x$with_mpfr_libdir" != xyes; then MPFR_LIBS="-L$with_mpfr_libdir $MPFR_LIBS" fi -if $PKG_CONFIG poppler --atleast-version=0.18; then +if $PKG_CONFIG poppler --atleast-version=0.30; then POPPLER_INCLUDES=`$PKG_CONFIG poppler --cflags` POPPLER_LIBS=`$PKG_CONFIG poppler --libs` elif test "x$need_poppler:$with_system_poppler" = xyes:yes; then - as_fn_error $? "did not find poppler 0.18 or better" "$LINENO" 5 + as_fn_error $? "did not find poppler 0.30 or better" "$LINENO" 5 fi POPPLER_VERSION='-DPOPPLER_VERSION=\"'`$PKG_CONFIG poppler --modversion`'\"' @@ -20616,7 +20752,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by TeX Live $as_me 2015-03-07, which was +This file was extended by TeX Live $as_me 2015-06-12, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -20673,7 +20809,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -TeX Live config.status 2015-03-07 +TeX Live config.status 2015-06-12 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -22629,11 +22765,11 @@ msg_compiling="$msg_compiling test "x$srcdir" = x. || msg_compiling="$msg_compiling from sources in $kpse_src" { $as_echo "$as_me:${as_lineno-$LINENO}: result: -** Configuration summary for $PACKAGE_STRING (2015$with_banner_add): +** Configuration summary for $PACKAGE_STRING (2016/dev$with_banner_add): $msg_compiling" >&5 $as_echo " -** Configuration summary for $PACKAGE_STRING (2015$with_banner_add): +** Configuration summary for $PACKAGE_STRING (2016/dev$with_banner_add): $msg_compiling" >&6; } case $kpse_src$kpse_bld in diff --git a/source/libs/README b/source/libs/README index 95c4d8ebd..6f8f177eb 100644 --- a/source/libs/README +++ b/source/libs/README @@ -1,4 +1,4 @@ -$Id: README 36780 2015-04-12 11:50:46Z peter $ +$Id: README 37503 2015-06-12 08:05:53Z peter $ Public domain. Originally created by Karl Berry, 2005. Libraries we compile for TeX Live. @@ -12,7 +12,7 @@ See also comments in ../texk/README. cairo 1.14.2 - checked 11mar15 http://cairographics.org/releases/ -freetype2 2.5.5 - checked 7jan15 +freetype2 2.6 - checked 12jun15 http://savannah.nongnu.org/download/freetype/ gd 2.1.1 - checked 14jan15 @@ -40,8 +40,8 @@ libpng 1.6.17 - checked 27mar15 lua 5.2.3 - checked 11mar15 http://www.lua.org/ftp/ -luajit 2.0.3 - checked 14mar14 - http://luajit.org/download/LuaJIT-2.0.3.tar.gz +luajit 2.0.4 - checked 12jun15 + http://luajit.org/download/LuaJIT-2.0.4.tar.gz mpfr 3.1.2 - checked 13mar13 http://ftp.gnu.org/gnu/mpfr/ @@ -49,7 +49,7 @@ mpfr 3.1.2 - checked 13mar13 pixman 0.32.6 - checked 7jul14 http://cairographics.org/releases/ -poppler 0.32.0 - checked 8mar15 +poppler 0.33.0 - checked 12jun15 http://poppler.freedesktop.org/ - used by luatex and xetex potrace 1.12 - checked 27mar15 diff --git a/source/libs/cairo/cairo-1.14.2-PATCHES/ChangeLog b/source/libs/cairo/cairo-1.14.2-PATCHES/ChangeLog old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2-PATCHES/TL-Changes b/source/libs/cairo/cairo-1.14.2-PATCHES/TL-Changes old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/AUTHORS b/source/libs/cairo/cairo-1.14.2/AUTHORS old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/BIBLIOGRAPHY b/source/libs/cairo/cairo-1.14.2/BIBLIOGRAPHY old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/BUGS b/source/libs/cairo/cairo-1.14.2/BUGS old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/CODING_STYLE b/source/libs/cairo/cairo-1.14.2/CODING_STYLE old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/COPYING b/source/libs/cairo/cairo-1.14.2/COPYING old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/COPYING-LGPL-2.1 b/source/libs/cairo/cairo-1.14.2/COPYING-LGPL-2.1 old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/COPYING-MPL-1.1 b/source/libs/cairo/cairo-1.14.2/COPYING-MPL-1.1 old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/HACKING b/source/libs/cairo/cairo-1.14.2/HACKING old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/INSTALL b/source/libs/cairo/cairo-1.14.2/INSTALL old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/KNOWN_ISSUES b/source/libs/cairo/cairo-1.14.2/KNOWN_ISSUES old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/Makefile.am b/source/libs/cairo/cairo-1.14.2/Makefile.am old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/Makefile.win32 b/source/libs/cairo/cairo-1.14.2/Makefile.win32 old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/NEWS b/source/libs/cairo/cairo-1.14.2/NEWS old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/PORTING_GUIDE b/source/libs/cairo/cairo-1.14.2/PORTING_GUIDE old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/README b/source/libs/cairo/cairo-1.14.2/README old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/README.win32 b/source/libs/cairo/cairo-1.14.2/README.win32 old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/RELEASING b/source/libs/cairo/cairo-1.14.2/RELEASING old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/acinclude.m4 b/source/libs/cairo/cairo-1.14.2/acinclude.m4 old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/Makefile.am.analysis b/source/libs/cairo/cairo-1.14.2/build/Makefile.am.analysis old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/Makefile.am.changelog b/source/libs/cairo/cairo-1.14.2/build/Makefile.am.changelog old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/Makefile.am.common b/source/libs/cairo/cairo-1.14.2/build/Makefile.am.common old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/Makefile.am.gtk-doc b/source/libs/cairo/cairo-1.14.2/build/Makefile.am.gtk-doc old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/Makefile.am.releasing b/source/libs/cairo/cairo-1.14.2/build/Makefile.am.releasing old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/Makefile.win32.common b/source/libs/cairo/cairo-1.14.2/build/Makefile.win32.common old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/Makefile.win32.features b/source/libs/cairo/cairo-1.14.2/build/Makefile.win32.features old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/Makefile.win32.features-h b/source/libs/cairo/cairo-1.14.2/build/Makefile.win32.features-h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/Makefile.win32.inform b/source/libs/cairo/cairo-1.14.2/build/Makefile.win32.inform old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/aclocal.cairo.m4 b/source/libs/cairo/cairo-1.14.2/build/aclocal.cairo.m4 old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/aclocal.compare.m4 b/source/libs/cairo/cairo-1.14.2/build/aclocal.compare.m4 old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/aclocal.enable.m4 b/source/libs/cairo/cairo-1.14.2/build/aclocal.enable.m4 old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/aclocal.float.m4 b/source/libs/cairo/cairo-1.14.2/build/aclocal.float.m4 old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/aclocal.makefile.m4 b/source/libs/cairo/cairo-1.14.2/build/aclocal.makefile.m4 old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/aclocal.pkg.m4 b/source/libs/cairo/cairo-1.14.2/build/aclocal.pkg.m4 old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/configure.ac.analysis b/source/libs/cairo/cairo-1.14.2/build/configure.ac.analysis old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/configure.ac.features b/source/libs/cairo/cairo-1.14.2/build/configure.ac.features old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/configure.ac.noversion b/source/libs/cairo/cairo-1.14.2/build/configure.ac.noversion old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/configure.ac.pthread b/source/libs/cairo/cairo-1.14.2/build/configure.ac.pthread old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/configure.ac.system b/source/libs/cairo/cairo-1.14.2/build/configure.ac.system old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/configure.ac.tools b/source/libs/cairo/cairo-1.14.2/build/configure.ac.tools old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/configure.ac.version b/source/libs/cairo/cairo-1.14.2/build/configure.ac.version old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/configure.ac.warnings b/source/libs/cairo/cairo-1.14.2/build/configure.ac.warnings old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/build/gtk-doc.m4 b/source/libs/cairo/cairo-1.14.2/build/gtk-doc.m4 old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/cairo-version.h b/source/libs/cairo/cairo-1.14.2/cairo-version.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/config.h.in b/source/libs/cairo/cairo-1.14.2/config.h.in old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/configure.ac b/source/libs/cairo/cairo-1.14.2/configure.ac old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/Makefile.am b/source/libs/cairo/cairo-1.14.2/src/Makefile.am old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/Makefile.am.analysis b/source/libs/cairo/cairo-1.14.2/src/Makefile.am.analysis old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/Makefile.am.features b/source/libs/cairo/cairo-1.14.2/src/Makefile.am.features old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/Makefile.sources b/source/libs/cairo/cairo-1.14.2/src/Makefile.sources old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/Makefile.win32 b/source/libs/cairo/cairo-1.14.2/src/Makefile.win32 old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/Makefile.win32.features b/source/libs/cairo/cairo-1.14.2/src/Makefile.win32.features old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/README b/source/libs/cairo/cairo-1.14.2/src/README old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-analysis-surface-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-analysis-surface-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-analysis-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-analysis-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-arc-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-arc-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-arc.c b/source/libs/cairo/cairo-1.14.2/src/cairo-arc.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-array-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-array-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-array.c b/source/libs/cairo/cairo-1.14.2/src/cairo-array.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-atomic-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-atomic-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-atomic.c b/source/libs/cairo/cairo-1.14.2/src/cairo-atomic.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-backend-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-backend-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-base64-stream.c b/source/libs/cairo/cairo-1.14.2/src/cairo-base64-stream.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-base85-stream.c b/source/libs/cairo/cairo-1.14.2/src/cairo-base85-stream.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-bentley-ottmann-rectangular.c b/source/libs/cairo/cairo-1.14.2/src/cairo-bentley-ottmann-rectangular.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-bentley-ottmann-rectilinear.c b/source/libs/cairo/cairo-1.14.2/src/cairo-bentley-ottmann-rectilinear.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-bentley-ottmann.c b/source/libs/cairo/cairo-1.14.2/src/cairo-bentley-ottmann.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-beos-surface.cpp b/source/libs/cairo/cairo-1.14.2/src/cairo-beos-surface.cpp old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-beos.h b/source/libs/cairo/cairo-1.14.2/src/cairo-beos.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-botor-scan-converter.c b/source/libs/cairo/cairo-1.14.2/src/cairo-botor-scan-converter.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-box-inline.h b/source/libs/cairo/cairo-1.14.2/src/cairo-box-inline.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-boxes-intersect.c b/source/libs/cairo/cairo-1.14.2/src/cairo-boxes-intersect.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-boxes-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-boxes-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-boxes.c b/source/libs/cairo/cairo-1.14.2/src/cairo-boxes.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-cache-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-cache-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-cache.c b/source/libs/cairo/cairo-1.14.2/src/cairo-cache.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-cff-subset.c b/source/libs/cairo/cairo-1.14.2/src/cairo-cff-subset.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-clip-boxes.c b/source/libs/cairo/cairo-1.14.2/src/cairo-clip-boxes.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-clip-inline.h b/source/libs/cairo/cairo-1.14.2/src/cairo-clip-inline.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-clip-polygon.c b/source/libs/cairo/cairo-1.14.2/src/cairo-clip-polygon.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-clip-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-clip-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-clip-region.c b/source/libs/cairo/cairo-1.14.2/src/cairo-clip-region.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-clip-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-clip-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-clip-tor-scan-converter.c b/source/libs/cairo/cairo-1.14.2/src/cairo-clip-tor-scan-converter.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-clip.c b/source/libs/cairo/cairo-1.14.2/src/cairo-clip.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-cogl-context-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-cogl-context-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-cogl-context.c b/source/libs/cairo/cairo-1.14.2/src/cairo-cogl-context.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-cogl-gradient-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-cogl-gradient-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-cogl-gradient.c b/source/libs/cairo/cairo-1.14.2/src/cairo-cogl-gradient.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-cogl-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-cogl-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-cogl-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-cogl-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-cogl-utils-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-cogl-utils-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-cogl-utils.c b/source/libs/cairo/cairo-1.14.2/src/cairo-cogl-utils.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-cogl.h b/source/libs/cairo/cairo-1.14.2/src/cairo-cogl.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-color.c b/source/libs/cairo/cairo-1.14.2/src/cairo-color.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-combsort-inline.h b/source/libs/cairo/cairo-1.14.2/src/cairo-combsort-inline.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-compiler-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-compiler-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-composite-rectangles-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-composite-rectangles-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-composite-rectangles.c b/source/libs/cairo/cairo-1.14.2/src/cairo-composite-rectangles.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-compositor-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-compositor-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-compositor.c b/source/libs/cairo/cairo-1.14.2/src/cairo-compositor.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-contour-inline.h b/source/libs/cairo/cairo-1.14.2/src/cairo-contour-inline.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-contour-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-contour-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-contour.c b/source/libs/cairo/cairo-1.14.2/src/cairo-contour.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-damage-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-damage-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-damage.c b/source/libs/cairo/cairo-1.14.2/src/cairo-damage.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-debug.c b/source/libs/cairo/cairo-1.14.2/src/cairo-debug.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-default-context-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-default-context-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-default-context.c b/source/libs/cairo/cairo-1.14.2/src/cairo-default-context.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-deflate-stream.c b/source/libs/cairo/cairo-1.14.2/src/cairo-deflate-stream.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-deprecated.h b/source/libs/cairo/cairo-1.14.2/src/cairo-deprecated.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-device-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-device-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-device.c b/source/libs/cairo/cairo-1.14.2/src/cairo-device.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-directfb-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-directfb-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-directfb.h b/source/libs/cairo/cairo-1.14.2/src/cairo-directfb.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-drm.h b/source/libs/cairo/cairo-1.14.2/src/cairo-drm.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-egl-context.c b/source/libs/cairo/cairo-1.14.2/src/cairo-egl-context.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-error-inline.h b/source/libs/cairo/cairo-1.14.2/src/cairo-error-inline.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-error-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-error-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-error.c b/source/libs/cairo/cairo-1.14.2/src/cairo-error.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-fallback-compositor.c b/source/libs/cairo/cairo-1.14.2/src/cairo-fallback-compositor.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-features-uninstalled.pc.in b/source/libs/cairo/cairo-1.14.2/src/cairo-features-uninstalled.pc.in old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-features.pc.in b/source/libs/cairo/cairo-1.14.2/src/cairo-features.pc.in old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-fixed-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-fixed-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-fixed-type-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-fixed-type-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-fixed.c b/source/libs/cairo/cairo-1.14.2/src/cairo-fixed.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-font-face-twin-data.c b/source/libs/cairo/cairo-1.14.2/src/cairo-font-face-twin-data.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-font-face-twin.c b/source/libs/cairo/cairo-1.14.2/src/cairo-font-face-twin.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-font-face.c b/source/libs/cairo/cairo-1.14.2/src/cairo-font-face.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-font-options.c b/source/libs/cairo/cairo-1.14.2/src/cairo-font-options.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-fontconfig-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-fontconfig-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-freed-pool-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-freed-pool-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-freed-pool.c b/source/libs/cairo/cairo-1.14.2/src/cairo-freed-pool.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-freelist-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-freelist-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-freelist-type-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-freelist-type-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-freelist.c b/source/libs/cairo/cairo-1.14.2/src/cairo-freelist.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-ft-font.c b/source/libs/cairo/cairo-1.14.2/src/cairo-ft-font.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-ft-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-ft-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-ft.h b/source/libs/cairo/cairo-1.14.2/src/cairo-ft.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gl-composite.c b/source/libs/cairo/cairo-1.14.2/src/cairo-gl-composite.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gl-device.c b/source/libs/cairo/cairo-1.14.2/src/cairo-gl-device.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gl-dispatch-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-gl-dispatch-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gl-dispatch.c b/source/libs/cairo/cairo-1.14.2/src/cairo-gl-dispatch.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gl-ext-def-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-gl-ext-def-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gl-glyphs.c b/source/libs/cairo/cairo-1.14.2/src/cairo-gl-glyphs.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gl-gradient-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-gl-gradient-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gl-gradient.c b/source/libs/cairo/cairo-1.14.2/src/cairo-gl-gradient.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gl-info.c b/source/libs/cairo/cairo-1.14.2/src/cairo-gl-info.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gl-msaa-compositor.c b/source/libs/cairo/cairo-1.14.2/src/cairo-gl-msaa-compositor.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gl-operand.c b/source/libs/cairo/cairo-1.14.2/src/cairo-gl-operand.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gl-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-gl-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gl-shaders.c b/source/libs/cairo/cairo-1.14.2/src/cairo-gl-shaders.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gl-source.c b/source/libs/cairo/cairo-1.14.2/src/cairo-gl-source.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gl-spans-compositor.c b/source/libs/cairo/cairo-1.14.2/src/cairo-gl-spans-compositor.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gl-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-gl-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gl-traps-compositor.c b/source/libs/cairo/cairo-1.14.2/src/cairo-gl-traps-compositor.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gl.h b/source/libs/cairo/cairo-1.14.2/src/cairo-gl.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-glx-context.c b/source/libs/cairo/cairo-1.14.2/src/cairo-glx-context.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gstate-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-gstate-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-gstate.c b/source/libs/cairo/cairo-1.14.2/src/cairo-gstate.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-hash-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-hash-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-hash.c b/source/libs/cairo/cairo-1.14.2/src/cairo-hash.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-hull.c b/source/libs/cairo/cairo-1.14.2/src/cairo-hull.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-image-compositor.c b/source/libs/cairo/cairo-1.14.2/src/cairo-image-compositor.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-image-info-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-image-info-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-image-info.c b/source/libs/cairo/cairo-1.14.2/src/cairo-image-info.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-image-source.c b/source/libs/cairo/cairo-1.14.2/src/cairo-image-source.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-image-surface-inline.h b/source/libs/cairo/cairo-1.14.2/src/cairo-image-surface-inline.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-image-surface-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-image-surface-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-image-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-image-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-line-inline.h b/source/libs/cairo/cairo-1.14.2/src/cairo-line-inline.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-line-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-line-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-line.c b/source/libs/cairo/cairo-1.14.2/src/cairo-line.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-list-inline.h b/source/libs/cairo/cairo-1.14.2/src/cairo-list-inline.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-list-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-list-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-lzw.c b/source/libs/cairo/cairo-1.14.2/src/cairo-lzw.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-malloc-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-malloc-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-mask-compositor.c b/source/libs/cairo/cairo-1.14.2/src/cairo-mask-compositor.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-matrix.c b/source/libs/cairo/cairo-1.14.2/src/cairo-matrix.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-mempool-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-mempool-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-mempool.c b/source/libs/cairo/cairo-1.14.2/src/cairo-mempool.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-mesh-pattern-rasterizer.c b/source/libs/cairo/cairo-1.14.2/src/cairo-mesh-pattern-rasterizer.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-misc.c b/source/libs/cairo/cairo-1.14.2/src/cairo-misc.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-mono-scan-converter.c b/source/libs/cairo/cairo-1.14.2/src/cairo-mono-scan-converter.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-mutex-impl-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-mutex-impl-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-mutex-list-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-mutex-list-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-mutex-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-mutex-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-mutex-type-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-mutex-type-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-mutex.c b/source/libs/cairo/cairo-1.14.2/src/cairo-mutex.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-no-compositor.c b/source/libs/cairo/cairo-1.14.2/src/cairo-no-compositor.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-observer.c b/source/libs/cairo/cairo-1.14.2/src/cairo-observer.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-os2-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-os2-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-os2-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-os2-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-os2.h b/source/libs/cairo/cairo-1.14.2/src/cairo-os2.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-output-stream-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-output-stream-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-output-stream.c b/source/libs/cairo/cairo-1.14.2/src/cairo-output-stream.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-paginated-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-paginated-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-paginated-surface-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-paginated-surface-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-paginated-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-paginated-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-path-bounds.c b/source/libs/cairo/cairo-1.14.2/src/cairo-path-bounds.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-path-fill.c b/source/libs/cairo/cairo-1.14.2/src/cairo-path-fill.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-path-fixed-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-path-fixed-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-path-fixed.c b/source/libs/cairo/cairo-1.14.2/src/cairo-path-fixed.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-path-in-fill.c b/source/libs/cairo/cairo-1.14.2/src/cairo-path-in-fill.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-path-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-path-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-path-stroke-boxes.c b/source/libs/cairo/cairo-1.14.2/src/cairo-path-stroke-boxes.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-path-stroke-polygon.c b/source/libs/cairo/cairo-1.14.2/src/cairo-path-stroke-polygon.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-path-stroke-traps.c b/source/libs/cairo/cairo-1.14.2/src/cairo-path-stroke-traps.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-path-stroke-tristrip.c b/source/libs/cairo/cairo-1.14.2/src/cairo-path-stroke-tristrip.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-path-stroke.c b/source/libs/cairo/cairo-1.14.2/src/cairo-path-stroke.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-path.c b/source/libs/cairo/cairo-1.14.2/src/cairo-path.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-pattern-inline.h b/source/libs/cairo/cairo-1.14.2/src/cairo-pattern-inline.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-pattern-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-pattern-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-pattern.c b/source/libs/cairo/cairo-1.14.2/src/cairo-pattern.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-pdf-operators-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-pdf-operators-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-pdf-operators.c b/source/libs/cairo/cairo-1.14.2/src/cairo-pdf-operators.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-pdf-shading-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-pdf-shading-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-pdf-shading.c b/source/libs/cairo/cairo-1.14.2/src/cairo-pdf-shading.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-pdf-surface-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-pdf-surface-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-pdf-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-pdf-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-pdf.h b/source/libs/cairo/cairo-1.14.2/src/cairo-pdf.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-pen.c b/source/libs/cairo/cairo-1.14.2/src/cairo-pen.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-pixman-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-pixman-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-png.c b/source/libs/cairo/cairo-1.14.2/src/cairo-png.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-polygon-intersect.c b/source/libs/cairo/cairo-1.14.2/src/cairo-polygon-intersect.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-polygon-reduce.c b/source/libs/cairo/cairo-1.14.2/src/cairo-polygon-reduce.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-polygon.c b/source/libs/cairo/cairo-1.14.2/src/cairo-polygon.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-ps-surface-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-ps-surface-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-ps-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-ps-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-ps.h b/source/libs/cairo/cairo-1.14.2/src/cairo-ps.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-qt-surface.cpp b/source/libs/cairo/cairo-1.14.2/src/cairo-qt-surface.cpp old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-qt.h b/source/libs/cairo/cairo-1.14.2/src/cairo-qt.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-quartz-font.c b/source/libs/cairo/cairo-1.14.2/src/cairo-quartz-font.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-quartz-image-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-quartz-image-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-quartz-image.h b/source/libs/cairo/cairo-1.14.2/src/cairo-quartz-image.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-quartz-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-quartz-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-quartz-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-quartz-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-quartz.h b/source/libs/cairo/cairo-1.14.2/src/cairo-quartz.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-raster-source-pattern.c b/source/libs/cairo/cairo-1.14.2/src/cairo-raster-source-pattern.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-recording-surface-inline.h b/source/libs/cairo/cairo-1.14.2/src/cairo-recording-surface-inline.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-recording-surface-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-recording-surface-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-recording-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-recording-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-rectangle.c b/source/libs/cairo/cairo-1.14.2/src/cairo-rectangle.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-rectangular-scan-converter.c b/source/libs/cairo/cairo-1.14.2/src/cairo-rectangular-scan-converter.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-reference-count-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-reference-count-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-region-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-region-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-region.c b/source/libs/cairo/cairo-1.14.2/src/cairo-region.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-rtree-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-rtree-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-rtree.c b/source/libs/cairo/cairo-1.14.2/src/cairo-rtree.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-scaled-font-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-scaled-font-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-scaled-font-subsets-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-scaled-font-subsets-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-scaled-font-subsets.c b/source/libs/cairo/cairo-1.14.2/src/cairo-scaled-font-subsets.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-scaled-font.c b/source/libs/cairo/cairo-1.14.2/src/cairo-scaled-font.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-script-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-script-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-script-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-script-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-script.h b/source/libs/cairo/cairo-1.14.2/src/cairo-script.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-shape-mask-compositor.c b/source/libs/cairo/cairo-1.14.2/src/cairo-shape-mask-compositor.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-skia.h b/source/libs/cairo/cairo-1.14.2/src/cairo-skia.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-slope-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-slope-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-slope.c b/source/libs/cairo/cairo-1.14.2/src/cairo-slope.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-spans-compositor-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-spans-compositor-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-spans-compositor.c b/source/libs/cairo/cairo-1.14.2/src/cairo-spans-compositor.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-spans-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-spans-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-spans.c b/source/libs/cairo/cairo-1.14.2/src/cairo-spans.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-spline.c b/source/libs/cairo/cairo-1.14.2/src/cairo-spline.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-stroke-dash-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-stroke-dash-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-stroke-dash.c b/source/libs/cairo/cairo-1.14.2/src/cairo-stroke-dash.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-stroke-style.c b/source/libs/cairo/cairo-1.14.2/src/cairo-stroke-style.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-backend-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-backend-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-clipper-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-clipper-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-clipper.c b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-clipper.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-fallback-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-fallback-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-fallback.c b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-fallback.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-inline.h b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-inline.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-observer-inline.h b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-observer-inline.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-observer-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-observer-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-observer.c b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-observer.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-offset-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-offset-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-offset.c b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-offset.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-snapshot-inline.h b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-snapshot-inline.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-snapshot-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-snapshot-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-snapshot.c b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-snapshot.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-subsurface-inline.h b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-subsurface-inline.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-subsurface-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-subsurface-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-subsurface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-subsurface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-wrapper-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-wrapper-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface-wrapper.c b/source/libs/cairo/cairo-1.14.2/src/cairo-surface-wrapper.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-svg-surface-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-svg-surface-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-svg-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-svg-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-svg.h b/source/libs/cairo/cairo-1.14.2/src/cairo-svg.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-tee-surface-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-tee-surface-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-tee-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-tee-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-tee.h b/source/libs/cairo/cairo-1.14.2/src/cairo-tee.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-time-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-time-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-time.c b/source/libs/cairo/cairo-1.14.2/src/cairo-time.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-tor-scan-converter.c b/source/libs/cairo/cairo-1.14.2/src/cairo-tor-scan-converter.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-tor22-scan-converter.c b/source/libs/cairo/cairo-1.14.2/src/cairo-tor22-scan-converter.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-toy-font-face.c b/source/libs/cairo/cairo-1.14.2/src/cairo-toy-font-face.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-traps-compositor.c b/source/libs/cairo/cairo-1.14.2/src/cairo-traps-compositor.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-traps-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-traps-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-traps.c b/source/libs/cairo/cairo-1.14.2/src/cairo-traps.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-tristrip-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-tristrip-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-tristrip.c b/source/libs/cairo/cairo-1.14.2/src/cairo-tristrip.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-truetype-subset-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-truetype-subset-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-truetype-subset.c b/source/libs/cairo/cairo-1.14.2/src/cairo-truetype-subset.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-type1-fallback.c b/source/libs/cairo/cairo-1.14.2/src/cairo-type1-fallback.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-type1-glyph-names.c b/source/libs/cairo/cairo-1.14.2/src/cairo-type1-glyph-names.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-type1-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-type1-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-type1-subset.c b/source/libs/cairo/cairo-1.14.2/src/cairo-type1-subset.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-type3-glyph-surface-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-type3-glyph-surface-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-type3-glyph-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-type3-glyph-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-types-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-types-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-unicode.c b/source/libs/cairo/cairo-1.14.2/src/cairo-unicode.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-uninstalled.pc.in b/source/libs/cairo/cairo-1.14.2/src/cairo-uninstalled.pc.in old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-user-font-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-user-font-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-user-font.c b/source/libs/cairo/cairo-1.14.2/src/cairo-user-font.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-version.c b/source/libs/cairo/cairo-1.14.2/src/cairo-version.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-version.h b/source/libs/cairo/cairo-1.14.2/src/cairo-version.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-vg-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-vg-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-vg.h b/source/libs/cairo/cairo-1.14.2/src/cairo-vg.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-wgl-context.c b/source/libs/cairo/cairo-1.14.2/src/cairo-wgl-context.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-wideint-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-wideint-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-wideint-type-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-wideint-type-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-wideint.c b/source/libs/cairo/cairo-1.14.2/src/cairo-wideint.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-win32.h b/source/libs/cairo/cairo-1.14.2/src/cairo-win32.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-connection-core.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-connection-core.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-connection-render.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-connection-render.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-connection-shm.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-connection-shm.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-connection.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-connection.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-resources.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-resources.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-screen.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-screen.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-shm.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-shm.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-surface-core.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-surface-core.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-surface-render.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-surface-render.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xcb-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xcb.h b/source/libs/cairo/cairo-1.14.2/src/cairo-xcb.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-core-compositor.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-core-compositor.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-display.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-display.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-fallback-compositor.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-fallback-compositor.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-render-compositor.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-render-compositor.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-screen.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-screen.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-source.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-source.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-surface-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-surface-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-surface-shm.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-surface-shm.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-visual.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-visual.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-xcb-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-xcb-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-xrender-private.h b/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-xrender-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-xrender.h b/source/libs/cairo/cairo-1.14.2/src/cairo-xlib-xrender.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xlib.h b/source/libs/cairo/cairo-1.14.2/src/cairo-xlib.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xml-surface.c b/source/libs/cairo/cairo-1.14.2/src/cairo-xml-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo-xml.h b/source/libs/cairo/cairo-1.14.2/src/cairo-xml.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo.c b/source/libs/cairo/cairo-1.14.2/src/cairo.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo.h b/source/libs/cairo/cairo-1.14.2/src/cairo.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairo.pc.in b/source/libs/cairo/cairo-1.14.2/src/cairo.pc.in old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/cairoint.h b/source/libs/cairo/cairo-1.14.2/src/cairoint.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/check-doc-syntax.awk b/source/libs/cairo/cairo-1.14.2/src/check-doc-syntax.awk old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/check-has-hidden-symbols.c b/source/libs/cairo/cairo-1.14.2/src/check-has-hidden-symbols.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/check-link.c b/source/libs/cairo/cairo-1.14.2/src/check-link.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/test-base-compositor-surface.c b/source/libs/cairo/cairo-1.14.2/src/test-base-compositor-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/test-compositor-surface-private.h b/source/libs/cairo/cairo-1.14.2/src/test-compositor-surface-private.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/test-compositor-surface.c b/source/libs/cairo/cairo-1.14.2/src/test-compositor-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/test-compositor-surface.h b/source/libs/cairo/cairo-1.14.2/src/test-compositor-surface.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/test-null-compositor-surface.c b/source/libs/cairo/cairo-1.14.2/src/test-null-compositor-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/test-null-compositor-surface.h b/source/libs/cairo/cairo-1.14.2/src/test-null-compositor-surface.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/test-paginated-surface.c b/source/libs/cairo/cairo-1.14.2/src/test-paginated-surface.c old mode 100755 new mode 100644 diff --git a/source/libs/cairo/cairo-1.14.2/src/test-paginated-surface.h b/source/libs/cairo/cairo-1.14.2/src/test-paginated-surface.h old mode 100755 new mode 100644 diff --git a/source/libs/cairo/configure b/source/libs/cairo/configure index d36967852..1c761b1c4 100755 --- a/source/libs/cairo/configure +++ b/source/libs/cairo/configure @@ -4666,13 +4666,13 @@ else if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_cflags="-Wimplicit -Wreturn-type" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement" ;; #( *) : ;; esac case `$CC -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -4684,7 +4684,7 @@ esac kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition" ;; #( *) : ;; diff --git a/source/libs/configure b/source/libs/configure index c99bca744..7e5fc0ed7 100755 --- a/source/libs/configure +++ b/source/libs/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for TeX Live libs 2015. +# Generated by GNU Autoconf 2.69 for TeX Live libs 2016/dev. # # Report bugs to . # @@ -579,8 +579,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='TeX Live libs' PACKAGE_TARNAME='tex-live-libs' -PACKAGE_VERSION='2015' -PACKAGE_STRING='TeX Live libs 2015' +PACKAGE_VERSION='2016/dev' +PACKAGE_STRING='TeX Live libs 2016/dev' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' @@ -726,6 +726,10 @@ enable_xetex enable_xetex_synctex enable_mf enable_mf_nowin +enable_mflua +enable_mflua_nowin +enable_mfluajit +enable_mfluajit_nowin with_mf_x_toolkit enable_epsfwin enable_hp2627win @@ -1323,7 +1327,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures TeX Live libs 2015 to adapt to many kinds of systems. +\`configure' configures TeX Live libs 2016/dev to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1393,7 +1397,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of TeX Live libs 2015:";; + short | recursive ) echo "Configuration of TeX Live libs 2016/dev:";; esac cat <<\_ACEOF @@ -1441,6 +1445,10 @@ Optional Features: --disable-mf do not compile and install METAFONT --disable-mf-nowin do not build a separate non-window-capable METAFONT + --disable-mflua do not compile and install MFLua + --enable-mflua-nowin build a separate non-window-capable MFLua + --disable-mfluajit do not compile and install MFLuaJIT + --enable-mfluajit-nowin build a separate non-window-capable MFLuaJIT --enable-epsfwin include EPSF pseudo window support --enable-hp2627win include HP 2627 window support --enable-mftalkwin include mftalk (generic server) window support @@ -1579,7 +1587,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -TeX Live libs configure 2015 +TeX Live libs configure 2016/dev generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1680,7 +1688,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by TeX Live libs $as_me 2015, which was +It was created by TeX Live libs $as_me 2016/dev, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3171,6 +3179,20 @@ $as_echo "$as_me: $host -> \`--disable-luajittex'" >&6;} ;; esac ;; esac +case $enable_mfluajit in #( + yes | no) : + : ;; #( + *) : + case $host in #( + alpha* | sparc* | x86_64-*-cygwin | powerpc-*-darwin* ) : + { $as_echo "$as_me:${as_lineno-$LINENO}: $host -> \`--disable-mfluajit'" >&5 +$as_echo "$as_me: $host -> \`--disable-mfluajit'" >&6;} + ac_configure_args="$ac_configure_args '--disable-mfluajit'" ;; #( + *) : + ;; +esac ;; +esac + ## texk/web2c/ac/withenable.ac: configure.ac fragment for the TeX Live subdirectory texk/web2c/ ## configure options and TL libraries required for web2c @@ -3483,6 +3505,62 @@ esac if test "${enable_mf_nowin+set}" = set; then : enableval=$enable_mf_nowin; fi +case $enable_mf_nowin in #( + yes | no) : + ;; #( + *) : + enable_mf_nowin=yes ;; +esac +# Check whether --enable-mflua was given. +if test "${enable_mflua+set}" = set; then : + enableval=$enable_mflua; +fi +case $enable_mflua in #( + yes | no) : + ;; #( + *) : + enable_mflua=yes ;; +esac + +# Check whether --enable-mflua-nowin was given. +if test "${enable_mflua_nowin+set}" = set; then : + enableval=$enable_mflua_nowin; +fi +case $enable_mflua_nowin in #( + yes | no) : + ;; #( + *) : + enable_mflua_nowin=no ;; +esac + +test "x$enable_web2c:$enable_mflua" = xyes:yes && { + need_lua52=yes +} +# Check whether --enable-mfluajit was given. +if test "${enable_mfluajit+set}" = set; then : + enableval=$enable_mfluajit; +fi +case $enable_mfluajit in #( + yes | no) : + ;; #( + *) : + enable_mfluajit=yes ;; +esac + +# Check whether --enable-mfluajit-nowin was given. +if test "${enable_mfluajit_nowin+set}" = set; then : + enableval=$enable_mfluajit_nowin; +fi +case $enable_mfluajit_nowin in #( + yes | no) : + ;; #( + *) : + enable_mfluajit_nowin=no ;; +esac + +test "x$enable_web2c:$enable_mfluajit" = xyes:yes && { + need_luajit=yes +} # Check whether --with-mf-x-toolkit was given. if test "${with_mf_x_toolkit+set}" = set; then : @@ -4442,7 +4520,7 @@ fi # Define the identity of the package. PACKAGE='tex-live-libs' - VERSION='2015' + VERSION='2016/dev' cat >>confdefs.h <<_ACEOF @@ -4725,13 +4803,13 @@ else if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_cflags="-Wimplicit -Wreturn-type" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement" ;; #( *) : ;; esac case `$CC -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -4743,7 +4821,7 @@ esac kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition" ;; #( *) : ;; @@ -5436,7 +5514,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by TeX Live libs $as_me 2015, which was +This file was extended by TeX Live libs $as_me 2016/dev, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5493,7 +5571,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -TeX Live libs config.status 2015 +TeX Live libs config.status 2016/dev configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/source/libs/gmp/configure b/source/libs/gmp/configure index aa35d22fc..f513f2bcd 100755 --- a/source/libs/gmp/configure +++ b/source/libs/gmp/configure @@ -4054,13 +4054,13 @@ else if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_cflags="-Wimplicit -Wreturn-type" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement" ;; #( *) : ;; esac case `$CC -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -4072,7 +4072,7 @@ esac kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition" ;; #( *) : ;; diff --git a/source/libs/gmp/native/configure b/source/libs/gmp/native/configure index b0b6fac3c..59838eb27 100755 --- a/source/libs/gmp/native/configure +++ b/source/libs/gmp/native/configure @@ -3575,13 +3575,13 @@ else if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_cflags="-Wimplicit -Wreturn-type" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement" ;; #( *) : ;; esac case `$CC -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -3593,7 +3593,7 @@ esac kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition" ;; #( *) : ;; diff --git a/source/libs/libpng/configure b/source/libs/libpng/configure index bec483673..04b141971 100755 --- a/source/libs/libpng/configure +++ b/source/libs/libpng/configure @@ -3960,13 +3960,13 @@ else if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_cflags="-Wimplicit -Wreturn-type" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement" ;; #( *) : ;; esac case `$CC -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -3978,7 +3978,7 @@ esac kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition" ;; #( *) : ;; diff --git a/source/libs/libpng/libpng-1.6.17-PATCHES/ChangeLog b/source/libs/libpng/libpng-1.6.17-PATCHES/ChangeLog old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17-PATCHES/TL-Changes b/source/libs/libpng/libpng-1.6.17-PATCHES/TL-Changes old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/ANNOUNCE b/source/libs/libpng/libpng-1.6.17/ANNOUNCE old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/CHANGES b/source/libs/libpng/libpng-1.6.17/CHANGES old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/CMakeLists.txt b/source/libs/libpng/libpng-1.6.17/CMakeLists.txt old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/INSTALL b/source/libs/libpng/libpng-1.6.17/INSTALL old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/LICENSE b/source/libs/libpng/libpng-1.6.17/LICENSE old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/Makefile.am b/source/libs/libpng/libpng-1.6.17/Makefile.am old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/README b/source/libs/libpng/libpng-1.6.17/README old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/TODO b/source/libs/libpng/libpng-1.6.17/TODO old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/arm/arm_init.c b/source/libs/libpng/libpng-1.6.17/arm/arm_init.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/arm/filter_neon.S b/source/libs/libpng/libpng-1.6.17/arm/filter_neon.S old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/arm/filter_neon_intrinsics.c b/source/libs/libpng/libpng-1.6.17/arm/filter_neon_intrinsics.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/config.h.in b/source/libs/libpng/libpng-1.6.17/config.h.in old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/configure.ac b/source/libs/libpng/libpng-1.6.17/configure.ac old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/README.txt b/source/libs/libpng/libpng-1.6.17/contrib/README.txt old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/arm-neon/README b/source/libs/libpng/libpng-1.6.17/contrib/arm-neon/README old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/arm-neon/android-ndk.c b/source/libs/libpng/libpng-1.6.17/contrib/arm-neon/android-ndk.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/arm-neon/linux-auxv.c b/source/libs/libpng/libpng-1.6.17/contrib/arm-neon/linux-auxv.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/arm-neon/linux.c b/source/libs/libpng/libpng-1.6.17/contrib/arm-neon/linux.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/conftest/README b/source/libs/libpng/libpng-1.6.17/contrib/conftest/README old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/conftest/read.dfa b/source/libs/libpng/libpng-1.6.17/contrib/conftest/read.dfa old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/conftest/s_read.dfa b/source/libs/libpng/libpng-1.6.17/contrib/conftest/s_read.dfa old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/conftest/s_write.dfa b/source/libs/libpng/libpng-1.6.17/contrib/conftest/s_write.dfa old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/conftest/simple.dfa b/source/libs/libpng/libpng-1.6.17/contrib/conftest/simple.dfa old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/conftest/write.dfa b/source/libs/libpng/libpng-1.6.17/contrib/conftest/write.dfa old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/examples/README.txt b/source/libs/libpng/libpng-1.6.17/contrib/examples/README.txt old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/examples/iccfrompng.c b/source/libs/libpng/libpng-1.6.17/contrib/examples/iccfrompng.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/examples/pngpixel.c b/source/libs/libpng/libpng-1.6.17/contrib/examples/pngpixel.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/examples/pngtopng.c b/source/libs/libpng/libpng-1.6.17/contrib/examples/pngtopng.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/COPYING b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/COPYING old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/LICENSE b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/LICENSE old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/Makefile.mingw32 b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/Makefile.mingw32 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/Makefile.sgi b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/Makefile.sgi old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/Makefile.unx b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/Makefile.unx old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/Makefile.w32 b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/Makefile.w32 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/README b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/README old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/makevms.com b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/makevms.com old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/readpng.c b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/readpng.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/readpng.h b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/readpng.h old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/readpng2.c b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/readpng2.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/readpng2.h b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/readpng2.h old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/readppm.c b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/readppm.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/rpng-win.c b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/rpng-win.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/rpng-x.c b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/rpng-x.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/rpng2-win.c b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/rpng2-win.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/rpng2-x.c b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/rpng2-x.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/toucan.png b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/toucan.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/wpng.c b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/wpng.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/writepng.c b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/writepng.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/gregbook/writepng.h b/source/libs/libpng/libpng-1.6.17/contrib/gregbook/writepng.h old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/libtests/fakepng.c b/source/libs/libpng/libpng-1.6.17/contrib/libtests/fakepng.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/libtests/makepng.c b/source/libs/libpng/libpng-1.6.17/contrib/libtests/makepng.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/libtests/pngimage.c b/source/libs/libpng/libpng-1.6.17/contrib/libtests/pngimage.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/libtests/pngstest.c b/source/libs/libpng/libpng-1.6.17/contrib/libtests/pngstest.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/libtests/pngunknown.c b/source/libs/libpng/libpng-1.6.17/contrib/libtests/pngunknown.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/libtests/pngvalid.c b/source/libs/libpng/libpng-1.6.17/contrib/libtests/pngvalid.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/libtests/readpng.c b/source/libs/libpng/libpng-1.6.17/contrib/libtests/readpng.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/libtests/tarith.c b/source/libs/libpng/libpng-1.6.17/contrib/libtests/tarith.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/libtests/timepng.c b/source/libs/libpng/libpng-1.6.17/contrib/libtests/timepng.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminim/README b/source/libs/libpng/libpng-1.6.17/contrib/pngminim/README old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminim/decoder/README b/source/libs/libpng/libpng-1.6.17/contrib/pngminim/decoder/README old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminim/decoder/makefile b/source/libs/libpng/libpng-1.6.17/contrib/pngminim/decoder/makefile old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminim/decoder/pngusr.dfa b/source/libs/libpng/libpng-1.6.17/contrib/pngminim/decoder/pngusr.dfa old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminim/decoder/pngusr.h b/source/libs/libpng/libpng-1.6.17/contrib/pngminim/decoder/pngusr.h old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminim/encoder/README b/source/libs/libpng/libpng-1.6.17/contrib/pngminim/encoder/README old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminim/encoder/makefile b/source/libs/libpng/libpng-1.6.17/contrib/pngminim/encoder/makefile old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminim/encoder/pngusr.dfa b/source/libs/libpng/libpng-1.6.17/contrib/pngminim/encoder/pngusr.dfa old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminim/encoder/pngusr.h b/source/libs/libpng/libpng-1.6.17/contrib/pngminim/encoder/pngusr.h old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminim/preader/README b/source/libs/libpng/libpng-1.6.17/contrib/pngminim/preader/README old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminim/preader/makefile b/source/libs/libpng/libpng-1.6.17/contrib/pngminim/preader/makefile old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminim/preader/pngusr.dfa b/source/libs/libpng/libpng-1.6.17/contrib/pngminim/preader/pngusr.dfa old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminim/preader/pngusr.h b/source/libs/libpng/libpng-1.6.17/contrib/pngminim/preader/pngusr.h old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminus/README b/source/libs/libpng/libpng-1.6.17/contrib/pngminus/README old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminus/makefile.std b/source/libs/libpng/libpng-1.6.17/contrib/pngminus/makefile.std old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminus/makefile.tc3 b/source/libs/libpng/libpng-1.6.17/contrib/pngminus/makefile.tc3 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminus/makevms.com b/source/libs/libpng/libpng-1.6.17/contrib/pngminus/makevms.com old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminus/png2pnm.bat b/source/libs/libpng/libpng-1.6.17/contrib/pngminus/png2pnm.bat old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminus/png2pnm.c b/source/libs/libpng/libpng-1.6.17/contrib/pngminus/png2pnm.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminus/pngminus.bat b/source/libs/libpng/libpng-1.6.17/contrib/pngminus/pngminus.bat old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminus/pnm2png.bat b/source/libs/libpng/libpng-1.6.17/contrib/pngminus/pnm2png.bat old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngminus/pnm2png.c b/source/libs/libpng/libpng-1.6.17/contrib/pngminus/pnm2png.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/README b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/README old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn0g01.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn0g01.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn0g02.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn0g02.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn0g04.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn0g04.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn0g08.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn0g08.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn0g16.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn0g16.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn2c08.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn2c08.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn2c16.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn2c16.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn3p01.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn3p01.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn3p02.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn3p02.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn3p04.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn3p04.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn3p08.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn3p08.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn4a08.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn4a08.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn4a16.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn4a16.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn6a08.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn6a08.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn6a16.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/basn6a16.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbbn0g01.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbbn0g01.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbbn0g02.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbbn0g02.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbbn0g04.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbbn0g04.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbbn2c16.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbbn2c16.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbbn3p08.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbbn3p08.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbgn2c16.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbgn2c16.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbgn3p08.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbgn3p08.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbrn2c08.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbrn2c08.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbwn0g16.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbwn0g16.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbwn3p08.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbwn3p08.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbyn3p08.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftbyn3p08.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftp0n0g08.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftp0n0g08.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftp0n2c08.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftp0n2c08.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftp0n3p08.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftp0n3p08.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftp1n3p08.png b/source/libs/libpng/libpng-1.6.17/contrib/pngsuite/ftp1n3p08.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/tools/README.txt b/source/libs/libpng/libpng-1.6.17/contrib/tools/README.txt old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/tools/checksum-icc.c b/source/libs/libpng/libpng-1.6.17/contrib/tools/checksum-icc.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/tools/chkfmt b/source/libs/libpng/libpng-1.6.17/contrib/tools/chkfmt old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/tools/cvtcolor.c b/source/libs/libpng/libpng-1.6.17/contrib/tools/cvtcolor.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/tools/makesRGB.c b/source/libs/libpng/libpng-1.6.17/contrib/tools/makesRGB.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/tools/png-fix-itxt.c b/source/libs/libpng/libpng-1.6.17/contrib/tools/png-fix-itxt.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/tools/pngfix.c b/source/libs/libpng/libpng-1.6.17/contrib/tools/pngfix.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/tools/sRGB.h b/source/libs/libpng/libpng-1.6.17/contrib/tools/sRGB.h old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/visupng/PngFile.c b/source/libs/libpng/libpng-1.6.17/contrib/visupng/PngFile.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/visupng/PngFile.h b/source/libs/libpng/libpng-1.6.17/contrib/visupng/PngFile.h old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/visupng/README.txt b/source/libs/libpng/libpng-1.6.17/contrib/visupng/README.txt old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/visupng/VisualPng.c b/source/libs/libpng/libpng-1.6.17/contrib/visupng/VisualPng.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/visupng/VisualPng.dsp b/source/libs/libpng/libpng-1.6.17/contrib/visupng/VisualPng.dsp old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/visupng/VisualPng.dsw b/source/libs/libpng/libpng-1.6.17/contrib/visupng/VisualPng.dsw old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/visupng/VisualPng.ico b/source/libs/libpng/libpng-1.6.17/contrib/visupng/VisualPng.ico old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/visupng/VisualPng.png b/source/libs/libpng/libpng-1.6.17/contrib/visupng/VisualPng.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/visupng/VisualPng.rc b/source/libs/libpng/libpng-1.6.17/contrib/visupng/VisualPng.rc old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/visupng/cexcept.h b/source/libs/libpng/libpng-1.6.17/contrib/visupng/cexcept.h old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/contrib/visupng/resource.h b/source/libs/libpng/libpng-1.6.17/contrib/visupng/resource.h old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/example.c b/source/libs/libpng/libpng-1.6.17/example.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/libpng-config.in b/source/libs/libpng/libpng-1.6.17/libpng-config.in old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/libpng-manual.txt b/source/libs/libpng/libpng-1.6.17/libpng-manual.txt old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/libpng.3 b/source/libs/libpng/libpng-1.6.17/libpng.3 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/libpng.pc.in b/source/libs/libpng/libpng-1.6.17/libpng.pc.in old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/libpngpf.3 b/source/libs/libpng/libpng-1.6.17/libpngpf.3 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/png.5 b/source/libs/libpng/libpng-1.6.17/png.5 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/png.c b/source/libs/libpng/libpng-1.6.17/png.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/png.h b/source/libs/libpng/libpng-1.6.17/png.h old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngbar.jpg b/source/libs/libpng/libpng-1.6.17/pngbar.jpg old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngbar.png b/source/libs/libpng/libpng-1.6.17/pngbar.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngconf.h b/source/libs/libpng/libpng-1.6.17/pngconf.h old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngdebug.h b/source/libs/libpng/libpng-1.6.17/pngdebug.h old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngerror.c b/source/libs/libpng/libpng-1.6.17/pngerror.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngget.c b/source/libs/libpng/libpng-1.6.17/pngget.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pnginfo.h b/source/libs/libpng/libpng-1.6.17/pnginfo.h old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pnglibconf.h b/source/libs/libpng/libpng-1.6.17/pnglibconf.h old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngmem.c b/source/libs/libpng/libpng-1.6.17/pngmem.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngnow.png b/source/libs/libpng/libpng-1.6.17/pngnow.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngpread.c b/source/libs/libpng/libpng-1.6.17/pngpread.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngpriv.h b/source/libs/libpng/libpng-1.6.17/pngpriv.h old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngread.c b/source/libs/libpng/libpng-1.6.17/pngread.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngrio.c b/source/libs/libpng/libpng-1.6.17/pngrio.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngrtran.c b/source/libs/libpng/libpng-1.6.17/pngrtran.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngrutil.c b/source/libs/libpng/libpng-1.6.17/pngrutil.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngset.c b/source/libs/libpng/libpng-1.6.17/pngset.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngstruct.h b/source/libs/libpng/libpng-1.6.17/pngstruct.h old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngtest.c b/source/libs/libpng/libpng-1.6.17/pngtest.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngtest.png b/source/libs/libpng/libpng-1.6.17/pngtest.png old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngtrans.c b/source/libs/libpng/libpng-1.6.17/pngtrans.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngusr.dfa b/source/libs/libpng/libpng-1.6.17/pngusr.dfa old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngwio.c b/source/libs/libpng/libpng-1.6.17/pngwio.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngwrite.c b/source/libs/libpng/libpng-1.6.17/pngwrite.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngwtran.c b/source/libs/libpng/libpng-1.6.17/pngwtran.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/pngwutil.c b/source/libs/libpng/libpng-1.6.17/pngwutil.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/owatcom/libpng.tgt b/source/libs/libpng/libpng-1.6.17/projects/owatcom/libpng.tgt old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/owatcom/libpng.wpj b/source/libs/libpng/libpng-1.6.17/projects/owatcom/libpng.wpj old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/owatcom/pngconfig.mak b/source/libs/libpng/libpng-1.6.17/projects/owatcom/pngconfig.mak old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/owatcom/pngstest.tgt b/source/libs/libpng/libpng-1.6.17/projects/owatcom/pngstest.tgt old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/owatcom/pngtest.tgt b/source/libs/libpng/libpng-1.6.17/projects/owatcom/pngtest.tgt old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/owatcom/pngvalid.tgt b/source/libs/libpng/libpng-1.6.17/projects/owatcom/pngvalid.tgt old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/visualc71/PRJ0041.mak b/source/libs/libpng/libpng-1.6.17/projects/visualc71/PRJ0041.mak old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/visualc71/README.txt b/source/libs/libpng/libpng-1.6.17/projects/visualc71/README.txt old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/visualc71/README_zlib.txt b/source/libs/libpng/libpng-1.6.17/projects/visualc71/README_zlib.txt old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/visualc71/libpng.sln b/source/libs/libpng/libpng-1.6.17/projects/visualc71/libpng.sln old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/visualc71/libpng.vcproj b/source/libs/libpng/libpng-1.6.17/projects/visualc71/libpng.vcproj old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/visualc71/pngtest.vcproj b/source/libs/libpng/libpng-1.6.17/projects/visualc71/pngtest.vcproj old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/visualc71/zlib.vcproj b/source/libs/libpng/libpng-1.6.17/projects/visualc71/zlib.vcproj old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/vstudio/WARNING b/source/libs/libpng/libpng-1.6.17/projects/vstudio/WARNING old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/vstudio/libpng/libpng.vcxproj b/source/libs/libpng/libpng-1.6.17/projects/vstudio/libpng/libpng.vcxproj old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/vstudio/pnglibconf/pnglibconf.vcxproj b/source/libs/libpng/libpng-1.6.17/projects/vstudio/pnglibconf/pnglibconf.vcxproj old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/vstudio/pngstest/pngstest.vcxproj b/source/libs/libpng/libpng-1.6.17/projects/vstudio/pngstest/pngstest.vcxproj old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/vstudio/pngtest/pngtest.vcxproj b/source/libs/libpng/libpng-1.6.17/projects/vstudio/pngtest/pngtest.vcxproj old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/vstudio/pngunknown/pngunknown.vcxproj b/source/libs/libpng/libpng-1.6.17/projects/vstudio/pngunknown/pngunknown.vcxproj old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/vstudio/pngvalid/pngvalid.vcxproj b/source/libs/libpng/libpng-1.6.17/projects/vstudio/pngvalid/pngvalid.vcxproj old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/vstudio/readme.txt b/source/libs/libpng/libpng-1.6.17/projects/vstudio/readme.txt old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/vstudio/vstudio.sln b/source/libs/libpng/libpng-1.6.17/projects/vstudio/vstudio.sln old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/vstudio/zlib.props b/source/libs/libpng/libpng-1.6.17/projects/vstudio/zlib.props old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/projects/vstudio/zlib/zlib.vcxproj b/source/libs/libpng/libpng-1.6.17/projects/vstudio/zlib/zlib.vcxproj old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/README.txt b/source/libs/libpng/libpng-1.6.17/scripts/README.txt old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/SCOPTIONS.ppc b/source/libs/libpng/libpng-1.6.17/scripts/SCOPTIONS.ppc old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/checksym.awk b/source/libs/libpng/libpng-1.6.17/scripts/checksym.awk old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/def.c b/source/libs/libpng/libpng-1.6.17/scripts/def.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/descrip.mms b/source/libs/libpng/libpng-1.6.17/scripts/descrip.mms old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/dfn.awk b/source/libs/libpng/libpng-1.6.17/scripts/dfn.awk old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/intprefix.c b/source/libs/libpng/libpng-1.6.17/scripts/intprefix.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/libpng-config-body.in b/source/libs/libpng/libpng-1.6.17/scripts/libpng-config-body.in old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/libpng-config-head.in b/source/libs/libpng/libpng-1.6.17/scripts/libpng-config-head.in old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/libpng.pc.in b/source/libs/libpng/libpng-1.6.17/scripts/libpng.pc.in old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/libtool.m4 b/source/libs/libpng/libpng-1.6.17/scripts/libtool.m4 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/ltoptions.m4 b/source/libs/libpng/libpng-1.6.17/scripts/ltoptions.m4 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/ltsugar.m4 b/source/libs/libpng/libpng-1.6.17/scripts/ltsugar.m4 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/ltversion.m4 b/source/libs/libpng/libpng-1.6.17/scripts/ltversion.m4 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/lt~obsolete.m4 b/source/libs/libpng/libpng-1.6.17/scripts/lt~obsolete.m4 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/macro.lst b/source/libs/libpng/libpng-1.6.17/scripts/macro.lst old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.32sunu b/source/libs/libpng/libpng-1.6.17/scripts/makefile.32sunu old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.64sunu b/source/libs/libpng/libpng-1.6.17/scripts/makefile.64sunu old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.acorn b/source/libs/libpng/libpng-1.6.17/scripts/makefile.acorn old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.aix b/source/libs/libpng/libpng-1.6.17/scripts/makefile.aix old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.amiga b/source/libs/libpng/libpng-1.6.17/scripts/makefile.amiga old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.atari b/source/libs/libpng/libpng-1.6.17/scripts/makefile.atari old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.bc32 b/source/libs/libpng/libpng-1.6.17/scripts/makefile.bc32 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.beos b/source/libs/libpng/libpng-1.6.17/scripts/makefile.beos old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.bor b/source/libs/libpng/libpng-1.6.17/scripts/makefile.bor old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.cegcc b/source/libs/libpng/libpng-1.6.17/scripts/makefile.cegcc old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.darwin b/source/libs/libpng/libpng-1.6.17/scripts/makefile.darwin old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.dec b/source/libs/libpng/libpng-1.6.17/scripts/makefile.dec old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.dj2 b/source/libs/libpng/libpng-1.6.17/scripts/makefile.dj2 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.freebsd b/source/libs/libpng/libpng-1.6.17/scripts/makefile.freebsd old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.gcc b/source/libs/libpng/libpng-1.6.17/scripts/makefile.gcc old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.hp64 b/source/libs/libpng/libpng-1.6.17/scripts/makefile.hp64 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.hpgcc b/source/libs/libpng/libpng-1.6.17/scripts/makefile.hpgcc old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.hpux b/source/libs/libpng/libpng-1.6.17/scripts/makefile.hpux old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.ibmc b/source/libs/libpng/libpng-1.6.17/scripts/makefile.ibmc old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.intel b/source/libs/libpng/libpng-1.6.17/scripts/makefile.intel old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.knr b/source/libs/libpng/libpng-1.6.17/scripts/makefile.knr old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.linux b/source/libs/libpng/libpng-1.6.17/scripts/makefile.linux old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.mips b/source/libs/libpng/libpng-1.6.17/scripts/makefile.mips old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.msc b/source/libs/libpng/libpng-1.6.17/scripts/makefile.msc old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.msys b/source/libs/libpng/libpng-1.6.17/scripts/makefile.msys old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.ne12bsd b/source/libs/libpng/libpng-1.6.17/scripts/makefile.ne12bsd old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.netbsd b/source/libs/libpng/libpng-1.6.17/scripts/makefile.netbsd old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.openbsd b/source/libs/libpng/libpng-1.6.17/scripts/makefile.openbsd old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.sco b/source/libs/libpng/libpng-1.6.17/scripts/makefile.sco old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.sggcc b/source/libs/libpng/libpng-1.6.17/scripts/makefile.sggcc old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.sgi b/source/libs/libpng/libpng-1.6.17/scripts/makefile.sgi old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.so9 b/source/libs/libpng/libpng-1.6.17/scripts/makefile.so9 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.solaris b/source/libs/libpng/libpng-1.6.17/scripts/makefile.solaris old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.solaris-x86 b/source/libs/libpng/libpng-1.6.17/scripts/makefile.solaris-x86 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.std b/source/libs/libpng/libpng-1.6.17/scripts/makefile.std old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.sunos b/source/libs/libpng/libpng-1.6.17/scripts/makefile.sunos old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.tc3 b/source/libs/libpng/libpng-1.6.17/scripts/makefile.tc3 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makefile.vcwin32 b/source/libs/libpng/libpng-1.6.17/scripts/makefile.vcwin32 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/makevms.com b/source/libs/libpng/libpng-1.6.17/scripts/makevms.com old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/options.awk b/source/libs/libpng/libpng-1.6.17/scripts/options.awk old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/pnglibconf.dfa b/source/libs/libpng/libpng-1.6.17/scripts/pnglibconf.dfa old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/pnglibconf.h.prebuilt b/source/libs/libpng/libpng-1.6.17/scripts/pnglibconf.h.prebuilt old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/pnglibconf.mak b/source/libs/libpng/libpng-1.6.17/scripts/pnglibconf.mak old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/pngwin.rc b/source/libs/libpng/libpng-1.6.17/scripts/pngwin.rc old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/prefix.c b/source/libs/libpng/libpng-1.6.17/scripts/prefix.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/smakefile.ppc b/source/libs/libpng/libpng-1.6.17/scripts/smakefile.ppc old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/sym.c b/source/libs/libpng/libpng-1.6.17/scripts/sym.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/symbols.c b/source/libs/libpng/libpng-1.6.17/scripts/symbols.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/symbols.def b/source/libs/libpng/libpng-1.6.17/scripts/symbols.def old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/scripts/vers.c b/source/libs/libpng/libpng-1.6.17/scripts/vers.c old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngimage-full b/source/libs/libpng/libpng-1.6.17/tests/pngimage-full old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngimage-quick b/source/libs/libpng/libpng-1.6.17/tests/pngimage-quick old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngstest b/source/libs/libpng/libpng-1.6.17/tests/pngstest old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngstest-0g01 b/source/libs/libpng/libpng-1.6.17/tests/pngstest-0g01 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngstest-0g02 b/source/libs/libpng/libpng-1.6.17/tests/pngstest-0g02 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngstest-0g04 b/source/libs/libpng/libpng-1.6.17/tests/pngstest-0g04 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngstest-0g08 b/source/libs/libpng/libpng-1.6.17/tests/pngstest-0g08 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngstest-0g16 b/source/libs/libpng/libpng-1.6.17/tests/pngstest-0g16 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngstest-2c08 b/source/libs/libpng/libpng-1.6.17/tests/pngstest-2c08 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngstest-2c16 b/source/libs/libpng/libpng-1.6.17/tests/pngstest-2c16 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngstest-3p01 b/source/libs/libpng/libpng-1.6.17/tests/pngstest-3p01 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngstest-3p02 b/source/libs/libpng/libpng-1.6.17/tests/pngstest-3p02 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngstest-3p04 b/source/libs/libpng/libpng-1.6.17/tests/pngstest-3p04 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngstest-3p08 b/source/libs/libpng/libpng-1.6.17/tests/pngstest-3p08 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngstest-4a08 b/source/libs/libpng/libpng-1.6.17/tests/pngstest-4a08 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngstest-4a16 b/source/libs/libpng/libpng-1.6.17/tests/pngstest-4a16 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngstest-6a08 b/source/libs/libpng/libpng-1.6.17/tests/pngstest-6a08 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngstest-6a16 b/source/libs/libpng/libpng-1.6.17/tests/pngstest-6a16 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngstest-error b/source/libs/libpng/libpng-1.6.17/tests/pngstest-error old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngtest b/source/libs/libpng/libpng-1.6.17/tests/pngtest old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngunknown-IDAT b/source/libs/libpng/libpng-1.6.17/tests/pngunknown-IDAT old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngunknown-discard b/source/libs/libpng/libpng-1.6.17/tests/pngunknown-discard old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngunknown-if-safe b/source/libs/libpng/libpng-1.6.17/tests/pngunknown-if-safe old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngunknown-sAPI b/source/libs/libpng/libpng-1.6.17/tests/pngunknown-sAPI old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngunknown-sTER b/source/libs/libpng/libpng-1.6.17/tests/pngunknown-sTER old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngunknown-save b/source/libs/libpng/libpng-1.6.17/tests/pngunknown-save old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngunknown-vpAg b/source/libs/libpng/libpng-1.6.17/tests/pngunknown-vpAg old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-16-to-8 b/source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-16-to-8 old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-alpha-mode b/source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-alpha-mode old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-background b/source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-background old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-expand16-alpha-mode b/source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-expand16-alpha-mode old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-expand16-background b/source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-expand16-background old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-expand16-transform b/source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-expand16-transform old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-sbit b/source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-sbit old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-threshold b/source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-threshold old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-transform b/source/libs/libpng/libpng-1.6.17/tests/pngvalid-gamma-transform old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngvalid-progressive-interlace-size b/source/libs/libpng/libpng-1.6.17/tests/pngvalid-progressive-interlace-size old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngvalid-progressive-interlace-standard b/source/libs/libpng/libpng-1.6.17/tests/pngvalid-progressive-interlace-standard old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngvalid-progressive-interlace-transform b/source/libs/libpng/libpng-1.6.17/tests/pngvalid-progressive-interlace-transform old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngvalid-progressive-standard b/source/libs/libpng/libpng-1.6.17/tests/pngvalid-progressive-standard old mode 100755 new mode 100644 diff --git a/source/libs/libpng/libpng-1.6.17/tests/pngvalid-standard b/source/libs/libpng/libpng-1.6.17/tests/pngvalid-standard old mode 100755 new mode 100644 diff --git a/source/libs/lua52/configure b/source/libs/lua52/configure index 187c0a827..e2ee66ceb 100755 --- a/source/libs/lua52/configure +++ b/source/libs/lua52/configure @@ -4054,13 +4054,13 @@ else if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_cflags="-Wimplicit -Wreturn-type" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement" ;; #( *) : ;; esac case `$CC -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -4072,7 +4072,7 @@ esac kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition" ;; #( *) : ;; diff --git a/source/libs/luajit/ChangeLog b/source/libs/luajit/ChangeLog index 9f7a72e82..93745a1dd 100644 --- a/source/libs/luajit/ChangeLog +++ b/source/libs/luajit/ChangeLog @@ -1,3 +1,8 @@ +2015-06-12 Peter Breitenlohner + + Import LuaJIT-2.0.4. + * version.ac: Adjust. + 2015-02-16 Peter Breitenlohner * Makefile.am: Use the fragment ../../am/dist_hook.am. diff --git a/source/libs/luajit/LuaJIT-2.0.3-PATCHES/patch-01-LuaJITTeX b/source/libs/luajit/LuaJIT-2.0.3-PATCHES/patch-01-LuaJITTeX deleted file mode 100644 index 351a00f3c..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3-PATCHES/patch-01-LuaJITTeX +++ /dev/null @@ -1,175 +0,0 @@ -diff -ur -x lbitlib.c LuaJIT-2.0.3.orig/src/Makefile LuaJIT-2.0.3/src/Makefile ---- LuaJIT-2.0.3.orig/src/Makefile 2014-03-12 13:10:00.000000000 +0100 -+++ LuaJIT-2.0.3/src/Makefile 2014-03-14 09:15:50.000000000 +0100 -@@ -100,7 +100,7 @@ - # enabled by default. Some other features that *might* break some existing - # code (e.g. __pairs or os.execute() return values) can be enabled here. - # Note: this does not provide full compatibility with Lua 5.2 at this time. --#XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT -+XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT - # - # Disable the JIT compiler, i.e. turn LuaJIT into a pure interpreter. - #XCFLAGS+= -DLUAJIT_DISABLE_JIT -@@ -450,7 +450,7 @@ - LJVM_BOUT= $(LJVM_S) - LJVM_MODE= elfasm - --LJLIB_O= lib_base.o lib_math.o lib_bit.o lib_string.o lib_table.o \ -+LJLIB_O= lib_base.o lib_math.o lbitlib.o lib_bit.o lib_string.o lib_table.o \ - lib_io.o lib_os.o lib_package.o lib_debug.o lib_jit.o lib_ffi.o - LJLIB_C= $(LJLIB_O:.o=.c) - -diff -ur -x lbitlib.c LuaJIT-2.0.3.orig/src/Makefile.dep LuaJIT-2.0.3/src/Makefile.dep ---- LuaJIT-2.0.3.orig/src/Makefile.dep 2014-03-12 13:10:00.000000000 +0100 -+++ LuaJIT-2.0.3/src/Makefile.dep 2014-03-14 09:15:50.000000000 +0100 -@@ -6,6 +6,7 @@ - lj_tab.h lj_meta.h lj_state.h lj_ctype.h lj_cconv.h lj_bc.h lj_ff.h \ - lj_ffdef.h lj_dispatch.h lj_jit.h lj_ir.h lj_char.h lj_strscan.h \ - lj_lib.h lj_libdef.h -+lbitlib.o: lbitlib.c lua.h luaconf.h lauxlib.h lualib.h - lib_bit.o: lib_bit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ - lj_arch.h lj_err.h lj_errmsg.h lj_str.h lj_lib.h lj_libdef.h - lib_debug.o: lib_debug.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ -diff -ur -x lbitlib.c LuaJIT-2.0.3.orig/src/lauxlib.h LuaJIT-2.0.3/src/lauxlib.h ---- LuaJIT-2.0.3.orig/src/lauxlib.h 2014-03-12 13:10:00.000000000 +0100 -+++ LuaJIT-2.0.3/src/lauxlib.h 2014-03-14 09:15:50.000000000 +0100 -@@ -86,6 +86,32 @@ - int level); - - -+ -+/* -+** {====================================================== -+** File handles for IO library -+** ======================================================= -+*/ -+ -+/* -+** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and -+** initial structure 'luaL_Stream' (it may contain other fields -+** after that initial structure). -+*/ -+ -+#define LUA_FILEHANDLE "FILE*" -+ -+ -+typedef struct luaL_Stream { -+ FILE *f; /* stream (NULL for incompletely created streams) */ -+ lua_CFunction closef; /* to close stream (NULL for closed streams) */ -+} luaL_Stream; -+ -+/* }====================================================== */ -+ -+ -+ -+ - /* - ** =============================================================== - ** some useful macros -diff -ur -x lbitlib.c LuaJIT-2.0.3.orig/src/lib_init.c LuaJIT-2.0.3/src/lib_init.c ---- LuaJIT-2.0.3.orig/src/lib_init.c 2014-03-12 13:10:00.000000000 +0100 -+++ LuaJIT-2.0.3/src/lib_init.c 2014-03-14 09:15:50.000000000 +0100 -@@ -26,6 +26,7 @@ - { LUA_DBLIBNAME, luaopen_debug }, - { LUA_BITLIBNAME, luaopen_bit }, - { LUA_JITLIBNAME, luaopen_jit }, -+ { LUA_BITLIBNAME_32, luaopen_bit32 }, - { NULL, NULL } - }; - -diff -ur -x lbitlib.c LuaJIT-2.0.3.orig/src/lib_package.c LuaJIT-2.0.3/src/lib_package.c ---- LuaJIT-2.0.3.orig/src/lib_package.c 2014-03-12 13:10:00.000000000 +0100 -+++ LuaJIT-2.0.3/src/lib_package.c 2014-03-14 09:15:50.000000000 +0100 -@@ -354,6 +354,29 @@ - return 1; /* library loaded successfully */ - } - -+#define LUA_POF "luaopen_" -+#define LUA_OFSEP "_" -+#define POF LUA_POF -+ -+static const char *mkfuncname (lua_State *L, const char *modname) { -+ const char *funcname; -+ const char *mark = strchr(modname, *LUA_IGMARK); -+ if (mark) modname = mark + 1; -+ funcname = luaL_gsub(L, modname, ".", LUA_OFSEP); -+ funcname = lua_pushfstring(L, POF"%s", funcname); -+ lua_remove(L, -2); /* remove 'gsub' result */ -+ return funcname; -+} -+ -+ -+int loader_C_luatex (lua_State *L, const char *name, const char *filename) { -+ const char *funcname; -+ funcname = mkfuncname(L, name); -+ if (ll_loadfunc(L, filename, funcname,0) != 0) -+ loaderror(L, filename); -+ return 1; /* library loaded successfully */ -+} -+ - static int lj_cf_package_loader_croot(lua_State *L) - { - const char *filename; -@@ -373,6 +396,21 @@ - return 1; - } - -+int loader_Call_luatex (lua_State *L, const char *name, const char *filename) { -+ const char *funcname; -+ int stat; -+ if (filename == NULL) return 1; /* root not found */ -+ funcname = mkfuncname(L, name); -+ if ((stat = ll_loadfunc(L, filename, funcname,0)) != 0) { -+ if (stat != PACKAGE_ERR_FUNC) loaderror(L, filename); /* real error */ -+ lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, -+ name, filename); -+ return 1; /* function not found */ -+ } -+ return 1; /* library loaded successfully */ -+} -+ -+ - static int lj_cf_package_loader_preload(lua_State *L) - { - const char *name = luaL_checkstring(L, 1); -diff -ur -x lbitlib.c LuaJIT-2.0.3.orig/src/lua.h LuaJIT-2.0.3/src/lua.h ---- LuaJIT-2.0.3.orig/src/lua.h 2014-03-12 13:10:00.000000000 +0100 -+++ LuaJIT-2.0.3/src/lua.h 2014-03-14 09:15:50.000000000 +0100 -@@ -348,6 +348,16 @@ - const char *chunkname, const char *mode); - - -+#define LUA_OPEQ 0 -+#define LUA_OPLT 1 -+#define LUA_OPLE 2 -+#define LUA_OK 0 -+ -+/* see http://comments.gmane.org/gmane.comp.programming.swig/18673 */ -+# define lua_rawlen lua_objlen -+ -+ -+ - struct lua_Debug { - int event; - const char *name; /* (n) */ -diff -ur -x lbitlib.c LuaJIT-2.0.3.orig/src/lualib.h LuaJIT-2.0.3/src/lualib.h ---- LuaJIT-2.0.3.orig/src/lualib.h 2014-03-12 13:10:00.000000000 +0100 -+++ LuaJIT-2.0.3/src/lualib.h 2014-03-14 09:15:50.000000000 +0100 -@@ -22,6 +22,8 @@ - #define LUA_JITLIBNAME "jit" - #define LUA_FFILIBNAME "ffi" - -+#define LUA_BITLIBNAME_32 "bit32" -+ - LUALIB_API int luaopen_base(lua_State *L); - LUALIB_API int luaopen_math(lua_State *L); - LUALIB_API int luaopen_string(lua_State *L); -@@ -34,6 +36,8 @@ - LUALIB_API int luaopen_jit(lua_State *L); - LUALIB_API int luaopen_ffi(lua_State *L); - -+LUALIB_API int luaopen_bit32(lua_State *L); -+ - LUALIB_API void luaL_openlibs(lua_State *L); - - #ifndef lua_assert diff --git a/source/libs/luajit/LuaJIT-2.0.3-PATCHES/patch-05-LuaJITTeX b/source/libs/luajit/LuaJIT-2.0.3-PATCHES/patch-05-LuaJITTeX deleted file mode 100644 index a33bf70ea..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3-PATCHES/patch-05-LuaJITTeX +++ /dev/null @@ -1,107 +0,0 @@ -diff -ur -x lbitlib.c LuaJIT-2.0.3.orig/src/lj_def.h LuaJIT-2.0.3/src/lj_def.h ---- LuaJIT-2.0.3.orig/src/lj_def.h 2014-03-12 13:10:00.000000000 +0100 -+++ LuaJIT-2.0.3/src/lj_def.h 2014-03-14 09:30:30.000000000 +0100 -@@ -62,7 +62,7 @@ - #define LJ_MAX_BCINS (1<<26) /* Max. # of bytecode instructions. */ - #define LJ_MAX_SLOTS 250 /* Max. # of slots in a Lua func. */ - #define LJ_MAX_LOCVAR 200 /* Max. # of local variables. */ --#define LJ_MAX_UPVAL 60 /* Max. # of upvalues. */ -+#define LJ_MAX_UPVAL 249 /* Max. # of upvalues. */ - - #define LJ_MAX_IDXCHAIN 100 /* __index/__newindex chain limit. */ - #define LJ_STACK_EXTRA 5 /* Extra stack space (metamethods). */ -diff -ur -x lbitlib.c LuaJIT-2.0.3.orig/src/lj_str.c LuaJIT-2.0.3/src/lj_str.c ---- LuaJIT-2.0.3.orig/src/lj_str.c 2014-03-12 13:10:00.000000000 +0100 -+++ LuaJIT-2.0.3/src/lj_str.c 2014-06-02 14:10:04.000000000 +0200 -@@ -90,6 +90,16 @@ - g->strhash = newhash; - } - -+/* -+** Lua will use at most ~(2^LUAI_HASHLIMIT) bytes from a string to -+** compute its hash -+*/ -+#if !defined(LUAI_HASHLIMIT) -+#define LUAI_HASHLIMIT 5 -+#endif -+ -+#define cast(t, exp) ((t)(exp)) -+int luajittex_choose_hash_function = 0 ; - /* Intern a string and return string object. */ - GCstr *lj_str_new(lua_State *L, const char *str, size_t lenx) - { -@@ -98,27 +108,44 @@ - GCobj *o; - MSize len = (MSize)lenx; - MSize a, b, h = len; -+ size_t step ; -+ size_t l1 ; - if (lenx >= LJ_MAX_STR) - lj_err_msg(L, LJ_ERR_STROV); - g = G(L); -+ -+ if (len==0) -+ return &g->strempty; -+ if (luajittex_choose_hash_function==0) { -+ /* Lua 5.1.5 hash function */ -+ /* for 5.2 max methods we also need to patch the vm eq */ -+ step = (len>>LUAI_HASHLIMIT)+1; /* if string is too long, don't hash all its chars */ -+ for (l1=len; l1>=step; l1-=step) /* compute hash */ -+ h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); -+ } else { -+ /* LuaJIT 2.0.2 hash function */ - /* Compute string hash. Constants taken from lookup3 hash by Bob Jenkins. */ -- if (len >= 4) { /* Caveat: unaligned access! */ -- a = lj_getu32(str); -- h ^= lj_getu32(str+len-4); -- b = lj_getu32(str+(len>>1)-2); -- h ^= b; h -= lj_rol(b, 14); -- b += lj_getu32(str+(len>>2)-1); -- } else if (len > 0) { -- a = *(const uint8_t *)str; -- h ^= *(const uint8_t *)(str+len-1); -- b = *(const uint8_t *)(str+(len>>1)); -- h ^= b; h -= lj_rol(b, 14); -- } else { -- return &g->strempty; -- } -- a ^= h; a -= lj_rol(h, 11); -- b ^= a; b -= lj_rol(a, 25); -- h ^= b; h -= lj_rol(b, 16); -+ if (len >= 4) { /* Caveat: unaligned access! */ -+ a = lj_getu32(str); -+ h ^= lj_getu32(str+len-4); -+ b = lj_getu32(str+(len>>1)-2); -+ h ^= b; h -= lj_rol(b, 14); -+ b += lj_getu32(str+(len>>2)-1); -+ } else if (len > 0) { -+ a = *(const uint8_t *)str; -+ h ^= *(const uint8_t *)(str+len-1); -+ b = *(const uint8_t *)(str+(len>>1)); -+ h ^= b; h -= lj_rol(b, 14); -+ } else { -+ /* Already done, kept for reference */ -+ return &g->strempty; -+ } -+ a ^= h; a -= lj_rol(h, 11); -+ b ^= a; b -= lj_rol(a, 25); -+ h ^= b; h -= lj_rol(b, 16); -+ } -+ -+ - /* Check if the string has already been interned. */ - o = gcref(g->strhash[h & g->strmask]); - if (LJ_LIKELY((((uintptr_t)str+len-1) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4)) { -diff -ur -x lbitlib.c LuaJIT-2.0.3.orig/src/lua.h LuaJIT-2.0.3/src/lua.h ---- LuaJIT-2.0.3.orig/src/lua.h 2014-03-14 09:15:50.000000000 +0100 -+++ LuaJIT-2.0.3/src/lua.h 2014-03-14 10:08:51.000000000 +0100 -@@ -103,6 +103,9 @@ - typedef LUA_INTEGER lua_Integer; - - -+/* communication with LuaJiTTeX */ -+LUA_API int luajittex_choose_hash_function; -+ - - /* - ** state manipulation diff --git a/source/libs/luajit/LuaJIT-2.0.3-PATCHES/patch-06-ppc-darwin b/source/libs/luajit/LuaJIT-2.0.3-PATCHES/patch-06-ppc-darwin deleted file mode 100644 index 7ab68cfa1..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3-PATCHES/patch-06-ppc-darwin +++ /dev/null @@ -1,24 +0,0 @@ -diff -ur -x lbitlib.c LuaJIT-2.0.3.orig/src/host/buildvm.c LuaJIT-2.0.3/src/host/buildvm.c ---- LuaJIT-2.0.3.orig/src/host/buildvm.c 2014-03-12 13:10:00.000000000 +0100 -+++ LuaJIT-2.0.3/src/host/buildvm.c 2015-02-19 13:01:47.000000000 +0100 -@@ -113,7 +113,7 @@ - name[0] = '@'; - else - *p = '\0'; --#elif (LJ_TARGET_PPC || LJ_TARGET_PPCSPE) && !LJ_TARGET_CONSOLE -+#elif ((LJ_TARGET_PPC && !LJ_TARGET_OSX) || LJ_TARGET_PPCSPE) && !LJ_TARGET_CONSOLE - /* Keep @plt. */ - #else - *p = '\0'; -diff -ur -x lbitlib.c LuaJIT-2.0.3.orig/src/lj_arch.h LuaJIT-2.0.3/src/lj_arch.h ---- LuaJIT-2.0.3.orig/src/lj_arch.h 2014-03-12 13:10:00.000000000 +0100 -+++ LuaJIT-2.0.3/src/lj_arch.h 2015-02-19 13:04:58.000000000 +0100 -@@ -293,7 +293,7 @@ - #if __GNUC__ < 4 - #error "Need at least GCC 4.0 or newer" - #endif --#elif LJ_TARGET_ARM -+#elif LJ_TARGET_ARM || LJ_TARGET_PPC - #if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 2) - #error "Need at least GCC 4.2 or newer" - #endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/COPYRIGHT b/source/libs/luajit/LuaJIT-2.0.3/COPYRIGHT deleted file mode 100644 index 08936dfb9..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/COPYRIGHT +++ /dev/null @@ -1,56 +0,0 @@ -=============================================================================== -LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/ - -Copyright (C) 2005-2014 Mike Pall. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -[ MIT license: http://www.opensource.org/licenses/mit-license.php ] - -=============================================================================== -[ LuaJIT includes code from Lua 5.1/5.2, which has this license statement: ] - -Copyright (C) 1994-2012 Lua.org, PUC-Rio. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -=============================================================================== -[ LuaJIT includes code from dlmalloc, which has this license statement: ] - -This is a version (aka dlmalloc) of malloc/free/realloc written by -Doug Lea and released to the public domain, as explained at -http://creativecommons.org/licenses/publicdomain - -=============================================================================== diff --git a/source/libs/luajit/LuaJIT-2.0.3/Makefile b/source/libs/luajit/LuaJIT-2.0.3/Makefile deleted file mode 100644 index b23b64816..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/Makefile +++ /dev/null @@ -1,151 +0,0 @@ -############################################################################## -# LuaJIT top level Makefile for installation. Requires GNU Make. -# -# Please read doc/install.html before changing any variables! -# -# Suitable for POSIX platforms (Linux, *BSD, OSX etc.). -# Note: src/Makefile has many more configurable options. -# -# ##### This Makefile is NOT useful for Windows! ##### -# For MSVC, please follow the instructions given in src/msvcbuild.bat. -# For MinGW and Cygwin, cd to src and run make with the Makefile there. -# -# Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -############################################################################## - -MAJVER= 2 -MINVER= 0 -RELVER= 3 -VERSION= $(MAJVER).$(MINVER).$(RELVER) -ABIVER= 5.1 - -############################################################################## -# -# Change the installation path as needed. This automatically adjusts -# the paths in src/luaconf.h, too. Note: PREFIX must be an absolute path! -# -export PREFIX= /usr/local -export MULTILIB= lib -############################################################################## - -DPREFIX= $(DESTDIR)$(PREFIX) -INSTALL_BIN= $(DPREFIX)/bin -INSTALL_LIB= $(DPREFIX)/$(MULTILIB) -INSTALL_SHARE= $(DPREFIX)/share -INSTALL_INC= $(DPREFIX)/include/luajit-$(MAJVER).$(MINVER) - -INSTALL_LJLIBD= $(INSTALL_SHARE)/luajit-$(VERSION) -INSTALL_JITLIB= $(INSTALL_LJLIBD)/jit -INSTALL_LMODD= $(INSTALL_SHARE)/lua -INSTALL_LMOD= $(INSTALL_LMODD)/$(ABIVER) -INSTALL_CMODD= $(INSTALL_LIB)/lua -INSTALL_CMOD= $(INSTALL_CMODD)/$(ABIVER) -INSTALL_MAN= $(INSTALL_SHARE)/man/man1 -INSTALL_PKGCONFIG= $(INSTALL_LIB)/pkgconfig - -INSTALL_TNAME= luajit-$(VERSION) -INSTALL_TSYMNAME= luajit -INSTALL_ANAME= libluajit-$(ABIVER).a -INSTALL_SONAME= libluajit-$(ABIVER).so.$(MAJVER).$(MINVER).$(RELVER) -INSTALL_SOSHORT= libluajit-$(ABIVER).so -INSTALL_DYLIBNAME= libluajit-$(ABIVER).$(MAJVER).$(MINVER).$(RELVER).dylib -INSTALL_DYLIBSHORT1= libluajit-$(ABIVER).dylib -INSTALL_DYLIBSHORT2= libluajit-$(ABIVER).$(MAJVER).dylib -INSTALL_PCNAME= luajit.pc - -INSTALL_STATIC= $(INSTALL_LIB)/$(INSTALL_ANAME) -INSTALL_DYN= $(INSTALL_LIB)/$(INSTALL_SONAME) -INSTALL_SHORT1= $(INSTALL_LIB)/$(INSTALL_SOSHORT) -INSTALL_SHORT2= $(INSTALL_LIB)/$(INSTALL_SOSHORT) -INSTALL_T= $(INSTALL_BIN)/$(INSTALL_TNAME) -INSTALL_TSYM= $(INSTALL_BIN)/$(INSTALL_TSYMNAME) -INSTALL_PC= $(INSTALL_PKGCONFIG)/$(INSTALL_PCNAME) - -INSTALL_DIRS= $(INSTALL_BIN) $(INSTALL_LIB) $(INSTALL_INC) $(INSTALL_MAN) \ - $(INSTALL_PKGCONFIG) $(INSTALL_JITLIB) $(INSTALL_LMOD) $(INSTALL_CMOD) -UNINSTALL_DIRS= $(INSTALL_JITLIB) $(INSTALL_LJLIBD) $(INSTALL_INC) \ - $(INSTALL_LMOD) $(INSTALL_LMODD) $(INSTALL_CMOD) $(INSTALL_CMODD) - -RM= rm -f -MKDIR= mkdir -p -RMDIR= rmdir 2>/dev/null -SYMLINK= ln -sf -INSTALL_X= install -m 0755 -INSTALL_F= install -m 0644 -UNINSTALL= $(RM) -LDCONFIG= ldconfig -n -SED_PC= sed -e "s|^prefix=.*|prefix=$(PREFIX)|" \ - -e "s|^multilib=.*|multilib=$(MULTILIB)|" - -FILE_T= luajit -FILE_A= libluajit.a -FILE_SO= libluajit.so -FILE_MAN= luajit.1 -FILE_PC= luajit.pc -FILES_INC= lua.h lualib.h lauxlib.h luaconf.h lua.hpp luajit.h -FILES_JITLIB= bc.lua v.lua dump.lua dis_x86.lua dis_x64.lua dis_arm.lua \ - dis_ppc.lua dis_mips.lua dis_mipsel.lua bcsave.lua vmdef.lua - -ifeq (,$(findstring Windows,$(OS))) - ifeq (Darwin,$(shell uname -s)) - INSTALL_SONAME= $(INSTALL_DYLIBNAME) - INSTALL_SHORT1= $(INSTALL_LIB)/$(INSTALL_DYLIBSHORT1) - INSTALL_SHORT2= $(INSTALL_LIB)/$(INSTALL_DYLIBSHORT2) - LDCONFIG= : - endif -endif - -############################################################################## - -INSTALL_DEP= src/luajit - -default all $(INSTALL_DEP): - @echo "==== Building LuaJIT $(VERSION) ====" - $(MAKE) -C src - @echo "==== Successfully built LuaJIT $(VERSION) ====" - -install: $(INSTALL_DEP) - @echo "==== Installing LuaJIT $(VERSION) to $(PREFIX) ====" - $(MKDIR) $(INSTALL_DIRS) - cd src && $(INSTALL_X) $(FILE_T) $(INSTALL_T) - cd src && test -f $(FILE_A) && $(INSTALL_F) $(FILE_A) $(INSTALL_STATIC) || : - $(RM) $(INSTALL_TSYM) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2) - cd src && test -f $(FILE_SO) && \ - $(INSTALL_X) $(FILE_SO) $(INSTALL_DYN) && \ - $(LDCONFIG) $(INSTALL_LIB) && \ - $(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT1) && \ - $(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT2) || : - cd etc && $(INSTALL_F) $(FILE_MAN) $(INSTALL_MAN) - cd etc && $(SED_PC) $(FILE_PC) > $(FILE_PC).tmp && \ - $(INSTALL_F) $(FILE_PC).tmp $(INSTALL_PC) && \ - $(RM) $(FILE_PC).tmp - cd src && $(INSTALL_F) $(FILES_INC) $(INSTALL_INC) - cd src/jit && $(INSTALL_F) $(FILES_JITLIB) $(INSTALL_JITLIB) - $(SYMLINK) $(INSTALL_TNAME) $(INSTALL_TSYM) - @echo "==== Successfully installed LuaJIT $(VERSION) to $(PREFIX) ====" - -uninstall: - @echo "==== Uninstalling LuaJIT $(VERSION) from $(PREFIX) ====" - $(UNINSTALL) $(INSTALL_TSYM) $(INSTALL_T) $(INSTALL_STATIC) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2) $(INSTALL_MAN)/$(FILE_MAN) $(INSTALL_PC) - for file in $(FILES_JITLIB); do \ - $(UNINSTALL) $(INSTALL_JITLIB)/$$file; \ - done - for file in $(FILES_INC); do \ - $(UNINSTALL) $(INSTALL_INC)/$$file; \ - done - $(LDCONFIG) $(INSTALL_LIB) - $(RMDIR) $(UNINSTALL_DIRS) || : - @echo "==== Successfully uninstalled LuaJIT $(VERSION) from $(PREFIX) ====" - -############################################################################## - -amalg: - @echo "Building LuaJIT $(VERSION)" - $(MAKE) -C src amalg - -clean: - $(MAKE) -C src clean - -.PHONY: all install amalg clean - -############################################################################## diff --git a/source/libs/luajit/LuaJIT-2.0.3/README b/source/libs/luajit/LuaJIT-2.0.3/README deleted file mode 100644 index 902a6d2e4..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/README +++ /dev/null @@ -1,16 +0,0 @@ -README for LuaJIT 2.0.3 ------------------------ - -LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language. - -Project Homepage: http://luajit.org/ - -LuaJIT is Copyright (C) 2005-2014 Mike Pall. -LuaJIT is free software, released under the MIT license. -See full Copyright Notice in the COPYRIGHT file or in luajit.h. - -Documentation for LuaJIT is available in HTML format. -Please point your favorite browser to: - - doc/luajit.html - diff --git a/source/libs/luajit/LuaJIT-2.0.3/doc/bluequad-print.css b/source/libs/luajit/LuaJIT-2.0.3/doc/bluequad-print.css deleted file mode 100644 index 21da8688a..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/doc/bluequad-print.css +++ /dev/null @@ -1,166 +0,0 @@ -/* Copyright (C) 2004-2014 Mike Pall. - * - * You are welcome to use the general ideas of this design for your own sites. - * But please do not steal the stylesheet, the layout or the color scheme. - */ -body { - font-family: serif; - font-size: 11pt; - margin: 0 3em; - padding: 0; - border: none; -} -a:link, a:visited, a:hover, a:active { - text-decoration: none; - background: transparent; - color: #0000ff; -} -h1, h2, h3 { - font-family: sans-serif; - font-weight: bold; - text-align: left; - margin: 0.5em 0; - padding: 0; -} -h1 { - font-size: 200%; -} -h2 { - font-size: 150%; -} -h3 { - font-size: 125%; -} -p { - margin: 0 0 0.5em 0; - padding: 0; -} -ul, ol { - margin: 0.5em 0; - padding: 0 0 0 2em; -} -ul { - list-style: outside square; -} -ol { - list-style: outside decimal; -} -li { - margin: 0; - padding: 0; -} -dl { - margin: 1em 0; - padding: 1em; - border: 1px solid black; -} -dt { - font-weight: bold; - margin: 0; - padding: 0; -} -dt sup { - float: right; - margin-left: 1em; -} -dd { - margin: 0.5em 0 0 2em; - padding: 0; -} -table { - table-layout: fixed; - width: 100%; - margin: 1em 0; - padding: 0; - border: 1px solid black; - border-spacing: 0; - border-collapse: collapse; -} -tr { - margin: 0; - padding: 0; - border: none; -} -td { - text-align: left; - margin: 0; - padding: 0.2em 0.5em; - border-top: 1px solid black; - border-bottom: 1px solid black; -} -tr.separate td { - border-top: double; -} -tt, pre, code, kbd, samp { - font-family: monospace; - font-size: 75%; -} -kbd { - font-weight: bolder; -} -blockquote, pre { - margin: 1em 2em; - padding: 0; -} -img { - border: none; - vertical-align: baseline; - margin: 0; - padding: 0; -} -img.left { - float: left; - margin: 0.5em 1em 0.5em 0; -} -img.right { - float: right; - margin: 0.5em 0 0.5em 1em; -} -.flush { - clear: both; - visibility: hidden; -} -.hide, .noprint, #nav { - display: none !important; -} -.pagebreak { - page-break-before: always; -} -#site { - text-align: right; - font-family: sans-serif; - font-weight: bold; - margin: 0 1em; - border-bottom: 1pt solid black; -} -#site a { - font-size: 1.2em; -} -#site a:link, #site a:visited { - text-decoration: none; - font-weight: bold; - background: transparent; - color: #ffffff; -} -#logo { - color: #ff8000; -} -#head { - clear: both; - margin: 0 1em; -} -#main { - line-height: 1.3; - text-align: justify; - margin: 1em; -} -#foot { - clear: both; - font-size: 80%; - text-align: center; - margin: 0 1.25em; - padding: 0.5em 0 0 0; - border-top: 1pt solid black; - page-break-before: avoid; - page-break-after: avoid; -} diff --git a/source/libs/luajit/LuaJIT-2.0.3/doc/bluequad.css b/source/libs/luajit/LuaJIT-2.0.3/doc/bluequad.css deleted file mode 100644 index 05b092e4d..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/doc/bluequad.css +++ /dev/null @@ -1,325 +0,0 @@ -/* Copyright (C) 2004-2014 Mike Pall. - * - * You are welcome to use the general ideas of this design for your own sites. - * But please do not steal the stylesheet, the layout or the color scheme. - */ -/* colorscheme: - * - * site | head #4162bf/white | #6078bf/#e6ecff - * ------+------ ----------------+------------------- - * nav | main #bfcfff | #e6ecff/black - * - * nav: hiback loback #c5d5ff #b9c9f9 - * hiborder loborder #e6ecff #97a7d7 - * link hover #2142bf #ff0000 - * - * link: link visited hover #2142bf #8122bf #ff0000 - * - * main: boxback boxborder #f0f4ff #bfcfff - */ -body { - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 10pt; - margin: 0; - padding: 0; - border: none; - background: #e0e0e0; - color: #000000; -} -a:link { - text-decoration: none; - background: transparent; - color: #2142bf; -} -a:visited { - text-decoration: none; - background: transparent; - color: #8122bf; -} -a:hover, a:active { - text-decoration: underline; - background: transparent; - color: #ff0000; -} -h1, h2, h3 { - font-weight: bold; - text-align: left; - margin: 0.5em 0; - padding: 0; - background: transparent; -} -h1 { - font-size: 200%; - line-height: 3em; /* really 6em relative to body, match #site span */ - margin: 0; -} -h2 { - font-size: 150%; - color: #606060; -} -h3 { - font-size: 125%; - color: #404040; -} -p { - max-width: 600px; - margin: 0 0 0.5em 0; - padding: 0; -} -b { - color: #404040; -} -ul, ol { - max-width: 600px; - margin: 0.5em 0; - padding: 0 0 0 2em; -} -ul { - list-style: outside square; -} -ol { - list-style: outside decimal; -} -li { - margin: 0; - padding: 0; -} -dl { - max-width: 600px; - margin: 1em 0; - padding: 1em; - border: 1px solid #bfcfff; - background: #f0f4ff; -} -dt { - font-weight: bold; - margin: 0; - padding: 0; -} -dt sup { - float: right; - margin-left: 1em; - color: #808080; -} -dt a:visited { - text-decoration: none; - color: #2142bf; -} -dt a:hover, dt a:active { - text-decoration: none; - color: #ff0000; -} -dd { - margin: 0.5em 0 0 2em; - padding: 0; -} -div.tablewrap { /* for IE *sigh* */ - max-width: 600px; -} -table { - table-layout: fixed; - border-spacing: 0; - border-collapse: collapse; - max-width: 600px; - width: 100%; - margin: 1em 0; - padding: 0; - border: 1px solid #bfcfff; -} -tr { - margin: 0; - padding: 0; - border: none; -} -tr.odd { - background: #f0f4ff; -} -tr.separate td { - border-top: 1px solid #bfcfff; -} -td { - text-align: left; - margin: 0; - padding: 0.2em 0.5em; - border: none; -} -tt, code, kbd, samp { - font-family: Courier New, Courier, monospace; - line-height: 1.2; - font-size: 110%; -} -kbd { - font-weight: bolder; -} -blockquote, pre { - max-width: 600px; - margin: 1em 2em; - padding: 0; -} -pre { - line-height: 1.1; -} -pre.code { - line-height: 1.4; - margin: 0.5em 0 1em 0.5em; - padding: 0.5em 1em; - border: 1px solid #bfcfff; - background: #f0f4ff; -} -pre.mark { - padding-left: 2em; -} -span.codemark { - position:absolute; - left: 16em; - color: #4040c0; -} -span.mark { - color: #4040c0; - font-family: Courier New, Courier, monospace; - line-height: 1.1; -} -img { - border: none; - vertical-align: baseline; - margin: 0; - padding: 0; -} -img.left { - float: left; - margin: 0.5em 1em 0.5em 0; -} -img.right { - float: right; - margin: 0.5em 0 0.5em 1em; -} -.indent { - padding-left: 1em; -} -.flush { - clear: both; - visibility: hidden; -} -.hide, .noscreen { - display: none !important; -} -.ext { - color: #ff8000; -} -.new { - font-size: 6pt; - vertical-align: middle; - background: #ff8000; - color: #ffffff; -} -#site { - clear: both; - float: left; - width: 13em; - text-align: center; - font-weight: bold; - margin: 0; - padding: 0; - background: transparent; - color: #ffffff; -} -#site a { - font-size: 200%; -} -#site a:link, #site a:visited { - text-decoration: none; - font-weight: bold; - background: transparent; - color: #ffffff; -} -#site span { - line-height: 3em; /* really 6em relative to body, match h1 */ -} -#logo { - color: #ffb380; -} -#head { - margin: 0; - padding: 0 0 0 2em; - border-left: solid 13em #4162bf; - border-right: solid 3em #6078bf; - background: #6078bf; - color: #e6ecff; -} -#nav { - clear: both; - float: left; - overflow: hidden; - text-align: left; - line-height: 1.5; - width: 13em; - padding-top: 1em; - background: transparent; -} -#nav ul { - list-style: none outside; - margin: 0; - padding: 0; -} -#nav li { - margin: 0; - padding: 0; -} -#nav a { - display: block; - text-decoration: none; - font-weight: bold; - margin: 0; - padding: 2px 1em; - border-top: 1px solid transparent; - border-bottom: 1px solid transparent; - background: transparent; - color: #2142bf; -} -#nav a:hover, #nav a:active { - text-decoration: none; - border-top: 1px solid #97a7d7; - border-bottom: 1px solid #e6ecff; - background: #b9c9f9; - color: #ff0000; -} -#nav a.current, #nav a.current:hover, #nav a.current:active { - border-top: 1px solid #e6ecff; - border-bottom: 1px solid #97a7d7; - background: #c5d5ff; - color: #2142bf; -} -#nav ul ul a { - padding: 0 1em 0 1.7em; -} -#nav ul ul ul a { - padding: 0 0.5em 0 2.4em; -} -#main { - line-height: 1.5; - text-align: left; - margin: 0; - padding: 1em 2em; - border-left: solid 13em #bfcfff; - border-right: solid 3em #e6ecff; - background: #e6ecff; -} -#foot { - clear: both; - font-size: 80%; - text-align: center; - margin: 0; - padding: 0.5em; - background: #6078bf; - color: #ffffff; -} -#foot a:link, #foot a:visited { - text-decoration: underline; - background: transparent; - color: #ffffff; -} -#foot a:hover, #foot a:active { - text-decoration: underline; - background: transparent; - color: #bfcfff; -} diff --git a/source/libs/luajit/LuaJIT-2.0.3/doc/changes.html b/source/libs/luajit/LuaJIT-2.0.3/doc/changes.html deleted file mode 100644 index 984122939..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/doc/changes.html +++ /dev/null @@ -1,928 +0,0 @@ - - - -LuaJIT Change History - - - - - - - - - -
-Lua -
- - -
-

-This is a list of changes between the released versions of LuaJIT.
-The current stable version is LuaJIT 2.0.3.
-

-

-Please check the -» Online Change History -to see whether newer versions are available. -

- -
-

LuaJIT 2.0.3 — 2014-03-12

-
    -
  • Add PS4 port.
  • -
  • Add support for multilib distro builds.
  • -
  • Fix OSX build.
  • -
  • Fix MinGW build.
  • -
  • Fix Xbox 360 build.
  • -
  • Improve ULOAD forwarding for open upvalues.
  • -
  • Fix GC steps threshold handling when called by JIT-compiled code.
  • -
  • Fix argument checks for math.deg() and math.rad().
  • -
  • Fix jit.flush(func|true).
  • -
  • Respect jit.off(func) when returning to a function, too.
  • -
  • Fix compilation of string.byte(s, nil, n).
  • -
  • Fix line number for relocated bytecode after closure fixup
  • -
  • Fix frame traversal for backtraces.
  • -
  • Fix ABC elimination.
  • -
  • Fix handling of redundant PHIs.
  • -
  • Fix snapshot restore for exit to function header.
  • -
  • Fix type punning alias analysis for constified pointers
  • -
  • Fix call unroll checks in the presence of metamethod frames.
  • -
  • Fix initial maxslot for down-recursive traces.
  • -
  • Prevent BASE register coalescing if parent uses IR_RETF.
  • -
  • Don't purge modified function from stack slots in BC_RET.
  • -
  • Fix recording of BC_VARG.
  • -
  • Don't access dangling reference to reallocated IR.
  • -
  • Fix frame depth display for bytecode dump in -jdump.
  • -
  • ARM: Fix register allocation when rematerializing FPRs.
  • -
  • x64: Fix store to upvalue for lightuserdata values.
  • -
  • FFI: Add missing GC steps for callback argument conversions.
  • -
  • FFI: Properly unload loaded DLLs.
  • -
  • FFI: Fix argument checks for ffi.string().
  • -
  • FFI/x64: Fix passing of vector arguments to calls.
  • -
  • FFI: Rehash finalizer table after GC cycle, if needed.
  • -
  • FFI: Fix cts->L for cdata unsinking in snapshot restore.
  • -
- -

LuaJIT 2.0.2 — 2013-06-03

-
    -
  • Fix memory access check for fast string interning.
  • -
  • Fix MSVC intrinsics for older versions.
  • -
  • Add missing GC steps for io.* functions.
  • -
  • Fix spurious red zone overflows in machine code generation.
  • -
  • Fix jump-range constrained mcode allocation.
  • -
  • Inhibit DSE for implicit loads via calls.
  • -
  • Fix builtin string to number conversion for overflow digits.
  • -
  • Fix optional argument handling while recording builtins.
  • -
  • Fix optional argument handling in table.concat().
  • -
  • Add partial support for building with MingW64 GCC 4.8-SEH.
  • -
  • Add missing PHI barrier to string.sub(str, a, b) == kstr FOLD rule.
  • -
  • Fix compatibility issues with Illumos.
  • -
  • ARM: Fix cache flush/sync for exit stubs of JIT-compiled code.
  • -
  • MIPS: Fix cache flush/sync for JIT-compiled code jump area.
  • -
  • PPC: Add plt suffix for external calls from assembler code.
  • -
  • FFI: Fix snapshot substitution in SPLIT pass.
  • -
  • FFI/x86: Fix register allocation for 64 bit comparisons.
  • -
  • FFI: Fix tailcall in lowest frame to C function with bool result.
  • -
  • FFI: Ignore long type specifier in ffi.istype().
  • -
  • FFI: Fix calling conventions for 32 bit OSX and iOS simulator (struct returns).
  • -
  • FFI: Fix calling conventions for ARM hard-float EABI (nested structs).
  • -
  • FFI: Improve error messages for arithmetic and comparison operators.
  • -
  • FFI: Insert no-op type conversion for pointer to integer cast.
  • -
  • FFI: Fix unroll limit for ffi.fill().
  • -
  • FFI: Must sink XBAR together with XSTOREs.
  • -
  • FFI: Preserve intermediate string for const char * conversion.
  • -
- -

LuaJIT 2.0.1 — 2013-02-19

-
    -
  • Don't clear frame for out-of-memory error.
  • -
  • Leave hook when resume catches error thrown from hook.
  • -
  • Add missing GC steps for template table creation.
  • -
  • Fix discharge order of comparisons in Lua parser.
  • -
  • Improve buffer handling for io.read().
  • -
  • OSX: Add support for Mach-O object files to -b option.
  • -
  • Fix PS3 port.
  • -
  • Fix/enable Xbox 360 port.
  • -
  • x86/x64: Always mark ref for shift count as non-weak.
  • -
  • x64: Don't fuse implicitly 32-to-64 extended operands.
  • -
  • ARM: Fix armhf call argument handling.
  • -
  • ARM: Fix code generation for integer math.min/math.max.
  • -
  • PPC/e500: Fix lj_vm_floor() for Inf/NaN.
  • -
  • FFI: Change priority of table initializer variants for structs.
  • -
  • FFI: Fix code generation for bool call result check on x86/x64.
  • -
  • FFI: Load FFI library on-demand for bytecode with cdata literals.
  • -
  • FFI: Fix handling of qualified transparent structs/unions.
  • -
- -

LuaJIT 2.0.0 — 2012-11-08

-
    -
  • Correctness and completeness: -
      -
    • Fix Android/x86 build.
    • -
    • Fix recording of equality comparisons with __eq metamethods.
    • -
    • Fix detection of immutable upvalues.
    • -
    • Replace error with PANIC for callbacks from JIT-compiled code.
    • -
    • Fix builtin string to number conversion for INT_MIN.
    • -
    • Don't create unneeded array part for template tables.
    • -
    • Fix CONV.num.int sinking.
    • -
    • Don't propagate implicitly widened number to index metamethods.
    • -
    • ARM: Fix ordered comparisons of number vs. non-number.
    • -
    • FFI: Fix code generation for replay of sunk float fields.
    • -
    • FFI: Fix signedness of bool.
    • -
    • FFI: Fix recording of bool call result check on x86/x64.
    • -
    • FFI: Fix stack-adjustment for __thiscall callbacks.
    • -
  • -
- -

LuaJIT 2.0.0-beta11 — 2012-10-16

-
    -
  • New features: -
      -
    • Use ARM VFP instructions, if available (build-time detection).
    • -
    • Add support for ARM hard-float EABI (armhf).
    • -
    • Add PS3 port.
    • -
    • Add many features from Lua 5.2, e.g. goto/labels. - Refer to this list.
    • -
    • FFI: Add parameterized C types.
    • -
    • FFI: Add support for copy constructors.
    • -
    • FFI: Equality comparisons never raise an error (treat as unequal instead).
    • -
    • FFI: Box all accessed or returned enums.
    • -
    • FFI: Check for __new metamethod when calling a constructor.
    • -
    • FFI: Handle __pairs/__ipairs metamethods for cdata objects.
    • -
    • FFI: Convert io.* file handle to FILE * pointer (but as a void *).
    • -
    • FFI: Detect and support type punning through unions.
    • -
    • FFI: Improve various error messages.
    • -
  • -
  • Build-system reorganization: -
      -
    • Reorganize directory layout:
      - lib/*src/jit/*
      - src/buildvm_*.dascsrc/vm_*.dasc
      - src/buildvm_*.h → removed
      - src/buildvm*src/host/*
    • -
    • Add minified Lua interpreter plus Lua BitOp (minilua) to run DynASM.
    • -
    • Change DynASM bit operations to use Lua BitOp
    • -
    • Translate only vm_*.dasc for detected target architecture.
    • -
    • Improve target detection for msvcbuild.bat.
    • -
    • Fix build issues on Cygwin and MinGW with optional MSys.
    • -
    • Handle cross-compiles with FPU/no-FPU or hard-fp/soft-fp ABI mismatch.
    • -
    • Remove some library functions for no-JIT/no-FFI builds.
    • -
    • Add uninstall target to top-level Makefile.
    • -
  • -
  • Correctness and completeness: -
      -
    • Preserve snapshot #0 PC for all traces.
    • -
    • Fix argument checks for coroutine.create().
    • -
    • Command line prints version and JIT status to stdout, not stderr.
    • -
    • Fix userdata __gc separations at Lua state close.
    • -
    • Fix TDUP to HLOAD forwarding for LJ_DUALNUM builds.
    • -
    • Fix buffer check in bytecode writer.
    • -
    • Make os.date() thread-safe.
    • -
    • Add missing declarations for MSVC intrinsics.
    • -
    • Fix dispatch table modifications for return hooks.
    • -
    • Workaround for MSVC conversion bug (doubleuint32_tint32_t).
    • -
    • Fix FOLD rule (i-j)-i => 0-j.
    • -
    • Never use DWARF unwinder on Windows.
    • -
    • Fix shrinking of direct mapped blocks in builtin allocator.
    • -
    • Limit recursion depth in string.match() et al.
    • -
    • Fix late despecialization of ITERN after loop has been entered.
    • -
    • Fix 'f' and 'L' options for debug.getinfo() and lua_getinfo().
    • -
    • Fix package.searchpath().
    • -
    • OSX: Change dylib names to be consistent with other platforms.
    • -
    • Android: Workaround for broken sprintf("%g", -0.0).
    • -
    • x86: Remove support for ancient CPUs without CMOV (before Pentium Pro).
    • -
    • x86: Fix register allocation for calls returning register pair.
    • -
    • x86/x64: Fix fusion of unsigned byte comparisons with swapped operands.
    • -
    • ARM: Fix tonumber() argument check.
    • -
    • ARM: Fix modulo operator and math.floor()/math.ceil() for inf/nan.
    • -
    • ARM: Invoke SPLIT pass for leftover IR_TOBIT.
    • -
    • ARM: Fix BASE register coalescing.
    • -
    • PPC: Fix interpreter state setup in callbacks.
    • -
    • PPC: Fix string.sub() range check.
    • -
    • MIPS: Support generation of MIPS/MIPSEL bytecode object files.
    • -
    • MIPS: Fix calls to floor()/ceil()/trunc().
    • -
    • ARM/PPC: Detect more target architecture variants.
    • -
    • ARM/PPC/e500/MIPS: Fix tailcalls from fast functions, esp. tostring().
    • -
    • ARM/PPC/MIPS: Fix rematerialization of FP constants.
    • -
    • FFI: Don't call FreeLibrary() on our own EXE/DLL.
    • -
    • FFI: Resolve metamethods for constructors, too.
    • -
    • FFI: Properly disable callbacks on iOS (would require executable memory).
    • -
    • FFI: Fix cdecl string parsing during recording.
    • -
    • FFI: Show address pointed to for tostring(ref), too.
    • -
    • FFI: Fix alignment of C call argument/return structure.
    • -
    • FFI: Initialize all fields of standard types.
    • -
    • FFI: Fix callback handling when new C types are declared in callback.
    • -
    • FFI: Fix recording of constructors for pointers.
    • -
    • FFI: Always resolve metamethods for pointers to structs.
    • -
    • FFI: Correctly propagate alignment when interning nested types.
    • -
  • -
  • Structural and performance enhancements: -
      -
    • Add allocation sinking and store sinking optimization.
    • -
    • Constify immutable upvalues.
    • -
    • Add builtin string to integer or FP number conversion. Improves cross-platform consistency and correctness.
    • -
    • Create string hash slots in template tables for non-const values, too. Avoids later table resizes.
    • -
    • Eliminate HREFK guard for template table references.
    • -
    • Add various new FOLD rules.
    • -
    • Don't use stack unwinding for lua_yield() (slow on x64).
    • -
    • ARM, PPC, MIPS: Improve XLOAD operand fusion and register hinting.
    • -
    • PPC, MIPS: Compile math.sqrt() to sqrt instruction, if available.
    • -
    • FFI: Fold KPTR + constant offset in SPLIT pass.
    • -
    • FFI: Optimize/inline ffi.copy() and ffi.fill().
    • -
    • FFI: Compile and optimize array/struct copies.
    • -
    • FFI: Compile ffi.typeof(cdata|ctype), ffi.sizeof(), ffi.alignof(), ffi.offsetof() and ffi.gc().
    • -
  • -
- -

LuaJIT 2.0.0-beta10 — 2012-05-09

-
    -
  • New features: -
      -
    • The MIPS of LuaJIT is complete. It requires a CPU conforming to the -MIPS32 R1 architecture with hardware FPU. O32 hard-fp ABI, -little-endian or big-endian.
    • -
    • Auto-detect target arch via cross-compiler. No need for -TARGET=arch anymore.
    • -
    • Make DynASM compatible with Lua 5.2.
    • -
    • From Lua 5.2: Try __tostring metamethod on non-string error -messages..
    • -
  • -
  • Correctness and completeness: -
      -
    • Fix parsing of hex literals with exponents.
    • -
    • Fix bytecode dump for certain number constants.
    • -
    • Fix argument type in error message for relative arguments.
    • -
    • Fix argument error handling on Lua stacks without a frame.
    • -
    • Add missing mcode limit check in assembler backend.
    • -
    • Fix compilation on OpenBSD.
    • -
    • Avoid recursive GC steps after GC-triggered trace exit.
    • -
    • Replace <unwind.h> definitions with our own.
    • -
    • Fix OSX build issues. Bump minimum required OSX version to 10.4.
    • -
    • Fix discharge order of comparisons in Lua parser.
    • -
    • Ensure running __gc of userdata created in __gc -at state close.
    • -
    • Limit number of userdata __gc separations at state close.
    • -
    • Fix bytecode JMP slot range when optimizing -and/or with constant LHS.
    • -
    • Fix DSE of USTORE.
    • -
    • Make lua_concat() work from C hook with partial frame.
    • -
    • Add required PHIs for implicit conversions, e.g. via XREF -forwarding.
    • -
    • Add more comparison variants to Valgrind suppressions file.
    • -
    • Disable loading bytecode with an extra header (BOM or #!).
    • -
    • Fix PHI stack slot syncing.
    • -
    • ARM: Reorder type/value tests to silence Valgrind.
    • -
    • ARM: Fix register allocation for ldrd-optimized -HREFK.
    • -
    • ARM: Fix conditional branch fixup for OBAR.
    • -
    • ARM: Invoke SPLIT pass for double args in FFI call.
    • -
    • ARM: Handle all CALL* ops with double results in -SPLIT pass.
    • -
    • ARM: Fix rejoin of POW in SPLIT pass.
    • -
    • ARM: Fix compilation of math.sinh, math.cosh, -math.tanh.
    • -
    • ARM, PPC: Avoid pointless arg clearing in BC_IFUNCF.
    • -
    • PPC: Fix resume after yield from hook.
    • -
    • PPC: Fix argument checking for rawget().
    • -
    • PPC: Fix fusion of floating-point XLOAD/XSTORE.
    • -
    • PPC: Fix HREFK code generation for huge tables.
    • -
    • PPC: Use builtin D-Cache/I-Cache sync code.
    • -
  • -
  • FFI library: -
      -
    • Ignore empty statements in ffi.cdef().
    • -
    • Ignore number parsing errors while skipping definitions.
    • -
    • Don't touch frame in callbacks with tailcalls to fast functions.
    • -
    • Fix library unloading on POSIX systems.
    • -
    • Finalize cdata before userdata when closing the state.
    • -
    • Change ffi.load() library name resolution for Cygwin.
    • -
    • Fix resolving of function name redirects on Windows/x86.
    • -
    • Fix symbol resolving error messages on Windows.
    • -
    • Fix blacklisting of C functions calling callbacks.
    • -
    • Fix result type of pointer difference.
    • -
    • Use correct PC in FFI metamethod error message.
    • -
    • Allow 'typedef _Bool int BOOL;' for the Windows API.
    • -
    • Don't record test for bool result of call, if ignored.
    • -
  • -
- -

LuaJIT 2.0.0-beta9 — 2011-12-14

-
    -
  • New features: -
      -
    • PPC port of LuaJIT is complete. Default is the dual-number port -(usually faster). Single-number port selectable via src/Makefile -at build time.
    • -
    • Add FFI callback support.
    • -
    • Extend -b to generate .c, .h or .obj/.o -files with embedded bytecode.
    • -
    • Allow loading embedded bytecode with require().
    • -
    • From Lua 5.2: Change to '\z' escape. Reject undefined escape -sequences.
    • -
  • -
  • Correctness and completeness: -
      -
    • Fix OSX 10.7 build. Fix install_name and versioning on OSX.
    • -
    • Fix iOS build.
    • -
    • Install dis_arm.lua, too.
    • -
    • Mark installed shared library as executable.
    • -
    • Add debug option to msvcbuild.bat and improve error handling.
    • -
    • Fix data-flow analysis for iterators.
    • -
    • Fix forced unwinding triggered by external unwinder.
    • -
    • Record missing for loop slot loads (return to lower frame).
    • -
    • Always use ANSI variants of Windows system functions.
    • -
    • Fix GC barrier for multi-result table constructor (TSETM).
    • -
    • Fix/add various FOLD rules.
    • -
    • Add potential PHI for number conversions due to type instability.
    • -
    • Do not eliminate PHIs only referenced from other PHIs.
    • -
    • Correctly anchor implicit number to string conversions in Lua/C API.
    • -
    • Fix various stack limit checks.
    • -
    • x64: Use thread-safe exceptions for external unwinding (GCC platforms).
    • -
    • x64: Fix result type of cdata index conversions.
    • -
    • x64: Fix math.random() and bit.bswap() code generation.
    • -
    • x64: Fix lightuserdata comparisons.
    • -
    • x64: Always extend stack-passed arguments to pointer size.
    • -
    • ARM: Many fixes to code generation backend.
    • -
    • PPC/e500: Fix dispatch for binop metamethods.
    • -
    • PPC/e500: Save/restore condition registers when entering/leaving the VM.
    • -
    • PPC/e500: Fix write barrier in stores of strings to upvalues.
    • -
  • -
  • FFI library: -
      -
    • Fix C comment parsing.
    • -
    • Fix snapshot optimization for cdata comparisons.
    • -
    • Fix recording of const/enum lookups in namespaces.
    • -
    • Fix call argument and return handling for I8/U8/I16/U16 types.
    • -
    • Fix unfused loads of float fields.
    • -
    • Fix ffi.string() recording.
    • -
    • Save GetLastError() around ffi.load() and symbol -resolving, too.
    • -
    • Improve ld script detection in ffi.load().
    • -
    • Record loads/stores to external variables in namespaces.
    • -
    • Compile calls to stdcall, fastcall and vararg functions.
    • -
    • Treat function ctypes like pointers in comparisons.
    • -
    • Resolve __call metamethod for pointers, too.
    • -
    • Record C function calls with bool return values.
    • -
    • Record ffi.errno().
    • -
    • x86: Fix number to uint32_t conversion rounding.
    • -
    • x86: Fix 64 bit arithmetic in assembler backend.
    • -
    • x64: Fix struct-by-value calling conventions.
    • -
    • ARM: Ensure invocation of SPLIT pass for float conversions.
    • -
  • -
  • Structural and performance enhancements: -
      -
    • Display trace types with -jv and -jdump.
    • -
    • Record isolated calls. But prefer recording loops over calls.
    • -
    • Specialize to prototype for non-monomorphic functions. Solves the -trace-explosion problem for closure-heavy programming styles.
    • -
    • Always generate a portable vmdef.lua. Easier for distros.
    • -
  • -
- -

LuaJIT 2.0.0-beta8 — 2011-06-23

-
    -
  • New features: -
      -
    • Soft-float ARM port of LuaJIT is complete.
    • -
    • Add support for bytecode loading/saving and -b command line -option.
    • -
    • From Lua 5.2: __len metamethod for tables -(disabled by default).
    • -
  • -
  • Correctness and completeness: -
      -
    • ARM: Misc. fixes for interpreter.
    • -
    • x86/x64: Fix bit.* argument checking in interpreter.
    • -
    • Catch early out-of-memory in memory allocator initialization.
    • -
    • Fix data-flow analysis for paths leading to an upvalue close.
    • -
    • Fix check for missing arguments in string.format().
    • -
    • Fix Solaris/x86 build (note: not a supported target).
    • -
    • Fix recording of loops with instable directions in side traces.
    • -
    • x86/x64: Fix fusion of comparisons with u8/u16 -XLOAD.
    • -
    • x86/x64: Fix register allocation for variable shifts.
    • -
  • -
  • FFI library: -
      -
    • Add ffi.errno(). Save errno/GetLastError() -around allocations etc.
    • -
    • Fix __gc for VLA/VLS cdata objects.
    • -
    • Fix recording of casts from 32 bit cdata pointers to integers.
    • -
    • tonumber(cdata) returns nil for non-numbers.
    • -
    • Show address pointed to for tostring(pointer).
    • -
    • Print NULL pointers as "cdata<... *>: NULL".
    • -
    • Support __tostring metamethod for pointers to structs, too.
    • -
  • -
  • Structural and performance enhancements: -
      -
    • More tuning for loop unrolling heuristics.
    • -
    • Flatten and compress in-memory debug info (saves ~70%).
    • -
  • -
- -

LuaJIT 2.0.0-beta7 — 2011-05-05

-
    -
  • New features: -
      -
    • ARM port of the LuaJIT interpreter is complete.
    • -
    • FFI library: Add ffi.gc(), ffi.metatype(), -ffi.istype().
    • -
    • FFI library: Resolve ld script redirection in ffi.load().
    • -
    • From Lua 5.2: package.searchpath(), fp:read("*L"), -load(string).
    • -
    • From Lua 5.2, disabled by default: empty statement, -table.unpack(), modified coroutine.running().
    • -
  • -
  • Correctness and completeness: -
      -
    • FFI library: numerous fixes.
    • -
    • Fix type mismatches in store-to-load forwarding.
    • -
    • Fix error handling within metamethods.
    • -
    • Fix table.maxn().
    • -
    • Improve accuracy of x^-k on x64.
    • -
    • Fix code generation for Intel Atom in x64 mode.
    • -
    • Fix narrowing of POW.
    • -
    • Fix recording of retried fast functions.
    • -
    • Fix code generation for bit.bnot() and multiplies.
    • -
    • Fix error location within cpcall frames.
    • -
    • Add workaround for old libgcc unwind bug.
    • -
    • Fix lua_yield() and getmetatable(lightuserdata) on x64.
    • -
    • Misc. fixes for PPC/e500 interpreter.
    • -
    • Fix stack slot updates for down-recursion.
    • -
  • -
  • Structural and performance enhancements: -
      -
    • Add dual-number mode (int/double) for the VM. Enabled for ARM.
    • -
    • Improve narrowing of arithmetic operators and for loops.
    • -
    • Tune loop unrolling heuristics and increase trace recorder limits.
    • -
    • Eliminate dead slots in snapshots using bytecode data-flow analysis.
    • -
    • Avoid phantom stores to proxy tables.
    • -
    • Optimize lookups in empty proxy tables.
    • -
    • Improve bytecode optimization of and/or operators.
    • -
  • -
- -

LuaJIT 2.0.0-beta6 — 2011-02-11

-
    -
  • New features: -
      -
    • PowerPC/e500v2 port of the LuaJIT interpreter is complete.
    • -
    • Various minor features from Lua 5.2: Hex escapes in literals, -'\*' escape, reversible string.format("%q",s), -"%g" pattern, table.sort checks callbacks, -os.exit(status|true|false[,close]).
    • -
    • Lua 5.2 __pairs and __ipairs metamethods -(disabled by default).
    • -
    • Initial release of the FFI library.
    • -
  • -
  • Correctness and completeness: -
      -
    • Fix string.format() for non-finite numbers.
    • -
    • Fix memory leak when compiled to use the built-in allocator.
    • -
    • x86/x64: Fix unnecessary resize in TSETM bytecode.
    • -
    • Fix various GC issues with traces and jit.flush().
    • -
    • x64: Fix fusion of indexes for array references.
    • -
    • x86/x64: Fix stack overflow handling for coroutine results.
    • -
    • Enable low-2GB memory allocation on FreeBSD/x64.
    • -
    • Fix collectgarbage("count") result if more than 2GB is in use.
    • -
    • Fix parsing of hex floats.
    • -
    • x86/x64: Fix loop branch inversion with trailing -HREF+NE/EQ.
    • -
    • Add jit.os string.
    • -
    • coroutine.create() permits running C functions, too.
    • -
    • Fix OSX build to work with newer ld64 versions.
    • -
    • Fix bytecode optimization of and/or operators.
    • -
  • -
  • Structural and performance enhancements: -
      -
    • Emit specialized bytecode for pairs()/next().
    • -
    • Improve bytecode coalescing of nil constants.
    • -
    • Compile calls to vararg functions.
    • -
    • Compile select().
    • -
    • Improve alias analysis, esp. for loads from allocations.
    • -
    • Tuning of various compiler heuristics.
    • -
    • Refactor and extend IR conversion instructions.
    • -
    • x86/x64: Various backend enhancements related to the FFI.
    • -
    • Add SPLIT pass to split 64 bit IR instructions for 32 bit CPUs.
    • -
  • -
- -

LuaJIT 2.0.0-beta5 — 2010-08-24

-
    -
  • Correctness and completeness: -
      -
    • Fix trace exit dispatch to function headers.
    • -
    • Fix Windows and OSX builds with LUAJIT_DISABLE_JIT.
    • -
    • Reorganize and fix placement of generated machine code on x64.
    • -
    • Fix TNEW in x64 interpreter.
    • -
    • Do not eliminate PHIs for values only referenced from side exits.
    • -
    • OS-independent canonicalization of strings for non-finite numbers.
    • -
    • Fix string.char() range check on x64.
    • -
    • Fix tostring() resolving within print().
    • -
    • Fix error handling for next().
    • -
    • Fix passing of constant arguments to external calls on x64.
    • -
    • Fix interpreter argument check for two-argument SSE math functions.
    • -
    • Fix C frame chain corruption caused by lua_cpcall().
    • -
    • Fix return from pcall() within active hook.
    • -
  • -
  • Structural and performance enhancements: -
      -
    • Replace on-trace GC frame syncing with interpreter exit.
    • -
    • Improve hash lookup specialization by not removing dead keys during GC.
    • -
    • Turn traces into true GC objects.
    • -
    • Avoid starting a GC cycle immediately after library init.
    • -
    • Add weak guards to improve dead-code elimination.
    • -
    • Speed up string interning.
    • -
  • -
- -

LuaJIT 2.0.0-beta4 — 2010-03-28

-
    -
  • Correctness and completeness: -
      -
    • Fix precondition for on-trace creation of table keys.
    • -
    • Fix {f()} on x64 when table is resized.
    • -
    • Fix folding of ordered comparisons with same references.
    • -
    • Fix snapshot restores for multi-result bytecodes.
    • -
    • Fix potential hang when recording bytecode with nested closures.
    • -
    • Fix recording of getmetatable(), tonumber() and bad argument types.
    • -
    • Fix SLOAD fusion across returns to lower frames.
    • -
  • -
  • Structural and performance enhancements: -
      -
    • Add array bounds check elimination. -Oabc is enabled by default.
    • -
    • More tuning for x64, e.g. smaller table objects.
    • -
  • -
- -

LuaJIT 2.0.0-beta3 — 2010-03-07

-
    -
  • LuaJIT x64 port: -
      -
    • Port integrated memory allocator to Linux/x64, Windows/x64 and OSX/x64.
    • -
    • Port interpreter and JIT compiler to x64.
    • -
    • Port DynASM to x64.
    • -
    • Many 32/64 bit cleanups in the VM.
    • -
    • Allow building the interpreter with either x87 or SSE2 arithmetics.
    • -
    • Add external unwinding and C++ exception interop (default on x64).
    • -
  • -
  • Correctness and completeness: -
      -
    • Fix constructor bytecode generation for certain conditional values.
    • -
    • Fix some cases of ordered string comparisons.
    • -
    • Fix lua_tocfunction().
    • -
    • Fix cutoff register in JMP bytecode for some conditional expressions.
    • -
    • Fix PHI marking algorithm for references from variant slots.
    • -
    • Fix package.cpath for non-default PREFIX.
    • -
    • Fix DWARF2 frame unwind information for interpreter on OSX.
    • -
    • Drive the GC forward on string allocations in the parser.
    • -
    • Implement call/return hooks (zero-cost if disabled).
    • -
    • Implement yield from C hooks.
    • -
    • Disable JIT compiler on older non-SSE2 CPUs instead of aborting.
    • -
  • -
  • Structural and performance enhancements: -
      -
    • Compile recursive code (tail-, up- and down-recursion).
    • -
    • Improve heuristics for bytecode penalties and blacklisting.
    • -
    • Split CALL/FUNC recording and clean up fast function call semantics.
    • -
    • Major redesign of internal function call handling.
    • -
    • Improve FOR loop const specialization and integerness checks.
    • -
    • Switch to pre-initialized stacks. Avoid frame-clearing.
    • -
    • Colocation of prototypes and related data: bytecode, constants, debug info.
    • -
    • Cleanup parser and streamline bytecode generation.
    • -
    • Add support for weak IR references to register allocator.
    • -
    • Switch to compressed, extensible snapshots.
    • -
    • Compile returns to frames below the start frame.
    • -
    • Improve alias analysis of upvalues using a disambiguation hash value.
    • -
    • Compile floor/ceil/trunc to SSE2 helper calls or SSE4.1 instructions.
    • -
    • Add generic C call handling to IR and backend.
    • -
    • Improve KNUM fuse vs. load heuristics.
    • -
    • Compile various io.*() functions.
    • -
    • Compile math.sinh(), math.cosh(), math.tanh() -and math.random().
    • -
  • -
- -

LuaJIT 2.0.0-beta2 — 2009-11-09

-
    -
  • Reorganize build system. Build static+shared library on POSIX.
  • -
  • Allow C++ exception conversion on all platforms -using a wrapper function.
  • -
  • Automatically catch C++ exceptions and rethrow Lua error -(DWARF2 only).
  • -
  • Check for the correct x87 FPU precision at strategic points.
  • -
  • Always use wrappers for libm functions.
  • -
  • Resurrect metamethod name strings before copying them.
  • -
  • Mark current trace, even if compiler is idle.
  • -
  • Ensure FILE metatable is created only once.
  • -
  • Fix type comparisons when different integer types are involved.
  • -
  • Fix getmetatable() recording.
  • -
  • Fix TDUP with dead keys in template table.
  • -
  • jit.flush(tr) returns status. -Prevent manual flush of a trace that's still linked.
  • -
  • Improve register allocation heuristics for invariant references.
  • -
  • Compile the push/pop variants of table.insert() and -table.remove().
  • -
  • Compatibility with MSVC link /debug.
  • -
  • Fix lua_iscfunction().
  • -
  • Fix math.random() when compiled with -fpic (OSX).
  • -
  • Fix table.maxn().
  • -
  • Bump MACOSX_DEPLOYMENT_TARGET to 10.4
  • -
  • luaL_check*() and luaL_opt*() now support -negative arguments, too.
    -This matches the behavior of Lua 5.1, but not the specification.
  • -
- -

LuaJIT 2.0.0-beta1 — 2009-10-31

-
    -
  • This is the first public release of LuaJIT 2.0.
  • -
  • The whole VM has been rewritten from the ground up, so there's -no point in listing differences over earlier versions.
  • -
-
- -
-

LuaJIT 1.1.8 — 2012-04-16

- - -

LuaJIT 1.1.7 — 2011-05-05

- - -

LuaJIT 1.1.6 — 2010-03-28

-
    -
  • Added fixes for the -» currently known bugs in Lua 5.1.4.
  • -
  • Removed wrong GC check in jit_createstate(). -Thanks to Tim Mensch.
  • -
  • Fixed bad assertions while compiling table.insert() and -table.remove().
  • -
- -

LuaJIT 1.1.5 — 2008-10-25

- - -

LuaJIT 1.1.4 — 2008-02-05

-
    -
  • Merged with Lua 5.1.3. Fixes all -» known bugs in Lua 5.1.2.
  • -
  • Fixed possible (but unlikely) stack corruption while compiling -k^x expressions.
  • -
  • Fixed DynASM template for cmpss instruction.
  • -
- -

LuaJIT 1.1.3 — 2007-05-24

-
    -
  • Merged with Lua 5.1.2. Fixes all -» known bugs in Lua 5.1.1.
  • -
  • Merged pending Lua 5.1.x fixes: "return -nil" bug, spurious count hook call.
  • -
  • Remove a (sometimes) wrong assertion in luaJIT_findpc().
  • -
  • DynASM now allows labels for displacements and .aword.
  • -
  • Fix some compiler warnings for DynASM glue (internal API change).
  • -
  • Correct naming for SSSE3 (temporarily known as SSE4) in DynASM and x86 disassembler.
  • -
  • The loadable debug modules now handle redirection to stdout -(e.g. -j trace=-).
  • -
- -

LuaJIT 1.1.2 — 2006-06-24

-
    -
  • Fix MSVC inline assembly: use only local variables with -lua_number2int().
  • -
  • Fix "attempt to call a thread value" bug on Mac OS X: -make values of consts used as lightuserdata keys unique -to avoid joining by the compiler/linker.
  • -
- -

LuaJIT 1.1.1 — 2006-06-20

-
    -
  • Merged with Lua 5.1.1. Fixes all -» known bugs in Lua 5.1.
  • -
  • Enforce (dynamic) linker error for EXE/DLL version mismatches.
  • -
  • Minor changes to DynASM: faster pre-processing, smaller encoding -for some immediates.
  • -
-

-This release is in sync with Coco 1.1.1 (see the -» Coco Change History). -

- -

LuaJIT 1.1.0 — 2006-03-13

-
    -
  • Merged with Lua 5.1 (final).
  • - -
  • New JIT call frame setup: -
      -
    • The C stack is kept 16 byte aligned (faster). -Mandatory for Mac OS X on Intel, too.
    • -
    • Faster calling conventions for internal C helper functions.
    • -
    • Better instruction scheduling for function prologue, OP_CALL and -OP_RETURN.
    • -
  • - -
  • Miscellaneous optimizations: -
      -
    • Faster loads of FP constants. Remove narrow-to-wide store-to-load -forwarding stalls.
    • -
    • Use (scalar) SSE2 ops (if the CPU supports it) to speed up slot moves -and FP to integer conversions.
    • -
    • Optimized the two-argument form of OP_CONCAT (a..b).
    • -
    • Inlined OP_MOD (a%b). -With better accuracy than the C variant, too.
    • -
    • Inlined OP_POW (a^b). Unroll x^k or -use k^x = 2^(log2(k)*x) or call pow().
    • -
  • - -
  • Changes in the optimizer: -
      -
    • Improved hinting for table keys derived from table values -(t1[t2[x]]).
    • -
    • Lookup hinting now works with arbitrary object types and -supports index chains, too.
    • -
    • Generate type hints for arithmetic and comparison operators, -OP_LEN, OP_CONCAT and OP_FORPREP.
    • -
    • Remove several hint definitions in favour of a generic COMBINE hint.
    • -
    • Complete rewrite of jit.opt_inline module -(ex jit.opt_lib).
    • -
  • - -
  • Use adaptive deoptimization: -
      -
    • If runtime verification of a contract fails, the affected -instruction is recompiled and patched on-the-fly. -Regular programs will trigger deoptimization only occasionally.
    • -
    • This avoids generating code for uncommon fallback cases -most of the time. Generated code is up to 30% smaller compared to -LuaJIT 1.0.3.
    • -
    • Deoptimization is used for many opcodes and contracts: -
        -
      • OP_CALL, OP_TAILCALL: type mismatch for callable.
      • -
      • Inlined calls: closure mismatch, parameter number and type mismatches.
      • -
      • OP_GETTABLE, OP_SETTABLE: table or key type and range mismatches.
      • -
      • All arithmetic and comparison operators, OP_LEN, OP_CONCAT, -OP_FORPREP: operand type and range mismatches.
      • -
    • -
    • Complete redesign of the debug and traceback info -(bytecode ↔ mcode) to support deoptimization. -Much more flexible and needs only 50% of the space.
    • -
    • The modules jit.trace, jit.dumphints and -jit.dump handle deoptimization.
    • -
  • - -
  • Inlined many popular library functions -(for commonly used arguments only): -
      -
    • Most math.* functions (the 18 most used ones) -[2x-10x faster].
    • -
    • string.len, string.sub and string.char -[2x-10x faster].
    • -
    • table.insert, table.remove and table.getn -[3x-5x faster].
    • -
    • coroutine.yield and coroutine.resume -[3x-5x faster].
    • -
    • pairs, ipairs and the corresponding iterators -[8x-15x faster].
    • -
  • - -
  • Changes in the core and loadable modules and the stand-alone executable: -
      -
    • Added jit.version, jit.version_num -and jit.arch.
    • -
    • Reorganized some internal API functions (jit.util.*mcode*).
    • -
    • The -j dump output now shows JSUB names, too.
    • -
    • New x86 disassembler module written in pure Lua. No dependency -on ndisasm anymore. Flexible API, very compact (500 lines) -and complete (x87, MMX, SSE, SSE2, SSE3, SSSE3, privileged instructions).
    • -
    • luajit -v prints the LuaJIT version and copyright -on a separate line.
    • -
  • - -
  • Added SSE, SSE2, SSE3 and SSSE3 support to DynASM.
  • -
  • Miscellaneous doc changes. Added a section about -embedding LuaJIT.
  • -
-

-This release is in sync with Coco 1.1.0 (see the -» Coco Change History). -

-
- -
-

LuaJIT 1.0.3 — 2005-09-08

-
    -
  • Even more docs.
  • -
  • Unified closure checks in jit.*.
  • -
  • Fixed some range checks in jit.util.*.
  • -
  • Fixed __newindex call originating from jit_settable_str().
  • -
  • Merged with Lua 5.1 alpha (including early bug fixes).
  • -
-

-This is the first public release of LuaJIT. -

- -

LuaJIT 1.0.2 — 2005-09-02

-
    -
  • Add support for flushing the Valgrind translation cache
    -(MYCFLAGS= -DUSE_VALGRIND).
  • -
  • Add support for freeing executable mcode memory to the mmap()-based -variant for POSIX systems.
  • -
  • Reorganized the C function signature handling in -jit.opt_lib.
  • -
  • Changed to index-based hints for inlining C functions. -Still no support in the backend for inlining.
  • -
  • Hardcode HEAP_CREATE_ENABLE_EXECUTE value if undefined.
  • -
  • Misc. changes to the jit.* modules.
  • -
  • Misc. changes to the Makefiles.
  • -
  • Lots of new docs.
  • -
  • Complete doc reorg.
  • -
-

-Not released because Lua 5.1 alpha came out today. -

- -

LuaJIT 1.0.1 — 2005-08-31

-
    -
  • Missing GC step in OP_CONCAT.
  • -
  • Fix result handling for C –> JIT calls.
  • -
  • Detect CPU feature bits.
  • -
  • Encode conditional moves (fucomip) only when supported.
  • -
  • Add fallback instructions for FP compares.
  • -
  • Add support for LUA_COMPAT_VARARG. Still disabled by default.
  • -
  • MSVC needs a specific place for the CALLBACK attribute -(David Burgess).
  • -
  • Misc. doc updates.
  • -
-

-Interim non-public release. -Special thanks to Adam D. Moss for reporting most of the bugs. -

- -

LuaJIT 1.0.0 — 2005-08-29

-

-This is the initial non-public release of LuaJIT. -

-
-
-
- - - diff --git a/source/libs/luajit/LuaJIT-2.0.3/doc/contact.html b/source/libs/luajit/LuaJIT-2.0.3/doc/contact.html deleted file mode 100644 index 0483a829b..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/doc/contact.html +++ /dev/null @@ -1,102 +0,0 @@ - - - -Contact - - - - - - - - -
-Lua -
- - -
-

-Please send general questions to the -» LuaJIT mailing list. -You can also send any questions you have directly to me: -

- - - - - -

Copyright

-

-All documentation is -Copyright © 2005-2014 Mike Pall. -

- - -
-
- - - diff --git a/source/libs/luajit/LuaJIT-2.0.3/doc/ext_c_api.html b/source/libs/luajit/LuaJIT-2.0.3/doc/ext_c_api.html deleted file mode 100644 index 485033613..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/doc/ext_c_api.html +++ /dev/null @@ -1,187 +0,0 @@ - - - -Lua/C API Extensions - - - - - - - - -
-Lua -
- - -
-

-LuaJIT adds some extensions to the standard Lua/C API. The LuaJIT include -directory must be in the compiler search path (-Ipath) -to be able to include the required header for C code: -

-
-#include "luajit.h"
-
-

-Or for C++ code: -

-
-#include "lua.hpp"
-
- -

luaJIT_setmode(L, idx, mode) -— Control VM

-

-This is a C API extension to allow control of the VM from C code. The -full prototype of LuaJIT_setmode is: -

-
-LUA_API int luaJIT_setmode(lua_State *L, int idx, int mode);
-
-

-The returned status is either success (1) or failure (0). -The second argument is either 0 or a stack index (similar to the -other Lua/C API functions). -

-

-The third argument specifies the mode, which is 'or'ed with a flag. -The flag can be LUAJIT_MODE_OFF to turn a feature on, -LUAJIT_MODE_ON to turn a feature off, or -LUAJIT_MODE_FLUSH to flush cached code. -

-

-The following modes are defined: -

- -

luaJIT_setmode(L, 0, LUAJIT_MODE_ENGINE|flag)

-

-Turn the whole JIT compiler on or off or flush the whole cache of compiled code. -

- -

luaJIT_setmode(L, idx, LUAJIT_MODE_FUNC|flag)
-luaJIT_setmode(L, idx, LUAJIT_MODE_ALLFUNC|flag)
-luaJIT_setmode(L, idx, LUAJIT_MODE_ALLSUBFUNC|flag)

-

-This sets the mode for the function at the stack index idx or -the parent of the calling function (idx = 0). It either -enables JIT compilation for a function, disables it and flushes any -already compiled code or only flushes already compiled code. This -applies recursively to all sub-functions of the function with -LUAJIT_MODE_ALLFUNC or only to the sub-functions with -LUAJIT_MODE_ALLSUBFUNC. -

- -

luaJIT_setmode(L, trace,
-  LUAJIT_MODE_TRACE|LUAJIT_MODE_FLUSH)

-

-Flushes the specified root trace and all of its side traces from the cache. -The code for the trace will be retained as long as there are any other -traces which link to it. -

- -

luaJIT_setmode(L, idx, LUAJIT_MODE_WRAPCFUNC|flag)

-

-This mode defines a wrapper function for calls to C functions. If -called with LUAJIT_MODE_ON, the stack index at idx -must be a lightuserdata object holding a pointer to the wrapper -function. From now on all C functions are called through the wrapper -function. If called with LUAJIT_MODE_OFF this mode is turned -off and all C functions are directly called. -

-

-The wrapper function can be used for debugging purposes or to catch -and convert foreign exceptions. But please read the section on -C++ exception interoperability -first. Recommended usage can be seen in this C++ code excerpt: -

-
-#include <exception>
-#include "lua.hpp"
-
-// Catch C++ exceptions and convert them to Lua error messages.
-// Customize as needed for your own exception classes.
-static int wrap_exceptions(lua_State *L, lua_CFunction f)
-{
-  try {
-    return f(L);  // Call wrapped function and return result.
-  } catch (const char *s) {  // Catch and convert exceptions.
-    lua_pushstring(L, s);
-  } catch (std::exception& e) {
-    lua_pushstring(L, e.what());
-  } catch (...) {
-    lua_pushliteral(L, "caught (...)");
-  }
-  return lua_error(L);  // Rethrow as a Lua error.
-}
-
-static int myinit(lua_State *L)
-{
-  ...
-  // Define wrapper function and enable it.
-  lua_pushlightuserdata(L, (void *)wrap_exceptions);
-  luaJIT_setmode(L, -1, LUAJIT_MODE_WRAPCFUNC|LUAJIT_MODE_ON);
-  lua_pop(L, 1);
-  ...
-}
-
-

-Note that you can only define a single global wrapper function, -so be careful when using this mechanism from multiple C++ modules. -Also note that this mechanism is not without overhead. -

-
-
- - - diff --git a/source/libs/luajit/LuaJIT-2.0.3/doc/ext_ffi.html b/source/libs/luajit/LuaJIT-2.0.3/doc/ext_ffi.html deleted file mode 100644 index fa9ca971c..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/doc/ext_ffi.html +++ /dev/null @@ -1,330 +0,0 @@ - - - -FFI Library - - - - - - - - -
-Lua -
- - -
-

- -The FFI library allows calling external C functions and -using C data structures from pure Lua code. - -

-

- -The FFI library largely obviates the need to write tedious manual -Lua/C bindings in C. No need to learn a separate binding language -— it parses plain C declarations! These can be -cut-n-pasted from C header files or reference manuals. It's up to -the task of binding large libraries without the need for dealing with -fragile binding generators. - -

-

-The FFI library is tightly integrated into LuaJIT (it's not available -as a separate module). The code generated by the JIT-compiler for -accesses to C data structures from Lua code is on par with the -code a C compiler would generate. Calls to C functions can -be inlined in JIT-compiled code, unlike calls to functions bound via -the classic Lua/C API. -

-

-This page gives a short introduction to the usage of the FFI library. -Please use the FFI sub-topics in the navigation bar to learn more. -

- -

Motivating Example: Calling External C Functions

-

-It's really easy to call an external C library function: -

-
-①
-②
-
-
-③local ffi = require("ffi")
-ffi.cdef[[
-int printf(const char *fmt, ...);
-]]
-ffi.C.printf("Hello %s!", "world")
-
-

-So, let's pick that apart: -

-

- Load the FFI library. -

-

- Add a C declaration -for the function. The part inside the double-brackets (in green) is -just standard C syntax. -

-

- Call the named -C function — Yes, it's that simple! -

-

-Actually, what goes on behind the scenes is far from simple: makes use of the standard -C library namespace ffi.C. Indexing this namespace with -a symbol name ("printf") automatically binds it to the -standard C library. The result is a special kind of object which, -when called, runs the printf function. The arguments passed -to this function are automatically converted from Lua objects to the -corresponding C types. -

-

-Ok, so maybe the use of printf() wasn't such a spectacular -example. You could have done that with io.write() and -string.format(), too. But you get the idea ... -

-

-So here's something to pop up a message box on Windows: -

-
-local ffi = require("ffi")
-ffi.cdef[[
-int MessageBoxA(void *w, const char *txt, const char *cap, int type);
-]]
-ffi.C.MessageBoxA(nil, "Hello world!", "Test", 0)
-
-

-Bing! Again, that was far too easy, no? -

-

-Compare this with the effort required to bind that function using the -classic Lua/C API: create an extra C file, add a C function -that retrieves and checks the argument types passed from Lua and calls -the actual C function, add a list of module functions and their -names, add a luaopen_* function and register all module -functions, compile and link it into a shared library (DLL), move it to -the proper path, add Lua code that loads the module aaaand ... finally -call the binding function. Phew! -

- -

Motivating Example: Using C Data Structures

-

-The FFI library allows you to create and access C data -structures. Of course the main use for this is for interfacing with -C functions. But they can be used stand-alone, too. -

-

-Lua is built upon high-level data types. They are flexible, extensible -and dynamic. That's why we all love Lua so much. Alas, this can be -inefficient for certain tasks, where you'd really want a low-level -data type. E.g. a large array of a fixed structure needs to be -implemented with a big table holding lots of tiny tables. This imposes -both a substantial memory overhead as well as a performance overhead. -

-

-Here's a sketch of a library that operates on color images plus a -simple benchmark. First, the plain Lua version: -

-
-local floor = math.floor
-
-local function image_ramp_green(n)
-  local img = {}
-  local f = 255/(n-1)
-  for i=1,n do
-    img[i] = { red = 0, green = floor((i-1)*f), blue = 0, alpha = 255 }
-  end
-  return img
-end
-
-local function image_to_grey(img, n)
-  for i=1,n do
-    local y = floor(0.3*img[i].red + 0.59*img[i].green + 0.11*img[i].blue)
-    img[i].red = y; img[i].green = y; img[i].blue = y
-  end
-end
-
-local N = 400*400
-local img = image_ramp_green(N)
-for i=1,1000 do
-  image_to_grey(img, N)
-end
-
-

-This creates a table with 160.000 pixels, each of which is a table -holding four number values in the range of 0-255. First an image with -a green ramp is created (1D for simplicity), then the image is -converted to greyscale 1000 times. Yes, that's silly, but I was in -need of a simple example ... -

-

-And here's the FFI version. The modified parts have been marked in -bold: -

-
-①
-
-
-
-
-
-②
-
-③
-④
-
-
-
-
-
-
-③
-⑤local ffi = require("ffi")
-ffi.cdef[[
-typedef struct { uint8_t red, green, blue, alpha; } rgba_pixel;
-]]
-
-local function image_ramp_green(n)
-  local img = ffi.new("rgba_pixel[?]", n)
-  local f = 255/(n-1)
-  for i=0,n-1 do
-    img[i].green = i*f
-    img[i].alpha = 255
-  end
-  return img
-end
-
-local function image_to_grey(img, n)
-  for i=0,n-1 do
-    local y = 0.3*img[i].red + 0.59*img[i].green + 0.11*img[i].blue
-    img[i].red = y; img[i].green = y; img[i].blue = y
-  end
-end
-
-local N = 400*400
-local img = image_ramp_green(N)
-for i=1,1000 do
-  image_to_grey(img, N)
-end
-
-

-Ok, so that wasn't too difficult: -

-

- First, load the FFI -library and declare the low-level data type. Here we choose a -struct which holds four byte fields, one for each component -of a 4x8 bit RGBA pixel. -

-

- Creating the data -structure with ffi.new() is straightforward — the -'?' is a placeholder for the number of elements of a -variable-length array. -

-

- C arrays are -zero-based, so the indexes have to run from 0 to -n-1. One might want to allocate one more element instead to -simplify converting legacy code. -

-

- Since ffi.new() -zero-fills the array by default, we only need to set the green and the -alpha fields. -

-

- The calls to -math.floor() can be omitted here, because floating-point -numbers are already truncated towards zero when converting them to an -integer. This happens implicitly when the number is stored in the -fields of each pixel. -

-

-Now let's have a look at the impact of the changes: first, memory -consumption for the image is down from 22 Megabytes to -640 Kilobytes (400*400*4 bytes). That's a factor of 35x less! So, -yes, tables do have a noticeable overhead. BTW: The original program -would consume 40 Megabytes in plain Lua (on x64). -

-

-Next, performance: the pure Lua version runs in 9.57 seconds (52.9 -seconds with the Lua interpreter) and the FFI version runs in 0.48 -seconds on my machine (YMMV). That's a factor of 20x faster (110x -faster than the Lua interpreter). -

-

-The avid reader may notice that converting the pure Lua version over -to use array indexes for the colors ([1] instead of -.red, [2] instead of .green etc.) ought to -be more compact and faster. This is certainly true (by a factor of -~1.7x). Switching to a struct-of-arrays would help, too. -

-

-However the resulting code would be less idiomatic and rather -error-prone. And it still doesn't get even close to the performance of -the FFI version of the code. Also, high-level data structures cannot -be easily passed to other C functions, especially I/O functions, -without undue conversion penalties. -

-
-
- - - diff --git a/source/libs/luajit/LuaJIT-2.0.3/doc/ext_ffi_api.html b/source/libs/luajit/LuaJIT-2.0.3/doc/ext_ffi_api.html deleted file mode 100644 index dcffcfa38..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/doc/ext_ffi_api.html +++ /dev/null @@ -1,566 +0,0 @@ - - - -ffi.* API Functions - - - - - - - - - -
-Lua -
- - -
-

-This page describes the API functions provided by the FFI library in -detail. It's recommended to read through the -introduction and the -FFI tutorial first. -

- -

Glossary

-
    -
  • cdecl — An abstract C type declaration (a Lua -string).
  • -
  • ctype — A C type object. This is a special kind of -cdata returned by ffi.typeof(). It serves as a -cdata constructor when called.
  • -
  • cdata — A C data object. It holds a value of the -corresponding ctype.
  • -
  • ct — A C type specification which can be used for -most of the API functions. Either a cdecl, a ctype or a -cdata serving as a template type.
  • -
  • cb — A callback object. This is a C data object -holding a special function pointer. Calling this function from -C code runs an associated Lua function.
  • -
  • VLA — A variable-length array is declared with a -? instead of the number of elements, e.g. "int[?]". -The number of elements (nelem) must be given when it's -created.
  • -
  • VLS — A variable-length struct is a struct C -type where the last element is a VLA. The same rules for -declaration and creation apply.
  • -
- -

Declaring and Accessing External Symbols

-

-External symbols must be declared first and can then be accessed by -indexing a C library -namespace, which automatically binds the symbol to a specific -library. -

- -

ffi.cdef(def)

-

-Adds multiple C declarations for types or external symbols (named -variables or functions). def must be a Lua string. It's -recommended to use the syntactic sugar for string arguments as -follows: -

-
-ffi.cdef[[
-typedef struct foo { int a, b; } foo_t;  // Declare a struct and typedef.
-int dofoo(foo_t *f, int n);  /* Declare an external C function. */
-]]
-
-

-The contents of the string (the part in green above) must be a -sequence of -C declarations, -separated by semicolons. The trailing semicolon for a single -declaration may be omitted. -

-

-Please note that external symbols are only declared, but they -are not bound to any specific address, yet. Binding is -achieved with C library namespaces (see below). -

-

-C declarations are not passed through a C pre-processor, -yet. No pre-processor tokens are allowed, except for -#pragma pack. Replace #define in existing -C header files with enum, static const -or typedef and/or pass the files through an external -C pre-processor (once). Be careful not to include unneeded or -redundant declarations from unrelated header files. -

- -

ffi.C

-

-This is the default C library namespace — note the -uppercase 'C'. It binds to the default set of symbols or -libraries on the target system. These are more or less the same as a -C compiler would offer by default, without specifying extra link -libraries. -

-

-On POSIX systems, this binds to symbols in the default or global -namespace. This includes all exported symbols from the executable and -any libraries loaded into the global namespace. This includes at least -libc, libm, libdl (on Linux), -libgcc (if compiled with GCC), as well as any exported -symbols from the Lua/C API provided by LuaJIT itself. -

-

-On Windows systems, this binds to symbols exported from the -*.exe, the lua51.dll (i.e. the Lua/C API -provided by LuaJIT itself), the C runtime library LuaJIT was linked -with (msvcrt*.dll), kernel32.dll, -user32.dll and gdi32.dll. -

- -

clib = ffi.load(name [,global])

-

-This loads the dynamic library given by name and returns -a new C library namespace which binds to its symbols. On POSIX -systems, if global is true, the library symbols are -loaded into the global namespace, too. -

-

-If name is a path, the library is loaded from this path. -Otherwise name is canonicalized in a system-dependent way and -searched in the default search path for dynamic libraries: -

-

-On POSIX systems, if the name contains no dot, the extension -.so is appended. Also, the lib prefix is prepended -if necessary. So ffi.load("z") looks for "libz.so" -in the default shared library search path. -

-

-On Windows systems, if the name contains no dot, the extension -.dll is appended. So ffi.load("ws2_32") looks for -"ws2_32.dll" in the default DLL search path. -

- -

Creating cdata Objects

-

-The following API functions create cdata objects (type() -returns "cdata"). All created cdata objects are -garbage collected. -

- -

cdata = ffi.new(ct [,nelem] [,init...])
-cdata = ctype([nelem,] [init...])

-

-Creates a cdata object for the given ct. VLA/VLS types -require the nelem argument. The second syntax uses a ctype as -a constructor and is otherwise fully equivalent. -

-

-The cdata object is initialized according to the -rules for initializers, -using the optional init arguments. Excess initializers cause -an error. -

-

-Performance notice: if you want to create many objects of one kind, -parse the cdecl only once and get its ctype with -ffi.typeof(). Then use the ctype as a constructor repeatedly. -

-

-Please note that an anonymous struct declaration implicitly -creates a new and distinguished ctype every time you use it for -ffi.new(). This is probably not what you want, -especially if you create more than one cdata object. Different anonymous -structs are not considered assignment-compatible by the -C standard, even though they may have the same fields! Also, they -are considered different types by the JIT-compiler, which may cause an -excessive number of traces. It's strongly suggested to either declare -a named struct or typedef with ffi.cdef() -or to create a single ctype object for an anonymous struct -with ffi.typeof(). -

- -

ctype = ffi.typeof(ct)

-

-Creates a ctype object for the given ct. -

-

-This function is especially useful to parse a cdecl only once and then -use the resulting ctype object as a constructor. -

- -

cdata = ffi.cast(ct, init)

-

-Creates a scalar cdata object for the given ct. The cdata -object is initialized with init using the "cast" variant of -the C type conversion -rules. -

-

-This functions is mainly useful to override the pointer compatibility -checks or to convert pointers to addresses or vice versa. -

- -

ctype = ffi.metatype(ct, metatable)

-

-Creates a ctype object for the given ct and associates it with -a metatable. Only struct/union types, complex numbers -and vectors are allowed. Other types may be wrapped in a -struct, if needed. -

-

-The association with a metatable is permanent and cannot be changed -afterwards. Neither the contents of the metatable nor the -contents of an __index table (if any) may be modified -afterwards. The associated metatable automatically applies to all uses -of this type, no matter how the objects are created or where they -originate from. Note that pre-defined operations on types have -precedence (e.g. declared field names cannot be overriden). -

-

-All standard Lua metamethods are implemented. These are called directly, -without shortcuts and on any mix of types. For binary operations, the -left operand is checked first for a valid ctype metamethod. The -__gc metamethod only applies to struct/union -types and performs an implicit ffi.gc() -call during creation of an instance. -

- -

cdata = ffi.gc(cdata, finalizer)

-

-Associates a finalizer with a pointer or aggregate cdata object. The -cdata object is returned unchanged. -

-

-This function allows safe integration of unmanaged resources into the -automatic memory management of the LuaJIT garbage collector. Typical -usage: -

-
-local p = ffi.gc(ffi.C.malloc(n), ffi.C.free)
-...
-p = nil -- Last reference to p is gone.
--- GC will eventually run finalizer: ffi.C.free(p)
-
-

-A cdata finalizer works like the __gc metamethod for userdata -objects: when the last reference to a cdata object is gone, the -associated finalizer is called with the cdata object as an argument. The -finalizer can be a Lua function or a cdata function or cdata function -pointer. An existing finalizer can be removed by setting a nil -finalizer, e.g. right before explicitly deleting a resource: -

-
-ffi.C.free(ffi.gc(p, nil)) -- Manually free the memory.
-
- -

C Type Information

-

-The following API functions return information about C types. -They are most useful for inspecting cdata objects. -

- -

size = ffi.sizeof(ct [,nelem])

-

-Returns the size of ct in bytes. Returns nil if -the size is not known (e.g. for "void" or function types). -Requires nelem for VLA/VLS types, except for cdata objects. -

- -

align = ffi.alignof(ct)

-

-Returns the minimum required alignment for ct in bytes. -

- -

ofs [,bpos,bsize] = ffi.offsetof(ct, field)

-

-Returns the offset (in bytes) of field relative to the start -of ct, which must be a struct. Additionally returns -the position and the field size (in bits) for bit fields. -

- -

status = ffi.istype(ct, obj)

-

-Returns true if obj has the C type given by -ct. Returns false otherwise. -

-

-C type qualifiers (const etc.) are ignored. Pointers are -checked with the standard pointer compatibility rules, but without any -special treatment for void *. If ct specifies a -struct/union, then a pointer to this type is accepted, -too. Otherwise the types must match exactly. -

-

-Note: this function accepts all kinds of Lua objects for the -obj argument, but always returns false for non-cdata -objects. -

- -

Utility Functions

- -

err = ffi.errno([newerr])

-

-Returns the error number set by the last C function call which -indicated an error condition. If the optional newerr argument -is present, the error number is set to the new value and the previous -value is returned. -

-

-This function offers a portable and OS-independent way to get and set the -error number. Note that only some C functions set the error -number. And it's only significant if the function actually indicated an -error condition (e.g. with a return value of -1 or -NULL). Otherwise, it may or may not contain any previously set -value. -

-

-You're advised to call this function only when needed and as close as -possible after the return of the related C function. The -errno value is preserved across hooks, memory allocations, -invocations of the JIT compiler and other internal VM activity. The same -applies to the value returned by GetLastError() on Windows, but -you need to declare and call it yourself. -

- -

str = ffi.string(ptr [,len])

-

-Creates an interned Lua string from the data pointed to by -ptr. -

-

-If the optional argument len is missing, ptr is -converted to a "char *" and the data is assumed to be -zero-terminated. The length of the string is computed with -strlen(). -

-

-Otherwise ptr is converted to a "void *" and -len gives the length of the data. The data may contain -embedded zeros and need not be byte-oriented (though this may cause -endianess issues). -

-

-This function is mainly useful to convert (temporary) -"const char *" pointers returned by -C functions to Lua strings and store them or pass them to other -functions expecting a Lua string. The Lua string is an (interned) copy -of the data and bears no relation to the original data area anymore. -Lua strings are 8 bit clean and may be used to hold arbitrary, -non-character data. -

-

-Performance notice: it's faster to pass the length of the string, if -it's known. E.g. when the length is returned by a C call like -sprintf(). -

- -

ffi.copy(dst, src, len)
-ffi.copy(dst, str)

-

-Copies the data pointed to by src to dst. -dst is converted to a "void *" and src -is converted to a "const void *". -

-

-In the first syntax, len gives the number of bytes to copy. -Caveat: if src is a Lua string, then len must not -exceed #src+1. -

-

-In the second syntax, the source of the copy must be a Lua string. All -bytes of the string plus a zero-terminator are copied to -dst (i.e. #src+1 bytes). -

-

-Performance notice: ffi.copy() may be used as a faster -(inlinable) replacement for the C library functions -memcpy(), strcpy() and strncpy(). -

- -

ffi.fill(dst, len [,c])

-

-Fills the data pointed to by dst with len constant -bytes, given by c. If c is omitted, the data is -zero-filled. -

-

-Performance notice: ffi.fill() may be used as a faster -(inlinable) replacement for the C library function -memset(dst, c, len). Please note the different -order of arguments! -

- -

Target-specific Information

- -

status = ffi.abi(param)

-

-Returns true if param (a Lua string) applies for the -target ABI (Application Binary Interface). Returns false -otherwise. The following parameters are currently defined: -

- - - - - - - - - - - - - - - - - - - - - - - -
ParameterDescription
32bit32 bit architecture
64bit64 bit architecture
leLittle-endian architecture
beBig-endian architecture
fpuTarget has a hardware FPU
softfpsoftfp calling conventions
hardfphardfp calling conventions
eabiEABI variant of the standard ABI
winWindows variant of the standard ABI
- -

ffi.os

-

-Contains the target OS name. Same contents as -jit.os. -

- -

ffi.arch

-

-Contains the target architecture name. Same contents as -jit.arch. -

- -

Methods for Callbacks

-

-The C types for callbacks -have some extra methods: -

- -

cb:free()

-

-Free the resources associated with a callback. The associated Lua -function is unanchored and may be garbage collected. The callback -function pointer is no longer valid and must not be called anymore -(it may be reused by a subsequently created callback). -

- -

cb:set(func)

-

-Associate a new Lua function with a callback. The C type of the -callback and the callback function pointer are unchanged. -

-

-This method is useful to dynamically switch the receiver of callbacks -without creating a new callback each time and registering it again (e.g. -with a GUI library). -

- -

Extended Standard Library Functions

-

-The following standard library functions have been extended to work -with cdata objects: -

- -

n = tonumber(cdata)

-

-Converts a number cdata object to a double and returns it as -a Lua number. This is particularly useful for boxed 64 bit -integer values. Caveat: this conversion may incur a precision loss. -

- -

s = tostring(cdata)

-

-Returns a string representation of the value of 64 bit integers -("nnnLL" or "nnnULL") or -complex numbers ("re±imi"). Otherwise -returns a string representation of the C type of a ctype object -("ctype<type>") or a cdata object -("cdata<type>: address"), unless you -override it with a __tostring metamethod (see -ffi.metatype()). -

- -

iter, obj, start = pairs(cdata)
-iter, obj, start = ipairs(cdata)

-

-Calls the __pairs or __ipairs metamethod of the -corresponding ctype. -

- -

Extensions to the Lua Parser

-

-The parser for Lua source code treats numeric literals with the -suffixes LL or ULL as signed or unsigned 64 bit -integers. Case doesn't matter, but uppercase is recommended for -readability. It handles both decimal (42LL) and hexadecimal -(0x2aLL) literals. -

-

-The imaginary part of complex numbers can be specified by suffixing -number literals with i or I, e.g. 12.5i. -Caveat: you'll need to use 1i to get an imaginary part with -the value one, since i itself still refers to a variable -named i. -

-
-
- - - diff --git a/source/libs/luajit/LuaJIT-2.0.3/doc/ext_ffi_semantics.html b/source/libs/luajit/LuaJIT-2.0.3/doc/ext_ffi_semantics.html deleted file mode 100644 index 7e5f70357..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/doc/ext_ffi_semantics.html +++ /dev/null @@ -1,1245 +0,0 @@ - - - -FFI Semantics - - - - - - - - - -
-Lua -
- - -
-

-This page describes the detailed semantics underlying the FFI library -and its interaction with both Lua and C code. -

-

-Given that the FFI library is designed to interface with C code -and that declarations can be written in plain C syntax, it -closely follows the C language semantics, wherever possible. -Some minor concessions are needed for smoother interoperation with Lua -language semantics. -

-

-Please don't be overwhelmed by the contents of this page — this -is a reference and you may need to consult it, if in doubt. It doesn't -hurt to skim this page, but most of the semantics "just work" as you'd -expect them to work. It should be straightforward to write -applications using the LuaJIT FFI for developers with a C or C++ -background. -

- -

C Language Support

-

-The FFI library has a built-in C parser with a minimal memory -footprint. It's used by the ffi.* library -functions to declare C types or external symbols. -

-

-It's only purpose is to parse C declarations, as found e.g. in -C header files. Although it does evaluate constant expressions, -it's not a C compiler. The body of inline -C function definitions is simply ignored. -

-

-Also, this is not a validating C parser. It expects and -accepts correctly formed C declarations, but it may choose to -ignore bad declarations or show rather generic error messages. If in -doubt, please check the input against your favorite C compiler. -

-

-The C parser complies to the C99 language standard plus -the following extensions: -

-
    - -
  • The '\e' escape in character and string literals.
  • - -
  • The C99/C++ boolean type, declared with the keywords bool -or _Bool.
  • - -
  • Complex numbers, declared with the keywords complex or -_Complex.
  • - -
  • Two complex number types: complex (aka -complex double) and complex float.
  • - -
  • Vector types, declared with the GCC mode or -vector_size attribute.
  • - -
  • Unnamed ('transparent') struct/union fields -inside a struct/union.
  • - -
  • Incomplete enum declarations, handled like incomplete -struct declarations.
  • - -
  • Unnamed enum fields inside a -struct/union. This is similar to a scoped C++ -enum, except that declared constants are visible in the -global namespace, too.
  • - -
  • Scoped static const declarations inside a -struct/union (from C++).
  • - -
  • Zero-length arrays ([0]), empty -struct/union, variable-length arrays (VLA, -[?]) and variable-length structs (VLS, with a trailing -VLA).
  • - -
  • C++ reference types (int &x).
  • - -
  • Alternate GCC keywords with '__', e.g. -__const__.
  • - -
  • GCC __attribute__ with the following attributes: -aligned, packed, mode, -vector_size, cdecl, fastcall, -stdcall, thiscall.
  • - -
  • The GCC __extension__ keyword and the GCC -__alignof__ operator.
  • - -
  • GCC __asm__("symname") symbol name redirection for -function declarations.
  • - -
  • MSVC keywords for fixed-length types: __int8, -__int16, __int32 and __int64.
  • - -
  • MSVC __cdecl, __fastcall, __stdcall, -__thiscall, __ptr32, __ptr64, -__declspec(align(n)) and #pragma pack.
  • - -
  • All other GCC/MSVC-specific attributes are ignored.
  • - -
-

-The following C types are pre-defined by the C parser (like -a typedef, except re-declarations will be ignored): -

-
    - -
  • Vararg handling: va_list, __builtin_va_list, -__gnuc_va_list.
  • - -
  • From <stddef.h>: ptrdiff_t, -size_t, wchar_t.
  • - -
  • From <stdint.h>: int8_t, int16_t, -int32_t, int64_t, uint8_t, -uint16_t, uint32_t, uint64_t, -intptr_t, uintptr_t.
  • - -
-

-You're encouraged to use these types in preference to -compiler-specific extensions or target-dependent standard types. -E.g. char differs in signedness and long differs in -size, depending on the target architecture and platform ABI. -

-

-The following C features are not supported: -

-
    - -
  • A declaration must always have a type specifier; it doesn't -default to an int type.
  • - -
  • Old-style empty function declarations (K&R) are not allowed. -All C functions must have a proper prototype declaration. A -function declared without parameters (int foo();) is -treated as a function taking zero arguments, like in C++.
  • - -
  • The long double C type is parsed correctly, but -there's no support for the related conversions, accesses or arithmetic -operations.
  • - -
  • Wide character strings and character literals are not -supported.
  • - -
  • See below for features that are currently -not implemented.
  • - -
- -

C Type Conversion Rules

- -

Conversions from C types to Lua objects

-

-These conversion rules apply for read accesses to -C types: indexing pointers, arrays or -struct/union types; reading external variables or -constant values; retrieving return values from C calls: -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
InputConversionOutput
int8_t, int16_tsign-ext int32_tdoublenumber
uint8_t, uint16_tzero-ext int32_tdoublenumber
int32_t, uint32_tdoublenumber
int64_t, uint64_tboxed value64 bit int cdata
double, floatdoublenumber
bool0 → false, otherwise trueboolean
enumboxed valueenum cdata
Complex numberboxed valuecomplex cdata
Vectorboxed valuevector cdata
Pointerboxed valuepointer cdata
Arrayboxed referencereference cdata
struct/unionboxed referencereference cdata
-

-Bitfields are treated like their underlying type. -

-

-Reference types are dereferenced before a conversion can take -place — the conversion is applied to the C type pointed to -by the reference. -

- -

Conversions from Lua objects to C types

-

-These conversion rules apply for write accesses to -C types: indexing pointers, arrays or -struct/union types; initializing cdata objects; -casts to C types; writing to external variables; passing -arguments to C calls: -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
InputConversionOutput
numberdouble
booleanfalse → 0, true → 1bool
nilNULL(void *)
lightuserdatalightuserdata address →(void *)
userdatauserdata payload →(void *)
io.* fileget FILE * handle →(void *)
stringmatch against enum constantenum
stringcopy string data + zero-byteint8_t[], uint8_t[]
stringstring data →const char[]
functioncreate callbackC function type
tabletable initializerArray
tabletable initializerstruct/union
cdatacdata payload →C type
-

-If the result type of this conversion doesn't match the -C type of the destination, the -conversion rules between C types -are applied. -

-

-Reference types are immutable after initialization ("no re-seating of -references"). For initialization purposes or when passing values to -reference parameters, they are treated like pointers. Note that unlike -in C++, there's no way to implement automatic reference generation of -variables under the Lua language semantics. If you want to call a -function with a reference parameter, you need to explicitly pass a -one-element array. -

- -

Conversions between C types

-

-These conversion rules are more or less the same as the standard -C conversion rules. Some rules only apply to casts, or require -pointer or type compatibility: -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
InputConversionOutput
Signed integernarrow or sign-extendInteger
Unsigned integernarrow or zero-extendInteger
Integerrounddouble, float
double, floattrunc int32_tnarrow(u)int8_t, (u)int16_t
double, floattrunc(u)int32_t, (u)int64_t
double, floatroundfloat, double
Numbern == 0 → 0, otherwise 1bool
boolfalse → 0, true → 1Number
Complex numberconvert real partNumber
Numberconvert real part, imag = 0Complex number
Complex numberconvert real and imag partComplex number
Numberconvert scalar and replicateVector
Vectorcopy (same size)Vector
struct/uniontake base address (compat)Pointer
Arraytake base address (compat)Pointer
Functiontake function addressFunction pointer
Numberconvert via uintptr_t (cast)Pointer
Pointerconvert address (compat/cast)Pointer
Pointerconvert address (cast)Integer
Arrayconvert base address (cast)Integer
Arraycopy (compat)Array
struct/unioncopy (identical type)struct/union
-

-Bitfields or enum types are treated like their underlying -type. -

-

-Conversions not listed above will raise an error. E.g. it's not -possible to convert a pointer to a complex number or vice versa. -

- -

Conversions for vararg C function arguments

-

-The following default conversion rules apply when passing Lua objects -to the variable argument part of vararg C functions: -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
InputConversionOutput
numberdouble
booleanfalse → 0, true → 1bool
nilNULL(void *)
userdatauserdata payload →(void *)
lightuserdatalightuserdata address →(void *)
stringstring data →const char *
float cdatadouble
Array cdatatake base addressElement pointer
struct/union cdatatake base addressstruct/union pointer
Function cdatatake function addressFunction pointer
Any other cdatano conversionC type
-

-To pass a Lua object, other than a cdata object, as a specific type, -you need to override the conversion rules: create a temporary cdata -object with a constructor or a cast and initialize it with the value -to pass: -

-

-Assuming x is a Lua number, here's how to pass it as an -integer to a vararg function: -

-
-ffi.cdef[[
-int printf(const char *fmt, ...);
-]]
-ffi.C.printf("integer value: %d\n", ffi.new("int", x))
-
-

-If you don't do this, the default Lua number → double -conversion rule applies. A vararg C function expecting an integer -will see a garbled or uninitialized value. -

- -

Initializers

-

-Creating a cdata object with -ffi.new() or the -equivalent constructor syntax always initializes its contents, too. -Different rules apply, depending on the number of optional -initializers and the C types involved: -

-
    -
  • If no initializers are given, the object is filled with zero bytes.
  • - -
  • Scalar types (numbers and pointers) accept a single initializer. -The Lua object is converted to the scalar -C type.
  • - -
  • Valarrays (complex numbers and vectors) are treated like scalars -when a single initializer is given. Otherwise they are treated like -regular arrays.
  • - -
  • Aggregate types (arrays and structs) accept either a single cdata -initializer of the same type (copy constructor), a single -table initializer, or a flat list of -initializers.
  • - -
  • The elements of an array are initialized, starting at index zero. -If a single initializer is given for an array, it's repeated for all -remaining elements. This doesn't happen if two or more initializers -are given: all remaining uninitialized elements are filled with zero -bytes.
  • - -
  • Byte arrays may also be initialized with a Lua string. This copies -the whole string plus a terminating zero-byte. The copy stops early only -if the array has a known, fixed size.
  • - -
  • The fields of a struct are initialized in the order of -their declaration. Uninitialized fields are filled with zero -bytes.
  • - -
  • Only the first field of a union can be initialized with a -flat initializer.
  • - -
  • Elements or fields which are aggregates themselves are initialized -with a single initializer, but this may be a table -initializer or a compatible aggregate.
  • - -
  • Excess initializers cause an error.
  • - -
- -

Table Initializers

-

-The following rules apply if a Lua table is used to initialize an -Array or a struct/union: -

-
    - -
  • If the table index [0] is non-nil, then the -table is assumed to be zero-based. Otherwise it's assumed to be -one-based.
  • - -
  • Array elements, starting at index zero, are initialized one-by-one -with the consecutive table elements, starting at either index -[0] or [1]. This process stops at the first -nil table element.
  • - -
  • If exactly one array element was initialized, it's repeated for -all the remaining elements. Otherwise all remaining uninitialized -elements are filled with zero bytes.
  • - -
  • The above logic only applies to arrays with a known fixed size. -A VLA is only initialized with the element(s) given in the table. -Depending on the use case, you may need to explicitly add a -NULL or 0 terminator to a VLA.
  • - -
  • A struct/union can be initialized in the -order of the declaration of its fields. Each field is initialized with -consecutive table elements, starting at either index [0] -or [1]. This process stops at the first nil table -element.
  • - -
  • Otherwise, if neither index [0] nor [1] is present, -a struct/union is initialized by looking up each field -name (as a string key) in the table. Each non-nil value is -used to initialize the corresponding field.
  • - -
  • Uninitialized fields of a struct are filled with zero -bytes, except for the trailing VLA of a VLS.
  • - -
  • Initialization of a union stops after one field has been -initialized. If no field has been initialized, the union is -filled with zero bytes.
  • - -
  • Elements or fields which are aggregates themselves are initialized -with a single initializer, but this may be a nested table -initializer (or a compatible aggregate).
  • - -
  • Excess initializers for an array cause an error. Excess -initializers for a struct/union are ignored. -Unrelated table entries are ignored, too.
  • - -
-

-Example: -

-
-local ffi = require("ffi")
-
-ffi.cdef[[
-struct foo { int a, b; };
-union bar { int i; double d; };
-struct nested { int x; struct foo y; };
-]]
-
-ffi.new("int[3]", {})            --> 0, 0, 0
-ffi.new("int[3]", {1})           --> 1, 1, 1
-ffi.new("int[3]", {1,2})         --> 1, 2, 0
-ffi.new("int[3]", {1,2,3})       --> 1, 2, 3
-ffi.new("int[3]", {[0]=1})       --> 1, 1, 1
-ffi.new("int[3]", {[0]=1,2})     --> 1, 2, 0
-ffi.new("int[3]", {[0]=1,2,3})   --> 1, 2, 3
-ffi.new("int[3]", {[0]=1,2,3,4}) --> error: too many initializers
-
-ffi.new("struct foo", {})            --> a = 0, b = 0
-ffi.new("struct foo", {1})           --> a = 1, b = 0
-ffi.new("struct foo", {1,2})         --> a = 1, b = 2
-ffi.new("struct foo", {[0]=1,2})     --> a = 1, b = 2
-ffi.new("struct foo", {b=2})         --> a = 0, b = 2
-ffi.new("struct foo", {a=1,b=2,c=3}) --> a = 1, b = 2  'c' is ignored
-
-ffi.new("union bar", {})        --> i = 0, d = 0.0
-ffi.new("union bar", {1})       --> i = 1, d = ?
-ffi.new("union bar", {[0]=1,2}) --> i = 1, d = ?    '2' is ignored
-ffi.new("union bar", {d=2})     --> i = ?, d = 2.0
-
-ffi.new("struct nested", {1,{2,3}})     --> x = 1, y.a = 2, y.b = 3
-ffi.new("struct nested", {x=1,y={2,3}}) --> x = 1, y.a = 2, y.b = 3
-
- -

Operations on cdata Objects

-

-All of the standard Lua operators can be applied to cdata objects or a -mix of a cdata object and another Lua object. The following list shows -the pre-defined operations. -

-

-Reference types are dereferenced before performing each of -the operations below — the operation is applied to the -C type pointed to by the reference. -

-

-The pre-defined operations are always tried first before deferring to a -metamethod or index table (if any) for the corresponding ctype (except -for __new). An error is raised if the metamethod lookup or -index table lookup fails. -

- -

Indexing a cdata object

-
    - -
  • Indexing a pointer/array: a cdata pointer/array can be -indexed by a cdata number or a Lua number. The element address is -computed as the base address plus the number value multiplied by the -element size in bytes. A read access loads the element value and -converts it to a Lua object. A write -access converts a Lua object to the element -type and stores the converted value to the element. An error is -raised if the element size is undefined or a write access to a -constant element is attempted.
  • - -
  • Dereferencing a struct/union field: a -cdata struct/union or a pointer to a -struct/union can be dereferenced by a string key, -giving the field name. The field address is computed as the base -address plus the relative offset of the field. A read access loads the -field value and converts it to a Lua -object. A write access converts a Lua -object to the field type and stores the converted value to the -field. An error is raised if a write access to a constant -struct/union or a constant field is attempted. -Scoped enum constants or static constants are treated like a constant -field.
  • - -
  • Indexing a complex number: a complex number can be indexed -either by a cdata number or a Lua number with the values 0 or 1, or by -the strings "re" or "im". A read access loads the -real part ([0], .re) or the imaginary part -([1], .im) part of a complex number and -converts it to a Lua number. The -sub-parts of a complex number are immutable — assigning to an -index of a complex number raises an error. Accessing out-of-bound -indexes returns unspecified results, but is guaranteed not to trigger -memory access violations.
  • - -
  • Indexing a vector: a vector is treated like an array for -indexing purposes, except the vector elements are immutable — -assigning to an index of a vector raises an error.
  • - -
-

-A ctype object can be indexed with a string key, too. The only -pre-defined operation is reading scoped constants of -struct/union types. All other accesses defer -to the corresponding metamethods or index tables (if any). -

-

-Note: since there's (deliberately) no address-of operator, a cdata -object holding a value type is effectively immutable after -initialization. The JIT compiler benefits from this fact when applying -certain optimizations. -

-

-As a consequence, the elements of complex numbers and -vectors are immutable. But the elements of an aggregate holding these -types may be modified of course. I.e. you cannot assign to -foo.c.im, but you can assign a (newly created) complex number -to foo.c. -

-

-The JIT compiler implements strict aliasing rules: accesses to different -types do not alias, except for differences in signedness (this -applies even to char pointers, unlike C99). Type punning -through unions is explicitly detected and allowed. -

- -

Calling a cdata object

-
    - -
  • Constructor: a ctype object can be called and used as a -constructor. This is equivalent -to ffi.new(ct, ...), unless a __new metamethod is -defined. The __new metamethod is called with the ctype object -plus any other arguments passed to the contructor. Note that you have to -use ffi.new inside of it, since calling ct(...) would -cause infinite recursion.
  • - -
  • C function call: a cdata function or cdata function -pointer can be called. The passed arguments are -converted to the C types of the -parameters given by the function declaration. Arguments passed to the -variable argument part of vararg C function use -special conversion rules. This -C function is called and the return value (if any) is -converted to a Lua object.
    -On Windows/x86 systems, __stdcall functions are automatically -detected and a function declared as __cdecl (the default) is -silently fixed up after the first call.
  • - -
- -

Arithmetic on cdata objects

-
    - -
  • Pointer arithmetic: a cdata pointer/array and a cdata -number or a Lua number can be added or subtracted. The number must be -on the right hand side for a subtraction. The result is a pointer of -the same type with an address plus or minus the number value -multiplied by the element size in bytes. An error is raised if the -element size is undefined.
  • - -
  • Pointer difference: two compatible cdata pointers/arrays -can be subtracted. The result is the difference between their -addresses, divided by the element size in bytes. An error is raised if -the element size is undefined or zero.
  • - -
  • 64 bit integer arithmetic: the standard arithmetic -operators (+ - * / % ^ and unary -minus) can be applied to two cdata numbers, or a cdata number and a -Lua number. If one of them is an uint64_t, the other side is -converted to an uint64_t and an unsigned arithmetic operation -is performed. Otherwise both sides are converted to an -int64_t and a signed arithmetic operation is performed. The -result is a boxed 64 bit cdata object.
    - -If one of the operands is an enum and the other operand is a -string, the string is converted to the value of a matching enum -constant before the above conversion.
    - -These rules ensure that 64 bit integers are "sticky". Any -expression involving at least one 64 bit integer operand results -in another one. The undefined cases for the division, modulo and power -operators return 2LL ^ 63 or -2ULL ^ 63.
    - -You'll have to explicitly convert a 64 bit integer to a Lua -number (e.g. for regular floating-point calculations) with -tonumber(). But note this may incur a precision loss.
  • - -
- -

Comparisons of cdata objects

-
    - -
  • Pointer comparison: two compatible cdata pointers/arrays -can be compared. The result is the same as an unsigned comparison of -their addresses. nil is treated like a NULL pointer, -which is compatible with any other pointer type.
  • - -
  • 64 bit integer comparison: two cdata numbers, or a -cdata number and a Lua number can be compared with each other. If one -of them is an uint64_t, the other side is converted to an -uint64_t and an unsigned comparison is performed. Otherwise -both sides are converted to an int64_t and a signed -comparison is performed.
    - -If one of the operands is an enum and the other operand is a -string, the string is converted to the value of a matching enum -constant before the above conversion.
    - -
  • Comparisons for equality/inequality never raise an error. -Even incompatible pointers can be compared for equality by address. Any -other incompatible comparison (also with non-cdata objects) treats the -two sides as unequal.
  • - -
- -

cdata objects as table keys

-

-Lua tables may be indexed by cdata objects, but this doesn't provide -any useful semantics — cdata objects are unsuitable as table -keys! -

-

-A cdata object is treated like any other garbage-collected object and -is hashed and compared by its address for table indexing. Since -there's no interning for cdata value types, the same value may be -boxed in different cdata objects with different addresses. Thus -t[1LL+1LL] and t[2LL] usually do not point to -the same hash slot and they certainly do not point to the same -hash slot as t[2]. -

-

-It would seriously drive up implementation complexity and slow down -the common case, if one were to add extra handling for by-value -hashing and comparisons to Lua tables. Given the ubiquity of their use -inside the VM, this is not acceptable. -

-

-There are three viable alternatives, if you really need to use cdata -objects as keys: -

-
    - -
  • If you can get by with the precision of Lua numbers -(52 bits), then use tonumber() on a cdata number or -combine multiple fields of a cdata aggregate to a Lua number. Then use -the resulting Lua number as a key when indexing tables.
    -One obvious benefit: t[tonumber(2LL)] does point to -the same slot as t[2].
  • - -
  • Otherwise use either tostring() on 64 bit integers -or complex numbers or combine multiple fields of a cdata aggregate to -a Lua string (e.g. with -ffi.string()). Then -use the resulting Lua string as a key when indexing tables.
  • - -
  • Create your own specialized hash table implementation using the -C types provided by the FFI library, just like you would in -C code. Ultimately this may give much better performance than the -other alternatives or what a generic by-value hash table could -possibly provide.
  • - -
- -

Parameterized Types

-

-To facilitate some abstractions, the two functions -ffi.typeof and -ffi.cdef support -parameterized types in C declarations. Note: none of the other API -functions taking a cdecl allow this. -

-

-Any place you can write a typedef name, an -identifier or a number in a declaration, you can write -$ (the dollar sign) instead. These placeholders are replaced in -order of appearance with the arguments following the cdecl string: -

-
--- Declare a struct with a parameterized field type and name:
-ffi.cdef([[
-typedef struct { $ $; } foo_t;
-]], type1, name1)
-
--- Anonymous struct with dynamic names:
-local bar_t = ffi.typeof("struct { int $, $; }", name1, name2)
--- Derived pointer type:
-local bar_ptr_t = ffi.typeof("$ *", bar_t)
-
--- Parameterized dimensions work even where a VLA won't work:
-local matrix_t = ffi.typeof("uint8_t[$][$]", width, height)
-
-

-Caveat: this is not simple text substitution! A passed ctype or -cdata object is treated like the underlying type, a passed string is -considered an identifier and a number is considered a number. You must -not mix this up: e.g. passing "int" as a string doesn't work in -place of a type, you'd need to use ffi.typeof("int") instead. -

-

-The main use for parameterized types are libraries implementing abstract -data types -(» example), -similar to what can be achieved with C++ template metaprogramming. -Another use case are derived types of anonymous structs, which avoids -pollution of the global struct namespace. -

-

-Please note that parameterized types are a nice tool and indispensable -for certain use cases. But you'll want to use them sparingly in regular -code, e.g. when all types are actually fixed. -

- -

Garbage Collection of cdata Objects

-

-All explicitly (ffi.new(), ffi.cast() etc.) or -implicitly (accessors) created cdata objects are garbage collected. -You need to ensure to retain valid references to cdata objects -somewhere on a Lua stack, an upvalue or in a Lua table while they are -still in use. Once the last reference to a cdata object is gone, the -garbage collector will automatically free the memory used by it (at -the end of the next GC cycle). -

-

-Please note that pointers themselves are cdata objects, however they -are not followed by the garbage collector. So e.g. if you -assign a cdata array to a pointer, you must keep the cdata object -holding the array alive as long as the pointer is still in use: -

-
-ffi.cdef[[
-typedef struct { int *a; } foo_t;
-]]
-
-local s = ffi.new("foo_t", ffi.new("int[10]")) -- WRONG!
-
-local a = ffi.new("int[10]") -- OK
-local s = ffi.new("foo_t", a)
--- Now do something with 's', but keep 'a' alive until you're done.
-
-

-Similar rules apply for Lua strings which are implicitly converted to -"const char *": the string object itself must be -referenced somewhere or it'll be garbage collected eventually. The -pointer will then point to stale data, which may have already been -overwritten. Note that string literals are automatically kept -alive as long as the function containing it (actually its prototype) -is not garbage collected. -

-

-Objects which are passed as an argument to an external C function -are kept alive until the call returns. So it's generally safe to -create temporary cdata objects in argument lists. This is a common -idiom for passing specific C types to -vararg functions. -

-

-Memory areas returned by C functions (e.g. from malloc()) -must be manually managed, of course (or use -ffi.gc()). Pointers to -cdata objects are indistinguishable from pointers returned by C -functions (which is one of the reasons why the GC cannot follow them). -

- -

Callbacks

-

-The LuaJIT FFI automatically generates special callback functions -whenever a Lua function is converted to a C function pointer. This -associates the generated callback function pointer with the C type -of the function pointer and the Lua function object (closure). -

-

-This can happen implicitly due to the usual conversions, e.g. when -passing a Lua function to a function pointer argument. Or you can use -ffi.cast() to explicitly cast a Lua function to a -C function pointer. -

-

-Currently only certain C function types can be used as callback -functions. Neither C vararg functions nor functions with -pass-by-value aggregate argument or result types are supported. There -are no restrictions for the kind of Lua functions that can be called -from the callback — no checks for the proper number of arguments -are made. The return value of the Lua function will be converted to the -result type and an error will be thrown for invalid conversions. -

-

-It's allowed to throw errors across a callback invocation, but it's not -advisable in general. Do this only if you know the C function, that -called the callback, copes with the forced stack unwinding and doesn't -leak resources. -

-

-One thing that's not allowed, is to let an FFI call into a C function -get JIT-compiled, which in turn calls a callback, calling into Lua again. -Usually this attempt is caught by the interpreter first and the -C function is blacklisted for compilation. -

-

-However, this heuristic may fail under specific circumstances: e.g. a -message polling function might not run Lua callbacks right away and the call -gets JIT-compiled. If it later happens to call back into Lua (e.g. a rarely -invoked error callback), you'll get a VM PANIC with the message -"bad callback". Then you'll need to manually turn off -JIT-compilation with -jit.off() for the -surrounding Lua function that invokes such a message polling function (or -similar). -

- -

Callback resource handling

-

-Callbacks take up resources — you can only have a limited number -of them at the same time (500 - 1000, depending on the -architecture). The associated Lua functions are anchored to prevent -garbage collection, too. -

-

-Callbacks due to implicit conversions are permanent! There is no -way to guess their lifetime, since the C side might store the -function pointer for later use (typical for GUI toolkits). The associated -resources cannot be reclaimed until termination: -

-
-ffi.cdef[[
-typedef int (__stdcall *WNDENUMPROC)(void *hwnd, intptr_t l);
-int EnumWindows(WNDENUMPROC func, intptr_t l);
-]]
-
--- Implicit conversion to a callback via function pointer argument.
-local count = 0
-ffi.C.EnumWindows(function(hwnd, l)
-  count = count + 1
-  return true
-end, 0)
--- The callback is permanent and its resources cannot be reclaimed!
--- Ok, so this may not be a problem, if you do this only once.
-
-

-Note: this example shows that you must properly declare -__stdcall callbacks on Windows/x86 systems. The calling -convention cannot be automatically detected, unlike for -__stdcall calls to Windows functions. -

-

-For some use cases it's necessary to free up the resources or to -dynamically redirect callbacks. Use an explicit cast to a -C function pointer and keep the resulting cdata object. Then use -the cb:free() -or cb:set() methods -on the cdata object: -

-
--- Explicitly convert to a callback via cast.
-local count = 0
-local cb = ffi.cast("WNDENUMPROC", function(hwnd, l)
-  count = count + 1
-  return true
-end)
-
--- Pass it to a C function.
-ffi.C.EnumWindows(cb, 0)
--- EnumWindows doesn't need the callback after it returns, so free it.
-
-cb:free()
--- The callback function pointer is no longer valid and its resources
--- will be reclaimed. The created Lua closure will be garbage collected.
-
- -

Callback performance

-

-Callbacks are slow! First, the C to Lua transition itself -has an unavoidable cost, similar to a lua_call() or -lua_pcall(). Argument and result marshalling add to that cost. -And finally, neither the C compiler nor LuaJIT can inline or -optimize across the language barrier and hoist repeated computations out -of a callback function. -

-

-Do not use callbacks for performance-sensitive work: e.g. consider a -numerical integration routine which takes a user-defined function to -integrate over. It's a bad idea to call a user-defined Lua function from -C code millions of times. The callback overhead will be absolutely -detrimental for performance. -

-

-It's considerably faster to write the numerical integration routine -itself in Lua — the JIT compiler will be able to inline the -user-defined function and optimize it together with its calling context, -with very competitive performance. -

-

-As a general guideline: use callbacks only when you must, because -of existing C APIs. E.g. callback performance is irrelevant for a -GUI application, which waits for user input most of the time, anyway. -

-

-For new designs avoid push-style APIs: a C function repeatedly -calling a callback for each result. Instead use pull-style APIs: -call a C function repeatedly to get a new result. Calls from Lua -to C via the FFI are much faster than the other way round. Most well-designed -libraries already use pull-style APIs (read/write, get/put). -

- -

C Library Namespaces

-

-A C library namespace is a special kind of object which allows -access to the symbols contained in shared libraries or the default -symbol namespace. The default -ffi.C namespace is -automatically created when the FFI library is loaded. C library -namespaces for specific shared libraries may be created with the -ffi.load() API -function. -

-

-Indexing a C library namespace object with a symbol name (a Lua -string) automatically binds it to the library. First the symbol type -is resolved — it must have been declared with -ffi.cdef. Then the -symbol address is resolved by searching for the symbol name in the -associated shared libraries or the default symbol namespace. Finally, -the resulting binding between the symbol name, the symbol type and its -address is cached. Missing symbol declarations or nonexistent symbol -names cause an error. -

-

-This is what happens on a read access for the different kinds of -symbols: -

-
    - -
  • External functions: a cdata object with the type of the function -and its address is returned.
  • - -
  • External variables: the symbol address is dereferenced and the -loaded value is converted to a Lua object -and returned.
  • - -
  • Constant values (static const or enum -constants): the constant is converted to a -Lua object and returned.
  • - -
-

-This is what happens on a write access: -

-
    - -
  • External variables: the value to be written is -converted to the C type of the -variable and then stored at the symbol address.
  • - -
  • Writing to constant variables or to any other symbol type causes -an error, like any other attempted write to a constant location.
  • - -
-

-C library namespaces themselves are garbage collected objects. If -the last reference to the namespace object is gone, the garbage -collector will eventually release the shared library reference and -remove all memory associated with the namespace. Since this may -trigger the removal of the shared library from the memory of the -running process, it's generally not safe to use function -cdata objects obtained from a library if the namespace object may be -unreferenced. -

-

-Performance notice: the JIT compiler specializes to the identity of -namespace objects and to the strings used to index it. This -effectively turns function cdata objects into constants. It's not -useful and actually counter-productive to explicitly cache these -function objects, e.g. local strlen = ffi.C.strlen. OTOH it -is useful to cache the namespace itself, e.g. local C = -ffi.C. -

- -

No Hand-holding!

-

-The FFI library has been designed as a low-level library. The -goal is to interface with C code and C data types with a -minimum of overhead. This means you can do anything you can do -from C: access all memory, overwrite anything in memory, call -machine code at any memory address and so on. -

-

-The FFI library provides no memory safety, unlike regular Lua -code. It will happily allow you to dereference a NULL -pointer, to access arrays out of bounds or to misdeclare -C functions. If you make a mistake, your application might crash, -just like equivalent C code would. -

-

-This behavior is inevitable, since the goal is to provide full -interoperability with C code. Adding extra safety measures, like -bounds checks, would be futile. There's no way to detect -misdeclarations of C functions, since shared libraries only -provide symbol names, but no type information. Likewise there's no way -to infer the valid range of indexes for a returned pointer. -

-

-Again: the FFI library is a low-level library. This implies it needs -to be used with care, but it's flexibility and performance often -outweigh this concern. If you're a C or C++ developer, it'll be easy -to apply your existing knowledge. OTOH writing code for the FFI -library is not for the faint of heart and probably shouldn't be the -first exercise for someone with little experience in Lua, C or C++. -

-

-As a corollary of the above, the FFI library is not safe for use by -untrusted Lua code. If you're sandboxing untrusted Lua code, you -definitely don't want to give this code access to the FFI library or -to any cdata object (except 64 bit integers or complex -numbers). Any properly engineered Lua sandbox needs to provide safety -wrappers for many of the standard Lua library functions — -similar wrappers need to be written for high-level operations on FFI -data types, too. -

- -

Current Status

-

-The initial release of the FFI library has some limitations and is -missing some features. Most of these will be fixed in future releases. -

-

-C language support is -currently incomplete: -

-
    -
  • C declarations are not passed through a C pre-processor, -yet.
  • -
  • The C parser is able to evaluate most constant expressions -commonly found in C header files. However it doesn't handle the -full range of C expression semantics and may fail for some -obscure constructs.
  • -
  • static const declarations only work for integer types -up to 32 bits. Neither declaring string constants nor -floating-point constants is supported.
  • -
  • Packed struct bitfields that cross container boundaries -are not implemented.
  • -
  • Native vector types may be defined with the GCC mode or -vector_size attribute. But no operations other than loading, -storing and initializing them are supported, yet.
  • -
  • The volatile type qualifier is currently ignored by -compiled code.
  • -
  • ffi.cdef silently -ignores most re-declarations. Note: avoid re-declarations which do not -conform to C99. The implementation will eventually be changed to -perform strict checks.
  • -
-

-The JIT compiler already handles a large subset of all FFI operations. -It automatically falls back to the interpreter for unimplemented -operations (you can check for this with the --jv command line option). -The following operations are currently not compiled and may exhibit -suboptimal performance, especially when used in inner loops: -

-
    -
  • Bitfield accesses and initializations.
  • -
  • Vector operations.
  • -
  • Table initializers.
  • -
  • Initialization of nested struct/union types.
  • -
  • Allocations of variable-length arrays or structs.
  • -
  • Allocations of C types with a size > 128 bytes or an -alignment > 8 bytes.
  • -
  • Conversions from lightuserdata to void *.
  • -
  • Pointer differences for element sizes that are not a power of -two.
  • -
  • Calls to C functions with aggregates passed or returned by -value.
  • -
  • Calls to ctype metamethods which are not plain functions.
  • -
  • ctype __newindex tables and non-string lookups in ctype -__index tables.
  • -
  • tostring() for cdata types.
  • -
  • Calls to ffi.cdef(), ffi.load() and -ffi.metatype().
  • -
-

-Other missing features: -

-
    -
  • Bit operations for 64 bit types.
  • -
  • Arithmetic for complex numbers.
  • -
  • Passing structs by value to vararg C functions.
  • -
  • C++ exception interoperability -does not extend to C functions called via the FFI, if the call is -compiled.
  • -
-
-
- - - diff --git a/source/libs/luajit/LuaJIT-2.0.3/doc/ext_ffi_tutorial.html b/source/libs/luajit/LuaJIT-2.0.3/doc/ext_ffi_tutorial.html deleted file mode 100644 index 01fb89929..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/doc/ext_ffi_tutorial.html +++ /dev/null @@ -1,601 +0,0 @@ - - - -FFI Tutorial - - - - - - - - - -
-Lua -
- - -
-

-This page is intended to give you an overview of the features of the FFI -library by presenting a few use cases and guidelines. -

-

-This page makes no attempt to explain all of the FFI library, though. -You'll want to have a look at the ffi.* API -function reference and the FFI -semantics to learn more. -

- -

Loading the FFI Library

-

-The FFI library is built into LuaJIT by default, but it's not loaded -and initialized by default. The suggested way to use the FFI library -is to add the following to the start of every Lua file that needs one -of its functions: -

-
-local ffi = require("ffi")
-
-

-Please note this doesn't define an ffi variable in the table -of globals — you really need to use the local variable. The -require function ensures the library is only loaded once. -

-

-Note: If you want to experiment with the FFI from the interactive prompt -of the command line executable, omit the local, as it doesn't -preserve local variables across lines. -

- -

Accessing Standard System Functions

-

-The following code explains how to access standard system functions. -We slowly print two lines of dots by sleeping for 10 milliseconds -after each dot: -

-
- 
-①
-
-
-
-
-
-②
-③
-④
-
-
-
-⑤
-
-
-
-
-
-⑥local ffi = require("ffi")
-ffi.cdef[[
-void Sleep(int ms);
-int poll(struct pollfd *fds, unsigned long nfds, int timeout);
-]]
-
-local sleep
-if ffi.os == "Windows" then
-  function sleep(s)
-    ffi.C.Sleep(s*1000)
-  end
-else
-  function sleep(s)
-    ffi.C.poll(nil, 0, s*1000)
-  end
-end
-
-for i=1,160 do
-  io.write("."); io.flush()
-  sleep(0.01)
-end
-io.write("\n")
-
-

-Here's the step-by-step explanation: -

-

- This defines the -C library functions we're going to use. The part inside the -double-brackets (in green) is just standard C syntax. You can -usually get this info from the C header files or the -documentation provided by each C library or C compiler. -

-

- The difficulty we're -facing here, is that there are different standards to choose from. -Windows has a simple Sleep() function. On other systems there -are a variety of functions available to achieve sub-second sleeps, but -with no clear consensus. Thankfully poll() can be used for -this task, too, and it's present on most non-Windows systems. The -check for ffi.os makes sure we use the Windows-specific -function only on Windows systems. -

-

- Here we're wrapping the -call to the C function in a Lua function. This isn't strictly -necessary, but it's helpful to deal with system-specific issues only -in one part of the code. The way we're wrapping it ensures the check -for the OS is only done during initialization and not for every call. -

-

- A more subtle point is -that we defined our sleep() function (for the sake of this -example) as taking the number of seconds, but accepting fractional -seconds. Multiplying this by 1000 gets us milliseconds, but that still -leaves it a Lua number, which is a floating-point value. Alas, the -Sleep() function only accepts an integer value. Luckily for -us, the FFI library automatically performs the conversion when calling -the function (truncating the FP value towards zero, like in C). -

-

-Some readers will notice that Sleep() is part of -KERNEL32.DLL and is also a stdcall function. So how -can this possibly work? The FFI library provides the ffi.C -default C library namespace, which allows calling functions from -the default set of libraries, like a C compiler would. Also, the -FFI library automatically detects stdcall functions, so you -don't need to declare them as such. -

-

- The poll() -function takes a couple more arguments we're not going to use. You can -simply use nil to pass a NULL pointer and 0 -for the nfds parameter. Please note that the -number 0 does not convert to a pointer value, -unlike in C++. You really have to pass pointers to pointer arguments -and numbers to number arguments. -

-

-The page on FFI semantics has all -of the gory details about -conversions between Lua -objects and C types. For the most part you don't have to deal -with this, as it's performed automatically and it's carefully designed -to bridge the semantic differences between Lua and C. -

-

- Now that we have defined -our own sleep() function, we can just call it from plain Lua -code. That wasn't so bad, huh? Turning these boring animated dots into -a fascinating best-selling game is left as an exercise for the reader. -:-) -

- -

Accessing the zlib Compression Library

-

-The following code shows how to access the zlib compression library from Lua code. -We'll define two convenience wrapper functions that take a string and -compress or uncompress it to another string: -

-
- 
-①
-
-
-
-
-
-
-②
-
-
-③
-
-④
-
-
-⑤
-
-
-⑥
-
-
-
-
-
-
-
-⑦local ffi = require("ffi")
-ffi.cdef[[
-unsigned long compressBound(unsigned long sourceLen);
-int compress2(uint8_t *dest, unsigned long *destLen,
-	      const uint8_t *source, unsigned long sourceLen, int level);
-int uncompress(uint8_t *dest, unsigned long *destLen,
-	       const uint8_t *source, unsigned long sourceLen);
-]]
-local zlib = ffi.load(ffi.os == "Windows" and "zlib1" or "z")
-
-local function compress(txt)
-  local n = zlib.compressBound(#txt)
-  local buf = ffi.new("uint8_t[?]", n)
-  local buflen = ffi.new("unsigned long[1]", n)
-  local res = zlib.compress2(buf, buflen, txt, #txt, 9)
-  assert(res == 0)
-  return ffi.string(buf, buflen[0])
-end
-
-local function uncompress(comp, n)
-  local buf = ffi.new("uint8_t[?]", n)
-  local buflen = ffi.new("unsigned long[1]", n)
-  local res = zlib.uncompress(buf, buflen, comp, #comp)
-  assert(res == 0)
-  return ffi.string(buf, buflen[0])
-end
-
--- Simple test code.
-local txt = string.rep("abcd", 1000)
-print("Uncompressed size: ", #txt)
-local c = compress(txt)
-print("Compressed size: ", #c)
-local txt2 = uncompress(c, #txt)
-assert(txt2 == txt)
-
-

-Here's the step-by-step explanation: -

-

- This defines some of the -C functions provided by zlib. For the sake of this example, some -type indirections have been reduced and it uses the pre-defined -fixed-size integer types, while still adhering to the zlib API/ABI. -

-

- This loads the zlib shared -library. On POSIX systems it's named libz.so and usually -comes pre-installed. Since ffi.load() automatically adds any -missing standard prefixes/suffixes, we can simply load the -"z" library. On Windows it's named zlib1.dll and -you'll have to download it first from the -» zlib site. The check for -ffi.os makes sure we pass the right name to -ffi.load(). -

-

- First, the maximum size of -the compression buffer is obtained by calling the -zlib.compressBound function with the length of the -uncompressed string. The next line allocates a byte buffer of this -size. The [?] in the type specification indicates a -variable-length array (VLA). The actual number of elements of this -array is given as the 2nd argument to ffi.new(). -

-

- This may look strange at -first, but have a look at the declaration of the compress2 -function from zlib: the destination length is defined as a pointer! -This is because you pass in the maximum buffer size and get back the -actual length that was used. -

-

-In C you'd pass in the address of a local variable -(&buflen). But since there's no address-of operator in -Lua, we'll just pass in a one-element array. Conveniently it can be -initialized with the maximum buffer size in one step. Calling the -actual zlib.compress2 function is then straightforward. -

-

- We want to return the -compressed data as a Lua string, so we'll use ffi.string(). -It needs a pointer to the start of the data and the actual length. The -length has been returned in the buflen array, so we'll just -get it from there. -

-

-Note that since the function returns now, the buf and -buflen variables will eventually be garbage collected. This -is fine, because ffi.string() has copied the contents to a -newly created (interned) Lua string. If you plan to call this function -lots of times, consider reusing the buffers and/or handing back the -results in buffers instead of strings. This will reduce the overhead -for garbage collection and string interning. -

-

- The uncompress -functions does the exact opposite of the compress function. -The compressed data doesn't include the size of the original string, -so this needs to be passed in. Otherwise no surprises here. -

-

- The code, that makes use -of the functions we just defined, is just plain Lua code. It doesn't -need to know anything about the LuaJIT FFI — the convenience -wrapper functions completely hide it. -

-

-One major advantage of the LuaJIT FFI is that you are now able to -write those wrappers in Lua. And at a fraction of the time it -would cost you to create an extra C module using the Lua/C API. -Many of the simpler C functions can probably be used directly -from your Lua code, without any wrappers. -

-

-Side note: the zlib API uses the long type for passing -lengths and sizes around. But all those zlib functions actually only -deal with 32 bit values. This is an unfortunate choice for a -public API, but may be explained by zlib's history — we'll just -have to deal with it. -

-

-First, you should know that a long is a 64 bit type e.g. -on POSIX/x64 systems, but a 32 bit type on Windows/x64 and on -32 bit systems. Thus a long result can be either a plain -Lua number or a boxed 64 bit integer cdata object, depending on -the target system. -

-

-Ok, so the ffi.* functions generally accept cdata objects -wherever you'd want to use a number. That's why we get a away with -passing n to ffi.string() above. But other Lua -library functions or modules don't know how to deal with this. So for -maximum portability one needs to use tonumber() on returned -long results before passing them on. Otherwise the -application might work on some systems, but would fail in a POSIX/x64 -environment. -

- -

Defining Metamethods for a C Type

-

-The following code explains how to define metamethods for a C type. -We define a simple point type and add some operations to it: -

-
- 
-①
-
-
-
-②
-
-③
-
-④
-
-
-
-⑤
-
-⑥local ffi = require("ffi")
-ffi.cdef[[
-typedef struct { double x, y; } point_t;
-]]
-
-local point
-local mt = {
-  __add = function(a, b) return point(a.x+b.x, a.y+b.y) end,
-  __len = function(a) return math.sqrt(a.x*a.x + a.y*a.y) end,
-  __index = {
-    area = function(a) return a.x*a.x + a.y*a.y end,
-  },
-}
-point = ffi.metatype("point_t", mt)
-
-local a = point(3, 4)
-print(a.x, a.y)  --> 3  4
-print(#a)        --> 5
-print(a:area())  --> 25
-local b = a + point(0.5, 8)
-print(#b)        --> 12.5
-
-

-Here's the step-by-step explanation: -

-

- This defines the C type for a -two-dimensional point object. -

-

- We have to declare the variable -holding the point constructor first, because it's used inside of a -metamethod. -

-

- Let's define an __add -metamethod which adds the coordinates of two points and creates a new -point object. For simplicity, this function assumes that both arguments -are points. But it could be any mix of objects, if at least one operand -is of the required type (e.g. adding a point plus a number or vice -versa). Our __len metamethod returns the distance of a point to -the origin. -

-

- If we run out of operators, we can -define named methods, too. Here the __index table defines an -area function. For custom indexing needs, one might want to -define __index and __newindex functions instead. -

-

- This associates the metamethods with -our C type. This only needs to be done once. For convenience, a -constructor is returned by -ffi.metatype(). -We're not required to use it, though. The original C type can still -be used e.g. to create an array of points. The metamethods automatically -apply to any and all uses of this type. -

-

-Please note that the association with a metatable is permanent and -the metatable must not be modified afterwards! Ditto for the -__index table. -

-

- Here are some simple usage examples -for the point type and their expected results. The pre-defined -operations (such as a.x) can be freely mixed with the newly -defined metamethods. Note that area is a method and must be -called with the Lua syntax for methods: a:area(), not -a.area(). -

-

-The C type metamethod mechanism is most useful when used in -conjunction with C libraries that are written in an object-oriented -style. Creators return a pointer to a new instance and methods take an -instance pointer as the first argument. Sometimes you can just point -__index to the library namespace and __gc to the -destructor and you're done. But often enough you'll want to add -convenience wrappers, e.g. to return actual Lua strings or when -returning multiple values. -

-

-Some C libraries only declare instance pointers as an opaque -void * type. In this case you can use a fake type for all -declarations, e.g. a pointer to a named (incomplete) struct will do: -typedef struct foo_type *foo_handle. The C side doesn't -know what you declare with the LuaJIT FFI, but as long as the underlying -types are compatible, everything still works. -

- -

Translating C Idioms

-

-Here's a list of common C idioms and their translation to the -LuaJIT FFI: -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IdiomC codeLua code
Pointer dereference
int *p;
x = *p;
*p = y;
x = p[0]
p[0] = y
Pointer indexing
int i, *p;
x = p[i];
p[i+1] = y;
x = p[i]
p[i+1] = y
Array indexing
int i, a[];
x = a[i];
a[i+1] = y;
x = a[i]
a[i+1] = y
struct/union dereference
struct foo s;
x = s.field;
s.field = y;
x = s.field
s.field = y
struct/union pointer deref.
struct foo *sp;
x = sp->field;
sp->field = y;
x = s.field
s.field = y
Pointer arithmetic
int i, *p;
x = p + i;
y = p - i;
x = p + i
y = p - i
Pointer difference
int *p1, *p2;
x = p1 - p2;x = p1 - p2
Array element pointer
int i, a[];
x = &a[i];x = a+i
Cast pointer to address
int *p;
x = (intptr_t)p;x = tonumber(
 ffi.cast("intptr_t",
          p))
Functions with outargs
void foo(int *inoutlen);
int len = x;
foo(&len);
y = len;
local len =
  ffi.new("int[1]", x)
foo(len)
y = len[0]
Vararg conversions
int printf(char *fmt, ...);
printf("%g", 1.0);
printf("%d", 1);
 
printf("%g", 1);
printf("%d",
  ffi.new("int", 1))
- -

To Cache or Not to Cache

-

-It's a common Lua idiom to cache library functions in local variables -or upvalues, e.g.: -

-
-local byte, char = string.byte, string.char
-local function foo(x)
-  return char(byte(x)+1)
-end
-
-

-This replaces several hash-table lookups with a (faster) direct use of -a local or an upvalue. This is less important with LuaJIT, since the -JIT compiler optimizes hash-table lookups a lot and is even able to -hoist most of them out of the inner loops. It can't eliminate -all of them, though, and it saves some typing for often-used -functions. So there's still a place for this, even with LuaJIT. -

-

-The situation is a bit different with C function calls via the -FFI library. The JIT compiler has special logic to eliminate all -of the lookup overhead for functions resolved from a -C library namespace! -Thus it's not helpful and actually counter-productive to cache -individual C functions like this: -

-
-local funca, funcb = ffi.C.funcb, ffi.C.funcb -- Not helpful!
-local function foo(x, n)
-  for i=1,n do funcb(funca(x, i), 1) end
-end
-
-

-This turns them into indirect calls and generates bigger and slower -machine code. Instead you'll want to cache the namespace itself and -rely on the JIT compiler to eliminate the lookups: -

-
-local C = ffi.C          -- Instead use this!
-local function foo(x, n)
-  for i=1,n do C.funcb(C.funca(x, i), 1) end
-end
-
-

-This generates both shorter and faster code. So don't cache -C functions, but do cache namespaces! Most often the -namespace is already in a local variable at an outer scope, e.g. from -local lib = ffi.load(...). Note that copying -it to a local variable in the function scope is unnecessary. -

-
-
- - - diff --git a/source/libs/luajit/LuaJIT-2.0.3/doc/ext_jit.html b/source/libs/luajit/LuaJIT-2.0.3/doc/ext_jit.html deleted file mode 100644 index 098be5e06..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/doc/ext_jit.html +++ /dev/null @@ -1,199 +0,0 @@ - - - -jit.* Library - - - - - - - - -
-Lua -
- - -
-

-The functions in this built-in module control the behavior of the JIT -compiler engine. Note that JIT-compilation is fully automatic — -you probably won't need to use any of the following functions unless -you have special needs. -

- -

jit.on()
-jit.off()

-

-Turns the whole JIT compiler on (default) or off. -

-

-These functions are typically used with the command line options --j on or -j off. -

- -

jit.flush()

-

-Flushes the whole cache of compiled code. -

- -

jit.on(func|true [,true|false])
-jit.off(func|true [,true|false])
-jit.flush(func|true [,true|false])

-

-jit.on enables JIT compilation for a Lua function (this is -the default). -

-

-jit.off disables JIT compilation for a Lua function and -flushes any already compiled code from the code cache. -

-

-jit.flush flushes the code, but doesn't affect the -enable/disable status. -

-

-The current function, i.e. the Lua function calling this library -function, can also be specified by passing true as the first -argument. -

-

-If the second argument is true, JIT compilation is also -enabled, disabled or flushed recursively for all sub-functions of a -function. With false only the sub-functions are affected. -

-

-The jit.on and jit.off functions only set a flag -which is checked when the function is about to be compiled. They do -not trigger immediate compilation. -

-

-Typical usage is jit.off(true, true) in the main chunk -of a module to turn off JIT compilation for the whole module for -debugging purposes. -

- -

jit.flush(tr)

-

-Flushes the root trace, specified by its number, and all of its side -traces from the cache. The code for the trace will be retained as long -as there are any other traces which link to it. -

- -

status, ... = jit.status()

-

-Returns the current status of the JIT compiler. The first result is -either true or false if the JIT compiler is turned -on or off. The remaining results are strings for CPU-specific features -and enabled optimizations. -

- -

jit.version

-

-Contains the LuaJIT version string. -

- -

jit.version_num

-

-Contains the version number of the LuaJIT core. Version xx.yy.zz -is represented by the decimal number xxyyzz. -

- -

jit.os

-

-Contains the target OS name: -"Windows", "Linux", "OSX", "BSD", "POSIX" or "Other". -

- -

jit.arch

-

-Contains the target architecture name: -"x86", "x64" or "ppcspe". -

- -

jit.opt.* — JIT compiler optimization control

-

-This sub-module provides the backend for the -O command line -option. -

-

-You can also use it programmatically, e.g.: -

-
-jit.opt.start(2) -- same as -O2
-jit.opt.start("-dce")
-jit.opt.start("hotloop=10", "hotexit=2")
-
-

-Unlike in LuaJIT 1.x, the module is built-in and -optimization is turned on by default! -It's no longer necessary to run require("jit.opt").start(), -which was one of the ways to enable optimization. -

- -

jit.util.* — JIT compiler introspection

-

-This sub-module holds functions to introspect the bytecode, generated -traces, the IR and the generated machine code. The functionality -provided by this module is still in flux and therefore undocumented. -

-

-The debug modules -jbc, -jv and -jdump make -extensive use of these functions. Please check out their source code, -if you want to know more. -

-
-
- - - diff --git a/source/libs/luajit/LuaJIT-2.0.3/doc/extensions.html b/source/libs/luajit/LuaJIT-2.0.3/doc/extensions.html deleted file mode 100644 index 20b597f13..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/doc/extensions.html +++ /dev/null @@ -1,408 +0,0 @@ - - - -Extensions - - - - - - - - - -
-Lua -
- - -
-

-LuaJIT is fully upwards-compatible with Lua 5.1. It supports all -» standard Lua -library functions and the full set of -» Lua/C API -functions. -

-

-LuaJIT is also fully ABI-compatible to Lua 5.1 at the linker/dynamic -loader level. This means you can compile a C module against the -standard Lua headers and load the same shared library from either Lua -or LuaJIT. -

-

-LuaJIT extends the standard Lua VM with new functionality and adds -several extension modules. Please note this page is only about -functional enhancements and not about performance enhancements, -such as the optimized VM, the faster interpreter or the JIT compiler. -

- -

Extensions Modules

-

-LuaJIT comes with several built-in extension modules: -

- -

bit.* — Bitwise operations

-

-LuaJIT supports all bitwise operations as defined by -» Lua BitOp: -

-
-bit.tobit  bit.tohex  bit.bnot    bit.band bit.bor  bit.bxor
-bit.lshift bit.rshift bit.arshift bit.rol  bit.ror  bit.bswap
-
-

-This module is a LuaJIT built-in — you don't need to download or -install Lua BitOp. The Lua BitOp site has full documentation for all -» Lua BitOp API functions. -

-

-Please make sure to require the module before using any of -its functions: -

-
-local bit = require("bit")
-
-

-An already installed Lua BitOp module is ignored by LuaJIT. -This way you can use bit operations from both Lua and LuaJIT on a -shared installation. -

- -

ffi.* — FFI library

-

-The FFI library allows calling external -C functions and the use of C data structures from pure Lua -code. -

- -

jit.* — JIT compiler control

-

-The functions in this module -control the behavior of the JIT compiler engine. -

- -

C API extensions

-

-LuaJIT adds some -extra functions to the Lua/C API. -

- -

Enhanced Standard Library Functions

- -

xpcall(f, err [,args...]) passes arguments

-

-Unlike the standard implementation in Lua 5.1, xpcall() -passes any arguments after the error function to the function -which is called in a protected context. -

- -

loadfile() etc. handle UTF-8 source code

-

-Non-ASCII characters are handled transparently by the Lua source code parser. -This allows the use of UTF-8 characters in identifiers and strings. -A UTF-8 BOM is skipped at the start of the source code. -

- -

tostring() etc. canonicalize NaN and ±Inf

-

-All number-to-string conversions consistently convert non-finite numbers -to the same strings on all platforms. NaN results in "nan", -positive infinity results in "inf" and negative infinity results -in "-inf". -

- -

tonumber() etc. use builtin string to number conversion

-

-All string-to-number conversions consistently convert integer and -floating-point inputs in decimal and hexadecimal on all platforms. -strtod() is not used anymore, which avoids numerous -problems with poor C library implementations. The builtin conversion -function provides full precision according to the IEEE-754 standard, it -works independently of the current locale and it supports hex floating-point -numbers (e.g. 0x1.5p-3). -

- -

string.dump(f [,strip]) generates portable bytecode

-

-An extra argument has been added to string.dump(). If set to -true, 'stripped' bytecode without debug information is -generated. This speeds up later bytecode loading and reduces memory -usage. See also the --b command line option. -

-

-The generated bytecode is portable and can be loaded on any architecture -that LuaJIT supports, independent of word size or endianess. However the -bytecode compatibility versions must match. Bytecode stays compatible -for dot releases (x.y.0 → x.y.1), but may change with major or -minor releases (2.0 → 2.1) or between any beta release. Foreign -bytecode (e.g. from Lua 5.1) is incompatible and cannot be loaded. -

- -

Enhanced PRNG for math.random()

-

-LuaJIT uses a Tausworthe PRNG with period 2^223 to implement -math.random() and math.randomseed(). The quality of -the PRNG results is much superior compared to the standard Lua -implementation which uses the platform-specific ANSI rand(). -

-

-The PRNG generates the same sequences from the same seeds on all -platforms and makes use of all bits in the seed argument. -math.random() without arguments generates 52 pseudo-random bits -for every call. The result is uniformly distributed between 0.0 and 1.0. -It's correctly scaled up and rounded for math.random(n [,m]) to -preserve uniformity. -

- -

io.* functions handle 64 bit file offsets

-

-The file I/O functions in the standard io.* library handle -64 bit file offsets. In particular this means it's possible -to open files larger than 2 Gigabytes and to reposition or obtain -the current file position for offsets beyond 2 GB -(fp:seek() method). -

- -

debug.* functions identify metamethods

-

-debug.getinfo() and lua_getinfo() also return information -about invoked metamethods. The namewhat field is set to -"metamethod" and the name field has the name of -the corresponding metamethod (e.g. "__index"). -

- -

Fully Resumable VM

-

-The LuaJIT VM is fully resumable. This means you can yield from a -coroutine even across contexts, where this would not possible with -the standard Lua 5.1 VM: e.g. you can yield across pcall() -and xpcall(), across iterators and across metamethods. -

- -

Extensions from Lua 5.2

-

-LuaJIT supports some language and library extensions from Lua 5.2. -Features that are unlikely to break existing code are unconditionally -enabled: -

-
    -
  • goto and ::labels::.
  • -
  • Hex escapes '\x3F' and '\*' escape in strings.
  • -
  • load(string|reader [, chunkname [,mode [,env]]]).
  • -
  • loadstring() is an alias for load().
  • -
  • loadfile(filename [,mode [,env]]).
  • -
  • math.log(x [,base]). -
  • string.rep(s, n [,sep]). -
  • string.format(): %q reversible. -%s checks __tostring. -%a and "%A added.
  • -
  • String matching pattern %g added.
  • -
  • io.read("*L").
  • -
  • io.lines() and file:lines() process -io.read() options.
  • -
  • os.exit(status|true|false [,close]).
  • -
  • package.searchpath(name, path [, sep [, rep]]).
  • -
  • package.loadlib(name, "*").
  • -
  • debug.getinfo() returns nparams and isvararg -for option "u".
  • -
  • debug.getlocal() accepts function instead of level.
  • -
  • debug.getlocal() and debug.setlocal() accept negative -indexes for varargs.
  • -
  • debug.getupvalue() and debug.setupvalue() handle -C functions.
  • -
  • debug.upvalueid() and debug.upvaluejoin().
  • -
  • Command line option -E.
  • -
  • Command line checks __tostring for errors.
  • -
-

-Other features are only enabled, if LuaJIT is built with --DLUAJIT_ENABLE_LUA52COMPAT: -

-
    -
  • goto is a keyword and not a valid variable name anymore.
  • -
  • break can be placed anywhere. Empty statements (;;) -are allowed.
  • -
  • __lt, __le are invoked for mixed types.
  • -
  • __len for tables. rawlen() library function.
  • -
  • pairs() and ipairs() check for __pairs and -__ipairs.
  • -
  • coroutine.running() returns two results.
  • -
  • table.pack() and table.unpack() -(same as unpack()).
  • -
  • io.write() and file:write() return file handle -instead of true.
  • -
  • os.execute() and pipe:close() return detailed -exit status.
  • -
  • debug.setmetatable() returns object.
  • -
  • debug.getuservalue() and debug.setuservalue().
  • -
  • Remove math.mod(), string.gfind(). -
-

-Note: this provides only partial compatibility with Lua 5.2 at the -language and Lua library level. LuaJIT is API+ABI-compatible with -Lua 5.1, which prevents implementing features that would otherwise -break the Lua/C API and ABI (e.g. _ENV). -

- -

C++ Exception Interoperability

-

-LuaJIT has built-in support for interoperating with C++ exceptions. -The available range of features depends on the target platform and -the toolchain used to compile LuaJIT: -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PlatformCompilerInteroperability
POSIX/x64, DWARF2 unwindingGCC 4.3+Full
Other platforms, DWARF2 unwindingGCCLimited
Windows/x64MSVC or WinSDKFull
Windows/x86AnyNo
Other platformsOther compilersNo
-

-Full interoperability means: -

-
    -
  • C++ exceptions can be caught on the Lua side with pcall(), -lua_pcall() etc.
  • -
  • C++ exceptions will be converted to the generic Lua error -"C++ exception", unless you use the -C call wrapper feature.
  • -
  • It's safe to throw C++ exceptions across non-protected Lua frames -on the C stack. The contents of the C++ exception object -pass through unmodified.
  • -
  • Lua errors can be caught on the C++ side with catch(...). -The corresponding Lua error message can be retrieved from the Lua stack.
  • -
  • Throwing Lua errors across C++ frames is safe. C++ destructors -will be called.
  • -
-

-Limited interoperability means: -

-
    -
  • C++ exceptions can be caught on the Lua side with pcall(), -lua_pcall() etc.
  • -
  • C++ exceptions will be converted to the generic Lua error -"C++ exception", unless you use the -C call wrapper feature.
  • -
  • C++ exceptions will be caught by non-protected Lua frames and -are rethrown as a generic Lua error. The C++ exception object will -be destroyed.
  • -
  • Lua errors cannot be caught on the C++ side.
  • -
  • Throwing Lua errors across C++ frames will not call -C++ destructors.
  • -
- -

-No interoperability means: -

-
    -
  • It's not safe to throw C++ exceptions across Lua frames.
  • -
  • C++ exceptions cannot be caught on the Lua side.
  • -
  • Lua errors cannot be caught on the C++ side.
  • -
  • Throwing Lua errors across C++ frames will not call -C++ destructors.
  • -
  • Additionally, on Windows/x86 with SEH-based C++ exceptions: -it's not safe to throw a Lua error across any frames containing -a C++ function with any try/catch construct or using variables with -(implicit) destructors. This also applies to any functions which may be -inlined in such a function. It doesn't matter whether lua_error() -is called inside or outside of a try/catch or whether any object actually -needs to be destroyed: the SEH chain is corrupted and this will eventually -lead to the termination of the process.
  • -
-
-
- - - diff --git a/source/libs/luajit/LuaJIT-2.0.3/doc/faq.html b/source/libs/luajit/LuaJIT-2.0.3/doc/faq.html deleted file mode 100644 index ffc2ae899..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/doc/faq.html +++ /dev/null @@ -1,184 +0,0 @@ - - - -Frequently Asked Questions (FAQ) - - - - - - - - - -
-Lua -
- - -
-
-
Q: Where can I learn more about LuaJIT and Lua?
-
- -
- -
-
Q: Where can I learn more about the compiler technology used by LuaJIT?
-
-I'm planning to write more documentation about the internals of LuaJIT. -In the meantime, please use the following Google Scholar searches -to find relevant papers:
-Search for: » Trace Compiler
-Search for: » JIT Compiler
-Search for: » Dynamic Language Optimizations
-Search for: » SSA Form
-Search for: » Linear Scan Register Allocation
-Here is a list of the » innovative features in LuaJIT.
-And, you know, reading the source is of course the only way to enlightenment. :-) -
-
- -
-
Q: Why do I get this error: "attempt to index global 'arg' (a nil value)"?
-Q: My vararg functions fail after switching to LuaJIT!
-
LuaJIT is compatible to the Lua 5.1 language standard. It doesn't -support the implicit arg parameter for old-style vararg -functions from Lua 5.0.
Please convert your code to the -» Lua 5.1 -vararg syntax.
-
- -
-
Q: Why do I get this error: "bad FPU precision"?
-
Q: I get weird behavior after initializing Direct3D.
-
Q: Some FPU operations crash after I load a Delphi DLL.
-
-
- -DirectX/Direct3D (up to version 9) sets the x87 FPU to single-precision -mode by default. This violates the Windows ABI and interferes with the -operation of many programs — LuaJIT is affected, too. Please make -sure you always use the D3DCREATE_FPU_PRESERVE flag when -initializing Direct3D.
- -Direct3D version 10 or higher do not show this behavior anymore. -Consider testing your application with older versions, too.
- -Similarly, the Borland/Delphi runtime modifies the FPU control word and -enables FP exceptions. Of course this violates the Windows ABI, too. -Please check the Delphi docs for the Set8087CW method. - -
- -
-
Q: Sometimes Ctrl-C fails to stop my Lua program. Why?
-
The interrupt signal handler sets a Lua debug hook. But this is -currently ignored by compiled code (this will eventually be fixed). If -your program is running in a tight loop and never falls back to the -interpreter, the debug hook never runs and can't throw the -"interrupted!" error.
In the meantime you have to press Ctrl-C -twice to get stop your program. That's similar to when it's stuck -running inside a C function under the Lua interpreter.
-
- -
-
Q: Why doesn't my favorite power-patch for Lua apply against LuaJIT?
-
Because it's a completely redesigned VM and has very little code -in common with Lua anymore. Also, if the patch introduces changes to -the Lua semantics, these would need to be reflected everywhere in the -VM, from the interpreter up to all stages of the compiler.
Please -use only standard Lua language constructs. For many common needs you -can use source transformations or use wrapper or proxy functions. -The compiler will happily optimize away such indirections.
-
- -
-
Q: Lua runs everywhere. Why doesn't LuaJIT support my CPU?
-
Because it's a compiler — it needs to generate native -machine code. This means the code generator must be ported to each -architecture. And the fast interpreter is written in assembler and -must be ported, too. This is quite an undertaking.
-The install documentation shows the supported -architectures. Other architectures will follow based on sufficient user -demand and/or sponsoring.
-
- -
-
Q: When will feature X be added? When will the next version be released?
-
When it's ready.
-C'mon, it's open source — I'm doing it on my own time and you're -getting it for free. You can either contribute a patch or sponsor -the development of certain features, if they are important to you. -
-
-
-
- - - diff --git a/source/libs/luajit/LuaJIT-2.0.3/doc/install.html b/source/libs/luajit/LuaJIT-2.0.3/doc/install.html deleted file mode 100644 index 2388ff338..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/doc/install.html +++ /dev/null @@ -1,631 +0,0 @@ - - - -Installation - - - - - - - - - -
-Lua -
- - -
-

-LuaJIT is only distributed as a source package. This page explains -how to build and install LuaJIT with different operating systems -and C compilers. -

-

-For the impatient (on POSIX systems): -

-
-make && sudo make install
-
-

-LuaJIT currently builds out-of-the box on most systems. -Here's the compatibility matrix for the supported combinations of -operating systems, CPUs and compilers: -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CPU / OSLinux or
Android
*BSD, OtherOSX 10.4+ or
iOS 3.0+
Windows
XP/Vista/7
x86 (32 bit)GCC 4.x
GCC 3.4
GCC 4.x
GCC 3.4
GCC 4.x
GCC 3.4
MSVC, MSVC/EE
WinSDK
MinGW, Cygwin
x64 (64 bit)GCC 4.xORBIS (PS4)GCC 4.xMSVC + SDK v7.0
WinSDK v7.0
ARMv5+
ARM9E+
GCC 4.2+GCC 4.2+GCC 4.2+ 
PPCGCC 4.3+GCC 4.3+
GCC 4.1 (PS3)
 XEDK (Xbox 360)
PPC/e500v2GCC 4.3+GCC 4.3+  
MIPSGCC 4.3+GCC 4.3+  
- -

Configuring LuaJIT

-

-The standard configuration should work fine for most installations. -Usually there is no need to tweak the settings. The following files -hold all user-configurable settings: -

-
    -
  • src/luaconf.h sets some configuration variables.
  • -
  • Makefile has settings for installing LuaJIT (POSIX -only).
  • -
  • src/Makefile has settings for compiling LuaJIT -under POSIX, MinGW or Cygwin.
  • -
  • src/msvcbuild.bat has settings for compiling LuaJIT with -MSVC or WinSDK.
  • -
-

-Please read the instructions given in these files, before changing -any settings. -

- -

POSIX Systems (Linux, OSX, *BSD etc.)

-

Prerequisites

-

-Depending on your distribution, you may need to install a package for -GCC, the development headers and/or a complete SDK. E.g. on a current -Debian/Ubuntu, install libc6-dev with the package manager. -

-

-Download the current source package of LuaJIT (pick the .tar.gz), -if you haven't already done so. Move it to a directory of your choice, -open a terminal window and change to this directory. Now unpack the archive -and change to the newly created directory: -

-
-tar zxf LuaJIT-2.0.3.tar.gz
-cd LuaJIT-2.0.3
-

Building LuaJIT

-

-The supplied Makefiles try to auto-detect the settings needed for your -operating system and your compiler. They need to be run with GNU Make, -which is probably the default on your system, anyway. Simply run: -

-
-make
-
-

-This always builds a native x86, x64 or PPC binary, depending on the host OS -you're running this command on. Check the section on -cross-compilation for more options. -

-

-By default, modules are only searched under the prefix /usr/local. -You can add an extra prefix to the search paths by appending the -PREFIX option, e.g.: -

-
-make PREFIX=/home/myself/lj2
-
-

-Note for OSX: if the MACOSX_DEPLOYMENT_TARGET environment -variable is not set, then it's forced to 10.4. -

-

Installing LuaJIT

-

-The top-level Makefile installs LuaJIT by default under -/usr/local, i.e. the executable ends up in -/usr/local/bin and so on. You need root privileges -to write to this path. So, assuming sudo is installed on your system, -run the following command and enter your sudo password: -

-
-sudo make install
-
-

-Otherwise specify the directory prefix as an absolute path, e.g.: -

-
-make install PREFIX=/home/myself/lj2
-
-

-Obviously the prefixes given during build and installation need to be the same. -

- -

Windows Systems

-

Prerequisites

-

-Either install one of the open source SDKs -(» MinGW or -» Cygwin), which come with a modified -GCC plus the required development headers. -

-

-Or install Microsoft's Visual C++ (MSVC). The freely downloadable -» Express Edition -works just fine, but only contains an x86 compiler. -

-

-The freely downloadable -» Windows SDK -only comes with command line tools, but this is all you need to build LuaJIT. -It contains x86 and x64 compilers. -

-

-Next, download the source package and unpack it using an archive manager -(e.g. the Windows Explorer) to a directory of your choice. -

-

Building with MSVC

-

-Open a "Visual Studio .NET Command Prompt", cd to the -directory where you've unpacked the sources and run these commands: -

-
-cd src
-msvcbuild
-
-

-Then follow the installation instructions below. -

-

Building with the Windows SDK

-

-Open a "Windows SDK Command Shell" and select the x86 compiler: -

-
-setenv /release /x86
-
-

-Or select the x64 compiler: -

-
-setenv /release /x64
-
-

-Then cd to the directory where you've unpacked the sources -and run these commands: -

-
-cd src
-msvcbuild
-
-

-Then follow the installation instructions below. -

-

Building with MinGW or Cygwin

-

-Open a command prompt window and make sure the MinGW or Cygwin programs -are in your path. Then cd to the directory where -you've unpacked the sources and run this command for MinGW: -

-
-mingw32-make
-
-

-Or this command for Cygwin: -

-
-make
-
-

-Then follow the installation instructions below. -

-

Installing LuaJIT

-

-Copy luajit.exe and lua51.dll (built in the src -directory) to a newly created directory (any location is ok). -Add lua and lua\jit directories below it and copy -all Lua files from the src\jit directory of the distribution -to the latter directory. -

-

-There are no hardcoded -absolute path names — all modules are loaded relative to the -directory where luajit.exe is installed -(see src/luaconf.h). -

- -

Cross-compiling LuaJIT

-

-The GNU Makefile-based build system allows cross-compiling on any host -for any supported target, as long as both architectures have the same -pointer size. If you want to cross-compile to any 32 bit target on an -x64 OS, you need to install the multilib development package (e.g. -libc6-dev-i386 on Debian/Ubuntu) and build a 32 bit host part -(HOST_CC="gcc -m32"). -

-

-You need to specify TARGET_SYS whenever the host OS and the -target OS differ, or you'll get assembler or linker errors. E.g. if -you're compiling on a Windows or OSX host for embedded Linux or Android, -you need to add TARGET_SYS=Linux to the examples below. For a -minimal target OS, you may need to disable the built-in allocator in -src/Makefile and use TARGET_SYS=Other. The examples -below only show some popular targets — please check the comments -in src/Makefile for more details. -

-
-# Cross-compile to a 32 bit binary on a multilib x64 OS
-make CC="gcc -m32"
-
-# Cross-compile on Debian/Ubuntu for Windows (mingw32 package)
-make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows
-
-

-The CROSS prefix allows specifying a standard GNU cross-compile -toolchain (Binutils, GCC and a matching libc). The prefix may vary -depending on the --target the toolchain was built for (note the -CROSS prefix has a trailing "-"). The examples below -use the canonical toolchain triplets for Linux. -

-

-Since there's often no easy way to detect CPU features at runtime, it's -important to compile with the proper CPU or architecture settings. You -can specify these when building the toolchain yourself. Or add --mcpu=... or -march=... to TARGET_CFLAGS. For -ARM it's important to have the correct -mfloat-abi=... setting, -too. Otherwise LuaJIT may not run at the full performance of your target -CPU. -

-
-# ARM soft-float
-make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
-     TARGET_CFLAGS="-mfloat-abi=soft"
-
-# ARM soft-float ABI with VFP (example for Cortex-A8)
-make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
-     TARGET_CFLAGS="-mcpu=cortex-a8 -mfloat-abi=softfp"
-
-# ARM hard-float ABI with VFP (armhf, requires recent toolchain)
-make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabihf-
-
-# PPC
-make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu-
-# PPC/e500v2 (fast interpreter only)
-make HOST_CC="gcc -m32" CROSS=powerpc-e500v2-linux-gnuspe-
-
-# MIPS big-endian
-make HOST_CC="gcc -m32" CROSS=mips-linux-
-# MIPS little-endian
-make HOST_CC="gcc -m32" CROSS=mipsel-linux-
-
-

-You can cross-compile for Android using the » Android NDK. -The environment variables need to match the install locations and the -desired target platform. E.g. Android 4.0 corresponds to ABI level 14. -For details check the folder docs in the NDK directory. -

-

-Only a few common variations for the different CPUs, ABIs and platforms -are listed. Please use your own judgement for which combination you want -to build/deploy or which lowest common denominator you want to pick: -

-
-# Android/ARM, armeabi (ARMv5TE soft-float), Android 2.2+ (Froyo)
-NDK=/opt/android/ndk
-NDKABI=8
-NDKVER=$NDK/toolchains/arm-linux-androideabi-4.6
-NDKP=$NDKVER/prebuilt/linux-x86/bin/arm-linux-androideabi-
-NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm"
-make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF"
-
-# Android/ARM, armeabi-v7a (ARMv7 VFP), Android 4.0+ (ICS)
-NDK=/opt/android/ndk
-NDKABI=14
-NDKVER=$NDK/toolchains/arm-linux-androideabi-4.6
-NDKP=$NDKVER/prebuilt/linux-x86/bin/arm-linux-androideabi-
-NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm"
-NDKARCH="-march=armv7-a -mfloat-abi=softfp -Wl,--fix-cortex-a8"
-make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF $NDKARCH"
-
-# Android/MIPS, mips (MIPS32R1 hard-float), Android 4.0+ (ICS)
-NDK=/opt/android/ndk
-NDKABI=14
-NDKVER=$NDK/toolchains/mipsel-linux-android-4.6
-NDKP=$NDKVER/prebuilt/linux-x86/bin/mipsel-linux-android-
-NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-mips"
-make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF"
-
-# Android/x86, x86 (i686 SSE3), Android 4.0+ (ICS)
-NDK=/opt/android/ndk
-NDKABI=14
-NDKVER=$NDK/toolchains/x86-4.6
-NDKP=$NDKVER/prebuilt/linux-x86/bin/i686-linux-android-
-NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-x86"
-make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF"
-
-

-You can cross-compile for iOS 3.0+ (iPhone/iPad) using the » iOS SDK. -The environment variables need to match the iOS SDK version: -

-

-Note: the JIT compiler is disabled for iOS, because regular iOS Apps -are not allowed to generate code at runtime. You'll only get the performance -of the LuaJIT interpreter on iOS. This is still faster than plain Lua, but -much slower than the JIT compiler. Please complain to Apple, not me. -Or use Android. :-p -

-
-IXCODE=`xcode-select -print-path`
-ISDK=$IXCODE/Platforms/iPhoneOS.platform/Developer
-ISDKVER=iPhoneOS6.0.sdk
-ISDKP=$ISDK/usr/bin/
-ISDKF="-arch armv7 -isysroot $ISDK/SDKs/$ISDKVER"
-make HOST_CC="gcc -m32 -arch i386" CROSS=$ISDKP TARGET_FLAGS="$ISDKF" \
-     TARGET_SYS=iOS
-
-

-You can cross-compile for PS3 using the PS3 SDK from -a Linux host or a Windows host (requires 32 bit MinGW (GCC) on the host, -too). Due to restrictions on consoles, the JIT compiler is disabled and -only the fast interpreter is built: -

-
-make HOST_CC="gcc -m32" CROSS=ppu-lv2-
-
-

-You can cross-compile for PS4 from a Windows host using -the PS4 SDK (ORBIS) plus 64 bit MSVC. Due to restrictions on -consoles, the JIT compiler is disabled and only the fast interpreter -is built. -

-

-Open a "Visual Studio .NET Command Prompt" (64 bit host compiler), -cd to the directory where you've unpacked the sources and run -the following commands. This builds a static library libluajit.a, -which can be linked against your game, just like the Lua library. -

-
-cd src
-ps4build
-
-

-You can cross-compile for Xbox 360 using the -Xbox 360 SDK (MSVC + XEDK). Due to restrictions on consoles, the -JIT compiler is disabled and only the fast interpreter is built. -

-

-Open a "Visual Studio .NET Command Prompt" (32 bit host compiler), -cd to the directory where you've unpacked the sources and run -the following commands. This builds a static library luajit20.lib, -which can be linked against your game, just like the Lua library. -

-
-cd src
-xedkbuild
-
- -

Embedding LuaJIT

-

-LuaJIT is API-compatible with Lua 5.1. If you've already embedded Lua -into your application, you probably don't need to do anything to switch -to LuaJIT, except link with a different library: -

-
    -
  • It's strongly suggested to build LuaJIT separately using the supplied -build system. Please do not attempt to integrate the individual -source files into your build tree. You'll most likely get the internal build -dependencies wrong or mess up the compiler flags. Treat LuaJIT like any -other external library and link your application with either the dynamic -or static library, depending on your needs.
  • -
  • If you want to load C modules compiled for plain Lua -with require(), you need to make sure the public symbols -(e.g. lua_pushnumber) are exported, too: -
    • On POSIX systems you can either link to the shared library -or link the static library into your application. In the latter case -you'll need to export all public symbols from your main executable -(e.g. -Wl,-E on Linux) and add the external dependencies -(e.g. -lm -ldl on Linux).
    • -
    • Since Windows symbols are bound to a specific DLL name, you need to -link to the lua51.dll created by the LuaJIT build (do not rename -the DLL). You may link LuaJIT statically on Windows only if you don't -intend to load Lua/C modules at runtime. -
    -
  • -
  • -If you're building a 64 bit application on OSX which links directly or -indirectly against LuaJIT, you need to link your main executable -with these flags: -
    --pagezero_size 10000 -image_base 100000000
    -
    -Also, it's recommended to rebase all (self-compiled) shared libraries -which are loaded at runtime on OSX/x64 (e.g. C extension modules for Lua). -See: man rebase -
  • -
-

Additional hints for initializing LuaJIT using the C API functions:

-
    -
  • Here's a -» simple example -for embedding Lua or LuaJIT into your application.
  • -
  • Make sure you use luaL_newstate. Avoid using -lua_newstate, since this uses the (slower) default memory -allocator from your system (no support for this on x64).
  • -
  • Make sure you use luaL_openlibs and not the old Lua 5.0 style -of calling luaopen_base etc. directly.
  • -
  • To change or extend the list of standard libraries to load, copy -src/lib_init.c to your project and modify it accordingly. -Make sure the jit library is loaded or the JIT compiler -will not be activated.
  • -
  • The bit.* module for bitwise operations -is already built-in. There's no need to statically link -» Lua BitOp to your application.
  • -
- -

Hints for Distribution Maintainers

-

-The LuaJIT build system has extra provisions for the needs of most -POSIX-based distributions. If you're a package maintainer for -a distribution, please make use of these features and -avoid patching, subverting, autotoolizing or messing up the build system -in unspeakable ways. -

-

-There should be absolutely no need to patch luaconf.h or any -of the Makefiles. And please do not hand-pick files for your packages — -simply use whatever make install creates. There's a reason -for all of the files and directories it creates. -

-

-The build system uses GNU make and auto-detects most settings based on -the host you're building it on. This should work fine for native builds, -even when sandboxed. You may need to pass some of the following flags to -both the make and the make install command lines -for a regular distribution build: -

-
    -
  • PREFIX overrides the installation path and should usually -be set to /usr. Setting this also changes the module paths and -the paths needed to locate the shared library.
  • -
  • DESTDIR is an absolute path which allows you to install -to a shadow tree instead of the root tree of the build system.
  • -
  • MULTILIB sets the architecture-specific library path component -for multilib systems. The default is lib.
  • -
  • Have a look at the top-level Makefile and src/Makefile -for additional variables to tweak. The following variables may be -overridden, but it's not recommended, except for special needs -like cross-builds: -BUILDMODE, CC, HOST_CC, STATIC_CC, DYNAMIC_CC, CFLAGS, HOST_CFLAGS, -TARGET_CFLAGS, LDFLAGS, HOST_LDFLAGS, TARGET_LDFLAGS, TARGET_SHLDFLAGS, -TARGET_FLAGS, LIBS, HOST_LIBS, TARGET_LIBS, CROSS, HOST_SYS, TARGET_SYS -
  • -
-

-The build system has a special target for an amalgamated build, i.e. -make amalg. This compiles the LuaJIT core as one huge C file -and allows GCC to generate faster and shorter code. Alas, this requires -lots of memory during the build. This may be a problem for some users, -that's why it's not enabled by default. But it shouldn't be a problem for -most build farms. It's recommended that binary distributions use this -target for their LuaJIT builds. -

-

-The tl;dr version of the above: -

-
-make amalg PREFIX=/usr && \
-make install PREFIX=/usr DESTDIR=/tmp/buildroot
-
-

-Finally, if you encounter any difficulties, please -contact me first, instead of releasing a broken -package onto unsuspecting users. Because they'll usually gonna complain -to me (the upstream) and not you (the package maintainer), anyway. -

-
-
- - - diff --git a/source/libs/luajit/LuaJIT-2.0.3/doc/luajit.html b/source/libs/luajit/LuaJIT-2.0.3/doc/luajit.html deleted file mode 100644 index 43af69c92..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/doc/luajit.html +++ /dev/null @@ -1,228 +0,0 @@ - - - -LuaJIT - - - - - - - - - - -
-Lua -
- - -
-

-LuaJIT is a Just-In-Time Compiler (JIT) for the -» Lua programming language. -Lua is a powerful, dynamic and light-weight programming language. -It may be embedded or used as a general-purpose, stand-alone language. -

-

-LuaJIT is Copyright © 2005-2014 Mike Pall, released under the -» MIT open source license. -

-

-

- -

Compatibility

- - -
WindowsLinuxBSDOSXPOSIX
- - -
EmbeddedAndroidiOSPS3PS4Xbox 360
- - -
GCCCLANG
LLVM
MSVC
- - -
x86x64ARMPPCe500MIPS
- - -
Lua 5.1
API+ABI
+ JIT+ BitOp+ FFIDrop-in
DLL/.so
- -

Overview

- - - - - - - - - -
3x
-  100x
115 KB
VM
90 KB
JIT
63 KLOC
C
24 KLOC
ASM
11 KLOC
Lua
-

-LuaJIT has been successfully used as a scripting middleware in -games, appliances, network and graphics apps, numerical simulations, -trading platforms and many other specialty applications. It scales from -embedded devices, smartphones, desktops up to server farms. It combines -high flexibility with » high performance -and an unmatched low memory footprint. -

-

-LuaJIT has been in continuous development since 2005. It's widely -considered to be one of the fastest dynamic language -implementations. It has outperformed other dynamic languages on many -cross-language benchmarks since its first release — often by a -substantial margin. -

-

-For LuaJIT 2.0, the whole VM has been rewritten from the ground up -and relentlessly optimized for performance. It combines a high-speed -interpreter, written in assembler, with a state-of-the-art JIT -compiler. -

-

-An innovative trace compiler is integrated with advanced, -SSA-based optimizations and highly tuned code generation backends. -A substantial reduction of the overhead associated with dynamic languages -allows it to break into the performance range traditionally reserved for -offline, static language compilers. -

- -

More ...

-

-Please select a sub-topic in the navigation bar to learn more about LuaJIT. -

-
-
- - - diff --git a/source/libs/luajit/LuaJIT-2.0.3/doc/running.html b/source/libs/luajit/LuaJIT-2.0.3/doc/running.html deleted file mode 100644 index c01c52d5a..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/doc/running.html +++ /dev/null @@ -1,306 +0,0 @@ - - - -Running LuaJIT - - - - - - - - - -
-Lua -
- - -
-

-LuaJIT has only a single stand-alone executable, called luajit on -POSIX systems or luajit.exe on Windows. It can be used to run simple -Lua statements or whole Lua applications from the command line. It has an -interactive mode, too. -

- -

Command Line Options

-

-The luajit stand-alone executable is just a slightly modified -version of the regular lua stand-alone executable. -It supports the same basic options, too. luajit -h -prints a short list of the available options. Please have a look at the -» Lua manual -for details. -

-

-LuaJIT has some additional options: -

- -

-b[options] input output

-

-This option saves or lists bytecode. The following additional options -are accepted: -

-
    -
  • -l — Only list bytecode.
  • -
  • -s — Strip debug info (this is the default).
  • -
  • -g — Keep debug info.
  • -
  • -n name — Set module name (default: auto-detect from input name)
  • -
  • -t type — Set output file type (default: auto-detect from output name).
  • -
  • -a arch — Override architecture for object files (default: native).
  • -
  • -o os — Override OS for object files (default: native).
  • -
  • -e chunk — Use chunk string as input.
  • -
  • - (a single minus sign) — Use stdin as input and/or stdout as output.
  • -
-

-The output file type is auto-detected from the extension of the output -file name: -

-
    -
  • c — C source file, exported bytecode data.
  • -
  • h — C header file, static bytecode data.
  • -
  • obj or o — Object file, exported bytecode data -(OS- and architecture-specific).
  • -
  • raw or any other extension — Raw bytecode file (portable). -
-

-Notes: -

-
    -
  • See also string.dump() -for information on bytecode portability and compatibility.
  • -
  • A file in raw bytecode format is auto-detected and can be loaded like -any Lua source file. E.g. directly from the command line or with -loadfile(), dofile() etc.
  • -
  • To statically embed the bytecode of a module in your application, -generate an object file and just link it with your application.
  • -
  • On most ELF-based systems (e.g. Linux) you need to explicitly export the -global symbols when linking your application, e.g. with: -Wl,-E
  • -
  • require() tries to load embedded bytecode data from exported -symbols (in *.exe or lua51.dll on Windows) and from -shared libraries in package.cpath.
  • -
-

-Typical usage examples: -

-
-luajit -b test.lua test.out                 # Save bytecode to test.out
-luajit -bg test.lua test.out                # Keep debug info
-luajit -be "print('hello world')" test.out  # Save cmdline script
-
-luajit -bl test.lua                         # List to stdout
-luajit -bl test.lua test.txt                # List to test.txt
-luajit -ble "print('hello world')"          # List cmdline script
-
-luajit -b test.lua test.obj                 # Generate object file
-# Link test.obj with your application and load it with require("test")
-
- -

-j cmd[=arg[,arg...]]

-

-This option performs a LuaJIT control command or activates one of the -loadable extension modules. The command is first looked up in the -jit.* library. If no matching function is found, a module -named jit.<cmd> is loaded and the start() -function of the module is called with the specified arguments (if -any). The space between -j and cmd is optional. -

-

-Here are the available LuaJIT control commands: -

-
    -
  • -jon — Turns the JIT compiler on (default).
  • -
  • -joff — Turns the JIT compiler off (only use the interpreter).
  • -
  • -jflush — Flushes the whole cache of compiled code.
  • -
  • -jv — Shows verbose information about the progress of the JIT compiler.
  • -
  • -jdump — Dumps the code and structures used in various compiler stages.
  • -
-

-The -jv and -jdump commands are extension modules -written in Lua. They are mainly used for debugging the JIT compiler -itself. For a description of their options and output format, please -read the comment block at the start of their source. -They can be found in the lib directory of the source -distribution or installed under the jit directory. By default -this is /usr/local/share/luajit-2.0.3/jit on POSIX -systems. -

- -

-O[level]
--O[+]flag   -O-flag
--Oparam=value

-

-This options allows fine-tuned control of the optimizations used by -the JIT compiler. This is mainly intended for debugging LuaJIT itself. -Please note that the JIT compiler is extremely fast (we are talking -about the microsecond to millisecond range). Disabling optimizations -doesn't have any visible impact on its overhead, but usually generates -code that runs slower. -

-

-The first form sets an optimization level — this enables a -specific mix of optimization flags. -O0 turns off all -optimizations and higher numbers enable more optimizations. Omitting -the level (i.e. just -O) sets the default optimization level, -which is -O3 in the current version. -

-

-The second form adds or removes individual optimization flags. -The third form sets a parameter for the VM or the JIT compiler -to a specific value. -

-

-You can either use this option multiple times (like -Ocse --O-dce -Ohotloop=10) or separate several settings with a comma -(like -O+cse,-dce,hotloop=10). The settings are applied from -left to right and later settings override earlier ones. You can freely -mix the three forms, but note that setting an optimization level -overrides all earlier flags. -

-

-Here are the available flags and at what optimization levels they -are enabled: -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Flag-O1-O2-O3 
foldConstant Folding, Simplifications and Reassociation
cseCommon-Subexpression Elimination
dceDead-Code Elimination
narrow Narrowing of numbers to integers
loop Loop Optimizations (code hoisting)
fwd  Load Forwarding (L2L) and Store Forwarding (S2L)
dse  Dead-Store Elimination
abc  Array Bounds Check Elimination
sink  Allocation/Store Sinking
fuse  Fusion of operands into instructions
-

-Here are the parameters and their default settings: -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterDefault 
maxtrace1000Max. number of traces in the cache
maxrecord4000Max. number of recorded IR instructions
maxirconst500Max. number of IR constants of a trace
maxside100Max. number of side traces of a root trace
maxsnap500Max. number of snapshots for a trace
hotloop56Number of iterations to detect a hot loop or hot call
hotexit10Number of taken exits to start a side trace
tryside4Number of attempts to compile a side trace
instunroll4Max. unroll factor for instable loops
loopunroll15Max. unroll factor for loop ops in side traces
callunroll3Max. unroll factor for pseudo-recursive calls
recunroll2Min. unroll factor for true recursion
sizemcode32Size of each machine code area in KBytes (Windows: 64K)
maxmcode512Max. total size of all machine code areas in KBytes
-
-
- - - diff --git a/source/libs/luajit/LuaJIT-2.0.3/doc/status.html b/source/libs/luajit/LuaJIT-2.0.3/doc/status.html deleted file mode 100644 index ddcaed332..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/doc/status.html +++ /dev/null @@ -1,125 +0,0 @@ - - - -Status & Roadmap - - - - - - - - - -
-Lua -
- - -
-

-LuaJIT 2.0 is the current -stable branch. This branch is in -feature-freeze — new features will only be added to LuaJIT 2.1. -

- -

Current Status

-

-LuaJIT ought to run all Lua 5.1-compatible source code just fine. -It's considered a serious bug if the VM crashes or produces unexpected -results — please report this. -

-

-Known incompatibilities and issues in LuaJIT 2.0: -

-
    -
  • -There are some differences in implementation-defined behavior. -These either have a good reason, are arbitrary design choices -or are due to quirks in the VM. The latter cases may get fixed if a -demonstrable need is shown. -
  • -
  • -The Lua debug API is missing a couple of features (return -hooks for non-Lua functions) and shows slightly different behavior -in LuaJIT (no per-coroutine hooks, no tail call counting). -
  • -
  • -Some checks are missing in the JIT-compiled code for obscure situations -with open upvalues aliasing one of the SSA slots later on (or -vice versa). Bonus points, if you can find a real world test case for -this. -
  • -
  • -Currently some out-of-memory errors from on-trace code are not -handled correctly. The error may fall through an on-trace -pcall or it may be passed on to the function set with -lua_atpanic on x64. This issue will be fixed with the new -garbage collector. -
  • -
- -

Roadmap

-

-Please refer to the -» LuaJIT Roadmap 2012/2013 and an -» update on release planning for details. -

-

-

-
-
- - - diff --git a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_arm.h b/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_arm.h deleted file mode 100644 index 435bbf5e1..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_arm.h +++ /dev/null @@ -1,456 +0,0 @@ -/* -** DynASM ARM encoding engine. -** Copyright (C) 2005-2014 Mike Pall. All rights reserved. -** Released under the MIT license. See dynasm.lua for full copyright notice. -*/ - -#include -#include -#include -#include - -#define DASM_ARCH "arm" - -#ifndef DASM_EXTERN -#define DASM_EXTERN(a,b,c,d) 0 -#endif - -/* Action definitions. */ -enum { - DASM_STOP, DASM_SECTION, DASM_ESC, DASM_REL_EXT, - /* The following actions need a buffer position. */ - DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG, - /* The following actions also have an argument. */ - DASM_REL_PC, DASM_LABEL_PC, - DASM_IMM, DASM_IMM12, DASM_IMM16, DASM_IMML8, DASM_IMML12, DASM_IMMV8, - DASM__MAX -}; - -/* Maximum number of section buffer positions for a single dasm_put() call. */ -#define DASM_MAXSECPOS 25 - -/* DynASM encoder status codes. Action list offset or number are or'ed in. */ -#define DASM_S_OK 0x00000000 -#define DASM_S_NOMEM 0x01000000 -#define DASM_S_PHASE 0x02000000 -#define DASM_S_MATCH_SEC 0x03000000 -#define DASM_S_RANGE_I 0x11000000 -#define DASM_S_RANGE_SEC 0x12000000 -#define DASM_S_RANGE_LG 0x13000000 -#define DASM_S_RANGE_PC 0x14000000 -#define DASM_S_RANGE_REL 0x15000000 -#define DASM_S_UNDEF_LG 0x21000000 -#define DASM_S_UNDEF_PC 0x22000000 - -/* Macros to convert positions (8 bit section + 24 bit index). */ -#define DASM_POS2IDX(pos) ((pos)&0x00ffffff) -#define DASM_POS2BIAS(pos) ((pos)&0xff000000) -#define DASM_SEC2POS(sec) ((sec)<<24) -#define DASM_POS2SEC(pos) ((pos)>>24) -#define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) - -/* Action list type. */ -typedef const unsigned int *dasm_ActList; - -/* Per-section structure. */ -typedef struct dasm_Section { - int *rbuf; /* Biased buffer pointer (negative section bias). */ - int *buf; /* True buffer pointer. */ - size_t bsize; /* Buffer size in bytes. */ - int pos; /* Biased buffer position. */ - int epos; /* End of biased buffer position - max single put. */ - int ofs; /* Byte offset into section. */ -} dasm_Section; - -/* Core structure holding the DynASM encoding state. */ -struct dasm_State { - size_t psize; /* Allocated size of this structure. */ - dasm_ActList actionlist; /* Current actionlist pointer. */ - int *lglabels; /* Local/global chain/pos ptrs. */ - size_t lgsize; - int *pclabels; /* PC label chains/pos ptrs. */ - size_t pcsize; - void **globals; /* Array of globals (bias -10). */ - dasm_Section *section; /* Pointer to active section. */ - size_t codesize; /* Total size of all code sections. */ - int maxsection; /* 0 <= sectionidx < maxsection. */ - int status; /* Status code. */ - dasm_Section sections[1]; /* All sections. Alloc-extended. */ -}; - -/* The size of the core structure depends on the max. number of sections. */ -#define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section)) - - -/* Initialize DynASM state. */ -void dasm_init(Dst_DECL, int maxsection) -{ - dasm_State *D; - size_t psz = 0; - int i; - Dst_REF = NULL; - DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); - D = Dst_REF; - D->psize = psz; - D->lglabels = NULL; - D->lgsize = 0; - D->pclabels = NULL; - D->pcsize = 0; - D->globals = NULL; - D->maxsection = maxsection; - for (i = 0; i < maxsection; i++) { - D->sections[i].buf = NULL; /* Need this for pass3. */ - D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i); - D->sections[i].bsize = 0; - D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ - } -} - -/* Free DynASM state. */ -void dasm_free(Dst_DECL) -{ - dasm_State *D = Dst_REF; - int i; - for (i = 0; i < D->maxsection; i++) - if (D->sections[i].buf) - DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize); - if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize); - if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize); - DASM_M_FREE(Dst, D, D->psize); -} - -/* Setup global label array. Must be called before dasm_setup(). */ -void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) -{ - dasm_State *D = Dst_REF; - D->globals = gl - 10; /* Negative bias to compensate for locals. */ - DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); -} - -/* Grow PC label array. Can be called after dasm_setup(), too. */ -void dasm_growpc(Dst_DECL, unsigned int maxpc) -{ - dasm_State *D = Dst_REF; - size_t osz = D->pcsize; - DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int)); - memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz); -} - -/* Setup encoder. */ -void dasm_setup(Dst_DECL, const void *actionlist) -{ - dasm_State *D = Dst_REF; - int i; - D->actionlist = (dasm_ActList)actionlist; - D->status = DASM_S_OK; - D->section = &D->sections[0]; - memset((void *)D->lglabels, 0, D->lgsize); - if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); - for (i = 0; i < D->maxsection; i++) { - D->sections[i].pos = DASM_SEC2POS(i); - D->sections[i].ofs = 0; - } -} - - -#ifdef DASM_CHECKS -#define CK(x, st) \ - do { if (!(x)) { \ - D->status = DASM_S_##st|(p-D->actionlist-1); return; } } while (0) -#define CKPL(kind, st) \ - do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \ - D->status = DASM_S_RANGE_##st|(p-D->actionlist-1); return; } } while (0) -#else -#define CK(x, st) ((void)0) -#define CKPL(kind, st) ((void)0) -#endif - -static int dasm_imm12(unsigned int n) -{ - int i; - for (i = 0; i < 16; i++, n = (n << 2) | (n >> 30)) - if (n <= 255) return (int)(n + (i << 8)); - return -1; -} - -/* Pass 1: Store actions and args, link branches/labels, estimate offsets. */ -void dasm_put(Dst_DECL, int start, ...) -{ - va_list ap; - dasm_State *D = Dst_REF; - dasm_ActList p = D->actionlist + start; - dasm_Section *sec = D->section; - int pos = sec->pos, ofs = sec->ofs; - int *b; - - if (pos >= sec->epos) { - DASM_M_GROW(Dst, int, sec->buf, sec->bsize, - sec->bsize + 2*DASM_MAXSECPOS*sizeof(int)); - sec->rbuf = sec->buf - DASM_POS2BIAS(pos); - sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos); - } - - b = sec->rbuf; - b[pos++] = start; - - va_start(ap, start); - while (1) { - unsigned int ins = *p++; - unsigned int action = (ins >> 16); - if (action >= DASM__MAX) { - ofs += 4; - } else { - int *pl, n = action >= DASM_REL_PC ? va_arg(ap, int) : 0; - switch (action) { - case DASM_STOP: goto stop; - case DASM_SECTION: - n = (ins & 255); CK(n < D->maxsection, RANGE_SEC); - D->section = &D->sections[n]; goto stop; - case DASM_ESC: p++; ofs += 4; break; - case DASM_REL_EXT: break; - case DASM_ALIGN: ofs += (ins & 255); b[pos++] = ofs; break; - case DASM_REL_LG: - n = (ins & 2047) - 10; pl = D->lglabels + n; - /* Bkwd rel or global. */ - if (n >= 0) { CK(n>=10||*pl<0, RANGE_LG); CKPL(lg, LG); goto putrel; } - pl += 10; n = *pl; - if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */ - goto linkrel; - case DASM_REL_PC: - pl = D->pclabels + n; CKPL(pc, PC); - putrel: - n = *pl; - if (n < 0) { /* Label exists. Get label pos and store it. */ - b[pos] = -n; - } else { - linkrel: - b[pos] = n; /* Else link to rel chain, anchored at label. */ - *pl = pos; - } - pos++; - break; - case DASM_LABEL_LG: - pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel; - case DASM_LABEL_PC: - pl = D->pclabels + n; CKPL(pc, PC); - putlabel: - n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */ - while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; - } - *pl = -pos; /* Label exists now. */ - b[pos++] = ofs; /* Store pass1 offset estimate. */ - break; - case DASM_IMM: - case DASM_IMM16: -#ifdef DASM_CHECKS - CK((n & ((1<<((ins>>10)&31))-1)) == 0, RANGE_I); - if ((ins & 0x8000)) - CK(((n + (1<<(((ins>>5)&31)-1)))>>((ins>>5)&31)) == 0, RANGE_I); - else - CK((n>>((ins>>5)&31)) == 0, RANGE_I); -#endif - b[pos++] = n; - break; - case DASM_IMMV8: - CK((n & 3) == 0, RANGE_I); - n >>= 2; - case DASM_IMML8: - case DASM_IMML12: - CK(n >= 0 ? ((n>>((ins>>5)&31)) == 0) : - (((-n)>>((ins>>5)&31)) == 0), RANGE_I); - b[pos++] = n; - break; - case DASM_IMM12: - CK(dasm_imm12((unsigned int)n) != -1, RANGE_I); - b[pos++] = n; - break; - } - } - } -stop: - va_end(ap); - sec->pos = pos; - sec->ofs = ofs; -} -#undef CK - -/* Pass 2: Link sections, shrink aligns, fix label offsets. */ -int dasm_link(Dst_DECL, size_t *szp) -{ - dasm_State *D = Dst_REF; - int secnum; - int ofs = 0; - -#ifdef DASM_CHECKS - *szp = 0; - if (D->status != DASM_S_OK) return D->status; - { - int pc; - for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) - if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; - } -#endif - - { /* Handle globals not defined in this translation unit. */ - int idx; - for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) { - int n = D->lglabels[idx]; - /* Undefined label: Collapse rel chain and replace with marker (< 0). */ - while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } - } - } - - /* Combine all code sections. No support for data sections (yet). */ - for (secnum = 0; secnum < D->maxsection; secnum++) { - dasm_Section *sec = D->sections + secnum; - int *b = sec->rbuf; - int pos = DASM_SEC2POS(secnum); - int lastpos = sec->pos; - - while (pos != lastpos) { - dasm_ActList p = D->actionlist + b[pos++]; - while (1) { - unsigned int ins = *p++; - unsigned int action = (ins >> 16); - switch (action) { - case DASM_STOP: case DASM_SECTION: goto stop; - case DASM_ESC: p++; break; - case DASM_REL_EXT: break; - case DASM_ALIGN: ofs -= (b[pos++] + ofs) & (ins & 255); break; - case DASM_REL_LG: case DASM_REL_PC: pos++; break; - case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break; - case DASM_IMM: case DASM_IMM12: case DASM_IMM16: - case DASM_IMML8: case DASM_IMML12: case DASM_IMMV8: pos++; break; - } - } - stop: (void)0; - } - ofs += sec->ofs; /* Next section starts right after current section. */ - } - - D->codesize = ofs; /* Total size of all code sections */ - *szp = ofs; - return DASM_S_OK; -} - -#ifdef DASM_CHECKS -#define CK(x, st) \ - do { if (!(x)) return DASM_S_##st|(p-D->actionlist-1); } while (0) -#else -#define CK(x, st) ((void)0) -#endif - -/* Pass 3: Encode sections. */ -int dasm_encode(Dst_DECL, void *buffer) -{ - dasm_State *D = Dst_REF; - char *base = (char *)buffer; - unsigned int *cp = (unsigned int *)buffer; - int secnum; - - /* Encode all code sections. No support for data sections (yet). */ - for (secnum = 0; secnum < D->maxsection; secnum++) { - dasm_Section *sec = D->sections + secnum; - int *b = sec->buf; - int *endb = sec->rbuf + sec->pos; - - while (b != endb) { - dasm_ActList p = D->actionlist + *b++; - while (1) { - unsigned int ins = *p++; - unsigned int action = (ins >> 16); - int n = (action >= DASM_ALIGN && action < DASM__MAX) ? *b++ : 0; - switch (action) { - case DASM_STOP: case DASM_SECTION: goto stop; - case DASM_ESC: *cp++ = *p++; break; - case DASM_REL_EXT: - n = DASM_EXTERN(Dst, (unsigned char *)cp, (ins&2047), !(ins&2048)); - goto patchrel; - case DASM_ALIGN: - ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0xe1a00000; - break; - case DASM_REL_LG: - CK(n >= 0, UNDEF_LG); - case DASM_REL_PC: - CK(n >= 0, UNDEF_PC); - n = *DASM_POS2PTR(D, n) - (int)((char *)cp - base) - 4; - patchrel: - if ((ins & 0x800) == 0) { - CK((n & 3) == 0 && ((n+0x02000000) >> 26) == 0, RANGE_REL); - cp[-1] |= ((n >> 2) & 0x00ffffff); - } else if ((ins & 0x1000)) { - CK((n & 3) == 0 && -256 <= n && n <= 256, RANGE_REL); - goto patchimml8; - } else if ((ins & 0x2000) == 0) { - CK((n & 3) == 0 && -4096 <= n && n <= 4096, RANGE_REL); - goto patchimml; - } else { - CK((n & 3) == 0 && -1020 <= n && n <= 1020, RANGE_REL); - n >>= 2; - goto patchimml; - } - break; - case DASM_LABEL_LG: - ins &= 2047; if (ins >= 20) D->globals[ins-10] = (void *)(base + n); - break; - case DASM_LABEL_PC: break; - case DASM_IMM: - cp[-1] |= ((n>>((ins>>10)&31)) & ((1<<((ins>>5)&31))-1)) << (ins&31); - break; - case DASM_IMM12: - cp[-1] |= dasm_imm12((unsigned int)n); - break; - case DASM_IMM16: - cp[-1] |= ((n & 0xf000) << 4) | (n & 0x0fff); - break; - case DASM_IMML8: patchimml8: - cp[-1] |= n >= 0 ? (0x00800000 | (n & 0x0f) | ((n & 0xf0) << 4)) : - ((-n & 0x0f) | ((-n & 0xf0) << 4)); - break; - case DASM_IMML12: case DASM_IMMV8: patchimml: - cp[-1] |= n >= 0 ? (0x00800000 | n) : (-n); - break; - default: *cp++ = ins; break; - } - } - stop: (void)0; - } - } - - if (base + D->codesize != (char *)cp) /* Check for phase errors. */ - return DASM_S_PHASE; - return DASM_S_OK; -} -#undef CK - -/* Get PC label offset. */ -int dasm_getpclabel(Dst_DECL, unsigned int pc) -{ - dasm_State *D = Dst_REF; - if (pc*sizeof(int) < D->pcsize) { - int pos = D->pclabels[pc]; - if (pos < 0) return *DASM_POS2PTR(D, -pos); - if (pos > 0) return -1; /* Undefined. */ - } - return -2; /* Unused or out of range. */ -} - -#ifdef DASM_CHECKS -/* Optional sanity checker to call between isolated encoding steps. */ -int dasm_checkstep(Dst_DECL, int secmatch) -{ - dasm_State *D = Dst_REF; - if (D->status == DASM_S_OK) { - int i; - for (i = 1; i <= 9; i++) { - if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_LG|i; break; } - D->lglabels[i] = 0; - } - } - if (D->status == DASM_S_OK && secmatch >= 0 && - D->section != &D->sections[secmatch]) - D->status = DASM_S_MATCH_SEC|(D->section-D->sections); - return D->status; -} -#endif - diff --git a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_arm.lua b/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_arm.lua deleted file mode 100644 index b3a8827e3..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_arm.lua +++ /dev/null @@ -1,1122 +0,0 @@ ------------------------------------------------------------------------------- --- DynASM ARM module. --- --- Copyright (C) 2005-2014 Mike Pall. All rights reserved. --- See dynasm.lua for full copyright notice. ------------------------------------------------------------------------------- - --- Module information: -local _info = { - arch = "arm", - description = "DynASM ARM module", - version = "1.3.0", - vernum = 10300, - release = "2011-05-05", - author = "Mike Pall", - license = "MIT", -} - --- Exported glue functions for the arch-specific module. -local _M = { _info = _info } - --- Cache library functions. -local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs -local assert, setmetatable, rawget = assert, setmetatable, rawget -local _s = string -local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char -local match, gmatch, gsub = _s.match, _s.gmatch, _s.gsub -local concat, sort, insert = table.concat, table.sort, table.insert -local bit = bit or require("bit") -local band, shl, shr, sar = bit.band, bit.lshift, bit.rshift, bit.arshift -local ror, tohex = bit.ror, bit.tohex - --- Inherited tables and callbacks. -local g_opt, g_arch -local wline, werror, wfatal, wwarn - --- Action name list. --- CHECK: Keep this in sync with the C code! -local action_names = { - "STOP", "SECTION", "ESC", "REL_EXT", - "ALIGN", "REL_LG", "LABEL_LG", - "REL_PC", "LABEL_PC", "IMM", "IMM12", "IMM16", "IMML8", "IMML12", "IMMV8", -} - --- Maximum number of section buffer positions for dasm_put(). --- CHECK: Keep this in sync with the C code! -local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines. - --- Action name -> action number. -local map_action = {} -for n,name in ipairs(action_names) do - map_action[name] = n-1 -end - --- Action list buffer. -local actlist = {} - --- Argument list for next dasm_put(). Start with offset 0 into action list. -local actargs = { 0 } - --- Current number of section buffer positions for dasm_put(). -local secpos = 1 - ------------------------------------------------------------------------------- - --- Dump action names and numbers. -local function dumpactions(out) - out:write("DynASM encoding engine action codes:\n") - for n,name in ipairs(action_names) do - local num = map_action[name] - out:write(format(" %-10s %02X %d\n", name, num, num)) - end - out:write("\n") -end - --- Write action list buffer as a huge static C array. -local function writeactions(out, name) - local nn = #actlist - if nn == 0 then nn = 1; actlist[0] = map_action.STOP end - out:write("static const unsigned int ", name, "[", nn, "] = {\n") - for i = 1,nn-1 do - assert(out:write("0x", tohex(actlist[i]), ",\n")) - end - assert(out:write("0x", tohex(actlist[nn]), "\n};\n\n")) -end - ------------------------------------------------------------------------------- - --- Add word to action list. -local function wputxw(n) - assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") - actlist[#actlist+1] = n -end - --- Add action to list with optional arg. Advance buffer pos, too. -local function waction(action, val, a, num) - local w = assert(map_action[action], "bad action name `"..action.."'") - wputxw(w * 0x10000 + (val or 0)) - if a then actargs[#actargs+1] = a end - if a or num then secpos = secpos + (num or 1) end -end - --- Flush action list (intervening C code or buffer pos overflow). -local function wflush(term) - if #actlist == actargs[1] then return end -- Nothing to flush. - if not term then waction("STOP") end -- Terminate action list. - wline(format("dasm_put(Dst, %s);", concat(actargs, ", ")), true) - actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put(). - secpos = 1 -- The actionlist offset occupies a buffer position, too. -end - --- Put escaped word. -local function wputw(n) - if n <= 0x000fffff then waction("ESC") end - wputxw(n) -end - --- Reserve position for word. -local function wpos() - local pos = #actlist+1 - actlist[pos] = "" - return pos -end - --- Store word to reserved position. -local function wputpos(pos, n) - assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") - if n <= 0x000fffff then - insert(actlist, pos+1, n) - n = map_action.ESC * 0x10000 - end - actlist[pos] = n -end - ------------------------------------------------------------------------------- - --- Global label name -> global label number. With auto assignment on 1st use. -local next_global = 20 -local map_global = setmetatable({}, { __index = function(t, name) - if not match(name, "^[%a_][%w_]*$") then werror("bad global label") end - local n = next_global - if n > 2047 then werror("too many global labels") end - next_global = n + 1 - t[name] = n - return n -end}) - --- Dump global labels. -local function dumpglobals(out, lvl) - local t = {} - for name, n in pairs(map_global) do t[n] = name end - out:write("Global labels:\n") - for i=20,next_global-1 do - out:write(format(" %s\n", t[i])) - end - out:write("\n") -end - --- Write global label enum. -local function writeglobals(out, prefix) - local t = {} - for name, n in pairs(map_global) do t[n] = name end - out:write("enum {\n") - for i=20,next_global-1 do - out:write(" ", prefix, t[i], ",\n") - end - out:write(" ", prefix, "_MAX\n};\n") -end - --- Write global label names. -local function writeglobalnames(out, name) - local t = {} - for name, n in pairs(map_global) do t[n] = name end - out:write("static const char *const ", name, "[] = {\n") - for i=20,next_global-1 do - out:write(" \"", t[i], "\",\n") - end - out:write(" (const char *)0\n};\n") -end - ------------------------------------------------------------------------------- - --- Extern label name -> extern label number. With auto assignment on 1st use. -local next_extern = 0 -local map_extern_ = {} -local map_extern = setmetatable({}, { __index = function(t, name) - -- No restrictions on the name for now. - local n = next_extern - if n > 2047 then werror("too many extern labels") end - next_extern = n + 1 - t[name] = n - map_extern_[n] = name - return n -end}) - --- Dump extern labels. -local function dumpexterns(out, lvl) - out:write("Extern labels:\n") - for i=0,next_extern-1 do - out:write(format(" %s\n", map_extern_[i])) - end - out:write("\n") -end - --- Write extern label names. -local function writeexternnames(out, name) - out:write("static const char *const ", name, "[] = {\n") - for i=0,next_extern-1 do - out:write(" \"", map_extern_[i], "\",\n") - end - out:write(" (const char *)0\n};\n") -end - ------------------------------------------------------------------------------- - --- Arch-specific maps. - --- Ext. register name -> int. name. -local map_archdef = { sp = "r13", lr = "r14", pc = "r15", } - --- Int. register name -> ext. name. -local map_reg_rev = { r13 = "sp", r14 = "lr", r15 = "pc", } - -local map_type = {} -- Type name -> { ctype, reg } -local ctypenum = 0 -- Type number (for Dt... macros). - --- Reverse defines for registers. -function _M.revdef(s) - return map_reg_rev[s] or s -end - -local map_shift = { lsl = 0, lsr = 1, asr = 2, ror = 3, } - -local map_cond = { - eq = 0, ne = 1, cs = 2, cc = 3, mi = 4, pl = 5, vs = 6, vc = 7, - hi = 8, ls = 9, ge = 10, lt = 11, gt = 12, le = 13, al = 14, - hs = 2, lo = 3, -} - ------------------------------------------------------------------------------- - --- Template strings for ARM instructions. -local map_op = { - -- Basic data processing instructions. - and_3 = "e0000000DNPs", - eor_3 = "e0200000DNPs", - sub_3 = "e0400000DNPs", - rsb_3 = "e0600000DNPs", - add_3 = "e0800000DNPs", - adc_3 = "e0a00000DNPs", - sbc_3 = "e0c00000DNPs", - rsc_3 = "e0e00000DNPs", - tst_2 = "e1100000NP", - teq_2 = "e1300000NP", - cmp_2 = "e1500000NP", - cmn_2 = "e1700000NP", - orr_3 = "e1800000DNPs", - mov_2 = "e1a00000DPs", - bic_3 = "e1c00000DNPs", - mvn_2 = "e1e00000DPs", - - and_4 = "e0000000DNMps", - eor_4 = "e0200000DNMps", - sub_4 = "e0400000DNMps", - rsb_4 = "e0600000DNMps", - add_4 = "e0800000DNMps", - adc_4 = "e0a00000DNMps", - sbc_4 = "e0c00000DNMps", - rsc_4 = "e0e00000DNMps", - tst_3 = "e1100000NMp", - teq_3 = "e1300000NMp", - cmp_3 = "e1500000NMp", - cmn_3 = "e1700000NMp", - orr_4 = "e1800000DNMps", - mov_3 = "e1a00000DMps", - bic_4 = "e1c00000DNMps", - mvn_3 = "e1e00000DMps", - - lsl_3 = "e1a00000DMws", - lsr_3 = "e1a00020DMws", - asr_3 = "e1a00040DMws", - ror_3 = "e1a00060DMws", - rrx_2 = "e1a00060DMs", - - -- Multiply and multiply-accumulate. - mul_3 = "e0000090NMSs", - mla_4 = "e0200090NMSDs", - umaal_4 = "e0400090DNMSs", -- v6 - mls_4 = "e0600090DNMSs", -- v6T2 - umull_4 = "e0800090DNMSs", - umlal_4 = "e0a00090DNMSs", - smull_4 = "e0c00090DNMSs", - smlal_4 = "e0e00090DNMSs", - - -- Halfword multiply and multiply-accumulate. - smlabb_4 = "e1000080NMSD", -- v5TE - smlatb_4 = "e10000a0NMSD", -- v5TE - smlabt_4 = "e10000c0NMSD", -- v5TE - smlatt_4 = "e10000e0NMSD", -- v5TE - smlawb_4 = "e1200080NMSD", -- v5TE - smulwb_3 = "e12000a0NMS", -- v5TE - smlawt_4 = "e12000c0NMSD", -- v5TE - smulwt_3 = "e12000e0NMS", -- v5TE - smlalbb_4 = "e1400080NMSD", -- v5TE - smlaltb_4 = "e14000a0NMSD", -- v5TE - smlalbt_4 = "e14000c0NMSD", -- v5TE - smlaltt_4 = "e14000e0NMSD", -- v5TE - smulbb_3 = "e1600080NMS", -- v5TE - smultb_3 = "e16000a0NMS", -- v5TE - smulbt_3 = "e16000c0NMS", -- v5TE - smultt_3 = "e16000e0NMS", -- v5TE - - -- Miscellaneous data processing instructions. - clz_2 = "e16f0f10DM", -- v5T - rev_2 = "e6bf0f30DM", -- v6 - rev16_2 = "e6bf0fb0DM", -- v6 - revsh_2 = "e6ff0fb0DM", -- v6 - sel_3 = "e6800fb0DNM", -- v6 - usad8_3 = "e780f010NMS", -- v6 - usada8_4 = "e7800010NMSD", -- v6 - rbit_2 = "e6ff0f30DM", -- v6T2 - movw_2 = "e3000000DW", -- v6T2 - movt_2 = "e3400000DW", -- v6T2 - -- Note: the X encodes width-1, not width. - sbfx_4 = "e7a00050DMvX", -- v6T2 - ubfx_4 = "e7e00050DMvX", -- v6T2 - -- Note: the X encodes the msb field, not the width. - bfc_3 = "e7c0001fDvX", -- v6T2 - bfi_4 = "e7c00010DMvX", -- v6T2 - - -- Packing and unpacking instructions. - pkhbt_3 = "e6800010DNM", pkhbt_4 = "e6800010DNMv", -- v6 - pkhtb_3 = "e6800050DNM", pkhtb_4 = "e6800050DNMv", -- v6 - sxtab_3 = "e6a00070DNM", sxtab_4 = "e6a00070DNMv", -- v6 - sxtab16_3 = "e6800070DNM", sxtab16_4 = "e6800070DNMv", -- v6 - sxtah_3 = "e6b00070DNM", sxtah_4 = "e6b00070DNMv", -- v6 - sxtb_2 = "e6af0070DM", sxtb_3 = "e6af0070DMv", -- v6 - sxtb16_2 = "e68f0070DM", sxtb16_3 = "e68f0070DMv", -- v6 - sxth_2 = "e6bf0070DM", sxth_3 = "e6bf0070DMv", -- v6 - uxtab_3 = "e6e00070DNM", uxtab_4 = "e6e00070DNMv", -- v6 - uxtab16_3 = "e6c00070DNM", uxtab16_4 = "e6c00070DNMv", -- v6 - uxtah_3 = "e6f00070DNM", uxtah_4 = "e6f00070DNMv", -- v6 - uxtb_2 = "e6ef0070DM", uxtb_3 = "e6ef0070DMv", -- v6 - uxtb16_2 = "e6cf0070DM", uxtb16_3 = "e6cf0070DMv", -- v6 - uxth_2 = "e6ff0070DM", uxth_3 = "e6ff0070DMv", -- v6 - - -- Saturating instructions. - qadd_3 = "e1000050DMN", -- v5TE - qsub_3 = "e1200050DMN", -- v5TE - qdadd_3 = "e1400050DMN", -- v5TE - qdsub_3 = "e1600050DMN", -- v5TE - -- Note: the X for ssat* encodes sat_imm-1, not sat_imm. - ssat_3 = "e6a00010DXM", ssat_4 = "e6a00010DXMp", -- v6 - usat_3 = "e6e00010DXM", usat_4 = "e6e00010DXMp", -- v6 - ssat16_3 = "e6a00f30DXM", -- v6 - usat16_3 = "e6e00f30DXM", -- v6 - - -- Parallel addition and subtraction. - sadd16_3 = "e6100f10DNM", -- v6 - sasx_3 = "e6100f30DNM", -- v6 - ssax_3 = "e6100f50DNM", -- v6 - ssub16_3 = "e6100f70DNM", -- v6 - sadd8_3 = "e6100f90DNM", -- v6 - ssub8_3 = "e6100ff0DNM", -- v6 - qadd16_3 = "e6200f10DNM", -- v6 - qasx_3 = "e6200f30DNM", -- v6 - qsax_3 = "e6200f50DNM", -- v6 - qsub16_3 = "e6200f70DNM", -- v6 - qadd8_3 = "e6200f90DNM", -- v6 - qsub8_3 = "e6200ff0DNM", -- v6 - shadd16_3 = "e6300f10DNM", -- v6 - shasx_3 = "e6300f30DNM", -- v6 - shsax_3 = "e6300f50DNM", -- v6 - shsub16_3 = "e6300f70DNM", -- v6 - shadd8_3 = "e6300f90DNM", -- v6 - shsub8_3 = "e6300ff0DNM", -- v6 - uadd16_3 = "e6500f10DNM", -- v6 - uasx_3 = "e6500f30DNM", -- v6 - usax_3 = "e6500f50DNM", -- v6 - usub16_3 = "e6500f70DNM", -- v6 - uadd8_3 = "e6500f90DNM", -- v6 - usub8_3 = "e6500ff0DNM", -- v6 - uqadd16_3 = "e6600f10DNM", -- v6 - uqasx_3 = "e6600f30DNM", -- v6 - uqsax_3 = "e6600f50DNM", -- v6 - uqsub16_3 = "e6600f70DNM", -- v6 - uqadd8_3 = "e6600f90DNM", -- v6 - uqsub8_3 = "e6600ff0DNM", -- v6 - uhadd16_3 = "e6700f10DNM", -- v6 - uhasx_3 = "e6700f30DNM", -- v6 - uhsax_3 = "e6700f50DNM", -- v6 - uhsub16_3 = "e6700f70DNM", -- v6 - uhadd8_3 = "e6700f90DNM", -- v6 - uhsub8_3 = "e6700ff0DNM", -- v6 - - -- Load/store instructions. - str_2 = "e4000000DL", str_3 = "e4000000DL", str_4 = "e4000000DL", - strb_2 = "e4400000DL", strb_3 = "e4400000DL", strb_4 = "e4400000DL", - ldr_2 = "e4100000DL", ldr_3 = "e4100000DL", ldr_4 = "e4100000DL", - ldrb_2 = "e4500000DL", ldrb_3 = "e4500000DL", ldrb_4 = "e4500000DL", - strh_2 = "e00000b0DL", strh_3 = "e00000b0DL", - ldrh_2 = "e01000b0DL", ldrh_3 = "e01000b0DL", - ldrd_2 = "e00000d0DL", ldrd_3 = "e00000d0DL", -- v5TE - ldrsb_2 = "e01000d0DL", ldrsb_3 = "e01000d0DL", - strd_2 = "e00000f0DL", strd_3 = "e00000f0DL", -- v5TE - ldrsh_2 = "e01000f0DL", ldrsh_3 = "e01000f0DL", - - ldm_2 = "e8900000oR", ldmia_2 = "e8900000oR", ldmfd_2 = "e8900000oR", - ldmda_2 = "e8100000oR", ldmfa_2 = "e8100000oR", - ldmdb_2 = "e9100000oR", ldmea_2 = "e9100000oR", - ldmib_2 = "e9900000oR", ldmed_2 = "e9900000oR", - stm_2 = "e8800000oR", stmia_2 = "e8800000oR", stmfd_2 = "e8800000oR", - stmda_2 = "e8000000oR", stmfa_2 = "e8000000oR", - stmdb_2 = "e9000000oR", stmea_2 = "e9000000oR", - stmib_2 = "e9800000oR", stmed_2 = "e9800000oR", - pop_1 = "e8bd0000R", push_1 = "e92d0000R", - - -- Branch instructions. - b_1 = "ea000000B", - bl_1 = "eb000000B", - blx_1 = "e12fff30C", - bx_1 = "e12fff10M", - - -- Miscellaneous instructions. - nop_0 = "e1a00000", - mrs_1 = "e10f0000D", - bkpt_1 = "e1200070K", -- v5T - svc_1 = "ef000000T", swi_1 = "ef000000T", - ud_0 = "e7f001f0", - - -- VFP instructions. - ["vadd.f32_3"] = "ee300a00dnm", - ["vadd.f64_3"] = "ee300b00Gdnm", - ["vsub.f32_3"] = "ee300a40dnm", - ["vsub.f64_3"] = "ee300b40Gdnm", - ["vmul.f32_3"] = "ee200a00dnm", - ["vmul.f64_3"] = "ee200b00Gdnm", - ["vnmul.f32_3"] = "ee200a40dnm", - ["vnmul.f64_3"] = "ee200b40Gdnm", - ["vmla.f32_3"] = "ee000a00dnm", - ["vmla.f64_3"] = "ee000b00Gdnm", - ["vmls.f32_3"] = "ee000a40dnm", - ["vmls.f64_3"] = "ee000b40Gdnm", - ["vnmla.f32_3"] = "ee100a40dnm", - ["vnmla.f64_3"] = "ee100b40Gdnm", - ["vnmls.f32_3"] = "ee100a00dnm", - ["vnmls.f64_3"] = "ee100b00Gdnm", - ["vdiv.f32_3"] = "ee800a00dnm", - ["vdiv.f64_3"] = "ee800b00Gdnm", - - ["vabs.f32_2"] = "eeb00ac0dm", - ["vabs.f64_2"] = "eeb00bc0Gdm", - ["vneg.f32_2"] = "eeb10a40dm", - ["vneg.f64_2"] = "eeb10b40Gdm", - ["vsqrt.f32_2"] = "eeb10ac0dm", - ["vsqrt.f64_2"] = "eeb10bc0Gdm", - ["vcmp.f32_2"] = "eeb40a40dm", - ["vcmp.f64_2"] = "eeb40b40Gdm", - ["vcmpe.f32_2"] = "eeb40ac0dm", - ["vcmpe.f64_2"] = "eeb40bc0Gdm", - ["vcmpz.f32_1"] = "eeb50a40d", - ["vcmpz.f64_1"] = "eeb50b40Gd", - ["vcmpze.f32_1"] = "eeb50ac0d", - ["vcmpze.f64_1"] = "eeb50bc0Gd", - - vldr_2 = "ed100a00dl|ed100b00Gdl", - vstr_2 = "ed000a00dl|ed000b00Gdl", - vldm_2 = "ec900a00or", - vldmia_2 = "ec900a00or", - vldmdb_2 = "ed100a00or", - vpop_1 = "ecbd0a00r", - vstm_2 = "ec800a00or", - vstmia_2 = "ec800a00or", - vstmdb_2 = "ed000a00or", - vpush_1 = "ed2d0a00r", - - ["vmov.f32_2"] = "eeb00a40dm|eeb00a00dY", -- #imm is VFPv3 only - ["vmov.f64_2"] = "eeb00b40Gdm|eeb00b00GdY", -- #imm is VFPv3 only - vmov_2 = "ee100a10Dn|ee000a10nD", - vmov_3 = "ec500a10DNm|ec400a10mDN|ec500b10GDNm|ec400b10GmDN", - - vmrs_0 = "eef1fa10", - vmrs_1 = "eef10a10D", - vmsr_1 = "eee10a10D", - - ["vcvt.s32.f32_2"] = "eebd0ac0dm", - ["vcvt.s32.f64_2"] = "eebd0bc0dGm", - ["vcvt.u32.f32_2"] = "eebc0ac0dm", - ["vcvt.u32.f64_2"] = "eebc0bc0dGm", - ["vcvtr.s32.f32_2"] = "eebd0a40dm", - ["vcvtr.s32.f64_2"] = "eebd0b40dGm", - ["vcvtr.u32.f32_2"] = "eebc0a40dm", - ["vcvtr.u32.f64_2"] = "eebc0b40dGm", - ["vcvt.f32.s32_2"] = "eeb80ac0dm", - ["vcvt.f64.s32_2"] = "eeb80bc0GdFm", - ["vcvt.f32.u32_2"] = "eeb80a40dm", - ["vcvt.f64.u32_2"] = "eeb80b40GdFm", - ["vcvt.f32.f64_2"] = "eeb70bc0dGm", - ["vcvt.f64.f32_2"] = "eeb70ac0GdFm", - - -- VFPv4 only: - ["vfma.f32_3"] = "eea00a00dnm", - ["vfma.f64_3"] = "eea00b00Gdnm", - ["vfms.f32_3"] = "eea00a40dnm", - ["vfms.f64_3"] = "eea00b40Gdnm", - ["vfnma.f32_3"] = "ee900a40dnm", - ["vfnma.f64_3"] = "ee900b40Gdnm", - ["vfnms.f32_3"] = "ee900a00dnm", - ["vfnms.f64_3"] = "ee900b00Gdnm", - - -- NYI: Advanced SIMD instructions. - - -- NYI: I have no need for these instructions right now: - -- swp, swpb, strex, ldrex, strexd, ldrexd, strexb, ldrexb, strexh, ldrexh - -- msr, nopv6, yield, wfe, wfi, sev, dbg, bxj, smc, srs, rfe - -- cps, setend, pli, pld, pldw, clrex, dsb, dmb, isb - -- stc, ldc, mcr, mcr2, mrc, mrc2, mcrr, mcrr2, mrrc, mrrc2, cdp, cdp2 -} - --- Add mnemonics for "s" variants. -do - local t = {} - for k,v in pairs(map_op) do - if sub(v, -1) == "s" then - local v2 = sub(v, 1, 2)..char(byte(v, 3)+1)..sub(v, 4, -2) - t[sub(k, 1, -3).."s"..sub(k, -2)] = v2 - end - end - for k,v in pairs(t) do - map_op[k] = v - end -end - ------------------------------------------------------------------------------- - -local function parse_gpr(expr) - local tname, ovreg = match(expr, "^([%w_]+):(r1?[0-9])$") - local tp = map_type[tname or expr] - if tp then - local reg = ovreg or tp.reg - if not reg then - werror("type `"..(tname or expr).."' needs a register override") - end - expr = reg - end - local r = match(expr, "^r(1?[0-9])$") - if r then - r = tonumber(r) - if r <= 15 then return r, tp end - end - werror("bad register name `"..expr.."'") -end - -local function parse_gpr_pm(expr) - local pm, expr2 = match(expr, "^([+-]?)(.*)$") - return parse_gpr(expr2), (pm == "-") -end - -local function parse_vr(expr, tp) - local t, r = match(expr, "^([sd])([0-9]+)$") - if t == tp then - r = tonumber(r) - if r <= 31 then - if t == "s" then return shr(r, 1), band(r, 1) end - return band(r, 15), shr(r, 4) - end - end - werror("bad register name `"..expr.."'") -end - -local function parse_reglist(reglist) - reglist = match(reglist, "^{%s*([^}]*)}$") - if not reglist then werror("register list expected") end - local rr = 0 - for p in gmatch(reglist..",", "%s*([^,]*),") do - local rbit = shl(1, parse_gpr(gsub(p, "%s+$", ""))) - if band(rr, rbit) ~= 0 then - werror("duplicate register `"..p.."'") - end - rr = rr + rbit - end - return rr -end - -local function parse_vrlist(reglist) - local ta, ra, tb, rb = match(reglist, - "^{%s*([sd])([0-9]+)%s*%-%s*([sd])([0-9]+)%s*}$") - ra, rb = tonumber(ra), tonumber(rb) - if ta and ta == tb and ra and rb and ra <= 31 and rb <= 31 and ra <= rb then - local nr = rb+1 - ra - if ta == "s" then - return shl(shr(ra,1),12)+shl(band(ra,1),22) + nr - else - return shl(band(ra,15),12)+shl(shr(ra,4),22) + nr*2 + 0x100 - end - end - werror("register list expected") -end - -local function parse_imm(imm, bits, shift, scale, signed) - imm = match(imm, "^#(.*)$") - if not imm then werror("expected immediate operand") end - local n = tonumber(imm) - if n then - local m = sar(n, scale) - if shl(m, scale) == n then - if signed then - local s = sar(m, bits-1) - if s == 0 then return shl(m, shift) - elseif s == -1 then return shl(m + shl(1, bits), shift) end - else - if sar(m, bits) == 0 then return shl(m, shift) end - end - end - werror("out of range immediate `"..imm.."'") - else - waction("IMM", (signed and 32768 or 0)+scale*1024+bits*32+shift, imm) - return 0 - end -end - -local function parse_imm12(imm) - local n = tonumber(imm) - if n then - local m = band(n) - for i=0,-15,-1 do - if shr(m, 8) == 0 then return m + shl(band(i, 15), 8) end - m = ror(m, 2) - end - werror("out of range immediate `"..imm.."'") - else - waction("IMM12", 0, imm) - return 0 - end -end - -local function parse_imm16(imm) - imm = match(imm, "^#(.*)$") - if not imm then werror("expected immediate operand") end - local n = tonumber(imm) - if n then - if shr(n, 16) == 0 then return band(n, 0x0fff) + shl(band(n, 0xf000), 4) end - werror("out of range immediate `"..imm.."'") - else - waction("IMM16", 32*16, imm) - return 0 - end -end - -local function parse_imm_load(imm, ext) - local n = tonumber(imm) - if n then - if ext then - if n >= -255 and n <= 255 then - local up = 0x00800000 - if n < 0 then n = -n; up = 0 end - return shl(band(n, 0xf0), 4) + band(n, 0x0f) + up - end - else - if n >= -4095 and n <= 4095 then - if n >= 0 then return n+0x00800000 end - return -n - end - end - werror("out of range immediate `"..imm.."'") - else - waction(ext and "IMML8" or "IMML12", 32768 + shl(ext and 8 or 12, 5), imm) - return 0 - end -end - -local function parse_shift(shift, gprok) - if shift == "rrx" then - return 3 * 32 - else - local s, s2 = match(shift, "^(%S+)%s*(.*)$") - s = map_shift[s] - if not s then werror("expected shift operand") end - if sub(s2, 1, 1) == "#" then - return parse_imm(s2, 5, 7, 0, false) + shl(s, 5) - else - if not gprok then werror("expected immediate shift operand") end - return shl(parse_gpr(s2), 8) + shl(s, 5) + 16 - end - end -end - -local function parse_label(label, def) - local prefix = sub(label, 1, 2) - -- =>label (pc label reference) - if prefix == "=>" then - return "PC", 0, sub(label, 3) - end - -- ->name (global label reference) - if prefix == "->" then - return "LG", map_global[sub(label, 3)] - end - if def then - -- [1-9] (local label definition) - if match(label, "^[1-9]$") then - return "LG", 10+tonumber(label) - end - else - -- [<>][1-9] (local label reference) - local dir, lnum = match(label, "^([<>])([1-9])$") - if dir then -- Fwd: 1-9, Bkwd: 11-19. - return "LG", lnum + (dir == ">" and 0 or 10) - end - -- extern label (extern label reference) - local extname = match(label, "^extern%s+(%S+)$") - if extname then - return "EXT", map_extern[extname] - end - end - werror("bad label `"..label.."'") -end - -local function parse_load(params, nparams, n, op) - local oplo = band(op, 255) - local ext, ldrd = (oplo ~= 0), (oplo == 208) - local d - if (ldrd or oplo == 240) then - d = band(shr(op, 12), 15) - if band(d, 1) ~= 0 then werror("odd destination register") end - end - local pn = params[n] - local p1, wb = match(pn, "^%[%s*(.-)%s*%](!?)$") - local p2 = params[n+1] - if not p1 then - if not p2 then - if match(pn, "^[<>=%-]") or match(pn, "^extern%s+") then - local mode, n, s = parse_label(pn, false) - waction("REL_"..mode, n + (ext and 0x1800 or 0x0800), s, 1) - return op + 15 * 65536 + 0x01000000 + (ext and 0x00400000 or 0) - end - local reg, tailr = match(pn, "^([%w_:]+)%s*(.*)$") - if reg and tailr ~= "" then - local d, tp = parse_gpr(reg) - if tp then - waction(ext and "IMML8" or "IMML12", 32768 + 32*(ext and 8 or 12), - format(tp.ctypefmt, tailr)) - return op + shl(d, 16) + 0x01000000 + (ext and 0x00400000 or 0) - end - end - end - werror("expected address operand") - end - if wb == "!" then op = op + 0x00200000 end - if p2 then - if wb == "!" then werror("bad use of '!'") end - local p3 = params[n+2] - op = op + shl(parse_gpr(p1), 16) - local imm = match(p2, "^#(.*)$") - if imm then - local m = parse_imm_load(imm, ext) - if p3 then werror("too many parameters") end - op = op + m + (ext and 0x00400000 or 0) - else - local m, neg = parse_gpr_pm(p2) - if ldrd and (m == d or m-1 == d) then werror("register conflict") end - op = op + m + (neg and 0 or 0x00800000) + (ext and 0 or 0x02000000) - if p3 then op = op + parse_shift(p3) end - end - else - local p1a, p2 = match(p1, "^([^,%s]*)%s*(.*)$") - op = op + shl(parse_gpr(p1a), 16) + 0x01000000 - if p2 ~= "" then - local imm = match(p2, "^,%s*#(.*)$") - if imm then - local m = parse_imm_load(imm, ext) - op = op + m + (ext and 0x00400000 or 0) - else - local p2a, p3 = match(p2, "^,%s*([^,%s]*)%s*,?%s*(.*)$") - local m, neg = parse_gpr_pm(p2a) - if ldrd and (m == d or m-1 == d) then werror("register conflict") end - op = op + m + (neg and 0 or 0x00800000) + (ext and 0 or 0x02000000) - if p3 ~= "" then - if ext then werror("too many parameters") end - op = op + parse_shift(p3) - end - end - else - if wb == "!" then werror("bad use of '!'") end - op = op + (ext and 0x00c00000 or 0x00800000) - end - end - return op -end - -local function parse_vload(q) - local reg, imm = match(q, "^%[%s*([^,%s]*)%s*(.*)%]$") - if reg then - local d = shl(parse_gpr(reg), 16) - if imm == "" then return d end - imm = match(imm, "^,%s*#(.*)$") - if imm then - local n = tonumber(imm) - if n then - if n >= -1020 and n <= 1020 and n%4 == 0 then - return d + (n >= 0 and n/4+0x00800000 or -n/4) - end - werror("out of range immediate `"..imm.."'") - else - waction("IMMV8", 32768 + 32*8, imm) - return d - end - end - else - if match(q, "^[<>=%-]") or match(q, "^extern%s+") then - local mode, n, s = parse_label(q, false) - waction("REL_"..mode, n + 0x2800, s, 1) - return 15 * 65536 - end - local reg, tailr = match(q, "^([%w_:]+)%s*(.*)$") - if reg and tailr ~= "" then - local d, tp = parse_gpr(reg) - if tp then - waction("IMMV8", 32768 + 32*8, format(tp.ctypefmt, tailr)) - return shl(d, 16) - end - end - end - werror("expected address operand") -end - ------------------------------------------------------------------------------- - --- Handle opcodes defined with template strings. -local function parse_template(params, template, nparams, pos) - local op = tonumber(sub(template, 1, 8), 16) - local n = 1 - local vr = "s" - - -- Process each character. - for p in gmatch(sub(template, 9), ".") do - local q = params[n] - if p == "D" then - op = op + shl(parse_gpr(q), 12); n = n + 1 - elseif p == "N" then - op = op + shl(parse_gpr(q), 16); n = n + 1 - elseif p == "S" then - op = op + shl(parse_gpr(q), 8); n = n + 1 - elseif p == "M" then - op = op + parse_gpr(q); n = n + 1 - elseif p == "d" then - local r,h = parse_vr(q, vr); op = op+shl(r,12)+shl(h,22); n = n + 1 - elseif p == "n" then - local r,h = parse_vr(q, vr); op = op+shl(r,16)+shl(h,7); n = n + 1 - elseif p == "m" then - local r,h = parse_vr(q, vr); op = op+r+shl(h,5); n = n + 1 - elseif p == "P" then - local imm = match(q, "^#(.*)$") - if imm then - op = op + parse_imm12(imm) + 0x02000000 - else - op = op + parse_gpr(q) - end - n = n + 1 - elseif p == "p" then - op = op + parse_shift(q, true); n = n + 1 - elseif p == "L" then - op = parse_load(params, nparams, n, op) - elseif p == "l" then - op = op + parse_vload(q) - elseif p == "B" then - local mode, n, s = parse_label(q, false) - waction("REL_"..mode, n, s, 1) - elseif p == "C" then -- blx gpr vs. blx label. - if match(q, "^([%w_]+):(r1?[0-9])$") or match(q, "^r(1?[0-9])$") then - op = op + parse_gpr(q) - else - if op < 0xe0000000 then werror("unconditional instruction") end - local mode, n, s = parse_label(q, false) - waction("REL_"..mode, n, s, 1) - op = 0xfa000000 - end - elseif p == "F" then - vr = "s" - elseif p == "G" then - vr = "d" - elseif p == "o" then - local r, wb = match(q, "^([^!]*)(!?)$") - op = op + shl(parse_gpr(r), 16) + (wb == "!" and 0x00200000 or 0) - n = n + 1 - elseif p == "R" then - op = op + parse_reglist(q); n = n + 1 - elseif p == "r" then - op = op + parse_vrlist(q); n = n + 1 - elseif p == "W" then - op = op + parse_imm16(q); n = n + 1 - elseif p == "v" then - op = op + parse_imm(q, 5, 7, 0, false); n = n + 1 - elseif p == "w" then - local imm = match(q, "^#(.*)$") - if imm then - op = op + parse_imm(q, 5, 7, 0, false); n = n + 1 - else - op = op + shl(parse_gpr(q), 8) + 16 - end - elseif p == "X" then - op = op + parse_imm(q, 5, 16, 0, false); n = n + 1 - elseif p == "Y" then - local imm = tonumber(match(q, "^#(.*)$")); n = n + 1 - if not imm or shr(imm, 8) ~= 0 then - werror("bad immediate operand") - end - op = op + shl(band(imm, 0xf0), 12) + band(imm, 0x0f) - elseif p == "K" then - local imm = tonumber(match(q, "^#(.*)$")); n = n + 1 - if not imm or shr(imm, 16) ~= 0 then - werror("bad immediate operand") - end - op = op + shl(band(imm, 0xfff0), 4) + band(imm, 0x000f) - elseif p == "T" then - op = op + parse_imm(q, 24, 0, 0, false); n = n + 1 - elseif p == "s" then - -- Ignored. - else - assert(false) - end - end - wputpos(pos, op) -end - -map_op[".template__"] = function(params, template, nparams) - if not params then return sub(template, 9) end - - -- Limit number of section buffer positions used by a single dasm_put(). - -- A single opcode needs a maximum of 3 positions. - if secpos+3 > maxsecpos then wflush() end - local pos = wpos() - local apos, spos = #actargs, secpos - - local ok, err - for t in gmatch(template, "[^|]+") do - ok, err = pcall(parse_template, params, t, nparams, pos) - if ok then return end - secpos = spos - actargs[apos+1] = nil - actargs[apos+2] = nil - actargs[apos+3] = nil - end - error(err, 0) -end - ------------------------------------------------------------------------------- - --- Pseudo-opcode to mark the position where the action list is to be emitted. -map_op[".actionlist_1"] = function(params) - if not params then return "cvar" end - local name = params[1] -- No syntax check. You get to keep the pieces. - wline(function(out) writeactions(out, name) end) -end - --- Pseudo-opcode to mark the position where the global enum is to be emitted. -map_op[".globals_1"] = function(params) - if not params then return "prefix" end - local prefix = params[1] -- No syntax check. You get to keep the pieces. - wline(function(out) writeglobals(out, prefix) end) -end - --- Pseudo-opcode to mark the position where the global names are to be emitted. -map_op[".globalnames_1"] = function(params) - if not params then return "cvar" end - local name = params[1] -- No syntax check. You get to keep the pieces. - wline(function(out) writeglobalnames(out, name) end) -end - --- Pseudo-opcode to mark the position where the extern names are to be emitted. -map_op[".externnames_1"] = function(params) - if not params then return "cvar" end - local name = params[1] -- No syntax check. You get to keep the pieces. - wline(function(out) writeexternnames(out, name) end) -end - ------------------------------------------------------------------------------- - --- Label pseudo-opcode (converted from trailing colon form). -map_op[".label_1"] = function(params) - if not params then return "[1-9] | ->global | =>pcexpr" end - if secpos+1 > maxsecpos then wflush() end - local mode, n, s = parse_label(params[1], true) - if mode == "EXT" then werror("bad label definition") end - waction("LABEL_"..mode, n, s, 1) -end - ------------------------------------------------------------------------------- - --- Pseudo-opcodes for data storage. -map_op[".long_*"] = function(params) - if not params then return "imm..." end - for _,p in ipairs(params) do - local n = tonumber(p) - if not n then werror("bad immediate `"..p.."'") end - if n < 0 then n = n + 2^32 end - wputw(n) - if secpos+2 > maxsecpos then wflush() end - end -end - --- Alignment pseudo-opcode. -map_op[".align_1"] = function(params) - if not params then return "numpow2" end - if secpos+1 > maxsecpos then wflush() end - local align = tonumber(params[1]) - if align then - local x = align - -- Must be a power of 2 in the range (2 ... 256). - for i=1,8 do - x = x / 2 - if x == 1 then - waction("ALIGN", align-1, nil, 1) -- Action byte is 2**n-1. - return - end - end - end - werror("bad alignment") -end - ------------------------------------------------------------------------------- - --- Pseudo-opcode for (primitive) type definitions (map to C types). -map_op[".type_3"] = function(params, nparams) - if not params then - return nparams == 2 and "name, ctype" or "name, ctype, reg" - end - local name, ctype, reg = params[1], params[2], params[3] - if not match(name, "^[%a_][%w_]*$") then - werror("bad type name `"..name.."'") - end - local tp = map_type[name] - if tp then - werror("duplicate type `"..name.."'") - end - -- Add #type to defines. A bit unclean to put it in map_archdef. - map_archdef["#"..name] = "sizeof("..ctype..")" - -- Add new type and emit shortcut define. - local num = ctypenum + 1 - map_type[name] = { - ctype = ctype, - ctypefmt = format("Dt%X(%%s)", num), - reg = reg, - } - wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype)) - ctypenum = num -end -map_op[".type_2"] = map_op[".type_3"] - --- Dump type definitions. -local function dumptypes(out, lvl) - local t = {} - for name in pairs(map_type) do t[#t+1] = name end - sort(t) - out:write("Type definitions:\n") - for _,name in ipairs(t) do - local tp = map_type[name] - local reg = tp.reg or "" - out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg)) - end - out:write("\n") -end - ------------------------------------------------------------------------------- - --- Set the current section. -function _M.section(num) - waction("SECTION", num) - wflush(true) -- SECTION is a terminal action. -end - ------------------------------------------------------------------------------- - --- Dump architecture description. -function _M.dumparch(out) - out:write(format("DynASM %s version %s, released %s\n\n", - _info.arch, _info.version, _info.release)) - dumpactions(out) -end - --- Dump all user defined elements. -function _M.dumpdef(out, lvl) - dumptypes(out, lvl) - dumpglobals(out, lvl) - dumpexterns(out, lvl) -end - ------------------------------------------------------------------------------- - --- Pass callbacks from/to the DynASM core. -function _M.passcb(wl, we, wf, ww) - wline, werror, wfatal, wwarn = wl, we, wf, ww - return wflush -end - --- Setup the arch-specific module. -function _M.setup(arch, opt) - g_arch, g_opt = arch, opt -end - --- Merge the core maps and the arch-specific maps. -function _M.mergemaps(map_coreop, map_def) - setmetatable(map_op, { __index = function(t, k) - local v = map_coreop[k] - if v then return v end - local k1, cc, k2 = match(k, "^(.-)(..)([._].*)$") - local cv = map_cond[cc] - if cv then - local v = rawget(t, k1..k2) - if type(v) == "string" then - local scv = format("%x", cv) - return gsub(scv..sub(v, 2), "|e", "|"..scv) - end - end - end }) - setmetatable(map_def, { __index = map_archdef }) - return map_op, map_def -end - -return _M - ------------------------------------------------------------------------------- - diff --git a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_mips.h b/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_mips.h deleted file mode 100644 index 435958899..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_mips.h +++ /dev/null @@ -1,416 +0,0 @@ -/* -** DynASM MIPS encoding engine. -** Copyright (C) 2005-2014 Mike Pall. All rights reserved. -** Released under the MIT license. See dynasm.lua for full copyright notice. -*/ - -#include -#include -#include -#include - -#define DASM_ARCH "mips" - -#ifndef DASM_EXTERN -#define DASM_EXTERN(a,b,c,d) 0 -#endif - -/* Action definitions. */ -enum { - DASM_STOP, DASM_SECTION, DASM_ESC, DASM_REL_EXT, - /* The following actions need a buffer position. */ - DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG, - /* The following actions also have an argument. */ - DASM_REL_PC, DASM_LABEL_PC, DASM_IMM, - DASM__MAX -}; - -/* Maximum number of section buffer positions for a single dasm_put() call. */ -#define DASM_MAXSECPOS 25 - -/* DynASM encoder status codes. Action list offset or number are or'ed in. */ -#define DASM_S_OK 0x00000000 -#define DASM_S_NOMEM 0x01000000 -#define DASM_S_PHASE 0x02000000 -#define DASM_S_MATCH_SEC 0x03000000 -#define DASM_S_RANGE_I 0x11000000 -#define DASM_S_RANGE_SEC 0x12000000 -#define DASM_S_RANGE_LG 0x13000000 -#define DASM_S_RANGE_PC 0x14000000 -#define DASM_S_RANGE_REL 0x15000000 -#define DASM_S_UNDEF_LG 0x21000000 -#define DASM_S_UNDEF_PC 0x22000000 - -/* Macros to convert positions (8 bit section + 24 bit index). */ -#define DASM_POS2IDX(pos) ((pos)&0x00ffffff) -#define DASM_POS2BIAS(pos) ((pos)&0xff000000) -#define DASM_SEC2POS(sec) ((sec)<<24) -#define DASM_POS2SEC(pos) ((pos)>>24) -#define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) - -/* Action list type. */ -typedef const unsigned int *dasm_ActList; - -/* Per-section structure. */ -typedef struct dasm_Section { - int *rbuf; /* Biased buffer pointer (negative section bias). */ - int *buf; /* True buffer pointer. */ - size_t bsize; /* Buffer size in bytes. */ - int pos; /* Biased buffer position. */ - int epos; /* End of biased buffer position - max single put. */ - int ofs; /* Byte offset into section. */ -} dasm_Section; - -/* Core structure holding the DynASM encoding state. */ -struct dasm_State { - size_t psize; /* Allocated size of this structure. */ - dasm_ActList actionlist; /* Current actionlist pointer. */ - int *lglabels; /* Local/global chain/pos ptrs. */ - size_t lgsize; - int *pclabels; /* PC label chains/pos ptrs. */ - size_t pcsize; - void **globals; /* Array of globals (bias -10). */ - dasm_Section *section; /* Pointer to active section. */ - size_t codesize; /* Total size of all code sections. */ - int maxsection; /* 0 <= sectionidx < maxsection. */ - int status; /* Status code. */ - dasm_Section sections[1]; /* All sections. Alloc-extended. */ -}; - -/* The size of the core structure depends on the max. number of sections. */ -#define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section)) - - -/* Initialize DynASM state. */ -void dasm_init(Dst_DECL, int maxsection) -{ - dasm_State *D; - size_t psz = 0; - int i; - Dst_REF = NULL; - DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); - D = Dst_REF; - D->psize = psz; - D->lglabels = NULL; - D->lgsize = 0; - D->pclabels = NULL; - D->pcsize = 0; - D->globals = NULL; - D->maxsection = maxsection; - for (i = 0; i < maxsection; i++) { - D->sections[i].buf = NULL; /* Need this for pass3. */ - D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i); - D->sections[i].bsize = 0; - D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ - } -} - -/* Free DynASM state. */ -void dasm_free(Dst_DECL) -{ - dasm_State *D = Dst_REF; - int i; - for (i = 0; i < D->maxsection; i++) - if (D->sections[i].buf) - DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize); - if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize); - if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize); - DASM_M_FREE(Dst, D, D->psize); -} - -/* Setup global label array. Must be called before dasm_setup(). */ -void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) -{ - dasm_State *D = Dst_REF; - D->globals = gl - 10; /* Negative bias to compensate for locals. */ - DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); -} - -/* Grow PC label array. Can be called after dasm_setup(), too. */ -void dasm_growpc(Dst_DECL, unsigned int maxpc) -{ - dasm_State *D = Dst_REF; - size_t osz = D->pcsize; - DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int)); - memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz); -} - -/* Setup encoder. */ -void dasm_setup(Dst_DECL, const void *actionlist) -{ - dasm_State *D = Dst_REF; - int i; - D->actionlist = (dasm_ActList)actionlist; - D->status = DASM_S_OK; - D->section = &D->sections[0]; - memset((void *)D->lglabels, 0, D->lgsize); - if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); - for (i = 0; i < D->maxsection; i++) { - D->sections[i].pos = DASM_SEC2POS(i); - D->sections[i].ofs = 0; - } -} - - -#ifdef DASM_CHECKS -#define CK(x, st) \ - do { if (!(x)) { \ - D->status = DASM_S_##st|(p-D->actionlist-1); return; } } while (0) -#define CKPL(kind, st) \ - do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \ - D->status = DASM_S_RANGE_##st|(p-D->actionlist-1); return; } } while (0) -#else -#define CK(x, st) ((void)0) -#define CKPL(kind, st) ((void)0) -#endif - -/* Pass 1: Store actions and args, link branches/labels, estimate offsets. */ -void dasm_put(Dst_DECL, int start, ...) -{ - va_list ap; - dasm_State *D = Dst_REF; - dasm_ActList p = D->actionlist + start; - dasm_Section *sec = D->section; - int pos = sec->pos, ofs = sec->ofs; - int *b; - - if (pos >= sec->epos) { - DASM_M_GROW(Dst, int, sec->buf, sec->bsize, - sec->bsize + 2*DASM_MAXSECPOS*sizeof(int)); - sec->rbuf = sec->buf - DASM_POS2BIAS(pos); - sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos); - } - - b = sec->rbuf; - b[pos++] = start; - - va_start(ap, start); - while (1) { - unsigned int ins = *p++; - unsigned int action = (ins >> 16) - 0xff00; - if (action >= DASM__MAX) { - ofs += 4; - } else { - int *pl, n = action >= DASM_REL_PC ? va_arg(ap, int) : 0; - switch (action) { - case DASM_STOP: goto stop; - case DASM_SECTION: - n = (ins & 255); CK(n < D->maxsection, RANGE_SEC); - D->section = &D->sections[n]; goto stop; - case DASM_ESC: p++; ofs += 4; break; - case DASM_REL_EXT: break; - case DASM_ALIGN: ofs += (ins & 255); b[pos++] = ofs; break; - case DASM_REL_LG: - n = (ins & 2047) - 10; pl = D->lglabels + n; - /* Bkwd rel or global. */ - if (n >= 0) { CK(n>=10||*pl<0, RANGE_LG); CKPL(lg, LG); goto putrel; } - pl += 10; n = *pl; - if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */ - goto linkrel; - case DASM_REL_PC: - pl = D->pclabels + n; CKPL(pc, PC); - putrel: - n = *pl; - if (n < 0) { /* Label exists. Get label pos and store it. */ - b[pos] = -n; - } else { - linkrel: - b[pos] = n; /* Else link to rel chain, anchored at label. */ - *pl = pos; - } - pos++; - break; - case DASM_LABEL_LG: - pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel; - case DASM_LABEL_PC: - pl = D->pclabels + n; CKPL(pc, PC); - putlabel: - n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */ - while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; - } - *pl = -pos; /* Label exists now. */ - b[pos++] = ofs; /* Store pass1 offset estimate. */ - break; - case DASM_IMM: -#ifdef DASM_CHECKS - CK((n & ((1<<((ins>>10)&31))-1)) == 0, RANGE_I); -#endif - n >>= ((ins>>10)&31); -#ifdef DASM_CHECKS - if (ins & 0x8000) - CK(((n + (1<<(((ins>>5)&31)-1)))>>((ins>>5)&31)) == 0, RANGE_I); - else - CK((n>>((ins>>5)&31)) == 0, RANGE_I); -#endif - b[pos++] = n; - break; - } - } - } -stop: - va_end(ap); - sec->pos = pos; - sec->ofs = ofs; -} -#undef CK - -/* Pass 2: Link sections, shrink aligns, fix label offsets. */ -int dasm_link(Dst_DECL, size_t *szp) -{ - dasm_State *D = Dst_REF; - int secnum; - int ofs = 0; - -#ifdef DASM_CHECKS - *szp = 0; - if (D->status != DASM_S_OK) return D->status; - { - int pc; - for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) - if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; - } -#endif - - { /* Handle globals not defined in this translation unit. */ - int idx; - for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) { - int n = D->lglabels[idx]; - /* Undefined label: Collapse rel chain and replace with marker (< 0). */ - while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } - } - } - - /* Combine all code sections. No support for data sections (yet). */ - for (secnum = 0; secnum < D->maxsection; secnum++) { - dasm_Section *sec = D->sections + secnum; - int *b = sec->rbuf; - int pos = DASM_SEC2POS(secnum); - int lastpos = sec->pos; - - while (pos != lastpos) { - dasm_ActList p = D->actionlist + b[pos++]; - while (1) { - unsigned int ins = *p++; - unsigned int action = (ins >> 16) - 0xff00; - switch (action) { - case DASM_STOP: case DASM_SECTION: goto stop; - case DASM_ESC: p++; break; - case DASM_REL_EXT: break; - case DASM_ALIGN: ofs -= (b[pos++] + ofs) & (ins & 255); break; - case DASM_REL_LG: case DASM_REL_PC: pos++; break; - case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break; - case DASM_IMM: pos++; break; - } - } - stop: (void)0; - } - ofs += sec->ofs; /* Next section starts right after current section. */ - } - - D->codesize = ofs; /* Total size of all code sections */ - *szp = ofs; - return DASM_S_OK; -} - -#ifdef DASM_CHECKS -#define CK(x, st) \ - do { if (!(x)) return DASM_S_##st|(p-D->actionlist-1); } while (0) -#else -#define CK(x, st) ((void)0) -#endif - -/* Pass 3: Encode sections. */ -int dasm_encode(Dst_DECL, void *buffer) -{ - dasm_State *D = Dst_REF; - char *base = (char *)buffer; - unsigned int *cp = (unsigned int *)buffer; - int secnum; - - /* Encode all code sections. No support for data sections (yet). */ - for (secnum = 0; secnum < D->maxsection; secnum++) { - dasm_Section *sec = D->sections + secnum; - int *b = sec->buf; - int *endb = sec->rbuf + sec->pos; - - while (b != endb) { - dasm_ActList p = D->actionlist + *b++; - while (1) { - unsigned int ins = *p++; - unsigned int action = (ins >> 16) - 0xff00; - int n = (action >= DASM_ALIGN && action < DASM__MAX) ? *b++ : 0; - switch (action) { - case DASM_STOP: case DASM_SECTION: goto stop; - case DASM_ESC: *cp++ = *p++; break; - case DASM_REL_EXT: - n = DASM_EXTERN(Dst, (unsigned char *)cp, (ins & 2047), 1); - goto patchrel; - case DASM_ALIGN: - ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0x60000000; - break; - case DASM_REL_LG: - CK(n >= 0, UNDEF_LG); - case DASM_REL_PC: - CK(n >= 0, UNDEF_PC); - n = *DASM_POS2PTR(D, n); - if (ins & 2048) - n = n - (int)((char *)cp - base); - else - n = (n + (int)base) & 0x0fffffff; - patchrel: - CK((n & 3) == 0 && - ((n + ((ins & 2048) ? 0x00020000 : 0)) >> - ((ins & 2048) ? 18 : 28)) == 0, RANGE_REL); - cp[-1] |= ((n>>2) & ((ins & 2048) ? 0x0000ffff: 0x03ffffff)); - break; - case DASM_LABEL_LG: - ins &= 2047; if (ins >= 20) D->globals[ins-10] = (void *)(base + n); - break; - case DASM_LABEL_PC: break; - case DASM_IMM: - cp[-1] |= (n & ((1<<((ins>>5)&31))-1)) << (ins&31); - break; - default: *cp++ = ins; break; - } - } - stop: (void)0; - } - } - - if (base + D->codesize != (char *)cp) /* Check for phase errors. */ - return DASM_S_PHASE; - return DASM_S_OK; -} -#undef CK - -/* Get PC label offset. */ -int dasm_getpclabel(Dst_DECL, unsigned int pc) -{ - dasm_State *D = Dst_REF; - if (pc*sizeof(int) < D->pcsize) { - int pos = D->pclabels[pc]; - if (pos < 0) return *DASM_POS2PTR(D, -pos); - if (pos > 0) return -1; /* Undefined. */ - } - return -2; /* Unused or out of range. */ -} - -#ifdef DASM_CHECKS -/* Optional sanity checker to call between isolated encoding steps. */ -int dasm_checkstep(Dst_DECL, int secmatch) -{ - dasm_State *D = Dst_REF; - if (D->status == DASM_S_OK) { - int i; - for (i = 1; i <= 9; i++) { - if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_LG|i; break; } - D->lglabels[i] = 0; - } - } - if (D->status == DASM_S_OK && secmatch >= 0 && - D->section != &D->sections[secmatch]) - D->status = DASM_S_MATCH_SEC|(D->section-D->sections); - return D->status; -} -#endif - diff --git a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_mips.lua b/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_mips.lua deleted file mode 100644 index 82942cbb5..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_mips.lua +++ /dev/null @@ -1,953 +0,0 @@ ------------------------------------------------------------------------------- --- DynASM MIPS module. --- --- Copyright (C) 2005-2014 Mike Pall. All rights reserved. --- See dynasm.lua for full copyright notice. ------------------------------------------------------------------------------- - --- Module information: -local _info = { - arch = "mips", - description = "DynASM MIPS module", - version = "1.3.0", - vernum = 10300, - release = "2012-01-23", - author = "Mike Pall", - license = "MIT", -} - --- Exported glue functions for the arch-specific module. -local _M = { _info = _info } - --- Cache library functions. -local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs -local assert, setmetatable = assert, setmetatable -local _s = string -local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char -local match, gmatch = _s.match, _s.gmatch -local concat, sort = table.concat, table.sort -local bit = bit or require("bit") -local band, shl, sar, tohex = bit.band, bit.lshift, bit.arshift, bit.tohex - --- Inherited tables and callbacks. -local g_opt, g_arch -local wline, werror, wfatal, wwarn - --- Action name list. --- CHECK: Keep this in sync with the C code! -local action_names = { - "STOP", "SECTION", "ESC", "REL_EXT", - "ALIGN", "REL_LG", "LABEL_LG", - "REL_PC", "LABEL_PC", "IMM", -} - --- Maximum number of section buffer positions for dasm_put(). --- CHECK: Keep this in sync with the C code! -local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines. - --- Action name -> action number. -local map_action = {} -for n,name in ipairs(action_names) do - map_action[name] = n-1 -end - --- Action list buffer. -local actlist = {} - --- Argument list for next dasm_put(). Start with offset 0 into action list. -local actargs = { 0 } - --- Current number of section buffer positions for dasm_put(). -local secpos = 1 - ------------------------------------------------------------------------------- - --- Dump action names and numbers. -local function dumpactions(out) - out:write("DynASM encoding engine action codes:\n") - for n,name in ipairs(action_names) do - local num = map_action[name] - out:write(format(" %-10s %02X %d\n", name, num, num)) - end - out:write("\n") -end - --- Write action list buffer as a huge static C array. -local function writeactions(out, name) - local nn = #actlist - if nn == 0 then nn = 1; actlist[0] = map_action.STOP end - out:write("static const unsigned int ", name, "[", nn, "] = {\n") - for i = 1,nn-1 do - assert(out:write("0x", tohex(actlist[i]), ",\n")) - end - assert(out:write("0x", tohex(actlist[nn]), "\n};\n\n")) -end - ------------------------------------------------------------------------------- - --- Add word to action list. -local function wputxw(n) - assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") - actlist[#actlist+1] = n -end - --- Add action to list with optional arg. Advance buffer pos, too. -local function waction(action, val, a, num) - local w = assert(map_action[action], "bad action name `"..action.."'") - wputxw(0xff000000 + w * 0x10000 + (val or 0)) - if a then actargs[#actargs+1] = a end - if a or num then secpos = secpos + (num or 1) end -end - --- Flush action list (intervening C code or buffer pos overflow). -local function wflush(term) - if #actlist == actargs[1] then return end -- Nothing to flush. - if not term then waction("STOP") end -- Terminate action list. - wline(format("dasm_put(Dst, %s);", concat(actargs, ", ")), true) - actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put(). - secpos = 1 -- The actionlist offset occupies a buffer position, too. -end - --- Put escaped word. -local function wputw(n) - if n >= 0xff000000 then waction("ESC") end - wputxw(n) -end - --- Reserve position for word. -local function wpos() - local pos = #actlist+1 - actlist[pos] = "" - return pos -end - --- Store word to reserved position. -local function wputpos(pos, n) - assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") - actlist[pos] = n -end - ------------------------------------------------------------------------------- - --- Global label name -> global label number. With auto assignment on 1st use. -local next_global = 20 -local map_global = setmetatable({}, { __index = function(t, name) - if not match(name, "^[%a_][%w_]*$") then werror("bad global label") end - local n = next_global - if n > 2047 then werror("too many global labels") end - next_global = n + 1 - t[name] = n - return n -end}) - --- Dump global labels. -local function dumpglobals(out, lvl) - local t = {} - for name, n in pairs(map_global) do t[n] = name end - out:write("Global labels:\n") - for i=20,next_global-1 do - out:write(format(" %s\n", t[i])) - end - out:write("\n") -end - --- Write global label enum. -local function writeglobals(out, prefix) - local t = {} - for name, n in pairs(map_global) do t[n] = name end - out:write("enum {\n") - for i=20,next_global-1 do - out:write(" ", prefix, t[i], ",\n") - end - out:write(" ", prefix, "_MAX\n};\n") -end - --- Write global label names. -local function writeglobalnames(out, name) - local t = {} - for name, n in pairs(map_global) do t[n] = name end - out:write("static const char *const ", name, "[] = {\n") - for i=20,next_global-1 do - out:write(" \"", t[i], "\",\n") - end - out:write(" (const char *)0\n};\n") -end - ------------------------------------------------------------------------------- - --- Extern label name -> extern label number. With auto assignment on 1st use. -local next_extern = 0 -local map_extern_ = {} -local map_extern = setmetatable({}, { __index = function(t, name) - -- No restrictions on the name for now. - local n = next_extern - if n > 2047 then werror("too many extern labels") end - next_extern = n + 1 - t[name] = n - map_extern_[n] = name - return n -end}) - --- Dump extern labels. -local function dumpexterns(out, lvl) - out:write("Extern labels:\n") - for i=0,next_extern-1 do - out:write(format(" %s\n", map_extern_[i])) - end - out:write("\n") -end - --- Write extern label names. -local function writeexternnames(out, name) - out:write("static const char *const ", name, "[] = {\n") - for i=0,next_extern-1 do - out:write(" \"", map_extern_[i], "\",\n") - end - out:write(" (const char *)0\n};\n") -end - ------------------------------------------------------------------------------- - --- Arch-specific maps. -local map_archdef = { sp="r29", ra="r31" } -- Ext. register name -> int. name. - -local map_type = {} -- Type name -> { ctype, reg } -local ctypenum = 0 -- Type number (for Dt... macros). - --- Reverse defines for registers. -function _M.revdef(s) - if s == "r29" then return "sp" - elseif s == "r31" then return "ra" end - return s -end - ------------------------------------------------------------------------------- - --- Template strings for MIPS instructions. -local map_op = { - -- First-level opcodes. - j_1 = "08000000J", - jal_1 = "0c000000J", - b_1 = "10000000B", - beqz_2 = "10000000SB", - beq_3 = "10000000STB", - bnez_2 = "14000000SB", - bne_3 = "14000000STB", - blez_2 = "18000000SB", - bgtz_2 = "1c000000SB", - addi_3 = "20000000TSI", - li_2 = "24000000TI", - addiu_3 = "24000000TSI", - slti_3 = "28000000TSI", - sltiu_3 = "2c000000TSI", - andi_3 = "30000000TSU", - lu_2 = "34000000TU", - ori_3 = "34000000TSU", - xori_3 = "38000000TSU", - lui_2 = "3c000000TU", - beqzl_2 = "50000000SB", - beql_3 = "50000000STB", - bnezl_2 = "54000000SB", - bnel_3 = "54000000STB", - blezl_2 = "58000000SB", - bgtzl_2 = "5c000000SB", - lb_2 = "80000000TO", - lh_2 = "84000000TO", - lwl_2 = "88000000TO", - lw_2 = "8c000000TO", - lbu_2 = "90000000TO", - lhu_2 = "94000000TO", - lwr_2 = "98000000TO", - sb_2 = "a0000000TO", - sh_2 = "a4000000TO", - swl_2 = "a8000000TO", - sw_2 = "ac000000TO", - swr_2 = "b8000000TO", - cache_2 = "bc000000NO", - ll_2 = "c0000000TO", - lwc1_2 = "c4000000HO", - pref_2 = "cc000000NO", - ldc1_2 = "d4000000HO", - sc_2 = "e0000000TO", - swc1_2 = "e4000000HO", - sdc1_2 = "f4000000HO", - - -- Opcode SPECIAL. - nop_0 = "00000000", - sll_3 = "00000000DTA", - movf_2 = "00000001DS", - movf_3 = "00000001DSC", - movt_2 = "00010001DS", - movt_3 = "00010001DSC", - srl_3 = "00000002DTA", - rotr_3 = "00200002DTA", - sra_3 = "00000003DTA", - sllv_3 = "00000004DTS", - srlv_3 = "00000006DTS", - rotrv_3 = "00000046DTS", - srav_3 = "00000007DTS", - jr_1 = "00000008S", - jalr_1 = "0000f809S", - jalr_2 = "00000009DS", - movz_3 = "0000000aDST", - movn_3 = "0000000bDST", - syscall_0 = "0000000c", - syscall_1 = "0000000cY", - break_0 = "0000000d", - break_1 = "0000000dY", - sync_0 = "0000000f", - mfhi_1 = "00000010D", - mthi_1 = "00000011S", - mflo_1 = "00000012D", - mtlo_1 = "00000013S", - mult_2 = "00000018ST", - multu_2 = "00000019ST", - div_2 = "0000001aST", - divu_2 = "0000001bST", - add_3 = "00000020DST", - move_2 = "00000021DS", - addu_3 = "00000021DST", - sub_3 = "00000022DST", - negu_2 = "00000023DT", - subu_3 = "00000023DST", - and_3 = "00000024DST", - or_3 = "00000025DST", - xor_3 = "00000026DST", - not_2 = "00000027DS", - nor_3 = "00000027DST", - slt_3 = "0000002aDST", - sltu_3 = "0000002bDST", - tge_2 = "00000030ST", - tge_3 = "00000030STZ", - tgeu_2 = "00000031ST", - tgeu_3 = "00000031STZ", - tlt_2 = "00000032ST", - tlt_3 = "00000032STZ", - tltu_2 = "00000033ST", - tltu_3 = "00000033STZ", - teq_2 = "00000034ST", - teq_3 = "00000034STZ", - tne_2 = "00000036ST", - tne_3 = "00000036STZ", - - -- Opcode REGIMM. - bltz_2 = "04000000SB", - bgez_2 = "04010000SB", - bltzl_2 = "04020000SB", - bgezl_2 = "04030000SB", - tgei_2 = "04080000SI", - tgeiu_2 = "04090000SI", - tlti_2 = "040a0000SI", - tltiu_2 = "040b0000SI", - teqi_2 = "040c0000SI", - tnei_2 = "040e0000SI", - bltzal_2 = "04100000SB", - bal_1 = "04110000B", - bgezal_2 = "04110000SB", - bltzall_2 = "04120000SB", - bgezall_2 = "04130000SB", - synci_1 = "041f0000O", - - -- Opcode SPECIAL2. - madd_2 = "70000000ST", - maddu_2 = "70000001ST", - mul_3 = "70000002DST", - msub_2 = "70000004ST", - msubu_2 = "70000005ST", - clz_2 = "70000020DS=", - clo_2 = "70000021DS=", - sdbbp_0 = "7000003f", - sdbbp_1 = "7000003fY", - - -- Opcode SPECIAL3. - ext_4 = "7c000000TSAM", -- Note: last arg is msbd = size-1 - ins_4 = "7c000004TSAM", -- Note: last arg is msb = pos+size-1 - wsbh_2 = "7c0000a0DT", - seb_2 = "7c000420DT", - seh_2 = "7c000620DT", - rdhwr_2 = "7c00003bTD", - - -- Opcode COP0. - mfc0_2 = "40000000TD", - mfc0_3 = "40000000TDW", - mtc0_2 = "40800000TD", - mtc0_3 = "40800000TDW", - rdpgpr_2 = "41400000DT", - di_0 = "41606000", - di_1 = "41606000T", - ei_0 = "41606020", - ei_1 = "41606020T", - wrpgpr_2 = "41c00000DT", - tlbr_0 = "42000001", - tlbwi_0 = "42000002", - tlbwr_0 = "42000006", - tlbp_0 = "42000008", - eret_0 = "42000018", - deret_0 = "4200001f", - wait_0 = "42000020", - - -- Opcode COP1. - mfc1_2 = "44000000TG", - cfc1_2 = "44400000TG", - mfhc1_2 = "44600000TG", - mtc1_2 = "44800000TG", - ctc1_2 = "44c00000TG", - mthc1_2 = "44e00000TG", - - bc1f_1 = "45000000B", - bc1f_2 = "45000000CB", - bc1t_1 = "45010000B", - bc1t_2 = "45010000CB", - bc1fl_1 = "45020000B", - bc1fl_2 = "45020000CB", - bc1tl_1 = "45030000B", - bc1tl_2 = "45030000CB", - - ["add.s_3"] = "46000000FGH", - ["sub.s_3"] = "46000001FGH", - ["mul.s_3"] = "46000002FGH", - ["div.s_3"] = "46000003FGH", - ["sqrt.s_2"] = "46000004FG", - ["abs.s_2"] = "46000005FG", - ["mov.s_2"] = "46000006FG", - ["neg.s_2"] = "46000007FG", - ["round.l.s_2"] = "46000008FG", - ["trunc.l.s_2"] = "46000009FG", - ["ceil.l.s_2"] = "4600000aFG", - ["floor.l.s_2"] = "4600000bFG", - ["round.w.s_2"] = "4600000cFG", - ["trunc.w.s_2"] = "4600000dFG", - ["ceil.w.s_2"] = "4600000eFG", - ["floor.w.s_2"] = "4600000fFG", - ["movf.s_2"] = "46000011FG", - ["movf.s_3"] = "46000011FGC", - ["movt.s_2"] = "46010011FG", - ["movt.s_3"] = "46010011FGC", - ["movz.s_3"] = "46000012FGT", - ["movn.s_3"] = "46000013FGT", - ["recip.s_2"] = "46000015FG", - ["rsqrt.s_2"] = "46000016FG", - ["cvt.d.s_2"] = "46000021FG", - ["cvt.w.s_2"] = "46000024FG", - ["cvt.l.s_2"] = "46000025FG", - ["cvt.ps.s_3"] = "46000026FGH", - ["c.f.s_2"] = "46000030GH", - ["c.f.s_3"] = "46000030VGH", - ["c.un.s_2"] = "46000031GH", - ["c.un.s_3"] = "46000031VGH", - ["c.eq.s_2"] = "46000032GH", - ["c.eq.s_3"] = "46000032VGH", - ["c.ueq.s_2"] = "46000033GH", - ["c.ueq.s_3"] = "46000033VGH", - ["c.olt.s_2"] = "46000034GH", - ["c.olt.s_3"] = "46000034VGH", - ["c.ult.s_2"] = "46000035GH", - ["c.ult.s_3"] = "46000035VGH", - ["c.ole.s_2"] = "46000036GH", - ["c.ole.s_3"] = "46000036VGH", - ["c.ule.s_2"] = "46000037GH", - ["c.ule.s_3"] = "46000037VGH", - ["c.sf.s_2"] = "46000038GH", - ["c.sf.s_3"] = "46000038VGH", - ["c.ngle.s_2"] = "46000039GH", - ["c.ngle.s_3"] = "46000039VGH", - ["c.seq.s_2"] = "4600003aGH", - ["c.seq.s_3"] = "4600003aVGH", - ["c.ngl.s_2"] = "4600003bGH", - ["c.ngl.s_3"] = "4600003bVGH", - ["c.lt.s_2"] = "4600003cGH", - ["c.lt.s_3"] = "4600003cVGH", - ["c.nge.s_2"] = "4600003dGH", - ["c.nge.s_3"] = "4600003dVGH", - ["c.le.s_2"] = "4600003eGH", - ["c.le.s_3"] = "4600003eVGH", - ["c.ngt.s_2"] = "4600003fGH", - ["c.ngt.s_3"] = "4600003fVGH", - - ["add.d_3"] = "46200000FGH", - ["sub.d_3"] = "46200001FGH", - ["mul.d_3"] = "46200002FGH", - ["div.d_3"] = "46200003FGH", - ["sqrt.d_2"] = "46200004FG", - ["abs.d_2"] = "46200005FG", - ["mov.d_2"] = "46200006FG", - ["neg.d_2"] = "46200007FG", - ["round.l.d_2"] = "46200008FG", - ["trunc.l.d_2"] = "46200009FG", - ["ceil.l.d_2"] = "4620000aFG", - ["floor.l.d_2"] = "4620000bFG", - ["round.w.d_2"] = "4620000cFG", - ["trunc.w.d_2"] = "4620000dFG", - ["ceil.w.d_2"] = "4620000eFG", - ["floor.w.d_2"] = "4620000fFG", - ["movf.d_2"] = "46200011FG", - ["movf.d_3"] = "46200011FGC", - ["movt.d_2"] = "46210011FG", - ["movt.d_3"] = "46210011FGC", - ["movz.d_3"] = "46200012FGT", - ["movn.d_3"] = "46200013FGT", - ["recip.d_2"] = "46200015FG", - ["rsqrt.d_2"] = "46200016FG", - ["cvt.s.d_2"] = "46200020FG", - ["cvt.w.d_2"] = "46200024FG", - ["cvt.l.d_2"] = "46200025FG", - ["c.f.d_2"] = "46200030GH", - ["c.f.d_3"] = "46200030VGH", - ["c.un.d_2"] = "46200031GH", - ["c.un.d_3"] = "46200031VGH", - ["c.eq.d_2"] = "46200032GH", - ["c.eq.d_3"] = "46200032VGH", - ["c.ueq.d_2"] = "46200033GH", - ["c.ueq.d_3"] = "46200033VGH", - ["c.olt.d_2"] = "46200034GH", - ["c.olt.d_3"] = "46200034VGH", - ["c.ult.d_2"] = "46200035GH", - ["c.ult.d_3"] = "46200035VGH", - ["c.ole.d_2"] = "46200036GH", - ["c.ole.d_3"] = "46200036VGH", - ["c.ule.d_2"] = "46200037GH", - ["c.ule.d_3"] = "46200037VGH", - ["c.sf.d_2"] = "46200038GH", - ["c.sf.d_3"] = "46200038VGH", - ["c.ngle.d_2"] = "46200039GH", - ["c.ngle.d_3"] = "46200039VGH", - ["c.seq.d_2"] = "4620003aGH", - ["c.seq.d_3"] = "4620003aVGH", - ["c.ngl.d_2"] = "4620003bGH", - ["c.ngl.d_3"] = "4620003bVGH", - ["c.lt.d_2"] = "4620003cGH", - ["c.lt.d_3"] = "4620003cVGH", - ["c.nge.d_2"] = "4620003dGH", - ["c.nge.d_3"] = "4620003dVGH", - ["c.le.d_2"] = "4620003eGH", - ["c.le.d_3"] = "4620003eVGH", - ["c.ngt.d_2"] = "4620003fGH", - ["c.ngt.d_3"] = "4620003fVGH", - - ["add.ps_3"] = "46c00000FGH", - ["sub.ps_3"] = "46c00001FGH", - ["mul.ps_3"] = "46c00002FGH", - ["abs.ps_2"] = "46c00005FG", - ["mov.ps_2"] = "46c00006FG", - ["neg.ps_2"] = "46c00007FG", - ["movf.ps_2"] = "46c00011FG", - ["movf.ps_3"] = "46c00011FGC", - ["movt.ps_2"] = "46c10011FG", - ["movt.ps_3"] = "46c10011FGC", - ["movz.ps_3"] = "46c00012FGT", - ["movn.ps_3"] = "46c00013FGT", - ["cvt.s.pu_2"] = "46c00020FG", - ["cvt.s.pl_2"] = "46c00028FG", - ["pll.ps_3"] = "46c0002cFGH", - ["plu.ps_3"] = "46c0002dFGH", - ["pul.ps_3"] = "46c0002eFGH", - ["puu.ps_3"] = "46c0002fFGH", - ["c.f.ps_2"] = "46c00030GH", - ["c.f.ps_3"] = "46c00030VGH", - ["c.un.ps_2"] = "46c00031GH", - ["c.un.ps_3"] = "46c00031VGH", - ["c.eq.ps_2"] = "46c00032GH", - ["c.eq.ps_3"] = "46c00032VGH", - ["c.ueq.ps_2"] = "46c00033GH", - ["c.ueq.ps_3"] = "46c00033VGH", - ["c.olt.ps_2"] = "46c00034GH", - ["c.olt.ps_3"] = "46c00034VGH", - ["c.ult.ps_2"] = "46c00035GH", - ["c.ult.ps_3"] = "46c00035VGH", - ["c.ole.ps_2"] = "46c00036GH", - ["c.ole.ps_3"] = "46c00036VGH", - ["c.ule.ps_2"] = "46c00037GH", - ["c.ule.ps_3"] = "46c00037VGH", - ["c.sf.ps_2"] = "46c00038GH", - ["c.sf.ps_3"] = "46c00038VGH", - ["c.ngle.ps_2"] = "46c00039GH", - ["c.ngle.ps_3"] = "46c00039VGH", - ["c.seq.ps_2"] = "46c0003aGH", - ["c.seq.ps_3"] = "46c0003aVGH", - ["c.ngl.ps_2"] = "46c0003bGH", - ["c.ngl.ps_3"] = "46c0003bVGH", - ["c.lt.ps_2"] = "46c0003cGH", - ["c.lt.ps_3"] = "46c0003cVGH", - ["c.nge.ps_2"] = "46c0003dGH", - ["c.nge.ps_3"] = "46c0003dVGH", - ["c.le.ps_2"] = "46c0003eGH", - ["c.le.ps_3"] = "46c0003eVGH", - ["c.ngt.ps_2"] = "46c0003fGH", - ["c.ngt.ps_3"] = "46c0003fVGH", - - ["cvt.s.w_2"] = "46800020FG", - ["cvt.d.w_2"] = "46800021FG", - - ["cvt.s.l_2"] = "46a00020FG", - ["cvt.d.l_2"] = "46a00021FG", - - -- Opcode COP1X. - lwxc1_2 = "4c000000FX", - ldxc1_2 = "4c000001FX", - luxc1_2 = "4c000005FX", - swxc1_2 = "4c000008FX", - sdxc1_2 = "4c000009FX", - suxc1_2 = "4c00000dFX", - prefx_2 = "4c00000fMX", - ["alnv.ps_4"] = "4c00001eFGHS", - ["madd.s_4"] = "4c000020FRGH", - ["madd.d_4"] = "4c000021FRGH", - ["madd.ps_4"] = "4c000026FRGH", - ["msub.s_4"] = "4c000028FRGH", - ["msub.d_4"] = "4c000029FRGH", - ["msub.ps_4"] = "4c00002eFRGH", - ["nmadd.s_4"] = "4c000030FRGH", - ["nmadd.d_4"] = "4c000031FRGH", - ["nmadd.ps_4"] = "4c000036FRGH", - ["nmsub.s_4"] = "4c000038FRGH", - ["nmsub.d_4"] = "4c000039FRGH", - ["nmsub.ps_4"] = "4c00003eFRGH", -} - ------------------------------------------------------------------------------- - -local function parse_gpr(expr) - local tname, ovreg = match(expr, "^([%w_]+):(r[1-3]?[0-9])$") - local tp = map_type[tname or expr] - if tp then - local reg = ovreg or tp.reg - if not reg then - werror("type `"..(tname or expr).."' needs a register override") - end - expr = reg - end - local r = match(expr, "^r([1-3]?[0-9])$") - if r then - r = tonumber(r) - if r <= 31 then return r, tp end - end - werror("bad register name `"..expr.."'") -end - -local function parse_fpr(expr) - local r = match(expr, "^f([1-3]?[0-9])$") - if r then - r = tonumber(r) - if r <= 31 then return r end - end - werror("bad register name `"..expr.."'") -end - -local function parse_imm(imm, bits, shift, scale, signed) - local n = tonumber(imm) - if n then - local m = sar(n, scale) - if shl(m, scale) == n then - if signed then - local s = sar(m, bits-1) - if s == 0 then return shl(m, shift) - elseif s == -1 then return shl(m + shl(1, bits), shift) end - else - if sar(m, bits) == 0 then return shl(m, shift) end - end - end - werror("out of range immediate `"..imm.."'") - elseif match(imm, "^[rf]([1-3]?[0-9])$") or - match(imm, "^([%w_]+):([rf][1-3]?[0-9])$") then - werror("expected immediate operand, got register") - else - waction("IMM", (signed and 32768 or 0)+scale*1024+bits*32+shift, imm) - return 0 - end -end - -local function parse_disp(disp) - local imm, reg = match(disp, "^(.*)%(([%w_:]+)%)$") - if imm then - local r = shl(parse_gpr(reg), 21) - local extname = match(imm, "^extern%s+(%S+)$") - if extname then - waction("REL_EXT", map_extern[extname], nil, 1) - return r - else - return r + parse_imm(imm, 16, 0, 0, true) - end - end - local reg, tailr = match(disp, "^([%w_:]+)%s*(.*)$") - if reg and tailr ~= "" then - local r, tp = parse_gpr(reg) - if tp then - waction("IMM", 32768+16*32, format(tp.ctypefmt, tailr)) - return shl(r, 21) - end - end - werror("bad displacement `"..disp.."'") -end - -local function parse_index(idx) - local rt, rs = match(idx, "^(.*)%(([%w_:]+)%)$") - if rt then - rt = parse_gpr(rt) - rs = parse_gpr(rs) - return shl(rt, 16) + shl(rs, 21) - end - werror("bad index `"..idx.."'") -end - -local function parse_label(label, def) - local prefix = sub(label, 1, 2) - -- =>label (pc label reference) - if prefix == "=>" then - return "PC", 0, sub(label, 3) - end - -- ->name (global label reference) - if prefix == "->" then - return "LG", map_global[sub(label, 3)] - end - if def then - -- [1-9] (local label definition) - if match(label, "^[1-9]$") then - return "LG", 10+tonumber(label) - end - else - -- [<>][1-9] (local label reference) - local dir, lnum = match(label, "^([<>])([1-9])$") - if dir then -- Fwd: 1-9, Bkwd: 11-19. - return "LG", lnum + (dir == ">" and 0 or 10) - end - -- extern label (extern label reference) - local extname = match(label, "^extern%s+(%S+)$") - if extname then - return "EXT", map_extern[extname] - end - end - werror("bad label `"..label.."'") -end - ------------------------------------------------------------------------------- - --- Handle opcodes defined with template strings. -map_op[".template__"] = function(params, template, nparams) - if not params then return sub(template, 9) end - local op = tonumber(sub(template, 1, 8), 16) - local n = 1 - - -- Limit number of section buffer positions used by a single dasm_put(). - -- A single opcode needs a maximum of 2 positions (ins/ext). - if secpos+2 > maxsecpos then wflush() end - local pos = wpos() - - -- Process each character. - for p in gmatch(sub(template, 9), ".") do - if p == "D" then - op = op + shl(parse_gpr(params[n]), 11); n = n + 1 - elseif p == "T" then - op = op + shl(parse_gpr(params[n]), 16); n = n + 1 - elseif p == "S" then - op = op + shl(parse_gpr(params[n]), 21); n = n + 1 - elseif p == "F" then - op = op + shl(parse_fpr(params[n]), 6); n = n + 1 - elseif p == "G" then - op = op + shl(parse_fpr(params[n]), 11); n = n + 1 - elseif p == "H" then - op = op + shl(parse_fpr(params[n]), 16); n = n + 1 - elseif p == "R" then - op = op + shl(parse_fpr(params[n]), 21); n = n + 1 - elseif p == "I" then - op = op + parse_imm(params[n], 16, 0, 0, true); n = n + 1 - elseif p == "U" then - op = op + parse_imm(params[n], 16, 0, 0, false); n = n + 1 - elseif p == "O" then - op = op + parse_disp(params[n]); n = n + 1 - elseif p == "X" then - op = op + parse_index(params[n]); n = n + 1 - elseif p == "B" or p == "J" then - local mode, n, s = parse_label(params[n], false) - if p == "B" then n = n + 2048 end - waction("REL_"..mode, n, s, 1) - n = n + 1 - elseif p == "A" then - op = op + parse_imm(params[n], 5, 6, 0, false); n = n + 1 - elseif p == "M" then - op = op + parse_imm(params[n], 5, 11, 0, false); n = n + 1 - elseif p == "N" then - op = op + parse_imm(params[n], 5, 16, 0, false); n = n + 1 - elseif p == "C" then - op = op + parse_imm(params[n], 3, 18, 0, false); n = n + 1 - elseif p == "V" then - op = op + parse_imm(params[n], 3, 8, 0, false); n = n + 1 - elseif p == "W" then - op = op + parse_imm(params[n], 3, 0, 0, false); n = n + 1 - elseif p == "Y" then - op = op + parse_imm(params[n], 20, 6, 0, false); n = n + 1 - elseif p == "Z" then - op = op + parse_imm(params[n], 10, 6, 0, false); n = n + 1 - elseif p == "=" then - op = op + shl(band(op, 0xf800), 5) -- Copy D to T for clz, clo. - else - assert(false) - end - end - wputpos(pos, op) -end - ------------------------------------------------------------------------------- - --- Pseudo-opcode to mark the position where the action list is to be emitted. -map_op[".actionlist_1"] = function(params) - if not params then return "cvar" end - local name = params[1] -- No syntax check. You get to keep the pieces. - wline(function(out) writeactions(out, name) end) -end - --- Pseudo-opcode to mark the position where the global enum is to be emitted. -map_op[".globals_1"] = function(params) - if not params then return "prefix" end - local prefix = params[1] -- No syntax check. You get to keep the pieces. - wline(function(out) writeglobals(out, prefix) end) -end - --- Pseudo-opcode to mark the position where the global names are to be emitted. -map_op[".globalnames_1"] = function(params) - if not params then return "cvar" end - local name = params[1] -- No syntax check. You get to keep the pieces. - wline(function(out) writeglobalnames(out, name) end) -end - --- Pseudo-opcode to mark the position where the extern names are to be emitted. -map_op[".externnames_1"] = function(params) - if not params then return "cvar" end - local name = params[1] -- No syntax check. You get to keep the pieces. - wline(function(out) writeexternnames(out, name) end) -end - ------------------------------------------------------------------------------- - --- Label pseudo-opcode (converted from trailing colon form). -map_op[".label_1"] = function(params) - if not params then return "[1-9] | ->global | =>pcexpr" end - if secpos+1 > maxsecpos then wflush() end - local mode, n, s = parse_label(params[1], true) - if mode == "EXT" then werror("bad label definition") end - waction("LABEL_"..mode, n, s, 1) -end - ------------------------------------------------------------------------------- - --- Pseudo-opcodes for data storage. -map_op[".long_*"] = function(params) - if not params then return "imm..." end - for _,p in ipairs(params) do - local n = tonumber(p) - if not n then werror("bad immediate `"..p.."'") end - if n < 0 then n = n + 2^32 end - wputw(n) - if secpos+2 > maxsecpos then wflush() end - end -end - --- Alignment pseudo-opcode. -map_op[".align_1"] = function(params) - if not params then return "numpow2" end - if secpos+1 > maxsecpos then wflush() end - local align = tonumber(params[1]) - if align then - local x = align - -- Must be a power of 2 in the range (2 ... 256). - for i=1,8 do - x = x / 2 - if x == 1 then - waction("ALIGN", align-1, nil, 1) -- Action byte is 2**n-1. - return - end - end - end - werror("bad alignment") -end - ------------------------------------------------------------------------------- - --- Pseudo-opcode for (primitive) type definitions (map to C types). -map_op[".type_3"] = function(params, nparams) - if not params then - return nparams == 2 and "name, ctype" or "name, ctype, reg" - end - local name, ctype, reg = params[1], params[2], params[3] - if not match(name, "^[%a_][%w_]*$") then - werror("bad type name `"..name.."'") - end - local tp = map_type[name] - if tp then - werror("duplicate type `"..name.."'") - end - -- Add #type to defines. A bit unclean to put it in map_archdef. - map_archdef["#"..name] = "sizeof("..ctype..")" - -- Add new type and emit shortcut define. - local num = ctypenum + 1 - map_type[name] = { - ctype = ctype, - ctypefmt = format("Dt%X(%%s)", num), - reg = reg, - } - wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype)) - ctypenum = num -end -map_op[".type_2"] = map_op[".type_3"] - --- Dump type definitions. -local function dumptypes(out, lvl) - local t = {} - for name in pairs(map_type) do t[#t+1] = name end - sort(t) - out:write("Type definitions:\n") - for _,name in ipairs(t) do - local tp = map_type[name] - local reg = tp.reg or "" - out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg)) - end - out:write("\n") -end - ------------------------------------------------------------------------------- - --- Set the current section. -function _M.section(num) - waction("SECTION", num) - wflush(true) -- SECTION is a terminal action. -end - ------------------------------------------------------------------------------- - --- Dump architecture description. -function _M.dumparch(out) - out:write(format("DynASM %s version %s, released %s\n\n", - _info.arch, _info.version, _info.release)) - dumpactions(out) -end - --- Dump all user defined elements. -function _M.dumpdef(out, lvl) - dumptypes(out, lvl) - dumpglobals(out, lvl) - dumpexterns(out, lvl) -end - ------------------------------------------------------------------------------- - --- Pass callbacks from/to the DynASM core. -function _M.passcb(wl, we, wf, ww) - wline, werror, wfatal, wwarn = wl, we, wf, ww - return wflush -end - --- Setup the arch-specific module. -function _M.setup(arch, opt) - g_arch, g_opt = arch, opt -end - --- Merge the core maps and the arch-specific maps. -function _M.mergemaps(map_coreop, map_def) - setmetatable(map_op, { __index = map_coreop }) - setmetatable(map_def, { __index = map_archdef }) - return map_op, map_def -end - -return _M - ------------------------------------------------------------------------------- - diff --git a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_ppc.h b/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_ppc.h deleted file mode 100644 index 5ccff250f..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_ppc.h +++ /dev/null @@ -1,412 +0,0 @@ -/* -** DynASM PPC encoding engine. -** Copyright (C) 2005-2014 Mike Pall. All rights reserved. -** Released under the MIT license. See dynasm.lua for full copyright notice. -*/ - -#include -#include -#include -#include - -#define DASM_ARCH "ppc" - -#ifndef DASM_EXTERN -#define DASM_EXTERN(a,b,c,d) 0 -#endif - -/* Action definitions. */ -enum { - DASM_STOP, DASM_SECTION, DASM_ESC, DASM_REL_EXT, - /* The following actions need a buffer position. */ - DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG, - /* The following actions also have an argument. */ - DASM_REL_PC, DASM_LABEL_PC, DASM_IMM, - DASM__MAX -}; - -/* Maximum number of section buffer positions for a single dasm_put() call. */ -#define DASM_MAXSECPOS 25 - -/* DynASM encoder status codes. Action list offset or number are or'ed in. */ -#define DASM_S_OK 0x00000000 -#define DASM_S_NOMEM 0x01000000 -#define DASM_S_PHASE 0x02000000 -#define DASM_S_MATCH_SEC 0x03000000 -#define DASM_S_RANGE_I 0x11000000 -#define DASM_S_RANGE_SEC 0x12000000 -#define DASM_S_RANGE_LG 0x13000000 -#define DASM_S_RANGE_PC 0x14000000 -#define DASM_S_RANGE_REL 0x15000000 -#define DASM_S_UNDEF_LG 0x21000000 -#define DASM_S_UNDEF_PC 0x22000000 - -/* Macros to convert positions (8 bit section + 24 bit index). */ -#define DASM_POS2IDX(pos) ((pos)&0x00ffffff) -#define DASM_POS2BIAS(pos) ((pos)&0xff000000) -#define DASM_SEC2POS(sec) ((sec)<<24) -#define DASM_POS2SEC(pos) ((pos)>>24) -#define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) - -/* Action list type. */ -typedef const unsigned int *dasm_ActList; - -/* Per-section structure. */ -typedef struct dasm_Section { - int *rbuf; /* Biased buffer pointer (negative section bias). */ - int *buf; /* True buffer pointer. */ - size_t bsize; /* Buffer size in bytes. */ - int pos; /* Biased buffer position. */ - int epos; /* End of biased buffer position - max single put. */ - int ofs; /* Byte offset into section. */ -} dasm_Section; - -/* Core structure holding the DynASM encoding state. */ -struct dasm_State { - size_t psize; /* Allocated size of this structure. */ - dasm_ActList actionlist; /* Current actionlist pointer. */ - int *lglabels; /* Local/global chain/pos ptrs. */ - size_t lgsize; - int *pclabels; /* PC label chains/pos ptrs. */ - size_t pcsize; - void **globals; /* Array of globals (bias -10). */ - dasm_Section *section; /* Pointer to active section. */ - size_t codesize; /* Total size of all code sections. */ - int maxsection; /* 0 <= sectionidx < maxsection. */ - int status; /* Status code. */ - dasm_Section sections[1]; /* All sections. Alloc-extended. */ -}; - -/* The size of the core structure depends on the max. number of sections. */ -#define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section)) - - -/* Initialize DynASM state. */ -void dasm_init(Dst_DECL, int maxsection) -{ - dasm_State *D; - size_t psz = 0; - int i; - Dst_REF = NULL; - DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); - D = Dst_REF; - D->psize = psz; - D->lglabels = NULL; - D->lgsize = 0; - D->pclabels = NULL; - D->pcsize = 0; - D->globals = NULL; - D->maxsection = maxsection; - for (i = 0; i < maxsection; i++) { - D->sections[i].buf = NULL; /* Need this for pass3. */ - D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i); - D->sections[i].bsize = 0; - D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ - } -} - -/* Free DynASM state. */ -void dasm_free(Dst_DECL) -{ - dasm_State *D = Dst_REF; - int i; - for (i = 0; i < D->maxsection; i++) - if (D->sections[i].buf) - DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize); - if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize); - if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize); - DASM_M_FREE(Dst, D, D->psize); -} - -/* Setup global label array. Must be called before dasm_setup(). */ -void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) -{ - dasm_State *D = Dst_REF; - D->globals = gl - 10; /* Negative bias to compensate for locals. */ - DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); -} - -/* Grow PC label array. Can be called after dasm_setup(), too. */ -void dasm_growpc(Dst_DECL, unsigned int maxpc) -{ - dasm_State *D = Dst_REF; - size_t osz = D->pcsize; - DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int)); - memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz); -} - -/* Setup encoder. */ -void dasm_setup(Dst_DECL, const void *actionlist) -{ - dasm_State *D = Dst_REF; - int i; - D->actionlist = (dasm_ActList)actionlist; - D->status = DASM_S_OK; - D->section = &D->sections[0]; - memset((void *)D->lglabels, 0, D->lgsize); - if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); - for (i = 0; i < D->maxsection; i++) { - D->sections[i].pos = DASM_SEC2POS(i); - D->sections[i].ofs = 0; - } -} - - -#ifdef DASM_CHECKS -#define CK(x, st) \ - do { if (!(x)) { \ - D->status = DASM_S_##st|(p-D->actionlist-1); return; } } while (0) -#define CKPL(kind, st) \ - do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \ - D->status = DASM_S_RANGE_##st|(p-D->actionlist-1); return; } } while (0) -#else -#define CK(x, st) ((void)0) -#define CKPL(kind, st) ((void)0) -#endif - -/* Pass 1: Store actions and args, link branches/labels, estimate offsets. */ -void dasm_put(Dst_DECL, int start, ...) -{ - va_list ap; - dasm_State *D = Dst_REF; - dasm_ActList p = D->actionlist + start; - dasm_Section *sec = D->section; - int pos = sec->pos, ofs = sec->ofs; - int *b; - - if (pos >= sec->epos) { - DASM_M_GROW(Dst, int, sec->buf, sec->bsize, - sec->bsize + 2*DASM_MAXSECPOS*sizeof(int)); - sec->rbuf = sec->buf - DASM_POS2BIAS(pos); - sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos); - } - - b = sec->rbuf; - b[pos++] = start; - - va_start(ap, start); - while (1) { - unsigned int ins = *p++; - unsigned int action = (ins >> 16); - if (action >= DASM__MAX) { - ofs += 4; - } else { - int *pl, n = action >= DASM_REL_PC ? va_arg(ap, int) : 0; - switch (action) { - case DASM_STOP: goto stop; - case DASM_SECTION: - n = (ins & 255); CK(n < D->maxsection, RANGE_SEC); - D->section = &D->sections[n]; goto stop; - case DASM_ESC: p++; ofs += 4; break; - case DASM_REL_EXT: break; - case DASM_ALIGN: ofs += (ins & 255); b[pos++] = ofs; break; - case DASM_REL_LG: - n = (ins & 2047) - 10; pl = D->lglabels + n; - /* Bkwd rel or global. */ - if (n >= 0) { CK(n>=10||*pl<0, RANGE_LG); CKPL(lg, LG); goto putrel; } - pl += 10; n = *pl; - if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */ - goto linkrel; - case DASM_REL_PC: - pl = D->pclabels + n; CKPL(pc, PC); - putrel: - n = *pl; - if (n < 0) { /* Label exists. Get label pos and store it. */ - b[pos] = -n; - } else { - linkrel: - b[pos] = n; /* Else link to rel chain, anchored at label. */ - *pl = pos; - } - pos++; - break; - case DASM_LABEL_LG: - pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel; - case DASM_LABEL_PC: - pl = D->pclabels + n; CKPL(pc, PC); - putlabel: - n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */ - while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; - } - *pl = -pos; /* Label exists now. */ - b[pos++] = ofs; /* Store pass1 offset estimate. */ - break; - case DASM_IMM: -#ifdef DASM_CHECKS - CK((n & ((1<<((ins>>10)&31))-1)) == 0, RANGE_I); -#endif - n >>= ((ins>>10)&31); -#ifdef DASM_CHECKS - if (ins & 0x8000) - CK(((n + (1<<(((ins>>5)&31)-1)))>>((ins>>5)&31)) == 0, RANGE_I); - else - CK((n>>((ins>>5)&31)) == 0, RANGE_I); -#endif - b[pos++] = n; - break; - } - } - } -stop: - va_end(ap); - sec->pos = pos; - sec->ofs = ofs; -} -#undef CK - -/* Pass 2: Link sections, shrink aligns, fix label offsets. */ -int dasm_link(Dst_DECL, size_t *szp) -{ - dasm_State *D = Dst_REF; - int secnum; - int ofs = 0; - -#ifdef DASM_CHECKS - *szp = 0; - if (D->status != DASM_S_OK) return D->status; - { - int pc; - for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) - if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; - } -#endif - - { /* Handle globals not defined in this translation unit. */ - int idx; - for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) { - int n = D->lglabels[idx]; - /* Undefined label: Collapse rel chain and replace with marker (< 0). */ - while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } - } - } - - /* Combine all code sections. No support for data sections (yet). */ - for (secnum = 0; secnum < D->maxsection; secnum++) { - dasm_Section *sec = D->sections + secnum; - int *b = sec->rbuf; - int pos = DASM_SEC2POS(secnum); - int lastpos = sec->pos; - - while (pos != lastpos) { - dasm_ActList p = D->actionlist + b[pos++]; - while (1) { - unsigned int ins = *p++; - unsigned int action = (ins >> 16); - switch (action) { - case DASM_STOP: case DASM_SECTION: goto stop; - case DASM_ESC: p++; break; - case DASM_REL_EXT: break; - case DASM_ALIGN: ofs -= (b[pos++] + ofs) & (ins & 255); break; - case DASM_REL_LG: case DASM_REL_PC: pos++; break; - case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break; - case DASM_IMM: pos++; break; - } - } - stop: (void)0; - } - ofs += sec->ofs; /* Next section starts right after current section. */ - } - - D->codesize = ofs; /* Total size of all code sections */ - *szp = ofs; - return DASM_S_OK; -} - -#ifdef DASM_CHECKS -#define CK(x, st) \ - do { if (!(x)) return DASM_S_##st|(p-D->actionlist-1); } while (0) -#else -#define CK(x, st) ((void)0) -#endif - -/* Pass 3: Encode sections. */ -int dasm_encode(Dst_DECL, void *buffer) -{ - dasm_State *D = Dst_REF; - char *base = (char *)buffer; - unsigned int *cp = (unsigned int *)buffer; - int secnum; - - /* Encode all code sections. No support for data sections (yet). */ - for (secnum = 0; secnum < D->maxsection; secnum++) { - dasm_Section *sec = D->sections + secnum; - int *b = sec->buf; - int *endb = sec->rbuf + sec->pos; - - while (b != endb) { - dasm_ActList p = D->actionlist + *b++; - while (1) { - unsigned int ins = *p++; - unsigned int action = (ins >> 16); - int n = (action >= DASM_ALIGN && action < DASM__MAX) ? *b++ : 0; - switch (action) { - case DASM_STOP: case DASM_SECTION: goto stop; - case DASM_ESC: *cp++ = *p++; break; - case DASM_REL_EXT: - n = DASM_EXTERN(Dst, (unsigned char *)cp, (ins & 2047), 1) - 4; - goto patchrel; - case DASM_ALIGN: - ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0x60000000; - break; - case DASM_REL_LG: - CK(n >= 0, UNDEF_LG); - case DASM_REL_PC: - CK(n >= 0, UNDEF_PC); - n = *DASM_POS2PTR(D, n) - (int)((char *)cp - base); - patchrel: - CK((n & 3) == 0 && - (((n+4) + ((ins & 2048) ? 0x00008000 : 0x02000000)) >> - ((ins & 2048) ? 16 : 26)) == 0, RANGE_REL); - cp[-1] |= ((n+4) & ((ins & 2048) ? 0x0000fffc: 0x03fffffc)); - break; - case DASM_LABEL_LG: - ins &= 2047; if (ins >= 20) D->globals[ins-10] = (void *)(base + n); - break; - case DASM_LABEL_PC: break; - case DASM_IMM: - cp[-1] |= (n & ((1<<((ins>>5)&31))-1)) << (ins&31); - break; - default: *cp++ = ins; break; - } - } - stop: (void)0; - } - } - - if (base + D->codesize != (char *)cp) /* Check for phase errors. */ - return DASM_S_PHASE; - return DASM_S_OK; -} -#undef CK - -/* Get PC label offset. */ -int dasm_getpclabel(Dst_DECL, unsigned int pc) -{ - dasm_State *D = Dst_REF; - if (pc*sizeof(int) < D->pcsize) { - int pos = D->pclabels[pc]; - if (pos < 0) return *DASM_POS2PTR(D, -pos); - if (pos > 0) return -1; /* Undefined. */ - } - return -2; /* Unused or out of range. */ -} - -#ifdef DASM_CHECKS -/* Optional sanity checker to call between isolated encoding steps. */ -int dasm_checkstep(Dst_DECL, int secmatch) -{ - dasm_State *D = Dst_REF; - if (D->status == DASM_S_OK) { - int i; - for (i = 1; i <= 9; i++) { - if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_LG|i; break; } - D->lglabels[i] = 0; - } - } - if (D->status == DASM_S_OK && secmatch >= 0 && - D->section != &D->sections[secmatch]) - D->status = DASM_S_MATCH_SEC|(D->section-D->sections); - return D->status; -} -#endif - diff --git a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_ppc.lua b/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_ppc.lua deleted file mode 100644 index 61da50efb..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_ppc.lua +++ /dev/null @@ -1,1249 +0,0 @@ ------------------------------------------------------------------------------- --- DynASM PPC module. --- --- Copyright (C) 2005-2014 Mike Pall. All rights reserved. --- See dynasm.lua for full copyright notice. ------------------------------------------------------------------------------- - --- Module information: -local _info = { - arch = "ppc", - description = "DynASM PPC module", - version = "1.3.0", - vernum = 10300, - release = "2011-05-05", - author = "Mike Pall", - license = "MIT", -} - --- Exported glue functions for the arch-specific module. -local _M = { _info = _info } - --- Cache library functions. -local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs -local assert, setmetatable = assert, setmetatable -local _s = string -local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char -local match, gmatch = _s.match, _s.gmatch -local concat, sort = table.concat, table.sort -local bit = bit or require("bit") -local band, shl, shr, sar = bit.band, bit.lshift, bit.rshift, bit.arshift -local tohex = bit.tohex - --- Inherited tables and callbacks. -local g_opt, g_arch -local wline, werror, wfatal, wwarn - --- Action name list. --- CHECK: Keep this in sync with the C code! -local action_names = { - "STOP", "SECTION", "ESC", "REL_EXT", - "ALIGN", "REL_LG", "LABEL_LG", - "REL_PC", "LABEL_PC", "IMM", -} - --- Maximum number of section buffer positions for dasm_put(). --- CHECK: Keep this in sync with the C code! -local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines. - --- Action name -> action number. -local map_action = {} -for n,name in ipairs(action_names) do - map_action[name] = n-1 -end - --- Action list buffer. -local actlist = {} - --- Argument list for next dasm_put(). Start with offset 0 into action list. -local actargs = { 0 } - --- Current number of section buffer positions for dasm_put(). -local secpos = 1 - ------------------------------------------------------------------------------- - --- Dump action names and numbers. -local function dumpactions(out) - out:write("DynASM encoding engine action codes:\n") - for n,name in ipairs(action_names) do - local num = map_action[name] - out:write(format(" %-10s %02X %d\n", name, num, num)) - end - out:write("\n") -end - --- Write action list buffer as a huge static C array. -local function writeactions(out, name) - local nn = #actlist - if nn == 0 then nn = 1; actlist[0] = map_action.STOP end - out:write("static const unsigned int ", name, "[", nn, "] = {\n") - for i = 1,nn-1 do - assert(out:write("0x", tohex(actlist[i]), ",\n")) - end - assert(out:write("0x", tohex(actlist[nn]), "\n};\n\n")) -end - ------------------------------------------------------------------------------- - --- Add word to action list. -local function wputxw(n) - assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") - actlist[#actlist+1] = n -end - --- Add action to list with optional arg. Advance buffer pos, too. -local function waction(action, val, a, num) - local w = assert(map_action[action], "bad action name `"..action.."'") - wputxw(w * 0x10000 + (val or 0)) - if a then actargs[#actargs+1] = a end - if a or num then secpos = secpos + (num or 1) end -end - --- Flush action list (intervening C code or buffer pos overflow). -local function wflush(term) - if #actlist == actargs[1] then return end -- Nothing to flush. - if not term then waction("STOP") end -- Terminate action list. - wline(format("dasm_put(Dst, %s);", concat(actargs, ", ")), true) - actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put(). - secpos = 1 -- The actionlist offset occupies a buffer position, too. -end - --- Put escaped word. -local function wputw(n) - if n <= 0xffffff then waction("ESC") end - wputxw(n) -end - --- Reserve position for word. -local function wpos() - local pos = #actlist+1 - actlist[pos] = "" - return pos -end - --- Store word to reserved position. -local function wputpos(pos, n) - assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") - actlist[pos] = n -end - ------------------------------------------------------------------------------- - --- Global label name -> global label number. With auto assignment on 1st use. -local next_global = 20 -local map_global = setmetatable({}, { __index = function(t, name) - if not match(name, "^[%a_][%w_]*$") then werror("bad global label") end - local n = next_global - if n > 2047 then werror("too many global labels") end - next_global = n + 1 - t[name] = n - return n -end}) - --- Dump global labels. -local function dumpglobals(out, lvl) - local t = {} - for name, n in pairs(map_global) do t[n] = name end - out:write("Global labels:\n") - for i=20,next_global-1 do - out:write(format(" %s\n", t[i])) - end - out:write("\n") -end - --- Write global label enum. -local function writeglobals(out, prefix) - local t = {} - for name, n in pairs(map_global) do t[n] = name end - out:write("enum {\n") - for i=20,next_global-1 do - out:write(" ", prefix, t[i], ",\n") - end - out:write(" ", prefix, "_MAX\n};\n") -end - --- Write global label names. -local function writeglobalnames(out, name) - local t = {} - for name, n in pairs(map_global) do t[n] = name end - out:write("static const char *const ", name, "[] = {\n") - for i=20,next_global-1 do - out:write(" \"", t[i], "\",\n") - end - out:write(" (const char *)0\n};\n") -end - ------------------------------------------------------------------------------- - --- Extern label name -> extern label number. With auto assignment on 1st use. -local next_extern = 0 -local map_extern_ = {} -local map_extern = setmetatable({}, { __index = function(t, name) - -- No restrictions on the name for now. - local n = next_extern - if n > 2047 then werror("too many extern labels") end - next_extern = n + 1 - t[name] = n - map_extern_[n] = name - return n -end}) - --- Dump extern labels. -local function dumpexterns(out, lvl) - out:write("Extern labels:\n") - for i=0,next_extern-1 do - out:write(format(" %s\n", map_extern_[i])) - end - out:write("\n") -end - --- Write extern label names. -local function writeexternnames(out, name) - out:write("static const char *const ", name, "[] = {\n") - for i=0,next_extern-1 do - out:write(" \"", map_extern_[i], "\",\n") - end - out:write(" (const char *)0\n};\n") -end - ------------------------------------------------------------------------------- - --- Arch-specific maps. -local map_archdef = { sp = "r1" } -- Ext. register name -> int. name. - -local map_type = {} -- Type name -> { ctype, reg } -local ctypenum = 0 -- Type number (for Dt... macros). - --- Reverse defines for registers. -function _M.revdef(s) - if s == "r1" then return "sp" end - return s -end - -local map_cond = { - lt = 0, gt = 1, eq = 2, so = 3, - ge = 4, le = 5, ne = 6, ns = 7, -} - ------------------------------------------------------------------------------- - --- Template strings for PPC instructions. -local map_op = { - tdi_3 = "08000000ARI", - twi_3 = "0c000000ARI", - mulli_3 = "1c000000RRI", - subfic_3 = "20000000RRI", - cmplwi_3 = "28000000XRU", - cmplwi_2 = "28000000-RU", - cmpldi_3 = "28200000XRU", - cmpldi_2 = "28200000-RU", - cmpwi_3 = "2c000000XRI", - cmpwi_2 = "2c000000-RI", - cmpdi_3 = "2c200000XRI", - cmpdi_2 = "2c200000-RI", - addic_3 = "30000000RRI", - ["addic._3"] = "34000000RRI", - addi_3 = "38000000RR0I", - li_2 = "38000000RI", - la_2 = "38000000RD", - addis_3 = "3c000000RR0I", - lis_2 = "3c000000RI", - lus_2 = "3c000000RU", - bc_3 = "40000000AAK", - bcl_3 = "40000001AAK", - bdnz_1 = "42000000K", - bdz_1 = "42400000K", - sc_0 = "44000000", - b_1 = "48000000J", - bl_1 = "48000001J", - rlwimi_5 = "50000000RR~AAA.", - rlwinm_5 = "54000000RR~AAA.", - rlwnm_5 = "5c000000RR~RAA.", - ori_3 = "60000000RR~U", - nop_0 = "60000000", - oris_3 = "64000000RR~U", - xori_3 = "68000000RR~U", - xoris_3 = "6c000000RR~U", - ["andi._3"] = "70000000RR~U", - ["andis._3"] = "74000000RR~U", - lwz_2 = "80000000RD", - lwzu_2 = "84000000RD", - lbz_2 = "88000000RD", - lbzu_2 = "8c000000RD", - stw_2 = "90000000RD", - stwu_2 = "94000000RD", - stb_2 = "98000000RD", - stbu_2 = "9c000000RD", - lhz_2 = "a0000000RD", - lhzu_2 = "a4000000RD", - lha_2 = "a8000000RD", - lhau_2 = "ac000000RD", - sth_2 = "b0000000RD", - sthu_2 = "b4000000RD", - lmw_2 = "b8000000RD", - stmw_2 = "bc000000RD", - lfs_2 = "c0000000FD", - lfsu_2 = "c4000000FD", - lfd_2 = "c8000000FD", - lfdu_2 = "cc000000FD", - stfs_2 = "d0000000FD", - stfsu_2 = "d4000000FD", - stfd_2 = "d8000000FD", - stfdu_2 = "dc000000FD", - ld_2 = "e8000000RD", -- NYI: displacement must be divisible by 4. - ldu_2 = "e8000001RD", - lwa_2 = "e8000002RD", - std_2 = "f8000000RD", - stdu_2 = "f8000001RD", - - -- Primary opcode 19: - mcrf_2 = "4c000000XX", - isync_0 = "4c00012c", - crnor_3 = "4c000042CCC", - crnot_2 = "4c000042CC=", - crandc_3 = "4c000102CCC", - crxor_3 = "4c000182CCC", - crclr_1 = "4c000182C==", - crnand_3 = "4c0001c2CCC", - crand_3 = "4c000202CCC", - creqv_3 = "4c000242CCC", - crset_1 = "4c000242C==", - crorc_3 = "4c000342CCC", - cror_3 = "4c000382CCC", - crmove_2 = "4c000382CC=", - bclr_2 = "4c000020AA", - bclrl_2 = "4c000021AA", - bcctr_2 = "4c000420AA", - bcctrl_2 = "4c000421AA", - blr_0 = "4e800020", - blrl_0 = "4e800021", - bctr_0 = "4e800420", - bctrl_0 = "4e800421", - - -- Primary opcode 31: - cmpw_3 = "7c000000XRR", - cmpw_2 = "7c000000-RR", - cmpd_3 = "7c200000XRR", - cmpd_2 = "7c200000-RR", - tw_3 = "7c000008ARR", - subfc_3 = "7c000010RRR.", - subc_3 = "7c000010RRR~.", - mulhdu_3 = "7c000012RRR.", - addc_3 = "7c000014RRR.", - mulhwu_3 = "7c000016RRR.", - isel_4 = "7c00001eRRRC", - isellt_3 = "7c00001eRRR", - iselgt_3 = "7c00005eRRR", - iseleq_3 = "7c00009eRRR", - mfcr_1 = "7c000026R", - mfocrf_2 = "7c100026RG", - mtcrf_2 = "7c000120GR", - mtocrf_2 = "7c100120GR", - lwarx_3 = "7c000028RR0R", - ldx_3 = "7c00002aRR0R", - lwzx_3 = "7c00002eRR0R", - slw_3 = "7c000030RR~R.", - cntlzw_2 = "7c000034RR~", - sld_3 = "7c000036RR~R.", - and_3 = "7c000038RR~R.", - cmplw_3 = "7c000040XRR", - cmplw_2 = "7c000040-RR", - cmpld_3 = "7c200040XRR", - cmpld_2 = "7c200040-RR", - subf_3 = "7c000050RRR.", - sub_3 = "7c000050RRR~.", - ldux_3 = "7c00006aRR0R", - dcbst_2 = "7c00006c-RR", - lwzux_3 = "7c00006eRR0R", - cntlzd_2 = "7c000074RR~", - andc_3 = "7c000078RR~R.", - td_3 = "7c000088ARR", - mulhd_3 = "7c000092RRR.", - mulhw_3 = "7c000096RRR.", - ldarx_3 = "7c0000a8RR0R", - dcbf_2 = "7c0000ac-RR", - lbzx_3 = "7c0000aeRR0R", - neg_2 = "7c0000d0RR.", - lbzux_3 = "7c0000eeRR0R", - popcntb_2 = "7c0000f4RR~", - not_2 = "7c0000f8RR~%.", - nor_3 = "7c0000f8RR~R.", - subfe_3 = "7c000110RRR.", - sube_3 = "7c000110RRR~.", - adde_3 = "7c000114RRR.", - stdx_3 = "7c00012aRR0R", - stwcx_3 = "7c00012cRR0R.", - stwx_3 = "7c00012eRR0R", - prtyw_2 = "7c000134RR~", - stdux_3 = "7c00016aRR0R", - stwux_3 = "7c00016eRR0R", - prtyd_2 = "7c000174RR~", - subfze_2 = "7c000190RR.", - addze_2 = "7c000194RR.", - stdcx_3 = "7c0001acRR0R.", - stbx_3 = "7c0001aeRR0R", - subfme_2 = "7c0001d0RR.", - mulld_3 = "7c0001d2RRR.", - addme_2 = "7c0001d4RR.", - mullw_3 = "7c0001d6RRR.", - dcbtst_2 = "7c0001ec-RR", - stbux_3 = "7c0001eeRR0R", - add_3 = "7c000214RRR.", - dcbt_2 = "7c00022c-RR", - lhzx_3 = "7c00022eRR0R", - eqv_3 = "7c000238RR~R.", - eciwx_3 = "7c00026cRR0R", - lhzux_3 = "7c00026eRR0R", - xor_3 = "7c000278RR~R.", - mfspefscr_1 = "7c0082a6R", - mfxer_1 = "7c0102a6R", - mflr_1 = "7c0802a6R", - mfctr_1 = "7c0902a6R", - lwax_3 = "7c0002aaRR0R", - lhax_3 = "7c0002aeRR0R", - mftb_1 = "7c0c42e6R", - mftbu_1 = "7c0d42e6R", - lwaux_3 = "7c0002eaRR0R", - lhaux_3 = "7c0002eeRR0R", - sthx_3 = "7c00032eRR0R", - orc_3 = "7c000338RR~R.", - ecowx_3 = "7c00036cRR0R", - sthux_3 = "7c00036eRR0R", - or_3 = "7c000378RR~R.", - mr_2 = "7c000378RR~%.", - divdu_3 = "7c000392RRR.", - divwu_3 = "7c000396RRR.", - mtspefscr_1 = "7c0083a6R", - mtxer_1 = "7c0103a6R", - mtlr_1 = "7c0803a6R", - mtctr_1 = "7c0903a6R", - dcbi_2 = "7c0003ac-RR", - nand_3 = "7c0003b8RR~R.", - divd_3 = "7c0003d2RRR.", - divw_3 = "7c0003d6RRR.", - cmpb_3 = "7c0003f8RR~R.", - mcrxr_1 = "7c000400X", - subfco_3 = "7c000410RRR.", - subco_3 = "7c000410RRR~.", - addco_3 = "7c000414RRR.", - ldbrx_3 = "7c000428RR0R", - lswx_3 = "7c00042aRR0R", - lwbrx_3 = "7c00042cRR0R", - lfsx_3 = "7c00042eFR0R", - srw_3 = "7c000430RR~R.", - srd_3 = "7c000436RR~R.", - subfo_3 = "7c000450RRR.", - subo_3 = "7c000450RRR~.", - lfsux_3 = "7c00046eFR0R", - lswi_3 = "7c0004aaRR0A", - sync_0 = "7c0004ac", - lwsync_0 = "7c2004ac", - ptesync_0 = "7c4004ac", - lfdx_3 = "7c0004aeFR0R", - nego_2 = "7c0004d0RR.", - lfdux_3 = "7c0004eeFR0R", - subfeo_3 = "7c000510RRR.", - subeo_3 = "7c000510RRR~.", - addeo_3 = "7c000514RRR.", - stdbrx_3 = "7c000528RR0R", - stswx_3 = "7c00052aRR0R", - stwbrx_3 = "7c00052cRR0R", - stfsx_3 = "7c00052eFR0R", - stfsux_3 = "7c00056eFR0R", - subfzeo_2 = "7c000590RR.", - addzeo_2 = "7c000594RR.", - stswi_3 = "7c0005aaRR0A", - stfdx_3 = "7c0005aeFR0R", - subfmeo_2 = "7c0005d0RR.", - mulldo_3 = "7c0005d2RRR.", - addmeo_2 = "7c0005d4RR.", - mullwo_3 = "7c0005d6RRR.", - dcba_2 = "7c0005ec-RR", - stfdux_3 = "7c0005eeFR0R", - addo_3 = "7c000614RRR.", - lhbrx_3 = "7c00062cRR0R", - sraw_3 = "7c000630RR~R.", - srad_3 = "7c000634RR~R.", - srawi_3 = "7c000670RR~A.", - sradi_3 = "7c000674RR~H.", - eieio_0 = "7c0006ac", - lfiwax_3 = "7c0006aeFR0R", - sthbrx_3 = "7c00072cRR0R", - extsh_2 = "7c000734RR~.", - extsb_2 = "7c000774RR~.", - divduo_3 = "7c000792RRR.", - divwou_3 = "7c000796RRR.", - icbi_2 = "7c0007ac-RR", - stfiwx_3 = "7c0007aeFR0R", - extsw_2 = "7c0007b4RR~.", - divdo_3 = "7c0007d2RRR.", - divwo_3 = "7c0007d6RRR.", - dcbz_2 = "7c0007ec-RR", - - -- Primary opcode 30: - rldicl_4 = "78000000RR~HM.", - rldicr_4 = "78000004RR~HM.", - rldic_4 = "78000008RR~HM.", - rldimi_4 = "7800000cRR~HM.", - rldcl_4 = "78000010RR~RM.", - rldcr_4 = "78000012RR~RM.", - - -- Primary opcode 59: - fdivs_3 = "ec000024FFF.", - fsubs_3 = "ec000028FFF.", - fadds_3 = "ec00002aFFF.", - fsqrts_2 = "ec00002cF-F.", - fres_2 = "ec000030F-F.", - fmuls_3 = "ec000032FF-F.", - frsqrtes_2 = "ec000034F-F.", - fmsubs_4 = "ec000038FFFF~.", - fmadds_4 = "ec00003aFFFF~.", - fnmsubs_4 = "ec00003cFFFF~.", - fnmadds_4 = "ec00003eFFFF~.", - - -- Primary opcode 63: - fdiv_3 = "fc000024FFF.", - fsub_3 = "fc000028FFF.", - fadd_3 = "fc00002aFFF.", - fsqrt_2 = "fc00002cF-F.", - fsel_4 = "fc00002eFFFF~.", - fre_2 = "fc000030F-F.", - fmul_3 = "fc000032FF-F.", - frsqrte_2 = "fc000034F-F.", - fmsub_4 = "fc000038FFFF~.", - fmadd_4 = "fc00003aFFFF~.", - fnmsub_4 = "fc00003cFFFF~.", - fnmadd_4 = "fc00003eFFFF~.", - fcmpu_3 = "fc000000XFF", - fcpsgn_3 = "fc000010FFF.", - fcmpo_3 = "fc000040XFF", - mtfsb1_1 = "fc00004cA", - fneg_2 = "fc000050F-F.", - mcrfs_2 = "fc000080XX", - mtfsb0_1 = "fc00008cA", - fmr_2 = "fc000090F-F.", - frsp_2 = "fc000018F-F.", - fctiw_2 = "fc00001cF-F.", - fctiwz_2 = "fc00001eF-F.", - mtfsfi_2 = "fc00010cAA", -- NYI: upshift. - fnabs_2 = "fc000110F-F.", - fabs_2 = "fc000210F-F.", - frin_2 = "fc000310F-F.", - friz_2 = "fc000350F-F.", - frip_2 = "fc000390F-F.", - frim_2 = "fc0003d0F-F.", - mffs_1 = "fc00048eF.", - -- NYI: mtfsf, mtfsb0, mtfsb1. - fctid_2 = "fc00065cF-F.", - fctidz_2 = "fc00065eF-F.", - fcfid_2 = "fc00069cF-F.", - - -- Primary opcode 4, SPE APU extension: - evaddw_3 = "10000200RRR", - evaddiw_3 = "10000202RAR~", - evsubw_3 = "10000204RRR~", - evsubiw_3 = "10000206RAR~", - evabs_2 = "10000208RR", - evneg_2 = "10000209RR", - evextsb_2 = "1000020aRR", - evextsh_2 = "1000020bRR", - evrndw_2 = "1000020cRR", - evcntlzw_2 = "1000020dRR", - evcntlsw_2 = "1000020eRR", - brinc_3 = "1000020fRRR", - evand_3 = "10000211RRR", - evandc_3 = "10000212RRR", - evxor_3 = "10000216RRR", - evor_3 = "10000217RRR", - evmr_2 = "10000217RR=", - evnor_3 = "10000218RRR", - evnot_2 = "10000218RR=", - eveqv_3 = "10000219RRR", - evorc_3 = "1000021bRRR", - evnand_3 = "1000021eRRR", - evsrwu_3 = "10000220RRR", - evsrws_3 = "10000221RRR", - evsrwiu_3 = "10000222RRA", - evsrwis_3 = "10000223RRA", - evslw_3 = "10000224RRR", - evslwi_3 = "10000226RRA", - evrlw_3 = "10000228RRR", - evsplati_2 = "10000229RS", - evrlwi_3 = "1000022aRRA", - evsplatfi_2 = "1000022bRS", - evmergehi_3 = "1000022cRRR", - evmergelo_3 = "1000022dRRR", - evcmpgtu_3 = "10000230XRR", - evcmpgtu_2 = "10000230-RR", - evcmpgts_3 = "10000231XRR", - evcmpgts_2 = "10000231-RR", - evcmpltu_3 = "10000232XRR", - evcmpltu_2 = "10000232-RR", - evcmplts_3 = "10000233XRR", - evcmplts_2 = "10000233-RR", - evcmpeq_3 = "10000234XRR", - evcmpeq_2 = "10000234-RR", - evsel_4 = "10000278RRRW", - evsel_3 = "10000278RRR", - evfsadd_3 = "10000280RRR", - evfssub_3 = "10000281RRR", - evfsabs_2 = "10000284RR", - evfsnabs_2 = "10000285RR", - evfsneg_2 = "10000286RR", - evfsmul_3 = "10000288RRR", - evfsdiv_3 = "10000289RRR", - evfscmpgt_3 = "1000028cXRR", - evfscmpgt_2 = "1000028c-RR", - evfscmplt_3 = "1000028dXRR", - evfscmplt_2 = "1000028d-RR", - evfscmpeq_3 = "1000028eXRR", - evfscmpeq_2 = "1000028e-RR", - evfscfui_2 = "10000290R-R", - evfscfsi_2 = "10000291R-R", - evfscfuf_2 = "10000292R-R", - evfscfsf_2 = "10000293R-R", - evfsctui_2 = "10000294R-R", - evfsctsi_2 = "10000295R-R", - evfsctuf_2 = "10000296R-R", - evfsctsf_2 = "10000297R-R", - evfsctuiz_2 = "10000298R-R", - evfsctsiz_2 = "1000029aR-R", - evfststgt_3 = "1000029cXRR", - evfststgt_2 = "1000029c-RR", - evfststlt_3 = "1000029dXRR", - evfststlt_2 = "1000029d-RR", - evfststeq_3 = "1000029eXRR", - evfststeq_2 = "1000029e-RR", - efsadd_3 = "100002c0RRR", - efssub_3 = "100002c1RRR", - efsabs_2 = "100002c4RR", - efsnabs_2 = "100002c5RR", - efsneg_2 = "100002c6RR", - efsmul_3 = "100002c8RRR", - efsdiv_3 = "100002c9RRR", - efscmpgt_3 = "100002ccXRR", - efscmpgt_2 = "100002cc-RR", - efscmplt_3 = "100002cdXRR", - efscmplt_2 = "100002cd-RR", - efscmpeq_3 = "100002ceXRR", - efscmpeq_2 = "100002ce-RR", - efscfd_2 = "100002cfR-R", - efscfui_2 = "100002d0R-R", - efscfsi_2 = "100002d1R-R", - efscfuf_2 = "100002d2R-R", - efscfsf_2 = "100002d3R-R", - efsctui_2 = "100002d4R-R", - efsctsi_2 = "100002d5R-R", - efsctuf_2 = "100002d6R-R", - efsctsf_2 = "100002d7R-R", - efsctuiz_2 = "100002d8R-R", - efsctsiz_2 = "100002daR-R", - efststgt_3 = "100002dcXRR", - efststgt_2 = "100002dc-RR", - efststlt_3 = "100002ddXRR", - efststlt_2 = "100002dd-RR", - efststeq_3 = "100002deXRR", - efststeq_2 = "100002de-RR", - efdadd_3 = "100002e0RRR", - efdsub_3 = "100002e1RRR", - efdcfuid_2 = "100002e2R-R", - efdcfsid_2 = "100002e3R-R", - efdabs_2 = "100002e4RR", - efdnabs_2 = "100002e5RR", - efdneg_2 = "100002e6RR", - efdmul_3 = "100002e8RRR", - efddiv_3 = "100002e9RRR", - efdctuidz_2 = "100002eaR-R", - efdctsidz_2 = "100002ebR-R", - efdcmpgt_3 = "100002ecXRR", - efdcmpgt_2 = "100002ec-RR", - efdcmplt_3 = "100002edXRR", - efdcmplt_2 = "100002ed-RR", - efdcmpeq_3 = "100002eeXRR", - efdcmpeq_2 = "100002ee-RR", - efdcfs_2 = "100002efR-R", - efdcfui_2 = "100002f0R-R", - efdcfsi_2 = "100002f1R-R", - efdcfuf_2 = "100002f2R-R", - efdcfsf_2 = "100002f3R-R", - efdctui_2 = "100002f4R-R", - efdctsi_2 = "100002f5R-R", - efdctuf_2 = "100002f6R-R", - efdctsf_2 = "100002f7R-R", - efdctuiz_2 = "100002f8R-R", - efdctsiz_2 = "100002faR-R", - efdtstgt_3 = "100002fcXRR", - efdtstgt_2 = "100002fc-RR", - efdtstlt_3 = "100002fdXRR", - efdtstlt_2 = "100002fd-RR", - efdtsteq_3 = "100002feXRR", - efdtsteq_2 = "100002fe-RR", - evlddx_3 = "10000300RR0R", - evldd_2 = "10000301R8", - evldwx_3 = "10000302RR0R", - evldw_2 = "10000303R8", - evldhx_3 = "10000304RR0R", - evldh_2 = "10000305R8", - evlwhex_3 = "10000310RR0R", - evlwhe_2 = "10000311R4", - evlwhoux_3 = "10000314RR0R", - evlwhou_2 = "10000315R4", - evlwhosx_3 = "10000316RR0R", - evlwhos_2 = "10000317R4", - evstddx_3 = "10000320RR0R", - evstdd_2 = "10000321R8", - evstdwx_3 = "10000322RR0R", - evstdw_2 = "10000323R8", - evstdhx_3 = "10000324RR0R", - evstdh_2 = "10000325R8", - evstwhex_3 = "10000330RR0R", - evstwhe_2 = "10000331R4", - evstwhox_3 = "10000334RR0R", - evstwho_2 = "10000335R4", - evstwwex_3 = "10000338RR0R", - evstwwe_2 = "10000339R4", - evstwwox_3 = "1000033cRR0R", - evstwwo_2 = "1000033dR4", - evmhessf_3 = "10000403RRR", - evmhossf_3 = "10000407RRR", - evmheumi_3 = "10000408RRR", - evmhesmi_3 = "10000409RRR", - evmhesmf_3 = "1000040bRRR", - evmhoumi_3 = "1000040cRRR", - evmhosmi_3 = "1000040dRRR", - evmhosmf_3 = "1000040fRRR", - evmhessfa_3 = "10000423RRR", - evmhossfa_3 = "10000427RRR", - evmheumia_3 = "10000428RRR", - evmhesmia_3 = "10000429RRR", - evmhesmfa_3 = "1000042bRRR", - evmhoumia_3 = "1000042cRRR", - evmhosmia_3 = "1000042dRRR", - evmhosmfa_3 = "1000042fRRR", - evmwhssf_3 = "10000447RRR", - evmwlumi_3 = "10000448RRR", - evmwhumi_3 = "1000044cRRR", - evmwhsmi_3 = "1000044dRRR", - evmwhsmf_3 = "1000044fRRR", - evmwssf_3 = "10000453RRR", - evmwumi_3 = "10000458RRR", - evmwsmi_3 = "10000459RRR", - evmwsmf_3 = "1000045bRRR", - evmwhssfa_3 = "10000467RRR", - evmwlumia_3 = "10000468RRR", - evmwhumia_3 = "1000046cRRR", - evmwhsmia_3 = "1000046dRRR", - evmwhsmfa_3 = "1000046fRRR", - evmwssfa_3 = "10000473RRR", - evmwumia_3 = "10000478RRR", - evmwsmia_3 = "10000479RRR", - evmwsmfa_3 = "1000047bRRR", - evmra_2 = "100004c4RR", - evdivws_3 = "100004c6RRR", - evdivwu_3 = "100004c7RRR", - evmwssfaa_3 = "10000553RRR", - evmwumiaa_3 = "10000558RRR", - evmwsmiaa_3 = "10000559RRR", - evmwsmfaa_3 = "1000055bRRR", - evmwssfan_3 = "100005d3RRR", - evmwumian_3 = "100005d8RRR", - evmwsmian_3 = "100005d9RRR", - evmwsmfan_3 = "100005dbRRR", - evmergehilo_3 = "1000022eRRR", - evmergelohi_3 = "1000022fRRR", - evlhhesplatx_3 = "10000308RR0R", - evlhhesplat_2 = "10000309R2", - evlhhousplatx_3 = "1000030cRR0R", - evlhhousplat_2 = "1000030dR2", - evlhhossplatx_3 = "1000030eRR0R", - evlhhossplat_2 = "1000030fR2", - evlwwsplatx_3 = "10000318RR0R", - evlwwsplat_2 = "10000319R4", - evlwhsplatx_3 = "1000031cRR0R", - evlwhsplat_2 = "1000031dR4", - evaddusiaaw_2 = "100004c0RR", - evaddssiaaw_2 = "100004c1RR", - evsubfusiaaw_2 = "100004c2RR", - evsubfssiaaw_2 = "100004c3RR", - evaddumiaaw_2 = "100004c8RR", - evaddsmiaaw_2 = "100004c9RR", - evsubfumiaaw_2 = "100004caRR", - evsubfsmiaaw_2 = "100004cbRR", - evmheusiaaw_3 = "10000500RRR", - evmhessiaaw_3 = "10000501RRR", - evmhessfaaw_3 = "10000503RRR", - evmhousiaaw_3 = "10000504RRR", - evmhossiaaw_3 = "10000505RRR", - evmhossfaaw_3 = "10000507RRR", - evmheumiaaw_3 = "10000508RRR", - evmhesmiaaw_3 = "10000509RRR", - evmhesmfaaw_3 = "1000050bRRR", - evmhoumiaaw_3 = "1000050cRRR", - evmhosmiaaw_3 = "1000050dRRR", - evmhosmfaaw_3 = "1000050fRRR", - evmhegumiaa_3 = "10000528RRR", - evmhegsmiaa_3 = "10000529RRR", - evmhegsmfaa_3 = "1000052bRRR", - evmhogumiaa_3 = "1000052cRRR", - evmhogsmiaa_3 = "1000052dRRR", - evmhogsmfaa_3 = "1000052fRRR", - evmwlusiaaw_3 = "10000540RRR", - evmwlssiaaw_3 = "10000541RRR", - evmwlumiaaw_3 = "10000548RRR", - evmwlsmiaaw_3 = "10000549RRR", - evmheusianw_3 = "10000580RRR", - evmhessianw_3 = "10000581RRR", - evmhessfanw_3 = "10000583RRR", - evmhousianw_3 = "10000584RRR", - evmhossianw_3 = "10000585RRR", - evmhossfanw_3 = "10000587RRR", - evmheumianw_3 = "10000588RRR", - evmhesmianw_3 = "10000589RRR", - evmhesmfanw_3 = "1000058bRRR", - evmhoumianw_3 = "1000058cRRR", - evmhosmianw_3 = "1000058dRRR", - evmhosmfanw_3 = "1000058fRRR", - evmhegumian_3 = "100005a8RRR", - evmhegsmian_3 = "100005a9RRR", - evmhegsmfan_3 = "100005abRRR", - evmhogumian_3 = "100005acRRR", - evmhogsmian_3 = "100005adRRR", - evmhogsmfan_3 = "100005afRRR", - evmwlusianw_3 = "100005c0RRR", - evmwlssianw_3 = "100005c1RRR", - evmwlumianw_3 = "100005c8RRR", - evmwlsmianw_3 = "100005c9RRR", - - -- NYI: Book E instructions. -} - --- Add mnemonics for "." variants. -do - local t = {} - for k,v in pairs(map_op) do - if sub(v, -1) == "." then - local v2 = sub(v, 1, 7)..char(byte(v, 8)+1)..sub(v, 9, -2) - t[sub(k, 1, -3).."."..sub(k, -2)] = v2 - end - end - for k,v in pairs(t) do - map_op[k] = v - end -end - --- Add more branch mnemonics. -for cond,c in pairs(map_cond) do - local b1 = "b"..cond - local c1 = shl(band(c, 3), 16) + (c < 4 and 0x01000000 or 0) - -- bX[l] - map_op[b1.."_1"] = tohex(0x40800000 + c1).."K" - map_op[b1.."y_1"] = tohex(0x40a00000 + c1).."K" - map_op[b1.."l_1"] = tohex(0x40800001 + c1).."K" - map_op[b1.."_2"] = tohex(0x40800000 + c1).."-XK" - map_op[b1.."y_2"] = tohex(0x40a00000 + c1).."-XK" - map_op[b1.."l_2"] = tohex(0x40800001 + c1).."-XK" - -- bXlr[l] - map_op[b1.."lr_0"] = tohex(0x4c800020 + c1) - map_op[b1.."lrl_0"] = tohex(0x4c800021 + c1) - map_op[b1.."ctr_0"] = tohex(0x4c800420 + c1) - map_op[b1.."ctrl_0"] = tohex(0x4c800421 + c1) - -- bXctr[l] - map_op[b1.."lr_1"] = tohex(0x4c800020 + c1).."-X" - map_op[b1.."lrl_1"] = tohex(0x4c800021 + c1).."-X" - map_op[b1.."ctr_1"] = tohex(0x4c800420 + c1).."-X" - map_op[b1.."ctrl_1"] = tohex(0x4c800421 + c1).."-X" -end - ------------------------------------------------------------------------------- - -local function parse_gpr(expr) - local tname, ovreg = match(expr, "^([%w_]+):(r[1-3]?[0-9])$") - local tp = map_type[tname or expr] - if tp then - local reg = ovreg or tp.reg - if not reg then - werror("type `"..(tname or expr).."' needs a register override") - end - expr = reg - end - local r = match(expr, "^r([1-3]?[0-9])$") - if r then - r = tonumber(r) - if r <= 31 then return r, tp end - end - werror("bad register name `"..expr.."'") -end - -local function parse_fpr(expr) - local r = match(expr, "^f([1-3]?[0-9])$") - if r then - r = tonumber(r) - if r <= 31 then return r end - end - werror("bad register name `"..expr.."'") -end - -local function parse_cr(expr) - local r = match(expr, "^cr([0-7])$") - if r then return tonumber(r) end - werror("bad condition register name `"..expr.."'") -end - -local function parse_cond(expr) - local r, cond = match(expr, "^4%*cr([0-7])%+(%w%w)$") - if r then - r = tonumber(r) - local c = map_cond[cond] - if c and c < 4 then return r*4+c end - end - werror("bad condition bit name `"..expr.."'") -end - -local function parse_imm(imm, bits, shift, scale, signed) - local n = tonumber(imm) - if n then - local m = sar(n, scale) - if shl(m, scale) == n then - if signed then - local s = sar(m, bits-1) - if s == 0 then return shl(m, shift) - elseif s == -1 then return shl(m + shl(1, bits), shift) end - else - if sar(m, bits) == 0 then return shl(m, shift) end - end - end - werror("out of range immediate `"..imm.."'") - elseif match(imm, "^r([1-3]?[0-9])$") or - match(imm, "^([%w_]+):(r[1-3]?[0-9])$") then - werror("expected immediate operand, got register") - else - waction("IMM", (signed and 32768 or 0)+scale*1024+bits*32+shift, imm) - return 0 - end -end - -local function parse_shiftmask(imm, isshift) - local n = tonumber(imm) - if n then - if shr(n, 6) == 0 then - local lsb = band(imm, 31) - local msb = imm - lsb - return isshift and (shl(lsb, 11)+shr(msb, 4)) or (shl(lsb, 6)+msb) - end - werror("out of range immediate `"..imm.."'") - elseif match(imm, "^r([1-3]?[0-9])$") or - match(imm, "^([%w_]+):(r[1-3]?[0-9])$") then - werror("expected immediate operand, got register") - else - werror("NYI: parameterized 64 bit shift/mask") - end -end - -local function parse_disp(disp) - local imm, reg = match(disp, "^(.*)%(([%w_:]+)%)$") - if imm then - local r = parse_gpr(reg) - if r == 0 then werror("cannot use r0 in displacement") end - return shl(r, 16) + parse_imm(imm, 16, 0, 0, true) - end - local reg, tailr = match(disp, "^([%w_:]+)%s*(.*)$") - if reg and tailr ~= "" then - local r, tp = parse_gpr(reg) - if r == 0 then werror("cannot use r0 in displacement") end - if tp then - waction("IMM", 32768+16*32, format(tp.ctypefmt, tailr)) - return shl(r, 16) - end - end - werror("bad displacement `"..disp.."'") -end - -local function parse_u5disp(disp, scale) - local imm, reg = match(disp, "^(.*)%(([%w_:]+)%)$") - if imm then - local r = parse_gpr(reg) - if r == 0 then werror("cannot use r0 in displacement") end - return shl(r, 16) + parse_imm(imm, 5, 11, scale, false) - end - local reg, tailr = match(disp, "^([%w_:]+)%s*(.*)$") - if reg and tailr ~= "" then - local r, tp = parse_gpr(reg) - if r == 0 then werror("cannot use r0 in displacement") end - if tp then - waction("IMM", scale*1024+5*32+11, format(tp.ctypefmt, tailr)) - return shl(r, 16) - end - end - werror("bad displacement `"..disp.."'") -end - -local function parse_label(label, def) - local prefix = sub(label, 1, 2) - -- =>label (pc label reference) - if prefix == "=>" then - return "PC", 0, sub(label, 3) - end - -- ->name (global label reference) - if prefix == "->" then - return "LG", map_global[sub(label, 3)] - end - if def then - -- [1-9] (local label definition) - if match(label, "^[1-9]$") then - return "LG", 10+tonumber(label) - end - else - -- [<>][1-9] (local label reference) - local dir, lnum = match(label, "^([<>])([1-9])$") - if dir then -- Fwd: 1-9, Bkwd: 11-19. - return "LG", lnum + (dir == ">" and 0 or 10) - end - -- extern label (extern label reference) - local extname = match(label, "^extern%s+(%S+)$") - if extname then - return "EXT", map_extern[extname] - end - end - werror("bad label `"..label.."'") -end - ------------------------------------------------------------------------------- - --- Handle opcodes defined with template strings. -map_op[".template__"] = function(params, template, nparams) - if not params then return sub(template, 9) end - local op = tonumber(sub(template, 1, 8), 16) - local n, rs = 1, 26 - - -- Limit number of section buffer positions used by a single dasm_put(). - -- A single opcode needs a maximum of 3 positions (rlwinm). - if secpos+3 > maxsecpos then wflush() end - local pos = wpos() - - -- Process each character. - for p in gmatch(sub(template, 9), ".") do - if p == "R" then - rs = rs - 5; op = op + shl(parse_gpr(params[n]), rs); n = n + 1 - elseif p == "F" then - rs = rs - 5; op = op + shl(parse_fpr(params[n]), rs); n = n + 1 - elseif p == "A" then - rs = rs - 5; op = op + parse_imm(params[n], 5, rs, 0, false); n = n + 1 - elseif p == "S" then - rs = rs - 5; op = op + parse_imm(params[n], 5, rs, 0, true); n = n + 1 - elseif p == "I" then - op = op + parse_imm(params[n], 16, 0, 0, true); n = n + 1 - elseif p == "U" then - op = op + parse_imm(params[n], 16, 0, 0, false); n = n + 1 - elseif p == "D" then - op = op + parse_disp(params[n]); n = n + 1 - elseif p == "2" then - op = op + parse_u5disp(params[n], 1); n = n + 1 - elseif p == "4" then - op = op + parse_u5disp(params[n], 2); n = n + 1 - elseif p == "8" then - op = op + parse_u5disp(params[n], 3); n = n + 1 - elseif p == "C" then - rs = rs - 5; op = op + shl(parse_cond(params[n]), rs); n = n + 1 - elseif p == "X" then - rs = rs - 5; op = op + shl(parse_cr(params[n]), rs+2); n = n + 1 - elseif p == "W" then - op = op + parse_cr(params[n]); n = n + 1 - elseif p == "G" then - op = op + parse_imm(params[n], 8, 12, 0, false); n = n + 1 - elseif p == "H" then - op = op + parse_shiftmask(params[n], true); n = n + 1 - elseif p == "M" then - op = op + parse_shiftmask(params[n], false); n = n + 1 - elseif p == "J" or p == "K" then - local mode, n, s = parse_label(params[n], false) - if p == "K" then n = n + 2048 end - waction("REL_"..mode, n, s, 1) - n = n + 1 - elseif p == "0" then - if band(shr(op, rs), 31) == 0 then werror("cannot use r0") end - elseif p == "=" or p == "%" then - local t = band(shr(op, p == "%" and rs+5 or rs), 31) - rs = rs - 5 - op = op + shl(t, rs) - elseif p == "~" then - local mm = shl(31, rs) - local lo = band(op, mm) - local hi = band(op, shl(mm, 5)) - op = op - lo - hi + shl(lo, 5) + shr(hi, 5) - elseif p == "-" then - rs = rs - 5 - elseif p == "." then - -- Ignored. - else - assert(false) - end - end - wputpos(pos, op) -end - ------------------------------------------------------------------------------- - --- Pseudo-opcode to mark the position where the action list is to be emitted. -map_op[".actionlist_1"] = function(params) - if not params then return "cvar" end - local name = params[1] -- No syntax check. You get to keep the pieces. - wline(function(out) writeactions(out, name) end) -end - --- Pseudo-opcode to mark the position where the global enum is to be emitted. -map_op[".globals_1"] = function(params) - if not params then return "prefix" end - local prefix = params[1] -- No syntax check. You get to keep the pieces. - wline(function(out) writeglobals(out, prefix) end) -end - --- Pseudo-opcode to mark the position where the global names are to be emitted. -map_op[".globalnames_1"] = function(params) - if not params then return "cvar" end - local name = params[1] -- No syntax check. You get to keep the pieces. - wline(function(out) writeglobalnames(out, name) end) -end - --- Pseudo-opcode to mark the position where the extern names are to be emitted. -map_op[".externnames_1"] = function(params) - if not params then return "cvar" end - local name = params[1] -- No syntax check. You get to keep the pieces. - wline(function(out) writeexternnames(out, name) end) -end - ------------------------------------------------------------------------------- - --- Label pseudo-opcode (converted from trailing colon form). -map_op[".label_1"] = function(params) - if not params then return "[1-9] | ->global | =>pcexpr" end - if secpos+1 > maxsecpos then wflush() end - local mode, n, s = parse_label(params[1], true) - if mode == "EXT" then werror("bad label definition") end - waction("LABEL_"..mode, n, s, 1) -end - ------------------------------------------------------------------------------- - --- Pseudo-opcodes for data storage. -map_op[".long_*"] = function(params) - if not params then return "imm..." end - for _,p in ipairs(params) do - local n = tonumber(p) - if not n then werror("bad immediate `"..p.."'") end - if n < 0 then n = n + 2^32 end - wputw(n) - if secpos+2 > maxsecpos then wflush() end - end -end - --- Alignment pseudo-opcode. -map_op[".align_1"] = function(params) - if not params then return "numpow2" end - if secpos+1 > maxsecpos then wflush() end - local align = tonumber(params[1]) - if align then - local x = align - -- Must be a power of 2 in the range (2 ... 256). - for i=1,8 do - x = x / 2 - if x == 1 then - waction("ALIGN", align-1, nil, 1) -- Action byte is 2**n-1. - return - end - end - end - werror("bad alignment") -end - ------------------------------------------------------------------------------- - --- Pseudo-opcode for (primitive) type definitions (map to C types). -map_op[".type_3"] = function(params, nparams) - if not params then - return nparams == 2 and "name, ctype" or "name, ctype, reg" - end - local name, ctype, reg = params[1], params[2], params[3] - if not match(name, "^[%a_][%w_]*$") then - werror("bad type name `"..name.."'") - end - local tp = map_type[name] - if tp then - werror("duplicate type `"..name.."'") - end - -- Add #type to defines. A bit unclean to put it in map_archdef. - map_archdef["#"..name] = "sizeof("..ctype..")" - -- Add new type and emit shortcut define. - local num = ctypenum + 1 - map_type[name] = { - ctype = ctype, - ctypefmt = format("Dt%X(%%s)", num), - reg = reg, - } - wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype)) - ctypenum = num -end -map_op[".type_2"] = map_op[".type_3"] - --- Dump type definitions. -local function dumptypes(out, lvl) - local t = {} - for name in pairs(map_type) do t[#t+1] = name end - sort(t) - out:write("Type definitions:\n") - for _,name in ipairs(t) do - local tp = map_type[name] - local reg = tp.reg or "" - out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg)) - end - out:write("\n") -end - ------------------------------------------------------------------------------- - --- Set the current section. -function _M.section(num) - waction("SECTION", num) - wflush(true) -- SECTION is a terminal action. -end - ------------------------------------------------------------------------------- - --- Dump architecture description. -function _M.dumparch(out) - out:write(format("DynASM %s version %s, released %s\n\n", - _info.arch, _info.version, _info.release)) - dumpactions(out) -end - --- Dump all user defined elements. -function _M.dumpdef(out, lvl) - dumptypes(out, lvl) - dumpglobals(out, lvl) - dumpexterns(out, lvl) -end - ------------------------------------------------------------------------------- - --- Pass callbacks from/to the DynASM core. -function _M.passcb(wl, we, wf, ww) - wline, werror, wfatal, wwarn = wl, we, wf, ww - return wflush -end - --- Setup the arch-specific module. -function _M.setup(arch, opt) - g_arch, g_opt = arch, opt -end - --- Merge the core maps and the arch-specific maps. -function _M.mergemaps(map_coreop, map_def) - setmetatable(map_op, { __index = map_coreop }) - setmetatable(map_def, { __index = map_archdef }) - return map_op, map_def -end - -return _M - ------------------------------------------------------------------------------- - diff --git a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_proto.h b/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_proto.h deleted file mode 100644 index e77bb8445..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_proto.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -** DynASM encoding engine prototypes. -** Copyright (C) 2005-2014 Mike Pall. All rights reserved. -** Released under the MIT license. See dynasm.lua for full copyright notice. -*/ - -#ifndef _DASM_PROTO_H -#define _DASM_PROTO_H - -#include -#include - -#define DASM_IDENT "DynASM 1.3.0" -#define DASM_VERSION 10300 /* 1.3.0 */ - -#ifndef Dst_DECL -#define Dst_DECL dasm_State **Dst -#endif - -#ifndef Dst_REF -#define Dst_REF (*Dst) -#endif - -#ifndef DASM_FDEF -#define DASM_FDEF extern -#endif - -#ifndef DASM_M_GROW -#define DASM_M_GROW(ctx, t, p, sz, need) \ - do { \ - size_t _sz = (sz), _need = (need); \ - if (_sz < _need) { \ - if (_sz < 16) _sz = 16; \ - while (_sz < _need) _sz += _sz; \ - (p) = (t *)realloc((p), _sz); \ - if ((p) == NULL) exit(1); \ - (sz) = _sz; \ - } \ - } while(0) -#endif - -#ifndef DASM_M_FREE -#define DASM_M_FREE(ctx, p, sz) free(p) -#endif - -/* Internal DynASM encoder state. */ -typedef struct dasm_State dasm_State; - - -/* Initialize and free DynASM state. */ -DASM_FDEF void dasm_init(Dst_DECL, int maxsection); -DASM_FDEF void dasm_free(Dst_DECL); - -/* Setup global array. Must be called before dasm_setup(). */ -DASM_FDEF void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl); - -/* Grow PC label array. Can be called after dasm_setup(), too. */ -DASM_FDEF void dasm_growpc(Dst_DECL, unsigned int maxpc); - -/* Setup encoder. */ -DASM_FDEF void dasm_setup(Dst_DECL, const void *actionlist); - -/* Feed encoder with actions. Calls are generated by pre-processor. */ -DASM_FDEF void dasm_put(Dst_DECL, int start, ...); - -/* Link sections and return the resulting size. */ -DASM_FDEF int dasm_link(Dst_DECL, size_t *szp); - -/* Encode sections into buffer. */ -DASM_FDEF int dasm_encode(Dst_DECL, void *buffer); - -/* Get PC label offset. */ -DASM_FDEF int dasm_getpclabel(Dst_DECL, unsigned int pc); - -#ifdef DASM_CHECKS -/* Optional sanity checker to call between isolated encoding steps. */ -DASM_FDEF int dasm_checkstep(Dst_DECL, int secmatch); -#else -#define dasm_checkstep(a, b) 0 -#endif - - -#endif /* _DASM_PROTO_H */ diff --git a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_x64.lua b/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_x64.lua deleted file mode 100644 index 91d676d17..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_x64.lua +++ /dev/null @@ -1,12 +0,0 @@ ------------------------------------------------------------------------------- --- DynASM x64 module. --- --- Copyright (C) 2005-2014 Mike Pall. All rights reserved. --- See dynasm.lua for full copyright notice. ------------------------------------------------------------------------------- --- This module just sets 64 bit mode for the combined x86/x64 module. --- All the interesting stuff is there. ------------------------------------------------------------------------------- - -x64 = true -- Using a global is an ugly, but effective solution. -return require("dasm_x86") diff --git a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_x86.h b/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_x86.h deleted file mode 100644 index 97cbbea89..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_x86.h +++ /dev/null @@ -1,471 +0,0 @@ -/* -** DynASM x86 encoding engine. -** Copyright (C) 2005-2014 Mike Pall. All rights reserved. -** Released under the MIT license. See dynasm.lua for full copyright notice. -*/ - -#include -#include -#include -#include - -#define DASM_ARCH "x86" - -#ifndef DASM_EXTERN -#define DASM_EXTERN(a,b,c,d) 0 -#endif - -/* Action definitions. DASM_STOP must be 255. */ -enum { - DASM_DISP = 233, - DASM_IMM_S, DASM_IMM_B, DASM_IMM_W, DASM_IMM_D, DASM_IMM_WB, DASM_IMM_DB, - DASM_VREG, DASM_SPACE, DASM_SETLABEL, DASM_REL_A, DASM_REL_LG, DASM_REL_PC, - DASM_IMM_LG, DASM_IMM_PC, DASM_LABEL_LG, DASM_LABEL_PC, DASM_ALIGN, - DASM_EXTERN, DASM_ESC, DASM_MARK, DASM_SECTION, DASM_STOP -}; - -/* Maximum number of section buffer positions for a single dasm_put() call. */ -#define DASM_MAXSECPOS 25 - -/* DynASM encoder status codes. Action list offset or number are or'ed in. */ -#define DASM_S_OK 0x00000000 -#define DASM_S_NOMEM 0x01000000 -#define DASM_S_PHASE 0x02000000 -#define DASM_S_MATCH_SEC 0x03000000 -#define DASM_S_RANGE_I 0x11000000 -#define DASM_S_RANGE_SEC 0x12000000 -#define DASM_S_RANGE_LG 0x13000000 -#define DASM_S_RANGE_PC 0x14000000 -#define DASM_S_RANGE_VREG 0x15000000 -#define DASM_S_UNDEF_L 0x21000000 -#define DASM_S_UNDEF_PC 0x22000000 - -/* Macros to convert positions (8 bit section + 24 bit index). */ -#define DASM_POS2IDX(pos) ((pos)&0x00ffffff) -#define DASM_POS2BIAS(pos) ((pos)&0xff000000) -#define DASM_SEC2POS(sec) ((sec)<<24) -#define DASM_POS2SEC(pos) ((pos)>>24) -#define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) - -/* Action list type. */ -typedef const unsigned char *dasm_ActList; - -/* Per-section structure. */ -typedef struct dasm_Section { - int *rbuf; /* Biased buffer pointer (negative section bias). */ - int *buf; /* True buffer pointer. */ - size_t bsize; /* Buffer size in bytes. */ - int pos; /* Biased buffer position. */ - int epos; /* End of biased buffer position - max single put. */ - int ofs; /* Byte offset into section. */ -} dasm_Section; - -/* Core structure holding the DynASM encoding state. */ -struct dasm_State { - size_t psize; /* Allocated size of this structure. */ - dasm_ActList actionlist; /* Current actionlist pointer. */ - int *lglabels; /* Local/global chain/pos ptrs. */ - size_t lgsize; - int *pclabels; /* PC label chains/pos ptrs. */ - size_t pcsize; - void **globals; /* Array of globals (bias -10). */ - dasm_Section *section; /* Pointer to active section. */ - size_t codesize; /* Total size of all code sections. */ - int maxsection; /* 0 <= sectionidx < maxsection. */ - int status; /* Status code. */ - dasm_Section sections[1]; /* All sections. Alloc-extended. */ -}; - -/* The size of the core structure depends on the max. number of sections. */ -#define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section)) - - -/* Initialize DynASM state. */ -void dasm_init(Dst_DECL, int maxsection) -{ - dasm_State *D; - size_t psz = 0; - int i; - Dst_REF = NULL; - DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); - D = Dst_REF; - D->psize = psz; - D->lglabels = NULL; - D->lgsize = 0; - D->pclabels = NULL; - D->pcsize = 0; - D->globals = NULL; - D->maxsection = maxsection; - for (i = 0; i < maxsection; i++) { - D->sections[i].buf = NULL; /* Need this for pass3. */ - D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i); - D->sections[i].bsize = 0; - D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ - } -} - -/* Free DynASM state. */ -void dasm_free(Dst_DECL) -{ - dasm_State *D = Dst_REF; - int i; - for (i = 0; i < D->maxsection; i++) - if (D->sections[i].buf) - DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize); - if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize); - if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize); - DASM_M_FREE(Dst, D, D->psize); -} - -/* Setup global label array. Must be called before dasm_setup(). */ -void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) -{ - dasm_State *D = Dst_REF; - D->globals = gl - 10; /* Negative bias to compensate for locals. */ - DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); -} - -/* Grow PC label array. Can be called after dasm_setup(), too. */ -void dasm_growpc(Dst_DECL, unsigned int maxpc) -{ - dasm_State *D = Dst_REF; - size_t osz = D->pcsize; - DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int)); - memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz); -} - -/* Setup encoder. */ -void dasm_setup(Dst_DECL, const void *actionlist) -{ - dasm_State *D = Dst_REF; - int i; - D->actionlist = (dasm_ActList)actionlist; - D->status = DASM_S_OK; - D->section = &D->sections[0]; - memset((void *)D->lglabels, 0, D->lgsize); - if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); - for (i = 0; i < D->maxsection; i++) { - D->sections[i].pos = DASM_SEC2POS(i); - D->sections[i].ofs = 0; - } -} - - -#ifdef DASM_CHECKS -#define CK(x, st) \ - do { if (!(x)) { \ - D->status = DASM_S_##st|(int)(p-D->actionlist-1); return; } } while (0) -#define CKPL(kind, st) \ - do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \ - D->status=DASM_S_RANGE_##st|(int)(p-D->actionlist-1); return; } } while (0) -#else -#define CK(x, st) ((void)0) -#define CKPL(kind, st) ((void)0) -#endif - -/* Pass 1: Store actions and args, link branches/labels, estimate offsets. */ -void dasm_put(Dst_DECL, int start, ...) -{ - va_list ap; - dasm_State *D = Dst_REF; - dasm_ActList p = D->actionlist + start; - dasm_Section *sec = D->section; - int pos = sec->pos, ofs = sec->ofs, mrm = 4; - int *b; - - if (pos >= sec->epos) { - DASM_M_GROW(Dst, int, sec->buf, sec->bsize, - sec->bsize + 2*DASM_MAXSECPOS*sizeof(int)); - sec->rbuf = sec->buf - DASM_POS2BIAS(pos); - sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos); - } - - b = sec->rbuf; - b[pos++] = start; - - va_start(ap, start); - while (1) { - int action = *p++; - if (action < DASM_DISP) { - ofs++; - } else if (action <= DASM_REL_A) { - int n = va_arg(ap, int); - b[pos++] = n; - switch (action) { - case DASM_DISP: - if (n == 0) { if ((mrm&7) == 4) mrm = p[-2]; if ((mrm&7) != 5) break; } - case DASM_IMM_DB: if (((n+128)&-256) == 0) goto ob; - case DASM_REL_A: /* Assumes ptrdiff_t is int. !x64 */ - case DASM_IMM_D: ofs += 4; break; - case DASM_IMM_S: CK(((n+128)&-256) == 0, RANGE_I); goto ob; - case DASM_IMM_B: CK((n&-256) == 0, RANGE_I); ob: ofs++; break; - case DASM_IMM_WB: if (((n+128)&-256) == 0) goto ob; - case DASM_IMM_W: CK((n&-65536) == 0, RANGE_I); ofs += 2; break; - case DASM_SPACE: p++; ofs += n; break; - case DASM_SETLABEL: b[pos-2] = -0x40000000; break; /* Neg. label ofs. */ - case DASM_VREG: CK((n&-8) == 0 && (n != 4 || (*p&1) == 0), RANGE_VREG); - if (*p++ == 1 && *p == DASM_DISP) mrm = n; continue; - } - mrm = 4; - } else { - int *pl, n; - switch (action) { - case DASM_REL_LG: - case DASM_IMM_LG: - n = *p++; pl = D->lglabels + n; - /* Bkwd rel or global. */ - if (n <= 246) { CK(n>=10||*pl<0, RANGE_LG); CKPL(lg, LG); goto putrel; } - pl -= 246; n = *pl; - if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */ - goto linkrel; - case DASM_REL_PC: - case DASM_IMM_PC: pl = D->pclabels + va_arg(ap, int); CKPL(pc, PC); - putrel: - n = *pl; - if (n < 0) { /* Label exists. Get label pos and store it. */ - b[pos] = -n; - } else { - linkrel: - b[pos] = n; /* Else link to rel chain, anchored at label. */ - *pl = pos; - } - pos++; - ofs += 4; /* Maximum offset needed. */ - if (action == DASM_REL_LG || action == DASM_REL_PC) - b[pos++] = ofs; /* Store pass1 offset estimate. */ - break; - case DASM_LABEL_LG: pl = D->lglabels + *p++; CKPL(lg, LG); goto putlabel; - case DASM_LABEL_PC: pl = D->pclabels + va_arg(ap, int); CKPL(pc, PC); - putlabel: - n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */ - while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; } - *pl = -pos; /* Label exists now. */ - b[pos++] = ofs; /* Store pass1 offset estimate. */ - break; - case DASM_ALIGN: - ofs += *p++; /* Maximum alignment needed (arg is 2**n-1). */ - b[pos++] = ofs; /* Store pass1 offset estimate. */ - break; - case DASM_EXTERN: p += 2; ofs += 4; break; - case DASM_ESC: p++; ofs++; break; - case DASM_MARK: mrm = p[-2]; break; - case DASM_SECTION: - n = *p; CK(n < D->maxsection, RANGE_SEC); D->section = &D->sections[n]; - case DASM_STOP: goto stop; - } - } - } -stop: - va_end(ap); - sec->pos = pos; - sec->ofs = ofs; -} -#undef CK - -/* Pass 2: Link sections, shrink branches/aligns, fix label offsets. */ -int dasm_link(Dst_DECL, size_t *szp) -{ - dasm_State *D = Dst_REF; - int secnum; - int ofs = 0; - -#ifdef DASM_CHECKS - *szp = 0; - if (D->status != DASM_S_OK) return D->status; - { - int pc; - for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) - if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; - } -#endif - - { /* Handle globals not defined in this translation unit. */ - int idx; - for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) { - int n = D->lglabels[idx]; - /* Undefined label: Collapse rel chain and replace with marker (< 0). */ - while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } - } - } - - /* Combine all code sections. No support for data sections (yet). */ - for (secnum = 0; secnum < D->maxsection; secnum++) { - dasm_Section *sec = D->sections + secnum; - int *b = sec->rbuf; - int pos = DASM_SEC2POS(secnum); - int lastpos = sec->pos; - - while (pos != lastpos) { - dasm_ActList p = D->actionlist + b[pos++]; - while (1) { - int op, action = *p++; - switch (action) { - case DASM_REL_LG: p++; op = p[-3]; goto rel_pc; - case DASM_REL_PC: op = p[-2]; rel_pc: { - int shrink = op == 0xe9 ? 3 : ((op&0xf0) == 0x80 ? 4 : 0); - if (shrink) { /* Shrinkable branch opcode? */ - int lofs, lpos = b[pos]; - if (lpos < 0) goto noshrink; /* Ext global? */ - lofs = *DASM_POS2PTR(D, lpos); - if (lpos > pos) { /* Fwd label: add cumulative section offsets. */ - int i; - for (i = secnum; i < DASM_POS2SEC(lpos); i++) - lofs += D->sections[i].ofs; - } else { - lofs -= ofs; /* Bkwd label: unfix offset. */ - } - lofs -= b[pos+1]; /* Short branch ok? */ - if (lofs >= -128-shrink && lofs <= 127) ofs -= shrink; /* Yes. */ - else { noshrink: shrink = 0; } /* No, cannot shrink op. */ - } - b[pos+1] = shrink; - pos += 2; - break; - } - case DASM_SPACE: case DASM_IMM_LG: case DASM_VREG: p++; - case DASM_DISP: case DASM_IMM_S: case DASM_IMM_B: case DASM_IMM_W: - case DASM_IMM_D: case DASM_IMM_WB: case DASM_IMM_DB: - case DASM_SETLABEL: case DASM_REL_A: case DASM_IMM_PC: pos++; break; - case DASM_LABEL_LG: p++; - case DASM_LABEL_PC: b[pos++] += ofs; break; /* Fix label offset. */ - case DASM_ALIGN: ofs -= (b[pos++]+ofs)&*p++; break; /* Adjust ofs. */ - case DASM_EXTERN: p += 2; break; - case DASM_ESC: p++; break; - case DASM_MARK: break; - case DASM_SECTION: case DASM_STOP: goto stop; - } - } - stop: (void)0; - } - ofs += sec->ofs; /* Next section starts right after current section. */ - } - - D->codesize = ofs; /* Total size of all code sections */ - *szp = ofs; - return DASM_S_OK; -} - -#define dasmb(x) *cp++ = (unsigned char)(x) -#ifndef DASM_ALIGNED_WRITES -#define dasmw(x) \ - do { *((unsigned short *)cp) = (unsigned short)(x); cp+=2; } while (0) -#define dasmd(x) \ - do { *((unsigned int *)cp) = (unsigned int)(x); cp+=4; } while (0) -#else -#define dasmw(x) do { dasmb(x); dasmb((x)>>8); } while (0) -#define dasmd(x) do { dasmw(x); dasmw((x)>>16); } while (0) -#endif - -/* Pass 3: Encode sections. */ -int dasm_encode(Dst_DECL, void *buffer) -{ - dasm_State *D = Dst_REF; - unsigned char *base = (unsigned char *)buffer; - unsigned char *cp = base; - int secnum; - - /* Encode all code sections. No support for data sections (yet). */ - for (secnum = 0; secnum < D->maxsection; secnum++) { - dasm_Section *sec = D->sections + secnum; - int *b = sec->buf; - int *endb = sec->rbuf + sec->pos; - - while (b != endb) { - dasm_ActList p = D->actionlist + *b++; - unsigned char *mark = NULL; - while (1) { - int action = *p++; - int n = (action >= DASM_DISP && action <= DASM_ALIGN) ? *b++ : 0; - switch (action) { - case DASM_DISP: if (!mark) mark = cp; { - unsigned char *mm = mark; - if (*p != DASM_IMM_DB && *p != DASM_IMM_WB) mark = NULL; - if (n == 0) { int mrm = mm[-1]&7; if (mrm == 4) mrm = mm[0]&7; - if (mrm != 5) { mm[-1] -= 0x80; break; } } - if (((n+128) & -256) != 0) goto wd; else mm[-1] -= 0x40; - } - case DASM_IMM_S: case DASM_IMM_B: wb: dasmb(n); break; - case DASM_IMM_DB: if (((n+128)&-256) == 0) { - db: if (!mark) mark = cp; mark[-2] += 2; mark = NULL; goto wb; - } else mark = NULL; - case DASM_IMM_D: wd: dasmd(n); break; - case DASM_IMM_WB: if (((n+128)&-256) == 0) goto db; else mark = NULL; - case DASM_IMM_W: dasmw(n); break; - case DASM_VREG: { int t = *p++; if (t >= 2) n<<=3; cp[-1] |= n; break; } - case DASM_REL_LG: p++; if (n >= 0) goto rel_pc; - b++; n = (int)(ptrdiff_t)D->globals[-n]; - case DASM_REL_A: rel_a: n -= (int)(ptrdiff_t)(cp+4); goto wd; /* !x64 */ - case DASM_REL_PC: rel_pc: { - int shrink = *b++; - int *pb = DASM_POS2PTR(D, n); if (*pb < 0) { n = pb[1]; goto rel_a; } - n = *pb - ((int)(cp-base) + 4-shrink); - if (shrink == 0) goto wd; - if (shrink == 4) { cp--; cp[-1] = *cp-0x10; } else cp[-1] = 0xeb; - goto wb; - } - case DASM_IMM_LG: - p++; if (n < 0) { n = (int)(ptrdiff_t)D->globals[-n]; goto wd; } - case DASM_IMM_PC: { - int *pb = DASM_POS2PTR(D, n); - n = *pb < 0 ? pb[1] : (*pb + (int)(ptrdiff_t)base); - goto wd; - } - case DASM_LABEL_LG: { - int idx = *p++; - if (idx >= 10) - D->globals[idx] = (void *)(base + (*p == DASM_SETLABEL ? *b : n)); - break; - } - case DASM_LABEL_PC: case DASM_SETLABEL: break; - case DASM_SPACE: { int fill = *p++; while (n--) *cp++ = fill; break; } - case DASM_ALIGN: - n = *p++; - while (((cp-base) & n)) *cp++ = 0x90; /* nop */ - break; - case DASM_EXTERN: n = DASM_EXTERN(Dst, cp, p[1], *p); p += 2; goto wd; - case DASM_MARK: mark = cp; break; - case DASM_ESC: action = *p++; - default: *cp++ = action; break; - case DASM_SECTION: case DASM_STOP: goto stop; - } - } - stop: (void)0; - } - } - - if (base + D->codesize != cp) /* Check for phase errors. */ - return DASM_S_PHASE; - return DASM_S_OK; -} - -/* Get PC label offset. */ -int dasm_getpclabel(Dst_DECL, unsigned int pc) -{ - dasm_State *D = Dst_REF; - if (pc*sizeof(int) < D->pcsize) { - int pos = D->pclabels[pc]; - if (pos < 0) return *DASM_POS2PTR(D, -pos); - if (pos > 0) return -1; /* Undefined. */ - } - return -2; /* Unused or out of range. */ -} - -#ifdef DASM_CHECKS -/* Optional sanity checker to call between isolated encoding steps. */ -int dasm_checkstep(Dst_DECL, int secmatch) -{ - dasm_State *D = Dst_REF; - if (D->status == DASM_S_OK) { - int i; - for (i = 1; i <= 9; i++) { - if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_L|i; break; } - D->lglabels[i] = 0; - } - } - if (D->status == DASM_S_OK && secmatch >= 0 && - D->section != &D->sections[secmatch]) - D->status = DASM_S_MATCH_SEC|(int)(D->section-D->sections); - return D->status; -} -#endif - diff --git a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_x86.lua b/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_x86.lua deleted file mode 100644 index f3859e3e1..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dasm_x86.lua +++ /dev/null @@ -1,1937 +0,0 @@ ------------------------------------------------------------------------------- --- DynASM x86/x64 module. --- --- Copyright (C) 2005-2014 Mike Pall. All rights reserved. --- See dynasm.lua for full copyright notice. ------------------------------------------------------------------------------- - -local x64 = x64 - --- Module information: -local _info = { - arch = x64 and "x64" or "x86", - description = "DynASM x86/x64 module", - version = "1.3.0", - vernum = 10300, - release = "2011-05-05", - author = "Mike Pall", - license = "MIT", -} - --- Exported glue functions for the arch-specific module. -local _M = { _info = _info } - --- Cache library functions. -local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs -local assert, unpack, setmetatable = assert, unpack or table.unpack, setmetatable -local _s = string -local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char -local find, match, gmatch, gsub = _s.find, _s.match, _s.gmatch, _s.gsub -local concat, sort = table.concat, table.sort -local bit = bit or require("bit") -local band, shl, shr = bit.band, bit.lshift, bit.rshift - --- Inherited tables and callbacks. -local g_opt, g_arch -local wline, werror, wfatal, wwarn - --- Action name list. --- CHECK: Keep this in sync with the C code! -local action_names = { - -- int arg, 1 buffer pos: - "DISP", "IMM_S", "IMM_B", "IMM_W", "IMM_D", "IMM_WB", "IMM_DB", - -- action arg (1 byte), int arg, 1 buffer pos (reg/num): - "VREG", "SPACE", -- !x64: VREG support NYI. - -- ptrdiff_t arg, 1 buffer pos (address): !x64 - "SETLABEL", "REL_A", - -- action arg (1 byte) or int arg, 2 buffer pos (link, offset): - "REL_LG", "REL_PC", - -- action arg (1 byte) or int arg, 1 buffer pos (link): - "IMM_LG", "IMM_PC", - -- action arg (1 byte) or int arg, 1 buffer pos (offset): - "LABEL_LG", "LABEL_PC", - -- action arg (1 byte), 1 buffer pos (offset): - "ALIGN", - -- action args (2 bytes), no buffer pos. - "EXTERN", - -- action arg (1 byte), no buffer pos. - "ESC", - -- no action arg, no buffer pos. - "MARK", - -- action arg (1 byte), no buffer pos, terminal action: - "SECTION", - -- no args, no buffer pos, terminal action: - "STOP" -} - --- Maximum number of section buffer positions for dasm_put(). --- CHECK: Keep this in sync with the C code! -local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines. - --- Action name -> action number (dynamically generated below). -local map_action = {} --- First action number. Everything below does not need to be escaped. -local actfirst = 256-#action_names - --- Action list buffer and string (only used to remove dupes). -local actlist = {} -local actstr = "" - --- Argument list for next dasm_put(). Start with offset 0 into action list. -local actargs = { 0 } - --- Current number of section buffer positions for dasm_put(). -local secpos = 1 - ------------------------------------------------------------------------------- - --- Compute action numbers for action names. -for n,name in ipairs(action_names) do - local num = actfirst + n - 1 - map_action[name] = num -end - --- Dump action names and numbers. -local function dumpactions(out) - out:write("DynASM encoding engine action codes:\n") - for n,name in ipairs(action_names) do - local num = map_action[name] - out:write(format(" %-10s %02X %d\n", name, num, num)) - end - out:write("\n") -end - --- Write action list buffer as a huge static C array. -local function writeactions(out, name) - local nn = #actlist - local last = actlist[nn] or 255 - actlist[nn] = nil -- Remove last byte. - if nn == 0 then nn = 1 end - out:write("static const unsigned char ", name, "[", nn, "] = {\n") - local s = " " - for n,b in ipairs(actlist) do - s = s..b.."," - if #s >= 75 then - assert(out:write(s, "\n")) - s = " " - end - end - out:write(s, last, "\n};\n\n") -- Add last byte back. -end - ------------------------------------------------------------------------------- - --- Add byte to action list. -local function wputxb(n) - assert(n >= 0 and n <= 255 and n % 1 == 0, "byte out of range") - actlist[#actlist+1] = n -end - --- Add action to list with optional arg. Advance buffer pos, too. -local function waction(action, a, num) - wputxb(assert(map_action[action], "bad action name `"..action.."'")) - if a then actargs[#actargs+1] = a end - if a or num then secpos = secpos + (num or 1) end -end - --- Add call to embedded DynASM C code. -local function wcall(func, args) - wline(format("dasm_%s(Dst, %s);", func, concat(args, ", ")), true) -end - --- Delete duplicate action list chunks. A tad slow, but so what. -local function dedupechunk(offset) - local al, as = actlist, actstr - local chunk = char(unpack(al, offset+1, #al)) - local orig = find(as, chunk, 1, true) - if orig then - actargs[1] = orig-1 -- Replace with original offset. - for i=offset+1,#al do al[i] = nil end -- Kill dupe. - else - actstr = as..chunk - end -end - --- Flush action list (intervening C code or buffer pos overflow). -local function wflush(term) - local offset = actargs[1] - if #actlist == offset then return end -- Nothing to flush. - if not term then waction("STOP") end -- Terminate action list. - dedupechunk(offset) - wcall("put", actargs) -- Add call to dasm_put(). - actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put(). - secpos = 1 -- The actionlist offset occupies a buffer position, too. -end - --- Put escaped byte. -local function wputb(n) - if n >= actfirst then waction("ESC") end -- Need to escape byte. - wputxb(n) -end - ------------------------------------------------------------------------------- - --- Global label name -> global label number. With auto assignment on 1st use. -local next_global = 10 -local map_global = setmetatable({}, { __index = function(t, name) - if not match(name, "^[%a_][%w_@]*$") then werror("bad global label") end - local n = next_global - if n > 246 then werror("too many global labels") end - next_global = n + 1 - t[name] = n - return n -end}) - --- Dump global labels. -local function dumpglobals(out, lvl) - local t = {} - for name, n in pairs(map_global) do t[n] = name end - out:write("Global labels:\n") - for i=10,next_global-1 do - out:write(format(" %s\n", t[i])) - end - out:write("\n") -end - --- Write global label enum. -local function writeglobals(out, prefix) - local t = {} - for name, n in pairs(map_global) do t[n] = name end - out:write("enum {\n") - for i=10,next_global-1 do - out:write(" ", prefix, gsub(t[i], "@.*", ""), ",\n") - end - out:write(" ", prefix, "_MAX\n};\n") -end - --- Write global label names. -local function writeglobalnames(out, name) - local t = {} - for name, n in pairs(map_global) do t[n] = name end - out:write("static const char *const ", name, "[] = {\n") - for i=10,next_global-1 do - out:write(" \"", t[i], "\",\n") - end - out:write(" (const char *)0\n};\n") -end - ------------------------------------------------------------------------------- - --- Extern label name -> extern label number. With auto assignment on 1st use. -local next_extern = -1 -local map_extern = setmetatable({}, { __index = function(t, name) - -- No restrictions on the name for now. - local n = next_extern - if n < -256 then werror("too many extern labels") end - next_extern = n - 1 - t[name] = n - return n -end}) - --- Dump extern labels. -local function dumpexterns(out, lvl) - local t = {} - for name, n in pairs(map_extern) do t[-n] = name end - out:write("Extern labels:\n") - for i=1,-next_extern-1 do - out:write(format(" %s\n", t[i])) - end - out:write("\n") -end - --- Write extern label names. -local function writeexternnames(out, name) - local t = {} - for name, n in pairs(map_extern) do t[-n] = name end - out:write("static const char *const ", name, "[] = {\n") - for i=1,-next_extern-1 do - out:write(" \"", t[i], "\",\n") - end - out:write(" (const char *)0\n};\n") -end - ------------------------------------------------------------------------------- - --- Arch-specific maps. -local map_archdef = {} -- Ext. register name -> int. name. -local map_reg_rev = {} -- Int. register name -> ext. name. -local map_reg_num = {} -- Int. register name -> register number. -local map_reg_opsize = {} -- Int. register name -> operand size. -local map_reg_valid_base = {} -- Int. register name -> valid base register? -local map_reg_valid_index = {} -- Int. register name -> valid index register? -local map_reg_needrex = {} -- Int. register name -> need rex vs. no rex. -local reg_list = {} -- Canonical list of int. register names. - -local map_type = {} -- Type name -> { ctype, reg } -local ctypenum = 0 -- Type number (for _PTx macros). - -local addrsize = x64 and "q" or "d" -- Size for address operands. - --- Helper functions to fill register maps. -local function mkrmap(sz, cl, names) - local cname = format("@%s", sz) - reg_list[#reg_list+1] = cname - map_archdef[cl] = cname - map_reg_rev[cname] = cl - map_reg_num[cname] = -1 - map_reg_opsize[cname] = sz - if sz == addrsize or sz == "d" then - map_reg_valid_base[cname] = true - map_reg_valid_index[cname] = true - end - if names then - for n,name in ipairs(names) do - local iname = format("@%s%x", sz, n-1) - reg_list[#reg_list+1] = iname - map_archdef[name] = iname - map_reg_rev[iname] = name - map_reg_num[iname] = n-1 - map_reg_opsize[iname] = sz - if sz == "b" and n > 4 then map_reg_needrex[iname] = false end - if sz == addrsize or sz == "d" then - map_reg_valid_base[iname] = true - map_reg_valid_index[iname] = true - end - end - end - for i=0,(x64 and sz ~= "f") and 15 or 7 do - local needrex = sz == "b" and i > 3 - local iname = format("@%s%x%s", sz, i, needrex and "R" or "") - if needrex then map_reg_needrex[iname] = true end - local name - if sz == "o" then name = format("xmm%d", i) - elseif sz == "f" then name = format("st%d", i) - else name = format("r%d%s", i, sz == addrsize and "" or sz) end - map_archdef[name] = iname - if not map_reg_rev[iname] then - reg_list[#reg_list+1] = iname - map_reg_rev[iname] = name - map_reg_num[iname] = i - map_reg_opsize[iname] = sz - if sz == addrsize or sz == "d" then - map_reg_valid_base[iname] = true - map_reg_valid_index[iname] = true - end - end - end - reg_list[#reg_list+1] = "" -end - --- Integer registers (qword, dword, word and byte sized). -if x64 then - mkrmap("q", "Rq", {"rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi"}) -end -mkrmap("d", "Rd", {"eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi"}) -mkrmap("w", "Rw", {"ax", "cx", "dx", "bx", "sp", "bp", "si", "di"}) -mkrmap("b", "Rb", {"al", "cl", "dl", "bl", "ah", "ch", "dh", "bh"}) -map_reg_valid_index[map_archdef.esp] = false -if x64 then map_reg_valid_index[map_archdef.rsp] = false end -map_archdef["Ra"] = "@"..addrsize - --- FP registers (internally tword sized, but use "f" as operand size). -mkrmap("f", "Rf") - --- SSE registers (oword sized, but qword and dword accessible). -mkrmap("o", "xmm") - --- Operand size prefixes to codes. -local map_opsize = { - byte = "b", word = "w", dword = "d", qword = "q", oword = "o", tword = "t", - aword = addrsize, -} - --- Operand size code to number. -local map_opsizenum = { - b = 1, w = 2, d = 4, q = 8, o = 16, t = 10, -} - --- Operand size code to name. -local map_opsizename = { - b = "byte", w = "word", d = "dword", q = "qword", o = "oword", t = "tword", - f = "fpword", -} - --- Valid index register scale factors. -local map_xsc = { - ["1"] = 0, ["2"] = 1, ["4"] = 2, ["8"] = 3, -} - --- Condition codes. -local map_cc = { - o = 0, no = 1, b = 2, nb = 3, e = 4, ne = 5, be = 6, nbe = 7, - s = 8, ns = 9, p = 10, np = 11, l = 12, nl = 13, le = 14, nle = 15, - c = 2, nae = 2, nc = 3, ae = 3, z = 4, nz = 5, na = 6, a = 7, - pe = 10, po = 11, nge = 12, ge = 13, ng = 14, g = 15, -} - - --- Reverse defines for registers. -function _M.revdef(s) - return gsub(s, "@%w+", map_reg_rev) -end - --- Dump register names and numbers -local function dumpregs(out) - out:write("Register names, sizes and internal numbers:\n") - for _,reg in ipairs(reg_list) do - if reg == "" then - out:write("\n") - else - local name = map_reg_rev[reg] - local num = map_reg_num[reg] - local opsize = map_opsizename[map_reg_opsize[reg]] - out:write(format(" %-5s %-8s %s\n", name, opsize, - num < 0 and "(variable)" or num)) - end - end -end - ------------------------------------------------------------------------------- - --- Put action for label arg (IMM_LG, IMM_PC, REL_LG, REL_PC). -local function wputlabel(aprefix, imm, num) - if type(imm) == "number" then - if imm < 0 then - waction("EXTERN") - wputxb(aprefix == "IMM_" and 0 or 1) - imm = -imm-1 - else - waction(aprefix.."LG", nil, num); - end - wputxb(imm) - else - waction(aprefix.."PC", imm, num) - end -end - --- Put signed byte or arg. -local function wputsbarg(n) - if type(n) == "number" then - if n < -128 or n > 127 then - werror("signed immediate byte out of range") - end - if n < 0 then n = n + 256 end - wputb(n) - else waction("IMM_S", n) end -end - --- Put unsigned byte or arg. -local function wputbarg(n) - if type(n) == "number" then - if n < 0 or n > 255 then - werror("unsigned immediate byte out of range") - end - wputb(n) - else waction("IMM_B", n) end -end - --- Put unsigned word or arg. -local function wputwarg(n) - if type(n) == "number" then - if shr(n, 16) ~= 0 then - werror("unsigned immediate word out of range") - end - wputb(band(n, 255)); wputb(shr(n, 8)); - else waction("IMM_W", n) end -end - --- Put signed or unsigned dword or arg. -local function wputdarg(n) - local tn = type(n) - if tn == "number" then - wputb(band(n, 255)) - wputb(band(shr(n, 8), 255)) - wputb(band(shr(n, 16), 255)) - wputb(shr(n, 24)) - elseif tn == "table" then - wputlabel("IMM_", n[1], 1) - else - waction("IMM_D", n) - end -end - --- Put operand-size dependent number or arg (defaults to dword). -local function wputszarg(sz, n) - if not sz or sz == "d" or sz == "q" then wputdarg(n) - elseif sz == "w" then wputwarg(n) - elseif sz == "b" then wputbarg(n) - elseif sz == "s" then wputsbarg(n) - else werror("bad operand size") end -end - --- Put multi-byte opcode with operand-size dependent modifications. -local function wputop(sz, op, rex) - local r - if rex ~= 0 and not x64 then werror("bad operand size") end - if sz == "w" then wputb(102) end - -- Needs >32 bit numbers, but only for crc32 eax, word [ebx] - if op >= 4294967296 then r = op%4294967296 wputb((op-r)/4294967296) op = r end - if op >= 16777216 then wputb(shr(op, 24)); op = band(op, 0xffffff) end - if op >= 65536 then - if rex ~= 0 then - local opc3 = band(op, 0xffff00) - if opc3 == 0x0f3a00 or opc3 == 0x0f3800 then - wputb(64 + band(rex, 15)); rex = 0 - end - end - wputb(shr(op, 16)); op = band(op, 0xffff) - end - if op >= 256 then - local b = shr(op, 8) - if b == 15 and rex ~= 0 then wputb(64 + band(rex, 15)); rex = 0 end - wputb(b) - op = band(op, 255) - end - if rex ~= 0 then wputb(64 + band(rex, 15)) end - if sz == "b" then op = op - 1 end - wputb(op) -end - --- Put ModRM or SIB formatted byte. -local function wputmodrm(m, s, rm, vs, vrm) - assert(m < 4 and s < 16 and rm < 16, "bad modrm operands") - wputb(shl(m, 6) + shl(band(s, 7), 3) + band(rm, 7)) -end - --- Put ModRM/SIB plus optional displacement. -local function wputmrmsib(t, imark, s, vsreg) - local vreg, vxreg - local reg, xreg = t.reg, t.xreg - if reg and reg < 0 then reg = 0; vreg = t.vreg end - if xreg and xreg < 0 then xreg = 0; vxreg = t.vxreg end - if s < 0 then s = 0 end - - -- Register mode. - if sub(t.mode, 1, 1) == "r" then - wputmodrm(3, s, reg) - if vsreg then waction("VREG", vsreg); wputxb(2) end - if vreg then waction("VREG", vreg); wputxb(0) end - return - end - - local disp = t.disp - local tdisp = type(disp) - -- No base register? - if not reg then - local riprel = false - if xreg then - -- Indexed mode with index register only. - -- [xreg*xsc+disp] -> (0, s, esp) (xsc, xreg, ebp) - wputmodrm(0, s, 4) - if imark == "I" then waction("MARK") end - if vsreg then waction("VREG", vsreg); wputxb(2) end - wputmodrm(t.xsc, xreg, 5) - if vxreg then waction("VREG", vxreg); wputxb(3) end - else - -- Pure 32 bit displacement. - if x64 and tdisp ~= "table" then - wputmodrm(0, s, 4) -- [disp] -> (0, s, esp) (0, esp, ebp) - if imark == "I" then waction("MARK") end - wputmodrm(0, 4, 5) - else - riprel = x64 - wputmodrm(0, s, 5) -- [disp|rip-label] -> (0, s, ebp) - if imark == "I" then waction("MARK") end - end - if vsreg then waction("VREG", vsreg); wputxb(2) end - end - if riprel then -- Emit rip-relative displacement. - if match("UWSiI", imark) then - werror("NYI: rip-relative displacement followed by immediate") - end - -- The previous byte in the action buffer cannot be 0xe9 or 0x80-0x8f. - wputlabel("REL_", disp[1], 2) - else - wputdarg(disp) - end - return - end - - local m - if tdisp == "number" then -- Check displacement size at assembly time. - if disp == 0 and band(reg, 7) ~= 5 then -- [ebp] -> [ebp+0] (in SIB, too) - if not vreg then m = 0 end -- Force DISP to allow [Rd(5)] -> [ebp+0] - elseif disp >= -128 and disp <= 127 then m = 1 - else m = 2 end - elseif tdisp == "table" then - m = 2 - end - - -- Index register present or esp as base register: need SIB encoding. - if xreg or band(reg, 7) == 4 then - wputmodrm(m or 2, s, 4) -- ModRM. - if m == nil or imark == "I" then waction("MARK") end - if vsreg then waction("VREG", vsreg); wputxb(2) end - wputmodrm(t.xsc or 0, xreg or 4, reg) -- SIB. - if vxreg then waction("VREG", vxreg); wputxb(3) end - if vreg then waction("VREG", vreg); wputxb(1) end - else - wputmodrm(m or 2, s, reg) -- ModRM. - if (imark == "I" and (m == 1 or m == 2)) or - (m == nil and (vsreg or vreg)) then waction("MARK") end - if vsreg then waction("VREG", vsreg); wputxb(2) end - if vreg then waction("VREG", vreg); wputxb(1) end - end - - -- Put displacement. - if m == 1 then wputsbarg(disp) - elseif m == 2 then wputdarg(disp) - elseif m == nil then waction("DISP", disp) end -end - ------------------------------------------------------------------------------- - --- Return human-readable operand mode string. -local function opmodestr(op, args) - local m = {} - for i=1,#args do - local a = args[i] - m[#m+1] = sub(a.mode, 1, 1)..(a.opsize or "?") - end - return op.." "..concat(m, ",") -end - --- Convert number to valid integer or nil. -local function toint(expr) - local n = tonumber(expr) - if n then - if n % 1 ~= 0 or n < -2147483648 or n > 4294967295 then - werror("bad integer number `"..expr.."'") - end - return n - end -end - --- Parse immediate expression. -local function immexpr(expr) - -- &expr (pointer) - if sub(expr, 1, 1) == "&" then - return "iPJ", format("(ptrdiff_t)(%s)", sub(expr,2)) - end - - local prefix = sub(expr, 1, 2) - -- =>expr (pc label reference) - if prefix == "=>" then - return "iJ", sub(expr, 3) - end - -- ->name (global label reference) - if prefix == "->" then - return "iJ", map_global[sub(expr, 3)] - end - - -- [<>][1-9] (local label reference) - local dir, lnum = match(expr, "^([<>])([1-9])$") - if dir then -- Fwd: 247-255, Bkwd: 1-9. - return "iJ", lnum + (dir == ">" and 246 or 0) - end - - local extname = match(expr, "^extern%s+(%S+)$") - if extname then - return "iJ", map_extern[extname] - end - - -- expr (interpreted as immediate) - return "iI", expr -end - --- Parse displacement expression: +-num, +-expr, +-opsize*num -local function dispexpr(expr) - local disp = expr == "" and 0 or toint(expr) - if disp then return disp end - local c, dispt = match(expr, "^([+-])%s*(.+)$") - if c == "+" then - expr = dispt - elseif not c then - werror("bad displacement expression `"..expr.."'") - end - local opsize, tailops = match(dispt, "^(%w+)%s*%*%s*(.+)$") - local ops, imm = map_opsize[opsize], toint(tailops) - if ops and imm then - if c == "-" then imm = -imm end - return imm*map_opsizenum[ops] - end - local mode, iexpr = immexpr(dispt) - if mode == "iJ" then - if c == "-" then werror("cannot invert label reference") end - return { iexpr } - end - return expr -- Need to return original signed expression. -end - --- Parse register or type expression. -local function rtexpr(expr) - if not expr then return end - local tname, ovreg = match(expr, "^([%w_]+):(@[%w_]+)$") - local tp = map_type[tname or expr] - if tp then - local reg = ovreg or tp.reg - local rnum = map_reg_num[reg] - if not rnum then - werror("type `"..(tname or expr).."' needs a register override") - end - if not map_reg_valid_base[reg] then - werror("bad base register override `"..(map_reg_rev[reg] or reg).."'") - end - return reg, rnum, tp - end - return expr, map_reg_num[expr] -end - --- Parse operand and return { mode, opsize, reg, xreg, xsc, disp, imm }. -local function parseoperand(param) - local t = {} - - local expr = param - local opsize, tailops = match(param, "^(%w+)%s*(.+)$") - if opsize then - t.opsize = map_opsize[opsize] - if t.opsize then expr = tailops end - end - - local br = match(expr, "^%[%s*(.-)%s*%]$") - repeat - if br then - t.mode = "xm" - - -- [disp] - t.disp = toint(br) - if t.disp then - t.mode = x64 and "xm" or "xmO" - break - end - - -- [reg...] - local tp - local reg, tailr = match(br, "^([@%w_:]+)%s*(.*)$") - reg, t.reg, tp = rtexpr(reg) - if not t.reg then - -- [expr] - t.mode = x64 and "xm" or "xmO" - t.disp = dispexpr("+"..br) - break - end - - if t.reg == -1 then - t.vreg, tailr = match(tailr, "^(%b())(.*)$") - if not t.vreg then werror("bad variable register expression") end - end - - -- [xreg*xsc] or [xreg*xsc+-disp] or [xreg*xsc+-expr] - local xsc, tailsc = match(tailr, "^%*%s*([1248])%s*(.*)$") - if xsc then - if not map_reg_valid_index[reg] then - werror("bad index register `"..map_reg_rev[reg].."'") - end - t.xsc = map_xsc[xsc] - t.xreg = t.reg - t.vxreg = t.vreg - t.reg = nil - t.vreg = nil - t.disp = dispexpr(tailsc) - break - end - if not map_reg_valid_base[reg] then - werror("bad base register `"..map_reg_rev[reg].."'") - end - - -- [reg] or [reg+-disp] - t.disp = toint(tailr) or (tailr == "" and 0) - if t.disp then break end - - -- [reg+xreg...] - local xreg, tailx = match(tailr, "^+%s*([@%w_:]+)%s*(.*)$") - xreg, t.xreg, tp = rtexpr(xreg) - if not t.xreg then - -- [reg+-expr] - t.disp = dispexpr(tailr) - break - end - if not map_reg_valid_index[xreg] then - werror("bad index register `"..map_reg_rev[xreg].."'") - end - - if t.xreg == -1 then - t.vxreg, tailx = match(tailx, "^(%b())(.*)$") - if not t.vxreg then werror("bad variable register expression") end - end - - -- [reg+xreg*xsc...] - local xsc, tailsc = match(tailx, "^%*%s*([1248])%s*(.*)$") - if xsc then - t.xsc = map_xsc[xsc] - tailx = tailsc - end - - -- [...] or [...+-disp] or [...+-expr] - t.disp = dispexpr(tailx) - else - -- imm or opsize*imm - local imm = toint(expr) - if not imm and sub(expr, 1, 1) == "*" and t.opsize then - imm = toint(sub(expr, 2)) - if imm then - imm = imm * map_opsizenum[t.opsize] - t.opsize = nil - end - end - if imm then - if t.opsize then werror("bad operand size override") end - local m = "i" - if imm == 1 then m = m.."1" end - if imm >= 4294967168 and imm <= 4294967295 then imm = imm-4294967296 end - if imm >= -128 and imm <= 127 then m = m.."S" end - t.imm = imm - t.mode = m - break - end - - local tp - local reg, tailr = match(expr, "^([@%w_:]+)%s*(.*)$") - reg, t.reg, tp = rtexpr(reg) - if t.reg then - if t.reg == -1 then - t.vreg, tailr = match(tailr, "^(%b())(.*)$") - if not t.vreg then werror("bad variable register expression") end - end - -- reg - if tailr == "" then - if t.opsize then werror("bad operand size override") end - t.opsize = map_reg_opsize[reg] - if t.opsize == "f" then - t.mode = t.reg == 0 and "fF" or "f" - else - if reg == "@w4" or (x64 and reg == "@d4") then - wwarn("bad idea, try again with `"..(x64 and "rsp'" or "esp'")) - end - t.mode = t.reg == 0 and "rmR" or (reg == "@b1" and "rmC" or "rm") - end - t.needrex = map_reg_needrex[reg] - break - end - - -- type[idx], type[idx].field, type->field -> [reg+offset_expr] - if not tp then werror("bad operand `"..param.."'") end - t.mode = "xm" - t.disp = format(tp.ctypefmt, tailr) - else - t.mode, t.imm = immexpr(expr) - if sub(t.mode, -1) == "J" then - if t.opsize and t.opsize ~= addrsize then - werror("bad operand size override") - end - t.opsize = addrsize - end - end - end - until true - return t -end - ------------------------------------------------------------------------------- --- x86 Template String Description --- =============================== --- --- Each template string is a list of [match:]pattern pairs, --- separated by "|". The first match wins. No match means a --- bad or unsupported combination of operand modes or sizes. --- --- The match part and the ":" is omitted if the operation has --- no operands. Otherwise the first N characters are matched --- against the mode strings of each of the N operands. --- --- The mode string for each operand type is (see parseoperand()): --- Integer register: "rm", +"R" for eax, ax, al, +"C" for cl --- FP register: "f", +"F" for st0 --- Index operand: "xm", +"O" for [disp] (pure offset) --- Immediate: "i", +"S" for signed 8 bit, +"1" for 1, --- +"I" for arg, +"P" for pointer --- Any: +"J" for valid jump targets --- --- So a match character "m" (mixed) matches both an integer register --- and an index operand (to be encoded with the ModRM/SIB scheme). --- But "r" matches only a register and "x" only an index operand --- (e.g. for FP memory access operations). --- --- The operand size match string starts right after the mode match --- characters and ends before the ":". "dwb" or "qdwb" is assumed, if empty. --- The effective data size of the operation is matched against this list. --- --- If only the regular "b", "w", "d", "q", "t" operand sizes are --- present, then all operands must be the same size. Unspecified sizes --- are ignored, but at least one operand must have a size or the pattern --- won't match (use the "byte", "word", "dword", "qword", "tword" --- operand size overrides. E.g.: mov dword [eax], 1). --- --- If the list has a "1" or "2" prefix, the operand size is taken --- from the respective operand and any other operand sizes are ignored. --- If the list contains only ".", all operand sizes are ignored. --- If the list has a "/" prefix, the concatenated (mixed) operand sizes --- are compared to the match. --- --- E.g. "rrdw" matches for either two dword registers or two word --- registers. "Fx2dq" matches an st0 operand plus an index operand --- pointing to a dword (float) or qword (double). --- --- Every character after the ":" is part of the pattern string: --- Hex chars are accumulated to form the opcode (left to right). --- "n" disables the standard opcode mods --- (otherwise: -1 for "b", o16 prefix for "w", rex.w for "q") --- "X" Force REX.W. --- "r"/"R" adds the reg. number from the 1st/2nd operand to the opcode. --- "m"/"M" generates ModRM/SIB from the 1st/2nd operand. --- The spare 3 bits are either filled with the last hex digit or --- the result from a previous "r"/"R". The opcode is restored. --- --- All of the following characters force a flush of the opcode: --- "o"/"O" stores a pure 32 bit disp (offset) from the 1st/2nd operand. --- "S" stores a signed 8 bit immediate from the last operand. --- "U" stores an unsigned 8 bit immediate from the last operand. --- "W" stores an unsigned 16 bit immediate from the last operand. --- "i" stores an operand sized immediate from the last operand. --- "I" dito, but generates an action code to optionally modify --- the opcode (+2) for a signed 8 bit immediate. --- "J" generates one of the REL action codes from the last operand. --- ------------------------------------------------------------------------------- - --- Template strings for x86 instructions. Ordered by first opcode byte. --- Unimplemented opcodes (deliberate omissions) are marked with *. -local map_op = { - -- 00-05: add... - -- 06: *push es - -- 07: *pop es - -- 08-0D: or... - -- 0E: *push cs - -- 0F: two byte opcode prefix - -- 10-15: adc... - -- 16: *push ss - -- 17: *pop ss - -- 18-1D: sbb... - -- 1E: *push ds - -- 1F: *pop ds - -- 20-25: and... - es_0 = "26", - -- 27: *daa - -- 28-2D: sub... - cs_0 = "2E", - -- 2F: *das - -- 30-35: xor... - ss_0 = "36", - -- 37: *aaa - -- 38-3D: cmp... - ds_0 = "3E", - -- 3F: *aas - inc_1 = x64 and "m:FF0m" or "rdw:40r|m:FF0m", - dec_1 = x64 and "m:FF1m" or "rdw:48r|m:FF1m", - push_1 = (x64 and "rq:n50r|rw:50r|mq:nFF6m|mw:FF6m" or - "rdw:50r|mdw:FF6m").."|S.:6AS|ib:n6Ai|i.:68i", - pop_1 = x64 and "rq:n58r|rw:58r|mq:n8F0m|mw:8F0m" or "rdw:58r|mdw:8F0m", - -- 60: *pusha, *pushad, *pushaw - -- 61: *popa, *popad, *popaw - -- 62: *bound rdw,x - -- 63: x86: *arpl mw,rw - movsxd_2 = x64 and "rm/qd:63rM", - fs_0 = "64", - gs_0 = "65", - o16_0 = "66", - a16_0 = not x64 and "67" or nil, - a32_0 = x64 and "67", - -- 68: push idw - -- 69: imul rdw,mdw,idw - -- 6A: push ib - -- 6B: imul rdw,mdw,S - -- 6C: *insb - -- 6D: *insd, *insw - -- 6E: *outsb - -- 6F: *outsd, *outsw - -- 70-7F: jcc lb - -- 80: add... mb,i - -- 81: add... mdw,i - -- 82: *undefined - -- 83: add... mdw,S - test_2 = "mr:85Rm|rm:85rM|Ri:A9ri|mi:F70mi", - -- 86: xchg rb,mb - -- 87: xchg rdw,mdw - -- 88: mov mb,r - -- 89: mov mdw,r - -- 8A: mov r,mb - -- 8B: mov r,mdw - -- 8C: *mov mdw,seg - lea_2 = "rx1dq:8DrM", - -- 8E: *mov seg,mdw - -- 8F: pop mdw - nop_0 = "90", - xchg_2 = "Rrqdw:90R|rRqdw:90r|rm:87rM|mr:87Rm", - cbw_0 = "6698", - cwde_0 = "98", - cdqe_0 = "4898", - cwd_0 = "6699", - cdq_0 = "99", - cqo_0 = "4899", - -- 9A: *call iw:idw - wait_0 = "9B", - fwait_0 = "9B", - pushf_0 = "9C", - pushfd_0 = not x64 and "9C", - pushfq_0 = x64 and "9C", - popf_0 = "9D", - popfd_0 = not x64 and "9D", - popfq_0 = x64 and "9D", - sahf_0 = "9E", - lahf_0 = "9F", - mov_2 = "OR:A3o|RO:A1O|mr:89Rm|rm:8BrM|rib:nB0ri|ridw:B8ri|mi:C70mi", - movsb_0 = "A4", - movsw_0 = "66A5", - movsd_0 = "A5", - cmpsb_0 = "A6", - cmpsw_0 = "66A7", - cmpsd_0 = "A7", - -- A8: test Rb,i - -- A9: test Rdw,i - stosb_0 = "AA", - stosw_0 = "66AB", - stosd_0 = "AB", - lodsb_0 = "AC", - lodsw_0 = "66AD", - lodsd_0 = "AD", - scasb_0 = "AE", - scasw_0 = "66AF", - scasd_0 = "AF", - -- B0-B7: mov rb,i - -- B8-BF: mov rdw,i - -- C0: rol... mb,i - -- C1: rol... mdw,i - ret_1 = "i.:nC2W", - ret_0 = "C3", - -- C4: *les rdw,mq - -- C5: *lds rdw,mq - -- C6: mov mb,i - -- C7: mov mdw,i - -- C8: *enter iw,ib - leave_0 = "C9", - -- CA: *retf iw - -- CB: *retf - int3_0 = "CC", - int_1 = "i.:nCDU", - into_0 = "CE", - -- CF: *iret - -- D0: rol... mb,1 - -- D1: rol... mdw,1 - -- D2: rol... mb,cl - -- D3: rol... mb,cl - -- D4: *aam ib - -- D5: *aad ib - -- D6: *salc - -- D7: *xlat - -- D8-DF: floating point ops - -- E0: *loopne - -- E1: *loope - -- E2: *loop - -- E3: *jcxz, *jecxz - -- E4: *in Rb,ib - -- E5: *in Rdw,ib - -- E6: *out ib,Rb - -- E7: *out ib,Rdw - call_1 = x64 and "mq:nFF2m|J.:E8nJ" or "md:FF2m|J.:E8J", - jmp_1 = x64 and "mq:nFF4m|J.:E9nJ" or "md:FF4m|J.:E9J", -- short: EB - -- EA: *jmp iw:idw - -- EB: jmp ib - -- EC: *in Rb,dx - -- ED: *in Rdw,dx - -- EE: *out dx,Rb - -- EF: *out dx,Rdw - lock_0 = "F0", - int1_0 = "F1", - repne_0 = "F2", - repnz_0 = "F2", - rep_0 = "F3", - repe_0 = "F3", - repz_0 = "F3", - -- F4: *hlt - cmc_0 = "F5", - -- F6: test... mb,i; div... mb - -- F7: test... mdw,i; div... mdw - clc_0 = "F8", - stc_0 = "F9", - -- FA: *cli - cld_0 = "FC", - std_0 = "FD", - -- FE: inc... mb - -- FF: inc... mdw - - -- misc ops - not_1 = "m:F72m", - neg_1 = "m:F73m", - mul_1 = "m:F74m", - imul_1 = "m:F75m", - div_1 = "m:F76m", - idiv_1 = "m:F77m", - - imul_2 = "rmqdw:0FAFrM|rIqdw:69rmI|rSqdw:6BrmS|riqdw:69rmi", - imul_3 = "rmIqdw:69rMI|rmSqdw:6BrMS|rmiqdw:69rMi", - - movzx_2 = "rm/db:0FB6rM|rm/qb:|rm/wb:0FB6rM|rm/dw:0FB7rM|rm/qw:", - movsx_2 = "rm/db:0FBErM|rm/qb:|rm/wb:0FBErM|rm/dw:0FBFrM|rm/qw:", - - bswap_1 = "rqd:0FC8r", - bsf_2 = "rmqdw:0FBCrM", - bsr_2 = "rmqdw:0FBDrM", - bt_2 = "mrqdw:0FA3Rm|miqdw:0FBA4mU", - btc_2 = "mrqdw:0FBBRm|miqdw:0FBA7mU", - btr_2 = "mrqdw:0FB3Rm|miqdw:0FBA6mU", - bts_2 = "mrqdw:0FABRm|miqdw:0FBA5mU", - - rdtsc_0 = "0F31", -- P1+ - cpuid_0 = "0FA2", -- P1+ - - -- floating point ops - fst_1 = "ff:DDD0r|xd:D92m|xq:nDD2m", - fstp_1 = "ff:DDD8r|xd:D93m|xq:nDD3m|xt:DB7m", - fld_1 = "ff:D9C0r|xd:D90m|xq:nDD0m|xt:DB5m", - - fpop_0 = "DDD8", -- Alias for fstp st0. - - fist_1 = "xw:nDF2m|xd:DB2m", - fistp_1 = "xw:nDF3m|xd:DB3m|xq:nDF7m", - fild_1 = "xw:nDF0m|xd:DB0m|xq:nDF5m", - - fxch_0 = "D9C9", - fxch_1 = "ff:D9C8r", - fxch_2 = "fFf:D9C8r|Fff:D9C8R", - - fucom_1 = "ff:DDE0r", - fucom_2 = "Fff:DDE0R", - fucomp_1 = "ff:DDE8r", - fucomp_2 = "Fff:DDE8R", - fucomi_1 = "ff:DBE8r", -- P6+ - fucomi_2 = "Fff:DBE8R", -- P6+ - fucomip_1 = "ff:DFE8r", -- P6+ - fucomip_2 = "Fff:DFE8R", -- P6+ - fcomi_1 = "ff:DBF0r", -- P6+ - fcomi_2 = "Fff:DBF0R", -- P6+ - fcomip_1 = "ff:DFF0r", -- P6+ - fcomip_2 = "Fff:DFF0R", -- P6+ - fucompp_0 = "DAE9", - fcompp_0 = "DED9", - - fldcw_1 = "xw:nD95m", - fstcw_1 = "xw:n9BD97m", - fnstcw_1 = "xw:nD97m", - fstsw_1 = "Rw:n9BDFE0|xw:n9BDD7m", - fnstsw_1 = "Rw:nDFE0|xw:nDD7m", - fclex_0 = "9BDBE2", - fnclex_0 = "DBE2", - - fnop_0 = "D9D0", - -- D9D1-D9DF: unassigned - - fchs_0 = "D9E0", - fabs_0 = "D9E1", - -- D9E2: unassigned - -- D9E3: unassigned - ftst_0 = "D9E4", - fxam_0 = "D9E5", - -- D9E6: unassigned - -- D9E7: unassigned - fld1_0 = "D9E8", - fldl2t_0 = "D9E9", - fldl2e_0 = "D9EA", - fldpi_0 = "D9EB", - fldlg2_0 = "D9EC", - fldln2_0 = "D9ED", - fldz_0 = "D9EE", - -- D9EF: unassigned - - f2xm1_0 = "D9F0", - fyl2x_0 = "D9F1", - fptan_0 = "D9F2", - fpatan_0 = "D9F3", - fxtract_0 = "D9F4", - fprem1_0 = "D9F5", - fdecstp_0 = "D9F6", - fincstp_0 = "D9F7", - fprem_0 = "D9F8", - fyl2xp1_0 = "D9F9", - fsqrt_0 = "D9FA", - fsincos_0 = "D9FB", - frndint_0 = "D9FC", - fscale_0 = "D9FD", - fsin_0 = "D9FE", - fcos_0 = "D9FF", - - -- SSE, SSE2 - andnpd_2 = "rmo:660F55rM", - andnps_2 = "rmo:0F55rM", - andpd_2 = "rmo:660F54rM", - andps_2 = "rmo:0F54rM", - clflush_1 = "x.:0FAE7m", - cmppd_3 = "rmio:660FC2rMU", - cmpps_3 = "rmio:0FC2rMU", - cmpsd_3 = "rrio:F20FC2rMU|rxi/oq:", - cmpss_3 = "rrio:F30FC2rMU|rxi/od:", - comisd_2 = "rro:660F2FrM|rx/oq:", - comiss_2 = "rro:0F2FrM|rx/od:", - cvtdq2pd_2 = "rro:F30FE6rM|rx/oq:", - cvtdq2ps_2 = "rmo:0F5BrM", - cvtpd2dq_2 = "rmo:F20FE6rM", - cvtpd2ps_2 = "rmo:660F5ArM", - cvtpi2pd_2 = "rx/oq:660F2ArM", - cvtpi2ps_2 = "rx/oq:0F2ArM", - cvtps2dq_2 = "rmo:660F5BrM", - cvtps2pd_2 = "rro:0F5ArM|rx/oq:", - cvtsd2si_2 = "rr/do:F20F2DrM|rr/qo:|rx/dq:|rxq:", - cvtsd2ss_2 = "rro:F20F5ArM|rx/oq:", - cvtsi2sd_2 = "rm/od:F20F2ArM|rm/oq:F20F2ArXM", - cvtsi2ss_2 = "rm/od:F30F2ArM|rm/oq:F30F2ArXM", - cvtss2sd_2 = "rro:F30F5ArM|rx/od:", - cvtss2si_2 = "rr/do:F20F2CrM|rr/qo:|rxd:|rx/qd:", - cvttpd2dq_2 = "rmo:660FE6rM", - cvttps2dq_2 = "rmo:F30F5BrM", - cvttsd2si_2 = "rr/do:F20F2CrM|rr/qo:|rx/dq:|rxq:", - cvttss2si_2 = "rr/do:F30F2CrM|rr/qo:|rxd:|rx/qd:", - ldmxcsr_1 = "xd:0FAE2m", - lfence_0 = "0FAEE8", - maskmovdqu_2 = "rro:660FF7rM", - mfence_0 = "0FAEF0", - movapd_2 = "rmo:660F28rM|mro:660F29Rm", - movaps_2 = "rmo:0F28rM|mro:0F29Rm", - movd_2 = "rm/od:660F6ErM|rm/oq:660F6ErXM|mr/do:660F7ERm|mr/qo:", - movdqa_2 = "rmo:660F6FrM|mro:660F7FRm", - movdqu_2 = "rmo:F30F6FrM|mro:F30F7FRm", - movhlps_2 = "rro:0F12rM", - movhpd_2 = "rx/oq:660F16rM|xr/qo:n660F17Rm", - movhps_2 = "rx/oq:0F16rM|xr/qo:n0F17Rm", - movlhps_2 = "rro:0F16rM", - movlpd_2 = "rx/oq:660F12rM|xr/qo:n660F13Rm", - movlps_2 = "rx/oq:0F12rM|xr/qo:n0F13Rm", - movmskpd_2 = "rr/do:660F50rM", - movmskps_2 = "rr/do:0F50rM", - movntdq_2 = "xro:660FE7Rm", - movnti_2 = "xrqd:0FC3Rm", - movntpd_2 = "xro:660F2BRm", - movntps_2 = "xro:0F2BRm", - movq_2 = "rro:F30F7ErM|rx/oq:|xr/qo:n660FD6Rm", - movsd_2 = "rro:F20F10rM|rx/oq:|xr/qo:nF20F11Rm", - movss_2 = "rro:F30F10rM|rx/od:|xr/do:F30F11Rm", - movupd_2 = "rmo:660F10rM|mro:660F11Rm", - movups_2 = "rmo:0F10rM|mro:0F11Rm", - orpd_2 = "rmo:660F56rM", - orps_2 = "rmo:0F56rM", - packssdw_2 = "rmo:660F6BrM", - packsswb_2 = "rmo:660F63rM", - packuswb_2 = "rmo:660F67rM", - paddb_2 = "rmo:660FFCrM", - paddd_2 = "rmo:660FFErM", - paddq_2 = "rmo:660FD4rM", - paddsb_2 = "rmo:660FECrM", - paddsw_2 = "rmo:660FEDrM", - paddusb_2 = "rmo:660FDCrM", - paddusw_2 = "rmo:660FDDrM", - paddw_2 = "rmo:660FFDrM", - pand_2 = "rmo:660FDBrM", - pandn_2 = "rmo:660FDFrM", - pause_0 = "F390", - pavgb_2 = "rmo:660FE0rM", - pavgw_2 = "rmo:660FE3rM", - pcmpeqb_2 = "rmo:660F74rM", - pcmpeqd_2 = "rmo:660F76rM", - pcmpeqw_2 = "rmo:660F75rM", - pcmpgtb_2 = "rmo:660F64rM", - pcmpgtd_2 = "rmo:660F66rM", - pcmpgtw_2 = "rmo:660F65rM", - pextrw_3 = "rri/do:660FC5rMU|xri/wo:660F3A15nrMU", -- Mem op: SSE4.1 only. - pinsrw_3 = "rri/od:660FC4rMU|rxi/ow:", - pmaddwd_2 = "rmo:660FF5rM", - pmaxsw_2 = "rmo:660FEErM", - pmaxub_2 = "rmo:660FDErM", - pminsw_2 = "rmo:660FEArM", - pminub_2 = "rmo:660FDArM", - pmovmskb_2 = "rr/do:660FD7rM", - pmulhuw_2 = "rmo:660FE4rM", - pmulhw_2 = "rmo:660FE5rM", - pmullw_2 = "rmo:660FD5rM", - pmuludq_2 = "rmo:660FF4rM", - por_2 = "rmo:660FEBrM", - prefetchnta_1 = "xb:n0F180m", - prefetcht0_1 = "xb:n0F181m", - prefetcht1_1 = "xb:n0F182m", - prefetcht2_1 = "xb:n0F183m", - psadbw_2 = "rmo:660FF6rM", - pshufd_3 = "rmio:660F70rMU", - pshufhw_3 = "rmio:F30F70rMU", - pshuflw_3 = "rmio:F20F70rMU", - pslld_2 = "rmo:660FF2rM|rio:660F726mU", - pslldq_2 = "rio:660F737mU", - psllq_2 = "rmo:660FF3rM|rio:660F736mU", - psllw_2 = "rmo:660FF1rM|rio:660F716mU", - psrad_2 = "rmo:660FE2rM|rio:660F724mU", - psraw_2 = "rmo:660FE1rM|rio:660F714mU", - psrld_2 = "rmo:660FD2rM|rio:660F722mU", - psrldq_2 = "rio:660F733mU", - psrlq_2 = "rmo:660FD3rM|rio:660F732mU", - psrlw_2 = "rmo:660FD1rM|rio:660F712mU", - psubb_2 = "rmo:660FF8rM", - psubd_2 = "rmo:660FFArM", - psubq_2 = "rmo:660FFBrM", - psubsb_2 = "rmo:660FE8rM", - psubsw_2 = "rmo:660FE9rM", - psubusb_2 = "rmo:660FD8rM", - psubusw_2 = "rmo:660FD9rM", - psubw_2 = "rmo:660FF9rM", - punpckhbw_2 = "rmo:660F68rM", - punpckhdq_2 = "rmo:660F6ArM", - punpckhqdq_2 = "rmo:660F6DrM", - punpckhwd_2 = "rmo:660F69rM", - punpcklbw_2 = "rmo:660F60rM", - punpckldq_2 = "rmo:660F62rM", - punpcklqdq_2 = "rmo:660F6CrM", - punpcklwd_2 = "rmo:660F61rM", - pxor_2 = "rmo:660FEFrM", - rcpps_2 = "rmo:0F53rM", - rcpss_2 = "rro:F30F53rM|rx/od:", - rsqrtps_2 = "rmo:0F52rM", - rsqrtss_2 = "rmo:F30F52rM", - sfence_0 = "0FAEF8", - shufpd_3 = "rmio:660FC6rMU", - shufps_3 = "rmio:0FC6rMU", - stmxcsr_1 = "xd:0FAE3m", - ucomisd_2 = "rro:660F2ErM|rx/oq:", - ucomiss_2 = "rro:0F2ErM|rx/od:", - unpckhpd_2 = "rmo:660F15rM", - unpckhps_2 = "rmo:0F15rM", - unpcklpd_2 = "rmo:660F14rM", - unpcklps_2 = "rmo:0F14rM", - xorpd_2 = "rmo:660F57rM", - xorps_2 = "rmo:0F57rM", - - -- SSE3 ops - fisttp_1 = "xw:nDF1m|xd:DB1m|xq:nDD1m", - addsubpd_2 = "rmo:660FD0rM", - addsubps_2 = "rmo:F20FD0rM", - haddpd_2 = "rmo:660F7CrM", - haddps_2 = "rmo:F20F7CrM", - hsubpd_2 = "rmo:660F7DrM", - hsubps_2 = "rmo:F20F7DrM", - lddqu_2 = "rxo:F20FF0rM", - movddup_2 = "rmo:F20F12rM", - movshdup_2 = "rmo:F30F16rM", - movsldup_2 = "rmo:F30F12rM", - - -- SSSE3 ops - pabsb_2 = "rmo:660F381CrM", - pabsd_2 = "rmo:660F381ErM", - pabsw_2 = "rmo:660F381DrM", - palignr_3 = "rmio:660F3A0FrMU", - phaddd_2 = "rmo:660F3802rM", - phaddsw_2 = "rmo:660F3803rM", - phaddw_2 = "rmo:660F3801rM", - phsubd_2 = "rmo:660F3806rM", - phsubsw_2 = "rmo:660F3807rM", - phsubw_2 = "rmo:660F3805rM", - pmaddubsw_2 = "rmo:660F3804rM", - pmulhrsw_2 = "rmo:660F380BrM", - pshufb_2 = "rmo:660F3800rM", - psignb_2 = "rmo:660F3808rM", - psignd_2 = "rmo:660F380ArM", - psignw_2 = "rmo:660F3809rM", - - -- SSE4.1 ops - blendpd_3 = "rmio:660F3A0DrMU", - blendps_3 = "rmio:660F3A0CrMU", - blendvpd_3 = "rmRo:660F3815rM", - blendvps_3 = "rmRo:660F3814rM", - dppd_3 = "rmio:660F3A41rMU", - dpps_3 = "rmio:660F3A40rMU", - extractps_3 = "mri/do:660F3A17RmU|rri/qo:660F3A17RXmU", - insertps_3 = "rrio:660F3A41rMU|rxi/od:", - movntdqa_2 = "rmo:660F382ArM", - mpsadbw_3 = "rmio:660F3A42rMU", - packusdw_2 = "rmo:660F382BrM", - pblendvb_3 = "rmRo:660F3810rM", - pblendw_3 = "rmio:660F3A0ErMU", - pcmpeqq_2 = "rmo:660F3829rM", - pextrb_3 = "rri/do:660F3A14nRmU|rri/qo:|xri/bo:", - pextrd_3 = "mri/do:660F3A16RmU", - pextrq_3 = "mri/qo:660F3A16RmU", - -- pextrw is SSE2, mem operand is SSE4.1 only - phminposuw_2 = "rmo:660F3841rM", - pinsrb_3 = "rri/od:660F3A20nrMU|rxi/ob:", - pinsrd_3 = "rmi/od:660F3A22rMU", - pinsrq_3 = "rmi/oq:660F3A22rXMU", - pmaxsb_2 = "rmo:660F383CrM", - pmaxsd_2 = "rmo:660F383DrM", - pmaxud_2 = "rmo:660F383FrM", - pmaxuw_2 = "rmo:660F383ErM", - pminsb_2 = "rmo:660F3838rM", - pminsd_2 = "rmo:660F3839rM", - pminud_2 = "rmo:660F383BrM", - pminuw_2 = "rmo:660F383ArM", - pmovsxbd_2 = "rro:660F3821rM|rx/od:", - pmovsxbq_2 = "rro:660F3822rM|rx/ow:", - pmovsxbw_2 = "rro:660F3820rM|rx/oq:", - pmovsxdq_2 = "rro:660F3825rM|rx/oq:", - pmovsxwd_2 = "rro:660F3823rM|rx/oq:", - pmovsxwq_2 = "rro:660F3824rM|rx/od:", - pmovzxbd_2 = "rro:660F3831rM|rx/od:", - pmovzxbq_2 = "rro:660F3832rM|rx/ow:", - pmovzxbw_2 = "rro:660F3830rM|rx/oq:", - pmovzxdq_2 = "rro:660F3835rM|rx/oq:", - pmovzxwd_2 = "rro:660F3833rM|rx/oq:", - pmovzxwq_2 = "rro:660F3834rM|rx/od:", - pmuldq_2 = "rmo:660F3828rM", - pmulld_2 = "rmo:660F3840rM", - ptest_2 = "rmo:660F3817rM", - roundpd_3 = "rmio:660F3A09rMU", - roundps_3 = "rmio:660F3A08rMU", - roundsd_3 = "rrio:660F3A0BrMU|rxi/oq:", - roundss_3 = "rrio:660F3A0ArMU|rxi/od:", - - -- SSE4.2 ops - crc32_2 = "rmqd:F20F38F1rM|rm/dw:66F20F38F1rM|rm/db:F20F38F0rM|rm/qb:", - pcmpestri_3 = "rmio:660F3A61rMU", - pcmpestrm_3 = "rmio:660F3A60rMU", - pcmpgtq_2 = "rmo:660F3837rM", - pcmpistri_3 = "rmio:660F3A63rMU", - pcmpistrm_3 = "rmio:660F3A62rMU", - popcnt_2 = "rmqdw:F30FB8rM", - - -- SSE4a - extrq_2 = "rro:660F79rM", - extrq_3 = "riio:660F780mUU", - insertq_2 = "rro:F20F79rM", - insertq_4 = "rriio:F20F78rMUU", - lzcnt_2 = "rmqdw:F30FBDrM", - movntsd_2 = "xr/qo:nF20F2BRm", - movntss_2 = "xr/do:F30F2BRm", - -- popcnt is also in SSE4.2 -} - ------------------------------------------------------------------------------- - --- Arithmetic ops. -for name,n in pairs{ add = 0, ["or"] = 1, adc = 2, sbb = 3, - ["and"] = 4, sub = 5, xor = 6, cmp = 7 } do - local n8 = shl(n, 3) - map_op[name.."_2"] = format( - "mr:%02XRm|rm:%02XrM|mI1qdw:81%XmI|mS1qdw:83%XmS|Ri1qdwb:%02Xri|mi1qdwb:81%Xmi", - 1+n8, 3+n8, n, n, 5+n8, n) -end - --- Shift ops. -for name,n in pairs{ rol = 0, ror = 1, rcl = 2, rcr = 3, - shl = 4, shr = 5, sar = 7, sal = 4 } do - map_op[name.."_2"] = format("m1:D1%Xm|mC1qdwb:D3%Xm|mi:C1%XmU", n, n, n) -end - --- Conditional ops. -for cc,n in pairs(map_cc) do - map_op["j"..cc.."_1"] = format("J.:n0F8%XJ", n) -- short: 7%X - map_op["set"..cc.."_1"] = format("mb:n0F9%X2m", n) - map_op["cmov"..cc.."_2"] = format("rmqdw:0F4%XrM", n) -- P6+ -end - --- FP arithmetic ops. -for name,n in pairs{ add = 0, mul = 1, com = 2, comp = 3, - sub = 4, subr = 5, div = 6, divr = 7 } do - local nc = 0xc0 + shl(n, 3) - local nr = nc + (n < 4 and 0 or (n % 2 == 0 and 8 or -8)) - local fn = "f"..name - map_op[fn.."_1"] = format("ff:D8%02Xr|xd:D8%Xm|xq:nDC%Xm", nc, n, n) - if n == 2 or n == 3 then - map_op[fn.."_2"] = format("Fff:D8%02XR|Fx2d:D8%XM|Fx2q:nDC%XM", nc, n, n) - else - map_op[fn.."_2"] = format("Fff:D8%02XR|fFf:DC%02Xr|Fx2d:D8%XM|Fx2q:nDC%XM", nc, nr, n, n) - map_op[fn.."p_1"] = format("ff:DE%02Xr", nr) - map_op[fn.."p_2"] = format("fFf:DE%02Xr", nr) - end - map_op["fi"..name.."_1"] = format("xd:DA%Xm|xw:nDE%Xm", n, n) -end - --- FP conditional moves. -for cc,n in pairs{ b=0, e=1, be=2, u=3, nb=4, ne=5, nbe=6, nu=7 } do - local nc = 0xdac0 + shl(band(n, 3), 3) + shl(band(n, 4), 6) - map_op["fcmov"..cc.."_1"] = format("ff:%04Xr", nc) -- P6+ - map_op["fcmov"..cc.."_2"] = format("Fff:%04XR", nc) -- P6+ -end - --- SSE FP arithmetic ops. -for name,n in pairs{ sqrt = 1, add = 8, mul = 9, - sub = 12, min = 13, div = 14, max = 15 } do - map_op[name.."ps_2"] = format("rmo:0F5%XrM", n) - map_op[name.."ss_2"] = format("rro:F30F5%XrM|rx/od:", n) - map_op[name.."pd_2"] = format("rmo:660F5%XrM", n) - map_op[name.."sd_2"] = format("rro:F20F5%XrM|rx/oq:", n) -end - ------------------------------------------------------------------------------- - --- Process pattern string. -local function dopattern(pat, args, sz, op, needrex) - local digit, addin - local opcode = 0 - local szov = sz - local narg = 1 - local rex = 0 - - -- Limit number of section buffer positions used by a single dasm_put(). - -- A single opcode needs a maximum of 5 positions. - if secpos+5 > maxsecpos then wflush() end - - -- Process each character. - for c in gmatch(pat.."|", ".") do - if match(c, "%x") then -- Hex digit. - digit = byte(c) - 48 - if digit > 48 then digit = digit - 39 - elseif digit > 16 then digit = digit - 7 end - opcode = opcode*16 + digit - addin = nil - elseif c == "n" then -- Disable operand size mods for opcode. - szov = nil - elseif c == "X" then -- Force REX.W. - rex = 8 - elseif c == "r" then -- Merge 1st operand regno. into opcode. - addin = args[1]; opcode = opcode + (addin.reg % 8) - if narg < 2 then narg = 2 end - elseif c == "R" then -- Merge 2nd operand regno. into opcode. - addin = args[2]; opcode = opcode + (addin.reg % 8) - narg = 3 - elseif c == "m" or c == "M" then -- Encode ModRM/SIB. - local s - if addin then - s = addin.reg - opcode = opcode - band(s, 7) -- Undo regno opcode merge. - else - s = band(opcode, 15) -- Undo last digit. - opcode = shr(opcode, 4) - end - local nn = c == "m" and 1 or 2 - local t = args[nn] - if narg <= nn then narg = nn + 1 end - if szov == "q" and rex == 0 then rex = rex + 8 end - if t.reg and t.reg > 7 then rex = rex + 1 end - if t.xreg and t.xreg > 7 then rex = rex + 2 end - if s > 7 then rex = rex + 4 end - if needrex then rex = rex + 16 end - wputop(szov, opcode, rex); opcode = nil - local imark = sub(pat, -1) -- Force a mark (ugly). - -- Put ModRM/SIB with regno/last digit as spare. - wputmrmsib(t, imark, s, addin and addin.vreg) - addin = nil - else - if opcode then -- Flush opcode. - if szov == "q" and rex == 0 then rex = rex + 8 end - if needrex then rex = rex + 16 end - if addin and addin.reg == -1 then - wputop(szov, opcode - 7, rex) - waction("VREG", addin.vreg); wputxb(0) - else - if addin and addin.reg > 7 then rex = rex + 1 end - wputop(szov, opcode, rex) - end - opcode = nil - end - if c == "|" then break end - if c == "o" then -- Offset (pure 32 bit displacement). - wputdarg(args[1].disp); if narg < 2 then narg = 2 end - elseif c == "O" then - wputdarg(args[2].disp); narg = 3 - else - -- Anything else is an immediate operand. - local a = args[narg] - narg = narg + 1 - local mode, imm = a.mode, a.imm - if mode == "iJ" and not match("iIJ", c) then - werror("bad operand size for label") - end - if c == "S" then - wputsbarg(imm) - elseif c == "U" then - wputbarg(imm) - elseif c == "W" then - wputwarg(imm) - elseif c == "i" or c == "I" then - if mode == "iJ" then - wputlabel("IMM_", imm, 1) - elseif mode == "iI" and c == "I" then - waction(sz == "w" and "IMM_WB" or "IMM_DB", imm) - else - wputszarg(sz, imm) - end - elseif c == "J" then - if mode == "iPJ" then - waction("REL_A", imm) -- !x64 (secpos) - else - wputlabel("REL_", imm, 2) - end - else - werror("bad char `"..c.."' in pattern `"..pat.."' for `"..op.."'") - end - end - end - end -end - ------------------------------------------------------------------------------- - --- Mapping of operand modes to short names. Suppress output with '#'. -local map_modename = { - r = "reg", R = "eax", C = "cl", x = "mem", m = "mrm", i = "imm", - f = "stx", F = "st0", J = "lbl", ["1"] = "1", - I = "#", S = "#", O = "#", -} - --- Return a table/string showing all possible operand modes. -local function templatehelp(template, nparams) - if nparams == 0 then return "" end - local t = {} - for tm in gmatch(template, "[^%|]+") do - local s = map_modename[sub(tm, 1, 1)] - s = s..gsub(sub(tm, 2, nparams), ".", function(c) - return ", "..map_modename[c] - end) - if not match(s, "#") then t[#t+1] = s end - end - return t -end - --- Match operand modes against mode match part of template. -local function matchtm(tm, args) - for i=1,#args do - if not match(args[i].mode, sub(tm, i, i)) then return end - end - return true -end - --- Handle opcodes defined with template strings. -map_op[".template__"] = function(params, template, nparams) - if not params then return templatehelp(template, nparams) end - local args = {} - - -- Zero-operand opcodes have no match part. - if #params == 0 then - dopattern(template, args, "d", params.op, nil) - return - end - - -- Determine common operand size (coerce undefined size) or flag as mixed. - local sz, szmix, needrex - for i,p in ipairs(params) do - args[i] = parseoperand(p) - local nsz = args[i].opsize - if nsz then - if sz and sz ~= nsz then szmix = true else sz = nsz end - end - local nrex = args[i].needrex - if nrex ~= nil then - if needrex == nil then - needrex = nrex - elseif needrex ~= nrex then - werror("bad mix of byte-addressable registers") - end - end - end - - -- Try all match:pattern pairs (separated by '|'). - local gotmatch, lastpat - for tm in gmatch(template, "[^%|]+") do - -- Split off size match (starts after mode match) and pattern string. - local szm, pat = match(tm, "^(.-):(.*)$", #args+1) - if pat == "" then pat = lastpat else lastpat = pat end - if matchtm(tm, args) then - local prefix = sub(szm, 1, 1) - if prefix == "/" then -- Match both operand sizes. - if args[1].opsize == sub(szm, 2, 2) and - args[2].opsize == sub(szm, 3, 3) then - dopattern(pat, args, sz, params.op, needrex) -- Process pattern. - return - end - else -- Match common operand size. - local szp = sz - if szm == "" then szm = x64 and "qdwb" or "dwb" end -- Default sizes. - if prefix == "1" then szp = args[1].opsize; szmix = nil - elseif prefix == "2" then szp = args[2].opsize; szmix = nil end - if not szmix and (prefix == "." or match(szm, szp or "#")) then - dopattern(pat, args, szp, params.op, needrex) -- Process pattern. - return - end - end - gotmatch = true - end - end - - local msg = "bad operand mode" - if gotmatch then - if szmix then - msg = "mixed operand size" - else - msg = sz and "bad operand size" or "missing operand size" - end - end - - werror(msg.." in `"..opmodestr(params.op, args).."'") -end - ------------------------------------------------------------------------------- - --- x64-specific opcode for 64 bit immediates and displacements. -if x64 then - function map_op.mov64_2(params) - if not params then return { "reg, imm", "reg, [disp]", "[disp], reg" } end - if secpos+2 > maxsecpos then wflush() end - local opcode, op64, sz, rex, vreg - local op64 = match(params[1], "^%[%s*(.-)%s*%]$") - if op64 then - local a = parseoperand(params[2]) - if a.mode ~= "rmR" then werror("bad operand mode") end - sz = a.opsize - rex = sz == "q" and 8 or 0 - opcode = 0xa3 - else - op64 = match(params[2], "^%[%s*(.-)%s*%]$") - local a = parseoperand(params[1]) - if op64 then - if a.mode ~= "rmR" then werror("bad operand mode") end - sz = a.opsize - rex = sz == "q" and 8 or 0 - opcode = 0xa1 - else - if sub(a.mode, 1, 1) ~= "r" or a.opsize ~= "q" then - werror("bad operand mode") - end - op64 = params[2] - if a.reg == -1 then - vreg = a.vreg - opcode = 0xb8 - else - opcode = 0xb8 + band(a.reg, 7) - end - rex = a.reg > 7 and 9 or 8 - end - end - wputop(sz, opcode, rex) - if vreg then waction("VREG", vreg); wputxb(0) end - waction("IMM_D", format("(unsigned int)(%s)", op64)) - waction("IMM_D", format("(unsigned int)((%s)>>32)", op64)) - end -end - ------------------------------------------------------------------------------- - --- Pseudo-opcodes for data storage. -local function op_data(params) - if not params then return "imm..." end - local sz = sub(params.op, 2, 2) - if sz == "a" then sz = addrsize end - for _,p in ipairs(params) do - local a = parseoperand(p) - if sub(a.mode, 1, 1) ~= "i" or (a.opsize and a.opsize ~= sz) then - werror("bad mode or size in `"..p.."'") - end - if a.mode == "iJ" then - wputlabel("IMM_", a.imm, 1) - else - wputszarg(sz, a.imm) - end - if secpos+2 > maxsecpos then wflush() end - end -end - -map_op[".byte_*"] = op_data -map_op[".sbyte_*"] = op_data -map_op[".word_*"] = op_data -map_op[".dword_*"] = op_data -map_op[".aword_*"] = op_data - ------------------------------------------------------------------------------- - --- Pseudo-opcode to mark the position where the action list is to be emitted. -map_op[".actionlist_1"] = function(params) - if not params then return "cvar" end - local name = params[1] -- No syntax check. You get to keep the pieces. - wline(function(out) writeactions(out, name) end) -end - --- Pseudo-opcode to mark the position where the global enum is to be emitted. -map_op[".globals_1"] = function(params) - if not params then return "prefix" end - local prefix = params[1] -- No syntax check. You get to keep the pieces. - wline(function(out) writeglobals(out, prefix) end) -end - --- Pseudo-opcode to mark the position where the global names are to be emitted. -map_op[".globalnames_1"] = function(params) - if not params then return "cvar" end - local name = params[1] -- No syntax check. You get to keep the pieces. - wline(function(out) writeglobalnames(out, name) end) -end - --- Pseudo-opcode to mark the position where the extern names are to be emitted. -map_op[".externnames_1"] = function(params) - if not params then return "cvar" end - local name = params[1] -- No syntax check. You get to keep the pieces. - wline(function(out) writeexternnames(out, name) end) -end - ------------------------------------------------------------------------------- - --- Label pseudo-opcode (converted from trailing colon form). -map_op[".label_2"] = function(params) - if not params then return "[1-9] | ->global | =>pcexpr [, addr]" end - if secpos+2 > maxsecpos then wflush() end - local a = parseoperand(params[1]) - local mode, imm = a.mode, a.imm - if type(imm) == "number" and (mode == "iJ" or (imm >= 1 and imm <= 9)) then - -- Local label (1: ... 9:) or global label (->global:). - waction("LABEL_LG", nil, 1) - wputxb(imm) - elseif mode == "iJ" then - -- PC label (=>pcexpr:). - waction("LABEL_PC", imm) - else - werror("bad label definition") - end - -- SETLABEL must immediately follow LABEL_LG/LABEL_PC. - local addr = params[2] - if addr then - local a = parseoperand(addr) - if a.mode == "iPJ" then - waction("SETLABEL", a.imm) - else - werror("bad label assignment") - end - end -end -map_op[".label_1"] = map_op[".label_2"] - ------------------------------------------------------------------------------- - --- Alignment pseudo-opcode. -map_op[".align_1"] = function(params) - if not params then return "numpow2" end - if secpos+1 > maxsecpos then wflush() end - local align = tonumber(params[1]) or map_opsizenum[map_opsize[params[1]]] - if align then - local x = align - -- Must be a power of 2 in the range (2 ... 256). - for i=1,8 do - x = x / 2 - if x == 1 then - waction("ALIGN", nil, 1) - wputxb(align-1) -- Action byte is 2**n-1. - return - end - end - end - werror("bad alignment") -end - --- Spacing pseudo-opcode. -map_op[".space_2"] = function(params) - if not params then return "num [, filler]" end - if secpos+1 > maxsecpos then wflush() end - waction("SPACE", params[1]) - local fill = params[2] - if fill then - fill = tonumber(fill) - if not fill or fill < 0 or fill > 255 then werror("bad filler") end - end - wputxb(fill or 0) -end -map_op[".space_1"] = map_op[".space_2"] - ------------------------------------------------------------------------------- - --- Pseudo-opcode for (primitive) type definitions (map to C types). -map_op[".type_3"] = function(params, nparams) - if not params then - return nparams == 2 and "name, ctype" or "name, ctype, reg" - end - local name, ctype, reg = params[1], params[2], params[3] - if not match(name, "^[%a_][%w_]*$") then - werror("bad type name `"..name.."'") - end - local tp = map_type[name] - if tp then - werror("duplicate type `"..name.."'") - end - if reg and not map_reg_valid_base[reg] then - werror("bad base register `"..(map_reg_rev[reg] or reg).."'") - end - -- Add #type to defines. A bit unclean to put it in map_archdef. - map_archdef["#"..name] = "sizeof("..ctype..")" - -- Add new type and emit shortcut define. - local num = ctypenum + 1 - map_type[name] = { - ctype = ctype, - ctypefmt = format("Dt%X(%%s)", num), - reg = reg, - } - wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype)) - ctypenum = num -end -map_op[".type_2"] = map_op[".type_3"] - --- Dump type definitions. -local function dumptypes(out, lvl) - local t = {} - for name in pairs(map_type) do t[#t+1] = name end - sort(t) - out:write("Type definitions:\n") - for _,name in ipairs(t) do - local tp = map_type[name] - local reg = tp.reg and map_reg_rev[tp.reg] or "" - out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg)) - end - out:write("\n") -end - ------------------------------------------------------------------------------- - --- Set the current section. -function _M.section(num) - waction("SECTION") - wputxb(num) - wflush(true) -- SECTION is a terminal action. -end - ------------------------------------------------------------------------------- - --- Dump architecture description. -function _M.dumparch(out) - out:write(format("DynASM %s version %s, released %s\n\n", - _info.arch, _info.version, _info.release)) - dumpregs(out) - dumpactions(out) -end - --- Dump all user defined elements. -function _M.dumpdef(out, lvl) - dumptypes(out, lvl) - dumpglobals(out, lvl) - dumpexterns(out, lvl) -end - ------------------------------------------------------------------------------- - --- Pass callbacks from/to the DynASM core. -function _M.passcb(wl, we, wf, ww) - wline, werror, wfatal, wwarn = wl, we, wf, ww - return wflush -end - --- Setup the arch-specific module. -function _M.setup(arch, opt) - g_arch, g_opt = arch, opt -end - --- Merge the core maps and the arch-specific maps. -function _M.mergemaps(map_coreop, map_def) - setmetatable(map_op, { __index = map_coreop }) - setmetatable(map_def, { __index = map_archdef }) - return map_op, map_def -end - -return _M - ------------------------------------------------------------------------------- - diff --git a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dynasm.lua b/source/libs/luajit/LuaJIT-2.0.3/dynasm/dynasm.lua deleted file mode 100644 index 0ea8697c0..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/dynasm/dynasm.lua +++ /dev/null @@ -1,1094 +0,0 @@ ------------------------------------------------------------------------------- --- DynASM. A dynamic assembler for code generation engines. --- Originally designed and implemented for LuaJIT. --- --- Copyright (C) 2005-2014 Mike Pall. All rights reserved. --- See below for full copyright notice. ------------------------------------------------------------------------------- - --- Application information. -local _info = { - name = "DynASM", - description = "A dynamic assembler for code generation engines", - version = "1.3.0", - vernum = 10300, - release = "2011-05-05", - author = "Mike Pall", - url = "http://luajit.org/dynasm.html", - license = "MIT", - copyright = [[ -Copyright (C) 2005-2014 Mike Pall. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -[ MIT license: http://www.opensource.org/licenses/mit-license.php ] -]], -} - --- Cache library functions. -local type, pairs, ipairs = type, pairs, ipairs -local pcall, error, assert = pcall, error, assert -local _s = string -local sub, match, gmatch, gsub = _s.sub, _s.match, _s.gmatch, _s.gsub -local format, rep, upper = _s.format, _s.rep, _s.upper -local _t = table -local insert, remove, concat, sort = _t.insert, _t.remove, _t.concat, _t.sort -local exit = os.exit -local io = io -local stdin, stdout, stderr = io.stdin, io.stdout, io.stderr - ------------------------------------------------------------------------------- - --- Program options. -local g_opt = {} - --- Global state for current file. -local g_fname, g_curline, g_indent, g_lineno, g_synclineno, g_arch -local g_errcount = 0 - --- Write buffer for output file. -local g_wbuffer, g_capbuffer - ------------------------------------------------------------------------------- - --- Write an output line (or callback function) to the buffer. -local function wline(line, needindent) - local buf = g_capbuffer or g_wbuffer - buf[#buf+1] = needindent and g_indent..line or line - g_synclineno = g_synclineno + 1 -end - --- Write assembler line as a comment, if requestd. -local function wcomment(aline) - if g_opt.comment then - wline(g_opt.comment..aline..g_opt.endcomment, true) - end -end - --- Resync CPP line numbers. -local function wsync() - if g_synclineno ~= g_lineno and g_opt.cpp then - wline("#line "..g_lineno..' "'..g_fname..'"') - g_synclineno = g_lineno - end -end - --- Dummy action flush function. Replaced with arch-specific function later. -local function wflush(term) -end - --- Dump all buffered output lines. -local function wdumplines(out, buf) - for _,line in ipairs(buf) do - if type(line) == "string" then - assert(out:write(line, "\n")) - else - -- Special callback to dynamically insert lines after end of processing. - line(out) - end - end -end - ------------------------------------------------------------------------------- - --- Emit an error. Processing continues with next statement. -local function werror(msg) - error(format("%s:%s: error: %s:\n%s", g_fname, g_lineno, msg, g_curline), 0) -end - --- Emit a fatal error. Processing stops. -local function wfatal(msg) - g_errcount = "fatal" - werror(msg) -end - --- Print a warning. Processing continues. -local function wwarn(msg) - stderr:write(format("%s:%s: warning: %s:\n%s\n", - g_fname, g_lineno, msg, g_curline)) -end - --- Print caught error message. But suppress excessive errors. -local function wprinterr(...) - if type(g_errcount) == "number" then - -- Regular error. - g_errcount = g_errcount + 1 - if g_errcount < 21 then -- Seems to be a reasonable limit. - stderr:write(...) - elseif g_errcount == 21 then - stderr:write(g_fname, - ":*: warning: too many errors (suppressed further messages).\n") - end - else - -- Fatal error. - stderr:write(...) - return true -- Stop processing. - end -end - ------------------------------------------------------------------------------- - --- Map holding all option handlers. -local opt_map = {} -local opt_current - --- Print error and exit with error status. -local function opterror(...) - stderr:write("dynasm.lua: ERROR: ", ...) - stderr:write("\n") - exit(1) -end - --- Get option parameter. -local function optparam(args) - local argn = args.argn - local p = args[argn] - if not p then - opterror("missing parameter for option `", opt_current, "'.") - end - args.argn = argn + 1 - return p -end - ------------------------------------------------------------------------------- - --- Core pseudo-opcodes. -local map_coreop = {} --- Dummy opcode map. Replaced by arch-specific map. -local map_op = {} - --- Forward declarations. -local dostmt -local readfile - ------------------------------------------------------------------------------- - --- Map for defines (initially empty, chains to arch-specific map). -local map_def = {} - --- Pseudo-opcode to define a substitution. -map_coreop[".define_2"] = function(params, nparams) - if not params then return nparams == 1 and "name" or "name, subst" end - local name, def = params[1], params[2] or "1" - if not match(name, "^[%a_][%w_]*$") then werror("bad or duplicate define") end - map_def[name] = def -end -map_coreop[".define_1"] = map_coreop[".define_2"] - --- Define a substitution on the command line. -function opt_map.D(args) - local namesubst = optparam(args) - local name, subst = match(namesubst, "^([%a_][%w_]*)=(.*)$") - if name then - map_def[name] = subst - elseif match(namesubst, "^[%a_][%w_]*$") then - map_def[namesubst] = "1" - else - opterror("bad define") - end -end - --- Undefine a substitution on the command line. -function opt_map.U(args) - local name = optparam(args) - if match(name, "^[%a_][%w_]*$") then - map_def[name] = nil - else - opterror("bad define") - end -end - --- Helper for definesubst. -local gotsubst - -local function definesubst_one(word) - local subst = map_def[word] - if subst then gotsubst = word; return subst else return word end -end - --- Iteratively substitute defines. -local function definesubst(stmt) - -- Limit number of iterations. - for i=1,100 do - gotsubst = false - stmt = gsub(stmt, "#?[%w_]+", definesubst_one) - if not gotsubst then break end - end - if gotsubst then wfatal("recursive define involving `"..gotsubst.."'") end - return stmt -end - --- Dump all defines. -local function dumpdefines(out, lvl) - local t = {} - for name in pairs(map_def) do - t[#t+1] = name - end - sort(t) - out:write("Defines:\n") - for _,name in ipairs(t) do - local subst = map_def[name] - if g_arch then subst = g_arch.revdef(subst) end - out:write(format(" %-20s %s\n", name, subst)) - end - out:write("\n") -end - ------------------------------------------------------------------------------- - --- Support variables for conditional assembly. -local condlevel = 0 -local condstack = {} - --- Evaluate condition with a Lua expression. Substitutions already performed. -local function cond_eval(cond) - local func, err - if setfenv then - func, err = loadstring("return "..cond, "=expr") - else - -- No globals. All unknown identifiers evaluate to nil. - func, err = load("return "..cond, "=expr", "t", {}) - end - if func then - if setfenv then - setfenv(func, {}) -- No globals. All unknown identifiers evaluate to nil. - end - local ok, res = pcall(func) - if ok then - if res == 0 then return false end -- Oh well. - return not not res - end - err = res - end - wfatal("bad condition: "..err) -end - --- Skip statements until next conditional pseudo-opcode at the same level. -local function stmtskip() - local dostmt_save = dostmt - local lvl = 0 - dostmt = function(stmt) - local op = match(stmt, "^%s*(%S+)") - if op == ".if" then - lvl = lvl + 1 - elseif lvl ~= 0 then - if op == ".endif" then lvl = lvl - 1 end - elseif op == ".elif" or op == ".else" or op == ".endif" then - dostmt = dostmt_save - dostmt(stmt) - end - end -end - --- Pseudo-opcodes for conditional assembly. -map_coreop[".if_1"] = function(params) - if not params then return "condition" end - local lvl = condlevel + 1 - local res = cond_eval(params[1]) - condlevel = lvl - condstack[lvl] = res - if not res then stmtskip() end -end - -map_coreop[".elif_1"] = function(params) - if not params then return "condition" end - if condlevel == 0 then wfatal(".elif without .if") end - local lvl = condlevel - local res = condstack[lvl] - if res then - if res == "else" then wfatal(".elif after .else") end - else - res = cond_eval(params[1]) - if res then - condstack[lvl] = res - return - end - end - stmtskip() -end - -map_coreop[".else_0"] = function(params) - if condlevel == 0 then wfatal(".else without .if") end - local lvl = condlevel - local res = condstack[lvl] - condstack[lvl] = "else" - if res then - if res == "else" then wfatal(".else after .else") end - stmtskip() - end -end - -map_coreop[".endif_0"] = function(params) - local lvl = condlevel - if lvl == 0 then wfatal(".endif without .if") end - condlevel = lvl - 1 -end - --- Check for unfinished conditionals. -local function checkconds() - if g_errcount ~= "fatal" and condlevel ~= 0 then - wprinterr(g_fname, ":*: error: unbalanced conditional\n") - end -end - ------------------------------------------------------------------------------- - --- Search for a file in the given path and open it for reading. -local function pathopen(path, name) - local dirsep = package and match(package.path, "\\") and "\\" or "/" - for _,p in ipairs(path) do - local fullname = p == "" and name or p..dirsep..name - local fin = io.open(fullname, "r") - if fin then - g_fname = fullname - return fin - end - end -end - --- Include a file. -map_coreop[".include_1"] = function(params) - if not params then return "filename" end - local name = params[1] - -- Save state. Ugly, I know. but upvalues are fast. - local gf, gl, gcl, gi = g_fname, g_lineno, g_curline, g_indent - -- Read the included file. - local fatal = readfile(pathopen(g_opt.include, name) or - wfatal("include file `"..name.."' not found")) - -- Restore state. - g_synclineno = -1 - g_fname, g_lineno, g_curline, g_indent = gf, gl, gcl, gi - if fatal then wfatal("in include file") end -end - --- Make .include and conditionals initially available, too. -map_op[".include_1"] = map_coreop[".include_1"] -map_op[".if_1"] = map_coreop[".if_1"] -map_op[".elif_1"] = map_coreop[".elif_1"] -map_op[".else_0"] = map_coreop[".else_0"] -map_op[".endif_0"] = map_coreop[".endif_0"] - ------------------------------------------------------------------------------- - --- Support variables for macros. -local mac_capture, mac_lineno, mac_name -local mac_active = {} -local mac_list = {} - --- Pseudo-opcode to define a macro. -map_coreop[".macro_*"] = function(mparams) - if not mparams then return "name [, params...]" end - -- Split off and validate macro name. - local name = remove(mparams, 1) - if not name then werror("missing macro name") end - if not (match(name, "^[%a_][%w_%.]*$") or match(name, "^%.[%w_%.]*$")) then - wfatal("bad macro name `"..name.."'") - end - -- Validate macro parameter names. - local mdup = {} - for _,mp in ipairs(mparams) do - if not match(mp, "^[%a_][%w_]*$") then - wfatal("bad macro parameter name `"..mp.."'") - end - if mdup[mp] then wfatal("duplicate macro parameter name `"..mp.."'") end - mdup[mp] = true - end - -- Check for duplicate or recursive macro definitions. - local opname = name.."_"..#mparams - if map_op[opname] or map_op[name.."_*"] then - wfatal("duplicate macro `"..name.."' ("..#mparams.." parameters)") - end - if mac_capture then wfatal("recursive macro definition") end - - -- Enable statement capture. - local lines = {} - mac_lineno = g_lineno - mac_name = name - mac_capture = function(stmt) -- Statement capture function. - -- Stop macro definition with .endmacro pseudo-opcode. - if not match(stmt, "^%s*.endmacro%s*$") then - lines[#lines+1] = stmt - return - end - mac_capture = nil - mac_lineno = nil - mac_name = nil - mac_list[#mac_list+1] = opname - -- Add macro-op definition. - map_op[opname] = function(params) - if not params then return mparams, lines end - -- Protect against recursive macro invocation. - if mac_active[opname] then wfatal("recursive macro invocation") end - mac_active[opname] = true - -- Setup substitution map. - local subst = {} - for i,mp in ipairs(mparams) do subst[mp] = params[i] end - local mcom - if g_opt.maccomment and g_opt.comment then - mcom = " MACRO "..name.." ("..#mparams..")" - wcomment("{"..mcom) - end - -- Loop through all captured statements - for _,stmt in ipairs(lines) do - -- Substitute macro parameters. - local st = gsub(stmt, "[%w_]+", subst) - st = definesubst(st) - st = gsub(st, "%s*%.%.%s*", "") -- Token paste a..b. - if mcom and sub(st, 1, 1) ~= "|" then wcomment(st) end - -- Emit statement. Use a protected call for better diagnostics. - local ok, err = pcall(dostmt, st) - if not ok then - -- Add the captured statement to the error. - wprinterr(err, "\n", g_indent, "| ", stmt, - "\t[MACRO ", name, " (", #mparams, ")]\n") - end - end - if mcom then wcomment("}"..mcom) end - mac_active[opname] = nil - end - end -end - --- An .endmacro pseudo-opcode outside of a macro definition is an error. -map_coreop[".endmacro_0"] = function(params) - wfatal(".endmacro without .macro") -end - --- Dump all macros and their contents (with -PP only). -local function dumpmacros(out, lvl) - sort(mac_list) - out:write("Macros:\n") - for _,opname in ipairs(mac_list) do - local name = sub(opname, 1, -3) - local params, lines = map_op[opname]() - out:write(format(" %-20s %s\n", name, concat(params, ", "))) - if lvl > 1 then - for _,line in ipairs(lines) do - out:write(" |", line, "\n") - end - out:write("\n") - end - end - out:write("\n") -end - --- Check for unfinished macro definitions. -local function checkmacros() - if mac_capture then - wprinterr(g_fname, ":", mac_lineno, - ": error: unfinished .macro `", mac_name ,"'\n") - end -end - ------------------------------------------------------------------------------- - --- Support variables for captures. -local cap_lineno, cap_name -local cap_buffers = {} -local cap_used = {} - --- Start a capture. -map_coreop[".capture_1"] = function(params) - if not params then return "name" end - wflush() - local name = params[1] - if not match(name, "^[%a_][%w_]*$") then - wfatal("bad capture name `"..name.."'") - end - if cap_name then - wfatal("already capturing to `"..cap_name.."' since line "..cap_lineno) - end - cap_name = name - cap_lineno = g_lineno - -- Create or continue a capture buffer and start the output line capture. - local buf = cap_buffers[name] - if not buf then buf = {}; cap_buffers[name] = buf end - g_capbuffer = buf - g_synclineno = 0 -end - --- Stop a capture. -map_coreop[".endcapture_0"] = function(params) - wflush() - if not cap_name then wfatal(".endcapture without a valid .capture") end - cap_name = nil - cap_lineno = nil - g_capbuffer = nil - g_synclineno = 0 -end - --- Dump a capture buffer. -map_coreop[".dumpcapture_1"] = function(params) - if not params then return "name" end - wflush() - local name = params[1] - if not match(name, "^[%a_][%w_]*$") then - wfatal("bad capture name `"..name.."'") - end - cap_used[name] = true - wline(function(out) - local buf = cap_buffers[name] - if buf then wdumplines(out, buf) end - end) - g_synclineno = 0 -end - --- Dump all captures and their buffers (with -PP only). -local function dumpcaptures(out, lvl) - out:write("Captures:\n") - for name,buf in pairs(cap_buffers) do - out:write(format(" %-20s %4s)\n", name, "("..#buf)) - if lvl > 1 then - local bar = rep("=", 76) - out:write(" ", bar, "\n") - for _,line in ipairs(buf) do - out:write(" ", line, "\n") - end - out:write(" ", bar, "\n\n") - end - end - out:write("\n") -end - --- Check for unfinished or unused captures. -local function checkcaptures() - if cap_name then - wprinterr(g_fname, ":", cap_lineno, - ": error: unfinished .capture `", cap_name,"'\n") - return - end - for name in pairs(cap_buffers) do - if not cap_used[name] then - wprinterr(g_fname, ":*: error: missing .dumpcapture ", name ,"\n") - end - end -end - ------------------------------------------------------------------------------- - --- Sections names. -local map_sections = {} - --- Pseudo-opcode to define code sections. --- TODO: Data sections, BSS sections. Needs extra C code and API. -map_coreop[".section_*"] = function(params) - if not params then return "name..." end - if #map_sections > 0 then werror("duplicate section definition") end - wflush() - for sn,name in ipairs(params) do - local opname = "."..name.."_0" - if not match(name, "^[%a][%w_]*$") or - map_op[opname] or map_op["."..name.."_*"] then - werror("bad section name `"..name.."'") - end - map_sections[#map_sections+1] = name - wline(format("#define DASM_SECTION_%s\t%d", upper(name), sn-1)) - map_op[opname] = function(params) g_arch.section(sn-1) end - end - wline(format("#define DASM_MAXSECTION\t\t%d", #map_sections)) -end - --- Dump all sections. -local function dumpsections(out, lvl) - out:write("Sections:\n") - for _,name in ipairs(map_sections) do - out:write(format(" %s\n", name)) - end - out:write("\n") -end - ------------------------------------------------------------------------------- - --- Replacement for customized Lua, which lacks the package library. -local prefix = "" -if not require then - function require(name) - local fp = assert(io.open(prefix..name..".lua")) - local s = fp:read("*a") - assert(fp:close()) - return assert(loadstring(s, "@"..name..".lua"))() - end -end - --- Load architecture-specific module. -local function loadarch(arch) - if not match(arch, "^[%w_]+$") then return "bad arch name" end - local ok, m_arch = pcall(require, "dasm_"..arch) - if not ok then return "cannot load module: "..m_arch end - g_arch = m_arch - wflush = m_arch.passcb(wline, werror, wfatal, wwarn) - m_arch.setup(arch, g_opt) - map_op, map_def = m_arch.mergemaps(map_coreop, map_def) -end - --- Dump architecture description. -function opt_map.dumparch(args) - local name = optparam(args) - if not g_arch then - local err = loadarch(name) - if err then opterror(err) end - end - - local t = {} - for name in pairs(map_coreop) do t[#t+1] = name end - for name in pairs(map_op) do t[#t+1] = name end - sort(t) - - local out = stdout - local _arch = g_arch._info - out:write(format("%s version %s, released %s, %s\n", - _info.name, _info.version, _info.release, _info.url)) - g_arch.dumparch(out) - - local pseudo = true - out:write("Pseudo-Opcodes:\n") - for _,sname in ipairs(t) do - local name, nparam = match(sname, "^(.+)_([0-9%*])$") - if name then - if pseudo and sub(name, 1, 1) ~= "." then - out:write("\nOpcodes:\n") - pseudo = false - end - local f = map_op[sname] - local s - if nparam ~= "*" then nparam = nparam + 0 end - if nparam == 0 then - s = "" - elseif type(f) == "string" then - s = map_op[".template__"](nil, f, nparam) - else - s = f(nil, nparam) - end - if type(s) == "table" then - for _,s2 in ipairs(s) do - out:write(format(" %-12s %s\n", name, s2)) - end - else - out:write(format(" %-12s %s\n", name, s)) - end - end - end - out:write("\n") - exit(0) -end - --- Pseudo-opcode to set the architecture. --- Only initially available (map_op is replaced when called). -map_op[".arch_1"] = function(params) - if not params then return "name" end - local err = loadarch(params[1]) - if err then wfatal(err) end - wline(format("#if DASM_VERSION != %d", _info.vernum)) - wline('#error "Version mismatch between DynASM and included encoding engine"') - wline("#endif") -end - --- Dummy .arch pseudo-opcode to improve the error report. -map_coreop[".arch_1"] = function(params) - if not params then return "name" end - wfatal("duplicate .arch statement") -end - ------------------------------------------------------------------------------- - --- Dummy pseudo-opcode. Don't confuse '.nop' with 'nop'. -map_coreop[".nop_*"] = function(params) - if not params then return "[ignored...]" end -end - --- Pseudo-opcodes to raise errors. -map_coreop[".error_1"] = function(params) - if not params then return "message" end - werror(params[1]) -end - -map_coreop[".fatal_1"] = function(params) - if not params then return "message" end - wfatal(params[1]) -end - --- Dump all user defined elements. -local function dumpdef(out) - local lvl = g_opt.dumpdef - if lvl == 0 then return end - dumpsections(out, lvl) - dumpdefines(out, lvl) - if g_arch then g_arch.dumpdef(out, lvl) end - dumpmacros(out, lvl) - dumpcaptures(out, lvl) -end - ------------------------------------------------------------------------------- - --- Helper for splitstmt. -local splitlvl - -local function splitstmt_one(c) - if c == "(" then - splitlvl = ")"..splitlvl - elseif c == "[" then - splitlvl = "]"..splitlvl - elseif c == "{" then - splitlvl = "}"..splitlvl - elseif c == ")" or c == "]" or c == "}" then - if sub(splitlvl, 1, 1) ~= c then werror("unbalanced (), [] or {}") end - splitlvl = sub(splitlvl, 2) - elseif splitlvl == "" then - return " \0 " - end - return c -end - --- Split statement into (pseudo-)opcode and params. -local function splitstmt(stmt) - -- Convert label with trailing-colon into .label statement. - local label = match(stmt, "^%s*(.+):%s*$") - if label then return ".label", {label} end - - -- Split at commas and equal signs, but obey parentheses and brackets. - splitlvl = "" - stmt = gsub(stmt, "[,%(%)%[%]{}]", splitstmt_one) - if splitlvl ~= "" then werror("unbalanced () or []") end - - -- Split off opcode. - local op, other = match(stmt, "^%s*([^%s%z]+)%s*(.*)$") - if not op then werror("bad statement syntax") end - - -- Split parameters. - local params = {} - for p in gmatch(other, "%s*(%Z+)%z?") do - params[#params+1] = gsub(p, "%s+$", "") - end - if #params > 16 then werror("too many parameters") end - - params.op = op - return op, params -end - --- Process a single statement. -dostmt = function(stmt) - -- Ignore empty statements. - if match(stmt, "^%s*$") then return end - - -- Capture macro defs before substitution. - if mac_capture then return mac_capture(stmt) end - stmt = definesubst(stmt) - - -- Emit C code without parsing the line. - if sub(stmt, 1, 1) == "|" then - local tail = sub(stmt, 2) - wflush() - if sub(tail, 1, 2) == "//" then wcomment(tail) else wline(tail, true) end - return - end - - -- Split into (pseudo-)opcode and params. - local op, params = splitstmt(stmt) - - -- Get opcode handler (matching # of parameters or generic handler). - local f = map_op[op.."_"..#params] or map_op[op.."_*"] - if not f then - if not g_arch then wfatal("first statement must be .arch") end - -- Improve error report. - for i=0,9 do - if map_op[op.."_"..i] then - werror("wrong number of parameters for `"..op.."'") - end - end - werror("unknown statement `"..op.."'") - end - - -- Call opcode handler or special handler for template strings. - if type(f) == "string" then - map_op[".template__"](params, f) - else - f(params) - end -end - --- Process a single line. -local function doline(line) - if g_opt.flushline then wflush() end - - -- Assembler line? - local indent, aline = match(line, "^(%s*)%|(.*)$") - if not aline then - -- No, plain C code line, need to flush first. - wflush() - wsync() - wline(line, false) - return - end - - g_indent = indent -- Remember current line indentation. - - -- Emit C code (even from macros). Avoids echo and line parsing. - if sub(aline, 1, 1) == "|" then - if not mac_capture then - wsync() - elseif g_opt.comment then - wsync() - wcomment(aline) - end - dostmt(aline) - return - end - - -- Echo assembler line as a comment. - if g_opt.comment then - wsync() - wcomment(aline) - end - - -- Strip assembler comments. - aline = gsub(aline, "//.*$", "") - - -- Split line into statements at semicolons. - if match(aline, ";") then - for stmt in gmatch(aline, "[^;]+") do dostmt(stmt) end - else - dostmt(aline) - end -end - ------------------------------------------------------------------------------- - --- Write DynASM header. -local function dasmhead(out) - out:write(format([[ -/* -** This file has been pre-processed with DynASM. -** %s -** DynASM version %s, DynASM %s version %s -** DO NOT EDIT! The original file is in "%s". -*/ - -]], _info.url, - _info.version, g_arch._info.arch, g_arch._info.version, - g_fname)) -end - --- Read input file. -readfile = function(fin) - g_indent = "" - g_lineno = 0 - g_synclineno = -1 - - -- Process all lines. - for line in fin:lines() do - g_lineno = g_lineno + 1 - g_curline = line - local ok, err = pcall(doline, line) - if not ok and wprinterr(err, "\n") then return true end - end - wflush() - - -- Close input file. - assert(fin == stdin or fin:close()) -end - --- Write output file. -local function writefile(outfile) - local fout - - -- Open output file. - if outfile == nil or outfile == "-" then - fout = stdout - else - fout = assert(io.open(outfile, "w")) - end - - -- Write all buffered lines - wdumplines(fout, g_wbuffer) - - -- Close output file. - assert(fout == stdout or fout:close()) - - -- Optionally dump definitions. - dumpdef(fout == stdout and stderr or stdout) -end - --- Translate an input file to an output file. -local function translate(infile, outfile) - g_wbuffer = {} - g_indent = "" - g_lineno = 0 - g_synclineno = -1 - - -- Put header. - wline(dasmhead) - - -- Read input file. - local fin - if infile == "-" then - g_fname = "(stdin)" - fin = stdin - else - g_fname = infile - fin = assert(io.open(infile, "r")) - end - readfile(fin) - - -- Check for errors. - if not g_arch then - wprinterr(g_fname, ":*: error: missing .arch directive\n") - end - checkconds() - checkmacros() - checkcaptures() - - if g_errcount ~= 0 then - stderr:write(g_fname, ":*: info: ", g_errcount, " error", - (type(g_errcount) == "number" and g_errcount > 1) and "s" or "", - " in input file -- no output file generated.\n") - dumpdef(stderr) - exit(1) - end - - -- Write output file. - writefile(outfile) -end - ------------------------------------------------------------------------------- - --- Print help text. -function opt_map.help() - stdout:write("DynASM -- ", _info.description, ".\n") - stdout:write("DynASM ", _info.version, " ", _info.release, " ", _info.url, "\n") - stdout:write[[ - -Usage: dynasm [OPTION]... INFILE.dasc|- - - -h, --help Display this help text. - -V, --version Display version and copyright information. - - -o, --outfile FILE Output file name (default is stdout). - -I, --include DIR Add directory to the include search path. - - -c, --ccomment Use /* */ comments for assembler lines. - -C, --cppcomment Use // comments for assembler lines (default). - -N, --nocomment Suppress assembler lines in output. - -M, --maccomment Show macro expansions as comments (default off). - - -L, --nolineno Suppress CPP line number information in output. - -F, --flushline Flush action list for every line. - - -D NAME[=SUBST] Define a substitution. - -U NAME Undefine a substitution. - - -P, --dumpdef Dump defines, macros, etc. Repeat for more output. - -A, --dumparch ARCH Load architecture ARCH and dump description. -]] - exit(0) -end - --- Print version information. -function opt_map.version() - stdout:write(format("%s version %s, released %s\n%s\n\n%s", - _info.name, _info.version, _info.release, _info.url, _info.copyright)) - exit(0) -end - --- Misc. options. -function opt_map.outfile(args) g_opt.outfile = optparam(args) end -function opt_map.include(args) insert(g_opt.include, 1, optparam(args)) end -function opt_map.ccomment() g_opt.comment = "/*|"; g_opt.endcomment = " */" end -function opt_map.cppcomment() g_opt.comment = "//|"; g_opt.endcomment = "" end -function opt_map.nocomment() g_opt.comment = false end -function opt_map.maccomment() g_opt.maccomment = true end -function opt_map.nolineno() g_opt.cpp = false end -function opt_map.flushline() g_opt.flushline = true end -function opt_map.dumpdef() g_opt.dumpdef = g_opt.dumpdef + 1 end - ------------------------------------------------------------------------------- - --- Short aliases for long options. -local opt_alias = { - h = "help", ["?"] = "help", V = "version", - o = "outfile", I = "include", - c = "ccomment", C = "cppcomment", N = "nocomment", M = "maccomment", - L = "nolineno", F = "flushline", - P = "dumpdef", A = "dumparch", -} - --- Parse single option. -local function parseopt(opt, args) - opt_current = #opt == 1 and "-"..opt or "--"..opt - local f = opt_map[opt] or opt_map[opt_alias[opt]] - if not f then - opterror("unrecognized option `", opt_current, "'. Try `--help'.\n") - end - f(args) -end - --- Parse arguments. -local function parseargs(args) - -- Default options. - g_opt.comment = "//|" - g_opt.endcomment = "" - g_opt.cpp = true - g_opt.dumpdef = 0 - g_opt.include = { "" } - - -- Process all option arguments. - args.argn = 1 - repeat - local a = args[args.argn] - if not a then break end - local lopt, opt = match(a, "^%-(%-?)(.+)") - if not opt then break end - args.argn = args.argn + 1 - if lopt == "" then - -- Loop through short options. - for o in gmatch(opt, ".") do parseopt(o, args) end - else - -- Long option. - parseopt(opt, args) - end - until false - - -- Check for proper number of arguments. - local nargs = #args - args.argn + 1 - if nargs ~= 1 then - if nargs == 0 then - if g_opt.dumpdef > 0 then return dumpdef(stdout) end - end - opt_map.help() - end - - -- Translate a single input file to a single output file - -- TODO: Handle multiple files? - translate(args[args.argn], g_opt.outfile) -end - ------------------------------------------------------------------------------- - --- Add the directory dynasm.lua resides in to the Lua module search path. -local arg = arg -if arg and arg[0] then - prefix = match(arg[0], "^(.*[/\\])") - if package and prefix then package.path = prefix.."?.lua;"..package.path end -end - --- Start DynASM. -parseargs{...} - ------------------------------------------------------------------------------- - diff --git a/source/libs/luajit/LuaJIT-2.0.3/etc/luajit.1 b/source/libs/luajit/LuaJIT-2.0.3/etc/luajit.1 deleted file mode 100644 index 723a708cc..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/etc/luajit.1 +++ /dev/null @@ -1,88 +0,0 @@ -.TH luajit 1 "" "" "LuaJIT documentation" -.SH NAME -luajit \- Just-In-Time Compiler for the Lua Language -\fB -.SH SYNOPSIS -.B luajit -[\fIoptions\fR]... [\fIscript\fR [\fIargs\fR]...] -.SH "WEB SITE" -.IR http://luajit.org -.SH DESCRIPTION -.PP -This is the command-line program to run Lua programs with \fBLuaJIT\fR. -.PP -\fBLuaJIT\fR is a just-in-time (JIT) compiler for the Lua language. -The virtual machine (VM) is based on a fast interpreter combined with -a trace compiler. It can significantly improve the performance of Lua programs. -.PP -\fBLuaJIT\fR is API\- and ABI-compatible with the VM of the standard -Lua\ 5.1 interpreter. When embedding the VM into an application, -the built library can be used as a drop-in replacement. -.SH OPTIONS -.TP -.BI "\-e " chunk -Run the given chunk of Lua code. -.TP -.BI "\-l " library -Load the named library, just like \fBrequire("\fR\fIlibrary\fR\fB")\fR. -.TP -.BI "\-b " ... -Save or list bytecode. Run without arguments to get help on options. -.TP -.BI "\-j " command -Perform LuaJIT control command (optional space after \fB\-j\fR). -.TP -.BI "\-O" [opt] -Control LuaJIT optimizations. -.TP -.B "\-i" -Run in interactive mode. -.TP -.B "\-v" -Show \fBLuaJIT\fR version. -.TP -.B "\-E" -Ignore environment variables. -.TP -.B "\-\-" -Stop processing options. -.TP -.B "\-" -Read script from stdin instead. -.PP -After all options are processed, the given \fIscript\fR is run. -The arguments are passed in the global \fIarg\fR table. -.PP -Interactive mode is only entered, if no \fIscript\fR and no \fB\-e\fR -option is given. Interactive mode can be left with EOF (\fICtrl\-Z\fB). -.SH EXAMPLES -.TP -luajit hello.lua world - -Prints "Hello world", assuming \fIhello.lua\fR contains: -.br - print("Hello", arg[1]) -.TP -luajit \-e "local x=0; for i=1,1e9 do x=x+i end; print(x)" - -Calculates the sum of the numbers from 1 to 1000000000. -.br -And finishes in a reasonable amount of time, too. -.TP -luajit \-jv \-e "for i=1,10 do for j=1,10 do for k=1,100 do end end end" - -Runs some nested loops and shows the resulting traces. -.SH COPYRIGHT -.PP -\fBLuaJIT\fR is Copyright \(co 2005-2014 Mike Pall. -.br -\fBLuaJIT\fR is open source software, released under the MIT license. -.SH SEE ALSO -.PP -More details in the provided HTML docs or at: -.IR http://luajit.org -.br -More about the Lua language can be found at: -.IR http://lua.org/docs.html -.PP -lua(1) diff --git a/source/libs/luajit/LuaJIT-2.0.3/etc/luajit.pc b/source/libs/luajit/LuaJIT-2.0.3/etc/luajit.pc deleted file mode 100644 index d3f0cf30b..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/etc/luajit.pc +++ /dev/null @@ -1,25 +0,0 @@ -# Package information for LuaJIT to be used by pkg-config. -majver=2 -minver=0 -relver=3 -version=${majver}.${minver}.${relver} -abiver=5.1 - -prefix=/usr/local -multilib=lib -exec_prefix=${prefix} -libdir=${exec_prefix}/${multilib} -libname=luajit-${abiver} -includedir=${prefix}/include/luajit-${majver}.${minver} - -INSTALL_LMOD=${prefix}/share/lua/${abiver} -INSTALL_CMOD=${prefix}/${multilib}/lua/${abiver} - -Name: LuaJIT -Description: Just-in-time compiler for Lua -URL: http://luajit.org -Version: ${version} -Requires: -Libs: -L${libdir} -l${libname} -Libs.private: -Wl,-E -lm -ldl -Cflags: -I${includedir} diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/Makefile b/source/libs/luajit/LuaJIT-2.0.3/src/Makefile deleted file mode 100644 index 818f30192..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/Makefile +++ /dev/null @@ -1,686 +0,0 @@ -############################################################################## -# LuaJIT Makefile. Requires GNU Make. -# -# Please read doc/install.html before changing any variables! -# -# Suitable for POSIX platforms (Linux, *BSD, OSX etc.). -# Also works with MinGW and Cygwin on Windows. -# Please check msvcbuild.bat for building with MSVC on Windows. -# -# Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -############################################################################## - -MAJVER= 2 -MINVER= 0 -RELVER= 3 -ABIVER= 5.1 -NODOTABIVER= 51 - -############################################################################## -############################# COMPILER OPTIONS ############################# -############################################################################## -# These options mainly affect the speed of the JIT compiler itself, not the -# speed of the JIT-compiled code. Turn any of the optional settings on by -# removing the '#' in front of them. Make sure you force a full recompile -# with "make clean", followed by "make" if you change any options. -# -# LuaJIT builds as a native 32 or 64 bit binary by default. -CC= gcc -# -# Use this if you want to force a 32 bit build on a 64 bit multilib OS. -#CC= gcc -m32 -# -# Since the assembler part does NOT maintain a frame pointer, it's pointless -# to slow down the C part by not omitting it. Debugging, tracebacks and -# unwinding are not affected -- the assembler part has frame unwind -# information and GCC emits it where needed (x64) or with -g (see CCDEBUG). -CCOPT= -O2 -fomit-frame-pointer -# Use this if you want to generate a smaller binary (but it's slower): -#CCOPT= -Os -fomit-frame-pointer -# Note: it's no longer recommended to use -O3 with GCC 4.x. -# The I-Cache bloat usually outweighs the benefits from aggressive inlining. -# -# Target-specific compiler options: -# -# x86 only: it's recommended to compile at least for i686. Better yet, -# compile for an architecture that has SSE2, too (-msse -msse2). -# -# x86/x64 only: For GCC 4.2 or higher and if you don't intend to distribute -# the binaries to a different machine you could also use: -march=native -# -CCOPT_x86= -march=i686 -CCOPT_x64= -CCOPT_arm= -CCOPT_ppc= -CCOPT_ppcspe= -CCOPT_mips= -# -CCDEBUG= -# Uncomment the next line to generate debug information: -#CCDEBUG= -g -# -CCWARN= -Wall -# Uncomment the next line to enable more warnings: -#CCWARN+= -Wextra -Wdeclaration-after-statement -Wredundant-decls -Wshadow -Wpointer-arith -# -############################################################################## - -############################################################################## -################################ BUILD MODE ################################ -############################################################################## -# The default build mode is mixed mode on POSIX. On Windows this is the same -# as dynamic mode. -# -# Mixed mode creates a static + dynamic library and a statically linked luajit. -BUILDMODE= mixed -# -# Static mode creates a static library and a statically linked luajit. -#BUILDMODE= static -# -# Dynamic mode creates a dynamic library and a dynamically linked luajit. -# Note: this executable will only run when the library is installed! -#BUILDMODE= dynamic -# -############################################################################## - -############################################################################## -################################# FEATURES ################################# -############################################################################## -# Enable/disable these features as needed, but make sure you force a full -# recompile with "make clean", followed by "make". -XCFLAGS= -# -# Permanently disable the FFI extension to reduce the size of the LuaJIT -# executable. But please consider that the FFI library is compiled-in, -# but NOT loaded by default. It only allocates any memory, if you actually -# make use of it. -#XCFLAGS+= -DLUAJIT_DISABLE_FFI -# -# Features from Lua 5.2 that are unlikely to break existing code are -# enabled by default. Some other features that *might* break some existing -# code (e.g. __pairs or os.execute() return values) can be enabled here. -# Note: this does not provide full compatibility with Lua 5.2 at this time. -XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT -# -# Disable the JIT compiler, i.e. turn LuaJIT into a pure interpreter. -#XCFLAGS+= -DLUAJIT_DISABLE_JIT -# -# Some architectures (e.g. PPC) can use either single-number (1) or -# dual-number (2) mode. Uncomment one of these lines to override the -# default mode. Please see LJ_ARCH_NUMMODE in lj_arch.h for details. -#XCFLAGS+= -DLUAJIT_NUMMODE=1 -#XCFLAGS+= -DLUAJIT_NUMMODE=2 -# -############################################################################## - -############################################################################## -############################ DEBUGGING SUPPORT ############################# -############################################################################## -# Enable these options as needed, but make sure you force a full recompile -# with "make clean", followed by "make". -# Note that most of these are NOT suitable for benchmarking or release mode! -# -# Use the system provided memory allocator (realloc) instead of the -# bundled memory allocator. This is slower, but sometimes helpful for -# debugging. It's helpful for Valgrind's memcheck tool, too. This option -# cannot be enabled on x64, since the built-in allocator is mandatory. -#XCFLAGS+= -DLUAJIT_USE_SYSMALLOC -# -# This define is required to run LuaJIT under Valgrind. The Valgrind -# header files must be installed. You should enable debug information, too. -# Use --suppressions=lj.supp to avoid some false positives. -#XCFLAGS+= -DLUAJIT_USE_VALGRIND -# -# This is the client for the GDB JIT API. GDB 7.0 or higher is required -# to make use of it. See lj_gdbjit.c for details. Enabling this causes -# a non-negligible overhead, even when not running under GDB. -#XCFLAGS+= -DLUAJIT_USE_GDBJIT -# -# Turn on assertions for the Lua/C API to debug problems with lua_* calls. -# This is rather slow -- use only while developing C libraries/embeddings. -#XCFLAGS+= -DLUA_USE_APICHECK -# -# Turn on assertions for the whole LuaJIT VM. This significantly slows down -# everything. Use only if you suspect a problem with LuaJIT itself. -#XCFLAGS+= -DLUA_USE_ASSERT -# -############################################################################## -# You probably don't need to change anything below this line! -############################################################################## - -############################################################################## -# Flags and options for host and target. -############################################################################## - -# You can override the following variables at the make command line: -# CC HOST_CC STATIC_CC DYNAMIC_CC -# CFLAGS HOST_CFLAGS TARGET_CFLAGS -# LDFLAGS HOST_LDFLAGS TARGET_LDFLAGS TARGET_SHLDFLAGS -# LIBS HOST_LIBS TARGET_LIBS -# CROSS HOST_SYS TARGET_SYS TARGET_FLAGS -# -# Cross-compilation examples: -# make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows -# make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu- - -CCOPTIONS= $(CCDEBUG) $(CCOPT) $(CCWARN) $(XCFLAGS) $(CFLAGS) -LDOPTIONS= $(CCDEBUG) $(LDFLAGS) - -HOST_CC= $(CC) -HOST_RM= rm -f -# If left blank, minilua is built and used. You can supply an installed -# copy of (plain) Lua 5.1 or 5.2, plus Lua BitOp. E.g. with: HOST_LUA=lua -HOST_LUA= - -HOST_XCFLAGS= -I. -HOST_XLDFLAGS= -HOST_XLIBS= -HOST_ACFLAGS= $(CCOPTIONS) $(HOST_XCFLAGS) $(TARGET_ARCH) $(HOST_CFLAGS) -HOST_ALDFLAGS= $(LDOPTIONS) $(HOST_XLDFLAGS) $(HOST_LDFLAGS) -HOST_ALIBS= $(HOST_XLIBS) $(LIBS) $(HOST_LIBS) - -STATIC_CC = $(CROSS)$(CC) -DYNAMIC_CC = $(CROSS)$(CC) -fPIC -TARGET_CC= $(STATIC_CC) -TARGET_STCC= $(STATIC_CC) -TARGET_DYNCC= $(DYNAMIC_CC) -TARGET_LD= $(CROSS)$(CC) -TARGET_AR= $(CROSS)ar rcus -TARGET_STRIP= $(CROSS)strip - -TARGET_LIBPATH= $(or $(PREFIX),/usr/local)/$(or $(MULTILIB),lib) -TARGET_SONAME= libluajit-$(ABIVER).so.$(MAJVER) -TARGET_DYLIBNAME= libluajit-$(ABIVER).$(MAJVER).dylib -TARGET_DYLIBPATH= $(TARGET_LIBPATH)/$(TARGET_DYLIBNAME) -TARGET_DLLNAME= lua$(NODOTABIVER).dll -TARGET_XSHLDFLAGS= -shared -fPIC -Wl,-soname,$(TARGET_SONAME) -TARGET_DYNXLDOPTS= - -TARGET_LFSFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -TARGET_XCFLAGS= $(TARGET_LFSFLAGS) -U_FORTIFY_SOURCE -TARGET_XLDFLAGS= -TARGET_XLIBS= -lm -TARGET_TCFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS) -TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS) -TARGET_ALDFLAGS= $(LDOPTIONS) $(TARGET_XLDFLAGS) $(TARGET_FLAGS) $(TARGET_LDFLAGS) -TARGET_ASHLDFLAGS= $(LDOPTIONS) $(TARGET_XSHLDFLAGS) $(TARGET_FLAGS) $(TARGET_SHLDFLAGS) -TARGET_ALIBS= $(TARGET_XLIBS) $(LIBS) $(TARGET_LIBS) - -TARGET_TESTARCH=$(shell $(TARGET_CC) $(TARGET_TCFLAGS) -E lj_arch.h -dM) -ifneq (,$(findstring LJ_TARGET_X64 ,$(TARGET_TESTARCH))) - TARGET_LJARCH= x64 -else -ifneq (,$(findstring LJ_TARGET_X86 ,$(TARGET_TESTARCH))) - TARGET_LJARCH= x86 -else -ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH))) - TARGET_LJARCH= arm -else -ifneq (,$(findstring LJ_TARGET_PPC ,$(TARGET_TESTARCH))) - TARGET_LJARCH= ppc -else -ifneq (,$(findstring LJ_TARGET_PPCSPE ,$(TARGET_TESTARCH))) - TARGET_LJARCH= ppcspe -else -ifneq (,$(findstring LJ_TARGET_MIPS ,$(TARGET_TESTARCH))) - ifneq (,$(findstring MIPSEL ,$(TARGET_TESTARCH))) - TARGET_ARCH= -D__MIPSEL__=1 - endif - TARGET_LJARCH= mips -else - $(error Unsupported target architecture) -endif -endif -endif -endif -endif -endif - -ifneq (,$(findstring LJ_TARGET_PS3 1,$(TARGET_TESTARCH))) - TARGET_SYS= PS3 - TARGET_ARCH+= -D__CELLOS_LV2__ - TARGET_XCFLAGS+= -DLUAJIT_USE_SYSMALLOC -endif -ifneq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH))) - TARGET_ARCH+= -DLUAJIT_NO_UNWIND -endif - -TARGET_XCFLAGS+= $(CCOPT_$(TARGET_LJARCH)) -TARGET_ARCH+= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_LJARCH)) - -ifneq (,$(PREFIX)) -ifneq (/usr/local,$(PREFIX)) - TARGET_XCFLAGS+= -DLUA_ROOT=\"$(PREFIX)\" - ifneq (/usr,$(PREFIX)) - TARGET_DYNXLDOPTS= -Wl,-rpath,$(TARGET_LIBPATH) - endif -endif -endif -ifneq (,$(MULTILIB)) - TARGET_XCFLAGS+= -DLUA_MULTILIB=\"$(MULTILIB)\" -endif -ifneq (,$(LMULTILIB)) - TARGET_XCFLAGS+= -DLUA_LMULTILIB=\"$(LMULTILIB)\" -endif - -############################################################################## -# System detection. -############################################################################## - -ifeq (Windows,$(findstring Windows,$(OS))$(MSYSTEM)$(TERM)) - HOST_SYS= Windows - HOST_RM= del -else - HOST_SYS:= $(shell uname -s) - ifneq (,$(findstring MINGW,$(HOST_SYS))) - HOST_SYS= Windows - HOST_MSYS= mingw - endif - ifneq (,$(findstring CYGWIN,$(HOST_SYS))) - HOST_SYS= Windows - HOST_MSYS= cygwin - endif -endif - -TARGET_SYS?= $(HOST_SYS) -ifeq (Windows,$(TARGET_SYS)) - TARGET_STRIP+= --strip-unneeded - TARGET_XSHLDFLAGS= -shared - TARGET_DYNXLDOPTS= -else -ifeq (Darwin,$(TARGET_SYS)) - ifeq (,$(MACOSX_DEPLOYMENT_TARGET)) - export MACOSX_DEPLOYMENT_TARGET=10.4 - endif - TARGET_STRIP+= -x - TARGET_AR+= 2>/dev/null - ifeq (,$(shell $(TARGET_CC) -o /dev/null -c -x c /dev/null -fno-stack-protector 2>/dev/null || echo 1)) - TARGET_XCFLAGS+= -fno-stack-protector - endif - TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC - TARGET_DYNXLDOPTS= - TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) - ifeq (x64,$(TARGET_LJARCH)) - TARGET_XLDFLAGS+= -pagezero_size 10000 -image_base 100000000 - TARGET_XSHLDFLAGS+= -image_base 7fff04c4a000 - endif -else -ifeq (iOS,$(TARGET_SYS)) - TARGET_STRIP+= -x - TARGET_AR+= 2>/dev/null - TARGET_XCFLAGS+= -fno-stack-protector - TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC - TARGET_DYNXLDOPTS= - TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) -else - ifneq (,$(findstring stack-protector,$(shell $(TARGET_CC) -dumpspecs))) - TARGET_XCFLAGS+= -fno-stack-protector - endif - ifneq (SunOS,$(TARGET_SYS)) - ifneq (PS3,$(TARGET_SYS)) - TARGET_XLDFLAGS+= -Wl,-E - endif - endif - ifeq (Linux,$(TARGET_SYS)) - TARGET_XLIBS+= -ldl - endif - ifeq (GNU/kFreeBSD,$(TARGET_SYS)) - TARGET_XLIBS+= -ldl - endif -endif -endif -endif - -ifneq ($(HOST_SYS),$(TARGET_SYS)) - ifeq (Windows,$(TARGET_SYS)) - HOST_XCFLAGS+= -malign-double -DLUAJIT_OS=LUAJIT_OS_WINDOWS - else - ifeq (Linux,$(TARGET_SYS)) - HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_LINUX - else - ifeq (Darwin,$(TARGET_SYS)) - HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX - else - ifeq (iOS,$(TARGET_SYS)) - HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX - else - HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OTHER - endif - endif - endif - endif -endif - -ifneq (,$(CCDEBUG)) - TARGET_STRIP= @: -endif - -############################################################################## -# Files and pathnames. -############################################################################## - -MINILUA_O= host/minilua.o -MINILUA_LIBS= -lm -MINILUA_T= host/minilua -MINILUA_X= $(MINILUA_T) - -ifeq (,$(HOST_LUA)) - HOST_LUA= $(MINILUA_X) - DASM_DEP= $(MINILUA_T) -endif - -DASM_DIR= ../dynasm -DASM= $(HOST_LUA) $(DASM_DIR)/dynasm.lua -DASM_XFLAGS= -DASM_AFLAGS= -DASM_ARCH= $(TARGET_LJARCH) - -ifneq (,$(findstring LJ_ARCH_BITS 64,$(TARGET_TESTARCH))) - DASM_AFLAGS+= -D P64 -endif -ifneq (,$(findstring LJ_HASJIT 1,$(TARGET_TESTARCH))) - DASM_AFLAGS+= -D JIT -endif -ifneq (,$(findstring LJ_HASFFI 1,$(TARGET_TESTARCH))) - DASM_AFLAGS+= -D FFI -endif -ifneq (,$(findstring LJ_DUALNUM 1,$(TARGET_TESTARCH))) - DASM_AFLAGS+= -D DUALNUM -endif -ifneq (,$(findstring LJ_ARCH_HASFPU 1,$(TARGET_TESTARCH))) - DASM_AFLAGS+= -D FPU - TARGET_ARCH+= -DLJ_ARCH_HASFPU=1 -else - TARGET_ARCH+= -DLJ_ARCH_HASFPU=0 -endif -ifeq (,$(findstring LJ_ABI_SOFTFP 1,$(TARGET_TESTARCH))) - DASM_AFLAGS+= -D HFABI - TARGET_ARCH+= -DLJ_ABI_SOFTFP=0 -else - TARGET_ARCH+= -DLJ_ABI_SOFTFP=1 -endif -DASM_AFLAGS+= -D VER=$(subst LJ_ARCH_VERSION_,,$(filter LJ_ARCH_VERSION_%,$(subst LJ_ARCH_VERSION ,LJ_ARCH_VERSION_,$(TARGET_TESTARCH)))) -ifeq (Windows,$(TARGET_SYS)) - DASM_AFLAGS+= -D WIN -endif -ifeq (x86,$(TARGET_LJARCH)) - ifneq (,$(findstring __SSE2__ 1,$(TARGET_TESTARCH))) - DASM_AFLAGS+= -D SSE - endif -else -ifeq (x64,$(TARGET_LJARCH)) - DASM_ARCH= x86 -else -ifeq (arm,$(TARGET_LJARCH)) - ifeq (iOS,$(TARGET_SYS)) - DASM_AFLAGS+= -D IOS - endif -else -ifeq (ppc,$(TARGET_LJARCH)) - ifneq (,$(findstring LJ_ARCH_SQRT 1,$(TARGET_TESTARCH))) - DASM_AFLAGS+= -D SQRT - endif - ifneq (,$(findstring LJ_ARCH_ROUND 1,$(TARGET_TESTARCH))) - DASM_AFLAGS+= -D ROUND - endif - ifneq (,$(findstring LJ_ARCH_PPC64 1,$(TARGET_TESTARCH))) - DASM_AFLAGS+= -D GPR64 - endif - ifeq (PS3,$(TARGET_SYS)) - DASM_AFLAGS+= -D PPE -D TOC - endif -endif -endif -endif -endif - -DASM_FLAGS= $(DASM_XFLAGS) $(DASM_AFLAGS) -DASM_DASC= vm_$(DASM_ARCH).dasc - -BUILDVM_O= host/buildvm.o host/buildvm_asm.o host/buildvm_peobj.o \ - host/buildvm_lib.o host/buildvm_fold.o -BUILDVM_T= host/buildvm -BUILDVM_X= $(BUILDVM_T) - -HOST_O= $(MINILUA_O) $(BUILDVM_O) -HOST_T= $(MINILUA_T) $(BUILDVM_T) - -LJVM_S= lj_vm.s -LJVM_O= lj_vm.o -LJVM_BOUT= $(LJVM_S) -LJVM_MODE= elfasm - -LJLIB_O= lib_base.o lib_math.o lbitlib.o lib_bit.o lib_string.o lib_table.o \ - lib_io.o lib_os.o lib_package.o lib_debug.o lib_jit.o lib_ffi.o -LJLIB_C= $(LJLIB_O:.o=.c) - -LJCORE_O= lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o \ - lj_str.o lj_tab.o lj_func.o lj_udata.o lj_meta.o lj_debug.o \ - lj_state.o lj_dispatch.o lj_vmevent.o lj_vmmath.o lj_strscan.o \ - lj_api.o lj_lex.o lj_parse.o lj_bcread.o lj_bcwrite.o lj_load.o \ - lj_ir.o lj_opt_mem.o lj_opt_fold.o lj_opt_narrow.o \ - lj_opt_dce.o lj_opt_loop.o lj_opt_split.o lj_opt_sink.o \ - lj_mcode.o lj_snap.o lj_record.o lj_crecord.o lj_ffrecord.o \ - lj_asm.o lj_trace.o lj_gdbjit.o \ - lj_ctype.o lj_cdata.o lj_cconv.o lj_ccall.o lj_ccallback.o \ - lj_carith.o lj_clib.o lj_cparse.o \ - lj_lib.o lj_alloc.o lib_aux.o \ - $(LJLIB_O) lib_init.o - -LJVMCORE_O= $(LJVM_O) $(LJCORE_O) -LJVMCORE_DYNO= $(LJVMCORE_O:.o=_dyn.o) - -LIB_VMDEF= jit/vmdef.lua -LIB_VMDEFP= $(LIB_VMDEF) - -LUAJIT_O= luajit.o -LUAJIT_A= libluajit.a -LUAJIT_SO= libluajit.so -LUAJIT_T= luajit - -ALL_T= $(LUAJIT_T) $(LUAJIT_A) $(LUAJIT_SO) $(HOST_T) -ALL_HDRGEN= lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h \ - host/buildvm_arch.h -ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) $(LIB_VMDEFP) -WIN_RM= *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk -ALL_RM= $(ALL_T) $(ALL_GEN) *.o host/*.o $(WIN_RM) - -############################################################################## -# Build mode handling. -############################################################################## - -# Mixed mode defaults. -TARGET_O= $(LUAJIT_A) -TARGET_T= $(LUAJIT_T) $(LUAJIT_SO) -TARGET_DEP= $(LIB_VMDEF) $(LUAJIT_SO) - -ifeq (Windows,$(TARGET_SYS)) - TARGET_DYNCC= $(STATIC_CC) - LJVM_MODE= peobj - LJVM_BOUT= $(LJVM_O) - LUAJIT_T= luajit.exe - ifeq (cygwin,$(HOST_MSYS)) - LUAJIT_SO= cyg$(TARGET_DLLNAME) - else - LUAJIT_SO= $(TARGET_DLLNAME) - endif - # Mixed mode is not supported on Windows. And static mode doesn't work well. - # C modules cannot be loaded, because they bind to lua51.dll. - ifneq (static,$(BUILDMODE)) - BUILDMODE= dynamic - TARGET_XCFLAGS+= -DLUA_BUILD_AS_DLL - endif -endif -ifeq (Darwin,$(TARGET_SYS)) - LJVM_MODE= machasm -endif -ifeq (iOS,$(TARGET_SYS)) - LJVM_MODE= machasm -endif -ifeq (SunOS,$(TARGET_SYS)) - BUILDMODE= static -endif -ifeq (PS3,$(TARGET_SYS)) - BUILDMODE= static -endif - -ifeq (Windows,$(HOST_SYS)) - MINILUA_T= host/minilua.exe - BUILDVM_T= host/buildvm.exe - ifeq (,$(HOST_MSYS)) - MINILUA_X= host\minilua - BUILDVM_X= host\buildvm - ALL_RM:= $(subst /,\,$(ALL_RM)) - endif -endif - -ifeq (static,$(BUILDMODE)) - TARGET_DYNCC= @: - TARGET_T= $(LUAJIT_T) - TARGET_DEP= $(LIB_VMDEF) -else -ifeq (dynamic,$(BUILDMODE)) - ifneq (Windows,$(TARGET_SYS)) - TARGET_CC= $(DYNAMIC_CC) - endif - TARGET_DYNCC= @: - LJVMCORE_DYNO= $(LJVMCORE_O) - TARGET_O= $(LUAJIT_SO) - TARGET_XLDFLAGS+= $(TARGET_DYNXLDOPTS) -else -ifeq (Darwin,$(TARGET_SYS)) - TARGET_DYNCC= @: - LJVMCORE_DYNO= $(LJVMCORE_O) -endif -ifeq (iOS,$(TARGET_SYS)) - TARGET_DYNCC= @: - LJVMCORE_DYNO= $(LJVMCORE_O) -endif -endif -endif - -Q= @ -E= @echo -#Q= -#E= @: - -############################################################################## -# Make targets. -############################################################################## - -default all: $(TARGET_T) - -amalg: - @grep "^[+|]" ljamalg.c - $(MAKE) all "LJCORE_O=ljamalg.o" - -clean: - $(HOST_RM) $(ALL_RM) - -depend: - @for file in $(ALL_HDRGEN); do \ - test -f $$file || touch $$file; \ - done - @$(HOST_CC) $(HOST_ACFLAGS) -MM *.c host/*.c | \ - sed -e "s| [^ ]*/dasm_\S*\.h||g" \ - -e "s|^\([^l ]\)|host/\1|" \ - -e "s| lj_target_\S*\.h| lj_target_*.h|g" \ - -e "s| lj_emit_\S*\.h| lj_emit_*.h|g" \ - -e "s| lj_asm_\S*\.h| lj_asm_*.h|g" >Makefile.dep - @for file in $(ALL_HDRGEN); do \ - test -s $$file || $(HOST_RM) $$file; \ - done - -.PHONY: default all amalg clean depend - -############################################################################## -# Rules for generated files. -############################################################################## - -$(MINILUA_T): $(MINILUA_O) - $(E) "HOSTLINK $@" - $(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(MINILUA_O) $(MINILUA_LIBS) $(HOST_ALIBS) - -host/buildvm_arch.h: $(DASM_DASC) $(DASM_DEP) - $(E) "DYNASM $@" - $(Q)$(DASM) $(DASM_FLAGS) -o $@ $(DASM_DASC) - -host/buildvm.o: $(DASM_DIR)/dasm_*.h - -$(BUILDVM_T): $(BUILDVM_O) - $(E) "HOSTLINK $@" - $(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(BUILDVM_O) $(HOST_ALIBS) - -$(LJVM_BOUT): $(BUILDVM_T) - $(E) "BUILDVM $@" - $(Q)$(BUILDVM_X) -m $(LJVM_MODE) -o $@ - -lj_bcdef.h: $(BUILDVM_T) $(LJLIB_C) - $(E) "BUILDVM $@" - $(Q)$(BUILDVM_X) -m bcdef -o $@ $(LJLIB_C) - -lj_ffdef.h: $(BUILDVM_T) $(LJLIB_C) - $(E) "BUILDVM $@" - $(Q)$(BUILDVM_X) -m ffdef -o $@ $(LJLIB_C) - -lj_libdef.h: $(BUILDVM_T) $(LJLIB_C) - $(E) "BUILDVM $@" - $(Q)$(BUILDVM_X) -m libdef -o $@ $(LJLIB_C) - -lj_recdef.h: $(BUILDVM_T) $(LJLIB_C) - $(E) "BUILDVM $@" - $(Q)$(BUILDVM_X) -m recdef -o $@ $(LJLIB_C) - -$(LIB_VMDEF): $(BUILDVM_T) $(LJLIB_C) - $(E) "BUILDVM $@" - $(Q)$(BUILDVM_X) -m vmdef -o $(LIB_VMDEFP) $(LJLIB_C) - -lj_folddef.h: $(BUILDVM_T) lj_opt_fold.c - $(E) "BUILDVM $@" - $(Q)$(BUILDVM_X) -m folddef -o $@ lj_opt_fold.c - -############################################################################## -# Object file rules. -############################################################################## - -%.o: %.c - $(E) "CC $@" - $(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $< - $(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $< - -%.o: %.s - $(E) "ASM $@" - $(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $< - $(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $< - -$(LUAJIT_O): - $(E) "CC $@" - $(Q)$(TARGET_STCC) $(TARGET_ACFLAGS) -c -o $@ $< - -$(HOST_O): %.o: %.c - $(E) "HOSTCC $@" - $(Q)$(HOST_CC) $(HOST_ACFLAGS) -c -o $@ $< - -include Makefile.dep - -############################################################################## -# Target file rules. -############################################################################## - -$(LUAJIT_A): $(LJVMCORE_O) - $(E) "AR $@" - $(Q)$(TARGET_AR) $@ $(LJVMCORE_O) - -# The dependency on _O, but linking with _DYNO is intentional. -$(LUAJIT_SO): $(LJVMCORE_O) - $(E) "DYNLINK $@" - $(Q)$(TARGET_LD) $(TARGET_ASHLDFLAGS) -o $@ $(LJVMCORE_DYNO) $(TARGET_ALIBS) - $(Q)$(TARGET_STRIP) $@ - -$(LUAJIT_T): $(TARGET_O) $(LUAJIT_O) $(TARGET_DEP) - $(E) "LINK $@" - $(Q)$(TARGET_LD) $(TARGET_ALDFLAGS) -o $@ $(LUAJIT_O) $(TARGET_O) $(TARGET_ALIBS) - $(Q)$(TARGET_STRIP) $@ - $(E) "OK Successfully built LuaJIT" - -############################################################################## diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/Makefile.dep b/source/libs/luajit/LuaJIT-2.0.3/src/Makefile.dep deleted file mode 100644 index b155b81c6..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/Makefile.dep +++ /dev/null @@ -1,227 +0,0 @@ -lib_aux.o: lib_aux.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \ - lj_arch.h lj_err.h lj_errmsg.h lj_state.h lj_trace.h lj_jit.h lj_ir.h \ - lj_dispatch.h lj_bc.h lj_traceerr.h lj_lib.h lj_alloc.h -lib_base.o: lib_base.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ - lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h \ - lj_tab.h lj_meta.h lj_state.h lj_ctype.h lj_cconv.h lj_bc.h lj_ff.h \ - lj_ffdef.h lj_dispatch.h lj_jit.h lj_ir.h lj_char.h lj_strscan.h \ - lj_lib.h lj_libdef.h -lbitlib.o: lbitlib.c lua.h luaconf.h lauxlib.h lualib.h -lib_bit.o: lib_bit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ - lj_arch.h lj_err.h lj_errmsg.h lj_str.h lj_lib.h lj_libdef.h -lib_debug.o: lib_debug.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ - lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_lib.h \ - lj_libdef.h -lib_ffi.o: lib_ffi.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ - lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h \ - lj_ctype.h lj_cparse.h lj_cdata.h lj_cconv.h lj_carith.h lj_ccall.h \ - lj_ccallback.h lj_clib.h lj_ff.h lj_ffdef.h lj_lib.h lj_libdef.h -lib_init.o: lib_init.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h -lib_io.o: lib_io.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ - lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_state.h lj_ff.h \ - lj_ffdef.h lj_lib.h lj_libdef.h -lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h \ - lj_obj.h lj_def.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h \ - lj_bc.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_target.h \ - lj_target_*.h lj_dispatch.h lj_vm.h lj_vmevent.h lj_lib.h luajit.h \ - lj_libdef.h -lib_math.o: lib_math.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ - lj_def.h lj_arch.h lj_lib.h lj_vm.h lj_libdef.h -lib_os.o: lib_os.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ - lj_arch.h lj_err.h lj_errmsg.h lj_lib.h lj_libdef.h -lib_package.o: lib_package.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ - lj_def.h lj_arch.h lj_err.h lj_errmsg.h lj_lib.h -lib_string.o: lib_string.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ - lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h \ - lj_meta.h lj_state.h lj_ff.h lj_ffdef.h lj_bcdump.h lj_lex.h lj_char.h \ - lj_lib.h lj_libdef.h -lib_table.o: lib_table.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ - lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_tab.h lj_lib.h \ - lj_libdef.h -lj_alloc.o: lj_alloc.c lj_def.h lua.h luaconf.h lj_arch.h lj_alloc.h -lj_api.o: lj_api.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ - lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_func.h lj_udata.h \ - lj_meta.h lj_state.h lj_bc.h lj_frame.h lj_trace.h lj_jit.h lj_ir.h \ - lj_dispatch.h lj_traceerr.h lj_vm.h lj_strscan.h -lj_asm.o: lj_asm.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ - lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ctype.h lj_ir.h lj_jit.h \ - lj_ircall.h lj_iropt.h lj_mcode.h lj_trace.h lj_dispatch.h lj_traceerr.h \ - lj_snap.h lj_asm.h lj_vm.h lj_target.h lj_target_*.h lj_emit_*.h \ - lj_asm_*.h -lj_bc.o: lj_bc.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_bc.h \ - lj_bcdef.h -lj_bcread.o: lj_bcread.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_bc.h lj_ctype.h \ - lj_cdata.h lualib.h lj_lex.h lj_bcdump.h lj_state.h -lj_bcwrite.o: lj_bcwrite.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_gc.h lj_str.h lj_bc.h lj_ctype.h lj_dispatch.h lj_jit.h lj_ir.h \ - lj_bcdump.h lj_lex.h lj_err.h lj_errmsg.h lj_vm.h -lj_carith.o: lj_carith.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_gc.h lj_err.h lj_errmsg.h lj_tab.h lj_meta.h lj_ctype.h lj_cconv.h \ - lj_cdata.h lj_carith.h -lj_ccall.o: lj_ccall.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_cconv.h \ - lj_cdata.h lj_ccall.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_bc.h \ - lj_traceerr.h -lj_ccallback.o: lj_ccallback.c lj_obj.h lua.h luaconf.h lj_def.h \ - lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_tab.h lj_state.h lj_frame.h \ - lj_bc.h lj_ctype.h lj_cconv.h lj_ccall.h lj_ccallback.h lj_target.h \ - lj_target_*.h lj_mcode.h lj_jit.h lj_ir.h lj_trace.h lj_dispatch.h \ - lj_traceerr.h lj_vm.h -lj_cconv.o: lj_cconv.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_err.h lj_errmsg.h lj_tab.h lj_ctype.h lj_gc.h lj_cdata.h lj_cconv.h \ - lj_ccallback.h -lj_cdata.o: lj_cdata.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_cconv.h \ - lj_cdata.h -lj_char.o: lj_char.c lj_char.h lj_def.h lua.h luaconf.h -lj_clib.o: lj_clib.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ - lj_err.h lj_errmsg.h lj_tab.h lj_str.h lj_udata.h lj_ctype.h lj_cconv.h \ - lj_cdata.h lj_clib.h -lj_cparse.o: lj_cparse.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_ctype.h lj_cparse.h lj_frame.h \ - lj_bc.h lj_vm.h lj_char.h lj_strscan.h -lj_crecord.o: lj_crecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ctype.h \ - lj_gc.h lj_cdata.h lj_cparse.h lj_cconv.h lj_clib.h lj_ccall.h lj_ff.h \ - lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \ - lj_dispatch.h lj_traceerr.h lj_record.h lj_ffrecord.h lj_snap.h \ - lj_crecord.h -lj_ctype.o: lj_ctype.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_ccallback.h -lj_debug.o: lj_debug.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_state.h lj_frame.h \ - lj_bc.h lj_jit.h lj_ir.h -lj_dispatch.o: lj_dispatch.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_err.h lj_errmsg.h lj_func.h lj_str.h lj_tab.h lj_meta.h lj_debug.h \ - lj_state.h lj_frame.h lj_bc.h lj_ff.h lj_ffdef.h lj_jit.h lj_ir.h \ - lj_ccallback.h lj_ctype.h lj_gc.h lj_trace.h lj_dispatch.h lj_traceerr.h \ - lj_vm.h luajit.h -lj_err.o: lj_err.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_err.h \ - lj_errmsg.h lj_debug.h lj_str.h lj_func.h lj_state.h lj_frame.h lj_bc.h \ - lj_ff.h lj_ffdef.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h \ - lj_traceerr.h lj_vm.h -lj_ffrecord.o: lj_ffrecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ff.h \ - lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \ - lj_dispatch.h lj_traceerr.h lj_record.h lj_ffrecord.h lj_crecord.h \ - lj_vm.h lj_strscan.h lj_recdef.h -lj_func.o: lj_func.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ - lj_func.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_bc.h \ - lj_traceerr.h lj_vm.h -lj_gc.o: lj_gc.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ - lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_udata.h lj_meta.h \ - lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_cdata.h lj_trace.h lj_jit.h \ - lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h -lj_gdbjit.o: lj_gdbjit.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_frame.h lj_bc.h lj_jit.h \ - lj_ir.h lj_dispatch.h -lj_ir.o: lj_ir.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ - lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \ - lj_dispatch.h lj_bc.h lj_traceerr.h lj_ctype.h lj_cdata.h lj_carith.h \ - lj_vm.h lj_strscan.h lj_lib.h -lj_lex.o: lj_lex.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ - lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_cdata.h lualib.h \ - lj_state.h lj_lex.h lj_parse.h lj_char.h lj_strscan.h -lj_lib.o: lj_lib.c lauxlib.h lua.h luaconf.h lj_obj.h lj_def.h lj_arch.h \ - lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_bc.h \ - lj_dispatch.h lj_jit.h lj_ir.h lj_vm.h lj_strscan.h lj_lib.h -lj_load.o: lj_load.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \ - lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_func.h lj_frame.h \ - lj_bc.h lj_vm.h lj_lex.h lj_bcdump.h lj_parse.h -lj_mcode.o: lj_mcode.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_gc.h lj_err.h lj_errmsg.h lj_jit.h lj_ir.h lj_mcode.h lj_trace.h \ - lj_dispatch.h lj_bc.h lj_traceerr.h lj_vm.h -lj_meta.o: lj_meta.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ - lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h lj_frame.h lj_bc.h \ - lj_vm.h lj_strscan.h -lj_obj.o: lj_obj.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h -lj_opt_dce.o: lj_opt_dce.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_ir.h lj_jit.h lj_iropt.h -lj_opt_fold.o: lj_opt_fold.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \ - lj_bc.h lj_traceerr.h lj_ctype.h lj_gc.h lj_carith.h lj_vm.h \ - lj_strscan.h lj_folddef.h -lj_opt_loop.o: lj_opt_loop.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_err.h lj_errmsg.h lj_str.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h \ - lj_dispatch.h lj_bc.h lj_traceerr.h lj_snap.h lj_vm.h -lj_opt_mem.o: lj_opt_mem.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_tab.h lj_ir.h lj_jit.h lj_iropt.h -lj_opt_narrow.o: lj_opt_narrow.c lj_obj.h lua.h luaconf.h lj_def.h \ - lj_arch.h lj_bc.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \ - lj_traceerr.h lj_vm.h lj_strscan.h -lj_opt_sink.o: lj_opt_sink.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_ir.h lj_jit.h lj_iropt.h lj_target.h lj_target_*.h -lj_opt_split.o: lj_opt_split.c lj_obj.h lua.h luaconf.h lj_def.h \ - lj_arch.h lj_err.h lj_errmsg.h lj_str.h lj_ir.h lj_jit.h lj_ircall.h \ - lj_iropt.h lj_vm.h -lj_parse.o: lj_parse.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_func.h \ - lj_state.h lj_bc.h lj_ctype.h lj_lex.h lj_parse.h lj_vm.h lj_vmevent.h -lj_record.o: lj_record.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h lj_frame.h lj_bc.h \ - lj_ctype.h lj_gc.h lj_ff.h lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h \ - lj_iropt.h lj_trace.h lj_dispatch.h lj_traceerr.h lj_record.h \ - lj_ffrecord.h lj_snap.h lj_vm.h -lj_snap.o: lj_snap.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ - lj_tab.h lj_state.h lj_frame.h lj_bc.h lj_ir.h lj_jit.h lj_iropt.h \ - lj_trace.h lj_dispatch.h lj_traceerr.h lj_snap.h lj_target.h \ - lj_target_*.h lj_ctype.h lj_cdata.h -lj_state.o: lj_state.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_meta.h \ - lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_trace.h lj_jit.h lj_ir.h \ - lj_dispatch.h lj_traceerr.h lj_vm.h lj_lex.h lj_alloc.h -lj_str.o: lj_str.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ - lj_err.h lj_errmsg.h lj_str.h lj_state.h lj_char.h -lj_strscan.o: lj_strscan.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_char.h lj_strscan.h -lj_tab.o: lj_tab.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ - lj_err.h lj_errmsg.h lj_tab.h -lj_trace.o: lj_trace.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_frame.h lj_bc.h \ - lj_state.h lj_ir.h lj_jit.h lj_iropt.h lj_mcode.h lj_trace.h \ - lj_dispatch.h lj_traceerr.h lj_snap.h lj_gdbjit.h lj_record.h lj_asm.h \ - lj_vm.h lj_vmevent.h lj_target.h lj_target_*.h -lj_udata.o: lj_udata.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_gc.h lj_udata.h -lj_vmevent.o: lj_vmevent.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_str.h lj_tab.h lj_state.h lj_dispatch.h lj_bc.h lj_jit.h lj_ir.h \ - lj_vm.h lj_vmevent.h -lj_vmmath.o: lj_vmmath.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_ir.h lj_vm.h -ljamalg.o: ljamalg.c lua.h luaconf.h lauxlib.h lj_gc.c lj_obj.h lj_def.h \ - lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h \ - lj_udata.h lj_meta.h lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_cdata.h \ - lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h lj_err.c \ - lj_debug.h lj_ff.h lj_ffdef.h lj_char.c lj_char.h lj_bc.c lj_bcdef.h \ - lj_obj.c lj_str.c lj_tab.c lj_func.c lj_udata.c lj_meta.c lj_strscan.h \ - lj_debug.c lj_state.c lj_lex.h lj_alloc.h lj_dispatch.c lj_ccallback.h \ - luajit.h lj_vmevent.c lj_vmevent.h lj_vmmath.c lj_strscan.c lj_api.c \ - lj_lex.c lualib.h lj_parse.h lj_parse.c lj_bcread.c lj_bcdump.h \ - lj_bcwrite.c lj_load.c lj_ctype.c lj_cdata.c lj_cconv.h lj_cconv.c \ - lj_ccall.c lj_ccall.h lj_ccallback.c lj_target.h lj_target_*.h \ - lj_mcode.h lj_carith.c lj_carith.h lj_clib.c lj_clib.h lj_cparse.c \ - lj_cparse.h lj_lib.c lj_lib.h lj_ir.c lj_ircall.h lj_iropt.h \ - lj_opt_mem.c lj_opt_fold.c lj_folddef.h lj_opt_narrow.c lj_opt_dce.c \ - lj_opt_loop.c lj_snap.h lj_opt_split.c lj_opt_sink.c lj_mcode.c \ - lj_snap.c lj_record.c lj_record.h lj_ffrecord.h lj_crecord.c \ - lj_crecord.h lj_ffrecord.c lj_recdef.h lj_asm.c lj_asm.h lj_emit_*.h \ - lj_asm_*.h lj_trace.c lj_gdbjit.h lj_gdbjit.c lj_alloc.c lib_aux.c \ - lib_base.c lj_libdef.h lib_math.c lib_string.c lib_table.c lib_io.c \ - lib_os.c lib_package.c lib_debug.c lib_bit.c lib_jit.c lib_ffi.c \ - lib_init.c -luajit.o: luajit.c lua.h luaconf.h lauxlib.h lualib.h luajit.h lj_arch.h -host/buildvm.o: host/buildvm.c host/buildvm.h lj_def.h lua.h luaconf.h \ - lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_gc.h lj_obj.h lj_bc.h lj_ir.h \ - lj_ircall.h lj_ir.h lj_jit.h lj_frame.h lj_bc.h lj_dispatch.h lj_ctype.h \ - lj_gc.h lj_ccall.h lj_ctype.h luajit.h \ - host/buildvm_arch.h lj_traceerr.h -host/buildvm_asm.o: host/buildvm_asm.c host/buildvm.h lj_def.h lua.h luaconf.h \ - lj_arch.h lj_bc.h lj_def.h lj_arch.h -host/buildvm_fold.o: host/buildvm_fold.c host/buildvm.h lj_def.h lua.h \ - luaconf.h lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_ir.h lj_obj.h -host/buildvm_lib.o: host/buildvm_lib.c host/buildvm.h lj_def.h lua.h luaconf.h \ - lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_lib.h lj_obj.h -host/buildvm_peobj.o: host/buildvm_peobj.c host/buildvm.h lj_def.h lua.h \ - luaconf.h lj_arch.h lj_bc.h lj_def.h lj_arch.h -host/minilua.o: host/minilua.c diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm.c b/source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm.c deleted file mode 100644 index 95d89e9b0..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm.c +++ /dev/null @@ -1,516 +0,0 @@ -/* -** LuaJIT VM builder. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** This is a tool to build the hand-tuned assembler code required for -** LuaJIT's bytecode interpreter. It supports a variety of output formats -** to feed different toolchains (see usage() below). -** -** This tool is not particularly optimized because it's only used while -** _building_ LuaJIT. There's no point in distributing or installing it. -** Only the object code generated by this tool is linked into LuaJIT. -** -** Caveat: some memory is not free'd, error handling is lazy. -** It's a one-shot tool -- any effort fixing this would be wasted. -*/ - -#include "buildvm.h" -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_bc.h" -#include "lj_ir.h" -#include "lj_ircall.h" -#include "lj_frame.h" -#include "lj_dispatch.h" -#if LJ_HASFFI -#include "lj_ctype.h" -#include "lj_ccall.h" -#endif -#include "luajit.h" - -#if defined(_WIN32) -#include -#include -#endif - -/* ------------------------------------------------------------------------ */ - -/* DynASM glue definitions. */ -#define Dst ctx -#define Dst_DECL BuildCtx *ctx -#define Dst_REF (ctx->D) -#define DASM_CHECKS 1 - -#include "../dynasm/dasm_proto.h" - -/* Glue macros for DynASM. */ -static int collect_reloc(BuildCtx *ctx, uint8_t *addr, int idx, int type); - -#define DASM_EXTERN(ctx, addr, idx, type) \ - collect_reloc(ctx, addr, idx, type) - -/* ------------------------------------------------------------------------ */ - -/* Avoid trouble if cross-compiling for an x86 target. Speed doesn't matter. */ -#define DASM_ALIGNED_WRITES 1 - -/* Embed architecture-specific DynASM encoder. */ -#if LJ_TARGET_X86ORX64 -#include "../dynasm/dasm_x86.h" -#elif LJ_TARGET_ARM -#include "../dynasm/dasm_arm.h" -#elif LJ_TARGET_PPC -#include "../dynasm/dasm_ppc.h" -#elif LJ_TARGET_PPCSPE -#include "../dynasm/dasm_ppc.h" -#elif LJ_TARGET_MIPS -#include "../dynasm/dasm_mips.h" -#else -#error "No support for this architecture (yet)" -#endif - -/* Embed generated architecture-specific backend. */ -#include "buildvm_arch.h" - -/* ------------------------------------------------------------------------ */ - -void owrite(BuildCtx *ctx, const void *ptr, size_t sz) -{ - if (fwrite(ptr, 1, sz, ctx->fp) != sz) { - fprintf(stderr, "Error: cannot write to output file: %s\n", - strerror(errno)); - exit(1); - } -} - -/* ------------------------------------------------------------------------ */ - -/* Emit code as raw bytes. Only used for DynASM debugging. */ -static void emit_raw(BuildCtx *ctx) -{ - owrite(ctx, ctx->code, ctx->codesz); -} - -/* -- Build machine code -------------------------------------------------- */ - -static const char *sym_decorate(BuildCtx *ctx, - const char *prefix, const char *suffix) -{ - char name[256]; - char *p; -#if LJ_64 - const char *symprefix = ctx->mode == BUILD_machasm ? "_" : ""; -#elif LJ_TARGET_XBOX360 - const char *symprefix = ""; -#else - const char *symprefix = ctx->mode != BUILD_elfasm ? "_" : ""; -#endif - sprintf(name, "%s%s%s", symprefix, prefix, suffix); - p = strchr(name, '@'); - if (p) { -#if LJ_TARGET_X86ORX64 - if (!LJ_64 && (ctx->mode == BUILD_coffasm || ctx->mode == BUILD_peobj)) - name[0] = '@'; - else - *p = '\0'; -#elif ((LJ_TARGET_PPC && !LJ_TARGET_OSX) || LJ_TARGET_PPCSPE) && !LJ_TARGET_CONSOLE - /* Keep @plt. */ -#else - *p = '\0'; -#endif - } - p = (char *)malloc(strlen(name)+1); /* MSVC doesn't like strdup. */ - strcpy(p, name); - return p; -} - -#define NRELOCSYM (sizeof(extnames)/sizeof(extnames[0])-1) - -static int relocmap[NRELOCSYM]; - -/* Collect external relocations. */ -static int collect_reloc(BuildCtx *ctx, uint8_t *addr, int idx, int type) -{ - if (ctx->nreloc >= BUILD_MAX_RELOC) { - fprintf(stderr, "Error: too many relocations, increase BUILD_MAX_RELOC.\n"); - exit(1); - } - if (relocmap[idx] < 0) { - relocmap[idx] = ctx->nrelocsym; - ctx->relocsym[ctx->nrelocsym] = sym_decorate(ctx, "", extnames[idx]); - ctx->nrelocsym++; - } - ctx->reloc[ctx->nreloc].ofs = (int32_t)(addr - ctx->code); - ctx->reloc[ctx->nreloc].sym = relocmap[idx]; - ctx->reloc[ctx->nreloc].type = type; - ctx->nreloc++; -#if LJ_TARGET_XBOX360 - return (int)(ctx->code - addr) + 4; /* Encode symbol offset of .text. */ -#else - return 0; /* Encode symbol offset of 0. */ -#endif -} - -/* Naive insertion sort. Performance doesn't matter here. */ -static void sym_insert(BuildCtx *ctx, int32_t ofs, - const char *prefix, const char *suffix) -{ - ptrdiff_t i = ctx->nsym++; - while (i > 0) { - if (ctx->sym[i-1].ofs <= ofs) - break; - ctx->sym[i] = ctx->sym[i-1]; - i--; - } - ctx->sym[i].ofs = ofs; - ctx->sym[i].name = sym_decorate(ctx, prefix, suffix); -} - -/* Build the machine code. */ -static int build_code(BuildCtx *ctx) -{ - int status; - int i; - - /* Initialize DynASM structures. */ - ctx->nglob = GLOB__MAX; - ctx->glob = (void **)malloc(ctx->nglob*sizeof(void *)); - memset(ctx->glob, 0, ctx->nglob*sizeof(void *)); - ctx->nreloc = 0; - - ctx->globnames = globnames; - ctx->relocsym = (const char **)malloc(NRELOCSYM*sizeof(const char *)); - ctx->nrelocsym = 0; - for (i = 0; i < (int)NRELOCSYM; i++) relocmap[i] = -1; - - ctx->dasm_ident = DASM_IDENT; - ctx->dasm_arch = DASM_ARCH; - - dasm_init(Dst, DASM_MAXSECTION); - dasm_setupglobal(Dst, ctx->glob, ctx->nglob); - dasm_setup(Dst, build_actionlist); - - /* Call arch-specific backend to emit the code. */ - ctx->npc = build_backend(ctx); - - /* Finalize the code. */ - (void)dasm_checkstep(Dst, -1); - if ((status = dasm_link(Dst, &ctx->codesz))) return status; - ctx->code = (uint8_t *)malloc(ctx->codesz); - if ((status = dasm_encode(Dst, (void *)ctx->code))) return status; - - /* Allocate symbol table and bytecode offsets. */ - ctx->beginsym = sym_decorate(ctx, "", LABEL_PREFIX "vm_asm_begin"); - ctx->sym = (BuildSym *)malloc((ctx->npc+ctx->nglob+1)*sizeof(BuildSym)); - ctx->nsym = 0; - ctx->bc_ofs = (int32_t *)malloc(ctx->npc*sizeof(int32_t)); - - /* Collect the opcodes (PC labels). */ - for (i = 0; i < ctx->npc; i++) { - int32_t ofs = dasm_getpclabel(Dst, i); - if (ofs < 0) return 0x22000000|i; - ctx->bc_ofs[i] = ofs; - if ((LJ_HASJIT || - !(i == BC_JFORI || i == BC_JFORL || i == BC_JITERL || i == BC_JLOOP || - i == BC_IFORL || i == BC_IITERL || i == BC_ILOOP)) && - (LJ_HASFFI || i != BC_KCDATA)) - sym_insert(ctx, ofs, LABEL_PREFIX_BC, bc_names[i]); - } - - /* Collect the globals (named labels). */ - for (i = 0; i < ctx->nglob; i++) { - const char *gl = globnames[i]; - int len = (int)strlen(gl); - if (!ctx->glob[i]) { - fprintf(stderr, "Error: undefined global %s\n", gl); - exit(2); - } - /* Skip the _Z symbols. */ - if (!(len >= 2 && gl[len-2] == '_' && gl[len-1] == 'Z')) - sym_insert(ctx, (int32_t)((uint8_t *)(ctx->glob[i]) - ctx->code), - LABEL_PREFIX, globnames[i]); - } - - /* Close the address range. */ - sym_insert(ctx, (int32_t)ctx->codesz, "", ""); - ctx->nsym--; - - dasm_free(Dst); - - return 0; -} - -/* -- Generate VM enums --------------------------------------------------- */ - -const char *const bc_names[] = { -#define BCNAME(name, ma, mb, mc, mt) #name, -BCDEF(BCNAME) -#undef BCNAME - NULL -}; - -const char *const ir_names[] = { -#define IRNAME(name, m, m1, m2) #name, -IRDEF(IRNAME) -#undef IRNAME - NULL -}; - -const char *const irt_names[] = { -#define IRTNAME(name, size) #name, -IRTDEF(IRTNAME) -#undef IRTNAME - NULL -}; - -const char *const irfpm_names[] = { -#define FPMNAME(name) #name, -IRFPMDEF(FPMNAME) -#undef FPMNAME - NULL -}; - -const char *const irfield_names[] = { -#define FLNAME(name, ofs) #name, -IRFLDEF(FLNAME) -#undef FLNAME - NULL -}; - -const char *const ircall_names[] = { -#define IRCALLNAME(cond, name, nargs, kind, type, flags) #name, -IRCALLDEF(IRCALLNAME) -#undef IRCALLNAME - NULL -}; - -static const char *const trace_errors[] = { -#define TREDEF(name, msg) msg, -#include "lj_traceerr.h" - NULL -}; - -static const char *lower(char *buf, const char *s) -{ - char *p = buf; - while (*s) { - *p++ = (*s >= 'A' && *s <= 'Z') ? *s+0x20 : *s; - s++; - } - *p = '\0'; - return buf; -} - -/* Emit C source code for bytecode-related definitions. */ -static void emit_bcdef(BuildCtx *ctx) -{ - int i; - fprintf(ctx->fp, "/* This is a generated file. DO NOT EDIT! */\n\n"); - fprintf(ctx->fp, "LJ_DATADEF const uint16_t lj_bc_ofs[] = {\n"); - for (i = 0; i < ctx->npc; i++) { - if (i != 0) - fprintf(ctx->fp, ",\n"); - fprintf(ctx->fp, "%d", ctx->bc_ofs[i]); - } -} - -/* Emit VM definitions as Lua code for debug modules. */ -static void emit_vmdef(BuildCtx *ctx) -{ - char buf[80]; - int i; - fprintf(ctx->fp, "-- This is a generated file. DO NOT EDIT!\n\n"); - fprintf(ctx->fp, "module(...)\n\n"); - - fprintf(ctx->fp, "bcnames = \""); - for (i = 0; bc_names[i]; i++) fprintf(ctx->fp, "%-6s", bc_names[i]); - fprintf(ctx->fp, "\"\n\n"); - - fprintf(ctx->fp, "irnames = \""); - for (i = 0; ir_names[i]; i++) fprintf(ctx->fp, "%-6s", ir_names[i]); - fprintf(ctx->fp, "\"\n\n"); - - fprintf(ctx->fp, "irfpm = { [0]="); - for (i = 0; irfpm_names[i]; i++) - fprintf(ctx->fp, "\"%s\", ", lower(buf, irfpm_names[i])); - fprintf(ctx->fp, "}\n\n"); - - fprintf(ctx->fp, "irfield = { [0]="); - for (i = 0; irfield_names[i]; i++) { - char *p; - lower(buf, irfield_names[i]); - p = strchr(buf, '_'); - if (p) *p = '.'; - fprintf(ctx->fp, "\"%s\", ", buf); - } - fprintf(ctx->fp, "}\n\n"); - - fprintf(ctx->fp, "ircall = {\n[0]="); - for (i = 0; ircall_names[i]; i++) - fprintf(ctx->fp, "\"%s\",\n", ircall_names[i]); - fprintf(ctx->fp, "}\n\n"); - - fprintf(ctx->fp, "traceerr = {\n[0]="); - for (i = 0; trace_errors[i]; i++) - fprintf(ctx->fp, "\"%s\",\n", trace_errors[i]); - fprintf(ctx->fp, "}\n\n"); -} - -/* -- Argument parsing ---------------------------------------------------- */ - -/* Build mode names. */ -static const char *const modenames[] = { -#define BUILDNAME(name) #name, -BUILDDEF(BUILDNAME) -#undef BUILDNAME - NULL -}; - -/* Print usage information and exit. */ -static void usage(void) -{ - int i; - fprintf(stderr, LUAJIT_VERSION " VM builder.\n"); - fprintf(stderr, LUAJIT_COPYRIGHT ", " LUAJIT_URL "\n"); - fprintf(stderr, "Target architecture: " LJ_ARCH_NAME "\n\n"); - fprintf(stderr, "Usage: buildvm -m mode [-o outfile] [infiles...]\n\n"); - fprintf(stderr, "Available modes:\n"); - for (i = 0; i < BUILD__MAX; i++) - fprintf(stderr, " %s\n", modenames[i]); - exit(1); -} - -/* Parse the output mode name. */ -static BuildMode parsemode(const char *mode) -{ - int i; - for (i = 0; modenames[i]; i++) - if (!strcmp(mode, modenames[i])) - return (BuildMode)i; - usage(); - return (BuildMode)-1; -} - -/* Parse arguments. */ -static void parseargs(BuildCtx *ctx, char **argv) -{ - const char *a; - int i; - ctx->mode = (BuildMode)-1; - ctx->outname = "-"; - for (i = 1; (a = argv[i]) != NULL; i++) { - if (a[0] != '-') - break; - switch (a[1]) { - case '-': - if (a[2]) goto err; - i++; - goto ok; - case '\0': - goto ok; - case 'm': - i++; - if (a[2] || argv[i] == NULL) goto err; - ctx->mode = parsemode(argv[i]); - break; - case 'o': - i++; - if (a[2] || argv[i] == NULL) goto err; - ctx->outname = argv[i]; - break; - default: err: - usage(); - break; - } - } -ok: - ctx->args = argv+i; - if (ctx->mode == (BuildMode)-1) goto err; -} - -int main(int argc, char **argv) -{ - BuildCtx ctx_; - BuildCtx *ctx = &ctx_; - int status, binmode; - - if (sizeof(void *) != 4*LJ_32+8*LJ_64) { - fprintf(stderr,"Error: pointer size mismatch in cross-build.\n"); - fprintf(stderr,"Try: make HOST_CC=\"gcc -m32\" CROSS=...\n\n"); - return 1; - } - - UNUSED(argc); - parseargs(ctx, argv); - - if ((status = build_code(ctx))) { - fprintf(stderr,"Error: DASM error %08x\n", status); - return 1; - } - - switch (ctx->mode) { - case BUILD_peobj: - case BUILD_raw: - binmode = 1; - break; - default: - binmode = 0; - break; - } - - if (ctx->outname[0] == '-' && ctx->outname[1] == '\0') { - ctx->fp = stdout; -#if defined(_WIN32) - if (binmode) - _setmode(_fileno(stdout), _O_BINARY); /* Yuck. */ -#endif - } else if (!(ctx->fp = fopen(ctx->outname, binmode ? "wb" : "w"))) { - fprintf(stderr, "Error: cannot open output file '%s': %s\n", - ctx->outname, strerror(errno)); - exit(1); - } - - switch (ctx->mode) { - case BUILD_elfasm: - case BUILD_coffasm: - case BUILD_machasm: - emit_asm(ctx); - emit_asm_debug(ctx); - break; - case BUILD_peobj: - emit_peobj(ctx); - break; - case BUILD_raw: - emit_raw(ctx); - break; - case BUILD_bcdef: - emit_bcdef(ctx); - emit_lib(ctx); - break; - case BUILD_vmdef: - emit_vmdef(ctx); - emit_lib(ctx); - break; - case BUILD_ffdef: - case BUILD_libdef: - case BUILD_recdef: - emit_lib(ctx); - break; - case BUILD_folddef: - emit_fold(ctx); - break; - default: - break; - } - - fflush(ctx->fp); - if (ferror(ctx->fp)) { - fprintf(stderr, "Error: cannot write to output file: %s\n", - strerror(errno)); - exit(1); - } - fclose(ctx->fp); - - return 0; -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm.h b/source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm.h deleted file mode 100644 index f9dc8c4f2..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm.h +++ /dev/null @@ -1,104 +0,0 @@ -/* -** LuaJIT VM builder. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _BUILDVM_H -#define _BUILDVM_H - -#include -#include -#include -#include -#include - -#include "lj_def.h" -#include "lj_arch.h" - -/* Hardcoded limits. Increase as needed. */ -#define BUILD_MAX_RELOC 200 /* Max. number of relocations. */ -#define BUILD_MAX_FOLD 4096 /* Max. number of fold rules. */ - -/* Prefix for scanned library definitions. */ -#define LIBDEF_PREFIX "LJLIB_" - -/* Prefix for scanned fold definitions. */ -#define FOLDDEF_PREFIX "LJFOLD" - -/* Prefixes for generated labels. */ -#define LABEL_PREFIX "lj_" -#define LABEL_PREFIX_BC LABEL_PREFIX "BC_" -#define LABEL_PREFIX_FF LABEL_PREFIX "ff_" -#define LABEL_PREFIX_CF LABEL_PREFIX "cf_" -#define LABEL_PREFIX_FFH LABEL_PREFIX "ffh_" -#define LABEL_PREFIX_LIBCF LABEL_PREFIX "lib_cf_" -#define LABEL_PREFIX_LIBINIT LABEL_PREFIX "lib_init_" - -/* Forward declaration. */ -struct dasm_State; - -/* Build modes. */ -#define BUILDDEF(_) \ - _(elfasm) _(coffasm) _(machasm) _(peobj) _(raw) \ - _(bcdef) _(ffdef) _(libdef) _(recdef) _(vmdef) \ - _(folddef) - -typedef enum { -#define BUILDENUM(name) BUILD_##name, -BUILDDEF(BUILDENUM) -#undef BUILDENUM - BUILD__MAX -} BuildMode; - -/* Code relocation. */ -typedef struct BuildReloc { - int32_t ofs; - int sym; - int type; -} BuildReloc; - -typedef struct BuildSym { - const char *name; - int32_t ofs; -} BuildSym; - -/* Build context structure. */ -typedef struct BuildCtx { - /* DynASM state pointer. Should be first member. */ - struct dasm_State *D; - /* Parsed command line. */ - BuildMode mode; - FILE *fp; - const char *outname; - char **args; - /* Code and symbols generated by DynASM. */ - uint8_t *code; - size_t codesz; - int npc, nglob, nsym, nreloc, nrelocsym; - void **glob; - BuildSym *sym; - const char **relocsym; - int32_t *bc_ofs; - const char *beginsym; - /* Strings generated by DynASM. */ - const char *const *globnames; - const char *dasm_ident; - const char *dasm_arch; - /* Relocations. */ - BuildReloc reloc[BUILD_MAX_RELOC]; -} BuildCtx; - -extern void owrite(BuildCtx *ctx, const void *ptr, size_t sz); -extern void emit_asm(BuildCtx *ctx); -extern void emit_peobj(BuildCtx *ctx); -extern void emit_lib(BuildCtx *ctx); -extern void emit_fold(BuildCtx *ctx); - -extern const char *const bc_names[]; -extern const char *const ir_names[]; -extern const char *const irt_names[]; -extern const char *const irfpm_names[]; -extern const char *const irfield_names[]; -extern const char *const ircall_names[]; - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm_asm.c b/source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm_asm.c deleted file mode 100644 index 9b28b3b38..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm_asm.c +++ /dev/null @@ -1,313 +0,0 @@ -/* -** LuaJIT VM builder: Assembler source code emitter. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#include "buildvm.h" -#include "lj_bc.h" - -/* ------------------------------------------------------------------------ */ - -#if LJ_TARGET_X86ORX64 -/* Emit bytes piecewise as assembler text. */ -static void emit_asm_bytes(BuildCtx *ctx, uint8_t *p, int n) -{ - int i; - for (i = 0; i < n; i++) { - if ((i & 15) == 0) - fprintf(ctx->fp, "\t.byte %d", p[i]); - else - fprintf(ctx->fp, ",%d", p[i]); - if ((i & 15) == 15) putc('\n', ctx->fp); - } - if ((n & 15) != 0) putc('\n', ctx->fp); -} - -/* Emit relocation */ -static void emit_asm_reloc(BuildCtx *ctx, int type, const char *sym) -{ - switch (ctx->mode) { - case BUILD_elfasm: - if (type) - fprintf(ctx->fp, "\t.long %s-.-4\n", sym); - else - fprintf(ctx->fp, "\t.long %s\n", sym); - break; - case BUILD_coffasm: - fprintf(ctx->fp, "\t.def %s; .scl 3; .type 32; .endef\n", sym); - if (type) - fprintf(ctx->fp, "\t.long %s-.-4\n", sym); - else - fprintf(ctx->fp, "\t.long %s\n", sym); - break; - default: /* BUILD_machasm for relative relocations handled below. */ - fprintf(ctx->fp, "\t.long %s\n", sym); - break; - } -} - -static const char *const jccnames[] = { - "jo", "jno", "jb", "jnb", "jz", "jnz", "jbe", "ja", - "js", "jns", "jpe", "jpo", "jl", "jge", "jle", "jg" -}; - -/* Emit relocation for the incredibly stupid OSX assembler. */ -static void emit_asm_reloc_mach(BuildCtx *ctx, uint8_t *cp, int n, - const char *sym) -{ - const char *opname = NULL; - if (--n < 0) goto err; - if (cp[n] == 0xe8) { - opname = "call"; - } else if (cp[n] == 0xe9) { - opname = "jmp"; - } else if (cp[n] >= 0x80 && cp[n] <= 0x8f && n > 0 && cp[n-1] == 0x0f) { - opname = jccnames[cp[n]-0x80]; - n--; - } else { -err: - fprintf(stderr, "Error: unsupported opcode for %s symbol relocation.\n", - sym); - exit(1); - } - emit_asm_bytes(ctx, cp, n); - fprintf(ctx->fp, "\t%s %s\n", opname, sym); -} -#else -/* Emit words piecewise as assembler text. */ -static void emit_asm_words(BuildCtx *ctx, uint8_t *p, int n) -{ - int i; - for (i = 0; i < n; i += 4) { - if ((i & 15) == 0) - fprintf(ctx->fp, "\t.long 0x%08x", *(uint32_t *)(p+i)); - else - fprintf(ctx->fp, ",0x%08x", *(uint32_t *)(p+i)); - if ((i & 15) == 12) putc('\n', ctx->fp); - } - if ((n & 15) != 0) putc('\n', ctx->fp); -} - -/* Emit relocation as part of an instruction. */ -static void emit_asm_wordreloc(BuildCtx *ctx, uint8_t *p, int n, - const char *sym) -{ - uint32_t ins; - emit_asm_words(ctx, p, n-4); - ins = *(uint32_t *)(p+n-4); -#if LJ_TARGET_ARM - if ((ins & 0xff000000u) == 0xfa000000u) { - fprintf(ctx->fp, "\tblx %s\n", sym); - } else if ((ins & 0x0e000000u) == 0x0a000000u) { - fprintf(ctx->fp, "\t%s%.2s %s\n", (ins & 0x01000000u) ? "bl" : "b", - &"eqnecsccmiplvsvchilsgeltgtle"[2*(ins >> 28)], sym); - } else { - fprintf(stderr, - "Error: unsupported opcode %08x for %s symbol relocation.\n", - ins, sym); - exit(1); - } -#elif LJ_TARGET_PPC || LJ_TARGET_PPCSPE -#if LJ_TARGET_PS3 -#define TOCPREFIX "." -#else -#define TOCPREFIX "" -#endif - if ((ins >> 26) == 16) { - fprintf(ctx->fp, "\t%s %d, %d, " TOCPREFIX "%s\n", - (ins & 1) ? "bcl" : "bc", (ins >> 21) & 31, (ins >> 16) & 31, sym); - } else if ((ins >> 26) == 18) { - fprintf(ctx->fp, "\t%s " TOCPREFIX "%s\n", (ins & 1) ? "bl" : "b", sym); - } else { - fprintf(stderr, - "Error: unsupported opcode %08x for %s symbol relocation.\n", - ins, sym); - exit(1); - } -#elif LJ_TARGET_MIPS - fprintf(stderr, - "Error: unsupported opcode %08x for %s symbol relocation.\n", - ins, sym); - exit(1); -#else -#error "missing relocation support for this architecture" -#endif -} -#endif - -#if LJ_TARGET_ARM -#define ELFASM_PX "%%" -#else -#define ELFASM_PX "@" -#endif - -/* Emit an assembler label. */ -static void emit_asm_label(BuildCtx *ctx, const char *name, int size, int isfunc) -{ - switch (ctx->mode) { - case BUILD_elfasm: -#if LJ_TARGET_PS3 - if (!strncmp(name, "lj_vm_", 6) && - strcmp(name, ctx->beginsym) && - !strstr(name, "hook")) { - fprintf(ctx->fp, - "\n\t.globl %s\n" - "\t.section \".opd\",\"aw\"\n" - "%s:\n" - "\t.long .%s,.TOC.@tocbase32\n" - "\t.size %s,8\n" - "\t.previous\n" - "\t.globl .%s\n" - "\t.hidden .%s\n" - "\t.type .%s, " ELFASM_PX "function\n" - "\t.size .%s, %d\n" - ".%s:\n", - name, name, name, name, name, name, name, name, size, name); - break; - } -#endif - fprintf(ctx->fp, - "\n\t.globl %s\n" - "\t.hidden %s\n" - "\t.type %s, " ELFASM_PX "%s\n" - "\t.size %s, %d\n" - "%s:\n", - name, name, name, isfunc ? "function" : "object", name, size, name); - break; - case BUILD_coffasm: - fprintf(ctx->fp, "\n\t.globl %s\n", name); - if (isfunc) - fprintf(ctx->fp, "\t.def %s; .scl 3; .type 32; .endef\n", name); - fprintf(ctx->fp, "%s:\n", name); - break; - case BUILD_machasm: - fprintf(ctx->fp, - "\n\t.private_extern %s\n" - "%s:\n", name, name); - break; - default: - break; - } -} - -/* Emit alignment. */ -static void emit_asm_align(BuildCtx *ctx, int bits) -{ - switch (ctx->mode) { - case BUILD_elfasm: - case BUILD_coffasm: - fprintf(ctx->fp, "\t.p2align %d\n", bits); - break; - case BUILD_machasm: - fprintf(ctx->fp, "\t.align %d\n", bits); - break; - default: - break; - } -} - -/* ------------------------------------------------------------------------ */ - -/* Emit assembler source code. */ -void emit_asm(BuildCtx *ctx) -{ - int i, rel; - - fprintf(ctx->fp, "\t.file \"buildvm_%s.dasc\"\n", ctx->dasm_arch); - fprintf(ctx->fp, "\t.text\n"); - emit_asm_align(ctx, 4); - -#if LJ_TARGET_PS3 - emit_asm_label(ctx, ctx->beginsym, ctx->codesz, 0); -#else - emit_asm_label(ctx, ctx->beginsym, 0, 0); -#endif - if (ctx->mode != BUILD_machasm) - fprintf(ctx->fp, ".Lbegin:\n"); - -#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND - /* This should really be moved into buildvm_arm.dasc. */ - fprintf(ctx->fp, - ".fnstart\n" - ".save {r4, r5, r6, r7, r8, r9, r10, r11, lr}\n" - ".pad #28\n"); -#endif -#if LJ_TARGET_MIPS - fprintf(ctx->fp, ".set nomips16\n.abicalls\n.set noreorder\n.set nomacro\n"); -#endif - - for (i = rel = 0; i < ctx->nsym; i++) { - int32_t ofs = ctx->sym[i].ofs; - int32_t next = ctx->sym[i+1].ofs; -#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND && LJ_HASFFI - if (!strcmp(ctx->sym[i].name, "lj_vm_ffi_call")) - fprintf(ctx->fp, - ".globl lj_err_unwind_arm\n" - ".personality lj_err_unwind_arm\n" - ".fnend\n" - ".fnstart\n" - ".save {r4, r5, r11, lr}\n" - ".setfp r11, sp\n"); -#endif - emit_asm_label(ctx, ctx->sym[i].name, next - ofs, 1); - while (rel < ctx->nreloc && ctx->reloc[rel].ofs <= next) { - BuildReloc *r = &ctx->reloc[rel]; - int n = r->ofs - ofs; -#if LJ_TARGET_X86ORX64 - if (ctx->mode == BUILD_machasm && r->type != 0) { - emit_asm_reloc_mach(ctx, ctx->code+ofs, n, ctx->relocsym[r->sym]); - } else { - emit_asm_bytes(ctx, ctx->code+ofs, n); - emit_asm_reloc(ctx, r->type, ctx->relocsym[r->sym]); - } - ofs += n+4; -#else - emit_asm_wordreloc(ctx, ctx->code+ofs, n, ctx->relocsym[r->sym]); - ofs += n; -#endif - rel++; - } -#if LJ_TARGET_X86ORX64 - emit_asm_bytes(ctx, ctx->code+ofs, next-ofs); -#else - emit_asm_words(ctx, ctx->code+ofs, next-ofs); -#endif - } - -#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND - fprintf(ctx->fp, -#if !LJ_HASFFI - ".globl lj_err_unwind_arm\n" - ".personality lj_err_unwind_arm\n" -#endif - ".fnend\n"); -#endif - - fprintf(ctx->fp, "\n"); - switch (ctx->mode) { - case BUILD_elfasm: -#if !LJ_TARGET_PS3 - fprintf(ctx->fp, "\t.section .note.GNU-stack,\"\"," ELFASM_PX "progbits\n"); -#endif -#if LJ_TARGET_PPCSPE - /* Soft-float ABI + SPE. */ - fprintf(ctx->fp, "\t.gnu_attribute 4, 2\n\t.gnu_attribute 8, 3\n"); -#elif LJ_TARGET_PPC && !LJ_TARGET_PS3 - /* Hard-float ABI. */ - fprintf(ctx->fp, "\t.gnu_attribute 4, 1\n"); -#endif - /* fallthrough */ - case BUILD_coffasm: - fprintf(ctx->fp, "\t.ident \"%s\"\n", ctx->dasm_ident); - break; - case BUILD_machasm: - fprintf(ctx->fp, - "\t.cstring\n" - "\t.ascii \"%s\\0\"\n", ctx->dasm_ident); - break; - default: - break; - } - fprintf(ctx->fp, "\n"); -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm_fold.c b/source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm_fold.c deleted file mode 100644 index 7f5d9f2f1..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm_fold.c +++ /dev/null @@ -1,229 +0,0 @@ -/* -** LuaJIT VM builder: IR folding hash table generator. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#include "buildvm.h" -#include "lj_obj.h" -#include "lj_ir.h" - -/* Context for the folding hash table generator. */ -static int lineno; -static int funcidx; -static uint32_t foldkeys[BUILD_MAX_FOLD]; -static uint32_t nkeys; - -/* Try to fill the hash table with keys using the hash parameters. */ -static int tryhash(uint32_t *htab, uint32_t sz, uint32_t r, int dorol) -{ - uint32_t i; - if (dorol && ((r & 31) == 0 || (r>>5) == 0)) - return 0; /* Avoid zero rotates. */ - memset(htab, 0xff, (sz+1)*sizeof(uint32_t)); - for (i = 0; i < nkeys; i++) { - uint32_t key = foldkeys[i]; - uint32_t k = key & 0xffffff; - uint32_t h = (dorol ? lj_rol(lj_rol(k, r>>5) - k, r&31) : - (((k << (r>>5)) - k) << (r&31))) % sz; - if (htab[h] != 0xffffffff) { /* Collision on primary slot. */ - if (htab[h+1] != 0xffffffff) { /* Collision on secondary slot. */ - /* Try to move the colliding key, if possible. */ - if (h < sz-1 && htab[h+2] == 0xffffffff) { - uint32_t k2 = htab[h+1] & 0xffffff; - uint32_t h2 = (dorol ? lj_rol(lj_rol(k2, r>>5) - k2, r&31) : - (((k2 << (r>>5)) - k2) << (r&31))) % sz; - if (h2 != h+1) return 0; /* Cannot resolve collision. */ - htab[h+2] = htab[h+1]; /* Move colliding key to secondary slot. */ - } else { - return 0; /* Collision. */ - } - } - htab[h+1] = key; - } else { - htab[h] = key; - } - } - return 1; /* Success, all keys could be stored. */ -} - -/* Print the generated hash table. */ -static void printhash(BuildCtx *ctx, uint32_t *htab, uint32_t sz) -{ - uint32_t i; - fprintf(ctx->fp, "static const uint32_t fold_hash[%d] = {\n0x%08x", - sz+1, htab[0]); - for (i = 1; i < sz+1; i++) - fprintf(ctx->fp, ",\n0x%08x", htab[i]); - fprintf(ctx->fp, "\n};\n\n"); -} - -/* Exhaustive search for the shortest semi-perfect hash table. */ -static void makehash(BuildCtx *ctx) -{ - uint32_t htab[BUILD_MAX_FOLD*2+1]; - uint32_t sz, r; - /* Search for the smallest hash table with an odd size. */ - for (sz = (nkeys|1); sz < BUILD_MAX_FOLD*2; sz += 2) { - /* First try all shift hash combinations. */ - for (r = 0; r < 32*32; r++) { - if (tryhash(htab, sz, r, 0)) { - printhash(ctx, htab, sz); - fprintf(ctx->fp, - "#define fold_hashkey(k)\t(((((k)<<%u)-(k))<<%u)%%%u)\n\n", - r>>5, r&31, sz); - return; - } - } - /* Then try all rotate hash combinations. */ - for (r = 0; r < 32*32; r++) { - if (tryhash(htab, sz, r, 1)) { - printhash(ctx, htab, sz); - fprintf(ctx->fp, - "#define fold_hashkey(k)\t(lj_rol(lj_rol((k),%u)-(k),%u)%%%u)\n\n", - r>>5, r&31, sz); - return; - } - } - } - fprintf(stderr, "Error: search for perfect hash failed\n"); - exit(1); -} - -/* Parse one token of a fold rule. */ -static uint32_t nexttoken(char **pp, int allowlit, int allowany) -{ - char *p = *pp; - if (p) { - uint32_t i; - char *q = strchr(p, ' '); - if (q) *q++ = '\0'; - *pp = q; - if (allowlit && !strncmp(p, "IRFPM_", 6)) { - for (i = 0; irfpm_names[i]; i++) - if (!strcmp(irfpm_names[i], p+6)) - return i; - } else if (allowlit && !strncmp(p, "IRFL_", 5)) { - for (i = 0; irfield_names[i]; i++) - if (!strcmp(irfield_names[i], p+5)) - return i; - } else if (allowlit && !strncmp(p, "IRCALL_", 7)) { - for (i = 0; ircall_names[i]; i++) - if (!strcmp(ircall_names[i], p+7)) - return i; - } else if (allowlit && !strncmp(p, "IRCONV_", 7)) { - for (i = 0; irt_names[i]; i++) { - const char *r = strchr(p+7, '_'); - if (r && !strncmp(irt_names[i], p+7, r-(p+7))) { - uint32_t j; - for (j = 0; irt_names[j]; j++) - if (!strcmp(irt_names[j], r+1)) - return (i << 5) + j; - } - } - } else if (allowlit && *p >= '0' && *p <= '9') { - for (i = 0; *p >= '0' && *p <= '9'; p++) - i = i*10 + (*p - '0'); - if (*p == '\0') - return i; - } else if (allowany && !strcmp("any", p)) { - return allowany; - } else { - for (i = 0; ir_names[i]; i++) - if (!strcmp(ir_names[i], p)) - return i; - } - fprintf(stderr, "Error: bad fold definition token \"%s\" at line %d\n", p, lineno); - exit(1); - } - return 0; -} - -/* Parse a fold rule. */ -static void foldrule(char *p) -{ - uint32_t op = nexttoken(&p, 0, 0); - uint32_t left = nexttoken(&p, 0, 0x7f); - uint32_t right = nexttoken(&p, 1, 0x3ff); - uint32_t key = (funcidx << 24) | (op << 17) | (left << 10) | right; - uint32_t i; - if (nkeys >= BUILD_MAX_FOLD) { - fprintf(stderr, "Error: too many fold rules, increase BUILD_MAX_FOLD.\n"); - exit(1); - } - /* Simple insertion sort to detect duplicates. */ - for (i = nkeys; i > 0; i--) { - if ((foldkeys[i-1]&0xffffff) < (key & 0xffffff)) - break; - if ((foldkeys[i-1]&0xffffff) == (key & 0xffffff)) { - fprintf(stderr, "Error: duplicate fold definition at line %d\n", lineno); - exit(1); - } - foldkeys[i] = foldkeys[i-1]; - } - foldkeys[i] = key; - nkeys++; -} - -/* Emit C source code for IR folding hash table. */ -void emit_fold(BuildCtx *ctx) -{ - char buf[256]; /* We don't care about analyzing lines longer than that. */ - const char *fname = ctx->args[0]; - FILE *fp; - - if (fname == NULL) { - fprintf(stderr, "Error: missing input filename\n"); - exit(1); - } - - if (fname[0] == '-' && fname[1] == '\0') { - fp = stdin; - } else { - fp = fopen(fname, "r"); - if (!fp) { - fprintf(stderr, "Error: cannot open input file '%s': %s\n", - fname, strerror(errno)); - exit(1); - } - } - - fprintf(ctx->fp, "/* This is a generated file. DO NOT EDIT! */\n\n"); - fprintf(ctx->fp, "static const FoldFunc fold_func[] = {\n"); - - lineno = 0; - funcidx = 0; - nkeys = 0; - while (fgets(buf, sizeof(buf), fp) != NULL) { - lineno++; - /* The prefix must be at the start of a line, otherwise it's ignored. */ - if (!strncmp(buf, FOLDDEF_PREFIX, sizeof(FOLDDEF_PREFIX)-1)) { - char *p = buf+sizeof(FOLDDEF_PREFIX)-1; - char *q = strchr(p, ')'); - if (p[0] == '(' && q) { - p++; - *q = '\0'; - foldrule(p); - } else if ((p[0] == 'F' || p[0] == 'X') && p[1] == '(' && q) { - p += 2; - *q = '\0'; - if (funcidx) - fprintf(ctx->fp, ",\n"); - if (p[-2] == 'X') - fprintf(ctx->fp, " %s", p); - else - fprintf(ctx->fp, " fold_%s", p); - funcidx++; - } else { - buf[strlen(buf)-1] = '\0'; - fprintf(stderr, "Error: unknown fold definition tag %s%s at line %d\n", - FOLDDEF_PREFIX, p, lineno); - exit(1); - } - } - } - fclose(fp); - fprintf(ctx->fp, "\n};\n\n"); - - makehash(ctx); -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm_lib.c b/source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm_lib.c deleted file mode 100644 index eafdab981..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm_lib.c +++ /dev/null @@ -1,398 +0,0 @@ -/* -** LuaJIT VM builder: library definition compiler. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#include "buildvm.h" -#include "lj_obj.h" -#include "lj_lib.h" - -/* Context for library definitions. */ -static uint8_t obuf[8192]; -static uint8_t *optr; -static char modname[80]; -static size_t modnamelen; -static char funcname[80]; -static int modstate, regfunc; -static int ffid, recffid, ffasmfunc; - -enum { - REGFUNC_OK, - REGFUNC_NOREG, - REGFUNC_NOREGUV -}; - -static void libdef_name(const char *p, int kind) -{ - size_t n = strlen(p); - if (kind != LIBINIT_STRING) { - if (n > modnamelen && p[modnamelen] == '_' && - !strncmp(p, modname, modnamelen)) { - p += modnamelen+1; - n -= modnamelen+1; - } - } - if (n > LIBINIT_MAXSTR) { - fprintf(stderr, "Error: string too long: '%s'\n", p); - exit(1); - } - if (optr+1+n+2 > obuf+sizeof(obuf)) { /* +2 for caller. */ - fprintf(stderr, "Error: output buffer overflow\n"); - exit(1); - } - *optr++ = (uint8_t)(n | kind); - memcpy(optr, p, n); - optr += n; -} - -static void libdef_endmodule(BuildCtx *ctx) -{ - if (modstate != 0) { - char line[80]; - const uint8_t *p; - int n; - if (modstate == 1) - fprintf(ctx->fp, " (lua_CFunction)0"); - fprintf(ctx->fp, "\n};\n"); - fprintf(ctx->fp, "static const uint8_t %s%s[] = {\n", - LABEL_PREFIX_LIBINIT, modname); - line[0] = '\0'; - for (n = 0, p = obuf; p < optr; p++) { - n += sprintf(line+n, "%d,", *p); - if (n >= 75) { - fprintf(ctx->fp, "%s\n", line); - n = 0; - line[0] = '\0'; - } - } - fprintf(ctx->fp, "%s%d\n};\n#endif\n\n", line, LIBINIT_END); - } -} - -static void libdef_module(BuildCtx *ctx, char *p, int arg) -{ - UNUSED(arg); - if (ctx->mode == BUILD_libdef) { - libdef_endmodule(ctx); - optr = obuf; - *optr++ = (uint8_t)ffid; - *optr++ = (uint8_t)ffasmfunc; - *optr++ = 0; /* Hash table size. */ - modstate = 1; - fprintf(ctx->fp, "#ifdef %sMODULE_%s\n", LIBDEF_PREFIX, p); - fprintf(ctx->fp, "#undef %sMODULE_%s\n", LIBDEF_PREFIX, p); - fprintf(ctx->fp, "static const lua_CFunction %s%s[] = {\n", - LABEL_PREFIX_LIBCF, p); - } - modnamelen = strlen(p); - if (modnamelen > sizeof(modname)-1) { - fprintf(stderr, "Error: module name too long: '%s'\n", p); - exit(1); - } - strcpy(modname, p); -} - -static int find_ffofs(BuildCtx *ctx, const char *name) -{ - int i; - for (i = 0; i < ctx->nglob; i++) { - const char *gl = ctx->globnames[i]; - if (gl[0] == 'f' && gl[1] == 'f' && gl[2] == '_' && !strcmp(gl+3, name)) { - return (int)((uint8_t *)ctx->glob[i] - ctx->code); - } - } - fprintf(stderr, "Error: undefined fast function %s%s\n", - LABEL_PREFIX_FF, name); - exit(1); -} - -static void libdef_func(BuildCtx *ctx, char *p, int arg) -{ - if (arg != LIBINIT_CF) - ffasmfunc++; - if (ctx->mode == BUILD_libdef) { - if (modstate == 0) { - fprintf(stderr, "Error: no module for function definition %s\n", p); - exit(1); - } - if (regfunc == REGFUNC_NOREG) { - if (optr+1 > obuf+sizeof(obuf)) { - fprintf(stderr, "Error: output buffer overflow\n"); - exit(1); - } - *optr++ = LIBINIT_FFID; - } else { - if (arg != LIBINIT_ASM_) { - if (modstate != 1) fprintf(ctx->fp, ",\n"); - modstate = 2; - fprintf(ctx->fp, " %s%s", arg ? LABEL_PREFIX_FFH : LABEL_PREFIX_CF, p); - } - if (regfunc != REGFUNC_NOREGUV) obuf[2]++; /* Bump hash table size. */ - libdef_name(regfunc == REGFUNC_NOREGUV ? "" : p, arg); - } - } else if (ctx->mode == BUILD_ffdef) { - fprintf(ctx->fp, "FFDEF(%s)\n", p); - } else if (ctx->mode == BUILD_recdef) { - if (strlen(p) > sizeof(funcname)-1) { - fprintf(stderr, "Error: function name too long: '%s'\n", p); - exit(1); - } - strcpy(funcname, p); - } else if (ctx->mode == BUILD_vmdef) { - int i; - for (i = 1; p[i] && modname[i-1]; i++) - if (p[i] == '_') p[i] = '.'; - fprintf(ctx->fp, "\"%s\",\n", p); - } else if (ctx->mode == BUILD_bcdef) { - if (arg != LIBINIT_CF) - fprintf(ctx->fp, ",\n%d", find_ffofs(ctx, p)); - } - ffid++; - regfunc = REGFUNC_OK; -} - -static uint32_t find_rec(char *name) -{ - char *p = (char *)obuf; - uint32_t n; - for (n = 2; *p; n++) { - if (strcmp(p, name) == 0) - return n; - p += strlen(p)+1; - } - if (p+strlen(name)+1 >= (char *)obuf+sizeof(obuf)) { - fprintf(stderr, "Error: output buffer overflow\n"); - exit(1); - } - strcpy(p, name); - return n; -} - -static void libdef_rec(BuildCtx *ctx, char *p, int arg) -{ - UNUSED(arg); - if (ctx->mode == BUILD_recdef) { - char *q; - uint32_t n; - for (; recffid+1 < ffid; recffid++) - fprintf(ctx->fp, ",\n0"); - recffid = ffid; - if (*p == '.') p = funcname; - q = strchr(p, ' '); - if (q) *q++ = '\0'; - n = find_rec(p); - if (q) - fprintf(ctx->fp, ",\n0x%02x00+(%s)", n, q); - else - fprintf(ctx->fp, ",\n0x%02x00", n); - } -} - -static void memcpy_endian(void *dst, void *src, size_t n) -{ - union { uint8_t b; uint32_t u; } host_endian; - host_endian.u = 1; - if (host_endian.b == LJ_ENDIAN_SELECT(1, 0)) { - memcpy(dst, src, n); - } else { - size_t i; - for (i = 0; i < n; i++) - ((uint8_t *)dst)[i] = ((uint8_t *)src)[n-i-1]; - } -} - -static void libdef_push(BuildCtx *ctx, char *p, int arg) -{ - UNUSED(arg); - if (ctx->mode == BUILD_libdef) { - int len = (int)strlen(p); - if (*p == '"') { - if (len > 1 && p[len-1] == '"') { - p[len-1] = '\0'; - libdef_name(p+1, LIBINIT_STRING); - return; - } - } else if (*p >= '0' && *p <= '9') { - char *ep; - double d = strtod(p, &ep); - if (*ep == '\0') { - if (optr+1+sizeof(double) > obuf+sizeof(obuf)) { - fprintf(stderr, "Error: output buffer overflow\n"); - exit(1); - } - *optr++ = LIBINIT_NUMBER; - memcpy_endian(optr, &d, sizeof(double)); - optr += sizeof(double); - return; - } - } else if (!strcmp(p, "lastcl")) { - if (optr+1 > obuf+sizeof(obuf)) { - fprintf(stderr, "Error: output buffer overflow\n"); - exit(1); - } - *optr++ = LIBINIT_LASTCL; - return; - } else if (len > 4 && !strncmp(p, "top-", 4)) { - if (optr+2 > obuf+sizeof(obuf)) { - fprintf(stderr, "Error: output buffer overflow\n"); - exit(1); - } - *optr++ = LIBINIT_COPY; - *optr++ = (uint8_t)atoi(p+4); - return; - } - fprintf(stderr, "Error: bad value for %sPUSH(%s)\n", LIBDEF_PREFIX, p); - exit(1); - } -} - -static void libdef_set(BuildCtx *ctx, char *p, int arg) -{ - UNUSED(arg); - if (ctx->mode == BUILD_libdef) { - if (p[0] == '!' && p[1] == '\0') p[0] = '\0'; /* Set env. */ - libdef_name(p, LIBINIT_STRING); - *optr++ = LIBINIT_SET; - obuf[2]++; /* Bump hash table size. */ - } -} - -static void libdef_regfunc(BuildCtx *ctx, char *p, int arg) -{ - UNUSED(ctx); UNUSED(p); - regfunc = arg; -} - -typedef void (*LibDefFunc)(BuildCtx *ctx, char *p, int arg); - -typedef struct LibDefHandler { - const char *suffix; - const char *stop; - const LibDefFunc func; - const int arg; -} LibDefHandler; - -static const LibDefHandler libdef_handlers[] = { - { "MODULE_", " \t\r\n", libdef_module, 0 }, - { "CF(", ")", libdef_func, LIBINIT_CF }, - { "ASM(", ")", libdef_func, LIBINIT_ASM }, - { "ASM_(", ")", libdef_func, LIBINIT_ASM_ }, - { "REC(", ")", libdef_rec, 0 }, - { "PUSH(", ")", libdef_push, 0 }, - { "SET(", ")", libdef_set, 0 }, - { "NOREGUV", NULL, libdef_regfunc, REGFUNC_NOREGUV }, - { "NOREG", NULL, libdef_regfunc, REGFUNC_NOREG }, - { NULL, NULL, (LibDefFunc)0, 0 } -}; - -/* Emit C source code for library function definitions. */ -void emit_lib(BuildCtx *ctx) -{ - const char *fname; - - if (ctx->mode == BUILD_ffdef || ctx->mode == BUILD_libdef || - ctx->mode == BUILD_recdef) - fprintf(ctx->fp, "/* This is a generated file. DO NOT EDIT! */\n\n"); - else if (ctx->mode == BUILD_vmdef) - fprintf(ctx->fp, "ffnames = {\n[0]=\"Lua\",\n\"C\",\n"); - if (ctx->mode == BUILD_recdef) - fprintf(ctx->fp, "static const uint16_t recff_idmap[] = {\n0,\n0x0100"); - recffid = ffid = FF_C+1; - ffasmfunc = 0; - - while ((fname = *ctx->args++)) { - char buf[256]; /* We don't care about analyzing lines longer than that. */ - FILE *fp; - if (fname[0] == '-' && fname[1] == '\0') { - fp = stdin; - } else { - fp = fopen(fname, "r"); - if (!fp) { - fprintf(stderr, "Error: cannot open input file '%s': %s\n", - fname, strerror(errno)); - exit(1); - } - } - modstate = 0; - regfunc = REGFUNC_OK; - while (fgets(buf, sizeof(buf), fp) != NULL) { - char *p; - /* Simplistic pre-processor. Only handles top-level #if/#endif. */ - if (buf[0] == '#' && buf[1] == 'i' && buf[2] == 'f') { - int ok = 1; - if (!strcmp(buf, "#if LJ_52\n")) - ok = LJ_52; - else if (!strcmp(buf, "#if LJ_HASJIT\n")) - ok = LJ_HASJIT; - else if (!strcmp(buf, "#if LJ_HASFFI\n")) - ok = LJ_HASFFI; - if (!ok) { - int lvl = 1; - while (fgets(buf, sizeof(buf), fp) != NULL) { - if (buf[0] == '#' && buf[1] == 'e' && buf[2] == 'n') { - if (--lvl == 0) break; - } else if (buf[0] == '#' && buf[1] == 'i' && buf[2] == 'f') { - lvl++; - } - } - continue; - } - } - for (p = buf; (p = strstr(p, LIBDEF_PREFIX)) != NULL; ) { - const LibDefHandler *ldh; - p += sizeof(LIBDEF_PREFIX)-1; - for (ldh = libdef_handlers; ldh->suffix != NULL; ldh++) { - size_t n, len = strlen(ldh->suffix); - if (!strncmp(p, ldh->suffix, len)) { - p += len; - n = ldh->stop ? strcspn(p, ldh->stop) : 0; - if (!p[n]) break; - p[n] = '\0'; - ldh->func(ctx, p, ldh->arg); - p += n+1; - break; - } - } - if (ldh->suffix == NULL) { - buf[strlen(buf)-1] = '\0'; - fprintf(stderr, "Error: unknown library definition tag %s%s\n", - LIBDEF_PREFIX, p); - exit(1); - } - } - } - fclose(fp); - if (ctx->mode == BUILD_libdef) { - libdef_endmodule(ctx); - } - } - - if (ctx->mode == BUILD_ffdef) { - fprintf(ctx->fp, "\n#undef FFDEF\n\n"); - fprintf(ctx->fp, - "#ifndef FF_NUM_ASMFUNC\n#define FF_NUM_ASMFUNC %d\n#endif\n\n", - ffasmfunc); - } else if (ctx->mode == BUILD_vmdef) { - fprintf(ctx->fp, "}\n\n"); - } else if (ctx->mode == BUILD_bcdef) { - int i; - fprintf(ctx->fp, "\n};\n\n"); - fprintf(ctx->fp, "LJ_DATADEF const uint16_t lj_bc_mode[] = {\n"); - fprintf(ctx->fp, "BCDEF(BCMODE)\n"); - for (i = ffasmfunc-1; i > 0; i--) - fprintf(ctx->fp, "BCMODE_FF,\n"); - fprintf(ctx->fp, "BCMODE_FF\n};\n\n"); - } else if (ctx->mode == BUILD_recdef) { - char *p = (char *)obuf; - fprintf(ctx->fp, "\n};\n\n"); - fprintf(ctx->fp, "static const RecordFunc recff_func[] = {\n" - "recff_nyi,\n" - "recff_c"); - while (*p) { - fprintf(ctx->fp, ",\nrecff_%s", p); - p += strlen(p)+1; - } - fprintf(ctx->fp, "\n};\n\n"); - } -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm_peobj.c b/source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm_peobj.c deleted file mode 100644 index 138b04232..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/host/buildvm_peobj.c +++ /dev/null @@ -1,368 +0,0 @@ -/* -** LuaJIT VM builder: PE object emitter. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Only used for building on Windows, since we cannot assume the presence -** of a suitable assembler. The host and target byte order must match. -*/ - -#include "buildvm.h" -#include "lj_bc.h" - -#if LJ_TARGET_X86ORX64 || LJ_TARGET_PPC - -/* Context for PE object emitter. */ -static char *strtab; -static size_t strtabofs; - -/* -- PE object definitions ----------------------------------------------- */ - -/* PE header. */ -typedef struct PEheader { - uint16_t arch; - uint16_t nsects; - uint32_t time; - uint32_t symtabofs; - uint32_t nsyms; - uint16_t opthdrsz; - uint16_t flags; -} PEheader; - -/* PE section. */ -typedef struct PEsection { - char name[8]; - uint32_t vsize; - uint32_t vaddr; - uint32_t size; - uint32_t ofs; - uint32_t relocofs; - uint32_t lineofs; - uint16_t nreloc; - uint16_t nline; - uint32_t flags; -} PEsection; - -/* PE relocation. */ -typedef struct PEreloc { - uint32_t vaddr; - uint32_t symidx; - uint16_t type; -} PEreloc; - -/* Cannot use sizeof, because it pads up to the max. alignment. */ -#define PEOBJ_RELOC_SIZE (4+4+2) - -/* PE symbol table entry. */ -typedef struct PEsym { - union { - char name[8]; - uint32_t nameref[2]; - } n; - uint32_t value; - int16_t sect; - uint16_t type; - uint8_t scl; - uint8_t naux; -} PEsym; - -/* PE symbol table auxiliary entry for a section. */ -typedef struct PEsymaux { - uint32_t size; - uint16_t nreloc; - uint16_t nline; - uint32_t cksum; - uint16_t assoc; - uint8_t comdatsel; - uint8_t unused[3]; -} PEsymaux; - -/* Cannot use sizeof, because it pads up to the max. alignment. */ -#define PEOBJ_SYM_SIZE (8+4+2+2+1+1) - -/* PE object CPU specific defines. */ -#if LJ_TARGET_X86 -#define PEOBJ_ARCH_TARGET 0x014c -#define PEOBJ_RELOC_REL32 0x14 /* MS: REL32, GNU: DISP32. */ -#define PEOBJ_RELOC_DIR32 0x06 -#define PEOBJ_RELOC_OFS 0 -#define PEOBJ_TEXT_FLAGS 0x60500020 /* 60=r+x, 50=align16, 20=code. */ -#elif LJ_TARGET_X64 -#define PEOBJ_ARCH_TARGET 0x8664 -#define PEOBJ_RELOC_REL32 0x04 /* MS: REL32, GNU: DISP32. */ -#define PEOBJ_RELOC_DIR32 0x02 -#define PEOBJ_RELOC_ADDR32NB 0x03 -#define PEOBJ_RELOC_OFS 0 -#define PEOBJ_TEXT_FLAGS 0x60500020 /* 60=r+x, 50=align16, 20=code. */ -#elif LJ_TARGET_PPC -#define PEOBJ_ARCH_TARGET 0x01f2 -#define PEOBJ_RELOC_REL32 0x06 -#define PEOBJ_RELOC_DIR32 0x02 -#define PEOBJ_RELOC_OFS (-4) -#define PEOBJ_TEXT_FLAGS 0x60400020 /* 60=r+x, 40=align8, 20=code. */ -#endif - -/* Section numbers (0-based). */ -enum { - PEOBJ_SECT_ABS = -2, - PEOBJ_SECT_UNDEF = -1, - PEOBJ_SECT_TEXT, -#if LJ_TARGET_X64 - PEOBJ_SECT_PDATA, - PEOBJ_SECT_XDATA, -#endif - PEOBJ_SECT_RDATA_Z, - PEOBJ_NSECTIONS -}; - -/* Symbol types. */ -#define PEOBJ_TYPE_NULL 0 -#define PEOBJ_TYPE_FUNC 0x20 - -/* Symbol storage class. */ -#define PEOBJ_SCL_EXTERN 2 -#define PEOBJ_SCL_STATIC 3 - -/* -- PE object emitter --------------------------------------------------- */ - -/* Emit PE object symbol. */ -static void emit_peobj_sym(BuildCtx *ctx, const char *name, uint32_t value, - int sect, int type, int scl) -{ - PEsym sym; - size_t len = strlen(name); - if (!strtab) { /* Pass 1: only calculate string table length. */ - if (len > 8) strtabofs += len+1; - return; - } - if (len <= 8) { - memcpy(sym.n.name, name, len); - memset(sym.n.name+len, 0, 8-len); - } else { - sym.n.nameref[0] = 0; - sym.n.nameref[1] = (uint32_t)strtabofs; - memcpy(strtab + strtabofs, name, len); - strtab[strtabofs+len] = 0; - strtabofs += len+1; - } - sym.value = value; - sym.sect = (int16_t)(sect+1); /* 1-based section number. */ - sym.type = (uint16_t)type; - sym.scl = (uint8_t)scl; - sym.naux = 0; - owrite(ctx, &sym, PEOBJ_SYM_SIZE); -} - -/* Emit PE object section symbol. */ -static void emit_peobj_sym_sect(BuildCtx *ctx, PEsection *pesect, int sect) -{ - PEsym sym; - PEsymaux aux; - if (!strtab) return; /* Pass 1: no output. */ - memcpy(sym.n.name, pesect[sect].name, 8); - sym.value = 0; - sym.sect = (int16_t)(sect+1); /* 1-based section number. */ - sym.type = PEOBJ_TYPE_NULL; - sym.scl = PEOBJ_SCL_STATIC; - sym.naux = 1; - owrite(ctx, &sym, PEOBJ_SYM_SIZE); - memset(&aux, 0, sizeof(PEsymaux)); - aux.size = pesect[sect].size; - aux.nreloc = pesect[sect].nreloc; - owrite(ctx, &aux, PEOBJ_SYM_SIZE); -} - -/* Emit Windows PE object file. */ -void emit_peobj(BuildCtx *ctx) -{ - PEheader pehdr; - PEsection pesect[PEOBJ_NSECTIONS]; - uint32_t sofs; - int i, nrsym; - union { uint8_t b; uint32_t u; } host_endian; - - sofs = sizeof(PEheader) + PEOBJ_NSECTIONS*sizeof(PEsection); - - /* Fill in PE sections. */ - memset(&pesect, 0, PEOBJ_NSECTIONS*sizeof(PEsection)); - memcpy(pesect[PEOBJ_SECT_TEXT].name, ".text", sizeof(".text")-1); - pesect[PEOBJ_SECT_TEXT].ofs = sofs; - sofs += (pesect[PEOBJ_SECT_TEXT].size = (uint32_t)ctx->codesz); - pesect[PEOBJ_SECT_TEXT].relocofs = sofs; - sofs += (pesect[PEOBJ_SECT_TEXT].nreloc = (uint16_t)ctx->nreloc) * PEOBJ_RELOC_SIZE; - /* Flags: 60 = read+execute, 50 = align16, 20 = code. */ - pesect[PEOBJ_SECT_TEXT].flags = PEOBJ_TEXT_FLAGS; - -#if LJ_TARGET_X64 - memcpy(pesect[PEOBJ_SECT_PDATA].name, ".pdata", sizeof(".pdata")-1); - pesect[PEOBJ_SECT_PDATA].ofs = sofs; - sofs += (pesect[PEOBJ_SECT_PDATA].size = 6*4); - pesect[PEOBJ_SECT_PDATA].relocofs = sofs; - sofs += (pesect[PEOBJ_SECT_PDATA].nreloc = 6) * PEOBJ_RELOC_SIZE; - /* Flags: 40 = read, 30 = align4, 40 = initialized data. */ - pesect[PEOBJ_SECT_PDATA].flags = 0x40300040; - - memcpy(pesect[PEOBJ_SECT_XDATA].name, ".xdata", sizeof(".xdata")-1); - pesect[PEOBJ_SECT_XDATA].ofs = sofs; - sofs += (pesect[PEOBJ_SECT_XDATA].size = 8*2+4+6*2); /* See below. */ - pesect[PEOBJ_SECT_XDATA].relocofs = sofs; - sofs += (pesect[PEOBJ_SECT_XDATA].nreloc = 1) * PEOBJ_RELOC_SIZE; - /* Flags: 40 = read, 30 = align4, 40 = initialized data. */ - pesect[PEOBJ_SECT_XDATA].flags = 0x40300040; -#endif - - memcpy(pesect[PEOBJ_SECT_RDATA_Z].name, ".rdata$Z", sizeof(".rdata$Z")-1); - pesect[PEOBJ_SECT_RDATA_Z].ofs = sofs; - sofs += (pesect[PEOBJ_SECT_RDATA_Z].size = (uint32_t)strlen(ctx->dasm_ident)+1); - /* Flags: 40 = read, 30 = align4, 40 = initialized data. */ - pesect[PEOBJ_SECT_RDATA_Z].flags = 0x40300040; - - /* Fill in PE header. */ - pehdr.arch = PEOBJ_ARCH_TARGET; - pehdr.nsects = PEOBJ_NSECTIONS; - pehdr.time = 0; /* Timestamp is optional. */ - pehdr.symtabofs = sofs; - pehdr.opthdrsz = 0; - pehdr.flags = 0; - - /* Compute the size of the symbol table: - ** @feat.00 + nsections*2 - ** + asm_start + nsym - ** + nrsym - */ - nrsym = ctx->nrelocsym; - pehdr.nsyms = 1+PEOBJ_NSECTIONS*2 + 1+ctx->nsym + nrsym; -#if LJ_TARGET_X64 - pehdr.nsyms += 1; /* Symbol for lj_err_unwind_win64. */ -#endif - - /* Write PE object header and all sections. */ - owrite(ctx, &pehdr, sizeof(PEheader)); - owrite(ctx, &pesect, sizeof(PEsection)*PEOBJ_NSECTIONS); - - /* Write .text section. */ - host_endian.u = 1; - if (host_endian.b != LJ_ENDIAN_SELECT(1, 0)) { -#if LJ_TARGET_PPC - uint32_t *p = (uint32_t *)ctx->code; - int n = (int)(ctx->codesz >> 2); - for (i = 0; i < n; i++, p++) - *p = lj_bswap(*p); /* Byteswap .text section. */ -#else - fprintf(stderr, "Error: different byte order for host and target\n"); - exit(1); -#endif - } - owrite(ctx, ctx->code, ctx->codesz); - for (i = 0; i < ctx->nreloc; i++) { - PEreloc reloc; - reloc.vaddr = (uint32_t)ctx->reloc[i].ofs + PEOBJ_RELOC_OFS; - reloc.symidx = 1+2+ctx->reloc[i].sym; /* Reloc syms are after .text sym. */ - reloc.type = ctx->reloc[i].type ? PEOBJ_RELOC_REL32 : PEOBJ_RELOC_DIR32; - owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); - } - -#if LJ_TARGET_X64 - { /* Write .pdata section. */ - uint32_t fcofs = (uint32_t)ctx->sym[ctx->nsym-1].ofs; - uint32_t pdata[3]; /* Start of .text, end of .text and .xdata. */ - PEreloc reloc; - pdata[0] = 0; pdata[1] = fcofs; pdata[2] = 0; - owrite(ctx, &pdata, sizeof(pdata)); - pdata[0] = fcofs; pdata[1] = (uint32_t)ctx->codesz; pdata[2] = 20; - owrite(ctx, &pdata, sizeof(pdata)); - reloc.vaddr = 0; reloc.symidx = 1+2+nrsym+2+2+1; - reloc.type = PEOBJ_RELOC_ADDR32NB; - owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); - reloc.vaddr = 4; reloc.symidx = 1+2+nrsym+2+2+1; - reloc.type = PEOBJ_RELOC_ADDR32NB; - owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); - reloc.vaddr = 8; reloc.symidx = 1+2+nrsym+2; - reloc.type = PEOBJ_RELOC_ADDR32NB; - owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); - reloc.vaddr = 12; reloc.symidx = 1+2+nrsym+2+2+1; - reloc.type = PEOBJ_RELOC_ADDR32NB; - owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); - reloc.vaddr = 16; reloc.symidx = 1+2+nrsym+2+2+1; - reloc.type = PEOBJ_RELOC_ADDR32NB; - owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); - reloc.vaddr = 20; reloc.symidx = 1+2+nrsym+2; - reloc.type = PEOBJ_RELOC_ADDR32NB; - owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); - } - { /* Write .xdata section. */ - uint16_t xdata[8+2+6]; - PEreloc reloc; - xdata[0] = 0x01|0x08|0x10; /* Ver. 1, uhandler/ehandler, prolog size 0. */ - xdata[1] = 0x0005; /* Number of unwind codes, no frame pointer. */ - xdata[2] = 0x4200; /* Stack offset 4*8+8 = aword*5. */ - xdata[3] = 0x3000; /* Push rbx. */ - xdata[4] = 0x6000; /* Push rsi. */ - xdata[5] = 0x7000; /* Push rdi. */ - xdata[6] = 0x5000; /* Push rbp. */ - xdata[7] = 0; /* Alignment. */ - xdata[8] = xdata[9] = 0; /* Relocated address of exception handler. */ - xdata[10] = 0x01; /* Ver. 1, no handler, prolog size 0. */ - xdata[11] = 0x1504; /* Number of unwind codes, fp = rbp, fpofs = 16. */ - xdata[12] = 0x0300; /* set_fpreg. */ - xdata[13] = 0x0200; /* stack offset 0*8+8 = aword*1. */ - xdata[14] = 0x3000; /* Push rbx. */ - xdata[15] = 0x5000; /* Push rbp. */ - owrite(ctx, &xdata, sizeof(xdata)); - reloc.vaddr = 2*8; reloc.symidx = 1+2+nrsym+2+2; - reloc.type = PEOBJ_RELOC_ADDR32NB; - owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); - } -#endif - - /* Write .rdata$Z section. */ - owrite(ctx, ctx->dasm_ident, strlen(ctx->dasm_ident)+1); - - /* Write symbol table. */ - strtab = NULL; /* 1st pass: collect string sizes. */ - for (;;) { - strtabofs = 4; - /* Mark as SafeSEH compliant. */ - emit_peobj_sym(ctx, "@feat.00", 1, - PEOBJ_SECT_ABS, PEOBJ_TYPE_NULL, PEOBJ_SCL_STATIC); - - emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_TEXT); - for (i = 0; i < nrsym; i++) - emit_peobj_sym(ctx, ctx->relocsym[i], 0, - PEOBJ_SECT_UNDEF, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN); - -#if LJ_TARGET_X64 - emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_PDATA); - emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_XDATA); - emit_peobj_sym(ctx, "lj_err_unwind_win64", 0, - PEOBJ_SECT_UNDEF, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN); -#endif - - emit_peobj_sym(ctx, ctx->beginsym, 0, - PEOBJ_SECT_TEXT, PEOBJ_TYPE_NULL, PEOBJ_SCL_EXTERN); - for (i = 0; i < ctx->nsym; i++) - emit_peobj_sym(ctx, ctx->sym[i].name, (uint32_t)ctx->sym[i].ofs, - PEOBJ_SECT_TEXT, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN); - - emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_RDATA_Z); - - if (strtab) - break; - /* 2nd pass: alloc strtab, write syms and copy strings. */ - strtab = (char *)malloc(strtabofs); - *(uint32_t *)strtab = (uint32_t)strtabofs; - } - - /* Write string table. */ - owrite(ctx, strtab, strtabofs); -} - -#else - -void emit_peobj(BuildCtx *ctx) -{ - UNUSED(ctx); - fprintf(stderr, "Error: no PE object support for this target\n"); - exit(1); -} - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/host/genminilua.lua b/source/libs/luajit/LuaJIT-2.0.3/src/host/genminilua.lua deleted file mode 100644 index 04c551887..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/host/genminilua.lua +++ /dev/null @@ -1,428 +0,0 @@ ----------------------------------------------------------------------------- --- Lua script to generate a customized, minified version of Lua. --- The resulting 'minilua' is used for the build process of LuaJIT. ----------------------------------------------------------------------------- --- Copyright (C) 2005-2014 Mike Pall. All rights reserved. --- Released under the MIT license. See Copyright Notice in luajit.h ----------------------------------------------------------------------------- - -local sub, match, gsub = string.sub, string.match, string.gsub - -local LUA_VERSION = "5.1.5" -local LUA_SOURCE - -local function usage() - io.stderr:write("Usage: ", arg and arg[0] or "genminilua", - " lua-", LUA_VERSION, "-source-dir\n") - os.exit(1) -end - -local function find_sources() - LUA_SOURCE = arg and arg[1] - if not LUA_SOURCE then usage() end - if sub(LUA_SOURCE, -1) ~= "/" then LUA_SOURCE = LUA_SOURCE.."/" end - local fp = io.open(LUA_SOURCE .. "lua.h") - if not fp then - LUA_SOURCE = LUA_SOURCE.."src/" - fp = io.open(LUA_SOURCE .. "lua.h") - if not fp then usage() end - end - local all = fp:read("*a") - fp:close() - if not match(all, 'LUA_RELEASE%s*"Lua '..LUA_VERSION..'"') then - io.stderr:write("Error: version mismatch\n") - usage() - end -end - -local LUA_FILES = { -"lmem.c", "lobject.c", "ltm.c", "lfunc.c", "ldo.c", "lstring.c", "ltable.c", -"lgc.c", "lstate.c", "ldebug.c", "lzio.c", "lopcodes.c", -"llex.c", "lcode.c", "lparser.c", "lvm.c", "lapi.c", "lauxlib.c", -"lbaselib.c", "ltablib.c", "liolib.c", "loslib.c", "lstrlib.c", "linit.c", -} - -local REMOVE_LIB = {} -gsub([[ -collectgarbage dofile gcinfo getfenv getmetatable load print rawequal rawset -select tostring xpcall -foreach foreachi getn maxn setn -popen tmpfile seek setvbuf __tostring -clock date difftime execute getenv rename setlocale time tmpname -dump gfind len reverse -LUA_LOADLIBNAME LUA_MATHLIBNAME LUA_DBLIBNAME -]], "%S+", function(name) - REMOVE_LIB[name] = true -end) - -local REMOVE_EXTINC = { [""] = true, [""] = true, } - -local CUSTOM_MAIN = [[ -typedef unsigned int UB; -static UB barg(lua_State *L,int idx){ -union{lua_Number n;U64 b;}bn; -bn.n=lua_tonumber(L,idx)+6755399441055744.0; -if (bn.n==0.0&&!lua_isnumber(L,idx))luaL_typerror(L,idx,"number"); -return(UB)bn.b; -} -#define BRET(b) lua_pushnumber(L,(lua_Number)(int)(b));return 1; -static int tobit(lua_State *L){ -BRET(barg(L,1))} -static int bnot(lua_State *L){ -BRET(~barg(L,1))} -static int band(lua_State *L){ -int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b&=barg(L,i);BRET(b)} -static int bor(lua_State *L){ -int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b|=barg(L,i);BRET(b)} -static int bxor(lua_State *L){ -int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b^=barg(L,i);BRET(b)} -static int lshift(lua_State *L){ -UB b=barg(L,1),n=barg(L,2)&31;BRET(b<>n)} -static int arshift(lua_State *L){ -UB b=barg(L,1),n=barg(L,2)&31;BRET((int)b>>n)} -static int rol(lua_State *L){ -UB b=barg(L,1),n=barg(L,2)&31;BRET((b<>(32-n)))} -static int ror(lua_State *L){ -UB b=barg(L,1),n=barg(L,2)&31;BRET((b>>n)|(b<<(32-n)))} -static int bswap(lua_State *L){ -UB b=barg(L,1);b=(b>>24)|((b>>8)&0xff00)|((b&0xff00)<<8)|(b<<24);BRET(b)} -static int tohex(lua_State *L){ -UB b=barg(L,1); -int n=lua_isnone(L,2)?8:(int)barg(L,2); -const char *hexdigits="0123456789abcdef"; -char buf[8]; -int i; -if(n<0){n=-n;hexdigits="0123456789ABCDEF";} -if(n>8)n=8; -for(i=(int)n;--i>=0;){buf[i]=hexdigits[b&15];b>>=4;} -lua_pushlstring(L,buf,(size_t)n); -return 1; -} -static const struct luaL_Reg bitlib[] = { -{"tobit",tobit}, -{"bnot",bnot}, -{"band",band}, -{"bor",bor}, -{"bxor",bxor}, -{"lshift",lshift}, -{"rshift",rshift}, -{"arshift",arshift}, -{"rol",rol}, -{"ror",ror}, -{"bswap",bswap}, -{"tohex",tohex}, -{NULL,NULL} -}; -int main(int argc, char **argv){ - lua_State *L = luaL_newstate(); - int i; - luaL_openlibs(L); - luaL_register(L, "bit", bitlib); - if (argc < 2) return sizeof(void *); - lua_createtable(L, 0, 1); - lua_pushstring(L, argv[1]); - lua_rawseti(L, -2, 0); - lua_setglobal(L, "arg"); - if (luaL_loadfile(L, argv[1])) - goto err; - for (i = 2; i < argc; i++) - lua_pushstring(L, argv[i]); - if (lua_pcall(L, argc - 2, 0, 0)) { - err: - fprintf(stderr, "Error: %s\n", lua_tostring(L, -1)); - return 1; - } - lua_close(L); - return 0; -} -]] - -local function read_sources() - local t = {} - for i, name in ipairs(LUA_FILES) do - local fp = assert(io.open(LUA_SOURCE..name, "r")) - t[i] = fp:read("*a") - assert(fp:close()) - end - t[#t+1] = CUSTOM_MAIN - return table.concat(t) -end - -local includes = {} - -local function merge_includes(src) - return gsub(src, '#include%s*"([^"]*)"%s*\n', function(name) - if includes[name] then return "" end - includes[name] = true - local fp = assert(io.open(LUA_SOURCE..name, "r")) - local src = fp:read("*a") - assert(fp:close()) - src = gsub(src, "#ifndef%s+%w+_h\n#define%s+%w+_h\n", "") - src = gsub(src, "#endif%s*$", "") - return merge_includes(src) - end) -end - -local function get_license(src) - return match(src, "/%*+\n%* Copyright %(.-%*/\n") -end - -local function fold_lines(src) - return gsub(src, "\\\n", " ") -end - -local strings = {} - -local function save_str(str) - local n = #strings+1 - strings[n] = str - return "\1"..n.."\2" -end - -local function save_strings(src) - src = gsub(src, '"[^"\n]*"', save_str) - return gsub(src, "'[^'\n]*'", save_str) -end - -local function restore_strings(src) - return gsub(src, "\1(%d+)\2", function(numstr) - return strings[tonumber(numstr)] - end) -end - -local function def_istrue(def) - return def == "INT_MAX > 2147483640L" or - def == "LUAI_BITSINT >= 32" or - def == "SIZE_Bx < LUAI_BITSINT-1" or - def == "cast" or - def == "defined(LUA_CORE)" or - def == "MINSTRTABSIZE" or - def == "LUA_MINBUFFER" or - def == "HARDSTACKTESTS" or - def == "UNUSED" -end - -local head, defs = {[[ -#ifdef _MSC_VER -typedef unsigned __int64 U64; -#else -typedef unsigned long long U64; -#endif -int _CRT_glob = 0; -]]}, {} - -local function preprocess(src) - local t = { match(src, "^(.-)#") } - local lvl, on, oldon = 0, true, {} - for pp, def, txt in string.gmatch(src, "#(%w+) *([^\n]*)\n([^#]*)") do - if pp == "if" or pp == "ifdef" or pp == "ifndef" then - lvl = lvl + 1 - oldon[lvl] = on - on = def_istrue(def) - elseif pp == "else" then - if oldon[lvl] then - if on == false then on = true else on = false end - end - elseif pp == "elif" then - if oldon[lvl] then - on = def_istrue(def) - end - elseif pp == "endif" then - on = oldon[lvl] - lvl = lvl - 1 - elseif on then - if pp == "include" then - if not head[def] and not REMOVE_EXTINC[def] then - head[def] = true - head[#head+1] = "#include "..def.."\n" - end - elseif pp == "define" then - local k, sp, v = match(def, "([%w_]+)(%s*)(.*)") - if k and not (sp == "" and sub(v, 1, 1) == "(") then - defs[k] = gsub(v, "%a[%w_]*", function(tok) - return defs[tok] or tok - end) - else - t[#t+1] = "#define "..def.."\n" - end - elseif pp ~= "undef" then - error("unexpected directive: "..pp.." "..def) - end - end - if on then t[#t+1] = txt end - end - return gsub(table.concat(t), "%a[%w_]*", function(tok) - return defs[tok] or tok - end) -end - -local function merge_header(src, license) - local hdr = string.format([[ -/* This is a heavily customized and minimized copy of Lua %s. */ -/* It's only used to build LuaJIT. It does NOT have all standard functions! */ -]], LUA_VERSION) - return hdr..license..table.concat(head)..src -end - -local function strip_unused1(src) - return gsub(src, '( {"?([%w_]+)"?,%s+%a[%w_]*},\n)', function(line, func) - return REMOVE_LIB[func] and "" or line - end) -end - -local function strip_unused2(src) - return gsub(src, "Symbolic Execution.-}=", "") -end - -local function strip_unused3(src) - src = gsub(src, "extern", "static") - src = gsub(src, "\nstatic([^\n]-)%(([^)]*)%)%(", "\nstatic%1 %2(") - src = gsub(src, "#define lua_assert[^\n]*\n", "") - src = gsub(src, "lua_assert%b();?", "") - src = gsub(src, "default:\n}", "default:;\n}") - src = gsub(src, "lua_lock%b();", "") - src = gsub(src, "lua_unlock%b();", "") - src = gsub(src, "luai_threadyield%b();", "") - src = gsub(src, "luai_userstateopen%b();", "{}") - src = gsub(src, "luai_userstate%w+%b();", "") - src = gsub(src, "%(%(c==.*luaY_parser%)", "luaY_parser") - src = gsub(src, "trydecpoint%(ls,seminfo%)", - "luaX_lexerror(ls,\"malformed number\",TK_NUMBER)") - src = gsub(src, "int c=luaZ_lookahead%b();", "") - src = gsub(src, "luaL_register%(L,[^,]*,co_funcs%);\nreturn 2;", - "return 1;") - src = gsub(src, "getfuncname%b():", "NULL:") - src = gsub(src, "getobjname%b():", "NULL:") - src = gsub(src, "if%([^\n]*hookmask[^\n]*%)\n[^\n]*\n", "") - src = gsub(src, "if%([^\n]*hookmask[^\n]*%)%b{}\n", "") - src = gsub(src, "if%([^\n]*hookmask[^\n]*&&\n[^\n]*%b{}\n", "") - src = gsub(src, "(twoto%b()%()", "%1(size_t)") - src = gsub(src, "i -- BYTECODE -- [...] --- print(bc.line(foo, 2)) --> 0002 KSTR 1 1 ; "hello" --- --- local out = { --- -- Do something with each line: --- write = function(t, ...) io.write(...) end, --- close = function(t) end, --- flush = function(t) end, --- } --- bc.dump(foo, out) --- ------------------------------------------------------------------------------- - --- Cache some library functions and objects. -local jit = require("jit") -assert(jit.version_num == 20003, "LuaJIT core/library version mismatch") -local jutil = require("jit.util") -local vmdef = require("jit.vmdef") -local bit = require("bit") -local sub, gsub, format = string.sub, string.gsub, string.format -local byte, band, shr = string.byte, bit.band, bit.rshift -local funcinfo, funcbc, funck = jutil.funcinfo, jutil.funcbc, jutil.funck -local funcuvname = jutil.funcuvname -local bcnames = vmdef.bcnames -local stdout, stderr = io.stdout, io.stderr - ------------------------------------------------------------------------------- - -local function ctlsub(c) - if c == "\n" then return "\\n" - elseif c == "\r" then return "\\r" - elseif c == "\t" then return "\\t" - else return format("\\%03d", byte(c)) - end -end - --- Return one bytecode line. -local function bcline(func, pc, prefix) - local ins, m = funcbc(func, pc) - if not ins then return end - local ma, mb, mc = band(m, 7), band(m, 15*8), band(m, 15*128) - local a = band(shr(ins, 8), 0xff) - local oidx = 6*band(ins, 0xff) - local op = sub(bcnames, oidx+1, oidx+6) - local s = format("%04d %s %-6s %3s ", - pc, prefix or " ", op, ma == 0 and "" or a) - local d = shr(ins, 16) - if mc == 13*128 then -- BCMjump - return format("%s=> %04d\n", s, pc+d-0x7fff) - end - if mb ~= 0 then - d = band(d, 0xff) - elseif mc == 0 then - return s.."\n" - end - local kc - if mc == 10*128 then -- BCMstr - kc = funck(func, -d-1) - kc = format(#kc > 40 and '"%.40s"~' or '"%s"', gsub(kc, "%c", ctlsub)) - elseif mc == 9*128 then -- BCMnum - kc = funck(func, d) - if op == "TSETM " then kc = kc - 2^52 end - elseif mc == 12*128 then -- BCMfunc - local fi = funcinfo(funck(func, -d-1)) - if fi.ffid then - kc = vmdef.ffnames[fi.ffid] - else - kc = fi.loc - end - elseif mc == 5*128 then -- BCMuv - kc = funcuvname(func, d) - end - if ma == 5 then -- BCMuv - local ka = funcuvname(func, a) - if kc then kc = ka.." ; "..kc else kc = ka end - end - if mb ~= 0 then - local b = shr(ins, 24) - if kc then return format("%s%3d %3d ; %s\n", s, b, d, kc) end - return format("%s%3d %3d\n", s, b, d) - end - if kc then return format("%s%3d ; %s\n", s, d, kc) end - if mc == 7*128 and d > 32767 then d = d - 65536 end -- BCMlits - return format("%s%3d\n", s, d) -end - --- Collect branch targets of a function. -local function bctargets(func) - local target = {} - for pc=1,1000000000 do - local ins, m = funcbc(func, pc) - if not ins then break end - if band(m, 15*128) == 13*128 then target[pc+shr(ins, 16)-0x7fff] = true end - end - return target -end - --- Dump bytecode instructions of a function. -local function bcdump(func, out, all) - if not out then out = stdout end - local fi = funcinfo(func) - if all and fi.children then - for n=-1,-1000000000,-1 do - local k = funck(func, n) - if not k then break end - if type(k) == "proto" then bcdump(k, out, true) end - end - end - out:write(format("-- BYTECODE -- %s-%d\n", fi.loc, fi.lastlinedefined)) - local target = bctargets(func) - for pc=1,1000000000 do - local s = bcline(func, pc, target[pc] and "=>") - if not s then break end - out:write(s) - end - out:write("\n") - out:flush() -end - ------------------------------------------------------------------------------- - --- Active flag and output file handle. -local active, out - --- List handler. -local function h_list(func) - return bcdump(func, out) -end - --- Detach list handler. -local function bclistoff() - if active then - active = false - jit.attach(h_list) - if out and out ~= stdout and out ~= stderr then out:close() end - out = nil - end -end - --- Open the output file and attach list handler. -local function bcliston(outfile) - if active then bclistoff() end - if not outfile then outfile = os.getenv("LUAJIT_LISTFILE") end - if outfile then - out = outfile == "-" and stdout or assert(io.open(outfile, "w")) - else - out = stderr - end - jit.attach(h_list, "bc") - active = true -end - --- Public module functions. -module(...) - -line = bcline -dump = bcdump -targets = bctargets - -on = bcliston -off = bclistoff -start = bcliston -- For -j command line option. - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/jit/bcsave.lua b/source/libs/luajit/LuaJIT-2.0.3/src/jit/bcsave.lua deleted file mode 100644 index f55bda970..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/jit/bcsave.lua +++ /dev/null @@ -1,659 +0,0 @@ ----------------------------------------------------------------------------- --- LuaJIT module to save/list bytecode. --- --- Copyright (C) 2005-2014 Mike Pall. All rights reserved. --- Released under the MIT license. See Copyright Notice in luajit.h ----------------------------------------------------------------------------- --- --- This module saves or lists the bytecode for an input file. --- It's run by the -b command line option. --- ------------------------------------------------------------------------------- - -local jit = require("jit") -assert(jit.version_num == 20003, "LuaJIT core/library version mismatch") -local bit = require("bit") - --- Symbol name prefix for LuaJIT bytecode. -local LJBC_PREFIX = "luaJIT_BC_" - ------------------------------------------------------------------------------- - -local function usage() - io.stderr:write[[ -Save LuaJIT bytecode: luajit -b[options] input output - -l Only list bytecode. - -s Strip debug info (default). - -g Keep debug info. - -n name Set module name (default: auto-detect from input name). - -t type Set output file type (default: auto-detect from output name). - -a arch Override architecture for object files (default: native). - -o os Override OS for object files (default: native). - -e chunk Use chunk string as input. - -- Stop handling options. - - Use stdin as input and/or stdout as output. - -File types: c h obj o raw (default) -]] - os.exit(1) -end - -local function check(ok, ...) - if ok then return ok, ... end - io.stderr:write("luajit: ", ...) - io.stderr:write("\n") - os.exit(1) -end - -local function readfile(input) - if type(input) == "function" then return input end - if input == "-" then input = nil end - return check(loadfile(input)) -end - -local function savefile(name, mode) - if name == "-" then return io.stdout end - return check(io.open(name, mode)) -end - ------------------------------------------------------------------------------- - -local map_type = { - raw = "raw", c = "c", h = "h", o = "obj", obj = "obj", -} - -local map_arch = { - x86 = true, x64 = true, arm = true, ppc = true, ppcspe = true, - mips = true, mipsel = true, -} - -local map_os = { - linux = true, windows = true, osx = true, freebsd = true, netbsd = true, - openbsd = true, solaris = true, -} - -local function checkarg(str, map, err) - str = string.lower(str) - local s = check(map[str], "unknown ", err) - return s == true and str or s -end - -local function detecttype(str) - local ext = string.match(string.lower(str), "%.(%a+)$") - return map_type[ext] or "raw" -end - -local function checkmodname(str) - check(string.match(str, "^[%w_.%-]+$"), "bad module name") - return string.gsub(str, "[%.%-]", "_") -end - -local function detectmodname(str) - if type(str) == "string" then - local tail = string.match(str, "[^/\\]+$") - if tail then str = tail end - local head = string.match(str, "^(.*)%.[^.]*$") - if head then str = head end - str = string.match(str, "^[%w_.%-]+") - else - str = nil - end - check(str, "cannot derive module name, use -n name") - return string.gsub(str, "[%.%-]", "_") -end - ------------------------------------------------------------------------------- - -local function bcsave_tail(fp, output, s) - local ok, err = fp:write(s) - if ok and output ~= "-" then ok, err = fp:close() end - check(ok, "cannot write ", output, ": ", err) -end - -local function bcsave_raw(output, s) - local fp = savefile(output, "wb") - bcsave_tail(fp, output, s) -end - -local function bcsave_c(ctx, output, s) - local fp = savefile(output, "w") - if ctx.type == "c" then - fp:write(string.format([[ -#ifdef _cplusplus -extern "C" -#endif -#ifdef _WIN32 -__declspec(dllexport) -#endif -const char %s%s[] = { -]], LJBC_PREFIX, ctx.modname)) - else - fp:write(string.format([[ -#define %s%s_SIZE %d -static const char %s%s[] = { -]], LJBC_PREFIX, ctx.modname, #s, LJBC_PREFIX, ctx.modname)) - end - local t, n, m = {}, 0, 0 - for i=1,#s do - local b = tostring(string.byte(s, i)) - m = m + #b + 1 - if m > 78 then - fp:write(table.concat(t, ",", 1, n), ",\n") - n, m = 0, #b + 1 - end - n = n + 1 - t[n] = b - end - bcsave_tail(fp, output, table.concat(t, ",", 1, n).."\n};\n") -end - -local function bcsave_elfobj(ctx, output, s, ffi) - ffi.cdef[[ -typedef struct { - uint8_t emagic[4], eclass, eendian, eversion, eosabi, eabiversion, epad[7]; - uint16_t type, machine; - uint32_t version; - uint32_t entry, phofs, shofs; - uint32_t flags; - uint16_t ehsize, phentsize, phnum, shentsize, shnum, shstridx; -} ELF32header; -typedef struct { - uint8_t emagic[4], eclass, eendian, eversion, eosabi, eabiversion, epad[7]; - uint16_t type, machine; - uint32_t version; - uint64_t entry, phofs, shofs; - uint32_t flags; - uint16_t ehsize, phentsize, phnum, shentsize, shnum, shstridx; -} ELF64header; -typedef struct { - uint32_t name, type, flags, addr, ofs, size, link, info, align, entsize; -} ELF32sectheader; -typedef struct { - uint32_t name, type; - uint64_t flags, addr, ofs, size; - uint32_t link, info; - uint64_t align, entsize; -} ELF64sectheader; -typedef struct { - uint32_t name, value, size; - uint8_t info, other; - uint16_t sectidx; -} ELF32symbol; -typedef struct { - uint32_t name; - uint8_t info, other; - uint16_t sectidx; - uint64_t value, size; -} ELF64symbol; -typedef struct { - ELF32header hdr; - ELF32sectheader sect[6]; - ELF32symbol sym[2]; - uint8_t space[4096]; -} ELF32obj; -typedef struct { - ELF64header hdr; - ELF64sectheader sect[6]; - ELF64symbol sym[2]; - uint8_t space[4096]; -} ELF64obj; -]] - local symname = LJBC_PREFIX..ctx.modname - local is64, isbe = false, false - if ctx.arch == "x64" then - is64 = true - elseif ctx.arch == "ppc" or ctx.arch == "ppcspe" or ctx.arch == "mips" then - isbe = true - end - - -- Handle different host/target endianess. - local function f32(x) return x end - local f16, fofs = f32, f32 - if ffi.abi("be") ~= isbe then - f32 = bit.bswap - function f16(x) return bit.rshift(bit.bswap(x), 16) end - if is64 then - local two32 = ffi.cast("int64_t", 2^32) - function fofs(x) return bit.bswap(x)*two32 end - else - fofs = f32 - end - end - - -- Create ELF object and fill in header. - local o = ffi.new(is64 and "ELF64obj" or "ELF32obj") - local hdr = o.hdr - if ctx.os == "bsd" or ctx.os == "other" then -- Determine native hdr.eosabi. - local bf = assert(io.open("/bin/ls", "rb")) - local bs = bf:read(9) - bf:close() - ffi.copy(o, bs, 9) - check(hdr.emagic[0] == 127, "no support for writing native object files") - else - hdr.emagic = "\127ELF" - hdr.eosabi = ({ freebsd=9, netbsd=2, openbsd=12, solaris=6 })[ctx.os] or 0 - end - hdr.eclass = is64 and 2 or 1 - hdr.eendian = isbe and 2 or 1 - hdr.eversion = 1 - hdr.type = f16(1) - hdr.machine = f16(({ x86=3, x64=62, arm=40, ppc=20, ppcspe=20, mips=8, mipsel=8 })[ctx.arch]) - if ctx.arch == "mips" or ctx.arch == "mipsel" then - hdr.flags = 0x50001006 - end - hdr.version = f32(1) - hdr.shofs = fofs(ffi.offsetof(o, "sect")) - hdr.ehsize = f16(ffi.sizeof(hdr)) - hdr.shentsize = f16(ffi.sizeof(o.sect[0])) - hdr.shnum = f16(6) - hdr.shstridx = f16(2) - - -- Fill in sections and symbols. - local sofs, ofs = ffi.offsetof(o, "space"), 1 - for i,name in ipairs{ - ".symtab", ".shstrtab", ".strtab", ".rodata", ".note.GNU-stack", - } do - local sect = o.sect[i] - sect.align = fofs(1) - sect.name = f32(ofs) - ffi.copy(o.space+ofs, name) - ofs = ofs + #name+1 - end - o.sect[1].type = f32(2) -- .symtab - o.sect[1].link = f32(3) - o.sect[1].info = f32(1) - o.sect[1].align = fofs(8) - o.sect[1].ofs = fofs(ffi.offsetof(o, "sym")) - o.sect[1].entsize = fofs(ffi.sizeof(o.sym[0])) - o.sect[1].size = fofs(ffi.sizeof(o.sym)) - o.sym[1].name = f32(1) - o.sym[1].sectidx = f16(4) - o.sym[1].size = fofs(#s) - o.sym[1].info = 17 - o.sect[2].type = f32(3) -- .shstrtab - o.sect[2].ofs = fofs(sofs) - o.sect[2].size = fofs(ofs) - o.sect[3].type = f32(3) -- .strtab - o.sect[3].ofs = fofs(sofs + ofs) - o.sect[3].size = fofs(#symname+1) - ffi.copy(o.space+ofs+1, symname) - ofs = ofs + #symname + 2 - o.sect[4].type = f32(1) -- .rodata - o.sect[4].flags = fofs(2) - o.sect[4].ofs = fofs(sofs + ofs) - o.sect[4].size = fofs(#s) - o.sect[5].type = f32(1) -- .note.GNU-stack - o.sect[5].ofs = fofs(sofs + ofs + #s) - - -- Write ELF object file. - local fp = savefile(output, "wb") - fp:write(ffi.string(o, ffi.sizeof(o)-4096+ofs)) - bcsave_tail(fp, output, s) -end - -local function bcsave_peobj(ctx, output, s, ffi) - ffi.cdef[[ -typedef struct { - uint16_t arch, nsects; - uint32_t time, symtabofs, nsyms; - uint16_t opthdrsz, flags; -} PEheader; -typedef struct { - char name[8]; - uint32_t vsize, vaddr, size, ofs, relocofs, lineofs; - uint16_t nreloc, nline; - uint32_t flags; -} PEsection; -typedef struct __attribute((packed)) { - union { - char name[8]; - uint32_t nameref[2]; - }; - uint32_t value; - int16_t sect; - uint16_t type; - uint8_t scl, naux; -} PEsym; -typedef struct __attribute((packed)) { - uint32_t size; - uint16_t nreloc, nline; - uint32_t cksum; - uint16_t assoc; - uint8_t comdatsel, unused[3]; -} PEsymaux; -typedef struct { - PEheader hdr; - PEsection sect[2]; - // Must be an even number of symbol structs. - PEsym sym0; - PEsymaux sym0aux; - PEsym sym1; - PEsymaux sym1aux; - PEsym sym2; - PEsym sym3; - uint32_t strtabsize; - uint8_t space[4096]; -} PEobj; -]] - local symname = LJBC_PREFIX..ctx.modname - local is64 = false - if ctx.arch == "x86" then - symname = "_"..symname - elseif ctx.arch == "x64" then - is64 = true - end - local symexport = " /EXPORT:"..symname..",DATA " - - -- The file format is always little-endian. Swap if the host is big-endian. - local function f32(x) return x end - local f16 = f32 - if ffi.abi("be") then - f32 = bit.bswap - function f16(x) return bit.rshift(bit.bswap(x), 16) end - end - - -- Create PE object and fill in header. - local o = ffi.new("PEobj") - local hdr = o.hdr - hdr.arch = f16(({ x86=0x14c, x64=0x8664, arm=0x1c0, ppc=0x1f2, mips=0x366, mipsel=0x366 })[ctx.arch]) - hdr.nsects = f16(2) - hdr.symtabofs = f32(ffi.offsetof(o, "sym0")) - hdr.nsyms = f32(6) - - -- Fill in sections and symbols. - o.sect[0].name = ".drectve" - o.sect[0].size = f32(#symexport) - o.sect[0].flags = f32(0x00100a00) - o.sym0.sect = f16(1) - o.sym0.scl = 3 - o.sym0.name = ".drectve" - o.sym0.naux = 1 - o.sym0aux.size = f32(#symexport) - o.sect[1].name = ".rdata" - o.sect[1].size = f32(#s) - o.sect[1].flags = f32(0x40300040) - o.sym1.sect = f16(2) - o.sym1.scl = 3 - o.sym1.name = ".rdata" - o.sym1.naux = 1 - o.sym1aux.size = f32(#s) - o.sym2.sect = f16(2) - o.sym2.scl = 2 - o.sym2.nameref[1] = f32(4) - o.sym3.sect = f16(-1) - o.sym3.scl = 2 - o.sym3.value = f32(1) - o.sym3.name = "@feat.00" -- Mark as SafeSEH compliant. - ffi.copy(o.space, symname) - local ofs = #symname + 1 - o.strtabsize = f32(ofs + 4) - o.sect[0].ofs = f32(ffi.offsetof(o, "space") + ofs) - ffi.copy(o.space + ofs, symexport) - ofs = ofs + #symexport - o.sect[1].ofs = f32(ffi.offsetof(o, "space") + ofs) - - -- Write PE object file. - local fp = savefile(output, "wb") - fp:write(ffi.string(o, ffi.sizeof(o)-4096+ofs)) - bcsave_tail(fp, output, s) -end - -local function bcsave_machobj(ctx, output, s, ffi) - ffi.cdef[[ -typedef struct -{ - uint32_t magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds, flags; -} mach_header; -typedef struct -{ - mach_header; uint32_t reserved; -} mach_header_64; -typedef struct { - uint32_t cmd, cmdsize; - char segname[16]; - uint32_t vmaddr, vmsize, fileoff, filesize; - uint32_t maxprot, initprot, nsects, flags; -} mach_segment_command; -typedef struct { - uint32_t cmd, cmdsize; - char segname[16]; - uint64_t vmaddr, vmsize, fileoff, filesize; - uint32_t maxprot, initprot, nsects, flags; -} mach_segment_command_64; -typedef struct { - char sectname[16], segname[16]; - uint32_t addr, size; - uint32_t offset, align, reloff, nreloc, flags; - uint32_t reserved1, reserved2; -} mach_section; -typedef struct { - char sectname[16], segname[16]; - uint64_t addr, size; - uint32_t offset, align, reloff, nreloc, flags; - uint32_t reserved1, reserved2, reserved3; -} mach_section_64; -typedef struct { - uint32_t cmd, cmdsize, symoff, nsyms, stroff, strsize; -} mach_symtab_command; -typedef struct { - int32_t strx; - uint8_t type, sect; - int16_t desc; - uint32_t value; -} mach_nlist; -typedef struct { - uint32_t strx; - uint8_t type, sect; - uint16_t desc; - uint64_t value; -} mach_nlist_64; -typedef struct -{ - uint32_t magic, nfat_arch; -} mach_fat_header; -typedef struct -{ - uint32_t cputype, cpusubtype, offset, size, align; -} mach_fat_arch; -typedef struct { - struct { - mach_header hdr; - mach_segment_command seg; - mach_section sec; - mach_symtab_command sym; - } arch[1]; - mach_nlist sym_entry; - uint8_t space[4096]; -} mach_obj; -typedef struct { - struct { - mach_header_64 hdr; - mach_segment_command_64 seg; - mach_section_64 sec; - mach_symtab_command sym; - } arch[1]; - mach_nlist_64 sym_entry; - uint8_t space[4096]; -} mach_obj_64; -typedef struct { - mach_fat_header fat; - mach_fat_arch fat_arch[4]; - struct { - mach_header hdr; - mach_segment_command seg; - mach_section sec; - mach_symtab_command sym; - } arch[4]; - mach_nlist sym_entry; - uint8_t space[4096]; -} mach_fat_obj; -]] - local symname = '_'..LJBC_PREFIX..ctx.modname - local isfat, is64, align, mobj = false, false, 4, "mach_obj" - if ctx.arch == "x64" then - is64, align, mobj = true, 8, "mach_obj_64" - elseif ctx.arch == "arm" then - isfat, mobj = true, "mach_fat_obj" - else - check(ctx.arch == "x86", "unsupported architecture for OSX") - end - local function aligned(v, a) return bit.band(v+a-1, -a) end - local be32 = bit.bswap -- Mach-O FAT is BE, supported archs are LE. - - -- Create Mach-O object and fill in header. - local o = ffi.new(mobj) - local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, align) - local cputype = ({ x86={7}, x64={0x01000007}, arm={7,12,12,12} })[ctx.arch] - local cpusubtype = ({ x86={3}, x64={3}, arm={3,6,9,11} })[ctx.arch] - if isfat then - o.fat.magic = be32(0xcafebabe) - o.fat.nfat_arch = be32(#cpusubtype) - end - - -- Fill in sections and symbols. - for i=0,#cpusubtype-1 do - local ofs = 0 - if isfat then - local a = o.fat_arch[i] - a.cputype = be32(cputype[i+1]) - a.cpusubtype = be32(cpusubtype[i+1]) - -- Subsequent slices overlap each other to share data. - ofs = ffi.offsetof(o, "arch") + i*ffi.sizeof(o.arch[0]) - a.offset = be32(ofs) - a.size = be32(mach_size-ofs+#s) - end - local a = o.arch[i] - a.hdr.magic = is64 and 0xfeedfacf or 0xfeedface - a.hdr.cputype = cputype[i+1] - a.hdr.cpusubtype = cpusubtype[i+1] - a.hdr.filetype = 1 - a.hdr.ncmds = 2 - a.hdr.sizeofcmds = ffi.sizeof(a.seg)+ffi.sizeof(a.sec)+ffi.sizeof(a.sym) - a.seg.cmd = is64 and 0x19 or 0x1 - a.seg.cmdsize = ffi.sizeof(a.seg)+ffi.sizeof(a.sec) - a.seg.vmsize = #s - a.seg.fileoff = mach_size-ofs - a.seg.filesize = #s - a.seg.maxprot = 1 - a.seg.initprot = 1 - a.seg.nsects = 1 - ffi.copy(a.sec.sectname, "__data") - ffi.copy(a.sec.segname, "__DATA") - a.sec.size = #s - a.sec.offset = mach_size-ofs - a.sym.cmd = 2 - a.sym.cmdsize = ffi.sizeof(a.sym) - a.sym.symoff = ffi.offsetof(o, "sym_entry")-ofs - a.sym.nsyms = 1 - a.sym.stroff = ffi.offsetof(o, "sym_entry")+ffi.sizeof(o.sym_entry)-ofs - a.sym.strsize = aligned(#symname+2, align) - end - o.sym_entry.type = 0xf - o.sym_entry.sect = 1 - o.sym_entry.strx = 1 - ffi.copy(o.space+1, symname) - - -- Write Macho-O object file. - local fp = savefile(output, "wb") - fp:write(ffi.string(o, mach_size)) - bcsave_tail(fp, output, s) -end - -local function bcsave_obj(ctx, output, s) - local ok, ffi = pcall(require, "ffi") - check(ok, "FFI library required to write this file type") - if ctx.os == "windows" then - return bcsave_peobj(ctx, output, s, ffi) - elseif ctx.os == "osx" then - return bcsave_machobj(ctx, output, s, ffi) - else - return bcsave_elfobj(ctx, output, s, ffi) - end -end - ------------------------------------------------------------------------------- - -local function bclist(input, output) - local f = readfile(input) - require("jit.bc").dump(f, savefile(output, "w"), true) -end - -local function bcsave(ctx, input, output) - local f = readfile(input) - local s = string.dump(f, ctx.strip) - local t = ctx.type - if not t then - t = detecttype(output) - ctx.type = t - end - if t == "raw" then - bcsave_raw(output, s) - else - if not ctx.modname then ctx.modname = detectmodname(input) end - if t == "obj" then - bcsave_obj(ctx, output, s) - else - bcsave_c(ctx, output, s) - end - end -end - -local function docmd(...) - local arg = {...} - local n = 1 - local list = false - local ctx = { - strip = true, arch = jit.arch, os = string.lower(jit.os), - type = false, modname = false, - } - while n <= #arg do - local a = arg[n] - if type(a) == "string" and string.sub(a, 1, 1) == "-" and a ~= "-" then - table.remove(arg, n) - if a == "--" then break end - for m=2,#a do - local opt = string.sub(a, m, m) - if opt == "l" then - list = true - elseif opt == "s" then - ctx.strip = true - elseif opt == "g" then - ctx.strip = false - else - if arg[n] == nil or m ~= #a then usage() end - if opt == "e" then - if n ~= 1 then usage() end - arg[1] = check(loadstring(arg[1])) - elseif opt == "n" then - ctx.modname = checkmodname(table.remove(arg, n)) - elseif opt == "t" then - ctx.type = checkarg(table.remove(arg, n), map_type, "file type") - elseif opt == "a" then - ctx.arch = checkarg(table.remove(arg, n), map_arch, "architecture") - elseif opt == "o" then - ctx.os = checkarg(table.remove(arg, n), map_os, "OS name") - else - usage() - end - end - end - else - n = n + 1 - end - end - if list then - if #arg == 0 or #arg > 2 then usage() end - bclist(arg[1], arg[2] or "-") - else - if #arg ~= 2 then usage() end - bcsave(ctx, arg[1], arg[2]) - end -end - ------------------------------------------------------------------------------- - --- Public module functions. -module(...) - -start = docmd -- Process -b command line option. - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_arm.lua b/source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_arm.lua deleted file mode 100644 index b3d0ebc2c..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_arm.lua +++ /dev/null @@ -1,689 +0,0 @@ ----------------------------------------------------------------------------- --- LuaJIT ARM disassembler module. --- --- Copyright (C) 2005-2014 Mike Pall. All rights reserved. --- Released under the MIT license. See Copyright Notice in luajit.h ----------------------------------------------------------------------------- --- This is a helper module used by the LuaJIT machine code dumper module. --- --- It disassembles most user-mode ARMv7 instructions --- NYI: Advanced SIMD and VFP instructions. ------------------------------------------------------------------------------- - -local type = type -local sub, byte, format = string.sub, string.byte, string.format -local match, gmatch, gsub = string.match, string.gmatch, string.gsub -local concat = table.concat -local bit = require("bit") -local band, bor, ror, tohex = bit.band, bit.bor, bit.ror, bit.tohex -local lshift, rshift, arshift = bit.lshift, bit.rshift, bit.arshift - ------------------------------------------------------------------------------- --- Opcode maps ------------------------------------------------------------------------------- - -local map_loadc = { - shift = 8, mask = 15, - [10] = { - shift = 20, mask = 1, - [0] = { - shift = 23, mask = 3, - [0] = "vmovFmDN", "vstmFNdr", - _ = { - shift = 21, mask = 1, - [0] = "vstrFdl", - { shift = 16, mask = 15, [13] = "vpushFdr", _ = "vstmdbFNdr", } - }, - }, - { - shift = 23, mask = 3, - [0] = "vmovFDNm", - { shift = 16, mask = 15, [13] = "vpopFdr", _ = "vldmFNdr", }, - _ = { - shift = 21, mask = 1, - [0] = "vldrFdl", "vldmdbFNdr", - }, - }, - }, - [11] = { - shift = 20, mask = 1, - [0] = { - shift = 23, mask = 3, - [0] = "vmovGmDN", "vstmGNdr", - _ = { - shift = 21, mask = 1, - [0] = "vstrGdl", - { shift = 16, mask = 15, [13] = "vpushGdr", _ = "vstmdbGNdr", } - }, - }, - { - shift = 23, mask = 3, - [0] = "vmovGDNm", - { shift = 16, mask = 15, [13] = "vpopGdr", _ = "vldmGNdr", }, - _ = { - shift = 21, mask = 1, - [0] = "vldrGdl", "vldmdbGNdr", - }, - }, - }, - _ = { - shift = 0, mask = 0 -- NYI ldc, mcrr, mrrc. - }, -} - -local map_vfps = { - shift = 6, mask = 0x2c001, - [0] = "vmlaF.dnm", "vmlsF.dnm", - [0x04000] = "vnmlsF.dnm", [0x04001] = "vnmlaF.dnm", - [0x08000] = "vmulF.dnm", [0x08001] = "vnmulF.dnm", - [0x0c000] = "vaddF.dnm", [0x0c001] = "vsubF.dnm", - [0x20000] = "vdivF.dnm", - [0x24000] = "vfnmsF.dnm", [0x24001] = "vfnmaF.dnm", - [0x28000] = "vfmaF.dnm", [0x28001] = "vfmsF.dnm", - [0x2c000] = "vmovF.dY", - [0x2c001] = { - shift = 7, mask = 0x1e01, - [0] = "vmovF.dm", "vabsF.dm", - [0x0200] = "vnegF.dm", [0x0201] = "vsqrtF.dm", - [0x0800] = "vcmpF.dm", [0x0801] = "vcmpeF.dm", - [0x0a00] = "vcmpzF.d", [0x0a01] = "vcmpzeF.d", - [0x0e01] = "vcvtG.dF.m", - [0x1000] = "vcvt.f32.u32Fdm", [0x1001] = "vcvt.f32.s32Fdm", - [0x1800] = "vcvtr.u32F.dm", [0x1801] = "vcvt.u32F.dm", - [0x1a00] = "vcvtr.s32F.dm", [0x1a01] = "vcvt.s32F.dm", - }, -} - -local map_vfpd = { - shift = 6, mask = 0x2c001, - [0] = "vmlaG.dnm", "vmlsG.dnm", - [0x04000] = "vnmlsG.dnm", [0x04001] = "vnmlaG.dnm", - [0x08000] = "vmulG.dnm", [0x08001] = "vnmulG.dnm", - [0x0c000] = "vaddG.dnm", [0x0c001] = "vsubG.dnm", - [0x20000] = "vdivG.dnm", - [0x24000] = "vfnmsG.dnm", [0x24001] = "vfnmaG.dnm", - [0x28000] = "vfmaG.dnm", [0x28001] = "vfmsG.dnm", - [0x2c000] = "vmovG.dY", - [0x2c001] = { - shift = 7, mask = 0x1e01, - [0] = "vmovG.dm", "vabsG.dm", - [0x0200] = "vnegG.dm", [0x0201] = "vsqrtG.dm", - [0x0800] = "vcmpG.dm", [0x0801] = "vcmpeG.dm", - [0x0a00] = "vcmpzG.d", [0x0a01] = "vcmpzeG.d", - [0x0e01] = "vcvtF.dG.m", - [0x1000] = "vcvt.f64.u32GdFm", [0x1001] = "vcvt.f64.s32GdFm", - [0x1800] = "vcvtr.u32FdG.m", [0x1801] = "vcvt.u32FdG.m", - [0x1a00] = "vcvtr.s32FdG.m", [0x1a01] = "vcvt.s32FdG.m", - }, -} - -local map_datac = { - shift = 24, mask = 1, - [0] = { - shift = 4, mask = 1, - [0] = { - shift = 8, mask = 15, - [10] = map_vfps, - [11] = map_vfpd, - -- NYI cdp, mcr, mrc. - }, - { - shift = 8, mask = 15, - [10] = { - shift = 20, mask = 15, - [0] = "vmovFnD", "vmovFDn", - [14] = "vmsrD", - [15] = { shift = 12, mask = 15, [15] = "vmrs", _ = "vmrsD", }, - }, - }, - }, - "svcT", -} - -local map_loadcu = { - shift = 0, mask = 0, -- NYI unconditional CP load/store. -} - -local map_datacu = { - shift = 0, mask = 0, -- NYI unconditional CP data. -} - -local map_simddata = { - shift = 0, mask = 0, -- NYI SIMD data. -} - -local map_simdload = { - shift = 0, mask = 0, -- NYI SIMD load/store, preload. -} - -local map_preload = { - shift = 0, mask = 0, -- NYI preload. -} - -local map_media = { - shift = 20, mask = 31, - [0] = false, - { --01 - shift = 5, mask = 7, - [0] = "sadd16DNM", "sasxDNM", "ssaxDNM", "ssub16DNM", - "sadd8DNM", false, false, "ssub8DNM", - }, - { --02 - shift = 5, mask = 7, - [0] = "qadd16DNM", "qasxDNM", "qsaxDNM", "qsub16DNM", - "qadd8DNM", false, false, "qsub8DNM", - }, - { --03 - shift = 5, mask = 7, - [0] = "shadd16DNM", "shasxDNM", "shsaxDNM", "shsub16DNM", - "shadd8DNM", false, false, "shsub8DNM", - }, - false, - { --05 - shift = 5, mask = 7, - [0] = "uadd16DNM", "uasxDNM", "usaxDNM", "usub16DNM", - "uadd8DNM", false, false, "usub8DNM", - }, - { --06 - shift = 5, mask = 7, - [0] = "uqadd16DNM", "uqasxDNM", "uqsaxDNM", "uqsub16DNM", - "uqadd8DNM", false, false, "uqsub8DNM", - }, - { --07 - shift = 5, mask = 7, - [0] = "uhadd16DNM", "uhasxDNM", "uhsaxDNM", "uhsub16DNM", - "uhadd8DNM", false, false, "uhsub8DNM", - }, - { --08 - shift = 5, mask = 7, - [0] = "pkhbtDNMU", false, "pkhtbDNMU", - { shift = 16, mask = 15, [15] = "sxtb16DMU", _ = "sxtab16DNMU", }, - "pkhbtDNMU", "selDNM", "pkhtbDNMU", - }, - false, - { --0a - shift = 5, mask = 7, - [0] = "ssatDxMu", "ssat16DxM", "ssatDxMu", - { shift = 16, mask = 15, [15] = "sxtbDMU", _ = "sxtabDNMU", }, - "ssatDxMu", false, "ssatDxMu", - }, - { --0b - shift = 5, mask = 7, - [0] = "ssatDxMu", "revDM", "ssatDxMu", - { shift = 16, mask = 15, [15] = "sxthDMU", _ = "sxtahDNMU", }, - "ssatDxMu", "rev16DM", "ssatDxMu", - }, - { --0c - shift = 5, mask = 7, - [3] = { shift = 16, mask = 15, [15] = "uxtb16DMU", _ = "uxtab16DNMU", }, - }, - false, - { --0e - shift = 5, mask = 7, - [0] = "usatDwMu", "usat16DwM", "usatDwMu", - { shift = 16, mask = 15, [15] = "uxtbDMU", _ = "uxtabDNMU", }, - "usatDwMu", false, "usatDwMu", - }, - { --0f - shift = 5, mask = 7, - [0] = "usatDwMu", "rbitDM", "usatDwMu", - { shift = 16, mask = 15, [15] = "uxthDMU", _ = "uxtahDNMU", }, - "usatDwMu", "revshDM", "usatDwMu", - }, - { --10 - shift = 12, mask = 15, - [15] = { - shift = 5, mask = 7, - "smuadNMS", "smuadxNMS", "smusdNMS", "smusdxNMS", - }, - _ = { - shift = 5, mask = 7, - [0] = "smladNMSD", "smladxNMSD", "smlsdNMSD", "smlsdxNMSD", - }, - }, - false, false, false, - { --14 - shift = 5, mask = 7, - [0] = "smlaldDNMS", "smlaldxDNMS", "smlsldDNMS", "smlsldxDNMS", - }, - { --15 - shift = 5, mask = 7, - [0] = { shift = 12, mask = 15, [15] = "smmulNMS", _ = "smmlaNMSD", }, - { shift = 12, mask = 15, [15] = "smmulrNMS", _ = "smmlarNMSD", }, - false, false, false, false, - "smmlsNMSD", "smmlsrNMSD", - }, - false, false, - { --18 - shift = 5, mask = 7, - [0] = { shift = 12, mask = 15, [15] = "usad8NMS", _ = "usada8NMSD", }, - }, - false, - { --1a - shift = 5, mask = 3, [2] = "sbfxDMvw", - }, - { --1b - shift = 5, mask = 3, [2] = "sbfxDMvw", - }, - { --1c - shift = 5, mask = 3, - [0] = { shift = 0, mask = 15, [15] = "bfcDvX", _ = "bfiDMvX", }, - }, - { --1d - shift = 5, mask = 3, - [0] = { shift = 0, mask = 15, [15] = "bfcDvX", _ = "bfiDMvX", }, - }, - { --1e - shift = 5, mask = 3, [2] = "ubfxDMvw", - }, - { --1f - shift = 5, mask = 3, [2] = "ubfxDMvw", - }, -} - -local map_load = { - shift = 21, mask = 9, - { - shift = 20, mask = 5, - [0] = "strtDL", "ldrtDL", [4] = "strbtDL", [5] = "ldrbtDL", - }, - _ = { - shift = 20, mask = 5, - [0] = "strDL", "ldrDL", [4] = "strbDL", [5] = "ldrbDL", - } -} - -local map_load1 = { - shift = 4, mask = 1, - [0] = map_load, map_media, -} - -local map_loadm = { - shift = 20, mask = 1, - [0] = { - shift = 23, mask = 3, - [0] = "stmdaNR", "stmNR", - { shift = 16, mask = 63, [45] = "pushR", _ = "stmdbNR", }, "stmibNR", - }, - { - shift = 23, mask = 3, - [0] = "ldmdaNR", { shift = 16, mask = 63, [61] = "popR", _ = "ldmNR", }, - "ldmdbNR", "ldmibNR", - }, -} - -local map_data = { - shift = 21, mask = 15, - [0] = "andDNPs", "eorDNPs", "subDNPs", "rsbDNPs", - "addDNPs", "adcDNPs", "sbcDNPs", "rscDNPs", - "tstNP", "teqNP", "cmpNP", "cmnNP", - "orrDNPs", "movDPs", "bicDNPs", "mvnDPs", -} - -local map_mul = { - shift = 21, mask = 7, - [0] = "mulNMSs", "mlaNMSDs", "umaalDNMS", "mlsDNMS", - "umullDNMSs", "umlalDNMSs", "smullDNMSs", "smlalDNMSs", -} - -local map_sync = { - shift = 20, mask = 15, -- NYI: brackets around N. R(D+1) for ldrexd/strexd. - [0] = "swpDMN", false, false, false, - "swpbDMN", false, false, false, - "strexDMN", "ldrexDN", "strexdDN", "ldrexdDN", - "strexbDMN", "ldrexbDN", "strexhDN", "ldrexhDN", -} - -local map_mulh = { - shift = 21, mask = 3, - [0] = { shift = 5, mask = 3, - [0] = "smlabbNMSD", "smlatbNMSD", "smlabtNMSD", "smlattNMSD", }, - { shift = 5, mask = 3, - [0] = "smlawbNMSD", "smulwbNMS", "smlawtNMSD", "smulwtNMS", }, - { shift = 5, mask = 3, - [0] = "smlalbbDNMS", "smlaltbDNMS", "smlalbtDNMS", "smlalttDNMS", }, - { shift = 5, mask = 3, - [0] = "smulbbNMS", "smultbNMS", "smulbtNMS", "smulttNMS", }, -} - -local map_misc = { - shift = 4, mask = 7, - -- NYI: decode PSR bits of msr. - [0] = { shift = 21, mask = 1, [0] = "mrsD", "msrM", }, - { shift = 21, mask = 3, "bxM", false, "clzDM", }, - { shift = 21, mask = 3, "bxjM", }, - { shift = 21, mask = 3, "blxM", }, - false, - { shift = 21, mask = 3, [0] = "qaddDMN", "qsubDMN", "qdaddDMN", "qdsubDMN", }, - false, - { shift = 21, mask = 3, "bkptK", }, -} - -local map_datar = { - shift = 4, mask = 9, - [9] = { - shift = 5, mask = 3, - [0] = { shift = 24, mask = 1, [0] = map_mul, map_sync, }, - { shift = 20, mask = 1, [0] = "strhDL", "ldrhDL", }, - { shift = 20, mask = 1, [0] = "ldrdDL", "ldrsbDL", }, - { shift = 20, mask = 1, [0] = "strdDL", "ldrshDL", }, - }, - _ = { - shift = 20, mask = 25, - [16] = { shift = 7, mask = 1, [0] = map_misc, map_mulh, }, - _ = { - shift = 0, mask = 0xffffffff, - [bor(0xe1a00000)] = "nop", - _ = map_data, - } - }, -} - -local map_datai = { - shift = 20, mask = 31, -- NYI: decode PSR bits of msr. Decode imm12. - [16] = "movwDW", [20] = "movtDW", - [18] = { shift = 0, mask = 0xf00ff, [0] = "nopv6", _ = "msrNW", }, - [22] = "msrNW", - _ = map_data, -} - -local map_branch = { - shift = 24, mask = 1, - [0] = "bB", "blB" -} - -local map_condins = { - [0] = map_datar, map_datai, map_load, map_load1, - map_loadm, map_branch, map_loadc, map_datac -} - --- NYI: setend. -local map_uncondins = { - [0] = false, map_simddata, map_simdload, map_preload, - false, "blxB", map_loadcu, map_datacu, -} - ------------------------------------------------------------------------------- - -local map_gpr = { - [0] = "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", - "r8", "r9", "r10", "r11", "r12", "sp", "lr", "pc", -} - -local map_cond = { - [0] = "eq", "ne", "hs", "lo", "mi", "pl", "vs", "vc", - "hi", "ls", "ge", "lt", "gt", "le", "al", -} - -local map_shift = { [0] = "lsl", "lsr", "asr", "ror", } - ------------------------------------------------------------------------------- - --- Output a nicely formatted line with an opcode and operands. -local function putop(ctx, text, operands) - local pos = ctx.pos - local extra = "" - if ctx.rel then - local sym = ctx.symtab[ctx.rel] - if sym then - extra = "\t->"..sym - elseif band(ctx.op, 0x0e000000) ~= 0x0a000000 then - extra = "\t; 0x"..tohex(ctx.rel) - end - end - if ctx.hexdump > 0 then - ctx.out(format("%08x %s %-5s %s%s\n", - ctx.addr+pos, tohex(ctx.op), text, concat(operands, ", "), extra)) - else - ctx.out(format("%08x %-5s %s%s\n", - ctx.addr+pos, text, concat(operands, ", "), extra)) - end - ctx.pos = pos + 4 -end - --- Fallback for unknown opcodes. -local function unknown(ctx) - return putop(ctx, ".long", { "0x"..tohex(ctx.op) }) -end - --- Format operand 2 of load/store opcodes. -local function fmtload(ctx, op, pos) - local base = map_gpr[band(rshift(op, 16), 15)] - local x, ofs - local ext = (band(op, 0x04000000) == 0) - if not ext and band(op, 0x02000000) == 0 then - ofs = band(op, 4095) - if band(op, 0x00800000) == 0 then ofs = -ofs end - if base == "pc" then ctx.rel = ctx.addr + pos + 8 + ofs end - ofs = "#"..ofs - elseif ext and band(op, 0x00400000) ~= 0 then - ofs = band(op, 15) + band(rshift(op, 4), 0xf0) - if band(op, 0x00800000) == 0 then ofs = -ofs end - if base == "pc" then ctx.rel = ctx.addr + pos + 8 + ofs end - ofs = "#"..ofs - else - ofs = map_gpr[band(op, 15)] - if ext or band(op, 0xfe0) == 0 then - elseif band(op, 0xfe0) == 0x60 then - ofs = format("%s, rrx", ofs) - else - local sh = band(rshift(op, 7), 31) - if sh == 0 then sh = 32 end - ofs = format("%s, %s #%d", ofs, map_shift[band(rshift(op, 5), 3)], sh) - end - if band(op, 0x00800000) == 0 then ofs = "-"..ofs end - end - if ofs == "#0" then - x = format("[%s]", base) - elseif band(op, 0x01000000) == 0 then - x = format("[%s], %s", base, ofs) - else - x = format("[%s, %s]", base, ofs) - end - if band(op, 0x01200000) == 0x01200000 then x = x.."!" end - return x -end - --- Format operand 2 of vector load/store opcodes. -local function fmtvload(ctx, op, pos) - local base = map_gpr[band(rshift(op, 16), 15)] - local ofs = band(op, 255)*4 - if band(op, 0x00800000) == 0 then ofs = -ofs end - if base == "pc" then ctx.rel = ctx.addr + pos + 8 + ofs end - if ofs == 0 then - return format("[%s]", base) - else - return format("[%s, #%d]", base, ofs) - end -end - -local function fmtvr(op, vr, sh0, sh1) - if vr == "s" then - return format("s%d", 2*band(rshift(op, sh0), 15)+band(rshift(op, sh1), 1)) - else - return format("d%d", band(rshift(op, sh0), 15)+band(rshift(op, sh1-4), 16)) - end -end - --- Disassemble a single instruction. -local function disass_ins(ctx) - local pos = ctx.pos - local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4) - local op = bor(lshift(b3, 24), lshift(b2, 16), lshift(b1, 8), b0) - local operands = {} - local suffix = "" - local last, name, pat - local vr - ctx.op = op - ctx.rel = nil - - local cond = rshift(op, 28) - local opat - if cond == 15 then - opat = map_uncondins[band(rshift(op, 25), 7)] - else - if cond ~= 14 then suffix = map_cond[cond] end - opat = map_condins[band(rshift(op, 25), 7)] - end - while type(opat) ~= "string" do - if not opat then return unknown(ctx) end - opat = opat[band(rshift(op, opat.shift), opat.mask)] or opat._ - end - name, pat = match(opat, "^([a-z0-9]*)(.*)") - if sub(pat, 1, 1) == "." then - local s2, p2 = match(pat, "^([a-z0-9.]*)(.*)") - suffix = suffix..s2 - pat = p2 - end - - for p in gmatch(pat, ".") do - local x = nil - if p == "D" then - x = map_gpr[band(rshift(op, 12), 15)] - elseif p == "N" then - x = map_gpr[band(rshift(op, 16), 15)] - elseif p == "S" then - x = map_gpr[band(rshift(op, 8), 15)] - elseif p == "M" then - x = map_gpr[band(op, 15)] - elseif p == "d" then - x = fmtvr(op, vr, 12, 22) - elseif p == "n" then - x = fmtvr(op, vr, 16, 7) - elseif p == "m" then - x = fmtvr(op, vr, 0, 5) - elseif p == "P" then - if band(op, 0x02000000) ~= 0 then - x = ror(band(op, 255), 2*band(rshift(op, 8), 15)) - else - x = map_gpr[band(op, 15)] - if band(op, 0xff0) ~= 0 then - operands[#operands+1] = x - local s = map_shift[band(rshift(op, 5), 3)] - local r = nil - if band(op, 0xf90) == 0 then - if s == "ror" then s = "rrx" else r = "#32" end - elseif band(op, 0x10) == 0 then - r = "#"..band(rshift(op, 7), 31) - else - r = map_gpr[band(rshift(op, 8), 15)] - end - if name == "mov" then name = s; x = r - elseif r then x = format("%s %s", s, r) - else x = s end - end - end - elseif p == "L" then - x = fmtload(ctx, op, pos) - elseif p == "l" then - x = fmtvload(ctx, op, pos) - elseif p == "B" then - local addr = ctx.addr + pos + 8 + arshift(lshift(op, 8), 6) - if cond == 15 then addr = addr + band(rshift(op, 23), 2) end - ctx.rel = addr - x = "0x"..tohex(addr) - elseif p == "F" then - vr = "s" - elseif p == "G" then - vr = "d" - elseif p == "." then - suffix = suffix..(vr == "s" and ".f32" or ".f64") - elseif p == "R" then - if band(op, 0x00200000) ~= 0 and #operands == 1 then - operands[1] = operands[1].."!" - end - local t = {} - for i=0,15 do - if band(rshift(op, i), 1) == 1 then t[#t+1] = map_gpr[i] end - end - x = "{"..concat(t, ", ").."}" - elseif p == "r" then - if band(op, 0x00200000) ~= 0 and #operands == 2 then - operands[1] = operands[1].."!" - end - local s = tonumber(sub(last, 2)) - local n = band(op, 255) - if vr == "d" then n = rshift(n, 1) end - operands[#operands] = format("{%s-%s%d}", last, vr, s+n-1) - elseif p == "W" then - x = band(op, 0x0fff) + band(rshift(op, 4), 0xf000) - elseif p == "T" then - x = "#0x"..tohex(band(op, 0x00ffffff), 6) - elseif p == "U" then - x = band(rshift(op, 7), 31) - if x == 0 then x = nil end - elseif p == "u" then - x = band(rshift(op, 7), 31) - if band(op, 0x40) == 0 then - if x == 0 then x = nil else x = "lsl #"..x end - else - if x == 0 then x = "asr #32" else x = "asr #"..x end - end - elseif p == "v" then - x = band(rshift(op, 7), 31) - elseif p == "w" then - x = band(rshift(op, 16), 31) - elseif p == "x" then - x = band(rshift(op, 16), 31) + 1 - elseif p == "X" then - x = band(rshift(op, 16), 31) - last + 1 - elseif p == "Y" then - x = band(rshift(op, 12), 0xf0) + band(op, 0x0f) - elseif p == "K" then - x = "#0x"..tohex(band(rshift(op, 4), 0x0000fff0) + band(op, 15), 4) - elseif p == "s" then - if band(op, 0x00100000) ~= 0 then suffix = "s"..suffix end - else - assert(false) - end - if x then - last = x - if type(x) == "number" then x = "#"..x end - operands[#operands+1] = x - end - end - - return putop(ctx, name..suffix, operands) -end - ------------------------------------------------------------------------------- - --- Disassemble a block of code. -local function disass_block(ctx, ofs, len) - if not ofs then ofs = 0 end - local stop = len and ofs+len or #ctx.code - ctx.pos = ofs - ctx.rel = nil - while ctx.pos < stop do disass_ins(ctx) end -end - --- Extended API: create a disassembler context. Then call ctx:disass(ofs, len). -local function create_(code, addr, out) - local ctx = {} - ctx.code = code - ctx.addr = addr or 0 - ctx.out = out or io.write - ctx.symtab = {} - ctx.disass = disass_block - ctx.hexdump = 8 - return ctx -end - --- Simple API: disassemble code (a string) at address and output via out. -local function disass_(code, addr, out) - create_(code, addr, out):disass() -end - --- Return register name for RID. -local function regname_(r) - if r < 16 then return map_gpr[r] end - return "d"..(r-16) -end - --- Public module functions. -module(...) - -create = create_ -disass = disass_ -regname = regname_ - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_mips.lua b/source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_mips.lua deleted file mode 100644 index 47a7a83bc..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_mips.lua +++ /dev/null @@ -1,428 +0,0 @@ ----------------------------------------------------------------------------- --- LuaJIT MIPS disassembler module. --- --- Copyright (C) 2005-2014 Mike Pall. All rights reserved. --- Released under the MIT/X license. See Copyright Notice in luajit.h ----------------------------------------------------------------------------- --- This is a helper module used by the LuaJIT machine code dumper module. --- --- It disassembles all standard MIPS32R1/R2 instructions. --- Default mode is big-endian, but see: dis_mipsel.lua ------------------------------------------------------------------------------- - -local type = type -local sub, byte, format = string.sub, string.byte, string.format -local match, gmatch, gsub = string.match, string.gmatch, string.gsub -local concat = table.concat -local bit = require("bit") -local band, bor, tohex = bit.band, bit.bor, bit.tohex -local lshift, rshift, arshift = bit.lshift, bit.rshift, bit.arshift - ------------------------------------------------------------------------------- --- Primary and extended opcode maps ------------------------------------------------------------------------------- - -local map_movci = { shift = 16, mask = 1, [0] = "movfDSC", "movtDSC", } -local map_srl = { shift = 21, mask = 1, [0] = "srlDTA", "rotrDTA", } -local map_srlv = { shift = 6, mask = 1, [0] = "srlvDTS", "rotrvDTS", } - -local map_special = { - shift = 0, mask = 63, - [0] = { shift = 0, mask = -1, [0] = "nop", _ = "sllDTA" }, - map_movci, map_srl, "sraDTA", - "sllvDTS", false, map_srlv, "sravDTS", - "jrS", "jalrD1S", "movzDST", "movnDST", - "syscallY", "breakY", false, "sync", - "mfhiD", "mthiS", "mfloD", "mtloS", - false, false, false, false, - "multST", "multuST", "divST", "divuST", - false, false, false, false, - "addDST", "addu|moveDST0", "subDST", "subu|neguDS0T", - "andDST", "orDST", "xorDST", "nor|notDST0", - false, false, "sltDST", "sltuDST", - false, false, false, false, - "tgeSTZ", "tgeuSTZ", "tltSTZ", "tltuSTZ", - "teqSTZ", false, "tneSTZ", -} - -local map_special2 = { - shift = 0, mask = 63, - [0] = "maddST", "madduST", "mulDST", false, - "msubST", "msubuST", - [32] = "clzDS", [33] = "cloDS", - [63] = "sdbbpY", -} - -local map_bshfl = { - shift = 6, mask = 31, - [2] = "wsbhDT", - [16] = "sebDT", - [24] = "sehDT", -} - -local map_special3 = { - shift = 0, mask = 63, - [0] = "extTSAK", [4] = "insTSAL", - [32] = map_bshfl, - [59] = "rdhwrTD", -} - -local map_regimm = { - shift = 16, mask = 31, - [0] = "bltzSB", "bgezSB", "bltzlSB", "bgezlSB", - false, false, false, false, - "tgeiSI", "tgeiuSI", "tltiSI", "tltiuSI", - "teqiSI", false, "tneiSI", false, - "bltzalSB", "bgezalSB", "bltzallSB", "bgezallSB", - false, false, false, false, - false, false, false, false, - false, false, false, "synciSO", -} - -local map_cop0 = { - shift = 25, mask = 1, - [0] = { - shift = 21, mask = 15, - [0] = "mfc0TDW", [4] = "mtc0TDW", - [10] = "rdpgprDT", - [11] = { shift = 5, mask = 1, [0] = "diT0", "eiT0", }, - [14] = "wrpgprDT", - }, { - shift = 0, mask = 63, - [1] = "tlbr", [2] = "tlbwi", [6] = "tlbwr", [8] = "tlbp", - [24] = "eret", [31] = "deret", - [32] = "wait", - }, -} - -local map_cop1s = { - shift = 0, mask = 63, - [0] = "add.sFGH", "sub.sFGH", "mul.sFGH", "div.sFGH", - "sqrt.sFG", "abs.sFG", "mov.sFG", "neg.sFG", - "round.l.sFG", "trunc.l.sFG", "ceil.l.sFG", "floor.l.sFG", - "round.w.sFG", "trunc.w.sFG", "ceil.w.sFG", "floor.w.sFG", - false, - { shift = 16, mask = 1, [0] = "movf.sFGC", "movt.sFGC" }, - "movz.sFGT", "movn.sFGT", - false, "recip.sFG", "rsqrt.sFG", false, - false, false, false, false, - false, false, false, false, - false, "cvt.d.sFG", false, false, - "cvt.w.sFG", "cvt.l.sFG", "cvt.ps.sFGH", false, - false, false, false, false, - false, false, false, false, - "c.f.sVGH", "c.un.sVGH", "c.eq.sVGH", "c.ueq.sVGH", - "c.olt.sVGH", "c.ult.sVGH", "c.ole.sVGH", "c.ule.sVGH", - "c.sf.sVGH", "c.ngle.sVGH", "c.seq.sVGH", "c.ngl.sVGH", - "c.lt.sVGH", "c.nge.sVGH", "c.le.sVGH", "c.ngt.sVGH", -} - -local map_cop1d = { - shift = 0, mask = 63, - [0] = "add.dFGH", "sub.dFGH", "mul.dFGH", "div.dFGH", - "sqrt.dFG", "abs.dFG", "mov.dFG", "neg.dFG", - "round.l.dFG", "trunc.l.dFG", "ceil.l.dFG", "floor.l.dFG", - "round.w.dFG", "trunc.w.dFG", "ceil.w.dFG", "floor.w.dFG", - false, - { shift = 16, mask = 1, [0] = "movf.dFGC", "movt.dFGC" }, - "movz.dFGT", "movn.dFGT", - false, "recip.dFG", "rsqrt.dFG", false, - false, false, false, false, - false, false, false, false, - "cvt.s.dFG", false, false, false, - "cvt.w.dFG", "cvt.l.dFG", false, false, - false, false, false, false, - false, false, false, false, - "c.f.dVGH", "c.un.dVGH", "c.eq.dVGH", "c.ueq.dVGH", - "c.olt.dVGH", "c.ult.dVGH", "c.ole.dVGH", "c.ule.dVGH", - "c.df.dVGH", "c.ngle.dVGH", "c.deq.dVGH", "c.ngl.dVGH", - "c.lt.dVGH", "c.nge.dVGH", "c.le.dVGH", "c.ngt.dVGH", -} - -local map_cop1ps = { - shift = 0, mask = 63, - [0] = "add.psFGH", "sub.psFGH", "mul.psFGH", false, - false, "abs.psFG", "mov.psFG", "neg.psFG", - false, false, false, false, - false, false, false, false, - false, - { shift = 16, mask = 1, [0] = "movf.psFGC", "movt.psFGC" }, - "movz.psFGT", "movn.psFGT", - false, false, false, false, - false, false, false, false, - false, false, false, false, - "cvt.s.puFG", false, false, false, - false, false, false, false, - "cvt.s.plFG", false, false, false, - "pll.psFGH", "plu.psFGH", "pul.psFGH", "puu.psFGH", - "c.f.psVGH", "c.un.psVGH", "c.eq.psVGH", "c.ueq.psVGH", - "c.olt.psVGH", "c.ult.psVGH", "c.ole.psVGH", "c.ule.psVGH", - "c.psf.psVGH", "c.ngle.psVGH", "c.pseq.psVGH", "c.ngl.psVGH", - "c.lt.psVGH", "c.nge.psVGH", "c.le.psVGH", "c.ngt.psVGH", -} - -local map_cop1w = { - shift = 0, mask = 63, - [32] = "cvt.s.wFG", [33] = "cvt.d.wFG", -} - -local map_cop1l = { - shift = 0, mask = 63, - [32] = "cvt.s.lFG", [33] = "cvt.d.lFG", -} - -local map_cop1bc = { - shift = 16, mask = 3, - [0] = "bc1fCB", "bc1tCB", "bc1flCB", "bc1tlCB", -} - -local map_cop1 = { - shift = 21, mask = 31, - [0] = "mfc1TG", false, "cfc1TG", "mfhc1TG", - "mtc1TG", false, "ctc1TG", "mthc1TG", - map_cop1bc, false, false, false, - false, false, false, false, - map_cop1s, map_cop1d, false, false, - map_cop1w, map_cop1l, map_cop1ps, -} - -local map_cop1x = { - shift = 0, mask = 63, - [0] = "lwxc1FSX", "ldxc1FSX", false, false, - false, "luxc1FSX", false, false, - "swxc1FSX", "sdxc1FSX", false, false, - false, "suxc1FSX", false, "prefxMSX", - false, false, false, false, - false, false, false, false, - false, false, false, false, - false, false, "alnv.psFGHS", false, - "madd.sFRGH", "madd.dFRGH", false, false, - false, false, "madd.psFRGH", false, - "msub.sFRGH", "msub.dFRGH", false, false, - false, false, "msub.psFRGH", false, - "nmadd.sFRGH", "nmadd.dFRGH", false, false, - false, false, "nmadd.psFRGH", false, - "nmsub.sFRGH", "nmsub.dFRGH", false, false, - false, false, "nmsub.psFRGH", false, -} - -local map_pri = { - [0] = map_special, map_regimm, "jJ", "jalJ", - "beq|beqz|bST00B", "bne|bnezST0B", "blezSB", "bgtzSB", - "addiTSI", "addiu|liTS0I", "sltiTSI", "sltiuTSI", - "andiTSU", "ori|liTS0U", "xoriTSU", "luiTU", - map_cop0, map_cop1, false, map_cop1x, - "beql|beqzlST0B", "bnel|bnezlST0B", "blezlSB", "bgtzlSB", - false, false, false, false, - map_special2, false, false, map_special3, - "lbTSO", "lhTSO", "lwlTSO", "lwTSO", - "lbuTSO", "lhuTSO", "lwrTSO", false, - "sbTSO", "shTSO", "swlTSO", "swTSO", - false, false, "swrTSO", "cacheNSO", - "llTSO", "lwc1HSO", "lwc2TSO", "prefNSO", - false, "ldc1HSO", "ldc2TSO", false, - "scTSO", "swc1HSO", "swc2TSO", false, - false, "sdc1HSO", "sdc2TSO", false, -} - ------------------------------------------------------------------------------- - -local map_gpr = { - [0] = "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", - "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", - "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", - "r24", "r25", "r26", "r27", "r28", "sp", "r30", "ra", -} - ------------------------------------------------------------------------------- - --- Output a nicely formatted line with an opcode and operands. -local function putop(ctx, text, operands) - local pos = ctx.pos - local extra = "" - if ctx.rel then - local sym = ctx.symtab[ctx.rel] - if sym then extra = "\t->"..sym end - end - if ctx.hexdump > 0 then - ctx.out(format("%08x %s %-7s %s%s\n", - ctx.addr+pos, tohex(ctx.op), text, concat(operands, ", "), extra)) - else - ctx.out(format("%08x %-7s %s%s\n", - ctx.addr+pos, text, concat(operands, ", "), extra)) - end - ctx.pos = pos + 4 -end - --- Fallback for unknown opcodes. -local function unknown(ctx) - return putop(ctx, ".long", { "0x"..tohex(ctx.op) }) -end - -local function get_be(ctx) - local pos = ctx.pos - local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4) - return bor(lshift(b0, 24), lshift(b1, 16), lshift(b2, 8), b3) -end - -local function get_le(ctx) - local pos = ctx.pos - local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4) - return bor(lshift(b3, 24), lshift(b2, 16), lshift(b1, 8), b0) -end - --- Disassemble a single instruction. -local function disass_ins(ctx) - local op = ctx:get() - local operands = {} - local last = nil - ctx.op = op - ctx.rel = nil - - local opat = map_pri[rshift(op, 26)] - while type(opat) ~= "string" do - if not opat then return unknown(ctx) end - opat = opat[band(rshift(op, opat.shift), opat.mask)] or opat._ - end - local name, pat = match(opat, "^([a-z0-9_.]*)(.*)") - local altname, pat2 = match(pat, "|([a-z0-9_.|]*)(.*)") - if altname then pat = pat2 end - - for p in gmatch(pat, ".") do - local x = nil - if p == "S" then - x = map_gpr[band(rshift(op, 21), 31)] - elseif p == "T" then - x = map_gpr[band(rshift(op, 16), 31)] - elseif p == "D" then - x = map_gpr[band(rshift(op, 11), 31)] - elseif p == "F" then - x = "f"..band(rshift(op, 6), 31) - elseif p == "G" then - x = "f"..band(rshift(op, 11), 31) - elseif p == "H" then - x = "f"..band(rshift(op, 16), 31) - elseif p == "R" then - x = "f"..band(rshift(op, 21), 31) - elseif p == "A" then - x = band(rshift(op, 6), 31) - elseif p == "M" then - x = band(rshift(op, 11), 31) - elseif p == "N" then - x = band(rshift(op, 16), 31) - elseif p == "C" then - x = band(rshift(op, 18), 7) - if x == 0 then x = nil end - elseif p == "K" then - x = band(rshift(op, 11), 31) + 1 - elseif p == "L" then - x = band(rshift(op, 11), 31) - last + 1 - elseif p == "I" then - x = arshift(lshift(op, 16), 16) - elseif p == "U" then - x = band(op, 0xffff) - elseif p == "O" then - local disp = arshift(lshift(op, 16), 16) - operands[#operands] = format("%d(%s)", disp, last) - elseif p == "X" then - local index = map_gpr[band(rshift(op, 16), 31)] - operands[#operands] = format("%s(%s)", index, last) - elseif p == "B" then - x = ctx.addr + ctx.pos + arshift(lshift(op, 16), 16)*4 + 4 - ctx.rel = x - x = "0x"..tohex(x) - elseif p == "J" then - x = band(ctx.addr + ctx.pos, 0xf0000000) + band(op, 0x03ffffff)*4 - ctx.rel = x - x = "0x"..tohex(x) - elseif p == "V" then - x = band(rshift(op, 8), 7) - if x == 0 then x = nil end - elseif p == "W" then - x = band(op, 7) - if x == 0 then x = nil end - elseif p == "Y" then - x = band(rshift(op, 6), 0x000fffff) - if x == 0 then x = nil end - elseif p == "Z" then - x = band(rshift(op, 6), 1023) - if x == 0 then x = nil end - elseif p == "0" then - if last == "r0" or last == 0 then - local n = #operands - operands[n] = nil - last = operands[n-1] - if altname then - local a1, a2 = match(altname, "([^|]*)|(.*)") - if a1 then name, altname = a1, a2 - else name = altname end - end - end - elseif p == "1" then - if last == "ra" then - operands[#operands] = nil - end - else - assert(false) - end - if x then operands[#operands+1] = x; last = x end - end - - return putop(ctx, name, operands) -end - ------------------------------------------------------------------------------- - --- Disassemble a block of code. -local function disass_block(ctx, ofs, len) - if not ofs then ofs = 0 end - local stop = len and ofs+len or #ctx.code - stop = stop - stop % 4 - ctx.pos = ofs - ofs % 4 - ctx.rel = nil - while ctx.pos < stop do disass_ins(ctx) end -end - --- Extended API: create a disassembler context. Then call ctx:disass(ofs, len). -local function create_(code, addr, out) - local ctx = {} - ctx.code = code - ctx.addr = addr or 0 - ctx.out = out or io.write - ctx.symtab = {} - ctx.disass = disass_block - ctx.hexdump = 8 - ctx.get = get_be - return ctx -end - -local function create_el_(code, addr, out) - local ctx = create_(code, addr, out) - ctx.get = get_le - return ctx -end - --- Simple API: disassemble code (a string) at address and output via out. -local function disass_(code, addr, out) - create_(code, addr, out):disass() -end - -local function disass_el_(code, addr, out) - create_el_(code, addr, out):disass() -end - --- Return register name for RID. -local function regname_(r) - if r < 32 then return map_gpr[r] end - return "f"..(r-32) -end - --- Public module functions. -module(...) - -create = create_ -create_el = create_el_ -disass = disass_ -disass_el = disass_el_ -regname = regname_ - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_mipsel.lua b/source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_mipsel.lua deleted file mode 100644 index d19de3193..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_mipsel.lua +++ /dev/null @@ -1,20 +0,0 @@ ----------------------------------------------------------------------------- --- LuaJIT MIPSEL disassembler wrapper module. --- --- Copyright (C) 2005-2014 Mike Pall. All rights reserved. --- Released under the MIT license. See Copyright Notice in luajit.h ----------------------------------------------------------------------------- --- This module just exports the little-endian functions from the --- MIPS disassembler module. All the interesting stuff is there. ------------------------------------------------------------------------------- - -local require = require - -module(...) - -local dis_mips = require(_PACKAGE.."dis_mips") - -create = dis_mips.create_el -disass = dis_mips.disass_el -regname = dis_mips.regname - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_ppc.lua b/source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_ppc.lua deleted file mode 100644 index cfaf982fa..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_ppc.lua +++ /dev/null @@ -1,591 +0,0 @@ ----------------------------------------------------------------------------- --- LuaJIT PPC disassembler module. --- --- Copyright (C) 2005-2014 Mike Pall. All rights reserved. --- Released under the MIT/X license. See Copyright Notice in luajit.h ----------------------------------------------------------------------------- --- This is a helper module used by the LuaJIT machine code dumper module. --- --- It disassembles all common, non-privileged 32/64 bit PowerPC instructions --- plus the e500 SPE instructions and some Cell/Xenon extensions. --- --- NYI: VMX, VMX128 ------------------------------------------------------------------------------- - -local type = type -local sub, byte, format = string.sub, string.byte, string.format -local match, gmatch, gsub = string.match, string.gmatch, string.gsub -local concat = table.concat -local bit = require("bit") -local band, bor, tohex = bit.band, bit.bor, bit.tohex -local lshift, rshift, arshift = bit.lshift, bit.rshift, bit.arshift - ------------------------------------------------------------------------------- --- Primary and extended opcode maps ------------------------------------------------------------------------------- - -local map_crops = { - shift = 1, mask = 1023, - [0] = "mcrfXX", - [33] = "crnor|crnotCCC=", [129] = "crandcCCC", - [193] = "crxor|crclrCCC%", [225] = "crnandCCC", - [257] = "crandCCC", [289] = "creqv|crsetCCC%", - [417] = "crorcCCC", [449] = "cror|crmoveCCC=", - [16] = "b_lrKB", [528] = "b_ctrKB", - [150] = "isync", -} - -local map_rlwinm = setmetatable({ - shift = 0, mask = -1, -}, -{ __index = function(t, x) - local rot = band(rshift(x, 11), 31) - local mb = band(rshift(x, 6), 31) - local me = band(rshift(x, 1), 31) - if mb == 0 and me == 31-rot then - return "slwiRR~A." - elseif me == 31 and mb == 32-rot then - return "srwiRR~-A." - else - return "rlwinmRR~AAA." - end - end -}) - -local map_rld = { - shift = 2, mask = 7, - [0] = "rldiclRR~HM.", "rldicrRR~HM.", "rldicRR~HM.", "rldimiRR~HM.", - { - shift = 1, mask = 1, - [0] = "rldclRR~RM.", "rldcrRR~RM.", - }, -} - -local map_ext = setmetatable({ - shift = 1, mask = 1023, - - [0] = "cmp_YLRR", [32] = "cmpl_YLRR", - [4] = "twARR", [68] = "tdARR", - - [8] = "subfcRRR.", [40] = "subfRRR.", - [104] = "negRR.", [136] = "subfeRRR.", - [200] = "subfzeRR.", [232] = "subfmeRR.", - [520] = "subfcoRRR.", [552] = "subfoRRR.", - [616] = "negoRR.", [648] = "subfeoRRR.", - [712] = "subfzeoRR.", [744] = "subfmeoRR.", - - [9] = "mulhduRRR.", [73] = "mulhdRRR.", [233] = "mulldRRR.", - [457] = "divduRRR.", [489] = "divdRRR.", - [745] = "mulldoRRR.", - [969] = "divduoRRR.", [1001] = "divdoRRR.", - - [10] = "addcRRR.", [138] = "addeRRR.", - [202] = "addzeRR.", [234] = "addmeRR.", [266] = "addRRR.", - [522] = "addcoRRR.", [650] = "addeoRRR.", - [714] = "addzeoRR.", [746] = "addmeoRR.", [778] = "addoRRR.", - - [11] = "mulhwuRRR.", [75] = "mulhwRRR.", [235] = "mullwRRR.", - [459] = "divwuRRR.", [491] = "divwRRR.", - [747] = "mullwoRRR.", - [971] = "divwouRRR.", [1003] = "divwoRRR.", - - [15] = "iselltRRR", [47] = "iselgtRRR", [79] = "iseleqRRR", - - [144] = { shift = 20, mask = 1, [0] = "mtcrfRZ~", "mtocrfRZ~", }, - [19] = { shift = 20, mask = 1, [0] = "mfcrR", "mfocrfRZ", }, - [371] = { shift = 11, mask = 1023, [392] = "mftbR", [424] = "mftbuR", }, - [339] = { - shift = 11, mask = 1023, - [32] = "mferR", [256] = "mflrR", [288] = "mfctrR", [16] = "mfspefscrR", - }, - [467] = { - shift = 11, mask = 1023, - [32] = "mtxerR", [256] = "mtlrR", [288] = "mtctrR", [16] = "mtspefscrR", - }, - - [20] = "lwarxRR0R", [84] = "ldarxRR0R", - - [21] = "ldxRR0R", [53] = "lduxRRR", - [149] = "stdxRR0R", [181] = "stduxRRR", - [341] = "lwaxRR0R", [373] = "lwauxRRR", - - [23] = "lwzxRR0R", [55] = "lwzuxRRR", - [87] = "lbzxRR0R", [119] = "lbzuxRRR", - [151] = "stwxRR0R", [183] = "stwuxRRR", - [215] = "stbxRR0R", [247] = "stbuxRRR", - [279] = "lhzxRR0R", [311] = "lhzuxRRR", - [343] = "lhaxRR0R", [375] = "lhauxRRR", - [407] = "sthxRR0R", [439] = "sthuxRRR", - - [54] = "dcbst-R0R", [86] = "dcbf-R0R", - [150] = "stwcxRR0R.", [214] = "stdcxRR0R.", - [246] = "dcbtst-R0R", [278] = "dcbt-R0R", - [310] = "eciwxRR0R", [438] = "ecowxRR0R", - [470] = "dcbi-RR", - - [598] = { - shift = 21, mask = 3, - [0] = "sync", "lwsync", "ptesync", - }, - [758] = "dcba-RR", - [854] = "eieio", [982] = "icbi-R0R", [1014] = "dcbz-R0R", - - [26] = "cntlzwRR~", [58] = "cntlzdRR~", - [122] = "popcntbRR~", - [154] = "prtywRR~", [186] = "prtydRR~", - - [28] = "andRR~R.", [60] = "andcRR~R.", [124] = "nor|notRR~R=.", - [284] = "eqvRR~R.", [316] = "xorRR~R.", - [412] = "orcRR~R.", [444] = "or|mrRR~R=.", [476] = "nandRR~R.", - [508] = "cmpbRR~R", - - [512] = "mcrxrX", - - [532] = "ldbrxRR0R", [660] = "stdbrxRR0R", - - [533] = "lswxRR0R", [597] = "lswiRR0A", - [661] = "stswxRR0R", [725] = "stswiRR0A", - - [534] = "lwbrxRR0R", [662] = "stwbrxRR0R", - [790] = "lhbrxRR0R", [918] = "sthbrxRR0R", - - [535] = "lfsxFR0R", [567] = "lfsuxFRR", - [599] = "lfdxFR0R", [631] = "lfduxFRR", - [663] = "stfsxFR0R", [695] = "stfsuxFRR", - [727] = "stfdxFR0R", [759] = "stfduxFR0R", - [855] = "lfiwaxFR0R", - [983] = "stfiwxFR0R", - - [24] = "slwRR~R.", - - [27] = "sldRR~R.", [536] = "srwRR~R.", - [792] = "srawRR~R.", [824] = "srawiRR~A.", - - [794] = "sradRR~R.", [826] = "sradiRR~H.", [827] = "sradiRR~H.", - [922] = "extshRR~.", [954] = "extsbRR~.", [986] = "extswRR~.", - - [539] = "srdRR~R.", -}, -{ __index = function(t, x) - if band(x, 31) == 15 then return "iselRRRC" end - end -}) - -local map_ld = { - shift = 0, mask = 3, - [0] = "ldRRE", "lduRRE", "lwaRRE", -} - -local map_std = { - shift = 0, mask = 3, - [0] = "stdRRE", "stduRRE", -} - -local map_fps = { - shift = 5, mask = 1, - { - shift = 1, mask = 15, - [0] = false, false, "fdivsFFF.", false, - "fsubsFFF.", "faddsFFF.", "fsqrtsF-F.", false, - "fresF-F.", "fmulsFF-F.", "frsqrtesF-F.", false, - "fmsubsFFFF~.", "fmaddsFFFF~.", "fnmsubsFFFF~.", "fnmaddsFFFF~.", - } -} - -local map_fpd = { - shift = 5, mask = 1, - [0] = { - shift = 1, mask = 1023, - [0] = "fcmpuXFF", [32] = "fcmpoXFF", [64] = "mcrfsXX", - [38] = "mtfsb1A.", [70] = "mtfsb0A.", [134] = "mtfsfiA>>-A>", - [8] = "fcpsgnFFF.", [40] = "fnegF-F.", [72] = "fmrF-F.", - [136] = "fnabsF-F.", [264] = "fabsF-F.", - [12] = "frspF-F.", - [14] = "fctiwF-F.", [15] = "fctiwzF-F.", - [583] = "mffsF.", [711] = "mtfsfZF.", - [392] = "frinF-F.", [424] = "frizF-F.", - [456] = "fripF-F.", [488] = "frimF-F.", - [814] = "fctidF-F.", [815] = "fctidzF-F.", [846] = "fcfidF-F.", - }, - { - shift = 1, mask = 15, - [0] = false, false, "fdivFFF.", false, - "fsubFFF.", "faddFFF.", "fsqrtF-F.", "fselFFFF~.", - "freF-F.", "fmulFF-F.", "frsqrteF-F.", false, - "fmsubFFFF~.", "fmaddFFFF~.", "fnmsubFFFF~.", "fnmaddFFFF~.", - } -} - -local map_spe = { - shift = 0, mask = 2047, - - [512] = "evaddwRRR", [514] = "evaddiwRAR~", - [516] = "evsubwRRR~", [518] = "evsubiwRAR~", - [520] = "evabsRR", [521] = "evnegRR", - [522] = "evextsbRR", [523] = "evextshRR", [524] = "evrndwRR", - [525] = "evcntlzwRR", [526] = "evcntlswRR", - - [527] = "brincRRR", - - [529] = "evandRRR", [530] = "evandcRRR", [534] = "evxorRRR", - [535] = "evor|evmrRRR=", [536] = "evnor|evnotRRR=", - [537] = "eveqvRRR", [539] = "evorcRRR", [542] = "evnandRRR", - - [544] = "evsrwuRRR", [545] = "evsrwsRRR", - [546] = "evsrwiuRRA", [547] = "evsrwisRRA", - [548] = "evslwRRR", [550] = "evslwiRRA", - [552] = "evrlwRRR", [553] = "evsplatiRS", - [554] = "evrlwiRRA", [555] = "evsplatfiRS", - [556] = "evmergehiRRR", [557] = "evmergeloRRR", - [558] = "evmergehiloRRR", [559] = "evmergelohiRRR", - - [560] = "evcmpgtuYRR", [561] = "evcmpgtsYRR", - [562] = "evcmpltuYRR", [563] = "evcmpltsYRR", - [564] = "evcmpeqYRR", - - [632] = "evselRRR", [633] = "evselRRRW", - [634] = "evselRRRW", [635] = "evselRRRW", - [636] = "evselRRRW", [637] = "evselRRRW", - [638] = "evselRRRW", [639] = "evselRRRW", - - [640] = "evfsaddRRR", [641] = "evfssubRRR", - [644] = "evfsabsRR", [645] = "evfsnabsRR", [646] = "evfsnegRR", - [648] = "evfsmulRRR", [649] = "evfsdivRRR", - [652] = "evfscmpgtYRR", [653] = "evfscmpltYRR", [654] = "evfscmpeqYRR", - [656] = "evfscfuiR-R", [657] = "evfscfsiR-R", - [658] = "evfscfufR-R", [659] = "evfscfsfR-R", - [660] = "evfsctuiR-R", [661] = "evfsctsiR-R", - [662] = "evfsctufR-R", [663] = "evfsctsfR-R", - [664] = "evfsctuizR-R", [666] = "evfsctsizR-R", - [668] = "evfststgtYRR", [669] = "evfststltYRR", [670] = "evfststeqYRR", - - [704] = "efsaddRRR", [705] = "efssubRRR", - [708] = "efsabsRR", [709] = "efsnabsRR", [710] = "efsnegRR", - [712] = "efsmulRRR", [713] = "efsdivRRR", - [716] = "efscmpgtYRR", [717] = "efscmpltYRR", [718] = "efscmpeqYRR", - [719] = "efscfdR-R", - [720] = "efscfuiR-R", [721] = "efscfsiR-R", - [722] = "efscfufR-R", [723] = "efscfsfR-R", - [724] = "efsctuiR-R", [725] = "efsctsiR-R", - [726] = "efsctufR-R", [727] = "efsctsfR-R", - [728] = "efsctuizR-R", [730] = "efsctsizR-R", - [732] = "efststgtYRR", [733] = "efststltYRR", [734] = "efststeqYRR", - - [736] = "efdaddRRR", [737] = "efdsubRRR", - [738] = "efdcfuidR-R", [739] = "efdcfsidR-R", - [740] = "efdabsRR", [741] = "efdnabsRR", [742] = "efdnegRR", - [744] = "efdmulRRR", [745] = "efddivRRR", - [746] = "efdctuidzR-R", [747] = "efdctsidzR-R", - [748] = "efdcmpgtYRR", [749] = "efdcmpltYRR", [750] = "efdcmpeqYRR", - [751] = "efdcfsR-R", - [752] = "efdcfuiR-R", [753] = "efdcfsiR-R", - [754] = "efdcfufR-R", [755] = "efdcfsfR-R", - [756] = "efdctuiR-R", [757] = "efdctsiR-R", - [758] = "efdctufR-R", [759] = "efdctsfR-R", - [760] = "efdctuizR-R", [762] = "efdctsizR-R", - [764] = "efdtstgtYRR", [765] = "efdtstltYRR", [766] = "efdtsteqYRR", - - [768] = "evlddxRR0R", [769] = "evlddRR8", - [770] = "evldwxRR0R", [771] = "evldwRR8", - [772] = "evldhxRR0R", [773] = "evldhRR8", - [776] = "evlhhesplatxRR0R", [777] = "evlhhesplatRR2", - [780] = "evlhhousplatxRR0R", [781] = "evlhhousplatRR2", - [782] = "evlhhossplatxRR0R", [783] = "evlhhossplatRR2", - [784] = "evlwhexRR0R", [785] = "evlwheRR4", - [788] = "evlwhouxRR0R", [789] = "evlwhouRR4", - [790] = "evlwhosxRR0R", [791] = "evlwhosRR4", - [792] = "evlwwsplatxRR0R", [793] = "evlwwsplatRR4", - [796] = "evlwhsplatxRR0R", [797] = "evlwhsplatRR4", - - [800] = "evstddxRR0R", [801] = "evstddRR8", - [802] = "evstdwxRR0R", [803] = "evstdwRR8", - [804] = "evstdhxRR0R", [805] = "evstdhRR8", - [816] = "evstwhexRR0R", [817] = "evstwheRR4", - [820] = "evstwhoxRR0R", [821] = "evstwhoRR4", - [824] = "evstwwexRR0R", [825] = "evstwweRR4", - [828] = "evstwwoxRR0R", [829] = "evstwwoRR4", - - [1027] = "evmhessfRRR", [1031] = "evmhossfRRR", [1032] = "evmheumiRRR", - [1033] = "evmhesmiRRR", [1035] = "evmhesmfRRR", [1036] = "evmhoumiRRR", - [1037] = "evmhosmiRRR", [1039] = "evmhosmfRRR", [1059] = "evmhessfaRRR", - [1063] = "evmhossfaRRR", [1064] = "evmheumiaRRR", [1065] = "evmhesmiaRRR", - [1067] = "evmhesmfaRRR", [1068] = "evmhoumiaRRR", [1069] = "evmhosmiaRRR", - [1071] = "evmhosmfaRRR", [1095] = "evmwhssfRRR", [1096] = "evmwlumiRRR", - [1100] = "evmwhumiRRR", [1101] = "evmwhsmiRRR", [1103] = "evmwhsmfRRR", - [1107] = "evmwssfRRR", [1112] = "evmwumiRRR", [1113] = "evmwsmiRRR", - [1115] = "evmwsmfRRR", [1127] = "evmwhssfaRRR", [1128] = "evmwlumiaRRR", - [1132] = "evmwhumiaRRR", [1133] = "evmwhsmiaRRR", [1135] = "evmwhsmfaRRR", - [1139] = "evmwssfaRRR", [1144] = "evmwumiaRRR", [1145] = "evmwsmiaRRR", - [1147] = "evmwsmfaRRR", - - [1216] = "evaddusiaawRR", [1217] = "evaddssiaawRR", - [1218] = "evsubfusiaawRR", [1219] = "evsubfssiaawRR", - [1220] = "evmraRR", - [1222] = "evdivwsRRR", [1223] = "evdivwuRRR", - [1224] = "evaddumiaawRR", [1225] = "evaddsmiaawRR", - [1226] = "evsubfumiaawRR", [1227] = "evsubfsmiaawRR", - - [1280] = "evmheusiaawRRR", [1281] = "evmhessiaawRRR", - [1283] = "evmhessfaawRRR", [1284] = "evmhousiaawRRR", - [1285] = "evmhossiaawRRR", [1287] = "evmhossfaawRRR", - [1288] = "evmheumiaawRRR", [1289] = "evmhesmiaawRRR", - [1291] = "evmhesmfaawRRR", [1292] = "evmhoumiaawRRR", - [1293] = "evmhosmiaawRRR", [1295] = "evmhosmfaawRRR", - [1320] = "evmhegumiaaRRR", [1321] = "evmhegsmiaaRRR", - [1323] = "evmhegsmfaaRRR", [1324] = "evmhogumiaaRRR", - [1325] = "evmhogsmiaaRRR", [1327] = "evmhogsmfaaRRR", - [1344] = "evmwlusiaawRRR", [1345] = "evmwlssiaawRRR", - [1352] = "evmwlumiaawRRR", [1353] = "evmwlsmiaawRRR", - [1363] = "evmwssfaaRRR", [1368] = "evmwumiaaRRR", - [1369] = "evmwsmiaaRRR", [1371] = "evmwsmfaaRRR", - [1408] = "evmheusianwRRR", [1409] = "evmhessianwRRR", - [1411] = "evmhessfanwRRR", [1412] = "evmhousianwRRR", - [1413] = "evmhossianwRRR", [1415] = "evmhossfanwRRR", - [1416] = "evmheumianwRRR", [1417] = "evmhesmianwRRR", - [1419] = "evmhesmfanwRRR", [1420] = "evmhoumianwRRR", - [1421] = "evmhosmianwRRR", [1423] = "evmhosmfanwRRR", - [1448] = "evmhegumianRRR", [1449] = "evmhegsmianRRR", - [1451] = "evmhegsmfanRRR", [1452] = "evmhogumianRRR", - [1453] = "evmhogsmianRRR", [1455] = "evmhogsmfanRRR", - [1472] = "evmwlusianwRRR", [1473] = "evmwlssianwRRR", - [1480] = "evmwlumianwRRR", [1481] = "evmwlsmianwRRR", - [1491] = "evmwssfanRRR", [1496] = "evmwumianRRR", - [1497] = "evmwsmianRRR", [1499] = "evmwsmfanRRR", -} - -local map_pri = { - [0] = false, false, "tdiARI", "twiARI", - map_spe, false, false, "mulliRRI", - "subficRRI", false, "cmpl_iYLRU", "cmp_iYLRI", - "addicRRI", "addic.RRI", "addi|liRR0I", "addis|lisRR0I", - "b_KBJ", "sc", "bKJ", map_crops, - "rlwimiRR~AAA.", map_rlwinm, false, "rlwnmRR~RAA.", - "oriNRR~U", "orisRR~U", "xoriRR~U", "xorisRR~U", - "andi.RR~U", "andis.RR~U", map_rld, map_ext, - "lwzRRD", "lwzuRRD", "lbzRRD", "lbzuRRD", - "stwRRD", "stwuRRD", "stbRRD", "stbuRRD", - "lhzRRD", "lhzuRRD", "lhaRRD", "lhauRRD", - "sthRRD", "sthuRRD", "lmwRRD", "stmwRRD", - "lfsFRD", "lfsuFRD", "lfdFRD", "lfduFRD", - "stfsFRD", "stfsuFRD", "stfdFRD", "stfduFRD", - false, false, map_ld, map_fps, - false, false, map_std, map_fpd, -} - ------------------------------------------------------------------------------- - -local map_gpr = { - [0] = "r0", "sp", "r2", "r3", "r4", "r5", "r6", "r7", - "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", - "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", - "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", -} - -local map_cond = { [0] = "lt", "gt", "eq", "so", "ge", "le", "ne", "ns", } - --- Format a condition bit. -local function condfmt(cond) - if cond <= 3 then - return map_cond[band(cond, 3)] - else - return format("4*cr%d+%s", rshift(cond, 2), map_cond[band(cond, 3)]) - end -end - ------------------------------------------------------------------------------- - --- Output a nicely formatted line with an opcode and operands. -local function putop(ctx, text, operands) - local pos = ctx.pos - local extra = "" - if ctx.rel then - local sym = ctx.symtab[ctx.rel] - if sym then extra = "\t->"..sym end - end - if ctx.hexdump > 0 then - ctx.out(format("%08x %s %-7s %s%s\n", - ctx.addr+pos, tohex(ctx.op), text, concat(operands, ", "), extra)) - else - ctx.out(format("%08x %-7s %s%s\n", - ctx.addr+pos, text, concat(operands, ", "), extra)) - end - ctx.pos = pos + 4 -end - --- Fallback for unknown opcodes. -local function unknown(ctx) - return putop(ctx, ".long", { "0x"..tohex(ctx.op) }) -end - --- Disassemble a single instruction. -local function disass_ins(ctx) - local pos = ctx.pos - local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4) - local op = bor(lshift(b0, 24), lshift(b1, 16), lshift(b2, 8), b3) - local operands = {} - local last = nil - local rs = 21 - ctx.op = op - ctx.rel = nil - - local opat = map_pri[rshift(b0, 2)] - while type(opat) ~= "string" do - if not opat then return unknown(ctx) end - opat = opat[band(rshift(op, opat.shift), opat.mask)] - end - local name, pat = match(opat, "^([a-z0-9_.]*)(.*)") - local altname, pat2 = match(pat, "|([a-z0-9_.]*)(.*)") - if altname then pat = pat2 end - - for p in gmatch(pat, ".") do - local x = nil - if p == "R" then - x = map_gpr[band(rshift(op, rs), 31)] - rs = rs - 5 - elseif p == "F" then - x = "f"..band(rshift(op, rs), 31) - rs = rs - 5 - elseif p == "A" then - x = band(rshift(op, rs), 31) - rs = rs - 5 - elseif p == "S" then - x = arshift(lshift(op, 27-rs), 27) - rs = rs - 5 - elseif p == "I" then - x = arshift(lshift(op, 16), 16) - elseif p == "U" then - x = band(op, 0xffff) - elseif p == "D" or p == "E" then - local disp = arshift(lshift(op, 16), 16) - if p == "E" then disp = band(disp, -4) end - if last == "r0" then last = "0" end - operands[#operands] = format("%d(%s)", disp, last) - elseif p >= "2" and p <= "8" then - local disp = band(rshift(op, rs), 31) * p - if last == "r0" then last = "0" end - operands[#operands] = format("%d(%s)", disp, last) - elseif p == "H" then - x = band(rshift(op, rs), 31) + lshift(band(op, 2), 4) - rs = rs - 5 - elseif p == "M" then - x = band(rshift(op, rs), 31) + band(op, 0x20) - elseif p == "C" then - x = condfmt(band(rshift(op, rs), 31)) - rs = rs - 5 - elseif p == "B" then - local bo = rshift(op, 21) - local cond = band(rshift(op, 16), 31) - local cn = "" - rs = rs - 10 - if band(bo, 4) == 0 then - cn = band(bo, 2) == 0 and "dnz" or "dz" - if band(bo, 0x10) == 0 then - cn = cn..(band(bo, 8) == 0 and "f" or "t") - end - if band(bo, 0x10) == 0 then x = condfmt(cond) end - name = name..(band(bo, 1) == band(rshift(op, 15), 1) and "-" or "+") - elseif band(bo, 0x10) == 0 then - cn = map_cond[band(cond, 3) + (band(bo, 8) == 0 and 4 or 0)] - if cond > 3 then x = "cr"..rshift(cond, 2) end - name = name..(band(bo, 1) == band(rshift(op, 15), 1) and "-" or "+") - end - name = gsub(name, "_", cn) - elseif p == "J" then - x = arshift(lshift(op, 27-rs), 29-rs)*4 - if band(op, 2) == 0 then x = ctx.addr + pos + x end - ctx.rel = x - x = "0x"..tohex(x) - elseif p == "K" then - if band(op, 1) ~= 0 then name = name.."l" end - if band(op, 2) ~= 0 then name = name.."a" end - elseif p == "X" or p == "Y" then - x = band(rshift(op, rs+2), 7) - if x == 0 and p == "Y" then x = nil else x = "cr"..x end - rs = rs - 5 - elseif p == "W" then - x = "cr"..band(op, 7) - elseif p == "Z" then - x = band(rshift(op, rs-4), 255) - rs = rs - 10 - elseif p == ">" then - operands[#operands] = rshift(operands[#operands], 1) - elseif p == "0" then - if last == "r0" then - operands[#operands] = nil - if altname then name = altname end - end - elseif p == "L" then - name = gsub(name, "_", band(op, 0x00200000) ~= 0 and "d" or "w") - elseif p == "." then - if band(op, 1) == 1 then name = name.."." end - elseif p == "N" then - if op == 0x60000000 then name = "nop"; break end - elseif p == "~" then - local n = #operands - operands[n-1], operands[n] = operands[n], operands[n-1] - elseif p == "=" then - local n = #operands - if last == operands[n-1] then - operands[n] = nil - name = altname - end - elseif p == "%" then - local n = #operands - if last == operands[n-1] and last == operands[n-2] then - operands[n] = nil - operands[n-1] = nil - name = altname - end - elseif p == "-" then - rs = rs - 5 - else - assert(false) - end - if x then operands[#operands+1] = x; last = x end - end - - return putop(ctx, name, operands) -end - ------------------------------------------------------------------------------- - --- Disassemble a block of code. -local function disass_block(ctx, ofs, len) - if not ofs then ofs = 0 end - local stop = len and ofs+len or #ctx.code - stop = stop - stop % 4 - ctx.pos = ofs - ofs % 4 - ctx.rel = nil - while ctx.pos < stop do disass_ins(ctx) end -end - --- Extended API: create a disassembler context. Then call ctx:disass(ofs, len). -local function create_(code, addr, out) - local ctx = {} - ctx.code = code - ctx.addr = addr or 0 - ctx.out = out or io.write - ctx.symtab = {} - ctx.disass = disass_block - ctx.hexdump = 8 - return ctx -end - --- Simple API: disassemble code (a string) at address and output via out. -local function disass_(code, addr, out) - create_(code, addr, out):disass() -end - --- Return register name for RID. -local function regname_(r) - if r < 32 then return map_gpr[r] end - return "f"..(r-32) -end - --- Public module functions. -module(...) - -create = create_ -disass = disass_ -regname = regname_ - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_x64.lua b/source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_x64.lua deleted file mode 100644 index 4f4916953..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_x64.lua +++ /dev/null @@ -1,20 +0,0 @@ ----------------------------------------------------------------------------- --- LuaJIT x64 disassembler wrapper module. --- --- Copyright (C) 2005-2014 Mike Pall. All rights reserved. --- Released under the MIT license. See Copyright Notice in luajit.h ----------------------------------------------------------------------------- --- This module just exports the 64 bit functions from the combined --- x86/x64 disassembler module. All the interesting stuff is there. ------------------------------------------------------------------------------- - -local require = require - -module(...) - -local dis_x86 = require(_PACKAGE.."dis_x86") - -create = dis_x86.create64 -disass = dis_x86.disass64 -regname = dis_x86.regname64 - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_x86.lua b/source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_x86.lua deleted file mode 100644 index 0b865ab6e..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/jit/dis_x86.lua +++ /dev/null @@ -1,836 +0,0 @@ ----------------------------------------------------------------------------- --- LuaJIT x86/x64 disassembler module. --- --- Copyright (C) 2005-2014 Mike Pall. All rights reserved. --- Released under the MIT license. See Copyright Notice in luajit.h ----------------------------------------------------------------------------- --- This is a helper module used by the LuaJIT machine code dumper module. --- --- Sending small code snippets to an external disassembler and mixing the --- output with our own stuff was too fragile. So I had to bite the bullet --- and write yet another x86 disassembler. Oh well ... --- --- The output format is very similar to what ndisasm generates. But it has --- been developed independently by looking at the opcode tables from the --- Intel and AMD manuals. The supported instruction set is quite extensive --- and reflects what a current generation Intel or AMD CPU implements in --- 32 bit and 64 bit mode. Yes, this includes MMX, SSE, SSE2, SSE3, SSSE3, --- SSE4.1, SSE4.2, SSE4a and even privileged and hypervisor (VMX/SVM) --- instructions. --- --- Notes: --- * The (useless) a16 prefix, 3DNow and pre-586 opcodes are unsupported. --- * No attempt at optimization has been made -- it's fast enough for my needs. --- * The public API may change when more architectures are added. ------------------------------------------------------------------------------- - -local type = type -local sub, byte, format = string.sub, string.byte, string.format -local match, gmatch, gsub = string.match, string.gmatch, string.gsub -local lower, rep = string.lower, string.rep - --- Map for 1st opcode byte in 32 bit mode. Ugly? Well ... read on. -local map_opc1_32 = { ---0x -[0]="addBmr","addVmr","addBrm","addVrm","addBai","addVai","push es","pop es", -"orBmr","orVmr","orBrm","orVrm","orBai","orVai","push cs","opc2*", ---1x -"adcBmr","adcVmr","adcBrm","adcVrm","adcBai","adcVai","push ss","pop ss", -"sbbBmr","sbbVmr","sbbBrm","sbbVrm","sbbBai","sbbVai","push ds","pop ds", ---2x -"andBmr","andVmr","andBrm","andVrm","andBai","andVai","es:seg","daa", -"subBmr","subVmr","subBrm","subVrm","subBai","subVai","cs:seg","das", ---3x -"xorBmr","xorVmr","xorBrm","xorVrm","xorBai","xorVai","ss:seg","aaa", -"cmpBmr","cmpVmr","cmpBrm","cmpVrm","cmpBai","cmpVai","ds:seg","aas", ---4x -"incVR","incVR","incVR","incVR","incVR","incVR","incVR","incVR", -"decVR","decVR","decVR","decVR","decVR","decVR","decVR","decVR", ---5x -"pushUR","pushUR","pushUR","pushUR","pushUR","pushUR","pushUR","pushUR", -"popUR","popUR","popUR","popUR","popUR","popUR","popUR","popUR", ---6x -"sz*pushaw,pusha","sz*popaw,popa","boundVrm","arplWmr", -"fs:seg","gs:seg","o16:","a16", -"pushUi","imulVrmi","pushBs","imulVrms", -"insb","insVS","outsb","outsVS", ---7x -"joBj","jnoBj","jbBj","jnbBj","jzBj","jnzBj","jbeBj","jaBj", -"jsBj","jnsBj","jpeBj","jpoBj","jlBj","jgeBj","jleBj","jgBj", ---8x -"arith!Bmi","arith!Vmi","arith!Bmi","arith!Vms", -"testBmr","testVmr","xchgBrm","xchgVrm", -"movBmr","movVmr","movBrm","movVrm", -"movVmg","leaVrm","movWgm","popUm", ---9x -"nop*xchgVaR|pause|xchgWaR|repne nop","xchgVaR","xchgVaR","xchgVaR", -"xchgVaR","xchgVaR","xchgVaR","xchgVaR", -"sz*cbw,cwde,cdqe","sz*cwd,cdq,cqo","call farViw","wait", -"sz*pushfw,pushf","sz*popfw,popf","sahf","lahf", ---Ax -"movBao","movVao","movBoa","movVoa", -"movsb","movsVS","cmpsb","cmpsVS", -"testBai","testVai","stosb","stosVS", -"lodsb","lodsVS","scasb","scasVS", ---Bx -"movBRi","movBRi","movBRi","movBRi","movBRi","movBRi","movBRi","movBRi", -"movVRI","movVRI","movVRI","movVRI","movVRI","movVRI","movVRI","movVRI", ---Cx -"shift!Bmu","shift!Vmu","retBw","ret","$lesVrm","$ldsVrm","movBmi","movVmi", -"enterBwu","leave","retfBw","retf","int3","intBu","into","iretVS", ---Dx -"shift!Bm1","shift!Vm1","shift!Bmc","shift!Vmc","aamBu","aadBu","salc","xlatb", -"fp*0","fp*1","fp*2","fp*3","fp*4","fp*5","fp*6","fp*7", ---Ex -"loopneBj","loopeBj","loopBj","sz*jcxzBj,jecxzBj,jrcxzBj", -"inBau","inVau","outBua","outVua", -"callVj","jmpVj","jmp farViw","jmpBj","inBad","inVad","outBda","outVda", ---Fx -"lock:","int1","repne:rep","rep:","hlt","cmc","testb!Bm","testv!Vm", -"clc","stc","cli","sti","cld","std","incb!Bm","incd!Vm", -} -assert(#map_opc1_32 == 255) - --- Map for 1st opcode byte in 64 bit mode (overrides only). -local map_opc1_64 = setmetatable({ - [0x06]=false, [0x07]=false, [0x0e]=false, - [0x16]=false, [0x17]=false, [0x1e]=false, [0x1f]=false, - [0x27]=false, [0x2f]=false, [0x37]=false, [0x3f]=false, - [0x60]=false, [0x61]=false, [0x62]=false, [0x63]="movsxdVrDmt", [0x67]="a32:", - [0x40]="rex*", [0x41]="rex*b", [0x42]="rex*x", [0x43]="rex*xb", - [0x44]="rex*r", [0x45]="rex*rb", [0x46]="rex*rx", [0x47]="rex*rxb", - [0x48]="rex*w", [0x49]="rex*wb", [0x4a]="rex*wx", [0x4b]="rex*wxb", - [0x4c]="rex*wr", [0x4d]="rex*wrb", [0x4e]="rex*wrx", [0x4f]="rex*wrxb", - [0x82]=false, [0x9a]=false, [0xc4]=false, [0xc5]=false, [0xce]=false, - [0xd4]=false, [0xd5]=false, [0xd6]=false, [0xea]=false, -}, { __index = map_opc1_32 }) - --- Map for 2nd opcode byte (0F xx). True CISC hell. Hey, I told you. --- Prefix dependent MMX/SSE opcodes: (none)|rep|o16|repne, -|F3|66|F2 -local map_opc2 = { ---0x -[0]="sldt!Dmp","sgdt!Ump","larVrm","lslVrm",nil,"syscall","clts","sysret", -"invd","wbinvd",nil,"ud1",nil,"$prefetch!Bm","femms","3dnowMrmu", ---1x -"movupsXrm|movssXrm|movupdXrm|movsdXrm", -"movupsXmr|movssXmr|movupdXmr|movsdXmr", -"movhlpsXrm$movlpsXrm|movsldupXrm|movlpdXrm|movddupXrm", -"movlpsXmr||movlpdXmr", -"unpcklpsXrm||unpcklpdXrm", -"unpckhpsXrm||unpckhpdXrm", -"movlhpsXrm$movhpsXrm|movshdupXrm|movhpdXrm", -"movhpsXmr||movhpdXmr", -"$prefetcht!Bm","hintnopVm","hintnopVm","hintnopVm", -"hintnopVm","hintnopVm","hintnopVm","hintnopVm", ---2x -"movUmx$","movUmy$","movUxm$","movUym$","movUmz$",nil,"movUzm$",nil, -"movapsXrm||movapdXrm", -"movapsXmr||movapdXmr", -"cvtpi2psXrMm|cvtsi2ssXrVmt|cvtpi2pdXrMm|cvtsi2sdXrVmt", -"movntpsXmr|movntssXmr|movntpdXmr|movntsdXmr", -"cvttps2piMrXm|cvttss2siVrXm|cvttpd2piMrXm|cvttsd2siVrXm", -"cvtps2piMrXm|cvtss2siVrXm|cvtpd2piMrXm|cvtsd2siVrXm", -"ucomissXrm||ucomisdXrm", -"comissXrm||comisdXrm", ---3x -"wrmsr","rdtsc","rdmsr","rdpmc","sysenter","sysexit",nil,"getsec", -"opc3*38",nil,"opc3*3a",nil,nil,nil,nil,nil, ---4x -"cmovoVrm","cmovnoVrm","cmovbVrm","cmovnbVrm", -"cmovzVrm","cmovnzVrm","cmovbeVrm","cmovaVrm", -"cmovsVrm","cmovnsVrm","cmovpeVrm","cmovpoVrm", -"cmovlVrm","cmovgeVrm","cmovleVrm","cmovgVrm", ---5x -"movmskpsVrXm$||movmskpdVrXm$","sqrtpsXrm|sqrtssXrm|sqrtpdXrm|sqrtsdXrm", -"rsqrtpsXrm|rsqrtssXrm","rcppsXrm|rcpssXrm", -"andpsXrm||andpdXrm","andnpsXrm||andnpdXrm", -"orpsXrm||orpdXrm","xorpsXrm||xorpdXrm", -"addpsXrm|addssXrm|addpdXrm|addsdXrm","mulpsXrm|mulssXrm|mulpdXrm|mulsdXrm", -"cvtps2pdXrm|cvtss2sdXrm|cvtpd2psXrm|cvtsd2ssXrm", -"cvtdq2psXrm|cvttps2dqXrm|cvtps2dqXrm", -"subpsXrm|subssXrm|subpdXrm|subsdXrm","minpsXrm|minssXrm|minpdXrm|minsdXrm", -"divpsXrm|divssXrm|divpdXrm|divsdXrm","maxpsXrm|maxssXrm|maxpdXrm|maxsdXrm", ---6x -"punpcklbwPrm","punpcklwdPrm","punpckldqPrm","packsswbPrm", -"pcmpgtbPrm","pcmpgtwPrm","pcmpgtdPrm","packuswbPrm", -"punpckhbwPrm","punpckhwdPrm","punpckhdqPrm","packssdwPrm", -"||punpcklqdqXrm","||punpckhqdqXrm", -"movPrVSm","movqMrm|movdquXrm|movdqaXrm", ---7x -"pshufwMrmu|pshufhwXrmu|pshufdXrmu|pshuflwXrmu","pshiftw!Pmu", -"pshiftd!Pmu","pshiftq!Mmu||pshiftdq!Xmu", -"pcmpeqbPrm","pcmpeqwPrm","pcmpeqdPrm","emms|", -"vmreadUmr||extrqXmuu$|insertqXrmuu$","vmwriteUrm||extrqXrm$|insertqXrm$", -nil,nil, -"||haddpdXrm|haddpsXrm","||hsubpdXrm|hsubpsXrm", -"movVSmMr|movqXrm|movVSmXr","movqMmr|movdquXmr|movdqaXmr", ---8x -"joVj","jnoVj","jbVj","jnbVj","jzVj","jnzVj","jbeVj","jaVj", -"jsVj","jnsVj","jpeVj","jpoVj","jlVj","jgeVj","jleVj","jgVj", ---9x -"setoBm","setnoBm","setbBm","setnbBm","setzBm","setnzBm","setbeBm","setaBm", -"setsBm","setnsBm","setpeBm","setpoBm","setlBm","setgeBm","setleBm","setgBm", ---Ax -"push fs","pop fs","cpuid","btVmr","shldVmru","shldVmrc",nil,nil, -"push gs","pop gs","rsm","btsVmr","shrdVmru","shrdVmrc","fxsave!Dmp","imulVrm", ---Bx -"cmpxchgBmr","cmpxchgVmr","$lssVrm","btrVmr", -"$lfsVrm","$lgsVrm","movzxVrBmt","movzxVrWmt", -"|popcntVrm","ud2Dp","bt!Vmu","btcVmr", -"bsfVrm","bsrVrm|lzcntVrm|bsrWrm","movsxVrBmt","movsxVrWmt", ---Cx -"xaddBmr","xaddVmr", -"cmppsXrmu|cmpssXrmu|cmppdXrmu|cmpsdXrmu","$movntiVmr|", -"pinsrwPrWmu","pextrwDrPmu", -"shufpsXrmu||shufpdXrmu","$cmpxchg!Qmp", -"bswapVR","bswapVR","bswapVR","bswapVR","bswapVR","bswapVR","bswapVR","bswapVR", ---Dx -"||addsubpdXrm|addsubpsXrm","psrlwPrm","psrldPrm","psrlqPrm", -"paddqPrm","pmullwPrm", -"|movq2dqXrMm|movqXmr|movdq2qMrXm$","pmovmskbVrMm||pmovmskbVrXm", -"psubusbPrm","psubuswPrm","pminubPrm","pandPrm", -"paddusbPrm","padduswPrm","pmaxubPrm","pandnPrm", ---Ex -"pavgbPrm","psrawPrm","psradPrm","pavgwPrm", -"pmulhuwPrm","pmulhwPrm", -"|cvtdq2pdXrm|cvttpd2dqXrm|cvtpd2dqXrm","$movntqMmr||$movntdqXmr", -"psubsbPrm","psubswPrm","pminswPrm","porPrm", -"paddsbPrm","paddswPrm","pmaxswPrm","pxorPrm", ---Fx -"|||lddquXrm","psllwPrm","pslldPrm","psllqPrm", -"pmuludqPrm","pmaddwdPrm","psadbwPrm","maskmovqMrm||maskmovdquXrm$", -"psubbPrm","psubwPrm","psubdPrm","psubqPrm", -"paddbPrm","paddwPrm","padddPrm","ud", -} -assert(map_opc2[255] == "ud") - --- Map for three-byte opcodes. Can't wait for their next invention. -local map_opc3 = { -["38"] = { -- [66] 0f 38 xx ---0x -[0]="pshufbPrm","phaddwPrm","phadddPrm","phaddswPrm", -"pmaddubswPrm","phsubwPrm","phsubdPrm","phsubswPrm", -"psignbPrm","psignwPrm","psigndPrm","pmulhrswPrm", -nil,nil,nil,nil, ---1x -"||pblendvbXrma",nil,nil,nil, -"||blendvpsXrma","||blendvpdXrma",nil,"||ptestXrm", -nil,nil,nil,nil, -"pabsbPrm","pabswPrm","pabsdPrm",nil, ---2x -"||pmovsxbwXrm","||pmovsxbdXrm","||pmovsxbqXrm","||pmovsxwdXrm", -"||pmovsxwqXrm","||pmovsxdqXrm",nil,nil, -"||pmuldqXrm","||pcmpeqqXrm","||$movntdqaXrm","||packusdwXrm", -nil,nil,nil,nil, ---3x -"||pmovzxbwXrm","||pmovzxbdXrm","||pmovzxbqXrm","||pmovzxwdXrm", -"||pmovzxwqXrm","||pmovzxdqXrm",nil,"||pcmpgtqXrm", -"||pminsbXrm","||pminsdXrm","||pminuwXrm","||pminudXrm", -"||pmaxsbXrm","||pmaxsdXrm","||pmaxuwXrm","||pmaxudXrm", ---4x -"||pmulddXrm","||phminposuwXrm", ---Fx -[0xf0] = "|||crc32TrBmt",[0xf1] = "|||crc32TrVmt", -}, - -["3a"] = { -- [66] 0f 3a xx ---0x -[0x00]=nil,nil,nil,nil,nil,nil,nil,nil, -"||roundpsXrmu","||roundpdXrmu","||roundssXrmu","||roundsdXrmu", -"||blendpsXrmu","||blendpdXrmu","||pblendwXrmu","palignrPrmu", ---1x -nil,nil,nil,nil, -"||pextrbVmXru","||pextrwVmXru","||pextrVmSXru","||extractpsVmXru", -nil,nil,nil,nil,nil,nil,nil,nil, ---2x -"||pinsrbXrVmu","||insertpsXrmu","||pinsrXrVmuS",nil, ---4x -[0x40] = "||dppsXrmu", -[0x41] = "||dppdXrmu", -[0x42] = "||mpsadbwXrmu", ---6x -[0x60] = "||pcmpestrmXrmu",[0x61] = "||pcmpestriXrmu", -[0x62] = "||pcmpistrmXrmu",[0x63] = "||pcmpistriXrmu", -}, -} - --- Map for VMX/SVM opcodes 0F 01 C0-FF (sgdt group with register operands). -local map_opcvm = { -[0xc1]="vmcall",[0xc2]="vmlaunch",[0xc3]="vmresume",[0xc4]="vmxoff", -[0xc8]="monitor",[0xc9]="mwait", -[0xd8]="vmrun",[0xd9]="vmmcall",[0xda]="vmload",[0xdb]="vmsave", -[0xdc]="stgi",[0xdd]="clgi",[0xde]="skinit",[0xdf]="invlpga", -[0xf8]="swapgs",[0xf9]="rdtscp", -} - --- Map for FP opcodes. And you thought stack machines are simple? -local map_opcfp = { --- D8-DF 00-BF: opcodes with a memory operand. --- D8 -[0]="faddFm","fmulFm","fcomFm","fcompFm","fsubFm","fsubrFm","fdivFm","fdivrFm", -"fldFm",nil,"fstFm","fstpFm","fldenvVm","fldcwWm","fnstenvVm","fnstcwWm", --- DA -"fiaddDm","fimulDm","ficomDm","ficompDm", -"fisubDm","fisubrDm","fidivDm","fidivrDm", --- DB -"fildDm","fisttpDm","fistDm","fistpDm",nil,"fld twordFmp",nil,"fstp twordFmp", --- DC -"faddGm","fmulGm","fcomGm","fcompGm","fsubGm","fsubrGm","fdivGm","fdivrGm", --- DD -"fldGm","fisttpQm","fstGm","fstpGm","frstorDmp",nil,"fnsaveDmp","fnstswWm", --- DE -"fiaddWm","fimulWm","ficomWm","ficompWm", -"fisubWm","fisubrWm","fidivWm","fidivrWm", --- DF -"fildWm","fisttpWm","fistWm","fistpWm", -"fbld twordFmp","fildQm","fbstp twordFmp","fistpQm", --- xx C0-FF: opcodes with a pseudo-register operand. --- D8 -"faddFf","fmulFf","fcomFf","fcompFf","fsubFf","fsubrFf","fdivFf","fdivrFf", --- D9 -"fldFf","fxchFf",{"fnop"},nil, -{"fchs","fabs",nil,nil,"ftst","fxam"}, -{"fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz"}, -{"f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp"}, -{"fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos"}, --- DA -"fcmovbFf","fcmoveFf","fcmovbeFf","fcmovuFf",nil,{nil,"fucompp"},nil,nil, --- DB -"fcmovnbFf","fcmovneFf","fcmovnbeFf","fcmovnuFf", -{nil,nil,"fnclex","fninit"},"fucomiFf","fcomiFf",nil, --- DC -"fadd toFf","fmul toFf",nil,nil, -"fsub toFf","fsubr toFf","fdivr toFf","fdiv toFf", --- DD -"ffreeFf",nil,"fstFf","fstpFf","fucomFf","fucompFf",nil,nil, --- DE -"faddpFf","fmulpFf",nil,{nil,"fcompp"}, -"fsubrpFf","fsubpFf","fdivrpFf","fdivpFf", --- DF -nil,nil,nil,nil,{"fnstsw ax"},"fucomipFf","fcomipFf",nil, -} -assert(map_opcfp[126] == "fcomipFf") - --- Map for opcode groups. The subkey is sp from the ModRM byte. -local map_opcgroup = { - arith = { "add", "or", "adc", "sbb", "and", "sub", "xor", "cmp" }, - shift = { "rol", "ror", "rcl", "rcr", "shl", "shr", "sal", "sar" }, - testb = { "testBmi", "testBmi", "not", "neg", "mul", "imul", "div", "idiv" }, - testv = { "testVmi", "testVmi", "not", "neg", "mul", "imul", "div", "idiv" }, - incb = { "inc", "dec" }, - incd = { "inc", "dec", "callUmp", "$call farDmp", - "jmpUmp", "$jmp farDmp", "pushUm" }, - sldt = { "sldt", "str", "lldt", "ltr", "verr", "verw" }, - sgdt = { "vm*$sgdt", "vm*$sidt", "$lgdt", "vm*$lidt", - "smsw", nil, "lmsw", "vm*$invlpg" }, - bt = { nil, nil, nil, nil, "bt", "bts", "btr", "btc" }, - cmpxchg = { nil, "sz*,cmpxchg8bQmp,cmpxchg16bXmp", nil, nil, - nil, nil, "vmptrld|vmxon|vmclear", "vmptrst" }, - pshiftw = { nil, nil, "psrlw", nil, "psraw", nil, "psllw" }, - pshiftd = { nil, nil, "psrld", nil, "psrad", nil, "pslld" }, - pshiftq = { nil, nil, "psrlq", nil, nil, nil, "psllq" }, - pshiftdq = { nil, nil, "psrlq", "psrldq", nil, nil, "psllq", "pslldq" }, - fxsave = { "$fxsave", "$fxrstor", "$ldmxcsr", "$stmxcsr", - nil, "lfenceDp$", "mfenceDp$", "sfenceDp$clflush" }, - prefetch = { "prefetch", "prefetchw" }, - prefetcht = { "prefetchnta", "prefetcht0", "prefetcht1", "prefetcht2" }, -} - ------------------------------------------------------------------------------- - --- Maps for register names. -local map_regs = { - B = { "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh", - "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b" }, - B64 = { "al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil", - "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b" }, - W = { "ax", "cx", "dx", "bx", "sp", "bp", "si", "di", - "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w" }, - D = { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", - "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d" }, - Q = { "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi", - "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" }, - M = { "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7", - "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7" }, -- No x64 ext! - X = { "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", - "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15" }, -} -local map_segregs = { "es", "cs", "ss", "ds", "fs", "gs", "segr6", "segr7" } - --- Maps for size names. -local map_sz2n = { - B = 1, W = 2, D = 4, Q = 8, M = 8, X = 16, -} -local map_sz2prefix = { - B = "byte", W = "word", D = "dword", - Q = "qword", - M = "qword", X = "xword", - F = "dword", G = "qword", -- No need for sizes/register names for these two. -} - ------------------------------------------------------------------------------- - --- Output a nicely formatted line with an opcode and operands. -local function putop(ctx, text, operands) - local code, pos, hex = ctx.code, ctx.pos, "" - local hmax = ctx.hexdump - if hmax > 0 then - for i=ctx.start,pos-1 do - hex = hex..format("%02X", byte(code, i, i)) - end - if #hex > hmax then hex = sub(hex, 1, hmax)..". " - else hex = hex..rep(" ", hmax-#hex+2) end - end - if operands then text = text.." "..operands end - if ctx.o16 then text = "o16 "..text; ctx.o16 = false end - if ctx.a32 then text = "a32 "..text; ctx.a32 = false end - if ctx.rep then text = ctx.rep.." "..text; ctx.rep = false end - if ctx.rex then - local t = (ctx.rexw and "w" or "")..(ctx.rexr and "r" or "").. - (ctx.rexx and "x" or "")..(ctx.rexb and "b" or "") - if t ~= "" then text = "rex."..t.." "..text end - ctx.rexw = false; ctx.rexr = false; ctx.rexx = false; ctx.rexb = false - ctx.rex = false - end - if ctx.seg then - local text2, n = gsub(text, "%[", "["..ctx.seg..":") - if n == 0 then text = ctx.seg.." "..text else text = text2 end - ctx.seg = false - end - if ctx.lock then text = "lock "..text; ctx.lock = false end - local imm = ctx.imm - if imm then - local sym = ctx.symtab[imm] - if sym then text = text.."\t->"..sym end - end - ctx.out(format("%08x %s%s\n", ctx.addr+ctx.start, hex, text)) - ctx.mrm = false - ctx.start = pos - ctx.imm = nil -end - --- Clear all prefix flags. -local function clearprefixes(ctx) - ctx.o16 = false; ctx.seg = false; ctx.lock = false; ctx.rep = false - ctx.rexw = false; ctx.rexr = false; ctx.rexx = false; ctx.rexb = false - ctx.rex = false; ctx.a32 = false -end - --- Fallback for incomplete opcodes at the end. -local function incomplete(ctx) - ctx.pos = ctx.stop+1 - clearprefixes(ctx) - return putop(ctx, "(incomplete)") -end - --- Fallback for unknown opcodes. -local function unknown(ctx) - clearprefixes(ctx) - return putop(ctx, "(unknown)") -end - --- Return an immediate of the specified size. -local function getimm(ctx, pos, n) - if pos+n-1 > ctx.stop then return incomplete(ctx) end - local code = ctx.code - if n == 1 then - local b1 = byte(code, pos, pos) - return b1 - elseif n == 2 then - local b1, b2 = byte(code, pos, pos+1) - return b1+b2*256 - else - local b1, b2, b3, b4 = byte(code, pos, pos+3) - local imm = b1+b2*256+b3*65536+b4*16777216 - ctx.imm = imm - return imm - end -end - --- Process pattern string and generate the operands. -local function putpat(ctx, name, pat) - local operands, regs, sz, mode, sp, rm, sc, rx, sdisp - local code, pos, stop = ctx.code, ctx.pos, ctx.stop - - -- Chars used: 1DFGIMPQRSTUVWXacdfgijmoprstuwxyz - for p in gmatch(pat, ".") do - local x = nil - if p == "V" or p == "U" then - if ctx.rexw then sz = "Q"; ctx.rexw = false - elseif ctx.o16 then sz = "W"; ctx.o16 = false - elseif p == "U" and ctx.x64 then sz = "Q" - else sz = "D" end - regs = map_regs[sz] - elseif p == "T" then - if ctx.rexw then sz = "Q"; ctx.rexw = false else sz = "D" end - regs = map_regs[sz] - elseif p == "B" then - sz = "B" - regs = ctx.rex and map_regs.B64 or map_regs.B - elseif match(p, "[WDQMXFG]") then - sz = p - regs = map_regs[sz] - elseif p == "P" then - sz = ctx.o16 and "X" or "M"; ctx.o16 = false - regs = map_regs[sz] - elseif p == "S" then - name = name..lower(sz) - elseif p == "s" then - local imm = getimm(ctx, pos, 1); if not imm then return end - x = imm <= 127 and format("+0x%02x", imm) - or format("-0x%02x", 256-imm) - pos = pos+1 - elseif p == "u" then - local imm = getimm(ctx, pos, 1); if not imm then return end - x = format("0x%02x", imm) - pos = pos+1 - elseif p == "w" then - local imm = getimm(ctx, pos, 2); if not imm then return end - x = format("0x%x", imm) - pos = pos+2 - elseif p == "o" then -- [offset] - if ctx.x64 then - local imm1 = getimm(ctx, pos, 4); if not imm1 then return end - local imm2 = getimm(ctx, pos+4, 4); if not imm2 then return end - x = format("[0x%08x%08x]", imm2, imm1) - pos = pos+8 - else - local imm = getimm(ctx, pos, 4); if not imm then return end - x = format("[0x%08x]", imm) - pos = pos+4 - end - elseif p == "i" or p == "I" then - local n = map_sz2n[sz] - if n == 8 and ctx.x64 and p == "I" then - local imm1 = getimm(ctx, pos, 4); if not imm1 then return end - local imm2 = getimm(ctx, pos+4, 4); if not imm2 then return end - x = format("0x%08x%08x", imm2, imm1) - else - if n == 8 then n = 4 end - local imm = getimm(ctx, pos, n); if not imm then return end - if sz == "Q" and (imm < 0 or imm > 0x7fffffff) then - imm = (0xffffffff+1)-imm - x = format(imm > 65535 and "-0x%08x" or "-0x%x", imm) - else - x = format(imm > 65535 and "0x%08x" or "0x%x", imm) - end - end - pos = pos+n - elseif p == "j" then - local n = map_sz2n[sz] - if n == 8 then n = 4 end - local imm = getimm(ctx, pos, n); if not imm then return end - if sz == "B" and imm > 127 then imm = imm-256 - elseif imm > 2147483647 then imm = imm-4294967296 end - pos = pos+n - imm = imm + pos + ctx.addr - if imm > 4294967295 and not ctx.x64 then imm = imm-4294967296 end - ctx.imm = imm - if sz == "W" then - x = format("word 0x%04x", imm%65536) - elseif ctx.x64 then - local lo = imm % 0x1000000 - x = format("0x%02x%06x", (imm-lo) / 0x1000000, lo) - else - x = format("0x%08x", imm) - end - elseif p == "R" then - local r = byte(code, pos-1, pos-1)%8 - if ctx.rexb then r = r + 8; ctx.rexb = false end - x = regs[r+1] - elseif p == "a" then x = regs[1] - elseif p == "c" then x = "cl" - elseif p == "d" then x = "dx" - elseif p == "1" then x = "1" - else - if not mode then - mode = ctx.mrm - if not mode then - if pos > stop then return incomplete(ctx) end - mode = byte(code, pos, pos) - pos = pos+1 - end - rm = mode%8; mode = (mode-rm)/8 - sp = mode%8; mode = (mode-sp)/8 - sdisp = "" - if mode < 3 then - if rm == 4 then - if pos > stop then return incomplete(ctx) end - sc = byte(code, pos, pos) - pos = pos+1 - rm = sc%8; sc = (sc-rm)/8 - rx = sc%8; sc = (sc-rx)/8 - if ctx.rexx then rx = rx + 8; ctx.rexx = false end - if rx == 4 then rx = nil end - end - if mode > 0 or rm == 5 then - local dsz = mode - if dsz ~= 1 then dsz = 4 end - local disp = getimm(ctx, pos, dsz); if not disp then return end - if mode == 0 then rm = nil end - if rm or rx or (not sc and ctx.x64 and not ctx.a32) then - if dsz == 1 and disp > 127 then - sdisp = format("-0x%x", 256-disp) - elseif disp >= 0 and disp <= 0x7fffffff then - sdisp = format("+0x%x", disp) - else - sdisp = format("-0x%x", (0xffffffff+1)-disp) - end - else - sdisp = format(ctx.x64 and not ctx.a32 and - not (disp >= 0 and disp <= 0x7fffffff) - and "0xffffffff%08x" or "0x%08x", disp) - end - pos = pos+dsz - end - end - if rm and ctx.rexb then rm = rm + 8; ctx.rexb = false end - if ctx.rexr then sp = sp + 8; ctx.rexr = false end - end - if p == "m" then - if mode == 3 then x = regs[rm+1] - else - local aregs = ctx.a32 and map_regs.D or ctx.aregs - local srm, srx = "", "" - if rm then srm = aregs[rm+1] - elseif not sc and ctx.x64 and not ctx.a32 then srm = "rip" end - ctx.a32 = false - if rx then - if rm then srm = srm.."+" end - srx = aregs[rx+1] - if sc > 0 then srx = srx.."*"..(2^sc) end - end - x = format("[%s%s%s]", srm, srx, sdisp) - end - if mode < 3 and - (not match(pat, "[aRrgp]") or match(pat, "t")) then -- Yuck. - x = map_sz2prefix[sz].." "..x - end - elseif p == "r" then x = regs[sp+1] - elseif p == "g" then x = map_segregs[sp+1] - elseif p == "p" then -- Suppress prefix. - elseif p == "f" then x = "st"..rm - elseif p == "x" then - if sp == 0 and ctx.lock and not ctx.x64 then - x = "CR8"; ctx.lock = false - else - x = "CR"..sp - end - elseif p == "y" then x = "DR"..sp - elseif p == "z" then x = "TR"..sp - elseif p == "t" then - else - error("bad pattern `"..pat.."'") - end - end - if x then operands = operands and operands..", "..x or x end - end - ctx.pos = pos - return putop(ctx, name, operands) -end - --- Forward declaration. -local map_act - --- Fetch and cache MRM byte. -local function getmrm(ctx) - local mrm = ctx.mrm - if not mrm then - local pos = ctx.pos - if pos > ctx.stop then return nil end - mrm = byte(ctx.code, pos, pos) - ctx.pos = pos+1 - ctx.mrm = mrm - end - return mrm -end - --- Dispatch to handler depending on pattern. -local function dispatch(ctx, opat, patgrp) - if not opat then return unknown(ctx) end - if match(opat, "%|") then -- MMX/SSE variants depending on prefix. - local p - if ctx.rep then - p = ctx.rep=="rep" and "%|([^%|]*)" or "%|[^%|]*%|[^%|]*%|([^%|]*)" - ctx.rep = false - elseif ctx.o16 then p = "%|[^%|]*%|([^%|]*)"; ctx.o16 = false - else p = "^[^%|]*" end - opat = match(opat, p) - if not opat then return unknown(ctx) end --- ctx.rep = false; ctx.o16 = false - --XXX fails for 66 f2 0f 38 f1 06 crc32 eax,WORD PTR [esi] - --XXX remove in branches? - end - if match(opat, "%$") then -- reg$mem variants. - local mrm = getmrm(ctx); if not mrm then return incomplete(ctx) end - opat = match(opat, mrm >= 192 and "^[^%$]*" or "%$(.*)") - if opat == "" then return unknown(ctx) end - end - if opat == "" then return unknown(ctx) end - local name, pat = match(opat, "^([a-z0-9 ]*)(.*)") - if pat == "" and patgrp then pat = patgrp end - return map_act[sub(pat, 1, 1)](ctx, name, pat) -end - --- Get a pattern from an opcode map and dispatch to handler. -local function dispatchmap(ctx, opcmap) - local pos = ctx.pos - local opat = opcmap[byte(ctx.code, pos, pos)] - pos = pos + 1 - ctx.pos = pos - return dispatch(ctx, opat) -end - --- Map for action codes. The key is the first char after the name. -map_act = { - -- Simple opcodes without operands. - [""] = function(ctx, name, pat) - return putop(ctx, name) - end, - - -- Operand size chars fall right through. - B = putpat, W = putpat, D = putpat, Q = putpat, - V = putpat, U = putpat, T = putpat, - M = putpat, X = putpat, P = putpat, - F = putpat, G = putpat, - - -- Collect prefixes. - [":"] = function(ctx, name, pat) - ctx[pat == ":" and name or sub(pat, 2)] = name - if ctx.pos - ctx.start > 5 then return unknown(ctx) end -- Limit #prefixes. - end, - - -- Chain to special handler specified by name. - ["*"] = function(ctx, name, pat) - return map_act[name](ctx, name, sub(pat, 2)) - end, - - -- Use named subtable for opcode group. - ["!"] = function(ctx, name, pat) - local mrm = getmrm(ctx); if not mrm then return incomplete(ctx) end - return dispatch(ctx, map_opcgroup[name][((mrm-(mrm%8))/8)%8+1], sub(pat, 2)) - end, - - -- o16,o32[,o64] variants. - sz = function(ctx, name, pat) - if ctx.o16 then ctx.o16 = false - else - pat = match(pat, ",(.*)") - if ctx.rexw then - local p = match(pat, ",(.*)") - if p then pat = p; ctx.rexw = false end - end - end - pat = match(pat, "^[^,]*") - return dispatch(ctx, pat) - end, - - -- Two-byte opcode dispatch. - opc2 = function(ctx, name, pat) - return dispatchmap(ctx, map_opc2) - end, - - -- Three-byte opcode dispatch. - opc3 = function(ctx, name, pat) - return dispatchmap(ctx, map_opc3[pat]) - end, - - -- VMX/SVM dispatch. - vm = function(ctx, name, pat) - return dispatch(ctx, map_opcvm[ctx.mrm]) - end, - - -- Floating point opcode dispatch. - fp = function(ctx, name, pat) - local mrm = getmrm(ctx); if not mrm then return incomplete(ctx) end - local rm = mrm%8 - local idx = pat*8 + ((mrm-rm)/8)%8 - if mrm >= 192 then idx = idx + 64 end - local opat = map_opcfp[idx] - if type(opat) == "table" then opat = opat[rm+1] end - return dispatch(ctx, opat) - end, - - -- REX prefix. - rex = function(ctx, name, pat) - if ctx.rex then return unknown(ctx) end -- Only 1 REX prefix allowed. - for p in gmatch(pat, ".") do ctx["rex"..p] = true end - ctx.rex = true - end, - - -- Special case for nop with REX prefix. - nop = function(ctx, name, pat) - return dispatch(ctx, ctx.rex and pat or "nop") - end, -} - ------------------------------------------------------------------------------- - --- Disassemble a block of code. -local function disass_block(ctx, ofs, len) - if not ofs then ofs = 0 end - local stop = len and ofs+len or #ctx.code - ofs = ofs + 1 - ctx.start = ofs - ctx.pos = ofs - ctx.stop = stop - ctx.imm = nil - ctx.mrm = false - clearprefixes(ctx) - while ctx.pos <= stop do dispatchmap(ctx, ctx.map1) end - if ctx.pos ~= ctx.start then incomplete(ctx) end -end - --- Extended API: create a disassembler context. Then call ctx:disass(ofs, len). -local function create_(code, addr, out) - local ctx = {} - ctx.code = code - ctx.addr = (addr or 0) - 1 - ctx.out = out or io.write - ctx.symtab = {} - ctx.disass = disass_block - ctx.hexdump = 16 - ctx.x64 = false - ctx.map1 = map_opc1_32 - ctx.aregs = map_regs.D - return ctx -end - -local function create64_(code, addr, out) - local ctx = create_(code, addr, out) - ctx.x64 = true - ctx.map1 = map_opc1_64 - ctx.aregs = map_regs.Q - return ctx -end - --- Simple API: disassemble code (a string) at address and output via out. -local function disass_(code, addr, out) - create_(code, addr, out):disass() -end - -local function disass64_(code, addr, out) - create64_(code, addr, out):disass() -end - --- Return register name for RID. -local function regname_(r) - if r < 8 then return map_regs.D[r+1] end - return map_regs.X[r-7] -end - -local function regname64_(r) - if r < 16 then return map_regs.Q[r+1] end - return map_regs.X[r-15] -end - --- Public module functions. -module(...) - -create = create_ -create64 = create64_ -disass = disass_ -disass64 = disass64_ -regname = regname_ -regname64 = regname64_ - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/jit/dump.lua b/source/libs/luajit/LuaJIT-2.0.3/src/jit/dump.lua deleted file mode 100644 index 556ce8830..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/jit/dump.lua +++ /dev/null @@ -1,699 +0,0 @@ ----------------------------------------------------------------------------- --- LuaJIT compiler dump module. --- --- Copyright (C) 2005-2014 Mike Pall. All rights reserved. --- Released under the MIT license. See Copyright Notice in luajit.h ----------------------------------------------------------------------------- --- --- This module can be used to debug the JIT compiler itself. It dumps the --- code representations and structures used in various compiler stages. --- --- Example usage: --- --- luajit -jdump -e "local x=0; for i=1,1e6 do x=x+i end; print(x)" --- luajit -jdump=im -e "for i=1,1000 do for j=1,1000 do end end" | less -R --- luajit -jdump=is myapp.lua | less -R --- luajit -jdump=-b myapp.lua --- luajit -jdump=+aH,myapp.html myapp.lua --- luajit -jdump=ixT,myapp.dump myapp.lua --- --- The first argument specifies the dump mode. The second argument gives --- the output file name. Default output is to stdout, unless the environment --- variable LUAJIT_DUMPFILE is set. The file is overwritten every time the --- module is started. --- --- Different features can be turned on or off with the dump mode. If the --- mode starts with a '+', the following features are added to the default --- set of features; a '-' removes them. Otherwise the features are replaced. --- --- The following dump features are available (* marks the default): --- --- * t Print a line for each started, ended or aborted trace (see also -jv). --- * b Dump the traced bytecode. --- * i Dump the IR (intermediate representation). --- r Augment the IR with register/stack slots. --- s Dump the snapshot map. --- * m Dump the generated machine code. --- x Print each taken trace exit. --- X Print each taken trace exit and the contents of all registers. --- a Print the IR of aborted traces, too. --- --- The output format can be set with the following characters: --- --- T Plain text output. --- A ANSI-colored text output --- H Colorized HTML + CSS output. --- --- The default output format is plain text. It's set to ANSI-colored text --- if the COLORTERM variable is set. Note: this is independent of any output --- redirection, which is actually considered a feature. --- --- You probably want to use less -R to enjoy viewing ANSI-colored text from --- a pipe or a file. Add this to your ~/.bashrc: export LESS="-R" --- ------------------------------------------------------------------------------- - --- Cache some library functions and objects. -local jit = require("jit") -assert(jit.version_num == 20003, "LuaJIT core/library version mismatch") -local jutil = require("jit.util") -local vmdef = require("jit.vmdef") -local funcinfo, funcbc = jutil.funcinfo, jutil.funcbc -local traceinfo, traceir, tracek = jutil.traceinfo, jutil.traceir, jutil.tracek -local tracemc, tracesnap = jutil.tracemc, jutil.tracesnap -local traceexitstub, ircalladdr = jutil.traceexitstub, jutil.ircalladdr -local bit = require("bit") -local band, shl, shr = bit.band, bit.lshift, bit.rshift -local sub, gsub, format = string.sub, string.gsub, string.format -local byte, char, rep = string.byte, string.char, string.rep -local type, tostring = type, tostring -local stdout, stderr = io.stdout, io.stderr - --- Load other modules on-demand. -local bcline, disass - --- Active flag, output file handle and dump mode. -local active, out, dumpmode - ------------------------------------------------------------------------------- - -local symtabmt = { __index = false } -local symtab = {} -local nexitsym = 0 - --- Fill nested symbol table with per-trace exit stub addresses. -local function fillsymtab_tr(tr, nexit) - local t = {} - symtabmt.__index = t - if jit.arch == "mips" or jit.arch == "mipsel" then - t[traceexitstub(tr, 0)] = "exit" - return - end - for i=0,nexit-1 do - local addr = traceexitstub(tr, i) - t[addr] = tostring(i) - end - local addr = traceexitstub(tr, nexit) - if addr then t[addr] = "stack_check" end -end - --- Fill symbol table with trace exit stub addresses. -local function fillsymtab(tr, nexit) - local t = symtab - if nexitsym == 0 then - local ircall = vmdef.ircall - for i=0,#ircall do - local addr = ircalladdr(i) - if addr ~= 0 then t[addr] = ircall[i] end - end - end - if nexitsym == 1000000 then -- Per-trace exit stubs. - fillsymtab_tr(tr, nexit) - elseif nexit > nexitsym then -- Shared exit stubs. - for i=nexitsym,nexit-1 do - local addr = traceexitstub(i) - if addr == nil then -- Fall back to per-trace exit stubs. - fillsymtab_tr(tr, nexit) - setmetatable(symtab, symtabmt) - nexit = 1000000 - break - end - t[addr] = tostring(i) - end - nexitsym = nexit - end - return t -end - -local function dumpwrite(s) - out:write(s) -end - --- Disassemble machine code. -local function dump_mcode(tr) - local info = traceinfo(tr) - if not info then return end - local mcode, addr, loop = tracemc(tr) - if not mcode then return end - if not disass then disass = require("jit.dis_"..jit.arch) end - out:write("---- TRACE ", tr, " mcode ", #mcode, "\n") - local ctx = disass.create(mcode, addr, dumpwrite) - ctx.hexdump = 0 - ctx.symtab = fillsymtab(tr, info.nexit) - if loop ~= 0 then - symtab[addr+loop] = "LOOP" - ctx:disass(0, loop) - out:write("->LOOP:\n") - ctx:disass(loop, #mcode-loop) - symtab[addr+loop] = nil - else - ctx:disass(0, #mcode) - end -end - ------------------------------------------------------------------------------- - -local irtype_text = { - [0] = "nil", - "fal", - "tru", - "lud", - "str", - "p32", - "thr", - "pro", - "fun", - "p64", - "cdt", - "tab", - "udt", - "flt", - "num", - "i8 ", - "u8 ", - "i16", - "u16", - "int", - "u32", - "i64", - "u64", - "sfp", -} - -local colortype_ansi = { - [0] = "%s", - "%s", - "%s", - "\027[36m%s\027[m", - "\027[32m%s\027[m", - "%s", - "\027[1m%s\027[m", - "%s", - "\027[1m%s\027[m", - "%s", - "\027[33m%s\027[m", - "\027[31m%s\027[m", - "\027[36m%s\027[m", - "\027[34m%s\027[m", - "\027[34m%s\027[m", - "\027[35m%s\027[m", - "\027[35m%s\027[m", - "\027[35m%s\027[m", - "\027[35m%s\027[m", - "\027[35m%s\027[m", - "\027[35m%s\027[m", - "\027[35m%s\027[m", - "\027[35m%s\027[m", - "\027[35m%s\027[m", -} - -local function colorize_text(s, t) - return s -end - -local function colorize_ansi(s, t) - return format(colortype_ansi[t], s) -end - -local irtype_ansi = setmetatable({}, - { __index = function(tab, t) - local s = colorize_ansi(irtype_text[t], t); tab[t] = s; return s; end }) - -local html_escape = { ["<"] = "<", [">"] = ">", ["&"] = "&", } - -local function colorize_html(s, t) - s = gsub(s, "[<>&]", html_escape) - return format('%s', irtype_text[t], s) -end - -local irtype_html = setmetatable({}, - { __index = function(tab, t) - local s = colorize_html(irtype_text[t], t); tab[t] = s; return s; end }) - -local header_html = [[ - -]] - -local colorize, irtype - --- Lookup tables to convert some literals into names. -local litname = { - ["SLOAD "] = setmetatable({}, { __index = function(t, mode) - local s = "" - if band(mode, 1) ~= 0 then s = s.."P" end - if band(mode, 2) ~= 0 then s = s.."F" end - if band(mode, 4) ~= 0 then s = s.."T" end - if band(mode, 8) ~= 0 then s = s.."C" end - if band(mode, 16) ~= 0 then s = s.."R" end - if band(mode, 32) ~= 0 then s = s.."I" end - t[mode] = s - return s - end}), - ["XLOAD "] = { [0] = "", "R", "V", "RV", "U", "RU", "VU", "RVU", }, - ["CONV "] = setmetatable({}, { __index = function(t, mode) - local s = irtype[band(mode, 31)] - s = irtype[band(shr(mode, 5), 31)].."."..s - if band(mode, 0x400) ~= 0 then s = s.." trunc" - elseif band(mode, 0x800) ~= 0 then s = s.." sext" end - local c = shr(mode, 14) - if c == 2 then s = s.." index" elseif c == 3 then s = s.." check" end - t[mode] = s - return s - end}), - ["FLOAD "] = vmdef.irfield, - ["FREF "] = vmdef.irfield, - ["FPMATH"] = vmdef.irfpm, -} - -local function ctlsub(c) - if c == "\n" then return "\\n" - elseif c == "\r" then return "\\r" - elseif c == "\t" then return "\\t" - else return format("\\%03d", byte(c)) - end -end - -local function fmtfunc(func, pc) - local fi = funcinfo(func, pc) - if fi.loc then - return fi.loc - elseif fi.ffid then - return vmdef.ffnames[fi.ffid] - elseif fi.addr then - return format("C:%x", fi.addr) - else - return "(?)" - end -end - -local function formatk(tr, idx) - local k, t, slot = tracek(tr, idx) - local tn = type(k) - local s - if tn == "number" then - if k == 2^52+2^51 then - s = "bias" - else - s = format("%+.14g", k) - end - elseif tn == "string" then - s = format(#k > 20 and '"%.20s"~' or '"%s"', gsub(k, "%c", ctlsub)) - elseif tn == "function" then - s = fmtfunc(k) - elseif tn == "table" then - s = format("{%p}", k) - elseif tn == "userdata" then - if t == 12 then - s = format("userdata:%p", k) - else - s = format("[%p]", k) - if s == "[0x00000000]" then s = "NULL" end - end - elseif t == 21 then -- int64_t - s = sub(tostring(k), 1, -3) - if sub(s, 1, 1) ~= "-" then s = "+"..s end - else - s = tostring(k) -- For primitives. - end - s = colorize(format("%-4s", s), t) - if slot then - s = format("%s @%d", s, slot) - end - return s -end - -local function printsnap(tr, snap) - local n = 2 - for s=0,snap[1]-1 do - local sn = snap[n] - if shr(sn, 24) == s then - n = n + 1 - local ref = band(sn, 0xffff) - 0x8000 -- REF_BIAS - if ref < 0 then - out:write(formatk(tr, ref)) - elseif band(sn, 0x80000) ~= 0 then -- SNAP_SOFTFPNUM - out:write(colorize(format("%04d/%04d", ref, ref+1), 14)) - else - local m, ot, op1, op2 = traceir(tr, ref) - out:write(colorize(format("%04d", ref), band(ot, 31))) - end - out:write(band(sn, 0x10000) == 0 and " " or "|") -- SNAP_FRAME - else - out:write("---- ") - end - end - out:write("]\n") -end - --- Dump snapshots (not interleaved with IR). -local function dump_snap(tr) - out:write("---- TRACE ", tr, " snapshots\n") - for i=0,1000000000 do - local snap = tracesnap(tr, i) - if not snap then break end - out:write(format("#%-3d %04d [ ", i, snap[0])) - printsnap(tr, snap) - end -end - --- Return a register name or stack slot for a rid/sp location. -local function ridsp_name(ridsp, ins) - if not disass then disass = require("jit.dis_"..jit.arch) end - local rid, slot = band(ridsp, 0xff), shr(ridsp, 8) - if rid == 253 or rid == 254 then - return (slot == 0 or slot == 255) and " {sink" or format(" {%04d", ins-slot) - end - if ridsp > 255 then return format("[%x]", slot*4) end - if rid < 128 then return disass.regname(rid) end - return "" -end - --- Dump CALL* function ref and return optional ctype. -local function dumpcallfunc(tr, ins) - local ctype - if ins > 0 then - local m, ot, op1, op2 = traceir(tr, ins) - if band(ot, 31) == 0 then -- nil type means CARG(func, ctype). - ins = op1 - ctype = formatk(tr, op2) - end - end - if ins < 0 then - out:write(format("[0x%x](", tonumber((tracek(tr, ins))))) - else - out:write(format("%04d (", ins)) - end - return ctype -end - --- Recursively gather CALL* args and dump them. -local function dumpcallargs(tr, ins) - if ins < 0 then - out:write(formatk(tr, ins)) - else - local m, ot, op1, op2 = traceir(tr, ins) - local oidx = 6*shr(ot, 8) - local op = sub(vmdef.irnames, oidx+1, oidx+6) - if op == "CARG " then - dumpcallargs(tr, op1) - if op2 < 0 then - out:write(" ", formatk(tr, op2)) - else - out:write(" ", format("%04d", op2)) - end - else - out:write(format("%04d", ins)) - end - end -end - --- Dump IR and interleaved snapshots. -local function dump_ir(tr, dumpsnap, dumpreg) - local info = traceinfo(tr) - if not info then return end - local nins = info.nins - out:write("---- TRACE ", tr, " IR\n") - local irnames = vmdef.irnames - local snapref = 65536 - local snap, snapno - if dumpsnap then - snap = tracesnap(tr, 0) - snapref = snap[0] - snapno = 0 - end - for ins=1,nins do - if ins >= snapref then - if dumpreg then - out:write(format(".... SNAP #%-3d [ ", snapno)) - else - out:write(format(".... SNAP #%-3d [ ", snapno)) - end - printsnap(tr, snap) - snapno = snapno + 1 - snap = tracesnap(tr, snapno) - snapref = snap and snap[0] or 65536 - end - local m, ot, op1, op2, ridsp = traceir(tr, ins) - local oidx, t = 6*shr(ot, 8), band(ot, 31) - local op = sub(irnames, oidx+1, oidx+6) - if op == "LOOP " then - if dumpreg then - out:write(format("%04d ------------ LOOP ------------\n", ins)) - else - out:write(format("%04d ------ LOOP ------------\n", ins)) - end - elseif op ~= "NOP " and op ~= "CARG " and - (dumpreg or op ~= "RENAME") then - local rid = band(ridsp, 255) - if dumpreg then - out:write(format("%04d %-6s", ins, ridsp_name(ridsp, ins))) - else - out:write(format("%04d ", ins)) - end - out:write(format("%s%s %s %s ", - (rid == 254 or rid == 253) and "}" or - (band(ot, 128) == 0 and " " or ">"), - band(ot, 64) == 0 and " " or "+", - irtype[t], op)) - local m1, m2 = band(m, 3), band(m, 3*4) - if sub(op, 1, 4) == "CALL" then - local ctype - if m2 == 1*4 then -- op2 == IRMlit - out:write(format("%-10s (", vmdef.ircall[op2])) - else - ctype = dumpcallfunc(tr, op2) - end - if op1 ~= -1 then dumpcallargs(tr, op1) end - out:write(")") - if ctype then out:write(" ctype ", ctype) end - elseif op == "CNEW " and op2 == -1 then - out:write(formatk(tr, op1)) - elseif m1 ~= 3 then -- op1 != IRMnone - if op1 < 0 then - out:write(formatk(tr, op1)) - else - out:write(format(m1 == 0 and "%04d" or "#%-3d", op1)) - end - if m2 ~= 3*4 then -- op2 != IRMnone - if m2 == 1*4 then -- op2 == IRMlit - local litn = litname[op] - if litn and litn[op2] then - out:write(" ", litn[op2]) - elseif op == "UREFO " or op == "UREFC " then - out:write(format(" #%-3d", shr(op2, 8))) - else - out:write(format(" #%-3d", op2)) - end - elseif op2 < 0 then - out:write(" ", formatk(tr, op2)) - else - out:write(format(" %04d", op2)) - end - end - end - out:write("\n") - end - end - if snap then - if dumpreg then - out:write(format(".... SNAP #%-3d [ ", snapno)) - else - out:write(format(".... SNAP #%-3d [ ", snapno)) - end - printsnap(tr, snap) - end -end - ------------------------------------------------------------------------------- - -local recprefix = "" -local recdepth = 0 - --- Format trace error message. -local function fmterr(err, info) - if type(err) == "number" then - if type(info) == "function" then info = fmtfunc(info) end - err = format(vmdef.traceerr[err], info) - end - return err -end - --- Dump trace states. -local function dump_trace(what, tr, func, pc, otr, oex) - if what == "stop" or (what == "abort" and dumpmode.a) then - if dumpmode.i then dump_ir(tr, dumpmode.s, dumpmode.r and what == "stop") - elseif dumpmode.s then dump_snap(tr) end - if dumpmode.m then dump_mcode(tr) end - end - if what == "start" then - if dumpmode.H then out:write('
\n') end
-    out:write("---- TRACE ", tr, " ", what)
-    if otr then out:write(" ", otr, "/", oex) end
-    out:write(" ", fmtfunc(func, pc), "\n")
-  elseif what == "stop" or what == "abort" then
-    out:write("---- TRACE ", tr, " ", what)
-    if what == "abort" then
-      out:write(" ", fmtfunc(func, pc), " -- ", fmterr(otr, oex), "\n")
-    else
-      local info = traceinfo(tr)
-      local link, ltype = info.link, info.linktype
-      if link == tr or link == 0 then
-	out:write(" -> ", ltype, "\n")
-      elseif ltype == "root" then
-	out:write(" -> ", link, "\n")
-      else
-	out:write(" -> ", link, " ", ltype, "\n")
-      end
-    end
-    if dumpmode.H then out:write("
\n\n") else out:write("\n") end - else - out:write("---- TRACE ", what, "\n\n") - end - out:flush() -end - --- Dump recorded bytecode. -local function dump_record(tr, func, pc, depth, callee) - if depth ~= recdepth then - recdepth = depth - recprefix = rep(" .", depth) - end - local line - if pc >= 0 then - line = bcline(func, pc, recprefix) - if dumpmode.H then line = gsub(line, "[<>&]", html_escape) end - else - line = "0000 "..recprefix.." FUNCC \n" - callee = func - end - if pc <= 0 then - out:write(sub(line, 1, -2), " ; ", fmtfunc(func), "\n") - else - out:write(line) - end - if pc >= 0 and band(funcbc(func, pc), 0xff) < 16 then -- ORDER BC - out:write(bcline(func, pc+1, recprefix)) -- Write JMP for cond. - end -end - ------------------------------------------------------------------------------- - --- Dump taken trace exits. -local function dump_texit(tr, ex, ngpr, nfpr, ...) - out:write("---- TRACE ", tr, " exit ", ex, "\n") - if dumpmode.X then - local regs = {...} - if jit.arch == "x64" then - for i=1,ngpr do - out:write(format(" %016x", regs[i])) - if i % 4 == 0 then out:write("\n") end - end - else - for i=1,ngpr do - out:write(format(" %08x", regs[i])) - if i % 8 == 0 then out:write("\n") end - end - end - if jit.arch == "mips" or jit.arch == "mipsel" then - for i=1,nfpr,2 do - out:write(format(" %+17.14g", regs[ngpr+i])) - if i % 8 == 7 then out:write("\n") end - end - else - for i=1,nfpr do - out:write(format(" %+17.14g", regs[ngpr+i])) - if i % 4 == 0 then out:write("\n") end - end - end - end -end - ------------------------------------------------------------------------------- - --- Detach dump handlers. -local function dumpoff() - if active then - active = false - jit.attach(dump_texit) - jit.attach(dump_record) - jit.attach(dump_trace) - if out and out ~= stdout and out ~= stderr then out:close() end - out = nil - end -end - --- Open the output file and attach dump handlers. -local function dumpon(opt, outfile) - if active then dumpoff() end - - local colormode = os.getenv("COLORTERM") and "A" or "T" - if opt then - opt = gsub(opt, "[TAH]", function(mode) colormode = mode; return ""; end) - end - - local m = { t=true, b=true, i=true, m=true, } - if opt and opt ~= "" then - local o = sub(opt, 1, 1) - if o ~= "+" and o ~= "-" then m = {} end - for i=1,#opt do m[sub(opt, i, i)] = (o ~= "-") end - end - dumpmode = m - - if m.t or m.b or m.i or m.s or m.m then - jit.attach(dump_trace, "trace") - end - if m.b then - jit.attach(dump_record, "record") - if not bcline then bcline = require("jit.bc").line end - end - if m.x or m.X then - jit.attach(dump_texit, "texit") - end - - if not outfile then outfile = os.getenv("LUAJIT_DUMPFILE") end - if outfile then - out = outfile == "-" and stdout or assert(io.open(outfile, "w")) - else - out = stdout - end - - m[colormode] = true - if colormode == "A" then - colorize = colorize_ansi - irtype = irtype_ansi - elseif colormode == "H" then - colorize = colorize_html - irtype = irtype_html - out:write(header_html) - else - colorize = colorize_text - irtype = irtype_text - end - - active = true -end - --- Public module functions. -module(...) - -on = dumpon -off = dumpoff -start = dumpon -- For -j command line option. - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/jit/v.lua b/source/libs/luajit/LuaJIT-2.0.3/src/jit/v.lua deleted file mode 100644 index 197e67c69..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/jit/v.lua +++ /dev/null @@ -1,167 +0,0 @@ ----------------------------------------------------------------------------- --- Verbose mode of the LuaJIT compiler. --- --- Copyright (C) 2005-2014 Mike Pall. All rights reserved. --- Released under the MIT license. See Copyright Notice in luajit.h ----------------------------------------------------------------------------- --- --- This module shows verbose information about the progress of the --- JIT compiler. It prints one line for each generated trace. This module --- is useful to see which code has been compiled or where the compiler --- punts and falls back to the interpreter. --- --- Example usage: --- --- luajit -jv -e "for i=1,1000 do for j=1,1000 do end end" --- luajit -jv=myapp.out myapp.lua --- --- Default output is to stderr. To redirect the output to a file, pass a --- filename as an argument (use '-' for stdout) or set the environment --- variable LUAJIT_VERBOSEFILE. The file is overwritten every time the --- module is started. --- --- The output from the first example should look like this: --- --- [TRACE 1 (command line):1 loop] --- [TRACE 2 (1/3) (command line):1 -> 1] --- --- The first number in each line is the internal trace number. Next are --- the file name ('(command line)') and the line number (':1') where the --- trace has started. Side traces also show the parent trace number and --- the exit number where they are attached to in parentheses ('(1/3)'). --- An arrow at the end shows where the trace links to ('-> 1'), unless --- it loops to itself. --- --- In this case the inner loop gets hot and is traced first, generating --- a root trace. Then the last exit from the 1st trace gets hot, too, --- and triggers generation of the 2nd trace. The side trace follows the --- path along the outer loop and *around* the inner loop, back to its --- start, and then links to the 1st trace. Yes, this may seem unusual, --- if you know how traditional compilers work. Trace compilers are full --- of surprises like this -- have fun! :-) --- --- Aborted traces are shown like this: --- --- [TRACE --- foo.lua:44 -- leaving loop in root trace at foo:lua:50] --- --- Don't worry -- trace aborts are quite common, even in programs which --- can be fully compiled. The compiler may retry several times until it --- finds a suitable trace. --- --- Of course this doesn't work with features that are not-yet-implemented --- (NYI error messages). The VM simply falls back to the interpreter. This --- may not matter at all if the particular trace is not very high up in --- the CPU usage profile. Oh, and the interpreter is quite fast, too. --- --- Also check out the -jdump module, which prints all the gory details. --- ------------------------------------------------------------------------------- - --- Cache some library functions and objects. -local jit = require("jit") -assert(jit.version_num == 20003, "LuaJIT core/library version mismatch") -local jutil = require("jit.util") -local vmdef = require("jit.vmdef") -local funcinfo, traceinfo = jutil.funcinfo, jutil.traceinfo -local type, format = type, string.format -local stdout, stderr = io.stdout, io.stderr - --- Active flag and output file handle. -local active, out - ------------------------------------------------------------------------------- - -local startloc, startex - -local function fmtfunc(func, pc) - local fi = funcinfo(func, pc) - if fi.loc then - return fi.loc - elseif fi.ffid then - return vmdef.ffnames[fi.ffid] - elseif fi.addr then - return format("C:%x", fi.addr) - else - return "(?)" - end -end - --- Format trace error message. -local function fmterr(err, info) - if type(err) == "number" then - if type(info) == "function" then info = fmtfunc(info) end - err = format(vmdef.traceerr[err], info) - end - return err -end - --- Dump trace states. -local function dump_trace(what, tr, func, pc, otr, oex) - if what == "start" then - startloc = fmtfunc(func, pc) - startex = otr and "("..otr.."/"..oex..") " or "" - else - if what == "abort" then - local loc = fmtfunc(func, pc) - if loc ~= startloc then - out:write(format("[TRACE --- %s%s -- %s at %s]\n", - startex, startloc, fmterr(otr, oex), loc)) - else - out:write(format("[TRACE --- %s%s -- %s]\n", - startex, startloc, fmterr(otr, oex))) - end - elseif what == "stop" then - local info = traceinfo(tr) - local link, ltype = info.link, info.linktype - if ltype == "interpreter" then - out:write(format("[TRACE %3s %s%s -- fallback to interpreter]\n", - tr, startex, startloc)) - elseif link == tr or link == 0 then - out:write(format("[TRACE %3s %s%s %s]\n", - tr, startex, startloc, ltype)) - elseif ltype == "root" then - out:write(format("[TRACE %3s %s%s -> %d]\n", - tr, startex, startloc, link)) - else - out:write(format("[TRACE %3s %s%s -> %d %s]\n", - tr, startex, startloc, link, ltype)) - end - else - out:write(format("[TRACE %s]\n", what)) - end - out:flush() - end -end - ------------------------------------------------------------------------------- - --- Detach dump handlers. -local function dumpoff() - if active then - active = false - jit.attach(dump_trace) - if out and out ~= stdout and out ~= stderr then out:close() end - out = nil - end -end - --- Open the output file and attach dump handlers. -local function dumpon(outfile) - if active then dumpoff() end - if not outfile then outfile = os.getenv("LUAJIT_VERBOSEFILE") end - if outfile then - out = outfile == "-" and stdout or assert(io.open(outfile, "w")) - else - out = stderr - end - jit.attach(dump_trace, "trace") - active = true -end - --- Public module functions. -module(...) - -on = dumpon -off = dumpoff -start = dumpon -- For -j command line option. - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lib_aux.c b/source/libs/luajit/LuaJIT-2.0.3/src/lib_aux.c deleted file mode 100644 index 1b01fe070..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lib_aux.c +++ /dev/null @@ -1,356 +0,0 @@ -/* -** Auxiliary library for the Lua/C API. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Major parts taken verbatim or adapted from the Lua interpreter. -** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h -*/ - -#include -#include -#include - -#define lib_aux_c -#define LUA_LIB - -#include "lua.h" -#include "lauxlib.h" - -#include "lj_obj.h" -#include "lj_err.h" -#include "lj_state.h" -#include "lj_trace.h" -#include "lj_lib.h" - -#if LJ_TARGET_POSIX -#include -#endif - -/* -- I/O error handling -------------------------------------------------- */ - -LUALIB_API int luaL_fileresult(lua_State *L, int stat, const char *fname) -{ - if (stat) { - setboolV(L->top++, 1); - return 1; - } else { - int en = errno; /* Lua API calls may change this value. */ - setnilV(L->top++); - if (fname) - lua_pushfstring(L, "%s: %s", fname, strerror(en)); - else - lua_pushfstring(L, "%s", strerror(en)); - setintV(L->top++, en); - lj_trace_abort(G(L)); - return 3; - } -} - -LUALIB_API int luaL_execresult(lua_State *L, int stat) -{ - if (stat != -1) { -#if LJ_TARGET_POSIX - if (WIFSIGNALED(stat)) { - stat = WTERMSIG(stat); - setnilV(L->top++); - lua_pushliteral(L, "signal"); - } else { - if (WIFEXITED(stat)) - stat = WEXITSTATUS(stat); - if (stat == 0) - setboolV(L->top++, 1); - else - setnilV(L->top++); - lua_pushliteral(L, "exit"); - } -#else - if (stat == 0) - setboolV(L->top++, 1); - else - setnilV(L->top++); - lua_pushliteral(L, "exit"); -#endif - setintV(L->top++, stat); - return 3; - } - return luaL_fileresult(L, 0, NULL); -} - -/* -- Module registration ------------------------------------------------- */ - -LUALIB_API const char *luaL_findtable(lua_State *L, int idx, - const char *fname, int szhint) -{ - const char *e; - lua_pushvalue(L, idx); - do { - e = strchr(fname, '.'); - if (e == NULL) e = fname + strlen(fname); - lua_pushlstring(L, fname, (size_t)(e - fname)); - lua_rawget(L, -2); - if (lua_isnil(L, -1)) { /* no such field? */ - lua_pop(L, 1); /* remove this nil */ - lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ - lua_pushlstring(L, fname, (size_t)(e - fname)); - lua_pushvalue(L, -2); - lua_settable(L, -4); /* set new table into field */ - } else if (!lua_istable(L, -1)) { /* field has a non-table value? */ - lua_pop(L, 2); /* remove table and value */ - return fname; /* return problematic part of the name */ - } - lua_remove(L, -2); /* remove previous table */ - fname = e + 1; - } while (*e == '.'); - return NULL; -} - -static int libsize(const luaL_Reg *l) -{ - int size = 0; - for (; l->name; l++) size++; - return size; -} - -LUALIB_API void luaL_openlib(lua_State *L, const char *libname, - const luaL_Reg *l, int nup) -{ - lj_lib_checkfpu(L); - if (libname) { - int size = libsize(l); - /* check whether lib already exists */ - luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 16); - lua_getfield(L, -1, libname); /* get _LOADED[libname] */ - if (!lua_istable(L, -1)) { /* not found? */ - lua_pop(L, 1); /* remove previous result */ - /* try global variable (and create one if it does not exist) */ - if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL) - lj_err_callerv(L, LJ_ERR_BADMODN, libname); - lua_pushvalue(L, -1); - lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ - } - lua_remove(L, -2); /* remove _LOADED table */ - lua_insert(L, -(nup+1)); /* move library table to below upvalues */ - } - for (; l->name; l++) { - int i; - for (i = 0; i < nup; i++) /* copy upvalues to the top */ - lua_pushvalue(L, -nup); - lua_pushcclosure(L, l->func, nup); - lua_setfield(L, -(nup+2), l->name); - } - lua_pop(L, nup); /* remove upvalues */ -} - -LUALIB_API void luaL_register(lua_State *L, const char *libname, - const luaL_Reg *l) -{ - luaL_openlib(L, libname, l, 0); -} - -LUALIB_API const char *luaL_gsub(lua_State *L, const char *s, - const char *p, const char *r) -{ - const char *wild; - size_t l = strlen(p); - luaL_Buffer b; - luaL_buffinit(L, &b); - while ((wild = strstr(s, p)) != NULL) { - luaL_addlstring(&b, s, (size_t)(wild - s)); /* push prefix */ - luaL_addstring(&b, r); /* push replacement in place of pattern */ - s = wild + l; /* continue after `p' */ - } - luaL_addstring(&b, s); /* push last suffix */ - luaL_pushresult(&b); - return lua_tostring(L, -1); -} - -/* -- Buffer handling ----------------------------------------------------- */ - -#define bufflen(B) ((size_t)((B)->p - (B)->buffer)) -#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B))) - -static int emptybuffer(luaL_Buffer *B) -{ - size_t l = bufflen(B); - if (l == 0) - return 0; /* put nothing on stack */ - lua_pushlstring(B->L, B->buffer, l); - B->p = B->buffer; - B->lvl++; - return 1; -} - -static void adjuststack(luaL_Buffer *B) -{ - if (B->lvl > 1) { - lua_State *L = B->L; - int toget = 1; /* number of levels to concat */ - size_t toplen = lua_strlen(L, -1); - do { - size_t l = lua_strlen(L, -(toget+1)); - if (!(B->lvl - toget + 1 >= LUA_MINSTACK/2 || toplen > l)) - break; - toplen += l; - toget++; - } while (toget < B->lvl); - lua_concat(L, toget); - B->lvl = B->lvl - toget + 1; - } -} - -LUALIB_API char *luaL_prepbuffer(luaL_Buffer *B) -{ - if (emptybuffer(B)) - adjuststack(B); - return B->buffer; -} - -LUALIB_API void luaL_addlstring(luaL_Buffer *B, const char *s, size_t l) -{ - while (l--) - luaL_addchar(B, *s++); -} - -LUALIB_API void luaL_addstring(luaL_Buffer *B, const char *s) -{ - luaL_addlstring(B, s, strlen(s)); -} - -LUALIB_API void luaL_pushresult(luaL_Buffer *B) -{ - emptybuffer(B); - lua_concat(B->L, B->lvl); - B->lvl = 1; -} - -LUALIB_API void luaL_addvalue(luaL_Buffer *B) -{ - lua_State *L = B->L; - size_t vl; - const char *s = lua_tolstring(L, -1, &vl); - if (vl <= bufffree(B)) { /* fit into buffer? */ - memcpy(B->p, s, vl); /* put it there */ - B->p += vl; - lua_pop(L, 1); /* remove from stack */ - } else { - if (emptybuffer(B)) - lua_insert(L, -2); /* put buffer before new value */ - B->lvl++; /* add new value into B stack */ - adjuststack(B); - } -} - -LUALIB_API void luaL_buffinit(lua_State *L, luaL_Buffer *B) -{ - B->L = L; - B->p = B->buffer; - B->lvl = 0; -} - -/* -- Reference management ------------------------------------------------ */ - -#define FREELIST_REF 0 - -/* Convert a stack index to an absolute index. */ -#define abs_index(L, i) \ - ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : lua_gettop(L) + (i) + 1) - -LUALIB_API int luaL_ref(lua_State *L, int t) -{ - int ref; - t = abs_index(L, t); - if (lua_isnil(L, -1)) { - lua_pop(L, 1); /* remove from stack */ - return LUA_REFNIL; /* `nil' has a unique fixed reference */ - } - lua_rawgeti(L, t, FREELIST_REF); /* get first free element */ - ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */ - lua_pop(L, 1); /* remove it from stack */ - if (ref != 0) { /* any free element? */ - lua_rawgeti(L, t, ref); /* remove it from list */ - lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ - } else { /* no free elements */ - ref = (int)lua_objlen(L, t); - ref++; /* create new reference */ - } - lua_rawseti(L, t, ref); - return ref; -} - -LUALIB_API void luaL_unref(lua_State *L, int t, int ref) -{ - if (ref >= 0) { - t = abs_index(L, t); - lua_rawgeti(L, t, FREELIST_REF); - lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */ - lua_pushinteger(L, ref); - lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */ - } -} - -/* -- Default allocator and panic function -------------------------------- */ - -static int panic(lua_State *L) -{ - const char *s = lua_tostring(L, -1); - fputs("PANIC: unprotected error in call to Lua API (", stderr); - fputs(s ? s : "?", stderr); - fputc(')', stderr); fputc('\n', stderr); - fflush(stderr); - return 0; -} - -#ifdef LUAJIT_USE_SYSMALLOC - -#if LJ_64 -#error "Must use builtin allocator for 64 bit target" -#endif - -static void *mem_alloc(void *ud, void *ptr, size_t osize, size_t nsize) -{ - (void)ud; - (void)osize; - if (nsize == 0) { - free(ptr); - return NULL; - } else { - return realloc(ptr, nsize); - } -} - -LUALIB_API lua_State *luaL_newstate(void) -{ - lua_State *L = lua_newstate(mem_alloc, NULL); - if (L) G(L)->panic = panic; - return L; -} - -#else - -#include "lj_alloc.h" - -LUALIB_API lua_State *luaL_newstate(void) -{ - lua_State *L; - void *ud = lj_alloc_create(); - if (ud == NULL) return NULL; -#if LJ_64 - L = lj_state_newstate(lj_alloc_f, ud); -#else - L = lua_newstate(lj_alloc_f, ud); -#endif - if (L) G(L)->panic = panic; - return L; -} - -#if LJ_64 -LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) -{ - UNUSED(f); UNUSED(ud); - fputs("Must use luaL_newstate() for 64 bit target\n", stderr); - return NULL; -} -#endif - -#endif - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lib_base.c b/source/libs/luajit/LuaJIT-2.0.3/src/lib_base.c deleted file mode 100644 index 30e88f19d..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lib_base.c +++ /dev/null @@ -1,683 +0,0 @@ -/* -** Base and coroutine library. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Major portions taken verbatim or adapted from the Lua interpreter. -** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h -*/ - -#include - -#define lib_base_c -#define LUA_LIB - -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" - -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_debug.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_meta.h" -#include "lj_state.h" -#if LJ_HASFFI -#include "lj_ctype.h" -#include "lj_cconv.h" -#endif -#include "lj_bc.h" -#include "lj_ff.h" -#include "lj_dispatch.h" -#include "lj_char.h" -#include "lj_strscan.h" -#include "lj_lib.h" - -/* -- Base library: checks ------------------------------------------------ */ - -#define LJLIB_MODULE_base - -LJLIB_ASM(assert) LJLIB_REC(.) -{ - GCstr *s; - lj_lib_checkany(L, 1); - s = lj_lib_optstr(L, 2); - if (s) - lj_err_callermsg(L, strdata(s)); - else - lj_err_caller(L, LJ_ERR_ASSERT); - return FFH_UNREACHABLE; -} - -/* ORDER LJ_T */ -LJLIB_PUSH("nil") -LJLIB_PUSH("boolean") -LJLIB_PUSH(top-1) /* boolean */ -LJLIB_PUSH("userdata") -LJLIB_PUSH("string") -LJLIB_PUSH("upval") -LJLIB_PUSH("thread") -LJLIB_PUSH("proto") -LJLIB_PUSH("function") -LJLIB_PUSH("trace") -LJLIB_PUSH("cdata") -LJLIB_PUSH("table") -LJLIB_PUSH(top-9) /* userdata */ -LJLIB_PUSH("number") -LJLIB_ASM_(type) LJLIB_REC(.) -/* Recycle the lj_lib_checkany(L, 1) from assert. */ - -/* -- Base library: iterators --------------------------------------------- */ - -/* This solves a circular dependency problem -- change FF_next_N as needed. */ -LJ_STATIC_ASSERT((int)FF_next == FF_next_N); - -LJLIB_ASM(next) -{ - lj_lib_checktab(L, 1); - return FFH_UNREACHABLE; -} - -#if LJ_52 || LJ_HASFFI -static int ffh_pairs(lua_State *L, MMS mm) -{ - TValue *o = lj_lib_checkany(L, 1); - cTValue *mo = lj_meta_lookup(L, o, mm); - if ((LJ_52 || tviscdata(o)) && !tvisnil(mo)) { - L->top = o+1; /* Only keep one argument. */ - copyTV(L, L->base-1, mo); /* Replace callable. */ - return FFH_TAILCALL; - } else { - if (!tvistab(o)) lj_err_argt(L, 1, LUA_TTABLE); - setfuncV(L, o-1, funcV(lj_lib_upvalue(L, 1))); - if (mm == MM_pairs) setnilV(o+1); else setintV(o+1, 0); - return FFH_RES(3); - } -} -#else -#define ffh_pairs(L, mm) (lj_lib_checktab(L, 1), FFH_UNREACHABLE) -#endif - -LJLIB_PUSH(lastcl) -LJLIB_ASM(pairs) -{ - return ffh_pairs(L, MM_pairs); -} - -LJLIB_NOREGUV LJLIB_ASM(ipairs_aux) LJLIB_REC(.) -{ - lj_lib_checktab(L, 1); - lj_lib_checkint(L, 2); - return FFH_UNREACHABLE; -} - -LJLIB_PUSH(lastcl) -LJLIB_ASM(ipairs) LJLIB_REC(.) -{ - return ffh_pairs(L, MM_ipairs); -} - -/* -- Base library: getters and setters ----------------------------------- */ - -LJLIB_ASM_(getmetatable) LJLIB_REC(.) -/* Recycle the lj_lib_checkany(L, 1) from assert. */ - -LJLIB_ASM(setmetatable) LJLIB_REC(.) -{ - GCtab *t = lj_lib_checktab(L, 1); - GCtab *mt = lj_lib_checktabornil(L, 2); - if (!tvisnil(lj_meta_lookup(L, L->base, MM_metatable))) - lj_err_caller(L, LJ_ERR_PROTMT); - setgcref(t->metatable, obj2gco(mt)); - if (mt) { lj_gc_objbarriert(L, t, mt); } - settabV(L, L->base-1, t); - return FFH_RES(1); -} - -LJLIB_CF(getfenv) -{ - GCfunc *fn; - cTValue *o = L->base; - if (!(o < L->top && tvisfunc(o))) { - int level = lj_lib_optint(L, 1, 1); - o = lj_debug_frame(L, level, &level); - if (o == NULL) - lj_err_arg(L, 1, LJ_ERR_INVLVL); - } - fn = &gcval(o)->fn; - settabV(L, L->top++, isluafunc(fn) ? tabref(fn->l.env) : tabref(L->env)); - return 1; -} - -LJLIB_CF(setfenv) -{ - GCfunc *fn; - GCtab *t = lj_lib_checktab(L, 2); - cTValue *o = L->base; - if (!(o < L->top && tvisfunc(o))) { - int level = lj_lib_checkint(L, 1); - if (level == 0) { - /* NOBARRIER: A thread (i.e. L) is never black. */ - setgcref(L->env, obj2gco(t)); - return 0; - } - o = lj_debug_frame(L, level, &level); - if (o == NULL) - lj_err_arg(L, 1, LJ_ERR_INVLVL); - } - fn = &gcval(o)->fn; - if (!isluafunc(fn)) - lj_err_caller(L, LJ_ERR_SETFENV); - setgcref(fn->l.env, obj2gco(t)); - lj_gc_objbarrier(L, obj2gco(fn), t); - setfuncV(L, L->top++, fn); - return 1; -} - -LJLIB_ASM(rawget) LJLIB_REC(.) -{ - lj_lib_checktab(L, 1); - lj_lib_checkany(L, 2); - return FFH_UNREACHABLE; -} - -LJLIB_CF(rawset) LJLIB_REC(.) -{ - lj_lib_checktab(L, 1); - lj_lib_checkany(L, 2); - L->top = 1+lj_lib_checkany(L, 3); - lua_rawset(L, 1); - return 1; -} - -LJLIB_CF(rawequal) LJLIB_REC(.) -{ - cTValue *o1 = lj_lib_checkany(L, 1); - cTValue *o2 = lj_lib_checkany(L, 2); - setboolV(L->top-1, lj_obj_equal(o1, o2)); - return 1; -} - -#if LJ_52 -LJLIB_CF(rawlen) LJLIB_REC(.) -{ - cTValue *o = L->base; - int32_t len; - if (L->top > o && tvisstr(o)) - len = (int32_t)strV(o)->len; - else - len = (int32_t)lj_tab_len(lj_lib_checktab(L, 1)); - setintV(L->top-1, len); - return 1; -} -#endif - -LJLIB_CF(unpack) -{ - GCtab *t = lj_lib_checktab(L, 1); - int32_t n, i = lj_lib_optint(L, 2, 1); - int32_t e = (L->base+3-1 < L->top && !tvisnil(L->base+3-1)) ? - lj_lib_checkint(L, 3) : (int32_t)lj_tab_len(t); - if (i > e) return 0; - n = e - i + 1; - if (n <= 0 || !lua_checkstack(L, n)) - lj_err_caller(L, LJ_ERR_UNPACK); - do { - cTValue *tv = lj_tab_getint(t, i); - if (tv) { - copyTV(L, L->top++, tv); - } else { - setnilV(L->top++); - } - } while (i++ < e); - return n; -} - -LJLIB_CF(select) LJLIB_REC(.) -{ - int32_t n = (int32_t)(L->top - L->base); - if (n >= 1 && tvisstr(L->base) && *strVdata(L->base) == '#') { - setintV(L->top-1, n-1); - return 1; - } else { - int32_t i = lj_lib_checkint(L, 1); - if (i < 0) i = n + i; else if (i > n) i = n; - if (i < 1) - lj_err_arg(L, 1, LJ_ERR_IDXRNG); - return n - i; - } -} - -/* -- Base library: conversions ------------------------------------------- */ - -LJLIB_ASM(tonumber) LJLIB_REC(.) -{ - int32_t base = lj_lib_optint(L, 2, 10); - if (base == 10) { - TValue *o = lj_lib_checkany(L, 1); - if (lj_strscan_numberobj(o)) { - copyTV(L, L->base-1, o); - return FFH_RES(1); - } -#if LJ_HASFFI - if (tviscdata(o)) { - CTState *cts = ctype_cts(L); - CType *ct = lj_ctype_rawref(cts, cdataV(o)->ctypeid); - if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); - if (ctype_isnum(ct->info) || ctype_iscomplex(ct->info)) { - if (LJ_DUALNUM && ctype_isinteger_or_bool(ct->info) && - ct->size <= 4 && !(ct->size == 4 && (ct->info & CTF_UNSIGNED))) { - int32_t i; - lj_cconv_ct_tv(cts, ctype_get(cts, CTID_INT32), (uint8_t *)&i, o, 0); - setintV(L->base-1, i); - return FFH_RES(1); - } - lj_cconv_ct_tv(cts, ctype_get(cts, CTID_DOUBLE), - (uint8_t *)&(L->base-1)->n, o, 0); - return FFH_RES(1); - } - } -#endif - } else { - const char *p = strdata(lj_lib_checkstr(L, 1)); - char *ep; - unsigned long ul; - if (base < 2 || base > 36) - lj_err_arg(L, 2, LJ_ERR_BASERNG); - ul = strtoul(p, &ep, base); - if (p != ep) { - while (lj_char_isspace((unsigned char)(*ep))) ep++; - if (*ep == '\0') { - if (LJ_DUALNUM && LJ_LIKELY(ul < 0x80000000u)) - setintV(L->base-1, (int32_t)ul); - else - setnumV(L->base-1, (lua_Number)ul); - return FFH_RES(1); - } - } - } - setnilV(L->base-1); - return FFH_RES(1); -} - -LJLIB_PUSH("nil") -LJLIB_PUSH("false") -LJLIB_PUSH("true") -LJLIB_ASM(tostring) LJLIB_REC(.) -{ - TValue *o = lj_lib_checkany(L, 1); - cTValue *mo; - L->top = o+1; /* Only keep one argument. */ - if (!tvisnil(mo = lj_meta_lookup(L, o, MM_tostring))) { - copyTV(L, L->base-1, mo); /* Replace callable. */ - return FFH_TAILCALL; - } else { - GCstr *s; - if (tvisnumber(o)) { - s = lj_str_fromnumber(L, o); - } else if (tvispri(o)) { - s = strV(lj_lib_upvalue(L, -(int32_t)itype(o))); - } else { - if (tvisfunc(o) && isffunc(funcV(o))) - lua_pushfstring(L, "function: builtin#%d", funcV(o)->c.ffid); - else - lua_pushfstring(L, "%s: %p", lj_typename(o), lua_topointer(L, 1)); - /* Note: lua_pushfstring calls the GC which may invalidate o. */ - s = strV(L->top-1); - } - setstrV(L, L->base-1, s); - return FFH_RES(1); - } -} - -/* -- Base library: throw and catch errors -------------------------------- */ - -LJLIB_CF(error) -{ - int32_t level = lj_lib_optint(L, 2, 1); - lua_settop(L, 1); - if (lua_isstring(L, 1) && level > 0) { - luaL_where(L, level); - lua_pushvalue(L, 1); - lua_concat(L, 2); - } - return lua_error(L); -} - -LJLIB_ASM(pcall) LJLIB_REC(.) -{ - lj_lib_checkany(L, 1); - lj_lib_checkfunc(L, 2); /* For xpcall only. */ - return FFH_UNREACHABLE; -} -LJLIB_ASM_(xpcall) LJLIB_REC(.) - -/* -- Base library: load Lua code ----------------------------------------- */ - -static int load_aux(lua_State *L, int status, int envarg) -{ - if (status == 0) { - if (tvistab(L->base+envarg-1)) { - GCfunc *fn = funcV(L->top-1); - GCtab *t = tabV(L->base+envarg-1); - setgcref(fn->c.env, obj2gco(t)); - lj_gc_objbarrier(L, fn, t); - } - return 1; - } else { - setnilV(L->top-2); - return 2; - } -} - -LJLIB_CF(loadfile) -{ - GCstr *fname = lj_lib_optstr(L, 1); - GCstr *mode = lj_lib_optstr(L, 2); - int status; - lua_settop(L, 3); /* Ensure env arg exists. */ - status = luaL_loadfilex(L, fname ? strdata(fname) : NULL, - mode ? strdata(mode) : NULL); - return load_aux(L, status, 3); -} - -static const char *reader_func(lua_State *L, void *ud, size_t *size) -{ - UNUSED(ud); - luaL_checkstack(L, 2, "too many nested functions"); - copyTV(L, L->top++, L->base); - lua_call(L, 0, 1); /* Call user-supplied function. */ - L->top--; - if (tvisnil(L->top)) { - *size = 0; - return NULL; - } else if (tvisstr(L->top) || tvisnumber(L->top)) { - copyTV(L, L->base+4, L->top); /* Anchor string in reserved stack slot. */ - return lua_tolstring(L, 5, size); - } else { - lj_err_caller(L, LJ_ERR_RDRSTR); - return NULL; - } -} - -LJLIB_CF(load) -{ - GCstr *name = lj_lib_optstr(L, 2); - GCstr *mode = lj_lib_optstr(L, 3); - int status; - if (L->base < L->top && (tvisstr(L->base) || tvisnumber(L->base))) { - GCstr *s = lj_lib_checkstr(L, 1); - lua_settop(L, 4); /* Ensure env arg exists. */ - status = luaL_loadbufferx(L, strdata(s), s->len, strdata(name ? name : s), - mode ? strdata(mode) : NULL); - } else { - lj_lib_checkfunc(L, 1); - lua_settop(L, 5); /* Reserve a slot for the string from the reader. */ - status = lua_loadx(L, reader_func, NULL, name ? strdata(name) : "=(load)", - mode ? strdata(mode) : NULL); - } - return load_aux(L, status, 4); -} - -LJLIB_CF(loadstring) -{ - return lj_cf_load(L); -} - -LJLIB_CF(dofile) -{ - GCstr *fname = lj_lib_optstr(L, 1); - setnilV(L->top); - L->top = L->base+1; - if (luaL_loadfile(L, fname ? strdata(fname) : NULL) != 0) - lua_error(L); - lua_call(L, 0, LUA_MULTRET); - return (int)(L->top - L->base) - 1; -} - -/* -- Base library: GC control -------------------------------------------- */ - -LJLIB_CF(gcinfo) -{ - setintV(L->top++, (G(L)->gc.total >> 10)); - return 1; -} - -LJLIB_CF(collectgarbage) -{ - int opt = lj_lib_checkopt(L, 1, LUA_GCCOLLECT, /* ORDER LUA_GC* */ - "\4stop\7restart\7collect\5count\1\377\4step\10setpause\12setstepmul"); - int32_t data = lj_lib_optint(L, 2, 0); - if (opt == LUA_GCCOUNT) { - setnumV(L->top, (lua_Number)G(L)->gc.total/1024.0); - } else { - int res = lua_gc(L, opt, data); - if (opt == LUA_GCSTEP) - setboolV(L->top, res); - else - setintV(L->top, res); - } - L->top++; - return 1; -} - -/* -- Base library: miscellaneous functions ------------------------------- */ - -LJLIB_PUSH(top-2) /* Upvalue holds weak table. */ -LJLIB_CF(newproxy) -{ - lua_settop(L, 1); - lua_newuserdata(L, 0); - if (lua_toboolean(L, 1) == 0) { /* newproxy(): without metatable. */ - return 1; - } else if (lua_isboolean(L, 1)) { /* newproxy(true): with metatable. */ - lua_newtable(L); - lua_pushvalue(L, -1); - lua_pushboolean(L, 1); - lua_rawset(L, lua_upvalueindex(1)); /* Remember mt in weak table. */ - } else { /* newproxy(proxy): inherit metatable. */ - int validproxy = 0; - if (lua_getmetatable(L, 1)) { - lua_rawget(L, lua_upvalueindex(1)); - validproxy = lua_toboolean(L, -1); - lua_pop(L, 1); - } - if (!validproxy) - lj_err_arg(L, 1, LJ_ERR_NOPROXY); - lua_getmetatable(L, 1); - } - lua_setmetatable(L, 2); - return 1; -} - -LJLIB_PUSH("tostring") -LJLIB_CF(print) -{ - ptrdiff_t i, nargs = L->top - L->base; - cTValue *tv = lj_tab_getstr(tabref(L->env), strV(lj_lib_upvalue(L, 1))); - int shortcut; - if (tv && !tvisnil(tv)) { - copyTV(L, L->top++, tv); - } else { - setstrV(L, L->top++, strV(lj_lib_upvalue(L, 1))); - lua_gettable(L, LUA_GLOBALSINDEX); - tv = L->top-1; - } - shortcut = (tvisfunc(tv) && funcV(tv)->c.ffid == FF_tostring); - for (i = 0; i < nargs; i++) { - const char *str; - size_t size; - cTValue *o = &L->base[i]; - if (shortcut && tvisstr(o)) { - str = strVdata(o); - size = strV(o)->len; - } else if (shortcut && tvisint(o)) { - char buf[LJ_STR_INTBUF]; - char *p = lj_str_bufint(buf, intV(o)); - size = (size_t)(buf+LJ_STR_INTBUF-p); - str = p; - } else if (shortcut && tvisnum(o)) { - char buf[LJ_STR_NUMBUF]; - size = lj_str_bufnum(buf, o); - str = buf; - } else { - copyTV(L, L->top+1, o); - copyTV(L, L->top, L->top-1); - L->top += 2; - lua_call(L, 1, 1); - str = lua_tolstring(L, -1, &size); - if (!str) - lj_err_caller(L, LJ_ERR_PRTOSTR); - L->top--; - } - if (i) - putchar('\t'); - fwrite(str, 1, size, stdout); - } - putchar('\n'); - return 0; -} - -LJLIB_PUSH(top-3) -LJLIB_SET(_VERSION) - -#include "lj_libdef.h" - -/* -- Coroutine library --------------------------------------------------- */ - -#define LJLIB_MODULE_coroutine - -LJLIB_CF(coroutine_status) -{ - const char *s; - lua_State *co; - if (!(L->top > L->base && tvisthread(L->base))) - lj_err_arg(L, 1, LJ_ERR_NOCORO); - co = threadV(L->base); - if (co == L) s = "running"; - else if (co->status == LUA_YIELD) s = "suspended"; - else if (co->status != 0) s = "dead"; - else if (co->base > tvref(co->stack)+1) s = "normal"; - else if (co->top == co->base) s = "dead"; - else s = "suspended"; - lua_pushstring(L, s); - return 1; -} - -LJLIB_CF(coroutine_running) -{ -#if LJ_52 - int ismain = lua_pushthread(L); - setboolV(L->top++, ismain); - return 2; -#else - if (lua_pushthread(L)) - setnilV(L->top++); - return 1; -#endif -} - -LJLIB_CF(coroutine_create) -{ - lua_State *L1; - if (!(L->base < L->top && tvisfunc(L->base))) - lj_err_argt(L, 1, LUA_TFUNCTION); - L1 = lua_newthread(L); - setfuncV(L, L1->top++, funcV(L->base)); - return 1; -} - -LJLIB_ASM(coroutine_yield) -{ - lj_err_caller(L, LJ_ERR_CYIELD); - return FFH_UNREACHABLE; -} - -static int ffh_resume(lua_State *L, lua_State *co, int wrap) -{ - if (co->cframe != NULL || co->status > LUA_YIELD || - (co->status == 0 && co->top == co->base)) { - ErrMsg em = co->cframe ? LJ_ERR_CORUN : LJ_ERR_CODEAD; - if (wrap) lj_err_caller(L, em); - setboolV(L->base-1, 0); - setstrV(L, L->base, lj_err_str(L, em)); - return FFH_RES(2); - } - lj_state_growstack(co, (MSize)(L->top - L->base)); - return FFH_RETRY; -} - -LJLIB_ASM(coroutine_resume) -{ - if (!(L->top > L->base && tvisthread(L->base))) - lj_err_arg(L, 1, LJ_ERR_NOCORO); - return ffh_resume(L, threadV(L->base), 0); -} - -LJLIB_NOREG LJLIB_ASM(coroutine_wrap_aux) -{ - return ffh_resume(L, threadV(lj_lib_upvalue(L, 1)), 1); -} - -/* Inline declarations. */ -LJ_ASMF void lj_ff_coroutine_wrap_aux(void); -#if !(LJ_TARGET_MIPS && defined(ljamalg_c)) -LJ_FUNCA_NORET void LJ_FASTCALL lj_ffh_coroutine_wrap_err(lua_State *L, - lua_State *co); -#endif - -/* Error handler, called from assembler VM. */ -void LJ_FASTCALL lj_ffh_coroutine_wrap_err(lua_State *L, lua_State *co) -{ - co->top--; copyTV(L, L->top, co->top); L->top++; - if (tvisstr(L->top-1)) - lj_err_callermsg(L, strVdata(L->top-1)); - else - lj_err_run(L); -} - -/* Forward declaration. */ -static void setpc_wrap_aux(lua_State *L, GCfunc *fn); - -LJLIB_CF(coroutine_wrap) -{ - lj_cf_coroutine_create(L); - lj_lib_pushcc(L, lj_ffh_coroutine_wrap_aux, FF_coroutine_wrap_aux, 1); - setpc_wrap_aux(L, funcV(L->top-1)); - return 1; -} - -#include "lj_libdef.h" - -/* Fix the PC of wrap_aux. Really ugly workaround. */ -static void setpc_wrap_aux(lua_State *L, GCfunc *fn) -{ - setmref(fn->c.pc, &L2GG(L)->bcff[lj_lib_init_coroutine[1]+2]); -} - -/* ------------------------------------------------------------------------ */ - -static void newproxy_weaktable(lua_State *L) -{ - /* NOBARRIER: The table is new (marked white). */ - GCtab *t = lj_tab_new(L, 0, 1); - settabV(L, L->top++, t); - setgcref(t->metatable, obj2gco(t)); - setstrV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "__mode")), - lj_str_newlit(L, "kv")); - t->nomm = (uint8_t)(~(1u<env); - settabV(L, lj_tab_setstr(L, env, lj_str_newlit(L, "_G")), env); - lua_pushliteral(L, LUA_VERSION); /* top-3. */ - newproxy_weaktable(L); /* top-2. */ - LJ_LIB_REG(L, "_G", base); - LJ_LIB_REG(L, LUA_COLIBNAME, coroutine); - return 2; -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lib_bit.c b/source/libs/luajit/LuaJIT-2.0.3/src/lib_bit.c deleted file mode 100644 index 739924b09..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lib_bit.c +++ /dev/null @@ -1,74 +0,0 @@ -/* -** Bit manipulation library. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lib_bit_c -#define LUA_LIB - -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" - -#include "lj_obj.h" -#include "lj_err.h" -#include "lj_str.h" -#include "lj_lib.h" - -/* ------------------------------------------------------------------------ */ - -#define LJLIB_MODULE_bit - -LJLIB_ASM(bit_tobit) LJLIB_REC(bit_unary IR_TOBIT) -{ - lj_lib_checknumber(L, 1); - return FFH_RETRY; -} -LJLIB_ASM_(bit_bnot) LJLIB_REC(bit_unary IR_BNOT) -LJLIB_ASM_(bit_bswap) LJLIB_REC(bit_unary IR_BSWAP) - -LJLIB_ASM(bit_lshift) LJLIB_REC(bit_shift IR_BSHL) -{ - lj_lib_checknumber(L, 1); - lj_lib_checkbit(L, 2); - return FFH_RETRY; -} -LJLIB_ASM_(bit_rshift) LJLIB_REC(bit_shift IR_BSHR) -LJLIB_ASM_(bit_arshift) LJLIB_REC(bit_shift IR_BSAR) -LJLIB_ASM_(bit_rol) LJLIB_REC(bit_shift IR_BROL) -LJLIB_ASM_(bit_ror) LJLIB_REC(bit_shift IR_BROR) - -LJLIB_ASM(bit_band) LJLIB_REC(bit_nary IR_BAND) -{ - int i = 0; - do { lj_lib_checknumber(L, ++i); } while (L->base+i < L->top); - return FFH_RETRY; -} -LJLIB_ASM_(bit_bor) LJLIB_REC(bit_nary IR_BOR) -LJLIB_ASM_(bit_bxor) LJLIB_REC(bit_nary IR_BXOR) - -/* ------------------------------------------------------------------------ */ - -LJLIB_CF(bit_tohex) -{ - uint32_t b = (uint32_t)lj_lib_checkbit(L, 1); - int32_t i, n = L->base+1 >= L->top ? 8 : lj_lib_checkbit(L, 2); - const char *hexdigits = "0123456789abcdef"; - char buf[8]; - if (n < 0) { n = -n; hexdigits = "0123456789ABCDEF"; } - if (n > 8) n = 8; - for (i = n; --i >= 0; ) { buf[i] = hexdigits[b & 15]; b >>= 4; } - lua_pushlstring(L, buf, (size_t)n); - return 1; -} - -/* ------------------------------------------------------------------------ */ - -#include "lj_libdef.h" - -LUALIB_API int luaopen_bit(lua_State *L) -{ - LJ_LIB_REG(L, LUA_BITLIBNAME, bit); - return 1; -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lib_debug.c b/source/libs/luajit/LuaJIT-2.0.3/src/lib_debug.c deleted file mode 100644 index 97f032f11..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lib_debug.c +++ /dev/null @@ -1,405 +0,0 @@ -/* -** Debug library. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Major portions taken verbatim or adapted from the Lua interpreter. -** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h -*/ - -#define lib_debug_c -#define LUA_LIB - -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" - -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_debug.h" -#include "lj_lib.h" - -/* ------------------------------------------------------------------------ */ - -#define LJLIB_MODULE_debug - -LJLIB_CF(debug_getregistry) -{ - copyTV(L, L->top++, registry(L)); - return 1; -} - -LJLIB_CF(debug_getmetatable) -{ - lj_lib_checkany(L, 1); - if (!lua_getmetatable(L, 1)) { - setnilV(L->top-1); - } - return 1; -} - -LJLIB_CF(debug_setmetatable) -{ - lj_lib_checktabornil(L, 2); - L->top = L->base+2; - lua_setmetatable(L, 1); -#if !LJ_52 - setboolV(L->top-1, 1); -#endif - return 1; -} - -LJLIB_CF(debug_getfenv) -{ - lj_lib_checkany(L, 1); - lua_getfenv(L, 1); - return 1; -} - -LJLIB_CF(debug_setfenv) -{ - lj_lib_checktab(L, 2); - L->top = L->base+2; - if (!lua_setfenv(L, 1)) - lj_err_caller(L, LJ_ERR_SETFENV); - return 1; -} - -/* ------------------------------------------------------------------------ */ - -static void settabss(lua_State *L, const char *i, const char *v) -{ - lua_pushstring(L, v); - lua_setfield(L, -2, i); -} - -static void settabsi(lua_State *L, const char *i, int v) -{ - lua_pushinteger(L, v); - lua_setfield(L, -2, i); -} - -static void settabsb(lua_State *L, const char *i, int v) -{ - lua_pushboolean(L, v); - lua_setfield(L, -2, i); -} - -static lua_State *getthread(lua_State *L, int *arg) -{ - if (L->base < L->top && tvisthread(L->base)) { - *arg = 1; - return threadV(L->base); - } else { - *arg = 0; - return L; - } -} - -static void treatstackoption(lua_State *L, lua_State *L1, const char *fname) -{ - if (L == L1) { - lua_pushvalue(L, -2); - lua_remove(L, -3); - } - else - lua_xmove(L1, L, 1); - lua_setfield(L, -2, fname); -} - -LJLIB_CF(debug_getinfo) -{ - lj_Debug ar; - int arg, opt_f = 0, opt_L = 0; - lua_State *L1 = getthread(L, &arg); - const char *options = luaL_optstring(L, arg+2, "flnSu"); - if (lua_isnumber(L, arg+1)) { - if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), (lua_Debug *)&ar)) { - setnilV(L->top-1); - return 1; - } - } else if (L->base+arg < L->top && tvisfunc(L->base+arg)) { - options = lua_pushfstring(L, ">%s", options); - setfuncV(L1, L1->top++, funcV(L->base+arg)); - } else { - lj_err_arg(L, arg+1, LJ_ERR_NOFUNCL); - } - if (!lj_debug_getinfo(L1, options, &ar, 1)) - lj_err_arg(L, arg+2, LJ_ERR_INVOPT); - lua_createtable(L, 0, 16); /* Create result table. */ - for (; *options; options++) { - switch (*options) { - case 'S': - settabss(L, "source", ar.source); - settabss(L, "short_src", ar.short_src); - settabsi(L, "linedefined", ar.linedefined); - settabsi(L, "lastlinedefined", ar.lastlinedefined); - settabss(L, "what", ar.what); - break; - case 'l': - settabsi(L, "currentline", ar.currentline); - break; - case 'u': - settabsi(L, "nups", ar.nups); - settabsi(L, "nparams", ar.nparams); - settabsb(L, "isvararg", ar.isvararg); - break; - case 'n': - settabss(L, "name", ar.name); - settabss(L, "namewhat", ar.namewhat); - break; - case 'f': opt_f = 1; break; - case 'L': opt_L = 1; break; - default: break; - } - } - if (opt_L) treatstackoption(L, L1, "activelines"); - if (opt_f) treatstackoption(L, L1, "func"); - return 1; /* Return result table. */ -} - -LJLIB_CF(debug_getlocal) -{ - int arg; - lua_State *L1 = getthread(L, &arg); - lua_Debug ar; - const char *name; - int slot = lj_lib_checkint(L, arg+2); - if (tvisfunc(L->base+arg)) { - L->top = L->base+arg+1; - lua_pushstring(L, lua_getlocal(L, NULL, slot)); - return 1; - } - if (!lua_getstack(L1, lj_lib_checkint(L, arg+1), &ar)) - lj_err_arg(L, arg+1, LJ_ERR_LVLRNG); - name = lua_getlocal(L1, &ar, slot); - if (name) { - lua_xmove(L1, L, 1); - lua_pushstring(L, name); - lua_pushvalue(L, -2); - return 2; - } else { - setnilV(L->top-1); - return 1; - } -} - -LJLIB_CF(debug_setlocal) -{ - int arg; - lua_State *L1 = getthread(L, &arg); - lua_Debug ar; - TValue *tv; - if (!lua_getstack(L1, lj_lib_checkint(L, arg+1), &ar)) - lj_err_arg(L, arg+1, LJ_ERR_LVLRNG); - tv = lj_lib_checkany(L, arg+3); - copyTV(L1, L1->top++, tv); - lua_pushstring(L, lua_setlocal(L1, &ar, lj_lib_checkint(L, arg+2))); - return 1; -} - -static int debug_getupvalue(lua_State *L, int get) -{ - int32_t n = lj_lib_checkint(L, 2); - const char *name; - lj_lib_checkfunc(L, 1); - name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); - if (name) { - lua_pushstring(L, name); - if (!get) return 1; - copyTV(L, L->top, L->top-2); - L->top++; - return 2; - } - return 0; -} - -LJLIB_CF(debug_getupvalue) -{ - return debug_getupvalue(L, 1); -} - -LJLIB_CF(debug_setupvalue) -{ - lj_lib_checkany(L, 3); - return debug_getupvalue(L, 0); -} - -LJLIB_CF(debug_upvalueid) -{ - GCfunc *fn = lj_lib_checkfunc(L, 1); - int32_t n = lj_lib_checkint(L, 2) - 1; - if ((uint32_t)n >= fn->l.nupvalues) - lj_err_arg(L, 2, LJ_ERR_IDXRNG); - setlightudV(L->top-1, isluafunc(fn) ? (void *)gcref(fn->l.uvptr[n]) : - (void *)&fn->c.upvalue[n]); - return 1; -} - -LJLIB_CF(debug_upvaluejoin) -{ - GCfunc *fn[2]; - GCRef *p[2]; - int i; - for (i = 0; i < 2; i++) { - int32_t n; - fn[i] = lj_lib_checkfunc(L, 2*i+1); - if (!isluafunc(fn[i])) - lj_err_arg(L, 2*i+1, LJ_ERR_NOLFUNC); - n = lj_lib_checkint(L, 2*i+2) - 1; - if ((uint32_t)n >= fn[i]->l.nupvalues) - lj_err_arg(L, 2*i+2, LJ_ERR_IDXRNG); - p[i] = &fn[i]->l.uvptr[n]; - } - setgcrefr(*p[0], *p[1]); - lj_gc_objbarrier(L, fn[0], gcref(*p[1])); - return 0; -} - -#if LJ_52 -LJLIB_CF(debug_getuservalue) -{ - TValue *o = L->base; - if (o < L->top && tvisudata(o)) - settabV(L, o, tabref(udataV(o)->env)); - else - setnilV(o); - L->top = o+1; - return 1; -} - -LJLIB_CF(debug_setuservalue) -{ - TValue *o = L->base; - if (!(o < L->top && tvisudata(o))) - lj_err_argt(L, 1, LUA_TUSERDATA); - if (!(o+1 < L->top && tvistab(o+1))) - lj_err_argt(L, 2, LUA_TTABLE); - L->top = o+2; - lua_setfenv(L, 1); - return 1; -} -#endif - -/* ------------------------------------------------------------------------ */ - -static const char KEY_HOOK = 'h'; - -static void hookf(lua_State *L, lua_Debug *ar) -{ - static const char *const hooknames[] = - {"call", "return", "line", "count", "tail return"}; - lua_pushlightuserdata(L, (void *)&KEY_HOOK); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_isfunction(L, -1)) { - lua_pushstring(L, hooknames[(int)ar->event]); - if (ar->currentline >= 0) - lua_pushinteger(L, ar->currentline); - else lua_pushnil(L); - lua_call(L, 2, 0); - } -} - -static int makemask(const char *smask, int count) -{ - int mask = 0; - if (strchr(smask, 'c')) mask |= LUA_MASKCALL; - if (strchr(smask, 'r')) mask |= LUA_MASKRET; - if (strchr(smask, 'l')) mask |= LUA_MASKLINE; - if (count > 0) mask |= LUA_MASKCOUNT; - return mask; -} - -static char *unmakemask(int mask, char *smask) -{ - int i = 0; - if (mask & LUA_MASKCALL) smask[i++] = 'c'; - if (mask & LUA_MASKRET) smask[i++] = 'r'; - if (mask & LUA_MASKLINE) smask[i++] = 'l'; - smask[i] = '\0'; - return smask; -} - -LJLIB_CF(debug_sethook) -{ - int arg, mask, count; - lua_Hook func; - (void)getthread(L, &arg); - if (lua_isnoneornil(L, arg+1)) { - lua_settop(L, arg+1); - func = NULL; mask = 0; count = 0; /* turn off hooks */ - } else { - const char *smask = luaL_checkstring(L, arg+2); - luaL_checktype(L, arg+1, LUA_TFUNCTION); - count = luaL_optint(L, arg+3, 0); - func = hookf; mask = makemask(smask, count); - } - lua_pushlightuserdata(L, (void *)&KEY_HOOK); - lua_pushvalue(L, arg+1); - lua_rawset(L, LUA_REGISTRYINDEX); - lua_sethook(L, func, mask, count); - return 0; -} - -LJLIB_CF(debug_gethook) -{ - char buff[5]; - int mask = lua_gethookmask(L); - lua_Hook hook = lua_gethook(L); - if (hook != NULL && hook != hookf) { /* external hook? */ - lua_pushliteral(L, "external hook"); - } else { - lua_pushlightuserdata(L, (void *)&KEY_HOOK); - lua_rawget(L, LUA_REGISTRYINDEX); /* get hook */ - } - lua_pushstring(L, unmakemask(mask, buff)); - lua_pushinteger(L, lua_gethookcount(L)); - return 3; -} - -/* ------------------------------------------------------------------------ */ - -LJLIB_CF(debug_debug) -{ - for (;;) { - char buffer[250]; - fputs("lua_debug> ", stderr); - if (fgets(buffer, sizeof(buffer), stdin) == 0 || - strcmp(buffer, "cont\n") == 0) - return 0; - if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || - lua_pcall(L, 0, 0, 0)) { - fputs(lua_tostring(L, -1), stderr); - fputs("\n", stderr); - } - lua_settop(L, 0); /* remove eventual returns */ - } -} - -/* ------------------------------------------------------------------------ */ - -#define LEVELS1 12 /* size of the first part of the stack */ -#define LEVELS2 10 /* size of the second part of the stack */ - -LJLIB_CF(debug_traceback) -{ - int arg; - lua_State *L1 = getthread(L, &arg); - const char *msg = lua_tostring(L, arg+1); - if (msg == NULL && L->top > L->base+arg) - L->top = L->base+arg+1; - else - luaL_traceback(L, L1, msg, lj_lib_optint(L, arg+2, (L == L1))); - return 1; -} - -/* ------------------------------------------------------------------------ */ - -#include "lj_libdef.h" - -LUALIB_API int luaopen_debug(lua_State *L) -{ - LJ_LIB_REG(L, LUA_DBLIBNAME, debug); - return 1; -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lib_ffi.c b/source/libs/luajit/LuaJIT-2.0.3/src/lib_ffi.c deleted file mode 100644 index e789ad6c3..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lib_ffi.c +++ /dev/null @@ -1,850 +0,0 @@ -/* -** FFI library. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lib_ffi_c -#define LUA_LIB - -#include - -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" - -#include "lj_obj.h" - -#if LJ_HASFFI - -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_meta.h" -#include "lj_ctype.h" -#include "lj_cparse.h" -#include "lj_cdata.h" -#include "lj_cconv.h" -#include "lj_carith.h" -#include "lj_ccall.h" -#include "lj_ccallback.h" -#include "lj_clib.h" -#include "lj_ff.h" -#include "lj_lib.h" - -/* -- C type checks ------------------------------------------------------- */ - -/* Check first argument for a C type and returns its ID. */ -static CTypeID ffi_checkctype(lua_State *L, CTState *cts, TValue *param) -{ - TValue *o = L->base; - if (!(o < L->top)) { - err_argtype: - lj_err_argtype(L, 1, "C type"); - } - if (tvisstr(o)) { /* Parse an abstract C type declaration. */ - GCstr *s = strV(o); - CPState cp; - int errcode; - cp.L = L; - cp.cts = cts; - cp.srcname = strdata(s); - cp.p = strdata(s); - cp.param = param; - cp.mode = CPARSE_MODE_ABSTRACT|CPARSE_MODE_NOIMPLICIT; - errcode = lj_cparse(&cp); - if (errcode) lj_err_throw(L, errcode); /* Propagate errors. */ - return cp.val.id; - } else { - GCcdata *cd; - if (!tviscdata(o)) goto err_argtype; - if (param && param < L->top) lj_err_arg(L, 1, LJ_ERR_FFI_NUMPARAM); - cd = cdataV(o); - return cd->ctypeid == CTID_CTYPEID ? *(CTypeID *)cdataptr(cd) : cd->ctypeid; - } -} - -/* Check argument for C data and return it. */ -static GCcdata *ffi_checkcdata(lua_State *L, int narg) -{ - TValue *o = L->base + narg-1; - if (!(o < L->top && tviscdata(o))) - lj_err_argt(L, narg, LUA_TCDATA); - return cdataV(o); -} - -/* Convert argument to C pointer. */ -static void *ffi_checkptr(lua_State *L, int narg, CTypeID id) -{ - CTState *cts = ctype_cts(L); - TValue *o = L->base + narg-1; - void *p; - if (o >= L->top) - lj_err_arg(L, narg, LJ_ERR_NOVAL); - lj_cconv_ct_tv(cts, ctype_get(cts, id), (uint8_t *)&p, o, CCF_ARG(narg)); - return p; -} - -/* Convert argument to int32_t. */ -static int32_t ffi_checkint(lua_State *L, int narg) -{ - CTState *cts = ctype_cts(L); - TValue *o = L->base + narg-1; - int32_t i; - if (o >= L->top) - lj_err_arg(L, narg, LJ_ERR_NOVAL); - lj_cconv_ct_tv(cts, ctype_get(cts, CTID_INT32), (uint8_t *)&i, o, - CCF_ARG(narg)); - return i; -} - -/* -- C type metamethods -------------------------------------------------- */ - -#define LJLIB_MODULE_ffi_meta - -/* Handle ctype __index/__newindex metamethods. */ -static int ffi_index_meta(lua_State *L, CTState *cts, CType *ct, MMS mm) -{ - CTypeID id = ctype_typeid(cts, ct); - cTValue *tv = lj_ctype_meta(cts, id, mm); - TValue *base = L->base; - if (!tv) { - const char *s; - err_index: - s = strdata(lj_ctype_repr(L, id, NULL)); - if (tvisstr(L->base+1)) { - lj_err_callerv(L, LJ_ERR_FFI_BADMEMBER, s, strVdata(L->base+1)); - } else { - const char *key = tviscdata(L->base+1) ? - strdata(lj_ctype_repr(L, cdataV(L->base+1)->ctypeid, NULL)) : - lj_typename(L->base+1); - lj_err_callerv(L, LJ_ERR_FFI_BADIDXW, s, key); - } - } - if (!tvisfunc(tv)) { - if (mm == MM_index) { - cTValue *o = lj_meta_tget(L, tv, base+1); - if (o) { - if (tvisnil(o)) goto err_index; - copyTV(L, L->top-1, o); - return 1; - } - } else { - TValue *o = lj_meta_tset(L, tv, base+1); - if (o) { - copyTV(L, o, base+2); - return 0; - } - } - tv = L->top-1; - } - return lj_meta_tailcall(L, tv); -} - -LJLIB_CF(ffi_meta___index) LJLIB_REC(cdata_index 0) -{ - CTState *cts = ctype_cts(L); - CTInfo qual = 0; - CType *ct; - uint8_t *p; - TValue *o = L->base; - if (!(o+1 < L->top && tviscdata(o))) /* Also checks for presence of key. */ - lj_err_argt(L, 1, LUA_TCDATA); - ct = lj_cdata_index(cts, cdataV(o), o+1, &p, &qual); - if ((qual & 1)) - return ffi_index_meta(L, cts, ct, MM_index); - if (lj_cdata_get(cts, ct, L->top-1, p)) - lj_gc_check(L); - return 1; -} - -LJLIB_CF(ffi_meta___newindex) LJLIB_REC(cdata_index 1) -{ - CTState *cts = ctype_cts(L); - CTInfo qual = 0; - CType *ct; - uint8_t *p; - TValue *o = L->base; - if (!(o+2 < L->top && tviscdata(o))) /* Also checks for key and value. */ - lj_err_argt(L, 1, LUA_TCDATA); - ct = lj_cdata_index(cts, cdataV(o), o+1, &p, &qual); - if ((qual & 1)) { - if ((qual & CTF_CONST)) - lj_err_caller(L, LJ_ERR_FFI_WRCONST); - return ffi_index_meta(L, cts, ct, MM_newindex); - } - lj_cdata_set(cts, ct, p, o+2, qual); - return 0; -} - -/* Common handler for cdata arithmetic. */ -static int ffi_arith(lua_State *L) -{ - MMS mm = (MMS)(curr_func(L)->c.ffid - (int)FF_ffi_meta___eq + (int)MM_eq); - return lj_carith_op(L, mm); -} - -/* The following functions must be in contiguous ORDER MM. */ -LJLIB_CF(ffi_meta___eq) LJLIB_REC(cdata_arith MM_eq) -{ - return ffi_arith(L); -} - -LJLIB_CF(ffi_meta___len) LJLIB_REC(cdata_arith MM_len) -{ - return ffi_arith(L); -} - -LJLIB_CF(ffi_meta___lt) LJLIB_REC(cdata_arith MM_lt) -{ - return ffi_arith(L); -} - -LJLIB_CF(ffi_meta___le) LJLIB_REC(cdata_arith MM_le) -{ - return ffi_arith(L); -} - -LJLIB_CF(ffi_meta___concat) LJLIB_REC(cdata_arith MM_concat) -{ - return ffi_arith(L); -} - -/* Forward declaration. */ -static int lj_cf_ffi_new(lua_State *L); - -LJLIB_CF(ffi_meta___call) LJLIB_REC(cdata_call) -{ - CTState *cts = ctype_cts(L); - GCcdata *cd = ffi_checkcdata(L, 1); - CTypeID id = cd->ctypeid; - CType *ct; - cTValue *tv; - MMS mm = MM_call; - if (cd->ctypeid == CTID_CTYPEID) { - id = *(CTypeID *)cdataptr(cd); - mm = MM_new; - } else { - int ret = lj_ccall_func(L, cd); - if (ret >= 0) - return ret; - } - /* Handle ctype __call/__new metamethod. */ - ct = ctype_raw(cts, id); - if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); - tv = lj_ctype_meta(cts, id, mm); - if (tv) - return lj_meta_tailcall(L, tv); - else if (mm == MM_call) - lj_err_callerv(L, LJ_ERR_FFI_BADCALL, strdata(lj_ctype_repr(L, id, NULL))); - return lj_cf_ffi_new(L); -} - -LJLIB_CF(ffi_meta___add) LJLIB_REC(cdata_arith MM_add) -{ - return ffi_arith(L); -} - -LJLIB_CF(ffi_meta___sub) LJLIB_REC(cdata_arith MM_sub) -{ - return ffi_arith(L); -} - -LJLIB_CF(ffi_meta___mul) LJLIB_REC(cdata_arith MM_mul) -{ - return ffi_arith(L); -} - -LJLIB_CF(ffi_meta___div) LJLIB_REC(cdata_arith MM_div) -{ - return ffi_arith(L); -} - -LJLIB_CF(ffi_meta___mod) LJLIB_REC(cdata_arith MM_mod) -{ - return ffi_arith(L); -} - -LJLIB_CF(ffi_meta___pow) LJLIB_REC(cdata_arith MM_pow) -{ - return ffi_arith(L); -} - -LJLIB_CF(ffi_meta___unm) LJLIB_REC(cdata_arith MM_unm) -{ - return ffi_arith(L); -} -/* End of contiguous ORDER MM. */ - -LJLIB_CF(ffi_meta___tostring) -{ - GCcdata *cd = ffi_checkcdata(L, 1); - const char *msg = "cdata<%s>: %p"; - CTypeID id = cd->ctypeid; - void *p = cdataptr(cd); - if (id == CTID_CTYPEID) { - msg = "ctype<%s>"; - id = *(CTypeID *)p; - } else { - CTState *cts = ctype_cts(L); - CType *ct = ctype_raw(cts, id); - if (ctype_isref(ct->info)) { - p = *(void **)p; - ct = ctype_rawchild(cts, ct); - } - if (ctype_iscomplex(ct->info)) { - setstrV(L, L->top-1, lj_ctype_repr_complex(L, cdataptr(cd), ct->size)); - goto checkgc; - } else if (ct->size == 8 && ctype_isinteger(ct->info)) { - setstrV(L, L->top-1, lj_ctype_repr_int64(L, *(uint64_t *)cdataptr(cd), - (ct->info & CTF_UNSIGNED))); - goto checkgc; - } else if (ctype_isfunc(ct->info)) { - p = *(void **)p; - } else if (ctype_isenum(ct->info)) { - msg = "cdata<%s>: %d"; - p = (void *)(uintptr_t)*(uint32_t **)p; - } else { - if (ctype_isptr(ct->info)) { - p = cdata_getptr(p, ct->size); - ct = ctype_rawchild(cts, ct); - } - if (ctype_isstruct(ct->info) || ctype_isvector(ct->info)) { - /* Handle ctype __tostring metamethod. */ - cTValue *tv = lj_ctype_meta(cts, ctype_typeid(cts, ct), MM_tostring); - if (tv) - return lj_meta_tailcall(L, tv); - } - } - } - lj_str_pushf(L, msg, strdata(lj_ctype_repr(L, id, NULL)), p); -checkgc: - lj_gc_check(L); - return 1; -} - -static int ffi_pairs(lua_State *L, MMS mm) -{ - CTState *cts = ctype_cts(L); - CTypeID id = ffi_checkcdata(L, 1)->ctypeid; - CType *ct = ctype_raw(cts, id); - cTValue *tv; - if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); - tv = lj_ctype_meta(cts, id, mm); - if (!tv) - lj_err_callerv(L, LJ_ERR_FFI_BADMM, strdata(lj_ctype_repr(L, id, NULL)), - strdata(mmname_str(G(L), mm))); - return lj_meta_tailcall(L, tv); -} - -LJLIB_CF(ffi_meta___pairs) -{ - return ffi_pairs(L, MM_pairs); -} - -LJLIB_CF(ffi_meta___ipairs) -{ - return ffi_pairs(L, MM_ipairs); -} - -LJLIB_PUSH("ffi") LJLIB_SET(__metatable) - -#include "lj_libdef.h" - -/* -- C library metamethods ----------------------------------------------- */ - -#define LJLIB_MODULE_ffi_clib - -/* Index C library by a name. */ -static TValue *ffi_clib_index(lua_State *L) -{ - TValue *o = L->base; - CLibrary *cl; - if (!(o < L->top && tvisudata(o) && udataV(o)->udtype == UDTYPE_FFI_CLIB)) - lj_err_argt(L, 1, LUA_TUSERDATA); - cl = (CLibrary *)uddata(udataV(o)); - if (!(o+1 < L->top && tvisstr(o+1))) - lj_err_argt(L, 2, LUA_TSTRING); - return lj_clib_index(L, cl, strV(o+1)); -} - -LJLIB_CF(ffi_clib___index) LJLIB_REC(clib_index 1) -{ - TValue *tv = ffi_clib_index(L); - if (tviscdata(tv)) { - CTState *cts = ctype_cts(L); - GCcdata *cd = cdataV(tv); - CType *s = ctype_get(cts, cd->ctypeid); - if (ctype_isextern(s->info)) { - CTypeID sid = ctype_cid(s->info); - void *sp = *(void **)cdataptr(cd); - CType *ct = ctype_raw(cts, sid); - if (lj_cconv_tv_ct(cts, ct, sid, L->top-1, sp)) - lj_gc_check(L); - return 1; - } - } - copyTV(L, L->top-1, tv); - return 1; -} - -LJLIB_CF(ffi_clib___newindex) LJLIB_REC(clib_index 0) -{ - TValue *tv = ffi_clib_index(L); - TValue *o = L->base+2; - if (o < L->top && tviscdata(tv)) { - CTState *cts = ctype_cts(L); - GCcdata *cd = cdataV(tv); - CType *d = ctype_get(cts, cd->ctypeid); - if (ctype_isextern(d->info)) { - CTInfo qual = 0; - for (;;) { /* Skip attributes and collect qualifiers. */ - d = ctype_child(cts, d); - if (!ctype_isattrib(d->info)) break; - if (ctype_attrib(d->info) == CTA_QUAL) qual |= d->size; - } - if (!((d->info|qual) & CTF_CONST)) { - lj_cconv_ct_tv(cts, d, *(void **)cdataptr(cd), o, 0); - return 0; - } - } - } - lj_err_caller(L, LJ_ERR_FFI_WRCONST); - return 0; /* unreachable */ -} - -LJLIB_CF(ffi_clib___gc) -{ - TValue *o = L->base; - if (o < L->top && tvisudata(o) && udataV(o)->udtype == UDTYPE_FFI_CLIB) - lj_clib_unload((CLibrary *)uddata(udataV(o))); - return 0; -} - -#include "lj_libdef.h" - -/* -- Callback function metamethods --------------------------------------- */ - -#define LJLIB_MODULE_ffi_callback - -static int ffi_callback_set(lua_State *L, GCfunc *fn) -{ - GCcdata *cd = ffi_checkcdata(L, 1); - CTState *cts = ctype_cts(L); - CType *ct = ctype_raw(cts, cd->ctypeid); - if (ctype_isptr(ct->info) && (LJ_32 || ct->size == 8)) { - MSize slot = lj_ccallback_ptr2slot(cts, *(void **)cdataptr(cd)); - if (slot < cts->cb.sizeid && cts->cb.cbid[slot] != 0) { - GCtab *t = cts->miscmap; - TValue *tv = lj_tab_setint(L, t, (int32_t)slot); - if (fn) { - setfuncV(L, tv, fn); - lj_gc_anybarriert(L, t); - } else { - setnilV(tv); - cts->cb.cbid[slot] = 0; - cts->cb.topid = slot < cts->cb.topid ? slot : cts->cb.topid; - } - return 0; - } - } - lj_err_caller(L, LJ_ERR_FFI_BADCBACK); - return 0; -} - -LJLIB_CF(ffi_callback_free) -{ - return ffi_callback_set(L, NULL); -} - -LJLIB_CF(ffi_callback_set) -{ - GCfunc *fn = lj_lib_checkfunc(L, 2); - return ffi_callback_set(L, fn); -} - -LJLIB_PUSH(top-1) LJLIB_SET(__index) - -#include "lj_libdef.h" - -/* -- FFI library functions ----------------------------------------------- */ - -#define LJLIB_MODULE_ffi - -LJLIB_CF(ffi_cdef) -{ - GCstr *s = lj_lib_checkstr(L, 1); - CPState cp; - int errcode; - cp.L = L; - cp.cts = ctype_cts(L); - cp.srcname = strdata(s); - cp.p = strdata(s); - cp.param = L->base+1; - cp.mode = CPARSE_MODE_MULTI|CPARSE_MODE_DIRECT; - errcode = lj_cparse(&cp); - if (errcode) lj_err_throw(L, errcode); /* Propagate errors. */ - lj_gc_check(L); - return 0; -} - -LJLIB_CF(ffi_new) LJLIB_REC(.) -{ - CTState *cts = ctype_cts(L); - CTypeID id = ffi_checkctype(L, cts, NULL); - CType *ct = ctype_raw(cts, id); - CTSize sz; - CTInfo info = lj_ctype_info(cts, id, &sz); - TValue *o = L->base+1; - GCcdata *cd; - if ((info & CTF_VLA)) { - o++; - sz = lj_ctype_vlsize(cts, ct, (CTSize)ffi_checkint(L, 2)); - } - if (sz == CTSIZE_INVALID) - lj_err_arg(L, 1, LJ_ERR_FFI_INVSIZE); - if (!(info & CTF_VLA) && ctype_align(info) <= CT_MEMALIGN) - cd = lj_cdata_new(cts, id, sz); - else - cd = lj_cdata_newv(cts, id, sz, ctype_align(info)); - setcdataV(L, o-1, cd); /* Anchor the uninitialized cdata. */ - lj_cconv_ct_init(cts, ct, sz, cdataptr(cd), - o, (MSize)(L->top - o)); /* Initialize cdata. */ - if (ctype_isstruct(ct->info)) { - /* Handle ctype __gc metamethod. Use the fast lookup here. */ - cTValue *tv = lj_tab_getinth(cts->miscmap, -(int32_t)id); - if (tv && tvistab(tv) && (tv = lj_meta_fast(L, tabV(tv), MM_gc))) { - GCtab *t = cts->finalizer; - if (gcref(t->metatable)) { - /* Add to finalizer table, if still enabled. */ - copyTV(L, lj_tab_set(L, t, o-1), tv); - lj_gc_anybarriert(L, t); - cd->marked |= LJ_GC_CDATA_FIN; - } - } - } - L->top = o; /* Only return the cdata itself. */ - lj_gc_check(L); - return 1; -} - -LJLIB_CF(ffi_cast) LJLIB_REC(ffi_new) -{ - CTState *cts = ctype_cts(L); - CTypeID id = ffi_checkctype(L, cts, NULL); - CType *d = ctype_raw(cts, id); - TValue *o = lj_lib_checkany(L, 2); - L->top = o+1; /* Make sure this is the last item on the stack. */ - if (!(ctype_isnum(d->info) || ctype_isptr(d->info) || ctype_isenum(d->info))) - lj_err_arg(L, 1, LJ_ERR_FFI_INVTYPE); - if (!(tviscdata(o) && cdataV(o)->ctypeid == id)) { - GCcdata *cd = lj_cdata_new(cts, id, d->size); - lj_cconv_ct_tv(cts, d, cdataptr(cd), o, CCF_CAST); - setcdataV(L, o, cd); - lj_gc_check(L); - } - return 1; -} - -LJLIB_CF(ffi_typeof) LJLIB_REC(.) -{ - CTState *cts = ctype_cts(L); - CTypeID id = ffi_checkctype(L, cts, L->base+1); - GCcdata *cd = lj_cdata_new(cts, CTID_CTYPEID, 4); - *(CTypeID *)cdataptr(cd) = id; - setcdataV(L, L->top-1, cd); - lj_gc_check(L); - return 1; -} - -LJLIB_CF(ffi_istype) LJLIB_REC(.) -{ - CTState *cts = ctype_cts(L); - CTypeID id1 = ffi_checkctype(L, cts, NULL); - TValue *o = lj_lib_checkany(L, 2); - int b = 0; - if (tviscdata(o)) { - GCcdata *cd = cdataV(o); - CTypeID id2 = cd->ctypeid == CTID_CTYPEID ? *(CTypeID *)cdataptr(cd) : - cd->ctypeid; - CType *ct1 = lj_ctype_rawref(cts, id1); - CType *ct2 = lj_ctype_rawref(cts, id2); - if (ct1 == ct2) { - b = 1; - } else if (ctype_type(ct1->info) == ctype_type(ct2->info) && - ct1->size == ct2->size) { - if (ctype_ispointer(ct1->info)) - b = lj_cconv_compatptr(cts, ct1, ct2, CCF_IGNQUAL); - else if (ctype_isnum(ct1->info) || ctype_isvoid(ct1->info)) - b = (((ct1->info ^ ct2->info) & ~(CTF_QUAL|CTF_LONG)) == 0); - } else if (ctype_isstruct(ct1->info) && ctype_isptr(ct2->info) && - ct1 == ctype_rawchild(cts, ct2)) { - b = 1; - } - } - setboolV(L->top-1, b); - setboolV(&G(L)->tmptv2, b); /* Remember for trace recorder. */ - return 1; -} - -LJLIB_CF(ffi_sizeof) LJLIB_REC(ffi_xof FF_ffi_sizeof) -{ - CTState *cts = ctype_cts(L); - CTypeID id = ffi_checkctype(L, cts, NULL); - CTSize sz; - if (LJ_UNLIKELY(tviscdata(L->base) && cdataisv(cdataV(L->base)))) { - sz = cdatavlen(cdataV(L->base)); - } else { - CType *ct = lj_ctype_rawref(cts, id); - if (ctype_isvltype(ct->info)) - sz = lj_ctype_vlsize(cts, ct, (CTSize)ffi_checkint(L, 2)); - else - sz = ctype_hassize(ct->info) ? ct->size : CTSIZE_INVALID; - if (LJ_UNLIKELY(sz == CTSIZE_INVALID)) { - setnilV(L->top-1); - return 1; - } - } - setintV(L->top-1, (int32_t)sz); - return 1; -} - -LJLIB_CF(ffi_alignof) LJLIB_REC(ffi_xof FF_ffi_alignof) -{ - CTState *cts = ctype_cts(L); - CTypeID id = ffi_checkctype(L, cts, NULL); - CTSize sz = 0; - CTInfo info = lj_ctype_info(cts, id, &sz); - setintV(L->top-1, 1 << ctype_align(info)); - return 1; -} - -LJLIB_CF(ffi_offsetof) LJLIB_REC(ffi_xof FF_ffi_offsetof) -{ - CTState *cts = ctype_cts(L); - CTypeID id = ffi_checkctype(L, cts, NULL); - GCstr *name = lj_lib_checkstr(L, 2); - CType *ct = lj_ctype_rawref(cts, id); - CTSize ofs; - if (ctype_isstruct(ct->info) && ct->size != CTSIZE_INVALID) { - CType *fct = lj_ctype_getfield(cts, ct, name, &ofs); - if (fct) { - setintV(L->top-1, ofs); - if (ctype_isfield(fct->info)) { - return 1; - } else if (ctype_isbitfield(fct->info)) { - setintV(L->top++, ctype_bitpos(fct->info)); - setintV(L->top++, ctype_bitbsz(fct->info)); - return 3; - } - } - } - return 0; -} - -LJLIB_CF(ffi_errno) LJLIB_REC(.) -{ - int err = errno; - if (L->top > L->base) - errno = ffi_checkint(L, 1); - setintV(L->top++, err); - return 1; -} - -LJLIB_CF(ffi_string) LJLIB_REC(.) -{ - CTState *cts = ctype_cts(L); - TValue *o = lj_lib_checkany(L, 1); - const char *p; - size_t len; - if (o+1 < L->top && !tvisnil(o+1)) { - len = (size_t)ffi_checkint(L, 2); - lj_cconv_ct_tv(cts, ctype_get(cts, CTID_P_CVOID), (uint8_t *)&p, o, - CCF_ARG(1)); - } else { - lj_cconv_ct_tv(cts, ctype_get(cts, CTID_P_CCHAR), (uint8_t *)&p, o, - CCF_ARG(1)); - len = strlen(p); - } - L->top = o+1; /* Make sure this is the last item on the stack. */ - setstrV(L, o, lj_str_new(L, p, len)); - lj_gc_check(L); - return 1; -} - -LJLIB_CF(ffi_copy) LJLIB_REC(.) -{ - void *dp = ffi_checkptr(L, 1, CTID_P_VOID); - void *sp = ffi_checkptr(L, 2, CTID_P_CVOID); - TValue *o = L->base+1; - CTSize len; - if (tvisstr(o) && o+1 >= L->top) - len = strV(o)->len+1; /* Copy Lua string including trailing '\0'. */ - else - len = (CTSize)ffi_checkint(L, 3); - memcpy(dp, sp, len); - return 0; -} - -LJLIB_CF(ffi_fill) LJLIB_REC(.) -{ - void *dp = ffi_checkptr(L, 1, CTID_P_VOID); - CTSize len = (CTSize)ffi_checkint(L, 2); - int32_t fill = 0; - if (L->base+2 < L->top && !tvisnil(L->base+2)) fill = ffi_checkint(L, 3); - memset(dp, fill, len); - return 0; -} - -#define H_(le, be) LJ_ENDIAN_SELECT(0x##le, 0x##be) - -/* Test ABI string. */ -LJLIB_CF(ffi_abi) LJLIB_REC(.) -{ - GCstr *s = lj_lib_checkstr(L, 1); - int b = 0; - switch (s->hash) { -#if LJ_64 - case H_(849858eb,ad35fd06): b = 1; break; /* 64bit */ -#else - case H_(662d3c79,d0e22477): b = 1; break; /* 32bit */ -#endif -#if LJ_ARCH_HASFPU - case H_(e33ee463,e33ee463): b = 1; break; /* fpu */ -#endif -#if LJ_ABI_SOFTFP - case H_(61211a23,c2e8c81c): b = 1; break; /* softfp */ -#else - case H_(539417a8,8ce0812f): b = 1; break; /* hardfp */ -#endif -#if LJ_ABI_EABI - case H_(2182df8f,f2ed1152): b = 1; break; /* eabi */ -#endif -#if LJ_ABI_WIN - case H_(4ab624a8,4ab624a8): b = 1; break; /* win */ -#endif - case H_(3af93066,1f001464): b = 1; break; /* le/be */ - default: - break; - } - setboolV(L->top-1, b); - setboolV(&G(L)->tmptv2, b); /* Remember for trace recorder. */ - return 1; -} - -#undef H_ - -LJLIB_PUSH(top-8) LJLIB_SET(!) /* Store reference to miscmap table. */ - -LJLIB_CF(ffi_metatype) -{ - CTState *cts = ctype_cts(L); - CTypeID id = ffi_checkctype(L, cts, NULL); - GCtab *mt = lj_lib_checktab(L, 2); - GCtab *t = cts->miscmap; - CType *ct = ctype_get(cts, id); /* Only allow raw types. */ - TValue *tv; - GCcdata *cd; - if (!(ctype_isstruct(ct->info) || ctype_iscomplex(ct->info) || - ctype_isvector(ct->info))) - lj_err_arg(L, 1, LJ_ERR_FFI_INVTYPE); - tv = lj_tab_setinth(L, t, -(int32_t)id); - if (!tvisnil(tv)) - lj_err_caller(L, LJ_ERR_PROTMT); - settabV(L, tv, mt); - lj_gc_anybarriert(L, t); - cd = lj_cdata_new(cts, CTID_CTYPEID, 4); - *(CTypeID *)cdataptr(cd) = id; - setcdataV(L, L->top-1, cd); - lj_gc_check(L); - return 1; -} - -LJLIB_PUSH(top-7) LJLIB_SET(!) /* Store reference to finalizer table. */ - -LJLIB_CF(ffi_gc) LJLIB_REC(.) -{ - GCcdata *cd = ffi_checkcdata(L, 1); - TValue *fin = lj_lib_checkany(L, 2); - CTState *cts = ctype_cts(L); - GCtab *t = cts->finalizer; - CType *ct = ctype_raw(cts, cd->ctypeid); - if (!(ctype_isptr(ct->info) || ctype_isstruct(ct->info) || - ctype_isrefarray(ct->info))) - lj_err_arg(L, 1, LJ_ERR_FFI_INVTYPE); - if (gcref(t->metatable)) { /* Update finalizer table, if still enabled. */ - copyTV(L, lj_tab_set(L, t, L->base), fin); - lj_gc_anybarriert(L, t); - if (!tvisnil(fin)) - cd->marked |= LJ_GC_CDATA_FIN; - else - cd->marked &= ~LJ_GC_CDATA_FIN; - } - L->top = L->base+1; /* Pass through the cdata object. */ - return 1; -} - -LJLIB_PUSH(top-5) LJLIB_SET(!) /* Store clib metatable in func environment. */ - -LJLIB_CF(ffi_load) -{ - GCstr *name = lj_lib_checkstr(L, 1); - int global = (L->base+1 < L->top && tvistruecond(L->base+1)); - lj_clib_load(L, tabref(curr_func(L)->c.env), name, global); - return 1; -} - -LJLIB_PUSH(top-4) LJLIB_SET(C) -LJLIB_PUSH(top-3) LJLIB_SET(os) -LJLIB_PUSH(top-2) LJLIB_SET(arch) - -#include "lj_libdef.h" - -/* ------------------------------------------------------------------------ */ - -/* Create special weak-keyed finalizer table. */ -static GCtab *ffi_finalizer(lua_State *L) -{ - /* NOBARRIER: The table is new (marked white). */ - GCtab *t = lj_tab_new(L, 0, 1); - settabV(L, L->top++, t); - setgcref(t->metatable, obj2gco(t)); - setstrV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "__mode")), - lj_str_newlit(L, "K")); - t->nomm = (uint8_t)(~(1u<top-1); - lj_gc_anybarriert(L, t); - } -} - -LUALIB_API int luaopen_ffi(lua_State *L) -{ - CTState *cts = lj_ctype_init(L); - settabV(L, L->top++, (cts->miscmap = lj_tab_new(L, 0, 1))); - cts->finalizer = ffi_finalizer(L); - LJ_LIB_REG(L, NULL, ffi_meta); - /* NOBARRIER: basemt is a GC root. */ - setgcref(basemt_it(G(L), LJ_TCDATA), obj2gco(tabV(L->top-1))); - LJ_LIB_REG(L, NULL, ffi_clib); - LJ_LIB_REG(L, NULL, ffi_callback); - /* NOBARRIER: the key is new and lj_tab_newkey() handles the barrier. */ - settabV(L, lj_tab_setstr(L, cts->miscmap, &cts->g->strempty), tabV(L->top-1)); - L->top--; - lj_clib_default(L, tabV(L->top-1)); /* Create ffi.C default namespace. */ - lua_pushliteral(L, LJ_OS_NAME); - lua_pushliteral(L, LJ_ARCH_NAME); - LJ_LIB_REG(L, NULL, ffi); /* Note: no global "ffi" created! */ - ffi_register_module(L); - return 1; -} - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lib_init.c b/source/libs/luajit/LuaJIT-2.0.3/src/lib_init.c deleted file mode 100644 index c1b6115e3..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lib_init.c +++ /dev/null @@ -1,56 +0,0 @@ -/* -** Library initialization. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Major parts taken verbatim from the Lua interpreter. -** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h -*/ - -#define lib_init_c -#define LUA_LIB - -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" - -#include "lj_arch.h" - -static const luaL_Reg lj_lib_load[] = { - { "", luaopen_base }, - { LUA_LOADLIBNAME, luaopen_package }, - { LUA_TABLIBNAME, luaopen_table }, - { LUA_IOLIBNAME, luaopen_io }, - { LUA_OSLIBNAME, luaopen_os }, - { LUA_STRLIBNAME, luaopen_string }, - { LUA_MATHLIBNAME, luaopen_math }, - { LUA_DBLIBNAME, luaopen_debug }, - { LUA_BITLIBNAME, luaopen_bit }, - { LUA_JITLIBNAME, luaopen_jit }, - { LUA_BITLIBNAME_32, luaopen_bit32 }, - { NULL, NULL } -}; - -static const luaL_Reg lj_lib_preload[] = { -#if LJ_HASFFI - { LUA_FFILIBNAME, luaopen_ffi }, -#endif - { NULL, NULL } -}; - -LUALIB_API void luaL_openlibs(lua_State *L) -{ - const luaL_Reg *lib; - for (lib = lj_lib_load; lib->func; lib++) { - lua_pushcfunction(L, lib->func); - lua_pushstring(L, lib->name); - lua_call(L, 1, 0); - } - luaL_findtable(L, LUA_REGISTRYINDEX, "_PRELOAD", - sizeof(lj_lib_preload)/sizeof(lj_lib_preload[0])-1); - for (lib = lj_lib_preload; lib->func; lib++) { - lua_pushcfunction(L, lib->func); - lua_setfield(L, -2, lib->name); - } - lua_pop(L, 1); -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lib_io.c b/source/libs/luajit/LuaJIT-2.0.3/src/lib_io.c deleted file mode 100644 index 04f0f7390..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lib_io.c +++ /dev/null @@ -1,539 +0,0 @@ -/* -** I/O library. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Major portions taken verbatim or adapted from the Lua interpreter. -** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h -*/ - -#include -#include - -#define lib_io_c -#define LUA_LIB - -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" - -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_str.h" -#include "lj_state.h" -#include "lj_ff.h" -#include "lj_lib.h" - -/* Userdata payload for I/O file. */ -typedef struct IOFileUD { - FILE *fp; /* File handle. */ - uint32_t type; /* File type. */ -} IOFileUD; - -#define IOFILE_TYPE_FILE 0 /* Regular file. */ -#define IOFILE_TYPE_PIPE 1 /* Pipe. */ -#define IOFILE_TYPE_STDF 2 /* Standard file handle. */ -#define IOFILE_TYPE_MASK 3 - -#define IOFILE_FLAG_CLOSE 4 /* Close after io.lines() iterator. */ - -#define IOSTDF_UD(L, id) (&gcref(G(L)->gcroot[(id)])->ud) -#define IOSTDF_IOF(L, id) ((IOFileUD *)uddata(IOSTDF_UD(L, (id)))) - -/* -- Open/close helpers -------------------------------------------------- */ - -static IOFileUD *io_tofilep(lua_State *L) -{ - if (!(L->base < L->top && tvisudata(L->base) && - udataV(L->base)->udtype == UDTYPE_IO_FILE)) - lj_err_argtype(L, 1, "FILE*"); - return (IOFileUD *)uddata(udataV(L->base)); -} - -static IOFileUD *io_tofile(lua_State *L) -{ - IOFileUD *iof = io_tofilep(L); - if (iof->fp == NULL) - lj_err_caller(L, LJ_ERR_IOCLFL); - return iof; -} - -static FILE *io_stdfile(lua_State *L, ptrdiff_t id) -{ - IOFileUD *iof = IOSTDF_IOF(L, id); - if (iof->fp == NULL) - lj_err_caller(L, LJ_ERR_IOSTDCL); - return iof->fp; -} - -static IOFileUD *io_file_new(lua_State *L) -{ - IOFileUD *iof = (IOFileUD *)lua_newuserdata(L, sizeof(IOFileUD)); - GCudata *ud = udataV(L->top-1); - ud->udtype = UDTYPE_IO_FILE; - /* NOBARRIER: The GCudata is new (marked white). */ - setgcrefr(ud->metatable, curr_func(L)->c.env); - iof->fp = NULL; - iof->type = IOFILE_TYPE_FILE; - return iof; -} - -static IOFileUD *io_file_open(lua_State *L, const char *mode) -{ - const char *fname = strdata(lj_lib_checkstr(L, 1)); - IOFileUD *iof = io_file_new(L); - iof->fp = fopen(fname, mode); - if (iof->fp == NULL) - luaL_argerror(L, 1, lj_str_pushf(L, "%s: %s", fname, strerror(errno))); - return iof; -} - -static int io_file_close(lua_State *L, IOFileUD *iof) -{ - int ok; - if ((iof->type & IOFILE_TYPE_MASK) == IOFILE_TYPE_FILE) { - ok = (fclose(iof->fp) == 0); - } else if ((iof->type & IOFILE_TYPE_MASK) == IOFILE_TYPE_PIPE) { - int stat = -1; -#if LJ_TARGET_POSIX - stat = pclose(iof->fp); -#elif LJ_TARGET_WINDOWS - stat = _pclose(iof->fp); -#else - lua_assert(0); - return 0; -#endif -#if LJ_52 - iof->fp = NULL; - return luaL_execresult(L, stat); -#else - ok = (stat != -1); -#endif - } else { - lua_assert((iof->type & IOFILE_TYPE_MASK) == IOFILE_TYPE_STDF); - setnilV(L->top++); - lua_pushliteral(L, "cannot close standard file"); - return 2; - } - iof->fp = NULL; - return luaL_fileresult(L, ok, NULL); -} - -/* -- Read/write helpers -------------------------------------------------- */ - -static int io_file_readnum(lua_State *L, FILE *fp) -{ - lua_Number d; - if (fscanf(fp, LUA_NUMBER_SCAN, &d) == 1) { - if (LJ_DUALNUM) { - int32_t i = lj_num2int(d); - if (d == (lua_Number)i && !tvismzero((cTValue *)&d)) { - setintV(L->top++, i); - return 1; - } - } - setnumV(L->top++, d); - return 1; - } else { - setnilV(L->top++); - return 0; - } -} - -static int io_file_readline(lua_State *L, FILE *fp, MSize chop) -{ - MSize m = LUAL_BUFFERSIZE, n = 0, ok = 0; - char *buf; - for (;;) { - buf = lj_str_needbuf(L, &G(L)->tmpbuf, m); - if (fgets(buf+n, m-n, fp) == NULL) break; - n += (MSize)strlen(buf+n); - ok |= n; - if (n && buf[n-1] == '\n') { n -= chop; break; } - if (n >= m - 64) m += m; - } - setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n)); - lj_gc_check(L); - return (int)ok; -} - -static void io_file_readall(lua_State *L, FILE *fp) -{ - MSize m, n; - for (m = LUAL_BUFFERSIZE, n = 0; ; m += m) { - char *buf = lj_str_needbuf(L, &G(L)->tmpbuf, m); - n += (MSize)fread(buf+n, 1, m-n, fp); - if (n != m) { - setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n)); - lj_gc_check(L); - return; - } - } -} - -static int io_file_readlen(lua_State *L, FILE *fp, MSize m) -{ - if (m) { - char *buf = lj_str_needbuf(L, &G(L)->tmpbuf, m); - MSize n = (MSize)fread(buf, 1, m, fp); - setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n)); - lj_gc_check(L); - return (n > 0 || m == 0); - } else { - int c = getc(fp); - ungetc(c, fp); - setstrV(L, L->top++, &G(L)->strempty); - return (c != EOF); - } -} - -static int io_file_read(lua_State *L, FILE *fp, int start) -{ - int ok, n, nargs = (int)(L->top - L->base) - start; - clearerr(fp); - if (nargs == 0) { - ok = io_file_readline(L, fp, 1); - n = start+1; /* Return 1 result. */ - } else { - /* The results plus the buffers go on top of the args. */ - luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); - ok = 1; - for (n = start; nargs-- && ok; n++) { - if (tvisstr(L->base+n)) { - const char *p = strVdata(L->base+n); - if (p[0] != '*') - lj_err_arg(L, n+1, LJ_ERR_INVOPT); - if (p[1] == 'n') - ok = io_file_readnum(L, fp); - else if ((p[1] & ~0x20) == 'L') - ok = io_file_readline(L, fp, (p[1] == 'l')); - else if (p[1] == 'a') - io_file_readall(L, fp); - else - lj_err_arg(L, n+1, LJ_ERR_INVFMT); - } else if (tvisnumber(L->base+n)) { - ok = io_file_readlen(L, fp, (MSize)lj_lib_checkint(L, n+1)); - } else { - lj_err_arg(L, n+1, LJ_ERR_INVOPT); - } - } - } - if (ferror(fp)) - return luaL_fileresult(L, 0, NULL); - if (!ok) - setnilV(L->top-1); /* Replace last result with nil. */ - return n - start; -} - -static int io_file_write(lua_State *L, FILE *fp, int start) -{ - cTValue *tv; - int status = 1; - for (tv = L->base+start; tv < L->top; tv++) { - if (tvisstr(tv)) { - MSize len = strV(tv)->len; - status = status && (fwrite(strVdata(tv), 1, len, fp) == len); - } else if (tvisint(tv)) { - char buf[LJ_STR_INTBUF]; - char *p = lj_str_bufint(buf, intV(tv)); - size_t len = (size_t)(buf+LJ_STR_INTBUF-p); - status = status && (fwrite(p, 1, len, fp) == len); - } else if (tvisnum(tv)) { - status = status && (fprintf(fp, LUA_NUMBER_FMT, numV(tv)) > 0); - } else { - lj_err_argt(L, (int)(tv - L->base) + 1, LUA_TSTRING); - } - } - if (LJ_52 && status) { - L->top = L->base+1; - if (start == 0) - setudataV(L, L->base, IOSTDF_UD(L, GCROOT_IO_OUTPUT)); - return 1; - } - return luaL_fileresult(L, status, NULL); -} - -static int io_file_iter(lua_State *L) -{ - GCfunc *fn = curr_func(L); - IOFileUD *iof = uddata(udataV(&fn->c.upvalue[0])); - int n = fn->c.nupvalues - 1; - if (iof->fp == NULL) - lj_err_caller(L, LJ_ERR_IOCLFL); - L->top = L->base; - if (n) { /* Copy upvalues with options to stack. */ - if (n > LUAI_MAXCSTACK) - lj_err_caller(L, LJ_ERR_STKOV); - lj_state_checkstack(L, (MSize)n); - memcpy(L->top, &fn->c.upvalue[1], n*sizeof(TValue)); - L->top += n; - } - n = io_file_read(L, iof->fp, 0); - if (ferror(iof->fp)) - lj_err_callermsg(L, strVdata(L->top-2)); - if (tvisnil(L->base) && (iof->type & IOFILE_FLAG_CLOSE)) { - io_file_close(L, iof); /* Return values are ignored. */ - return 0; - } - return n; -} - -/* -- I/O file methods ---------------------------------------------------- */ - -#define LJLIB_MODULE_io_method - -LJLIB_CF(io_method_close) -{ - IOFileUD *iof = L->base < L->top ? io_tofile(L) : - IOSTDF_IOF(L, GCROOT_IO_OUTPUT); - return io_file_close(L, iof); -} - -LJLIB_CF(io_method_read) -{ - return io_file_read(L, io_tofile(L)->fp, 1); -} - -LJLIB_CF(io_method_write) LJLIB_REC(io_write 0) -{ - return io_file_write(L, io_tofile(L)->fp, 1); -} - -LJLIB_CF(io_method_flush) LJLIB_REC(io_flush 0) -{ - return luaL_fileresult(L, fflush(io_tofile(L)->fp) == 0, NULL); -} - -LJLIB_CF(io_method_seek) -{ - FILE *fp = io_tofile(L)->fp; - int opt = lj_lib_checkopt(L, 2, 1, "\3set\3cur\3end"); - int64_t ofs = 0; - cTValue *o; - int res; - if (opt == 0) opt = SEEK_SET; - else if (opt == 1) opt = SEEK_CUR; - else if (opt == 2) opt = SEEK_END; - o = L->base+2; - if (o < L->top) { - if (tvisint(o)) - ofs = (int64_t)intV(o); - else if (tvisnum(o)) - ofs = (int64_t)numV(o); - else if (!tvisnil(o)) - lj_err_argt(L, 3, LUA_TNUMBER); - } -#if LJ_TARGET_POSIX - res = fseeko(fp, ofs, opt); -#elif _MSC_VER >= 1400 - res = _fseeki64(fp, ofs, opt); -#elif defined(__MINGW32__) - res = fseeko64(fp, ofs, opt); -#else - res = fseek(fp, (long)ofs, opt); -#endif - if (res) - return luaL_fileresult(L, 0, NULL); -#if LJ_TARGET_POSIX - ofs = ftello(fp); -#elif _MSC_VER >= 1400 - ofs = _ftelli64(fp); -#elif defined(__MINGW32__) - ofs = ftello64(fp); -#else - ofs = (int64_t)ftell(fp); -#endif - setint64V(L->top-1, ofs); - return 1; -} - -LJLIB_CF(io_method_setvbuf) -{ - FILE *fp = io_tofile(L)->fp; - int opt = lj_lib_checkopt(L, 2, -1, "\4full\4line\2no"); - size_t sz = (size_t)lj_lib_optint(L, 3, LUAL_BUFFERSIZE); - if (opt == 0) opt = _IOFBF; - else if (opt == 1) opt = _IOLBF; - else if (opt == 2) opt = _IONBF; - return luaL_fileresult(L, setvbuf(fp, NULL, opt, sz) == 0, NULL); -} - -LJLIB_CF(io_method_lines) -{ - io_tofile(L); - lua_pushcclosure(L, io_file_iter, (int)(L->top - L->base)); - return 1; -} - -LJLIB_CF(io_method___gc) -{ - IOFileUD *iof = io_tofilep(L); - if (iof->fp != NULL && (iof->type & IOFILE_TYPE_MASK) != IOFILE_TYPE_STDF) - io_file_close(L, iof); - return 0; -} - -LJLIB_CF(io_method___tostring) -{ - IOFileUD *iof = io_tofilep(L); - if (iof->fp != NULL) - lua_pushfstring(L, "file (%p)", iof->fp); - else - lua_pushliteral(L, "file (closed)"); - return 1; -} - -LJLIB_PUSH(top-1) LJLIB_SET(__index) - -#include "lj_libdef.h" - -/* -- I/O library functions ----------------------------------------------- */ - -#define LJLIB_MODULE_io - -LJLIB_PUSH(top-2) LJLIB_SET(!) /* Set environment. */ - -LJLIB_CF(io_open) -{ - const char *fname = strdata(lj_lib_checkstr(L, 1)); - GCstr *s = lj_lib_optstr(L, 2); - const char *mode = s ? strdata(s) : "r"; - IOFileUD *iof = io_file_new(L); - iof->fp = fopen(fname, mode); - return iof->fp != NULL ? 1 : luaL_fileresult(L, 0, fname); -} - -LJLIB_CF(io_popen) -{ -#if LJ_TARGET_POSIX || LJ_TARGET_WINDOWS - const char *fname = strdata(lj_lib_checkstr(L, 1)); - GCstr *s = lj_lib_optstr(L, 2); - const char *mode = s ? strdata(s) : "r"; - IOFileUD *iof = io_file_new(L); - iof->type = IOFILE_TYPE_PIPE; -#if LJ_TARGET_POSIX - fflush(NULL); - iof->fp = popen(fname, mode); -#else - iof->fp = _popen(fname, mode); -#endif - return iof->fp != NULL ? 1 : luaL_fileresult(L, 0, fname); -#else - return luaL_error(L, LUA_QL("popen") " not supported"); -#endif -} - -LJLIB_CF(io_tmpfile) -{ - IOFileUD *iof = io_file_new(L); -#if LJ_TARGET_PS3 || LJ_TARGET_PS4 - iof->fp = NULL; errno = ENOSYS; -#else - iof->fp = tmpfile(); -#endif - return iof->fp != NULL ? 1 : luaL_fileresult(L, 0, NULL); -} - -LJLIB_CF(io_close) -{ - return lj_cf_io_method_close(L); -} - -LJLIB_CF(io_read) -{ - return io_file_read(L, io_stdfile(L, GCROOT_IO_INPUT), 0); -} - -LJLIB_CF(io_write) LJLIB_REC(io_write GCROOT_IO_OUTPUT) -{ - return io_file_write(L, io_stdfile(L, GCROOT_IO_OUTPUT), 0); -} - -LJLIB_CF(io_flush) LJLIB_REC(io_flush GCROOT_IO_OUTPUT) -{ - return luaL_fileresult(L, fflush(io_stdfile(L, GCROOT_IO_OUTPUT)) == 0, NULL); -} - -static int io_std_getset(lua_State *L, ptrdiff_t id, const char *mode) -{ - if (L->base < L->top && !tvisnil(L->base)) { - if (tvisudata(L->base)) { - io_tofile(L); - L->top = L->base+1; - } else { - io_file_open(L, mode); - } - /* NOBARRIER: The standard I/O handles are GC roots. */ - setgcref(G(L)->gcroot[id], gcV(L->top-1)); - } else { - setudataV(L, L->top++, IOSTDF_UD(L, id)); - } - return 1; -} - -LJLIB_CF(io_input) -{ - return io_std_getset(L, GCROOT_IO_INPUT, "r"); -} - -LJLIB_CF(io_output) -{ - return io_std_getset(L, GCROOT_IO_OUTPUT, "w"); -} - -LJLIB_CF(io_lines) -{ - if (L->base == L->top) setnilV(L->top++); - if (!tvisnil(L->base)) { /* io.lines(fname) */ - IOFileUD *iof = io_file_open(L, "r"); - iof->type = IOFILE_TYPE_FILE|IOFILE_FLAG_CLOSE; - L->top--; - setudataV(L, L->base, udataV(L->top)); - } else { /* io.lines() iterates over stdin. */ - setudataV(L, L->base, IOSTDF_UD(L, GCROOT_IO_INPUT)); - } - lua_pushcclosure(L, io_file_iter, (int)(L->top - L->base)); - return 1; -} - -LJLIB_CF(io_type) -{ - cTValue *o = lj_lib_checkany(L, 1); - if (!(tvisudata(o) && udataV(o)->udtype == UDTYPE_IO_FILE)) - setnilV(L->top++); - else if (((IOFileUD *)uddata(udataV(o)))->fp != NULL) - lua_pushliteral(L, "file"); - else - lua_pushliteral(L, "closed file"); - return 1; -} - -#include "lj_libdef.h" - -/* ------------------------------------------------------------------------ */ - -static GCobj *io_std_new(lua_State *L, FILE *fp, const char *name) -{ - IOFileUD *iof = (IOFileUD *)lua_newuserdata(L, sizeof(IOFileUD)); - GCudata *ud = udataV(L->top-1); - ud->udtype = UDTYPE_IO_FILE; - /* NOBARRIER: The GCudata is new (marked white). */ - setgcref(ud->metatable, gcV(L->top-3)); - iof->fp = fp; - iof->type = IOFILE_TYPE_STDF; - lua_setfield(L, -2, name); - return obj2gco(ud); -} - -LUALIB_API int luaopen_io(lua_State *L) -{ - LJ_LIB_REG(L, NULL, io_method); - copyTV(L, L->top, L->top-1); L->top++; - lua_setfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE); - LJ_LIB_REG(L, LUA_IOLIBNAME, io); - setgcref(G(L)->gcroot[GCROOT_IO_INPUT], io_std_new(L, stdin, "stdin")); - setgcref(G(L)->gcroot[GCROOT_IO_OUTPUT], io_std_new(L, stdout, "stdout")); - io_std_new(L, stderr, "stderr"); - return 1; -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lib_jit.c b/source/libs/luajit/LuaJIT-2.0.3/src/lib_jit.c deleted file mode 100644 index 0fadf8b9e..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lib_jit.c +++ /dev/null @@ -1,663 +0,0 @@ -/* -** JIT library. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lib_jit_c -#define LUA_LIB - -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" - -#include "lj_arch.h" -#include "lj_obj.h" -#include "lj_err.h" -#include "lj_debug.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_bc.h" -#if LJ_HASJIT -#include "lj_ir.h" -#include "lj_jit.h" -#include "lj_ircall.h" -#include "lj_iropt.h" -#include "lj_target.h" -#endif -#include "lj_dispatch.h" -#include "lj_vm.h" -#include "lj_vmevent.h" -#include "lj_lib.h" - -#include "luajit.h" - -/* -- jit.* functions ----------------------------------------------------- */ - -#define LJLIB_MODULE_jit - -static int setjitmode(lua_State *L, int mode) -{ - int idx = 0; - if (L->base == L->top || tvisnil(L->base)) { /* jit.on/off/flush([nil]) */ - mode |= LUAJIT_MODE_ENGINE; - } else { - /* jit.on/off/flush(func|proto, nil|true|false) */ - if (tvisfunc(L->base) || tvisproto(L->base)) - idx = 1; - else if (!tvistrue(L->base)) /* jit.on/off/flush(true, nil|true|false) */ - goto err; - if (L->base+1 < L->top && tvisbool(L->base+1)) - mode |= boolV(L->base+1) ? LUAJIT_MODE_ALLFUNC : LUAJIT_MODE_ALLSUBFUNC; - else - mode |= LUAJIT_MODE_FUNC; - } - if (luaJIT_setmode(L, idx, mode) != 1) { - if ((mode & LUAJIT_MODE_MASK) == LUAJIT_MODE_ENGINE) - lj_err_caller(L, LJ_ERR_NOJIT); - err: - lj_err_argt(L, 1, LUA_TFUNCTION); - } - return 0; -} - -LJLIB_CF(jit_on) -{ - return setjitmode(L, LUAJIT_MODE_ON); -} - -LJLIB_CF(jit_off) -{ - return setjitmode(L, LUAJIT_MODE_OFF); -} - -LJLIB_CF(jit_flush) -{ -#if LJ_HASJIT - if (L->base < L->top && tvisnumber(L->base)) { - int traceno = lj_lib_checkint(L, 1); - luaJIT_setmode(L, traceno, LUAJIT_MODE_FLUSH|LUAJIT_MODE_TRACE); - return 0; - } -#endif - return setjitmode(L, LUAJIT_MODE_FLUSH); -} - -#if LJ_HASJIT -/* Push a string for every flag bit that is set. */ -static void flagbits_to_strings(lua_State *L, uint32_t flags, uint32_t base, - const char *str) -{ - for (; *str; base <<= 1, str += 1+*str) - if (flags & base) - setstrV(L, L->top++, lj_str_new(L, str+1, *(uint8_t *)str)); -} -#endif - -LJLIB_CF(jit_status) -{ -#if LJ_HASJIT - jit_State *J = L2J(L); - L->top = L->base; - setboolV(L->top++, (J->flags & JIT_F_ON) ? 1 : 0); - flagbits_to_strings(L, J->flags, JIT_F_CPU_FIRST, JIT_F_CPUSTRING); - flagbits_to_strings(L, J->flags, JIT_F_OPT_FIRST, JIT_F_OPTSTRING); - return (int)(L->top - L->base); -#else - setboolV(L->top++, 0); - return 1; -#endif -} - -LJLIB_CF(jit_attach) -{ -#ifdef LUAJIT_DISABLE_VMEVENT - luaL_error(L, "vmevent API disabled"); -#else - GCfunc *fn = lj_lib_checkfunc(L, 1); - GCstr *s = lj_lib_optstr(L, 2); - luaL_findtable(L, LUA_REGISTRYINDEX, LJ_VMEVENTS_REGKEY, LJ_VMEVENTS_HSIZE); - if (s) { /* Attach to given event. */ - const uint8_t *p = (const uint8_t *)strdata(s); - uint32_t h = s->len; - while (*p) h = h ^ (lj_rol(h, 6) + *p++); - lua_pushvalue(L, 1); - lua_rawseti(L, -2, VMEVENT_HASHIDX(h)); - G(L)->vmevmask = VMEVENT_NOCACHE; /* Invalidate cache. */ - } else { /* Detach if no event given. */ - setnilV(L->top++); - while (lua_next(L, -2)) { - L->top--; - if (tvisfunc(L->top) && funcV(L->top) == fn) { - setnilV(lj_tab_set(L, tabV(L->top-2), L->top-1)); - } - } - } -#endif - return 0; -} - -LJLIB_PUSH(top-5) LJLIB_SET(os) -LJLIB_PUSH(top-4) LJLIB_SET(arch) -LJLIB_PUSH(top-3) LJLIB_SET(version_num) -LJLIB_PUSH(top-2) LJLIB_SET(version) - -#include "lj_libdef.h" - -/* -- jit.util.* functions ------------------------------------------------ */ - -#define LJLIB_MODULE_jit_util - -/* -- Reflection API for Lua functions ------------------------------------ */ - -/* Return prototype of first argument (Lua function or prototype object) */ -static GCproto *check_Lproto(lua_State *L, int nolua) -{ - TValue *o = L->base; - if (L->top > o) { - if (tvisproto(o)) { - return protoV(o); - } else if (tvisfunc(o)) { - if (isluafunc(funcV(o))) - return funcproto(funcV(o)); - else if (nolua) - return NULL; - } - } - lj_err_argt(L, 1, LUA_TFUNCTION); - return NULL; /* unreachable */ -} - -static void setintfield(lua_State *L, GCtab *t, const char *name, int32_t val) -{ - setintV(lj_tab_setstr(L, t, lj_str_newz(L, name)), val); -} - -/* local info = jit.util.funcinfo(func [,pc]) */ -LJLIB_CF(jit_util_funcinfo) -{ - GCproto *pt = check_Lproto(L, 1); - if (pt) { - BCPos pc = (BCPos)lj_lib_optint(L, 2, 0); - GCtab *t; - lua_createtable(L, 0, 16); /* Increment hash size if fields are added. */ - t = tabV(L->top-1); - setintfield(L, t, "linedefined", pt->firstline); - setintfield(L, t, "lastlinedefined", pt->firstline + pt->numline); - setintfield(L, t, "stackslots", pt->framesize); - setintfield(L, t, "params", pt->numparams); - setintfield(L, t, "bytecodes", (int32_t)pt->sizebc); - setintfield(L, t, "gcconsts", (int32_t)pt->sizekgc); - setintfield(L, t, "nconsts", (int32_t)pt->sizekn); - setintfield(L, t, "upvalues", (int32_t)pt->sizeuv); - if (pc < pt->sizebc) - setintfield(L, t, "currentline", lj_debug_line(pt, pc)); - lua_pushboolean(L, (pt->flags & PROTO_VARARG)); - lua_setfield(L, -2, "isvararg"); - lua_pushboolean(L, (pt->flags & PROTO_CHILD)); - lua_setfield(L, -2, "children"); - setstrV(L, L->top++, proto_chunkname(pt)); - lua_setfield(L, -2, "source"); - lj_debug_pushloc(L, pt, pc); - lua_setfield(L, -2, "loc"); - } else { - GCfunc *fn = funcV(L->base); - GCtab *t; - lua_createtable(L, 0, 4); /* Increment hash size if fields are added. */ - t = tabV(L->top-1); - if (!iscfunc(fn)) - setintfield(L, t, "ffid", fn->c.ffid); - setintptrV(lj_tab_setstr(L, t, lj_str_newlit(L, "addr")), - (intptr_t)(void *)fn->c.f); - setintfield(L, t, "upvalues", fn->c.nupvalues); - } - return 1; -} - -/* local ins, m = jit.util.funcbc(func, pc) */ -LJLIB_CF(jit_util_funcbc) -{ - GCproto *pt = check_Lproto(L, 0); - BCPos pc = (BCPos)lj_lib_checkint(L, 2); - if (pc < pt->sizebc) { - BCIns ins = proto_bc(pt)[pc]; - BCOp op = bc_op(ins); - lua_assert(op < BC__MAX); - setintV(L->top, ins); - setintV(L->top+1, lj_bc_mode[op]); - L->top += 2; - return 2; - } - return 0; -} - -/* local k = jit.util.funck(func, idx) */ -LJLIB_CF(jit_util_funck) -{ - GCproto *pt = check_Lproto(L, 0); - ptrdiff_t idx = (ptrdiff_t)lj_lib_checkint(L, 2); - if (idx >= 0) { - if (idx < (ptrdiff_t)pt->sizekn) { - copyTV(L, L->top-1, proto_knumtv(pt, idx)); - return 1; - } - } else { - if (~idx < (ptrdiff_t)pt->sizekgc) { - GCobj *gc = proto_kgc(pt, idx); - setgcV(L, L->top-1, gc, ~gc->gch.gct); - return 1; - } - } - return 0; -} - -/* local name = jit.util.funcuvname(func, idx) */ -LJLIB_CF(jit_util_funcuvname) -{ - GCproto *pt = check_Lproto(L, 0); - uint32_t idx = (uint32_t)lj_lib_checkint(L, 2); - if (idx < pt->sizeuv) { - setstrV(L, L->top-1, lj_str_newz(L, lj_debug_uvname(pt, idx))); - return 1; - } - return 0; -} - -/* -- Reflection API for traces ------------------------------------------- */ - -#if LJ_HASJIT - -/* Check trace argument. Must not throw for non-existent trace numbers. */ -static GCtrace *jit_checktrace(lua_State *L) -{ - TraceNo tr = (TraceNo)lj_lib_checkint(L, 1); - jit_State *J = L2J(L); - if (tr > 0 && tr < J->sizetrace) - return traceref(J, tr); - return NULL; -} - -/* Names of link types. ORDER LJ_TRLINK */ -static const char *const jit_trlinkname[] = { - "none", "root", "loop", "tail-recursion", "up-recursion", "down-recursion", - "interpreter", "return" -}; - -/* local info = jit.util.traceinfo(tr) */ -LJLIB_CF(jit_util_traceinfo) -{ - GCtrace *T = jit_checktrace(L); - if (T) { - GCtab *t; - lua_createtable(L, 0, 8); /* Increment hash size if fields are added. */ - t = tabV(L->top-1); - setintfield(L, t, "nins", (int32_t)T->nins - REF_BIAS - 1); - setintfield(L, t, "nk", REF_BIAS - (int32_t)T->nk); - setintfield(L, t, "link", T->link); - setintfield(L, t, "nexit", T->nsnap); - setstrV(L, L->top++, lj_str_newz(L, jit_trlinkname[T->linktype])); - lua_setfield(L, -2, "linktype"); - /* There are many more fields. Add them only when needed. */ - return 1; - } - return 0; -} - -/* local m, ot, op1, op2, prev = jit.util.traceir(tr, idx) */ -LJLIB_CF(jit_util_traceir) -{ - GCtrace *T = jit_checktrace(L); - IRRef ref = (IRRef)lj_lib_checkint(L, 2) + REF_BIAS; - if (T && ref >= REF_BIAS && ref < T->nins) { - IRIns *ir = &T->ir[ref]; - int32_t m = lj_ir_mode[ir->o]; - setintV(L->top-2, m); - setintV(L->top-1, ir->ot); - setintV(L->top++, (int32_t)ir->op1 - (irm_op1(m)==IRMref ? REF_BIAS : 0)); - setintV(L->top++, (int32_t)ir->op2 - (irm_op2(m)==IRMref ? REF_BIAS : 0)); - setintV(L->top++, ir->prev); - return 5; - } - return 0; -} - -/* local k, t [, slot] = jit.util.tracek(tr, idx) */ -LJLIB_CF(jit_util_tracek) -{ - GCtrace *T = jit_checktrace(L); - IRRef ref = (IRRef)lj_lib_checkint(L, 2) + REF_BIAS; - if (T && ref >= T->nk && ref < REF_BIAS) { - IRIns *ir = &T->ir[ref]; - int32_t slot = -1; - if (ir->o == IR_KSLOT) { - slot = ir->op2; - ir = &T->ir[ir->op1]; - } - lj_ir_kvalue(L, L->top-2, ir); - setintV(L->top-1, (int32_t)irt_type(ir->t)); - if (slot == -1) - return 2; - setintV(L->top++, slot); - return 3; - } - return 0; -} - -/* local snap = jit.util.tracesnap(tr, sn) */ -LJLIB_CF(jit_util_tracesnap) -{ - GCtrace *T = jit_checktrace(L); - SnapNo sn = (SnapNo)lj_lib_checkint(L, 2); - if (T && sn < T->nsnap) { - SnapShot *snap = &T->snap[sn]; - SnapEntry *map = &T->snapmap[snap->mapofs]; - MSize n, nent = snap->nent; - GCtab *t; - lua_createtable(L, nent+2, 0); - t = tabV(L->top-1); - setintV(lj_tab_setint(L, t, 0), (int32_t)snap->ref - REF_BIAS); - setintV(lj_tab_setint(L, t, 1), (int32_t)snap->nslots); - for (n = 0; n < nent; n++) - setintV(lj_tab_setint(L, t, (int32_t)(n+2)), (int32_t)map[n]); - setintV(lj_tab_setint(L, t, (int32_t)(nent+2)), (int32_t)SNAP(255, 0, 0)); - return 1; - } - return 0; -} - -/* local mcode, addr, loop = jit.util.tracemc(tr) */ -LJLIB_CF(jit_util_tracemc) -{ - GCtrace *T = jit_checktrace(L); - if (T && T->mcode != NULL) { - setstrV(L, L->top-1, lj_str_new(L, (const char *)T->mcode, T->szmcode)); - setintptrV(L->top++, (intptr_t)(void *)T->mcode); - setintV(L->top++, T->mcloop); - return 3; - } - return 0; -} - -/* local addr = jit.util.traceexitstub([tr,] exitno) */ -LJLIB_CF(jit_util_traceexitstub) -{ -#ifdef EXITSTUBS_PER_GROUP - ExitNo exitno = (ExitNo)lj_lib_checkint(L, 1); - jit_State *J = L2J(L); - if (exitno < EXITSTUBS_PER_GROUP*LJ_MAX_EXITSTUBGR) { - setintptrV(L->top-1, (intptr_t)(void *)exitstub_addr(J, exitno)); - return 1; - } -#else - if (L->top > L->base+1) { /* Don't throw for one-argument variant. */ - GCtrace *T = jit_checktrace(L); - ExitNo exitno = (ExitNo)lj_lib_checkint(L, 2); - ExitNo maxexit = T->root ? T->nsnap+1 : T->nsnap; - if (T && T->mcode != NULL && exitno < maxexit) { - setintptrV(L->top-1, (intptr_t)(void *)exitstub_trace_addr(T, exitno)); - return 1; - } - } -#endif - return 0; -} - -/* local addr = jit.util.ircalladdr(idx) */ -LJLIB_CF(jit_util_ircalladdr) -{ - uint32_t idx = (uint32_t)lj_lib_checkint(L, 1); - if (idx < IRCALL__MAX) { - setintptrV(L->top-1, (intptr_t)(void *)lj_ir_callinfo[idx].func); - return 1; - } - return 0; -} - -#endif - -#include "lj_libdef.h" - -/* -- jit.opt module ------------------------------------------------------ */ - -#if LJ_HASJIT - -#define LJLIB_MODULE_jit_opt - -/* Parse optimization level. */ -static int jitopt_level(jit_State *J, const char *str) -{ - if (str[0] >= '0' && str[0] <= '9' && str[1] == '\0') { - uint32_t flags; - if (str[0] == '0') flags = JIT_F_OPT_0; - else if (str[0] == '1') flags = JIT_F_OPT_1; - else if (str[0] == '2') flags = JIT_F_OPT_2; - else flags = JIT_F_OPT_3; - J->flags = (J->flags & ~JIT_F_OPT_MASK) | flags; - return 1; /* Ok. */ - } - return 0; /* No match. */ -} - -/* Parse optimization flag. */ -static int jitopt_flag(jit_State *J, const char *str) -{ - const char *lst = JIT_F_OPTSTRING; - uint32_t opt; - int set = 1; - if (str[0] == '+') { - str++; - } else if (str[0] == '-') { - str++; - set = 0; - } else if (str[0] == 'n' && str[1] == 'o') { - str += str[2] == '-' ? 3 : 2; - set = 0; - } - for (opt = JIT_F_OPT_FIRST; ; opt <<= 1) { - size_t len = *(const uint8_t *)lst; - if (len == 0) - break; - if (strncmp(str, lst+1, len) == 0 && str[len] == '\0') { - if (set) J->flags |= opt; else J->flags &= ~opt; - return 1; /* Ok. */ - } - lst += 1+len; - } - return 0; /* No match. */ -} - -/* Parse optimization parameter. */ -static int jitopt_param(jit_State *J, const char *str) -{ - const char *lst = JIT_P_STRING; - int i; - for (i = 0; i < JIT_P__MAX; i++) { - size_t len = *(const uint8_t *)lst; - lua_assert(len != 0); - if (strncmp(str, lst+1, len) == 0 && str[len] == '=') { - int32_t n = 0; - const char *p = &str[len+1]; - while (*p >= '0' && *p <= '9') - n = n*10 + (*p++ - '0'); - if (*p) return 0; /* Malformed number. */ - J->param[i] = n; - if (i == JIT_P_hotloop) - lj_dispatch_init_hotcount(J2G(J)); - return 1; /* Ok. */ - } - lst += 1+len; - } - return 0; /* No match. */ -} - -/* jit.opt.start(flags...) */ -LJLIB_CF(jit_opt_start) -{ - jit_State *J = L2J(L); - int nargs = (int)(L->top - L->base); - if (nargs == 0) { - J->flags = (J->flags & ~JIT_F_OPT_MASK) | JIT_F_OPT_DEFAULT; - } else { - int i; - for (i = 1; i <= nargs; i++) { - const char *str = strdata(lj_lib_checkstr(L, i)); - if (!jitopt_level(J, str) && - !jitopt_flag(J, str) && - !jitopt_param(J, str)) - lj_err_callerv(L, LJ_ERR_JITOPT, str); - } - } - return 0; -} - -#include "lj_libdef.h" - -#endif - -/* -- JIT compiler initialization ----------------------------------------- */ - -#if LJ_HASJIT -/* Default values for JIT parameters. */ -static const int32_t jit_param_default[JIT_P__MAX+1] = { -#define JIT_PARAMINIT(len, name, value) (value), -JIT_PARAMDEF(JIT_PARAMINIT) -#undef JIT_PARAMINIT - 0 -}; -#endif - -#if LJ_TARGET_ARM && LJ_TARGET_LINUX -#include -#endif - -/* Arch-dependent CPU detection. */ -static uint32_t jit_cpudetect(lua_State *L) -{ - uint32_t flags = 0; -#if LJ_TARGET_X86ORX64 - uint32_t vendor[4]; - uint32_t features[4]; - if (lj_vm_cpuid(0, vendor) && lj_vm_cpuid(1, features)) { -#if !LJ_HASJIT -#define JIT_F_CMOV 1 -#define JIT_F_SSE2 2 -#endif - flags |= ((features[3] >> 15)&1) * JIT_F_CMOV; - flags |= ((features[3] >> 26)&1) * JIT_F_SSE2; -#if LJ_HASJIT - flags |= ((features[2] >> 0)&1) * JIT_F_SSE3; - flags |= ((features[2] >> 19)&1) * JIT_F_SSE4_1; - if (vendor[2] == 0x6c65746e) { /* Intel. */ - if ((features[0] & 0x0ff00f00) == 0x00000f00) /* P4. */ - flags |= JIT_F_P4; /* Currently unused. */ - else if ((features[0] & 0x0fff0ff0) == 0x000106c0) /* Atom. */ - flags |= JIT_F_LEA_AGU; - } else if (vendor[2] == 0x444d4163) { /* AMD. */ - uint32_t fam = (features[0] & 0x0ff00f00); - if (fam == 0x00000f00) /* K8. */ - flags |= JIT_F_SPLIT_XMM; - if (fam >= 0x00000f00) /* K8, K10. */ - flags |= JIT_F_PREFER_IMUL; - } -#endif - } - /* Check for required instruction set support on x86 (unnecessary on x64). */ -#if LJ_TARGET_X86 -#if !defined(LUAJIT_CPU_NOCMOV) - if (!(flags & JIT_F_CMOV)) - luaL_error(L, "CPU not supported"); -#endif -#if defined(LUAJIT_CPU_SSE2) - if (!(flags & JIT_F_SSE2)) - luaL_error(L, "CPU does not support SSE2 (recompile without -DLUAJIT_CPU_SSE2)"); -#endif -#endif -#elif LJ_TARGET_ARM -#if LJ_HASJIT - int ver = LJ_ARCH_VERSION; /* Compile-time ARM CPU detection. */ -#if LJ_TARGET_LINUX - if (ver < 70) { /* Runtime ARM CPU detection. */ - struct utsname ut; - uname(&ut); - if (strncmp(ut.machine, "armv", 4) == 0) { - if (ut.machine[4] >= '7') - ver = 70; - else if (ut.machine[4] == '6') - ver = 60; - } - } -#endif - flags |= ver >= 70 ? JIT_F_ARMV7 : - ver >= 61 ? JIT_F_ARMV6T2_ : - ver >= 60 ? JIT_F_ARMV6_ : 0; - flags |= LJ_ARCH_HASFPU == 0 ? 0 : ver >= 70 ? JIT_F_VFPV3 : JIT_F_VFPV2; -#endif -#elif LJ_TARGET_PPC -#if LJ_HASJIT -#if LJ_ARCH_SQRT - flags |= JIT_F_SQRT; -#endif -#if LJ_ARCH_ROUND - flags |= JIT_F_ROUND; -#endif -#endif -#elif LJ_TARGET_PPCSPE - /* Nothing to do. */ -#elif LJ_TARGET_MIPS -#if LJ_HASJIT - /* Compile-time MIPS CPU detection. */ -#if LJ_ARCH_VERSION >= 20 - flags |= JIT_F_MIPS32R2; -#endif - /* Runtime MIPS CPU detection. */ -#if defined(__GNUC__) - if (!(flags & JIT_F_MIPS32R2)) { - int x; - /* On MIPS32R1 rotr is treated as srl. rotr r2,r2,1 -> srl r2,r2,1. */ - __asm__("li $2, 1\n\t.long 0x00221042\n\tmove %0, $2" : "=r"(x) : : "$2"); - if (x) flags |= JIT_F_MIPS32R2; /* Either 0x80000000 (R2) or 0 (R1). */ - } -#endif -#endif -#else -#error "Missing CPU detection for this architecture" -#endif - UNUSED(L); - return flags; -} - -/* Initialize JIT compiler. */ -static void jit_init(lua_State *L) -{ - uint32_t flags = jit_cpudetect(L); -#if LJ_HASJIT - jit_State *J = L2J(L); -#if LJ_TARGET_X86 - /* Silently turn off the JIT compiler on CPUs without SSE2. */ - if ((flags & JIT_F_SSE2)) -#endif - J->flags = flags | JIT_F_ON | JIT_F_OPT_DEFAULT; - memcpy(J->param, jit_param_default, sizeof(J->param)); - lj_dispatch_update(G(L)); -#else - UNUSED(flags); -#endif -} - -LUALIB_API int luaopen_jit(lua_State *L) -{ - lua_pushliteral(L, LJ_OS_NAME); - lua_pushliteral(L, LJ_ARCH_NAME); - lua_pushinteger(L, LUAJIT_VERSION_NUM); - lua_pushliteral(L, LUAJIT_VERSION); - LJ_LIB_REG(L, LUA_JITLIBNAME, jit); -#ifndef LUAJIT_DISABLE_JITUTIL - LJ_LIB_REG(L, "jit.util", jit_util); -#endif -#if LJ_HASJIT - LJ_LIB_REG(L, "jit.opt", jit_opt); -#endif - L->top -= 2; - jit_init(L); - return 1; -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lib_math.c b/source/libs/luajit/LuaJIT-2.0.3/src/lib_math.c deleted file mode 100644 index 3aa5c6b01..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lib_math.c +++ /dev/null @@ -1,233 +0,0 @@ -/* -** Math library. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#include - -#define lib_math_c -#define LUA_LIB - -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" - -#include "lj_obj.h" -#include "lj_lib.h" -#include "lj_vm.h" - -/* ------------------------------------------------------------------------ */ - -#define LJLIB_MODULE_math - -LJLIB_ASM(math_abs) LJLIB_REC(.) -{ - lj_lib_checknumber(L, 1); - return FFH_RETRY; -} -LJLIB_ASM_(math_floor) LJLIB_REC(math_round IRFPM_FLOOR) -LJLIB_ASM_(math_ceil) LJLIB_REC(math_round IRFPM_CEIL) - -LJLIB_ASM(math_sqrt) LJLIB_REC(math_unary IRFPM_SQRT) -{ - lj_lib_checknum(L, 1); - return FFH_RETRY; -} -LJLIB_ASM_(math_log10) LJLIB_REC(math_unary IRFPM_LOG10) -LJLIB_ASM_(math_exp) LJLIB_REC(math_unary IRFPM_EXP) -LJLIB_ASM_(math_sin) LJLIB_REC(math_unary IRFPM_SIN) -LJLIB_ASM_(math_cos) LJLIB_REC(math_unary IRFPM_COS) -LJLIB_ASM_(math_tan) LJLIB_REC(math_unary IRFPM_TAN) -LJLIB_ASM_(math_asin) LJLIB_REC(math_atrig FF_math_asin) -LJLIB_ASM_(math_acos) LJLIB_REC(math_atrig FF_math_acos) -LJLIB_ASM_(math_atan) LJLIB_REC(math_atrig FF_math_atan) -LJLIB_ASM_(math_sinh) LJLIB_REC(math_htrig IRCALL_sinh) -LJLIB_ASM_(math_cosh) LJLIB_REC(math_htrig IRCALL_cosh) -LJLIB_ASM_(math_tanh) LJLIB_REC(math_htrig IRCALL_tanh) -LJLIB_ASM_(math_frexp) -LJLIB_ASM_(math_modf) LJLIB_REC(.) - -LJLIB_PUSH(57.29577951308232) -LJLIB_ASM_(math_deg) LJLIB_REC(math_degrad) - -LJLIB_PUSH(0.017453292519943295) -LJLIB_ASM_(math_rad) LJLIB_REC(math_degrad) - -LJLIB_ASM(math_log) LJLIB_REC(math_log) -{ - double x = lj_lib_checknum(L, 1); - if (L->base+1 < L->top) { - double y = lj_lib_checknum(L, 2); -#ifdef LUAJIT_NO_LOG2 - x = log(x); y = 1.0 / log(y); -#else - x = lj_vm_log2(x); y = 1.0 / lj_vm_log2(y); -#endif - setnumV(L->base-1, x*y); /* Do NOT join the expression to x / y. */ - return FFH_RES(1); - } - return FFH_RETRY; -} - -LJLIB_ASM(math_atan2) LJLIB_REC(.) -{ - lj_lib_checknum(L, 1); - lj_lib_checknum(L, 2); - return FFH_RETRY; -} -LJLIB_ASM_(math_pow) LJLIB_REC(.) -LJLIB_ASM_(math_fmod) - -LJLIB_ASM(math_ldexp) LJLIB_REC(.) -{ - lj_lib_checknum(L, 1); -#if LJ_DUALNUM && !LJ_TARGET_X86ORX64 - lj_lib_checkint(L, 2); -#else - lj_lib_checknum(L, 2); -#endif - return FFH_RETRY; -} - -LJLIB_ASM(math_min) LJLIB_REC(math_minmax IR_MIN) -{ - int i = 0; - do { lj_lib_checknumber(L, ++i); } while (L->base+i < L->top); - return FFH_RETRY; -} -LJLIB_ASM_(math_max) LJLIB_REC(math_minmax IR_MAX) - -LJLIB_PUSH(3.14159265358979323846) LJLIB_SET(pi) -LJLIB_PUSH(1e310) LJLIB_SET(huge) - -/* ------------------------------------------------------------------------ */ - -/* This implements a Tausworthe PRNG with period 2^223. Based on: -** Tables of maximally-equidistributed combined LFSR generators, -** Pierre L'Ecuyer, 1991, table 3, 1st entry. -** Full-period ME-CF generator with L=64, J=4, k=223, N1=49. -*/ - -/* PRNG state. */ -struct RandomState { - uint64_t gen[4]; /* State of the 4 LFSR generators. */ - int valid; /* State is valid. */ -}; - -/* Union needed for bit-pattern conversion between uint64_t and double. */ -typedef union { uint64_t u64; double d; } U64double; - -/* Update generator i and compute a running xor of all states. */ -#define TW223_GEN(i, k, q, s) \ - z = rs->gen[i]; \ - z = (((z<> (k-s)) ^ ((z&((uint64_t)(int64_t)-1 << (64-k)))<gen[i] = z; - -/* PRNG step function. Returns a double in the range 1.0 <= d < 2.0. */ -LJ_NOINLINE uint64_t LJ_FASTCALL lj_math_random_step(RandomState *rs) -{ - uint64_t z, r = 0; - TW223_GEN(0, 63, 31, 18) - TW223_GEN(1, 58, 19, 28) - TW223_GEN(2, 55, 24, 7) - TW223_GEN(3, 47, 21, 8) - return (r & U64x(000fffff,ffffffff)) | U64x(3ff00000,00000000); -} - -/* PRNG initialization function. */ -static void random_init(RandomState *rs, double d) -{ - uint32_t r = 0x11090601; /* 64-k[i] as four 8 bit constants. */ - int i; - for (i = 0; i < 4; i++) { - U64double u; - uint32_t m = 1u << (r&255); - r >>= 8; - u.d = d = d * 3.14159265358979323846 + 2.7182818284590452354; - if (u.u64 < m) u.u64 += m; /* Ensure k[i] MSB of gen[i] are non-zero. */ - rs->gen[i] = u.u64; - } - rs->valid = 1; - for (i = 0; i < 10; i++) - lj_math_random_step(rs); -} - -/* PRNG extract function. */ -LJLIB_PUSH(top-2) /* Upvalue holds userdata with RandomState. */ -LJLIB_CF(math_random) LJLIB_REC(.) -{ - int n = (int)(L->top - L->base); - RandomState *rs = (RandomState *)(uddata(udataV(lj_lib_upvalue(L, 1)))); - U64double u; - double d; - if (LJ_UNLIKELY(!rs->valid)) random_init(rs, 0.0); - u.u64 = lj_math_random_step(rs); - d = u.d - 1.0; - if (n > 0) { -#if LJ_DUALNUM - int isint = 1; - double r1; - lj_lib_checknumber(L, 1); - if (tvisint(L->base)) { - r1 = (lua_Number)intV(L->base); - } else { - isint = 0; - r1 = numV(L->base); - } -#else - double r1 = lj_lib_checknum(L, 1); -#endif - if (n == 1) { - d = lj_vm_floor(d*r1) + 1.0; /* d is an int in range [1, r1] */ - } else { -#if LJ_DUALNUM - double r2; - lj_lib_checknumber(L, 2); - if (tvisint(L->base+1)) { - r2 = (lua_Number)intV(L->base+1); - } else { - isint = 0; - r2 = numV(L->base+1); - } -#else - double r2 = lj_lib_checknum(L, 2); -#endif - d = lj_vm_floor(d*(r2-r1+1.0)) + r1; /* d is an int in range [r1, r2] */ - } -#if LJ_DUALNUM - if (isint) { - setintV(L->top-1, lj_num2int(d)); - return 1; - } -#endif - } /* else: d is a double in range [0, 1] */ - setnumV(L->top++, d); - return 1; -} - -/* PRNG seed function. */ -LJLIB_PUSH(top-2) /* Upvalue holds userdata with RandomState. */ -LJLIB_CF(math_randomseed) -{ - RandomState *rs = (RandomState *)(uddata(udataV(lj_lib_upvalue(L, 1)))); - random_init(rs, lj_lib_checknum(L, 1)); - return 0; -} - -/* ------------------------------------------------------------------------ */ - -#include "lj_libdef.h" - -LUALIB_API int luaopen_math(lua_State *L) -{ - RandomState *rs; - rs = (RandomState *)lua_newuserdata(L, sizeof(RandomState)); - rs->valid = 0; /* Use lazy initialization to save some time on startup. */ - LJ_LIB_REG(L, LUA_MATHLIBNAME, math); -#if defined(LUA_COMPAT_MOD) && !LJ_52 - lua_getfield(L, -1, "fmod"); - lua_setfield(L, -2, "mod"); -#endif - return 1; -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lib_os.c b/source/libs/luajit/LuaJIT-2.0.3/src/lib_os.c deleted file mode 100644 index f62e8c8bb..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lib_os.c +++ /dev/null @@ -1,280 +0,0 @@ -/* -** OS library. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Major portions taken verbatim or adapted from the Lua interpreter. -** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h -*/ - -#include -#include -#include - -#define lib_os_c -#define LUA_LIB - -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" - -#include "lj_obj.h" -#include "lj_err.h" -#include "lj_lib.h" - -#if LJ_TARGET_POSIX -#include -#else -#include -#endif - -/* ------------------------------------------------------------------------ */ - -#define LJLIB_MODULE_os - -LJLIB_CF(os_execute) -{ -#if LJ_TARGET_CONSOLE -#if LJ_52 - errno = ENOSYS; - return luaL_fileresult(L, 0, NULL); -#else - lua_pushinteger(L, -1); - return 1; -#endif -#else - const char *cmd = luaL_optstring(L, 1, NULL); - int stat = system(cmd); -#if LJ_52 - if (cmd) - return luaL_execresult(L, stat); - setboolV(L->top++, 1); -#else - setintV(L->top++, stat); -#endif - return 1; -#endif -} - -LJLIB_CF(os_remove) -{ - const char *filename = luaL_checkstring(L, 1); - return luaL_fileresult(L, remove(filename) == 0, filename); -} - -LJLIB_CF(os_rename) -{ - const char *fromname = luaL_checkstring(L, 1); - const char *toname = luaL_checkstring(L, 2); - return luaL_fileresult(L, rename(fromname, toname) == 0, fromname); -} - -LJLIB_CF(os_tmpname) -{ -#if LJ_TARGET_PS3 || LJ_TARGET_PS4 - lj_err_caller(L, LJ_ERR_OSUNIQF); - return 0; -#else -#if LJ_TARGET_POSIX - char buf[15+1]; - int fp; - strcpy(buf, "/tmp/lua_XXXXXX"); - fp = mkstemp(buf); - if (fp != -1) - close(fp); - else - lj_err_caller(L, LJ_ERR_OSUNIQF); -#else - char buf[L_tmpnam]; - if (tmpnam(buf) == NULL) - lj_err_caller(L, LJ_ERR_OSUNIQF); -#endif - lua_pushstring(L, buf); - return 1; -#endif -} - -LJLIB_CF(os_getenv) -{ -#if LJ_TARGET_CONSOLE - lua_pushnil(L); -#else - lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ -#endif - return 1; -} - -LJLIB_CF(os_exit) -{ - int status; - if (L->base < L->top && tvisbool(L->base)) - status = boolV(L->base) ? EXIT_SUCCESS : EXIT_FAILURE; - else - status = lj_lib_optint(L, 1, EXIT_SUCCESS); - if (L->base+1 < L->top && tvistruecond(L->base+1)) - lua_close(L); - exit(status); - return 0; /* Unreachable. */ -} - -LJLIB_CF(os_clock) -{ - setnumV(L->top++, ((lua_Number)clock())*(1.0/(lua_Number)CLOCKS_PER_SEC)); - return 1; -} - -/* ------------------------------------------------------------------------ */ - -static void setfield(lua_State *L, const char *key, int value) -{ - lua_pushinteger(L, value); - lua_setfield(L, -2, key); -} - -static void setboolfield(lua_State *L, const char *key, int value) -{ - if (value < 0) /* undefined? */ - return; /* does not set field */ - lua_pushboolean(L, value); - lua_setfield(L, -2, key); -} - -static int getboolfield(lua_State *L, const char *key) -{ - int res; - lua_getfield(L, -1, key); - res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1); - lua_pop(L, 1); - return res; -} - -static int getfield(lua_State *L, const char *key, int d) -{ - int res; - lua_getfield(L, -1, key); - if (lua_isnumber(L, -1)) { - res = (int)lua_tointeger(L, -1); - } else { - if (d < 0) - lj_err_callerv(L, LJ_ERR_OSDATEF, key); - res = d; - } - lua_pop(L, 1); - return res; -} - -LJLIB_CF(os_date) -{ - const char *s = luaL_optstring(L, 1, "%c"); - time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL)); - struct tm *stm; -#if LJ_TARGET_POSIX - struct tm rtm; -#endif - if (*s == '!') { /* UTC? */ - s++; /* Skip '!' */ -#if LJ_TARGET_POSIX - stm = gmtime_r(&t, &rtm); -#else - stm = gmtime(&t); -#endif - } else { -#if LJ_TARGET_POSIX - stm = localtime_r(&t, &rtm); -#else - stm = localtime(&t); -#endif - } - if (stm == NULL) { /* Invalid date? */ - setnilV(L->top-1); - } else if (strcmp(s, "*t") == 0) { - lua_createtable(L, 0, 9); /* 9 = number of fields */ - setfield(L, "sec", stm->tm_sec); - setfield(L, "min", stm->tm_min); - setfield(L, "hour", stm->tm_hour); - setfield(L, "day", stm->tm_mday); - setfield(L, "month", stm->tm_mon+1); - setfield(L, "year", stm->tm_year+1900); - setfield(L, "wday", stm->tm_wday+1); - setfield(L, "yday", stm->tm_yday+1); - setboolfield(L, "isdst", stm->tm_isdst); - } else { - char cc[3]; - luaL_Buffer b; - cc[0] = '%'; cc[2] = '\0'; - luaL_buffinit(L, &b); - for (; *s; s++) { - if (*s != '%' || *(s + 1) == '\0') { /* No conversion specifier? */ - luaL_addchar(&b, *s); - } else { - size_t reslen; - char buff[200]; /* Should be big enough for any conversion result. */ - cc[1] = *(++s); - reslen = strftime(buff, sizeof(buff), cc, stm); - luaL_addlstring(&b, buff, reslen); - } - } - luaL_pushresult(&b); - } - return 1; -} - -LJLIB_CF(os_time) -{ - time_t t; - if (lua_isnoneornil(L, 1)) { /* called without args? */ - t = time(NULL); /* get current time */ - } else { - struct tm ts; - luaL_checktype(L, 1, LUA_TTABLE); - lua_settop(L, 1); /* make sure table is at the top */ - ts.tm_sec = getfield(L, "sec", 0); - ts.tm_min = getfield(L, "min", 0); - ts.tm_hour = getfield(L, "hour", 12); - ts.tm_mday = getfield(L, "day", -1); - ts.tm_mon = getfield(L, "month", -1) - 1; - ts.tm_year = getfield(L, "year", -1) - 1900; - ts.tm_isdst = getboolfield(L, "isdst"); - t = mktime(&ts); - } - if (t == (time_t)(-1)) - lua_pushnil(L); - else - lua_pushnumber(L, (lua_Number)t); - return 1; -} - -LJLIB_CF(os_difftime) -{ - lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)), - (time_t)(luaL_optnumber(L, 2, (lua_Number)0)))); - return 1; -} - -/* ------------------------------------------------------------------------ */ - -LJLIB_CF(os_setlocale) -{ - GCstr *s = lj_lib_optstr(L, 1); - const char *str = s ? strdata(s) : NULL; - int opt = lj_lib_checkopt(L, 2, 6, - "\5ctype\7numeric\4time\7collate\10monetary\1\377\3all"); - if (opt == 0) opt = LC_CTYPE; - else if (opt == 1) opt = LC_NUMERIC; - else if (opt == 2) opt = LC_TIME; - else if (opt == 3) opt = LC_COLLATE; - else if (opt == 4) opt = LC_MONETARY; - else if (opt == 6) opt = LC_ALL; - lua_pushstring(L, setlocale(opt, str)); - return 1; -} - -/* ------------------------------------------------------------------------ */ - -#include "lj_libdef.h" - -LUALIB_API int luaopen_os(lua_State *L) -{ - LJ_LIB_REG(L, LUA_OSLIBNAME, os); - return 1; -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lib_package.c b/source/libs/luajit/LuaJIT-2.0.3/src/lib_package.c deleted file mode 100644 index 0e4a8ed06..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lib_package.c +++ /dev/null @@ -1,640 +0,0 @@ -/* -** Package library. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Major portions taken verbatim or adapted from the Lua interpreter. -** Copyright (C) 1994-2012 Lua.org, PUC-Rio. See Copyright Notice in lua.h -*/ - -#define lib_package_c -#define LUA_LIB - -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" - -#include "lj_obj.h" -#include "lj_err.h" -#include "lj_lib.h" - -/* ------------------------------------------------------------------------ */ - -/* Error codes for ll_loadfunc. */ -#define PACKAGE_ERR_LIB 1 -#define PACKAGE_ERR_FUNC 2 -#define PACKAGE_ERR_LOAD 3 - -/* Redefined in platform specific part. */ -#define PACKAGE_LIB_FAIL "open" -#define setprogdir(L) ((void)0) - -/* Symbol name prefixes. */ -#define SYMPREFIX_CF "luaopen_%s" -#define SYMPREFIX_BC "luaJIT_BC_%s" - -#if LJ_TARGET_DLOPEN - -#include - -static void ll_unloadlib(void *lib) -{ - dlclose(lib); -} - -static void *ll_load(lua_State *L, const char *path, int gl) -{ - void *lib = dlopen(path, RTLD_NOW | (gl ? RTLD_GLOBAL : RTLD_LOCAL)); - if (lib == NULL) lua_pushstring(L, dlerror()); - return lib; -} - -static lua_CFunction ll_sym(lua_State *L, void *lib, const char *sym) -{ - lua_CFunction f = (lua_CFunction)dlsym(lib, sym); - if (f == NULL) lua_pushstring(L, dlerror()); - return f; -} - -static const char *ll_bcsym(void *lib, const char *sym) -{ -#if defined(RTLD_DEFAULT) - if (lib == NULL) lib = RTLD_DEFAULT; -#elif LJ_TARGET_OSX || LJ_TARGET_BSD - if (lib == NULL) lib = (void *)(intptr_t)-2; -#endif - return (const char *)dlsym(lib, sym); -} - -#elif LJ_TARGET_WINDOWS - -#define WIN32_LEAN_AND_MEAN -#include - -#ifndef GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS -#define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 4 -#define GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT 2 -BOOL WINAPI GetModuleHandleExA(DWORD, LPCSTR, HMODULE*); -#endif - -#undef setprogdir - -static void setprogdir(lua_State *L) -{ - char buff[MAX_PATH + 1]; - char *lb; - DWORD nsize = sizeof(buff); - DWORD n = GetModuleFileNameA(NULL, buff, nsize); - if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) { - luaL_error(L, "unable to get ModuleFileName"); - } else { - *lb = '\0'; - luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff); - lua_remove(L, -2); /* remove original string */ - } -} - -static void pusherror(lua_State *L) -{ - DWORD error = GetLastError(); - char buffer[128]; - if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, error, 0, buffer, sizeof(buffer), NULL)) - lua_pushstring(L, buffer); - else - lua_pushfstring(L, "system error %d\n", error); -} - -static void ll_unloadlib(void *lib) -{ - FreeLibrary((HINSTANCE)lib); -} - -static void *ll_load(lua_State *L, const char *path, int gl) -{ - HINSTANCE lib = LoadLibraryA(path); - if (lib == NULL) pusherror(L); - UNUSED(gl); - return lib; -} - -static lua_CFunction ll_sym(lua_State *L, void *lib, const char *sym) -{ - lua_CFunction f = (lua_CFunction)GetProcAddress((HINSTANCE)lib, sym); - if (f == NULL) pusherror(L); - return f; -} - -static const char *ll_bcsym(void *lib, const char *sym) -{ - if (lib) { - return (const char *)GetProcAddress((HINSTANCE)lib, sym); - } else { - HINSTANCE h = GetModuleHandleA(NULL); - const char *p = (const char *)GetProcAddress(h, sym); - if (p == NULL && GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - (const char *)ll_bcsym, &h)) - p = (const char *)GetProcAddress(h, sym); - return p; - } -} - -#else - -#undef PACKAGE_LIB_FAIL -#define PACKAGE_LIB_FAIL "absent" - -#define DLMSG "dynamic libraries not enabled; no support for target OS" - -static void ll_unloadlib(void *lib) -{ - UNUSED(lib); -} - -static void *ll_load(lua_State *L, const char *path, int gl) -{ - UNUSED(path); UNUSED(gl); - lua_pushliteral(L, DLMSG); - return NULL; -} - -static lua_CFunction ll_sym(lua_State *L, void *lib, const char *sym) -{ - UNUSED(lib); UNUSED(sym); - lua_pushliteral(L, DLMSG); - return NULL; -} - -static const char *ll_bcsym(void *lib, const char *sym) -{ - UNUSED(lib); UNUSED(sym); - return NULL; -} - -#endif - -/* ------------------------------------------------------------------------ */ - -static void **ll_register(lua_State *L, const char *path) -{ - void **plib; - lua_pushfstring(L, "LOADLIB: %s", path); - lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */ - if (!lua_isnil(L, -1)) { /* is there an entry? */ - plib = (void **)lua_touserdata(L, -1); - } else { /* no entry yet; create one */ - lua_pop(L, 1); - plib = (void **)lua_newuserdata(L, sizeof(void *)); - *plib = NULL; - luaL_getmetatable(L, "_LOADLIB"); - lua_setmetatable(L, -2); - lua_pushfstring(L, "LOADLIB: %s", path); - lua_pushvalue(L, -2); - lua_settable(L, LUA_REGISTRYINDEX); - } - return plib; -} - -static const char *mksymname(lua_State *L, const char *modname, - const char *prefix) -{ - const char *funcname; - const char *mark = strchr(modname, *LUA_IGMARK); - if (mark) modname = mark + 1; - funcname = luaL_gsub(L, modname, ".", "_"); - funcname = lua_pushfstring(L, prefix, funcname); - lua_remove(L, -2); /* remove 'gsub' result */ - return funcname; -} - -static int ll_loadfunc(lua_State *L, const char *path, const char *name, int r) -{ - void **reg = ll_register(L, path); - if (*reg == NULL) *reg = ll_load(L, path, (*name == '*')); - if (*reg == NULL) { - return PACKAGE_ERR_LIB; /* Unable to load library. */ - } else if (*name == '*') { /* Only load library into global namespace. */ - lua_pushboolean(L, 1); - return 0; - } else { - const char *sym = r ? name : mksymname(L, name, SYMPREFIX_CF); - lua_CFunction f = ll_sym(L, *reg, sym); - if (f) { - lua_pushcfunction(L, f); - return 0; - } - if (!r) { - const char *bcdata = ll_bcsym(*reg, mksymname(L, name, SYMPREFIX_BC)); - lua_pop(L, 1); - if (bcdata) { - if (luaL_loadbuffer(L, bcdata, ~(size_t)0, name) != 0) - return PACKAGE_ERR_LOAD; - return 0; - } - } - return PACKAGE_ERR_FUNC; /* Unable to find function. */ - } -} - -static int lj_cf_package_loadlib(lua_State *L) -{ - const char *path = luaL_checkstring(L, 1); - const char *init = luaL_checkstring(L, 2); - int st = ll_loadfunc(L, path, init, 1); - if (st == 0) { /* no errors? */ - return 1; /* return the loaded function */ - } else { /* error; error message is on stack top */ - lua_pushnil(L); - lua_insert(L, -2); - lua_pushstring(L, (st == PACKAGE_ERR_LIB) ? PACKAGE_LIB_FAIL : "init"); - return 3; /* return nil, error message, and where */ - } -} - -static int lj_cf_package_unloadlib(lua_State *L) -{ - void **lib = (void **)luaL_checkudata(L, 1, "_LOADLIB"); - if (*lib) ll_unloadlib(*lib); - *lib = NULL; /* mark library as closed */ - return 0; -} - -/* ------------------------------------------------------------------------ */ - -static int readable(const char *filename) -{ - FILE *f = fopen(filename, "r"); /* try to open file */ - if (f == NULL) return 0; /* open failed */ - fclose(f); - return 1; -} - -static const char *pushnexttemplate(lua_State *L, const char *path) -{ - const char *l; - while (*path == *LUA_PATHSEP) path++; /* skip separators */ - if (*path == '\0') return NULL; /* no more templates */ - l = strchr(path, *LUA_PATHSEP); /* find next separator */ - if (l == NULL) l = path + strlen(path); - lua_pushlstring(L, path, (size_t)(l - path)); /* template */ - return l; -} - -static const char *searchpath (lua_State *L, const char *name, - const char *path, const char *sep, - const char *dirsep) -{ - luaL_Buffer msg; /* to build error message */ - luaL_buffinit(L, &msg); - if (*sep != '\0') /* non-empty separator? */ - name = luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */ - while ((path = pushnexttemplate(L, path)) != NULL) { - const char *filename = luaL_gsub(L, lua_tostring(L, -1), - LUA_PATH_MARK, name); - lua_remove(L, -2); /* remove path template */ - if (readable(filename)) /* does file exist and is readable? */ - return filename; /* return that file name */ - lua_pushfstring(L, "\n\tno file " LUA_QS, filename); - lua_remove(L, -2); /* remove file name */ - luaL_addvalue(&msg); /* concatenate error msg. entry */ - } - luaL_pushresult(&msg); /* create error message */ - return NULL; /* not found */ -} - -static int lj_cf_package_searchpath(lua_State *L) -{ - const char *f = searchpath(L, luaL_checkstring(L, 1), - luaL_checkstring(L, 2), - luaL_optstring(L, 3, "."), - luaL_optstring(L, 4, LUA_DIRSEP)); - if (f != NULL) { - return 1; - } else { /* error message is on top of the stack */ - lua_pushnil(L); - lua_insert(L, -2); - return 2; /* return nil + error message */ - } -} - -static const char *findfile(lua_State *L, const char *name, - const char *pname) -{ - const char *path; - lua_getfield(L, LUA_ENVIRONINDEX, pname); - path = lua_tostring(L, -1); - if (path == NULL) - luaL_error(L, LUA_QL("package.%s") " must be a string", pname); - return searchpath(L, name, path, ".", LUA_DIRSEP); -} - -static void loaderror(lua_State *L, const char *filename) -{ - luaL_error(L, "error loading module " LUA_QS " from file " LUA_QS ":\n\t%s", - lua_tostring(L, 1), filename, lua_tostring(L, -1)); -} - -static int lj_cf_package_loader_lua(lua_State *L) -{ - const char *filename; - const char *name = luaL_checkstring(L, 1); - filename = findfile(L, name, "path"); - if (filename == NULL) return 1; /* library not found in this path */ - if (luaL_loadfile(L, filename) != 0) - loaderror(L, filename); - return 1; /* library loaded successfully */ -} - -static int lj_cf_package_loader_c(lua_State *L) -{ - const char *name = luaL_checkstring(L, 1); - const char *filename = findfile(L, name, "cpath"); - if (filename == NULL) return 1; /* library not found in this path */ - if (ll_loadfunc(L, filename, name, 0) != 0) - loaderror(L, filename); - return 1; /* library loaded successfully */ -} - -#define LUA_POF "luaopen_" -#define LUA_OFSEP "_" -#define POF LUA_POF - -static const char *mkfuncname (lua_State *L, const char *modname) { - const char *funcname; - const char *mark = strchr(modname, *LUA_IGMARK); - if (mark) modname = mark + 1; - funcname = luaL_gsub(L, modname, ".", LUA_OFSEP); - funcname = lua_pushfstring(L, POF"%s", funcname); - lua_remove(L, -2); /* remove 'gsub' result */ - return funcname; -} - - -int loader_C_luatex (lua_State *L, const char *name, const char *filename) { - const char *funcname; - funcname = mkfuncname(L, name); - if (ll_loadfunc(L, filename, funcname,0) != 0) - loaderror(L, filename); - return 1; /* library loaded successfully */ -} - -static int lj_cf_package_loader_croot(lua_State *L) -{ - const char *filename; - const char *name = luaL_checkstring(L, 1); - const char *p = strchr(name, '.'); - int st; - if (p == NULL) return 0; /* is root */ - lua_pushlstring(L, name, (size_t)(p - name)); - filename = findfile(L, lua_tostring(L, -1), "cpath"); - if (filename == NULL) return 1; /* root not found */ - if ((st = ll_loadfunc(L, filename, name, 0)) != 0) { - if (st != PACKAGE_ERR_FUNC) loaderror(L, filename); /* real error */ - lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, - name, filename); - return 1; /* function not found */ - } - return 1; -} - -int loader_Call_luatex (lua_State *L, const char *name, const char *filename) { - const char *funcname; - int stat; - if (filename == NULL) return 1; /* root not found */ - funcname = mkfuncname(L, name); - if ((stat = ll_loadfunc(L, filename, funcname,0)) != 0) { - if (stat != PACKAGE_ERR_FUNC) loaderror(L, filename); /* real error */ - lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, - name, filename); - return 1; /* function not found */ - } - return 1; /* library loaded successfully */ -} - - -static int lj_cf_package_loader_preload(lua_State *L) -{ - const char *name = luaL_checkstring(L, 1); - lua_getfield(L, LUA_ENVIRONINDEX, "preload"); - if (!lua_istable(L, -1)) - luaL_error(L, LUA_QL("package.preload") " must be a table"); - lua_getfield(L, -1, name); - if (lua_isnil(L, -1)) { /* Not found? */ - const char *bcname = mksymname(L, name, SYMPREFIX_BC); - const char *bcdata = ll_bcsym(NULL, bcname); - if (bcdata == NULL || luaL_loadbuffer(L, bcdata, ~(size_t)0, name) != 0) - lua_pushfstring(L, "\n\tno field package.preload['%s']", name); - } - return 1; -} - -/* ------------------------------------------------------------------------ */ - -static const int sentinel_ = 0; -#define sentinel ((void *)&sentinel_) - -static int lj_cf_package_require(lua_State *L) -{ - const char *name = luaL_checkstring(L, 1); - int i; - lua_settop(L, 1); /* _LOADED table will be at index 2 */ - lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); - lua_getfield(L, 2, name); - if (lua_toboolean(L, -1)) { /* is it there? */ - if (lua_touserdata(L, -1) == sentinel) /* check loops */ - luaL_error(L, "loop or previous error loading module " LUA_QS, name); - return 1; /* package is already loaded */ - } - /* else must load it; iterate over available loaders */ - lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); - if (!lua_istable(L, -1)) - luaL_error(L, LUA_QL("package.loaders") " must be a table"); - lua_pushliteral(L, ""); /* error message accumulator */ - for (i = 1; ; i++) { - lua_rawgeti(L, -2, i); /* get a loader */ - if (lua_isnil(L, -1)) - luaL_error(L, "module " LUA_QS " not found:%s", - name, lua_tostring(L, -2)); - lua_pushstring(L, name); - lua_call(L, 1, 1); /* call it */ - if (lua_isfunction(L, -1)) /* did it find module? */ - break; /* module loaded successfully */ - else if (lua_isstring(L, -1)) /* loader returned error message? */ - lua_concat(L, 2); /* accumulate it */ - else - lua_pop(L, 1); - } - lua_pushlightuserdata(L, sentinel); - lua_setfield(L, 2, name); /* _LOADED[name] = sentinel */ - lua_pushstring(L, name); /* pass name as argument to module */ - lua_call(L, 1, 1); /* run loaded module */ - if (!lua_isnil(L, -1)) /* non-nil return? */ - lua_setfield(L, 2, name); /* _LOADED[name] = returned value */ - lua_getfield(L, 2, name); - if (lua_touserdata(L, -1) == sentinel) { /* module did not set a value? */ - lua_pushboolean(L, 1); /* use true as result */ - lua_pushvalue(L, -1); /* extra copy to be returned */ - lua_setfield(L, 2, name); /* _LOADED[name] = true */ - } - lj_lib_checkfpu(L); - return 1; -} - -/* ------------------------------------------------------------------------ */ - -static void setfenv(lua_State *L) -{ - lua_Debug ar; - if (lua_getstack(L, 1, &ar) == 0 || - lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ - lua_iscfunction(L, -1)) - luaL_error(L, LUA_QL("module") " not called from a Lua function"); - lua_pushvalue(L, -2); - lua_setfenv(L, -2); - lua_pop(L, 1); -} - -static void dooptions(lua_State *L, int n) -{ - int i; - for (i = 2; i <= n; i++) { - lua_pushvalue(L, i); /* get option (a function) */ - lua_pushvalue(L, -2); /* module */ - lua_call(L, 1, 0); - } -} - -static void modinit(lua_State *L, const char *modname) -{ - const char *dot; - lua_pushvalue(L, -1); - lua_setfield(L, -2, "_M"); /* module._M = module */ - lua_pushstring(L, modname); - lua_setfield(L, -2, "_NAME"); - dot = strrchr(modname, '.'); /* look for last dot in module name */ - if (dot == NULL) dot = modname; else dot++; - /* set _PACKAGE as package name (full module name minus last part) */ - lua_pushlstring(L, modname, (size_t)(dot - modname)); - lua_setfield(L, -2, "_PACKAGE"); -} - -static int lj_cf_package_module(lua_State *L) -{ - const char *modname = luaL_checkstring(L, 1); - int loaded = lua_gettop(L) + 1; /* index of _LOADED table */ - lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); - lua_getfield(L, loaded, modname); /* get _LOADED[modname] */ - if (!lua_istable(L, -1)) { /* not found? */ - lua_pop(L, 1); /* remove previous result */ - /* try global variable (and create one if it does not exist) */ - if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, 1) != NULL) - lj_err_callerv(L, LJ_ERR_BADMODN, modname); - lua_pushvalue(L, -1); - lua_setfield(L, loaded, modname); /* _LOADED[modname] = new table */ - } - /* check whether table already has a _NAME field */ - lua_getfield(L, -1, "_NAME"); - if (!lua_isnil(L, -1)) { /* is table an initialized module? */ - lua_pop(L, 1); - } else { /* no; initialize it */ - lua_pop(L, 1); - modinit(L, modname); - } - lua_pushvalue(L, -1); - setfenv(L); - dooptions(L, loaded - 1); - return 0; -} - -static int lj_cf_package_seeall(lua_State *L) -{ - luaL_checktype(L, 1, LUA_TTABLE); - if (!lua_getmetatable(L, 1)) { - lua_createtable(L, 0, 1); /* create new metatable */ - lua_pushvalue(L, -1); - lua_setmetatable(L, 1); - } - lua_pushvalue(L, LUA_GLOBALSINDEX); - lua_setfield(L, -2, "__index"); /* mt.__index = _G */ - return 0; -} - -/* ------------------------------------------------------------------------ */ - -#define AUXMARK "\1" - -static void setpath(lua_State *L, const char *fieldname, const char *envname, - const char *def, int noenv) -{ -#if LJ_TARGET_CONSOLE - const char *path = NULL; - UNUSED(envname); -#else - const char *path = getenv(envname); -#endif - if (path == NULL || noenv) { - lua_pushstring(L, def); - } else { - path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP, - LUA_PATHSEP AUXMARK LUA_PATHSEP); - luaL_gsub(L, path, AUXMARK, def); - lua_remove(L, -2); - } - setprogdir(L); - lua_setfield(L, -2, fieldname); -} - -static const luaL_Reg package_lib[] = { - { "loadlib", lj_cf_package_loadlib }, - { "searchpath", lj_cf_package_searchpath }, - { "seeall", lj_cf_package_seeall }, - { NULL, NULL } -}; - -static const luaL_Reg package_global[] = { - { "module", lj_cf_package_module }, - { "require", lj_cf_package_require }, - { NULL, NULL } -}; - -static const lua_CFunction package_loaders[] = -{ - lj_cf_package_loader_preload, - lj_cf_package_loader_lua, - lj_cf_package_loader_c, - lj_cf_package_loader_croot, - NULL -}; - -LUALIB_API int luaopen_package(lua_State *L) -{ - int i; - int noenv; - luaL_newmetatable(L, "_LOADLIB"); - lj_lib_pushcf(L, lj_cf_package_unloadlib, 1); - lua_setfield(L, -2, "__gc"); - luaL_register(L, LUA_LOADLIBNAME, package_lib); - lua_pushvalue(L, -1); - lua_replace(L, LUA_ENVIRONINDEX); - lua_createtable(L, sizeof(package_loaders)/sizeof(package_loaders[0])-1, 0); - for (i = 0; package_loaders[i] != NULL; i++) { - lj_lib_pushcf(L, package_loaders[i], 1); - lua_rawseti(L, -2, i+1); - } - lua_setfield(L, -2, "loaders"); - lua_getfield(L, LUA_REGISTRYINDEX, "LUA_NOENV"); - noenv = lua_toboolean(L, -1); - lua_pop(L, 1); - setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT, noenv); - setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT, noenv); - lua_pushliteral(L, LUA_PATH_CONFIG); - lua_setfield(L, -2, "config"); - luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 16); - lua_setfield(L, -2, "loaded"); - luaL_findtable(L, LUA_REGISTRYINDEX, "_PRELOAD", 4); - lua_setfield(L, -2, "preload"); - lua_pushvalue(L, LUA_GLOBALSINDEX); - luaL_register(L, NULL, package_global); - lua_pop(L, 1); - return 1; -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lib_string.c b/source/libs/luajit/LuaJIT-2.0.3/src/lib_string.c deleted file mode 100644 index 9ec6d0c3d..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lib_string.c +++ /dev/null @@ -1,940 +0,0 @@ -/* -** String library. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Major portions taken verbatim or adapted from the Lua interpreter. -** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h -*/ - -#include - -#define lib_string_c -#define LUA_LIB - -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" - -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_meta.h" -#include "lj_state.h" -#include "lj_ff.h" -#include "lj_bcdump.h" -#include "lj_char.h" -#include "lj_lib.h" - -/* ------------------------------------------------------------------------ */ - -#define LJLIB_MODULE_string - -LJLIB_ASM(string_len) LJLIB_REC(.) -{ - lj_lib_checkstr(L, 1); - return FFH_RETRY; -} - -LJLIB_ASM(string_byte) LJLIB_REC(string_range 0) -{ - GCstr *s = lj_lib_checkstr(L, 1); - int32_t len = (int32_t)s->len; - int32_t start = lj_lib_optint(L, 2, 1); - int32_t stop = lj_lib_optint(L, 3, start); - int32_t n, i; - const unsigned char *p; - if (stop < 0) stop += len+1; - if (start < 0) start += len+1; - if (start <= 0) start = 1; - if (stop > len) stop = len; - if (start > stop) return FFH_RES(0); /* Empty interval: return no results. */ - start--; - n = stop - start; - if ((uint32_t)n > LUAI_MAXCSTACK) - lj_err_caller(L, LJ_ERR_STRSLC); - lj_state_checkstack(L, (MSize)n); - p = (const unsigned char *)strdata(s) + start; - for (i = 0; i < n; i++) - setintV(L->base + i-1, p[i]); - return FFH_RES(n); -} - -LJLIB_ASM(string_char) -{ - int i, nargs = (int)(L->top - L->base); - char *buf = lj_str_needbuf(L, &G(L)->tmpbuf, (MSize)nargs); - for (i = 1; i <= nargs; i++) { - int32_t k = lj_lib_checkint(L, i); - if (!checku8(k)) - lj_err_arg(L, i, LJ_ERR_BADVAL); - buf[i-1] = (char)k; - } - setstrV(L, L->base-1, lj_str_new(L, buf, (size_t)nargs)); - return FFH_RES(1); -} - -LJLIB_ASM(string_sub) LJLIB_REC(string_range 1) -{ - lj_lib_checkstr(L, 1); - lj_lib_checkint(L, 2); - setintV(L->base+2, lj_lib_optint(L, 3, -1)); - return FFH_RETRY; -} - -LJLIB_ASM(string_rep) -{ - GCstr *s = lj_lib_checkstr(L, 1); - int32_t k = lj_lib_checkint(L, 2); - GCstr *sep = lj_lib_optstr(L, 3); - int32_t len = (int32_t)s->len; - global_State *g = G(L); - int64_t tlen; - const char *src; - char *buf; - if (k <= 0) { - empty: - setstrV(L, L->base-1, &g->strempty); - return FFH_RES(1); - } - if (sep) { - tlen = (int64_t)len + sep->len; - if (tlen > LJ_MAX_STR) - lj_err_caller(L, LJ_ERR_STROV); - tlen *= k; - if (tlen > LJ_MAX_STR) - lj_err_caller(L, LJ_ERR_STROV); - } else { - tlen = (int64_t)k * len; - if (tlen > LJ_MAX_STR) - lj_err_caller(L, LJ_ERR_STROV); - } - if (tlen == 0) goto empty; - buf = lj_str_needbuf(L, &g->tmpbuf, (MSize)tlen); - src = strdata(s); - if (sep) { - tlen -= sep->len; /* Ignore trailing separator. */ - if (k > 1) { /* Paste one string and one separator. */ - int32_t i; - i = 0; while (i < len) *buf++ = src[i++]; - src = strdata(sep); len = sep->len; - i = 0; while (i < len) *buf++ = src[i++]; - src = g->tmpbuf.buf; len += s->len; k--; /* Now copy that k-1 times. */ - } - } - do { - int32_t i = 0; - do { *buf++ = src[i++]; } while (i < len); - } while (--k > 0); - setstrV(L, L->base-1, lj_str_new(L, g->tmpbuf.buf, (size_t)tlen)); - return FFH_RES(1); -} - -LJLIB_ASM(string_reverse) -{ - GCstr *s = lj_lib_checkstr(L, 1); - lj_str_needbuf(L, &G(L)->tmpbuf, s->len); - return FFH_RETRY; -} -LJLIB_ASM_(string_lower) -LJLIB_ASM_(string_upper) - -/* ------------------------------------------------------------------------ */ - -static int writer_buf(lua_State *L, const void *p, size_t size, void *b) -{ - luaL_addlstring((luaL_Buffer *)b, (const char *)p, size); - UNUSED(L); - return 0; -} - -LJLIB_CF(string_dump) -{ - GCfunc *fn = lj_lib_checkfunc(L, 1); - int strip = L->base+1 < L->top && tvistruecond(L->base+1); - luaL_Buffer b; - L->top = L->base+1; - luaL_buffinit(L, &b); - if (!isluafunc(fn) || lj_bcwrite(L, funcproto(fn), writer_buf, &b, strip)) - lj_err_caller(L, LJ_ERR_STRDUMP); - luaL_pushresult(&b); - return 1; -} - -/* ------------------------------------------------------------------------ */ - -/* macro to `unsign' a character */ -#define uchar(c) ((unsigned char)(c)) - -#define CAP_UNFINISHED (-1) -#define CAP_POSITION (-2) - -typedef struct MatchState { - const char *src_init; /* init of source string */ - const char *src_end; /* end (`\0') of source string */ - lua_State *L; - int level; /* total number of captures (finished or unfinished) */ - int depth; - struct { - const char *init; - ptrdiff_t len; - } capture[LUA_MAXCAPTURES]; -} MatchState; - -#define L_ESC '%' -#define SPECIALS "^$*+?.([%-" - -static int check_capture(MatchState *ms, int l) -{ - l -= '1'; - if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED) - lj_err_caller(ms->L, LJ_ERR_STRCAPI); - return l; -} - -static int capture_to_close(MatchState *ms) -{ - int level = ms->level; - for (level--; level>=0; level--) - if (ms->capture[level].len == CAP_UNFINISHED) return level; - lj_err_caller(ms->L, LJ_ERR_STRPATC); - return 0; /* unreachable */ -} - -static const char *classend(MatchState *ms, const char *p) -{ - switch (*p++) { - case L_ESC: - if (*p == '\0') - lj_err_caller(ms->L, LJ_ERR_STRPATE); - return p+1; - case '[': - if (*p == '^') p++; - do { /* look for a `]' */ - if (*p == '\0') - lj_err_caller(ms->L, LJ_ERR_STRPATM); - if (*(p++) == L_ESC && *p != '\0') - p++; /* skip escapes (e.g. `%]') */ - } while (*p != ']'); - return p+1; - default: - return p; - } -} - -static const unsigned char match_class_map[32] = { - 0,LJ_CHAR_ALPHA,0,LJ_CHAR_CNTRL,LJ_CHAR_DIGIT,0,0,LJ_CHAR_GRAPH,0,0,0,0, - LJ_CHAR_LOWER,0,0,0,LJ_CHAR_PUNCT,0,0,LJ_CHAR_SPACE,0, - LJ_CHAR_UPPER,0,LJ_CHAR_ALNUM,LJ_CHAR_XDIGIT,0,0,0,0,0,0,0 -}; - -static int match_class(int c, int cl) -{ - if ((cl & 0xc0) == 0x40) { - int t = match_class_map[(cl&0x1f)]; - if (t) { - t = lj_char_isa(c, t); - return (cl & 0x20) ? t : !t; - } - if (cl == 'z') return c == 0; - if (cl == 'Z') return c != 0; - } - return (cl == c); -} - -static int matchbracketclass(int c, const char *p, const char *ec) -{ - int sig = 1; - if (*(p+1) == '^') { - sig = 0; - p++; /* skip the `^' */ - } - while (++p < ec) { - if (*p == L_ESC) { - p++; - if (match_class(c, uchar(*p))) - return sig; - } - else if ((*(p+1) == '-') && (p+2 < ec)) { - p+=2; - if (uchar(*(p-2)) <= c && c <= uchar(*p)) - return sig; - } - else if (uchar(*p) == c) return sig; - } - return !sig; -} - -static int singlematch(int c, const char *p, const char *ep) -{ - switch (*p) { - case '.': return 1; /* matches any char */ - case L_ESC: return match_class(c, uchar(*(p+1))); - case '[': return matchbracketclass(c, p, ep-1); - default: return (uchar(*p) == c); - } -} - -static const char *match(MatchState *ms, const char *s, const char *p); - -static const char *matchbalance(MatchState *ms, const char *s, const char *p) -{ - if (*p == 0 || *(p+1) == 0) - lj_err_caller(ms->L, LJ_ERR_STRPATU); - if (*s != *p) { - return NULL; - } else { - int b = *p; - int e = *(p+1); - int cont = 1; - while (++s < ms->src_end) { - if (*s == e) { - if (--cont == 0) return s+1; - } else if (*s == b) { - cont++; - } - } - } - return NULL; /* string ends out of balance */ -} - -static const char *max_expand(MatchState *ms, const char *s, - const char *p, const char *ep) -{ - ptrdiff_t i = 0; /* counts maximum expand for item */ - while ((s+i)src_end && singlematch(uchar(*(s+i)), p, ep)) - i++; - /* keeps trying to match with the maximum repetitions */ - while (i>=0) { - const char *res = match(ms, (s+i), ep+1); - if (res) return res; - i--; /* else didn't match; reduce 1 repetition to try again */ - } - return NULL; -} - -static const char *min_expand(MatchState *ms, const char *s, - const char *p, const char *ep) -{ - for (;;) { - const char *res = match(ms, s, ep+1); - if (res != NULL) - return res; - else if (ssrc_end && singlematch(uchar(*s), p, ep)) - s++; /* try with one more repetition */ - else - return NULL; - } -} - -static const char *start_capture(MatchState *ms, const char *s, - const char *p, int what) -{ - const char *res; - int level = ms->level; - if (level >= LUA_MAXCAPTURES) lj_err_caller(ms->L, LJ_ERR_STRCAPN); - ms->capture[level].init = s; - ms->capture[level].len = what; - ms->level = level+1; - if ((res=match(ms, s, p)) == NULL) /* match failed? */ - ms->level--; /* undo capture */ - return res; -} - -static const char *end_capture(MatchState *ms, const char *s, - const char *p) -{ - int l = capture_to_close(ms); - const char *res; - ms->capture[l].len = s - ms->capture[l].init; /* close capture */ - if ((res = match(ms, s, p)) == NULL) /* match failed? */ - ms->capture[l].len = CAP_UNFINISHED; /* undo capture */ - return res; -} - -static const char *match_capture(MatchState *ms, const char *s, int l) -{ - size_t len; - l = check_capture(ms, l); - len = (size_t)ms->capture[l].len; - if ((size_t)(ms->src_end-s) >= len && - memcmp(ms->capture[l].init, s, len) == 0) - return s+len; - else - return NULL; -} - -static const char *match(MatchState *ms, const char *s, const char *p) -{ - if (++ms->depth > LJ_MAX_XLEVEL) - lj_err_caller(ms->L, LJ_ERR_STRPATX); - init: /* using goto's to optimize tail recursion */ - switch (*p) { - case '(': /* start capture */ - if (*(p+1) == ')') /* position capture? */ - s = start_capture(ms, s, p+2, CAP_POSITION); - else - s = start_capture(ms, s, p+1, CAP_UNFINISHED); - break; - case ')': /* end capture */ - s = end_capture(ms, s, p+1); - break; - case L_ESC: - switch (*(p+1)) { - case 'b': /* balanced string? */ - s = matchbalance(ms, s, p+2); - if (s == NULL) break; - p+=4; - goto init; /* else s = match(ms, s, p+4); */ - case 'f': { /* frontier? */ - const char *ep; char previous; - p += 2; - if (*p != '[') - lj_err_caller(ms->L, LJ_ERR_STRPATB); - ep = classend(ms, p); /* points to what is next */ - previous = (s == ms->src_init) ? '\0' : *(s-1); - if (matchbracketclass(uchar(previous), p, ep-1) || - !matchbracketclass(uchar(*s), p, ep-1)) { s = NULL; break; } - p=ep; - goto init; /* else s = match(ms, s, ep); */ - } - default: - if (lj_char_isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */ - s = match_capture(ms, s, uchar(*(p+1))); - if (s == NULL) break; - p+=2; - goto init; /* else s = match(ms, s, p+2) */ - } - goto dflt; /* case default */ - } - break; - case '\0': /* end of pattern */ - break; /* match succeeded */ - case '$': - /* is the `$' the last char in pattern? */ - if (*(p+1) != '\0') goto dflt; - if (s != ms->src_end) s = NULL; /* check end of string */ - break; - default: dflt: { /* it is a pattern item */ - const char *ep = classend(ms, p); /* points to what is next */ - int m = ssrc_end && singlematch(uchar(*s), p, ep); - switch (*ep) { - case '?': { /* optional */ - const char *res; - if (m && ((res=match(ms, s+1, ep+1)) != NULL)) { - s = res; - break; - } - p=ep+1; - goto init; /* else s = match(ms, s, ep+1); */ - } - case '*': /* 0 or more repetitions */ - s = max_expand(ms, s, p, ep); - break; - case '+': /* 1 or more repetitions */ - s = (m ? max_expand(ms, s+1, p, ep) : NULL); - break; - case '-': /* 0 or more repetitions (minimum) */ - s = min_expand(ms, s, p, ep); - break; - default: - if (m) { s++; p=ep; goto init; } /* else s = match(ms, s+1, ep); */ - s = NULL; - break; - } - break; - } - } - ms->depth--; - return s; -} - -static const char *lmemfind(const char *s1, size_t l1, - const char *s2, size_t l2) -{ - if (l2 == 0) { - return s1; /* empty strings are everywhere */ - } else if (l2 > l1) { - return NULL; /* avoids a negative `l1' */ - } else { - const char *init; /* to search for a `*s2' inside `s1' */ - l2--; /* 1st char will be checked by `memchr' */ - l1 = l1-l2; /* `s2' cannot be found after that */ - while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) { - init++; /* 1st char is already checked */ - if (memcmp(init, s2+1, l2) == 0) { - return init-1; - } else { /* correct `l1' and `s1' to try again */ - l1 -= (size_t)(init-s1); - s1 = init; - } - } - return NULL; /* not found */ - } -} - -static void push_onecapture(MatchState *ms, int i, const char *s, const char *e) -{ - if (i >= ms->level) { - if (i == 0) /* ms->level == 0, too */ - lua_pushlstring(ms->L, s, (size_t)(e - s)); /* add whole match */ - else - lj_err_caller(ms->L, LJ_ERR_STRCAPI); - } else { - ptrdiff_t l = ms->capture[i].len; - if (l == CAP_UNFINISHED) lj_err_caller(ms->L, LJ_ERR_STRCAPU); - if (l == CAP_POSITION) - lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); - else - lua_pushlstring(ms->L, ms->capture[i].init, (size_t)l); - } -} - -static int push_captures(MatchState *ms, const char *s, const char *e) -{ - int i; - int nlevels = (ms->level == 0 && s) ? 1 : ms->level; - luaL_checkstack(ms->L, nlevels, "too many captures"); - for (i = 0; i < nlevels; i++) - push_onecapture(ms, i, s, e); - return nlevels; /* number of strings pushed */ -} - -static ptrdiff_t posrelat(ptrdiff_t pos, size_t len) -{ - /* relative string position: negative means back from end */ - if (pos < 0) pos += (ptrdiff_t)len + 1; - return (pos >= 0) ? pos : 0; -} - -static int str_find_aux(lua_State *L, int find) -{ - size_t l1, l2; - const char *s = luaL_checklstring(L, 1, &l1); - const char *p = luaL_checklstring(L, 2, &l2); - ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1; - if (init < 0) { - init = 0; - } else if ((size_t)(init) > l1) { -#if LJ_52 - setnilV(L->top-1); - return 1; -#else - init = (ptrdiff_t)l1; -#endif - } - if (find && (lua_toboolean(L, 4) || /* explicit request? */ - strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */ - /* do a plain search */ - const char *s2 = lmemfind(s+init, l1-(size_t)init, p, l2); - if (s2) { - lua_pushinteger(L, s2-s+1); - lua_pushinteger(L, s2-s+(ptrdiff_t)l2); - return 2; - } - } else { - MatchState ms; - int anchor = (*p == '^') ? (p++, 1) : 0; - const char *s1=s+init; - ms.L = L; - ms.src_init = s; - ms.src_end = s+l1; - do { - const char *res; - ms.level = ms.depth = 0; - if ((res=match(&ms, s1, p)) != NULL) { - if (find) { - lua_pushinteger(L, s1-s+1); /* start */ - lua_pushinteger(L, res-s); /* end */ - return push_captures(&ms, NULL, 0) + 2; - } else { - return push_captures(&ms, s1, res); - } - } - } while (s1++ < ms.src_end && !anchor); - } - lua_pushnil(L); /* not found */ - return 1; -} - -LJLIB_CF(string_find) -{ - return str_find_aux(L, 1); -} - -LJLIB_CF(string_match) -{ - return str_find_aux(L, 0); -} - -LJLIB_NOREG LJLIB_CF(string_gmatch_aux) -{ - const char *p = strVdata(lj_lib_upvalue(L, 2)); - GCstr *str = strV(lj_lib_upvalue(L, 1)); - const char *s = strdata(str); - TValue *tvpos = lj_lib_upvalue(L, 3); - const char *src = s + tvpos->u32.lo; - MatchState ms; - ms.L = L; - ms.src_init = s; - ms.src_end = s + str->len; - for (; src <= ms.src_end; src++) { - const char *e; - ms.level = ms.depth = 0; - if ((e = match(&ms, src, p)) != NULL) { - int32_t pos = (int32_t)(e - s); - if (e == src) pos++; /* Ensure progress for empty match. */ - tvpos->u32.lo = (uint32_t)pos; - return push_captures(&ms, src, e); - } - } - return 0; /* not found */ -} - -LJLIB_CF(string_gmatch) -{ - lj_lib_checkstr(L, 1); - lj_lib_checkstr(L, 2); - L->top = L->base+3; - (L->top-1)->u64 = 0; - lj_lib_pushcc(L, lj_cf_string_gmatch_aux, FF_string_gmatch_aux, 3); - return 1; -} - -static void add_s(MatchState *ms, luaL_Buffer *b, const char *s, const char *e) -{ - size_t l, i; - const char *news = lua_tolstring(ms->L, 3, &l); - for (i = 0; i < l; i++) { - if (news[i] != L_ESC) { - luaL_addchar(b, news[i]); - } else { - i++; /* skip ESC */ - if (!lj_char_isdigit(uchar(news[i]))) { - luaL_addchar(b, news[i]); - } else if (news[i] == '0') { - luaL_addlstring(b, s, (size_t)(e - s)); - } else { - push_onecapture(ms, news[i] - '1', s, e); - luaL_addvalue(b); /* add capture to accumulated result */ - } - } - } -} - -static void add_value(MatchState *ms, luaL_Buffer *b, - const char *s, const char *e) -{ - lua_State *L = ms->L; - switch (lua_type(L, 3)) { - case LUA_TNUMBER: - case LUA_TSTRING: { - add_s(ms, b, s, e); - return; - } - case LUA_TFUNCTION: { - int n; - lua_pushvalue(L, 3); - n = push_captures(ms, s, e); - lua_call(L, n, 1); - break; - } - case LUA_TTABLE: { - push_onecapture(ms, 0, s, e); - lua_gettable(L, 3); - break; - } - } - if (!lua_toboolean(L, -1)) { /* nil or false? */ - lua_pop(L, 1); - lua_pushlstring(L, s, (size_t)(e - s)); /* keep original text */ - } else if (!lua_isstring(L, -1)) { - lj_err_callerv(L, LJ_ERR_STRGSRV, luaL_typename(L, -1)); - } - luaL_addvalue(b); /* add result to accumulator */ -} - -LJLIB_CF(string_gsub) -{ - size_t srcl; - const char *src = luaL_checklstring(L, 1, &srcl); - const char *p = luaL_checkstring(L, 2); - int tr = lua_type(L, 3); - int max_s = luaL_optint(L, 4, (int)(srcl+1)); - int anchor = (*p == '^') ? (p++, 1) : 0; - int n = 0; - MatchState ms; - luaL_Buffer b; - if (!(tr == LUA_TNUMBER || tr == LUA_TSTRING || - tr == LUA_TFUNCTION || tr == LUA_TTABLE)) - lj_err_arg(L, 3, LJ_ERR_NOSFT); - luaL_buffinit(L, &b); - ms.L = L; - ms.src_init = src; - ms.src_end = src+srcl; - while (n < max_s) { - const char *e; - ms.level = ms.depth = 0; - e = match(&ms, src, p); - if (e) { - n++; - add_value(&ms, &b, src, e); - } - if (e && e>src) /* non empty match? */ - src = e; /* skip it */ - else if (src < ms.src_end) - luaL_addchar(&b, *src++); - else - break; - if (anchor) - break; - } - luaL_addlstring(&b, src, (size_t)(ms.src_end-src)); - luaL_pushresult(&b); - lua_pushinteger(L, n); /* number of substitutions */ - return 2; -} - -/* ------------------------------------------------------------------------ */ - -/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */ -#define MAX_FMTITEM 512 -/* valid flags in a format specification */ -#define FMT_FLAGS "-+ #0" -/* -** maximum size of each format specification (such as '%-099.99d') -** (+10 accounts for %99.99x plus margin of error) -*/ -#define MAX_FMTSPEC (sizeof(FMT_FLAGS) + sizeof(LUA_INTFRMLEN) + 10) - -static void addquoted(lua_State *L, luaL_Buffer *b, int arg) -{ - GCstr *str = lj_lib_checkstr(L, arg); - int32_t len = (int32_t)str->len; - const char *s = strdata(str); - luaL_addchar(b, '"'); - while (len--) { - uint32_t c = uchar(*s); - if (c == '"' || c == '\\' || c == '\n') { - luaL_addchar(b, '\\'); - } else if (lj_char_iscntrl(c)) { /* This can only be 0-31 or 127. */ - uint32_t d; - luaL_addchar(b, '\\'); - if (c >= 100 || lj_char_isdigit(uchar(s[1]))) { - luaL_addchar(b, '0'+(c >= 100)); if (c >= 100) c -= 100; - goto tens; - } else if (c >= 10) { - tens: - d = (c * 205) >> 11; c -= d * 10; luaL_addchar(b, '0'+d); - } - c += '0'; - } - luaL_addchar(b, c); - s++; - } - luaL_addchar(b, '"'); -} - -static const char *scanformat(lua_State *L, const char *strfrmt, char *form) -{ - const char *p = strfrmt; - while (*p != '\0' && strchr(FMT_FLAGS, *p) != NULL) p++; /* skip flags */ - if ((size_t)(p - strfrmt) >= sizeof(FMT_FLAGS)) - lj_err_caller(L, LJ_ERR_STRFMTR); - if (lj_char_isdigit(uchar(*p))) p++; /* skip width */ - if (lj_char_isdigit(uchar(*p))) p++; /* (2 digits at most) */ - if (*p == '.') { - p++; - if (lj_char_isdigit(uchar(*p))) p++; /* skip precision */ - if (lj_char_isdigit(uchar(*p))) p++; /* (2 digits at most) */ - } - if (lj_char_isdigit(uchar(*p))) - lj_err_caller(L, LJ_ERR_STRFMTW); - *(form++) = '%'; - strncpy(form, strfrmt, (size_t)(p - strfrmt + 1)); - form += p - strfrmt + 1; - *form = '\0'; - return p; -} - -static void addintlen(char *form) -{ - size_t l = strlen(form); - char spec = form[l - 1]; - strcpy(form + l - 1, LUA_INTFRMLEN); - form[l + sizeof(LUA_INTFRMLEN) - 2] = spec; - form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0'; -} - -static unsigned LUA_INTFRM_T num2intfrm(lua_State *L, int arg) -{ - if (sizeof(LUA_INTFRM_T) == 4) { - return (LUA_INTFRM_T)lj_lib_checkbit(L, arg); - } else { - cTValue *o; - lj_lib_checknumber(L, arg); - o = L->base+arg-1; - if (tvisint(o)) - return (LUA_INTFRM_T)intV(o); - else - return (LUA_INTFRM_T)numV(o); - } -} - -static unsigned LUA_INTFRM_T num2uintfrm(lua_State *L, int arg) -{ - if (sizeof(LUA_INTFRM_T) == 4) { - return (unsigned LUA_INTFRM_T)lj_lib_checkbit(L, arg); - } else { - cTValue *o; - lj_lib_checknumber(L, arg); - o = L->base+arg-1; - if (tvisint(o)) - return (unsigned LUA_INTFRM_T)intV(o); - else if ((int32_t)o->u32.hi < 0) - return (unsigned LUA_INTFRM_T)(LUA_INTFRM_T)numV(o); - else - return (unsigned LUA_INTFRM_T)numV(o); - } -} - -static GCstr *meta_tostring(lua_State *L, int arg) -{ - TValue *o = L->base+arg-1; - cTValue *mo; - lua_assert(o < L->top); /* Caller already checks for existence. */ - if (LJ_LIKELY(tvisstr(o))) - return strV(o); - if (!tvisnil(mo = lj_meta_lookup(L, o, MM_tostring))) { - copyTV(L, L->top++, mo); - copyTV(L, L->top++, o); - lua_call(L, 1, 1); - L->top--; - if (tvisstr(L->top)) - return strV(L->top); - o = L->base+arg-1; - copyTV(L, o, L->top); - } - if (tvisnumber(o)) { - return lj_str_fromnumber(L, o); - } else if (tvisnil(o)) { - return lj_str_newlit(L, "nil"); - } else if (tvisfalse(o)) { - return lj_str_newlit(L, "false"); - } else if (tvistrue(o)) { - return lj_str_newlit(L, "true"); - } else { - if (tvisfunc(o) && isffunc(funcV(o))) - lj_str_pushf(L, "function: builtin#%d", funcV(o)->c.ffid); - else - lj_str_pushf(L, "%s: %p", lj_typename(o), lua_topointer(L, arg)); - L->top--; - return strV(L->top); - } -} - -LJLIB_CF(string_format) -{ - int arg = 1, top = (int)(L->top - L->base); - GCstr *fmt = lj_lib_checkstr(L, arg); - const char *strfrmt = strdata(fmt); - const char *strfrmt_end = strfrmt + fmt->len; - luaL_Buffer b; - luaL_buffinit(L, &b); - while (strfrmt < strfrmt_end) { - if (*strfrmt != L_ESC) { - luaL_addchar(&b, *strfrmt++); - } else if (*++strfrmt == L_ESC) { - luaL_addchar(&b, *strfrmt++); /* %% */ - } else { /* format item */ - char form[MAX_FMTSPEC]; /* to store the format (`%...') */ - char buff[MAX_FMTITEM]; /* to store the formatted item */ - if (++arg > top) - luaL_argerror(L, arg, lj_obj_typename[0]); - strfrmt = scanformat(L, strfrmt, form); - switch (*strfrmt++) { - case 'c': - sprintf(buff, form, lj_lib_checkint(L, arg)); - break; - case 'd': case 'i': - addintlen(form); - sprintf(buff, form, num2intfrm(L, arg)); - break; - case 'o': case 'u': case 'x': case 'X': - addintlen(form); - sprintf(buff, form, num2uintfrm(L, arg)); - break; - case 'e': case 'E': case 'f': case 'g': case 'G': case 'a': case 'A': { - TValue tv; - tv.n = lj_lib_checknum(L, arg); - if (LJ_UNLIKELY((tv.u32.hi << 1) >= 0xffe00000)) { - /* Canonicalize output of non-finite values. */ - char *p, nbuf[LJ_STR_NUMBUF]; - size_t len = lj_str_bufnum(nbuf, &tv); - if (strfrmt[-1] < 'a') { - nbuf[len-3] = nbuf[len-3] - 0x20; - nbuf[len-2] = nbuf[len-2] - 0x20; - nbuf[len-1] = nbuf[len-1] - 0x20; - } - nbuf[len] = '\0'; - for (p = form; *p < 'A' && *p != '.'; p++) ; - *p++ = 's'; *p = '\0'; - sprintf(buff, form, nbuf); - break; - } - sprintf(buff, form, (double)tv.n); - break; - } - case 'q': - addquoted(L, &b, arg); - continue; - case 'p': - lj_str_pushf(L, "%p", lua_topointer(L, arg)); - luaL_addvalue(&b); - continue; - case 's': { - GCstr *str = meta_tostring(L, arg); - if (!strchr(form, '.') && str->len >= 100) { - /* no precision and string is too long to be formatted; - keep original string */ - setstrV(L, L->top++, str); - luaL_addvalue(&b); - continue; - } - sprintf(buff, form, strdata(str)); - break; - } - default: - lj_err_callerv(L, LJ_ERR_STRFMTO, *(strfrmt -1)); - break; - } - luaL_addlstring(&b, buff, strlen(buff)); - } - } - luaL_pushresult(&b); - return 1; -} - -/* ------------------------------------------------------------------------ */ - -#include "lj_libdef.h" - -LUALIB_API int luaopen_string(lua_State *L) -{ - GCtab *mt; - global_State *g; - LJ_LIB_REG(L, LUA_STRLIBNAME, string); -#if defined(LUA_COMPAT_GFIND) && !LJ_52 - lua_getfield(L, -1, "gmatch"); - lua_setfield(L, -2, "gfind"); -#endif - mt = lj_tab_new(L, 0, 1); - /* NOBARRIER: basemt is a GC root. */ - g = G(L); - setgcref(basemt_it(g, LJ_TSTR), obj2gco(mt)); - settabV(L, lj_tab_setstr(L, mt, mmname_str(g, MM_index)), tabV(L->top-1)); - mt->nomm = (uint8_t)(~(1u<top, func); - setintV(L->top+1, i); - val = lj_tab_getint(t, (int32_t)i); - if (val) { copyTV(L, L->top+2, val); } else { setnilV(L->top+2); } - L->top += 3; - lua_call(L, 2, 1); - if (!tvisnil(L->top-1)) - return 1; - L->top--; - } - return 0; -} - -LJLIB_CF(table_foreach) -{ - GCtab *t = lj_lib_checktab(L, 1); - GCfunc *func = lj_lib_checkfunc(L, 2); - L->top = L->base+3; - setnilV(L->top-1); - while (lj_tab_next(L, t, L->top-1)) { - copyTV(L, L->top+2, L->top); - copyTV(L, L->top+1, L->top-1); - setfuncV(L, L->top, func); - L->top += 3; - lua_call(L, 2, 1); - if (!tvisnil(L->top-1)) - return 1; - L->top--; - } - return 0; -} - -LJLIB_ASM(table_getn) LJLIB_REC(.) -{ - lj_lib_checktab(L, 1); - return FFH_UNREACHABLE; -} - -LJLIB_CF(table_maxn) -{ - GCtab *t = lj_lib_checktab(L, 1); - TValue *array = tvref(t->array); - Node *node; - lua_Number m = 0; - ptrdiff_t i; - for (i = (ptrdiff_t)t->asize - 1; i >= 0; i--) - if (!tvisnil(&array[i])) { - m = (lua_Number)(int32_t)i; - break; - } - node = noderef(t->node); - for (i = (ptrdiff_t)t->hmask; i >= 0; i--) - if (!tvisnil(&node[i].val) && tvisnumber(&node[i].key)) { - lua_Number n = numberVnum(&node[i].key); - if (n > m) m = n; - } - setnumV(L->top-1, m); - return 1; -} - -LJLIB_CF(table_insert) LJLIB_REC(.) -{ - GCtab *t = lj_lib_checktab(L, 1); - int32_t n, i = (int32_t)lj_tab_len(t) + 1; - int nargs = (int)((char *)L->top - (char *)L->base); - if (nargs != 2*sizeof(TValue)) { - if (nargs != 3*sizeof(TValue)) - lj_err_caller(L, LJ_ERR_TABINS); - /* NOBARRIER: This just moves existing elements around. */ - for (n = lj_lib_checkint(L, 2); i > n; i--) { - /* The set may invalidate the get pointer, so need to do it first! */ - TValue *dst = lj_tab_setint(L, t, i); - cTValue *src = lj_tab_getint(t, i-1); - if (src) { - copyTV(L, dst, src); - } else { - setnilV(dst); - } - } - i = n; - } - { - TValue *dst = lj_tab_setint(L, t, i); - copyTV(L, dst, L->top-1); /* Set new value. */ - lj_gc_barriert(L, t, dst); - } - return 0; -} - -LJLIB_CF(table_remove) LJLIB_REC(.) -{ - GCtab *t = lj_lib_checktab(L, 1); - int32_t e = (int32_t)lj_tab_len(t); - int32_t pos = lj_lib_optint(L, 2, e); - if (!(1 <= pos && pos <= e)) /* Nothing to remove? */ - return 0; - lua_rawgeti(L, 1, pos); /* Get previous value. */ - /* NOBARRIER: This just moves existing elements around. */ - for (; pos < e; pos++) { - cTValue *src = lj_tab_getint(t, pos+1); - TValue *dst = lj_tab_setint(L, t, pos); - if (src) { - copyTV(L, dst, src); - } else { - setnilV(dst); - } - } - setnilV(lj_tab_setint(L, t, e)); /* Remove (last) value. */ - return 1; /* Return previous value. */ -} - -LJLIB_CF(table_concat) -{ - luaL_Buffer b; - GCtab *t = lj_lib_checktab(L, 1); - GCstr *sep = lj_lib_optstr(L, 2); - MSize seplen = sep ? sep->len : 0; - int32_t i = lj_lib_optint(L, 3, 1); - int32_t e = (L->base+3 < L->top && !tvisnil(L->base+3)) ? - lj_lib_checkint(L, 4) : (int32_t)lj_tab_len(t); - luaL_buffinit(L, &b); - if (i <= e) { - for (;;) { - cTValue *o; - lua_rawgeti(L, 1, i); - o = L->top-1; - if (!(tvisstr(o) || tvisnumber(o))) - lj_err_callerv(L, LJ_ERR_TABCAT, lj_typename(o), i); - luaL_addvalue(&b); - if (i++ == e) break; - if (seplen) - luaL_addlstring(&b, strdata(sep), seplen); - } - } - luaL_pushresult(&b); - return 1; -} - -/* ------------------------------------------------------------------------ */ - -static void set2(lua_State *L, int i, int j) -{ - lua_rawseti(L, 1, i); - lua_rawseti(L, 1, j); -} - -static int sort_comp(lua_State *L, int a, int b) -{ - if (!lua_isnil(L, 2)) { /* function? */ - int res; - lua_pushvalue(L, 2); - lua_pushvalue(L, a-1); /* -1 to compensate function */ - lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */ - lua_call(L, 2, 1); - res = lua_toboolean(L, -1); - lua_pop(L, 1); - return res; - } else { /* a < b? */ - return lua_lessthan(L, a, b); - } -} - -static void auxsort(lua_State *L, int l, int u) -{ - while (l < u) { /* for tail recursion */ - int i, j; - /* sort elements a[l], a[(l+u)/2] and a[u] */ - lua_rawgeti(L, 1, l); - lua_rawgeti(L, 1, u); - if (sort_comp(L, -1, -2)) /* a[u] < a[l]? */ - set2(L, l, u); /* swap a[l] - a[u] */ - else - lua_pop(L, 2); - if (u-l == 1) break; /* only 2 elements */ - i = (l+u)/2; - lua_rawgeti(L, 1, i); - lua_rawgeti(L, 1, l); - if (sort_comp(L, -2, -1)) { /* a[i]= P */ - while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { - if (i>=u) lj_err_caller(L, LJ_ERR_TABSORT); - lua_pop(L, 1); /* remove a[i] */ - } - /* repeat --j until a[j] <= P */ - while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { - if (j<=l) lj_err_caller(L, LJ_ERR_TABSORT); - lua_pop(L, 1); /* remove a[j] */ - } - if (jbase+1)) - lj_lib_checkfunc(L, 2); - auxsort(L, 1, n); - return 0; -} - -#if LJ_52 -LJLIB_PUSH("n") -LJLIB_CF(table_pack) -{ - TValue *array, *base = L->base; - MSize i, n = (uint32_t)(L->top - base); - GCtab *t = lj_tab_new(L, n ? n+1 : 0, 1); - /* NOBARRIER: The table is new (marked white). */ - setintV(lj_tab_setstr(L, t, strV(lj_lib_upvalue(L, 1))), (int32_t)n); - for (array = tvref(t->array) + 1, i = 0; i < n; i++) - copyTV(L, &array[i], &base[i]); - settabV(L, base, t); - L->top = base+1; - lj_gc_check(L); - return 1; -} -#endif - -/* ------------------------------------------------------------------------ */ - -#include "lj_libdef.h" - -LUALIB_API int luaopen_table(lua_State *L) -{ - LJ_LIB_REG(L, LUA_TABLIBNAME, table); -#if LJ_52 - lua_getglobal(L, "unpack"); - lua_setfield(L, -2, "unpack"); -#endif - return 1; -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_alloc.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_alloc.c deleted file mode 100644 index f856a7a01..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_alloc.c +++ /dev/null @@ -1,1390 +0,0 @@ -/* -** Bundled memory allocator. -** -** Beware: this is a HEAVILY CUSTOMIZED version of dlmalloc. -** The original bears the following remark: -** -** This is a version (aka dlmalloc) of malloc/free/realloc written by -** Doug Lea and released to the public domain, as explained at -** http://creativecommons.org/licenses/publicdomain. -** -** * Version pre-2.8.4 Wed Mar 29 19:46:29 2006 (dl at gee) -** -** No additional copyright is claimed over the customizations. -** Please do NOT bother the original author about this version here! -** -** If you want to use dlmalloc in another project, you should get -** the original from: ftp://gee.cs.oswego.edu/pub/misc/ -** For thread-safe derivatives, take a look at: -** - ptmalloc: http://www.malloc.de/ -** - nedmalloc: http://www.nedprod.com/programs/portable/nedmalloc/ -*/ - -#define lj_alloc_c -#define LUA_CORE - -/* To get the mremap prototype. Must be defined before any system includes. */ -#if defined(__linux__) && !defined(_GNU_SOURCE) -#define _GNU_SOURCE -#endif - -#include "lj_def.h" -#include "lj_arch.h" -#include "lj_alloc.h" - -#ifndef LUAJIT_USE_SYSMALLOC - -#define MAX_SIZE_T (~(size_t)0) -#define MALLOC_ALIGNMENT ((size_t)8U) - -#define DEFAULT_GRANULARITY ((size_t)128U * (size_t)1024U) -#define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U) -#define DEFAULT_MMAP_THRESHOLD ((size_t)128U * (size_t)1024U) -#define MAX_RELEASE_CHECK_RATE 255 - -/* ------------------- size_t and alignment properties -------------------- */ - -/* The byte and bit size of a size_t */ -#define SIZE_T_SIZE (sizeof(size_t)) -#define SIZE_T_BITSIZE (sizeof(size_t) << 3) - -/* Some constants coerced to size_t */ -/* Annoying but necessary to avoid errors on some platforms */ -#define SIZE_T_ZERO ((size_t)0) -#define SIZE_T_ONE ((size_t)1) -#define SIZE_T_TWO ((size_t)2) -#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1) -#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2) -#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES) - -/* The bit mask value corresponding to MALLOC_ALIGNMENT */ -#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) - -/* the number of bytes to offset an address to align it */ -#define align_offset(A)\ - ((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\ - ((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK)) - -/* -------------------------- MMAP support ------------------------------- */ - -#define MFAIL ((void *)(MAX_SIZE_T)) -#define CMFAIL ((char *)(MFAIL)) /* defined for convenience */ - -#define IS_DIRECT_BIT (SIZE_T_ONE) - -#if LJ_TARGET_WINDOWS - -#define WIN32_LEAN_AND_MEAN -#include - -#if LJ_64 - -/* Undocumented, but hey, that's what we all love so much about Windows. */ -typedef long (*PNTAVM)(HANDLE handle, void **addr, ULONG zbits, - size_t *size, ULONG alloctype, ULONG prot); -static PNTAVM ntavm; - -/* Number of top bits of the lower 32 bits of an address that must be zero. -** Apparently 0 gives us full 64 bit addresses and 1 gives us the lower 2GB. -*/ -#define NTAVM_ZEROBITS 1 - -static void INIT_MMAP(void) -{ - ntavm = (PNTAVM)GetProcAddress(GetModuleHandleA("ntdll.dll"), - "NtAllocateVirtualMemory"); -} - -/* Win64 32 bit MMAP via NtAllocateVirtualMemory. */ -static LJ_AINLINE void *CALL_MMAP(size_t size) -{ - DWORD olderr = GetLastError(); - void *ptr = NULL; - long st = ntavm(INVALID_HANDLE_VALUE, &ptr, NTAVM_ZEROBITS, &size, - MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); - SetLastError(olderr); - return st == 0 ? ptr : MFAIL; -} - -/* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ -static LJ_AINLINE void *DIRECT_MMAP(size_t size) -{ - DWORD olderr = GetLastError(); - void *ptr = NULL; - long st = ntavm(INVALID_HANDLE_VALUE, &ptr, NTAVM_ZEROBITS, &size, - MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, PAGE_READWRITE); - SetLastError(olderr); - return st == 0 ? ptr : MFAIL; -} - -#else - -#define INIT_MMAP() ((void)0) - -/* Win32 MMAP via VirtualAlloc */ -static LJ_AINLINE void *CALL_MMAP(size_t size) -{ - DWORD olderr = GetLastError(); - void *ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); - SetLastError(olderr); - return ptr ? ptr : MFAIL; -} - -/* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ -static LJ_AINLINE void *DIRECT_MMAP(size_t size) -{ - DWORD olderr = GetLastError(); - void *ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, - PAGE_READWRITE); - SetLastError(olderr); - return ptr ? ptr : MFAIL; -} - -#endif - -/* This function supports releasing coalesed segments */ -static LJ_AINLINE int CALL_MUNMAP(void *ptr, size_t size) -{ - DWORD olderr = GetLastError(); - MEMORY_BASIC_INFORMATION minfo; - char *cptr = (char *)ptr; - while (size) { - if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) - return -1; - if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr || - minfo.State != MEM_COMMIT || minfo.RegionSize > size) - return -1; - if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) - return -1; - cptr += minfo.RegionSize; - size -= minfo.RegionSize; - } - SetLastError(olderr); - return 0; -} - -#else - -#include -#include - -#define MMAP_PROT (PROT_READ|PROT_WRITE) -#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) -#define MAP_ANONYMOUS MAP_ANON -#endif -#define MMAP_FLAGS (MAP_PRIVATE|MAP_ANONYMOUS) - -#if LJ_64 -/* 64 bit mode needs special support for allocating memory in the lower 2GB. */ - -#if defined(MAP_32BIT) - -/* Actually this only gives us max. 1GB in current Linux kernels. */ -static LJ_AINLINE void *CALL_MMAP(size_t size) -{ - int olderr = errno; - void *ptr = mmap(NULL, size, MMAP_PROT, MAP_32BIT|MMAP_FLAGS, -1, 0); - errno = olderr; - return ptr; -} - -#elif LJ_TARGET_OSX || LJ_TARGET_PS4 || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__sun__) - -/* OSX and FreeBSD mmap() use a naive first-fit linear search. -** That's perfect for us. Except that -pagezero_size must be set for OSX, -** otherwise the lower 4GB are blocked. And the 32GB RLIMIT_DATA needs -** to be reduced to 250MB on FreeBSD. -*/ -#if LJ_TARGET_OSX -#define MMAP_REGION_START ((uintptr_t)0x10000) -#elif LJ_TARGET_PS4 -#define MMAP_REGION_START ((uintptr_t)0x4000) -#else -#define MMAP_REGION_START ((uintptr_t)0x10000000) -#endif -#define MMAP_REGION_END ((uintptr_t)0x80000000) - -#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && !LJ_TARGET_PS4 -#include -#endif - -static LJ_AINLINE void *CALL_MMAP(size_t size) -{ - int olderr = errno; - /* Hint for next allocation. Doesn't need to be thread-safe. */ - static uintptr_t alloc_hint = MMAP_REGION_START; - int retry = 0; -#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && !LJ_TARGET_PS4 - static int rlimit_modified = 0; - if (LJ_UNLIKELY(rlimit_modified == 0)) { - struct rlimit rlim; - rlim.rlim_cur = rlim.rlim_max = MMAP_REGION_START; - setrlimit(RLIMIT_DATA, &rlim); /* Ignore result. May fail below. */ - rlimit_modified = 1; - } -#endif - for (;;) { - void *p = mmap((void *)alloc_hint, size, MMAP_PROT, MMAP_FLAGS, -1, 0); - if ((uintptr_t)p >= MMAP_REGION_START && - (uintptr_t)p + size < MMAP_REGION_END) { - alloc_hint = (uintptr_t)p + size; - errno = olderr; - return p; - } - if (p != CMFAIL) munmap(p, size); -#ifdef __sun__ - alloc_hint += 0x1000000; /* Need near-exhaustive linear scan. */ - if (alloc_hint + size < MMAP_REGION_END) continue; -#endif - if (retry) break; - retry = 1; - alloc_hint = MMAP_REGION_START; - } - errno = olderr; - return CMFAIL; -} - -#else - -#error "NYI: need an equivalent of MAP_32BIT for this 64 bit OS" - -#endif - -#else - -/* 32 bit mode is easy. */ -static LJ_AINLINE void *CALL_MMAP(size_t size) -{ - int olderr = errno; - void *ptr = mmap(NULL, size, MMAP_PROT, MMAP_FLAGS, -1, 0); - errno = olderr; - return ptr; -} - -#endif - -#define INIT_MMAP() ((void)0) -#define DIRECT_MMAP(s) CALL_MMAP(s) - -static LJ_AINLINE int CALL_MUNMAP(void *ptr, size_t size) -{ - int olderr = errno; - int ret = munmap(ptr, size); - errno = olderr; - return ret; -} - -#if LJ_TARGET_LINUX -/* Need to define _GNU_SOURCE to get the mremap prototype. */ -static LJ_AINLINE void *CALL_MREMAP_(void *ptr, size_t osz, size_t nsz, - int flags) -{ - int olderr = errno; - ptr = mremap(ptr, osz, nsz, flags); - errno = olderr; - return ptr; -} - -#define CALL_MREMAP(addr, osz, nsz, mv) CALL_MREMAP_((addr), (osz), (nsz), (mv)) -#define CALL_MREMAP_NOMOVE 0 -#define CALL_MREMAP_MAYMOVE 1 -#if LJ_64 -#define CALL_MREMAP_MV CALL_MREMAP_NOMOVE -#else -#define CALL_MREMAP_MV CALL_MREMAP_MAYMOVE -#endif -#endif - -#endif - -#ifndef CALL_MREMAP -#define CALL_MREMAP(addr, osz, nsz, mv) ((void)osz, MFAIL) -#endif - -/* ----------------------- Chunk representations ------------------------ */ - -struct malloc_chunk { - size_t prev_foot; /* Size of previous chunk (if free). */ - size_t head; /* Size and inuse bits. */ - struct malloc_chunk *fd; /* double links -- used only if free. */ - struct malloc_chunk *bk; -}; - -typedef struct malloc_chunk mchunk; -typedef struct malloc_chunk *mchunkptr; -typedef struct malloc_chunk *sbinptr; /* The type of bins of chunks */ -typedef size_t bindex_t; /* Described below */ -typedef unsigned int binmap_t; /* Described below */ -typedef unsigned int flag_t; /* The type of various bit flag sets */ - -/* ------------------- Chunks sizes and alignments ----------------------- */ - -#define MCHUNK_SIZE (sizeof(mchunk)) - -#define CHUNK_OVERHEAD (SIZE_T_SIZE) - -/* Direct chunks need a second word of overhead ... */ -#define DIRECT_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) -/* ... and additional padding for fake next-chunk at foot */ -#define DIRECT_FOOT_PAD (FOUR_SIZE_T_SIZES) - -/* The smallest size we can malloc is an aligned minimal chunk */ -#define MIN_CHUNK_SIZE\ - ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) - -/* conversion from malloc headers to user pointers, and back */ -#define chunk2mem(p) ((void *)((char *)(p) + TWO_SIZE_T_SIZES)) -#define mem2chunk(mem) ((mchunkptr)((char *)(mem) - TWO_SIZE_T_SIZES)) -/* chunk associated with aligned address A */ -#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) - -/* Bounds on request (not chunk) sizes. */ -#define MAX_REQUEST ((~MIN_CHUNK_SIZE+1) << 2) -#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) - -/* pad request bytes into a usable size */ -#define pad_request(req) \ - (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) - -/* pad request, checking for minimum (but not maximum) */ -#define request2size(req) \ - (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req)) - -/* ------------------ Operations on head and foot fields ----------------- */ - -#define PINUSE_BIT (SIZE_T_ONE) -#define CINUSE_BIT (SIZE_T_TWO) -#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT) - -/* Head value for fenceposts */ -#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE) - -/* extraction of fields from head words */ -#define cinuse(p) ((p)->head & CINUSE_BIT) -#define pinuse(p) ((p)->head & PINUSE_BIT) -#define chunksize(p) ((p)->head & ~(INUSE_BITS)) - -#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) -#define clear_cinuse(p) ((p)->head &= ~CINUSE_BIT) - -/* Treat space at ptr +/- offset as a chunk */ -#define chunk_plus_offset(p, s) ((mchunkptr)(((char *)(p)) + (s))) -#define chunk_minus_offset(p, s) ((mchunkptr)(((char *)(p)) - (s))) - -/* Ptr to next or previous physical malloc_chunk. */ -#define next_chunk(p) ((mchunkptr)(((char *)(p)) + ((p)->head & ~INUSE_BITS))) -#define prev_chunk(p) ((mchunkptr)(((char *)(p)) - ((p)->prev_foot) )) - -/* extract next chunk's pinuse bit */ -#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) - -/* Get/set size at footer */ -#define get_foot(p, s) (((mchunkptr)((char *)(p) + (s)))->prev_foot) -#define set_foot(p, s) (((mchunkptr)((char *)(p) + (s)))->prev_foot = (s)) - -/* Set size, pinuse bit, and foot */ -#define set_size_and_pinuse_of_free_chunk(p, s)\ - ((p)->head = (s|PINUSE_BIT), set_foot(p, s)) - -/* Set size, pinuse bit, foot, and clear next pinuse */ -#define set_free_with_pinuse(p, s, n)\ - (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) - -#define is_direct(p)\ - (!((p)->head & PINUSE_BIT) && ((p)->prev_foot & IS_DIRECT_BIT)) - -/* Get the internal overhead associated with chunk p */ -#define overhead_for(p)\ - (is_direct(p)? DIRECT_CHUNK_OVERHEAD : CHUNK_OVERHEAD) - -/* ---------------------- Overlaid data structures ----------------------- */ - -struct malloc_tree_chunk { - /* The first four fields must be compatible with malloc_chunk */ - size_t prev_foot; - size_t head; - struct malloc_tree_chunk *fd; - struct malloc_tree_chunk *bk; - - struct malloc_tree_chunk *child[2]; - struct malloc_tree_chunk *parent; - bindex_t index; -}; - -typedef struct malloc_tree_chunk tchunk; -typedef struct malloc_tree_chunk *tchunkptr; -typedef struct malloc_tree_chunk *tbinptr; /* The type of bins of trees */ - -/* A little helper macro for trees */ -#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) - -/* ----------------------------- Segments -------------------------------- */ - -struct malloc_segment { - char *base; /* base address */ - size_t size; /* allocated size */ - struct malloc_segment *next; /* ptr to next segment */ -}; - -typedef struct malloc_segment msegment; -typedef struct malloc_segment *msegmentptr; - -/* ---------------------------- malloc_state ----------------------------- */ - -/* Bin types, widths and sizes */ -#define NSMALLBINS (32U) -#define NTREEBINS (32U) -#define SMALLBIN_SHIFT (3U) -#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) -#define TREEBIN_SHIFT (8U) -#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) -#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) -#define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) - -struct malloc_state { - binmap_t smallmap; - binmap_t treemap; - size_t dvsize; - size_t topsize; - mchunkptr dv; - mchunkptr top; - size_t trim_check; - size_t release_checks; - mchunkptr smallbins[(NSMALLBINS+1)*2]; - tbinptr treebins[NTREEBINS]; - msegment seg; -}; - -typedef struct malloc_state *mstate; - -#define is_initialized(M) ((M)->top != 0) - -/* -------------------------- system alloc setup ------------------------- */ - -/* page-align a size */ -#define page_align(S)\ - (((S) + (LJ_PAGESIZE - SIZE_T_ONE)) & ~(LJ_PAGESIZE - SIZE_T_ONE)) - -/* granularity-align a size */ -#define granularity_align(S)\ - (((S) + (DEFAULT_GRANULARITY - SIZE_T_ONE))\ - & ~(DEFAULT_GRANULARITY - SIZE_T_ONE)) - -#if LJ_TARGET_WINDOWS -#define mmap_align(S) granularity_align(S) -#else -#define mmap_align(S) page_align(S) -#endif - -/* True if segment S holds address A */ -#define segment_holds(S, A)\ - ((char *)(A) >= S->base && (char *)(A) < S->base + S->size) - -/* Return segment holding given address */ -static msegmentptr segment_holding(mstate m, char *addr) -{ - msegmentptr sp = &m->seg; - for (;;) { - if (addr >= sp->base && addr < sp->base + sp->size) - return sp; - if ((sp = sp->next) == 0) - return 0; - } -} - -/* Return true if segment contains a segment link */ -static int has_segment_link(mstate m, msegmentptr ss) -{ - msegmentptr sp = &m->seg; - for (;;) { - if ((char *)sp >= ss->base && (char *)sp < ss->base + ss->size) - return 1; - if ((sp = sp->next) == 0) - return 0; - } -} - -/* - TOP_FOOT_SIZE is padding at the end of a segment, including space - that may be needed to place segment records and fenceposts when new - noncontiguous segments are added. -*/ -#define TOP_FOOT_SIZE\ - (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE) - -/* ---------------------------- Indexing Bins ---------------------------- */ - -#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) -#define small_index(s) ((s) >> SMALLBIN_SHIFT) -#define small_index2size(i) ((i) << SMALLBIN_SHIFT) -#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) - -/* addressing by index. See above about smallbin repositioning */ -#define smallbin_at(M, i) ((sbinptr)((char *)&((M)->smallbins[(i)<<1]))) -#define treebin_at(M,i) (&((M)->treebins[i])) - -/* assign tree index for size S to variable I */ -#define compute_tree_index(S, I)\ -{\ - unsigned int X = (unsigned int)(S >> TREEBIN_SHIFT);\ - if (X == 0) {\ - I = 0;\ - } else if (X > 0xFFFF) {\ - I = NTREEBINS-1;\ - } else {\ - unsigned int K = lj_fls(X);\ - I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ - }\ -} - -/* Bit representing maximum resolved size in a treebin at i */ -#define bit_for_tree_index(i) \ - (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2) - -/* Shift placing maximum resolved bit in a treebin at i as sign bit */ -#define leftshift_for_tree_index(i) \ - ((i == NTREEBINS-1)? 0 : \ - ((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) - -/* The size of the smallest chunk held in bin with index i */ -#define minsize_for_tree_index(i) \ - ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ - (((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) - -/* ------------------------ Operations on bin maps ----------------------- */ - -/* bit corresponding to given index */ -#define idx2bit(i) ((binmap_t)(1) << (i)) - -/* Mark/Clear bits with given index */ -#define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i)) -#define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i)) -#define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i)) - -#define mark_treemap(M,i) ((M)->treemap |= idx2bit(i)) -#define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i)) -#define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i)) - -/* mask with all bits to left of least bit of x on */ -#define left_bits(x) ((x<<1) | (~(x<<1)+1)) - -/* Set cinuse bit and pinuse bit of next chunk */ -#define set_inuse(M,p,s)\ - ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ - ((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT) - -/* Set cinuse and pinuse of this chunk and pinuse of next chunk */ -#define set_inuse_and_pinuse(M,p,s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ - ((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT) - -/* Set size, cinuse and pinuse bit of this chunk */ -#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT)) - -/* ----------------------- Operations on smallbins ----------------------- */ - -/* Link a free chunk into a smallbin */ -#define insert_small_chunk(M, P, S) {\ - bindex_t I = small_index(S);\ - mchunkptr B = smallbin_at(M, I);\ - mchunkptr F = B;\ - if (!smallmap_is_marked(M, I))\ - mark_smallmap(M, I);\ - else\ - F = B->fd;\ - B->fd = P;\ - F->bk = P;\ - P->fd = F;\ - P->bk = B;\ -} - -/* Unlink a chunk from a smallbin */ -#define unlink_small_chunk(M, P, S) {\ - mchunkptr F = P->fd;\ - mchunkptr B = P->bk;\ - bindex_t I = small_index(S);\ - if (F == B) {\ - clear_smallmap(M, I);\ - } else {\ - F->bk = B;\ - B->fd = F;\ - }\ -} - -/* Unlink the first chunk from a smallbin */ -#define unlink_first_small_chunk(M, B, P, I) {\ - mchunkptr F = P->fd;\ - if (B == F) {\ - clear_smallmap(M, I);\ - } else {\ - B->fd = F;\ - F->bk = B;\ - }\ -} - -/* Replace dv node, binning the old one */ -/* Used only when dvsize known to be small */ -#define replace_dv(M, P, S) {\ - size_t DVS = M->dvsize;\ - if (DVS != 0) {\ - mchunkptr DV = M->dv;\ - insert_small_chunk(M, DV, DVS);\ - }\ - M->dvsize = S;\ - M->dv = P;\ -} - -/* ------------------------- Operations on trees ------------------------- */ - -/* Insert chunk into tree */ -#define insert_large_chunk(M, X, S) {\ - tbinptr *H;\ - bindex_t I;\ - compute_tree_index(S, I);\ - H = treebin_at(M, I);\ - X->index = I;\ - X->child[0] = X->child[1] = 0;\ - if (!treemap_is_marked(M, I)) {\ - mark_treemap(M, I);\ - *H = X;\ - X->parent = (tchunkptr)H;\ - X->fd = X->bk = X;\ - } else {\ - tchunkptr T = *H;\ - size_t K = S << leftshift_for_tree_index(I);\ - for (;;) {\ - if (chunksize(T) != S) {\ - tchunkptr *C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\ - K <<= 1;\ - if (*C != 0) {\ - T = *C;\ - } else {\ - *C = X;\ - X->parent = T;\ - X->fd = X->bk = X;\ - break;\ - }\ - } else {\ - tchunkptr F = T->fd;\ - T->fd = F->bk = X;\ - X->fd = F;\ - X->bk = T;\ - X->parent = 0;\ - break;\ - }\ - }\ - }\ -} - -#define unlink_large_chunk(M, X) {\ - tchunkptr XP = X->parent;\ - tchunkptr R;\ - if (X->bk != X) {\ - tchunkptr F = X->fd;\ - R = X->bk;\ - F->bk = R;\ - R->fd = F;\ - } else {\ - tchunkptr *RP;\ - if (((R = *(RP = &(X->child[1]))) != 0) ||\ - ((R = *(RP = &(X->child[0]))) != 0)) {\ - tchunkptr *CP;\ - while ((*(CP = &(R->child[1])) != 0) ||\ - (*(CP = &(R->child[0])) != 0)) {\ - R = *(RP = CP);\ - }\ - *RP = 0;\ - }\ - }\ - if (XP != 0) {\ - tbinptr *H = treebin_at(M, X->index);\ - if (X == *H) {\ - if ((*H = R) == 0) \ - clear_treemap(M, X->index);\ - } else {\ - if (XP->child[0] == X) \ - XP->child[0] = R;\ - else \ - XP->child[1] = R;\ - }\ - if (R != 0) {\ - tchunkptr C0, C1;\ - R->parent = XP;\ - if ((C0 = X->child[0]) != 0) {\ - R->child[0] = C0;\ - C0->parent = R;\ - }\ - if ((C1 = X->child[1]) != 0) {\ - R->child[1] = C1;\ - C1->parent = R;\ - }\ - }\ - }\ -} - -/* Relays to large vs small bin operations */ - -#define insert_chunk(M, P, S)\ - if (is_small(S)) { insert_small_chunk(M, P, S)\ - } else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); } - -#define unlink_chunk(M, P, S)\ - if (is_small(S)) { unlink_small_chunk(M, P, S)\ - } else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); } - -/* ----------------------- Direct-mmapping chunks ----------------------- */ - -static void *direct_alloc(size_t nb) -{ - size_t mmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); - if (LJ_LIKELY(mmsize > nb)) { /* Check for wrap around 0 */ - char *mm = (char *)(DIRECT_MMAP(mmsize)); - if (mm != CMFAIL) { - size_t offset = align_offset(chunk2mem(mm)); - size_t psize = mmsize - offset - DIRECT_FOOT_PAD; - mchunkptr p = (mchunkptr)(mm + offset); - p->prev_foot = offset | IS_DIRECT_BIT; - p->head = psize|CINUSE_BIT; - chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; - chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; - return chunk2mem(p); - } - } - return NULL; -} - -static mchunkptr direct_resize(mchunkptr oldp, size_t nb) -{ - size_t oldsize = chunksize(oldp); - if (is_small(nb)) /* Can't shrink direct regions below small size */ - return NULL; - /* Keep old chunk if big enough but not too big */ - if (oldsize >= nb + SIZE_T_SIZE && - (oldsize - nb) <= (DEFAULT_GRANULARITY >> 1)) { - return oldp; - } else { - size_t offset = oldp->prev_foot & ~IS_DIRECT_BIT; - size_t oldmmsize = oldsize + offset + DIRECT_FOOT_PAD; - size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); - char *cp = (char *)CALL_MREMAP((char *)oldp - offset, - oldmmsize, newmmsize, CALL_MREMAP_MV); - if (cp != CMFAIL) { - mchunkptr newp = (mchunkptr)(cp + offset); - size_t psize = newmmsize - offset - DIRECT_FOOT_PAD; - newp->head = psize|CINUSE_BIT; - chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; - chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; - return newp; - } - } - return NULL; -} - -/* -------------------------- mspace management -------------------------- */ - -/* Initialize top chunk and its size */ -static void init_top(mstate m, mchunkptr p, size_t psize) -{ - /* Ensure alignment */ - size_t offset = align_offset(chunk2mem(p)); - p = (mchunkptr)((char *)p + offset); - psize -= offset; - - m->top = p; - m->topsize = psize; - p->head = psize | PINUSE_BIT; - /* set size of fake trailing chunk holding overhead space only once */ - chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; - m->trim_check = DEFAULT_TRIM_THRESHOLD; /* reset on each update */ -} - -/* Initialize bins for a new mstate that is otherwise zeroed out */ -static void init_bins(mstate m) -{ - /* Establish circular links for smallbins */ - bindex_t i; - for (i = 0; i < NSMALLBINS; i++) { - sbinptr bin = smallbin_at(m,i); - bin->fd = bin->bk = bin; - } -} - -/* Allocate chunk and prepend remainder with chunk in successor base. */ -static void *prepend_alloc(mstate m, char *newbase, char *oldbase, size_t nb) -{ - mchunkptr p = align_as_chunk(newbase); - mchunkptr oldfirst = align_as_chunk(oldbase); - size_t psize = (size_t)((char *)oldfirst - (char *)p); - mchunkptr q = chunk_plus_offset(p, nb); - size_t qsize = psize - nb; - set_size_and_pinuse_of_inuse_chunk(m, p, nb); - - /* consolidate remainder with first chunk of old base */ - if (oldfirst == m->top) { - size_t tsize = m->topsize += qsize; - m->top = q; - q->head = tsize | PINUSE_BIT; - } else if (oldfirst == m->dv) { - size_t dsize = m->dvsize += qsize; - m->dv = q; - set_size_and_pinuse_of_free_chunk(q, dsize); - } else { - if (!cinuse(oldfirst)) { - size_t nsize = chunksize(oldfirst); - unlink_chunk(m, oldfirst, nsize); - oldfirst = chunk_plus_offset(oldfirst, nsize); - qsize += nsize; - } - set_free_with_pinuse(q, qsize, oldfirst); - insert_chunk(m, q, qsize); - } - - return chunk2mem(p); -} - -/* Add a segment to hold a new noncontiguous region */ -static void add_segment(mstate m, char *tbase, size_t tsize) -{ - /* Determine locations and sizes of segment, fenceposts, old top */ - char *old_top = (char *)m->top; - msegmentptr oldsp = segment_holding(m, old_top); - char *old_end = oldsp->base + oldsp->size; - size_t ssize = pad_request(sizeof(struct malloc_segment)); - char *rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); - size_t offset = align_offset(chunk2mem(rawsp)); - char *asp = rawsp + offset; - char *csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; - mchunkptr sp = (mchunkptr)csp; - msegmentptr ss = (msegmentptr)(chunk2mem(sp)); - mchunkptr tnext = chunk_plus_offset(sp, ssize); - mchunkptr p = tnext; - - /* reset top to new space */ - init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); - - /* Set up segment record */ - set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); - *ss = m->seg; /* Push current record */ - m->seg.base = tbase; - m->seg.size = tsize; - m->seg.next = ss; - - /* Insert trailing fenceposts */ - for (;;) { - mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); - p->head = FENCEPOST_HEAD; - if ((char *)(&(nextp->head)) < old_end) - p = nextp; - else - break; - } - - /* Insert the rest of old top into a bin as an ordinary free chunk */ - if (csp != old_top) { - mchunkptr q = (mchunkptr)old_top; - size_t psize = (size_t)(csp - old_top); - mchunkptr tn = chunk_plus_offset(q, psize); - set_free_with_pinuse(q, psize, tn); - insert_chunk(m, q, psize); - } -} - -/* -------------------------- System allocation -------------------------- */ - -static void *alloc_sys(mstate m, size_t nb) -{ - char *tbase = CMFAIL; - size_t tsize = 0; - - /* Directly map large chunks */ - if (LJ_UNLIKELY(nb >= DEFAULT_MMAP_THRESHOLD)) { - void *mem = direct_alloc(nb); - if (mem != 0) - return mem; - } - - { - size_t req = nb + TOP_FOOT_SIZE + SIZE_T_ONE; - size_t rsize = granularity_align(req); - if (LJ_LIKELY(rsize > nb)) { /* Fail if wraps around zero */ - char *mp = (char *)(CALL_MMAP(rsize)); - if (mp != CMFAIL) { - tbase = mp; - tsize = rsize; - } - } - } - - if (tbase != CMFAIL) { - msegmentptr sp = &m->seg; - /* Try to merge with an existing segment */ - while (sp != 0 && tbase != sp->base + sp->size) - sp = sp->next; - if (sp != 0 && segment_holds(sp, m->top)) { /* append */ - sp->size += tsize; - init_top(m, m->top, m->topsize + tsize); - } else { - sp = &m->seg; - while (sp != 0 && sp->base != tbase + tsize) - sp = sp->next; - if (sp != 0) { - char *oldbase = sp->base; - sp->base = tbase; - sp->size += tsize; - return prepend_alloc(m, tbase, oldbase, nb); - } else { - add_segment(m, tbase, tsize); - } - } - - if (nb < m->topsize) { /* Allocate from new or extended top space */ - size_t rsize = m->topsize -= nb; - mchunkptr p = m->top; - mchunkptr r = m->top = chunk_plus_offset(p, nb); - r->head = rsize | PINUSE_BIT; - set_size_and_pinuse_of_inuse_chunk(m, p, nb); - return chunk2mem(p); - } - } - - return NULL; -} - -/* ----------------------- system deallocation -------------------------- */ - -/* Unmap and unlink any mmapped segments that don't contain used chunks */ -static size_t release_unused_segments(mstate m) -{ - size_t released = 0; - size_t nsegs = 0; - msegmentptr pred = &m->seg; - msegmentptr sp = pred->next; - while (sp != 0) { - char *base = sp->base; - size_t size = sp->size; - msegmentptr next = sp->next; - nsegs++; - { - mchunkptr p = align_as_chunk(base); - size_t psize = chunksize(p); - /* Can unmap if first chunk holds entire segment and not pinned */ - if (!cinuse(p) && (char *)p + psize >= base + size - TOP_FOOT_SIZE) { - tchunkptr tp = (tchunkptr)p; - if (p == m->dv) { - m->dv = 0; - m->dvsize = 0; - } else { - unlink_large_chunk(m, tp); - } - if (CALL_MUNMAP(base, size) == 0) { - released += size; - /* unlink obsoleted record */ - sp = pred; - sp->next = next; - } else { /* back out if cannot unmap */ - insert_large_chunk(m, tp, psize); - } - } - } - pred = sp; - sp = next; - } - /* Reset check counter */ - m->release_checks = nsegs > MAX_RELEASE_CHECK_RATE ? - nsegs : MAX_RELEASE_CHECK_RATE; - return released; -} - -static int alloc_trim(mstate m, size_t pad) -{ - size_t released = 0; - if (pad < MAX_REQUEST && is_initialized(m)) { - pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ - - if (m->topsize > pad) { - /* Shrink top space in granularity-size units, keeping at least one */ - size_t unit = DEFAULT_GRANULARITY; - size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - - SIZE_T_ONE) * unit; - msegmentptr sp = segment_holding(m, (char *)m->top); - - if (sp->size >= extra && - !has_segment_link(m, sp)) { /* can't shrink if pinned */ - size_t newsize = sp->size - extra; - /* Prefer mremap, fall back to munmap */ - if ((CALL_MREMAP(sp->base, sp->size, newsize, CALL_MREMAP_NOMOVE) != MFAIL) || - (CALL_MUNMAP(sp->base + newsize, extra) == 0)) { - released = extra; - } - } - - if (released != 0) { - sp->size -= released; - init_top(m, m->top, m->topsize - released); - } - } - - /* Unmap any unused mmapped segments */ - released += release_unused_segments(m); - - /* On failure, disable autotrim to avoid repeated failed future calls */ - if (released == 0 && m->topsize > m->trim_check) - m->trim_check = MAX_SIZE_T; - } - - return (released != 0)? 1 : 0; -} - -/* ---------------------------- malloc support --------------------------- */ - -/* allocate a large request from the best fitting chunk in a treebin */ -static void *tmalloc_large(mstate m, size_t nb) -{ - tchunkptr v = 0; - size_t rsize = ~nb+1; /* Unsigned negation */ - tchunkptr t; - bindex_t idx; - compute_tree_index(nb, idx); - - if ((t = *treebin_at(m, idx)) != 0) { - /* Traverse tree for this bin looking for node with size == nb */ - size_t sizebits = nb << leftshift_for_tree_index(idx); - tchunkptr rst = 0; /* The deepest untaken right subtree */ - for (;;) { - tchunkptr rt; - size_t trem = chunksize(t) - nb; - if (trem < rsize) { - v = t; - if ((rsize = trem) == 0) - break; - } - rt = t->child[1]; - t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; - if (rt != 0 && rt != t) - rst = rt; - if (t == 0) { - t = rst; /* set t to least subtree holding sizes > nb */ - break; - } - sizebits <<= 1; - } - } - - if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ - binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; - if (leftbits != 0) - t = *treebin_at(m, lj_ffs(leftbits)); - } - - while (t != 0) { /* find smallest of tree or subtree */ - size_t trem = chunksize(t) - nb; - if (trem < rsize) { - rsize = trem; - v = t; - } - t = leftmost_child(t); - } - - /* If dv is a better fit, return NULL so malloc will use it */ - if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { - mchunkptr r = chunk_plus_offset(v, nb); - unlink_large_chunk(m, v); - if (rsize < MIN_CHUNK_SIZE) { - set_inuse_and_pinuse(m, v, (rsize + nb)); - } else { - set_size_and_pinuse_of_inuse_chunk(m, v, nb); - set_size_and_pinuse_of_free_chunk(r, rsize); - insert_chunk(m, r, rsize); - } - return chunk2mem(v); - } - return NULL; -} - -/* allocate a small request from the best fitting chunk in a treebin */ -static void *tmalloc_small(mstate m, size_t nb) -{ - tchunkptr t, v; - mchunkptr r; - size_t rsize; - bindex_t i = lj_ffs(m->treemap); - - v = t = *treebin_at(m, i); - rsize = chunksize(t) - nb; - - while ((t = leftmost_child(t)) != 0) { - size_t trem = chunksize(t) - nb; - if (trem < rsize) { - rsize = trem; - v = t; - } - } - - r = chunk_plus_offset(v, nb); - unlink_large_chunk(m, v); - if (rsize < MIN_CHUNK_SIZE) { - set_inuse_and_pinuse(m, v, (rsize + nb)); - } else { - set_size_and_pinuse_of_inuse_chunk(m, v, nb); - set_size_and_pinuse_of_free_chunk(r, rsize); - replace_dv(m, r, rsize); - } - return chunk2mem(v); -} - -/* ----------------------------------------------------------------------- */ - -void *lj_alloc_create(void) -{ - size_t tsize = DEFAULT_GRANULARITY; - char *tbase; - INIT_MMAP(); - tbase = (char *)(CALL_MMAP(tsize)); - if (tbase != CMFAIL) { - size_t msize = pad_request(sizeof(struct malloc_state)); - mchunkptr mn; - mchunkptr msp = align_as_chunk(tbase); - mstate m = (mstate)(chunk2mem(msp)); - memset(m, 0, msize); - msp->head = (msize|PINUSE_BIT|CINUSE_BIT); - m->seg.base = tbase; - m->seg.size = tsize; - m->release_checks = MAX_RELEASE_CHECK_RATE; - init_bins(m); - mn = next_chunk(mem2chunk(m)); - init_top(m, mn, (size_t)((tbase + tsize) - (char *)mn) - TOP_FOOT_SIZE); - return m; - } - return NULL; -} - -void lj_alloc_destroy(void *msp) -{ - mstate ms = (mstate)msp; - msegmentptr sp = &ms->seg; - while (sp != 0) { - char *base = sp->base; - size_t size = sp->size; - sp = sp->next; - CALL_MUNMAP(base, size); - } -} - -static LJ_NOINLINE void *lj_alloc_malloc(void *msp, size_t nsize) -{ - mstate ms = (mstate)msp; - void *mem; - size_t nb; - if (nsize <= MAX_SMALL_REQUEST) { - bindex_t idx; - binmap_t smallbits; - nb = (nsize < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(nsize); - idx = small_index(nb); - smallbits = ms->smallmap >> idx; - - if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ - mchunkptr b, p; - idx += ~smallbits & 1; /* Uses next bin if idx empty */ - b = smallbin_at(ms, idx); - p = b->fd; - unlink_first_small_chunk(ms, b, p, idx); - set_inuse_and_pinuse(ms, p, small_index2size(idx)); - mem = chunk2mem(p); - return mem; - } else if (nb > ms->dvsize) { - if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ - mchunkptr b, p, r; - size_t rsize; - binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); - bindex_t i = lj_ffs(leftbits); - b = smallbin_at(ms, i); - p = b->fd; - unlink_first_small_chunk(ms, b, p, i); - rsize = small_index2size(i) - nb; - /* Fit here cannot be remainderless if 4byte sizes */ - if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) { - set_inuse_and_pinuse(ms, p, small_index2size(i)); - } else { - set_size_and_pinuse_of_inuse_chunk(ms, p, nb); - r = chunk_plus_offset(p, nb); - set_size_and_pinuse_of_free_chunk(r, rsize); - replace_dv(ms, r, rsize); - } - mem = chunk2mem(p); - return mem; - } else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) { - return mem; - } - } - } else if (nsize >= MAX_REQUEST) { - nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ - } else { - nb = pad_request(nsize); - if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) { - return mem; - } - } - - if (nb <= ms->dvsize) { - size_t rsize = ms->dvsize - nb; - mchunkptr p = ms->dv; - if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ - mchunkptr r = ms->dv = chunk_plus_offset(p, nb); - ms->dvsize = rsize; - set_size_and_pinuse_of_free_chunk(r, rsize); - set_size_and_pinuse_of_inuse_chunk(ms, p, nb); - } else { /* exhaust dv */ - size_t dvs = ms->dvsize; - ms->dvsize = 0; - ms->dv = 0; - set_inuse_and_pinuse(ms, p, dvs); - } - mem = chunk2mem(p); - return mem; - } else if (nb < ms->topsize) { /* Split top */ - size_t rsize = ms->topsize -= nb; - mchunkptr p = ms->top; - mchunkptr r = ms->top = chunk_plus_offset(p, nb); - r->head = rsize | PINUSE_BIT; - set_size_and_pinuse_of_inuse_chunk(ms, p, nb); - mem = chunk2mem(p); - return mem; - } - return alloc_sys(ms, nb); -} - -static LJ_NOINLINE void *lj_alloc_free(void *msp, void *ptr) -{ - if (ptr != 0) { - mchunkptr p = mem2chunk(ptr); - mstate fm = (mstate)msp; - size_t psize = chunksize(p); - mchunkptr next = chunk_plus_offset(p, psize); - if (!pinuse(p)) { - size_t prevsize = p->prev_foot; - if ((prevsize & IS_DIRECT_BIT) != 0) { - prevsize &= ~IS_DIRECT_BIT; - psize += prevsize + DIRECT_FOOT_PAD; - CALL_MUNMAP((char *)p - prevsize, psize); - return NULL; - } else { - mchunkptr prev = chunk_minus_offset(p, prevsize); - psize += prevsize; - p = prev; - /* consolidate backward */ - if (p != fm->dv) { - unlink_chunk(fm, p, prevsize); - } else if ((next->head & INUSE_BITS) == INUSE_BITS) { - fm->dvsize = psize; - set_free_with_pinuse(p, psize, next); - return NULL; - } - } - } - if (!cinuse(next)) { /* consolidate forward */ - if (next == fm->top) { - size_t tsize = fm->topsize += psize; - fm->top = p; - p->head = tsize | PINUSE_BIT; - if (p == fm->dv) { - fm->dv = 0; - fm->dvsize = 0; - } - if (tsize > fm->trim_check) - alloc_trim(fm, 0); - return NULL; - } else if (next == fm->dv) { - size_t dsize = fm->dvsize += psize; - fm->dv = p; - set_size_and_pinuse_of_free_chunk(p, dsize); - return NULL; - } else { - size_t nsize = chunksize(next); - psize += nsize; - unlink_chunk(fm, next, nsize); - set_size_and_pinuse_of_free_chunk(p, psize); - if (p == fm->dv) { - fm->dvsize = psize; - return NULL; - } - } - } else { - set_free_with_pinuse(p, psize, next); - } - - if (is_small(psize)) { - insert_small_chunk(fm, p, psize); - } else { - tchunkptr tp = (tchunkptr)p; - insert_large_chunk(fm, tp, psize); - if (--fm->release_checks == 0) - release_unused_segments(fm); - } - } - return NULL; -} - -static LJ_NOINLINE void *lj_alloc_realloc(void *msp, void *ptr, size_t nsize) -{ - if (nsize >= MAX_REQUEST) { - return NULL; - } else { - mstate m = (mstate)msp; - mchunkptr oldp = mem2chunk(ptr); - size_t oldsize = chunksize(oldp); - mchunkptr next = chunk_plus_offset(oldp, oldsize); - mchunkptr newp = 0; - size_t nb = request2size(nsize); - - /* Try to either shrink or extend into top. Else malloc-copy-free */ - if (is_direct(oldp)) { - newp = direct_resize(oldp, nb); /* this may return NULL. */ - } else if (oldsize >= nb) { /* already big enough */ - size_t rsize = oldsize - nb; - newp = oldp; - if (rsize >= MIN_CHUNK_SIZE) { - mchunkptr rem = chunk_plus_offset(newp, nb); - set_inuse(m, newp, nb); - set_inuse(m, rem, rsize); - lj_alloc_free(m, chunk2mem(rem)); - } - } else if (next == m->top && oldsize + m->topsize > nb) { - /* Expand into top */ - size_t newsize = oldsize + m->topsize; - size_t newtopsize = newsize - nb; - mchunkptr newtop = chunk_plus_offset(oldp, nb); - set_inuse(m, oldp, nb); - newtop->head = newtopsize |PINUSE_BIT; - m->top = newtop; - m->topsize = newtopsize; - newp = oldp; - } - - if (newp != 0) { - return chunk2mem(newp); - } else { - void *newmem = lj_alloc_malloc(m, nsize); - if (newmem != 0) { - size_t oc = oldsize - overhead_for(oldp); - memcpy(newmem, ptr, oc < nsize ? oc : nsize); - lj_alloc_free(m, ptr); - } - return newmem; - } - } -} - -void *lj_alloc_f(void *msp, void *ptr, size_t osize, size_t nsize) -{ - (void)osize; - if (nsize == 0) { - return lj_alloc_free(msp, ptr); - } else if (ptr == NULL) { - return lj_alloc_malloc(msp, nsize); - } else { - return lj_alloc_realloc(msp, ptr, nsize); - } -} - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_api.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_api.c deleted file mode 100644 index bc5290b24..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_api.c +++ /dev/null @@ -1,1200 +0,0 @@ -/* -** Public Lua/C API. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Major portions taken verbatim or adapted from the Lua interpreter. -** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h -*/ - -#define lj_api_c -#define LUA_CORE - -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_debug.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_func.h" -#include "lj_udata.h" -#include "lj_meta.h" -#include "lj_state.h" -#include "lj_bc.h" -#include "lj_frame.h" -#include "lj_trace.h" -#include "lj_vm.h" -#include "lj_strscan.h" - -/* -- Common helper functions --------------------------------------------- */ - -#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base)) -#define api_checkvalidindex(L, i) api_check(L, (i) != niltv(L)) - -static TValue *index2adr(lua_State *L, int idx) -{ - if (idx > 0) { - TValue *o = L->base + (idx - 1); - return o < L->top ? o : niltv(L); - } else if (idx > LUA_REGISTRYINDEX) { - api_check(L, idx != 0 && -idx <= L->top - L->base); - return L->top + idx; - } else if (idx == LUA_GLOBALSINDEX) { - TValue *o = &G(L)->tmptv; - settabV(L, o, tabref(L->env)); - return o; - } else if (idx == LUA_REGISTRYINDEX) { - return registry(L); - } else { - GCfunc *fn = curr_func(L); - api_check(L, fn->c.gct == ~LJ_TFUNC && !isluafunc(fn)); - if (idx == LUA_ENVIRONINDEX) { - TValue *o = &G(L)->tmptv; - settabV(L, o, tabref(fn->c.env)); - return o; - } else { - idx = LUA_GLOBALSINDEX - idx; - return idx <= fn->c.nupvalues ? &fn->c.upvalue[idx-1] : niltv(L); - } - } -} - -static TValue *stkindex2adr(lua_State *L, int idx) -{ - if (idx > 0) { - TValue *o = L->base + (idx - 1); - return o < L->top ? o : niltv(L); - } else { - api_check(L, idx != 0 && -idx <= L->top - L->base); - return L->top + idx; - } -} - -static GCtab *getcurrenv(lua_State *L) -{ - GCfunc *fn = curr_func(L); - return fn->c.gct == ~LJ_TFUNC ? tabref(fn->c.env) : tabref(L->env); -} - -/* -- Miscellaneous API functions ----------------------------------------- */ - -LUA_API int lua_status(lua_State *L) -{ - return L->status; -} - -LUA_API int lua_checkstack(lua_State *L, int size) -{ - if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK) { - return 0; /* Stack overflow. */ - } else if (size > 0) { - lj_state_checkstack(L, (MSize)size); - } - return 1; -} - -LUALIB_API void luaL_checkstack(lua_State *L, int size, const char *msg) -{ - if (!lua_checkstack(L, size)) - lj_err_callerv(L, LJ_ERR_STKOVM, msg); -} - -LUA_API void lua_xmove(lua_State *from, lua_State *to, int n) -{ - TValue *f, *t; - if (from == to) return; - api_checknelems(from, n); - api_check(from, G(from) == G(to)); - lj_state_checkstack(to, (MSize)n); - f = from->top; - t = to->top = to->top + n; - while (--n >= 0) copyTV(to, --t, --f); - from->top = f; -} - -/* -- Stack manipulation -------------------------------------------------- */ - -LUA_API int lua_gettop(lua_State *L) -{ - return (int)(L->top - L->base); -} - -LUA_API void lua_settop(lua_State *L, int idx) -{ - if (idx >= 0) { - api_check(L, idx <= tvref(L->maxstack) - L->base); - if (L->base + idx > L->top) { - if (L->base + idx >= tvref(L->maxstack)) - lj_state_growstack(L, (MSize)idx - (MSize)(L->top - L->base)); - do { setnilV(L->top++); } while (L->top < L->base + idx); - } else { - L->top = L->base + idx; - } - } else { - api_check(L, -(idx+1) <= (L->top - L->base)); - L->top += idx+1; /* Shrinks top (idx < 0). */ - } -} - -LUA_API void lua_remove(lua_State *L, int idx) -{ - TValue *p = stkindex2adr(L, idx); - api_checkvalidindex(L, p); - while (++p < L->top) copyTV(L, p-1, p); - L->top--; -} - -LUA_API void lua_insert(lua_State *L, int idx) -{ - TValue *q, *p = stkindex2adr(L, idx); - api_checkvalidindex(L, p); - for (q = L->top; q > p; q--) copyTV(L, q, q-1); - copyTV(L, p, L->top); -} - -LUA_API void lua_replace(lua_State *L, int idx) -{ - api_checknelems(L, 1); - if (idx == LUA_GLOBALSINDEX) { - api_check(L, tvistab(L->top-1)); - /* NOBARRIER: A thread (i.e. L) is never black. */ - setgcref(L->env, obj2gco(tabV(L->top-1))); - } else if (idx == LUA_ENVIRONINDEX) { - GCfunc *fn = curr_func(L); - if (fn->c.gct != ~LJ_TFUNC) - lj_err_msg(L, LJ_ERR_NOENV); - api_check(L, tvistab(L->top-1)); - setgcref(fn->c.env, obj2gco(tabV(L->top-1))); - lj_gc_barrier(L, fn, L->top-1); - } else { - TValue *o = index2adr(L, idx); - api_checkvalidindex(L, o); - copyTV(L, o, L->top-1); - if (idx < LUA_GLOBALSINDEX) /* Need a barrier for upvalues. */ - lj_gc_barrier(L, curr_func(L), L->top-1); - } - L->top--; -} - -LUA_API void lua_pushvalue(lua_State *L, int idx) -{ - copyTV(L, L->top, index2adr(L, idx)); - incr_top(L); -} - -/* -- Stack getters ------------------------------------------------------- */ - -LUA_API int lua_type(lua_State *L, int idx) -{ - cTValue *o = index2adr(L, idx); - if (tvisnumber(o)) { - return LUA_TNUMBER; -#if LJ_64 - } else if (tvislightud(o)) { - return LUA_TLIGHTUSERDATA; -#endif - } else if (o == niltv(L)) { - return LUA_TNONE; - } else { /* Magic internal/external tag conversion. ORDER LJ_T */ - uint32_t t = ~itype(o); -#if LJ_64 - int tt = (int)((U64x(75a06,98042110) >> 4*t) & 15u); -#else - int tt = (int)(((t < 8 ? 0x98042110u : 0x75a06u) >> 4*(t&7)) & 15u); -#endif - lua_assert(tt != LUA_TNIL || tvisnil(o)); - return tt; - } -} - -LUALIB_API void luaL_checktype(lua_State *L, int idx, int tt) -{ - if (lua_type(L, idx) != tt) - lj_err_argt(L, idx, tt); -} - -LUALIB_API void luaL_checkany(lua_State *L, int idx) -{ - if (index2adr(L, idx) == niltv(L)) - lj_err_arg(L, idx, LJ_ERR_NOVAL); -} - -LUA_API const char *lua_typename(lua_State *L, int t) -{ - UNUSED(L); - return lj_obj_typename[t+1]; -} - -LUA_API int lua_iscfunction(lua_State *L, int idx) -{ - cTValue *o = index2adr(L, idx); - return tvisfunc(o) && !isluafunc(funcV(o)); -} - -LUA_API int lua_isnumber(lua_State *L, int idx) -{ - cTValue *o = index2adr(L, idx); - TValue tmp; - return (tvisnumber(o) || (tvisstr(o) && lj_strscan_number(strV(o), &tmp))); -} - -LUA_API int lua_isstring(lua_State *L, int idx) -{ - cTValue *o = index2adr(L, idx); - return (tvisstr(o) || tvisnumber(o)); -} - -LUA_API int lua_isuserdata(lua_State *L, int idx) -{ - cTValue *o = index2adr(L, idx); - return (tvisudata(o) || tvislightud(o)); -} - -LUA_API int lua_rawequal(lua_State *L, int idx1, int idx2) -{ - cTValue *o1 = index2adr(L, idx1); - cTValue *o2 = index2adr(L, idx2); - return (o1 == niltv(L) || o2 == niltv(L)) ? 0 : lj_obj_equal(o1, o2); -} - -LUA_API int lua_equal(lua_State *L, int idx1, int idx2) -{ - cTValue *o1 = index2adr(L, idx1); - cTValue *o2 = index2adr(L, idx2); - if (tvisint(o1) && tvisint(o2)) { - return intV(o1) == intV(o2); - } else if (tvisnumber(o1) && tvisnumber(o2)) { - return numberVnum(o1) == numberVnum(o2); - } else if (itype(o1) != itype(o2)) { - return 0; - } else if (tvispri(o1)) { - return o1 != niltv(L) && o2 != niltv(L); -#if LJ_64 - } else if (tvislightud(o1)) { - return o1->u64 == o2->u64; -#endif - } else if (gcrefeq(o1->gcr, o2->gcr)) { - return 1; - } else if (!tvistabud(o1)) { - return 0; - } else { - TValue *base = lj_meta_equal(L, gcV(o1), gcV(o2), 0); - if ((uintptr_t)base <= 1) { - return (int)(uintptr_t)base; - } else { - L->top = base+2; - lj_vm_call(L, base, 1+1); - L->top -= 2; - return tvistruecond(L->top+1); - } - } -} - -LUA_API int lua_lessthan(lua_State *L, int idx1, int idx2) -{ - cTValue *o1 = index2adr(L, idx1); - cTValue *o2 = index2adr(L, idx2); - if (o1 == niltv(L) || o2 == niltv(L)) { - return 0; - } else if (tvisint(o1) && tvisint(o2)) { - return intV(o1) < intV(o2); - } else if (tvisnumber(o1) && tvisnumber(o2)) { - return numberVnum(o1) < numberVnum(o2); - } else { - TValue *base = lj_meta_comp(L, o1, o2, 0); - if ((uintptr_t)base <= 1) { - return (int)(uintptr_t)base; - } else { - L->top = base+2; - lj_vm_call(L, base, 1+1); - L->top -= 2; - return tvistruecond(L->top+1); - } - } -} - -LUA_API lua_Number lua_tonumber(lua_State *L, int idx) -{ - cTValue *o = index2adr(L, idx); - TValue tmp; - if (LJ_LIKELY(tvisnumber(o))) - return numberVnum(o); - else if (tvisstr(o) && lj_strscan_num(strV(o), &tmp)) - return numV(&tmp); - else - return 0; -} - -LUALIB_API lua_Number luaL_checknumber(lua_State *L, int idx) -{ - cTValue *o = index2adr(L, idx); - TValue tmp; - if (LJ_LIKELY(tvisnumber(o))) - return numberVnum(o); - else if (!(tvisstr(o) && lj_strscan_num(strV(o), &tmp))) - lj_err_argt(L, idx, LUA_TNUMBER); - return numV(&tmp); -} - -LUALIB_API lua_Number luaL_optnumber(lua_State *L, int idx, lua_Number def) -{ - cTValue *o = index2adr(L, idx); - TValue tmp; - if (LJ_LIKELY(tvisnumber(o))) - return numberVnum(o); - else if (tvisnil(o)) - return def; - else if (!(tvisstr(o) && lj_strscan_num(strV(o), &tmp))) - lj_err_argt(L, idx, LUA_TNUMBER); - return numV(&tmp); -} - -LUA_API lua_Integer lua_tointeger(lua_State *L, int idx) -{ - cTValue *o = index2adr(L, idx); - TValue tmp; - lua_Number n; - if (LJ_LIKELY(tvisint(o))) { - return intV(o); - } else if (LJ_LIKELY(tvisnum(o))) { - n = numV(o); - } else { - if (!(tvisstr(o) && lj_strscan_number(strV(o), &tmp))) - return 0; - if (tvisint(&tmp)) - return (lua_Integer)intV(&tmp); - n = numV(&tmp); - } -#if LJ_64 - return (lua_Integer)n; -#else - return lj_num2int(n); -#endif -} - -LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int idx) -{ - cTValue *o = index2adr(L, idx); - TValue tmp; - lua_Number n; - if (LJ_LIKELY(tvisint(o))) { - return intV(o); - } else if (LJ_LIKELY(tvisnum(o))) { - n = numV(o); - } else { - if (!(tvisstr(o) && lj_strscan_number(strV(o), &tmp))) - lj_err_argt(L, idx, LUA_TNUMBER); - if (tvisint(&tmp)) - return (lua_Integer)intV(&tmp); - n = numV(&tmp); - } -#if LJ_64 - return (lua_Integer)n; -#else - return lj_num2int(n); -#endif -} - -LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int idx, lua_Integer def) -{ - cTValue *o = index2adr(L, idx); - TValue tmp; - lua_Number n; - if (LJ_LIKELY(tvisint(o))) { - return intV(o); - } else if (LJ_LIKELY(tvisnum(o))) { - n = numV(o); - } else if (tvisnil(o)) { - return def; - } else { - if (!(tvisstr(o) && lj_strscan_number(strV(o), &tmp))) - lj_err_argt(L, idx, LUA_TNUMBER); - if (tvisint(&tmp)) - return (lua_Integer)intV(&tmp); - n = numV(&tmp); - } -#if LJ_64 - return (lua_Integer)n; -#else - return lj_num2int(n); -#endif -} - -LUA_API int lua_toboolean(lua_State *L, int idx) -{ - cTValue *o = index2adr(L, idx); - return tvistruecond(o); -} - -LUA_API const char *lua_tolstring(lua_State *L, int idx, size_t *len) -{ - TValue *o = index2adr(L, idx); - GCstr *s; - if (LJ_LIKELY(tvisstr(o))) { - s = strV(o); - } else if (tvisnumber(o)) { - lj_gc_check(L); - o = index2adr(L, idx); /* GC may move the stack. */ - s = lj_str_fromnumber(L, o); - setstrV(L, o, s); - } else { - if (len != NULL) *len = 0; - return NULL; - } - if (len != NULL) *len = s->len; - return strdata(s); -} - -LUALIB_API const char *luaL_checklstring(lua_State *L, int idx, size_t *len) -{ - TValue *o = index2adr(L, idx); - GCstr *s; - if (LJ_LIKELY(tvisstr(o))) { - s = strV(o); - } else if (tvisnumber(o)) { - lj_gc_check(L); - o = index2adr(L, idx); /* GC may move the stack. */ - s = lj_str_fromnumber(L, o); - setstrV(L, o, s); - } else { - lj_err_argt(L, idx, LUA_TSTRING); - } - if (len != NULL) *len = s->len; - return strdata(s); -} - -LUALIB_API const char *luaL_optlstring(lua_State *L, int idx, - const char *def, size_t *len) -{ - TValue *o = index2adr(L, idx); - GCstr *s; - if (LJ_LIKELY(tvisstr(o))) { - s = strV(o); - } else if (tvisnil(o)) { - if (len != NULL) *len = def ? strlen(def) : 0; - return def; - } else if (tvisnumber(o)) { - lj_gc_check(L); - o = index2adr(L, idx); /* GC may move the stack. */ - s = lj_str_fromnumber(L, o); - setstrV(L, o, s); - } else { - lj_err_argt(L, idx, LUA_TSTRING); - } - if (len != NULL) *len = s->len; - return strdata(s); -} - -LUALIB_API int luaL_checkoption(lua_State *L, int idx, const char *def, - const char *const lst[]) -{ - ptrdiff_t i; - const char *s = lua_tolstring(L, idx, NULL); - if (s == NULL && (s = def) == NULL) - lj_err_argt(L, idx, LUA_TSTRING); - for (i = 0; lst[i]; i++) - if (strcmp(lst[i], s) == 0) - return (int)i; - lj_err_argv(L, idx, LJ_ERR_INVOPTM, s); -} - -LUA_API size_t lua_objlen(lua_State *L, int idx) -{ - TValue *o = index2adr(L, idx); - if (tvisstr(o)) { - return strV(o)->len; - } else if (tvistab(o)) { - return (size_t)lj_tab_len(tabV(o)); - } else if (tvisudata(o)) { - return udataV(o)->len; - } else if (tvisnumber(o)) { - GCstr *s = lj_str_fromnumber(L, o); - setstrV(L, o, s); - return s->len; - } else { - return 0; - } -} - -LUA_API lua_CFunction lua_tocfunction(lua_State *L, int idx) -{ - cTValue *o = index2adr(L, idx); - if (tvisfunc(o)) { - BCOp op = bc_op(*mref(funcV(o)->c.pc, BCIns)); - if (op == BC_FUNCC || op == BC_FUNCCW) - return funcV(o)->c.f; - } - return NULL; -} - -LUA_API void *lua_touserdata(lua_State *L, int idx) -{ - cTValue *o = index2adr(L, idx); - if (tvisudata(o)) - return uddata(udataV(o)); - else if (tvislightud(o)) - return lightudV(o); - else - return NULL; -} - -LUA_API lua_State *lua_tothread(lua_State *L, int idx) -{ - cTValue *o = index2adr(L, idx); - return (!tvisthread(o)) ? NULL : threadV(o); -} - -LUA_API const void *lua_topointer(lua_State *L, int idx) -{ - cTValue *o = index2adr(L, idx); - if (tvisudata(o)) - return uddata(udataV(o)); - else if (tvislightud(o)) - return lightudV(o); - else if (tviscdata(o)) - return cdataptr(cdataV(o)); - else if (tvisgcv(o)) - return gcV(o); - else - return NULL; -} - -/* -- Stack setters (object creation) ------------------------------------- */ - -LUA_API void lua_pushnil(lua_State *L) -{ - setnilV(L->top); - incr_top(L); -} - -LUA_API void lua_pushnumber(lua_State *L, lua_Number n) -{ - setnumV(L->top, n); - if (LJ_UNLIKELY(tvisnan(L->top))) - setnanV(L->top); /* Canonicalize injected NaNs. */ - incr_top(L); -} - -LUA_API void lua_pushinteger(lua_State *L, lua_Integer n) -{ - setintptrV(L->top, n); - incr_top(L); -} - -LUA_API void lua_pushlstring(lua_State *L, const char *str, size_t len) -{ - GCstr *s; - lj_gc_check(L); - s = lj_str_new(L, str, len); - setstrV(L, L->top, s); - incr_top(L); -} - -LUA_API void lua_pushstring(lua_State *L, const char *str) -{ - if (str == NULL) { - setnilV(L->top); - } else { - GCstr *s; - lj_gc_check(L); - s = lj_str_newz(L, str); - setstrV(L, L->top, s); - } - incr_top(L); -} - -LUA_API const char *lua_pushvfstring(lua_State *L, const char *fmt, - va_list argp) -{ - lj_gc_check(L); - return lj_str_pushvf(L, fmt, argp); -} - -LUA_API const char *lua_pushfstring(lua_State *L, const char *fmt, ...) -{ - const char *ret; - va_list argp; - lj_gc_check(L); - va_start(argp, fmt); - ret = lj_str_pushvf(L, fmt, argp); - va_end(argp); - return ret; -} - -LUA_API void lua_pushcclosure(lua_State *L, lua_CFunction f, int n) -{ - GCfunc *fn; - lj_gc_check(L); - api_checknelems(L, n); - fn = lj_func_newC(L, (MSize)n, getcurrenv(L)); - fn->c.f = f; - L->top -= n; - while (n--) - copyTV(L, &fn->c.upvalue[n], L->top+n); - setfuncV(L, L->top, fn); - lua_assert(iswhite(obj2gco(fn))); - incr_top(L); -} - -LUA_API void lua_pushboolean(lua_State *L, int b) -{ - setboolV(L->top, (b != 0)); - incr_top(L); -} - -LUA_API void lua_pushlightuserdata(lua_State *L, void *p) -{ - setlightudV(L->top, checklightudptr(L, p)); - incr_top(L); -} - -LUA_API void lua_createtable(lua_State *L, int narray, int nrec) -{ - GCtab *t; - lj_gc_check(L); - t = lj_tab_new(L, (uint32_t)(narray > 0 ? narray+1 : 0), hsize2hbits(nrec)); - settabV(L, L->top, t); - incr_top(L); -} - -LUALIB_API int luaL_newmetatable(lua_State *L, const char *tname) -{ - GCtab *regt = tabV(registry(L)); - TValue *tv = lj_tab_setstr(L, regt, lj_str_newz(L, tname)); - if (tvisnil(tv)) { - GCtab *mt = lj_tab_new(L, 0, 1); - settabV(L, tv, mt); - settabV(L, L->top++, mt); - lj_gc_anybarriert(L, regt); - return 1; - } else { - copyTV(L, L->top++, tv); - return 0; - } -} - -LUA_API int lua_pushthread(lua_State *L) -{ - setthreadV(L, L->top, L); - incr_top(L); - return (mainthread(G(L)) == L); -} - -LUA_API lua_State *lua_newthread(lua_State *L) -{ - lua_State *L1; - lj_gc_check(L); - L1 = lj_state_new(L); - setthreadV(L, L->top, L1); - incr_top(L); - return L1; -} - -LUA_API void *lua_newuserdata(lua_State *L, size_t size) -{ - GCudata *ud; - lj_gc_check(L); - if (size > LJ_MAX_UDATA) - lj_err_msg(L, LJ_ERR_UDATAOV); - ud = lj_udata_new(L, (MSize)size, getcurrenv(L)); - setudataV(L, L->top, ud); - incr_top(L); - return uddata(ud); -} - -LUA_API void lua_concat(lua_State *L, int n) -{ - api_checknelems(L, n); - if (n >= 2) { - n--; - do { - TValue *top = lj_meta_cat(L, L->top-1, -n); - if (top == NULL) { - L->top -= n; - break; - } - n -= (int)(L->top - top); - L->top = top+2; - lj_vm_call(L, top, 1+1); - L->top--; - copyTV(L, L->top-1, L->top); - } while (--n > 0); - } else if (n == 0) { /* Push empty string. */ - setstrV(L, L->top, &G(L)->strempty); - incr_top(L); - } - /* else n == 1: nothing to do. */ -} - -/* -- Object getters ------------------------------------------------------ */ - -LUA_API void lua_gettable(lua_State *L, int idx) -{ - cTValue *v, *t = index2adr(L, idx); - api_checkvalidindex(L, t); - v = lj_meta_tget(L, t, L->top-1); - if (v == NULL) { - L->top += 2; - lj_vm_call(L, L->top-2, 1+1); - L->top -= 2; - v = L->top+1; - } - copyTV(L, L->top-1, v); -} - -LUA_API void lua_getfield(lua_State *L, int idx, const char *k) -{ - cTValue *v, *t = index2adr(L, idx); - TValue key; - api_checkvalidindex(L, t); - setstrV(L, &key, lj_str_newz(L, k)); - v = lj_meta_tget(L, t, &key); - if (v == NULL) { - L->top += 2; - lj_vm_call(L, L->top-2, 1+1); - L->top -= 2; - v = L->top+1; - } - copyTV(L, L->top, v); - incr_top(L); -} - -LUA_API void lua_rawget(lua_State *L, int idx) -{ - cTValue *t = index2adr(L, idx); - api_check(L, tvistab(t)); - copyTV(L, L->top-1, lj_tab_get(L, tabV(t), L->top-1)); -} - -LUA_API void lua_rawgeti(lua_State *L, int idx, int n) -{ - cTValue *v, *t = index2adr(L, idx); - api_check(L, tvistab(t)); - v = lj_tab_getint(tabV(t), n); - if (v) { - copyTV(L, L->top, v); - } else { - setnilV(L->top); - } - incr_top(L); -} - -LUA_API int lua_getmetatable(lua_State *L, int idx) -{ - cTValue *o = index2adr(L, idx); - GCtab *mt = NULL; - if (tvistab(o)) - mt = tabref(tabV(o)->metatable); - else if (tvisudata(o)) - mt = tabref(udataV(o)->metatable); - else - mt = tabref(basemt_obj(G(L), o)); - if (mt == NULL) - return 0; - settabV(L, L->top, mt); - incr_top(L); - return 1; -} - -LUALIB_API int luaL_getmetafield(lua_State *L, int idx, const char *field) -{ - if (lua_getmetatable(L, idx)) { - cTValue *tv = lj_tab_getstr(tabV(L->top-1), lj_str_newz(L, field)); - if (tv && !tvisnil(tv)) { - copyTV(L, L->top-1, tv); - return 1; - } - L->top--; - } - return 0; -} - -LUA_API void lua_getfenv(lua_State *L, int idx) -{ - cTValue *o = index2adr(L, idx); - api_checkvalidindex(L, o); - if (tvisfunc(o)) { - settabV(L, L->top, tabref(funcV(o)->c.env)); - } else if (tvisudata(o)) { - settabV(L, L->top, tabref(udataV(o)->env)); - } else if (tvisthread(o)) { - settabV(L, L->top, tabref(threadV(o)->env)); - } else { - setnilV(L->top); - } - incr_top(L); -} - -LUA_API int lua_next(lua_State *L, int idx) -{ - cTValue *t = index2adr(L, idx); - int more; - api_check(L, tvistab(t)); - more = lj_tab_next(L, tabV(t), L->top-1); - if (more) { - incr_top(L); /* Return new key and value slot. */ - } else { /* End of traversal. */ - L->top--; /* Remove key slot. */ - } - return more; -} - -LUA_API const char *lua_getupvalue(lua_State *L, int idx, int n) -{ - TValue *val; - const char *name = lj_debug_uvnamev(index2adr(L, idx), (uint32_t)(n-1), &val); - if (name) { - copyTV(L, L->top, val); - incr_top(L); - } - return name; -} - -LUA_API void *lua_upvalueid(lua_State *L, int idx, int n) -{ - GCfunc *fn = funcV(index2adr(L, idx)); - n--; - api_check(L, (uint32_t)n < fn->l.nupvalues); - return isluafunc(fn) ? (void *)gcref(fn->l.uvptr[n]) : - (void *)&fn->c.upvalue[n]; -} - -LUA_API void lua_upvaluejoin(lua_State *L, int idx1, int n1, int idx2, int n2) -{ - GCfunc *fn1 = funcV(index2adr(L, idx1)); - GCfunc *fn2 = funcV(index2adr(L, idx2)); - n1--; n2--; - api_check(L, isluafunc(fn1) && (uint32_t)n1 < fn1->l.nupvalues); - api_check(L, isluafunc(fn2) && (uint32_t)n2 < fn2->l.nupvalues); - setgcrefr(fn1->l.uvptr[n1], fn2->l.uvptr[n2]); - lj_gc_objbarrier(L, fn1, gcref(fn1->l.uvptr[n1])); -} - -LUALIB_API void *luaL_checkudata(lua_State *L, int idx, const char *tname) -{ - cTValue *o = index2adr(L, idx); - if (tvisudata(o)) { - GCudata *ud = udataV(o); - cTValue *tv = lj_tab_getstr(tabV(registry(L)), lj_str_newz(L, tname)); - if (tv && tvistab(tv) && tabV(tv) == tabref(ud->metatable)) - return uddata(ud); - } - lj_err_argtype(L, idx, tname); - return NULL; /* unreachable */ -} - -/* -- Object setters ------------------------------------------------------ */ - -LUA_API void lua_settable(lua_State *L, int idx) -{ - TValue *o; - cTValue *t = index2adr(L, idx); - api_checknelems(L, 2); - api_checkvalidindex(L, t); - o = lj_meta_tset(L, t, L->top-2); - if (o) { - /* NOBARRIER: lj_meta_tset ensures the table is not black. */ - copyTV(L, o, L->top-1); - L->top -= 2; - } else { - L->top += 3; - copyTV(L, L->top-1, L->top-6); - lj_vm_call(L, L->top-3, 0+1); - L->top -= 3; - } -} - -LUA_API void lua_setfield(lua_State *L, int idx, const char *k) -{ - TValue *o; - TValue key; - cTValue *t = index2adr(L, idx); - api_checknelems(L, 1); - api_checkvalidindex(L, t); - setstrV(L, &key, lj_str_newz(L, k)); - o = lj_meta_tset(L, t, &key); - if (o) { - L->top--; - /* NOBARRIER: lj_meta_tset ensures the table is not black. */ - copyTV(L, o, L->top); - } else { - L->top += 3; - copyTV(L, L->top-1, L->top-6); - lj_vm_call(L, L->top-3, 0+1); - L->top -= 2; - } -} - -LUA_API void lua_rawset(lua_State *L, int idx) -{ - GCtab *t = tabV(index2adr(L, idx)); - TValue *dst, *key; - api_checknelems(L, 2); - key = L->top-2; - dst = lj_tab_set(L, t, key); - copyTV(L, dst, key+1); - lj_gc_anybarriert(L, t); - L->top = key; -} - -LUA_API void lua_rawseti(lua_State *L, int idx, int n) -{ - GCtab *t = tabV(index2adr(L, idx)); - TValue *dst, *src; - api_checknelems(L, 1); - dst = lj_tab_setint(L, t, n); - src = L->top-1; - copyTV(L, dst, src); - lj_gc_barriert(L, t, dst); - L->top = src; -} - -LUA_API int lua_setmetatable(lua_State *L, int idx) -{ - global_State *g; - GCtab *mt; - cTValue *o = index2adr(L, idx); - api_checknelems(L, 1); - api_checkvalidindex(L, o); - if (tvisnil(L->top-1)) { - mt = NULL; - } else { - api_check(L, tvistab(L->top-1)); - mt = tabV(L->top-1); - } - g = G(L); - if (tvistab(o)) { - setgcref(tabV(o)->metatable, obj2gco(mt)); - if (mt) - lj_gc_objbarriert(L, tabV(o), mt); - } else if (tvisudata(o)) { - setgcref(udataV(o)->metatable, obj2gco(mt)); - if (mt) - lj_gc_objbarrier(L, udataV(o), mt); - } else { - /* Flush cache, since traces specialize to basemt. But not during __gc. */ - if (lj_trace_flushall(L)) - lj_err_caller(L, LJ_ERR_NOGCMM); - if (tvisbool(o)) { - /* NOBARRIER: basemt is a GC root. */ - setgcref(basemt_it(g, LJ_TTRUE), obj2gco(mt)); - setgcref(basemt_it(g, LJ_TFALSE), obj2gco(mt)); - } else { - /* NOBARRIER: basemt is a GC root. */ - setgcref(basemt_obj(g, o), obj2gco(mt)); - } - } - L->top--; - return 1; -} - -LUA_API int lua_setfenv(lua_State *L, int idx) -{ - cTValue *o = index2adr(L, idx); - GCtab *t; - api_checknelems(L, 1); - api_checkvalidindex(L, o); - api_check(L, tvistab(L->top-1)); - t = tabV(L->top-1); - if (tvisfunc(o)) { - setgcref(funcV(o)->c.env, obj2gco(t)); - } else if (tvisudata(o)) { - setgcref(udataV(o)->env, obj2gco(t)); - } else if (tvisthread(o)) { - setgcref(threadV(o)->env, obj2gco(t)); - } else { - L->top--; - return 0; - } - lj_gc_objbarrier(L, gcV(o), t); - L->top--; - return 1; -} - -LUA_API const char *lua_setupvalue(lua_State *L, int idx, int n) -{ - cTValue *f = index2adr(L, idx); - TValue *val; - const char *name; - api_checknelems(L, 1); - name = lj_debug_uvnamev(f, (uint32_t)(n-1), &val); - if (name) { - L->top--; - copyTV(L, val, L->top); - lj_gc_barrier(L, funcV(f), L->top); - } - return name; -} - -/* -- Calls --------------------------------------------------------------- */ - -LUA_API void lua_call(lua_State *L, int nargs, int nresults) -{ - api_check(L, L->status == 0 || L->status == LUA_ERRERR); - api_checknelems(L, nargs+1); - lj_vm_call(L, L->top - nargs, nresults+1); -} - -LUA_API int lua_pcall(lua_State *L, int nargs, int nresults, int errfunc) -{ - global_State *g = G(L); - uint8_t oldh = hook_save(g); - ptrdiff_t ef; - int status; - api_check(L, L->status == 0 || L->status == LUA_ERRERR); - api_checknelems(L, nargs+1); - if (errfunc == 0) { - ef = 0; - } else { - cTValue *o = stkindex2adr(L, errfunc); - api_checkvalidindex(L, o); - ef = savestack(L, o); - } - status = lj_vm_pcall(L, L->top - nargs, nresults+1, ef); - if (status) hook_restore(g, oldh); - return status; -} - -static TValue *cpcall(lua_State *L, lua_CFunction func, void *ud) -{ - GCfunc *fn = lj_func_newC(L, 0, getcurrenv(L)); - fn->c.f = func; - setfuncV(L, L->top, fn); - setlightudV(L->top+1, checklightudptr(L, ud)); - cframe_nres(L->cframe) = 1+0; /* Zero results. */ - L->top += 2; - return L->top-1; /* Now call the newly allocated C function. */ -} - -LUA_API int lua_cpcall(lua_State *L, lua_CFunction func, void *ud) -{ - global_State *g = G(L); - uint8_t oldh = hook_save(g); - int status; - api_check(L, L->status == 0 || L->status == LUA_ERRERR); - status = lj_vm_cpcall(L, func, ud, cpcall); - if (status) hook_restore(g, oldh); - return status; -} - -LUALIB_API int luaL_callmeta(lua_State *L, int idx, const char *field) -{ - if (luaL_getmetafield(L, idx, field)) { - TValue *base = L->top--; - copyTV(L, base, index2adr(L, idx)); - L->top = base+1; - lj_vm_call(L, base, 1+1); - return 1; - } - return 0; -} - -/* -- Coroutine yield and resume ------------------------------------------ */ - -LUA_API int lua_yield(lua_State *L, int nresults) -{ - void *cf = L->cframe; - global_State *g = G(L); - if (cframe_canyield(cf)) { - cf = cframe_raw(cf); - if (!hook_active(g)) { /* Regular yield: move results down if needed. */ - cTValue *f = L->top - nresults; - if (f > L->base) { - TValue *t = L->base; - while (--nresults >= 0) copyTV(L, t++, f++); - L->top = t; - } - L->cframe = NULL; - L->status = LUA_YIELD; - return -1; - } else { /* Yield from hook: add a pseudo-frame. */ - TValue *top = L->top; - hook_leave(g); - top->u64 = cframe_multres(cf); - setcont(top+1, lj_cont_hook); - setframe_pc(top+1, cframe_pc(cf)-1); - setframe_gc(top+2, obj2gco(L)); - setframe_ftsz(top+2, (int)((char *)(top+3)-(char *)L->base)+FRAME_CONT); - L->top = L->base = top+3; -#if LJ_TARGET_X64 - lj_err_throw(L, LUA_YIELD); -#else - L->cframe = NULL; - L->status = LUA_YIELD; - lj_vm_unwind_c(cf, LUA_YIELD); -#endif - } - } - lj_err_msg(L, LJ_ERR_CYIELD); - return 0; /* unreachable */ -} - -LUA_API int lua_resume(lua_State *L, int nargs) -{ - if (L->cframe == NULL && L->status <= LUA_YIELD) - return lj_vm_resume(L, L->top - nargs, 0, 0); - L->top = L->base; - setstrV(L, L->top, lj_err_str(L, LJ_ERR_COSUSP)); - incr_top(L); - return LUA_ERRRUN; -} - -/* -- GC and memory management -------------------------------------------- */ - -LUA_API int lua_gc(lua_State *L, int what, int data) -{ - global_State *g = G(L); - int res = 0; - switch (what) { - case LUA_GCSTOP: - g->gc.threshold = LJ_MAX_MEM; - break; - case LUA_GCRESTART: - g->gc.threshold = data == -1 ? (g->gc.total/100)*g->gc.pause : g->gc.total; - break; - case LUA_GCCOLLECT: - lj_gc_fullgc(L); - break; - case LUA_GCCOUNT: - res = (int)(g->gc.total >> 10); - break; - case LUA_GCCOUNTB: - res = (int)(g->gc.total & 0x3ff); - break; - case LUA_GCSTEP: { - MSize a = (MSize)data << 10; - g->gc.threshold = (a <= g->gc.total) ? (g->gc.total - a) : 0; - while (g->gc.total >= g->gc.threshold) - if (lj_gc_step(L) > 0) { - res = 1; - break; - } - break; - } - case LUA_GCSETPAUSE: - res = (int)(g->gc.pause); - g->gc.pause = (MSize)data; - break; - case LUA_GCSETSTEPMUL: - res = (int)(g->gc.stepmul); - g->gc.stepmul = (MSize)data; - break; - default: - res = -1; /* Invalid option. */ - } - return res; -} - -LUA_API lua_Alloc lua_getallocf(lua_State *L, void **ud) -{ - global_State *g = G(L); - if (ud) *ud = g->allocd; - return g->allocf; -} - -LUA_API void lua_setallocf(lua_State *L, lua_Alloc f, void *ud) -{ - global_State *g = G(L); - g->allocd = ud; - g->allocf = f; -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_arch.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_arch.h deleted file mode 100644 index 0b0720951..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_arch.h +++ /dev/null @@ -1,426 +0,0 @@ -/* -** Target architecture selection. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_ARCH_H -#define _LJ_ARCH_H - -#include "lua.h" - -/* Target endianess. */ -#define LUAJIT_LE 0 -#define LUAJIT_BE 1 - -/* Target architectures. */ -#define LUAJIT_ARCH_X86 1 -#define LUAJIT_ARCH_x86 1 -#define LUAJIT_ARCH_X64 2 -#define LUAJIT_ARCH_x64 2 -#define LUAJIT_ARCH_ARM 3 -#define LUAJIT_ARCH_arm 3 -#define LUAJIT_ARCH_PPC 4 -#define LUAJIT_ARCH_ppc 4 -#define LUAJIT_ARCH_PPCSPE 5 -#define LUAJIT_ARCH_ppcspe 5 -#define LUAJIT_ARCH_MIPS 6 -#define LUAJIT_ARCH_mips 6 - -/* Target OS. */ -#define LUAJIT_OS_OTHER 0 -#define LUAJIT_OS_WINDOWS 1 -#define LUAJIT_OS_LINUX 2 -#define LUAJIT_OS_OSX 3 -#define LUAJIT_OS_BSD 4 -#define LUAJIT_OS_POSIX 5 - -/* Select native target if no target defined. */ -#ifndef LUAJIT_TARGET - -#if defined(__i386) || defined(__i386__) || defined(_M_IX86) -#define LUAJIT_TARGET LUAJIT_ARCH_X86 -#elif defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) -#define LUAJIT_TARGET LUAJIT_ARCH_X64 -#elif defined(__arm__) || defined(__arm) || defined(__ARM__) || defined(__ARM) -#define LUAJIT_TARGET LUAJIT_ARCH_ARM -#elif defined(__ppc__) || defined(__ppc) || defined(__PPC__) || defined(__PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__POWERPC) || defined(_M_PPC) -#ifdef __NO_FPRS__ -#define LUAJIT_TARGET LUAJIT_ARCH_PPCSPE -#else -#define LUAJIT_TARGET LUAJIT_ARCH_PPC -#endif -#elif defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(__MIPS) -#define LUAJIT_TARGET LUAJIT_ARCH_MIPS -#else -#error "No support for this architecture (yet)" -#endif - -#endif - -/* Select native OS if no target OS defined. */ -#ifndef LUAJIT_OS - -#if defined(_WIN32) && !defined(_XBOX_VER) -#define LUAJIT_OS LUAJIT_OS_WINDOWS -#elif defined(__linux__) -#define LUAJIT_OS LUAJIT_OS_LINUX -#elif defined(__MACH__) && defined(__APPLE__) -#define LUAJIT_OS LUAJIT_OS_OSX -#elif (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ - defined(__NetBSD__) || defined(__OpenBSD__)) && !defined(__ORBIS__) -#define LUAJIT_OS LUAJIT_OS_BSD -#elif (defined(__sun__) && defined(__svr4__)) || defined(__CYGWIN__) -#define LUAJIT_OS LUAJIT_OS_POSIX -#else -#define LUAJIT_OS LUAJIT_OS_OTHER -#endif - -#endif - -/* Set target OS properties. */ -#if LUAJIT_OS == LUAJIT_OS_WINDOWS -#define LJ_OS_NAME "Windows" -#elif LUAJIT_OS == LUAJIT_OS_LINUX -#define LJ_OS_NAME "Linux" -#elif LUAJIT_OS == LUAJIT_OS_OSX -#define LJ_OS_NAME "OSX" -#elif LUAJIT_OS == LUAJIT_OS_BSD -#define LJ_OS_NAME "BSD" -#elif LUAJIT_OS == LUAJIT_OS_POSIX -#define LJ_OS_NAME "POSIX" -#else -#define LJ_OS_NAME "Other" -#endif - -#define LJ_TARGET_WINDOWS (LUAJIT_OS == LUAJIT_OS_WINDOWS) -#define LJ_TARGET_LINUX (LUAJIT_OS == LUAJIT_OS_LINUX) -#define LJ_TARGET_OSX (LUAJIT_OS == LUAJIT_OS_OSX) -#define LJ_TARGET_IOS (LJ_TARGET_OSX && LUAJIT_TARGET == LUAJIT_ARCH_ARM) -#define LJ_TARGET_POSIX (LUAJIT_OS > LUAJIT_OS_WINDOWS) -#define LJ_TARGET_DLOPEN LJ_TARGET_POSIX - -#ifdef __CELLOS_LV2__ -#define LJ_TARGET_PS3 1 -#define LJ_TARGET_CONSOLE 1 -#endif - -#ifdef __ORBIS__ -#define LJ_TARGET_PS4 1 -#define LJ_TARGET_CONSOLE 1 -#undef NULL -#define NULL ((void*)0) -#endif - -#if _XBOX_VER >= 200 -#define LJ_TARGET_XBOX360 1 -#define LJ_TARGET_CONSOLE 1 -#endif - -#define LJ_NUMMODE_SINGLE 0 /* Single-number mode only. */ -#define LJ_NUMMODE_SINGLE_DUAL 1 /* Default to single-number mode. */ -#define LJ_NUMMODE_DUAL 2 /* Dual-number mode only. */ -#define LJ_NUMMODE_DUAL_SINGLE 3 /* Default to dual-number mode. */ - -/* Set target architecture properties. */ -#if LUAJIT_TARGET == LUAJIT_ARCH_X86 - -#define LJ_ARCH_NAME "x86" -#define LJ_ARCH_BITS 32 -#define LJ_ARCH_ENDIAN LUAJIT_LE -#if LJ_TARGET_WINDOWS || __CYGWIN__ -#define LJ_ABI_WIN 1 -#else -#define LJ_ABI_WIN 0 -#endif -#define LJ_TARGET_X86 1 -#define LJ_TARGET_X86ORX64 1 -#define LJ_TARGET_EHRETREG 0 -#define LJ_TARGET_MASKSHIFT 1 -#define LJ_TARGET_MASKROT 1 -#define LJ_TARGET_UNALIGNED 1 -#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE_DUAL - -#elif LUAJIT_TARGET == LUAJIT_ARCH_X64 - -#define LJ_ARCH_NAME "x64" -#define LJ_ARCH_BITS 64 -#define LJ_ARCH_ENDIAN LUAJIT_LE -#define LJ_ABI_WIN LJ_TARGET_WINDOWS -#define LJ_TARGET_X64 1 -#define LJ_TARGET_X86ORX64 1 -#define LJ_TARGET_EHRETREG 0 -#define LJ_TARGET_JUMPRANGE 31 /* +-2^31 = +-2GB */ -#define LJ_TARGET_MASKSHIFT 1 -#define LJ_TARGET_MASKROT 1 -#define LJ_TARGET_UNALIGNED 1 -#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE_DUAL - -#elif LUAJIT_TARGET == LUAJIT_ARCH_ARM - -#define LJ_ARCH_NAME "arm" -#define LJ_ARCH_BITS 32 -#define LJ_ARCH_ENDIAN LUAJIT_LE -#if !defined(LJ_ARCH_HASFPU) && __SOFTFP__ -#define LJ_ARCH_HASFPU 0 -#endif -#if !defined(LJ_ABI_SOFTFP) && !__ARM_PCS_VFP -#define LJ_ABI_SOFTFP 1 -#endif -#define LJ_ABI_EABI 1 -#define LJ_TARGET_ARM 1 -#define LJ_TARGET_EHRETREG 0 -#define LJ_TARGET_JUMPRANGE 25 /* +-2^25 = +-32MB */ -#define LJ_TARGET_MASKSHIFT 0 -#define LJ_TARGET_MASKROT 1 -#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */ -#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL - -#if __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH_7S__ -#define LJ_ARCH_VERSION 70 -#elif __ARM_ARCH_6T2__ -#define LJ_ARCH_VERSION 61 -#elif __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6K__ || __ARM_ARCH_6Z__ || __ARM_ARCH_6ZK__ -#define LJ_ARCH_VERSION 60 -#else -#define LJ_ARCH_VERSION 50 -#endif - -#elif LUAJIT_TARGET == LUAJIT_ARCH_PPC - -#define LJ_ARCH_NAME "ppc" -#if _LP64 -#define LJ_ARCH_BITS 64 -#else -#define LJ_ARCH_BITS 32 -#endif -#define LJ_ARCH_ENDIAN LUAJIT_BE -#define LJ_TARGET_PPC 1 -#define LJ_TARGET_EHRETREG 3 -#define LJ_TARGET_JUMPRANGE 25 /* +-2^25 = +-32MB */ -#define LJ_TARGET_MASKSHIFT 0 -#define LJ_TARGET_MASKROT 1 -#define LJ_TARGET_UNIFYROT 1 /* Want only IR_BROL. */ -#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL_SINGLE - -#if _ARCH_PWR7 -#define LJ_ARCH_VERSION 70 -#elif _ARCH_PWR6 -#define LJ_ARCH_VERSION 60 -#elif _ARCH_PWR5X -#define LJ_ARCH_VERSION 51 -#elif _ARCH_PWR5 -#define LJ_ARCH_VERSION 50 -#elif _ARCH_PWR4 -#define LJ_ARCH_VERSION 40 -#else -#define LJ_ARCH_VERSION 0 -#endif -#if __PPC64__ || __powerpc64__ || LJ_TARGET_CONSOLE -#define LJ_ARCH_PPC64 1 -#define LJ_ARCH_NOFFI 1 -#endif -#if _ARCH_PPCSQ -#define LJ_ARCH_SQRT 1 -#endif -#if _ARCH_PWR5X -#define LJ_ARCH_ROUND 1 -#endif -#if __PPU__ -#define LJ_ARCH_CELL 1 -#endif -#if LJ_TARGET_XBOX360 -#define LJ_ARCH_XENON 1 -#endif - -#elif LUAJIT_TARGET == LUAJIT_ARCH_PPCSPE - -#define LJ_ARCH_NAME "ppcspe" -#define LJ_ARCH_BITS 32 -#define LJ_ARCH_ENDIAN LUAJIT_BE -#ifndef LJ_ABI_SOFTFP -#define LJ_ABI_SOFTFP 1 -#endif -#define LJ_ABI_EABI 1 -#define LJ_TARGET_PPCSPE 1 -#define LJ_TARGET_EHRETREG 3 -#define LJ_TARGET_JUMPRANGE 25 /* +-2^25 = +-32MB */ -#define LJ_TARGET_MASKSHIFT 0 -#define LJ_TARGET_MASKROT 1 -#define LJ_TARGET_UNIFYROT 1 /* Want only IR_BROL. */ -#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE -#define LJ_ARCH_NOFFI 1 /* NYI: comparisons, calls. */ -#define LJ_ARCH_NOJIT 1 - -#elif LUAJIT_TARGET == LUAJIT_ARCH_MIPS - -#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) -#define LJ_ARCH_NAME "mipsel" -#define LJ_ARCH_ENDIAN LUAJIT_LE -#else -#define LJ_ARCH_NAME "mips" -#define LJ_ARCH_ENDIAN LUAJIT_BE -#endif -#define LJ_ARCH_BITS 32 -#define LJ_TARGET_MIPS 1 -#define LJ_TARGET_EHRETREG 4 -#define LJ_TARGET_JUMPRANGE 27 /* 2*2^27 = 256MB-aligned region */ -#define LJ_TARGET_MASKSHIFT 1 -#define LJ_TARGET_MASKROT 1 -#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */ -#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE - -#if _MIPS_ARCH_MIPS32R2 -#define LJ_ARCH_VERSION 20 -#else -#define LJ_ARCH_VERSION 10 -#endif - -#else -#error "No target architecture defined" -#endif - -#ifndef LJ_PAGESIZE -#define LJ_PAGESIZE 4096 -#endif - -/* Check for minimum required compiler versions. */ -#if defined(__GNUC__) -#if LJ_TARGET_X86 -#if (__GNUC__ < 3) || ((__GNUC__ == 3) && __GNUC_MINOR__ < 4) -#error "Need at least GCC 3.4 or newer" -#endif -#elif LJ_TARGET_X64 -#if __GNUC__ < 4 -#error "Need at least GCC 4.0 or newer" -#endif -#elif LJ_TARGET_ARM || LJ_TARGET_PPC -#if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 2) -#error "Need at least GCC 4.2 or newer" -#endif -#elif !LJ_TARGET_PS3 -#if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 3) -#error "Need at least GCC 4.3 or newer" -#endif -#endif -#endif - -/* Check target-specific constraints. */ -#ifndef _BUILDVM_H -#if LJ_TARGET_X64 -#if __USING_SJLJ_EXCEPTIONS__ -#error "Need a C compiler with native exception handling on x64" -#endif -#elif LJ_TARGET_ARM -#if defined(__ARMEB__) -#error "No support for big-endian ARM" -#endif -#if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__ -#error "No support for Cortex-M CPUs" -#endif -#if !(__ARM_EABI__ || LJ_TARGET_IOS) -#error "Only ARM EABI or iOS 3.0+ ABI is supported" -#endif -#elif LJ_TARGET_PPC || LJ_TARGET_PPCSPE -#if defined(_SOFT_FLOAT) || defined(_SOFT_DOUBLE) -#error "No support for PowerPC CPUs without double-precision FPU" -#endif -#if defined(_LITTLE_ENDIAN) -#error "No support for little-endian PowerPC" -#endif -#if defined(_LP64) -#error "No support for PowerPC 64 bit mode" -#endif -#elif LJ_TARGET_MIPS -#if defined(__mips_soft_float) -#error "No support for MIPS CPUs without FPU" -#endif -#endif -#endif - -/* Enable or disable the dual-number mode for the VM. */ -#if (LJ_ARCH_NUMMODE == LJ_NUMMODE_SINGLE && LUAJIT_NUMMODE == 2) || \ - (LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL && LUAJIT_NUMMODE == 1) -#error "No support for this number mode on this architecture" -#endif -#if LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL || \ - (LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL_SINGLE && LUAJIT_NUMMODE != 1) || \ - (LJ_ARCH_NUMMODE == LJ_NUMMODE_SINGLE_DUAL && LUAJIT_NUMMODE == 2) -#define LJ_DUALNUM 1 -#else -#define LJ_DUALNUM 0 -#endif - -#if LJ_TARGET_IOS || LJ_TARGET_CONSOLE -/* Runtime code generation is restricted on iOS. Complain to Apple, not me. */ -/* Ditto for the consoles. Complain to Sony or MS, not me. */ -#ifndef LUAJIT_ENABLE_JIT -#define LJ_OS_NOJIT 1 -#endif -#endif - -/* Disable or enable the JIT compiler. */ -#if defined(LUAJIT_DISABLE_JIT) || defined(LJ_ARCH_NOJIT) || defined(LJ_OS_NOJIT) -#define LJ_HASJIT 0 -#else -#define LJ_HASJIT 1 -#endif - -/* Disable or enable the FFI extension. */ -#if defined(LUAJIT_DISABLE_FFI) || defined(LJ_ARCH_NOFFI) -#define LJ_HASFFI 0 -#else -#define LJ_HASFFI 1 -#endif - -#ifndef LJ_ARCH_HASFPU -#define LJ_ARCH_HASFPU 1 -#endif -#ifndef LJ_ABI_SOFTFP -#define LJ_ABI_SOFTFP 0 -#endif -#define LJ_SOFTFP (!LJ_ARCH_HASFPU) - -#if LJ_ARCH_ENDIAN == LUAJIT_BE -#define LJ_LE 0 -#define LJ_BE 1 -#define LJ_ENDIAN_SELECT(le, be) be -#define LJ_ENDIAN_LOHI(lo, hi) hi lo -#else -#define LJ_LE 1 -#define LJ_BE 0 -#define LJ_ENDIAN_SELECT(le, be) le -#define LJ_ENDIAN_LOHI(lo, hi) lo hi -#endif - -#if LJ_ARCH_BITS == 32 -#define LJ_32 1 -#define LJ_64 0 -#else -#define LJ_32 0 -#define LJ_64 1 -#endif - -#ifndef LJ_TARGET_UNALIGNED -#define LJ_TARGET_UNALIGNED 0 -#endif - -/* Various workarounds for embedded operating systems. */ -#if (defined(__ANDROID__) && !defined(LJ_TARGET_X86ORX64)) || defined(__symbian__) || LJ_TARGET_XBOX360 -#define LUAJIT_NO_LOG2 -#endif -#if defined(__symbian__) -#define LUAJIT_NO_EXP2 -#endif - -#if defined(LUAJIT_NO_UNWIND) || defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3 -#define LJ_NO_UNWIND 1 -#endif - -/* Compatibility with Lua 5.1 vs. 5.2. */ -#ifdef LUAJIT_ENABLE_LUA52COMPAT -#define LJ_52 1 -#else -#define LJ_52 0 -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_asm.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_asm.c deleted file mode 100644 index 264649aeb..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_asm.c +++ /dev/null @@ -1,1914 +0,0 @@ -/* -** IR assembler (SSA IR -> machine code). -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_asm_c -#define LUA_CORE - -#include "lj_obj.h" - -#if LJ_HASJIT - -#include "lj_gc.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_frame.h" -#if LJ_HASFFI -#include "lj_ctype.h" -#endif -#include "lj_ir.h" -#include "lj_jit.h" -#include "lj_ircall.h" -#include "lj_iropt.h" -#include "lj_mcode.h" -#include "lj_iropt.h" -#include "lj_trace.h" -#include "lj_snap.h" -#include "lj_asm.h" -#include "lj_dispatch.h" -#include "lj_vm.h" -#include "lj_target.h" - -#ifdef LUA_USE_ASSERT -#include -#endif - -/* -- Assembler state and common macros ----------------------------------- */ - -/* Assembler state. */ -typedef struct ASMState { - RegCost cost[RID_MAX]; /* Reference and blended allocation cost for regs. */ - - MCode *mcp; /* Current MCode pointer (grows down). */ - MCode *mclim; /* Lower limit for MCode memory + red zone. */ -#ifdef LUA_USE_ASSERT - MCode *mcp_prev; /* Red zone overflow check. */ -#endif - - IRIns *ir; /* Copy of pointer to IR instructions/constants. */ - jit_State *J; /* JIT compiler state. */ - -#if LJ_TARGET_X86ORX64 - x86ModRM mrm; /* Fused x86 address operand. */ -#endif - - RegSet freeset; /* Set of free registers. */ - RegSet modset; /* Set of registers modified inside the loop. */ - RegSet weakset; /* Set of weakly referenced registers. */ - RegSet phiset; /* Set of PHI registers. */ - - uint32_t flags; /* Copy of JIT compiler flags. */ - int loopinv; /* Loop branch inversion (0:no, 1:yes, 2:yes+CC_P). */ - - int32_t evenspill; /* Next even spill slot. */ - int32_t oddspill; /* Next odd spill slot (or 0). */ - - IRRef curins; /* Reference of current instruction. */ - IRRef stopins; /* Stop assembly before hitting this instruction. */ - IRRef orignins; /* Original T->nins. */ - - IRRef snapref; /* Current snapshot is active after this reference. */ - IRRef snaprename; /* Rename highwater mark for snapshot check. */ - SnapNo snapno; /* Current snapshot number. */ - SnapNo loopsnapno; /* Loop snapshot number. */ - - IRRef fuseref; /* Fusion limit (loopref, 0 or FUSE_DISABLED). */ - IRRef sectref; /* Section base reference (loopref or 0). */ - IRRef loopref; /* Reference of LOOP instruction (or 0). */ - - BCReg topslot; /* Number of slots for stack check (unless 0). */ - int32_t gcsteps; /* Accumulated number of GC steps (per section). */ - - GCtrace *T; /* Trace to assemble. */ - GCtrace *parent; /* Parent trace (or NULL). */ - - MCode *mcbot; /* Bottom of reserved MCode. */ - MCode *mctop; /* Top of generated MCode. */ - MCode *mcloop; /* Pointer to loop MCode (or NULL). */ - MCode *invmcp; /* Points to invertible loop branch (or NULL). */ - MCode *flagmcp; /* Pending opportunity to merge flag setting ins. */ - MCode *realign; /* Realign loop if not NULL. */ - -#ifdef RID_NUM_KREF - int32_t krefk[RID_NUM_KREF]; -#endif - IRRef1 phireg[RID_MAX]; /* PHI register references. */ - uint16_t parentmap[LJ_MAX_JSLOTS]; /* Parent instruction to RegSP map. */ -} ASMState; - -#define IR(ref) (&as->ir[(ref)]) - -#define ASMREF_TMP1 REF_TRUE /* Temp. register. */ -#define ASMREF_TMP2 REF_FALSE /* Temp. register. */ -#define ASMREF_L REF_NIL /* Stores register for L. */ - -/* Check for variant to invariant references. */ -#define iscrossref(as, ref) ((ref) < as->sectref) - -/* Inhibit memory op fusion from variant to invariant references. */ -#define FUSE_DISABLED (~(IRRef)0) -#define mayfuse(as, ref) ((ref) > as->fuseref) -#define neverfuse(as) (as->fuseref == FUSE_DISABLED) -#define canfuse(as, ir) (!neverfuse(as) && !irt_isphi((ir)->t)) -#define opisfusableload(o) \ - ((o) == IR_ALOAD || (o) == IR_HLOAD || (o) == IR_ULOAD || \ - (o) == IR_FLOAD || (o) == IR_XLOAD || (o) == IR_SLOAD || (o) == IR_VLOAD) - -/* Sparse limit checks using a red zone before the actual limit. */ -#define MCLIM_REDZONE 64 - -static LJ_NORET LJ_NOINLINE void asm_mclimit(ASMState *as) -{ - lj_mcode_limiterr(as->J, (size_t)(as->mctop - as->mcp + 4*MCLIM_REDZONE)); -} - -static LJ_AINLINE void checkmclim(ASMState *as) -{ -#ifdef LUA_USE_ASSERT - if (as->mcp + MCLIM_REDZONE < as->mcp_prev) { - IRIns *ir = IR(as->curins+1); - fprintf(stderr, "RED ZONE OVERFLOW: %p IR %04d %02d %04d %04d\n", as->mcp, - as->curins+1-REF_BIAS, ir->o, ir->op1-REF_BIAS, ir->op2-REF_BIAS); - lua_assert(0); - } -#endif - if (LJ_UNLIKELY(as->mcp < as->mclim)) asm_mclimit(as); -#ifdef LUA_USE_ASSERT - as->mcp_prev = as->mcp; -#endif -} - -#ifdef RID_NUM_KREF -#define ra_iskref(ref) ((ref) < RID_NUM_KREF) -#define ra_krefreg(ref) ((Reg)(RID_MIN_KREF + (Reg)(ref))) -#define ra_krefk(as, ref) (as->krefk[(ref)]) - -static LJ_AINLINE void ra_setkref(ASMState *as, Reg r, int32_t k) -{ - IRRef ref = (IRRef)(r - RID_MIN_KREF); - as->krefk[ref] = k; - as->cost[r] = REGCOST(ref, ref); -} - -#else -#define ra_iskref(ref) 0 -#define ra_krefreg(ref) RID_MIN_GPR -#define ra_krefk(as, ref) 0 -#endif - -/* Arch-specific field offsets. */ -static const uint8_t field_ofs[IRFL__MAX+1] = { -#define FLOFS(name, ofs) (uint8_t)(ofs), -IRFLDEF(FLOFS) -#undef FLOFS - 0 -}; - -/* -- Target-specific instruction emitter --------------------------------- */ - -#if LJ_TARGET_X86ORX64 -#include "lj_emit_x86.h" -#elif LJ_TARGET_ARM -#include "lj_emit_arm.h" -#elif LJ_TARGET_PPC -#include "lj_emit_ppc.h" -#elif LJ_TARGET_MIPS -#include "lj_emit_mips.h" -#else -#error "Missing instruction emitter for target CPU" -#endif - -/* -- Register allocator debugging ---------------------------------------- */ - -/* #define LUAJIT_DEBUG_RA */ - -#ifdef LUAJIT_DEBUG_RA - -#include -#include - -#define RIDNAME(name) #name, -static const char *const ra_regname[] = { - GPRDEF(RIDNAME) - FPRDEF(RIDNAME) - VRIDDEF(RIDNAME) - NULL -}; -#undef RIDNAME - -static char ra_dbg_buf[65536]; -static char *ra_dbg_p; -static char *ra_dbg_merge; -static MCode *ra_dbg_mcp; - -static void ra_dstart(void) -{ - ra_dbg_p = ra_dbg_buf; - ra_dbg_merge = NULL; - ra_dbg_mcp = NULL; -} - -static void ra_dflush(void) -{ - fwrite(ra_dbg_buf, 1, (size_t)(ra_dbg_p-ra_dbg_buf), stdout); - ra_dstart(); -} - -static void ra_dprintf(ASMState *as, const char *fmt, ...) -{ - char *p; - va_list argp; - va_start(argp, fmt); - p = ra_dbg_mcp == as->mcp ? ra_dbg_merge : ra_dbg_p; - ra_dbg_mcp = NULL; - p += sprintf(p, "%08x \e[36m%04d ", (uintptr_t)as->mcp, as->curins-REF_BIAS); - for (;;) { - const char *e = strchr(fmt, '$'); - if (e == NULL) break; - memcpy(p, fmt, (size_t)(e-fmt)); - p += e-fmt; - if (e[1] == 'r') { - Reg r = va_arg(argp, Reg) & RID_MASK; - if (r <= RID_MAX) { - const char *q; - for (q = ra_regname[r]; *q; q++) - *p++ = *q >= 'A' && *q <= 'Z' ? *q + 0x20 : *q; - } else { - *p++ = '?'; - lua_assert(0); - } - } else if (e[1] == 'f' || e[1] == 'i') { - IRRef ref; - if (e[1] == 'f') - ref = va_arg(argp, IRRef); - else - ref = va_arg(argp, IRIns *) - as->ir; - if (ref >= REF_BIAS) - p += sprintf(p, "%04d", ref - REF_BIAS); - else - p += sprintf(p, "K%03d", REF_BIAS - ref); - } else if (e[1] == 's') { - uint32_t slot = va_arg(argp, uint32_t); - p += sprintf(p, "[sp+0x%x]", sps_scale(slot)); - } else if (e[1] == 'x') { - p += sprintf(p, "%08x", va_arg(argp, int32_t)); - } else { - lua_assert(0); - } - fmt = e+2; - } - va_end(argp); - while (*fmt) - *p++ = *fmt++; - *p++ = '\e'; *p++ = '['; *p++ = 'm'; *p++ = '\n'; - if (p > ra_dbg_buf+sizeof(ra_dbg_buf)-256) { - fwrite(ra_dbg_buf, 1, (size_t)(p-ra_dbg_buf), stdout); - p = ra_dbg_buf; - } - ra_dbg_p = p; -} - -#define RA_DBG_START() ra_dstart() -#define RA_DBG_FLUSH() ra_dflush() -#define RA_DBG_REF() \ - do { char *_p = ra_dbg_p; ra_dprintf(as, ""); \ - ra_dbg_merge = _p; ra_dbg_mcp = as->mcp; } while (0) -#define RA_DBGX(x) ra_dprintf x - -#else -#define RA_DBG_START() ((void)0) -#define RA_DBG_FLUSH() ((void)0) -#define RA_DBG_REF() ((void)0) -#define RA_DBGX(x) ((void)0) -#endif - -/* -- Register allocator -------------------------------------------------- */ - -#define ra_free(as, r) rset_set(as->freeset, (r)) -#define ra_modified(as, r) rset_set(as->modset, (r)) -#define ra_weak(as, r) rset_set(as->weakset, (r)) -#define ra_noweak(as, r) rset_clear(as->weakset, (r)) - -#define ra_used(ir) (ra_hasreg((ir)->r) || ra_hasspill((ir)->s)) - -/* Setup register allocator. */ -static void ra_setup(ASMState *as) -{ - Reg r; - /* Initially all regs (except the stack pointer) are free for use. */ - as->freeset = RSET_INIT; - as->modset = RSET_EMPTY; - as->weakset = RSET_EMPTY; - as->phiset = RSET_EMPTY; - memset(as->phireg, 0, sizeof(as->phireg)); - for (r = RID_MIN_GPR; r < RID_MAX; r++) - as->cost[r] = REGCOST(~0u, 0u); -} - -/* Rematerialize constants. */ -static Reg ra_rematk(ASMState *as, IRRef ref) -{ - IRIns *ir; - Reg r; - if (ra_iskref(ref)) { - r = ra_krefreg(ref); - lua_assert(!rset_test(as->freeset, r)); - ra_free(as, r); - ra_modified(as, r); - emit_loadi(as, r, ra_krefk(as, ref)); - return r; - } - ir = IR(ref); - r = ir->r; - lua_assert(ra_hasreg(r) && !ra_hasspill(ir->s)); - ra_free(as, r); - ra_modified(as, r); - ir->r = RID_INIT; /* Do not keep any hint. */ - RA_DBGX((as, "remat $i $r", ir, r)); -#if !LJ_SOFTFP - if (ir->o == IR_KNUM) { - emit_loadn(as, r, ir_knum(ir)); - } else -#endif - if (emit_canremat(REF_BASE) && ir->o == IR_BASE) { - ra_sethint(ir->r, RID_BASE); /* Restore BASE register hint. */ - emit_getgl(as, r, jit_base); - } else if (emit_canremat(ASMREF_L) && ir->o == IR_KPRI) { - lua_assert(irt_isnil(ir->t)); /* REF_NIL stores ASMREF_L register. */ - emit_getgl(as, r, jit_L); -#if LJ_64 - } else if (ir->o == IR_KINT64) { - emit_loadu64(as, r, ir_kint64(ir)->u64); -#endif - } else { - lua_assert(ir->o == IR_KINT || ir->o == IR_KGC || - ir->o == IR_KPTR || ir->o == IR_KKPTR || ir->o == IR_KNULL); - emit_loadi(as, r, ir->i); - } - return r; -} - -/* Force a spill. Allocate a new spill slot if needed. */ -static int32_t ra_spill(ASMState *as, IRIns *ir) -{ - int32_t slot = ir->s; - if (!ra_hasspill(slot)) { - if (irt_is64(ir->t)) { - slot = as->evenspill; - as->evenspill += 2; - } else if (as->oddspill) { - slot = as->oddspill; - as->oddspill = 0; - } else { - slot = as->evenspill; - as->oddspill = slot+1; - as->evenspill += 2; - } - if (as->evenspill > 256) - lj_trace_err(as->J, LJ_TRERR_SPILLOV); - ir->s = (uint8_t)slot; - } - return sps_scale(slot); -} - -/* Release the temporarily allocated register in ASMREF_TMP1/ASMREF_TMP2. */ -static Reg ra_releasetmp(ASMState *as, IRRef ref) -{ - IRIns *ir = IR(ref); - Reg r = ir->r; - lua_assert(ra_hasreg(r) && !ra_hasspill(ir->s)); - ra_free(as, r); - ra_modified(as, r); - ir->r = RID_INIT; - return r; -} - -/* Restore a register (marked as free). Rematerialize or force a spill. */ -static Reg ra_restore(ASMState *as, IRRef ref) -{ - if (emit_canremat(ref)) { - return ra_rematk(as, ref); - } else { - IRIns *ir = IR(ref); - int32_t ofs = ra_spill(as, ir); /* Force a spill slot. */ - Reg r = ir->r; - lua_assert(ra_hasreg(r)); - ra_sethint(ir->r, r); /* Keep hint. */ - ra_free(as, r); - if (!rset_test(as->weakset, r)) { /* Only restore non-weak references. */ - ra_modified(as, r); - RA_DBGX((as, "restore $i $r", ir, r)); - emit_spload(as, ir, r, ofs); - } - return r; - } -} - -/* Save a register to a spill slot. */ -static void ra_save(ASMState *as, IRIns *ir, Reg r) -{ - RA_DBGX((as, "save $i $r", ir, r)); - emit_spstore(as, ir, r, sps_scale(ir->s)); -} - -#define MINCOST(name) \ - if (rset_test(RSET_ALL, RID_##name) && \ - LJ_LIKELY(allow&RID2RSET(RID_##name)) && as->cost[RID_##name] < cost) \ - cost = as->cost[RID_##name]; - -/* Evict the register with the lowest cost, forcing a restore. */ -static Reg ra_evict(ASMState *as, RegSet allow) -{ - IRRef ref; - RegCost cost = ~(RegCost)0; - lua_assert(allow != RSET_EMPTY); - if (RID_NUM_FPR == 0 || allow < RID2RSET(RID_MAX_GPR)) { - GPRDEF(MINCOST) - } else { - FPRDEF(MINCOST) - } - ref = regcost_ref(cost); - lua_assert(ra_iskref(ref) || (ref >= as->T->nk && ref < as->T->nins)); - /* Preferably pick any weak ref instead of a non-weak, non-const ref. */ - if (!irref_isk(ref) && (as->weakset & allow)) { - IRIns *ir = IR(ref); - if (!rset_test(as->weakset, ir->r)) - ref = regcost_ref(as->cost[rset_pickbot((as->weakset & allow))]); - } - return ra_restore(as, ref); -} - -/* Pick any register (marked as free). Evict on-demand. */ -static Reg ra_pick(ASMState *as, RegSet allow) -{ - RegSet pick = as->freeset & allow; - if (!pick) - return ra_evict(as, allow); - else - return rset_picktop(pick); -} - -/* Get a scratch register (marked as free). */ -static Reg ra_scratch(ASMState *as, RegSet allow) -{ - Reg r = ra_pick(as, allow); - ra_modified(as, r); - RA_DBGX((as, "scratch $r", r)); - return r; -} - -/* Evict all registers from a set (if not free). */ -static void ra_evictset(ASMState *as, RegSet drop) -{ - RegSet work; - as->modset |= drop; -#if !LJ_SOFTFP - work = (drop & ~as->freeset) & RSET_FPR; - while (work) { - Reg r = rset_pickbot(work); - ra_restore(as, regcost_ref(as->cost[r])); - rset_clear(work, r); - checkmclim(as); - } -#endif - work = (drop & ~as->freeset); - while (work) { - Reg r = rset_pickbot(work); - ra_restore(as, regcost_ref(as->cost[r])); - rset_clear(work, r); - checkmclim(as); - } -} - -/* Evict (rematerialize) all registers allocated to constants. */ -static void ra_evictk(ASMState *as) -{ - RegSet work; -#if !LJ_SOFTFP - work = ~as->freeset & RSET_FPR; - while (work) { - Reg r = rset_pickbot(work); - IRRef ref = regcost_ref(as->cost[r]); - if (emit_canremat(ref) && irref_isk(ref)) { - ra_rematk(as, ref); - checkmclim(as); - } - rset_clear(work, r); - } -#endif - work = ~as->freeset & RSET_GPR; - while (work) { - Reg r = rset_pickbot(work); - IRRef ref = regcost_ref(as->cost[r]); - if (emit_canremat(ref) && irref_isk(ref)) { - ra_rematk(as, ref); - checkmclim(as); - } - rset_clear(work, r); - } -} - -#ifdef RID_NUM_KREF -/* Allocate a register for a constant. */ -static Reg ra_allock(ASMState *as, int32_t k, RegSet allow) -{ - /* First try to find a register which already holds the same constant. */ - RegSet pick, work = ~as->freeset & RSET_GPR; - Reg r; - while (work) { - IRRef ref; - r = rset_pickbot(work); - ref = regcost_ref(as->cost[r]); - if (ref < ASMREF_L && - k == (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i)) - return r; - rset_clear(work, r); - } - pick = as->freeset & allow; - if (pick) { - /* Constants should preferably get unmodified registers. */ - if ((pick & ~as->modset)) - pick &= ~as->modset; - r = rset_pickbot(pick); /* Reduce conflicts with inverse allocation. */ - } else { - r = ra_evict(as, allow); - } - RA_DBGX((as, "allock $x $r", k, r)); - ra_setkref(as, r, k); - rset_clear(as->freeset, r); - ra_noweak(as, r); - return r; -} - -/* Allocate a specific register for a constant. */ -static void ra_allockreg(ASMState *as, int32_t k, Reg r) -{ - Reg kr = ra_allock(as, k, RID2RSET(r)); - if (kr != r) { - IRIns irdummy; - irdummy.t.irt = IRT_INT; - ra_scratch(as, RID2RSET(r)); - emit_movrr(as, &irdummy, r, kr); - } -} -#else -#define ra_allockreg(as, k, r) emit_loadi(as, (r), (k)) -#endif - -/* Allocate a register for ref from the allowed set of registers. -** Note: this function assumes the ref does NOT have a register yet! -** Picks an optimal register, sets the cost and marks the register as non-free. -*/ -static Reg ra_allocref(ASMState *as, IRRef ref, RegSet allow) -{ - IRIns *ir = IR(ref); - RegSet pick = as->freeset & allow; - Reg r; - lua_assert(ra_noreg(ir->r)); - if (pick) { - /* First check register hint from propagation or PHI. */ - if (ra_hashint(ir->r)) { - r = ra_gethint(ir->r); - if (rset_test(pick, r)) /* Use hint register if possible. */ - goto found; - /* Rematerialization is cheaper than missing a hint. */ - if (rset_test(allow, r) && emit_canremat(regcost_ref(as->cost[r]))) { - ra_rematk(as, regcost_ref(as->cost[r])); - goto found; - } - RA_DBGX((as, "hintmiss $f $r", ref, r)); - } - /* Invariants should preferably get unmodified registers. */ - if (ref < as->loopref && !irt_isphi(ir->t)) { - if ((pick & ~as->modset)) - pick &= ~as->modset; - r = rset_pickbot(pick); /* Reduce conflicts with inverse allocation. */ - } else { - /* We've got plenty of regs, so get callee-save regs if possible. */ - if (RID_NUM_GPR > 8 && (pick & ~RSET_SCRATCH)) - pick &= ~RSET_SCRATCH; - r = rset_picktop(pick); - } - } else { - r = ra_evict(as, allow); - } -found: - RA_DBGX((as, "alloc $f $r", ref, r)); - ir->r = (uint8_t)r; - rset_clear(as->freeset, r); - ra_noweak(as, r); - as->cost[r] = REGCOST_REF_T(ref, irt_t(ir->t)); - return r; -} - -/* Allocate a register on-demand. */ -static Reg ra_alloc1(ASMState *as, IRRef ref, RegSet allow) -{ - Reg r = IR(ref)->r; - /* Note: allow is ignored if the register is already allocated. */ - if (ra_noreg(r)) r = ra_allocref(as, ref, allow); - ra_noweak(as, r); - return r; -} - -/* Rename register allocation and emit move. */ -static void ra_rename(ASMState *as, Reg down, Reg up) -{ - IRRef ren, ref = regcost_ref(as->cost[up] = as->cost[down]); - IRIns *ir = IR(ref); - ir->r = (uint8_t)up; - as->cost[down] = 0; - lua_assert((down < RID_MAX_GPR) == (up < RID_MAX_GPR)); - lua_assert(!rset_test(as->freeset, down) && rset_test(as->freeset, up)); - ra_free(as, down); /* 'down' is free ... */ - ra_modified(as, down); - rset_clear(as->freeset, up); /* ... and 'up' is now allocated. */ - ra_noweak(as, up); - RA_DBGX((as, "rename $f $r $r", regcost_ref(as->cost[up]), down, up)); - emit_movrr(as, ir, down, up); /* Backwards codegen needs inverse move. */ - if (!ra_hasspill(IR(ref)->s)) { /* Add the rename to the IR. */ - lj_ir_set(as->J, IRT(IR_RENAME, IRT_NIL), ref, as->snapno); - ren = tref_ref(lj_ir_emit(as->J)); - as->ir = as->T->ir; /* The IR may have been reallocated. */ - IR(ren)->r = (uint8_t)down; - IR(ren)->s = SPS_NONE; - } -} - -/* Pick a destination register (marked as free). -** Caveat: allow is ignored if there's already a destination register. -** Use ra_destreg() to get a specific register. -*/ -static Reg ra_dest(ASMState *as, IRIns *ir, RegSet allow) -{ - Reg dest = ir->r; - if (ra_hasreg(dest)) { - ra_free(as, dest); - ra_modified(as, dest); - } else { - if (ra_hashint(dest) && rset_test((as->freeset&allow), ra_gethint(dest))) { - dest = ra_gethint(dest); - ra_modified(as, dest); - RA_DBGX((as, "dest $r", dest)); - } else { - dest = ra_scratch(as, allow); - } - ir->r = dest; - } - if (LJ_UNLIKELY(ra_hasspill(ir->s))) ra_save(as, ir, dest); - return dest; -} - -/* Force a specific destination register (marked as free). */ -static void ra_destreg(ASMState *as, IRIns *ir, Reg r) -{ - Reg dest = ra_dest(as, ir, RID2RSET(r)); - if (dest != r) { - lua_assert(rset_test(as->freeset, r)); - ra_modified(as, r); - emit_movrr(as, ir, dest, r); - } -} - -#if LJ_TARGET_X86ORX64 -/* Propagate dest register to left reference. Emit moves as needed. -** This is a required fixup step for all 2-operand machine instructions. -*/ -static void ra_left(ASMState *as, Reg dest, IRRef lref) -{ - IRIns *ir = IR(lref); - Reg left = ir->r; - if (ra_noreg(left)) { - if (irref_isk(lref)) { - if (ir->o == IR_KNUM) { - cTValue *tv = ir_knum(ir); - /* FP remat needs a load except for +0. Still better than eviction. */ - if (tvispzero(tv) || !(as->freeset & RSET_FPR)) { - emit_loadn(as, dest, tv); - return; - } -#if LJ_64 - } else if (ir->o == IR_KINT64) { - emit_loadu64(as, dest, ir_kint64(ir)->u64); - return; -#endif - } else { - lua_assert(ir->o == IR_KINT || ir->o == IR_KGC || - ir->o == IR_KPTR || ir->o == IR_KKPTR || ir->o == IR_KNULL); - emit_loadi(as, dest, ir->i); - return; - } - } - if (!ra_hashint(left) && !iscrossref(as, lref)) - ra_sethint(ir->r, dest); /* Propagate register hint. */ - left = ra_allocref(as, lref, dest < RID_MAX_GPR ? RSET_GPR : RSET_FPR); - } - ra_noweak(as, left); - /* Move needed for true 3-operand instruction: y=a+b ==> y=a; y+=b. */ - if (dest != left) { - /* Use register renaming if dest is the PHI reg. */ - if (irt_isphi(ir->t) && as->phireg[dest] == lref) { - ra_modified(as, left); - ra_rename(as, left, dest); - } else { - emit_movrr(as, ir, dest, left); - } - } -} -#else -/* Similar to ra_left, except we override any hints. */ -static void ra_leftov(ASMState *as, Reg dest, IRRef lref) -{ - IRIns *ir = IR(lref); - Reg left = ir->r; - if (ra_noreg(left)) { - ra_sethint(ir->r, dest); /* Propagate register hint. */ - left = ra_allocref(as, lref, - (LJ_SOFTFP || dest < RID_MAX_GPR) ? RSET_GPR : RSET_FPR); - } - ra_noweak(as, left); - if (dest != left) { - /* Use register renaming if dest is the PHI reg. */ - if (irt_isphi(ir->t) && as->phireg[dest] == lref) { - ra_modified(as, left); - ra_rename(as, left, dest); - } else { - emit_movrr(as, ir, dest, left); - } - } -} -#endif - -#if !LJ_64 -/* Force a RID_RETLO/RID_RETHI destination register pair (marked as free). */ -static void ra_destpair(ASMState *as, IRIns *ir) -{ - Reg destlo = ir->r, desthi = (ir+1)->r; - /* First spill unrelated refs blocking the destination registers. */ - if (!rset_test(as->freeset, RID_RETLO) && - destlo != RID_RETLO && desthi != RID_RETLO) - ra_restore(as, regcost_ref(as->cost[RID_RETLO])); - if (!rset_test(as->freeset, RID_RETHI) && - destlo != RID_RETHI && desthi != RID_RETHI) - ra_restore(as, regcost_ref(as->cost[RID_RETHI])); - /* Next free the destination registers (if any). */ - if (ra_hasreg(destlo)) { - ra_free(as, destlo); - ra_modified(as, destlo); - } else { - destlo = RID_RETLO; - } - if (ra_hasreg(desthi)) { - ra_free(as, desthi); - ra_modified(as, desthi); - } else { - desthi = RID_RETHI; - } - /* Check for conflicts and shuffle the registers as needed. */ - if (destlo == RID_RETHI) { - if (desthi == RID_RETLO) { -#if LJ_TARGET_X86 - *--as->mcp = XI_XCHGa + RID_RETHI; -#else - emit_movrr(as, ir, RID_RETHI, RID_TMP); - emit_movrr(as, ir, RID_RETLO, RID_RETHI); - emit_movrr(as, ir, RID_TMP, RID_RETLO); -#endif - } else { - emit_movrr(as, ir, RID_RETHI, RID_RETLO); - if (desthi != RID_RETHI) emit_movrr(as, ir, desthi, RID_RETHI); - } - } else if (desthi == RID_RETLO) { - emit_movrr(as, ir, RID_RETLO, RID_RETHI); - if (destlo != RID_RETLO) emit_movrr(as, ir, destlo, RID_RETLO); - } else { - if (desthi != RID_RETHI) emit_movrr(as, ir, desthi, RID_RETHI); - if (destlo != RID_RETLO) emit_movrr(as, ir, destlo, RID_RETLO); - } - /* Restore spill slots (if any). */ - if (ra_hasspill((ir+1)->s)) ra_save(as, ir+1, RID_RETHI); - if (ra_hasspill(ir->s)) ra_save(as, ir, RID_RETLO); -} -#endif - -/* -- Snapshot handling --------- ----------------------------------------- */ - -/* Can we rematerialize a KNUM instead of forcing a spill? */ -static int asm_snap_canremat(ASMState *as) -{ - Reg r; - for (r = RID_MIN_FPR; r < RID_MAX_FPR; r++) - if (irref_isk(regcost_ref(as->cost[r]))) - return 1; - return 0; -} - -/* Check whether a sunk store corresponds to an allocation. */ -static int asm_sunk_store(ASMState *as, IRIns *ira, IRIns *irs) -{ - if (irs->s == 255) { - if (irs->o == IR_ASTORE || irs->o == IR_HSTORE || - irs->o == IR_FSTORE || irs->o == IR_XSTORE) { - IRIns *irk = IR(irs->op1); - if (irk->o == IR_AREF || irk->o == IR_HREFK) - irk = IR(irk->op1); - return (IR(irk->op1) == ira); - } - return 0; - } else { - return (ira + irs->s == irs); /* Quick check. */ - } -} - -/* Allocate register or spill slot for a ref that escapes to a snapshot. */ -static void asm_snap_alloc1(ASMState *as, IRRef ref) -{ - IRIns *ir = IR(ref); - if (!irref_isk(ref) && (!(ra_used(ir) || ir->r == RID_SUNK))) { - if (ir->r == RID_SINK) { - ir->r = RID_SUNK; -#if LJ_HASFFI - if (ir->o == IR_CNEWI) { /* Allocate CNEWI value. */ - asm_snap_alloc1(as, ir->op2); - if (LJ_32 && (ir+1)->o == IR_HIOP) - asm_snap_alloc1(as, (ir+1)->op2); - } else -#endif - { /* Allocate stored values for TNEW, TDUP and CNEW. */ - IRIns *irs; - lua_assert(ir->o == IR_TNEW || ir->o == IR_TDUP || ir->o == IR_CNEW); - for (irs = IR(as->snapref-1); irs > ir; irs--) - if (irs->r == RID_SINK && asm_sunk_store(as, ir, irs)) { - lua_assert(irs->o == IR_ASTORE || irs->o == IR_HSTORE || - irs->o == IR_FSTORE || irs->o == IR_XSTORE); - asm_snap_alloc1(as, irs->op2); - if (LJ_32 && (irs+1)->o == IR_HIOP) - asm_snap_alloc1(as, (irs+1)->op2); - } - } - } else { - RegSet allow; - if (ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT) { - IRIns *irc; - for (irc = IR(as->curins); irc > ir; irc--) - if ((irc->op1 == ref || irc->op2 == ref) && - !(irc->r == RID_SINK || irc->r == RID_SUNK)) - goto nosink; /* Don't sink conversion if result is used. */ - asm_snap_alloc1(as, ir->op1); - return; - } - nosink: - allow = (!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR; - if ((as->freeset & allow) || - (allow == RSET_FPR && asm_snap_canremat(as))) { - /* Get a weak register if we have a free one or can rematerialize. */ - Reg r = ra_allocref(as, ref, allow); /* Allocate a register. */ - if (!irt_isphi(ir->t)) - ra_weak(as, r); /* But mark it as weakly referenced. */ - checkmclim(as); - RA_DBGX((as, "snapreg $f $r", ref, ir->r)); - } else { - ra_spill(as, ir); /* Otherwise force a spill slot. */ - RA_DBGX((as, "snapspill $f $s", ref, ir->s)); - } - } - } -} - -/* Allocate refs escaping to a snapshot. */ -static void asm_snap_alloc(ASMState *as) -{ - SnapShot *snap = &as->T->snap[as->snapno]; - SnapEntry *map = &as->T->snapmap[snap->mapofs]; - MSize n, nent = snap->nent; - for (n = 0; n < nent; n++) { - SnapEntry sn = map[n]; - IRRef ref = snap_ref(sn); - if (!irref_isk(ref)) { - asm_snap_alloc1(as, ref); - if (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM)) { - lua_assert(irt_type(IR(ref+1)->t) == IRT_SOFTFP); - asm_snap_alloc1(as, ref+1); - } - } - } -} - -/* All guards for a snapshot use the same exitno. This is currently the -** same as the snapshot number. Since the exact origin of the exit cannot -** be determined, all guards for the same snapshot must exit with the same -** RegSP mapping. -** A renamed ref which has been used in a prior guard for the same snapshot -** would cause an inconsistency. The easy way out is to force a spill slot. -*/ -static int asm_snap_checkrename(ASMState *as, IRRef ren) -{ - SnapShot *snap = &as->T->snap[as->snapno]; - SnapEntry *map = &as->T->snapmap[snap->mapofs]; - MSize n, nent = snap->nent; - for (n = 0; n < nent; n++) { - SnapEntry sn = map[n]; - IRRef ref = snap_ref(sn); - if (ref == ren || (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM) && ++ref == ren)) { - IRIns *ir = IR(ref); - ra_spill(as, ir); /* Register renamed, so force a spill slot. */ - RA_DBGX((as, "snaprensp $f $s", ref, ir->s)); - return 1; /* Found. */ - } - } - return 0; /* Not found. */ -} - -/* Prepare snapshot for next guard instruction. */ -static void asm_snap_prep(ASMState *as) -{ - if (as->curins < as->snapref) { - do { - if (as->snapno == 0) return; /* Called by sunk stores before snap #0. */ - as->snapno--; - as->snapref = as->T->snap[as->snapno].ref; - } while (as->curins < as->snapref); - asm_snap_alloc(as); - as->snaprename = as->T->nins; - } else { - /* Process any renames above the highwater mark. */ - for (; as->snaprename < as->T->nins; as->snaprename++) { - IRIns *ir = IR(as->snaprename); - if (asm_snap_checkrename(as, ir->op1)) - ir->op2 = REF_BIAS-1; /* Kill rename. */ - } - } -} - -/* -- Miscellaneous helpers ----------------------------------------------- */ - -/* Collect arguments from CALL* and CARG instructions. */ -static void asm_collectargs(ASMState *as, IRIns *ir, - const CCallInfo *ci, IRRef *args) -{ - uint32_t n = CCI_NARGS(ci); - lua_assert(n <= CCI_NARGS_MAX*2); /* Account for split args. */ - if ((ci->flags & CCI_L)) { *args++ = ASMREF_L; n--; } - while (n-- > 1) { - ir = IR(ir->op1); - lua_assert(ir->o == IR_CARG); - args[n] = ir->op2 == REF_NIL ? 0 : ir->op2; - } - args[0] = ir->op1 == REF_NIL ? 0 : ir->op1; - lua_assert(IR(ir->op1)->o != IR_CARG); -} - -/* Reconstruct CCallInfo flags for CALLX*. */ -static uint32_t asm_callx_flags(ASMState *as, IRIns *ir) -{ - uint32_t nargs = 0; - if (ir->op1 != REF_NIL) { /* Count number of arguments first. */ - IRIns *ira = IR(ir->op1); - nargs++; - while (ira->o == IR_CARG) { nargs++; ira = IR(ira->op1); } - } -#if LJ_HASFFI - if (IR(ir->op2)->o == IR_CARG) { /* Copy calling convention info. */ - CTypeID id = (CTypeID)IR(IR(ir->op2)->op2)->i; - CType *ct = ctype_get(ctype_ctsG(J2G(as->J)), id); - nargs |= ((ct->info & CTF_VARARG) ? CCI_VARARG : 0); -#if LJ_TARGET_X86 - nargs |= (ctype_cconv(ct->info) << CCI_CC_SHIFT); -#endif - } -#endif - return (nargs | (ir->t.irt << CCI_OTSHIFT)); -} - -/* Calculate stack adjustment. */ -static int32_t asm_stack_adjust(ASMState *as) -{ - if (as->evenspill <= SPS_FIXED) - return 0; - return sps_scale(sps_align(as->evenspill)); -} - -/* Must match with hash*() in lj_tab.c. */ -static uint32_t ir_khash(IRIns *ir) -{ - uint32_t lo, hi; - if (irt_isstr(ir->t)) { - return ir_kstr(ir)->hash; - } else if (irt_isnum(ir->t)) { - lo = ir_knum(ir)->u32.lo; - hi = ir_knum(ir)->u32.hi << 1; - } else if (irt_ispri(ir->t)) { - lua_assert(!irt_isnil(ir->t)); - return irt_type(ir->t)-IRT_FALSE; - } else { - lua_assert(irt_isgcv(ir->t)); - lo = u32ptr(ir_kgc(ir)); - hi = lo + HASH_BIAS; - } - return hashrot(lo, hi); -} - -/* -- Allocations --------------------------------------------------------- */ - -static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args); -static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci); - -static void asm_snew(ASMState *as, IRIns *ir) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_new]; - IRRef args[3]; - args[0] = ASMREF_L; /* lua_State *L */ - args[1] = ir->op1; /* const char *str */ - args[2] = ir->op2; /* size_t len */ - as->gcsteps++; - asm_setupresult(as, ir, ci); /* GCstr * */ - asm_gencall(as, ci, args); -} - -static void asm_tnew(ASMState *as, IRIns *ir) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_new1]; - IRRef args[2]; - args[0] = ASMREF_L; /* lua_State *L */ - args[1] = ASMREF_TMP1; /* uint32_t ahsize */ - as->gcsteps++; - asm_setupresult(as, ir, ci); /* GCtab * */ - asm_gencall(as, ci, args); - ra_allockreg(as, ir->op1 | (ir->op2 << 24), ra_releasetmp(as, ASMREF_TMP1)); -} - -static void asm_tdup(ASMState *as, IRIns *ir) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_dup]; - IRRef args[2]; - args[0] = ASMREF_L; /* lua_State *L */ - args[1] = ir->op1; /* const GCtab *kt */ - as->gcsteps++; - asm_setupresult(as, ir, ci); /* GCtab * */ - asm_gencall(as, ci, args); -} - -static void asm_gc_check(ASMState *as); - -/* Explicit GC step. */ -static void asm_gcstep(ASMState *as, IRIns *ir) -{ - IRIns *ira; - for (ira = IR(as->stopins+1); ira < ir; ira++) - if ((ira->o == IR_TNEW || ira->o == IR_TDUP || - (LJ_HASFFI && (ira->o == IR_CNEW || ira->o == IR_CNEWI))) && - ra_used(ira)) - as->gcsteps++; - if (as->gcsteps) - asm_gc_check(as); - as->gcsteps = 0x80000000; /* Prevent implicit GC check further up. */ -} - -/* -- PHI and loop handling ----------------------------------------------- */ - -/* Break a PHI cycle by renaming to a free register (evict if needed). */ -static void asm_phi_break(ASMState *as, RegSet blocked, RegSet blockedby, - RegSet allow) -{ - RegSet candidates = blocked & allow; - if (candidates) { /* If this register file has candidates. */ - /* Note: the set for ra_pick cannot be empty, since each register file - ** has some registers never allocated to PHIs. - */ - Reg down, up = ra_pick(as, ~blocked & allow); /* Get a free register. */ - if (candidates & ~blockedby) /* Optimize shifts, else it's a cycle. */ - candidates = candidates & ~blockedby; - down = rset_picktop(candidates); /* Pick candidate PHI register. */ - ra_rename(as, down, up); /* And rename it to the free register. */ - } -} - -/* PHI register shuffling. -** -** The allocator tries hard to preserve PHI register assignments across -** the loop body. Most of the time this loop does nothing, since there -** are no register mismatches. -** -** If a register mismatch is detected and ... -** - the register is currently free: rename it. -** - the register is blocked by an invariant: restore/remat and rename it. -** - Otherwise the register is used by another PHI, so mark it as blocked. -** -** The renames are order-sensitive, so just retry the loop if a register -** is marked as blocked, but has been freed in the meantime. A cycle is -** detected if all of the blocked registers are allocated. To break the -** cycle rename one of them to a free register and retry. -** -** Note that PHI spill slots are kept in sync and don't need to be shuffled. -*/ -static void asm_phi_shuffle(ASMState *as) -{ - RegSet work; - - /* Find and resolve PHI register mismatches. */ - for (;;) { - RegSet blocked = RSET_EMPTY; - RegSet blockedby = RSET_EMPTY; - RegSet phiset = as->phiset; - while (phiset) { /* Check all left PHI operand registers. */ - Reg r = rset_pickbot(phiset); - IRIns *irl = IR(as->phireg[r]); - Reg left = irl->r; - if (r != left) { /* Mismatch? */ - if (!rset_test(as->freeset, r)) { /* PHI register blocked? */ - IRRef ref = regcost_ref(as->cost[r]); - /* Blocked by other PHI (w/reg)? */ - if (!ra_iskref(ref) && irt_ismarked(IR(ref)->t)) { - rset_set(blocked, r); - if (ra_hasreg(left)) - rset_set(blockedby, left); - left = RID_NONE; - } else { /* Otherwise grab register from invariant. */ - ra_restore(as, ref); - checkmclim(as); - } - } - if (ra_hasreg(left)) { - ra_rename(as, left, r); - checkmclim(as); - } - } - rset_clear(phiset, r); - } - if (!blocked) break; /* Finished. */ - if (!(as->freeset & blocked)) { /* Break cycles if none are free. */ - asm_phi_break(as, blocked, blockedby, RSET_GPR); - if (!LJ_SOFTFP) asm_phi_break(as, blocked, blockedby, RSET_FPR); - checkmclim(as); - } /* Else retry some more renames. */ - } - - /* Restore/remat invariants whose registers are modified inside the loop. */ -#if !LJ_SOFTFP - work = as->modset & ~(as->freeset | as->phiset) & RSET_FPR; - while (work) { - Reg r = rset_pickbot(work); - ra_restore(as, regcost_ref(as->cost[r])); - rset_clear(work, r); - checkmclim(as); - } -#endif - work = as->modset & ~(as->freeset | as->phiset); - while (work) { - Reg r = rset_pickbot(work); - ra_restore(as, regcost_ref(as->cost[r])); - rset_clear(work, r); - checkmclim(as); - } - - /* Allocate and save all unsaved PHI regs and clear marks. */ - work = as->phiset; - while (work) { - Reg r = rset_picktop(work); - IRRef lref = as->phireg[r]; - IRIns *ir = IR(lref); - if (ra_hasspill(ir->s)) { /* Left PHI gained a spill slot? */ - irt_clearmark(ir->t); /* Handled here, so clear marker now. */ - ra_alloc1(as, lref, RID2RSET(r)); - ra_save(as, ir, r); /* Save to spill slot inside the loop. */ - checkmclim(as); - } - rset_clear(work, r); - } -} - -/* Copy unsynced left/right PHI spill slots. Rarely needed. */ -static void asm_phi_copyspill(ASMState *as) -{ - int need = 0; - IRIns *ir; - for (ir = IR(as->orignins-1); ir->o == IR_PHI; ir--) - if (ra_hasspill(ir->s) && ra_hasspill(IR(ir->op1)->s)) - need |= irt_isfp(ir->t) ? 2 : 1; /* Unsynced spill slot? */ - if ((need & 1)) { /* Copy integer spill slots. */ -#if !LJ_TARGET_X86ORX64 - Reg r = RID_TMP; -#else - Reg r = RID_RET; - if ((as->freeset & RSET_GPR)) - r = rset_pickbot((as->freeset & RSET_GPR)); - else - emit_spload(as, IR(regcost_ref(as->cost[r])), r, SPOFS_TMP); -#endif - for (ir = IR(as->orignins-1); ir->o == IR_PHI; ir--) { - if (ra_hasspill(ir->s)) { - IRIns *irl = IR(ir->op1); - if (ra_hasspill(irl->s) && !irt_isfp(ir->t)) { - emit_spstore(as, irl, r, sps_scale(irl->s)); - emit_spload(as, ir, r, sps_scale(ir->s)); - checkmclim(as); - } - } - } -#if LJ_TARGET_X86ORX64 - if (!rset_test(as->freeset, r)) - emit_spstore(as, IR(regcost_ref(as->cost[r])), r, SPOFS_TMP); -#endif - } -#if !LJ_SOFTFP - if ((need & 2)) { /* Copy FP spill slots. */ -#if LJ_TARGET_X86 - Reg r = RID_XMM0; -#else - Reg r = RID_FPRET; -#endif - if ((as->freeset & RSET_FPR)) - r = rset_pickbot((as->freeset & RSET_FPR)); - if (!rset_test(as->freeset, r)) - emit_spload(as, IR(regcost_ref(as->cost[r])), r, SPOFS_TMP); - for (ir = IR(as->orignins-1); ir->o == IR_PHI; ir--) { - if (ra_hasspill(ir->s)) { - IRIns *irl = IR(ir->op1); - if (ra_hasspill(irl->s) && irt_isfp(ir->t)) { - emit_spstore(as, irl, r, sps_scale(irl->s)); - emit_spload(as, ir, r, sps_scale(ir->s)); - checkmclim(as); - } - } - } - if (!rset_test(as->freeset, r)) - emit_spstore(as, IR(regcost_ref(as->cost[r])), r, SPOFS_TMP); - } -#endif -} - -/* Emit renames for left PHIs which are only spilled outside the loop. */ -static void asm_phi_fixup(ASMState *as) -{ - RegSet work = as->phiset; - while (work) { - Reg r = rset_picktop(work); - IRRef lref = as->phireg[r]; - IRIns *ir = IR(lref); - if (irt_ismarked(ir->t)) { - irt_clearmark(ir->t); - /* Left PHI gained a spill slot before the loop? */ - if (ra_hasspill(ir->s)) { - IRRef ren; - lj_ir_set(as->J, IRT(IR_RENAME, IRT_NIL), lref, as->loopsnapno); - ren = tref_ref(lj_ir_emit(as->J)); - as->ir = as->T->ir; /* The IR may have been reallocated. */ - IR(ren)->r = (uint8_t)r; - IR(ren)->s = SPS_NONE; - } - } - rset_clear(work, r); - } -} - -/* Setup right PHI reference. */ -static void asm_phi(ASMState *as, IRIns *ir) -{ - RegSet allow = ((!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR) & - ~as->phiset; - RegSet afree = (as->freeset & allow); - IRIns *irl = IR(ir->op1); - IRIns *irr = IR(ir->op2); - if (ir->r == RID_SINK) /* Sink PHI. */ - return; - /* Spill slot shuffling is not implemented yet (but rarely needed). */ - if (ra_hasspill(irl->s) || ra_hasspill(irr->s)) - lj_trace_err(as->J, LJ_TRERR_NYIPHI); - /* Leave at least one register free for non-PHIs (and PHI cycle breaking). */ - if ((afree & (afree-1))) { /* Two or more free registers? */ - Reg r; - if (ra_noreg(irr->r)) { /* Get a register for the right PHI. */ - r = ra_allocref(as, ir->op2, allow); - } else { /* Duplicate right PHI, need a copy (rare). */ - r = ra_scratch(as, allow); - emit_movrr(as, irr, r, irr->r); - } - ir->r = (uint8_t)r; - rset_set(as->phiset, r); - as->phireg[r] = (IRRef1)ir->op1; - irt_setmark(irl->t); /* Marks left PHIs _with_ register. */ - if (ra_noreg(irl->r)) - ra_sethint(irl->r, r); /* Set register hint for left PHI. */ - } else { /* Otherwise allocate a spill slot. */ - /* This is overly restrictive, but it triggers only on synthetic code. */ - if (ra_hasreg(irl->r) || ra_hasreg(irr->r)) - lj_trace_err(as->J, LJ_TRERR_NYIPHI); - ra_spill(as, ir); - irr->s = ir->s; /* Set right PHI spill slot. Sync left slot later. */ - } -} - -static void asm_loop_fixup(ASMState *as); - -/* Middle part of a loop. */ -static void asm_loop(ASMState *as) -{ - MCode *mcspill; - /* LOOP is a guard, so the snapno is up to date. */ - as->loopsnapno = as->snapno; - if (as->gcsteps) - asm_gc_check(as); - /* LOOP marks the transition from the variant to the invariant part. */ - as->flagmcp = as->invmcp = NULL; - as->sectref = 0; - if (!neverfuse(as)) as->fuseref = 0; - asm_phi_shuffle(as); - mcspill = as->mcp; - asm_phi_copyspill(as); - asm_loop_fixup(as); - as->mcloop = as->mcp; - RA_DBGX((as, "===== LOOP =====")); - if (!as->realign) RA_DBG_FLUSH(); - if (as->mcp != mcspill) - emit_jmp(as, mcspill); -} - -/* -- Target-specific assembler ------------------------------------------- */ - -#if LJ_TARGET_X86ORX64 -#include "lj_asm_x86.h" -#elif LJ_TARGET_ARM -#include "lj_asm_arm.h" -#elif LJ_TARGET_PPC -#include "lj_asm_ppc.h" -#elif LJ_TARGET_MIPS -#include "lj_asm_mips.h" -#else -#error "Missing assembler for target CPU" -#endif - -/* -- Head of trace ------------------------------------------------------- */ - -/* Head of a root trace. */ -static void asm_head_root(ASMState *as) -{ - int32_t spadj; - asm_head_root_base(as); - emit_setvmstate(as, (int32_t)as->T->traceno); - spadj = asm_stack_adjust(as); - as->T->spadjust = (uint16_t)spadj; - emit_spsub(as, spadj); - /* Root traces assume a checked stack for the starting proto. */ - as->T->topslot = gcref(as->T->startpt)->pt.framesize; -} - -/* Head of a side trace. -** -** The current simplistic algorithm requires that all slots inherited -** from the parent are live in a register between pass 2 and pass 3. This -** avoids the complexity of stack slot shuffling. But of course this may -** overflow the register set in some cases and cause the dreaded error: -** "NYI: register coalescing too complex". A refined algorithm is needed. -*/ -static void asm_head_side(ASMState *as) -{ - IRRef1 sloadins[RID_MAX]; - RegSet allow = RSET_ALL; /* Inverse of all coalesced registers. */ - RegSet live = RSET_EMPTY; /* Live parent registers. */ - IRIns *irp = &as->parent->ir[REF_BASE]; /* Parent base. */ - int32_t spadj, spdelta; - int pass2 = 0; - int pass3 = 0; - IRRef i; - - allow = asm_head_side_base(as, irp, allow); - - /* Scan all parent SLOADs and collect register dependencies. */ - for (i = as->stopins; i > REF_BASE; i--) { - IRIns *ir = IR(i); - RegSP rs; - lua_assert((ir->o == IR_SLOAD && (ir->op2 & IRSLOAD_PARENT)) || - (LJ_SOFTFP && ir->o == IR_HIOP) || ir->o == IR_PVAL); - rs = as->parentmap[i - REF_FIRST]; - if (ra_hasreg(ir->r)) { - rset_clear(allow, ir->r); - if (ra_hasspill(ir->s)) { - ra_save(as, ir, ir->r); - checkmclim(as); - } - } else if (ra_hasspill(ir->s)) { - irt_setmark(ir->t); - pass2 = 1; - } - if (ir->r == rs) { /* Coalesce matching registers right now. */ - ra_free(as, ir->r); - } else if (ra_hasspill(regsp_spill(rs))) { - if (ra_hasreg(ir->r)) - pass3 = 1; - } else if (ra_used(ir)) { - sloadins[rs] = (IRRef1)i; - rset_set(live, rs); /* Block live parent register. */ - } - } - - /* Calculate stack frame adjustment. */ - spadj = asm_stack_adjust(as); - spdelta = spadj - (int32_t)as->parent->spadjust; - if (spdelta < 0) { /* Don't shrink the stack frame. */ - spadj = (int32_t)as->parent->spadjust; - spdelta = 0; - } - as->T->spadjust = (uint16_t)spadj; - - /* Reload spilled target registers. */ - if (pass2) { - for (i = as->stopins; i > REF_BASE; i--) { - IRIns *ir = IR(i); - if (irt_ismarked(ir->t)) { - RegSet mask; - Reg r; - RegSP rs; - irt_clearmark(ir->t); - rs = as->parentmap[i - REF_FIRST]; - if (!ra_hasspill(regsp_spill(rs))) - ra_sethint(ir->r, rs); /* Hint may be gone, set it again. */ - else if (sps_scale(regsp_spill(rs))+spdelta == sps_scale(ir->s)) - continue; /* Same spill slot, do nothing. */ - mask = ((!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR) & allow; - if (mask == RSET_EMPTY) - lj_trace_err(as->J, LJ_TRERR_NYICOAL); - r = ra_allocref(as, i, mask); - ra_save(as, ir, r); - rset_clear(allow, r); - if (r == rs) { /* Coalesce matching registers right now. */ - ra_free(as, r); - rset_clear(live, r); - } else if (ra_hasspill(regsp_spill(rs))) { - pass3 = 1; - } - checkmclim(as); - } - } - } - - /* Store trace number and adjust stack frame relative to the parent. */ - emit_setvmstate(as, (int32_t)as->T->traceno); - emit_spsub(as, spdelta); - -#if !LJ_TARGET_X86ORX64 - /* Restore BASE register from parent spill slot. */ - if (ra_hasspill(irp->s)) - emit_spload(as, IR(REF_BASE), IR(REF_BASE)->r, sps_scale(irp->s)); -#endif - - /* Restore target registers from parent spill slots. */ - if (pass3) { - RegSet work = ~as->freeset & RSET_ALL; - while (work) { - Reg r = rset_pickbot(work); - IRRef ref = regcost_ref(as->cost[r]); - RegSP rs = as->parentmap[ref - REF_FIRST]; - rset_clear(work, r); - if (ra_hasspill(regsp_spill(rs))) { - int32_t ofs = sps_scale(regsp_spill(rs)); - ra_free(as, r); - emit_spload(as, IR(ref), r, ofs); - checkmclim(as); - } - } - } - - /* Shuffle registers to match up target regs with parent regs. */ - for (;;) { - RegSet work; - - /* Repeatedly coalesce free live registers by moving to their target. */ - while ((work = as->freeset & live) != RSET_EMPTY) { - Reg rp = rset_pickbot(work); - IRIns *ir = IR(sloadins[rp]); - rset_clear(live, rp); - rset_clear(allow, rp); - ra_free(as, ir->r); - emit_movrr(as, ir, ir->r, rp); - checkmclim(as); - } - - /* We're done if no live registers remain. */ - if (live == RSET_EMPTY) - break; - - /* Break cycles by renaming one target to a temp. register. */ - if (live & RSET_GPR) { - RegSet tmpset = as->freeset & ~live & allow & RSET_GPR; - if (tmpset == RSET_EMPTY) - lj_trace_err(as->J, LJ_TRERR_NYICOAL); - ra_rename(as, rset_pickbot(live & RSET_GPR), rset_pickbot(tmpset)); - } - if (!LJ_SOFTFP && (live & RSET_FPR)) { - RegSet tmpset = as->freeset & ~live & allow & RSET_FPR; - if (tmpset == RSET_EMPTY) - lj_trace_err(as->J, LJ_TRERR_NYICOAL); - ra_rename(as, rset_pickbot(live & RSET_FPR), rset_pickbot(tmpset)); - } - checkmclim(as); - /* Continue with coalescing to fix up the broken cycle(s). */ - } - - /* Inherit top stack slot already checked by parent trace. */ - as->T->topslot = as->parent->topslot; - if (as->topslot > as->T->topslot) { /* Need to check for higher slot? */ -#ifdef EXITSTATE_CHECKEXIT - /* Highest exit + 1 indicates stack check. */ - ExitNo exitno = as->T->nsnap; -#else - /* Reuse the parent exit in the context of the parent trace. */ - ExitNo exitno = as->J->exitno; -#endif - as->T->topslot = (uint8_t)as->topslot; /* Remember for child traces. */ - asm_stack_check(as, as->topslot, irp, allow & RSET_GPR, exitno); - } -} - -/* -- Tail of trace ------------------------------------------------------- */ - -/* Get base slot for a snapshot. */ -static BCReg asm_baseslot(ASMState *as, SnapShot *snap, int *gotframe) -{ - SnapEntry *map = &as->T->snapmap[snap->mapofs]; - MSize n; - for (n = snap->nent; n > 0; n--) { - SnapEntry sn = map[n-1]; - if ((sn & SNAP_FRAME)) { - *gotframe = 1; - return snap_slot(sn); - } - } - return 0; -} - -/* Link to another trace. */ -static void asm_tail_link(ASMState *as) -{ - SnapNo snapno = as->T->nsnap-1; /* Last snapshot. */ - SnapShot *snap = &as->T->snap[snapno]; - int gotframe = 0; - BCReg baseslot = asm_baseslot(as, snap, &gotframe); - - as->topslot = snap->topslot; - checkmclim(as); - ra_allocref(as, REF_BASE, RID2RSET(RID_BASE)); - - if (as->T->link == 0) { - /* Setup fixed registers for exit to interpreter. */ - const BCIns *pc = snap_pc(as->T->snapmap[snap->mapofs + snap->nent]); - int32_t mres; - if (bc_op(*pc) == BC_JLOOP) { /* NYI: find a better way to do this. */ - BCIns *retpc = &traceref(as->J, bc_d(*pc))->startins; - if (bc_isret(bc_op(*retpc))) - pc = retpc; - } - ra_allockreg(as, i32ptr(J2GG(as->J)->dispatch), RID_DISPATCH); - ra_allockreg(as, i32ptr(pc), RID_LPC); - mres = (int32_t)(snap->nslots - baseslot); - switch (bc_op(*pc)) { - case BC_CALLM: case BC_CALLMT: - mres -= (int32_t)(1 + bc_a(*pc) + bc_c(*pc)); break; - case BC_RETM: mres -= (int32_t)(bc_a(*pc) + bc_d(*pc)); break; - case BC_TSETM: mres -= (int32_t)bc_a(*pc); break; - default: if (bc_op(*pc) < BC_FUNCF) mres = 0; break; - } - ra_allockreg(as, mres, RID_RET); /* Return MULTRES or 0. */ - } else if (baseslot) { - /* Save modified BASE for linking to trace with higher start frame. */ - emit_setgl(as, RID_BASE, jit_base); - } - emit_addptr(as, RID_BASE, 8*(int32_t)baseslot); - - /* Sync the interpreter state with the on-trace state. */ - asm_stack_restore(as, snap); - - /* Root traces that add frames need to check the stack at the end. */ - if (!as->parent && gotframe) - asm_stack_check(as, as->topslot, NULL, as->freeset & RSET_GPR, snapno); -} - -/* -- Trace setup --------------------------------------------------------- */ - -/* Clear reg/sp for all instructions and add register hints. */ -static void asm_setup_regsp(ASMState *as) -{ - GCtrace *T = as->T; - int sink = T->sinktags; - IRRef nins = T->nins; - IRIns *ir, *lastir; - int inloop; -#if LJ_TARGET_ARM - uint32_t rload = 0xa6402a64; -#endif - - ra_setup(as); - - /* Clear reg/sp for constants. */ - for (ir = IR(T->nk), lastir = IR(REF_BASE); ir < lastir; ir++) - ir->prev = REGSP_INIT; - - /* REF_BASE is used for implicit references to the BASE register. */ - lastir->prev = REGSP_HINT(RID_BASE); - - ir = IR(nins-1); - if (ir->o == IR_RENAME) { - do { ir--; nins--; } while (ir->o == IR_RENAME); - T->nins = nins; /* Remove any renames left over from ASM restart. */ - } - as->snaprename = nins; - as->snapref = nins; - as->snapno = T->nsnap; - - as->stopins = REF_BASE; - as->orignins = nins; - as->curins = nins; - - /* Setup register hints for parent link instructions. */ - ir = IR(REF_FIRST); - if (as->parent) { - uint16_t *p; - lastir = lj_snap_regspmap(as->parent, as->J->exitno, ir); - if (lastir - ir > LJ_MAX_JSLOTS) - lj_trace_err(as->J, LJ_TRERR_NYICOAL); - as->stopins = (IRRef)((lastir-1) - as->ir); - for (p = as->parentmap; ir < lastir; ir++) { - RegSP rs = ir->prev; - *p++ = (uint16_t)rs; /* Copy original parent RegSP to parentmap. */ - if (!ra_hasspill(regsp_spill(rs))) - ir->prev = (uint16_t)REGSP_HINT(regsp_reg(rs)); - else - ir->prev = REGSP_INIT; - } - } - - inloop = 0; - as->evenspill = SPS_FIRST; - for (lastir = IR(nins); ir < lastir; ir++) { - if (sink) { - if (ir->r == RID_SINK) - continue; - if (ir->r == RID_SUNK) { /* Revert after ASM restart. */ - ir->r = RID_SINK; - continue; - } - } - switch (ir->o) { - case IR_LOOP: - inloop = 1; - break; -#if LJ_TARGET_ARM - case IR_SLOAD: - if (!((ir->op2 & IRSLOAD_TYPECHECK) || (ir+1)->o == IR_HIOP)) - break; - /* fallthrough */ - case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: - if (!LJ_SOFTFP && irt_isnum(ir->t)) break; - ir->prev = (uint16_t)REGSP_HINT((rload & 15)); - rload = lj_ror(rload, 4); - continue; -#endif - case IR_CALLXS: { - CCallInfo ci; - ci.flags = asm_callx_flags(as, ir); - ir->prev = asm_setup_call_slots(as, ir, &ci); - if (inloop) - as->modset |= RSET_SCRATCH; - continue; - } - case IR_CALLN: case IR_CALLL: case IR_CALLS: { - const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; - ir->prev = asm_setup_call_slots(as, ir, ci); - if (inloop) - as->modset |= (ci->flags & CCI_NOFPRCLOBBER) ? - (RSET_SCRATCH & ~RSET_FPR) : RSET_SCRATCH; - continue; - } -#if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) - case IR_HIOP: - switch ((ir-1)->o) { -#if LJ_SOFTFP && LJ_TARGET_ARM - case IR_SLOAD: case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: - if (ra_hashint((ir-1)->r)) { - ir->prev = (ir-1)->prev + 1; - continue; - } - break; -#endif -#if !LJ_SOFTFP && LJ_NEED_FP64 - case IR_CONV: - if (irt_isfp((ir-1)->t)) { - ir->prev = REGSP_HINT(RID_FPRET); - continue; - } - /* fallthrough */ -#endif - case IR_CALLN: case IR_CALLXS: -#if LJ_SOFTFP - case IR_MIN: case IR_MAX: -#endif - (ir-1)->prev = REGSP_HINT(RID_RETLO); - ir->prev = REGSP_HINT(RID_RETHI); - continue; - default: - break; - } - break; -#endif -#if LJ_SOFTFP - case IR_MIN: case IR_MAX: - if ((ir+1)->o != IR_HIOP) break; - /* fallthrough */ -#endif - /* C calls evict all scratch regs and return results in RID_RET. */ - case IR_SNEW: case IR_XSNEW: case IR_NEWREF: - if (REGARG_NUMGPR < 3 && as->evenspill < 3) - as->evenspill = 3; /* lj_str_new and lj_tab_newkey need 3 args. */ - case IR_TNEW: case IR_TDUP: case IR_CNEW: case IR_CNEWI: case IR_TOSTR: - ir->prev = REGSP_HINT(RID_RET); - if (inloop) - as->modset = RSET_SCRATCH; - continue; - case IR_STRTO: case IR_OBAR: - if (inloop) - as->modset = RSET_SCRATCH; - break; -#if !LJ_TARGET_X86ORX64 && !LJ_SOFTFP - case IR_ATAN2: case IR_LDEXP: -#endif - case IR_POW: - if (!LJ_SOFTFP && irt_isnum(ir->t)) { -#if LJ_TARGET_X86ORX64 - ir->prev = REGSP_HINT(RID_XMM0); - if (inloop) - as->modset |= RSET_RANGE(RID_XMM0, RID_XMM1+1)|RID2RSET(RID_EAX); -#else - ir->prev = REGSP_HINT(RID_FPRET); - if (inloop) - as->modset |= RSET_SCRATCH; -#endif - continue; - } - /* fallthrough for integer POW */ - case IR_DIV: case IR_MOD: - if (!irt_isnum(ir->t)) { - ir->prev = REGSP_HINT(RID_RET); - if (inloop) - as->modset |= (RSET_SCRATCH & RSET_GPR); - continue; - } - break; - case IR_FPMATH: -#if LJ_TARGET_X86ORX64 - if (ir->op2 == IRFPM_EXP2) { /* May be joined to lj_vm_pow_sse. */ - ir->prev = REGSP_HINT(RID_XMM0); -#if !LJ_64 - if (as->evenspill < 4) /* Leave room for 16 byte scratch area. */ - as->evenspill = 4; -#endif - if (inloop) - as->modset |= RSET_RANGE(RID_XMM0, RID_XMM2+1)|RID2RSET(RID_EAX); - continue; - } else if (ir->op2 <= IRFPM_TRUNC && !(as->flags & JIT_F_SSE4_1)) { - ir->prev = REGSP_HINT(RID_XMM0); - if (inloop) - as->modset |= RSET_RANGE(RID_XMM0, RID_XMM3+1)|RID2RSET(RID_EAX); - continue; - } - break; -#else - ir->prev = REGSP_HINT(RID_FPRET); - if (inloop) - as->modset |= RSET_SCRATCH; - continue; -#endif -#if LJ_TARGET_X86ORX64 - /* Non-constant shift counts need to be in RID_ECX on x86/x64. */ - case IR_BSHL: case IR_BSHR: case IR_BSAR: case IR_BROL: case IR_BROR: - if (!irref_isk(ir->op2) && !ra_hashint(IR(ir->op2)->r)) { - IR(ir->op2)->r = REGSP_HINT(RID_ECX); - if (inloop) - rset_set(as->modset, RID_ECX); - } - break; -#endif - /* Do not propagate hints across type conversions or loads. */ - case IR_TOBIT: - case IR_XLOAD: -#if !LJ_TARGET_ARM - case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: -#endif - break; - case IR_CONV: - if (irt_isfp(ir->t) || (ir->op2 & IRCONV_SRCMASK) == IRT_NUM || - (ir->op2 & IRCONV_SRCMASK) == IRT_FLOAT) - break; - /* fallthrough */ - default: - /* Propagate hints across likely 'op reg, imm' or 'op reg'. */ - if (irref_isk(ir->op2) && !irref_isk(ir->op1) && - ra_hashint(regsp_reg(IR(ir->op1)->prev))) { - ir->prev = IR(ir->op1)->prev; - continue; - } - break; - } - ir->prev = REGSP_INIT; - } - if ((as->evenspill & 1)) - as->oddspill = as->evenspill++; - else - as->oddspill = 0; -} - -/* -- Assembler core ------------------------------------------------------ */ - -/* Assemble a trace. */ -void lj_asm_trace(jit_State *J, GCtrace *T) -{ - ASMState as_; - ASMState *as = &as_; - MCode *origtop; - - /* Ensure an initialized instruction beyond the last one for HIOP checks. */ - J->cur.nins = lj_ir_nextins(J); - J->cur.ir[J->cur.nins].o = IR_NOP; - - /* Setup initial state. Copy some fields to reduce indirections. */ - as->J = J; - as->T = T; - as->ir = T->ir; - as->flags = J->flags; - as->loopref = J->loopref; - as->realign = NULL; - as->loopinv = 0; - as->parent = J->parent ? traceref(J, J->parent) : NULL; - - /* Reserve MCode memory. */ - as->mctop = origtop = lj_mcode_reserve(J, &as->mcbot); - as->mcp = as->mctop; - as->mclim = as->mcbot + MCLIM_REDZONE; - asm_setup_target(as); - - do { - as->mcp = as->mctop; -#ifdef LUA_USE_ASSERT - as->mcp_prev = as->mcp; -#endif - as->curins = T->nins; - RA_DBG_START(); - RA_DBGX((as, "===== STOP =====")); - - /* General trace setup. Emit tail of trace. */ - asm_tail_prep(as); - as->mcloop = NULL; - as->flagmcp = NULL; - as->topslot = 0; - as->gcsteps = 0; - as->sectref = as->loopref; - as->fuseref = (as->flags & JIT_F_OPT_FUSE) ? as->loopref : FUSE_DISABLED; - asm_setup_regsp(as); - if (!as->loopref) - asm_tail_link(as); - - /* Assemble a trace in linear backwards order. */ - for (as->curins--; as->curins > as->stopins; as->curins--) { - IRIns *ir = IR(as->curins); - lua_assert(!(LJ_32 && irt_isint64(ir->t))); /* Handled by SPLIT. */ - if (!ra_used(ir) && !ir_sideeff(ir) && (as->flags & JIT_F_OPT_DCE)) - continue; /* Dead-code elimination can be soooo easy. */ - if (irt_isguard(ir->t)) - asm_snap_prep(as); - RA_DBG_REF(); - checkmclim(as); - asm_ir(as, ir); - } - } while (as->realign); /* Retry in case the MCode needs to be realigned. */ - - /* Emit head of trace. */ - RA_DBG_REF(); - checkmclim(as); - if (as->gcsteps > 0) { - as->curins = as->T->snap[0].ref; - asm_snap_prep(as); /* The GC check is a guard. */ - asm_gc_check(as); - } - ra_evictk(as); - if (as->parent) - asm_head_side(as); - else - asm_head_root(as); - asm_phi_fixup(as); - - RA_DBGX((as, "===== START ====")); - RA_DBG_FLUSH(); - if (as->freeset != RSET_ALL) - lj_trace_err(as->J, LJ_TRERR_BADRA); /* Ouch! Should never happen. */ - - /* Set trace entry point before fixing up tail to allow link to self. */ - T->mcode = as->mcp; - T->mcloop = as->mcloop ? (MSize)((char *)as->mcloop - (char *)as->mcp) : 0; - if (!as->loopref) - asm_tail_fixup(as, T->link); /* Note: this may change as->mctop! */ - T->szmcode = (MSize)((char *)as->mctop - (char *)as->mcp); - lj_mcode_sync(T->mcode, origtop); -} - -#undef IR - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_asm.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_asm.h deleted file mode 100644 index f5d0159b1..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_asm.h +++ /dev/null @@ -1,17 +0,0 @@ -/* -** IR assembler (SSA IR -> machine code). -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_ASM_H -#define _LJ_ASM_H - -#include "lj_jit.h" - -#if LJ_HASJIT -LJ_FUNC void lj_asm_trace(jit_State *J, GCtrace *T); -LJ_FUNC void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, - MCode *target); -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_arm.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_arm.h deleted file mode 100644 index 72f205d90..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_arm.h +++ /dev/null @@ -1,2361 +0,0 @@ -/* -** ARM IR assembler (SSA IR -> machine code). -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -/* -- Register allocator extensions --------------------------------------- */ - -/* Allocate a register with a hint. */ -static Reg ra_hintalloc(ASMState *as, IRRef ref, Reg hint, RegSet allow) -{ - Reg r = IR(ref)->r; - if (ra_noreg(r)) { - if (!ra_hashint(r) && !iscrossref(as, ref)) - ra_sethint(IR(ref)->r, hint); /* Propagate register hint. */ - r = ra_allocref(as, ref, allow); - } - ra_noweak(as, r); - return r; -} - -/* Allocate a scratch register pair. */ -static Reg ra_scratchpair(ASMState *as, RegSet allow) -{ - RegSet pick1 = as->freeset & allow; - RegSet pick2 = pick1 & (pick1 >> 1) & RSET_GPREVEN; - Reg r; - if (pick2) { - r = rset_picktop(pick2); - } else { - RegSet pick = pick1 & (allow >> 1) & RSET_GPREVEN; - if (pick) { - r = rset_picktop(pick); - ra_restore(as, regcost_ref(as->cost[r+1])); - } else { - pick = pick1 & (allow << 1) & RSET_GPRODD; - if (pick) { - r = ra_restore(as, regcost_ref(as->cost[rset_picktop(pick)-1])); - } else { - r = ra_evict(as, allow & (allow >> 1) & RSET_GPREVEN); - ra_restore(as, regcost_ref(as->cost[r+1])); - } - } - } - lua_assert(rset_test(RSET_GPREVEN, r)); - ra_modified(as, r); - ra_modified(as, r+1); - RA_DBGX((as, "scratchpair $r $r", r, r+1)); - return r; -} - -#if !LJ_SOFTFP -/* Allocate two source registers for three-operand instructions. */ -static Reg ra_alloc2(ASMState *as, IRIns *ir, RegSet allow) -{ - IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); - Reg left = irl->r, right = irr->r; - if (ra_hasreg(left)) { - ra_noweak(as, left); - if (ra_noreg(right)) - right = ra_allocref(as, ir->op2, rset_exclude(allow, left)); - else - ra_noweak(as, right); - } else if (ra_hasreg(right)) { - ra_noweak(as, right); - left = ra_allocref(as, ir->op1, rset_exclude(allow, right)); - } else if (ra_hashint(right)) { - right = ra_allocref(as, ir->op2, allow); - left = ra_alloc1(as, ir->op1, rset_exclude(allow, right)); - } else { - left = ra_allocref(as, ir->op1, allow); - right = ra_alloc1(as, ir->op2, rset_exclude(allow, left)); - } - return left | (right << 8); -} -#endif - -/* -- Guard handling ------------------------------------------------------ */ - -/* Generate an exit stub group at the bottom of the reserved MCode memory. */ -static MCode *asm_exitstub_gen(ASMState *as, ExitNo group) -{ - MCode *mxp = as->mcbot; - int i; - if (mxp + 4*4+4*EXITSTUBS_PER_GROUP >= as->mctop) - asm_mclimit(as); - /* str lr, [sp]; bl ->vm_exit_handler; .long DISPATCH_address, group. */ - *mxp++ = ARMI_STR|ARMI_LS_P|ARMI_LS_U|ARMF_D(RID_LR)|ARMF_N(RID_SP); - *mxp = ARMI_BL|((((MCode *)(void *)lj_vm_exit_handler-mxp)-2)&0x00ffffffu); - mxp++; - *mxp++ = (MCode)i32ptr(J2GG(as->J)->dispatch); /* DISPATCH address */ - *mxp++ = group*EXITSTUBS_PER_GROUP; - for (i = 0; i < EXITSTUBS_PER_GROUP; i++) - *mxp++ = ARMI_B|((-6-i)&0x00ffffffu); - lj_mcode_sync(as->mcbot, mxp); - lj_mcode_commitbot(as->J, mxp); - as->mcbot = mxp; - as->mclim = as->mcbot + MCLIM_REDZONE; - return mxp - EXITSTUBS_PER_GROUP; -} - -/* Setup all needed exit stubs. */ -static void asm_exitstub_setup(ASMState *as, ExitNo nexits) -{ - ExitNo i; - if (nexits >= EXITSTUBS_PER_GROUP*LJ_MAX_EXITSTUBGR) - lj_trace_err(as->J, LJ_TRERR_SNAPOV); - for (i = 0; i < (nexits+EXITSTUBS_PER_GROUP-1)/EXITSTUBS_PER_GROUP; i++) - if (as->J->exitstubgroup[i] == NULL) - as->J->exitstubgroup[i] = asm_exitstub_gen(as, i); -} - -/* Emit conditional branch to exit for guard. */ -static void asm_guardcc(ASMState *as, ARMCC cc) -{ - MCode *target = exitstub_addr(as->J, as->snapno); - MCode *p = as->mcp; - if (LJ_UNLIKELY(p == as->invmcp)) { - as->loopinv = 1; - *p = ARMI_BL | ((target-p-2) & 0x00ffffffu); - emit_branch(as, ARMF_CC(ARMI_B, cc^1), p+1); - return; - } - emit_branch(as, ARMF_CC(ARMI_BL, cc), target); -} - -/* -- Operand fusion ------------------------------------------------------ */ - -/* Limit linear search to this distance. Avoids O(n^2) behavior. */ -#define CONFLICT_SEARCH_LIM 31 - -/* Check if there's no conflicting instruction between curins and ref. */ -static int noconflict(ASMState *as, IRRef ref, IROp conflict) -{ - IRIns *ir = as->ir; - IRRef i = as->curins; - if (i > ref + CONFLICT_SEARCH_LIM) - return 0; /* Give up, ref is too far away. */ - while (--i > ref) - if (ir[i].o == conflict) - return 0; /* Conflict found. */ - return 1; /* Ok, no conflict. */ -} - -/* Fuse the array base of colocated arrays. */ -static int32_t asm_fuseabase(ASMState *as, IRRef ref) -{ - IRIns *ir = IR(ref); - if (ir->o == IR_TNEW && ir->op1 <= LJ_MAX_COLOSIZE && - !neverfuse(as) && noconflict(as, ref, IR_NEWREF)) - return (int32_t)sizeof(GCtab); - return 0; -} - -/* Fuse array/hash/upvalue reference into register+offset operand. */ -static Reg asm_fuseahuref(ASMState *as, IRRef ref, int32_t *ofsp, RegSet allow, - int lim) -{ - IRIns *ir = IR(ref); - if (ra_noreg(ir->r)) { - if (ir->o == IR_AREF) { - if (mayfuse(as, ref)) { - if (irref_isk(ir->op2)) { - IRRef tab = IR(ir->op1)->op1; - int32_t ofs = asm_fuseabase(as, tab); - IRRef refa = ofs ? tab : ir->op1; - ofs += 8*IR(ir->op2)->i; - if (ofs > -lim && ofs < lim) { - *ofsp = ofs; - return ra_alloc1(as, refa, allow); - } - } - } - } else if (ir->o == IR_HREFK) { - if (mayfuse(as, ref)) { - int32_t ofs = (int32_t)(IR(ir->op2)->op2 * sizeof(Node)); - if (ofs < lim) { - *ofsp = ofs; - return ra_alloc1(as, ir->op1, allow); - } - } - } else if (ir->o == IR_UREFC) { - if (irref_isk(ir->op1)) { - GCfunc *fn = ir_kfunc(IR(ir->op1)); - int32_t ofs = i32ptr(&gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.tv); - *ofsp = (ofs & 255); /* Mask out less bits to allow LDRD. */ - return ra_allock(as, (ofs & ~255), allow); - } - } - } - *ofsp = 0; - return ra_alloc1(as, ref, allow); -} - -/* Fuse m operand into arithmetic/logic instructions. */ -static uint32_t asm_fuseopm(ASMState *as, ARMIns ai, IRRef ref, RegSet allow) -{ - IRIns *ir = IR(ref); - if (ra_hasreg(ir->r)) { - ra_noweak(as, ir->r); - return ARMF_M(ir->r); - } else if (irref_isk(ref)) { - uint32_t k = emit_isk12(ai, ir->i); - if (k) - return k; - } else if (mayfuse(as, ref)) { - if (ir->o >= IR_BSHL && ir->o <= IR_BROR) { - Reg m = ra_alloc1(as, ir->op1, allow); - ARMShift sh = ir->o == IR_BSHL ? ARMSH_LSL : - ir->o == IR_BSHR ? ARMSH_LSR : - ir->o == IR_BSAR ? ARMSH_ASR : ARMSH_ROR; - if (irref_isk(ir->op2)) { - return m | ARMF_SH(sh, (IR(ir->op2)->i & 31)); - } else { - Reg s = ra_alloc1(as, ir->op2, rset_exclude(allow, m)); - return m | ARMF_RSH(sh, s); - } - } else if (ir->o == IR_ADD && ir->op1 == ir->op2) { - Reg m = ra_alloc1(as, ir->op1, allow); - return m | ARMF_SH(ARMSH_LSL, 1); - } - } - return ra_allocref(as, ref, allow); -} - -/* Fuse shifts into loads/stores. Only bother with BSHL 2 => lsl #2. */ -static IRRef asm_fuselsl2(ASMState *as, IRRef ref) -{ - IRIns *ir = IR(ref); - if (ra_noreg(ir->r) && mayfuse(as, ref) && ir->o == IR_BSHL && - irref_isk(ir->op2) && IR(ir->op2)->i == 2) - return ir->op1; - return 0; /* No fusion. */ -} - -/* Fuse XLOAD/XSTORE reference into load/store operand. */ -static void asm_fusexref(ASMState *as, ARMIns ai, Reg rd, IRRef ref, - RegSet allow, int32_t ofs) -{ - IRIns *ir = IR(ref); - Reg base; - if (ra_noreg(ir->r) && canfuse(as, ir)) { - int32_t lim = (!LJ_SOFTFP && (ai & 0x08000000)) ? 1024 : - (ai & 0x04000000) ? 4096 : 256; - if (ir->o == IR_ADD) { - int32_t ofs2; - if (irref_isk(ir->op2) && - (ofs2 = ofs + IR(ir->op2)->i) > -lim && ofs2 < lim && - (!(!LJ_SOFTFP && (ai & 0x08000000)) || !(ofs2 & 3))) { - ofs = ofs2; - ref = ir->op1; - } else if (ofs == 0 && !(!LJ_SOFTFP && (ai & 0x08000000))) { - IRRef lref = ir->op1, rref = ir->op2; - Reg rn, rm; - if ((ai & 0x04000000)) { - IRRef sref = asm_fuselsl2(as, rref); - if (sref) { - rref = sref; - ai |= ARMF_SH(ARMSH_LSL, 2); - } else if ((sref = asm_fuselsl2(as, lref)) != 0) { - lref = rref; - rref = sref; - ai |= ARMF_SH(ARMSH_LSL, 2); - } - } - rn = ra_alloc1(as, lref, allow); - rm = ra_alloc1(as, rref, rset_exclude(allow, rn)); - if ((ai & 0x04000000)) ai |= ARMI_LS_R; - emit_dnm(as, ai|ARMI_LS_P|ARMI_LS_U, rd, rn, rm); - return; - } - } else if (ir->o == IR_STRREF && !(!LJ_SOFTFP && (ai & 0x08000000))) { - lua_assert(ofs == 0); - ofs = (int32_t)sizeof(GCstr); - if (irref_isk(ir->op2)) { - ofs += IR(ir->op2)->i; - ref = ir->op1; - } else if (irref_isk(ir->op1)) { - ofs += IR(ir->op1)->i; - ref = ir->op2; - } else { - /* NYI: Fuse ADD with constant. */ - Reg rn = ra_alloc1(as, ir->op1, allow); - uint32_t m = asm_fuseopm(as, 0, ir->op2, rset_exclude(allow, rn)); - if ((ai & 0x04000000)) - emit_lso(as, ai, rd, rd, ofs); - else - emit_lsox(as, ai, rd, rd, ofs); - emit_dn(as, ARMI_ADD^m, rd, rn); - return; - } - if (ofs <= -lim || ofs >= lim) { - Reg rn = ra_alloc1(as, ref, allow); - Reg rm = ra_allock(as, ofs, rset_exclude(allow, rn)); - if ((ai & 0x04000000)) ai |= ARMI_LS_R; - emit_dnm(as, ai|ARMI_LS_P|ARMI_LS_U, rd, rn, rm); - return; - } - } - } - base = ra_alloc1(as, ref, allow); -#if !LJ_SOFTFP - if ((ai & 0x08000000)) - emit_vlso(as, ai, rd, base, ofs); - else -#endif - if ((ai & 0x04000000)) - emit_lso(as, ai, rd, base, ofs); - else - emit_lsox(as, ai, rd, base, ofs); -} - -#if !LJ_SOFTFP -/* Fuse to multiply-add/sub instruction. */ -static int asm_fusemadd(ASMState *as, IRIns *ir, ARMIns ai, ARMIns air) -{ - IRRef lref = ir->op1, rref = ir->op2; - IRIns *irm; - if (lref != rref && - ((mayfuse(as, lref) && (irm = IR(lref), irm->o == IR_MUL) && - ra_noreg(irm->r)) || - (mayfuse(as, rref) && (irm = IR(rref), irm->o == IR_MUL) && - (rref = lref, ai = air, ra_noreg(irm->r))))) { - Reg dest = ra_dest(as, ir, RSET_FPR); - Reg add = ra_hintalloc(as, rref, dest, RSET_FPR); - Reg right, left = ra_alloc2(as, irm, - rset_exclude(rset_exclude(RSET_FPR, dest), add)); - right = (left >> 8); left &= 255; - emit_dnm(as, ai, (dest & 15), (left & 15), (right & 15)); - if (dest != add) emit_dm(as, ARMI_VMOV_D, (dest & 15), (add & 15)); - return 1; - } - return 0; -} -#endif - -/* -- Calls --------------------------------------------------------------- */ - -/* Generate a call to a C function. */ -static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args) -{ - uint32_t n, nargs = CCI_NARGS(ci); - int32_t ofs = 0; -#if LJ_SOFTFP - Reg gpr = REGARG_FIRSTGPR; -#else - Reg gpr, fpr = REGARG_FIRSTFPR, fprodd = 0; -#endif - if ((void *)ci->func) - emit_call(as, (void *)ci->func); -#if !LJ_SOFTFP - for (gpr = REGARG_FIRSTGPR; gpr <= REGARG_LASTGPR; gpr++) - as->cost[gpr] = REGCOST(~0u, ASMREF_L); - gpr = REGARG_FIRSTGPR; -#endif - for (n = 0; n < nargs; n++) { /* Setup args. */ - IRRef ref = args[n]; - IRIns *ir = IR(ref); -#if !LJ_SOFTFP - if (ref && irt_isfp(ir->t)) { - RegSet of = as->freeset; - Reg src; - if (!LJ_ABI_SOFTFP && !(ci->flags & CCI_VARARG)) { - if (irt_isnum(ir->t)) { - if (fpr <= REGARG_LASTFPR) { - ra_leftov(as, fpr, ref); - fpr++; - continue; - } - } else if (fprodd) { /* Ick. */ - src = ra_alloc1(as, ref, RSET_FPR); - emit_dm(as, ARMI_VMOV_S, (fprodd & 15), (src & 15) | 0x00400000); - fprodd = 0; - continue; - } else if (fpr <= REGARG_LASTFPR) { - ra_leftov(as, fpr, ref); - fprodd = fpr++; - continue; - } - /* Workaround to protect argument GPRs from being used for remat. */ - as->freeset &= ~RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1); - src = ra_alloc1(as, ref, RSET_FPR); /* May alloc GPR to remat FPR. */ - as->freeset |= (of & RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1)); - fprodd = 0; - goto stackfp; - } - /* Workaround to protect argument GPRs from being used for remat. */ - as->freeset &= ~RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1); - src = ra_alloc1(as, ref, RSET_FPR); /* May alloc GPR to remat FPR. */ - as->freeset |= (of & RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1)); - if (irt_isnum(ir->t)) gpr = (gpr+1) & ~1u; - if (gpr <= REGARG_LASTGPR) { - lua_assert(rset_test(as->freeset, gpr)); /* Must have been evicted. */ - if (irt_isnum(ir->t)) { - lua_assert(rset_test(as->freeset, gpr+1)); /* Ditto. */ - emit_dnm(as, ARMI_VMOV_RR_D, gpr, gpr+1, (src & 15)); - gpr += 2; - } else { - emit_dn(as, ARMI_VMOV_R_S, gpr, (src & 15)); - gpr++; - } - } else { - stackfp: - if (irt_isnum(ir->t)) ofs = (ofs + 4) & ~4; - emit_spstore(as, ir, src, ofs); - ofs += irt_isnum(ir->t) ? 8 : 4; - } - } else -#endif - { - if (gpr <= REGARG_LASTGPR) { - lua_assert(rset_test(as->freeset, gpr)); /* Must have been evicted. */ - if (ref) ra_leftov(as, gpr, ref); - gpr++; - } else { - if (ref) { - Reg r = ra_alloc1(as, ref, RSET_GPR); - emit_spstore(as, ir, r, ofs); - } - ofs += 4; - } - } - } -} - -/* Setup result reg/sp for call. Evict scratch regs. */ -static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci) -{ - RegSet drop = RSET_SCRATCH; - int hiop = ((ir+1)->o == IR_HIOP); - if (ra_hasreg(ir->r)) - rset_clear(drop, ir->r); /* Dest reg handled below. */ - if (hiop && ra_hasreg((ir+1)->r)) - rset_clear(drop, (ir+1)->r); /* Dest reg handled below. */ - ra_evictset(as, drop); /* Evictions must be performed first. */ - if (ra_used(ir)) { - lua_assert(!irt_ispri(ir->t)); - if (!LJ_SOFTFP && irt_isfp(ir->t)) { - if (LJ_ABI_SOFTFP || (ci->flags & (CCI_CASTU64|CCI_VARARG))) { - Reg dest = (ra_dest(as, ir, RSET_FPR) & 15); - if (irt_isnum(ir->t)) - emit_dnm(as, ARMI_VMOV_D_RR, RID_RETLO, RID_RETHI, dest); - else - emit_dn(as, ARMI_VMOV_S_R, RID_RET, dest); - } else { - ra_destreg(as, ir, RID_FPRET); - } - } else if (hiop) { - ra_destpair(as, ir); - } else { - ra_destreg(as, ir, RID_RET); - } - } - UNUSED(ci); -} - -static void asm_call(ASMState *as, IRIns *ir) -{ - IRRef args[CCI_NARGS_MAX]; - const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; - asm_collectargs(as, ir, ci, args); - asm_setupresult(as, ir, ci); - asm_gencall(as, ci, args); -} - -static void asm_callx(ASMState *as, IRIns *ir) -{ - IRRef args[CCI_NARGS_MAX*2]; - CCallInfo ci; - IRRef func; - IRIns *irf; - ci.flags = asm_callx_flags(as, ir); - asm_collectargs(as, ir, &ci, args); - asm_setupresult(as, ir, &ci); - func = ir->op2; irf = IR(func); - if (irf->o == IR_CARG) { func = irf->op1; irf = IR(func); } - if (irref_isk(func)) { /* Call to constant address. */ - ci.func = (ASMFunction)(void *)(irf->i); - } else { /* Need a non-argument register for indirect calls. */ - Reg freg = ra_alloc1(as, func, RSET_RANGE(RID_R4, RID_R12+1)); - emit_m(as, ARMI_BLXr, freg); - ci.func = (ASMFunction)(void *)0; - } - asm_gencall(as, &ci, args); -} - -/* -- Returns ------------------------------------------------------------- */ - -/* Return to lower frame. Guard that it goes to the right spot. */ -static void asm_retf(ASMState *as, IRIns *ir) -{ - Reg base = ra_alloc1(as, REF_BASE, RSET_GPR); - void *pc = ir_kptr(IR(ir->op2)); - int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); - as->topslot -= (BCReg)delta; - if ((int32_t)as->topslot < 0) as->topslot = 0; - irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */ - /* Need to force a spill on REF_BASE now to update the stack slot. */ - emit_lso(as, ARMI_STR, base, RID_SP, ra_spill(as, IR(REF_BASE))); - emit_setgl(as, base, jit_base); - emit_addptr(as, base, -8*delta); - asm_guardcc(as, CC_NE); - emit_nm(as, ARMI_CMP, RID_TMP, - ra_allock(as, i32ptr(pc), rset_exclude(RSET_GPR, base))); - emit_lso(as, ARMI_LDR, RID_TMP, base, -4); -} - -/* -- Type conversions ---------------------------------------------------- */ - -#if !LJ_SOFTFP -static void asm_tointg(ASMState *as, IRIns *ir, Reg left) -{ - Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); - Reg dest = ra_dest(as, ir, RSET_GPR); - asm_guardcc(as, CC_NE); - emit_d(as, ARMI_VMRS, 0); - emit_dm(as, ARMI_VCMP_D, (tmp & 15), (left & 15)); - emit_dm(as, ARMI_VCVT_F64_S32, (tmp & 15), (tmp & 15)); - emit_dn(as, ARMI_VMOV_R_S, dest, (tmp & 15)); - emit_dm(as, ARMI_VCVT_S32_F64, (tmp & 15), (left & 15)); -} - -static void asm_tobit(ASMState *as, IRIns *ir) -{ - RegSet allow = RSET_FPR; - Reg left = ra_alloc1(as, ir->op1, allow); - Reg right = ra_alloc1(as, ir->op2, rset_clear(allow, left)); - Reg tmp = ra_scratch(as, rset_clear(allow, right)); - Reg dest = ra_dest(as, ir, RSET_GPR); - emit_dn(as, ARMI_VMOV_R_S, dest, (tmp & 15)); - emit_dnm(as, ARMI_VADD_D, (tmp & 15), (left & 15), (right & 15)); -} -#endif - -static void asm_conv(ASMState *as, IRIns *ir) -{ - IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); -#if !LJ_SOFTFP - int stfp = (st == IRT_NUM || st == IRT_FLOAT); -#endif - IRRef lref = ir->op1; - /* 64 bit integer conversions are handled by SPLIT. */ - lua_assert(!irt_isint64(ir->t) && !(st == IRT_I64 || st == IRT_U64)); -#if LJ_SOFTFP - /* FP conversions are handled by SPLIT. */ - lua_assert(!irt_isfp(ir->t) && !(st == IRT_NUM || st == IRT_FLOAT)); - /* Can't check for same types: SPLIT uses CONV int.int + BXOR for sfp NEG. */ -#else - lua_assert(irt_type(ir->t) != st); - if (irt_isfp(ir->t)) { - Reg dest = ra_dest(as, ir, RSET_FPR); - if (stfp) { /* FP to FP conversion. */ - emit_dm(as, st == IRT_NUM ? ARMI_VCVT_F32_F64 : ARMI_VCVT_F64_F32, - (dest & 15), (ra_alloc1(as, lref, RSET_FPR) & 15)); - } else { /* Integer to FP conversion. */ - Reg left = ra_alloc1(as, lref, RSET_GPR); - ARMIns ai = irt_isfloat(ir->t) ? - (st == IRT_INT ? ARMI_VCVT_F32_S32 : ARMI_VCVT_F32_U32) : - (st == IRT_INT ? ARMI_VCVT_F64_S32 : ARMI_VCVT_F64_U32); - emit_dm(as, ai, (dest & 15), (dest & 15)); - emit_dn(as, ARMI_VMOV_S_R, left, (dest & 15)); - } - } else if (stfp) { /* FP to integer conversion. */ - if (irt_isguard(ir->t)) { - /* Checked conversions are only supported from number to int. */ - lua_assert(irt_isint(ir->t) && st == IRT_NUM); - asm_tointg(as, ir, ra_alloc1(as, lref, RSET_FPR)); - } else { - Reg left = ra_alloc1(as, lref, RSET_FPR); - Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); - Reg dest = ra_dest(as, ir, RSET_GPR); - ARMIns ai; - emit_dn(as, ARMI_VMOV_R_S, dest, (tmp & 15)); - ai = irt_isint(ir->t) ? - (st == IRT_NUM ? ARMI_VCVT_S32_F64 : ARMI_VCVT_S32_F32) : - (st == IRT_NUM ? ARMI_VCVT_U32_F64 : ARMI_VCVT_U32_F32); - emit_dm(as, ai, (tmp & 15), (left & 15)); - } - } else -#endif - { - Reg dest = ra_dest(as, ir, RSET_GPR); - if (st >= IRT_I8 && st <= IRT_U16) { /* Extend to 32 bit integer. */ - Reg left = ra_alloc1(as, lref, RSET_GPR); - lua_assert(irt_isint(ir->t) || irt_isu32(ir->t)); - if ((as->flags & JIT_F_ARMV6)) { - ARMIns ai = st == IRT_I8 ? ARMI_SXTB : - st == IRT_U8 ? ARMI_UXTB : - st == IRT_I16 ? ARMI_SXTH : ARMI_UXTH; - emit_dm(as, ai, dest, left); - } else if (st == IRT_U8) { - emit_dn(as, ARMI_AND|ARMI_K12|255, dest, left); - } else { - uint32_t shift = st == IRT_I8 ? 24 : 16; - ARMShift sh = st == IRT_U16 ? ARMSH_LSR : ARMSH_ASR; - emit_dm(as, ARMI_MOV|ARMF_SH(sh, shift), dest, RID_TMP); - emit_dm(as, ARMI_MOV|ARMF_SH(ARMSH_LSL, shift), RID_TMP, left); - } - } else { /* Handle 32/32 bit no-op (cast). */ - ra_leftov(as, dest, lref); /* Do nothing, but may need to move regs. */ - } - } -} - -#if !LJ_SOFTFP && LJ_HASFFI -static void asm_conv64(ASMState *as, IRIns *ir) -{ - IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK); - IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH); - IRCallID id; - CCallInfo ci; - IRRef args[2]; - args[0] = (ir-1)->op1; - args[1] = ir->op1; - if (st == IRT_NUM || st == IRT_FLOAT) { - id = IRCALL_fp64_d2l + ((st == IRT_FLOAT) ? 2 : 0) + (dt - IRT_I64); - ir--; - } else { - id = IRCALL_fp64_l2d + ((dt == IRT_FLOAT) ? 2 : 0) + (st - IRT_I64); - } - ci = lj_ir_callinfo[id]; -#if !LJ_ABI_SOFTFP - ci.flags |= CCI_VARARG; /* These calls don't use the hard-float ABI! */ -#endif - asm_setupresult(as, ir, &ci); - asm_gencall(as, &ci, args); -} -#endif - -static void asm_strto(ASMState *as, IRIns *ir) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_strscan_num]; - IRRef args[2]; - Reg rlo = 0, rhi = 0, tmp; - int destused = ra_used(ir); - int32_t ofs = 0; - ra_evictset(as, RSET_SCRATCH); -#if LJ_SOFTFP - if (destused) { - if (ra_hasspill(ir->s) && ra_hasspill((ir+1)->s) && - (ir->s & 1) == 0 && ir->s + 1 == (ir+1)->s) { - int i; - for (i = 0; i < 2; i++) { - Reg r = (ir+i)->r; - if (ra_hasreg(r)) { - ra_free(as, r); - ra_modified(as, r); - emit_spload(as, ir+i, r, sps_scale((ir+i)->s)); - } - } - ofs = sps_scale(ir->s); - destused = 0; - } else { - rhi = ra_dest(as, ir+1, RSET_GPR); - rlo = ra_dest(as, ir, rset_exclude(RSET_GPR, rhi)); - } - } - asm_guardcc(as, CC_EQ); - if (destused) { - emit_lso(as, ARMI_LDR, rhi, RID_SP, 4); - emit_lso(as, ARMI_LDR, rlo, RID_SP, 0); - } -#else - UNUSED(rhi); - if (destused) { - if (ra_hasspill(ir->s)) { - ofs = sps_scale(ir->s); - destused = 0; - if (ra_hasreg(ir->r)) { - ra_free(as, ir->r); - ra_modified(as, ir->r); - emit_spload(as, ir, ir->r, ofs); - } - } else { - rlo = ra_dest(as, ir, RSET_FPR); - } - } - asm_guardcc(as, CC_EQ); - if (destused) - emit_vlso(as, ARMI_VLDR_D, rlo, RID_SP, 0); -#endif - emit_n(as, ARMI_CMP|ARMI_K12|0, RID_RET); /* Test return status. */ - args[0] = ir->op1; /* GCstr *str */ - args[1] = ASMREF_TMP1; /* TValue *n */ - asm_gencall(as, ci, args); - tmp = ra_releasetmp(as, ASMREF_TMP1); - if (ofs == 0) - emit_dm(as, ARMI_MOV, tmp, RID_SP); - else - emit_opk(as, ARMI_ADD, tmp, RID_SP, ofs, RSET_GPR); -} - -/* Get pointer to TValue. */ -static void asm_tvptr(ASMState *as, Reg dest, IRRef ref) -{ - IRIns *ir = IR(ref); - if (irt_isnum(ir->t)) { - if (irref_isk(ref)) { - /* Use the number constant itself as a TValue. */ - ra_allockreg(as, i32ptr(ir_knum(ir)), dest); - } else { -#if LJ_SOFTFP - lua_assert(0); -#else - /* Otherwise force a spill and use the spill slot. */ - emit_opk(as, ARMI_ADD, dest, RID_SP, ra_spill(as, ir), RSET_GPR); -#endif - } - } else { - /* Otherwise use [sp] and [sp+4] to hold the TValue. */ - RegSet allow = rset_exclude(RSET_GPR, dest); - Reg type; - emit_dm(as, ARMI_MOV, dest, RID_SP); - if (!irt_ispri(ir->t)) { - Reg src = ra_alloc1(as, ref, allow); - emit_lso(as, ARMI_STR, src, RID_SP, 0); - } - if ((ir+1)->o == IR_HIOP) - type = ra_alloc1(as, ref+1, allow); - else - type = ra_allock(as, irt_toitype(ir->t), allow); - emit_lso(as, ARMI_STR, type, RID_SP, 4); - } -} - -static void asm_tostr(ASMState *as, IRIns *ir) -{ - IRRef args[2]; - args[0] = ASMREF_L; - as->gcsteps++; - if (irt_isnum(IR(ir->op1)->t) || (ir+1)->o == IR_HIOP) { - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromnum]; - args[1] = ASMREF_TMP1; /* const lua_Number * */ - asm_setupresult(as, ir, ci); /* GCstr * */ - asm_gencall(as, ci, args); - asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op1); - } else { - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromint]; - args[1] = ir->op1; /* int32_t k */ - asm_setupresult(as, ir, ci); /* GCstr * */ - asm_gencall(as, ci, args); - } -} - -/* -- Memory references --------------------------------------------------- */ - -static void asm_aref(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg idx, base; - if (irref_isk(ir->op2)) { - IRRef tab = IR(ir->op1)->op1; - int32_t ofs = asm_fuseabase(as, tab); - IRRef refa = ofs ? tab : ir->op1; - uint32_t k = emit_isk12(ARMI_ADD, ofs + 8*IR(ir->op2)->i); - if (k) { - base = ra_alloc1(as, refa, RSET_GPR); - emit_dn(as, ARMI_ADD^k, dest, base); - return; - } - } - base = ra_alloc1(as, ir->op1, RSET_GPR); - idx = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, base)); - emit_dnm(as, ARMI_ADD|ARMF_SH(ARMSH_LSL, 3), dest, base, idx); -} - -/* Inlined hash lookup. Specialized for key type and for const keys. -** The equivalent C code is: -** Node *n = hashkey(t, key); -** do { -** if (lj_obj_equal(&n->key, key)) return &n->val; -** } while ((n = nextnode(n))); -** return niltv(L); -*/ -static void asm_href(ASMState *as, IRIns *ir, IROp merge) -{ - RegSet allow = RSET_GPR; - int destused = ra_used(ir); - Reg dest = ra_dest(as, ir, allow); - Reg tab = ra_alloc1(as, ir->op1, rset_clear(allow, dest)); - Reg key = 0, keyhi = 0, keynumhi = RID_NONE, tmp = RID_TMP; - IRRef refkey = ir->op2; - IRIns *irkey = IR(refkey); - IRType1 kt = irkey->t; - int32_t k = 0, khi = emit_isk12(ARMI_CMP, irt_toitype(kt)); - uint32_t khash; - MCLabel l_end, l_loop; - rset_clear(allow, tab); - if (!irref_isk(refkey) || irt_isstr(kt)) { -#if LJ_SOFTFP - key = ra_alloc1(as, refkey, allow); - rset_clear(allow, key); - if (irkey[1].o == IR_HIOP) { - if (ra_hasreg((irkey+1)->r)) { - keynumhi = (irkey+1)->r; - keyhi = RID_TMP; - ra_noweak(as, keynumhi); - } else { - keyhi = keynumhi = ra_allocref(as, refkey+1, allow); - } - rset_clear(allow, keynumhi); - khi = 0; - } -#else - if (irt_isnum(kt)) { - key = ra_scratch(as, allow); - rset_clear(allow, key); - keyhi = keynumhi = ra_scratch(as, allow); - rset_clear(allow, keyhi); - khi = 0; - } else { - key = ra_alloc1(as, refkey, allow); - rset_clear(allow, key); - } -#endif - } else if (irt_isnum(kt)) { - int32_t val = (int32_t)ir_knum(irkey)->u32.lo; - k = emit_isk12(ARMI_CMP, val); - if (!k) { - key = ra_allock(as, val, allow); - rset_clear(allow, key); - } - val = (int32_t)ir_knum(irkey)->u32.hi; - khi = emit_isk12(ARMI_CMP, val); - if (!khi) { - keyhi = ra_allock(as, val, allow); - rset_clear(allow, keyhi); - } - } else if (!irt_ispri(kt)) { - k = emit_isk12(ARMI_CMP, irkey->i); - if (!k) { - key = ra_alloc1(as, refkey, allow); - rset_clear(allow, key); - } - } - if (!irt_ispri(kt)) - tmp = ra_scratchpair(as, allow); - - /* Key not found in chain: jump to exit (if merged) or load niltv. */ - l_end = emit_label(as); - as->invmcp = NULL; - if (merge == IR_NE) - asm_guardcc(as, CC_AL); - else if (destused) - emit_loada(as, dest, niltvg(J2G(as->J))); - - /* Follow hash chain until the end. */ - l_loop = --as->mcp; - emit_n(as, ARMI_CMP|ARMI_K12|0, dest); - emit_lso(as, ARMI_LDR, dest, dest, (int32_t)offsetof(Node, next)); - - /* Type and value comparison. */ - if (merge == IR_EQ) - asm_guardcc(as, CC_EQ); - else - emit_branch(as, ARMF_CC(ARMI_B, CC_EQ), l_end); - if (!irt_ispri(kt)) { - emit_nm(as, ARMF_CC(ARMI_CMP, CC_EQ)^k, tmp, key); - emit_nm(as, ARMI_CMP^khi, tmp+1, keyhi); - emit_lsox(as, ARMI_LDRD, tmp, dest, (int32_t)offsetof(Node, key)); - } else { - emit_n(as, ARMI_CMP^khi, tmp); - emit_lso(as, ARMI_LDR, tmp, dest, (int32_t)offsetof(Node, key.it)); - } - *l_loop = ARMF_CC(ARMI_B, CC_NE) | ((as->mcp-l_loop-2) & 0x00ffffffu); - - /* Load main position relative to tab->node into dest. */ - khash = irref_isk(refkey) ? ir_khash(irkey) : 1; - if (khash == 0) { - emit_lso(as, ARMI_LDR, dest, tab, (int32_t)offsetof(GCtab, node)); - } else { - emit_dnm(as, ARMI_ADD|ARMF_SH(ARMSH_LSL, 3), dest, dest, tmp); - emit_dnm(as, ARMI_ADD|ARMF_SH(ARMSH_LSL, 1), tmp, tmp, tmp); - if (irt_isstr(kt)) { /* Fetch of str->hash is cheaper than ra_allock. */ - emit_dnm(as, ARMI_AND, tmp, tmp+1, RID_TMP); - emit_lso(as, ARMI_LDR, dest, tab, (int32_t)offsetof(GCtab, node)); - emit_lso(as, ARMI_LDR, tmp+1, key, (int32_t)offsetof(GCstr, hash)); - emit_lso(as, ARMI_LDR, RID_TMP, tab, (int32_t)offsetof(GCtab, hmask)); - } else if (irref_isk(refkey)) { - emit_opk(as, ARMI_AND, tmp, RID_TMP, (int32_t)khash, - rset_exclude(rset_exclude(RSET_GPR, tab), dest)); - emit_lso(as, ARMI_LDR, dest, tab, (int32_t)offsetof(GCtab, node)); - emit_lso(as, ARMI_LDR, RID_TMP, tab, (int32_t)offsetof(GCtab, hmask)); - } else { /* Must match with hash*() in lj_tab.c. */ - if (ra_hasreg(keynumhi)) { /* Canonicalize +-0.0 to 0.0. */ - if (keyhi == RID_TMP) - emit_dm(as, ARMF_CC(ARMI_MOV, CC_NE), keyhi, keynumhi); - emit_d(as, ARMF_CC(ARMI_MOV, CC_EQ)|ARMI_K12|0, keyhi); - } - emit_dnm(as, ARMI_AND, tmp, tmp, RID_TMP); - emit_dnm(as, ARMI_SUB|ARMF_SH(ARMSH_ROR, 32-HASH_ROT3), tmp, tmp, tmp+1); - emit_lso(as, ARMI_LDR, dest, tab, (int32_t)offsetof(GCtab, node)); - emit_dnm(as, ARMI_EOR|ARMF_SH(ARMSH_ROR, 32-((HASH_ROT2+HASH_ROT1)&31)), - tmp, tmp+1, tmp); - emit_lso(as, ARMI_LDR, RID_TMP, tab, (int32_t)offsetof(GCtab, hmask)); - emit_dnm(as, ARMI_SUB|ARMF_SH(ARMSH_ROR, 32-HASH_ROT1), tmp+1, tmp+1, tmp); - if (ra_hasreg(keynumhi)) { - emit_dnm(as, ARMI_EOR, tmp+1, tmp, key); - emit_dnm(as, ARMI_ORR|ARMI_S, RID_TMP, tmp, key); /* Test for +-0.0. */ - emit_dnm(as, ARMI_ADD, tmp, keynumhi, keynumhi); -#if !LJ_SOFTFP - emit_dnm(as, ARMI_VMOV_RR_D, key, keynumhi, - (ra_alloc1(as, refkey, RSET_FPR) & 15)); -#endif - } else { - emit_dnm(as, ARMI_EOR, tmp+1, tmp, key); - emit_opk(as, ARMI_ADD, tmp, key, (int32_t)HASH_BIAS, - rset_exclude(rset_exclude(RSET_GPR, tab), key)); - } - } - } -} - -static void asm_hrefk(ASMState *as, IRIns *ir) -{ - IRIns *kslot = IR(ir->op2); - IRIns *irkey = IR(kslot->op1); - int32_t ofs = (int32_t)(kslot->op2 * sizeof(Node)); - int32_t kofs = ofs + (int32_t)offsetof(Node, key); - Reg dest = (ra_used(ir) || ofs > 4095) ? ra_dest(as, ir, RSET_GPR) : RID_NONE; - Reg node = ra_alloc1(as, ir->op1, RSET_GPR); - Reg key = RID_NONE, type = RID_TMP, idx = node; - RegSet allow = rset_exclude(RSET_GPR, node); - lua_assert(ofs % sizeof(Node) == 0); - if (ofs > 4095) { - idx = dest; - rset_clear(allow, dest); - kofs = (int32_t)offsetof(Node, key); - } else if (ra_hasreg(dest)) { - emit_opk(as, ARMI_ADD, dest, node, ofs, allow); - } - asm_guardcc(as, CC_NE); - if (!irt_ispri(irkey->t)) { - RegSet even = (as->freeset & allow); - even = even & (even >> 1) & RSET_GPREVEN; - if (even) { - key = ra_scratch(as, even); - if (rset_test(as->freeset, key+1)) { - type = key+1; - ra_modified(as, type); - } - } else { - key = ra_scratch(as, allow); - } - rset_clear(allow, key); - } - rset_clear(allow, type); - if (irt_isnum(irkey->t)) { - emit_opk(as, ARMF_CC(ARMI_CMP, CC_EQ), 0, type, - (int32_t)ir_knum(irkey)->u32.hi, allow); - emit_opk(as, ARMI_CMP, 0, key, - (int32_t)ir_knum(irkey)->u32.lo, allow); - } else { - if (ra_hasreg(key)) - emit_opk(as, ARMF_CC(ARMI_CMP, CC_EQ), 0, key, irkey->i, allow); - emit_n(as, ARMI_CMN|ARMI_K12|-irt_toitype(irkey->t), type); - } - emit_lso(as, ARMI_LDR, type, idx, kofs+4); - if (ra_hasreg(key)) emit_lso(as, ARMI_LDR, key, idx, kofs); - if (ofs > 4095) - emit_opk(as, ARMI_ADD, dest, node, ofs, RSET_GPR); -} - -static void asm_newref(ASMState *as, IRIns *ir) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_newkey]; - IRRef args[3]; - if (ir->r == RID_SINK) - return; - args[0] = ASMREF_L; /* lua_State *L */ - args[1] = ir->op1; /* GCtab *t */ - args[2] = ASMREF_TMP1; /* cTValue *key */ - asm_setupresult(as, ir, ci); /* TValue * */ - asm_gencall(as, ci, args); - asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op2); -} - -static void asm_uref(ASMState *as, IRIns *ir) -{ - /* NYI: Check that UREFO is still open and not aliasing a slot. */ - Reg dest = ra_dest(as, ir, RSET_GPR); - if (irref_isk(ir->op1)) { - GCfunc *fn = ir_kfunc(IR(ir->op1)); - MRef *v = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.v; - emit_lsptr(as, ARMI_LDR, dest, v); - } else { - Reg uv = ra_scratch(as, RSET_GPR); - Reg func = ra_alloc1(as, ir->op1, RSET_GPR); - if (ir->o == IR_UREFC) { - asm_guardcc(as, CC_NE); - emit_n(as, ARMI_CMP|ARMI_K12|1, RID_TMP); - emit_opk(as, ARMI_ADD, dest, uv, - (int32_t)offsetof(GCupval, tv), RSET_GPR); - emit_lso(as, ARMI_LDRB, RID_TMP, uv, (int32_t)offsetof(GCupval, closed)); - } else { - emit_lso(as, ARMI_LDR, dest, uv, (int32_t)offsetof(GCupval, v)); - } - emit_lso(as, ARMI_LDR, uv, func, - (int32_t)offsetof(GCfuncL, uvptr) + 4*(int32_t)(ir->op2 >> 8)); - } -} - -static void asm_fref(ASMState *as, IRIns *ir) -{ - UNUSED(as); UNUSED(ir); - lua_assert(!ra_used(ir)); -} - -static void asm_strref(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - IRRef ref = ir->op2, refk = ir->op1; - Reg r; - if (irref_isk(ref)) { - IRRef tmp = refk; refk = ref; ref = tmp; - } else if (!irref_isk(refk)) { - uint32_t k, m = ARMI_K12|sizeof(GCstr); - Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); - IRIns *irr = IR(ir->op2); - if (ra_hasreg(irr->r)) { - ra_noweak(as, irr->r); - right = irr->r; - } else if (mayfuse(as, irr->op2) && - irr->o == IR_ADD && irref_isk(irr->op2) && - (k = emit_isk12(ARMI_ADD, - (int32_t)sizeof(GCstr) + IR(irr->op2)->i))) { - m = k; - right = ra_alloc1(as, irr->op1, rset_exclude(RSET_GPR, left)); - } else { - right = ra_allocref(as, ir->op2, rset_exclude(RSET_GPR, left)); - } - emit_dn(as, ARMI_ADD^m, dest, dest); - emit_dnm(as, ARMI_ADD, dest, left, right); - return; - } - r = ra_alloc1(as, ref, RSET_GPR); - emit_opk(as, ARMI_ADD, dest, r, - sizeof(GCstr) + IR(refk)->i, rset_exclude(RSET_GPR, r)); -} - -/* -- Loads and stores ---------------------------------------------------- */ - -static ARMIns asm_fxloadins(IRIns *ir) -{ - switch (irt_type(ir->t)) { - case IRT_I8: return ARMI_LDRSB; - case IRT_U8: return ARMI_LDRB; - case IRT_I16: return ARMI_LDRSH; - case IRT_U16: return ARMI_LDRH; - case IRT_NUM: lua_assert(!LJ_SOFTFP); return ARMI_VLDR_D; - case IRT_FLOAT: if (!LJ_SOFTFP) return ARMI_VLDR_S; - default: return ARMI_LDR; - } -} - -static ARMIns asm_fxstoreins(IRIns *ir) -{ - switch (irt_type(ir->t)) { - case IRT_I8: case IRT_U8: return ARMI_STRB; - case IRT_I16: case IRT_U16: return ARMI_STRH; - case IRT_NUM: lua_assert(!LJ_SOFTFP); return ARMI_VSTR_D; - case IRT_FLOAT: if (!LJ_SOFTFP) return ARMI_VSTR_S; - default: return ARMI_STR; - } -} - -static void asm_fload(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg idx = ra_alloc1(as, ir->op1, RSET_GPR); - ARMIns ai = asm_fxloadins(ir); - int32_t ofs; - if (ir->op2 == IRFL_TAB_ARRAY) { - ofs = asm_fuseabase(as, ir->op1); - if (ofs) { /* Turn the t->array load into an add for colocated arrays. */ - emit_dn(as, ARMI_ADD|ARMI_K12|ofs, dest, idx); - return; - } - } - ofs = field_ofs[ir->op2]; - if ((ai & 0x04000000)) - emit_lso(as, ai, dest, idx, ofs); - else - emit_lsox(as, ai, dest, idx, ofs); -} - -static void asm_fstore(ASMState *as, IRIns *ir) -{ - if (ir->r != RID_SINK) { - Reg src = ra_alloc1(as, ir->op2, RSET_GPR); - IRIns *irf = IR(ir->op1); - Reg idx = ra_alloc1(as, irf->op1, rset_exclude(RSET_GPR, src)); - int32_t ofs = field_ofs[irf->op2]; - ARMIns ai = asm_fxstoreins(ir); - if ((ai & 0x04000000)) - emit_lso(as, ai, src, idx, ofs); - else - emit_lsox(as, ai, src, idx, ofs); - } -} - -static void asm_xload(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, - (!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR); - lua_assert(!(ir->op2 & IRXLOAD_UNALIGNED)); - asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR, 0); -} - -static void asm_xstore(ASMState *as, IRIns *ir, int32_t ofs) -{ - if (ir->r != RID_SINK) { - Reg src = ra_alloc1(as, ir->op2, - (!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR); - asm_fusexref(as, asm_fxstoreins(ir), src, ir->op1, - rset_exclude(RSET_GPR, src), ofs); - } -} - -static void asm_ahuvload(ASMState *as, IRIns *ir) -{ - int hiop = (LJ_SOFTFP && (ir+1)->o == IR_HIOP); - IRType t = hiop ? IRT_NUM : irt_type(ir->t); - Reg dest = RID_NONE, type = RID_NONE, idx; - RegSet allow = RSET_GPR; - int32_t ofs = 0; - if (hiop && ra_used(ir+1)) { - type = ra_dest(as, ir+1, allow); - rset_clear(allow, type); - } - if (ra_used(ir)) { - lua_assert((LJ_SOFTFP ? 0 : irt_isnum(ir->t)) || - irt_isint(ir->t) || irt_isaddr(ir->t)); - dest = ra_dest(as, ir, (!LJ_SOFTFP && t == IRT_NUM) ? RSET_FPR : allow); - rset_clear(allow, dest); - } - idx = asm_fuseahuref(as, ir->op1, &ofs, allow, - (!LJ_SOFTFP && t == IRT_NUM) ? 1024 : 4096); - if (!hiop || type == RID_NONE) { - rset_clear(allow, idx); - if (ofs < 256 && ra_hasreg(dest) && (dest & 1) == 0 && - rset_test((as->freeset & allow), dest+1)) { - type = dest+1; - ra_modified(as, type); - } else { - type = RID_TMP; - } - } - asm_guardcc(as, t == IRT_NUM ? CC_HS : CC_NE); - emit_n(as, ARMI_CMN|ARMI_K12|-irt_toitype_(t), type); - if (ra_hasreg(dest)) { -#if !LJ_SOFTFP - if (t == IRT_NUM) - emit_vlso(as, ARMI_VLDR_D, dest, idx, ofs); - else -#endif - emit_lso(as, ARMI_LDR, dest, idx, ofs); - } - emit_lso(as, ARMI_LDR, type, idx, ofs+4); -} - -static void asm_ahustore(ASMState *as, IRIns *ir) -{ - if (ir->r != RID_SINK) { - RegSet allow = RSET_GPR; - Reg idx, src = RID_NONE, type = RID_NONE; - int32_t ofs = 0; -#if !LJ_SOFTFP - if (irt_isnum(ir->t)) { - src = ra_alloc1(as, ir->op2, RSET_FPR); - idx = asm_fuseahuref(as, ir->op1, &ofs, allow, 1024); - emit_vlso(as, ARMI_VSTR_D, src, idx, ofs); - } else -#endif - { - int hiop = (LJ_SOFTFP && (ir+1)->o == IR_HIOP); - if (!irt_ispri(ir->t)) { - src = ra_alloc1(as, ir->op2, allow); - rset_clear(allow, src); - } - if (hiop) - type = ra_alloc1(as, (ir+1)->op2, allow); - else - type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); - idx = asm_fuseahuref(as, ir->op1, &ofs, rset_exclude(allow, type), 4096); - if (ra_hasreg(src)) emit_lso(as, ARMI_STR, src, idx, ofs); - emit_lso(as, ARMI_STR, type, idx, ofs+4); - } - } -} - -static void asm_sload(ASMState *as, IRIns *ir) -{ - int32_t ofs = 8*((int32_t)ir->op1-1) + ((ir->op2 & IRSLOAD_FRAME) ? 4 : 0); - int hiop = (LJ_SOFTFP && (ir+1)->o == IR_HIOP); - IRType t = hiop ? IRT_NUM : irt_type(ir->t); - Reg dest = RID_NONE, type = RID_NONE, base; - RegSet allow = RSET_GPR; - lua_assert(!(ir->op2 & IRSLOAD_PARENT)); /* Handled by asm_head_side(). */ - lua_assert(irt_isguard(ir->t) || !(ir->op2 & IRSLOAD_TYPECHECK)); -#if LJ_SOFTFP - lua_assert(!(ir->op2 & IRSLOAD_CONVERT)); /* Handled by LJ_SOFTFP SPLIT. */ - if (hiop && ra_used(ir+1)) { - type = ra_dest(as, ir+1, allow); - rset_clear(allow, type); - } -#else - if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(ir->t) && t == IRT_INT) { - dest = ra_scratch(as, RSET_FPR); - asm_tointg(as, ir, dest); - t = IRT_NUM; /* Continue with a regular number type check. */ - } else -#endif - if (ra_used(ir)) { - Reg tmp = RID_NONE; - if ((ir->op2 & IRSLOAD_CONVERT)) - tmp = ra_scratch(as, t == IRT_INT ? RSET_FPR : RSET_GPR); - lua_assert((LJ_SOFTFP ? 0 : irt_isnum(ir->t)) || - irt_isint(ir->t) || irt_isaddr(ir->t)); - dest = ra_dest(as, ir, (!LJ_SOFTFP && t == IRT_NUM) ? RSET_FPR : allow); - rset_clear(allow, dest); - base = ra_alloc1(as, REF_BASE, allow); - if ((ir->op2 & IRSLOAD_CONVERT)) { - if (t == IRT_INT) { - emit_dn(as, ARMI_VMOV_R_S, dest, (tmp & 15)); - emit_dm(as, ARMI_VCVT_S32_F64, (tmp & 15), (tmp & 15)); - t = IRT_NUM; /* Check for original type. */ - } else { - emit_dm(as, ARMI_VCVT_F64_S32, (dest & 15), (dest & 15)); - emit_dn(as, ARMI_VMOV_S_R, tmp, (dest & 15)); - t = IRT_INT; /* Check for original type. */ - } - dest = tmp; - } - goto dotypecheck; - } - base = ra_alloc1(as, REF_BASE, allow); -dotypecheck: - rset_clear(allow, base); - if ((ir->op2 & IRSLOAD_TYPECHECK)) { - if (ra_noreg(type)) { - if (ofs < 256 && ra_hasreg(dest) && (dest & 1) == 0 && - rset_test((as->freeset & allow), dest+1)) { - type = dest+1; - ra_modified(as, type); - } else { - type = RID_TMP; - } - } - asm_guardcc(as, t == IRT_NUM ? CC_HS : CC_NE); - emit_n(as, ARMI_CMN|ARMI_K12|-irt_toitype_(t), type); - } - if (ra_hasreg(dest)) { -#if !LJ_SOFTFP - if (t == IRT_NUM) { - if (ofs < 1024) { - emit_vlso(as, ARMI_VLDR_D, dest, base, ofs); - } else { - if (ra_hasreg(type)) emit_lso(as, ARMI_LDR, type, base, ofs+4); - emit_vlso(as, ARMI_VLDR_D, dest, RID_TMP, 0); - emit_opk(as, ARMI_ADD, RID_TMP, base, ofs, allow); - return; - } - } else -#endif - emit_lso(as, ARMI_LDR, dest, base, ofs); - } - if (ra_hasreg(type)) emit_lso(as, ARMI_LDR, type, base, ofs+4); -} - -/* -- Allocations --------------------------------------------------------- */ - -#if LJ_HASFFI -static void asm_cnew(ASMState *as, IRIns *ir) -{ - CTState *cts = ctype_ctsG(J2G(as->J)); - CTypeID ctypeid = (CTypeID)IR(ir->op1)->i; - CTSize sz = (ir->o == IR_CNEWI || ir->op2 == REF_NIL) ? - lj_ctype_size(cts, ctypeid) : (CTSize)IR(ir->op2)->i; - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco]; - IRRef args[2]; - RegSet allow = (RSET_GPR & ~RSET_SCRATCH); - RegSet drop = RSET_SCRATCH; - lua_assert(sz != CTSIZE_INVALID); - - args[0] = ASMREF_L; /* lua_State *L */ - args[1] = ASMREF_TMP1; /* MSize size */ - as->gcsteps++; - - if (ra_hasreg(ir->r)) - rset_clear(drop, ir->r); /* Dest reg handled below. */ - ra_evictset(as, drop); - if (ra_used(ir)) - ra_destreg(as, ir, RID_RET); /* GCcdata * */ - - /* Initialize immutable cdata object. */ - if (ir->o == IR_CNEWI) { - int32_t ofs = sizeof(GCcdata); - lua_assert(sz == 4 || sz == 8); - if (sz == 8) { - ofs += 4; ir++; - lua_assert(ir->o == IR_HIOP); - } - for (;;) { - Reg r = ra_alloc1(as, ir->op2, allow); - emit_lso(as, ARMI_STR, r, RID_RET, ofs); - rset_clear(allow, r); - if (ofs == sizeof(GCcdata)) break; - ofs -= 4; ir--; - } - } - /* Initialize gct and ctypeid. lj_mem_newgco() already sets marked. */ - { - uint32_t k = emit_isk12(ARMI_MOV, ctypeid); - Reg r = k ? RID_R1 : ra_allock(as, ctypeid, allow); - emit_lso(as, ARMI_STRB, RID_TMP, RID_RET, offsetof(GCcdata, gct)); - emit_lsox(as, ARMI_STRH, r, RID_RET, offsetof(GCcdata, ctypeid)); - emit_d(as, ARMI_MOV|ARMI_K12|~LJ_TCDATA, RID_TMP); - if (k) emit_d(as, ARMI_MOV^k, RID_R1); - } - asm_gencall(as, ci, args); - ra_allockreg(as, (int32_t)(sz+sizeof(GCcdata)), - ra_releasetmp(as, ASMREF_TMP1)); -} -#else -#define asm_cnew(as, ir) ((void)0) -#endif - -/* -- Write barriers ------------------------------------------------------ */ - -static void asm_tbar(ASMState *as, IRIns *ir) -{ - Reg tab = ra_alloc1(as, ir->op1, RSET_GPR); - Reg link = ra_scratch(as, rset_exclude(RSET_GPR, tab)); - Reg gr = ra_allock(as, i32ptr(J2G(as->J)), - rset_exclude(rset_exclude(RSET_GPR, tab), link)); - Reg mark = RID_TMP; - MCLabel l_end = emit_label(as); - emit_lso(as, ARMI_STR, link, tab, (int32_t)offsetof(GCtab, gclist)); - emit_lso(as, ARMI_STRB, mark, tab, (int32_t)offsetof(GCtab, marked)); - emit_lso(as, ARMI_STR, tab, gr, - (int32_t)offsetof(global_State, gc.grayagain)); - emit_dn(as, ARMI_BIC|ARMI_K12|LJ_GC_BLACK, mark, mark); - emit_lso(as, ARMI_LDR, link, gr, - (int32_t)offsetof(global_State, gc.grayagain)); - emit_branch(as, ARMF_CC(ARMI_B, CC_EQ), l_end); - emit_n(as, ARMI_TST|ARMI_K12|LJ_GC_BLACK, mark); - emit_lso(as, ARMI_LDRB, mark, tab, (int32_t)offsetof(GCtab, marked)); -} - -static void asm_obar(ASMState *as, IRIns *ir) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_barrieruv]; - IRRef args[2]; - MCLabel l_end; - Reg obj, val, tmp; - /* No need for other object barriers (yet). */ - lua_assert(IR(ir->op1)->o == IR_UREFC); - ra_evictset(as, RSET_SCRATCH); - l_end = emit_label(as); - args[0] = ASMREF_TMP1; /* global_State *g */ - args[1] = ir->op1; /* TValue *tv */ - asm_gencall(as, ci, args); - if ((l_end[-1] >> 28) == CC_AL) - l_end[-1] = ARMF_CC(l_end[-1], CC_NE); - else - emit_branch(as, ARMF_CC(ARMI_B, CC_EQ), l_end); - ra_allockreg(as, i32ptr(J2G(as->J)), ra_releasetmp(as, ASMREF_TMP1)); - obj = IR(ir->op1)->r; - tmp = ra_scratch(as, rset_exclude(RSET_GPR, obj)); - emit_n(as, ARMF_CC(ARMI_TST, CC_NE)|ARMI_K12|LJ_GC_BLACK, tmp); - emit_n(as, ARMI_TST|ARMI_K12|LJ_GC_WHITES, RID_TMP); - val = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, obj)); - emit_lso(as, ARMI_LDRB, tmp, obj, - (int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)); - emit_lso(as, ARMI_LDRB, RID_TMP, val, (int32_t)offsetof(GChead, marked)); -} - -/* -- Arithmetic and logic operations ------------------------------------- */ - -#if !LJ_SOFTFP -static void asm_fparith(ASMState *as, IRIns *ir, ARMIns ai) -{ - Reg dest = ra_dest(as, ir, RSET_FPR); - Reg right, left = ra_alloc2(as, ir, RSET_FPR); - right = (left >> 8); left &= 255; - emit_dnm(as, ai, (dest & 15), (left & 15), (right & 15)); -} - -static void asm_fpunary(ASMState *as, IRIns *ir, ARMIns ai) -{ - Reg dest = ra_dest(as, ir, RSET_FPR); - Reg left = ra_hintalloc(as, ir->op1, dest, RSET_FPR); - emit_dm(as, ai, (dest & 15), (left & 15)); -} - -static int asm_fpjoin_pow(ASMState *as, IRIns *ir) -{ - IRIns *irp = IR(ir->op1); - if (irp == ir-1 && irp->o == IR_MUL && !ra_used(irp)) { - IRIns *irpp = IR(irp->op1); - if (irpp == ir-2 && irpp->o == IR_FPMATH && - irpp->op2 == IRFPM_LOG2 && !ra_used(irpp)) { - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_pow]; - IRRef args[2]; - args[0] = irpp->op1; - args[1] = irp->op2; - asm_setupresult(as, ir, ci); - asm_gencall(as, ci, args); - return 1; - } - } - return 0; -} -#endif - -static int asm_swapops(ASMState *as, IRRef lref, IRRef rref) -{ - IRIns *ir; - if (irref_isk(rref)) - return 0; /* Don't swap constants to the left. */ - if (irref_isk(lref)) - return 1; /* But swap constants to the right. */ - ir = IR(rref); - if ((ir->o >= IR_BSHL && ir->o <= IR_BROR) || - (ir->o == IR_ADD && ir->op1 == ir->op2)) - return 0; /* Don't swap fusable operands to the left. */ - ir = IR(lref); - if ((ir->o >= IR_BSHL && ir->o <= IR_BROR) || - (ir->o == IR_ADD && ir->op1 == ir->op2)) - return 1; /* But swap fusable operands to the right. */ - return 0; /* Otherwise don't swap. */ -} - -static void asm_intop(ASMState *as, IRIns *ir, ARMIns ai) -{ - IRRef lref = ir->op1, rref = ir->op2; - Reg left, dest = ra_dest(as, ir, RSET_GPR); - uint32_t m; - if (asm_swapops(as, lref, rref)) { - IRRef tmp = lref; lref = rref; rref = tmp; - if ((ai & ~ARMI_S) == ARMI_SUB || (ai & ~ARMI_S) == ARMI_SBC) - ai ^= (ARMI_SUB^ARMI_RSB); - } - left = ra_hintalloc(as, lref, dest, RSET_GPR); - m = asm_fuseopm(as, ai, rref, rset_exclude(RSET_GPR, left)); - if (irt_isguard(ir->t)) { /* For IR_ADDOV etc. */ - asm_guardcc(as, CC_VS); - ai |= ARMI_S; - } - emit_dn(as, ai^m, dest, left); -} - -static void asm_intop_s(ASMState *as, IRIns *ir, ARMIns ai) -{ - if (as->flagmcp == as->mcp) { /* Drop cmp r, #0. */ - as->flagmcp = NULL; - as->mcp++; - ai |= ARMI_S; - } - asm_intop(as, ir, ai); -} - -static void asm_bitop(ASMState *as, IRIns *ir, ARMIns ai) -{ - if (as->flagmcp == as->mcp) { /* Try to drop cmp r, #0. */ - uint32_t cc = (as->mcp[1] >> 28); - as->flagmcp = NULL; - if (cc <= CC_NE) { - as->mcp++; - ai |= ARMI_S; - } else if (cc == CC_GE) { - *++as->mcp ^= ((CC_GE^CC_PL) << 28); - ai |= ARMI_S; - } else if (cc == CC_LT) { - *++as->mcp ^= ((CC_LT^CC_MI) << 28); - ai |= ARMI_S; - } /* else: other conds don't work with bit ops. */ - } - if (ir->op2 == 0) { - Reg dest = ra_dest(as, ir, RSET_GPR); - uint32_t m = asm_fuseopm(as, ai, ir->op1, RSET_GPR); - emit_d(as, ai^m, dest); - } else { - /* NYI: Turn BAND !k12 into uxtb, uxth or bfc or shl+shr. */ - asm_intop(as, ir, ai); - } -} - -static void asm_intneg(ASMState *as, IRIns *ir, ARMIns ai) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); - emit_dn(as, ai|ARMI_K12|0, dest, left); -} - -/* NYI: use add/shift for MUL(OV) with constants. FOLD only does 2^k. */ -static void asm_intmul(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg left = ra_alloc1(as, ir->op1, rset_exclude(RSET_GPR, dest)); - Reg right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); - Reg tmp = RID_NONE; - /* ARMv5 restriction: dest != left and dest_hi != left. */ - if (dest == left && left != right) { left = right; right = dest; } - if (irt_isguard(ir->t)) { /* IR_MULOV */ - if (!(as->flags & JIT_F_ARMV6) && dest == left) - tmp = left = ra_scratch(as, rset_exclude(RSET_GPR, left)); - asm_guardcc(as, CC_NE); - emit_nm(as, ARMI_TEQ|ARMF_SH(ARMSH_ASR, 31), RID_TMP, dest); - emit_dnm(as, ARMI_SMULL|ARMF_S(right), dest, RID_TMP, left); - } else { - if (!(as->flags & JIT_F_ARMV6) && dest == left) tmp = left = RID_TMP; - emit_nm(as, ARMI_MUL|ARMF_S(right), dest, left); - } - /* Only need this for the dest == left == right case. */ - if (ra_hasreg(tmp)) emit_dm(as, ARMI_MOV, tmp, right); -} - -static void asm_add(ASMState *as, IRIns *ir) -{ -#if !LJ_SOFTFP - if (irt_isnum(ir->t)) { - if (!asm_fusemadd(as, ir, ARMI_VMLA_D, ARMI_VMLA_D)) - asm_fparith(as, ir, ARMI_VADD_D); - return; - } -#endif - asm_intop_s(as, ir, ARMI_ADD); -} - -static void asm_sub(ASMState *as, IRIns *ir) -{ -#if !LJ_SOFTFP - if (irt_isnum(ir->t)) { - if (!asm_fusemadd(as, ir, ARMI_VNMLS_D, ARMI_VMLS_D)) - asm_fparith(as, ir, ARMI_VSUB_D); - return; - } -#endif - asm_intop_s(as, ir, ARMI_SUB); -} - -static void asm_mul(ASMState *as, IRIns *ir) -{ -#if !LJ_SOFTFP - if (irt_isnum(ir->t)) { - asm_fparith(as, ir, ARMI_VMUL_D); - return; - } -#endif - asm_intmul(as, ir); -} - -static void asm_neg(ASMState *as, IRIns *ir) -{ -#if !LJ_SOFTFP - if (irt_isnum(ir->t)) { - asm_fpunary(as, ir, ARMI_VNEG_D); - return; - } -#endif - asm_intneg(as, ir, ARMI_RSB); -} - -static void asm_callid(ASMState *as, IRIns *ir, IRCallID id) -{ - const CCallInfo *ci = &lj_ir_callinfo[id]; - IRRef args[2]; - args[0] = ir->op1; - args[1] = ir->op2; - asm_setupresult(as, ir, ci); - asm_gencall(as, ci, args); -} - -#if !LJ_SOFTFP -static void asm_callround(ASMState *as, IRIns *ir, int id) -{ - /* The modified regs must match with the *.dasc implementation. */ - RegSet drop = RID2RSET(RID_R0)|RID2RSET(RID_R1)|RID2RSET(RID_R2)| - RID2RSET(RID_R3)|RID2RSET(RID_R12); - RegSet of; - Reg dest, src; - ra_evictset(as, drop); - dest = ra_dest(as, ir, RSET_FPR); - emit_dnm(as, ARMI_VMOV_D_RR, RID_RETLO, RID_RETHI, (dest & 15)); - emit_call(as, id == IRFPM_FLOOR ? (void *)lj_vm_floor_sf : - id == IRFPM_CEIL ? (void *)lj_vm_ceil_sf : - (void *)lj_vm_trunc_sf); - /* Workaround to protect argument GPRs from being used for remat. */ - of = as->freeset; - as->freeset &= ~RSET_RANGE(RID_R0, RID_R1+1); - as->cost[RID_R0] = as->cost[RID_R1] = REGCOST(~0u, ASMREF_L); - src = ra_alloc1(as, ir->op1, RSET_FPR); /* May alloc GPR to remat FPR. */ - as->freeset |= (of & RSET_RANGE(RID_R0, RID_R1+1)); - emit_dnm(as, ARMI_VMOV_RR_D, RID_R0, RID_R1, (src & 15)); -} -#endif - -static void asm_bitswap(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg left = ra_alloc1(as, ir->op1, RSET_GPR); - if ((as->flags & JIT_F_ARMV6)) { - emit_dm(as, ARMI_REV, dest, left); - } else { - Reg tmp2 = dest; - if (tmp2 == left) - tmp2 = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, dest), left)); - emit_dnm(as, ARMI_EOR|ARMF_SH(ARMSH_LSR, 8), dest, tmp2, RID_TMP); - emit_dm(as, ARMI_MOV|ARMF_SH(ARMSH_ROR, 8), tmp2, left); - emit_dn(as, ARMI_BIC|ARMI_K12|256*8|255, RID_TMP, RID_TMP); - emit_dnm(as, ARMI_EOR|ARMF_SH(ARMSH_ROR, 16), RID_TMP, left, left); - } -} - -static void asm_bitshift(ASMState *as, IRIns *ir, ARMShift sh) -{ - if (irref_isk(ir->op2)) { /* Constant shifts. */ - /* NYI: Turn SHL+SHR or BAND+SHR into uxtb, uxth or ubfx. */ - /* NYI: Turn SHL+ASR into sxtb, sxth or sbfx. */ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg left = ra_alloc1(as, ir->op1, RSET_GPR); - int32_t shift = (IR(ir->op2)->i & 31); - emit_dm(as, ARMI_MOV|ARMF_SH(sh, shift), dest, left); - } else { - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg left = ra_alloc1(as, ir->op1, RSET_GPR); - Reg right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); - emit_dm(as, ARMI_MOV|ARMF_RSH(sh, right), dest, left); - } -} - -static void asm_intmin_max(ASMState *as, IRIns *ir, int cc) -{ - uint32_t kcmp = 0, kmov = 0; - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); - Reg right = 0; - if (irref_isk(ir->op2)) { - kcmp = emit_isk12(ARMI_CMP, IR(ir->op2)->i); - if (kcmp) kmov = emit_isk12(ARMI_MOV, IR(ir->op2)->i); - } - if (!kmov) { - kcmp = 0; - right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); - } - if (kmov || dest != right) { - emit_dm(as, ARMF_CC(ARMI_MOV, cc)^kmov, dest, right); - cc ^= 1; /* Must use opposite conditions for paired moves. */ - } else { - cc ^= (CC_LT^CC_GT); /* Otherwise may swap CC_LT <-> CC_GT. */ - } - if (dest != left) emit_dm(as, ARMF_CC(ARMI_MOV, cc), dest, left); - emit_nm(as, ARMI_CMP^kcmp, left, right); -} - -#if LJ_SOFTFP -static void asm_sfpmin_max(ASMState *as, IRIns *ir, int cc) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_softfp_cmp]; - RegSet drop = RSET_SCRATCH; - Reg r; - IRRef args[4]; - args[0] = ir->op1; args[1] = (ir+1)->op1; - args[2] = ir->op2; args[3] = (ir+1)->op2; - /* __aeabi_cdcmple preserves r0-r3. */ - if (ra_hasreg(ir->r)) rset_clear(drop, ir->r); - if (ra_hasreg((ir+1)->r)) rset_clear(drop, (ir+1)->r); - if (!rset_test(as->freeset, RID_R2) && - regcost_ref(as->cost[RID_R2]) == args[2]) rset_clear(drop, RID_R2); - if (!rset_test(as->freeset, RID_R3) && - regcost_ref(as->cost[RID_R3]) == args[3]) rset_clear(drop, RID_R3); - ra_evictset(as, drop); - ra_destpair(as, ir); - emit_dm(as, ARMF_CC(ARMI_MOV, cc), RID_RETHI, RID_R3); - emit_dm(as, ARMF_CC(ARMI_MOV, cc), RID_RETLO, RID_R2); - emit_call(as, (void *)ci->func); - for (r = RID_R0; r <= RID_R3; r++) - ra_leftov(as, r, args[r-RID_R0]); -} -#else -static void asm_fpmin_max(ASMState *as, IRIns *ir, int cc) -{ - Reg dest = (ra_dest(as, ir, RSET_FPR) & 15); - Reg right, left = ra_alloc2(as, ir, RSET_FPR); - right = ((left >> 8) & 15); left &= 15; - if (dest != left) emit_dm(as, ARMF_CC(ARMI_VMOV_D, cc^1), dest, left); - if (dest != right) emit_dm(as, ARMF_CC(ARMI_VMOV_D, cc), dest, right); - emit_d(as, ARMI_VMRS, 0); - emit_dm(as, ARMI_VCMP_D, left, right); -} -#endif - -static void asm_min_max(ASMState *as, IRIns *ir, int cc, int fcc) -{ -#if LJ_SOFTFP - UNUSED(fcc); -#else - if (irt_isnum(ir->t)) - asm_fpmin_max(as, ir, fcc); - else -#endif - asm_intmin_max(as, ir, cc); -} - -/* -- Comparisons --------------------------------------------------------- */ - -/* Map of comparisons to flags. ORDER IR. */ -static const uint8_t asm_compmap[IR_ABC+1] = { - /* op FP swp int cc FP cc */ - /* LT */ CC_GE + (CC_HS << 4), - /* GE x */ CC_LT + (CC_HI << 4), - /* LE */ CC_GT + (CC_HI << 4), - /* GT x */ CC_LE + (CC_HS << 4), - /* ULT x */ CC_HS + (CC_LS << 4), - /* UGE */ CC_LO + (CC_LO << 4), - /* ULE x */ CC_HI + (CC_LO << 4), - /* UGT */ CC_LS + (CC_LS << 4), - /* EQ */ CC_NE + (CC_NE << 4), - /* NE */ CC_EQ + (CC_EQ << 4), - /* ABC */ CC_LS + (CC_LS << 4) /* Same as UGT. */ -}; - -#if LJ_SOFTFP -/* FP comparisons. */ -static void asm_sfpcomp(ASMState *as, IRIns *ir) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_softfp_cmp]; - RegSet drop = RSET_SCRATCH; - Reg r; - IRRef args[4]; - int swp = (((ir->o ^ (ir->o >> 2)) & ~(ir->o >> 3) & 1) << 1); - args[swp^0] = ir->op1; args[swp^1] = (ir+1)->op1; - args[swp^2] = ir->op2; args[swp^3] = (ir+1)->op2; - /* __aeabi_cdcmple preserves r0-r3. This helps to reduce spills. */ - for (r = RID_R0; r <= RID_R3; r++) - if (!rset_test(as->freeset, r) && - regcost_ref(as->cost[r]) == args[r-RID_R0]) rset_clear(drop, r); - ra_evictset(as, drop); - asm_guardcc(as, (asm_compmap[ir->o] >> 4)); - emit_call(as, (void *)ci->func); - for (r = RID_R0; r <= RID_R3; r++) - ra_leftov(as, r, args[r-RID_R0]); -} -#else -/* FP comparisons. */ -static void asm_fpcomp(ASMState *as, IRIns *ir) -{ - Reg left, right; - ARMIns ai; - int swp = ((ir->o ^ (ir->o >> 2)) & ~(ir->o >> 3) & 1); - if (!swp && irref_isk(ir->op2) && ir_knum(IR(ir->op2))->u64 == 0) { - left = (ra_alloc1(as, ir->op1, RSET_FPR) & 15); - right = 0; - ai = ARMI_VCMPZ_D; - } else { - left = ra_alloc2(as, ir, RSET_FPR); - if (swp) { - right = (left & 15); left = ((left >> 8) & 15); - } else { - right = ((left >> 8) & 15); left &= 15; - } - ai = ARMI_VCMP_D; - } - asm_guardcc(as, (asm_compmap[ir->o] >> 4)); - emit_d(as, ARMI_VMRS, 0); - emit_dm(as, ai, left, right); -} -#endif - -/* Integer comparisons. */ -static void asm_intcomp(ASMState *as, IRIns *ir) -{ - ARMCC cc = (asm_compmap[ir->o] & 15); - IRRef lref = ir->op1, rref = ir->op2; - Reg left; - uint32_t m; - int cmpprev0 = 0; - lua_assert(irt_isint(ir->t) || irt_isu32(ir->t) || irt_isaddr(ir->t)); - if (asm_swapops(as, lref, rref)) { - Reg tmp = lref; lref = rref; rref = tmp; - if (cc >= CC_GE) cc ^= 7; /* LT <-> GT, LE <-> GE */ - else if (cc > CC_NE) cc ^= 11; /* LO <-> HI, LS <-> HS */ - } - if (irref_isk(rref) && IR(rref)->i == 0) { - IRIns *irl = IR(lref); - cmpprev0 = (irl+1 == ir); - /* Combine comp(BAND(left, right), 0) into tst left, right. */ - if (cmpprev0 && irl->o == IR_BAND && !ra_used(irl)) { - IRRef blref = irl->op1, brref = irl->op2; - uint32_t m2 = 0; - Reg bleft; - if (asm_swapops(as, blref, brref)) { - Reg tmp = blref; blref = brref; brref = tmp; - } - if (irref_isk(brref)) { - m2 = emit_isk12(ARMI_AND, IR(brref)->i); - if ((m2 & (ARMI_AND^ARMI_BIC))) - goto notst; /* Not beneficial if we miss a constant operand. */ - } - if (cc == CC_GE) cc = CC_PL; - else if (cc == CC_LT) cc = CC_MI; - else if (cc > CC_NE) goto notst; /* Other conds don't work with tst. */ - bleft = ra_alloc1(as, blref, RSET_GPR); - if (!m2) m2 = asm_fuseopm(as, 0, brref, rset_exclude(RSET_GPR, bleft)); - asm_guardcc(as, cc); - emit_n(as, ARMI_TST^m2, bleft); - return; - } - } -notst: - left = ra_alloc1(as, lref, RSET_GPR); - m = asm_fuseopm(as, ARMI_CMP, rref, rset_exclude(RSET_GPR, left)); - asm_guardcc(as, cc); - emit_n(as, ARMI_CMP^m, left); - /* Signed comparison with zero and referencing previous ins? */ - if (cmpprev0 && (cc <= CC_NE || cc >= CC_GE)) - as->flagmcp = as->mcp; /* Allow elimination of the compare. */ -} - -#if LJ_HASFFI -/* 64 bit integer comparisons. */ -static void asm_int64comp(ASMState *as, IRIns *ir) -{ - int signedcomp = (ir->o <= IR_GT); - ARMCC cclo, cchi; - Reg leftlo, lefthi; - uint32_t mlo, mhi; - RegSet allow = RSET_GPR, oldfree; - - /* Always use unsigned comparison for loword. */ - cclo = asm_compmap[ir->o + (signedcomp ? 4 : 0)] & 15; - leftlo = ra_alloc1(as, ir->op1, allow); - oldfree = as->freeset; - mlo = asm_fuseopm(as, ARMI_CMP, ir->op2, rset_clear(allow, leftlo)); - allow &= ~(oldfree & ~as->freeset); /* Update for allocs of asm_fuseopm. */ - - /* Use signed or unsigned comparison for hiword. */ - cchi = asm_compmap[ir->o] & 15; - lefthi = ra_alloc1(as, (ir+1)->op1, allow); - mhi = asm_fuseopm(as, ARMI_CMP, (ir+1)->op2, rset_clear(allow, lefthi)); - - /* All register allocations must be performed _before_ this point. */ - if (signedcomp) { - MCLabel l_around = emit_label(as); - asm_guardcc(as, cclo); - emit_n(as, ARMI_CMP^mlo, leftlo); - emit_branch(as, ARMF_CC(ARMI_B, CC_NE), l_around); - if (cchi == CC_GE || cchi == CC_LE) cchi ^= 6; /* GE -> GT, LE -> LT */ - asm_guardcc(as, cchi); - } else { - asm_guardcc(as, cclo); - emit_n(as, ARMF_CC(ARMI_CMP, CC_EQ)^mlo, leftlo); - } - emit_n(as, ARMI_CMP^mhi, lefthi); -} -#endif - -/* -- Support for 64 bit ops in 32 bit mode ------------------------------- */ - -/* Hiword op of a split 64 bit op. Previous op must be the loword op. */ -static void asm_hiop(ASMState *as, IRIns *ir) -{ -#if LJ_HASFFI || LJ_SOFTFP - /* HIOP is marked as a store because it needs its own DCE logic. */ - int uselo = ra_used(ir-1), usehi = ra_used(ir); /* Loword/hiword used? */ - if (LJ_UNLIKELY(!(as->flags & JIT_F_OPT_DCE))) uselo = usehi = 1; - if ((ir-1)->o <= IR_NE) { /* 64 bit integer or FP comparisons. ORDER IR. */ - as->curins--; /* Always skip the loword comparison. */ -#if LJ_SOFTFP - if (!irt_isint(ir->t)) { - asm_sfpcomp(as, ir-1); - return; - } -#endif -#if LJ_HASFFI - asm_int64comp(as, ir-1); -#endif - return; -#if LJ_SOFTFP - } else if ((ir-1)->o == IR_MIN || (ir-1)->o == IR_MAX) { - as->curins--; /* Always skip the loword min/max. */ - if (uselo || usehi) - asm_sfpmin_max(as, ir-1, (ir-1)->o == IR_MIN ? CC_HI : CC_LO); - return; -#elif LJ_HASFFI - } else if ((ir-1)->o == IR_CONV) { - as->curins--; /* Always skip the CONV. */ - if (usehi || uselo) - asm_conv64(as, ir); - return; -#endif - } else if ((ir-1)->o == IR_XSTORE) { - if ((ir-1)->r != RID_SINK) - asm_xstore(as, ir, 4); - return; - } - if (!usehi) return; /* Skip unused hiword op for all remaining ops. */ - switch ((ir-1)->o) { -#if LJ_HASFFI - case IR_ADD: - as->curins--; - asm_intop(as, ir, ARMI_ADC); - asm_intop(as, ir-1, ARMI_ADD|ARMI_S); - break; - case IR_SUB: - as->curins--; - asm_intop(as, ir, ARMI_SBC); - asm_intop(as, ir-1, ARMI_SUB|ARMI_S); - break; - case IR_NEG: - as->curins--; - asm_intneg(as, ir, ARMI_RSC); - asm_intneg(as, ir-1, ARMI_RSB|ARMI_S); - break; -#endif -#if LJ_SOFTFP - case IR_SLOAD: case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: - case IR_STRTO: - if (!uselo) - ra_allocref(as, ir->op1, RSET_GPR); /* Mark lo op as used. */ - break; -#endif - case IR_CALLN: - case IR_CALLS: - case IR_CALLXS: - if (!uselo) - ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */ - break; -#if LJ_SOFTFP - case IR_ASTORE: case IR_HSTORE: case IR_USTORE: case IR_TOSTR: -#endif - case IR_CNEWI: - /* Nothing to do here. Handled by lo op itself. */ - break; - default: lua_assert(0); break; - } -#else - UNUSED(as); UNUSED(ir); lua_assert(0); -#endif -} - -/* -- Stack handling ------------------------------------------------------ */ - -/* Check Lua stack size for overflow. Use exit handler as fallback. */ -static void asm_stack_check(ASMState *as, BCReg topslot, - IRIns *irp, RegSet allow, ExitNo exitno) -{ - Reg pbase; - uint32_t k; - if (irp) { - if (!ra_hasspill(irp->s)) { - pbase = irp->r; - lua_assert(ra_hasreg(pbase)); - } else if (allow) { - pbase = rset_pickbot(allow); - } else { - pbase = RID_RET; - emit_lso(as, ARMI_LDR, RID_RET, RID_SP, 0); /* Restore temp. register. */ - } - } else { - pbase = RID_BASE; - } - emit_branch(as, ARMF_CC(ARMI_BL, CC_LS), exitstub_addr(as->J, exitno)); - k = emit_isk12(0, (int32_t)(8*topslot)); - lua_assert(k); - emit_n(as, ARMI_CMP^k, RID_TMP); - emit_dnm(as, ARMI_SUB, RID_TMP, RID_TMP, pbase); - emit_lso(as, ARMI_LDR, RID_TMP, RID_TMP, - (int32_t)offsetof(lua_State, maxstack)); - if (irp) { /* Must not spill arbitrary registers in head of side trace. */ - int32_t i = i32ptr(&J2G(as->J)->jit_L); - if (ra_hasspill(irp->s)) - emit_lso(as, ARMI_LDR, pbase, RID_SP, sps_scale(irp->s)); - emit_lso(as, ARMI_LDR, RID_TMP, RID_TMP, (i & 4095)); - if (ra_hasspill(irp->s) && !allow) - emit_lso(as, ARMI_STR, RID_RET, RID_SP, 0); /* Save temp. register. */ - emit_loadi(as, RID_TMP, (i & ~4095)); - } else { - emit_getgl(as, RID_TMP, jit_L); - } -} - -/* Restore Lua stack from on-trace state. */ -static void asm_stack_restore(ASMState *as, SnapShot *snap) -{ - SnapEntry *map = &as->T->snapmap[snap->mapofs]; - SnapEntry *flinks = &as->T->snapmap[snap_nextofs(as->T, snap)-1]; - MSize n, nent = snap->nent; - /* Store the value of all modified slots to the Lua stack. */ - for (n = 0; n < nent; n++) { - SnapEntry sn = map[n]; - BCReg s = snap_slot(sn); - int32_t ofs = 8*((int32_t)s-1); - IRRef ref = snap_ref(sn); - IRIns *ir = IR(ref); - if ((sn & SNAP_NORESTORE)) - continue; - if (irt_isnum(ir->t)) { -#if LJ_SOFTFP - RegSet odd = rset_exclude(RSET_GPRODD, RID_BASE); - Reg tmp; - lua_assert(irref_isk(ref)); /* LJ_SOFTFP: must be a number constant. */ - tmp = ra_allock(as, (int32_t)ir_knum(ir)->u32.lo, - rset_exclude(RSET_GPREVEN, RID_BASE)); - emit_lso(as, ARMI_STR, tmp, RID_BASE, ofs); - if (rset_test(as->freeset, tmp+1)) odd = RID2RSET(tmp+1); - tmp = ra_allock(as, (int32_t)ir_knum(ir)->u32.hi, odd); - emit_lso(as, ARMI_STR, tmp, RID_BASE, ofs+4); -#else - Reg src = ra_alloc1(as, ref, RSET_FPR); - emit_vlso(as, ARMI_VSTR_D, src, RID_BASE, ofs); -#endif - } else { - RegSet odd = rset_exclude(RSET_GPRODD, RID_BASE); - Reg type; - lua_assert(irt_ispri(ir->t) || irt_isaddr(ir->t) || irt_isinteger(ir->t)); - if (!irt_ispri(ir->t)) { - Reg src = ra_alloc1(as, ref, rset_exclude(RSET_GPREVEN, RID_BASE)); - emit_lso(as, ARMI_STR, src, RID_BASE, ofs); - if (rset_test(as->freeset, src+1)) odd = RID2RSET(src+1); - } - if ((sn & (SNAP_CONT|SNAP_FRAME))) { - if (s == 0) continue; /* Do not overwrite link to previous frame. */ - type = ra_allock(as, (int32_t)(*flinks--), odd); -#if LJ_SOFTFP - } else if ((sn & SNAP_SOFTFPNUM)) { - type = ra_alloc1(as, ref+1, rset_exclude(RSET_GPRODD, RID_BASE)); -#endif - } else { - type = ra_allock(as, (int32_t)irt_toitype(ir->t), odd); - } - emit_lso(as, ARMI_STR, type, RID_BASE, ofs+4); - } - checkmclim(as); - } - lua_assert(map + nent == flinks); -} - -/* -- GC handling --------------------------------------------------------- */ - -/* Check GC threshold and do one or more GC steps. */ -static void asm_gc_check(ASMState *as) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_step_jit]; - IRRef args[2]; - MCLabel l_end; - Reg tmp1, tmp2; - ra_evictset(as, RSET_SCRATCH); - l_end = emit_label(as); - /* Exit trace if in GCSatomic or GCSfinalize. Avoids syncing GC objects. */ - asm_guardcc(as, CC_NE); /* Assumes asm_snap_prep() already done. */ - emit_n(as, ARMI_CMP|ARMI_K12|0, RID_RET); - args[0] = ASMREF_TMP1; /* global_State *g */ - args[1] = ASMREF_TMP2; /* MSize steps */ - asm_gencall(as, ci, args); - tmp1 = ra_releasetmp(as, ASMREF_TMP1); - tmp2 = ra_releasetmp(as, ASMREF_TMP2); - emit_loadi(as, tmp2, as->gcsteps); - /* Jump around GC step if GC total < GC threshold. */ - emit_branch(as, ARMF_CC(ARMI_B, CC_LS), l_end); - emit_nm(as, ARMI_CMP, RID_TMP, tmp2); - emit_lso(as, ARMI_LDR, tmp2, tmp1, - (int32_t)offsetof(global_State, gc.threshold)); - emit_lso(as, ARMI_LDR, RID_TMP, tmp1, - (int32_t)offsetof(global_State, gc.total)); - ra_allockreg(as, i32ptr(J2G(as->J)), tmp1); - as->gcsteps = 0; - checkmclim(as); -} - -/* -- Loop handling ------------------------------------------------------- */ - -/* Fixup the loop branch. */ -static void asm_loop_fixup(ASMState *as) -{ - MCode *p = as->mctop; - MCode *target = as->mcp; - if (as->loopinv) { /* Inverted loop branch? */ - /* asm_guardcc already inverted the bcc and patched the final bl. */ - p[-2] |= ((uint32_t)(target-p) & 0x00ffffffu); - } else { - p[-1] = ARMI_B | ((uint32_t)((target-p)-1) & 0x00ffffffu); - } -} - -/* -- Head of trace ------------------------------------------------------- */ - -/* Reload L register from g->jit_L. */ -static void asm_head_lreg(ASMState *as) -{ - IRIns *ir = IR(ASMREF_L); - if (ra_used(ir)) { - Reg r = ra_dest(as, ir, RSET_GPR); - emit_getgl(as, r, jit_L); - ra_evictk(as); - } -} - -/* Coalesce BASE register for a root trace. */ -static void asm_head_root_base(ASMState *as) -{ - IRIns *ir; - asm_head_lreg(as); - ir = IR(REF_BASE); - if (ra_hasreg(ir->r) && (rset_test(as->modset, ir->r) || irt_ismarked(ir->t))) - ra_spill(as, ir); - ra_destreg(as, ir, RID_BASE); -} - -/* Coalesce BASE register for a side trace. */ -static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) -{ - IRIns *ir; - asm_head_lreg(as); - ir = IR(REF_BASE); - if (ra_hasreg(ir->r) && (rset_test(as->modset, ir->r) || irt_ismarked(ir->t))) - ra_spill(as, ir); - if (ra_hasspill(irp->s)) { - rset_clear(allow, ra_dest(as, ir, allow)); - } else { - Reg r = irp->r; - lua_assert(ra_hasreg(r)); - rset_clear(allow, r); - if (r != ir->r && !rset_test(as->freeset, r)) - ra_restore(as, regcost_ref(as->cost[r])); - ra_destreg(as, ir, r); - } - return allow; -} - -/* -- Tail of trace ------------------------------------------------------- */ - -/* Fixup the tail code. */ -static void asm_tail_fixup(ASMState *as, TraceNo lnk) -{ - MCode *p = as->mctop; - MCode *target; - int32_t spadj = as->T->spadjust; - if (spadj == 0) { - as->mctop = --p; - } else { - /* Patch stack adjustment. */ - uint32_t k = emit_isk12(ARMI_ADD, spadj); - lua_assert(k); - p[-2] = (ARMI_ADD^k) | ARMF_D(RID_SP) | ARMF_N(RID_SP); - } - /* Patch exit branch. */ - target = lnk ? traceref(as->J, lnk)->mcode : (MCode *)lj_vm_exit_interp; - p[-1] = ARMI_B|(((target-p)-1)&0x00ffffffu); -} - -/* Prepare tail of code. */ -static void asm_tail_prep(ASMState *as) -{ - MCode *p = as->mctop - 1; /* Leave room for exit branch. */ - if (as->loopref) { - as->invmcp = as->mcp = p; - } else { - as->mcp = p-1; /* Leave room for stack pointer adjustment. */ - as->invmcp = NULL; - } - *p = 0; /* Prevent load/store merging. */ -} - -/* -- Instruction dispatch ------------------------------------------------ */ - -/* Assemble a single instruction. */ -static void asm_ir(ASMState *as, IRIns *ir) -{ - switch ((IROp)ir->o) { - /* Miscellaneous ops. */ - case IR_LOOP: asm_loop(as); break; - case IR_NOP: case IR_XBAR: lua_assert(!ra_used(ir)); break; - case IR_USE: - ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break; - case IR_PHI: asm_phi(as, ir); break; - case IR_HIOP: asm_hiop(as, ir); break; - case IR_GCSTEP: asm_gcstep(as, ir); break; - - /* Guarded assertions. */ - case IR_EQ: case IR_NE: - if ((ir-1)->o == IR_HREF && ir->op1 == as->curins-1) { - as->curins--; - asm_href(as, ir-1, (IROp)ir->o); - break; - } - /* fallthrough */ - case IR_LT: case IR_GE: case IR_LE: case IR_GT: - case IR_ULT: case IR_UGE: case IR_ULE: case IR_UGT: - case IR_ABC: -#if !LJ_SOFTFP - if (irt_isnum(ir->t)) { asm_fpcomp(as, ir); break; } -#endif - asm_intcomp(as, ir); - break; - - case IR_RETF: asm_retf(as, ir); break; - - /* Bit ops. */ - case IR_BNOT: asm_bitop(as, ir, ARMI_MVN); break; - case IR_BSWAP: asm_bitswap(as, ir); break; - - case IR_BAND: asm_bitop(as, ir, ARMI_AND); break; - case IR_BOR: asm_bitop(as, ir, ARMI_ORR); break; - case IR_BXOR: asm_bitop(as, ir, ARMI_EOR); break; - - case IR_BSHL: asm_bitshift(as, ir, ARMSH_LSL); break; - case IR_BSHR: asm_bitshift(as, ir, ARMSH_LSR); break; - case IR_BSAR: asm_bitshift(as, ir, ARMSH_ASR); break; - case IR_BROR: asm_bitshift(as, ir, ARMSH_ROR); break; - case IR_BROL: lua_assert(0); break; - - /* Arithmetic ops. */ - case IR_ADD: case IR_ADDOV: asm_add(as, ir); break; - case IR_SUB: case IR_SUBOV: asm_sub(as, ir); break; - case IR_MUL: case IR_MULOV: asm_mul(as, ir); break; - case IR_MOD: asm_callid(as, ir, IRCALL_lj_vm_modi); break; - case IR_NEG: asm_neg(as, ir); break; - -#if LJ_SOFTFP - case IR_DIV: case IR_POW: case IR_ABS: - case IR_ATAN2: case IR_LDEXP: case IR_FPMATH: case IR_TOBIT: - lua_assert(0); /* Unused for LJ_SOFTFP. */ - break; -#else - case IR_DIV: asm_fparith(as, ir, ARMI_VDIV_D); break; - case IR_POW: asm_callid(as, ir, IRCALL_lj_vm_powi); break; - case IR_ABS: asm_fpunary(as, ir, ARMI_VABS_D); break; - case IR_ATAN2: asm_callid(as, ir, IRCALL_atan2); break; - case IR_LDEXP: asm_callid(as, ir, IRCALL_ldexp); break; - case IR_FPMATH: - if (ir->op2 == IRFPM_EXP2 && asm_fpjoin_pow(as, ir)) - break; - if (ir->op2 <= IRFPM_TRUNC) - asm_callround(as, ir, ir->op2); - else if (ir->op2 == IRFPM_SQRT) - asm_fpunary(as, ir, ARMI_VSQRT_D); - else - asm_callid(as, ir, IRCALL_lj_vm_floor + ir->op2); - break; - case IR_TOBIT: asm_tobit(as, ir); break; -#endif - - case IR_MIN: asm_min_max(as, ir, CC_GT, CC_HI); break; - case IR_MAX: asm_min_max(as, ir, CC_LT, CC_LO); break; - - /* Memory references. */ - case IR_AREF: asm_aref(as, ir); break; - case IR_HREF: asm_href(as, ir, 0); break; - case IR_HREFK: asm_hrefk(as, ir); break; - case IR_NEWREF: asm_newref(as, ir); break; - case IR_UREFO: case IR_UREFC: asm_uref(as, ir); break; - case IR_FREF: asm_fref(as, ir); break; - case IR_STRREF: asm_strref(as, ir); break; - - /* Loads and stores. */ - case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: - asm_ahuvload(as, ir); - break; - case IR_FLOAD: asm_fload(as, ir); break; - case IR_XLOAD: asm_xload(as, ir); break; - case IR_SLOAD: asm_sload(as, ir); break; - - case IR_ASTORE: case IR_HSTORE: case IR_USTORE: asm_ahustore(as, ir); break; - case IR_FSTORE: asm_fstore(as, ir); break; - case IR_XSTORE: asm_xstore(as, ir, 0); break; - - /* Allocations. */ - case IR_SNEW: case IR_XSNEW: asm_snew(as, ir); break; - case IR_TNEW: asm_tnew(as, ir); break; - case IR_TDUP: asm_tdup(as, ir); break; - case IR_CNEW: case IR_CNEWI: asm_cnew(as, ir); break; - - /* Write barriers. */ - case IR_TBAR: asm_tbar(as, ir); break; - case IR_OBAR: asm_obar(as, ir); break; - - /* Type conversions. */ - case IR_CONV: asm_conv(as, ir); break; - case IR_TOSTR: asm_tostr(as, ir); break; - case IR_STRTO: asm_strto(as, ir); break; - - /* Calls. */ - case IR_CALLN: case IR_CALLL: case IR_CALLS: asm_call(as, ir); break; - case IR_CALLXS: asm_callx(as, ir); break; - case IR_CARG: break; - - default: - setintV(&as->J->errinfo, ir->o); - lj_trace_err_info(as->J, LJ_TRERR_NYIIR); - break; - } -} - -/* -- Trace setup --------------------------------------------------------- */ - -/* Ensure there are enough stack slots for call arguments. */ -static Reg asm_setup_call_slots(ASMState *as, IRIns *ir, const CCallInfo *ci) -{ - IRRef args[CCI_NARGS_MAX*2]; - uint32_t i, nargs = (int)CCI_NARGS(ci); - int nslots = 0, ngpr = REGARG_NUMGPR, nfpr = REGARG_NUMFPR, fprodd = 0; - asm_collectargs(as, ir, ci, args); - for (i = 0; i < nargs; i++) { - if (!LJ_SOFTFP && args[i] && irt_isfp(IR(args[i])->t)) { - if (!LJ_ABI_SOFTFP && !(ci->flags & CCI_VARARG)) { - if (irt_isnum(IR(args[i])->t)) { - if (nfpr > 0) nfpr--; - else fprodd = 0, nslots = (nslots + 3) & ~1; - } else { - if (fprodd) fprodd--; - else if (nfpr > 0) fprodd = 1, nfpr--; - else nslots++; - } - } else if (irt_isnum(IR(args[i])->t)) { - ngpr &= ~1; - if (ngpr > 0) ngpr -= 2; else nslots += 2; - } else { - if (ngpr > 0) ngpr--; else nslots++; - } - } else { - if (ngpr > 0) ngpr--; else nslots++; - } - } - if (nslots > as->evenspill) /* Leave room for args in stack slots. */ - as->evenspill = nslots; - return REGSP_HINT(RID_RET); -} - -static void asm_setup_target(ASMState *as) -{ - /* May need extra exit for asm_stack_check on side traces. */ - asm_exitstub_setup(as, as->T->nsnap + (as->parent ? 1 : 0)); -} - -/* -- Trace patching ------------------------------------------------------ */ - -/* Patch exit jumps of existing machine code to a new target. */ -void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target) -{ - MCode *p = T->mcode; - MCode *pe = (MCode *)((char *)p + T->szmcode); - MCode *cstart = NULL, *cend = p; - MCode *mcarea = lj_mcode_patch(J, p, 0); - MCode *px = exitstub_addr(J, exitno) - 2; - for (; p < pe; p++) { - /* Look for bl_cc exitstub, replace with b_cc target. */ - uint32_t ins = *p; - if ((ins & 0x0f000000u) == 0x0b000000u && ins < 0xf0000000u && - ((ins ^ (px-p)) & 0x00ffffffu) == 0) { - *p = (ins & 0xfe000000u) | (((target-p)-2) & 0x00ffffffu); - cend = p+1; - if (!cstart) cstart = p; - } - } - lua_assert(cstart != NULL); - lj_mcode_sync(cstart, cend); - lj_mcode_patch(J, mcarea, 1); -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_mips.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_mips.h deleted file mode 100644 index e5c67b53e..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_mips.h +++ /dev/null @@ -1,1977 +0,0 @@ -/* -** MIPS IR assembler (SSA IR -> machine code). -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -/* -- Register allocator extensions --------------------------------------- */ - -/* Allocate a register with a hint. */ -static Reg ra_hintalloc(ASMState *as, IRRef ref, Reg hint, RegSet allow) -{ - Reg r = IR(ref)->r; - if (ra_noreg(r)) { - if (!ra_hashint(r) && !iscrossref(as, ref)) - ra_sethint(IR(ref)->r, hint); /* Propagate register hint. */ - r = ra_allocref(as, ref, allow); - } - ra_noweak(as, r); - return r; -} - -/* Allocate a register or RID_ZERO. */ -static Reg ra_alloc1z(ASMState *as, IRRef ref, RegSet allow) -{ - Reg r = IR(ref)->r; - if (ra_noreg(r)) { - if (!(allow & RSET_FPR) && irref_isk(ref) && IR(ref)->i == 0) - return RID_ZERO; - r = ra_allocref(as, ref, allow); - } else { - ra_noweak(as, r); - } - return r; -} - -/* Allocate two source registers for three-operand instructions. */ -static Reg ra_alloc2(ASMState *as, IRIns *ir, RegSet allow) -{ - IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); - Reg left = irl->r, right = irr->r; - if (ra_hasreg(left)) { - ra_noweak(as, left); - if (ra_noreg(right)) - right = ra_alloc1z(as, ir->op2, rset_exclude(allow, left)); - else - ra_noweak(as, right); - } else if (ra_hasreg(right)) { - ra_noweak(as, right); - left = ra_alloc1z(as, ir->op1, rset_exclude(allow, right)); - } else if (ra_hashint(right)) { - right = ra_alloc1z(as, ir->op2, allow); - left = ra_alloc1z(as, ir->op1, rset_exclude(allow, right)); - } else { - left = ra_alloc1z(as, ir->op1, allow); - right = ra_alloc1z(as, ir->op2, rset_exclude(allow, left)); - } - return left | (right << 8); -} - -/* -- Guard handling ------------------------------------------------------ */ - -/* Need some spare long-range jump slots, for out-of-range branches. */ -#define MIPS_SPAREJUMP 4 - -/* Setup spare long-range jump slots per mcarea. */ -static void asm_sparejump_setup(ASMState *as) -{ - MCode *mxp = as->mcbot; - /* Assumes sizeof(MCLink) == 8. */ - if (((uintptr_t)mxp & (LJ_PAGESIZE-1)) == 8) { - lua_assert(MIPSI_NOP == 0); - memset(mxp+2, 0, MIPS_SPAREJUMP*8); - mxp += MIPS_SPAREJUMP*2; - lua_assert(mxp < as->mctop); - lj_mcode_sync(as->mcbot, mxp); - lj_mcode_commitbot(as->J, mxp); - as->mcbot = mxp; - as->mclim = as->mcbot + MCLIM_REDZONE; - } -} - -/* Setup exit stub after the end of each trace. */ -static void asm_exitstub_setup(ASMState *as) -{ - MCode *mxp = as->mctop; - /* sw TMP, 0(sp); j ->vm_exit_handler; li TMP, traceno */ - *--mxp = MIPSI_LI|MIPSF_T(RID_TMP)|as->T->traceno; - *--mxp = MIPSI_J|((((uintptr_t)(void *)lj_vm_exit_handler)>>2)&0x03ffffffu); - lua_assert(((uintptr_t)mxp ^ (uintptr_t)(void *)lj_vm_exit_handler)>>28 == 0); - *--mxp = MIPSI_SW|MIPSF_T(RID_TMP)|MIPSF_S(RID_SP)|0; - as->mctop = mxp; -} - -/* Keep this in-sync with exitstub_trace_addr(). */ -#define asm_exitstub_addr(as) ((as)->mctop) - -/* Emit conditional branch to exit for guard. */ -static void asm_guard(ASMState *as, MIPSIns mi, Reg rs, Reg rt) -{ - MCode *target = asm_exitstub_addr(as); - MCode *p = as->mcp; - if (LJ_UNLIKELY(p == as->invmcp)) { - as->invmcp = NULL; - as->loopinv = 1; - as->mcp = p+1; - mi = mi ^ ((mi>>28) == 1 ? 0x04000000u : 0x00010000u); /* Invert cond. */ - target = p; /* Patch target later in asm_loop_fixup. */ - } - emit_ti(as, MIPSI_LI, RID_TMP, as->snapno); - emit_branch(as, mi, rs, rt, target); -} - -/* -- Operand fusion ------------------------------------------------------ */ - -/* Limit linear search to this distance. Avoids O(n^2) behavior. */ -#define CONFLICT_SEARCH_LIM 31 - -/* Check if there's no conflicting instruction between curins and ref. */ -static int noconflict(ASMState *as, IRRef ref, IROp conflict) -{ - IRIns *ir = as->ir; - IRRef i = as->curins; - if (i > ref + CONFLICT_SEARCH_LIM) - return 0; /* Give up, ref is too far away. */ - while (--i > ref) - if (ir[i].o == conflict) - return 0; /* Conflict found. */ - return 1; /* Ok, no conflict. */ -} - -/* Fuse the array base of colocated arrays. */ -static int32_t asm_fuseabase(ASMState *as, IRRef ref) -{ - IRIns *ir = IR(ref); - if (ir->o == IR_TNEW && ir->op1 <= LJ_MAX_COLOSIZE && - !neverfuse(as) && noconflict(as, ref, IR_NEWREF)) - return (int32_t)sizeof(GCtab); - return 0; -} - -/* Fuse array/hash/upvalue reference into register+offset operand. */ -static Reg asm_fuseahuref(ASMState *as, IRRef ref, int32_t *ofsp, RegSet allow) -{ - IRIns *ir = IR(ref); - if (ra_noreg(ir->r)) { - if (ir->o == IR_AREF) { - if (mayfuse(as, ref)) { - if (irref_isk(ir->op2)) { - IRRef tab = IR(ir->op1)->op1; - int32_t ofs = asm_fuseabase(as, tab); - IRRef refa = ofs ? tab : ir->op1; - ofs += 8*IR(ir->op2)->i; - if (checki16(ofs)) { - *ofsp = ofs; - return ra_alloc1(as, refa, allow); - } - } - } - } else if (ir->o == IR_HREFK) { - if (mayfuse(as, ref)) { - int32_t ofs = (int32_t)(IR(ir->op2)->op2 * sizeof(Node)); - if (checki16(ofs)) { - *ofsp = ofs; - return ra_alloc1(as, ir->op1, allow); - } - } - } else if (ir->o == IR_UREFC) { - if (irref_isk(ir->op1)) { - GCfunc *fn = ir_kfunc(IR(ir->op1)); - int32_t ofs = i32ptr(&gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.tv); - int32_t jgl = (intptr_t)J2G(as->J); - if ((uint32_t)(ofs-jgl) < 65536) { - *ofsp = ofs-jgl-32768; - return RID_JGL; - } else { - *ofsp = (int16_t)ofs; - return ra_allock(as, ofs-(int16_t)ofs, allow); - } - } - } - } - *ofsp = 0; - return ra_alloc1(as, ref, allow); -} - -/* Fuse XLOAD/XSTORE reference into load/store operand. */ -static void asm_fusexref(ASMState *as, MIPSIns mi, Reg rt, IRRef ref, - RegSet allow, int32_t ofs) -{ - IRIns *ir = IR(ref); - Reg base; - if (ra_noreg(ir->r) && canfuse(as, ir)) { - if (ir->o == IR_ADD) { - int32_t ofs2; - if (irref_isk(ir->op2) && (ofs2 = ofs + IR(ir->op2)->i, checki16(ofs2))) { - ref = ir->op1; - ofs = ofs2; - } - } else if (ir->o == IR_STRREF) { - int32_t ofs2 = 65536; - lua_assert(ofs == 0); - ofs = (int32_t)sizeof(GCstr); - if (irref_isk(ir->op2)) { - ofs2 = ofs + IR(ir->op2)->i; - ref = ir->op1; - } else if (irref_isk(ir->op1)) { - ofs2 = ofs + IR(ir->op1)->i; - ref = ir->op2; - } - if (!checki16(ofs2)) { - /* NYI: Fuse ADD with constant. */ - Reg right, left = ra_alloc2(as, ir, allow); - right = (left >> 8); left &= 255; - emit_hsi(as, mi, rt, RID_TMP, ofs); - emit_dst(as, MIPSI_ADDU, RID_TMP, left, right); - return; - } - ofs = ofs2; - } - } - base = ra_alloc1(as, ref, allow); - emit_hsi(as, mi, rt, base, ofs); -} - -/* -- Calls --------------------------------------------------------------- */ - -/* Generate a call to a C function. */ -static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args) -{ - uint32_t n, nargs = CCI_NARGS(ci); - int32_t ofs = 16; - Reg gpr, fpr = REGARG_FIRSTFPR; - if ((void *)ci->func) - emit_call(as, (void *)ci->func); - for (gpr = REGARG_FIRSTGPR; gpr <= REGARG_LASTGPR; gpr++) - as->cost[gpr] = REGCOST(~0u, ASMREF_L); - gpr = REGARG_FIRSTGPR; - for (n = 0; n < nargs; n++) { /* Setup args. */ - IRRef ref = args[n]; - if (ref) { - IRIns *ir = IR(ref); - if (irt_isfp(ir->t) && fpr <= REGARG_LASTFPR && - !(ci->flags & CCI_VARARG)) { - lua_assert(rset_test(as->freeset, fpr)); /* Already evicted. */ - ra_leftov(as, fpr, ref); - fpr += 2; - gpr += irt_isnum(ir->t) ? 2 : 1; - } else { - fpr = REGARG_LASTFPR+1; - if (irt_isnum(ir->t)) gpr = (gpr+1) & ~1; - if (gpr <= REGARG_LASTGPR) { - lua_assert(rset_test(as->freeset, gpr)); /* Already evicted. */ - if (irt_isfp(ir->t)) { - RegSet of = as->freeset; - Reg r; - /* Workaround to protect argument GPRs from being used for remat. */ - as->freeset &= ~RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1); - r = ra_alloc1(as, ref, RSET_FPR); - as->freeset |= (of & RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1)); - if (irt_isnum(ir->t)) { - emit_tg(as, MIPSI_MFC1, gpr+(LJ_BE?0:1), r+1); - emit_tg(as, MIPSI_MFC1, gpr+(LJ_BE?1:0), r); - lua_assert(rset_test(as->freeset, gpr+1)); /* Already evicted. */ - gpr += 2; - } else if (irt_isfloat(ir->t)) { - emit_tg(as, MIPSI_MFC1, gpr, r); - gpr++; - } - } else { - ra_leftov(as, gpr, ref); - gpr++; - } - } else { - Reg r = ra_alloc1z(as, ref, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); - if (irt_isnum(ir->t)) ofs = (ofs + 4) & ~4; - emit_spstore(as, ir, r, ofs); - ofs += irt_isnum(ir->t) ? 8 : 4; - } - } - } else { - fpr = REGARG_LASTFPR+1; - if (gpr <= REGARG_LASTGPR) - gpr++; - else - ofs += 4; - } - checkmclim(as); - } -} - -/* Setup result reg/sp for call. Evict scratch regs. */ -static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci) -{ - RegSet drop = RSET_SCRATCH; - int hiop = ((ir+1)->o == IR_HIOP); - if ((ci->flags & CCI_NOFPRCLOBBER)) - drop &= ~RSET_FPR; - if (ra_hasreg(ir->r)) - rset_clear(drop, ir->r); /* Dest reg handled below. */ - if (hiop && ra_hasreg((ir+1)->r)) - rset_clear(drop, (ir+1)->r); /* Dest reg handled below. */ - ra_evictset(as, drop); /* Evictions must be performed first. */ - if (ra_used(ir)) { - lua_assert(!irt_ispri(ir->t)); - if (irt_isfp(ir->t)) { - if ((ci->flags & CCI_CASTU64)) { - int32_t ofs = sps_scale(ir->s); - Reg dest = ir->r; - if (ra_hasreg(dest)) { - ra_free(as, dest); - ra_modified(as, dest); - emit_tg(as, MIPSI_MTC1, RID_RETHI, dest+1); - emit_tg(as, MIPSI_MTC1, RID_RETLO, dest); - } - if (ofs) { - emit_tsi(as, MIPSI_SW, RID_RETLO, RID_SP, ofs+(LJ_BE?4:0)); - emit_tsi(as, MIPSI_SW, RID_RETHI, RID_SP, ofs+(LJ_BE?0:4)); - } - } else { - ra_destreg(as, ir, RID_FPRET); - } - } else if (hiop) { - ra_destpair(as, ir); - } else { - ra_destreg(as, ir, RID_RET); - } - } -} - -static void asm_call(ASMState *as, IRIns *ir) -{ - IRRef args[CCI_NARGS_MAX]; - const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; - asm_collectargs(as, ir, ci, args); - asm_setupresult(as, ir, ci); - asm_gencall(as, ci, args); -} - -static void asm_callx(ASMState *as, IRIns *ir) -{ - IRRef args[CCI_NARGS_MAX*2]; - CCallInfo ci; - IRRef func; - IRIns *irf; - ci.flags = asm_callx_flags(as, ir); - asm_collectargs(as, ir, &ci, args); - asm_setupresult(as, ir, &ci); - func = ir->op2; irf = IR(func); - if (irf->o == IR_CARG) { func = irf->op1; irf = IR(func); } - if (irref_isk(func)) { /* Call to constant address. */ - ci.func = (ASMFunction)(void *)(irf->i); - } else { /* Need specific register for indirect calls. */ - Reg r = ra_alloc1(as, func, RID2RSET(RID_CFUNCADDR)); - MCode *p = as->mcp; - if (r == RID_CFUNCADDR) - *--p = MIPSI_NOP; - else - *--p = MIPSI_MOVE | MIPSF_D(RID_CFUNCADDR) | MIPSF_S(r); - *--p = MIPSI_JALR | MIPSF_S(r); - as->mcp = p; - ci.func = (ASMFunction)(void *)0; - } - asm_gencall(as, &ci, args); -} - -static void asm_callid(ASMState *as, IRIns *ir, IRCallID id) -{ - const CCallInfo *ci = &lj_ir_callinfo[id]; - IRRef args[2]; - args[0] = ir->op1; - args[1] = ir->op2; - asm_setupresult(as, ir, ci); - asm_gencall(as, ci, args); -} - -static void asm_callround(ASMState *as, IRIns *ir, IRCallID id) -{ - /* The modified regs must match with the *.dasc implementation. */ - RegSet drop = RID2RSET(RID_R1)|RID2RSET(RID_R12)|RID2RSET(RID_FPRET)| - RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(REGARG_FIRSTFPR); - if (ra_hasreg(ir->r)) rset_clear(drop, ir->r); - ra_evictset(as, drop); - ra_destreg(as, ir, RID_FPRET); - emit_call(as, (void *)lj_ir_callinfo[id].func); - ra_leftov(as, REGARG_FIRSTFPR, ir->op1); -} - -/* -- Returns ------------------------------------------------------------- */ - -/* Return to lower frame. Guard that it goes to the right spot. */ -static void asm_retf(ASMState *as, IRIns *ir) -{ - Reg base = ra_alloc1(as, REF_BASE, RSET_GPR); - void *pc = ir_kptr(IR(ir->op2)); - int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); - as->topslot -= (BCReg)delta; - if ((int32_t)as->topslot < 0) as->topslot = 0; - irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */ - emit_setgl(as, base, jit_base); - emit_addptr(as, base, -8*delta); - asm_guard(as, MIPSI_BNE, RID_TMP, - ra_allock(as, i32ptr(pc), rset_exclude(RSET_GPR, base))); - emit_tsi(as, MIPSI_LW, RID_TMP, base, -8); -} - -/* -- Type conversions ---------------------------------------------------- */ - -static void asm_tointg(ASMState *as, IRIns *ir, Reg left) -{ - Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); - Reg dest = ra_dest(as, ir, RSET_GPR); - asm_guard(as, MIPSI_BC1F, 0, 0); - emit_fgh(as, MIPSI_C_EQ_D, 0, tmp, left); - emit_fg(as, MIPSI_CVT_D_W, tmp, tmp); - emit_tg(as, MIPSI_MFC1, dest, tmp); - emit_fg(as, MIPSI_CVT_W_D, tmp, left); -} - -static void asm_tobit(ASMState *as, IRIns *ir) -{ - RegSet allow = RSET_FPR; - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg left = ra_alloc1(as, ir->op1, allow); - Reg right = ra_alloc1(as, ir->op2, rset_clear(allow, left)); - Reg tmp = ra_scratch(as, rset_clear(allow, right)); - emit_tg(as, MIPSI_MFC1, dest, tmp); - emit_fgh(as, MIPSI_ADD_D, tmp, left, right); -} - -static void asm_conv(ASMState *as, IRIns *ir) -{ - IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); - int stfp = (st == IRT_NUM || st == IRT_FLOAT); - IRRef lref = ir->op1; - lua_assert(irt_type(ir->t) != st); - lua_assert(!(irt_isint64(ir->t) || - (st == IRT_I64 || st == IRT_U64))); /* Handled by SPLIT. */ - if (irt_isfp(ir->t)) { - Reg dest = ra_dest(as, ir, RSET_FPR); - if (stfp) { /* FP to FP conversion. */ - emit_fg(as, st == IRT_NUM ? MIPSI_CVT_S_D : MIPSI_CVT_D_S, - dest, ra_alloc1(as, lref, RSET_FPR)); - } else if (st == IRT_U32) { /* U32 to FP conversion. */ - /* y = (x ^ 0x8000000) + 2147483648.0 */ - Reg left = ra_alloc1(as, lref, RSET_GPR); - Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, dest)); - emit_fgh(as, irt_isfloat(ir->t) ? MIPSI_ADD_S : MIPSI_ADD_D, - dest, dest, tmp); - emit_fg(as, irt_isfloat(ir->t) ? MIPSI_CVT_S_W : MIPSI_CVT_D_W, - dest, dest); - if (irt_isfloat(ir->t)) - emit_lsptr(as, MIPSI_LWC1, (tmp & 31), - (void *)lj_ir_k64_find(as->J, U64x(4f000000,4f000000)), - RSET_GPR); - else - emit_lsptr(as, MIPSI_LDC1, (tmp & 31), - (void *)lj_ir_k64_find(as->J, U64x(41e00000,00000000)), - RSET_GPR); - emit_tg(as, MIPSI_MTC1, RID_TMP, dest); - emit_dst(as, MIPSI_XOR, RID_TMP, RID_TMP, left); - emit_ti(as, MIPSI_LUI, RID_TMP, 0x8000); - } else { /* Integer to FP conversion. */ - Reg left = ra_alloc1(as, lref, RSET_GPR); - emit_fg(as, irt_isfloat(ir->t) ? MIPSI_CVT_S_W : MIPSI_CVT_D_W, - dest, dest); - emit_tg(as, MIPSI_MTC1, left, dest); - } - } else if (stfp) { /* FP to integer conversion. */ - if (irt_isguard(ir->t)) { - /* Checked conversions are only supported from number to int. */ - lua_assert(irt_isint(ir->t) && st == IRT_NUM); - asm_tointg(as, ir, ra_alloc1(as, lref, RSET_FPR)); - } else { - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg left = ra_alloc1(as, lref, RSET_FPR); - Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); - if (irt_isu32(ir->t)) { - /* y = (int)floor(x - 2147483648.0) ^ 0x80000000 */ - emit_dst(as, MIPSI_XOR, dest, dest, RID_TMP); - emit_ti(as, MIPSI_LUI, RID_TMP, 0x8000); - emit_tg(as, MIPSI_MFC1, dest, tmp); - emit_fg(as, st == IRT_FLOAT ? MIPSI_FLOOR_W_S : MIPSI_FLOOR_W_D, - tmp, tmp); - emit_fgh(as, st == IRT_FLOAT ? MIPSI_SUB_S : MIPSI_SUB_D, - tmp, left, tmp); - if (st == IRT_FLOAT) - emit_lsptr(as, MIPSI_LWC1, (tmp & 31), - (void *)lj_ir_k64_find(as->J, U64x(4f000000,4f000000)), - RSET_GPR); - else - emit_lsptr(as, MIPSI_LDC1, (tmp & 31), - (void *)lj_ir_k64_find(as->J, U64x(41e00000,00000000)), - RSET_GPR); - } else { - emit_tg(as, MIPSI_MFC1, dest, tmp); - emit_fg(as, st == IRT_FLOAT ? MIPSI_TRUNC_W_S : MIPSI_TRUNC_W_D, - tmp, left); - } - } - } else { - Reg dest = ra_dest(as, ir, RSET_GPR); - if (st >= IRT_I8 && st <= IRT_U16) { /* Extend to 32 bit integer. */ - Reg left = ra_alloc1(as, ir->op1, RSET_GPR); - lua_assert(irt_isint(ir->t) || irt_isu32(ir->t)); - if ((ir->op2 & IRCONV_SEXT)) { - if ((as->flags & JIT_F_MIPS32R2)) { - emit_dst(as, st == IRT_I8 ? MIPSI_SEB : MIPSI_SEH, dest, 0, left); - } else { - uint32_t shift = st == IRT_I8 ? 24 : 16; - emit_dta(as, MIPSI_SRA, dest, dest, shift); - emit_dta(as, MIPSI_SLL, dest, left, shift); - } - } else { - emit_tsi(as, MIPSI_ANDI, dest, left, - (int32_t)(st == IRT_U8 ? 0xff : 0xffff)); - } - } else { /* 32/64 bit integer conversions. */ - /* Only need to handle 32/32 bit no-op (cast) on 32 bit archs. */ - ra_leftov(as, dest, lref); /* Do nothing, but may need to move regs. */ - } - } -} - -#if LJ_HASFFI -static void asm_conv64(ASMState *as, IRIns *ir) -{ - IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK); - IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH); - IRCallID id; - const CCallInfo *ci; - IRRef args[2]; - args[LJ_BE?0:1] = ir->op1; - args[LJ_BE?1:0] = (ir-1)->op1; - if (st == IRT_NUM || st == IRT_FLOAT) { - id = IRCALL_fp64_d2l + ((st == IRT_FLOAT) ? 2 : 0) + (dt - IRT_I64); - ir--; - } else { - id = IRCALL_fp64_l2d + ((dt == IRT_FLOAT) ? 2 : 0) + (st - IRT_I64); - } - ci = &lj_ir_callinfo[id]; - asm_setupresult(as, ir, ci); - asm_gencall(as, ci, args); -} -#endif - -static void asm_strto(ASMState *as, IRIns *ir) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_strscan_num]; - IRRef args[2]; - RegSet drop = RSET_SCRATCH; - if (ra_hasreg(ir->r)) rset_set(drop, ir->r); /* Spill dest reg (if any). */ - ra_evictset(as, drop); - asm_guard(as, MIPSI_BEQ, RID_RET, RID_ZERO); /* Test return status. */ - args[0] = ir->op1; /* GCstr *str */ - args[1] = ASMREF_TMP1; /* TValue *n */ - asm_gencall(as, ci, args); - /* Store the result to the spill slot or temp slots. */ - emit_tsi(as, MIPSI_ADDIU, ra_releasetmp(as, ASMREF_TMP1), - RID_SP, sps_scale(ir->s)); -} - -/* Get pointer to TValue. */ -static void asm_tvptr(ASMState *as, Reg dest, IRRef ref) -{ - IRIns *ir = IR(ref); - if (irt_isnum(ir->t)) { - if (irref_isk(ref)) /* Use the number constant itself as a TValue. */ - ra_allockreg(as, i32ptr(ir_knum(ir)), dest); - else /* Otherwise force a spill and use the spill slot. */ - emit_tsi(as, MIPSI_ADDIU, dest, RID_SP, ra_spill(as, ir)); - } else { - /* Otherwise use g->tmptv to hold the TValue. */ - RegSet allow = rset_exclude(RSET_GPR, dest); - Reg type; - emit_tsi(as, MIPSI_ADDIU, dest, RID_JGL, offsetof(global_State, tmptv)-32768); - if (!irt_ispri(ir->t)) { - Reg src = ra_alloc1(as, ref, allow); - emit_setgl(as, src, tmptv.gcr); - } - type = ra_allock(as, irt_toitype(ir->t), allow); - emit_setgl(as, type, tmptv.it); - } -} - -static void asm_tostr(ASMState *as, IRIns *ir) -{ - IRRef args[2]; - args[0] = ASMREF_L; - as->gcsteps++; - if (irt_isnum(IR(ir->op1)->t) || (ir+1)->o == IR_HIOP) { - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromnum]; - args[1] = ASMREF_TMP1; /* const lua_Number * */ - asm_setupresult(as, ir, ci); /* GCstr * */ - asm_gencall(as, ci, args); - asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op1); - } else { - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromint]; - args[1] = ir->op1; /* int32_t k */ - asm_setupresult(as, ir, ci); /* GCstr * */ - asm_gencall(as, ci, args); - } -} - -/* -- Memory references --------------------------------------------------- */ - -static void asm_aref(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg idx, base; - if (irref_isk(ir->op2)) { - IRRef tab = IR(ir->op1)->op1; - int32_t ofs = asm_fuseabase(as, tab); - IRRef refa = ofs ? tab : ir->op1; - ofs += 8*IR(ir->op2)->i; - if (checki16(ofs)) { - base = ra_alloc1(as, refa, RSET_GPR); - emit_tsi(as, MIPSI_ADDIU, dest, base, ofs); - return; - } - } - base = ra_alloc1(as, ir->op1, RSET_GPR); - idx = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, base)); - emit_dst(as, MIPSI_ADDU, dest, RID_TMP, base); - emit_dta(as, MIPSI_SLL, RID_TMP, idx, 3); -} - -/* Inlined hash lookup. Specialized for key type and for const keys. -** The equivalent C code is: -** Node *n = hashkey(t, key); -** do { -** if (lj_obj_equal(&n->key, key)) return &n->val; -** } while ((n = nextnode(n))); -** return niltv(L); -*/ -static void asm_href(ASMState *as, IRIns *ir) -{ - RegSet allow = RSET_GPR; - int destused = ra_used(ir); - Reg dest = ra_dest(as, ir, allow); - Reg tab = ra_alloc1(as, ir->op1, rset_clear(allow, dest)); - Reg key = RID_NONE, type = RID_NONE, tmpnum = RID_NONE, tmp1 = RID_TMP, tmp2; - IRRef refkey = ir->op2; - IRIns *irkey = IR(refkey); - IRType1 kt = irkey->t; - uint32_t khash; - MCLabel l_end, l_loop, l_next; - - rset_clear(allow, tab); - if (irt_isnum(kt)) { - key = ra_alloc1(as, refkey, RSET_FPR); - tmpnum = ra_scratch(as, rset_exclude(RSET_FPR, key)); - } else if (!irt_ispri(kt)) { - key = ra_alloc1(as, refkey, allow); - rset_clear(allow, key); - type = ra_allock(as, irt_toitype(irkey->t), allow); - rset_clear(allow, type); - } - tmp2 = ra_scratch(as, allow); - rset_clear(allow, tmp2); - - /* Key not found in chain: load niltv. */ - l_end = emit_label(as); - if (destused) - emit_loada(as, dest, niltvg(J2G(as->J))); - else - *--as->mcp = MIPSI_NOP; - /* Follow hash chain until the end. */ - emit_move(as, dest, tmp1); - l_loop = --as->mcp; - emit_tsi(as, MIPSI_LW, tmp1, dest, (int32_t)offsetof(Node, next)); - l_next = emit_label(as); - - /* Type and value comparison. */ - if (irt_isnum(kt)) { - emit_branch(as, MIPSI_BC1T, 0, 0, l_end); - emit_fgh(as, MIPSI_C_EQ_D, 0, tmpnum, key); - emit_tg(as, MIPSI_MFC1, tmp1, key+1); - emit_branch(as, MIPSI_BEQ, tmp1, RID_ZERO, l_next); - emit_tsi(as, MIPSI_SLTIU, tmp1, tmp1, (int32_t)LJ_TISNUM); - emit_hsi(as, MIPSI_LDC1, tmpnum, dest, (int32_t)offsetof(Node, key.n)); - } else { - if (irt_ispri(kt)) { - emit_branch(as, MIPSI_BEQ, tmp1, type, l_end); - } else { - emit_branch(as, MIPSI_BEQ, tmp2, key, l_end); - emit_tsi(as, MIPSI_LW, tmp2, dest, (int32_t)offsetof(Node, key.gcr)); - emit_branch(as, MIPSI_BNE, tmp1, type, l_next); - } - } - emit_tsi(as, MIPSI_LW, tmp1, dest, (int32_t)offsetof(Node, key.it)); - *l_loop = MIPSI_BNE | MIPSF_S(tmp1) | ((as->mcp-l_loop-1) & 0xffffu); - - /* Load main position relative to tab->node into dest. */ - khash = irref_isk(refkey) ? ir_khash(irkey) : 1; - if (khash == 0) { - emit_tsi(as, MIPSI_LW, dest, tab, (int32_t)offsetof(GCtab, node)); - } else { - Reg tmphash = tmp1; - if (irref_isk(refkey)) - tmphash = ra_allock(as, khash, allow); - emit_dst(as, MIPSI_ADDU, dest, dest, tmp1); - lua_assert(sizeof(Node) == 24); - emit_dst(as, MIPSI_SUBU, tmp1, tmp2, tmp1); - emit_dta(as, MIPSI_SLL, tmp1, tmp1, 3); - emit_dta(as, MIPSI_SLL, tmp2, tmp1, 5); - emit_dst(as, MIPSI_AND, tmp1, tmp2, tmphash); - emit_tsi(as, MIPSI_LW, dest, tab, (int32_t)offsetof(GCtab, node)); - emit_tsi(as, MIPSI_LW, tmp2, tab, (int32_t)offsetof(GCtab, hmask)); - if (irref_isk(refkey)) { - /* Nothing to do. */ - } else if (irt_isstr(kt)) { - emit_tsi(as, MIPSI_LW, tmp1, key, (int32_t)offsetof(GCstr, hash)); - } else { /* Must match with hash*() in lj_tab.c. */ - emit_dst(as, MIPSI_SUBU, tmp1, tmp1, tmp2); - emit_rotr(as, tmp2, tmp2, dest, (-HASH_ROT3)&31); - emit_dst(as, MIPSI_XOR, tmp1, tmp1, tmp2); - emit_rotr(as, tmp1, tmp1, dest, (-HASH_ROT2-HASH_ROT1)&31); - emit_dst(as, MIPSI_SUBU, tmp2, tmp2, dest); - if (irt_isnum(kt)) { - emit_dst(as, MIPSI_XOR, tmp2, tmp2, tmp1); - if ((as->flags & JIT_F_MIPS32R2)) { - emit_dta(as, MIPSI_ROTR, dest, tmp1, (-HASH_ROT1)&31); - } else { - emit_dst(as, MIPSI_OR, dest, dest, tmp1); - emit_dta(as, MIPSI_SLL, tmp1, tmp1, HASH_ROT1); - emit_dta(as, MIPSI_SRL, dest, tmp1, (-HASH_ROT1)&31); - } - emit_dst(as, MIPSI_ADDU, tmp1, tmp1, tmp1); - emit_tg(as, MIPSI_MFC1, tmp2, key); - emit_tg(as, MIPSI_MFC1, tmp1, key+1); - } else { - emit_dst(as, MIPSI_XOR, tmp2, key, tmp1); - emit_rotr(as, dest, tmp1, tmp2, (-HASH_ROT1)&31); - emit_dst(as, MIPSI_ADDU, tmp1, key, ra_allock(as, HASH_BIAS, allow)); - } - } - } -} - -static void asm_hrefk(ASMState *as, IRIns *ir) -{ - IRIns *kslot = IR(ir->op2); - IRIns *irkey = IR(kslot->op1); - int32_t ofs = (int32_t)(kslot->op2 * sizeof(Node)); - int32_t kofs = ofs + (int32_t)offsetof(Node, key); - Reg dest = (ra_used(ir)||ofs > 32736) ? ra_dest(as, ir, RSET_GPR) : RID_NONE; - Reg node = ra_alloc1(as, ir->op1, RSET_GPR); - Reg key = RID_NONE, type = RID_TMP, idx = node; - RegSet allow = rset_exclude(RSET_GPR, node); - int32_t lo, hi; - lua_assert(ofs % sizeof(Node) == 0); - if (ofs > 32736) { - idx = dest; - rset_clear(allow, dest); - kofs = (int32_t)offsetof(Node, key); - } else if (ra_hasreg(dest)) { - emit_tsi(as, MIPSI_ADDIU, dest, node, ofs); - } - if (!irt_ispri(irkey->t)) { - key = ra_scratch(as, allow); - rset_clear(allow, key); - } - if (irt_isnum(irkey->t)) { - lo = (int32_t)ir_knum(irkey)->u32.lo; - hi = (int32_t)ir_knum(irkey)->u32.hi; - } else { - lo = irkey->i; - hi = irt_toitype(irkey->t); - if (!ra_hasreg(key)) - goto nolo; - } - asm_guard(as, MIPSI_BNE, key, lo ? ra_allock(as, lo, allow) : RID_ZERO); -nolo: - asm_guard(as, MIPSI_BNE, type, hi ? ra_allock(as, hi, allow) : RID_ZERO); - if (ra_hasreg(key)) emit_tsi(as, MIPSI_LW, key, idx, kofs+(LJ_BE?4:0)); - emit_tsi(as, MIPSI_LW, type, idx, kofs+(LJ_BE?0:4)); - if (ofs > 32736) - emit_tsi(as, MIPSI_ADDU, dest, node, ra_allock(as, ofs, allow)); -} - -static void asm_newref(ASMState *as, IRIns *ir) -{ - if (ir->r != RID_SINK) { - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_newkey]; - IRRef args[3]; - args[0] = ASMREF_L; /* lua_State *L */ - args[1] = ir->op1; /* GCtab *t */ - args[2] = ASMREF_TMP1; /* cTValue *key */ - asm_setupresult(as, ir, ci); /* TValue * */ - asm_gencall(as, ci, args); - asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op2); - } -} - -static void asm_uref(ASMState *as, IRIns *ir) -{ - /* NYI: Check that UREFO is still open and not aliasing a slot. */ - Reg dest = ra_dest(as, ir, RSET_GPR); - if (irref_isk(ir->op1)) { - GCfunc *fn = ir_kfunc(IR(ir->op1)); - MRef *v = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.v; - emit_lsptr(as, MIPSI_LW, dest, v, RSET_GPR); - } else { - Reg uv = ra_scratch(as, RSET_GPR); - Reg func = ra_alloc1(as, ir->op1, RSET_GPR); - if (ir->o == IR_UREFC) { - asm_guard(as, MIPSI_BEQ, RID_TMP, RID_ZERO); - emit_tsi(as, MIPSI_ADDIU, dest, uv, (int32_t)offsetof(GCupval, tv)); - emit_tsi(as, MIPSI_LBU, RID_TMP, uv, (int32_t)offsetof(GCupval, closed)); - } else { - emit_tsi(as, MIPSI_LW, dest, uv, (int32_t)offsetof(GCupval, v)); - } - emit_tsi(as, MIPSI_LW, uv, func, - (int32_t)offsetof(GCfuncL, uvptr) + 4*(int32_t)(ir->op2 >> 8)); - } -} - -static void asm_fref(ASMState *as, IRIns *ir) -{ - UNUSED(as); UNUSED(ir); - lua_assert(!ra_used(ir)); -} - -static void asm_strref(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - IRRef ref = ir->op2, refk = ir->op1; - int32_t ofs = (int32_t)sizeof(GCstr); - Reg r; - if (irref_isk(ref)) { - IRRef tmp = refk; refk = ref; ref = tmp; - } else if (!irref_isk(refk)) { - Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); - IRIns *irr = IR(ir->op2); - if (ra_hasreg(irr->r)) { - ra_noweak(as, irr->r); - right = irr->r; - } else if (mayfuse(as, irr->op2) && - irr->o == IR_ADD && irref_isk(irr->op2) && - checki16(ofs + IR(irr->op2)->i)) { - ofs += IR(irr->op2)->i; - right = ra_alloc1(as, irr->op1, rset_exclude(RSET_GPR, left)); - } else { - right = ra_allocref(as, ir->op2, rset_exclude(RSET_GPR, left)); - } - emit_tsi(as, MIPSI_ADDIU, dest, dest, ofs); - emit_dst(as, MIPSI_ADDU, dest, left, right); - return; - } - r = ra_alloc1(as, ref, RSET_GPR); - ofs += IR(refk)->i; - if (checki16(ofs)) - emit_tsi(as, MIPSI_ADDIU, dest, r, ofs); - else - emit_dst(as, MIPSI_ADDU, dest, r, - ra_allock(as, ofs, rset_exclude(RSET_GPR, r))); -} - -/* -- Loads and stores ---------------------------------------------------- */ - -static MIPSIns asm_fxloadins(IRIns *ir) -{ - switch (irt_type(ir->t)) { - case IRT_I8: return MIPSI_LB; - case IRT_U8: return MIPSI_LBU; - case IRT_I16: return MIPSI_LH; - case IRT_U16: return MIPSI_LHU; - case IRT_NUM: return MIPSI_LDC1; - case IRT_FLOAT: return MIPSI_LWC1; - default: return MIPSI_LW; - } -} - -static MIPSIns asm_fxstoreins(IRIns *ir) -{ - switch (irt_type(ir->t)) { - case IRT_I8: case IRT_U8: return MIPSI_SB; - case IRT_I16: case IRT_U16: return MIPSI_SH; - case IRT_NUM: return MIPSI_SDC1; - case IRT_FLOAT: return MIPSI_SWC1; - default: return MIPSI_SW; - } -} - -static void asm_fload(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg idx = ra_alloc1(as, ir->op1, RSET_GPR); - MIPSIns mi = asm_fxloadins(ir); - int32_t ofs; - if (ir->op2 == IRFL_TAB_ARRAY) { - ofs = asm_fuseabase(as, ir->op1); - if (ofs) { /* Turn the t->array load into an add for colocated arrays. */ - emit_tsi(as, MIPSI_ADDIU, dest, idx, ofs); - return; - } - } - ofs = field_ofs[ir->op2]; - lua_assert(!irt_isfp(ir->t)); - emit_tsi(as, mi, dest, idx, ofs); -} - -static void asm_fstore(ASMState *as, IRIns *ir) -{ - if (ir->r != RID_SINK) { - Reg src = ra_alloc1z(as, ir->op2, RSET_GPR); - IRIns *irf = IR(ir->op1); - Reg idx = ra_alloc1(as, irf->op1, rset_exclude(RSET_GPR, src)); - int32_t ofs = field_ofs[irf->op2]; - MIPSIns mi = asm_fxstoreins(ir); - lua_assert(!irt_isfp(ir->t)); - emit_tsi(as, mi, src, idx, ofs); - } -} - -static void asm_xload(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); - lua_assert(!(ir->op2 & IRXLOAD_UNALIGNED)); - asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR, 0); -} - -static void asm_xstore(ASMState *as, IRIns *ir, int32_t ofs) -{ - if (ir->r != RID_SINK) { - Reg src = ra_alloc1z(as, ir->op2, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); - asm_fusexref(as, asm_fxstoreins(ir), src, ir->op1, - rset_exclude(RSET_GPR, src), ofs); - } -} - -static void asm_ahuvload(ASMState *as, IRIns *ir) -{ - IRType1 t = ir->t; - Reg dest = RID_NONE, type = RID_TMP, idx; - RegSet allow = RSET_GPR; - int32_t ofs = 0; - if (ra_used(ir)) { - lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); - dest = ra_dest(as, ir, irt_isnum(t) ? RSET_FPR : RSET_GPR); - rset_clear(allow, dest); - } - idx = asm_fuseahuref(as, ir->op1, &ofs, allow); - rset_clear(allow, idx); - if (irt_isnum(t)) { - asm_guard(as, MIPSI_BEQ, type, RID_ZERO); - emit_tsi(as, MIPSI_SLTIU, type, type, (int32_t)LJ_TISNUM); - if (ra_hasreg(dest)) - emit_hsi(as, MIPSI_LDC1, dest, idx, ofs); - } else { - asm_guard(as, MIPSI_BNE, type, ra_allock(as, irt_toitype(t), allow)); - if (ra_hasreg(dest)) emit_tsi(as, MIPSI_LW, dest, idx, ofs+(LJ_BE?4:0)); - } - emit_tsi(as, MIPSI_LW, type, idx, ofs+(LJ_BE?0:4)); -} - -static void asm_ahustore(ASMState *as, IRIns *ir) -{ - RegSet allow = RSET_GPR; - Reg idx, src = RID_NONE, type = RID_NONE; - int32_t ofs = 0; - if (ir->r == RID_SINK) - return; - if (irt_isnum(ir->t)) { - src = ra_alloc1(as, ir->op2, RSET_FPR); - } else { - if (!irt_ispri(ir->t)) { - src = ra_alloc1(as, ir->op2, allow); - rset_clear(allow, src); - } - type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); - rset_clear(allow, type); - } - idx = asm_fuseahuref(as, ir->op1, &ofs, allow); - if (irt_isnum(ir->t)) { - emit_hsi(as, MIPSI_SDC1, src, idx, ofs); - } else { - if (ra_hasreg(src)) - emit_tsi(as, MIPSI_SW, src, idx, ofs+(LJ_BE?4:0)); - emit_tsi(as, MIPSI_SW, type, idx, ofs+(LJ_BE?0:4)); - } -} - -static void asm_sload(ASMState *as, IRIns *ir) -{ - int32_t ofs = 8*((int32_t)ir->op1-1) + ((ir->op2 & IRSLOAD_FRAME) ? 4 : 0); - IRType1 t = ir->t; - Reg dest = RID_NONE, type = RID_NONE, base; - RegSet allow = RSET_GPR; - lua_assert(!(ir->op2 & IRSLOAD_PARENT)); /* Handled by asm_head_side(). */ - lua_assert(irt_isguard(t) || !(ir->op2 & IRSLOAD_TYPECHECK)); - lua_assert(!irt_isint(t) || (ir->op2 & (IRSLOAD_CONVERT|IRSLOAD_FRAME))); - if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(t) && irt_isint(t)) { - dest = ra_scratch(as, RSET_FPR); - asm_tointg(as, ir, dest); - t.irt = IRT_NUM; /* Continue with a regular number type check. */ - } else if (ra_used(ir)) { - lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); - dest = ra_dest(as, ir, irt_isnum(t) ? RSET_FPR : RSET_GPR); - rset_clear(allow, dest); - base = ra_alloc1(as, REF_BASE, allow); - rset_clear(allow, base); - if ((ir->op2 & IRSLOAD_CONVERT)) { - if (irt_isint(t)) { - Reg tmp = ra_scratch(as, RSET_FPR); - emit_tg(as, MIPSI_MFC1, dest, tmp); - emit_fg(as, MIPSI_CVT_W_D, tmp, tmp); - dest = tmp; - t.irt = IRT_NUM; /* Check for original type. */ - } else { - Reg tmp = ra_scratch(as, RSET_GPR); - emit_fg(as, MIPSI_CVT_D_W, dest, dest); - emit_tg(as, MIPSI_MTC1, tmp, dest); - dest = tmp; - t.irt = IRT_INT; /* Check for original type. */ - } - } - goto dotypecheck; - } - base = ra_alloc1(as, REF_BASE, allow); - rset_clear(allow, base); -dotypecheck: - if (irt_isnum(t)) { - if ((ir->op2 & IRSLOAD_TYPECHECK)) { - asm_guard(as, MIPSI_BEQ, RID_TMP, RID_ZERO); - emit_tsi(as, MIPSI_SLTIU, RID_TMP, RID_TMP, (int32_t)LJ_TISNUM); - type = RID_TMP; - } - if (ra_hasreg(dest)) emit_hsi(as, MIPSI_LDC1, dest, base, ofs); - } else { - if ((ir->op2 & IRSLOAD_TYPECHECK)) { - Reg ktype = ra_allock(as, irt_toitype(t), allow); - asm_guard(as, MIPSI_BNE, RID_TMP, ktype); - type = RID_TMP; - } - if (ra_hasreg(dest)) emit_tsi(as, MIPSI_LW, dest, base, ofs ^ (LJ_BE?4:0)); - } - if (ra_hasreg(type)) emit_tsi(as, MIPSI_LW, type, base, ofs ^ (LJ_BE?0:4)); -} - -/* -- Allocations --------------------------------------------------------- */ - -#if LJ_HASFFI -static void asm_cnew(ASMState *as, IRIns *ir) -{ - CTState *cts = ctype_ctsG(J2G(as->J)); - CTypeID ctypeid = (CTypeID)IR(ir->op1)->i; - CTSize sz = (ir->o == IR_CNEWI || ir->op2 == REF_NIL) ? - lj_ctype_size(cts, ctypeid) : (CTSize)IR(ir->op2)->i; - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco]; - IRRef args[2]; - RegSet allow = (RSET_GPR & ~RSET_SCRATCH); - RegSet drop = RSET_SCRATCH; - lua_assert(sz != CTSIZE_INVALID); - - args[0] = ASMREF_L; /* lua_State *L */ - args[1] = ASMREF_TMP1; /* MSize size */ - as->gcsteps++; - - if (ra_hasreg(ir->r)) - rset_clear(drop, ir->r); /* Dest reg handled below. */ - ra_evictset(as, drop); - if (ra_used(ir)) - ra_destreg(as, ir, RID_RET); /* GCcdata * */ - - /* Initialize immutable cdata object. */ - if (ir->o == IR_CNEWI) { - int32_t ofs = sizeof(GCcdata); - lua_assert(sz == 4 || sz == 8); - if (sz == 8) { - ofs += 4; - lua_assert((ir+1)->o == IR_HIOP); - if (LJ_LE) ir++; - } - for (;;) { - Reg r = ra_alloc1z(as, ir->op2, allow); - emit_tsi(as, MIPSI_SW, r, RID_RET, ofs); - rset_clear(allow, r); - if (ofs == sizeof(GCcdata)) break; - ofs -= 4; if (LJ_BE) ir++; else ir--; - } - } - /* Initialize gct and ctypeid. lj_mem_newgco() already sets marked. */ - emit_tsi(as, MIPSI_SB, RID_RET+1, RID_RET, offsetof(GCcdata, gct)); - emit_tsi(as, MIPSI_SH, RID_TMP, RID_RET, offsetof(GCcdata, ctypeid)); - emit_ti(as, MIPSI_LI, RID_RET+1, ~LJ_TCDATA); - emit_ti(as, MIPSI_LI, RID_TMP, ctypeid); /* Lower 16 bit used. Sign-ext ok. */ - asm_gencall(as, ci, args); - ra_allockreg(as, (int32_t)(sz+sizeof(GCcdata)), - ra_releasetmp(as, ASMREF_TMP1)); -} -#else -#define asm_cnew(as, ir) ((void)0) -#endif - -/* -- Write barriers ------------------------------------------------------ */ - -static void asm_tbar(ASMState *as, IRIns *ir) -{ - Reg tab = ra_alloc1(as, ir->op1, RSET_GPR); - Reg mark = ra_scratch(as, rset_exclude(RSET_GPR, tab)); - Reg link = RID_TMP; - MCLabel l_end = emit_label(as); - emit_tsi(as, MIPSI_SW, link, tab, (int32_t)offsetof(GCtab, gclist)); - emit_tsi(as, MIPSI_SB, mark, tab, (int32_t)offsetof(GCtab, marked)); - emit_setgl(as, tab, gc.grayagain); - emit_getgl(as, link, gc.grayagain); - emit_dst(as, MIPSI_XOR, mark, mark, RID_TMP); /* Clear black bit. */ - emit_branch(as, MIPSI_BEQ, RID_TMP, RID_ZERO, l_end); - emit_tsi(as, MIPSI_ANDI, RID_TMP, mark, LJ_GC_BLACK); - emit_tsi(as, MIPSI_LBU, mark, tab, (int32_t)offsetof(GCtab, marked)); -} - -static void asm_obar(ASMState *as, IRIns *ir) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_barrieruv]; - IRRef args[2]; - MCLabel l_end; - Reg obj, val, tmp; - /* No need for other object barriers (yet). */ - lua_assert(IR(ir->op1)->o == IR_UREFC); - ra_evictset(as, RSET_SCRATCH); - l_end = emit_label(as); - args[0] = ASMREF_TMP1; /* global_State *g */ - args[1] = ir->op1; /* TValue *tv */ - asm_gencall(as, ci, args); - emit_tsi(as, MIPSI_ADDIU, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768); - obj = IR(ir->op1)->r; - tmp = ra_scratch(as, rset_exclude(RSET_GPR, obj)); - emit_branch(as, MIPSI_BEQ, RID_TMP, RID_ZERO, l_end); - emit_tsi(as, MIPSI_ANDI, tmp, tmp, LJ_GC_BLACK); - emit_branch(as, MIPSI_BEQ, RID_TMP, RID_ZERO, l_end); - emit_tsi(as, MIPSI_ANDI, RID_TMP, RID_TMP, LJ_GC_WHITES); - val = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, obj)); - emit_tsi(as, MIPSI_LBU, tmp, obj, - (int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)); - emit_tsi(as, MIPSI_LBU, RID_TMP, val, (int32_t)offsetof(GChead, marked)); -} - -/* -- Arithmetic and logic operations ------------------------------------- */ - -static void asm_fparith(ASMState *as, IRIns *ir, MIPSIns mi) -{ - Reg dest = ra_dest(as, ir, RSET_FPR); - Reg right, left = ra_alloc2(as, ir, RSET_FPR); - right = (left >> 8); left &= 255; - emit_fgh(as, mi, dest, left, right); -} - -static void asm_fpunary(ASMState *as, IRIns *ir, MIPSIns mi) -{ - Reg dest = ra_dest(as, ir, RSET_FPR); - Reg left = ra_hintalloc(as, ir->op1, dest, RSET_FPR); - emit_fg(as, mi, dest, left); -} - -static int asm_fpjoin_pow(ASMState *as, IRIns *ir) -{ - IRIns *irp = IR(ir->op1); - if (irp == ir-1 && irp->o == IR_MUL && !ra_used(irp)) { - IRIns *irpp = IR(irp->op1); - if (irpp == ir-2 && irpp->o == IR_FPMATH && - irpp->op2 == IRFPM_LOG2 && !ra_used(irpp)) { - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_pow]; - IRRef args[2]; - args[0] = irpp->op1; - args[1] = irp->op2; - asm_setupresult(as, ir, ci); - asm_gencall(as, ci, args); - return 1; - } - } - return 0; -} - -static void asm_add(ASMState *as, IRIns *ir) -{ - if (irt_isnum(ir->t)) { - asm_fparith(as, ir, MIPSI_ADD_D); - } else { - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); - if (irref_isk(ir->op2)) { - int32_t k = IR(ir->op2)->i; - if (checki16(k)) { - emit_tsi(as, MIPSI_ADDIU, dest, left, k); - return; - } - } - right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); - emit_dst(as, MIPSI_ADDU, dest, left, right); - } -} - -static void asm_sub(ASMState *as, IRIns *ir) -{ - if (irt_isnum(ir->t)) { - asm_fparith(as, ir, MIPSI_SUB_D); - } else { - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg right, left = ra_alloc2(as, ir, RSET_GPR); - right = (left >> 8); left &= 255; - emit_dst(as, MIPSI_SUBU, dest, left, right); - } -} - -static void asm_mul(ASMState *as, IRIns *ir) -{ - if (irt_isnum(ir->t)) { - asm_fparith(as, ir, MIPSI_MUL_D); - } else { - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg right, left = ra_alloc2(as, ir, RSET_GPR); - right = (left >> 8); left &= 255; - emit_dst(as, MIPSI_MUL, dest, left, right); - } -} - -static void asm_neg(ASMState *as, IRIns *ir) -{ - if (irt_isnum(ir->t)) { - asm_fpunary(as, ir, MIPSI_NEG_D); - } else { - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); - emit_dst(as, MIPSI_SUBU, dest, RID_ZERO, left); - } -} - -static void asm_arithov(ASMState *as, IRIns *ir) -{ - Reg right, left, tmp, dest = ra_dest(as, ir, RSET_GPR); - if (irref_isk(ir->op2)) { - int k = IR(ir->op2)->i; - if (ir->o == IR_SUBOV) k = -k; - if (checki16(k)) { /* (dest < left) == (k >= 0 ? 1 : 0) */ - left = ra_alloc1(as, ir->op1, RSET_GPR); - asm_guard(as, k >= 0 ? MIPSI_BNE : MIPSI_BEQ, RID_TMP, RID_ZERO); - emit_dst(as, MIPSI_SLT, RID_TMP, dest, dest == left ? RID_TMP : left); - emit_tsi(as, MIPSI_ADDIU, dest, left, k); - if (dest == left) emit_move(as, RID_TMP, left); - return; - } - } - left = ra_alloc2(as, ir, RSET_GPR); - right = (left >> 8); left &= 255; - tmp = ra_scratch(as, rset_exclude(rset_exclude(rset_exclude(RSET_GPR, left), - right), dest)); - asm_guard(as, MIPSI_BLTZ, RID_TMP, 0); - emit_dst(as, MIPSI_AND, RID_TMP, RID_TMP, tmp); - if (ir->o == IR_ADDOV) { /* ((dest^left) & (dest^right)) < 0 */ - emit_dst(as, MIPSI_XOR, RID_TMP, dest, dest == right ? RID_TMP : right); - } else { /* ((dest^left) & (dest^~right)) < 0 */ - emit_dst(as, MIPSI_XOR, RID_TMP, RID_TMP, dest); - emit_dst(as, MIPSI_NOR, RID_TMP, dest == right ? RID_TMP : right, RID_ZERO); - } - emit_dst(as, MIPSI_XOR, tmp, dest, dest == left ? RID_TMP : left); - emit_dst(as, ir->o == IR_ADDOV ? MIPSI_ADDU : MIPSI_SUBU, dest, left, right); - if (dest == left || dest == right) - emit_move(as, RID_TMP, dest == left ? left : right); -} - -static void asm_mulov(ASMState *as, IRIns *ir) -{ -#if LJ_DUALNUM -#error "NYI: MULOV" -#else - UNUSED(as); UNUSED(ir); lua_assert(0); /* Unused in single-number mode. */ -#endif -} - -#if LJ_HASFFI -static void asm_add64(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); - if (irref_isk(ir->op2)) { - int32_t k = IR(ir->op2)->i; - if (k == 0) { - emit_dst(as, MIPSI_ADDU, dest, left, RID_TMP); - goto loarith; - } else if (checki16(k)) { - emit_dst(as, MIPSI_ADDU, dest, dest, RID_TMP); - emit_tsi(as, MIPSI_ADDIU, dest, left, k); - goto loarith; - } - } - emit_dst(as, MIPSI_ADDU, dest, dest, RID_TMP); - right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); - emit_dst(as, MIPSI_ADDU, dest, left, right); -loarith: - ir--; - dest = ra_dest(as, ir, RSET_GPR); - left = ra_alloc1(as, ir->op1, RSET_GPR); - if (irref_isk(ir->op2)) { - int32_t k = IR(ir->op2)->i; - if (k == 0) { - if (dest != left) - emit_move(as, dest, left); - return; - } else if (checki16(k)) { - if (dest == left) { - Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, left)); - emit_move(as, dest, tmp); - dest = tmp; - } - emit_dst(as, MIPSI_SLTU, RID_TMP, dest, left); - emit_tsi(as, MIPSI_ADDIU, dest, left, k); - return; - } - } - right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); - if (dest == left && dest == right) { - Reg tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, left), right)); - emit_move(as, dest, tmp); - dest = tmp; - } - emit_dst(as, MIPSI_SLTU, RID_TMP, dest, dest == left ? right : left); - emit_dst(as, MIPSI_ADDU, dest, left, right); -} - -static void asm_sub64(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg right, left = ra_alloc2(as, ir, RSET_GPR); - right = (left >> 8); left &= 255; - emit_dst(as, MIPSI_SUBU, dest, dest, RID_TMP); - emit_dst(as, MIPSI_SUBU, dest, left, right); - ir--; - dest = ra_dest(as, ir, RSET_GPR); - left = ra_alloc2(as, ir, RSET_GPR); - right = (left >> 8); left &= 255; - if (dest == left) { - Reg tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, left), right)); - emit_move(as, dest, tmp); - dest = tmp; - } - emit_dst(as, MIPSI_SLTU, RID_TMP, left, dest); - emit_dst(as, MIPSI_SUBU, dest, left, right); -} - -static void asm_neg64(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg left = ra_alloc1(as, ir->op1, RSET_GPR); - emit_dst(as, MIPSI_SUBU, dest, dest, RID_TMP); - emit_dst(as, MIPSI_SUBU, dest, RID_ZERO, left); - ir--; - dest = ra_dest(as, ir, RSET_GPR); - left = ra_alloc1(as, ir->op1, RSET_GPR); - emit_dst(as, MIPSI_SLTU, RID_TMP, RID_ZERO, dest); - emit_dst(as, MIPSI_SUBU, dest, RID_ZERO, left); -} -#endif - -static void asm_bitnot(ASMState *as, IRIns *ir) -{ - Reg left, right, dest = ra_dest(as, ir, RSET_GPR); - IRIns *irl = IR(ir->op1); - if (mayfuse(as, ir->op1) && irl->o == IR_BOR) { - left = ra_alloc2(as, irl, RSET_GPR); - right = (left >> 8); left &= 255; - } else { - left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); - right = RID_ZERO; - } - emit_dst(as, MIPSI_NOR, dest, left, right); -} - -static void asm_bitswap(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg left = ra_alloc1(as, ir->op1, RSET_GPR); - if ((as->flags & JIT_F_MIPS32R2)) { - emit_dta(as, MIPSI_ROTR, dest, RID_TMP, 16); - emit_dst(as, MIPSI_WSBH, RID_TMP, 0, left); - } else { - Reg tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, left), dest)); - emit_dst(as, MIPSI_OR, dest, dest, tmp); - emit_dst(as, MIPSI_OR, dest, dest, RID_TMP); - emit_tsi(as, MIPSI_ANDI, dest, dest, 0xff00); - emit_dta(as, MIPSI_SLL, RID_TMP, RID_TMP, 8); - emit_dta(as, MIPSI_SRL, dest, left, 8); - emit_tsi(as, MIPSI_ANDI, RID_TMP, left, 0xff00); - emit_dst(as, MIPSI_OR, tmp, tmp, RID_TMP); - emit_dta(as, MIPSI_SRL, tmp, left, 24); - emit_dta(as, MIPSI_SLL, RID_TMP, left, 24); - } -} - -static void asm_bitop(ASMState *as, IRIns *ir, MIPSIns mi, MIPSIns mik) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); - if (irref_isk(ir->op2)) { - int32_t k = IR(ir->op2)->i; - if (checku16(k)) { - emit_tsi(as, mik, dest, left, k); - return; - } - } - right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); - emit_dst(as, mi, dest, left, right); -} - -static void asm_bitshift(ASMState *as, IRIns *ir, MIPSIns mi, MIPSIns mik) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - if (irref_isk(ir->op2)) { /* Constant shifts. */ - uint32_t shift = (uint32_t)(IR(ir->op2)->i & 31); - emit_dta(as, mik, dest, ra_hintalloc(as, ir->op1, dest, RSET_GPR), shift); - } else { - Reg right, left = ra_alloc2(as, ir, RSET_GPR); - right = (left >> 8); left &= 255; - emit_dst(as, mi, dest, right, left); /* Shift amount is in rs. */ - } -} - -static void asm_bitror(ASMState *as, IRIns *ir) -{ - if ((as->flags & JIT_F_MIPS32R2)) { - asm_bitshift(as, ir, MIPSI_ROTRV, MIPSI_ROTR); - } else { - Reg dest = ra_dest(as, ir, RSET_GPR); - if (irref_isk(ir->op2)) { /* Constant shifts. */ - uint32_t shift = (uint32_t)(IR(ir->op2)->i & 31); - Reg left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); - emit_rotr(as, dest, left, RID_TMP, shift); - } else { - Reg right, left = ra_alloc2(as, ir, RSET_GPR); - right = (left >> 8); left &= 255; - emit_dst(as, MIPSI_OR, dest, dest, RID_TMP); - emit_dst(as, MIPSI_SRLV, dest, right, left); - emit_dst(as, MIPSI_SLLV, RID_TMP, RID_TMP, left); - emit_dst(as, MIPSI_SUBU, RID_TMP, ra_allock(as, 32, RSET_GPR), right); - } - } -} - -static void asm_min_max(ASMState *as, IRIns *ir, int ismax) -{ - if (irt_isnum(ir->t)) { - Reg dest = ra_dest(as, ir, RSET_FPR); - Reg right, left = ra_alloc2(as, ir, RSET_FPR); - right = (left >> 8); left &= 255; - if (dest == left) { - emit_fg(as, MIPSI_MOVT_D, dest, right); - } else { - emit_fg(as, MIPSI_MOVF_D, dest, left); - if (dest != right) emit_fg(as, MIPSI_MOV_D, dest, right); - } - emit_fgh(as, MIPSI_C_OLT_D, 0, ismax ? left : right, ismax ? right : left); - } else { - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg right, left = ra_alloc2(as, ir, RSET_GPR); - right = (left >> 8); left &= 255; - if (dest == left) { - emit_dst(as, MIPSI_MOVN, dest, right, RID_TMP); - } else { - emit_dst(as, MIPSI_MOVZ, dest, left, RID_TMP); - if (dest != right) emit_move(as, dest, right); - } - emit_dst(as, MIPSI_SLT, RID_TMP, - ismax ? left : right, ismax ? right : left); - } -} - -/* -- Comparisons --------------------------------------------------------- */ - -static void asm_comp(ASMState *as, IRIns *ir) -{ - /* ORDER IR: LT GE LE GT ULT UGE ULE UGT. */ - IROp op = ir->o; - if (irt_isnum(ir->t)) { - Reg right, left = ra_alloc2(as, ir, RSET_FPR); - right = (left >> 8); left &= 255; - asm_guard(as, (op&1) ? MIPSI_BC1T : MIPSI_BC1F, 0, 0); - emit_fgh(as, MIPSI_C_OLT_D + ((op&3) ^ ((op>>2)&1)), 0, left, right); - } else { - Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); - if (op == IR_ABC) op = IR_UGT; - if ((op&4) == 0 && irref_isk(ir->op2) && IR(ir->op2)->i == 0) { - MIPSIns mi = (op&2) ? ((op&1) ? MIPSI_BLEZ : MIPSI_BGTZ) : - ((op&1) ? MIPSI_BLTZ : MIPSI_BGEZ); - asm_guard(as, mi, left, 0); - } else { - if (irref_isk(ir->op2)) { - int32_t k = IR(ir->op2)->i; - if ((op&2)) k++; - if (checki16(k)) { - asm_guard(as, (op&1) ? MIPSI_BNE : MIPSI_BEQ, RID_TMP, RID_ZERO); - emit_tsi(as, (op&4) ? MIPSI_SLTIU : MIPSI_SLTI, - RID_TMP, left, k); - return; - } - } - right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); - asm_guard(as, ((op^(op>>1))&1) ? MIPSI_BNE : MIPSI_BEQ, RID_TMP, RID_ZERO); - emit_dst(as, (op&4) ? MIPSI_SLTU : MIPSI_SLT, - RID_TMP, (op&2) ? right : left, (op&2) ? left : right); - } - } -} - -static void asm_compeq(ASMState *as, IRIns *ir) -{ - Reg right, left = ra_alloc2(as, ir, irt_isnum(ir->t) ? RSET_FPR : RSET_GPR); - right = (left >> 8); left &= 255; - if (irt_isnum(ir->t)) { - asm_guard(as, (ir->o & 1) ? MIPSI_BC1T : MIPSI_BC1F, 0, 0); - emit_fgh(as, MIPSI_C_EQ_D, 0, left, right); - } else { - asm_guard(as, (ir->o & 1) ? MIPSI_BEQ : MIPSI_BNE, left, right); - } -} - -#if LJ_HASFFI -/* 64 bit integer comparisons. */ -static void asm_comp64(ASMState *as, IRIns *ir) -{ - /* ORDER IR: LT GE LE GT ULT UGE ULE UGT. */ - IROp op = (ir-1)->o; - MCLabel l_end; - Reg rightlo, leftlo, righthi, lefthi = ra_alloc2(as, ir, RSET_GPR); - righthi = (lefthi >> 8); lefthi &= 255; - leftlo = ra_alloc2(as, ir-1, - rset_exclude(rset_exclude(RSET_GPR, lefthi), righthi)); - rightlo = (leftlo >> 8); leftlo &= 255; - asm_guard(as, ((op^(op>>1))&1) ? MIPSI_BNE : MIPSI_BEQ, RID_TMP, RID_ZERO); - l_end = emit_label(as); - if (lefthi != righthi) - emit_dst(as, (op&4) ? MIPSI_SLTU : MIPSI_SLT, RID_TMP, - (op&2) ? righthi : lefthi, (op&2) ? lefthi : righthi); - emit_dst(as, MIPSI_SLTU, RID_TMP, - (op&2) ? rightlo : leftlo, (op&2) ? leftlo : rightlo); - if (lefthi != righthi) - emit_branch(as, MIPSI_BEQ, lefthi, righthi, l_end); -} - -static void asm_comp64eq(ASMState *as, IRIns *ir) -{ - Reg tmp, right, left = ra_alloc2(as, ir, RSET_GPR); - right = (left >> 8); left &= 255; - asm_guard(as, ((ir-1)->o & 1) ? MIPSI_BEQ : MIPSI_BNE, RID_TMP, RID_ZERO); - tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, left), right)); - emit_dst(as, MIPSI_OR, RID_TMP, RID_TMP, tmp); - emit_dst(as, MIPSI_XOR, tmp, left, right); - left = ra_alloc2(as, ir-1, RSET_GPR); - right = (left >> 8); left &= 255; - emit_dst(as, MIPSI_XOR, RID_TMP, left, right); -} -#endif - -/* -- Support for 64 bit ops in 32 bit mode ------------------------------- */ - -/* Hiword op of a split 64 bit op. Previous op must be the loword op. */ -static void asm_hiop(ASMState *as, IRIns *ir) -{ -#if LJ_HASFFI - /* HIOP is marked as a store because it needs its own DCE logic. */ - int uselo = ra_used(ir-1), usehi = ra_used(ir); /* Loword/hiword used? */ - if (LJ_UNLIKELY(!(as->flags & JIT_F_OPT_DCE))) uselo = usehi = 1; - if ((ir-1)->o == IR_CONV) { /* Conversions to/from 64 bit. */ - as->curins--; /* Always skip the CONV. */ - if (usehi || uselo) - asm_conv64(as, ir); - return; - } else if ((ir-1)->o < IR_EQ) { /* 64 bit integer comparisons. ORDER IR. */ - as->curins--; /* Always skip the loword comparison. */ - asm_comp64(as, ir); - return; - } else if ((ir-1)->o <= IR_NE) { /* 64 bit integer comparisons. ORDER IR. */ - as->curins--; /* Always skip the loword comparison. */ - asm_comp64eq(as, ir); - return; - } else if ((ir-1)->o == IR_XSTORE) { - as->curins--; /* Handle both stores here. */ - if ((ir-1)->r != RID_SINK) { - asm_xstore(as, ir, LJ_LE ? 4 : 0); - asm_xstore(as, ir-1, LJ_LE ? 0 : 4); - } - return; - } - if (!usehi) return; /* Skip unused hiword op for all remaining ops. */ - switch ((ir-1)->o) { - case IR_ADD: as->curins--; asm_add64(as, ir); break; - case IR_SUB: as->curins--; asm_sub64(as, ir); break; - case IR_NEG: as->curins--; asm_neg64(as, ir); break; - case IR_CALLN: - case IR_CALLXS: - if (!uselo) - ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */ - break; - case IR_CNEWI: - /* Nothing to do here. Handled by lo op itself. */ - break; - default: lua_assert(0); break; - } -#else - UNUSED(as); UNUSED(ir); lua_assert(0); /* Unused without FFI. */ -#endif -} - -/* -- Stack handling ------------------------------------------------------ */ - -/* Check Lua stack size for overflow. Use exit handler as fallback. */ -static void asm_stack_check(ASMState *as, BCReg topslot, - IRIns *irp, RegSet allow, ExitNo exitno) -{ - /* Try to get an unused temp. register, otherwise spill/restore RID_RET*. */ - Reg tmp, pbase = irp ? (ra_hasreg(irp->r) ? irp->r : RID_TMP) : RID_BASE; - ExitNo oldsnap = as->snapno; - rset_clear(allow, pbase); - tmp = allow ? rset_pickbot(allow) : - (pbase == RID_RETHI ? RID_RETLO : RID_RETHI); - as->snapno = exitno; - asm_guard(as, MIPSI_BNE, RID_TMP, RID_ZERO); - as->snapno = oldsnap; - if (allow == RSET_EMPTY) /* Restore temp. register. */ - emit_tsi(as, MIPSI_LW, tmp, RID_SP, 0); - else - ra_modified(as, tmp); - emit_tsi(as, MIPSI_SLTIU, RID_TMP, RID_TMP, (int32_t)(8*topslot)); - emit_dst(as, MIPSI_SUBU, RID_TMP, tmp, pbase); - emit_tsi(as, MIPSI_LW, tmp, tmp, offsetof(lua_State, maxstack)); - if (pbase == RID_TMP) - emit_getgl(as, RID_TMP, jit_base); - emit_getgl(as, tmp, jit_L); - if (allow == RSET_EMPTY) /* Spill temp. register. */ - emit_tsi(as, MIPSI_SW, tmp, RID_SP, 0); -} - -/* Restore Lua stack from on-trace state. */ -static void asm_stack_restore(ASMState *as, SnapShot *snap) -{ - SnapEntry *map = &as->T->snapmap[snap->mapofs]; - SnapEntry *flinks = &as->T->snapmap[snap_nextofs(as->T, snap)-1]; - MSize n, nent = snap->nent; - /* Store the value of all modified slots to the Lua stack. */ - for (n = 0; n < nent; n++) { - SnapEntry sn = map[n]; - BCReg s = snap_slot(sn); - int32_t ofs = 8*((int32_t)s-1); - IRRef ref = snap_ref(sn); - IRIns *ir = IR(ref); - if ((sn & SNAP_NORESTORE)) - continue; - if (irt_isnum(ir->t)) { - Reg src = ra_alloc1(as, ref, RSET_FPR); - emit_hsi(as, MIPSI_SDC1, src, RID_BASE, ofs); - } else { - Reg type; - RegSet allow = rset_exclude(RSET_GPR, RID_BASE); - lua_assert(irt_ispri(ir->t) || irt_isaddr(ir->t) || irt_isinteger(ir->t)); - if (!irt_ispri(ir->t)) { - Reg src = ra_alloc1(as, ref, allow); - rset_clear(allow, src); - emit_tsi(as, MIPSI_SW, src, RID_BASE, ofs+(LJ_BE?4:0)); - } - if ((sn & (SNAP_CONT|SNAP_FRAME))) { - if (s == 0) continue; /* Do not overwrite link to previous frame. */ - type = ra_allock(as, (int32_t)(*flinks--), allow); - } else { - type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); - } - emit_tsi(as, MIPSI_SW, type, RID_BASE, ofs+(LJ_BE?0:4)); - } - checkmclim(as); - } - lua_assert(map + nent == flinks); -} - -/* -- GC handling --------------------------------------------------------- */ - -/* Check GC threshold and do one or more GC steps. */ -static void asm_gc_check(ASMState *as) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_step_jit]; - IRRef args[2]; - MCLabel l_end; - Reg tmp; - ra_evictset(as, RSET_SCRATCH); - l_end = emit_label(as); - /* Exit trace if in GCSatomic or GCSfinalize. Avoids syncing GC objects. */ - /* Assumes asm_snap_prep() already done. */ - asm_guard(as, MIPSI_BNE, RID_RET, RID_ZERO); - args[0] = ASMREF_TMP1; /* global_State *g */ - args[1] = ASMREF_TMP2; /* MSize steps */ - asm_gencall(as, ci, args); - emit_tsi(as, MIPSI_ADDIU, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768); - tmp = ra_releasetmp(as, ASMREF_TMP2); - emit_loadi(as, tmp, as->gcsteps); - /* Jump around GC step if GC total < GC threshold. */ - emit_branch(as, MIPSI_BNE, RID_TMP, RID_ZERO, l_end); - emit_dst(as, MIPSI_SLTU, RID_TMP, RID_TMP, tmp); - emit_getgl(as, tmp, gc.threshold); - emit_getgl(as, RID_TMP, gc.total); - as->gcsteps = 0; - checkmclim(as); -} - -/* -- Loop handling ------------------------------------------------------- */ - -/* Fixup the loop branch. */ -static void asm_loop_fixup(ASMState *as) -{ - MCode *p = as->mctop; - MCode *target = as->mcp; - p[-1] = MIPSI_NOP; - if (as->loopinv) { /* Inverted loop branch? */ - /* asm_guard already inverted the cond branch. Only patch the target. */ - p[-3] |= ((target-p+2) & 0x0000ffffu); - } else { - p[-2] = MIPSI_J|(((uintptr_t)target>>2)&0x03ffffffu); - } -} - -/* -- Head of trace ------------------------------------------------------- */ - -/* Coalesce BASE register for a root trace. */ -static void asm_head_root_base(ASMState *as) -{ - IRIns *ir = IR(REF_BASE); - Reg r = ir->r; - if (as->loopinv) as->mctop--; - if (ra_hasreg(r)) { - ra_free(as, r); - if (rset_test(as->modset, r) || irt_ismarked(ir->t)) - ir->r = RID_INIT; /* No inheritance for modified BASE register. */ - if (r != RID_BASE) - emit_move(as, r, RID_BASE); - } -} - -/* Coalesce BASE register for a side trace. */ -static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) -{ - IRIns *ir = IR(REF_BASE); - Reg r = ir->r; - if (as->loopinv) as->mctop--; - if (ra_hasreg(r)) { - ra_free(as, r); - if (rset_test(as->modset, r) || irt_ismarked(ir->t)) - ir->r = RID_INIT; /* No inheritance for modified BASE register. */ - if (irp->r == r) { - rset_clear(allow, r); /* Mark same BASE register as coalesced. */ - } else if (ra_hasreg(irp->r) && rset_test(as->freeset, irp->r)) { - rset_clear(allow, irp->r); - emit_move(as, r, irp->r); /* Move from coalesced parent reg. */ - } else { - emit_getgl(as, r, jit_base); /* Otherwise reload BASE. */ - } - } - return allow; -} - -/* -- Tail of trace ------------------------------------------------------- */ - -/* Fixup the tail code. */ -static void asm_tail_fixup(ASMState *as, TraceNo lnk) -{ - MCode *target = lnk ? traceref(as->J,lnk)->mcode : (MCode *)lj_vm_exit_interp; - int32_t spadj = as->T->spadjust; - MCode *p = as->mctop-1; - *p = spadj ? (MIPSI_ADDIU|MIPSF_T(RID_SP)|MIPSF_S(RID_SP)|spadj) : MIPSI_NOP; - p[-1] = MIPSI_J|(((uintptr_t)target>>2)&0x03ffffffu); -} - -/* Prepare tail of code. */ -static void asm_tail_prep(ASMState *as) -{ - as->mcp = as->mctop-2; /* Leave room for branch plus nop or stack adj. */ - as->invmcp = as->loopref ? as->mcp : NULL; -} - -/* -- Instruction dispatch ------------------------------------------------ */ - -/* Assemble a single instruction. */ -static void asm_ir(ASMState *as, IRIns *ir) -{ - switch ((IROp)ir->o) { - /* Miscellaneous ops. */ - case IR_LOOP: asm_loop(as); break; - case IR_NOP: case IR_XBAR: lua_assert(!ra_used(ir)); break; - case IR_USE: - ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break; - case IR_PHI: asm_phi(as, ir); break; - case IR_HIOP: asm_hiop(as, ir); break; - case IR_GCSTEP: asm_gcstep(as, ir); break; - - /* Guarded assertions. */ - case IR_EQ: case IR_NE: asm_compeq(as, ir); break; - case IR_LT: case IR_GE: case IR_LE: case IR_GT: - case IR_ULT: case IR_UGE: case IR_ULE: case IR_UGT: - case IR_ABC: - asm_comp(as, ir); - break; - - case IR_RETF: asm_retf(as, ir); break; - - /* Bit ops. */ - case IR_BNOT: asm_bitnot(as, ir); break; - case IR_BSWAP: asm_bitswap(as, ir); break; - - case IR_BAND: asm_bitop(as, ir, MIPSI_AND, MIPSI_ANDI); break; - case IR_BOR: asm_bitop(as, ir, MIPSI_OR, MIPSI_ORI); break; - case IR_BXOR: asm_bitop(as, ir, MIPSI_XOR, MIPSI_XORI); break; - - case IR_BSHL: asm_bitshift(as, ir, MIPSI_SLLV, MIPSI_SLL); break; - case IR_BSHR: asm_bitshift(as, ir, MIPSI_SRLV, MIPSI_SRL); break; - case IR_BSAR: asm_bitshift(as, ir, MIPSI_SRAV, MIPSI_SRA); break; - case IR_BROL: lua_assert(0); break; - case IR_BROR: asm_bitror(as, ir); break; - - /* Arithmetic ops. */ - case IR_ADD: asm_add(as, ir); break; - case IR_SUB: asm_sub(as, ir); break; - case IR_MUL: asm_mul(as, ir); break; - case IR_DIV: asm_fparith(as, ir, MIPSI_DIV_D); break; - case IR_MOD: asm_callid(as, ir, IRCALL_lj_vm_modi); break; - case IR_POW: asm_callid(as, ir, IRCALL_lj_vm_powi); break; - case IR_NEG: asm_neg(as, ir); break; - - case IR_ABS: asm_fpunary(as, ir, MIPSI_ABS_D); break; - case IR_ATAN2: asm_callid(as, ir, IRCALL_atan2); break; - case IR_LDEXP: asm_callid(as, ir, IRCALL_ldexp); break; - case IR_MIN: asm_min_max(as, ir, 0); break; - case IR_MAX: asm_min_max(as, ir, 1); break; - case IR_FPMATH: - if (ir->op2 == IRFPM_EXP2 && asm_fpjoin_pow(as, ir)) - break; - if (ir->op2 <= IRFPM_TRUNC) - asm_callround(as, ir, IRCALL_lj_vm_floor + ir->op2); - else if (ir->op2 == IRFPM_SQRT) - asm_fpunary(as, ir, MIPSI_SQRT_D); - else - asm_callid(as, ir, IRCALL_lj_vm_floor + ir->op2); - break; - - /* Overflow-checking arithmetic ops. */ - case IR_ADDOV: asm_arithov(as, ir); break; - case IR_SUBOV: asm_arithov(as, ir); break; - case IR_MULOV: asm_mulov(as, ir); break; - - /* Memory references. */ - case IR_AREF: asm_aref(as, ir); break; - case IR_HREF: asm_href(as, ir); break; - case IR_HREFK: asm_hrefk(as, ir); break; - case IR_NEWREF: asm_newref(as, ir); break; - case IR_UREFO: case IR_UREFC: asm_uref(as, ir); break; - case IR_FREF: asm_fref(as, ir); break; - case IR_STRREF: asm_strref(as, ir); break; - - /* Loads and stores. */ - case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: - asm_ahuvload(as, ir); - break; - case IR_FLOAD: asm_fload(as, ir); break; - case IR_XLOAD: asm_xload(as, ir); break; - case IR_SLOAD: asm_sload(as, ir); break; - - case IR_ASTORE: case IR_HSTORE: case IR_USTORE: asm_ahustore(as, ir); break; - case IR_FSTORE: asm_fstore(as, ir); break; - case IR_XSTORE: asm_xstore(as, ir, 0); break; - - /* Allocations. */ - case IR_SNEW: case IR_XSNEW: asm_snew(as, ir); break; - case IR_TNEW: asm_tnew(as, ir); break; - case IR_TDUP: asm_tdup(as, ir); break; - case IR_CNEW: case IR_CNEWI: asm_cnew(as, ir); break; - - /* Write barriers. */ - case IR_TBAR: asm_tbar(as, ir); break; - case IR_OBAR: asm_obar(as, ir); break; - - /* Type conversions. */ - case IR_CONV: asm_conv(as, ir); break; - case IR_TOBIT: asm_tobit(as, ir); break; - case IR_TOSTR: asm_tostr(as, ir); break; - case IR_STRTO: asm_strto(as, ir); break; - - /* Calls. */ - case IR_CALLN: case IR_CALLL: case IR_CALLS: asm_call(as, ir); break; - case IR_CALLXS: asm_callx(as, ir); break; - case IR_CARG: break; - - default: - setintV(&as->J->errinfo, ir->o); - lj_trace_err_info(as->J, LJ_TRERR_NYIIR); - break; - } -} - -/* -- Trace setup --------------------------------------------------------- */ - -/* Ensure there are enough stack slots for call arguments. */ -static Reg asm_setup_call_slots(ASMState *as, IRIns *ir, const CCallInfo *ci) -{ - IRRef args[CCI_NARGS_MAX*2]; - uint32_t i, nargs = (int)CCI_NARGS(ci); - int nslots = 4, ngpr = REGARG_NUMGPR, nfpr = REGARG_NUMFPR; - asm_collectargs(as, ir, ci, args); - for (i = 0; i < nargs; i++) { - if (args[i] && irt_isfp(IR(args[i])->t) && - nfpr > 0 && !(ci->flags & CCI_VARARG)) { - nfpr--; - ngpr -= irt_isnum(IR(args[i])->t) ? 2 : 1; - } else if (args[i] && irt_isnum(IR(args[i])->t)) { - nfpr = 0; - ngpr = ngpr & ~1; - if (ngpr > 0) ngpr -= 2; else nslots = (nslots+3) & ~1; - } else { - nfpr = 0; - if (ngpr > 0) ngpr--; else nslots++; - } - } - if (nslots > as->evenspill) /* Leave room for args in stack slots. */ - as->evenspill = nslots; - return irt_isfp(ir->t) ? REGSP_HINT(RID_FPRET) : REGSP_HINT(RID_RET); -} - -static void asm_setup_target(ASMState *as) -{ - asm_sparejump_setup(as); - asm_exitstub_setup(as); -} - -/* -- Trace patching ------------------------------------------------------ */ - -/* Patch exit jumps of existing machine code to a new target. */ -void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target) -{ - MCode *p = T->mcode; - MCode *pe = (MCode *)((char *)p + T->szmcode); - MCode *px = exitstub_trace_addr(T, exitno); - MCode *cstart = NULL, *cstop = NULL; - MCode *mcarea = lj_mcode_patch(J, p, 0); - MCode exitload = MIPSI_LI | MIPSF_T(RID_TMP) | exitno; - MCode tjump = MIPSI_J|(((uintptr_t)target>>2)&0x03ffffffu); - for (p++; p < pe; p++) { - if (*p == exitload) { /* Look for load of exit number. */ - if (((p[-1] ^ (px-p)) & 0xffffu) == 0) { /* Look for exitstub branch. */ - ptrdiff_t delta = target - p; - if (((delta + 0x8000) >> 16) == 0) { /* Patch in-range branch. */ - patchbranch: - p[-1] = (p[-1] & 0xffff0000u) | (delta & 0xffffu); - *p = MIPSI_NOP; /* Replace the load of the exit number. */ - cstop = p; - if (!cstart) cstart = p-1; - } else { /* Branch out of range. Use spare jump slot in mcarea. */ - int i; - for (i = 2; i < 2+MIPS_SPAREJUMP*2; i += 2) { - if (mcarea[i] == tjump) { - delta = mcarea+i - p; - goto patchbranch; - } else if (mcarea[i] == MIPSI_NOP) { - mcarea[i] = tjump; - cstart = mcarea+i; - delta = mcarea+i - p; - goto patchbranch; - } - } - /* Ignore jump slot overflow. Child trace is simply not attached. */ - } - } else if (p+1 == pe) { - /* Patch NOP after code for inverted loop branch. Use of J is ok. */ - lua_assert(p[1] == MIPSI_NOP); - p[1] = tjump; - *p = MIPSI_NOP; /* Replace the load of the exit number. */ - cstop = p+2; - if (!cstart) cstart = p+1; - } - } - } - if (cstart) lj_mcode_sync(cstart, cstop); - lj_mcode_patch(J, mcarea, 1); -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_ppc.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_ppc.h deleted file mode 100644 index e1a496a7e..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_ppc.h +++ /dev/null @@ -1,2167 +0,0 @@ -/* -** PPC IR assembler (SSA IR -> machine code). -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -/* -- Register allocator extensions --------------------------------------- */ - -/* Allocate a register with a hint. */ -static Reg ra_hintalloc(ASMState *as, IRRef ref, Reg hint, RegSet allow) -{ - Reg r = IR(ref)->r; - if (ra_noreg(r)) { - if (!ra_hashint(r) && !iscrossref(as, ref)) - ra_sethint(IR(ref)->r, hint); /* Propagate register hint. */ - r = ra_allocref(as, ref, allow); - } - ra_noweak(as, r); - return r; -} - -/* Allocate two source registers for three-operand instructions. */ -static Reg ra_alloc2(ASMState *as, IRIns *ir, RegSet allow) -{ - IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); - Reg left = irl->r, right = irr->r; - if (ra_hasreg(left)) { - ra_noweak(as, left); - if (ra_noreg(right)) - right = ra_allocref(as, ir->op2, rset_exclude(allow, left)); - else - ra_noweak(as, right); - } else if (ra_hasreg(right)) { - ra_noweak(as, right); - left = ra_allocref(as, ir->op1, rset_exclude(allow, right)); - } else if (ra_hashint(right)) { - right = ra_allocref(as, ir->op2, allow); - left = ra_alloc1(as, ir->op1, rset_exclude(allow, right)); - } else { - left = ra_allocref(as, ir->op1, allow); - right = ra_alloc1(as, ir->op2, rset_exclude(allow, left)); - } - return left | (right << 8); -} - -/* -- Guard handling ------------------------------------------------------ */ - -/* Setup exit stubs after the end of each trace. */ -static void asm_exitstub_setup(ASMState *as, ExitNo nexits) -{ - ExitNo i; - MCode *mxp = as->mctop; - /* 1: mflr r0; bl ->vm_exit_handler; li r0, traceno; bl <1; bl <1; ... */ - for (i = nexits-1; (int32_t)i >= 0; i--) - *--mxp = PPCI_BL|(((-3-i)&0x00ffffffu)<<2); - *--mxp = PPCI_LI|PPCF_T(RID_TMP)|as->T->traceno; /* Read by exit handler. */ - mxp--; - *mxp = PPCI_BL|((((MCode *)(void *)lj_vm_exit_handler-mxp)&0x00ffffffu)<<2); - *--mxp = PPCI_MFLR|PPCF_T(RID_TMP); - as->mctop = mxp; -} - -static MCode *asm_exitstub_addr(ASMState *as, ExitNo exitno) -{ - /* Keep this in-sync with exitstub_trace_addr(). */ - return as->mctop + exitno + 3; -} - -/* Emit conditional branch to exit for guard. */ -static void asm_guardcc(ASMState *as, PPCCC cc) -{ - MCode *target = asm_exitstub_addr(as, as->snapno); - MCode *p = as->mcp; - if (LJ_UNLIKELY(p == as->invmcp)) { - as->loopinv = 1; - *p = PPCI_B | (((target-p) & 0x00ffffffu) << 2); - emit_condbranch(as, PPCI_BC, cc^4, p); - return; - } - emit_condbranch(as, PPCI_BC, cc, target); -} - -/* -- Operand fusion ------------------------------------------------------ */ - -/* Limit linear search to this distance. Avoids O(n^2) behavior. */ -#define CONFLICT_SEARCH_LIM 31 - -/* Check if there's no conflicting instruction between curins and ref. */ -static int noconflict(ASMState *as, IRRef ref, IROp conflict) -{ - IRIns *ir = as->ir; - IRRef i = as->curins; - if (i > ref + CONFLICT_SEARCH_LIM) - return 0; /* Give up, ref is too far away. */ - while (--i > ref) - if (ir[i].o == conflict) - return 0; /* Conflict found. */ - return 1; /* Ok, no conflict. */ -} - -/* Fuse the array base of colocated arrays. */ -static int32_t asm_fuseabase(ASMState *as, IRRef ref) -{ - IRIns *ir = IR(ref); - if (ir->o == IR_TNEW && ir->op1 <= LJ_MAX_COLOSIZE && - !neverfuse(as) && noconflict(as, ref, IR_NEWREF)) - return (int32_t)sizeof(GCtab); - return 0; -} - -/* Indicates load/store indexed is ok. */ -#define AHUREF_LSX ((int32_t)0x80000000) - -/* Fuse array/hash/upvalue reference into register+offset operand. */ -static Reg asm_fuseahuref(ASMState *as, IRRef ref, int32_t *ofsp, RegSet allow) -{ - IRIns *ir = IR(ref); - if (ra_noreg(ir->r)) { - if (ir->o == IR_AREF) { - if (mayfuse(as, ref)) { - if (irref_isk(ir->op2)) { - IRRef tab = IR(ir->op1)->op1; - int32_t ofs = asm_fuseabase(as, tab); - IRRef refa = ofs ? tab : ir->op1; - ofs += 8*IR(ir->op2)->i; - if (checki16(ofs)) { - *ofsp = ofs; - return ra_alloc1(as, refa, allow); - } - } - if (*ofsp == AHUREF_LSX) { - Reg base = ra_alloc1(as, ir->op1, allow); - Reg idx = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, base)); - return base | (idx << 8); - } - } - } else if (ir->o == IR_HREFK) { - if (mayfuse(as, ref)) { - int32_t ofs = (int32_t)(IR(ir->op2)->op2 * sizeof(Node)); - if (checki16(ofs)) { - *ofsp = ofs; - return ra_alloc1(as, ir->op1, allow); - } - } - } else if (ir->o == IR_UREFC) { - if (irref_isk(ir->op1)) { - GCfunc *fn = ir_kfunc(IR(ir->op1)); - int32_t ofs = i32ptr(&gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.tv); - int32_t jgl = (intptr_t)J2G(as->J); - if ((uint32_t)(ofs-jgl) < 65536) { - *ofsp = ofs-jgl-32768; - return RID_JGL; - } else { - *ofsp = (int16_t)ofs; - return ra_allock(as, ofs-(int16_t)ofs, allow); - } - } - } - } - *ofsp = 0; - return ra_alloc1(as, ref, allow); -} - -/* Fuse XLOAD/XSTORE reference into load/store operand. */ -static void asm_fusexref(ASMState *as, PPCIns pi, Reg rt, IRRef ref, - RegSet allow, int32_t ofs) -{ - IRIns *ir = IR(ref); - Reg base; - if (ra_noreg(ir->r) && canfuse(as, ir)) { - if (ir->o == IR_ADD) { - int32_t ofs2; - if (irref_isk(ir->op2) && (ofs2 = ofs + IR(ir->op2)->i, checki16(ofs2))) { - ofs = ofs2; - ref = ir->op1; - } else if (ofs == 0) { - Reg right, left = ra_alloc2(as, ir, allow); - right = (left >> 8); left &= 255; - emit_fab(as, PPCI_LWZX | ((pi >> 20) & 0x780), rt, left, right); - return; - } - } else if (ir->o == IR_STRREF) { - lua_assert(ofs == 0); - ofs = (int32_t)sizeof(GCstr); - if (irref_isk(ir->op2)) { - ofs += IR(ir->op2)->i; - ref = ir->op1; - } else if (irref_isk(ir->op1)) { - ofs += IR(ir->op1)->i; - ref = ir->op2; - } else { - /* NYI: Fuse ADD with constant. */ - Reg tmp, right, left = ra_alloc2(as, ir, allow); - right = (left >> 8); left &= 255; - tmp = ra_scratch(as, rset_exclude(rset_exclude(allow, left), right)); - emit_fai(as, pi, rt, tmp, ofs); - emit_tab(as, PPCI_ADD, tmp, left, right); - return; - } - if (!checki16(ofs)) { - Reg left = ra_alloc1(as, ref, allow); - Reg right = ra_allock(as, ofs, rset_exclude(allow, left)); - emit_fab(as, PPCI_LWZX | ((pi >> 20) & 0x780), rt, left, right); - return; - } - } - } - base = ra_alloc1(as, ref, allow); - emit_fai(as, pi, rt, base, ofs); -} - -/* Fuse XLOAD/XSTORE reference into indexed-only load/store operand. */ -static void asm_fusexrefx(ASMState *as, PPCIns pi, Reg rt, IRRef ref, - RegSet allow) -{ - IRIns *ira = IR(ref); - Reg right, left; - if (canfuse(as, ira) && ira->o == IR_ADD && ra_noreg(ira->r)) { - left = ra_alloc2(as, ira, allow); - right = (left >> 8); left &= 255; - } else { - right = ra_alloc1(as, ref, allow); - left = RID_R0; - } - emit_tab(as, pi, rt, left, right); -} - -/* Fuse to multiply-add/sub instruction. */ -static int asm_fusemadd(ASMState *as, IRIns *ir, PPCIns pi, PPCIns pir) -{ - IRRef lref = ir->op1, rref = ir->op2; - IRIns *irm; - if (lref != rref && - ((mayfuse(as, lref) && (irm = IR(lref), irm->o == IR_MUL) && - ra_noreg(irm->r)) || - (mayfuse(as, rref) && (irm = IR(rref), irm->o == IR_MUL) && - (rref = lref, pi = pir, ra_noreg(irm->r))))) { - Reg dest = ra_dest(as, ir, RSET_FPR); - Reg add = ra_alloc1(as, rref, RSET_FPR); - Reg right, left = ra_alloc2(as, irm, rset_exclude(RSET_FPR, add)); - right = (left >> 8); left &= 255; - emit_facb(as, pi, dest, left, right, add); - return 1; - } - return 0; -} - -/* -- Calls --------------------------------------------------------------- */ - -/* Generate a call to a C function. */ -static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args) -{ - uint32_t n, nargs = CCI_NARGS(ci); - int32_t ofs = 8; - Reg gpr = REGARG_FIRSTGPR, fpr = REGARG_FIRSTFPR; - if ((void *)ci->func) - emit_call(as, (void *)ci->func); - for (n = 0; n < nargs; n++) { /* Setup args. */ - IRRef ref = args[n]; - if (ref) { - IRIns *ir = IR(ref); - if (irt_isfp(ir->t)) { - if (fpr <= REGARG_LASTFPR) { - lua_assert(rset_test(as->freeset, fpr)); /* Already evicted. */ - ra_leftov(as, fpr, ref); - fpr++; - } else { - Reg r = ra_alloc1(as, ref, RSET_FPR); - if (irt_isnum(ir->t)) ofs = (ofs + 4) & ~4; - emit_spstore(as, ir, r, ofs); - ofs += irt_isnum(ir->t) ? 8 : 4; - } - } else { - if (gpr <= REGARG_LASTGPR) { - lua_assert(rset_test(as->freeset, gpr)); /* Already evicted. */ - ra_leftov(as, gpr, ref); - gpr++; - } else { - Reg r = ra_alloc1(as, ref, RSET_GPR); - emit_spstore(as, ir, r, ofs); - ofs += 4; - } - } - } else { - if (gpr <= REGARG_LASTGPR) - gpr++; - else - ofs += 4; - } - checkmclim(as); - } - if ((ci->flags & CCI_VARARG)) /* Vararg calls need to know about FPR use. */ - emit_tab(as, fpr == REGARG_FIRSTFPR ? PPCI_CRXOR : PPCI_CREQV, 6, 6, 6); -} - -/* Setup result reg/sp for call. Evict scratch regs. */ -static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci) -{ - RegSet drop = RSET_SCRATCH; - int hiop = ((ir+1)->o == IR_HIOP); - if ((ci->flags & CCI_NOFPRCLOBBER)) - drop &= ~RSET_FPR; - if (ra_hasreg(ir->r)) - rset_clear(drop, ir->r); /* Dest reg handled below. */ - if (hiop && ra_hasreg((ir+1)->r)) - rset_clear(drop, (ir+1)->r); /* Dest reg handled below. */ - ra_evictset(as, drop); /* Evictions must be performed first. */ - if (ra_used(ir)) { - lua_assert(!irt_ispri(ir->t)); - if (irt_isfp(ir->t)) { - if ((ci->flags & CCI_CASTU64)) { - /* Use spill slot or temp slots. */ - int32_t ofs = ir->s ? sps_scale(ir->s) : SPOFS_TMP; - Reg dest = ir->r; - if (ra_hasreg(dest)) { - ra_free(as, dest); - ra_modified(as, dest); - emit_fai(as, PPCI_LFD, dest, RID_SP, ofs); - } - emit_tai(as, PPCI_STW, RID_RETHI, RID_SP, ofs); - emit_tai(as, PPCI_STW, RID_RETLO, RID_SP, ofs+4); - } else { - ra_destreg(as, ir, RID_FPRET); - } - } else if (hiop) { - ra_destpair(as, ir); - } else { - ra_destreg(as, ir, RID_RET); - } - } -} - -static void asm_call(ASMState *as, IRIns *ir) -{ - IRRef args[CCI_NARGS_MAX]; - const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; - asm_collectargs(as, ir, ci, args); - asm_setupresult(as, ir, ci); - asm_gencall(as, ci, args); -} - -static void asm_callx(ASMState *as, IRIns *ir) -{ - IRRef args[CCI_NARGS_MAX*2]; - CCallInfo ci; - IRRef func; - IRIns *irf; - ci.flags = asm_callx_flags(as, ir); - asm_collectargs(as, ir, &ci, args); - asm_setupresult(as, ir, &ci); - func = ir->op2; irf = IR(func); - if (irf->o == IR_CARG) { func = irf->op1; irf = IR(func); } - if (irref_isk(func)) { /* Call to constant address. */ - ci.func = (ASMFunction)(void *)(irf->i); - } else { /* Need a non-argument register for indirect calls. */ - RegSet allow = RSET_GPR & ~RSET_RANGE(RID_R0, REGARG_LASTGPR+1); - Reg freg = ra_alloc1(as, func, allow); - *--as->mcp = PPCI_BCTRL; - *--as->mcp = PPCI_MTCTR | PPCF_T(freg); - ci.func = (ASMFunction)(void *)0; - } - asm_gencall(as, &ci, args); -} - -static void asm_callid(ASMState *as, IRIns *ir, IRCallID id) -{ - const CCallInfo *ci = &lj_ir_callinfo[id]; - IRRef args[2]; - args[0] = ir->op1; - args[1] = ir->op2; - asm_setupresult(as, ir, ci); - asm_gencall(as, ci, args); -} - -/* -- Returns ------------------------------------------------------------- */ - -/* Return to lower frame. Guard that it goes to the right spot. */ -static void asm_retf(ASMState *as, IRIns *ir) -{ - Reg base = ra_alloc1(as, REF_BASE, RSET_GPR); - void *pc = ir_kptr(IR(ir->op2)); - int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); - as->topslot -= (BCReg)delta; - if ((int32_t)as->topslot < 0) as->topslot = 0; - irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */ - emit_setgl(as, base, jit_base); - emit_addptr(as, base, -8*delta); - asm_guardcc(as, CC_NE); - emit_ab(as, PPCI_CMPW, RID_TMP, - ra_allock(as, i32ptr(pc), rset_exclude(RSET_GPR, base))); - emit_tai(as, PPCI_LWZ, RID_TMP, base, -8); -} - -/* -- Type conversions ---------------------------------------------------- */ - -static void asm_tointg(ASMState *as, IRIns *ir, Reg left) -{ - RegSet allow = RSET_FPR; - Reg tmp = ra_scratch(as, rset_clear(allow, left)); - Reg fbias = ra_scratch(as, rset_clear(allow, tmp)); - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg hibias = ra_allock(as, 0x43300000, rset_exclude(RSET_GPR, dest)); - asm_guardcc(as, CC_NE); - emit_fab(as, PPCI_FCMPU, 0, tmp, left); - emit_fab(as, PPCI_FSUB, tmp, tmp, fbias); - emit_fai(as, PPCI_LFD, tmp, RID_SP, SPOFS_TMP); - emit_tai(as, PPCI_STW, RID_TMP, RID_SP, SPOFS_TMPLO); - emit_tai(as, PPCI_STW, hibias, RID_SP, SPOFS_TMPHI); - emit_asi(as, PPCI_XORIS, RID_TMP, dest, 0x8000); - emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO); - emit_lsptr(as, PPCI_LFS, (fbias & 31), - (void *)lj_ir_k64_find(as->J, U64x(59800004,59800000)), - RSET_GPR); - emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); - emit_fb(as, PPCI_FCTIWZ, tmp, left); -} - -static void asm_tobit(ASMState *as, IRIns *ir) -{ - RegSet allow = RSET_FPR; - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg left = ra_alloc1(as, ir->op1, allow); - Reg right = ra_alloc1(as, ir->op2, rset_clear(allow, left)); - Reg tmp = ra_scratch(as, rset_clear(allow, right)); - emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO); - emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); - emit_fab(as, PPCI_FADD, tmp, left, right); -} - -static void asm_conv(ASMState *as, IRIns *ir) -{ - IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); - int stfp = (st == IRT_NUM || st == IRT_FLOAT); - IRRef lref = ir->op1; - lua_assert(irt_type(ir->t) != st); - lua_assert(!(irt_isint64(ir->t) || - (st == IRT_I64 || st == IRT_U64))); /* Handled by SPLIT. */ - if (irt_isfp(ir->t)) { - Reg dest = ra_dest(as, ir, RSET_FPR); - if (stfp) { /* FP to FP conversion. */ - if (st == IRT_NUM) /* double -> float conversion. */ - emit_fb(as, PPCI_FRSP, dest, ra_alloc1(as, lref, RSET_FPR)); - else /* float -> double conversion is a no-op on PPC. */ - ra_leftov(as, dest, lref); /* Do nothing, but may need to move regs. */ - } else { /* Integer to FP conversion. */ - /* IRT_INT: Flip hibit, bias with 2^52, subtract 2^52+2^31. */ - /* IRT_U32: Bias with 2^52, subtract 2^52. */ - RegSet allow = RSET_GPR; - Reg left = ra_alloc1(as, lref, allow); - Reg hibias = ra_allock(as, 0x43300000, rset_clear(allow, left)); - Reg fbias = ra_scratch(as, rset_exclude(RSET_FPR, dest)); - const float *kbias; - if (irt_isfloat(ir->t)) emit_fb(as, PPCI_FRSP, dest, dest); - emit_fab(as, PPCI_FSUB, dest, dest, fbias); - emit_fai(as, PPCI_LFD, dest, RID_SP, SPOFS_TMP); - kbias = (const float *)lj_ir_k64_find(as->J, U64x(59800004,59800000)); - if (st == IRT_U32) kbias++; - emit_lsptr(as, PPCI_LFS, (fbias & 31), (void *)kbias, - rset_clear(allow, hibias)); - emit_tai(as, PPCI_STW, st == IRT_U32 ? left : RID_TMP, - RID_SP, SPOFS_TMPLO); - emit_tai(as, PPCI_STW, hibias, RID_SP, SPOFS_TMPHI); - if (st != IRT_U32) emit_asi(as, PPCI_XORIS, RID_TMP, left, 0x8000); - } - } else if (stfp) { /* FP to integer conversion. */ - if (irt_isguard(ir->t)) { - /* Checked conversions are only supported from number to int. */ - lua_assert(irt_isint(ir->t) && st == IRT_NUM); - asm_tointg(as, ir, ra_alloc1(as, lref, RSET_FPR)); - } else { - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg left = ra_alloc1(as, lref, RSET_FPR); - Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); - if (irt_isu32(ir->t)) { - /* Convert both x and x-2^31 to int and merge results. */ - Reg tmpi = ra_scratch(as, rset_exclude(RSET_GPR, dest)); - emit_asb(as, PPCI_OR, dest, dest, tmpi); /* Select with mask idiom. */ - emit_asb(as, PPCI_AND, tmpi, tmpi, RID_TMP); - emit_asb(as, PPCI_ANDC, dest, dest, RID_TMP); - emit_tai(as, PPCI_LWZ, tmpi, RID_SP, SPOFS_TMPLO); /* tmp = (int)(x) */ - emit_tai(as, PPCI_ADDIS, dest, dest, 0x8000); /* dest += 2^31 */ - emit_asb(as, PPCI_SRAWI, RID_TMP, dest, 31); /* mask = -(dest < 0) */ - emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); - emit_tai(as, PPCI_LWZ, dest, - RID_SP, SPOFS_TMPLO); /* dest = (int)(x-2^31) */ - emit_fb(as, PPCI_FCTIWZ, tmp, left); - emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); - emit_fb(as, PPCI_FCTIWZ, tmp, tmp); - emit_fab(as, PPCI_FSUB, tmp, left, tmp); - emit_lsptr(as, PPCI_LFS, (tmp & 31), - (void *)lj_ir_k64_find(as->J, U64x(4f000000,00000000)), - RSET_GPR); - } else { - emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO); - emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); - emit_fb(as, PPCI_FCTIWZ, tmp, left); - } - } - } else { - Reg dest = ra_dest(as, ir, RSET_GPR); - if (st >= IRT_I8 && st <= IRT_U16) { /* Extend to 32 bit integer. */ - Reg left = ra_alloc1(as, ir->op1, RSET_GPR); - lua_assert(irt_isint(ir->t) || irt_isu32(ir->t)); - if ((ir->op2 & IRCONV_SEXT)) - emit_as(as, st == IRT_I8 ? PPCI_EXTSB : PPCI_EXTSH, dest, left); - else - emit_rot(as, PPCI_RLWINM, dest, left, 0, st == IRT_U8 ? 24 : 16, 31); - } else { /* 32/64 bit integer conversions. */ - /* Only need to handle 32/32 bit no-op (cast) on 32 bit archs. */ - ra_leftov(as, dest, lref); /* Do nothing, but may need to move regs. */ - } - } -} - -#if LJ_HASFFI -static void asm_conv64(ASMState *as, IRIns *ir) -{ - IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK); - IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH); - IRCallID id; - const CCallInfo *ci; - IRRef args[2]; - args[0] = ir->op1; - args[1] = (ir-1)->op1; - if (st == IRT_NUM || st == IRT_FLOAT) { - id = IRCALL_fp64_d2l + ((st == IRT_FLOAT) ? 2 : 0) + (dt - IRT_I64); - ir--; - } else { - id = IRCALL_fp64_l2d + ((dt == IRT_FLOAT) ? 2 : 0) + (st - IRT_I64); - } - ci = &lj_ir_callinfo[id]; - asm_setupresult(as, ir, ci); - asm_gencall(as, ci, args); -} -#endif - -static void asm_strto(ASMState *as, IRIns *ir) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_strscan_num]; - IRRef args[2]; - int32_t ofs; - RegSet drop = RSET_SCRATCH; - if (ra_hasreg(ir->r)) rset_set(drop, ir->r); /* Spill dest reg (if any). */ - ra_evictset(as, drop); - asm_guardcc(as, CC_EQ); - emit_ai(as, PPCI_CMPWI, RID_RET, 0); /* Test return status. */ - args[0] = ir->op1; /* GCstr *str */ - args[1] = ASMREF_TMP1; /* TValue *n */ - asm_gencall(as, ci, args); - /* Store the result to the spill slot or temp slots. */ - ofs = ir->s ? sps_scale(ir->s) : SPOFS_TMP; - emit_tai(as, PPCI_ADDI, ra_releasetmp(as, ASMREF_TMP1), RID_SP, ofs); -} - -/* Get pointer to TValue. */ -static void asm_tvptr(ASMState *as, Reg dest, IRRef ref) -{ - IRIns *ir = IR(ref); - if (irt_isnum(ir->t)) { - if (irref_isk(ref)) /* Use the number constant itself as a TValue. */ - ra_allockreg(as, i32ptr(ir_knum(ir)), dest); - else /* Otherwise force a spill and use the spill slot. */ - emit_tai(as, PPCI_ADDI, dest, RID_SP, ra_spill(as, ir)); - } else { - /* Otherwise use g->tmptv to hold the TValue. */ - RegSet allow = rset_exclude(RSET_GPR, dest); - Reg type; - emit_tai(as, PPCI_ADDI, dest, RID_JGL, offsetof(global_State, tmptv)-32768); - if (!irt_ispri(ir->t)) { - Reg src = ra_alloc1(as, ref, allow); - emit_setgl(as, src, tmptv.gcr); - } - type = ra_allock(as, irt_toitype(ir->t), allow); - emit_setgl(as, type, tmptv.it); - } -} - -static void asm_tostr(ASMState *as, IRIns *ir) -{ - IRRef args[2]; - args[0] = ASMREF_L; - as->gcsteps++; - if (irt_isnum(IR(ir->op1)->t) || (ir+1)->o == IR_HIOP) { - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromnum]; - args[1] = ASMREF_TMP1; /* const lua_Number * */ - asm_setupresult(as, ir, ci); /* GCstr * */ - asm_gencall(as, ci, args); - asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op1); - } else { - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromint]; - args[1] = ir->op1; /* int32_t k */ - asm_setupresult(as, ir, ci); /* GCstr * */ - asm_gencall(as, ci, args); - } -} - -/* -- Memory references --------------------------------------------------- */ - -static void asm_aref(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg idx, base; - if (irref_isk(ir->op2)) { - IRRef tab = IR(ir->op1)->op1; - int32_t ofs = asm_fuseabase(as, tab); - IRRef refa = ofs ? tab : ir->op1; - ofs += 8*IR(ir->op2)->i; - if (checki16(ofs)) { - base = ra_alloc1(as, refa, RSET_GPR); - emit_tai(as, PPCI_ADDI, dest, base, ofs); - return; - } - } - base = ra_alloc1(as, ir->op1, RSET_GPR); - idx = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, base)); - emit_tab(as, PPCI_ADD, dest, RID_TMP, base); - emit_slwi(as, RID_TMP, idx, 3); -} - -/* Inlined hash lookup. Specialized for key type and for const keys. -** The equivalent C code is: -** Node *n = hashkey(t, key); -** do { -** if (lj_obj_equal(&n->key, key)) return &n->val; -** } while ((n = nextnode(n))); -** return niltv(L); -*/ -static void asm_href(ASMState *as, IRIns *ir, IROp merge) -{ - RegSet allow = RSET_GPR; - int destused = ra_used(ir); - Reg dest = ra_dest(as, ir, allow); - Reg tab = ra_alloc1(as, ir->op1, rset_clear(allow, dest)); - Reg key = RID_NONE, tmp1 = RID_TMP, tmp2; - Reg tisnum = RID_NONE, tmpnum = RID_NONE; - IRRef refkey = ir->op2; - IRIns *irkey = IR(refkey); - IRType1 kt = irkey->t; - uint32_t khash; - MCLabel l_end, l_loop, l_next; - - rset_clear(allow, tab); - if (irt_isnum(kt)) { - key = ra_alloc1(as, refkey, RSET_FPR); - tmpnum = ra_scratch(as, rset_exclude(RSET_FPR, key)); - tisnum = ra_allock(as, (int32_t)LJ_TISNUM, allow); - rset_clear(allow, tisnum); - } else if (!irt_ispri(kt)) { - key = ra_alloc1(as, refkey, allow); - rset_clear(allow, key); - } - tmp2 = ra_scratch(as, allow); - rset_clear(allow, tmp2); - - /* Key not found in chain: jump to exit (if merged) or load niltv. */ - l_end = emit_label(as); - as->invmcp = NULL; - if (merge == IR_NE) - asm_guardcc(as, CC_EQ); - else if (destused) - emit_loada(as, dest, niltvg(J2G(as->J))); - - /* Follow hash chain until the end. */ - l_loop = --as->mcp; - emit_ai(as, PPCI_CMPWI, dest, 0); - emit_tai(as, PPCI_LWZ, dest, dest, (int32_t)offsetof(Node, next)); - l_next = emit_label(as); - - /* Type and value comparison. */ - if (merge == IR_EQ) - asm_guardcc(as, CC_EQ); - else - emit_condbranch(as, PPCI_BC|PPCF_Y, CC_EQ, l_end); - if (irt_isnum(kt)) { - emit_fab(as, PPCI_FCMPU, 0, tmpnum, key); - emit_condbranch(as, PPCI_BC, CC_GE, l_next); - emit_ab(as, PPCI_CMPLW, tmp1, tisnum); - emit_fai(as, PPCI_LFD, tmpnum, dest, (int32_t)offsetof(Node, key.n)); - } else { - if (!irt_ispri(kt)) { - emit_ab(as, PPCI_CMPW, tmp2, key); - emit_condbranch(as, PPCI_BC, CC_NE, l_next); - } - emit_ai(as, PPCI_CMPWI, tmp1, irt_toitype(irkey->t)); - if (!irt_ispri(kt)) - emit_tai(as, PPCI_LWZ, tmp2, dest, (int32_t)offsetof(Node, key.gcr)); - } - emit_tai(as, PPCI_LWZ, tmp1, dest, (int32_t)offsetof(Node, key.it)); - *l_loop = PPCI_BC | PPCF_Y | PPCF_CC(CC_NE) | - (((char *)as->mcp-(char *)l_loop) & 0xffffu); - - /* Load main position relative to tab->node into dest. */ - khash = irref_isk(refkey) ? ir_khash(irkey) : 1; - if (khash == 0) { - emit_tai(as, PPCI_LWZ, dest, tab, (int32_t)offsetof(GCtab, node)); - } else { - Reg tmphash = tmp1; - if (irref_isk(refkey)) - tmphash = ra_allock(as, khash, allow); - emit_tab(as, PPCI_ADD, dest, dest, tmp1); - emit_tai(as, PPCI_MULLI, tmp1, tmp1, sizeof(Node)); - emit_asb(as, PPCI_AND, tmp1, tmp2, tmphash); - emit_tai(as, PPCI_LWZ, dest, tab, (int32_t)offsetof(GCtab, node)); - emit_tai(as, PPCI_LWZ, tmp2, tab, (int32_t)offsetof(GCtab, hmask)); - if (irref_isk(refkey)) { - /* Nothing to do. */ - } else if (irt_isstr(kt)) { - emit_tai(as, PPCI_LWZ, tmp1, key, (int32_t)offsetof(GCstr, hash)); - } else { /* Must match with hash*() in lj_tab.c. */ - emit_tab(as, PPCI_SUBF, tmp1, tmp2, tmp1); - emit_rotlwi(as, tmp2, tmp2, HASH_ROT3); - emit_asb(as, PPCI_XOR, tmp1, tmp1, tmp2); - emit_rotlwi(as, tmp1, tmp1, (HASH_ROT2+HASH_ROT1)&31); - emit_tab(as, PPCI_SUBF, tmp2, dest, tmp2); - if (irt_isnum(kt)) { - int32_t ofs = ra_spill(as, irkey); - emit_asb(as, PPCI_XOR, tmp2, tmp2, tmp1); - emit_rotlwi(as, dest, tmp1, HASH_ROT1); - emit_tab(as, PPCI_ADD, tmp1, tmp1, tmp1); - emit_tai(as, PPCI_LWZ, tmp2, RID_SP, ofs+4); - emit_tai(as, PPCI_LWZ, tmp1, RID_SP, ofs); - } else { - emit_asb(as, PPCI_XOR, tmp2, key, tmp1); - emit_rotlwi(as, dest, tmp1, HASH_ROT1); - emit_tai(as, PPCI_ADDI, tmp1, tmp2, HASH_BIAS); - emit_tai(as, PPCI_ADDIS, tmp2, key, (HASH_BIAS + 32768)>>16); - } - } - } -} - -static void asm_hrefk(ASMState *as, IRIns *ir) -{ - IRIns *kslot = IR(ir->op2); - IRIns *irkey = IR(kslot->op1); - int32_t ofs = (int32_t)(kslot->op2 * sizeof(Node)); - int32_t kofs = ofs + (int32_t)offsetof(Node, key); - Reg dest = (ra_used(ir)||ofs > 32736) ? ra_dest(as, ir, RSET_GPR) : RID_NONE; - Reg node = ra_alloc1(as, ir->op1, RSET_GPR); - Reg key = RID_NONE, type = RID_TMP, idx = node; - RegSet allow = rset_exclude(RSET_GPR, node); - lua_assert(ofs % sizeof(Node) == 0); - if (ofs > 32736) { - idx = dest; - rset_clear(allow, dest); - kofs = (int32_t)offsetof(Node, key); - } else if (ra_hasreg(dest)) { - emit_tai(as, PPCI_ADDI, dest, node, ofs); - } - asm_guardcc(as, CC_NE); - if (!irt_ispri(irkey->t)) { - key = ra_scratch(as, allow); - rset_clear(allow, key); - } - rset_clear(allow, type); - if (irt_isnum(irkey->t)) { - emit_cmpi(as, key, (int32_t)ir_knum(irkey)->u32.lo); - asm_guardcc(as, CC_NE); - emit_cmpi(as, type, (int32_t)ir_knum(irkey)->u32.hi); - } else { - if (ra_hasreg(key)) { - emit_cmpi(as, key, irkey->i); /* May use RID_TMP, i.e. type. */ - asm_guardcc(as, CC_NE); - } - emit_ai(as, PPCI_CMPWI, type, irt_toitype(irkey->t)); - } - if (ra_hasreg(key)) emit_tai(as, PPCI_LWZ, key, idx, kofs+4); - emit_tai(as, PPCI_LWZ, type, idx, kofs); - if (ofs > 32736) { - emit_tai(as, PPCI_ADDIS, dest, dest, (ofs + 32768) >> 16); - emit_tai(as, PPCI_ADDI, dest, node, ofs); - } -} - -static void asm_newref(ASMState *as, IRIns *ir) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_newkey]; - IRRef args[3]; - if (ir->r == RID_SINK) - return; - args[0] = ASMREF_L; /* lua_State *L */ - args[1] = ir->op1; /* GCtab *t */ - args[2] = ASMREF_TMP1; /* cTValue *key */ - asm_setupresult(as, ir, ci); /* TValue * */ - asm_gencall(as, ci, args); - asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op2); -} - -static void asm_uref(ASMState *as, IRIns *ir) -{ - /* NYI: Check that UREFO is still open and not aliasing a slot. */ - Reg dest = ra_dest(as, ir, RSET_GPR); - if (irref_isk(ir->op1)) { - GCfunc *fn = ir_kfunc(IR(ir->op1)); - MRef *v = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.v; - emit_lsptr(as, PPCI_LWZ, dest, v, RSET_GPR); - } else { - Reg uv = ra_scratch(as, RSET_GPR); - Reg func = ra_alloc1(as, ir->op1, RSET_GPR); - if (ir->o == IR_UREFC) { - asm_guardcc(as, CC_NE); - emit_ai(as, PPCI_CMPWI, RID_TMP, 1); - emit_tai(as, PPCI_ADDI, dest, uv, (int32_t)offsetof(GCupval, tv)); - emit_tai(as, PPCI_LBZ, RID_TMP, uv, (int32_t)offsetof(GCupval, closed)); - } else { - emit_tai(as, PPCI_LWZ, dest, uv, (int32_t)offsetof(GCupval, v)); - } - emit_tai(as, PPCI_LWZ, uv, func, - (int32_t)offsetof(GCfuncL, uvptr) + 4*(int32_t)(ir->op2 >> 8)); - } -} - -static void asm_fref(ASMState *as, IRIns *ir) -{ - UNUSED(as); UNUSED(ir); - lua_assert(!ra_used(ir)); -} - -static void asm_strref(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - IRRef ref = ir->op2, refk = ir->op1; - int32_t ofs = (int32_t)sizeof(GCstr); - Reg r; - if (irref_isk(ref)) { - IRRef tmp = refk; refk = ref; ref = tmp; - } else if (!irref_isk(refk)) { - Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); - IRIns *irr = IR(ir->op2); - if (ra_hasreg(irr->r)) { - ra_noweak(as, irr->r); - right = irr->r; - } else if (mayfuse(as, irr->op2) && - irr->o == IR_ADD && irref_isk(irr->op2) && - checki16(ofs + IR(irr->op2)->i)) { - ofs += IR(irr->op2)->i; - right = ra_alloc1(as, irr->op1, rset_exclude(RSET_GPR, left)); - } else { - right = ra_allocref(as, ir->op2, rset_exclude(RSET_GPR, left)); - } - emit_tai(as, PPCI_ADDI, dest, dest, ofs); - emit_tab(as, PPCI_ADD, dest, left, right); - return; - } - r = ra_alloc1(as, ref, RSET_GPR); - ofs += IR(refk)->i; - if (checki16(ofs)) - emit_tai(as, PPCI_ADDI, dest, r, ofs); - else - emit_tab(as, PPCI_ADD, dest, r, - ra_allock(as, ofs, rset_exclude(RSET_GPR, r))); -} - -/* -- Loads and stores ---------------------------------------------------- */ - -static PPCIns asm_fxloadins(IRIns *ir) -{ - switch (irt_type(ir->t)) { - case IRT_I8: return PPCI_LBZ; /* Needs sign-extension. */ - case IRT_U8: return PPCI_LBZ; - case IRT_I16: return PPCI_LHA; - case IRT_U16: return PPCI_LHZ; - case IRT_NUM: return PPCI_LFD; - case IRT_FLOAT: return PPCI_LFS; - default: return PPCI_LWZ; - } -} - -static PPCIns asm_fxstoreins(IRIns *ir) -{ - switch (irt_type(ir->t)) { - case IRT_I8: case IRT_U8: return PPCI_STB; - case IRT_I16: case IRT_U16: return PPCI_STH; - case IRT_NUM: return PPCI_STFD; - case IRT_FLOAT: return PPCI_STFS; - default: return PPCI_STW; - } -} - -static void asm_fload(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg idx = ra_alloc1(as, ir->op1, RSET_GPR); - PPCIns pi = asm_fxloadins(ir); - int32_t ofs; - if (ir->op2 == IRFL_TAB_ARRAY) { - ofs = asm_fuseabase(as, ir->op1); - if (ofs) { /* Turn the t->array load into an add for colocated arrays. */ - emit_tai(as, PPCI_ADDI, dest, idx, ofs); - return; - } - } - ofs = field_ofs[ir->op2]; - lua_assert(!irt_isi8(ir->t)); - emit_tai(as, pi, dest, idx, ofs); -} - -static void asm_fstore(ASMState *as, IRIns *ir) -{ - if (ir->r != RID_SINK) { - Reg src = ra_alloc1(as, ir->op2, RSET_GPR); - IRIns *irf = IR(ir->op1); - Reg idx = ra_alloc1(as, irf->op1, rset_exclude(RSET_GPR, src)); - int32_t ofs = field_ofs[irf->op2]; - PPCIns pi = asm_fxstoreins(ir); - emit_tai(as, pi, src, idx, ofs); - } -} - -static void asm_xload(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); - lua_assert(!(ir->op2 & IRXLOAD_UNALIGNED)); - if (irt_isi8(ir->t)) - emit_as(as, PPCI_EXTSB, dest, dest); - asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR, 0); -} - -static void asm_xstore(ASMState *as, IRIns *ir, int32_t ofs) -{ - IRIns *irb; - if (ir->r == RID_SINK) - return; - if (ofs == 0 && mayfuse(as, ir->op2) && (irb = IR(ir->op2))->o == IR_BSWAP && - ra_noreg(irb->r) && (irt_isint(ir->t) || irt_isu32(ir->t))) { - /* Fuse BSWAP with XSTORE to stwbrx. */ - Reg src = ra_alloc1(as, irb->op1, RSET_GPR); - asm_fusexrefx(as, PPCI_STWBRX, src, ir->op1, rset_exclude(RSET_GPR, src)); - } else { - Reg src = ra_alloc1(as, ir->op2, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); - asm_fusexref(as, asm_fxstoreins(ir), src, ir->op1, - rset_exclude(RSET_GPR, src), ofs); - } -} - -static void asm_ahuvload(ASMState *as, IRIns *ir) -{ - IRType1 t = ir->t; - Reg dest = RID_NONE, type = RID_TMP, tmp = RID_TMP, idx; - RegSet allow = RSET_GPR; - int32_t ofs = AHUREF_LSX; - if (ra_used(ir)) { - lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); - if (!irt_isnum(t)) ofs = 0; - dest = ra_dest(as, ir, irt_isnum(t) ? RSET_FPR : RSET_GPR); - rset_clear(allow, dest); - } - idx = asm_fuseahuref(as, ir->op1, &ofs, allow); - if (irt_isnum(t)) { - Reg tisnum = ra_allock(as, (int32_t)LJ_TISNUM, rset_exclude(allow, idx)); - asm_guardcc(as, CC_GE); - emit_ab(as, PPCI_CMPLW, type, tisnum); - if (ra_hasreg(dest)) { - if (ofs == AHUREF_LSX) { - tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, - (idx&255)), (idx>>8))); - emit_fab(as, PPCI_LFDX, dest, (idx&255), tmp); - } else { - emit_fai(as, PPCI_LFD, dest, idx, ofs); - } - } - } else { - asm_guardcc(as, CC_NE); - emit_ai(as, PPCI_CMPWI, type, irt_toitype(t)); - if (ra_hasreg(dest)) emit_tai(as, PPCI_LWZ, dest, idx, ofs+4); - } - if (ofs == AHUREF_LSX) { - emit_tab(as, PPCI_LWZX, type, (idx&255), tmp); - emit_slwi(as, tmp, (idx>>8), 3); - } else { - emit_tai(as, PPCI_LWZ, type, idx, ofs); - } -} - -static void asm_ahustore(ASMState *as, IRIns *ir) -{ - RegSet allow = RSET_GPR; - Reg idx, src = RID_NONE, type = RID_NONE; - int32_t ofs = AHUREF_LSX; - if (ir->r == RID_SINK) - return; - if (irt_isnum(ir->t)) { - src = ra_alloc1(as, ir->op2, RSET_FPR); - } else { - if (!irt_ispri(ir->t)) { - src = ra_alloc1(as, ir->op2, allow); - rset_clear(allow, src); - ofs = 0; - } - type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); - rset_clear(allow, type); - } - idx = asm_fuseahuref(as, ir->op1, &ofs, allow); - if (irt_isnum(ir->t)) { - if (ofs == AHUREF_LSX) { - emit_fab(as, PPCI_STFDX, src, (idx&255), RID_TMP); - emit_slwi(as, RID_TMP, (idx>>8), 3); - } else { - emit_fai(as, PPCI_STFD, src, idx, ofs); - } - } else { - if (ra_hasreg(src)) - emit_tai(as, PPCI_STW, src, idx, ofs+4); - if (ofs == AHUREF_LSX) { - emit_tab(as, PPCI_STWX, type, (idx&255), RID_TMP); - emit_slwi(as, RID_TMP, (idx>>8), 3); - } else { - emit_tai(as, PPCI_STW, type, idx, ofs); - } - } -} - -static void asm_sload(ASMState *as, IRIns *ir) -{ - int32_t ofs = 8*((int32_t)ir->op1-1) + ((ir->op2 & IRSLOAD_FRAME) ? 0 : 4); - IRType1 t = ir->t; - Reg dest = RID_NONE, type = RID_NONE, base; - RegSet allow = RSET_GPR; - lua_assert(!(ir->op2 & IRSLOAD_PARENT)); /* Handled by asm_head_side(). */ - lua_assert(irt_isguard(t) || !(ir->op2 & IRSLOAD_TYPECHECK)); - lua_assert(LJ_DUALNUM || - !irt_isint(t) || (ir->op2 & (IRSLOAD_CONVERT|IRSLOAD_FRAME))); - if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(t) && irt_isint(t)) { - dest = ra_scratch(as, RSET_FPR); - asm_tointg(as, ir, dest); - t.irt = IRT_NUM; /* Continue with a regular number type check. */ - } else if (ra_used(ir)) { - lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); - dest = ra_dest(as, ir, irt_isnum(t) ? RSET_FPR : RSET_GPR); - rset_clear(allow, dest); - base = ra_alloc1(as, REF_BASE, allow); - rset_clear(allow, base); - if ((ir->op2 & IRSLOAD_CONVERT)) { - if (irt_isint(t)) { - emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO); - dest = ra_scratch(as, RSET_FPR); - emit_fai(as, PPCI_STFD, dest, RID_SP, SPOFS_TMP); - emit_fb(as, PPCI_FCTIWZ, dest, dest); - t.irt = IRT_NUM; /* Check for original type. */ - } else { - Reg tmp = ra_scratch(as, allow); - Reg hibias = ra_allock(as, 0x43300000, rset_clear(allow, tmp)); - Reg fbias = ra_scratch(as, rset_exclude(RSET_FPR, dest)); - emit_fab(as, PPCI_FSUB, dest, dest, fbias); - emit_fai(as, PPCI_LFD, dest, RID_SP, SPOFS_TMP); - emit_lsptr(as, PPCI_LFS, (fbias & 31), - (void *)lj_ir_k64_find(as->J, U64x(59800004,59800000)), - rset_clear(allow, hibias)); - emit_tai(as, PPCI_STW, tmp, RID_SP, SPOFS_TMPLO); - emit_tai(as, PPCI_STW, hibias, RID_SP, SPOFS_TMPHI); - emit_asi(as, PPCI_XORIS, tmp, tmp, 0x8000); - dest = tmp; - t.irt = IRT_INT; /* Check for original type. */ - } - } - goto dotypecheck; - } - base = ra_alloc1(as, REF_BASE, allow); - rset_clear(allow, base); -dotypecheck: - if (irt_isnum(t)) { - if ((ir->op2 & IRSLOAD_TYPECHECK)) { - Reg tisnum = ra_allock(as, (int32_t)LJ_TISNUM, allow); - asm_guardcc(as, CC_GE); - emit_ab(as, PPCI_CMPLW, RID_TMP, tisnum); - type = RID_TMP; - } - if (ra_hasreg(dest)) emit_fai(as, PPCI_LFD, dest, base, ofs-4); - } else { - if ((ir->op2 & IRSLOAD_TYPECHECK)) { - asm_guardcc(as, CC_NE); - emit_ai(as, PPCI_CMPWI, RID_TMP, irt_toitype(t)); - type = RID_TMP; - } - if (ra_hasreg(dest)) emit_tai(as, PPCI_LWZ, dest, base, ofs); - } - if (ra_hasreg(type)) emit_tai(as, PPCI_LWZ, type, base, ofs-4); -} - -/* -- Allocations --------------------------------------------------------- */ - -#if LJ_HASFFI -static void asm_cnew(ASMState *as, IRIns *ir) -{ - CTState *cts = ctype_ctsG(J2G(as->J)); - CTypeID ctypeid = (CTypeID)IR(ir->op1)->i; - CTSize sz = (ir->o == IR_CNEWI || ir->op2 == REF_NIL) ? - lj_ctype_size(cts, ctypeid) : (CTSize)IR(ir->op2)->i; - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco]; - IRRef args[2]; - RegSet allow = (RSET_GPR & ~RSET_SCRATCH); - RegSet drop = RSET_SCRATCH; - lua_assert(sz != CTSIZE_INVALID); - - args[0] = ASMREF_L; /* lua_State *L */ - args[1] = ASMREF_TMP1; /* MSize size */ - as->gcsteps++; - - if (ra_hasreg(ir->r)) - rset_clear(drop, ir->r); /* Dest reg handled below. */ - ra_evictset(as, drop); - if (ra_used(ir)) - ra_destreg(as, ir, RID_RET); /* GCcdata * */ - - /* Initialize immutable cdata object. */ - if (ir->o == IR_CNEWI) { - int32_t ofs = sizeof(GCcdata); - lua_assert(sz == 4 || sz == 8); - if (sz == 8) { - ofs += 4; - lua_assert((ir+1)->o == IR_HIOP); - } - for (;;) { - Reg r = ra_alloc1(as, ir->op2, allow); - emit_tai(as, PPCI_STW, r, RID_RET, ofs); - rset_clear(allow, r); - if (ofs == sizeof(GCcdata)) break; - ofs -= 4; ir++; - } - } - /* Initialize gct and ctypeid. lj_mem_newgco() already sets marked. */ - emit_tai(as, PPCI_STB, RID_RET+1, RID_RET, offsetof(GCcdata, gct)); - emit_tai(as, PPCI_STH, RID_TMP, RID_RET, offsetof(GCcdata, ctypeid)); - emit_ti(as, PPCI_LI, RID_RET+1, ~LJ_TCDATA); - emit_ti(as, PPCI_LI, RID_TMP, ctypeid); /* Lower 16 bit used. Sign-ext ok. */ - asm_gencall(as, ci, args); - ra_allockreg(as, (int32_t)(sz+sizeof(GCcdata)), - ra_releasetmp(as, ASMREF_TMP1)); -} -#else -#define asm_cnew(as, ir) ((void)0) -#endif - -/* -- Write barriers ------------------------------------------------------ */ - -static void asm_tbar(ASMState *as, IRIns *ir) -{ - Reg tab = ra_alloc1(as, ir->op1, RSET_GPR); - Reg mark = ra_scratch(as, rset_exclude(RSET_GPR, tab)); - Reg link = RID_TMP; - MCLabel l_end = emit_label(as); - emit_tai(as, PPCI_STW, link, tab, (int32_t)offsetof(GCtab, gclist)); - emit_tai(as, PPCI_STB, mark, tab, (int32_t)offsetof(GCtab, marked)); - emit_setgl(as, tab, gc.grayagain); - lua_assert(LJ_GC_BLACK == 0x04); - emit_rot(as, PPCI_RLWINM, mark, mark, 0, 30, 28); /* Clear black bit. */ - emit_getgl(as, link, gc.grayagain); - emit_condbranch(as, PPCI_BC|PPCF_Y, CC_EQ, l_end); - emit_asi(as, PPCI_ANDIDOT, RID_TMP, mark, LJ_GC_BLACK); - emit_tai(as, PPCI_LBZ, mark, tab, (int32_t)offsetof(GCtab, marked)); -} - -static void asm_obar(ASMState *as, IRIns *ir) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_barrieruv]; - IRRef args[2]; - MCLabel l_end; - Reg obj, val, tmp; - /* No need for other object barriers (yet). */ - lua_assert(IR(ir->op1)->o == IR_UREFC); - ra_evictset(as, RSET_SCRATCH); - l_end = emit_label(as); - args[0] = ASMREF_TMP1; /* global_State *g */ - args[1] = ir->op1; /* TValue *tv */ - asm_gencall(as, ci, args); - emit_tai(as, PPCI_ADDI, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768); - obj = IR(ir->op1)->r; - tmp = ra_scratch(as, rset_exclude(RSET_GPR, obj)); - emit_condbranch(as, PPCI_BC|PPCF_Y, CC_EQ, l_end); - emit_asi(as, PPCI_ANDIDOT, tmp, tmp, LJ_GC_BLACK); - emit_condbranch(as, PPCI_BC, CC_EQ, l_end); - emit_asi(as, PPCI_ANDIDOT, RID_TMP, RID_TMP, LJ_GC_WHITES); - val = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, obj)); - emit_tai(as, PPCI_LBZ, tmp, obj, - (int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)); - emit_tai(as, PPCI_LBZ, RID_TMP, val, (int32_t)offsetof(GChead, marked)); -} - -/* -- Arithmetic and logic operations ------------------------------------- */ - -static void asm_fparith(ASMState *as, IRIns *ir, PPCIns pi) -{ - Reg dest = ra_dest(as, ir, RSET_FPR); - Reg right, left = ra_alloc2(as, ir, RSET_FPR); - right = (left >> 8); left &= 255; - if (pi == PPCI_FMUL) - emit_fac(as, pi, dest, left, right); - else - emit_fab(as, pi, dest, left, right); -} - -static void asm_fpunary(ASMState *as, IRIns *ir, PPCIns pi) -{ - Reg dest = ra_dest(as, ir, RSET_FPR); - Reg left = ra_hintalloc(as, ir->op1, dest, RSET_FPR); - emit_fb(as, pi, dest, left); -} - -static int asm_fpjoin_pow(ASMState *as, IRIns *ir) -{ - IRIns *irp = IR(ir->op1); - if (irp == ir-1 && irp->o == IR_MUL && !ra_used(irp)) { - IRIns *irpp = IR(irp->op1); - if (irpp == ir-2 && irpp->o == IR_FPMATH && - irpp->op2 == IRFPM_LOG2 && !ra_used(irpp)) { - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_pow]; - IRRef args[2]; - args[0] = irpp->op1; - args[1] = irp->op2; - asm_setupresult(as, ir, ci); - asm_gencall(as, ci, args); - return 1; - } - } - return 0; -} - -static void asm_add(ASMState *as, IRIns *ir) -{ - if (irt_isnum(ir->t)) { - if (!asm_fusemadd(as, ir, PPCI_FMADD, PPCI_FMADD)) - asm_fparith(as, ir, PPCI_FADD); - } else { - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); - PPCIns pi; - if (irref_isk(ir->op2)) { - int32_t k = IR(ir->op2)->i; - if (checki16(k)) { - pi = PPCI_ADDI; - /* May fail due to spills/restores above, but simplifies the logic. */ - if (as->flagmcp == as->mcp) { - as->flagmcp = NULL; - as->mcp++; - pi = PPCI_ADDICDOT; - } - emit_tai(as, pi, dest, left, k); - return; - } else if ((k & 0xffff) == 0) { - emit_tai(as, PPCI_ADDIS, dest, left, (k >> 16)); - return; - } else if (!as->sectref) { - emit_tai(as, PPCI_ADDIS, dest, dest, (k + 32768) >> 16); - emit_tai(as, PPCI_ADDI, dest, left, k); - return; - } - } - pi = PPCI_ADD; - /* May fail due to spills/restores above, but simplifies the logic. */ - if (as->flagmcp == as->mcp) { - as->flagmcp = NULL; - as->mcp++; - pi |= PPCF_DOT; - } - right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); - emit_tab(as, pi, dest, left, right); - } -} - -static void asm_sub(ASMState *as, IRIns *ir) -{ - if (irt_isnum(ir->t)) { - if (!asm_fusemadd(as, ir, PPCI_FMSUB, PPCI_FNMSUB)) - asm_fparith(as, ir, PPCI_FSUB); - } else { - PPCIns pi = PPCI_SUBF; - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg left, right; - if (irref_isk(ir->op1)) { - int32_t k = IR(ir->op1)->i; - if (checki16(k)) { - right = ra_alloc1(as, ir->op2, RSET_GPR); - emit_tai(as, PPCI_SUBFIC, dest, right, k); - return; - } - } - /* May fail due to spills/restores above, but simplifies the logic. */ - if (as->flagmcp == as->mcp) { - as->flagmcp = NULL; - as->mcp++; - pi |= PPCF_DOT; - } - left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); - right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); - emit_tab(as, pi, dest, right, left); /* Subtract right _from_ left. */ - } -} - -static void asm_mul(ASMState *as, IRIns *ir) -{ - if (irt_isnum(ir->t)) { - asm_fparith(as, ir, PPCI_FMUL); - } else { - PPCIns pi = PPCI_MULLW; - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); - if (irref_isk(ir->op2)) { - int32_t k = IR(ir->op2)->i; - if (checki16(k)) { - emit_tai(as, PPCI_MULLI, dest, left, k); - return; - } - } - /* May fail due to spills/restores above, but simplifies the logic. */ - if (as->flagmcp == as->mcp) { - as->flagmcp = NULL; - as->mcp++; - pi |= PPCF_DOT; - } - right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); - emit_tab(as, pi, dest, left, right); - } -} - -static void asm_neg(ASMState *as, IRIns *ir) -{ - if (irt_isnum(ir->t)) { - asm_fpunary(as, ir, PPCI_FNEG); - } else { - Reg dest, left; - PPCIns pi = PPCI_NEG; - if (as->flagmcp == as->mcp) { - as->flagmcp = NULL; - as->mcp++; - pi |= PPCF_DOT; - } - dest = ra_dest(as, ir, RSET_GPR); - left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); - emit_tab(as, pi, dest, left, 0); - } -} - -static void asm_arithov(ASMState *as, IRIns *ir, PPCIns pi) -{ - Reg dest, left, right; - if (as->flagmcp == as->mcp) { - as->flagmcp = NULL; - as->mcp++; - } - asm_guardcc(as, CC_SO); - dest = ra_dest(as, ir, RSET_GPR); - left = ra_alloc2(as, ir, RSET_GPR); - right = (left >> 8); left &= 255; - if (pi == PPCI_SUBFO) { Reg tmp = left; left = right; right = tmp; } - emit_tab(as, pi|PPCF_DOT, dest, left, right); -} - -#if LJ_HASFFI -static void asm_add64(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); - PPCIns pi = PPCI_ADDE; - if (irref_isk(ir->op2)) { - int32_t k = IR(ir->op2)->i; - if (k == 0) - pi = PPCI_ADDZE; - else if (k == -1) - pi = PPCI_ADDME; - else - goto needright; - right = 0; - } else { - needright: - right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); - } - emit_tab(as, pi, dest, left, right); - ir--; - dest = ra_dest(as, ir, RSET_GPR); - left = ra_alloc1(as, ir->op1, RSET_GPR); - if (irref_isk(ir->op2)) { - int32_t k = IR(ir->op2)->i; - if (checki16(k)) { - emit_tai(as, PPCI_ADDIC, dest, left, k); - return; - } - } - right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); - emit_tab(as, PPCI_ADDC, dest, left, right); -} - -static void asm_sub64(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg left, right = ra_alloc1(as, ir->op2, RSET_GPR); - PPCIns pi = PPCI_SUBFE; - if (irref_isk(ir->op1)) { - int32_t k = IR(ir->op1)->i; - if (k == 0) - pi = PPCI_SUBFZE; - else if (k == -1) - pi = PPCI_SUBFME; - else - goto needleft; - left = 0; - } else { - needleft: - left = ra_alloc1(as, ir->op1, rset_exclude(RSET_GPR, right)); - } - emit_tab(as, pi, dest, right, left); /* Subtract right _from_ left. */ - ir--; - dest = ra_dest(as, ir, RSET_GPR); - right = ra_alloc1(as, ir->op2, RSET_GPR); - if (irref_isk(ir->op1)) { - int32_t k = IR(ir->op1)->i; - if (checki16(k)) { - emit_tai(as, PPCI_SUBFIC, dest, right, k); - return; - } - } - left = ra_alloc1(as, ir->op1, rset_exclude(RSET_GPR, right)); - emit_tab(as, PPCI_SUBFC, dest, right, left); -} - -static void asm_neg64(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg left = ra_alloc1(as, ir->op1, RSET_GPR); - emit_tab(as, PPCI_SUBFZE, dest, left, 0); - ir--; - dest = ra_dest(as, ir, RSET_GPR); - left = ra_alloc1(as, ir->op1, RSET_GPR); - emit_tai(as, PPCI_SUBFIC, dest, left, 0); -} -#endif - -static void asm_bitnot(ASMState *as, IRIns *ir) -{ - Reg dest, left, right; - PPCIns pi = PPCI_NOR; - if (as->flagmcp == as->mcp) { - as->flagmcp = NULL; - as->mcp++; - pi |= PPCF_DOT; - } - dest = ra_dest(as, ir, RSET_GPR); - if (mayfuse(as, ir->op1)) { - IRIns *irl = IR(ir->op1); - if (irl->o == IR_BAND) - pi ^= (PPCI_NOR ^ PPCI_NAND); - else if (irl->o == IR_BXOR) - pi ^= (PPCI_NOR ^ PPCI_EQV); - else if (irl->o != IR_BOR) - goto nofuse; - left = ra_hintalloc(as, irl->op1, dest, RSET_GPR); - right = ra_alloc1(as, irl->op2, rset_exclude(RSET_GPR, left)); - } else { -nofuse: - left = right = ra_hintalloc(as, ir->op1, dest, RSET_GPR); - } - emit_asb(as, pi, dest, left, right); -} - -static void asm_bitswap(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - IRIns *irx; - if (mayfuse(as, ir->op1) && (irx = IR(ir->op1))->o == IR_XLOAD && - ra_noreg(irx->r) && (irt_isint(irx->t) || irt_isu32(irx->t))) { - /* Fuse BSWAP with XLOAD to lwbrx. */ - asm_fusexrefx(as, PPCI_LWBRX, dest, irx->op1, RSET_GPR); - } else { - Reg left = ra_alloc1(as, ir->op1, RSET_GPR); - Reg tmp = dest; - if (tmp == left) { - tmp = RID_TMP; - emit_mr(as, dest, RID_TMP); - } - emit_rot(as, PPCI_RLWIMI, tmp, left, 24, 16, 23); - emit_rot(as, PPCI_RLWIMI, tmp, left, 24, 0, 7); - emit_rotlwi(as, tmp, left, 8); - } -} - -static void asm_bitop(ASMState *as, IRIns *ir, PPCIns pi, PPCIns pik) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); - if (irref_isk(ir->op2)) { - int32_t k = IR(ir->op2)->i; - Reg tmp = left; - if ((checku16(k) || (k & 0xffff) == 0) || (tmp = dest, !as->sectref)) { - if (!checku16(k)) { - emit_asi(as, pik ^ (PPCI_ORI ^ PPCI_ORIS), dest, tmp, (k >> 16)); - if ((k & 0xffff) == 0) return; - } - emit_asi(as, pik, dest, left, k); - return; - } - } - /* May fail due to spills/restores above, but simplifies the logic. */ - if (as->flagmcp == as->mcp) { - as->flagmcp = NULL; - as->mcp++; - pi |= PPCF_DOT; - } - right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); - emit_asb(as, pi, dest, left, right); -} - -/* Fuse BAND with contiguous bitmask and a shift to rlwinm. */ -static void asm_fuseandsh(ASMState *as, PPCIns pi, int32_t mask, IRRef ref) -{ - IRIns *ir; - Reg left; - if (mayfuse(as, ref) && (ir = IR(ref), ra_noreg(ir->r)) && - irref_isk(ir->op2) && ir->o >= IR_BSHL && ir->o <= IR_BROR) { - int32_t sh = (IR(ir->op2)->i & 31); - switch (ir->o) { - case IR_BSHL: - if ((mask & ((1u<>sh))) goto nofuse; - sh = ((32-sh)&31); - break; - case IR_BROL: - break; - default: - goto nofuse; - } - left = ra_alloc1(as, ir->op1, RSET_GPR); - *--as->mcp = pi | PPCF_T(left) | PPCF_B(sh); - return; - } -nofuse: - left = ra_alloc1(as, ref, RSET_GPR); - *--as->mcp = pi | PPCF_T(left); -} - -static void asm_bitand(ASMState *as, IRIns *ir) -{ - Reg dest, left, right; - IRRef lref = ir->op1; - PPCIns dot = 0; - IRRef op2; - if (as->flagmcp == as->mcp) { - as->flagmcp = NULL; - as->mcp++; - dot = PPCF_DOT; - } - dest = ra_dest(as, ir, RSET_GPR); - if (irref_isk(ir->op2)) { - int32_t k = IR(ir->op2)->i; - if (k) { - /* First check for a contiguous bitmask as used by rlwinm. */ - uint32_t s1 = lj_ffs((uint32_t)k); - uint32_t k1 = ((uint32_t)k >> s1); - if ((k1 & (k1+1)) == 0) { - asm_fuseandsh(as, PPCI_RLWINM|dot | PPCF_A(dest) | - PPCF_MB(31-lj_fls((uint32_t)k)) | PPCF_ME(31-s1), - k, lref); - return; - } - if (~(uint32_t)k) { - uint32_t s2 = lj_ffs(~(uint32_t)k); - uint32_t k2 = (~(uint32_t)k >> s2); - if ((k2 & (k2+1)) == 0) { - asm_fuseandsh(as, PPCI_RLWINM|dot | PPCF_A(dest) | - PPCF_MB(32-s2) | PPCF_ME(30-lj_fls(~(uint32_t)k)), - k, lref); - return; - } - } - } - if (checku16(k)) { - left = ra_alloc1(as, lref, RSET_GPR); - emit_asi(as, PPCI_ANDIDOT, dest, left, k); - return; - } else if ((k & 0xffff) == 0) { - left = ra_alloc1(as, lref, RSET_GPR); - emit_asi(as, PPCI_ANDISDOT, dest, left, (k >> 16)); - return; - } - } - op2 = ir->op2; - if (mayfuse(as, op2) && IR(op2)->o == IR_BNOT && ra_noreg(IR(op2)->r)) { - dot ^= (PPCI_AND ^ PPCI_ANDC); - op2 = IR(op2)->op1; - } - left = ra_hintalloc(as, lref, dest, RSET_GPR); - right = ra_alloc1(as, op2, rset_exclude(RSET_GPR, left)); - emit_asb(as, PPCI_AND ^ dot, dest, left, right); -} - -static void asm_bitshift(ASMState *as, IRIns *ir, PPCIns pi, PPCIns pik) -{ - Reg dest, left; - Reg dot = 0; - if (as->flagmcp == as->mcp) { - as->flagmcp = NULL; - as->mcp++; - dot = PPCF_DOT; - } - dest = ra_dest(as, ir, RSET_GPR); - left = ra_alloc1(as, ir->op1, RSET_GPR); - if (irref_isk(ir->op2)) { /* Constant shifts. */ - int32_t shift = (IR(ir->op2)->i & 31); - if (pik == 0) /* SLWI */ - emit_rot(as, PPCI_RLWINM|dot, dest, left, shift, 0, 31-shift); - else if (pik == 1) /* SRWI */ - emit_rot(as, PPCI_RLWINM|dot, dest, left, (32-shift)&31, shift, 31); - else - emit_asb(as, pik|dot, dest, left, shift); - } else { - Reg right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); - emit_asb(as, pi|dot, dest, left, right); - } -} - -static void asm_min_max(ASMState *as, IRIns *ir, int ismax) -{ - if (irt_isnum(ir->t)) { - Reg dest = ra_dest(as, ir, RSET_FPR); - Reg tmp = dest; - Reg right, left = ra_alloc2(as, ir, RSET_FPR); - right = (left >> 8); left &= 255; - if (tmp == left || tmp == right) - tmp = ra_scratch(as, rset_exclude(rset_exclude(rset_exclude(RSET_FPR, - dest), left), right)); - emit_facb(as, PPCI_FSEL, dest, tmp, - ismax ? left : right, ismax ? right : left); - emit_fab(as, PPCI_FSUB, tmp, left, right); - } else { - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg tmp1 = RID_TMP, tmp2 = dest; - Reg right, left = ra_alloc2(as, ir, RSET_GPR); - right = (left >> 8); left &= 255; - if (tmp2 == left || tmp2 == right) - tmp2 = ra_scratch(as, rset_exclude(rset_exclude(rset_exclude(RSET_GPR, - dest), left), right)); - emit_tab(as, PPCI_ADD, dest, tmp2, right); - emit_asb(as, ismax ? PPCI_ANDC : PPCI_AND, tmp2, tmp2, tmp1); - emit_tab(as, PPCI_SUBFE, tmp1, tmp1, tmp1); - emit_tab(as, PPCI_SUBFC, tmp2, tmp2, tmp1); - emit_asi(as, PPCI_XORIS, tmp2, right, 0x8000); - emit_asi(as, PPCI_XORIS, tmp1, left, 0x8000); - } -} - -/* -- Comparisons --------------------------------------------------------- */ - -#define CC_UNSIGNED 0x08 /* Unsigned integer comparison. */ -#define CC_TWO 0x80 /* Check two flags for FP comparison. */ - -/* Map of comparisons to flags. ORDER IR. */ -static const uint8_t asm_compmap[IR_ABC+1] = { - /* op int cc FP cc */ - /* LT */ CC_GE + (CC_GE<<4), - /* GE */ CC_LT + (CC_LE<<4) + CC_TWO, - /* LE */ CC_GT + (CC_GE<<4) + CC_TWO, - /* GT */ CC_LE + (CC_LE<<4), - /* ULT */ CC_GE + CC_UNSIGNED + (CC_GT<<4) + CC_TWO, - /* UGE */ CC_LT + CC_UNSIGNED + (CC_LT<<4), - /* ULE */ CC_GT + CC_UNSIGNED + (CC_GT<<4), - /* UGT */ CC_LE + CC_UNSIGNED + (CC_LT<<4) + CC_TWO, - /* EQ */ CC_NE + (CC_NE<<4), - /* NE */ CC_EQ + (CC_EQ<<4), - /* ABC */ CC_LE + CC_UNSIGNED + (CC_LT<<4) + CC_TWO /* Same as UGT. */ -}; - -static void asm_intcomp_(ASMState *as, IRRef lref, IRRef rref, Reg cr, PPCCC cc) -{ - Reg right, left = ra_alloc1(as, lref, RSET_GPR); - if (irref_isk(rref)) { - int32_t k = IR(rref)->i; - if ((cc & CC_UNSIGNED) == 0) { /* Signed comparison with constant. */ - if (checki16(k)) { - emit_tai(as, PPCI_CMPWI, cr, left, k); - /* Signed comparison with zero and referencing previous ins? */ - if (k == 0 && lref == as->curins-1) - as->flagmcp = as->mcp; /* Allow elimination of the compare. */ - return; - } else if ((cc & 3) == (CC_EQ & 3)) { /* Use CMPLWI for EQ or NE. */ - if (checku16(k)) { - emit_tai(as, PPCI_CMPLWI, cr, left, k); - return; - } else if (!as->sectref && ra_noreg(IR(rref)->r)) { - emit_tai(as, PPCI_CMPLWI, cr, RID_TMP, k); - emit_asi(as, PPCI_XORIS, RID_TMP, left, (k >> 16)); - return; - } - } - } else { /* Unsigned comparison with constant. */ - if (checku16(k)) { - emit_tai(as, PPCI_CMPLWI, cr, left, k); - return; - } - } - } - right = ra_alloc1(as, rref, rset_exclude(RSET_GPR, left)); - emit_tab(as, (cc & CC_UNSIGNED) ? PPCI_CMPLW : PPCI_CMPW, cr, left, right); -} - -static void asm_comp(ASMState *as, IRIns *ir) -{ - PPCCC cc = asm_compmap[ir->o]; - if (irt_isnum(ir->t)) { - Reg right, left = ra_alloc2(as, ir, RSET_FPR); - right = (left >> 8); left &= 255; - asm_guardcc(as, (cc >> 4)); - if ((cc & CC_TWO)) - emit_tab(as, PPCI_CROR, ((cc>>4)&3), ((cc>>4)&3), (CC_EQ&3)); - emit_fab(as, PPCI_FCMPU, 0, left, right); - } else { - IRRef lref = ir->op1, rref = ir->op2; - if (irref_isk(lref) && !irref_isk(rref)) { - /* Swap constants to the right (only for ABC). */ - IRRef tmp = lref; lref = rref; rref = tmp; - if ((cc & 2) == 0) cc ^= 1; /* LT <-> GT, LE <-> GE */ - } - asm_guardcc(as, cc); - asm_intcomp_(as, lref, rref, 0, cc); - } -} - -#if LJ_HASFFI -/* 64 bit integer comparisons. */ -static void asm_comp64(ASMState *as, IRIns *ir) -{ - PPCCC cc = asm_compmap[(ir-1)->o]; - if ((cc&3) == (CC_EQ&3)) { - asm_guardcc(as, cc); - emit_tab(as, (cc&4) ? PPCI_CRAND : PPCI_CROR, - (CC_EQ&3), (CC_EQ&3), 4+(CC_EQ&3)); - } else { - asm_guardcc(as, CC_EQ); - emit_tab(as, PPCI_CROR, (CC_EQ&3), (CC_EQ&3), ((cc^~(cc>>2))&1)); - emit_tab(as, (cc&4) ? PPCI_CRAND : PPCI_CRANDC, - (CC_EQ&3), (CC_EQ&3), 4+(cc&3)); - } - /* Loword comparison sets cr1 and is unsigned, except for equality. */ - asm_intcomp_(as, (ir-1)->op1, (ir-1)->op2, 4, - cc | ((cc&3) == (CC_EQ&3) ? 0 : CC_UNSIGNED)); - /* Hiword comparison sets cr0. */ - asm_intcomp_(as, ir->op1, ir->op2, 0, cc); - as->flagmcp = NULL; /* Doesn't work here. */ -} -#endif - -/* -- Support for 64 bit ops in 32 bit mode ------------------------------- */ - -/* Hiword op of a split 64 bit op. Previous op must be the loword op. */ -static void asm_hiop(ASMState *as, IRIns *ir) -{ -#if LJ_HASFFI - /* HIOP is marked as a store because it needs its own DCE logic. */ - int uselo = ra_used(ir-1), usehi = ra_used(ir); /* Loword/hiword used? */ - if (LJ_UNLIKELY(!(as->flags & JIT_F_OPT_DCE))) uselo = usehi = 1; - if ((ir-1)->o == IR_CONV) { /* Conversions to/from 64 bit. */ - as->curins--; /* Always skip the CONV. */ - if (usehi || uselo) - asm_conv64(as, ir); - return; - } else if ((ir-1)->o <= IR_NE) { /* 64 bit integer comparisons. ORDER IR. */ - as->curins--; /* Always skip the loword comparison. */ - asm_comp64(as, ir); - return; - } else if ((ir-1)->o == IR_XSTORE) { - as->curins--; /* Handle both stores here. */ - if ((ir-1)->r != RID_SINK) { - asm_xstore(as, ir, 0); - asm_xstore(as, ir-1, 4); - } - return; - } - if (!usehi) return; /* Skip unused hiword op for all remaining ops. */ - switch ((ir-1)->o) { - case IR_ADD: as->curins--; asm_add64(as, ir); break; - case IR_SUB: as->curins--; asm_sub64(as, ir); break; - case IR_NEG: as->curins--; asm_neg64(as, ir); break; - case IR_CALLN: - case IR_CALLXS: - if (!uselo) - ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */ - break; - case IR_CNEWI: - /* Nothing to do here. Handled by lo op itself. */ - break; - default: lua_assert(0); break; - } -#else - UNUSED(as); UNUSED(ir); lua_assert(0); /* Unused without FFI. */ -#endif -} - -/* -- Stack handling ------------------------------------------------------ */ - -/* Check Lua stack size for overflow. Use exit handler as fallback. */ -static void asm_stack_check(ASMState *as, BCReg topslot, - IRIns *irp, RegSet allow, ExitNo exitno) -{ - /* Try to get an unused temp. register, otherwise spill/restore RID_RET*. */ - Reg tmp, pbase = irp ? (ra_hasreg(irp->r) ? irp->r : RID_TMP) : RID_BASE; - rset_clear(allow, pbase); - tmp = allow ? rset_pickbot(allow) : - (pbase == RID_RETHI ? RID_RETLO : RID_RETHI); - emit_condbranch(as, PPCI_BC, CC_LT, asm_exitstub_addr(as, exitno)); - if (allow == RSET_EMPTY) /* Restore temp. register. */ - emit_tai(as, PPCI_LWZ, tmp, RID_SP, SPOFS_TMPW); - else - ra_modified(as, tmp); - emit_ai(as, PPCI_CMPLWI, RID_TMP, (int32_t)(8*topslot)); - emit_tab(as, PPCI_SUBF, RID_TMP, pbase, tmp); - emit_tai(as, PPCI_LWZ, tmp, tmp, offsetof(lua_State, maxstack)); - if (pbase == RID_TMP) - emit_getgl(as, RID_TMP, jit_base); - emit_getgl(as, tmp, jit_L); - if (allow == RSET_EMPTY) /* Spill temp. register. */ - emit_tai(as, PPCI_STW, tmp, RID_SP, SPOFS_TMPW); -} - -/* Restore Lua stack from on-trace state. */ -static void asm_stack_restore(ASMState *as, SnapShot *snap) -{ - SnapEntry *map = &as->T->snapmap[snap->mapofs]; - SnapEntry *flinks = &as->T->snapmap[snap_nextofs(as->T, snap)-1]; - MSize n, nent = snap->nent; - /* Store the value of all modified slots to the Lua stack. */ - for (n = 0; n < nent; n++) { - SnapEntry sn = map[n]; - BCReg s = snap_slot(sn); - int32_t ofs = 8*((int32_t)s-1); - IRRef ref = snap_ref(sn); - IRIns *ir = IR(ref); - if ((sn & SNAP_NORESTORE)) - continue; - if (irt_isnum(ir->t)) { - Reg src = ra_alloc1(as, ref, RSET_FPR); - emit_fai(as, PPCI_STFD, src, RID_BASE, ofs); - } else { - Reg type; - RegSet allow = rset_exclude(RSET_GPR, RID_BASE); - lua_assert(irt_ispri(ir->t) || irt_isaddr(ir->t) || irt_isinteger(ir->t)); - if (!irt_ispri(ir->t)) { - Reg src = ra_alloc1(as, ref, allow); - rset_clear(allow, src); - emit_tai(as, PPCI_STW, src, RID_BASE, ofs+4); - } - if ((sn & (SNAP_CONT|SNAP_FRAME))) { - if (s == 0) continue; /* Do not overwrite link to previous frame. */ - type = ra_allock(as, (int32_t)(*flinks--), allow); - } else { - type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); - } - emit_tai(as, PPCI_STW, type, RID_BASE, ofs); - } - checkmclim(as); - } - lua_assert(map + nent == flinks); -} - -/* -- GC handling --------------------------------------------------------- */ - -/* Check GC threshold and do one or more GC steps. */ -static void asm_gc_check(ASMState *as) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_step_jit]; - IRRef args[2]; - MCLabel l_end; - Reg tmp; - ra_evictset(as, RSET_SCRATCH); - l_end = emit_label(as); - /* Exit trace if in GCSatomic or GCSfinalize. Avoids syncing GC objects. */ - asm_guardcc(as, CC_NE); /* Assumes asm_snap_prep() already done. */ - emit_ai(as, PPCI_CMPWI, RID_RET, 0); - args[0] = ASMREF_TMP1; /* global_State *g */ - args[1] = ASMREF_TMP2; /* MSize steps */ - asm_gencall(as, ci, args); - emit_tai(as, PPCI_ADDI, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768); - tmp = ra_releasetmp(as, ASMREF_TMP2); - emit_loadi(as, tmp, as->gcsteps); - /* Jump around GC step if GC total < GC threshold. */ - emit_condbranch(as, PPCI_BC|PPCF_Y, CC_LT, l_end); - emit_ab(as, PPCI_CMPLW, RID_TMP, tmp); - emit_getgl(as, tmp, gc.threshold); - emit_getgl(as, RID_TMP, gc.total); - as->gcsteps = 0; - checkmclim(as); -} - -/* -- Loop handling ------------------------------------------------------- */ - -/* Fixup the loop branch. */ -static void asm_loop_fixup(ASMState *as) -{ - MCode *p = as->mctop; - MCode *target = as->mcp; - if (as->loopinv) { /* Inverted loop branch? */ - /* asm_guardcc already inverted the cond branch and patched the final b. */ - p[-2] = (p[-2] & (0xffff0000u & ~PPCF_Y)) | (((target-p+2) & 0x3fffu) << 2); - } else { - p[-1] = PPCI_B|(((target-p+1)&0x00ffffffu)<<2); - } -} - -/* -- Head of trace ------------------------------------------------------- */ - -/* Coalesce BASE register for a root trace. */ -static void asm_head_root_base(ASMState *as) -{ - IRIns *ir = IR(REF_BASE); - Reg r = ir->r; - if (ra_hasreg(r)) { - ra_free(as, r); - if (rset_test(as->modset, r) || irt_ismarked(ir->t)) - ir->r = RID_INIT; /* No inheritance for modified BASE register. */ - if (r != RID_BASE) - emit_mr(as, r, RID_BASE); - } -} - -/* Coalesce BASE register for a side trace. */ -static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) -{ - IRIns *ir = IR(REF_BASE); - Reg r = ir->r; - if (ra_hasreg(r)) { - ra_free(as, r); - if (rset_test(as->modset, r) || irt_ismarked(ir->t)) - ir->r = RID_INIT; /* No inheritance for modified BASE register. */ - if (irp->r == r) { - rset_clear(allow, r); /* Mark same BASE register as coalesced. */ - } else if (ra_hasreg(irp->r) && rset_test(as->freeset, irp->r)) { - rset_clear(allow, irp->r); - emit_mr(as, r, irp->r); /* Move from coalesced parent reg. */ - } else { - emit_getgl(as, r, jit_base); /* Otherwise reload BASE. */ - } - } - return allow; -} - -/* -- Tail of trace ------------------------------------------------------- */ - -/* Fixup the tail code. */ -static void asm_tail_fixup(ASMState *as, TraceNo lnk) -{ - MCode *p = as->mctop; - MCode *target; - int32_t spadj = as->T->spadjust; - if (spadj == 0) { - *--p = PPCI_NOP; - *--p = PPCI_NOP; - as->mctop = p; - } else { - /* Patch stack adjustment. */ - lua_assert(checki16(CFRAME_SIZE+spadj)); - p[-3] = PPCI_ADDI | PPCF_T(RID_TMP) | PPCF_A(RID_SP) | (CFRAME_SIZE+spadj); - p[-2] = PPCI_STWU | PPCF_T(RID_TMP) | PPCF_A(RID_SP) | spadj; - } - /* Patch exit branch. */ - target = lnk ? traceref(as->J, lnk)->mcode : (MCode *)lj_vm_exit_interp; - p[-1] = PPCI_B|(((target-p+1)&0x00ffffffu)<<2); -} - -/* Prepare tail of code. */ -static void asm_tail_prep(ASMState *as) -{ - MCode *p = as->mctop - 1; /* Leave room for exit branch. */ - if (as->loopref) { - as->invmcp = as->mcp = p; - } else { - as->mcp = p-2; /* Leave room for stack pointer adjustment. */ - as->invmcp = NULL; - } -} - -/* -- Instruction dispatch ------------------------------------------------ */ - -/* Assemble a single instruction. */ -static void asm_ir(ASMState *as, IRIns *ir) -{ - switch ((IROp)ir->o) { - /* Miscellaneous ops. */ - case IR_LOOP: asm_loop(as); break; - case IR_NOP: case IR_XBAR: lua_assert(!ra_used(ir)); break; - case IR_USE: - ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break; - case IR_PHI: asm_phi(as, ir); break; - case IR_HIOP: asm_hiop(as, ir); break; - case IR_GCSTEP: asm_gcstep(as, ir); break; - - /* Guarded assertions. */ - case IR_EQ: case IR_NE: - if ((ir-1)->o == IR_HREF && ir->op1 == as->curins-1) { - as->curins--; - asm_href(as, ir-1, (IROp)ir->o); - break; - } - /* fallthrough */ - case IR_LT: case IR_GE: case IR_LE: case IR_GT: - case IR_ULT: case IR_UGE: case IR_ULE: case IR_UGT: - case IR_ABC: - asm_comp(as, ir); - break; - - case IR_RETF: asm_retf(as, ir); break; - - /* Bit ops. */ - case IR_BNOT: asm_bitnot(as, ir); break; - case IR_BSWAP: asm_bitswap(as, ir); break; - - case IR_BAND: asm_bitand(as, ir); break; - case IR_BOR: asm_bitop(as, ir, PPCI_OR, PPCI_ORI); break; - case IR_BXOR: asm_bitop(as, ir, PPCI_XOR, PPCI_XORI); break; - - case IR_BSHL: asm_bitshift(as, ir, PPCI_SLW, 0); break; - case IR_BSHR: asm_bitshift(as, ir, PPCI_SRW, 1); break; - case IR_BSAR: asm_bitshift(as, ir, PPCI_SRAW, PPCI_SRAWI); break; - case IR_BROL: asm_bitshift(as, ir, PPCI_RLWNM|PPCF_MB(0)|PPCF_ME(31), - PPCI_RLWINM|PPCF_MB(0)|PPCF_ME(31)); break; - case IR_BROR: lua_assert(0); break; - - /* Arithmetic ops. */ - case IR_ADD: asm_add(as, ir); break; - case IR_SUB: asm_sub(as, ir); break; - case IR_MUL: asm_mul(as, ir); break; - case IR_DIV: asm_fparith(as, ir, PPCI_FDIV); break; - case IR_MOD: asm_callid(as, ir, IRCALL_lj_vm_modi); break; - case IR_POW: asm_callid(as, ir, IRCALL_lj_vm_powi); break; - case IR_NEG: asm_neg(as, ir); break; - - case IR_ABS: asm_fpunary(as, ir, PPCI_FABS); break; - case IR_ATAN2: asm_callid(as, ir, IRCALL_atan2); break; - case IR_LDEXP: asm_callid(as, ir, IRCALL_ldexp); break; - case IR_MIN: asm_min_max(as, ir, 0); break; - case IR_MAX: asm_min_max(as, ir, 1); break; - case IR_FPMATH: - if (ir->op2 == IRFPM_EXP2 && asm_fpjoin_pow(as, ir)) - break; - if (ir->op2 == IRFPM_SQRT && (as->flags & JIT_F_SQRT)) - asm_fpunary(as, ir, PPCI_FSQRT); - else - asm_callid(as, ir, IRCALL_lj_vm_floor + ir->op2); - break; - - /* Overflow-checking arithmetic ops. */ - case IR_ADDOV: asm_arithov(as, ir, PPCI_ADDO); break; - case IR_SUBOV: asm_arithov(as, ir, PPCI_SUBFO); break; - case IR_MULOV: asm_arithov(as, ir, PPCI_MULLWO); break; - - /* Memory references. */ - case IR_AREF: asm_aref(as, ir); break; - case IR_HREF: asm_href(as, ir, 0); break; - case IR_HREFK: asm_hrefk(as, ir); break; - case IR_NEWREF: asm_newref(as, ir); break; - case IR_UREFO: case IR_UREFC: asm_uref(as, ir); break; - case IR_FREF: asm_fref(as, ir); break; - case IR_STRREF: asm_strref(as, ir); break; - - /* Loads and stores. */ - case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: - asm_ahuvload(as, ir); - break; - case IR_FLOAD: asm_fload(as, ir); break; - case IR_XLOAD: asm_xload(as, ir); break; - case IR_SLOAD: asm_sload(as, ir); break; - - case IR_ASTORE: case IR_HSTORE: case IR_USTORE: asm_ahustore(as, ir); break; - case IR_FSTORE: asm_fstore(as, ir); break; - case IR_XSTORE: asm_xstore(as, ir, 0); break; - - /* Allocations. */ - case IR_SNEW: case IR_XSNEW: asm_snew(as, ir); break; - case IR_TNEW: asm_tnew(as, ir); break; - case IR_TDUP: asm_tdup(as, ir); break; - case IR_CNEW: case IR_CNEWI: asm_cnew(as, ir); break; - - /* Write barriers. */ - case IR_TBAR: asm_tbar(as, ir); break; - case IR_OBAR: asm_obar(as, ir); break; - - /* Type conversions. */ - case IR_CONV: asm_conv(as, ir); break; - case IR_TOBIT: asm_tobit(as, ir); break; - case IR_TOSTR: asm_tostr(as, ir); break; - case IR_STRTO: asm_strto(as, ir); break; - - /* Calls. */ - case IR_CALLN: case IR_CALLL: case IR_CALLS: asm_call(as, ir); break; - case IR_CALLXS: asm_callx(as, ir); break; - case IR_CARG: break; - - default: - setintV(&as->J->errinfo, ir->o); - lj_trace_err_info(as->J, LJ_TRERR_NYIIR); - break; - } -} - -/* -- Trace setup --------------------------------------------------------- */ - -/* Ensure there are enough stack slots for call arguments. */ -static Reg asm_setup_call_slots(ASMState *as, IRIns *ir, const CCallInfo *ci) -{ - IRRef args[CCI_NARGS_MAX*2]; - uint32_t i, nargs = (int)CCI_NARGS(ci); - int nslots = 2, ngpr = REGARG_NUMGPR, nfpr = REGARG_NUMFPR; - asm_collectargs(as, ir, ci, args); - for (i = 0; i < nargs; i++) - if (args[i] && irt_isfp(IR(args[i])->t)) { - if (nfpr > 0) nfpr--; else nslots = (nslots+3) & ~1; - } else { - if (ngpr > 0) ngpr--; else nslots++; - } - if (nslots > as->evenspill) /* Leave room for args in stack slots. */ - as->evenspill = nslots; - return irt_isfp(ir->t) ? REGSP_HINT(RID_FPRET) : REGSP_HINT(RID_RET); -} - -static void asm_setup_target(ASMState *as) -{ - asm_exitstub_setup(as, as->T->nsnap + (as->parent ? 1 : 0)); -} - -/* -- Trace patching ------------------------------------------------------ */ - -/* Patch exit jumps of existing machine code to a new target. */ -void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target) -{ - MCode *p = T->mcode; - MCode *pe = (MCode *)((char *)p + T->szmcode); - MCode *px = exitstub_trace_addr(T, exitno); - MCode *cstart = NULL; - MCode *mcarea = lj_mcode_patch(J, p, 0); - int clearso = 0; - for (; p < pe; p++) { - /* Look for exitstub branch, try to replace with branch to target. */ - uint32_t ins = *p; - if ((ins & 0xfc000000u) == 0x40000000u && - ((ins ^ ((char *)px-(char *)p)) & 0xffffu) == 0) { - ptrdiff_t delta = (char *)target - (char *)p; - if (((ins >> 16) & 3) == (CC_SO&3)) { - clearso = sizeof(MCode); - delta -= sizeof(MCode); - } - /* Many, but not all short-range branches can be patched directly. */ - if (((delta + 0x8000) >> 16) == 0) { - *p = (ins & 0xffdf0000u) | ((uint32_t)delta & 0xffffu) | - ((delta & 0x8000) * (PPCF_Y/0x8000)); - if (!cstart) cstart = p; - } - } else if ((ins & 0xfc000000u) == PPCI_B && - ((ins ^ ((char *)px-(char *)p)) & 0x03ffffffu) == 0) { - ptrdiff_t delta = (char *)target - (char *)p; - lua_assert(((delta + 0x02000000) >> 26) == 0); - *p = PPCI_B | ((uint32_t)delta & 0x03ffffffu); - if (!cstart) cstart = p; - } - } - { /* Always patch long-range branch in exit stub itself. */ - ptrdiff_t delta = (char *)target - (char *)px - clearso; - lua_assert(((delta + 0x02000000) >> 26) == 0); - *px = PPCI_B | ((uint32_t)delta & 0x03ffffffu); - } - if (!cstart) cstart = px; - lj_mcode_sync(cstart, px+1); - if (clearso) { /* Extend the current trace. Ugly workaround. */ - MCode *pp = J->cur.mcode; - J->cur.szmcode += sizeof(MCode); - *--pp = PPCI_MCRXR; /* Clear SO flag. */ - J->cur.mcode = pp; - lj_mcode_sync(pp, pp+1); - } - lj_mcode_patch(J, mcarea, 1); -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_x86.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_x86.h deleted file mode 100644 index fda911e50..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_asm_x86.h +++ /dev/null @@ -1,2794 +0,0 @@ -/* -** x86/x64 IR assembler (SSA IR -> machine code). -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -/* -- Guard handling ------------------------------------------------------ */ - -/* Generate an exit stub group at the bottom of the reserved MCode memory. */ -static MCode *asm_exitstub_gen(ASMState *as, ExitNo group) -{ - ExitNo i, groupofs = (group*EXITSTUBS_PER_GROUP) & 0xff; - MCode *mxp = as->mcbot; - MCode *mxpstart = mxp; - if (mxp + (2+2)*EXITSTUBS_PER_GROUP+8+5 >= as->mctop) - asm_mclimit(as); - /* Push low byte of exitno for each exit stub. */ - *mxp++ = XI_PUSHi8; *mxp++ = (MCode)groupofs; - for (i = 1; i < EXITSTUBS_PER_GROUP; i++) { - *mxp++ = XI_JMPs; *mxp++ = (MCode)((2+2)*(EXITSTUBS_PER_GROUP - i) - 2); - *mxp++ = XI_PUSHi8; *mxp++ = (MCode)(groupofs + i); - } - /* Push the high byte of the exitno for each exit stub group. */ - *mxp++ = XI_PUSHi8; *mxp++ = (MCode)((group*EXITSTUBS_PER_GROUP)>>8); - /* Store DISPATCH at original stack slot 0. Account for the two push ops. */ - *mxp++ = XI_MOVmi; - *mxp++ = MODRM(XM_OFS8, 0, RID_ESP); - *mxp++ = MODRM(XM_SCALE1, RID_ESP, RID_ESP); - *mxp++ = 2*sizeof(void *); - *(int32_t *)mxp = ptr2addr(J2GG(as->J)->dispatch); mxp += 4; - /* Jump to exit handler which fills in the ExitState. */ - *mxp++ = XI_JMP; mxp += 4; - *((int32_t *)(mxp-4)) = jmprel(mxp, (MCode *)(void *)lj_vm_exit_handler); - /* Commit the code for this group (even if assembly fails later on). */ - lj_mcode_commitbot(as->J, mxp); - as->mcbot = mxp; - as->mclim = as->mcbot + MCLIM_REDZONE; - return mxpstart; -} - -/* Setup all needed exit stubs. */ -static void asm_exitstub_setup(ASMState *as, ExitNo nexits) -{ - ExitNo i; - if (nexits >= EXITSTUBS_PER_GROUP*LJ_MAX_EXITSTUBGR) - lj_trace_err(as->J, LJ_TRERR_SNAPOV); - for (i = 0; i < (nexits+EXITSTUBS_PER_GROUP-1)/EXITSTUBS_PER_GROUP; i++) - if (as->J->exitstubgroup[i] == NULL) - as->J->exitstubgroup[i] = asm_exitstub_gen(as, i); -} - -/* Emit conditional branch to exit for guard. -** It's important to emit this *after* all registers have been allocated, -** because rematerializations may invalidate the flags. -*/ -static void asm_guardcc(ASMState *as, int cc) -{ - MCode *target = exitstub_addr(as->J, as->snapno); - MCode *p = as->mcp; - if (LJ_UNLIKELY(p == as->invmcp)) { - as->loopinv = 1; - *(int32_t *)(p+1) = jmprel(p+5, target); - target = p; - cc ^= 1; - if (as->realign) { - emit_sjcc(as, cc, target); - return; - } - } - emit_jcc(as, cc, target); -} - -/* -- Memory operand fusion ----------------------------------------------- */ - -/* Limit linear search to this distance. Avoids O(n^2) behavior. */ -#define CONFLICT_SEARCH_LIM 31 - -/* Check if a reference is a signed 32 bit constant. */ -static int asm_isk32(ASMState *as, IRRef ref, int32_t *k) -{ - if (irref_isk(ref)) { - IRIns *ir = IR(ref); - if (ir->o != IR_KINT64) { - *k = ir->i; - return 1; - } else if (checki32((int64_t)ir_kint64(ir)->u64)) { - *k = (int32_t)ir_kint64(ir)->u64; - return 1; - } - } - return 0; -} - -/* Check if there's no conflicting instruction between curins and ref. -** Also avoid fusing loads if there are multiple references. -*/ -static int noconflict(ASMState *as, IRRef ref, IROp conflict, int noload) -{ - IRIns *ir = as->ir; - IRRef i = as->curins; - if (i > ref + CONFLICT_SEARCH_LIM) - return 0; /* Give up, ref is too far away. */ - while (--i > ref) { - if (ir[i].o == conflict) - return 0; /* Conflict found. */ - else if (!noload && (ir[i].op1 == ref || ir[i].op2 == ref)) - return 0; - } - return 1; /* Ok, no conflict. */ -} - -/* Fuse array base into memory operand. */ -static IRRef asm_fuseabase(ASMState *as, IRRef ref) -{ - IRIns *irb = IR(ref); - as->mrm.ofs = 0; - if (irb->o == IR_FLOAD) { - IRIns *ira = IR(irb->op1); - lua_assert(irb->op2 == IRFL_TAB_ARRAY); - /* We can avoid the FLOAD of t->array for colocated arrays. */ - if (ira->o == IR_TNEW && ira->op1 <= LJ_MAX_COLOSIZE && - !neverfuse(as) && noconflict(as, irb->op1, IR_NEWREF, 1)) { - as->mrm.ofs = (int32_t)sizeof(GCtab); /* Ofs to colocated array. */ - return irb->op1; /* Table obj. */ - } - } else if (irb->o == IR_ADD && irref_isk(irb->op2)) { - /* Fuse base offset (vararg load). */ - as->mrm.ofs = IR(irb->op2)->i; - return irb->op1; - } - return ref; /* Otherwise use the given array base. */ -} - -/* Fuse array reference into memory operand. */ -static void asm_fusearef(ASMState *as, IRIns *ir, RegSet allow) -{ - IRIns *irx; - lua_assert(ir->o == IR_AREF); - as->mrm.base = (uint8_t)ra_alloc1(as, asm_fuseabase(as, ir->op1), allow); - irx = IR(ir->op2); - if (irref_isk(ir->op2)) { - as->mrm.ofs += 8*irx->i; - as->mrm.idx = RID_NONE; - } else { - rset_clear(allow, as->mrm.base); - as->mrm.scale = XM_SCALE8; - /* Fuse a constant ADD (e.g. t[i+1]) into the offset. - ** Doesn't help much without ABCelim, but reduces register pressure. - */ - if (!LJ_64 && /* Has bad effects with negative index on x64. */ - mayfuse(as, ir->op2) && ra_noreg(irx->r) && - irx->o == IR_ADD && irref_isk(irx->op2)) { - as->mrm.ofs += 8*IR(irx->op2)->i; - as->mrm.idx = (uint8_t)ra_alloc1(as, irx->op1, allow); - } else { - as->mrm.idx = (uint8_t)ra_alloc1(as, ir->op2, allow); - } - } -} - -/* Fuse array/hash/upvalue reference into memory operand. -** Caveat: this may allocate GPRs for the base/idx registers. Be sure to -** pass the final allow mask, excluding any GPRs used for other inputs. -** In particular: 2-operand GPR instructions need to call ra_dest() first! -*/ -static void asm_fuseahuref(ASMState *as, IRRef ref, RegSet allow) -{ - IRIns *ir = IR(ref); - if (ra_noreg(ir->r)) { - switch ((IROp)ir->o) { - case IR_AREF: - if (mayfuse(as, ref)) { - asm_fusearef(as, ir, allow); - return; - } - break; - case IR_HREFK: - if (mayfuse(as, ref)) { - as->mrm.base = (uint8_t)ra_alloc1(as, ir->op1, allow); - as->mrm.ofs = (int32_t)(IR(ir->op2)->op2 * sizeof(Node)); - as->mrm.idx = RID_NONE; - return; - } - break; - case IR_UREFC: - if (irref_isk(ir->op1)) { - GCfunc *fn = ir_kfunc(IR(ir->op1)); - GCupval *uv = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv; - as->mrm.ofs = ptr2addr(&uv->tv); - as->mrm.base = as->mrm.idx = RID_NONE; - return; - } - break; - default: - lua_assert(ir->o == IR_HREF || ir->o == IR_NEWREF || ir->o == IR_UREFO || - ir->o == IR_KKPTR); - break; - } - } - as->mrm.base = (uint8_t)ra_alloc1(as, ref, allow); - as->mrm.ofs = 0; - as->mrm.idx = RID_NONE; -} - -/* Fuse FLOAD/FREF reference into memory operand. */ -static void asm_fusefref(ASMState *as, IRIns *ir, RegSet allow) -{ - lua_assert(ir->o == IR_FLOAD || ir->o == IR_FREF); - as->mrm.ofs = field_ofs[ir->op2]; - as->mrm.idx = RID_NONE; - if (irref_isk(ir->op1)) { - as->mrm.ofs += IR(ir->op1)->i; - as->mrm.base = RID_NONE; - } else { - as->mrm.base = (uint8_t)ra_alloc1(as, ir->op1, allow); - } -} - -/* Fuse string reference into memory operand. */ -static void asm_fusestrref(ASMState *as, IRIns *ir, RegSet allow) -{ - IRIns *irr; - lua_assert(ir->o == IR_STRREF); - as->mrm.base = as->mrm.idx = RID_NONE; - as->mrm.scale = XM_SCALE1; - as->mrm.ofs = sizeof(GCstr); - if (irref_isk(ir->op1)) { - as->mrm.ofs += IR(ir->op1)->i; - } else { - Reg r = ra_alloc1(as, ir->op1, allow); - rset_clear(allow, r); - as->mrm.base = (uint8_t)r; - } - irr = IR(ir->op2); - if (irref_isk(ir->op2)) { - as->mrm.ofs += irr->i; - } else { - Reg r; - /* Fuse a constant add into the offset, e.g. string.sub(s, i+10). */ - if (!LJ_64 && /* Has bad effects with negative index on x64. */ - mayfuse(as, ir->op2) && irr->o == IR_ADD && irref_isk(irr->op2)) { - as->mrm.ofs += IR(irr->op2)->i; - r = ra_alloc1(as, irr->op1, allow); - } else { - r = ra_alloc1(as, ir->op2, allow); - } - if (as->mrm.base == RID_NONE) - as->mrm.base = (uint8_t)r; - else - as->mrm.idx = (uint8_t)r; - } -} - -static void asm_fusexref(ASMState *as, IRRef ref, RegSet allow) -{ - IRIns *ir = IR(ref); - as->mrm.idx = RID_NONE; - if (ir->o == IR_KPTR || ir->o == IR_KKPTR) { - as->mrm.ofs = ir->i; - as->mrm.base = RID_NONE; - } else if (ir->o == IR_STRREF) { - asm_fusestrref(as, ir, allow); - } else { - as->mrm.ofs = 0; - if (canfuse(as, ir) && ir->o == IR_ADD && ra_noreg(ir->r)) { - /* Gather (base+idx*sz)+ofs as emitted by cdata ptr/array indexing. */ - IRIns *irx; - IRRef idx; - Reg r; - if (asm_isk32(as, ir->op2, &as->mrm.ofs)) { /* Recognize x+ofs. */ - ref = ir->op1; - ir = IR(ref); - if (!(ir->o == IR_ADD && canfuse(as, ir) && ra_noreg(ir->r))) - goto noadd; - } - as->mrm.scale = XM_SCALE1; - idx = ir->op1; - ref = ir->op2; - irx = IR(idx); - if (!(irx->o == IR_BSHL || irx->o == IR_ADD)) { /* Try other operand. */ - idx = ir->op2; - ref = ir->op1; - irx = IR(idx); - } - if (canfuse(as, irx) && ra_noreg(irx->r)) { - if (irx->o == IR_BSHL && irref_isk(irx->op2) && IR(irx->op2)->i <= 3) { - /* Recognize idx<op1; - as->mrm.scale = (uint8_t)(IR(irx->op2)->i << 6); - } else if (irx->o == IR_ADD && irx->op1 == irx->op2) { - /* FOLD does idx*2 ==> idx<<1 ==> idx+idx. */ - idx = irx->op1; - as->mrm.scale = XM_SCALE2; - } - } - r = ra_alloc1(as, idx, allow); - rset_clear(allow, r); - as->mrm.idx = (uint8_t)r; - } - noadd: - as->mrm.base = (uint8_t)ra_alloc1(as, ref, allow); - } -} - -/* Fuse load into memory operand. */ -static Reg asm_fuseload(ASMState *as, IRRef ref, RegSet allow) -{ - IRIns *ir = IR(ref); - if (ra_hasreg(ir->r)) { - if (allow != RSET_EMPTY) { /* Fast path. */ - ra_noweak(as, ir->r); - return ir->r; - } - fusespill: - /* Force a spill if only memory operands are allowed (asm_x87load). */ - as->mrm.base = RID_ESP; - as->mrm.ofs = ra_spill(as, ir); - as->mrm.idx = RID_NONE; - return RID_MRM; - } - if (ir->o == IR_KNUM) { - RegSet avail = as->freeset & ~as->modset & RSET_FPR; - lua_assert(allow != RSET_EMPTY); - if (!(avail & (avail-1))) { /* Fuse if less than two regs available. */ - as->mrm.ofs = ptr2addr(ir_knum(ir)); - as->mrm.base = as->mrm.idx = RID_NONE; - return RID_MRM; - } - } else if (mayfuse(as, ref)) { - RegSet xallow = (allow & RSET_GPR) ? allow : RSET_GPR; - if (ir->o == IR_SLOAD) { - if (!(ir->op2 & (IRSLOAD_PARENT|IRSLOAD_CONVERT)) && - noconflict(as, ref, IR_RETF, 0)) { - as->mrm.base = (uint8_t)ra_alloc1(as, REF_BASE, xallow); - as->mrm.ofs = 8*((int32_t)ir->op1-1) + ((ir->op2&IRSLOAD_FRAME)?4:0); - as->mrm.idx = RID_NONE; - return RID_MRM; - } - } else if (ir->o == IR_FLOAD) { - /* Generic fusion is only ok for 32 bit operand (but see asm_comp). */ - if ((irt_isint(ir->t) || irt_isu32(ir->t) || irt_isaddr(ir->t)) && - noconflict(as, ref, IR_FSTORE, 0)) { - asm_fusefref(as, ir, xallow); - return RID_MRM; - } - } else if (ir->o == IR_ALOAD || ir->o == IR_HLOAD || ir->o == IR_ULOAD) { - if (noconflict(as, ref, ir->o + IRDELTA_L2S, 0)) { - asm_fuseahuref(as, ir->op1, xallow); - return RID_MRM; - } - } else if (ir->o == IR_XLOAD) { - /* Generic fusion is not ok for 8/16 bit operands (but see asm_comp). - ** Fusing unaligned memory operands is ok on x86 (except for SIMD types). - */ - if ((!irt_typerange(ir->t, IRT_I8, IRT_U16)) && - noconflict(as, ref, IR_XSTORE, 0)) { - asm_fusexref(as, ir->op1, xallow); - return RID_MRM; - } - } else if (ir->o == IR_VLOAD) { - asm_fuseahuref(as, ir->op1, xallow); - return RID_MRM; - } - } - if (!(as->freeset & allow) && - (allow == RSET_EMPTY || ra_hasspill(ir->s) || iscrossref(as, ref))) - goto fusespill; - return ra_allocref(as, ref, allow); -} - -#if LJ_64 -/* Don't fuse a 32 bit load into a 64 bit operation. */ -static Reg asm_fuseloadm(ASMState *as, IRRef ref, RegSet allow, int is64) -{ - if (is64 && !irt_is64(IR(ref)->t)) - return ra_alloc1(as, ref, allow); - return asm_fuseload(as, ref, allow); -} -#else -#define asm_fuseloadm(as, ref, allow, is64) asm_fuseload(as, (ref), (allow)) -#endif - -/* -- Calls --------------------------------------------------------------- */ - -/* Count the required number of stack slots for a call. */ -static int asm_count_call_slots(ASMState *as, const CCallInfo *ci, IRRef *args) -{ - uint32_t i, nargs = CCI_NARGS(ci); - int nslots = 0; -#if LJ_64 - if (LJ_ABI_WIN) { - nslots = (int)(nargs*2); /* Only matters for more than four args. */ - } else { - int ngpr = REGARG_NUMGPR, nfpr = REGARG_NUMFPR; - for (i = 0; i < nargs; i++) - if (args[i] && irt_isfp(IR(args[i])->t)) { - if (nfpr > 0) nfpr--; else nslots += 2; - } else { - if (ngpr > 0) ngpr--; else nslots += 2; - } - } -#else - int ngpr = 0; - if ((ci->flags & CCI_CC_MASK) == CCI_CC_FASTCALL) - ngpr = 2; - else if ((ci->flags & CCI_CC_MASK) == CCI_CC_THISCALL) - ngpr = 1; - for (i = 0; i < nargs; i++) - if (args[i] && irt_isfp(IR(args[i])->t)) { - nslots += irt_isnum(IR(args[i])->t) ? 2 : 1; - } else { - if (ngpr > 0) ngpr--; else nslots++; - } -#endif - return nslots; -} - -/* Generate a call to a C function. */ -static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args) -{ - uint32_t n, nargs = CCI_NARGS(ci); - int32_t ofs = STACKARG_OFS; -#if LJ_64 - uint32_t gprs = REGARG_GPRS; - Reg fpr = REGARG_FIRSTFPR; -#if !LJ_ABI_WIN - MCode *patchnfpr = NULL; -#endif -#else - uint32_t gprs = 0; - if ((ci->flags & CCI_CC_MASK) != CCI_CC_CDECL) { - if ((ci->flags & CCI_CC_MASK) == CCI_CC_THISCALL) - gprs = (REGARG_GPRS & 31); - else if ((ci->flags & CCI_CC_MASK) == CCI_CC_FASTCALL) - gprs = REGARG_GPRS; - } -#endif - if ((void *)ci->func) - emit_call(as, ci->func); -#if LJ_64 - if ((ci->flags & CCI_VARARG)) { /* Special handling for vararg calls. */ -#if LJ_ABI_WIN - for (n = 0; n < 4 && n < nargs; n++) { - IRIns *ir = IR(args[n]); - if (irt_isfp(ir->t)) /* Duplicate FPRs in GPRs. */ - emit_rr(as, XO_MOVDto, (irt_isnum(ir->t) ? REX_64 : 0) | (fpr+n), - ((gprs >> (n*5)) & 31)); /* Either MOVD or MOVQ. */ - } -#else - patchnfpr = --as->mcp; /* Indicate number of used FPRs in register al. */ - *--as->mcp = XI_MOVrib | RID_EAX; -#endif - } -#endif - for (n = 0; n < nargs; n++) { /* Setup args. */ - IRRef ref = args[n]; - IRIns *ir = IR(ref); - Reg r; -#if LJ_64 && LJ_ABI_WIN - /* Windows/x64 argument registers are strictly positional. */ - r = irt_isfp(ir->t) ? (fpr <= REGARG_LASTFPR ? fpr : 0) : (gprs & 31); - fpr++; gprs >>= 5; -#elif LJ_64 - /* POSIX/x64 argument registers are used in order of appearance. */ - if (irt_isfp(ir->t)) { - r = fpr <= REGARG_LASTFPR ? fpr++ : 0; - } else { - r = gprs & 31; gprs >>= 5; - } -#else - if (ref && irt_isfp(ir->t)) { - r = 0; - } else { - r = gprs & 31; gprs >>= 5; - if (!ref) continue; - } -#endif - if (r) { /* Argument is in a register. */ - if (r < RID_MAX_GPR && ref < ASMREF_TMP1) { -#if LJ_64 - if (ir->o == IR_KINT64) - emit_loadu64(as, r, ir_kint64(ir)->u64); - else -#endif - emit_loadi(as, r, ir->i); - } else { - lua_assert(rset_test(as->freeset, r)); /* Must have been evicted. */ - if (ra_hasreg(ir->r)) { - ra_noweak(as, ir->r); - emit_movrr(as, ir, r, ir->r); - } else { - ra_allocref(as, ref, RID2RSET(r)); - } - } - } else if (irt_isfp(ir->t)) { /* FP argument is on stack. */ - lua_assert(!(irt_isfloat(ir->t) && irref_isk(ref))); /* No float k. */ - if (LJ_32 && (ofs & 4) && irref_isk(ref)) { - /* Split stores for unaligned FP consts. */ - emit_movmroi(as, RID_ESP, ofs, (int32_t)ir_knum(ir)->u32.lo); - emit_movmroi(as, RID_ESP, ofs+4, (int32_t)ir_knum(ir)->u32.hi); - } else { - r = ra_alloc1(as, ref, RSET_FPR); - emit_rmro(as, irt_isnum(ir->t) ? XO_MOVSDto : XO_MOVSSto, - r, RID_ESP, ofs); - } - ofs += (LJ_32 && irt_isfloat(ir->t)) ? 4 : 8; - } else { /* Non-FP argument is on stack. */ - if (LJ_32 && ref < ASMREF_TMP1) { - emit_movmroi(as, RID_ESP, ofs, ir->i); - } else { - r = ra_alloc1(as, ref, RSET_GPR); - emit_movtomro(as, REX_64 + r, RID_ESP, ofs); - } - ofs += sizeof(intptr_t); - } - checkmclim(as); - } -#if LJ_64 && !LJ_ABI_WIN - if (patchnfpr) *patchnfpr = fpr - REGARG_FIRSTFPR; -#endif -} - -/* Setup result reg/sp for call. Evict scratch regs. */ -static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci) -{ - RegSet drop = RSET_SCRATCH; - int hiop = (LJ_32 && (ir+1)->o == IR_HIOP); - if ((ci->flags & CCI_NOFPRCLOBBER)) - drop &= ~RSET_FPR; - if (ra_hasreg(ir->r)) - rset_clear(drop, ir->r); /* Dest reg handled below. */ - if (hiop && ra_hasreg((ir+1)->r)) - rset_clear(drop, (ir+1)->r); /* Dest reg handled below. */ - ra_evictset(as, drop); /* Evictions must be performed first. */ - if (ra_used(ir)) { - if (irt_isfp(ir->t)) { - int32_t ofs = sps_scale(ir->s); /* Use spill slot or temp slots. */ -#if LJ_64 - if ((ci->flags & CCI_CASTU64)) { - Reg dest = ir->r; - if (ra_hasreg(dest)) { - ra_free(as, dest); - ra_modified(as, dest); - emit_rr(as, XO_MOVD, dest|REX_64, RID_RET); /* Really MOVQ. */ - } - if (ofs) emit_movtomro(as, RID_RET|REX_64, RID_ESP, ofs); - } else { - ra_destreg(as, ir, RID_FPRET); - } -#else - /* Number result is in x87 st0 for x86 calling convention. */ - Reg dest = ir->r; - if (ra_hasreg(dest)) { - ra_free(as, dest); - ra_modified(as, dest); - emit_rmro(as, irt_isnum(ir->t) ? XMM_MOVRM(as) : XO_MOVSS, - dest, RID_ESP, ofs); - } - if ((ci->flags & CCI_CASTU64)) { - emit_movtomro(as, RID_RETLO, RID_ESP, ofs); - emit_movtomro(as, RID_RETHI, RID_ESP, ofs+4); - } else { - emit_rmro(as, irt_isnum(ir->t) ? XO_FSTPq : XO_FSTPd, - irt_isnum(ir->t) ? XOg_FSTPq : XOg_FSTPd, RID_ESP, ofs); - } -#endif -#if LJ_32 - } else if (hiop) { - ra_destpair(as, ir); -#endif - } else { - lua_assert(!irt_ispri(ir->t)); - ra_destreg(as, ir, RID_RET); - } - } else if (LJ_32 && irt_isfp(ir->t)) { - emit_x87op(as, XI_FPOP); /* Pop unused result from x87 st0. */ - } -} - -static void asm_call(ASMState *as, IRIns *ir) -{ - IRRef args[CCI_NARGS_MAX]; - const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; - asm_collectargs(as, ir, ci, args); - asm_setupresult(as, ir, ci); - asm_gencall(as, ci, args); -} - -/* Return a constant function pointer or NULL for indirect calls. */ -static void *asm_callx_func(ASMState *as, IRIns *irf, IRRef func) -{ -#if LJ_32 - UNUSED(as); - if (irref_isk(func)) - return (void *)irf->i; -#else - if (irref_isk(func)) { - MCode *p; - if (irf->o == IR_KINT64) - p = (MCode *)(void *)ir_k64(irf)->u64; - else - p = (MCode *)(void *)(uintptr_t)(uint32_t)irf->i; - if (p - as->mcp == (int32_t)(p - as->mcp)) - return p; /* Call target is still in +-2GB range. */ - /* Avoid the indirect case of emit_call(). Try to hoist func addr. */ - } -#endif - return NULL; -} - -static void asm_callx(ASMState *as, IRIns *ir) -{ - IRRef args[CCI_NARGS_MAX*2]; - CCallInfo ci; - IRRef func; - IRIns *irf; - int32_t spadj = 0; - ci.flags = asm_callx_flags(as, ir); - asm_collectargs(as, ir, &ci, args); - asm_setupresult(as, ir, &ci); -#if LJ_32 - /* Have to readjust stack after non-cdecl calls due to callee cleanup. */ - if ((ci.flags & CCI_CC_MASK) != CCI_CC_CDECL) - spadj = 4 * asm_count_call_slots(as, &ci, args); -#endif - func = ir->op2; irf = IR(func); - if (irf->o == IR_CARG) { func = irf->op1; irf = IR(func); } - ci.func = (ASMFunction)asm_callx_func(as, irf, func); - if (!(void *)ci.func) { - /* Use a (hoistable) non-scratch register for indirect calls. */ - RegSet allow = (RSET_GPR & ~RSET_SCRATCH); - Reg r = ra_alloc1(as, func, allow); - if (LJ_32) emit_spsub(as, spadj); /* Above code may cause restores! */ - emit_rr(as, XO_GROUP5, XOg_CALL, r); - } else if (LJ_32) { - emit_spsub(as, spadj); - } - asm_gencall(as, &ci, args); -} - -/* -- Returns ------------------------------------------------------------- */ - -/* Return to lower frame. Guard that it goes to the right spot. */ -static void asm_retf(ASMState *as, IRIns *ir) -{ - Reg base = ra_alloc1(as, REF_BASE, RSET_GPR); - void *pc = ir_kptr(IR(ir->op2)); - int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); - as->topslot -= (BCReg)delta; - if ((int32_t)as->topslot < 0) as->topslot = 0; - irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */ - emit_setgl(as, base, jit_base); - emit_addptr(as, base, -8*delta); - asm_guardcc(as, CC_NE); - emit_gmroi(as, XG_ARITHi(XOg_CMP), base, -4, ptr2addr(pc)); -} - -/* -- Type conversions ---------------------------------------------------- */ - -static void asm_tointg(ASMState *as, IRIns *ir, Reg left) -{ - Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); - Reg dest = ra_dest(as, ir, RSET_GPR); - asm_guardcc(as, CC_P); - asm_guardcc(as, CC_NE); - emit_rr(as, XO_UCOMISD, left, tmp); - emit_rr(as, XO_CVTSI2SD, tmp, dest); - if (!(as->flags & JIT_F_SPLIT_XMM)) - emit_rr(as, XO_XORPS, tmp, tmp); /* Avoid partial register stall. */ - emit_rr(as, XO_CVTTSD2SI, dest, left); - /* Can't fuse since left is needed twice. */ -} - -static void asm_tobit(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - Reg tmp = ra_noreg(IR(ir->op1)->r) ? - ra_alloc1(as, ir->op1, RSET_FPR) : - ra_scratch(as, RSET_FPR); - Reg right = asm_fuseload(as, ir->op2, rset_exclude(RSET_FPR, tmp)); - emit_rr(as, XO_MOVDto, tmp, dest); - emit_mrm(as, XO_ADDSD, tmp, right); - ra_left(as, tmp, ir->op1); -} - -static void asm_conv(ASMState *as, IRIns *ir) -{ - IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); - int st64 = (st == IRT_I64 || st == IRT_U64 || (LJ_64 && st == IRT_P64)); - int stfp = (st == IRT_NUM || st == IRT_FLOAT); - IRRef lref = ir->op1; - lua_assert(irt_type(ir->t) != st); - lua_assert(!(LJ_32 && (irt_isint64(ir->t) || st64))); /* Handled by SPLIT. */ - if (irt_isfp(ir->t)) { - Reg dest = ra_dest(as, ir, RSET_FPR); - if (stfp) { /* FP to FP conversion. */ - Reg left = asm_fuseload(as, lref, RSET_FPR); - emit_mrm(as, st == IRT_NUM ? XO_CVTSD2SS : XO_CVTSS2SD, dest, left); - if (left == dest) return; /* Avoid the XO_XORPS. */ - } else if (LJ_32 && st == IRT_U32) { /* U32 to FP conversion on x86. */ - /* number = (2^52+2^51 .. u32) - (2^52+2^51) */ - cTValue *k = lj_ir_k64_find(as->J, U64x(43380000,00000000)); - Reg bias = ra_scratch(as, rset_exclude(RSET_FPR, dest)); - if (irt_isfloat(ir->t)) - emit_rr(as, XO_CVTSD2SS, dest, dest); - emit_rr(as, XO_SUBSD, dest, bias); /* Subtract 2^52+2^51 bias. */ - emit_rr(as, XO_XORPS, dest, bias); /* Merge bias and integer. */ - emit_loadn(as, bias, k); - emit_mrm(as, XO_MOVD, dest, asm_fuseload(as, lref, RSET_GPR)); - return; - } else { /* Integer to FP conversion. */ - Reg left = (LJ_64 && (st == IRT_U32 || st == IRT_U64)) ? - ra_alloc1(as, lref, RSET_GPR) : - asm_fuseloadm(as, lref, RSET_GPR, st64); - if (LJ_64 && st == IRT_U64) { - MCLabel l_end = emit_label(as); - const void *k = lj_ir_k64_find(as->J, U64x(43f00000,00000000)); - emit_rma(as, XO_ADDSD, dest, k); /* Add 2^64 to compensate. */ - emit_sjcc(as, CC_NS, l_end); - emit_rr(as, XO_TEST, left|REX_64, left); /* Check if u64 >= 2^63. */ - } - emit_mrm(as, irt_isnum(ir->t) ? XO_CVTSI2SD : XO_CVTSI2SS, - dest|((LJ_64 && (st64 || st == IRT_U32)) ? REX_64 : 0), left); - } - if (!(as->flags & JIT_F_SPLIT_XMM)) - emit_rr(as, XO_XORPS, dest, dest); /* Avoid partial register stall. */ - } else if (stfp) { /* FP to integer conversion. */ - if (irt_isguard(ir->t)) { - /* Checked conversions are only supported from number to int. */ - lua_assert(irt_isint(ir->t) && st == IRT_NUM); - asm_tointg(as, ir, ra_alloc1(as, lref, RSET_FPR)); - } else { - Reg dest = ra_dest(as, ir, RSET_GPR); - x86Op op = st == IRT_NUM ? - ((ir->op2 & IRCONV_TRUNC) ? XO_CVTTSD2SI : XO_CVTSD2SI) : - ((ir->op2 & IRCONV_TRUNC) ? XO_CVTTSS2SI : XO_CVTSS2SI); - if (LJ_64 ? irt_isu64(ir->t) : irt_isu32(ir->t)) { - /* LJ_64: For inputs >= 2^63 add -2^64, convert again. */ - /* LJ_32: For inputs >= 2^31 add -2^31, convert again and add 2^31. */ - Reg tmp = ra_noreg(IR(lref)->r) ? ra_alloc1(as, lref, RSET_FPR) : - ra_scratch(as, RSET_FPR); - MCLabel l_end = emit_label(as); - if (LJ_32) - emit_gri(as, XG_ARITHi(XOg_ADD), dest, (int32_t)0x80000000); - emit_rr(as, op, dest|REX_64, tmp); - if (st == IRT_NUM) - emit_rma(as, XO_ADDSD, tmp, lj_ir_k64_find(as->J, - LJ_64 ? U64x(c3f00000,00000000) : U64x(c1e00000,00000000))); - else - emit_rma(as, XO_ADDSS, tmp, lj_ir_k64_find(as->J, - LJ_64 ? U64x(00000000,df800000) : U64x(00000000,cf000000))); - emit_sjcc(as, CC_NS, l_end); - emit_rr(as, XO_TEST, dest|REX_64, dest); /* Check if dest negative. */ - emit_rr(as, op, dest|REX_64, tmp); - ra_left(as, tmp, lref); - } else { - Reg left = asm_fuseload(as, lref, RSET_FPR); - if (LJ_64 && irt_isu32(ir->t)) - emit_rr(as, XO_MOV, dest, dest); /* Zero hiword. */ - emit_mrm(as, op, - dest|((LJ_64 && - (irt_is64(ir->t) || irt_isu32(ir->t))) ? REX_64 : 0), - left); - } - } - } else if (st >= IRT_I8 && st <= IRT_U16) { /* Extend to 32 bit integer. */ - Reg left, dest = ra_dest(as, ir, RSET_GPR); - RegSet allow = RSET_GPR; - x86Op op; - lua_assert(irt_isint(ir->t) || irt_isu32(ir->t)); - if (st == IRT_I8) { - op = XO_MOVSXb; allow = RSET_GPR8; dest |= FORCE_REX; - } else if (st == IRT_U8) { - op = XO_MOVZXb; allow = RSET_GPR8; dest |= FORCE_REX; - } else if (st == IRT_I16) { - op = XO_MOVSXw; - } else { - op = XO_MOVZXw; - } - left = asm_fuseload(as, lref, allow); - /* Add extra MOV if source is already in wrong register. */ - if (!LJ_64 && left != RID_MRM && !rset_test(allow, left)) { - Reg tmp = ra_scratch(as, allow); - emit_rr(as, op, dest, tmp); - emit_rr(as, XO_MOV, tmp, left); - } else { - emit_mrm(as, op, dest, left); - } - } else { /* 32/64 bit integer conversions. */ - if (LJ_32) { /* Only need to handle 32/32 bit no-op (cast) on x86. */ - Reg dest = ra_dest(as, ir, RSET_GPR); - ra_left(as, dest, lref); /* Do nothing, but may need to move regs. */ - } else if (irt_is64(ir->t)) { - Reg dest = ra_dest(as, ir, RSET_GPR); - if (st64 || !(ir->op2 & IRCONV_SEXT)) { - /* 64/64 bit no-op (cast) or 32 to 64 bit zero extension. */ - ra_left(as, dest, lref); /* Do nothing, but may need to move regs. */ - } else { /* 32 to 64 bit sign extension. */ - Reg left = asm_fuseload(as, lref, RSET_GPR); - emit_mrm(as, XO_MOVSXd, dest|REX_64, left); - } - } else { - Reg dest = ra_dest(as, ir, RSET_GPR); - if (st64) { - Reg left = asm_fuseload(as, lref, RSET_GPR); - /* This is either a 32 bit reg/reg mov which zeroes the hiword - ** or a load of the loword from a 64 bit address. - */ - emit_mrm(as, XO_MOV, dest, left); - } else { /* 32/32 bit no-op (cast). */ - ra_left(as, dest, lref); /* Do nothing, but may need to move regs. */ - } - } - } -} - -#if LJ_32 && LJ_HASFFI -/* No SSE conversions to/from 64 bit on x86, so resort to ugly x87 code. */ - -/* 64 bit integer to FP conversion in 32 bit mode. */ -static void asm_conv_fp_int64(ASMState *as, IRIns *ir) -{ - Reg hi = ra_alloc1(as, ir->op1, RSET_GPR); - Reg lo = ra_alloc1(as, (ir-1)->op1, rset_exclude(RSET_GPR, hi)); - int32_t ofs = sps_scale(ir->s); /* Use spill slot or temp slots. */ - Reg dest = ir->r; - if (ra_hasreg(dest)) { - ra_free(as, dest); - ra_modified(as, dest); - emit_rmro(as, irt_isnum(ir->t) ? XMM_MOVRM(as) : XO_MOVSS, - dest, RID_ESP, ofs); - } - emit_rmro(as, irt_isnum(ir->t) ? XO_FSTPq : XO_FSTPd, - irt_isnum(ir->t) ? XOg_FSTPq : XOg_FSTPd, RID_ESP, ofs); - if (((ir-1)->op2 & IRCONV_SRCMASK) == IRT_U64) { - /* For inputs in [2^63,2^64-1] add 2^64 to compensate. */ - MCLabel l_end = emit_label(as); - emit_rma(as, XO_FADDq, XOg_FADDq, - lj_ir_k64_find(as->J, U64x(43f00000,00000000))); - emit_sjcc(as, CC_NS, l_end); - emit_rr(as, XO_TEST, hi, hi); /* Check if u64 >= 2^63. */ - } else { - lua_assert(((ir-1)->op2 & IRCONV_SRCMASK) == IRT_I64); - } - emit_rmro(as, XO_FILDq, XOg_FILDq, RID_ESP, 0); - /* NYI: Avoid narrow-to-wide store-to-load forwarding stall. */ - emit_rmro(as, XO_MOVto, hi, RID_ESP, 4); - emit_rmro(as, XO_MOVto, lo, RID_ESP, 0); -} - -/* FP to 64 bit integer conversion in 32 bit mode. */ -static void asm_conv_int64_fp(ASMState *as, IRIns *ir) -{ - IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK); - IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH); - Reg lo, hi; - lua_assert(st == IRT_NUM || st == IRT_FLOAT); - lua_assert(dt == IRT_I64 || dt == IRT_U64); - lua_assert(((ir-1)->op2 & IRCONV_TRUNC)); - hi = ra_dest(as, ir, RSET_GPR); - lo = ra_dest(as, ir-1, rset_exclude(RSET_GPR, hi)); - if (ra_used(ir-1)) emit_rmro(as, XO_MOV, lo, RID_ESP, 0); - /* NYI: Avoid wide-to-narrow store-to-load forwarding stall. */ - if (!(as->flags & JIT_F_SSE3)) { /* Set FPU rounding mode to default. */ - emit_rmro(as, XO_FLDCW, XOg_FLDCW, RID_ESP, 4); - emit_rmro(as, XO_MOVto, lo, RID_ESP, 4); - emit_gri(as, XG_ARITHi(XOg_AND), lo, 0xf3ff); - } - if (dt == IRT_U64) { - /* For inputs in [2^63,2^64-1] add -2^64 and convert again. */ - MCLabel l_pop, l_end = emit_label(as); - emit_x87op(as, XI_FPOP); - l_pop = emit_label(as); - emit_sjmp(as, l_end); - emit_rmro(as, XO_MOV, hi, RID_ESP, 4); - if ((as->flags & JIT_F_SSE3)) - emit_rmro(as, XO_FISTTPq, XOg_FISTTPq, RID_ESP, 0); - else - emit_rmro(as, XO_FISTPq, XOg_FISTPq, RID_ESP, 0); - emit_rma(as, XO_FADDq, XOg_FADDq, - lj_ir_k64_find(as->J, U64x(c3f00000,00000000))); - emit_sjcc(as, CC_NS, l_pop); - emit_rr(as, XO_TEST, hi, hi); /* Check if out-of-range (2^63). */ - } - emit_rmro(as, XO_MOV, hi, RID_ESP, 4); - if ((as->flags & JIT_F_SSE3)) { /* Truncation is easy with SSE3. */ - emit_rmro(as, XO_FISTTPq, XOg_FISTTPq, RID_ESP, 0); - } else { /* Otherwise set FPU rounding mode to truncate before the store. */ - emit_rmro(as, XO_FISTPq, XOg_FISTPq, RID_ESP, 0); - emit_rmro(as, XO_FLDCW, XOg_FLDCW, RID_ESP, 0); - emit_rmro(as, XO_MOVtow, lo, RID_ESP, 0); - emit_rmro(as, XO_ARITHw(XOg_OR), lo, RID_ESP, 0); - emit_loadi(as, lo, 0xc00); - emit_rmro(as, XO_FNSTCW, XOg_FNSTCW, RID_ESP, 0); - } - if (dt == IRT_U64) - emit_x87op(as, XI_FDUP); - emit_mrm(as, st == IRT_NUM ? XO_FLDq : XO_FLDd, - st == IRT_NUM ? XOg_FLDq: XOg_FLDd, - asm_fuseload(as, ir->op1, RSET_EMPTY)); -} -#endif - -static void asm_strto(ASMState *as, IRIns *ir) -{ - /* Force a spill slot for the destination register (if any). */ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_strscan_num]; - IRRef args[2]; - RegSet drop = RSET_SCRATCH; - if ((drop & RSET_FPR) != RSET_FPR && ra_hasreg(ir->r)) - rset_set(drop, ir->r); /* WIN64 doesn't spill all FPRs. */ - ra_evictset(as, drop); - asm_guardcc(as, CC_E); - emit_rr(as, XO_TEST, RID_RET, RID_RET); /* Test return status. */ - args[0] = ir->op1; /* GCstr *str */ - args[1] = ASMREF_TMP1; /* TValue *n */ - asm_gencall(as, ci, args); - /* Store the result to the spill slot or temp slots. */ - emit_rmro(as, XO_LEA, ra_releasetmp(as, ASMREF_TMP1)|REX_64, - RID_ESP, sps_scale(ir->s)); -} - -static void asm_tostr(ASMState *as, IRIns *ir) -{ - IRIns *irl = IR(ir->op1); - IRRef args[2]; - args[0] = ASMREF_L; - as->gcsteps++; - if (irt_isnum(irl->t)) { - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromnum]; - args[1] = ASMREF_TMP1; /* const lua_Number * */ - asm_setupresult(as, ir, ci); /* GCstr * */ - asm_gencall(as, ci, args); - emit_rmro(as, XO_LEA, ra_releasetmp(as, ASMREF_TMP1)|REX_64, - RID_ESP, ra_spill(as, irl)); - } else { - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromint]; - args[1] = ir->op1; /* int32_t k */ - asm_setupresult(as, ir, ci); /* GCstr * */ - asm_gencall(as, ci, args); - } -} - -/* -- Memory references --------------------------------------------------- */ - -static void asm_aref(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - asm_fusearef(as, ir, RSET_GPR); - if (!(as->mrm.idx == RID_NONE && as->mrm.ofs == 0)) - emit_mrm(as, XO_LEA, dest, RID_MRM); - else if (as->mrm.base != dest) - emit_rr(as, XO_MOV, dest, as->mrm.base); -} - -/* Merge NE(HREF, niltv) check. */ -static MCode *merge_href_niltv(ASMState *as, IRIns *ir) -{ - /* Assumes nothing else generates NE of HREF. */ - if ((ir[1].o == IR_NE || ir[1].o == IR_EQ) && ir[1].op1 == as->curins && - ra_hasreg(ir->r)) { - MCode *p = as->mcp; - p += (LJ_64 && *p != XI_ARITHi) ? 7+6 : 6+6; - /* Ensure no loop branch inversion happened. */ - if (p[-6] == 0x0f && p[-5] == XI_JCCn+(CC_NE^(ir[1].o & 1))) { - as->mcp = p; /* Kill cmp reg, imm32 + jz exit. */ - return p + *(int32_t *)(p-4); /* Return exit address. */ - } - } - return NULL; -} - -/* Inlined hash lookup. Specialized for key type and for const keys. -** The equivalent C code is: -** Node *n = hashkey(t, key); -** do { -** if (lj_obj_equal(&n->key, key)) return &n->val; -** } while ((n = nextnode(n))); -** return niltv(L); -*/ -static void asm_href(ASMState *as, IRIns *ir) -{ - MCode *nilexit = merge_href_niltv(as, ir); /* Do this before any restores. */ - RegSet allow = RSET_GPR; - Reg dest = ra_dest(as, ir, allow); - Reg tab = ra_alloc1(as, ir->op1, rset_clear(allow, dest)); - Reg key = RID_NONE, tmp = RID_NONE; - IRIns *irkey = IR(ir->op2); - int isk = irref_isk(ir->op2); - IRType1 kt = irkey->t; - uint32_t khash; - MCLabel l_end, l_loop, l_next; - - if (!isk) { - rset_clear(allow, tab); - key = ra_alloc1(as, ir->op2, irt_isnum(kt) ? RSET_FPR : allow); - if (!irt_isstr(kt)) - tmp = ra_scratch(as, rset_exclude(allow, key)); - } - - /* Key not found in chain: jump to exit (if merged with NE) or load niltv. */ - l_end = emit_label(as); - if (nilexit && ir[1].o == IR_NE) { - emit_jcc(as, CC_E, nilexit); /* XI_JMP is not found by lj_asm_patchexit. */ - nilexit = NULL; - } else { - emit_loada(as, dest, niltvg(J2G(as->J))); - } - - /* Follow hash chain until the end. */ - l_loop = emit_sjcc_label(as, CC_NZ); - emit_rr(as, XO_TEST, dest, dest); - emit_rmro(as, XO_MOV, dest, dest, offsetof(Node, next)); - l_next = emit_label(as); - - /* Type and value comparison. */ - if (nilexit) - emit_jcc(as, CC_E, nilexit); - else - emit_sjcc(as, CC_E, l_end); - if (irt_isnum(kt)) { - if (isk) { - /* Assumes -0.0 is already canonicalized to +0.0. */ - emit_gmroi(as, XG_ARITHi(XOg_CMP), dest, offsetof(Node, key.u32.lo), - (int32_t)ir_knum(irkey)->u32.lo); - emit_sjcc(as, CC_NE, l_next); - emit_gmroi(as, XG_ARITHi(XOg_CMP), dest, offsetof(Node, key.u32.hi), - (int32_t)ir_knum(irkey)->u32.hi); - } else { - emit_sjcc(as, CC_P, l_next); - emit_rmro(as, XO_UCOMISD, key, dest, offsetof(Node, key.n)); - emit_sjcc(as, CC_AE, l_next); - /* The type check avoids NaN penalties and complaints from Valgrind. */ -#if LJ_64 - emit_u32(as, LJ_TISNUM); - emit_rmro(as, XO_ARITHi, XOg_CMP, dest, offsetof(Node, key.it)); -#else - emit_i8(as, LJ_TISNUM); - emit_rmro(as, XO_ARITHi8, XOg_CMP, dest, offsetof(Node, key.it)); -#endif - } -#if LJ_64 - } else if (irt_islightud(kt)) { - emit_rmro(as, XO_CMP, key|REX_64, dest, offsetof(Node, key.u64)); -#endif - } else { - if (!irt_ispri(kt)) { - lua_assert(irt_isaddr(kt)); - if (isk) - emit_gmroi(as, XG_ARITHi(XOg_CMP), dest, offsetof(Node, key.gcr), - ptr2addr(ir_kgc(irkey))); - else - emit_rmro(as, XO_CMP, key, dest, offsetof(Node, key.gcr)); - emit_sjcc(as, CC_NE, l_next); - } - lua_assert(!irt_isnil(kt)); - emit_i8(as, irt_toitype(kt)); - emit_rmro(as, XO_ARITHi8, XOg_CMP, dest, offsetof(Node, key.it)); - } - emit_sfixup(as, l_loop); - checkmclim(as); - - /* Load main position relative to tab->node into dest. */ - khash = isk ? ir_khash(irkey) : 1; - if (khash == 0) { - emit_rmro(as, XO_MOV, dest, tab, offsetof(GCtab, node)); - } else { - emit_rmro(as, XO_ARITH(XOg_ADD), dest, tab, offsetof(GCtab, node)); - if ((as->flags & JIT_F_PREFER_IMUL)) { - emit_i8(as, sizeof(Node)); - emit_rr(as, XO_IMULi8, dest, dest); - } else { - emit_shifti(as, XOg_SHL, dest, 3); - emit_rmrxo(as, XO_LEA, dest, dest, dest, XM_SCALE2, 0); - } - if (isk) { - emit_gri(as, XG_ARITHi(XOg_AND), dest, (int32_t)khash); - emit_rmro(as, XO_MOV, dest, tab, offsetof(GCtab, hmask)); - } else if (irt_isstr(kt)) { - emit_rmro(as, XO_ARITH(XOg_AND), dest, key, offsetof(GCstr, hash)); - emit_rmro(as, XO_MOV, dest, tab, offsetof(GCtab, hmask)); - } else { /* Must match with hashrot() in lj_tab.c. */ - emit_rmro(as, XO_ARITH(XOg_AND), dest, tab, offsetof(GCtab, hmask)); - emit_rr(as, XO_ARITH(XOg_SUB), dest, tmp); - emit_shifti(as, XOg_ROL, tmp, HASH_ROT3); - emit_rr(as, XO_ARITH(XOg_XOR), dest, tmp); - emit_shifti(as, XOg_ROL, dest, HASH_ROT2); - emit_rr(as, XO_ARITH(XOg_SUB), tmp, dest); - emit_shifti(as, XOg_ROL, dest, HASH_ROT1); - emit_rr(as, XO_ARITH(XOg_XOR), tmp, dest); - if (irt_isnum(kt)) { - emit_rr(as, XO_ARITH(XOg_ADD), dest, dest); -#if LJ_64 - emit_shifti(as, XOg_SHR|REX_64, dest, 32); - emit_rr(as, XO_MOV, tmp, dest); - emit_rr(as, XO_MOVDto, key|REX_64, dest); -#else - emit_rmro(as, XO_MOV, dest, RID_ESP, ra_spill(as, irkey)+4); - emit_rr(as, XO_MOVDto, key, tmp); -#endif - } else { - emit_rr(as, XO_MOV, tmp, key); - emit_rmro(as, XO_LEA, dest, key, HASH_BIAS); - } - } - } -} - -static void asm_hrefk(ASMState *as, IRIns *ir) -{ - IRIns *kslot = IR(ir->op2); - IRIns *irkey = IR(kslot->op1); - int32_t ofs = (int32_t)(kslot->op2 * sizeof(Node)); - Reg dest = ra_used(ir) ? ra_dest(as, ir, RSET_GPR) : RID_NONE; - Reg node = ra_alloc1(as, ir->op1, RSET_GPR); -#if !LJ_64 - MCLabel l_exit; -#endif - lua_assert(ofs % sizeof(Node) == 0); - if (ra_hasreg(dest)) { - if (ofs != 0) { - if (dest == node && !(as->flags & JIT_F_LEA_AGU)) - emit_gri(as, XG_ARITHi(XOg_ADD), dest, ofs); - else - emit_rmro(as, XO_LEA, dest, node, ofs); - } else if (dest != node) { - emit_rr(as, XO_MOV, dest, node); - } - } - asm_guardcc(as, CC_NE); -#if LJ_64 - if (!irt_ispri(irkey->t)) { - Reg key = ra_scratch(as, rset_exclude(RSET_GPR, node)); - emit_rmro(as, XO_CMP, key|REX_64, node, - ofs + (int32_t)offsetof(Node, key.u64)); - lua_assert(irt_isnum(irkey->t) || irt_isgcv(irkey->t)); - /* Assumes -0.0 is already canonicalized to +0.0. */ - emit_loadu64(as, key, irt_isnum(irkey->t) ? ir_knum(irkey)->u64 : - ((uint64_t)irt_toitype(irkey->t) << 32) | - (uint64_t)(uint32_t)ptr2addr(ir_kgc(irkey))); - } else { - lua_assert(!irt_isnil(irkey->t)); - emit_i8(as, irt_toitype(irkey->t)); - emit_rmro(as, XO_ARITHi8, XOg_CMP, node, - ofs + (int32_t)offsetof(Node, key.it)); - } -#else - l_exit = emit_label(as); - if (irt_isnum(irkey->t)) { - /* Assumes -0.0 is already canonicalized to +0.0. */ - emit_gmroi(as, XG_ARITHi(XOg_CMP), node, - ofs + (int32_t)offsetof(Node, key.u32.lo), - (int32_t)ir_knum(irkey)->u32.lo); - emit_sjcc(as, CC_NE, l_exit); - emit_gmroi(as, XG_ARITHi(XOg_CMP), node, - ofs + (int32_t)offsetof(Node, key.u32.hi), - (int32_t)ir_knum(irkey)->u32.hi); - } else { - if (!irt_ispri(irkey->t)) { - lua_assert(irt_isgcv(irkey->t)); - emit_gmroi(as, XG_ARITHi(XOg_CMP), node, - ofs + (int32_t)offsetof(Node, key.gcr), - ptr2addr(ir_kgc(irkey))); - emit_sjcc(as, CC_NE, l_exit); - } - lua_assert(!irt_isnil(irkey->t)); - emit_i8(as, irt_toitype(irkey->t)); - emit_rmro(as, XO_ARITHi8, XOg_CMP, node, - ofs + (int32_t)offsetof(Node, key.it)); - } -#endif -} - -static void asm_newref(ASMState *as, IRIns *ir) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_newkey]; - IRRef args[3]; - IRIns *irkey; - Reg tmp; - if (ir->r == RID_SINK) - return; - args[0] = ASMREF_L; /* lua_State *L */ - args[1] = ir->op1; /* GCtab *t */ - args[2] = ASMREF_TMP1; /* cTValue *key */ - asm_setupresult(as, ir, ci); /* TValue * */ - asm_gencall(as, ci, args); - tmp = ra_releasetmp(as, ASMREF_TMP1); - irkey = IR(ir->op2); - if (irt_isnum(irkey->t)) { - /* For numbers use the constant itself or a spill slot as a TValue. */ - if (irref_isk(ir->op2)) - emit_loada(as, tmp, ir_knum(irkey)); - else - emit_rmro(as, XO_LEA, tmp|REX_64, RID_ESP, ra_spill(as, irkey)); - } else { - /* Otherwise use g->tmptv to hold the TValue. */ - if (!irref_isk(ir->op2)) { - Reg src = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, tmp)); - emit_movtomro(as, REX_64IR(irkey, src), tmp, 0); - } else if (!irt_ispri(irkey->t)) { - emit_movmroi(as, tmp, 0, irkey->i); - } - if (!(LJ_64 && irt_islightud(irkey->t))) - emit_movmroi(as, tmp, 4, irt_toitype(irkey->t)); - emit_loada(as, tmp, &J2G(as->J)->tmptv); - } -} - -static void asm_uref(ASMState *as, IRIns *ir) -{ - /* NYI: Check that UREFO is still open and not aliasing a slot. */ - Reg dest = ra_dest(as, ir, RSET_GPR); - if (irref_isk(ir->op1)) { - GCfunc *fn = ir_kfunc(IR(ir->op1)); - MRef *v = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.v; - emit_rma(as, XO_MOV, dest, v); - } else { - Reg uv = ra_scratch(as, RSET_GPR); - Reg func = ra_alloc1(as, ir->op1, RSET_GPR); - if (ir->o == IR_UREFC) { - emit_rmro(as, XO_LEA, dest, uv, offsetof(GCupval, tv)); - asm_guardcc(as, CC_NE); - emit_i8(as, 1); - emit_rmro(as, XO_ARITHib, XOg_CMP, uv, offsetof(GCupval, closed)); - } else { - emit_rmro(as, XO_MOV, dest, uv, offsetof(GCupval, v)); - } - emit_rmro(as, XO_MOV, uv, func, - (int32_t)offsetof(GCfuncL, uvptr) + 4*(int32_t)(ir->op2 >> 8)); - } -} - -static void asm_fref(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - asm_fusefref(as, ir, RSET_GPR); - emit_mrm(as, XO_LEA, dest, RID_MRM); -} - -static void asm_strref(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - asm_fusestrref(as, ir, RSET_GPR); - if (as->mrm.base == RID_NONE) - emit_loadi(as, dest, as->mrm.ofs); - else if (as->mrm.base == dest && as->mrm.idx == RID_NONE) - emit_gri(as, XG_ARITHi(XOg_ADD), dest, as->mrm.ofs); - else - emit_mrm(as, XO_LEA, dest, RID_MRM); -} - -/* -- Loads and stores ---------------------------------------------------- */ - -static void asm_fxload(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); - x86Op xo; - if (ir->o == IR_FLOAD) - asm_fusefref(as, ir, RSET_GPR); - else - asm_fusexref(as, ir->op1, RSET_GPR); - /* ir->op2 is ignored -- unaligned loads are ok on x86. */ - switch (irt_type(ir->t)) { - case IRT_I8: xo = XO_MOVSXb; break; - case IRT_U8: xo = XO_MOVZXb; break; - case IRT_I16: xo = XO_MOVSXw; break; - case IRT_U16: xo = XO_MOVZXw; break; - case IRT_NUM: xo = XMM_MOVRM(as); break; - case IRT_FLOAT: xo = XO_MOVSS; break; - default: - if (LJ_64 && irt_is64(ir->t)) - dest |= REX_64; - else - lua_assert(irt_isint(ir->t) || irt_isu32(ir->t) || irt_isaddr(ir->t)); - xo = XO_MOV; - break; - } - emit_mrm(as, xo, dest, RID_MRM); -} - -static void asm_fxstore(ASMState *as, IRIns *ir) -{ - RegSet allow = RSET_GPR; - Reg src = RID_NONE, osrc = RID_NONE; - int32_t k = 0; - if (ir->r == RID_SINK) - return; - /* The IRT_I16/IRT_U16 stores should never be simplified for constant - ** values since mov word [mem], imm16 has a length-changing prefix. - */ - if (irt_isi16(ir->t) || irt_isu16(ir->t) || irt_isfp(ir->t) || - !asm_isk32(as, ir->op2, &k)) { - RegSet allow8 = irt_isfp(ir->t) ? RSET_FPR : - (irt_isi8(ir->t) || irt_isu8(ir->t)) ? RSET_GPR8 : RSET_GPR; - src = osrc = ra_alloc1(as, ir->op2, allow8); - if (!LJ_64 && !rset_test(allow8, src)) { /* Already in wrong register. */ - rset_clear(allow, osrc); - src = ra_scratch(as, allow8); - } - rset_clear(allow, src); - } - if (ir->o == IR_FSTORE) { - asm_fusefref(as, IR(ir->op1), allow); - } else { - asm_fusexref(as, ir->op1, allow); - if (LJ_32 && ir->o == IR_HIOP) as->mrm.ofs += 4; - } - if (ra_hasreg(src)) { - x86Op xo; - switch (irt_type(ir->t)) { - case IRT_I8: case IRT_U8: xo = XO_MOVtob; src |= FORCE_REX; break; - case IRT_I16: case IRT_U16: xo = XO_MOVtow; break; - case IRT_NUM: xo = XO_MOVSDto; break; - case IRT_FLOAT: xo = XO_MOVSSto; break; -#if LJ_64 - case IRT_LIGHTUD: lua_assert(0); /* NYI: mask 64 bit lightuserdata. */ -#endif - default: - if (LJ_64 && irt_is64(ir->t)) - src |= REX_64; - else - lua_assert(irt_isint(ir->t) || irt_isu32(ir->t) || irt_isaddr(ir->t)); - xo = XO_MOVto; - break; - } - emit_mrm(as, xo, src, RID_MRM); - if (!LJ_64 && src != osrc) { - ra_noweak(as, osrc); - emit_rr(as, XO_MOV, src, osrc); - } - } else { - if (irt_isi8(ir->t) || irt_isu8(ir->t)) { - emit_i8(as, k); - emit_mrm(as, XO_MOVmib, 0, RID_MRM); - } else { - lua_assert(irt_is64(ir->t) || irt_isint(ir->t) || irt_isu32(ir->t) || - irt_isaddr(ir->t)); - emit_i32(as, k); - emit_mrm(as, XO_MOVmi, REX_64IR(ir, 0), RID_MRM); - } - } -} - -#if LJ_64 -static Reg asm_load_lightud64(ASMState *as, IRIns *ir, int typecheck) -{ - if (ra_used(ir) || typecheck) { - Reg dest = ra_dest(as, ir, RSET_GPR); - if (typecheck) { - Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, dest)); - asm_guardcc(as, CC_NE); - emit_i8(as, -2); - emit_rr(as, XO_ARITHi8, XOg_CMP, tmp); - emit_shifti(as, XOg_SAR|REX_64, tmp, 47); - emit_rr(as, XO_MOV, tmp|REX_64, dest); - } - return dest; - } else { - return RID_NONE; - } -} -#endif - -static void asm_ahuvload(ASMState *as, IRIns *ir) -{ - lua_assert(irt_isnum(ir->t) || irt_ispri(ir->t) || irt_isaddr(ir->t) || - (LJ_DUALNUM && irt_isint(ir->t))); -#if LJ_64 - if (irt_islightud(ir->t)) { - Reg dest = asm_load_lightud64(as, ir, 1); - if (ra_hasreg(dest)) { - asm_fuseahuref(as, ir->op1, RSET_GPR); - emit_mrm(as, XO_MOV, dest|REX_64, RID_MRM); - } - return; - } else -#endif - if (ra_used(ir)) { - RegSet allow = irt_isnum(ir->t) ? RSET_FPR : RSET_GPR; - Reg dest = ra_dest(as, ir, allow); - asm_fuseahuref(as, ir->op1, RSET_GPR); - emit_mrm(as, dest < RID_MAX_GPR ? XO_MOV : XMM_MOVRM(as), dest, RID_MRM); - } else { - asm_fuseahuref(as, ir->op1, RSET_GPR); - } - /* Always do the type check, even if the load result is unused. */ - as->mrm.ofs += 4; - asm_guardcc(as, irt_isnum(ir->t) ? CC_AE : CC_NE); - if (LJ_64 && irt_type(ir->t) >= IRT_NUM) { - lua_assert(irt_isinteger(ir->t) || irt_isnum(ir->t)); - emit_u32(as, LJ_TISNUM); - emit_mrm(as, XO_ARITHi, XOg_CMP, RID_MRM); - } else { - emit_i8(as, irt_toitype(ir->t)); - emit_mrm(as, XO_ARITHi8, XOg_CMP, RID_MRM); - } -} - -static void asm_ahustore(ASMState *as, IRIns *ir) -{ - if (ir->r == RID_SINK) - return; - if (irt_isnum(ir->t)) { - Reg src = ra_alloc1(as, ir->op2, RSET_FPR); - asm_fuseahuref(as, ir->op1, RSET_GPR); - emit_mrm(as, XO_MOVSDto, src, RID_MRM); -#if LJ_64 - } else if (irt_islightud(ir->t)) { - Reg src = ra_alloc1(as, ir->op2, RSET_GPR); - asm_fuseahuref(as, ir->op1, rset_exclude(RSET_GPR, src)); - emit_mrm(as, XO_MOVto, src|REX_64, RID_MRM); -#endif - } else { - IRIns *irr = IR(ir->op2); - RegSet allow = RSET_GPR; - Reg src = RID_NONE; - if (!irref_isk(ir->op2)) { - src = ra_alloc1(as, ir->op2, allow); - rset_clear(allow, src); - } - asm_fuseahuref(as, ir->op1, allow); - if (ra_hasreg(src)) { - emit_mrm(as, XO_MOVto, src, RID_MRM); - } else if (!irt_ispri(irr->t)) { - lua_assert(irt_isaddr(ir->t) || (LJ_DUALNUM && irt_isinteger(ir->t))); - emit_i32(as, irr->i); - emit_mrm(as, XO_MOVmi, 0, RID_MRM); - } - as->mrm.ofs += 4; - emit_i32(as, (int32_t)irt_toitype(ir->t)); - emit_mrm(as, XO_MOVmi, 0, RID_MRM); - } -} - -static void asm_sload(ASMState *as, IRIns *ir) -{ - int32_t ofs = 8*((int32_t)ir->op1-1) + ((ir->op2 & IRSLOAD_FRAME) ? 4 : 0); - IRType1 t = ir->t; - Reg base; - lua_assert(!(ir->op2 & IRSLOAD_PARENT)); /* Handled by asm_head_side(). */ - lua_assert(irt_isguard(t) || !(ir->op2 & IRSLOAD_TYPECHECK)); - lua_assert(LJ_DUALNUM || - !irt_isint(t) || (ir->op2 & (IRSLOAD_CONVERT|IRSLOAD_FRAME))); - if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(t) && irt_isint(t)) { - Reg left = ra_scratch(as, RSET_FPR); - asm_tointg(as, ir, left); /* Frees dest reg. Do this before base alloc. */ - base = ra_alloc1(as, REF_BASE, RSET_GPR); - emit_rmro(as, XMM_MOVRM(as), left, base, ofs); - t.irt = IRT_NUM; /* Continue with a regular number type check. */ -#if LJ_64 - } else if (irt_islightud(t)) { - Reg dest = asm_load_lightud64(as, ir, (ir->op2 & IRSLOAD_TYPECHECK)); - if (ra_hasreg(dest)) { - base = ra_alloc1(as, REF_BASE, RSET_GPR); - emit_rmro(as, XO_MOV, dest|REX_64, base, ofs); - } - return; -#endif - } else if (ra_used(ir)) { - RegSet allow = irt_isnum(t) ? RSET_FPR : RSET_GPR; - Reg dest = ra_dest(as, ir, allow); - base = ra_alloc1(as, REF_BASE, RSET_GPR); - lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); - if ((ir->op2 & IRSLOAD_CONVERT)) { - t.irt = irt_isint(t) ? IRT_NUM : IRT_INT; /* Check for original type. */ - emit_rmro(as, irt_isint(t) ? XO_CVTSI2SD : XO_CVTSD2SI, dest, base, ofs); - } else if (irt_isnum(t)) { - emit_rmro(as, XMM_MOVRM(as), dest, base, ofs); - } else { - emit_rmro(as, XO_MOV, dest, base, ofs); - } - } else { - if (!(ir->op2 & IRSLOAD_TYPECHECK)) - return; /* No type check: avoid base alloc. */ - base = ra_alloc1(as, REF_BASE, RSET_GPR); - } - if ((ir->op2 & IRSLOAD_TYPECHECK)) { - /* Need type check, even if the load result is unused. */ - asm_guardcc(as, irt_isnum(t) ? CC_AE : CC_NE); - if (LJ_64 && irt_type(t) >= IRT_NUM) { - lua_assert(irt_isinteger(t) || irt_isnum(t)); - emit_u32(as, LJ_TISNUM); - emit_rmro(as, XO_ARITHi, XOg_CMP, base, ofs+4); - } else { - emit_i8(as, irt_toitype(t)); - emit_rmro(as, XO_ARITHi8, XOg_CMP, base, ofs+4); - } - } -} - -/* -- Allocations --------------------------------------------------------- */ - -#if LJ_HASFFI -static void asm_cnew(ASMState *as, IRIns *ir) -{ - CTState *cts = ctype_ctsG(J2G(as->J)); - CTypeID ctypeid = (CTypeID)IR(ir->op1)->i; - CTSize sz = (ir->o == IR_CNEWI || ir->op2 == REF_NIL) ? - lj_ctype_size(cts, ctypeid) : (CTSize)IR(ir->op2)->i; - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco]; - IRRef args[2]; - lua_assert(sz != CTSIZE_INVALID); - - args[0] = ASMREF_L; /* lua_State *L */ - args[1] = ASMREF_TMP1; /* MSize size */ - as->gcsteps++; - asm_setupresult(as, ir, ci); /* GCcdata * */ - - /* Initialize immutable cdata object. */ - if (ir->o == IR_CNEWI) { - RegSet allow = (RSET_GPR & ~RSET_SCRATCH); -#if LJ_64 - Reg r64 = sz == 8 ? REX_64 : 0; - if (irref_isk(ir->op2)) { - IRIns *irk = IR(ir->op2); - uint64_t k = irk->o == IR_KINT64 ? ir_k64(irk)->u64 : - (uint64_t)(uint32_t)irk->i; - if (sz == 4 || checki32((int64_t)k)) { - emit_i32(as, (int32_t)k); - emit_rmro(as, XO_MOVmi, r64, RID_RET, sizeof(GCcdata)); - } else { - emit_movtomro(as, RID_ECX + r64, RID_RET, sizeof(GCcdata)); - emit_loadu64(as, RID_ECX, k); - } - } else { - Reg r = ra_alloc1(as, ir->op2, allow); - emit_movtomro(as, r + r64, RID_RET, sizeof(GCcdata)); - } -#else - int32_t ofs = sizeof(GCcdata); - if (sz == 8) { - ofs += 4; ir++; - lua_assert(ir->o == IR_HIOP); - } - do { - if (irref_isk(ir->op2)) { - emit_movmroi(as, RID_RET, ofs, IR(ir->op2)->i); - } else { - Reg r = ra_alloc1(as, ir->op2, allow); - emit_movtomro(as, r, RID_RET, ofs); - rset_clear(allow, r); - } - if (ofs == sizeof(GCcdata)) break; - ofs -= 4; ir--; - } while (1); -#endif - lua_assert(sz == 4 || sz == 8); - } - - /* Combine initialization of marked, gct and ctypeid. */ - emit_movtomro(as, RID_ECX, RID_RET, offsetof(GCcdata, marked)); - emit_gri(as, XG_ARITHi(XOg_OR), RID_ECX, - (int32_t)((~LJ_TCDATA<<8)+(ctypeid<<16))); - emit_gri(as, XG_ARITHi(XOg_AND), RID_ECX, LJ_GC_WHITES); - emit_opgl(as, XO_MOVZXb, RID_ECX, gc.currentwhite); - - asm_gencall(as, ci, args); - emit_loadi(as, ra_releasetmp(as, ASMREF_TMP1), (int32_t)(sz+sizeof(GCcdata))); -} -#else -#define asm_cnew(as, ir) ((void)0) -#endif - -/* -- Write barriers ------------------------------------------------------ */ - -static void asm_tbar(ASMState *as, IRIns *ir) -{ - Reg tab = ra_alloc1(as, ir->op1, RSET_GPR); - Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, tab)); - MCLabel l_end = emit_label(as); - emit_movtomro(as, tmp, tab, offsetof(GCtab, gclist)); - emit_setgl(as, tab, gc.grayagain); - emit_getgl(as, tmp, gc.grayagain); - emit_i8(as, ~LJ_GC_BLACK); - emit_rmro(as, XO_ARITHib, XOg_AND, tab, offsetof(GCtab, marked)); - emit_sjcc(as, CC_Z, l_end); - emit_i8(as, LJ_GC_BLACK); - emit_rmro(as, XO_GROUP3b, XOg_TEST, tab, offsetof(GCtab, marked)); -} - -static void asm_obar(ASMState *as, IRIns *ir) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_barrieruv]; - IRRef args[2]; - MCLabel l_end; - Reg obj; - /* No need for other object barriers (yet). */ - lua_assert(IR(ir->op1)->o == IR_UREFC); - ra_evictset(as, RSET_SCRATCH); - l_end = emit_label(as); - args[0] = ASMREF_TMP1; /* global_State *g */ - args[1] = ir->op1; /* TValue *tv */ - asm_gencall(as, ci, args); - emit_loada(as, ra_releasetmp(as, ASMREF_TMP1), J2G(as->J)); - obj = IR(ir->op1)->r; - emit_sjcc(as, CC_Z, l_end); - emit_i8(as, LJ_GC_WHITES); - if (irref_isk(ir->op2)) { - GCobj *vp = ir_kgc(IR(ir->op2)); - emit_rma(as, XO_GROUP3b, XOg_TEST, &vp->gch.marked); - } else { - Reg val = ra_alloc1(as, ir->op2, rset_exclude(RSET_SCRATCH&RSET_GPR, obj)); - emit_rmro(as, XO_GROUP3b, XOg_TEST, val, (int32_t)offsetof(GChead, marked)); - } - emit_sjcc(as, CC_Z, l_end); - emit_i8(as, LJ_GC_BLACK); - emit_rmro(as, XO_GROUP3b, XOg_TEST, obj, - (int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)); -} - -/* -- FP/int arithmetic and logic operations ------------------------------ */ - -/* Load reference onto x87 stack. Force a spill to memory if needed. */ -static void asm_x87load(ASMState *as, IRRef ref) -{ - IRIns *ir = IR(ref); - if (ir->o == IR_KNUM) { - cTValue *tv = ir_knum(ir); - if (tvispzero(tv)) /* Use fldz only for +0. */ - emit_x87op(as, XI_FLDZ); - else if (tvispone(tv)) - emit_x87op(as, XI_FLD1); - else - emit_rma(as, XO_FLDq, XOg_FLDq, tv); - } else if (ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT && !ra_used(ir) && - !irref_isk(ir->op1) && mayfuse(as, ir->op1)) { - IRIns *iri = IR(ir->op1); - emit_rmro(as, XO_FILDd, XOg_FILDd, RID_ESP, ra_spill(as, iri)); - } else { - emit_mrm(as, XO_FLDq, XOg_FLDq, asm_fuseload(as, ref, RSET_EMPTY)); - } -} - -/* Try to rejoin pow from EXP2, MUL and LOG2 (if still unsplit). */ -static int fpmjoin_pow(ASMState *as, IRIns *ir) -{ - IRIns *irp = IR(ir->op1); - if (irp == ir-1 && irp->o == IR_MUL && !ra_used(irp)) { - IRIns *irpp = IR(irp->op1); - if (irpp == ir-2 && irpp->o == IR_FPMATH && - irpp->op2 == IRFPM_LOG2 && !ra_used(irpp)) { - /* The modified regs must match with the *.dasc implementation. */ - RegSet drop = RSET_RANGE(RID_XMM0, RID_XMM2+1)|RID2RSET(RID_EAX); - IRIns *irx; - if (ra_hasreg(ir->r)) - rset_clear(drop, ir->r); /* Dest reg handled below. */ - ra_evictset(as, drop); - ra_destreg(as, ir, RID_XMM0); - emit_call(as, lj_vm_pow_sse); - irx = IR(irpp->op1); - if (ra_noreg(irx->r) && ra_gethint(irx->r) == RID_XMM1) - irx->r = RID_INIT; /* Avoid allocating xmm1 for x. */ - ra_left(as, RID_XMM0, irpp->op1); - ra_left(as, RID_XMM1, irp->op2); - return 1; - } - } - return 0; -} - -static void asm_fpmath(ASMState *as, IRIns *ir) -{ - IRFPMathOp fpm = ir->o == IR_FPMATH ? (IRFPMathOp)ir->op2 : IRFPM_OTHER; - if (fpm == IRFPM_SQRT) { - Reg dest = ra_dest(as, ir, RSET_FPR); - Reg left = asm_fuseload(as, ir->op1, RSET_FPR); - emit_mrm(as, XO_SQRTSD, dest, left); - } else if (fpm <= IRFPM_TRUNC) { - if (as->flags & JIT_F_SSE4_1) { /* SSE4.1 has a rounding instruction. */ - Reg dest = ra_dest(as, ir, RSET_FPR); - Reg left = asm_fuseload(as, ir->op1, RSET_FPR); - /* ROUNDSD has a 4-byte opcode which doesn't fit in x86Op. - ** Let's pretend it's a 3-byte opcode, and compensate afterwards. - ** This is atrocious, but the alternatives are much worse. - */ - /* Round down/up/trunc == 1001/1010/1011. */ - emit_i8(as, 0x09 + fpm); - emit_mrm(as, XO_ROUNDSD, dest, left); - if (LJ_64 && as->mcp[1] != (MCode)(XO_ROUNDSD >> 16)) { - as->mcp[0] = as->mcp[1]; as->mcp[1] = 0x0f; /* Swap 0F and REX. */ - } - *--as->mcp = 0x66; /* 1st byte of ROUNDSD opcode. */ - } else { /* Call helper functions for SSE2 variant. */ - /* The modified regs must match with the *.dasc implementation. */ - RegSet drop = RSET_RANGE(RID_XMM0, RID_XMM3+1)|RID2RSET(RID_EAX); - if (ra_hasreg(ir->r)) - rset_clear(drop, ir->r); /* Dest reg handled below. */ - ra_evictset(as, drop); - ra_destreg(as, ir, RID_XMM0); - emit_call(as, fpm == IRFPM_FLOOR ? lj_vm_floor_sse : - fpm == IRFPM_CEIL ? lj_vm_ceil_sse : lj_vm_trunc_sse); - ra_left(as, RID_XMM0, ir->op1); - } - } else if (fpm == IRFPM_EXP2 && fpmjoin_pow(as, ir)) { - /* Rejoined to pow(). */ - } else { /* Handle x87 ops. */ - int32_t ofs = sps_scale(ir->s); /* Use spill slot or temp slots. */ - Reg dest = ir->r; - if (ra_hasreg(dest)) { - ra_free(as, dest); - ra_modified(as, dest); - emit_rmro(as, XMM_MOVRM(as), dest, RID_ESP, ofs); - } - emit_rmro(as, XO_FSTPq, XOg_FSTPq, RID_ESP, ofs); - switch (fpm) { /* st0 = lj_vm_*(st0) */ - case IRFPM_EXP: emit_call(as, lj_vm_exp_x87); break; - case IRFPM_EXP2: emit_call(as, lj_vm_exp2_x87); break; - case IRFPM_SIN: emit_x87op(as, XI_FSIN); break; - case IRFPM_COS: emit_x87op(as, XI_FCOS); break; - case IRFPM_TAN: emit_x87op(as, XI_FPOP); emit_x87op(as, XI_FPTAN); break; - case IRFPM_LOG: case IRFPM_LOG2: case IRFPM_LOG10: - /* Note: the use of fyl2xp1 would be pointless here. When computing - ** log(1.0+eps) the precision is already lost after 1.0 is added. - ** Subtracting 1.0 won't recover it. OTOH math.log1p would make sense. - */ - emit_x87op(as, XI_FYL2X); break; - case IRFPM_OTHER: - switch (ir->o) { - case IR_ATAN2: - emit_x87op(as, XI_FPATAN); asm_x87load(as, ir->op2); break; - case IR_LDEXP: - emit_x87op(as, XI_FPOP1); emit_x87op(as, XI_FSCALE); break; - default: lua_assert(0); break; - } - break; - default: lua_assert(0); break; - } - asm_x87load(as, ir->op1); - switch (fpm) { - case IRFPM_LOG: emit_x87op(as, XI_FLDLN2); break; - case IRFPM_LOG2: emit_x87op(as, XI_FLD1); break; - case IRFPM_LOG10: emit_x87op(as, XI_FLDLG2); break; - case IRFPM_OTHER: - if (ir->o == IR_LDEXP) asm_x87load(as, ir->op2); - break; - default: break; - } - } -} - -static void asm_fppowi(ASMState *as, IRIns *ir) -{ - /* The modified regs must match with the *.dasc implementation. */ - RegSet drop = RSET_RANGE(RID_XMM0, RID_XMM1+1)|RID2RSET(RID_EAX); - if (ra_hasreg(ir->r)) - rset_clear(drop, ir->r); /* Dest reg handled below. */ - ra_evictset(as, drop); - ra_destreg(as, ir, RID_XMM0); - emit_call(as, lj_vm_powi_sse); - ra_left(as, RID_XMM0, ir->op1); - ra_left(as, RID_EAX, ir->op2); -} - -#if LJ_64 && LJ_HASFFI -static void asm_arith64(ASMState *as, IRIns *ir, IRCallID id) -{ - const CCallInfo *ci = &lj_ir_callinfo[id]; - IRRef args[2]; - args[0] = ir->op1; - args[1] = ir->op2; - asm_setupresult(as, ir, ci); - asm_gencall(as, ci, args); -} -#endif - -static void asm_intmod(ASMState *as, IRIns *ir) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_vm_modi]; - IRRef args[2]; - args[0] = ir->op1; - args[1] = ir->op2; - asm_setupresult(as, ir, ci); - asm_gencall(as, ci, args); -} - -static int asm_swapops(ASMState *as, IRIns *ir) -{ - IRIns *irl = IR(ir->op1); - IRIns *irr = IR(ir->op2); - lua_assert(ra_noreg(irr->r)); - if (!irm_iscomm(lj_ir_mode[ir->o])) - return 0; /* Can't swap non-commutative operations. */ - if (irref_isk(ir->op2)) - return 0; /* Don't swap constants to the left. */ - if (ra_hasreg(irl->r)) - return 1; /* Swap if left already has a register. */ - if (ra_samehint(ir->r, irr->r)) - return 1; /* Swap if dest and right have matching hints. */ - if (as->curins > as->loopref) { /* In variant part? */ - if (ir->op2 < as->loopref && !irt_isphi(irr->t)) - return 0; /* Keep invariants on the right. */ - if (ir->op1 < as->loopref && !irt_isphi(irl->t)) - return 1; /* Swap invariants to the right. */ - } - if (opisfusableload(irl->o)) - return 1; /* Swap fusable loads to the right. */ - return 0; /* Otherwise don't swap. */ -} - -static void asm_fparith(ASMState *as, IRIns *ir, x86Op xo) -{ - IRRef lref = ir->op1; - IRRef rref = ir->op2; - RegSet allow = RSET_FPR; - Reg dest; - Reg right = IR(rref)->r; - if (ra_hasreg(right)) { - rset_clear(allow, right); - ra_noweak(as, right); - } - dest = ra_dest(as, ir, allow); - if (lref == rref) { - right = dest; - } else if (ra_noreg(right)) { - if (asm_swapops(as, ir)) { - IRRef tmp = lref; lref = rref; rref = tmp; - } - right = asm_fuseload(as, rref, rset_clear(allow, dest)); - } - emit_mrm(as, xo, dest, right); - ra_left(as, dest, lref); -} - -static void asm_intarith(ASMState *as, IRIns *ir, x86Arith xa) -{ - IRRef lref = ir->op1; - IRRef rref = ir->op2; - RegSet allow = RSET_GPR; - Reg dest, right; - int32_t k = 0; - if (as->flagmcp == as->mcp) { /* Drop test r,r instruction. */ - as->flagmcp = NULL; - as->mcp += (LJ_64 && *as->mcp < XI_TESTb) ? 3 : 2; - } - right = IR(rref)->r; - if (ra_hasreg(right)) { - rset_clear(allow, right); - ra_noweak(as, right); - } - dest = ra_dest(as, ir, allow); - if (lref == rref) { - right = dest; - } else if (ra_noreg(right) && !asm_isk32(as, rref, &k)) { - if (asm_swapops(as, ir)) { - IRRef tmp = lref; lref = rref; rref = tmp; - } - right = asm_fuseloadm(as, rref, rset_clear(allow, dest), irt_is64(ir->t)); - } - if (irt_isguard(ir->t)) /* For IR_ADDOV etc. */ - asm_guardcc(as, CC_O); - if (xa != XOg_X_IMUL) { - if (ra_hasreg(right)) - emit_mrm(as, XO_ARITH(xa), REX_64IR(ir, dest), right); - else - emit_gri(as, XG_ARITHi(xa), REX_64IR(ir, dest), k); - } else if (ra_hasreg(right)) { /* IMUL r, mrm. */ - emit_mrm(as, XO_IMUL, REX_64IR(ir, dest), right); - } else { /* IMUL r, r, k. */ - /* NYI: use lea/shl/add/sub (FOLD only does 2^k) depending on CPU. */ - Reg left = asm_fuseloadm(as, lref, RSET_GPR, irt_is64(ir->t)); - x86Op xo; - if (checki8(k)) { emit_i8(as, k); xo = XO_IMULi8; - } else { emit_i32(as, k); xo = XO_IMULi; } - emit_mrm(as, xo, REX_64IR(ir, dest), left); - return; - } - ra_left(as, dest, lref); -} - -/* LEA is really a 4-operand ADD with an independent destination register, -** up to two source registers and an immediate. One register can be scaled -** by 1, 2, 4 or 8. This can be used to avoid moves or to fuse several -** instructions. -** -** Currently only a few common cases are supported: -** - 3-operand ADD: y = a+b; y = a+k with a and b already allocated -** - Left ADD fusion: y = (a+b)+k; y = (a+k)+b -** - Right ADD fusion: y = a+(b+k) -** The ommited variants have already been reduced by FOLD. -** -** There are more fusion opportunities, like gathering shifts or joining -** common references. But these are probably not worth the trouble, since -** array indexing is not decomposed and already makes use of all fields -** of the ModRM operand. -*/ -static int asm_lea(ASMState *as, IRIns *ir) -{ - IRIns *irl = IR(ir->op1); - IRIns *irr = IR(ir->op2); - RegSet allow = RSET_GPR; - Reg dest; - as->mrm.base = as->mrm.idx = RID_NONE; - as->mrm.scale = XM_SCALE1; - as->mrm.ofs = 0; - if (ra_hasreg(irl->r)) { - rset_clear(allow, irl->r); - ra_noweak(as, irl->r); - as->mrm.base = irl->r; - if (irref_isk(ir->op2) || ra_hasreg(irr->r)) { - /* The PHI renaming logic does a better job in some cases. */ - if (ra_hasreg(ir->r) && - ((irt_isphi(irl->t) && as->phireg[ir->r] == ir->op1) || - (irt_isphi(irr->t) && as->phireg[ir->r] == ir->op2))) - return 0; - if (irref_isk(ir->op2)) { - as->mrm.ofs = irr->i; - } else { - rset_clear(allow, irr->r); - ra_noweak(as, irr->r); - as->mrm.idx = irr->r; - } - } else if (irr->o == IR_ADD && mayfuse(as, ir->op2) && - irref_isk(irr->op2)) { - Reg idx = ra_alloc1(as, irr->op1, allow); - rset_clear(allow, idx); - as->mrm.idx = (uint8_t)idx; - as->mrm.ofs = IR(irr->op2)->i; - } else { - return 0; - } - } else if (ir->op1 != ir->op2 && irl->o == IR_ADD && mayfuse(as, ir->op1) && - (irref_isk(ir->op2) || irref_isk(irl->op2))) { - Reg idx, base = ra_alloc1(as, irl->op1, allow); - rset_clear(allow, base); - as->mrm.base = (uint8_t)base; - if (irref_isk(ir->op2)) { - as->mrm.ofs = irr->i; - idx = ra_alloc1(as, irl->op2, allow); - } else { - as->mrm.ofs = IR(irl->op2)->i; - idx = ra_alloc1(as, ir->op2, allow); - } - rset_clear(allow, idx); - as->mrm.idx = (uint8_t)idx; - } else { - return 0; - } - dest = ra_dest(as, ir, allow); - emit_mrm(as, XO_LEA, dest, RID_MRM); - return 1; /* Success. */ -} - -static void asm_add(ASMState *as, IRIns *ir) -{ - if (irt_isnum(ir->t)) - asm_fparith(as, ir, XO_ADDSD); - else if ((as->flags & JIT_F_LEA_AGU) || as->flagmcp == as->mcp || - irt_is64(ir->t) || !asm_lea(as, ir)) - asm_intarith(as, ir, XOg_ADD); -} - -static void asm_neg_not(ASMState *as, IRIns *ir, x86Group3 xg) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - emit_rr(as, XO_GROUP3, REX_64IR(ir, xg), dest); - ra_left(as, dest, ir->op1); -} - -static void asm_min_max(ASMState *as, IRIns *ir, int cc) -{ - Reg right, dest = ra_dest(as, ir, RSET_GPR); - IRRef lref = ir->op1, rref = ir->op2; - if (irref_isk(rref)) { lref = rref; rref = ir->op1; } - right = ra_alloc1(as, rref, rset_exclude(RSET_GPR, dest)); - emit_rr(as, XO_CMOV + (cc<<24), REX_64IR(ir, dest), right); - emit_rr(as, XO_CMP, REX_64IR(ir, dest), right); - ra_left(as, dest, lref); -} - -static void asm_bitswap(ASMState *as, IRIns *ir) -{ - Reg dest = ra_dest(as, ir, RSET_GPR); - as->mcp = emit_op(XO_BSWAP + ((dest&7) << 24), - REX_64IR(ir, 0), dest, 0, as->mcp, 1); - ra_left(as, dest, ir->op1); -} - -static void asm_bitshift(ASMState *as, IRIns *ir, x86Shift xs) -{ - IRRef rref = ir->op2; - IRIns *irr = IR(rref); - Reg dest; - if (irref_isk(rref)) { /* Constant shifts. */ - int shift; - dest = ra_dest(as, ir, RSET_GPR); - shift = irr->i & (irt_is64(ir->t) ? 63 : 31); - switch (shift) { - case 0: break; - case 1: emit_rr(as, XO_SHIFT1, REX_64IR(ir, xs), dest); break; - default: emit_shifti(as, REX_64IR(ir, xs), dest, shift); break; - } - } else { /* Variable shifts implicitly use register cl (i.e. ecx). */ - Reg right; - dest = ra_dest(as, ir, rset_exclude(RSET_GPR, RID_ECX)); - if (dest == RID_ECX) { - dest = ra_scratch(as, rset_exclude(RSET_GPR, RID_ECX)); - emit_rr(as, XO_MOV, RID_ECX, dest); - } - right = irr->r; - if (ra_noreg(right)) - right = ra_allocref(as, rref, RID2RSET(RID_ECX)); - else if (right != RID_ECX) - ra_scratch(as, RID2RSET(RID_ECX)); - emit_rr(as, XO_SHIFTcl, REX_64IR(ir, xs), dest); - ra_noweak(as, right); - if (right != RID_ECX) - emit_rr(as, XO_MOV, RID_ECX, right); - } - ra_left(as, dest, ir->op1); - /* - ** Note: avoid using the flags resulting from a shift or rotate! - ** All of them cause a partial flag stall, except for r,1 shifts - ** (but not rotates). And a shift count of 0 leaves the flags unmodified. - */ -} - -/* -- Comparisons --------------------------------------------------------- */ - -/* Virtual flags for unordered FP comparisons. */ -#define VCC_U 0x1000 /* Unordered. */ -#define VCC_P 0x2000 /* Needs extra CC_P branch. */ -#define VCC_S 0x4000 /* Swap avoids CC_P branch. */ -#define VCC_PS (VCC_P|VCC_S) - -/* Map of comparisons to flags. ORDER IR. */ -#define COMPFLAGS(ci, cin, cu, cf) ((ci)+((cu)<<4)+((cin)<<8)+(cf)) -static const uint16_t asm_compmap[IR_ABC+1] = { - /* signed non-eq unsigned flags */ - /* LT */ COMPFLAGS(CC_GE, CC_G, CC_AE, VCC_PS), - /* GE */ COMPFLAGS(CC_L, CC_L, CC_B, 0), - /* LE */ COMPFLAGS(CC_G, CC_G, CC_A, VCC_PS), - /* GT */ COMPFLAGS(CC_LE, CC_L, CC_BE, 0), - /* ULT */ COMPFLAGS(CC_AE, CC_A, CC_AE, VCC_U), - /* UGE */ COMPFLAGS(CC_B, CC_B, CC_B, VCC_U|VCC_PS), - /* ULE */ COMPFLAGS(CC_A, CC_A, CC_A, VCC_U), - /* UGT */ COMPFLAGS(CC_BE, CC_B, CC_BE, VCC_U|VCC_PS), - /* EQ */ COMPFLAGS(CC_NE, CC_NE, CC_NE, VCC_P), - /* NE */ COMPFLAGS(CC_E, CC_E, CC_E, VCC_U|VCC_P), - /* ABC */ COMPFLAGS(CC_BE, CC_B, CC_BE, VCC_U|VCC_PS) /* Same as UGT. */ -}; - -/* FP and integer comparisons. */ -static void asm_comp(ASMState *as, IRIns *ir, uint32_t cc) -{ - if (irt_isnum(ir->t)) { - IRRef lref = ir->op1; - IRRef rref = ir->op2; - Reg left, right; - MCLabel l_around; - /* - ** An extra CC_P branch is required to preserve ordered/unordered - ** semantics for FP comparisons. This can be avoided by swapping - ** the operands and inverting the condition (except for EQ and UNE). - ** So always try to swap if possible. - ** - ** Another option would be to swap operands to achieve better memory - ** operand fusion. But it's unlikely that this outweighs the cost - ** of the extra branches. - */ - if (cc & VCC_S) { /* Swap? */ - IRRef tmp = lref; lref = rref; rref = tmp; - cc ^= (VCC_PS|(5<<4)); /* A <-> B, AE <-> BE, PS <-> none */ - } - left = ra_alloc1(as, lref, RSET_FPR); - right = asm_fuseload(as, rref, rset_exclude(RSET_FPR, left)); - l_around = emit_label(as); - asm_guardcc(as, cc >> 4); - if (cc & VCC_P) { /* Extra CC_P branch required? */ - if (!(cc & VCC_U)) { - asm_guardcc(as, CC_P); /* Branch to exit for ordered comparisons. */ - } else if (l_around != as->invmcp) { - emit_sjcc(as, CC_P, l_around); /* Branch around for unordered. */ - } else { - /* Patched to mcloop by asm_loop_fixup. */ - as->loopinv = 2; - if (as->realign) - emit_sjcc(as, CC_P, as->mcp); - else - emit_jcc(as, CC_P, as->mcp); - } - } - emit_mrm(as, XO_UCOMISD, left, right); - } else { - IRRef lref = ir->op1, rref = ir->op2; - IROp leftop = (IROp)(IR(lref)->o); - Reg r64 = REX_64IR(ir, 0); - int32_t imm = 0; - lua_assert(irt_is64(ir->t) || irt_isint(ir->t) || - irt_isu32(ir->t) || irt_isaddr(ir->t) || irt_isu8(ir->t)); - /* Swap constants (only for ABC) and fusable loads to the right. */ - if (irref_isk(lref) || (!irref_isk(rref) && opisfusableload(leftop))) { - if ((cc & 0xc) == 0xc) cc ^= 0x53; /* L <-> G, LE <-> GE */ - else if ((cc & 0xa) == 0x2) cc ^= 0x55; /* A <-> B, AE <-> BE */ - lref = ir->op2; rref = ir->op1; - } - if (asm_isk32(as, rref, &imm)) { - IRIns *irl = IR(lref); - /* Check wether we can use test ins. Not for unsigned, since CF=0. */ - int usetest = (imm == 0 && (cc & 0xa) != 0x2); - if (usetest && irl->o == IR_BAND && irl+1 == ir && !ra_used(irl)) { - /* Combine comp(BAND(ref, r/imm), 0) into test mrm, r/imm. */ - Reg right, left = RID_NONE; - RegSet allow = RSET_GPR; - if (!asm_isk32(as, irl->op2, &imm)) { - left = ra_alloc1(as, irl->op2, allow); - rset_clear(allow, left); - } else { /* Try to Fuse IRT_I8/IRT_U8 loads, too. See below. */ - IRIns *irll = IR(irl->op1); - if (opisfusableload((IROp)irll->o) && - (irt_isi8(irll->t) || irt_isu8(irll->t))) { - IRType1 origt = irll->t; /* Temporarily flip types. */ - irll->t.irt = (irll->t.irt & ~IRT_TYPE) | IRT_INT; - as->curins--; /* Skip to BAND to avoid failing in noconflict(). */ - right = asm_fuseload(as, irl->op1, RSET_GPR); - as->curins++; - irll->t = origt; - if (right != RID_MRM) goto test_nofuse; - /* Fusion succeeded, emit test byte mrm, imm8. */ - asm_guardcc(as, cc); - emit_i8(as, (imm & 0xff)); - emit_mrm(as, XO_GROUP3b, XOg_TEST, RID_MRM); - return; - } - } - as->curins--; /* Skip to BAND to avoid failing in noconflict(). */ - right = asm_fuseloadm(as, irl->op1, allow, r64); - as->curins++; /* Undo the above. */ - test_nofuse: - asm_guardcc(as, cc); - if (ra_noreg(left)) { - emit_i32(as, imm); - emit_mrm(as, XO_GROUP3, r64 + XOg_TEST, right); - } else { - emit_mrm(as, XO_TEST, r64 + left, right); - } - } else { - Reg left; - if (opisfusableload((IROp)irl->o) && - ((irt_isu8(irl->t) && checku8(imm)) || - ((irt_isi8(irl->t) || irt_isi16(irl->t)) && checki8(imm)) || - (irt_isu16(irl->t) && checku16(imm) && checki8((int16_t)imm)))) { - /* Only the IRT_INT case is fused by asm_fuseload. - ** The IRT_I8/IRT_U8 loads and some IRT_I16/IRT_U16 loads - ** are handled here. - ** Note that cmp word [mem], imm16 should not be generated, - ** since it has a length-changing prefix. Compares of a word - ** against a sign-extended imm8 are ok, however. - */ - IRType1 origt = irl->t; /* Temporarily flip types. */ - irl->t.irt = (irl->t.irt & ~IRT_TYPE) | IRT_INT; - left = asm_fuseload(as, lref, RSET_GPR); - irl->t = origt; - if (left == RID_MRM) { /* Fusion succeeded? */ - if (irt_isu8(irl->t) || irt_isu16(irl->t)) - cc >>= 4; /* Need unsigned compare. */ - asm_guardcc(as, cc); - emit_i8(as, imm); - emit_mrm(as, (irt_isi8(origt) || irt_isu8(origt)) ? - XO_ARITHib : XO_ARITHiw8, r64 + XOg_CMP, RID_MRM); - return; - } /* Otherwise handle register case as usual. */ - } else { - left = asm_fuseloadm(as, lref, - irt_isu8(ir->t) ? RSET_GPR8 : RSET_GPR, r64); - } - asm_guardcc(as, cc); - if (usetest && left != RID_MRM) { - /* Use test r,r instead of cmp r,0. */ - x86Op xo = XO_TEST; - if (irt_isu8(ir->t)) { - lua_assert(ir->o == IR_EQ || ir->o == IR_NE); - xo = XO_TESTb; - if (!rset_test(RSET_RANGE(RID_EAX, RID_EBX+1), left)) { - if (LJ_64) { - left |= FORCE_REX; - } else { - emit_i32(as, 0xff); - emit_mrm(as, XO_GROUP3, XOg_TEST, left); - return; - } - } - } - emit_rr(as, xo, r64 + left, left); - if (irl+1 == ir) /* Referencing previous ins? */ - as->flagmcp = as->mcp; /* Set flag to drop test r,r if possible. */ - } else { - emit_gmrmi(as, XG_ARITHi(XOg_CMP), r64 + left, imm); - } - } - } else { - Reg left = ra_alloc1(as, lref, RSET_GPR); - Reg right = asm_fuseloadm(as, rref, rset_exclude(RSET_GPR, left), r64); - asm_guardcc(as, cc); - emit_mrm(as, XO_CMP, r64 + left, right); - } - } -} - -#if LJ_32 && LJ_HASFFI -/* 64 bit integer comparisons in 32 bit mode. */ -static void asm_comp_int64(ASMState *as, IRIns *ir) -{ - uint32_t cc = asm_compmap[(ir-1)->o]; - RegSet allow = RSET_GPR; - Reg lefthi = RID_NONE, leftlo = RID_NONE; - Reg righthi = RID_NONE, rightlo = RID_NONE; - MCLabel l_around; - x86ModRM mrm; - - as->curins--; /* Skip loword ins. Avoids failing in noconflict(), too. */ - - /* Allocate/fuse hiword operands. */ - if (irref_isk(ir->op2)) { - lefthi = asm_fuseload(as, ir->op1, allow); - } else { - lefthi = ra_alloc1(as, ir->op1, allow); - rset_clear(allow, lefthi); - righthi = asm_fuseload(as, ir->op2, allow); - if (righthi == RID_MRM) { - if (as->mrm.base != RID_NONE) rset_clear(allow, as->mrm.base); - if (as->mrm.idx != RID_NONE) rset_clear(allow, as->mrm.idx); - } else { - rset_clear(allow, righthi); - } - } - mrm = as->mrm; /* Save state for hiword instruction. */ - - /* Allocate/fuse loword operands. */ - if (irref_isk((ir-1)->op2)) { - leftlo = asm_fuseload(as, (ir-1)->op1, allow); - } else { - leftlo = ra_alloc1(as, (ir-1)->op1, allow); - rset_clear(allow, leftlo); - rightlo = asm_fuseload(as, (ir-1)->op2, allow); - } - - /* All register allocations must be performed _before_ this point. */ - l_around = emit_label(as); - as->invmcp = as->flagmcp = NULL; /* Cannot use these optimizations. */ - - /* Loword comparison and branch. */ - asm_guardcc(as, cc >> 4); /* Always use unsigned compare for loword. */ - if (ra_noreg(rightlo)) { - int32_t imm = IR((ir-1)->op2)->i; - if (imm == 0 && ((cc >> 4) & 0xa) != 0x2 && leftlo != RID_MRM) - emit_rr(as, XO_TEST, leftlo, leftlo); - else - emit_gmrmi(as, XG_ARITHi(XOg_CMP), leftlo, imm); - } else { - emit_mrm(as, XO_CMP, leftlo, rightlo); - } - - /* Hiword comparison and branches. */ - if ((cc & 15) != CC_NE) - emit_sjcc(as, CC_NE, l_around); /* Hiword unequal: skip loword compare. */ - if ((cc & 15) != CC_E) - asm_guardcc(as, cc >> 8); /* Hiword compare without equality check. */ - as->mrm = mrm; /* Restore state. */ - if (ra_noreg(righthi)) { - int32_t imm = IR(ir->op2)->i; - if (imm == 0 && (cc & 0xa) != 0x2 && lefthi != RID_MRM) - emit_rr(as, XO_TEST, lefthi, lefthi); - else - emit_gmrmi(as, XG_ARITHi(XOg_CMP), lefthi, imm); - } else { - emit_mrm(as, XO_CMP, lefthi, righthi); - } -} -#endif - -/* -- Support for 64 bit ops in 32 bit mode ------------------------------- */ - -/* Hiword op of a split 64 bit op. Previous op must be the loword op. */ -static void asm_hiop(ASMState *as, IRIns *ir) -{ -#if LJ_32 && LJ_HASFFI - /* HIOP is marked as a store because it needs its own DCE logic. */ - int uselo = ra_used(ir-1), usehi = ra_used(ir); /* Loword/hiword used? */ - if (LJ_UNLIKELY(!(as->flags & JIT_F_OPT_DCE))) uselo = usehi = 1; - if ((ir-1)->o == IR_CONV) { /* Conversions to/from 64 bit. */ - if (usehi || uselo) { - if (irt_isfp(ir->t)) - asm_conv_fp_int64(as, ir); - else - asm_conv_int64_fp(as, ir); - } - as->curins--; /* Always skip the CONV. */ - return; - } else if ((ir-1)->o <= IR_NE) { /* 64 bit integer comparisons. ORDER IR. */ - asm_comp_int64(as, ir); - return; - } else if ((ir-1)->o == IR_XSTORE) { - if ((ir-1)->r != RID_SINK) - asm_fxstore(as, ir); - return; - } - if (!usehi) return; /* Skip unused hiword op for all remaining ops. */ - switch ((ir-1)->o) { - case IR_ADD: - as->flagmcp = NULL; - as->curins--; - asm_intarith(as, ir, XOg_ADC); - asm_intarith(as, ir-1, XOg_ADD); - break; - case IR_SUB: - as->flagmcp = NULL; - as->curins--; - asm_intarith(as, ir, XOg_SBB); - asm_intarith(as, ir-1, XOg_SUB); - break; - case IR_NEG: { - Reg dest = ra_dest(as, ir, RSET_GPR); - emit_rr(as, XO_GROUP3, XOg_NEG, dest); - emit_i8(as, 0); - emit_rr(as, XO_ARITHi8, XOg_ADC, dest); - ra_left(as, dest, ir->op1); - as->curins--; - asm_neg_not(as, ir-1, XOg_NEG); - break; - } - case IR_CALLN: - case IR_CALLXS: - if (!uselo) - ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */ - break; - case IR_CNEWI: - /* Nothing to do here. Handled by CNEWI itself. */ - break; - default: lua_assert(0); break; - } -#else - UNUSED(as); UNUSED(ir); lua_assert(0); /* Unused on x64 or without FFI. */ -#endif -} - -/* -- Stack handling ------------------------------------------------------ */ - -/* Check Lua stack size for overflow. Use exit handler as fallback. */ -static void asm_stack_check(ASMState *as, BCReg topslot, - IRIns *irp, RegSet allow, ExitNo exitno) -{ - /* Try to get an unused temp. register, otherwise spill/restore eax. */ - Reg pbase = irp ? irp->r : RID_BASE; - Reg r = allow ? rset_pickbot(allow) : RID_EAX; - emit_jcc(as, CC_B, exitstub_addr(as->J, exitno)); - if (allow == RSET_EMPTY) /* Restore temp. register. */ - emit_rmro(as, XO_MOV, r|REX_64, RID_ESP, 0); - else - ra_modified(as, r); - emit_gri(as, XG_ARITHi(XOg_CMP), r, (int32_t)(8*topslot)); - if (ra_hasreg(pbase) && pbase != r) - emit_rr(as, XO_ARITH(XOg_SUB), r, pbase); - else - emit_rmro(as, XO_ARITH(XOg_SUB), r, RID_NONE, - ptr2addr(&J2G(as->J)->jit_base)); - emit_rmro(as, XO_MOV, r, r, offsetof(lua_State, maxstack)); - emit_getgl(as, r, jit_L); - if (allow == RSET_EMPTY) /* Spill temp. register. */ - emit_rmro(as, XO_MOVto, r|REX_64, RID_ESP, 0); -} - -/* Restore Lua stack from on-trace state. */ -static void asm_stack_restore(ASMState *as, SnapShot *snap) -{ - SnapEntry *map = &as->T->snapmap[snap->mapofs]; - SnapEntry *flinks = &as->T->snapmap[snap_nextofs(as->T, snap)-1]; - MSize n, nent = snap->nent; - /* Store the value of all modified slots to the Lua stack. */ - for (n = 0; n < nent; n++) { - SnapEntry sn = map[n]; - BCReg s = snap_slot(sn); - int32_t ofs = 8*((int32_t)s-1); - IRRef ref = snap_ref(sn); - IRIns *ir = IR(ref); - if ((sn & SNAP_NORESTORE)) - continue; - if (irt_isnum(ir->t)) { - Reg src = ra_alloc1(as, ref, RSET_FPR); - emit_rmro(as, XO_MOVSDto, src, RID_BASE, ofs); - } else { - lua_assert(irt_ispri(ir->t) || irt_isaddr(ir->t) || - (LJ_DUALNUM && irt_isinteger(ir->t))); - if (!irref_isk(ref)) { - Reg src = ra_alloc1(as, ref, rset_exclude(RSET_GPR, RID_BASE)); - emit_movtomro(as, REX_64IR(ir, src), RID_BASE, ofs); - } else if (!irt_ispri(ir->t)) { - emit_movmroi(as, RID_BASE, ofs, ir->i); - } - if ((sn & (SNAP_CONT|SNAP_FRAME))) { - if (s != 0) /* Do not overwrite link to previous frame. */ - emit_movmroi(as, RID_BASE, ofs+4, (int32_t)(*flinks--)); - } else { - if (!(LJ_64 && irt_islightud(ir->t))) - emit_movmroi(as, RID_BASE, ofs+4, irt_toitype(ir->t)); - } - } - checkmclim(as); - } - lua_assert(map + nent == flinks); -} - -/* -- GC handling --------------------------------------------------------- */ - -/* Check GC threshold and do one or more GC steps. */ -static void asm_gc_check(ASMState *as) -{ - const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_step_jit]; - IRRef args[2]; - MCLabel l_end; - Reg tmp; - ra_evictset(as, RSET_SCRATCH); - l_end = emit_label(as); - /* Exit trace if in GCSatomic or GCSfinalize. Avoids syncing GC objects. */ - asm_guardcc(as, CC_NE); /* Assumes asm_snap_prep() already done. */ - emit_rr(as, XO_TEST, RID_RET, RID_RET); - args[0] = ASMREF_TMP1; /* global_State *g */ - args[1] = ASMREF_TMP2; /* MSize steps */ - asm_gencall(as, ci, args); - tmp = ra_releasetmp(as, ASMREF_TMP1); - emit_loada(as, tmp, J2G(as->J)); - emit_loadi(as, ra_releasetmp(as, ASMREF_TMP2), as->gcsteps); - /* Jump around GC step if GC total < GC threshold. */ - emit_sjcc(as, CC_B, l_end); - emit_opgl(as, XO_ARITH(XOg_CMP), tmp, gc.threshold); - emit_getgl(as, tmp, gc.total); - as->gcsteps = 0; - checkmclim(as); -} - -/* -- Loop handling ------------------------------------------------------- */ - -/* Fixup the loop branch. */ -static void asm_loop_fixup(ASMState *as) -{ - MCode *p = as->mctop; - MCode *target = as->mcp; - if (as->realign) { /* Realigned loops use short jumps. */ - as->realign = NULL; /* Stop another retry. */ - lua_assert(((intptr_t)target & 15) == 0); - if (as->loopinv) { /* Inverted loop branch? */ - p -= 5; - p[0] = XI_JMP; - lua_assert(target - p >= -128); - p[-1] = (MCode)(target - p); /* Patch sjcc. */ - if (as->loopinv == 2) - p[-3] = (MCode)(target - p + 2); /* Patch opt. short jp. */ - } else { - lua_assert(target - p >= -128); - p[-1] = (MCode)(int8_t)(target - p); /* Patch short jmp. */ - p[-2] = XI_JMPs; - } - } else { - MCode *newloop; - p[-5] = XI_JMP; - if (as->loopinv) { /* Inverted loop branch? */ - /* asm_guardcc already inverted the jcc and patched the jmp. */ - p -= 5; - newloop = target+4; - *(int32_t *)(p-4) = (int32_t)(target - p); /* Patch jcc. */ - if (as->loopinv == 2) { - *(int32_t *)(p-10) = (int32_t)(target - p + 6); /* Patch opt. jp. */ - newloop = target+8; - } - } else { /* Otherwise just patch jmp. */ - *(int32_t *)(p-4) = (int32_t)(target - p); - newloop = target+3; - } - /* Realign small loops and shorten the loop branch. */ - if (newloop >= p - 128) { - as->realign = newloop; /* Force a retry and remember alignment. */ - as->curins = as->stopins; /* Abort asm_trace now. */ - as->T->nins = as->orignins; /* Remove any added renames. */ - } - } -} - -/* -- Head of trace ------------------------------------------------------- */ - -/* Coalesce BASE register for a root trace. */ -static void asm_head_root_base(ASMState *as) -{ - IRIns *ir = IR(REF_BASE); - Reg r = ir->r; - if (ra_hasreg(r)) { - ra_free(as, r); - if (rset_test(as->modset, r) || irt_ismarked(ir->t)) - ir->r = RID_INIT; /* No inheritance for modified BASE register. */ - if (r != RID_BASE) - emit_rr(as, XO_MOV, r, RID_BASE); - } -} - -/* Coalesce or reload BASE register for a side trace. */ -static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) -{ - IRIns *ir = IR(REF_BASE); - Reg r = ir->r; - if (ra_hasreg(r)) { - ra_free(as, r); - if (rset_test(as->modset, r) || irt_ismarked(ir->t)) - ir->r = RID_INIT; /* No inheritance for modified BASE register. */ - if (irp->r == r) { - rset_clear(allow, r); /* Mark same BASE register as coalesced. */ - } else if (ra_hasreg(irp->r) && rset_test(as->freeset, irp->r)) { - rset_clear(allow, irp->r); - emit_rr(as, XO_MOV, r, irp->r); /* Move from coalesced parent reg. */ - } else { - emit_getgl(as, r, jit_base); /* Otherwise reload BASE. */ - } - } - return allow; -} - -/* -- Tail of trace ------------------------------------------------------- */ - -/* Fixup the tail code. */ -static void asm_tail_fixup(ASMState *as, TraceNo lnk) -{ - /* Note: don't use as->mcp swap + emit_*: emit_op overwrites more bytes. */ - MCode *p = as->mctop; - MCode *target, *q; - int32_t spadj = as->T->spadjust; - if (spadj == 0) { - p -= ((as->flags & JIT_F_LEA_AGU) ? 7 : 6) + (LJ_64 ? 1 : 0); - } else { - MCode *p1; - /* Patch stack adjustment. */ - if (checki8(spadj)) { - p -= 3; - p1 = p-6; - *p1 = (MCode)spadj; - } else { - p1 = p-9; - *(int32_t *)p1 = spadj; - } - if ((as->flags & JIT_F_LEA_AGU)) { -#if LJ_64 - p1[-4] = 0x48; -#endif - p1[-3] = (MCode)XI_LEA; - p1[-2] = MODRM(checki8(spadj) ? XM_OFS8 : XM_OFS32, RID_ESP, RID_ESP); - p1[-1] = MODRM(XM_SCALE1, RID_ESP, RID_ESP); - } else { -#if LJ_64 - p1[-3] = 0x48; -#endif - p1[-2] = (MCode)(checki8(spadj) ? XI_ARITHi8 : XI_ARITHi); - p1[-1] = MODRM(XM_REG, XOg_ADD, RID_ESP); - } - } - /* Patch exit branch. */ - target = lnk ? traceref(as->J, lnk)->mcode : (MCode *)lj_vm_exit_interp; - *(int32_t *)(p-4) = jmprel(p, target); - p[-5] = XI_JMP; - /* Drop unused mcode tail. Fill with NOPs to make the prefetcher happy. */ - for (q = as->mctop-1; q >= p; q--) - *q = XI_NOP; - as->mctop = p; -} - -/* Prepare tail of code. */ -static void asm_tail_prep(ASMState *as) -{ - MCode *p = as->mctop; - /* Realign and leave room for backwards loop branch or exit branch. */ - if (as->realign) { - int i = ((int)(intptr_t)as->realign) & 15; - /* Fill unused mcode tail with NOPs to make the prefetcher happy. */ - while (i-- > 0) - *--p = XI_NOP; - as->mctop = p; - p -= (as->loopinv ? 5 : 2); /* Space for short/near jmp. */ - } else { - p -= 5; /* Space for exit branch (near jmp). */ - } - if (as->loopref) { - as->invmcp = as->mcp = p; - } else { - /* Leave room for ESP adjustment: add esp, imm or lea esp, [esp+imm] */ - as->mcp = p - (((as->flags & JIT_F_LEA_AGU) ? 7 : 6) + (LJ_64 ? 1 : 0)); - as->invmcp = NULL; - } -} - -/* -- Instruction dispatch ------------------------------------------------ */ - -/* Assemble a single instruction. */ -static void asm_ir(ASMState *as, IRIns *ir) -{ - switch ((IROp)ir->o) { - /* Miscellaneous ops. */ - case IR_LOOP: asm_loop(as); break; - case IR_NOP: case IR_XBAR: lua_assert(!ra_used(ir)); break; - case IR_USE: - ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break; - case IR_PHI: asm_phi(as, ir); break; - case IR_HIOP: asm_hiop(as, ir); break; - case IR_GCSTEP: asm_gcstep(as, ir); break; - - /* Guarded assertions. */ - case IR_LT: case IR_GE: case IR_LE: case IR_GT: - case IR_ULT: case IR_UGE: case IR_ULE: case IR_UGT: - case IR_EQ: case IR_NE: case IR_ABC: - asm_comp(as, ir, asm_compmap[ir->o]); - break; - - case IR_RETF: asm_retf(as, ir); break; - - /* Bit ops. */ - case IR_BNOT: asm_neg_not(as, ir, XOg_NOT); break; - case IR_BSWAP: asm_bitswap(as, ir); break; - - case IR_BAND: asm_intarith(as, ir, XOg_AND); break; - case IR_BOR: asm_intarith(as, ir, XOg_OR); break; - case IR_BXOR: asm_intarith(as, ir, XOg_XOR); break; - - case IR_BSHL: asm_bitshift(as, ir, XOg_SHL); break; - case IR_BSHR: asm_bitshift(as, ir, XOg_SHR); break; - case IR_BSAR: asm_bitshift(as, ir, XOg_SAR); break; - case IR_BROL: asm_bitshift(as, ir, XOg_ROL); break; - case IR_BROR: asm_bitshift(as, ir, XOg_ROR); break; - - /* Arithmetic ops. */ - case IR_ADD: asm_add(as, ir); break; - case IR_SUB: - if (irt_isnum(ir->t)) - asm_fparith(as, ir, XO_SUBSD); - else /* Note: no need for LEA trick here. i-k is encoded as i+(-k). */ - asm_intarith(as, ir, XOg_SUB); - break; - case IR_MUL: - if (irt_isnum(ir->t)) - asm_fparith(as, ir, XO_MULSD); - else - asm_intarith(as, ir, XOg_X_IMUL); - break; - case IR_DIV: -#if LJ_64 && LJ_HASFFI - if (!irt_isnum(ir->t)) - asm_arith64(as, ir, irt_isi64(ir->t) ? IRCALL_lj_carith_divi64 : - IRCALL_lj_carith_divu64); - else -#endif - asm_fparith(as, ir, XO_DIVSD); - break; - case IR_MOD: -#if LJ_64 && LJ_HASFFI - if (!irt_isint(ir->t)) - asm_arith64(as, ir, irt_isi64(ir->t) ? IRCALL_lj_carith_modi64 : - IRCALL_lj_carith_modu64); - else -#endif - asm_intmod(as, ir); - break; - - case IR_NEG: - if (irt_isnum(ir->t)) - asm_fparith(as, ir, XO_XORPS); - else - asm_neg_not(as, ir, XOg_NEG); - break; - case IR_ABS: asm_fparith(as, ir, XO_ANDPS); break; - - case IR_MIN: - if (irt_isnum(ir->t)) - asm_fparith(as, ir, XO_MINSD); - else - asm_min_max(as, ir, CC_G); - break; - case IR_MAX: - if (irt_isnum(ir->t)) - asm_fparith(as, ir, XO_MAXSD); - else - asm_min_max(as, ir, CC_L); - break; - - case IR_FPMATH: case IR_ATAN2: case IR_LDEXP: - asm_fpmath(as, ir); - break; - case IR_POW: -#if LJ_64 && LJ_HASFFI - if (!irt_isnum(ir->t)) - asm_arith64(as, ir, irt_isi64(ir->t) ? IRCALL_lj_carith_powi64 : - IRCALL_lj_carith_powu64); - else -#endif - asm_fppowi(as, ir); - break; - - /* Overflow-checking arithmetic ops. Note: don't use LEA here! */ - case IR_ADDOV: asm_intarith(as, ir, XOg_ADD); break; - case IR_SUBOV: asm_intarith(as, ir, XOg_SUB); break; - case IR_MULOV: asm_intarith(as, ir, XOg_X_IMUL); break; - - /* Memory references. */ - case IR_AREF: asm_aref(as, ir); break; - case IR_HREF: asm_href(as, ir); break; - case IR_HREFK: asm_hrefk(as, ir); break; - case IR_NEWREF: asm_newref(as, ir); break; - case IR_UREFO: case IR_UREFC: asm_uref(as, ir); break; - case IR_FREF: asm_fref(as, ir); break; - case IR_STRREF: asm_strref(as, ir); break; - - /* Loads and stores. */ - case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: - asm_ahuvload(as, ir); - break; - case IR_FLOAD: case IR_XLOAD: asm_fxload(as, ir); break; - case IR_SLOAD: asm_sload(as, ir); break; - - case IR_ASTORE: case IR_HSTORE: case IR_USTORE: asm_ahustore(as, ir); break; - case IR_FSTORE: case IR_XSTORE: asm_fxstore(as, ir); break; - - /* Allocations. */ - case IR_SNEW: case IR_XSNEW: asm_snew(as, ir); break; - case IR_TNEW: asm_tnew(as, ir); break; - case IR_TDUP: asm_tdup(as, ir); break; - case IR_CNEW: case IR_CNEWI: asm_cnew(as, ir); break; - - /* Write barriers. */ - case IR_TBAR: asm_tbar(as, ir); break; - case IR_OBAR: asm_obar(as, ir); break; - - /* Type conversions. */ - case IR_TOBIT: asm_tobit(as, ir); break; - case IR_CONV: asm_conv(as, ir); break; - case IR_TOSTR: asm_tostr(as, ir); break; - case IR_STRTO: asm_strto(as, ir); break; - - /* Calls. */ - case IR_CALLN: case IR_CALLL: case IR_CALLS: asm_call(as, ir); break; - case IR_CALLXS: asm_callx(as, ir); break; - case IR_CARG: break; - - default: - setintV(&as->J->errinfo, ir->o); - lj_trace_err_info(as->J, LJ_TRERR_NYIIR); - break; - } -} - -/* -- Trace setup --------------------------------------------------------- */ - -/* Ensure there are enough stack slots for call arguments. */ -static Reg asm_setup_call_slots(ASMState *as, IRIns *ir, const CCallInfo *ci) -{ - IRRef args[CCI_NARGS_MAX*2]; - int nslots; - asm_collectargs(as, ir, ci, args); - nslots = asm_count_call_slots(as, ci, args); - if (nslots > as->evenspill) /* Leave room for args in stack slots. */ - as->evenspill = nslots; -#if LJ_64 - return irt_isfp(ir->t) ? REGSP_HINT(RID_FPRET) : REGSP_HINT(RID_RET); -#else - return irt_isfp(ir->t) ? REGSP_INIT : REGSP_HINT(RID_RET); -#endif -} - -/* Target-specific setup. */ -static void asm_setup_target(ASMState *as) -{ - asm_exitstub_setup(as, as->T->nsnap); -} - -/* -- Trace patching ------------------------------------------------------ */ - -/* Patch exit jumps of existing machine code to a new target. */ -void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target) -{ - MCode *p = T->mcode; - MCode *mcarea = lj_mcode_patch(J, p, 0); - MSize len = T->szmcode; - MCode *px = exitstub_addr(J, exitno) - 6; - MCode *pe = p+len-6; - uint32_t stateaddr = u32ptr(&J2G(J)->vmstate); - if (len > 5 && p[len-5] == XI_JMP && p+len-6 + *(int32_t *)(p+len-4) == px) - *(int32_t *)(p+len-4) = jmprel(p+len, target); - /* Do not patch parent exit for a stack check. Skip beyond vmstate update. */ - for (; p < pe; p++) - if (*(uint32_t *)(p+(LJ_64 ? 3 : 2)) == stateaddr && p[0] == XI_MOVmi) { - p += LJ_64 ? 11 : 10; - break; - } - lua_assert(p < pe); - for (; p < pe; p++) { - if ((*(uint16_t *)p & 0xf0ff) == 0x800f && p + *(int32_t *)(p+2) == px) { - *(int32_t *)(p+2) = jmprel(p+6, target); - p += 5; - } - } - lj_mcode_sync(T->mcode, T->mcode + T->szmcode); - lj_mcode_patch(J, mcarea, 1); -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_bc.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_bc.c deleted file mode 100644 index d5d3d78db..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_bc.c +++ /dev/null @@ -1,14 +0,0 @@ -/* -** Bytecode instruction modes. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_bc_c -#define LUA_CORE - -#include "lj_obj.h" -#include "lj_bc.h" - -/* Bytecode offsets and bytecode instruction modes. */ -#include "lj_bcdef.h" - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_bc.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_bc.h deleted file mode 100644 index 1a4ade317..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_bc.h +++ /dev/null @@ -1,261 +0,0 @@ -/* -** Bytecode instruction format. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_BC_H -#define _LJ_BC_H - -#include "lj_def.h" -#include "lj_arch.h" - -/* Bytecode instruction format, 32 bit wide, fields of 8 or 16 bit: -** -** +----+----+----+----+ -** | B | C | A | OP | Format ABC -** +----+----+----+----+ -** | D | A | OP | Format AD -** +-------------------- -** MSB LSB -** -** In-memory instructions are always stored in host byte order. -*/ - -/* Operand ranges and related constants. */ -#define BCMAX_A 0xff -#define BCMAX_B 0xff -#define BCMAX_C 0xff -#define BCMAX_D 0xffff -#define BCBIAS_J 0x8000 -#define NO_REG BCMAX_A -#define NO_JMP (~(BCPos)0) - -/* Macros to get instruction fields. */ -#define bc_op(i) ((BCOp)((i)&0xff)) -#define bc_a(i) ((BCReg)(((i)>>8)&0xff)) -#define bc_b(i) ((BCReg)((i)>>24)) -#define bc_c(i) ((BCReg)(((i)>>16)&0xff)) -#define bc_d(i) ((BCReg)((i)>>16)) -#define bc_j(i) ((ptrdiff_t)bc_d(i)-BCBIAS_J) - -/* Macros to set instruction fields. */ -#define setbc_byte(p, x, ofs) \ - ((uint8_t *)(p))[LJ_ENDIAN_SELECT(ofs, 3-ofs)] = (uint8_t)(x) -#define setbc_op(p, x) setbc_byte(p, (x), 0) -#define setbc_a(p, x) setbc_byte(p, (x), 1) -#define setbc_b(p, x) setbc_byte(p, (x), 3) -#define setbc_c(p, x) setbc_byte(p, (x), 2) -#define setbc_d(p, x) \ - ((uint16_t *)(p))[LJ_ENDIAN_SELECT(1, 0)] = (uint16_t)(x) -#define setbc_j(p, x) setbc_d(p, (BCPos)((int32_t)(x)+BCBIAS_J)) - -/* Macros to compose instructions. */ -#define BCINS_ABC(o, a, b, c) \ - (((BCIns)(o))|((BCIns)(a)<<8)|((BCIns)(b)<<24)|((BCIns)(c)<<16)) -#define BCINS_AD(o, a, d) \ - (((BCIns)(o))|((BCIns)(a)<<8)|((BCIns)(d)<<16)) -#define BCINS_AJ(o, a, j) BCINS_AD(o, a, (BCPos)((int32_t)(j)+BCBIAS_J)) - -/* Bytecode instruction definition. Order matters, see below. -** -** (name, filler, Amode, Bmode, Cmode or Dmode, metamethod) -** -** The opcode name suffixes specify the type for RB/RC or RD: -** V = variable slot -** S = string const -** N = number const -** P = primitive type (~itype) -** B = unsigned byte literal -** M = multiple args/results -*/ -#define BCDEF(_) \ - /* Comparison ops. ORDER OPR. */ \ - _(ISLT, var, ___, var, lt) \ - _(ISGE, var, ___, var, lt) \ - _(ISLE, var, ___, var, le) \ - _(ISGT, var, ___, var, le) \ - \ - _(ISEQV, var, ___, var, eq) \ - _(ISNEV, var, ___, var, eq) \ - _(ISEQS, var, ___, str, eq) \ - _(ISNES, var, ___, str, eq) \ - _(ISEQN, var, ___, num, eq) \ - _(ISNEN, var, ___, num, eq) \ - _(ISEQP, var, ___, pri, eq) \ - _(ISNEP, var, ___, pri, eq) \ - \ - /* Unary test and copy ops. */ \ - _(ISTC, dst, ___, var, ___) \ - _(ISFC, dst, ___, var, ___) \ - _(IST, ___, ___, var, ___) \ - _(ISF, ___, ___, var, ___) \ - \ - /* Unary ops. */ \ - _(MOV, dst, ___, var, ___) \ - _(NOT, dst, ___, var, ___) \ - _(UNM, dst, ___, var, unm) \ - _(LEN, dst, ___, var, len) \ - \ - /* Binary ops. ORDER OPR. VV last, POW must be next. */ \ - _(ADDVN, dst, var, num, add) \ - _(SUBVN, dst, var, num, sub) \ - _(MULVN, dst, var, num, mul) \ - _(DIVVN, dst, var, num, div) \ - _(MODVN, dst, var, num, mod) \ - \ - _(ADDNV, dst, var, num, add) \ - _(SUBNV, dst, var, num, sub) \ - _(MULNV, dst, var, num, mul) \ - _(DIVNV, dst, var, num, div) \ - _(MODNV, dst, var, num, mod) \ - \ - _(ADDVV, dst, var, var, add) \ - _(SUBVV, dst, var, var, sub) \ - _(MULVV, dst, var, var, mul) \ - _(DIVVV, dst, var, var, div) \ - _(MODVV, dst, var, var, mod) \ - \ - _(POW, dst, var, var, pow) \ - _(CAT, dst, rbase, rbase, concat) \ - \ - /* Constant ops. */ \ - _(KSTR, dst, ___, str, ___) \ - _(KCDATA, dst, ___, cdata, ___) \ - _(KSHORT, dst, ___, lits, ___) \ - _(KNUM, dst, ___, num, ___) \ - _(KPRI, dst, ___, pri, ___) \ - _(KNIL, base, ___, base, ___) \ - \ - /* Upvalue and function ops. */ \ - _(UGET, dst, ___, uv, ___) \ - _(USETV, uv, ___, var, ___) \ - _(USETS, uv, ___, str, ___) \ - _(USETN, uv, ___, num, ___) \ - _(USETP, uv, ___, pri, ___) \ - _(UCLO, rbase, ___, jump, ___) \ - _(FNEW, dst, ___, func, gc) \ - \ - /* Table ops. */ \ - _(TNEW, dst, ___, lit, gc) \ - _(TDUP, dst, ___, tab, gc) \ - _(GGET, dst, ___, str, index) \ - _(GSET, var, ___, str, newindex) \ - _(TGETV, dst, var, var, index) \ - _(TGETS, dst, var, str, index) \ - _(TGETB, dst, var, lit, index) \ - _(TSETV, var, var, var, newindex) \ - _(TSETS, var, var, str, newindex) \ - _(TSETB, var, var, lit, newindex) \ - _(TSETM, base, ___, num, newindex) \ - \ - /* Calls and vararg handling. T = tail call. */ \ - _(CALLM, base, lit, lit, call) \ - _(CALL, base, lit, lit, call) \ - _(CALLMT, base, ___, lit, call) \ - _(CALLT, base, ___, lit, call) \ - _(ITERC, base, lit, lit, call) \ - _(ITERN, base, lit, lit, call) \ - _(VARG, base, lit, lit, ___) \ - _(ISNEXT, base, ___, jump, ___) \ - \ - /* Returns. */ \ - _(RETM, base, ___, lit, ___) \ - _(RET, rbase, ___, lit, ___) \ - _(RET0, rbase, ___, lit, ___) \ - _(RET1, rbase, ___, lit, ___) \ - \ - /* Loops and branches. I/J = interp/JIT, I/C/L = init/call/loop. */ \ - _(FORI, base, ___, jump, ___) \ - _(JFORI, base, ___, jump, ___) \ - \ - _(FORL, base, ___, jump, ___) \ - _(IFORL, base, ___, jump, ___) \ - _(JFORL, base, ___, lit, ___) \ - \ - _(ITERL, base, ___, jump, ___) \ - _(IITERL, base, ___, jump, ___) \ - _(JITERL, base, ___, lit, ___) \ - \ - _(LOOP, rbase, ___, jump, ___) \ - _(ILOOP, rbase, ___, jump, ___) \ - _(JLOOP, rbase, ___, lit, ___) \ - \ - _(JMP, rbase, ___, jump, ___) \ - \ - /* Function headers. I/J = interp/JIT, F/V/C = fixarg/vararg/C func. */ \ - _(FUNCF, rbase, ___, ___, ___) \ - _(IFUNCF, rbase, ___, ___, ___) \ - _(JFUNCF, rbase, ___, lit, ___) \ - _(FUNCV, rbase, ___, ___, ___) \ - _(IFUNCV, rbase, ___, ___, ___) \ - _(JFUNCV, rbase, ___, lit, ___) \ - _(FUNCC, rbase, ___, ___, ___) \ - _(FUNCCW, rbase, ___, ___, ___) - -/* Bytecode opcode numbers. */ -typedef enum { -#define BCENUM(name, ma, mb, mc, mt) BC_##name, -BCDEF(BCENUM) -#undef BCENUM - BC__MAX -} BCOp; - -LJ_STATIC_ASSERT((int)BC_ISEQV+1 == (int)BC_ISNEV); -LJ_STATIC_ASSERT(((int)BC_ISEQV^1) == (int)BC_ISNEV); -LJ_STATIC_ASSERT(((int)BC_ISEQS^1) == (int)BC_ISNES); -LJ_STATIC_ASSERT(((int)BC_ISEQN^1) == (int)BC_ISNEN); -LJ_STATIC_ASSERT(((int)BC_ISEQP^1) == (int)BC_ISNEP); -LJ_STATIC_ASSERT(((int)BC_ISLT^1) == (int)BC_ISGE); -LJ_STATIC_ASSERT(((int)BC_ISLE^1) == (int)BC_ISGT); -LJ_STATIC_ASSERT(((int)BC_ISLT^3) == (int)BC_ISGT); -LJ_STATIC_ASSERT((int)BC_IST-(int)BC_ISTC == (int)BC_ISF-(int)BC_ISFC); -LJ_STATIC_ASSERT((int)BC_CALLT-(int)BC_CALL == (int)BC_CALLMT-(int)BC_CALLM); -LJ_STATIC_ASSERT((int)BC_CALLMT + 1 == (int)BC_CALLT); -LJ_STATIC_ASSERT((int)BC_RETM + 1 == (int)BC_RET); -LJ_STATIC_ASSERT((int)BC_FORL + 1 == (int)BC_IFORL); -LJ_STATIC_ASSERT((int)BC_FORL + 2 == (int)BC_JFORL); -LJ_STATIC_ASSERT((int)BC_ITERL + 1 == (int)BC_IITERL); -LJ_STATIC_ASSERT((int)BC_ITERL + 2 == (int)BC_JITERL); -LJ_STATIC_ASSERT((int)BC_LOOP + 1 == (int)BC_ILOOP); -LJ_STATIC_ASSERT((int)BC_LOOP + 2 == (int)BC_JLOOP); -LJ_STATIC_ASSERT((int)BC_FUNCF + 1 == (int)BC_IFUNCF); -LJ_STATIC_ASSERT((int)BC_FUNCF + 2 == (int)BC_JFUNCF); -LJ_STATIC_ASSERT((int)BC_FUNCV + 1 == (int)BC_IFUNCV); -LJ_STATIC_ASSERT((int)BC_FUNCV + 2 == (int)BC_JFUNCV); - -/* This solves a circular dependency problem, change as needed. */ -#define FF_next_N 4 - -/* Stack slots used by FORI/FORL, relative to operand A. */ -enum { - FORL_IDX, FORL_STOP, FORL_STEP, FORL_EXT -}; - -/* Bytecode operand modes. ORDER BCMode */ -typedef enum { - BCMnone, BCMdst, BCMbase, BCMvar, BCMrbase, BCMuv, /* Mode A must be <= 7 */ - BCMlit, BCMlits, BCMpri, BCMnum, BCMstr, BCMtab, BCMfunc, BCMjump, BCMcdata, - BCM_max -} BCMode; -#define BCM___ BCMnone - -#define bcmode_a(op) ((BCMode)(lj_bc_mode[op] & 7)) -#define bcmode_b(op) ((BCMode)((lj_bc_mode[op]>>3) & 15)) -#define bcmode_c(op) ((BCMode)((lj_bc_mode[op]>>7) & 15)) -#define bcmode_d(op) bcmode_c(op) -#define bcmode_hasd(op) ((lj_bc_mode[op] & (15<<3)) == (BCMnone<<3)) -#define bcmode_mm(op) ((MMS)(lj_bc_mode[op]>>11)) - -#define BCMODE(name, ma, mb, mc, mm) \ - (BCM##ma|(BCM##mb<<3)|(BCM##mc<<7)|(MM_##mm<<11)), -#define BCMODE_FF 0 - -static LJ_AINLINE int bc_isret(BCOp op) -{ - return (op == BC_RETM || op == BC_RET || op == BC_RET0 || op == BC_RET1); -} - -LJ_DATA const uint16_t lj_bc_mode[]; -LJ_DATA const uint16_t lj_bc_ofs[]; - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_bcdump.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_bcdump.h deleted file mode 100644 index 77a789e9e..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_bcdump.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -** Bytecode dump definitions. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_BCDUMP_H -#define _LJ_BCDUMP_H - -#include "lj_obj.h" -#include "lj_lex.h" - -/* -- Bytecode dump format ------------------------------------------------ */ - -/* -** dump = header proto+ 0U -** header = ESC 'L' 'J' versionB flagsU [namelenU nameB*] -** proto = lengthU pdata -** pdata = phead bcinsW* uvdataH* kgc* knum* [debugB*] -** phead = flagsB numparamsB framesizeB numuvB numkgcU numknU numbcU -** [debuglenU [firstlineU numlineU]] -** kgc = kgctypeU { ktab | (loU hiU) | (rloU rhiU iloU ihiU) | strB* } -** knum = intU0 | (loU1 hiU) -** ktab = narrayU nhashU karray* khash* -** karray = ktabk -** khash = ktabk ktabk -** ktabk = ktabtypeU { intU | (loU hiU) | strB* } -** -** B = 8 bit, H = 16 bit, W = 32 bit, U = ULEB128 of W, U0/U1 = ULEB128 of W+1 -*/ - -/* Bytecode dump header. */ -#define BCDUMP_HEAD1 0x1b -#define BCDUMP_HEAD2 0x4c -#define BCDUMP_HEAD3 0x4a - -/* If you perform *any* kind of private modifications to the bytecode itself -** or to the dump format, you *must* set BCDUMP_VERSION to 0x80 or higher. -*/ -#define BCDUMP_VERSION 1 - -/* Compatibility flags. */ -#define BCDUMP_F_BE 0x01 -#define BCDUMP_F_STRIP 0x02 -#define BCDUMP_F_FFI 0x04 - -#define BCDUMP_F_KNOWN (BCDUMP_F_FFI*2-1) - -/* Type codes for the GC constants of a prototype. Plus length for strings. */ -enum { - BCDUMP_KGC_CHILD, BCDUMP_KGC_TAB, BCDUMP_KGC_I64, BCDUMP_KGC_U64, - BCDUMP_KGC_COMPLEX, BCDUMP_KGC_STR -}; - -/* Type codes for the keys/values of a constant table. */ -enum { - BCDUMP_KTAB_NIL, BCDUMP_KTAB_FALSE, BCDUMP_KTAB_TRUE, - BCDUMP_KTAB_INT, BCDUMP_KTAB_NUM, BCDUMP_KTAB_STR -}; - -/* -- Bytecode reader/writer ---------------------------------------------- */ - -LJ_FUNC int lj_bcwrite(lua_State *L, GCproto *pt, lua_Writer writer, - void *data, int strip); -LJ_FUNC GCproto *lj_bcread(LexState *ls); - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_bcread.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_bcread.c deleted file mode 100644 index c0baece46..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_bcread.c +++ /dev/null @@ -1,476 +0,0 @@ -/* -** Bytecode reader. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_bcread_c -#define LUA_CORE - -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_bc.h" -#if LJ_HASFFI -#include "lj_ctype.h" -#include "lj_cdata.h" -#include "lualib.h" -#endif -#include "lj_lex.h" -#include "lj_bcdump.h" -#include "lj_state.h" - -/* Reuse some lexer fields for our own purposes. */ -#define bcread_flags(ls) ls->level -#define bcread_swap(ls) \ - ((bcread_flags(ls) & BCDUMP_F_BE) != LJ_BE*BCDUMP_F_BE) -#define bcread_oldtop(L, ls) restorestack(L, ls->lastline) -#define bcread_savetop(L, ls, top) \ - ls->lastline = (BCLine)savestack(L, (top)) - -/* -- Input buffer handling ----------------------------------------------- */ - -/* Throw reader error. */ -static LJ_NOINLINE void bcread_error(LexState *ls, ErrMsg em) -{ - lua_State *L = ls->L; - const char *name = ls->chunkarg; - if (*name == BCDUMP_HEAD1) name = "(binary)"; - else if (*name == '@' || *name == '=') name++; - lj_str_pushf(L, "%s: %s", name, err2msg(em)); - lj_err_throw(L, LUA_ERRSYNTAX); -} - -/* Resize input buffer. */ -static void bcread_resize(LexState *ls, MSize len) -{ - if (ls->sb.sz < len) { - MSize sz = ls->sb.sz * 2; - while (len > sz) sz = sz * 2; - lj_str_resizebuf(ls->L, &ls->sb, sz); - /* Caveat: this may change ls->sb.buf which may affect ls->p. */ - } -} - -/* Refill buffer if needed. */ -static LJ_NOINLINE void bcread_fill(LexState *ls, MSize len, int need) -{ - lua_assert(len != 0); - if (len > LJ_MAX_MEM || ls->current < 0) - bcread_error(ls, LJ_ERR_BCBAD); - do { - const char *buf; - size_t size; - if (ls->n) { /* Copy remainder to buffer. */ - if (ls->sb.n) { /* Move down in buffer. */ - lua_assert(ls->p + ls->n == ls->sb.buf + ls->sb.n); - if (ls->n != ls->sb.n) - memmove(ls->sb.buf, ls->p, ls->n); - } else { /* Copy from buffer provided by reader. */ - bcread_resize(ls, len); - memcpy(ls->sb.buf, ls->p, ls->n); - } - ls->p = ls->sb.buf; - } - ls->sb.n = ls->n; - buf = ls->rfunc(ls->L, ls->rdata, &size); /* Get more data from reader. */ - if (buf == NULL || size == 0) { /* EOF? */ - if (need) bcread_error(ls, LJ_ERR_BCBAD); - ls->current = -1; /* Only bad if we get called again. */ - break; - } - if (ls->sb.n) { /* Append to buffer. */ - MSize n = ls->sb.n + (MSize)size; - bcread_resize(ls, n < len ? len : n); - memcpy(ls->sb.buf + ls->sb.n, buf, size); - ls->n = ls->sb.n = n; - ls->p = ls->sb.buf; - } else { /* Return buffer provided by reader. */ - ls->n = (MSize)size; - ls->p = buf; - } - } while (ls->n < len); -} - -/* Need a certain number of bytes. */ -static LJ_AINLINE void bcread_need(LexState *ls, MSize len) -{ - if (LJ_UNLIKELY(ls->n < len)) - bcread_fill(ls, len, 1); -} - -/* Want to read up to a certain number of bytes, but may need less. */ -static LJ_AINLINE void bcread_want(LexState *ls, MSize len) -{ - if (LJ_UNLIKELY(ls->n < len)) - bcread_fill(ls, len, 0); -} - -#define bcread_dec(ls) check_exp(ls->n > 0, ls->n--) -#define bcread_consume(ls, len) check_exp(ls->n >= (len), ls->n -= (len)) - -/* Return memory block from buffer. */ -static uint8_t *bcread_mem(LexState *ls, MSize len) -{ - uint8_t *p = (uint8_t *)ls->p; - bcread_consume(ls, len); - ls->p = (char *)p + len; - return p; -} - -/* Copy memory block from buffer. */ -static void bcread_block(LexState *ls, void *q, MSize len) -{ - memcpy(q, bcread_mem(ls, len), len); -} - -/* Read byte from buffer. */ -static LJ_AINLINE uint32_t bcread_byte(LexState *ls) -{ - bcread_dec(ls); - return (uint32_t)(uint8_t)*ls->p++; -} - -/* Read ULEB128 value from buffer. */ -static uint32_t bcread_uleb128(LexState *ls) -{ - const uint8_t *p = (const uint8_t *)ls->p; - uint32_t v = *p++; - if (LJ_UNLIKELY(v >= 0x80)) { - int sh = 0; - v &= 0x7f; - do { - v |= ((*p & 0x7f) << (sh += 7)); - bcread_dec(ls); - } while (*p++ >= 0x80); - } - bcread_dec(ls); - ls->p = (char *)p; - return v; -} - -/* Read top 32 bits of 33 bit ULEB128 value from buffer. */ -static uint32_t bcread_uleb128_33(LexState *ls) -{ - const uint8_t *p = (const uint8_t *)ls->p; - uint32_t v = (*p++ >> 1); - if (LJ_UNLIKELY(v >= 0x40)) { - int sh = -1; - v &= 0x3f; - do { - v |= ((*p & 0x7f) << (sh += 7)); - bcread_dec(ls); - } while (*p++ >= 0x80); - } - bcread_dec(ls); - ls->p = (char *)p; - return v; -} - -/* -- Bytecode reader ----------------------------------------------------- */ - -/* Read debug info of a prototype. */ -static void bcread_dbg(LexState *ls, GCproto *pt, MSize sizedbg) -{ - void *lineinfo = (void *)proto_lineinfo(pt); - bcread_block(ls, lineinfo, sizedbg); - /* Swap lineinfo if the endianess differs. */ - if (bcread_swap(ls) && pt->numline >= 256) { - MSize i, n = pt->sizebc-1; - if (pt->numline < 65536) { - uint16_t *p = (uint16_t *)lineinfo; - for (i = 0; i < n; i++) p[i] = (uint16_t)((p[i] >> 8)|(p[i] << 8)); - } else { - uint32_t *p = (uint32_t *)lineinfo; - for (i = 0; i < n; i++) p[i] = lj_bswap(p[i]); - } - } -} - -/* Find pointer to varinfo. */ -static const void *bcread_varinfo(GCproto *pt) -{ - const uint8_t *p = proto_uvinfo(pt); - MSize n = pt->sizeuv; - if (n) while (*p++ || --n) ; - return p; -} - -/* Read a single constant key/value of a template table. */ -static void bcread_ktabk(LexState *ls, TValue *o) -{ - MSize tp = bcread_uleb128(ls); - if (tp >= BCDUMP_KTAB_STR) { - MSize len = tp - BCDUMP_KTAB_STR; - const char *p = (const char *)bcread_mem(ls, len); - setstrV(ls->L, o, lj_str_new(ls->L, p, len)); - } else if (tp == BCDUMP_KTAB_INT) { - setintV(o, (int32_t)bcread_uleb128(ls)); - } else if (tp == BCDUMP_KTAB_NUM) { - o->u32.lo = bcread_uleb128(ls); - o->u32.hi = bcread_uleb128(ls); - } else { - lua_assert(tp <= BCDUMP_KTAB_TRUE); - setitype(o, ~tp); - } -} - -/* Read a template table. */ -static GCtab *bcread_ktab(LexState *ls) -{ - MSize narray = bcread_uleb128(ls); - MSize nhash = bcread_uleb128(ls); - GCtab *t = lj_tab_new(ls->L, narray, hsize2hbits(nhash)); - if (narray) { /* Read array entries. */ - MSize i; - TValue *o = tvref(t->array); - for (i = 0; i < narray; i++, o++) - bcread_ktabk(ls, o); - } - if (nhash) { /* Read hash entries. */ - MSize i; - for (i = 0; i < nhash; i++) { - TValue key; - bcread_ktabk(ls, &key); - lua_assert(!tvisnil(&key)); - bcread_ktabk(ls, lj_tab_set(ls->L, t, &key)); - } - } - return t; -} - -/* Read GC constants of a prototype. */ -static void bcread_kgc(LexState *ls, GCproto *pt, MSize sizekgc) -{ - MSize i; - GCRef *kr = mref(pt->k, GCRef) - (ptrdiff_t)sizekgc; - for (i = 0; i < sizekgc; i++, kr++) { - MSize tp = bcread_uleb128(ls); - if (tp >= BCDUMP_KGC_STR) { - MSize len = tp - BCDUMP_KGC_STR; - const char *p = (const char *)bcread_mem(ls, len); - setgcref(*kr, obj2gco(lj_str_new(ls->L, p, len))); - } else if (tp == BCDUMP_KGC_TAB) { - setgcref(*kr, obj2gco(bcread_ktab(ls))); -#if LJ_HASFFI - } else if (tp != BCDUMP_KGC_CHILD) { - CTypeID id = tp == BCDUMP_KGC_COMPLEX ? CTID_COMPLEX_DOUBLE : - tp == BCDUMP_KGC_I64 ? CTID_INT64 : CTID_UINT64; - CTSize sz = tp == BCDUMP_KGC_COMPLEX ? 16 : 8; - GCcdata *cd = lj_cdata_new_(ls->L, id, sz); - TValue *p = (TValue *)cdataptr(cd); - setgcref(*kr, obj2gco(cd)); - p[0].u32.lo = bcread_uleb128(ls); - p[0].u32.hi = bcread_uleb128(ls); - if (tp == BCDUMP_KGC_COMPLEX) { - p[1].u32.lo = bcread_uleb128(ls); - p[1].u32.hi = bcread_uleb128(ls); - } -#endif - } else { - lua_State *L = ls->L; - lua_assert(tp == BCDUMP_KGC_CHILD); - if (L->top <= bcread_oldtop(L, ls)) /* Stack underflow? */ - bcread_error(ls, LJ_ERR_BCBAD); - L->top--; - setgcref(*kr, obj2gco(protoV(L->top))); - } - } -} - -/* Read number constants of a prototype. */ -static void bcread_knum(LexState *ls, GCproto *pt, MSize sizekn) -{ - MSize i; - TValue *o = mref(pt->k, TValue); - for (i = 0; i < sizekn; i++, o++) { - int isnum = (ls->p[0] & 1); - uint32_t lo = bcread_uleb128_33(ls); - if (isnum) { - o->u32.lo = lo; - o->u32.hi = bcread_uleb128(ls); - } else { - setintV(o, lo); - } - } -} - -/* Read bytecode instructions. */ -static void bcread_bytecode(LexState *ls, GCproto *pt, MSize sizebc) -{ - BCIns *bc = proto_bc(pt); - bc[0] = BCINS_AD((pt->flags & PROTO_VARARG) ? BC_FUNCV : BC_FUNCF, - pt->framesize, 0); - bcread_block(ls, bc+1, (sizebc-1)*(MSize)sizeof(BCIns)); - /* Swap bytecode instructions if the endianess differs. */ - if (bcread_swap(ls)) { - MSize i; - for (i = 1; i < sizebc; i++) bc[i] = lj_bswap(bc[i]); - } -} - -/* Read upvalue refs. */ -static void bcread_uv(LexState *ls, GCproto *pt, MSize sizeuv) -{ - if (sizeuv) { - uint16_t *uv = proto_uv(pt); - bcread_block(ls, uv, sizeuv*2); - /* Swap upvalue refs if the endianess differs. */ - if (bcread_swap(ls)) { - MSize i; - for (i = 0; i < sizeuv; i++) - uv[i] = (uint16_t)((uv[i] >> 8)|(uv[i] << 8)); - } - } -} - -/* Read a prototype. */ -static GCproto *bcread_proto(LexState *ls) -{ - GCproto *pt; - MSize framesize, numparams, flags, sizeuv, sizekgc, sizekn, sizebc, sizept; - MSize ofsk, ofsuv, ofsdbg; - MSize sizedbg = 0; - BCLine firstline = 0, numline = 0; - MSize len, startn; - - /* Read length. */ - if (ls->n > 0 && ls->p[0] == 0) { /* Shortcut EOF. */ - ls->n--; ls->p++; - return NULL; - } - bcread_want(ls, 5); - len = bcread_uleb128(ls); - if (!len) return NULL; /* EOF */ - bcread_need(ls, len); - startn = ls->n; - - /* Read prototype header. */ - flags = bcread_byte(ls); - numparams = bcread_byte(ls); - framesize = bcread_byte(ls); - sizeuv = bcread_byte(ls); - sizekgc = bcread_uleb128(ls); - sizekn = bcread_uleb128(ls); - sizebc = bcread_uleb128(ls) + 1; - if (!(bcread_flags(ls) & BCDUMP_F_STRIP)) { - sizedbg = bcread_uleb128(ls); - if (sizedbg) { - firstline = bcread_uleb128(ls); - numline = bcread_uleb128(ls); - } - } - - /* Calculate total size of prototype including all colocated arrays. */ - sizept = (MSize)sizeof(GCproto) + - sizebc*(MSize)sizeof(BCIns) + - sizekgc*(MSize)sizeof(GCRef); - sizept = (sizept + (MSize)sizeof(TValue)-1) & ~((MSize)sizeof(TValue)-1); - ofsk = sizept; sizept += sizekn*(MSize)sizeof(TValue); - ofsuv = sizept; sizept += ((sizeuv+1)&~1)*2; - ofsdbg = sizept; sizept += sizedbg; - - /* Allocate prototype object and initialize its fields. */ - pt = (GCproto *)lj_mem_newgco(ls->L, (MSize)sizept); - pt->gct = ~LJ_TPROTO; - pt->numparams = (uint8_t)numparams; - pt->framesize = (uint8_t)framesize; - pt->sizebc = sizebc; - setmref(pt->k, (char *)pt + ofsk); - setmref(pt->uv, (char *)pt + ofsuv); - pt->sizekgc = 0; /* Set to zero until fully initialized. */ - pt->sizekn = sizekn; - pt->sizept = sizept; - pt->sizeuv = (uint8_t)sizeuv; - pt->flags = (uint8_t)flags; - pt->trace = 0; - setgcref(pt->chunkname, obj2gco(ls->chunkname)); - - /* Close potentially uninitialized gap between bc and kgc. */ - *(uint32_t *)((char *)pt + ofsk - sizeof(GCRef)*(sizekgc+1)) = 0; - - /* Read bytecode instructions and upvalue refs. */ - bcread_bytecode(ls, pt, sizebc); - bcread_uv(ls, pt, sizeuv); - - /* Read constants. */ - bcread_kgc(ls, pt, sizekgc); - pt->sizekgc = sizekgc; - bcread_knum(ls, pt, sizekn); - - /* Read and initialize debug info. */ - pt->firstline = firstline; - pt->numline = numline; - if (sizedbg) { - MSize sizeli = (sizebc-1) << (numline < 256 ? 0 : numline < 65536 ? 1 : 2); - setmref(pt->lineinfo, (char *)pt + ofsdbg); - setmref(pt->uvinfo, (char *)pt + ofsdbg + sizeli); - bcread_dbg(ls, pt, sizedbg); - setmref(pt->varinfo, bcread_varinfo(pt)); - } else { - setmref(pt->lineinfo, NULL); - setmref(pt->uvinfo, NULL); - setmref(pt->varinfo, NULL); - } - - if (len != startn - ls->n) - bcread_error(ls, LJ_ERR_BCBAD); - return pt; -} - -/* Read and check header of bytecode dump. */ -static int bcread_header(LexState *ls) -{ - uint32_t flags; - bcread_want(ls, 3+5+5); - if (bcread_byte(ls) != BCDUMP_HEAD2 || - bcread_byte(ls) != BCDUMP_HEAD3 || - bcread_byte(ls) != BCDUMP_VERSION) return 0; - bcread_flags(ls) = flags = bcread_uleb128(ls); - if ((flags & ~(BCDUMP_F_KNOWN)) != 0) return 0; - if ((flags & BCDUMP_F_FFI)) { -#if LJ_HASFFI - lua_State *L = ls->L; - if (!ctype_ctsG(G(L))) { - ptrdiff_t oldtop = savestack(L, L->top); - luaopen_ffi(L); /* Load FFI library on-demand. */ - L->top = restorestack(L, oldtop); - } -#else - return 0; -#endif - } - if ((flags & BCDUMP_F_STRIP)) { - ls->chunkname = lj_str_newz(ls->L, ls->chunkarg); - } else { - MSize len = bcread_uleb128(ls); - bcread_need(ls, len); - ls->chunkname = lj_str_new(ls->L, (const char *)bcread_mem(ls, len), len); - } - return 1; /* Ok. */ -} - -/* Read a bytecode dump. */ -GCproto *lj_bcread(LexState *ls) -{ - lua_State *L = ls->L; - lua_assert(ls->current == BCDUMP_HEAD1); - bcread_savetop(L, ls, L->top); - lj_str_resetbuf(&ls->sb); - /* Check for a valid bytecode dump header. */ - if (!bcread_header(ls)) - bcread_error(ls, LJ_ERR_BCFMT); - for (;;) { /* Process all prototypes in the bytecode dump. */ - GCproto *pt = bcread_proto(ls); - if (!pt) break; - setprotoV(L, L->top, pt); - incr_top(L); - } - if ((int32_t)ls->n > 0 || L->top-1 != bcread_oldtop(L, ls)) - bcread_error(ls, LJ_ERR_BCBAD); - /* Pop off last prototype. */ - L->top--; - return protoV(L->top); -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_bcwrite.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_bcwrite.c deleted file mode 100644 index dcdaa10a6..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_bcwrite.c +++ /dev/null @@ -1,396 +0,0 @@ -/* -** Bytecode writer. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_bcwrite_c -#define LUA_CORE - -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_str.h" -#include "lj_bc.h" -#if LJ_HASFFI -#include "lj_ctype.h" -#endif -#if LJ_HASJIT -#include "lj_dispatch.h" -#include "lj_jit.h" -#endif -#include "lj_bcdump.h" -#include "lj_vm.h" - -/* Context for bytecode writer. */ -typedef struct BCWriteCtx { - SBuf sb; /* Output buffer. */ - lua_State *L; /* Lua state. */ - GCproto *pt; /* Root prototype. */ - lua_Writer wfunc; /* Writer callback. */ - void *wdata; /* Writer callback data. */ - int strip; /* Strip debug info. */ - int status; /* Status from writer callback. */ -} BCWriteCtx; - -/* -- Output buffer handling ---------------------------------------------- */ - -/* Resize buffer if needed. */ -static LJ_NOINLINE void bcwrite_resize(BCWriteCtx *ctx, MSize len) -{ - MSize sz = ctx->sb.sz * 2; - while (ctx->sb.n + len > sz) sz = sz * 2; - lj_str_resizebuf(ctx->L, &ctx->sb, sz); -} - -/* Need a certain amount of buffer space. */ -static LJ_AINLINE void bcwrite_need(BCWriteCtx *ctx, MSize len) -{ - if (LJ_UNLIKELY(ctx->sb.n + len > ctx->sb.sz)) - bcwrite_resize(ctx, len); -} - -/* Add memory block to buffer. */ -static void bcwrite_block(BCWriteCtx *ctx, const void *p, MSize len) -{ - uint8_t *q = (uint8_t *)(ctx->sb.buf + ctx->sb.n); - MSize i; - ctx->sb.n += len; - for (i = 0; i < len; i++) q[i] = ((uint8_t *)p)[i]; -} - -/* Add byte to buffer. */ -static LJ_AINLINE void bcwrite_byte(BCWriteCtx *ctx, uint8_t b) -{ - ctx->sb.buf[ctx->sb.n++] = b; -} - -/* Add ULEB128 value to buffer. */ -static void bcwrite_uleb128(BCWriteCtx *ctx, uint32_t v) -{ - MSize n = ctx->sb.n; - uint8_t *p = (uint8_t *)ctx->sb.buf; - for (; v >= 0x80; v >>= 7) - p[n++] = (uint8_t)((v & 0x7f) | 0x80); - p[n++] = (uint8_t)v; - ctx->sb.n = n; -} - -/* -- Bytecode writer ----------------------------------------------------- */ - -/* Write a single constant key/value of a template table. */ -static void bcwrite_ktabk(BCWriteCtx *ctx, cTValue *o, int narrow) -{ - bcwrite_need(ctx, 1+10); - if (tvisstr(o)) { - const GCstr *str = strV(o); - MSize len = str->len; - bcwrite_need(ctx, 5+len); - bcwrite_uleb128(ctx, BCDUMP_KTAB_STR+len); - bcwrite_block(ctx, strdata(str), len); - } else if (tvisint(o)) { - bcwrite_byte(ctx, BCDUMP_KTAB_INT); - bcwrite_uleb128(ctx, intV(o)); - } else if (tvisnum(o)) { - if (!LJ_DUALNUM && narrow) { /* Narrow number constants to integers. */ - lua_Number num = numV(o); - int32_t k = lj_num2int(num); - if (num == (lua_Number)k) { /* -0 is never a constant. */ - bcwrite_byte(ctx, BCDUMP_KTAB_INT); - bcwrite_uleb128(ctx, k); - return; - } - } - bcwrite_byte(ctx, BCDUMP_KTAB_NUM); - bcwrite_uleb128(ctx, o->u32.lo); - bcwrite_uleb128(ctx, o->u32.hi); - } else { - lua_assert(tvispri(o)); - bcwrite_byte(ctx, BCDUMP_KTAB_NIL+~itype(o)); - } -} - -/* Write a template table. */ -static void bcwrite_ktab(BCWriteCtx *ctx, const GCtab *t) -{ - MSize narray = 0, nhash = 0; - if (t->asize > 0) { /* Determine max. length of array part. */ - ptrdiff_t i; - TValue *array = tvref(t->array); - for (i = (ptrdiff_t)t->asize-1; i >= 0; i--) - if (!tvisnil(&array[i])) - break; - narray = (MSize)(i+1); - } - if (t->hmask > 0) { /* Count number of used hash slots. */ - MSize i, hmask = t->hmask; - Node *node = noderef(t->node); - for (i = 0; i <= hmask; i++) - nhash += !tvisnil(&node[i].val); - } - /* Write number of array slots and hash slots. */ - bcwrite_uleb128(ctx, narray); - bcwrite_uleb128(ctx, nhash); - if (narray) { /* Write array entries (may contain nil). */ - MSize i; - TValue *o = tvref(t->array); - for (i = 0; i < narray; i++, o++) - bcwrite_ktabk(ctx, o, 1); - } - if (nhash) { /* Write hash entries. */ - MSize i = nhash; - Node *node = noderef(t->node) + t->hmask; - for (;; node--) - if (!tvisnil(&node->val)) { - bcwrite_ktabk(ctx, &node->key, 0); - bcwrite_ktabk(ctx, &node->val, 1); - if (--i == 0) break; - } - } -} - -/* Write GC constants of a prototype. */ -static void bcwrite_kgc(BCWriteCtx *ctx, GCproto *pt) -{ - MSize i, sizekgc = pt->sizekgc; - GCRef *kr = mref(pt->k, GCRef) - (ptrdiff_t)sizekgc; - for (i = 0; i < sizekgc; i++, kr++) { - GCobj *o = gcref(*kr); - MSize tp, need = 1; - /* Determine constant type and needed size. */ - if (o->gch.gct == ~LJ_TSTR) { - tp = BCDUMP_KGC_STR + gco2str(o)->len; - need = 5+gco2str(o)->len; - } else if (o->gch.gct == ~LJ_TPROTO) { - lua_assert((pt->flags & PROTO_CHILD)); - tp = BCDUMP_KGC_CHILD; -#if LJ_HASFFI - } else if (o->gch.gct == ~LJ_TCDATA) { - CTypeID id = gco2cd(o)->ctypeid; - need = 1+4*5; - if (id == CTID_INT64) { - tp = BCDUMP_KGC_I64; - } else if (id == CTID_UINT64) { - tp = BCDUMP_KGC_U64; - } else { - lua_assert(id == CTID_COMPLEX_DOUBLE); - tp = BCDUMP_KGC_COMPLEX; - } -#endif - } else { - lua_assert(o->gch.gct == ~LJ_TTAB); - tp = BCDUMP_KGC_TAB; - need = 1+2*5; - } - /* Write constant type. */ - bcwrite_need(ctx, need); - bcwrite_uleb128(ctx, tp); - /* Write constant data (if any). */ - if (tp >= BCDUMP_KGC_STR) { - bcwrite_block(ctx, strdata(gco2str(o)), gco2str(o)->len); - } else if (tp == BCDUMP_KGC_TAB) { - bcwrite_ktab(ctx, gco2tab(o)); -#if LJ_HASFFI - } else if (tp != BCDUMP_KGC_CHILD) { - cTValue *p = (TValue *)cdataptr(gco2cd(o)); - bcwrite_uleb128(ctx, p[0].u32.lo); - bcwrite_uleb128(ctx, p[0].u32.hi); - if (tp == BCDUMP_KGC_COMPLEX) { - bcwrite_uleb128(ctx, p[1].u32.lo); - bcwrite_uleb128(ctx, p[1].u32.hi); - } -#endif - } - } -} - -/* Write number constants of a prototype. */ -static void bcwrite_knum(BCWriteCtx *ctx, GCproto *pt) -{ - MSize i, sizekn = pt->sizekn; - cTValue *o = mref(pt->k, TValue); - bcwrite_need(ctx, 10*sizekn); - for (i = 0; i < sizekn; i++, o++) { - int32_t k; - if (tvisint(o)) { - k = intV(o); - goto save_int; - } else { - /* Write a 33 bit ULEB128 for the int (lsb=0) or loword (lsb=1). */ - if (!LJ_DUALNUM) { /* Narrow number constants to integers. */ - lua_Number num = numV(o); - k = lj_num2int(num); - if (num == (lua_Number)k) { /* -0 is never a constant. */ - save_int: - bcwrite_uleb128(ctx, 2*(uint32_t)k | ((uint32_t)k & 0x80000000u)); - if (k < 0) { - char *p = &ctx->sb.buf[ctx->sb.n-1]; - *p = (*p & 7) | ((k>>27) & 0x18); - } - continue; - } - } - bcwrite_uleb128(ctx, 1+(2*o->u32.lo | (o->u32.lo & 0x80000000u))); - if (o->u32.lo >= 0x80000000u) { - char *p = &ctx->sb.buf[ctx->sb.n-1]; - *p = (*p & 7) | ((o->u32.lo>>27) & 0x18); - } - bcwrite_uleb128(ctx, o->u32.hi); - } - } -} - -/* Write bytecode instructions. */ -static void bcwrite_bytecode(BCWriteCtx *ctx, GCproto *pt) -{ - MSize nbc = pt->sizebc-1; /* Omit the [JI]FUNC* header. */ -#if LJ_HASJIT - uint8_t *p = (uint8_t *)&ctx->sb.buf[ctx->sb.n]; -#endif - bcwrite_block(ctx, proto_bc(pt)+1, nbc*(MSize)sizeof(BCIns)); -#if LJ_HASJIT - /* Unpatch modified bytecode containing ILOOP/JLOOP etc. */ - if ((pt->flags & PROTO_ILOOP) || pt->trace) { - jit_State *J = L2J(ctx->L); - MSize i; - for (i = 0; i < nbc; i++, p += sizeof(BCIns)) { - BCOp op = (BCOp)p[LJ_ENDIAN_SELECT(0, 3)]; - if (op == BC_IFORL || op == BC_IITERL || op == BC_ILOOP || - op == BC_JFORI) { - p[LJ_ENDIAN_SELECT(0, 3)] = (uint8_t)(op-BC_IFORL+BC_FORL); - } else if (op == BC_JFORL || op == BC_JITERL || op == BC_JLOOP) { - BCReg rd = p[LJ_ENDIAN_SELECT(2, 1)] + (p[LJ_ENDIAN_SELECT(3, 0)] << 8); - BCIns ins = traceref(J, rd)->startins; - p[LJ_ENDIAN_SELECT(0, 3)] = (uint8_t)(op-BC_JFORL+BC_FORL); - p[LJ_ENDIAN_SELECT(2, 1)] = bc_c(ins); - p[LJ_ENDIAN_SELECT(3, 0)] = bc_b(ins); - } - } - } -#endif -} - -/* Write prototype. */ -static void bcwrite_proto(BCWriteCtx *ctx, GCproto *pt) -{ - MSize sizedbg = 0; - - /* Recursively write children of prototype. */ - if ((pt->flags & PROTO_CHILD)) { - ptrdiff_t i, n = pt->sizekgc; - GCRef *kr = mref(pt->k, GCRef) - 1; - for (i = 0; i < n; i++, kr--) { - GCobj *o = gcref(*kr); - if (o->gch.gct == ~LJ_TPROTO) - bcwrite_proto(ctx, gco2pt(o)); - } - } - - /* Start writing the prototype info to a buffer. */ - lj_str_resetbuf(&ctx->sb); - ctx->sb.n = 5; /* Leave room for final size. */ - bcwrite_need(ctx, 4+6*5+(pt->sizebc-1)*(MSize)sizeof(BCIns)+pt->sizeuv*2); - - /* Write prototype header. */ - bcwrite_byte(ctx, (pt->flags & (PROTO_CHILD|PROTO_VARARG|PROTO_FFI))); - bcwrite_byte(ctx, pt->numparams); - bcwrite_byte(ctx, pt->framesize); - bcwrite_byte(ctx, pt->sizeuv); - bcwrite_uleb128(ctx, pt->sizekgc); - bcwrite_uleb128(ctx, pt->sizekn); - bcwrite_uleb128(ctx, pt->sizebc-1); - if (!ctx->strip) { - if (proto_lineinfo(pt)) - sizedbg = pt->sizept - (MSize)((char *)proto_lineinfo(pt) - (char *)pt); - bcwrite_uleb128(ctx, sizedbg); - if (sizedbg) { - bcwrite_uleb128(ctx, pt->firstline); - bcwrite_uleb128(ctx, pt->numline); - } - } - - /* Write bytecode instructions and upvalue refs. */ - bcwrite_bytecode(ctx, pt); - bcwrite_block(ctx, proto_uv(pt), pt->sizeuv*2); - - /* Write constants. */ - bcwrite_kgc(ctx, pt); - bcwrite_knum(ctx, pt); - - /* Write debug info, if not stripped. */ - if (sizedbg) { - bcwrite_need(ctx, sizedbg); - bcwrite_block(ctx, proto_lineinfo(pt), sizedbg); - } - - /* Pass buffer to writer function. */ - if (ctx->status == 0) { - MSize n = ctx->sb.n - 5; - MSize nn = (lj_fls(n)+8)*9 >> 6; - ctx->sb.n = 5 - nn; - bcwrite_uleb128(ctx, n); /* Fill in final size. */ - lua_assert(ctx->sb.n == 5); - ctx->status = ctx->wfunc(ctx->L, ctx->sb.buf+5-nn, nn+n, ctx->wdata); - } -} - -/* Write header of bytecode dump. */ -static void bcwrite_header(BCWriteCtx *ctx) -{ - GCstr *chunkname = proto_chunkname(ctx->pt); - const char *name = strdata(chunkname); - MSize len = chunkname->len; - lj_str_resetbuf(&ctx->sb); - bcwrite_need(ctx, 5+5+len); - bcwrite_byte(ctx, BCDUMP_HEAD1); - bcwrite_byte(ctx, BCDUMP_HEAD2); - bcwrite_byte(ctx, BCDUMP_HEAD3); - bcwrite_byte(ctx, BCDUMP_VERSION); - bcwrite_byte(ctx, (ctx->strip ? BCDUMP_F_STRIP : 0) + - (LJ_BE ? BCDUMP_F_BE : 0) + - ((ctx->pt->flags & PROTO_FFI) ? BCDUMP_F_FFI : 0)); - if (!ctx->strip) { - bcwrite_uleb128(ctx, len); - bcwrite_block(ctx, name, len); - } - ctx->status = ctx->wfunc(ctx->L, ctx->sb.buf, ctx->sb.n, ctx->wdata); -} - -/* Write footer of bytecode dump. */ -static void bcwrite_footer(BCWriteCtx *ctx) -{ - if (ctx->status == 0) { - uint8_t zero = 0; - ctx->status = ctx->wfunc(ctx->L, &zero, 1, ctx->wdata); - } -} - -/* Protected callback for bytecode writer. */ -static TValue *cpwriter(lua_State *L, lua_CFunction dummy, void *ud) -{ - BCWriteCtx *ctx = (BCWriteCtx *)ud; - UNUSED(dummy); - lj_str_resizebuf(L, &ctx->sb, 1024); /* Avoids resize for most prototypes. */ - bcwrite_header(ctx); - bcwrite_proto(ctx, ctx->pt); - bcwrite_footer(ctx); - return NULL; -} - -/* Write bytecode for a prototype. */ -int lj_bcwrite(lua_State *L, GCproto *pt, lua_Writer writer, void *data, - int strip) -{ - BCWriteCtx ctx; - int status; - ctx.L = L; - ctx.pt = pt; - ctx.wfunc = writer; - ctx.wdata = data; - ctx.strip = strip; - ctx.status = 0; - lj_str_initbuf(&ctx.sb); - status = lj_vm_cpcall(L, NULL, &ctx, cpwriter); - if (status == 0) status = ctx.status; - lj_str_freebuf(G(ctx.L), &ctx.sb); - return status; -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_carith.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_carith.c deleted file mode 100644 index 9f94091d4..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_carith.c +++ /dev/null @@ -1,351 +0,0 @@ -/* -** C data arithmetic. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#include "lj_obj.h" - -#if LJ_HASFFI - -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_tab.h" -#include "lj_meta.h" -#include "lj_ctype.h" -#include "lj_cconv.h" -#include "lj_cdata.h" -#include "lj_carith.h" - -/* -- C data arithmetic --------------------------------------------------- */ - -/* Binary operands of an operator converted to ctypes. */ -typedef struct CDArith { - uint8_t *p[2]; - CType *ct[2]; -} CDArith; - -/* Check arguments for arithmetic metamethods. */ -static int carith_checkarg(lua_State *L, CTState *cts, CDArith *ca) -{ - TValue *o = L->base; - int ok = 1; - MSize i; - if (o+1 >= L->top) - lj_err_argt(L, 1, LUA_TCDATA); - for (i = 0; i < 2; i++, o++) { - if (tviscdata(o)) { - GCcdata *cd = cdataV(o); - CTypeID id = (CTypeID)cd->ctypeid; - CType *ct = ctype_raw(cts, id); - uint8_t *p = (uint8_t *)cdataptr(cd); - if (ctype_isptr(ct->info)) { - p = (uint8_t *)cdata_getptr(p, ct->size); - if (ctype_isref(ct->info)) ct = ctype_rawchild(cts, ct); - } else if (ctype_isfunc(ct->info)) { - p = (uint8_t *)*(void **)p; - ct = ctype_get(cts, - lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|id), CTSIZE_PTR)); - } - if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); - ca->ct[i] = ct; - ca->p[i] = p; - } else if (tvisint(o)) { - ca->ct[i] = ctype_get(cts, CTID_INT32); - ca->p[i] = (uint8_t *)&o->i; - } else if (tvisnum(o)) { - ca->ct[i] = ctype_get(cts, CTID_DOUBLE); - ca->p[i] = (uint8_t *)&o->n; - } else if (tvisnil(o)) { - ca->ct[i] = ctype_get(cts, CTID_P_VOID); - ca->p[i] = (uint8_t *)0; - } else if (tvisstr(o)) { - TValue *o2 = i == 0 ? o+1 : o-1; - CType *ct = ctype_raw(cts, cdataV(o2)->ctypeid); - ca->ct[i] = NULL; - ca->p[i] = NULL; - ok = 0; - if (ctype_isenum(ct->info)) { - CTSize ofs; - CType *cct = lj_ctype_getfield(cts, ct, strV(o), &ofs); - if (cct && ctype_isconstval(cct->info)) { - ca->ct[i] = ctype_child(cts, cct); - ca->p[i] = (uint8_t *)&cct->size; /* Assumes ct does not grow. */ - ok = 1; - } else { - ca->ct[1-i] = ct; /* Use enum to improve error message. */ - ca->p[1-i] = NULL; - break; - } - } - } else { - ca->ct[i] = NULL; - ca->p[i] = NULL; - ok = 0; - } - } - return ok; -} - -/* Pointer arithmetic. */ -static int carith_ptr(lua_State *L, CTState *cts, CDArith *ca, MMS mm) -{ - CType *ctp = ca->ct[0]; - uint8_t *pp = ca->p[0]; - ptrdiff_t idx; - CTSize sz; - CTypeID id; - GCcdata *cd; - if (ctype_isptr(ctp->info) || ctype_isrefarray(ctp->info)) { - if ((mm == MM_sub || mm == MM_eq || mm == MM_lt || mm == MM_le) && - (ctype_isptr(ca->ct[1]->info) || ctype_isrefarray(ca->ct[1]->info))) { - uint8_t *pp2 = ca->p[1]; - if (mm == MM_eq) { /* Pointer equality. Incompatible pointers are ok. */ - setboolV(L->top-1, (pp == pp2)); - return 1; - } - if (!lj_cconv_compatptr(cts, ctp, ca->ct[1], CCF_IGNQUAL)) - return 0; - if (mm == MM_sub) { /* Pointer difference. */ - intptr_t diff; - sz = lj_ctype_size(cts, ctype_cid(ctp->info)); /* Element size. */ - if (sz == 0 || sz == CTSIZE_INVALID) - return 0; - diff = ((intptr_t)pp - (intptr_t)pp2) / (int32_t)sz; - /* All valid pointer differences on x64 are in (-2^47, +2^47), - ** which fits into a double without loss of precision. - */ - setintptrV(L->top-1, (int32_t)diff); - return 1; - } else if (mm == MM_lt) { /* Pointer comparison (unsigned). */ - setboolV(L->top-1, ((uintptr_t)pp < (uintptr_t)pp2)); - return 1; - } else { - lua_assert(mm == MM_le); - setboolV(L->top-1, ((uintptr_t)pp <= (uintptr_t)pp2)); - return 1; - } - } - if (!((mm == MM_add || mm == MM_sub) && ctype_isnum(ca->ct[1]->info))) - return 0; - lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT_PSZ), ca->ct[1], - (uint8_t *)&idx, ca->p[1], 0); - if (mm == MM_sub) idx = -idx; - } else if (mm == MM_add && ctype_isnum(ctp->info) && - (ctype_isptr(ca->ct[1]->info) || ctype_isrefarray(ca->ct[1]->info))) { - /* Swap pointer and index. */ - ctp = ca->ct[1]; pp = ca->p[1]; - lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT_PSZ), ca->ct[0], - (uint8_t *)&idx, ca->p[0], 0); - } else { - return 0; - } - sz = lj_ctype_size(cts, ctype_cid(ctp->info)); /* Element size. */ - if (sz == CTSIZE_INVALID) - return 0; - pp += idx*(int32_t)sz; /* Compute pointer + index. */ - id = lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|ctype_cid(ctp->info)), - CTSIZE_PTR); - cd = lj_cdata_new(cts, id, CTSIZE_PTR); - *(uint8_t **)cdataptr(cd) = pp; - setcdataV(L, L->top-1, cd); - lj_gc_check(L); - return 1; -} - -/* 64 bit integer arithmetic. */ -static int carith_int64(lua_State *L, CTState *cts, CDArith *ca, MMS mm) -{ - if (ctype_isnum(ca->ct[0]->info) && ca->ct[0]->size <= 8 && - ctype_isnum(ca->ct[1]->info) && ca->ct[1]->size <= 8) { - CTypeID id = (((ca->ct[0]->info & CTF_UNSIGNED) && ca->ct[0]->size == 8) || - ((ca->ct[1]->info & CTF_UNSIGNED) && ca->ct[1]->size == 8)) ? - CTID_UINT64 : CTID_INT64; - CType *ct = ctype_get(cts, id); - GCcdata *cd; - uint64_t u0, u1, *up; - lj_cconv_ct_ct(cts, ct, ca->ct[0], (uint8_t *)&u0, ca->p[0], 0); - if (mm != MM_unm) - lj_cconv_ct_ct(cts, ct, ca->ct[1], (uint8_t *)&u1, ca->p[1], 0); - switch (mm) { - case MM_eq: - setboolV(L->top-1, (u0 == u1)); - return 1; - case MM_lt: - setboolV(L->top-1, - id == CTID_INT64 ? ((int64_t)u0 < (int64_t)u1) : (u0 < u1)); - return 1; - case MM_le: - setboolV(L->top-1, - id == CTID_INT64 ? ((int64_t)u0 <= (int64_t)u1) : (u0 <= u1)); - return 1; - default: break; - } - cd = lj_cdata_new(cts, id, 8); - up = (uint64_t *)cdataptr(cd); - setcdataV(L, L->top-1, cd); - switch (mm) { - case MM_add: *up = u0 + u1; break; - case MM_sub: *up = u0 - u1; break; - case MM_mul: *up = u0 * u1; break; - case MM_div: - if (id == CTID_INT64) - *up = (uint64_t)lj_carith_divi64((int64_t)u0, (int64_t)u1); - else - *up = lj_carith_divu64(u0, u1); - break; - case MM_mod: - if (id == CTID_INT64) - *up = (uint64_t)lj_carith_modi64((int64_t)u0, (int64_t)u1); - else - *up = lj_carith_modu64(u0, u1); - break; - case MM_pow: - if (id == CTID_INT64) - *up = (uint64_t)lj_carith_powi64((int64_t)u0, (int64_t)u1); - else - *up = lj_carith_powu64(u0, u1); - break; - case MM_unm: *up = (uint64_t)-(int64_t)u0; break; - default: lua_assert(0); break; - } - lj_gc_check(L); - return 1; - } - return 0; -} - -/* Handle ctype arithmetic metamethods. */ -static int lj_carith_meta(lua_State *L, CTState *cts, CDArith *ca, MMS mm) -{ - cTValue *tv = NULL; - if (tviscdata(L->base)) { - CTypeID id = cdataV(L->base)->ctypeid; - CType *ct = ctype_raw(cts, id); - if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); - tv = lj_ctype_meta(cts, id, mm); - } - if (!tv && L->base+1 < L->top && tviscdata(L->base+1)) { - CTypeID id = cdataV(L->base+1)->ctypeid; - CType *ct = ctype_raw(cts, id); - if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); - tv = lj_ctype_meta(cts, id, mm); - } - if (!tv) { - const char *repr[2]; - int i, isenum = -1, isstr = -1; - if (mm == MM_eq) { /* Equality checks never raise an error. */ - setboolV(L->top-1, 0); - return 1; - } - for (i = 0; i < 2; i++) { - if (ca->ct[i] && tviscdata(L->base+i)) { - if (ctype_isenum(ca->ct[i]->info)) isenum = i; - repr[i] = strdata(lj_ctype_repr(L, ctype_typeid(cts, ca->ct[i]), NULL)); - } else { - if (tvisstr(&L->base[i])) isstr = i; - repr[i] = lj_typename(&L->base[i]); - } - } - if ((isenum ^ isstr) == 1) - lj_err_callerv(L, LJ_ERR_FFI_BADCONV, repr[isstr], repr[isenum]); - lj_err_callerv(L, mm == MM_len ? LJ_ERR_FFI_BADLEN : - mm == MM_concat ? LJ_ERR_FFI_BADCONCAT : - mm < MM_add ? LJ_ERR_FFI_BADCOMP : LJ_ERR_FFI_BADARITH, - repr[0], repr[1]); - } - return lj_meta_tailcall(L, tv); -} - -/* Arithmetic operators for cdata. */ -int lj_carith_op(lua_State *L, MMS mm) -{ - CTState *cts = ctype_cts(L); - CDArith ca; - if (carith_checkarg(L, cts, &ca)) { - if (carith_int64(L, cts, &ca, mm) || carith_ptr(L, cts, &ca, mm)) { - copyTV(L, &G(L)->tmptv2, L->top-1); /* Remember for trace recorder. */ - return 1; - } - } - return lj_carith_meta(L, cts, &ca, mm); -} - -/* -- 64 bit integer arithmetic helpers ----------------------------------- */ - -#if LJ_32 && LJ_HASJIT -/* Signed/unsigned 64 bit multiplication. */ -int64_t lj_carith_mul64(int64_t a, int64_t b) -{ - return a * b; -} -#endif - -/* Unsigned 64 bit division. */ -uint64_t lj_carith_divu64(uint64_t a, uint64_t b) -{ - if (b == 0) return U64x(80000000,00000000); - return a / b; -} - -/* Signed 64 bit division. */ -int64_t lj_carith_divi64(int64_t a, int64_t b) -{ - if (b == 0 || (a == (int64_t)U64x(80000000,00000000) && b == -1)) - return U64x(80000000,00000000); - return a / b; -} - -/* Unsigned 64 bit modulo. */ -uint64_t lj_carith_modu64(uint64_t a, uint64_t b) -{ - if (b == 0) return U64x(80000000,00000000); - return a % b; -} - -/* Signed 64 bit modulo. */ -int64_t lj_carith_modi64(int64_t a, int64_t b) -{ - if (b == 0) return U64x(80000000,00000000); - if (a == (int64_t)U64x(80000000,00000000) && b == -1) return 0; - return a % b; -} - -/* Unsigned 64 bit x^k. */ -uint64_t lj_carith_powu64(uint64_t x, uint64_t k) -{ - uint64_t y; - if (k == 0) - return 1; - for (; (k & 1) == 0; k >>= 1) x *= x; - y = x; - if ((k >>= 1) != 0) { - for (;;) { - x *= x; - if (k == 1) break; - if (k & 1) y *= x; - k >>= 1; - } - y *= x; - } - return y; -} - -/* Signed 64 bit x^k. */ -int64_t lj_carith_powi64(int64_t x, int64_t k) -{ - if (k == 0) - return 1; - if (k < 0) { - if (x == 0) - return U64x(7fffffff,ffffffff); - else if (x == 1) - return 1; - else if (x == -1) - return (k & 1) ? -1 : 1; - else - return 0; - } - return (int64_t)lj_carith_powu64((uint64_t)x, (uint64_t)k); -} - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_carith.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_carith.h deleted file mode 100644 index 8b28556d8..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_carith.h +++ /dev/null @@ -1,27 +0,0 @@ -/* -** C data arithmetic. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_CARITH_H -#define _LJ_CARITH_H - -#include "lj_obj.h" - -#if LJ_HASFFI - -LJ_FUNC int lj_carith_op(lua_State *L, MMS mm); - -#if LJ_32 && LJ_HASJIT -LJ_FUNC int64_t lj_carith_mul64(int64_t x, int64_t k); -#endif -LJ_FUNC uint64_t lj_carith_divu64(uint64_t a, uint64_t b); -LJ_FUNC int64_t lj_carith_divi64(int64_t a, int64_t b); -LJ_FUNC uint64_t lj_carith_modu64(uint64_t a, uint64_t b); -LJ_FUNC int64_t lj_carith_modi64(int64_t a, int64_t b); -LJ_FUNC uint64_t lj_carith_powu64(uint64_t x, uint64_t k); -LJ_FUNC int64_t lj_carith_powi64(int64_t x, int64_t k); - -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ccall.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_ccall.c deleted file mode 100644 index 70c9ba5ec..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ccall.c +++ /dev/null @@ -1,900 +0,0 @@ -/* -** FFI C call handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#include "lj_obj.h" - -#if LJ_HASFFI - -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_ctype.h" -#include "lj_cconv.h" -#include "lj_cdata.h" -#include "lj_ccall.h" -#include "lj_trace.h" - -/* Target-specific handling of register arguments. */ -#if LJ_TARGET_X86 -/* -- x86 calling conventions --------------------------------------------- */ - -#if LJ_ABI_WIN - -#define CCALL_HANDLE_STRUCTRET \ - /* Return structs bigger than 8 by reference (on stack only). */ \ - cc->retref = (sz > 8); \ - if (cc->retref) cc->stack[nsp++] = (GPRArg)dp; - -#define CCALL_HANDLE_COMPLEXRET CCALL_HANDLE_STRUCTRET - -#else - -#if LJ_TARGET_OSX - -#define CCALL_HANDLE_STRUCTRET \ - /* Return structs of size 1, 2, 4 or 8 in registers. */ \ - cc->retref = !(sz == 1 || sz == 2 || sz == 4 || sz == 8); \ - if (cc->retref) { \ - if (ngpr < maxgpr) \ - cc->gpr[ngpr++] = (GPRArg)dp; \ - else \ - cc->stack[nsp++] = (GPRArg)dp; \ - } else { /* Struct with single FP field ends up in FPR. */ \ - cc->resx87 = ccall_classify_struct(cts, ctr); \ - } - -#define CCALL_HANDLE_STRUCTRET2 \ - if (cc->resx87) sp = (uint8_t *)&cc->fpr[0]; \ - memcpy(dp, sp, ctr->size); - -#else - -#define CCALL_HANDLE_STRUCTRET \ - cc->retref = 1; /* Return all structs by reference (in reg or on stack). */ \ - if (ngpr < maxgpr) \ - cc->gpr[ngpr++] = (GPRArg)dp; \ - else \ - cc->stack[nsp++] = (GPRArg)dp; - -#endif - -#define CCALL_HANDLE_COMPLEXRET \ - /* Return complex float in GPRs and complex double by reference. */ \ - cc->retref = (sz > 8); \ - if (cc->retref) { \ - if (ngpr < maxgpr) \ - cc->gpr[ngpr++] = (GPRArg)dp; \ - else \ - cc->stack[nsp++] = (GPRArg)dp; \ - } - -#endif - -#define CCALL_HANDLE_COMPLEXRET2 \ - if (!cc->retref) \ - *(int64_t *)dp = *(int64_t *)sp; /* Copy complex float from GPRs. */ - -#define CCALL_HANDLE_STRUCTARG \ - ngpr = maxgpr; /* Pass all structs by value on the stack. */ - -#define CCALL_HANDLE_COMPLEXARG \ - isfp = 1; /* Pass complex by value on stack. */ - -#define CCALL_HANDLE_REGARG \ - if (!isfp) { /* Only non-FP values may be passed in registers. */ \ - if (n > 1) { /* Anything > 32 bit is passed on the stack. */ \ - if (!LJ_ABI_WIN) ngpr = maxgpr; /* Prevent reordering. */ \ - } else if (ngpr + 1 <= maxgpr) { \ - dp = &cc->gpr[ngpr]; \ - ngpr += n; \ - goto done; \ - } \ - } - -#elif LJ_TARGET_X64 && LJ_ABI_WIN -/* -- Windows/x64 calling conventions ------------------------------------- */ - -#define CCALL_HANDLE_STRUCTRET \ - /* Return structs of size 1, 2, 4 or 8 in a GPR. */ \ - cc->retref = !(sz == 1 || sz == 2 || sz == 4 || sz == 8); \ - if (cc->retref) cc->gpr[ngpr++] = (GPRArg)dp; - -#define CCALL_HANDLE_COMPLEXRET CCALL_HANDLE_STRUCTRET - -#define CCALL_HANDLE_COMPLEXRET2 \ - if (!cc->retref) \ - *(int64_t *)dp = *(int64_t *)sp; /* Copy complex float from GPRs. */ - -#define CCALL_HANDLE_STRUCTARG \ - /* Pass structs of size 1, 2, 4 or 8 in a GPR by value. */ \ - if (!(sz == 1 || sz == 2 || sz == 4 || sz == 8)) { \ - rp = cdataptr(lj_cdata_new(cts, did, sz)); \ - sz = CTSIZE_PTR; /* Pass all other structs by reference. */ \ - } - -#define CCALL_HANDLE_COMPLEXARG \ - /* Pass complex float in a GPR and complex double by reference. */ \ - if (sz != 2*sizeof(float)) { \ - rp = cdataptr(lj_cdata_new(cts, did, sz)); \ - sz = CTSIZE_PTR; \ - } - -/* Windows/x64 argument registers are strictly positional (use ngpr). */ -#define CCALL_HANDLE_REGARG \ - if (isfp) { \ - if (ngpr < maxgpr) { dp = &cc->fpr[ngpr++]; nfpr = ngpr; goto done; } \ - } else { \ - if (ngpr < maxgpr) { dp = &cc->gpr[ngpr++]; goto done; } \ - } - -#elif LJ_TARGET_X64 -/* -- POSIX/x64 calling conventions --------------------------------------- */ - -#define CCALL_HANDLE_STRUCTRET \ - int rcl[2]; rcl[0] = rcl[1] = 0; \ - if (ccall_classify_struct(cts, ctr, rcl, 0)) { \ - cc->retref = 1; /* Return struct by reference. */ \ - cc->gpr[ngpr++] = (GPRArg)dp; \ - } else { \ - cc->retref = 0; /* Return small structs in registers. */ \ - } - -#define CCALL_HANDLE_STRUCTRET2 \ - int rcl[2]; rcl[0] = rcl[1] = 0; \ - ccall_classify_struct(cts, ctr, rcl, 0); \ - ccall_struct_ret(cc, rcl, dp, ctr->size); - -#define CCALL_HANDLE_COMPLEXRET \ - /* Complex values are returned in one or two FPRs. */ \ - cc->retref = 0; - -#define CCALL_HANDLE_COMPLEXRET2 \ - if (ctr->size == 2*sizeof(float)) { /* Copy complex float from FPR. */ \ - *(int64_t *)dp = cc->fpr[0].l[0]; \ - } else { /* Copy non-contiguous complex double from FPRs. */ \ - ((int64_t *)dp)[0] = cc->fpr[0].l[0]; \ - ((int64_t *)dp)[1] = cc->fpr[1].l[0]; \ - } - -#define CCALL_HANDLE_STRUCTARG \ - int rcl[2]; rcl[0] = rcl[1] = 0; \ - if (!ccall_classify_struct(cts, d, rcl, 0)) { \ - cc->nsp = nsp; cc->ngpr = ngpr; cc->nfpr = nfpr; \ - if (ccall_struct_arg(cc, cts, d, rcl, o, narg)) goto err_nyi; \ - nsp = cc->nsp; ngpr = cc->ngpr; nfpr = cc->nfpr; \ - continue; \ - } /* Pass all other structs by value on stack. */ - -#define CCALL_HANDLE_COMPLEXARG \ - isfp = 2; /* Pass complex in FPRs or on stack. Needs postprocessing. */ - -#define CCALL_HANDLE_REGARG \ - if (isfp) { /* Try to pass argument in FPRs. */ \ - int n2 = ctype_isvector(d->info) ? 1 : n; \ - if (nfpr + n2 <= CCALL_NARG_FPR) { \ - dp = &cc->fpr[nfpr]; \ - nfpr += n2; \ - goto done; \ - } \ - } else { /* Try to pass argument in GPRs. */ \ - /* Note that reordering is explicitly allowed in the x64 ABI. */ \ - if (n <= 2 && ngpr + n <= maxgpr) { \ - dp = &cc->gpr[ngpr]; \ - ngpr += n; \ - goto done; \ - } \ - } - -#elif LJ_TARGET_ARM -/* -- ARM calling conventions --------------------------------------------- */ - -#if LJ_ABI_SOFTFP - -#define CCALL_HANDLE_STRUCTRET \ - /* Return structs of size <= 4 in a GPR. */ \ - cc->retref = !(sz <= 4); \ - if (cc->retref) cc->gpr[ngpr++] = (GPRArg)dp; - -#define CCALL_HANDLE_COMPLEXRET \ - cc->retref = 1; /* Return all complex values by reference. */ \ - cc->gpr[ngpr++] = (GPRArg)dp; - -#define CCALL_HANDLE_COMPLEXRET2 \ - UNUSED(dp); /* Nothing to do. */ - -#define CCALL_HANDLE_STRUCTARG \ - /* Pass all structs by value in registers and/or on the stack. */ - -#define CCALL_HANDLE_COMPLEXARG \ - /* Pass complex by value in 2 or 4 GPRs. */ - -#define CCALL_HANDLE_REGARG_FP1 -#define CCALL_HANDLE_REGARG_FP2 - -#else - -#define CCALL_HANDLE_STRUCTRET \ - cc->retref = !ccall_classify_struct(cts, ctr, ct); \ - if (cc->retref) cc->gpr[ngpr++] = (GPRArg)dp; - -#define CCALL_HANDLE_STRUCTRET2 \ - if (ccall_classify_struct(cts, ctr, ct) > 1) sp = (uint8_t *)&cc->fpr[0]; \ - memcpy(dp, sp, ctr->size); - -#define CCALL_HANDLE_COMPLEXRET \ - if (!(ct->info & CTF_VARARG)) cc->retref = 0; /* Return complex in FPRs. */ - -#define CCALL_HANDLE_COMPLEXRET2 \ - if (!(ct->info & CTF_VARARG)) memcpy(dp, &cc->fpr[0], ctr->size); - -#define CCALL_HANDLE_STRUCTARG \ - isfp = (ccall_classify_struct(cts, d, ct) > 1); - /* Pass all structs by value in registers and/or on the stack. */ - -#define CCALL_HANDLE_COMPLEXARG \ - isfp = 1; /* Pass complex by value in FPRs or on stack. */ - -#define CCALL_HANDLE_REGARG_FP1 \ - if (isfp && !(ct->info & CTF_VARARG)) { \ - if ((d->info & CTF_ALIGN) > CTALIGN_PTR) { \ - if (nfpr + (n >> 1) <= CCALL_NARG_FPR) { \ - dp = &cc->fpr[nfpr]; \ - nfpr += (n >> 1); \ - goto done; \ - } \ - } else { \ - if (sz > 1 && fprodd != nfpr) fprodd = 0; \ - if (fprodd) { \ - if (2*nfpr+n <= 2*CCALL_NARG_FPR+1) { \ - dp = (void *)&cc->fpr[fprodd-1].f[1]; \ - nfpr += (n >> 1); \ - if ((n & 1)) fprodd = 0; else fprodd = nfpr-1; \ - goto done; \ - } \ - } else { \ - if (2*nfpr+n <= 2*CCALL_NARG_FPR) { \ - dp = (void *)&cc->fpr[nfpr]; \ - nfpr += (n >> 1); \ - if ((n & 1)) fprodd = ++nfpr; else fprodd = 0; \ - goto done; \ - } \ - } \ - } \ - fprodd = 0; /* No reordering after the first FP value is on stack. */ \ - } else { - -#define CCALL_HANDLE_REGARG_FP2 } - -#endif - -#define CCALL_HANDLE_REGARG \ - CCALL_HANDLE_REGARG_FP1 \ - if ((d->info & CTF_ALIGN) > CTALIGN_PTR) { \ - if (ngpr < maxgpr) \ - ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \ - } \ - if (ngpr < maxgpr) { \ - dp = &cc->gpr[ngpr]; \ - if (ngpr + n > maxgpr) { \ - nsp += ngpr + n - maxgpr; /* Assumes contiguous gpr/stack fields. */ \ - if (nsp > CCALL_MAXSTACK) goto err_nyi; /* Too many arguments. */ \ - ngpr = maxgpr; \ - } else { \ - ngpr += n; \ - } \ - goto done; \ - } CCALL_HANDLE_REGARG_FP2 - -#define CCALL_HANDLE_RET \ - if ((ct->info & CTF_VARARG)) sp = (uint8_t *)&cc->gpr[0]; - -#elif LJ_TARGET_PPC -/* -- PPC calling conventions --------------------------------------------- */ - -#define CCALL_HANDLE_STRUCTRET \ - cc->retref = 1; /* Return all structs by reference. */ \ - cc->gpr[ngpr++] = (GPRArg)dp; - -#define CCALL_HANDLE_COMPLEXRET \ - /* Complex values are returned in 2 or 4 GPRs. */ \ - cc->retref = 0; - -#define CCALL_HANDLE_COMPLEXRET2 \ - memcpy(dp, sp, ctr->size); /* Copy complex from GPRs. */ - -#define CCALL_HANDLE_STRUCTARG \ - rp = cdataptr(lj_cdata_new(cts, did, sz)); \ - sz = CTSIZE_PTR; /* Pass all structs by reference. */ - -#define CCALL_HANDLE_COMPLEXARG \ - /* Pass complex by value in 2 or 4 GPRs. */ - -#define CCALL_HANDLE_REGARG \ - if (isfp) { /* Try to pass argument in FPRs. */ \ - if (nfpr + 1 <= CCALL_NARG_FPR) { \ - dp = &cc->fpr[nfpr]; \ - nfpr += 1; \ - d = ctype_get(cts, CTID_DOUBLE); /* FPRs always hold doubles. */ \ - goto done; \ - } \ - } else { /* Try to pass argument in GPRs. */ \ - if (n > 1) { \ - lua_assert(n == 2 || n == 4); /* int64_t or complex (float). */ \ - if (ctype_isinteger(d->info)) \ - ngpr = (ngpr + 1u) & ~1u; /* Align int64_t to regpair. */ \ - else if (ngpr + n > maxgpr) \ - ngpr = maxgpr; /* Prevent reordering. */ \ - } \ - if (ngpr + n <= maxgpr) { \ - dp = &cc->gpr[ngpr]; \ - ngpr += n; \ - goto done; \ - } \ - } - -#define CCALL_HANDLE_RET \ - if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \ - ctr = ctype_get(cts, CTID_DOUBLE); /* FPRs always hold doubles. */ - -#elif LJ_TARGET_PPCSPE -/* -- PPC/SPE calling conventions ----------------------------------------- */ - -#define CCALL_HANDLE_STRUCTRET \ - cc->retref = 1; /* Return all structs by reference. */ \ - cc->gpr[ngpr++] = (GPRArg)dp; - -#define CCALL_HANDLE_COMPLEXRET \ - /* Complex values are returned in 2 or 4 GPRs. */ \ - cc->retref = 0; - -#define CCALL_HANDLE_COMPLEXRET2 \ - memcpy(dp, sp, ctr->size); /* Copy complex from GPRs. */ - -#define CCALL_HANDLE_STRUCTARG \ - rp = cdataptr(lj_cdata_new(cts, did, sz)); \ - sz = CTSIZE_PTR; /* Pass all structs by reference. */ - -#define CCALL_HANDLE_COMPLEXARG \ - /* Pass complex by value in 2 or 4 GPRs. */ - -/* PPC/SPE has a softfp ABI. */ -#define CCALL_HANDLE_REGARG \ - if (n > 1) { /* Doesn't fit in a single GPR? */ \ - lua_assert(n == 2 || n == 4); /* int64_t, double or complex (float). */ \ - if (n == 2) \ - ngpr = (ngpr + 1u) & ~1u; /* Only align 64 bit value to regpair. */ \ - else if (ngpr + n > maxgpr) \ - ngpr = maxgpr; /* Prevent reordering. */ \ - } \ - if (ngpr + n <= maxgpr) { \ - dp = &cc->gpr[ngpr]; \ - ngpr += n; \ - goto done; \ - } - -#elif LJ_TARGET_MIPS -/* -- MIPS calling conventions -------------------------------------------- */ - -#define CCALL_HANDLE_STRUCTRET \ - cc->retref = 1; /* Return all structs by reference. */ \ - cc->gpr[ngpr++] = (GPRArg)dp; - -#define CCALL_HANDLE_COMPLEXRET \ - /* Complex values are returned in 1 or 2 FPRs. */ \ - cc->retref = 0; - -#define CCALL_HANDLE_COMPLEXRET2 \ - if (ctr->size == 2*sizeof(float)) { /* Copy complex float from FPRs. */ \ - ((float *)dp)[0] = cc->fpr[0].f; \ - ((float *)dp)[1] = cc->fpr[1].f; \ - } else { /* Copy complex double from FPRs. */ \ - ((double *)dp)[0] = cc->fpr[0].d; \ - ((double *)dp)[1] = cc->fpr[1].d; \ - } - -#define CCALL_HANDLE_STRUCTARG \ - /* Pass all structs by value in registers and/or on the stack. */ - -#define CCALL_HANDLE_COMPLEXARG \ - /* Pass complex by value in 2 or 4 GPRs. */ - -#define CCALL_HANDLE_REGARG \ - if (isfp && nfpr < CCALL_NARG_FPR && !(ct->info & CTF_VARARG)) { \ - /* Try to pass argument in FPRs. */ \ - dp = n == 1 ? (void *)&cc->fpr[nfpr].f : (void *)&cc->fpr[nfpr].d; \ - nfpr++; ngpr += n; \ - goto done; \ - } else { /* Try to pass argument in GPRs. */ \ - nfpr = CCALL_NARG_FPR; \ - if ((d->info & CTF_ALIGN) > CTALIGN_PTR) \ - ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \ - if (ngpr < maxgpr) { \ - dp = &cc->gpr[ngpr]; \ - if (ngpr + n > maxgpr) { \ - nsp += ngpr + n - maxgpr; /* Assumes contiguous gpr/stack fields. */ \ - if (nsp > CCALL_MAXSTACK) goto err_nyi; /* Too many arguments. */ \ - ngpr = maxgpr; \ - } else { \ - ngpr += n; \ - } \ - goto done; \ - } \ - } - -#define CCALL_HANDLE_RET \ - if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \ - sp = (uint8_t *)&cc->fpr[0].f; - -#else -#error "Missing calling convention definitions for this architecture" -#endif - -#ifndef CCALL_HANDLE_STRUCTRET2 -#define CCALL_HANDLE_STRUCTRET2 \ - memcpy(dp, sp, ctr->size); /* Copy struct return value from GPRs. */ -#endif - -/* -- x86 OSX ABI struct classification ----------------------------------- */ - -#if LJ_TARGET_X86 && LJ_TARGET_OSX - -/* Check for struct with single FP field. */ -static int ccall_classify_struct(CTState *cts, CType *ct) -{ - CTSize sz = ct->size; - if (!(sz == sizeof(float) || sz == sizeof(double))) return 0; - if ((ct->info & CTF_UNION)) return 0; - while (ct->sib) { - ct = ctype_get(cts, ct->sib); - if (ctype_isfield(ct->info)) { - CType *sct = ctype_rawchild(cts, ct); - if (ctype_isfp(sct->info)) { - if (sct->size == sz) - return (sz >> 2); /* Return 1 for float or 2 for double. */ - } else if (ctype_isstruct(sct->info)) { - if (sct->size) - return ccall_classify_struct(cts, sct); - } else { - break; - } - } else if (ctype_isbitfield(ct->info)) { - break; - } else if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) { - CType *sct = ctype_rawchild(cts, ct); - if (sct->size) - return ccall_classify_struct(cts, sct); - } - } - return 0; -} - -#endif - -/* -- x64 struct classification ------------------------------------------- */ - -#if LJ_TARGET_X64 && !LJ_ABI_WIN - -/* Register classes for x64 struct classification. */ -#define CCALL_RCL_INT 1 -#define CCALL_RCL_SSE 2 -#define CCALL_RCL_MEM 4 -/* NYI: classify vectors. */ - -static int ccall_classify_struct(CTState *cts, CType *ct, int *rcl, CTSize ofs); - -/* Classify a C type. */ -static void ccall_classify_ct(CTState *cts, CType *ct, int *rcl, CTSize ofs) -{ - if (ctype_isarray(ct->info)) { - CType *cct = ctype_rawchild(cts, ct); - CTSize eofs, esz = cct->size, asz = ct->size; - for (eofs = 0; eofs < asz; eofs += esz) - ccall_classify_ct(cts, cct, rcl, ofs+eofs); - } else if (ctype_isstruct(ct->info)) { - ccall_classify_struct(cts, ct, rcl, ofs); - } else { - int cl = ctype_isfp(ct->info) ? CCALL_RCL_SSE : CCALL_RCL_INT; - lua_assert(ctype_hassize(ct->info)); - if ((ofs & (ct->size-1))) cl = CCALL_RCL_MEM; /* Unaligned. */ - rcl[(ofs >= 8)] |= cl; - } -} - -/* Recursively classify a struct based on its fields. */ -static int ccall_classify_struct(CTState *cts, CType *ct, int *rcl, CTSize ofs) -{ - if (ct->size > 16) return CCALL_RCL_MEM; /* Too big, gets memory class. */ - while (ct->sib) { - CTSize fofs; - ct = ctype_get(cts, ct->sib); - fofs = ofs+ct->size; - if (ctype_isfield(ct->info)) - ccall_classify_ct(cts, ctype_rawchild(cts, ct), rcl, fofs); - else if (ctype_isbitfield(ct->info)) - rcl[(fofs >= 8)] |= CCALL_RCL_INT; /* NYI: unaligned bitfields? */ - else if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) - ccall_classify_struct(cts, ctype_rawchild(cts, ct), rcl, fofs); - } - return ((rcl[0]|rcl[1]) & CCALL_RCL_MEM); /* Memory class? */ -} - -/* Try to split up a small struct into registers. */ -static int ccall_struct_reg(CCallState *cc, GPRArg *dp, int *rcl) -{ - MSize ngpr = cc->ngpr, nfpr = cc->nfpr; - uint32_t i; - for (i = 0; i < 2; i++) { - lua_assert(!(rcl[i] & CCALL_RCL_MEM)); - if ((rcl[i] & CCALL_RCL_INT)) { /* Integer class takes precedence. */ - if (ngpr >= CCALL_NARG_GPR) return 1; /* Register overflow. */ - cc->gpr[ngpr++] = dp[i]; - } else if ((rcl[i] & CCALL_RCL_SSE)) { - if (nfpr >= CCALL_NARG_FPR) return 1; /* Register overflow. */ - cc->fpr[nfpr++].l[0] = dp[i]; - } - } - cc->ngpr = ngpr; cc->nfpr = nfpr; - return 0; /* Ok. */ -} - -/* Pass a small struct argument. */ -static int ccall_struct_arg(CCallState *cc, CTState *cts, CType *d, int *rcl, - TValue *o, int narg) -{ - GPRArg dp[2]; - dp[0] = dp[1] = 0; - /* Convert to temp. struct. */ - lj_cconv_ct_tv(cts, d, (uint8_t *)dp, o, CCF_ARG(narg)); - if (ccall_struct_reg(cc, dp, rcl)) { /* Register overflow? Pass on stack. */ - MSize nsp = cc->nsp, n = rcl[1] ? 2 : 1; - if (nsp + n > CCALL_MAXSTACK) return 1; /* Too many arguments. */ - cc->nsp = nsp + n; - memcpy(&cc->stack[nsp], dp, n*CTSIZE_PTR); - } - return 0; /* Ok. */ -} - -/* Combine returned small struct. */ -static void ccall_struct_ret(CCallState *cc, int *rcl, uint8_t *dp, CTSize sz) -{ - GPRArg sp[2]; - MSize ngpr = 0, nfpr = 0; - uint32_t i; - for (i = 0; i < 2; i++) { - if ((rcl[i] & CCALL_RCL_INT)) { /* Integer class takes precedence. */ - sp[i] = cc->gpr[ngpr++]; - } else if ((rcl[i] & CCALL_RCL_SSE)) { - sp[i] = cc->fpr[nfpr++].l[0]; - } - } - memcpy(dp, sp, sz); -} -#endif - -/* -- ARM hard-float ABI struct classification ---------------------------- */ - -#if LJ_TARGET_ARM && !LJ_ABI_SOFTFP - -/* Classify a struct based on its fields. */ -static unsigned int ccall_classify_struct(CTState *cts, CType *ct, CType *ctf) -{ - CTSize sz = ct->size; - unsigned int r = 0, n = 0, isu = (ct->info & CTF_UNION); - if ((ctf->info & CTF_VARARG)) goto noth; - while (ct->sib) { - CType *sct; - ct = ctype_get(cts, ct->sib); - if (ctype_isfield(ct->info)) { - sct = ctype_rawchild(cts, ct); - if (ctype_isfp(sct->info)) { - r |= sct->size; - if (!isu) n++; else if (n == 0) n = 1; - } else if (ctype_iscomplex(sct->info)) { - r |= (sct->size >> 1); - if (!isu) n += 2; else if (n < 2) n = 2; - } else if (ctype_isstruct(sct->info)) { - goto substruct; - } else { - goto noth; - } - } else if (ctype_isbitfield(ct->info)) { - goto noth; - } else if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) { - sct = ctype_rawchild(cts, ct); - substruct: - if (sct->size > 0) { - unsigned int s = ccall_classify_struct(cts, sct, ctf); - if (s <= 1) goto noth; - r |= (s & 255); - if (!isu) n += (s >> 8); else if (n < (s >>8)) n = (s >> 8); - } - } - } - if ((r == 4 || r == 8) && n <= 4) - return r + (n << 8); -noth: /* Not a homogeneous float/double aggregate. */ - return (sz <= 4); /* Return structs of size <= 4 in a GPR. */ -} - -#endif - -/* -- Common C call handling ---------------------------------------------- */ - -/* Infer the destination CTypeID for a vararg argument. */ -CTypeID lj_ccall_ctid_vararg(CTState *cts, cTValue *o) -{ - if (tvisnumber(o)) { - return CTID_DOUBLE; - } else if (tviscdata(o)) { - CTypeID id = cdataV(o)->ctypeid; - CType *s = ctype_get(cts, id); - if (ctype_isrefarray(s->info)) { - return lj_ctype_intern(cts, - CTINFO(CT_PTR, CTALIGN_PTR|ctype_cid(s->info)), CTSIZE_PTR); - } else if (ctype_isstruct(s->info) || ctype_isfunc(s->info)) { - /* NYI: how to pass a struct by value in a vararg argument? */ - return lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|id), CTSIZE_PTR); - } else if (ctype_isfp(s->info) && s->size == sizeof(float)) { - return CTID_DOUBLE; - } else { - return id; - } - } else if (tvisstr(o)) { - return CTID_P_CCHAR; - } else if (tvisbool(o)) { - return CTID_BOOL; - } else { - return CTID_P_VOID; - } -} - -/* Setup arguments for C call. */ -static int ccall_set_args(lua_State *L, CTState *cts, CType *ct, - CCallState *cc) -{ - int gcsteps = 0; - TValue *o, *top = L->top; - CTypeID fid; - CType *ctr; - MSize maxgpr, ngpr = 0, nsp = 0, narg; -#if CCALL_NARG_FPR - MSize nfpr = 0; -#if LJ_TARGET_ARM - MSize fprodd = 0; -#endif -#endif - - /* Clear unused regs to get some determinism in case of misdeclaration. */ - memset(cc->gpr, 0, sizeof(cc->gpr)); -#if CCALL_NUM_FPR - memset(cc->fpr, 0, sizeof(cc->fpr)); -#endif - -#if LJ_TARGET_X86 - /* x86 has several different calling conventions. */ - cc->resx87 = 0; - switch (ctype_cconv(ct->info)) { - case CTCC_FASTCALL: maxgpr = 2; break; - case CTCC_THISCALL: maxgpr = 1; break; - default: maxgpr = 0; break; - } -#else - maxgpr = CCALL_NARG_GPR; -#endif - - /* Perform required setup for some result types. */ - ctr = ctype_rawchild(cts, ct); - if (ctype_isvector(ctr->info)) { - if (!(CCALL_VECTOR_REG && (ctr->size == 8 || ctr->size == 16))) - goto err_nyi; - } else if (ctype_iscomplex(ctr->info) || ctype_isstruct(ctr->info)) { - /* Preallocate cdata object and anchor it after arguments. */ - CTSize sz = ctr->size; - GCcdata *cd = lj_cdata_new(cts, ctype_cid(ct->info), sz); - void *dp = cdataptr(cd); - setcdataV(L, L->top++, cd); - if (ctype_isstruct(ctr->info)) { - CCALL_HANDLE_STRUCTRET - } else { - CCALL_HANDLE_COMPLEXRET - } -#if LJ_TARGET_X86 - } else if (ctype_isfp(ctr->info)) { - cc->resx87 = ctr->size == sizeof(float) ? 1 : 2; -#endif - } - - /* Skip initial attributes. */ - fid = ct->sib; - while (fid) { - CType *ctf = ctype_get(cts, fid); - if (!ctype_isattrib(ctf->info)) break; - fid = ctf->sib; - } - - /* Walk through all passed arguments. */ - for (o = L->base+1, narg = 1; o < top; o++, narg++) { - CTypeID did; - CType *d; - CTSize sz; - MSize n, isfp = 0, isva = 0; - void *dp, *rp = NULL; - - if (fid) { /* Get argument type from field. */ - CType *ctf = ctype_get(cts, fid); - fid = ctf->sib; - lua_assert(ctype_isfield(ctf->info)); - did = ctype_cid(ctf->info); - } else { - if (!(ct->info & CTF_VARARG)) - lj_err_caller(L, LJ_ERR_FFI_NUMARG); /* Too many arguments. */ - did = lj_ccall_ctid_vararg(cts, o); /* Infer vararg type. */ - isva = 1; - } - d = ctype_raw(cts, did); - sz = d->size; - - /* Find out how (by value/ref) and where (GPR/FPR) to pass an argument. */ - if (ctype_isnum(d->info)) { - if (sz > 8) goto err_nyi; - if ((d->info & CTF_FP)) - isfp = 1; - } else if (ctype_isvector(d->info)) { - if (CCALL_VECTOR_REG && (sz == 8 || sz == 16)) - isfp = 1; - else - goto err_nyi; - } else if (ctype_isstruct(d->info)) { - CCALL_HANDLE_STRUCTARG - } else if (ctype_iscomplex(d->info)) { - CCALL_HANDLE_COMPLEXARG - } else { - sz = CTSIZE_PTR; - } - sz = (sz + CTSIZE_PTR-1) & ~(CTSIZE_PTR-1); - n = sz / CTSIZE_PTR; /* Number of GPRs or stack slots needed. */ - - CCALL_HANDLE_REGARG /* Handle register arguments. */ - - /* Otherwise pass argument on stack. */ - if (CCALL_ALIGN_STACKARG && !rp && (d->info & CTF_ALIGN) > CTALIGN_PTR) { - MSize align = (1u << ctype_align(d->info-CTALIGN_PTR)) -1; - nsp = (nsp + align) & ~align; /* Align argument on stack. */ - } - if (nsp + n > CCALL_MAXSTACK) { /* Too many arguments. */ - err_nyi: - lj_err_caller(L, LJ_ERR_FFI_NYICALL); - } - dp = &cc->stack[nsp]; - nsp += n; - isva = 0; - - done: - if (rp) { /* Pass by reference. */ - gcsteps++; - *(void **)dp = rp; - dp = rp; - } - lj_cconv_ct_tv(cts, d, (uint8_t *)dp, o, CCF_ARG(narg)); - /* Extend passed integers to 32 bits at least. */ - if (ctype_isinteger_or_bool(d->info) && d->size < 4) { - if (d->info & CTF_UNSIGNED) - *(uint32_t *)dp = d->size == 1 ? (uint32_t)*(uint8_t *)dp : - (uint32_t)*(uint16_t *)dp; - else - *(int32_t *)dp = d->size == 1 ? (int32_t)*(int8_t *)dp : - (int32_t)*(int16_t *)dp; - } -#if LJ_TARGET_X64 && LJ_ABI_WIN - if (isva) { /* Windows/x64 mirrors varargs in both register sets. */ - if (nfpr == ngpr) - cc->gpr[ngpr-1] = cc->fpr[ngpr-1].l[0]; - else - cc->fpr[ngpr-1].l[0] = cc->gpr[ngpr-1]; - } -#else - UNUSED(isva); -#endif -#if LJ_TARGET_X64 && !LJ_ABI_WIN - if (isfp == 2 && n == 2 && (uint8_t *)dp == (uint8_t *)&cc->fpr[nfpr-2]) { - cc->fpr[nfpr-1].d[0] = cc->fpr[nfpr-2].d[1]; /* Split complex double. */ - cc->fpr[nfpr-2].d[1] = 0; - } -#else - UNUSED(isfp); -#endif - } - if (fid) lj_err_caller(L, LJ_ERR_FFI_NUMARG); /* Too few arguments. */ - -#if LJ_TARGET_X64 || LJ_TARGET_PPC - cc->nfpr = nfpr; /* Required for vararg functions. */ -#endif - cc->nsp = nsp; - cc->spadj = (CCALL_SPS_FREE + CCALL_SPS_EXTRA)*CTSIZE_PTR; - if (nsp > CCALL_SPS_FREE) - cc->spadj += (((nsp-CCALL_SPS_FREE)*CTSIZE_PTR + 15u) & ~15u); - return gcsteps; -} - -/* Get results from C call. */ -static int ccall_get_results(lua_State *L, CTState *cts, CType *ct, - CCallState *cc, int *ret) -{ - CType *ctr = ctype_rawchild(cts, ct); - uint8_t *sp = (uint8_t *)&cc->gpr[0]; - if (ctype_isvoid(ctr->info)) { - *ret = 0; /* Zero results. */ - return 0; /* No additional GC step. */ - } - *ret = 1; /* One result. */ - if (ctype_isstruct(ctr->info)) { - /* Return cdata object which is already on top of stack. */ - if (!cc->retref) { - void *dp = cdataptr(cdataV(L->top-1)); /* Use preallocated object. */ - CCALL_HANDLE_STRUCTRET2 - } - return 1; /* One GC step. */ - } - if (ctype_iscomplex(ctr->info)) { - /* Return cdata object which is already on top of stack. */ - void *dp = cdataptr(cdataV(L->top-1)); /* Use preallocated object. */ - CCALL_HANDLE_COMPLEXRET2 - return 1; /* One GC step. */ - } - if (LJ_BE && ctype_isinteger_or_bool(ctr->info) && ctr->size < CTSIZE_PTR) - sp += (CTSIZE_PTR - ctr->size); -#if CCALL_NUM_FPR - if (ctype_isfp(ctr->info) || ctype_isvector(ctr->info)) - sp = (uint8_t *)&cc->fpr[0]; -#endif -#ifdef CCALL_HANDLE_RET - CCALL_HANDLE_RET -#endif - /* No reference types end up here, so there's no need for the CTypeID. */ - lua_assert(!(ctype_isrefarray(ctr->info) || ctype_isstruct(ctr->info))); - return lj_cconv_tv_ct(cts, ctr, 0, L->top-1, sp); -} - -/* Call C function. */ -int lj_ccall_func(lua_State *L, GCcdata *cd) -{ - CTState *cts = ctype_cts(L); - CType *ct = ctype_raw(cts, cd->ctypeid); - CTSize sz = CTSIZE_PTR; - if (ctype_isptr(ct->info)) { - sz = ct->size; - ct = ctype_rawchild(cts, ct); - } - if (ctype_isfunc(ct->info)) { - CCallState cc; - int gcsteps, ret; - cc.func = (void (*)(void))cdata_getptr(cdataptr(cd), sz); - gcsteps = ccall_set_args(L, cts, ct, &cc); - ct = (CType *)((intptr_t)ct-(intptr_t)cts->tab); - cts->cb.slot = ~0u; - lj_vm_ffi_call(&cc); - if (cts->cb.slot != ~0u) { /* Blacklist function that called a callback. */ - TValue tv; - setlightudV(&tv, (void *)cc.func); - setboolV(lj_tab_set(L, cts->miscmap, &tv), 1); - } - ct = (CType *)((intptr_t)ct+(intptr_t)cts->tab); /* May be reallocated. */ - gcsteps += ccall_get_results(L, cts, ct, &cc, &ret); -#if LJ_TARGET_X86 && LJ_ABI_WIN - /* Automatically detect __stdcall and fix up C function declaration. */ - if (cc.spadj && ctype_cconv(ct->info) == CTCC_CDECL) { - CTF_INSERT(ct->info, CCONV, CTCC_STDCALL); - lj_trace_abort(G(L)); - } -#endif - while (gcsteps-- > 0) - lj_gc_check(L); - return ret; - } - return -1; /* Not a function. */ -} - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ccall.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_ccall.h deleted file mode 100644 index c3ea9e6f9..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ccall.h +++ /dev/null @@ -1,171 +0,0 @@ -/* -** FFI C call handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_CCALL_H -#define _LJ_CCALL_H - -#include "lj_obj.h" -#include "lj_ctype.h" - -#if LJ_HASFFI - -/* -- C calling conventions ----------------------------------------------- */ - -#if LJ_TARGET_X86ORX64 - -#if LJ_TARGET_X86 -#define CCALL_NARG_GPR 2 /* For fastcall arguments. */ -#define CCALL_NARG_FPR 0 -#define CCALL_NRET_GPR 2 -#define CCALL_NRET_FPR 1 /* For FP results on x87 stack. */ -#define CCALL_ALIGN_STACKARG 0 /* Don't align argument on stack. */ -#elif LJ_ABI_WIN -#define CCALL_NARG_GPR 4 -#define CCALL_NARG_FPR 4 -#define CCALL_NRET_GPR 1 -#define CCALL_NRET_FPR 1 -#define CCALL_SPS_EXTRA 4 -#else -#define CCALL_NARG_GPR 6 -#define CCALL_NARG_FPR 8 -#define CCALL_NRET_GPR 2 -#define CCALL_NRET_FPR 2 -#define CCALL_VECTOR_REG 1 /* Pass vectors in registers. */ -#endif - -#define CCALL_SPS_FREE 1 -#define CCALL_ALIGN_CALLSTATE 16 - -typedef LJ_ALIGN(16) union FPRArg { - double d[2]; - float f[4]; - uint8_t b[16]; - uint16_t s[8]; - int i[4]; - int64_t l[2]; -} FPRArg; - -typedef intptr_t GPRArg; - -#elif LJ_TARGET_ARM - -#define CCALL_NARG_GPR 4 -#define CCALL_NRET_GPR 2 /* For softfp double. */ -#if LJ_ABI_SOFTFP -#define CCALL_NARG_FPR 0 -#define CCALL_NRET_FPR 0 -#else -#define CCALL_NARG_FPR 8 -#define CCALL_NRET_FPR 4 -#endif -#define CCALL_SPS_FREE 0 - -typedef intptr_t GPRArg; -typedef union FPRArg { - double d; - float f[2]; -} FPRArg; - -#elif LJ_TARGET_PPC - -#define CCALL_NARG_GPR 8 -#define CCALL_NARG_FPR 8 -#define CCALL_NRET_GPR 4 /* For complex double. */ -#define CCALL_NRET_FPR 1 -#define CCALL_SPS_EXTRA 4 -#define CCALL_SPS_FREE 0 - -typedef intptr_t GPRArg; -typedef double FPRArg; - -#elif LJ_TARGET_PPCSPE - -#define CCALL_NARG_GPR 8 -#define CCALL_NARG_FPR 0 -#define CCALL_NRET_GPR 4 /* For softfp complex double. */ -#define CCALL_NRET_FPR 0 -#define CCALL_SPS_FREE 0 /* NYI */ - -typedef intptr_t GPRArg; - -#elif LJ_TARGET_MIPS - -#define CCALL_NARG_GPR 4 -#define CCALL_NARG_FPR 2 -#define CCALL_NRET_GPR 2 -#define CCALL_NRET_FPR 2 -#define CCALL_SPS_EXTRA 7 -#define CCALL_SPS_FREE 1 - -typedef intptr_t GPRArg; -typedef union FPRArg { - double d; - struct { LJ_ENDIAN_LOHI(float f; , float g;) }; -} FPRArg; - -#else -#error "Missing calling convention definitions for this architecture" -#endif - -#ifndef CCALL_SPS_EXTRA -#define CCALL_SPS_EXTRA 0 -#endif -#ifndef CCALL_VECTOR_REG -#define CCALL_VECTOR_REG 0 -#endif -#ifndef CCALL_ALIGN_STACKARG -#define CCALL_ALIGN_STACKARG 1 -#endif -#ifndef CCALL_ALIGN_CALLSTATE -#define CCALL_ALIGN_CALLSTATE 8 -#endif - -#define CCALL_NUM_GPR \ - (CCALL_NARG_GPR > CCALL_NRET_GPR ? CCALL_NARG_GPR : CCALL_NRET_GPR) -#define CCALL_NUM_FPR \ - (CCALL_NARG_FPR > CCALL_NRET_FPR ? CCALL_NARG_FPR : CCALL_NRET_FPR) - -/* Check against constants in lj_ctype.h. */ -LJ_STATIC_ASSERT(CCALL_NUM_GPR <= CCALL_MAX_GPR); -LJ_STATIC_ASSERT(CCALL_NUM_FPR <= CCALL_MAX_FPR); - -#define CCALL_MAXSTACK 32 - -/* -- C call state -------------------------------------------------------- */ - -typedef LJ_ALIGN(CCALL_ALIGN_CALLSTATE) struct CCallState { - void (*func)(void); /* Pointer to called function. */ - uint32_t spadj; /* Stack pointer adjustment. */ - uint8_t nsp; /* Number of stack slots. */ - uint8_t retref; /* Return value by reference. */ -#if LJ_TARGET_X64 - uint8_t ngpr; /* Number of arguments in GPRs. */ - uint8_t nfpr; /* Number of arguments in FPRs. */ -#elif LJ_TARGET_X86 - uint8_t resx87; /* Result on x87 stack: 1:float, 2:double. */ -#elif LJ_TARGET_PPC - uint8_t nfpr; /* Number of arguments in FPRs. */ -#endif -#if LJ_32 - int32_t align1; -#endif -#if CCALL_NUM_FPR - FPRArg fpr[CCALL_NUM_FPR]; /* Arguments/results in FPRs. */ -#endif - GPRArg gpr[CCALL_NUM_GPR]; /* Arguments/results in GPRs. */ - GPRArg stack[CCALL_MAXSTACK]; /* Stack slots. */ -} CCallState; - -/* -- C call handling ----------------------------------------------------- */ - -/* Really belongs to lj_vm.h. */ -LJ_ASMF void LJ_FASTCALL lj_vm_ffi_call(CCallState *cc); - -LJ_FUNC CTypeID lj_ccall_ctid_vararg(CTState *cts, cTValue *o); -LJ_FUNC int lj_ccall_func(lua_State *L, GCcdata *cd); - -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ccallback.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_ccallback.c deleted file mode 100644 index d872d6715..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ccallback.c +++ /dev/null @@ -1,644 +0,0 @@ -/* -** FFI C callback handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#include "lj_obj.h" - -#if LJ_HASFFI - -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_tab.h" -#include "lj_state.h" -#include "lj_frame.h" -#include "lj_ctype.h" -#include "lj_cconv.h" -#include "lj_ccall.h" -#include "lj_ccallback.h" -#include "lj_target.h" -#include "lj_mcode.h" -#include "lj_trace.h" -#include "lj_vm.h" - -/* -- Target-specific handling of callback slots -------------------------- */ - -#define CALLBACK_MCODE_SIZE (LJ_PAGESIZE * LJ_NUM_CBPAGE) - -#if LJ_OS_NOJIT - -/* Disabled callback support. */ -#define CALLBACK_SLOT2OFS(slot) (0*(slot)) -#define CALLBACK_OFS2SLOT(ofs) (0*(ofs)) -#define CALLBACK_MAX_SLOT 0 - -#elif LJ_TARGET_X86ORX64 - -#define CALLBACK_MCODE_HEAD (LJ_64 ? 8 : 0) -#define CALLBACK_MCODE_GROUP (-2+1+2+5+(LJ_64 ? 6 : 5)) - -#define CALLBACK_SLOT2OFS(slot) \ - (CALLBACK_MCODE_HEAD + CALLBACK_MCODE_GROUP*((slot)/32) + 4*(slot)) - -static MSize CALLBACK_OFS2SLOT(MSize ofs) -{ - MSize group; - ofs -= CALLBACK_MCODE_HEAD; - group = ofs / (32*4 + CALLBACK_MCODE_GROUP); - return (ofs % (32*4 + CALLBACK_MCODE_GROUP))/4 + group*32; -} - -#define CALLBACK_MAX_SLOT \ - (((CALLBACK_MCODE_SIZE-CALLBACK_MCODE_HEAD)/(CALLBACK_MCODE_GROUP+4*32))*32) - -#elif LJ_TARGET_ARM - -#define CALLBACK_MCODE_HEAD 32 -#define CALLBACK_SLOT2OFS(slot) (CALLBACK_MCODE_HEAD + 8*(slot)) -#define CALLBACK_OFS2SLOT(ofs) (((ofs)-CALLBACK_MCODE_HEAD)/8) -#define CALLBACK_MAX_SLOT (CALLBACK_OFS2SLOT(CALLBACK_MCODE_SIZE)) - -#elif LJ_TARGET_PPC - -#define CALLBACK_MCODE_HEAD 24 -#define CALLBACK_SLOT2OFS(slot) (CALLBACK_MCODE_HEAD + 8*(slot)) -#define CALLBACK_OFS2SLOT(ofs) (((ofs)-CALLBACK_MCODE_HEAD)/8) -#define CALLBACK_MAX_SLOT (CALLBACK_OFS2SLOT(CALLBACK_MCODE_SIZE)) - -#elif LJ_TARGET_MIPS - -#define CALLBACK_MCODE_HEAD 24 -#define CALLBACK_SLOT2OFS(slot) (CALLBACK_MCODE_HEAD + 8*(slot)) -#define CALLBACK_OFS2SLOT(ofs) (((ofs)-CALLBACK_MCODE_HEAD)/8) -#define CALLBACK_MAX_SLOT (CALLBACK_OFS2SLOT(CALLBACK_MCODE_SIZE)) - -#else - -/* Missing support for this architecture. */ -#define CALLBACK_SLOT2OFS(slot) (0*(slot)) -#define CALLBACK_OFS2SLOT(ofs) (0*(ofs)) -#define CALLBACK_MAX_SLOT 0 - -#endif - -/* Convert callback slot number to callback function pointer. */ -static void *callback_slot2ptr(CTState *cts, MSize slot) -{ - return (uint8_t *)cts->cb.mcode + CALLBACK_SLOT2OFS(slot); -} - -/* Convert callback function pointer to slot number. */ -MSize lj_ccallback_ptr2slot(CTState *cts, void *p) -{ - uintptr_t ofs = (uintptr_t)((uint8_t *)p -(uint8_t *)cts->cb.mcode); - if (ofs < CALLBACK_MCODE_SIZE) { - MSize slot = CALLBACK_OFS2SLOT((MSize)ofs); - if (CALLBACK_SLOT2OFS(slot) == (MSize)ofs) - return slot; - } - return ~0u; /* Not a known callback function pointer. */ -} - -/* Initialize machine code for callback function pointers. */ -#if LJ_OS_NOJIT -/* Disabled callback support. */ -#define callback_mcode_init(g, p) UNUSED(p) -#elif LJ_TARGET_X86ORX64 -static void callback_mcode_init(global_State *g, uint8_t *page) -{ - uint8_t *p = page; - uint8_t *target = (uint8_t *)(void *)lj_vm_ffi_callback; - MSize slot; -#if LJ_64 - *(void **)p = target; p += 8; -#endif - for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) { - /* mov al, slot; jmp group */ - *p++ = XI_MOVrib | RID_EAX; *p++ = (uint8_t)slot; - if ((slot & 31) == 31 || slot == CALLBACK_MAX_SLOT-1) { - /* push ebp/rbp; mov ah, slot>>8; mov ebp, &g. */ - *p++ = XI_PUSH + RID_EBP; - *p++ = XI_MOVrib | (RID_EAX+4); *p++ = (uint8_t)(slot >> 8); - *p++ = XI_MOVri | RID_EBP; - *(int32_t *)p = i32ptr(g); p += 4; -#if LJ_64 - /* jmp [rip-pageofs] where lj_vm_ffi_callback is stored. */ - *p++ = XI_GROUP5; *p++ = XM_OFS0 + (XOg_JMP<<3) + RID_EBP; - *(int32_t *)p = (int32_t)(page-(p+4)); p += 4; -#else - /* jmp lj_vm_ffi_callback. */ - *p++ = XI_JMP; *(int32_t *)p = target-(p+4); p += 4; -#endif - } else { - *p++ = XI_JMPs; *p++ = (uint8_t)((2+2)*(31-(slot&31)) - 2); - } - } - lua_assert(p - page <= CALLBACK_MCODE_SIZE); -} -#elif LJ_TARGET_ARM -static void callback_mcode_init(global_State *g, uint32_t *page) -{ - uint32_t *p = page; - void *target = (void *)lj_vm_ffi_callback; - MSize slot; - /* This must match with the saveregs macro in buildvm_arm.dasc. */ - *p++ = ARMI_SUB|ARMF_D(RID_R12)|ARMF_N(RID_R12)|ARMF_M(RID_PC); - *p++ = ARMI_PUSH|ARMF_N(RID_SP)|RSET_RANGE(RID_R4,RID_R11+1)|RID2RSET(RID_LR); - *p++ = ARMI_SUB|ARMI_K12|ARMF_D(RID_R12)|ARMF_N(RID_R12)|CALLBACK_MCODE_HEAD; - *p++ = ARMI_STR|ARMI_LS_P|ARMI_LS_W|ARMF_D(RID_R12)|ARMF_N(RID_SP)|(CFRAME_SIZE-4*9); - *p++ = ARMI_LDR|ARMI_LS_P|ARMI_LS_U|ARMF_D(RID_R12)|ARMF_N(RID_PC); - *p++ = ARMI_LDR|ARMI_LS_P|ARMI_LS_U|ARMF_D(RID_PC)|ARMF_N(RID_PC); - *p++ = u32ptr(g); - *p++ = u32ptr(target); - for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) { - *p++ = ARMI_MOV|ARMF_D(RID_R12)|ARMF_M(RID_PC); - *p = ARMI_B | ((page-p-2) & 0x00ffffffu); - p++; - } - lua_assert(p - page <= CALLBACK_MCODE_SIZE); -} -#elif LJ_TARGET_PPC -static void callback_mcode_init(global_State *g, uint32_t *page) -{ - uint32_t *p = page; - void *target = (void *)lj_vm_ffi_callback; - MSize slot; - *p++ = PPCI_LIS | PPCF_T(RID_TMP) | (u32ptr(target) >> 16); - *p++ = PPCI_LIS | PPCF_T(RID_R12) | (u32ptr(g) >> 16); - *p++ = PPCI_ORI | PPCF_A(RID_TMP)|PPCF_T(RID_TMP) | (u32ptr(target) & 0xffff); - *p++ = PPCI_ORI | PPCF_A(RID_R12)|PPCF_T(RID_R12) | (u32ptr(g) & 0xffff); - *p++ = PPCI_MTCTR | PPCF_T(RID_TMP); - *p++ = PPCI_BCTR; - for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) { - *p++ = PPCI_LI | PPCF_T(RID_R11) | slot; - *p = PPCI_B | (((page-p) & 0x00ffffffu) << 2); - p++; - } - lua_assert(p - page <= CALLBACK_MCODE_SIZE); -} -#elif LJ_TARGET_MIPS -static void callback_mcode_init(global_State *g, uint32_t *page) -{ - uint32_t *p = page; - void *target = (void *)lj_vm_ffi_callback; - MSize slot; - *p++ = MIPSI_SW | MIPSF_T(RID_R1)|MIPSF_S(RID_SP) | 0; - *p++ = MIPSI_LUI | MIPSF_T(RID_R3) | (u32ptr(target) >> 16); - *p++ = MIPSI_LUI | MIPSF_T(RID_R2) | (u32ptr(g) >> 16); - *p++ = MIPSI_ORI | MIPSF_T(RID_R3)|MIPSF_S(RID_R3) |(u32ptr(target)&0xffff); - *p++ = MIPSI_JR | MIPSF_S(RID_R3); - *p++ = MIPSI_ORI | MIPSF_T(RID_R2)|MIPSF_S(RID_R2) | (u32ptr(g)&0xffff); - for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) { - *p = MIPSI_B | ((page-p-1) & 0x0000ffffu); - p++; - *p++ = MIPSI_LI | MIPSF_T(RID_R1) | slot; - } - lua_assert(p - page <= CALLBACK_MCODE_SIZE); -} -#else -/* Missing support for this architecture. */ -#define callback_mcode_init(g, p) UNUSED(p) -#endif - -/* -- Machine code management --------------------------------------------- */ - -#if LJ_TARGET_WINDOWS - -#define WIN32_LEAN_AND_MEAN -#include - -#elif LJ_TARGET_POSIX - -#include -#ifndef MAP_ANONYMOUS -#define MAP_ANONYMOUS MAP_ANON -#endif - -#endif - -/* Allocate and initialize area for callback function pointers. */ -static void callback_mcode_new(CTState *cts) -{ - size_t sz = (size_t)CALLBACK_MCODE_SIZE; - void *p; - if (CALLBACK_MAX_SLOT == 0) - lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV); -#if LJ_TARGET_WINDOWS - p = VirtualAlloc(NULL, sz, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); - if (!p) - lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV); -#elif LJ_TARGET_POSIX - p = mmap(NULL, sz, (PROT_READ|PROT_WRITE), MAP_PRIVATE|MAP_ANONYMOUS, - -1, 0); - if (p == MAP_FAILED) - lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV); -#else - /* Fallback allocator. Fails if memory is not executable by default. */ - p = lj_mem_new(cts->L, sz); -#endif - cts->cb.mcode = p; - callback_mcode_init(cts->g, p); - lj_mcode_sync(p, (char *)p + sz); -#if LJ_TARGET_WINDOWS - { - DWORD oprot; - VirtualProtect(p, sz, PAGE_EXECUTE_READ, &oprot); - } -#elif LJ_TARGET_POSIX - mprotect(p, sz, (PROT_READ|PROT_EXEC)); -#endif -} - -/* Free area for callback function pointers. */ -void lj_ccallback_mcode_free(CTState *cts) -{ - size_t sz = (size_t)CALLBACK_MCODE_SIZE; - void *p = cts->cb.mcode; - if (p == NULL) return; -#if LJ_TARGET_WINDOWS - VirtualFree(p, 0, MEM_RELEASE); - UNUSED(sz); -#elif LJ_TARGET_POSIX - munmap(p, sz); -#else - lj_mem_free(cts->g, p, sz); -#endif -} - -/* -- C callback entry ---------------------------------------------------- */ - -/* Target-specific handling of register arguments. Similar to lj_ccall.c. */ -#if LJ_TARGET_X86 - -#define CALLBACK_HANDLE_REGARG \ - if (!isfp) { /* Only non-FP values may be passed in registers. */ \ - if (n > 1) { /* Anything > 32 bit is passed on the stack. */ \ - if (!LJ_ABI_WIN) ngpr = maxgpr; /* Prevent reordering. */ \ - } else if (ngpr + 1 <= maxgpr) { \ - sp = &cts->cb.gpr[ngpr]; \ - ngpr += n; \ - goto done; \ - } \ - } - -#elif LJ_TARGET_X64 && LJ_ABI_WIN - -/* Windows/x64 argument registers are strictly positional (use ngpr). */ -#define CALLBACK_HANDLE_REGARG \ - if (isfp) { \ - if (ngpr < maxgpr) { sp = &cts->cb.fpr[ngpr++]; UNUSED(nfpr); goto done; } \ - } else { \ - if (ngpr < maxgpr) { sp = &cts->cb.gpr[ngpr++]; goto done; } \ - } - -#elif LJ_TARGET_X64 - -#define CALLBACK_HANDLE_REGARG \ - if (isfp) { \ - if (nfpr + n <= CCALL_NARG_FPR) { \ - sp = &cts->cb.fpr[nfpr]; \ - nfpr += n; \ - goto done; \ - } \ - } else { \ - if (ngpr + n <= maxgpr) { \ - sp = &cts->cb.gpr[ngpr]; \ - ngpr += n; \ - goto done; \ - } \ - } - -#elif LJ_TARGET_ARM - -#if LJ_ABI_SOFTFP - -#define CALLBACK_HANDLE_REGARG_FP1 UNUSED(isfp); -#define CALLBACK_HANDLE_REGARG_FP2 - -#else - -#define CALLBACK_HANDLE_REGARG_FP1 \ - if (isfp) { \ - if (n == 1) { \ - if (fprodd) { \ - sp = &cts->cb.fpr[fprodd-1]; \ - fprodd = 0; \ - goto done; \ - } else if (nfpr + 1 <= CCALL_NARG_FPR) { \ - sp = &cts->cb.fpr[nfpr++]; \ - fprodd = nfpr; \ - goto done; \ - } \ - } else { \ - if (nfpr + 1 <= CCALL_NARG_FPR) { \ - sp = &cts->cb.fpr[nfpr++]; \ - goto done; \ - } \ - } \ - fprodd = 0; /* No reordering after the first FP value is on stack. */ \ - } else { - -#define CALLBACK_HANDLE_REGARG_FP2 } - -#endif - -#define CALLBACK_HANDLE_REGARG \ - CALLBACK_HANDLE_REGARG_FP1 \ - if (n > 1) ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \ - if (ngpr + n <= maxgpr) { \ - sp = &cts->cb.gpr[ngpr]; \ - ngpr += n; \ - goto done; \ - } CALLBACK_HANDLE_REGARG_FP2 - -#elif LJ_TARGET_PPC - -#define CALLBACK_HANDLE_REGARG \ - if (isfp) { \ - if (nfpr + 1 <= CCALL_NARG_FPR) { \ - sp = &cts->cb.fpr[nfpr++]; \ - cta = ctype_get(cts, CTID_DOUBLE); /* FPRs always hold doubles. */ \ - goto done; \ - } \ - } else { /* Try to pass argument in GPRs. */ \ - if (n > 1) { \ - lua_assert(ctype_isinteger(cta->info) && n == 2); /* int64_t. */ \ - ngpr = (ngpr + 1u) & ~1u; /* Align int64_t to regpair. */ \ - } \ - if (ngpr + n <= maxgpr) { \ - sp = &cts->cb.gpr[ngpr]; \ - ngpr += n; \ - goto done; \ - } \ - } - -#define CALLBACK_HANDLE_RET \ - if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \ - *(double *)dp = *(float *)dp; /* FPRs always hold doubles. */ - -#elif LJ_TARGET_MIPS - -#define CALLBACK_HANDLE_REGARG \ - if (isfp && nfpr < CCALL_NARG_FPR) { /* Try to pass argument in FPRs. */ \ - sp = (void *)((uint8_t *)&cts->cb.fpr[nfpr] + ((LJ_BE && n==1) ? 4 : 0)); \ - nfpr++; ngpr += n; \ - goto done; \ - } else { /* Try to pass argument in GPRs. */ \ - nfpr = CCALL_NARG_FPR; \ - if (n > 1) ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \ - if (ngpr + n <= maxgpr) { \ - sp = &cts->cb.gpr[ngpr]; \ - ngpr += n; \ - goto done; \ - } \ - } - -#define CALLBACK_HANDLE_RET \ - if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \ - ((float *)dp)[1] = *(float *)dp; - -#else -#error "Missing calling convention definitions for this architecture" -#endif - -/* Convert and push callback arguments to Lua stack. */ -static void callback_conv_args(CTState *cts, lua_State *L) -{ - TValue *o = L->top; - intptr_t *stack = cts->cb.stack; - MSize slot = cts->cb.slot; - CTypeID id = 0, rid, fid; - int gcsteps = 0; - CType *ct; - GCfunc *fn; - MSize ngpr = 0, nsp = 0, maxgpr = CCALL_NARG_GPR; -#if CCALL_NARG_FPR - MSize nfpr = 0; -#if LJ_TARGET_ARM - MSize fprodd = 0; -#endif -#endif - - if (slot < cts->cb.sizeid && (id = cts->cb.cbid[slot]) != 0) { - ct = ctype_get(cts, id); - rid = ctype_cid(ct->info); - fn = funcV(lj_tab_getint(cts->miscmap, (int32_t)slot)); - } else { /* Must set up frame first, before throwing the error. */ - ct = NULL; - rid = 0; - fn = (GCfunc *)L; - } - o->u32.lo = LJ_CONT_FFI_CALLBACK; /* Continuation returns from callback. */ - o->u32.hi = rid; /* Return type. x86: +(spadj<<16). */ - o++; - setframe_gc(o, obj2gco(fn)); - setframe_ftsz(o, (int)((char *)(o+1) - (char *)L->base) + FRAME_CONT); - L->top = L->base = ++o; - if (!ct) - lj_err_caller(cts->L, LJ_ERR_FFI_BADCBACK); - if (isluafunc(fn)) - setcframe_pc(L->cframe, proto_bc(funcproto(fn))+1); - lj_state_checkstack(L, LUA_MINSTACK); /* May throw. */ - o = L->base; /* Might have been reallocated. */ - -#if LJ_TARGET_X86 - /* x86 has several different calling conventions. */ - switch (ctype_cconv(ct->info)) { - case CTCC_FASTCALL: maxgpr = 2; break; - case CTCC_THISCALL: maxgpr = 1; break; - default: maxgpr = 0; break; - } -#endif - - fid = ct->sib; - while (fid) { - CType *ctf = ctype_get(cts, fid); - if (!ctype_isattrib(ctf->info)) { - CType *cta; - void *sp; - CTSize sz; - int isfp; - MSize n; - lua_assert(ctype_isfield(ctf->info)); - cta = ctype_rawchild(cts, ctf); - isfp = ctype_isfp(cta->info); - sz = (cta->size + CTSIZE_PTR-1) & ~(CTSIZE_PTR-1); - n = sz / CTSIZE_PTR; /* Number of GPRs or stack slots needed. */ - - CALLBACK_HANDLE_REGARG /* Handle register arguments. */ - - /* Otherwise pass argument on stack. */ - if (CCALL_ALIGN_STACKARG && LJ_32 && sz == 8) - nsp = (nsp + 1) & ~1u; /* Align 64 bit argument on stack. */ - sp = &stack[nsp]; - nsp += n; - - done: - if (LJ_BE && cta->size < CTSIZE_PTR) - sp = (void *)((uint8_t *)sp + CTSIZE_PTR-cta->size); - gcsteps += lj_cconv_tv_ct(cts, cta, 0, o++, sp); - } - fid = ctf->sib; - } - L->top = o; -#if LJ_TARGET_X86 - /* Store stack adjustment for returns from non-cdecl callbacks. */ - if (ctype_cconv(ct->info) != CTCC_CDECL) - (L->base-2)->u32.hi |= (nsp << (16+2)); -#endif - while (gcsteps-- > 0) - lj_gc_check(L); -} - -/* Convert Lua object to callback result. */ -static void callback_conv_result(CTState *cts, lua_State *L, TValue *o) -{ - CType *ctr = ctype_raw(cts, (uint16_t)(L->base-2)->u32.hi); -#if LJ_TARGET_X86 - cts->cb.gpr[2] = 0; -#endif - if (!ctype_isvoid(ctr->info)) { - uint8_t *dp = (uint8_t *)&cts->cb.gpr[0]; -#if CCALL_NUM_FPR - if (ctype_isfp(ctr->info)) - dp = (uint8_t *)&cts->cb.fpr[0]; -#endif - lj_cconv_ct_tv(cts, ctr, dp, o, 0); -#ifdef CALLBACK_HANDLE_RET - CALLBACK_HANDLE_RET -#endif - /* Extend returned integers to (at least) 32 bits. */ - if (ctype_isinteger_or_bool(ctr->info) && ctr->size < 4) { - if (ctr->info & CTF_UNSIGNED) - *(uint32_t *)dp = ctr->size == 1 ? (uint32_t)*(uint8_t *)dp : - (uint32_t)*(uint16_t *)dp; - else - *(int32_t *)dp = ctr->size == 1 ? (int32_t)*(int8_t *)dp : - (int32_t)*(int16_t *)dp; - } -#if LJ_TARGET_X86 - if (ctype_isfp(ctr->info)) - cts->cb.gpr[2] = ctr->size == sizeof(float) ? 1 : 2; -#endif - } -} - -/* Enter callback. */ -lua_State * LJ_FASTCALL lj_ccallback_enter(CTState *cts, void *cf) -{ - lua_State *L = cts->L; - global_State *g = cts->g; - lua_assert(L != NULL); - if (gcref(g->jit_L)) { - setstrV(L, L->top++, lj_err_str(L, LJ_ERR_FFI_BADCBACK)); - if (g->panic) g->panic(L); - exit(EXIT_FAILURE); - } - lj_trace_abort(g); /* Never record across callback. */ - /* Setup C frame. */ - cframe_prev(cf) = L->cframe; - setcframe_L(cf, L); - cframe_errfunc(cf) = -1; - cframe_nres(cf) = 0; - L->cframe = cf; - callback_conv_args(cts, L); - return L; /* Now call the function on this stack. */ -} - -/* Leave callback. */ -void LJ_FASTCALL lj_ccallback_leave(CTState *cts, TValue *o) -{ - lua_State *L = cts->L; - GCfunc *fn; - TValue *obase = L->base; - L->base = L->top; /* Keep continuation frame for throwing errors. */ - if (o >= L->base) { - /* PC of RET* is lost. Point to last line for result conv. errors. */ - fn = curr_func(L); - if (isluafunc(fn)) { - GCproto *pt = funcproto(fn); - setcframe_pc(L->cframe, proto_bc(pt)+pt->sizebc+1); - } - } - callback_conv_result(cts, L, o); - /* Finally drop C frame and continuation frame. */ - L->cframe = cframe_prev(L->cframe); - L->top -= 2; - L->base = obase; - cts->cb.slot = 0; /* Blacklist C function that called the callback. */ -} - -/* -- C callback management ----------------------------------------------- */ - -/* Get an unused slot in the callback slot table. */ -static MSize callback_slot_new(CTState *cts, CType *ct) -{ - CTypeID id = ctype_typeid(cts, ct); - CTypeID1 *cbid = cts->cb.cbid; - MSize top; - for (top = cts->cb.topid; top < cts->cb.sizeid; top++) - if (LJ_LIKELY(cbid[top] == 0)) - goto found; -#if CALLBACK_MAX_SLOT - if (top >= CALLBACK_MAX_SLOT) -#endif - lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV); - if (!cts->cb.mcode) - callback_mcode_new(cts); - lj_mem_growvec(cts->L, cbid, cts->cb.sizeid, CALLBACK_MAX_SLOT, CTypeID1); - cts->cb.cbid = cbid; - memset(cbid+top, 0, (cts->cb.sizeid-top)*sizeof(CTypeID1)); -found: - cbid[top] = id; - cts->cb.topid = top+1; - return top; -} - -/* Check for function pointer and supported argument/result types. */ -static CType *callback_checkfunc(CTState *cts, CType *ct) -{ - int narg = 0; - if (!ctype_isptr(ct->info) || (LJ_64 && ct->size != CTSIZE_PTR)) - return NULL; - ct = ctype_rawchild(cts, ct); - if (ctype_isfunc(ct->info)) { - CType *ctr = ctype_rawchild(cts, ct); - CTypeID fid = ct->sib; - if (!(ctype_isvoid(ctr->info) || ctype_isenum(ctr->info) || - ctype_isptr(ctr->info) || (ctype_isnum(ctr->info) && ctr->size <= 8))) - return NULL; - if ((ct->info & CTF_VARARG)) - return NULL; - while (fid) { - CType *ctf = ctype_get(cts, fid); - if (!ctype_isattrib(ctf->info)) { - CType *cta; - lua_assert(ctype_isfield(ctf->info)); - cta = ctype_rawchild(cts, ctf); - if (!(ctype_isenum(cta->info) || ctype_isptr(cta->info) || - (ctype_isnum(cta->info) && cta->size <= 8)) || - ++narg >= LUA_MINSTACK-3) - return NULL; - } - fid = ctf->sib; - } - return ct; - } - return NULL; -} - -/* Create a new callback and return the callback function pointer. */ -void *lj_ccallback_new(CTState *cts, CType *ct, GCfunc *fn) -{ - ct = callback_checkfunc(cts, ct); - if (ct) { - MSize slot = callback_slot_new(cts, ct); - GCtab *t = cts->miscmap; - setfuncV(cts->L, lj_tab_setint(cts->L, t, (int32_t)slot), fn); - lj_gc_anybarriert(cts->L, t); - return callback_slot2ptr(cts, slot); - } - return NULL; /* Bad conversion. */ -} - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ccallback.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_ccallback.h deleted file mode 100644 index 45b5ff02d..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ccallback.h +++ /dev/null @@ -1,25 +0,0 @@ -/* -** FFI C callback handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_CCALLBACK_H -#define _LJ_CCALLBACK_H - -#include "lj_obj.h" -#include "lj_ctype.h" - -#if LJ_HASFFI - -/* Really belongs to lj_vm.h. */ -LJ_ASMF void lj_vm_ffi_callback(void); - -LJ_FUNC MSize lj_ccallback_ptr2slot(CTState *cts, void *p); -LJ_FUNCA lua_State * LJ_FASTCALL lj_ccallback_enter(CTState *cts, void *cf); -LJ_FUNCA void LJ_FASTCALL lj_ccallback_leave(CTState *cts, TValue *o); -LJ_FUNC void *lj_ccallback_new(CTState *cts, CType *ct, GCfunc *fn); -LJ_FUNC void lj_ccallback_mcode_free(CTState *cts); - -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_cconv.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_cconv.c deleted file mode 100644 index de4938e4f..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_cconv.c +++ /dev/null @@ -1,751 +0,0 @@ -/* -** C type conversions. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#include "lj_obj.h" - -#if LJ_HASFFI - -#include "lj_err.h" -#include "lj_tab.h" -#include "lj_ctype.h" -#include "lj_cdata.h" -#include "lj_cconv.h" -#include "lj_ccallback.h" - -/* -- Conversion errors --------------------------------------------------- */ - -/* Bad conversion. */ -LJ_NORET static void cconv_err_conv(CTState *cts, CType *d, CType *s, - CTInfo flags) -{ - const char *dst = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, d), NULL)); - const char *src; - if ((flags & CCF_FROMTV)) - src = lj_obj_typename[1+(ctype_isnum(s->info) ? LUA_TNUMBER : - ctype_isarray(s->info) ? LUA_TSTRING : LUA_TNIL)]; - else - src = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, s), NULL)); - if (CCF_GETARG(flags)) - lj_err_argv(cts->L, CCF_GETARG(flags), LJ_ERR_FFI_BADCONV, src, dst); - else - lj_err_callerv(cts->L, LJ_ERR_FFI_BADCONV, src, dst); -} - -/* Bad conversion from TValue. */ -LJ_NORET static void cconv_err_convtv(CTState *cts, CType *d, TValue *o, - CTInfo flags) -{ - const char *dst = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, d), NULL)); - const char *src = lj_typename(o); - if (CCF_GETARG(flags)) - lj_err_argv(cts->L, CCF_GETARG(flags), LJ_ERR_FFI_BADCONV, src, dst); - else - lj_err_callerv(cts->L, LJ_ERR_FFI_BADCONV, src, dst); -} - -/* Initializer overflow. */ -LJ_NORET static void cconv_err_initov(CTState *cts, CType *d) -{ - const char *dst = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, d), NULL)); - lj_err_callerv(cts->L, LJ_ERR_FFI_INITOV, dst); -} - -/* -- C type compatibility checks ----------------------------------------- */ - -/* Get raw type and qualifiers for a child type. Resolves enums, too. */ -static CType *cconv_childqual(CTState *cts, CType *ct, CTInfo *qual) -{ - ct = ctype_child(cts, ct); - for (;;) { - if (ctype_isattrib(ct->info)) { - if (ctype_attrib(ct->info) == CTA_QUAL) *qual |= ct->size; - } else if (!ctype_isenum(ct->info)) { - break; - } - ct = ctype_child(cts, ct); - } - *qual |= (ct->info & CTF_QUAL); - return ct; -} - -/* Check for compatible types when converting to a pointer. -** Note: these checks are more relaxed than what C99 mandates. -*/ -int lj_cconv_compatptr(CTState *cts, CType *d, CType *s, CTInfo flags) -{ - if (!((flags & CCF_CAST) || d == s)) { - CTInfo dqual = 0, squal = 0; - d = cconv_childqual(cts, d, &dqual); - if (!ctype_isstruct(s->info)) - s = cconv_childqual(cts, s, &squal); - if ((flags & CCF_SAME)) { - if (dqual != squal) - return 0; /* Different qualifiers. */ - } else if (!(flags & CCF_IGNQUAL)) { - if ((dqual & squal) != squal) - return 0; /* Discarded qualifiers. */ - if (ctype_isvoid(d->info) || ctype_isvoid(s->info)) - return 1; /* Converting to/from void * is always ok. */ - } - if (ctype_type(d->info) != ctype_type(s->info) || - d->size != s->size) - return 0; /* Different type or different size. */ - if (ctype_isnum(d->info)) { - if (((d->info ^ s->info) & (CTF_BOOL|CTF_FP))) - return 0; /* Different numeric types. */ - } else if (ctype_ispointer(d->info)) { - /* Check child types for compatibility. */ - return lj_cconv_compatptr(cts, d, s, flags|CCF_SAME); - } else if (ctype_isstruct(d->info)) { - if (d != s) - return 0; /* Must be exact same type for struct/union. */ - } else if (ctype_isfunc(d->info)) { - /* NYI: structural equality of functions. */ - } - } - return 1; /* Types are compatible. */ -} - -/* -- C type to C type conversion ----------------------------------------- */ - -/* Convert C type to C type. Caveat: expects to get the raw CType! -** -** Note: This is only used by the interpreter and not optimized at all. -** The JIT compiler will do a much better job specializing for each case. -*/ -void lj_cconv_ct_ct(CTState *cts, CType *d, CType *s, - uint8_t *dp, uint8_t *sp, CTInfo flags) -{ - CTSize dsize = d->size, ssize = s->size; - CTInfo dinfo = d->info, sinfo = s->info; - void *tmpptr; - - lua_assert(!ctype_isenum(dinfo) && !ctype_isenum(sinfo)); - lua_assert(!ctype_isattrib(dinfo) && !ctype_isattrib(sinfo)); - - if (ctype_type(dinfo) > CT_MAYCONVERT || ctype_type(sinfo) > CT_MAYCONVERT) - goto err_conv; - - /* Some basic sanity checks. */ - lua_assert(!ctype_isnum(dinfo) || dsize > 0); - lua_assert(!ctype_isnum(sinfo) || ssize > 0); - lua_assert(!ctype_isbool(dinfo) || dsize == 1 || dsize == 4); - lua_assert(!ctype_isbool(sinfo) || ssize == 1 || ssize == 4); - lua_assert(!ctype_isinteger(dinfo) || (1u< ssize) { /* Zero-extend or sign-extend LSB. */ -#if LJ_LE - uint8_t fill = (!(sinfo & CTF_UNSIGNED) && (sp[ssize-1]&0x80)) ? 0xff : 0; - memcpy(dp, sp, ssize); - memset(dp + ssize, fill, dsize-ssize); -#else - uint8_t fill = (!(sinfo & CTF_UNSIGNED) && (sp[0]&0x80)) ? 0xff : 0; - memset(dp, fill, dsize-ssize); - memcpy(dp + (dsize-ssize), sp, ssize); -#endif - } else { /* Copy LSB. */ -#if LJ_LE - memcpy(dp, sp, dsize); -#else - memcpy(dp, sp + (ssize-dsize), dsize); -#endif - } - break; - case CCX(I, F): { - double n; /* Always convert via double. */ - conv_I_F: - /* Convert source to double. */ - if (ssize == sizeof(double)) n = *(double *)sp; - else if (ssize == sizeof(float)) n = (double)*(float *)sp; - else goto err_conv; /* NYI: long double. */ - /* Then convert double to integer. */ - /* The conversion must exactly match the semantics of JIT-compiled code! */ - if (dsize < 4 || (dsize == 4 && !(dinfo & CTF_UNSIGNED))) { - int32_t i = (int32_t)n; - if (dsize == 4) *(int32_t *)dp = i; - else if (dsize == 2) *(int16_t *)dp = (int16_t)i; - else *(int8_t *)dp = (int8_t)i; - } else if (dsize == 4) { - *(uint32_t *)dp = (uint32_t)n; - } else if (dsize == 8) { - if (!(dinfo & CTF_UNSIGNED)) - *(int64_t *)dp = (int64_t)n; - else - *(uint64_t *)dp = lj_num2u64(n); - } else { - goto err_conv; /* NYI: conversion to >64 bit integers. */ - } - break; - } - case CCX(I, C): - s = ctype_child(cts, s); - sinfo = s->info; - ssize = s->size; - goto conv_I_F; /* Just convert re. */ - case CCX(I, P): - if (!(flags & CCF_CAST)) goto err_conv; - sinfo = CTINFO(CT_NUM, CTF_UNSIGNED); - goto conv_I_I; - case CCX(I, A): - if (!(flags & CCF_CAST)) goto err_conv; - sinfo = CTINFO(CT_NUM, CTF_UNSIGNED); - ssize = CTSIZE_PTR; - tmpptr = sp; - sp = (uint8_t *)&tmpptr; - goto conv_I_I; - - /* Destination is a floating-point number. */ - case CCX(F, B): - case CCX(F, I): { - double n; /* Always convert via double. */ - conv_F_I: - /* First convert source to double. */ - /* The conversion must exactly match the semantics of JIT-compiled code! */ - if (ssize < 4 || (ssize == 4 && !(sinfo & CTF_UNSIGNED))) { - int32_t i; - if (ssize == 4) { - i = *(int32_t *)sp; - } else if (!(sinfo & CTF_UNSIGNED)) { - if (ssize == 2) i = *(int16_t *)sp; - else i = *(int8_t *)sp; - } else { - if (ssize == 2) i = *(uint16_t *)sp; - else i = *(uint8_t *)sp; - } - n = (double)i; - } else if (ssize == 4) { - n = (double)*(uint32_t *)sp; - } else if (ssize == 8) { - if (!(sinfo & CTF_UNSIGNED)) n = (double)*(int64_t *)sp; - else n = (double)*(uint64_t *)sp; - } else { - goto err_conv; /* NYI: conversion from >64 bit integers. */ - } - /* Convert double to destination. */ - if (dsize == sizeof(double)) *(double *)dp = n; - else if (dsize == sizeof(float)) *(float *)dp = (float)n; - else goto err_conv; /* NYI: long double. */ - break; - } - case CCX(F, F): { - double n; /* Always convert via double. */ - conv_F_F: - if (ssize == dsize) goto copyval; - /* Convert source to double. */ - if (ssize == sizeof(double)) n = *(double *)sp; - else if (ssize == sizeof(float)) n = (double)*(float *)sp; - else goto err_conv; /* NYI: long double. */ - /* Convert double to destination. */ - if (dsize == sizeof(double)) *(double *)dp = n; - else if (dsize == sizeof(float)) *(float *)dp = (float)n; - else goto err_conv; /* NYI: long double. */ - break; - } - case CCX(F, C): - s = ctype_child(cts, s); - sinfo = s->info; - ssize = s->size; - goto conv_F_F; /* Ignore im, and convert from re. */ - - /* Destination is a complex number. */ - case CCX(C, I): - d = ctype_child(cts, d); - dinfo = d->info; - dsize = d->size; - memset(dp + dsize, 0, dsize); /* Clear im. */ - goto conv_F_I; /* Convert to re. */ - case CCX(C, F): - d = ctype_child(cts, d); - dinfo = d->info; - dsize = d->size; - memset(dp + dsize, 0, dsize); /* Clear im. */ - goto conv_F_F; /* Convert to re. */ - - case CCX(C, C): - if (dsize != ssize) { /* Different types: convert re/im separately. */ - CType *dc = ctype_child(cts, d); - CType *sc = ctype_child(cts, s); - lj_cconv_ct_ct(cts, dc, sc, dp, sp, flags); - lj_cconv_ct_ct(cts, dc, sc, dp + dc->size, sp + sc->size, flags); - return; - } - goto copyval; /* Otherwise this is easy. */ - - /* Destination is a vector. */ - case CCX(V, I): - case CCX(V, F): - case CCX(V, C): { - CType *dc = ctype_child(cts, d); - CTSize esize; - /* First convert the scalar to the first element. */ - lj_cconv_ct_ct(cts, dc, s, dp, sp, flags); - /* Then replicate it to the other elements (splat). */ - for (sp = dp, esize = dc->size; dsize > esize; dsize -= esize) { - dp += esize; - memcpy(dp, sp, esize); - } - break; - } - - case CCX(V, V): - /* Copy same-sized vectors, even for different lengths/element-types. */ - if (dsize != ssize) goto err_conv; - goto copyval; - - /* Destination is a pointer. */ - case CCX(P, I): - if (!(flags & CCF_CAST)) goto err_conv; - dinfo = CTINFO(CT_NUM, CTF_UNSIGNED); - goto conv_I_I; - - case CCX(P, F): - if (!(flags & CCF_CAST) || !(flags & CCF_FROMTV)) goto err_conv; - /* The signed conversion is cheaper. x64 really has 47 bit pointers. */ - dinfo = CTINFO(CT_NUM, (LJ_64 && dsize == 8) ? 0 : CTF_UNSIGNED); - goto conv_I_F; - - case CCX(P, P): - if (!lj_cconv_compatptr(cts, d, s, flags)) goto err_conv; - cdata_setptr(dp, dsize, cdata_getptr(sp, ssize)); - break; - - case CCX(P, A): - case CCX(P, S): - if (!lj_cconv_compatptr(cts, d, s, flags)) goto err_conv; - cdata_setptr(dp, dsize, sp); - break; - - /* Destination is an array. */ - case CCX(A, A): - if ((flags & CCF_CAST) || (d->info & CTF_VLA) || dsize != ssize || - d->size == CTSIZE_INVALID || !lj_cconv_compatptr(cts, d, s, flags)) - goto err_conv; - goto copyval; - - /* Destination is a struct/union. */ - case CCX(S, S): - if ((flags & CCF_CAST) || (d->info & CTF_VLA) || d != s) - goto err_conv; /* Must be exact same type. */ -copyval: /* Copy value. */ - lua_assert(dsize == ssize); - memcpy(dp, sp, dsize); - break; - - default: - err_conv: - cconv_err_conv(cts, d, s, flags); - } -} - -/* -- C type to TValue conversion ----------------------------------------- */ - -/* Convert C type to TValue. Caveat: expects to get the raw CType! */ -int lj_cconv_tv_ct(CTState *cts, CType *s, CTypeID sid, - TValue *o, uint8_t *sp) -{ - CTInfo sinfo = s->info; - if (ctype_isnum(sinfo)) { - if (!ctype_isbool(sinfo)) { - if (ctype_isinteger(sinfo) && s->size > 4) goto copyval; - if (LJ_DUALNUM && ctype_isinteger(sinfo)) { - int32_t i; - lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT32), s, - (uint8_t *)&i, sp, 0); - if ((sinfo & CTF_UNSIGNED) && i < 0) - setnumV(o, (lua_Number)(uint32_t)i); - else - setintV(o, i); - } else { - lj_cconv_ct_ct(cts, ctype_get(cts, CTID_DOUBLE), s, - (uint8_t *)&o->n, sp, 0); - /* Numbers are NOT canonicalized here! Beware of uninitialized data. */ - lua_assert(tvisnum(o)); - } - } else { - uint32_t b = s->size == 1 ? (*sp != 0) : (*(int *)sp != 0); - setboolV(o, b); - setboolV(&cts->g->tmptv2, b); /* Remember for trace recorder. */ - } - return 0; - } else if (ctype_isrefarray(sinfo) || ctype_isstruct(sinfo)) { - /* Create reference. */ - setcdataV(cts->L, o, lj_cdata_newref(cts, sp, sid)); - return 1; /* Need GC step. */ - } else { - GCcdata *cd; - CTSize sz; - copyval: /* Copy value. */ - sz = s->size; - lua_assert(sz != CTSIZE_INVALID); - /* Attributes are stripped, qualifiers are kept (but mostly ignored). */ - cd = lj_cdata_new(cts, ctype_typeid(cts, s), sz); - setcdataV(cts->L, o, cd); - memcpy(cdataptr(cd), sp, sz); - return 1; /* Need GC step. */ - } -} - -/* Convert bitfield to TValue. */ -int lj_cconv_tv_bf(CTState *cts, CType *s, TValue *o, uint8_t *sp) -{ - CTInfo info = s->info; - CTSize pos, bsz; - uint32_t val; - lua_assert(ctype_isbitfield(info)); - /* NYI: packed bitfields may cause misaligned reads. */ - switch (ctype_bitcsz(info)) { - case 4: val = *(uint32_t *)sp; break; - case 2: val = *(uint16_t *)sp; break; - case 1: val = *(uint8_t *)sp; break; - default: lua_assert(0); val = 0; break; - } - /* Check if a packed bitfield crosses a container boundary. */ - pos = ctype_bitpos(info); - bsz = ctype_bitbsz(info); - lua_assert(pos < 8*ctype_bitcsz(info)); - lua_assert(bsz > 0 && bsz <= 8*ctype_bitcsz(info)); - if (pos + bsz > 8*ctype_bitcsz(info)) - lj_err_caller(cts->L, LJ_ERR_FFI_NYIPACKBIT); - if (!(info & CTF_BOOL)) { - CTSize shift = 32 - bsz; - if (!(info & CTF_UNSIGNED)) { - setintV(o, (int32_t)(val << (shift-pos)) >> shift); - } else { - val = (val << (shift-pos)) >> shift; - if (!LJ_DUALNUM || (int32_t)val < 0) - setnumV(o, (lua_Number)(uint32_t)val); - else - setintV(o, (int32_t)val); - } - } else { - lua_assert(bsz == 1); - setboolV(o, (val >> pos) & 1); - } - return 0; /* No GC step needed. */ -} - -/* -- TValue to C type conversion ----------------------------------------- */ - -/* Convert table to array. */ -static void cconv_array_tab(CTState *cts, CType *d, - uint8_t *dp, GCtab *t, CTInfo flags) -{ - int32_t i; - CType *dc = ctype_rawchild(cts, d); /* Array element type. */ - CTSize size = d->size, esize = dc->size, ofs = 0; - for (i = 0; ; i++) { - TValue *tv = (TValue *)lj_tab_getint(t, i); - if (!tv || tvisnil(tv)) { - if (i == 0) continue; /* Try again for 1-based tables. */ - break; /* Stop at first nil. */ - } - if (ofs >= size) - cconv_err_initov(cts, d); - lj_cconv_ct_tv(cts, dc, dp + ofs, tv, flags); - ofs += esize; - } - if (size != CTSIZE_INVALID) { /* Only fill up arrays with known size. */ - if (ofs == esize) { /* Replicate a single element. */ - for (; ofs < size; ofs += esize) memcpy(dp + ofs, dp, esize); - } else { /* Otherwise fill the remainder with zero. */ - memset(dp + ofs, 0, size - ofs); - } - } -} - -/* Convert table to sub-struct/union. */ -static void cconv_substruct_tab(CTState *cts, CType *d, uint8_t *dp, - GCtab *t, int32_t *ip, CTInfo flags) -{ - CTypeID id = d->sib; - while (id) { - CType *df = ctype_get(cts, id); - id = df->sib; - if (ctype_isfield(df->info) || ctype_isbitfield(df->info)) { - TValue *tv; - int32_t i = *ip, iz = i; - if (!gcref(df->name)) continue; /* Ignore unnamed fields. */ - if (i >= 0) { - retry: - tv = (TValue *)lj_tab_getint(t, i); - if (!tv || tvisnil(tv)) { - if (i == 0) { i = 1; goto retry; } /* 1-based tables. */ - if (iz == 0) { *ip = i = -1; goto tryname; } /* Init named fields. */ - break; /* Stop at first nil. */ - } - *ip = i + 1; - } else { - tryname: - tv = (TValue *)lj_tab_getstr(t, gco2str(gcref(df->name))); - if (!tv || tvisnil(tv)) continue; - } - if (ctype_isfield(df->info)) - lj_cconv_ct_tv(cts, ctype_rawchild(cts, df), dp+df->size, tv, flags); - else - lj_cconv_bf_tv(cts, df, dp+df->size, tv); - if ((d->info & CTF_UNION)) break; - } else if (ctype_isxattrib(df->info, CTA_SUBTYPE)) { - cconv_substruct_tab(cts, ctype_rawchild(cts, df), - dp+df->size, t, ip, flags); - } /* Ignore all other entries in the chain. */ - } -} - -/* Convert table to struct/union. */ -static void cconv_struct_tab(CTState *cts, CType *d, - uint8_t *dp, GCtab *t, CTInfo flags) -{ - int32_t i = 0; - memset(dp, 0, d->size); /* Much simpler to clear the struct first. */ - cconv_substruct_tab(cts, d, dp, t, &i, flags); -} - -/* Convert TValue to C type. Caveat: expects to get the raw CType! */ -void lj_cconv_ct_tv(CTState *cts, CType *d, - uint8_t *dp, TValue *o, CTInfo flags) -{ - CTypeID sid = CTID_P_VOID; - CType *s; - void *tmpptr; - uint8_t tmpbool, *sp = (uint8_t *)&tmpptr; - if (LJ_LIKELY(tvisint(o))) { - sp = (uint8_t *)&o->i; - sid = CTID_INT32; - flags |= CCF_FROMTV; - } else if (LJ_LIKELY(tvisnum(o))) { - sp = (uint8_t *)&o->n; - sid = CTID_DOUBLE; - flags |= CCF_FROMTV; - } else if (tviscdata(o)) { - sp = cdataptr(cdataV(o)); - sid = cdataV(o)->ctypeid; - s = ctype_get(cts, sid); - if (ctype_isref(s->info)) { /* Resolve reference for value. */ - lua_assert(s->size == CTSIZE_PTR); - sp = *(void **)sp; - sid = ctype_cid(s->info); - } - s = ctype_raw(cts, sid); - if (ctype_isfunc(s->info)) { - sid = lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|sid), CTSIZE_PTR); - } else { - if (ctype_isenum(s->info)) s = ctype_child(cts, s); - goto doconv; - } - } else if (tvisstr(o)) { - GCstr *str = strV(o); - if (ctype_isenum(d->info)) { /* Match string against enum constant. */ - CTSize ofs; - CType *cct = lj_ctype_getfield(cts, d, str, &ofs); - if (!cct || !ctype_isconstval(cct->info)) - goto err_conv; - lua_assert(d->size == 4); - sp = (uint8_t *)&cct->size; - sid = ctype_cid(cct->info); - } else if (ctype_isrefarray(d->info)) { /* Copy string to array. */ - CType *dc = ctype_rawchild(cts, d); - CTSize sz = str->len+1; - if (!ctype_isinteger(dc->info) || dc->size != 1) - goto err_conv; - if (d->size != 0 && d->size < sz) - sz = d->size; - memcpy(dp, strdata(str), sz); - return; - } else { /* Otherwise pass it as a const char[]. */ - sp = (uint8_t *)strdata(str); - sid = CTID_A_CCHAR; - flags |= CCF_FROMTV; - } - } else if (tvistab(o)) { - if (ctype_isarray(d->info)) { - cconv_array_tab(cts, d, dp, tabV(o), flags); - return; - } else if (ctype_isstruct(d->info)) { - cconv_struct_tab(cts, d, dp, tabV(o), flags); - return; - } else { - goto err_conv; - } - } else if (tvisbool(o)) { - tmpbool = boolV(o); - sp = &tmpbool; - sid = CTID_BOOL; - } else if (tvisnil(o)) { - tmpptr = (void *)0; - flags |= CCF_FROMTV; - } else if (tvisudata(o)) { - GCudata *ud = udataV(o); - tmpptr = uddata(ud); - if (ud->udtype == UDTYPE_IO_FILE) - tmpptr = *(void **)tmpptr; - } else if (tvislightud(o)) { - tmpptr = lightudV(o); - } else if (tvisfunc(o)) { - void *p = lj_ccallback_new(cts, d, funcV(o)); - if (p) { - *(void **)dp = p; - return; - } - goto err_conv; - } else { - err_conv: - cconv_err_convtv(cts, d, o, flags); - } - s = ctype_get(cts, sid); -doconv: - if (ctype_isenum(d->info)) d = ctype_child(cts, d); - lj_cconv_ct_ct(cts, d, s, dp, sp, flags); -} - -/* Convert TValue to bitfield. */ -void lj_cconv_bf_tv(CTState *cts, CType *d, uint8_t *dp, TValue *o) -{ - CTInfo info = d->info; - CTSize pos, bsz; - uint32_t val, mask; - lua_assert(ctype_isbitfield(info)); - if ((info & CTF_BOOL)) { - uint8_t tmpbool; - lua_assert(ctype_bitbsz(info) == 1); - lj_cconv_ct_tv(cts, ctype_get(cts, CTID_BOOL), &tmpbool, o, 0); - val = tmpbool; - } else { - CTypeID did = (info & CTF_UNSIGNED) ? CTID_UINT32 : CTID_INT32; - lj_cconv_ct_tv(cts, ctype_get(cts, did), (uint8_t *)&val, o, 0); - } - pos = ctype_bitpos(info); - bsz = ctype_bitbsz(info); - lua_assert(pos < 8*ctype_bitcsz(info)); - lua_assert(bsz > 0 && bsz <= 8*ctype_bitcsz(info)); - /* Check if a packed bitfield crosses a container boundary. */ - if (pos + bsz > 8*ctype_bitcsz(info)) - lj_err_caller(cts->L, LJ_ERR_FFI_NYIPACKBIT); - mask = ((1u << bsz) - 1u) << pos; - val = (val << pos) & mask; - /* NYI: packed bitfields may cause misaligned reads/writes. */ - switch (ctype_bitcsz(info)) { - case 4: *(uint32_t *)dp = (*(uint32_t *)dp & ~mask) | (uint32_t)val; break; - case 2: *(uint16_t *)dp = (*(uint16_t *)dp & ~mask) | (uint16_t)val; break; - case 1: *(uint8_t *)dp = (*(uint8_t *)dp & ~mask) | (uint8_t)val; break; - default: lua_assert(0); break; - } -} - -/* -- Initialize C type with TValues -------------------------------------- */ - -/* Initialize an array with TValues. */ -static void cconv_array_init(CTState *cts, CType *d, CTSize sz, uint8_t *dp, - TValue *o, MSize len) -{ - CType *dc = ctype_rawchild(cts, d); /* Array element type. */ - CTSize ofs, esize = dc->size; - MSize i; - if (len*esize > sz) - cconv_err_initov(cts, d); - for (i = 0, ofs = 0; i < len; i++, ofs += esize) - lj_cconv_ct_tv(cts, dc, dp + ofs, o + i, 0); - if (ofs == esize) { /* Replicate a single element. */ - for (; ofs < sz; ofs += esize) memcpy(dp + ofs, dp, esize); - } else { /* Otherwise fill the remainder with zero. */ - memset(dp + ofs, 0, sz - ofs); - } -} - -/* Initialize a sub-struct/union with TValues. */ -static void cconv_substruct_init(CTState *cts, CType *d, uint8_t *dp, - TValue *o, MSize len, MSize *ip) -{ - CTypeID id = d->sib; - while (id) { - CType *df = ctype_get(cts, id); - id = df->sib; - if (ctype_isfield(df->info) || ctype_isbitfield(df->info)) { - MSize i = *ip; - if (!gcref(df->name)) continue; /* Ignore unnamed fields. */ - if (i >= len) break; - *ip = i + 1; - if (ctype_isfield(df->info)) - lj_cconv_ct_tv(cts, ctype_rawchild(cts, df), dp+df->size, o + i, 0); - else - lj_cconv_bf_tv(cts, df, dp+df->size, o + i); - if ((d->info & CTF_UNION)) break; - } else if (ctype_isxattrib(df->info, CTA_SUBTYPE)) { - cconv_substruct_init(cts, ctype_rawchild(cts, df), - dp+df->size, o, len, ip); - } /* Ignore all other entries in the chain. */ - } -} - -/* Initialize a struct/union with TValues. */ -static void cconv_struct_init(CTState *cts, CType *d, CTSize sz, uint8_t *dp, - TValue *o, MSize len) -{ - MSize i = 0; - memset(dp, 0, sz); /* Much simpler to clear the struct first. */ - cconv_substruct_init(cts, d, dp, o, len, &i); - if (i < len) - cconv_err_initov(cts, d); -} - -/* Check whether to use a multi-value initializer. -** This is true if an aggregate is to be initialized with a value. -** Valarrays are treated as values here so ct_tv handles (V|C, I|F). -*/ -int lj_cconv_multi_init(CTState *cts, CType *d, TValue *o) -{ - if (!(ctype_isrefarray(d->info) || ctype_isstruct(d->info))) - return 0; /* Destination is not an aggregate. */ - if (tvistab(o) || (tvisstr(o) && !ctype_isstruct(d->info))) - return 0; /* Initializer is not a value. */ - if (tviscdata(o) && lj_ctype_rawref(cts, cdataV(o)->ctypeid) == d) - return 0; /* Source and destination are identical aggregates. */ - return 1; /* Otherwise the initializer is a value. */ -} - -/* Initialize C type with TValues. Caveat: expects to get the raw CType! */ -void lj_cconv_ct_init(CTState *cts, CType *d, CTSize sz, - uint8_t *dp, TValue *o, MSize len) -{ - if (len == 0) - memset(dp, 0, sz); - else if (len == 1 && !lj_cconv_multi_init(cts, d, o)) - lj_cconv_ct_tv(cts, d, dp, o, 0); - else if (ctype_isarray(d->info)) /* Also handles valarray init with len>1. */ - cconv_array_init(cts, d, sz, dp, o, len); - else if (ctype_isstruct(d->info)) - cconv_struct_init(cts, d, sz, dp, o, len); - else - cconv_err_initov(cts, d); -} - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_cconv.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_cconv.h deleted file mode 100644 index 17e0f050e..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_cconv.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -** C type conversions. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_CCONV_H -#define _LJ_CCONV_H - -#include "lj_obj.h" -#include "lj_ctype.h" - -#if LJ_HASFFI - -/* Compressed C type index. ORDER CCX. */ -enum { - CCX_B, /* Bool. */ - CCX_I, /* Integer. */ - CCX_F, /* Floating-point number. */ - CCX_C, /* Complex. */ - CCX_V, /* Vector. */ - CCX_P, /* Pointer. */ - CCX_A, /* Refarray. */ - CCX_S /* Struct/union. */ -}; - -/* Convert C type info to compressed C type index. ORDER CT. ORDER CCX. */ -static LJ_AINLINE uint32_t cconv_idx(CTInfo info) -{ - uint32_t idx = ((info >> 26) & 15u); /* Dispatch bits. */ - lua_assert(ctype_type(info) <= CT_MAYCONVERT); -#if LJ_64 - idx = ((uint32_t)(U64x(f436fff5,fff7f021) >> 4*idx) & 15u); -#else - idx = (((idx < 8 ? 0xfff7f021u : 0xf436fff5) >> 4*(idx & 7u)) & 15u); -#endif - lua_assert(idx < 8); - return idx; -} - -#define cconv_idx2(dinfo, sinfo) \ - ((cconv_idx((dinfo)) << 3) + cconv_idx((sinfo))) - -#define CCX(dst, src) ((CCX_##dst << 3) + CCX_##src) - -/* Conversion flags. */ -#define CCF_CAST 0x00000001u -#define CCF_FROMTV 0x00000002u -#define CCF_SAME 0x00000004u -#define CCF_IGNQUAL 0x00000008u - -#define CCF_ARG_SHIFT 8 -#define CCF_ARG(n) ((n) << CCF_ARG_SHIFT) -#define CCF_GETARG(f) ((f) >> CCF_ARG_SHIFT) - -LJ_FUNC int lj_cconv_compatptr(CTState *cts, CType *d, CType *s, CTInfo flags); -LJ_FUNC void lj_cconv_ct_ct(CTState *cts, CType *d, CType *s, - uint8_t *dp, uint8_t *sp, CTInfo flags); -LJ_FUNC int lj_cconv_tv_ct(CTState *cts, CType *s, CTypeID sid, - TValue *o, uint8_t *sp); -LJ_FUNC int lj_cconv_tv_bf(CTState *cts, CType *s, TValue *o, uint8_t *sp); -LJ_FUNC void lj_cconv_ct_tv(CTState *cts, CType *d, - uint8_t *dp, TValue *o, CTInfo flags); -LJ_FUNC void lj_cconv_bf_tv(CTState *cts, CType *d, uint8_t *dp, TValue *o); -LJ_FUNC int lj_cconv_multi_init(CTState *cts, CType *d, TValue *o); -LJ_FUNC void lj_cconv_ct_init(CTState *cts, CType *d, CTSize sz, - uint8_t *dp, TValue *o, MSize len); - -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_cdata.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_cdata.c deleted file mode 100644 index 590ddf106..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_cdata.c +++ /dev/null @@ -1,285 +0,0 @@ -/* -** C data management. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#include "lj_obj.h" - -#if LJ_HASFFI - -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_ctype.h" -#include "lj_cconv.h" -#include "lj_cdata.h" - -/* -- C data allocation --------------------------------------------------- */ - -/* Allocate a new C data object holding a reference to another object. */ -GCcdata *lj_cdata_newref(CTState *cts, const void *p, CTypeID id) -{ - CTypeID refid = lj_ctype_intern(cts, CTINFO_REF(id), CTSIZE_PTR); - GCcdata *cd = lj_cdata_new(cts, refid, CTSIZE_PTR); - *(const void **)cdataptr(cd) = p; - return cd; -} - -/* Allocate variable-sized or specially aligned C data object. */ -GCcdata *lj_cdata_newv(CTState *cts, CTypeID id, CTSize sz, CTSize align) -{ - global_State *g; - MSize extra = sizeof(GCcdataVar) + sizeof(GCcdata) + - (align > CT_MEMALIGN ? (1u<L, extra + sz, char); - uintptr_t adata = (uintptr_t)p + sizeof(GCcdataVar) + sizeof(GCcdata); - uintptr_t almask = (1u << align) - 1u; - GCcdata *cd = (GCcdata *)(((adata + almask) & ~almask) - sizeof(GCcdata)); - lua_assert((char *)cd - p < 65536); - cdatav(cd)->offset = (uint16_t)((char *)cd - p); - cdatav(cd)->extra = extra; - cdatav(cd)->len = sz; - g = cts->g; - setgcrefr(cd->nextgc, g->gc.root); - setgcref(g->gc.root, obj2gco(cd)); - newwhite(g, obj2gco(cd)); - cd->marked |= 0x80; - cd->gct = ~LJ_TCDATA; - cd->ctypeid = id; - return cd; -} - -/* Free a C data object. */ -void LJ_FASTCALL lj_cdata_free(global_State *g, GCcdata *cd) -{ - if (LJ_UNLIKELY(cd->marked & LJ_GC_CDATA_FIN)) { - GCobj *root; - makewhite(g, obj2gco(cd)); - markfinalized(obj2gco(cd)); - if ((root = gcref(g->gc.mmudata)) != NULL) { - setgcrefr(cd->nextgc, root->gch.nextgc); - setgcref(root->gch.nextgc, obj2gco(cd)); - setgcref(g->gc.mmudata, obj2gco(cd)); - } else { - setgcref(cd->nextgc, obj2gco(cd)); - setgcref(g->gc.mmudata, obj2gco(cd)); - } - } else if (LJ_LIKELY(!cdataisv(cd))) { - CType *ct = ctype_raw(ctype_ctsG(g), cd->ctypeid); - CTSize sz = ctype_hassize(ct->info) ? ct->size : CTSIZE_PTR; - lua_assert(ctype_hassize(ct->info) || ctype_isfunc(ct->info) || - ctype_isextern(ct->info)); - lj_mem_free(g, cd, sizeof(GCcdata) + sz); - } else { - lj_mem_free(g, memcdatav(cd), sizecdatav(cd)); - } -} - -TValue * LJ_FASTCALL lj_cdata_setfin(lua_State *L, GCcdata *cd) -{ - global_State *g = G(L); - GCtab *t = ctype_ctsG(g)->finalizer; - if (gcref(t->metatable)) { - /* Add cdata to finalizer table, if still enabled. */ - TValue *tv, tmp; - setcdataV(L, &tmp, cd); - lj_gc_anybarriert(L, t); - tv = lj_tab_set(L, t, &tmp); - cd->marked |= LJ_GC_CDATA_FIN; - return tv; - } else { - /* Otherwise return dummy TValue. */ - return &g->tmptv; - } -} - -/* -- C data indexing ----------------------------------------------------- */ - -/* Index C data by a TValue. Return CType and pointer. */ -CType *lj_cdata_index(CTState *cts, GCcdata *cd, cTValue *key, uint8_t **pp, - CTInfo *qual) -{ - uint8_t *p = (uint8_t *)cdataptr(cd); - CType *ct = ctype_get(cts, cd->ctypeid); - ptrdiff_t idx; - - /* Resolve reference for cdata object. */ - if (ctype_isref(ct->info)) { - lua_assert(ct->size == CTSIZE_PTR); - p = *(uint8_t **)p; - ct = ctype_child(cts, ct); - } - -collect_attrib: - /* Skip attributes and collect qualifiers. */ - while (ctype_isattrib(ct->info)) { - if (ctype_attrib(ct->info) == CTA_QUAL) *qual |= ct->size; - ct = ctype_child(cts, ct); - } - lua_assert(!ctype_isref(ct->info)); /* Interning rejects refs to refs. */ - - if (tvisint(key)) { - idx = (ptrdiff_t)intV(key); - goto integer_key; - } else if (tvisnum(key)) { /* Numeric key. */ - idx = LJ_64 ? (ptrdiff_t)numV(key) : (ptrdiff_t)lj_num2int(numV(key)); - integer_key: - if (ctype_ispointer(ct->info)) { - CTSize sz = lj_ctype_size(cts, ctype_cid(ct->info)); /* Element size. */ - if (sz != CTSIZE_INVALID) { - if (ctype_isptr(ct->info)) { - p = (uint8_t *)cdata_getptr(p, ct->size); - } else if ((ct->info & (CTF_VECTOR|CTF_COMPLEX))) { - if ((ct->info & CTF_COMPLEX)) idx &= 1; - *qual |= CTF_CONST; /* Valarray elements are constant. */ - } - *pp = p + idx*(int32_t)sz; - return ct; - } - } - } else if (tviscdata(key)) { /* Integer cdata key. */ - GCcdata *cdk = cdataV(key); - CType *ctk = ctype_raw(cts, cdk->ctypeid); - if (ctype_isenum(ctk->info)) ctk = ctype_child(cts, ctk); - if (ctype_isinteger(ctk->info)) { - lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT_PSZ), ctk, - (uint8_t *)&idx, cdataptr(cdk), 0); - goto integer_key; - } - } else if (tvisstr(key)) { /* String key. */ - GCstr *name = strV(key); - if (ctype_isstruct(ct->info)) { - CTSize ofs; - CType *fct = lj_ctype_getfieldq(cts, ct, name, &ofs, qual); - if (fct) { - *pp = p + ofs; - return fct; - } - } else if (ctype_iscomplex(ct->info)) { - if (name->len == 2) { - *qual |= CTF_CONST; /* Complex fields are constant. */ - if (strdata(name)[0] == 'r' && strdata(name)[1] == 'e') { - *pp = p; - return ct; - } else if (strdata(name)[0] == 'i' && strdata(name)[1] == 'm') { - *pp = p + (ct->size >> 1); - return ct; - } - } - } else if (cd->ctypeid == CTID_CTYPEID) { - /* Allow indexing a (pointer to) struct constructor to get constants. */ - CType *sct = ctype_raw(cts, *(CTypeID *)p); - if (ctype_isptr(sct->info)) - sct = ctype_rawchild(cts, sct); - if (ctype_isstruct(sct->info)) { - CTSize ofs; - CType *fct = lj_ctype_getfield(cts, sct, name, &ofs); - if (fct && ctype_isconstval(fct->info)) - return fct; - } - ct = sct; /* Allow resolving metamethods for constructors, too. */ - } - } - if (ctype_isptr(ct->info)) { /* Automatically perform '->'. */ - if (ctype_isstruct(ctype_rawchild(cts, ct)->info)) { - p = (uint8_t *)cdata_getptr(p, ct->size); - ct = ctype_child(cts, ct); - goto collect_attrib; - } - } - *qual |= 1; /* Lookup failed. */ - return ct; /* But return the resolved raw type. */ -} - -/* -- C data getters ------------------------------------------------------ */ - -/* Get constant value and convert to TValue. */ -static void cdata_getconst(CTState *cts, TValue *o, CType *ct) -{ - CType *ctt = ctype_child(cts, ct); - lua_assert(ctype_isinteger(ctt->info) && ctt->size <= 4); - /* Constants are already zero-extended/sign-extended to 32 bits. */ - if ((ctt->info & CTF_UNSIGNED) && (int32_t)ct->size < 0) - setnumV(o, (lua_Number)(uint32_t)ct->size); - else - setintV(o, (int32_t)ct->size); -} - -/* Get C data value and convert to TValue. */ -int lj_cdata_get(CTState *cts, CType *s, TValue *o, uint8_t *sp) -{ - CTypeID sid; - - if (ctype_isconstval(s->info)) { - cdata_getconst(cts, o, s); - return 0; /* No GC step needed. */ - } else if (ctype_isbitfield(s->info)) { - return lj_cconv_tv_bf(cts, s, o, sp); - } - - /* Get child type of pointer/array/field. */ - lua_assert(ctype_ispointer(s->info) || ctype_isfield(s->info)); - sid = ctype_cid(s->info); - s = ctype_get(cts, sid); - - /* Resolve reference for field. */ - if (ctype_isref(s->info)) { - lua_assert(s->size == CTSIZE_PTR); - sp = *(uint8_t **)sp; - sid = ctype_cid(s->info); - s = ctype_get(cts, sid); - } - - /* Skip attributes. */ - while (ctype_isattrib(s->info)) - s = ctype_child(cts, s); - - return lj_cconv_tv_ct(cts, s, sid, o, sp); -} - -/* -- C data setters ------------------------------------------------------ */ - -/* Convert TValue and set C data value. */ -void lj_cdata_set(CTState *cts, CType *d, uint8_t *dp, TValue *o, CTInfo qual) -{ - if (ctype_isconstval(d->info)) { - goto err_const; - } else if (ctype_isbitfield(d->info)) { - if (((d->info|qual) & CTF_CONST)) goto err_const; - lj_cconv_bf_tv(cts, d, dp, o); - return; - } - - /* Get child type of pointer/array/field. */ - lua_assert(ctype_ispointer(d->info) || ctype_isfield(d->info)); - d = ctype_child(cts, d); - - /* Resolve reference for field. */ - if (ctype_isref(d->info)) { - lua_assert(d->size == CTSIZE_PTR); - dp = *(uint8_t **)dp; - d = ctype_child(cts, d); - } - - /* Skip attributes and collect qualifiers. */ - for (;;) { - if (ctype_isattrib(d->info)) { - if (ctype_attrib(d->info) == CTA_QUAL) qual |= d->size; - } else { - break; - } - d = ctype_child(cts, d); - } - - lua_assert(ctype_hassize(d->info) && !ctype_isvoid(d->info)); - - if (((d->info|qual) & CTF_CONST)) { - err_const: - lj_err_caller(cts->L, LJ_ERR_FFI_WRCONST); - } - - lj_cconv_ct_tv(cts, d, dp, o, 0); -} - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_cdata.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_cdata.h deleted file mode 100644 index 6c8e7a1ad..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_cdata.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -** C data management. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_CDATA_H -#define _LJ_CDATA_H - -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_ctype.h" - -#if LJ_HASFFI - -/* Get C data pointer. */ -static LJ_AINLINE void *cdata_getptr(void *p, CTSize sz) -{ - if (LJ_64 && sz == 4) { /* Support 32 bit pointers on 64 bit targets. */ - return ((void *)(uintptr_t)*(uint32_t *)p); - } else { - lua_assert(sz == CTSIZE_PTR); - return *(void **)p; - } -} - -/* Set C data pointer. */ -static LJ_AINLINE void cdata_setptr(void *p, CTSize sz, const void *v) -{ - if (LJ_64 && sz == 4) { /* Support 32 bit pointers on 64 bit targets. */ - *(uint32_t *)p = (uint32_t)(uintptr_t)v; - } else { - lua_assert(sz == CTSIZE_PTR); - *(void **)p = (void *)v; - } -} - -/* Allocate fixed-size C data object. */ -static LJ_AINLINE GCcdata *lj_cdata_new(CTState *cts, CTypeID id, CTSize sz) -{ - GCcdata *cd; -#ifdef LUA_USE_ASSERT - CType *ct = ctype_raw(cts, id); - lua_assert((ctype_hassize(ct->info) ? ct->size : CTSIZE_PTR) == sz); -#endif - cd = (GCcdata *)lj_mem_newgco(cts->L, sizeof(GCcdata) + sz); - cd->gct = ~LJ_TCDATA; - cd->ctypeid = ctype_check(cts, id); - return cd; -} - -/* Variant which works without a valid CTState. */ -static LJ_AINLINE GCcdata *lj_cdata_new_(lua_State *L, CTypeID id, CTSize sz) -{ - GCcdata *cd = (GCcdata *)lj_mem_newgco(L, sizeof(GCcdata) + sz); - cd->gct = ~LJ_TCDATA; - cd->ctypeid = id; - return cd; -} - -LJ_FUNC GCcdata *lj_cdata_newref(CTState *cts, const void *pp, CTypeID id); -LJ_FUNC GCcdata *lj_cdata_newv(CTState *cts, CTypeID id, CTSize sz, - CTSize align); - -LJ_FUNC void LJ_FASTCALL lj_cdata_free(global_State *g, GCcdata *cd); -LJ_FUNCA TValue * LJ_FASTCALL lj_cdata_setfin(lua_State *L, GCcdata *cd); - -LJ_FUNC CType *lj_cdata_index(CTState *cts, GCcdata *cd, cTValue *key, - uint8_t **pp, CTInfo *qual); -LJ_FUNC int lj_cdata_get(CTState *cts, CType *s, TValue *o, uint8_t *sp); -LJ_FUNC void lj_cdata_set(CTState *cts, CType *d, uint8_t *dp, TValue *o, - CTInfo qual); - -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_clib.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_clib.c deleted file mode 100644 index ccb99e55a..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_clib.c +++ /dev/null @@ -1,409 +0,0 @@ -/* -** FFI C library loader. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#include "lj_obj.h" - -#if LJ_HASFFI - -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_tab.h" -#include "lj_str.h" -#include "lj_udata.h" -#include "lj_ctype.h" -#include "lj_cconv.h" -#include "lj_cdata.h" -#include "lj_clib.h" - -/* -- OS-specific functions ----------------------------------------------- */ - -#if LJ_TARGET_DLOPEN - -#include -#include - -#if defined(RTLD_DEFAULT) -#define CLIB_DEFHANDLE RTLD_DEFAULT -#elif LJ_TARGET_OSX || LJ_TARGET_BSD -#define CLIB_DEFHANDLE ((void *)(intptr_t)-2) -#else -#define CLIB_DEFHANDLE NULL -#endif - -LJ_NORET LJ_NOINLINE static void clib_error_(lua_State *L) -{ - lj_err_callermsg(L, dlerror()); -} - -#define clib_error(L, fmt, name) clib_error_(L) - -#if defined(__CYGWIN__) -#define CLIB_SOPREFIX "cyg" -#else -#define CLIB_SOPREFIX "lib" -#endif - -#if LJ_TARGET_OSX -#define CLIB_SOEXT "%s.dylib" -#elif defined(__CYGWIN__) -#define CLIB_SOEXT "%s.dll" -#else -#define CLIB_SOEXT "%s.so" -#endif - -static const char *clib_extname(lua_State *L, const char *name) -{ - if (!strchr(name, '/') -#ifdef __CYGWIN__ - && !strchr(name, '\\') -#endif - ) { - if (!strchr(name, '.')) { - name = lj_str_pushf(L, CLIB_SOEXT, name); - L->top--; -#ifdef __CYGWIN__ - } else { - return name; -#endif - } - if (!(name[0] == CLIB_SOPREFIX[0] && name[1] == CLIB_SOPREFIX[1] && - name[2] == CLIB_SOPREFIX[2])) { - name = lj_str_pushf(L, CLIB_SOPREFIX "%s", name); - L->top--; - } - } - return name; -} - -/* Check for a recognized ld script line. */ -static const char *clib_check_lds(lua_State *L, const char *buf) -{ - char *p, *e; - if ((!strncmp(buf, "GROUP", 5) || !strncmp(buf, "INPUT", 5)) && - (p = strchr(buf, '('))) { - while (*++p == ' ') ; - for (e = p; *e && *e != ' ' && *e != ')'; e++) ; - return strdata(lj_str_new(L, p, e-p)); - } - return NULL; -} - -/* Quick and dirty solution to resolve shared library name from ld script. */ -static const char *clib_resolve_lds(lua_State *L, const char *name) -{ - FILE *fp = fopen(name, "r"); - const char *p = NULL; - if (fp) { - char buf[256]; - if (fgets(buf, sizeof(buf), fp)) { - if (!strncmp(buf, "/* GNU ld script", 16)) { /* ld script magic? */ - while (fgets(buf, sizeof(buf), fp)) { /* Check all lines. */ - p = clib_check_lds(L, buf); - if (p) break; - } - } else { /* Otherwise check only the first line. */ - p = clib_check_lds(L, buf); - } - } - fclose(fp); - } - return p; -} - -static void *clib_loadlib(lua_State *L, const char *name, int global) -{ - void *h = dlopen(clib_extname(L, name), - RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL)); - if (!h) { - const char *e, *err = dlerror(); - if (*err == '/' && (e = strchr(err, ':')) && - (name = clib_resolve_lds(L, strdata(lj_str_new(L, err, e-err))))) { - h = dlopen(name, RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL)); - if (h) return h; - err = dlerror(); - } - lj_err_callermsg(L, err); - } - return h; -} - -static void clib_unloadlib(CLibrary *cl) -{ - if (cl->handle && cl->handle != CLIB_DEFHANDLE) - dlclose(cl->handle); -} - -static void *clib_getsym(CLibrary *cl, const char *name) -{ - void *p = dlsym(cl->handle, name); - return p; -} - -#elif LJ_TARGET_WINDOWS - -#define WIN32_LEAN_AND_MEAN -#include - -#ifndef GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS -#define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 4 -#define GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT 2 -BOOL WINAPI GetModuleHandleExA(DWORD, LPCSTR, HMODULE*); -#endif - -#define CLIB_DEFHANDLE ((void *)-1) - -/* Default libraries. */ -enum { - CLIB_HANDLE_EXE, - CLIB_HANDLE_DLL, - CLIB_HANDLE_CRT, - CLIB_HANDLE_KERNEL32, - CLIB_HANDLE_USER32, - CLIB_HANDLE_GDI32, - CLIB_HANDLE_MAX -}; - -static void *clib_def_handle[CLIB_HANDLE_MAX]; - -LJ_NORET LJ_NOINLINE static void clib_error(lua_State *L, const char *fmt, - const char *name) -{ - DWORD err = GetLastError(); - char buf[128]; - if (!FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_SYSTEM, - NULL, err, 0, buf, sizeof(buf), NULL)) - buf[0] = '\0'; - lj_err_callermsg(L, lj_str_pushf(L, fmt, name, buf)); -} - -static int clib_needext(const char *s) -{ - while (*s) { - if (*s == '/' || *s == '\\' || *s == '.') return 0; - s++; - } - return 1; -} - -static const char *clib_extname(lua_State *L, const char *name) -{ - if (clib_needext(name)) { - name = lj_str_pushf(L, "%s.dll", name); - L->top--; - } - return name; -} - -static void *clib_loadlib(lua_State *L, const char *name, int global) -{ - DWORD oldwerr = GetLastError(); - void *h = (void *)LoadLibraryA(clib_extname(L, name)); - if (!h) clib_error(L, "cannot load module " LUA_QS ": %s", name); - SetLastError(oldwerr); - UNUSED(global); - return h; -} - -static void clib_unloadlib(CLibrary *cl) -{ - if (cl->handle == CLIB_DEFHANDLE) { - MSize i; - for (i = CLIB_HANDLE_KERNEL32; i < CLIB_HANDLE_MAX; i++) { - void *h = clib_def_handle[i]; - if (h) { - clib_def_handle[i] = NULL; - FreeLibrary((HINSTANCE)h); - } - } - } else if (cl->handle) { - FreeLibrary((HINSTANCE)cl->handle); - } -} - -static void *clib_getsym(CLibrary *cl, const char *name) -{ - void *p = NULL; - if (cl->handle == CLIB_DEFHANDLE) { /* Search default libraries. */ - MSize i; - for (i = 0; i < CLIB_HANDLE_MAX; i++) { - HINSTANCE h = (HINSTANCE)clib_def_handle[i]; - if (!(void *)h) { /* Resolve default library handles (once). */ - switch (i) { - case CLIB_HANDLE_EXE: GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, &h); break; - case CLIB_HANDLE_DLL: - GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - (const char *)clib_def_handle, &h); - break; - case CLIB_HANDLE_CRT: - GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - (const char *)&_fmode, &h); - break; - case CLIB_HANDLE_KERNEL32: h = LoadLibraryA("kernel32.dll"); break; - case CLIB_HANDLE_USER32: h = LoadLibraryA("user32.dll"); break; - case CLIB_HANDLE_GDI32: h = LoadLibraryA("gdi32.dll"); break; - } - if (!h) continue; - clib_def_handle[i] = (void *)h; - } - p = (void *)GetProcAddress(h, name); - if (p) break; - } - } else { - p = (void *)GetProcAddress((HINSTANCE)cl->handle, name); - } - return p; -} - -#else - -#define CLIB_DEFHANDLE NULL - -LJ_NORET LJ_NOINLINE static void clib_error(lua_State *L, const char *fmt, - const char *name) -{ - lj_err_callermsg(L, lj_str_pushf(L, fmt, name, "no support for this OS")); -} - -static void *clib_loadlib(lua_State *L, const char *name, int global) -{ - lj_err_callermsg(L, "no support for loading dynamic libraries for this OS"); - UNUSED(name); UNUSED(global); - return NULL; -} - -static void clib_unloadlib(CLibrary *cl) -{ - UNUSED(cl); -} - -static void *clib_getsym(CLibrary *cl, const char *name) -{ - UNUSED(cl); UNUSED(name); - return NULL; -} - -#endif - -/* -- C library indexing -------------------------------------------------- */ - -#if LJ_TARGET_X86 && LJ_ABI_WIN -/* Compute argument size for fastcall/stdcall functions. */ -static CTSize clib_func_argsize(CTState *cts, CType *ct) -{ - CTSize n = 0; - while (ct->sib) { - CType *d; - ct = ctype_get(cts, ct->sib); - if (ctype_isfield(ct->info)) { - d = ctype_rawchild(cts, ct); - n += ((d->size + 3) & ~3); - } - } - return n; -} -#endif - -/* Get redirected or mangled external symbol. */ -static const char *clib_extsym(CTState *cts, CType *ct, GCstr *name) -{ - if (ct->sib) { - CType *ctf = ctype_get(cts, ct->sib); - if (ctype_isxattrib(ctf->info, CTA_REDIR)) - return strdata(gco2str(gcref(ctf->name))); - } - return strdata(name); -} - -/* Index a C library by name. */ -TValue *lj_clib_index(lua_State *L, CLibrary *cl, GCstr *name) -{ - TValue *tv = lj_tab_setstr(L, cl->cache, name); - if (LJ_UNLIKELY(tvisnil(tv))) { - CTState *cts = ctype_cts(L); - CType *ct; - CTypeID id = lj_ctype_getname(cts, &ct, name, CLNS_INDEX); - if (!id) - lj_err_callerv(L, LJ_ERR_FFI_NODECL, strdata(name)); - if (ctype_isconstval(ct->info)) { - CType *ctt = ctype_child(cts, ct); - lua_assert(ctype_isinteger(ctt->info) && ctt->size <= 4); - if ((ctt->info & CTF_UNSIGNED) && (int32_t)ct->size < 0) - setnumV(tv, (lua_Number)(uint32_t)ct->size); - else - setintV(tv, (int32_t)ct->size); - } else { - const char *sym = clib_extsym(cts, ct, name); -#if LJ_TARGET_WINDOWS - DWORD oldwerr = GetLastError(); -#endif - void *p = clib_getsym(cl, sym); - GCcdata *cd; - lua_assert(ctype_isfunc(ct->info) || ctype_isextern(ct->info)); -#if LJ_TARGET_X86 && LJ_ABI_WIN - /* Retry with decorated name for fastcall/stdcall functions. */ - if (!p && ctype_isfunc(ct->info)) { - CTInfo cconv = ctype_cconv(ct->info); - if (cconv == CTCC_FASTCALL || cconv == CTCC_STDCALL) { - CTSize sz = clib_func_argsize(cts, ct); - const char *symd = lj_str_pushf(L, - cconv == CTCC_FASTCALL ? "@%s@%d" : "_%s@%d", - sym, sz); - L->top--; - p = clib_getsym(cl, symd); - } - } -#endif - if (!p) - clib_error(L, "cannot resolve symbol " LUA_QS ": %s", sym); -#if LJ_TARGET_WINDOWS - SetLastError(oldwerr); -#endif - cd = lj_cdata_new(cts, id, CTSIZE_PTR); - *(void **)cdataptr(cd) = p; - setcdataV(L, tv, cd); - } - } - return tv; -} - -/* -- C library management ------------------------------------------------ */ - -/* Create a new CLibrary object and push it on the stack. */ -static CLibrary *clib_new(lua_State *L, GCtab *mt) -{ - GCtab *t = lj_tab_new(L, 0, 0); - GCudata *ud = lj_udata_new(L, sizeof(CLibrary), t); - CLibrary *cl = (CLibrary *)uddata(ud); - cl->cache = t; - ud->udtype = UDTYPE_FFI_CLIB; - /* NOBARRIER: The GCudata is new (marked white). */ - setgcref(ud->metatable, obj2gco(mt)); - setudataV(L, L->top++, ud); - return cl; -} - -/* Load a C library. */ -void lj_clib_load(lua_State *L, GCtab *mt, GCstr *name, int global) -{ - void *handle = clib_loadlib(L, strdata(name), global); - CLibrary *cl = clib_new(L, mt); - cl->handle = handle; -} - -/* Unload a C library. */ -void lj_clib_unload(CLibrary *cl) -{ - clib_unloadlib(cl); - cl->handle = NULL; -} - -/* Create the default C library object. */ -void lj_clib_default(lua_State *L, GCtab *mt) -{ - CLibrary *cl = clib_new(L, mt); - cl->handle = CLIB_DEFHANDLE; -} - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_clib.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_clib.h deleted file mode 100644 index 473732882..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_clib.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -** FFI C library loader. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_CLIB_H -#define _LJ_CLIB_H - -#include "lj_obj.h" - -#if LJ_HASFFI - -/* Namespace for C library indexing. */ -#define CLNS_INDEX ((1u<env. */ -} CLibrary; - -LJ_FUNC TValue *lj_clib_index(lua_State *L, CLibrary *cl, GCstr *name); -LJ_FUNC void lj_clib_load(lua_State *L, GCtab *mt, GCstr *name, int global); -LJ_FUNC void lj_clib_unload(CLibrary *cl); -LJ_FUNC void lj_clib_default(lua_State *L, GCtab *mt); - -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_cparse.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_cparse.c deleted file mode 100644 index 6ffe16a2f..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_cparse.c +++ /dev/null @@ -1,1872 +0,0 @@ -/* -** C declaration parser. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#include "lj_obj.h" - -#if LJ_HASFFI - -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_str.h" -#include "lj_ctype.h" -#include "lj_cparse.h" -#include "lj_frame.h" -#include "lj_vm.h" -#include "lj_char.h" -#include "lj_strscan.h" - -/* -** Important note: this is NOT a validating C parser! This is a minimal -** C declaration parser, solely for use by the LuaJIT FFI. -** -** It ought to return correct results for properly formed C declarations, -** but it may accept some invalid declarations, too (and return nonsense). -** Also, it shows rather generic error messages to avoid unnecessary bloat. -** If in doubt, please check the input against your favorite C compiler. -*/ - -/* -- C lexer ------------------------------------------------------------- */ - -/* C lexer token names. */ -static const char *const ctoknames[] = { -#define CTOKSTR(name, str) str, -CTOKDEF(CTOKSTR) -#undef CTOKSTR - NULL -}; - -/* Forward declaration. */ -LJ_NORET static void cp_err(CPState *cp, ErrMsg em); - -static const char *cp_tok2str(CPState *cp, CPToken tok) -{ - lua_assert(tok < CTOK_FIRSTDECL); - if (tok > CTOK_OFS) - return ctoknames[tok-CTOK_OFS-1]; - else if (!lj_char_iscntrl(tok)) - return lj_str_pushf(cp->L, "%c", tok); - else - return lj_str_pushf(cp->L, "char(%d)", tok); -} - -/* End-of-line? */ -static LJ_AINLINE int cp_iseol(CPChar c) -{ - return (c == '\n' || c == '\r'); -} - -/* Peek next raw character. */ -static LJ_AINLINE CPChar cp_rawpeek(CPState *cp) -{ - return (CPChar)(uint8_t)(*cp->p); -} - -static LJ_NOINLINE CPChar cp_get_bs(CPState *cp); - -/* Get next character. */ -static LJ_AINLINE CPChar cp_get(CPState *cp) -{ - cp->c = (CPChar)(uint8_t)(*cp->p++); - if (LJ_LIKELY(cp->c != '\\')) return cp->c; - return cp_get_bs(cp); -} - -/* Transparently skip backslash-escaped line breaks. */ -static LJ_NOINLINE CPChar cp_get_bs(CPState *cp) -{ - CPChar c2, c = cp_rawpeek(cp); - if (!cp_iseol(c)) return cp->c; - cp->p++; - c2 = cp_rawpeek(cp); - if (cp_iseol(c2) && c2 != c) cp->p++; - cp->linenumber++; - return cp_get(cp); -} - -/* Grow save buffer. */ -static LJ_NOINLINE void cp_save_grow(CPState *cp, CPChar c) -{ - MSize newsize; - if (cp->sb.sz >= CPARSE_MAX_BUF/2) - cp_err(cp, LJ_ERR_XELEM); - newsize = cp->sb.sz * 2; - lj_str_resizebuf(cp->L, &cp->sb, newsize); - cp->sb.buf[cp->sb.n++] = (char)c; -} - -/* Save character in buffer. */ -static LJ_AINLINE void cp_save(CPState *cp, CPChar c) -{ - if (LJ_UNLIKELY(cp->sb.n + 1 > cp->sb.sz)) - cp_save_grow(cp, c); - else - cp->sb.buf[cp->sb.n++] = (char)c; -} - -/* Skip line break. Handles "\n", "\r", "\r\n" or "\n\r". */ -static void cp_newline(CPState *cp) -{ - CPChar c = cp_rawpeek(cp); - if (cp_iseol(c) && c != cp->c) cp->p++; - cp->linenumber++; -} - -LJ_NORET static void cp_errmsg(CPState *cp, CPToken tok, ErrMsg em, ...) -{ - const char *msg, *tokstr; - lua_State *L; - va_list argp; - if (tok == 0) { - tokstr = NULL; - } else if (tok == CTOK_IDENT || tok == CTOK_INTEGER || tok == CTOK_STRING || - tok >= CTOK_FIRSTDECL) { - if (cp->sb.n == 0) cp_save(cp, '$'); - cp_save(cp, '\0'); - tokstr = cp->sb.buf; - } else { - tokstr = cp_tok2str(cp, tok); - } - L = cp->L; - va_start(argp, em); - msg = lj_str_pushvf(L, err2msg(em), argp); - va_end(argp); - if (tokstr) - msg = lj_str_pushf(L, err2msg(LJ_ERR_XNEAR), msg, tokstr); - if (cp->linenumber > 1) - msg = lj_str_pushf(L, "%s at line %d", msg, cp->linenumber); - lj_err_callermsg(L, msg); -} - -LJ_NORET LJ_NOINLINE static void cp_err_token(CPState *cp, CPToken tok) -{ - cp_errmsg(cp, cp->tok, LJ_ERR_XTOKEN, cp_tok2str(cp, tok)); -} - -LJ_NORET LJ_NOINLINE static void cp_err_badidx(CPState *cp, CType *ct) -{ - GCstr *s = lj_ctype_repr(cp->cts->L, ctype_typeid(cp->cts, ct), NULL); - cp_errmsg(cp, 0, LJ_ERR_FFI_BADIDX, strdata(s)); -} - -LJ_NORET LJ_NOINLINE static void cp_err(CPState *cp, ErrMsg em) -{ - cp_errmsg(cp, 0, em); -} - -/* -- Main lexical scanner ------------------------------------------------ */ - -/* Parse number literal. Only handles int32_t/uint32_t right now. */ -static CPToken cp_number(CPState *cp) -{ - StrScanFmt fmt; - TValue o; - do { cp_save(cp, cp->c); } while (lj_char_isident(cp_get(cp))); - cp_save(cp, '\0'); - fmt = lj_strscan_scan((const uint8_t *)cp->sb.buf, &o, STRSCAN_OPT_C); - if (fmt == STRSCAN_INT) cp->val.id = CTID_INT32; - else if (fmt == STRSCAN_U32) cp->val.id = CTID_UINT32; - else if (!(cp->mode & CPARSE_MODE_SKIP)) - cp_errmsg(cp, CTOK_INTEGER, LJ_ERR_XNUMBER); - cp->val.u32 = (uint32_t)o.i; - return CTOK_INTEGER; -} - -/* Parse identifier or keyword. */ -static CPToken cp_ident(CPState *cp) -{ - do { cp_save(cp, cp->c); } while (lj_char_isident(cp_get(cp))); - cp->str = lj_str_new(cp->L, cp->sb.buf, cp->sb.n); - cp->val.id = lj_ctype_getname(cp->cts, &cp->ct, cp->str, cp->tmask); - if (ctype_type(cp->ct->info) == CT_KW) - return ctype_cid(cp->ct->info); - return CTOK_IDENT; -} - -/* Parse parameter. */ -static CPToken cp_param(CPState *cp) -{ - CPChar c = cp_get(cp); - TValue *o = cp->param; - if (lj_char_isident(c) || c == '$') /* Reserve $xyz for future extensions. */ - cp_errmsg(cp, c, LJ_ERR_XSYNTAX); - if (!o || o >= cp->L->top) - cp_err(cp, LJ_ERR_FFI_NUMPARAM); - cp->param = o+1; - if (tvisstr(o)) { - cp->str = strV(o); - cp->val.id = 0; - cp->ct = &cp->cts->tab[0]; - return CTOK_IDENT; - } else if (tvisnumber(o)) { - cp->val.i32 = numberVint(o); - cp->val.id = CTID_INT32; - return CTOK_INTEGER; - } else { - GCcdata *cd; - if (!tviscdata(o)) - lj_err_argtype(cp->L, (int)(o-cp->L->base)+1, "type parameter"); - cd = cdataV(o); - if (cd->ctypeid == CTID_CTYPEID) - cp->val.id = *(CTypeID *)cdataptr(cd); - else - cp->val.id = cd->ctypeid; - return '$'; - } -} - -/* Parse string or character constant. */ -static CPToken cp_string(CPState *cp) -{ - CPChar delim = cp->c; - cp_get(cp); - while (cp->c != delim) { - CPChar c = cp->c; - if (c == '\0') cp_errmsg(cp, CTOK_EOF, LJ_ERR_XSTR); - if (c == '\\') { - c = cp_get(cp); - switch (c) { - case '\0': cp_errmsg(cp, CTOK_EOF, LJ_ERR_XSTR); break; - case 'a': c = '\a'; break; - case 'b': c = '\b'; break; - case 'f': c = '\f'; break; - case 'n': c = '\n'; break; - case 'r': c = '\r'; break; - case 't': c = '\t'; break; - case 'v': c = '\v'; break; - case 'e': c = 27; break; - case 'x': - c = 0; - while (lj_char_isxdigit(cp_get(cp))) - c = (c<<4) + (lj_char_isdigit(cp->c) ? cp->c-'0' : (cp->c&15)+9); - cp_save(cp, (c & 0xff)); - continue; - default: - if (lj_char_isdigit(c)) { - c -= '0'; - if (lj_char_isdigit(cp_get(cp))) { - c = c*8 + (cp->c - '0'); - if (lj_char_isdigit(cp_get(cp))) { - c = c*8 + (cp->c - '0'); - cp_get(cp); - } - } - cp_save(cp, (c & 0xff)); - continue; - } - break; - } - } - cp_save(cp, c); - cp_get(cp); - } - cp_get(cp); - if (delim == '"') { - cp->str = lj_str_new(cp->L, cp->sb.buf, cp->sb.n); - return CTOK_STRING; - } else { - if (cp->sb.n != 1) cp_err_token(cp, '\''); - cp->val.i32 = (int32_t)(char)cp->sb.buf[0]; - cp->val.id = CTID_INT32; - return CTOK_INTEGER; - } -} - -/* Skip C comment. */ -static void cp_comment_c(CPState *cp) -{ - do { - if (cp_get(cp) == '*') { - do { - if (cp_get(cp) == '/') { cp_get(cp); return; } - } while (cp->c == '*'); - } - if (cp_iseol(cp->c)) cp_newline(cp); - } while (cp->c != '\0'); -} - -/* Skip C++ comment. */ -static void cp_comment_cpp(CPState *cp) -{ - while (!cp_iseol(cp_get(cp)) && cp->c != '\0') - ; -} - -/* Lexical scanner for C. Only a minimal subset is implemented. */ -static CPToken cp_next_(CPState *cp) -{ - lj_str_resetbuf(&cp->sb); - for (;;) { - if (lj_char_isident(cp->c)) - return lj_char_isdigit(cp->c) ? cp_number(cp) : cp_ident(cp); - switch (cp->c) { - case '\n': case '\r': cp_newline(cp); /* fallthrough. */ - case ' ': case '\t': case '\v': case '\f': cp_get(cp); break; - case '"': case '\'': return cp_string(cp); - case '/': - if (cp_get(cp) == '*') cp_comment_c(cp); - else if (cp->c == '/') cp_comment_cpp(cp); - else return '/'; - break; - case '|': - if (cp_get(cp) != '|') return '|'; cp_get(cp); return CTOK_OROR; - case '&': - if (cp_get(cp) != '&') return '&'; cp_get(cp); return CTOK_ANDAND; - case '=': - if (cp_get(cp) != '=') return '='; cp_get(cp); return CTOK_EQ; - case '!': - if (cp_get(cp) != '=') return '!'; cp_get(cp); return CTOK_NE; - case '<': - if (cp_get(cp) == '=') { cp_get(cp); return CTOK_LE; } - else if (cp->c == '<') { cp_get(cp); return CTOK_SHL; } - return '<'; - case '>': - if (cp_get(cp) == '=') { cp_get(cp); return CTOK_GE; } - else if (cp->c == '>') { cp_get(cp); return CTOK_SHR; } - return '>'; - case '-': - if (cp_get(cp) != '>') return '-'; cp_get(cp); return CTOK_DEREF; - case '$': - return cp_param(cp); - case '\0': return CTOK_EOF; - default: { CPToken c = cp->c; cp_get(cp); return c; } - } - } -} - -static LJ_NOINLINE CPToken cp_next(CPState *cp) -{ - return (cp->tok = cp_next_(cp)); -} - -/* -- C parser ------------------------------------------------------------ */ - -/* Namespaces for resolving identifiers. */ -#define CPNS_DEFAULT \ - ((1u<linenumber = 1; - cp->depth = 0; - cp->curpack = 0; - cp->packstack[0] = 255; - lj_str_initbuf(&cp->sb); - lj_str_resizebuf(cp->L, &cp->sb, LJ_MIN_SBUF); - lua_assert(cp->p != NULL); - cp_get(cp); /* Read-ahead first char. */ - cp->tok = 0; - cp->tmask = CPNS_DEFAULT; - cp_next(cp); /* Read-ahead first token. */ -} - -/* Cleanup C parser state. */ -static void cp_cleanup(CPState *cp) -{ - global_State *g = G(cp->L); - lj_str_freebuf(g, &cp->sb); -} - -/* Check and consume optional token. */ -static int cp_opt(CPState *cp, CPToken tok) -{ - if (cp->tok == tok) { cp_next(cp); return 1; } - return 0; -} - -/* Check and consume token. */ -static void cp_check(CPState *cp, CPToken tok) -{ - if (cp->tok != tok) cp_err_token(cp, tok); - cp_next(cp); -} - -/* Check if the next token may start a type declaration. */ -static int cp_istypedecl(CPState *cp) -{ - if (cp->tok >= CTOK_FIRSTDECL && cp->tok <= CTOK_LASTDECL) return 1; - if (cp->tok == CTOK_IDENT && ctype_istypedef(cp->ct->info)) return 1; - if (cp->tok == '$') return 1; - return 0; -} - -/* -- Constant expression evaluator --------------------------------------- */ - -/* Forward declarations. */ -static void cp_expr_unary(CPState *cp, CPValue *k); -static void cp_expr_sub(CPState *cp, CPValue *k, int pri); - -/* Please note that type handling is very weak here. Most ops simply -** assume integer operands. Accessors are only needed to compute types and -** return synthetic values. The only purpose of the expression evaluator -** is to compute the values of constant expressions one would typically -** find in C header files. And again: this is NOT a validating C parser! -*/ - -/* Parse comma separated expression and return last result. */ -static void cp_expr_comma(CPState *cp, CPValue *k) -{ - do { cp_expr_sub(cp, k, 0); } while (cp_opt(cp, ',')); -} - -/* Parse sizeof/alignof operator. */ -static void cp_expr_sizeof(CPState *cp, CPValue *k, int wantsz) -{ - CTSize sz; - CTInfo info; - if (cp_opt(cp, '(')) { - if (cp_istypedecl(cp)) - k->id = cp_decl_abstract(cp); - else - cp_expr_comma(cp, k); - cp_check(cp, ')'); - } else { - cp_expr_unary(cp, k); - } - info = lj_ctype_info(cp->cts, k->id, &sz); - if (wantsz) { - if (sz != CTSIZE_INVALID) - k->u32 = sz; - else if (k->id != CTID_A_CCHAR) /* Special case for sizeof("string"). */ - cp_err(cp, LJ_ERR_FFI_INVSIZE); - } else { - k->u32 = 1u << ctype_align(info); - } - k->id = CTID_UINT32; /* Really size_t. */ -} - -/* Parse prefix operators. */ -static void cp_expr_prefix(CPState *cp, CPValue *k) -{ - if (cp->tok == CTOK_INTEGER) { - *k = cp->val; cp_next(cp); - } else if (cp_opt(cp, '+')) { - cp_expr_unary(cp, k); /* Nothing to do (well, integer promotion). */ - } else if (cp_opt(cp, '-')) { - cp_expr_unary(cp, k); k->i32 = -k->i32; - } else if (cp_opt(cp, '~')) { - cp_expr_unary(cp, k); k->i32 = ~k->i32; - } else if (cp_opt(cp, '!')) { - cp_expr_unary(cp, k); k->i32 = !k->i32; k->id = CTID_INT32; - } else if (cp_opt(cp, '(')) { - if (cp_istypedecl(cp)) { /* Cast operator. */ - CTypeID id = cp_decl_abstract(cp); - cp_check(cp, ')'); - cp_expr_unary(cp, k); - k->id = id; /* No conversion performed. */ - } else { /* Sub-expression. */ - cp_expr_comma(cp, k); - cp_check(cp, ')'); - } - } else if (cp_opt(cp, '*')) { /* Indirection. */ - CType *ct; - cp_expr_unary(cp, k); - ct = lj_ctype_rawref(cp->cts, k->id); - if (!ctype_ispointer(ct->info)) - cp_err_badidx(cp, ct); - k->u32 = 0; k->id = ctype_cid(ct->info); - } else if (cp_opt(cp, '&')) { /* Address operator. */ - cp_expr_unary(cp, k); - k->id = lj_ctype_intern(cp->cts, CTINFO(CT_PTR, CTALIGN_PTR+k->id), - CTSIZE_PTR); - } else if (cp_opt(cp, CTOK_SIZEOF)) { - cp_expr_sizeof(cp, k, 1); - } else if (cp_opt(cp, CTOK_ALIGNOF)) { - cp_expr_sizeof(cp, k, 0); - } else if (cp->tok == CTOK_IDENT) { - if (ctype_type(cp->ct->info) == CT_CONSTVAL) { - k->u32 = cp->ct->size; k->id = ctype_cid(cp->ct->info); - } else if (ctype_type(cp->ct->info) == CT_EXTERN) { - k->u32 = cp->val.id; k->id = ctype_cid(cp->ct->info); - } else if (ctype_type(cp->ct->info) == CT_FUNC) { - k->u32 = cp->val.id; k->id = cp->val.id; - } else { - goto err_expr; - } - cp_next(cp); - } else if (cp->tok == CTOK_STRING) { - CTSize sz = cp->str->len; - while (cp_next(cp) == CTOK_STRING) - sz += cp->str->len; - k->u32 = sz + 1; - k->id = CTID_A_CCHAR; - } else { - err_expr: - cp_errmsg(cp, cp->tok, LJ_ERR_XSYMBOL); - } -} - -/* Parse postfix operators. */ -static void cp_expr_postfix(CPState *cp, CPValue *k) -{ - for (;;) { - CType *ct; - if (cp_opt(cp, '[')) { /* Array/pointer index. */ - CPValue k2; - cp_expr_comma(cp, &k2); - ct = lj_ctype_rawref(cp->cts, k->id); - if (!ctype_ispointer(ct->info)) { - ct = lj_ctype_rawref(cp->cts, k2.id); - if (!ctype_ispointer(ct->info)) - cp_err_badidx(cp, ct); - } - cp_check(cp, ']'); - k->u32 = 0; - } else if (cp->tok == '.' || cp->tok == CTOK_DEREF) { /* Struct deref. */ - CTSize ofs; - CType *fct; - ct = lj_ctype_rawref(cp->cts, k->id); - if (cp->tok == CTOK_DEREF) { - if (!ctype_ispointer(ct->info)) - cp_err_badidx(cp, ct); - ct = lj_ctype_rawref(cp->cts, ctype_cid(ct->info)); - } - cp_next(cp); - if (cp->tok != CTOK_IDENT) cp_err_token(cp, CTOK_IDENT); - if (!ctype_isstruct(ct->info) || ct->size == CTSIZE_INVALID || - !(fct = lj_ctype_getfield(cp->cts, ct, cp->str, &ofs)) || - ctype_isbitfield(fct->info)) { - GCstr *s = lj_ctype_repr(cp->cts->L, ctype_typeid(cp->cts, ct), NULL); - cp_errmsg(cp, 0, LJ_ERR_FFI_BADMEMBER, strdata(s), strdata(cp->str)); - } - ct = fct; - k->u32 = ctype_isconstval(ct->info) ? ct->size : 0; - cp_next(cp); - } else { - return; - } - k->id = ctype_cid(ct->info); - } -} - -/* Parse infix operators. */ -static void cp_expr_infix(CPState *cp, CPValue *k, int pri) -{ - CPValue k2; - k2.u32 = 0; k2.id = 0; /* Silence the compiler. */ - for (;;) { - switch (pri) { - case 0: - if (cp_opt(cp, '?')) { - CPValue k3; - cp_expr_comma(cp, &k2); /* Right-associative. */ - cp_check(cp, ':'); - cp_expr_sub(cp, &k3, 0); - k->u32 = k->u32 ? k2.u32 : k3.u32; - k->id = k2.id > k3.id ? k2.id : k3.id; - continue; - } - case 1: - if (cp_opt(cp, CTOK_OROR)) { - cp_expr_sub(cp, &k2, 2); k->i32 = k->u32 || k2.u32; k->id = CTID_INT32; - continue; - } - case 2: - if (cp_opt(cp, CTOK_ANDAND)) { - cp_expr_sub(cp, &k2, 3); k->i32 = k->u32 && k2.u32; k->id = CTID_INT32; - continue; - } - case 3: - if (cp_opt(cp, '|')) { - cp_expr_sub(cp, &k2, 4); k->u32 = k->u32 | k2.u32; goto arith_result; - } - case 4: - if (cp_opt(cp, '^')) { - cp_expr_sub(cp, &k2, 5); k->u32 = k->u32 ^ k2.u32; goto arith_result; - } - case 5: - if (cp_opt(cp, '&')) { - cp_expr_sub(cp, &k2, 6); k->u32 = k->u32 & k2.u32; goto arith_result; - } - case 6: - if (cp_opt(cp, CTOK_EQ)) { - cp_expr_sub(cp, &k2, 7); k->i32 = k->u32 == k2.u32; k->id = CTID_INT32; - continue; - } else if (cp_opt(cp, CTOK_NE)) { - cp_expr_sub(cp, &k2, 7); k->i32 = k->u32 != k2.u32; k->id = CTID_INT32; - continue; - } - case 7: - if (cp_opt(cp, '<')) { - cp_expr_sub(cp, &k2, 8); - if (k->id == CTID_INT32 && k2.id == CTID_INT32) - k->i32 = k->i32 < k2.i32; - else - k->i32 = k->u32 < k2.u32; - k->id = CTID_INT32; - continue; - } else if (cp_opt(cp, '>')) { - cp_expr_sub(cp, &k2, 8); - if (k->id == CTID_INT32 && k2.id == CTID_INT32) - k->i32 = k->i32 > k2.i32; - else - k->i32 = k->u32 > k2.u32; - k->id = CTID_INT32; - continue; - } else if (cp_opt(cp, CTOK_LE)) { - cp_expr_sub(cp, &k2, 8); - if (k->id == CTID_INT32 && k2.id == CTID_INT32) - k->i32 = k->i32 <= k2.i32; - else - k->i32 = k->u32 <= k2.u32; - k->id = CTID_INT32; - continue; - } else if (cp_opt(cp, CTOK_GE)) { - cp_expr_sub(cp, &k2, 8); - if (k->id == CTID_INT32 && k2.id == CTID_INT32) - k->i32 = k->i32 >= k2.i32; - else - k->i32 = k->u32 >= k2.u32; - k->id = CTID_INT32; - continue; - } - case 8: - if (cp_opt(cp, CTOK_SHL)) { - cp_expr_sub(cp, &k2, 9); k->u32 = k->u32 << k2.u32; - continue; - } else if (cp_opt(cp, CTOK_SHR)) { - cp_expr_sub(cp, &k2, 9); - if (k->id == CTID_INT32) - k->i32 = k->i32 >> k2.i32; - else - k->u32 = k->u32 >> k2.u32; - continue; - } - case 9: - if (cp_opt(cp, '+')) { - cp_expr_sub(cp, &k2, 10); k->u32 = k->u32 + k2.u32; - arith_result: - if (k2.id > k->id) k->id = k2.id; /* Trivial promotion to unsigned. */ - continue; - } else if (cp_opt(cp, '-')) { - cp_expr_sub(cp, &k2, 10); k->u32 = k->u32 - k2.u32; goto arith_result; - } - case 10: - if (cp_opt(cp, '*')) { - cp_expr_unary(cp, &k2); k->u32 = k->u32 * k2.u32; goto arith_result; - } else if (cp_opt(cp, '/')) { - cp_expr_unary(cp, &k2); - if (k2.id > k->id) k->id = k2.id; /* Trivial promotion to unsigned. */ - if (k2.u32 == 0 || - (k->id == CTID_INT32 && k->u32 == 0x80000000u && k2.i32 == -1)) - cp_err(cp, LJ_ERR_BADVAL); - if (k->id == CTID_INT32) - k->i32 = k->i32 / k2.i32; - else - k->u32 = k->u32 / k2.u32; - continue; - } else if (cp_opt(cp, '%')) { - cp_expr_unary(cp, &k2); - if (k2.id > k->id) k->id = k2.id; /* Trivial promotion to unsigned. */ - if (k2.u32 == 0 || - (k->id == CTID_INT32 && k->u32 == 0x80000000u && k2.i32 == -1)) - cp_err(cp, LJ_ERR_BADVAL); - if (k->id == CTID_INT32) - k->i32 = k->i32 % k2.i32; - else - k->u32 = k->u32 % k2.u32; - continue; - } - default: - return; - } - } -} - -/* Parse and evaluate unary expression. */ -static void cp_expr_unary(CPState *cp, CPValue *k) -{ - if (++cp->depth > CPARSE_MAX_DECLDEPTH) cp_err(cp, LJ_ERR_XLEVELS); - cp_expr_prefix(cp, k); - cp_expr_postfix(cp, k); - cp->depth--; -} - -/* Parse and evaluate sub-expression. */ -static void cp_expr_sub(CPState *cp, CPValue *k, int pri) -{ - cp_expr_unary(cp, k); - cp_expr_infix(cp, k, pri); -} - -/* Parse constant integer expression. */ -static void cp_expr_kint(CPState *cp, CPValue *k) -{ - CType *ct; - cp_expr_sub(cp, k, 0); - ct = ctype_raw(cp->cts, k->id); - if (!ctype_isinteger(ct->info)) cp_err(cp, LJ_ERR_BADVAL); -} - -/* Parse (non-negative) size expression. */ -static CTSize cp_expr_ksize(CPState *cp) -{ - CPValue k; - cp_expr_kint(cp, &k); - if (k.u32 >= 0x80000000u) cp_err(cp, LJ_ERR_FFI_INVSIZE); - return k.u32; -} - -/* -- Type declaration stack management ----------------------------------- */ - -/* Add declaration element behind the insertion position. */ -static CPDeclIdx cp_add(CPDecl *decl, CTInfo info, CTSize size) -{ - CPDeclIdx top = decl->top; - if (top >= CPARSE_MAX_DECLSTACK) cp_err(decl->cp, LJ_ERR_XLEVELS); - decl->stack[top].info = info; - decl->stack[top].size = size; - decl->stack[top].sib = 0; - setgcrefnull(decl->stack[top].name); - decl->stack[top].next = decl->stack[decl->pos].next; - decl->stack[decl->pos].next = (CTypeID1)top; - decl->top = top+1; - return top; -} - -/* Push declaration element before the insertion position. */ -static CPDeclIdx cp_push(CPDecl *decl, CTInfo info, CTSize size) -{ - return (decl->pos = cp_add(decl, info, size)); -} - -/* Push or merge attributes. */ -static void cp_push_attributes(CPDecl *decl) -{ - CType *ct = &decl->stack[decl->pos]; - if (ctype_isfunc(ct->info)) { /* Ok to modify in-place. */ -#if LJ_TARGET_X86 - if ((decl->fattr & CTFP_CCONV)) - ct->info = (ct->info & (CTMASK_NUM|CTF_VARARG|CTMASK_CID)) + - (decl->fattr & ~CTMASK_CID); -#endif - } else { - if ((decl->attr & CTFP_ALIGNED) && !(decl->mode & CPARSE_MODE_FIELD)) - cp_push(decl, CTINFO(CT_ATTRIB, CTATTRIB(CTA_ALIGN)), - ctype_align(decl->attr)); - } -} - -/* Push unrolled type to declaration stack and merge qualifiers. */ -static void cp_push_type(CPDecl *decl, CTypeID id) -{ - CType *ct = ctype_get(decl->cp->cts, id); - CTInfo info = ct->info; - CTSize size = ct->size; - switch (ctype_type(info)) { - case CT_STRUCT: case CT_ENUM: - cp_push(decl, CTINFO(CT_TYPEDEF, id), 0); /* Don't copy unique types. */ - if ((decl->attr & CTF_QUAL)) { /* Push unmerged qualifiers. */ - cp_push(decl, CTINFO(CT_ATTRIB, CTATTRIB(CTA_QUAL)), - (decl->attr & CTF_QUAL)); - decl->attr &= ~CTF_QUAL; - } - break; - case CT_ATTRIB: - if (ctype_isxattrib(info, CTA_QUAL)) - decl->attr &= ~size; /* Remove redundant qualifiers. */ - cp_push_type(decl, ctype_cid(info)); /* Unroll. */ - cp_push(decl, info & ~CTMASK_CID, size); /* Copy type. */ - break; - case CT_ARRAY: - cp_push_type(decl, ctype_cid(info)); /* Unroll. */ - cp_push(decl, info & ~CTMASK_CID, size); /* Copy type. */ - decl->stack[decl->pos].sib = 1; /* Mark as already checked and sized. */ - /* Note: this is not copied to the ct->sib in the C type table. */ - break; - case CT_FUNC: - /* Copy type, link parameters (shared). */ - decl->stack[cp_push(decl, info, size)].sib = ct->sib; - break; - default: - /* Copy type, merge common qualifiers. */ - cp_push(decl, info|(decl->attr & CTF_QUAL), size); - decl->attr &= ~CTF_QUAL; - break; - } -} - -/* Consume the declaration element chain and intern the C type. */ -static CTypeID cp_decl_intern(CPState *cp, CPDecl *decl) -{ - CTypeID id = 0; - CPDeclIdx idx = 0; - CTSize csize = CTSIZE_INVALID; - CTSize cinfo = 0; - do { - CType *ct = &decl->stack[idx]; - CTInfo info = ct->info; - CTInfo size = ct->size; - /* The cid is already part of info for copies of pointers/functions. */ - idx = ct->next; - if (ctype_istypedef(info)) { - lua_assert(id == 0); - id = ctype_cid(info); - /* Always refetch info/size, since struct/enum may have been completed. */ - cinfo = ctype_get(cp->cts, id)->info; - csize = ctype_get(cp->cts, id)->size; - lua_assert(ctype_isstruct(cinfo) || ctype_isenum(cinfo)); - } else if (ctype_isfunc(info)) { /* Intern function. */ - CType *fct; - CTypeID fid; - CTypeID sib; - if (id) { - CType *refct = ctype_raw(cp->cts, id); - /* Reject function or refarray return types. */ - if (ctype_isfunc(refct->info) || ctype_isrefarray(refct->info)) - cp_err(cp, LJ_ERR_FFI_INVTYPE); - } - /* No intervening attributes allowed, skip forward. */ - while (idx) { - CType *ctn = &decl->stack[idx]; - if (!ctype_isattrib(ctn->info)) break; - idx = ctn->next; /* Skip attribute. */ - } - sib = ct->sib; /* Next line may reallocate the C type table. */ - fid = lj_ctype_new(cp->cts, &fct); - csize = CTSIZE_INVALID; - fct->info = cinfo = info + id; - fct->size = size; - fct->sib = sib; - id = fid; - } else if (ctype_isattrib(info)) { - if (ctype_isxattrib(info, CTA_QUAL)) - cinfo |= size; - else if (ctype_isxattrib(info, CTA_ALIGN)) - CTF_INSERT(cinfo, ALIGN, size); - id = lj_ctype_intern(cp->cts, info+id, size); - /* Inherit csize/cinfo from original type. */ - } else { - if (ctype_isnum(info)) { /* Handle mode/vector-size attributes. */ - lua_assert(id == 0); - if (!(info & CTF_BOOL)) { - CTSize msize = ctype_msizeP(decl->attr); - CTSize vsize = ctype_vsizeP(decl->attr); - if (msize && (!(info & CTF_FP) || (msize == 4 || msize == 8))) { - CTSize malign = lj_fls(msize); - if (malign > 4) malign = 4; /* Limit alignment. */ - CTF_INSERT(info, ALIGN, malign); - size = msize; /* Override size via mode. */ - } - if (vsize) { /* Vector size set? */ - CTSize esize = lj_fls(size); - if (vsize >= esize) { - /* Intern the element type first. */ - id = lj_ctype_intern(cp->cts, info, size); - /* Then create a vector (array) with vsize alignment. */ - size = (1u << vsize); - if (vsize > 4) vsize = 4; /* Limit alignment. */ - if (ctype_align(info) > vsize) vsize = ctype_align(info); - info = CTINFO(CT_ARRAY, (info & CTF_QUAL) + CTF_VECTOR + - CTALIGN(vsize)); - } - } - } - } else if (ctype_isptr(info)) { - /* Reject pointer/ref to ref. */ - if (id && ctype_isref(ctype_raw(cp->cts, id)->info)) - cp_err(cp, LJ_ERR_FFI_INVTYPE); - if (ctype_isref(info)) { - info &= ~CTF_VOLATILE; /* Refs are always const, never volatile. */ - /* No intervening attributes allowed, skip forward. */ - while (idx) { - CType *ctn = &decl->stack[idx]; - if (!ctype_isattrib(ctn->info)) break; - idx = ctn->next; /* Skip attribute. */ - } - } - } else if (ctype_isarray(info)) { /* Check for valid array size etc. */ - if (ct->sib == 0) { /* Only check/size arrays not copied by unroll. */ - if (ctype_isref(cinfo)) /* Reject arrays of refs. */ - cp_err(cp, LJ_ERR_FFI_INVTYPE); - /* Reject VLS or unknown-sized types. */ - if (ctype_isvltype(cinfo) || csize == CTSIZE_INVALID) - cp_err(cp, LJ_ERR_FFI_INVSIZE); - /* a[] and a[?] keep their invalid size. */ - if (size != CTSIZE_INVALID) { - uint64_t xsz = (uint64_t)size * csize; - if (xsz >= 0x80000000u) cp_err(cp, LJ_ERR_FFI_INVSIZE); - size = (CTSize)xsz; - } - } - if ((cinfo & CTF_ALIGN) > (info & CTF_ALIGN)) /* Find max. align. */ - info = (info & ~CTF_ALIGN) | (cinfo & CTF_ALIGN); - info |= (cinfo & CTF_QUAL); /* Inherit qual. */ - } else { - lua_assert(ctype_isvoid(info)); - } - csize = size; - cinfo = info+id; - id = lj_ctype_intern(cp->cts, info+id, size); - } - } while (idx); - return id; -} - -/* -- C declaration parser ------------------------------------------------ */ - -#define H_(le, be) LJ_ENDIAN_SELECT(0x##le, 0x##be) - -/* Reset declaration state to declaration specifier. */ -static void cp_decl_reset(CPDecl *decl) -{ - decl->pos = decl->specpos; - decl->top = decl->specpos+1; - decl->stack[decl->specpos].next = 0; - decl->attr = decl->specattr; - decl->fattr = decl->specfattr; - decl->name = NULL; - decl->redir = NULL; -} - -/* Parse constant initializer. */ -/* NYI: FP constants and strings as initializers. */ -static CTypeID cp_decl_constinit(CPState *cp, CType **ctp, CTypeID ctypeid) -{ - CType *ctt = ctype_get(cp->cts, ctypeid); - CTInfo info; - CTSize size; - CPValue k; - CTypeID constid; - while (ctype_isattrib(ctt->info)) { /* Skip attributes. */ - ctypeid = ctype_cid(ctt->info); /* Update ID, too. */ - ctt = ctype_get(cp->cts, ctypeid); - } - info = ctt->info; - size = ctt->size; - if (!ctype_isinteger(info) || !(info & CTF_CONST) || size > 4) - cp_err(cp, LJ_ERR_FFI_INVTYPE); - cp_check(cp, '='); - cp_expr_sub(cp, &k, 0); - constid = lj_ctype_new(cp->cts, ctp); - (*ctp)->info = CTINFO(CT_CONSTVAL, CTF_CONST|ctypeid); - k.u32 <<= 8*(4-size); - if ((info & CTF_UNSIGNED)) - k.u32 >>= 8*(4-size); - else - k.u32 = (uint32_t)((int32_t)k.u32 >> 8*(4-size)); - (*ctp)->size = k.u32; - return constid; -} - -/* Parse size in parentheses as part of attribute. */ -static CTSize cp_decl_sizeattr(CPState *cp) -{ - CTSize sz; - uint32_t oldtmask = cp->tmask; - cp->tmask = CPNS_DEFAULT; /* Required for expression evaluator. */ - cp_check(cp, '('); - sz = cp_expr_ksize(cp); - cp->tmask = oldtmask; - cp_check(cp, ')'); - return sz; -} - -/* Parse alignment attribute. */ -static void cp_decl_align(CPState *cp, CPDecl *decl) -{ - CTSize al = 4; /* Unspecified alignment is 16 bytes. */ - if (cp->tok == '(') { - al = cp_decl_sizeattr(cp); - al = al ? lj_fls(al) : 0; - } - CTF_INSERT(decl->attr, ALIGN, al); - decl->attr |= CTFP_ALIGNED; -} - -/* Parse GCC asm("name") redirect. */ -static void cp_decl_asm(CPState *cp, CPDecl *decl) -{ - UNUSED(decl); - cp_next(cp); - cp_check(cp, '('); - if (cp->tok == CTOK_STRING) { - GCstr *str = cp->str; - while (cp_next(cp) == CTOK_STRING) { - lj_str_pushf(cp->L, "%s%s", strdata(str), strdata(cp->str)); - cp->L->top--; - str = strV(cp->L->top); - } - decl->redir = str; - } - cp_check(cp, ')'); -} - -/* Parse GCC __attribute__((mode(...))). */ -static void cp_decl_mode(CPState *cp, CPDecl *decl) -{ - cp_check(cp, '('); - if (cp->tok == CTOK_IDENT) { - const char *s = strdata(cp->str); - CTSize sz = 0, vlen = 0; - if (s[0] == '_' && s[1] == '_') s += 2; - if (*s == 'V') { - s++; - vlen = *s++ - '0'; - if (*s >= '0' && *s <= '9') - vlen = vlen*10 + (*s++ - '0'); - } - switch (*s++) { - case 'Q': sz = 1; break; - case 'H': sz = 2; break; - case 'S': sz = 4; break; - case 'D': sz = 8; break; - case 'T': sz = 16; break; - case 'O': sz = 32; break; - default: goto bad_size; - } - if (*s == 'I' || *s == 'F') { - CTF_INSERT(decl->attr, MSIZEP, sz); - if (vlen) CTF_INSERT(decl->attr, VSIZEP, lj_fls(vlen*sz)); - } - bad_size: - cp_next(cp); - } - cp_check(cp, ')'); -} - -/* Parse GCC __attribute__((...)). */ -static void cp_decl_gccattribute(CPState *cp, CPDecl *decl) -{ - cp_next(cp); - cp_check(cp, '('); - cp_check(cp, '('); - while (cp->tok != ')') { - if (cp->tok == CTOK_IDENT) { - GCstr *attrstr = cp->str; - cp_next(cp); - switch (attrstr->hash) { - case H_(64a9208e,8ce14319): case H_(8e6331b2,95a282af): /* aligned */ - cp_decl_align(cp, decl); - break; - case H_(42eb47de,f0ede26c): case H_(29f48a09,cf383e0c): /* packed */ - decl->attr |= CTFP_PACKED; - break; - case H_(0a84eef6,8dfab04c): case H_(995cf92c,d5696591): /* mode */ - cp_decl_mode(cp, decl); - break; - case H_(0ab31997,2d5213fa): case H_(bf875611,200e9990): /* vector_size */ - { - CTSize vsize = cp_decl_sizeattr(cp); - if (vsize) CTF_INSERT(decl->attr, VSIZEP, lj_fls(vsize)); - } - break; -#if LJ_TARGET_X86 - case H_(5ad22db8,c689b848): case H_(439150fa,65ea78cb): /* regparm */ - CTF_INSERT(decl->fattr, REGPARM, cp_decl_sizeattr(cp)); - decl->fattr |= CTFP_CCONV; - break; - case H_(18fc0b98,7ff4c074): case H_(4e62abed,0a747424): /* cdecl */ - CTF_INSERT(decl->fattr, CCONV, CTCC_CDECL); - decl->fattr |= CTFP_CCONV; - break; - case H_(72b2e41b,494c5a44): case H_(f2356d59,f25fc9bd): /* thiscall */ - CTF_INSERT(decl->fattr, CCONV, CTCC_THISCALL); - decl->fattr |= CTFP_CCONV; - break; - case H_(0d0ffc42,ab746f88): case H_(21c54ba1,7f0ca7e3): /* fastcall */ - CTF_INSERT(decl->fattr, CCONV, CTCC_FASTCALL); - decl->fattr |= CTFP_CCONV; - break; - case H_(ef76b040,9412e06a): case H_(de56697b,c750e6e1): /* stdcall */ - CTF_INSERT(decl->fattr, CCONV, CTCC_STDCALL); - decl->fattr |= CTFP_CCONV; - break; - case H_(ea78b622,f234bd8e): case H_(252ffb06,8d50f34b): /* sseregparm */ - decl->fattr |= CTF_SSEREGPARM; - decl->fattr |= CTFP_CCONV; - break; -#endif - default: /* Skip all other attributes. */ - goto skip_attr; - } - } else if (cp->tok >= CTOK_FIRSTDECL) { /* For __attribute((const)) etc. */ - cp_next(cp); - skip_attr: - if (cp_opt(cp, '(')) { - while (cp->tok != ')' && cp->tok != CTOK_EOF) cp_next(cp); - cp_check(cp, ')'); - } - } else { - break; - } - if (!cp_opt(cp, ',')) break; - } - cp_check(cp, ')'); - cp_check(cp, ')'); -} - -/* Parse MSVC __declspec(...). */ -static void cp_decl_msvcattribute(CPState *cp, CPDecl *decl) -{ - cp_next(cp); - cp_check(cp, '('); - while (cp->tok == CTOK_IDENT) { - GCstr *attrstr = cp->str; - cp_next(cp); - switch (attrstr->hash) { - case H_(bc2395fa,98f267f8): /* align */ - cp_decl_align(cp, decl); - break; - default: /* Ignore all other attributes. */ - if (cp_opt(cp, '(')) { - while (cp->tok != ')' && cp->tok != CTOK_EOF) cp_next(cp); - cp_check(cp, ')'); - } - break; - } - } - cp_check(cp, ')'); -} - -/* Parse declaration attributes (and common qualifiers). */ -static void cp_decl_attributes(CPState *cp, CPDecl *decl) -{ - for (;;) { - switch (cp->tok) { - case CTOK_CONST: decl->attr |= CTF_CONST; break; - case CTOK_VOLATILE: decl->attr |= CTF_VOLATILE; break; - case CTOK_RESTRICT: break; /* Ignore. */ - case CTOK_EXTENSION: break; /* Ignore. */ - case CTOK_ATTRIBUTE: cp_decl_gccattribute(cp, decl); continue; - case CTOK_ASM: cp_decl_asm(cp, decl); continue; - case CTOK_DECLSPEC: cp_decl_msvcattribute(cp, decl); continue; - case CTOK_CCDECL: -#if LJ_TARGET_X86 - CTF_INSERT(decl->fattr, CCONV, cp->ct->size); - decl->fattr |= CTFP_CCONV; -#endif - break; - case CTOK_PTRSZ: -#if LJ_64 - CTF_INSERT(decl->attr, MSIZEP, cp->ct->size); -#endif - break; - default: return; - } - cp_next(cp); - } -} - -/* Parse struct/union/enum name. */ -static CTypeID cp_struct_name(CPState *cp, CPDecl *sdecl, CTInfo info) -{ - CTypeID sid; - CType *ct; - cp->tmask = CPNS_STRUCT; - cp_next(cp); - cp_decl_attributes(cp, sdecl); - cp->tmask = CPNS_DEFAULT; - if (cp->tok != '{') { - if (cp->tok != CTOK_IDENT) cp_err_token(cp, CTOK_IDENT); - if (cp->val.id) { /* Name of existing struct/union/enum. */ - sid = cp->val.id; - ct = cp->ct; - if ((ct->info ^ info) & (CTMASK_NUM|CTF_UNION)) /* Wrong type. */ - cp_errmsg(cp, 0, LJ_ERR_FFI_REDEF, strdata(gco2str(gcref(ct->name)))); - } else { /* Create named, incomplete struct/union/enum. */ - if ((cp->mode & CPARSE_MODE_NOIMPLICIT)) - cp_errmsg(cp, 0, LJ_ERR_FFI_BADTAG, strdata(cp->str)); - sid = lj_ctype_new(cp->cts, &ct); - ct->info = info; - ct->size = CTSIZE_INVALID; - ctype_setname(ct, cp->str); - lj_ctype_addname(cp->cts, ct, sid); - } - cp_next(cp); - } else { /* Create anonymous, incomplete struct/union/enum. */ - sid = lj_ctype_new(cp->cts, &ct); - ct->info = info; - ct->size = CTSIZE_INVALID; - } - if (cp->tok == '{') { - if (ct->size != CTSIZE_INVALID || ct->sib) - cp_errmsg(cp, 0, LJ_ERR_FFI_REDEF, strdata(gco2str(gcref(ct->name)))); - ct->sib = 1; /* Indicate the type is currently being defined. */ - } - return sid; -} - -/* Determine field alignment. */ -static CTSize cp_field_align(CPState *cp, CType *ct, CTInfo info) -{ - CTSize align = ctype_align(info); - UNUSED(cp); UNUSED(ct); -#if (LJ_TARGET_X86 && !LJ_ABI_WIN) || (LJ_TARGET_ARM && __APPLE__) - /* The SYSV i386 and iOS ABIs limit alignment of non-vector fields to 2^2. */ - if (align > 2 && !(info & CTFP_ALIGNED)) { - if (ctype_isarray(info) && !(info & CTF_VECTOR)) { - do { - ct = ctype_rawchild(cp->cts, ct); - info = ct->info; - } while (ctype_isarray(info) && !(info & CTF_VECTOR)); - } - if (ctype_isnum(info) || ctype_isenum(info)) - align = 2; - } -#endif - return align; -} - -/* Layout struct/union fields. */ -static void cp_struct_layout(CPState *cp, CTypeID sid, CTInfo sattr) -{ - CTSize bofs = 0, bmaxofs = 0; /* Bit offset and max. bit offset. */ - CTSize maxalign = ctype_align(sattr); - CType *sct = ctype_get(cp->cts, sid); - CTInfo sinfo = sct->info; - CTypeID fieldid = sct->sib; - while (fieldid) { - CType *ct = ctype_get(cp->cts, fieldid); - CTInfo attr = ct->size; /* Field declaration attributes (temp.). */ - - if (ctype_isfield(ct->info) || - (ctype_isxattrib(ct->info, CTA_SUBTYPE) && attr)) { - CTSize align, amask; /* Alignment (pow2) and alignment mask (bits). */ - CTSize sz; - CTInfo info = lj_ctype_info(cp->cts, ctype_cid(ct->info), &sz); - CTSize bsz, csz = 8*sz; /* Field size and container size (in bits). */ - sinfo |= (info & (CTF_QUAL|CTF_VLA)); /* Merge pseudo-qualifiers. */ - - /* Check for size overflow and determine alignment. */ - if (sz >= 0x20000000u || bofs + csz < bofs || (info & CTF_VLA)) { - if (!(sz == CTSIZE_INVALID && ctype_isarray(info) && - !(sinfo & CTF_UNION))) - cp_err(cp, LJ_ERR_FFI_INVSIZE); - csz = sz = 0; /* Treat a[] and a[?] as zero-sized. */ - } - align = cp_field_align(cp, ct, info); - if (((attr|sattr) & CTFP_PACKED) || - ((attr & CTFP_ALIGNED) && ctype_align(attr) > align)) - align = ctype_align(attr); - if (cp->packstack[cp->curpack] < align) - align = cp->packstack[cp->curpack]; - if (align > maxalign) maxalign = align; - amask = (8u << align) - 1; - - bsz = ctype_bitcsz(ct->info); /* Bitfield size (temp.). */ - if (bsz == CTBSZ_FIELD || !ctype_isfield(ct->info)) { - bsz = csz; /* Regular fields or subtypes always fill the container. */ - bofs = (bofs + amask) & ~amask; /* Start new aligned field. */ - ct->size = (bofs >> 3); /* Store field offset. */ - } else { /* Bitfield. */ - if (bsz == 0 || (attr & CTFP_ALIGNED) || - (!((attr|sattr) & CTFP_PACKED) && (bofs & amask) + bsz > csz)) - bofs = (bofs + amask) & ~amask; /* Start new aligned field. */ - - /* Prefer regular field over bitfield. */ - if (bsz == csz && (bofs & amask) == 0) { - ct->info = CTINFO(CT_FIELD, ctype_cid(ct->info)); - ct->size = (bofs >> 3); /* Store field offset. */ - } else { - ct->info = CTINFO(CT_BITFIELD, - (info & (CTF_QUAL|CTF_UNSIGNED|CTF_BOOL)) + - (csz << (CTSHIFT_BITCSZ-3)) + (bsz << CTSHIFT_BITBSZ)); -#if LJ_BE - ct->info += ((csz - (bofs & (csz-1)) - bsz) << CTSHIFT_BITPOS); -#else - ct->info += ((bofs & (csz-1)) << CTSHIFT_BITPOS); -#endif - ct->size = ((bofs & ~(csz-1)) >> 3); /* Store container offset. */ - } - } - - /* Determine next offset or max. offset. */ - if ((sinfo & CTF_UNION)) { - if (bsz > bmaxofs) bmaxofs = bsz; - } else { - bofs += bsz; - } - } /* All other fields in the chain are already set up. */ - - fieldid = ct->sib; - } - - /* Complete struct/union. */ - sct->info = sinfo + CTALIGN(maxalign); - bofs = (sinfo & CTF_UNION) ? bmaxofs : bofs; - maxalign = (8u << maxalign) - 1; - sct->size = (((bofs + maxalign) & ~maxalign) >> 3); -} - -/* Parse struct/union declaration. */ -static CTypeID cp_decl_struct(CPState *cp, CPDecl *sdecl, CTInfo sinfo) -{ - CTypeID sid = cp_struct_name(cp, sdecl, sinfo); - if (cp_opt(cp, '{')) { /* Struct/union definition. */ - CTypeID lastid = sid; - int lastdecl = 0; - while (cp->tok != '}') { - CPDecl decl; - CPscl scl = cp_decl_spec(cp, &decl, CDF_STATIC); - decl.mode = scl ? CPARSE_MODE_DIRECT : - CPARSE_MODE_DIRECT|CPARSE_MODE_ABSTRACT|CPARSE_MODE_FIELD; - - for (;;) { - CTypeID ctypeid; - - if (lastdecl) cp_err_token(cp, '}'); - - /* Parse field declarator. */ - decl.bits = CTSIZE_INVALID; - cp_declarator(cp, &decl); - ctypeid = cp_decl_intern(cp, &decl); - - if ((scl & CDF_STATIC)) { /* Static constant in struct namespace. */ - CType *ct; - CTypeID fieldid = cp_decl_constinit(cp, &ct, ctypeid); - ctype_get(cp->cts, lastid)->sib = fieldid; - lastid = fieldid; - ctype_setname(ct, decl.name); - } else { - CTSize bsz = CTBSZ_FIELD; /* Temp. for layout phase. */ - CType *ct; - CTypeID fieldid = lj_ctype_new(cp->cts, &ct); /* Do this first. */ - CType *tct = ctype_raw(cp->cts, ctypeid); - - if (decl.bits == CTSIZE_INVALID) { /* Regular field. */ - if (ctype_isarray(tct->info) && tct->size == CTSIZE_INVALID) - lastdecl = 1; /* a[] or a[?] must be the last declared field. */ - - /* Accept transparent struct/union/enum. */ - if (!decl.name) { - if (!((ctype_isstruct(tct->info) && !(tct->info & CTF_VLA)) || - ctype_isenum(tct->info))) - cp_err_token(cp, CTOK_IDENT); - ct->info = CTINFO(CT_ATTRIB, CTATTRIB(CTA_SUBTYPE) + ctypeid); - ct->size = ctype_isstruct(tct->info) ? - (decl.attr|0x80000000u) : 0; /* For layout phase. */ - goto add_field; - } - } else { /* Bitfield. */ - bsz = decl.bits; - if (!ctype_isinteger_or_bool(tct->info) || - (bsz == 0 && decl.name) || 8*tct->size > CTBSZ_MAX || - bsz > ((tct->info & CTF_BOOL) ? 1 : 8*tct->size)) - cp_errmsg(cp, ':', LJ_ERR_BADVAL); - } - - /* Create temporary field for layout phase. */ - ct->info = CTINFO(CT_FIELD, ctypeid + (bsz << CTSHIFT_BITCSZ)); - ct->size = decl.attr; - if (decl.name) ctype_setname(ct, decl.name); - - add_field: - ctype_get(cp->cts, lastid)->sib = fieldid; - lastid = fieldid; - } - if (!cp_opt(cp, ',')) break; - cp_decl_reset(&decl); - } - cp_check(cp, ';'); - } - cp_check(cp, '}'); - ctype_get(cp->cts, lastid)->sib = 0; /* Drop sib = 1 for empty structs. */ - cp_decl_attributes(cp, sdecl); /* Layout phase needs postfix attributes. */ - cp_struct_layout(cp, sid, sdecl->attr); - } - return sid; -} - -/* Parse enum declaration. */ -static CTypeID cp_decl_enum(CPState *cp, CPDecl *sdecl) -{ - CTypeID eid = cp_struct_name(cp, sdecl, CTINFO(CT_ENUM, CTID_VOID)); - CTInfo einfo = CTINFO(CT_ENUM, CTALIGN(2) + CTID_UINT32); - CTSize esize = 4; /* Only 32 bit enums are supported. */ - if (cp_opt(cp, '{')) { /* Enum definition. */ - CPValue k; - CTypeID lastid = eid; - k.u32 = 0; - k.id = CTID_INT32; - do { - GCstr *name = cp->str; - if (cp->tok != CTOK_IDENT) cp_err_token(cp, CTOK_IDENT); - if (cp->val.id) cp_errmsg(cp, 0, LJ_ERR_FFI_REDEF, strdata(name)); - cp_next(cp); - if (cp_opt(cp, '=')) { - cp_expr_kint(cp, &k); - if (k.id == CTID_UINT32) { - /* C99 says that enum constants are always (signed) integers. - ** But since unsigned constants like 0x80000000 are quite common, - ** those are left as uint32_t. - */ - if (k.i32 >= 0) k.id = CTID_INT32; - } else { - /* OTOH it's common practice and even mandated by some ABIs - ** that the enum type itself is unsigned, unless there are any - ** negative constants. - */ - k.id = CTID_INT32; - if (k.i32 < 0) einfo = CTINFO(CT_ENUM, CTALIGN(2) + CTID_INT32); - } - } - /* Add named enum constant. */ - { - CType *ct; - CTypeID constid = lj_ctype_new(cp->cts, &ct); - ctype_get(cp->cts, lastid)->sib = constid; - lastid = constid; - ctype_setname(ct, name); - ct->info = CTINFO(CT_CONSTVAL, CTF_CONST|k.id); - ct->size = k.u32++; - if (k.u32 == 0x80000000u) k.id = CTID_UINT32; - lj_ctype_addname(cp->cts, ct, constid); - } - if (!cp_opt(cp, ',')) break; - } while (cp->tok != '}'); /* Trailing ',' is ok. */ - cp_check(cp, '}'); - /* Complete enum. */ - ctype_get(cp->cts, eid)->info = einfo; - ctype_get(cp->cts, eid)->size = esize; - } - return eid; -} - -/* Parse declaration specifiers. */ -static CPscl cp_decl_spec(CPState *cp, CPDecl *decl, CPscl scl) -{ - uint32_t cds = 0, sz = 0; - CTypeID tdef = 0; - - decl->cp = cp; - decl->mode = cp->mode; - decl->name = NULL; - decl->redir = NULL; - decl->attr = 0; - decl->fattr = 0; - decl->pos = decl->top = 0; - decl->stack[0].next = 0; - - for (;;) { /* Parse basic types. */ - cp_decl_attributes(cp, decl); - if (cp->tok >= CTOK_FIRSTDECL && cp->tok <= CTOK_LASTDECLFLAG) { - uint32_t cbit; - if (cp->ct->size) { - if (sz) goto end_decl; - sz = cp->ct->size; - } - cbit = (1u << (cp->tok - CTOK_FIRSTDECL)); - cds = cds | cbit | ((cbit & cds & CDF_LONG) << 1); - if (cp->tok >= CTOK_FIRSTSCL) { - if (!(scl & cbit)) cp_errmsg(cp, cp->tok, LJ_ERR_FFI_BADSCL); - } else if (tdef) { - goto end_decl; - } - cp_next(cp); - continue; - } - if (sz || tdef || - (cds & (CDF_SHORT|CDF_LONG|CDF_SIGNED|CDF_UNSIGNED|CDF_COMPLEX))) - break; - switch (cp->tok) { - case CTOK_STRUCT: - tdef = cp_decl_struct(cp, decl, CTINFO(CT_STRUCT, 0)); - continue; - case CTOK_UNION: - tdef = cp_decl_struct(cp, decl, CTINFO(CT_STRUCT, CTF_UNION)); - continue; - case CTOK_ENUM: - tdef = cp_decl_enum(cp, decl); - continue; - case CTOK_IDENT: - if (ctype_istypedef(cp->ct->info)) { - tdef = ctype_cid(cp->ct->info); /* Get typedef. */ - cp_next(cp); - continue; - } - break; - case '$': - tdef = cp->val.id; - cp_next(cp); - continue; - default: - break; - } - break; - } -end_decl: - - if ((cds & CDF_COMPLEX)) /* Use predefined complex types. */ - tdef = sz == 4 ? CTID_COMPLEX_FLOAT : CTID_COMPLEX_DOUBLE; - - if (tdef) { - cp_push_type(decl, tdef); - } else if ((cds & CDF_VOID)) { - cp_push(decl, CTINFO(CT_VOID, (decl->attr & CTF_QUAL)), CTSIZE_INVALID); - decl->attr &= ~CTF_QUAL; - } else { - /* Determine type info and size. */ - CTInfo info = CTINFO(CT_NUM, (cds & CDF_UNSIGNED) ? CTF_UNSIGNED : 0); - if ((cds & CDF_BOOL)) { - if ((cds & ~(CDF_SCL|CDF_BOOL|CDF_INT|CDF_SIGNED|CDF_UNSIGNED))) - cp_errmsg(cp, 0, LJ_ERR_FFI_INVTYPE); - info |= CTF_BOOL; - if (!(cds & CDF_SIGNED)) info |= CTF_UNSIGNED; - if (!sz) { - sz = 1; - } - } else if ((cds & CDF_FP)) { - info = CTINFO(CT_NUM, CTF_FP); - if ((cds & CDF_LONG)) sz = sizeof(long double); - } else if ((cds & CDF_CHAR)) { - if ((cds & (CDF_CHAR|CDF_SIGNED|CDF_UNSIGNED)) == CDF_CHAR) - info |= CTF_UCHAR; /* Handle platforms where char is unsigned. */ - } else if ((cds & CDF_SHORT)) { - sz = sizeof(short); - } else if ((cds & CDF_LONGLONG)) { - sz = 8; - } else if ((cds & CDF_LONG)) { - info |= CTF_LONG; - sz = sizeof(long); - } else if (!sz) { - if (!(cds & (CDF_SIGNED|CDF_UNSIGNED))) - cp_errmsg(cp, cp->tok, LJ_ERR_FFI_DECLSPEC); - sz = sizeof(int); - } - lua_assert(sz != 0); - info += CTALIGN(lj_fls(sz)); /* Use natural alignment. */ - info += (decl->attr & CTF_QUAL); /* Merge qualifiers. */ - cp_push(decl, info, sz); - decl->attr &= ~CTF_QUAL; - } - decl->specpos = decl->pos; - decl->specattr = decl->attr; - decl->specfattr = decl->fattr; - return (cds & CDF_SCL); /* Return storage class. */ -} - -/* Parse array declaration. */ -static void cp_decl_array(CPState *cp, CPDecl *decl) -{ - CTInfo info = CTINFO(CT_ARRAY, 0); - CTSize nelem = CTSIZE_INVALID; /* Default size for a[] or a[?]. */ - cp_decl_attributes(cp, decl); - if (cp_opt(cp, '?')) - info |= CTF_VLA; /* Create variable-length array a[?]. */ - else if (cp->tok != ']') - nelem = cp_expr_ksize(cp); - cp_check(cp, ']'); - cp_add(decl, info, nelem); -} - -/* Parse function declaration. */ -static void cp_decl_func(CPState *cp, CPDecl *fdecl) -{ - CTSize nargs = 0; - CTInfo info = CTINFO(CT_FUNC, 0); - CTypeID lastid = 0, anchor = 0; - if (cp->tok != ')') { - do { - CPDecl decl; - CTypeID ctypeid, fieldid; - CType *ct; - if (cp_opt(cp, '.')) { /* Vararg function. */ - cp_check(cp, '.'); /* Workaround for the minimalistic lexer. */ - cp_check(cp, '.'); - info |= CTF_VARARG; - break; - } - cp_decl_spec(cp, &decl, CDF_REGISTER); - decl.mode = CPARSE_MODE_DIRECT|CPARSE_MODE_ABSTRACT; - cp_declarator(cp, &decl); - ctypeid = cp_decl_intern(cp, &decl); - ct = ctype_raw(cp->cts, ctypeid); - if (ctype_isvoid(ct->info)) - break; - else if (ctype_isrefarray(ct->info)) - ctypeid = lj_ctype_intern(cp->cts, - CTINFO(CT_PTR, CTALIGN_PTR|ctype_cid(ct->info)), CTSIZE_PTR); - else if (ctype_isfunc(ct->info)) - ctypeid = lj_ctype_intern(cp->cts, - CTINFO(CT_PTR, CTALIGN_PTR|ctypeid), CTSIZE_PTR); - /* Add new parameter. */ - fieldid = lj_ctype_new(cp->cts, &ct); - if (anchor) - ctype_get(cp->cts, lastid)->sib = fieldid; - else - anchor = fieldid; - lastid = fieldid; - if (decl.name) ctype_setname(ct, decl.name); - ct->info = CTINFO(CT_FIELD, ctypeid); - ct->size = nargs++; - } while (cp_opt(cp, ',')); - } - cp_check(cp, ')'); - if (cp_opt(cp, '{')) { /* Skip function definition. */ - int level = 1; - cp->mode |= CPARSE_MODE_SKIP; - for (;;) { - if (cp->tok == '{') level++; - else if (cp->tok == '}' && --level == 0) break; - else if (cp->tok == CTOK_EOF) cp_err_token(cp, '}'); - cp_next(cp); - } - cp->mode &= ~CPARSE_MODE_SKIP; - cp->tok = ';'; /* Ok for cp_decl_multi(), error in cp_decl_single(). */ - } - info |= (fdecl->fattr & ~CTMASK_CID); - fdecl->fattr = 0; - fdecl->stack[cp_add(fdecl, info, nargs)].sib = anchor; -} - -/* Parse declarator. */ -static void cp_declarator(CPState *cp, CPDecl *decl) -{ - if (++cp->depth > CPARSE_MAX_DECLDEPTH) cp_err(cp, LJ_ERR_XLEVELS); - - for (;;) { /* Head of declarator. */ - if (cp_opt(cp, '*')) { /* Pointer. */ - CTSize sz; - CTInfo info; - cp_decl_attributes(cp, decl); - sz = CTSIZE_PTR; - info = CTINFO(CT_PTR, CTALIGN_PTR); -#if LJ_64 - if (ctype_msizeP(decl->attr) == 4) { - sz = 4; - info = CTINFO(CT_PTR, CTALIGN(2)); - } -#endif - info += (decl->attr & (CTF_QUAL|CTF_REF)); - decl->attr &= ~(CTF_QUAL|(CTMASK_MSIZEP<attr &= ~(CTF_QUAL|(CTMASK_MSIZEP<mode & CPARSE_MODE_ABSTRACT) && - (cp->tok == ')' || cp_istypedecl(cp))) goto func_decl; - pos = decl->pos; - cp_declarator(cp, decl); - cp_check(cp, ')'); - decl->pos = pos; - } else if (cp->tok == CTOK_IDENT) { /* Direct declarator. */ - if (!(decl->mode & CPARSE_MODE_DIRECT)) cp_err_token(cp, CTOK_EOF); - decl->name = cp->str; - decl->nameid = cp->val.id; - cp_next(cp); - } else { /* Abstract declarator. */ - if (!(decl->mode & CPARSE_MODE_ABSTRACT)) cp_err_token(cp, CTOK_IDENT); - } - - for (;;) { /* Tail of declarator. */ - if (cp_opt(cp, '[')) { /* Array. */ - cp_decl_array(cp, decl); - } else if (cp_opt(cp, '(')) { /* Function. */ - func_decl: - cp_decl_func(cp, decl); - } else { - break; - } - } - - if ((decl->mode & CPARSE_MODE_FIELD) && cp_opt(cp, ':')) /* Field width. */ - decl->bits = cp_expr_ksize(cp); - - /* Process postfix attributes. */ - cp_decl_attributes(cp, decl); - cp_push_attributes(decl); - - cp->depth--; -} - -/* Parse an abstract type declaration and return it's C type ID. */ -static CTypeID cp_decl_abstract(CPState *cp) -{ - CPDecl decl; - cp_decl_spec(cp, &decl, 0); - decl.mode = CPARSE_MODE_ABSTRACT; - cp_declarator(cp, &decl); - return cp_decl_intern(cp, &decl); -} - -/* Handle pragmas. */ -static void cp_pragma(CPState *cp, BCLine pragmaline) -{ - cp_next(cp); - if (cp->tok == CTOK_IDENT && - cp->str->hash == H_(e79b999f,42ca3e85)) { /* pack */ - cp_next(cp); - cp_check(cp, '('); - if (cp->tok == CTOK_IDENT) { - if (cp->str->hash == H_(738e923c,a1b65954)) { /* push */ - if (cp->curpack < CPARSE_MAX_PACKSTACK) { - cp->packstack[cp->curpack+1] = cp->packstack[cp->curpack]; - cp->curpack++; - } - } else if (cp->str->hash == H_(6c71cf27,6c71cf27)) { /* pop */ - if (cp->curpack > 0) cp->curpack--; - } else { - cp_errmsg(cp, cp->tok, LJ_ERR_XSYMBOL); - } - cp_next(cp); - if (!cp_opt(cp, ',')) goto end_pack; - } - if (cp->tok == CTOK_INTEGER) { - cp->packstack[cp->curpack] = cp->val.u32 ? lj_fls(cp->val.u32) : 0; - cp_next(cp); - } else { - cp->packstack[cp->curpack] = 255; - } - end_pack: - cp_check(cp, ')'); - } else { /* Ignore all other pragmas. */ - while (cp->tok != CTOK_EOF && cp->linenumber == pragmaline) - cp_next(cp); - } -} - -/* Parse multiple C declarations of types or extern identifiers. */ -static void cp_decl_multi(CPState *cp) -{ - int first = 1; - while (cp->tok != CTOK_EOF) { - CPDecl decl; - CPscl scl; - if (cp_opt(cp, ';')) { /* Skip empty statements. */ - first = 0; - continue; - } - if (cp->tok == '#') { /* Workaround, since we have no preprocessor, yet. */ - BCLine pragmaline = cp->linenumber; - if (!(cp_next(cp) == CTOK_IDENT && - cp->str->hash == H_(f5e6b4f8,1d509107))) /* pragma */ - cp_errmsg(cp, cp->tok, LJ_ERR_XSYMBOL); - cp_pragma(cp, pragmaline); - continue; - } - scl = cp_decl_spec(cp, &decl, CDF_TYPEDEF|CDF_EXTERN|CDF_STATIC); - if ((cp->tok == ';' || cp->tok == CTOK_EOF) && - ctype_istypedef(decl.stack[0].info)) { - CTInfo info = ctype_rawchild(cp->cts, &decl.stack[0])->info; - if (ctype_isstruct(info) || ctype_isenum(info)) - goto decl_end; /* Accept empty declaration of struct/union/enum. */ - } - for (;;) { - CTypeID ctypeid; - cp_declarator(cp, &decl); - ctypeid = cp_decl_intern(cp, &decl); - if (decl.name && !decl.nameid) { /* NYI: redeclarations are ignored. */ - CType *ct; - CTypeID id; - if ((scl & CDF_TYPEDEF)) { /* Create new typedef. */ - id = lj_ctype_new(cp->cts, &ct); - ct->info = CTINFO(CT_TYPEDEF, ctypeid); - goto noredir; - } else if (ctype_isfunc(ctype_get(cp->cts, ctypeid)->info)) { - /* Treat both static and extern function declarations as extern. */ - ct = ctype_get(cp->cts, ctypeid); - /* We always get new anonymous functions (typedefs are copied). */ - lua_assert(gcref(ct->name) == NULL); - id = ctypeid; /* Just name it. */ - } else if ((scl & CDF_STATIC)) { /* Accept static constants. */ - id = cp_decl_constinit(cp, &ct, ctypeid); - goto noredir; - } else { /* External references have extern or no storage class. */ - id = lj_ctype_new(cp->cts, &ct); - ct->info = CTINFO(CT_EXTERN, ctypeid); - } - if (decl.redir) { /* Add attribute for redirected symbol name. */ - CType *cta; - CTypeID aid = lj_ctype_new(cp->cts, &cta); - ct = ctype_get(cp->cts, id); /* Table may have been reallocated. */ - cta->info = CTINFO(CT_ATTRIB, CTATTRIB(CTA_REDIR)); - cta->sib = ct->sib; - ct->sib = aid; - ctype_setname(cta, decl.redir); - } - noredir: - ctype_setname(ct, decl.name); - lj_ctype_addname(cp->cts, ct, id); - } - if (!cp_opt(cp, ',')) break; - cp_decl_reset(&decl); - } - decl_end: - if (cp->tok == CTOK_EOF && first) break; /* May omit ';' for 1 decl. */ - first = 0; - cp_check(cp, ';'); - } -} - -/* Parse a single C type declaration. */ -static void cp_decl_single(CPState *cp) -{ - CPDecl decl; - cp_decl_spec(cp, &decl, 0); - cp_declarator(cp, &decl); - cp->val.id = cp_decl_intern(cp, &decl); - if (cp->tok != CTOK_EOF) cp_err_token(cp, CTOK_EOF); -} - -#undef H_ - -/* ------------------------------------------------------------------------ */ - -/* Protected callback for C parser. */ -static TValue *cpcparser(lua_State *L, lua_CFunction dummy, void *ud) -{ - CPState *cp = (CPState *)ud; - UNUSED(dummy); - cframe_errfunc(L->cframe) = -1; /* Inherit error function. */ - cp_init(cp); - if ((cp->mode & CPARSE_MODE_MULTI)) - cp_decl_multi(cp); - else - cp_decl_single(cp); - if (cp->param && cp->param != cp->L->top) - cp_err(cp, LJ_ERR_FFI_NUMPARAM); - lua_assert(cp->depth == 0); - return NULL; -} - -/* C parser. */ -int lj_cparse(CPState *cp) -{ - LJ_CTYPE_SAVE(cp->cts); - int errcode = lj_vm_cpcall(cp->L, NULL, cp, cpcparser); - if (errcode) - LJ_CTYPE_RESTORE(cp->cts); - cp_cleanup(cp); - return errcode; -} - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_cparse.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_cparse.h deleted file mode 100644 index 586f49456..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_cparse.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -** C declaration parser. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_CPARSE_H -#define _LJ_CPARSE_H - -#include "lj_obj.h" -#include "lj_ctype.h" - -#if LJ_HASFFI - -/* C parser limits. */ -#define CPARSE_MAX_BUF 32768 /* Max. token buffer size. */ -#define CPARSE_MAX_DECLSTACK 100 /* Max. declaration stack depth. */ -#define CPARSE_MAX_DECLDEPTH 20 /* Max. recursive declaration depth. */ -#define CPARSE_MAX_PACKSTACK 7 /* Max. pack pragma stack depth. */ - -/* Flags for C parser mode. */ -#define CPARSE_MODE_MULTI 1 /* Process multiple declarations. */ -#define CPARSE_MODE_ABSTRACT 2 /* Accept abstract declarators. */ -#define CPARSE_MODE_DIRECT 4 /* Accept direct declarators. */ -#define CPARSE_MODE_FIELD 8 /* Accept field width in bits, too. */ -#define CPARSE_MODE_NOIMPLICIT 16 /* Reject implicit declarations. */ -#define CPARSE_MODE_SKIP 32 /* Skip definitions, ignore errors. */ - -typedef int CPChar; /* C parser character. Unsigned ext. from char. */ -typedef int CPToken; /* C parser token. */ - -/* C parser internal value representation. */ -typedef struct CPValue { - union { - int32_t i32; /* Value for CTID_INT32. */ - uint32_t u32; /* Value for CTID_UINT32. */ - }; - CTypeID id; /* C Type ID of the value. */ -} CPValue; - -/* C parser state. */ -typedef struct CPState { - CPChar c; /* Current character. */ - CPToken tok; /* Current token. */ - CPValue val; /* Token value. */ - GCstr *str; /* Interned string of identifier/keyword. */ - CType *ct; /* C type table entry. */ - const char *p; /* Current position in input buffer. */ - SBuf sb; /* String buffer for tokens. */ - lua_State *L; /* Lua state. */ - CTState *cts; /* C type state. */ - TValue *param; /* C type parameters. */ - const char *srcname; /* Current source name. */ - BCLine linenumber; /* Input line counter. */ - int depth; /* Recursive declaration depth. */ - uint32_t tmask; /* Type mask for next identifier. */ - uint32_t mode; /* C parser mode. */ - uint8_t packstack[CPARSE_MAX_PACKSTACK]; /* Stack for pack pragmas. */ - uint8_t curpack; /* Current position in pack pragma stack. */ -} CPState; - -LJ_FUNC int lj_cparse(CPState *cp); - -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_crecord.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_crecord.c deleted file mode 100644 index da9013f0c..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_crecord.c +++ /dev/null @@ -1,1653 +0,0 @@ -/* -** Trace recorder for C data operations. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_ffrecord_c -#define LUA_CORE - -#include "lj_obj.h" - -#if LJ_HASJIT && LJ_HASFFI - -#include "lj_err.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_frame.h" -#include "lj_ctype.h" -#include "lj_cdata.h" -#include "lj_cparse.h" -#include "lj_cconv.h" -#include "lj_clib.h" -#include "lj_ccall.h" -#include "lj_ff.h" -#include "lj_ir.h" -#include "lj_jit.h" -#include "lj_ircall.h" -#include "lj_iropt.h" -#include "lj_trace.h" -#include "lj_record.h" -#include "lj_ffrecord.h" -#include "lj_snap.h" -#include "lj_crecord.h" -#include "lj_dispatch.h" - -/* Some local macros to save typing. Undef'd at the end. */ -#define IR(ref) (&J->cur.ir[(ref)]) - -/* Pass IR on to next optimization in chain (FOLD). */ -#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) - -#define emitconv(a, dt, st, flags) \ - emitir(IRT(IR_CONV, (dt)), (a), (st)|((dt) << 5)|(flags)) - -/* -- C type checks ------------------------------------------------------- */ - -static GCcdata *argv2cdata(jit_State *J, TRef tr, cTValue *o) -{ - GCcdata *cd; - TRef trtypeid; - if (!tref_iscdata(tr)) - lj_trace_err(J, LJ_TRERR_BADTYPE); - cd = cdataV(o); - /* Specialize to the CTypeID. */ - trtypeid = emitir(IRT(IR_FLOAD, IRT_U16), tr, IRFL_CDATA_CTYPEID); - emitir(IRTG(IR_EQ, IRT_INT), trtypeid, lj_ir_kint(J, (int32_t)cd->ctypeid)); - return cd; -} - -/* Specialize to the CTypeID held by a cdata constructor. */ -static CTypeID crec_constructor(jit_State *J, GCcdata *cd, TRef tr) -{ - CTypeID id; - lua_assert(tref_iscdata(tr) && cd->ctypeid == CTID_CTYPEID); - id = *(CTypeID *)cdataptr(cd); - tr = emitir(IRT(IR_FLOAD, IRT_INT), tr, IRFL_CDATA_INT); - emitir(IRTG(IR_EQ, IRT_INT), tr, lj_ir_kint(J, (int32_t)id)); - return id; -} - -static CTypeID argv2ctype(jit_State *J, TRef tr, cTValue *o) -{ - if (tref_isstr(tr)) { - GCstr *s = strV(o); - CPState cp; - CTypeID oldtop; - /* Specialize to the string containing the C type declaration. */ - emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, s)); - cp.L = J->L; - cp.cts = ctype_ctsG(J2G(J)); - oldtop = cp.cts->top; - cp.srcname = strdata(s); - cp.p = strdata(s); - cp.param = NULL; - cp.mode = CPARSE_MODE_ABSTRACT|CPARSE_MODE_NOIMPLICIT; - if (lj_cparse(&cp) || cp.cts->top > oldtop) /* Avoid new struct defs. */ - lj_trace_err(J, LJ_TRERR_BADTYPE); - return cp.val.id; - } else { - GCcdata *cd = argv2cdata(J, tr, o); - return cd->ctypeid == CTID_CTYPEID ? crec_constructor(J, cd, tr) : - cd->ctypeid; - } -} - -/* Convert CType to IRType (if possible). */ -static IRType crec_ct2irt(CTState *cts, CType *ct) -{ - if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); - if (LJ_LIKELY(ctype_isnum(ct->info))) { - if ((ct->info & CTF_FP)) { - if (ct->size == sizeof(double)) - return IRT_NUM; - else if (ct->size == sizeof(float)) - return IRT_FLOAT; - } else { - uint32_t b = lj_fls(ct->size); - if (b <= 3) - return IRT_I8 + 2*b + ((ct->info & CTF_UNSIGNED) ? 1 : 0); - } - } else if (ctype_isptr(ct->info)) { - return (LJ_64 && ct->size == 8) ? IRT_P64 : IRT_P32; - } else if (ctype_iscomplex(ct->info)) { - if (ct->size == 2*sizeof(double)) - return IRT_NUM; - else if (ct->size == 2*sizeof(float)) - return IRT_FLOAT; - } - return IRT_CDATA; -} - -/* -- Optimized memory fill and copy -------------------------------------- */ - -/* Maximum length and unroll of inlined copy/fill. */ -#define CREC_COPY_MAXUNROLL 16 -#define CREC_COPY_MAXLEN 128 - -#define CREC_FILL_MAXUNROLL 16 - -/* Number of windowed registers used for optimized memory copy. */ -#if LJ_TARGET_X86 -#define CREC_COPY_REGWIN 2 -#elif LJ_TARGET_PPC || LJ_TARGET_MIPS -#define CREC_COPY_REGWIN 8 -#else -#define CREC_COPY_REGWIN 4 -#endif - -/* List of memory offsets for copy/fill. */ -typedef struct CRecMemList { - CTSize ofs; /* Offset in bytes. */ - IRType tp; /* Type of load/store. */ - TRef trofs; /* TRef of interned offset. */ - TRef trval; /* TRef of load value. */ -} CRecMemList; - -/* Generate copy list for element-wise struct copy. */ -static MSize crec_copy_struct(CRecMemList *ml, CTState *cts, CType *ct) -{ - CTypeID fid = ct->sib; - MSize mlp = 0; - while (fid) { - CType *df = ctype_get(cts, fid); - fid = df->sib; - if (ctype_isfield(df->info)) { - CType *cct; - IRType tp; - if (!gcref(df->name)) continue; /* Ignore unnamed fields. */ - cct = ctype_rawchild(cts, df); /* Field type. */ - tp = crec_ct2irt(cts, cct); - if (tp == IRT_CDATA) return 0; /* NYI: aggregates. */ - if (mlp >= CREC_COPY_MAXUNROLL) return 0; - ml[mlp].ofs = df->size; - ml[mlp].tp = tp; - mlp++; - if (ctype_iscomplex(cct->info)) { - if (mlp >= CREC_COPY_MAXUNROLL) return 0; - ml[mlp].ofs = df->size + (cct->size >> 1); - ml[mlp].tp = tp; - mlp++; - } - } else if (!ctype_isconstval(df->info)) { - /* NYI: bitfields and sub-structures. */ - return 0; - } - } - return mlp; -} - -/* Generate unrolled copy list, from highest to lowest step size/alignment. */ -static MSize crec_copy_unroll(CRecMemList *ml, CTSize len, CTSize step, - IRType tp) -{ - CTSize ofs = 0; - MSize mlp = 0; - if (tp == IRT_CDATA) tp = IRT_U8 + 2*lj_fls(step); - do { - while (ofs + step <= len) { - if (mlp >= CREC_COPY_MAXUNROLL) return 0; - ml[mlp].ofs = ofs; - ml[mlp].tp = tp; - mlp++; - ofs += step; - } - step >>= 1; - tp -= 2; - } while (ofs < len); - return mlp; -} - -/* -** Emit copy list with windowed loads/stores. -** LJ_TARGET_UNALIGNED: may emit unaligned loads/stores (not marked as such). -*/ -static void crec_copy_emit(jit_State *J, CRecMemList *ml, MSize mlp, - TRef trdst, TRef trsrc) -{ - MSize i, j, rwin = 0; - for (i = 0, j = 0; i < mlp; ) { - TRef trofs = lj_ir_kintp(J, ml[i].ofs); - TRef trsptr = emitir(IRT(IR_ADD, IRT_PTR), trsrc, trofs); - ml[i].trval = emitir(IRT(IR_XLOAD, ml[i].tp), trsptr, 0); - ml[i].trofs = trofs; - i++; - rwin += (LJ_SOFTFP && ml[i].tp == IRT_NUM) ? 2 : 1; - if (rwin >= CREC_COPY_REGWIN || i >= mlp) { /* Flush buffered stores. */ - rwin = 0; - for ( ; j < i; j++) { - TRef trdptr = emitir(IRT(IR_ADD, IRT_PTR), trdst, ml[j].trofs); - emitir(IRT(IR_XSTORE, ml[j].tp), trdptr, ml[j].trval); - } - } - } -} - -/* Optimized memory copy. */ -static void crec_copy(jit_State *J, TRef trdst, TRef trsrc, TRef trlen, - CType *ct) -{ - if (tref_isk(trlen)) { /* Length must be constant. */ - CRecMemList ml[CREC_COPY_MAXUNROLL]; - MSize mlp = 0; - CTSize step = 1, len = (CTSize)IR(tref_ref(trlen))->i; - IRType tp = IRT_CDATA; - int needxbar = 0; - if (len == 0) return; /* Shortcut. */ - if (len > CREC_COPY_MAXLEN) goto fallback; - if (ct) { - CTState *cts = ctype_ctsG(J2G(J)); - lua_assert(ctype_isarray(ct->info) || ctype_isstruct(ct->info)); - if (ctype_isarray(ct->info)) { - CType *cct = ctype_rawchild(cts, ct); - tp = crec_ct2irt(cts, cct); - if (tp == IRT_CDATA) goto rawcopy; - step = lj_ir_type_size[tp]; - lua_assert((len & (step-1)) == 0); - } else if ((ct->info & CTF_UNION)) { - step = (1u << ctype_align(ct->info)); - goto rawcopy; - } else { - mlp = crec_copy_struct(ml, cts, ct); - goto emitcopy; - } - } else { - rawcopy: - needxbar = 1; - if (LJ_TARGET_UNALIGNED || step >= CTSIZE_PTR) - step = CTSIZE_PTR; - } - mlp = crec_copy_unroll(ml, len, step, tp); - emitcopy: - if (mlp) { - crec_copy_emit(J, ml, mlp, trdst, trsrc); - if (needxbar) - emitir(IRT(IR_XBAR, IRT_NIL), 0, 0); - return; - } - } -fallback: - /* Call memcpy. Always needs a barrier to disable alias analysis. */ - lj_ir_call(J, IRCALL_memcpy, trdst, trsrc, trlen); - emitir(IRT(IR_XBAR, IRT_NIL), 0, 0); -} - -/* Generate unrolled fill list, from highest to lowest step size/alignment. */ -static MSize crec_fill_unroll(CRecMemList *ml, CTSize len, CTSize step) -{ - CTSize ofs = 0; - MSize mlp = 0; - IRType tp = IRT_U8 + 2*lj_fls(step); - do { - while (ofs + step <= len) { - if (mlp >= CREC_COPY_MAXUNROLL) return 0; - ml[mlp].ofs = ofs; - ml[mlp].tp = tp; - mlp++; - ofs += step; - } - step >>= 1; - tp -= 2; - } while (ofs < len); - return mlp; -} - -/* -** Emit stores for fill list. -** LJ_TARGET_UNALIGNED: may emit unaligned stores (not marked as such). -*/ -static void crec_fill_emit(jit_State *J, CRecMemList *ml, MSize mlp, - TRef trdst, TRef trfill) -{ - MSize i; - for (i = 0; i < mlp; i++) { - TRef trofs = lj_ir_kintp(J, ml[i].ofs); - TRef trdptr = emitir(IRT(IR_ADD, IRT_PTR), trdst, trofs); - emitir(IRT(IR_XSTORE, ml[i].tp), trdptr, trfill); - } -} - -/* Optimized memory fill. */ -static void crec_fill(jit_State *J, TRef trdst, TRef trlen, TRef trfill, - CTSize step) -{ - if (tref_isk(trlen)) { /* Length must be constant. */ - CRecMemList ml[CREC_FILL_MAXUNROLL]; - MSize mlp; - CTSize len = (CTSize)IR(tref_ref(trlen))->i; - if (len == 0) return; /* Shortcut. */ - if (LJ_TARGET_UNALIGNED || step >= CTSIZE_PTR) - step = CTSIZE_PTR; - if (step * CREC_FILL_MAXUNROLL < len) goto fallback; - mlp = crec_fill_unroll(ml, len, step); - if (!mlp) goto fallback; - if (tref_isk(trfill) || ml[0].tp != IRT_U8) - trfill = emitconv(trfill, IRT_INT, IRT_U8, 0); - if (ml[0].tp != IRT_U8) { /* Scatter U8 to U16/U32/U64. */ - if (CTSIZE_PTR == 8 && ml[0].tp == IRT_U64) { - if (tref_isk(trfill)) /* Pointless on x64 with zero-extended regs. */ - trfill = emitconv(trfill, IRT_U64, IRT_U32, 0); - trfill = emitir(IRT(IR_MUL, IRT_U64), trfill, - lj_ir_kint64(J, U64x(01010101,01010101))); - } else { - trfill = emitir(IRTI(IR_MUL), trfill, - lj_ir_kint(J, ml[0].tp == IRT_U16 ? 0x0101 : 0x01010101)); - } - } - crec_fill_emit(J, ml, mlp, trdst, trfill); - } else { -fallback: - /* Call memset. Always needs a barrier to disable alias analysis. */ - lj_ir_call(J, IRCALL_memset, trdst, trfill, trlen); /* Note: arg order! */ - } - emitir(IRT(IR_XBAR, IRT_NIL), 0, 0); -} - -/* -- Convert C type to C type -------------------------------------------- */ - -/* -** This code mirrors the code in lj_cconv.c. It performs the same steps -** for the trace recorder that lj_cconv.c does for the interpreter. -** -** One major difference is that we can get away with much fewer checks -** here. E.g. checks for casts, constness or correct types can often be -** omitted, even if they might fail. The interpreter subsequently throws -** an error, which aborts the trace. -** -** All operations are specialized to their C types, so the on-trace -** outcome must be the same as the outcome in the interpreter. If the -** interpreter doesn't throw an error, then the trace is correct, too. -** Care must be taken not to generate invalid (temporary) IR or to -** trigger asserts. -*/ - -/* Determine whether a passed number or cdata number is non-zero. */ -static int crec_isnonzero(CType *s, void *p) -{ - if (p == (void *)0) - return 0; - if (p == (void *)1) - return 1; - if ((s->info & CTF_FP)) { - if (s->size == sizeof(float)) - return (*(float *)p != 0); - else - return (*(double *)p != 0); - } else { - if (s->size == 1) - return (*(uint8_t *)p != 0); - else if (s->size == 2) - return (*(uint16_t *)p != 0); - else if (s->size == 4) - return (*(uint32_t *)p != 0); - else - return (*(uint64_t *)p != 0); - } -} - -static TRef crec_ct_ct(jit_State *J, CType *d, CType *s, TRef dp, TRef sp, - void *svisnz) -{ - IRType dt = crec_ct2irt(ctype_ctsG(J2G(J)), d); - IRType st = crec_ct2irt(ctype_ctsG(J2G(J)), s); - CTSize dsize = d->size, ssize = s->size; - CTInfo dinfo = d->info, sinfo = s->info; - - if (ctype_type(dinfo) > CT_MAYCONVERT || ctype_type(sinfo) > CT_MAYCONVERT) - goto err_conv; - - /* - ** Note: Unlike lj_cconv_ct_ct(), sp holds the _value_ of pointers and - ** numbers up to 8 bytes. Otherwise sp holds a pointer. - */ - - switch (cconv_idx2(dinfo, sinfo)) { - /* Destination is a bool. */ - case CCX(B, B): - goto xstore; /* Source operand is already normalized. */ - case CCX(B, I): - case CCX(B, F): - if (st != IRT_CDATA) { - /* Specialize to the result of a comparison against 0. */ - TRef zero = (st == IRT_NUM || st == IRT_FLOAT) ? lj_ir_knum(J, 0) : - (st == IRT_I64 || st == IRT_U64) ? lj_ir_kint64(J, 0) : - lj_ir_kint(J, 0); - int isnz = crec_isnonzero(s, svisnz); - emitir(IRTG(isnz ? IR_NE : IR_EQ, st), sp, zero); - sp = lj_ir_kint(J, isnz); - goto xstore; - } - goto err_nyi; - - /* Destination is an integer. */ - case CCX(I, B): - case CCX(I, I): - conv_I_I: - if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; - /* Extend 32 to 64 bit integer. */ - if (dsize == 8 && ssize < 8 && !(LJ_64 && (sinfo & CTF_UNSIGNED))) - sp = emitconv(sp, dt, ssize < 4 ? IRT_INT : st, - (sinfo & CTF_UNSIGNED) ? 0 : IRCONV_SEXT); - else if (dsize < 8 && ssize == 8) /* Truncate from 64 bit integer. */ - sp = emitconv(sp, dsize < 4 ? IRT_INT : dt, st, 0); - else if (st == IRT_INT) - sp = lj_opt_narrow_toint(J, sp); - xstore: - if (dt == IRT_I64 || dt == IRT_U64) lj_needsplit(J); - if (dp == 0) return sp; - emitir(IRT(IR_XSTORE, dt), dp, sp); - break; - case CCX(I, C): - sp = emitir(IRT(IR_XLOAD, st), sp, 0); /* Load re. */ - /* fallthrough */ - case CCX(I, F): - if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; - sp = emitconv(sp, dsize < 4 ? IRT_INT : dt, st, IRCONV_TRUNC|IRCONV_ANY); - goto xstore; - case CCX(I, P): - case CCX(I, A): - sinfo = CTINFO(CT_NUM, CTF_UNSIGNED); - ssize = CTSIZE_PTR; - st = IRT_UINTP; - if (((dsize ^ ssize) & 8) == 0) { /* Must insert no-op type conversion. */ - sp = emitconv(sp, dsize < 4 ? IRT_INT : dt, IRT_PTR, 0); - goto xstore; - } - goto conv_I_I; - - /* Destination is a floating-point number. */ - case CCX(F, B): - case CCX(F, I): - conv_F_I: - if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; - sp = emitconv(sp, dt, ssize < 4 ? IRT_INT : st, 0); - goto xstore; - case CCX(F, C): - sp = emitir(IRT(IR_XLOAD, st), sp, 0); /* Load re. */ - /* fallthrough */ - case CCX(F, F): - conv_F_F: - if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; - if (dt != st) sp = emitconv(sp, dt, st, 0); - goto xstore; - - /* Destination is a complex number. */ - case CCX(C, I): - case CCX(C, F): - { /* Clear im. */ - TRef ptr = emitir(IRT(IR_ADD, IRT_PTR), dp, lj_ir_kintp(J, (dsize >> 1))); - emitir(IRT(IR_XSTORE, dt), ptr, lj_ir_knum(J, 0)); - } - /* Convert to re. */ - if ((sinfo & CTF_FP)) goto conv_F_F; else goto conv_F_I; - - case CCX(C, C): - if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; - { - TRef re, im, ptr; - re = emitir(IRT(IR_XLOAD, st), sp, 0); - ptr = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, (ssize >> 1))); - im = emitir(IRT(IR_XLOAD, st), ptr, 0); - if (dt != st) { - re = emitconv(re, dt, st, 0); - im = emitconv(im, dt, st, 0); - } - emitir(IRT(IR_XSTORE, dt), dp, re); - ptr = emitir(IRT(IR_ADD, IRT_PTR), dp, lj_ir_kintp(J, (dsize >> 1))); - emitir(IRT(IR_XSTORE, dt), ptr, im); - } - break; - - /* Destination is a vector. */ - case CCX(V, I): - case CCX(V, F): - case CCX(V, C): - case CCX(V, V): - goto err_nyi; - - /* Destination is a pointer. */ - case CCX(P, P): - case CCX(P, A): - case CCX(P, S): - /* There are only 32 bit pointers/addresses on 32 bit machines. - ** Also ok on x64, since all 32 bit ops clear the upper part of the reg. - */ - goto xstore; - case CCX(P, I): - if (st == IRT_CDATA) goto err_nyi; - if (!LJ_64 && ssize == 8) /* Truncate from 64 bit integer. */ - sp = emitconv(sp, IRT_U32, st, 0); - goto xstore; - case CCX(P, F): - if (st == IRT_CDATA) goto err_nyi; - /* The signed conversion is cheaper. x64 really has 47 bit pointers. */ - sp = emitconv(sp, (LJ_64 && dsize == 8) ? IRT_I64 : IRT_U32, - st, IRCONV_TRUNC|IRCONV_ANY); - goto xstore; - - /* Destination is an array. */ - case CCX(A, A): - /* Destination is a struct/union. */ - case CCX(S, S): - if (dp == 0) goto err_conv; - crec_copy(J, dp, sp, lj_ir_kint(J, dsize), d); - break; - - default: - err_conv: - err_nyi: - lj_trace_err(J, LJ_TRERR_NYICONV); - break; - } - return 0; -} - -/* -- Convert C type to TValue (load) ------------------------------------- */ - -static TRef crec_tv_ct(jit_State *J, CType *s, CTypeID sid, TRef sp) -{ - CTState *cts = ctype_ctsG(J2G(J)); - IRType t = crec_ct2irt(cts, s); - CTInfo sinfo = s->info; - if (ctype_isnum(sinfo)) { - TRef tr; - if (t == IRT_CDATA) - goto err_nyi; /* NYI: copyval of >64 bit integers. */ - tr = emitir(IRT(IR_XLOAD, t), sp, 0); - if (t == IRT_FLOAT || t == IRT_U32) { /* Keep uint32_t/float as numbers. */ - return emitconv(tr, IRT_NUM, t, 0); - } else if (t == IRT_I64 || t == IRT_U64) { /* Box 64 bit integer. */ - sp = tr; - lj_needsplit(J); - } else if ((sinfo & CTF_BOOL)) { - /* Assume not equal to zero. Fixup and emit pending guard later. */ - lj_ir_set(J, IRTGI(IR_NE), tr, lj_ir_kint(J, 0)); - J->postproc = LJ_POST_FIXGUARD; - return TREF_TRUE; - } else { - return tr; - } - } else if (ctype_isptr(sinfo) || ctype_isenum(sinfo)) { - sp = emitir(IRT(IR_XLOAD, t), sp, 0); /* Box pointers and enums. */ - } else if (ctype_isrefarray(sinfo) || ctype_isstruct(sinfo)) { - cts->L = J->L; - sid = lj_ctype_intern(cts, CTINFO_REF(sid), CTSIZE_PTR); /* Create ref. */ - } else if (ctype_iscomplex(sinfo)) { /* Unbox/box complex. */ - ptrdiff_t esz = (ptrdiff_t)(s->size >> 1); - TRef ptr, tr1, tr2, dp; - dp = emitir(IRTG(IR_CNEW, IRT_CDATA), lj_ir_kint(J, sid), TREF_NIL); - tr1 = emitir(IRT(IR_XLOAD, t), sp, 0); - ptr = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, esz)); - tr2 = emitir(IRT(IR_XLOAD, t), ptr, 0); - ptr = emitir(IRT(IR_ADD, IRT_PTR), dp, lj_ir_kintp(J, sizeof(GCcdata))); - emitir(IRT(IR_XSTORE, t), ptr, tr1); - ptr = emitir(IRT(IR_ADD, IRT_PTR), dp, lj_ir_kintp(J, sizeof(GCcdata)+esz)); - emitir(IRT(IR_XSTORE, t), ptr, tr2); - return dp; - } else { - /* NYI: copyval of vectors. */ - err_nyi: - lj_trace_err(J, LJ_TRERR_NYICONV); - } - /* Box pointer, ref, enum or 64 bit integer. */ - return emitir(IRTG(IR_CNEWI, IRT_CDATA), lj_ir_kint(J, sid), sp); -} - -/* -- Convert TValue to C type (store) ------------------------------------ */ - -static TRef crec_ct_tv(jit_State *J, CType *d, TRef dp, TRef sp, cTValue *sval) -{ - CTState *cts = ctype_ctsG(J2G(J)); - CTypeID sid = CTID_P_VOID; - void *svisnz = 0; - CType *s; - if (LJ_LIKELY(tref_isinteger(sp))) { - sid = CTID_INT32; - svisnz = (void *)(intptr_t)(tvisint(sval)?(intV(sval)!=0):!tviszero(sval)); - } else if (tref_isnum(sp)) { - sid = CTID_DOUBLE; - svisnz = (void *)(intptr_t)(tvisint(sval)?(intV(sval)!=0):!tviszero(sval)); - } else if (tref_isbool(sp)) { - sp = lj_ir_kint(J, tref_istrue(sp) ? 1 : 0); - sid = CTID_BOOL; - } else if (tref_isnil(sp)) { - sp = lj_ir_kptr(J, NULL); - } else if (tref_isudata(sp)) { - GCudata *ud = udataV(sval); - if (ud->udtype == UDTYPE_IO_FILE) { - TRef tr = emitir(IRT(IR_FLOAD, IRT_U8), sp, IRFL_UDATA_UDTYPE); - emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, UDTYPE_IO_FILE)); - sp = emitir(IRT(IR_FLOAD, IRT_PTR), sp, IRFL_UDATA_FILE); - } else { - sp = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, sizeof(GCudata))); - } - } else if (tref_isstr(sp)) { - if (ctype_isenum(d->info)) { /* Match string against enum constant. */ - GCstr *str = strV(sval); - CTSize ofs; - CType *cct = lj_ctype_getfield(cts, d, str, &ofs); - /* Specialize to the name of the enum constant. */ - emitir(IRTG(IR_EQ, IRT_STR), sp, lj_ir_kstr(J, str)); - if (cct && ctype_isconstval(cct->info)) { - lua_assert(ctype_child(cts, cct)->size == 4); - svisnz = (void *)(intptr_t)(ofs != 0); - sp = lj_ir_kint(J, (int32_t)ofs); - sid = ctype_cid(cct->info); - } /* else: interpreter will throw. */ - } else if (ctype_isrefarray(d->info)) { /* Copy string to array. */ - lj_trace_err(J, LJ_TRERR_BADTYPE); /* NYI */ - } else { /* Otherwise pass the string data as a const char[]. */ - /* Don't use STRREF. It folds with SNEW, which loses the trailing NUL. */ - sp = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, sizeof(GCstr))); - sid = CTID_A_CCHAR; - } - } else { /* NYI: tref_istab(sp), tref_islightud(sp). */ - IRType t; - sid = argv2cdata(J, sp, sval)->ctypeid; - s = ctype_raw(cts, sid); - svisnz = cdataptr(cdataV(sval)); - t = crec_ct2irt(cts, s); - if (ctype_isptr(s->info)) { - sp = emitir(IRT(IR_FLOAD, t), sp, IRFL_CDATA_PTR); - if (ctype_isref(s->info)) { - svisnz = *(void **)svisnz; - s = ctype_rawchild(cts, s); - if (ctype_isenum(s->info)) s = ctype_child(cts, s); - t = crec_ct2irt(cts, s); - } else { - goto doconv; - } - } else if (t == IRT_I64 || t == IRT_U64) { - sp = emitir(IRT(IR_FLOAD, t), sp, IRFL_CDATA_INT64); - lj_needsplit(J); - goto doconv; - } else if (t == IRT_INT || t == IRT_U32) { - if (ctype_isenum(s->info)) s = ctype_child(cts, s); - sp = emitir(IRT(IR_FLOAD, t), sp, IRFL_CDATA_INT); - goto doconv; - } else { - sp = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, sizeof(GCcdata))); - } - if (ctype_isnum(s->info) && t != IRT_CDATA) - sp = emitir(IRT(IR_XLOAD, t), sp, 0); /* Load number value. */ - goto doconv; - } - s = ctype_get(cts, sid); -doconv: - if (ctype_isenum(d->info)) d = ctype_child(cts, d); - return crec_ct_ct(J, d, s, dp, sp, svisnz); -} - -/* -- C data metamethods -------------------------------------------------- */ - -/* This would be rather difficult in FOLD, so do it here: -** (base+k)+(idx*sz)+ofs ==> (base+idx*sz)+(ofs+k) -** (base+(idx+k)*sz)+ofs ==> (base+idx*sz)+(ofs+k*sz) -*/ -static TRef crec_reassoc_ofs(jit_State *J, TRef tr, ptrdiff_t *ofsp, MSize sz) -{ - IRIns *ir = IR(tref_ref(tr)); - if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && irref_isk(ir->op2) && - (ir->o == IR_ADD || ir->o == IR_ADDOV || ir->o == IR_SUBOV)) { - IRIns *irk = IR(ir->op2); - ptrdiff_t k; - if (LJ_64 && irk->o == IR_KINT64) - k = (ptrdiff_t)ir_kint64(irk)->u64 * sz; - else - k = (ptrdiff_t)irk->i * sz; - if (ir->o == IR_SUBOV) *ofsp -= k; else *ofsp += k; - tr = ir->op1; /* Not a TRef, but the caller doesn't care. */ - } - return tr; -} - -/* Record ctype __index/__newindex metamethods. */ -static void crec_index_meta(jit_State *J, CTState *cts, CType *ct, - RecordFFData *rd) -{ - CTypeID id = ctype_typeid(cts, ct); - cTValue *tv = lj_ctype_meta(cts, id, rd->data ? MM_newindex : MM_index); - if (!tv) - lj_trace_err(J, LJ_TRERR_BADTYPE); - if (tvisfunc(tv)) { - J->base[-1] = lj_ir_kfunc(J, funcV(tv)) | TREF_FRAME; - rd->nres = -1; /* Pending tailcall. */ - } else if (rd->data == 0 && tvistab(tv) && tref_isstr(J->base[1])) { - /* Specialize to result of __index lookup. */ - cTValue *o = lj_tab_get(J->L, tabV(tv), &rd->argv[1]); - J->base[0] = lj_record_constify(J, o); - if (!J->base[0]) - lj_trace_err(J, LJ_TRERR_BADTYPE); - /* Always specialize to the key. */ - emitir(IRTG(IR_EQ, IRT_STR), J->base[1], lj_ir_kstr(J, strV(&rd->argv[1]))); - } else { - /* NYI: resolving of non-function metamethods. */ - /* NYI: non-string keys for __index table. */ - /* NYI: stores to __newindex table. */ - lj_trace_err(J, LJ_TRERR_BADTYPE); - } -} - -void LJ_FASTCALL recff_cdata_index(jit_State *J, RecordFFData *rd) -{ - TRef idx, ptr = J->base[0]; - ptrdiff_t ofs = sizeof(GCcdata); - GCcdata *cd = argv2cdata(J, ptr, &rd->argv[0]); - CTState *cts = ctype_ctsG(J2G(J)); - CType *ct = ctype_raw(cts, cd->ctypeid); - CTypeID sid = 0; - - /* Resolve pointer or reference for cdata object. */ - if (ctype_isptr(ct->info)) { - IRType t = (LJ_64 && ct->size == 8) ? IRT_P64 : IRT_P32; - if (ctype_isref(ct->info)) ct = ctype_rawchild(cts, ct); - ptr = emitir(IRT(IR_FLOAD, t), ptr, IRFL_CDATA_PTR); - ofs = 0; - ptr = crec_reassoc_ofs(J, ptr, &ofs, 1); - } - -again: - idx = J->base[1]; - if (tref_isnumber(idx)) { - idx = lj_opt_narrow_cindex(J, idx); - if (ctype_ispointer(ct->info)) { - CTSize sz; - integer_key: - if ((ct->info & CTF_COMPLEX)) - idx = emitir(IRT(IR_BAND, IRT_INTP), idx, lj_ir_kintp(J, 1)); - sz = lj_ctype_size(cts, (sid = ctype_cid(ct->info))); - idx = crec_reassoc_ofs(J, idx, &ofs, sz); -#if LJ_TARGET_ARM || LJ_TARGET_PPC - /* Hoist base add to allow fusion of index/shift into operands. */ - if (LJ_LIKELY(J->flags & JIT_F_OPT_LOOP) && ofs -#if LJ_TARGET_ARM - && (sz == 1 || sz == 4) -#endif - ) { - ptr = emitir(IRT(IR_ADD, IRT_PTR), ptr, lj_ir_kintp(J, ofs)); - ofs = 0; - } -#endif - idx = emitir(IRT(IR_MUL, IRT_INTP), idx, lj_ir_kintp(J, sz)); - ptr = emitir(IRT(IR_ADD, IRT_PTR), idx, ptr); - } - } else if (tref_iscdata(idx)) { - GCcdata *cdk = cdataV(&rd->argv[1]); - CType *ctk = ctype_raw(cts, cdk->ctypeid); - IRType t = crec_ct2irt(cts, ctk); - if (ctype_ispointer(ct->info) && t >= IRT_I8 && t <= IRT_U64) { - if (ctk->size == 8) { - idx = emitir(IRT(IR_FLOAD, t), idx, IRFL_CDATA_INT64); - } else if (ctk->size == 4) { - idx = emitir(IRT(IR_FLOAD, t), idx, IRFL_CDATA_INT); - } else { - idx = emitir(IRT(IR_ADD, IRT_PTR), idx, - lj_ir_kintp(J, sizeof(GCcdata))); - idx = emitir(IRT(IR_XLOAD, t), idx, 0); - } - if (LJ_64 && ctk->size < sizeof(intptr_t) && !(ctk->info & CTF_UNSIGNED)) - idx = emitconv(idx, IRT_INTP, IRT_INT, IRCONV_SEXT); - if (!LJ_64 && ctk->size > sizeof(intptr_t)) { - idx = emitconv(idx, IRT_INTP, t, 0); - lj_needsplit(J); - } - goto integer_key; - } - } else if (tref_isstr(idx)) { - GCstr *name = strV(&rd->argv[1]); - if (cd->ctypeid == CTID_CTYPEID) - ct = ctype_raw(cts, crec_constructor(J, cd, ptr)); - if (ctype_isstruct(ct->info)) { - CTSize fofs; - CType *fct; - fct = lj_ctype_getfield(cts, ct, name, &fofs); - if (fct) { - /* Always specialize to the field name. */ - emitir(IRTG(IR_EQ, IRT_STR), idx, lj_ir_kstr(J, name)); - if (ctype_isconstval(fct->info)) { - if (fct->size >= 0x80000000u && - (ctype_child(cts, fct)->info & CTF_UNSIGNED)) { - J->base[0] = lj_ir_knum(J, (lua_Number)(uint32_t)fct->size); - return; - } - J->base[0] = lj_ir_kint(J, (int32_t)fct->size); - return; /* Interpreter will throw for newindex. */ - } else if (ctype_isbitfield(fct->info)) { - lj_trace_err(J, LJ_TRERR_NYICONV); - } else { - lua_assert(ctype_isfield(fct->info)); - sid = ctype_cid(fct->info); - } - ofs += (ptrdiff_t)fofs; - } - } else if (ctype_iscomplex(ct->info)) { - if (name->len == 2 && - ((strdata(name)[0] == 'r' && strdata(name)[1] == 'e') || - (strdata(name)[0] == 'i' && strdata(name)[1] == 'm'))) { - /* Always specialize to the field name. */ - emitir(IRTG(IR_EQ, IRT_STR), idx, lj_ir_kstr(J, name)); - if (strdata(name)[0] == 'i') ofs += (ct->size >> 1); - sid = ctype_cid(ct->info); - } - } - } - if (!sid) { - if (ctype_isptr(ct->info)) { /* Automatically perform '->'. */ - CType *cct = ctype_rawchild(cts, ct); - if (ctype_isstruct(cct->info)) { - ct = cct; - if (tref_isstr(idx)) goto again; - } - } - crec_index_meta(J, cts, ct, rd); - return; - } - - if (ofs) - ptr = emitir(IRT(IR_ADD, IRT_PTR), ptr, lj_ir_kintp(J, ofs)); - - /* Resolve reference for field. */ - ct = ctype_get(cts, sid); - if (ctype_isref(ct->info)) - ptr = emitir(IRT(IR_XLOAD, IRT_PTR), ptr, 0); - - while (ctype_isattrib(ct->info)) - ct = ctype_child(cts, ct); /* Skip attributes. */ - - if (rd->data == 0) { /* __index metamethod. */ - J->base[0] = crec_tv_ct(J, ct, sid, ptr); - } else { /* __newindex metamethod. */ - rd->nres = 0; - J->needsnap = 1; - crec_ct_tv(J, ct, ptr, J->base[2], &rd->argv[2]); - } -} - -/* Record setting a finalizer. */ -static void crec_finalizer(jit_State *J, TRef trcd, cTValue *fin) -{ - TRef trlo = lj_ir_call(J, IRCALL_lj_cdata_setfin, trcd); - TRef trhi = emitir(IRT(IR_ADD, IRT_P32), trlo, lj_ir_kint(J, 4)); - if (LJ_BE) { TRef tmp = trlo; trlo = trhi; trhi = tmp; } - if (tvisfunc(fin)) { - emitir(IRT(IR_XSTORE, IRT_P32), trlo, lj_ir_kfunc(J, funcV(fin))); - emitir(IRTI(IR_XSTORE), trhi, lj_ir_kint(J, LJ_TFUNC)); - } else if (tviscdata(fin)) { - emitir(IRT(IR_XSTORE, IRT_P32), trlo, - lj_ir_kgc(J, obj2gco(cdataV(fin)), IRT_CDATA)); - emitir(IRTI(IR_XSTORE), trhi, lj_ir_kint(J, LJ_TCDATA)); - } else { - lj_trace_err(J, LJ_TRERR_BADTYPE); - } - J->needsnap = 1; -} - -/* Record cdata allocation. */ -static void crec_alloc(jit_State *J, RecordFFData *rd, CTypeID id) -{ - CTState *cts = ctype_ctsG(J2G(J)); - CTSize sz; - CTInfo info = lj_ctype_info(cts, id, &sz); - CType *d = ctype_raw(cts, id); - TRef trid; - if (!sz || sz > 128 || (info & CTF_VLA) || ctype_align(info) > CT_MEMALIGN) - lj_trace_err(J, LJ_TRERR_NYICONV); /* NYI: large/special allocations. */ - trid = lj_ir_kint(J, id); - /* Use special instruction to box pointer or 32/64 bit integer. */ - if (ctype_isptr(info) || (ctype_isinteger(info) && (sz == 4 || sz == 8))) { - TRef sp = J->base[1] ? crec_ct_tv(J, d, 0, J->base[1], &rd->argv[1]) : - ctype_isptr(info) ? lj_ir_kptr(J, NULL) : - sz == 4 ? lj_ir_kint(J, 0) : - (lj_needsplit(J), lj_ir_kint64(J, 0)); - J->base[0] = emitir(IRTG(IR_CNEWI, IRT_CDATA), trid, sp); - } else { - TRef trcd = emitir(IRTG(IR_CNEW, IRT_CDATA), trid, TREF_NIL); - cTValue *fin; - J->base[0] = trcd; - if (J->base[1] && !J->base[2] && - !lj_cconv_multi_init(cts, d, &rd->argv[1])) { - goto single_init; - } else if (ctype_isarray(d->info)) { - CType *dc = ctype_rawchild(cts, d); /* Array element type. */ - CTSize ofs, esize = dc->size; - TRef sp = 0; - TValue tv; - TValue *sval = &tv; - MSize i; - tv.u64 = 0; - if (!(ctype_isnum(dc->info) || ctype_isptr(dc->info))) - lj_trace_err(J, LJ_TRERR_NYICONV); /* NYI: init array of aggregates. */ - for (i = 1, ofs = 0; ofs < sz; ofs += esize) { - TRef dp = emitir(IRT(IR_ADD, IRT_PTR), trcd, - lj_ir_kintp(J, ofs + sizeof(GCcdata))); - if (J->base[i]) { - sp = J->base[i]; - sval = &rd->argv[i]; - i++; - } else if (i != 2) { - sp = ctype_isnum(dc->info) ? lj_ir_kint(J, 0) : TREF_NIL; - } - crec_ct_tv(J, dc, dp, sp, sval); - } - } else if (ctype_isstruct(d->info)) { - CTypeID fid = d->sib; - MSize i = 1; - while (fid) { - CType *df = ctype_get(cts, fid); - fid = df->sib; - if (ctype_isfield(df->info)) { - CType *dc; - TRef sp, dp; - TValue tv; - TValue *sval = &tv; - setintV(&tv, 0); - if (!gcref(df->name)) continue; /* Ignore unnamed fields. */ - dc = ctype_rawchild(cts, df); /* Field type. */ - if (!(ctype_isnum(dc->info) || ctype_isptr(dc->info) || - ctype_isenum(dc->info))) - lj_trace_err(J, LJ_TRERR_NYICONV); /* NYI: init aggregates. */ - if (J->base[i]) { - sp = J->base[i]; - sval = &rd->argv[i]; - i++; - } else { - sp = ctype_isptr(dc->info) ? TREF_NIL : lj_ir_kint(J, 0); - } - dp = emitir(IRT(IR_ADD, IRT_PTR), trcd, - lj_ir_kintp(J, df->size + sizeof(GCcdata))); - crec_ct_tv(J, dc, dp, sp, sval); - } else if (!ctype_isconstval(df->info)) { - /* NYI: init bitfields and sub-structures. */ - lj_trace_err(J, LJ_TRERR_NYICONV); - } - } - } else { - TRef dp; - single_init: - dp = emitir(IRT(IR_ADD, IRT_PTR), trcd, lj_ir_kintp(J, sizeof(GCcdata))); - if (J->base[1]) { - crec_ct_tv(J, d, dp, J->base[1], &rd->argv[1]); - } else { - TValue tv; - tv.u64 = 0; - crec_ct_tv(J, d, dp, lj_ir_kint(J, 0), &tv); - } - } - /* Handle __gc metamethod. */ - fin = lj_ctype_meta(cts, id, MM_gc); - if (fin) - crec_finalizer(J, trcd, fin); - } -} - -/* Record argument conversions. */ -static TRef crec_call_args(jit_State *J, RecordFFData *rd, - CTState *cts, CType *ct) -{ - TRef args[CCI_NARGS_MAX]; - CTypeID fid; - MSize i, n; - TRef tr, *base; - cTValue *o; -#if LJ_TARGET_X86 -#if LJ_ABI_WIN - TRef *arg0 = NULL, *arg1 = NULL; -#endif - int ngpr = 0; - if (ctype_cconv(ct->info) == CTCC_THISCALL) - ngpr = 1; - else if (ctype_cconv(ct->info) == CTCC_FASTCALL) - ngpr = 2; -#endif - - /* Skip initial attributes. */ - fid = ct->sib; - while (fid) { - CType *ctf = ctype_get(cts, fid); - if (!ctype_isattrib(ctf->info)) break; - fid = ctf->sib; - } - args[0] = TREF_NIL; - for (n = 0, base = J->base+1, o = rd->argv+1; *base; n++, base++, o++) { - CTypeID did; - CType *d; - - if (n >= CCI_NARGS_MAX) - lj_trace_err(J, LJ_TRERR_NYICALL); - - if (fid) { /* Get argument type from field. */ - CType *ctf = ctype_get(cts, fid); - fid = ctf->sib; - lua_assert(ctype_isfield(ctf->info)); - did = ctype_cid(ctf->info); - } else { - if (!(ct->info & CTF_VARARG)) - lj_trace_err(J, LJ_TRERR_NYICALL); /* Too many arguments. */ - did = lj_ccall_ctid_vararg(cts, o); /* Infer vararg type. */ - } - d = ctype_raw(cts, did); - if (!(ctype_isnum(d->info) || ctype_isptr(d->info) || - ctype_isenum(d->info))) - lj_trace_err(J, LJ_TRERR_NYICALL); - tr = crec_ct_tv(J, d, 0, *base, o); - if (ctype_isinteger_or_bool(d->info)) { - if (d->size < 4) { - if ((d->info & CTF_UNSIGNED)) - tr = emitconv(tr, IRT_INT, d->size==1 ? IRT_U8 : IRT_U16, 0); - else - tr = emitconv(tr, IRT_INT, d->size==1 ? IRT_I8 : IRT_I16,IRCONV_SEXT); - } - } else if (LJ_SOFTFP && ctype_isfp(d->info) && d->size > 4) { - lj_needsplit(J); - } -#if LJ_TARGET_X86 - /* 64 bit args must not end up in registers for fastcall/thiscall. */ -#if LJ_ABI_WIN - if (!ctype_isfp(d->info)) { - /* Sigh, the Windows/x86 ABI allows reordering across 64 bit args. */ - if (tref_typerange(tr, IRT_I64, IRT_U64)) { - if (ngpr) { - arg0 = &args[n]; args[n++] = TREF_NIL; ngpr--; - if (ngpr) { - arg1 = &args[n]; args[n++] = TREF_NIL; ngpr--; - } - } - } else { - if (arg0) { *arg0 = tr; arg0 = NULL; n--; continue; } - if (arg1) { *arg1 = tr; arg1 = NULL; n--; continue; } - if (ngpr) ngpr--; - } - } -#else - if (!ctype_isfp(d->info) && ngpr) { - if (tref_typerange(tr, IRT_I64, IRT_U64)) { - /* No reordering for other x86 ABIs. Simply add alignment args. */ - do { args[n++] = TREF_NIL; } while (--ngpr); - } else { - ngpr--; - } - } -#endif -#endif - args[n] = tr; - } - tr = args[0]; - for (i = 1; i < n; i++) - tr = emitir(IRT(IR_CARG, IRT_NIL), tr, args[i]); - return tr; -} - -/* Create a snapshot for the caller, simulating a 'false' return value. */ -static void crec_snap_caller(jit_State *J) -{ - lua_State *L = J->L; - TValue *base = L->base, *top = L->top; - const BCIns *pc = J->pc; - TRef ftr = J->base[-1]; - ptrdiff_t delta; - if (!frame_islua(base-1) || J->framedepth <= 0) - lj_trace_err(J, LJ_TRERR_NYICALL); - J->pc = frame_pc(base-1); delta = 1+bc_a(J->pc[-1]); - L->top = base; L->base = base - delta; - J->base[-1] = TREF_FALSE; - J->base -= delta; J->baseslot -= (BCReg)delta; - J->maxslot = (BCReg)delta; J->framedepth--; - lj_snap_add(J); - L->base = base; L->top = top; - J->framedepth++; J->maxslot = 1; - J->base += delta; J->baseslot += (BCReg)delta; - J->base[-1] = ftr; J->pc = pc; -} - -/* Record function call. */ -static int crec_call(jit_State *J, RecordFFData *rd, GCcdata *cd) -{ - CTState *cts = ctype_ctsG(J2G(J)); - CType *ct = ctype_raw(cts, cd->ctypeid); - IRType tp = IRT_PTR; - if (ctype_isptr(ct->info)) { - tp = (LJ_64 && ct->size == 8) ? IRT_P64 : IRT_P32; - ct = ctype_rawchild(cts, ct); - } - if (ctype_isfunc(ct->info)) { - TRef func = emitir(IRT(IR_FLOAD, tp), J->base[0], IRFL_CDATA_PTR); - CType *ctr = ctype_rawchild(cts, ct); - IRType t = crec_ct2irt(cts, ctr); - TRef tr; - TValue tv; - /* Check for blacklisted C functions that might call a callback. */ - setlightudV(&tv, - cdata_getptr(cdataptr(cd), (LJ_64 && tp == IRT_P64) ? 8 : 4)); - if (tvistrue(lj_tab_get(J->L, cts->miscmap, &tv))) - lj_trace_err(J, LJ_TRERR_BLACKL); - if (ctype_isvoid(ctr->info)) { - t = IRT_NIL; - rd->nres = 0; - } else if (!(ctype_isnum(ctr->info) || ctype_isptr(ctr->info) || - ctype_isenum(ctr->info)) || t == IRT_CDATA) { - lj_trace_err(J, LJ_TRERR_NYICALL); - } - if ((ct->info & CTF_VARARG) -#if LJ_TARGET_X86 - || ctype_cconv(ct->info) != CTCC_CDECL -#endif - ) - func = emitir(IRT(IR_CARG, IRT_NIL), func, - lj_ir_kint(J, ctype_typeid(cts, ct))); - tr = emitir(IRT(IR_CALLXS, t), crec_call_args(J, rd, cts, ct), func); - if (ctype_isbool(ctr->info)) { - if (frame_islua(J->L->base-1) && bc_b(frame_pc(J->L->base-1)[-1]) == 1) { - /* Don't check result if ignored. */ - tr = TREF_NIL; - } else { - crec_snap_caller(J); -#if LJ_TARGET_X86ORX64 - /* Note: only the x86/x64 backend supports U8 and only for EQ(tr, 0). */ - lj_ir_set(J, IRTG(IR_NE, IRT_U8), tr, lj_ir_kint(J, 0)); -#else - lj_ir_set(J, IRTGI(IR_NE), tr, lj_ir_kint(J, 0)); -#endif - J->postproc = LJ_POST_FIXGUARDSNAP; - tr = TREF_TRUE; - } - } else if (t == IRT_PTR || (LJ_64 && t == IRT_P32) || - t == IRT_I64 || t == IRT_U64 || ctype_isenum(ctr->info)) { - TRef trid = lj_ir_kint(J, ctype_cid(ct->info)); - tr = emitir(IRTG(IR_CNEWI, IRT_CDATA), trid, tr); - if (t == IRT_I64 || t == IRT_U64) lj_needsplit(J); - } else if (t == IRT_FLOAT || t == IRT_U32) { - tr = emitconv(tr, IRT_NUM, t, 0); - } else if (t == IRT_I8 || t == IRT_I16) { - tr = emitconv(tr, IRT_INT, t, IRCONV_SEXT); - } else if (t == IRT_U8 || t == IRT_U16) { - tr = emitconv(tr, IRT_INT, t, 0); - } - J->base[0] = tr; - J->needsnap = 1; - return 1; - } - return 0; -} - -void LJ_FASTCALL recff_cdata_call(jit_State *J, RecordFFData *rd) -{ - CTState *cts = ctype_ctsG(J2G(J)); - GCcdata *cd = argv2cdata(J, J->base[0], &rd->argv[0]); - CTypeID id = cd->ctypeid; - CType *ct; - cTValue *tv; - MMS mm = MM_call; - if (id == CTID_CTYPEID) { - id = crec_constructor(J, cd, J->base[0]); - mm = MM_new; - } else if (crec_call(J, rd, cd)) { - return; - } - /* Record ctype __call/__new metamethod. */ - ct = ctype_raw(cts, id); - tv = lj_ctype_meta(cts, ctype_isptr(ct->info) ? ctype_cid(ct->info) : id, mm); - if (tv) { - if (tvisfunc(tv)) { - J->base[-1] = lj_ir_kfunc(J, funcV(tv)) | TREF_FRAME; - rd->nres = -1; /* Pending tailcall. */ - return; - } - } else if (mm == MM_new) { - crec_alloc(J, rd, id); - return; - } - /* No metamethod or NYI: non-function metamethods. */ - lj_trace_err(J, LJ_TRERR_BADTYPE); -} - -static TRef crec_arith_int64(jit_State *J, TRef *sp, CType **s, MMS mm) -{ - if (ctype_isnum(s[0]->info) && ctype_isnum(s[1]->info)) { - IRType dt; - CTypeID id; - TRef tr; - MSize i; - IROp op; - lj_needsplit(J); - if (((s[0]->info & CTF_UNSIGNED) && s[0]->size == 8) || - ((s[1]->info & CTF_UNSIGNED) && s[1]->size == 8)) { - dt = IRT_U64; id = CTID_UINT64; - } else { - dt = IRT_I64; id = CTID_INT64; - if (mm < MM_add && - !((s[0]->info | s[1]->info) & CTF_FP) && - s[0]->size == 4 && s[1]->size == 4) { /* Try to narrow comparison. */ - if (!((s[0]->info ^ s[1]->info) & CTF_UNSIGNED) || - (tref_isk(sp[1]) && IR(tref_ref(sp[1]))->i >= 0)) { - dt = (s[0]->info & CTF_UNSIGNED) ? IRT_U32 : IRT_INT; - goto comp; - } else if (tref_isk(sp[0]) && IR(tref_ref(sp[0]))->i >= 0) { - dt = (s[1]->info & CTF_UNSIGNED) ? IRT_U32 : IRT_INT; - goto comp; - } - } - } - for (i = 0; i < 2; i++) { - IRType st = tref_type(sp[i]); - if (st == IRT_NUM || st == IRT_FLOAT) - sp[i] = emitconv(sp[i], dt, st, IRCONV_TRUNC|IRCONV_ANY); - else if (!(st == IRT_I64 || st == IRT_U64)) - sp[i] = emitconv(sp[i], dt, IRT_INT, - (s[i]->info & CTF_UNSIGNED) ? 0 : IRCONV_SEXT); - } - if (mm < MM_add) { - comp: - /* Assume true comparison. Fixup and emit pending guard later. */ - if (mm == MM_eq) { - op = IR_EQ; - } else { - op = mm == MM_lt ? IR_LT : IR_LE; - if (dt == IRT_U32 || dt == IRT_U64) - op += (IR_ULT-IR_LT); - } - lj_ir_set(J, IRTG(op, dt), sp[0], sp[1]); - J->postproc = LJ_POST_FIXGUARD; - return TREF_TRUE; - } else { - tr = emitir(IRT(mm+(int)IR_ADD-(int)MM_add, dt), sp[0], sp[1]); - } - return emitir(IRTG(IR_CNEWI, IRT_CDATA), lj_ir_kint(J, id), tr); - } - return 0; -} - -static TRef crec_arith_ptr(jit_State *J, TRef *sp, CType **s, MMS mm) -{ - CTState *cts = ctype_ctsG(J2G(J)); - CType *ctp = s[0]; - if (ctype_isptr(ctp->info) || ctype_isrefarray(ctp->info)) { - if ((mm == MM_sub || mm == MM_eq || mm == MM_lt || mm == MM_le) && - (ctype_isptr(s[1]->info) || ctype_isrefarray(s[1]->info))) { - if (mm == MM_sub) { /* Pointer difference. */ - TRef tr; - CTSize sz = lj_ctype_size(cts, ctype_cid(ctp->info)); - if (sz == 0 || (sz & (sz-1)) != 0) - return 0; /* NYI: integer division. */ - tr = emitir(IRT(IR_SUB, IRT_INTP), sp[0], sp[1]); - tr = emitir(IRT(IR_BSAR, IRT_INTP), tr, lj_ir_kint(J, lj_fls(sz))); -#if LJ_64 - tr = emitconv(tr, IRT_NUM, IRT_INTP, 0); -#endif - return tr; - } else { /* Pointer comparison (unsigned). */ - /* Assume true comparison. Fixup and emit pending guard later. */ - IROp op = mm == MM_eq ? IR_EQ : mm == MM_lt ? IR_ULT : IR_ULE; - lj_ir_set(J, IRTG(op, IRT_PTR), sp[0], sp[1]); - J->postproc = LJ_POST_FIXGUARD; - return TREF_TRUE; - } - } - if (!((mm == MM_add || mm == MM_sub) && ctype_isnum(s[1]->info))) - return 0; - } else if (mm == MM_add && ctype_isnum(ctp->info) && - (ctype_isptr(s[1]->info) || ctype_isrefarray(s[1]->info))) { - TRef tr = sp[0]; sp[0] = sp[1]; sp[1] = tr; /* Swap pointer and index. */ - ctp = s[1]; - } else { - return 0; - } - { - TRef tr = sp[1]; - IRType t = tref_type(tr); - CTSize sz = lj_ctype_size(cts, ctype_cid(ctp->info)); - CTypeID id; -#if LJ_64 - if (t == IRT_NUM || t == IRT_FLOAT) - tr = emitconv(tr, IRT_INTP, t, IRCONV_TRUNC|IRCONV_ANY); - else if (!(t == IRT_I64 || t == IRT_U64)) - tr = emitconv(tr, IRT_INTP, IRT_INT, - ((t - IRT_I8) & 1) ? 0 : IRCONV_SEXT); -#else - if (!tref_typerange(sp[1], IRT_I8, IRT_U32)) { - tr = emitconv(tr, IRT_INTP, t, - (t == IRT_NUM || t == IRT_FLOAT) ? - IRCONV_TRUNC|IRCONV_ANY : 0); - } -#endif - tr = emitir(IRT(IR_MUL, IRT_INTP), tr, lj_ir_kintp(J, sz)); - tr = emitir(IRT(mm+(int)IR_ADD-(int)MM_add, IRT_PTR), sp[0], tr); - id = lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|ctype_cid(ctp->info)), - CTSIZE_PTR); - return emitir(IRTG(IR_CNEWI, IRT_CDATA), lj_ir_kint(J, id), tr); - } -} - -/* Record ctype arithmetic metamethods. */ -static void crec_arith_meta(jit_State *J, CTState *cts, RecordFFData *rd) -{ - cTValue *tv = NULL; - if (J->base[0]) { - if (tviscdata(&rd->argv[0])) { - CTypeID id = argv2cdata(J, J->base[0], &rd->argv[0])->ctypeid; - CType *ct = ctype_raw(cts, id); - if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); - tv = lj_ctype_meta(cts, id, (MMS)rd->data); - } - if (!tv && J->base[1] && tviscdata(&rd->argv[1])) { - CTypeID id = argv2cdata(J, J->base[1], &rd->argv[1])->ctypeid; - CType *ct = ctype_raw(cts, id); - if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); - tv = lj_ctype_meta(cts, id, (MMS)rd->data); - } - } - if (tv) { - if (tvisfunc(tv)) { - J->base[-1] = lj_ir_kfunc(J, funcV(tv)) | TREF_FRAME; - rd->nres = -1; /* Pending tailcall. */ - return; - } /* NYI: non-function metamethods. */ - } else if ((MMS)rd->data == MM_eq) { - J->base[0] = TREF_FALSE; - return; - } - lj_trace_err(J, LJ_TRERR_BADTYPE); -} - -void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd) -{ - CTState *cts = ctype_ctsG(J2G(J)); - TRef sp[2]; - CType *s[2]; - MSize i; - for (i = 0; i < 2; i++) { - TRef tr = J->base[i]; - CType *ct = ctype_get(cts, CTID_DOUBLE); - if (!tr) { - goto trymeta; - } else if (tref_iscdata(tr)) { - CTypeID id = argv2cdata(J, tr, &rd->argv[i])->ctypeid; - IRType t; - ct = ctype_raw(cts, id); - t = crec_ct2irt(cts, ct); - if (ctype_isptr(ct->info)) { /* Resolve pointer or reference. */ - tr = emitir(IRT(IR_FLOAD, t), tr, IRFL_CDATA_PTR); - if (ctype_isref(ct->info)) { - ct = ctype_rawchild(cts, ct); - t = crec_ct2irt(cts, ct); - } - } else if (t == IRT_I64 || t == IRT_U64) { - tr = emitir(IRT(IR_FLOAD, t), tr, IRFL_CDATA_INT64); - lj_needsplit(J); - goto ok; - } else if (t == IRT_INT || t == IRT_U32) { - tr = emitir(IRT(IR_FLOAD, t), tr, IRFL_CDATA_INT); - if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); - goto ok; - } else if (ctype_isfunc(ct->info)) { - tr = emitir(IRT(IR_FLOAD, IRT_PTR), tr, IRFL_CDATA_PTR); - ct = ctype_get(cts, - lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|id), CTSIZE_PTR)); - goto ok; - } else { - tr = emitir(IRT(IR_ADD, IRT_PTR), tr, lj_ir_kintp(J, sizeof(GCcdata))); - } - if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); - if (ctype_isnum(ct->info)) { - if (t == IRT_CDATA) goto trymeta; - if (t == IRT_I64 || t == IRT_U64) lj_needsplit(J); - tr = emitir(IRT(IR_XLOAD, t), tr, 0); - } else if (!(ctype_isptr(ct->info) || ctype_isrefarray(ct->info))) { - goto trymeta; - } - } else if (tref_isnil(tr)) { - tr = lj_ir_kptr(J, NULL); - ct = ctype_get(cts, CTID_P_VOID); - } else if (tref_isinteger(tr)) { - ct = ctype_get(cts, CTID_INT32); - } else if (tref_isstr(tr)) { - TRef tr2 = J->base[1-i]; - CTypeID id = argv2cdata(J, tr2, &rd->argv[1-i])->ctypeid; - ct = ctype_raw(cts, id); - if (ctype_isenum(ct->info)) { /* Match string against enum constant. */ - GCstr *str = strV(&rd->argv[i]); - CTSize ofs; - CType *cct = lj_ctype_getfield(cts, ct, str, &ofs); - if (cct && ctype_isconstval(cct->info)) { - /* Specialize to the name of the enum constant. */ - emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, str)); - ct = ctype_child(cts, cct); - tr = lj_ir_kint(J, (int32_t)ofs); - } /* else: interpreter will throw. */ - } /* else: interpreter will throw. */ - } else if (!tref_isnum(tr)) { - goto trymeta; - } - ok: - s[i] = ct; - sp[i] = tr; - } - { - TRef tr; - if ((tr = crec_arith_int64(J, sp, s, (MMS)rd->data)) || - (tr = crec_arith_ptr(J, sp, s, (MMS)rd->data))) { - J->base[0] = tr; - /* Fixup cdata comparisons, too. Avoids some cdata escapes. */ - if (J->postproc == LJ_POST_FIXGUARD && frame_iscont(J->L->base-1) && - !irt_isguard(J->guardemit)) { - const BCIns *pc = frame_contpc(J->L->base-1) - 1; - if (bc_op(*pc) <= BC_ISNEP) { - setframe_pc(&J2G(J)->tmptv, pc); - J2G(J)->tmptv.u32.lo = ((tref_istrue(tr) ^ bc_op(*pc)) & 1); - J->postproc = LJ_POST_FIXCOMP; - } - } - } else { - trymeta: - crec_arith_meta(J, cts, rd); - } - } -} - -/* -- C library namespace metamethods ------------------------------------- */ - -void LJ_FASTCALL recff_clib_index(jit_State *J, RecordFFData *rd) -{ - CTState *cts = ctype_ctsG(J2G(J)); - if (tref_isudata(J->base[0]) && tref_isstr(J->base[1]) && - udataV(&rd->argv[0])->udtype == UDTYPE_FFI_CLIB) { - CLibrary *cl = (CLibrary *)uddata(udataV(&rd->argv[0])); - GCstr *name = strV(&rd->argv[1]); - CType *ct; - CTypeID id = lj_ctype_getname(cts, &ct, name, CLNS_INDEX); - cTValue *tv = lj_tab_getstr(cl->cache, name); - rd->nres = rd->data; - if (id && tv && !tvisnil(tv)) { - /* Specialize to the symbol name and make the result a constant. */ - emitir(IRTG(IR_EQ, IRT_STR), J->base[1], lj_ir_kstr(J, name)); - if (ctype_isconstval(ct->info)) { - if (ct->size >= 0x80000000u && - (ctype_child(cts, ct)->info & CTF_UNSIGNED)) - J->base[0] = lj_ir_knum(J, (lua_Number)(uint32_t)ct->size); - else - J->base[0] = lj_ir_kint(J, (int32_t)ct->size); - } else if (ctype_isextern(ct->info)) { - CTypeID sid = ctype_cid(ct->info); - void *sp = *(void **)cdataptr(cdataV(tv)); - TRef ptr; - ct = ctype_raw(cts, sid); - if (LJ_64 && !checkptr32(sp)) - ptr = lj_ir_kintp(J, (uintptr_t)sp); - else - ptr = lj_ir_kptr(J, sp); - if (rd->data) { - J->base[0] = crec_tv_ct(J, ct, sid, ptr); - } else { - J->needsnap = 1; - crec_ct_tv(J, ct, ptr, J->base[2], &rd->argv[2]); - } - } else { - J->base[0] = lj_ir_kgc(J, obj2gco(cdataV(tv)), IRT_CDATA); - } - } else { - lj_trace_err(J, LJ_TRERR_NOCACHE); - } - } /* else: interpreter will throw. */ -} - -/* -- FFI library functions ----------------------------------------------- */ - -static TRef crec_toint(jit_State *J, CTState *cts, TRef sp, TValue *sval) -{ - return crec_ct_tv(J, ctype_get(cts, CTID_INT32), 0, sp, sval); -} - -void LJ_FASTCALL recff_ffi_new(jit_State *J, RecordFFData *rd) -{ - crec_alloc(J, rd, argv2ctype(J, J->base[0], &rd->argv[0])); -} - -void LJ_FASTCALL recff_ffi_errno(jit_State *J, RecordFFData *rd) -{ - UNUSED(rd); - if (J->base[0]) - lj_trace_err(J, LJ_TRERR_NYICALL); - J->base[0] = lj_ir_call(J, IRCALL_lj_vm_errno); -} - -void LJ_FASTCALL recff_ffi_string(jit_State *J, RecordFFData *rd) -{ - CTState *cts = ctype_ctsG(J2G(J)); - TRef tr = J->base[0]; - if (tr) { - TRef trlen = J->base[1]; - if (!tref_isnil(trlen)) { - trlen = crec_toint(J, cts, trlen, &rd->argv[1]); - tr = crec_ct_tv(J, ctype_get(cts, CTID_P_CVOID), 0, tr, &rd->argv[0]); - } else { - tr = crec_ct_tv(J, ctype_get(cts, CTID_P_CCHAR), 0, tr, &rd->argv[0]); - trlen = lj_ir_call(J, IRCALL_strlen, tr); - } - J->base[0] = emitir(IRT(IR_XSNEW, IRT_STR), tr, trlen); - } /* else: interpreter will throw. */ -} - -void LJ_FASTCALL recff_ffi_copy(jit_State *J, RecordFFData *rd) -{ - CTState *cts = ctype_ctsG(J2G(J)); - TRef trdst = J->base[0], trsrc = J->base[1], trlen = J->base[2]; - if (trdst && trsrc && (trlen || tref_isstr(trsrc))) { - trdst = crec_ct_tv(J, ctype_get(cts, CTID_P_VOID), 0, trdst, &rd->argv[0]); - trsrc = crec_ct_tv(J, ctype_get(cts, CTID_P_CVOID), 0, trsrc, &rd->argv[1]); - if (trlen) { - trlen = crec_toint(J, cts, trlen, &rd->argv[2]); - } else { - trlen = emitir(IRTI(IR_FLOAD), J->base[1], IRFL_STR_LEN); - trlen = emitir(IRTI(IR_ADD), trlen, lj_ir_kint(J, 1)); - } - rd->nres = 0; - crec_copy(J, trdst, trsrc, trlen, NULL); - } /* else: interpreter will throw. */ -} - -void LJ_FASTCALL recff_ffi_fill(jit_State *J, RecordFFData *rd) -{ - CTState *cts = ctype_ctsG(J2G(J)); - TRef trdst = J->base[0], trlen = J->base[1], trfill = J->base[2]; - if (trdst && trlen) { - CTSize step = 1; - if (tviscdata(&rd->argv[0])) { /* Get alignment of original destination. */ - CTSize sz; - CType *ct = ctype_raw(cts, cdataV(&rd->argv[0])->ctypeid); - if (ctype_isptr(ct->info)) - ct = ctype_rawchild(cts, ct); - step = (1u<argv[0]); - trlen = crec_toint(J, cts, trlen, &rd->argv[1]); - if (trfill) - trfill = crec_toint(J, cts, trfill, &rd->argv[2]); - else - trfill = lj_ir_kint(J, 0); - rd->nres = 0; - crec_fill(J, trdst, trlen, trfill, step); - } /* else: interpreter will throw. */ -} - -void LJ_FASTCALL recff_ffi_typeof(jit_State *J, RecordFFData *rd) -{ - if (tref_iscdata(J->base[0])) { - TRef trid = lj_ir_kint(J, argv2ctype(J, J->base[0], &rd->argv[0])); - J->base[0] = emitir(IRTG(IR_CNEWI, IRT_CDATA), - lj_ir_kint(J, CTID_CTYPEID), trid); - } else { - setfuncV(J->L, &J->errinfo, J->fn); - lj_trace_err_info(J, LJ_TRERR_NYIFFU); - } -} - -void LJ_FASTCALL recff_ffi_istype(jit_State *J, RecordFFData *rd) -{ - argv2ctype(J, J->base[0], &rd->argv[0]); - if (tref_iscdata(J->base[1])) { - argv2ctype(J, J->base[1], &rd->argv[1]); - J->postproc = LJ_POST_FIXBOOL; - J->base[0] = TREF_TRUE; - } else { - J->base[0] = TREF_FALSE; - } -} - -void LJ_FASTCALL recff_ffi_abi(jit_State *J, RecordFFData *rd) -{ - if (tref_isstr(J->base[0])) { - /* Specialize to the ABI string to make the boolean result a constant. */ - emitir(IRTG(IR_EQ, IRT_STR), J->base[0], lj_ir_kstr(J, strV(&rd->argv[0]))); - J->postproc = LJ_POST_FIXBOOL; - J->base[0] = TREF_TRUE; - } else { - lj_trace_err(J, LJ_TRERR_BADTYPE); - } -} - -/* Record ffi.sizeof(), ffi.alignof(), ffi.offsetof(). */ -void LJ_FASTCALL recff_ffi_xof(jit_State *J, RecordFFData *rd) -{ - CTypeID id = argv2ctype(J, J->base[0], &rd->argv[0]); - if (rd->data == FF_ffi_sizeof) { - CType *ct = lj_ctype_rawref(ctype_ctsG(J2G(J)), id); - if (ctype_isvltype(ct->info)) - lj_trace_err(J, LJ_TRERR_BADTYPE); - } else if (rd->data == FF_ffi_offsetof) { /* Specialize to the field name. */ - if (!tref_isstr(J->base[1])) - lj_trace_err(J, LJ_TRERR_BADTYPE); - emitir(IRTG(IR_EQ, IRT_STR), J->base[1], lj_ir_kstr(J, strV(&rd->argv[1]))); - rd->nres = 3; /* Just in case. */ - } - J->postproc = LJ_POST_FIXCONST; - J->base[0] = J->base[1] = J->base[2] = TREF_NIL; -} - -void LJ_FASTCALL recff_ffi_gc(jit_State *J, RecordFFData *rd) -{ - argv2cdata(J, J->base[0], &rd->argv[0]); - crec_finalizer(J, J->base[0], &rd->argv[1]); -} - -/* -- Miscellaneous library functions ------------------------------------- */ - -void LJ_FASTCALL lj_crecord_tonumber(jit_State *J, RecordFFData *rd) -{ - CTState *cts = ctype_ctsG(J2G(J)); - CType *d, *ct = lj_ctype_rawref(cts, cdataV(&rd->argv[0])->ctypeid); - if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); - if (ctype_isnum(ct->info) || ctype_iscomplex(ct->info)) { - if (ctype_isinteger_or_bool(ct->info) && ct->size <= 4 && - !(ct->size == 4 && (ct->info & CTF_UNSIGNED))) - d = ctype_get(cts, CTID_INT32); - else - d = ctype_get(cts, CTID_DOUBLE); - J->base[0] = crec_ct_tv(J, d, 0, J->base[0], &rd->argv[0]); - } else { - J->base[0] = TREF_NIL; - } -} - -#undef IR -#undef emitir -#undef emitconv - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_crecord.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_crecord.h deleted file mode 100644 index fb77ca608..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_crecord.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -** Trace recorder for C data operations. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_CRECORD_H -#define _LJ_CRECORD_H - -#include "lj_obj.h" -#include "lj_jit.h" -#include "lj_ffrecord.h" - -#if LJ_HASJIT && LJ_HASFFI -LJ_FUNC void LJ_FASTCALL recff_cdata_index(jit_State *J, RecordFFData *rd); -LJ_FUNC void LJ_FASTCALL recff_cdata_call(jit_State *J, RecordFFData *rd); -LJ_FUNC void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd); -LJ_FUNC void LJ_FASTCALL recff_clib_index(jit_State *J, RecordFFData *rd); -LJ_FUNC void LJ_FASTCALL recff_ffi_new(jit_State *J, RecordFFData *rd); -LJ_FUNC void LJ_FASTCALL recff_ffi_errno(jit_State *J, RecordFFData *rd); -LJ_FUNC void LJ_FASTCALL recff_ffi_string(jit_State *J, RecordFFData *rd); -LJ_FUNC void LJ_FASTCALL recff_ffi_copy(jit_State *J, RecordFFData *rd); -LJ_FUNC void LJ_FASTCALL recff_ffi_fill(jit_State *J, RecordFFData *rd); -LJ_FUNC void LJ_FASTCALL recff_ffi_typeof(jit_State *J, RecordFFData *rd); -LJ_FUNC void LJ_FASTCALL recff_ffi_istype(jit_State *J, RecordFFData *rd); -LJ_FUNC void LJ_FASTCALL recff_ffi_abi(jit_State *J, RecordFFData *rd); -LJ_FUNC void LJ_FASTCALL recff_ffi_xof(jit_State *J, RecordFFData *rd); -LJ_FUNC void LJ_FASTCALL recff_ffi_gc(jit_State *J, RecordFFData *rd); -LJ_FUNC void LJ_FASTCALL lj_crecord_tonumber(jit_State *J, RecordFFData *rd); -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ctype.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_ctype.c deleted file mode 100644 index e9fe0943f..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ctype.c +++ /dev/null @@ -1,634 +0,0 @@ -/* -** C type management. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#include "lj_obj.h" - -#if LJ_HASFFI - -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_ctype.h" -#include "lj_ccallback.h" - -/* -- C type definitions -------------------------------------------------- */ - -/* Predefined typedefs. */ -#define CTTDDEF(_) \ - /* Vararg handling. */ \ - _("va_list", P_VOID) \ - _("__builtin_va_list", P_VOID) \ - _("__gnuc_va_list", P_VOID) \ - /* From stddef.h. */ \ - _("ptrdiff_t", INT_PSZ) \ - _("size_t", UINT_PSZ) \ - _("wchar_t", WCHAR) \ - /* Subset of stdint.h. */ \ - _("int8_t", INT8) \ - _("int16_t", INT16) \ - _("int32_t", INT32) \ - _("int64_t", INT64) \ - _("uint8_t", UINT8) \ - _("uint16_t", UINT16) \ - _("uint32_t", UINT32) \ - _("uint64_t", UINT64) \ - _("intptr_t", INT_PSZ) \ - _("uintptr_t", UINT_PSZ) \ - /* End of typedef list. */ - -/* Keywords (only the ones we actually care for). */ -#define CTKWDEF(_) \ - /* Type specifiers. */ \ - _("void", -1, CTOK_VOID) \ - _("_Bool", 0, CTOK_BOOL) \ - _("bool", 1, CTOK_BOOL) \ - _("char", 1, CTOK_CHAR) \ - _("int", 4, CTOK_INT) \ - _("__int8", 1, CTOK_INT) \ - _("__int16", 2, CTOK_INT) \ - _("__int32", 4, CTOK_INT) \ - _("__int64", 8, CTOK_INT) \ - _("float", 4, CTOK_FP) \ - _("double", 8, CTOK_FP) \ - _("long", 0, CTOK_LONG) \ - _("short", 0, CTOK_SHORT) \ - _("_Complex", 0, CTOK_COMPLEX) \ - _("complex", 0, CTOK_COMPLEX) \ - _("__complex", 0, CTOK_COMPLEX) \ - _("__complex__", 0, CTOK_COMPLEX) \ - _("signed", 0, CTOK_SIGNED) \ - _("__signed", 0, CTOK_SIGNED) \ - _("__signed__", 0, CTOK_SIGNED) \ - _("unsigned", 0, CTOK_UNSIGNED) \ - /* Type qualifiers. */ \ - _("const", 0, CTOK_CONST) \ - _("__const", 0, CTOK_CONST) \ - _("__const__", 0, CTOK_CONST) \ - _("volatile", 0, CTOK_VOLATILE) \ - _("__volatile", 0, CTOK_VOLATILE) \ - _("__volatile__", 0, CTOK_VOLATILE) \ - _("restrict", 0, CTOK_RESTRICT) \ - _("__restrict", 0, CTOK_RESTRICT) \ - _("__restrict__", 0, CTOK_RESTRICT) \ - _("inline", 0, CTOK_INLINE) \ - _("__inline", 0, CTOK_INLINE) \ - _("__inline__", 0, CTOK_INLINE) \ - /* Storage class specifiers. */ \ - _("typedef", 0, CTOK_TYPEDEF) \ - _("extern", 0, CTOK_EXTERN) \ - _("static", 0, CTOK_STATIC) \ - _("auto", 0, CTOK_AUTO) \ - _("register", 0, CTOK_REGISTER) \ - /* GCC Attributes. */ \ - _("__extension__", 0, CTOK_EXTENSION) \ - _("__attribute", 0, CTOK_ATTRIBUTE) \ - _("__attribute__", 0, CTOK_ATTRIBUTE) \ - _("asm", 0, CTOK_ASM) \ - _("__asm", 0, CTOK_ASM) \ - _("__asm__", 0, CTOK_ASM) \ - /* MSVC Attributes. */ \ - _("__declspec", 0, CTOK_DECLSPEC) \ - _("__cdecl", CTCC_CDECL, CTOK_CCDECL) \ - _("__thiscall", CTCC_THISCALL, CTOK_CCDECL) \ - _("__fastcall", CTCC_FASTCALL, CTOK_CCDECL) \ - _("__stdcall", CTCC_STDCALL, CTOK_CCDECL) \ - _("__ptr32", 4, CTOK_PTRSZ) \ - _("__ptr64", 8, CTOK_PTRSZ) \ - /* Other type specifiers. */ \ - _("struct", 0, CTOK_STRUCT) \ - _("union", 0, CTOK_UNION) \ - _("enum", 0, CTOK_ENUM) \ - /* Operators. */ \ - _("sizeof", 0, CTOK_SIZEOF) \ - _("__alignof", 0, CTOK_ALIGNOF) \ - _("__alignof__", 0, CTOK_ALIGNOF) \ - /* End of keyword list. */ - -/* Type info for predefined types. Size merged in. */ -static CTInfo lj_ctype_typeinfo[] = { -#define CTTYINFODEF(id, sz, ct, info) CTINFO((ct),(((sz)&0x3fu)<<10)+(info)), -#define CTTDINFODEF(name, id) CTINFO(CT_TYPEDEF, CTID_##id), -#define CTKWINFODEF(name, sz, kw) CTINFO(CT_KW,(((sz)&0x3fu)<<10)+(kw)), -CTTYDEF(CTTYINFODEF) -CTTDDEF(CTTDINFODEF) -CTKWDEF(CTKWINFODEF) -#undef CTTYINFODEF -#undef CTTDINFODEF -#undef CTKWINFODEF - 0 -}; - -/* Predefined type names collected in a single string. */ -static const char * const lj_ctype_typenames = -#define CTTDNAMEDEF(name, id) name "\0" -#define CTKWNAMEDEF(name, sz, cds) name "\0" -CTTDDEF(CTTDNAMEDEF) -CTKWDEF(CTKWNAMEDEF) -#undef CTTDNAMEDEF -#undef CTKWNAMEDEF -; - -#define CTTYPEINFO_NUM (sizeof(lj_ctype_typeinfo)/sizeof(CTInfo)-1) -#ifdef LUAJIT_CTYPE_CHECK_ANCHOR -#define CTTYPETAB_MIN CTTYPEINFO_NUM -#else -#define CTTYPETAB_MIN 128 -#endif - -/* -- C type interning ---------------------------------------------------- */ - -#define ct_hashtype(info, size) (hashrot(info, size) & CTHASH_MASK) -#define ct_hashname(name) \ - (hashrot(u32ptr(name), u32ptr(name) + HASH_BIAS) & CTHASH_MASK) - -/* Create new type element. */ -CTypeID lj_ctype_new(CTState *cts, CType **ctp) -{ - CTypeID id = cts->top; - CType *ct; - lua_assert(cts->L); - if (LJ_UNLIKELY(id >= cts->sizetab)) { - if (id >= CTID_MAX) lj_err_msg(cts->L, LJ_ERR_TABOV); -#ifdef LUAJIT_CTYPE_CHECK_ANCHOR - ct = lj_mem_newvec(cts->L, id+1, CType); - memcpy(ct, cts->tab, id*sizeof(CType)); - memset(cts->tab, 0, id*sizeof(CType)); - lj_mem_freevec(cts->g, cts->tab, cts->sizetab, CType); - cts->tab = ct; - cts->sizetab = id+1; -#else - lj_mem_growvec(cts->L, cts->tab, cts->sizetab, CTID_MAX, CType); -#endif - } - cts->top = id+1; - *ctp = ct = &cts->tab[id]; - ct->info = 0; - ct->size = 0; - ct->sib = 0; - ct->next = 0; - setgcrefnull(ct->name); - return id; -} - -/* Intern a type element. */ -CTypeID lj_ctype_intern(CTState *cts, CTInfo info, CTSize size) -{ - uint32_t h = ct_hashtype(info, size); - CTypeID id = cts->hash[h]; - lua_assert(cts->L); - while (id) { - CType *ct = ctype_get(cts, id); - if (ct->info == info && ct->size == size) - return id; - id = ct->next; - } - id = cts->top; - if (LJ_UNLIKELY(id >= cts->sizetab)) { - if (id >= CTID_MAX) lj_err_msg(cts->L, LJ_ERR_TABOV); - lj_mem_growvec(cts->L, cts->tab, cts->sizetab, CTID_MAX, CType); - } - cts->top = id+1; - cts->tab[id].info = info; - cts->tab[id].size = size; - cts->tab[id].sib = 0; - cts->tab[id].next = cts->hash[h]; - setgcrefnull(cts->tab[id].name); - cts->hash[h] = (CTypeID1)id; - return id; -} - -/* Add type element to hash table. */ -static void ctype_addtype(CTState *cts, CType *ct, CTypeID id) -{ - uint32_t h = ct_hashtype(ct->info, ct->size); - ct->next = cts->hash[h]; - cts->hash[h] = (CTypeID1)id; -} - -/* Add named element to hash table. */ -void lj_ctype_addname(CTState *cts, CType *ct, CTypeID id) -{ - uint32_t h = ct_hashname(gcref(ct->name)); - ct->next = cts->hash[h]; - cts->hash[h] = (CTypeID1)id; -} - -/* Get a C type by name, matching the type mask. */ -CTypeID lj_ctype_getname(CTState *cts, CType **ctp, GCstr *name, uint32_t tmask) -{ - CTypeID id = cts->hash[ct_hashname(name)]; - while (id) { - CType *ct = ctype_get(cts, id); - if (gcref(ct->name) == obj2gco(name) && - ((tmask >> ctype_type(ct->info)) & 1)) { - *ctp = ct; - return id; - } - id = ct->next; - } - *ctp = &cts->tab[0]; /* Simplify caller logic. ctype_get() would assert. */ - return 0; -} - -/* Get a struct/union/enum/function field by name. */ -CType *lj_ctype_getfieldq(CTState *cts, CType *ct, GCstr *name, CTSize *ofs, - CTInfo *qual) -{ - while (ct->sib) { - ct = ctype_get(cts, ct->sib); - if (gcref(ct->name) == obj2gco(name)) { - *ofs = ct->size; - return ct; - } - if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) { - CType *fct, *cct = ctype_child(cts, ct); - CTInfo q = 0; - while (ctype_isattrib(cct->info)) { - if (ctype_attrib(cct->info) == CTA_QUAL) q |= cct->size; - cct = ctype_child(cts, cct); - } - fct = lj_ctype_getfieldq(cts, cct, name, ofs, qual); - if (fct) { - if (qual) *qual |= q; - *ofs += ct->size; - return fct; - } - } - } - return NULL; /* Not found. */ -} - -/* -- C type information -------------------------------------------------- */ - -/* Follow references and get raw type for a C type ID. */ -CType *lj_ctype_rawref(CTState *cts, CTypeID id) -{ - CType *ct = ctype_get(cts, id); - while (ctype_isattrib(ct->info) || ctype_isref(ct->info)) - ct = ctype_child(cts, ct); - return ct; -} - -/* Get size for a C type ID. Does NOT support VLA/VLS. */ -CTSize lj_ctype_size(CTState *cts, CTypeID id) -{ - CType *ct = ctype_raw(cts, id); - return ctype_hassize(ct->info) ? ct->size : CTSIZE_INVALID; -} - -/* Get size for a variable-length C type. Does NOT support other C types. */ -CTSize lj_ctype_vlsize(CTState *cts, CType *ct, CTSize nelem) -{ - uint64_t xsz = 0; - if (ctype_isstruct(ct->info)) { - CTypeID arrid = 0, fid = ct->sib; - xsz = ct->size; /* Add the struct size. */ - while (fid) { - CType *ctf = ctype_get(cts, fid); - if (ctype_type(ctf->info) == CT_FIELD) - arrid = ctype_cid(ctf->info); /* Remember last field of VLS. */ - fid = ctf->sib; - } - ct = ctype_raw(cts, arrid); - } - lua_assert(ctype_isvlarray(ct->info)); /* Must be a VLA. */ - ct = ctype_rawchild(cts, ct); /* Get array element. */ - lua_assert(ctype_hassize(ct->info)); - /* Calculate actual size of VLA and check for overflow. */ - xsz += (uint64_t)ct->size * nelem; - return xsz < 0x80000000u ? (CTSize)xsz : CTSIZE_INVALID; -} - -/* Get type, qualifiers, size and alignment for a C type ID. */ -CTInfo lj_ctype_info(CTState *cts, CTypeID id, CTSize *szp) -{ - CTInfo qual = 0; - CType *ct = ctype_get(cts, id); - for (;;) { - CTInfo info = ct->info; - if (ctype_isenum(info)) { - /* Follow child. Need to look at its attributes, too. */ - } else if (ctype_isattrib(info)) { - if (ctype_isxattrib(info, CTA_QUAL)) - qual |= ct->size; - else if (ctype_isxattrib(info, CTA_ALIGN) && !(qual & CTFP_ALIGNED)) - qual |= CTFP_ALIGNED + CTALIGN(ct->size); - } else { - if (!(qual & CTFP_ALIGNED)) qual |= (info & CTF_ALIGN); - qual |= (info & ~(CTF_ALIGN|CTMASK_CID)); - lua_assert(ctype_hassize(info) || ctype_isfunc(info)); - *szp = ctype_isfunc(info) ? CTSIZE_INVALID : ct->size; - break; - } - ct = ctype_get(cts, ctype_cid(info)); - } - return qual; -} - -/* Get ctype metamethod. */ -cTValue *lj_ctype_meta(CTState *cts, CTypeID id, MMS mm) -{ - CType *ct = ctype_get(cts, id); - cTValue *tv; - while (ctype_isattrib(ct->info) || ctype_isref(ct->info)) { - id = ctype_cid(ct->info); - ct = ctype_get(cts, id); - } - if (ctype_isptr(ct->info) && - ctype_isfunc(ctype_get(cts, ctype_cid(ct->info))->info)) - tv = lj_tab_getstr(cts->miscmap, &cts->g->strempty); - else - tv = lj_tab_getinth(cts->miscmap, -(int32_t)id); - if (tv && tvistab(tv) && - (tv = lj_tab_getstr(tabV(tv), mmname_str(cts->g, mm))) && !tvisnil(tv)) - return tv; - return NULL; -} - -/* -- C type representation ----------------------------------------------- */ - -/* Fixed max. length of a C type representation. */ -#define CTREPR_MAX 512 - -typedef struct CTRepr { - char *pb, *pe; - CTState *cts; - lua_State *L; - int needsp; - int ok; - char buf[CTREPR_MAX]; -} CTRepr; - -/* Prepend string. */ -static void ctype_prepstr(CTRepr *ctr, const char *str, MSize len) -{ - char *p = ctr->pb; - if (ctr->buf + len+1 > p) { ctr->ok = 0; return; } - if (ctr->needsp) *--p = ' '; - ctr->needsp = 1; - p -= len; - while (len-- > 0) p[len] = str[len]; - ctr->pb = p; -} - -#define ctype_preplit(ctr, str) ctype_prepstr((ctr), "" str, sizeof(str)-1) - -/* Prepend char. */ -static void ctype_prepc(CTRepr *ctr, int c) -{ - if (ctr->buf >= ctr->pb) { ctr->ok = 0; return; } - *--ctr->pb = c; -} - -/* Prepend number. */ -static void ctype_prepnum(CTRepr *ctr, uint32_t n) -{ - char *p = ctr->pb; - if (ctr->buf + 10+1 > p) { ctr->ok = 0; return; } - do { *--p = (char)('0' + n % 10); } while (n /= 10); - ctr->pb = p; - ctr->needsp = 0; -} - -/* Append char. */ -static void ctype_appc(CTRepr *ctr, int c) -{ - if (ctr->pe >= ctr->buf + CTREPR_MAX) { ctr->ok = 0; return; } - *ctr->pe++ = c; -} - -/* Append number. */ -static void ctype_appnum(CTRepr *ctr, uint32_t n) -{ - char buf[10]; - char *p = buf+sizeof(buf); - char *q = ctr->pe; - if (q > ctr->buf + CTREPR_MAX - 10) { ctr->ok = 0; return; } - do { *--p = (char)('0' + n % 10); } while (n /= 10); - do { *q++ = *p++; } while (p < buf+sizeof(buf)); - ctr->pe = q; -} - -/* Prepend qualifiers. */ -static void ctype_prepqual(CTRepr *ctr, CTInfo info) -{ - if ((info & CTF_VOLATILE)) ctype_preplit(ctr, "volatile"); - if ((info & CTF_CONST)) ctype_preplit(ctr, "const"); -} - -/* Prepend named type. */ -static void ctype_preptype(CTRepr *ctr, CType *ct, CTInfo qual, const char *t) -{ - if (gcref(ct->name)) { - GCstr *str = gco2str(gcref(ct->name)); - ctype_prepstr(ctr, strdata(str), str->len); - } else { - if (ctr->needsp) ctype_prepc(ctr, ' '); - ctype_prepnum(ctr, ctype_typeid(ctr->cts, ct)); - ctr->needsp = 1; - } - ctype_prepstr(ctr, t, (MSize)strlen(t)); - ctype_prepqual(ctr, qual); -} - -static void ctype_repr(CTRepr *ctr, CTypeID id) -{ - CType *ct = ctype_get(ctr->cts, id); - CTInfo qual = 0; - int ptrto = 0; - for (;;) { - CTInfo info = ct->info; - CTSize size = ct->size; - switch (ctype_type(info)) { - case CT_NUM: - if ((info & CTF_BOOL)) { - ctype_preplit(ctr, "bool"); - } else if ((info & CTF_FP)) { - if (size == sizeof(double)) ctype_preplit(ctr, "double"); - else if (size == sizeof(float)) ctype_preplit(ctr, "float"); - else ctype_preplit(ctr, "long double"); - } else if (size == 1) { - if (!((info ^ CTF_UCHAR) & CTF_UNSIGNED)) ctype_preplit(ctr, "char"); - else if (CTF_UCHAR) ctype_preplit(ctr, "signed char"); - else ctype_preplit(ctr, "unsigned char"); - } else if (size < 8) { - if (size == 4) ctype_preplit(ctr, "int"); - else ctype_preplit(ctr, "short"); - if ((info & CTF_UNSIGNED)) ctype_preplit(ctr, "unsigned"); - } else { - ctype_preplit(ctr, "_t"); - ctype_prepnum(ctr, size*8); - ctype_preplit(ctr, "int"); - if ((info & CTF_UNSIGNED)) ctype_prepc(ctr, 'u'); - } - ctype_prepqual(ctr, (qual|info)); - return; - case CT_VOID: - ctype_preplit(ctr, "void"); - ctype_prepqual(ctr, (qual|info)); - return; - case CT_STRUCT: - ctype_preptype(ctr, ct, qual, (info & CTF_UNION) ? "union" : "struct"); - return; - case CT_ENUM: - if (id == CTID_CTYPEID) { - ctype_preplit(ctr, "ctype"); - return; - } - ctype_preptype(ctr, ct, qual, "enum"); - return; - case CT_ATTRIB: - if (ctype_attrib(info) == CTA_QUAL) qual |= size; - break; - case CT_PTR: - if ((info & CTF_REF)) { - ctype_prepc(ctr, '&'); - } else { - ctype_prepqual(ctr, (qual|info)); - if (LJ_64 && size == 4) ctype_preplit(ctr, "__ptr32"); - ctype_prepc(ctr, '*'); - } - qual = 0; - ptrto = 1; - ctr->needsp = 1; - break; - case CT_ARRAY: - if (ctype_isrefarray(info)) { - ctr->needsp = 1; - if (ptrto) { ptrto = 0; ctype_prepc(ctr, '('); ctype_appc(ctr, ')'); } - ctype_appc(ctr, '['); - if (size != CTSIZE_INVALID) { - CTSize csize = ctype_child(ctr->cts, ct)->size; - ctype_appnum(ctr, csize ? size/csize : 0); - } else if ((info & CTF_VLA)) { - ctype_appc(ctr, '?'); - } - ctype_appc(ctr, ']'); - } else if ((info & CTF_COMPLEX)) { - if (size == 2*sizeof(float)) ctype_preplit(ctr, "float"); - ctype_preplit(ctr, "complex"); - return; - } else { - ctype_preplit(ctr, ")))"); - ctype_prepnum(ctr, size); - ctype_preplit(ctr, "__attribute__((vector_size("); - } - break; - case CT_FUNC: - ctr->needsp = 1; - if (ptrto) { ptrto = 0; ctype_prepc(ctr, '('); ctype_appc(ctr, ')'); } - ctype_appc(ctr, '('); - ctype_appc(ctr, ')'); - break; - default: - lua_assert(0); - break; - } - ct = ctype_get(ctr->cts, ctype_cid(info)); - } -} - -/* Return a printable representation of a C type. */ -GCstr *lj_ctype_repr(lua_State *L, CTypeID id, GCstr *name) -{ - global_State *g = G(L); - CTRepr ctr; - ctr.pb = ctr.pe = &ctr.buf[CTREPR_MAX/2]; - ctr.cts = ctype_ctsG(g); - ctr.L = L; - ctr.ok = 1; - ctr.needsp = 0; - if (name) ctype_prepstr(&ctr, strdata(name), name->len); - ctype_repr(&ctr, id); - if (LJ_UNLIKELY(!ctr.ok)) return lj_str_newlit(L, "?"); - return lj_str_new(L, ctr.pb, ctr.pe - ctr.pb); -} - -/* Convert int64_t/uint64_t to string with 'LL' or 'ULL' suffix. */ -GCstr *lj_ctype_repr_int64(lua_State *L, uint64_t n, int isunsigned) -{ - char buf[1+20+3]; - char *p = buf+sizeof(buf); - int sign = 0; - *--p = 'L'; *--p = 'L'; - if (isunsigned) { - *--p = 'U'; - } else if ((int64_t)n < 0) { - n = (uint64_t)-(int64_t)n; - sign = 1; - } - do { *--p = (char)('0' + n % 10); } while (n /= 10); - if (sign) *--p = '-'; - return lj_str_new(L, p, (size_t)(buf+sizeof(buf)-p)); -} - -/* Convert complex to string with 'i' or 'I' suffix. */ -GCstr *lj_ctype_repr_complex(lua_State *L, void *sp, CTSize size) -{ - char buf[2*LJ_STR_NUMBUF+2+1]; - TValue re, im; - size_t len; - if (size == 2*sizeof(double)) { - re.n = *(double *)sp; im.n = ((double *)sp)[1]; - } else { - re.n = (double)*(float *)sp; im.n = (double)((float *)sp)[1]; - } - len = lj_str_bufnum(buf, &re); - if (!(im.u32.hi & 0x80000000u) || im.n != im.n) buf[len++] = '+'; - len += lj_str_bufnum(buf+len, &im); - buf[len] = buf[len-1] >= 'a' ? 'I' : 'i'; - return lj_str_new(L, buf, len+1); -} - -/* -- C type state -------------------------------------------------------- */ - -/* Initialize C type table and state. */ -CTState *lj_ctype_init(lua_State *L) -{ - CTState *cts = lj_mem_newt(L, sizeof(CTState), CTState); - CType *ct = lj_mem_newvec(L, CTTYPETAB_MIN, CType); - const char *name = lj_ctype_typenames; - CTypeID id; - memset(cts, 0, sizeof(CTState)); - cts->tab = ct; - cts->sizetab = CTTYPETAB_MIN; - cts->top = CTTYPEINFO_NUM; - cts->L = NULL; - cts->g = G(L); - for (id = 0; id < CTTYPEINFO_NUM; id++, ct++) { - CTInfo info = lj_ctype_typeinfo[id]; - ct->size = (CTSize)((int32_t)(info << 16) >> 26); - ct->info = info & 0xffff03ffu; - ct->sib = 0; - if (ctype_type(info) == CT_KW || ctype_istypedef(info)) { - size_t len = strlen(name); - GCstr *str = lj_str_new(L, name, len); - ctype_setname(ct, str); - name += len+1; - lj_ctype_addname(cts, ct, id); - } else { - setgcrefnull(ct->name); - ct->next = 0; - if (!ctype_isenum(info)) ctype_addtype(cts, ct, id); - } - } - setmref(G(L)->ctype_state, cts); - return cts; -} - -/* Free C type table and state. */ -void lj_ctype_freestate(global_State *g) -{ - CTState *cts = ctype_ctsG(g); - if (cts) { - lj_ccallback_mcode_free(cts); - lj_mem_freevec(g, cts->tab, cts->sizetab, CType); - lj_mem_freevec(g, cts->cb.cbid, cts->cb.sizeid, CTypeID1); - lj_mem_freet(g, cts); - } -} - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ctype.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_ctype.h deleted file mode 100644 index ff8ee069b..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ctype.h +++ /dev/null @@ -1,461 +0,0 @@ -/* -** C type management. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_CTYPE_H -#define _LJ_CTYPE_H - -#include "lj_obj.h" -#include "lj_gc.h" - -#if LJ_HASFFI - -/* -- C type definitions -------------------------------------------------- */ - -/* C type numbers. Highest 4 bits of C type info. ORDER CT. */ -enum { - /* Externally visible types. */ - CT_NUM, /* Integer or floating-point numbers. */ - CT_STRUCT, /* Struct or union. */ - CT_PTR, /* Pointer or reference. */ - CT_ARRAY, /* Array or complex type. */ - CT_MAYCONVERT = CT_ARRAY, - CT_VOID, /* Void type. */ - CT_ENUM, /* Enumeration. */ - CT_HASSIZE = CT_ENUM, /* Last type where ct->size holds the actual size. */ - CT_FUNC, /* Function. */ - CT_TYPEDEF, /* Typedef. */ - CT_ATTRIB, /* Miscellaneous attributes. */ - /* Internal element types. */ - CT_FIELD, /* Struct/union field or function parameter. */ - CT_BITFIELD, /* Struct/union bitfield. */ - CT_CONSTVAL, /* Constant value. */ - CT_EXTERN, /* External reference. */ - CT_KW /* Keyword. */ -}; - -LJ_STATIC_ASSERT(((int)CT_PTR & (int)CT_ARRAY) == CT_PTR); -LJ_STATIC_ASSERT(((int)CT_STRUCT & (int)CT_ARRAY) == CT_STRUCT); - -/* -** ---------- info ------------ -** |type flags... A cid | size | sib | next | name | -** +----------------------------+--------+-------+-------+-------+-- -** |NUM BFvcUL.. A | size | | type | | -** |STRUCT ..vcU..V A | size | field | name? | name? | -** |PTR ..vcR... A cid | size | | type | | -** |ARRAY VCvc...V A cid | size | | type | | -** |VOID ..vc.... A | size | | type | | -** |ENUM A cid | size | const | name? | name? | -** |FUNC ....VS.. cc cid | nargs | field | name? | name? | -** |TYPEDEF cid | | | name | name | -** |ATTRIB attrnum cid | attr | sib? | type? | | -** |FIELD cid | offset | field | | name? | -** |BITFIELD B.vcU csz bsz pos | offset | field | | name? | -** |CONSTVAL c cid | value | const | name | name | -** |EXTERN cid | | sib? | name | name | -** |KW tok | size | | name | name | -** +----------------------------+--------+-------+-------+-------+-- -** ^^ ^^--- bits used for C type conversion dispatch -*/ - -/* C type info flags. TFFArrrr */ -#define CTF_BOOL 0x08000000u /* Boolean: NUM, BITFIELD. */ -#define CTF_FP 0x04000000u /* Floating-point: NUM. */ -#define CTF_CONST 0x02000000u /* Const qualifier. */ -#define CTF_VOLATILE 0x01000000u /* Volatile qualifier. */ -#define CTF_UNSIGNED 0x00800000u /* Unsigned: NUM, BITFIELD. */ -#define CTF_LONG 0x00400000u /* Long: NUM. */ -#define CTF_VLA 0x00100000u /* Variable-length: ARRAY, STRUCT. */ -#define CTF_REF 0x00800000u /* Reference: PTR. */ -#define CTF_VECTOR 0x08000000u /* Vector: ARRAY. */ -#define CTF_COMPLEX 0x04000000u /* Complex: ARRAY. */ -#define CTF_UNION 0x00800000u /* Union: STRUCT. */ -#define CTF_VARARG 0x00800000u /* Vararg: FUNC. */ -#define CTF_SSEREGPARM 0x00400000u /* SSE register parameters: FUNC. */ - -#define CTF_QUAL (CTF_CONST|CTF_VOLATILE) -#define CTF_ALIGN (CTMASK_ALIGN< 0 ? CTF_UNSIGNED : 0) - -/* Flags used in parser. .F.Ammvf cp->attr */ -#define CTFP_ALIGNED 0x00000001u /* cp->attr + ALIGN */ -#define CTFP_PACKED 0x00000002u /* cp->attr */ -/* ...C...f cp->fattr */ -#define CTFP_CCONV 0x00000001u /* cp->fattr + CCONV/[SSE]REGPARM */ - -/* C type info bitfields. */ -#define CTMASK_CID 0x0000ffffu /* Max. 65536 type IDs. */ -#define CTMASK_NUM 0xf0000000u /* Max. 16 type numbers. */ -#define CTSHIFT_NUM 28 -#define CTMASK_ALIGN 15 /* Max. alignment is 2^15. */ -#define CTSHIFT_ALIGN 16 -#define CTMASK_ATTRIB 255 /* Max. 256 attributes. */ -#define CTSHIFT_ATTRIB 16 -#define CTMASK_CCONV 3 /* Max. 4 calling conventions. */ -#define CTSHIFT_CCONV 16 -#define CTMASK_REGPARM 3 /* Max. 0-3 regparms. */ -#define CTSHIFT_REGPARM 18 -/* Bitfields only used in parser. */ -#define CTMASK_VSIZEP 15 /* Max. vector size is 2^15. */ -#define CTSHIFT_VSIZEP 4 -#define CTMASK_MSIZEP 255 /* Max. type size (via mode) is 128. */ -#define CTSHIFT_MSIZEP 8 - -/* Info bits for BITFIELD. Max. size of bitfield is 64 bits. */ -#define CTBSZ_MAX 32 /* Max. size of bitfield is 32 bit. */ -#define CTBSZ_FIELD 127 /* Temp. marker for regular field. */ -#define CTMASK_BITPOS 127 -#define CTMASK_BITBSZ 127 -#define CTMASK_BITCSZ 127 -#define CTSHIFT_BITPOS 0 -#define CTSHIFT_BITBSZ 8 -#define CTSHIFT_BITCSZ 16 - -#define CTF_INSERT(info, field, val) \ - info = (info & ~(CTMASK_##field<> CTSHIFT_NUM) -#define ctype_cid(info) ((CTypeID)((info) & CTMASK_CID)) -#define ctype_align(info) (((info) >> CTSHIFT_ALIGN) & CTMASK_ALIGN) -#define ctype_attrib(info) (((info) >> CTSHIFT_ATTRIB) & CTMASK_ATTRIB) -#define ctype_bitpos(info) (((info) >> CTSHIFT_BITPOS) & CTMASK_BITPOS) -#define ctype_bitbsz(info) (((info) >> CTSHIFT_BITBSZ) & CTMASK_BITBSZ) -#define ctype_bitcsz(info) (((info) >> CTSHIFT_BITCSZ) & CTMASK_BITCSZ) -#define ctype_vsizeP(info) (((info) >> CTSHIFT_VSIZEP) & CTMASK_VSIZEP) -#define ctype_msizeP(info) (((info) >> CTSHIFT_MSIZEP) & CTMASK_MSIZEP) -#define ctype_cconv(info) (((info) >> CTSHIFT_CCONV) & CTMASK_CCONV) - -/* Simple type checks. */ -#define ctype_isnum(info) (ctype_type((info)) == CT_NUM) -#define ctype_isvoid(info) (ctype_type((info)) == CT_VOID) -#define ctype_isptr(info) (ctype_type((info)) == CT_PTR) -#define ctype_isarray(info) (ctype_type((info)) == CT_ARRAY) -#define ctype_isstruct(info) (ctype_type((info)) == CT_STRUCT) -#define ctype_isfunc(info) (ctype_type((info)) == CT_FUNC) -#define ctype_isenum(info) (ctype_type((info)) == CT_ENUM) -#define ctype_istypedef(info) (ctype_type((info)) == CT_TYPEDEF) -#define ctype_isattrib(info) (ctype_type((info)) == CT_ATTRIB) -#define ctype_isfield(info) (ctype_type((info)) == CT_FIELD) -#define ctype_isbitfield(info) (ctype_type((info)) == CT_BITFIELD) -#define ctype_isconstval(info) (ctype_type((info)) == CT_CONSTVAL) -#define ctype_isextern(info) (ctype_type((info)) == CT_EXTERN) -#define ctype_hassize(info) (ctype_type((info)) <= CT_HASSIZE) - -/* Combined type and flag checks. */ -#define ctype_isinteger(info) \ - (((info) & (CTMASK_NUM|CTF_BOOL|CTF_FP)) == CTINFO(CT_NUM, 0)) -#define ctype_isinteger_or_bool(info) \ - (((info) & (CTMASK_NUM|CTF_FP)) == CTINFO(CT_NUM, 0)) -#define ctype_isbool(info) \ - (((info) & (CTMASK_NUM|CTF_BOOL)) == CTINFO(CT_NUM, CTF_BOOL)) -#define ctype_isfp(info) \ - (((info) & (CTMASK_NUM|CTF_FP)) == CTINFO(CT_NUM, CTF_FP)) - -#define ctype_ispointer(info) \ - ((ctype_type(info) >> 1) == (CT_PTR >> 1)) /* Pointer or array. */ -#define ctype_isref(info) \ - (((info) & (CTMASK_NUM|CTF_REF)) == CTINFO(CT_PTR, CTF_REF)) - -#define ctype_isrefarray(info) \ - (((info) & (CTMASK_NUM|CTF_VECTOR|CTF_COMPLEX)) == CTINFO(CT_ARRAY, 0)) -#define ctype_isvector(info) \ - (((info) & (CTMASK_NUM|CTF_VECTOR)) == CTINFO(CT_ARRAY, CTF_VECTOR)) -#define ctype_iscomplex(info) \ - (((info) & (CTMASK_NUM|CTF_COMPLEX)) == CTINFO(CT_ARRAY, CTF_COMPLEX)) - -#define ctype_isvltype(info) \ - (((info) & ((CTMASK_NUM|CTF_VLA) - (2u<") _(STRING, "") \ - _(INTEGER, "") _(EOF, "") \ - _(OROR, "||") _(ANDAND, "&&") _(EQ, "==") _(NE, "!=") \ - _(LE, "<=") _(GE, ">=") _(SHL, "<<") _(SHR, ">>") _(DEREF, "->") - -/* Simple declaration specifiers. */ -#define CDSDEF(_) \ - _(VOID) _(BOOL) _(CHAR) _(INT) _(FP) \ - _(LONG) _(LONGLONG) _(SHORT) _(COMPLEX) _(SIGNED) _(UNSIGNED) \ - _(CONST) _(VOLATILE) _(RESTRICT) _(INLINE) \ - _(TYPEDEF) _(EXTERN) _(STATIC) _(AUTO) _(REGISTER) - -/* C keywords. */ -#define CKWDEF(_) \ - CDSDEF(_) _(EXTENSION) _(ASM) _(ATTRIBUTE) \ - _(DECLSPEC) _(CCDECL) _(PTRSZ) \ - _(STRUCT) _(UNION) _(ENUM) \ - _(SIZEOF) _(ALIGNOF) - -/* C token numbers. */ -enum { - CTOK_OFS = 255, -#define CTOKNUM(name, sym) CTOK_##name, -#define CKWNUM(name) CTOK_##name, -CTOKDEF(CTOKNUM) -CKWDEF(CKWNUM) -#undef CTOKNUM -#undef CKWNUM - CTOK_FIRSTDECL = CTOK_VOID, - CTOK_FIRSTSCL = CTOK_TYPEDEF, - CTOK_LASTDECLFLAG = CTOK_REGISTER, - CTOK_LASTDECL = CTOK_ENUM -}; - -/* Declaration specifier flags. */ -enum { -#define CDSFLAG(name) CDF_##name = (1u << (CTOK_##name - CTOK_FIRSTDECL)), -CDSDEF(CDSFLAG) -#undef CDSFLAG - CDF__END -}; - -#define CDF_SCL (CDF_TYPEDEF|CDF_EXTERN|CDF_STATIC|CDF_AUTO|CDF_REGISTER) - -/* -- C type management --------------------------------------------------- */ - -#define ctype_ctsG(g) (mref((g)->ctype_state, CTState)) - -/* Get C type state. */ -static LJ_AINLINE CTState *ctype_cts(lua_State *L) -{ - CTState *cts = ctype_ctsG(G(L)); - cts->L = L; /* Save L for errors and allocations. */ - return cts; -} - -/* Save and restore state of C type table. */ -#define LJ_CTYPE_SAVE(cts) CTState savects_ = *(cts) -#define LJ_CTYPE_RESTORE(cts) \ - ((cts)->top = savects_.top, \ - memcpy((cts)->hash, savects_.hash, sizeof(savects_.hash))) - -/* Check C type ID for validity when assertions are enabled. */ -static LJ_AINLINE CTypeID ctype_check(CTState *cts, CTypeID id) -{ - lua_assert(id > 0 && id < cts->top); UNUSED(cts); - return id; -} - -/* Get C type for C type ID. */ -static LJ_AINLINE CType *ctype_get(CTState *cts, CTypeID id) -{ - return &cts->tab[ctype_check(cts, id)]; -} - -/* Get C type ID for a C type. */ -#define ctype_typeid(cts, ct) ((CTypeID)((ct) - (cts)->tab)) - -/* Get child C type. */ -static LJ_AINLINE CType *ctype_child(CTState *cts, CType *ct) -{ - lua_assert(!(ctype_isvoid(ct->info) || ctype_isstruct(ct->info) || - ctype_isbitfield(ct->info))); /* These don't have children. */ - return ctype_get(cts, ctype_cid(ct->info)); -} - -/* Get raw type for a C type ID. */ -static LJ_AINLINE CType *ctype_raw(CTState *cts, CTypeID id) -{ - CType *ct = ctype_get(cts, id); - while (ctype_isattrib(ct->info)) ct = ctype_child(cts, ct); - return ct; -} - -/* Get raw type of the child of a C type. */ -static LJ_AINLINE CType *ctype_rawchild(CTState *cts, CType *ct) -{ - do { ct = ctype_child(cts, ct); } while (ctype_isattrib(ct->info)); - return ct; -} - -/* Set the name of a C type table element. */ -static LJ_AINLINE void ctype_setname(CType *ct, GCstr *s) -{ - /* NOBARRIER: mark string as fixed -- the C type table is never collected. */ - fixstring(s); - setgcref(ct->name, obj2gco(s)); -} - -LJ_FUNC CTypeID lj_ctype_new(CTState *cts, CType **ctp); -LJ_FUNC CTypeID lj_ctype_intern(CTState *cts, CTInfo info, CTSize size); -LJ_FUNC void lj_ctype_addname(CTState *cts, CType *ct, CTypeID id); -LJ_FUNC CTypeID lj_ctype_getname(CTState *cts, CType **ctp, GCstr *name, - uint32_t tmask); -LJ_FUNC CType *lj_ctype_getfieldq(CTState *cts, CType *ct, GCstr *name, - CTSize *ofs, CTInfo *qual); -#define lj_ctype_getfield(cts, ct, name, ofs) \ - lj_ctype_getfieldq((cts), (ct), (name), (ofs), NULL) -LJ_FUNC CType *lj_ctype_rawref(CTState *cts, CTypeID id); -LJ_FUNC CTSize lj_ctype_size(CTState *cts, CTypeID id); -LJ_FUNC CTSize lj_ctype_vlsize(CTState *cts, CType *ct, CTSize nelem); -LJ_FUNC CTInfo lj_ctype_info(CTState *cts, CTypeID id, CTSize *szp); -LJ_FUNC cTValue *lj_ctype_meta(CTState *cts, CTypeID id, MMS mm); -LJ_FUNC GCstr *lj_ctype_repr(lua_State *L, CTypeID id, GCstr *name); -LJ_FUNC GCstr *lj_ctype_repr_int64(lua_State *L, uint64_t n, int isunsigned); -LJ_FUNC GCstr *lj_ctype_repr_complex(lua_State *L, void *sp, CTSize size); -LJ_FUNC CTState *lj_ctype_init(lua_State *L); -LJ_FUNC void lj_ctype_freestate(global_State *g); - -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_debug.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_debug.c deleted file mode 100644 index 4653a4ec1..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_debug.c +++ /dev/null @@ -1,603 +0,0 @@ -/* -** Debugging and introspection. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_debug_c -#define LUA_CORE - -#include "lj_obj.h" -#include "lj_err.h" -#include "lj_debug.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_state.h" -#include "lj_frame.h" -#include "lj_bc.h" -#if LJ_HASJIT -#include "lj_jit.h" -#endif - -/* -- Frames -------------------------------------------------------------- */ - -/* Get frame corresponding to a level. */ -cTValue *lj_debug_frame(lua_State *L, int level, int *size) -{ - cTValue *frame, *nextframe, *bot = tvref(L->stack); - /* Traverse frames backwards. */ - for (nextframe = frame = L->base-1; frame > bot; ) { - if (frame_gc(frame) == obj2gco(L)) - level++; /* Skip dummy frames. See lj_meta_call(). */ - if (level-- == 0) { - *size = (int)(nextframe - frame); - return frame; /* Level found. */ - } - nextframe = frame; - if (frame_islua(frame)) { - frame = frame_prevl(frame); - } else { - if (frame_isvarg(frame)) - level++; /* Skip vararg pseudo-frame. */ - frame = frame_prevd(frame); - } - } - *size = level; - return NULL; /* Level not found. */ -} - -/* Invalid bytecode position. */ -#define NO_BCPOS (~(BCPos)0) - -/* Return bytecode position for function/frame or NO_BCPOS. */ -static BCPos debug_framepc(lua_State *L, GCfunc *fn, cTValue *nextframe) -{ - const BCIns *ins; - GCproto *pt; - BCPos pos; - lua_assert(fn->c.gct == ~LJ_TFUNC || fn->c.gct == ~LJ_TTHREAD); - if (!isluafunc(fn)) { /* Cannot derive a PC for non-Lua functions. */ - return NO_BCPOS; - } else if (nextframe == NULL) { /* Lua function on top. */ - void *cf = cframe_raw(L->cframe); - if (cf == NULL || (char *)cframe_pc(cf) == (char *)cframe_L(cf)) - return NO_BCPOS; - ins = cframe_pc(cf); /* Only happens during error/hook handling. */ - } else { - if (frame_islua(nextframe)) { - ins = frame_pc(nextframe); - } else if (frame_iscont(nextframe)) { - ins = frame_contpc(nextframe); - } else { - /* Lua function below errfunc/gc/hook: find cframe to get the PC. */ - void *cf = cframe_raw(L->cframe); - TValue *f = L->base-1; - for (;;) { - if (cf == NULL) - return NO_BCPOS; - while (cframe_nres(cf) < 0) { - if (f >= restorestack(L, -cframe_nres(cf))) - break; - cf = cframe_raw(cframe_prev(cf)); - if (cf == NULL) - return NO_BCPOS; - } - if (f < nextframe) - break; - if (frame_islua(f)) { - f = frame_prevl(f); - } else { - if (frame_isc(f)) - cf = cframe_raw(cframe_prev(cf)); - f = frame_prevd(f); - } - } - ins = cframe_pc(cf); - } - } - pt = funcproto(fn); - pos = proto_bcpos(pt, ins) - 1; -#if LJ_HASJIT - if (pos > pt->sizebc) { /* Undo the effects of lj_trace_exit for JLOOP. */ - GCtrace *T = (GCtrace *)((char *)(ins-1) - offsetof(GCtrace, startins)); - lua_assert(bc_isret(bc_op(ins[-1]))); - pos = proto_bcpos(pt, mref(T->startpc, const BCIns)); - } -#endif - return pos; -} - -/* -- Line numbers -------------------------------------------------------- */ - -/* Get line number for a bytecode position. */ -BCLine LJ_FASTCALL lj_debug_line(GCproto *pt, BCPos pc) -{ - const void *lineinfo = proto_lineinfo(pt); - if (pc <= pt->sizebc && lineinfo) { - BCLine first = pt->firstline; - if (pc == pt->sizebc) return first + pt->numline; - if (pc-- == 0) return first; - if (pt->numline < 256) - return first + (BCLine)((const uint8_t *)lineinfo)[pc]; - else if (pt->numline < 65536) - return first + (BCLine)((const uint16_t *)lineinfo)[pc]; - else - return first + (BCLine)((const uint32_t *)lineinfo)[pc]; - } - return 0; -} - -/* Get line number for function/frame. */ -static BCLine debug_frameline(lua_State *L, GCfunc *fn, cTValue *nextframe) -{ - BCPos pc = debug_framepc(L, fn, nextframe); - if (pc != NO_BCPOS) { - GCproto *pt = funcproto(fn); - lua_assert(pc <= pt->sizebc); - return lj_debug_line(pt, pc); - } - return -1; -} - -/* -- Variable names ------------------------------------------------------ */ - -/* Read ULEB128 value. */ -static uint32_t debug_read_uleb128(const uint8_t **pp) -{ - const uint8_t *p = *pp; - uint32_t v = *p++; - if (LJ_UNLIKELY(v >= 0x80)) { - int sh = 0; - v &= 0x7f; - do { v |= ((*p & 0x7f) << (sh += 7)); } while (*p++ >= 0x80); - } - *pp = p; - return v; -} - -/* Get name of a local variable from slot number and PC. */ -static const char *debug_varname(const GCproto *pt, BCPos pc, BCReg slot) -{ - const uint8_t *p = proto_varinfo(pt); - if (p) { - BCPos lastpc = 0; - for (;;) { - const char *name = (const char *)p; - uint32_t vn = *p++; - BCPos startpc, endpc; - if (vn < VARNAME__MAX) { - if (vn == VARNAME_END) break; /* End of varinfo. */ - } else { - while (*p++) ; /* Skip over variable name string. */ - } - lastpc = startpc = lastpc + debug_read_uleb128(&p); - if (startpc > pc) break; - endpc = startpc + debug_read_uleb128(&p); - if (pc < endpc && slot-- == 0) { - if (vn < VARNAME__MAX) { -#define VARNAMESTR(name, str) str "\0" - name = VARNAMEDEF(VARNAMESTR); -#undef VARNAMESTR - if (--vn) while (*name++ || --vn) ; - } - return name; - } - } - } - return NULL; -} - -/* Get name of local variable from 1-based slot number and function/frame. */ -static TValue *debug_localname(lua_State *L, const lua_Debug *ar, - const char **name, BCReg slot1) -{ - uint32_t offset = (uint32_t)ar->i_ci & 0xffff; - uint32_t size = (uint32_t)ar->i_ci >> 16; - TValue *frame = tvref(L->stack) + offset; - TValue *nextframe = size ? frame + size : NULL; - GCfunc *fn = frame_func(frame); - BCPos pc = debug_framepc(L, fn, nextframe); - if (!nextframe) nextframe = L->top; - if ((int)slot1 < 0) { /* Negative slot number is for varargs. */ - if (pc != NO_BCPOS) { - GCproto *pt = funcproto(fn); - if ((pt->flags & PROTO_VARARG)) { - slot1 = pt->numparams + (BCReg)(-(int)slot1); - if (frame_isvarg(frame)) { /* Vararg frame has been set up? (pc!=0) */ - nextframe = frame; - frame = frame_prevd(frame); - } - if (frame + slot1 < nextframe) { - *name = "(*vararg)"; - return frame+slot1; - } - } - } - return NULL; - } - if (pc != NO_BCPOS && - (*name = debug_varname(funcproto(fn), pc, slot1-1)) != NULL) - ; - else if (slot1 > 0 && frame + slot1 < nextframe) - *name = "(*temporary)"; - return frame+slot1; -} - -/* Get name of upvalue. */ -const char *lj_debug_uvname(GCproto *pt, uint32_t idx) -{ - const uint8_t *p = proto_uvinfo(pt); - lua_assert(idx < pt->sizeuv); - if (!p) return ""; - if (idx) while (*p++ || --idx) ; - return (const char *)p; -} - -/* Get name and value of upvalue. */ -const char *lj_debug_uvnamev(cTValue *o, uint32_t idx, TValue **tvp) -{ - if (tvisfunc(o)) { - GCfunc *fn = funcV(o); - if (isluafunc(fn)) { - GCproto *pt = funcproto(fn); - if (idx < pt->sizeuv) { - *tvp = uvval(&gcref(fn->l.uvptr[idx])->uv); - return lj_debug_uvname(pt, idx); - } - } else { - if (idx < fn->c.nupvalues) { - *tvp = &fn->c.upvalue[idx]; - return ""; - } - } - } - return NULL; -} - -/* Deduce name of an object from slot number and PC. */ -const char *lj_debug_slotname(GCproto *pt, const BCIns *ip, BCReg slot, - const char **name) -{ - const char *lname; -restart: - lname = debug_varname(pt, proto_bcpos(pt, ip), slot); - if (lname != NULL) { *name = lname; return "local"; } - while (--ip > proto_bc(pt)) { - BCIns ins = *ip; - BCOp op = bc_op(ins); - BCReg ra = bc_a(ins); - if (bcmode_a(op) == BCMbase) { - if (slot >= ra && (op != BC_KNIL || slot <= bc_d(ins))) - return NULL; - } else if (bcmode_a(op) == BCMdst && ra == slot) { - switch (bc_op(ins)) { - case BC_MOV: - if (ra == slot) { slot = bc_d(ins); goto restart; } - break; - case BC_GGET: - *name = strdata(gco2str(proto_kgc(pt, ~(ptrdiff_t)bc_d(ins)))); - return "global"; - case BC_TGETS: - *name = strdata(gco2str(proto_kgc(pt, ~(ptrdiff_t)bc_c(ins)))); - if (ip > proto_bc(pt)) { - BCIns insp = ip[-1]; - if (bc_op(insp) == BC_MOV && bc_a(insp) == ra+1 && - bc_d(insp) == bc_b(ins)) - return "method"; - } - return "field"; - case BC_UGET: - *name = lj_debug_uvname(pt, bc_d(ins)); - return "upvalue"; - default: - return NULL; - } - } - } - return NULL; -} - -/* Deduce function name from caller of a frame. */ -const char *lj_debug_funcname(lua_State *L, TValue *frame, const char **name) -{ - TValue *pframe; - GCfunc *fn; - BCPos pc; - if (frame <= tvref(L->stack)) - return NULL; - if (frame_isvarg(frame)) - frame = frame_prevd(frame); - pframe = frame_prev(frame); - fn = frame_func(pframe); - pc = debug_framepc(L, fn, frame); - if (pc != NO_BCPOS) { - GCproto *pt = funcproto(fn); - const BCIns *ip = &proto_bc(pt)[check_exp(pc < pt->sizebc, pc)]; - MMS mm = bcmode_mm(bc_op(*ip)); - if (mm == MM_call) { - BCReg slot = bc_a(*ip); - if (bc_op(*ip) == BC_ITERC) slot -= 3; - return lj_debug_slotname(pt, ip, slot, name); - } else if (mm != MM__MAX) { - *name = strdata(mmname_str(G(L), mm)); - return "metamethod"; - } - } - return NULL; -} - -/* -- Source code locations ----------------------------------------------- */ - -/* Generate shortened source name. */ -void lj_debug_shortname(char *out, GCstr *str) -{ - const char *src = strdata(str); - if (*src == '=') { - strncpy(out, src+1, LUA_IDSIZE); /* Remove first char. */ - out[LUA_IDSIZE-1] = '\0'; /* Ensures null termination. */ - } else if (*src == '@') { /* Output "source", or "...source". */ - size_t len = str->len-1; - src++; /* Skip the `@' */ - if (len >= LUA_IDSIZE) { - src += len-(LUA_IDSIZE-4); /* Get last part of file name. */ - *out++ = '.'; *out++ = '.'; *out++ = '.'; - } - strcpy(out, src); - } else { /* Output [string "string"]. */ - size_t len; /* Length, up to first control char. */ - for (len = 0; len < LUA_IDSIZE-12; len++) - if (((const unsigned char *)src)[len] < ' ') break; - strcpy(out, "[string \""); out += 9; - if (src[len] != '\0') { /* Must truncate? */ - if (len > LUA_IDSIZE-15) len = LUA_IDSIZE-15; - strncpy(out, src, len); out += len; - strcpy(out, "..."); out += 3; - } else { - strcpy(out, src); out += len; - } - strcpy(out, "\"]"); - } -} - -/* Add current location of a frame to error message. */ -void lj_debug_addloc(lua_State *L, const char *msg, - cTValue *frame, cTValue *nextframe) -{ - if (frame) { - GCfunc *fn = frame_func(frame); - if (isluafunc(fn)) { - BCLine line = debug_frameline(L, fn, nextframe); - if (line >= 0) { - char buf[LUA_IDSIZE]; - lj_debug_shortname(buf, proto_chunkname(funcproto(fn))); - lj_str_pushf(L, "%s:%d: %s", buf, line, msg); - return; - } - } - } - lj_str_pushf(L, "%s", msg); -} - -/* Push location string for a bytecode position to Lua stack. */ -void lj_debug_pushloc(lua_State *L, GCproto *pt, BCPos pc) -{ - GCstr *name = proto_chunkname(pt); - const char *s = strdata(name); - MSize i, len = name->len; - BCLine line = lj_debug_line(pt, pc); - if (*s == '@') { - s++; len--; - for (i = len; i > 0; i--) - if (s[i] == '/' || s[i] == '\\') { - s += i+1; - break; - } - lj_str_pushf(L, "%s:%d", s, line); - } else if (len > 40) { - lj_str_pushf(L, "%p:%d", pt, line); - } else if (*s == '=') { - lj_str_pushf(L, "%s:%d", s+1, line); - } else { - lj_str_pushf(L, "\"%s\":%d", s, line); - } -} - -/* -- Public debug API ---------------------------------------------------- */ - -/* lua_getupvalue() and lua_setupvalue() are in lj_api.c. */ - -LUA_API const char *lua_getlocal(lua_State *L, const lua_Debug *ar, int n) -{ - const char *name = NULL; - if (ar) { - TValue *o = debug_localname(L, ar, &name, (BCReg)n); - if (name) { - copyTV(L, L->top, o); - incr_top(L); - } - } else if (tvisfunc(L->top-1) && isluafunc(funcV(L->top-1))) { - name = debug_varname(funcproto(funcV(L->top-1)), 0, (BCReg)n-1); - } - return name; -} - -LUA_API const char *lua_setlocal(lua_State *L, const lua_Debug *ar, int n) -{ - const char *name = NULL; - TValue *o = debug_localname(L, ar, &name, (BCReg)n); - if (name) - copyTV(L, o, L->top-1); - L->top--; - return name; -} - -int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, int ext) -{ - int opt_f = 0, opt_L = 0; - TValue *frame = NULL; - TValue *nextframe = NULL; - GCfunc *fn; - if (*what == '>') { - TValue *func = L->top - 1; - api_check(L, tvisfunc(func)); - fn = funcV(func); - L->top--; - what++; - } else { - uint32_t offset = (uint32_t)ar->i_ci & 0xffff; - uint32_t size = (uint32_t)ar->i_ci >> 16; - lua_assert(offset != 0); - frame = tvref(L->stack) + offset; - if (size) nextframe = frame + size; - lua_assert(frame <= tvref(L->maxstack) && - (!nextframe || nextframe <= tvref(L->maxstack))); - fn = frame_func(frame); - lua_assert(fn->c.gct == ~LJ_TFUNC); - } - for (; *what; what++) { - if (*what == 'S') { - if (isluafunc(fn)) { - GCproto *pt = funcproto(fn); - BCLine firstline = pt->firstline; - GCstr *name = proto_chunkname(pt); - ar->source = strdata(name); - lj_debug_shortname(ar->short_src, name); - ar->linedefined = (int)firstline; - ar->lastlinedefined = (int)(firstline + pt->numline); - ar->what = firstline ? "Lua" : "main"; - } else { - ar->source = "=[C]"; - ar->short_src[0] = '['; - ar->short_src[1] = 'C'; - ar->short_src[2] = ']'; - ar->short_src[3] = '\0'; - ar->linedefined = -1; - ar->lastlinedefined = -1; - ar->what = "C"; - } - } else if (*what == 'l') { - ar->currentline = frame ? debug_frameline(L, fn, nextframe) : -1; - } else if (*what == 'u') { - ar->nups = fn->c.nupvalues; - if (ext) { - if (isluafunc(fn)) { - GCproto *pt = funcproto(fn); - ar->nparams = pt->numparams; - ar->isvararg = !!(pt->flags & PROTO_VARARG); - } else { - ar->nparams = 0; - ar->isvararg = 1; - } - } - } else if (*what == 'n') { - ar->namewhat = frame ? lj_debug_funcname(L, frame, &ar->name) : NULL; - if (ar->namewhat == NULL) { - ar->namewhat = ""; - ar->name = NULL; - } - } else if (*what == 'f') { - opt_f = 1; - } else if (*what == 'L') { - opt_L = 1; - } else { - return 0; /* Bad option. */ - } - } - if (opt_f) { - setfuncV(L, L->top, fn); - incr_top(L); - } - if (opt_L) { - if (isluafunc(fn)) { - GCtab *t = lj_tab_new(L, 0, 0); - GCproto *pt = funcproto(fn); - const void *lineinfo = proto_lineinfo(pt); - if (lineinfo) { - BCLine first = pt->firstline; - int sz = pt->numline < 256 ? 1 : pt->numline < 65536 ? 2 : 4; - MSize i, szl = pt->sizebc-1; - for (i = 0; i < szl; i++) { - BCLine line = first + - (sz == 1 ? (BCLine)((const uint8_t *)lineinfo)[i] : - sz == 2 ? (BCLine)((const uint16_t *)lineinfo)[i] : - (BCLine)((const uint32_t *)lineinfo)[i]); - setboolV(lj_tab_setint(L, t, line), 1); - } - } - settabV(L, L->top, t); - } else { - setnilV(L->top); - } - incr_top(L); - } - return 1; /* Ok. */ -} - -LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar) -{ - return lj_debug_getinfo(L, what, (lj_Debug *)ar, 0); -} - -LUA_API int lua_getstack(lua_State *L, int level, lua_Debug *ar) -{ - int size; - cTValue *frame = lj_debug_frame(L, level, &size); - if (frame) { - ar->i_ci = (size << 16) + (int)(frame - tvref(L->stack)); - return 1; - } else { - ar->i_ci = level - size; - return 0; - } -} - -/* Number of frames for the leading and trailing part of a traceback. */ -#define TRACEBACK_LEVELS1 12 -#define TRACEBACK_LEVELS2 10 - -LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1, const char *msg, - int level) -{ - int top = (int)(L->top - L->base); - int lim = TRACEBACK_LEVELS1; - lua_Debug ar; - if (msg) lua_pushfstring(L, "%s\n", msg); - lua_pushliteral(L, "stack traceback:"); - while (lua_getstack(L1, level++, &ar)) { - GCfunc *fn; - if (level > lim) { - if (!lua_getstack(L1, level + TRACEBACK_LEVELS2, &ar)) { - level--; - } else { - lua_pushliteral(L, "\n\t..."); - lua_getstack(L1, -10, &ar); - level = ar.i_ci - TRACEBACK_LEVELS2; - } - lim = 2147483647; - continue; - } - lua_getinfo(L1, "Snlf", &ar); - fn = funcV(L1->top-1); L1->top--; - if (isffunc(fn) && !*ar.namewhat) - lua_pushfstring(L, "\n\t[builtin#%d]:", fn->c.ffid); - else - lua_pushfstring(L, "\n\t%s:", ar.short_src); - if (ar.currentline > 0) - lua_pushfstring(L, "%d:", ar.currentline); - if (*ar.namewhat) { - lua_pushfstring(L, " in function " LUA_QS, ar.name); - } else { - if (*ar.what == 'm') { - lua_pushliteral(L, " in main chunk"); - } else if (*ar.what == 'C') { - lua_pushfstring(L, " at %p", fn->c.f); - } else { - lua_pushfstring(L, " in function <%s:%d>", - ar.short_src, ar.linedefined); - } - } - if ((int)(L->top - L->base) - top >= 15) - lua_concat(L, (int)(L->top - L->base) - top); - } - lua_concat(L, (int)(L->top - L->base) - top); -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_debug.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_debug.h deleted file mode 100644 index bec6b4f35..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_debug.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -** Debugging and introspection. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_DEBUG_H -#define _LJ_DEBUG_H - -#include "lj_obj.h" - -typedef struct lj_Debug { - /* Common fields. Must be in the same order as in lua.h. */ - int event; - const char *name; - const char *namewhat; - const char *what; - const char *source; - int currentline; - int nups; - int linedefined; - int lastlinedefined; - char short_src[LUA_IDSIZE]; - int i_ci; - /* Extended fields. Only valid if lj_debug_getinfo() is called with ext = 1.*/ - int nparams; - int isvararg; -} lj_Debug; - -LJ_FUNC cTValue *lj_debug_frame(lua_State *L, int level, int *size); -LJ_FUNC BCLine LJ_FASTCALL lj_debug_line(GCproto *pt, BCPos pc); -LJ_FUNC const char *lj_debug_uvname(GCproto *pt, uint32_t idx); -LJ_FUNC const char *lj_debug_uvnamev(cTValue *o, uint32_t idx, TValue **tvp); -LJ_FUNC const char *lj_debug_slotname(GCproto *pt, const BCIns *pc, - BCReg slot, const char **name); -LJ_FUNC const char *lj_debug_funcname(lua_State *L, TValue *frame, - const char **name); -LJ_FUNC void lj_debug_shortname(char *out, GCstr *str); -LJ_FUNC void lj_debug_addloc(lua_State *L, const char *msg, - cTValue *frame, cTValue *nextframe); -LJ_FUNC void lj_debug_pushloc(lua_State *L, GCproto *pt, BCPos pc); -LJ_FUNC int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, - int ext); - -/* Fixed internal variable names. */ -#define VARNAMEDEF(_) \ - _(FOR_IDX, "(for index)") \ - _(FOR_STOP, "(for limit)") \ - _(FOR_STEP, "(for step)") \ - _(FOR_GEN, "(for generator)") \ - _(FOR_STATE, "(for state)") \ - _(FOR_CTL, "(for control)") - -enum { - VARNAME_END, -#define VARNAMEENUM(name, str) VARNAME_##name, - VARNAMEDEF(VARNAMEENUM) -#undef VARNAMEENUM - VARNAME__MAX -}; - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_def.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_def.h deleted file mode 100644 index 47c6158c0..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_def.h +++ /dev/null @@ -1,349 +0,0 @@ -/* -** LuaJIT common internal definitions. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_DEF_H -#define _LJ_DEF_H - -#include "lua.h" - -#if defined(_MSC_VER) -/* MSVC is stuck in the last century and doesn't have C99's stdint.h. */ -typedef __int8 int8_t; -typedef __int16 int16_t; -typedef __int32 int32_t; -typedef __int64 int64_t; -typedef unsigned __int8 uint8_t; -typedef unsigned __int16 uint16_t; -typedef unsigned __int32 uint32_t; -typedef unsigned __int64 uint64_t; -#ifdef _WIN64 -typedef __int64 intptr_t; -typedef unsigned __int64 uintptr_t; -#else -typedef __int32 intptr_t; -typedef unsigned __int32 uintptr_t; -#endif -#elif defined(__symbian__) -/* Cough. */ -typedef signed char int8_t; -typedef short int int16_t; -typedef int int32_t; -typedef long long int64_t; -typedef unsigned char uint8_t; -typedef unsigned short int uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long long uint64_t; -typedef int intptr_t; -typedef unsigned int uintptr_t; -#else -#include -#endif - -/* Needed everywhere. */ -#include -#include - -/* Various VM limits. */ -#define LJ_MAX_MEM 0x7fffff00 /* Max. total memory allocation. */ -#define LJ_MAX_ALLOC LJ_MAX_MEM /* Max. individual allocation length. */ -#define LJ_MAX_STR LJ_MAX_MEM /* Max. string length. */ -#define LJ_MAX_UDATA LJ_MAX_MEM /* Max. userdata length. */ - -#define LJ_MAX_STRTAB (1<<26) /* Max. string table size. */ -#define LJ_MAX_HBITS 26 /* Max. hash bits. */ -#define LJ_MAX_ABITS 28 /* Max. bits of array key. */ -#define LJ_MAX_ASIZE ((1<<(LJ_MAX_ABITS-1))+1) /* Max. array part size. */ -#define LJ_MAX_COLOSIZE 16 /* Max. elems for colocated array. */ - -#define LJ_MAX_LINE LJ_MAX_MEM /* Max. source code line number. */ -#define LJ_MAX_XLEVEL 200 /* Max. syntactic nesting level. */ -#define LJ_MAX_BCINS (1<<26) /* Max. # of bytecode instructions. */ -#define LJ_MAX_SLOTS 250 /* Max. # of slots in a Lua func. */ -#define LJ_MAX_LOCVAR 200 /* Max. # of local variables. */ -#define LJ_MAX_UPVAL 249 /* Max. # of upvalues. */ - -#define LJ_MAX_IDXCHAIN 100 /* __index/__newindex chain limit. */ -#define LJ_STACK_EXTRA 5 /* Extra stack space (metamethods). */ - -#define LJ_NUM_CBPAGE 1 /* Number of FFI callback pages. */ - -/* Minimum table/buffer sizes. */ -#define LJ_MIN_GLOBAL 6 /* Min. global table size (hbits). */ -#define LJ_MIN_REGISTRY 2 /* Min. registry size (hbits). */ -#define LJ_MIN_STRTAB 256 /* Min. string table size (pow2). */ -#define LJ_MIN_SBUF 32 /* Min. string buffer length. */ -#define LJ_MIN_VECSZ 8 /* Min. size for growable vectors. */ -#define LJ_MIN_IRSZ 32 /* Min. size for growable IR. */ -#define LJ_MIN_K64SZ 16 /* Min. size for chained K64Array. */ - -/* JIT compiler limits. */ -#define LJ_MAX_JSLOTS 250 /* Max. # of stack slots for a trace. */ -#define LJ_MAX_PHI 64 /* Max. # of PHIs for a loop. */ -#define LJ_MAX_EXITSTUBGR 16 /* Max. # of exit stub groups. */ - -/* Various macros. */ -#ifndef UNUSED -#define UNUSED(x) ((void)(x)) /* to avoid warnings */ -#endif - -#define U64x(hi, lo) (((uint64_t)0x##hi << 32) + (uint64_t)0x##lo) -#define i32ptr(p) ((int32_t)(intptr_t)(void *)(p)) -#define u32ptr(p) ((uint32_t)(intptr_t)(void *)(p)) - -#define checki8(x) ((x) == (int32_t)(int8_t)(x)) -#define checku8(x) ((x) == (int32_t)(uint8_t)(x)) -#define checki16(x) ((x) == (int32_t)(int16_t)(x)) -#define checku16(x) ((x) == (int32_t)(uint16_t)(x)) -#define checki32(x) ((x) == (int32_t)(x)) -#define checku32(x) ((x) == (uint32_t)(x)) -#define checkptr32(x) ((uintptr_t)(x) == (uint32_t)(uintptr_t)(x)) - -/* Every half-decent C compiler transforms this into a rotate instruction. */ -#define lj_rol(x, n) (((x)<<(n)) | ((x)>>(-(int)(n)&(8*sizeof(x)-1)))) -#define lj_ror(x, n) (((x)<<(-(int)(n)&(8*sizeof(x)-1))) | ((x)>>(n))) - -/* A really naive Bloom filter. But sufficient for our needs. */ -typedef uintptr_t BloomFilter; -#define BLOOM_MASK (8*sizeof(BloomFilter) - 1) -#define bloombit(x) ((uintptr_t)1 << ((x) & BLOOM_MASK)) -#define bloomset(b, x) ((b) |= bloombit((x))) -#define bloomtest(b, x) ((b) & bloombit((x))) - -#if defined(__GNUC__) - -#define LJ_NORET __attribute__((noreturn)) -#define LJ_ALIGN(n) __attribute__((aligned(n))) -#define LJ_INLINE inline -#define LJ_AINLINE inline __attribute__((always_inline)) -#define LJ_NOINLINE __attribute__((noinline)) - -#if defined(__ELF__) || defined(__MACH__) -#if !((defined(__sun__) && defined(__svr4__)) || defined(__CELLOS_LV2__)) -#define LJ_NOAPI extern __attribute__((visibility("hidden"))) -#endif -#endif - -/* Note: it's only beneficial to use fastcall on x86 and then only for up to -** two non-FP args. The amalgamated compile covers all LJ_FUNC cases. Only -** indirect calls and related tail-called C functions are marked as fastcall. -*/ -#if defined(__i386__) -#define LJ_FASTCALL __attribute__((fastcall)) -#endif - -#define LJ_LIKELY(x) __builtin_expect(!!(x), 1) -#define LJ_UNLIKELY(x) __builtin_expect(!!(x), 0) - -#define lj_ffs(x) ((uint32_t)__builtin_ctz(x)) -/* Don't ask ... */ -#if defined(__INTEL_COMPILER) && (defined(__i386__) || defined(__x86_64__)) -static LJ_AINLINE uint32_t lj_fls(uint32_t x) -{ - uint32_t r; __asm__("bsrl %1, %0" : "=r" (r) : "rm" (x) : "cc"); return r; -} -#else -#define lj_fls(x) ((uint32_t)(__builtin_clz(x)^31)) -#endif - -#if defined(__arm__) -static LJ_AINLINE uint32_t lj_bswap(uint32_t x) -{ - uint32_t r; -#if __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6T2__ || __ARM_ARCH_6Z__ ||\ - __ARM_ARCH_6ZK__ || __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ - __asm__("rev %0, %1" : "=r" (r) : "r" (x)); - return r; -#else -#ifdef __thumb__ - r = x ^ lj_ror(x, 16); -#else - __asm__("eor %0, %1, %1, ror #16" : "=r" (r) : "r" (x)); -#endif - return ((r & 0xff00ffffu) >> 8) ^ lj_ror(x, 8); -#endif -} - -static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) -{ - return ((uint64_t)lj_bswap((uint32_t)x)<<32) | lj_bswap((uint32_t)(x>>32)); -} -#elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -static LJ_AINLINE uint32_t lj_bswap(uint32_t x) -{ - return (uint32_t)__builtin_bswap32((int32_t)x); -} - -static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) -{ - return (uint64_t)__builtin_bswap64((int64_t)x); -} -#elif defined(__i386__) || defined(__x86_64__) -static LJ_AINLINE uint32_t lj_bswap(uint32_t x) -{ - uint32_t r; __asm__("bswap %0" : "=r" (r) : "0" (x)); return r; -} - -#if defined(__i386__) -static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) -{ - return ((uint64_t)lj_bswap((uint32_t)x)<<32) | lj_bswap((uint32_t)(x>>32)); -} -#else -static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) -{ - uint64_t r; __asm__("bswap %0" : "=r" (r) : "0" (x)); return r; -} -#endif -#else -static LJ_AINLINE uint32_t lj_bswap(uint32_t x) -{ - return (x << 24) | ((x & 0xff00) << 8) | ((x >> 8) & 0xff00) | (x >> 24); -} - -static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) -{ - return (uint64_t)lj_bswap((uint32_t)(x >> 32)) | - ((uint64_t)lj_bswap((uint32_t)x) << 32); -} -#endif - -typedef union __attribute__((packed)) Unaligned16 { - uint16_t u; - uint8_t b[2]; -} Unaligned16; - -typedef union __attribute__((packed)) Unaligned32 { - uint32_t u; - uint8_t b[4]; -} Unaligned32; - -/* Unaligned load of uint16_t. */ -static LJ_AINLINE uint16_t lj_getu16(const void *p) -{ - return ((const Unaligned16 *)p)->u; -} - -/* Unaligned load of uint32_t. */ -static LJ_AINLINE uint32_t lj_getu32(const void *p) -{ - return ((const Unaligned32 *)p)->u; -} - -#elif defined(_MSC_VER) - -#define LJ_NORET __declspec(noreturn) -#define LJ_ALIGN(n) __declspec(align(n)) -#define LJ_INLINE __inline -#define LJ_AINLINE __forceinline -#define LJ_NOINLINE __declspec(noinline) -#if defined(_M_IX86) -#define LJ_FASTCALL __fastcall -#endif - -#ifdef _M_PPC -unsigned int _CountLeadingZeros(long); -#pragma intrinsic(_CountLeadingZeros) -static LJ_AINLINE uint32_t lj_fls(uint32_t x) -{ - return _CountLeadingZeros(x) ^ 31; -} -#else -unsigned char _BitScanForward(uint32_t *, unsigned long); -unsigned char _BitScanReverse(uint32_t *, unsigned long); -#pragma intrinsic(_BitScanForward) -#pragma intrinsic(_BitScanReverse) - -static LJ_AINLINE uint32_t lj_ffs(uint32_t x) -{ - uint32_t r; _BitScanForward(&r, x); return r; -} - -static LJ_AINLINE uint32_t lj_fls(uint32_t x) -{ - uint32_t r; _BitScanReverse(&r, x); return r; -} -#endif - -unsigned long _byteswap_ulong(unsigned long); -uint64_t _byteswap_uint64(uint64_t); -#define lj_bswap(x) (_byteswap_ulong((x))) -#define lj_bswap64(x) (_byteswap_uint64((x))) - -#if defined(_M_PPC) && defined(LUAJIT_NO_UNALIGNED) -/* -** Replacement for unaligned loads on Xbox 360. Disabled by default since it's -** usually more costly than the occasional stall when crossing a cache-line. -*/ -static LJ_AINLINE uint16_t lj_getu16(const void *v) -{ - const uint8_t *p = (const uint8_t *)v; - return (uint16_t)((p[0]<<8) | p[1]); -} -static LJ_AINLINE uint32_t lj_getu32(const void *v) -{ - const uint8_t *p = (const uint8_t *)v; - return (uint32_t)((p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]); -} -#else -/* Unaligned loads are generally ok on x86/x64. */ -#define lj_getu16(p) (*(uint16_t *)(p)) -#define lj_getu32(p) (*(uint32_t *)(p)) -#endif - -#else -#error "missing defines for your compiler" -#endif - -/* Optional defines. */ -#ifndef LJ_FASTCALL -#define LJ_FASTCALL -#endif -#ifndef LJ_NORET -#define LJ_NORET -#endif -#ifndef LJ_NOAPI -#define LJ_NOAPI extern -#endif -#ifndef LJ_LIKELY -#define LJ_LIKELY(x) (x) -#define LJ_UNLIKELY(x) (x) -#endif - -/* Attributes for internal functions. */ -#define LJ_DATA LJ_NOAPI -#define LJ_DATADEF -#define LJ_ASMF LJ_NOAPI -#define LJ_FUNCA LJ_NOAPI -#if defined(ljamalg_c) -#define LJ_FUNC static -#else -#define LJ_FUNC LJ_NOAPI -#endif -#define LJ_FUNC_NORET LJ_FUNC LJ_NORET -#define LJ_FUNCA_NORET LJ_FUNCA LJ_NORET -#define LJ_ASMF_NORET LJ_ASMF LJ_NORET - -/* Runtime assertions. */ -#ifdef lua_assert -#define check_exp(c, e) (lua_assert(c), (e)) -#define api_check(l, e) lua_assert(e) -#else -#define lua_assert(c) ((void)0) -#define check_exp(c, e) (e) -#define api_check luai_apicheck -#endif - -/* Static assertions. */ -#define LJ_ASSERT_NAME2(name, line) name ## line -#define LJ_ASSERT_NAME(line) LJ_ASSERT_NAME2(lj_assert_, line) -#ifdef __COUNTER__ -#define LJ_STATIC_ASSERT(cond) \ - extern void LJ_ASSERT_NAME(__COUNTER__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1]) -#else -#define LJ_STATIC_ASSERT(cond) \ - extern void LJ_ASSERT_NAME(__LINE__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1]) -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_dispatch.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_dispatch.c deleted file mode 100644 index 58d6c3e2b..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_dispatch.c +++ /dev/null @@ -1,494 +0,0 @@ -/* -** Instruction dispatch handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_dispatch_c -#define LUA_CORE - -#include "lj_obj.h" -#include "lj_err.h" -#include "lj_func.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_meta.h" -#include "lj_debug.h" -#include "lj_state.h" -#include "lj_frame.h" -#include "lj_bc.h" -#include "lj_ff.h" -#if LJ_HASJIT -#include "lj_jit.h" -#endif -#if LJ_HASFFI -#include "lj_ccallback.h" -#endif -#include "lj_trace.h" -#include "lj_dispatch.h" -#include "lj_vm.h" -#include "luajit.h" - -/* Bump GG_NUM_ASMFF in lj_dispatch.h as needed. Ugly. */ -LJ_STATIC_ASSERT(GG_NUM_ASMFF == FF_NUM_ASMFUNC); - -/* -- Dispatch table management ------------------------------------------- */ - -#if LJ_TARGET_MIPS -#include -LJ_FUNCA_NORET void LJ_FASTCALL lj_ffh_coroutine_wrap_err(lua_State *L, - lua_State *co); - -#define GOTFUNC(name) (ASMFunction)name, -static const ASMFunction dispatch_got[] = { - GOTDEF(GOTFUNC) -}; -#undef GOTFUNC -#endif - -/* Initialize instruction dispatch table and hot counters. */ -void lj_dispatch_init(GG_State *GG) -{ - uint32_t i; - ASMFunction *disp = GG->dispatch; - for (i = 0; i < GG_LEN_SDISP; i++) - disp[GG_LEN_DDISP+i] = disp[i] = makeasmfunc(lj_bc_ofs[i]); - for (i = GG_LEN_SDISP; i < GG_LEN_DDISP; i++) - disp[i] = makeasmfunc(lj_bc_ofs[i]); - /* The JIT engine is off by default. luaopen_jit() turns it on. */ - disp[BC_FORL] = disp[BC_IFORL]; - disp[BC_ITERL] = disp[BC_IITERL]; - disp[BC_LOOP] = disp[BC_ILOOP]; - disp[BC_FUNCF] = disp[BC_IFUNCF]; - disp[BC_FUNCV] = disp[BC_IFUNCV]; - GG->g.bc_cfunc_ext = GG->g.bc_cfunc_int = BCINS_AD(BC_FUNCC, LUA_MINSTACK, 0); - for (i = 0; i < GG_NUM_ASMFF; i++) - GG->bcff[i] = BCINS_AD(BC__MAX+i, 0, 0); -#if LJ_TARGET_MIPS - memcpy(GG->got, dispatch_got, LJ_GOT__MAX*4); -#endif -} - -#if LJ_HASJIT -/* Initialize hotcount table. */ -void lj_dispatch_init_hotcount(global_State *g) -{ - int32_t hotloop = G2J(g)->param[JIT_P_hotloop]; - HotCount start = (HotCount)(hotloop*HOTCOUNT_LOOP - 1); - HotCount *hotcount = G2GG(g)->hotcount; - uint32_t i; - for (i = 0; i < HOTCOUNT_SIZE; i++) - hotcount[i] = start; -} -#endif - -/* Internal dispatch mode bits. */ -#define DISPMODE_JIT 0x01 /* JIT compiler on. */ -#define DISPMODE_REC 0x02 /* Recording active. */ -#define DISPMODE_INS 0x04 /* Override instruction dispatch. */ -#define DISPMODE_CALL 0x08 /* Override call dispatch. */ -#define DISPMODE_RET 0x10 /* Override return dispatch. */ - -/* Update dispatch table depending on various flags. */ -void lj_dispatch_update(global_State *g) -{ - uint8_t oldmode = g->dispatchmode; - uint8_t mode = 0; -#if LJ_HASJIT - mode |= (G2J(g)->flags & JIT_F_ON) ? DISPMODE_JIT : 0; - mode |= G2J(g)->state != LJ_TRACE_IDLE ? - (DISPMODE_REC|DISPMODE_INS|DISPMODE_CALL) : 0; -#endif - mode |= (g->hookmask & (LUA_MASKLINE|LUA_MASKCOUNT)) ? DISPMODE_INS : 0; - mode |= (g->hookmask & LUA_MASKCALL) ? DISPMODE_CALL : 0; - mode |= (g->hookmask & LUA_MASKRET) ? DISPMODE_RET : 0; - if (oldmode != mode) { /* Mode changed? */ - ASMFunction *disp = G2GG(g)->dispatch; - ASMFunction f_forl, f_iterl, f_loop, f_funcf, f_funcv; - g->dispatchmode = mode; - - /* Hotcount if JIT is on, but not while recording. */ - if ((mode & (DISPMODE_JIT|DISPMODE_REC)) == DISPMODE_JIT) { - f_forl = makeasmfunc(lj_bc_ofs[BC_FORL]); - f_iterl = makeasmfunc(lj_bc_ofs[BC_ITERL]); - f_loop = makeasmfunc(lj_bc_ofs[BC_LOOP]); - f_funcf = makeasmfunc(lj_bc_ofs[BC_FUNCF]); - f_funcv = makeasmfunc(lj_bc_ofs[BC_FUNCV]); - } else { /* Otherwise use the non-hotcounting instructions. */ - f_forl = disp[GG_LEN_DDISP+BC_IFORL]; - f_iterl = disp[GG_LEN_DDISP+BC_IITERL]; - f_loop = disp[GG_LEN_DDISP+BC_ILOOP]; - f_funcf = makeasmfunc(lj_bc_ofs[BC_IFUNCF]); - f_funcv = makeasmfunc(lj_bc_ofs[BC_IFUNCV]); - } - /* Init static counting instruction dispatch first (may be copied below). */ - disp[GG_LEN_DDISP+BC_FORL] = f_forl; - disp[GG_LEN_DDISP+BC_ITERL] = f_iterl; - disp[GG_LEN_DDISP+BC_LOOP] = f_loop; - - /* Set dynamic instruction dispatch. */ - if ((oldmode ^ mode) & (DISPMODE_REC|DISPMODE_INS)) { - /* Need to update the whole table. */ - if (!(mode & (DISPMODE_REC|DISPMODE_INS))) { /* No ins dispatch? */ - /* Copy static dispatch table to dynamic dispatch table. */ - memcpy(&disp[0], &disp[GG_LEN_DDISP], GG_LEN_SDISP*sizeof(ASMFunction)); - /* Overwrite with dynamic return dispatch. */ - if ((mode & DISPMODE_RET)) { - disp[BC_RETM] = lj_vm_rethook; - disp[BC_RET] = lj_vm_rethook; - disp[BC_RET0] = lj_vm_rethook; - disp[BC_RET1] = lj_vm_rethook; - } - } else { - /* The recording dispatch also checks for hooks. */ - ASMFunction f = (mode & DISPMODE_REC) ? lj_vm_record : lj_vm_inshook; - uint32_t i; - for (i = 0; i < GG_LEN_SDISP; i++) - disp[i] = f; - } - } else if (!(mode & (DISPMODE_REC|DISPMODE_INS))) { - /* Otherwise set dynamic counting ins. */ - disp[BC_FORL] = f_forl; - disp[BC_ITERL] = f_iterl; - disp[BC_LOOP] = f_loop; - /* Set dynamic return dispatch. */ - if ((mode & DISPMODE_RET)) { - disp[BC_RETM] = lj_vm_rethook; - disp[BC_RET] = lj_vm_rethook; - disp[BC_RET0] = lj_vm_rethook; - disp[BC_RET1] = lj_vm_rethook; - } else { - disp[BC_RETM] = disp[GG_LEN_DDISP+BC_RETM]; - disp[BC_RET] = disp[GG_LEN_DDISP+BC_RET]; - disp[BC_RET0] = disp[GG_LEN_DDISP+BC_RET0]; - disp[BC_RET1] = disp[GG_LEN_DDISP+BC_RET1]; - } - } - - /* Set dynamic call dispatch. */ - if ((oldmode ^ mode) & DISPMODE_CALL) { /* Update the whole table? */ - uint32_t i; - if ((mode & DISPMODE_CALL) == 0) { /* No call hooks? */ - for (i = GG_LEN_SDISP; i < GG_LEN_DDISP; i++) - disp[i] = makeasmfunc(lj_bc_ofs[i]); - } else { - for (i = GG_LEN_SDISP; i < GG_LEN_DDISP; i++) - disp[i] = lj_vm_callhook; - } - } - if (!(mode & DISPMODE_CALL)) { /* Overwrite dynamic counting ins. */ - disp[BC_FUNCF] = f_funcf; - disp[BC_FUNCV] = f_funcv; - } - -#if LJ_HASJIT - /* Reset hotcounts for JIT off to on transition. */ - if ((mode & DISPMODE_JIT) && !(oldmode & DISPMODE_JIT)) - lj_dispatch_init_hotcount(g); -#endif - } -} - -/* -- JIT mode setting ---------------------------------------------------- */ - -#if LJ_HASJIT -/* Set JIT mode for a single prototype. */ -static void setptmode(global_State *g, GCproto *pt, int mode) -{ - if ((mode & LUAJIT_MODE_ON)) { /* (Re-)enable JIT compilation. */ - pt->flags &= ~PROTO_NOJIT; - lj_trace_reenableproto(pt); /* Unpatch all ILOOP etc. bytecodes. */ - } else { /* Flush and/or disable JIT compilation. */ - if (!(mode & LUAJIT_MODE_FLUSH)) - pt->flags |= PROTO_NOJIT; - lj_trace_flushproto(g, pt); /* Flush all traces of prototype. */ - } -} - -/* Recursively set the JIT mode for all children of a prototype. */ -static void setptmode_all(global_State *g, GCproto *pt, int mode) -{ - ptrdiff_t i; - if (!(pt->flags & PROTO_CHILD)) return; - for (i = -(ptrdiff_t)pt->sizekgc; i < 0; i++) { - GCobj *o = proto_kgc(pt, i); - if (o->gch.gct == ~LJ_TPROTO) { - setptmode(g, gco2pt(o), mode); - setptmode_all(g, gco2pt(o), mode); - } - } -} -#endif - -/* Public API function: control the JIT engine. */ -int luaJIT_setmode(lua_State *L, int idx, int mode) -{ - global_State *g = G(L); - int mm = mode & LUAJIT_MODE_MASK; - lj_trace_abort(g); /* Abort recording on any state change. */ - /* Avoid pulling the rug from under our own feet. */ - if ((g->hookmask & HOOK_GC)) - lj_err_caller(L, LJ_ERR_NOGCMM); - switch (mm) { -#if LJ_HASJIT - case LUAJIT_MODE_ENGINE: - if ((mode & LUAJIT_MODE_FLUSH)) { - lj_trace_flushall(L); - } else { - if (!(mode & LUAJIT_MODE_ON)) - G2J(g)->flags &= ~(uint32_t)JIT_F_ON; -#if LJ_TARGET_X86ORX64 - else if ((G2J(g)->flags & JIT_F_SSE2)) - G2J(g)->flags |= (uint32_t)JIT_F_ON; - else - return 0; /* Don't turn on JIT compiler without SSE2 support. */ -#else - else - G2J(g)->flags |= (uint32_t)JIT_F_ON; -#endif - lj_dispatch_update(g); - } - break; - case LUAJIT_MODE_FUNC: - case LUAJIT_MODE_ALLFUNC: - case LUAJIT_MODE_ALLSUBFUNC: { - cTValue *tv = idx == 0 ? frame_prev(L->base-1) : - idx > 0 ? L->base + (idx-1) : L->top + idx; - GCproto *pt; - if ((idx == 0 || tvisfunc(tv)) && isluafunc(&gcval(tv)->fn)) - pt = funcproto(&gcval(tv)->fn); /* Cannot use funcV() for frame slot. */ - else if (tvisproto(tv)) - pt = protoV(tv); - else - return 0; /* Failed. */ - if (mm != LUAJIT_MODE_ALLSUBFUNC) - setptmode(g, pt, mode); - if (mm != LUAJIT_MODE_FUNC) - setptmode_all(g, pt, mode); - break; - } - case LUAJIT_MODE_TRACE: - if (!(mode & LUAJIT_MODE_FLUSH)) - return 0; /* Failed. */ - lj_trace_flush(G2J(g), idx); - break; -#else - case LUAJIT_MODE_ENGINE: - case LUAJIT_MODE_FUNC: - case LUAJIT_MODE_ALLFUNC: - case LUAJIT_MODE_ALLSUBFUNC: - UNUSED(idx); - if ((mode & LUAJIT_MODE_ON)) - return 0; /* Failed. */ - break; -#endif - case LUAJIT_MODE_WRAPCFUNC: - if ((mode & LUAJIT_MODE_ON)) { - if (idx != 0) { - cTValue *tv = idx > 0 ? L->base + (idx-1) : L->top + idx; - if (tvislightud(tv)) - g->wrapf = (lua_CFunction)lightudV(tv); - else - return 0; /* Failed. */ - } else { - return 0; /* Failed. */ - } - g->bc_cfunc_ext = BCINS_AD(BC_FUNCCW, 0, 0); - } else { - g->bc_cfunc_ext = BCINS_AD(BC_FUNCC, 0, 0); - } - break; - default: - return 0; /* Failed. */ - } - return 1; /* OK. */ -} - -/* Enforce (dynamic) linker error for version mismatches. See luajit.c. */ -LUA_API void LUAJIT_VERSION_SYM(void) -{ -} - -/* -- Hooks --------------------------------------------------------------- */ - -/* This function can be called asynchronously (e.g. during a signal). */ -LUA_API int lua_sethook(lua_State *L, lua_Hook func, int mask, int count) -{ - global_State *g = G(L); - mask &= HOOK_EVENTMASK; - if (func == NULL || mask == 0) { mask = 0; func = NULL; } /* Consistency. */ - g->hookf = func; - g->hookcount = g->hookcstart = (int32_t)count; - g->hookmask = (uint8_t)((g->hookmask & ~HOOK_EVENTMASK) | mask); - lj_trace_abort(g); /* Abort recording on any hook change. */ - lj_dispatch_update(g); - return 1; -} - -LUA_API lua_Hook lua_gethook(lua_State *L) -{ - return G(L)->hookf; -} - -LUA_API int lua_gethookmask(lua_State *L) -{ - return G(L)->hookmask & HOOK_EVENTMASK; -} - -LUA_API int lua_gethookcount(lua_State *L) -{ - return (int)G(L)->hookcstart; -} - -/* Call a hook. */ -static void callhook(lua_State *L, int event, BCLine line) -{ - global_State *g = G(L); - lua_Hook hookf = g->hookf; - if (hookf && !hook_active(g)) { - lua_Debug ar; - lj_trace_abort(g); /* Abort recording on any hook call. */ - ar.event = event; - ar.currentline = line; - /* Top frame, nextframe = NULL. */ - ar.i_ci = (int)((L->base-1) - tvref(L->stack)); - lj_state_checkstack(L, 1+LUA_MINSTACK); - hook_enter(g); - hookf(L, &ar); - lua_assert(hook_active(g)); - hook_leave(g); - } -} - -/* -- Dispatch callbacks -------------------------------------------------- */ - -/* Calculate number of used stack slots in the current frame. */ -static BCReg cur_topslot(GCproto *pt, const BCIns *pc, uint32_t nres) -{ - BCIns ins = pc[-1]; - if (bc_op(ins) == BC_UCLO) - ins = pc[bc_j(ins)]; - switch (bc_op(ins)) { - case BC_CALLM: case BC_CALLMT: return bc_a(ins) + bc_c(ins) + nres-1+1; - case BC_RETM: return bc_a(ins) + bc_d(ins) + nres-1; - case BC_TSETM: return bc_a(ins) + nres-1; - default: return pt->framesize; - } -} - -/* Instruction dispatch. Used by instr/line/return hooks or when recording. */ -void LJ_FASTCALL lj_dispatch_ins(lua_State *L, const BCIns *pc) -{ - ERRNO_SAVE - GCfunc *fn = curr_func(L); - GCproto *pt = funcproto(fn); - void *cf = cframe_raw(L->cframe); - const BCIns *oldpc = cframe_pc(cf); - global_State *g = G(L); - BCReg slots; - setcframe_pc(cf, pc); - slots = cur_topslot(pt, pc, cframe_multres_n(cf)); - L->top = L->base + slots; /* Fix top. */ -#if LJ_HASJIT - { - jit_State *J = G2J(g); - if (J->state != LJ_TRACE_IDLE) { -#ifdef LUA_USE_ASSERT - ptrdiff_t delta = L->top - L->base; -#endif - J->L = L; - lj_trace_ins(J, pc-1); /* The interpreter bytecode PC is offset by 1. */ - lua_assert(L->top - L->base == delta); - } - } -#endif - if ((g->hookmask & LUA_MASKCOUNT) && g->hookcount == 0) { - g->hookcount = g->hookcstart; - callhook(L, LUA_HOOKCOUNT, -1); - L->top = L->base + slots; /* Fix top again. */ - } - if ((g->hookmask & LUA_MASKLINE)) { - BCPos npc = proto_bcpos(pt, pc) - 1; - BCPos opc = proto_bcpos(pt, oldpc) - 1; - BCLine line = lj_debug_line(pt, npc); - if (pc <= oldpc || opc >= pt->sizebc || line != lj_debug_line(pt, opc)) { - callhook(L, LUA_HOOKLINE, line); - L->top = L->base + slots; /* Fix top again. */ - } - } - if ((g->hookmask & LUA_MASKRET) && bc_isret(bc_op(pc[-1]))) - callhook(L, LUA_HOOKRET, -1); - ERRNO_RESTORE -} - -/* Initialize call. Ensure stack space and return # of missing parameters. */ -static int call_init(lua_State *L, GCfunc *fn) -{ - if (isluafunc(fn)) { - GCproto *pt = funcproto(fn); - int numparams = pt->numparams; - int gotparams = (int)(L->top - L->base); - int need = pt->framesize; - if ((pt->flags & PROTO_VARARG)) need += 1+gotparams; - lj_state_checkstack(L, (MSize)need); - numparams -= gotparams; - return numparams >= 0 ? numparams : 0; - } else { - lj_state_checkstack(L, LUA_MINSTACK); - return 0; - } -} - -/* Call dispatch. Used by call hooks, hot calls or when recording. */ -ASMFunction LJ_FASTCALL lj_dispatch_call(lua_State *L, const BCIns *pc) -{ - ERRNO_SAVE - GCfunc *fn = curr_func(L); - BCOp op; - global_State *g = G(L); -#if LJ_HASJIT - jit_State *J = G2J(g); -#endif - int missing = call_init(L, fn); -#if LJ_HASJIT - J->L = L; - if ((uintptr_t)pc & 1) { /* Marker for hot call. */ -#ifdef LUA_USE_ASSERT - ptrdiff_t delta = L->top - L->base; -#endif - pc = (const BCIns *)((uintptr_t)pc & ~(uintptr_t)1); - lj_trace_hot(J, pc); - lua_assert(L->top - L->base == delta); - goto out; - } else if (J->state != LJ_TRACE_IDLE && - !(g->hookmask & (HOOK_GC|HOOK_VMEVENT))) { -#ifdef LUA_USE_ASSERT - ptrdiff_t delta = L->top - L->base; -#endif - /* Record the FUNC* bytecodes, too. */ - lj_trace_ins(J, pc-1); /* The interpreter bytecode PC is offset by 1. */ - lua_assert(L->top - L->base == delta); - } -#endif - if ((g->hookmask & LUA_MASKCALL)) { - int i; - for (i = 0; i < missing; i++) /* Add missing parameters. */ - setnilV(L->top++); - callhook(L, LUA_HOOKCALL, -1); - /* Preserve modifications of missing parameters by lua_setlocal(). */ - while (missing-- > 0 && tvisnil(L->top - 1)) - L->top--; - } -#if LJ_HASJIT -out: -#endif - op = bc_op(pc[-1]); /* Get FUNC* op. */ -#if LJ_HASJIT - /* Use the non-hotcounting variants if JIT is off or while recording. */ - if ((!(J->flags & JIT_F_ON) || J->state != LJ_TRACE_IDLE) && - (op == BC_FUNCF || op == BC_FUNCV)) - op = (BCOp)((int)op+(int)BC_IFUNCF-(int)BC_FUNCF); -#endif - ERRNO_RESTORE - return makeasmfunc(lj_bc_ofs[op]); /* Return static dispatch target. */ -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_dispatch.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_dispatch.h deleted file mode 100644 index 5960e64a6..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_dispatch.h +++ /dev/null @@ -1,131 +0,0 @@ -/* -** Instruction dispatch handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_DISPATCH_H -#define _LJ_DISPATCH_H - -#include "lj_obj.h" -#include "lj_bc.h" -#if LJ_HASJIT -#include "lj_jit.h" -#endif - -#if LJ_TARGET_MIPS -/* Need our own global offset table for the dreaded MIPS calling conventions. */ -#if LJ_HASJIT -#define JITGOTDEF(_) _(lj_trace_exit) _(lj_trace_hot) -#else -#define JITGOTDEF(_) -#endif -#if LJ_HASFFI -#define FFIGOTDEF(_) \ - _(lj_meta_equal_cd) _(lj_ccallback_enter) _(lj_ccallback_leave) -#else -#define FFIGOTDEF(_) -#endif -#define GOTDEF(_) \ - _(floor) _(ceil) _(trunc) _(log) _(log10) _(exp) _(sin) _(cos) _(tan) \ - _(asin) _(acos) _(atan) _(sinh) _(cosh) _(tanh) _(frexp) _(modf) _(atan2) \ - _(pow) _(fmod) _(ldexp) \ - _(lj_dispatch_call) _(lj_dispatch_ins) _(lj_err_throw) \ - _(lj_ffh_coroutine_wrap_err) _(lj_func_closeuv) _(lj_func_newL_gc) \ - _(lj_gc_barrieruv) _(lj_gc_step) _(lj_gc_step_fixtop) _(lj_meta_arith) \ - _(lj_meta_call) _(lj_meta_cat) _(lj_meta_comp) _(lj_meta_equal) \ - _(lj_meta_for) _(lj_meta_len) _(lj_meta_tget) _(lj_meta_tset) \ - _(lj_state_growstack) _(lj_str_fromnum) _(lj_str_fromnumber) _(lj_str_new) \ - _(lj_tab_dup) _(lj_tab_get) _(lj_tab_getinth) _(lj_tab_len) _(lj_tab_new) \ - _(lj_tab_newkey) _(lj_tab_next) _(lj_tab_reasize) \ - JITGOTDEF(_) FFIGOTDEF(_) - -enum { -#define GOTENUM(name) LJ_GOT_##name, -GOTDEF(GOTENUM) -#undef GOTENUM - LJ_GOT__MAX -}; -#endif - -/* Type of hot counter. Must match the code in the assembler VM. */ -/* 16 bits are sufficient. Only 0.0015% overhead with maximum slot penalty. */ -typedef uint16_t HotCount; - -/* Number of hot counter hash table entries (must be a power of two). */ -#define HOTCOUNT_SIZE 64 -#define HOTCOUNT_PCMASK ((HOTCOUNT_SIZE-1)*sizeof(HotCount)) - -/* Hotcount decrements. */ -#define HOTCOUNT_LOOP 2 -#define HOTCOUNT_CALL 1 - -/* This solves a circular dependency problem -- bump as needed. Sigh. */ -#define GG_NUM_ASMFF 62 - -#define GG_LEN_DDISP (BC__MAX + GG_NUM_ASMFF) -#define GG_LEN_SDISP BC_FUNCF -#define GG_LEN_DISP (GG_LEN_DDISP + GG_LEN_SDISP) - -/* Global state, main thread and extra fields are allocated together. */ -typedef struct GG_State { - lua_State L; /* Main thread. */ - global_State g; /* Global state. */ -#if LJ_TARGET_MIPS - ASMFunction got[LJ_GOT__MAX]; /* Global offset table. */ -#endif -#if LJ_HASJIT - jit_State J; /* JIT state. */ - HotCount hotcount[HOTCOUNT_SIZE]; /* Hot counters. */ -#endif - ASMFunction dispatch[GG_LEN_DISP]; /* Instruction dispatch tables. */ - BCIns bcff[GG_NUM_ASMFF]; /* Bytecode for ASM fast functions. */ -} GG_State; - -#define GG_OFS(field) ((int)offsetof(GG_State, field)) -#define G2GG(gl) ((GG_State *)((char *)(gl) - GG_OFS(g))) -#define J2GG(j) ((GG_State *)((char *)(j) - GG_OFS(J))) -#define L2GG(L) (G2GG(G(L))) -#define J2G(J) (&J2GG(J)->g) -#define G2J(gl) (&G2GG(gl)->J) -#define L2J(L) (&L2GG(L)->J) -#define GG_G2DISP (GG_OFS(dispatch) - GG_OFS(g)) -#define GG_DISP2G (GG_OFS(g) - GG_OFS(dispatch)) -#define GG_DISP2J (GG_OFS(J) - GG_OFS(dispatch)) -#define GG_DISP2HOT (GG_OFS(hotcount) - GG_OFS(dispatch)) -#define GG_DISP2STATIC (GG_LEN_DDISP*(int)sizeof(ASMFunction)) - -#define hotcount_get(gg, pc) \ - (gg)->hotcount[(u32ptr(pc)>>2) & (HOTCOUNT_SIZE-1)] -#define hotcount_set(gg, pc, val) \ - (hotcount_get((gg), (pc)) = (HotCount)(val)) - -/* Dispatch table management. */ -LJ_FUNC void lj_dispatch_init(GG_State *GG); -#if LJ_HASJIT -LJ_FUNC void lj_dispatch_init_hotcount(global_State *g); -#endif -LJ_FUNC void lj_dispatch_update(global_State *g); - -/* Instruction dispatch callback for hooks or when recording. */ -LJ_FUNCA void LJ_FASTCALL lj_dispatch_ins(lua_State *L, const BCIns *pc); -LJ_FUNCA ASMFunction LJ_FASTCALL lj_dispatch_call(lua_State *L, const BCIns*pc); -LJ_FUNCA void LJ_FASTCALL lj_dispatch_return(lua_State *L, const BCIns *pc); - -#if LJ_HASFFI && !defined(_BUILDVM_H) -/* Save/restore errno and GetLastError() around hooks, exits and recording. */ -#include -#if LJ_TARGET_WINDOWS -#define WIN32_LEAN_AND_MEAN -#include -#define ERRNO_SAVE int olderr = errno; DWORD oldwerr = GetLastError(); -#define ERRNO_RESTORE errno = olderr; SetLastError(oldwerr); -#else -#define ERRNO_SAVE int olderr = errno; -#define ERRNO_RESTORE errno = olderr; -#endif -#else -#define ERRNO_SAVE -#define ERRNO_RESTORE -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_arm.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_arm.h deleted file mode 100644 index 3bac3679a..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_arm.h +++ /dev/null @@ -1,356 +0,0 @@ -/* -** ARM instruction emitter. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -/* -- Constant encoding --------------------------------------------------- */ - -static uint8_t emit_invai[16] = { - /* AND */ (ARMI_AND^ARMI_BIC) >> 21, - /* EOR */ 0, - /* SUB */ (ARMI_SUB^ARMI_ADD) >> 21, - /* RSB */ 0, - /* ADD */ (ARMI_ADD^ARMI_SUB) >> 21, - /* ADC */ (ARMI_ADC^ARMI_SBC) >> 21, - /* SBC */ (ARMI_SBC^ARMI_ADC) >> 21, - /* RSC */ 0, - /* TST */ 0, - /* TEQ */ 0, - /* CMP */ (ARMI_CMP^ARMI_CMN) >> 21, - /* CMN */ (ARMI_CMN^ARMI_CMP) >> 21, - /* ORR */ 0, - /* MOV */ (ARMI_MOV^ARMI_MVN) >> 21, - /* BIC */ (ARMI_BIC^ARMI_AND) >> 21, - /* MVN */ (ARMI_MVN^ARMI_MOV) >> 21 -}; - -/* Encode constant in K12 format for data processing instructions. */ -static uint32_t emit_isk12(ARMIns ai, int32_t n) -{ - uint32_t invai, i, m = (uint32_t)n; - /* K12: unsigned 8 bit value, rotated in steps of two bits. */ - for (i = 0; i < 4096; i += 256, m = lj_rol(m, 2)) - if (m <= 255) return ARMI_K12|m|i; - /* Otherwise try negation/complement with the inverse instruction. */ - invai = emit_invai[((ai >> 21) & 15)]; - if (!invai) return 0; /* Failed. No inverse instruction. */ - m = ~(uint32_t)n; - if (invai == ((ARMI_SUB^ARMI_ADD) >> 21) || - invai == (ARMI_CMP^ARMI_CMN) >> 21) m++; - for (i = 0; i < 4096; i += 256, m = lj_rol(m, 2)) - if (m <= 255) return ARMI_K12|(invai<<21)|m|i; - return 0; /* Failed. */ -} - -/* -- Emit basic instructions --------------------------------------------- */ - -static void emit_dnm(ASMState *as, ARMIns ai, Reg rd, Reg rn, Reg rm) -{ - *--as->mcp = ai | ARMF_D(rd) | ARMF_N(rn) | ARMF_M(rm); -} - -static void emit_dm(ASMState *as, ARMIns ai, Reg rd, Reg rm) -{ - *--as->mcp = ai | ARMF_D(rd) | ARMF_M(rm); -} - -static void emit_dn(ASMState *as, ARMIns ai, Reg rd, Reg rn) -{ - *--as->mcp = ai | ARMF_D(rd) | ARMF_N(rn); -} - -static void emit_nm(ASMState *as, ARMIns ai, Reg rn, Reg rm) -{ - *--as->mcp = ai | ARMF_N(rn) | ARMF_M(rm); -} - -static void emit_d(ASMState *as, ARMIns ai, Reg rd) -{ - *--as->mcp = ai | ARMF_D(rd); -} - -static void emit_n(ASMState *as, ARMIns ai, Reg rn) -{ - *--as->mcp = ai | ARMF_N(rn); -} - -static void emit_m(ASMState *as, ARMIns ai, Reg rm) -{ - *--as->mcp = ai | ARMF_M(rm); -} - -static void emit_lsox(ASMState *as, ARMIns ai, Reg rd, Reg rn, int32_t ofs) -{ - lua_assert(ofs >= -255 && ofs <= 255); - if (ofs < 0) ofs = -ofs; else ai |= ARMI_LS_U; - *--as->mcp = ai | ARMI_LS_P | ARMI_LSX_I | ARMF_D(rd) | ARMF_N(rn) | - ((ofs & 0xf0) << 4) | (ofs & 0x0f); -} - -static void emit_lso(ASMState *as, ARMIns ai, Reg rd, Reg rn, int32_t ofs) -{ - lua_assert(ofs >= -4095 && ofs <= 4095); - /* Combine LDR/STR pairs to LDRD/STRD. */ - if (*as->mcp == (ai|ARMI_LS_P|ARMI_LS_U|ARMF_D(rd^1)|ARMF_N(rn)|(ofs^4)) && - (ai & ~(ARMI_LDR^ARMI_STR)) == ARMI_STR && rd != rn && - (uint32_t)ofs <= 252 && !(ofs & 3) && !((rd ^ (ofs >>2)) & 1) && - as->mcp != as->mcloop) { - as->mcp++; - emit_lsox(as, ai == ARMI_LDR ? ARMI_LDRD : ARMI_STRD, rd&~1, rn, ofs&~4); - return; - } - if (ofs < 0) ofs = -ofs; else ai |= ARMI_LS_U; - *--as->mcp = ai | ARMI_LS_P | ARMF_D(rd) | ARMF_N(rn) | ofs; -} - -#if !LJ_SOFTFP -static void emit_vlso(ASMState *as, ARMIns ai, Reg rd, Reg rn, int32_t ofs) -{ - lua_assert(ofs >= -1020 && ofs <= 1020 && (ofs&3) == 0); - if (ofs < 0) ofs = -ofs; else ai |= ARMI_LS_U; - *--as->mcp = ai | ARMI_LS_P | ARMF_D(rd & 15) | ARMF_N(rn) | (ofs >> 2); -} -#endif - -/* -- Emit loads/stores --------------------------------------------------- */ - -/* Prefer spills of BASE/L. */ -#define emit_canremat(ref) ((ref) < ASMREF_L) - -/* Try to find a one step delta relative to another constant. */ -static int emit_kdelta1(ASMState *as, Reg d, int32_t i) -{ - RegSet work = ~as->freeset & RSET_GPR; - while (work) { - Reg r = rset_picktop(work); - IRRef ref = regcost_ref(as->cost[r]); - lua_assert(r != d); - if (emit_canremat(ref)) { - int32_t delta = i - (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i); - uint32_t k = emit_isk12(ARMI_ADD, delta); - if (k) { - if (k == ARMI_K12) - emit_dm(as, ARMI_MOV, d, r); - else - emit_dn(as, ARMI_ADD^k, d, r); - return 1; - } - } - rset_clear(work, r); - } - return 0; /* Failed. */ -} - -/* Try to find a two step delta relative to another constant. */ -static int emit_kdelta2(ASMState *as, Reg d, int32_t i) -{ - RegSet work = ~as->freeset & RSET_GPR; - while (work) { - Reg r = rset_picktop(work); - IRRef ref = regcost_ref(as->cost[r]); - lua_assert(r != d); - if (emit_canremat(ref)) { - int32_t other = ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i; - if (other) { - int32_t delta = i - other; - uint32_t sh, inv = 0, k2, k; - if (delta < 0) { delta = -delta; inv = ARMI_ADD^ARMI_SUB; } - sh = lj_ffs(delta) & ~1; - k2 = emit_isk12(0, delta & (255 << sh)); - k = emit_isk12(0, delta & ~(255 << sh)); - if (k) { - emit_dn(as, ARMI_ADD^k2^inv, d, d); - emit_dn(as, ARMI_ADD^k^inv, d, r); - return 1; - } - } - } - rset_clear(work, r); - } - return 0; /* Failed. */ -} - -/* Load a 32 bit constant into a GPR. */ -static void emit_loadi(ASMState *as, Reg r, int32_t i) -{ - uint32_t k = emit_isk12(ARMI_MOV, i); - lua_assert(rset_test(as->freeset, r) || r == RID_TMP); - if (k) { - /* Standard K12 constant. */ - emit_d(as, ARMI_MOV^k, r); - } else if ((as->flags & JIT_F_ARMV6T2) && (uint32_t)i < 0x00010000u) { - /* 16 bit loword constant for ARMv6T2. */ - emit_d(as, ARMI_MOVW|(i & 0x0fff)|((i & 0xf000)<<4), r); - } else if (emit_kdelta1(as, r, i)) { - /* One step delta relative to another constant. */ - } else if ((as->flags & JIT_F_ARMV6T2)) { - /* 32 bit hiword/loword constant for ARMv6T2. */ - emit_d(as, ARMI_MOVT|((i>>16) & 0x0fff)|(((i>>16) & 0xf000)<<4), r); - emit_d(as, ARMI_MOVW|(i & 0x0fff)|((i & 0xf000)<<4), r); - } else if (emit_kdelta2(as, r, i)) { - /* Two step delta relative to another constant. */ - } else { - /* Otherwise construct the constant with up to 4 instructions. */ - /* NYI: use mvn+bic, use pc-relative loads. */ - for (;;) { - uint32_t sh = lj_ffs(i) & ~1; - int32_t m = i & (255 << sh); - i &= ~(255 << sh); - if (i == 0) { - emit_d(as, ARMI_MOV ^ emit_isk12(0, m), r); - break; - } - emit_dn(as, ARMI_ORR ^ emit_isk12(0, m), r, r); - } - } -} - -#define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr))) - -static Reg ra_allock(ASMState *as, int32_t k, RegSet allow); - -/* Get/set from constant pointer. */ -static void emit_lsptr(ASMState *as, ARMIns ai, Reg r, void *p) -{ - int32_t i = i32ptr(p); - emit_lso(as, ai, r, ra_allock(as, (i & ~4095), rset_exclude(RSET_GPR, r)), - (i & 4095)); -} - -#if !LJ_SOFTFP -/* Load a number constant into an FPR. */ -static void emit_loadn(ASMState *as, Reg r, cTValue *tv) -{ - int32_t i; - if ((as->flags & JIT_F_VFPV3) && !tv->u32.lo) { - uint32_t hi = tv->u32.hi; - uint32_t b = ((hi >> 22) & 0x1ff); - if (!(hi & 0xffff) && (b == 0x100 || b == 0x0ff)) { - *--as->mcp = ARMI_VMOVI_D | ARMF_D(r & 15) | - ((tv->u32.hi >> 12) & 0x00080000) | - ((tv->u32.hi >> 4) & 0x00070000) | - ((tv->u32.hi >> 16) & 0x0000000f); - return; - } - } - i = i32ptr(tv); - emit_vlso(as, ARMI_VLDR_D, r, - ra_allock(as, (i & ~1020), RSET_GPR), (i & 1020)); -} -#endif - -/* Get/set global_State fields. */ -#define emit_getgl(as, r, field) \ - emit_lsptr(as, ARMI_LDR, (r), (void *)&J2G(as->J)->field) -#define emit_setgl(as, r, field) \ - emit_lsptr(as, ARMI_STR, (r), (void *)&J2G(as->J)->field) - -/* Trace number is determined from pc of exit instruction. */ -#define emit_setvmstate(as, i) UNUSED(i) - -/* -- Emit control-flow instructions -------------------------------------- */ - -/* Label for internal jumps. */ -typedef MCode *MCLabel; - -/* Return label pointing to current PC. */ -#define emit_label(as) ((as)->mcp) - -static void emit_branch(ASMState *as, ARMIns ai, MCode *target) -{ - MCode *p = as->mcp; - ptrdiff_t delta = (target - p) - 1; - lua_assert(((delta + 0x00800000) >> 24) == 0); - *--p = ai | ((uint32_t)delta & 0x00ffffffu); - as->mcp = p; -} - -#define emit_jmp(as, target) emit_branch(as, ARMI_B, (target)) - -static void emit_call(ASMState *as, void *target) -{ - MCode *p = --as->mcp; - ptrdiff_t delta = ((char *)target - (char *)p) - 8; - if ((((delta>>2) + 0x00800000) >> 24) == 0) { - if ((delta & 1)) - *p = ARMI_BLX | ((uint32_t)(delta>>2) & 0x00ffffffu) | ((delta&2) << 27); - else - *p = ARMI_BL | ((uint32_t)(delta>>2) & 0x00ffffffu); - } else { /* Target out of range: need indirect call. But don't use R0-R3. */ - Reg r = ra_allock(as, i32ptr(target), RSET_RANGE(RID_R4, RID_R12+1)); - *p = ARMI_BLXr | ARMF_M(r); - } -} - -/* -- Emit generic operations --------------------------------------------- */ - -/* Generic move between two regs. */ -static void emit_movrr(ASMState *as, IRIns *ir, Reg dst, Reg src) -{ -#if LJ_SOFTFP - lua_assert(!irt_isnum(ir->t)); UNUSED(ir); -#else - if (dst >= RID_MAX_GPR) { - emit_dm(as, irt_isnum(ir->t) ? ARMI_VMOV_D : ARMI_VMOV_S, - (dst & 15), (src & 15)); - return; - } -#endif - if (as->mcp != as->mcloop) { /* Swap early registers for loads/stores. */ - MCode ins = *as->mcp, swp = (src^dst); - if ((ins & 0x0c000000) == 0x04000000 && (ins & 0x02000010) != 0x02000010) { - if (!((ins ^ (dst << 16)) & 0x000f0000)) - *as->mcp = ins ^ (swp << 16); /* Swap N in load/store. */ - if (!(ins & 0x00100000) && !((ins ^ (dst << 12)) & 0x0000f000)) - *as->mcp = ins ^ (swp << 12); /* Swap D in store. */ - } - } - emit_dm(as, ARMI_MOV, dst, src); -} - -/* Generic load of register from stack slot. */ -static void emit_spload(ASMState *as, IRIns *ir, Reg r, int32_t ofs) -{ -#if LJ_SOFTFP - lua_assert(!irt_isnum(ir->t)); UNUSED(ir); -#else - if (r >= RID_MAX_GPR) - emit_vlso(as, irt_isnum(ir->t) ? ARMI_VLDR_D : ARMI_VLDR_S, r, RID_SP, ofs); - else -#endif - emit_lso(as, ARMI_LDR, r, RID_SP, ofs); -} - -/* Generic store of register to stack slot. */ -static void emit_spstore(ASMState *as, IRIns *ir, Reg r, int32_t ofs) -{ -#if LJ_SOFTFP - lua_assert(!irt_isnum(ir->t)); UNUSED(ir); -#else - if (r >= RID_MAX_GPR) - emit_vlso(as, irt_isnum(ir->t) ? ARMI_VSTR_D : ARMI_VSTR_S, r, RID_SP, ofs); - else -#endif - emit_lso(as, ARMI_STR, r, RID_SP, ofs); -} - -/* Emit an arithmetic/logic operation with a constant operand. */ -static void emit_opk(ASMState *as, ARMIns ai, Reg dest, Reg src, - int32_t i, RegSet allow) -{ - uint32_t k = emit_isk12(ai, i); - if (k) - emit_dn(as, ai^k, dest, src); - else - emit_dnm(as, ai, dest, src, ra_allock(as, i, allow)); -} - -/* Add offset to pointer. */ -static void emit_addptr(ASMState *as, Reg r, int32_t ofs) -{ - if (ofs) - emit_opk(as, ARMI_ADD, r, r, ofs, rset_exclude(RSET_GPR, r)); -} - -#define emit_spsub(as, ofs) emit_addptr(as, RID_SP, -(ofs)) - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_mips.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_mips.h deleted file mode 100644 index dc9197ad8..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_mips.h +++ /dev/null @@ -1,211 +0,0 @@ -/* -** MIPS instruction emitter. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -/* -- Emit basic instructions --------------------------------------------- */ - -static void emit_dst(ASMState *as, MIPSIns mi, Reg rd, Reg rs, Reg rt) -{ - *--as->mcp = mi | MIPSF_D(rd) | MIPSF_S(rs) | MIPSF_T(rt); -} - -static void emit_dta(ASMState *as, MIPSIns mi, Reg rd, Reg rt, uint32_t a) -{ - *--as->mcp = mi | MIPSF_D(rd) | MIPSF_T(rt) | MIPSF_A(a); -} - -#define emit_ds(as, mi, rd, rs) emit_dst(as, (mi), (rd), (rs), 0) -#define emit_tg(as, mi, rt, rg) emit_dst(as, (mi), (rg)&31, 0, (rt)) - -static void emit_tsi(ASMState *as, MIPSIns mi, Reg rt, Reg rs, int32_t i) -{ - *--as->mcp = mi | MIPSF_T(rt) | MIPSF_S(rs) | (i & 0xffff); -} - -#define emit_ti(as, mi, rt, i) emit_tsi(as, (mi), (rt), 0, (i)) -#define emit_hsi(as, mi, rh, rs, i) emit_tsi(as, (mi), (rh) & 31, (rs), (i)) - -static void emit_fgh(ASMState *as, MIPSIns mi, Reg rf, Reg rg, Reg rh) -{ - *--as->mcp = mi | MIPSF_F(rf&31) | MIPSF_G(rg&31) | MIPSF_H(rh&31); -} - -#define emit_fg(as, mi, rf, rg) emit_fgh(as, (mi), (rf), (rg), 0) - -static void emit_rotr(ASMState *as, Reg dest, Reg src, Reg tmp, uint32_t shift) -{ - if ((as->flags & JIT_F_MIPS32R2)) { - emit_dta(as, MIPSI_ROTR, dest, src, shift); - } else { - emit_dst(as, MIPSI_OR, dest, dest, tmp); - emit_dta(as, MIPSI_SLL, dest, src, (-shift)&31); - emit_dta(as, MIPSI_SRL, tmp, src, shift); - } -} - -/* -- Emit loads/stores --------------------------------------------------- */ - -/* Prefer rematerialization of BASE/L from global_State over spills. */ -#define emit_canremat(ref) ((ref) <= REF_BASE) - -/* Try to find a one step delta relative to another constant. */ -static int emit_kdelta1(ASMState *as, Reg t, int32_t i) -{ - RegSet work = ~as->freeset & RSET_GPR; - while (work) { - Reg r = rset_picktop(work); - IRRef ref = regcost_ref(as->cost[r]); - lua_assert(r != t); - if (ref < ASMREF_L) { - int32_t delta = i - (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i); - if (checki16(delta)) { - emit_tsi(as, MIPSI_ADDIU, t, r, delta); - return 1; - } - } - rset_clear(work, r); - } - return 0; /* Failed. */ -} - -/* Load a 32 bit constant into a GPR. */ -static void emit_loadi(ASMState *as, Reg r, int32_t i) -{ - if (checki16(i)) { - emit_ti(as, MIPSI_LI, r, i); - } else { - if ((i & 0xffff)) { - int32_t jgl = i32ptr(J2G(as->J)); - if ((uint32_t)(i-jgl) < 65536) { - emit_tsi(as, MIPSI_ADDIU, r, RID_JGL, i-jgl-32768); - return; - } else if (emit_kdelta1(as, r, i)) { - return; - } else if ((i >> 16) == 0) { - emit_tsi(as, MIPSI_ORI, r, RID_ZERO, i); - return; - } - emit_tsi(as, MIPSI_ORI, r, r, i); - } - emit_ti(as, MIPSI_LUI, r, (i >> 16)); - } -} - -#define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr))) - -static Reg ra_allock(ASMState *as, int32_t k, RegSet allow); -static void ra_allockreg(ASMState *as, int32_t k, Reg r); - -/* Get/set from constant pointer. */ -static void emit_lsptr(ASMState *as, MIPSIns mi, Reg r, void *p, RegSet allow) -{ - int32_t jgl = i32ptr(J2G(as->J)); - int32_t i = i32ptr(p); - Reg base; - if ((uint32_t)(i-jgl) < 65536) { - i = i-jgl-32768; - base = RID_JGL; - } else { - base = ra_allock(as, i-(int16_t)i, allow); - } - emit_tsi(as, mi, r, base, i); -} - -#define emit_loadn(as, r, tv) \ - emit_lsptr(as, MIPSI_LDC1, ((r) & 31), (void *)(tv), RSET_GPR) - -/* Get/set global_State fields. */ -static void emit_lsglptr(ASMState *as, MIPSIns mi, Reg r, int32_t ofs) -{ - emit_tsi(as, mi, r, RID_JGL, ofs-32768); -} - -#define emit_getgl(as, r, field) \ - emit_lsglptr(as, MIPSI_LW, (r), (int32_t)offsetof(global_State, field)) -#define emit_setgl(as, r, field) \ - emit_lsglptr(as, MIPSI_SW, (r), (int32_t)offsetof(global_State, field)) - -/* Trace number is determined from per-trace exit stubs. */ -#define emit_setvmstate(as, i) UNUSED(i) - -/* -- Emit control-flow instructions -------------------------------------- */ - -/* Label for internal jumps. */ -typedef MCode *MCLabel; - -/* Return label pointing to current PC. */ -#define emit_label(as) ((as)->mcp) - -static void emit_branch(ASMState *as, MIPSIns mi, Reg rs, Reg rt, MCode *target) -{ - MCode *p = as->mcp; - ptrdiff_t delta = target - p; - lua_assert(((delta + 0x8000) >> 16) == 0); - *--p = mi | MIPSF_S(rs) | MIPSF_T(rt) | ((uint32_t)delta & 0xffffu); - as->mcp = p; -} - -static void emit_jmp(ASMState *as, MCode *target) -{ - *--as->mcp = MIPSI_NOP; - emit_branch(as, MIPSI_B, RID_ZERO, RID_ZERO, (target)); -} - -static void emit_call(ASMState *as, void *target) -{ - MCode *p = as->mcp; - *--p = MIPSI_NOP; - if ((((uintptr_t)target ^ (uintptr_t)p) >> 28) == 0) - *--p = MIPSI_JAL | (((uintptr_t)target >>2) & 0x03ffffffu); - else /* Target out of range: need indirect call. */ - *--p = MIPSI_JALR | MIPSF_S(RID_CFUNCADDR); - as->mcp = p; - ra_allockreg(as, i32ptr(target), RID_CFUNCADDR); -} - -/* -- Emit generic operations --------------------------------------------- */ - -#define emit_move(as, dst, src) \ - emit_ds(as, MIPSI_MOVE, (dst), (src)) - -/* Generic move between two regs. */ -static void emit_movrr(ASMState *as, IRIns *ir, Reg dst, Reg src) -{ - if (dst < RID_MAX_GPR) - emit_move(as, dst, src); - else - emit_fg(as, irt_isnum(ir->t) ? MIPSI_MOV_D : MIPSI_MOV_S, dst, src); -} - -/* Generic load of register from stack slot. */ -static void emit_spload(ASMState *as, IRIns *ir, Reg r, int32_t ofs) -{ - if (r < RID_MAX_GPR) - emit_tsi(as, MIPSI_LW, r, RID_SP, ofs); - else - emit_tsi(as, irt_isnum(ir->t) ? MIPSI_LDC1 : MIPSI_LWC1, - (r & 31), RID_SP, ofs); -} - -/* Generic store of register to stack slot. */ -static void emit_spstore(ASMState *as, IRIns *ir, Reg r, int32_t ofs) -{ - if (r < RID_MAX_GPR) - emit_tsi(as, MIPSI_SW, r, RID_SP, ofs); - else - emit_tsi(as, irt_isnum(ir->t) ? MIPSI_SDC1 : MIPSI_SWC1, - (r&31), RID_SP, ofs); -} - -/* Add offset to pointer. */ -static void emit_addptr(ASMState *as, Reg r, int32_t ofs) -{ - if (ofs) { - lua_assert(checki16(ofs)); - emit_tsi(as, MIPSI_ADDIU, r, r, ofs); - } -} - -#define emit_spsub(as, ofs) emit_addptr(as, RID_SP, -(ofs)) - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_ppc.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_ppc.h deleted file mode 100644 index 3a2ae3894..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_ppc.h +++ /dev/null @@ -1,238 +0,0 @@ -/* -** PPC instruction emitter. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -/* -- Emit basic instructions --------------------------------------------- */ - -static void emit_tab(ASMState *as, PPCIns pi, Reg rt, Reg ra, Reg rb) -{ - *--as->mcp = pi | PPCF_T(rt) | PPCF_A(ra) | PPCF_B(rb); -} - -#define emit_asb(as, pi, ra, rs, rb) emit_tab(as, (pi), (rs), (ra), (rb)) -#define emit_as(as, pi, ra, rs) emit_tab(as, (pi), (rs), (ra), 0) -#define emit_ab(as, pi, ra, rb) emit_tab(as, (pi), 0, (ra), (rb)) - -static void emit_tai(ASMState *as, PPCIns pi, Reg rt, Reg ra, int32_t i) -{ - *--as->mcp = pi | PPCF_T(rt) | PPCF_A(ra) | (i & 0xffff); -} - -#define emit_ti(as, pi, rt, i) emit_tai(as, (pi), (rt), 0, (i)) -#define emit_ai(as, pi, ra, i) emit_tai(as, (pi), 0, (ra), (i)) -#define emit_asi(as, pi, ra, rs, i) emit_tai(as, (pi), (rs), (ra), (i)) - -#define emit_fab(as, pi, rf, ra, rb) \ - emit_tab(as, (pi), (rf)&31, (ra)&31, (rb)&31) -#define emit_fb(as, pi, rf, rb) emit_tab(as, (pi), (rf)&31, 0, (rb)&31) -#define emit_fac(as, pi, rf, ra, rc) \ - emit_tab(as, (pi) | PPCF_C((rc) & 31), (rf)&31, (ra)&31, 0) -#define emit_facb(as, pi, rf, ra, rc, rb) \ - emit_tab(as, (pi) | PPCF_C((rc) & 31), (rf)&31, (ra)&31, (rb)&31) -#define emit_fai(as, pi, rf, ra, i) emit_tai(as, (pi), (rf)&31, (ra), (i)) - -static void emit_rot(ASMState *as, PPCIns pi, Reg ra, Reg rs, - int32_t n, int32_t b, int32_t e) -{ - *--as->mcp = pi | PPCF_T(rs) | PPCF_A(ra) | PPCF_B(n) | - PPCF_MB(b) | PPCF_ME(e); -} - -static void emit_slwi(ASMState *as, Reg ra, Reg rs, int32_t n) -{ - lua_assert(n >= 0 && n < 32); - emit_rot(as, PPCI_RLWINM, ra, rs, n, 0, 31-n); -} - -static void emit_rotlwi(ASMState *as, Reg ra, Reg rs, int32_t n) -{ - lua_assert(n >= 0 && n < 32); - emit_rot(as, PPCI_RLWINM, ra, rs, n, 0, 31); -} - -/* -- Emit loads/stores --------------------------------------------------- */ - -/* Prefer rematerialization of BASE/L from global_State over spills. */ -#define emit_canremat(ref) ((ref) <= REF_BASE) - -/* Try to find a one step delta relative to another constant. */ -static int emit_kdelta1(ASMState *as, Reg t, int32_t i) -{ - RegSet work = ~as->freeset & RSET_GPR; - while (work) { - Reg r = rset_picktop(work); - IRRef ref = regcost_ref(as->cost[r]); - lua_assert(r != t); - if (ref < ASMREF_L) { - int32_t delta = i - (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i); - if (checki16(delta)) { - emit_tai(as, PPCI_ADDI, t, r, delta); - return 1; - } - } - rset_clear(work, r); - } - return 0; /* Failed. */ -} - -/* Load a 32 bit constant into a GPR. */ -static void emit_loadi(ASMState *as, Reg r, int32_t i) -{ - if (checki16(i)) { - emit_ti(as, PPCI_LI, r, i); - } else { - if ((i & 0xffff)) { - int32_t jgl = i32ptr(J2G(as->J)); - if ((uint32_t)(i-jgl) < 65536) { - emit_tai(as, PPCI_ADDI, r, RID_JGL, i-jgl-32768); - return; - } else if (emit_kdelta1(as, r, i)) { - return; - } - emit_asi(as, PPCI_ORI, r, r, i); - } - emit_ti(as, PPCI_LIS, r, (i >> 16)); - } -} - -#define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr))) - -static Reg ra_allock(ASMState *as, int32_t k, RegSet allow); - -/* Get/set from constant pointer. */ -static void emit_lsptr(ASMState *as, PPCIns pi, Reg r, void *p, RegSet allow) -{ - int32_t jgl = i32ptr(J2G(as->J)); - int32_t i = i32ptr(p); - Reg base; - if ((uint32_t)(i-jgl) < 65536) { - i = i-jgl-32768; - base = RID_JGL; - } else { - base = ra_allock(as, i-(int16_t)i, allow); - } - emit_tai(as, pi, r, base, i); -} - -#define emit_loadn(as, r, tv) \ - emit_lsptr(as, PPCI_LFD, ((r) & 31), (void *)(tv), RSET_GPR) - -/* Get/set global_State fields. */ -static void emit_lsglptr(ASMState *as, PPCIns pi, Reg r, int32_t ofs) -{ - emit_tai(as, pi, r, RID_JGL, ofs-32768); -} - -#define emit_getgl(as, r, field) \ - emit_lsglptr(as, PPCI_LWZ, (r), (int32_t)offsetof(global_State, field)) -#define emit_setgl(as, r, field) \ - emit_lsglptr(as, PPCI_STW, (r), (int32_t)offsetof(global_State, field)) - -/* Trace number is determined from per-trace exit stubs. */ -#define emit_setvmstate(as, i) UNUSED(i) - -/* -- Emit control-flow instructions -------------------------------------- */ - -/* Label for internal jumps. */ -typedef MCode *MCLabel; - -/* Return label pointing to current PC. */ -#define emit_label(as) ((as)->mcp) - -static void emit_condbranch(ASMState *as, PPCIns pi, PPCCC cc, MCode *target) -{ - MCode *p = --as->mcp; - ptrdiff_t delta = (char *)target - (char *)p; - lua_assert(((delta + 0x8000) >> 16) == 0); - pi ^= (delta & 0x8000) * (PPCF_Y/0x8000); - *p = pi | PPCF_CC(cc) | ((uint32_t)delta & 0xffffu); -} - -static void emit_jmp(ASMState *as, MCode *target) -{ - MCode *p = --as->mcp; - ptrdiff_t delta = (char *)target - (char *)p; - *p = PPCI_B | (delta & 0x03fffffcu); -} - -static void emit_call(ASMState *as, void *target) -{ - MCode *p = --as->mcp; - ptrdiff_t delta = (char *)target - (char *)p; - if ((((delta>>2) + 0x00800000) >> 24) == 0) { - *p = PPCI_BL | (delta & 0x03fffffcu); - } else { /* Target out of range: need indirect call. Don't use arg reg. */ - RegSet allow = RSET_GPR & ~RSET_RANGE(RID_R0, REGARG_LASTGPR+1); - Reg r = ra_allock(as, i32ptr(target), allow); - *p = PPCI_BCTRL; - p[-1] = PPCI_MTCTR | PPCF_T(r); - as->mcp = p-1; - } -} - -/* -- Emit generic operations --------------------------------------------- */ - -#define emit_mr(as, dst, src) \ - emit_asb(as, PPCI_MR, (dst), (src), (src)) - -/* Generic move between two regs. */ -static void emit_movrr(ASMState *as, IRIns *ir, Reg dst, Reg src) -{ - UNUSED(ir); - if (dst < RID_MAX_GPR) - emit_mr(as, dst, src); - else - emit_fb(as, PPCI_FMR, dst, src); -} - -/* Generic load of register from stack slot. */ -static void emit_spload(ASMState *as, IRIns *ir, Reg r, int32_t ofs) -{ - if (r < RID_MAX_GPR) - emit_tai(as, PPCI_LWZ, r, RID_SP, ofs); - else - emit_fai(as, irt_isnum(ir->t) ? PPCI_LFD : PPCI_LFS, r, RID_SP, ofs); -} - -/* Generic store of register to stack slot. */ -static void emit_spstore(ASMState *as, IRIns *ir, Reg r, int32_t ofs) -{ - if (r < RID_MAX_GPR) - emit_tai(as, PPCI_STW, r, RID_SP, ofs); - else - emit_fai(as, irt_isnum(ir->t) ? PPCI_STFD : PPCI_STFS, r, RID_SP, ofs); -} - -/* Emit a compare (for equality) with a constant operand. */ -static void emit_cmpi(ASMState *as, Reg r, int32_t k) -{ - if (checki16(k)) { - emit_ai(as, PPCI_CMPWI, r, k); - } else if (checku16(k)) { - emit_ai(as, PPCI_CMPLWI, r, k); - } else { - emit_ai(as, PPCI_CMPLWI, RID_TMP, k); - emit_asi(as, PPCI_XORIS, RID_TMP, r, (k >> 16)); - } -} - -/* Add offset to pointer. */ -static void emit_addptr(ASMState *as, Reg r, int32_t ofs) -{ - if (ofs) { - emit_tai(as, PPCI_ADDI, r, r, ofs); - if (!checki16(ofs)) - emit_tai(as, PPCI_ADDIS, r, r, (ofs + 32768) >> 16); - } -} - -static void emit_spsub(ASMState *as, int32_t ofs) -{ - if (ofs) { - emit_tai(as, PPCI_STWU, RID_TMP, RID_SP, -ofs); - emit_tai(as, PPCI_ADDI, RID_TMP, RID_SP, - CFRAME_SIZE + (as->parent ? as->parent->spadjust : 0)); - } -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_x86.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_x86.h deleted file mode 100644 index 8cfb654f3..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_emit_x86.h +++ /dev/null @@ -1,466 +0,0 @@ -/* -** x86/x64 instruction emitter. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -/* -- Emit basic instructions --------------------------------------------- */ - -#define MODRM(mode, r1, r2) ((MCode)((mode)+(((r1)&7)<<3)+((r2)&7))) - -#if LJ_64 -#define REXRB(p, rr, rb) \ - { MCode rex = 0x40 + (((rr)>>1)&4) + (((rb)>>3)&1); \ - if (rex != 0x40) *--(p) = rex; } -#define FORCE_REX 0x200 -#define REX_64 (FORCE_REX|0x080000) -#else -#define REXRB(p, rr, rb) ((void)0) -#define FORCE_REX 0 -#define REX_64 0 -#endif - -#define emit_i8(as, i) (*--as->mcp = (MCode)(i)) -#define emit_i32(as, i) (*(int32_t *)(as->mcp-4) = (i), as->mcp -= 4) -#define emit_u32(as, u) (*(uint32_t *)(as->mcp-4) = (u), as->mcp -= 4) - -#define emit_x87op(as, xo) \ - (*(uint16_t *)(as->mcp-2) = (uint16_t)(xo), as->mcp -= 2) - -/* op */ -static LJ_AINLINE MCode *emit_op(x86Op xo, Reg rr, Reg rb, Reg rx, - MCode *p, int delta) -{ - int n = (int8_t)xo; -#if defined(__GNUC__) - if (__builtin_constant_p(xo) && n == -2) - p[delta-2] = (MCode)(xo >> 24); - else if (__builtin_constant_p(xo) && n == -3) - *(uint16_t *)(p+delta-3) = (uint16_t)(xo >> 16); - else -#endif - *(uint32_t *)(p+delta-5) = (uint32_t)xo; - p += n + delta; -#if LJ_64 - { - uint32_t rex = 0x40 + ((rr>>1)&(4+(FORCE_REX>>1)))+((rx>>2)&2)+((rb>>3)&1); - if (rex != 0x40) { - rex |= (rr >> 16); - if (n == -4) { *p = (MCode)rex; rex = (MCode)(xo >> 8); } - else if ((xo & 0xffffff) == 0x6600fd) { *p = (MCode)rex; rex = 0x66; } - *--p = (MCode)rex; - } - } -#else - UNUSED(rr); UNUSED(rb); UNUSED(rx); -#endif - return p; -} - -/* op + modrm */ -#define emit_opm(xo, mode, rr, rb, p, delta) \ - (p[(delta)-1] = MODRM((mode), (rr), (rb)), \ - emit_op((xo), (rr), (rb), 0, (p), (delta))) - -/* op + modrm + sib */ -#define emit_opmx(xo, mode, scale, rr, rb, rx, p) \ - (p[-1] = MODRM((scale), (rx), (rb)), \ - p[-2] = MODRM((mode), (rr), RID_ESP), \ - emit_op((xo), (rr), (rb), (rx), (p), -1)) - -/* op r1, r2 */ -static void emit_rr(ASMState *as, x86Op xo, Reg r1, Reg r2) -{ - MCode *p = as->mcp; - as->mcp = emit_opm(xo, XM_REG, r1, r2, p, 0); -} - -#if LJ_64 && defined(LUA_USE_ASSERT) -/* [addr] is sign-extended in x64 and must be in lower 2G (not 4G). */ -static int32_t ptr2addr(const void *p) -{ - lua_assert((uintptr_t)p < (uintptr_t)0x80000000); - return i32ptr(p); -} -#else -#define ptr2addr(p) (i32ptr((p))) -#endif - -/* op r, [addr] */ -static void emit_rma(ASMState *as, x86Op xo, Reg rr, const void *addr) -{ - MCode *p = as->mcp; - *(int32_t *)(p-4) = ptr2addr(addr); -#if LJ_64 - p[-5] = MODRM(XM_SCALE1, RID_ESP, RID_EBP); - as->mcp = emit_opm(xo, XM_OFS0, rr, RID_ESP, p, -5); -#else - as->mcp = emit_opm(xo, XM_OFS0, rr, RID_EBP, p, -4); -#endif -} - -/* op r, [base+ofs] */ -static void emit_rmro(ASMState *as, x86Op xo, Reg rr, Reg rb, int32_t ofs) -{ - MCode *p = as->mcp; - x86Mode mode; - if (ra_hasreg(rb)) { - if (ofs == 0 && (rb&7) != RID_EBP) { - mode = XM_OFS0; - } else if (checki8(ofs)) { - *--p = (MCode)ofs; - mode = XM_OFS8; - } else { - p -= 4; - *(int32_t *)p = ofs; - mode = XM_OFS32; - } - if ((rb&7) == RID_ESP) - *--p = MODRM(XM_SCALE1, RID_ESP, RID_ESP); - } else { - *(int32_t *)(p-4) = ofs; -#if LJ_64 - p[-5] = MODRM(XM_SCALE1, RID_ESP, RID_EBP); - p -= 5; - rb = RID_ESP; -#else - p -= 4; - rb = RID_EBP; -#endif - mode = XM_OFS0; - } - as->mcp = emit_opm(xo, mode, rr, rb, p, 0); -} - -/* op r, [base+idx*scale+ofs] */ -static void emit_rmrxo(ASMState *as, x86Op xo, Reg rr, Reg rb, Reg rx, - x86Mode scale, int32_t ofs) -{ - MCode *p = as->mcp; - x86Mode mode; - if (ofs == 0 && (rb&7) != RID_EBP) { - mode = XM_OFS0; - } else if (checki8(ofs)) { - mode = XM_OFS8; - *--p = (MCode)ofs; - } else { - mode = XM_OFS32; - p -= 4; - *(int32_t *)p = ofs; - } - as->mcp = emit_opmx(xo, mode, scale, rr, rb, rx, p); -} - -/* op r, i */ -static void emit_gri(ASMState *as, x86Group xg, Reg rb, int32_t i) -{ - MCode *p = as->mcp; - x86Op xo; - if (checki8(i)) { - *--p = (MCode)i; - xo = XG_TOXOi8(xg); - } else { - p -= 4; - *(int32_t *)p = i; - xo = XG_TOXOi(xg); - } - as->mcp = emit_opm(xo, XM_REG, (Reg)(xg & 7) | (rb & REX_64), rb, p, 0); -} - -/* op [base+ofs], i */ -static void emit_gmroi(ASMState *as, x86Group xg, Reg rb, int32_t ofs, - int32_t i) -{ - x86Op xo; - if (checki8(i)) { - emit_i8(as, i); - xo = XG_TOXOi8(xg); - } else { - emit_i32(as, i); - xo = XG_TOXOi(xg); - } - emit_rmro(as, xo, (Reg)(xg & 7), rb, ofs); -} - -#define emit_shifti(as, xg, r, i) \ - (emit_i8(as, (i)), emit_rr(as, XO_SHIFTi, (Reg)(xg), (r))) - -/* op r, rm/mrm */ -static void emit_mrm(ASMState *as, x86Op xo, Reg rr, Reg rb) -{ - MCode *p = as->mcp; - x86Mode mode = XM_REG; - if (rb == RID_MRM) { - rb = as->mrm.base; - if (rb == RID_NONE) { - rb = RID_EBP; - mode = XM_OFS0; - p -= 4; - *(int32_t *)p = as->mrm.ofs; - if (as->mrm.idx != RID_NONE) - goto mrmidx; -#if LJ_64 - *--p = MODRM(XM_SCALE1, RID_ESP, RID_EBP); - rb = RID_ESP; -#endif - } else { - if (as->mrm.ofs == 0 && (rb&7) != RID_EBP) { - mode = XM_OFS0; - } else if (checki8(as->mrm.ofs)) { - *--p = (MCode)as->mrm.ofs; - mode = XM_OFS8; - } else { - p -= 4; - *(int32_t *)p = as->mrm.ofs; - mode = XM_OFS32; - } - if (as->mrm.idx != RID_NONE) { - mrmidx: - as->mcp = emit_opmx(xo, mode, as->mrm.scale, rr, rb, as->mrm.idx, p); - return; - } - if ((rb&7) == RID_ESP) - *--p = MODRM(XM_SCALE1, RID_ESP, RID_ESP); - } - } - as->mcp = emit_opm(xo, mode, rr, rb, p, 0); -} - -/* op rm/mrm, i */ -static void emit_gmrmi(ASMState *as, x86Group xg, Reg rb, int32_t i) -{ - x86Op xo; - if (checki8(i)) { - emit_i8(as, i); - xo = XG_TOXOi8(xg); - } else { - emit_i32(as, i); - xo = XG_TOXOi(xg); - } - emit_mrm(as, xo, (Reg)(xg & 7) | (rb & REX_64), (rb & ~REX_64)); -} - -/* -- Emit loads/stores --------------------------------------------------- */ - -/* Instruction selection for XMM moves. */ -#define XMM_MOVRR(as) ((as->flags & JIT_F_SPLIT_XMM) ? XO_MOVSD : XO_MOVAPS) -#define XMM_MOVRM(as) ((as->flags & JIT_F_SPLIT_XMM) ? XO_MOVLPD : XO_MOVSD) - -/* mov [base+ofs], i */ -static void emit_movmroi(ASMState *as, Reg base, int32_t ofs, int32_t i) -{ - emit_i32(as, i); - emit_rmro(as, XO_MOVmi, 0, base, ofs); -} - -/* mov [base+ofs], r */ -#define emit_movtomro(as, r, base, ofs) \ - emit_rmro(as, XO_MOVto, (r), (base), (ofs)) - -/* Get/set global_State fields. */ -#define emit_opgl(as, xo, r, field) \ - emit_rma(as, (xo), (r), (void *)&J2G(as->J)->field) -#define emit_getgl(as, r, field) emit_opgl(as, XO_MOV, (r), field) -#define emit_setgl(as, r, field) emit_opgl(as, XO_MOVto, (r), field) - -#define emit_setvmstate(as, i) \ - (emit_i32(as, i), emit_opgl(as, XO_MOVmi, 0, vmstate)) - -/* mov r, i / xor r, r */ -static void emit_loadi(ASMState *as, Reg r, int32_t i) -{ - /* XOR r,r is shorter, but modifies the flags. This is bad for HIOP. */ - if (i == 0 && !(LJ_32 && (IR(as->curins)->o == IR_HIOP || - (as->curins+1 < as->T->nins && - IR(as->curins+1)->o == IR_HIOP)))) { - emit_rr(as, XO_ARITH(XOg_XOR), r, r); - } else { - MCode *p = as->mcp; - *(int32_t *)(p-4) = i; - p[-5] = (MCode)(XI_MOVri+(r&7)); - p -= 5; - REXRB(p, 0, r); - as->mcp = p; - } -} - -/* mov r, addr */ -#define emit_loada(as, r, addr) \ - emit_loadi(as, (r), ptr2addr((addr))) - -#if LJ_64 -/* mov r, imm64 or shorter 32 bit extended load. */ -static void emit_loadu64(ASMState *as, Reg r, uint64_t u64) -{ - if (checku32(u64)) { /* 32 bit load clears upper 32 bits. */ - emit_loadi(as, r, (int32_t)u64); - } else if (checki32((int64_t)u64)) { /* Sign-extended 32 bit load. */ - MCode *p = as->mcp; - *(int32_t *)(p-4) = (int32_t)u64; - as->mcp = emit_opm(XO_MOVmi, XM_REG, REX_64, r, p, -4); - } else { /* Full-size 64 bit load. */ - MCode *p = as->mcp; - *(uint64_t *)(p-8) = u64; - p[-9] = (MCode)(XI_MOVri+(r&7)); - p[-10] = 0x48 + ((r>>3)&1); - p -= 10; - as->mcp = p; - } -} -#endif - -/* movsd r, [&tv->n] / xorps r, r */ -static void emit_loadn(ASMState *as, Reg r, cTValue *tv) -{ - if (tvispzero(tv)) /* Use xor only for +0. */ - emit_rr(as, XO_XORPS, r, r); - else - emit_rma(as, XMM_MOVRM(as), r, &tv->n); -} - -/* -- Emit control-flow instructions -------------------------------------- */ - -/* Label for short jumps. */ -typedef MCode *MCLabel; - -#if LJ_32 && LJ_HASFFI -/* jmp short target */ -static void emit_sjmp(ASMState *as, MCLabel target) -{ - MCode *p = as->mcp; - ptrdiff_t delta = target - p; - lua_assert(delta == (int8_t)delta); - p[-1] = (MCode)(int8_t)delta; - p[-2] = XI_JMPs; - as->mcp = p - 2; -} -#endif - -/* jcc short target */ -static void emit_sjcc(ASMState *as, int cc, MCLabel target) -{ - MCode *p = as->mcp; - ptrdiff_t delta = target - p; - lua_assert(delta == (int8_t)delta); - p[-1] = (MCode)(int8_t)delta; - p[-2] = (MCode)(XI_JCCs+(cc&15)); - as->mcp = p - 2; -} - -/* jcc short (pending target) */ -static MCLabel emit_sjcc_label(ASMState *as, int cc) -{ - MCode *p = as->mcp; - p[-1] = 0; - p[-2] = (MCode)(XI_JCCs+(cc&15)); - as->mcp = p - 2; - return p; -} - -/* Fixup jcc short target. */ -static void emit_sfixup(ASMState *as, MCLabel source) -{ - source[-1] = (MCode)(as->mcp-source); -} - -/* Return label pointing to current PC. */ -#define emit_label(as) ((as)->mcp) - -/* Compute relative 32 bit offset for jump and call instructions. */ -static LJ_AINLINE int32_t jmprel(MCode *p, MCode *target) -{ - ptrdiff_t delta = target - p; - lua_assert(delta == (int32_t)delta); - return (int32_t)delta; -} - -/* jcc target */ -static void emit_jcc(ASMState *as, int cc, MCode *target) -{ - MCode *p = as->mcp; - *(int32_t *)(p-4) = jmprel(p, target); - p[-5] = (MCode)(XI_JCCn+(cc&15)); - p[-6] = 0x0f; - as->mcp = p - 6; -} - -/* jmp target */ -static void emit_jmp(ASMState *as, MCode *target) -{ - MCode *p = as->mcp; - *(int32_t *)(p-4) = jmprel(p, target); - p[-5] = XI_JMP; - as->mcp = p - 5; -} - -/* call target */ -static void emit_call_(ASMState *as, MCode *target) -{ - MCode *p = as->mcp; -#if LJ_64 - if (target-p != (int32_t)(target-p)) { - /* Assumes RID_RET is never an argument to calls and always clobbered. */ - emit_rr(as, XO_GROUP5, XOg_CALL, RID_RET); - emit_loadu64(as, RID_RET, (uint64_t)target); - return; - } -#endif - *(int32_t *)(p-4) = jmprel(p, target); - p[-5] = XI_CALL; - as->mcp = p - 5; -} - -#define emit_call(as, f) emit_call_(as, (MCode *)(void *)(f)) - -/* -- Emit generic operations --------------------------------------------- */ - -/* Use 64 bit operations to handle 64 bit IR types. */ -#if LJ_64 -#define REX_64IR(ir, r) ((r) + (irt_is64((ir)->t) ? REX_64 : 0)) -#else -#define REX_64IR(ir, r) (r) -#endif - -/* Generic move between two regs. */ -static void emit_movrr(ASMState *as, IRIns *ir, Reg dst, Reg src) -{ - UNUSED(ir); - if (dst < RID_MAX_GPR) - emit_rr(as, XO_MOV, REX_64IR(ir, dst), src); - else - emit_rr(as, XMM_MOVRR(as), dst, src); -} - -/* Generic load of register from stack slot. */ -static void emit_spload(ASMState *as, IRIns *ir, Reg r, int32_t ofs) -{ - if (r < RID_MAX_GPR) - emit_rmro(as, XO_MOV, REX_64IR(ir, r), RID_ESP, ofs); - else - emit_rmro(as, irt_isnum(ir->t) ? XMM_MOVRM(as) : XO_MOVSS, r, RID_ESP, ofs); -} - -/* Generic store of register to stack slot. */ -static void emit_spstore(ASMState *as, IRIns *ir, Reg r, int32_t ofs) -{ - if (r < RID_MAX_GPR) - emit_rmro(as, XO_MOVto, REX_64IR(ir, r), RID_ESP, ofs); - else - emit_rmro(as, irt_isnum(ir->t) ? XO_MOVSDto : XO_MOVSSto, r, RID_ESP, ofs); -} - -/* Add offset to pointer. */ -static void emit_addptr(ASMState *as, Reg r, int32_t ofs) -{ - if (ofs) { - if ((as->flags & JIT_F_LEA_AGU)) - emit_rmro(as, XO_LEA, r, r, ofs); - else - emit_gri(as, XG_ARITHi(XOg_ADD), r, ofs); - } -} - -#define emit_spsub(as, ofs) emit_addptr(as, RID_ESP|REX_64, -(ofs)) - -/* Prefer rematerialization of BASE/L from global_State over spills. */ -#define emit_canremat(ref) ((ref) <= REF_BASE) - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_err.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_err.c deleted file mode 100644 index db1826733..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_err.c +++ /dev/null @@ -1,785 +0,0 @@ -/* -** Error handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_err_c -#define LUA_CORE - -#include "lj_obj.h" -#include "lj_err.h" -#include "lj_debug.h" -#include "lj_str.h" -#include "lj_func.h" -#include "lj_state.h" -#include "lj_frame.h" -#include "lj_ff.h" -#include "lj_trace.h" -#include "lj_vm.h" - -/* -** LuaJIT can either use internal or external frame unwinding: -** -** - Internal frame unwinding (INT) is free-standing and doesn't require -** any OS or library support. -** -** - External frame unwinding (EXT) uses the system-provided unwind handler. -** -** Pros and Cons: -** -** - EXT requires unwind tables for *all* functions on the C stack between -** the pcall/catch and the error/throw. This is the default on x64, -** but needs to be manually enabled on x86/PPC for non-C++ code. -** -** - INT is faster when actually throwing errors (but this happens rarely). -** Setting up error handlers is zero-cost in any case. -** -** - EXT provides full interoperability with C++ exceptions. You can throw -** Lua errors or C++ exceptions through a mix of Lua frames and C++ frames. -** C++ destructors are called as needed. C++ exceptions caught by pcall -** are converted to the string "C++ exception". Lua errors can be caught -** with catch (...) in C++. -** -** - INT has only limited support for automatically catching C++ exceptions -** on POSIX systems using DWARF2 stack unwinding. Other systems may use -** the wrapper function feature. Lua errors thrown through C++ frames -** cannot be caught by C++ code and C++ destructors are not run. -** -** EXT is the default on x64 systems, INT is the default on all other systems. -** -** EXT can be manually enabled on POSIX systems using GCC and DWARF2 stack -** unwinding with -DLUAJIT_UNWIND_EXTERNAL. *All* C code must be compiled -** with -funwind-tables (or -fexceptions). This includes LuaJIT itself (set -** TARGET_CFLAGS), all of your C/Lua binding code, all loadable C modules -** and all C libraries that have callbacks which may be used to call back -** into Lua. C++ code must *not* be compiled with -fno-exceptions. -** -** EXT cannot be enabled on WIN32 since system exceptions use code-driven SEH. -** EXT is mandatory on WIN64 since the calling convention has an abundance -** of callee-saved registers (rbx, rbp, rsi, rdi, r12-r15, xmm6-xmm15). -** EXT is mandatory on POSIX/x64 since the interpreter doesn't save r12/r13. -*/ - -#if defined(__GNUC__) && (LJ_TARGET_X64 || defined(LUAJIT_UNWIND_EXTERNAL)) -#define LJ_UNWIND_EXT 1 -#elif LJ_TARGET_X64 && LJ_TARGET_WINDOWS -#define LJ_UNWIND_EXT 1 -#endif - -/* -- Error messages ------------------------------------------------------ */ - -/* Error message strings. */ -LJ_DATADEF const char *lj_err_allmsg = -#define ERRDEF(name, msg) msg "\0" -#include "lj_errmsg.h" -; - -/* -- Internal frame unwinding -------------------------------------------- */ - -/* Unwind Lua stack and move error message to new top. */ -LJ_NOINLINE static void unwindstack(lua_State *L, TValue *top) -{ - lj_func_closeuv(L, top); - if (top < L->top-1) { - copyTV(L, top, L->top-1); - L->top = top+1; - } - lj_state_relimitstack(L); -} - -/* Unwind until stop frame. Optionally cleanup frames. */ -static void *err_unwind(lua_State *L, void *stopcf, int errcode) -{ - TValue *frame = L->base-1; - void *cf = L->cframe; - while (cf) { - int32_t nres = cframe_nres(cframe_raw(cf)); - if (nres < 0) { /* C frame without Lua frame? */ - TValue *top = restorestack(L, -nres); - if (frame < top) { /* Frame reached? */ - if (errcode) { - L->cframe = cframe_prev(cf); - L->base = frame+1; - unwindstack(L, top); - } - return cf; - } - } - if (frame <= tvref(L->stack)) - break; - switch (frame_typep(frame)) { - case FRAME_LUA: /* Lua frame. */ - case FRAME_LUAP: - frame = frame_prevl(frame); - break; - case FRAME_C: /* C frame. */ -#if LJ_HASFFI - unwind_c: -#endif -#if LJ_UNWIND_EXT - if (errcode) { - L->cframe = cframe_prev(cf); - L->base = frame_prevd(frame) + 1; - unwindstack(L, frame); - } else if (cf != stopcf) { - cf = cframe_prev(cf); - frame = frame_prevd(frame); - break; - } - return NULL; /* Continue unwinding. */ -#else - UNUSED(stopcf); - cf = cframe_prev(cf); - frame = frame_prevd(frame); - break; -#endif - case FRAME_CP: /* Protected C frame. */ - if (cframe_canyield(cf)) { /* Resume? */ - if (errcode) { - hook_leave(G(L)); /* Assumes nobody uses coroutines inside hooks. */ - L->cframe = NULL; - L->status = (uint8_t)errcode; - } - return cf; - } - if (errcode) { - L->cframe = cframe_prev(cf); - L->base = frame_prevd(frame) + 1; - unwindstack(L, frame); - } - return cf; - case FRAME_CONT: /* Continuation frame. */ -#if LJ_HASFFI - if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK) - goto unwind_c; -#endif - case FRAME_VARG: /* Vararg frame. */ - frame = frame_prevd(frame); - break; - case FRAME_PCALL: /* FF pcall() frame. */ - case FRAME_PCALLH: /* FF pcall() frame inside hook. */ - if (errcode) { - if (errcode == LUA_YIELD) { - frame = frame_prevd(frame); - break; - } - if (frame_typep(frame) == FRAME_PCALL) - hook_leave(G(L)); - L->cframe = cf; - L->base = frame_prevd(frame) + 1; - unwindstack(L, L->base); - } - return (void *)((intptr_t)cf | CFRAME_UNWIND_FF); - } - } - /* No C frame. */ - if (errcode) { - L->cframe = NULL; - L->base = tvref(L->stack)+1; - unwindstack(L, L->base); - if (G(L)->panic) - G(L)->panic(L); - exit(EXIT_FAILURE); - } - return L; /* Anything non-NULL will do. */ -} - -/* -- External frame unwinding -------------------------------------------- */ - -#if defined(__GNUC__) && !LJ_NO_UNWIND && !LJ_TARGET_WINDOWS - -/* -** We have to use our own definitions instead of the mandatory (!) unwind.h, -** since various OS, distros and compilers mess up the header installation. -*/ - -typedef struct _Unwind_Exception -{ - uint64_t exclass; - void (*excleanup)(int, struct _Unwind_Exception *); - uintptr_t p1, p2; -} __attribute__((__aligned__)) _Unwind_Exception; - -typedef struct _Unwind_Context _Unwind_Context; - -#define _URC_OK 0 -#define _URC_FATAL_PHASE1_ERROR 3 -#define _URC_HANDLER_FOUND 6 -#define _URC_INSTALL_CONTEXT 7 -#define _URC_CONTINUE_UNWIND 8 -#define _URC_FAILURE 9 - -#if !LJ_TARGET_ARM - -extern uintptr_t _Unwind_GetCFA(_Unwind_Context *); -extern void _Unwind_SetGR(_Unwind_Context *, int, uintptr_t); -extern void _Unwind_SetIP(_Unwind_Context *, uintptr_t); -extern void _Unwind_DeleteException(_Unwind_Exception *); -extern int _Unwind_RaiseException(_Unwind_Exception *); - -#define _UA_SEARCH_PHASE 1 -#define _UA_CLEANUP_PHASE 2 -#define _UA_HANDLER_FRAME 4 -#define _UA_FORCE_UNWIND 8 - -#define LJ_UEXCLASS 0x4c55414a49543200ULL /* LUAJIT2\0 */ -#define LJ_UEXCLASS_MAKE(c) (LJ_UEXCLASS | (uint64_t)(c)) -#define LJ_UEXCLASS_CHECK(cl) (((cl) ^ LJ_UEXCLASS) <= 0xff) -#define LJ_UEXCLASS_ERRCODE(cl) ((int)((cl) & 0xff)) - -/* DWARF2 personality handler referenced from interpreter .eh_frame. */ -LJ_FUNCA int lj_err_unwind_dwarf(int version, int actions, - uint64_t uexclass, _Unwind_Exception *uex, _Unwind_Context *ctx) -{ - void *cf; - lua_State *L; - if (version != 1) - return _URC_FATAL_PHASE1_ERROR; - UNUSED(uexclass); - cf = (void *)_Unwind_GetCFA(ctx); - L = cframe_L(cf); - if ((actions & _UA_SEARCH_PHASE)) { -#if LJ_UNWIND_EXT - if (err_unwind(L, cf, 0) == NULL) - return _URC_CONTINUE_UNWIND; -#endif - if (!LJ_UEXCLASS_CHECK(uexclass)) { - setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP)); - } - return _URC_HANDLER_FOUND; - } - if ((actions & _UA_CLEANUP_PHASE)) { - int errcode; - if (LJ_UEXCLASS_CHECK(uexclass)) { - errcode = LJ_UEXCLASS_ERRCODE(uexclass); - } else { - if ((actions & _UA_HANDLER_FRAME)) - _Unwind_DeleteException(uex); - errcode = LUA_ERRRUN; - } -#if LJ_UNWIND_EXT - cf = err_unwind(L, cf, errcode); - if ((actions & _UA_FORCE_UNWIND)) { - return _URC_CONTINUE_UNWIND; - } else if (cf) { - _Unwind_SetGR(ctx, LJ_TARGET_EHRETREG, errcode); - _Unwind_SetIP(ctx, (uintptr_t)(cframe_unwind_ff(cf) ? - lj_vm_unwind_ff_eh : - lj_vm_unwind_c_eh)); - return _URC_INSTALL_CONTEXT; - } -#if LJ_TARGET_X86ORX64 - else if ((actions & _UA_HANDLER_FRAME)) { - /* Workaround for ancient libgcc bug. Still present in RHEL 5.5. :-/ - ** Real fix: http://gcc.gnu.org/viewcvs/trunk/gcc/unwind-dw2.c?r1=121165&r2=124837&pathrev=153877&diff_format=h - */ - _Unwind_SetGR(ctx, LJ_TARGET_EHRETREG, errcode); - _Unwind_SetIP(ctx, (uintptr_t)lj_vm_unwind_rethrow); - return _URC_INSTALL_CONTEXT; - } -#endif -#else - /* This is not the proper way to escape from the unwinder. We get away with - ** it on non-x64 because the interpreter restores all callee-saved regs. - */ - lj_err_throw(L, errcode); -#endif - } - return _URC_CONTINUE_UNWIND; -} - -#if LJ_UNWIND_EXT -#if LJ_TARGET_OSX || defined(__OpenBSD__) -/* Sorry, no thread safety for OSX. Complain to Apple, not me. */ -static _Unwind_Exception static_uex; -#else -static __thread _Unwind_Exception static_uex; -#endif - -/* Raise DWARF2 exception. */ -static void err_raise_ext(int errcode) -{ - static_uex.exclass = LJ_UEXCLASS_MAKE(errcode); - static_uex.excleanup = NULL; - _Unwind_RaiseException(&static_uex); -} -#endif - -#else - -extern void _Unwind_DeleteException(void *); -extern int __gnu_unwind_frame (void *, _Unwind_Context *); -extern int _Unwind_VRS_Set(_Unwind_Context *, int, uint32_t, int, void *); -extern int _Unwind_VRS_Get(_Unwind_Context *, int, uint32_t, int, void *); - -static inline uint32_t _Unwind_GetGR(_Unwind_Context *ctx, int r) -{ - uint32_t v; - _Unwind_VRS_Get(ctx, 0, r, 0, &v); - return v; -} - -static inline void _Unwind_SetGR(_Unwind_Context *ctx, int r, uint32_t v) -{ - _Unwind_VRS_Set(ctx, 0, r, 0, &v); -} - -#define _US_VIRTUAL_UNWIND_FRAME 0 -#define _US_UNWIND_FRAME_STARTING 1 -#define _US_ACTION_MASK 3 -#define _US_FORCE_UNWIND 8 - -/* ARM unwinder personality handler referenced from interpreter .ARM.extab. */ -LJ_FUNCA int lj_err_unwind_arm(int state, void *ucb, _Unwind_Context *ctx) -{ - void *cf = (void *)_Unwind_GetGR(ctx, 13); - lua_State *L = cframe_L(cf); - if ((state & _US_ACTION_MASK) == _US_VIRTUAL_UNWIND_FRAME) { - setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP)); - return _URC_HANDLER_FOUND; - } - if ((state&(_US_ACTION_MASK|_US_FORCE_UNWIND)) == _US_UNWIND_FRAME_STARTING) { - _Unwind_DeleteException(ucb); - _Unwind_SetGR(ctx, 15, (uint32_t)(void *)lj_err_throw); - _Unwind_SetGR(ctx, 0, (uint32_t)L); - _Unwind_SetGR(ctx, 1, (uint32_t)LUA_ERRRUN); - return _URC_INSTALL_CONTEXT; - } - if (__gnu_unwind_frame(ucb, ctx) != _URC_OK) - return _URC_FAILURE; - return _URC_CONTINUE_UNWIND; -} - -#endif - -#elif LJ_TARGET_X64 && LJ_TARGET_WINDOWS - -/* -** Someone in Redmond owes me several days of my life. A lot of this is -** undocumented or just plain wrong on MSDN. Some of it can be gathered -** from 3rd party docs or must be found by trial-and-error. They really -** don't want you to write your own language-specific exception handler -** or to interact gracefully with MSVC. :-( -** -** Apparently MSVC doesn't call C++ destructors for foreign exceptions -** unless you compile your C++ code with /EHa. Unfortunately this means -** catch (...) also catches things like access violations. The use of -** _set_se_translator doesn't really help, because it requires /EHa, too. -*/ - -#define WIN32_LEAN_AND_MEAN -#include - -/* Taken from: http://www.nynaeve.net/?p=99 */ -typedef struct UndocumentedDispatcherContext { - ULONG64 ControlPc; - ULONG64 ImageBase; - PRUNTIME_FUNCTION FunctionEntry; - ULONG64 EstablisherFrame; - ULONG64 TargetIp; - PCONTEXT ContextRecord; - PEXCEPTION_ROUTINE LanguageHandler; - PVOID HandlerData; - PUNWIND_HISTORY_TABLE HistoryTable; - ULONG ScopeIndex; - ULONG Fill0; -} UndocumentedDispatcherContext; - -/* Another wild guess. */ -extern void __DestructExceptionObject(EXCEPTION_RECORD *rec, int nothrow); - -#ifdef MINGW_SDK_INIT -/* Workaround for broken MinGW64 declaration. */ -VOID RtlUnwindEx_FIXED(PVOID,PVOID,PVOID,PVOID,PVOID,PVOID) asm("RtlUnwindEx"); -#define RtlUnwindEx RtlUnwindEx_FIXED -#endif - -#define LJ_MSVC_EXCODE ((DWORD)0xe06d7363) -#define LJ_GCC_EXCODE ((DWORD)0x20474343) - -#define LJ_EXCODE ((DWORD)0xe24c4a00) -#define LJ_EXCODE_MAKE(c) (LJ_EXCODE | (DWORD)(c)) -#define LJ_EXCODE_CHECK(cl) (((cl) ^ LJ_EXCODE) <= 0xff) -#define LJ_EXCODE_ERRCODE(cl) ((int)((cl) & 0xff)) - -/* Win64 exception handler for interpreter frame. */ -LJ_FUNCA EXCEPTION_DISPOSITION lj_err_unwind_win64(EXCEPTION_RECORD *rec, - void *cf, CONTEXT *ctx, UndocumentedDispatcherContext *dispatch) -{ - lua_State *L = cframe_L(cf); - int errcode = LJ_EXCODE_CHECK(rec->ExceptionCode) ? - LJ_EXCODE_ERRCODE(rec->ExceptionCode) : LUA_ERRRUN; - if ((rec->ExceptionFlags & 6)) { /* EH_UNWINDING|EH_EXIT_UNWIND */ - /* Unwind internal frames. */ - err_unwind(L, cf, errcode); - } else { - void *cf2 = err_unwind(L, cf, 0); - if (cf2) { /* We catch it, so start unwinding the upper frames. */ - if (rec->ExceptionCode == LJ_MSVC_EXCODE || - rec->ExceptionCode == LJ_GCC_EXCODE) { - __DestructExceptionObject(rec, 1); - setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP)); - } else if (!LJ_EXCODE_CHECK(rec->ExceptionCode)) { - /* Don't catch access violations etc. */ - return ExceptionContinueSearch; - } - /* Unwind the stack and call all handlers for all lower C frames - ** (including ourselves) again with EH_UNWINDING set. Then set - ** rsp = cf, rax = errcode and jump to the specified target. - */ - RtlUnwindEx(cf, (void *)((cframe_unwind_ff(cf2) && errcode != LUA_YIELD) ? - lj_vm_unwind_ff_eh : - lj_vm_unwind_c_eh), - rec, (void *)(uintptr_t)errcode, ctx, dispatch->HistoryTable); - /* RtlUnwindEx should never return. */ - } - } - return ExceptionContinueSearch; -} - -/* Raise Windows exception. */ -static void err_raise_ext(int errcode) -{ - RaiseException(LJ_EXCODE_MAKE(errcode), 1 /* EH_NONCONTINUABLE */, 0, NULL); -} - -#endif - -/* -- Error handling ------------------------------------------------------ */ - -/* Throw error. Find catch frame, unwind stack and continue. */ -LJ_NOINLINE void LJ_FASTCALL lj_err_throw(lua_State *L, int errcode) -{ - global_State *g = G(L); - lj_trace_abort(g); - setgcrefnull(g->jit_L); - L->status = 0; -#if LJ_UNWIND_EXT - err_raise_ext(errcode); - /* - ** A return from this function signals a corrupt C stack that cannot be - ** unwound. We have no choice but to call the panic function and exit. - ** - ** Usually this is caused by a C function without unwind information. - ** This should never happen on x64, but may happen if you've manually - ** enabled LUAJIT_UNWIND_EXTERNAL and forgot to recompile *every* - ** non-C++ file with -funwind-tables. - */ - if (G(L)->panic) - G(L)->panic(L); -#else - { - void *cf = err_unwind(L, NULL, errcode); - if (cframe_unwind_ff(cf)) - lj_vm_unwind_ff(cframe_raw(cf)); - else - lj_vm_unwind_c(cframe_raw(cf), errcode); - } -#endif - exit(EXIT_FAILURE); -} - -/* Return string object for error message. */ -LJ_NOINLINE GCstr *lj_err_str(lua_State *L, ErrMsg em) -{ - return lj_str_newz(L, err2msg(em)); -} - -/* Out-of-memory error. */ -LJ_NOINLINE void lj_err_mem(lua_State *L) -{ - if (L->status == LUA_ERRERR+1) /* Don't touch the stack during lua_open. */ - lj_vm_unwind_c(L->cframe, LUA_ERRMEM); - setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRMEM)); - lj_err_throw(L, LUA_ERRMEM); -} - -/* Find error function for runtime errors. Requires an extra stack traversal. */ -static ptrdiff_t finderrfunc(lua_State *L) -{ - cTValue *frame = L->base-1, *bot = tvref(L->stack); - void *cf = L->cframe; - while (frame > bot) { - lua_assert(cf != NULL); - while (cframe_nres(cframe_raw(cf)) < 0) { /* cframe without frame? */ - if (frame >= restorestack(L, -cframe_nres(cf))) - break; - if (cframe_errfunc(cf) >= 0) /* Error handler not inherited (-1)? */ - return cframe_errfunc(cf); - cf = cframe_prev(cf); /* Else unwind cframe and continue searching. */ - if (cf == NULL) - return 0; - } - switch (frame_typep(frame)) { - case FRAME_LUA: - case FRAME_LUAP: - frame = frame_prevl(frame); - break; - case FRAME_C: - cf = cframe_prev(cf); - /* fallthrough */ - case FRAME_CONT: -#if LJ_HASFFI - if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK) - cf = cframe_prev(cf); -#endif - case FRAME_VARG: - frame = frame_prevd(frame); - break; - case FRAME_CP: - if (cframe_canyield(cf)) return 0; - if (cframe_errfunc(cf) >= 0) - return cframe_errfunc(cf); - frame = frame_prevd(frame); - break; - case FRAME_PCALL: - case FRAME_PCALLH: - if (frame_ftsz(frame) >= (ptrdiff_t)(2*sizeof(TValue))) /* xpcall? */ - return savestack(L, frame-1); /* Point to xpcall's errorfunc. */ - return 0; - default: - lua_assert(0); - return 0; - } - } - return 0; -} - -/* Runtime error. */ -LJ_NOINLINE void lj_err_run(lua_State *L) -{ - ptrdiff_t ef = finderrfunc(L); - if (ef) { - TValue *errfunc = restorestack(L, ef); - TValue *top = L->top; - lj_trace_abort(G(L)); - if (!tvisfunc(errfunc) || L->status == LUA_ERRERR) { - setstrV(L, top-1, lj_err_str(L, LJ_ERR_ERRERR)); - lj_err_throw(L, LUA_ERRERR); - } - L->status = LUA_ERRERR; - copyTV(L, top, top-1); - copyTV(L, top-1, errfunc); - L->top = top+1; - lj_vm_call(L, top, 1+1); /* Stack: |errfunc|msg| -> |msg| */ - } - lj_err_throw(L, LUA_ERRRUN); -} - -/* Formatted runtime error message. */ -LJ_NORET LJ_NOINLINE static void err_msgv(lua_State *L, ErrMsg em, ...) -{ - const char *msg; - va_list argp; - va_start(argp, em); - if (curr_funcisL(L)) L->top = curr_topL(L); - msg = lj_str_pushvf(L, err2msg(em), argp); - va_end(argp); - lj_debug_addloc(L, msg, L->base-1, NULL); - lj_err_run(L); -} - -/* Non-vararg variant for better calling conventions. */ -LJ_NOINLINE void lj_err_msg(lua_State *L, ErrMsg em) -{ - err_msgv(L, em); -} - -/* Lexer error. */ -LJ_NOINLINE void lj_err_lex(lua_State *L, GCstr *src, const char *tok, - BCLine line, ErrMsg em, va_list argp) -{ - char buff[LUA_IDSIZE]; - const char *msg; - lj_debug_shortname(buff, src); - msg = lj_str_pushvf(L, err2msg(em), argp); - msg = lj_str_pushf(L, "%s:%d: %s", buff, line, msg); - if (tok) - lj_str_pushf(L, err2msg(LJ_ERR_XNEAR), msg, tok); - lj_err_throw(L, LUA_ERRSYNTAX); -} - -/* Typecheck error for operands. */ -LJ_NOINLINE void lj_err_optype(lua_State *L, cTValue *o, ErrMsg opm) -{ - const char *tname = lj_typename(o); - const char *opname = err2msg(opm); - if (curr_funcisL(L)) { - GCproto *pt = curr_proto(L); - const BCIns *pc = cframe_Lpc(L) - 1; - const char *oname = NULL; - const char *kind = lj_debug_slotname(pt, pc, (BCReg)(o-L->base), &oname); - if (kind) - err_msgv(L, LJ_ERR_BADOPRT, opname, kind, oname, tname); - } - err_msgv(L, LJ_ERR_BADOPRV, opname, tname); -} - -/* Typecheck error for ordered comparisons. */ -LJ_NOINLINE void lj_err_comp(lua_State *L, cTValue *o1, cTValue *o2) -{ - const char *t1 = lj_typename(o1); - const char *t2 = lj_typename(o2); - err_msgv(L, t1 == t2 ? LJ_ERR_BADCMPV : LJ_ERR_BADCMPT, t1, t2); - /* This assumes the two "boolean" entries are commoned by the C compiler. */ -} - -/* Typecheck error for __call. */ -LJ_NOINLINE void lj_err_optype_call(lua_State *L, TValue *o) -{ - /* Gross hack if lua_[p]call or pcall/xpcall fail for a non-callable object: - ** L->base still points to the caller. So add a dummy frame with L instead - ** of a function. See lua_getstack(). - */ - const BCIns *pc = cframe_Lpc(L); - if (((ptrdiff_t)pc & FRAME_TYPE) != FRAME_LUA) { - const char *tname = lj_typename(o); - setframe_pc(o, pc); - setframe_gc(o, obj2gco(L)); - L->top = L->base = o+1; - err_msgv(L, LJ_ERR_BADCALL, tname); - } - lj_err_optype(L, o, LJ_ERR_OPCALL); -} - -/* Error in context of caller. */ -LJ_NOINLINE void lj_err_callermsg(lua_State *L, const char *msg) -{ - TValue *frame = L->base-1; - TValue *pframe = NULL; - if (frame_islua(frame)) { - pframe = frame_prevl(frame); - } else if (frame_iscont(frame)) { -#if LJ_HASFFI - if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK) { - pframe = frame; - frame = NULL; - } else -#endif - { - pframe = frame_prevd(frame); -#if LJ_HASFFI - /* Remove frame for FFI metamethods. */ - if (frame_func(frame)->c.ffid >= FF_ffi_meta___index && - frame_func(frame)->c.ffid <= FF_ffi_meta___tostring) { - L->base = pframe+1; - L->top = frame; - setcframe_pc(cframe_raw(L->cframe), frame_contpc(frame)); - } -#endif - } - } - lj_debug_addloc(L, msg, pframe, frame); - lj_err_run(L); -} - -/* Formatted error in context of caller. */ -LJ_NOINLINE void lj_err_callerv(lua_State *L, ErrMsg em, ...) -{ - const char *msg; - va_list argp; - va_start(argp, em); - msg = lj_str_pushvf(L, err2msg(em), argp); - va_end(argp); - lj_err_callermsg(L, msg); -} - -/* Error in context of caller. */ -LJ_NOINLINE void lj_err_caller(lua_State *L, ErrMsg em) -{ - lj_err_callermsg(L, err2msg(em)); -} - -/* Argument error message. */ -LJ_NORET LJ_NOINLINE static void err_argmsg(lua_State *L, int narg, - const char *msg) -{ - const char *fname = "?"; - const char *ftype = lj_debug_funcname(L, L->base - 1, &fname); - if (narg < 0 && narg > LUA_REGISTRYINDEX) - narg = (int)(L->top - L->base) + narg + 1; - if (ftype && ftype[3] == 'h' && --narg == 0) /* Check for "method". */ - msg = lj_str_pushf(L, err2msg(LJ_ERR_BADSELF), fname, msg); - else - msg = lj_str_pushf(L, err2msg(LJ_ERR_BADARG), narg, fname, msg); - lj_err_callermsg(L, msg); -} - -/* Formatted argument error. */ -LJ_NOINLINE void lj_err_argv(lua_State *L, int narg, ErrMsg em, ...) -{ - const char *msg; - va_list argp; - va_start(argp, em); - msg = lj_str_pushvf(L, err2msg(em), argp); - va_end(argp); - err_argmsg(L, narg, msg); -} - -/* Argument error. */ -LJ_NOINLINE void lj_err_arg(lua_State *L, int narg, ErrMsg em) -{ - err_argmsg(L, narg, err2msg(em)); -} - -/* Typecheck error for arguments. */ -LJ_NOINLINE void lj_err_argtype(lua_State *L, int narg, const char *xname) -{ - TValue *o = narg < 0 ? L->top + narg : L->base + narg-1; - const char *tname = o < L->top ? lj_typename(o) : lj_obj_typename[0]; - const char *msg = lj_str_pushf(L, err2msg(LJ_ERR_BADTYPE), xname, tname); - err_argmsg(L, narg, msg); -} - -/* Typecheck error for arguments. */ -LJ_NOINLINE void lj_err_argt(lua_State *L, int narg, int tt) -{ - lj_err_argtype(L, narg, lj_obj_typename[tt+1]); -} - -/* -- Public error handling API ------------------------------------------- */ - -LUA_API lua_CFunction lua_atpanic(lua_State *L, lua_CFunction panicf) -{ - lua_CFunction old = G(L)->panic; - G(L)->panic = panicf; - return old; -} - -/* Forwarders for the public API (C calling convention and no LJ_NORET). */ -LUA_API int lua_error(lua_State *L) -{ - lj_err_run(L); - return 0; /* unreachable */ -} - -LUALIB_API int luaL_argerror(lua_State *L, int narg, const char *msg) -{ - err_argmsg(L, narg, msg); - return 0; /* unreachable */ -} - -LUALIB_API int luaL_typerror(lua_State *L, int narg, const char *xname) -{ - lj_err_argtype(L, narg, xname); - return 0; /* unreachable */ -} - -LUALIB_API void luaL_where(lua_State *L, int level) -{ - int size; - cTValue *frame = lj_debug_frame(L, level, &size); - lj_debug_addloc(L, "", frame, size ? frame+size : NULL); -} - -LUALIB_API int luaL_error(lua_State *L, const char *fmt, ...) -{ - const char *msg; - va_list argp; - va_start(argp, fmt); - msg = lj_str_pushvf(L, fmt, argp); - va_end(argp); - lj_err_callermsg(L, msg); - return 0; /* unreachable */ -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_err.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_err.h deleted file mode 100644 index 7ea512a34..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_err.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -** Error handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_ERR_H -#define _LJ_ERR_H - -#include - -#include "lj_obj.h" - -typedef enum { -#define ERRDEF(name, msg) \ - LJ_ERR_##name, LJ_ERR_##name##_ = LJ_ERR_##name + sizeof(msg)-1, -#include "lj_errmsg.h" - LJ_ERR__MAX -} ErrMsg; - -LJ_DATA const char *lj_err_allmsg; -#define err2msg(em) (lj_err_allmsg+(int)(em)) - -LJ_FUNC GCstr *lj_err_str(lua_State *L, ErrMsg em); -LJ_FUNCA_NORET void LJ_FASTCALL lj_err_throw(lua_State *L, int errcode); -LJ_FUNC_NORET void lj_err_mem(lua_State *L); -LJ_FUNC_NORET void lj_err_run(lua_State *L); -LJ_FUNC_NORET void lj_err_msg(lua_State *L, ErrMsg em); -LJ_FUNC_NORET void lj_err_lex(lua_State *L, GCstr *src, const char *tok, - BCLine line, ErrMsg em, va_list argp); -LJ_FUNC_NORET void lj_err_optype(lua_State *L, cTValue *o, ErrMsg opm); -LJ_FUNC_NORET void lj_err_comp(lua_State *L, cTValue *o1, cTValue *o2); -LJ_FUNC_NORET void lj_err_optype_call(lua_State *L, TValue *o); -LJ_FUNC_NORET void lj_err_callermsg(lua_State *L, const char *msg); -LJ_FUNC_NORET void lj_err_callerv(lua_State *L, ErrMsg em, ...); -LJ_FUNC_NORET void lj_err_caller(lua_State *L, ErrMsg em); -LJ_FUNC_NORET void lj_err_arg(lua_State *L, int narg, ErrMsg em); -LJ_FUNC_NORET void lj_err_argv(lua_State *L, int narg, ErrMsg em, ...); -LJ_FUNC_NORET void lj_err_argtype(lua_State *L, int narg, const char *xname); -LJ_FUNC_NORET void lj_err_argt(lua_State *L, int narg, int tt); - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_errmsg.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_errmsg.h deleted file mode 100644 index 137831eb3..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_errmsg.h +++ /dev/null @@ -1,193 +0,0 @@ -/* -** VM error messages. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -/* This file may be included multiple times with different ERRDEF macros. */ - -/* Basic error handling. */ -ERRDEF(ERRMEM, "not enough memory") -ERRDEF(ERRERR, "error in error handling") -ERRDEF(ERRCPP, "C++ exception") - -/* Allocations. */ -ERRDEF(STROV, "string length overflow") -ERRDEF(UDATAOV, "userdata length overflow") -ERRDEF(STKOV, "stack overflow") -ERRDEF(STKOVM, "stack overflow (%s)") -ERRDEF(TABOV, "table overflow") - -/* Table indexing. */ -ERRDEF(NANIDX, "table index is NaN") -ERRDEF(NILIDX, "table index is nil") -ERRDEF(NEXTIDX, "invalid key to " LUA_QL("next")) - -/* Metamethod resolving. */ -ERRDEF(BADCALL, "attempt to call a %s value") -ERRDEF(BADOPRT, "attempt to %s %s " LUA_QS " (a %s value)") -ERRDEF(BADOPRV, "attempt to %s a %s value") -ERRDEF(BADCMPT, "attempt to compare %s with %s") -ERRDEF(BADCMPV, "attempt to compare two %s values") -ERRDEF(GETLOOP, "loop in gettable") -ERRDEF(SETLOOP, "loop in settable") -ERRDEF(OPCALL, "call") -ERRDEF(OPINDEX, "index") -ERRDEF(OPARITH, "perform arithmetic on") -ERRDEF(OPCAT, "concatenate") -ERRDEF(OPLEN, "get length of") - -/* Type checks. */ -ERRDEF(BADSELF, "calling " LUA_QS " on bad self (%s)") -ERRDEF(BADARG, "bad argument #%d to " LUA_QS " (%s)") -ERRDEF(BADTYPE, "%s expected, got %s") -ERRDEF(BADVAL, "invalid value") -ERRDEF(NOVAL, "value expected") -ERRDEF(NOCORO, "coroutine expected") -ERRDEF(NOTABN, "nil or table expected") -ERRDEF(NOLFUNC, "Lua function expected") -ERRDEF(NOFUNCL, "function or level expected") -ERRDEF(NOSFT, "string/function/table expected") -ERRDEF(NOPROXY, "boolean or proxy expected") -ERRDEF(FORINIT, LUA_QL("for") " initial value must be a number") -ERRDEF(FORLIM, LUA_QL("for") " limit must be a number") -ERRDEF(FORSTEP, LUA_QL("for") " step must be a number") - -/* C API checks. */ -ERRDEF(NOENV, "no calling environment") -ERRDEF(CYIELD, "attempt to yield across C-call boundary") -ERRDEF(BADLU, "bad light userdata pointer") -ERRDEF(NOGCMM, "bad action while in __gc metamethod") -#if LJ_TARGET_WINDOWS -ERRDEF(BADFPU, "bad FPU precision (use D3DCREATE_FPU_PRESERVE with DirectX)") -#endif - -/* Standard library function errors. */ -ERRDEF(ASSERT, "assertion failed!") -ERRDEF(PROTMT, "cannot change a protected metatable") -ERRDEF(UNPACK, "too many results to unpack") -ERRDEF(RDRSTR, "reader function must return a string") -ERRDEF(PRTOSTR, LUA_QL("tostring") " must return a string to " LUA_QL("print")) -ERRDEF(IDXRNG, "index out of range") -ERRDEF(BASERNG, "base out of range") -ERRDEF(LVLRNG, "level out of range") -ERRDEF(INVLVL, "invalid level") -ERRDEF(INVOPT, "invalid option") -ERRDEF(INVOPTM, "invalid option " LUA_QS) -ERRDEF(INVFMT, "invalid format") -ERRDEF(SETFENV, LUA_QL("setfenv") " cannot change environment of given object") -ERRDEF(CORUN, "cannot resume running coroutine") -ERRDEF(CODEAD, "cannot resume dead coroutine") -ERRDEF(COSUSP, "cannot resume non-suspended coroutine") -ERRDEF(TABINS, "wrong number of arguments to " LUA_QL("insert")) -ERRDEF(TABCAT, "invalid value (%s) at index %d in table for " LUA_QL("concat")) -ERRDEF(TABSORT, "invalid order function for sorting") -ERRDEF(IOCLFL, "attempt to use a closed file") -ERRDEF(IOSTDCL, "standard file is closed") -ERRDEF(OSUNIQF, "unable to generate a unique filename") -ERRDEF(OSDATEF, "field " LUA_QS " missing in date table") -ERRDEF(STRDUMP, "unable to dump given function") -ERRDEF(STRSLC, "string slice too long") -ERRDEF(STRPATB, "missing " LUA_QL("[") " after " LUA_QL("%f") " in pattern") -ERRDEF(STRPATC, "invalid pattern capture") -ERRDEF(STRPATE, "malformed pattern (ends with " LUA_QL("%") ")") -ERRDEF(STRPATM, "malformed pattern (missing " LUA_QL("]") ")") -ERRDEF(STRPATU, "unbalanced pattern") -ERRDEF(STRPATX, "pattern too complex") -ERRDEF(STRCAPI, "invalid capture index") -ERRDEF(STRCAPN, "too many captures") -ERRDEF(STRCAPU, "unfinished capture") -ERRDEF(STRFMTO, "invalid option " LUA_QL("%%%c") " to " LUA_QL("format")) -ERRDEF(STRFMTR, "invalid format (repeated flags)") -ERRDEF(STRFMTW, "invalid format (width or precision too long)") -ERRDEF(STRGSRV, "invalid replacement value (a %s)") -ERRDEF(BADMODN, "name conflict for module " LUA_QS) -#if LJ_HASJIT -ERRDEF(JITPROT, "runtime code generation failed, restricted kernel?") -#if LJ_TARGET_X86ORX64 -ERRDEF(NOJIT, "JIT compiler disabled, CPU does not support SSE2") -#else -ERRDEF(NOJIT, "JIT compiler disabled") -#endif -#elif defined(LJ_ARCH_NOJIT) -ERRDEF(NOJIT, "no JIT compiler for this architecture (yet)") -#else -ERRDEF(NOJIT, "JIT compiler permanently disabled by build option") -#endif -ERRDEF(JITOPT, "unknown or malformed optimization flag " LUA_QS) - -/* Lexer/parser errors. */ -ERRDEF(XMODE, "attempt to load chunk with wrong mode") -ERRDEF(XNEAR, "%s near " LUA_QS) -ERRDEF(XELEM, "lexical element too long") -ERRDEF(XLINES, "chunk has too many lines") -ERRDEF(XLEVELS, "chunk has too many syntax levels") -ERRDEF(XNUMBER, "malformed number") -ERRDEF(XLSTR, "unfinished long string") -ERRDEF(XLCOM, "unfinished long comment") -ERRDEF(XSTR, "unfinished string") -ERRDEF(XESC, "invalid escape sequence") -ERRDEF(XLDELIM, "invalid long string delimiter") -ERRDEF(XTOKEN, LUA_QS " expected") -ERRDEF(XJUMP, "control structure too long") -ERRDEF(XSLOTS, "function or expression too complex") -ERRDEF(XLIMC, "chunk has more than %d local variables") -ERRDEF(XLIMM, "main function has more than %d %s") -ERRDEF(XLIMF, "function at line %d has more than %d %s") -ERRDEF(XMATCH, LUA_QS " expected (to close " LUA_QS " at line %d)") -ERRDEF(XFIXUP, "function too long for return fixup") -ERRDEF(XPARAM, " or " LUA_QL("...") " expected") -#if !LJ_52 -ERRDEF(XAMBIG, "ambiguous syntax (function call x new statement)") -#endif -ERRDEF(XFUNARG, "function arguments expected") -ERRDEF(XSYMBOL, "unexpected symbol") -ERRDEF(XDOTS, "cannot use " LUA_QL("...") " outside a vararg function") -ERRDEF(XSYNTAX, "syntax error") -ERRDEF(XFOR, LUA_QL("=") " or " LUA_QL("in") " expected") -ERRDEF(XBREAK, "no loop to break") -ERRDEF(XLUNDEF, "undefined label " LUA_QS) -ERRDEF(XLDUP, "duplicate label " LUA_QS) -ERRDEF(XGSCOPE, " jumps into the scope of local " LUA_QS) - -/* Bytecode reader errors. */ -ERRDEF(BCFMT, "cannot load incompatible bytecode") -ERRDEF(BCBAD, "cannot load malformed bytecode") - -#if LJ_HASFFI -/* FFI errors. */ -ERRDEF(FFI_INVTYPE, "invalid C type") -ERRDEF(FFI_INVSIZE, "size of C type is unknown or too large") -ERRDEF(FFI_BADSCL, "bad storage class") -ERRDEF(FFI_DECLSPEC, "declaration specifier expected") -ERRDEF(FFI_BADTAG, "undeclared or implicit tag " LUA_QS) -ERRDEF(FFI_REDEF, "attempt to redefine " LUA_QS) -ERRDEF(FFI_NUMPARAM, "wrong number of type parameters") -ERRDEF(FFI_INITOV, "too many initializers for " LUA_QS) -ERRDEF(FFI_BADCONV, "cannot convert " LUA_QS " to " LUA_QS) -ERRDEF(FFI_BADLEN, "attempt to get length of " LUA_QS) -ERRDEF(FFI_BADCONCAT, "attempt to concatenate " LUA_QS " and " LUA_QS) -ERRDEF(FFI_BADARITH, "attempt to perform arithmetic on " LUA_QS " and " LUA_QS) -ERRDEF(FFI_BADCOMP, "attempt to compare " LUA_QS " with " LUA_QS) -ERRDEF(FFI_BADCALL, LUA_QS " is not callable") -ERRDEF(FFI_NUMARG, "wrong number of arguments for function call") -ERRDEF(FFI_BADMEMBER, LUA_QS " has no member named " LUA_QS) -ERRDEF(FFI_BADIDX, LUA_QS " cannot be indexed") -ERRDEF(FFI_BADIDXW, LUA_QS " cannot be indexed with " LUA_QS) -ERRDEF(FFI_BADMM, LUA_QS " has no " LUA_QS " metamethod") -ERRDEF(FFI_WRCONST, "attempt to write to constant location") -ERRDEF(FFI_NODECL, "missing declaration for symbol " LUA_QS) -ERRDEF(FFI_BADCBACK, "bad callback") -#if LJ_OS_NOJIT -ERRDEF(FFI_CBACKOV, "no support for callbacks on this OS") -#else -ERRDEF(FFI_CBACKOV, "too many callbacks") -#endif -ERRDEF(FFI_NYIPACKBIT, "NYI: packed bit fields") -ERRDEF(FFI_NYICALL, "NYI: cannot call this C function (yet)") -#endif - -#undef ERRDEF - -/* Detecting unused error messages: - awk -F, '/^ERRDEF/ { gsub(/ERRDEF./, ""); printf "grep -q LJ_ERR_%s *.[ch] || echo %s\n", $1, $1}' lj_errmsg.h | sh -*/ diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ff.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_ff.h deleted file mode 100644 index d91a7395b..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ff.h +++ /dev/null @@ -1,18 +0,0 @@ -/* -** Fast function IDs. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_FF_H -#define _LJ_FF_H - -/* Fast function ID. */ -typedef enum { - FF_LUA_ = FF_LUA, /* Lua function (must be 0). */ - FF_C_ = FF_C, /* Regular C function (must be 1). */ -#define FFDEF(name) FF_##name, -#include "lj_ffdef.h" - FF__MAX -} FastFunc; - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ffrecord.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_ffrecord.c deleted file mode 100644 index 794bbd43c..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ffrecord.c +++ /dev/null @@ -1,888 +0,0 @@ -/* -** Fast function call recorder. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_ffrecord_c -#define LUA_CORE - -#include "lj_obj.h" - -#if LJ_HASJIT - -#include "lj_err.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_frame.h" -#include "lj_bc.h" -#include "lj_ff.h" -#include "lj_ir.h" -#include "lj_jit.h" -#include "lj_ircall.h" -#include "lj_iropt.h" -#include "lj_trace.h" -#include "lj_record.h" -#include "lj_ffrecord.h" -#include "lj_crecord.h" -#include "lj_dispatch.h" -#include "lj_vm.h" -#include "lj_strscan.h" - -/* Some local macros to save typing. Undef'd at the end. */ -#define IR(ref) (&J->cur.ir[(ref)]) - -/* Pass IR on to next optimization in chain (FOLD). */ -#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) - -/* -- Fast function recording handlers ------------------------------------ */ - -/* Conventions for fast function call handlers: -** -** The argument slots start at J->base[0]. All of them are guaranteed to be -** valid and type-specialized references. J->base[J->maxslot] is set to 0 -** as a sentinel. The runtime argument values start at rd->argv[0]. -** -** In general fast functions should check for presence of all of their -** arguments and for the correct argument types. Some simplifications -** are allowed if the interpreter throws instead. But even if recording -** is aborted, the generated IR must be consistent (no zero-refs). -** -** The number of results in rd->nres is set to 1. Handlers that return -** a different number of results need to override it. A negative value -** prevents return processing (e.g. for pending calls). -** -** Results need to be stored starting at J->base[0]. Return processing -** moves them to the right slots later. -** -** The per-ffid auxiliary data is the value of the 2nd part of the -** LJLIB_REC() annotation. This allows handling similar functionality -** in a common handler. -*/ - -/* Type of handler to record a fast function. */ -typedef void (LJ_FASTCALL *RecordFunc)(jit_State *J, RecordFFData *rd); - -/* Get runtime value of int argument. */ -static int32_t argv2int(jit_State *J, TValue *o) -{ - if (!lj_strscan_numberobj(o)) - lj_trace_err(J, LJ_TRERR_BADTYPE); - return tvisint(o) ? intV(o) : lj_num2int(numV(o)); -} - -/* Get runtime value of string argument. */ -static GCstr *argv2str(jit_State *J, TValue *o) -{ - if (LJ_LIKELY(tvisstr(o))) { - return strV(o); - } else { - GCstr *s; - if (!tvisnumber(o)) - lj_trace_err(J, LJ_TRERR_BADTYPE); - if (tvisint(o)) - s = lj_str_fromint(J->L, intV(o)); - else - s = lj_str_fromnum(J->L, &o->n); - setstrV(J->L, o, s); - return s; - } -} - -/* Return number of results wanted by caller. */ -static ptrdiff_t results_wanted(jit_State *J) -{ - TValue *frame = J->L->base-1; - if (frame_islua(frame)) - return (ptrdiff_t)bc_b(frame_pc(frame)[-1]) - 1; - else - return -1; -} - -/* Throw error for unsupported variant of fast function. */ -LJ_NORET static void recff_nyiu(jit_State *J) -{ - setfuncV(J->L, &J->errinfo, J->fn); - lj_trace_err_info(J, LJ_TRERR_NYIFFU); -} - -/* Fallback handler for all fast functions that are not recorded (yet). */ -static void LJ_FASTCALL recff_nyi(jit_State *J, RecordFFData *rd) -{ - setfuncV(J->L, &J->errinfo, J->fn); - lj_trace_err_info(J, LJ_TRERR_NYIFF); - UNUSED(rd); -} - -/* C functions can have arbitrary side-effects and are not recorded (yet). */ -static void LJ_FASTCALL recff_c(jit_State *J, RecordFFData *rd) -{ - setfuncV(J->L, &J->errinfo, J->fn); - lj_trace_err_info(J, LJ_TRERR_NYICF); - UNUSED(rd); -} - -/* -- Base library fast functions ----------------------------------------- */ - -static void LJ_FASTCALL recff_assert(jit_State *J, RecordFFData *rd) -{ - /* Arguments already specialized. The interpreter throws for nil/false. */ - rd->nres = J->maxslot; /* Pass through all arguments. */ -} - -static void LJ_FASTCALL recff_type(jit_State *J, RecordFFData *rd) -{ - /* Arguments already specialized. Result is a constant string. Neat, huh? */ - uint32_t t; - if (tvisnumber(&rd->argv[0])) - t = ~LJ_TNUMX; - else if (LJ_64 && tvislightud(&rd->argv[0])) - t = ~LJ_TLIGHTUD; - else - t = ~itype(&rd->argv[0]); - J->base[0] = lj_ir_kstr(J, strV(&J->fn->c.upvalue[t])); - UNUSED(rd); -} - -static void LJ_FASTCALL recff_getmetatable(jit_State *J, RecordFFData *rd) -{ - TRef tr = J->base[0]; - if (tr) { - RecordIndex ix; - ix.tab = tr; - copyTV(J->L, &ix.tabv, &rd->argv[0]); - if (lj_record_mm_lookup(J, &ix, MM_metatable)) - J->base[0] = ix.mobj; - else - J->base[0] = ix.mt; - } /* else: Interpreter will throw. */ -} - -static void LJ_FASTCALL recff_setmetatable(jit_State *J, RecordFFData *rd) -{ - TRef tr = J->base[0]; - TRef mt = J->base[1]; - if (tref_istab(tr) && (tref_istab(mt) || (mt && tref_isnil(mt)))) { - TRef fref, mtref; - RecordIndex ix; - ix.tab = tr; - copyTV(J->L, &ix.tabv, &rd->argv[0]); - lj_record_mm_lookup(J, &ix, MM_metatable); /* Guard for no __metatable. */ - fref = emitir(IRT(IR_FREF, IRT_P32), tr, IRFL_TAB_META); - mtref = tref_isnil(mt) ? lj_ir_knull(J, IRT_TAB) : mt; - emitir(IRT(IR_FSTORE, IRT_TAB), fref, mtref); - if (!tref_isnil(mt)) - emitir(IRT(IR_TBAR, IRT_TAB), tr, 0); - J->base[0] = tr; - J->needsnap = 1; - } /* else: Interpreter will throw. */ -} - -static void LJ_FASTCALL recff_rawget(jit_State *J, RecordFFData *rd) -{ - RecordIndex ix; - ix.tab = J->base[0]; ix.key = J->base[1]; - if (tref_istab(ix.tab) && ix.key) { - ix.val = 0; ix.idxchain = 0; - settabV(J->L, &ix.tabv, tabV(&rd->argv[0])); - copyTV(J->L, &ix.keyv, &rd->argv[1]); - J->base[0] = lj_record_idx(J, &ix); - } /* else: Interpreter will throw. */ -} - -static void LJ_FASTCALL recff_rawset(jit_State *J, RecordFFData *rd) -{ - RecordIndex ix; - ix.tab = J->base[0]; ix.key = J->base[1]; ix.val = J->base[2]; - if (tref_istab(ix.tab) && ix.key && ix.val) { - ix.idxchain = 0; - settabV(J->L, &ix.tabv, tabV(&rd->argv[0])); - copyTV(J->L, &ix.keyv, &rd->argv[1]); - copyTV(J->L, &ix.valv, &rd->argv[2]); - lj_record_idx(J, &ix); - /* Pass through table at J->base[0] as result. */ - } /* else: Interpreter will throw. */ -} - -static void LJ_FASTCALL recff_rawequal(jit_State *J, RecordFFData *rd) -{ - TRef tra = J->base[0]; - TRef trb = J->base[1]; - if (tra && trb) { - int diff = lj_record_objcmp(J, tra, trb, &rd->argv[0], &rd->argv[1]); - J->base[0] = diff ? TREF_FALSE : TREF_TRUE; - } /* else: Interpreter will throw. */ -} - -#if LJ_52 -static void LJ_FASTCALL recff_rawlen(jit_State *J, RecordFFData *rd) -{ - TRef tr = J->base[0]; - if (tref_isstr(tr)) - J->base[0] = emitir(IRTI(IR_FLOAD), tr, IRFL_STR_LEN); - else if (tref_istab(tr)) - J->base[0] = lj_ir_call(J, IRCALL_lj_tab_len, tr); - /* else: Interpreter will throw. */ - UNUSED(rd); -} -#endif - -/* Determine mode of select() call. */ -int32_t lj_ffrecord_select_mode(jit_State *J, TRef tr, TValue *tv) -{ - if (tref_isstr(tr) && *strVdata(tv) == '#') { /* select('#', ...) */ - if (strV(tv)->len == 1) { - emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, strV(tv))); - } else { - TRef trptr = emitir(IRT(IR_STRREF, IRT_P32), tr, lj_ir_kint(J, 0)); - TRef trchar = emitir(IRT(IR_XLOAD, IRT_U8), trptr, IRXLOAD_READONLY); - emitir(IRTG(IR_EQ, IRT_INT), trchar, lj_ir_kint(J, '#')); - } - return 0; - } else { /* select(n, ...) */ - int32_t start = argv2int(J, tv); - if (start == 0) lj_trace_err(J, LJ_TRERR_BADTYPE); /* A bit misleading. */ - return start; - } -} - -static void LJ_FASTCALL recff_select(jit_State *J, RecordFFData *rd) -{ - TRef tr = J->base[0]; - if (tr) { - ptrdiff_t start = lj_ffrecord_select_mode(J, tr, &rd->argv[0]); - if (start == 0) { /* select('#', ...) */ - J->base[0] = lj_ir_kint(J, J->maxslot - 1); - } else if (tref_isk(tr)) { /* select(k, ...) */ - ptrdiff_t n = (ptrdiff_t)J->maxslot; - if (start < 0) start += n; - else if (start > n) start = n; - rd->nres = n - start; - if (start >= 1) { - ptrdiff_t i; - for (i = 0; i < n - start; i++) - J->base[i] = J->base[start+i]; - } /* else: Interpreter will throw. */ - } else { - recff_nyiu(J); - } - } /* else: Interpreter will throw. */ -} - -static void LJ_FASTCALL recff_tonumber(jit_State *J, RecordFFData *rd) -{ - TRef tr = J->base[0]; - TRef base = J->base[1]; - if (tr && !tref_isnil(base)) { - base = lj_opt_narrow_toint(J, base); - if (!tref_isk(base) || IR(tref_ref(base))->i != 10) - recff_nyiu(J); - } - if (tref_isnumber_str(tr)) { - if (tref_isstr(tr)) { - TValue tmp; - if (!lj_strscan_num(strV(&rd->argv[0]), &tmp)) - recff_nyiu(J); /* Would need an inverted STRTO for this case. */ - tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); - } -#if LJ_HASFFI - } else if (tref_iscdata(tr)) { - lj_crecord_tonumber(J, rd); - return; -#endif - } else { - tr = TREF_NIL; - } - J->base[0] = tr; - UNUSED(rd); -} - -static TValue *recff_metacall_cp(lua_State *L, lua_CFunction dummy, void *ud) -{ - jit_State *J = (jit_State *)ud; - lj_record_tailcall(J, 0, 1); - UNUSED(L); UNUSED(dummy); - return NULL; -} - -static int recff_metacall(jit_State *J, RecordFFData *rd, MMS mm) -{ - RecordIndex ix; - ix.tab = J->base[0]; - copyTV(J->L, &ix.tabv, &rd->argv[0]); - if (lj_record_mm_lookup(J, &ix, mm)) { /* Has metamethod? */ - int errcode; - TValue argv0; - /* Temporarily insert metamethod below object. */ - J->base[1] = J->base[0]; - J->base[0] = ix.mobj; - copyTV(J->L, &argv0, &rd->argv[0]); - copyTV(J->L, &rd->argv[1], &rd->argv[0]); - copyTV(J->L, &rd->argv[0], &ix.mobjv); - /* Need to protect lj_record_tailcall because it may throw. */ - errcode = lj_vm_cpcall(J->L, NULL, J, recff_metacall_cp); - /* Always undo Lua stack changes to avoid confusing the interpreter. */ - copyTV(J->L, &rd->argv[0], &argv0); - if (errcode) - lj_err_throw(J->L, errcode); /* Propagate errors. */ - rd->nres = -1; /* Pending call. */ - return 1; /* Tailcalled to metamethod. */ - } - return 0; -} - -static void LJ_FASTCALL recff_tostring(jit_State *J, RecordFFData *rd) -{ - TRef tr = J->base[0]; - if (tref_isstr(tr)) { - /* Ignore __tostring in the string base metatable. */ - /* Pass on result in J->base[0]. */ - } else if (!recff_metacall(J, rd, MM_tostring)) { - if (tref_isnumber(tr)) { - J->base[0] = emitir(IRT(IR_TOSTR, IRT_STR), tr, 0); - } else if (tref_ispri(tr)) { - J->base[0] = lj_ir_kstr(J, strV(&J->fn->c.upvalue[tref_type(tr)])); - } else { - recff_nyiu(J); - } - } -} - -static void LJ_FASTCALL recff_ipairs_aux(jit_State *J, RecordFFData *rd) -{ - RecordIndex ix; - ix.tab = J->base[0]; - if (tref_istab(ix.tab)) { - if (!tvisnumber(&rd->argv[1])) /* No support for string coercion. */ - lj_trace_err(J, LJ_TRERR_BADTYPE); - setintV(&ix.keyv, numberVint(&rd->argv[1])+1); - settabV(J->L, &ix.tabv, tabV(&rd->argv[0])); - ix.val = 0; ix.idxchain = 0; - ix.key = lj_opt_narrow_toint(J, J->base[1]); - J->base[0] = ix.key = emitir(IRTI(IR_ADD), ix.key, lj_ir_kint(J, 1)); - J->base[1] = lj_record_idx(J, &ix); - rd->nres = tref_isnil(J->base[1]) ? 0 : 2; - } /* else: Interpreter will throw. */ -} - -static void LJ_FASTCALL recff_ipairs(jit_State *J, RecordFFData *rd) -{ - if (!(LJ_52 && recff_metacall(J, rd, MM_ipairs))) { - TRef tab = J->base[0]; - if (tref_istab(tab)) { - J->base[0] = lj_ir_kfunc(J, funcV(&J->fn->c.upvalue[0])); - J->base[1] = tab; - J->base[2] = lj_ir_kint(J, 0); - rd->nres = 3; - } /* else: Interpreter will throw. */ - } -} - -static void LJ_FASTCALL recff_pcall(jit_State *J, RecordFFData *rd) -{ - if (J->maxslot >= 1) { - lj_record_call(J, 0, J->maxslot - 1); - rd->nres = -1; /* Pending call. */ - } /* else: Interpreter will throw. */ -} - -static TValue *recff_xpcall_cp(lua_State *L, lua_CFunction dummy, void *ud) -{ - jit_State *J = (jit_State *)ud; - lj_record_call(J, 1, J->maxslot - 2); - UNUSED(L); UNUSED(dummy); - return NULL; -} - -static void LJ_FASTCALL recff_xpcall(jit_State *J, RecordFFData *rd) -{ - if (J->maxslot >= 2) { - TValue argv0, argv1; - TRef tmp; - int errcode; - /* Swap function and traceback. */ - tmp = J->base[0]; J->base[0] = J->base[1]; J->base[1] = tmp; - copyTV(J->L, &argv0, &rd->argv[0]); - copyTV(J->L, &argv1, &rd->argv[1]); - copyTV(J->L, &rd->argv[0], &argv1); - copyTV(J->L, &rd->argv[1], &argv0); - /* Need to protect lj_record_call because it may throw. */ - errcode = lj_vm_cpcall(J->L, NULL, J, recff_xpcall_cp); - /* Always undo Lua stack swap to avoid confusing the interpreter. */ - copyTV(J->L, &rd->argv[0], &argv0); - copyTV(J->L, &rd->argv[1], &argv1); - if (errcode) - lj_err_throw(J->L, errcode); /* Propagate errors. */ - rd->nres = -1; /* Pending call. */ - } /* else: Interpreter will throw. */ -} - -/* -- Math library fast functions ----------------------------------------- */ - -static void LJ_FASTCALL recff_math_abs(jit_State *J, RecordFFData *rd) -{ - TRef tr = lj_ir_tonum(J, J->base[0]); - J->base[0] = emitir(IRTN(IR_ABS), tr, lj_ir_knum_abs(J)); - UNUSED(rd); -} - -/* Record rounding functions math.floor and math.ceil. */ -static void LJ_FASTCALL recff_math_round(jit_State *J, RecordFFData *rd) -{ - TRef tr = J->base[0]; - if (!tref_isinteger(tr)) { /* Pass through integers unmodified. */ - tr = emitir(IRTN(IR_FPMATH), lj_ir_tonum(J, tr), rd->data); - /* Result is integral (or NaN/Inf), but may not fit an int32_t. */ - if (LJ_DUALNUM) { /* Try to narrow using a guarded conversion to int. */ - lua_Number n = lj_vm_foldfpm(numberVnum(&rd->argv[0]), rd->data); - if (n == (lua_Number)lj_num2int(n)) - tr = emitir(IRTGI(IR_CONV), tr, IRCONV_INT_NUM|IRCONV_CHECK); - } - J->base[0] = tr; - } -} - -/* Record unary math.* functions, mapped to IR_FPMATH opcode. */ -static void LJ_FASTCALL recff_math_unary(jit_State *J, RecordFFData *rd) -{ - J->base[0] = emitir(IRTN(IR_FPMATH), lj_ir_tonum(J, J->base[0]), rd->data); -} - -/* Record math.log. */ -static void LJ_FASTCALL recff_math_log(jit_State *J, RecordFFData *rd) -{ - TRef tr = lj_ir_tonum(J, J->base[0]); - if (J->base[1]) { -#ifdef LUAJIT_NO_LOG2 - uint32_t fpm = IRFPM_LOG; -#else - uint32_t fpm = IRFPM_LOG2; -#endif - TRef trb = lj_ir_tonum(J, J->base[1]); - tr = emitir(IRTN(IR_FPMATH), tr, fpm); - trb = emitir(IRTN(IR_FPMATH), trb, fpm); - trb = emitir(IRTN(IR_DIV), lj_ir_knum_one(J), trb); - tr = emitir(IRTN(IR_MUL), tr, trb); - } else { - tr = emitir(IRTN(IR_FPMATH), tr, IRFPM_LOG); - } - J->base[0] = tr; - UNUSED(rd); -} - -/* Record math.atan2. */ -static void LJ_FASTCALL recff_math_atan2(jit_State *J, RecordFFData *rd) -{ - TRef tr = lj_ir_tonum(J, J->base[0]); - TRef tr2 = lj_ir_tonum(J, J->base[1]); - J->base[0] = emitir(IRTN(IR_ATAN2), tr, tr2); - UNUSED(rd); -} - -/* Record math.ldexp. */ -static void LJ_FASTCALL recff_math_ldexp(jit_State *J, RecordFFData *rd) -{ - TRef tr = lj_ir_tonum(J, J->base[0]); -#if LJ_TARGET_X86ORX64 - TRef tr2 = lj_ir_tonum(J, J->base[1]); -#else - TRef tr2 = lj_opt_narrow_toint(J, J->base[1]); -#endif - J->base[0] = emitir(IRTN(IR_LDEXP), tr, tr2); - UNUSED(rd); -} - -/* Record math.asin, math.acos, math.atan. */ -static void LJ_FASTCALL recff_math_atrig(jit_State *J, RecordFFData *rd) -{ - TRef y = lj_ir_tonum(J, J->base[0]); - TRef x = lj_ir_knum_one(J); - uint32_t ffid = rd->data; - if (ffid != FF_math_atan) { - TRef tmp = emitir(IRTN(IR_MUL), y, y); - tmp = emitir(IRTN(IR_SUB), x, tmp); - tmp = emitir(IRTN(IR_FPMATH), tmp, IRFPM_SQRT); - if (ffid == FF_math_asin) { x = tmp; } else { x = y; y = tmp; } - } - J->base[0] = emitir(IRTN(IR_ATAN2), y, x); -} - -static void LJ_FASTCALL recff_math_htrig(jit_State *J, RecordFFData *rd) -{ - TRef tr = lj_ir_tonum(J, J->base[0]); - J->base[0] = emitir(IRTN(IR_CALLN), tr, rd->data); -} - -static void LJ_FASTCALL recff_math_modf(jit_State *J, RecordFFData *rd) -{ - TRef tr = J->base[0]; - if (tref_isinteger(tr)) { - J->base[0] = tr; - J->base[1] = lj_ir_kint(J, 0); - } else { - TRef trt; - tr = lj_ir_tonum(J, tr); - trt = emitir(IRTN(IR_FPMATH), tr, IRFPM_TRUNC); - J->base[0] = trt; - J->base[1] = emitir(IRTN(IR_SUB), tr, trt); - } - rd->nres = 2; -} - -static void LJ_FASTCALL recff_math_degrad(jit_State *J, RecordFFData *rd) -{ - TRef tr = lj_ir_tonum(J, J->base[0]); - TRef trm = lj_ir_knum(J, numV(&J->fn->c.upvalue[0])); - J->base[0] = emitir(IRTN(IR_MUL), tr, trm); - UNUSED(rd); -} - -static void LJ_FASTCALL recff_math_pow(jit_State *J, RecordFFData *rd) -{ - TRef tr = lj_ir_tonum(J, J->base[0]); - if (!tref_isnumber_str(J->base[1])) - lj_trace_err(J, LJ_TRERR_BADTYPE); - J->base[0] = lj_opt_narrow_pow(J, tr, J->base[1], &rd->argv[1]); - UNUSED(rd); -} - -static void LJ_FASTCALL recff_math_minmax(jit_State *J, RecordFFData *rd) -{ - TRef tr = lj_ir_tonumber(J, J->base[0]); - uint32_t op = rd->data; - BCReg i; - for (i = 1; J->base[i] != 0; i++) { - TRef tr2 = lj_ir_tonumber(J, J->base[i]); - IRType t = IRT_INT; - if (!(tref_isinteger(tr) && tref_isinteger(tr2))) { - if (tref_isinteger(tr)) tr = emitir(IRTN(IR_CONV), tr, IRCONV_NUM_INT); - if (tref_isinteger(tr2)) tr2 = emitir(IRTN(IR_CONV), tr2, IRCONV_NUM_INT); - t = IRT_NUM; - } - tr = emitir(IRT(op, t), tr, tr2); - } - J->base[0] = tr; -} - -static void LJ_FASTCALL recff_math_random(jit_State *J, RecordFFData *rd) -{ - GCudata *ud = udataV(&J->fn->c.upvalue[0]); - TRef tr, one; - lj_ir_kgc(J, obj2gco(ud), IRT_UDATA); /* Prevent collection. */ - tr = lj_ir_call(J, IRCALL_lj_math_random_step, lj_ir_kptr(J, uddata(ud))); - one = lj_ir_knum_one(J); - tr = emitir(IRTN(IR_SUB), tr, one); - if (J->base[0]) { - TRef tr1 = lj_ir_tonum(J, J->base[0]); - if (J->base[1]) { /* d = floor(d*(r2-r1+1.0)) + r1 */ - TRef tr2 = lj_ir_tonum(J, J->base[1]); - tr2 = emitir(IRTN(IR_SUB), tr2, tr1); - tr2 = emitir(IRTN(IR_ADD), tr2, one); - tr = emitir(IRTN(IR_MUL), tr, tr2); - tr = emitir(IRTN(IR_FPMATH), tr, IRFPM_FLOOR); - tr = emitir(IRTN(IR_ADD), tr, tr1); - } else { /* d = floor(d*r1) + 1.0 */ - tr = emitir(IRTN(IR_MUL), tr, tr1); - tr = emitir(IRTN(IR_FPMATH), tr, IRFPM_FLOOR); - tr = emitir(IRTN(IR_ADD), tr, one); - } - } - J->base[0] = tr; - UNUSED(rd); -} - -/* -- Bit library fast functions ------------------------------------------ */ - -/* Record unary bit.tobit, bit.bnot, bit.bswap. */ -static void LJ_FASTCALL recff_bit_unary(jit_State *J, RecordFFData *rd) -{ - TRef tr = lj_opt_narrow_tobit(J, J->base[0]); - J->base[0] = (rd->data == IR_TOBIT) ? tr : emitir(IRTI(rd->data), tr, 0); -} - -/* Record N-ary bit.band, bit.bor, bit.bxor. */ -static void LJ_FASTCALL recff_bit_nary(jit_State *J, RecordFFData *rd) -{ - TRef tr = lj_opt_narrow_tobit(J, J->base[0]); - uint32_t op = rd->data; - BCReg i; - for (i = 1; J->base[i] != 0; i++) - tr = emitir(IRTI(op), tr, lj_opt_narrow_tobit(J, J->base[i])); - J->base[0] = tr; -} - -/* Record bit shifts. */ -static void LJ_FASTCALL recff_bit_shift(jit_State *J, RecordFFData *rd) -{ - TRef tr = lj_opt_narrow_tobit(J, J->base[0]); - TRef tsh = lj_opt_narrow_tobit(J, J->base[1]); - IROp op = (IROp)rd->data; - if (!(op < IR_BROL ? LJ_TARGET_MASKSHIFT : LJ_TARGET_MASKROT) && - !tref_isk(tsh)) - tsh = emitir(IRTI(IR_BAND), tsh, lj_ir_kint(J, 31)); -#ifdef LJ_TARGET_UNIFYROT - if (op == (LJ_TARGET_UNIFYROT == 1 ? IR_BROR : IR_BROL)) { - op = LJ_TARGET_UNIFYROT == 1 ? IR_BROL : IR_BROR; - tsh = emitir(IRTI(IR_NEG), tsh, tsh); - } -#endif - J->base[0] = emitir(IRTI(op), tr, tsh); -} - -/* -- String library fast functions --------------------------------------- */ - -static void LJ_FASTCALL recff_string_len(jit_State *J, RecordFFData *rd) -{ - J->base[0] = emitir(IRTI(IR_FLOAD), lj_ir_tostr(J, J->base[0]), IRFL_STR_LEN); - UNUSED(rd); -} - -/* Handle string.byte (rd->data = 0) and string.sub (rd->data = 1). */ -static void LJ_FASTCALL recff_string_range(jit_State *J, RecordFFData *rd) -{ - TRef trstr = lj_ir_tostr(J, J->base[0]); - TRef trlen = emitir(IRTI(IR_FLOAD), trstr, IRFL_STR_LEN); - TRef tr0 = lj_ir_kint(J, 0); - TRef trstart, trend; - GCstr *str = argv2str(J, &rd->argv[0]); - int32_t start, end; - if (rd->data) { /* string.sub(str, start [,end]) */ - start = argv2int(J, &rd->argv[1]); - trstart = lj_opt_narrow_toint(J, J->base[1]); - trend = J->base[2]; - if (tref_isnil(trend)) { - trend = lj_ir_kint(J, -1); - end = -1; - } else { - trend = lj_opt_narrow_toint(J, trend); - end = argv2int(J, &rd->argv[2]); - } - } else { /* string.byte(str, [,start [,end]]) */ - if (tref_isnil(J->base[1])) { - start = 1; - trstart = lj_ir_kint(J, 1); - } else { - start = argv2int(J, &rd->argv[1]); - trstart = lj_opt_narrow_toint(J, J->base[1]); - } - if (J->base[1] && !tref_isnil(J->base[2])) { - trend = lj_opt_narrow_toint(J, J->base[2]); - end = argv2int(J, &rd->argv[2]); - } else { - trend = trstart; - end = start; - } - } - if (end < 0) { - emitir(IRTGI(IR_LT), trend, tr0); - trend = emitir(IRTI(IR_ADD), emitir(IRTI(IR_ADD), trlen, trend), - lj_ir_kint(J, 1)); - end = end+(int32_t)str->len+1; - } else if ((MSize)end <= str->len) { - emitir(IRTGI(IR_ULE), trend, trlen); - } else { - emitir(IRTGI(IR_GT), trend, trlen); - end = (int32_t)str->len; - trend = trlen; - } - if (start < 0) { - emitir(IRTGI(IR_LT), trstart, tr0); - trstart = emitir(IRTI(IR_ADD), trlen, trstart); - start = start+(int32_t)str->len; - emitir(start < 0 ? IRTGI(IR_LT) : IRTGI(IR_GE), trstart, tr0); - if (start < 0) { - trstart = tr0; - start = 0; - } - } else { - if (start == 0) { - emitir(IRTGI(IR_EQ), trstart, tr0); - trstart = tr0; - } else { - trstart = emitir(IRTI(IR_ADD), trstart, lj_ir_kint(J, -1)); - emitir(IRTGI(IR_GE), trstart, tr0); - start--; - } - } - if (rd->data) { /* Return string.sub result. */ - if (end - start >= 0) { - /* Also handle empty range here, to avoid extra traces. */ - TRef trptr, trslen = emitir(IRTI(IR_SUB), trend, trstart); - emitir(IRTGI(IR_GE), trslen, tr0); - trptr = emitir(IRT(IR_STRREF, IRT_P32), trstr, trstart); - J->base[0] = emitir(IRT(IR_SNEW, IRT_STR), trptr, trslen); - } else { /* Range underflow: return empty string. */ - emitir(IRTGI(IR_LT), trend, trstart); - J->base[0] = lj_ir_kstr(J, lj_str_new(J->L, strdata(str), 0)); - } - } else { /* Return string.byte result(s). */ - ptrdiff_t i, len = end - start; - if (len > 0) { - TRef trslen = emitir(IRTI(IR_SUB), trend, trstart); - emitir(IRTGI(IR_EQ), trslen, lj_ir_kint(J, (int32_t)len)); - if (J->baseslot + len > LJ_MAX_JSLOTS) - lj_trace_err_info(J, LJ_TRERR_STACKOV); - rd->nres = len; - for (i = 0; i < len; i++) { - TRef tmp = emitir(IRTI(IR_ADD), trstart, lj_ir_kint(J, (int32_t)i)); - tmp = emitir(IRT(IR_STRREF, IRT_P32), trstr, tmp); - J->base[i] = emitir(IRT(IR_XLOAD, IRT_U8), tmp, IRXLOAD_READONLY); - } - } else { /* Empty range or range underflow: return no results. */ - emitir(IRTGI(IR_LE), trend, trstart); - rd->nres = 0; - } - } -} - -/* -- Table library fast functions ---------------------------------------- */ - -static void LJ_FASTCALL recff_table_getn(jit_State *J, RecordFFData *rd) -{ - if (tref_istab(J->base[0])) - J->base[0] = lj_ir_call(J, IRCALL_lj_tab_len, J->base[0]); - /* else: Interpreter will throw. */ - UNUSED(rd); -} - -static void LJ_FASTCALL recff_table_remove(jit_State *J, RecordFFData *rd) -{ - TRef tab = J->base[0]; - rd->nres = 0; - if (tref_istab(tab)) { - if (tref_isnil(J->base[1])) { /* Simple pop: t[#t] = nil */ - TRef trlen = lj_ir_call(J, IRCALL_lj_tab_len, tab); - GCtab *t = tabV(&rd->argv[0]); - MSize len = lj_tab_len(t); - emitir(IRTGI(len ? IR_NE : IR_EQ), trlen, lj_ir_kint(J, 0)); - if (len) { - RecordIndex ix; - ix.tab = tab; - ix.key = trlen; - settabV(J->L, &ix.tabv, t); - setintV(&ix.keyv, len); - ix.idxchain = 0; - if (results_wanted(J) != 0) { /* Specialize load only if needed. */ - ix.val = 0; - J->base[0] = lj_record_idx(J, &ix); /* Load previous value. */ - rd->nres = 1; - /* Assumes ix.key/ix.tab is not modified for raw lj_record_idx(). */ - } - ix.val = TREF_NIL; - lj_record_idx(J, &ix); /* Remove value. */ - } - } else { /* Complex case: remove in the middle. */ - recff_nyiu(J); - } - } /* else: Interpreter will throw. */ -} - -static void LJ_FASTCALL recff_table_insert(jit_State *J, RecordFFData *rd) -{ - RecordIndex ix; - ix.tab = J->base[0]; - ix.val = J->base[1]; - rd->nres = 0; - if (tref_istab(ix.tab) && ix.val) { - if (!J->base[2]) { /* Simple push: t[#t+1] = v */ - TRef trlen = lj_ir_call(J, IRCALL_lj_tab_len, ix.tab); - GCtab *t = tabV(&rd->argv[0]); - ix.key = emitir(IRTI(IR_ADD), trlen, lj_ir_kint(J, 1)); - settabV(J->L, &ix.tabv, t); - setintV(&ix.keyv, lj_tab_len(t) + 1); - ix.idxchain = 0; - lj_record_idx(J, &ix); /* Set new value. */ - } else { /* Complex case: insert in the middle. */ - recff_nyiu(J); - } - } /* else: Interpreter will throw. */ -} - -/* -- I/O library fast functions ------------------------------------------ */ - -/* Get FILE* for I/O function. Any I/O error aborts recording, so there's -** no need to encode the alternate cases for any of the guards. -*/ -static TRef recff_io_fp(jit_State *J, TRef *udp, int32_t id) -{ - TRef tr, ud, fp; - if (id) { /* io.func() */ - tr = lj_ir_kptr(J, &J2G(J)->gcroot[id]); - ud = emitir(IRT(IR_XLOAD, IRT_UDATA), tr, 0); - } else { /* fp:method() */ - ud = J->base[0]; - if (!tref_isudata(ud)) - lj_trace_err(J, LJ_TRERR_BADTYPE); - tr = emitir(IRT(IR_FLOAD, IRT_U8), ud, IRFL_UDATA_UDTYPE); - emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, UDTYPE_IO_FILE)); - } - *udp = ud; - fp = emitir(IRT(IR_FLOAD, IRT_PTR), ud, IRFL_UDATA_FILE); - emitir(IRTG(IR_NE, IRT_PTR), fp, lj_ir_knull(J, IRT_PTR)); - return fp; -} - -static void LJ_FASTCALL recff_io_write(jit_State *J, RecordFFData *rd) -{ - TRef ud, fp = recff_io_fp(J, &ud, rd->data); - TRef zero = lj_ir_kint(J, 0); - TRef one = lj_ir_kint(J, 1); - ptrdiff_t i = rd->data == 0 ? 1 : 0; - for (; J->base[i]; i++) { - TRef str = lj_ir_tostr(J, J->base[i]); - TRef buf = emitir(IRT(IR_STRREF, IRT_P32), str, zero); - TRef len = emitir(IRTI(IR_FLOAD), str, IRFL_STR_LEN); - if (tref_isk(len) && IR(tref_ref(len))->i == 1) { - TRef tr = emitir(IRT(IR_XLOAD, IRT_U8), buf, IRXLOAD_READONLY); - tr = lj_ir_call(J, IRCALL_fputc, tr, fp); - if (results_wanted(J) != 0) /* Check result only if not ignored. */ - emitir(IRTGI(IR_NE), tr, lj_ir_kint(J, -1)); - } else { - TRef tr = lj_ir_call(J, IRCALL_fwrite, buf, one, len, fp); - if (results_wanted(J) != 0) /* Check result only if not ignored. */ - emitir(IRTGI(IR_EQ), tr, len); - } - } - J->base[0] = LJ_52 ? ud : TREF_TRUE; -} - -static void LJ_FASTCALL recff_io_flush(jit_State *J, RecordFFData *rd) -{ - TRef ud, fp = recff_io_fp(J, &ud, rd->data); - TRef tr = lj_ir_call(J, IRCALL_fflush, fp); - if (results_wanted(J) != 0) /* Check result only if not ignored. */ - emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, 0)); - J->base[0] = TREF_TRUE; -} - -/* -- Record calls to fast functions -------------------------------------- */ - -#include "lj_recdef.h" - -static uint32_t recdef_lookup(GCfunc *fn) -{ - if (fn->c.ffid < sizeof(recff_idmap)/sizeof(recff_idmap[0])) - return recff_idmap[fn->c.ffid]; - else - return 0; -} - -/* Record entry to a fast function or C function. */ -void lj_ffrecord_func(jit_State *J) -{ - RecordFFData rd; - uint32_t m = recdef_lookup(J->fn); - rd.data = m & 0xff; - rd.nres = 1; /* Default is one result. */ - rd.argv = J->L->base; - J->base[J->maxslot] = 0; /* Mark end of arguments. */ - (recff_func[m >> 8])(J, &rd); /* Call recff_* handler. */ - if (rd.nres >= 0) { - if (J->postproc == LJ_POST_NONE) J->postproc = LJ_POST_FFRETRY; - lj_record_ret(J, 0, rd.nres); - } -} - -#undef IR -#undef emitir - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ffrecord.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_ffrecord.h deleted file mode 100644 index b3bc66279..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ffrecord.h +++ /dev/null @@ -1,24 +0,0 @@ -/* -** Fast function call recorder. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_FFRECORD_H -#define _LJ_FFRECORD_H - -#include "lj_obj.h" -#include "lj_jit.h" - -#if LJ_HASJIT -/* Data used by handlers to record a fast function. */ -typedef struct RecordFFData { - TValue *argv; /* Runtime argument values. */ - ptrdiff_t nres; /* Number of returned results (defaults to 1). */ - uint32_t data; /* Per-ffid auxiliary data (opcode, literal etc.). */ -} RecordFFData; - -LJ_FUNC int32_t lj_ffrecord_select_mode(jit_State *J, TRef tr, TValue *tv); -LJ_FUNC void lj_ffrecord_func(jit_State *J); -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_frame.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_frame.h deleted file mode 100644 index fb533b0e5..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_frame.h +++ /dev/null @@ -1,183 +0,0 @@ -/* -** Stack frames. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_FRAME_H -#define _LJ_FRAME_H - -#include "lj_obj.h" -#include "lj_bc.h" - -/* -- Lua stack frame ----------------------------------------------------- */ - -/* Frame type markers in callee function slot (callee base-1). */ -enum { - FRAME_LUA, FRAME_C, FRAME_CONT, FRAME_VARG, - FRAME_LUAP, FRAME_CP, FRAME_PCALL, FRAME_PCALLH -}; -#define FRAME_TYPE 3 -#define FRAME_P 4 -#define FRAME_TYPEP (FRAME_TYPE|FRAME_P) - -/* Macros to access and modify Lua frames. */ -#define frame_gc(f) (gcref((f)->fr.func)) -#define frame_func(f) (&frame_gc(f)->fn) -#define frame_ftsz(f) ((f)->fr.tp.ftsz) - -#define frame_type(f) (frame_ftsz(f) & FRAME_TYPE) -#define frame_typep(f) (frame_ftsz(f) & FRAME_TYPEP) -#define frame_islua(f) (frame_type(f) == FRAME_LUA) -#define frame_isc(f) (frame_type(f) == FRAME_C) -#define frame_iscont(f) (frame_typep(f) == FRAME_CONT) -#define frame_isvarg(f) (frame_typep(f) == FRAME_VARG) -#define frame_ispcall(f) ((frame_ftsz(f) & 6) == FRAME_PCALL) - -#define frame_pc(f) (mref((f)->fr.tp.pcr, const BCIns)) -#define frame_contpc(f) (frame_pc((f)-1)) -#if LJ_64 -#define frame_contf(f) \ - ((ASMFunction)(void *)((intptr_t)lj_vm_asm_begin + \ - (intptr_t)(int32_t)((f)-1)->u32.lo)) -#else -#define frame_contf(f) ((ASMFunction)gcrefp(((f)-1)->gcr, void)) -#endif -#define frame_delta(f) (frame_ftsz(f) >> 3) -#define frame_sized(f) (frame_ftsz(f) & ~FRAME_TYPEP) - -#define frame_prevl(f) ((f) - (1+bc_a(frame_pc(f)[-1]))) -#define frame_prevd(f) ((TValue *)((char *)(f) - frame_sized(f))) -#define frame_prev(f) (frame_islua(f)?frame_prevl(f):frame_prevd(f)) -/* Note: this macro does not skip over FRAME_VARG. */ - -#define setframe_pc(f, pc) (setmref((f)->fr.tp.pcr, (pc))) -#define setframe_ftsz(f, sz) ((f)->fr.tp.ftsz = (sz)) -#define setframe_gc(f, p) (setgcref((f)->fr.func, (p))) - -/* -- C stack frame ------------------------------------------------------- */ - -/* Macros to access and modify the C stack frame chain. */ - -/* These definitions must match with the arch-specific *.dasc files. */ -#if LJ_TARGET_X86 -#define CFRAME_OFS_ERRF (15*4) -#define CFRAME_OFS_NRES (14*4) -#define CFRAME_OFS_PREV (13*4) -#define CFRAME_OFS_L (12*4) -#define CFRAME_OFS_PC (6*4) -#define CFRAME_OFS_MULTRES (5*4) -#define CFRAME_SIZE (12*4) -#define CFRAME_SHIFT_MULTRES 0 -#elif LJ_TARGET_X64 -#if LJ_ABI_WIN -#define CFRAME_OFS_PREV (13*8) -#define CFRAME_OFS_PC (25*4) -#define CFRAME_OFS_L (24*4) -#define CFRAME_OFS_ERRF (23*4) -#define CFRAME_OFS_NRES (22*4) -#define CFRAME_OFS_MULTRES (21*4) -#define CFRAME_SIZE (10*8) -#define CFRAME_SIZE_JIT (CFRAME_SIZE + 9*16 + 4*8) -#define CFRAME_SHIFT_MULTRES 0 -#else -#define CFRAME_OFS_PREV (4*8) -#define CFRAME_OFS_PC (7*4) -#define CFRAME_OFS_L (6*4) -#define CFRAME_OFS_ERRF (5*4) -#define CFRAME_OFS_NRES (4*4) -#define CFRAME_OFS_MULTRES (1*4) -#define CFRAME_SIZE (10*8) -#define CFRAME_SIZE_JIT (CFRAME_SIZE + 16) -#define CFRAME_SHIFT_MULTRES 0 -#endif -#elif LJ_TARGET_ARM -#define CFRAME_OFS_ERRF 24 -#define CFRAME_OFS_NRES 20 -#define CFRAME_OFS_PREV 16 -#define CFRAME_OFS_L 12 -#define CFRAME_OFS_PC 8 -#define CFRAME_OFS_MULTRES 4 -#if LJ_ARCH_HASFPU -#define CFRAME_SIZE 128 -#else -#define CFRAME_SIZE 64 -#endif -#define CFRAME_SHIFT_MULTRES 3 -#elif LJ_TARGET_PPC -#if LJ_TARGET_XBOX360 -#define CFRAME_OFS_ERRF 424 -#define CFRAME_OFS_NRES 420 -#define CFRAME_OFS_PREV 400 -#define CFRAME_OFS_L 416 -#define CFRAME_OFS_PC 412 -#define CFRAME_OFS_MULTRES 408 -#define CFRAME_SIZE 384 -#define CFRAME_SHIFT_MULTRES 3 -#elif LJ_ARCH_PPC64 -#define CFRAME_OFS_ERRF 472 -#define CFRAME_OFS_NRES 468 -#define CFRAME_OFS_PREV 448 -#define CFRAME_OFS_L 464 -#define CFRAME_OFS_PC 460 -#define CFRAME_OFS_MULTRES 456 -#define CFRAME_SIZE 400 -#define CFRAME_SHIFT_MULTRES 3 -#else -#define CFRAME_OFS_ERRF 48 -#define CFRAME_OFS_NRES 44 -#define CFRAME_OFS_PREV 40 -#define CFRAME_OFS_L 36 -#define CFRAME_OFS_PC 32 -#define CFRAME_OFS_MULTRES 28 -#define CFRAME_SIZE 272 -#define CFRAME_SHIFT_MULTRES 3 -#endif -#elif LJ_TARGET_PPCSPE -#define CFRAME_OFS_ERRF 28 -#define CFRAME_OFS_NRES 24 -#define CFRAME_OFS_PREV 20 -#define CFRAME_OFS_L 16 -#define CFRAME_OFS_PC 12 -#define CFRAME_OFS_MULTRES 8 -#define CFRAME_SIZE 184 -#define CFRAME_SHIFT_MULTRES 3 -#elif LJ_TARGET_MIPS -#define CFRAME_OFS_ERRF 124 -#define CFRAME_OFS_NRES 120 -#define CFRAME_OFS_PREV 116 -#define CFRAME_OFS_L 112 -#define CFRAME_OFS_PC 20 -#define CFRAME_OFS_MULTRES 16 -#define CFRAME_SIZE 112 -#define CFRAME_SHIFT_MULTRES 3 -#else -#error "Missing CFRAME_* definitions for this architecture" -#endif - -#ifndef CFRAME_SIZE_JIT -#define CFRAME_SIZE_JIT CFRAME_SIZE -#endif - -#define CFRAME_RESUME 1 -#define CFRAME_UNWIND_FF 2 /* Only used in unwinder. */ -#define CFRAME_RAWMASK (~(intptr_t)(CFRAME_RESUME|CFRAME_UNWIND_FF)) - -#define cframe_errfunc(cf) (*(int32_t *)(((char *)(cf))+CFRAME_OFS_ERRF)) -#define cframe_nres(cf) (*(int32_t *)(((char *)(cf))+CFRAME_OFS_NRES)) -#define cframe_prev(cf) (*(void **)(((char *)(cf))+CFRAME_OFS_PREV)) -#define cframe_multres(cf) (*(uint32_t *)(((char *)(cf))+CFRAME_OFS_MULTRES)) -#define cframe_multres_n(cf) (cframe_multres((cf)) >> CFRAME_SHIFT_MULTRES) -#define cframe_L(cf) \ - (&gcref(*(GCRef *)(((char *)(cf))+CFRAME_OFS_L))->th) -#define cframe_pc(cf) \ - (mref(*(MRef *)(((char *)(cf))+CFRAME_OFS_PC), const BCIns)) -#define setcframe_L(cf, L) \ - (setmref(*(MRef *)(((char *)(cf))+CFRAME_OFS_L), (L))) -#define setcframe_pc(cf, pc) \ - (setmref(*(MRef *)(((char *)(cf))+CFRAME_OFS_PC), (pc))) -#define cframe_canyield(cf) ((intptr_t)(cf) & CFRAME_RESUME) -#define cframe_unwind_ff(cf) ((intptr_t)(cf) & CFRAME_UNWIND_FF) -#define cframe_raw(cf) ((void *)((intptr_t)(cf) & CFRAME_RAWMASK)) -#define cframe_Lpc(L) cframe_pc(cframe_raw(L->cframe)) - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_func.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_func.c deleted file mode 100644 index 9a59b0f0c..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_func.c +++ /dev/null @@ -1,185 +0,0 @@ -/* -** Function handling (prototypes, functions and upvalues). -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Portions taken verbatim or adapted from the Lua interpreter. -** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h -*/ - -#define lj_func_c -#define LUA_CORE - -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_func.h" -#include "lj_trace.h" -#include "lj_vm.h" - -/* -- Prototypes ---------------------------------------------------------- */ - -void LJ_FASTCALL lj_func_freeproto(global_State *g, GCproto *pt) -{ - lj_mem_free(g, pt, pt->sizept); -} - -/* -- Upvalues ------------------------------------------------------------ */ - -static void unlinkuv(GCupval *uv) -{ - lua_assert(uvprev(uvnext(uv)) == uv && uvnext(uvprev(uv)) == uv); - setgcrefr(uvnext(uv)->prev, uv->prev); - setgcrefr(uvprev(uv)->next, uv->next); -} - -/* Find existing open upvalue for a stack slot or create a new one. */ -static GCupval *func_finduv(lua_State *L, TValue *slot) -{ - global_State *g = G(L); - GCRef *pp = &L->openupval; - GCupval *p; - GCupval *uv; - /* Search the sorted list of open upvalues. */ - while (gcref(*pp) != NULL && uvval((p = gco2uv(gcref(*pp)))) >= slot) { - lua_assert(!p->closed && uvval(p) != &p->tv); - if (uvval(p) == slot) { /* Found open upvalue pointing to same slot? */ - if (isdead(g, obj2gco(p))) /* Resurrect it, if it's dead. */ - flipwhite(obj2gco(p)); - return p; - } - pp = &p->nextgc; - } - /* No matching upvalue found. Create a new one. */ - uv = lj_mem_newt(L, sizeof(GCupval), GCupval); - newwhite(g, uv); - uv->gct = ~LJ_TUPVAL; - uv->closed = 0; /* Still open. */ - setmref(uv->v, slot); /* Pointing to the stack slot. */ - /* NOBARRIER: The GCupval is new (marked white) and open. */ - setgcrefr(uv->nextgc, *pp); /* Insert into sorted list of open upvalues. */ - setgcref(*pp, obj2gco(uv)); - setgcref(uv->prev, obj2gco(&g->uvhead)); /* Insert into GC list, too. */ - setgcrefr(uv->next, g->uvhead.next); - setgcref(uvnext(uv)->prev, obj2gco(uv)); - setgcref(g->uvhead.next, obj2gco(uv)); - lua_assert(uvprev(uvnext(uv)) == uv && uvnext(uvprev(uv)) == uv); - return uv; -} - -/* Create an empty and closed upvalue. */ -static GCupval *func_emptyuv(lua_State *L) -{ - GCupval *uv = (GCupval *)lj_mem_newgco(L, sizeof(GCupval)); - uv->gct = ~LJ_TUPVAL; - uv->closed = 1; - setnilV(&uv->tv); - setmref(uv->v, &uv->tv); - return uv; -} - -/* Close all open upvalues pointing to some stack level or above. */ -void LJ_FASTCALL lj_func_closeuv(lua_State *L, TValue *level) -{ - GCupval *uv; - global_State *g = G(L); - while (gcref(L->openupval) != NULL && - uvval((uv = gco2uv(gcref(L->openupval)))) >= level) { - GCobj *o = obj2gco(uv); - lua_assert(!isblack(o) && !uv->closed && uvval(uv) != &uv->tv); - setgcrefr(L->openupval, uv->nextgc); /* No longer in open list. */ - if (isdead(g, o)) { - lj_func_freeuv(g, uv); - } else { - unlinkuv(uv); - lj_gc_closeuv(g, uv); - } - } -} - -void LJ_FASTCALL lj_func_freeuv(global_State *g, GCupval *uv) -{ - if (!uv->closed) - unlinkuv(uv); - lj_mem_freet(g, uv); -} - -/* -- Functions (closures) ------------------------------------------------ */ - -GCfunc *lj_func_newC(lua_State *L, MSize nelems, GCtab *env) -{ - GCfunc *fn = (GCfunc *)lj_mem_newgco(L, sizeCfunc(nelems)); - fn->c.gct = ~LJ_TFUNC; - fn->c.ffid = FF_C; - fn->c.nupvalues = (uint8_t)nelems; - /* NOBARRIER: The GCfunc is new (marked white). */ - setmref(fn->c.pc, &G(L)->bc_cfunc_ext); - setgcref(fn->c.env, obj2gco(env)); - return fn; -} - -static GCfunc *func_newL(lua_State *L, GCproto *pt, GCtab *env) -{ - uint32_t count; - GCfunc *fn = (GCfunc *)lj_mem_newgco(L, sizeLfunc((MSize)pt->sizeuv)); - fn->l.gct = ~LJ_TFUNC; - fn->l.ffid = FF_LUA; - fn->l.nupvalues = 0; /* Set to zero until upvalues are initialized. */ - /* NOBARRIER: Really a setgcref. But the GCfunc is new (marked white). */ - setmref(fn->l.pc, proto_bc(pt)); - setgcref(fn->l.env, obj2gco(env)); - /* Saturating 3 bit counter (0..7) for created closures. */ - count = (uint32_t)pt->flags + PROTO_CLCOUNT; - pt->flags = (uint8_t)(count - ((count >> PROTO_CLC_BITS) & PROTO_CLCOUNT)); - return fn; -} - -/* Create a new Lua function with empty upvalues. */ -GCfunc *lj_func_newL_empty(lua_State *L, GCproto *pt, GCtab *env) -{ - GCfunc *fn = func_newL(L, pt, env); - MSize i, nuv = pt->sizeuv; - /* NOBARRIER: The GCfunc is new (marked white). */ - for (i = 0; i < nuv; i++) { - GCupval *uv = func_emptyuv(L); - uv->dhash = (uint32_t)(uintptr_t)pt ^ ((uint32_t)proto_uv(pt)[i] << 24); - setgcref(fn->l.uvptr[i], obj2gco(uv)); - } - fn->l.nupvalues = (uint8_t)nuv; - return fn; -} - -/* Do a GC check and create a new Lua function with inherited upvalues. */ -GCfunc *lj_func_newL_gc(lua_State *L, GCproto *pt, GCfuncL *parent) -{ - GCfunc *fn; - GCRef *puv; - MSize i, nuv; - TValue *base; - lj_gc_check_fixtop(L); - fn = func_newL(L, pt, tabref(parent->env)); - /* NOBARRIER: The GCfunc is new (marked white). */ - puv = parent->uvptr; - nuv = pt->sizeuv; - base = L->base; - for (i = 0; i < nuv; i++) { - uint32_t v = proto_uv(pt)[i]; - GCupval *uv; - if ((v & PROTO_UV_LOCAL)) { - uv = func_finduv(L, base + (v & 0xff)); - uv->immutable = ((v / PROTO_UV_IMMUTABLE) & 1); - uv->dhash = (uint32_t)(uintptr_t)mref(parent->pc, char) ^ (v << 24); - } else { - uv = &gcref(puv[v])->uv; - } - setgcref(fn->l.uvptr[i], obj2gco(uv)); - } - fn->l.nupvalues = (uint8_t)nuv; - return fn; -} - -void LJ_FASTCALL lj_func_free(global_State *g, GCfunc *fn) -{ - MSize size = isluafunc(fn) ? sizeLfunc((MSize)fn->l.nupvalues) : - sizeCfunc((MSize)fn->c.nupvalues); - lj_mem_free(g, fn, size); -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_func.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_func.h deleted file mode 100644 index 88732e83e..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_func.h +++ /dev/null @@ -1,24 +0,0 @@ -/* -** Function handling (prototypes, functions and upvalues). -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_FUNC_H -#define _LJ_FUNC_H - -#include "lj_obj.h" - -/* Prototypes. */ -LJ_FUNC void LJ_FASTCALL lj_func_freeproto(global_State *g, GCproto *pt); - -/* Upvalues. */ -LJ_FUNCA void LJ_FASTCALL lj_func_closeuv(lua_State *L, TValue *level); -LJ_FUNC void LJ_FASTCALL lj_func_freeuv(global_State *g, GCupval *uv); - -/* Functions (closures). */ -LJ_FUNC GCfunc *lj_func_newC(lua_State *L, MSize nelems, GCtab *env); -LJ_FUNC GCfunc *lj_func_newL_empty(lua_State *L, GCproto *pt, GCtab *env); -LJ_FUNCA GCfunc *lj_func_newL_gc(lua_State *L, GCproto *pt, GCfuncL *parent); -LJ_FUNC void LJ_FASTCALL lj_func_free(global_State *g, GCfunc *c); - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_gc.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_gc.c deleted file mode 100644 index c2bc397d4..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_gc.c +++ /dev/null @@ -1,849 +0,0 @@ -/* -** Garbage collector. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Major portions taken verbatim or adapted from the Lua interpreter. -** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h -*/ - -#define lj_gc_c -#define LUA_CORE - -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_func.h" -#include "lj_udata.h" -#include "lj_meta.h" -#include "lj_state.h" -#include "lj_frame.h" -#if LJ_HASFFI -#include "lj_ctype.h" -#include "lj_cdata.h" -#endif -#include "lj_trace.h" -#include "lj_vm.h" - -#define GCSTEPSIZE 1024u -#define GCSWEEPMAX 40 -#define GCSWEEPCOST 10 -#define GCFINALIZECOST 100 - -/* Macros to set GCobj colors and flags. */ -#define white2gray(x) ((x)->gch.marked &= (uint8_t)~LJ_GC_WHITES) -#define gray2black(x) ((x)->gch.marked |= LJ_GC_BLACK) -#define isfinalized(u) ((u)->marked & LJ_GC_FINALIZED) - -/* -- Mark phase ---------------------------------------------------------- */ - -/* Mark a TValue (if needed). */ -#define gc_marktv(g, tv) \ - { lua_assert(!tvisgcv(tv) || (~itype(tv) == gcval(tv)->gch.gct)); \ - if (tviswhite(tv)) gc_mark(g, gcV(tv)); } - -/* Mark a GCobj (if needed). */ -#define gc_markobj(g, o) \ - { if (iswhite(obj2gco(o))) gc_mark(g, obj2gco(o)); } - -/* Mark a string object. */ -#define gc_mark_str(s) ((s)->marked &= (uint8_t)~LJ_GC_WHITES) - -/* Mark a white GCobj. */ -static void gc_mark(global_State *g, GCobj *o) -{ - int gct = o->gch.gct; - lua_assert(iswhite(o) && !isdead(g, o)); - white2gray(o); - if (LJ_UNLIKELY(gct == ~LJ_TUDATA)) { - GCtab *mt = tabref(gco2ud(o)->metatable); - gray2black(o); /* Userdata are never gray. */ - if (mt) gc_markobj(g, mt); - gc_markobj(g, tabref(gco2ud(o)->env)); - } else if (LJ_UNLIKELY(gct == ~LJ_TUPVAL)) { - GCupval *uv = gco2uv(o); - gc_marktv(g, uvval(uv)); - if (uv->closed) - gray2black(o); /* Closed upvalues are never gray. */ - } else if (gct != ~LJ_TSTR && gct != ~LJ_TCDATA) { - lua_assert(gct == ~LJ_TFUNC || gct == ~LJ_TTAB || - gct == ~LJ_TTHREAD || gct == ~LJ_TPROTO); - setgcrefr(o->gch.gclist, g->gc.gray); - setgcref(g->gc.gray, o); - } -} - -/* Mark GC roots. */ -static void gc_mark_gcroot(global_State *g) -{ - ptrdiff_t i; - for (i = 0; i < GCROOT_MAX; i++) - if (gcref(g->gcroot[i]) != NULL) - gc_markobj(g, gcref(g->gcroot[i])); -} - -/* Start a GC cycle and mark the root set. */ -static void gc_mark_start(global_State *g) -{ - setgcrefnull(g->gc.gray); - setgcrefnull(g->gc.grayagain); - setgcrefnull(g->gc.weak); - gc_markobj(g, mainthread(g)); - gc_markobj(g, tabref(mainthread(g)->env)); - gc_marktv(g, &g->registrytv); - gc_mark_gcroot(g); - g->gc.state = GCSpropagate; -} - -/* Mark open upvalues. */ -static void gc_mark_uv(global_State *g) -{ - GCupval *uv; - for (uv = uvnext(&g->uvhead); uv != &g->uvhead; uv = uvnext(uv)) { - lua_assert(uvprev(uvnext(uv)) == uv && uvnext(uvprev(uv)) == uv); - if (isgray(obj2gco(uv))) - gc_marktv(g, uvval(uv)); - } -} - -/* Mark userdata in mmudata list. */ -static void gc_mark_mmudata(global_State *g) -{ - GCobj *root = gcref(g->gc.mmudata); - GCobj *u = root; - if (u) { - do { - u = gcnext(u); - makewhite(g, u); /* Could be from previous GC. */ - gc_mark(g, u); - } while (u != root); - } -} - -/* Separate userdata objects to be finalized to mmudata list. */ -size_t lj_gc_separateudata(global_State *g, int all) -{ - size_t m = 0; - GCRef *p = &mainthread(g)->nextgc; - GCobj *o; - while ((o = gcref(*p)) != NULL) { - if (!(iswhite(o) || all) || isfinalized(gco2ud(o))) { - p = &o->gch.nextgc; /* Nothing to do. */ - } else if (!lj_meta_fastg(g, tabref(gco2ud(o)->metatable), MM_gc)) { - markfinalized(o); /* Done, as there's no __gc metamethod. */ - p = &o->gch.nextgc; - } else { /* Otherwise move userdata to be finalized to mmudata list. */ - m += sizeudata(gco2ud(o)); - markfinalized(o); - *p = o->gch.nextgc; - if (gcref(g->gc.mmudata)) { /* Link to end of mmudata list. */ - GCobj *root = gcref(g->gc.mmudata); - setgcrefr(o->gch.nextgc, root->gch.nextgc); - setgcref(root->gch.nextgc, o); - setgcref(g->gc.mmudata, o); - } else { /* Create circular list. */ - setgcref(o->gch.nextgc, o); - setgcref(g->gc.mmudata, o); - } - } - } - return m; -} - -/* -- Propagation phase --------------------------------------------------- */ - -/* Traverse a table. */ -static int gc_traverse_tab(global_State *g, GCtab *t) -{ - int weak = 0; - cTValue *mode; - GCtab *mt = tabref(t->metatable); - if (mt) - gc_markobj(g, mt); - mode = lj_meta_fastg(g, mt, MM_mode); - if (mode && tvisstr(mode)) { /* Valid __mode field? */ - const char *modestr = strVdata(mode); - int c; - while ((c = *modestr++)) { - if (c == 'k') weak |= LJ_GC_WEAKKEY; - else if (c == 'v') weak |= LJ_GC_WEAKVAL; - else if (c == 'K') weak = (int)(~0u & ~LJ_GC_WEAKVAL); - } - if (weak > 0) { /* Weak tables are cleared in the atomic phase. */ - t->marked = (uint8_t)((t->marked & ~LJ_GC_WEAK) | weak); - setgcrefr(t->gclist, g->gc.weak); - setgcref(g->gc.weak, obj2gco(t)); - } - } - if (weak == LJ_GC_WEAK) /* Nothing to mark if both keys/values are weak. */ - return 1; - if (!(weak & LJ_GC_WEAKVAL)) { /* Mark array part. */ - MSize i, asize = t->asize; - for (i = 0; i < asize; i++) - gc_marktv(g, arrayslot(t, i)); - } - if (t->hmask > 0) { /* Mark hash part. */ - Node *node = noderef(t->node); - MSize i, hmask = t->hmask; - for (i = 0; i <= hmask; i++) { - Node *n = &node[i]; - if (!tvisnil(&n->val)) { /* Mark non-empty slot. */ - lua_assert(!tvisnil(&n->key)); - if (!(weak & LJ_GC_WEAKKEY)) gc_marktv(g, &n->key); - if (!(weak & LJ_GC_WEAKVAL)) gc_marktv(g, &n->val); - } - } - } - return weak; -} - -/* Traverse a function. */ -static void gc_traverse_func(global_State *g, GCfunc *fn) -{ - gc_markobj(g, tabref(fn->c.env)); - if (isluafunc(fn)) { - uint32_t i; - lua_assert(fn->l.nupvalues <= funcproto(fn)->sizeuv); - gc_markobj(g, funcproto(fn)); - for (i = 0; i < fn->l.nupvalues; i++) /* Mark Lua function upvalues. */ - gc_markobj(g, &gcref(fn->l.uvptr[i])->uv); - } else { - uint32_t i; - for (i = 0; i < fn->c.nupvalues; i++) /* Mark C function upvalues. */ - gc_marktv(g, &fn->c.upvalue[i]); - } -} - -#if LJ_HASJIT -/* Mark a trace. */ -static void gc_marktrace(global_State *g, TraceNo traceno) -{ - GCobj *o = obj2gco(traceref(G2J(g), traceno)); - lua_assert(traceno != G2J(g)->cur.traceno); - if (iswhite(o)) { - white2gray(o); - setgcrefr(o->gch.gclist, g->gc.gray); - setgcref(g->gc.gray, o); - } -} - -/* Traverse a trace. */ -static void gc_traverse_trace(global_State *g, GCtrace *T) -{ - IRRef ref; - if (T->traceno == 0) return; - for (ref = T->nk; ref < REF_TRUE; ref++) { - IRIns *ir = &T->ir[ref]; - if (ir->o == IR_KGC) - gc_markobj(g, ir_kgc(ir)); - } - if (T->link) gc_marktrace(g, T->link); - if (T->nextroot) gc_marktrace(g, T->nextroot); - if (T->nextside) gc_marktrace(g, T->nextside); - gc_markobj(g, gcref(T->startpt)); -} - -/* The current trace is a GC root while not anchored in the prototype (yet). */ -#define gc_traverse_curtrace(g) gc_traverse_trace(g, &G2J(g)->cur) -#else -#define gc_traverse_curtrace(g) UNUSED(g) -#endif - -/* Traverse a prototype. */ -static void gc_traverse_proto(global_State *g, GCproto *pt) -{ - ptrdiff_t i; - gc_mark_str(proto_chunkname(pt)); - for (i = -(ptrdiff_t)pt->sizekgc; i < 0; i++) /* Mark collectable consts. */ - gc_markobj(g, proto_kgc(pt, i)); -#if LJ_HASJIT - if (pt->trace) gc_marktrace(g, pt->trace); -#endif -} - -/* Traverse the frame structure of a stack. */ -static MSize gc_traverse_frames(global_State *g, lua_State *th) -{ - TValue *frame, *top = th->top-1, *bot = tvref(th->stack); - /* Note: extra vararg frame not skipped, marks function twice (harmless). */ - for (frame = th->base-1; frame > bot; frame = frame_prev(frame)) { - GCfunc *fn = frame_func(frame); - TValue *ftop = frame; - if (isluafunc(fn)) ftop += funcproto(fn)->framesize; - if (ftop > top) top = ftop; - gc_markobj(g, fn); /* Need to mark hidden function (or L). */ - } - top++; /* Correct bias of -1 (frame == base-1). */ - if (top > tvref(th->maxstack)) top = tvref(th->maxstack); - return (MSize)(top - bot); /* Return minimum needed stack size. */ -} - -/* Traverse a thread object. */ -static void gc_traverse_thread(global_State *g, lua_State *th) -{ - TValue *o, *top = th->top; - for (o = tvref(th->stack)+1; o < top; o++) - gc_marktv(g, o); - if (g->gc.state == GCSatomic) { - top = tvref(th->stack) + th->stacksize; - for (; o < top; o++) /* Clear unmarked slots. */ - setnilV(o); - } - gc_markobj(g, tabref(th->env)); - lj_state_shrinkstack(th, gc_traverse_frames(g, th)); -} - -/* Propagate one gray object. Traverse it and turn it black. */ -static size_t propagatemark(global_State *g) -{ - GCobj *o = gcref(g->gc.gray); - int gct = o->gch.gct; - lua_assert(isgray(o)); - gray2black(o); - setgcrefr(g->gc.gray, o->gch.gclist); /* Remove from gray list. */ - if (LJ_LIKELY(gct == ~LJ_TTAB)) { - GCtab *t = gco2tab(o); - if (gc_traverse_tab(g, t) > 0) - black2gray(o); /* Keep weak tables gray. */ - return sizeof(GCtab) + sizeof(TValue) * t->asize + - sizeof(Node) * (t->hmask + 1); - } else if (LJ_LIKELY(gct == ~LJ_TFUNC)) { - GCfunc *fn = gco2func(o); - gc_traverse_func(g, fn); - return isluafunc(fn) ? sizeLfunc((MSize)fn->l.nupvalues) : - sizeCfunc((MSize)fn->c.nupvalues); - } else if (LJ_LIKELY(gct == ~LJ_TPROTO)) { - GCproto *pt = gco2pt(o); - gc_traverse_proto(g, pt); - return pt->sizept; - } else if (LJ_LIKELY(gct == ~LJ_TTHREAD)) { - lua_State *th = gco2th(o); - setgcrefr(th->gclist, g->gc.grayagain); - setgcref(g->gc.grayagain, o); - black2gray(o); /* Threads are never black. */ - gc_traverse_thread(g, th); - return sizeof(lua_State) + sizeof(TValue) * th->stacksize; - } else { -#if LJ_HASJIT - GCtrace *T = gco2trace(o); - gc_traverse_trace(g, T); - return ((sizeof(GCtrace)+7)&~7) + (T->nins-T->nk)*sizeof(IRIns) + - T->nsnap*sizeof(SnapShot) + T->nsnapmap*sizeof(SnapEntry); -#else - lua_assert(0); - return 0; -#endif - } -} - -/* Propagate all gray objects. */ -static size_t gc_propagate_gray(global_State *g) -{ - size_t m = 0; - while (gcref(g->gc.gray) != NULL) - m += propagatemark(g); - return m; -} - -/* -- Sweep phase --------------------------------------------------------- */ - -/* Try to shrink some common data structures. */ -static void gc_shrink(global_State *g, lua_State *L) -{ - if (g->strnum <= (g->strmask >> 2) && g->strmask > LJ_MIN_STRTAB*2-1) - lj_str_resize(L, g->strmask >> 1); /* Shrink string table. */ - if (g->tmpbuf.sz > LJ_MIN_SBUF*2) - lj_str_resizebuf(L, &g->tmpbuf, g->tmpbuf.sz >> 1); /* Shrink temp buf. */ -} - -/* Type of GC free functions. */ -typedef void (LJ_FASTCALL *GCFreeFunc)(global_State *g, GCobj *o); - -/* GC free functions for LJ_TSTR .. LJ_TUDATA. ORDER LJ_T */ -static const GCFreeFunc gc_freefunc[] = { - (GCFreeFunc)lj_str_free, - (GCFreeFunc)lj_func_freeuv, - (GCFreeFunc)lj_state_free, - (GCFreeFunc)lj_func_freeproto, - (GCFreeFunc)lj_func_free, -#if LJ_HASJIT - (GCFreeFunc)lj_trace_free, -#else - (GCFreeFunc)0, -#endif -#if LJ_HASFFI - (GCFreeFunc)lj_cdata_free, -#else - (GCFreeFunc)0, -#endif - (GCFreeFunc)lj_tab_free, - (GCFreeFunc)lj_udata_free -}; - -/* Full sweep of a GC list. */ -#define gc_fullsweep(g, p) gc_sweep(g, (p), LJ_MAX_MEM) - -/* Partial sweep of a GC list. */ -static GCRef *gc_sweep(global_State *g, GCRef *p, uint32_t lim) -{ - /* Mask with other white and LJ_GC_FIXED. Or LJ_GC_SFIXED on shutdown. */ - int ow = otherwhite(g); - GCobj *o; - while ((o = gcref(*p)) != NULL && lim-- > 0) { - if (o->gch.gct == ~LJ_TTHREAD) /* Need to sweep open upvalues, too. */ - gc_fullsweep(g, &gco2th(o)->openupval); - if (((o->gch.marked ^ LJ_GC_WHITES) & ow)) { /* Black or current white? */ - lua_assert(!isdead(g, o) || (o->gch.marked & LJ_GC_FIXED)); - makewhite(g, o); /* Value is alive, change to the current white. */ - p = &o->gch.nextgc; - } else { /* Otherwise value is dead, free it. */ - lua_assert(isdead(g, o) || ow == LJ_GC_SFIXED); - setgcrefr(*p, o->gch.nextgc); - if (o == gcref(g->gc.root)) - setgcrefr(g->gc.root, o->gch.nextgc); /* Adjust list anchor. */ - gc_freefunc[o->gch.gct - ~LJ_TSTR](g, o); - } - } - return p; -} - -/* Check whether we can clear a key or a value slot from a table. */ -static int gc_mayclear(cTValue *o, int val) -{ - if (tvisgcv(o)) { /* Only collectable objects can be weak references. */ - if (tvisstr(o)) { /* But strings cannot be used as weak references. */ - gc_mark_str(strV(o)); /* And need to be marked. */ - return 0; - } - if (iswhite(gcV(o))) - return 1; /* Object is about to be collected. */ - if (tvisudata(o) && val && isfinalized(udataV(o))) - return 1; /* Finalized userdata is dropped only from values. */ - } - return 0; /* Cannot clear. */ -} - -/* Clear collected entries from weak tables. */ -static void gc_clearweak(GCobj *o) -{ - while (o) { - GCtab *t = gco2tab(o); - lua_assert((t->marked & LJ_GC_WEAK)); - if ((t->marked & LJ_GC_WEAKVAL)) { - MSize i, asize = t->asize; - for (i = 0; i < asize; i++) { - /* Clear array slot when value is about to be collected. */ - TValue *tv = arrayslot(t, i); - if (gc_mayclear(tv, 1)) - setnilV(tv); - } - } - if (t->hmask > 0) { - Node *node = noderef(t->node); - MSize i, hmask = t->hmask; - for (i = 0; i <= hmask; i++) { - Node *n = &node[i]; - /* Clear hash slot when key or value is about to be collected. */ - if (!tvisnil(&n->val) && (gc_mayclear(&n->key, 0) || - gc_mayclear(&n->val, 1))) - setnilV(&n->val); - } - } - o = gcref(t->gclist); - } -} - -/* Call a userdata or cdata finalizer. */ -static void gc_call_finalizer(global_State *g, lua_State *L, - cTValue *mo, GCobj *o) -{ - /* Save and restore lots of state around the __gc callback. */ - uint8_t oldh = hook_save(g); - MSize oldt = g->gc.threshold; - int errcode; - TValue *top; - lj_trace_abort(g); - top = L->top; - L->top = top+2; - hook_entergc(g); /* Disable hooks and new traces during __gc. */ - g->gc.threshold = LJ_MAX_MEM; /* Prevent GC steps. */ - copyTV(L, top, mo); - setgcV(L, top+1, o, ~o->gch.gct); - errcode = lj_vm_pcall(L, top+1, 1+0, -1); /* Stack: |mo|o| -> | */ - hook_restore(g, oldh); - g->gc.threshold = oldt; /* Restore GC threshold. */ - if (errcode) - lj_err_throw(L, errcode); /* Propagate errors. */ -} - -/* Finalize one userdata or cdata object from the mmudata list. */ -static void gc_finalize(lua_State *L) -{ - global_State *g = G(L); - GCobj *o = gcnext(gcref(g->gc.mmudata)); - cTValue *mo; - lua_assert(gcref(g->jit_L) == NULL); /* Must not be called on trace. */ - /* Unchain from list of userdata to be finalized. */ - if (o == gcref(g->gc.mmudata)) - setgcrefnull(g->gc.mmudata); - else - setgcrefr(gcref(g->gc.mmudata)->gch.nextgc, o->gch.nextgc); -#if LJ_HASFFI - if (o->gch.gct == ~LJ_TCDATA) { - TValue tmp, *tv; - /* Add cdata back to the GC list and make it white. */ - setgcrefr(o->gch.nextgc, g->gc.root); - setgcref(g->gc.root, o); - makewhite(g, o); - o->gch.marked &= (uint8_t)~LJ_GC_CDATA_FIN; - /* Resolve finalizer. */ - setcdataV(L, &tmp, gco2cd(o)); - tv = lj_tab_set(L, ctype_ctsG(g)->finalizer, &tmp); - if (!tvisnil(tv)) { - g->gc.nocdatafin = 0; - copyTV(L, &tmp, tv); - setnilV(tv); /* Clear entry in finalizer table. */ - gc_call_finalizer(g, L, &tmp, o); - } - return; - } -#endif - /* Add userdata back to the main userdata list and make it white. */ - setgcrefr(o->gch.nextgc, mainthread(g)->nextgc); - setgcref(mainthread(g)->nextgc, o); - makewhite(g, o); - /* Resolve the __gc metamethod. */ - mo = lj_meta_fastg(g, tabref(gco2ud(o)->metatable), MM_gc); - if (mo) - gc_call_finalizer(g, L, mo, o); -} - -/* Finalize all userdata objects from mmudata list. */ -void lj_gc_finalize_udata(lua_State *L) -{ - while (gcref(G(L)->gc.mmudata) != NULL) - gc_finalize(L); -} - -#if LJ_HASFFI -/* Finalize all cdata objects from finalizer table. */ -void lj_gc_finalize_cdata(lua_State *L) -{ - global_State *g = G(L); - CTState *cts = ctype_ctsG(g); - if (cts) { - GCtab *t = cts->finalizer; - Node *node = noderef(t->node); - ptrdiff_t i; - setgcrefnull(t->metatable); /* Mark finalizer table as disabled. */ - for (i = (ptrdiff_t)t->hmask; i >= 0; i--) - if (!tvisnil(&node[i].val) && tviscdata(&node[i].key)) { - GCobj *o = gcV(&node[i].key); - TValue tmp; - makewhite(g, o); - o->gch.marked &= (uint8_t)~LJ_GC_CDATA_FIN; - copyTV(L, &tmp, &node[i].val); - setnilV(&node[i].val); - gc_call_finalizer(g, L, &tmp, o); - } - } -} -#endif - -/* Free all remaining GC objects. */ -void lj_gc_freeall(global_State *g) -{ - MSize i, strmask; - /* Free everything, except super-fixed objects (the main thread). */ - g->gc.currentwhite = LJ_GC_WHITES | LJ_GC_SFIXED; - gc_fullsweep(g, &g->gc.root); - strmask = g->strmask; - for (i = 0; i <= strmask; i++) /* Free all string hash chains. */ - gc_fullsweep(g, &g->strhash[i]); -} - -/* -- Collector ----------------------------------------------------------- */ - -/* Atomic part of the GC cycle, transitioning from mark to sweep phase. */ -static void atomic(global_State *g, lua_State *L) -{ - size_t udsize; - - gc_mark_uv(g); /* Need to remark open upvalues (the thread may be dead). */ - gc_propagate_gray(g); /* Propagate any left-overs. */ - - setgcrefr(g->gc.gray, g->gc.weak); /* Empty the list of weak tables. */ - setgcrefnull(g->gc.weak); - lua_assert(!iswhite(obj2gco(mainthread(g)))); - gc_markobj(g, L); /* Mark running thread. */ - gc_traverse_curtrace(g); /* Traverse current trace. */ - gc_mark_gcroot(g); /* Mark GC roots (again). */ - gc_propagate_gray(g); /* Propagate all of the above. */ - - setgcrefr(g->gc.gray, g->gc.grayagain); /* Empty the 2nd chance list. */ - setgcrefnull(g->gc.grayagain); - gc_propagate_gray(g); /* Propagate it. */ - - udsize = lj_gc_separateudata(g, 0); /* Separate userdata to be finalized. */ - gc_mark_mmudata(g); /* Mark them. */ - udsize += gc_propagate_gray(g); /* And propagate the marks. */ - - /* All marking done, clear weak tables. */ - gc_clearweak(gcref(g->gc.weak)); - - /* Prepare for sweep phase. */ - g->gc.currentwhite = (uint8_t)otherwhite(g); /* Flip current white. */ - g->strempty.marked = g->gc.currentwhite; - setmref(g->gc.sweep, &g->gc.root); - g->gc.estimate = g->gc.total - (MSize)udsize; /* Initial estimate. */ -} - -/* GC state machine. Returns a cost estimate for each step performed. */ -static size_t gc_onestep(lua_State *L) -{ - global_State *g = G(L); - switch (g->gc.state) { - case GCSpause: - gc_mark_start(g); /* Start a new GC cycle by marking all GC roots. */ - return 0; - case GCSpropagate: - if (gcref(g->gc.gray) != NULL) - return propagatemark(g); /* Propagate one gray object. */ - g->gc.state = GCSatomic; /* End of mark phase. */ - return 0; - case GCSatomic: - if (gcref(g->jit_L)) /* Don't run atomic phase on trace. */ - return LJ_MAX_MEM; - atomic(g, L); - g->gc.state = GCSsweepstring; /* Start of sweep phase. */ - g->gc.sweepstr = 0; - return 0; - case GCSsweepstring: { - MSize old = g->gc.total; - gc_fullsweep(g, &g->strhash[g->gc.sweepstr++]); /* Sweep one chain. */ - if (g->gc.sweepstr > g->strmask) - g->gc.state = GCSsweep; /* All string hash chains sweeped. */ - lua_assert(old >= g->gc.total); - g->gc.estimate -= old - g->gc.total; - return GCSWEEPCOST; - } - case GCSsweep: { - MSize old = g->gc.total; - setmref(g->gc.sweep, gc_sweep(g, mref(g->gc.sweep, GCRef), GCSWEEPMAX)); - if (gcref(*mref(g->gc.sweep, GCRef)) == NULL) { - gc_shrink(g, L); - if (gcref(g->gc.mmudata)) { /* Need any finalizations? */ - g->gc.state = GCSfinalize; -#if LJ_HASFFI - g->gc.nocdatafin = 1; -#endif - } else { /* Otherwise skip this phase to help the JIT. */ - g->gc.state = GCSpause; /* End of GC cycle. */ - g->gc.debt = 0; - } - } - lua_assert(old >= g->gc.total); - g->gc.estimate -= old - g->gc.total; - return GCSWEEPMAX*GCSWEEPCOST; - } - case GCSfinalize: - if (gcref(g->gc.mmudata) != NULL) { - if (gcref(g->jit_L)) /* Don't call finalizers on trace. */ - return LJ_MAX_MEM; - gc_finalize(L); /* Finalize one userdata object. */ - if (g->gc.estimate > GCFINALIZECOST) - g->gc.estimate -= GCFINALIZECOST; - return GCFINALIZECOST; - } -#if LJ_HASFFI - if (!g->gc.nocdatafin) lj_tab_rehash(L, ctype_ctsG(g)->finalizer); -#endif - g->gc.state = GCSpause; /* End of GC cycle. */ - g->gc.debt = 0; - return 0; - default: - lua_assert(0); - return 0; - } -} - -/* Perform a limited amount of incremental GC steps. */ -int LJ_FASTCALL lj_gc_step(lua_State *L) -{ - global_State *g = G(L); - MSize lim; - int32_t ostate = g->vmstate; - setvmstate(g, GC); - lim = (GCSTEPSIZE/100) * g->gc.stepmul; - if (lim == 0) - lim = LJ_MAX_MEM; - if (g->gc.total > g->gc.threshold) - g->gc.debt += g->gc.total - g->gc.threshold; - do { - lim -= (MSize)gc_onestep(L); - if (g->gc.state == GCSpause) { - g->gc.threshold = (g->gc.estimate/100) * g->gc.pause; - g->vmstate = ostate; - return 1; /* Finished a GC cycle. */ - } - } while ((int32_t)lim > 0); - if (g->gc.debt < GCSTEPSIZE) { - g->gc.threshold = g->gc.total + GCSTEPSIZE; - g->vmstate = ostate; - return -1; - } else { - g->gc.debt -= GCSTEPSIZE; - g->gc.threshold = g->gc.total; - g->vmstate = ostate; - return 0; - } -} - -/* Ditto, but fix the stack top first. */ -void LJ_FASTCALL lj_gc_step_fixtop(lua_State *L) -{ - if (curr_funcisL(L)) L->top = curr_topL(L); - lj_gc_step(L); -} - -#if LJ_HASJIT -/* Perform multiple GC steps. Called from JIT-compiled code. */ -int LJ_FASTCALL lj_gc_step_jit(global_State *g, MSize steps) -{ - lua_State *L = gco2th(gcref(g->jit_L)); - L->base = mref(G(L)->jit_base, TValue); - L->top = curr_topL(L); - while (steps-- > 0 && lj_gc_step(L) == 0) - ; - /* Return 1 to force a trace exit. */ - return (G(L)->gc.state == GCSatomic || G(L)->gc.state == GCSfinalize); -} -#endif - -/* Perform a full GC cycle. */ -void lj_gc_fullgc(lua_State *L) -{ - global_State *g = G(L); - int32_t ostate = g->vmstate; - setvmstate(g, GC); - if (g->gc.state <= GCSatomic) { /* Caught somewhere in the middle. */ - setmref(g->gc.sweep, &g->gc.root); /* Sweep everything (preserving it). */ - setgcrefnull(g->gc.gray); /* Reset lists from partial propagation. */ - setgcrefnull(g->gc.grayagain); - setgcrefnull(g->gc.weak); - g->gc.state = GCSsweepstring; /* Fast forward to the sweep phase. */ - g->gc.sweepstr = 0; - } - while (g->gc.state == GCSsweepstring || g->gc.state == GCSsweep) - gc_onestep(L); /* Finish sweep. */ - lua_assert(g->gc.state == GCSfinalize || g->gc.state == GCSpause); - /* Now perform a full GC. */ - g->gc.state = GCSpause; - do { gc_onestep(L); } while (g->gc.state != GCSpause); - g->gc.threshold = (g->gc.estimate/100) * g->gc.pause; - g->vmstate = ostate; -} - -/* -- Write barriers ------------------------------------------------------ */ - -/* Move the GC propagation frontier forward. */ -void lj_gc_barrierf(global_State *g, GCobj *o, GCobj *v) -{ - lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); - lua_assert(g->gc.state != GCSfinalize && g->gc.state != GCSpause); - lua_assert(o->gch.gct != ~LJ_TTAB); - /* Preserve invariant during propagation. Otherwise it doesn't matter. */ - if (g->gc.state == GCSpropagate || g->gc.state == GCSatomic) - gc_mark(g, v); /* Move frontier forward. */ - else - makewhite(g, o); /* Make it white to avoid the following barrier. */ -} - -/* Specialized barrier for closed upvalue. Pass &uv->tv. */ -void LJ_FASTCALL lj_gc_barrieruv(global_State *g, TValue *tv) -{ -#define TV2MARKED(x) \ - (*((uint8_t *)(x) - offsetof(GCupval, tv) + offsetof(GCupval, marked))) - if (g->gc.state == GCSpropagate || g->gc.state == GCSatomic) - gc_mark(g, gcV(tv)); - else - TV2MARKED(tv) = (TV2MARKED(tv) & (uint8_t)~LJ_GC_COLORS) | curwhite(g); -#undef TV2MARKED -} - -/* Close upvalue. Also needs a write barrier. */ -void lj_gc_closeuv(global_State *g, GCupval *uv) -{ - GCobj *o = obj2gco(uv); - /* Copy stack slot to upvalue itself and point to the copy. */ - copyTV(mainthread(g), &uv->tv, uvval(uv)); - setmref(uv->v, &uv->tv); - uv->closed = 1; - setgcrefr(o->gch.nextgc, g->gc.root); - setgcref(g->gc.root, o); - if (isgray(o)) { /* A closed upvalue is never gray, so fix this. */ - if (g->gc.state == GCSpropagate || g->gc.state == GCSatomic) { - gray2black(o); /* Make it black and preserve invariant. */ - if (tviswhite(&uv->tv)) - lj_gc_barrierf(g, o, gcV(&uv->tv)); - } else { - makewhite(g, o); /* Make it white, i.e. sweep the upvalue. */ - lua_assert(g->gc.state != GCSfinalize && g->gc.state != GCSpause); - } - } -} - -#if LJ_HASJIT -/* Mark a trace if it's saved during the propagation phase. */ -void lj_gc_barriertrace(global_State *g, uint32_t traceno) -{ - if (g->gc.state == GCSpropagate || g->gc.state == GCSatomic) - gc_marktrace(g, traceno); -} -#endif - -/* -- Allocator ----------------------------------------------------------- */ - -/* Call pluggable memory allocator to allocate or resize a fragment. */ -void *lj_mem_realloc(lua_State *L, void *p, MSize osz, MSize nsz) -{ - global_State *g = G(L); - lua_assert((osz == 0) == (p == NULL)); - p = g->allocf(g->allocd, p, osz, nsz); - if (p == NULL && nsz > 0) - lj_err_mem(L); - lua_assert((nsz == 0) == (p == NULL)); - lua_assert(checkptr32(p)); - g->gc.total = (g->gc.total - osz) + nsz; - return p; -} - -/* Allocate new GC object and link it to the root set. */ -void * LJ_FASTCALL lj_mem_newgco(lua_State *L, MSize size) -{ - global_State *g = G(L); - GCobj *o = (GCobj *)g->allocf(g->allocd, NULL, 0, size); - if (o == NULL) - lj_err_mem(L); - lua_assert(checkptr32(o)); - g->gc.total += size; - setgcrefr(o->gch.nextgc, g->gc.root); - setgcref(g->gc.root, o); - newwhite(g, o); - return o; -} - -/* Resize growable vector. */ -void *lj_mem_grow(lua_State *L, void *p, MSize *szp, MSize lim, MSize esz) -{ - MSize sz = (*szp) << 1; - if (sz < LJ_MIN_VECSZ) - sz = LJ_MIN_VECSZ; - if (sz > lim) - sz = lim; - p = lj_mem_realloc(L, p, (*szp)*esz, sz*esz); - *szp = sz; - return p; -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_gc.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_gc.h deleted file mode 100644 index c85d0756b..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_gc.h +++ /dev/null @@ -1,134 +0,0 @@ -/* -** Garbage collector. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_GC_H -#define _LJ_GC_H - -#include "lj_obj.h" - -/* Garbage collector states. Order matters. */ -enum { - GCSpause, GCSpropagate, GCSatomic, GCSsweepstring, GCSsweep, GCSfinalize -}; - -/* Bitmasks for marked field of GCobj. */ -#define LJ_GC_WHITE0 0x01 -#define LJ_GC_WHITE1 0x02 -#define LJ_GC_BLACK 0x04 -#define LJ_GC_FINALIZED 0x08 -#define LJ_GC_WEAKKEY 0x08 -#define LJ_GC_WEAKVAL 0x10 -#define LJ_GC_CDATA_FIN 0x10 -#define LJ_GC_FIXED 0x20 -#define LJ_GC_SFIXED 0x40 - -#define LJ_GC_WHITES (LJ_GC_WHITE0 | LJ_GC_WHITE1) -#define LJ_GC_COLORS (LJ_GC_WHITES | LJ_GC_BLACK) -#define LJ_GC_WEAK (LJ_GC_WEAKKEY | LJ_GC_WEAKVAL) - -/* Macros to test and set GCobj colors. */ -#define iswhite(x) ((x)->gch.marked & LJ_GC_WHITES) -#define isblack(x) ((x)->gch.marked & LJ_GC_BLACK) -#define isgray(x) (!((x)->gch.marked & (LJ_GC_BLACK|LJ_GC_WHITES))) -#define tviswhite(x) (tvisgcv(x) && iswhite(gcV(x))) -#define otherwhite(g) (g->gc.currentwhite ^ LJ_GC_WHITES) -#define isdead(g, v) ((v)->gch.marked & otherwhite(g) & LJ_GC_WHITES) - -#define curwhite(g) ((g)->gc.currentwhite & LJ_GC_WHITES) -#define newwhite(g, x) (obj2gco(x)->gch.marked = (uint8_t)curwhite(g)) -#define makewhite(g, x) \ - ((x)->gch.marked = ((x)->gch.marked & (uint8_t)~LJ_GC_COLORS) | curwhite(g)) -#define flipwhite(x) ((x)->gch.marked ^= LJ_GC_WHITES) -#define black2gray(x) ((x)->gch.marked &= (uint8_t)~LJ_GC_BLACK) -#define fixstring(s) ((s)->marked |= LJ_GC_FIXED) -#define markfinalized(x) ((x)->gch.marked |= LJ_GC_FINALIZED) - -/* Collector. */ -LJ_FUNC size_t lj_gc_separateudata(global_State *g, int all); -LJ_FUNC void lj_gc_finalize_udata(lua_State *L); -#if LJ_HASFFI -LJ_FUNC void lj_gc_finalize_cdata(lua_State *L); -#else -#define lj_gc_finalize_cdata(L) UNUSED(L) -#endif -LJ_FUNC void lj_gc_freeall(global_State *g); -LJ_FUNCA int LJ_FASTCALL lj_gc_step(lua_State *L); -LJ_FUNCA void LJ_FASTCALL lj_gc_step_fixtop(lua_State *L); -#if LJ_HASJIT -LJ_FUNC int LJ_FASTCALL lj_gc_step_jit(global_State *g, MSize steps); -#endif -LJ_FUNC void lj_gc_fullgc(lua_State *L); - -/* GC check: drive collector forward if the GC threshold has been reached. */ -#define lj_gc_check(L) \ - { if (LJ_UNLIKELY(G(L)->gc.total >= G(L)->gc.threshold)) \ - lj_gc_step(L); } -#define lj_gc_check_fixtop(L) \ - { if (LJ_UNLIKELY(G(L)->gc.total >= G(L)->gc.threshold)) \ - lj_gc_step_fixtop(L); } - -/* Write barriers. */ -LJ_FUNC void lj_gc_barrierf(global_State *g, GCobj *o, GCobj *v); -LJ_FUNCA void LJ_FASTCALL lj_gc_barrieruv(global_State *g, TValue *tv); -LJ_FUNC void lj_gc_closeuv(global_State *g, GCupval *uv); -#if LJ_HASJIT -LJ_FUNC void lj_gc_barriertrace(global_State *g, uint32_t traceno); -#endif - -/* Move the GC propagation frontier back for tables (make it gray again). */ -static LJ_AINLINE void lj_gc_barrierback(global_State *g, GCtab *t) -{ - GCobj *o = obj2gco(t); - lua_assert(isblack(o) && !isdead(g, o)); - lua_assert(g->gc.state != GCSfinalize && g->gc.state != GCSpause); - black2gray(o); - setgcrefr(t->gclist, g->gc.grayagain); - setgcref(g->gc.grayagain, o); -} - -/* Barrier for stores to table objects. TValue and GCobj variant. */ -#define lj_gc_anybarriert(L, t) \ - { if (LJ_UNLIKELY(isblack(obj2gco(t)))) lj_gc_barrierback(G(L), (t)); } -#define lj_gc_barriert(L, t, tv) \ - { if (tviswhite(tv) && isblack(obj2gco(t))) \ - lj_gc_barrierback(G(L), (t)); } -#define lj_gc_objbarriert(L, t, o) \ - { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) \ - lj_gc_barrierback(G(L), (t)); } - -/* Barrier for stores to any other object. TValue and GCobj variant. */ -#define lj_gc_barrier(L, p, tv) \ - { if (tviswhite(tv) && isblack(obj2gco(p))) \ - lj_gc_barrierf(G(L), obj2gco(p), gcV(tv)); } -#define lj_gc_objbarrier(L, p, o) \ - { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ - lj_gc_barrierf(G(L), obj2gco(p), obj2gco(o)); } - -/* Allocator. */ -LJ_FUNC void *lj_mem_realloc(lua_State *L, void *p, MSize osz, MSize nsz); -LJ_FUNC void * LJ_FASTCALL lj_mem_newgco(lua_State *L, MSize size); -LJ_FUNC void *lj_mem_grow(lua_State *L, void *p, - MSize *szp, MSize lim, MSize esz); - -#define lj_mem_new(L, s) lj_mem_realloc(L, NULL, 0, (s)) - -static LJ_AINLINE void lj_mem_free(global_State *g, void *p, size_t osize) -{ - g->gc.total -= (MSize)osize; - g->allocf(g->allocd, p, osize, 0); -} - -#define lj_mem_newvec(L, n, t) ((t *)lj_mem_new(L, (MSize)((n)*sizeof(t)))) -#define lj_mem_reallocvec(L, p, on, n, t) \ - ((p) = (t *)lj_mem_realloc(L, p, (on)*sizeof(t), (MSize)((n)*sizeof(t)))) -#define lj_mem_growvec(L, p, n, m, t) \ - ((p) = (t *)lj_mem_grow(L, (p), &(n), (m), (MSize)sizeof(t))) -#define lj_mem_freevec(g, p, n, t) lj_mem_free(g, (p), (n)*sizeof(t)) - -#define lj_mem_newobj(L, t) ((t *)lj_mem_newgco(L, sizeof(t))) -#define lj_mem_newt(L, s, t) ((t *)lj_mem_new(L, (s))) -#define lj_mem_freet(g, p) lj_mem_free(g, (p), sizeof(*(p))) - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_gdbjit.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_gdbjit.c deleted file mode 100644 index 5e7fca1c1..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_gdbjit.c +++ /dev/null @@ -1,793 +0,0 @@ -/* -** Client for the GDB JIT API. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_gdbjit_c -#define LUA_CORE - -#include "lj_obj.h" - -#if LJ_HASJIT - -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_debug.h" -#include "lj_frame.h" -#include "lj_jit.h" -#include "lj_dispatch.h" - -/* This is not compiled in by default. -** Enable with -DLUAJIT_USE_GDBJIT in the Makefile and recompile everything. -*/ -#ifdef LUAJIT_USE_GDBJIT - -/* The GDB JIT API allows JIT compilers to pass debug information about -** JIT-compiled code back to GDB. You need at least GDB 7.0 or higher -** to see it in action. -** -** This is a passive API, so it works even when not running under GDB -** or when attaching to an already running process. Alas, this implies -** enabling it always has a non-negligible overhead -- do not use in -** release mode! -** -** The LuaJIT GDB JIT client is rather minimal at the moment. It gives -** each trace a symbol name and adds a source location and frame unwind -** information. Obviously LuaJIT itself and any embedding C application -** should be compiled with debug symbols, too (see the Makefile). -** -** Traces are named TRACE_1, TRACE_2, ... these correspond to the trace -** numbers from -jv or -jdump. Use "break TRACE_1" or "tbreak TRACE_1" etc. -** to set breakpoints on specific traces (even ahead of their creation). -** -** The source location for each trace allows listing the corresponding -** source lines with the GDB command "list" (but only if the Lua source -** has been loaded from a file). Currently this is always set to the -** location where the trace has been started. -** -** Frame unwind information can be inspected with the GDB command -** "info frame". This also allows proper backtraces across JIT-compiled -** code with the GDB command "bt". -** -** You probably want to add the following settings to a .gdbinit file -** (or add them to ~/.gdbinit): -** set disassembly-flavor intel -** set breakpoint pending on -** -** Here's a sample GDB session: -** ------------------------------------------------------------------------ - -$ cat >x.lua -for outer=1,100 do - for inner=1,100 do end -end -^D - -$ luajit -jv x.lua -[TRACE 1 x.lua:2] -[TRACE 2 (1/3) x.lua:1 -> 1] - -$ gdb --quiet --args luajit x.lua -(gdb) tbreak TRACE_1 -Function "TRACE_1" not defined. -Temporary breakpoint 1 (TRACE_1) pending. -(gdb) run -Starting program: luajit x.lua - -Temporary breakpoint 1, TRACE_1 () at x.lua:2 -2 for inner=1,100 do end -(gdb) list -1 for outer=1,100 do -2 for inner=1,100 do end -3 end -(gdb) bt -#0 TRACE_1 () at x.lua:2 -#1 0x08053690 in lua_pcall [...] -[...] -#7 0x0806ff90 in main [...] -(gdb) disass TRACE_1 -Dump of assembler code for function TRACE_1: -0xf7fd9fba : mov DWORD PTR ds:0xf7e0e2a0,0x1 -0xf7fd9fc4 : movsd xmm7,QWORD PTR [edx+0x20] -[...] -0xf7fd9ff8 : jmp 0xf7fd2014 -End of assembler dump. -(gdb) tbreak TRACE_2 -Function "TRACE_2" not defined. -Temporary breakpoint 2 (TRACE_2) pending. -(gdb) cont -Continuing. - -Temporary breakpoint 2, TRACE_2 () at x.lua:1 -1 for outer=1,100 do -(gdb) info frame -Stack level 0, frame at 0xffffd7c0: - eip = 0xf7fd9f60 in TRACE_2 (x.lua:1); saved eip 0x8053690 - called by frame at 0xffffd7e0 - source language unknown. - Arglist at 0xffffd78c, args: - Locals at 0xffffd78c, Previous frame's sp is 0xffffd7c0 - Saved registers: - ebx at 0xffffd7ac, ebp at 0xffffd7b8, esi at 0xffffd7b0, edi at 0xffffd7b4, - eip at 0xffffd7bc -(gdb) - -** ------------------------------------------------------------------------ -*/ - -/* -- GDB JIT API --------------------------------------------------------- */ - -/* GDB JIT actions. */ -enum { - GDBJIT_NOACTION = 0, - GDBJIT_REGISTER, - GDBJIT_UNREGISTER -}; - -/* GDB JIT entry. */ -typedef struct GDBJITentry { - struct GDBJITentry *next_entry; - struct GDBJITentry *prev_entry; - const char *symfile_addr; - uint64_t symfile_size; -} GDBJITentry; - -/* GDB JIT descriptor. */ -typedef struct GDBJITdesc { - uint32_t version; - uint32_t action_flag; - GDBJITentry *relevant_entry; - GDBJITentry *first_entry; -} GDBJITdesc; - -GDBJITdesc __jit_debug_descriptor = { - 1, GDBJIT_NOACTION, NULL, NULL -}; - -/* GDB sets a breakpoint at this function. */ -void LJ_NOINLINE __jit_debug_register_code() -{ - __asm__ __volatile__(""); -}; - -/* -- In-memory ELF object definitions ------------------------------------ */ - -/* ELF definitions. */ -typedef struct ELFheader { - uint8_t emagic[4]; - uint8_t eclass; - uint8_t eendian; - uint8_t eversion; - uint8_t eosabi; - uint8_t eabiversion; - uint8_t epad[7]; - uint16_t type; - uint16_t machine; - uint32_t version; - uintptr_t entry; - uintptr_t phofs; - uintptr_t shofs; - uint32_t flags; - uint16_t ehsize; - uint16_t phentsize; - uint16_t phnum; - uint16_t shentsize; - uint16_t shnum; - uint16_t shstridx; -} ELFheader; - -typedef struct ELFsectheader { - uint32_t name; - uint32_t type; - uintptr_t flags; - uintptr_t addr; - uintptr_t ofs; - uintptr_t size; - uint32_t link; - uint32_t info; - uintptr_t align; - uintptr_t entsize; -} ELFsectheader; - -#define ELFSECT_IDX_ABS 0xfff1 - -enum { - ELFSECT_TYPE_PROGBITS = 1, - ELFSECT_TYPE_SYMTAB = 2, - ELFSECT_TYPE_STRTAB = 3, - ELFSECT_TYPE_NOBITS = 8 -}; - -#define ELFSECT_FLAGS_WRITE 1 -#define ELFSECT_FLAGS_ALLOC 2 -#define ELFSECT_FLAGS_EXEC 4 - -typedef struct ELFsymbol { -#if LJ_64 - uint32_t name; - uint8_t info; - uint8_t other; - uint16_t sectidx; - uintptr_t value; - uint64_t size; -#else - uint32_t name; - uintptr_t value; - uint32_t size; - uint8_t info; - uint8_t other; - uint16_t sectidx; -#endif -} ELFsymbol; - -enum { - ELFSYM_TYPE_FUNC = 2, - ELFSYM_TYPE_FILE = 4, - ELFSYM_BIND_LOCAL = 0 << 4, - ELFSYM_BIND_GLOBAL = 1 << 4, -}; - -/* DWARF definitions. */ -#define DW_CIE_VERSION 1 - -enum { - DW_CFA_nop = 0x0, - DW_CFA_offset_extended = 0x5, - DW_CFA_def_cfa = 0xc, - DW_CFA_def_cfa_offset = 0xe, - DW_CFA_offset_extended_sf = 0x11, - DW_CFA_advance_loc = 0x40, - DW_CFA_offset = 0x80 -}; - -enum { - DW_EH_PE_udata4 = 3, - DW_EH_PE_textrel = 0x20 -}; - -enum { - DW_TAG_compile_unit = 0x11 -}; - -enum { - DW_children_no = 0, - DW_children_yes = 1 -}; - -enum { - DW_AT_name = 0x03, - DW_AT_stmt_list = 0x10, - DW_AT_low_pc = 0x11, - DW_AT_high_pc = 0x12 -}; - -enum { - DW_FORM_addr = 0x01, - DW_FORM_data4 = 0x06, - DW_FORM_string = 0x08 -}; - -enum { - DW_LNS_extended_op = 0, - DW_LNS_copy = 1, - DW_LNS_advance_pc = 2, - DW_LNS_advance_line = 3 -}; - -enum { - DW_LNE_end_sequence = 1, - DW_LNE_set_address = 2 -}; - -enum { -#if LJ_TARGET_X86 - DW_REG_AX, DW_REG_CX, DW_REG_DX, DW_REG_BX, - DW_REG_SP, DW_REG_BP, DW_REG_SI, DW_REG_DI, - DW_REG_RA, -#elif LJ_TARGET_X64 - /* Yes, the order is strange, but correct. */ - DW_REG_AX, DW_REG_DX, DW_REG_CX, DW_REG_BX, - DW_REG_SI, DW_REG_DI, DW_REG_BP, DW_REG_SP, - DW_REG_8, DW_REG_9, DW_REG_10, DW_REG_11, - DW_REG_12, DW_REG_13, DW_REG_14, DW_REG_15, - DW_REG_RA, -#elif LJ_TARGET_ARM - DW_REG_SP = 13, - DW_REG_RA = 14, -#elif LJ_TARGET_PPC - DW_REG_SP = 1, - DW_REG_RA = 65, - DW_REG_CR = 70, -#elif LJ_TARGET_MIPS - DW_REG_SP = 29, - DW_REG_RA = 31, -#else -#error "Unsupported target architecture" -#endif -}; - -/* Minimal list of sections for the in-memory ELF object. */ -enum { - GDBJIT_SECT_NULL, - GDBJIT_SECT_text, - GDBJIT_SECT_eh_frame, - GDBJIT_SECT_shstrtab, - GDBJIT_SECT_strtab, - GDBJIT_SECT_symtab, - GDBJIT_SECT_debug_info, - GDBJIT_SECT_debug_abbrev, - GDBJIT_SECT_debug_line, - GDBJIT_SECT__MAX -}; - -enum { - GDBJIT_SYM_UNDEF, - GDBJIT_SYM_FILE, - GDBJIT_SYM_FUNC, - GDBJIT_SYM__MAX -}; - -/* In-memory ELF object. */ -typedef struct GDBJITobj { - ELFheader hdr; /* ELF header. */ - ELFsectheader sect[GDBJIT_SECT__MAX]; /* ELF sections. */ - ELFsymbol sym[GDBJIT_SYM__MAX]; /* ELF symbol table. */ - uint8_t space[4096]; /* Space for various section data. */ -} GDBJITobj; - -/* Combined structure for GDB JIT entry and ELF object. */ -typedef struct GDBJITentryobj { - GDBJITentry entry; - size_t sz; - GDBJITobj obj; -} GDBJITentryobj; - -/* Template for in-memory ELF header. */ -static const ELFheader elfhdr_template = { - .emagic = { 0x7f, 'E', 'L', 'F' }, - .eclass = LJ_64 ? 2 : 1, - .eendian = LJ_ENDIAN_SELECT(1, 2), - .eversion = 1, -#if LJ_TARGET_LINUX - .eosabi = 0, /* Nope, it's not 3. */ -#elif defined(__FreeBSD__) - .eosabi = 9, -#elif defined(__NetBSD__) - .eosabi = 2, -#elif defined(__OpenBSD__) - .eosabi = 12, -#elif (defined(__sun__) && defined(__svr4__)) - .eosabi = 6, -#else - .eosabi = 0, -#endif - .eabiversion = 0, - .epad = { 0, 0, 0, 0, 0, 0, 0 }, - .type = 1, -#if LJ_TARGET_X86 - .machine = 3, -#elif LJ_TARGET_X64 - .machine = 62, -#elif LJ_TARGET_ARM - .machine = 40, -#elif LJ_TARGET_PPC - .machine = 20, -#elif LJ_TARGET_MIPS - .machine = 8, -#else -#error "Unsupported target architecture" -#endif - .version = 1, - .entry = 0, - .phofs = 0, - .shofs = offsetof(GDBJITobj, sect), - .flags = 0, - .ehsize = sizeof(ELFheader), - .phentsize = 0, - .phnum = 0, - .shentsize = sizeof(ELFsectheader), - .shnum = GDBJIT_SECT__MAX, - .shstridx = GDBJIT_SECT_shstrtab -}; - -/* -- In-memory ELF object generation ------------------------------------- */ - -/* Context for generating the ELF object for the GDB JIT API. */ -typedef struct GDBJITctx { - uint8_t *p; /* Pointer to next address in obj.space. */ - uint8_t *startp; /* Pointer to start address in obj.space. */ - GCtrace *T; /* Generate symbols for this trace. */ - uintptr_t mcaddr; /* Machine code address. */ - MSize szmcode; /* Size of machine code. */ - MSize spadjp; /* Stack adjustment for parent trace or interpreter. */ - MSize spadj; /* Stack adjustment for trace itself. */ - BCLine lineno; /* Starting line number. */ - const char *filename; /* Starting file name. */ - size_t objsize; /* Final size of ELF object. */ - GDBJITobj obj; /* In-memory ELF object. */ -} GDBJITctx; - -/* Add a zero-terminated string. */ -static uint32_t gdbjit_strz(GDBJITctx *ctx, const char *str) -{ - uint8_t *p = ctx->p; - uint32_t ofs = (uint32_t)(p - ctx->startp); - do { - *p++ = (uint8_t)*str; - } while (*str++); - ctx->p = p; - return ofs; -} - -/* Append a decimal number. */ -static void gdbjit_catnum(GDBJITctx *ctx, uint32_t n) -{ - if (n >= 10) { uint32_t m = n / 10; n = n % 10; gdbjit_catnum(ctx, m); } - *ctx->p++ = '0' + n; -} - -/* Add a ULEB128 value. */ -static void gdbjit_uleb128(GDBJITctx *ctx, uint32_t v) -{ - uint8_t *p = ctx->p; - for (; v >= 0x80; v >>= 7) - *p++ = (uint8_t)((v & 0x7f) | 0x80); - *p++ = (uint8_t)v; - ctx->p = p; -} - -/* Add a SLEB128 value. */ -static void gdbjit_sleb128(GDBJITctx *ctx, int32_t v) -{ - uint8_t *p = ctx->p; - for (; (uint32_t)(v+0x40) >= 0x80; v >>= 7) - *p++ = (uint8_t)((v & 0x7f) | 0x80); - *p++ = (uint8_t)(v & 0x7f); - ctx->p = p; -} - -/* Shortcuts to generate DWARF structures. */ -#define DB(x) (*p++ = (x)) -#define DI8(x) (*(int8_t *)p = (x), p++) -#define DU16(x) (*(uint16_t *)p = (x), p += 2) -#define DU32(x) (*(uint32_t *)p = (x), p += 4) -#define DADDR(x) (*(uintptr_t *)p = (x), p += sizeof(uintptr_t)) -#define DUV(x) (ctx->p = p, gdbjit_uleb128(ctx, (x)), p = ctx->p) -#define DSV(x) (ctx->p = p, gdbjit_sleb128(ctx, (x)), p = ctx->p) -#define DSTR(str) (ctx->p = p, gdbjit_strz(ctx, (str)), p = ctx->p) -#define DALIGNNOP(s) while ((uintptr_t)p & ((s)-1)) *p++ = DW_CFA_nop -#define DSECT(name, stmt) \ - { uint32_t *szp_##name = (uint32_t *)p; p += 4; stmt \ - *szp_##name = (uint32_t)((p-(uint8_t *)szp_##name)-4); } \ - -/* Initialize ELF section headers. */ -static void LJ_FASTCALL gdbjit_secthdr(GDBJITctx *ctx) -{ - ELFsectheader *sect; - - *ctx->p++ = '\0'; /* Empty string at start of string table. */ - -#define SECTDEF(id, tp, al) \ - sect = &ctx->obj.sect[GDBJIT_SECT_##id]; \ - sect->name = gdbjit_strz(ctx, "." #id); \ - sect->type = ELFSECT_TYPE_##tp; \ - sect->align = (al) - - SECTDEF(text, NOBITS, 16); - sect->flags = ELFSECT_FLAGS_ALLOC|ELFSECT_FLAGS_EXEC; - sect->addr = ctx->mcaddr; - sect->ofs = 0; - sect->size = ctx->szmcode; - - SECTDEF(eh_frame, PROGBITS, sizeof(uintptr_t)); - sect->flags = ELFSECT_FLAGS_ALLOC; - - SECTDEF(shstrtab, STRTAB, 1); - SECTDEF(strtab, STRTAB, 1); - - SECTDEF(symtab, SYMTAB, sizeof(uintptr_t)); - sect->ofs = offsetof(GDBJITobj, sym); - sect->size = sizeof(ctx->obj.sym); - sect->link = GDBJIT_SECT_strtab; - sect->entsize = sizeof(ELFsymbol); - sect->info = GDBJIT_SYM_FUNC; - - SECTDEF(debug_info, PROGBITS, 1); - SECTDEF(debug_abbrev, PROGBITS, 1); - SECTDEF(debug_line, PROGBITS, 1); - -#undef SECTDEF -} - -/* Initialize symbol table. */ -static void LJ_FASTCALL gdbjit_symtab(GDBJITctx *ctx) -{ - ELFsymbol *sym; - - *ctx->p++ = '\0'; /* Empty string at start of string table. */ - - sym = &ctx->obj.sym[GDBJIT_SYM_FILE]; - sym->name = gdbjit_strz(ctx, "JIT mcode"); - sym->sectidx = ELFSECT_IDX_ABS; - sym->info = ELFSYM_TYPE_FILE|ELFSYM_BIND_LOCAL; - - sym = &ctx->obj.sym[GDBJIT_SYM_FUNC]; - sym->name = gdbjit_strz(ctx, "TRACE_"); ctx->p--; - gdbjit_catnum(ctx, ctx->T->traceno); *ctx->p++ = '\0'; - sym->sectidx = GDBJIT_SECT_text; - sym->value = 0; - sym->size = ctx->szmcode; - sym->info = ELFSYM_TYPE_FUNC|ELFSYM_BIND_GLOBAL; -} - -/* Initialize .eh_frame section. */ -static void LJ_FASTCALL gdbjit_ehframe(GDBJITctx *ctx) -{ - uint8_t *p = ctx->p; - uint8_t *framep = p; - - /* Emit DWARF EH CIE. */ - DSECT(CIE, - DU32(0); /* Offset to CIE itself. */ - DB(DW_CIE_VERSION); - DSTR("zR"); /* Augmentation. */ - DUV(1); /* Code alignment factor. */ - DSV(-(int32_t)sizeof(uintptr_t)); /* Data alignment factor. */ - DB(DW_REG_RA); /* Return address register. */ - DB(1); DB(DW_EH_PE_textrel|DW_EH_PE_udata4); /* Augmentation data. */ - DB(DW_CFA_def_cfa); DUV(DW_REG_SP); DUV(sizeof(uintptr_t)); -#if LJ_TARGET_PPC - DB(DW_CFA_offset_extended_sf); DB(DW_REG_RA); DSV(-1); -#else - DB(DW_CFA_offset|DW_REG_RA); DUV(1); -#endif - DALIGNNOP(sizeof(uintptr_t)); - ) - - /* Emit DWARF EH FDE. */ - DSECT(FDE, - DU32((uint32_t)(p-framep)); /* Offset to CIE. */ - DU32(0); /* Machine code offset relative to .text. */ - DU32(ctx->szmcode); /* Machine code length. */ - DB(0); /* Augmentation data. */ - /* Registers saved in CFRAME. */ -#if LJ_TARGET_X86 - DB(DW_CFA_offset|DW_REG_BP); DUV(2); - DB(DW_CFA_offset|DW_REG_DI); DUV(3); - DB(DW_CFA_offset|DW_REG_SI); DUV(4); - DB(DW_CFA_offset|DW_REG_BX); DUV(5); -#elif LJ_TARGET_X64 - DB(DW_CFA_offset|DW_REG_BP); DUV(2); - DB(DW_CFA_offset|DW_REG_BX); DUV(3); - DB(DW_CFA_offset|DW_REG_15); DUV(4); - DB(DW_CFA_offset|DW_REG_14); DUV(5); - /* Extra registers saved for JIT-compiled code. */ - DB(DW_CFA_offset|DW_REG_13); DUV(9); - DB(DW_CFA_offset|DW_REG_12); DUV(10); -#elif LJ_TARGET_ARM - { - int i; - for (i = 11; i >= 4; i--) { DB(DW_CFA_offset|i); DUV(2+(11-i)); } - } -#elif LJ_TARGET_PPC - { - int i; - DB(DW_CFA_offset_extended); DB(DW_REG_CR); DUV(55); - for (i = 14; i <= 31; i++) { - DB(DW_CFA_offset|i); DUV(37+(31-i)); - DB(DW_CFA_offset|32|i); DUV(2+2*(31-i)); - } - } -#elif LJ_TARGET_MIPS - { - int i; - DB(DW_CFA_offset|30); DUV(2); - for (i = 23; i >= 16; i--) { DB(DW_CFA_offset|i); DUV(26-i); } - for (i = 30; i >= 20; i -= 2) { DB(DW_CFA_offset|32|i); DUV(42-i); } - } -#else -#error "Unsupported target architecture" -#endif - if (ctx->spadjp != ctx->spadj) { /* Parent/interpreter stack frame size. */ - DB(DW_CFA_def_cfa_offset); DUV(ctx->spadjp); - DB(DW_CFA_advance_loc|1); /* Only an approximation. */ - } - DB(DW_CFA_def_cfa_offset); DUV(ctx->spadj); /* Trace stack frame size. */ - DALIGNNOP(sizeof(uintptr_t)); - ) - - ctx->p = p; -} - -/* Initialize .debug_info section. */ -static void LJ_FASTCALL gdbjit_debuginfo(GDBJITctx *ctx) -{ - uint8_t *p = ctx->p; - - DSECT(info, - DU16(2); /* DWARF version. */ - DU32(0); /* Abbrev offset. */ - DB(sizeof(uintptr_t)); /* Pointer size. */ - - DUV(1); /* Abbrev #1: DW_TAG_compile_unit. */ - DSTR(ctx->filename); /* DW_AT_name. */ - DADDR(ctx->mcaddr); /* DW_AT_low_pc. */ - DADDR(ctx->mcaddr + ctx->szmcode); /* DW_AT_high_pc. */ - DU32(0); /* DW_AT_stmt_list. */ - ) - - ctx->p = p; -} - -/* Initialize .debug_abbrev section. */ -static void LJ_FASTCALL gdbjit_debugabbrev(GDBJITctx *ctx) -{ - uint8_t *p = ctx->p; - - /* Abbrev #1: DW_TAG_compile_unit. */ - DUV(1); DUV(DW_TAG_compile_unit); - DB(DW_children_no); - DUV(DW_AT_name); DUV(DW_FORM_string); - DUV(DW_AT_low_pc); DUV(DW_FORM_addr); - DUV(DW_AT_high_pc); DUV(DW_FORM_addr); - DUV(DW_AT_stmt_list); DUV(DW_FORM_data4); - DB(0); DB(0); - - ctx->p = p; -} - -#define DLNE(op, s) (DB(DW_LNS_extended_op), DUV(1+(s)), DB((op))) - -/* Initialize .debug_line section. */ -static void LJ_FASTCALL gdbjit_debugline(GDBJITctx *ctx) -{ - uint8_t *p = ctx->p; - - DSECT(line, - DU16(2); /* DWARF version. */ - DSECT(header, - DB(1); /* Minimum instruction length. */ - DB(1); /* is_stmt. */ - DI8(0); /* Line base for special opcodes. */ - DB(2); /* Line range for special opcodes. */ - DB(3+1); /* Opcode base at DW_LNS_advance_line+1. */ - DB(0); DB(1); DB(1); /* Standard opcode lengths. */ - /* Directory table. */ - DB(0); - /* File name table. */ - DSTR(ctx->filename); DUV(0); DUV(0); DUV(0); - DB(0); - ) - - DLNE(DW_LNE_set_address, sizeof(uintptr_t)); DADDR(ctx->mcaddr); - if (ctx->lineno) { - DB(DW_LNS_advance_line); DSV(ctx->lineno-1); - } - DB(DW_LNS_copy); - DB(DW_LNS_advance_pc); DUV(ctx->szmcode); - DLNE(DW_LNE_end_sequence, 0); - ) - - ctx->p = p; -} - -#undef DLNE - -/* Undef shortcuts. */ -#undef DB -#undef DI8 -#undef DU16 -#undef DU32 -#undef DADDR -#undef DUV -#undef DSV -#undef DSTR -#undef DALIGNNOP -#undef DSECT - -/* Type of a section initializer callback. */ -typedef void (LJ_FASTCALL *GDBJITinitf)(GDBJITctx *ctx); - -/* Call section initializer and set the section offset and size. */ -static void gdbjit_initsect(GDBJITctx *ctx, int sect, GDBJITinitf initf) -{ - ctx->startp = ctx->p; - ctx->obj.sect[sect].ofs = (uintptr_t)((char *)ctx->p - (char *)&ctx->obj); - initf(ctx); - ctx->obj.sect[sect].size = (uintptr_t)(ctx->p - ctx->startp); -} - -#define SECTALIGN(p, a) \ - ((p) = (uint8_t *)(((uintptr_t)(p) + ((a)-1)) & ~(uintptr_t)((a)-1))) - -/* Build in-memory ELF object. */ -static void gdbjit_buildobj(GDBJITctx *ctx) -{ - GDBJITobj *obj = &ctx->obj; - /* Fill in ELF header and clear structures. */ - memcpy(&obj->hdr, &elfhdr_template, sizeof(ELFheader)); - memset(&obj->sect, 0, sizeof(ELFsectheader)*GDBJIT_SECT__MAX); - memset(&obj->sym, 0, sizeof(ELFsymbol)*GDBJIT_SYM__MAX); - /* Initialize sections. */ - ctx->p = obj->space; - gdbjit_initsect(ctx, GDBJIT_SECT_shstrtab, gdbjit_secthdr); - gdbjit_initsect(ctx, GDBJIT_SECT_strtab, gdbjit_symtab); - gdbjit_initsect(ctx, GDBJIT_SECT_debug_info, gdbjit_debuginfo); - gdbjit_initsect(ctx, GDBJIT_SECT_debug_abbrev, gdbjit_debugabbrev); - gdbjit_initsect(ctx, GDBJIT_SECT_debug_line, gdbjit_debugline); - SECTALIGN(ctx->p, sizeof(uintptr_t)); - gdbjit_initsect(ctx, GDBJIT_SECT_eh_frame, gdbjit_ehframe); - ctx->objsize = (size_t)((char *)ctx->p - (char *)obj); - lua_assert(ctx->objsize < sizeof(GDBJITobj)); -} - -#undef SECTALIGN - -/* -- Interface to GDB JIT API -------------------------------------------- */ - -/* Add new entry to GDB JIT symbol chain. */ -static void gdbjit_newentry(lua_State *L, GDBJITctx *ctx) -{ - /* Allocate memory for GDB JIT entry and ELF object. */ - MSize sz = (MSize)(sizeof(GDBJITentryobj) - sizeof(GDBJITobj) + ctx->objsize); - GDBJITentryobj *eo = lj_mem_newt(L, sz, GDBJITentryobj); - memcpy(&eo->obj, &ctx->obj, ctx->objsize); /* Copy ELF object. */ - eo->sz = sz; - ctx->T->gdbjit_entry = (void *)eo; - /* Link new entry to chain and register it. */ - eo->entry.prev_entry = NULL; - eo->entry.next_entry = __jit_debug_descriptor.first_entry; - if (eo->entry.next_entry) - eo->entry.next_entry->prev_entry = &eo->entry; - eo->entry.symfile_addr = (const char *)&eo->obj; - eo->entry.symfile_size = ctx->objsize; - __jit_debug_descriptor.first_entry = &eo->entry; - __jit_debug_descriptor.relevant_entry = &eo->entry; - __jit_debug_descriptor.action_flag = GDBJIT_REGISTER; - __jit_debug_register_code(); -} - -/* Add debug info for newly compiled trace and notify GDB. */ -void lj_gdbjit_addtrace(jit_State *J, GCtrace *T) -{ - GDBJITctx ctx; - GCproto *pt = &gcref(T->startpt)->pt; - TraceNo parent = T->ir[REF_BASE].op1; - const BCIns *startpc = mref(T->startpc, const BCIns); - ctx.T = T; - ctx.mcaddr = (uintptr_t)T->mcode; - ctx.szmcode = T->szmcode; - ctx.spadjp = CFRAME_SIZE_JIT + - (MSize)(parent ? traceref(J, parent)->spadjust : 0); - ctx.spadj = CFRAME_SIZE_JIT + T->spadjust; - lua_assert(startpc >= proto_bc(pt) && startpc < proto_bc(pt) + pt->sizebc); - ctx.lineno = lj_debug_line(pt, proto_bcpos(pt, startpc)); - ctx.filename = proto_chunknamestr(pt); - if (*ctx.filename == '@' || *ctx.filename == '=') - ctx.filename++; - else - ctx.filename = "(string)"; - gdbjit_buildobj(&ctx); - gdbjit_newentry(J->L, &ctx); -} - -/* Delete debug info for trace and notify GDB. */ -void lj_gdbjit_deltrace(jit_State *J, GCtrace *T) -{ - GDBJITentryobj *eo = (GDBJITentryobj *)T->gdbjit_entry; - if (eo) { - if (eo->entry.prev_entry) - eo->entry.prev_entry->next_entry = eo->entry.next_entry; - else - __jit_debug_descriptor.first_entry = eo->entry.next_entry; - if (eo->entry.next_entry) - eo->entry.next_entry->prev_entry = eo->entry.prev_entry; - __jit_debug_descriptor.relevant_entry = &eo->entry; - __jit_debug_descriptor.action_flag = GDBJIT_UNREGISTER; - __jit_debug_register_code(); - lj_mem_free(J2G(J), eo, eo->sz); - } -} - -#endif -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_gdbjit.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_gdbjit.h deleted file mode 100644 index 9ae504fc5..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_gdbjit.h +++ /dev/null @@ -1,22 +0,0 @@ -/* -** Client for the GDB JIT API. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_GDBJIT_H -#define _LJ_GDBJIT_H - -#include "lj_obj.h" -#include "lj_jit.h" - -#if LJ_HASJIT && defined(LUAJIT_USE_GDBJIT) - -LJ_FUNC void lj_gdbjit_addtrace(jit_State *J, GCtrace *T); -LJ_FUNC void lj_gdbjit_deltrace(jit_State *J, GCtrace *T); - -#else -#define lj_gdbjit_addtrace(J, T) UNUSED(T) -#define lj_gdbjit_deltrace(J, T) UNUSED(T) -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ir.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_ir.c deleted file mode 100644 index b2170a10e..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ir.c +++ /dev/null @@ -1,501 +0,0 @@ -/* -** SSA IR (Intermediate Representation) emitter. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_ir_c -#define LUA_CORE - -/* For pointers to libc/libm functions. */ -#include -#include - -#include "lj_obj.h" - -#if LJ_HASJIT - -#include "lj_gc.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_ir.h" -#include "lj_jit.h" -#include "lj_ircall.h" -#include "lj_iropt.h" -#include "lj_trace.h" -#if LJ_HASFFI -#include "lj_ctype.h" -#include "lj_cdata.h" -#include "lj_carith.h" -#endif -#include "lj_vm.h" -#include "lj_strscan.h" -#include "lj_lib.h" - -/* Some local macros to save typing. Undef'd at the end. */ -#define IR(ref) (&J->cur.ir[(ref)]) -#define fins (&J->fold.ins) - -/* Pass IR on to next optimization in chain (FOLD). */ -#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) - -/* -- IR tables ----------------------------------------------------------- */ - -/* IR instruction modes. */ -LJ_DATADEF const uint8_t lj_ir_mode[IR__MAX+1] = { -IRDEF(IRMODE) - 0 -}; - -/* IR type sizes. */ -LJ_DATADEF const uint8_t lj_ir_type_size[IRT__MAX+1] = { -#define IRTSIZE(name, size) size, -IRTDEF(IRTSIZE) -#undef IRTSIZE - 0 -}; - -/* C call info for CALL* instructions. */ -LJ_DATADEF const CCallInfo lj_ir_callinfo[] = { -#define IRCALLCI(cond, name, nargs, kind, type, flags) \ - { (ASMFunction)IRCALLCOND_##cond(name), \ - (nargs)|(CCI_CALL_##kind)|(IRT_##type<irbuf + J->irbotlim; - MSize szins = J->irtoplim - J->irbotlim; - if (szins) { - baseir = (IRIns *)lj_mem_realloc(J->L, baseir, szins*sizeof(IRIns), - 2*szins*sizeof(IRIns)); - J->irtoplim = J->irbotlim + 2*szins; - } else { - baseir = (IRIns *)lj_mem_realloc(J->L, NULL, 0, LJ_MIN_IRSZ*sizeof(IRIns)); - J->irbotlim = REF_BASE - LJ_MIN_IRSZ/4; - J->irtoplim = J->irbotlim + LJ_MIN_IRSZ; - } - J->cur.ir = J->irbuf = baseir - J->irbotlim; -} - -/* Grow IR buffer at the bottom or shift it up. */ -static void lj_ir_growbot(jit_State *J) -{ - IRIns *baseir = J->irbuf + J->irbotlim; - MSize szins = J->irtoplim - J->irbotlim; - lua_assert(szins != 0); - lua_assert(J->cur.nk == J->irbotlim); - if (J->cur.nins + (szins >> 1) < J->irtoplim) { - /* More than half of the buffer is free on top: shift up by a quarter. */ - MSize ofs = szins >> 2; - memmove(baseir + ofs, baseir, (J->cur.nins - J->irbotlim)*sizeof(IRIns)); - J->irbotlim -= ofs; - J->irtoplim -= ofs; - J->cur.ir = J->irbuf = baseir - J->irbotlim; - } else { - /* Double the buffer size, but split the growth amongst top/bottom. */ - IRIns *newbase = lj_mem_newt(J->L, 2*szins*sizeof(IRIns), IRIns); - MSize ofs = szins >= 256 ? 128 : (szins >> 1); /* Limit bottom growth. */ - memcpy(newbase + ofs, baseir, (J->cur.nins - J->irbotlim)*sizeof(IRIns)); - lj_mem_free(G(J->L), baseir, szins*sizeof(IRIns)); - J->irbotlim -= ofs; - J->irtoplim = J->irbotlim + 2*szins; - J->cur.ir = J->irbuf = newbase - J->irbotlim; - } -} - -/* Emit IR without any optimizations. */ -TRef LJ_FASTCALL lj_ir_emit(jit_State *J) -{ - IRRef ref = lj_ir_nextins(J); - IRIns *ir = IR(ref); - IROp op = fins->o; - ir->prev = J->chain[op]; - J->chain[op] = (IRRef1)ref; - ir->o = op; - ir->op1 = fins->op1; - ir->op2 = fins->op2; - J->guardemit.irt |= fins->t.irt; - return TREF(ref, irt_t((ir->t = fins->t))); -} - -/* Emit call to a C function. */ -TRef lj_ir_call(jit_State *J, IRCallID id, ...) -{ - const CCallInfo *ci = &lj_ir_callinfo[id]; - uint32_t n = CCI_NARGS(ci); - TRef tr = TREF_NIL; - va_list argp; - va_start(argp, id); - if ((ci->flags & CCI_L)) n--; - if (n > 0) - tr = va_arg(argp, IRRef); - while (n-- > 1) - tr = emitir(IRT(IR_CARG, IRT_NIL), tr, va_arg(argp, IRRef)); - va_end(argp); - if (CCI_OP(ci) == IR_CALLS) - J->needsnap = 1; /* Need snapshot after call with side effect. */ - return emitir(CCI_OPTYPE(ci), tr, id); -} - -/* -- Interning of constants ---------------------------------------------- */ - -/* -** IR instructions for constants are kept between J->cur.nk >= ref < REF_BIAS. -** They are chained like all other instructions, but grow downwards. -** The are interned (like strings in the VM) to facilitate reference -** comparisons. The same constant must get the same reference. -*/ - -/* Get ref of next IR constant and optionally grow IR. -** Note: this may invalidate all IRIns *! -*/ -static LJ_AINLINE IRRef ir_nextk(jit_State *J) -{ - IRRef ref = J->cur.nk; - if (LJ_UNLIKELY(ref <= J->irbotlim)) lj_ir_growbot(J); - J->cur.nk = --ref; - return ref; -} - -/* Intern int32_t constant. */ -TRef LJ_FASTCALL lj_ir_kint(jit_State *J, int32_t k) -{ - IRIns *ir, *cir = J->cur.ir; - IRRef ref; - for (ref = J->chain[IR_KINT]; ref; ref = cir[ref].prev) - if (cir[ref].i == k) - goto found; - ref = ir_nextk(J); - ir = IR(ref); - ir->i = k; - ir->t.irt = IRT_INT; - ir->o = IR_KINT; - ir->prev = J->chain[IR_KINT]; - J->chain[IR_KINT] = (IRRef1)ref; -found: - return TREF(ref, IRT_INT); -} - -/* The MRef inside the KNUM/KINT64 IR instructions holds the address of the -** 64 bit constant. The constants themselves are stored in a chained array -** and shared across traces. -** -** Rationale for choosing this data structure: -** - The address of the constants is embedded in the generated machine code -** and must never move. A resizable array or hash table wouldn't work. -** - Most apps need very few non-32 bit integer constants (less than a dozen). -** - Linear search is hard to beat in terms of speed and low complexity. -*/ -typedef struct K64Array { - MRef next; /* Pointer to next list. */ - MSize numk; /* Number of used elements in this array. */ - TValue k[LJ_MIN_K64SZ]; /* Array of constants. */ -} K64Array; - -/* Free all chained arrays. */ -void lj_ir_k64_freeall(jit_State *J) -{ - K64Array *k; - for (k = mref(J->k64, K64Array); k; ) { - K64Array *next = mref(k->next, K64Array); - lj_mem_free(J2G(J), k, sizeof(K64Array)); - k = next; - } -} - -/* Find 64 bit constant in chained array or add it. */ -cTValue *lj_ir_k64_find(jit_State *J, uint64_t u64) -{ - K64Array *k, *kp = NULL; - TValue *ntv; - MSize idx; - /* Search for the constant in the whole chain of arrays. */ - for (k = mref(J->k64, K64Array); k; k = mref(k->next, K64Array)) { - kp = k; /* Remember previous element in list. */ - for (idx = 0; idx < k->numk; idx++) { /* Search one array. */ - TValue *tv = &k->k[idx]; - if (tv->u64 == u64) /* Needed for +-0/NaN/absmask. */ - return tv; - } - } - /* Constant was not found, need to add it. */ - if (!(kp && kp->numk < LJ_MIN_K64SZ)) { /* Allocate a new array. */ - K64Array *kn = lj_mem_newt(J->L, sizeof(K64Array), K64Array); - setmref(kn->next, NULL); - kn->numk = 0; - if (kp) - setmref(kp->next, kn); /* Chain to the end of the list. */ - else - setmref(J->k64, kn); /* Link first array. */ - kp = kn; - } - ntv = &kp->k[kp->numk++]; /* Add to current array. */ - ntv->u64 = u64; - return ntv; -} - -/* Intern 64 bit constant, given by its address. */ -TRef lj_ir_k64(jit_State *J, IROp op, cTValue *tv) -{ - IRIns *ir, *cir = J->cur.ir; - IRRef ref; - IRType t = op == IR_KNUM ? IRT_NUM : IRT_I64; - for (ref = J->chain[op]; ref; ref = cir[ref].prev) - if (ir_k64(&cir[ref]) == tv) - goto found; - ref = ir_nextk(J); - ir = IR(ref); - lua_assert(checkptr32(tv)); - setmref(ir->ptr, tv); - ir->t.irt = t; - ir->o = op; - ir->prev = J->chain[op]; - J->chain[op] = (IRRef1)ref; -found: - return TREF(ref, t); -} - -/* Intern FP constant, given by its 64 bit pattern. */ -TRef lj_ir_knum_u64(jit_State *J, uint64_t u64) -{ - return lj_ir_k64(J, IR_KNUM, lj_ir_k64_find(J, u64)); -} - -/* Intern 64 bit integer constant. */ -TRef lj_ir_kint64(jit_State *J, uint64_t u64) -{ - return lj_ir_k64(J, IR_KINT64, lj_ir_k64_find(J, u64)); -} - -/* Check whether a number is int and return it. -0 is NOT considered an int. */ -static int numistrueint(lua_Number n, int32_t *kp) -{ - int32_t k = lj_num2int(n); - if (n == (lua_Number)k) { - if (kp) *kp = k; - if (k == 0) { /* Special check for -0. */ - TValue tv; - setnumV(&tv, n); - if (tv.u32.hi != 0) - return 0; - } - return 1; - } - return 0; -} - -/* Intern number as int32_t constant if possible, otherwise as FP constant. */ -TRef lj_ir_knumint(jit_State *J, lua_Number n) -{ - int32_t k; - if (numistrueint(n, &k)) - return lj_ir_kint(J, k); - else - return lj_ir_knum(J, n); -} - -/* Intern GC object "constant". */ -TRef lj_ir_kgc(jit_State *J, GCobj *o, IRType t) -{ - IRIns *ir, *cir = J->cur.ir; - IRRef ref; - lua_assert(!isdead(J2G(J), o)); - for (ref = J->chain[IR_KGC]; ref; ref = cir[ref].prev) - if (ir_kgc(&cir[ref]) == o) - goto found; - ref = ir_nextk(J); - ir = IR(ref); - /* NOBARRIER: Current trace is a GC root. */ - setgcref(ir->gcr, o); - ir->t.irt = (uint8_t)t; - ir->o = IR_KGC; - ir->prev = J->chain[IR_KGC]; - J->chain[IR_KGC] = (IRRef1)ref; -found: - return TREF(ref, t); -} - -/* Intern 32 bit pointer constant. */ -TRef lj_ir_kptr_(jit_State *J, IROp op, void *ptr) -{ - IRIns *ir, *cir = J->cur.ir; - IRRef ref; - lua_assert((void *)(intptr_t)i32ptr(ptr) == ptr); - for (ref = J->chain[op]; ref; ref = cir[ref].prev) - if (mref(cir[ref].ptr, void) == ptr) - goto found; - ref = ir_nextk(J); - ir = IR(ref); - setmref(ir->ptr, ptr); - ir->t.irt = IRT_P32; - ir->o = op; - ir->prev = J->chain[op]; - J->chain[op] = (IRRef1)ref; -found: - return TREF(ref, IRT_P32); -} - -/* Intern typed NULL constant. */ -TRef lj_ir_knull(jit_State *J, IRType t) -{ - IRIns *ir, *cir = J->cur.ir; - IRRef ref; - for (ref = J->chain[IR_KNULL]; ref; ref = cir[ref].prev) - if (irt_t(cir[ref].t) == t) - goto found; - ref = ir_nextk(J); - ir = IR(ref); - ir->i = 0; - ir->t.irt = (uint8_t)t; - ir->o = IR_KNULL; - ir->prev = J->chain[IR_KNULL]; - J->chain[IR_KNULL] = (IRRef1)ref; -found: - return TREF(ref, t); -} - -/* Intern key slot. */ -TRef lj_ir_kslot(jit_State *J, TRef key, IRRef slot) -{ - IRIns *ir, *cir = J->cur.ir; - IRRef2 op12 = IRREF2((IRRef1)key, (IRRef1)slot); - IRRef ref; - /* Const part is not touched by CSE/DCE, so 0-65535 is ok for IRMlit here. */ - lua_assert(tref_isk(key) && slot == (IRRef)(IRRef1)slot); - for (ref = J->chain[IR_KSLOT]; ref; ref = cir[ref].prev) - if (cir[ref].op12 == op12) - goto found; - ref = ir_nextk(J); - ir = IR(ref); - ir->op12 = op12; - ir->t.irt = IRT_P32; - ir->o = IR_KSLOT; - ir->prev = J->chain[IR_KSLOT]; - J->chain[IR_KSLOT] = (IRRef1)ref; -found: - return TREF(ref, IRT_P32); -} - -/* -- Access to IR constants ---------------------------------------------- */ - -/* Copy value of IR constant. */ -void lj_ir_kvalue(lua_State *L, TValue *tv, const IRIns *ir) -{ - UNUSED(L); - lua_assert(ir->o != IR_KSLOT); /* Common mistake. */ - switch (ir->o) { - case IR_KPRI: setitype(tv, irt_toitype(ir->t)); break; - case IR_KINT: setintV(tv, ir->i); break; - case IR_KGC: setgcV(L, tv, ir_kgc(ir), irt_toitype(ir->t)); break; - case IR_KPTR: case IR_KKPTR: case IR_KNULL: - setlightudV(tv, mref(ir->ptr, void)); - break; - case IR_KNUM: setnumV(tv, ir_knum(ir)->n); break; -#if LJ_HASFFI - case IR_KINT64: { - GCcdata *cd = lj_cdata_new_(L, CTID_INT64, 8); - *(uint64_t *)cdataptr(cd) = ir_kint64(ir)->u64; - setcdataV(L, tv, cd); - break; - } -#endif - default: lua_assert(0); break; - } -} - -/* -- Convert IR operand types -------------------------------------------- */ - -/* Convert from string to number. */ -TRef LJ_FASTCALL lj_ir_tonumber(jit_State *J, TRef tr) -{ - if (!tref_isnumber(tr)) { - if (tref_isstr(tr)) - tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); - else - lj_trace_err(J, LJ_TRERR_BADTYPE); - } - return tr; -} - -/* Convert from integer or string to number. */ -TRef LJ_FASTCALL lj_ir_tonum(jit_State *J, TRef tr) -{ - if (!tref_isnum(tr)) { - if (tref_isinteger(tr)) - tr = emitir(IRTN(IR_CONV), tr, IRCONV_NUM_INT); - else if (tref_isstr(tr)) - tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); - else - lj_trace_err(J, LJ_TRERR_BADTYPE); - } - return tr; -} - -/* Convert from integer or number to string. */ -TRef LJ_FASTCALL lj_ir_tostr(jit_State *J, TRef tr) -{ - if (!tref_isstr(tr)) { - if (!tref_isnumber(tr)) - lj_trace_err(J, LJ_TRERR_BADTYPE); - tr = emitir(IRT(IR_TOSTR, IRT_STR), tr, 0); - } - return tr; -} - -/* -- Miscellaneous IR ops ------------------------------------------------ */ - -/* Evaluate numeric comparison. */ -int lj_ir_numcmp(lua_Number a, lua_Number b, IROp op) -{ - switch (op) { - case IR_EQ: return (a == b); - case IR_NE: return (a != b); - case IR_LT: return (a < b); - case IR_GE: return (a >= b); - case IR_LE: return (a <= b); - case IR_GT: return (a > b); - case IR_ULT: return !(a >= b); - case IR_UGE: return !(a < b); - case IR_ULE: return !(a > b); - case IR_UGT: return !(a <= b); - default: lua_assert(0); return 0; - } -} - -/* Evaluate string comparison. */ -int lj_ir_strcmp(GCstr *a, GCstr *b, IROp op) -{ - int res = lj_str_cmp(a, b); - switch (op) { - case IR_LT: return (res < 0); - case IR_GE: return (res >= 0); - case IR_LE: return (res <= 0); - case IR_GT: return (res > 0); - default: lua_assert(0); return 0; - } -} - -/* Rollback IR to previous state. */ -void lj_ir_rollback(jit_State *J, IRRef ref) -{ - IRRef nins = J->cur.nins; - while (nins > ref) { - IRIns *ir; - nins--; - ir = IR(nins); - J->chain[ir->o] = ir->prev; - } - J->cur.nins = nins; -} - -#undef IR -#undef fins -#undef emitir - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ir.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_ir.h deleted file mode 100644 index 80763d88e..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ir.h +++ /dev/null @@ -1,551 +0,0 @@ -/* -** SSA IR (Intermediate Representation) format. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_IR_H -#define _LJ_IR_H - -#include "lj_obj.h" - -/* -- IR instructions ----------------------------------------------------- */ - -/* IR instruction definition. Order matters, see below. ORDER IR */ -#define IRDEF(_) \ - /* Guarded assertions. */ \ - /* Must be properly aligned to flip opposites (^1) and (un)ordered (^4). */ \ - _(LT, N , ref, ref) \ - _(GE, N , ref, ref) \ - _(LE, N , ref, ref) \ - _(GT, N , ref, ref) \ - \ - _(ULT, N , ref, ref) \ - _(UGE, N , ref, ref) \ - _(ULE, N , ref, ref) \ - _(UGT, N , ref, ref) \ - \ - _(EQ, C , ref, ref) \ - _(NE, C , ref, ref) \ - \ - _(ABC, N , ref, ref) \ - _(RETF, S , ref, ref) \ - \ - /* Miscellaneous ops. */ \ - _(NOP, N , ___, ___) \ - _(BASE, N , lit, lit) \ - _(PVAL, N , lit, ___) \ - _(GCSTEP, S , ___, ___) \ - _(HIOP, S , ref, ref) \ - _(LOOP, S , ___, ___) \ - _(USE, S , ref, ___) \ - _(PHI, S , ref, ref) \ - _(RENAME, S , ref, lit) \ - \ - /* Constants. */ \ - _(KPRI, N , ___, ___) \ - _(KINT, N , cst, ___) \ - _(KGC, N , cst, ___) \ - _(KPTR, N , cst, ___) \ - _(KKPTR, N , cst, ___) \ - _(KNULL, N , cst, ___) \ - _(KNUM, N , cst, ___) \ - _(KINT64, N , cst, ___) \ - _(KSLOT, N , ref, lit) \ - \ - /* Bit ops. */ \ - _(BNOT, N , ref, ___) \ - _(BSWAP, N , ref, ___) \ - _(BAND, C , ref, ref) \ - _(BOR, C , ref, ref) \ - _(BXOR, C , ref, ref) \ - _(BSHL, N , ref, ref) \ - _(BSHR, N , ref, ref) \ - _(BSAR, N , ref, ref) \ - _(BROL, N , ref, ref) \ - _(BROR, N , ref, ref) \ - \ - /* Arithmetic ops. ORDER ARITH */ \ - _(ADD, C , ref, ref) \ - _(SUB, N , ref, ref) \ - _(MUL, C , ref, ref) \ - _(DIV, N , ref, ref) \ - _(MOD, N , ref, ref) \ - _(POW, N , ref, ref) \ - _(NEG, N , ref, ref) \ - \ - _(ABS, N , ref, ref) \ - _(ATAN2, N , ref, ref) \ - _(LDEXP, N , ref, ref) \ - _(MIN, C , ref, ref) \ - _(MAX, C , ref, ref) \ - _(FPMATH, N , ref, lit) \ - \ - /* Overflow-checking arithmetic ops. */ \ - _(ADDOV, CW, ref, ref) \ - _(SUBOV, NW, ref, ref) \ - _(MULOV, CW, ref, ref) \ - \ - /* Memory ops. A = array, H = hash, U = upvalue, F = field, S = stack. */ \ - \ - /* Memory references. */ \ - _(AREF, R , ref, ref) \ - _(HREFK, R , ref, ref) \ - _(HREF, L , ref, ref) \ - _(NEWREF, S , ref, ref) \ - _(UREFO, LW, ref, lit) \ - _(UREFC, LW, ref, lit) \ - _(FREF, R , ref, lit) \ - _(STRREF, N , ref, ref) \ - \ - /* Loads and Stores. These must be in the same order. */ \ - _(ALOAD, L , ref, ___) \ - _(HLOAD, L , ref, ___) \ - _(ULOAD, L , ref, ___) \ - _(FLOAD, L , ref, lit) \ - _(XLOAD, L , ref, lit) \ - _(SLOAD, L , lit, lit) \ - _(VLOAD, L , ref, ___) \ - \ - _(ASTORE, S , ref, ref) \ - _(HSTORE, S , ref, ref) \ - _(USTORE, S , ref, ref) \ - _(FSTORE, S , ref, ref) \ - _(XSTORE, S , ref, ref) \ - \ - /* Allocations. */ \ - _(SNEW, N , ref, ref) /* CSE is ok, not marked as A. */ \ - _(XSNEW, A , ref, ref) \ - _(TNEW, AW, lit, lit) \ - _(TDUP, AW, ref, ___) \ - _(CNEW, AW, ref, ref) \ - _(CNEWI, NW, ref, ref) /* CSE is ok, not marked as A. */ \ - \ - /* Barriers. */ \ - _(TBAR, S , ref, ___) \ - _(OBAR, S , ref, ref) \ - _(XBAR, S , ___, ___) \ - \ - /* Type conversions. */ \ - _(CONV, NW, ref, lit) \ - _(TOBIT, N , ref, ref) \ - _(TOSTR, N , ref, ___) \ - _(STRTO, N , ref, ___) \ - \ - /* Calls. */ \ - _(CALLN, N , ref, lit) \ - _(CALLL, L , ref, lit) \ - _(CALLS, S , ref, lit) \ - _(CALLXS, S , ref, ref) \ - _(CARG, N , ref, ref) \ - \ - /* End of list. */ - -/* IR opcodes (max. 256). */ -typedef enum { -#define IRENUM(name, m, m1, m2) IR_##name, -IRDEF(IRENUM) -#undef IRENUM - IR__MAX -} IROp; - -/* Stored opcode. */ -typedef uint8_t IROp1; - -LJ_STATIC_ASSERT(((int)IR_EQ^1) == (int)IR_NE); -LJ_STATIC_ASSERT(((int)IR_LT^1) == (int)IR_GE); -LJ_STATIC_ASSERT(((int)IR_LE^1) == (int)IR_GT); -LJ_STATIC_ASSERT(((int)IR_LT^3) == (int)IR_GT); -LJ_STATIC_ASSERT(((int)IR_LT^4) == (int)IR_ULT); - -/* Delta between xLOAD and xSTORE. */ -#define IRDELTA_L2S ((int)IR_ASTORE - (int)IR_ALOAD) - -LJ_STATIC_ASSERT((int)IR_HLOAD + IRDELTA_L2S == (int)IR_HSTORE); -LJ_STATIC_ASSERT((int)IR_ULOAD + IRDELTA_L2S == (int)IR_USTORE); -LJ_STATIC_ASSERT((int)IR_FLOAD + IRDELTA_L2S == (int)IR_FSTORE); -LJ_STATIC_ASSERT((int)IR_XLOAD + IRDELTA_L2S == (int)IR_XSTORE); - -/* -- Named IR literals --------------------------------------------------- */ - -/* FPMATH sub-functions. ORDER FPM. */ -#define IRFPMDEF(_) \ - _(FLOOR) _(CEIL) _(TRUNC) /* Must be first and in this order. */ \ - _(SQRT) _(EXP) _(EXP2) _(LOG) _(LOG2) _(LOG10) \ - _(SIN) _(COS) _(TAN) \ - _(OTHER) - -typedef enum { -#define FPMENUM(name) IRFPM_##name, -IRFPMDEF(FPMENUM) -#undef FPMENUM - IRFPM__MAX -} IRFPMathOp; - -/* FLOAD fields. */ -#define IRFLDEF(_) \ - _(STR_LEN, offsetof(GCstr, len)) \ - _(FUNC_ENV, offsetof(GCfunc, l.env)) \ - _(FUNC_PC, offsetof(GCfunc, l.pc)) \ - _(TAB_META, offsetof(GCtab, metatable)) \ - _(TAB_ARRAY, offsetof(GCtab, array)) \ - _(TAB_NODE, offsetof(GCtab, node)) \ - _(TAB_ASIZE, offsetof(GCtab, asize)) \ - _(TAB_HMASK, offsetof(GCtab, hmask)) \ - _(TAB_NOMM, offsetof(GCtab, nomm)) \ - _(UDATA_META, offsetof(GCudata, metatable)) \ - _(UDATA_UDTYPE, offsetof(GCudata, udtype)) \ - _(UDATA_FILE, sizeof(GCudata)) \ - _(CDATA_CTYPEID, offsetof(GCcdata, ctypeid)) \ - _(CDATA_PTR, sizeof(GCcdata)) \ - _(CDATA_INT, sizeof(GCcdata)) \ - _(CDATA_INT64, sizeof(GCcdata)) \ - _(CDATA_INT64_4, sizeof(GCcdata) + 4) - -typedef enum { -#define FLENUM(name, ofs) IRFL_##name, -IRFLDEF(FLENUM) -#undef FLENUM - IRFL__MAX -} IRFieldID; - -/* SLOAD mode bits, stored in op2. */ -#define IRSLOAD_PARENT 0x01 /* Coalesce with parent trace. */ -#define IRSLOAD_FRAME 0x02 /* Load hiword of frame. */ -#define IRSLOAD_TYPECHECK 0x04 /* Needs type check. */ -#define IRSLOAD_CONVERT 0x08 /* Number to integer conversion. */ -#define IRSLOAD_READONLY 0x10 /* Read-only, omit slot store. */ -#define IRSLOAD_INHERIT 0x20 /* Inherited by exits/side traces. */ - -/* XLOAD mode, stored in op2. */ -#define IRXLOAD_READONLY 1 /* Load from read-only data. */ -#define IRXLOAD_VOLATILE 2 /* Load from volatile data. */ -#define IRXLOAD_UNALIGNED 4 /* Unaligned load. */ - -/* CONV mode, stored in op2. */ -#define IRCONV_SRCMASK 0x001f /* Source IRType. */ -#define IRCONV_DSTMASK 0x03e0 /* Dest. IRType (also in ir->t). */ -#define IRCONV_DSH 5 -#define IRCONV_NUM_INT ((IRT_NUM<>2)&3)) -#define irm_iscomm(m) ((m) & IRM_C) -#define irm_kind(m) ((m) & IRM_S) - -#define IRMODE(name, m, m1, m2) (((IRM##m1)|((IRM##m2)<<2)|(IRM_##m))^IRM_W), - -LJ_DATA const uint8_t lj_ir_mode[IR__MAX+1]; - -/* -- IR instruction types ------------------------------------------------ */ - -/* Map of itypes to non-negative numbers. ORDER LJ_T. -** LJ_TUPVAL/LJ_TTRACE never appear in a TValue. Use these itypes for -** IRT_P32 and IRT_P64, which never escape the IR. -** The various integers are only used in the IR and can only escape to -** a TValue after implicit or explicit conversion. Their types must be -** contiguous and next to IRT_NUM (see the typerange macros below). -*/ -#define IRTDEF(_) \ - _(NIL, 4) _(FALSE, 4) _(TRUE, 4) _(LIGHTUD, LJ_64 ? 8 : 4) _(STR, 4) \ - _(P32, 4) _(THREAD, 4) _(PROTO, 4) _(FUNC, 4) _(P64, 8) _(CDATA, 4) \ - _(TAB, 4) _(UDATA, 4) \ - _(FLOAT, 4) _(NUM, 8) _(I8, 1) _(U8, 1) _(I16, 2) _(U16, 2) \ - _(INT, 4) _(U32, 4) _(I64, 8) _(U64, 8) \ - _(SOFTFP, 4) /* There is room for 9 more types. */ - -/* IR result type and flags (8 bit). */ -typedef enum { -#define IRTENUM(name, size) IRT_##name, -IRTDEF(IRTENUM) -#undef IRTENUM - IRT__MAX, - - /* Native pointer type and the corresponding integer type. */ - IRT_PTR = LJ_64 ? IRT_P64 : IRT_P32, - IRT_INTP = LJ_64 ? IRT_I64 : IRT_INT, - IRT_UINTP = LJ_64 ? IRT_U64 : IRT_U32, - - /* Additional flags. */ - IRT_MARK = 0x20, /* Marker for misc. purposes. */ - IRT_ISPHI = 0x40, /* Instruction is left or right PHI operand. */ - IRT_GUARD = 0x80, /* Instruction is a guard. */ - - /* Masks. */ - IRT_TYPE = 0x1f, - IRT_T = 0xff -} IRType; - -#define irtype_ispri(irt) ((uint32_t)(irt) <= IRT_TRUE) - -/* Stored IRType. */ -typedef struct IRType1 { uint8_t irt; } IRType1; - -#define IRT(o, t) ((uint32_t)(((o)<<8) | (t))) -#define IRTI(o) (IRT((o), IRT_INT)) -#define IRTN(o) (IRT((o), IRT_NUM)) -#define IRTG(o, t) (IRT((o), IRT_GUARD|(t))) -#define IRTGI(o) (IRT((o), IRT_GUARD|IRT_INT)) - -#define irt_t(t) ((IRType)(t).irt) -#define irt_type(t) ((IRType)((t).irt & IRT_TYPE)) -#define irt_sametype(t1, t2) ((((t1).irt ^ (t2).irt) & IRT_TYPE) == 0) -#define irt_typerange(t, first, last) \ - ((uint32_t)((t).irt & IRT_TYPE) - (uint32_t)(first) <= (uint32_t)(last-first)) - -#define irt_isnil(t) (irt_type(t) == IRT_NIL) -#define irt_ispri(t) ((uint32_t)irt_type(t) <= IRT_TRUE) -#define irt_islightud(t) (irt_type(t) == IRT_LIGHTUD) -#define irt_isstr(t) (irt_type(t) == IRT_STR) -#define irt_istab(t) (irt_type(t) == IRT_TAB) -#define irt_iscdata(t) (irt_type(t) == IRT_CDATA) -#define irt_isfloat(t) (irt_type(t) == IRT_FLOAT) -#define irt_isnum(t) (irt_type(t) == IRT_NUM) -#define irt_isint(t) (irt_type(t) == IRT_INT) -#define irt_isi8(t) (irt_type(t) == IRT_I8) -#define irt_isu8(t) (irt_type(t) == IRT_U8) -#define irt_isi16(t) (irt_type(t) == IRT_I16) -#define irt_isu16(t) (irt_type(t) == IRT_U16) -#define irt_isu32(t) (irt_type(t) == IRT_U32) -#define irt_isi64(t) (irt_type(t) == IRT_I64) -#define irt_isu64(t) (irt_type(t) == IRT_U64) - -#define irt_isfp(t) (irt_isnum(t) || irt_isfloat(t)) -#define irt_isinteger(t) (irt_typerange((t), IRT_I8, IRT_INT)) -#define irt_isgcv(t) (irt_typerange((t), IRT_STR, IRT_UDATA)) -#define irt_isaddr(t) (irt_typerange((t), IRT_LIGHTUD, IRT_UDATA)) -#define irt_isint64(t) (irt_typerange((t), IRT_I64, IRT_U64)) - -#if LJ_64 -#define IRT_IS64 \ - ((1u<> irt_type(t)) & 1) -#define irt_is64orfp(t) (((IRT_IS64|(1u<>irt_type(t)) & 1) - -#define irt_size(t) (lj_ir_type_size[irt_t((t))]) - -LJ_DATA const uint8_t lj_ir_type_size[]; - -static LJ_AINLINE IRType itype2irt(const TValue *tv) -{ - if (tvisint(tv)) - return IRT_INT; - else if (tvisnum(tv)) - return IRT_NUM; -#if LJ_64 - else if (tvislightud(tv)) - return IRT_LIGHTUD; -#endif - else - return (IRType)~itype(tv); -} - -static LJ_AINLINE uint32_t irt_toitype_(IRType t) -{ - lua_assert(!LJ_64 || t != IRT_LIGHTUD); - if (LJ_DUALNUM && t > IRT_NUM) { - return LJ_TISNUM; - } else { - lua_assert(t <= IRT_NUM); - return ~(uint32_t)t; - } -} - -#define irt_toitype(t) irt_toitype_(irt_type((t))) - -#define irt_isguard(t) ((t).irt & IRT_GUARD) -#define irt_ismarked(t) ((t).irt & IRT_MARK) -#define irt_setmark(t) ((t).irt |= IRT_MARK) -#define irt_clearmark(t) ((t).irt &= ~IRT_MARK) -#define irt_isphi(t) ((t).irt & IRT_ISPHI) -#define irt_setphi(t) ((t).irt |= IRT_ISPHI) -#define irt_clearphi(t) ((t).irt &= ~IRT_ISPHI) - -/* Stored combined IR opcode and type. */ -typedef uint16_t IROpT; - -/* -- IR references ------------------------------------------------------- */ - -/* IR references. */ -typedef uint16_t IRRef1; /* One stored reference. */ -typedef uint32_t IRRef2; /* Two stored references. */ -typedef uint32_t IRRef; /* Used to pass around references. */ - -/* Fixed references. */ -enum { - REF_BIAS = 0x8000, - REF_TRUE = REF_BIAS-3, - REF_FALSE = REF_BIAS-2, - REF_NIL = REF_BIAS-1, /* \--- Constants grow downwards. */ - REF_BASE = REF_BIAS, /* /--- IR grows upwards. */ - REF_FIRST = REF_BIAS+1, - REF_DROP = 0xffff -}; - -/* Note: IRMlit operands must be < REF_BIAS, too! -** This allows for fast and uniform manipulation of all operands -** without looking up the operand mode in lj_ir_mode: -** - CSE calculates the maximum reference of two operands. -** This must work with mixed reference/literal operands, too. -** - DCE marking only checks for operand >= REF_BIAS. -** - LOOP needs to substitute reference operands. -** Constant references and literals must not be modified. -*/ - -#define IRREF2(lo, hi) ((IRRef2)(lo) | ((IRRef2)(hi) << 16)) - -#define irref_isk(ref) ((ref) < REF_BIAS) - -/* Tagged IR references (32 bit). -** -** +-------+-------+---------------+ -** | irt | flags | ref | -** +-------+-------+---------------+ -** -** The tag holds a copy of the IRType and speeds up IR type checks. -*/ -typedef uint32_t TRef; - -#define TREF_REFMASK 0x0000ffff -#define TREF_FRAME 0x00010000 -#define TREF_CONT 0x00020000 - -#define TREF(ref, t) ((TRef)((ref) + ((t)<<24))) - -#define tref_ref(tr) ((IRRef1)(tr)) -#define tref_t(tr) ((IRType)((tr)>>24)) -#define tref_type(tr) ((IRType)(((tr)>>24) & IRT_TYPE)) -#define tref_typerange(tr, first, last) \ - ((((tr)>>24) & IRT_TYPE) - (TRef)(first) <= (TRef)(last-first)) - -#define tref_istype(tr, t) (((tr) & (IRT_TYPE<<24)) == ((t)<<24)) -#define tref_isnil(tr) (tref_istype((tr), IRT_NIL)) -#define tref_isfalse(tr) (tref_istype((tr), IRT_FALSE)) -#define tref_istrue(tr) (tref_istype((tr), IRT_TRUE)) -#define tref_isstr(tr) (tref_istype((tr), IRT_STR)) -#define tref_isfunc(tr) (tref_istype((tr), IRT_FUNC)) -#define tref_iscdata(tr) (tref_istype((tr), IRT_CDATA)) -#define tref_istab(tr) (tref_istype((tr), IRT_TAB)) -#define tref_isudata(tr) (tref_istype((tr), IRT_UDATA)) -#define tref_isnum(tr) (tref_istype((tr), IRT_NUM)) -#define tref_isint(tr) (tref_istype((tr), IRT_INT)) - -#define tref_isbool(tr) (tref_typerange((tr), IRT_FALSE, IRT_TRUE)) -#define tref_ispri(tr) (tref_typerange((tr), IRT_NIL, IRT_TRUE)) -#define tref_istruecond(tr) (!tref_typerange((tr), IRT_NIL, IRT_FALSE)) -#define tref_isinteger(tr) (tref_typerange((tr), IRT_I8, IRT_INT)) -#define tref_isnumber(tr) (tref_typerange((tr), IRT_NUM, IRT_INT)) -#define tref_isnumber_str(tr) (tref_isnumber((tr)) || tref_isstr((tr))) -#define tref_isgcv(tr) (tref_typerange((tr), IRT_STR, IRT_UDATA)) - -#define tref_isk(tr) (irref_isk(tref_ref((tr)))) -#define tref_isk2(tr1, tr2) (irref_isk(tref_ref((tr1) | (tr2)))) - -#define TREF_PRI(t) (TREF(REF_NIL-(t), (t))) -#define TREF_NIL (TREF_PRI(IRT_NIL)) -#define TREF_FALSE (TREF_PRI(IRT_FALSE)) -#define TREF_TRUE (TREF_PRI(IRT_TRUE)) - -/* -- IR format ----------------------------------------------------------- */ - -/* IR instruction format (64 bit). -** -** 16 16 8 8 8 8 -** +-------+-------+---+---+---+---+ -** | op1 | op2 | t | o | r | s | -** +-------+-------+---+---+---+---+ -** | op12/i/gco | ot | prev | (alternative fields in union) -** +---------------+-------+-------+ -** 32 16 16 -** -** prev is only valid prior to register allocation and then reused for r + s. -*/ - -typedef union IRIns { - struct { - LJ_ENDIAN_LOHI( - IRRef1 op1; /* IR operand 1. */ - , IRRef1 op2; /* IR operand 2. */ - ) - IROpT ot; /* IR opcode and type (overlaps t and o). */ - IRRef1 prev; /* Previous ins in same chain (overlaps r and s). */ - }; - struct { - IRRef2 op12; /* IR operand 1 and 2 (overlaps op1 and op2). */ - LJ_ENDIAN_LOHI( - IRType1 t; /* IR type. */ - , IROp1 o; /* IR opcode. */ - ) - LJ_ENDIAN_LOHI( - uint8_t r; /* Register allocation (overlaps prev). */ - , uint8_t s; /* Spill slot allocation (overlaps prev). */ - ) - }; - int32_t i; /* 32 bit signed integer literal (overlaps op12). */ - GCRef gcr; /* GCobj constant (overlaps op12). */ - MRef ptr; /* Pointer constant (overlaps op12). */ -} IRIns; - -#define ir_kgc(ir) check_exp((ir)->o == IR_KGC, gcref((ir)->gcr)) -#define ir_kstr(ir) (gco2str(ir_kgc((ir)))) -#define ir_ktab(ir) (gco2tab(ir_kgc((ir)))) -#define ir_kfunc(ir) (gco2func(ir_kgc((ir)))) -#define ir_kcdata(ir) (gco2cd(ir_kgc((ir)))) -#define ir_knum(ir) check_exp((ir)->o == IR_KNUM, mref((ir)->ptr, cTValue)) -#define ir_kint64(ir) check_exp((ir)->o == IR_KINT64, mref((ir)->ptr,cTValue)) -#define ir_k64(ir) \ - check_exp((ir)->o == IR_KNUM || (ir)->o == IR_KINT64, mref((ir)->ptr,cTValue)) -#define ir_kptr(ir) \ - check_exp((ir)->o == IR_KPTR || (ir)->o == IR_KKPTR, mref((ir)->ptr, void)) - -/* A store or any other op with a non-weak guard has a side-effect. */ -static LJ_AINLINE int ir_sideeff(IRIns *ir) -{ - return (((ir->t.irt | ~IRT_GUARD) & lj_ir_mode[ir->o]) >= IRM_S); -} - -LJ_STATIC_ASSERT((int)IRT_GUARD == (int)IRM_W); - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ircall.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_ircall.h deleted file mode 100644 index af30ba8fc..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_ircall.h +++ /dev/null @@ -1,271 +0,0 @@ -/* -** IR CALL* instruction definitions. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_IRCALL_H -#define _LJ_IRCALL_H - -#include "lj_obj.h" -#include "lj_ir.h" -#include "lj_jit.h" - -/* C call info for CALL* instructions. */ -typedef struct CCallInfo { - ASMFunction func; /* Function pointer. */ - uint32_t flags; /* Number of arguments and flags. */ -} CCallInfo; - -#define CCI_NARGS(ci) ((ci)->flags & 0xff) /* Extract # of args. */ -#define CCI_NARGS_MAX 32 /* Max. # of args. */ - -#define CCI_OTSHIFT 16 -#define CCI_OPTYPE(ci) ((ci)->flags >> CCI_OTSHIFT) /* Get op/type. */ -#define CCI_OPSHIFT 24 -#define CCI_OP(ci) ((ci)->flags >> CCI_OPSHIFT) /* Get op. */ - -#define CCI_CALL_N (IR_CALLN << CCI_OPSHIFT) -#define CCI_CALL_L (IR_CALLL << CCI_OPSHIFT) -#define CCI_CALL_S (IR_CALLS << CCI_OPSHIFT) -#define CCI_CALL_FN (CCI_CALL_N|CCI_CC_FASTCALL) -#define CCI_CALL_FL (CCI_CALL_L|CCI_CC_FASTCALL) -#define CCI_CALL_FS (CCI_CALL_S|CCI_CC_FASTCALL) - -/* C call info flags. */ -#define CCI_L 0x0100 /* Implicit L arg. */ -#define CCI_CASTU64 0x0200 /* Cast u64 result to number. */ -#define CCI_NOFPRCLOBBER 0x0400 /* Does not clobber any FPRs. */ -#define CCI_VARARG 0x0800 /* Vararg function. */ - -#define CCI_CC_MASK 0x3000 /* Calling convention mask. */ -#define CCI_CC_SHIFT 12 -/* ORDER CC */ -#define CCI_CC_CDECL 0x0000 /* Default cdecl calling convention. */ -#define CCI_CC_THISCALL 0x1000 /* Thiscall calling convention. */ -#define CCI_CC_FASTCALL 0x2000 /* Fastcall calling convention. */ -#define CCI_CC_STDCALL 0x3000 /* Stdcall calling convention. */ - -/* Helpers for conditional function definitions. */ -#define IRCALLCOND_ANY(x) x - -#if LJ_TARGET_X86ORX64 -#define IRCALLCOND_FPMATH(x) NULL -#else -#define IRCALLCOND_FPMATH(x) x -#endif - -#if LJ_SOFTFP -#define IRCALLCOND_SOFTFP(x) x -#if LJ_HASFFI -#define IRCALLCOND_SOFTFP_FFI(x) x -#else -#define IRCALLCOND_SOFTFP_FFI(x) NULL -#endif -#else -#define IRCALLCOND_SOFTFP(x) NULL -#define IRCALLCOND_SOFTFP_FFI(x) NULL -#endif - -#define LJ_NEED_FP64 (LJ_TARGET_ARM || LJ_TARGET_PPC || LJ_TARGET_MIPS) - -#if LJ_HASFFI && (LJ_SOFTFP || LJ_NEED_FP64) -#define IRCALLCOND_FP64_FFI(x) x -#else -#define IRCALLCOND_FP64_FFI(x) NULL -#endif - -#if LJ_HASFFI -#define IRCALLCOND_FFI(x) x -#if LJ_32 -#define IRCALLCOND_FFI32(x) x -#else -#define IRCALLCOND_FFI32(x) NULL -#endif -#else -#define IRCALLCOND_FFI(x) NULL -#define IRCALLCOND_FFI32(x) NULL -#endif - -#if LJ_SOFTFP -#define ARG1_FP 2 /* Treat as 2 32 bit arguments. */ -#else -#define ARG1_FP 1 -#endif - -#if LJ_32 -#define ARG2_64 4 /* Treat as 4 32 bit arguments. */ -#else -#define ARG2_64 2 -#endif - -/* Function definitions for CALL* instructions. */ -#define IRCALLDEF(_) \ - _(ANY, lj_str_cmp, 2, FN, INT, CCI_NOFPRCLOBBER) \ - _(ANY, lj_str_new, 3, S, STR, CCI_L) \ - _(ANY, lj_strscan_num, 2, FN, INT, 0) \ - _(ANY, lj_str_fromint, 2, FN, STR, CCI_L) \ - _(ANY, lj_str_fromnum, 2, FN, STR, CCI_L) \ - _(ANY, lj_tab_new1, 2, FS, TAB, CCI_L) \ - _(ANY, lj_tab_dup, 2, FS, TAB, CCI_L) \ - _(ANY, lj_tab_newkey, 3, S, P32, CCI_L) \ - _(ANY, lj_tab_len, 1, FL, INT, 0) \ - _(ANY, lj_gc_step_jit, 2, FS, NIL, CCI_L) \ - _(ANY, lj_gc_barrieruv, 2, FS, NIL, 0) \ - _(ANY, lj_mem_newgco, 2, FS, P32, CCI_L) \ - _(ANY, lj_math_random_step, 1, FS, NUM, CCI_CASTU64|CCI_NOFPRCLOBBER) \ - _(ANY, lj_vm_modi, 2, FN, INT, 0) \ - _(ANY, sinh, ARG1_FP, N, NUM, 0) \ - _(ANY, cosh, ARG1_FP, N, NUM, 0) \ - _(ANY, tanh, ARG1_FP, N, NUM, 0) \ - _(ANY, fputc, 2, S, INT, 0) \ - _(ANY, fwrite, 4, S, INT, 0) \ - _(ANY, fflush, 1, S, INT, 0) \ - /* ORDER FPM */ \ - _(FPMATH, lj_vm_floor, ARG1_FP, N, NUM, 0) \ - _(FPMATH, lj_vm_ceil, ARG1_FP, N, NUM, 0) \ - _(FPMATH, lj_vm_trunc, ARG1_FP, N, NUM, 0) \ - _(FPMATH, sqrt, ARG1_FP, N, NUM, 0) \ - _(FPMATH, exp, ARG1_FP, N, NUM, 0) \ - _(FPMATH, lj_vm_exp2, ARG1_FP, N, NUM, 0) \ - _(FPMATH, log, ARG1_FP, N, NUM, 0) \ - _(FPMATH, lj_vm_log2, ARG1_FP, N, NUM, 0) \ - _(FPMATH, log10, ARG1_FP, N, NUM, 0) \ - _(FPMATH, sin, ARG1_FP, N, NUM, 0) \ - _(FPMATH, cos, ARG1_FP, N, NUM, 0) \ - _(FPMATH, tan, ARG1_FP, N, NUM, 0) \ - _(FPMATH, lj_vm_powi, ARG1_FP+1, N, NUM, 0) \ - _(FPMATH, pow, ARG1_FP*2, N, NUM, 0) \ - _(FPMATH, atan2, ARG1_FP*2, N, NUM, 0) \ - _(FPMATH, ldexp, ARG1_FP+1, N, NUM, 0) \ - _(SOFTFP, lj_vm_tobit, 2, N, INT, 0) \ - _(SOFTFP, softfp_add, 4, N, NUM, 0) \ - _(SOFTFP, softfp_sub, 4, N, NUM, 0) \ - _(SOFTFP, softfp_mul, 4, N, NUM, 0) \ - _(SOFTFP, softfp_div, 4, N, NUM, 0) \ - _(SOFTFP, softfp_cmp, 4, N, NIL, 0) \ - _(SOFTFP, softfp_i2d, 1, N, NUM, 0) \ - _(SOFTFP, softfp_d2i, 2, N, INT, 0) \ - _(SOFTFP_FFI, softfp_ui2d, 1, N, NUM, 0) \ - _(SOFTFP_FFI, softfp_f2d, 1, N, NUM, 0) \ - _(SOFTFP_FFI, softfp_d2ui, 2, N, INT, 0) \ - _(SOFTFP_FFI, softfp_d2f, 2, N, FLOAT, 0) \ - _(SOFTFP_FFI, softfp_i2f, 1, N, FLOAT, 0) \ - _(SOFTFP_FFI, softfp_ui2f, 1, N, FLOAT, 0) \ - _(SOFTFP_FFI, softfp_f2i, 1, N, INT, 0) \ - _(SOFTFP_FFI, softfp_f2ui, 1, N, INT, 0) \ - _(FP64_FFI, fp64_l2d, 2, N, NUM, 0) \ - _(FP64_FFI, fp64_ul2d, 2, N, NUM, 0) \ - _(FP64_FFI, fp64_l2f, 2, N, FLOAT, 0) \ - _(FP64_FFI, fp64_ul2f, 2, N, FLOAT, 0) \ - _(FP64_FFI, fp64_d2l, ARG1_FP, N, I64, 0) \ - _(FP64_FFI, fp64_d2ul, ARG1_FP, N, U64, 0) \ - _(FP64_FFI, fp64_f2l, 1, N, I64, 0) \ - _(FP64_FFI, fp64_f2ul, 1, N, U64, 0) \ - _(FFI, lj_carith_divi64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \ - _(FFI, lj_carith_divu64, ARG2_64, N, U64, CCI_NOFPRCLOBBER) \ - _(FFI, lj_carith_modi64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \ - _(FFI, lj_carith_modu64, ARG2_64, N, U64, CCI_NOFPRCLOBBER) \ - _(FFI, lj_carith_powi64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \ - _(FFI, lj_carith_powu64, ARG2_64, N, U64, CCI_NOFPRCLOBBER) \ - _(FFI, lj_cdata_setfin, 2, FN, P32, CCI_L) \ - _(FFI, strlen, 1, L, INTP, 0) \ - _(FFI, memcpy, 3, S, PTR, 0) \ - _(FFI, memset, 3, S, PTR, 0) \ - _(FFI, lj_vm_errno, 0, S, INT, CCI_NOFPRCLOBBER) \ - _(FFI32, lj_carith_mul64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) - \ - /* End of list. */ - -typedef enum { -#define IRCALLENUM(cond, name, nargs, kind, type, flags) IRCALL_##name, -IRCALLDEF(IRCALLENUM) -#undef IRCALLENUM - IRCALL__MAX -} IRCallID; - -LJ_FUNC TRef lj_ir_call(jit_State *J, IRCallID id, ...); - -LJ_DATA const CCallInfo lj_ir_callinfo[IRCALL__MAX+1]; - -/* Soft-float declarations. */ -#if LJ_SOFTFP -#if LJ_TARGET_ARM -#define softfp_add __aeabi_dadd -#define softfp_sub __aeabi_dsub -#define softfp_mul __aeabi_dmul -#define softfp_div __aeabi_ddiv -#define softfp_cmp __aeabi_cdcmple -#define softfp_i2d __aeabi_i2d -#define softfp_d2i __aeabi_d2iz -#define softfp_ui2d __aeabi_ui2d -#define softfp_f2d __aeabi_f2d -#define softfp_d2ui __aeabi_d2uiz -#define softfp_d2f __aeabi_d2f -#define softfp_i2f __aeabi_i2f -#define softfp_ui2f __aeabi_ui2f -#define softfp_f2i __aeabi_f2iz -#define softfp_f2ui __aeabi_f2uiz -#define fp64_l2d __aeabi_l2d -#define fp64_ul2d __aeabi_ul2d -#define fp64_l2f __aeabi_l2f -#define fp64_ul2f __aeabi_ul2f -#if LJ_TARGET_IOS -#define fp64_d2l __fixdfdi -#define fp64_d2ul __fixunsdfdi -#define fp64_f2l __fixsfdi -#define fp64_f2ul __fixunssfdi -#else -#define fp64_d2l __aeabi_d2lz -#define fp64_d2ul __aeabi_d2ulz -#define fp64_f2l __aeabi_f2lz -#define fp64_f2ul __aeabi_f2ulz -#endif -#else -#error "Missing soft-float definitions for target architecture" -#endif -extern double softfp_add(double a, double b); -extern double softfp_sub(double a, double b); -extern double softfp_mul(double a, double b); -extern double softfp_div(double a, double b); -extern void softfp_cmp(double a, double b); -extern double softfp_i2d(int32_t a); -extern int32_t softfp_d2i(double a); -#if LJ_HASFFI -extern double softfp_ui2d(uint32_t a); -extern double softfp_f2d(float a); -extern uint32_t softfp_d2ui(double a); -extern float softfp_d2f(double a); -extern float softfp_i2f(int32_t a); -extern float softfp_ui2f(uint32_t a); -extern int32_t softfp_f2i(float a); -extern uint32_t softfp_f2ui(float a); -#endif -#endif - -#if LJ_HASFFI && LJ_NEED_FP64 && !(LJ_TARGET_ARM && LJ_SOFTFP) -#ifdef __GNUC__ -#define fp64_l2d __floatdidf -#define fp64_ul2d __floatundidf -#define fp64_l2f __floatdisf -#define fp64_ul2f __floatundisf -#define fp64_d2l __fixdfdi -#define fp64_d2ul __fixunsdfdi -#define fp64_f2l __fixsfdi -#define fp64_f2ul __fixunssfdi -#else -#error "Missing fp64 helper definitions for this compiler" -#endif -#endif - -#if LJ_HASFFI && (LJ_SOFTFP || LJ_NEED_FP64) -extern double fp64_l2d(int64_t a); -extern double fp64_ul2d(uint64_t a); -extern float fp64_l2f(int64_t a); -extern float fp64_ul2f(uint64_t a); -extern int64_t fp64_d2l(double a); -extern uint64_t fp64_d2ul(double a); -extern int64_t fp64_f2l(float a); -extern uint64_t fp64_f2ul(float a); -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_iropt.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_iropt.h deleted file mode 100644 index e45ae2b7b..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_iropt.h +++ /dev/null @@ -1,161 +0,0 @@ -/* -** Common header for IR emitter and optimizations. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_IROPT_H -#define _LJ_IROPT_H - -#include - -#include "lj_obj.h" -#include "lj_jit.h" - -#if LJ_HASJIT -/* IR emitter. */ -LJ_FUNC void LJ_FASTCALL lj_ir_growtop(jit_State *J); -LJ_FUNC TRef LJ_FASTCALL lj_ir_emit(jit_State *J); - -/* Save current IR in J->fold.ins, but do not emit it (yet). */ -static LJ_AINLINE void lj_ir_set_(jit_State *J, uint16_t ot, IRRef1 a, IRRef1 b) -{ - J->fold.ins.ot = ot; J->fold.ins.op1 = a; J->fold.ins.op2 = b; -} - -#define lj_ir_set(J, ot, a, b) \ - lj_ir_set_(J, (uint16_t)(ot), (IRRef1)(a), (IRRef1)(b)) - -/* Get ref of next IR instruction and optionally grow IR. -** Note: this may invalidate all IRIns*! -*/ -static LJ_AINLINE IRRef lj_ir_nextins(jit_State *J) -{ - IRRef ref = J->cur.nins; - if (LJ_UNLIKELY(ref >= J->irtoplim)) lj_ir_growtop(J); - J->cur.nins = ref + 1; - return ref; -} - -/* Interning of constants. */ -LJ_FUNC TRef LJ_FASTCALL lj_ir_kint(jit_State *J, int32_t k); -LJ_FUNC void lj_ir_k64_freeall(jit_State *J); -LJ_FUNC TRef lj_ir_k64(jit_State *J, IROp op, cTValue *tv); -LJ_FUNC cTValue *lj_ir_k64_find(jit_State *J, uint64_t u64); -LJ_FUNC TRef lj_ir_knum_u64(jit_State *J, uint64_t u64); -LJ_FUNC TRef lj_ir_knumint(jit_State *J, lua_Number n); -LJ_FUNC TRef lj_ir_kint64(jit_State *J, uint64_t u64); -LJ_FUNC TRef lj_ir_kgc(jit_State *J, GCobj *o, IRType t); -LJ_FUNC TRef lj_ir_kptr_(jit_State *J, IROp op, void *ptr); -LJ_FUNC TRef lj_ir_knull(jit_State *J, IRType t); -LJ_FUNC TRef lj_ir_kslot(jit_State *J, TRef key, IRRef slot); - -#if LJ_64 -#define lj_ir_kintp(J, k) lj_ir_kint64(J, (uint64_t)(k)) -#else -#define lj_ir_kintp(J, k) lj_ir_kint(J, (int32_t)(k)) -#endif - -static LJ_AINLINE TRef lj_ir_knum(jit_State *J, lua_Number n) -{ - TValue tv; - tv.n = n; - return lj_ir_knum_u64(J, tv.u64); -} - -#define lj_ir_kstr(J, str) lj_ir_kgc(J, obj2gco((str)), IRT_STR) -#define lj_ir_ktab(J, tab) lj_ir_kgc(J, obj2gco((tab)), IRT_TAB) -#define lj_ir_kfunc(J, func) lj_ir_kgc(J, obj2gco((func)), IRT_FUNC) -#define lj_ir_kptr(J, ptr) lj_ir_kptr_(J, IR_KPTR, (ptr)) -#define lj_ir_kkptr(J, ptr) lj_ir_kptr_(J, IR_KKPTR, (ptr)) - -/* Special FP constants. */ -#define lj_ir_knum_zero(J) lj_ir_knum_u64(J, U64x(00000000,00000000)) -#define lj_ir_knum_one(J) lj_ir_knum_u64(J, U64x(3ff00000,00000000)) -#define lj_ir_knum_tobit(J) lj_ir_knum_u64(J, U64x(43380000,00000000)) - -/* Special 128 bit SIMD constants. */ -#define lj_ir_knum_abs(J) lj_ir_k64(J, IR_KNUM, LJ_KSIMD(J, LJ_KSIMD_ABS)) -#define lj_ir_knum_neg(J) lj_ir_k64(J, IR_KNUM, LJ_KSIMD(J, LJ_KSIMD_NEG)) - -/* Access to constants. */ -LJ_FUNC void lj_ir_kvalue(lua_State *L, TValue *tv, const IRIns *ir); - -/* Convert IR operand types. */ -LJ_FUNC TRef LJ_FASTCALL lj_ir_tonumber(jit_State *J, TRef tr); -LJ_FUNC TRef LJ_FASTCALL lj_ir_tonum(jit_State *J, TRef tr); -LJ_FUNC TRef LJ_FASTCALL lj_ir_tostr(jit_State *J, TRef tr); - -/* Miscellaneous IR ops. */ -LJ_FUNC int lj_ir_numcmp(lua_Number a, lua_Number b, IROp op); -LJ_FUNC int lj_ir_strcmp(GCstr *a, GCstr *b, IROp op); -LJ_FUNC void lj_ir_rollback(jit_State *J, IRRef ref); - -/* Emit IR instructions with on-the-fly optimizations. */ -LJ_FUNC TRef LJ_FASTCALL lj_opt_fold(jit_State *J); -LJ_FUNC TRef LJ_FASTCALL lj_opt_cse(jit_State *J); -LJ_FUNC TRef LJ_FASTCALL lj_opt_cselim(jit_State *J, IRRef lim); - -/* Special return values for the fold functions. */ -enum { - NEXTFOLD, /* Couldn't fold, pass on. */ - RETRYFOLD, /* Retry fold with modified fins. */ - KINTFOLD, /* Return ref for int constant in fins->i. */ - FAILFOLD, /* Guard would always fail. */ - DROPFOLD, /* Guard eliminated. */ - MAX_FOLD -}; - -#define INTFOLD(k) ((J->fold.ins.i = (k)), (TRef)KINTFOLD) -#define INT64FOLD(k) (lj_ir_kint64(J, (k))) -#define CONDFOLD(cond) ((TRef)FAILFOLD + (TRef)(cond)) -#define LEFTFOLD (J->fold.ins.op1) -#define RIGHTFOLD (J->fold.ins.op2) -#define CSEFOLD (lj_opt_cse(J)) -#define EMITFOLD (lj_ir_emit(J)) - -/* Load/store forwarding. */ -LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_aload(jit_State *J); -LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_hload(jit_State *J); -LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_uload(jit_State *J); -LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_fload(jit_State *J); -LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_xload(jit_State *J); -LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_tab_len(jit_State *J); -LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_hrefk(jit_State *J); -LJ_FUNC int LJ_FASTCALL lj_opt_fwd_href_nokey(jit_State *J); -LJ_FUNC int LJ_FASTCALL lj_opt_fwd_tptr(jit_State *J, IRRef lim); -LJ_FUNC int lj_opt_fwd_wasnonnil(jit_State *J, IROpT loadop, IRRef xref); - -/* Dead-store elimination. */ -LJ_FUNC TRef LJ_FASTCALL lj_opt_dse_ahstore(jit_State *J); -LJ_FUNC TRef LJ_FASTCALL lj_opt_dse_ustore(jit_State *J); -LJ_FUNC TRef LJ_FASTCALL lj_opt_dse_fstore(jit_State *J); -LJ_FUNC TRef LJ_FASTCALL lj_opt_dse_xstore(jit_State *J); - -/* Narrowing. */ -LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_convert(jit_State *J); -LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_index(jit_State *J, TRef key); -LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_toint(jit_State *J, TRef tr); -LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_tobit(jit_State *J, TRef tr); -#if LJ_HASFFI -LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_cindex(jit_State *J, TRef key); -#endif -LJ_FUNC TRef lj_opt_narrow_arith(jit_State *J, TRef rb, TRef rc, - TValue *vb, TValue *vc, IROp op); -LJ_FUNC TRef lj_opt_narrow_unm(jit_State *J, TRef rc, TValue *vc); -LJ_FUNC TRef lj_opt_narrow_mod(jit_State *J, TRef rb, TRef rc, TValue *vc); -LJ_FUNC TRef lj_opt_narrow_pow(jit_State *J, TRef rb, TRef rc, TValue *vc); -LJ_FUNC IRType lj_opt_narrow_forl(jit_State *J, cTValue *forbase); - -/* Optimization passes. */ -LJ_FUNC void lj_opt_dce(jit_State *J); -LJ_FUNC int lj_opt_loop(jit_State *J); -#if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) -LJ_FUNC void lj_opt_split(jit_State *J); -#else -#define lj_opt_split(J) UNUSED(J) -#endif -LJ_FUNC void lj_opt_sink(jit_State *J); - -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_jit.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_jit.h deleted file mode 100644 index b69e4f4ef..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_jit.h +++ /dev/null @@ -1,416 +0,0 @@ -/* -** Common definitions for the JIT compiler. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_JIT_H -#define _LJ_JIT_H - -#include "lj_obj.h" -#include "lj_ir.h" - -/* JIT engine flags. */ -#define JIT_F_ON 0x00000001 - -/* CPU-specific JIT engine flags. */ -#if LJ_TARGET_X86ORX64 -#define JIT_F_CMOV 0x00000010 -#define JIT_F_SSE2 0x00000020 -#define JIT_F_SSE3 0x00000040 -#define JIT_F_SSE4_1 0x00000080 -#define JIT_F_P4 0x00000100 -#define JIT_F_PREFER_IMUL 0x00000200 -#define JIT_F_SPLIT_XMM 0x00000400 -#define JIT_F_LEA_AGU 0x00000800 - -/* Names for the CPU-specific flags. Must match the order above. */ -#define JIT_F_CPU_FIRST JIT_F_CMOV -#define JIT_F_CPUSTRING "\4CMOV\4SSE2\4SSE3\6SSE4.1\2P4\3AMD\2K8\4ATOM" -#elif LJ_TARGET_ARM -#define JIT_F_ARMV6_ 0x00000010 -#define JIT_F_ARMV6T2_ 0x00000020 -#define JIT_F_ARMV7 0x00000040 -#define JIT_F_VFPV2 0x00000080 -#define JIT_F_VFPV3 0x00000100 - -#define JIT_F_ARMV6 (JIT_F_ARMV6_|JIT_F_ARMV6T2_|JIT_F_ARMV7) -#define JIT_F_ARMV6T2 (JIT_F_ARMV6T2_|JIT_F_ARMV7) -#define JIT_F_VFP (JIT_F_VFPV2|JIT_F_VFPV3) - -/* Names for the CPU-specific flags. Must match the order above. */ -#define JIT_F_CPU_FIRST JIT_F_ARMV6_ -#define JIT_F_CPUSTRING "\5ARMv6\7ARMv6T2\5ARMv7\5VFPv2\5VFPv3" -#elif LJ_TARGET_PPC -#define JIT_F_SQRT 0x00000010 -#define JIT_F_ROUND 0x00000020 - -/* Names for the CPU-specific flags. Must match the order above. */ -#define JIT_F_CPU_FIRST JIT_F_SQRT -#define JIT_F_CPUSTRING "\4SQRT\5ROUND" -#elif LJ_TARGET_MIPS -#define JIT_F_MIPS32R2 0x00000010 - -/* Names for the CPU-specific flags. Must match the order above. */ -#define JIT_F_CPU_FIRST JIT_F_MIPS32R2 -#define JIT_F_CPUSTRING "\010MIPS32R2" -#else -#define JIT_F_CPU_FIRST 0 -#define JIT_F_CPUSTRING "" -#endif - -/* Optimization flags. */ -#define JIT_F_OPT_MASK 0x0fff0000 - -#define JIT_F_OPT_FOLD 0x00010000 -#define JIT_F_OPT_CSE 0x00020000 -#define JIT_F_OPT_DCE 0x00040000 -#define JIT_F_OPT_FWD 0x00080000 -#define JIT_F_OPT_DSE 0x00100000 -#define JIT_F_OPT_NARROW 0x00200000 -#define JIT_F_OPT_LOOP 0x00400000 -#define JIT_F_OPT_ABC 0x00800000 -#define JIT_F_OPT_SINK 0x01000000 -#define JIT_F_OPT_FUSE 0x02000000 - -/* Optimizations names for -O. Must match the order above. */ -#define JIT_F_OPT_FIRST JIT_F_OPT_FOLD -#define JIT_F_OPTSTRING \ - "\4fold\3cse\3dce\3fwd\3dse\6narrow\4loop\3abc\4sink\4fuse" - -/* Optimization levels set a fixed combination of flags. */ -#define JIT_F_OPT_0 0 -#define JIT_F_OPT_1 (JIT_F_OPT_FOLD|JIT_F_OPT_CSE|JIT_F_OPT_DCE) -#define JIT_F_OPT_2 (JIT_F_OPT_1|JIT_F_OPT_NARROW|JIT_F_OPT_LOOP) -#define JIT_F_OPT_3 (JIT_F_OPT_2|\ - JIT_F_OPT_FWD|JIT_F_OPT_DSE|JIT_F_OPT_ABC|JIT_F_OPT_SINK|JIT_F_OPT_FUSE) -#define JIT_F_OPT_DEFAULT JIT_F_OPT_3 - -#if LJ_TARGET_WINDOWS || LJ_64 -/* See: http://blogs.msdn.com/oldnewthing/archive/2003/10/08/55239.aspx */ -#define JIT_P_sizemcode_DEFAULT 64 -#else -/* Could go as low as 4K, but the mmap() overhead would be rather high. */ -#define JIT_P_sizemcode_DEFAULT 32 -#endif - -/* Optimization parameters and their defaults. Length is a char in octal! */ -#define JIT_PARAMDEF(_) \ - _(\010, maxtrace, 1000) /* Max. # of traces in cache. */ \ - _(\011, maxrecord, 4000) /* Max. # of recorded IR instructions. */ \ - _(\012, maxirconst, 500) /* Max. # of IR constants of a trace. */ \ - _(\007, maxside, 100) /* Max. # of side traces of a root trace. */ \ - _(\007, maxsnap, 500) /* Max. # of snapshots for a trace. */ \ - \ - _(\007, hotloop, 56) /* # of iter. to detect a hot loop/call. */ \ - _(\007, hotexit, 10) /* # of taken exits to start a side trace. */ \ - _(\007, tryside, 4) /* # of attempts to compile a side trace. */ \ - \ - _(\012, instunroll, 4) /* Max. unroll for instable loops. */ \ - _(\012, loopunroll, 15) /* Max. unroll for loop ops in side traces. */ \ - _(\012, callunroll, 3) /* Max. unroll for recursive calls. */ \ - _(\011, recunroll, 2) /* Min. unroll for true recursion. */ \ - \ - /* Size of each machine code area (in KBytes). */ \ - _(\011, sizemcode, JIT_P_sizemcode_DEFAULT) \ - /* Max. total size of all machine code areas (in KBytes). */ \ - _(\010, maxmcode, 512) \ - /* End of list. */ - -enum { -#define JIT_PARAMENUM(len, name, value) JIT_P_##name, -JIT_PARAMDEF(JIT_PARAMENUM) -#undef JIT_PARAMENUM - JIT_P__MAX -}; - -#define JIT_PARAMSTR(len, name, value) #len #name -#define JIT_P_STRING JIT_PARAMDEF(JIT_PARAMSTR) - -/* Trace compiler state. */ -typedef enum { - LJ_TRACE_IDLE, /* Trace compiler idle. */ - LJ_TRACE_ACTIVE = 0x10, - LJ_TRACE_RECORD, /* Bytecode recording active. */ - LJ_TRACE_START, /* New trace started. */ - LJ_TRACE_END, /* End of trace. */ - LJ_TRACE_ASM, /* Assemble trace. */ - LJ_TRACE_ERR /* Trace aborted with error. */ -} TraceState; - -/* Post-processing action. */ -typedef enum { - LJ_POST_NONE, /* No action. */ - LJ_POST_FIXCOMP, /* Fixup comparison and emit pending guard. */ - LJ_POST_FIXGUARD, /* Fixup and emit pending guard. */ - LJ_POST_FIXGUARDSNAP, /* Fixup and emit pending guard and snapshot. */ - LJ_POST_FIXBOOL, /* Fixup boolean result. */ - LJ_POST_FIXCONST, /* Fixup constant results. */ - LJ_POST_FFRETRY /* Suppress recording of retried fast functions. */ -} PostProc; - -/* Machine code type. */ -#if LJ_TARGET_X86ORX64 -typedef uint8_t MCode; -#else -typedef uint32_t MCode; -#endif - -/* Stack snapshot header. */ -typedef struct SnapShot { - uint16_t mapofs; /* Offset into snapshot map. */ - IRRef1 ref; /* First IR ref for this snapshot. */ - uint8_t nslots; /* Number of valid slots. */ - uint8_t topslot; /* Maximum frame extent. */ - uint8_t nent; /* Number of compressed entries. */ - uint8_t count; /* Count of taken exits for this snapshot. */ -} SnapShot; - -#define SNAPCOUNT_DONE 255 /* Already compiled and linked a side trace. */ - -/* Compressed snapshot entry. */ -typedef uint32_t SnapEntry; - -#define SNAP_FRAME 0x010000 /* Frame slot. */ -#define SNAP_CONT 0x020000 /* Continuation slot. */ -#define SNAP_NORESTORE 0x040000 /* No need to restore slot. */ -#define SNAP_SOFTFPNUM 0x080000 /* Soft-float number. */ -LJ_STATIC_ASSERT(SNAP_FRAME == TREF_FRAME); -LJ_STATIC_ASSERT(SNAP_CONT == TREF_CONT); - -#define SNAP(slot, flags, ref) (((SnapEntry)(slot) << 24) + (flags) + (ref)) -#define SNAP_TR(slot, tr) \ - (((SnapEntry)(slot) << 24) + ((tr) & (TREF_CONT|TREF_FRAME|TREF_REFMASK))) -#define SNAP_MKPC(pc) ((SnapEntry)u32ptr(pc)) -#define SNAP_MKFTSZ(ftsz) ((SnapEntry)(ftsz)) -#define snap_ref(sn) ((sn) & 0xffff) -#define snap_slot(sn) ((BCReg)((sn) >> 24)) -#define snap_isframe(sn) ((sn) & SNAP_FRAME) -#define snap_pc(sn) ((const BCIns *)(uintptr_t)(sn)) -#define snap_setref(sn, ref) (((sn) & (0xffff0000&~SNAP_NORESTORE)) | (ref)) - -/* Snapshot and exit numbers. */ -typedef uint32_t SnapNo; -typedef uint32_t ExitNo; - -/* Trace number. */ -typedef uint32_t TraceNo; /* Used to pass around trace numbers. */ -typedef uint16_t TraceNo1; /* Stored trace number. */ - -/* Type of link. ORDER LJ_TRLINK */ -typedef enum { - LJ_TRLINK_NONE, /* Incomplete trace. No link, yet. */ - LJ_TRLINK_ROOT, /* Link to other root trace. */ - LJ_TRLINK_LOOP, /* Loop to same trace. */ - LJ_TRLINK_TAILREC, /* Tail-recursion. */ - LJ_TRLINK_UPREC, /* Up-recursion. */ - LJ_TRLINK_DOWNREC, /* Down-recursion. */ - LJ_TRLINK_INTERP, /* Fallback to interpreter. */ - LJ_TRLINK_RETURN /* Return to interpreter. */ -} TraceLink; - -/* Trace object. */ -typedef struct GCtrace { - GCHeader; - uint8_t topslot; /* Top stack slot already checked to be allocated. */ - uint8_t linktype; /* Type of link. */ - IRRef nins; /* Next IR instruction. Biased with REF_BIAS. */ - GCRef gclist; - IRIns *ir; /* IR instructions/constants. Biased with REF_BIAS. */ - IRRef nk; /* Lowest IR constant. Biased with REF_BIAS. */ - uint16_t nsnap; /* Number of snapshots. */ - uint16_t nsnapmap; /* Number of snapshot map elements. */ - SnapShot *snap; /* Snapshot array. */ - SnapEntry *snapmap; /* Snapshot map. */ - GCRef startpt; /* Starting prototype. */ - MRef startpc; /* Bytecode PC of starting instruction. */ - BCIns startins; /* Original bytecode of starting instruction. */ - MSize szmcode; /* Size of machine code. */ - MCode *mcode; /* Start of machine code. */ - MSize mcloop; /* Offset of loop start in machine code. */ - uint16_t nchild; /* Number of child traces (root trace only). */ - uint16_t spadjust; /* Stack pointer adjustment (offset in bytes). */ - TraceNo1 traceno; /* Trace number. */ - TraceNo1 link; /* Linked trace (or self for loops). */ - TraceNo1 root; /* Root trace of side trace (or 0 for root traces). */ - TraceNo1 nextroot; /* Next root trace for same prototype. */ - TraceNo1 nextside; /* Next side trace of same root trace. */ - uint8_t sinktags; /* Trace has SINK tags. */ - uint8_t unused1; -#ifdef LUAJIT_USE_GDBJIT - void *gdbjit_entry; /* GDB JIT entry. */ -#endif -} GCtrace; - -#define gco2trace(o) check_exp((o)->gch.gct == ~LJ_TTRACE, (GCtrace *)(o)) -#define traceref(J, n) \ - check_exp((n)>0 && (MSize)(n)sizetrace, (GCtrace *)gcref(J->trace[(n)])) - -LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCtrace, gclist)); - -static LJ_AINLINE MSize snap_nextofs(GCtrace *T, SnapShot *snap) -{ - if (snap+1 == &T->snap[T->nsnap]) - return T->nsnapmap; - else - return (snap+1)->mapofs; -} - -/* Round-robin penalty cache for bytecodes leading to aborted traces. */ -typedef struct HotPenalty { - MRef pc; /* Starting bytecode PC. */ - uint16_t val; /* Penalty value, i.e. hotcount start. */ - uint16_t reason; /* Abort reason (really TraceErr). */ -} HotPenalty; - -#define PENALTY_SLOTS 64 /* Penalty cache slot. Must be a power of 2. */ -#define PENALTY_MIN (36*2) /* Minimum penalty value. */ -#define PENALTY_MAX 60000 /* Maximum penalty value. */ -#define PENALTY_RNDBITS 4 /* # of random bits to add to penalty value. */ - -/* Round-robin backpropagation cache for narrowing conversions. */ -typedef struct BPropEntry { - IRRef1 key; /* Key: original reference. */ - IRRef1 val; /* Value: reference after conversion. */ - IRRef mode; /* Mode for this entry (currently IRCONV_*). */ -} BPropEntry; - -/* Number of slots for the backpropagation cache. Must be a power of 2. */ -#define BPROP_SLOTS 16 - -/* Scalar evolution analysis cache. */ -typedef struct ScEvEntry { - IRRef1 idx; /* Index reference. */ - IRRef1 start; /* Constant start reference. */ - IRRef1 stop; /* Constant stop reference. */ - IRRef1 step; /* Constant step reference. */ - IRType1 t; /* Scalar type. */ - uint8_t dir; /* Direction. 1: +, 0: -. */ -} ScEvEntry; - -/* 128 bit SIMD constants. */ -enum { - LJ_KSIMD_ABS, - LJ_KSIMD_NEG, - LJ_KSIMD__MAX -}; - -/* Get 16 byte aligned pointer to SIMD constant. */ -#define LJ_KSIMD(J, n) \ - ((TValue *)(((intptr_t)&J->ksimd[2*(n)] + 15) & ~(intptr_t)15)) - -/* Set/reset flag to activate the SPLIT pass for the current trace. */ -#if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) -#define lj_needsplit(J) (J->needsplit = 1) -#define lj_resetsplit(J) (J->needsplit = 0) -#else -#define lj_needsplit(J) UNUSED(J) -#define lj_resetsplit(J) UNUSED(J) -#endif - -/* Fold state is used to fold instructions on-the-fly. */ -typedef struct FoldState { - IRIns ins; /* Currently emitted instruction. */ - IRIns left; /* Instruction referenced by left operand. */ - IRIns right; /* Instruction referenced by right operand. */ -} FoldState; - -/* JIT compiler state. */ -typedef struct jit_State { - GCtrace cur; /* Current trace. */ - - lua_State *L; /* Current Lua state. */ - const BCIns *pc; /* Current PC. */ - GCfunc *fn; /* Current function. */ - GCproto *pt; /* Current prototype. */ - TRef *base; /* Current frame base, points into J->slots. */ - - uint32_t flags; /* JIT engine flags. */ - BCReg maxslot; /* Relative to baseslot. */ - BCReg baseslot; /* Current frame base, offset into J->slots. */ - - uint8_t mergesnap; /* Allowed to merge with next snapshot. */ - uint8_t needsnap; /* Need snapshot before recording next bytecode. */ - IRType1 guardemit; /* Accumulated IRT_GUARD for emitted instructions. */ - uint8_t bcskip; /* Number of bytecode instructions to skip. */ - - FoldState fold; /* Fold state. */ - - const BCIns *bc_min; /* Start of allowed bytecode range for root trace. */ - MSize bc_extent; /* Extent of the range. */ - - TraceState state; /* Trace compiler state. */ - - int32_t instunroll; /* Unroll counter for instable loops. */ - int32_t loopunroll; /* Unroll counter for loop ops in side traces. */ - int32_t tailcalled; /* Number of successive tailcalls. */ - int32_t framedepth; /* Current frame depth. */ - int32_t retdepth; /* Return frame depth (count of RETF). */ - - MRef k64; /* Pointer to chained array of 64 bit constants. */ - TValue ksimd[LJ_KSIMD__MAX*2+1]; /* 16 byte aligned SIMD constants. */ - - IRIns *irbuf; /* Temp. IR instruction buffer. Biased with REF_BIAS. */ - IRRef irtoplim; /* Upper limit of instuction buffer (biased). */ - IRRef irbotlim; /* Lower limit of instuction buffer (biased). */ - IRRef loopref; /* Last loop reference or ref of final LOOP (or 0). */ - - MSize sizesnap; /* Size of temp. snapshot buffer. */ - SnapShot *snapbuf; /* Temp. snapshot buffer. */ - SnapEntry *snapmapbuf; /* Temp. snapshot map buffer. */ - MSize sizesnapmap; /* Size of temp. snapshot map buffer. */ - - PostProc postproc; /* Required post-processing after execution. */ -#if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) - int needsplit; /* Need SPLIT pass. */ -#endif - - GCRef *trace; /* Array of traces. */ - TraceNo freetrace; /* Start of scan for next free trace. */ - MSize sizetrace; /* Size of trace array. */ - - IRRef1 chain[IR__MAX]; /* IR instruction skip-list chain anchors. */ - TRef slot[LJ_MAX_JSLOTS+LJ_STACK_EXTRA]; /* Stack slot map. */ - - int32_t param[JIT_P__MAX]; /* JIT engine parameters. */ - - MCode *exitstubgroup[LJ_MAX_EXITSTUBGR]; /* Exit stub group addresses. */ - - HotPenalty penalty[PENALTY_SLOTS]; /* Penalty slots. */ - uint32_t penaltyslot; /* Round-robin index into penalty slots. */ - uint32_t prngstate; /* PRNG state. */ - - BPropEntry bpropcache[BPROP_SLOTS]; /* Backpropagation cache slots. */ - uint32_t bpropslot; /* Round-robin index into bpropcache slots. */ - - ScEvEntry scev; /* Scalar evolution analysis cache slots. */ - - const BCIns *startpc; /* Bytecode PC of starting instruction. */ - TraceNo parent; /* Parent of current side trace (0 for root traces). */ - ExitNo exitno; /* Exit number in parent of current side trace. */ - - BCIns *patchpc; /* PC for pending re-patch. */ - BCIns patchins; /* Instruction for pending re-patch. */ - - int mcprot; /* Protection of current mcode area. */ - MCode *mcarea; /* Base of current mcode area. */ - MCode *mctop; /* Top of current mcode area. */ - MCode *mcbot; /* Bottom of current mcode area. */ - size_t szmcarea; /* Size of current mcode area. */ - size_t szallmcarea; /* Total size of all allocated mcode areas. */ - - TValue errinfo; /* Additional info element for trace errors. */ -} -#if LJ_TARGET_ARM -LJ_ALIGN(16) /* For DISPATCH-relative addresses in assembler part. */ -#endif -jit_State; - -/* Trivial PRNG e.g. used for penalty randomization. */ -static LJ_AINLINE uint32_t LJ_PRNG_BITS(jit_State *J, int bits) -{ - /* Yes, this LCG is very weak, but that doesn't matter for our use case. */ - J->prngstate = J->prngstate * 1103515245 + 12345; - return J->prngstate >> (32-bits); -} - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_lex.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_lex.c deleted file mode 100644 index 4fa39313f..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_lex.c +++ /dev/null @@ -1,481 +0,0 @@ -/* -** Lexical analyzer. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Major portions taken verbatim or adapted from the Lua interpreter. -** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h -*/ - -#define lj_lex_c -#define LUA_CORE - -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_str.h" -#if LJ_HASFFI -#include "lj_tab.h" -#include "lj_ctype.h" -#include "lj_cdata.h" -#include "lualib.h" -#endif -#include "lj_state.h" -#include "lj_lex.h" -#include "lj_parse.h" -#include "lj_char.h" -#include "lj_strscan.h" - -/* Lua lexer token names. */ -static const char *const tokennames[] = { -#define TKSTR1(name) #name, -#define TKSTR2(name, sym) #sym, -TKDEF(TKSTR1, TKSTR2) -#undef TKSTR1 -#undef TKSTR2 - NULL -}; - -/* -- Buffer handling ----------------------------------------------------- */ - -#define char2int(c) ((int)(uint8_t)(c)) -#define next(ls) \ - (ls->current = (ls->n--) > 0 ? char2int(*ls->p++) : fillbuf(ls)) -#define save_and_next(ls) (save(ls, ls->current), next(ls)) -#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r') -#define END_OF_STREAM (-1) - -static int fillbuf(LexState *ls) -{ - size_t sz; - const char *buf = ls->rfunc(ls->L, ls->rdata, &sz); - if (buf == NULL || sz == 0) return END_OF_STREAM; - ls->n = (MSize)sz - 1; - ls->p = buf; - return char2int(*(ls->p++)); -} - -static LJ_NOINLINE void save_grow(LexState *ls, int c) -{ - MSize newsize; - if (ls->sb.sz >= LJ_MAX_STR/2) - lj_lex_error(ls, 0, LJ_ERR_XELEM); - newsize = ls->sb.sz * 2; - lj_str_resizebuf(ls->L, &ls->sb, newsize); - ls->sb.buf[ls->sb.n++] = (char)c; -} - -static LJ_AINLINE void save(LexState *ls, int c) -{ - if (LJ_UNLIKELY(ls->sb.n + 1 > ls->sb.sz)) - save_grow(ls, c); - else - ls->sb.buf[ls->sb.n++] = (char)c; -} - -static void inclinenumber(LexState *ls) -{ - int old = ls->current; - lua_assert(currIsNewline(ls)); - next(ls); /* skip `\n' or `\r' */ - if (currIsNewline(ls) && ls->current != old) - next(ls); /* skip `\n\r' or `\r\n' */ - if (++ls->linenumber >= LJ_MAX_LINE) - lj_lex_error(ls, ls->token, LJ_ERR_XLINES); -} - -/* -- Scanner for terminals ----------------------------------------------- */ - -/* Parse a number literal. */ -static void lex_number(LexState *ls, TValue *tv) -{ - StrScanFmt fmt; - int c, xp = 'e'; - lua_assert(lj_char_isdigit(ls->current)); - if ((c = ls->current) == '0') { - save_and_next(ls); - if ((ls->current | 0x20) == 'x') xp = 'p'; - } - while (lj_char_isident(ls->current) || ls->current == '.' || - ((ls->current == '-' || ls->current == '+') && (c | 0x20) == xp)) { - c = ls->current; - save_and_next(ls); - } - save(ls, '\0'); - fmt = lj_strscan_scan((const uint8_t *)ls->sb.buf, tv, - (LJ_DUALNUM ? STRSCAN_OPT_TOINT : STRSCAN_OPT_TONUM) | - (LJ_HASFFI ? (STRSCAN_OPT_LL|STRSCAN_OPT_IMAG) : 0)); - if (LJ_DUALNUM && fmt == STRSCAN_INT) { - setitype(tv, LJ_TISNUM); - } else if (fmt == STRSCAN_NUM) { - /* Already in correct format. */ -#if LJ_HASFFI - } else if (fmt != STRSCAN_ERROR) { - lua_State *L = ls->L; - GCcdata *cd; - lua_assert(fmt == STRSCAN_I64 || fmt == STRSCAN_U64 || fmt == STRSCAN_IMAG); - if (!ctype_ctsG(G(L))) { - ptrdiff_t oldtop = savestack(L, L->top); - luaopen_ffi(L); /* Load FFI library on-demand. */ - L->top = restorestack(L, oldtop); - } - if (fmt == STRSCAN_IMAG) { - cd = lj_cdata_new_(L, CTID_COMPLEX_DOUBLE, 2*sizeof(double)); - ((double *)cdataptr(cd))[0] = 0; - ((double *)cdataptr(cd))[1] = numV(tv); - } else { - cd = lj_cdata_new_(L, fmt==STRSCAN_I64 ? CTID_INT64 : CTID_UINT64, 8); - *(uint64_t *)cdataptr(cd) = tv->u64; - } - lj_parse_keepcdata(ls, tv, cd); -#endif - } else { - lua_assert(fmt == STRSCAN_ERROR); - lj_lex_error(ls, TK_number, LJ_ERR_XNUMBER); - } -} - -static int skip_sep(LexState *ls) -{ - int count = 0; - int s = ls->current; - lua_assert(s == '[' || s == ']'); - save_and_next(ls); - while (ls->current == '=') { - save_and_next(ls); - count++; - } - return (ls->current == s) ? count : (-count) - 1; -} - -static void read_long_string(LexState *ls, TValue *tv, int sep) -{ - save_and_next(ls); /* skip 2nd `[' */ - if (currIsNewline(ls)) /* string starts with a newline? */ - inclinenumber(ls); /* skip it */ - for (;;) { - switch (ls->current) { - case END_OF_STREAM: - lj_lex_error(ls, TK_eof, tv ? LJ_ERR_XLSTR : LJ_ERR_XLCOM); - break; - case ']': - if (skip_sep(ls) == sep) { - save_and_next(ls); /* skip 2nd `]' */ - goto endloop; - } - break; - case '\n': - case '\r': - save(ls, '\n'); - inclinenumber(ls); - if (!tv) lj_str_resetbuf(&ls->sb); /* avoid wasting space */ - break; - default: - if (tv) save_and_next(ls); - else next(ls); - break; - } - } endloop: - if (tv) { - GCstr *str = lj_parse_keepstr(ls, ls->sb.buf + (2 + (MSize)sep), - ls->sb.n - 2*(2 + (MSize)sep)); - setstrV(ls->L, tv, str); - } -} - -static void read_string(LexState *ls, int delim, TValue *tv) -{ - save_and_next(ls); - while (ls->current != delim) { - switch (ls->current) { - case END_OF_STREAM: - lj_lex_error(ls, TK_eof, LJ_ERR_XSTR); - continue; - case '\n': - case '\r': - lj_lex_error(ls, TK_string, LJ_ERR_XSTR); - continue; - case '\\': { - int c = next(ls); /* Skip the '\\'. */ - switch (c) { - case 'a': c = '\a'; break; - case 'b': c = '\b'; break; - case 'f': c = '\f'; break; - case 'n': c = '\n'; break; - case 'r': c = '\r'; break; - case 't': c = '\t'; break; - case 'v': c = '\v'; break; - case 'x': /* Hexadecimal escape '\xXX'. */ - c = (next(ls) & 15u) << 4; - if (!lj_char_isdigit(ls->current)) { - if (!lj_char_isxdigit(ls->current)) goto err_xesc; - c += 9 << 4; - } - c += (next(ls) & 15u); - if (!lj_char_isdigit(ls->current)) { - if (!lj_char_isxdigit(ls->current)) goto err_xesc; - c += 9; - } - break; - case 'z': /* Skip whitespace. */ - next(ls); - while (lj_char_isspace(ls->current)) - if (currIsNewline(ls)) inclinenumber(ls); else next(ls); - continue; - case '\n': case '\r': save(ls, '\n'); inclinenumber(ls); continue; - case '\\': case '\"': case '\'': break; - case END_OF_STREAM: continue; - default: - if (!lj_char_isdigit(c)) - goto err_xesc; - c -= '0'; /* Decimal escape '\ddd'. */ - if (lj_char_isdigit(next(ls))) { - c = c*10 + (ls->current - '0'); - if (lj_char_isdigit(next(ls))) { - c = c*10 + (ls->current - '0'); - if (c > 255) { - err_xesc: - lj_lex_error(ls, TK_string, LJ_ERR_XESC); - } - next(ls); - } - } - save(ls, c); - continue; - } - save(ls, c); - next(ls); - continue; - } - default: - save_and_next(ls); - break; - } - } - save_and_next(ls); /* skip delimiter */ - setstrV(ls->L, tv, lj_parse_keepstr(ls, ls->sb.buf + 1, ls->sb.n - 2)); -} - -/* -- Main lexical scanner ------------------------------------------------ */ - -static int llex(LexState *ls, TValue *tv) -{ - lj_str_resetbuf(&ls->sb); - for (;;) { - if (lj_char_isident(ls->current)) { - GCstr *s; - if (lj_char_isdigit(ls->current)) { /* Numeric literal. */ - lex_number(ls, tv); - return TK_number; - } - /* Identifier or reserved word. */ - do { - save_and_next(ls); - } while (lj_char_isident(ls->current)); - s = lj_parse_keepstr(ls, ls->sb.buf, ls->sb.n); - setstrV(ls->L, tv, s); - if (s->reserved > 0) /* Reserved word? */ - return TK_OFS + s->reserved; - return TK_name; - } - switch (ls->current) { - case '\n': - case '\r': - inclinenumber(ls); - continue; - case ' ': - case '\t': - case '\v': - case '\f': - next(ls); - continue; - case '-': - next(ls); - if (ls->current != '-') return '-'; - /* else is a comment */ - next(ls); - if (ls->current == '[') { - int sep = skip_sep(ls); - lj_str_resetbuf(&ls->sb); /* `skip_sep' may dirty the buffer */ - if (sep >= 0) { - read_long_string(ls, NULL, sep); /* long comment */ - lj_str_resetbuf(&ls->sb); - continue; - } - } - /* else short comment */ - while (!currIsNewline(ls) && ls->current != END_OF_STREAM) - next(ls); - continue; - case '[': { - int sep = skip_sep(ls); - if (sep >= 0) { - read_long_string(ls, tv, sep); - return TK_string; - } else if (sep == -1) { - return '['; - } else { - lj_lex_error(ls, TK_string, LJ_ERR_XLDELIM); - continue; - } - } - case '=': - next(ls); - if (ls->current != '=') return '='; else { next(ls); return TK_eq; } - case '<': - next(ls); - if (ls->current != '=') return '<'; else { next(ls); return TK_le; } - case '>': - next(ls); - if (ls->current != '=') return '>'; else { next(ls); return TK_ge; } - case '~': - next(ls); - if (ls->current != '=') return '~'; else { next(ls); return TK_ne; } - case ':': - next(ls); - if (ls->current != ':') return ':'; else { next(ls); return TK_label; } - case '"': - case '\'': - read_string(ls, ls->current, tv); - return TK_string; - case '.': - save_and_next(ls); - if (ls->current == '.') { - next(ls); - if (ls->current == '.') { - next(ls); - return TK_dots; /* ... */ - } - return TK_concat; /* .. */ - } else if (!lj_char_isdigit(ls->current)) { - return '.'; - } else { - lex_number(ls, tv); - return TK_number; - } - case END_OF_STREAM: - return TK_eof; - default: { - int c = ls->current; - next(ls); - return c; /* Single-char tokens (+ - / ...). */ - } - } - } -} - -/* -- Lexer API ----------------------------------------------------------- */ - -/* Setup lexer state. */ -int lj_lex_setup(lua_State *L, LexState *ls) -{ - int header = 0; - ls->L = L; - ls->fs = NULL; - ls->n = 0; - ls->p = NULL; - ls->vstack = NULL; - ls->sizevstack = 0; - ls->vtop = 0; - ls->bcstack = NULL; - ls->sizebcstack = 0; - ls->lookahead = TK_eof; /* No look-ahead token. */ - ls->linenumber = 1; - ls->lastline = 1; - lj_str_resizebuf(ls->L, &ls->sb, LJ_MIN_SBUF); - next(ls); /* Read-ahead first char. */ - if (ls->current == 0xef && ls->n >= 2 && char2int(ls->p[0]) == 0xbb && - char2int(ls->p[1]) == 0xbf) { /* Skip UTF-8 BOM (if buffered). */ - ls->n -= 2; - ls->p += 2; - next(ls); - header = 1; - } - if (ls->current == '#') { /* Skip POSIX #! header line. */ - do { - next(ls); - if (ls->current == END_OF_STREAM) return 0; - } while (!currIsNewline(ls)); - inclinenumber(ls); - header = 1; - } - if (ls->current == LUA_SIGNATURE[0]) { /* Bytecode dump. */ - if (header) { - /* - ** Loading bytecode with an extra header is disabled for security - ** reasons. This may circumvent the usual check for bytecode vs. - ** Lua code by looking at the first char. Since this is a potential - ** security violation no attempt is made to echo the chunkname either. - */ - setstrV(L, L->top++, lj_err_str(L, LJ_ERR_BCBAD)); - lj_err_throw(L, LUA_ERRSYNTAX); - } - return 1; - } - return 0; -} - -/* Cleanup lexer state. */ -void lj_lex_cleanup(lua_State *L, LexState *ls) -{ - global_State *g = G(L); - lj_mem_freevec(g, ls->bcstack, ls->sizebcstack, BCInsLine); - lj_mem_freevec(g, ls->vstack, ls->sizevstack, VarInfo); - lj_str_freebuf(g, &ls->sb); -} - -void lj_lex_next(LexState *ls) -{ - ls->lastline = ls->linenumber; - if (LJ_LIKELY(ls->lookahead == TK_eof)) { /* No lookahead token? */ - ls->token = llex(ls, &ls->tokenval); /* Get next token. */ - } else { /* Otherwise return lookahead token. */ - ls->token = ls->lookahead; - ls->lookahead = TK_eof; - ls->tokenval = ls->lookaheadval; - } -} - -LexToken lj_lex_lookahead(LexState *ls) -{ - lua_assert(ls->lookahead == TK_eof); - ls->lookahead = llex(ls, &ls->lookaheadval); - return ls->lookahead; -} - -const char *lj_lex_token2str(LexState *ls, LexToken token) -{ - if (token > TK_OFS) - return tokennames[token-TK_OFS-1]; - else if (!lj_char_iscntrl(token)) - return lj_str_pushf(ls->L, "%c", token); - else - return lj_str_pushf(ls->L, "char(%d)", token); -} - -void lj_lex_error(LexState *ls, LexToken token, ErrMsg em, ...) -{ - const char *tok; - va_list argp; - if (token == 0) { - tok = NULL; - } else if (token == TK_name || token == TK_string || token == TK_number) { - save(ls, '\0'); - tok = ls->sb.buf; - } else { - tok = lj_lex_token2str(ls, token); - } - va_start(argp, em); - lj_err_lex(ls->L, ls->chunkname, tok, ls->linenumber, em, argp); - va_end(argp); -} - -void lj_lex_init(lua_State *L) -{ - uint32_t i; - for (i = 0; i < TK_RESERVED; i++) { - GCstr *s = lj_str_newz(L, tokennames[i]); - fixstring(s); /* Reserved words are never collected. */ - s->reserved = (uint8_t)(i+1); - } -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_lex.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_lex.h deleted file mode 100644 index a7ff29a01..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_lex.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -** Lexical analyzer. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_LEX_H -#define _LJ_LEX_H - -#include - -#include "lj_obj.h" -#include "lj_err.h" - -/* Lua lexer tokens. */ -#define TKDEF(_, __) \ - _(and) _(break) _(do) _(else) _(elseif) _(end) _(false) \ - _(for) _(function) _(goto) _(if) _(in) _(local) _(nil) _(not) _(or) \ - _(repeat) _(return) _(then) _(true) _(until) _(while) \ - __(concat, ..) __(dots, ...) __(eq, ==) __(ge, >=) __(le, <=) __(ne, ~=) \ - __(label, ::) __(number, ) __(name, ) __(string, ) \ - __(eof, ) - -enum { - TK_OFS = 256, -#define TKENUM1(name) TK_##name, -#define TKENUM2(name, sym) TK_##name, -TKDEF(TKENUM1, TKENUM2) -#undef TKENUM1 -#undef TKENUM2 - TK_RESERVED = TK_while - TK_OFS -}; - -typedef int LexToken; - -/* Combined bytecode ins/line. Only used during bytecode generation. */ -typedef struct BCInsLine { - BCIns ins; /* Bytecode instruction. */ - BCLine line; /* Line number for this bytecode. */ -} BCInsLine; - -/* Info for local variables. Only used during bytecode generation. */ -typedef struct VarInfo { - GCRef name; /* Local variable name or goto/label name. */ - BCPos startpc; /* First point where the local variable is active. */ - BCPos endpc; /* First point where the local variable is dead. */ - uint8_t slot; /* Variable slot. */ - uint8_t info; /* Variable/goto/label info. */ -} VarInfo; - -/* Lua lexer state. */ -typedef struct LexState { - struct FuncState *fs; /* Current FuncState. Defined in lj_parse.c. */ - struct lua_State *L; /* Lua state. */ - TValue tokenval; /* Current token value. */ - TValue lookaheadval; /* Lookahead token value. */ - int current; /* Current character (charint). */ - LexToken token; /* Current token. */ - LexToken lookahead; /* Lookahead token. */ - MSize n; /* Bytes left in input buffer. */ - const char *p; /* Current position in input buffer. */ - SBuf sb; /* String buffer for tokens. */ - lua_Reader rfunc; /* Reader callback. */ - void *rdata; /* Reader callback data. */ - BCLine linenumber; /* Input line counter. */ - BCLine lastline; /* Line of last token. */ - GCstr *chunkname; /* Current chunk name (interned string). */ - const char *chunkarg; /* Chunk name argument. */ - const char *mode; /* Allow loading bytecode (b) and/or source text (t). */ - VarInfo *vstack; /* Stack for names and extents of local variables. */ - MSize sizevstack; /* Size of variable stack. */ - MSize vtop; /* Top of variable stack. */ - BCInsLine *bcstack; /* Stack for bytecode instructions/line numbers. */ - MSize sizebcstack; /* Size of bytecode stack. */ - uint32_t level; /* Syntactical nesting level. */ -} LexState; - -LJ_FUNC int lj_lex_setup(lua_State *L, LexState *ls); -LJ_FUNC void lj_lex_cleanup(lua_State *L, LexState *ls); -LJ_FUNC void lj_lex_next(LexState *ls); -LJ_FUNC LexToken lj_lex_lookahead(LexState *ls); -LJ_FUNC const char *lj_lex_token2str(LexState *ls, LexToken token); -LJ_FUNC_NORET void lj_lex_error(LexState *ls, LexToken token, ErrMsg em, ...); -LJ_FUNC void lj_lex_init(lua_State *L); - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_lib.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_lib.c deleted file mode 100644 index 76c8a064a..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_lib.c +++ /dev/null @@ -1,258 +0,0 @@ -/* -** Library function support. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_lib_c -#define LUA_CORE - -#include "lauxlib.h" - -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_func.h" -#include "lj_bc.h" -#include "lj_dispatch.h" -#include "lj_vm.h" -#include "lj_strscan.h" -#include "lj_lib.h" - -/* -- Library initialization ---------------------------------------------- */ - -static GCtab *lib_create_table(lua_State *L, const char *libname, int hsize) -{ - if (libname) { - luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 16); - lua_getfield(L, -1, libname); - if (!tvistab(L->top-1)) { - L->top--; - if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, hsize) != NULL) - lj_err_callerv(L, LJ_ERR_BADMODN, libname); - settabV(L, L->top, tabV(L->top-1)); - L->top++; - lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ - } - L->top--; - settabV(L, L->top-1, tabV(L->top)); - } else { - lua_createtable(L, 0, hsize); - } - return tabV(L->top-1); -} - -void lj_lib_register(lua_State *L, const char *libname, - const uint8_t *p, const lua_CFunction *cf) -{ - GCtab *env = tabref(L->env); - GCfunc *ofn = NULL; - int ffid = *p++; - BCIns *bcff = &L2GG(L)->bcff[*p++]; - GCtab *tab = lib_create_table(L, libname, *p++); - ptrdiff_t tpos = L->top - L->base; - - /* Avoid barriers further down. */ - lj_gc_anybarriert(L, tab); - tab->nomm = 0; - - for (;;) { - uint32_t tag = *p++; - MSize len = tag & LIBINIT_LENMASK; - tag &= LIBINIT_TAGMASK; - if (tag != LIBINIT_STRING) { - const char *name; - MSize nuv = (MSize)(L->top - L->base - tpos); - GCfunc *fn = lj_func_newC(L, nuv, env); - if (nuv) { - L->top = L->base + tpos; - memcpy(fn->c.upvalue, L->top, sizeof(TValue)*nuv); - } - fn->c.ffid = (uint8_t)(ffid++); - name = (const char *)p; - p += len; - if (tag == LIBINIT_CF) - setmref(fn->c.pc, &G(L)->bc_cfunc_int); - else - setmref(fn->c.pc, bcff++); - if (tag == LIBINIT_ASM_) - fn->c.f = ofn->c.f; /* Copy handler from previous function. */ - else - fn->c.f = *cf++; /* Get cf or handler from C function table. */ - if (len) { - /* NOBARRIER: See above for common barrier. */ - setfuncV(L, lj_tab_setstr(L, tab, lj_str_new(L, name, len)), fn); - } - ofn = fn; - } else { - switch (tag | len) { - case LIBINIT_SET: - L->top -= 2; - if (tvisstr(L->top+1) && strV(L->top+1)->len == 0) - env = tabV(L->top); - else /* NOBARRIER: See above for common barrier. */ - copyTV(L, lj_tab_set(L, tab, L->top+1), L->top); - break; - case LIBINIT_NUMBER: - memcpy(&L->top->n, p, sizeof(double)); - L->top++; - p += sizeof(double); - break; - case LIBINIT_COPY: - copyTV(L, L->top, L->top - *p++); - L->top++; - break; - case LIBINIT_LASTCL: - setfuncV(L, L->top++, ofn); - break; - case LIBINIT_FFID: - ffid++; - break; - case LIBINIT_END: - return; - default: - setstrV(L, L->top++, lj_str_new(L, (const char *)p, len)); - p += len; - break; - } - } - } -} - -/* -- Type checks --------------------------------------------------------- */ - -TValue *lj_lib_checkany(lua_State *L, int narg) -{ - TValue *o = L->base + narg-1; - if (o >= L->top) - lj_err_arg(L, narg, LJ_ERR_NOVAL); - return o; -} - -GCstr *lj_lib_checkstr(lua_State *L, int narg) -{ - TValue *o = L->base + narg-1; - if (o < L->top) { - if (LJ_LIKELY(tvisstr(o))) { - return strV(o); - } else if (tvisnumber(o)) { - GCstr *s = lj_str_fromnumber(L, o); - setstrV(L, o, s); - return s; - } - } - lj_err_argt(L, narg, LUA_TSTRING); - return NULL; /* unreachable */ -} - -GCstr *lj_lib_optstr(lua_State *L, int narg) -{ - TValue *o = L->base + narg-1; - return (o < L->top && !tvisnil(o)) ? lj_lib_checkstr(L, narg) : NULL; -} - -#if LJ_DUALNUM -void lj_lib_checknumber(lua_State *L, int narg) -{ - TValue *o = L->base + narg-1; - if (!(o < L->top && lj_strscan_numberobj(o))) - lj_err_argt(L, narg, LUA_TNUMBER); -} -#endif - -lua_Number lj_lib_checknum(lua_State *L, int narg) -{ - TValue *o = L->base + narg-1; - if (!(o < L->top && - (tvisnumber(o) || (tvisstr(o) && lj_strscan_num(strV(o), o))))) - lj_err_argt(L, narg, LUA_TNUMBER); - if (LJ_UNLIKELY(tvisint(o))) { - lua_Number n = (lua_Number)intV(o); - setnumV(o, n); - return n; - } else { - return numV(o); - } -} - -int32_t lj_lib_checkint(lua_State *L, int narg) -{ - TValue *o = L->base + narg-1; - if (!(o < L->top && lj_strscan_numberobj(o))) - lj_err_argt(L, narg, LUA_TNUMBER); - if (LJ_LIKELY(tvisint(o))) { - return intV(o); - } else { - int32_t i = lj_num2int(numV(o)); - if (LJ_DUALNUM) setintV(o, i); - return i; - } -} - -int32_t lj_lib_optint(lua_State *L, int narg, int32_t def) -{ - TValue *o = L->base + narg-1; - return (o < L->top && !tvisnil(o)) ? lj_lib_checkint(L, narg) : def; -} - -int32_t lj_lib_checkbit(lua_State *L, int narg) -{ - TValue *o = L->base + narg-1; - if (!(o < L->top && lj_strscan_numberobj(o))) - lj_err_argt(L, narg, LUA_TNUMBER); - if (LJ_LIKELY(tvisint(o))) { - return intV(o); - } else { - int32_t i = lj_num2bit(numV(o)); - if (LJ_DUALNUM) setintV(o, i); - return i; - } -} - -GCfunc *lj_lib_checkfunc(lua_State *L, int narg) -{ - TValue *o = L->base + narg-1; - if (!(o < L->top && tvisfunc(o))) - lj_err_argt(L, narg, LUA_TFUNCTION); - return funcV(o); -} - -GCtab *lj_lib_checktab(lua_State *L, int narg) -{ - TValue *o = L->base + narg-1; - if (!(o < L->top && tvistab(o))) - lj_err_argt(L, narg, LUA_TTABLE); - return tabV(o); -} - -GCtab *lj_lib_checktabornil(lua_State *L, int narg) -{ - TValue *o = L->base + narg-1; - if (o < L->top) { - if (tvistab(o)) - return tabV(o); - else if (tvisnil(o)) - return NULL; - } - lj_err_arg(L, narg, LJ_ERR_NOTABN); - return NULL; /* unreachable */ -} - -int lj_lib_checkopt(lua_State *L, int narg, int def, const char *lst) -{ - GCstr *s = def >= 0 ? lj_lib_optstr(L, narg) : lj_lib_checkstr(L, narg); - if (s) { - const char *opt = strdata(s); - MSize len = s->len; - int i; - for (i = 0; *(const uint8_t *)lst; i++) { - if (*(const uint8_t *)lst == len && memcmp(opt, lst+1, len) == 0) - return i; - lst += 1+*(const uint8_t *)lst; - } - lj_err_argv(L, narg, LJ_ERR_INVOPTM, opt); - } - return def; -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_lib.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_lib.h deleted file mode 100644 index daacb9213..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_lib.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -** Library function support. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_LIB_H -#define _LJ_LIB_H - -#include "lj_obj.h" - -/* -** A fallback handler is called by the assembler VM if the fast path fails: -** -** - too few arguments: unrecoverable. -** - wrong argument type: recoverable, if coercion succeeds. -** - bad argument value: unrecoverable. -** - stack overflow: recoverable, if stack reallocation succeeds. -** - extra handling: recoverable. -** -** The unrecoverable cases throw an error with lj_err_arg(), lj_err_argtype(), -** lj_err_caller() or lj_err_callermsg(). -** The recoverable cases return 0 or the number of results + 1. -** The assembler VM retries the fast path only if 0 is returned. -** This time the fallback must not be called again or it gets stuck in a loop. -*/ - -/* Return values from fallback handler. */ -#define FFH_RETRY 0 -#define FFH_UNREACHABLE FFH_RETRY -#define FFH_RES(n) ((n)+1) -#define FFH_TAILCALL (-1) - -LJ_FUNC TValue *lj_lib_checkany(lua_State *L, int narg); -LJ_FUNC GCstr *lj_lib_checkstr(lua_State *L, int narg); -LJ_FUNC GCstr *lj_lib_optstr(lua_State *L, int narg); -#if LJ_DUALNUM -LJ_FUNC void lj_lib_checknumber(lua_State *L, int narg); -#else -#define lj_lib_checknumber(L, narg) lj_lib_checknum((L), (narg)) -#endif -LJ_FUNC lua_Number lj_lib_checknum(lua_State *L, int narg); -LJ_FUNC int32_t lj_lib_checkint(lua_State *L, int narg); -LJ_FUNC int32_t lj_lib_optint(lua_State *L, int narg, int32_t def); -LJ_FUNC int32_t lj_lib_checkbit(lua_State *L, int narg); -LJ_FUNC GCfunc *lj_lib_checkfunc(lua_State *L, int narg); -LJ_FUNC GCtab *lj_lib_checktab(lua_State *L, int narg); -LJ_FUNC GCtab *lj_lib_checktabornil(lua_State *L, int narg); -LJ_FUNC int lj_lib_checkopt(lua_State *L, int narg, int def, const char *lst); - -/* Avoid including lj_frame.h. */ -#define lj_lib_upvalue(L, n) \ - (&gcref((L->base-1)->fr.func)->fn.c.upvalue[(n)-1]) - -#if LJ_TARGET_WINDOWS -#define lj_lib_checkfpu(L) \ - do { setnumV(L->top++, (lua_Number)1437217655); \ - if (lua_tointeger(L, -1) != 1437217655) lj_err_caller(L, LJ_ERR_BADFPU); \ - L->top--; } while (0) -#else -#define lj_lib_checkfpu(L) UNUSED(L) -#endif - -/* Push internal function on the stack. */ -static LJ_AINLINE void lj_lib_pushcc(lua_State *L, lua_CFunction f, - int id, int n) -{ - GCfunc *fn; - lua_pushcclosure(L, f, n); - fn = funcV(L->top-1); - fn->c.ffid = (uint8_t)id; - setmref(fn->c.pc, &G(L)->bc_cfunc_int); -} - -#define lj_lib_pushcf(L, fn, id) (lj_lib_pushcc(L, (fn), (id), 0)) - -/* Library function declarations. Scanned by buildvm. */ -#define LJLIB_CF(name) static int lj_cf_##name(lua_State *L) -#define LJLIB_ASM(name) static int lj_ffh_##name(lua_State *L) -#define LJLIB_ASM_(name) -#define LJLIB_SET(name) -#define LJLIB_PUSH(arg) -#define LJLIB_REC(handler) -#define LJLIB_NOREGUV -#define LJLIB_NOREG - -#define LJ_LIB_REG(L, regname, name) \ - lj_lib_register(L, regname, lj_lib_init_##name, lj_lib_cf_##name) - -LJ_FUNC void lj_lib_register(lua_State *L, const char *libname, - const uint8_t *init, const lua_CFunction *cf); - -/* Library init data tags. */ -#define LIBINIT_LENMASK 0x3f -#define LIBINIT_TAGMASK 0xc0 -#define LIBINIT_CF 0x00 -#define LIBINIT_ASM 0x40 -#define LIBINIT_ASM_ 0x80 -#define LIBINIT_STRING 0xc0 -#define LIBINIT_MAXSTR 0x39 -#define LIBINIT_SET 0xfa -#define LIBINIT_NUMBER 0xfb -#define LIBINIT_COPY 0xfc -#define LIBINIT_LASTCL 0xfd -#define LIBINIT_FFID 0xfe -#define LIBINIT_END 0xff - -/* Exported library functions. */ - -typedef struct RandomState RandomState; -LJ_FUNC uint64_t LJ_FASTCALL lj_math_random_step(RandomState *rs); - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_load.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_load.c deleted file mode 100644 index edfdc9037..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_load.c +++ /dev/null @@ -1,168 +0,0 @@ -/* -** Load and dump code. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#include -#include - -#define lj_load_c -#define LUA_CORE - -#include "lua.h" -#include "lauxlib.h" - -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_str.h" -#include "lj_func.h" -#include "lj_frame.h" -#include "lj_vm.h" -#include "lj_lex.h" -#include "lj_bcdump.h" -#include "lj_parse.h" - -/* -- Load Lua source code and bytecode ----------------------------------- */ - -static TValue *cpparser(lua_State *L, lua_CFunction dummy, void *ud) -{ - LexState *ls = (LexState *)ud; - GCproto *pt; - GCfunc *fn; - int bc; - UNUSED(dummy); - cframe_errfunc(L->cframe) = -1; /* Inherit error function. */ - bc = lj_lex_setup(L, ls); - if (ls->mode && !strchr(ls->mode, bc ? 'b' : 't')) { - setstrV(L, L->top++, lj_err_str(L, LJ_ERR_XMODE)); - lj_err_throw(L, LUA_ERRSYNTAX); - } - pt = bc ? lj_bcread(ls) : lj_parse(ls); - fn = lj_func_newL_empty(L, pt, tabref(L->env)); - /* Don't combine above/below into one statement. */ - setfuncV(L, L->top++, fn); - return NULL; -} - -LUA_API int lua_loadx(lua_State *L, lua_Reader reader, void *data, - const char *chunkname, const char *mode) -{ - LexState ls; - int status; - ls.rfunc = reader; - ls.rdata = data; - ls.chunkarg = chunkname ? chunkname : "?"; - ls.mode = mode; - lj_str_initbuf(&ls.sb); - status = lj_vm_cpcall(L, NULL, &ls, cpparser); - lj_lex_cleanup(L, &ls); - lj_gc_check(L); - return status; -} - -LUA_API int lua_load(lua_State *L, lua_Reader reader, void *data, - const char *chunkname) -{ - return lua_loadx(L, reader, data, chunkname, NULL); -} - -typedef struct FileReaderCtx { - FILE *fp; - char buf[LUAL_BUFFERSIZE]; -} FileReaderCtx; - -static const char *reader_file(lua_State *L, void *ud, size_t *size) -{ - FileReaderCtx *ctx = (FileReaderCtx *)ud; - UNUSED(L); - if (feof(ctx->fp)) return NULL; - *size = fread(ctx->buf, 1, sizeof(ctx->buf), ctx->fp); - return *size > 0 ? ctx->buf : NULL; -} - -LUALIB_API int luaL_loadfilex(lua_State *L, const char *filename, - const char *mode) -{ - FileReaderCtx ctx; - int status; - const char *chunkname; - if (filename) { - ctx.fp = fopen(filename, "rb"); - if (ctx.fp == NULL) { - lua_pushfstring(L, "cannot open %s: %s", filename, strerror(errno)); - return LUA_ERRFILE; - } - chunkname = lua_pushfstring(L, "@%s", filename); - } else { - ctx.fp = stdin; - chunkname = "=stdin"; - } - status = lua_loadx(L, reader_file, &ctx, chunkname, mode); - if (ferror(ctx.fp)) { - L->top -= filename ? 2 : 1; - lua_pushfstring(L, "cannot read %s: %s", chunkname+1, strerror(errno)); - if (filename) - fclose(ctx.fp); - return LUA_ERRFILE; - } - if (filename) { - L->top--; - copyTV(L, L->top-1, L->top); - fclose(ctx.fp); - } - return status; -} - -LUALIB_API int luaL_loadfile(lua_State *L, const char *filename) -{ - return luaL_loadfilex(L, filename, NULL); -} - -typedef struct StringReaderCtx { - const char *str; - size_t size; -} StringReaderCtx; - -static const char *reader_string(lua_State *L, void *ud, size_t *size) -{ - StringReaderCtx *ctx = (StringReaderCtx *)ud; - UNUSED(L); - if (ctx->size == 0) return NULL; - *size = ctx->size; - ctx->size = 0; - return ctx->str; -} - -LUALIB_API int luaL_loadbufferx(lua_State *L, const char *buf, size_t size, - const char *name, const char *mode) -{ - StringReaderCtx ctx; - ctx.str = buf; - ctx.size = size; - return lua_loadx(L, reader_string, &ctx, name, mode); -} - -LUALIB_API int luaL_loadbuffer(lua_State *L, const char *buf, size_t size, - const char *name) -{ - return luaL_loadbufferx(L, buf, size, name, NULL); -} - -LUALIB_API int luaL_loadstring(lua_State *L, const char *s) -{ - return luaL_loadbuffer(L, s, strlen(s), s); -} - -/* -- Dump bytecode ------------------------------------------------------- */ - -LUA_API int lua_dump(lua_State *L, lua_Writer writer, void *data) -{ - cTValue *o = L->top-1; - api_check(L, L->top > L->base); - if (tvisfunc(o) && isluafunc(funcV(o))) - return lj_bcwrite(L, funcproto(funcV(o)), writer, data, 0); - else - return 1; -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_mcode.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_mcode.c deleted file mode 100644 index 5a7329607..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_mcode.c +++ /dev/null @@ -1,373 +0,0 @@ -/* -** Machine code management. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_mcode_c -#define LUA_CORE - -#include "lj_obj.h" -#if LJ_HASJIT -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_jit.h" -#include "lj_mcode.h" -#include "lj_trace.h" -#include "lj_dispatch.h" -#endif -#if LJ_HASJIT || LJ_HASFFI -#include "lj_vm.h" -#endif - -/* -- OS-specific functions ----------------------------------------------- */ - -#if LJ_HASJIT || LJ_HASFFI - -/* Define this if you want to run LuaJIT with Valgrind. */ -#ifdef LUAJIT_USE_VALGRIND -#include -#endif - -#if LJ_TARGET_IOS -void sys_icache_invalidate(void *start, size_t len); -#endif - -/* Synchronize data/instruction cache. */ -void lj_mcode_sync(void *start, void *end) -{ -#ifdef LUAJIT_USE_VALGRIND - VALGRIND_DISCARD_TRANSLATIONS(start, (char *)end-(char *)start); -#endif -#if LJ_TARGET_X86ORX64 - UNUSED(start); UNUSED(end); -#elif LJ_TARGET_IOS - sys_icache_invalidate(start, (char *)end-(char *)start); -#elif LJ_TARGET_PPC - lj_vm_cachesync(start, end); -#elif defined(__GNUC__) - __clear_cache(start, end); -#else -#error "Missing builtin to flush instruction cache" -#endif -} - -#endif - -#if LJ_HASJIT - -#if LJ_TARGET_WINDOWS - -#define WIN32_LEAN_AND_MEAN -#include - -#define MCPROT_RW PAGE_READWRITE -#define MCPROT_RX PAGE_EXECUTE_READ -#define MCPROT_RWX PAGE_EXECUTE_READWRITE - -static void *mcode_alloc_at(jit_State *J, uintptr_t hint, size_t sz, DWORD prot) -{ - void *p = VirtualAlloc((void *)hint, sz, - MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, prot); - if (!p && !hint) - lj_trace_err(J, LJ_TRERR_MCODEAL); - return p; -} - -static void mcode_free(jit_State *J, void *p, size_t sz) -{ - UNUSED(J); UNUSED(sz); - VirtualFree(p, 0, MEM_RELEASE); -} - -static int mcode_setprot(void *p, size_t sz, DWORD prot) -{ - DWORD oprot; - return !VirtualProtect(p, sz, prot, &oprot); -} - -#elif LJ_TARGET_POSIX - -#include - -#ifndef MAP_ANONYMOUS -#define MAP_ANONYMOUS MAP_ANON -#endif - -#define MCPROT_RW (PROT_READ|PROT_WRITE) -#define MCPROT_RX (PROT_READ|PROT_EXEC) -#define MCPROT_RWX (PROT_READ|PROT_WRITE|PROT_EXEC) - -static void *mcode_alloc_at(jit_State *J, uintptr_t hint, size_t sz, int prot) -{ - void *p = mmap((void *)hint, sz, prot, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); - if (p == MAP_FAILED) { - if (!hint) lj_trace_err(J, LJ_TRERR_MCODEAL); - p = NULL; - } - return p; -} - -static void mcode_free(jit_State *J, void *p, size_t sz) -{ - UNUSED(J); - munmap(p, sz); -} - -static int mcode_setprot(void *p, size_t sz, int prot) -{ - return mprotect(p, sz, prot); -} - -#elif LJ_64 - -#error "Missing OS support for explicit placement of executable memory" - -#else - -/* Fallback allocator. This will fail if memory is not executable by default. */ -#define LUAJIT_UNPROTECT_MCODE -#define MCPROT_RW 0 -#define MCPROT_RX 0 -#define MCPROT_RWX 0 - -static void *mcode_alloc_at(jit_State *J, uintptr_t hint, size_t sz, int prot) -{ - UNUSED(hint); UNUSED(prot); - return lj_mem_new(J->L, sz); -} - -static void mcode_free(jit_State *J, void *p, size_t sz) -{ - lj_mem_free(J2G(J), p, sz); -} - -#endif - -/* -- MCode area protection ----------------------------------------------- */ - -/* Define this ONLY if the page protection twiddling becomes a bottleneck. */ -#ifdef LUAJIT_UNPROTECT_MCODE - -/* It's generally considered to be a potential security risk to have -** pages with simultaneous write *and* execute access in a process. -** -** Do not even think about using this mode for server processes or -** apps handling untrusted external data (such as a browser). -** -** The security risk is not in LuaJIT itself -- but if an adversary finds -** any *other* flaw in your C application logic, then any RWX memory page -** simplifies writing an exploit considerably. -*/ -#define MCPROT_GEN MCPROT_RWX -#define MCPROT_RUN MCPROT_RWX - -static void mcode_protect(jit_State *J, int prot) -{ - UNUSED(J); UNUSED(prot); -} - -#else - -/* This is the default behaviour and much safer: -** -** Most of the time the memory pages holding machine code are executable, -** but NONE of them is writable. -** -** The current memory area is marked read-write (but NOT executable) only -** during the short time window while the assembler generates machine code. -*/ -#define MCPROT_GEN MCPROT_RW -#define MCPROT_RUN MCPROT_RX - -/* Protection twiddling failed. Probably due to kernel security. */ -static LJ_NOINLINE void mcode_protfail(jit_State *J) -{ - lua_CFunction panic = J2G(J)->panic; - if (panic) { - lua_State *L = J->L; - setstrV(L, L->top++, lj_err_str(L, LJ_ERR_JITPROT)); - panic(L); - } -} - -/* Change protection of MCode area. */ -static void mcode_protect(jit_State *J, int prot) -{ - if (J->mcprot != prot) { - if (LJ_UNLIKELY(mcode_setprot(J->mcarea, J->szmcarea, prot))) - mcode_protfail(J); - J->mcprot = prot; - } -} - -#endif - -/* -- MCode area allocation ----------------------------------------------- */ - -#if LJ_TARGET_X64 -#define mcode_validptr(p) ((p) && (uintptr_t)(p) < (uintptr_t)1<<47) -#else -#define mcode_validptr(p) ((p) && (uintptr_t)(p) < 0xffff0000) -#endif - -#ifdef LJ_TARGET_JUMPRANGE - -/* Get memory within relative jump distance of our code in 64 bit mode. */ -static void *mcode_alloc(jit_State *J, size_t sz) -{ - /* Target an address in the static assembler code (64K aligned). - ** Try addresses within a distance of target-range/2+1MB..target+range/2-1MB. - ** Use half the jump range so every address in the range can reach any other. - */ -#if LJ_TARGET_MIPS - /* Use the middle of the 256MB-aligned region. */ - uintptr_t target = ((uintptr_t)(void *)lj_vm_exit_handler & 0xf0000000u) + - 0x08000000u; -#else - uintptr_t target = (uintptr_t)(void *)lj_vm_exit_handler & ~(uintptr_t)0xffff; -#endif - const uintptr_t range = (1u << (LJ_TARGET_JUMPRANGE-1)) - (1u << 21); - /* First try a contiguous area below the last one. */ - uintptr_t hint = J->mcarea ? (uintptr_t)J->mcarea - sz : 0; - int i; - for (i = 0; i < 32; i++) { /* 32 attempts ought to be enough ... */ - if (mcode_validptr(hint)) { - void *p = mcode_alloc_at(J, hint, sz, MCPROT_GEN); - - if (mcode_validptr(p) && - ((uintptr_t)p + sz - target < range || target - (uintptr_t)p < range)) - return p; - if (p) mcode_free(J, p, sz); /* Free badly placed area. */ - } - /* Next try probing pseudo-random addresses. */ - do { - hint = (0x78fb ^ LJ_PRNG_BITS(J, 15)) << 16; /* 64K aligned. */ - } while (!(hint + sz < range)); - hint = target + hint - (range>>1); - } - lj_trace_err(J, LJ_TRERR_MCODEAL); /* Give up. OS probably ignores hints? */ - return NULL; -} - -#else - -/* All memory addresses are reachable by relative jumps. */ -#define mcode_alloc(J, sz) mcode_alloc_at((J), 0, (sz), MCPROT_GEN) - -#endif - -/* -- MCode area management ----------------------------------------------- */ - -/* Linked list of MCode areas. */ -typedef struct MCLink { - MCode *next; /* Next area. */ - size_t size; /* Size of current area. */ -} MCLink; - -/* Allocate a new MCode area. */ -static void mcode_allocarea(jit_State *J) -{ - MCode *oldarea = J->mcarea; - size_t sz = (size_t)J->param[JIT_P_sizemcode] << 10; - sz = (sz + LJ_PAGESIZE-1) & ~(size_t)(LJ_PAGESIZE - 1); - J->mcarea = (MCode *)mcode_alloc(J, sz); - J->szmcarea = sz; - J->mcprot = MCPROT_GEN; - J->mctop = (MCode *)((char *)J->mcarea + J->szmcarea); - J->mcbot = (MCode *)((char *)J->mcarea + sizeof(MCLink)); - ((MCLink *)J->mcarea)->next = oldarea; - ((MCLink *)J->mcarea)->size = sz; - J->szallmcarea += sz; -} - -/* Free all MCode areas. */ -void lj_mcode_free(jit_State *J) -{ - MCode *mc = J->mcarea; - J->mcarea = NULL; - J->szallmcarea = 0; - while (mc) { - MCode *next = ((MCLink *)mc)->next; - mcode_free(J, mc, ((MCLink *)mc)->size); - mc = next; - } -} - -/* -- MCode transactions -------------------------------------------------- */ - -/* Reserve the remainder of the current MCode area. */ -MCode *lj_mcode_reserve(jit_State *J, MCode **lim) -{ - if (!J->mcarea) - mcode_allocarea(J); - else - mcode_protect(J, MCPROT_GEN); - *lim = J->mcbot; - return J->mctop; -} - -/* Commit the top part of the current MCode area. */ -void lj_mcode_commit(jit_State *J, MCode *top) -{ - J->mctop = top; - mcode_protect(J, MCPROT_RUN); -} - -/* Abort the reservation. */ -void lj_mcode_abort(jit_State *J) -{ - if (J->mcarea) - mcode_protect(J, MCPROT_RUN); -} - -/* Set/reset protection to allow patching of MCode areas. */ -MCode *lj_mcode_patch(jit_State *J, MCode *ptr, int finish) -{ -#ifdef LUAJIT_UNPROTECT_MCODE - UNUSED(J); UNUSED(ptr); UNUSED(finish); - return NULL; -#else - if (finish) { - if (J->mcarea == ptr) - mcode_protect(J, MCPROT_RUN); - else if (LJ_UNLIKELY(mcode_setprot(ptr, ((MCLink *)ptr)->size, MCPROT_RUN))) - mcode_protfail(J); - return NULL; - } else { - MCode *mc = J->mcarea; - /* Try current area first to use the protection cache. */ - if (ptr >= mc && ptr < (MCode *)((char *)mc + J->szmcarea)) { - mcode_protect(J, MCPROT_GEN); - return mc; - } - /* Otherwise search through the list of MCode areas. */ - for (;;) { - mc = ((MCLink *)mc)->next; - lua_assert(mc != NULL); - if (ptr >= mc && ptr < (MCode *)((char *)mc + ((MCLink *)mc)->size)) { - if (LJ_UNLIKELY(mcode_setprot(mc, ((MCLink *)mc)->size, MCPROT_GEN))) - mcode_protfail(J); - return mc; - } - } - } -#endif -} - -/* Limit of MCode reservation reached. */ -void lj_mcode_limiterr(jit_State *J, size_t need) -{ - size_t sizemcode, maxmcode; - lj_mcode_abort(J); - sizemcode = (size_t)J->param[JIT_P_sizemcode] << 10; - sizemcode = (sizemcode + LJ_PAGESIZE-1) & ~(size_t)(LJ_PAGESIZE - 1); - maxmcode = (size_t)J->param[JIT_P_maxmcode] << 10; - if ((size_t)need > sizemcode) - lj_trace_err(J, LJ_TRERR_MCODEOV); /* Too long for any area. */ - if (J->szallmcarea + sizemcode > maxmcode) - lj_trace_err(J, LJ_TRERR_MCODEAL); - mcode_allocarea(J); - lj_trace_err(J, LJ_TRERR_MCODELM); /* Retry with new area. */ -} - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_mcode.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_mcode.h deleted file mode 100644 index 89344fc73..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_mcode.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -** Machine code management. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_MCODE_H -#define _LJ_MCODE_H - -#include "lj_obj.h" - -#if LJ_HASJIT || LJ_HASFFI -LJ_FUNC void lj_mcode_sync(void *start, void *end); -#endif - -#if LJ_HASJIT - -#include "lj_jit.h" - -LJ_FUNC void lj_mcode_free(jit_State *J); -LJ_FUNC MCode *lj_mcode_reserve(jit_State *J, MCode **lim); -LJ_FUNC void lj_mcode_commit(jit_State *J, MCode *m); -LJ_FUNC void lj_mcode_abort(jit_State *J); -LJ_FUNC MCode *lj_mcode_patch(jit_State *J, MCode *ptr, int finish); -LJ_FUNC_NORET void lj_mcode_limiterr(jit_State *J, size_t need); - -#define lj_mcode_commitbot(J, m) (J->mcbot = (m)) - -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_meta.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_meta.c deleted file mode 100644 index 0a5266710..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_meta.c +++ /dev/null @@ -1,466 +0,0 @@ -/* -** Metamethod handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Portions taken verbatim or adapted from the Lua interpreter. -** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h -*/ - -#define lj_meta_c -#define LUA_CORE - -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_meta.h" -#include "lj_frame.h" -#include "lj_bc.h" -#include "lj_vm.h" -#include "lj_strscan.h" - -/* -- Metamethod handling ------------------------------------------------- */ - -/* String interning of metamethod names for fast indexing. */ -void lj_meta_init(lua_State *L) -{ -#define MMNAME(name) "__" #name - const char *metanames = MMDEF(MMNAME); -#undef MMNAME - global_State *g = G(L); - const char *p, *q; - uint32_t mm; - for (mm = 0, p = metanames; *p; mm++, p = q) { - GCstr *s; - for (q = p+2; *q && *q != '_'; q++) ; - s = lj_str_new(L, p, (size_t)(q-p)); - /* NOBARRIER: g->gcroot[] is a GC root. */ - setgcref(g->gcroot[GCROOT_MMNAME+mm], obj2gco(s)); - } -} - -/* Negative caching of a few fast metamethods. See the lj_meta_fast() macro. */ -cTValue *lj_meta_cache(GCtab *mt, MMS mm, GCstr *name) -{ - cTValue *mo = lj_tab_getstr(mt, name); - lua_assert(mm <= MM_FAST); - if (!mo || tvisnil(mo)) { /* No metamethod? */ - mt->nomm |= (uint8_t)(1u<metatable); - else if (tvisudata(o)) - mt = tabref(udataV(o)->metatable); - else - mt = tabref(basemt_obj(G(L), o)); - if (mt) { - cTValue *mo = lj_tab_getstr(mt, mmname_str(G(L), mm)); - if (mo) - return mo; - } - return niltv(L); -} - -#if LJ_HASFFI -/* Tailcall from C function. */ -int lj_meta_tailcall(lua_State *L, cTValue *tv) -{ - TValue *base = L->base; - TValue *top = L->top; - const BCIns *pc = frame_pc(base-1); /* Preserve old PC from frame. */ - copyTV(L, base-1, tv); /* Replace frame with new object. */ - top->u32.lo = LJ_CONT_TAILCALL; - setframe_pc(top, pc); - setframe_gc(top+1, obj2gco(L)); /* Dummy frame object. */ - setframe_ftsz(top+1, (int)((char *)(top+2) - (char *)base) + FRAME_CONT); - L->base = L->top = top+2; - /* - ** before: [old_mo|PC] [... ...] - ** ^base ^top - ** after: [new_mo|itype] [... ...] [NULL|PC] [dummy|delta] - ** ^base/top - ** tailcall: [new_mo|PC] [... ...] - ** ^base ^top - */ - return 0; -} -#endif - -/* Setup call to metamethod to be run by Assembler VM. */ -static TValue *mmcall(lua_State *L, ASMFunction cont, cTValue *mo, - cTValue *a, cTValue *b) -{ - /* - ** |-- framesize -> top top+1 top+2 top+3 - ** before: [func slots ...] - ** mm setup: [func slots ...] [cont|?] [mo|tmtype] [a] [b] - ** in asm: [func slots ...] [cont|PC] [mo|delta] [a] [b] - ** ^-- func base ^-- mm base - ** after mm: [func slots ...] [result] - ** ^-- copy to base[PC_RA] --/ for lj_cont_ra - ** istruecond + branch for lj_cont_cond* - ** ignore for lj_cont_nop - ** next PC: [func slots ...] - */ - TValue *top = L->top; - if (curr_funcisL(L)) top = curr_topL(L); - setcont(top, cont); /* Assembler VM stores PC in upper word. */ - copyTV(L, top+1, mo); /* Store metamethod and two arguments. */ - copyTV(L, top+2, a); - copyTV(L, top+3, b); - return top+2; /* Return new base. */ -} - -/* -- C helpers for some instructions, called from assembler VM ----------- */ - -/* Helper for TGET*. __index chain and metamethod. */ -cTValue *lj_meta_tget(lua_State *L, cTValue *o, cTValue *k) -{ - int loop; - for (loop = 0; loop < LJ_MAX_IDXCHAIN; loop++) { - cTValue *mo; - if (LJ_LIKELY(tvistab(o))) { - GCtab *t = tabV(o); - cTValue *tv = lj_tab_get(L, t, k); - if (!tvisnil(tv) || - !(mo = lj_meta_fast(L, tabref(t->metatable), MM_index))) - return tv; - } else if (tvisnil(mo = lj_meta_lookup(L, o, MM_index))) { - lj_err_optype(L, o, LJ_ERR_OPINDEX); - return NULL; /* unreachable */ - } - if (tvisfunc(mo)) { - L->top = mmcall(L, lj_cont_ra, mo, o, k); - return NULL; /* Trigger metamethod call. */ - } - o = mo; - } - lj_err_msg(L, LJ_ERR_GETLOOP); - return NULL; /* unreachable */ -} - -/* Helper for TSET*. __newindex chain and metamethod. */ -TValue *lj_meta_tset(lua_State *L, cTValue *o, cTValue *k) -{ - TValue tmp; - int loop; - for (loop = 0; loop < LJ_MAX_IDXCHAIN; loop++) { - cTValue *mo; - if (LJ_LIKELY(tvistab(o))) { - GCtab *t = tabV(o); - cTValue *tv = lj_tab_get(L, t, k); - if (LJ_LIKELY(!tvisnil(tv))) { - t->nomm = 0; /* Invalidate negative metamethod cache. */ - lj_gc_anybarriert(L, t); - return (TValue *)tv; - } else if (!(mo = lj_meta_fast(L, tabref(t->metatable), MM_newindex))) { - t->nomm = 0; /* Invalidate negative metamethod cache. */ - lj_gc_anybarriert(L, t); - if (tv != niltv(L)) - return (TValue *)tv; - if (tvisnil(k)) lj_err_msg(L, LJ_ERR_NILIDX); - else if (tvisint(k)) { setnumV(&tmp, (lua_Number)intV(k)); k = &tmp; } - else if (tvisnum(k) && tvisnan(k)) lj_err_msg(L, LJ_ERR_NANIDX); - return lj_tab_newkey(L, t, k); - } - } else if (tvisnil(mo = lj_meta_lookup(L, o, MM_newindex))) { - lj_err_optype(L, o, LJ_ERR_OPINDEX); - return NULL; /* unreachable */ - } - if (tvisfunc(mo)) { - L->top = mmcall(L, lj_cont_nop, mo, o, k); - /* L->top+2 = v filled in by caller. */ - return NULL; /* Trigger metamethod call. */ - } - copyTV(L, &tmp, mo); - o = &tmp; - } - lj_err_msg(L, LJ_ERR_SETLOOP); - return NULL; /* unreachable */ -} - -static cTValue *str2num(cTValue *o, TValue *n) -{ - if (tvisnum(o)) - return o; - else if (tvisint(o)) - return (setnumV(n, (lua_Number)intV(o)), n); - else if (tvisstr(o) && lj_strscan_num(strV(o), n)) - return n; - else - return NULL; -} - -/* Helper for arithmetic instructions. Coercion, metamethod. */ -TValue *lj_meta_arith(lua_State *L, TValue *ra, cTValue *rb, cTValue *rc, - BCReg op) -{ - MMS mm = bcmode_mm(op); - TValue tempb, tempc; - cTValue *b, *c; - if ((b = str2num(rb, &tempb)) != NULL && - (c = str2num(rc, &tempc)) != NULL) { /* Try coercion first. */ - setnumV(ra, lj_vm_foldarith(numV(b), numV(c), (int)mm-MM_add)); - return NULL; - } else { - cTValue *mo = lj_meta_lookup(L, rb, mm); - if (tvisnil(mo)) { - mo = lj_meta_lookup(L, rc, mm); - if (tvisnil(mo)) { - if (str2num(rb, &tempb) == NULL) rc = rb; - lj_err_optype(L, rc, LJ_ERR_OPARITH); - return NULL; /* unreachable */ - } - } - return mmcall(L, lj_cont_ra, mo, rb, rc); - } -} - -/* In-place coercion of a number to a string. */ -static LJ_AINLINE int tostring(lua_State *L, TValue *o) -{ - if (tvisstr(o)) { - return 1; - } else if (tvisnumber(o)) { - setstrV(L, o, lj_str_fromnumber(L, o)); - return 1; - } else { - return 0; - } -} - -/* Helper for CAT. Coercion, iterative concat, __concat metamethod. */ -TValue *lj_meta_cat(lua_State *L, TValue *top, int left) -{ - int fromc = 0; - if (left < 0) { left = -left; fromc = 1; } - do { - int n = 1; - if (!(tvisstr(top-1) || tvisnumber(top-1)) || !tostring(L, top)) { - cTValue *mo = lj_meta_lookup(L, top-1, MM_concat); - if (tvisnil(mo)) { - mo = lj_meta_lookup(L, top, MM_concat); - if (tvisnil(mo)) { - if (tvisstr(top-1) || tvisnumber(top-1)) top++; - lj_err_optype(L, top-1, LJ_ERR_OPCAT); - return NULL; /* unreachable */ - } - } - /* One of the top two elements is not a string, call __cat metamethod: - ** - ** before: [...][CAT stack .........................] - ** top-1 top top+1 top+2 - ** pick two: [...][CAT stack ...] [o1] [o2] - ** setup mm: [...][CAT stack ...] [cont|?] [mo|tmtype] [o1] [o2] - ** in asm: [...][CAT stack ...] [cont|PC] [mo|delta] [o1] [o2] - ** ^-- func base ^-- mm base - ** after mm: [...][CAT stack ...] <--push-- [result] - ** next step: [...][CAT stack .............] - */ - copyTV(L, top+2, top); /* Careful with the order of stack copies! */ - copyTV(L, top+1, top-1); - copyTV(L, top, mo); - setcont(top-1, lj_cont_cat); - return top+1; /* Trigger metamethod call. */ - } else if (strV(top)->len == 0) { /* Shortcut. */ - (void)tostring(L, top-1); - } else { - /* Pick as many strings as possible from the top and concatenate them: - ** - ** before: [...][CAT stack ...........................] - ** pick str: [...][CAT stack ...] [...... strings ......] - ** concat: [...][CAT stack ...] [result] - ** next step: [...][CAT stack ............] - */ - MSize tlen = strV(top)->len; - char *buffer; - int i; - for (n = 1; n <= left && tostring(L, top-n); n++) { - MSize len = strV(top-n)->len; - if (len >= LJ_MAX_STR - tlen) - lj_err_msg(L, LJ_ERR_STROV); - tlen += len; - } - buffer = lj_str_needbuf(L, &G(L)->tmpbuf, tlen); - n--; - tlen = 0; - for (i = n; i >= 0; i--) { - MSize len = strV(top-i)->len; - memcpy(buffer + tlen, strVdata(top-i), len); - tlen += len; - } - setstrV(L, top-n, lj_str_new(L, buffer, tlen)); - } - left -= n; - top -= n; - } while (left >= 1); - if (LJ_UNLIKELY(G(L)->gc.total >= G(L)->gc.threshold)) { - if (!fromc) L->top = curr_topL(L); - lj_gc_step(L); - } - return NULL; -} - -/* Helper for LEN. __len metamethod. */ -TValue * LJ_FASTCALL lj_meta_len(lua_State *L, cTValue *o) -{ - cTValue *mo = lj_meta_lookup(L, o, MM_len); - if (tvisnil(mo)) { - if (LJ_52 && tvistab(o)) - tabref(tabV(o)->metatable)->nomm |= (uint8_t)(1u<gch.metatable), MM_eq); - if (mo) { - TValue *top; - uint32_t it; - if (tabref(o1->gch.metatable) != tabref(o2->gch.metatable)) { - cTValue *mo2 = lj_meta_fast(L, tabref(o2->gch.metatable), MM_eq); - if (mo2 == NULL || !lj_obj_equal(mo, mo2)) - return (TValue *)(intptr_t)ne; - } - top = curr_top(L); - setcont(top, ne ? lj_cont_condf : lj_cont_condt); - copyTV(L, top+1, mo); - it = ~(uint32_t)o1->gch.gct; - setgcV(L, top+2, o1, it); - setgcV(L, top+3, o2, it); - return top+2; /* Trigger metamethod call. */ - } - return (TValue *)(intptr_t)ne; -} - -#if LJ_HASFFI -TValue * LJ_FASTCALL lj_meta_equal_cd(lua_State *L, BCIns ins) -{ - ASMFunction cont = (bc_op(ins) & 1) ? lj_cont_condf : lj_cont_condt; - int op = (int)bc_op(ins) & ~1; - TValue tv; - cTValue *mo, *o2, *o1 = &L->base[bc_a(ins)]; - cTValue *o1mm = o1; - if (op == BC_ISEQV) { - o2 = &L->base[bc_d(ins)]; - if (!tviscdata(o1mm)) o1mm = o2; - } else if (op == BC_ISEQS) { - setstrV(L, &tv, gco2str(proto_kgc(curr_proto(L), ~(ptrdiff_t)bc_d(ins)))); - o2 = &tv; - } else if (op == BC_ISEQN) { - o2 = &mref(curr_proto(L)->k, cTValue)[bc_d(ins)]; - } else { - lua_assert(op == BC_ISEQP); - setitype(&tv, ~bc_d(ins)); - o2 = &tv; - } - mo = lj_meta_lookup(L, o1mm, MM_eq); - if (LJ_LIKELY(!tvisnil(mo))) - return mmcall(L, cont, mo, o1, o2); - else - return (TValue *)(intptr_t)(bc_op(ins) & 1); -} -#endif - -/* Helper for ordered comparisons. String compare, __lt/__le metamethods. */ -TValue *lj_meta_comp(lua_State *L, cTValue *o1, cTValue *o2, int op) -{ - if (LJ_HASFFI && (tviscdata(o1) || tviscdata(o2))) { - ASMFunction cont = (op & 1) ? lj_cont_condf : lj_cont_condt; - MMS mm = (op & 2) ? MM_le : MM_lt; - cTValue *mo = lj_meta_lookup(L, tviscdata(o1) ? o1 : o2, mm); - if (LJ_UNLIKELY(tvisnil(mo))) goto err; - return mmcall(L, cont, mo, o1, o2); - } else if (LJ_52 || itype(o1) == itype(o2)) { - /* Never called with two numbers. */ - if (tvisstr(o1) && tvisstr(o2)) { - int32_t res = lj_str_cmp(strV(o1), strV(o2)); - return (TValue *)(intptr_t)(((op&2) ? res <= 0 : res < 0) ^ (op&1)); - } else { - trymt: - while (1) { - ASMFunction cont = (op & 1) ? lj_cont_condf : lj_cont_condt; - MMS mm = (op & 2) ? MM_le : MM_lt; - cTValue *mo = lj_meta_lookup(L, o1, mm); -#if LJ_52 - if (tvisnil(mo) && tvisnil((mo = lj_meta_lookup(L, o2, mm)))) -#else - cTValue *mo2 = lj_meta_lookup(L, o2, mm); - if (tvisnil(mo) || !lj_obj_equal(mo, mo2)) -#endif - { - if (op & 2) { /* MM_le not found: retry with MM_lt. */ - cTValue *ot = o1; o1 = o2; o2 = ot; /* Swap operands. */ - op ^= 3; /* Use LT and flip condition. */ - continue; - } - goto err; - } - return mmcall(L, cont, mo, o1, o2); - } - } - } else if (tvisbool(o1) && tvisbool(o2)) { - goto trymt; - } else { - err: - lj_err_comp(L, o1, o2); - return NULL; - } -} - -/* Helper for calls. __call metamethod. */ -void lj_meta_call(lua_State *L, TValue *func, TValue *top) -{ - cTValue *mo = lj_meta_lookup(L, func, MM_call); - TValue *p; - if (!tvisfunc(mo)) - lj_err_optype_call(L, func); - for (p = top; p > func; p--) copyTV(L, p, p-1); - copyTV(L, func, mo); -} - -/* Helper for FORI. Coercion. */ -void LJ_FASTCALL lj_meta_for(lua_State *L, TValue *o) -{ - if (!lj_strscan_numberobj(o)) lj_err_msg(L, LJ_ERR_FORINIT); - if (!lj_strscan_numberobj(o+1)) lj_err_msg(L, LJ_ERR_FORLIM); - if (!lj_strscan_numberobj(o+2)) lj_err_msg(L, LJ_ERR_FORSTEP); - if (LJ_DUALNUM) { - /* Ensure all slots are integers or all slots are numbers. */ - int32_t k[3]; - int nint = 0; - ptrdiff_t i; - for (i = 0; i <= 2; i++) { - if (tvisint(o+i)) { - k[i] = intV(o+i); nint++; - } else { - k[i] = lj_num2int(numV(o+i)); nint += ((lua_Number)k[i] == numV(o+i)); - } - } - if (nint == 3) { /* Narrow to integers. */ - setintV(o, k[0]); - setintV(o+1, k[1]); - setintV(o+2, k[2]); - } else if (nint != 0) { /* Widen to numbers. */ - if (tvisint(o)) setnumV(o, (lua_Number)intV(o)); - if (tvisint(o+1)) setnumV(o+1, (lua_Number)intV(o+1)); - if (tvisint(o+2)) setnumV(o+2, (lua_Number)intV(o+2)); - } - } -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_meta.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_meta.h deleted file mode 100644 index 8d7c2cd41..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_meta.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -** Metamethod handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_META_H -#define _LJ_META_H - -#include "lj_obj.h" - -/* Metamethod handling */ -LJ_FUNC void lj_meta_init(lua_State *L); -LJ_FUNC cTValue *lj_meta_cache(GCtab *mt, MMS mm, GCstr *name); -LJ_FUNC cTValue *lj_meta_lookup(lua_State *L, cTValue *o, MMS mm); -#if LJ_HASFFI -LJ_FUNC int lj_meta_tailcall(lua_State *L, cTValue *tv); -#endif - -#define lj_meta_fastg(g, mt, mm) \ - ((mt) == NULL ? NULL : ((mt)->nomm & (1u<<(mm))) ? NULL : \ - lj_meta_cache(mt, mm, mmname_str(g, mm))) -#define lj_meta_fast(L, mt, mm) lj_meta_fastg(G(L), mt, mm) - -/* C helpers for some instructions, called from assembler VM. */ -LJ_FUNCA cTValue *lj_meta_tget(lua_State *L, cTValue *o, cTValue *k); -LJ_FUNCA TValue *lj_meta_tset(lua_State *L, cTValue *o, cTValue *k); -LJ_FUNCA TValue *lj_meta_arith(lua_State *L, TValue *ra, cTValue *rb, - cTValue *rc, BCReg op); -LJ_FUNCA TValue *lj_meta_cat(lua_State *L, TValue *top, int left); -LJ_FUNCA TValue * LJ_FASTCALL lj_meta_len(lua_State *L, cTValue *o); -LJ_FUNCA TValue *lj_meta_equal(lua_State *L, GCobj *o1, GCobj *o2, int ne); -LJ_FUNCA TValue * LJ_FASTCALL lj_meta_equal_cd(lua_State *L, BCIns ins); -LJ_FUNCA TValue *lj_meta_comp(lua_State *L, cTValue *o1, cTValue *o2, int op); -LJ_FUNCA void lj_meta_call(lua_State *L, TValue *func, TValue *top); -LJ_FUNCA void LJ_FASTCALL lj_meta_for(lua_State *L, TValue *o); - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_obj.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_obj.c deleted file mode 100644 index c7f3bc121..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_obj.c +++ /dev/null @@ -1,35 +0,0 @@ -/* -** Miscellaneous object handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_obj_c -#define LUA_CORE - -#include "lj_obj.h" - -/* Object type names. */ -LJ_DATADEF const char *const lj_obj_typename[] = { /* ORDER LUA_T */ - "no value", "nil", "boolean", "userdata", "number", "string", - "table", "function", "userdata", "thread", "proto", "cdata" -}; - -LJ_DATADEF const char *const lj_obj_itypename[] = { /* ORDER LJ_T */ - "nil", "boolean", "boolean", "userdata", "string", "upval", "thread", - "proto", "function", "trace", "cdata", "table", "userdata", "number" -}; - -/* Compare two objects without calling metamethods. */ -int lj_obj_equal(cTValue *o1, cTValue *o2) -{ - if (itype(o1) == itype(o2)) { - if (tvispri(o1)) - return 1; - if (!tvisnum(o1)) - return gcrefeq(o1->gcr, o2->gcr); - } else if (!tvisnumber(o1) || !tvisnumber(o2)) { - return 0; - } - return numberVnum(o1) == numberVnum(o2); -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_obj.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_obj.h deleted file mode 100644 index cc999aa41..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_obj.h +++ /dev/null @@ -1,856 +0,0 @@ -/* -** LuaJIT VM tags, values and objects. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Portions taken verbatim or adapted from the Lua interpreter. -** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h -*/ - -#ifndef _LJ_OBJ_H -#define _LJ_OBJ_H - -#include "lua.h" -#include "lj_def.h" -#include "lj_arch.h" - -/* -- Memory references (32 bit address space) ---------------------------- */ - -/* Memory size. */ -typedef uint32_t MSize; - -/* Memory reference */ -typedef struct MRef { - uint32_t ptr32; /* Pseudo 32 bit pointer. */ -} MRef; - -#define mref(r, t) ((t *)(void *)(uintptr_t)(r).ptr32) - -#define setmref(r, p) ((r).ptr32 = (uint32_t)(uintptr_t)(void *)(p)) -#define setmrefr(r, v) ((r).ptr32 = (v).ptr32) - -/* -- GC object references (32 bit address space) ------------------------- */ - -/* GCobj reference */ -typedef struct GCRef { - uint32_t gcptr32; /* Pseudo 32 bit pointer. */ -} GCRef; - -/* Common GC header for all collectable objects. */ -#define GCHeader GCRef nextgc; uint8_t marked; uint8_t gct -/* This occupies 6 bytes, so use the next 2 bytes for non-32 bit fields. */ - -#define gcref(r) ((GCobj *)(uintptr_t)(r).gcptr32) -#define gcrefp(r, t) ((t *)(void *)(uintptr_t)(r).gcptr32) -#define gcrefu(r) ((r).gcptr32) -#define gcrefi(r) ((int32_t)(r).gcptr32) -#define gcrefeq(r1, r2) ((r1).gcptr32 == (r2).gcptr32) -#define gcnext(gc) (gcref((gc)->gch.nextgc)) - -#define setgcref(r, gc) ((r).gcptr32 = (uint32_t)(uintptr_t)&(gc)->gch) -#define setgcrefi(r, i) ((r).gcptr32 = (uint32_t)(i)) -#define setgcrefp(r, p) ((r).gcptr32 = (uint32_t)(uintptr_t)(p)) -#define setgcrefnull(r) ((r).gcptr32 = 0) -#define setgcrefr(r, v) ((r).gcptr32 = (v).gcptr32) - -/* IMPORTANT NOTE: -** -** All uses of the setgcref* macros MUST be accompanied with a write barrier. -** -** This is to ensure the integrity of the incremental GC. The invariant -** to preserve is that a black object never points to a white object. -** I.e. never store a white object into a field of a black object. -** -** It's ok to LEAVE OUT the write barrier ONLY in the following cases: -** - The source is not a GC object (NULL). -** - The target is a GC root. I.e. everything in global_State. -** - The target is a lua_State field (threads are never black). -** - The target is a stack slot, see setgcV et al. -** - The target is an open upvalue, i.e. pointing to a stack slot. -** - The target is a newly created object (i.e. marked white). But make -** sure nothing invokes the GC inbetween. -** - The target and the source are the same object (self-reference). -** - The target already contains the object (e.g. moving elements around). -** -** The most common case is a store to a stack slot. All other cases where -** a barrier has been omitted are annotated with a NOBARRIER comment. -** -** The same logic applies for stores to table slots (array part or hash -** part). ALL uses of lj_tab_set* require a barrier for the stored value -** *and* the stored key, based on the above rules. In practice this means -** a barrier is needed if *either* of the key or value are a GC object. -** -** It's ok to LEAVE OUT the write barrier in the following special cases: -** - The stored value is nil. The key doesn't matter because it's either -** not resurrected or lj_tab_newkey() will take care of the key barrier. -** - The key doesn't matter if the *previously* stored value is guaranteed -** to be non-nil (because the key is kept alive in the table). -** - The key doesn't matter if it's guaranteed not to be part of the table, -** since lj_tab_newkey() takes care of the key barrier. This applies -** trivially to new tables, but watch out for resurrected keys. Storing -** a nil value leaves the key in the table! -** -** In case of doubt use lj_gc_anybarriert() as it's rather cheap. It's used -** by the interpreter for all table stores. -** -** Note: In contrast to Lua's GC, LuaJIT's GC does *not* specially mark -** dead keys in tables. The reference is left in, but it's guaranteed to -** be never dereferenced as long as the value is nil. It's ok if the key is -** freed or if any object subsequently gets the same address. -** -** Not destroying dead keys helps to keep key hash slots stable. This avoids -** specialization back-off for HREFK when a value flips between nil and -** non-nil and the GC gets in the way. It also allows safely hoisting -** HREF/HREFK across GC steps. Dead keys are only removed if a table is -** resized (i.e. by NEWREF) and xREF must not be CSEd across a resize. -** -** The trade-off is that a write barrier for tables must take the key into -** account, too. Implicitly resurrecting the key by storing a non-nil value -** may invalidate the incremental GC invariant. -*/ - -/* -- Common type definitions --------------------------------------------- */ - -/* Types for handling bytecodes. Need this here, details in lj_bc.h. */ -typedef uint32_t BCIns; /* Bytecode instruction. */ -typedef uint32_t BCPos; /* Bytecode position. */ -typedef uint32_t BCReg; /* Bytecode register. */ -typedef int32_t BCLine; /* Bytecode line number. */ - -/* Internal assembler functions. Never call these directly from C. */ -typedef void (*ASMFunction)(void); - -/* Resizable string buffer. Need this here, details in lj_str.h. */ -typedef struct SBuf { - char *buf; /* String buffer base. */ - MSize n; /* String buffer length. */ - MSize sz; /* String buffer size. */ -} SBuf; - -/* -- Tags and values ----------------------------------------------------- */ - -/* Frame link. */ -typedef union { - int32_t ftsz; /* Frame type and size of previous frame. */ - MRef pcr; /* Overlaps PC for Lua frames. */ -} FrameLink; - -/* Tagged value. */ -typedef LJ_ALIGN(8) union TValue { - uint64_t u64; /* 64 bit pattern overlaps number. */ - lua_Number n; /* Number object overlaps split tag/value object. */ - struct { - LJ_ENDIAN_LOHI( - union { - GCRef gcr; /* GCobj reference (if any). */ - int32_t i; /* Integer value. */ - }; - , uint32_t it; /* Internal object tag. Must overlap MSW of number. */ - ) - }; - struct { - LJ_ENDIAN_LOHI( - GCRef func; /* Function for next frame (or dummy L). */ - , FrameLink tp; /* Link to previous frame. */ - ) - } fr; - struct { - LJ_ENDIAN_LOHI( - uint32_t lo; /* Lower 32 bits of number. */ - , uint32_t hi; /* Upper 32 bits of number. */ - ) - } u32; -} TValue; - -typedef const TValue cTValue; - -#define tvref(r) (mref(r, TValue)) - -/* More external and GCobj tags for internal objects. */ -#define LAST_TT LUA_TTHREAD -#define LUA_TPROTO (LAST_TT+1) -#define LUA_TCDATA (LAST_TT+2) - -/* Internal object tags. -** -** Internal tags overlap the MSW of a number object (must be a double). -** Interpreted as a double these are special NaNs. The FPU only generates -** one type of NaN (0xfff8_0000_0000_0000). So MSWs > 0xfff80000 are available -** for use as internal tags. Small negative numbers are used to shorten the -** encoding of type comparisons (reg/mem against sign-ext. 8 bit immediate). -** -** ---MSW---.---LSW--- -** primitive types | itype | | -** lightuserdata | itype | void * | (32 bit platforms) -** lightuserdata |ffff| void * | (64 bit platforms, 47 bit pointers) -** GC objects | itype | GCRef | -** int (LJ_DUALNUM)| itype | int | -** number -------double------ -** -** ORDER LJ_T -** Primitive types nil/false/true must be first, lightuserdata next. -** GC objects are at the end, table/userdata must be lowest. -** Also check lj_ir.h for similar ordering constraints. -*/ -#define LJ_TNIL (~0u) -#define LJ_TFALSE (~1u) -#define LJ_TTRUE (~2u) -#define LJ_TLIGHTUD (~3u) -#define LJ_TSTR (~4u) -#define LJ_TUPVAL (~5u) -#define LJ_TTHREAD (~6u) -#define LJ_TPROTO (~7u) -#define LJ_TFUNC (~8u) -#define LJ_TTRACE (~9u) -#define LJ_TCDATA (~10u) -#define LJ_TTAB (~11u) -#define LJ_TUDATA (~12u) -/* This is just the canonical number type used in some places. */ -#define LJ_TNUMX (~13u) - -/* Integers have itype == LJ_TISNUM doubles have itype < LJ_TISNUM */ -#if LJ_64 -#define LJ_TISNUM 0xfffeffffu -#else -#define LJ_TISNUM LJ_TNUMX -#endif -#define LJ_TISTRUECOND LJ_TFALSE -#define LJ_TISPRI LJ_TTRUE -#define LJ_TISGCV (LJ_TSTR+1) -#define LJ_TISTABUD LJ_TTAB - -/* -- String object ------------------------------------------------------- */ - -/* String object header. String payload follows. */ -typedef struct GCstr { - GCHeader; - uint8_t reserved; /* Used by lexer for fast lookup of reserved words. */ - uint8_t unused; - MSize hash; /* Hash of string. */ - MSize len; /* Size of string. */ -} GCstr; - -#define strref(r) (&gcref((r))->str) -#define strdata(s) ((const char *)((s)+1)) -#define strdatawr(s) ((char *)((s)+1)) -#define strVdata(o) strdata(strV(o)) -#define sizestring(s) (sizeof(struct GCstr)+(s)->len+1) - -/* -- Userdata object ----------------------------------------------------- */ - -/* Userdata object. Payload follows. */ -typedef struct GCudata { - GCHeader; - uint8_t udtype; /* Userdata type. */ - uint8_t unused2; - GCRef env; /* Should be at same offset in GCfunc. */ - MSize len; /* Size of payload. */ - GCRef metatable; /* Must be at same offset in GCtab. */ - uint32_t align1; /* To force 8 byte alignment of the payload. */ -} GCudata; - -/* Userdata types. */ -enum { - UDTYPE_USERDATA, /* Regular userdata. */ - UDTYPE_IO_FILE, /* I/O library FILE. */ - UDTYPE_FFI_CLIB, /* FFI C library namespace. */ - UDTYPE__MAX -}; - -#define uddata(u) ((void *)((u)+1)) -#define sizeudata(u) (sizeof(struct GCudata)+(u)->len) - -/* -- C data object ------------------------------------------------------- */ - -/* C data object. Payload follows. */ -typedef struct GCcdata { - GCHeader; - uint16_t ctypeid; /* C type ID. */ -} GCcdata; - -/* Prepended to variable-sized or realigned C data objects. */ -typedef struct GCcdataVar { - uint16_t offset; /* Offset to allocated memory (relative to GCcdata). */ - uint16_t extra; /* Extra space allocated (incl. GCcdata + GCcdatav). */ - MSize len; /* Size of payload. */ -} GCcdataVar; - -#define cdataptr(cd) ((void *)((cd)+1)) -#define cdataisv(cd) ((cd)->marked & 0x80) -#define cdatav(cd) ((GCcdataVar *)((char *)(cd) - sizeof(GCcdataVar))) -#define cdatavlen(cd) check_exp(cdataisv(cd), cdatav(cd)->len) -#define sizecdatav(cd) (cdatavlen(cd) + cdatav(cd)->extra) -#define memcdatav(cd) ((void *)((char *)(cd) - cdatav(cd)->offset)) - -/* -- Prototype object ---------------------------------------------------- */ - -#define SCALE_NUM_GCO ((int32_t)sizeof(lua_Number)/sizeof(GCRef)) -#define round_nkgc(n) (((n) + SCALE_NUM_GCO-1) & ~(SCALE_NUM_GCO-1)) - -typedef struct GCproto { - GCHeader; - uint8_t numparams; /* Number of parameters. */ - uint8_t framesize; /* Fixed frame size. */ - MSize sizebc; /* Number of bytecode instructions. */ - GCRef gclist; - MRef k; /* Split constant array (points to the middle). */ - MRef uv; /* Upvalue list. local slot|0x8000 or parent uv idx. */ - MSize sizekgc; /* Number of collectable constants. */ - MSize sizekn; /* Number of lua_Number constants. */ - MSize sizept; /* Total size including colocated arrays. */ - uint8_t sizeuv; /* Number of upvalues. */ - uint8_t flags; /* Miscellaneous flags (see below). */ - uint16_t trace; /* Anchor for chain of root traces. */ - /* ------ The following fields are for debugging/tracebacks only ------ */ - GCRef chunkname; /* Name of the chunk this function was defined in. */ - BCLine firstline; /* First line of the function definition. */ - BCLine numline; /* Number of lines for the function definition. */ - MRef lineinfo; /* Compressed map from bytecode ins. to source line. */ - MRef uvinfo; /* Upvalue names. */ - MRef varinfo; /* Names and compressed extents of local variables. */ -} GCproto; - -/* Flags for prototype. */ -#define PROTO_CHILD 0x01 /* Has child prototypes. */ -#define PROTO_VARARG 0x02 /* Vararg function. */ -#define PROTO_FFI 0x04 /* Uses BC_KCDATA for FFI datatypes. */ -#define PROTO_NOJIT 0x08 /* JIT disabled for this function. */ -#define PROTO_ILOOP 0x10 /* Patched bytecode with ILOOP etc. */ -/* Only used during parsing. */ -#define PROTO_HAS_RETURN 0x20 /* Already emitted a return. */ -#define PROTO_FIXUP_RETURN 0x40 /* Need to fixup emitted returns. */ -/* Top bits used for counting created closures. */ -#define PROTO_CLCOUNT 0x20 /* Base of saturating 3 bit counter. */ -#define PROTO_CLC_BITS 3 -#define PROTO_CLC_POLY (3*PROTO_CLCOUNT) /* Polymorphic threshold. */ - -#define PROTO_UV_LOCAL 0x8000 /* Upvalue for local slot. */ -#define PROTO_UV_IMMUTABLE 0x4000 /* Immutable upvalue. */ - -#define proto_kgc(pt, idx) \ - check_exp((uintptr_t)(intptr_t)(idx) >= (uintptr_t)-(intptr_t)(pt)->sizekgc, \ - gcref(mref((pt)->k, GCRef)[(idx)])) -#define proto_knumtv(pt, idx) \ - check_exp((uintptr_t)(idx) < (pt)->sizekn, &mref((pt)->k, TValue)[(idx)]) -#define proto_bc(pt) ((BCIns *)((char *)(pt) + sizeof(GCproto))) -#define proto_bcpos(pt, pc) ((BCPos)((pc) - proto_bc(pt))) -#define proto_uv(pt) (mref((pt)->uv, uint16_t)) - -#define proto_chunkname(pt) (strref((pt)->chunkname)) -#define proto_chunknamestr(pt) (strdata(proto_chunkname((pt)))) -#define proto_lineinfo(pt) (mref((pt)->lineinfo, const void)) -#define proto_uvinfo(pt) (mref((pt)->uvinfo, const uint8_t)) -#define proto_varinfo(pt) (mref((pt)->varinfo, const uint8_t)) - -/* -- Upvalue object ------------------------------------------------------ */ - -typedef struct GCupval { - GCHeader; - uint8_t closed; /* Set if closed (i.e. uv->v == &uv->u.value). */ - uint8_t immutable; /* Immutable value. */ - union { - TValue tv; /* If closed: the value itself. */ - struct { /* If open: double linked list, anchored at thread. */ - GCRef prev; - GCRef next; - }; - }; - MRef v; /* Points to stack slot (open) or above (closed). */ - uint32_t dhash; /* Disambiguation hash: dh1 != dh2 => cannot alias. */ -} GCupval; - -#define uvprev(uv_) (&gcref((uv_)->prev)->uv) -#define uvnext(uv_) (&gcref((uv_)->next)->uv) -#define uvval(uv_) (mref((uv_)->v, TValue)) - -/* -- Function object (closures) ------------------------------------------ */ - -/* Common header for functions. env should be at same offset in GCudata. */ -#define GCfuncHeader \ - GCHeader; uint8_t ffid; uint8_t nupvalues; \ - GCRef env; GCRef gclist; MRef pc - -typedef struct GCfuncC { - GCfuncHeader; - lua_CFunction f; /* C function to be called. */ - TValue upvalue[1]; /* Array of upvalues (TValue). */ -} GCfuncC; - -typedef struct GCfuncL { - GCfuncHeader; - GCRef uvptr[1]; /* Array of _pointers_ to upvalue objects (GCupval). */ -} GCfuncL; - -typedef union GCfunc { - GCfuncC c; - GCfuncL l; -} GCfunc; - -#define FF_LUA 0 -#define FF_C 1 -#define isluafunc(fn) ((fn)->c.ffid == FF_LUA) -#define iscfunc(fn) ((fn)->c.ffid == FF_C) -#define isffunc(fn) ((fn)->c.ffid > FF_C) -#define funcproto(fn) \ - check_exp(isluafunc(fn), (GCproto *)(mref((fn)->l.pc, char)-sizeof(GCproto))) -#define sizeCfunc(n) (sizeof(GCfuncC)-sizeof(TValue)+sizeof(TValue)*(n)) -#define sizeLfunc(n) (sizeof(GCfuncL)-sizeof(GCRef)+sizeof(GCRef)*(n)) - -/* -- Table object -------------------------------------------------------- */ - -/* Hash node. */ -typedef struct Node { - TValue val; /* Value object. Must be first field. */ - TValue key; /* Key object. */ - MRef next; /* Hash chain. */ - MRef freetop; /* Top of free elements (stored in t->node[0]). */ -} Node; - -LJ_STATIC_ASSERT(offsetof(Node, val) == 0); - -typedef struct GCtab { - GCHeader; - uint8_t nomm; /* Negative cache for fast metamethods. */ - int8_t colo; /* Array colocation. */ - MRef array; /* Array part. */ - GCRef gclist; - GCRef metatable; /* Must be at same offset in GCudata. */ - MRef node; /* Hash part. */ - uint32_t asize; /* Size of array part (keys [0, asize-1]). */ - uint32_t hmask; /* Hash part mask (size of hash part - 1). */ -} GCtab; - -#define sizetabcolo(n) ((n)*sizeof(TValue) + sizeof(GCtab)) -#define tabref(r) (&gcref((r))->tab) -#define noderef(r) (mref((r), Node)) -#define nextnode(n) (mref((n)->next, Node)) - -/* -- State objects ------------------------------------------------------- */ - -/* VM states. */ -enum { - LJ_VMST_INTERP, /* Interpreter. */ - LJ_VMST_C, /* C function. */ - LJ_VMST_GC, /* Garbage collector. */ - LJ_VMST_EXIT, /* Trace exit handler. */ - LJ_VMST_RECORD, /* Trace recorder. */ - LJ_VMST_OPT, /* Optimizer. */ - LJ_VMST_ASM, /* Assembler. */ - LJ_VMST__MAX -}; - -#define setvmstate(g, st) ((g)->vmstate = ~LJ_VMST_##st) - -/* Metamethods. ORDER MM */ -#ifdef LJ_HASFFI -#define MMDEF_FFI(_) _(new) -#else -#define MMDEF_FFI(_) -#endif - -#if LJ_52 || LJ_HASFFI -#define MMDEF_PAIRS(_) _(pairs) _(ipairs) -#else -#define MMDEF_PAIRS(_) -#define MM_pairs 255 -#define MM_ipairs 255 -#endif - -#define MMDEF(_) \ - _(index) _(newindex) _(gc) _(mode) _(eq) _(len) \ - /* Only the above (fast) metamethods are negative cached (max. 8). */ \ - _(lt) _(le) _(concat) _(call) \ - /* The following must be in ORDER ARITH. */ \ - _(add) _(sub) _(mul) _(div) _(mod) _(pow) _(unm) \ - /* The following are used in the standard libraries. */ \ - _(metatable) _(tostring) MMDEF_FFI(_) MMDEF_PAIRS(_) - -typedef enum { -#define MMENUM(name) MM_##name, -MMDEF(MMENUM) -#undef MMENUM - MM__MAX, - MM____ = MM__MAX, - MM_FAST = MM_len -} MMS; - -/* GC root IDs. */ -typedef enum { - GCROOT_MMNAME, /* Metamethod names. */ - GCROOT_MMNAME_LAST = GCROOT_MMNAME + MM__MAX-1, - GCROOT_BASEMT, /* Metatables for base types. */ - GCROOT_BASEMT_NUM = GCROOT_BASEMT + ~LJ_TNUMX, - GCROOT_IO_INPUT, /* Userdata for default I/O input file. */ - GCROOT_IO_OUTPUT, /* Userdata for default I/O output file. */ - GCROOT_MAX -} GCRootID; - -#define basemt_it(g, it) ((g)->gcroot[GCROOT_BASEMT+~(it)]) -#define basemt_obj(g, o) ((g)->gcroot[GCROOT_BASEMT+itypemap(o)]) -#define mmname_str(g, mm) (strref((g)->gcroot[GCROOT_MMNAME+(mm)])) - -typedef struct GCState { - MSize total; /* Memory currently allocated. */ - MSize threshold; /* Memory threshold. */ - uint8_t currentwhite; /* Current white color. */ - uint8_t state; /* GC state. */ - uint8_t nocdatafin; /* No cdata finalizer called. */ - uint8_t unused2; - MSize sweepstr; /* Sweep position in string table. */ - GCRef root; /* List of all collectable objects. */ - MRef sweep; /* Sweep position in root list. */ - GCRef gray; /* List of gray objects. */ - GCRef grayagain; /* List of objects for atomic traversal. */ - GCRef weak; /* List of weak tables (to be cleared). */ - GCRef mmudata; /* List of userdata (to be finalized). */ - MSize stepmul; /* Incremental GC step granularity. */ - MSize debt; /* Debt (how much GC is behind schedule). */ - MSize estimate; /* Estimate of memory actually in use. */ - MSize pause; /* Pause between successive GC cycles. */ -} GCState; - -/* Global state, shared by all threads of a Lua universe. */ -typedef struct global_State { - GCRef *strhash; /* String hash table (hash chain anchors). */ - MSize strmask; /* String hash mask (size of hash table - 1). */ - MSize strnum; /* Number of strings in hash table. */ - lua_Alloc allocf; /* Memory allocator. */ - void *allocd; /* Memory allocator data. */ - GCState gc; /* Garbage collector. */ - SBuf tmpbuf; /* Temporary buffer for string concatenation. */ - Node nilnode; /* Fallback 1-element hash part (nil key and value). */ - GCstr strempty; /* Empty string. */ - uint8_t stremptyz; /* Zero terminator of empty string. */ - uint8_t hookmask; /* Hook mask. */ - uint8_t dispatchmode; /* Dispatch mode. */ - uint8_t vmevmask; /* VM event mask. */ - GCRef mainthref; /* Link to main thread. */ - TValue registrytv; /* Anchor for registry. */ - TValue tmptv, tmptv2; /* Temporary TValues. */ - GCupval uvhead; /* Head of double-linked list of all open upvalues. */ - int32_t hookcount; /* Instruction hook countdown. */ - int32_t hookcstart; /* Start count for instruction hook counter. */ - lua_Hook hookf; /* Hook function. */ - lua_CFunction wrapf; /* Wrapper for C function calls. */ - lua_CFunction panic; /* Called as a last resort for errors. */ - volatile int32_t vmstate; /* VM state or current JIT code trace number. */ - BCIns bc_cfunc_int; /* Bytecode for internal C function calls. */ - BCIns bc_cfunc_ext; /* Bytecode for external C function calls. */ - GCRef jit_L; /* Current JIT code lua_State or NULL. */ - MRef jit_base; /* Current JIT code L->base. */ - MRef ctype_state; /* Pointer to C type state. */ - GCRef gcroot[GCROOT_MAX]; /* GC roots. */ -} global_State; - -#define mainthread(g) (&gcref(g->mainthref)->th) -#define niltv(L) \ - check_exp(tvisnil(&G(L)->nilnode.val), &G(L)->nilnode.val) -#define niltvg(g) \ - check_exp(tvisnil(&(g)->nilnode.val), &(g)->nilnode.val) - -/* Hook management. Hook event masks are defined in lua.h. */ -#define HOOK_EVENTMASK 0x0f -#define HOOK_ACTIVE 0x10 -#define HOOK_ACTIVE_SHIFT 4 -#define HOOK_VMEVENT 0x20 -#define HOOK_GC 0x40 -#define hook_active(g) ((g)->hookmask & HOOK_ACTIVE) -#define hook_enter(g) ((g)->hookmask |= HOOK_ACTIVE) -#define hook_entergc(g) ((g)->hookmask |= (HOOK_ACTIVE|HOOK_GC)) -#define hook_vmevent(g) ((g)->hookmask |= (HOOK_ACTIVE|HOOK_VMEVENT)) -#define hook_leave(g) ((g)->hookmask &= ~HOOK_ACTIVE) -#define hook_save(g) ((g)->hookmask & ~HOOK_EVENTMASK) -#define hook_restore(g, h) \ - ((g)->hookmask = ((g)->hookmask & HOOK_EVENTMASK) | (h)) - -/* Per-thread state object. */ -struct lua_State { - GCHeader; - uint8_t dummy_ffid; /* Fake FF_C for curr_funcisL() on dummy frames. */ - uint8_t status; /* Thread status. */ - MRef glref; /* Link to global state. */ - GCRef gclist; /* GC chain. */ - TValue *base; /* Base of currently executing function. */ - TValue *top; /* First free slot in the stack. */ - MRef maxstack; /* Last free slot in the stack. */ - MRef stack; /* Stack base. */ - GCRef openupval; /* List of open upvalues in the stack. */ - GCRef env; /* Thread environment (table of globals). */ - void *cframe; /* End of C stack frame chain. */ - MSize stacksize; /* True stack size (incl. LJ_STACK_EXTRA). */ -}; - -#define G(L) (mref(L->glref, global_State)) -#define registry(L) (&G(L)->registrytv) - -/* Macros to access the currently executing (Lua) function. */ -#define curr_func(L) (&gcref((L->base-1)->fr.func)->fn) -#define curr_funcisL(L) (isluafunc(curr_func(L))) -#define curr_proto(L) (funcproto(curr_func(L))) -#define curr_topL(L) (L->base + curr_proto(L)->framesize) -#define curr_top(L) (curr_funcisL(L) ? curr_topL(L) : L->top) - -/* -- GC object definition and conversions -------------------------------- */ - -/* GC header for generic access to common fields of GC objects. */ -typedef struct GChead { - GCHeader; - uint8_t unused1; - uint8_t unused2; - GCRef env; - GCRef gclist; - GCRef metatable; -} GChead; - -/* The env field SHOULD be at the same offset for all GC objects. */ -LJ_STATIC_ASSERT(offsetof(GChead, env) == offsetof(GCfuncL, env)); -LJ_STATIC_ASSERT(offsetof(GChead, env) == offsetof(GCudata, env)); - -/* The metatable field MUST be at the same offset for all GC objects. */ -LJ_STATIC_ASSERT(offsetof(GChead, metatable) == offsetof(GCtab, metatable)); -LJ_STATIC_ASSERT(offsetof(GChead, metatable) == offsetof(GCudata, metatable)); - -/* The gclist field MUST be at the same offset for all GC objects. */ -LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(lua_State, gclist)); -LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCproto, gclist)); -LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCfuncL, gclist)); -LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCtab, gclist)); - -typedef union GCobj { - GChead gch; - GCstr str; - GCupval uv; - lua_State th; - GCproto pt; - GCfunc fn; - GCcdata cd; - GCtab tab; - GCudata ud; -} GCobj; - -/* Macros to convert a GCobj pointer into a specific value. */ -#define gco2str(o) check_exp((o)->gch.gct == ~LJ_TSTR, &(o)->str) -#define gco2uv(o) check_exp((o)->gch.gct == ~LJ_TUPVAL, &(o)->uv) -#define gco2th(o) check_exp((o)->gch.gct == ~LJ_TTHREAD, &(o)->th) -#define gco2pt(o) check_exp((o)->gch.gct == ~LJ_TPROTO, &(o)->pt) -#define gco2func(o) check_exp((o)->gch.gct == ~LJ_TFUNC, &(o)->fn) -#define gco2cd(o) check_exp((o)->gch.gct == ~LJ_TCDATA, &(o)->cd) -#define gco2tab(o) check_exp((o)->gch.gct == ~LJ_TTAB, &(o)->tab) -#define gco2ud(o) check_exp((o)->gch.gct == ~LJ_TUDATA, &(o)->ud) - -/* Macro to convert any collectable object into a GCobj pointer. */ -#define obj2gco(v) ((GCobj *)(v)) - -/* -- TValue getters/setters ---------------------------------------------- */ - -#ifdef LUA_USE_ASSERT -#include "lj_gc.h" -#endif - -/* Macros to test types. */ -#define itype(o) ((o)->it) -#define tvisnil(o) (itype(o) == LJ_TNIL) -#define tvisfalse(o) (itype(o) == LJ_TFALSE) -#define tvistrue(o) (itype(o) == LJ_TTRUE) -#define tvisbool(o) (tvisfalse(o) || tvistrue(o)) -#if LJ_64 -#define tvislightud(o) (((int32_t)itype(o) >> 15) == -2) -#else -#define tvislightud(o) (itype(o) == LJ_TLIGHTUD) -#endif -#define tvisstr(o) (itype(o) == LJ_TSTR) -#define tvisfunc(o) (itype(o) == LJ_TFUNC) -#define tvisthread(o) (itype(o) == LJ_TTHREAD) -#define tvisproto(o) (itype(o) == LJ_TPROTO) -#define tviscdata(o) (itype(o) == LJ_TCDATA) -#define tvistab(o) (itype(o) == LJ_TTAB) -#define tvisudata(o) (itype(o) == LJ_TUDATA) -#define tvisnumber(o) (itype(o) <= LJ_TISNUM) -#define tvisint(o) (LJ_DUALNUM && itype(o) == LJ_TISNUM) -#define tvisnum(o) (itype(o) < LJ_TISNUM) - -#define tvistruecond(o) (itype(o) < LJ_TISTRUECOND) -#define tvispri(o) (itype(o) >= LJ_TISPRI) -#define tvistabud(o) (itype(o) <= LJ_TISTABUD) /* && !tvisnum() */ -#define tvisgcv(o) ((itype(o) - LJ_TISGCV) > (LJ_TNUMX - LJ_TISGCV)) - -/* Special macros to test numbers for NaN, +0, -0, +1 and raw equality. */ -#define tvisnan(o) ((o)->n != (o)->n) -#if LJ_64 -#define tviszero(o) (((o)->u64 << 1) == 0) -#else -#define tviszero(o) (((o)->u32.lo | ((o)->u32.hi << 1)) == 0) -#endif -#define tvispzero(o) ((o)->u64 == 0) -#define tvismzero(o) ((o)->u64 == U64x(80000000,00000000)) -#define tvispone(o) ((o)->u64 == U64x(3ff00000,00000000)) -#define rawnumequal(o1, o2) ((o1)->u64 == (o2)->u64) - -/* Macros to convert type ids. */ -#if LJ_64 -#define itypemap(o) \ - (tvisnumber(o) ? ~LJ_TNUMX : tvislightud(o) ? ~LJ_TLIGHTUD : ~itype(o)) -#else -#define itypemap(o) (tvisnumber(o) ? ~LJ_TNUMX : ~itype(o)) -#endif - -/* Macros to get tagged values. */ -#define gcval(o) (gcref((o)->gcr)) -#define boolV(o) check_exp(tvisbool(o), (LJ_TFALSE - (o)->it)) -#if LJ_64 -#define lightudV(o) \ - check_exp(tvislightud(o), (void *)((o)->u64 & U64x(00007fff,ffffffff))) -#else -#define lightudV(o) check_exp(tvislightud(o), gcrefp((o)->gcr, void)) -#endif -#define gcV(o) check_exp(tvisgcv(o), gcval(o)) -#define strV(o) check_exp(tvisstr(o), &gcval(o)->str) -#define funcV(o) check_exp(tvisfunc(o), &gcval(o)->fn) -#define threadV(o) check_exp(tvisthread(o), &gcval(o)->th) -#define protoV(o) check_exp(tvisproto(o), &gcval(o)->pt) -#define cdataV(o) check_exp(tviscdata(o), &gcval(o)->cd) -#define tabV(o) check_exp(tvistab(o), &gcval(o)->tab) -#define udataV(o) check_exp(tvisudata(o), &gcval(o)->ud) -#define numV(o) check_exp(tvisnum(o), (o)->n) -#define intV(o) check_exp(tvisint(o), (int32_t)(o)->i) - -/* Macros to set tagged values. */ -#define setitype(o, i) ((o)->it = (i)) -#define setnilV(o) ((o)->it = LJ_TNIL) -#define setboolV(o, x) ((o)->it = LJ_TFALSE-(uint32_t)(x)) - -static LJ_AINLINE void setlightudV(TValue *o, void *p) -{ -#if LJ_64 - o->u64 = (uint64_t)p | (((uint64_t)0xffff) << 48); -#else - setgcrefp(o->gcr, p); setitype(o, LJ_TLIGHTUD); -#endif -} - -#if LJ_64 -#define checklightudptr(L, p) \ - (((uint64_t)(p) >> 47) ? (lj_err_msg(L, LJ_ERR_BADLU), NULL) : (p)) -#define setcont(o, f) \ - ((o)->u64 = (uint64_t)(void *)(f) - (uint64_t)lj_vm_asm_begin) -#else -#define checklightudptr(L, p) (p) -#define setcont(o, f) setlightudV((o), (void *)(f)) -#endif - -#define tvchecklive(L, o) \ - UNUSED(L), lua_assert(!tvisgcv(o) || \ - ((~itype(o) == gcval(o)->gch.gct) && !isdead(G(L), gcval(o)))) - -static LJ_AINLINE void setgcV(lua_State *L, TValue *o, GCobj *v, uint32_t itype) -{ - setgcref(o->gcr, v); setitype(o, itype); tvchecklive(L, o); -} - -#define define_setV(name, type, tag) \ -static LJ_AINLINE void name(lua_State *L, TValue *o, type *v) \ -{ \ - setgcV(L, o, obj2gco(v), tag); \ -} -define_setV(setstrV, GCstr, LJ_TSTR) -define_setV(setthreadV, lua_State, LJ_TTHREAD) -define_setV(setprotoV, GCproto, LJ_TPROTO) -define_setV(setfuncV, GCfunc, LJ_TFUNC) -define_setV(setcdataV, GCcdata, LJ_TCDATA) -define_setV(settabV, GCtab, LJ_TTAB) -define_setV(setudataV, GCudata, LJ_TUDATA) - -#define setnumV(o, x) ((o)->n = (x)) -#define setnanV(o) ((o)->u64 = U64x(fff80000,00000000)) -#define setpinfV(o) ((o)->u64 = U64x(7ff00000,00000000)) -#define setminfV(o) ((o)->u64 = U64x(fff00000,00000000)) - -static LJ_AINLINE void setintV(TValue *o, int32_t i) -{ -#if LJ_DUALNUM - o->i = (uint32_t)i; setitype(o, LJ_TISNUM); -#else - o->n = (lua_Number)i; -#endif -} - -static LJ_AINLINE void setint64V(TValue *o, int64_t i) -{ - if (LJ_DUALNUM && LJ_LIKELY(i == (int64_t)(int32_t)i)) - setintV(o, (int32_t)i); - else - setnumV(o, (lua_Number)i); -} - -#if LJ_64 -#define setintptrV(o, i) setint64V((o), (i)) -#else -#define setintptrV(o, i) setintV((o), (i)) -#endif - -/* Copy tagged values. */ -static LJ_AINLINE void copyTV(lua_State *L, TValue *o1, const TValue *o2) -{ - *o1 = *o2; tvchecklive(L, o1); -} - -/* -- Number to integer conversion ---------------------------------------- */ - -#if LJ_SOFTFP -LJ_ASMF int32_t lj_vm_tobit(double x); -#endif - -static LJ_AINLINE int32_t lj_num2bit(lua_Number n) -{ -#if LJ_SOFTFP - return lj_vm_tobit(n); -#else - TValue o; - o.n = n + 6755399441055744.0; /* 2^52 + 2^51 */ - return (int32_t)o.u32.lo; -#endif -} - -#if LJ_TARGET_X86 && !defined(__SSE2__) -#define lj_num2int(n) lj_num2bit((n)) -#else -#define lj_num2int(n) ((int32_t)(n)) -#endif - -static LJ_AINLINE uint64_t lj_num2u64(lua_Number n) -{ -#ifdef _MSC_VER - if (n >= 9223372036854775808.0) /* They think it's a feature. */ - return (uint64_t)(int64_t)(n - 18446744073709551616.0); - else -#endif - return (uint64_t)n; -} - -static LJ_AINLINE int32_t numberVint(cTValue *o) -{ - if (LJ_LIKELY(tvisint(o))) - return intV(o); - else - return lj_num2int(numV(o)); -} - -static LJ_AINLINE lua_Number numberVnum(cTValue *o) -{ - if (LJ_UNLIKELY(tvisint(o))) - return (lua_Number)intV(o); - else - return numV(o); -} - -/* -- Miscellaneous object handling --------------------------------------- */ - -/* Names and maps for internal and external object tags. */ -LJ_DATA const char *const lj_obj_typename[1+LUA_TCDATA+1]; -LJ_DATA const char *const lj_obj_itypename[~LJ_TNUMX+1]; - -#define lj_typename(o) (lj_obj_itypename[itypemap(o)]) - -/* Compare two objects without calling metamethods. */ -LJ_FUNC int lj_obj_equal(cTValue *o1, cTValue *o2); - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_dce.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_dce.c deleted file mode 100644 index be8018947..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_dce.c +++ /dev/null @@ -1,77 +0,0 @@ -/* -** DCE: Dead Code Elimination. Pre-LOOP only -- ASM already performs DCE. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_opt_dce_c -#define LUA_CORE - -#include "lj_obj.h" - -#if LJ_HASJIT - -#include "lj_ir.h" -#include "lj_jit.h" -#include "lj_iropt.h" - -/* Some local macros to save typing. Undef'd at the end. */ -#define IR(ref) (&J->cur.ir[(ref)]) - -/* Scan through all snapshots and mark all referenced instructions. */ -static void dce_marksnap(jit_State *J) -{ - SnapNo i, nsnap = J->cur.nsnap; - for (i = 0; i < nsnap; i++) { - SnapShot *snap = &J->cur.snap[i]; - SnapEntry *map = &J->cur.snapmap[snap->mapofs]; - MSize n, nent = snap->nent; - for (n = 0; n < nent; n++) { - IRRef ref = snap_ref(map[n]); - if (ref >= REF_FIRST) - irt_setmark(IR(ref)->t); - } - } -} - -/* Backwards propagate marks. Replace unused instructions with NOPs. */ -static void dce_propagate(jit_State *J) -{ - IRRef1 *pchain[IR__MAX]; - IRRef ins; - uint32_t i; - for (i = 0; i < IR__MAX; i++) pchain[i] = &J->chain[i]; - for (ins = J->cur.nins-1; ins >= REF_FIRST; ins--) { - IRIns *ir = IR(ins); - if (irt_ismarked(ir->t)) { - irt_clearmark(ir->t); - pchain[ir->o] = &ir->prev; - } else if (!ir_sideeff(ir)) { - *pchain[ir->o] = ir->prev; /* Reroute original instruction chain. */ - ir->t.irt = IRT_NIL; - ir->o = IR_NOP; /* Replace instruction with NOP. */ - ir->op1 = ir->op2 = 0; - ir->prev = 0; - continue; - } - if (ir->op1 >= REF_FIRST) irt_setmark(IR(ir->op1)->t); - if (ir->op2 >= REF_FIRST) irt_setmark(IR(ir->op2)->t); - } -} - -/* Dead Code Elimination. -** -** First backpropagate marks for all used instructions. Then replace -** the unused ones with a NOP. Note that compressing the IR to eliminate -** the NOPs does not pay off. -*/ -void lj_opt_dce(jit_State *J) -{ - if ((J->flags & JIT_F_OPT_DCE)) { - dce_marksnap(J); - dce_propagate(J); - } -} - -#undef IR - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_fold.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_fold.c deleted file mode 100644 index 8a5b41cc2..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_fold.c +++ /dev/null @@ -1,2297 +0,0 @@ -/* -** FOLD: Constant Folding, Algebraic Simplifications and Reassociation. -** ABCelim: Array Bounds Check Elimination. -** CSE: Common-Subexpression Elimination. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_opt_fold_c -#define LUA_CORE - -#include - -#include "lj_obj.h" - -#if LJ_HASJIT - -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_ir.h" -#include "lj_jit.h" -#include "lj_iropt.h" -#include "lj_trace.h" -#if LJ_HASFFI -#include "lj_ctype.h" -#endif -#include "lj_carith.h" -#include "lj_vm.h" -#include "lj_strscan.h" - -/* Here's a short description how the FOLD engine processes instructions: -** -** The FOLD engine receives a single instruction stored in fins (J->fold.ins). -** The instruction and its operands are used to select matching fold rules. -** These are applied iteratively until a fixed point is reached. -** -** The 8 bit opcode of the instruction itself plus the opcodes of the -** two instructions referenced by its operands form a 24 bit key -** 'ins left right' (unused operands -> 0, literals -> lowest 8 bits). -** -** This key is used for partial matching against the fold rules. The -** left/right operand fields of the key are successively masked with -** the 'any' wildcard, from most specific to least specific: -** -** ins left right -** ins any right -** ins left any -** ins any any -** -** The masked key is used to lookup a matching fold rule in a semi-perfect -** hash table. If a matching rule is found, the related fold function is run. -** Multiple rules can share the same fold function. A fold rule may return -** one of several special values: -** -** - NEXTFOLD means no folding was applied, because an additional test -** inside the fold function failed. Matching continues against less -** specific fold rules. Finally the instruction is passed on to CSE. -** -** - RETRYFOLD means the instruction was modified in-place. Folding is -** retried as if this instruction had just been received. -** -** All other return values are terminal actions -- no further folding is -** applied: -** -** - INTFOLD(i) returns a reference to the integer constant i. -** -** - LEFTFOLD and RIGHTFOLD return the left/right operand reference -** without emitting an instruction. -** -** - CSEFOLD and EMITFOLD pass the instruction directly to CSE or emit -** it without passing through any further optimizations. -** -** - FAILFOLD, DROPFOLD and CONDFOLD only apply to instructions which have -** no result (e.g. guarded assertions): FAILFOLD means the guard would -** always fail, i.e. the current trace is pointless. DROPFOLD means -** the guard is always true and has been eliminated. CONDFOLD is a -** shortcut for FAILFOLD + cond (i.e. drop if true, otherwise fail). -** -** - Any other return value is interpreted as an IRRef or TRef. This -** can be a reference to an existing or a newly created instruction. -** Only the least-significant 16 bits (IRRef1) are used to form a TRef -** which is finally returned to the caller. -** -** The FOLD engine receives instructions both from the trace recorder and -** substituted instructions from LOOP unrolling. This means all types -** of instructions may end up here, even though the recorder bypasses -** FOLD in some cases. Thus all loads, stores and allocations must have -** an any/any rule to avoid being passed on to CSE. -** -** Carefully read the following requirements before adding or modifying -** any fold rules: -** -** Requirement #1: All fold rules must preserve their destination type. -** -** Consistently use INTFOLD() (KINT result) or lj_ir_knum() (KNUM result). -** Never use lj_ir_knumint() which can have either a KINT or KNUM result. -** -** Requirement #2: Fold rules should not create *new* instructions which -** reference operands *across* PHIs. -** -** E.g. a RETRYFOLD with 'fins->op1 = fleft->op1' is invalid if the -** left operand is a PHI. Then fleft->op1 would point across the PHI -** frontier to an invariant instruction. Adding a PHI for this instruction -** would be counterproductive. The solution is to add a barrier which -** prevents folding across PHIs, i.e. 'PHIBARRIER(fleft)' in this case. -** The only exception is for recurrences with high latencies like -** repeated int->num->int conversions. -** -** One could relax this condition a bit if the referenced instruction is -** a PHI, too. But this often leads to worse code due to excessive -** register shuffling. -** -** Note: returning *existing* instructions (e.g. LEFTFOLD) is ok, though. -** Even returning fleft->op1 would be ok, because a new PHI will added, -** if needed. But again, this leads to excessive register shuffling and -** should be avoided. -** -** Requirement #3: The set of all fold rules must be monotonic to guarantee -** termination. -** -** The goal is optimization, so one primarily wants to add strength-reducing -** rules. This means eliminating an instruction or replacing an instruction -** with one or more simpler instructions. Don't add fold rules which point -** into the other direction. -** -** Some rules (like commutativity) do not directly reduce the strength of -** an instruction, but enable other fold rules (e.g. by moving constants -** to the right operand). These rules must be made unidirectional to avoid -** cycles. -** -** Rule of thumb: the trace recorder expands the IR and FOLD shrinks it. -*/ - -/* Some local macros to save typing. Undef'd at the end. */ -#define IR(ref) (&J->cur.ir[(ref)]) -#define fins (&J->fold.ins) -#define fleft (&J->fold.left) -#define fright (&J->fold.right) -#define knumleft (ir_knum(fleft)->n) -#define knumright (ir_knum(fright)->n) - -/* Pass IR on to next optimization in chain (FOLD). */ -#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) - -/* Fold function type. Fastcall on x86 significantly reduces their size. */ -typedef IRRef (LJ_FASTCALL *FoldFunc)(jit_State *J); - -/* Macros for the fold specs, so buildvm can recognize them. */ -#define LJFOLD(x) -#define LJFOLDX(x) -#define LJFOLDF(name) static TRef LJ_FASTCALL fold_##name(jit_State *J) -/* Note: They must be at the start of a line or buildvm ignores them! */ - -/* Barrier to prevent using operands across PHIs. */ -#define PHIBARRIER(ir) if (irt_isphi((ir)->t)) return NEXTFOLD - -/* Barrier to prevent folding across a GC step. -** GC steps can only happen at the head of a trace and at LOOP. -** And the GC is only driven forward if there is at least one allocation. -*/ -#define gcstep_barrier(J, ref) \ - ((ref) < J->chain[IR_LOOP] && \ - (J->chain[IR_SNEW] || J->chain[IR_XSNEW] || \ - J->chain[IR_TNEW] || J->chain[IR_TDUP] || \ - J->chain[IR_CNEW] || J->chain[IR_CNEWI] || J->chain[IR_TOSTR])) - -/* -- Constant folding for FP numbers ------------------------------------- */ - -LJFOLD(ADD KNUM KNUM) -LJFOLD(SUB KNUM KNUM) -LJFOLD(MUL KNUM KNUM) -LJFOLD(DIV KNUM KNUM) -LJFOLD(NEG KNUM KNUM) -LJFOLD(ABS KNUM KNUM) -LJFOLD(ATAN2 KNUM KNUM) -LJFOLD(LDEXP KNUM KNUM) -LJFOLD(MIN KNUM KNUM) -LJFOLD(MAX KNUM KNUM) -LJFOLDF(kfold_numarith) -{ - lua_Number a = knumleft; - lua_Number b = knumright; - lua_Number y = lj_vm_foldarith(a, b, fins->o - IR_ADD); - return lj_ir_knum(J, y); -} - -LJFOLD(LDEXP KNUM KINT) -LJFOLDF(kfold_ldexp) -{ -#if LJ_TARGET_X86ORX64 - UNUSED(J); - return NEXTFOLD; -#else - return lj_ir_knum(J, ldexp(knumleft, fright->i)); -#endif -} - -LJFOLD(FPMATH KNUM any) -LJFOLDF(kfold_fpmath) -{ - lua_Number a = knumleft; - lua_Number y = lj_vm_foldfpm(a, fins->op2); - return lj_ir_knum(J, y); -} - -LJFOLD(POW KNUM KINT) -LJFOLDF(kfold_numpow) -{ - lua_Number a = knumleft; - lua_Number b = (lua_Number)fright->i; - lua_Number y = lj_vm_foldarith(a, b, IR_POW - IR_ADD); - return lj_ir_knum(J, y); -} - -/* Must not use kfold_kref for numbers (could be NaN). */ -LJFOLD(EQ KNUM KNUM) -LJFOLD(NE KNUM KNUM) -LJFOLD(LT KNUM KNUM) -LJFOLD(GE KNUM KNUM) -LJFOLD(LE KNUM KNUM) -LJFOLD(GT KNUM KNUM) -LJFOLD(ULT KNUM KNUM) -LJFOLD(UGE KNUM KNUM) -LJFOLD(ULE KNUM KNUM) -LJFOLD(UGT KNUM KNUM) -LJFOLDF(kfold_numcomp) -{ - return CONDFOLD(lj_ir_numcmp(knumleft, knumright, (IROp)fins->o)); -} - -/* -- Constant folding for 32 bit integers -------------------------------- */ - -static int32_t kfold_intop(int32_t k1, int32_t k2, IROp op) -{ - switch (op) { - case IR_ADD: k1 += k2; break; - case IR_SUB: k1 -= k2; break; - case IR_MUL: k1 *= k2; break; - case IR_MOD: k1 = lj_vm_modi(k1, k2); break; - case IR_NEG: k1 = -k1; break; - case IR_BAND: k1 &= k2; break; - case IR_BOR: k1 |= k2; break; - case IR_BXOR: k1 ^= k2; break; - case IR_BSHL: k1 <<= (k2 & 31); break; - case IR_BSHR: k1 = (int32_t)((uint32_t)k1 >> (k2 & 31)); break; - case IR_BSAR: k1 >>= (k2 & 31); break; - case IR_BROL: k1 = (int32_t)lj_rol((uint32_t)k1, (k2 & 31)); break; - case IR_BROR: k1 = (int32_t)lj_ror((uint32_t)k1, (k2 & 31)); break; - case IR_MIN: k1 = k1 < k2 ? k1 : k2; break; - case IR_MAX: k1 = k1 > k2 ? k1 : k2; break; - default: lua_assert(0); break; - } - return k1; -} - -LJFOLD(ADD KINT KINT) -LJFOLD(SUB KINT KINT) -LJFOLD(MUL KINT KINT) -LJFOLD(MOD KINT KINT) -LJFOLD(NEG KINT KINT) -LJFOLD(BAND KINT KINT) -LJFOLD(BOR KINT KINT) -LJFOLD(BXOR KINT KINT) -LJFOLD(BSHL KINT KINT) -LJFOLD(BSHR KINT KINT) -LJFOLD(BSAR KINT KINT) -LJFOLD(BROL KINT KINT) -LJFOLD(BROR KINT KINT) -LJFOLD(MIN KINT KINT) -LJFOLD(MAX KINT KINT) -LJFOLDF(kfold_intarith) -{ - return INTFOLD(kfold_intop(fleft->i, fright->i, (IROp)fins->o)); -} - -LJFOLD(ADDOV KINT KINT) -LJFOLD(SUBOV KINT KINT) -LJFOLD(MULOV KINT KINT) -LJFOLDF(kfold_intovarith) -{ - lua_Number n = lj_vm_foldarith((lua_Number)fleft->i, (lua_Number)fright->i, - fins->o - IR_ADDOV); - int32_t k = lj_num2int(n); - if (n != (lua_Number)k) - return FAILFOLD; - return INTFOLD(k); -} - -LJFOLD(BNOT KINT) -LJFOLDF(kfold_bnot) -{ - return INTFOLD(~fleft->i); -} - -LJFOLD(BSWAP KINT) -LJFOLDF(kfold_bswap) -{ - return INTFOLD((int32_t)lj_bswap((uint32_t)fleft->i)); -} - -LJFOLD(LT KINT KINT) -LJFOLD(GE KINT KINT) -LJFOLD(LE KINT KINT) -LJFOLD(GT KINT KINT) -LJFOLD(ULT KINT KINT) -LJFOLD(UGE KINT KINT) -LJFOLD(ULE KINT KINT) -LJFOLD(UGT KINT KINT) -LJFOLD(ABC KINT KINT) -LJFOLDF(kfold_intcomp) -{ - int32_t a = fleft->i, b = fright->i; - switch ((IROp)fins->o) { - case IR_LT: return CONDFOLD(a < b); - case IR_GE: return CONDFOLD(a >= b); - case IR_LE: return CONDFOLD(a <= b); - case IR_GT: return CONDFOLD(a > b); - case IR_ULT: return CONDFOLD((uint32_t)a < (uint32_t)b); - case IR_UGE: return CONDFOLD((uint32_t)a >= (uint32_t)b); - case IR_ULE: return CONDFOLD((uint32_t)a <= (uint32_t)b); - case IR_ABC: - case IR_UGT: return CONDFOLD((uint32_t)a > (uint32_t)b); - default: lua_assert(0); return FAILFOLD; - } -} - -LJFOLD(UGE any KINT) -LJFOLDF(kfold_intcomp0) -{ - if (fright->i == 0) - return DROPFOLD; - return NEXTFOLD; -} - -/* -- Constant folding for 64 bit integers -------------------------------- */ - -static uint64_t kfold_int64arith(uint64_t k1, uint64_t k2, IROp op) -{ - switch (op) { -#if LJ_64 || LJ_HASFFI - case IR_ADD: k1 += k2; break; - case IR_SUB: k1 -= k2; break; -#endif -#if LJ_HASFFI - case IR_MUL: k1 *= k2; break; - case IR_BAND: k1 &= k2; break; - case IR_BOR: k1 |= k2; break; - case IR_BXOR: k1 ^= k2; break; -#endif - default: UNUSED(k2); lua_assert(0); break; - } - return k1; -} - -LJFOLD(ADD KINT64 KINT64) -LJFOLD(SUB KINT64 KINT64) -LJFOLD(MUL KINT64 KINT64) -LJFOLD(BAND KINT64 KINT64) -LJFOLD(BOR KINT64 KINT64) -LJFOLD(BXOR KINT64 KINT64) -LJFOLDF(kfold_int64arith) -{ - return INT64FOLD(kfold_int64arith(ir_k64(fleft)->u64, - ir_k64(fright)->u64, (IROp)fins->o)); -} - -LJFOLD(DIV KINT64 KINT64) -LJFOLD(MOD KINT64 KINT64) -LJFOLD(POW KINT64 KINT64) -LJFOLDF(kfold_int64arith2) -{ -#if LJ_HASFFI - uint64_t k1 = ir_k64(fleft)->u64, k2 = ir_k64(fright)->u64; - if (irt_isi64(fins->t)) { - k1 = fins->o == IR_DIV ? lj_carith_divi64((int64_t)k1, (int64_t)k2) : - fins->o == IR_MOD ? lj_carith_modi64((int64_t)k1, (int64_t)k2) : - lj_carith_powi64((int64_t)k1, (int64_t)k2); - } else { - k1 = fins->o == IR_DIV ? lj_carith_divu64(k1, k2) : - fins->o == IR_MOD ? lj_carith_modu64(k1, k2) : - lj_carith_powu64(k1, k2); - } - return INT64FOLD(k1); -#else - UNUSED(J); lua_assert(0); return FAILFOLD; -#endif -} - -LJFOLD(BSHL KINT64 KINT) -LJFOLD(BSHR KINT64 KINT) -LJFOLD(BSAR KINT64 KINT) -LJFOLD(BROL KINT64 KINT) -LJFOLD(BROR KINT64 KINT) -LJFOLDF(kfold_int64shift) -{ -#if LJ_HASFFI || LJ_64 - uint64_t k = ir_k64(fleft)->u64; - int32_t sh = (fright->i & 63); - switch ((IROp)fins->o) { - case IR_BSHL: k <<= sh; break; -#if LJ_HASFFI - case IR_BSHR: k >>= sh; break; - case IR_BSAR: k = (uint64_t)((int64_t)k >> sh); break; - case IR_BROL: k = lj_rol(k, sh); break; - case IR_BROR: k = lj_ror(k, sh); break; -#endif - default: lua_assert(0); break; - } - return INT64FOLD(k); -#else - UNUSED(J); lua_assert(0); return FAILFOLD; -#endif -} - -LJFOLD(BNOT KINT64) -LJFOLDF(kfold_bnot64) -{ -#if LJ_HASFFI - return INT64FOLD(~ir_k64(fleft)->u64); -#else - UNUSED(J); lua_assert(0); return FAILFOLD; -#endif -} - -LJFOLD(BSWAP KINT64) -LJFOLDF(kfold_bswap64) -{ -#if LJ_HASFFI - return INT64FOLD(lj_bswap64(ir_k64(fleft)->u64)); -#else - UNUSED(J); lua_assert(0); return FAILFOLD; -#endif -} - -LJFOLD(LT KINT64 KINT64) -LJFOLD(GE KINT64 KINT64) -LJFOLD(LE KINT64 KINT64) -LJFOLD(GT KINT64 KINT64) -LJFOLD(ULT KINT64 KINT64) -LJFOLD(UGE KINT64 KINT64) -LJFOLD(ULE KINT64 KINT64) -LJFOLD(UGT KINT64 KINT64) -LJFOLDF(kfold_int64comp) -{ -#if LJ_HASFFI - uint64_t a = ir_k64(fleft)->u64, b = ir_k64(fright)->u64; - switch ((IROp)fins->o) { - case IR_LT: return CONDFOLD(a < b); - case IR_GE: return CONDFOLD(a >= b); - case IR_LE: return CONDFOLD(a <= b); - case IR_GT: return CONDFOLD(a > b); - case IR_ULT: return CONDFOLD((uint64_t)a < (uint64_t)b); - case IR_UGE: return CONDFOLD((uint64_t)a >= (uint64_t)b); - case IR_ULE: return CONDFOLD((uint64_t)a <= (uint64_t)b); - case IR_UGT: return CONDFOLD((uint64_t)a > (uint64_t)b); - default: lua_assert(0); return FAILFOLD; - } -#else - UNUSED(J); lua_assert(0); return FAILFOLD; -#endif -} - -LJFOLD(UGE any KINT64) -LJFOLDF(kfold_int64comp0) -{ -#if LJ_HASFFI - if (ir_k64(fright)->u64 == 0) - return DROPFOLD; - return NEXTFOLD; -#else - UNUSED(J); lua_assert(0); return FAILFOLD; -#endif -} - -/* -- Constant folding for strings ---------------------------------------- */ - -LJFOLD(SNEW KKPTR KINT) -LJFOLDF(kfold_snew_kptr) -{ - GCstr *s = lj_str_new(J->L, (const char *)ir_kptr(fleft), (size_t)fright->i); - return lj_ir_kstr(J, s); -} - -LJFOLD(SNEW any KINT) -LJFOLDF(kfold_snew_empty) -{ - if (fright->i == 0) - return lj_ir_kstr(J, &J2G(J)->strempty); - return NEXTFOLD; -} - -LJFOLD(STRREF KGC KINT) -LJFOLDF(kfold_strref) -{ - GCstr *str = ir_kstr(fleft); - lua_assert((MSize)fright->i <= str->len); - return lj_ir_kkptr(J, (char *)strdata(str) + fright->i); -} - -LJFOLD(STRREF SNEW any) -LJFOLDF(kfold_strref_snew) -{ - PHIBARRIER(fleft); - if (irref_isk(fins->op2) && fright->i == 0) { - return fleft->op1; /* strref(snew(ptr, len), 0) ==> ptr */ - } else { - /* Reassociate: strref(snew(strref(str, a), len), b) ==> strref(str, a+b) */ - IRIns *ir = IR(fleft->op1); - IRRef1 str = ir->op1; /* IRIns * is not valid across emitir. */ - lua_assert(ir->o == IR_STRREF); - PHIBARRIER(ir); - fins->op2 = emitir(IRTI(IR_ADD), ir->op2, fins->op2); /* Clobbers fins! */ - fins->op1 = str; - fins->ot = IRT(IR_STRREF, IRT_P32); - return RETRYFOLD; - } - return NEXTFOLD; -} - -LJFOLD(CALLN CARG IRCALL_lj_str_cmp) -LJFOLDF(kfold_strcmp) -{ - if (irref_isk(fleft->op1) && irref_isk(fleft->op2)) { - GCstr *a = ir_kstr(IR(fleft->op1)); - GCstr *b = ir_kstr(IR(fleft->op2)); - return INTFOLD(lj_str_cmp(a, b)); - } - return NEXTFOLD; -} - -/* -- Constant folding of pointer arithmetic ------------------------------ */ - -LJFOLD(ADD KGC KINT) -LJFOLD(ADD KGC KINT64) -LJFOLDF(kfold_add_kgc) -{ - GCobj *o = ir_kgc(fleft); -#if LJ_64 - ptrdiff_t ofs = (ptrdiff_t)ir_kint64(fright)->u64; -#else - ptrdiff_t ofs = fright->i; -#endif -#if LJ_HASFFI - if (irt_iscdata(fleft->t)) { - CType *ct = ctype_raw(ctype_ctsG(J2G(J)), gco2cd(o)->ctypeid); - if (ctype_isnum(ct->info) || ctype_isenum(ct->info) || - ctype_isptr(ct->info) || ctype_isfunc(ct->info) || - ctype_iscomplex(ct->info) || ctype_isvector(ct->info)) - return lj_ir_kkptr(J, (char *)o + ofs); - } -#endif - return lj_ir_kptr(J, (char *)o + ofs); -} - -LJFOLD(ADD KPTR KINT) -LJFOLD(ADD KPTR KINT64) -LJFOLD(ADD KKPTR KINT) -LJFOLD(ADD KKPTR KINT64) -LJFOLDF(kfold_add_kptr) -{ - void *p = ir_kptr(fleft); -#if LJ_64 - ptrdiff_t ofs = (ptrdiff_t)ir_kint64(fright)->u64; -#else - ptrdiff_t ofs = fright->i; -#endif - return lj_ir_kptr_(J, fleft->o, (char *)p + ofs); -} - -LJFOLD(ADD any KGC) -LJFOLD(ADD any KPTR) -LJFOLD(ADD any KKPTR) -LJFOLDF(kfold_add_kright) -{ - if (fleft->o == IR_KINT || fleft->o == IR_KINT64) { - IRRef1 tmp = fins->op1; fins->op1 = fins->op2; fins->op2 = tmp; - return RETRYFOLD; - } - return NEXTFOLD; -} - -/* -- Constant folding of conversions ------------------------------------- */ - -LJFOLD(TOBIT KNUM KNUM) -LJFOLDF(kfold_tobit) -{ - return INTFOLD(lj_num2bit(knumleft)); -} - -LJFOLD(CONV KINT IRCONV_NUM_INT) -LJFOLDF(kfold_conv_kint_num) -{ - return lj_ir_knum(J, (lua_Number)fleft->i); -} - -LJFOLD(CONV KINT IRCONV_NUM_U32) -LJFOLDF(kfold_conv_kintu32_num) -{ - return lj_ir_knum(J, (lua_Number)(uint32_t)fleft->i); -} - -LJFOLD(CONV KINT IRCONV_INT_I8) -LJFOLD(CONV KINT IRCONV_INT_U8) -LJFOLD(CONV KINT IRCONV_INT_I16) -LJFOLD(CONV KINT IRCONV_INT_U16) -LJFOLDF(kfold_conv_kint_ext) -{ - int32_t k = fleft->i; - if ((fins->op2 & IRCONV_SRCMASK) == IRT_I8) k = (int8_t)k; - else if ((fins->op2 & IRCONV_SRCMASK) == IRT_U8) k = (uint8_t)k; - else if ((fins->op2 & IRCONV_SRCMASK) == IRT_I16) k = (int16_t)k; - else k = (uint16_t)k; - return INTFOLD(k); -} - -LJFOLD(CONV KINT IRCONV_I64_INT) -LJFOLD(CONV KINT IRCONV_U64_INT) -LJFOLD(CONV KINT IRCONV_I64_U32) -LJFOLD(CONV KINT IRCONV_U64_U32) -LJFOLDF(kfold_conv_kint_i64) -{ - if ((fins->op2 & IRCONV_SEXT)) - return INT64FOLD((uint64_t)(int64_t)fleft->i); - else - return INT64FOLD((uint64_t)(int64_t)(uint32_t)fleft->i); -} - -LJFOLD(CONV KINT64 IRCONV_NUM_I64) -LJFOLDF(kfold_conv_kint64_num_i64) -{ - return lj_ir_knum(J, (lua_Number)(int64_t)ir_kint64(fleft)->u64); -} - -LJFOLD(CONV KINT64 IRCONV_NUM_U64) -LJFOLDF(kfold_conv_kint64_num_u64) -{ - return lj_ir_knum(J, (lua_Number)ir_kint64(fleft)->u64); -} - -LJFOLD(CONV KINT64 IRCONV_INT_I64) -LJFOLD(CONV KINT64 IRCONV_U32_I64) -LJFOLDF(kfold_conv_kint64_int_i64) -{ - return INTFOLD((int32_t)ir_kint64(fleft)->u64); -} - -LJFOLD(CONV KNUM IRCONV_INT_NUM) -LJFOLDF(kfold_conv_knum_int_num) -{ - lua_Number n = knumleft; - if (!(fins->op2 & IRCONV_TRUNC)) { - int32_t k = lj_num2int(n); - if (irt_isguard(fins->t) && n != (lua_Number)k) { - /* We're about to create a guard which always fails, like CONV +1.5. - ** Some pathological loops cause this during LICM, e.g.: - ** local x,k,t = 0,1.5,{1,[1.5]=2} - ** for i=1,200 do x = x+ t[k]; k = k == 1 and 1.5 or 1 end - ** assert(x == 300) - */ - return FAILFOLD; - } - return INTFOLD(k); - } else { - return INTFOLD((int32_t)n); - } -} - -LJFOLD(CONV KNUM IRCONV_U32_NUM) -LJFOLDF(kfold_conv_knum_u32_num) -{ - lua_assert((fins->op2 & IRCONV_TRUNC)); -#ifdef _MSC_VER - { /* Workaround for MSVC bug. */ - volatile uint32_t u = (uint32_t)knumleft; - return INTFOLD((int32_t)u); - } -#else - return INTFOLD((int32_t)(uint32_t)knumleft); -#endif -} - -LJFOLD(CONV KNUM IRCONV_I64_NUM) -LJFOLDF(kfold_conv_knum_i64_num) -{ - lua_assert((fins->op2 & IRCONV_TRUNC)); - return INT64FOLD((uint64_t)(int64_t)knumleft); -} - -LJFOLD(CONV KNUM IRCONV_U64_NUM) -LJFOLDF(kfold_conv_knum_u64_num) -{ - lua_assert((fins->op2 & IRCONV_TRUNC)); - return INT64FOLD(lj_num2u64(knumleft)); -} - -LJFOLD(TOSTR KNUM) -LJFOLDF(kfold_tostr_knum) -{ - return lj_ir_kstr(J, lj_str_fromnum(J->L, &knumleft)); -} - -LJFOLD(TOSTR KINT) -LJFOLDF(kfold_tostr_kint) -{ - return lj_ir_kstr(J, lj_str_fromint(J->L, fleft->i)); -} - -LJFOLD(STRTO KGC) -LJFOLDF(kfold_strto) -{ - TValue n; - if (lj_strscan_num(ir_kstr(fleft), &n)) - return lj_ir_knum(J, numV(&n)); - return FAILFOLD; -} - -/* -- Constant folding of equality checks --------------------------------- */ - -/* Don't constant-fold away FLOAD checks against KNULL. */ -LJFOLD(EQ FLOAD KNULL) -LJFOLD(NE FLOAD KNULL) -LJFOLDX(lj_opt_cse) - -/* But fold all other KNULL compares, since only KNULL is equal to KNULL. */ -LJFOLD(EQ any KNULL) -LJFOLD(NE any KNULL) -LJFOLD(EQ KNULL any) -LJFOLD(NE KNULL any) -LJFOLD(EQ KINT KINT) /* Constants are unique, so same refs <==> same value. */ -LJFOLD(NE KINT KINT) -LJFOLD(EQ KINT64 KINT64) -LJFOLD(NE KINT64 KINT64) -LJFOLD(EQ KGC KGC) -LJFOLD(NE KGC KGC) -LJFOLDF(kfold_kref) -{ - return CONDFOLD((fins->op1 == fins->op2) ^ (fins->o == IR_NE)); -} - -/* -- Algebraic shortcuts ------------------------------------------------- */ - -LJFOLD(FPMATH FPMATH IRFPM_FLOOR) -LJFOLD(FPMATH FPMATH IRFPM_CEIL) -LJFOLD(FPMATH FPMATH IRFPM_TRUNC) -LJFOLDF(shortcut_round) -{ - IRFPMathOp op = (IRFPMathOp)fleft->op2; - if (op == IRFPM_FLOOR || op == IRFPM_CEIL || op == IRFPM_TRUNC) - return LEFTFOLD; /* round(round_left(x)) = round_left(x) */ - return NEXTFOLD; -} - -LJFOLD(ABS ABS KNUM) -LJFOLDF(shortcut_left) -{ - return LEFTFOLD; /* f(g(x)) ==> g(x) */ -} - -LJFOLD(ABS NEG KNUM) -LJFOLDF(shortcut_dropleft) -{ - PHIBARRIER(fleft); - fins->op1 = fleft->op1; /* abs(neg(x)) ==> abs(x) */ - return RETRYFOLD; -} - -/* Note: no safe shortcuts with STRTO and TOSTR ("1e2" ==> +100 ==> "100"). */ -LJFOLD(NEG NEG any) -LJFOLD(BNOT BNOT) -LJFOLD(BSWAP BSWAP) -LJFOLDF(shortcut_leftleft) -{ - PHIBARRIER(fleft); /* See above. Fold would be ok, but not beneficial. */ - return fleft->op1; /* f(g(x)) ==> x */ -} - -/* -- FP algebraic simplifications ---------------------------------------- */ - -/* FP arithmetic is tricky -- there's not much to simplify. -** Please note the following common pitfalls before sending "improvements": -** x+0 ==> x is INVALID for x=-0 -** 0-x ==> -x is INVALID for x=+0 -** x*0 ==> 0 is INVALID for x=-0, x=+-Inf or x=NaN -*/ - -LJFOLD(ADD NEG any) -LJFOLDF(simplify_numadd_negx) -{ - PHIBARRIER(fleft); - fins->o = IR_SUB; /* (-a) + b ==> b - a */ - fins->op1 = fins->op2; - fins->op2 = fleft->op1; - return RETRYFOLD; -} - -LJFOLD(ADD any NEG) -LJFOLDF(simplify_numadd_xneg) -{ - PHIBARRIER(fright); - fins->o = IR_SUB; /* a + (-b) ==> a - b */ - fins->op2 = fright->op1; - return RETRYFOLD; -} - -LJFOLD(SUB any KNUM) -LJFOLDF(simplify_numsub_k) -{ - lua_Number n = knumright; - if (n == 0.0) /* x - (+-0) ==> x */ - return LEFTFOLD; - return NEXTFOLD; -} - -LJFOLD(SUB NEG KNUM) -LJFOLDF(simplify_numsub_negk) -{ - PHIBARRIER(fleft); - fins->op2 = fleft->op1; /* (-x) - k ==> (-k) - x */ - fins->op1 = (IRRef1)lj_ir_knum(J, -knumright); - return RETRYFOLD; -} - -LJFOLD(SUB any NEG) -LJFOLDF(simplify_numsub_xneg) -{ - PHIBARRIER(fright); - fins->o = IR_ADD; /* a - (-b) ==> a + b */ - fins->op2 = fright->op1; - return RETRYFOLD; -} - -LJFOLD(MUL any KNUM) -LJFOLD(DIV any KNUM) -LJFOLDF(simplify_nummuldiv_k) -{ - lua_Number n = knumright; - if (n == 1.0) { /* x o 1 ==> x */ - return LEFTFOLD; - } else if (n == -1.0) { /* x o -1 ==> -x */ - fins->o = IR_NEG; - fins->op2 = (IRRef1)lj_ir_knum_neg(J); - return RETRYFOLD; - } else if (fins->o == IR_MUL && n == 2.0) { /* x * 2 ==> x + x */ - fins->o = IR_ADD; - fins->op2 = fins->op1; - return RETRYFOLD; - } else if (fins->o == IR_DIV) { /* x / 2^k ==> x * 2^-k */ - uint64_t u = ir_knum(fright)->u64; - uint32_t ex = ((uint32_t)(u >> 52) & 0x7ff); - if ((u & U64x(000fffff,ffffffff)) == 0 && ex - 1 < 0x7fd) { - u = (u & ((uint64_t)1 << 63)) | ((uint64_t)(0x7fe - ex) << 52); - fins->o = IR_MUL; /* Multiply by exact reciprocal. */ - fins->op2 = lj_ir_knum_u64(J, u); - return RETRYFOLD; - } - } - return NEXTFOLD; -} - -LJFOLD(MUL NEG KNUM) -LJFOLD(DIV NEG KNUM) -LJFOLDF(simplify_nummuldiv_negk) -{ - PHIBARRIER(fleft); - fins->op1 = fleft->op1; /* (-a) o k ==> a o (-k) */ - fins->op2 = (IRRef1)lj_ir_knum(J, -knumright); - return RETRYFOLD; -} - -LJFOLD(MUL NEG NEG) -LJFOLD(DIV NEG NEG) -LJFOLDF(simplify_nummuldiv_negneg) -{ - PHIBARRIER(fleft); - PHIBARRIER(fright); - fins->op1 = fleft->op1; /* (-a) o (-b) ==> a o b */ - fins->op2 = fright->op1; - return RETRYFOLD; -} - -LJFOLD(POW any KINT) -LJFOLDF(simplify_numpow_xk) -{ - int32_t k = fright->i; - TRef ref = fins->op1; - if (k == 0) /* x ^ 0 ==> 1 */ - return lj_ir_knum_one(J); /* Result must be a number, not an int. */ - if (k == 1) /* x ^ 1 ==> x */ - return LEFTFOLD; - if ((uint32_t)(k+65536) > 2*65536u) /* Limit code explosion. */ - return NEXTFOLD; - if (k < 0) { /* x ^ (-k) ==> (1/x) ^ k. */ - ref = emitir(IRTN(IR_DIV), lj_ir_knum_one(J), ref); - k = -k; - } - /* Unroll x^k for 1 <= k <= 65536. */ - for (; (k & 1) == 0; k >>= 1) /* Handle leading zeros. */ - ref = emitir(IRTN(IR_MUL), ref, ref); - if ((k >>= 1) != 0) { /* Handle trailing bits. */ - TRef tmp = emitir(IRTN(IR_MUL), ref, ref); - for (; k != 1; k >>= 1) { - if (k & 1) - ref = emitir(IRTN(IR_MUL), ref, tmp); - tmp = emitir(IRTN(IR_MUL), tmp, tmp); - } - ref = emitir(IRTN(IR_MUL), ref, tmp); - } - return ref; -} - -LJFOLD(POW KNUM any) -LJFOLDF(simplify_numpow_kx) -{ - lua_Number n = knumleft; - if (n == 2.0) { /* 2.0 ^ i ==> ldexp(1.0, tonum(i)) */ - fins->o = IR_CONV; -#if LJ_TARGET_X86ORX64 - fins->op1 = fins->op2; - fins->op2 = IRCONV_NUM_INT; - fins->op2 = (IRRef1)lj_opt_fold(J); -#endif - fins->op1 = (IRRef1)lj_ir_knum_one(J); - fins->o = IR_LDEXP; - return RETRYFOLD; - } - return NEXTFOLD; -} - -/* -- Simplify conversions ------------------------------------------------ */ - -LJFOLD(CONV CONV IRCONV_NUM_INT) /* _NUM */ -LJFOLDF(shortcut_conv_num_int) -{ - PHIBARRIER(fleft); - /* Only safe with a guarded conversion to int. */ - if ((fleft->op2 & IRCONV_SRCMASK) == IRT_NUM && irt_isguard(fleft->t)) - return fleft->op1; /* f(g(x)) ==> x */ - return NEXTFOLD; -} - -LJFOLD(CONV CONV IRCONV_INT_NUM) /* _INT */ -LJFOLD(CONV CONV IRCONV_U32_NUM) /* _U32*/ -LJFOLDF(simplify_conv_int_num) -{ - /* Fold even across PHI to avoid expensive num->int conversions in loop. */ - if ((fleft->op2 & IRCONV_SRCMASK) == - ((fins->op2 & IRCONV_DSTMASK) >> IRCONV_DSH)) - return fleft->op1; - return NEXTFOLD; -} - -LJFOLD(CONV CONV IRCONV_I64_NUM) /* _INT or _U32 */ -LJFOLD(CONV CONV IRCONV_U64_NUM) /* _INT or _U32 */ -LJFOLDF(simplify_conv_i64_num) -{ - PHIBARRIER(fleft); - if ((fleft->op2 & IRCONV_SRCMASK) == IRT_INT) { - /* Reduce to a sign-extension. */ - fins->op1 = fleft->op1; - fins->op2 = ((IRT_I64<<5)|IRT_INT|IRCONV_SEXT); - return RETRYFOLD; - } else if ((fleft->op2 & IRCONV_SRCMASK) == IRT_U32) { -#if LJ_TARGET_X64 - return fleft->op1; -#else - /* Reduce to a zero-extension. */ - fins->op1 = fleft->op1; - fins->op2 = (IRT_I64<<5)|IRT_U32; - return RETRYFOLD; -#endif - } - return NEXTFOLD; -} - -LJFOLD(CONV CONV IRCONV_INT_I64) /* _INT or _U32 */ -LJFOLD(CONV CONV IRCONV_INT_U64) /* _INT or _U32 */ -LJFOLD(CONV CONV IRCONV_U32_I64) /* _INT or _U32 */ -LJFOLD(CONV CONV IRCONV_U32_U64) /* _INT or _U32 */ -LJFOLDF(simplify_conv_int_i64) -{ - int src; - PHIBARRIER(fleft); - src = (fleft->op2 & IRCONV_SRCMASK); - if (src == IRT_INT || src == IRT_U32) { - if (src == ((fins->op2 & IRCONV_DSTMASK) >> IRCONV_DSH)) { - return fleft->op1; - } else { - fins->op2 = ((fins->op2 & IRCONV_DSTMASK) | src); - fins->op1 = fleft->op1; - return RETRYFOLD; - } - } - return NEXTFOLD; -} - -LJFOLD(CONV CONV IRCONV_FLOAT_NUM) /* _FLOAT */ -LJFOLDF(simplify_conv_flt_num) -{ - PHIBARRIER(fleft); - if ((fleft->op2 & IRCONV_SRCMASK) == IRT_FLOAT) - return fleft->op1; - return NEXTFOLD; -} - -/* Shortcut TOBIT + IRT_NUM <- IRT_INT/IRT_U32 conversion. */ -LJFOLD(TOBIT CONV KNUM) -LJFOLDF(simplify_tobit_conv) -{ - if ((fleft->op2 & IRCONV_SRCMASK) == IRT_INT || - (fleft->op2 & IRCONV_SRCMASK) == IRT_U32) { - /* Fold even across PHI to avoid expensive num->int conversions in loop. */ - lua_assert(irt_isnum(fleft->t)); - return fleft->op1; - } - return NEXTFOLD; -} - -/* Shortcut floor/ceil/round + IRT_NUM <- IRT_INT/IRT_U32 conversion. */ -LJFOLD(FPMATH CONV IRFPM_FLOOR) -LJFOLD(FPMATH CONV IRFPM_CEIL) -LJFOLD(FPMATH CONV IRFPM_TRUNC) -LJFOLDF(simplify_floor_conv) -{ - if ((fleft->op2 & IRCONV_SRCMASK) == IRT_INT || - (fleft->op2 & IRCONV_SRCMASK) == IRT_U32) - return LEFTFOLD; - return NEXTFOLD; -} - -/* Strength reduction of widening. */ -LJFOLD(CONV any IRCONV_I64_INT) -LJFOLD(CONV any IRCONV_U64_INT) -LJFOLDF(simplify_conv_sext) -{ - IRRef ref = fins->op1; - int64_t ofs = 0; - if (!(fins->op2 & IRCONV_SEXT)) - return NEXTFOLD; - PHIBARRIER(fleft); - if (fleft->o == IR_XLOAD && (irt_isu8(fleft->t) || irt_isu16(fleft->t))) - goto ok_reduce; - if (fleft->o == IR_ADD && irref_isk(fleft->op2)) { - ofs = (int64_t)IR(fleft->op2)->i; - ref = fleft->op1; - } - /* Use scalar evolution analysis results to strength-reduce sign-extension. */ - if (ref == J->scev.idx) { - IRRef lo = J->scev.dir ? J->scev.start : J->scev.stop; - lua_assert(irt_isint(J->scev.t)); - if (lo && IR(lo)->i + ofs >= 0) { - ok_reduce: -#if LJ_TARGET_X64 - /* Eliminate widening. All 32 bit ops do an implicit zero-extension. */ - return LEFTFOLD; -#else - /* Reduce to a (cheaper) zero-extension. */ - fins->op2 &= ~IRCONV_SEXT; - return RETRYFOLD; -#endif - } - } - return NEXTFOLD; -} - -/* Strength reduction of narrowing. */ -LJFOLD(CONV ADD IRCONV_INT_I64) -LJFOLD(CONV SUB IRCONV_INT_I64) -LJFOLD(CONV MUL IRCONV_INT_I64) -LJFOLD(CONV ADD IRCONV_INT_U64) -LJFOLD(CONV SUB IRCONV_INT_U64) -LJFOLD(CONV MUL IRCONV_INT_U64) -LJFOLD(CONV ADD IRCONV_U32_I64) -LJFOLD(CONV SUB IRCONV_U32_I64) -LJFOLD(CONV MUL IRCONV_U32_I64) -LJFOLD(CONV ADD IRCONV_U32_U64) -LJFOLD(CONV SUB IRCONV_U32_U64) -LJFOLD(CONV MUL IRCONV_U32_U64) -LJFOLDF(simplify_conv_narrow) -{ - IROp op = (IROp)fleft->o; - IRType t = irt_type(fins->t); - IRRef op1 = fleft->op1, op2 = fleft->op2, mode = fins->op2; - PHIBARRIER(fleft); - op1 = emitir(IRTI(IR_CONV), op1, mode); - op2 = emitir(IRTI(IR_CONV), op2, mode); - fins->ot = IRT(op, t); - fins->op1 = op1; - fins->op2 = op2; - return RETRYFOLD; -} - -/* Special CSE rule for CONV. */ -LJFOLD(CONV any any) -LJFOLDF(cse_conv) -{ - if (LJ_LIKELY(J->flags & JIT_F_OPT_CSE)) { - IRRef op1 = fins->op1, op2 = (fins->op2 & IRCONV_MODEMASK); - uint8_t guard = irt_isguard(fins->t); - IRRef ref = J->chain[IR_CONV]; - while (ref > op1) { - IRIns *ir = IR(ref); - /* Commoning with stronger checks is ok. */ - if (ir->op1 == op1 && (ir->op2 & IRCONV_MODEMASK) == op2 && - irt_isguard(ir->t) >= guard) - return ref; - ref = ir->prev; - } - } - return EMITFOLD; /* No fallthrough to regular CSE. */ -} - -/* FP conversion narrowing. */ -LJFOLD(TOBIT ADD KNUM) -LJFOLD(TOBIT SUB KNUM) -LJFOLD(CONV ADD IRCONV_INT_NUM) -LJFOLD(CONV SUB IRCONV_INT_NUM) -LJFOLD(CONV ADD IRCONV_I64_NUM) -LJFOLD(CONV SUB IRCONV_I64_NUM) -LJFOLDF(narrow_convert) -{ - PHIBARRIER(fleft); - /* Narrowing ignores PHIs and repeating it inside the loop is not useful. */ - if (J->chain[IR_LOOP]) - return NEXTFOLD; - lua_assert(fins->o != IR_CONV || (fins->op2&IRCONV_CONVMASK) != IRCONV_TOBIT); - return lj_opt_narrow_convert(J); -} - -/* -- Integer algebraic simplifications ----------------------------------- */ - -LJFOLD(ADD any KINT) -LJFOLD(ADDOV any KINT) -LJFOLD(SUBOV any KINT) -LJFOLDF(simplify_intadd_k) -{ - if (fright->i == 0) /* i o 0 ==> i */ - return LEFTFOLD; - return NEXTFOLD; -} - -LJFOLD(MULOV any KINT) -LJFOLDF(simplify_intmul_k) -{ - if (fright->i == 0) /* i * 0 ==> 0 */ - return RIGHTFOLD; - if (fright->i == 1) /* i * 1 ==> i */ - return LEFTFOLD; - if (fright->i == 2) { /* i * 2 ==> i + i */ - fins->o = IR_ADDOV; - fins->op2 = fins->op1; - return RETRYFOLD; - } - return NEXTFOLD; -} - -LJFOLD(SUB any KINT) -LJFOLDF(simplify_intsub_k) -{ - if (fright->i == 0) /* i - 0 ==> i */ - return LEFTFOLD; - fins->o = IR_ADD; /* i - k ==> i + (-k) */ - fins->op2 = (IRRef1)lj_ir_kint(J, -fright->i); /* Overflow for -2^31 ok. */ - return RETRYFOLD; -} - -LJFOLD(SUB KINT any) -LJFOLD(SUB KINT64 any) -LJFOLDF(simplify_intsub_kleft) -{ - if (fleft->o == IR_KINT ? (fleft->i == 0) : (ir_kint64(fleft)->u64 == 0)) { - fins->o = IR_NEG; /* 0 - i ==> -i */ - fins->op1 = fins->op2; - return RETRYFOLD; - } - return NEXTFOLD; -} - -LJFOLD(ADD any KINT64) -LJFOLDF(simplify_intadd_k64) -{ - if (ir_kint64(fright)->u64 == 0) /* i + 0 ==> i */ - return LEFTFOLD; - return NEXTFOLD; -} - -LJFOLD(SUB any KINT64) -LJFOLDF(simplify_intsub_k64) -{ - uint64_t k = ir_kint64(fright)->u64; - if (k == 0) /* i - 0 ==> i */ - return LEFTFOLD; - fins->o = IR_ADD; /* i - k ==> i + (-k) */ - fins->op2 = (IRRef1)lj_ir_kint64(J, (uint64_t)-(int64_t)k); - return RETRYFOLD; -} - -static TRef simplify_intmul_k(jit_State *J, int32_t k) -{ - /* Note: many more simplifications are possible, e.g. 2^k1 +- 2^k2. - ** But this is mainly intended for simple address arithmetic. - ** Also it's easier for the backend to optimize the original multiplies. - */ - if (k == 1) { /* i * 1 ==> i */ - return LEFTFOLD; - } else if ((k & (k-1)) == 0) { /* i * 2^k ==> i << k */ - fins->o = IR_BSHL; - fins->op2 = lj_ir_kint(J, lj_fls((uint32_t)k)); - return RETRYFOLD; - } - return NEXTFOLD; -} - -LJFOLD(MUL any KINT) -LJFOLDF(simplify_intmul_k32) -{ - if (fright->i == 0) /* i * 0 ==> 0 */ - return INTFOLD(0); - else if (fright->i > 0) - return simplify_intmul_k(J, fright->i); - return NEXTFOLD; -} - -LJFOLD(MUL any KINT64) -LJFOLDF(simplify_intmul_k64) -{ - if (ir_kint64(fright)->u64 == 0) /* i * 0 ==> 0 */ - return INT64FOLD(0); -#if LJ_64 - /* NYI: SPLIT for BSHL and 32 bit backend support. */ - else if (ir_kint64(fright)->u64 < 0x80000000u) - return simplify_intmul_k(J, (int32_t)ir_kint64(fright)->u64); -#endif - return NEXTFOLD; -} - -LJFOLD(MOD any KINT) -LJFOLDF(simplify_intmod_k) -{ - int32_t k = fright->i; - lua_assert(k != 0); - if (k > 0 && (k & (k-1)) == 0) { /* i % (2^k) ==> i & (2^k-1) */ - fins->o = IR_BAND; - fins->op2 = lj_ir_kint(J, k-1); - return RETRYFOLD; - } - return NEXTFOLD; -} - -LJFOLD(MOD KINT any) -LJFOLDF(simplify_intmod_kleft) -{ - if (fleft->i == 0) - return INTFOLD(0); - return NEXTFOLD; -} - -LJFOLD(SUB any any) -LJFOLD(SUBOV any any) -LJFOLDF(simplify_intsub) -{ - if (fins->op1 == fins->op2 && !irt_isnum(fins->t)) /* i - i ==> 0 */ - return irt_is64(fins->t) ? INT64FOLD(0) : INTFOLD(0); - return NEXTFOLD; -} - -LJFOLD(SUB ADD any) -LJFOLDF(simplify_intsubadd_leftcancel) -{ - if (!irt_isnum(fins->t)) { - PHIBARRIER(fleft); - if (fins->op2 == fleft->op1) /* (i + j) - i ==> j */ - return fleft->op2; - if (fins->op2 == fleft->op2) /* (i + j) - j ==> i */ - return fleft->op1; - } - return NEXTFOLD; -} - -LJFOLD(SUB SUB any) -LJFOLDF(simplify_intsubsub_leftcancel) -{ - if (!irt_isnum(fins->t)) { - PHIBARRIER(fleft); - if (fins->op2 == fleft->op1) { /* (i - j) - i ==> 0 - j */ - fins->op1 = (IRRef1)lj_ir_kint(J, 0); - fins->op2 = fleft->op2; - return RETRYFOLD; - } - } - return NEXTFOLD; -} - -LJFOLD(SUB any SUB) -LJFOLDF(simplify_intsubsub_rightcancel) -{ - if (!irt_isnum(fins->t)) { - PHIBARRIER(fright); - if (fins->op1 == fright->op1) /* i - (i - j) ==> j */ - return fright->op2; - } - return NEXTFOLD; -} - -LJFOLD(SUB any ADD) -LJFOLDF(simplify_intsubadd_rightcancel) -{ - if (!irt_isnum(fins->t)) { - PHIBARRIER(fright); - if (fins->op1 == fright->op1) { /* i - (i + j) ==> 0 - j */ - fins->op2 = fright->op2; - fins->op1 = (IRRef1)lj_ir_kint(J, 0); - return RETRYFOLD; - } - if (fins->op1 == fright->op2) { /* i - (j + i) ==> 0 - j */ - fins->op2 = fright->op1; - fins->op1 = (IRRef1)lj_ir_kint(J, 0); - return RETRYFOLD; - } - } - return NEXTFOLD; -} - -LJFOLD(SUB ADD ADD) -LJFOLDF(simplify_intsubaddadd_cancel) -{ - if (!irt_isnum(fins->t)) { - PHIBARRIER(fleft); - PHIBARRIER(fright); - if (fleft->op1 == fright->op1) { /* (i + j1) - (i + j2) ==> j1 - j2 */ - fins->op1 = fleft->op2; - fins->op2 = fright->op2; - return RETRYFOLD; - } - if (fleft->op1 == fright->op2) { /* (i + j1) - (j2 + i) ==> j1 - j2 */ - fins->op1 = fleft->op2; - fins->op2 = fright->op1; - return RETRYFOLD; - } - if (fleft->op2 == fright->op1) { /* (j1 + i) - (i + j2) ==> j1 - j2 */ - fins->op1 = fleft->op1; - fins->op2 = fright->op2; - return RETRYFOLD; - } - if (fleft->op2 == fright->op2) { /* (j1 + i) - (j2 + i) ==> j1 - j2 */ - fins->op1 = fleft->op1; - fins->op2 = fright->op1; - return RETRYFOLD; - } - } - return NEXTFOLD; -} - -LJFOLD(BAND any KINT) -LJFOLD(BAND any KINT64) -LJFOLDF(simplify_band_k) -{ - int64_t k = fright->o == IR_KINT ? (int64_t)fright->i : - (int64_t)ir_k64(fright)->u64; - if (k == 0) /* i & 0 ==> 0 */ - return RIGHTFOLD; - if (k == -1) /* i & -1 ==> i */ - return LEFTFOLD; - return NEXTFOLD; -} - -LJFOLD(BOR any KINT) -LJFOLD(BOR any KINT64) -LJFOLDF(simplify_bor_k) -{ - int64_t k = fright->o == IR_KINT ? (int64_t)fright->i : - (int64_t)ir_k64(fright)->u64; - if (k == 0) /* i | 0 ==> i */ - return LEFTFOLD; - if (k == -1) /* i | -1 ==> -1 */ - return RIGHTFOLD; - return NEXTFOLD; -} - -LJFOLD(BXOR any KINT) -LJFOLD(BXOR any KINT64) -LJFOLDF(simplify_bxor_k) -{ - int64_t k = fright->o == IR_KINT ? (int64_t)fright->i : - (int64_t)ir_k64(fright)->u64; - if (k == 0) /* i xor 0 ==> i */ - return LEFTFOLD; - if (k == -1) { /* i xor -1 ==> ~i */ - fins->o = IR_BNOT; - fins->op2 = 0; - return RETRYFOLD; - } - return NEXTFOLD; -} - -LJFOLD(BSHL any KINT) -LJFOLD(BSHR any KINT) -LJFOLD(BSAR any KINT) -LJFOLD(BROL any KINT) -LJFOLD(BROR any KINT) -LJFOLDF(simplify_shift_ik) -{ - int32_t mask = irt_is64(fins->t) ? 63 : 31; - int32_t k = (fright->i & mask); - if (k == 0) /* i o 0 ==> i */ - return LEFTFOLD; - if (k == 1 && fins->o == IR_BSHL) { /* i << 1 ==> i + i */ - fins->o = IR_ADD; - fins->op2 = fins->op1; - return RETRYFOLD; - } - if (k != fright->i) { /* i o k ==> i o (k & mask) */ - fins->op2 = (IRRef1)lj_ir_kint(J, k); - return RETRYFOLD; - } -#ifndef LJ_TARGET_UNIFYROT - if (fins->o == IR_BROR) { /* bror(i, k) ==> brol(i, (-k)&mask) */ - fins->o = IR_BROL; - fins->op2 = (IRRef1)lj_ir_kint(J, (-k)&mask); - return RETRYFOLD; - } -#endif - return NEXTFOLD; -} - -LJFOLD(BSHL any BAND) -LJFOLD(BSHR any BAND) -LJFOLD(BSAR any BAND) -LJFOLD(BROL any BAND) -LJFOLD(BROR any BAND) -LJFOLDF(simplify_shift_andk) -{ - IRIns *irk = IR(fright->op2); - PHIBARRIER(fright); - if ((fins->o < IR_BROL ? LJ_TARGET_MASKSHIFT : LJ_TARGET_MASKROT) && - irk->o == IR_KINT) { /* i o (j & mask) ==> i o j */ - int32_t mask = irt_is64(fins->t) ? 63 : 31; - int32_t k = irk->i & mask; - if (k == mask) { - fins->op2 = fright->op1; - return RETRYFOLD; - } - } - return NEXTFOLD; -} - -LJFOLD(BSHL KINT any) -LJFOLD(BSHR KINT any) -LJFOLD(BSHL KINT64 any) -LJFOLD(BSHR KINT64 any) -LJFOLDF(simplify_shift1_ki) -{ - int64_t k = fleft->o == IR_KINT ? (int64_t)fleft->i : - (int64_t)ir_k64(fleft)->u64; - if (k == 0) /* 0 o i ==> 0 */ - return LEFTFOLD; - return NEXTFOLD; -} - -LJFOLD(BSAR KINT any) -LJFOLD(BROL KINT any) -LJFOLD(BROR KINT any) -LJFOLD(BSAR KINT64 any) -LJFOLD(BROL KINT64 any) -LJFOLD(BROR KINT64 any) -LJFOLDF(simplify_shift2_ki) -{ - int64_t k = fleft->o == IR_KINT ? (int64_t)fleft->i : - (int64_t)ir_k64(fleft)->u64; - if (k == 0 || k == -1) /* 0 o i ==> 0; -1 o i ==> -1 */ - return LEFTFOLD; - return NEXTFOLD; -} - -LJFOLD(BSHL BAND KINT) -LJFOLD(BSHR BAND KINT) -LJFOLD(BROL BAND KINT) -LJFOLD(BROR BAND KINT) -LJFOLDF(simplify_shiftk_andk) -{ - IRIns *irk = IR(fleft->op2); - PHIBARRIER(fleft); - if (irk->o == IR_KINT) { /* (i & k1) o k2 ==> (i o k2) & (k1 o k2) */ - int32_t k = kfold_intop(irk->i, fright->i, (IROp)fins->o); - fins->op1 = fleft->op1; - fins->op1 = (IRRef1)lj_opt_fold(J); - fins->op2 = (IRRef1)lj_ir_kint(J, k); - fins->ot = IRTI(IR_BAND); - return RETRYFOLD; - } - return NEXTFOLD; -} - -LJFOLD(BAND BSHL KINT) -LJFOLD(BAND BSHR KINT) -LJFOLDF(simplify_andk_shiftk) -{ - IRIns *irk = IR(fleft->op2); - if (irk->o == IR_KINT && - kfold_intop(-1, irk->i, (IROp)fleft->o) == fright->i) - return LEFTFOLD; /* (i o k1) & k2 ==> i, if (-1 o k1) == k2 */ - return NEXTFOLD; -} - -/* -- Reassociation ------------------------------------------------------- */ - -LJFOLD(ADD ADD KINT) -LJFOLD(MUL MUL KINT) -LJFOLD(BAND BAND KINT) -LJFOLD(BOR BOR KINT) -LJFOLD(BXOR BXOR KINT) -LJFOLDF(reassoc_intarith_k) -{ - IRIns *irk = IR(fleft->op2); - if (irk->o == IR_KINT) { - int32_t k = kfold_intop(irk->i, fright->i, (IROp)fins->o); - if (k == irk->i) /* (i o k1) o k2 ==> i o k1, if (k1 o k2) == k1. */ - return LEFTFOLD; - PHIBARRIER(fleft); - fins->op1 = fleft->op1; - fins->op2 = (IRRef1)lj_ir_kint(J, k); - return RETRYFOLD; /* (i o k1) o k2 ==> i o (k1 o k2) */ - } - return NEXTFOLD; -} - -LJFOLD(ADD ADD KINT64) -LJFOLD(MUL MUL KINT64) -LJFOLD(BAND BAND KINT64) -LJFOLD(BOR BOR KINT64) -LJFOLD(BXOR BXOR KINT64) -LJFOLDF(reassoc_intarith_k64) -{ -#if LJ_HASFFI || LJ_64 - IRIns *irk = IR(fleft->op2); - if (irk->o == IR_KINT64) { - uint64_t k = kfold_int64arith(ir_k64(irk)->u64, - ir_k64(fright)->u64, (IROp)fins->o); - PHIBARRIER(fleft); - fins->op1 = fleft->op1; - fins->op2 = (IRRef1)lj_ir_kint64(J, k); - return RETRYFOLD; /* (i o k1) o k2 ==> i o (k1 o k2) */ - } - return NEXTFOLD; -#else - UNUSED(J); lua_assert(0); return FAILFOLD; -#endif -} - -LJFOLD(MIN MIN any) -LJFOLD(MAX MAX any) -LJFOLD(BAND BAND any) -LJFOLD(BOR BOR any) -LJFOLDF(reassoc_dup) -{ - if (fins->op2 == fleft->op1 || fins->op2 == fleft->op2) - return LEFTFOLD; /* (a o b) o a ==> a o b; (a o b) o b ==> a o b */ - return NEXTFOLD; -} - -LJFOLD(BXOR BXOR any) -LJFOLDF(reassoc_bxor) -{ - PHIBARRIER(fleft); - if (fins->op2 == fleft->op1) /* (a xor b) xor a ==> b */ - return fleft->op2; - if (fins->op2 == fleft->op2) /* (a xor b) xor b ==> a */ - return fleft->op1; - return NEXTFOLD; -} - -LJFOLD(BSHL BSHL KINT) -LJFOLD(BSHR BSHR KINT) -LJFOLD(BSAR BSAR KINT) -LJFOLD(BROL BROL KINT) -LJFOLD(BROR BROR KINT) -LJFOLDF(reassoc_shift) -{ - IRIns *irk = IR(fleft->op2); - PHIBARRIER(fleft); /* The (shift any KINT) rule covers k2 == 0 and more. */ - if (irk->o == IR_KINT) { /* (i o k1) o k2 ==> i o (k1 + k2) */ - int32_t mask = irt_is64(fins->t) ? 63 : 31; - int32_t k = (irk->i & mask) + (fright->i & mask); - if (k > mask) { /* Combined shift too wide? */ - if (fins->o == IR_BSHL || fins->o == IR_BSHR) - return mask == 31 ? INTFOLD(0) : INT64FOLD(0); - else if (fins->o == IR_BSAR) - k = mask; - else - k &= mask; - } - fins->op1 = fleft->op1; - fins->op2 = (IRRef1)lj_ir_kint(J, k); - return RETRYFOLD; - } - return NEXTFOLD; -} - -LJFOLD(MIN MIN KNUM) -LJFOLD(MAX MAX KNUM) -LJFOLD(MIN MIN KINT) -LJFOLD(MAX MAX KINT) -LJFOLDF(reassoc_minmax_k) -{ - IRIns *irk = IR(fleft->op2); - if (irk->o == IR_KNUM) { - lua_Number a = ir_knum(irk)->n; - lua_Number y = lj_vm_foldarith(a, knumright, fins->o - IR_ADD); - if (a == y) /* (x o k1) o k2 ==> x o k1, if (k1 o k2) == k1. */ - return LEFTFOLD; - PHIBARRIER(fleft); - fins->op1 = fleft->op1; - fins->op2 = (IRRef1)lj_ir_knum(J, y); - return RETRYFOLD; /* (x o k1) o k2 ==> x o (k1 o k2) */ - } else if (irk->o == IR_KINT) { - int32_t a = irk->i; - int32_t y = kfold_intop(a, fright->i, fins->o); - if (a == y) /* (x o k1) o k2 ==> x o k1, if (k1 o k2) == k1. */ - return LEFTFOLD; - PHIBARRIER(fleft); - fins->op1 = fleft->op1; - fins->op2 = (IRRef1)lj_ir_kint(J, y); - return RETRYFOLD; /* (x o k1) o k2 ==> x o (k1 o k2) */ - } - return NEXTFOLD; -} - -LJFOLD(MIN MAX any) -LJFOLD(MAX MIN any) -LJFOLDF(reassoc_minmax_left) -{ - if (fins->op2 == fleft->op1 || fins->op2 == fleft->op2) - return RIGHTFOLD; /* (b o1 a) o2 b ==> b; (a o1 b) o2 b ==> b */ - return NEXTFOLD; -} - -LJFOLD(MIN any MAX) -LJFOLD(MAX any MIN) -LJFOLDF(reassoc_minmax_right) -{ - if (fins->op1 == fright->op1 || fins->op1 == fright->op2) - return LEFTFOLD; /* a o2 (a o1 b) ==> a; a o2 (b o1 a) ==> a */ - return NEXTFOLD; -} - -/* -- Array bounds check elimination -------------------------------------- */ - -/* Eliminate ABC across PHIs to handle t[i-1] forwarding case. -** ABC(asize, (i+k)+(-k)) ==> ABC(asize, i), but only if it already exists. -** Could be generalized to (i+k1)+k2 ==> i+(k1+k2), but needs better disambig. -*/ -LJFOLD(ABC any ADD) -LJFOLDF(abc_fwd) -{ - if (LJ_LIKELY(J->flags & JIT_F_OPT_ABC)) { - if (irref_isk(fright->op2)) { - IRIns *add2 = IR(fright->op1); - if (add2->o == IR_ADD && irref_isk(add2->op2) && - IR(fright->op2)->i == -IR(add2->op2)->i) { - IRRef ref = J->chain[IR_ABC]; - IRRef lim = add2->op1; - if (fins->op1 > lim) lim = fins->op1; - while (ref > lim) { - IRIns *ir = IR(ref); - if (ir->op1 == fins->op1 && ir->op2 == add2->op1) - return DROPFOLD; - ref = ir->prev; - } - } - } - } - return NEXTFOLD; -} - -/* Eliminate ABC for constants. -** ABC(asize, k1), ABC(asize k2) ==> ABC(asize, max(k1, k2)) -** Drop second ABC if k2 is lower. Otherwise patch first ABC with k2. -*/ -LJFOLD(ABC any KINT) -LJFOLDF(abc_k) -{ - if (LJ_LIKELY(J->flags & JIT_F_OPT_ABC)) { - IRRef ref = J->chain[IR_ABC]; - IRRef asize = fins->op1; - while (ref > asize) { - IRIns *ir = IR(ref); - if (ir->op1 == asize && irref_isk(ir->op2)) { - int32_t k = IR(ir->op2)->i; - if (fright->i > k) - ir->op2 = fins->op2; - return DROPFOLD; - } - ref = ir->prev; - } - return EMITFOLD; /* Already performed CSE. */ - } - return NEXTFOLD; -} - -/* Eliminate invariant ABC inside loop. */ -LJFOLD(ABC any any) -LJFOLDF(abc_invar) -{ - /* Invariant ABC marked as PTR. Drop if op1 is invariant, too. */ - if (!irt_isint(fins->t) && fins->op1 < J->chain[IR_LOOP] && - !irt_isphi(IR(fins->op1)->t)) - return DROPFOLD; - return NEXTFOLD; -} - -/* -- Commutativity ------------------------------------------------------- */ - -/* The refs of commutative ops are canonicalized. Lower refs go to the right. -** Rationale behind this: -** - It (also) moves constants to the right. -** - It reduces the number of FOLD rules (e.g. (BOR any KINT) suffices). -** - It helps CSE to find more matches. -** - The assembler generates better code with constants at the right. -*/ - -LJFOLD(ADD any any) -LJFOLD(MUL any any) -LJFOLD(ADDOV any any) -LJFOLD(MULOV any any) -LJFOLDF(comm_swap) -{ - if (fins->op1 < fins->op2) { /* Move lower ref to the right. */ - IRRef1 tmp = fins->op1; - fins->op1 = fins->op2; - fins->op2 = tmp; - return RETRYFOLD; - } - return NEXTFOLD; -} - -LJFOLD(EQ any any) -LJFOLD(NE any any) -LJFOLDF(comm_equal) -{ - /* For non-numbers only: x == x ==> drop; x ~= x ==> fail */ - if (fins->op1 == fins->op2 && !irt_isnum(fins->t)) - return CONDFOLD(fins->o == IR_EQ); - return fold_comm_swap(J); -} - -LJFOLD(LT any any) -LJFOLD(GE any any) -LJFOLD(LE any any) -LJFOLD(GT any any) -LJFOLD(ULT any any) -LJFOLD(UGE any any) -LJFOLD(ULE any any) -LJFOLD(UGT any any) -LJFOLDF(comm_comp) -{ - /* For non-numbers only: x <=> x ==> drop; x <> x ==> fail */ - if (fins->op1 == fins->op2 && !irt_isnum(fins->t)) - return CONDFOLD((fins->o ^ (fins->o >> 1)) & 1); - if (fins->op1 < fins->op2) { /* Move lower ref to the right. */ - IRRef1 tmp = fins->op1; - fins->op1 = fins->op2; - fins->op2 = tmp; - fins->o ^= 3; /* GT <-> LT, GE <-> LE, does not affect U */ - return RETRYFOLD; - } - return NEXTFOLD; -} - -LJFOLD(BAND any any) -LJFOLD(BOR any any) -LJFOLD(MIN any any) -LJFOLD(MAX any any) -LJFOLDF(comm_dup) -{ - if (fins->op1 == fins->op2) /* x o x ==> x */ - return LEFTFOLD; - return fold_comm_swap(J); -} - -LJFOLD(BXOR any any) -LJFOLDF(comm_bxor) -{ - if (fins->op1 == fins->op2) /* i xor i ==> 0 */ - return irt_is64(fins->t) ? INT64FOLD(0) : INTFOLD(0); - return fold_comm_swap(J); -} - -/* -- Simplification of compound expressions ------------------------------ */ - -static TRef kfold_xload(jit_State *J, IRIns *ir, const void *p) -{ - int32_t k; - switch (irt_type(ir->t)) { - case IRT_NUM: return lj_ir_knum_u64(J, *(uint64_t *)p); - case IRT_I8: k = (int32_t)*(int8_t *)p; break; - case IRT_U8: k = (int32_t)*(uint8_t *)p; break; - case IRT_I16: k = (int32_t)(int16_t)lj_getu16(p); break; - case IRT_U16: k = (int32_t)(uint16_t)lj_getu16(p); break; - case IRT_INT: case IRT_U32: k = (int32_t)lj_getu32(p); break; - case IRT_I64: case IRT_U64: return lj_ir_kint64(J, *(uint64_t *)p); - default: return 0; - } - return lj_ir_kint(J, k); -} - -/* Turn: string.sub(str, a, b) == kstr -** into: string.byte(str, a) == string.byte(kstr, 1) etc. -** Note: this creates unaligned XLOADs on x86/x64. -*/ -LJFOLD(EQ SNEW KGC) -LJFOLD(NE SNEW KGC) -LJFOLDF(merge_eqne_snew_kgc) -{ - GCstr *kstr = ir_kstr(fright); - int32_t len = (int32_t)kstr->len; - lua_assert(irt_isstr(fins->t)); - -#if LJ_TARGET_UNALIGNED -#define FOLD_SNEW_MAX_LEN 4 /* Handle string lengths 0, 1, 2, 3, 4. */ -#define FOLD_SNEW_TYPE8 IRT_I8 /* Creates shorter immediates. */ -#else -#define FOLD_SNEW_MAX_LEN 1 /* Handle string lengths 0 or 1. */ -#define FOLD_SNEW_TYPE8 IRT_U8 /* Prefer unsigned loads. */ -#endif - - PHIBARRIER(fleft); - if (len <= FOLD_SNEW_MAX_LEN) { - IROp op = (IROp)fins->o; - IRRef strref = fleft->op1; - lua_assert(IR(strref)->o == IR_STRREF); - if (op == IR_EQ) { - emitir(IRTGI(IR_EQ), fleft->op2, lj_ir_kint(J, len)); - /* Caveat: fins/fleft/fright is no longer valid after emitir. */ - } else { - /* NE is not expanded since this would need an OR of two conds. */ - if (!irref_isk(fleft->op2)) /* Only handle the constant length case. */ - return NEXTFOLD; - if (IR(fleft->op2)->i != len) - return DROPFOLD; - } - if (len > 0) { - /* A 4 byte load for length 3 is ok -- all strings have an extra NUL. */ - uint16_t ot = (uint16_t)(len == 1 ? IRT(IR_XLOAD, FOLD_SNEW_TYPE8) : - len == 2 ? IRT(IR_XLOAD, IRT_U16) : - IRTI(IR_XLOAD)); - TRef tmp = emitir(ot, strref, - IRXLOAD_READONLY | (len > 1 ? IRXLOAD_UNALIGNED : 0)); - TRef val = kfold_xload(J, IR(tref_ref(tmp)), strdata(kstr)); - if (len == 3) - tmp = emitir(IRTI(IR_BAND), tmp, - lj_ir_kint(J, LJ_ENDIAN_SELECT(0x00ffffff, 0xffffff00))); - fins->op1 = (IRRef1)tmp; - fins->op2 = (IRRef1)val; - fins->ot = (IROpT)IRTGI(op); - return RETRYFOLD; - } else { - return DROPFOLD; - } - } - return NEXTFOLD; -} - -/* -- Loads --------------------------------------------------------------- */ - -/* Loads cannot be folded or passed on to CSE in general. -** Alias analysis is needed to check for forwarding opportunities. -** -** Caveat: *all* loads must be listed here or they end up at CSE! -*/ - -LJFOLD(ALOAD any) -LJFOLDX(lj_opt_fwd_aload) - -/* From HREF fwd (see below). Must eliminate, not supported by fwd/backend. */ -LJFOLD(HLOAD KKPTR) -LJFOLDF(kfold_hload_kkptr) -{ - UNUSED(J); - lua_assert(ir_kptr(fleft) == niltvg(J2G(J))); - return TREF_NIL; -} - -LJFOLD(HLOAD any) -LJFOLDX(lj_opt_fwd_hload) - -LJFOLD(ULOAD any) -LJFOLDX(lj_opt_fwd_uload) - -LJFOLD(CALLL any IRCALL_lj_tab_len) -LJFOLDX(lj_opt_fwd_tab_len) - -/* Upvalue refs are really loads, but there are no corresponding stores. -** So CSE is ok for them, except for UREFO across a GC step (see below). -** If the referenced function is const, its upvalue addresses are const, too. -** This can be used to improve CSE by looking for the same address, -** even if the upvalues originate from a different function. -*/ -LJFOLD(UREFO KGC any) -LJFOLD(UREFC KGC any) -LJFOLDF(cse_uref) -{ - if (LJ_LIKELY(J->flags & JIT_F_OPT_CSE)) { - IRRef ref = J->chain[fins->o]; - GCfunc *fn = ir_kfunc(fleft); - GCupval *uv = gco2uv(gcref(fn->l.uvptr[(fins->op2 >> 8)])); - while (ref > 0) { - IRIns *ir = IR(ref); - if (irref_isk(ir->op1)) { - GCfunc *fn2 = ir_kfunc(IR(ir->op1)); - if (gco2uv(gcref(fn2->l.uvptr[(ir->op2 >> 8)])) == uv) { - if (fins->o == IR_UREFO && gcstep_barrier(J, ref)) - break; - return ref; - } - } - ref = ir->prev; - } - } - return EMITFOLD; -} - -LJFOLD(HREFK any any) -LJFOLDX(lj_opt_fwd_hrefk) - -LJFOLD(HREF TNEW any) -LJFOLDF(fwd_href_tnew) -{ - if (lj_opt_fwd_href_nokey(J)) - return lj_ir_kkptr(J, niltvg(J2G(J))); - return NEXTFOLD; -} - -LJFOLD(HREF TDUP KPRI) -LJFOLD(HREF TDUP KGC) -LJFOLD(HREF TDUP KNUM) -LJFOLDF(fwd_href_tdup) -{ - TValue keyv; - lj_ir_kvalue(J->L, &keyv, fright); - if (lj_tab_get(J->L, ir_ktab(IR(fleft->op1)), &keyv) == niltvg(J2G(J)) && - lj_opt_fwd_href_nokey(J)) - return lj_ir_kkptr(J, niltvg(J2G(J))); - return NEXTFOLD; -} - -/* We can safely FOLD/CSE array/hash refs and field loads, since there -** are no corresponding stores. But we need to check for any NEWREF with -** an aliased table, as it may invalidate all of the pointers and fields. -** Only HREF needs the NEWREF check -- AREF and HREFK already depend on -** FLOADs. And NEWREF itself is treated like a store (see below). -*/ -LJFOLD(FLOAD TNEW IRFL_TAB_ASIZE) -LJFOLDF(fload_tab_tnew_asize) -{ - if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && lj_opt_fwd_tptr(J, fins->op1)) - return INTFOLD(fleft->op1); - return NEXTFOLD; -} - -LJFOLD(FLOAD TNEW IRFL_TAB_HMASK) -LJFOLDF(fload_tab_tnew_hmask) -{ - if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && lj_opt_fwd_tptr(J, fins->op1)) - return INTFOLD((1 << fleft->op2)-1); - return NEXTFOLD; -} - -LJFOLD(FLOAD TDUP IRFL_TAB_ASIZE) -LJFOLDF(fload_tab_tdup_asize) -{ - if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && lj_opt_fwd_tptr(J, fins->op1)) - return INTFOLD((int32_t)ir_ktab(IR(fleft->op1))->asize); - return NEXTFOLD; -} - -LJFOLD(FLOAD TDUP IRFL_TAB_HMASK) -LJFOLDF(fload_tab_tdup_hmask) -{ - if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && lj_opt_fwd_tptr(J, fins->op1)) - return INTFOLD((int32_t)ir_ktab(IR(fleft->op1))->hmask); - return NEXTFOLD; -} - -LJFOLD(HREF any any) -LJFOLD(FLOAD any IRFL_TAB_ARRAY) -LJFOLD(FLOAD any IRFL_TAB_NODE) -LJFOLD(FLOAD any IRFL_TAB_ASIZE) -LJFOLD(FLOAD any IRFL_TAB_HMASK) -LJFOLDF(fload_tab_ah) -{ - TRef tr = lj_opt_cse(J); - return lj_opt_fwd_tptr(J, tref_ref(tr)) ? tr : EMITFOLD; -} - -/* Strings are immutable, so we can safely FOLD/CSE the related FLOAD. */ -LJFOLD(FLOAD KGC IRFL_STR_LEN) -LJFOLDF(fload_str_len_kgc) -{ - if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) - return INTFOLD((int32_t)ir_kstr(fleft)->len); - return NEXTFOLD; -} - -LJFOLD(FLOAD SNEW IRFL_STR_LEN) -LJFOLDF(fload_str_len_snew) -{ - if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) { - PHIBARRIER(fleft); - return fleft->op2; - } - return NEXTFOLD; -} - -/* The C type ID of cdata objects is immutable. */ -LJFOLD(FLOAD KGC IRFL_CDATA_CTYPEID) -LJFOLDF(fload_cdata_typeid_kgc) -{ - if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) - return INTFOLD((int32_t)ir_kcdata(fleft)->ctypeid); - return NEXTFOLD; -} - -/* Get the contents of immutable cdata objects. */ -LJFOLD(FLOAD KGC IRFL_CDATA_PTR) -LJFOLD(FLOAD KGC IRFL_CDATA_INT) -LJFOLD(FLOAD KGC IRFL_CDATA_INT64) -LJFOLDF(fload_cdata_int64_kgc) -{ - if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) { - void *p = cdataptr(ir_kcdata(fleft)); - if (irt_is64(fins->t)) - return INT64FOLD(*(uint64_t *)p); - else - return INTFOLD(*(int32_t *)p); - } - return NEXTFOLD; -} - -LJFOLD(FLOAD CNEW IRFL_CDATA_CTYPEID) -LJFOLD(FLOAD CNEWI IRFL_CDATA_CTYPEID) -LJFOLDF(fload_cdata_typeid_cnew) -{ - if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) - return fleft->op1; /* No PHI barrier needed. CNEW/CNEWI op1 is const. */ - return NEXTFOLD; -} - -/* Pointer, int and int64 cdata objects are immutable. */ -LJFOLD(FLOAD CNEWI IRFL_CDATA_PTR) -LJFOLD(FLOAD CNEWI IRFL_CDATA_INT) -LJFOLD(FLOAD CNEWI IRFL_CDATA_INT64) -LJFOLDF(fload_cdata_ptr_int64_cnew) -{ - if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) - return fleft->op2; /* Fold even across PHI to avoid allocations. */ - return NEXTFOLD; -} - -LJFOLD(FLOAD any IRFL_STR_LEN) -LJFOLD(FLOAD any IRFL_CDATA_CTYPEID) -LJFOLD(FLOAD any IRFL_CDATA_PTR) -LJFOLD(FLOAD any IRFL_CDATA_INT) -LJFOLD(FLOAD any IRFL_CDATA_INT64) -LJFOLD(VLOAD any any) /* Vararg loads have no corresponding stores. */ -LJFOLDX(lj_opt_cse) - -/* All other field loads need alias analysis. */ -LJFOLD(FLOAD any any) -LJFOLDX(lj_opt_fwd_fload) - -/* This is for LOOP only. Recording handles SLOADs internally. */ -LJFOLD(SLOAD any any) -LJFOLDF(fwd_sload) -{ - if ((fins->op2 & IRSLOAD_FRAME)) { - TRef tr = lj_opt_cse(J); - return tref_ref(tr) < J->chain[IR_RETF] ? EMITFOLD : tr; - } else { - lua_assert(J->slot[fins->op1] != 0); - return J->slot[fins->op1]; - } -} - -/* Only fold for KKPTR. The pointer _and_ the contents must be const. */ -LJFOLD(XLOAD KKPTR any) -LJFOLDF(xload_kptr) -{ - TRef tr = kfold_xload(J, fins, ir_kptr(fleft)); - return tr ? tr : NEXTFOLD; -} - -LJFOLD(XLOAD any any) -LJFOLDX(lj_opt_fwd_xload) - -/* -- Write barriers ------------------------------------------------------ */ - -/* Write barriers are amenable to CSE, but not across any incremental -** GC steps. -** -** The same logic applies to open upvalue references, because a stack -** may be resized during a GC step (not the current stack, but maybe that -** of a coroutine). -*/ -LJFOLD(TBAR any) -LJFOLD(OBAR any any) -LJFOLD(UREFO any any) -LJFOLDF(barrier_tab) -{ - TRef tr = lj_opt_cse(J); - if (gcstep_barrier(J, tref_ref(tr))) /* CSE across GC step? */ - return EMITFOLD; /* Raw emit. Assumes fins is left intact by CSE. */ - return tr; -} - -LJFOLD(TBAR TNEW) -LJFOLD(TBAR TDUP) -LJFOLDF(barrier_tnew_tdup) -{ - /* New tables are always white and never need a barrier. */ - if (fins->op1 < J->chain[IR_LOOP]) /* Except across a GC step. */ - return NEXTFOLD; - return DROPFOLD; -} - -/* -- Stores and allocations ---------------------------------------------- */ - -/* Stores and allocations cannot be folded or passed on to CSE in general. -** But some stores can be eliminated with dead-store elimination (DSE). -** -** Caveat: *all* stores and allocs must be listed here or they end up at CSE! -*/ - -LJFOLD(ASTORE any any) -LJFOLD(HSTORE any any) -LJFOLDX(lj_opt_dse_ahstore) - -LJFOLD(USTORE any any) -LJFOLDX(lj_opt_dse_ustore) - -LJFOLD(FSTORE any any) -LJFOLDX(lj_opt_dse_fstore) - -LJFOLD(XSTORE any any) -LJFOLDX(lj_opt_dse_xstore) - -LJFOLD(NEWREF any any) /* Treated like a store. */ -LJFOLD(CALLS any any) -LJFOLD(CALLL any any) /* Safeguard fallback. */ -LJFOLD(CALLXS any any) -LJFOLD(XBAR) -LJFOLD(RETF any any) /* Modifies BASE. */ -LJFOLD(TNEW any any) -LJFOLD(TDUP any) -LJFOLD(CNEW any any) -LJFOLD(XSNEW any any) -LJFOLDX(lj_ir_emit) - -/* ------------------------------------------------------------------------ */ - -/* Every entry in the generated hash table is a 32 bit pattern: -** -** xxxxxxxx iiiiiii lllllll rrrrrrrrrr -** -** xxxxxxxx = 8 bit index into fold function table -** iiiiiii = 7 bit folded instruction opcode -** lllllll = 7 bit left instruction opcode -** rrrrrrrrrr = 8 bit right instruction opcode or 10 bits from literal field -*/ - -#include "lj_folddef.h" - -/* ------------------------------------------------------------------------ */ - -/* Fold IR instruction. */ -TRef LJ_FASTCALL lj_opt_fold(jit_State *J) -{ - uint32_t key, any; - IRRef ref; - - if (LJ_UNLIKELY((J->flags & JIT_F_OPT_MASK) != JIT_F_OPT_DEFAULT)) { - lua_assert(((JIT_F_OPT_FOLD|JIT_F_OPT_FWD|JIT_F_OPT_CSE|JIT_F_OPT_DSE) | - JIT_F_OPT_DEFAULT) == JIT_F_OPT_DEFAULT); - /* Folding disabled? Chain to CSE, but not for loads/stores/allocs. */ - if (!(J->flags & JIT_F_OPT_FOLD) && irm_kind(lj_ir_mode[fins->o]) == IRM_N) - return lj_opt_cse(J); - - /* No FOLD, forwarding or CSE? Emit raw IR for loads, except for SLOAD. */ - if ((J->flags & (JIT_F_OPT_FOLD|JIT_F_OPT_FWD|JIT_F_OPT_CSE)) != - (JIT_F_OPT_FOLD|JIT_F_OPT_FWD|JIT_F_OPT_CSE) && - irm_kind(lj_ir_mode[fins->o]) == IRM_L && fins->o != IR_SLOAD) - return lj_ir_emit(J); - - /* No FOLD or DSE? Emit raw IR for stores. */ - if ((J->flags & (JIT_F_OPT_FOLD|JIT_F_OPT_DSE)) != - (JIT_F_OPT_FOLD|JIT_F_OPT_DSE) && - irm_kind(lj_ir_mode[fins->o]) == IRM_S) - return lj_ir_emit(J); - } - - /* Fold engine start/retry point. */ -retry: - /* Construct key from opcode and operand opcodes (unless literal/none). */ - key = ((uint32_t)fins->o << 17); - if (fins->op1 >= J->cur.nk) { - key += (uint32_t)IR(fins->op1)->o << 10; - *fleft = *IR(fins->op1); - } - if (fins->op2 >= J->cur.nk) { - key += (uint32_t)IR(fins->op2)->o; - *fright = *IR(fins->op2); - } else { - key += (fins->op2 & 0x3ffu); /* Literal mask. Must include IRCONV_*MASK. */ - } - - /* Check for a match in order from most specific to least specific. */ - any = 0; - for (;;) { - uint32_t k = key | (any & 0x1ffff); - uint32_t h = fold_hashkey(k); - uint32_t fh = fold_hash[h]; /* Lookup key in semi-perfect hash table. */ - if ((fh & 0xffffff) == k || (fh = fold_hash[h+1], (fh & 0xffffff) == k)) { - ref = (IRRef)tref_ref(fold_func[fh >> 24](J)); - if (ref != NEXTFOLD) - break; - } - if (any == 0xfffff) /* Exhausted folding. Pass on to CSE. */ - return lj_opt_cse(J); - any = (any | (any >> 10)) ^ 0xffc00; - } - - /* Return value processing, ordered by frequency. */ - if (LJ_LIKELY(ref >= MAX_FOLD)) - return TREF(ref, irt_t(IR(ref)->t)); - if (ref == RETRYFOLD) - goto retry; - if (ref == KINTFOLD) - return lj_ir_kint(J, fins->i); - if (ref == FAILFOLD) - lj_trace_err(J, LJ_TRERR_GFAIL); - lua_assert(ref == DROPFOLD); - return REF_DROP; -} - -/* -- Common-Subexpression Elimination ------------------------------------ */ - -/* CSE an IR instruction. This is very fast due to the skip-list chains. */ -TRef LJ_FASTCALL lj_opt_cse(jit_State *J) -{ - /* Avoid narrow to wide store-to-load forwarding stall */ - IRRef2 op12 = (IRRef2)fins->op1 + ((IRRef2)fins->op2 << 16); - IROp op = fins->o; - if (LJ_LIKELY(J->flags & JIT_F_OPT_CSE)) { - /* Limited search for same operands in per-opcode chain. */ - IRRef ref = J->chain[op]; - IRRef lim = fins->op1; - if (fins->op2 > lim) lim = fins->op2; /* Relies on lit < REF_BIAS. */ - while (ref > lim) { - if (IR(ref)->op12 == op12) - return TREF(ref, irt_t(IR(ref)->t)); /* Common subexpression found. */ - ref = IR(ref)->prev; - } - } - /* Otherwise emit IR (inlined for speed). */ - { - IRRef ref = lj_ir_nextins(J); - IRIns *ir = IR(ref); - ir->prev = J->chain[op]; - ir->op12 = op12; - J->chain[op] = (IRRef1)ref; - ir->o = fins->o; - J->guardemit.irt |= fins->t.irt; - return TREF(ref, irt_t((ir->t = fins->t))); - } -} - -/* CSE with explicit search limit. */ -TRef LJ_FASTCALL lj_opt_cselim(jit_State *J, IRRef lim) -{ - IRRef ref = J->chain[fins->o]; - IRRef2 op12 = (IRRef2)fins->op1 + ((IRRef2)fins->op2 << 16); - while (ref > lim) { - if (IR(ref)->op12 == op12) - return ref; - ref = IR(ref)->prev; - } - return lj_ir_emit(J); -} - -/* ------------------------------------------------------------------------ */ - -#undef IR -#undef fins -#undef fleft -#undef fright -#undef knumleft -#undef knumright -#undef emitir - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_loop.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_loop.c deleted file mode 100644 index fa001151a..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_loop.c +++ /dev/null @@ -1,436 +0,0 @@ -/* -** LOOP: Loop Optimizations. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_opt_loop_c -#define LUA_CORE - -#include "lj_obj.h" - -#if LJ_HASJIT - -#include "lj_err.h" -#include "lj_str.h" -#include "lj_ir.h" -#include "lj_jit.h" -#include "lj_iropt.h" -#include "lj_trace.h" -#include "lj_snap.h" -#include "lj_vm.h" - -/* Loop optimization: -** -** Traditional Loop-Invariant Code Motion (LICM) splits the instructions -** of a loop into invariant and variant instructions. The invariant -** instructions are hoisted out of the loop and only the variant -** instructions remain inside the loop body. -** -** Unfortunately LICM is mostly useless for compiling dynamic languages. -** The IR has many guards and most of the subsequent instructions are -** control-dependent on them. The first non-hoistable guard would -** effectively prevent hoisting of all subsequent instructions. -** -** That's why we use a special form of unrolling using copy-substitution, -** combined with redundancy elimination: -** -** The recorded instruction stream is re-emitted to the compiler pipeline -** with substituted operands. The substitution table is filled with the -** refs returned by re-emitting each instruction. This can be done -** on-the-fly, because the IR is in strict SSA form, where every ref is -** defined before its use. -** -** This aproach generates two code sections, separated by the LOOP -** instruction: -** -** 1. The recorded instructions form a kind of pre-roll for the loop. It -** contains a mix of invariant and variant instructions and performs -** exactly one loop iteration (but not necessarily the 1st iteration). -** -** 2. The loop body contains only the variant instructions and performs -** all remaining loop iterations. -** -** On first sight that looks like a waste of space, because the variant -** instructions are present twice. But the key insight is that the -** pre-roll honors the control-dependencies for *both* the pre-roll itself -** *and* the loop body! -** -** It also means one doesn't have to explicitly model control-dependencies -** (which, BTW, wouldn't help LICM much). And it's much easier to -** integrate sparse snapshotting with this approach. -** -** One of the nicest aspects of this approach is that all of the -** optimizations of the compiler pipeline (FOLD, CSE, FWD, etc.) can be -** reused with only minor restrictions (e.g. one should not fold -** instructions across loop-carried dependencies). -** -** But in general all optimizations can be applied which only need to look -** backwards into the generated instruction stream. At any point in time -** during the copy-substitution process this contains both a static loop -** iteration (the pre-roll) and a dynamic one (from the to-be-copied -** instruction up to the end of the partial loop body). -** -** Since control-dependencies are implicitly kept, CSE also applies to all -** kinds of guards. The major advantage is that all invariant guards can -** be hoisted, too. -** -** Load/store forwarding works across loop iterations, too. This is -** important if loop-carried dependencies are kept in upvalues or tables. -** E.g. 'self.idx = self.idx + 1' deep down in some OO-style method may -** become a forwarded loop-recurrence after inlining. -** -** Since the IR is in SSA form, loop-carried dependencies have to be -** modeled with PHI instructions. The potential candidates for PHIs are -** collected on-the-fly during copy-substitution. After eliminating the -** redundant ones, PHI instructions are emitted *below* the loop body. -** -** Note that this departure from traditional SSA form doesn't change the -** semantics of the PHI instructions themselves. But it greatly simplifies -** on-the-fly generation of the IR and the machine code. -*/ - -/* Some local macros to save typing. Undef'd at the end. */ -#define IR(ref) (&J->cur.ir[(ref)]) - -/* Pass IR on to next optimization in chain (FOLD). */ -#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) - -/* Emit raw IR without passing through optimizations. */ -#define emitir_raw(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_ir_emit(J)) - -/* -- PHI elimination ----------------------------------------------------- */ - -/* Emit or eliminate collected PHIs. */ -static void loop_emit_phi(jit_State *J, IRRef1 *subst, IRRef1 *phi, IRRef nphi, - SnapNo onsnap) -{ - int passx = 0; - IRRef i, j, nslots; - IRRef invar = J->chain[IR_LOOP]; - /* Pass #1: mark redundant and potentially redundant PHIs. */ - for (i = 0, j = 0; i < nphi; i++) { - IRRef lref = phi[i]; - IRRef rref = subst[lref]; - if (lref == rref || rref == REF_DROP) { /* Invariants are redundant. */ - irt_clearphi(IR(lref)->t); - } else { - phi[j++] = (IRRef1)lref; - if (!(IR(rref)->op1 == lref || IR(rref)->op2 == lref)) { - /* Quick check for simple recurrences failed, need pass2. */ - irt_setmark(IR(lref)->t); - passx = 1; - } - } - } - nphi = j; - /* Pass #2: traverse variant part and clear marks of non-redundant PHIs. */ - if (passx) { - SnapNo s; - for (i = J->cur.nins-1; i > invar; i--) { - IRIns *ir = IR(i); - if (!irref_isk(ir->op2)) irt_clearmark(IR(ir->op2)->t); - if (!irref_isk(ir->op1)) { - irt_clearmark(IR(ir->op1)->t); - if (ir->op1 < invar && - ir->o >= IR_CALLN && ir->o <= IR_CARG) { /* ORDER IR */ - ir = IR(ir->op1); - while (ir->o == IR_CARG) { - if (!irref_isk(ir->op2)) irt_clearmark(IR(ir->op2)->t); - if (irref_isk(ir->op1)) break; - ir = IR(ir->op1); - irt_clearmark(ir->t); - } - } - } - } - for (s = J->cur.nsnap-1; s >= onsnap; s--) { - SnapShot *snap = &J->cur.snap[s]; - SnapEntry *map = &J->cur.snapmap[snap->mapofs]; - MSize n, nent = snap->nent; - for (n = 0; n < nent; n++) { - IRRef ref = snap_ref(map[n]); - if (!irref_isk(ref)) irt_clearmark(IR(ref)->t); - } - } - } - /* Pass #3: add PHIs for variant slots without a corresponding SLOAD. */ - nslots = J->baseslot+J->maxslot; - for (i = 1; i < nslots; i++) { - IRRef ref = tref_ref(J->slot[i]); - while (!irref_isk(ref) && ref != subst[ref]) { - IRIns *ir = IR(ref); - irt_clearmark(ir->t); /* Unmark potential uses, too. */ - if (irt_isphi(ir->t) || irt_ispri(ir->t)) - break; - irt_setphi(ir->t); - if (nphi >= LJ_MAX_PHI) - lj_trace_err(J, LJ_TRERR_PHIOV); - phi[nphi++] = (IRRef1)ref; - ref = subst[ref]; - if (ref > invar) - break; - } - } - /* Pass #4: propagate non-redundant PHIs. */ - while (passx) { - passx = 0; - for (i = 0; i < nphi; i++) { - IRRef lref = phi[i]; - IRIns *ir = IR(lref); - if (!irt_ismarked(ir->t)) { /* Propagate only from unmarked PHIs. */ - IRIns *irr = IR(subst[lref]); - if (irt_ismarked(irr->t)) { /* Right ref points to other PHI? */ - irt_clearmark(irr->t); /* Mark that PHI as non-redundant. */ - passx = 1; /* Retry. */ - } - } - } - } - /* Pass #5: emit PHI instructions or eliminate PHIs. */ - for (i = 0; i < nphi; i++) { - IRRef lref = phi[i]; - IRIns *ir = IR(lref); - if (!irt_ismarked(ir->t)) { /* Emit PHI if not marked. */ - IRRef rref = subst[lref]; - if (rref > invar) - irt_setphi(IR(rref)->t); - emitir_raw(IRT(IR_PHI, irt_type(ir->t)), lref, rref); - } else { /* Otherwise eliminate PHI. */ - irt_clearmark(ir->t); - irt_clearphi(ir->t); - } - } -} - -/* -- Loop unrolling using copy-substitution ------------------------------ */ - -/* Copy-substitute snapshot. */ -static void loop_subst_snap(jit_State *J, SnapShot *osnap, - SnapEntry *loopmap, IRRef1 *subst) -{ - SnapEntry *nmap, *omap = &J->cur.snapmap[osnap->mapofs]; - SnapEntry *nextmap = &J->cur.snapmap[snap_nextofs(&J->cur, osnap)]; - MSize nmapofs; - MSize on, ln, nn, onent = osnap->nent; - BCReg nslots = osnap->nslots; - SnapShot *snap = &J->cur.snap[J->cur.nsnap]; - if (irt_isguard(J->guardemit)) { /* Guard inbetween? */ - nmapofs = J->cur.nsnapmap; - J->cur.nsnap++; /* Add new snapshot. */ - } else { /* Otherwise overwrite previous snapshot. */ - snap--; - nmapofs = snap->mapofs; - } - J->guardemit.irt = 0; - /* Setup new snapshot. */ - snap->mapofs = (uint16_t)nmapofs; - snap->ref = (IRRef1)J->cur.nins; - snap->nslots = nslots; - snap->topslot = osnap->topslot; - snap->count = 0; - nmap = &J->cur.snapmap[nmapofs]; - /* Substitute snapshot slots. */ - on = ln = nn = 0; - while (on < onent) { - SnapEntry osn = omap[on], lsn = loopmap[ln]; - if (snap_slot(lsn) < snap_slot(osn)) { /* Copy slot from loop map. */ - nmap[nn++] = lsn; - ln++; - } else { /* Copy substituted slot from snapshot map. */ - if (snap_slot(lsn) == snap_slot(osn)) ln++; /* Shadowed loop slot. */ - if (!irref_isk(snap_ref(osn))) - osn = snap_setref(osn, subst[snap_ref(osn)]); - nmap[nn++] = osn; - on++; - } - } - while (snap_slot(loopmap[ln]) < nslots) /* Copy remaining loop slots. */ - nmap[nn++] = loopmap[ln++]; - snap->nent = (uint8_t)nn; - omap += onent; - nmap += nn; - while (omap < nextmap) /* Copy PC + frame links. */ - *nmap++ = *omap++; - J->cur.nsnapmap = (uint16_t)(nmap - J->cur.snapmap); -} - -/* Unroll loop. */ -static void loop_unroll(jit_State *J) -{ - IRRef1 phi[LJ_MAX_PHI]; - uint32_t nphi = 0; - IRRef1 *subst; - SnapNo onsnap; - SnapShot *osnap, *loopsnap; - SnapEntry *loopmap, *psentinel; - IRRef ins, invar; - - /* Use temp buffer for substitution table. - ** Only non-constant refs in [REF_BIAS,invar) are valid indexes. - ** Caveat: don't call into the VM or run the GC or the buffer may be gone. - */ - invar = J->cur.nins; - subst = (IRRef1 *)lj_str_needbuf(J->L, &G(J->L)->tmpbuf, - (invar-REF_BIAS)*sizeof(IRRef1)) - REF_BIAS; - subst[REF_BASE] = REF_BASE; - - /* LOOP separates the pre-roll from the loop body. */ - emitir_raw(IRTG(IR_LOOP, IRT_NIL), 0, 0); - - /* Grow snapshot buffer and map for copy-substituted snapshots. - ** Need up to twice the number of snapshots minus #0 and loop snapshot. - ** Need up to twice the number of entries plus fallback substitutions - ** from the loop snapshot entries for each new snapshot. - ** Caveat: both calls may reallocate J->cur.snap and J->cur.snapmap! - */ - onsnap = J->cur.nsnap; - lj_snap_grow_buf(J, 2*onsnap-2); - lj_snap_grow_map(J, J->cur.nsnapmap*2+(onsnap-2)*J->cur.snap[onsnap-1].nent); - - /* The loop snapshot is used for fallback substitutions. */ - loopsnap = &J->cur.snap[onsnap-1]; - loopmap = &J->cur.snapmap[loopsnap->mapofs]; - /* The PC of snapshot #0 and the loop snapshot must match. */ - psentinel = &loopmap[loopsnap->nent]; - lua_assert(*psentinel == J->cur.snapmap[J->cur.snap[0].nent]); - *psentinel = SNAP(255, 0, 0); /* Replace PC with temporary sentinel. */ - - /* Start substitution with snapshot #1 (#0 is empty for root traces). */ - osnap = &J->cur.snap[1]; - - /* Copy and substitute all recorded instructions and snapshots. */ - for (ins = REF_FIRST; ins < invar; ins++) { - IRIns *ir; - IRRef op1, op2; - - if (ins >= osnap->ref) /* Instruction belongs to next snapshot? */ - loop_subst_snap(J, osnap++, loopmap, subst); /* Copy-substitute it. */ - - /* Substitute instruction operands. */ - ir = IR(ins); - op1 = ir->op1; - if (!irref_isk(op1)) op1 = subst[op1]; - op2 = ir->op2; - if (!irref_isk(op2)) op2 = subst[op2]; - if (irm_kind(lj_ir_mode[ir->o]) == IRM_N && - op1 == ir->op1 && op2 == ir->op2) { /* Regular invariant ins? */ - subst[ins] = (IRRef1)ins; /* Shortcut. */ - } else { - /* Re-emit substituted instruction to the FOLD/CSE/etc. pipeline. */ - IRType1 t = ir->t; /* Get this first, since emitir may invalidate ir. */ - IRRef ref = tref_ref(emitir(ir->ot & ~IRT_ISPHI, op1, op2)); - subst[ins] = (IRRef1)ref; - if (ref != ins) { - IRIns *irr = IR(ref); - if (ref < invar) { /* Loop-carried dependency? */ - /* Potential PHI? */ - if (!irref_isk(ref) && !irt_isphi(irr->t) && !irt_ispri(irr->t)) { - irt_setphi(irr->t); - if (nphi >= LJ_MAX_PHI) - lj_trace_err(J, LJ_TRERR_PHIOV); - phi[nphi++] = (IRRef1)ref; - } - /* Check all loop-carried dependencies for type instability. */ - if (!irt_sametype(t, irr->t)) { - if (irt_isinteger(t) && irt_isinteger(irr->t)) - continue; - else if (irt_isnum(t) && irt_isinteger(irr->t)) /* Fix int->num. */ - ref = tref_ref(emitir(IRTN(IR_CONV), ref, IRCONV_NUM_INT)); - else if (irt_isnum(irr->t) && irt_isinteger(t)) /* Fix num->int. */ - ref = tref_ref(emitir(IRTGI(IR_CONV), ref, - IRCONV_INT_NUM|IRCONV_CHECK)); - else - lj_trace_err(J, LJ_TRERR_TYPEINS); - subst[ins] = (IRRef1)ref; - irr = IR(ref); - goto phiconv; - } - } else if (ref != REF_DROP && irr->o == IR_CONV && - ref > invar && irr->op1 < invar) { - /* May need an extra PHI for a CONV. */ - ref = irr->op1; - irr = IR(ref); - phiconv: - if (ref < invar && !irref_isk(ref) && !irt_isphi(irr->t)) { - irt_setphi(irr->t); - if (nphi >= LJ_MAX_PHI) - lj_trace_err(J, LJ_TRERR_PHIOV); - phi[nphi++] = (IRRef1)ref; - } - } - } - } - } - if (!irt_isguard(J->guardemit)) /* Drop redundant snapshot. */ - J->cur.nsnapmap = (uint16_t)J->cur.snap[--J->cur.nsnap].mapofs; - lua_assert(J->cur.nsnapmap <= J->sizesnapmap); - *psentinel = J->cur.snapmap[J->cur.snap[0].nent]; /* Restore PC. */ - - loop_emit_phi(J, subst, phi, nphi, onsnap); -} - -/* Undo any partial changes made by the loop optimization. */ -static void loop_undo(jit_State *J, IRRef ins, SnapNo nsnap, MSize nsnapmap) -{ - ptrdiff_t i; - SnapShot *snap = &J->cur.snap[nsnap-1]; - SnapEntry *map = J->cur.snapmap; - map[snap->mapofs + snap->nent] = map[J->cur.snap[0].nent]; /* Restore PC. */ - J->cur.nsnapmap = (uint16_t)nsnapmap; - J->cur.nsnap = nsnap; - J->guardemit.irt = 0; - lj_ir_rollback(J, ins); - for (i = 0; i < BPROP_SLOTS; i++) { /* Remove backprop. cache entries. */ - BPropEntry *bp = &J->bpropcache[i]; - if (bp->val >= ins) - bp->key = 0; - } - for (ins--; ins >= REF_FIRST; ins--) { /* Remove flags. */ - IRIns *ir = IR(ins); - irt_clearphi(ir->t); - irt_clearmark(ir->t); - } -} - -/* Protected callback for loop optimization. */ -static TValue *cploop_opt(lua_State *L, lua_CFunction dummy, void *ud) -{ - UNUSED(L); UNUSED(dummy); - loop_unroll((jit_State *)ud); - return NULL; -} - -/* Loop optimization. */ -int lj_opt_loop(jit_State *J) -{ - IRRef nins = J->cur.nins; - SnapNo nsnap = J->cur.nsnap; - MSize nsnapmap = J->cur.nsnapmap; - int errcode = lj_vm_cpcall(J->L, NULL, J, cploop_opt); - if (LJ_UNLIKELY(errcode)) { - lua_State *L = J->L; - if (errcode == LUA_ERRRUN && tvisnumber(L->top-1)) { /* Trace error? */ - int32_t e = numberVint(L->top-1); - switch ((TraceError)e) { - case LJ_TRERR_TYPEINS: /* Type instability. */ - case LJ_TRERR_GFAIL: /* Guard would always fail. */ - /* Unrolling via recording fixes many cases, e.g. a flipped boolean. */ - if (--J->instunroll < 0) /* But do not unroll forever. */ - break; - L->top--; /* Remove error object. */ - loop_undo(J, nins, nsnap, nsnapmap); - return 1; /* Loop optimization failed, continue recording. */ - default: - break; - } - } - lj_err_throw(L, errcode); /* Propagate all other errors. */ - } - return 0; /* Loop optimization is ok. */ -} - -#undef IR -#undef emitir -#undef emitir_raw - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_mem.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_mem.c deleted file mode 100644 index c8cdc3e5f..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_mem.c +++ /dev/null @@ -1,917 +0,0 @@ -/* -** Memory access optimizations. -** AA: Alias Analysis using high-level semantic disambiguation. -** FWD: Load Forwarding (L2L) + Store Forwarding (S2L). -** DSE: Dead-Store Elimination. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_opt_mem_c -#define LUA_CORE - -#include "lj_obj.h" - -#if LJ_HASJIT - -#include "lj_tab.h" -#include "lj_ir.h" -#include "lj_jit.h" -#include "lj_iropt.h" - -/* Some local macros to save typing. Undef'd at the end. */ -#define IR(ref) (&J->cur.ir[(ref)]) -#define fins (&J->fold.ins) -#define fleft (&J->fold.left) -#define fright (&J->fold.right) - -/* -** Caveat #1: return value is not always a TRef -- only use with tref_ref(). -** Caveat #2: FWD relies on active CSE for xREF operands -- see lj_opt_fold(). -*/ - -/* Return values from alias analysis. */ -typedef enum { - ALIAS_NO, /* The two refs CANNOT alias (exact). */ - ALIAS_MAY, /* The two refs MAY alias (inexact). */ - ALIAS_MUST /* The two refs MUST alias (exact). */ -} AliasRet; - -/* -- ALOAD/HLOAD forwarding and ASTORE/HSTORE elimination ---------------- */ - -/* Simplified escape analysis: check for intervening stores. */ -static AliasRet aa_escape(jit_State *J, IRIns *ir, IRIns *stop) -{ - IRRef ref = (IRRef)(ir - J->cur.ir); /* The ref that might be stored. */ - for (ir++; ir < stop; ir++) - if (ir->op2 == ref && - (ir->o == IR_ASTORE || ir->o == IR_HSTORE || - ir->o == IR_USTORE || ir->o == IR_FSTORE)) - return ALIAS_MAY; /* Reference was stored and might alias. */ - return ALIAS_NO; /* Reference was not stored. */ -} - -/* Alias analysis for two different table references. */ -static AliasRet aa_table(jit_State *J, IRRef ta, IRRef tb) -{ - IRIns *taba = IR(ta), *tabb = IR(tb); - int newa, newb; - lua_assert(ta != tb); - lua_assert(irt_istab(taba->t) && irt_istab(tabb->t)); - /* Disambiguate new allocations. */ - newa = (taba->o == IR_TNEW || taba->o == IR_TDUP); - newb = (tabb->o == IR_TNEW || tabb->o == IR_TDUP); - if (newa && newb) - return ALIAS_NO; /* Two different allocations never alias. */ - if (newb) { /* At least one allocation? */ - IRIns *tmp = taba; taba = tabb; tabb = tmp; - } else if (!newa) { - return ALIAS_MAY; /* Anything else: we just don't know. */ - } - return aa_escape(J, taba, tabb); -} - -/* Alias analysis for array and hash access using key-based disambiguation. */ -static AliasRet aa_ahref(jit_State *J, IRIns *refa, IRIns *refb) -{ - IRRef ka = refa->op2; - IRRef kb = refb->op2; - IRIns *keya, *keyb; - IRRef ta, tb; - if (refa == refb) - return ALIAS_MUST; /* Shortcut for same refs. */ - keya = IR(ka); - if (keya->o == IR_KSLOT) { ka = keya->op1; keya = IR(ka); } - keyb = IR(kb); - if (keyb->o == IR_KSLOT) { kb = keyb->op1; keyb = IR(kb); } - ta = (refa->o==IR_HREFK || refa->o==IR_AREF) ? IR(refa->op1)->op1 : refa->op1; - tb = (refb->o==IR_HREFK || refb->o==IR_AREF) ? IR(refb->op1)->op1 : refb->op1; - if (ka == kb) { - /* Same key. Check for same table with different ref (NEWREF vs. HREF). */ - if (ta == tb) - return ALIAS_MUST; /* Same key, same table. */ - else - return aa_table(J, ta, tb); /* Same key, possibly different table. */ - } - if (irref_isk(ka) && irref_isk(kb)) - return ALIAS_NO; /* Different constant keys. */ - if (refa->o == IR_AREF) { - /* Disambiguate array references based on index arithmetic. */ - int32_t ofsa = 0, ofsb = 0; - IRRef basea = ka, baseb = kb; - lua_assert(refb->o == IR_AREF); - /* Gather base and offset from t[base] or t[base+-ofs]. */ - if (keya->o == IR_ADD && irref_isk(keya->op2)) { - basea = keya->op1; - ofsa = IR(keya->op2)->i; - if (basea == kb && ofsa != 0) - return ALIAS_NO; /* t[base+-ofs] vs. t[base]. */ - } - if (keyb->o == IR_ADD && irref_isk(keyb->op2)) { - baseb = keyb->op1; - ofsb = IR(keyb->op2)->i; - if (ka == baseb && ofsb != 0) - return ALIAS_NO; /* t[base] vs. t[base+-ofs]. */ - } - if (basea == baseb && ofsa != ofsb) - return ALIAS_NO; /* t[base+-o1] vs. t[base+-o2] and o1 != o2. */ - } else { - /* Disambiguate hash references based on the type of their keys. */ - lua_assert((refa->o==IR_HREF || refa->o==IR_HREFK || refa->o==IR_NEWREF) && - (refb->o==IR_HREF || refb->o==IR_HREFK || refb->o==IR_NEWREF)); - if (!irt_sametype(keya->t, keyb->t)) - return ALIAS_NO; /* Different key types. */ - } - if (ta == tb) - return ALIAS_MAY; /* Same table, cannot disambiguate keys. */ - else - return aa_table(J, ta, tb); /* Try to disambiguate tables. */ -} - -/* Array and hash load forwarding. */ -static TRef fwd_ahload(jit_State *J, IRRef xref) -{ - IRIns *xr = IR(xref); - IRRef lim = xref; /* Search limit. */ - IRRef ref; - - /* Search for conflicting stores. */ - ref = J->chain[fins->o+IRDELTA_L2S]; - while (ref > xref) { - IRIns *store = IR(ref); - switch (aa_ahref(J, xr, IR(store->op1))) { - case ALIAS_NO: break; /* Continue searching. */ - case ALIAS_MAY: lim = ref; goto cselim; /* Limit search for load. */ - case ALIAS_MUST: return store->op2; /* Store forwarding. */ - } - ref = store->prev; - } - - /* No conflicting store (yet): const-fold loads from allocations. */ - { - IRIns *ir = (xr->o == IR_HREFK || xr->o == IR_AREF) ? IR(xr->op1) : xr; - IRRef tab = ir->op1; - ir = IR(tab); - if (ir->o == IR_TNEW || (ir->o == IR_TDUP && irref_isk(xr->op2))) { - /* A NEWREF with a number key may end up pointing to the array part. - ** But it's referenced from HSTORE and not found in the ASTORE chain. - ** For now simply consider this a conflict without forwarding anything. - */ - if (xr->o == IR_AREF) { - IRRef ref2 = J->chain[IR_NEWREF]; - while (ref2 > tab) { - IRIns *newref = IR(ref2); - if (irt_isnum(IR(newref->op2)->t)) - goto cselim; - ref2 = newref->prev; - } - } - /* NEWREF inhibits CSE for HREF, and dependent FLOADs from HREFK/AREF. - ** But the above search for conflicting stores was limited by xref. - ** So continue searching, limited by the TNEW/TDUP. Store forwarding - ** is ok, too. A conflict does NOT limit the search for a matching load. - */ - while (ref > tab) { - IRIns *store = IR(ref); - switch (aa_ahref(J, xr, IR(store->op1))) { - case ALIAS_NO: break; /* Continue searching. */ - case ALIAS_MAY: goto cselim; /* Conflicting store. */ - case ALIAS_MUST: return store->op2; /* Store forwarding. */ - } - ref = store->prev; - } - lua_assert(ir->o != IR_TNEW || irt_isnil(fins->t)); - if (irt_ispri(fins->t)) { - return TREF_PRI(irt_type(fins->t)); - } else if (irt_isnum(fins->t) || (LJ_DUALNUM && irt_isint(fins->t)) || - irt_isstr(fins->t)) { - TValue keyv; - cTValue *tv; - IRIns *key = IR(xr->op2); - if (key->o == IR_KSLOT) key = IR(key->op1); - lj_ir_kvalue(J->L, &keyv, key); - tv = lj_tab_get(J->L, ir_ktab(IR(ir->op1)), &keyv); - lua_assert(itype2irt(tv) == irt_type(fins->t)); - if (irt_isnum(fins->t)) - return lj_ir_knum_u64(J, tv->u64); - else if (LJ_DUALNUM && irt_isint(fins->t)) - return lj_ir_kint(J, intV(tv)); - else - return lj_ir_kstr(J, strV(tv)); - } - /* Othwerwise: don't intern as a constant. */ - } - } - -cselim: - /* Try to find a matching load. Below the conflicting store, if any. */ - ref = J->chain[fins->o]; - while (ref > lim) { - IRIns *load = IR(ref); - if (load->op1 == xref) - return ref; /* Load forwarding. */ - ref = load->prev; - } - return 0; /* Conflict or no match. */ -} - -/* Reassociate ALOAD across PHIs to handle t[i-1] forwarding case. */ -static TRef fwd_aload_reassoc(jit_State *J) -{ - IRIns *irx = IR(fins->op1); - IRIns *key = IR(irx->op2); - if (key->o == IR_ADD && irref_isk(key->op2)) { - IRIns *add2 = IR(key->op1); - if (add2->o == IR_ADD && irref_isk(add2->op2) && - IR(key->op2)->i == -IR(add2->op2)->i) { - IRRef ref = J->chain[IR_AREF]; - IRRef lim = add2->op1; - if (irx->op1 > lim) lim = irx->op1; - while (ref > lim) { - IRIns *ir = IR(ref); - if (ir->op1 == irx->op1 && ir->op2 == add2->op1) - return fwd_ahload(J, ref); - ref = ir->prev; - } - } - } - return 0; -} - -/* ALOAD forwarding. */ -TRef LJ_FASTCALL lj_opt_fwd_aload(jit_State *J) -{ - IRRef ref; - if ((ref = fwd_ahload(J, fins->op1)) || - (ref = fwd_aload_reassoc(J))) - return ref; - return EMITFOLD; -} - -/* HLOAD forwarding. */ -TRef LJ_FASTCALL lj_opt_fwd_hload(jit_State *J) -{ - IRRef ref = fwd_ahload(J, fins->op1); - if (ref) - return ref; - return EMITFOLD; -} - -/* HREFK forwarding. */ -TRef LJ_FASTCALL lj_opt_fwd_hrefk(jit_State *J) -{ - IRRef tab = fleft->op1; - IRRef ref = J->chain[IR_NEWREF]; - while (ref > tab) { - IRIns *newref = IR(ref); - if (tab == newref->op1) { - if (fright->op1 == newref->op2) - return ref; /* Forward from NEWREF. */ - else - goto docse; - } else if (aa_table(J, tab, newref->op1) != ALIAS_NO) { - goto docse; - } - ref = newref->prev; - } - /* No conflicting NEWREF: key location unchanged for HREFK of TDUP. */ - if (IR(tab)->o == IR_TDUP) - fins->t.irt &= ~IRT_GUARD; /* Drop HREFK guard. */ -docse: - return CSEFOLD; -} - -/* Check whether HREF of TNEW/TDUP can be folded to niltv. */ -int LJ_FASTCALL lj_opt_fwd_href_nokey(jit_State *J) -{ - IRRef lim = fins->op1; /* Search limit. */ - IRRef ref; - - /* The key for an ASTORE may end up in the hash part after a NEWREF. */ - if (irt_isnum(fright->t) && J->chain[IR_NEWREF] > lim) { - ref = J->chain[IR_ASTORE]; - while (ref > lim) { - if (ref < J->chain[IR_NEWREF]) - return 0; /* Conflict. */ - ref = IR(ref)->prev; - } - } - - /* Search for conflicting stores. */ - ref = J->chain[IR_HSTORE]; - while (ref > lim) { - IRIns *store = IR(ref); - if (aa_ahref(J, fins, IR(store->op1)) != ALIAS_NO) - return 0; /* Conflict. */ - ref = store->prev; - } - - return 1; /* No conflict. Can fold to niltv. */ -} - -/* Check whether there's no aliasing NEWREF for the left operand. */ -int LJ_FASTCALL lj_opt_fwd_tptr(jit_State *J, IRRef lim) -{ - IRRef ta = fins->op1; - IRRef ref = J->chain[IR_NEWREF]; - while (ref > lim) { - IRIns *newref = IR(ref); - if (ta == newref->op1 || aa_table(J, ta, newref->op1) != ALIAS_NO) - return 0; /* Conflict. */ - ref = newref->prev; - } - return 1; /* No conflict. Can safely FOLD/CSE. */ -} - -/* ASTORE/HSTORE elimination. */ -TRef LJ_FASTCALL lj_opt_dse_ahstore(jit_State *J) -{ - IRRef xref = fins->op1; /* xREF reference. */ - IRRef val = fins->op2; /* Stored value reference. */ - IRIns *xr = IR(xref); - IRRef1 *refp = &J->chain[fins->o]; - IRRef ref = *refp; - while (ref > xref) { /* Search for redundant or conflicting stores. */ - IRIns *store = IR(ref); - switch (aa_ahref(J, xr, IR(store->op1))) { - case ALIAS_NO: - break; /* Continue searching. */ - case ALIAS_MAY: /* Store to MAYBE the same location. */ - if (store->op2 != val) /* Conflict if the value is different. */ - goto doemit; - break; /* Otherwise continue searching. */ - case ALIAS_MUST: /* Store to the same location. */ - if (store->op2 == val) /* Same value: drop the new store. */ - return DROPFOLD; - /* Different value: try to eliminate the redundant store. */ - if (ref > J->chain[IR_LOOP]) { /* Quick check to avoid crossing LOOP. */ - IRIns *ir; - /* Check for any intervening guards (includes conflicting loads). */ - for (ir = IR(J->cur.nins-1); ir > store; ir--) - if (irt_isguard(ir->t) || ir->o == IR_CALLL) - goto doemit; /* No elimination possible. */ - /* Remove redundant store from chain and replace with NOP. */ - *refp = store->prev; - store->o = IR_NOP; - store->t.irt = IRT_NIL; - store->op1 = store->op2 = 0; - store->prev = 0; - /* Now emit the new store instead. */ - } - goto doemit; - } - ref = *(refp = &store->prev); - } -doemit: - return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ -} - -/* -- ULOAD forwarding ---------------------------------------------------- */ - -/* The current alias analysis for upvalues is very simplistic. It only -** disambiguates between the unique upvalues of the same function. -** This is good enough for now, since most upvalues are read-only. -** -** A more precise analysis would be feasible with the help of the parser: -** generate a unique key for every upvalue, even across all prototypes. -** Lacking a realistic use-case, it's unclear whether this is beneficial. -*/ -static AliasRet aa_uref(IRIns *refa, IRIns *refb) -{ - if (refa->o != refb->o) - return ALIAS_NO; /* Different UREFx type. */ - if (refa->op1 == refb->op1) { /* Same function. */ - if (refa->op2 == refb->op2) - return ALIAS_MUST; /* Same function, same upvalue idx. */ - else - return ALIAS_NO; /* Same function, different upvalue idx. */ - } else { /* Different functions, check disambiguation hash values. */ - if (((refa->op2 ^ refb->op2) & 0xff)) - return ALIAS_NO; /* Upvalues with different hash values cannot alias. */ - else - return ALIAS_MAY; /* No conclusion can be drawn for same hash value. */ - } -} - -/* ULOAD forwarding. */ -TRef LJ_FASTCALL lj_opt_fwd_uload(jit_State *J) -{ - IRRef uref = fins->op1; - IRRef lim = REF_BASE; /* Search limit. */ - IRIns *xr = IR(uref); - IRRef ref; - - /* Search for conflicting stores. */ - ref = J->chain[IR_USTORE]; - while (ref > lim) { - IRIns *store = IR(ref); - switch (aa_uref(xr, IR(store->op1))) { - case ALIAS_NO: break; /* Continue searching. */ - case ALIAS_MAY: lim = ref; goto cselim; /* Limit search for load. */ - case ALIAS_MUST: return store->op2; /* Store forwarding. */ - } - ref = store->prev; - } - -cselim: - /* Try to find a matching load. Below the conflicting store, if any. */ - - ref = J->chain[IR_ULOAD]; - while (ref > lim) { - IRIns *ir = IR(ref); - if (ir->op1 == uref || - (IR(ir->op1)->op12 == IR(uref)->op12 && IR(ir->op1)->o == IR(uref)->o)) - return ref; /* Match for identical or equal UREFx (non-CSEable UREFO). */ - ref = ir->prev; - } - return lj_ir_emit(J); -} - -/* USTORE elimination. */ -TRef LJ_FASTCALL lj_opt_dse_ustore(jit_State *J) -{ - IRRef xref = fins->op1; /* xREF reference. */ - IRRef val = fins->op2; /* Stored value reference. */ - IRIns *xr = IR(xref); - IRRef1 *refp = &J->chain[IR_USTORE]; - IRRef ref = *refp; - while (ref > xref) { /* Search for redundant or conflicting stores. */ - IRIns *store = IR(ref); - switch (aa_uref(xr, IR(store->op1))) { - case ALIAS_NO: - break; /* Continue searching. */ - case ALIAS_MAY: /* Store to MAYBE the same location. */ - if (store->op2 != val) /* Conflict if the value is different. */ - goto doemit; - break; /* Otherwise continue searching. */ - case ALIAS_MUST: /* Store to the same location. */ - if (store->op2 == val) /* Same value: drop the new store. */ - return DROPFOLD; - /* Different value: try to eliminate the redundant store. */ - if (ref > J->chain[IR_LOOP]) { /* Quick check to avoid crossing LOOP. */ - IRIns *ir; - /* Check for any intervening guards (includes conflicting loads). */ - for (ir = IR(J->cur.nins-1); ir > store; ir--) - if (irt_isguard(ir->t)) - goto doemit; /* No elimination possible. */ - /* Remove redundant store from chain and replace with NOP. */ - *refp = store->prev; - store->o = IR_NOP; - store->t.irt = IRT_NIL; - store->op1 = store->op2 = 0; - store->prev = 0; - if (ref+1 < J->cur.nins && - store[1].o == IR_OBAR && store[1].op1 == xref) { - IRRef1 *bp = &J->chain[IR_OBAR]; - IRIns *obar; - for (obar = IR(*bp); *bp > ref+1; obar = IR(*bp)) - bp = &obar->prev; - /* Remove OBAR, too. */ - *bp = obar->prev; - obar->o = IR_NOP; - obar->t.irt = IRT_NIL; - obar->op1 = obar->op2 = 0; - obar->prev = 0; - } - /* Now emit the new store instead. */ - } - goto doemit; - } - ref = *(refp = &store->prev); - } -doemit: - return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ -} - -/* -- FLOAD forwarding and FSTORE elimination ----------------------------- */ - -/* Alias analysis for field access. -** Field loads are cheap and field stores are rare. -** Simple disambiguation based on field types is good enough. -*/ -static AliasRet aa_fref(jit_State *J, IRIns *refa, IRIns *refb) -{ - if (refa->op2 != refb->op2) - return ALIAS_NO; /* Different fields. */ - if (refa->op1 == refb->op1) - return ALIAS_MUST; /* Same field, same object. */ - else if (refa->op2 >= IRFL_TAB_META && refa->op2 <= IRFL_TAB_NOMM) - return aa_table(J, refa->op1, refb->op1); /* Disambiguate tables. */ - else - return ALIAS_MAY; /* Same field, possibly different object. */ -} - -/* Only the loads for mutable fields end up here (see FOLD). */ -TRef LJ_FASTCALL lj_opt_fwd_fload(jit_State *J) -{ - IRRef oref = fins->op1; /* Object reference. */ - IRRef fid = fins->op2; /* Field ID. */ - IRRef lim = oref; /* Search limit. */ - IRRef ref; - - /* Search for conflicting stores. */ - ref = J->chain[IR_FSTORE]; - while (ref > oref) { - IRIns *store = IR(ref); - switch (aa_fref(J, fins, IR(store->op1))) { - case ALIAS_NO: break; /* Continue searching. */ - case ALIAS_MAY: lim = ref; goto cselim; /* Limit search for load. */ - case ALIAS_MUST: return store->op2; /* Store forwarding. */ - } - ref = store->prev; - } - - /* No conflicting store: const-fold field loads from allocations. */ - if (fid == IRFL_TAB_META) { - IRIns *ir = IR(oref); - if (ir->o == IR_TNEW || ir->o == IR_TDUP) - return lj_ir_knull(J, IRT_TAB); - } - -cselim: - /* Try to find a matching load. Below the conflicting store, if any. */ - return lj_opt_cselim(J, lim); -} - -/* FSTORE elimination. */ -TRef LJ_FASTCALL lj_opt_dse_fstore(jit_State *J) -{ - IRRef fref = fins->op1; /* FREF reference. */ - IRRef val = fins->op2; /* Stored value reference. */ - IRIns *xr = IR(fref); - IRRef1 *refp = &J->chain[IR_FSTORE]; - IRRef ref = *refp; - while (ref > fref) { /* Search for redundant or conflicting stores. */ - IRIns *store = IR(ref); - switch (aa_fref(J, xr, IR(store->op1))) { - case ALIAS_NO: - break; /* Continue searching. */ - case ALIAS_MAY: - if (store->op2 != val) /* Conflict if the value is different. */ - goto doemit; - break; /* Otherwise continue searching. */ - case ALIAS_MUST: - if (store->op2 == val) /* Same value: drop the new store. */ - return DROPFOLD; - /* Different value: try to eliminate the redundant store. */ - if (ref > J->chain[IR_LOOP]) { /* Quick check to avoid crossing LOOP. */ - IRIns *ir; - /* Check for any intervening guards or conflicting loads. */ - for (ir = IR(J->cur.nins-1); ir > store; ir--) - if (irt_isguard(ir->t) || (ir->o == IR_FLOAD && ir->op2 == xr->op2)) - goto doemit; /* No elimination possible. */ - /* Remove redundant store from chain and replace with NOP. */ - *refp = store->prev; - store->o = IR_NOP; - store->t.irt = IRT_NIL; - store->op1 = store->op2 = 0; - store->prev = 0; - /* Now emit the new store instead. */ - } - goto doemit; - } - ref = *(refp = &store->prev); - } -doemit: - return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ -} - -/* -- XLOAD forwarding and XSTORE elimination ----------------------------- */ - -/* Find cdata allocation for a reference (if any). */ -static IRIns *aa_findcnew(jit_State *J, IRIns *ir) -{ - while (ir->o == IR_ADD) { - if (!irref_isk(ir->op1)) { - IRIns *ir1 = aa_findcnew(J, IR(ir->op1)); /* Left-recursion. */ - if (ir1) return ir1; - } - if (irref_isk(ir->op2)) return NULL; - ir = IR(ir->op2); /* Flatten right-recursion. */ - } - return ir->o == IR_CNEW ? ir : NULL; -} - -/* Alias analysis for two cdata allocations. */ -static AliasRet aa_cnew(jit_State *J, IRIns *refa, IRIns *refb) -{ - IRIns *cnewa = aa_findcnew(J, refa); - IRIns *cnewb = aa_findcnew(J, refb); - if (cnewa == cnewb) - return ALIAS_MAY; /* Same allocation or neither is an allocation. */ - if (cnewa && cnewb) - return ALIAS_NO; /* Two different allocations never alias. */ - if (cnewb) { cnewa = cnewb; refb = refa; } - return aa_escape(J, cnewa, refb); -} - -/* Alias analysis for XLOAD/XSTORE. */ -static AliasRet aa_xref(jit_State *J, IRIns *refa, IRIns *xa, IRIns *xb) -{ - ptrdiff_t ofsa = 0, ofsb = 0; - IRIns *refb = IR(xb->op1); - IRIns *basea = refa, *baseb = refb; - if (refa == refb && irt_sametype(xa->t, xb->t)) - return ALIAS_MUST; /* Shortcut for same refs with identical type. */ - /* Offset-based disambiguation. */ - if (refa->o == IR_ADD && irref_isk(refa->op2)) { - IRIns *irk = IR(refa->op2); - basea = IR(refa->op1); - ofsa = (LJ_64 && irk->o == IR_KINT64) ? (ptrdiff_t)ir_k64(irk)->u64 : - (ptrdiff_t)irk->i; - } - if (refb->o == IR_ADD && irref_isk(refb->op2)) { - IRIns *irk = IR(refb->op2); - baseb = IR(refb->op1); - ofsb = (LJ_64 && irk->o == IR_KINT64) ? (ptrdiff_t)ir_k64(irk)->u64 : - (ptrdiff_t)irk->i; - } - /* Treat constified pointers like base vs. base+offset. */ - if (basea->o == IR_KPTR && baseb->o == IR_KPTR) { - ofsb += (char *)ir_kptr(baseb) - (char *)ir_kptr(basea); - baseb = basea; - } - /* This implements (very) strict aliasing rules. - ** Different types do NOT alias, except for differences in signedness. - ** Type punning through unions is allowed (but forces a reload). - */ - if (basea == baseb) { - ptrdiff_t sza = irt_size(xa->t), szb = irt_size(xb->t); - if (ofsa == ofsb) { - if (sza == szb && irt_isfp(xa->t) == irt_isfp(xb->t)) - return ALIAS_MUST; /* Same-sized, same-kind. May need to convert. */ - } else if (ofsa + sza <= ofsb || ofsb + szb <= ofsa) { - return ALIAS_NO; /* Non-overlapping base+-o1 vs. base+-o2. */ - } - /* NYI: extract, extend or reinterpret bits (int <-> fp). */ - return ALIAS_MAY; /* Overlapping or type punning: force reload. */ - } - if (!irt_sametype(xa->t, xb->t) && - !(irt_typerange(xa->t, IRT_I8, IRT_U64) && - ((xa->t.irt - IRT_I8) ^ (xb->t.irt - IRT_I8)) == 1)) - return ALIAS_NO; - /* NYI: structural disambiguation. */ - return aa_cnew(J, basea, baseb); /* Try to disambiguate allocations. */ -} - -/* Return CSEd reference or 0. Caveat: swaps lower ref to the right! */ -static IRRef reassoc_trycse(jit_State *J, IROp op, IRRef op1, IRRef op2) -{ - IRRef ref = J->chain[op]; - IRRef lim = op1; - if (op2 > lim) { lim = op2; op2 = op1; op1 = lim; } - while (ref > lim) { - IRIns *ir = IR(ref); - if (ir->op1 == op1 && ir->op2 == op2) - return ref; - ref = ir->prev; - } - return 0; -} - -/* Reassociate index references. */ -static IRRef reassoc_xref(jit_State *J, IRIns *ir) -{ - ptrdiff_t ofs = 0; - if (ir->o == IR_ADD && irref_isk(ir->op2)) { /* Get constant offset. */ - IRIns *irk = IR(ir->op2); - ofs = (LJ_64 && irk->o == IR_KINT64) ? (ptrdiff_t)ir_k64(irk)->u64 : - (ptrdiff_t)irk->i; - ir = IR(ir->op1); - } - if (ir->o == IR_ADD) { /* Add of base + index. */ - /* Index ref > base ref for loop-carried dependences. Only check op1. */ - IRIns *ir2, *ir1 = IR(ir->op1); - int32_t shift = 0; - IRRef idxref; - /* Determine index shifts. Don't bother with IR_MUL here. */ - if (ir1->o == IR_BSHL && irref_isk(ir1->op2)) - shift = IR(ir1->op2)->i; - else if (ir1->o == IR_ADD && ir1->op1 == ir1->op2) - shift = 1; - else - ir1 = ir; - ir2 = IR(ir1->op1); - /* A non-reassociated add. Must be a loop-carried dependence. */ - if (ir2->o == IR_ADD && irt_isint(ir2->t) && irref_isk(ir2->op2)) - ofs += (ptrdiff_t)IR(ir2->op2)->i << shift; - else - return 0; - idxref = ir2->op1; - /* Try to CSE the reassociated chain. Give up if not found. */ - if (ir1 != ir && - !(idxref = reassoc_trycse(J, ir1->o, idxref, - ir1->o == IR_BSHL ? ir1->op2 : idxref))) - return 0; - if (!(idxref = reassoc_trycse(J, IR_ADD, idxref, ir->op2))) - return 0; - if (ofs != 0) { - IRRef refk = tref_ref(lj_ir_kintp(J, ofs)); - if (!(idxref = reassoc_trycse(J, IR_ADD, idxref, refk))) - return 0; - } - return idxref; /* Success, found a reassociated index reference. Phew. */ - } - return 0; /* Failure. */ -} - -/* XLOAD forwarding. */ -TRef LJ_FASTCALL lj_opt_fwd_xload(jit_State *J) -{ - IRRef xref = fins->op1; - IRIns *xr = IR(xref); - IRRef lim = xref; /* Search limit. */ - IRRef ref; - - if ((fins->op2 & IRXLOAD_READONLY)) - goto cselim; - if ((fins->op2 & IRXLOAD_VOLATILE)) - goto doemit; - - /* Search for conflicting stores. */ - ref = J->chain[IR_XSTORE]; -retry: - if (J->chain[IR_CALLXS] > lim) lim = J->chain[IR_CALLXS]; - if (J->chain[IR_XBAR] > lim) lim = J->chain[IR_XBAR]; - while (ref > lim) { - IRIns *store = IR(ref); - switch (aa_xref(J, xr, fins, store)) { - case ALIAS_NO: break; /* Continue searching. */ - case ALIAS_MAY: lim = ref; goto cselim; /* Limit search for load. */ - case ALIAS_MUST: - /* Emit conversion if the loaded type doesn't match the forwarded type. */ - if (!irt_sametype(fins->t, IR(store->op2)->t)) { - IRType st = irt_type(fins->t); - if (st == IRT_I8 || st == IRT_I16) { /* Trunc + sign-extend. */ - st |= IRCONV_SEXT; - } else if (st == IRT_U8 || st == IRT_U16) { /* Trunc + zero-extend. */ - } else if (st == IRT_INT) { - st = irt_type(IR(store->op2)->t); /* Needs dummy CONV.int.*. */ - } else { /* I64/U64 are boxed, U32 is hidden behind a CONV.num.u32. */ - goto store_fwd; - } - fins->ot = IRTI(IR_CONV); - fins->op1 = store->op2; - fins->op2 = (IRT_INT<<5)|st; - return RETRYFOLD; - } - store_fwd: - return store->op2; /* Store forwarding. */ - } - ref = store->prev; - } - -cselim: - /* Try to find a matching load. Below the conflicting store, if any. */ - ref = J->chain[IR_XLOAD]; - while (ref > lim) { - /* CSE for XLOAD depends on the type, but not on the IRXLOAD_* flags. */ - if (IR(ref)->op1 == xref && irt_sametype(IR(ref)->t, fins->t)) - return ref; - ref = IR(ref)->prev; - } - - /* Reassociate XLOAD across PHIs to handle a[i-1] forwarding case. */ - if (!(fins->op2 & IRXLOAD_READONLY) && J->chain[IR_LOOP] && - xref == fins->op1 && (xref = reassoc_xref(J, xr)) != 0) { - ref = J->chain[IR_XSTORE]; - while (ref > lim) /* Skip stores that have already been checked. */ - ref = IR(ref)->prev; - lim = xref; - xr = IR(xref); - goto retry; /* Retry with the reassociated reference. */ - } -doemit: - return EMITFOLD; -} - -/* XSTORE elimination. */ -TRef LJ_FASTCALL lj_opt_dse_xstore(jit_State *J) -{ - IRRef xref = fins->op1; - IRIns *xr = IR(xref); - IRRef lim = xref; /* Search limit. */ - IRRef val = fins->op2; /* Stored value reference. */ - IRRef1 *refp = &J->chain[IR_XSTORE]; - IRRef ref = *refp; - if (J->chain[IR_CALLXS] > lim) lim = J->chain[IR_CALLXS]; - if (J->chain[IR_XBAR] > lim) lim = J->chain[IR_XBAR]; - while (ref > lim) { /* Search for redundant or conflicting stores. */ - IRIns *store = IR(ref); - switch (aa_xref(J, xr, fins, store)) { - case ALIAS_NO: - break; /* Continue searching. */ - case ALIAS_MAY: - if (store->op2 != val) /* Conflict if the value is different. */ - goto doemit; - break; /* Otherwise continue searching. */ - case ALIAS_MUST: - if (store->op2 == val) /* Same value: drop the new store. */ - return DROPFOLD; - /* Different value: try to eliminate the redundant store. */ - if (ref > J->chain[IR_LOOP]) { /* Quick check to avoid crossing LOOP. */ - IRIns *ir; - /* Check for any intervening guards or any XLOADs (no AA performed). */ - for (ir = IR(J->cur.nins-1); ir > store; ir--) - if (irt_isguard(ir->t) || ir->o == IR_XLOAD) - goto doemit; /* No elimination possible. */ - /* Remove redundant store from chain and replace with NOP. */ - *refp = store->prev; - store->o = IR_NOP; - store->t.irt = IRT_NIL; - store->op1 = store->op2 = 0; - store->prev = 0; - /* Now emit the new store instead. */ - } - goto doemit; - } - ref = *(refp = &store->prev); - } -doemit: - return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ -} - -/* -- Forwarding of lj_tab_len -------------------------------------------- */ - -/* This is rather simplistic right now, but better than nothing. */ -TRef LJ_FASTCALL lj_opt_fwd_tab_len(jit_State *J) -{ - IRRef tab = fins->op1; /* Table reference. */ - IRRef lim = tab; /* Search limit. */ - IRRef ref; - - /* Any ASTORE is a conflict and limits the search. */ - if (J->chain[IR_ASTORE] > lim) lim = J->chain[IR_ASTORE]; - - /* Search for conflicting HSTORE with numeric key. */ - ref = J->chain[IR_HSTORE]; - while (ref > lim) { - IRIns *store = IR(ref); - IRIns *href = IR(store->op1); - IRIns *key = IR(href->op2); - if (irt_isnum(key->o == IR_KSLOT ? IR(key->op1)->t : key->t)) { - lim = ref; /* Conflicting store found, limits search for TLEN. */ - break; - } - ref = store->prev; - } - - /* Try to find a matching load. Below the conflicting store, if any. */ - return lj_opt_cselim(J, lim); -} - -/* -- ASTORE/HSTORE previous type analysis -------------------------------- */ - -/* Check whether the previous value for a table store is non-nil. -** This can be derived either from a previous store or from a previous -** load (because all loads from tables perform a type check). -** -** The result of the analysis can be used to avoid the metatable check -** and the guard against HREF returning niltv. Both of these are cheap, -** so let's not spend too much effort on the analysis. -** -** A result of 1 is exact: previous value CANNOT be nil. -** A result of 0 is inexact: previous value MAY be nil. -*/ -int lj_opt_fwd_wasnonnil(jit_State *J, IROpT loadop, IRRef xref) -{ - /* First check stores. */ - IRRef ref = J->chain[loadop+IRDELTA_L2S]; - while (ref > xref) { - IRIns *store = IR(ref); - if (store->op1 == xref) { /* Same xREF. */ - /* A nil store MAY alias, but a non-nil store MUST alias. */ - return !irt_isnil(store->t); - } else if (irt_isnil(store->t)) { /* Must check any nil store. */ - IRRef skref = IR(store->op1)->op2; - IRRef xkref = IR(xref)->op2; - /* Same key type MAY alias. Need ALOAD check due to multiple int types. */ - if (loadop == IR_ALOAD || irt_sametype(IR(skref)->t, IR(xkref)->t)) { - if (skref == xkref || !irref_isk(skref) || !irref_isk(xkref)) - return 0; /* A nil store with same const key or var key MAY alias. */ - /* Different const keys CANNOT alias. */ - } /* Different key types CANNOT alias. */ - } /* Other non-nil stores MAY alias. */ - ref = store->prev; - } - - /* Check loads since nothing could be derived from stores. */ - ref = J->chain[loadop]; - while (ref > xref) { - IRIns *load = IR(ref); - if (load->op1 == xref) { /* Same xREF. */ - /* A nil load MAY alias, but a non-nil load MUST alias. */ - return !irt_isnil(load->t); - } /* Other non-nil loads MAY alias. */ - ref = load->prev; - } - return 0; /* Nothing derived at all, previous value MAY be nil. */ -} - -/* ------------------------------------------------------------------------ */ - -#undef IR -#undef fins -#undef fleft -#undef fright - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_narrow.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_narrow.c deleted file mode 100644 index 2cecf65da..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_narrow.c +++ /dev/null @@ -1,648 +0,0 @@ -/* -** NARROW: Narrowing of numbers to integers (double to int32_t). -** STRIPOV: Stripping of overflow checks. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_opt_narrow_c -#define LUA_CORE - -#include "lj_obj.h" - -#if LJ_HASJIT - -#include "lj_bc.h" -#include "lj_ir.h" -#include "lj_jit.h" -#include "lj_iropt.h" -#include "lj_trace.h" -#include "lj_vm.h" -#include "lj_strscan.h" - -/* Rationale for narrowing optimizations: -** -** Lua has only a single number type and this is a FP double by default. -** Narrowing doubles to integers does not pay off for the interpreter on a -** current-generation x86/x64 machine. Most FP operations need the same -** amount of execution resources as their integer counterparts, except -** with slightly longer latencies. Longer latencies are a non-issue for -** the interpreter, since they are usually hidden by other overhead. -** -** The total CPU execution bandwidth is the sum of the bandwidth of the FP -** and the integer units, because they execute in parallel. The FP units -** have an equal or higher bandwidth than the integer units. Not using -** them means losing execution bandwidth. Moving work away from them to -** the already quite busy integer units is a losing proposition. -** -** The situation for JIT-compiled code is a bit different: the higher code -** density makes the extra latencies much more visible. Tight loops expose -** the latencies for updating the induction variables. Array indexing -** requires narrowing conversions with high latencies and additional -** guards (to check that the index is really an integer). And many common -** optimizations only work on integers. -** -** One solution would be speculative, eager narrowing of all number loads. -** This causes many problems, like losing -0 or the need to resolve type -** mismatches between traces. It also effectively forces the integer type -** to have overflow-checking semantics. This impedes many basic -** optimizations and requires adding overflow checks to all integer -** arithmetic operations (whereas FP arithmetics can do without). -** -** Always replacing an FP op with an integer op plus an overflow check is -** counter-productive on a current-generation super-scalar CPU. Although -** the overflow check branches are highly predictable, they will clog the -** execution port for the branch unit and tie up reorder buffers. This is -** turning a pure data-flow dependency into a different data-flow -** dependency (with slightly lower latency) *plus* a control dependency. -** In general, you don't want to do this since latencies due to data-flow -** dependencies can be well hidden by out-of-order execution. -** -** A better solution is to keep all numbers as FP values and only narrow -** when it's beneficial to do so. LuaJIT uses predictive narrowing for -** induction variables and demand-driven narrowing for index expressions, -** integer arguments and bit operations. Additionally it can eliminate or -** hoist most of the resulting overflow checks. Regular arithmetic -** computations are never narrowed to integers. -** -** The integer type in the IR has convenient wrap-around semantics and -** ignores overflow. Extra operations have been added for -** overflow-checking arithmetic (ADDOV/SUBOV) instead of an extra type. -** Apart from reducing overall complexity of the compiler, this also -** nicely solves the problem where you want to apply algebraic -** simplifications to ADD, but not to ADDOV. And the x86/x64 assembler can -** use lea instead of an add for integer ADD, but not for ADDOV (lea does -** not affect the flags, but it helps to avoid register moves). -** -** -** All of the above has to be reconsidered for architectures with slow FP -** operations or without a hardware FPU. The dual-number mode of LuaJIT -** addresses this issue. Arithmetic operations are performed on integers -** as far as possible and overflow checks are added as needed. -** -** This implies that narrowing for integer arguments and bit operations -** should also strip overflow checks, e.g. replace ADDOV with ADD. The -** original overflow guards are weak and can be eliminated by DCE, if -** there's no other use. -** -** A slight twist is that it's usually beneficial to use overflow-checked -** integer arithmetics if all inputs are already integers. This is the only -** change that affects the single-number mode, too. -*/ - -/* Some local macros to save typing. Undef'd at the end. */ -#define IR(ref) (&J->cur.ir[(ref)]) -#define fins (&J->fold.ins) - -/* Pass IR on to next optimization in chain (FOLD). */ -#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) - -#define emitir_raw(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_ir_emit(J)) - -/* -- Elimination of narrowing type conversions --------------------------- */ - -/* Narrowing of index expressions and bit operations is demand-driven. The -** trace recorder emits a narrowing type conversion (CONV.int.num or TOBIT) -** in all of these cases (e.g. array indexing or string indexing). FOLD -** already takes care of eliminating simple redundant conversions like -** CONV.int.num(CONV.num.int(x)) ==> x. -** -** But the surrounding code is FP-heavy and arithmetic operations are -** performed on FP numbers (for the single-number mode). Consider a common -** example such as 'x=t[i+1]', with 'i' already an integer (due to induction -** variable narrowing). The index expression would be recorded as -** CONV.int.num(ADD(CONV.num.int(i), 1)) -** which is clearly suboptimal. -** -** One can do better by recursively backpropagating the narrowing type -** conversion across FP arithmetic operations. This turns FP ops into -** their corresponding integer counterparts. Depending on the semantics of -** the conversion they also need to check for overflow. Currently only ADD -** and SUB are supported. -** -** The above example can be rewritten as -** ADDOV(CONV.int.num(CONV.num.int(i)), 1) -** and then into ADDOV(i, 1) after folding of the conversions. The original -** FP ops remain in the IR and are eliminated by DCE since all references to -** them are gone. -** -** [In dual-number mode the trace recorder already emits ADDOV etc., but -** this can be further reduced. See below.] -** -** Special care has to be taken to avoid narrowing across an operation -** which is potentially operating on non-integral operands. One obvious -** case is when an expression contains a non-integral constant, but ends -** up as an integer index at runtime (like t[x+1.5] with x=0.5). -** -** Operations with two non-constant operands illustrate a similar problem -** (like t[a+b] with a=1.5 and b=2.5). Backpropagation has to stop there, -** unless it can be proven that either operand is integral (e.g. by CSEing -** a previous conversion). As a not-so-obvious corollary this logic also -** applies for a whole expression tree (e.g. t[(a+1)+(b+1)]). -** -** Correctness of the transformation is guaranteed by avoiding to expand -** the tree by adding more conversions than the one we would need to emit -** if not backpropagating. TOBIT employs a more optimistic rule, because -** the conversion has special semantics, designed to make the life of the -** compiler writer easier. ;-) -** -** Using on-the-fly backpropagation of an expression tree doesn't work -** because it's unknown whether the transform is correct until the end. -** This either requires IR rollback and cache invalidation for every -** subtree or a two-pass algorithm. The former didn't work out too well, -** so the code now combines a recursive collector with a stack-based -** emitter. -** -** [A recursive backpropagation algorithm with backtracking, employing -** skip-list lookup and round-robin caching, emitting stack operations -** on-the-fly for a stack-based interpreter -- and all of that in a meager -** kilobyte? Yep, compilers are a great treasure chest. Throw away your -** textbooks and read the codebase of a compiler today!] -** -** There's another optimization opportunity for array indexing: it's -** always accompanied by an array bounds-check. The outermost overflow -** check may be delegated to the ABC operation. This works because ABC is -** an unsigned comparison and wrap-around due to overflow creates negative -** numbers. -** -** But this optimization is only valid for constants that cannot overflow -** an int32_t into the range of valid array indexes [0..2^27+1). A check -** for +-2^30 is safe since -2^31 - 2^30 wraps to 2^30 and 2^31-1 + 2^30 -** wraps to -2^30-1. -** -** It's also good enough in practice, since e.g. t[i+1] or t[i-10] are -** quite common. So the above example finally ends up as ADD(i, 1)! -** -** Later on, the assembler is able to fuse the whole array reference and -** the ADD into the memory operands of loads and other instructions. This -** is why LuaJIT is able to generate very pretty (and fast) machine code -** for array indexing. And that, my dear, concludes another story about -** one of the hidden secrets of LuaJIT ... -*/ - -/* Maximum backpropagation depth and maximum stack size. */ -#define NARROW_MAX_BACKPROP 100 -#define NARROW_MAX_STACK 256 - -/* The stack machine has a 32 bit instruction format: [IROpT | IRRef1] -** The lower 16 bits hold a reference (or 0). The upper 16 bits hold -** the IR opcode + type or one of the following special opcodes: -*/ -enum { - NARROW_REF, /* Push ref. */ - NARROW_CONV, /* Push conversion of ref. */ - NARROW_SEXT, /* Push sign-extension of ref. */ - NARROW_INT /* Push KINT ref. The next code holds an int32_t. */ -}; - -typedef uint32_t NarrowIns; - -#define NARROWINS(op, ref) (((op) << 16) + (ref)) -#define narrow_op(ins) ((IROpT)((ins) >> 16)) -#define narrow_ref(ins) ((IRRef1)(ins)) - -/* Context used for narrowing of type conversions. */ -typedef struct NarrowConv { - jit_State *J; /* JIT compiler state. */ - NarrowIns *sp; /* Current stack pointer. */ - NarrowIns *maxsp; /* Maximum stack pointer minus redzone. */ - int lim; /* Limit on the number of emitted conversions. */ - IRRef mode; /* Conversion mode (IRCONV_*). */ - IRType t; /* Destination type: IRT_INT or IRT_I64. */ - NarrowIns stack[NARROW_MAX_STACK]; /* Stack holding stack-machine code. */ -} NarrowConv; - -/* Lookup a reference in the backpropagation cache. */ -static BPropEntry *narrow_bpc_get(jit_State *J, IRRef1 key, IRRef mode) -{ - ptrdiff_t i; - for (i = 0; i < BPROP_SLOTS; i++) { - BPropEntry *bp = &J->bpropcache[i]; - /* Stronger checks are ok, too. */ - if (bp->key == key && bp->mode >= mode && - ((bp->mode ^ mode) & IRCONV_MODEMASK) == 0) - return bp; - } - return NULL; -} - -/* Add an entry to the backpropagation cache. */ -static void narrow_bpc_set(jit_State *J, IRRef1 key, IRRef1 val, IRRef mode) -{ - uint32_t slot = J->bpropslot; - BPropEntry *bp = &J->bpropcache[slot]; - J->bpropslot = (slot + 1) & (BPROP_SLOTS-1); - bp->key = key; - bp->val = val; - bp->mode = mode; -} - -/* Backpropagate overflow stripping. */ -static void narrow_stripov_backprop(NarrowConv *nc, IRRef ref, int depth) -{ - jit_State *J = nc->J; - IRIns *ir = IR(ref); - if (ir->o == IR_ADDOV || ir->o == IR_SUBOV || - (ir->o == IR_MULOV && (nc->mode & IRCONV_CONVMASK) == IRCONV_ANY)) { - BPropEntry *bp = narrow_bpc_get(nc->J, ref, IRCONV_TOBIT); - if (bp) { - ref = bp->val; - } else if (++depth < NARROW_MAX_BACKPROP && nc->sp < nc->maxsp) { - narrow_stripov_backprop(nc, ir->op1, depth); - narrow_stripov_backprop(nc, ir->op2, depth); - *nc->sp++ = NARROWINS(IRT(ir->o - IR_ADDOV + IR_ADD, IRT_INT), ref); - return; - } - } - *nc->sp++ = NARROWINS(NARROW_REF, ref); -} - -/* Backpropagate narrowing conversion. Return number of needed conversions. */ -static int narrow_conv_backprop(NarrowConv *nc, IRRef ref, int depth) -{ - jit_State *J = nc->J; - IRIns *ir = IR(ref); - IRRef cref; - - /* Check the easy cases first. */ - if (ir->o == IR_CONV && (ir->op2 & IRCONV_SRCMASK) == IRT_INT) { - if ((nc->mode & IRCONV_CONVMASK) <= IRCONV_ANY) - narrow_stripov_backprop(nc, ir->op1, depth+1); - else - *nc->sp++ = NARROWINS(NARROW_REF, ir->op1); /* Undo conversion. */ - if (nc->t == IRT_I64) - *nc->sp++ = NARROWINS(NARROW_SEXT, 0); /* Sign-extend integer. */ - return 0; - } else if (ir->o == IR_KNUM) { /* Narrow FP constant. */ - lua_Number n = ir_knum(ir)->n; - if ((nc->mode & IRCONV_CONVMASK) == IRCONV_TOBIT) { - /* Allows a wider range of constants. */ - int64_t k64 = (int64_t)n; - if (n == (lua_Number)k64) { /* Only if const doesn't lose precision. */ - *nc->sp++ = NARROWINS(NARROW_INT, 0); - *nc->sp++ = (NarrowIns)k64; /* But always truncate to 32 bits. */ - return 0; - } - } else { - int32_t k = lj_num2int(n); - /* Only if constant is a small integer. */ - if (checki16(k) && n == (lua_Number)k) { - *nc->sp++ = NARROWINS(NARROW_INT, 0); - *nc->sp++ = (NarrowIns)k; - return 0; - } - } - return 10; /* Never narrow other FP constants (this is rare). */ - } - - /* Try to CSE the conversion. Stronger checks are ok, too. */ - cref = J->chain[fins->o]; - while (cref > ref) { - IRIns *cr = IR(cref); - if (cr->op1 == ref && - (fins->o == IR_TOBIT || - ((cr->op2 & IRCONV_MODEMASK) == (nc->mode & IRCONV_MODEMASK) && - irt_isguard(cr->t) >= irt_isguard(fins->t)))) { - *nc->sp++ = NARROWINS(NARROW_REF, cref); - return 0; /* Already there, no additional conversion needed. */ - } - cref = cr->prev; - } - - /* Backpropagate across ADD/SUB. */ - if (ir->o == IR_ADD || ir->o == IR_SUB) { - /* Try cache lookup first. */ - IRRef mode = nc->mode; - BPropEntry *bp; - /* Inner conversions need a stronger check. */ - if ((mode & IRCONV_CONVMASK) == IRCONV_INDEX && depth > 0) - mode += IRCONV_CHECK-IRCONV_INDEX; - bp = narrow_bpc_get(nc->J, (IRRef1)ref, mode); - if (bp) { - *nc->sp++ = NARROWINS(NARROW_REF, bp->val); - return 0; - } else if (nc->t == IRT_I64) { - /* Try sign-extending from an existing (checked) conversion to int. */ - mode = (IRT_INT<<5)|IRT_NUM|IRCONV_INDEX; - bp = narrow_bpc_get(nc->J, (IRRef1)ref, mode); - if (bp) { - *nc->sp++ = NARROWINS(NARROW_REF, bp->val); - *nc->sp++ = NARROWINS(NARROW_SEXT, 0); - return 0; - } - } - if (++depth < NARROW_MAX_BACKPROP && nc->sp < nc->maxsp) { - NarrowIns *savesp = nc->sp; - int count = narrow_conv_backprop(nc, ir->op1, depth); - count += narrow_conv_backprop(nc, ir->op2, depth); - if (count <= nc->lim) { /* Limit total number of conversions. */ - *nc->sp++ = NARROWINS(IRT(ir->o, nc->t), ref); - return count; - } - nc->sp = savesp; /* Too many conversions, need to backtrack. */ - } - } - - /* Otherwise add a conversion. */ - *nc->sp++ = NARROWINS(NARROW_CONV, ref); - return 1; -} - -/* Emit the conversions collected during backpropagation. */ -static IRRef narrow_conv_emit(jit_State *J, NarrowConv *nc) -{ - /* The fins fields must be saved now -- emitir() overwrites them. */ - IROpT guardot = irt_isguard(fins->t) ? IRTG(IR_ADDOV-IR_ADD, 0) : 0; - IROpT convot = fins->ot; - IRRef1 convop2 = fins->op2; - NarrowIns *next = nc->stack; /* List of instructions from backpropagation. */ - NarrowIns *last = nc->sp; - NarrowIns *sp = nc->stack; /* Recycle the stack to store operands. */ - while (next < last) { /* Simple stack machine to process the ins. list. */ - NarrowIns ref = *next++; - IROpT op = narrow_op(ref); - if (op == NARROW_REF) { - *sp++ = ref; - } else if (op == NARROW_CONV) { - *sp++ = emitir_raw(convot, ref, convop2); /* Raw emit avoids a loop. */ - } else if (op == NARROW_SEXT) { - lua_assert(sp >= nc->stack+1); - sp[-1] = emitir(IRT(IR_CONV, IRT_I64), sp[-1], - (IRT_I64<<5)|IRT_INT|IRCONV_SEXT); - } else if (op == NARROW_INT) { - lua_assert(next < last); - *sp++ = nc->t == IRT_I64 ? - lj_ir_kint64(J, (int64_t)(int32_t)*next++) : - lj_ir_kint(J, *next++); - } else { /* Regular IROpT. Pops two operands and pushes one result. */ - IRRef mode = nc->mode; - lua_assert(sp >= nc->stack+2); - sp--; - /* Omit some overflow checks for array indexing. See comments above. */ - if ((mode & IRCONV_CONVMASK) == IRCONV_INDEX) { - if (next == last && irref_isk(narrow_ref(sp[0])) && - (uint32_t)IR(narrow_ref(sp[0]))->i + 0x40000000u < 0x80000000u) - guardot = 0; - else /* Otherwise cache a stronger check. */ - mode += IRCONV_CHECK-IRCONV_INDEX; - } - sp[-1] = emitir(op+guardot, sp[-1], sp[0]); - /* Add to cache. */ - if (narrow_ref(ref)) - narrow_bpc_set(J, narrow_ref(ref), narrow_ref(sp[-1]), mode); - } - } - lua_assert(sp == nc->stack+1); - return nc->stack[0]; -} - -/* Narrow a type conversion of an arithmetic operation. */ -TRef LJ_FASTCALL lj_opt_narrow_convert(jit_State *J) -{ - if ((J->flags & JIT_F_OPT_NARROW)) { - NarrowConv nc; - nc.J = J; - nc.sp = nc.stack; - nc.maxsp = &nc.stack[NARROW_MAX_STACK-4]; - nc.t = irt_type(fins->t); - if (fins->o == IR_TOBIT) { - nc.mode = IRCONV_TOBIT; /* Used only in the backpropagation cache. */ - nc.lim = 2; /* TOBIT can use a more optimistic rule. */ - } else { - nc.mode = fins->op2; - nc.lim = 1; - } - if (narrow_conv_backprop(&nc, fins->op1, 0) <= nc.lim) - return narrow_conv_emit(J, &nc); - } - return NEXTFOLD; -} - -/* -- Narrowing of implicit conversions ----------------------------------- */ - -/* Recursively strip overflow checks. */ -static TRef narrow_stripov(jit_State *J, TRef tr, int lastop, IRRef mode) -{ - IRRef ref = tref_ref(tr); - IRIns *ir = IR(ref); - int op = ir->o; - if (op >= IR_ADDOV && op <= lastop) { - BPropEntry *bp = narrow_bpc_get(J, ref, mode); - if (bp) { - return TREF(bp->val, irt_t(IR(bp->val)->t)); - } else { - IRRef op1 = ir->op1, op2 = ir->op2; /* The IR may be reallocated. */ - op1 = narrow_stripov(J, op1, lastop, mode); - op2 = narrow_stripov(J, op2, lastop, mode); - tr = emitir(IRT(op - IR_ADDOV + IR_ADD, - ((mode & IRCONV_DSTMASK) >> IRCONV_DSH)), op1, op2); - narrow_bpc_set(J, ref, tref_ref(tr), mode); - } - } else if (LJ_64 && (mode & IRCONV_SEXT) && !irt_is64(ir->t)) { - tr = emitir(IRT(IR_CONV, IRT_INTP), tr, mode); - } - return tr; -} - -/* Narrow array index. */ -TRef LJ_FASTCALL lj_opt_narrow_index(jit_State *J, TRef tr) -{ - IRIns *ir; - lua_assert(tref_isnumber(tr)); - if (tref_isnum(tr)) /* Conversion may be narrowed, too. See above. */ - return emitir(IRTGI(IR_CONV), tr, IRCONV_INT_NUM|IRCONV_INDEX); - /* Omit some overflow checks for array indexing. See comments above. */ - ir = IR(tref_ref(tr)); - if ((ir->o == IR_ADDOV || ir->o == IR_SUBOV) && irref_isk(ir->op2) && - (uint32_t)IR(ir->op2)->i + 0x40000000u < 0x80000000u) - return emitir(IRTI(ir->o - IR_ADDOV + IR_ADD), ir->op1, ir->op2); - return tr; -} - -/* Narrow conversion to integer operand (overflow undefined). */ -TRef LJ_FASTCALL lj_opt_narrow_toint(jit_State *J, TRef tr) -{ - if (tref_isstr(tr)) - tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); - if (tref_isnum(tr)) /* Conversion may be narrowed, too. See above. */ - return emitir(IRTI(IR_CONV), tr, IRCONV_INT_NUM|IRCONV_ANY); - if (!tref_isinteger(tr)) - lj_trace_err(J, LJ_TRERR_BADTYPE); - /* - ** Undefined overflow semantics allow stripping of ADDOV, SUBOV and MULOV. - ** Use IRCONV_TOBIT for the cache entries, since the semantics are the same. - */ - return narrow_stripov(J, tr, IR_MULOV, (IRT_INT<<5)|IRT_INT|IRCONV_TOBIT); -} - -/* Narrow conversion to bitop operand (overflow wrapped). */ -TRef LJ_FASTCALL lj_opt_narrow_tobit(jit_State *J, TRef tr) -{ - if (tref_isstr(tr)) - tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); - if (tref_isnum(tr)) /* Conversion may be narrowed, too. See above. */ - return emitir(IRTI(IR_TOBIT), tr, lj_ir_knum_tobit(J)); - if (!tref_isinteger(tr)) - lj_trace_err(J, LJ_TRERR_BADTYPE); - /* - ** Wrapped overflow semantics allow stripping of ADDOV and SUBOV. - ** MULOV cannot be stripped due to precision widening. - */ - return narrow_stripov(J, tr, IR_SUBOV, (IRT_INT<<5)|IRT_INT|IRCONV_TOBIT); -} - -#if LJ_HASFFI -/* Narrow C array index (overflow undefined). */ -TRef LJ_FASTCALL lj_opt_narrow_cindex(jit_State *J, TRef tr) -{ - lua_assert(tref_isnumber(tr)); - if (tref_isnum(tr)) - return emitir(IRT(IR_CONV, IRT_INTP), tr, - (IRT_INTP<<5)|IRT_NUM|IRCONV_TRUNC|IRCONV_ANY); - /* Undefined overflow semantics allow stripping of ADDOV, SUBOV and MULOV. */ - return narrow_stripov(J, tr, IR_MULOV, - LJ_64 ? ((IRT_INTP<<5)|IRT_INT|IRCONV_SEXT) : - ((IRT_INTP<<5)|IRT_INT|IRCONV_TOBIT)); -} -#endif - -/* -- Narrowing of arithmetic operators ----------------------------------- */ - -/* Check whether a number fits into an int32_t (-0 is ok, too). */ -static int numisint(lua_Number n) -{ - return (n == (lua_Number)lj_num2int(n)); -} - -/* Narrowing of arithmetic operations. */ -TRef lj_opt_narrow_arith(jit_State *J, TRef rb, TRef rc, - TValue *vb, TValue *vc, IROp op) -{ - if (tref_isstr(rb)) { - rb = emitir(IRTG(IR_STRTO, IRT_NUM), rb, 0); - lj_strscan_num(strV(vb), vb); - } - if (tref_isstr(rc)) { - rc = emitir(IRTG(IR_STRTO, IRT_NUM), rc, 0); - lj_strscan_num(strV(vc), vc); - } - /* Must not narrow MUL in non-DUALNUM variant, because it loses -0. */ - if ((op >= IR_ADD && op <= (LJ_DUALNUM ? IR_MUL : IR_SUB)) && - tref_isinteger(rb) && tref_isinteger(rc) && - numisint(lj_vm_foldarith(numberVnum(vb), numberVnum(vc), - (int)op - (int)IR_ADD))) - return emitir(IRTGI((int)op - (int)IR_ADD + (int)IR_ADDOV), rb, rc); - if (!tref_isnum(rb)) rb = emitir(IRTN(IR_CONV), rb, IRCONV_NUM_INT); - if (!tref_isnum(rc)) rc = emitir(IRTN(IR_CONV), rc, IRCONV_NUM_INT); - return emitir(IRTN(op), rb, rc); -} - -/* Narrowing of unary minus operator. */ -TRef lj_opt_narrow_unm(jit_State *J, TRef rc, TValue *vc) -{ - if (tref_isstr(rc)) { - rc = emitir(IRTG(IR_STRTO, IRT_NUM), rc, 0); - lj_strscan_num(strV(vc), vc); - } - if (tref_isinteger(rc)) { - if ((uint32_t)numberVint(vc) != 0x80000000u) - return emitir(IRTGI(IR_SUBOV), lj_ir_kint(J, 0), rc); - rc = emitir(IRTN(IR_CONV), rc, IRCONV_NUM_INT); - } - return emitir(IRTN(IR_NEG), rc, lj_ir_knum_neg(J)); -} - -/* Narrowing of modulo operator. */ -TRef lj_opt_narrow_mod(jit_State *J, TRef rb, TRef rc, TValue *vc) -{ - TRef tmp; - if (tvisstr(vc) && !lj_strscan_num(strV(vc), vc)) - lj_trace_err(J, LJ_TRERR_BADTYPE); - if ((LJ_DUALNUM || (J->flags & JIT_F_OPT_NARROW)) && - tref_isinteger(rb) && tref_isinteger(rc) && - (tvisint(vc) ? intV(vc) != 0 : !tviszero(vc))) { - emitir(IRTGI(IR_NE), rc, lj_ir_kint(J, 0)); - return emitir(IRTI(IR_MOD), rb, rc); - } - /* b % c ==> b - floor(b/c)*c */ - rb = lj_ir_tonum(J, rb); - rc = lj_ir_tonum(J, rc); - tmp = emitir(IRTN(IR_DIV), rb, rc); - tmp = emitir(IRTN(IR_FPMATH), tmp, IRFPM_FLOOR); - tmp = emitir(IRTN(IR_MUL), tmp, rc); - return emitir(IRTN(IR_SUB), rb, tmp); -} - -/* Narrowing of power operator or math.pow. */ -TRef lj_opt_narrow_pow(jit_State *J, TRef rb, TRef rc, TValue *vc) -{ - if (tvisstr(vc) && !lj_strscan_num(strV(vc), vc)) - lj_trace_err(J, LJ_TRERR_BADTYPE); - /* Narrowing must be unconditional to preserve (-x)^i semantics. */ - if (tvisint(vc) || numisint(numV(vc))) { - int checkrange = 0; - /* Split pow is faster for bigger exponents. But do this only for (+k)^i. */ - if (tref_isk(rb) && (int32_t)ir_knum(IR(tref_ref(rb)))->u32.hi >= 0) { - int32_t k = numberVint(vc); - if (!(k >= -65536 && k <= 65536)) goto split_pow; - checkrange = 1; - } - if (!tref_isinteger(rc)) { - if (tref_isstr(rc)) - rc = emitir(IRTG(IR_STRTO, IRT_NUM), rc, 0); - /* Guarded conversion to integer! */ - rc = emitir(IRTGI(IR_CONV), rc, IRCONV_INT_NUM|IRCONV_CHECK); - } - if (checkrange && !tref_isk(rc)) { /* Range guard: -65536 <= i <= 65536 */ - TRef tmp = emitir(IRTI(IR_ADD), rc, lj_ir_kint(J, 65536)); - emitir(IRTGI(IR_ULE), tmp, lj_ir_kint(J, 2*65536)); - } - return emitir(IRTN(IR_POW), rb, rc); - } -split_pow: - /* FOLD covers most cases, but some are easier to do here. */ - if (tref_isk(rb) && tvispone(ir_knum(IR(tref_ref(rb))))) - return rb; /* 1 ^ x ==> 1 */ - rc = lj_ir_tonum(J, rc); - if (tref_isk(rc) && ir_knum(IR(tref_ref(rc)))->n == 0.5) - return emitir(IRTN(IR_FPMATH), rb, IRFPM_SQRT); /* x ^ 0.5 ==> sqrt(x) */ - /* Split up b^c into exp2(c*log2(b)). Assembler may rejoin later. */ - rb = emitir(IRTN(IR_FPMATH), rb, IRFPM_LOG2); - rc = emitir(IRTN(IR_MUL), rb, rc); - return emitir(IRTN(IR_FPMATH), rc, IRFPM_EXP2); -} - -/* -- Predictive narrowing of induction variables ------------------------- */ - -/* Narrow a single runtime value. */ -static int narrow_forl(jit_State *J, cTValue *o) -{ - if (tvisint(o)) return 1; - if (LJ_DUALNUM || (J->flags & JIT_F_OPT_NARROW)) return numisint(numV(o)); - return 0; -} - -/* Narrow the FORL index type by looking at the runtime values. */ -IRType lj_opt_narrow_forl(jit_State *J, cTValue *tv) -{ - lua_assert(tvisnumber(&tv[FORL_IDX]) && - tvisnumber(&tv[FORL_STOP]) && - tvisnumber(&tv[FORL_STEP])); - /* Narrow only if the runtime values of start/stop/step are all integers. */ - if (narrow_forl(J, &tv[FORL_IDX]) && - narrow_forl(J, &tv[FORL_STOP]) && - narrow_forl(J, &tv[FORL_STEP])) { - /* And if the loop index can't possibly overflow. */ - lua_Number step = numberVnum(&tv[FORL_STEP]); - lua_Number sum = numberVnum(&tv[FORL_STOP]) + step; - if (0 <= step ? (sum <= 2147483647.0) : (sum >= -2147483648.0)) - return IRT_INT; - } - return IRT_NUM; -} - -#undef IR -#undef fins -#undef emitir -#undef emitir_raw - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_sink.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_sink.c deleted file mode 100644 index 3a3334616..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_sink.c +++ /dev/null @@ -1,245 +0,0 @@ -/* -** SINK: Allocation Sinking and Store Sinking. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_opt_sink_c -#define LUA_CORE - -#include "lj_obj.h" - -#if LJ_HASJIT - -#include "lj_ir.h" -#include "lj_jit.h" -#include "lj_iropt.h" -#include "lj_target.h" - -/* Some local macros to save typing. Undef'd at the end. */ -#define IR(ref) (&J->cur.ir[(ref)]) - -/* Check whether the store ref points to an eligible allocation. */ -static IRIns *sink_checkalloc(jit_State *J, IRIns *irs) -{ - IRIns *ir = IR(irs->op1); - if (!irref_isk(ir->op2)) - return NULL; /* Non-constant key. */ - if (ir->o == IR_HREFK || ir->o == IR_AREF) - ir = IR(ir->op1); - else if (!(ir->o == IR_HREF || ir->o == IR_NEWREF || - ir->o == IR_FREF || ir->o == IR_ADD)) - return NULL; /* Unhandled reference type (for XSTORE). */ - ir = IR(ir->op1); - if (!(ir->o == IR_TNEW || ir->o == IR_TDUP || ir->o == IR_CNEW)) - return NULL; /* Not an allocation. */ - return ir; /* Return allocation. */ -} - -/* Recursively check whether a value depends on a PHI. */ -static int sink_phidep(jit_State *J, IRRef ref) -{ - IRIns *ir = IR(ref); - if (irt_isphi(ir->t)) return 1; - if (ir->op1 >= REF_FIRST && sink_phidep(J, ir->op1)) return 1; - if (ir->op2 >= REF_FIRST && sink_phidep(J, ir->op2)) return 1; - return 0; -} - -/* Check whether a value is a sinkable PHI or loop-invariant. */ -static int sink_checkphi(jit_State *J, IRIns *ira, IRRef ref) -{ - if (ref >= REF_FIRST) { - IRIns *ir = IR(ref); - if (irt_isphi(ir->t) || (ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT && - irt_isphi(IR(ir->op1)->t))) { - ira->prev++; - return 1; /* Sinkable PHI. */ - } - /* Otherwise the value must be loop-invariant. */ - return ref < J->loopref && !sink_phidep(J, ref); - } - return 1; /* Constant (non-PHI). */ -} - -/* Mark non-sinkable allocations using single-pass backward propagation. -** -** Roots for the marking process are: -** - Some PHIs or snapshots (see below). -** - Non-PHI, non-constant values stored to PHI allocations. -** - All guards. -** - Any remaining loads not eliminated by store-to-load forwarding. -** - Stores with non-constant keys. -** - All stored values. -*/ -static void sink_mark_ins(jit_State *J) -{ - IRIns *ir, *irlast = IR(J->cur.nins-1); - for (ir = irlast ; ; ir--) { - switch (ir->o) { - case IR_BASE: - return; /* Finished. */ - case IR_CALLL: /* IRCALL_lj_tab_len */ - case IR_ALOAD: case IR_HLOAD: case IR_XLOAD: case IR_TBAR: - irt_setmark(IR(ir->op1)->t); /* Mark ref for remaining loads. */ - break; - case IR_FLOAD: - if (irt_ismarked(ir->t) || ir->op2 == IRFL_TAB_META) - irt_setmark(IR(ir->op1)->t); /* Mark table for remaining loads. */ - break; - case IR_ASTORE: case IR_HSTORE: case IR_FSTORE: case IR_XSTORE: { - IRIns *ira = sink_checkalloc(J, ir); - if (!ira || (irt_isphi(ira->t) && !sink_checkphi(J, ira, ir->op2))) - irt_setmark(IR(ir->op1)->t); /* Mark ineligible ref. */ - irt_setmark(IR(ir->op2)->t); /* Mark stored value. */ - break; - } -#if LJ_HASFFI - case IR_CNEWI: - if (irt_isphi(ir->t) && - (!sink_checkphi(J, ir, ir->op2) || - (LJ_32 && ir+1 < irlast && (ir+1)->o == IR_HIOP && - !sink_checkphi(J, ir, (ir+1)->op2)))) - irt_setmark(ir->t); /* Mark ineligible allocation. */ - /* fallthrough */ -#endif - case IR_USTORE: - irt_setmark(IR(ir->op2)->t); /* Mark stored value. */ - break; -#if LJ_HASFFI - case IR_CALLXS: -#endif - case IR_CALLS: - irt_setmark(IR(ir->op1)->t); /* Mark (potentially) stored values. */ - break; - case IR_PHI: { - IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); - irl->prev = irr->prev = 0; /* Clear PHI value counts. */ - if (irl->o == irr->o && - (irl->o == IR_TNEW || irl->o == IR_TDUP || - (LJ_HASFFI && (irl->o == IR_CNEW || irl->o == IR_CNEWI)))) - break; - irt_setmark(irl->t); - irt_setmark(irr->t); - break; - } - default: - if (irt_ismarked(ir->t) || irt_isguard(ir->t)) { /* Propagate mark. */ - if (ir->op1 >= REF_FIRST) irt_setmark(IR(ir->op1)->t); - if (ir->op2 >= REF_FIRST) irt_setmark(IR(ir->op2)->t); - } - break; - } - } -} - -/* Mark all instructions referenced by a snapshot. */ -static void sink_mark_snap(jit_State *J, SnapShot *snap) -{ - SnapEntry *map = &J->cur.snapmap[snap->mapofs]; - MSize n, nent = snap->nent; - for (n = 0; n < nent; n++) { - IRRef ref = snap_ref(map[n]); - if (!irref_isk(ref)) - irt_setmark(IR(ref)->t); - } -} - -/* Iteratively remark PHI refs with differing marks or PHI value counts. */ -static void sink_remark_phi(jit_State *J) -{ - IRIns *ir; - int remark; - do { - remark = 0; - for (ir = IR(J->cur.nins-1); ir->o == IR_PHI; ir--) { - IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); - if (((irl->t.irt ^ irr->t.irt) & IRT_MARK)) - remark = 1; - else if (irl->prev == irr->prev) - continue; - irt_setmark(IR(ir->op1)->t); - irt_setmark(IR(ir->op2)->t); - } - } while (remark); -} - -/* Sweep instructions and tag sunken allocations and stores. */ -static void sink_sweep_ins(jit_State *J) -{ - IRIns *ir, *irfirst = IR(J->cur.nk); - for (ir = IR(J->cur.nins-1) ; ir >= irfirst; ir--) { - switch (ir->o) { - case IR_ASTORE: case IR_HSTORE: case IR_FSTORE: case IR_XSTORE: { - IRIns *ira = sink_checkalloc(J, ir); - if (ira && !irt_ismarked(ira->t)) { - int delta = (int)(ir - ira); - ir->prev = REGSP(RID_SINK, delta > 255 ? 255 : delta); - } else { - ir->prev = REGSP_INIT; - } - break; - } - case IR_NEWREF: - if (!irt_ismarked(IR(ir->op1)->t)) { - ir->prev = REGSP(RID_SINK, 0); - } else { - irt_clearmark(ir->t); - ir->prev = REGSP_INIT; - } - break; -#if LJ_HASFFI - case IR_CNEW: case IR_CNEWI: -#endif - case IR_TNEW: case IR_TDUP: - if (!irt_ismarked(ir->t)) { - ir->t.irt &= ~IRT_GUARD; - ir->prev = REGSP(RID_SINK, 0); - J->cur.sinktags = 1; /* Signal present SINK tags to assembler. */ - } else { - irt_clearmark(ir->t); - ir->prev = REGSP_INIT; - } - break; - case IR_PHI: { - IRIns *ira = IR(ir->op2); - if (!irt_ismarked(ira->t) && - (ira->o == IR_TNEW || ira->o == IR_TDUP || - (LJ_HASFFI && (ira->o == IR_CNEW || ira->o == IR_CNEWI)))) { - ir->prev = REGSP(RID_SINK, 0); - } else { - ir->prev = REGSP_INIT; - } - break; - } - default: - irt_clearmark(ir->t); - ir->prev = REGSP_INIT; - break; - } - } -} - -/* Allocation sinking and store sinking. -** -** 1. Mark all non-sinkable allocations. -** 2. Then sink all remaining allocations and the related stores. -*/ -void lj_opt_sink(jit_State *J) -{ - const uint32_t need = (JIT_F_OPT_SINK|JIT_F_OPT_FWD| - JIT_F_OPT_DCE|JIT_F_OPT_CSE|JIT_F_OPT_FOLD); - if ((J->flags & need) == need && - (J->chain[IR_TNEW] || J->chain[IR_TDUP] || - (LJ_HASFFI && (J->chain[IR_CNEW] || J->chain[IR_CNEWI])))) { - if (!J->loopref) - sink_mark_snap(J, &J->cur.snap[J->cur.nsnap-1]); - sink_mark_ins(J); - if (J->loopref) - sink_remark_phi(J); - sink_sweep_ins(J); - } -} - -#undef IR - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_split.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_split.c deleted file mode 100644 index 99d10584f..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_opt_split.c +++ /dev/null @@ -1,731 +0,0 @@ -/* -** SPLIT: Split 64 bit IR instructions into 32 bit IR instructions. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_opt_split_c -#define LUA_CORE - -#include "lj_obj.h" - -#if LJ_HASJIT && (LJ_SOFTFP || (LJ_32 && LJ_HASFFI)) - -#include "lj_err.h" -#include "lj_str.h" -#include "lj_ir.h" -#include "lj_jit.h" -#include "lj_ircall.h" -#include "lj_iropt.h" -#include "lj_vm.h" - -/* SPLIT pass: -** -** This pass splits up 64 bit IR instructions into multiple 32 bit IR -** instructions. It's only active for soft-float targets or for 32 bit CPUs -** which lack native 64 bit integer operations (the FFI is currently the -** only emitter for 64 bit integer instructions). -** -** Splitting the IR in a separate pass keeps each 32 bit IR assembler -** backend simple. Only a small amount of extra functionality needs to be -** implemented. This is much easier than adding support for allocating -** register pairs to each backend (believe me, I tried). A few simple, but -** important optimizations can be performed by the SPLIT pass, which would -** be tedious to do in the backend. -** -** The basic idea is to replace each 64 bit IR instruction with its 32 bit -** equivalent plus an extra HIOP instruction. The splitted IR is not passed -** through FOLD or any other optimizations, so each HIOP is guaranteed to -** immediately follow it's counterpart. The actual functionality of HIOP is -** inferred from the previous instruction. -** -** The operands of HIOP hold the hiword input references. The output of HIOP -** is the hiword output reference, which is also used to hold the hiword -** register or spill slot information. The register allocator treats this -** instruction independently of any other instruction, which improves code -** quality compared to using fixed register pairs. -** -** It's easier to split up some instructions into two regular 32 bit -** instructions. E.g. XLOAD is split up into two XLOADs with two different -** addresses. Obviously 64 bit constants need to be split up into two 32 bit -** constants, too. Some hiword instructions can be entirely omitted, e.g. -** when zero-extending a 32 bit value to 64 bits. 64 bit arguments for calls -** are split up into two 32 bit arguments each. -** -** On soft-float targets, floating-point instructions are directly converted -** to soft-float calls by the SPLIT pass (except for comparisons and MIN/MAX). -** HIOP for number results has the type IRT_SOFTFP ("sfp" in -jdump). -** -** Here's the IR and x64 machine code for 'x.b = x.a + 1' for a struct with -** two int64_t fields: -** -** 0100 p32 ADD base +8 -** 0101 i64 XLOAD 0100 -** 0102 i64 ADD 0101 +1 -** 0103 p32 ADD base +16 -** 0104 i64 XSTORE 0103 0102 -** -** mov rax, [esi+0x8] -** add rax, +0x01 -** mov [esi+0x10], rax -** -** Here's the transformed IR and the x86 machine code after the SPLIT pass: -** -** 0100 p32 ADD base +8 -** 0101 int XLOAD 0100 -** 0102 p32 ADD base +12 -** 0103 int XLOAD 0102 -** 0104 int ADD 0101 +1 -** 0105 int HIOP 0103 +0 -** 0106 p32 ADD base +16 -** 0107 int XSTORE 0106 0104 -** 0108 int HIOP 0106 0105 -** -** mov eax, [esi+0x8] -** mov ecx, [esi+0xc] -** add eax, +0x01 -** adc ecx, +0x00 -** mov [esi+0x10], eax -** mov [esi+0x14], ecx -** -** You may notice the reassociated hiword address computation, which is -** later fused into the mov operands by the assembler. -*/ - -/* Some local macros to save typing. Undef'd at the end. */ -#define IR(ref) (&J->cur.ir[(ref)]) - -/* Directly emit the transformed IR without updating chains etc. */ -static IRRef split_emit(jit_State *J, uint16_t ot, IRRef1 op1, IRRef1 op2) -{ - IRRef nref = lj_ir_nextins(J); - IRIns *ir = IR(nref); - ir->ot = ot; - ir->op1 = op1; - ir->op2 = op2; - return nref; -} - -#if LJ_SOFTFP -/* Emit a (checked) number to integer conversion. */ -static IRRef split_num2int(jit_State *J, IRRef lo, IRRef hi, int check) -{ - IRRef tmp, res; -#if LJ_LE - tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), lo, hi); -#else - tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hi, lo); -#endif - res = split_emit(J, IRTI(IR_CALLN), tmp, IRCALL_softfp_d2i); - if (check) { - tmp = split_emit(J, IRTI(IR_CALLN), res, IRCALL_softfp_i2d); - split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), tmp, tmp); - split_emit(J, IRTGI(IR_EQ), tmp, lo); - split_emit(J, IRTG(IR_HIOP, IRT_SOFTFP), tmp+1, hi); - } - return res; -} - -/* Emit a CALLN with one split 64 bit argument. */ -static IRRef split_call_l(jit_State *J, IRRef1 *hisubst, IRIns *oir, - IRIns *ir, IRCallID id) -{ - IRRef tmp, op1 = ir->op1; - J->cur.nins--; -#if LJ_LE - tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), oir[op1].prev, hisubst[op1]); -#else - tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hisubst[op1], oir[op1].prev); -#endif - ir->prev = tmp = split_emit(J, IRTI(IR_CALLN), tmp, id); - return split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), tmp, tmp); -} - -/* Emit a CALLN with one split 64 bit argument and a 32 bit argument. */ -static IRRef split_call_li(jit_State *J, IRRef1 *hisubst, IRIns *oir, - IRIns *ir, IRCallID id) -{ - IRRef tmp, op1 = ir->op1, op2 = ir->op2; - J->cur.nins--; -#if LJ_LE - tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), oir[op1].prev, hisubst[op1]); -#else - tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hisubst[op1], oir[op1].prev); -#endif - tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, oir[op2].prev); - ir->prev = tmp = split_emit(J, IRTI(IR_CALLN), tmp, id); - return split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), tmp, tmp); -} -#endif - -/* Emit a CALLN with two split 64 bit arguments. */ -static IRRef split_call_ll(jit_State *J, IRRef1 *hisubst, IRIns *oir, - IRIns *ir, IRCallID id) -{ - IRRef tmp, op1 = ir->op1, op2 = ir->op2; - J->cur.nins--; -#if LJ_LE - tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), oir[op1].prev, hisubst[op1]); - tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, oir[op2].prev); - tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, hisubst[op2]); -#else - tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hisubst[op1], oir[op1].prev); - tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, hisubst[op2]); - tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, oir[op2].prev); -#endif - ir->prev = tmp = split_emit(J, IRTI(IR_CALLN), tmp, id); - return split_emit(J, - IRT(IR_HIOP, (LJ_SOFTFP && irt_isnum(ir->t)) ? IRT_SOFTFP : IRT_INT), - tmp, tmp); -} - -/* Get a pointer to the other 32 bit word (LE: hiword, BE: loword). */ -static IRRef split_ptr(jit_State *J, IRIns *oir, IRRef ref) -{ - IRRef nref = oir[ref].prev; - IRIns *ir = IR(nref); - int32_t ofs = 4; - if (ir->o == IR_KPTR) - return lj_ir_kptr(J, (char *)ir_kptr(ir) + ofs); - if (ir->o == IR_ADD && irref_isk(ir->op2) && !irt_isphi(oir[ref].t)) { - /* Reassociate address. */ - ofs += IR(ir->op2)->i; - nref = ir->op1; - if (ofs == 0) return nref; - } - return split_emit(J, IRTI(IR_ADD), nref, lj_ir_kint(J, ofs)); -} - -/* Substitute references of a snapshot. */ -static void split_subst_snap(jit_State *J, SnapShot *snap, IRIns *oir) -{ - SnapEntry *map = &J->cur.snapmap[snap->mapofs]; - MSize n, nent = snap->nent; - for (n = 0; n < nent; n++) { - SnapEntry sn = map[n]; - IRIns *ir = &oir[snap_ref(sn)]; - if (!(LJ_SOFTFP && (sn & SNAP_SOFTFPNUM) && irref_isk(snap_ref(sn)))) - map[n] = ((sn & 0xffff0000) | ir->prev); - } -} - -/* Transform the old IR to the new IR. */ -static void split_ir(jit_State *J) -{ - IRRef nins = J->cur.nins, nk = J->cur.nk; - MSize irlen = nins - nk; - MSize need = (irlen+1)*(sizeof(IRIns) + sizeof(IRRef1)); - IRIns *oir = (IRIns *)lj_str_needbuf(J->L, &G(J->L)->tmpbuf, need); - IRRef1 *hisubst; - IRRef ref, snref; - SnapShot *snap; - - /* Copy old IR to buffer. */ - memcpy(oir, IR(nk), irlen*sizeof(IRIns)); - /* Bias hiword substitution table and old IR. Loword kept in field prev. */ - hisubst = (IRRef1 *)&oir[irlen] - nk; - oir -= nk; - - /* Remove all IR instructions, but retain IR constants. */ - J->cur.nins = REF_FIRST; - J->loopref = 0; - - /* Process constants and fixed references. */ - for (ref = nk; ref <= REF_BASE; ref++) { - IRIns *ir = &oir[ref]; - if ((LJ_SOFTFP && ir->o == IR_KNUM) || ir->o == IR_KINT64) { - /* Split up 64 bit constant. */ - TValue tv = *ir_k64(ir); - ir->prev = lj_ir_kint(J, (int32_t)tv.u32.lo); - hisubst[ref] = lj_ir_kint(J, (int32_t)tv.u32.hi); - } else { - ir->prev = ref; /* Identity substitution for loword. */ - hisubst[ref] = 0; - } - } - - /* Process old IR instructions. */ - snap = J->cur.snap; - snref = snap->ref; - for (ref = REF_FIRST; ref < nins; ref++) { - IRIns *ir = &oir[ref]; - IRRef nref = lj_ir_nextins(J); - IRIns *nir = IR(nref); - IRRef hi = 0; - - if (ref >= snref) { - snap->ref = nref; - split_subst_snap(J, snap++, oir); - snref = snap < &J->cur.snap[J->cur.nsnap] ? snap->ref : ~(IRRef)0; - } - - /* Copy-substitute old instruction to new instruction. */ - nir->op1 = ir->op1 < nk ? ir->op1 : oir[ir->op1].prev; - nir->op2 = ir->op2 < nk ? ir->op2 : oir[ir->op2].prev; - ir->prev = nref; /* Loword substitution. */ - nir->o = ir->o; - nir->t.irt = ir->t.irt & ~(IRT_MARK|IRT_ISPHI); - hisubst[ref] = 0; - - /* Split 64 bit instructions. */ -#if LJ_SOFTFP - if (irt_isnum(ir->t)) { - nir->t.irt = IRT_INT | (nir->t.irt & IRT_GUARD); /* Turn into INT op. */ - /* Note: hi ref = lo ref + 1! Required for SNAP_SOFTFPNUM logic. */ - switch (ir->o) { - case IR_ADD: - hi = split_call_ll(J, hisubst, oir, ir, IRCALL_softfp_add); - break; - case IR_SUB: - hi = split_call_ll(J, hisubst, oir, ir, IRCALL_softfp_sub); - break; - case IR_MUL: - hi = split_call_ll(J, hisubst, oir, ir, IRCALL_softfp_mul); - break; - case IR_DIV: - hi = split_call_ll(J, hisubst, oir, ir, IRCALL_softfp_div); - break; - case IR_POW: - hi = split_call_li(J, hisubst, oir, ir, IRCALL_lj_vm_powi); - break; - case IR_FPMATH: - /* Try to rejoin pow from EXP2, MUL and LOG2. */ - if (nir->op2 == IRFPM_EXP2 && nir->op1 > J->loopref) { - IRIns *irp = IR(nir->op1); - if (irp->o == IR_CALLN && irp->op2 == IRCALL_softfp_mul) { - IRIns *irm4 = IR(irp->op1); - IRIns *irm3 = IR(irm4->op1); - IRIns *irm12 = IR(irm3->op1); - IRIns *irl1 = IR(irm12->op1); - if (irm12->op1 > J->loopref && irl1->o == IR_CALLN && - irl1->op2 == IRCALL_lj_vm_log2) { - IRRef tmp = irl1->op1; /* Recycle first two args from LOG2. */ - IRRef arg3 = irm3->op2, arg4 = irm4->op2; - J->cur.nins--; - tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, arg3); - tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, arg4); - ir->prev = tmp = split_emit(J, IRTI(IR_CALLN), tmp, IRCALL_pow); - hi = split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), tmp, tmp); - break; - } - } - } - hi = split_call_l(J, hisubst, oir, ir, IRCALL_lj_vm_floor + ir->op2); - break; - case IR_ATAN2: - hi = split_call_ll(J, hisubst, oir, ir, IRCALL_atan2); - break; - case IR_LDEXP: - hi = split_call_li(J, hisubst, oir, ir, IRCALL_ldexp); - break; - case IR_NEG: case IR_ABS: - nir->o = IR_CONV; /* Pass through loword. */ - nir->op2 = (IRT_INT << 5) | IRT_INT; - hi = split_emit(J, IRT(ir->o == IR_NEG ? IR_BXOR : IR_BAND, IRT_SOFTFP), - hisubst[ir->op1], hisubst[ir->op2]); - break; - case IR_SLOAD: - if ((nir->op2 & IRSLOAD_CONVERT)) { /* Convert from int to number. */ - nir->op2 &= ~IRSLOAD_CONVERT; - ir->prev = nref = split_emit(J, IRTI(IR_CALLN), nref, - IRCALL_softfp_i2d); - hi = split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nref, nref); - break; - } - /* fallthrough */ - case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: - case IR_STRTO: - hi = split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nref, nref); - break; - case IR_XLOAD: { - IRIns inslo = *nir; /* Save/undo the emit of the lo XLOAD. */ - J->cur.nins--; - hi = split_ptr(J, oir, ir->op1); /* Insert the hiref ADD. */ - nref = lj_ir_nextins(J); - nir = IR(nref); - *nir = inslo; /* Re-emit lo XLOAD immediately before hi XLOAD. */ - hi = split_emit(J, IRT(IR_XLOAD, IRT_SOFTFP), hi, ir->op2); -#if LJ_LE - ir->prev = nref; -#else - ir->prev = hi; hi = nref; -#endif - break; - } - case IR_ASTORE: case IR_HSTORE: case IR_USTORE: case IR_XSTORE: - split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nir->op1, hisubst[ir->op2]); - break; - case IR_CONV: { /* Conversion to number. Others handled below. */ - IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); - UNUSED(st); -#if LJ_32 && LJ_HASFFI - if (st == IRT_I64 || st == IRT_U64) { - hi = split_call_l(J, hisubst, oir, ir, - st == IRT_I64 ? IRCALL_fp64_l2d : IRCALL_fp64_ul2d); - break; - } -#endif - lua_assert(st == IRT_INT || - (LJ_32 && LJ_HASFFI && (st == IRT_U32 || st == IRT_FLOAT))); - nir->o = IR_CALLN; -#if LJ_32 && LJ_HASFFI - nir->op2 = st == IRT_INT ? IRCALL_softfp_i2d : - st == IRT_FLOAT ? IRCALL_softfp_f2d : - IRCALL_softfp_ui2d; -#else - nir->op2 = IRCALL_softfp_i2d; -#endif - hi = split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nref, nref); - break; - } - case IR_CALLN: - case IR_CALLL: - case IR_CALLS: - case IR_CALLXS: - goto split_call; - case IR_PHI: - if (nir->op1 == nir->op2) - J->cur.nins--; /* Drop useless PHIs. */ - if (hisubst[ir->op1] != hisubst[ir->op2]) - split_emit(J, IRT(IR_PHI, IRT_SOFTFP), - hisubst[ir->op1], hisubst[ir->op2]); - break; - case IR_HIOP: - J->cur.nins--; /* Drop joining HIOP. */ - ir->prev = nir->op1; - hi = nir->op2; - break; - default: - lua_assert(ir->o <= IR_NE || ir->o == IR_MIN || ir->o == IR_MAX); - hi = split_emit(J, IRTG(IR_HIOP, IRT_SOFTFP), - hisubst[ir->op1], hisubst[ir->op2]); - break; - } - } else -#endif -#if LJ_32 && LJ_HASFFI - if (irt_isint64(ir->t)) { - IRRef hiref = hisubst[ir->op1]; - nir->t.irt = IRT_INT | (nir->t.irt & IRT_GUARD); /* Turn into INT op. */ - switch (ir->o) { - case IR_ADD: - case IR_SUB: - /* Use plain op for hiword if loword cannot produce a carry/borrow. */ - if (irref_isk(nir->op2) && IR(nir->op2)->i == 0) { - ir->prev = nir->op1; /* Pass through loword. */ - nir->op1 = hiref; nir->op2 = hisubst[ir->op2]; - hi = nref; - break; - } - /* fallthrough */ - case IR_NEG: - hi = split_emit(J, IRTI(IR_HIOP), hiref, hisubst[ir->op2]); - break; - case IR_MUL: - hi = split_call_ll(J, hisubst, oir, ir, IRCALL_lj_carith_mul64); - break; - case IR_DIV: - hi = split_call_ll(J, hisubst, oir, ir, - irt_isi64(ir->t) ? IRCALL_lj_carith_divi64 : - IRCALL_lj_carith_divu64); - break; - case IR_MOD: - hi = split_call_ll(J, hisubst, oir, ir, - irt_isi64(ir->t) ? IRCALL_lj_carith_modi64 : - IRCALL_lj_carith_modu64); - break; - case IR_POW: - hi = split_call_ll(J, hisubst, oir, ir, - irt_isi64(ir->t) ? IRCALL_lj_carith_powi64 : - IRCALL_lj_carith_powu64); - break; - case IR_FLOAD: - lua_assert(ir->op2 == IRFL_CDATA_INT64); - hi = split_emit(J, IRTI(IR_FLOAD), nir->op1, IRFL_CDATA_INT64_4); -#if LJ_BE - ir->prev = hi; hi = nref; -#endif - break; - case IR_XLOAD: - hi = split_emit(J, IRTI(IR_XLOAD), split_ptr(J, oir, ir->op1), ir->op2); -#if LJ_BE - ir->prev = hi; hi = nref; -#endif - break; - case IR_XSTORE: - split_emit(J, IRTI(IR_HIOP), nir->op1, hisubst[ir->op2]); - break; - case IR_CONV: { /* Conversion to 64 bit integer. Others handled below. */ - IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); -#if LJ_SOFTFP - if (st == IRT_NUM) { /* NUM to 64 bit int conv. */ - hi = split_call_l(J, hisubst, oir, ir, - irt_isi64(ir->t) ? IRCALL_fp64_d2l : IRCALL_fp64_d2ul); - } else if (st == IRT_FLOAT) { /* FLOAT to 64 bit int conv. */ - nir->o = IR_CALLN; - nir->op2 = irt_isi64(ir->t) ? IRCALL_fp64_f2l : IRCALL_fp64_f2ul; - hi = split_emit(J, IRTI(IR_HIOP), nref, nref); - } -#else - if (st == IRT_NUM || st == IRT_FLOAT) { /* FP to 64 bit int conv. */ - hi = split_emit(J, IRTI(IR_HIOP), nir->op1, nref); - } -#endif - else if (st == IRT_I64 || st == IRT_U64) { /* 64/64 bit cast. */ - /* Drop cast, since assembler doesn't care. */ - goto fwdlo; - } else if ((ir->op2 & IRCONV_SEXT)) { /* Sign-extend to 64 bit. */ - IRRef k31 = lj_ir_kint(J, 31); - nir = IR(nref); /* May have been reallocated. */ - ir->prev = nir->op1; /* Pass through loword. */ - nir->o = IR_BSAR; /* hi = bsar(lo, 31). */ - nir->op2 = k31; - hi = nref; - } else { /* Zero-extend to 64 bit. */ - hi = lj_ir_kint(J, 0); - goto fwdlo; - } - break; - } - case IR_CALLXS: - goto split_call; - case IR_PHI: { - IRRef hiref2; - if ((irref_isk(nir->op1) && irref_isk(nir->op2)) || - nir->op1 == nir->op2) - J->cur.nins--; /* Drop useless PHIs. */ - hiref2 = hisubst[ir->op2]; - if (!((irref_isk(hiref) && irref_isk(hiref2)) || hiref == hiref2)) - split_emit(J, IRTI(IR_PHI), hiref, hiref2); - break; - } - case IR_HIOP: - J->cur.nins--; /* Drop joining HIOP. */ - ir->prev = nir->op1; - hi = nir->op2; - break; - default: - lua_assert(ir->o <= IR_NE); /* Comparisons. */ - split_emit(J, IRTGI(IR_HIOP), hiref, hisubst[ir->op2]); - break; - } - } else -#endif -#if LJ_SOFTFP - if (ir->o == IR_SLOAD) { - if ((nir->op2 & IRSLOAD_CONVERT)) { /* Convert from number to int. */ - nir->op2 &= ~IRSLOAD_CONVERT; - if (!(nir->op2 & IRSLOAD_TYPECHECK)) - nir->t.irt = IRT_INT; /* Drop guard. */ - split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nref, nref); - ir->prev = split_num2int(J, nref, nref+1, irt_isguard(ir->t)); - } - } else if (ir->o == IR_TOBIT) { - IRRef tmp, op1 = ir->op1; - J->cur.nins--; -#if LJ_LE - tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), oir[op1].prev, hisubst[op1]); -#else - tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hisubst[op1], oir[op1].prev); -#endif - ir->prev = split_emit(J, IRTI(IR_CALLN), tmp, IRCALL_lj_vm_tobit); - } else if (ir->o == IR_TOSTR) { - if (hisubst[ir->op1]) { - if (irref_isk(ir->op1)) - nir->op1 = ir->op1; - else - split_emit(J, IRT(IR_HIOP, IRT_NIL), hisubst[ir->op1], nref); - } - } else if (ir->o == IR_HREF || ir->o == IR_NEWREF) { - if (irref_isk(ir->op2) && hisubst[ir->op2]) - nir->op2 = ir->op2; - } else -#endif - if (ir->o == IR_CONV) { /* See above, too. */ - IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); -#if LJ_32 && LJ_HASFFI - if (st == IRT_I64 || st == IRT_U64) { /* Conversion from 64 bit int. */ -#if LJ_SOFTFP - if (irt_isfloat(ir->t)) { - split_call_l(J, hisubst, oir, ir, - st == IRT_I64 ? IRCALL_fp64_l2f : IRCALL_fp64_ul2f); - J->cur.nins--; /* Drop unused HIOP. */ - } -#else - if (irt_isfp(ir->t)) { /* 64 bit integer to FP conversion. */ - ir->prev = split_emit(J, IRT(IR_HIOP, irt_type(ir->t)), - hisubst[ir->op1], nref); - } -#endif - else { /* Truncate to lower 32 bits. */ - fwdlo: - ir->prev = nir->op1; /* Forward loword. */ - /* Replace with NOP to avoid messing up the snapshot logic. */ - nir->ot = IRT(IR_NOP, IRT_NIL); - nir->op1 = nir->op2 = 0; - } - } -#endif -#if LJ_SOFTFP && LJ_32 && LJ_HASFFI - else if (irt_isfloat(ir->t)) { - if (st == IRT_NUM) { - split_call_l(J, hisubst, oir, ir, IRCALL_softfp_d2f); - J->cur.nins--; /* Drop unused HIOP. */ - } else { - nir->o = IR_CALLN; - nir->op2 = st == IRT_INT ? IRCALL_softfp_i2f : IRCALL_softfp_ui2f; - } - } else if (st == IRT_FLOAT) { - nir->o = IR_CALLN; - nir->op2 = irt_isint(ir->t) ? IRCALL_softfp_f2i : IRCALL_softfp_f2ui; - } else -#endif -#if LJ_SOFTFP - if (st == IRT_NUM || (LJ_32 && LJ_HASFFI && st == IRT_FLOAT)) { - if (irt_isguard(ir->t)) { - lua_assert(st == IRT_NUM && irt_isint(ir->t)); - J->cur.nins--; - ir->prev = split_num2int(J, nir->op1, hisubst[ir->op1], 1); - } else { - split_call_l(J, hisubst, oir, ir, -#if LJ_32 && LJ_HASFFI - st == IRT_NUM ? - (irt_isint(ir->t) ? IRCALL_softfp_d2i : IRCALL_softfp_d2ui) : - (irt_isint(ir->t) ? IRCALL_softfp_f2i : IRCALL_softfp_f2ui) -#else - IRCALL_softfp_d2i -#endif - ); - J->cur.nins--; /* Drop unused HIOP. */ - } - } -#endif - } else if (ir->o == IR_CALLXS) { - IRRef hiref; - split_call: - hiref = hisubst[ir->op1]; - if (hiref) { - IROpT ot = nir->ot; - IRRef op2 = nir->op2; - nir->ot = IRT(IR_CARG, IRT_NIL); -#if LJ_LE - nir->op2 = hiref; -#else - nir->op2 = nir->op1; nir->op1 = hiref; -#endif - ir->prev = nref = split_emit(J, ot, nref, op2); - } - if (LJ_SOFTFP ? irt_is64(ir->t) : irt_isint64(ir->t)) - hi = split_emit(J, - IRT(IR_HIOP, (LJ_SOFTFP && irt_isnum(ir->t)) ? IRT_SOFTFP : IRT_INT), - nref, nref); - } else if (ir->o == IR_CARG) { - IRRef hiref = hisubst[ir->op1]; - if (hiref) { - IRRef op2 = nir->op2; -#if LJ_LE - nir->op2 = hiref; -#else - nir->op2 = nir->op1; nir->op1 = hiref; -#endif - ir->prev = nref = split_emit(J, IRT(IR_CARG, IRT_NIL), nref, op2); - nir = IR(nref); - } - hiref = hisubst[ir->op2]; - if (hiref) { -#if !LJ_TARGET_X86 - int carg = 0; - IRIns *cir; - for (cir = IR(nir->op1); cir->o == IR_CARG; cir = IR(cir->op1)) - carg++; - if ((carg & 1) == 0) { /* Align 64 bit arguments. */ - IRRef op2 = nir->op2; - nir->op2 = REF_NIL; - nref = split_emit(J, IRT(IR_CARG, IRT_NIL), nref, op2); - nir = IR(nref); - } -#endif -#if LJ_BE - { IRRef tmp = nir->op2; nir->op2 = hiref; hiref = tmp; } -#endif - ir->prev = split_emit(J, IRT(IR_CARG, IRT_NIL), nref, hiref); - } - } else if (ir->o == IR_CNEWI) { - if (hisubst[ir->op2]) - split_emit(J, IRT(IR_HIOP, IRT_NIL), nref, hisubst[ir->op2]); - } else if (ir->o == IR_LOOP) { - J->loopref = nref; /* Needed by assembler. */ - } - hisubst[ref] = hi; /* Store hiword substitution. */ - } - if (snref == nins) { /* Substitution for last snapshot. */ - snap->ref = J->cur.nins; - split_subst_snap(J, snap, oir); - } - - /* Add PHI marks. */ - for (ref = J->cur.nins-1; ref >= REF_FIRST; ref--) { - IRIns *ir = IR(ref); - if (ir->o != IR_PHI) break; - if (!irref_isk(ir->op1)) irt_setphi(IR(ir->op1)->t); - if (ir->op2 > J->loopref) irt_setphi(IR(ir->op2)->t); - } -} - -/* Protected callback for split pass. */ -static TValue *cpsplit(lua_State *L, lua_CFunction dummy, void *ud) -{ - jit_State *J = (jit_State *)ud; - split_ir(J); - UNUSED(L); UNUSED(dummy); - return NULL; -} - -#if defined(LUA_USE_ASSERT) || LJ_SOFTFP -/* Slow, but sure way to check whether a SPLIT pass is needed. */ -static int split_needsplit(jit_State *J) -{ - IRIns *ir, *irend; - IRRef ref; - for (ir = IR(REF_FIRST), irend = IR(J->cur.nins); ir < irend; ir++) - if (LJ_SOFTFP ? irt_is64orfp(ir->t) : irt_isint64(ir->t)) - return 1; - if (LJ_SOFTFP) { - for (ref = J->chain[IR_SLOAD]; ref; ref = IR(ref)->prev) - if ((IR(ref)->op2 & IRSLOAD_CONVERT)) - return 1; - if (J->chain[IR_TOBIT]) - return 1; - } - for (ref = J->chain[IR_CONV]; ref; ref = IR(ref)->prev) { - IRType st = (IR(ref)->op2 & IRCONV_SRCMASK); - if ((LJ_SOFTFP && (st == IRT_NUM || st == IRT_FLOAT)) || - st == IRT_I64 || st == IRT_U64) - return 1; - } - return 0; /* Nope. */ -} -#endif - -/* SPLIT pass. */ -void lj_opt_split(jit_State *J) -{ -#if LJ_SOFTFP - if (!J->needsplit) - J->needsplit = split_needsplit(J); -#else - lua_assert(J->needsplit >= split_needsplit(J)); /* Verify flag. */ -#endif - if (J->needsplit) { - int errcode = lj_vm_cpcall(J->L, NULL, J, cpsplit); - if (errcode) { - /* Completely reset the trace to avoid inconsistent dump on abort. */ - J->cur.nins = J->cur.nk = REF_BASE; - J->cur.nsnap = 0; - lj_err_throw(J->L, errcode); /* Propagate errors. */ - } - } -} - -#undef IR - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_parse.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_parse.c deleted file mode 100644 index e8aafba20..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_parse.c +++ /dev/null @@ -1,2752 +0,0 @@ -/* -** Lua parser (source code -> bytecode). -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Major portions taken verbatim or adapted from the Lua interpreter. -** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h -*/ - -#define lj_parse_c -#define LUA_CORE - -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_debug.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_func.h" -#include "lj_state.h" -#include "lj_bc.h" -#if LJ_HASFFI -#include "lj_ctype.h" -#endif -#include "lj_lex.h" -#include "lj_parse.h" -#include "lj_vm.h" -#include "lj_vmevent.h" - -/* -- Parser structures and definitions ----------------------------------- */ - -/* Expression kinds. */ -typedef enum { - /* Constant expressions must be first and in this order: */ - VKNIL, - VKFALSE, - VKTRUE, - VKSTR, /* sval = string value */ - VKNUM, /* nval = number value */ - VKLAST = VKNUM, - VKCDATA, /* nval = cdata value, not treated as a constant expression */ - /* Non-constant expressions follow: */ - VLOCAL, /* info = local register, aux = vstack index */ - VUPVAL, /* info = upvalue index, aux = vstack index */ - VGLOBAL, /* sval = string value */ - VINDEXED, /* info = table register, aux = index reg/byte/string const */ - VJMP, /* info = instruction PC */ - VRELOCABLE, /* info = instruction PC */ - VNONRELOC, /* info = result register */ - VCALL, /* info = instruction PC, aux = base */ - VVOID -} ExpKind; - -/* Expression descriptor. */ -typedef struct ExpDesc { - union { - struct { - uint32_t info; /* Primary info. */ - uint32_t aux; /* Secondary info. */ - } s; - TValue nval; /* Number value. */ - GCstr *sval; /* String value. */ - } u; - ExpKind k; - BCPos t; /* True condition jump list. */ - BCPos f; /* False condition jump list. */ -} ExpDesc; - -/* Macros for expressions. */ -#define expr_hasjump(e) ((e)->t != (e)->f) - -#define expr_isk(e) ((e)->k <= VKLAST) -#define expr_isk_nojump(e) (expr_isk(e) && !expr_hasjump(e)) -#define expr_isnumk(e) ((e)->k == VKNUM) -#define expr_isnumk_nojump(e) (expr_isnumk(e) && !expr_hasjump(e)) -#define expr_isstrk(e) ((e)->k == VKSTR) - -#define expr_numtv(e) check_exp(expr_isnumk((e)), &(e)->u.nval) -#define expr_numberV(e) numberVnum(expr_numtv((e))) - -/* Initialize expression. */ -static LJ_AINLINE void expr_init(ExpDesc *e, ExpKind k, uint32_t info) -{ - e->k = k; - e->u.s.info = info; - e->f = e->t = NO_JMP; -} - -/* Check number constant for +-0. */ -static int expr_numiszero(ExpDesc *e) -{ - TValue *o = expr_numtv(e); - return tvisint(o) ? (intV(o) == 0) : tviszero(o); -} - -/* Per-function linked list of scope blocks. */ -typedef struct FuncScope { - struct FuncScope *prev; /* Link to outer scope. */ - MSize vstart; /* Start of block-local variables. */ - uint8_t nactvar; /* Number of active vars outside the scope. */ - uint8_t flags; /* Scope flags. */ -} FuncScope; - -#define FSCOPE_LOOP 0x01 /* Scope is a (breakable) loop. */ -#define FSCOPE_BREAK 0x02 /* Break used in scope. */ -#define FSCOPE_GOLA 0x04 /* Goto or label used in scope. */ -#define FSCOPE_UPVAL 0x08 /* Upvalue in scope. */ -#define FSCOPE_NOCLOSE 0x10 /* Do not close upvalues. */ - -#define NAME_BREAK ((GCstr *)(uintptr_t)1) - -/* Index into variable stack. */ -typedef uint16_t VarIndex; -#define LJ_MAX_VSTACK (65536 - LJ_MAX_UPVAL) - -/* Variable/goto/label info. */ -#define VSTACK_VAR_RW 0x01 /* R/W variable. */ -#define VSTACK_GOTO 0x02 /* Pending goto. */ -#define VSTACK_LABEL 0x04 /* Label. */ - -/* Per-function state. */ -typedef struct FuncState { - GCtab *kt; /* Hash table for constants. */ - LexState *ls; /* Lexer state. */ - lua_State *L; /* Lua state. */ - FuncScope *bl; /* Current scope. */ - struct FuncState *prev; /* Enclosing function. */ - BCPos pc; /* Next bytecode position. */ - BCPos lasttarget; /* Bytecode position of last jump target. */ - BCPos jpc; /* Pending jump list to next bytecode. */ - BCReg freereg; /* First free register. */ - BCReg nactvar; /* Number of active local variables. */ - BCReg nkn, nkgc; /* Number of lua_Number/GCobj constants */ - BCLine linedefined; /* First line of the function definition. */ - BCInsLine *bcbase; /* Base of bytecode stack. */ - BCPos bclim; /* Limit of bytecode stack. */ - MSize vbase; /* Base of variable stack for this function. */ - uint8_t flags; /* Prototype flags. */ - uint8_t numparams; /* Number of parameters. */ - uint8_t framesize; /* Fixed frame size. */ - uint8_t nuv; /* Number of upvalues */ - VarIndex varmap[LJ_MAX_LOCVAR]; /* Map from register to variable idx. */ - VarIndex uvmap[LJ_MAX_UPVAL]; /* Map from upvalue to variable idx. */ - VarIndex uvtmp[LJ_MAX_UPVAL]; /* Temporary upvalue map. */ -} FuncState; - -/* Binary and unary operators. ORDER OPR */ -typedef enum BinOpr { - OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, /* ORDER ARITH */ - OPR_CONCAT, - OPR_NE, OPR_EQ, - OPR_LT, OPR_GE, OPR_LE, OPR_GT, - OPR_AND, OPR_OR, - OPR_NOBINOPR -} BinOpr; - -LJ_STATIC_ASSERT((int)BC_ISGE-(int)BC_ISLT == (int)OPR_GE-(int)OPR_LT); -LJ_STATIC_ASSERT((int)BC_ISLE-(int)BC_ISLT == (int)OPR_LE-(int)OPR_LT); -LJ_STATIC_ASSERT((int)BC_ISGT-(int)BC_ISLT == (int)OPR_GT-(int)OPR_LT); -LJ_STATIC_ASSERT((int)BC_SUBVV-(int)BC_ADDVV == (int)OPR_SUB-(int)OPR_ADD); -LJ_STATIC_ASSERT((int)BC_MULVV-(int)BC_ADDVV == (int)OPR_MUL-(int)OPR_ADD); -LJ_STATIC_ASSERT((int)BC_DIVVV-(int)BC_ADDVV == (int)OPR_DIV-(int)OPR_ADD); -LJ_STATIC_ASSERT((int)BC_MODVV-(int)BC_ADDVV == (int)OPR_MOD-(int)OPR_ADD); - -/* -- Error handling ------------------------------------------------------ */ - -LJ_NORET LJ_NOINLINE static void err_syntax(LexState *ls, ErrMsg em) -{ - lj_lex_error(ls, ls->token, em); -} - -LJ_NORET LJ_NOINLINE static void err_token(LexState *ls, LexToken token) -{ - lj_lex_error(ls, ls->token, LJ_ERR_XTOKEN, lj_lex_token2str(ls, token)); -} - -LJ_NORET static void err_limit(FuncState *fs, uint32_t limit, const char *what) -{ - if (fs->linedefined == 0) - lj_lex_error(fs->ls, 0, LJ_ERR_XLIMM, limit, what); - else - lj_lex_error(fs->ls, 0, LJ_ERR_XLIMF, fs->linedefined, limit, what); -} - -#define checklimit(fs, v, l, m) if ((v) >= (l)) err_limit(fs, l, m) -#define checklimitgt(fs, v, l, m) if ((v) > (l)) err_limit(fs, l, m) -#define checkcond(ls, c, em) { if (!(c)) err_syntax(ls, em); } - -/* -- Management of constants --------------------------------------------- */ - -/* Return bytecode encoding for primitive constant. */ -#define const_pri(e) check_exp((e)->k <= VKTRUE, (e)->k) - -#define tvhaskslot(o) ((o)->u32.hi == 0) -#define tvkslot(o) ((o)->u32.lo) - -/* Add a number constant. */ -static BCReg const_num(FuncState *fs, ExpDesc *e) -{ - lua_State *L = fs->L; - TValue *o; - lua_assert(expr_isnumk(e)); - o = lj_tab_set(L, fs->kt, &e->u.nval); - if (tvhaskslot(o)) - return tvkslot(o); - o->u64 = fs->nkn; - return fs->nkn++; -} - -/* Add a GC object constant. */ -static BCReg const_gc(FuncState *fs, GCobj *gc, uint32_t itype) -{ - lua_State *L = fs->L; - TValue key, *o; - setgcV(L, &key, gc, itype); - /* NOBARRIER: the key is new or kept alive. */ - o = lj_tab_set(L, fs->kt, &key); - if (tvhaskslot(o)) - return tvkslot(o); - o->u64 = fs->nkgc; - return fs->nkgc++; -} - -/* Add a string constant. */ -static BCReg const_str(FuncState *fs, ExpDesc *e) -{ - lua_assert(expr_isstrk(e) || e->k == VGLOBAL); - return const_gc(fs, obj2gco(e->u.sval), LJ_TSTR); -} - -/* Anchor string constant to avoid GC. */ -GCstr *lj_parse_keepstr(LexState *ls, const char *str, size_t len) -{ - /* NOBARRIER: the key is new or kept alive. */ - lua_State *L = ls->L; - GCstr *s = lj_str_new(L, str, len); - TValue *tv = lj_tab_setstr(L, ls->fs->kt, s); - if (tvisnil(tv)) setboolV(tv, 1); - lj_gc_check(L); - return s; -} - -#if LJ_HASFFI -/* Anchor cdata to avoid GC. */ -void lj_parse_keepcdata(LexState *ls, TValue *tv, GCcdata *cd) -{ - /* NOBARRIER: the key is new or kept alive. */ - lua_State *L = ls->L; - setcdataV(L, tv, cd); - setboolV(lj_tab_set(L, ls->fs->kt, tv), 1); -} -#endif - -/* -- Jump list handling -------------------------------------------------- */ - -/* Get next element in jump list. */ -static BCPos jmp_next(FuncState *fs, BCPos pc) -{ - ptrdiff_t delta = bc_j(fs->bcbase[pc].ins); - if ((BCPos)delta == NO_JMP) - return NO_JMP; - else - return (BCPos)(((ptrdiff_t)pc+1)+delta); -} - -/* Check if any of the instructions on the jump list produce no value. */ -static int jmp_novalue(FuncState *fs, BCPos list) -{ - for (; list != NO_JMP; list = jmp_next(fs, list)) { - BCIns p = fs->bcbase[list >= 1 ? list-1 : list].ins; - if (!(bc_op(p) == BC_ISTC || bc_op(p) == BC_ISFC || bc_a(p) == NO_REG)) - return 1; - } - return 0; -} - -/* Patch register of test instructions. */ -static int jmp_patchtestreg(FuncState *fs, BCPos pc, BCReg reg) -{ - BCInsLine *ilp = &fs->bcbase[pc >= 1 ? pc-1 : pc]; - BCOp op = bc_op(ilp->ins); - if (op == BC_ISTC || op == BC_ISFC) { - if (reg != NO_REG && reg != bc_d(ilp->ins)) { - setbc_a(&ilp->ins, reg); - } else { /* Nothing to store or already in the right register. */ - setbc_op(&ilp->ins, op+(BC_IST-BC_ISTC)); - setbc_a(&ilp->ins, 0); - } - } else if (bc_a(ilp->ins) == NO_REG) { - if (reg == NO_REG) { - ilp->ins = BCINS_AJ(BC_JMP, bc_a(fs->bcbase[pc].ins), 0); - } else { - setbc_a(&ilp->ins, reg); - if (reg >= bc_a(ilp[1].ins)) - setbc_a(&ilp[1].ins, reg+1); - } - } else { - return 0; /* Cannot patch other instructions. */ - } - return 1; -} - -/* Drop values for all instructions on jump list. */ -static void jmp_dropval(FuncState *fs, BCPos list) -{ - for (; list != NO_JMP; list = jmp_next(fs, list)) - jmp_patchtestreg(fs, list, NO_REG); -} - -/* Patch jump instruction to target. */ -static void jmp_patchins(FuncState *fs, BCPos pc, BCPos dest) -{ - BCIns *jmp = &fs->bcbase[pc].ins; - BCPos offset = dest-(pc+1)+BCBIAS_J; - lua_assert(dest != NO_JMP); - if (offset > BCMAX_D) - err_syntax(fs->ls, LJ_ERR_XJUMP); - setbc_d(jmp, offset); -} - -/* Append to jump list. */ -static void jmp_append(FuncState *fs, BCPos *l1, BCPos l2) -{ - if (l2 == NO_JMP) { - return; - } else if (*l1 == NO_JMP) { - *l1 = l2; - } else { - BCPos list = *l1; - BCPos next; - while ((next = jmp_next(fs, list)) != NO_JMP) /* Find last element. */ - list = next; - jmp_patchins(fs, list, l2); - } -} - -/* Patch jump list and preserve produced values. */ -static void jmp_patchval(FuncState *fs, BCPos list, BCPos vtarget, - BCReg reg, BCPos dtarget) -{ - while (list != NO_JMP) { - BCPos next = jmp_next(fs, list); - if (jmp_patchtestreg(fs, list, reg)) - jmp_patchins(fs, list, vtarget); /* Jump to target with value. */ - else - jmp_patchins(fs, list, dtarget); /* Jump to default target. */ - list = next; - } -} - -/* Jump to following instruction. Append to list of pending jumps. */ -static void jmp_tohere(FuncState *fs, BCPos list) -{ - fs->lasttarget = fs->pc; - jmp_append(fs, &fs->jpc, list); -} - -/* Patch jump list to target. */ -static void jmp_patch(FuncState *fs, BCPos list, BCPos target) -{ - if (target == fs->pc) { - jmp_tohere(fs, list); - } else { - lua_assert(target < fs->pc); - jmp_patchval(fs, list, target, NO_REG, target); - } -} - -/* -- Bytecode register allocator ----------------------------------------- */ - -/* Bump frame size. */ -static void bcreg_bump(FuncState *fs, BCReg n) -{ - BCReg sz = fs->freereg + n; - if (sz > fs->framesize) { - if (sz >= LJ_MAX_SLOTS) - err_syntax(fs->ls, LJ_ERR_XSLOTS); - fs->framesize = (uint8_t)sz; - } -} - -/* Reserve registers. */ -static void bcreg_reserve(FuncState *fs, BCReg n) -{ - bcreg_bump(fs, n); - fs->freereg += n; -} - -/* Free register. */ -static void bcreg_free(FuncState *fs, BCReg reg) -{ - if (reg >= fs->nactvar) { - fs->freereg--; - lua_assert(reg == fs->freereg); - } -} - -/* Free register for expression. */ -static void expr_free(FuncState *fs, ExpDesc *e) -{ - if (e->k == VNONRELOC) - bcreg_free(fs, e->u.s.info); -} - -/* -- Bytecode emitter ---------------------------------------------------- */ - -/* Emit bytecode instruction. */ -static BCPos bcemit_INS(FuncState *fs, BCIns ins) -{ - BCPos pc = fs->pc; - LexState *ls = fs->ls; - jmp_patchval(fs, fs->jpc, pc, NO_REG, pc); - fs->jpc = NO_JMP; - if (LJ_UNLIKELY(pc >= fs->bclim)) { - ptrdiff_t base = fs->bcbase - ls->bcstack; - checklimit(fs, ls->sizebcstack, LJ_MAX_BCINS, "bytecode instructions"); - lj_mem_growvec(fs->L, ls->bcstack, ls->sizebcstack, LJ_MAX_BCINS,BCInsLine); - fs->bclim = (BCPos)(ls->sizebcstack - base); - fs->bcbase = ls->bcstack + base; - } - fs->bcbase[pc].ins = ins; - fs->bcbase[pc].line = ls->lastline; - fs->pc = pc+1; - return pc; -} - -#define bcemit_ABC(fs, o, a, b, c) bcemit_INS(fs, BCINS_ABC(o, a, b, c)) -#define bcemit_AD(fs, o, a, d) bcemit_INS(fs, BCINS_AD(o, a, d)) -#define bcemit_AJ(fs, o, a, j) bcemit_INS(fs, BCINS_AJ(o, a, j)) - -#define bcptr(fs, e) (&(fs)->bcbase[(e)->u.s.info].ins) - -/* -- Bytecode emitter for expressions ------------------------------------ */ - -/* Discharge non-constant expression to any register. */ -static void expr_discharge(FuncState *fs, ExpDesc *e) -{ - BCIns ins; - if (e->k == VUPVAL) { - ins = BCINS_AD(BC_UGET, 0, e->u.s.info); - } else if (e->k == VGLOBAL) { - ins = BCINS_AD(BC_GGET, 0, const_str(fs, e)); - } else if (e->k == VINDEXED) { - BCReg rc = e->u.s.aux; - if ((int32_t)rc < 0) { - ins = BCINS_ABC(BC_TGETS, 0, e->u.s.info, ~rc); - } else if (rc > BCMAX_C) { - ins = BCINS_ABC(BC_TGETB, 0, e->u.s.info, rc-(BCMAX_C+1)); - } else { - bcreg_free(fs, rc); - ins = BCINS_ABC(BC_TGETV, 0, e->u.s.info, rc); - } - bcreg_free(fs, e->u.s.info); - } else if (e->k == VCALL) { - e->u.s.info = e->u.s.aux; - e->k = VNONRELOC; - return; - } else if (e->k == VLOCAL) { - e->k = VNONRELOC; - return; - } else { - return; - } - e->u.s.info = bcemit_INS(fs, ins); - e->k = VRELOCABLE; -} - -/* Emit bytecode to set a range of registers to nil. */ -static void bcemit_nil(FuncState *fs, BCReg from, BCReg n) -{ - if (fs->pc > fs->lasttarget) { /* No jumps to current position? */ - BCIns *ip = &fs->bcbase[fs->pc-1].ins; - BCReg pto, pfrom = bc_a(*ip); - switch (bc_op(*ip)) { /* Try to merge with the previous instruction. */ - case BC_KPRI: - if (bc_d(*ip) != ~LJ_TNIL) break; - if (from == pfrom) { - if (n == 1) return; - } else if (from == pfrom+1) { - from = pfrom; - n++; - } else { - break; - } - *ip = BCINS_AD(BC_KNIL, from, from+n-1); /* Replace KPRI. */ - return; - case BC_KNIL: - pto = bc_d(*ip); - if (pfrom <= from && from <= pto+1) { /* Can we connect both ranges? */ - if (from+n-1 > pto) - setbc_d(ip, from+n-1); /* Patch previous instruction range. */ - return; - } - break; - default: - break; - } - } - /* Emit new instruction or replace old instruction. */ - bcemit_INS(fs, n == 1 ? BCINS_AD(BC_KPRI, from, VKNIL) : - BCINS_AD(BC_KNIL, from, from+n-1)); -} - -/* Discharge an expression to a specific register. Ignore branches. */ -static void expr_toreg_nobranch(FuncState *fs, ExpDesc *e, BCReg reg) -{ - BCIns ins; - expr_discharge(fs, e); - if (e->k == VKSTR) { - ins = BCINS_AD(BC_KSTR, reg, const_str(fs, e)); - } else if (e->k == VKNUM) { -#if LJ_DUALNUM - cTValue *tv = expr_numtv(e); - if (tvisint(tv) && checki16(intV(tv))) - ins = BCINS_AD(BC_KSHORT, reg, (BCReg)(uint16_t)intV(tv)); - else -#else - lua_Number n = expr_numberV(e); - int32_t k = lj_num2int(n); - if (checki16(k) && n == (lua_Number)k) - ins = BCINS_AD(BC_KSHORT, reg, (BCReg)(uint16_t)k); - else -#endif - ins = BCINS_AD(BC_KNUM, reg, const_num(fs, e)); -#if LJ_HASFFI - } else if (e->k == VKCDATA) { - fs->flags |= PROTO_FFI; - ins = BCINS_AD(BC_KCDATA, reg, - const_gc(fs, obj2gco(cdataV(&e->u.nval)), LJ_TCDATA)); -#endif - } else if (e->k == VRELOCABLE) { - setbc_a(bcptr(fs, e), reg); - goto noins; - } else if (e->k == VNONRELOC) { - if (reg == e->u.s.info) - goto noins; - ins = BCINS_AD(BC_MOV, reg, e->u.s.info); - } else if (e->k == VKNIL) { - bcemit_nil(fs, reg, 1); - goto noins; - } else if (e->k <= VKTRUE) { - ins = BCINS_AD(BC_KPRI, reg, const_pri(e)); - } else { - lua_assert(e->k == VVOID || e->k == VJMP); - return; - } - bcemit_INS(fs, ins); -noins: - e->u.s.info = reg; - e->k = VNONRELOC; -} - -/* Forward declaration. */ -static BCPos bcemit_jmp(FuncState *fs); - -/* Discharge an expression to a specific register. */ -static void expr_toreg(FuncState *fs, ExpDesc *e, BCReg reg) -{ - expr_toreg_nobranch(fs, e, reg); - if (e->k == VJMP) - jmp_append(fs, &e->t, e->u.s.info); /* Add it to the true jump list. */ - if (expr_hasjump(e)) { /* Discharge expression with branches. */ - BCPos jend, jfalse = NO_JMP, jtrue = NO_JMP; - if (jmp_novalue(fs, e->t) || jmp_novalue(fs, e->f)) { - BCPos jval = (e->k == VJMP) ? NO_JMP : bcemit_jmp(fs); - jfalse = bcemit_AD(fs, BC_KPRI, reg, VKFALSE); - bcemit_AJ(fs, BC_JMP, fs->freereg, 1); - jtrue = bcemit_AD(fs, BC_KPRI, reg, VKTRUE); - jmp_tohere(fs, jval); - } - jend = fs->pc; - fs->lasttarget = jend; - jmp_patchval(fs, e->f, jend, reg, jfalse); - jmp_patchval(fs, e->t, jend, reg, jtrue); - } - e->f = e->t = NO_JMP; - e->u.s.info = reg; - e->k = VNONRELOC; -} - -/* Discharge an expression to the next free register. */ -static void expr_tonextreg(FuncState *fs, ExpDesc *e) -{ - expr_discharge(fs, e); - expr_free(fs, e); - bcreg_reserve(fs, 1); - expr_toreg(fs, e, fs->freereg - 1); -} - -/* Discharge an expression to any register. */ -static BCReg expr_toanyreg(FuncState *fs, ExpDesc *e) -{ - expr_discharge(fs, e); - if (e->k == VNONRELOC) { - if (!expr_hasjump(e)) return e->u.s.info; /* Already in a register. */ - if (e->u.s.info >= fs->nactvar) { - expr_toreg(fs, e, e->u.s.info); /* Discharge to temp. register. */ - return e->u.s.info; - } - } - expr_tonextreg(fs, e); /* Discharge to next register. */ - return e->u.s.info; -} - -/* Partially discharge expression to a value. */ -static void expr_toval(FuncState *fs, ExpDesc *e) -{ - if (expr_hasjump(e)) - expr_toanyreg(fs, e); - else - expr_discharge(fs, e); -} - -/* Emit store for LHS expression. */ -static void bcemit_store(FuncState *fs, ExpDesc *var, ExpDesc *e) -{ - BCIns ins; - if (var->k == VLOCAL) { - fs->ls->vstack[var->u.s.aux].info |= VSTACK_VAR_RW; - expr_free(fs, e); - expr_toreg(fs, e, var->u.s.info); - return; - } else if (var->k == VUPVAL) { - fs->ls->vstack[var->u.s.aux].info |= VSTACK_VAR_RW; - expr_toval(fs, e); - if (e->k <= VKTRUE) - ins = BCINS_AD(BC_USETP, var->u.s.info, const_pri(e)); - else if (e->k == VKSTR) - ins = BCINS_AD(BC_USETS, var->u.s.info, const_str(fs, e)); - else if (e->k == VKNUM) - ins = BCINS_AD(BC_USETN, var->u.s.info, const_num(fs, e)); - else - ins = BCINS_AD(BC_USETV, var->u.s.info, expr_toanyreg(fs, e)); - } else if (var->k == VGLOBAL) { - BCReg ra = expr_toanyreg(fs, e); - ins = BCINS_AD(BC_GSET, ra, const_str(fs, var)); - } else { - BCReg ra, rc; - lua_assert(var->k == VINDEXED); - ra = expr_toanyreg(fs, e); - rc = var->u.s.aux; - if ((int32_t)rc < 0) { - ins = BCINS_ABC(BC_TSETS, ra, var->u.s.info, ~rc); - } else if (rc > BCMAX_C) { - ins = BCINS_ABC(BC_TSETB, ra, var->u.s.info, rc-(BCMAX_C+1)); - } else { - /* Free late alloced key reg to avoid assert on free of value reg. */ - /* This can only happen when called from expr_table(). */ - lua_assert(e->k != VNONRELOC || ra < fs->nactvar || - rc < ra || (bcreg_free(fs, rc),1)); - ins = BCINS_ABC(BC_TSETV, ra, var->u.s.info, rc); - } - } - bcemit_INS(fs, ins); - expr_free(fs, e); -} - -/* Emit method lookup expression. */ -static void bcemit_method(FuncState *fs, ExpDesc *e, ExpDesc *key) -{ - BCReg idx, func, obj = expr_toanyreg(fs, e); - expr_free(fs, e); - func = fs->freereg; - bcemit_AD(fs, BC_MOV, func+1, obj); /* Copy object to first argument. */ - lua_assert(expr_isstrk(key)); - idx = const_str(fs, key); - if (idx <= BCMAX_C) { - bcreg_reserve(fs, 2); - bcemit_ABC(fs, BC_TGETS, func, obj, idx); - } else { - bcreg_reserve(fs, 3); - bcemit_AD(fs, BC_KSTR, func+2, idx); - bcemit_ABC(fs, BC_TGETV, func, obj, func+2); - fs->freereg--; - } - e->u.s.info = func; - e->k = VNONRELOC; -} - -/* -- Bytecode emitter for branches --------------------------------------- */ - -/* Emit unconditional branch. */ -static BCPos bcemit_jmp(FuncState *fs) -{ - BCPos jpc = fs->jpc; - BCPos j = fs->pc - 1; - BCIns *ip = &fs->bcbase[j].ins; - fs->jpc = NO_JMP; - if ((int32_t)j >= (int32_t)fs->lasttarget && bc_op(*ip) == BC_UCLO) - setbc_j(ip, NO_JMP); - else - j = bcemit_AJ(fs, BC_JMP, fs->freereg, NO_JMP); - jmp_append(fs, &j, jpc); - return j; -} - -/* Invert branch condition of bytecode instruction. */ -static void invertcond(FuncState *fs, ExpDesc *e) -{ - BCIns *ip = &fs->bcbase[e->u.s.info - 1].ins; - setbc_op(ip, bc_op(*ip)^1); -} - -/* Emit conditional branch. */ -static BCPos bcemit_branch(FuncState *fs, ExpDesc *e, int cond) -{ - BCPos pc; - if (e->k == VRELOCABLE) { - BCIns *ip = bcptr(fs, e); - if (bc_op(*ip) == BC_NOT) { - *ip = BCINS_AD(cond ? BC_ISF : BC_IST, 0, bc_d(*ip)); - return bcemit_jmp(fs); - } - } - if (e->k != VNONRELOC) { - bcreg_reserve(fs, 1); - expr_toreg_nobranch(fs, e, fs->freereg-1); - } - bcemit_AD(fs, cond ? BC_ISTC : BC_ISFC, NO_REG, e->u.s.info); - pc = bcemit_jmp(fs); - expr_free(fs, e); - return pc; -} - -/* Emit branch on true condition. */ -static void bcemit_branch_t(FuncState *fs, ExpDesc *e) -{ - BCPos pc; - expr_discharge(fs, e); - if (e->k == VKSTR || e->k == VKNUM || e->k == VKTRUE) - pc = NO_JMP; /* Never jump. */ - else if (e->k == VJMP) - invertcond(fs, e), pc = e->u.s.info; - else if (e->k == VKFALSE || e->k == VKNIL) - expr_toreg_nobranch(fs, e, NO_REG), pc = bcemit_jmp(fs); - else - pc = bcemit_branch(fs, e, 0); - jmp_append(fs, &e->f, pc); - jmp_tohere(fs, e->t); - e->t = NO_JMP; -} - -/* Emit branch on false condition. */ -static void bcemit_branch_f(FuncState *fs, ExpDesc *e) -{ - BCPos pc; - expr_discharge(fs, e); - if (e->k == VKNIL || e->k == VKFALSE) - pc = NO_JMP; /* Never jump. */ - else if (e->k == VJMP) - pc = e->u.s.info; - else if (e->k == VKSTR || e->k == VKNUM || e->k == VKTRUE) - expr_toreg_nobranch(fs, e, NO_REG), pc = bcemit_jmp(fs); - else - pc = bcemit_branch(fs, e, 1); - jmp_append(fs, &e->t, pc); - jmp_tohere(fs, e->f); - e->f = NO_JMP; -} - -/* -- Bytecode emitter for operators -------------------------------------- */ - -/* Try constant-folding of arithmetic operators. */ -static int foldarith(BinOpr opr, ExpDesc *e1, ExpDesc *e2) -{ - TValue o; - lua_Number n; - if (!expr_isnumk_nojump(e1) || !expr_isnumk_nojump(e2)) return 0; - n = lj_vm_foldarith(expr_numberV(e1), expr_numberV(e2), (int)opr-OPR_ADD); - setnumV(&o, n); - if (tvisnan(&o) || tvismzero(&o)) return 0; /* Avoid NaN and -0 as consts. */ - if (LJ_DUALNUM) { - int32_t k = lj_num2int(n); - if ((lua_Number)k == n) { - setintV(&e1->u.nval, k); - return 1; - } - } - setnumV(&e1->u.nval, n); - return 1; -} - -/* Emit arithmetic operator. */ -static void bcemit_arith(FuncState *fs, BinOpr opr, ExpDesc *e1, ExpDesc *e2) -{ - BCReg rb, rc, t; - uint32_t op; - if (foldarith(opr, e1, e2)) - return; - if (opr == OPR_POW) { - op = BC_POW; - rc = expr_toanyreg(fs, e2); - rb = expr_toanyreg(fs, e1); - } else { - op = opr-OPR_ADD+BC_ADDVV; - /* Must discharge 2nd operand first since VINDEXED might free regs. */ - expr_toval(fs, e2); - if (expr_isnumk(e2) && (rc = const_num(fs, e2)) <= BCMAX_C) - op -= BC_ADDVV-BC_ADDVN; - else - rc = expr_toanyreg(fs, e2); - /* 1st operand discharged by bcemit_binop_left, but need KNUM/KSHORT. */ - lua_assert(expr_isnumk(e1) || e1->k == VNONRELOC); - expr_toval(fs, e1); - /* Avoid two consts to satisfy bytecode constraints. */ - if (expr_isnumk(e1) && !expr_isnumk(e2) && - (t = const_num(fs, e1)) <= BCMAX_B) { - rb = rc; rc = t; op -= BC_ADDVV-BC_ADDNV; - } else { - rb = expr_toanyreg(fs, e1); - } - } - /* Using expr_free might cause asserts if the order is wrong. */ - if (e1->k == VNONRELOC && e1->u.s.info >= fs->nactvar) fs->freereg--; - if (e2->k == VNONRELOC && e2->u.s.info >= fs->nactvar) fs->freereg--; - e1->u.s.info = bcemit_ABC(fs, op, 0, rb, rc); - e1->k = VRELOCABLE; -} - -/* Emit comparison operator. */ -static void bcemit_comp(FuncState *fs, BinOpr opr, ExpDesc *e1, ExpDesc *e2) -{ - ExpDesc *eret = e1; - BCIns ins; - expr_toval(fs, e1); - if (opr == OPR_EQ || opr == OPR_NE) { - BCOp op = opr == OPR_EQ ? BC_ISEQV : BC_ISNEV; - BCReg ra; - if (expr_isk(e1)) { e1 = e2; e2 = eret; } /* Need constant in 2nd arg. */ - ra = expr_toanyreg(fs, e1); /* First arg must be in a reg. */ - expr_toval(fs, e2); - switch (e2->k) { - case VKNIL: case VKFALSE: case VKTRUE: - ins = BCINS_AD(op+(BC_ISEQP-BC_ISEQV), ra, const_pri(e2)); - break; - case VKSTR: - ins = BCINS_AD(op+(BC_ISEQS-BC_ISEQV), ra, const_str(fs, e2)); - break; - case VKNUM: - ins = BCINS_AD(op+(BC_ISEQN-BC_ISEQV), ra, const_num(fs, e2)); - break; - default: - ins = BCINS_AD(op, ra, expr_toanyreg(fs, e2)); - break; - } - } else { - uint32_t op = opr-OPR_LT+BC_ISLT; - BCReg ra, rd; - if ((op-BC_ISLT) & 1) { /* GT -> LT, GE -> LE */ - e1 = e2; e2 = eret; /* Swap operands. */ - op = ((op-BC_ISLT)^3)+BC_ISLT; - expr_toval(fs, e1); - } - rd = expr_toanyreg(fs, e2); - ra = expr_toanyreg(fs, e1); - ins = BCINS_AD(op, ra, rd); - } - /* Using expr_free might cause asserts if the order is wrong. */ - if (e1->k == VNONRELOC && e1->u.s.info >= fs->nactvar) fs->freereg--; - if (e2->k == VNONRELOC && e2->u.s.info >= fs->nactvar) fs->freereg--; - bcemit_INS(fs, ins); - eret->u.s.info = bcemit_jmp(fs); - eret->k = VJMP; -} - -/* Fixup left side of binary operator. */ -static void bcemit_binop_left(FuncState *fs, BinOpr op, ExpDesc *e) -{ - if (op == OPR_AND) { - bcemit_branch_t(fs, e); - } else if (op == OPR_OR) { - bcemit_branch_f(fs, e); - } else if (op == OPR_CONCAT) { - expr_tonextreg(fs, e); - } else if (op == OPR_EQ || op == OPR_NE) { - if (!expr_isk_nojump(e)) expr_toanyreg(fs, e); - } else { - if (!expr_isnumk_nojump(e)) expr_toanyreg(fs, e); - } -} - -/* Emit binary operator. */ -static void bcemit_binop(FuncState *fs, BinOpr op, ExpDesc *e1, ExpDesc *e2) -{ - if (op <= OPR_POW) { - bcemit_arith(fs, op, e1, e2); - } else if (op == OPR_AND) { - lua_assert(e1->t == NO_JMP); /* List must be closed. */ - expr_discharge(fs, e2); - jmp_append(fs, &e2->f, e1->f); - *e1 = *e2; - } else if (op == OPR_OR) { - lua_assert(e1->f == NO_JMP); /* List must be closed. */ - expr_discharge(fs, e2); - jmp_append(fs, &e2->t, e1->t); - *e1 = *e2; - } else if (op == OPR_CONCAT) { - expr_toval(fs, e2); - if (e2->k == VRELOCABLE && bc_op(*bcptr(fs, e2)) == BC_CAT) { - lua_assert(e1->u.s.info == bc_b(*bcptr(fs, e2))-1); - expr_free(fs, e1); - setbc_b(bcptr(fs, e2), e1->u.s.info); - e1->u.s.info = e2->u.s.info; - } else { - expr_tonextreg(fs, e2); - expr_free(fs, e2); - expr_free(fs, e1); - e1->u.s.info = bcemit_ABC(fs, BC_CAT, 0, e1->u.s.info, e2->u.s.info); - } - e1->k = VRELOCABLE; - } else { - lua_assert(op == OPR_NE || op == OPR_EQ || - op == OPR_LT || op == OPR_GE || op == OPR_LE || op == OPR_GT); - bcemit_comp(fs, op, e1, e2); - } -} - -/* Emit unary operator. */ -static void bcemit_unop(FuncState *fs, BCOp op, ExpDesc *e) -{ - if (op == BC_NOT) { - /* Swap true and false lists. */ - { BCPos temp = e->f; e->f = e->t; e->t = temp; } - jmp_dropval(fs, e->f); - jmp_dropval(fs, e->t); - expr_discharge(fs, e); - if (e->k == VKNIL || e->k == VKFALSE) { - e->k = VKTRUE; - return; - } else if (expr_isk(e) || (LJ_HASFFI && e->k == VKCDATA)) { - e->k = VKFALSE; - return; - } else if (e->k == VJMP) { - invertcond(fs, e); - return; - } else if (e->k == VRELOCABLE) { - bcreg_reserve(fs, 1); - setbc_a(bcptr(fs, e), fs->freereg-1); - e->u.s.info = fs->freereg-1; - e->k = VNONRELOC; - } else { - lua_assert(e->k == VNONRELOC); - } - } else { - lua_assert(op == BC_UNM || op == BC_LEN); - if (op == BC_UNM && !expr_hasjump(e)) { /* Constant-fold negations. */ -#if LJ_HASFFI - if (e->k == VKCDATA) { /* Fold in-place since cdata is not interned. */ - GCcdata *cd = cdataV(&e->u.nval); - int64_t *p = (int64_t *)cdataptr(cd); - if (cd->ctypeid == CTID_COMPLEX_DOUBLE) - p[1] ^= (int64_t)U64x(80000000,00000000); - else - *p = -*p; - return; - } else -#endif - if (expr_isnumk(e) && !expr_numiszero(e)) { /* Avoid folding to -0. */ - TValue *o = expr_numtv(e); - if (tvisint(o)) { - int32_t k = intV(o); - if (k == -k) - setnumV(o, -(lua_Number)k); - else - setintV(o, -k); - return; - } else { - o->u64 ^= U64x(80000000,00000000); - return; - } - } - } - expr_toanyreg(fs, e); - } - expr_free(fs, e); - e->u.s.info = bcemit_AD(fs, op, 0, e->u.s.info); - e->k = VRELOCABLE; -} - -/* -- Lexer support ------------------------------------------------------- */ - -/* Check and consume optional token. */ -static int lex_opt(LexState *ls, LexToken tok) -{ - if (ls->token == tok) { - lj_lex_next(ls); - return 1; - } - return 0; -} - -/* Check and consume token. */ -static void lex_check(LexState *ls, LexToken tok) -{ - if (ls->token != tok) - err_token(ls, tok); - lj_lex_next(ls); -} - -/* Check for matching token. */ -static void lex_match(LexState *ls, LexToken what, LexToken who, BCLine line) -{ - if (!lex_opt(ls, what)) { - if (line == ls->linenumber) { - err_token(ls, what); - } else { - const char *swhat = lj_lex_token2str(ls, what); - const char *swho = lj_lex_token2str(ls, who); - lj_lex_error(ls, ls->token, LJ_ERR_XMATCH, swhat, swho, line); - } - } -} - -/* Check for string token. */ -static GCstr *lex_str(LexState *ls) -{ - GCstr *s; - if (ls->token != TK_name && (LJ_52 || ls->token != TK_goto)) - err_token(ls, TK_name); - s = strV(&ls->tokenval); - lj_lex_next(ls); - return s; -} - -/* -- Variable handling --------------------------------------------------- */ - -#define var_get(ls, fs, i) ((ls)->vstack[(fs)->varmap[(i)]]) - -/* Define a new local variable. */ -static void var_new(LexState *ls, BCReg n, GCstr *name) -{ - FuncState *fs = ls->fs; - MSize vtop = ls->vtop; - checklimit(fs, fs->nactvar+n, LJ_MAX_LOCVAR, "local variables"); - if (LJ_UNLIKELY(vtop >= ls->sizevstack)) { - if (ls->sizevstack >= LJ_MAX_VSTACK) - lj_lex_error(ls, 0, LJ_ERR_XLIMC, LJ_MAX_VSTACK); - lj_mem_growvec(ls->L, ls->vstack, ls->sizevstack, LJ_MAX_VSTACK, VarInfo); - } - lua_assert((uintptr_t)name < VARNAME__MAX || - lj_tab_getstr(fs->kt, name) != NULL); - /* NOBARRIER: name is anchored in fs->kt and ls->vstack is not a GCobj. */ - setgcref(ls->vstack[vtop].name, obj2gco(name)); - fs->varmap[fs->nactvar+n] = (uint16_t)vtop; - ls->vtop = vtop+1; -} - -#define var_new_lit(ls, n, v) \ - var_new(ls, (n), lj_parse_keepstr(ls, "" v, sizeof(v)-1)) - -#define var_new_fixed(ls, n, vn) \ - var_new(ls, (n), (GCstr *)(uintptr_t)(vn)) - -/* Add local variables. */ -static void var_add(LexState *ls, BCReg nvars) -{ - FuncState *fs = ls->fs; - BCReg nactvar = fs->nactvar; - while (nvars--) { - VarInfo *v = &var_get(ls, fs, nactvar); - v->startpc = fs->pc; - v->slot = nactvar++; - v->info = 0; - } - fs->nactvar = nactvar; -} - -/* Remove local variables. */ -static void var_remove(LexState *ls, BCReg tolevel) -{ - FuncState *fs = ls->fs; - while (fs->nactvar > tolevel) - var_get(ls, fs, --fs->nactvar).endpc = fs->pc; -} - -/* Lookup local variable name. */ -static BCReg var_lookup_local(FuncState *fs, GCstr *n) -{ - int i; - for (i = fs->nactvar-1; i >= 0; i--) { - if (n == strref(var_get(fs->ls, fs, i).name)) - return (BCReg)i; - } - return (BCReg)-1; /* Not found. */ -} - -/* Lookup or add upvalue index. */ -static MSize var_lookup_uv(FuncState *fs, MSize vidx, ExpDesc *e) -{ - MSize i, n = fs->nuv; - for (i = 0; i < n; i++) - if (fs->uvmap[i] == vidx) - return i; /* Already exists. */ - /* Otherwise create a new one. */ - checklimit(fs, fs->nuv, LJ_MAX_UPVAL, "upvalues"); - lua_assert(e->k == VLOCAL || e->k == VUPVAL); - fs->uvmap[n] = (uint16_t)vidx; - fs->uvtmp[n] = (uint16_t)(e->k == VLOCAL ? vidx : LJ_MAX_VSTACK+e->u.s.info); - fs->nuv = n+1; - return n; -} - -/* Forward declaration. */ -static void fscope_uvmark(FuncState *fs, BCReg level); - -/* Recursively lookup variables in enclosing functions. */ -static MSize var_lookup_(FuncState *fs, GCstr *name, ExpDesc *e, int first) -{ - if (fs) { - BCReg reg = var_lookup_local(fs, name); - if ((int32_t)reg >= 0) { /* Local in this function? */ - expr_init(e, VLOCAL, reg); - if (!first) - fscope_uvmark(fs, reg); /* Scope now has an upvalue. */ - return (MSize)(e->u.s.aux = (uint32_t)fs->varmap[reg]); - } else { - MSize vidx = var_lookup_(fs->prev, name, e, 0); /* Var in outer func? */ - if ((int32_t)vidx >= 0) { /* Yes, make it an upvalue here. */ - e->u.s.info = (uint8_t)var_lookup_uv(fs, vidx, e); - e->k = VUPVAL; - return vidx; - } - } - } else { /* Not found in any function, must be a global. */ - expr_init(e, VGLOBAL, 0); - e->u.sval = name; - } - return (MSize)-1; /* Global. */ -} - -/* Lookup variable name. */ -#define var_lookup(ls, e) \ - var_lookup_((ls)->fs, lex_str(ls), (e), 1) - -/* -- Goto an label handling ---------------------------------------------- */ - -/* Add a new goto or label. */ -static MSize gola_new(LexState *ls, GCstr *name, uint8_t info, BCPos pc) -{ - FuncState *fs = ls->fs; - MSize vtop = ls->vtop; - if (LJ_UNLIKELY(vtop >= ls->sizevstack)) { - if (ls->sizevstack >= LJ_MAX_VSTACK) - lj_lex_error(ls, 0, LJ_ERR_XLIMC, LJ_MAX_VSTACK); - lj_mem_growvec(ls->L, ls->vstack, ls->sizevstack, LJ_MAX_VSTACK, VarInfo); - } - lua_assert(name == NAME_BREAK || lj_tab_getstr(fs->kt, name) != NULL); - /* NOBARRIER: name is anchored in fs->kt and ls->vstack is not a GCobj. */ - setgcref(ls->vstack[vtop].name, obj2gco(name)); - ls->vstack[vtop].startpc = pc; - ls->vstack[vtop].slot = (uint8_t)fs->nactvar; - ls->vstack[vtop].info = info; - ls->vtop = vtop+1; - return vtop; -} - -#define gola_isgoto(v) ((v)->info & VSTACK_GOTO) -#define gola_islabel(v) ((v)->info & VSTACK_LABEL) -#define gola_isgotolabel(v) ((v)->info & (VSTACK_GOTO|VSTACK_LABEL)) - -/* Patch goto to jump to label. */ -static void gola_patch(LexState *ls, VarInfo *vg, VarInfo *vl) -{ - FuncState *fs = ls->fs; - BCPos pc = vg->startpc; - setgcrefnull(vg->name); /* Invalidate pending goto. */ - setbc_a(&fs->bcbase[pc].ins, vl->slot); - jmp_patch(fs, pc, vl->startpc); -} - -/* Patch goto to close upvalues. */ -static void gola_close(LexState *ls, VarInfo *vg) -{ - FuncState *fs = ls->fs; - BCPos pc = vg->startpc; - BCIns *ip = &fs->bcbase[pc].ins; - lua_assert(gola_isgoto(vg)); - lua_assert(bc_op(*ip) == BC_JMP || bc_op(*ip) == BC_UCLO); - setbc_a(ip, vg->slot); - if (bc_op(*ip) == BC_JMP) { - BCPos next = jmp_next(fs, pc); - if (next != NO_JMP) jmp_patch(fs, next, pc); /* Jump to UCLO. */ - setbc_op(ip, BC_UCLO); /* Turn into UCLO. */ - setbc_j(ip, NO_JMP); - } -} - -/* Resolve pending forward gotos for label. */ -static void gola_resolve(LexState *ls, FuncScope *bl, MSize idx) -{ - VarInfo *vg = ls->vstack + bl->vstart; - VarInfo *vl = ls->vstack + idx; - for (; vg < vl; vg++) - if (gcrefeq(vg->name, vl->name) && gola_isgoto(vg)) { - if (vg->slot < vl->slot) { - GCstr *name = strref(var_get(ls, ls->fs, vg->slot).name); - lua_assert((uintptr_t)name >= VARNAME__MAX); - ls->linenumber = ls->fs->bcbase[vg->startpc].line; - lua_assert(strref(vg->name) != NAME_BREAK); - lj_lex_error(ls, 0, LJ_ERR_XGSCOPE, - strdata(strref(vg->name)), strdata(name)); - } - gola_patch(ls, vg, vl); - } -} - -/* Fixup remaining gotos and labels for scope. */ -static void gola_fixup(LexState *ls, FuncScope *bl) -{ - VarInfo *v = ls->vstack + bl->vstart; - VarInfo *ve = ls->vstack + ls->vtop; - for (; v < ve; v++) { - GCstr *name = strref(v->name); - if (name != NULL) { /* Only consider remaining valid gotos/labels. */ - if (gola_islabel(v)) { - VarInfo *vg; - setgcrefnull(v->name); /* Invalidate label that goes out of scope. */ - for (vg = v+1; vg < ve; vg++) /* Resolve pending backward gotos. */ - if (strref(vg->name) == name && gola_isgoto(vg)) { - if ((bl->flags&FSCOPE_UPVAL) && vg->slot > v->slot) - gola_close(ls, vg); - gola_patch(ls, vg, v); - } - } else if (gola_isgoto(v)) { - if (bl->prev) { /* Propagate goto or break to outer scope. */ - bl->prev->flags |= name == NAME_BREAK ? FSCOPE_BREAK : FSCOPE_GOLA; - v->slot = bl->nactvar; - if ((bl->flags & FSCOPE_UPVAL)) - gola_close(ls, v); - } else { /* No outer scope: undefined goto label or no loop. */ - ls->linenumber = ls->fs->bcbase[v->startpc].line; - if (name == NAME_BREAK) - lj_lex_error(ls, 0, LJ_ERR_XBREAK); - else - lj_lex_error(ls, 0, LJ_ERR_XLUNDEF, strdata(name)); - } - } - } - } -} - -/* Find existing label. */ -static VarInfo *gola_findlabel(LexState *ls, GCstr *name) -{ - VarInfo *v = ls->vstack + ls->fs->bl->vstart; - VarInfo *ve = ls->vstack + ls->vtop; - for (; v < ve; v++) - if (strref(v->name) == name && gola_islabel(v)) - return v; - return NULL; -} - -/* -- Scope handling ------------------------------------------------------ */ - -/* Begin a scope. */ -static void fscope_begin(FuncState *fs, FuncScope *bl, int flags) -{ - bl->nactvar = (uint8_t)fs->nactvar; - bl->flags = flags; - bl->vstart = fs->ls->vtop; - bl->prev = fs->bl; - fs->bl = bl; - lua_assert(fs->freereg == fs->nactvar); -} - -/* End a scope. */ -static void fscope_end(FuncState *fs) -{ - FuncScope *bl = fs->bl; - LexState *ls = fs->ls; - fs->bl = bl->prev; - var_remove(ls, bl->nactvar); - fs->freereg = fs->nactvar; - lua_assert(bl->nactvar == fs->nactvar); - if ((bl->flags & (FSCOPE_UPVAL|FSCOPE_NOCLOSE)) == FSCOPE_UPVAL) - bcemit_AJ(fs, BC_UCLO, bl->nactvar, 0); - if ((bl->flags & FSCOPE_BREAK)) { - if ((bl->flags & FSCOPE_LOOP)) { - MSize idx = gola_new(ls, NAME_BREAK, VSTACK_LABEL, fs->pc); - ls->vtop = idx; /* Drop break label immediately. */ - gola_resolve(ls, bl, idx); - return; - } /* else: need the fixup step to propagate the breaks. */ - } else if (!(bl->flags & FSCOPE_GOLA)) { - return; - } - gola_fixup(ls, bl); -} - -/* Mark scope as having an upvalue. */ -static void fscope_uvmark(FuncState *fs, BCReg level) -{ - FuncScope *bl; - for (bl = fs->bl; bl && bl->nactvar > level; bl = bl->prev) - ; - if (bl) - bl->flags |= FSCOPE_UPVAL; -} - -/* -- Function state management ------------------------------------------- */ - -/* Fixup bytecode for prototype. */ -static void fs_fixup_bc(FuncState *fs, GCproto *pt, BCIns *bc, MSize n) -{ - BCInsLine *base = fs->bcbase; - MSize i; - pt->sizebc = n; - bc[0] = BCINS_AD((fs->flags & PROTO_VARARG) ? BC_FUNCV : BC_FUNCF, - fs->framesize, 0); - for (i = 1; i < n; i++) - bc[i] = base[i].ins; -} - -/* Fixup upvalues for child prototype, step #2. */ -static void fs_fixup_uv2(FuncState *fs, GCproto *pt) -{ - VarInfo *vstack = fs->ls->vstack; - uint16_t *uv = proto_uv(pt); - MSize i, n = pt->sizeuv; - for (i = 0; i < n; i++) { - VarIndex vidx = uv[i]; - if (vidx >= LJ_MAX_VSTACK) - uv[i] = vidx - LJ_MAX_VSTACK; - else if ((vstack[vidx].info & VSTACK_VAR_RW)) - uv[i] = vstack[vidx].slot | PROTO_UV_LOCAL; - else - uv[i] = vstack[vidx].slot | PROTO_UV_LOCAL | PROTO_UV_IMMUTABLE; - } -} - -/* Fixup constants for prototype. */ -static void fs_fixup_k(FuncState *fs, GCproto *pt, void *kptr) -{ - GCtab *kt; - TValue *array; - Node *node; - MSize i, hmask; - checklimitgt(fs, fs->nkn, BCMAX_D+1, "constants"); - checklimitgt(fs, fs->nkgc, BCMAX_D+1, "constants"); - setmref(pt->k, kptr); - pt->sizekn = fs->nkn; - pt->sizekgc = fs->nkgc; - kt = fs->kt; - array = tvref(kt->array); - for (i = 0; i < kt->asize; i++) - if (tvhaskslot(&array[i])) { - TValue *tv = &((TValue *)kptr)[tvkslot(&array[i])]; - if (LJ_DUALNUM) - setintV(tv, (int32_t)i); - else - setnumV(tv, (lua_Number)i); - } - node = noderef(kt->node); - hmask = kt->hmask; - for (i = 0; i <= hmask; i++) { - Node *n = &node[i]; - if (tvhaskslot(&n->val)) { - ptrdiff_t kidx = (ptrdiff_t)tvkslot(&n->val); - lua_assert(!tvisint(&n->key)); - if (tvisnum(&n->key)) { - TValue *tv = &((TValue *)kptr)[kidx]; - if (LJ_DUALNUM) { - lua_Number nn = numV(&n->key); - int32_t k = lj_num2int(nn); - lua_assert(!tvismzero(&n->key)); - if ((lua_Number)k == nn) - setintV(tv, k); - else - *tv = n->key; - } else { - *tv = n->key; - } - } else { - GCobj *o = gcV(&n->key); - setgcref(((GCRef *)kptr)[~kidx], o); - lj_gc_objbarrier(fs->L, pt, o); - if (tvisproto(&n->key)) - fs_fixup_uv2(fs, gco2pt(o)); - } - } - } -} - -/* Fixup upvalues for prototype, step #1. */ -static void fs_fixup_uv1(FuncState *fs, GCproto *pt, uint16_t *uv) -{ - setmref(pt->uv, uv); - pt->sizeuv = fs->nuv; - memcpy(uv, fs->uvtmp, fs->nuv*sizeof(VarIndex)); -} - -#ifndef LUAJIT_DISABLE_DEBUGINFO -/* Prepare lineinfo for prototype. */ -static size_t fs_prep_line(FuncState *fs, BCLine numline) -{ - return (fs->pc-1) << (numline < 256 ? 0 : numline < 65536 ? 1 : 2); -} - -/* Fixup lineinfo for prototype. */ -static void fs_fixup_line(FuncState *fs, GCproto *pt, - void *lineinfo, BCLine numline) -{ - BCInsLine *base = fs->bcbase + 1; - BCLine first = fs->linedefined; - MSize i = 0, n = fs->pc-1; - pt->firstline = fs->linedefined; - pt->numline = numline; - setmref(pt->lineinfo, lineinfo); - if (LJ_LIKELY(numline < 256)) { - uint8_t *li = (uint8_t *)lineinfo; - do { - BCLine delta = base[i].line - first; - lua_assert(delta >= 0 && delta < 256); - li[i] = (uint8_t)delta; - } while (++i < n); - } else if (LJ_LIKELY(numline < 65536)) { - uint16_t *li = (uint16_t *)lineinfo; - do { - BCLine delta = base[i].line - first; - lua_assert(delta >= 0 && delta < 65536); - li[i] = (uint16_t)delta; - } while (++i < n); - } else { - uint32_t *li = (uint32_t *)lineinfo; - do { - BCLine delta = base[i].line - first; - lua_assert(delta >= 0); - li[i] = (uint32_t)delta; - } while (++i < n); - } -} - -/* Resize buffer if needed. */ -static LJ_NOINLINE void fs_buf_resize(LexState *ls, MSize len) -{ - MSize sz = ls->sb.sz * 2; - while (ls->sb.n + len > sz) sz = sz * 2; - lj_str_resizebuf(ls->L, &ls->sb, sz); -} - -static LJ_AINLINE void fs_buf_need(LexState *ls, MSize len) -{ - if (LJ_UNLIKELY(ls->sb.n + len > ls->sb.sz)) - fs_buf_resize(ls, len); -} - -/* Add string to buffer. */ -static void fs_buf_str(LexState *ls, const char *str, MSize len) -{ - char *p = ls->sb.buf + ls->sb.n; - MSize i; - ls->sb.n += len; - for (i = 0; i < len; i++) p[i] = str[i]; -} - -/* Add ULEB128 value to buffer. */ -static void fs_buf_uleb128(LexState *ls, uint32_t v) -{ - MSize n = ls->sb.n; - uint8_t *p = (uint8_t *)ls->sb.buf; - for (; v >= 0x80; v >>= 7) - p[n++] = (uint8_t)((v & 0x7f) | 0x80); - p[n++] = (uint8_t)v; - ls->sb.n = n; -} - -/* Prepare variable info for prototype. */ -static size_t fs_prep_var(LexState *ls, FuncState *fs, size_t *ofsvar) -{ - VarInfo *vs =ls->vstack, *ve; - MSize i, n; - BCPos lastpc; - lj_str_resetbuf(&ls->sb); /* Copy to temp. string buffer. */ - /* Store upvalue names. */ - for (i = 0, n = fs->nuv; i < n; i++) { - GCstr *s = strref(vs[fs->uvmap[i]].name); - MSize len = s->len+1; - fs_buf_need(ls, len); - fs_buf_str(ls, strdata(s), len); - } - *ofsvar = ls->sb.n; - lastpc = 0; - /* Store local variable names and compressed ranges. */ - for (ve = vs + ls->vtop, vs += fs->vbase; vs < ve; vs++) { - if (!gola_isgotolabel(vs)) { - GCstr *s = strref(vs->name); - BCPos startpc; - if ((uintptr_t)s < VARNAME__MAX) { - fs_buf_need(ls, 1 + 2*5); - ls->sb.buf[ls->sb.n++] = (uint8_t)(uintptr_t)s; - } else { - MSize len = s->len+1; - fs_buf_need(ls, len + 2*5); - fs_buf_str(ls, strdata(s), len); - } - startpc = vs->startpc; - fs_buf_uleb128(ls, startpc-lastpc); - fs_buf_uleb128(ls, vs->endpc-startpc); - lastpc = startpc; - } - } - fs_buf_need(ls, 1); - ls->sb.buf[ls->sb.n++] = '\0'; /* Terminator for varinfo. */ - return ls->sb.n; -} - -/* Fixup variable info for prototype. */ -static void fs_fixup_var(LexState *ls, GCproto *pt, uint8_t *p, size_t ofsvar) -{ - setmref(pt->uvinfo, p); - setmref(pt->varinfo, (char *)p + ofsvar); - memcpy(p, ls->sb.buf, ls->sb.n); /* Copy from temp. string buffer. */ -} -#else - -/* Initialize with empty debug info, if disabled. */ -#define fs_prep_line(fs, numline) (UNUSED(numline), 0) -#define fs_fixup_line(fs, pt, li, numline) \ - pt->firstline = pt->numline = 0, setmref((pt)->lineinfo, NULL) -#define fs_prep_var(ls, fs, ofsvar) (UNUSED(ofsvar), 0) -#define fs_fixup_var(ls, pt, p, ofsvar) \ - setmref((pt)->uvinfo, NULL), setmref((pt)->varinfo, NULL) - -#endif - -/* Check if bytecode op returns. */ -static int bcopisret(BCOp op) -{ - switch (op) { - case BC_CALLMT: case BC_CALLT: - case BC_RETM: case BC_RET: case BC_RET0: case BC_RET1: - return 1; - default: - return 0; - } -} - -/* Fixup return instruction for prototype. */ -static void fs_fixup_ret(FuncState *fs) -{ - BCPos lastpc = fs->pc; - if (lastpc <= fs->lasttarget || !bcopisret(bc_op(fs->bcbase[lastpc-1].ins))) { - if ((fs->bl->flags & FSCOPE_UPVAL)) - bcemit_AJ(fs, BC_UCLO, 0, 0); - bcemit_AD(fs, BC_RET0, 0, 1); /* Need final return. */ - } - fs->bl->flags |= FSCOPE_NOCLOSE; /* Handled above. */ - fscope_end(fs); - lua_assert(fs->bl == NULL); - /* May need to fixup returns encoded before first function was created. */ - if (fs->flags & PROTO_FIXUP_RETURN) { - BCPos pc; - for (pc = 1; pc < lastpc; pc++) { - BCIns ins = fs->bcbase[pc].ins; - BCPos offset; - switch (bc_op(ins)) { - case BC_CALLMT: case BC_CALLT: - case BC_RETM: case BC_RET: case BC_RET0: case BC_RET1: - offset = bcemit_INS(fs, ins); /* Copy original instruction. */ - fs->bcbase[offset].line = fs->bcbase[pc].line; - offset = offset-(pc+1)+BCBIAS_J; - if (offset > BCMAX_D) - err_syntax(fs->ls, LJ_ERR_XFIXUP); - /* Replace with UCLO plus branch. */ - fs->bcbase[pc].ins = BCINS_AD(BC_UCLO, 0, offset); - break; - case BC_UCLO: - return; /* We're done. */ - default: - break; - } - } - } -} - -/* Finish a FuncState and return the new prototype. */ -static GCproto *fs_finish(LexState *ls, BCLine line) -{ - lua_State *L = ls->L; - FuncState *fs = ls->fs; - BCLine numline = line - fs->linedefined; - size_t sizept, ofsk, ofsuv, ofsli, ofsdbg, ofsvar; - GCproto *pt; - - /* Apply final fixups. */ - fs_fixup_ret(fs); - - /* Calculate total size of prototype including all colocated arrays. */ - sizept = sizeof(GCproto) + fs->pc*sizeof(BCIns) + fs->nkgc*sizeof(GCRef); - sizept = (sizept + sizeof(TValue)-1) & ~(sizeof(TValue)-1); - ofsk = sizept; sizept += fs->nkn*sizeof(TValue); - ofsuv = sizept; sizept += ((fs->nuv+1)&~1)*2; - ofsli = sizept; sizept += fs_prep_line(fs, numline); - ofsdbg = sizept; sizept += fs_prep_var(ls, fs, &ofsvar); - - /* Allocate prototype and initialize its fields. */ - pt = (GCproto *)lj_mem_newgco(L, (MSize)sizept); - pt->gct = ~LJ_TPROTO; - pt->sizept = (MSize)sizept; - pt->trace = 0; - pt->flags = (uint8_t)(fs->flags & ~(PROTO_HAS_RETURN|PROTO_FIXUP_RETURN)); - pt->numparams = fs->numparams; - pt->framesize = fs->framesize; - setgcref(pt->chunkname, obj2gco(ls->chunkname)); - - /* Close potentially uninitialized gap between bc and kgc. */ - *(uint32_t *)((char *)pt + ofsk - sizeof(GCRef)*(fs->nkgc+1)) = 0; - fs_fixup_bc(fs, pt, (BCIns *)((char *)pt + sizeof(GCproto)), fs->pc); - fs_fixup_k(fs, pt, (void *)((char *)pt + ofsk)); - fs_fixup_uv1(fs, pt, (uint16_t *)((char *)pt + ofsuv)); - fs_fixup_line(fs, pt, (void *)((char *)pt + ofsli), numline); - fs_fixup_var(ls, pt, (uint8_t *)((char *)pt + ofsdbg), ofsvar); - - lj_vmevent_send(L, BC, - setprotoV(L, L->top++, pt); - ); - - L->top--; /* Pop table of constants. */ - ls->vtop = fs->vbase; /* Reset variable stack. */ - ls->fs = fs->prev; - lua_assert(ls->fs != NULL || ls->token == TK_eof); - return pt; -} - -/* Initialize a new FuncState. */ -static void fs_init(LexState *ls, FuncState *fs) -{ - lua_State *L = ls->L; - fs->prev = ls->fs; ls->fs = fs; /* Append to list. */ - fs->ls = ls; - fs->vbase = ls->vtop; - fs->L = L; - fs->pc = 0; - fs->lasttarget = 0; - fs->jpc = NO_JMP; - fs->freereg = 0; - fs->nkgc = 0; - fs->nkn = 0; - fs->nactvar = 0; - fs->nuv = 0; - fs->bl = NULL; - fs->flags = 0; - fs->framesize = 1; /* Minimum frame size. */ - fs->kt = lj_tab_new(L, 0, 0); - /* Anchor table of constants in stack to avoid being collected. */ - settabV(L, L->top, fs->kt); - incr_top(L); -} - -/* -- Expressions --------------------------------------------------------- */ - -/* Forward declaration. */ -static void expr(LexState *ls, ExpDesc *v); - -/* Return string expression. */ -static void expr_str(LexState *ls, ExpDesc *e) -{ - expr_init(e, VKSTR, 0); - e->u.sval = lex_str(ls); -} - -/* Return index expression. */ -static void expr_index(FuncState *fs, ExpDesc *t, ExpDesc *e) -{ - /* Already called: expr_toval(fs, e). */ - t->k = VINDEXED; - if (expr_isnumk(e)) { -#if LJ_DUALNUM - if (tvisint(expr_numtv(e))) { - int32_t k = intV(expr_numtv(e)); - if (checku8(k)) { - t->u.s.aux = BCMAX_C+1+(uint32_t)k; /* 256..511: const byte key */ - return; - } - } -#else - lua_Number n = expr_numberV(e); - int32_t k = lj_num2int(n); - if (checku8(k) && n == (lua_Number)k) { - t->u.s.aux = BCMAX_C+1+(uint32_t)k; /* 256..511: const byte key */ - return; - } -#endif - } else if (expr_isstrk(e)) { - BCReg idx = const_str(fs, e); - if (idx <= BCMAX_C) { - t->u.s.aux = ~idx; /* -256..-1: const string key */ - return; - } - } - t->u.s.aux = expr_toanyreg(fs, e); /* 0..255: register */ -} - -/* Parse index expression with named field. */ -static void expr_field(LexState *ls, ExpDesc *v) -{ - FuncState *fs = ls->fs; - ExpDesc key; - expr_toanyreg(fs, v); - lj_lex_next(ls); /* Skip dot or colon. */ - expr_str(ls, &key); - expr_index(fs, v, &key); -} - -/* Parse index expression with brackets. */ -static void expr_bracket(LexState *ls, ExpDesc *v) -{ - lj_lex_next(ls); /* Skip '['. */ - expr(ls, v); - expr_toval(ls->fs, v); - lex_check(ls, ']'); -} - -/* Get value of constant expression. */ -static void expr_kvalue(TValue *v, ExpDesc *e) -{ - if (e->k <= VKTRUE) { - setitype(v, ~(uint32_t)e->k); - } else if (e->k == VKSTR) { - setgcref(v->gcr, obj2gco(e->u.sval)); - setitype(v, LJ_TSTR); - } else { - lua_assert(tvisnumber(expr_numtv(e))); - *v = *expr_numtv(e); - } -} - -/* Parse table constructor expression. */ -static void expr_table(LexState *ls, ExpDesc *e) -{ - FuncState *fs = ls->fs; - BCLine line = ls->linenumber; - GCtab *t = NULL; - int vcall = 0, needarr = 0, fixt = 0; - uint32_t narr = 1; /* First array index. */ - uint32_t nhash = 0; /* Number of hash entries. */ - BCReg freg = fs->freereg; - BCPos pc = bcemit_AD(fs, BC_TNEW, freg, 0); - expr_init(e, VNONRELOC, freg); - bcreg_reserve(fs, 1); - freg++; - lex_check(ls, '{'); - while (ls->token != '}') { - ExpDesc key, val; - vcall = 0; - if (ls->token == '[') { - expr_bracket(ls, &key); /* Already calls expr_toval. */ - if (!expr_isk(&key)) expr_index(fs, e, &key); - if (expr_isnumk(&key) && expr_numiszero(&key)) needarr = 1; else nhash++; - lex_check(ls, '='); - } else if ((ls->token == TK_name || (!LJ_52 && ls->token == TK_goto)) && - lj_lex_lookahead(ls) == '=') { - expr_str(ls, &key); - lex_check(ls, '='); - nhash++; - } else { - expr_init(&key, VKNUM, 0); - setintV(&key.u.nval, (int)narr); - narr++; - needarr = vcall = 1; - } - expr(ls, &val); - if (expr_isk(&key) && key.k != VKNIL && - (key.k == VKSTR || expr_isk_nojump(&val))) { - TValue k, *v; - if (!t) { /* Create template table on demand. */ - BCReg kidx; - t = lj_tab_new(fs->L, needarr ? narr : 0, hsize2hbits(nhash)); - kidx = const_gc(fs, obj2gco(t), LJ_TTAB); - fs->bcbase[pc].ins = BCINS_AD(BC_TDUP, freg-1, kidx); - } - vcall = 0; - expr_kvalue(&k, &key); - v = lj_tab_set(fs->L, t, &k); - lj_gc_anybarriert(fs->L, t); - if (expr_isk_nojump(&val)) { /* Add const key/value to template table. */ - expr_kvalue(v, &val); - } else { /* Otherwise create dummy string key (avoids lj_tab_newkey). */ - settabV(fs->L, v, t); /* Preserve key with table itself as value. */ - fixt = 1; /* Fix this later, after all resizes. */ - goto nonconst; - } - } else { - nonconst: - if (val.k != VCALL) { expr_toanyreg(fs, &val); vcall = 0; } - if (expr_isk(&key)) expr_index(fs, e, &key); - bcemit_store(fs, e, &val); - } - fs->freereg = freg; - if (!lex_opt(ls, ',') && !lex_opt(ls, ';')) break; - } - lex_match(ls, '}', '{', line); - if (vcall) { - BCInsLine *ilp = &fs->bcbase[fs->pc-1]; - ExpDesc en; - lua_assert(bc_a(ilp->ins) == freg && - bc_op(ilp->ins) == (narr > 256 ? BC_TSETV : BC_TSETB)); - expr_init(&en, VKNUM, 0); - en.u.nval.u32.lo = narr-1; - en.u.nval.u32.hi = 0x43300000; /* Biased integer to avoid denormals. */ - if (narr > 256) { fs->pc--; ilp--; } - ilp->ins = BCINS_AD(BC_TSETM, freg, const_num(fs, &en)); - setbc_b(&ilp[-1].ins, 0); - } - if (pc == fs->pc-1) { /* Make expr relocable if possible. */ - e->u.s.info = pc; - fs->freereg--; - e->k = VRELOCABLE; - } else { - e->k = VNONRELOC; /* May have been changed by expr_index. */ - } - if (!t) { /* Construct TNEW RD: hhhhhaaaaaaaaaaa. */ - BCIns *ip = &fs->bcbase[pc].ins; - if (!needarr) narr = 0; - else if (narr < 3) narr = 3; - else if (narr > 0x7ff) narr = 0x7ff; - setbc_d(ip, narr|(hsize2hbits(nhash)<<11)); - } else { - if (needarr && t->asize < narr) - lj_tab_reasize(fs->L, t, narr-1); - if (fixt) { /* Fix value for dummy keys in template table. */ - Node *node = noderef(t->node); - uint32_t i, hmask = t->hmask; - for (i = 0; i <= hmask; i++) { - Node *n = &node[i]; - if (tvistab(&n->val)) { - lua_assert(tabV(&n->val) == t); - setnilV(&n->val); /* Turn value into nil. */ - } - } - } - lj_gc_check(fs->L); - } -} - -/* Parse function parameters. */ -static BCReg parse_params(LexState *ls, int needself) -{ - FuncState *fs = ls->fs; - BCReg nparams = 0; - lex_check(ls, '('); - if (needself) - var_new_lit(ls, nparams++, "self"); - if (ls->token != ')') { - do { - if (ls->token == TK_name || (!LJ_52 && ls->token == TK_goto)) { - var_new(ls, nparams++, lex_str(ls)); - } else if (ls->token == TK_dots) { - lj_lex_next(ls); - fs->flags |= PROTO_VARARG; - break; - } else { - err_syntax(ls, LJ_ERR_XPARAM); - } - } while (lex_opt(ls, ',')); - } - var_add(ls, nparams); - lua_assert(fs->nactvar == nparams); - bcreg_reserve(fs, nparams); - lex_check(ls, ')'); - return nparams; -} - -/* Forward declaration. */ -static void parse_chunk(LexState *ls); - -/* Parse body of a function. */ -static void parse_body(LexState *ls, ExpDesc *e, int needself, BCLine line) -{ - FuncState fs, *pfs = ls->fs; - FuncScope bl; - GCproto *pt; - ptrdiff_t oldbase = pfs->bcbase - ls->bcstack; - fs_init(ls, &fs); - fscope_begin(&fs, &bl, 0); - fs.linedefined = line; - fs.numparams = (uint8_t)parse_params(ls, needself); - fs.bcbase = pfs->bcbase + pfs->pc; - fs.bclim = pfs->bclim - pfs->pc; - bcemit_AD(&fs, BC_FUNCF, 0, 0); /* Placeholder. */ - parse_chunk(ls); - if (ls->token != TK_end) lex_match(ls, TK_end, TK_function, line); - pt = fs_finish(ls, (ls->lastline = ls->linenumber)); - pfs->bcbase = ls->bcstack + oldbase; /* May have been reallocated. */ - pfs->bclim = (BCPos)(ls->sizebcstack - oldbase); - /* Store new prototype in the constant array of the parent. */ - expr_init(e, VRELOCABLE, - bcemit_AD(pfs, BC_FNEW, 0, const_gc(pfs, obj2gco(pt), LJ_TPROTO))); -#if LJ_HASFFI - pfs->flags |= (fs.flags & PROTO_FFI); -#endif - if (!(pfs->flags & PROTO_CHILD)) { - if (pfs->flags & PROTO_HAS_RETURN) - pfs->flags |= PROTO_FIXUP_RETURN; - pfs->flags |= PROTO_CHILD; - } - lj_lex_next(ls); -} - -/* Parse expression list. Last expression is left open. */ -static BCReg expr_list(LexState *ls, ExpDesc *v) -{ - BCReg n = 1; - expr(ls, v); - while (lex_opt(ls, ',')) { - expr_tonextreg(ls->fs, v); - expr(ls, v); - n++; - } - return n; -} - -/* Parse function argument list. */ -static void parse_args(LexState *ls, ExpDesc *e) -{ - FuncState *fs = ls->fs; - ExpDesc args; - BCIns ins; - BCReg base; - BCLine line = ls->linenumber; - if (ls->token == '(') { -#if !LJ_52 - if (line != ls->lastline) - err_syntax(ls, LJ_ERR_XAMBIG); -#endif - lj_lex_next(ls); - if (ls->token == ')') { /* f(). */ - args.k = VVOID; - } else { - expr_list(ls, &args); - if (args.k == VCALL) /* f(a, b, g()) or f(a, b, ...). */ - setbc_b(bcptr(fs, &args), 0); /* Pass on multiple results. */ - } - lex_match(ls, ')', '(', line); - } else if (ls->token == '{') { - expr_table(ls, &args); - } else if (ls->token == TK_string) { - expr_init(&args, VKSTR, 0); - args.u.sval = strV(&ls->tokenval); - lj_lex_next(ls); - } else { - err_syntax(ls, LJ_ERR_XFUNARG); - return; /* Silence compiler. */ - } - lua_assert(e->k == VNONRELOC); - base = e->u.s.info; /* Base register for call. */ - if (args.k == VCALL) { - ins = BCINS_ABC(BC_CALLM, base, 2, args.u.s.aux - base - 1); - } else { - if (args.k != VVOID) - expr_tonextreg(fs, &args); - ins = BCINS_ABC(BC_CALL, base, 2, fs->freereg - base); - } - expr_init(e, VCALL, bcemit_INS(fs, ins)); - e->u.s.aux = base; - fs->bcbase[fs->pc - 1].line = line; - fs->freereg = base+1; /* Leave one result by default. */ -} - -/* Parse primary expression. */ -static void expr_primary(LexState *ls, ExpDesc *v) -{ - FuncState *fs = ls->fs; - /* Parse prefix expression. */ - if (ls->token == '(') { - BCLine line = ls->linenumber; - lj_lex_next(ls); - expr(ls, v); - lex_match(ls, ')', '(', line); - expr_discharge(ls->fs, v); - } else if (ls->token == TK_name || (!LJ_52 && ls->token == TK_goto)) { - var_lookup(ls, v); - } else { - err_syntax(ls, LJ_ERR_XSYMBOL); - } - for (;;) { /* Parse multiple expression suffixes. */ - if (ls->token == '.') { - expr_field(ls, v); - } else if (ls->token == '[') { - ExpDesc key; - expr_toanyreg(fs, v); - expr_bracket(ls, &key); - expr_index(fs, v, &key); - } else if (ls->token == ':') { - ExpDesc key; - lj_lex_next(ls); - expr_str(ls, &key); - bcemit_method(fs, v, &key); - parse_args(ls, v); - } else if (ls->token == '(' || ls->token == TK_string || ls->token == '{') { - expr_tonextreg(fs, v); - parse_args(ls, v); - } else { - break; - } - } -} - -/* Parse simple expression. */ -static void expr_simple(LexState *ls, ExpDesc *v) -{ - switch (ls->token) { - case TK_number: - expr_init(v, (LJ_HASFFI && tviscdata(&ls->tokenval)) ? VKCDATA : VKNUM, 0); - copyTV(ls->L, &v->u.nval, &ls->tokenval); - break; - case TK_string: - expr_init(v, VKSTR, 0); - v->u.sval = strV(&ls->tokenval); - break; - case TK_nil: - expr_init(v, VKNIL, 0); - break; - case TK_true: - expr_init(v, VKTRUE, 0); - break; - case TK_false: - expr_init(v, VKFALSE, 0); - break; - case TK_dots: { /* Vararg. */ - FuncState *fs = ls->fs; - BCReg base; - checkcond(ls, fs->flags & PROTO_VARARG, LJ_ERR_XDOTS); - bcreg_reserve(fs, 1); - base = fs->freereg-1; - expr_init(v, VCALL, bcemit_ABC(fs, BC_VARG, base, 2, fs->numparams)); - v->u.s.aux = base; - break; - } - case '{': /* Table constructor. */ - expr_table(ls, v); - return; - case TK_function: - lj_lex_next(ls); - parse_body(ls, v, 0, ls->linenumber); - return; - default: - expr_primary(ls, v); - return; - } - lj_lex_next(ls); -} - -/* Manage syntactic levels to avoid blowing up the stack. */ -static void synlevel_begin(LexState *ls) -{ - if (++ls->level >= LJ_MAX_XLEVEL) - lj_lex_error(ls, 0, LJ_ERR_XLEVELS); -} - -#define synlevel_end(ls) ((ls)->level--) - -/* Convert token to binary operator. */ -static BinOpr token2binop(LexToken tok) -{ - switch (tok) { - case '+': return OPR_ADD; - case '-': return OPR_SUB; - case '*': return OPR_MUL; - case '/': return OPR_DIV; - case '%': return OPR_MOD; - case '^': return OPR_POW; - case TK_concat: return OPR_CONCAT; - case TK_ne: return OPR_NE; - case TK_eq: return OPR_EQ; - case '<': return OPR_LT; - case TK_le: return OPR_LE; - case '>': return OPR_GT; - case TK_ge: return OPR_GE; - case TK_and: return OPR_AND; - case TK_or: return OPR_OR; - default: return OPR_NOBINOPR; - } -} - -/* Priorities for each binary operator. ORDER OPR. */ -static const struct { - uint8_t left; /* Left priority. */ - uint8_t right; /* Right priority. */ -} priority[] = { - {6,6}, {6,6}, {7,7}, {7,7}, {7,7}, /* ADD SUB MUL DIV MOD */ - {10,9}, {5,4}, /* POW CONCAT (right associative) */ - {3,3}, {3,3}, /* EQ NE */ - {3,3}, {3,3}, {3,3}, {3,3}, /* LT GE GT LE */ - {2,2}, {1,1} /* AND OR */ -}; - -#define UNARY_PRIORITY 8 /* Priority for unary operators. */ - -/* Forward declaration. */ -static BinOpr expr_binop(LexState *ls, ExpDesc *v, uint32_t limit); - -/* Parse unary expression. */ -static void expr_unop(LexState *ls, ExpDesc *v) -{ - BCOp op; - if (ls->token == TK_not) { - op = BC_NOT; - } else if (ls->token == '-') { - op = BC_UNM; - } else if (ls->token == '#') { - op = BC_LEN; - } else { - expr_simple(ls, v); - return; - } - lj_lex_next(ls); - expr_binop(ls, v, UNARY_PRIORITY); - bcemit_unop(ls->fs, op, v); -} - -/* Parse binary expressions with priority higher than the limit. */ -static BinOpr expr_binop(LexState *ls, ExpDesc *v, uint32_t limit) -{ - BinOpr op; - synlevel_begin(ls); - expr_unop(ls, v); - op = token2binop(ls->token); - while (op != OPR_NOBINOPR && priority[op].left > limit) { - ExpDesc v2; - BinOpr nextop; - lj_lex_next(ls); - bcemit_binop_left(ls->fs, op, v); - /* Parse binary expression with higher priority. */ - nextop = expr_binop(ls, &v2, priority[op].right); - bcemit_binop(ls->fs, op, v, &v2); - op = nextop; - } - synlevel_end(ls); - return op; /* Return unconsumed binary operator (if any). */ -} - -/* Parse expression. */ -static void expr(LexState *ls, ExpDesc *v) -{ - expr_binop(ls, v, 0); /* Priority 0: parse whole expression. */ -} - -/* Assign expression to the next register. */ -static void expr_next(LexState *ls) -{ - ExpDesc e; - expr(ls, &e); - expr_tonextreg(ls->fs, &e); -} - -/* Parse conditional expression. */ -static BCPos expr_cond(LexState *ls) -{ - ExpDesc v; - expr(ls, &v); - if (v.k == VKNIL) v.k = VKFALSE; - bcemit_branch_t(ls->fs, &v); - return v.f; -} - -/* -- Assignments --------------------------------------------------------- */ - -/* List of LHS variables. */ -typedef struct LHSVarList { - ExpDesc v; /* LHS variable. */ - struct LHSVarList *prev; /* Link to previous LHS variable. */ -} LHSVarList; - -/* Eliminate write-after-read hazards for local variable assignment. */ -static void assign_hazard(LexState *ls, LHSVarList *lh, const ExpDesc *v) -{ - FuncState *fs = ls->fs; - BCReg reg = v->u.s.info; /* Check against this variable. */ - BCReg tmp = fs->freereg; /* Rename to this temp. register (if needed). */ - int hazard = 0; - for (; lh; lh = lh->prev) { - if (lh->v.k == VINDEXED) { - if (lh->v.u.s.info == reg) { /* t[i], t = 1, 2 */ - hazard = 1; - lh->v.u.s.info = tmp; - } - if (lh->v.u.s.aux == reg) { /* t[i], i = 1, 2 */ - hazard = 1; - lh->v.u.s.aux = tmp; - } - } - } - if (hazard) { - bcemit_AD(fs, BC_MOV, tmp, reg); /* Rename conflicting variable. */ - bcreg_reserve(fs, 1); - } -} - -/* Adjust LHS/RHS of an assignment. */ -static void assign_adjust(LexState *ls, BCReg nvars, BCReg nexps, ExpDesc *e) -{ - FuncState *fs = ls->fs; - int32_t extra = (int32_t)nvars - (int32_t)nexps; - if (e->k == VCALL) { - extra++; /* Compensate for the VCALL itself. */ - if (extra < 0) extra = 0; - setbc_b(bcptr(fs, e), extra+1); /* Fixup call results. */ - if (extra > 1) bcreg_reserve(fs, (BCReg)extra-1); - } else { - if (e->k != VVOID) - expr_tonextreg(fs, e); /* Close last expression. */ - if (extra > 0) { /* Leftover LHS are set to nil. */ - BCReg reg = fs->freereg; - bcreg_reserve(fs, (BCReg)extra); - bcemit_nil(fs, reg, (BCReg)extra); - } - } -} - -/* Recursively parse assignment statement. */ -static void parse_assignment(LexState *ls, LHSVarList *lh, BCReg nvars) -{ - ExpDesc e; - checkcond(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED, LJ_ERR_XSYNTAX); - if (lex_opt(ls, ',')) { /* Collect LHS list and recurse upwards. */ - LHSVarList vl; - vl.prev = lh; - expr_primary(ls, &vl.v); - if (vl.v.k == VLOCAL) - assign_hazard(ls, lh, &vl.v); - checklimit(ls->fs, ls->level + nvars, LJ_MAX_XLEVEL, "variable names"); - parse_assignment(ls, &vl, nvars+1); - } else { /* Parse RHS. */ - BCReg nexps; - lex_check(ls, '='); - nexps = expr_list(ls, &e); - if (nexps == nvars) { - if (e.k == VCALL) { - if (bc_op(*bcptr(ls->fs, &e)) == BC_VARG) { /* Vararg assignment. */ - ls->fs->freereg--; - e.k = VRELOCABLE; - } else { /* Multiple call results. */ - e.u.s.info = e.u.s.aux; /* Base of call is not relocatable. */ - e.k = VNONRELOC; - } - } - bcemit_store(ls->fs, &lh->v, &e); - return; - } - assign_adjust(ls, nvars, nexps, &e); - if (nexps > nvars) - ls->fs->freereg -= nexps - nvars; /* Drop leftover regs. */ - } - /* Assign RHS to LHS and recurse downwards. */ - expr_init(&e, VNONRELOC, ls->fs->freereg-1); - bcemit_store(ls->fs, &lh->v, &e); -} - -/* Parse call statement or assignment. */ -static void parse_call_assign(LexState *ls) -{ - FuncState *fs = ls->fs; - LHSVarList vl; - expr_primary(ls, &vl.v); - if (vl.v.k == VCALL) { /* Function call statement. */ - setbc_b(bcptr(fs, &vl.v), 1); /* No results. */ - } else { /* Start of an assignment. */ - vl.prev = NULL; - parse_assignment(ls, &vl, 1); - } -} - -/* Parse 'local' statement. */ -static void parse_local(LexState *ls) -{ - if (lex_opt(ls, TK_function)) { /* Local function declaration. */ - ExpDesc v, b; - FuncState *fs = ls->fs; - var_new(ls, 0, lex_str(ls)); - expr_init(&v, VLOCAL, fs->freereg); - v.u.s.aux = fs->varmap[fs->freereg]; - bcreg_reserve(fs, 1); - var_add(ls, 1); - parse_body(ls, &b, 0, ls->linenumber); - /* bcemit_store(fs, &v, &b) without setting VSTACK_VAR_RW. */ - expr_free(fs, &b); - expr_toreg(fs, &b, v.u.s.info); - /* The upvalue is in scope, but the local is only valid after the store. */ - var_get(ls, fs, fs->nactvar - 1).startpc = fs->pc; - } else { /* Local variable declaration. */ - ExpDesc e; - BCReg nexps, nvars = 0; - do { /* Collect LHS. */ - var_new(ls, nvars++, lex_str(ls)); - } while (lex_opt(ls, ',')); - if (lex_opt(ls, '=')) { /* Optional RHS. */ - nexps = expr_list(ls, &e); - } else { /* Or implicitly set to nil. */ - e.k = VVOID; - nexps = 0; - } - assign_adjust(ls, nvars, nexps, &e); - var_add(ls, nvars); - } -} - -/* Parse 'function' statement. */ -static void parse_func(LexState *ls, BCLine line) -{ - FuncState *fs; - ExpDesc v, b; - int needself = 0; - lj_lex_next(ls); /* Skip 'function'. */ - /* Parse function name. */ - var_lookup(ls, &v); - while (ls->token == '.') /* Multiple dot-separated fields. */ - expr_field(ls, &v); - if (ls->token == ':') { /* Optional colon to signify method call. */ - needself = 1; - expr_field(ls, &v); - } - parse_body(ls, &b, needself, line); - fs = ls->fs; - bcemit_store(fs, &v, &b); - fs->bcbase[fs->pc - 1].line = line; /* Set line for the store. */ -} - -/* -- Control transfer statements ----------------------------------------- */ - -/* Check for end of block. */ -static int endofblock(LexToken token) -{ - switch (token) { - case TK_else: case TK_elseif: case TK_end: case TK_until: case TK_eof: - return 1; - default: - return 0; - } -} - -/* Parse 'return' statement. */ -static void parse_return(LexState *ls) -{ - BCIns ins; - FuncState *fs = ls->fs; - lj_lex_next(ls); /* Skip 'return'. */ - fs->flags |= PROTO_HAS_RETURN; - if (endofblock(ls->token) || ls->token == ';') { /* Bare return. */ - ins = BCINS_AD(BC_RET0, 0, 1); - } else { /* Return with one or more values. */ - ExpDesc e; /* Receives the _last_ expression in the list. */ - BCReg nret = expr_list(ls, &e); - if (nret == 1) { /* Return one result. */ - if (e.k == VCALL) { /* Check for tail call. */ - BCIns *ip = bcptr(fs, &e); - /* It doesn't pay off to add BC_VARGT just for 'return ...'. */ - if (bc_op(*ip) == BC_VARG) goto notailcall; - fs->pc--; - ins = BCINS_AD(bc_op(*ip)-BC_CALL+BC_CALLT, bc_a(*ip), bc_c(*ip)); - } else { /* Can return the result from any register. */ - ins = BCINS_AD(BC_RET1, expr_toanyreg(fs, &e), 2); - } - } else { - if (e.k == VCALL) { /* Append all results from a call. */ - notailcall: - setbc_b(bcptr(fs, &e), 0); - ins = BCINS_AD(BC_RETM, fs->nactvar, e.u.s.aux - fs->nactvar); - } else { - expr_tonextreg(fs, &e); /* Force contiguous registers. */ - ins = BCINS_AD(BC_RET, fs->nactvar, nret+1); - } - } - } - if (fs->flags & PROTO_CHILD) - bcemit_AJ(fs, BC_UCLO, 0, 0); /* May need to close upvalues first. */ - bcemit_INS(fs, ins); -} - -/* Parse 'break' statement. */ -static void parse_break(LexState *ls) -{ - ls->fs->bl->flags |= FSCOPE_BREAK; - gola_new(ls, NAME_BREAK, VSTACK_GOTO, bcemit_jmp(ls->fs)); -} - -/* Parse 'goto' statement. */ -static void parse_goto(LexState *ls) -{ - FuncState *fs = ls->fs; - GCstr *name = lex_str(ls); - VarInfo *vl = gola_findlabel(ls, name); - if (vl) /* Treat backwards goto within same scope like a loop. */ - bcemit_AJ(fs, BC_LOOP, vl->slot, -1); /* No BC range check. */ - fs->bl->flags |= FSCOPE_GOLA; - gola_new(ls, name, VSTACK_GOTO, bcemit_jmp(fs)); -} - -/* Parse label. */ -static void parse_label(LexState *ls) -{ - FuncState *fs = ls->fs; - GCstr *name; - MSize idx; - fs->lasttarget = fs->pc; - fs->bl->flags |= FSCOPE_GOLA; - lj_lex_next(ls); /* Skip '::'. */ - name = lex_str(ls); - if (gola_findlabel(ls, name)) - lj_lex_error(ls, 0, LJ_ERR_XLDUP, strdata(name)); - idx = gola_new(ls, name, VSTACK_LABEL, fs->pc); - lex_check(ls, TK_label); - /* Recursively parse trailing statements: labels and ';' (Lua 5.2 only). */ - for (;;) { - if (ls->token == TK_label) { - synlevel_begin(ls); - parse_label(ls); - synlevel_end(ls); - } else if (LJ_52 && ls->token == ';') { - lj_lex_next(ls); - } else { - break; - } - } - /* Trailing label is considered to be outside of scope. */ - if (endofblock(ls->token) && ls->token != TK_until) - ls->vstack[idx].slot = fs->bl->nactvar; - gola_resolve(ls, fs->bl, idx); -} - -/* -- Blocks, loops and conditional statements ---------------------------- */ - -/* Parse a block. */ -static void parse_block(LexState *ls) -{ - FuncState *fs = ls->fs; - FuncScope bl; - fscope_begin(fs, &bl, 0); - parse_chunk(ls); - fscope_end(fs); -} - -/* Parse 'while' statement. */ -static void parse_while(LexState *ls, BCLine line) -{ - FuncState *fs = ls->fs; - BCPos start, loop, condexit; - FuncScope bl; - lj_lex_next(ls); /* Skip 'while'. */ - start = fs->lasttarget = fs->pc; - condexit = expr_cond(ls); - fscope_begin(fs, &bl, FSCOPE_LOOP); - lex_check(ls, TK_do); - loop = bcemit_AD(fs, BC_LOOP, fs->nactvar, 0); - parse_block(ls); - jmp_patch(fs, bcemit_jmp(fs), start); - lex_match(ls, TK_end, TK_while, line); - fscope_end(fs); - jmp_tohere(fs, condexit); - jmp_patchins(fs, loop, fs->pc); -} - -/* Parse 'repeat' statement. */ -static void parse_repeat(LexState *ls, BCLine line) -{ - FuncState *fs = ls->fs; - BCPos loop = fs->lasttarget = fs->pc; - BCPos condexit; - FuncScope bl1, bl2; - fscope_begin(fs, &bl1, FSCOPE_LOOP); /* Breakable loop scope. */ - fscope_begin(fs, &bl2, 0); /* Inner scope. */ - lj_lex_next(ls); /* Skip 'repeat'. */ - bcemit_AD(fs, BC_LOOP, fs->nactvar, 0); - parse_chunk(ls); - lex_match(ls, TK_until, TK_repeat, line); - condexit = expr_cond(ls); /* Parse condition (still inside inner scope). */ - if (!(bl2.flags & FSCOPE_UPVAL)) { /* No upvalues? Just end inner scope. */ - fscope_end(fs); - } else { /* Otherwise generate: cond: UCLO+JMP out, !cond: UCLO+JMP loop. */ - parse_break(ls); /* Break from loop and close upvalues. */ - jmp_tohere(fs, condexit); - fscope_end(fs); /* End inner scope and close upvalues. */ - condexit = bcemit_jmp(fs); - } - jmp_patch(fs, condexit, loop); /* Jump backwards if !cond. */ - jmp_patchins(fs, loop, fs->pc); - fscope_end(fs); /* End loop scope. */ -} - -/* Parse numeric 'for'. */ -static void parse_for_num(LexState *ls, GCstr *varname, BCLine line) -{ - FuncState *fs = ls->fs; - BCReg base = fs->freereg; - FuncScope bl; - BCPos loop, loopend; - /* Hidden control variables. */ - var_new_fixed(ls, FORL_IDX, VARNAME_FOR_IDX); - var_new_fixed(ls, FORL_STOP, VARNAME_FOR_STOP); - var_new_fixed(ls, FORL_STEP, VARNAME_FOR_STEP); - /* Visible copy of index variable. */ - var_new(ls, FORL_EXT, varname); - lex_check(ls, '='); - expr_next(ls); - lex_check(ls, ','); - expr_next(ls); - if (lex_opt(ls, ',')) { - expr_next(ls); - } else { - bcemit_AD(fs, BC_KSHORT, fs->freereg, 1); /* Default step is 1. */ - bcreg_reserve(fs, 1); - } - var_add(ls, 3); /* Hidden control variables. */ - lex_check(ls, TK_do); - loop = bcemit_AJ(fs, BC_FORI, base, NO_JMP); - fscope_begin(fs, &bl, 0); /* Scope for visible variables. */ - var_add(ls, 1); - bcreg_reserve(fs, 1); - parse_block(ls); - fscope_end(fs); - /* Perform loop inversion. Loop control instructions are at the end. */ - loopend = bcemit_AJ(fs, BC_FORL, base, NO_JMP); - fs->bcbase[loopend].line = line; /* Fix line for control ins. */ - jmp_patchins(fs, loopend, loop+1); - jmp_patchins(fs, loop, fs->pc); -} - -/* Try to predict whether the iterator is next() and specialize the bytecode. -** Detecting next() and pairs() by name is simplistic, but quite effective. -** The interpreter backs off if the check for the closure fails at runtime. -*/ -static int predict_next(LexState *ls, FuncState *fs, BCPos pc) -{ - BCIns ins = fs->bcbase[pc].ins; - GCstr *name; - cTValue *o; - switch (bc_op(ins)) { - case BC_MOV: - name = gco2str(gcref(var_get(ls, fs, bc_d(ins)).name)); - break; - case BC_UGET: - name = gco2str(gcref(ls->vstack[fs->uvmap[bc_d(ins)]].name)); - break; - case BC_GGET: - /* There's no inverse index (yet), so lookup the strings. */ - o = lj_tab_getstr(fs->kt, lj_str_newlit(ls->L, "pairs")); - if (o && tvhaskslot(o) && tvkslot(o) == bc_d(ins)) - return 1; - o = lj_tab_getstr(fs->kt, lj_str_newlit(ls->L, "next")); - if (o && tvhaskslot(o) && tvkslot(o) == bc_d(ins)) - return 1; - return 0; - default: - return 0; - } - return (name->len == 5 && !strcmp(strdata(name), "pairs")) || - (name->len == 4 && !strcmp(strdata(name), "next")); -} - -/* Parse 'for' iterator. */ -static void parse_for_iter(LexState *ls, GCstr *indexname) -{ - FuncState *fs = ls->fs; - ExpDesc e; - BCReg nvars = 0; - BCLine line; - BCReg base = fs->freereg + 3; - BCPos loop, loopend, exprpc = fs->pc; - FuncScope bl; - int isnext; - /* Hidden control variables. */ - var_new_fixed(ls, nvars++, VARNAME_FOR_GEN); - var_new_fixed(ls, nvars++, VARNAME_FOR_STATE); - var_new_fixed(ls, nvars++, VARNAME_FOR_CTL); - /* Visible variables returned from iterator. */ - var_new(ls, nvars++, indexname); - while (lex_opt(ls, ',')) - var_new(ls, nvars++, lex_str(ls)); - lex_check(ls, TK_in); - line = ls->linenumber; - assign_adjust(ls, 3, expr_list(ls, &e), &e); - bcreg_bump(fs, 3); /* The iterator needs another 3 slots (func + 2 args). */ - isnext = (nvars <= 5 && predict_next(ls, fs, exprpc)); - var_add(ls, 3); /* Hidden control variables. */ - lex_check(ls, TK_do); - loop = bcemit_AJ(fs, isnext ? BC_ISNEXT : BC_JMP, base, NO_JMP); - fscope_begin(fs, &bl, 0); /* Scope for visible variables. */ - var_add(ls, nvars-3); - bcreg_reserve(fs, nvars-3); - parse_block(ls); - fscope_end(fs); - /* Perform loop inversion. Loop control instructions are at the end. */ - jmp_patchins(fs, loop, fs->pc); - bcemit_ABC(fs, isnext ? BC_ITERN : BC_ITERC, base, nvars-3+1, 2+1); - loopend = bcemit_AJ(fs, BC_ITERL, base, NO_JMP); - fs->bcbase[loopend-1].line = line; /* Fix line for control ins. */ - fs->bcbase[loopend].line = line; - jmp_patchins(fs, loopend, loop+1); -} - -/* Parse 'for' statement. */ -static void parse_for(LexState *ls, BCLine line) -{ - FuncState *fs = ls->fs; - GCstr *varname; - FuncScope bl; - fscope_begin(fs, &bl, FSCOPE_LOOP); - lj_lex_next(ls); /* Skip 'for'. */ - varname = lex_str(ls); /* Get first variable name. */ - if (ls->token == '=') - parse_for_num(ls, varname, line); - else if (ls->token == ',' || ls->token == TK_in) - parse_for_iter(ls, varname); - else - err_syntax(ls, LJ_ERR_XFOR); - lex_match(ls, TK_end, TK_for, line); - fscope_end(fs); /* Resolve break list. */ -} - -/* Parse condition and 'then' block. */ -static BCPos parse_then(LexState *ls) -{ - BCPos condexit; - lj_lex_next(ls); /* Skip 'if' or 'elseif'. */ - condexit = expr_cond(ls); - lex_check(ls, TK_then); - parse_block(ls); - return condexit; -} - -/* Parse 'if' statement. */ -static void parse_if(LexState *ls, BCLine line) -{ - FuncState *fs = ls->fs; - BCPos flist; - BCPos escapelist = NO_JMP; - flist = parse_then(ls); - while (ls->token == TK_elseif) { /* Parse multiple 'elseif' blocks. */ - jmp_append(fs, &escapelist, bcemit_jmp(fs)); - jmp_tohere(fs, flist); - flist = parse_then(ls); - } - if (ls->token == TK_else) { /* Parse optional 'else' block. */ - jmp_append(fs, &escapelist, bcemit_jmp(fs)); - jmp_tohere(fs, flist); - lj_lex_next(ls); /* Skip 'else'. */ - parse_block(ls); - } else { - jmp_append(fs, &escapelist, flist); - } - jmp_tohere(fs, escapelist); - lex_match(ls, TK_end, TK_if, line); -} - -/* -- Parse statements ---------------------------------------------------- */ - -/* Parse a statement. Returns 1 if it must be the last one in a chunk. */ -static int parse_stmt(LexState *ls) -{ - BCLine line = ls->linenumber; - switch (ls->token) { - case TK_if: - parse_if(ls, line); - break; - case TK_while: - parse_while(ls, line); - break; - case TK_do: - lj_lex_next(ls); - parse_block(ls); - lex_match(ls, TK_end, TK_do, line); - break; - case TK_for: - parse_for(ls, line); - break; - case TK_repeat: - parse_repeat(ls, line); - break; - case TK_function: - parse_func(ls, line); - break; - case TK_local: - lj_lex_next(ls); - parse_local(ls); - break; - case TK_return: - parse_return(ls); - return 1; /* Must be last. */ - case TK_break: - lj_lex_next(ls); - parse_break(ls); - return !LJ_52; /* Must be last in Lua 5.1. */ -#if LJ_52 - case ';': - lj_lex_next(ls); - break; -#endif - case TK_label: - parse_label(ls); - break; - case TK_goto: - if (LJ_52 || lj_lex_lookahead(ls) == TK_name) { - lj_lex_next(ls); - parse_goto(ls); - break; - } /* else: fallthrough */ - default: - parse_call_assign(ls); - break; - } - return 0; -} - -/* A chunk is a list of statements optionally separated by semicolons. */ -static void parse_chunk(LexState *ls) -{ - int islast = 0; - synlevel_begin(ls); - while (!islast && !endofblock(ls->token)) { - islast = parse_stmt(ls); - lex_opt(ls, ';'); - lua_assert(ls->fs->framesize >= ls->fs->freereg && - ls->fs->freereg >= ls->fs->nactvar); - ls->fs->freereg = ls->fs->nactvar; /* Free registers after each stmt. */ - } - synlevel_end(ls); -} - -/* Entry point of bytecode parser. */ -GCproto *lj_parse(LexState *ls) -{ - FuncState fs; - FuncScope bl; - GCproto *pt; - lua_State *L = ls->L; -#ifdef LUAJIT_DISABLE_DEBUGINFO - ls->chunkname = lj_str_newlit(L, "="); -#else - ls->chunkname = lj_str_newz(L, ls->chunkarg); -#endif - setstrV(L, L->top, ls->chunkname); /* Anchor chunkname string. */ - incr_top(L); - ls->level = 0; - fs_init(ls, &fs); - fs.linedefined = 0; - fs.numparams = 0; - fs.bcbase = NULL; - fs.bclim = 0; - fs.flags |= PROTO_VARARG; /* Main chunk is always a vararg func. */ - fscope_begin(&fs, &bl, 0); - bcemit_AD(&fs, BC_FUNCV, 0, 0); /* Placeholder. */ - lj_lex_next(ls); /* Read-ahead first token. */ - parse_chunk(ls); - if (ls->token != TK_eof) - err_token(ls, TK_eof); - pt = fs_finish(ls, ls->linenumber); - L->top--; /* Drop chunkname. */ - lua_assert(fs.prev == NULL); - lua_assert(ls->fs == NULL); - lua_assert(pt->sizeuv == 0); - return pt; -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_parse.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_parse.h deleted file mode 100644 index 532657a01..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_parse.h +++ /dev/null @@ -1,18 +0,0 @@ -/* -** Lua parser (source code -> bytecode). -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_PARSE_H -#define _LJ_PARSE_H - -#include "lj_obj.h" -#include "lj_lex.h" - -LJ_FUNC GCproto *lj_parse(LexState *ls); -LJ_FUNC GCstr *lj_parse_keepstr(LexState *ls, const char *str, size_t l); -#if LJ_HASFFI -LJ_FUNC void lj_parse_keepcdata(LexState *ls, TValue *tv, GCcdata *cd); -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_record.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_record.c deleted file mode 100644 index c6848fc09..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_record.c +++ /dev/null @@ -1,2248 +0,0 @@ -/* -** Trace recorder (bytecode -> SSA IR). -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_record_c -#define LUA_CORE - -#include "lj_obj.h" - -#if LJ_HASJIT - -#include "lj_err.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_meta.h" -#include "lj_frame.h" -#if LJ_HASFFI -#include "lj_ctype.h" -#endif -#include "lj_bc.h" -#include "lj_ff.h" -#include "lj_ir.h" -#include "lj_jit.h" -#include "lj_ircall.h" -#include "lj_iropt.h" -#include "lj_trace.h" -#include "lj_record.h" -#include "lj_ffrecord.h" -#include "lj_snap.h" -#include "lj_dispatch.h" -#include "lj_vm.h" - -/* Some local macros to save typing. Undef'd at the end. */ -#define IR(ref) (&J->cur.ir[(ref)]) - -/* Pass IR on to next optimization in chain (FOLD). */ -#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) - -/* Emit raw IR without passing through optimizations. */ -#define emitir_raw(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_ir_emit(J)) - -/* -- Sanity checks ------------------------------------------------------- */ - -#ifdef LUA_USE_ASSERT -/* Sanity check the whole IR -- sloooow. */ -static void rec_check_ir(jit_State *J) -{ - IRRef i, nins = J->cur.nins, nk = J->cur.nk; - lua_assert(nk <= REF_BIAS && nins >= REF_BIAS && nins < 65536); - for (i = nins-1; i >= nk; i--) { - IRIns *ir = IR(i); - uint32_t mode = lj_ir_mode[ir->o]; - IRRef op1 = ir->op1; - IRRef op2 = ir->op2; - switch (irm_op1(mode)) { - case IRMnone: lua_assert(op1 == 0); break; - case IRMref: lua_assert(op1 >= nk); - lua_assert(i >= REF_BIAS ? op1 < i : op1 > i); break; - case IRMlit: break; - case IRMcst: lua_assert(i < REF_BIAS); continue; - } - switch (irm_op2(mode)) { - case IRMnone: lua_assert(op2 == 0); break; - case IRMref: lua_assert(op2 >= nk); - lua_assert(i >= REF_BIAS ? op2 < i : op2 > i); break; - case IRMlit: break; - case IRMcst: lua_assert(0); break; - } - if (ir->prev) { - lua_assert(ir->prev >= nk); - lua_assert(i >= REF_BIAS ? ir->prev < i : ir->prev > i); - lua_assert(ir->o == IR_NOP || IR(ir->prev)->o == ir->o); - } - } -} - -/* Compare stack slots and frames of the recorder and the VM. */ -static void rec_check_slots(jit_State *J) -{ - BCReg s, nslots = J->baseslot + J->maxslot; - int32_t depth = 0; - cTValue *base = J->L->base - J->baseslot; - lua_assert(J->baseslot >= 1 && J->baseslot < LJ_MAX_JSLOTS); - lua_assert(J->baseslot == 1 || (J->slot[J->baseslot-1] & TREF_FRAME)); - lua_assert(nslots < LJ_MAX_JSLOTS); - for (s = 0; s < nslots; s++) { - TRef tr = J->slot[s]; - if (tr) { - cTValue *tv = &base[s]; - IRRef ref = tref_ref(tr); - IRIns *ir; - lua_assert(ref >= J->cur.nk && ref < J->cur.nins); - ir = IR(ref); - lua_assert(irt_t(ir->t) == tref_t(tr)); - if (s == 0) { - lua_assert(tref_isfunc(tr)); - } else if ((tr & TREF_FRAME)) { - GCfunc *fn = gco2func(frame_gc(tv)); - BCReg delta = (BCReg)(tv - frame_prev(tv)); - lua_assert(tref_isfunc(tr)); - if (tref_isk(tr)) lua_assert(fn == ir_kfunc(ir)); - lua_assert(s > delta ? (J->slot[s-delta] & TREF_FRAME) : (s == delta)); - depth++; - } else if ((tr & TREF_CONT)) { - lua_assert(ir_kptr(ir) == gcrefp(tv->gcr, void)); - lua_assert((J->slot[s+1] & TREF_FRAME)); - depth++; - } else { - if (tvisnumber(tv)) - lua_assert(tref_isnumber(tr)); /* Could be IRT_INT etc., too. */ - else - lua_assert(itype2irt(tv) == tref_type(tr)); - if (tref_isk(tr)) { /* Compare constants. */ - TValue tvk; - lj_ir_kvalue(J->L, &tvk, ir); - if (!(tvisnum(&tvk) && tvisnan(&tvk))) - lua_assert(lj_obj_equal(tv, &tvk)); - else - lua_assert(tvisnum(tv) && tvisnan(tv)); - } - } - } - } - lua_assert(J->framedepth == depth); -} -#endif - -/* -- Type handling and specialization ------------------------------------ */ - -/* Note: these functions return tagged references (TRef). */ - -/* Specialize a slot to a specific type. Note: slot can be negative! */ -static TRef sloadt(jit_State *J, int32_t slot, IRType t, int mode) -{ - /* Caller may set IRT_GUARD in t. */ - TRef ref = emitir_raw(IRT(IR_SLOAD, t), (int32_t)J->baseslot+slot, mode); - J->base[slot] = ref; - return ref; -} - -/* Specialize a slot to the runtime type. Note: slot can be negative! */ -static TRef sload(jit_State *J, int32_t slot) -{ - IRType t = itype2irt(&J->L->base[slot]); - TRef ref = emitir_raw(IRTG(IR_SLOAD, t), (int32_t)J->baseslot+slot, - IRSLOAD_TYPECHECK); - if (irtype_ispri(t)) ref = TREF_PRI(t); /* Canonicalize primitive refs. */ - J->base[slot] = ref; - return ref; -} - -/* Get TRef from slot. Load slot and specialize if not done already. */ -#define getslot(J, s) (J->base[(s)] ? J->base[(s)] : sload(J, (int32_t)(s))) - -/* Get TRef for current function. */ -static TRef getcurrf(jit_State *J) -{ - if (J->base[-1]) - return J->base[-1]; - lua_assert(J->baseslot == 1); - return sloadt(J, -1, IRT_FUNC, IRSLOAD_READONLY); -} - -/* Compare for raw object equality. -** Returns 0 if the objects are the same. -** Returns 1 if they are different, but the same type. -** Returns 2 for two different types. -** Comparisons between primitives always return 1 -- no caller cares about it. -*/ -int lj_record_objcmp(jit_State *J, TRef a, TRef b, cTValue *av, cTValue *bv) -{ - int diff = !lj_obj_equal(av, bv); - if (!tref_isk2(a, b)) { /* Shortcut, also handles primitives. */ - IRType ta = tref_isinteger(a) ? IRT_INT : tref_type(a); - IRType tb = tref_isinteger(b) ? IRT_INT : tref_type(b); - if (ta != tb) { - /* Widen mixed number/int comparisons to number/number comparison. */ - if (ta == IRT_INT && tb == IRT_NUM) { - a = emitir(IRTN(IR_CONV), a, IRCONV_NUM_INT); - ta = IRT_NUM; - } else if (ta == IRT_NUM && tb == IRT_INT) { - b = emitir(IRTN(IR_CONV), b, IRCONV_NUM_INT); - } else { - return 2; /* Two different types are never equal. */ - } - } - emitir(IRTG(diff ? IR_NE : IR_EQ, ta), a, b); - } - return diff; -} - -/* Constify a value. Returns 0 for non-representable object types. */ -TRef lj_record_constify(jit_State *J, cTValue *o) -{ - if (tvisgcv(o)) - return lj_ir_kgc(J, gcV(o), itype2irt(o)); - else if (tvisint(o)) - return lj_ir_kint(J, intV(o)); - else if (tvisnum(o)) - return lj_ir_knumint(J, numV(o)); - else if (tvisbool(o)) - return TREF_PRI(itype2irt(o)); - else - return 0; /* Can't represent lightuserdata (pointless). */ -} - -/* -- Record loop ops ----------------------------------------------------- */ - -/* Loop event. */ -typedef enum { - LOOPEV_LEAVE, /* Loop is left or not entered. */ - LOOPEV_ENTERLO, /* Loop is entered with a low iteration count left. */ - LOOPEV_ENTER /* Loop is entered. */ -} LoopEvent; - -/* Canonicalize slots: convert integers to numbers. */ -static void canonicalize_slots(jit_State *J) -{ - BCReg s; - if (LJ_DUALNUM) return; - for (s = J->baseslot+J->maxslot-1; s >= 1; s--) { - TRef tr = J->slot[s]; - if (tref_isinteger(tr)) { - IRIns *ir = IR(tref_ref(tr)); - if (!(ir->o == IR_SLOAD && (ir->op2 & IRSLOAD_READONLY))) - J->slot[s] = emitir(IRTN(IR_CONV), tr, IRCONV_NUM_INT); - } - } -} - -/* Stop recording. */ -static void rec_stop(jit_State *J, TraceLink linktype, TraceNo lnk) -{ - lj_trace_end(J); - J->cur.linktype = (uint8_t)linktype; - J->cur.link = (uint16_t)lnk; - /* Looping back at the same stack level? */ - if (lnk == J->cur.traceno && J->framedepth + J->retdepth == 0) { - if ((J->flags & JIT_F_OPT_LOOP)) /* Shall we try to create a loop? */ - goto nocanon; /* Do not canonicalize or we lose the narrowing. */ - if (J->cur.root) /* Otherwise ensure we always link to the root trace. */ - J->cur.link = J->cur.root; - } - canonicalize_slots(J); -nocanon: - /* Note: all loop ops must set J->pc to the following instruction! */ - lj_snap_add(J); /* Add loop snapshot. */ - J->needsnap = 0; - J->mergesnap = 1; /* In case recording continues. */ -} - -/* Search bytecode backwards for a int/num constant slot initializer. */ -static TRef find_kinit(jit_State *J, const BCIns *endpc, BCReg slot, IRType t) -{ - /* This algorithm is rather simplistic and assumes quite a bit about - ** how the bytecode is generated. It works fine for FORI initializers, - ** but it won't necessarily work in other cases (e.g. iterator arguments). - ** It doesn't do anything fancy, either (like backpropagating MOVs). - */ - const BCIns *pc, *startpc = proto_bc(J->pt); - for (pc = endpc-1; pc > startpc; pc--) { - BCIns ins = *pc; - BCOp op = bc_op(ins); - /* First try to find the last instruction that stores to this slot. */ - if (bcmode_a(op) == BCMbase && bc_a(ins) <= slot) { - return 0; /* Multiple results, e.g. from a CALL or KNIL. */ - } else if (bcmode_a(op) == BCMdst && bc_a(ins) == slot) { - if (op == BC_KSHORT || op == BC_KNUM) { /* Found const. initializer. */ - /* Now try to verify there's no forward jump across it. */ - const BCIns *kpc = pc; - for (; pc > startpc; pc--) - if (bc_op(*pc) == BC_JMP) { - const BCIns *target = pc+bc_j(*pc)+1; - if (target > kpc && target <= endpc) - return 0; /* Conditional assignment. */ - } - if (op == BC_KSHORT) { - int32_t k = (int32_t)(int16_t)bc_d(ins); - return t == IRT_INT ? lj_ir_kint(J, k) : lj_ir_knum(J, (lua_Number)k); - } else { - cTValue *tv = proto_knumtv(J->pt, bc_d(ins)); - if (t == IRT_INT) { - int32_t k = numberVint(tv); - if (tvisint(tv) || numV(tv) == (lua_Number)k) /* -0 is ok here. */ - return lj_ir_kint(J, k); - return 0; /* Type mismatch. */ - } else { - return lj_ir_knum(J, numberVnum(tv)); - } - } - } - return 0; /* Non-constant initializer. */ - } - } - return 0; /* No assignment to this slot found? */ -} - -/* Load and optionally convert a FORI argument from a slot. */ -static TRef fori_load(jit_State *J, BCReg slot, IRType t, int mode) -{ - int conv = (tvisint(&J->L->base[slot]) != (t==IRT_INT)) ? IRSLOAD_CONVERT : 0; - return sloadt(J, (int32_t)slot, - t + (((mode & IRSLOAD_TYPECHECK) || - (conv && t == IRT_INT && !(mode >> 16))) ? - IRT_GUARD : 0), - mode + conv); -} - -/* Peek before FORI to find a const initializer. Otherwise load from slot. */ -static TRef fori_arg(jit_State *J, const BCIns *fori, BCReg slot, - IRType t, int mode) -{ - TRef tr = J->base[slot]; - if (!tr) { - tr = find_kinit(J, fori, slot, t); - if (!tr) - tr = fori_load(J, slot, t, mode); - } - return tr; -} - -/* Return the direction of the FOR loop iterator. -** It's important to exactly reproduce the semantics of the interpreter. -*/ -static int rec_for_direction(cTValue *o) -{ - return (tvisint(o) ? intV(o) : (int32_t)o->u32.hi) >= 0; -} - -/* Simulate the runtime behavior of the FOR loop iterator. */ -static LoopEvent rec_for_iter(IROp *op, cTValue *o, int isforl) -{ - lua_Number stopv = numberVnum(&o[FORL_STOP]); - lua_Number idxv = numberVnum(&o[FORL_IDX]); - lua_Number stepv = numberVnum(&o[FORL_STEP]); - if (isforl) - idxv += stepv; - if (rec_for_direction(&o[FORL_STEP])) { - if (idxv <= stopv) { - *op = IR_LE; - return idxv + 2*stepv > stopv ? LOOPEV_ENTERLO : LOOPEV_ENTER; - } - *op = IR_GT; return LOOPEV_LEAVE; - } else { - if (stopv <= idxv) { - *op = IR_GE; - return idxv + 2*stepv < stopv ? LOOPEV_ENTERLO : LOOPEV_ENTER; - } - *op = IR_LT; return LOOPEV_LEAVE; - } -} - -/* Record checks for FOR loop overflow and step direction. */ -static void rec_for_check(jit_State *J, IRType t, int dir, - TRef stop, TRef step, int init) -{ - if (!tref_isk(step)) { - /* Non-constant step: need a guard for the direction. */ - TRef zero = (t == IRT_INT) ? lj_ir_kint(J, 0) : lj_ir_knum_zero(J); - emitir(IRTG(dir ? IR_GE : IR_LT, t), step, zero); - /* Add hoistable overflow checks for a narrowed FORL index. */ - if (init && t == IRT_INT) { - if (tref_isk(stop)) { - /* Constant stop: optimize check away or to a range check for step. */ - int32_t k = IR(tref_ref(stop))->i; - if (dir) { - if (k > 0) - emitir(IRTGI(IR_LE), step, lj_ir_kint(J, (int32_t)0x7fffffff-k)); - } else { - if (k < 0) - emitir(IRTGI(IR_GE), step, lj_ir_kint(J, (int32_t)0x80000000-k)); - } - } else { - /* Stop+step variable: need full overflow check. */ - TRef tr = emitir(IRTGI(IR_ADDOV), step, stop); - emitir(IRTI(IR_USE), tr, 0); /* ADDOV is weak. Avoid dead result. */ - } - } - } else if (init && t == IRT_INT && !tref_isk(stop)) { - /* Constant step: optimize overflow check to a range check for stop. */ - int32_t k = IR(tref_ref(step))->i; - k = (int32_t)(dir ? 0x7fffffff : 0x80000000) - k; - emitir(IRTGI(dir ? IR_LE : IR_GE), stop, lj_ir_kint(J, k)); - } -} - -/* Record a FORL instruction. */ -static void rec_for_loop(jit_State *J, const BCIns *fori, ScEvEntry *scev, - int init) -{ - BCReg ra = bc_a(*fori); - cTValue *tv = &J->L->base[ra]; - TRef idx = J->base[ra+FORL_IDX]; - IRType t = idx ? tref_type(idx) : - (init || LJ_DUALNUM) ? lj_opt_narrow_forl(J, tv) : IRT_NUM; - int mode = IRSLOAD_INHERIT + - ((!LJ_DUALNUM || tvisint(tv) == (t == IRT_INT)) ? IRSLOAD_READONLY : 0); - TRef stop = fori_arg(J, fori, ra+FORL_STOP, t, mode); - TRef step = fori_arg(J, fori, ra+FORL_STEP, t, mode); - int tc, dir = rec_for_direction(&tv[FORL_STEP]); - lua_assert(bc_op(*fori) == BC_FORI || bc_op(*fori) == BC_JFORI); - scev->t.irt = t; - scev->dir = dir; - scev->stop = tref_ref(stop); - scev->step = tref_ref(step); - rec_for_check(J, t, dir, stop, step, init); - scev->start = tref_ref(find_kinit(J, fori, ra+FORL_IDX, IRT_INT)); - tc = (LJ_DUALNUM && - !(scev->start && irref_isk(scev->stop) && irref_isk(scev->step) && - tvisint(&tv[FORL_IDX]) == (t == IRT_INT))) ? - IRSLOAD_TYPECHECK : 0; - if (tc) { - J->base[ra+FORL_STOP] = stop; - J->base[ra+FORL_STEP] = step; - } - if (!idx) - idx = fori_load(J, ra+FORL_IDX, t, - IRSLOAD_INHERIT + tc + (J->scev.start << 16)); - if (!init) - J->base[ra+FORL_IDX] = idx = emitir(IRT(IR_ADD, t), idx, step); - J->base[ra+FORL_EXT] = idx; - scev->idx = tref_ref(idx); - J->maxslot = ra+FORL_EXT+1; -} - -/* Record FORL/JFORL or FORI/JFORI. */ -static LoopEvent rec_for(jit_State *J, const BCIns *fori, int isforl) -{ - BCReg ra = bc_a(*fori); - TValue *tv = &J->L->base[ra]; - TRef *tr = &J->base[ra]; - IROp op; - LoopEvent ev; - TRef stop; - IRType t; - if (isforl) { /* Handle FORL/JFORL opcodes. */ - TRef idx = tr[FORL_IDX]; - if (tref_ref(idx) == J->scev.idx) { - t = J->scev.t.irt; - stop = J->scev.stop; - idx = emitir(IRT(IR_ADD, t), idx, J->scev.step); - tr[FORL_EXT] = tr[FORL_IDX] = idx; - } else { - ScEvEntry scev; - rec_for_loop(J, fori, &scev, 0); - t = scev.t.irt; - stop = scev.stop; - } - } else { /* Handle FORI/JFORI opcodes. */ - BCReg i; - lj_meta_for(J->L, tv); - t = (LJ_DUALNUM || tref_isint(tr[FORL_IDX])) ? lj_opt_narrow_forl(J, tv) : - IRT_NUM; - for (i = FORL_IDX; i <= FORL_STEP; i++) { - if (!tr[i]) sload(J, ra+i); - lua_assert(tref_isnumber_str(tr[i])); - if (tref_isstr(tr[i])) - tr[i] = emitir(IRTG(IR_STRTO, IRT_NUM), tr[i], 0); - if (t == IRT_INT) { - if (!tref_isinteger(tr[i])) - tr[i] = emitir(IRTGI(IR_CONV), tr[i], IRCONV_INT_NUM|IRCONV_CHECK); - } else { - if (!tref_isnum(tr[i])) - tr[i] = emitir(IRTN(IR_CONV), tr[i], IRCONV_NUM_INT); - } - } - tr[FORL_EXT] = tr[FORL_IDX]; - stop = tr[FORL_STOP]; - rec_for_check(J, t, rec_for_direction(&tv[FORL_STEP]), - stop, tr[FORL_STEP], 1); - } - - ev = rec_for_iter(&op, tv, isforl); - if (ev == LOOPEV_LEAVE) { - J->maxslot = ra+FORL_EXT+1; - J->pc = fori+1; - } else { - J->maxslot = ra; - J->pc = fori+bc_j(*fori)+1; - } - lj_snap_add(J); - - emitir(IRTG(op, t), tr[FORL_IDX], stop); - - if (ev == LOOPEV_LEAVE) { - J->maxslot = ra; - J->pc = fori+bc_j(*fori)+1; - } else { - J->maxslot = ra+FORL_EXT+1; - J->pc = fori+1; - } - J->needsnap = 1; - return ev; -} - -/* Record ITERL/JITERL. */ -static LoopEvent rec_iterl(jit_State *J, const BCIns iterins) -{ - BCReg ra = bc_a(iterins); - lua_assert(J->base[ra] != 0); - if (!tref_isnil(J->base[ra])) { /* Looping back? */ - J->base[ra-1] = J->base[ra]; /* Copy result of ITERC to control var. */ - J->maxslot = ra-1+bc_b(J->pc[-1]); - J->pc += bc_j(iterins)+1; - return LOOPEV_ENTER; - } else { - J->maxslot = ra-3; - J->pc++; - return LOOPEV_LEAVE; - } -} - -/* Record LOOP/JLOOP. Now, that was easy. */ -static LoopEvent rec_loop(jit_State *J, BCReg ra) -{ - if (ra < J->maxslot) J->maxslot = ra; - J->pc++; - return LOOPEV_ENTER; -} - -/* Check if a loop repeatedly failed to trace because it didn't loop back. */ -static int innerloopleft(jit_State *J, const BCIns *pc) -{ - ptrdiff_t i; - for (i = 0; i < PENALTY_SLOTS; i++) - if (mref(J->penalty[i].pc, const BCIns) == pc) { - if ((J->penalty[i].reason == LJ_TRERR_LLEAVE || - J->penalty[i].reason == LJ_TRERR_LINNER) && - J->penalty[i].val >= 2*PENALTY_MIN) - return 1; - break; - } - return 0; -} - -/* Handle the case when an interpreted loop op is hit. */ -static void rec_loop_interp(jit_State *J, const BCIns *pc, LoopEvent ev) -{ - if (J->parent == 0) { - if (pc == J->startpc && J->framedepth + J->retdepth == 0) { - /* Same loop? */ - if (ev == LOOPEV_LEAVE) /* Must loop back to form a root trace. */ - lj_trace_err(J, LJ_TRERR_LLEAVE); - rec_stop(J, LJ_TRLINK_LOOP, J->cur.traceno); /* Looping root trace. */ - } else if (ev != LOOPEV_LEAVE) { /* Entering inner loop? */ - /* It's usually better to abort here and wait until the inner loop - ** is traced. But if the inner loop repeatedly didn't loop back, - ** this indicates a low trip count. In this case try unrolling - ** an inner loop even in a root trace. But it's better to be a bit - ** more conservative here and only do it for very short loops. - */ - if (bc_j(*pc) != -1 && !innerloopleft(J, pc)) - lj_trace_err(J, LJ_TRERR_LINNER); /* Root trace hit an inner loop. */ - if ((ev != LOOPEV_ENTERLO && - J->loopref && J->cur.nins - J->loopref > 24) || --J->loopunroll < 0) - lj_trace_err(J, LJ_TRERR_LUNROLL); /* Limit loop unrolling. */ - J->loopref = J->cur.nins; - } - } else if (ev != LOOPEV_LEAVE) { /* Side trace enters an inner loop. */ - J->loopref = J->cur.nins; - if (--J->loopunroll < 0) - lj_trace_err(J, LJ_TRERR_LUNROLL); /* Limit loop unrolling. */ - } /* Side trace continues across a loop that's left or not entered. */ -} - -/* Handle the case when an already compiled loop op is hit. */ -static void rec_loop_jit(jit_State *J, TraceNo lnk, LoopEvent ev) -{ - if (J->parent == 0) { /* Root trace hit an inner loop. */ - /* Better let the inner loop spawn a side trace back here. */ - lj_trace_err(J, LJ_TRERR_LINNER); - } else if (ev != LOOPEV_LEAVE) { /* Side trace enters a compiled loop. */ - J->instunroll = 0; /* Cannot continue across a compiled loop op. */ - if (J->pc == J->startpc && J->framedepth + J->retdepth == 0) - rec_stop(J, LJ_TRLINK_LOOP, J->cur.traceno); /* Form an extra loop. */ - else - rec_stop(J, LJ_TRLINK_ROOT, lnk); /* Link to the loop. */ - } /* Side trace continues across a loop that's left or not entered. */ -} - -/* -- Record calls and returns -------------------------------------------- */ - -/* Specialize to the runtime value of the called function or its prototype. */ -static TRef rec_call_specialize(jit_State *J, GCfunc *fn, TRef tr) -{ - TRef kfunc; - if (isluafunc(fn)) { - GCproto *pt = funcproto(fn); - /* Too many closures created? Probably not a monomorphic function. */ - if (pt->flags >= PROTO_CLC_POLY) { /* Specialize to prototype instead. */ - TRef trpt = emitir(IRT(IR_FLOAD, IRT_P32), tr, IRFL_FUNC_PC); - emitir(IRTG(IR_EQ, IRT_P32), trpt, lj_ir_kptr(J, proto_bc(pt))); - (void)lj_ir_kgc(J, obj2gco(pt), IRT_PROTO); /* Prevent GC of proto. */ - return tr; - } - } - /* Otherwise specialize to the function (closure) value itself. */ - kfunc = lj_ir_kfunc(J, fn); - emitir(IRTG(IR_EQ, IRT_FUNC), tr, kfunc); - return kfunc; -} - -/* Record call setup. */ -static void rec_call_setup(jit_State *J, BCReg func, ptrdiff_t nargs) -{ - RecordIndex ix; - TValue *functv = &J->L->base[func]; - TRef *fbase = &J->base[func]; - ptrdiff_t i; - for (i = 0; i <= nargs; i++) - (void)getslot(J, func+i); /* Ensure func and all args have a reference. */ - if (!tref_isfunc(fbase[0])) { /* Resolve __call metamethod. */ - ix.tab = fbase[0]; - copyTV(J->L, &ix.tabv, functv); - if (!lj_record_mm_lookup(J, &ix, MM_call) || !tref_isfunc(ix.mobj)) - lj_trace_err(J, LJ_TRERR_NOMM); - for (i = ++nargs; i > 0; i--) /* Shift arguments up. */ - fbase[i] = fbase[i-1]; - fbase[0] = ix.mobj; /* Replace function. */ - functv = &ix.mobjv; - } - fbase[0] = TREF_FRAME | rec_call_specialize(J, funcV(functv), fbase[0]); - J->maxslot = (BCReg)nargs; -} - -/* Record call. */ -void lj_record_call(jit_State *J, BCReg func, ptrdiff_t nargs) -{ - rec_call_setup(J, func, nargs); - /* Bump frame. */ - J->framedepth++; - J->base += func+1; - J->baseslot += func+1; -} - -/* Record tail call. */ -void lj_record_tailcall(jit_State *J, BCReg func, ptrdiff_t nargs) -{ - rec_call_setup(J, func, nargs); - if (frame_isvarg(J->L->base - 1)) { - BCReg cbase = (BCReg)frame_delta(J->L->base - 1); - if (--J->framedepth < 0) - lj_trace_err(J, LJ_TRERR_NYIRETL); - J->baseslot -= (BCReg)cbase; - J->base -= cbase; - func += cbase; - } - /* Move func + args down. */ - memmove(&J->base[-1], &J->base[func], sizeof(TRef)*(J->maxslot+1)); - /* Note: the new TREF_FRAME is now at J->base[-1] (even for slot #0). */ - /* Tailcalls can form a loop, so count towards the loop unroll limit. */ - if (++J->tailcalled > J->loopunroll) - lj_trace_err(J, LJ_TRERR_LUNROLL); -} - -/* Check unroll limits for down-recursion. */ -static int check_downrec_unroll(jit_State *J, GCproto *pt) -{ - IRRef ptref; - for (ptref = J->chain[IR_KGC]; ptref; ptref = IR(ptref)->prev) - if (ir_kgc(IR(ptref)) == obj2gco(pt)) { - int count = 0; - IRRef ref; - for (ref = J->chain[IR_RETF]; ref; ref = IR(ref)->prev) - if (IR(ref)->op1 == ptref) - count++; - if (count) { - if (J->pc == J->startpc) { - if (count + J->tailcalled > J->param[JIT_P_recunroll]) - return 1; - } else { - lj_trace_err(J, LJ_TRERR_DOWNREC); - } - } - } - return 0; -} - -/* Record return. */ -void lj_record_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults) -{ - TValue *frame = J->L->base - 1; - ptrdiff_t i; - for (i = 0; i < gotresults; i++) - (void)getslot(J, rbase+i); /* Ensure all results have a reference. */ - while (frame_ispcall(frame)) { /* Immediately resolve pcall() returns. */ - BCReg cbase = (BCReg)frame_delta(frame); - if (--J->framedepth < 0) - lj_trace_err(J, LJ_TRERR_NYIRETL); - lua_assert(J->baseslot > 1); - gotresults++; - rbase += cbase; - J->baseslot -= (BCReg)cbase; - J->base -= cbase; - J->base[--rbase] = TREF_TRUE; /* Prepend true to results. */ - frame = frame_prevd(frame); - } - /* Return to lower frame via interpreter for unhandled cases. */ - if (J->framedepth == 0 && J->pt && bc_isret(bc_op(*J->pc)) && - (!frame_islua(frame) || - (J->parent == 0 && !bc_isret(bc_op(J->cur.startins))))) { - /* NYI: specialize to frame type and return directly, not via RET*. */ - for (i = 0; i < (ptrdiff_t)rbase; i++) - J->base[i] = 0; /* Purge dead slots. */ - J->maxslot = rbase + (BCReg)gotresults; - rec_stop(J, LJ_TRLINK_RETURN, 0); /* Return to interpreter. */ - return; - } - if (frame_isvarg(frame)) { - BCReg cbase = (BCReg)frame_delta(frame); - if (--J->framedepth < 0) /* NYI: return of vararg func to lower frame. */ - lj_trace_err(J, LJ_TRERR_NYIRETL); - lua_assert(J->baseslot > 1); - rbase += cbase; - J->baseslot -= (BCReg)cbase; - J->base -= cbase; - frame = frame_prevd(frame); - } - if (frame_islua(frame)) { /* Return to Lua frame. */ - BCIns callins = *(frame_pc(frame)-1); - ptrdiff_t nresults = bc_b(callins) ? (ptrdiff_t)bc_b(callins)-1 :gotresults; - BCReg cbase = bc_a(callins); - GCproto *pt = funcproto(frame_func(frame - (cbase+1))); - if ((pt->flags & PROTO_NOJIT)) - lj_trace_err(J, LJ_TRERR_CJITOFF); - if (J->framedepth == 0 && J->pt && frame == J->L->base - 1) { - if (check_downrec_unroll(J, pt)) { - J->maxslot = (BCReg)(rbase + gotresults); - lj_snap_purge(J); - rec_stop(J, LJ_TRLINK_DOWNREC, J->cur.traceno); /* Down-recursion. */ - return; - } - lj_snap_add(J); - } - for (i = 0; i < nresults; i++) /* Adjust results. */ - J->base[i-1] = i < gotresults ? J->base[rbase+i] : TREF_NIL; - J->maxslot = cbase+(BCReg)nresults; - if (J->framedepth > 0) { /* Return to a frame that is part of the trace. */ - J->framedepth--; - lua_assert(J->baseslot > cbase+1); - J->baseslot -= cbase+1; - J->base -= cbase+1; - } else if (J->parent == 0 && !bc_isret(bc_op(J->cur.startins))) { - /* Return to lower frame would leave the loop in a root trace. */ - lj_trace_err(J, LJ_TRERR_LLEAVE); - } else { /* Return to lower frame. Guard for the target we return to. */ - TRef trpt = lj_ir_kgc(J, obj2gco(pt), IRT_PROTO); - TRef trpc = lj_ir_kptr(J, (void *)frame_pc(frame)); - emitir(IRTG(IR_RETF, IRT_P32), trpt, trpc); - J->retdepth++; - J->needsnap = 1; - lua_assert(J->baseslot == 1); - /* Shift result slots up and clear the slots of the new frame below. */ - memmove(J->base + cbase, J->base-1, sizeof(TRef)*nresults); - memset(J->base-1, 0, sizeof(TRef)*(cbase+1)); - } - } else if (frame_iscont(frame)) { /* Return to continuation frame. */ - ASMFunction cont = frame_contf(frame); - BCReg cbase = (BCReg)frame_delta(frame); - if ((J->framedepth -= 2) < 0) - lj_trace_err(J, LJ_TRERR_NYIRETL); - J->baseslot -= (BCReg)cbase; - J->base -= cbase; - J->maxslot = cbase-2; - if (cont == lj_cont_ra) { - /* Copy result to destination slot. */ - BCReg dst = bc_a(*(frame_contpc(frame)-1)); - J->base[dst] = gotresults ? J->base[cbase+rbase] : TREF_NIL; - if (dst >= J->maxslot) J->maxslot = dst+1; - } else if (cont == lj_cont_nop) { - /* Nothing to do here. */ - } else if (cont == lj_cont_cat) { - lua_assert(0); - } else { - /* Result type already specialized. */ - lua_assert(cont == lj_cont_condf || cont == lj_cont_condt); - } - } else { - lj_trace_err(J, LJ_TRERR_NYIRETL); /* NYI: handle return to C frame. */ - } - lua_assert(J->baseslot >= 1); -} - -/* -- Metamethod handling ------------------------------------------------- */ - -/* Prepare to record call to metamethod. */ -static BCReg rec_mm_prep(jit_State *J, ASMFunction cont) -{ - BCReg s, top = curr_proto(J->L)->framesize; - TRef trcont; - setcont(&J->L->base[top], cont); -#if LJ_64 - trcont = lj_ir_kptr(J, (void *)((int64_t)cont - (int64_t)lj_vm_asm_begin)); -#else - trcont = lj_ir_kptr(J, (void *)cont); -#endif - J->base[top] = trcont | TREF_CONT; - J->framedepth++; - for (s = J->maxslot; s < top; s++) - J->base[s] = 0; /* Clear frame gap to avoid resurrecting previous refs. */ - return top+1; -} - -/* Record metamethod lookup. */ -int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm) -{ - RecordIndex mix; - GCtab *mt; - if (tref_istab(ix->tab)) { - mt = tabref(tabV(&ix->tabv)->metatable); - mix.tab = emitir(IRT(IR_FLOAD, IRT_TAB), ix->tab, IRFL_TAB_META); - } else if (tref_isudata(ix->tab)) { - int udtype = udataV(&ix->tabv)->udtype; - mt = tabref(udataV(&ix->tabv)->metatable); - /* The metatables of special userdata objects are treated as immutable. */ - if (udtype != UDTYPE_USERDATA) { - cTValue *mo; - if (LJ_HASFFI && udtype == UDTYPE_FFI_CLIB) { - /* Specialize to the C library namespace object. */ - emitir(IRTG(IR_EQ, IRT_P32), ix->tab, lj_ir_kptr(J, udataV(&ix->tabv))); - } else { - /* Specialize to the type of userdata. */ - TRef tr = emitir(IRT(IR_FLOAD, IRT_U8), ix->tab, IRFL_UDATA_UDTYPE); - emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, udtype)); - } - immutable_mt: - mo = lj_tab_getstr(mt, mmname_str(J2G(J), mm)); - if (!mo || tvisnil(mo)) - return 0; /* No metamethod. */ - /* Treat metamethod or index table as immutable, too. */ - if (!(tvisfunc(mo) || tvistab(mo))) - lj_trace_err(J, LJ_TRERR_BADTYPE); - copyTV(J->L, &ix->mobjv, mo); - ix->mobj = lj_ir_kgc(J, gcV(mo), tvisfunc(mo) ? IRT_FUNC : IRT_TAB); - ix->mtv = mt; - ix->mt = TREF_NIL; /* Dummy value for comparison semantics. */ - return 1; /* Got metamethod or index table. */ - } - mix.tab = emitir(IRT(IR_FLOAD, IRT_TAB), ix->tab, IRFL_UDATA_META); - } else { - /* Specialize to base metatable. Must flush mcode in lua_setmetatable(). */ - mt = tabref(basemt_obj(J2G(J), &ix->tabv)); - if (mt == NULL) { - ix->mt = TREF_NIL; - return 0; /* No metamethod. */ - } - /* The cdata metatable is treated as immutable. */ - if (LJ_HASFFI && tref_iscdata(ix->tab)) goto immutable_mt; - ix->mt = mix.tab = lj_ir_ktab(J, mt); - goto nocheck; - } - ix->mt = mt ? mix.tab : TREF_NIL; - emitir(IRTG(mt ? IR_NE : IR_EQ, IRT_TAB), mix.tab, lj_ir_knull(J, IRT_TAB)); -nocheck: - if (mt) { - GCstr *mmstr = mmname_str(J2G(J), mm); - cTValue *mo = lj_tab_getstr(mt, mmstr); - if (mo && !tvisnil(mo)) - copyTV(J->L, &ix->mobjv, mo); - ix->mtv = mt; - settabV(J->L, &mix.tabv, mt); - setstrV(J->L, &mix.keyv, mmstr); - mix.key = lj_ir_kstr(J, mmstr); - mix.val = 0; - mix.idxchain = 0; - ix->mobj = lj_record_idx(J, &mix); - return !tref_isnil(ix->mobj); /* 1 if metamethod found, 0 if not. */ - } - return 0; /* No metamethod. */ -} - -/* Record call to arithmetic metamethod. */ -static TRef rec_mm_arith(jit_State *J, RecordIndex *ix, MMS mm) -{ - /* Set up metamethod call first to save ix->tab and ix->tabv. */ - BCReg func = rec_mm_prep(J, lj_cont_ra); - TRef *base = J->base + func; - TValue *basev = J->L->base + func; - base[1] = ix->tab; base[2] = ix->key; - copyTV(J->L, basev+1, &ix->tabv); - copyTV(J->L, basev+2, &ix->keyv); - if (!lj_record_mm_lookup(J, ix, mm)) { /* Lookup mm on 1st operand. */ - if (mm != MM_unm) { - ix->tab = ix->key; - copyTV(J->L, &ix->tabv, &ix->keyv); - if (lj_record_mm_lookup(J, ix, mm)) /* Lookup mm on 2nd operand. */ - goto ok; - } - lj_trace_err(J, LJ_TRERR_NOMM); - } -ok: - base[0] = ix->mobj; - copyTV(J->L, basev+0, &ix->mobjv); - lj_record_call(J, func, 2); - return 0; /* No result yet. */ -} - -/* Record call to __len metamethod. */ -static TRef rec_mm_len(jit_State *J, TRef tr, TValue *tv) -{ - RecordIndex ix; - ix.tab = tr; - copyTV(J->L, &ix.tabv, tv); - if (lj_record_mm_lookup(J, &ix, MM_len)) { - BCReg func = rec_mm_prep(J, lj_cont_ra); - TRef *base = J->base + func; - TValue *basev = J->L->base + func; - base[0] = ix.mobj; copyTV(J->L, basev+0, &ix.mobjv); - base[1] = tr; copyTV(J->L, basev+1, tv); -#if LJ_52 - base[2] = tr; copyTV(J->L, basev+2, tv); -#else - base[2] = TREF_NIL; setnilV(basev+2); -#endif - lj_record_call(J, func, 2); - } else { - if (LJ_52 && tref_istab(tr)) - return lj_ir_call(J, IRCALL_lj_tab_len, tr); - lj_trace_err(J, LJ_TRERR_NOMM); - } - return 0; /* No result yet. */ -} - -/* Call a comparison metamethod. */ -static void rec_mm_callcomp(jit_State *J, RecordIndex *ix, int op) -{ - BCReg func = rec_mm_prep(J, (op&1) ? lj_cont_condf : lj_cont_condt); - TRef *base = J->base + func; - TValue *tv = J->L->base + func; - base[0] = ix->mobj; base[1] = ix->val; base[2] = ix->key; - copyTV(J->L, tv+0, &ix->mobjv); - copyTV(J->L, tv+1, &ix->valv); - copyTV(J->L, tv+2, &ix->keyv); - lj_record_call(J, func, 2); -} - -/* Record call to equality comparison metamethod (for tab and udata only). */ -static void rec_mm_equal(jit_State *J, RecordIndex *ix, int op) -{ - ix->tab = ix->val; - copyTV(J->L, &ix->tabv, &ix->valv); - if (lj_record_mm_lookup(J, ix, MM_eq)) { /* Lookup mm on 1st operand. */ - cTValue *bv; - TRef mo1 = ix->mobj; - TValue mo1v; - copyTV(J->L, &mo1v, &ix->mobjv); - /* Avoid the 2nd lookup and the objcmp if the metatables are equal. */ - bv = &ix->keyv; - if (tvistab(bv) && tabref(tabV(bv)->metatable) == ix->mtv) { - TRef mt2 = emitir(IRT(IR_FLOAD, IRT_TAB), ix->key, IRFL_TAB_META); - emitir(IRTG(IR_EQ, IRT_TAB), mt2, ix->mt); - } else if (tvisudata(bv) && tabref(udataV(bv)->metatable) == ix->mtv) { - TRef mt2 = emitir(IRT(IR_FLOAD, IRT_TAB), ix->key, IRFL_UDATA_META); - emitir(IRTG(IR_EQ, IRT_TAB), mt2, ix->mt); - } else { /* Lookup metamethod on 2nd operand and compare both. */ - ix->tab = ix->key; - copyTV(J->L, &ix->tabv, bv); - if (!lj_record_mm_lookup(J, ix, MM_eq) || - lj_record_objcmp(J, mo1, ix->mobj, &mo1v, &ix->mobjv)) - return; - } - rec_mm_callcomp(J, ix, op); - } -} - -/* Record call to ordered comparison metamethods (for arbitrary objects). */ -static void rec_mm_comp(jit_State *J, RecordIndex *ix, int op) -{ - ix->tab = ix->val; - copyTV(J->L, &ix->tabv, &ix->valv); - while (1) { - MMS mm = (op & 2) ? MM_le : MM_lt; /* Try __le + __lt or only __lt. */ -#if LJ_52 - if (!lj_record_mm_lookup(J, ix, mm)) { /* Lookup mm on 1st operand. */ - ix->tab = ix->key; - copyTV(J->L, &ix->tabv, &ix->keyv); - if (!lj_record_mm_lookup(J, ix, mm)) /* Lookup mm on 2nd operand. */ - goto nomatch; - } - rec_mm_callcomp(J, ix, op); - return; -#else - if (lj_record_mm_lookup(J, ix, mm)) { /* Lookup mm on 1st operand. */ - cTValue *bv; - TRef mo1 = ix->mobj; - TValue mo1v; - copyTV(J->L, &mo1v, &ix->mobjv); - /* Avoid the 2nd lookup and the objcmp if the metatables are equal. */ - bv = &ix->keyv; - if (tvistab(bv) && tabref(tabV(bv)->metatable) == ix->mtv) { - TRef mt2 = emitir(IRT(IR_FLOAD, IRT_TAB), ix->key, IRFL_TAB_META); - emitir(IRTG(IR_EQ, IRT_TAB), mt2, ix->mt); - } else if (tvisudata(bv) && tabref(udataV(bv)->metatable) == ix->mtv) { - TRef mt2 = emitir(IRT(IR_FLOAD, IRT_TAB), ix->key, IRFL_UDATA_META); - emitir(IRTG(IR_EQ, IRT_TAB), mt2, ix->mt); - } else { /* Lookup metamethod on 2nd operand and compare both. */ - ix->tab = ix->key; - copyTV(J->L, &ix->tabv, bv); - if (!lj_record_mm_lookup(J, ix, mm) || - lj_record_objcmp(J, mo1, ix->mobj, &mo1v, &ix->mobjv)) - goto nomatch; - } - rec_mm_callcomp(J, ix, op); - return; - } -#endif - nomatch: - /* Lookup failed. Retry with __lt and swapped operands. */ - if (!(op & 2)) break; /* Already at __lt. Interpreter will throw. */ - ix->tab = ix->key; ix->key = ix->val; ix->val = ix->tab; - copyTV(J->L, &ix->tabv, &ix->keyv); - copyTV(J->L, &ix->keyv, &ix->valv); - copyTV(J->L, &ix->valv, &ix->tabv); - op ^= 3; - } -} - -#if LJ_HASFFI -/* Setup call to cdata comparison metamethod. */ -static void rec_mm_comp_cdata(jit_State *J, RecordIndex *ix, int op, MMS mm) -{ - lj_snap_add(J); - if (tref_iscdata(ix->val)) { - ix->tab = ix->val; - copyTV(J->L, &ix->tabv, &ix->valv); - } else { - lua_assert(tref_iscdata(ix->key)); - ix->tab = ix->key; - copyTV(J->L, &ix->tabv, &ix->keyv); - } - lj_record_mm_lookup(J, ix, mm); - rec_mm_callcomp(J, ix, op); -} -#endif - -/* -- Indexed access ------------------------------------------------------ */ - -/* Record bounds-check. */ -static void rec_idx_abc(jit_State *J, TRef asizeref, TRef ikey, uint32_t asize) -{ - /* Try to emit invariant bounds checks. */ - if ((J->flags & (JIT_F_OPT_LOOP|JIT_F_OPT_ABC)) == - (JIT_F_OPT_LOOP|JIT_F_OPT_ABC)) { - IRRef ref = tref_ref(ikey); - IRIns *ir = IR(ref); - int32_t ofs = 0; - IRRef ofsref = 0; - /* Handle constant offsets. */ - if (ir->o == IR_ADD && irref_isk(ir->op2)) { - ofsref = ir->op2; - ofs = IR(ofsref)->i; - ref = ir->op1; - ir = IR(ref); - } - /* Got scalar evolution analysis results for this reference? */ - if (ref == J->scev.idx) { - int32_t stop; - lua_assert(irt_isint(J->scev.t) && ir->o == IR_SLOAD); - stop = numberVint(&(J->L->base - J->baseslot)[ir->op1 + FORL_STOP]); - /* Runtime value for stop of loop is within bounds? */ - if ((int64_t)stop + ofs < (int64_t)asize) { - /* Emit invariant bounds check for stop. */ - emitir(IRTG(IR_ABC, IRT_P32), asizeref, ofs == 0 ? J->scev.stop : - emitir(IRTI(IR_ADD), J->scev.stop, ofsref)); - /* Emit invariant bounds check for start, if not const or negative. */ - if (!(J->scev.dir && J->scev.start && - (int64_t)IR(J->scev.start)->i + ofs >= 0)) - emitir(IRTG(IR_ABC, IRT_P32), asizeref, ikey); - return; - } - } - } - emitir(IRTGI(IR_ABC), asizeref, ikey); /* Emit regular bounds check. */ -} - -/* Record indexed key lookup. */ -static TRef rec_idx_key(jit_State *J, RecordIndex *ix) -{ - TRef key; - GCtab *t = tabV(&ix->tabv); - ix->oldv = lj_tab_get(J->L, t, &ix->keyv); /* Lookup previous value. */ - - /* Integer keys are looked up in the array part first. */ - key = ix->key; - if (tref_isnumber(key)) { - int32_t k = numberVint(&ix->keyv); - if (!tvisint(&ix->keyv) && numV(&ix->keyv) != (lua_Number)k) - k = LJ_MAX_ASIZE; - if ((MSize)k < LJ_MAX_ASIZE) { /* Potential array key? */ - TRef ikey = lj_opt_narrow_index(J, key); - TRef asizeref = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_ASIZE); - if ((MSize)k < t->asize) { /* Currently an array key? */ - TRef arrayref; - rec_idx_abc(J, asizeref, ikey, t->asize); - arrayref = emitir(IRT(IR_FLOAD, IRT_P32), ix->tab, IRFL_TAB_ARRAY); - return emitir(IRT(IR_AREF, IRT_P32), arrayref, ikey); - } else { /* Currently not in array (may be an array extension)? */ - emitir(IRTGI(IR_ULE), asizeref, ikey); /* Inv. bounds check. */ - if (k == 0 && tref_isk(key)) - key = lj_ir_knum_zero(J); /* Canonicalize 0 or +-0.0 to +0.0. */ - /* And continue with the hash lookup. */ - } - } else if (!tref_isk(key)) { - /* We can rule out const numbers which failed the integerness test - ** above. But all other numbers are potential array keys. - */ - if (t->asize == 0) { /* True sparse tables have an empty array part. */ - /* Guard that the array part stays empty. */ - TRef tmp = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_ASIZE); - emitir(IRTGI(IR_EQ), tmp, lj_ir_kint(J, 0)); - } else { - lj_trace_err(J, LJ_TRERR_NYITMIX); - } - } - } - - /* Otherwise the key is located in the hash part. */ - if (t->hmask == 0) { /* Shortcut for empty hash part. */ - /* Guard that the hash part stays empty. */ - TRef tmp = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_HMASK); - emitir(IRTGI(IR_EQ), tmp, lj_ir_kint(J, 0)); - return lj_ir_kkptr(J, niltvg(J2G(J))); - } - if (tref_isinteger(key)) /* Hash keys are based on numbers, not ints. */ - key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT); - if (tref_isk(key)) { - /* Optimize lookup of constant hash keys. */ - MSize hslot = (MSize)((char *)ix->oldv - (char *)&noderef(t->node)[0].val); - if (t->hmask > 0 && hslot <= t->hmask*(MSize)sizeof(Node) && - hslot <= 65535*(MSize)sizeof(Node)) { - TRef node, kslot; - TRef hm = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_HMASK); - emitir(IRTGI(IR_EQ), hm, lj_ir_kint(J, (int32_t)t->hmask)); - node = emitir(IRT(IR_FLOAD, IRT_P32), ix->tab, IRFL_TAB_NODE); - kslot = lj_ir_kslot(J, key, hslot / sizeof(Node)); - return emitir(IRTG(IR_HREFK, IRT_P32), node, kslot); - } - } - /* Fall back to a regular hash lookup. */ - return emitir(IRT(IR_HREF, IRT_P32), ix->tab, key); -} - -/* Determine whether a key is NOT one of the fast metamethod names. */ -static int nommstr(jit_State *J, TRef key) -{ - if (tref_isstr(key)) { - if (tref_isk(key)) { - GCstr *str = ir_kstr(IR(tref_ref(key))); - uint32_t mm; - for (mm = 0; mm <= MM_FAST; mm++) - if (mmname_str(J2G(J), mm) == str) - return 0; /* MUST be one the fast metamethod names. */ - } else { - return 0; /* Variable string key MAY be a metamethod name. */ - } - } - return 1; /* CANNOT be a metamethod name. */ -} - -/* Record indexed load/store. */ -TRef lj_record_idx(jit_State *J, RecordIndex *ix) -{ - TRef xref; - IROp xrefop, loadop; - cTValue *oldv; - - while (!tref_istab(ix->tab)) { /* Handle non-table lookup. */ - /* Never call raw lj_record_idx() on non-table. */ - lua_assert(ix->idxchain != 0); - if (!lj_record_mm_lookup(J, ix, ix->val ? MM_newindex : MM_index)) - lj_trace_err(J, LJ_TRERR_NOMM); - handlemm: - if (tref_isfunc(ix->mobj)) { /* Handle metamethod call. */ - BCReg func = rec_mm_prep(J, ix->val ? lj_cont_nop : lj_cont_ra); - TRef *base = J->base + func; - TValue *tv = J->L->base + func; - base[0] = ix->mobj; base[1] = ix->tab; base[2] = ix->key; - setfuncV(J->L, tv+0, funcV(&ix->mobjv)); - copyTV(J->L, tv+1, &ix->tabv); - copyTV(J->L, tv+2, &ix->keyv); - if (ix->val) { - base[3] = ix->val; - copyTV(J->L, tv+3, &ix->valv); - lj_record_call(J, func, 3); /* mobj(tab, key, val) */ - return 0; - } else { - lj_record_call(J, func, 2); /* res = mobj(tab, key) */ - return 0; /* No result yet. */ - } - } - /* Otherwise retry lookup with metaobject. */ - ix->tab = ix->mobj; - copyTV(J->L, &ix->tabv, &ix->mobjv); - if (--ix->idxchain == 0) - lj_trace_err(J, LJ_TRERR_IDXLOOP); - } - - /* First catch nil and NaN keys for tables. */ - if (tvisnil(&ix->keyv) || (tvisnum(&ix->keyv) && tvisnan(&ix->keyv))) { - if (ix->val) /* Better fail early. */ - lj_trace_err(J, LJ_TRERR_STORENN); - if (tref_isk(ix->key)) { - if (ix->idxchain && lj_record_mm_lookup(J, ix, MM_index)) - goto handlemm; - return TREF_NIL; - } - } - - /* Record the key lookup. */ - xref = rec_idx_key(J, ix); - xrefop = IR(tref_ref(xref))->o; - loadop = xrefop == IR_AREF ? IR_ALOAD : IR_HLOAD; - /* The lj_meta_tset() inconsistency is gone, but better play safe. */ - oldv = xrefop == IR_KKPTR ? (cTValue *)ir_kptr(IR(tref_ref(xref))) : ix->oldv; - - if (ix->val == 0) { /* Indexed load */ - IRType t = itype2irt(oldv); - TRef res; - if (oldv == niltvg(J2G(J))) { - emitir(IRTG(IR_EQ, IRT_P32), xref, lj_ir_kkptr(J, niltvg(J2G(J)))); - res = TREF_NIL; - } else { - res = emitir(IRTG(loadop, t), xref, 0); - } - if (t == IRT_NIL && ix->idxchain && lj_record_mm_lookup(J, ix, MM_index)) - goto handlemm; - if (irtype_ispri(t)) res = TREF_PRI(t); /* Canonicalize primitives. */ - return res; - } else { /* Indexed store. */ - GCtab *mt = tabref(tabV(&ix->tabv)->metatable); - int keybarrier = tref_isgcv(ix->key) && !tref_isnil(ix->val); - if (tvisnil(oldv)) { /* Previous value was nil? */ - /* Need to duplicate the hasmm check for the early guards. */ - int hasmm = 0; - if (ix->idxchain && mt) { - cTValue *mo = lj_tab_getstr(mt, mmname_str(J2G(J), MM_newindex)); - hasmm = mo && !tvisnil(mo); - } - if (hasmm) - emitir(IRTG(loadop, IRT_NIL), xref, 0); /* Guard for nil value. */ - else if (xrefop == IR_HREF) - emitir(IRTG(oldv == niltvg(J2G(J)) ? IR_EQ : IR_NE, IRT_P32), - xref, lj_ir_kkptr(J, niltvg(J2G(J)))); - if (ix->idxchain && lj_record_mm_lookup(J, ix, MM_newindex)) { - lua_assert(hasmm); - goto handlemm; - } - lua_assert(!hasmm); - if (oldv == niltvg(J2G(J))) { /* Need to insert a new key. */ - TRef key = ix->key; - if (tref_isinteger(key)) /* NEWREF needs a TValue as a key. */ - key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT); - xref = emitir(IRT(IR_NEWREF, IRT_P32), ix->tab, key); - keybarrier = 0; /* NEWREF already takes care of the key barrier. */ - } - } else if (!lj_opt_fwd_wasnonnil(J, loadop, tref_ref(xref))) { - /* Cannot derive that the previous value was non-nil, must do checks. */ - if (xrefop == IR_HREF) /* Guard against store to niltv. */ - emitir(IRTG(IR_NE, IRT_P32), xref, lj_ir_kkptr(J, niltvg(J2G(J)))); - if (ix->idxchain) { /* Metamethod lookup required? */ - /* A check for NULL metatable is cheaper (hoistable) than a load. */ - if (!mt) { - TRef mtref = emitir(IRT(IR_FLOAD, IRT_TAB), ix->tab, IRFL_TAB_META); - emitir(IRTG(IR_EQ, IRT_TAB), mtref, lj_ir_knull(J, IRT_TAB)); - } else { - IRType t = itype2irt(oldv); - emitir(IRTG(loadop, t), xref, 0); /* Guard for non-nil value. */ - } - } - } else { - keybarrier = 0; /* Previous non-nil value kept the key alive. */ - } - /* Convert int to number before storing. */ - if (!LJ_DUALNUM && tref_isinteger(ix->val)) - ix->val = emitir(IRTN(IR_CONV), ix->val, IRCONV_NUM_INT); - emitir(IRT(loadop+IRDELTA_L2S, tref_type(ix->val)), xref, ix->val); - if (keybarrier || tref_isgcv(ix->val)) - emitir(IRT(IR_TBAR, IRT_NIL), ix->tab, 0); - /* Invalidate neg. metamethod cache for stores with certain string keys. */ - if (!nommstr(J, ix->key)) { - TRef fref = emitir(IRT(IR_FREF, IRT_P32), ix->tab, IRFL_TAB_NOMM); - emitir(IRT(IR_FSTORE, IRT_U8), fref, lj_ir_kint(J, 0)); - } - J->needsnap = 1; - return 0; - } -} - -/* -- Upvalue access ------------------------------------------------------ */ - -/* Check whether upvalue is immutable and ok to constify. */ -static int rec_upvalue_constify(jit_State *J, GCupval *uvp) -{ - if (uvp->immutable) { - cTValue *o = uvval(uvp); - /* Don't constify objects that may retain large amounts of memory. */ -#if LJ_HASFFI - if (tviscdata(o)) { - GCcdata *cd = cdataV(o); - if (!cdataisv(cd) && !(cd->marked & LJ_GC_CDATA_FIN)) { - CType *ct = ctype_raw(ctype_ctsG(J2G(J)), cd->ctypeid); - if (!ctype_hassize(ct->info) || ct->size <= 16) - return 1; - } - return 0; - } -#else - UNUSED(J); -#endif - if (!(tvistab(o) || tvisudata(o) || tvisthread(o))) - return 1; - } - return 0; -} - -/* Record upvalue load/store. */ -static TRef rec_upvalue(jit_State *J, uint32_t uv, TRef val) -{ - GCupval *uvp = &gcref(J->fn->l.uvptr[uv])->uv; - TRef fn = getcurrf(J); - IRRef uref; - int needbarrier = 0; - if (rec_upvalue_constify(J, uvp)) { /* Try to constify immutable upvalue. */ - TRef tr, kfunc; - lua_assert(val == 0); - if (!tref_isk(fn)) { /* Late specialization of current function. */ - if (J->pt->flags >= PROTO_CLC_POLY) - goto noconstify; - kfunc = lj_ir_kfunc(J, J->fn); - emitir(IRTG(IR_EQ, IRT_FUNC), fn, kfunc); - J->base[-1] = TREF_FRAME | kfunc; - fn = kfunc; - } - tr = lj_record_constify(J, uvval(uvp)); - if (tr) - return tr; - } -noconstify: - /* Note: this effectively limits LJ_MAX_UPVAL to 127. */ - uv = (uv << 8) | (hashrot(uvp->dhash, uvp->dhash + HASH_BIAS) & 0xff); - if (!uvp->closed) { - /* In current stack? */ - if (uvval(uvp) >= tvref(J->L->stack) && - uvval(uvp) < tvref(J->L->maxstack)) { - int32_t slot = (int32_t)(uvval(uvp) - (J->L->base - J->baseslot)); - if (slot >= 0) { /* Aliases an SSA slot? */ - slot -= (int32_t)J->baseslot; /* Note: slot number may be negative! */ - /* NYI: add IR to guard that it's still aliasing the same slot. */ - if (val == 0) { - return getslot(J, slot); - } else { - J->base[slot] = val; - if (slot >= (int32_t)J->maxslot) J->maxslot = (BCReg)(slot+1); - return 0; - } - } - } - uref = tref_ref(emitir(IRTG(IR_UREFO, IRT_P32), fn, uv)); - } else { - needbarrier = 1; - uref = tref_ref(emitir(IRTG(IR_UREFC, IRT_P32), fn, uv)); - } - if (val == 0) { /* Upvalue load */ - IRType t = itype2irt(uvval(uvp)); - TRef res = emitir(IRTG(IR_ULOAD, t), uref, 0); - if (irtype_ispri(t)) res = TREF_PRI(t); /* Canonicalize primitive refs. */ - return res; - } else { /* Upvalue store. */ - /* Convert int to number before storing. */ - if (!LJ_DUALNUM && tref_isinteger(val)) - val = emitir(IRTN(IR_CONV), val, IRCONV_NUM_INT); - emitir(IRT(IR_USTORE, tref_type(val)), uref, val); - if (needbarrier && tref_isgcv(val)) - emitir(IRT(IR_OBAR, IRT_NIL), uref, val); - J->needsnap = 1; - return 0; - } -} - -/* -- Record calls to Lua functions --------------------------------------- */ - -/* Check unroll limits for calls. */ -static void check_call_unroll(jit_State *J, TraceNo lnk) -{ - cTValue *frame = J->L->base - 1; - void *pc = mref(frame_func(frame)->l.pc, void); - int32_t depth = J->framedepth; - int32_t count = 0; - if ((J->pt->flags & PROTO_VARARG)) depth--; /* Vararg frame still missing. */ - for (; depth > 0; depth--) { /* Count frames with same prototype. */ - if (frame_iscont(frame)) depth--; - frame = frame_prev(frame); - if (mref(frame_func(frame)->l.pc, void) == pc) - count++; - } - if (J->pc == J->startpc) { - if (count + J->tailcalled > J->param[JIT_P_recunroll]) { - J->pc++; - if (J->framedepth + J->retdepth == 0) - rec_stop(J, LJ_TRLINK_TAILREC, J->cur.traceno); /* Tail-recursion. */ - else - rec_stop(J, LJ_TRLINK_UPREC, J->cur.traceno); /* Up-recursion. */ - } - } else { - if (count > J->param[JIT_P_callunroll]) { - if (lnk) { /* Possible tail- or up-recursion. */ - lj_trace_flush(J, lnk); /* Flush trace that only returns. */ - /* Set a small, pseudo-random hotcount for a quick retry of JFUNC*. */ - hotcount_set(J2GG(J), J->pc+1, LJ_PRNG_BITS(J, 4)); - } - lj_trace_err(J, LJ_TRERR_CUNROLL); - } - } -} - -/* Record Lua function setup. */ -static void rec_func_setup(jit_State *J) -{ - GCproto *pt = J->pt; - BCReg s, numparams = pt->numparams; - if ((pt->flags & PROTO_NOJIT)) - lj_trace_err(J, LJ_TRERR_CJITOFF); - if (J->baseslot + pt->framesize >= LJ_MAX_JSLOTS) - lj_trace_err(J, LJ_TRERR_STACKOV); - /* Fill up missing parameters with nil. */ - for (s = J->maxslot; s < numparams; s++) - J->base[s] = TREF_NIL; - /* The remaining slots should never be read before they are written. */ - J->maxslot = numparams; -} - -/* Record Lua vararg function setup. */ -static void rec_func_vararg(jit_State *J) -{ - GCproto *pt = J->pt; - BCReg s, fixargs, vframe = J->maxslot+1; - lua_assert((pt->flags & PROTO_VARARG)); - if (J->baseslot + vframe + pt->framesize >= LJ_MAX_JSLOTS) - lj_trace_err(J, LJ_TRERR_STACKOV); - J->base[vframe-1] = J->base[-1]; /* Copy function up. */ - /* Copy fixarg slots up and set their original slots to nil. */ - fixargs = pt->numparams < J->maxslot ? pt->numparams : J->maxslot; - for (s = 0; s < fixargs; s++) { - J->base[vframe+s] = J->base[s]; - J->base[s] = TREF_NIL; - } - J->maxslot = fixargs; - J->framedepth++; - J->base += vframe; - J->baseslot += vframe; -} - -/* Record entry to a Lua function. */ -static void rec_func_lua(jit_State *J) -{ - rec_func_setup(J); - check_call_unroll(J, 0); -} - -/* Record entry to an already compiled function. */ -static void rec_func_jit(jit_State *J, TraceNo lnk) -{ - GCtrace *T; - rec_func_setup(J); - T = traceref(J, lnk); - if (T->linktype == LJ_TRLINK_RETURN) { /* Trace returns to interpreter? */ - check_call_unroll(J, lnk); - /* Temporarily unpatch JFUNC* to continue recording across function. */ - J->patchins = *J->pc; - J->patchpc = (BCIns *)J->pc; - *J->patchpc = T->startins; - return; - } - J->instunroll = 0; /* Cannot continue across a compiled function. */ - if (J->pc == J->startpc && J->framedepth + J->retdepth == 0) - rec_stop(J, LJ_TRLINK_TAILREC, J->cur.traceno); /* Extra tail-recursion. */ - else - rec_stop(J, LJ_TRLINK_ROOT, lnk); /* Link to the function. */ -} - -/* -- Vararg handling ----------------------------------------------------- */ - -/* Detect y = select(x, ...) idiom. */ -static int select_detect(jit_State *J) -{ - BCIns ins = J->pc[1]; - if (bc_op(ins) == BC_CALLM && bc_b(ins) == 2 && bc_c(ins) == 1) { - cTValue *func = &J->L->base[bc_a(ins)]; - if (tvisfunc(func) && funcV(func)->c.ffid == FF_select) - return 1; - } - return 0; -} - -/* Record vararg instruction. */ -static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults) -{ - int32_t numparams = J->pt->numparams; - ptrdiff_t nvararg = frame_delta(J->L->base-1) - numparams - 1; - lua_assert(frame_isvarg(J->L->base-1)); - if (J->framedepth > 0) { /* Simple case: varargs defined on-trace. */ - ptrdiff_t i; - if (nvararg < 0) nvararg = 0; - if (nresults == -1) { - nresults = nvararg; - J->maxslot = dst + (BCReg)nvararg; - } else if (dst + nresults > J->maxslot) { - J->maxslot = dst + (BCReg)nresults; - } - for (i = 0; i < nresults; i++) - J->base[dst+i] = i < nvararg ? getslot(J, i - nvararg - 1) : TREF_NIL; - } else { /* Unknown number of varargs passed to trace. */ - TRef fr = emitir(IRTI(IR_SLOAD), 0, IRSLOAD_READONLY|IRSLOAD_FRAME); - int32_t frofs = 8*(1+numparams)+FRAME_VARG; - if (nresults >= 0) { /* Known fixed number of results. */ - ptrdiff_t i; - if (nvararg > 0) { - ptrdiff_t nload = nvararg >= nresults ? nresults : nvararg; - TRef vbase; - if (nvararg >= nresults) - emitir(IRTGI(IR_GE), fr, lj_ir_kint(J, frofs+8*(int32_t)nresults)); - else - emitir(IRTGI(IR_EQ), fr, lj_ir_kint(J, frame_ftsz(J->L->base-1))); - vbase = emitir(IRTI(IR_SUB), REF_BASE, fr); - vbase = emitir(IRT(IR_ADD, IRT_P32), vbase, lj_ir_kint(J, frofs-8)); - for (i = 0; i < nload; i++) { - IRType t = itype2irt(&J->L->base[i-1-nvararg]); - TRef aref = emitir(IRT(IR_AREF, IRT_P32), - vbase, lj_ir_kint(J, (int32_t)i)); - TRef tr = emitir(IRTG(IR_VLOAD, t), aref, 0); - if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */ - J->base[dst+i] = tr; - } - } else { - emitir(IRTGI(IR_LE), fr, lj_ir_kint(J, frofs)); - nvararg = 0; - } - for (i = nvararg; i < nresults; i++) - J->base[dst+i] = TREF_NIL; - if (dst + (BCReg)nresults > J->maxslot) - J->maxslot = dst + (BCReg)nresults; - } else if (select_detect(J)) { /* y = select(x, ...) */ - TRef tridx = J->base[dst-1]; - TRef tr = TREF_NIL; - ptrdiff_t idx = lj_ffrecord_select_mode(J, tridx, &J->L->base[dst-1]); - if (idx < 0) goto nyivarg; - if (idx != 0 && !tref_isinteger(tridx)) - tridx = emitir(IRTGI(IR_CONV), tridx, IRCONV_INT_NUM|IRCONV_INDEX); - if (idx != 0 && tref_isk(tridx)) { - emitir(IRTGI(idx <= nvararg ? IR_GE : IR_LT), - fr, lj_ir_kint(J, frofs+8*(int32_t)idx)); - frofs -= 8; /* Bias for 1-based index. */ - } else if (idx <= nvararg) { /* Compute size. */ - TRef tmp = emitir(IRTI(IR_ADD), fr, lj_ir_kint(J, -frofs)); - if (numparams) - emitir(IRTGI(IR_GE), tmp, lj_ir_kint(J, 0)); - tr = emitir(IRTI(IR_BSHR), tmp, lj_ir_kint(J, 3)); - if (idx != 0) { - tridx = emitir(IRTI(IR_ADD), tridx, lj_ir_kint(J, -1)); - rec_idx_abc(J, tr, tridx, (uint32_t)nvararg); - } - } else { - TRef tmp = lj_ir_kint(J, frofs); - if (idx != 0) { - TRef tmp2 = emitir(IRTI(IR_BSHL), tridx, lj_ir_kint(J, 3)); - tmp = emitir(IRTI(IR_ADD), tmp2, tmp); - } else { - tr = lj_ir_kint(J, 0); - } - emitir(IRTGI(IR_LT), fr, tmp); - } - if (idx != 0 && idx <= nvararg) { - IRType t; - TRef aref, vbase = emitir(IRTI(IR_SUB), REF_BASE, fr); - vbase = emitir(IRT(IR_ADD, IRT_P32), vbase, lj_ir_kint(J, frofs-8)); - t = itype2irt(&J->L->base[idx-2-nvararg]); - aref = emitir(IRT(IR_AREF, IRT_P32), vbase, tridx); - tr = emitir(IRTG(IR_VLOAD, t), aref, 0); - if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */ - } - J->base[dst-2] = tr; - J->maxslot = dst-1; - J->bcskip = 2; /* Skip CALLM + select. */ - } else { - nyivarg: - setintV(&J->errinfo, BC_VARG); - lj_trace_err_info(J, LJ_TRERR_NYIBC); - } - } -} - -/* -- Record allocations -------------------------------------------------- */ - -static TRef rec_tnew(jit_State *J, uint32_t ah) -{ - uint32_t asize = ah & 0x7ff; - uint32_t hbits = ah >> 11; - if (asize == 0x7ff) asize = 0x801; - return emitir(IRTG(IR_TNEW, IRT_TAB), asize, hbits); -} - -/* -- Record bytecode ops ------------------------------------------------- */ - -/* Prepare for comparison. */ -static void rec_comp_prep(jit_State *J) -{ - /* Prevent merging with snapshot #0 (GC exit) since we fixup the PC. */ - if (J->cur.nsnap == 1 && J->cur.snap[0].ref == J->cur.nins) - emitir_raw(IRT(IR_NOP, IRT_NIL), 0, 0); - lj_snap_add(J); -} - -/* Fixup comparison. */ -static void rec_comp_fixup(jit_State *J, const BCIns *pc, int cond) -{ - BCIns jmpins = pc[1]; - const BCIns *npc = pc + 2 + (cond ? bc_j(jmpins) : 0); - SnapShot *snap = &J->cur.snap[J->cur.nsnap-1]; - /* Set PC to opposite target to avoid re-recording the comp. in side trace. */ - J->cur.snapmap[snap->mapofs + snap->nent] = SNAP_MKPC(npc); - J->needsnap = 1; - if (bc_a(jmpins) < J->maxslot) J->maxslot = bc_a(jmpins); - lj_snap_shrink(J); /* Shrink last snapshot if possible. */ -} - -/* Record the next bytecode instruction (_before_ it's executed). */ -void lj_record_ins(jit_State *J) -{ - cTValue *lbase; - RecordIndex ix; - const BCIns *pc; - BCIns ins; - BCOp op; - TRef ra, rb, rc; - - /* Perform post-processing action before recording the next instruction. */ - if (LJ_UNLIKELY(J->postproc != LJ_POST_NONE)) { - switch (J->postproc) { - case LJ_POST_FIXCOMP: /* Fixup comparison. */ - pc = frame_pc(&J2G(J)->tmptv); - rec_comp_fixup(J, pc, (!tvistruecond(&J2G(J)->tmptv2) ^ (bc_op(*pc)&1))); - /* fallthrough */ - case LJ_POST_FIXGUARD: /* Fixup and emit pending guard. */ - case LJ_POST_FIXGUARDSNAP: /* Fixup and emit pending guard and snapshot. */ - if (!tvistruecond(&J2G(J)->tmptv2)) { - J->fold.ins.o ^= 1; /* Flip guard to opposite. */ - if (J->postproc == LJ_POST_FIXGUARDSNAP) { - SnapShot *snap = &J->cur.snap[J->cur.nsnap-1]; - J->cur.snapmap[snap->mapofs+snap->nent-1]--; /* False -> true. */ - } - } - lj_opt_fold(J); /* Emit pending guard. */ - /* fallthrough */ - case LJ_POST_FIXBOOL: - if (!tvistruecond(&J2G(J)->tmptv2)) { - BCReg s; - TValue *tv = J->L->base; - for (s = 0; s < J->maxslot; s++) /* Fixup stack slot (if any). */ - if (J->base[s] == TREF_TRUE && tvisfalse(&tv[s])) { - J->base[s] = TREF_FALSE; - break; - } - } - break; - case LJ_POST_FIXCONST: - { - BCReg s; - TValue *tv = J->L->base; - for (s = 0; s < J->maxslot; s++) /* Constify stack slots (if any). */ - if (J->base[s] == TREF_NIL && !tvisnil(&tv[s])) - J->base[s] = lj_record_constify(J, &tv[s]); - } - break; - case LJ_POST_FFRETRY: /* Suppress recording of retried fast function. */ - if (bc_op(*J->pc) >= BC__MAX) - return; - break; - default: lua_assert(0); break; - } - J->postproc = LJ_POST_NONE; - } - - /* Need snapshot before recording next bytecode (e.g. after a store). */ - if (J->needsnap) { - J->needsnap = 0; - lj_snap_purge(J); - lj_snap_add(J); - J->mergesnap = 1; - } - - /* Skip some bytecodes. */ - if (LJ_UNLIKELY(J->bcskip > 0)) { - J->bcskip--; - return; - } - - /* Record only closed loops for root traces. */ - pc = J->pc; - if (J->framedepth == 0 && - (MSize)((char *)pc - (char *)J->bc_min) >= J->bc_extent) - lj_trace_err(J, LJ_TRERR_LLEAVE); - -#ifdef LUA_USE_ASSERT - rec_check_slots(J); - rec_check_ir(J); -#endif - - /* Keep a copy of the runtime values of var/num/str operands. */ -#define rav (&ix.valv) -#define rbv (&ix.tabv) -#define rcv (&ix.keyv) - - lbase = J->L->base; - ins = *pc; - op = bc_op(ins); - ra = bc_a(ins); - ix.val = 0; - switch (bcmode_a(op)) { - case BCMvar: - copyTV(J->L, rav, &lbase[ra]); ix.val = ra = getslot(J, ra); break; - default: break; /* Handled later. */ - } - rb = bc_b(ins); - rc = bc_c(ins); - switch (bcmode_b(op)) { - case BCMnone: rb = 0; rc = bc_d(ins); break; /* Upgrade rc to 'rd'. */ - case BCMvar: - copyTV(J->L, rbv, &lbase[rb]); ix.tab = rb = getslot(J, rb); break; - default: break; /* Handled later. */ - } - switch (bcmode_c(op)) { - case BCMvar: - copyTV(J->L, rcv, &lbase[rc]); ix.key = rc = getslot(J, rc); break; - case BCMpri: setitype(rcv, ~rc); ix.key = rc = TREF_PRI(IRT_NIL+rc); break; - case BCMnum: { cTValue *tv = proto_knumtv(J->pt, rc); - copyTV(J->L, rcv, tv); ix.key = rc = tvisint(tv) ? lj_ir_kint(J, intV(tv)) : - lj_ir_knumint(J, numV(tv)); } break; - case BCMstr: { GCstr *s = gco2str(proto_kgc(J->pt, ~(ptrdiff_t)rc)); - setstrV(J->L, rcv, s); ix.key = rc = lj_ir_kstr(J, s); } break; - default: break; /* Handled later. */ - } - - switch (op) { - - /* -- Comparison ops ---------------------------------------------------- */ - - case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: -#if LJ_HASFFI - if (tref_iscdata(ra) || tref_iscdata(rc)) { - rec_mm_comp_cdata(J, &ix, op, ((int)op & 2) ? MM_le : MM_lt); - break; - } -#endif - /* Emit nothing for two numeric or string consts. */ - if (!(tref_isk2(ra,rc) && tref_isnumber_str(ra) && tref_isnumber_str(rc))) { - IRType ta = tref_isinteger(ra) ? IRT_INT : tref_type(ra); - IRType tc = tref_isinteger(rc) ? IRT_INT : tref_type(rc); - int irop; - if (ta != tc) { - /* Widen mixed number/int comparisons to number/number comparison. */ - if (ta == IRT_INT && tc == IRT_NUM) { - ra = emitir(IRTN(IR_CONV), ra, IRCONV_NUM_INT); - ta = IRT_NUM; - } else if (ta == IRT_NUM && tc == IRT_INT) { - rc = emitir(IRTN(IR_CONV), rc, IRCONV_NUM_INT); - } else if (LJ_52) { - ta = IRT_NIL; /* Force metamethod for different types. */ - } else if (!((ta == IRT_FALSE || ta == IRT_TRUE) && - (tc == IRT_FALSE || tc == IRT_TRUE))) { - break; /* Interpreter will throw for two different types. */ - } - } - rec_comp_prep(J); - irop = (int)op - (int)BC_ISLT + (int)IR_LT; - if (ta == IRT_NUM) { - if ((irop & 1)) irop ^= 4; /* ISGE/ISGT are unordered. */ - if (!lj_ir_numcmp(numberVnum(rav), numberVnum(rcv), (IROp)irop)) - irop ^= 5; - } else if (ta == IRT_INT) { - if (!lj_ir_numcmp(numberVnum(rav), numberVnum(rcv), (IROp)irop)) - irop ^= 1; - } else if (ta == IRT_STR) { - if (!lj_ir_strcmp(strV(rav), strV(rcv), (IROp)irop)) irop ^= 1; - ra = lj_ir_call(J, IRCALL_lj_str_cmp, ra, rc); - rc = lj_ir_kint(J, 0); - ta = IRT_INT; - } else { - rec_mm_comp(J, &ix, (int)op); - break; - } - emitir(IRTG(irop, ta), ra, rc); - rec_comp_fixup(J, J->pc, ((int)op ^ irop) & 1); - } - break; - - case BC_ISEQV: case BC_ISNEV: - case BC_ISEQS: case BC_ISNES: - case BC_ISEQN: case BC_ISNEN: - case BC_ISEQP: case BC_ISNEP: -#if LJ_HASFFI - if (tref_iscdata(ra) || tref_iscdata(rc)) { - rec_mm_comp_cdata(J, &ix, op, MM_eq); - break; - } -#endif - /* Emit nothing for two non-table, non-udata consts. */ - if (!(tref_isk2(ra, rc) && !(tref_istab(ra) || tref_isudata(ra)))) { - int diff; - rec_comp_prep(J); - diff = lj_record_objcmp(J, ra, rc, rav, rcv); - if (diff == 2 || !(tref_istab(ra) || tref_isudata(ra))) - rec_comp_fixup(J, J->pc, ((int)op & 1) == !diff); - else if (diff == 1) /* Only check __eq if different, but same type. */ - rec_mm_equal(J, &ix, (int)op); - } - break; - - /* -- Unary test and copy ops ------------------------------------------- */ - - case BC_ISTC: case BC_ISFC: - if ((op & 1) == tref_istruecond(rc)) - rc = 0; /* Don't store if condition is not true. */ - /* fallthrough */ - case BC_IST: case BC_ISF: /* Type specialization suffices. */ - if (bc_a(pc[1]) < J->maxslot) - J->maxslot = bc_a(pc[1]); /* Shrink used slots. */ - break; - - /* -- Unary ops --------------------------------------------------------- */ - - case BC_NOT: - /* Type specialization already forces const result. */ - rc = tref_istruecond(rc) ? TREF_FALSE : TREF_TRUE; - break; - - case BC_LEN: - if (tref_isstr(rc)) - rc = emitir(IRTI(IR_FLOAD), rc, IRFL_STR_LEN); - else if (!LJ_52 && tref_istab(rc)) - rc = lj_ir_call(J, IRCALL_lj_tab_len, rc); - else - rc = rec_mm_len(J, rc, rcv); - break; - - /* -- Arithmetic ops ---------------------------------------------------- */ - - case BC_UNM: - if (tref_isnumber_str(rc)) { - rc = lj_opt_narrow_unm(J, rc, rcv); - } else { - ix.tab = rc; - copyTV(J->L, &ix.tabv, rcv); - rc = rec_mm_arith(J, &ix, MM_unm); - } - break; - - case BC_ADDNV: case BC_SUBNV: case BC_MULNV: case BC_DIVNV: case BC_MODNV: - /* Swap rb/rc and rbv/rcv. rav is temp. */ - ix.tab = rc; ix.key = rc = rb; rb = ix.tab; - copyTV(J->L, rav, rbv); - copyTV(J->L, rbv, rcv); - copyTV(J->L, rcv, rav); - if (op == BC_MODNV) - goto recmod; - /* fallthrough */ - case BC_ADDVN: case BC_SUBVN: case BC_MULVN: case BC_DIVVN: - case BC_ADDVV: case BC_SUBVV: case BC_MULVV: case BC_DIVVV: { - MMS mm = bcmode_mm(op); - if (tref_isnumber_str(rb) && tref_isnumber_str(rc)) - rc = lj_opt_narrow_arith(J, rb, rc, rbv, rcv, - (int)mm - (int)MM_add + (int)IR_ADD); - else - rc = rec_mm_arith(J, &ix, mm); - break; - } - - case BC_MODVN: case BC_MODVV: - recmod: - if (tref_isnumber_str(rb) && tref_isnumber_str(rc)) - rc = lj_opt_narrow_mod(J, rb, rc, rcv); - else - rc = rec_mm_arith(J, &ix, MM_mod); - break; - - case BC_POW: - if (tref_isnumber_str(rb) && tref_isnumber_str(rc)) - rc = lj_opt_narrow_pow(J, lj_ir_tonum(J, rb), rc, rcv); - else - rc = rec_mm_arith(J, &ix, MM_pow); - break; - - /* -- Constant and move ops --------------------------------------------- */ - - case BC_MOV: - /* Clear gap of method call to avoid resurrecting previous refs. */ - if (ra > J->maxslot) J->base[ra-1] = 0; - break; - case BC_KSTR: case BC_KNUM: case BC_KPRI: - break; - case BC_KSHORT: - rc = lj_ir_kint(J, (int32_t)(int16_t)rc); - break; - case BC_KNIL: - while (ra <= rc) - J->base[ra++] = TREF_NIL; - if (rc >= J->maxslot) J->maxslot = rc+1; - break; -#if LJ_HASFFI - case BC_KCDATA: - rc = lj_ir_kgc(J, proto_kgc(J->pt, ~(ptrdiff_t)rc), IRT_CDATA); - break; -#endif - - /* -- Upvalue and function ops ------------------------------------------ */ - - case BC_UGET: - rc = rec_upvalue(J, rc, 0); - break; - case BC_USETV: case BC_USETS: case BC_USETN: case BC_USETP: - rec_upvalue(J, ra, rc); - break; - - /* -- Table ops --------------------------------------------------------- */ - - case BC_GGET: case BC_GSET: - settabV(J->L, &ix.tabv, tabref(J->fn->l.env)); - ix.tab = emitir(IRT(IR_FLOAD, IRT_TAB), getcurrf(J), IRFL_FUNC_ENV); - ix.idxchain = LJ_MAX_IDXCHAIN; - rc = lj_record_idx(J, &ix); - break; - - case BC_TGETB: case BC_TSETB: - setintV(&ix.keyv, (int32_t)rc); - ix.key = lj_ir_kint(J, (int32_t)rc); - /* fallthrough */ - case BC_TGETV: case BC_TGETS: case BC_TSETV: case BC_TSETS: - ix.idxchain = LJ_MAX_IDXCHAIN; - rc = lj_record_idx(J, &ix); - break; - - case BC_TNEW: - rc = rec_tnew(J, rc); - break; - case BC_TDUP: - rc = emitir(IRTG(IR_TDUP, IRT_TAB), - lj_ir_ktab(J, gco2tab(proto_kgc(J->pt, ~(ptrdiff_t)rc))), 0); - break; - - /* -- Calls and vararg handling ----------------------------------------- */ - - case BC_ITERC: - J->base[ra] = getslot(J, ra-3); - J->base[ra+1] = getslot(J, ra-2); - J->base[ra+2] = getslot(J, ra-1); - { /* Do the actual copy now because lj_record_call needs the values. */ - TValue *b = &J->L->base[ra]; - copyTV(J->L, b, b-3); - copyTV(J->L, b+1, b-2); - copyTV(J->L, b+2, b-1); - } - lj_record_call(J, ra, (ptrdiff_t)rc-1); - break; - - /* L->top is set to L->base+ra+rc+NARGS-1+1. See lj_dispatch_ins(). */ - case BC_CALLM: - rc = (BCReg)(J->L->top - J->L->base) - ra; - /* fallthrough */ - case BC_CALL: - lj_record_call(J, ra, (ptrdiff_t)rc-1); - break; - - case BC_CALLMT: - rc = (BCReg)(J->L->top - J->L->base) - ra; - /* fallthrough */ - case BC_CALLT: - lj_record_tailcall(J, ra, (ptrdiff_t)rc-1); - break; - - case BC_VARG: - rec_varg(J, ra, (ptrdiff_t)rb-1); - break; - - /* -- Returns ----------------------------------------------------------- */ - - case BC_RETM: - /* L->top is set to L->base+ra+rc+NRESULTS-1, see lj_dispatch_ins(). */ - rc = (BCReg)(J->L->top - J->L->base) - ra + 1; - /* fallthrough */ - case BC_RET: case BC_RET0: case BC_RET1: - lj_record_ret(J, ra, (ptrdiff_t)rc-1); - break; - - /* -- Loops and branches ------------------------------------------------ */ - - case BC_FORI: - if (rec_for(J, pc, 0) != LOOPEV_LEAVE) - J->loopref = J->cur.nins; - break; - case BC_JFORI: - lua_assert(bc_op(pc[(ptrdiff_t)rc-BCBIAS_J]) == BC_JFORL); - if (rec_for(J, pc, 0) != LOOPEV_LEAVE) /* Link to existing loop. */ - rec_stop(J, LJ_TRLINK_ROOT, bc_d(pc[(ptrdiff_t)rc-BCBIAS_J])); - /* Continue tracing if the loop is not entered. */ - break; - - case BC_FORL: - rec_loop_interp(J, pc, rec_for(J, pc+((ptrdiff_t)rc-BCBIAS_J), 1)); - break; - case BC_ITERL: - rec_loop_interp(J, pc, rec_iterl(J, *pc)); - break; - case BC_LOOP: - rec_loop_interp(J, pc, rec_loop(J, ra)); - break; - - case BC_JFORL: - rec_loop_jit(J, rc, rec_for(J, pc+bc_j(traceref(J, rc)->startins), 1)); - break; - case BC_JITERL: - rec_loop_jit(J, rc, rec_iterl(J, traceref(J, rc)->startins)); - break; - case BC_JLOOP: - rec_loop_jit(J, rc, rec_loop(J, ra)); - break; - - case BC_IFORL: - case BC_IITERL: - case BC_ILOOP: - case BC_IFUNCF: - case BC_IFUNCV: - lj_trace_err(J, LJ_TRERR_BLACKL); - break; - - case BC_JMP: - if (ra < J->maxslot) - J->maxslot = ra; /* Shrink used slots. */ - break; - - /* -- Function headers -------------------------------------------------- */ - - case BC_FUNCF: - rec_func_lua(J); - break; - case BC_JFUNCF: - rec_func_jit(J, rc); - break; - - case BC_FUNCV: - rec_func_vararg(J); - rec_func_lua(J); - break; - case BC_JFUNCV: - lua_assert(0); /* Cannot happen. No hotcall counting for varag funcs. */ - break; - - case BC_FUNCC: - case BC_FUNCCW: - lj_ffrecord_func(J); - break; - - default: - if (op >= BC__MAX) { - lj_ffrecord_func(J); - break; - } - /* fallthrough */ - case BC_ITERN: - case BC_ISNEXT: - case BC_CAT: - case BC_UCLO: - case BC_FNEW: - case BC_TSETM: - setintV(&J->errinfo, (int32_t)op); - lj_trace_err_info(J, LJ_TRERR_NYIBC); - break; - } - - /* rc == 0 if we have no result yet, e.g. pending __index metamethod call. */ - if (bcmode_a(op) == BCMdst && rc) { - J->base[ra] = rc; - if (ra >= J->maxslot) J->maxslot = ra+1; - } - -#undef rav -#undef rbv -#undef rcv - - /* Limit the number of recorded IR instructions. */ - if (J->cur.nins > REF_FIRST+(IRRef)J->param[JIT_P_maxrecord]) - lj_trace_err(J, LJ_TRERR_TRACEOV); -} - -/* -- Recording setup ----------------------------------------------------- */ - -/* Setup recording for a root trace started by a hot loop. */ -static const BCIns *rec_setup_root(jit_State *J) -{ - /* Determine the next PC and the bytecode range for the loop. */ - const BCIns *pcj, *pc = J->pc; - BCIns ins = *pc; - BCReg ra = bc_a(ins); - switch (bc_op(ins)) { - case BC_FORL: - J->bc_extent = (MSize)(-bc_j(ins))*sizeof(BCIns); - pc += 1+bc_j(ins); - J->bc_min = pc; - break; - case BC_ITERL: - lua_assert(bc_op(pc[-1]) == BC_ITERC); - J->maxslot = ra + bc_b(pc[-1]) - 1; - J->bc_extent = (MSize)(-bc_j(ins))*sizeof(BCIns); - pc += 1+bc_j(ins); - lua_assert(bc_op(pc[-1]) == BC_JMP); - J->bc_min = pc; - break; - case BC_LOOP: - /* Only check BC range for real loops, but not for "repeat until true". */ - pcj = pc + bc_j(ins); - ins = *pcj; - if (bc_op(ins) == BC_JMP && bc_j(ins) < 0) { - J->bc_min = pcj+1 + bc_j(ins); - J->bc_extent = (MSize)(-bc_j(ins))*sizeof(BCIns); - } - J->maxslot = ra; - pc++; - break; - case BC_RET: - case BC_RET0: - case BC_RET1: - /* No bytecode range check for down-recursive root traces. */ - J->maxslot = ra + bc_d(ins) - 1; - break; - case BC_FUNCF: - /* No bytecode range check for root traces started by a hot call. */ - J->maxslot = J->pt->numparams; - pc++; - break; - default: - lua_assert(0); - break; - } - return pc; -} - -/* Setup for recording a new trace. */ -void lj_record_setup(jit_State *J) -{ - uint32_t i; - - /* Initialize state related to current trace. */ - memset(J->slot, 0, sizeof(J->slot)); - memset(J->chain, 0, sizeof(J->chain)); - memset(J->bpropcache, 0, sizeof(J->bpropcache)); - J->scev.idx = REF_NIL; - - J->baseslot = 1; /* Invoking function is at base[-1]. */ - J->base = J->slot + J->baseslot; - J->maxslot = 0; - J->framedepth = 0; - J->retdepth = 0; - - J->instunroll = J->param[JIT_P_instunroll]; - J->loopunroll = J->param[JIT_P_loopunroll]; - J->tailcalled = 0; - J->loopref = 0; - - J->bc_min = NULL; /* Means no limit. */ - J->bc_extent = ~(MSize)0; - - /* Emit instructions for fixed references. Also triggers initial IR alloc. */ - emitir_raw(IRT(IR_BASE, IRT_P32), J->parent, J->exitno); - for (i = 0; i <= 2; i++) { - IRIns *ir = IR(REF_NIL-i); - ir->i = 0; - ir->t.irt = (uint8_t)(IRT_NIL+i); - ir->o = IR_KPRI; - ir->prev = 0; - } - J->cur.nk = REF_TRUE; - - J->startpc = J->pc; - setmref(J->cur.startpc, J->pc); - if (J->parent) { /* Side trace. */ - GCtrace *T = traceref(J, J->parent); - TraceNo root = T->root ? T->root : J->parent; - J->cur.root = (uint16_t)root; - J->cur.startins = BCINS_AD(BC_JMP, 0, 0); - /* Check whether we could at least potentially form an extra loop. */ - if (J->exitno == 0 && T->snap[0].nent == 0) { - /* We can narrow a FORL for some side traces, too. */ - if (J->pc > proto_bc(J->pt) && bc_op(J->pc[-1]) == BC_JFORI && - bc_d(J->pc[bc_j(J->pc[-1])-1]) == root) { - lj_snap_add(J); - rec_for_loop(J, J->pc-1, &J->scev, 1); - goto sidecheck; - } - } else { - J->startpc = NULL; /* Prevent forming an extra loop. */ - } - lj_snap_replay(J, T); - sidecheck: - if (traceref(J, J->cur.root)->nchild >= J->param[JIT_P_maxside] || - T->snap[J->exitno].count >= J->param[JIT_P_hotexit] + - J->param[JIT_P_tryside]) { - rec_stop(J, LJ_TRLINK_INTERP, 0); - } - } else { /* Root trace. */ - J->cur.root = 0; - J->cur.startins = *J->pc; - J->pc = rec_setup_root(J); - /* Note: the loop instruction itself is recorded at the end and not - ** at the start! So snapshot #0 needs to point to the *next* instruction. - */ - lj_snap_add(J); - if (bc_op(J->cur.startins) == BC_FORL) - rec_for_loop(J, J->pc-1, &J->scev, 1); - if (1 + J->pt->framesize >= LJ_MAX_JSLOTS) - lj_trace_err(J, LJ_TRERR_STACKOV); - } -#ifdef LUAJIT_ENABLE_CHECKHOOK - /* Regularly check for instruction/line hooks from compiled code and - ** exit to the interpreter if the hooks are set. - ** - ** This is a compile-time option and disabled by default, since the - ** hook checks may be quite expensive in tight loops. - ** - ** Note this is only useful if hooks are *not* set most of the time. - ** Use this only if you want to *asynchronously* interrupt the execution. - ** - ** You can set the instruction hook via lua_sethook() with a count of 1 - ** from a signal handler or another native thread. Please have a look - ** at the first few functions in luajit.c for an example (Ctrl-C handler). - */ - { - TRef tr = emitir(IRT(IR_XLOAD, IRT_U8), - lj_ir_kptr(J, &J2G(J)->hookmask), IRXLOAD_VOLATILE); - tr = emitir(IRTI(IR_BAND), tr, lj_ir_kint(J, (LUA_MASKLINE|LUA_MASKCOUNT))); - emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, 0)); - } -#endif -} - -#undef IR -#undef emitir_raw -#undef emitir - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_record.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_record.h deleted file mode 100644 index 940e105fb..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_record.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -** Trace recorder (bytecode -> SSA IR). -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_RECORD_H -#define _LJ_RECORD_H - -#include "lj_obj.h" -#include "lj_jit.h" - -#if LJ_HASJIT -/* Context for recording an indexed load/store. */ -typedef struct RecordIndex { - TValue tabv; /* Runtime value of table (or indexed object). */ - TValue keyv; /* Runtime value of key. */ - TValue valv; /* Runtime value of stored value. */ - TValue mobjv; /* Runtime value of metamethod object. */ - GCtab *mtv; /* Runtime value of metatable object. */ - cTValue *oldv; /* Runtime value of previously stored value. */ - TRef tab; /* Table (or indexed object) reference. */ - TRef key; /* Key reference. */ - TRef val; /* Value reference for a store or 0 for a load. */ - TRef mt; /* Metatable reference. */ - TRef mobj; /* Metamethod object reference. */ - int idxchain; /* Index indirections left or 0 for raw lookup. */ -} RecordIndex; - -LJ_FUNC int lj_record_objcmp(jit_State *J, TRef a, TRef b, - cTValue *av, cTValue *bv); -LJ_FUNC TRef lj_record_constify(jit_State *J, cTValue *o); - -LJ_FUNC void lj_record_call(jit_State *J, BCReg func, ptrdiff_t nargs); -LJ_FUNC void lj_record_tailcall(jit_State *J, BCReg func, ptrdiff_t nargs); -LJ_FUNC void lj_record_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults); - -LJ_FUNC int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm); -LJ_FUNC TRef lj_record_idx(jit_State *J, RecordIndex *ix); - -LJ_FUNC void lj_record_ins(jit_State *J); -LJ_FUNC void lj_record_setup(jit_State *J); -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_snap.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_snap.c deleted file mode 100644 index 1c978c26a..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_snap.c +++ /dev/null @@ -1,865 +0,0 @@ -/* -** Snapshot handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_snap_c -#define LUA_CORE - -#include "lj_obj.h" - -#if LJ_HASJIT - -#include "lj_gc.h" -#include "lj_tab.h" -#include "lj_state.h" -#include "lj_frame.h" -#include "lj_bc.h" -#include "lj_ir.h" -#include "lj_jit.h" -#include "lj_iropt.h" -#include "lj_trace.h" -#include "lj_snap.h" -#include "lj_target.h" -#if LJ_HASFFI -#include "lj_ctype.h" -#include "lj_cdata.h" -#endif - -/* Some local macros to save typing. Undef'd at the end. */ -#define IR(ref) (&J->cur.ir[(ref)]) - -/* Pass IR on to next optimization in chain (FOLD). */ -#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) - -/* Emit raw IR without passing through optimizations. */ -#define emitir_raw(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_ir_emit(J)) - -/* -- Snapshot buffer allocation ------------------------------------------ */ - -/* Grow snapshot buffer. */ -void lj_snap_grow_buf_(jit_State *J, MSize need) -{ - MSize maxsnap = (MSize)J->param[JIT_P_maxsnap]; - if (need > maxsnap) - lj_trace_err(J, LJ_TRERR_SNAPOV); - lj_mem_growvec(J->L, J->snapbuf, J->sizesnap, maxsnap, SnapShot); - J->cur.snap = J->snapbuf; -} - -/* Grow snapshot map buffer. */ -void lj_snap_grow_map_(jit_State *J, MSize need) -{ - if (need < 2*J->sizesnapmap) - need = 2*J->sizesnapmap; - else if (need < 64) - need = 64; - J->snapmapbuf = (SnapEntry *)lj_mem_realloc(J->L, J->snapmapbuf, - J->sizesnapmap*sizeof(SnapEntry), need*sizeof(SnapEntry)); - J->cur.snapmap = J->snapmapbuf; - J->sizesnapmap = need; -} - -/* -- Snapshot generation ------------------------------------------------- */ - -/* Add all modified slots to the snapshot. */ -static MSize snapshot_slots(jit_State *J, SnapEntry *map, BCReg nslots) -{ - IRRef retf = J->chain[IR_RETF]; /* Limits SLOAD restore elimination. */ - BCReg s; - MSize n = 0; - for (s = 0; s < nslots; s++) { - TRef tr = J->slot[s]; - IRRef ref = tref_ref(tr); - if (ref) { - SnapEntry sn = SNAP_TR(s, tr); - IRIns *ir = IR(ref); - if (!(sn & (SNAP_CONT|SNAP_FRAME)) && - ir->o == IR_SLOAD && ir->op1 == s && ref > retf) { - /* No need to snapshot unmodified non-inherited slots. */ - if (!(ir->op2 & IRSLOAD_INHERIT)) - continue; - /* No need to restore readonly slots and unmodified non-parent slots. */ - if (!(LJ_DUALNUM && (ir->op2 & IRSLOAD_CONVERT)) && - (ir->op2 & (IRSLOAD_READONLY|IRSLOAD_PARENT)) != IRSLOAD_PARENT) - sn |= SNAP_NORESTORE; - } - if (LJ_SOFTFP && irt_isnum(ir->t)) - sn |= SNAP_SOFTFPNUM; - map[n++] = sn; - } - } - return n; -} - -/* Add frame links at the end of the snapshot. */ -static BCReg snapshot_framelinks(jit_State *J, SnapEntry *map) -{ - cTValue *frame = J->L->base - 1; - cTValue *lim = J->L->base - J->baseslot; - cTValue *ftop = frame + funcproto(frame_func(frame))->framesize; - MSize f = 0; - map[f++] = SNAP_MKPC(J->pc); /* The current PC is always the first entry. */ - while (frame > lim) { /* Backwards traversal of all frames above base. */ - if (frame_islua(frame)) { - map[f++] = SNAP_MKPC(frame_pc(frame)); - frame = frame_prevl(frame); - if (frame + funcproto(frame_func(frame))->framesize > ftop) - ftop = frame + funcproto(frame_func(frame))->framesize; - } else if (frame_iscont(frame)) { - map[f++] = SNAP_MKFTSZ(frame_ftsz(frame)); - map[f++] = SNAP_MKPC(frame_contpc(frame)); - frame = frame_prevd(frame); - } else { - lua_assert(!frame_isc(frame)); - map[f++] = SNAP_MKFTSZ(frame_ftsz(frame)); - frame = frame_prevd(frame); - } - } - lua_assert(f == (MSize)(1 + J->framedepth)); - return (BCReg)(ftop - lim); -} - -/* Take a snapshot of the current stack. */ -static void snapshot_stack(jit_State *J, SnapShot *snap, MSize nsnapmap) -{ - BCReg nslots = J->baseslot + J->maxslot; - MSize nent; - SnapEntry *p; - /* Conservative estimate. */ - lj_snap_grow_map(J, nsnapmap + nslots + (MSize)J->framedepth+1); - p = &J->cur.snapmap[nsnapmap]; - nent = snapshot_slots(J, p, nslots); - snap->topslot = (uint8_t)snapshot_framelinks(J, p + nent); - snap->mapofs = (uint16_t)nsnapmap; - snap->ref = (IRRef1)J->cur.nins; - snap->nent = (uint8_t)nent; - snap->nslots = (uint8_t)nslots; - snap->count = 0; - J->cur.nsnapmap = (uint16_t)(nsnapmap + nent + 1 + J->framedepth); -} - -/* Add or merge a snapshot. */ -void lj_snap_add(jit_State *J) -{ - MSize nsnap = J->cur.nsnap; - MSize nsnapmap = J->cur.nsnapmap; - /* Merge if no ins. inbetween or if requested and no guard inbetween. */ - if (J->mergesnap ? !irt_isguard(J->guardemit) : - (nsnap > 0 && J->cur.snap[nsnap-1].ref == J->cur.nins)) { - if (nsnap == 1) { /* But preserve snap #0 PC. */ - emitir_raw(IRT(IR_NOP, IRT_NIL), 0, 0); - goto nomerge; - } - nsnapmap = J->cur.snap[--nsnap].mapofs; - } else { - nomerge: - lj_snap_grow_buf(J, nsnap+1); - J->cur.nsnap = (uint16_t)(nsnap+1); - } - J->mergesnap = 0; - J->guardemit.irt = 0; - snapshot_stack(J, &J->cur.snap[nsnap], nsnapmap); -} - -/* -- Snapshot modification ----------------------------------------------- */ - -#define SNAP_USEDEF_SLOTS (LJ_MAX_JSLOTS+LJ_STACK_EXTRA) - -/* Find unused slots with reaching-definitions bytecode data-flow analysis. */ -static BCReg snap_usedef(jit_State *J, uint8_t *udf, - const BCIns *pc, BCReg maxslot) -{ - BCReg s; - GCobj *o; - - if (maxslot == 0) return 0; -#ifdef LUAJIT_USE_VALGRIND - /* Avoid errors for harmless reads beyond maxslot. */ - memset(udf, 1, SNAP_USEDEF_SLOTS); -#else - memset(udf, 1, maxslot); -#endif - - /* Treat open upvalues as used. */ - o = gcref(J->L->openupval); - while (o) { - if (uvval(gco2uv(o)) < J->L->base) break; - udf[uvval(gco2uv(o)) - J->L->base] = 0; - o = gcref(o->gch.nextgc); - } - -#define USE_SLOT(s) udf[(s)] &= ~1 -#define DEF_SLOT(s) udf[(s)] *= 3 - - /* Scan through following bytecode and check for uses/defs. */ - lua_assert(pc >= proto_bc(J->pt) && pc < proto_bc(J->pt) + J->pt->sizebc); - for (;;) { - BCIns ins = *pc++; - BCOp op = bc_op(ins); - switch (bcmode_b(op)) { - case BCMvar: USE_SLOT(bc_b(ins)); break; - default: break; - } - switch (bcmode_c(op)) { - case BCMvar: USE_SLOT(bc_c(ins)); break; - case BCMrbase: - lua_assert(op == BC_CAT); - for (s = bc_b(ins); s <= bc_c(ins); s++) USE_SLOT(s); - for (; s < maxslot; s++) DEF_SLOT(s); - break; - case BCMjump: - handle_jump: { - BCReg minslot = bc_a(ins); - if (op >= BC_FORI && op <= BC_JFORL) minslot += FORL_EXT; - else if (op >= BC_ITERL && op <= BC_JITERL) minslot += bc_b(pc[-2])-1; - else if (op == BC_UCLO) { pc += bc_j(ins); break; } - for (s = minslot; s < maxslot; s++) DEF_SLOT(s); - return minslot < maxslot ? minslot : maxslot; - } - case BCMlit: - if (op == BC_JFORL || op == BC_JITERL || op == BC_JLOOP) { - goto handle_jump; - } else if (bc_isret(op)) { - BCReg top = op == BC_RETM ? maxslot : (bc_a(ins) + bc_d(ins)-1); - for (s = 0; s < bc_a(ins); s++) DEF_SLOT(s); - for (; s < top; s++) USE_SLOT(s); - for (; s < maxslot; s++) DEF_SLOT(s); - return 0; - } - break; - case BCMfunc: return maxslot; /* NYI: will abort, anyway. */ - default: break; - } - switch (bcmode_a(op)) { - case BCMvar: USE_SLOT(bc_a(ins)); break; - case BCMdst: - if (!(op == BC_ISTC || op == BC_ISFC)) DEF_SLOT(bc_a(ins)); - break; - case BCMbase: - if (op >= BC_CALLM && op <= BC_VARG) { - BCReg top = (op == BC_CALLM || op == BC_CALLMT || bc_c(ins) == 0) ? - maxslot : (bc_a(ins) + bc_c(ins)); - s = bc_a(ins) - ((op == BC_ITERC || op == BC_ITERN) ? 3 : 0); - for (; s < top; s++) USE_SLOT(s); - for (; s < maxslot; s++) DEF_SLOT(s); - if (op == BC_CALLT || op == BC_CALLMT) { - for (s = 0; s < bc_a(ins); s++) DEF_SLOT(s); - return 0; - } - } else if (op == BC_KNIL) { - for (s = bc_a(ins); s <= bc_d(ins); s++) DEF_SLOT(s); - } else if (op == BC_TSETM) { - for (s = bc_a(ins)-1; s < maxslot; s++) USE_SLOT(s); - } - break; - default: break; - } - lua_assert(pc >= proto_bc(J->pt) && pc < proto_bc(J->pt) + J->pt->sizebc); - } - -#undef USE_SLOT -#undef DEF_SLOT - - return 0; /* unreachable */ -} - -/* Purge dead slots before the next snapshot. */ -void lj_snap_purge(jit_State *J) -{ - uint8_t udf[SNAP_USEDEF_SLOTS]; - BCReg maxslot = J->maxslot; - BCReg s = snap_usedef(J, udf, J->pc, maxslot); - for (; s < maxslot; s++) - if (udf[s] != 0) - J->base[s] = 0; /* Purge dead slots. */ -} - -/* Shrink last snapshot. */ -void lj_snap_shrink(jit_State *J) -{ - SnapShot *snap = &J->cur.snap[J->cur.nsnap-1]; - SnapEntry *map = &J->cur.snapmap[snap->mapofs]; - MSize n, m, nlim, nent = snap->nent; - uint8_t udf[SNAP_USEDEF_SLOTS]; - BCReg maxslot = J->maxslot; - BCReg minslot = snap_usedef(J, udf, snap_pc(map[nent]), maxslot); - BCReg baseslot = J->baseslot; - maxslot += baseslot; - minslot += baseslot; - snap->nslots = (uint8_t)maxslot; - for (n = m = 0; n < nent; n++) { /* Remove unused slots from snapshot. */ - BCReg s = snap_slot(map[n]); - if (s < minslot || (s < maxslot && udf[s-baseslot] == 0)) - map[m++] = map[n]; /* Only copy used slots. */ - } - snap->nent = (uint8_t)m; - nlim = J->cur.nsnapmap - snap->mapofs - 1; - while (n <= nlim) map[m++] = map[n++]; /* Move PC + frame links down. */ - J->cur.nsnapmap = (uint16_t)(snap->mapofs + m); /* Free up space in map. */ -} - -/* -- Snapshot access ----------------------------------------------------- */ - -/* Initialize a Bloom Filter with all renamed refs. -** There are very few renames (often none), so the filter has -** very few bits set. This makes it suitable for negative filtering. -*/ -static BloomFilter snap_renamefilter(GCtrace *T, SnapNo lim) -{ - BloomFilter rfilt = 0; - IRIns *ir; - for (ir = &T->ir[T->nins-1]; ir->o == IR_RENAME; ir--) - if (ir->op2 <= lim) - bloomset(rfilt, ir->op1); - return rfilt; -} - -/* Process matching renames to find the original RegSP. */ -static RegSP snap_renameref(GCtrace *T, SnapNo lim, IRRef ref, RegSP rs) -{ - IRIns *ir; - for (ir = &T->ir[T->nins-1]; ir->o == IR_RENAME; ir--) - if (ir->op1 == ref && ir->op2 <= lim) - rs = ir->prev; - return rs; -} - -/* Copy RegSP from parent snapshot to the parent links of the IR. */ -IRIns *lj_snap_regspmap(GCtrace *T, SnapNo snapno, IRIns *ir) -{ - SnapShot *snap = &T->snap[snapno]; - SnapEntry *map = &T->snapmap[snap->mapofs]; - BloomFilter rfilt = snap_renamefilter(T, snapno); - MSize n = 0; - IRRef ref = 0; - for ( ; ; ir++) { - uint32_t rs; - if (ir->o == IR_SLOAD) { - if (!(ir->op2 & IRSLOAD_PARENT)) break; - for ( ; ; n++) { - lua_assert(n < snap->nent); - if (snap_slot(map[n]) == ir->op1) { - ref = snap_ref(map[n++]); - break; - } - } - } else if (LJ_SOFTFP && ir->o == IR_HIOP) { - ref++; - } else if (ir->o == IR_PVAL) { - ref = ir->op1 + REF_BIAS; - } else { - break; - } - rs = T->ir[ref].prev; - if (bloomtest(rfilt, ref)) - rs = snap_renameref(T, snapno, ref, rs); - ir->prev = (uint16_t)rs; - lua_assert(regsp_used(rs)); - } - return ir; -} - -/* -- Snapshot replay ----------------------------------------------------- */ - -/* Replay constant from parent trace. */ -static TRef snap_replay_const(jit_State *J, IRIns *ir) -{ - /* Only have to deal with constants that can occur in stack slots. */ - switch ((IROp)ir->o) { - case IR_KPRI: return TREF_PRI(irt_type(ir->t)); - case IR_KINT: return lj_ir_kint(J, ir->i); - case IR_KGC: return lj_ir_kgc(J, ir_kgc(ir), irt_t(ir->t)); - case IR_KNUM: return lj_ir_k64(J, IR_KNUM, ir_knum(ir)); - case IR_KINT64: return lj_ir_k64(J, IR_KINT64, ir_kint64(ir)); - case IR_KPTR: return lj_ir_kptr(J, ir_kptr(ir)); /* Continuation. */ - default: lua_assert(0); return TREF_NIL; break; - } -} - -/* De-duplicate parent reference. */ -static TRef snap_dedup(jit_State *J, SnapEntry *map, MSize nmax, IRRef ref) -{ - MSize j; - for (j = 0; j < nmax; j++) - if (snap_ref(map[j]) == ref) - return J->slot[snap_slot(map[j])] & ~(SNAP_CONT|SNAP_FRAME); - return 0; -} - -/* Emit parent reference with de-duplication. */ -static TRef snap_pref(jit_State *J, GCtrace *T, SnapEntry *map, MSize nmax, - BloomFilter seen, IRRef ref) -{ - IRIns *ir = &T->ir[ref]; - TRef tr; - if (irref_isk(ref)) - tr = snap_replay_const(J, ir); - else if (!regsp_used(ir->prev)) - tr = 0; - else if (!bloomtest(seen, ref) || (tr = snap_dedup(J, map, nmax, ref)) == 0) - tr = emitir(IRT(IR_PVAL, irt_type(ir->t)), ref - REF_BIAS, 0); - return tr; -} - -/* Check whether a sunk store corresponds to an allocation. Slow path. */ -static int snap_sunk_store2(jit_State *J, IRIns *ira, IRIns *irs) -{ - if (irs->o == IR_ASTORE || irs->o == IR_HSTORE || - irs->o == IR_FSTORE || irs->o == IR_XSTORE) { - IRIns *irk = IR(irs->op1); - if (irk->o == IR_AREF || irk->o == IR_HREFK) - irk = IR(irk->op1); - return (IR(irk->op1) == ira); - } - return 0; -} - -/* Check whether a sunk store corresponds to an allocation. Fast path. */ -static LJ_AINLINE int snap_sunk_store(jit_State *J, IRIns *ira, IRIns *irs) -{ - if (irs->s != 255) - return (ira + irs->s == irs); /* Fast check. */ - return snap_sunk_store2(J, ira, irs); -} - -/* Replay snapshot state to setup side trace. */ -void lj_snap_replay(jit_State *J, GCtrace *T) -{ - SnapShot *snap = &T->snap[J->exitno]; - SnapEntry *map = &T->snapmap[snap->mapofs]; - MSize n, nent = snap->nent; - BloomFilter seen = 0; - int pass23 = 0; - J->framedepth = 0; - /* Emit IR for slots inherited from parent snapshot. */ - for (n = 0; n < nent; n++) { - SnapEntry sn = map[n]; - BCReg s = snap_slot(sn); - IRRef ref = snap_ref(sn); - IRIns *ir = &T->ir[ref]; - TRef tr; - /* The bloom filter avoids O(nent^2) overhead for de-duping slots. */ - if (bloomtest(seen, ref) && (tr = snap_dedup(J, map, n, ref)) != 0) - goto setslot; - bloomset(seen, ref); - if (irref_isk(ref)) { - tr = snap_replay_const(J, ir); - } else if (!regsp_used(ir->prev)) { - pass23 = 1; - lua_assert(s != 0); - tr = s; - } else { - IRType t = irt_type(ir->t); - uint32_t mode = IRSLOAD_INHERIT|IRSLOAD_PARENT; - if (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM)) t = IRT_NUM; - if (ir->o == IR_SLOAD) mode |= (ir->op2 & IRSLOAD_READONLY); - tr = emitir_raw(IRT(IR_SLOAD, t), s, mode); - } - setslot: - J->slot[s] = tr | (sn&(SNAP_CONT|SNAP_FRAME)); /* Same as TREF_* flags. */ - J->framedepth += ((sn & (SNAP_CONT|SNAP_FRAME)) && s); - if ((sn & SNAP_FRAME)) - J->baseslot = s+1; - } - if (pass23) { - IRIns *irlast = &T->ir[snap->ref]; - pass23 = 0; - /* Emit dependent PVALs. */ - for (n = 0; n < nent; n++) { - SnapEntry sn = map[n]; - IRRef refp = snap_ref(sn); - IRIns *ir = &T->ir[refp]; - if (regsp_reg(ir->r) == RID_SUNK) { - if (J->slot[snap_slot(sn)] != snap_slot(sn)) continue; - pass23 = 1; - lua_assert(ir->o == IR_TNEW || ir->o == IR_TDUP || - ir->o == IR_CNEW || ir->o == IR_CNEWI); - if (ir->op1 >= T->nk) snap_pref(J, T, map, nent, seen, ir->op1); - if (ir->op2 >= T->nk) snap_pref(J, T, map, nent, seen, ir->op2); - if (LJ_HASFFI && ir->o == IR_CNEWI) { - if (LJ_32 && refp+1 < T->nins && (ir+1)->o == IR_HIOP) - snap_pref(J, T, map, nent, seen, (ir+1)->op2); - } else { - IRIns *irs; - for (irs = ir+1; irs < irlast; irs++) - if (irs->r == RID_SINK && snap_sunk_store(J, ir, irs)) { - if (snap_pref(J, T, map, nent, seen, irs->op2) == 0) - snap_pref(J, T, map, nent, seen, T->ir[irs->op2].op1); - else if ((LJ_SOFTFP || (LJ_32 && LJ_HASFFI)) && - irs+1 < irlast && (irs+1)->o == IR_HIOP) - snap_pref(J, T, map, nent, seen, (irs+1)->op2); - } - } - } else if (!irref_isk(refp) && !regsp_used(ir->prev)) { - lua_assert(ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT); - J->slot[snap_slot(sn)] = snap_pref(J, T, map, nent, seen, ir->op1); - } - } - /* Replay sunk instructions. */ - for (n = 0; pass23 && n < nent; n++) { - SnapEntry sn = map[n]; - IRRef refp = snap_ref(sn); - IRIns *ir = &T->ir[refp]; - if (regsp_reg(ir->r) == RID_SUNK) { - TRef op1, op2; - if (J->slot[snap_slot(sn)] != snap_slot(sn)) { /* De-dup allocs. */ - J->slot[snap_slot(sn)] = J->slot[J->slot[snap_slot(sn)]]; - continue; - } - op1 = ir->op1; - if (op1 >= T->nk) op1 = snap_pref(J, T, map, nent, seen, op1); - op2 = ir->op2; - if (op2 >= T->nk) op2 = snap_pref(J, T, map, nent, seen, op2); - if (LJ_HASFFI && ir->o == IR_CNEWI) { - if (LJ_32 && refp+1 < T->nins && (ir+1)->o == IR_HIOP) { - lj_needsplit(J); /* Emit joining HIOP. */ - op2 = emitir_raw(IRT(IR_HIOP, IRT_I64), op2, - snap_pref(J, T, map, nent, seen, (ir+1)->op2)); - } - J->slot[snap_slot(sn)] = emitir(ir->ot, op1, op2); - } else { - IRIns *irs; - TRef tr = emitir(ir->ot, op1, op2); - J->slot[snap_slot(sn)] = tr; - for (irs = ir+1; irs < irlast; irs++) - if (irs->r == RID_SINK && snap_sunk_store(J, ir, irs)) { - IRIns *irr = &T->ir[irs->op1]; - TRef val, key = irr->op2, tmp = tr; - if (irr->o != IR_FREF) { - IRIns *irk = &T->ir[key]; - if (irr->o == IR_HREFK) - key = lj_ir_kslot(J, snap_replay_const(J, &T->ir[irk->op1]), - irk->op2); - else - key = snap_replay_const(J, irk); - if (irr->o == IR_HREFK || irr->o == IR_AREF) { - IRIns *irf = &T->ir[irr->op1]; - tmp = emitir(irf->ot, tmp, irf->op2); - } - } - tmp = emitir(irr->ot, tmp, key); - val = snap_pref(J, T, map, nent, seen, irs->op2); - if (val == 0) { - IRIns *irc = &T->ir[irs->op2]; - lua_assert(irc->o == IR_CONV && irc->op2 == IRCONV_NUM_INT); - val = snap_pref(J, T, map, nent, seen, irc->op1); - val = emitir(IRTN(IR_CONV), val, IRCONV_NUM_INT); - } else if ((LJ_SOFTFP || (LJ_32 && LJ_HASFFI)) && - irs+1 < irlast && (irs+1)->o == IR_HIOP) { - IRType t = IRT_I64; - if (LJ_SOFTFP && irt_type((irs+1)->t) == IRT_SOFTFP) - t = IRT_NUM; - lj_needsplit(J); - if (irref_isk(irs->op2) && irref_isk((irs+1)->op2)) { - uint64_t k = (uint32_t)T->ir[irs->op2].i + - ((uint64_t)T->ir[(irs+1)->op2].i << 32); - val = lj_ir_k64(J, t == IRT_I64 ? IR_KINT64 : IR_KNUM, - lj_ir_k64_find(J, k)); - } else { - val = emitir_raw(IRT(IR_HIOP, t), val, - snap_pref(J, T, map, nent, seen, (irs+1)->op2)); - } - tmp = emitir(IRT(irs->o, t), tmp, val); - continue; - } - tmp = emitir(irs->ot, tmp, val); - } else if (LJ_HASFFI && irs->o == IR_XBAR && ir->o == IR_CNEW) { - emitir(IRT(IR_XBAR, IRT_NIL), 0, 0); - } - } - } - } - } - J->base = J->slot + J->baseslot; - J->maxslot = snap->nslots - J->baseslot; - lj_snap_add(J); - if (pass23) /* Need explicit GC step _after_ initial snapshot. */ - emitir_raw(IRTG(IR_GCSTEP, IRT_NIL), 0, 0); -} - -/* -- Snapshot restore ---------------------------------------------------- */ - -static void snap_unsink(jit_State *J, GCtrace *T, ExitState *ex, - SnapNo snapno, BloomFilter rfilt, - IRIns *ir, TValue *o); - -/* Restore a value from the trace exit state. */ -static void snap_restoreval(jit_State *J, GCtrace *T, ExitState *ex, - SnapNo snapno, BloomFilter rfilt, - IRRef ref, TValue *o) -{ - IRIns *ir = &T->ir[ref]; - IRType1 t = ir->t; - RegSP rs = ir->prev; - if (irref_isk(ref)) { /* Restore constant slot. */ - lj_ir_kvalue(J->L, o, ir); - return; - } - if (LJ_UNLIKELY(bloomtest(rfilt, ref))) - rs = snap_renameref(T, snapno, ref, rs); - if (ra_hasspill(regsp_spill(rs))) { /* Restore from spill slot. */ - int32_t *sps = &ex->spill[regsp_spill(rs)]; - if (irt_isinteger(t)) { - setintV(o, *sps); -#if !LJ_SOFTFP - } else if (irt_isnum(t)) { - o->u64 = *(uint64_t *)sps; -#endif - } else if (LJ_64 && irt_islightud(t)) { - /* 64 bit lightuserdata which may escape already has the tag bits. */ - o->u64 = *(uint64_t *)sps; - } else { - lua_assert(!irt_ispri(t)); /* PRI refs never have a spill slot. */ - setgcrefi(o->gcr, *sps); - setitype(o, irt_toitype(t)); - } - } else { /* Restore from register. */ - Reg r = regsp_reg(rs); - if (ra_noreg(r)) { - lua_assert(ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT); - snap_restoreval(J, T, ex, snapno, rfilt, ir->op1, o); - if (LJ_DUALNUM) setnumV(o, (lua_Number)intV(o)); - return; - } else if (irt_isinteger(t)) { - setintV(o, (int32_t)ex->gpr[r-RID_MIN_GPR]); -#if !LJ_SOFTFP - } else if (irt_isnum(t)) { - setnumV(o, ex->fpr[r-RID_MIN_FPR]); -#endif - } else if (LJ_64 && irt_islightud(t)) { - /* 64 bit lightuserdata which may escape already has the tag bits. */ - o->u64 = ex->gpr[r-RID_MIN_GPR]; - } else { - if (!irt_ispri(t)) - setgcrefi(o->gcr, ex->gpr[r-RID_MIN_GPR]); - setitype(o, irt_toitype(t)); - } - } -} - -#if LJ_HASFFI -/* Restore raw data from the trace exit state. */ -static void snap_restoredata(GCtrace *T, ExitState *ex, - SnapNo snapno, BloomFilter rfilt, - IRRef ref, void *dst, CTSize sz) -{ - IRIns *ir = &T->ir[ref]; - RegSP rs = ir->prev; - int32_t *src; - uint64_t tmp; - if (irref_isk(ref)) { - if (ir->o == IR_KNUM || ir->o == IR_KINT64) { - src = mref(ir->ptr, int32_t); - } else if (sz == 8) { - tmp = (uint64_t)(uint32_t)ir->i; - src = (int32_t *)&tmp; - } else { - src = &ir->i; - } - } else { - if (LJ_UNLIKELY(bloomtest(rfilt, ref))) - rs = snap_renameref(T, snapno, ref, rs); - if (ra_hasspill(regsp_spill(rs))) { - src = &ex->spill[regsp_spill(rs)]; - if (sz == 8 && !irt_is64(ir->t)) { - tmp = (uint64_t)(uint32_t)*src; - src = (int32_t *)&tmp; - } - } else { - Reg r = regsp_reg(rs); - if (ra_noreg(r)) { - /* Note: this assumes CNEWI is never used for SOFTFP split numbers. */ - lua_assert(sz == 8 && ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT); - snap_restoredata(T, ex, snapno, rfilt, ir->op1, dst, 4); - *(lua_Number *)dst = (lua_Number)*(int32_t *)dst; - return; - } - src = (int32_t *)&ex->gpr[r-RID_MIN_GPR]; -#if !LJ_SOFTFP - if (r >= RID_MAX_GPR) { - src = (int32_t *)&ex->fpr[r-RID_MIN_FPR]; -#if LJ_TARGET_PPC - if (sz == 4) { /* PPC FPRs are always doubles. */ - *(float *)dst = (float)*(double *)src; - return; - } -#else - if (LJ_BE && sz == 4) src++; -#endif - } -#endif - } - } - lua_assert(sz == 1 || sz == 2 || sz == 4 || sz == 8); - if (sz == 4) *(int32_t *)dst = *src; - else if (sz == 8) *(int64_t *)dst = *(int64_t *)src; - else if (sz == 1) *(int8_t *)dst = (int8_t)*src; - else *(int16_t *)dst = (int16_t)*src; -} -#endif - -/* Unsink allocation from the trace exit state. Unsink sunk stores. */ -static void snap_unsink(jit_State *J, GCtrace *T, ExitState *ex, - SnapNo snapno, BloomFilter rfilt, - IRIns *ir, TValue *o) -{ - lua_assert(ir->o == IR_TNEW || ir->o == IR_TDUP || - ir->o == IR_CNEW || ir->o == IR_CNEWI); -#if LJ_HASFFI - if (ir->o == IR_CNEW || ir->o == IR_CNEWI) { - CTState *cts = ctype_cts(J->L); - CTypeID id = (CTypeID)T->ir[ir->op1].i; - CTSize sz = lj_ctype_size(cts, id); - GCcdata *cd = lj_cdata_new(cts, id, sz); - setcdataV(J->L, o, cd); - if (ir->o == IR_CNEWI) { - uint8_t *p = (uint8_t *)cdataptr(cd); - lua_assert(sz == 4 || sz == 8); - if (LJ_32 && sz == 8 && ir+1 < T->ir + T->nins && (ir+1)->o == IR_HIOP) { - snap_restoredata(T, ex, snapno, rfilt, (ir+1)->op2, LJ_LE?p+4:p, 4); - if (LJ_BE) p += 4; - sz = 4; - } - snap_restoredata(T, ex, snapno, rfilt, ir->op2, p, sz); - } else { - IRIns *irs, *irlast = &T->ir[T->snap[snapno].ref]; - for (irs = ir+1; irs < irlast; irs++) - if (irs->r == RID_SINK && snap_sunk_store(J, ir, irs)) { - IRIns *iro = &T->ir[T->ir[irs->op1].op2]; - uint8_t *p = (uint8_t *)cd; - CTSize szs; - lua_assert(irs->o == IR_XSTORE && T->ir[irs->op1].o == IR_ADD); - lua_assert(iro->o == IR_KINT || iro->o == IR_KINT64); - if (irt_is64(irs->t)) szs = 8; - else if (irt_isi8(irs->t) || irt_isu8(irs->t)) szs = 1; - else if (irt_isi16(irs->t) || irt_isu16(irs->t)) szs = 2; - else szs = 4; - if (LJ_64 && iro->o == IR_KINT64) - p += (int64_t)ir_k64(iro)->u64; - else - p += iro->i; - lua_assert(p >= (uint8_t *)cdataptr(cd) && - p + szs <= (uint8_t *)cdataptr(cd) + sz); - if (LJ_32 && irs+1 < T->ir + T->nins && (irs+1)->o == IR_HIOP) { - lua_assert(szs == 4); - snap_restoredata(T, ex, snapno, rfilt, (irs+1)->op2, LJ_LE?p+4:p,4); - if (LJ_BE) p += 4; - } - snap_restoredata(T, ex, snapno, rfilt, irs->op2, p, szs); - } - } - } else -#endif - { - IRIns *irs, *irlast; - GCtab *t = ir->o == IR_TNEW ? lj_tab_new(J->L, ir->op1, ir->op2) : - lj_tab_dup(J->L, ir_ktab(&T->ir[ir->op1])); - settabV(J->L, o, t); - irlast = &T->ir[T->snap[snapno].ref]; - for (irs = ir+1; irs < irlast; irs++) - if (irs->r == RID_SINK && snap_sunk_store(J, ir, irs)) { - IRIns *irk = &T->ir[irs->op1]; - TValue tmp, *val; - lua_assert(irs->o == IR_ASTORE || irs->o == IR_HSTORE || - irs->o == IR_FSTORE); - if (irk->o == IR_FREF) { - lua_assert(irk->op2 == IRFL_TAB_META); - snap_restoreval(J, T, ex, snapno, rfilt, irs->op2, &tmp); - /* NOBARRIER: The table is new (marked white). */ - setgcref(t->metatable, obj2gco(tabV(&tmp))); - } else { - irk = &T->ir[irk->op2]; - if (irk->o == IR_KSLOT) irk = &T->ir[irk->op1]; - lj_ir_kvalue(J->L, &tmp, irk); - val = lj_tab_set(J->L, t, &tmp); - /* NOBARRIER: The table is new (marked white). */ - snap_restoreval(J, T, ex, snapno, rfilt, irs->op2, val); - if (LJ_SOFTFP && irs+1 < T->ir + T->nins && (irs+1)->o == IR_HIOP) { - snap_restoreval(J, T, ex, snapno, rfilt, (irs+1)->op2, &tmp); - val->u32.hi = tmp.u32.lo; - } - } - } - } -} - -/* Restore interpreter state from exit state with the help of a snapshot. */ -const BCIns *lj_snap_restore(jit_State *J, void *exptr) -{ - ExitState *ex = (ExitState *)exptr; - SnapNo snapno = J->exitno; /* For now, snapno == exitno. */ - GCtrace *T = traceref(J, J->parent); - SnapShot *snap = &T->snap[snapno]; - MSize n, nent = snap->nent; - SnapEntry *map = &T->snapmap[snap->mapofs]; - SnapEntry *flinks = &T->snapmap[snap_nextofs(T, snap)-1]; - int32_t ftsz0; - TValue *frame; - BloomFilter rfilt = snap_renamefilter(T, snapno); - const BCIns *pc = snap_pc(map[nent]); - lua_State *L = J->L; - - /* Set interpreter PC to the next PC to get correct error messages. */ - setcframe_pc(cframe_raw(L->cframe), pc+1); - - /* Make sure the stack is big enough for the slots from the snapshot. */ - if (LJ_UNLIKELY(L->base + snap->topslot >= tvref(L->maxstack))) { - L->top = curr_topL(L); - lj_state_growstack(L, snap->topslot - curr_proto(L)->framesize); - } - - /* Fill stack slots with data from the registers and spill slots. */ - frame = L->base-1; - ftsz0 = frame_ftsz(frame); /* Preserve link to previous frame in slot #0. */ - for (n = 0; n < nent; n++) { - SnapEntry sn = map[n]; - if (!(sn & SNAP_NORESTORE)) { - TValue *o = &frame[snap_slot(sn)]; - IRRef ref = snap_ref(sn); - IRIns *ir = &T->ir[ref]; - if (ir->r == RID_SUNK) { - MSize j; - for (j = 0; j < n; j++) - if (snap_ref(map[j]) == ref) { /* De-duplicate sunk allocations. */ - copyTV(L, o, &frame[snap_slot(map[j])]); - goto dupslot; - } - snap_unsink(J, T, ex, snapno, rfilt, ir, o); - dupslot: - continue; - } - snap_restoreval(J, T, ex, snapno, rfilt, ref, o); - if (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM) && tvisint(o)) { - TValue tmp; - snap_restoreval(J, T, ex, snapno, rfilt, ref+1, &tmp); - o->u32.hi = tmp.u32.lo; - } else if ((sn & (SNAP_CONT|SNAP_FRAME))) { - /* Overwrite tag with frame link. */ - o->fr.tp.ftsz = snap_slot(sn) != 0 ? (int32_t)*flinks-- : ftsz0; - L->base = o+1; - } - } - } - lua_assert(map + nent == flinks); - - /* Compute current stack top. */ - switch (bc_op(*pc)) { - default: - if (bc_op(*pc) < BC_FUNCF) { - L->top = curr_topL(L); - break; - } - /* fallthrough */ - case BC_CALLM: case BC_CALLMT: case BC_RETM: case BC_TSETM: - L->top = frame + snap->nslots; - break; - } - return pc; -} - -#undef IR -#undef emitir_raw -#undef emitir - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_snap.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_snap.h deleted file mode 100644 index 1b2d74da7..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_snap.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -** Snapshot handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_SNAP_H -#define _LJ_SNAP_H - -#include "lj_obj.h" -#include "lj_jit.h" - -#if LJ_HASJIT -LJ_FUNC void lj_snap_add(jit_State *J); -LJ_FUNC void lj_snap_purge(jit_State *J); -LJ_FUNC void lj_snap_shrink(jit_State *J); -LJ_FUNC IRIns *lj_snap_regspmap(GCtrace *T, SnapNo snapno, IRIns *ir); -LJ_FUNC void lj_snap_replay(jit_State *J, GCtrace *T); -LJ_FUNC const BCIns *lj_snap_restore(jit_State *J, void *exptr); -LJ_FUNC void lj_snap_grow_buf_(jit_State *J, MSize need); -LJ_FUNC void lj_snap_grow_map_(jit_State *J, MSize need); - -static LJ_AINLINE void lj_snap_grow_buf(jit_State *J, MSize need) -{ - if (LJ_UNLIKELY(need > J->sizesnap)) lj_snap_grow_buf_(J, need); -} - -static LJ_AINLINE void lj_snap_grow_map(jit_State *J, MSize need) -{ - if (LJ_UNLIKELY(need > J->sizesnapmap)) lj_snap_grow_map_(J, need); -} - -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_state.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_state.c deleted file mode 100644 index f972fdced..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_state.c +++ /dev/null @@ -1,287 +0,0 @@ -/* -** State and stack handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Portions taken verbatim or adapted from the Lua interpreter. -** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h -*/ - -#define lj_state_c -#define LUA_CORE - -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_func.h" -#include "lj_meta.h" -#include "lj_state.h" -#include "lj_frame.h" -#if LJ_HASFFI -#include "lj_ctype.h" -#endif -#include "lj_trace.h" -#include "lj_dispatch.h" -#include "lj_vm.h" -#include "lj_lex.h" -#include "lj_alloc.h" - -/* -- Stack handling ------------------------------------------------------ */ - -/* Stack sizes. */ -#define LJ_STACK_MIN LUA_MINSTACK /* Min. stack size. */ -#define LJ_STACK_MAX LUAI_MAXSTACK /* Max. stack size. */ -#define LJ_STACK_START (2*LJ_STACK_MIN) /* Starting stack size. */ -#define LJ_STACK_MAXEX (LJ_STACK_MAX + 1 + LJ_STACK_EXTRA) - -/* Explanation of LJ_STACK_EXTRA: -** -** Calls to metamethods store their arguments beyond the current top -** without checking for the stack limit. This avoids stack resizes which -** would invalidate passed TValue pointers. The stack check is performed -** later by the function header. This can safely resize the stack or raise -** an error. Thus we need some extra slots beyond the current stack limit. -** -** Most metamethods need 4 slots above top (cont, mobj, arg1, arg2) plus -** one extra slot if mobj is not a function. Only lj_meta_tset needs 5 -** slots above top, but then mobj is always a function. So we can get by -** with 5 extra slots. -*/ - -/* Resize stack slots and adjust pointers in state. */ -static void resizestack(lua_State *L, MSize n) -{ - TValue *st, *oldst = tvref(L->stack); - ptrdiff_t delta; - MSize oldsize = L->stacksize; - MSize realsize = n + 1 + LJ_STACK_EXTRA; - GCobj *up; - lua_assert((MSize)(tvref(L->maxstack)-oldst)==L->stacksize-LJ_STACK_EXTRA-1); - st = (TValue *)lj_mem_realloc(L, tvref(L->stack), - (MSize)(L->stacksize*sizeof(TValue)), - (MSize)(realsize*sizeof(TValue))); - setmref(L->stack, st); - delta = (char *)st - (char *)oldst; - setmref(L->maxstack, st + n); - while (oldsize < realsize) /* Clear new slots. */ - setnilV(st + oldsize++); - L->stacksize = realsize; - L->base = (TValue *)((char *)L->base + delta); - L->top = (TValue *)((char *)L->top + delta); - for (up = gcref(L->openupval); up != NULL; up = gcnext(up)) - setmref(gco2uv(up)->v, (TValue *)((char *)uvval(gco2uv(up)) + delta)); - if (obj2gco(L) == gcref(G(L)->jit_L)) - setmref(G(L)->jit_base, mref(G(L)->jit_base, char) + delta); -} - -/* Relimit stack after error, in case the limit was overdrawn. */ -void lj_state_relimitstack(lua_State *L) -{ - if (L->stacksize > LJ_STACK_MAXEX && L->top-tvref(L->stack) < LJ_STACK_MAX-1) - resizestack(L, LJ_STACK_MAX); -} - -/* Try to shrink the stack (called from GC). */ -void lj_state_shrinkstack(lua_State *L, MSize used) -{ - if (L->stacksize > LJ_STACK_MAXEX) - return; /* Avoid stack shrinking while handling stack overflow. */ - if (4*used < L->stacksize && - 2*(LJ_STACK_START+LJ_STACK_EXTRA) < L->stacksize && - obj2gco(L) != gcref(G(L)->jit_L)) /* Don't shrink stack of live trace. */ - resizestack(L, L->stacksize >> 1); -} - -/* Try to grow stack. */ -void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need) -{ - MSize n; - if (L->stacksize > LJ_STACK_MAXEX) /* Overflow while handling overflow? */ - lj_err_throw(L, LUA_ERRERR); - n = L->stacksize + need; - if (n > LJ_STACK_MAX) { - n += 2*LUA_MINSTACK; - } else if (n < 2*L->stacksize) { - n = 2*L->stacksize; - if (n >= LJ_STACK_MAX) - n = LJ_STACK_MAX; - } - resizestack(L, n); - if (L->stacksize > LJ_STACK_MAXEX) - lj_err_msg(L, LJ_ERR_STKOV); -} - -void LJ_FASTCALL lj_state_growstack1(lua_State *L) -{ - lj_state_growstack(L, 1); -} - -/* Allocate basic stack for new state. */ -static void stack_init(lua_State *L1, lua_State *L) -{ - TValue *stend, *st = lj_mem_newvec(L, LJ_STACK_START+LJ_STACK_EXTRA, TValue); - setmref(L1->stack, st); - L1->stacksize = LJ_STACK_START + LJ_STACK_EXTRA; - stend = st + L1->stacksize; - setmref(L1->maxstack, stend - LJ_STACK_EXTRA - 1); - L1->base = L1->top = st+1; - setthreadV(L1, st, L1); /* Needed for curr_funcisL() on empty stack. */ - while (st < stend) /* Clear new slots. */ - setnilV(st++); -} - -/* -- State handling ------------------------------------------------------ */ - -/* Open parts that may cause memory-allocation errors. */ -static TValue *cpluaopen(lua_State *L, lua_CFunction dummy, void *ud) -{ - global_State *g = G(L); - UNUSED(dummy); - UNUSED(ud); - stack_init(L, L); - /* NOBARRIER: State initialization, all objects are white. */ - setgcref(L->env, obj2gco(lj_tab_new(L, 0, LJ_MIN_GLOBAL))); - settabV(L, registry(L), lj_tab_new(L, 0, LJ_MIN_REGISTRY)); - lj_str_resize(L, LJ_MIN_STRTAB-1); - lj_meta_init(L); - lj_lex_init(L); - fixstring(lj_err_str(L, LJ_ERR_ERRMEM)); /* Preallocate memory error msg. */ - g->gc.threshold = 4*g->gc.total; - lj_trace_initstate(g); - return NULL; -} - -static void close_state(lua_State *L) -{ - global_State *g = G(L); - lj_func_closeuv(L, tvref(L->stack)); - lj_gc_freeall(g); - lua_assert(gcref(g->gc.root) == obj2gco(L)); - lua_assert(g->strnum == 0); - lj_trace_freestate(g); -#if LJ_HASFFI - lj_ctype_freestate(g); -#endif - lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef); - lj_str_freebuf(g, &g->tmpbuf); - lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue); - lua_assert(g->gc.total == sizeof(GG_State)); -#ifndef LUAJIT_USE_SYSMALLOC - if (g->allocf == lj_alloc_f) - lj_alloc_destroy(g->allocd); - else -#endif - g->allocf(g->allocd, G2GG(g), sizeof(GG_State), 0); -} - -#if LJ_64 -lua_State *lj_state_newstate(lua_Alloc f, void *ud) -#else -LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) -#endif -{ - GG_State *GG = (GG_State *)f(ud, NULL, 0, sizeof(GG_State)); - lua_State *L = &GG->L; - global_State *g = &GG->g; - if (GG == NULL || !checkptr32(GG)) return NULL; - memset(GG, 0, sizeof(GG_State)); - L->gct = ~LJ_TTHREAD; - L->marked = LJ_GC_WHITE0 | LJ_GC_FIXED | LJ_GC_SFIXED; /* Prevent free. */ - L->dummy_ffid = FF_C; - setmref(L->glref, g); - g->gc.currentwhite = LJ_GC_WHITE0 | LJ_GC_FIXED; - g->strempty.marked = LJ_GC_WHITE0; - g->strempty.gct = ~LJ_TSTR; - g->allocf = f; - g->allocd = ud; - setgcref(g->mainthref, obj2gco(L)); - setgcref(g->uvhead.prev, obj2gco(&g->uvhead)); - setgcref(g->uvhead.next, obj2gco(&g->uvhead)); - g->strmask = ~(MSize)0; - setnilV(registry(L)); - setnilV(&g->nilnode.val); - setnilV(&g->nilnode.key); - setmref(g->nilnode.freetop, &g->nilnode); - lj_str_initbuf(&g->tmpbuf); - g->gc.state = GCSpause; - setgcref(g->gc.root, obj2gco(L)); - setmref(g->gc.sweep, &g->gc.root); - g->gc.total = sizeof(GG_State); - g->gc.pause = LUAI_GCPAUSE; - g->gc.stepmul = LUAI_GCMUL; - lj_dispatch_init((GG_State *)L); - L->status = LUA_ERRERR+1; /* Avoid touching the stack upon memory error. */ - if (lj_vm_cpcall(L, NULL, NULL, cpluaopen) != 0) { - /* Memory allocation error: free partial state. */ - close_state(L); - return NULL; - } - L->status = 0; - return L; -} - -static TValue *cpfinalize(lua_State *L, lua_CFunction dummy, void *ud) -{ - UNUSED(dummy); - UNUSED(ud); - lj_gc_finalize_cdata(L); - lj_gc_finalize_udata(L); - /* Frame pop omitted. */ - return NULL; -} - -LUA_API void lua_close(lua_State *L) -{ - global_State *g = G(L); - int i; - L = mainthread(g); /* Only the main thread can be closed. */ - lj_func_closeuv(L, tvref(L->stack)); - lj_gc_separateudata(g, 1); /* Separate udata which have GC metamethods. */ -#if LJ_HASJIT - G2J(g)->flags &= ~JIT_F_ON; - G2J(g)->state = LJ_TRACE_IDLE; - lj_dispatch_update(g); -#endif - for (i = 0;;) { - hook_enter(g); - L->status = 0; - L->cframe = NULL; - L->base = L->top = tvref(L->stack) + 1; - if (lj_vm_cpcall(L, NULL, NULL, cpfinalize) == 0) { - if (++i >= 10) break; - lj_gc_separateudata(g, 1); /* Separate udata again. */ - if (gcref(g->gc.mmudata) == NULL) /* Until nothing is left to do. */ - break; - } - } - close_state(L); -} - -lua_State *lj_state_new(lua_State *L) -{ - lua_State *L1 = lj_mem_newobj(L, lua_State); - L1->gct = ~LJ_TTHREAD; - L1->dummy_ffid = FF_C; - L1->status = 0; - L1->stacksize = 0; - setmref(L1->stack, NULL); - L1->cframe = NULL; - /* NOBARRIER: The lua_State is new (marked white). */ - setgcrefnull(L1->openupval); - setmrefr(L1->glref, L->glref); - setgcrefr(L1->env, L->env); - stack_init(L1, L); /* init stack */ - lua_assert(iswhite(obj2gco(L1))); - return L1; -} - -void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L) -{ - lua_assert(L != mainthread(g)); - lj_func_closeuv(L, tvref(L->stack)); - lua_assert(gcref(L->openupval) == NULL); - lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue); - lj_mem_freet(g, L); -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_state.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_state.h deleted file mode 100644 index 74249d9bb..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_state.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -** State and stack handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_STATE_H -#define _LJ_STATE_H - -#include "lj_obj.h" - -#define incr_top(L) \ - (++L->top >= tvref(L->maxstack) && (lj_state_growstack1(L), 0)) - -#define savestack(L, p) ((char *)(p) - mref(L->stack, char)) -#define restorestack(L, n) ((TValue *)(mref(L->stack, char) + (n))) - -LJ_FUNC void lj_state_relimitstack(lua_State *L); -LJ_FUNC void lj_state_shrinkstack(lua_State *L, MSize used); -LJ_FUNCA void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need); -LJ_FUNC void LJ_FASTCALL lj_state_growstack1(lua_State *L); - -static LJ_AINLINE void lj_state_checkstack(lua_State *L, MSize need) -{ - if ((mref(L->maxstack, char) - (char *)L->top) <= - (ptrdiff_t)need*(ptrdiff_t)sizeof(TValue)) - lj_state_growstack(L, need); -} - -LJ_FUNC lua_State *lj_state_new(lua_State *L); -LJ_FUNC void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L); -#if LJ_64 -LJ_FUNC lua_State *lj_state_newstate(lua_Alloc f, void *ud); -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_str.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_str.c deleted file mode 100644 index b5fd45e50..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_str.c +++ /dev/null @@ -1,366 +0,0 @@ -/* -** String handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Portions taken verbatim or adapted from the Lua interpreter. -** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h -*/ - -#include - -#define lj_str_c -#define LUA_CORE - -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_str.h" -#include "lj_state.h" -#include "lj_char.h" - -/* -- String interning ---------------------------------------------------- */ - -/* Ordered compare of strings. Assumes string data is 4-byte aligned. */ -int32_t LJ_FASTCALL lj_str_cmp(GCstr *a, GCstr *b) -{ - MSize i, n = a->len > b->len ? b->len : a->len; - for (i = 0; i < n; i += 4) { - /* Note: innocuous access up to end of string + 3. */ - uint32_t va = *(const uint32_t *)(strdata(a)+i); - uint32_t vb = *(const uint32_t *)(strdata(b)+i); - if (va != vb) { -#if LJ_LE - va = lj_bswap(va); vb = lj_bswap(vb); -#endif - i -= n; - if ((int32_t)i >= -3) { - va >>= 32+(i<<3); vb >>= 32+(i<<3); - if (va == vb) break; - } - return va < vb ? -1 : 1; - } - } - return (int32_t)(a->len - b->len); -} - -/* Fast string data comparison. Caveat: unaligned access to 1st string! */ -static LJ_AINLINE int str_fastcmp(const char *a, const char *b, MSize len) -{ - MSize i = 0; - lua_assert(len > 0); - lua_assert((((uintptr_t)a+len-1) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4); - do { /* Note: innocuous access up to end of string + 3. */ - uint32_t v = lj_getu32(a+i) ^ *(const uint32_t *)(b+i); - if (v) { - i -= len; -#if LJ_LE - return (int32_t)i >= -3 ? (v << (32+(i<<3))) : 1; -#else - return (int32_t)i >= -3 ? (v >> (32+(i<<3))) : 1; -#endif - } - i += 4; - } while (i < len); - return 0; -} - -/* Resize the string hash table (grow and shrink). */ -void lj_str_resize(lua_State *L, MSize newmask) -{ - global_State *g = G(L); - GCRef *newhash; - MSize i; - if (g->gc.state == GCSsweepstring || newmask >= LJ_MAX_STRTAB-1) - return; /* No resizing during GC traversal or if already too big. */ - newhash = lj_mem_newvec(L, newmask+1, GCRef); - memset(newhash, 0, (newmask+1)*sizeof(GCRef)); - for (i = g->strmask; i != ~(MSize)0; i--) { /* Rehash old table. */ - GCobj *p = gcref(g->strhash[i]); - while (p) { /* Follow each hash chain and reinsert all strings. */ - MSize h = gco2str(p)->hash & newmask; - GCobj *next = gcnext(p); - /* NOBARRIER: The string table is a GC root. */ - setgcrefr(p->gch.nextgc, newhash[h]); - setgcref(newhash[h], p); - p = next; - } - } - lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef); - g->strmask = newmask; - g->strhash = newhash; -} - -/* -** Lua will use at most ~(2^LUAI_HASHLIMIT) bytes from a string to -** compute its hash -*/ -#if !defined(LUAI_HASHLIMIT) -#define LUAI_HASHLIMIT 5 -#endif - -#define cast(t, exp) ((t)(exp)) -int luajittex_choose_hash_function = 0 ; -/* Intern a string and return string object. */ -GCstr *lj_str_new(lua_State *L, const char *str, size_t lenx) -{ - global_State *g; - GCstr *s; - GCobj *o; - MSize len = (MSize)lenx; - MSize a, b, h = len; - size_t step ; - size_t l1 ; - if (lenx >= LJ_MAX_STR) - lj_err_msg(L, LJ_ERR_STROV); - g = G(L); - - if (len==0) - return &g->strempty; - if (luajittex_choose_hash_function==0) { - /* Lua 5.1.5 hash function */ - /* for 5.2 max methods we also need to patch the vm eq */ - step = (len>>LUAI_HASHLIMIT)+1; /* if string is too long, don't hash all its chars */ - for (l1=len; l1>=step; l1-=step) /* compute hash */ - h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); - } else { - /* LuaJIT 2.0.2 hash function */ - /* Compute string hash. Constants taken from lookup3 hash by Bob Jenkins. */ - if (len >= 4) { /* Caveat: unaligned access! */ - a = lj_getu32(str); - h ^= lj_getu32(str+len-4); - b = lj_getu32(str+(len>>1)-2); - h ^= b; h -= lj_rol(b, 14); - b += lj_getu32(str+(len>>2)-1); - } else if (len > 0) { - a = *(const uint8_t *)str; - h ^= *(const uint8_t *)(str+len-1); - b = *(const uint8_t *)(str+(len>>1)); - h ^= b; h -= lj_rol(b, 14); - } else { - /* Already done, kept for reference */ - return &g->strempty; - } - a ^= h; a -= lj_rol(h, 11); - b ^= a; b -= lj_rol(a, 25); - h ^= b; h -= lj_rol(b, 16); - } - - - /* Check if the string has already been interned. */ - o = gcref(g->strhash[h & g->strmask]); - if (LJ_LIKELY((((uintptr_t)str+len-1) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4)) { - while (o != NULL) { - GCstr *sx = gco2str(o); - if (sx->len == len && str_fastcmp(str, strdata(sx), len) == 0) { - /* Resurrect if dead. Can only happen with fixstring() (keywords). */ - if (isdead(g, o)) flipwhite(o); - return sx; /* Return existing string. */ - } - o = gcnext(o); - } - } else { /* Slow path: end of string is too close to a page boundary. */ - while (o != NULL) { - GCstr *sx = gco2str(o); - if (sx->len == len && memcmp(str, strdata(sx), len) == 0) { - /* Resurrect if dead. Can only happen with fixstring() (keywords). */ - if (isdead(g, o)) flipwhite(o); - return sx; /* Return existing string. */ - } - o = gcnext(o); - } - } - /* Nope, create a new string. */ - s = lj_mem_newt(L, sizeof(GCstr)+len+1, GCstr); - newwhite(g, s); - s->gct = ~LJ_TSTR; - s->len = len; - s->hash = h; - s->reserved = 0; - memcpy(strdatawr(s), str, len); - strdatawr(s)[len] = '\0'; /* Zero-terminate string. */ - /* Add it to string hash table. */ - h &= g->strmask; - s->nextgc = g->strhash[h]; - /* NOBARRIER: The string table is a GC root. */ - setgcref(g->strhash[h], obj2gco(s)); - if (g->strnum++ > g->strmask) /* Allow a 100% load factor. */ - lj_str_resize(L, (g->strmask<<1)+1); /* Grow string table. */ - return s; /* Return newly interned string. */ -} - -void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s) -{ - g->strnum--; - lj_mem_free(g, s, sizestring(s)); -} - -/* -- Type conversions ---------------------------------------------------- */ - -/* Print number to buffer. Canonicalizes non-finite values. */ -size_t LJ_FASTCALL lj_str_bufnum(char *s, cTValue *o) -{ - if (LJ_LIKELY((o->u32.hi << 1) < 0xffe00000)) { /* Finite? */ - lua_Number n = o->n; -#if __BIONIC__ - if (tvismzero(o)) { s[0] = '-'; s[1] = '0'; return 2; } -#endif - return (size_t)lua_number2str(s, n); - } else if (((o->u32.hi & 0x000fffff) | o->u32.lo) != 0) { - s[0] = 'n'; s[1] = 'a'; s[2] = 'n'; return 3; - } else if ((o->u32.hi & 0x80000000) == 0) { - s[0] = 'i'; s[1] = 'n'; s[2] = 'f'; return 3; - } else { - s[0] = '-'; s[1] = 'i'; s[2] = 'n'; s[3] = 'f'; return 4; - } -} - -/* Print integer to buffer. Returns pointer to start. */ -char * LJ_FASTCALL lj_str_bufint(char *p, int32_t k) -{ - uint32_t u = (uint32_t)(k < 0 ? -k : k); - p += 1+10; - do { *--p = (char)('0' + u % 10); } while (u /= 10); - if (k < 0) *--p = '-'; - return p; -} - -/* Convert number to string. */ -GCstr * LJ_FASTCALL lj_str_fromnum(lua_State *L, const lua_Number *np) -{ - char buf[LJ_STR_NUMBUF]; - size_t len = lj_str_bufnum(buf, (TValue *)np); - return lj_str_new(L, buf, len); -} - -/* Convert integer to string. */ -GCstr * LJ_FASTCALL lj_str_fromint(lua_State *L, int32_t k) -{ - char s[1+10]; - char *p = lj_str_bufint(s, k); - return lj_str_new(L, p, (size_t)(s+sizeof(s)-p)); -} - -GCstr * LJ_FASTCALL lj_str_fromnumber(lua_State *L, cTValue *o) -{ - return tvisint(o) ? lj_str_fromint(L, intV(o)) : lj_str_fromnum(L, &o->n); -} - -/* -- String formatting --------------------------------------------------- */ - -static void addstr(lua_State *L, SBuf *sb, const char *str, MSize len) -{ - char *p; - MSize i; - if (sb->n + len > sb->sz) { - MSize sz = sb->sz * 2; - while (sb->n + len > sz) sz = sz * 2; - lj_str_resizebuf(L, sb, sz); - } - p = sb->buf + sb->n; - sb->n += len; - for (i = 0; i < len; i++) p[i] = str[i]; -} - -static void addchar(lua_State *L, SBuf *sb, int c) -{ - if (sb->n + 1 > sb->sz) { - MSize sz = sb->sz * 2; - lj_str_resizebuf(L, sb, sz); - } - sb->buf[sb->n++] = (char)c; -} - -/* Push formatted message as a string object to Lua stack. va_list variant. */ -const char *lj_str_pushvf(lua_State *L, const char *fmt, va_list argp) -{ - SBuf *sb = &G(L)->tmpbuf; - lj_str_needbuf(L, sb, (MSize)strlen(fmt)); - lj_str_resetbuf(sb); - for (;;) { - const char *e = strchr(fmt, '%'); - if (e == NULL) break; - addstr(L, sb, fmt, (MSize)(e-fmt)); - /* This function only handles %s, %c, %d, %f and %p formats. */ - switch (e[1]) { - case 's': { - const char *s = va_arg(argp, char *); - if (s == NULL) s = "(null)"; - addstr(L, sb, s, (MSize)strlen(s)); - break; - } - case 'c': - addchar(L, sb, va_arg(argp, int)); - break; - case 'd': { - char buf[LJ_STR_INTBUF]; - char *p = lj_str_bufint(buf, va_arg(argp, int32_t)); - addstr(L, sb, p, (MSize)(buf+LJ_STR_INTBUF-p)); - break; - } - case 'f': { - char buf[LJ_STR_NUMBUF]; - TValue tv; - MSize len; - tv.n = (lua_Number)(va_arg(argp, LUAI_UACNUMBER)); - len = (MSize)lj_str_bufnum(buf, &tv); - addstr(L, sb, buf, len); - break; - } - case 'p': { -#define FMTP_CHARS (2*sizeof(ptrdiff_t)) - char buf[2+FMTP_CHARS]; - ptrdiff_t p = (ptrdiff_t)(va_arg(argp, void *)); - ptrdiff_t i, lasti = 2+FMTP_CHARS; - if (p == 0) { - addstr(L, sb, "NULL", 4); - break; - } -#if LJ_64 - /* Shorten output for 64 bit pointers. */ - lasti = 2+2*4+((p >> 32) ? 2+2*(lj_fls((uint32_t)(p >> 32))>>3) : 0); -#endif - buf[0] = '0'; - buf[1] = 'x'; - for (i = lasti-1; i >= 2; i--, p >>= 4) - buf[i] = "0123456789abcdef"[(p & 15)]; - addstr(L, sb, buf, (MSize)lasti); - break; - } - case '%': - addchar(L, sb, '%'); - break; - default: - addchar(L, sb, '%'); - addchar(L, sb, e[1]); - break; - } - fmt = e+2; - } - addstr(L, sb, fmt, (MSize)strlen(fmt)); - setstrV(L, L->top, lj_str_new(L, sb->buf, sb->n)); - incr_top(L); - return strVdata(L->top - 1); -} - -/* Push formatted message as a string object to Lua stack. Vararg variant. */ -const char *lj_str_pushf(lua_State *L, const char *fmt, ...) -{ - const char *msg; - va_list argp; - va_start(argp, fmt); - msg = lj_str_pushvf(L, fmt, argp); - va_end(argp); - return msg; -} - -/* -- Buffer handling ----------------------------------------------------- */ - -char *lj_str_needbuf(lua_State *L, SBuf *sb, MSize sz) -{ - if (sz > sb->sz) { - if (sz < LJ_MIN_SBUF) sz = LJ_MIN_SBUF; - lj_str_resizebuf(L, sb, sz); - } - return sb->buf; -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_str.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_str.h deleted file mode 100644 index 1602c980c..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_str.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -** String handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_STR_H -#define _LJ_STR_H - -#include - -#include "lj_obj.h" - -/* String interning. */ -LJ_FUNC int32_t LJ_FASTCALL lj_str_cmp(GCstr *a, GCstr *b); -LJ_FUNC void lj_str_resize(lua_State *L, MSize newmask); -LJ_FUNCA GCstr *lj_str_new(lua_State *L, const char *str, size_t len); -LJ_FUNC void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s); - -#define lj_str_newz(L, s) (lj_str_new(L, s, strlen(s))) -#define lj_str_newlit(L, s) (lj_str_new(L, "" s, sizeof(s)-1)) - -/* Type conversions. */ -LJ_FUNC size_t LJ_FASTCALL lj_str_bufnum(char *s, cTValue *o); -LJ_FUNC char * LJ_FASTCALL lj_str_bufint(char *p, int32_t k); -LJ_FUNCA GCstr * LJ_FASTCALL lj_str_fromnum(lua_State *L, const lua_Number *np); -LJ_FUNC GCstr * LJ_FASTCALL lj_str_fromint(lua_State *L, int32_t k); -LJ_FUNCA GCstr * LJ_FASTCALL lj_str_fromnumber(lua_State *L, cTValue *o); - -#define LJ_STR_INTBUF (1+10) -#define LJ_STR_NUMBUF LUAI_MAXNUMBER2STR - -/* String formatting. */ -LJ_FUNC const char *lj_str_pushvf(lua_State *L, const char *fmt, va_list argp); -LJ_FUNC const char *lj_str_pushf(lua_State *L, const char *fmt, ...) -#if defined(__GNUC__) - __attribute__ ((format (printf, 2, 3))) -#endif - ; - -/* Resizable string buffers. Struct definition in lj_obj.h. */ -LJ_FUNC char *lj_str_needbuf(lua_State *L, SBuf *sb, MSize sz); - -#define lj_str_initbuf(sb) ((sb)->buf = NULL, (sb)->sz = 0) -#define lj_str_resetbuf(sb) ((sb)->n = 0) -#define lj_str_resizebuf(L, sb, size) \ - ((sb)->buf = (char *)lj_mem_realloc(L, (sb)->buf, (sb)->sz, (size)), \ - (sb)->sz = (size)) -#define lj_str_freebuf(g, sb) lj_mem_free(g, (void *)(sb)->buf, (sb)->sz) - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_strscan.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_strscan.c deleted file mode 100644 index a21c414ab..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_strscan.c +++ /dev/null @@ -1,497 +0,0 @@ -/* -** String scanning. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#include - -#define lj_strscan_c -#define LUA_CORE - -#include "lj_obj.h" -#include "lj_char.h" -#include "lj_strscan.h" - -/* -- Scanning numbers ---------------------------------------------------- */ - -/* -** Rationale for the builtin string to number conversion library: -** -** It removes a dependency on libc's strtod(), which is a true portability -** nightmare. Mainly due to the plethora of supported OS and toolchain -** combinations. Sadly, the various implementations -** a) are often buggy, incomplete (no hex floats) and/or imprecise, -** b) sometimes crash or hang on certain inputs, -** c) return non-standard NaNs that need to be filtered out, and -** d) fail if the locale-specific decimal separator is not a dot, -** which can only be fixed with atrocious workarounds. -** -** Also, most of the strtod() implementations are hopelessly bloated, -** which is not just an I-cache hog, but a problem for static linkage -** on embedded systems, too. -** -** OTOH the builtin conversion function is very compact. Even though it -** does a lot more, like parsing long longs, octal or imaginary numbers -** and returning the result in different formats: -** a) It needs less than 3 KB (!) of machine code (on x64 with -Os), -** b) it doesn't perform any dynamic allocation and, -** c) it needs only around 600 bytes of stack space. -** -** The builtin function is faster than strtod() for typical inputs, e.g. -** "123", "1.5" or "1e6". Arguably, it's slower for very large exponents, -** which are not very common (this could be fixed, if needed). -** -** And most importantly, the builtin function is equally precise on all -** platforms. It correctly converts and rounds any input to a double. -** If this is not the case, please send a bug report -- but PLEASE verify -** that the implementation you're comparing to is not the culprit! -** -** The implementation quickly pre-scans the entire string first and -** handles simple integers on-the-fly. Otherwise, it dispatches to the -** base-specific parser. Hex and octal is straightforward. -** -** Decimal to binary conversion uses a fixed-length circular buffer in -** base 100. Some simple cases are handled directly. For other cases, the -** number in the buffer is up-scaled or down-scaled until the integer part -** is in the proper range. Then the integer part is rounded and converted -** to a double which is finally rescaled to the result. Denormals need -** special treatment to prevent incorrect 'double rounding'. -*/ - -/* Definitions for circular decimal digit buffer (base 100 = 2 digits/byte). */ -#define STRSCAN_DIG 1024 -#define STRSCAN_MAXDIG 800 /* 772 + extra are sufficient. */ -#define STRSCAN_DDIG (STRSCAN_DIG/2) -#define STRSCAN_DMASK (STRSCAN_DDIG-1) - -/* Helpers for circular buffer. */ -#define DNEXT(a) (((a)+1) & STRSCAN_DMASK) -#define DPREV(a) (((a)-1) & STRSCAN_DMASK) -#define DLEN(lo, hi) ((int32_t)(((lo)-(hi)) & STRSCAN_DMASK)) - -#define casecmp(c, k) (((c) | 0x20) == k) - -/* Final conversion to double. */ -static void strscan_double(uint64_t x, TValue *o, int32_t ex2, int32_t neg) -{ - double n; - - /* Avoid double rounding for denormals. */ - if (LJ_UNLIKELY(ex2 <= -1075 && x != 0)) { - /* NYI: all of this generates way too much code on 32 bit CPUs. */ -#if defined(__GNUC__) && LJ_64 - int32_t b = (int32_t)(__builtin_clzll(x)^63); -#else - int32_t b = (x>>32) ? 32+(int32_t)lj_fls((uint32_t)(x>>32)) : - (int32_t)lj_fls((uint32_t)x); -#endif - if ((int32_t)b + ex2 <= -1023 && (int32_t)b + ex2 >= -1075) { - uint64_t rb = (uint64_t)1 << (-1075-ex2); - if ((x & rb) && ((x & (rb+rb+rb-1)))) x += rb+rb; - x = (x & ~(rb+rb-1)); - } - } - - /* Convert to double using a signed int64_t conversion, then rescale. */ - lua_assert((int64_t)x >= 0); - n = (double)(int64_t)x; - if (neg) n = -n; - if (ex2) n = ldexp(n, ex2); - o->n = n; -} - -/* Parse hexadecimal number. */ -static StrScanFmt strscan_hex(const uint8_t *p, TValue *o, - StrScanFmt fmt, uint32_t opt, - int32_t ex2, int32_t neg, uint32_t dig) -{ - uint64_t x = 0; - uint32_t i; - - /* Scan hex digits. */ - for (i = dig > 16 ? 16 : dig ; i; i--, p++) { - uint32_t d = (*p != '.' ? *p : *++p); if (d > '9') d += 9; - x = (x << 4) + (d & 15); - } - - /* Summarize rounding-effect of excess digits. */ - for (i = 16; i < dig; i++, p++) - x |= ((*p != '.' ? *p : *++p) != '0'), ex2 += 4; - - /* Format-specific handling. */ - switch (fmt) { - case STRSCAN_INT: - if (!(opt & STRSCAN_OPT_TONUM) && x < 0x80000000u+neg) { - o->i = neg ? -(int32_t)x : (int32_t)x; - return STRSCAN_INT; /* Fast path for 32 bit integers. */ - } - if (!(opt & STRSCAN_OPT_C)) { fmt = STRSCAN_NUM; break; } - /* fallthrough */ - case STRSCAN_U32: - if (dig > 8) return STRSCAN_ERROR; - o->i = neg ? -(int32_t)x : (int32_t)x; - return STRSCAN_U32; - case STRSCAN_I64: - case STRSCAN_U64: - if (dig > 16) return STRSCAN_ERROR; - o->u64 = neg ? (uint64_t)-(int64_t)x : x; - return fmt; - default: - break; - } - - /* Reduce range then convert to double. */ - if ((x & U64x(c0000000,0000000))) { x = (x >> 2) | (x & 3); ex2 += 2; } - strscan_double(x, o, ex2, neg); - return fmt; -} - -/* Parse octal number. */ -static StrScanFmt strscan_oct(const uint8_t *p, TValue *o, - StrScanFmt fmt, int32_t neg, uint32_t dig) -{ - uint64_t x = 0; - - /* Scan octal digits. */ - if (dig > 22 || (dig == 22 && *p > '1')) return STRSCAN_ERROR; - while (dig-- > 0) { - if (!(*p >= '0' && *p <= '7')) return STRSCAN_ERROR; - x = (x << 3) + (*p++ & 7); - } - - /* Format-specific handling. */ - switch (fmt) { - case STRSCAN_INT: - if (x >= 0x80000000u+neg) fmt = STRSCAN_U32; - /* fallthrough */ - case STRSCAN_U32: - if ((x >> 32)) return STRSCAN_ERROR; - o->i = neg ? -(int32_t)x : (int32_t)x; - break; - default: - case STRSCAN_I64: - case STRSCAN_U64: - o->u64 = neg ? (uint64_t)-(int64_t)x : x; - break; - } - return fmt; -} - -/* Parse decimal number. */ -static StrScanFmt strscan_dec(const uint8_t *p, TValue *o, - StrScanFmt fmt, uint32_t opt, - int32_t ex10, int32_t neg, uint32_t dig) -{ - uint8_t xi[STRSCAN_DDIG], *xip = xi; - - if (dig) { - uint32_t i = dig; - if (i > STRSCAN_MAXDIG) { - ex10 += (int32_t)(i - STRSCAN_MAXDIG); - i = STRSCAN_MAXDIG; - } - /* Scan unaligned leading digit. */ - if (((ex10^i) & 1)) - *xip++ = ((*p != '.' ? *p : *++p) & 15), i--, p++; - /* Scan aligned double-digits. */ - for ( ; i > 1; i -= 2) { - uint32_t d = 10 * ((*p != '.' ? *p : *++p) & 15); p++; - *xip++ = d + ((*p != '.' ? *p : *++p) & 15); p++; - } - /* Scan and realign trailing digit. */ - if (i) *xip++ = 10 * ((*p != '.' ? *p : *++p) & 15), ex10--, p++; - - /* Summarize rounding-effect of excess digits. */ - if (dig > STRSCAN_MAXDIG) { - do { - if ((*p != '.' ? *p : *++p) != '0') { xip[-1] |= 1; break; } - p++; - } while (--dig > STRSCAN_MAXDIG); - dig = STRSCAN_MAXDIG; - } else { /* Simplify exponent. */ - while (ex10 > 0 && dig <= 18) *xip++ = 0, ex10 -= 2, dig += 2; - } - } else { /* Only got zeros. */ - ex10 = 0; - xi[0] = 0; - } - - /* Fast path for numbers in integer format (but handles e.g. 1e6, too). */ - if (dig <= 20 && ex10 == 0) { - uint8_t *xis; - uint64_t x = xi[0]; - double n; - for (xis = xi+1; xis < xip; xis++) x = x * 100 + *xis; - if (!(dig == 20 && (xi[0] > 18 || (int64_t)x >= 0))) { /* No overflow? */ - /* Format-specific handling. */ - switch (fmt) { - case STRSCAN_INT: - if (!(opt & STRSCAN_OPT_TONUM) && x < 0x80000000u+neg) { - o->i = neg ? -(int32_t)x : (int32_t)x; - return STRSCAN_INT; /* Fast path for 32 bit integers. */ - } - if (!(opt & STRSCAN_OPT_C)) { fmt = STRSCAN_NUM; goto plainnumber; } - /* fallthrough */ - case STRSCAN_U32: - if ((x >> 32) != 0) return STRSCAN_ERROR; - o->i = neg ? -(int32_t)x : (int32_t)x; - return STRSCAN_U32; - case STRSCAN_I64: - case STRSCAN_U64: - o->u64 = neg ? (uint64_t)-(int64_t)x : x; - return fmt; - default: - plainnumber: /* Fast path for plain numbers < 2^63. */ - if ((int64_t)x < 0) break; - n = (double)(int64_t)x; - if (neg) n = -n; - o->n = n; - return fmt; - } - } - } - - /* Slow non-integer path. */ - if (fmt == STRSCAN_INT) { - if ((opt & STRSCAN_OPT_C)) return STRSCAN_ERROR; - fmt = STRSCAN_NUM; - } else if (fmt > STRSCAN_INT) { - return STRSCAN_ERROR; - } - { - uint32_t hi = 0, lo = (uint32_t)(xip-xi); - int32_t ex2 = 0, idig = (int32_t)lo + (ex10 >> 1); - - lua_assert(lo > 0 && (ex10 & 1) == 0); - - /* Handle simple overflow/underflow. */ - if (idig > 310/2) { if (neg) setminfV(o); else setpinfV(o); return fmt; } - else if (idig < -326/2) { o->n = neg ? -0.0 : 0.0; return fmt; } - - /* Scale up until we have at least 17 or 18 integer part digits. */ - while (idig < 9 && idig < DLEN(lo, hi)) { - uint32_t i, cy = 0; - ex2 -= 6; - for (i = DPREV(lo); ; i = DPREV(i)) { - uint32_t d = (xi[i] << 6) + cy; - cy = (((d >> 2) * 5243) >> 17); d = d - cy * 100; /* Div/mod 100. */ - xi[i] = (uint8_t)d; - if (i == hi) break; - if (d == 0 && i == DPREV(lo)) lo = i; - } - if (cy) { - hi = DPREV(hi); - if (xi[DPREV(lo)] == 0) lo = DPREV(lo); - else if (hi == lo) { lo = DPREV(lo); xi[DPREV(lo)] |= xi[lo]; } - xi[hi] = (uint8_t)cy; idig++; - } - } - - /* Scale down until no more than 17 or 18 integer part digits remain. */ - while (idig > 9) { - uint32_t i, cy = 0; - ex2 += 6; - for (i = hi; i != lo; i = DNEXT(i)) { - cy += xi[i]; - xi[i] = (cy >> 6); - cy = 100 * (cy & 0x3f); - if (xi[i] == 0 && i == hi) hi = DNEXT(hi), idig--; - } - while (cy) { - if (hi == lo) { xi[DPREV(lo)] |= 1; break; } - xi[lo] = (cy >> 6); lo = DNEXT(lo); - cy = 100 * (cy & 0x3f); - } - } - - /* Collect integer part digits and convert to rescaled double. */ - { - uint64_t x = xi[hi]; - uint32_t i; - for (i = DNEXT(hi); --idig > 0 && i != lo; i = DNEXT(i)) - x = x * 100 + xi[i]; - if (i == lo) { - while (--idig >= 0) x = x * 100; - } else { /* Gather round bit from remaining digits. */ - x <<= 1; ex2--; - do { - if (xi[i]) { x |= 1; break; } - i = DNEXT(i); - } while (i != lo); - } - strscan_double(x, o, ex2, neg); - } - } - return fmt; -} - -/* Scan string containing a number. Returns format. Returns value in o. */ -StrScanFmt lj_strscan_scan(const uint8_t *p, TValue *o, uint32_t opt) -{ - int32_t neg = 0; - - /* Remove leading space, parse sign and non-numbers. */ - if (LJ_UNLIKELY(!lj_char_isdigit(*p))) { - while (lj_char_isspace(*p)) p++; - if (*p == '+' || *p == '-') neg = (*p++ == '-'); - if (LJ_UNLIKELY(*p >= 'A')) { /* Parse "inf", "infinity" or "nan". */ - TValue tmp; - setnanV(&tmp); - if (casecmp(p[0],'i') && casecmp(p[1],'n') && casecmp(p[2],'f')) { - if (neg) setminfV(&tmp); else setpinfV(&tmp); - p += 3; - if (casecmp(p[0],'i') && casecmp(p[1],'n') && casecmp(p[2],'i') && - casecmp(p[3],'t') && casecmp(p[4],'y')) p += 5; - } else if (casecmp(p[0],'n') && casecmp(p[1],'a') && casecmp(p[2],'n')) { - p += 3; - } - while (lj_char_isspace(*p)) p++; - if (*p) return STRSCAN_ERROR; - o->u64 = tmp.u64; - return STRSCAN_NUM; - } - } - - /* Parse regular number. */ - { - StrScanFmt fmt = STRSCAN_INT; - int cmask = LJ_CHAR_DIGIT; - int base = (opt & STRSCAN_OPT_C) && *p == '0' ? 0 : 10; - const uint8_t *sp, *dp = NULL; - uint32_t dig = 0, hasdig = 0, x = 0; - int32_t ex = 0; - - /* Determine base and skip leading zeros. */ - if (LJ_UNLIKELY(*p <= '0')) { - if (*p == '0' && casecmp(p[1], 'x')) - base = 16, cmask = LJ_CHAR_XDIGIT, p += 2; - for ( ; ; p++) { - if (*p == '0') { - hasdig = 1; - } else if (*p == '.') { - if (dp) return STRSCAN_ERROR; - dp = p; - } else { - break; - } - } - } - - /* Preliminary digit and decimal point scan. */ - for (sp = p; ; p++) { - if (LJ_LIKELY(lj_char_isa(*p, cmask))) { - x = x * 10 + (*p & 15); /* For fast path below. */ - dig++; - } else if (*p == '.') { - if (dp) return STRSCAN_ERROR; - dp = p; - } else { - break; - } - } - if (!(hasdig | dig)) return STRSCAN_ERROR; - - /* Handle decimal point. */ - if (dp) { - fmt = STRSCAN_NUM; - if (dig) { - ex = (int32_t)(dp-(p-1)); dp = p-1; - while (ex < 0 && *dp-- == '0') ex++, dig--; /* Skip trailing zeros. */ - if (base == 16) ex *= 4; - } - } - - /* Parse exponent. */ - if (casecmp(*p, (uint32_t)(base == 16 ? 'p' : 'e'))) { - uint32_t xx; - int negx = 0; - fmt = STRSCAN_NUM; p++; - if (*p == '+' || *p == '-') negx = (*p++ == '-'); - if (!lj_char_isdigit(*p)) return STRSCAN_ERROR; - xx = (*p++ & 15); - while (lj_char_isdigit(*p)) { - if (xx < 65536) xx = xx * 10 + (*p & 15); - p++; - } - ex += negx ? -(int32_t)xx : (int32_t)xx; - } - - /* Parse suffix. */ - if (*p) { - /* I (IMAG), U (U32), LL (I64), ULL/LLU (U64), L (long), UL/LU (ulong). */ - /* NYI: f (float). Not needed until cp_number() handles non-integers. */ - if (casecmp(*p, 'i')) { - if (!(opt & STRSCAN_OPT_IMAG)) return STRSCAN_ERROR; - p++; fmt = STRSCAN_IMAG; - } else if (fmt == STRSCAN_INT) { - if (casecmp(*p, 'u')) p++, fmt = STRSCAN_U32; - if (casecmp(*p, 'l')) { - p++; - if (casecmp(*p, 'l')) p++, fmt += STRSCAN_I64 - STRSCAN_INT; - else if (!(opt & STRSCAN_OPT_C)) return STRSCAN_ERROR; - else if (sizeof(long) == 8) fmt += STRSCAN_I64 - STRSCAN_INT; - } - if (casecmp(*p, 'u') && (fmt == STRSCAN_INT || fmt == STRSCAN_I64)) - p++, fmt += STRSCAN_U32 - STRSCAN_INT; - if ((fmt == STRSCAN_U32 && !(opt & STRSCAN_OPT_C)) || - (fmt >= STRSCAN_I64 && !(opt & STRSCAN_OPT_LL))) - return STRSCAN_ERROR; - } - while (lj_char_isspace(*p)) p++; - if (*p) return STRSCAN_ERROR; - } - - /* Fast path for decimal 32 bit integers. */ - if (fmt == STRSCAN_INT && base == 10 && - (dig < 10 || (dig == 10 && *sp <= '2' && x < 0x80000000u+neg))) { - int32_t y = neg ? -(int32_t)x : (int32_t)x; - if ((opt & STRSCAN_OPT_TONUM)) { - o->n = (double)y; - return STRSCAN_NUM; - } else { - o->i = y; - return STRSCAN_INT; - } - } - - /* Dispatch to base-specific parser. */ - if (base == 0 && !(fmt == STRSCAN_NUM || fmt == STRSCAN_IMAG)) - return strscan_oct(sp, o, fmt, neg, dig); - if (base == 16) - fmt = strscan_hex(sp, o, fmt, opt, ex, neg, dig); - else - fmt = strscan_dec(sp, o, fmt, opt, ex, neg, dig); - - /* Try to convert number to integer, if requested. */ - if (fmt == STRSCAN_NUM && (opt & STRSCAN_OPT_TOINT)) { - double n = o->n; - int32_t i = lj_num2int(n); - if (n == (lua_Number)i) { o->i = i; return STRSCAN_INT; } - } - return fmt; - } -} - -int LJ_FASTCALL lj_strscan_num(GCstr *str, TValue *o) -{ - StrScanFmt fmt = lj_strscan_scan((const uint8_t *)strdata(str), o, - STRSCAN_OPT_TONUM); - lua_assert(fmt == STRSCAN_ERROR || fmt == STRSCAN_NUM); - return (fmt != STRSCAN_ERROR); -} - -#if LJ_DUALNUM -int LJ_FASTCALL lj_strscan_number(GCstr *str, TValue *o) -{ - StrScanFmt fmt = lj_strscan_scan((const uint8_t *)strdata(str), o, - STRSCAN_OPT_TOINT); - lua_assert(fmt == STRSCAN_ERROR || fmt == STRSCAN_NUM || fmt == STRSCAN_INT); - if (fmt == STRSCAN_INT) setitype(o, LJ_TISNUM); - return (fmt != STRSCAN_ERROR); -} -#endif - -#undef DNEXT -#undef DPREV -#undef DLEN - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_strscan.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_strscan.h deleted file mode 100644 index 15abd6afb..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_strscan.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -** String scanning. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_STRSCAN_H -#define _LJ_STRSCAN_H - -#include "lj_obj.h" - -/* Options for accepted/returned formats. */ -#define STRSCAN_OPT_TOINT 0x01 /* Convert to int32_t, if possible. */ -#define STRSCAN_OPT_TONUM 0x02 /* Always convert to double. */ -#define STRSCAN_OPT_IMAG 0x04 -#define STRSCAN_OPT_LL 0x08 -#define STRSCAN_OPT_C 0x10 - -/* Returned format. */ -typedef enum { - STRSCAN_ERROR, - STRSCAN_NUM, STRSCAN_IMAG, - STRSCAN_INT, STRSCAN_U32, STRSCAN_I64, STRSCAN_U64, -} StrScanFmt; - -LJ_FUNC StrScanFmt lj_strscan_scan(const uint8_t *p, TValue *o, uint32_t opt); -LJ_FUNC int LJ_FASTCALL lj_strscan_num(GCstr *str, TValue *o); -#if LJ_DUALNUM -LJ_FUNC int LJ_FASTCALL lj_strscan_number(GCstr *str, TValue *o); -#else -#define lj_strscan_number(s, o) lj_strscan_num((s), (o)) -#endif - -/* Check for number or convert string to number/int in-place (!). */ -static LJ_AINLINE int lj_strscan_numberobj(TValue *o) -{ - return tvisnumber(o) || (tvisstr(o) && lj_strscan_number(strV(o), o)); -} - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_tab.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_tab.c deleted file mode 100644 index fc7d0f1c1..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_tab.c +++ /dev/null @@ -1,631 +0,0 @@ -/* -** Table handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Major portions taken verbatim or adapted from the Lua interpreter. -** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h -*/ - -#define lj_tab_c -#define LUA_CORE - -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_tab.h" - -/* -- Object hashing ------------------------------------------------------ */ - -/* Hash values are masked with the table hash mask and used as an index. */ -static LJ_AINLINE Node *hashmask(const GCtab *t, uint32_t hash) -{ - Node *n = noderef(t->node); - return &n[hash & t->hmask]; -} - -/* String hashes are precomputed when they are interned. */ -#define hashstr(t, s) hashmask(t, (s)->hash) - -#define hashlohi(t, lo, hi) hashmask((t), hashrot((lo), (hi))) -#define hashnum(t, o) hashlohi((t), (o)->u32.lo, ((o)->u32.hi << 1)) -#define hashptr(t, p) hashlohi((t), u32ptr(p), u32ptr(p) + HASH_BIAS) -#define hashgcref(t, r) hashlohi((t), gcrefu(r), gcrefu(r) + HASH_BIAS) - -/* Hash an arbitrary key and return its anchor position in the hash table. */ -static Node *hashkey(const GCtab *t, cTValue *key) -{ - lua_assert(!tvisint(key)); - if (tvisstr(key)) - return hashstr(t, strV(key)); - else if (tvisnum(key)) - return hashnum(t, key); - else if (tvisbool(key)) - return hashmask(t, boolV(key)); - else - return hashgcref(t, key->gcr); - /* Only hash 32 bits of lightuserdata on a 64 bit CPU. Good enough? */ -} - -/* -- Table creation and destruction -------------------------------------- */ - -/* Create new hash part for table. */ -static LJ_AINLINE void newhpart(lua_State *L, GCtab *t, uint32_t hbits) -{ - uint32_t hsize; - Node *node; - lua_assert(hbits != 0); - if (hbits > LJ_MAX_HBITS) - lj_err_msg(L, LJ_ERR_TABOV); - hsize = 1u << hbits; - node = lj_mem_newvec(L, hsize, Node); - setmref(node->freetop, &node[hsize]); - setmref(t->node, node); - t->hmask = hsize-1; -} - -/* -** Q: Why all of these copies of t->hmask, t->node etc. to local variables? -** A: Because alias analysis for C is _really_ tough. -** Even state-of-the-art C compilers won't produce good code without this. -*/ - -/* Clear hash part of table. */ -static LJ_AINLINE void clearhpart(GCtab *t) -{ - uint32_t i, hmask = t->hmask; - Node *node = noderef(t->node); - lua_assert(t->hmask != 0); - for (i = 0; i <= hmask; i++) { - Node *n = &node[i]; - setmref(n->next, NULL); - setnilV(&n->key); - setnilV(&n->val); - } -} - -/* Clear array part of table. */ -static LJ_AINLINE void clearapart(GCtab *t) -{ - uint32_t i, asize = t->asize; - TValue *array = tvref(t->array); - for (i = 0; i < asize; i++) - setnilV(&array[i]); -} - -/* Create a new table. Note: the slots are not initialized (yet). */ -static GCtab *newtab(lua_State *L, uint32_t asize, uint32_t hbits) -{ - GCtab *t; - /* First try to colocate the array part. */ - if (LJ_MAX_COLOSIZE != 0 && asize > 0 && asize <= LJ_MAX_COLOSIZE) { - lua_assert((sizeof(GCtab) & 7) == 0); - t = (GCtab *)lj_mem_newgco(L, sizetabcolo(asize)); - t->gct = ~LJ_TTAB; - t->nomm = (uint8_t)~0; - t->colo = (int8_t)asize; - setmref(t->array, (TValue *)((char *)t + sizeof(GCtab))); - setgcrefnull(t->metatable); - t->asize = asize; - t->hmask = 0; - setmref(t->node, &G(L)->nilnode); - } else { /* Otherwise separately allocate the array part. */ - t = lj_mem_newobj(L, GCtab); - t->gct = ~LJ_TTAB; - t->nomm = (uint8_t)~0; - t->colo = 0; - setmref(t->array, NULL); - setgcrefnull(t->metatable); - t->asize = 0; /* In case the array allocation fails. */ - t->hmask = 0; - setmref(t->node, &G(L)->nilnode); - if (asize > 0) { - if (asize > LJ_MAX_ASIZE) - lj_err_msg(L, LJ_ERR_TABOV); - setmref(t->array, lj_mem_newvec(L, asize, TValue)); - t->asize = asize; - } - } - if (hbits) - newhpart(L, t, hbits); - return t; -} - -/* Create a new table. -** -** IMPORTANT NOTE: The API differs from lua_createtable()! -** -** The array size is non-inclusive. E.g. asize=128 creates array slots -** for 0..127, but not for 128. If you need slots 1..128, pass asize=129 -** (slot 0 is wasted in this case). -** -** The hash size is given in hash bits. hbits=0 means no hash part. -** hbits=1 creates 2 hash slots, hbits=2 creates 4 hash slots and so on. -*/ -GCtab *lj_tab_new(lua_State *L, uint32_t asize, uint32_t hbits) -{ - GCtab *t = newtab(L, asize, hbits); - clearapart(t); - if (t->hmask > 0) clearhpart(t); - return t; -} - -#if LJ_HASJIT -GCtab * LJ_FASTCALL lj_tab_new1(lua_State *L, uint32_t ahsize) -{ - GCtab *t = newtab(L, ahsize & 0xffffff, ahsize >> 24); - clearapart(t); - if (t->hmask > 0) clearhpart(t); - return t; -} -#endif - -/* Duplicate a table. */ -GCtab * LJ_FASTCALL lj_tab_dup(lua_State *L, const GCtab *kt) -{ - GCtab *t; - uint32_t asize, hmask; - t = newtab(L, kt->asize, kt->hmask > 0 ? lj_fls(kt->hmask)+1 : 0); - lua_assert(kt->asize == t->asize && kt->hmask == t->hmask); - t->nomm = 0; /* Keys with metamethod names may be present. */ - asize = kt->asize; - if (asize > 0) { - TValue *array = tvref(t->array); - TValue *karray = tvref(kt->array); - if (asize < 64) { /* An inlined loop beats memcpy for < 512 bytes. */ - uint32_t i; - for (i = 0; i < asize; i++) - copyTV(L, &array[i], &karray[i]); - } else { - memcpy(array, karray, asize*sizeof(TValue)); - } - } - hmask = kt->hmask; - if (hmask > 0) { - uint32_t i; - Node *node = noderef(t->node); - Node *knode = noderef(kt->node); - ptrdiff_t d = (char *)node - (char *)knode; - setmref(node->freetop, (Node *)((char *)noderef(knode->freetop) + d)); - for (i = 0; i <= hmask; i++) { - Node *kn = &knode[i]; - Node *n = &node[i]; - Node *next = nextnode(kn); - /* Don't use copyTV here, since it asserts on a copy of a dead key. */ - n->val = kn->val; n->key = kn->key; - setmref(n->next, next == NULL? next : (Node *)((char *)next + d)); - } - } - return t; -} - -/* Free a table. */ -void LJ_FASTCALL lj_tab_free(global_State *g, GCtab *t) -{ - if (t->hmask > 0) - lj_mem_freevec(g, noderef(t->node), t->hmask+1, Node); - if (t->asize > 0 && LJ_MAX_COLOSIZE != 0 && t->colo <= 0) - lj_mem_freevec(g, tvref(t->array), t->asize, TValue); - if (LJ_MAX_COLOSIZE != 0 && t->colo) - lj_mem_free(g, t, sizetabcolo((uint32_t)t->colo & 0x7f)); - else - lj_mem_freet(g, t); -} - -/* -- Table resizing ------------------------------------------------------ */ - -/* Resize a table to fit the new array/hash part sizes. */ -static void resizetab(lua_State *L, GCtab *t, uint32_t asize, uint32_t hbits) -{ - Node *oldnode = noderef(t->node); - uint32_t oldasize = t->asize; - uint32_t oldhmask = t->hmask; - if (asize > oldasize) { /* Array part grows? */ - TValue *array; - uint32_t i; - if (asize > LJ_MAX_ASIZE) - lj_err_msg(L, LJ_ERR_TABOV); - if (LJ_MAX_COLOSIZE != 0 && t->colo > 0) { - /* A colocated array must be separated and copied. */ - TValue *oarray = tvref(t->array); - array = lj_mem_newvec(L, asize, TValue); - t->colo = (int8_t)(t->colo | 0x80); /* Mark as separated (colo < 0). */ - for (i = 0; i < oldasize; i++) - copyTV(L, &array[i], &oarray[i]); - } else { - array = (TValue *)lj_mem_realloc(L, tvref(t->array), - oldasize*sizeof(TValue), asize*sizeof(TValue)); - } - setmref(t->array, array); - t->asize = asize; - for (i = oldasize; i < asize; i++) /* Clear newly allocated slots. */ - setnilV(&array[i]); - } - /* Create new (empty) hash part. */ - if (hbits) { - newhpart(L, t, hbits); - clearhpart(t); - } else { - global_State *g = G(L); - setmref(t->node, &g->nilnode); - t->hmask = 0; - } - if (asize < oldasize) { /* Array part shrinks? */ - TValue *array = tvref(t->array); - uint32_t i; - t->asize = asize; /* Note: This 'shrinks' even colocated arrays. */ - for (i = asize; i < oldasize; i++) /* Reinsert old array values. */ - if (!tvisnil(&array[i])) - copyTV(L, lj_tab_setinth(L, t, (int32_t)i), &array[i]); - /* Physically shrink only separated arrays. */ - if (LJ_MAX_COLOSIZE != 0 && t->colo <= 0) - setmref(t->array, lj_mem_realloc(L, array, - oldasize*sizeof(TValue), asize*sizeof(TValue))); - } - if (oldhmask > 0) { /* Reinsert pairs from old hash part. */ - global_State *g; - uint32_t i; - for (i = 0; i <= oldhmask; i++) { - Node *n = &oldnode[i]; - if (!tvisnil(&n->val)) - copyTV(L, lj_tab_set(L, t, &n->key), &n->val); - } - g = G(L); - lj_mem_freevec(g, oldnode, oldhmask+1, Node); - } -} - -static uint32_t countint(cTValue *key, uint32_t *bins) -{ - lua_assert(!tvisint(key)); - if (tvisnum(key)) { - lua_Number nk = numV(key); - int32_t k = lj_num2int(nk); - if ((uint32_t)k < LJ_MAX_ASIZE && nk == (lua_Number)k) { - bins[(k > 2 ? lj_fls((uint32_t)(k-1)) : 0)]++; - return 1; - } - } - return 0; -} - -static uint32_t countarray(const GCtab *t, uint32_t *bins) -{ - uint32_t na, b, i; - if (t->asize == 0) return 0; - for (na = i = b = 0; b < LJ_MAX_ABITS; b++) { - uint32_t n, top = 2u << b; - TValue *array; - if (top >= t->asize) { - top = t->asize-1; - if (i > top) - break; - } - array = tvref(t->array); - for (n = 0; i <= top; i++) - if (!tvisnil(&array[i])) - n++; - bins[b] += n; - na += n; - } - return na; -} - -static uint32_t counthash(const GCtab *t, uint32_t *bins, uint32_t *narray) -{ - uint32_t total, na, i, hmask = t->hmask; - Node *node = noderef(t->node); - for (total = na = 0, i = 0; i <= hmask; i++) { - Node *n = &node[i]; - if (!tvisnil(&n->val)) { - na += countint(&n->key, bins); - total++; - } - } - *narray += na; - return total; -} - -static uint32_t bestasize(uint32_t bins[], uint32_t *narray) -{ - uint32_t b, sum, na = 0, sz = 0, nn = *narray; - for (b = 0, sum = 0; 2*nn > (1u< 0 && 2*(sum += bins[b]) > (1u<hmask > 0 ? lj_fls(t->hmask)+1 : 0); -} - -/* -- Table getters ------------------------------------------------------- */ - -cTValue * LJ_FASTCALL lj_tab_getinth(GCtab *t, int32_t key) -{ - TValue k; - Node *n; - k.n = (lua_Number)key; - n = hashnum(t, &k); - do { - if (tvisnum(&n->key) && n->key.n == k.n) - return &n->val; - } while ((n = nextnode(n))); - return NULL; -} - -cTValue *lj_tab_getstr(GCtab *t, GCstr *key) -{ - Node *n = hashstr(t, key); - do { - if (tvisstr(&n->key) && strV(&n->key) == key) - return &n->val; - } while ((n = nextnode(n))); - return NULL; -} - -cTValue *lj_tab_get(lua_State *L, GCtab *t, cTValue *key) -{ - if (tvisstr(key)) { - cTValue *tv = lj_tab_getstr(t, strV(key)); - if (tv) - return tv; - } else if (tvisint(key)) { - cTValue *tv = lj_tab_getint(t, intV(key)); - if (tv) - return tv; - } else if (tvisnum(key)) { - lua_Number nk = numV(key); - int32_t k = lj_num2int(nk); - if (nk == (lua_Number)k) { - cTValue *tv = lj_tab_getint(t, k); - if (tv) - return tv; - } else { - goto genlookup; /* Else use the generic lookup. */ - } - } else if (!tvisnil(key)) { - Node *n; - genlookup: - n = hashkey(t, key); - do { - if (lj_obj_equal(&n->key, key)) - return &n->val; - } while ((n = nextnode(n))); - } - return niltv(L); -} - -/* -- Table setters ------------------------------------------------------- */ - -/* Insert new key. Use Brent's variation to optimize the chain length. */ -TValue *lj_tab_newkey(lua_State *L, GCtab *t, cTValue *key) -{ - Node *n = hashkey(t, key); - if (!tvisnil(&n->val) || t->hmask == 0) { - Node *nodebase = noderef(t->node); - Node *collide, *freenode = noderef(nodebase->freetop); - lua_assert(freenode >= nodebase && freenode <= nodebase+t->hmask+1); - do { - if (freenode == nodebase) { /* No free node found? */ - rehashtab(L, t, key); /* Rehash table. */ - return lj_tab_set(L, t, key); /* Retry key insertion. */ - } - } while (!tvisnil(&(--freenode)->key)); - setmref(nodebase->freetop, freenode); - lua_assert(freenode != &G(L)->nilnode); - collide = hashkey(t, &n->key); - if (collide != n) { /* Colliding node not the main node? */ - while (noderef(collide->next) != n) /* Find predecessor. */ - collide = nextnode(collide); - setmref(collide->next, freenode); /* Relink chain. */ - /* Copy colliding node into free node and free main node. */ - freenode->val = n->val; - freenode->key = n->key; - freenode->next = n->next; - setmref(n->next, NULL); - setnilV(&n->val); - /* Rechain pseudo-resurrected string keys with colliding hashes. */ - while (nextnode(freenode)) { - Node *nn = nextnode(freenode); - if (tvisstr(&nn->key) && !tvisnil(&nn->val) && - hashstr(t, strV(&nn->key)) == n) { - freenode->next = nn->next; - nn->next = n->next; - setmref(n->next, nn); - } else { - freenode = nn; - } - } - } else { /* Otherwise use free node. */ - setmrefr(freenode->next, n->next); /* Insert into chain. */ - setmref(n->next, freenode); - n = freenode; - } - } - n->key.u64 = key->u64; - if (LJ_UNLIKELY(tvismzero(&n->key))) - n->key.u64 = 0; - lj_gc_anybarriert(L, t); - lua_assert(tvisnil(&n->val)); - return &n->val; -} - -TValue *lj_tab_setinth(lua_State *L, GCtab *t, int32_t key) -{ - TValue k; - Node *n; - k.n = (lua_Number)key; - n = hashnum(t, &k); - do { - if (tvisnum(&n->key) && n->key.n == k.n) - return &n->val; - } while ((n = nextnode(n))); - return lj_tab_newkey(L, t, &k); -} - -TValue *lj_tab_setstr(lua_State *L, GCtab *t, GCstr *key) -{ - TValue k; - Node *n = hashstr(t, key); - do { - if (tvisstr(&n->key) && strV(&n->key) == key) - return &n->val; - } while ((n = nextnode(n))); - setstrV(L, &k, key); - return lj_tab_newkey(L, t, &k); -} - -TValue *lj_tab_set(lua_State *L, GCtab *t, cTValue *key) -{ - Node *n; - t->nomm = 0; /* Invalidate negative metamethod cache. */ - if (tvisstr(key)) { - return lj_tab_setstr(L, t, strV(key)); - } else if (tvisint(key)) { - return lj_tab_setint(L, t, intV(key)); - } else if (tvisnum(key)) { - lua_Number nk = numV(key); - int32_t k = lj_num2int(nk); - if (nk == (lua_Number)k) - return lj_tab_setint(L, t, k); - if (tvisnan(key)) - lj_err_msg(L, LJ_ERR_NANIDX); - /* Else use the generic lookup. */ - } else if (tvisnil(key)) { - lj_err_msg(L, LJ_ERR_NILIDX); - } - n = hashkey(t, key); - do { - if (lj_obj_equal(&n->key, key)) - return &n->val; - } while ((n = nextnode(n))); - return lj_tab_newkey(L, t, key); -} - -/* -- Table traversal ----------------------------------------------------- */ - -/* Get the traversal index of a key. */ -static uint32_t keyindex(lua_State *L, GCtab *t, cTValue *key) -{ - TValue tmp; - if (tvisint(key)) { - int32_t k = intV(key); - if ((uint32_t)k < t->asize) - return (uint32_t)k; /* Array key indexes: [0..t->asize-1] */ - setnumV(&tmp, (lua_Number)k); - key = &tmp; - } else if (tvisnum(key)) { - lua_Number nk = numV(key); - int32_t k = lj_num2int(nk); - if ((uint32_t)k < t->asize && nk == (lua_Number)k) - return (uint32_t)k; /* Array key indexes: [0..t->asize-1] */ - } - if (!tvisnil(key)) { - Node *n = hashkey(t, key); - do { - if (lj_obj_equal(&n->key, key)) - return t->asize + (uint32_t)(n - noderef(t->node)); - /* Hash key indexes: [t->asize..t->asize+t->nmask] */ - } while ((n = nextnode(n))); - if (key->u32.hi == 0xfffe7fff) /* ITERN was despecialized while running. */ - return key->u32.lo - 1; - lj_err_msg(L, LJ_ERR_NEXTIDX); - return 0; /* unreachable */ - } - return ~0u; /* A nil key starts the traversal. */ -} - -/* Advance to the next step in a table traversal. */ -int lj_tab_next(lua_State *L, GCtab *t, TValue *key) -{ - uint32_t i = keyindex(L, t, key); /* Find predecessor key index. */ - for (i++; i < t->asize; i++) /* First traverse the array keys. */ - if (!tvisnil(arrayslot(t, i))) { - setintV(key, i); - copyTV(L, key+1, arrayslot(t, i)); - return 1; - } - for (i -= t->asize; i <= t->hmask; i++) { /* Then traverse the hash keys. */ - Node *n = &noderef(t->node)[i]; - if (!tvisnil(&n->val)) { - copyTV(L, key, &n->key); - copyTV(L, key+1, &n->val); - return 1; - } - } - return 0; /* End of traversal. */ -} - -/* -- Table length calculation -------------------------------------------- */ - -static MSize unbound_search(GCtab *t, MSize j) -{ - cTValue *tv; - MSize i = j; /* i is zero or a present index */ - j++; - /* find `i' and `j' such that i is present and j is not */ - while ((tv = lj_tab_getint(t, (int32_t)j)) && !tvisnil(tv)) { - i = j; - j *= 2; - if (j > (MSize)(INT_MAX-2)) { /* overflow? */ - /* table was built with bad purposes: resort to linear search */ - i = 1; - while ((tv = lj_tab_getint(t, (int32_t)i)) && !tvisnil(tv)) i++; - return i - 1; - } - } - /* now do a binary search between them */ - while (j - i > 1) { - MSize m = (i+j)/2; - cTValue *tvb = lj_tab_getint(t, (int32_t)m); - if (tvb && !tvisnil(tvb)) i = m; else j = m; - } - return i; -} - -/* -** Try to find a boundary in table `t'. A `boundary' is an integer index -** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). -*/ -MSize LJ_FASTCALL lj_tab_len(GCtab *t) -{ - MSize j = (MSize)t->asize; - if (j > 1 && tvisnil(arrayslot(t, j-1))) { - MSize i = 1; - while (j - i > 1) { - MSize m = (i+j)/2; - if (tvisnil(arrayslot(t, m-1))) j = m; else i = m; - } - return i-1; - } - if (j) j--; - if (t->hmask <= 0) - return j; - return unbound_search(t, j); -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_tab.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_tab.h deleted file mode 100644 index 44b1bbbd9..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_tab.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -** Table handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_TAB_H -#define _LJ_TAB_H - -#include "lj_obj.h" - -/* Hash constants. Tuned using a brute force search. */ -#define HASH_BIAS (-0x04c11db7) -#define HASH_ROT1 14 -#define HASH_ROT2 5 -#define HASH_ROT3 13 - -/* Scramble the bits of numbers and pointers. */ -static LJ_AINLINE uint32_t hashrot(uint32_t lo, uint32_t hi) -{ -#if LJ_TARGET_X86ORX64 - /* Prefer variant that compiles well for a 2-operand CPU. */ - lo ^= hi; hi = lj_rol(hi, HASH_ROT1); - lo -= hi; hi = lj_rol(hi, HASH_ROT2); - hi ^= lo; hi -= lj_rol(lo, HASH_ROT3); -#else - lo ^= hi; - lo = lo - lj_rol(hi, HASH_ROT1); - hi = lo ^ lj_rol(hi, HASH_ROT1 + HASH_ROT2); - hi = hi - lj_rol(lo, HASH_ROT3); -#endif - return hi; -} - -#define hsize2hbits(s) ((s) ? ((s)==1 ? 1 : 1+lj_fls((uint32_t)((s)-1))) : 0) - -LJ_FUNCA GCtab *lj_tab_new(lua_State *L, uint32_t asize, uint32_t hbits); -#if LJ_HASJIT -LJ_FUNC GCtab * LJ_FASTCALL lj_tab_new1(lua_State *L, uint32_t ahsize); -#endif -LJ_FUNCA GCtab * LJ_FASTCALL lj_tab_dup(lua_State *L, const GCtab *kt); -LJ_FUNC void LJ_FASTCALL lj_tab_free(global_State *g, GCtab *t); -#if LJ_HASFFI -LJ_FUNC void lj_tab_rehash(lua_State *L, GCtab *t); -#endif -LJ_FUNCA void lj_tab_reasize(lua_State *L, GCtab *t, uint32_t nasize); - -/* Caveat: all getters except lj_tab_get() can return NULL! */ - -LJ_FUNCA cTValue * LJ_FASTCALL lj_tab_getinth(GCtab *t, int32_t key); -LJ_FUNC cTValue *lj_tab_getstr(GCtab *t, GCstr *key); -LJ_FUNCA cTValue *lj_tab_get(lua_State *L, GCtab *t, cTValue *key); - -/* Caveat: all setters require a write barrier for the stored value. */ - -LJ_FUNCA TValue *lj_tab_newkey(lua_State *L, GCtab *t, cTValue *key); -LJ_FUNC TValue *lj_tab_setinth(lua_State *L, GCtab *t, int32_t key); -LJ_FUNC TValue *lj_tab_setstr(lua_State *L, GCtab *t, GCstr *key); -LJ_FUNC TValue *lj_tab_set(lua_State *L, GCtab *t, cTValue *key); - -#define inarray(t, key) ((MSize)(key) < (MSize)(t)->asize) -#define arrayslot(t, i) (&tvref((t)->array)[(i)]) -#define lj_tab_getint(t, key) \ - (inarray((t), (key)) ? arrayslot((t), (key)) : lj_tab_getinth((t), (key))) -#define lj_tab_setint(L, t, key) \ - (inarray((t), (key)) ? arrayslot((t), (key)) : lj_tab_setinth(L, (t), (key))) - -LJ_FUNCA int lj_tab_next(lua_State *L, GCtab *t, TValue *key); -LJ_FUNCA MSize LJ_FASTCALL lj_tab_len(GCtab *t); - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_target.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_target.h deleted file mode 100644 index 820a97a45..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_target.h +++ /dev/null @@ -1,162 +0,0 @@ -/* -** Definitions for target CPU. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_TARGET_H -#define _LJ_TARGET_H - -#include "lj_def.h" -#include "lj_arch.h" - -/* -- Registers and spill slots ------------------------------------------- */ - -/* Register type (uint8_t in ir->r). */ -typedef uint32_t Reg; - -/* The hi-bit is NOT set for an allocated register. This means the value -** can be directly used without masking. The hi-bit is set for a register -** allocation hint or for RID_INIT, RID_SINK or RID_SUNK. -*/ -#define RID_NONE 0x80 -#define RID_MASK 0x7f -#define RID_INIT (RID_NONE|RID_MASK) -#define RID_SINK (RID_INIT-1) -#define RID_SUNK (RID_INIT-2) - -#define ra_noreg(r) ((r) & RID_NONE) -#define ra_hasreg(r) (!((r) & RID_NONE)) - -/* The ra_hashint() macro assumes a previous test for ra_noreg(). */ -#define ra_hashint(r) ((r) < RID_SUNK) -#define ra_gethint(r) ((Reg)((r) & RID_MASK)) -#define ra_sethint(rr, r) rr = (uint8_t)((r)|RID_NONE) -#define ra_samehint(r1, r2) (ra_gethint((r1)^(r2)) == 0) - -/* Spill slot 0 means no spill slot has been allocated. */ -#define SPS_NONE 0 - -#define ra_hasspill(s) ((s) != SPS_NONE) - -/* Combined register and spill slot (uint16_t in ir->prev). */ -typedef uint32_t RegSP; - -#define REGSP(r, s) ((r) + ((s) << 8)) -#define REGSP_HINT(r) ((r)|RID_NONE) -#define REGSP_INIT REGSP(RID_INIT, 0) - -#define regsp_reg(rs) ((rs) & 255) -#define regsp_spill(rs) ((rs) >> 8) -#define regsp_used(rs) \ - (((rs) & ~REGSP(RID_MASK, 0)) != REGSP(RID_NONE, 0)) - -/* -- Register sets ------------------------------------------------------- */ - -/* Bitset for registers. 32 registers suffice for most architectures. -** Note that one set holds bits for both GPRs and FPRs. -*/ -#if LJ_TARGET_PPC || LJ_TARGET_MIPS -typedef uint64_t RegSet; -#else -typedef uint32_t RegSet; -#endif - -#define RID2RSET(r) (((RegSet)1) << (r)) -#define RSET_EMPTY ((RegSet)0) -#define RSET_RANGE(lo, hi) ((RID2RSET((hi)-(lo))-1) << (lo)) - -#define rset_test(rs, r) ((int)((rs) >> (r)) & 1) -#define rset_set(rs, r) (rs |= RID2RSET(r)) -#define rset_clear(rs, r) (rs &= ~RID2RSET(r)) -#define rset_exclude(rs, r) (rs & ~RID2RSET(r)) -#if LJ_TARGET_PPC || LJ_TARGET_MIPS -#define rset_picktop(rs) ((Reg)(__builtin_clzll(rs)^63)) -#define rset_pickbot(rs) ((Reg)__builtin_ctzll(rs)) -#else -#define rset_picktop(rs) ((Reg)lj_fls(rs)) -#define rset_pickbot(rs) ((Reg)lj_ffs(rs)) -#endif - -/* -- Register allocation cost -------------------------------------------- */ - -/* The register allocation heuristic keeps track of the cost for allocating -** a specific register: -** -** A free register (obviously) has a cost of 0 and a 1-bit in the free mask. -** -** An already allocated register has the (non-zero) IR reference in the lowest -** bits and the result of a blended cost-model in the higher bits. -** -** The allocator first checks the free mask for a hit. Otherwise an (unrolled) -** linear search for the minimum cost is used. The search doesn't need to -** keep track of the position of the minimum, which makes it very fast. -** The lowest bits of the minimum cost show the desired IR reference whose -** register is the one to evict. -** -** Without the cost-model this degenerates to the standard heuristics for -** (reverse) linear-scan register allocation. Since code generation is done -** in reverse, a live interval extends from the last use to the first def. -** For an SSA IR the IR reference is the first (and only) def and thus -** trivially marks the end of the interval. The LSRA heuristics says to pick -** the register whose live interval has the furthest extent, i.e. the lowest -** IR reference in our case. -** -** A cost-model should take into account other factors, like spill-cost and -** restore- or rematerialization-cost, which depend on the kind of instruction. -** E.g. constants have zero spill costs, variant instructions have higher -** costs than invariants and PHIs should preferably never be spilled. -** -** Here's a first cut at simple, but effective blended cost-model for R-LSRA: -** - Due to careful design of the IR, constants already have lower IR -** references than invariants and invariants have lower IR references -** than variants. -** - The cost in the upper 16 bits is the sum of the IR reference and a -** weighted score. The score currently only takes into account whether -** the IRT_ISPHI bit is set in the instruction type. -** - The PHI weight is the minimum distance (in IR instructions) a PHI -** reference has to be further apart from a non-PHI reference to be spilled. -** - It should be a power of two (for speed) and must be between 2 and 32768. -** Good values for the PHI weight seem to be between 40 and 150. -** - Further study is required. -*/ -#define REGCOST_PHI_WEIGHT 64 - -/* Cost for allocating a specific register. */ -typedef uint32_t RegCost; - -/* Note: assumes 16 bit IRRef1. */ -#define REGCOST(cost, ref) ((RegCost)(ref) + ((RegCost)(cost) << 16)) -#define regcost_ref(rc) ((IRRef1)(rc)) - -#define REGCOST_T(t) \ - ((RegCost)((t)&IRT_ISPHI) * (((RegCost)(REGCOST_PHI_WEIGHT)<<16)/IRT_ISPHI)) -#define REGCOST_REF_T(ref, t) (REGCOST((ref), (ref)) + REGCOST_T((t))) - -/* -- Target-specific definitions ----------------------------------------- */ - -#if LJ_TARGET_X86ORX64 -#include "lj_target_x86.h" -#elif LJ_TARGET_ARM -#include "lj_target_arm.h" -#elif LJ_TARGET_PPC -#include "lj_target_ppc.h" -#elif LJ_TARGET_MIPS -#include "lj_target_mips.h" -#else -#error "Missing include for target CPU" -#endif - -#ifdef EXITSTUBS_PER_GROUP -/* Return the address of an exit stub. */ -static LJ_AINLINE char *exitstub_addr_(char **group, uint32_t exitno) -{ - lua_assert(group[exitno / EXITSTUBS_PER_GROUP] != NULL); - return (char *)group[exitno / EXITSTUBS_PER_GROUP] + - EXITSTUB_SPACING*(exitno % EXITSTUBS_PER_GROUP); -} -/* Avoid dependence on lj_jit.h if only including lj_target.h. */ -#define exitstub_addr(J, exitno) \ - ((MCode *)exitstub_addr_((char **)((J)->exitstubgroup), (exitno))) -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_target_arm.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_target_arm.h deleted file mode 100644 index 63a0c925d..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_target_arm.h +++ /dev/null @@ -1,274 +0,0 @@ -/* -** Definitions for ARM CPUs. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_TARGET_ARM_H -#define _LJ_TARGET_ARM_H - -/* -- Registers IDs ------------------------------------------------------- */ - -#define GPRDEF(_) \ - _(R0) _(R1) _(R2) _(R3) _(R4) _(R5) _(R6) _(R7) \ - _(R8) _(R9) _(R10) _(R11) _(R12) _(SP) _(LR) _(PC) -#if LJ_SOFTFP -#define FPRDEF(_) -#else -#define FPRDEF(_) \ - _(D0) _(D1) _(D2) _(D3) _(D4) _(D5) _(D6) _(D7) \ - _(D8) _(D9) _(D10) _(D11) _(D12) _(D13) _(D14) _(D15) -#endif -#define VRIDDEF(_) - -#define RIDENUM(name) RID_##name, - -enum { - GPRDEF(RIDENUM) /* General-purpose registers (GPRs). */ - FPRDEF(RIDENUM) /* Floating-point registers (FPRs). */ - RID_MAX, - RID_TMP = RID_LR, - - /* Calling conventions. */ - RID_RET = RID_R0, - RID_RETLO = RID_R0, - RID_RETHI = RID_R1, -#if LJ_SOFTFP - RID_FPRET = RID_R0, -#else - RID_FPRET = RID_D0, -#endif - - /* These definitions must match with the *.dasc file(s): */ - RID_BASE = RID_R9, /* Interpreter BASE. */ - RID_LPC = RID_R6, /* Interpreter PC. */ - RID_DISPATCH = RID_R7, /* Interpreter DISPATCH table. */ - RID_LREG = RID_R8, /* Interpreter L. */ - - /* Register ranges [min, max) and number of registers. */ - RID_MIN_GPR = RID_R0, - RID_MAX_GPR = RID_PC+1, - RID_MIN_FPR = RID_MAX_GPR, -#if LJ_SOFTFP - RID_MAX_FPR = RID_MIN_FPR, -#else - RID_MAX_FPR = RID_D15+1, -#endif - RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR, - RID_NUM_FPR = RID_MAX_FPR - RID_MIN_FPR -}; - -#define RID_NUM_KREF RID_NUM_GPR -#define RID_MIN_KREF RID_R0 - -/* -- Register sets ------------------------------------------------------- */ - -/* Make use of all registers, except sp, lr and pc. */ -#define RSET_GPR (RSET_RANGE(RID_MIN_GPR, RID_R12+1)) -#define RSET_GPREVEN \ - (RID2RSET(RID_R0)|RID2RSET(RID_R2)|RID2RSET(RID_R4)|RID2RSET(RID_R6)| \ - RID2RSET(RID_R8)|RID2RSET(RID_R10)) -#define RSET_GPRODD \ - (RID2RSET(RID_R1)|RID2RSET(RID_R3)|RID2RSET(RID_R5)|RID2RSET(RID_R7)| \ - RID2RSET(RID_R9)|RID2RSET(RID_R11)) -#if LJ_SOFTFP -#define RSET_FPR 0 -#else -#define RSET_FPR (RSET_RANGE(RID_MIN_FPR, RID_MAX_FPR)) -#endif -#define RSET_ALL (RSET_GPR|RSET_FPR) -#define RSET_INIT RSET_ALL - -/* ABI-specific register sets. lr is an implicit scratch register. */ -#define RSET_SCRATCH_GPR_ (RSET_RANGE(RID_R0, RID_R3+1)|RID2RSET(RID_R12)) -#ifdef __APPLE__ -#define RSET_SCRATCH_GPR (RSET_SCRATCH_GPR_|RID2RSET(RID_R9)) -#else -#define RSET_SCRATCH_GPR RSET_SCRATCH_GPR_ -#endif -#if LJ_SOFTFP -#define RSET_SCRATCH_FPR 0 -#else -#define RSET_SCRATCH_FPR (RSET_RANGE(RID_D0, RID_D7+1)) -#endif -#define RSET_SCRATCH (RSET_SCRATCH_GPR|RSET_SCRATCH_FPR) -#define REGARG_FIRSTGPR RID_R0 -#define REGARG_LASTGPR RID_R3 -#define REGARG_NUMGPR 4 -#if LJ_ABI_SOFTFP -#define REGARG_FIRSTFPR 0 -#define REGARG_LASTFPR 0 -#define REGARG_NUMFPR 0 -#else -#define REGARG_FIRSTFPR RID_D0 -#define REGARG_LASTFPR RID_D7 -#define REGARG_NUMFPR 8 -#endif - -/* -- Spill slots --------------------------------------------------------- */ - -/* Spill slots are 32 bit wide. An even/odd pair is used for FPRs. -** -** SPS_FIXED: Available fixed spill slots in interpreter frame. -** This definition must match with the *.dasc file(s). -** -** SPS_FIRST: First spill slot for general use. Reserve min. two 32 bit slots. -*/ -#define SPS_FIXED 2 -#define SPS_FIRST 2 - -#define SPOFS_TMP 0 - -#define sps_scale(slot) (4 * (int32_t)(slot)) -#define sps_align(slot) (((slot) - SPS_FIXED + 1) & ~1) - -/* -- Exit state ---------------------------------------------------------- */ - -/* This definition must match with the *.dasc file(s). */ -typedef struct { -#if !LJ_SOFTFP - lua_Number fpr[RID_NUM_FPR]; /* Floating-point registers. */ -#endif - int32_t gpr[RID_NUM_GPR]; /* General-purpose registers. */ - int32_t spill[256]; /* Spill slots. */ -} ExitState; - -/* PC after instruction that caused an exit. Used to find the trace number. */ -#define EXITSTATE_PCREG RID_PC -/* Highest exit + 1 indicates stack check. */ -#define EXITSTATE_CHECKEXIT 1 - -#define EXITSTUB_SPACING 4 -#define EXITSTUBS_PER_GROUP 32 - -/* -- Instructions -------------------------------------------------------- */ - -/* Instruction fields. */ -#define ARMF_CC(ai, cc) (((ai) ^ ARMI_CCAL) | ((cc) << 28)) -#define ARMF_N(r) ((r) << 16) -#define ARMF_D(r) ((r) << 12) -#define ARMF_S(r) ((r) << 8) -#define ARMF_M(r) (r) -#define ARMF_SH(sh, n) (((sh) << 5) | ((n) << 7)) -#define ARMF_RSH(sh, r) (0x10 | ((sh) << 5) | ARMF_S(r)) - -typedef enum ARMIns { - ARMI_CCAL = 0xe0000000, - ARMI_S = 0x000100000, - ARMI_K12 = 0x02000000, - ARMI_KNEG = 0x00200000, - ARMI_LS_W = 0x00200000, - ARMI_LS_U = 0x00800000, - ARMI_LS_P = 0x01000000, - ARMI_LS_R = 0x02000000, - ARMI_LSX_I = 0x00400000, - - ARMI_AND = 0xe0000000, - ARMI_EOR = 0xe0200000, - ARMI_SUB = 0xe0400000, - ARMI_RSB = 0xe0600000, - ARMI_ADD = 0xe0800000, - ARMI_ADC = 0xe0a00000, - ARMI_SBC = 0xe0c00000, - ARMI_RSC = 0xe0e00000, - ARMI_TST = 0xe1100000, - ARMI_TEQ = 0xe1300000, - ARMI_CMP = 0xe1500000, - ARMI_CMN = 0xe1700000, - ARMI_ORR = 0xe1800000, - ARMI_MOV = 0xe1a00000, - ARMI_BIC = 0xe1c00000, - ARMI_MVN = 0xe1e00000, - - ARMI_NOP = 0xe1a00000, - - ARMI_MUL = 0xe0000090, - ARMI_SMULL = 0xe0c00090, - - ARMI_LDR = 0xe4100000, - ARMI_LDRB = 0xe4500000, - ARMI_LDRH = 0xe01000b0, - ARMI_LDRSB = 0xe01000d0, - ARMI_LDRSH = 0xe01000f0, - ARMI_LDRD = 0xe00000d0, - ARMI_STR = 0xe4000000, - ARMI_STRB = 0xe4400000, - ARMI_STRH = 0xe00000b0, - ARMI_STRD = 0xe00000f0, - ARMI_PUSH = 0xe92d0000, - - ARMI_B = 0xea000000, - ARMI_BL = 0xeb000000, - ARMI_BLX = 0xfa000000, - ARMI_BLXr = 0xe12fff30, - - /* ARMv6 */ - ARMI_REV = 0xe6bf0f30, - ARMI_SXTB = 0xe6af0070, - ARMI_SXTH = 0xe6bf0070, - ARMI_UXTB = 0xe6ef0070, - ARMI_UXTH = 0xe6ff0070, - - /* ARMv6T2 */ - ARMI_MOVW = 0xe3000000, - ARMI_MOVT = 0xe3400000, - - /* VFP */ - ARMI_VMOV_D = 0xeeb00b40, - ARMI_VMOV_S = 0xeeb00a40, - ARMI_VMOVI_D = 0xeeb00b00, - - ARMI_VMOV_R_S = 0xee100a10, - ARMI_VMOV_S_R = 0xee000a10, - ARMI_VMOV_RR_D = 0xec500b10, - ARMI_VMOV_D_RR = 0xec400b10, - - ARMI_VADD_D = 0xee300b00, - ARMI_VSUB_D = 0xee300b40, - ARMI_VMUL_D = 0xee200b00, - ARMI_VMLA_D = 0xee000b00, - ARMI_VMLS_D = 0xee000b40, - ARMI_VNMLS_D = 0xee100b00, - ARMI_VDIV_D = 0xee800b00, - - ARMI_VABS_D = 0xeeb00bc0, - ARMI_VNEG_D = 0xeeb10b40, - ARMI_VSQRT_D = 0xeeb10bc0, - - ARMI_VCMP_D = 0xeeb40b40, - ARMI_VCMPZ_D = 0xeeb50b40, - - ARMI_VMRS = 0xeef1fa10, - - ARMI_VCVT_S32_F32 = 0xeebd0ac0, - ARMI_VCVT_S32_F64 = 0xeebd0bc0, - ARMI_VCVT_U32_F32 = 0xeebc0ac0, - ARMI_VCVT_U32_F64 = 0xeebc0bc0, - ARMI_VCVTR_S32_F32 = 0xeebd0a40, - ARMI_VCVTR_S32_F64 = 0xeebd0b40, - ARMI_VCVTR_U32_F32 = 0xeebc0a40, - ARMI_VCVTR_U32_F64 = 0xeebc0b40, - ARMI_VCVT_F32_S32 = 0xeeb80ac0, - ARMI_VCVT_F64_S32 = 0xeeb80bc0, - ARMI_VCVT_F32_U32 = 0xeeb80a40, - ARMI_VCVT_F64_U32 = 0xeeb80b40, - ARMI_VCVT_F32_F64 = 0xeeb70bc0, - ARMI_VCVT_F64_F32 = 0xeeb70ac0, - - ARMI_VLDR_S = 0xed100a00, - ARMI_VLDR_D = 0xed100b00, - ARMI_VSTR_S = 0xed000a00, - ARMI_VSTR_D = 0xed000b00, -} ARMIns; - -typedef enum ARMShift { - ARMSH_LSL, ARMSH_LSR, ARMSH_ASR, ARMSH_ROR -} ARMShift; - -/* ARM condition codes. */ -typedef enum ARMCC { - CC_EQ, CC_NE, CC_CS, CC_CC, CC_MI, CC_PL, CC_VS, CC_VC, - CC_HI, CC_LS, CC_GE, CC_LT, CC_GT, CC_LE, CC_AL, - CC_HS = CC_CS, CC_LO = CC_CC -} ARMCC; - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_target_mips.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_target_mips.h deleted file mode 100644 index e0fc152d6..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_target_mips.h +++ /dev/null @@ -1,257 +0,0 @@ -/* -** Definitions for MIPS CPUs. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_TARGET_MIPS_H -#define _LJ_TARGET_MIPS_H - -/* -- Registers IDs ------------------------------------------------------- */ - -#define GPRDEF(_) \ - _(R0) _(R1) _(R2) _(R3) _(R4) _(R5) _(R6) _(R7) \ - _(R8) _(R9) _(R10) _(R11) _(R12) _(R13) _(R14) _(R15) \ - _(R16) _(R17) _(R18) _(R19) _(R20) _(R21) _(R22) _(R23) \ - _(R24) _(R25) _(SYS1) _(SYS2) _(R28) _(SP) _(R30) _(RA) -#define FPRDEF(_) \ - _(F0) _(F1) _(F2) _(F3) _(F4) _(F5) _(F6) _(F7) \ - _(F8) _(F9) _(F10) _(F11) _(F12) _(F13) _(F14) _(F15) \ - _(F16) _(F17) _(F18) _(F19) _(F20) _(F21) _(F22) _(F23) \ - _(F24) _(F25) _(F26) _(F27) _(F28) _(F29) _(F30) _(F31) -#define VRIDDEF(_) - -#define RIDENUM(name) RID_##name, - -enum { - GPRDEF(RIDENUM) /* General-purpose registers (GPRs). */ - FPRDEF(RIDENUM) /* Floating-point registers (FPRs). */ - RID_MAX, - RID_ZERO = RID_R0, - RID_TMP = RID_RA, - - /* Calling conventions. */ - RID_RET = RID_R2, -#if LJ_LE - RID_RETHI = RID_R3, - RID_RETLO = RID_R2, -#else - RID_RETHI = RID_R2, - RID_RETLO = RID_R3, -#endif - RID_FPRET = RID_F0, - RID_CFUNCADDR = RID_R25, - - /* These definitions must match with the *.dasc file(s): */ - RID_BASE = RID_R16, /* Interpreter BASE. */ - RID_LPC = RID_R18, /* Interpreter PC. */ - RID_DISPATCH = RID_R19, /* Interpreter DISPATCH table. */ - RID_LREG = RID_R20, /* Interpreter L. */ - RID_JGL = RID_R30, /* On-trace: global_State + 32768. */ - - /* Register ranges [min, max) and number of registers. */ - RID_MIN_GPR = RID_R0, - RID_MAX_GPR = RID_RA+1, - RID_MIN_FPR = RID_F0, - RID_MAX_FPR = RID_F31+1, - RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR, - RID_NUM_FPR = RID_MAX_FPR - RID_MIN_FPR /* Only even regs are used. */ -}; - -#define RID_NUM_KREF RID_NUM_GPR -#define RID_MIN_KREF RID_R0 - -/* -- Register sets ------------------------------------------------------- */ - -/* Make use of all registers, except ZERO, TMP, SP, SYS1, SYS2 and JGL. */ -#define RSET_FIXED \ - (RID2RSET(RID_ZERO)|RID2RSET(RID_TMP)|RID2RSET(RID_SP)|\ - RID2RSET(RID_SYS1)|RID2RSET(RID_SYS2)|RID2RSET(RID_JGL)) -#define RSET_GPR (RSET_RANGE(RID_MIN_GPR, RID_MAX_GPR) - RSET_FIXED) -#define RSET_FPR \ - (RID2RSET(RID_F0)|RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(RID_F6)|\ - RID2RSET(RID_F8)|RID2RSET(RID_F10)|RID2RSET(RID_F12)|RID2RSET(RID_F14)|\ - RID2RSET(RID_F16)|RID2RSET(RID_F18)|RID2RSET(RID_F20)|RID2RSET(RID_F22)|\ - RID2RSET(RID_F24)|RID2RSET(RID_F26)|RID2RSET(RID_F28)|RID2RSET(RID_F30)) -#define RSET_ALL (RSET_GPR|RSET_FPR) -#define RSET_INIT RSET_ALL - -#define RSET_SCRATCH_GPR \ - (RSET_RANGE(RID_R1, RID_R15+1)|\ - RID2RSET(RID_R24)|RID2RSET(RID_R25)|RID2RSET(RID_R28)) -#define RSET_SCRATCH_FPR \ - (RID2RSET(RID_F0)|RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(RID_F6)|\ - RID2RSET(RID_F8)|RID2RSET(RID_F10)|RID2RSET(RID_F12)|RID2RSET(RID_F14)|\ - RID2RSET(RID_F16)|RID2RSET(RID_F18)) -#define RSET_SCRATCH (RSET_SCRATCH_GPR|RSET_SCRATCH_FPR) -#define REGARG_FIRSTGPR RID_R4 -#define REGARG_LASTGPR RID_R7 -#define REGARG_NUMGPR 4 -#define REGARG_FIRSTFPR RID_F12 -#define REGARG_LASTFPR RID_F14 -#define REGARG_NUMFPR 2 - -/* -- Spill slots --------------------------------------------------------- */ - -/* Spill slots are 32 bit wide. An even/odd pair is used for FPRs. -** -** SPS_FIXED: Available fixed spill slots in interpreter frame. -** This definition must match with the *.dasc file(s). -** -** SPS_FIRST: First spill slot for general use. -*/ -#define SPS_FIXED 5 -#define SPS_FIRST 4 - -#define SPOFS_TMP 0 - -#define sps_scale(slot) (4 * (int32_t)(slot)) -#define sps_align(slot) (((slot) - SPS_FIXED + 1) & ~1) - -/* -- Exit state ---------------------------------------------------------- */ - -/* This definition must match with the *.dasc file(s). */ -typedef struct { - lua_Number fpr[RID_NUM_FPR]; /* Floating-point registers. */ - int32_t gpr[RID_NUM_GPR]; /* General-purpose registers. */ - int32_t spill[256]; /* Spill slots. */ -} ExitState; - -/* Highest exit + 1 indicates stack check. */ -#define EXITSTATE_CHECKEXIT 1 - -/* Return the address of a per-trace exit stub. */ -static LJ_AINLINE uint32_t *exitstub_trace_addr_(uint32_t *p) -{ - while (*p == 0x00000000) p++; /* Skip MIPSI_NOP. */ - return p; -} -/* Avoid dependence on lj_jit.h if only including lj_target.h. */ -#define exitstub_trace_addr(T, exitno) \ - exitstub_trace_addr_((MCode *)((char *)(T)->mcode + (T)->szmcode)) - -/* -- Instructions -------------------------------------------------------- */ - -/* Instruction fields. */ -#define MIPSF_S(r) ((r) << 21) -#define MIPSF_T(r) ((r) << 16) -#define MIPSF_D(r) ((r) << 11) -#define MIPSF_R(r) ((r) << 21) -#define MIPSF_H(r) ((r) << 16) -#define MIPSF_G(r) ((r) << 11) -#define MIPSF_F(r) ((r) << 6) -#define MIPSF_A(n) ((n) << 6) -#define MIPSF_M(n) ((n) << 11) - -typedef enum MIPSIns { - /* Integer instructions. */ - MIPSI_MOVE = 0x00000021, - MIPSI_NOP = 0x00000000, - - MIPSI_LI = 0x24000000, - MIPSI_LU = 0x34000000, - MIPSI_LUI = 0x3c000000, - - MIPSI_ADDIU = 0x24000000, - MIPSI_ANDI = 0x30000000, - MIPSI_ORI = 0x34000000, - MIPSI_XORI = 0x38000000, - MIPSI_SLTI = 0x28000000, - MIPSI_SLTIU = 0x2c000000, - - MIPSI_ADDU = 0x00000021, - MIPSI_SUBU = 0x00000023, - MIPSI_MUL = 0x70000002, - MIPSI_AND = 0x00000024, - MIPSI_OR = 0x00000025, - MIPSI_XOR = 0x00000026, - MIPSI_NOR = 0x00000027, - MIPSI_SLT = 0x0000002a, - MIPSI_SLTU = 0x0000002b, - MIPSI_MOVZ = 0x0000000a, - MIPSI_MOVN = 0x0000000b, - - MIPSI_SLL = 0x00000000, - MIPSI_SRL = 0x00000002, - MIPSI_SRA = 0x00000003, - MIPSI_ROTR = 0x00200002, /* MIPS32R2 */ - MIPSI_SLLV = 0x00000004, - MIPSI_SRLV = 0x00000006, - MIPSI_SRAV = 0x00000007, - MIPSI_ROTRV = 0x00000046, /* MIPS32R2 */ - - MIPSI_SEB = 0x7c000420, /* MIPS32R2 */ - MIPSI_SEH = 0x7c000620, /* MIPS32R2 */ - MIPSI_WSBH = 0x7c0000a0, /* MIPS32R2 */ - - MIPSI_B = 0x10000000, - MIPSI_J = 0x08000000, - MIPSI_JAL = 0x0c000000, - MIPSI_JR = 0x00000008, - MIPSI_JALR = 0x0000f809, - - MIPSI_BEQ = 0x10000000, - MIPSI_BNE = 0x14000000, - MIPSI_BLEZ = 0x18000000, - MIPSI_BGTZ = 0x1c000000, - MIPSI_BLTZ = 0x04000000, - MIPSI_BGEZ = 0x04010000, - - /* Load/store instructions. */ - MIPSI_LW = 0x8c000000, - MIPSI_SW = 0xac000000, - MIPSI_LB = 0x80000000, - MIPSI_SB = 0xa0000000, - MIPSI_LH = 0x84000000, - MIPSI_SH = 0xa4000000, - MIPSI_LBU = 0x90000000, - MIPSI_LHU = 0x94000000, - MIPSI_LWC1 = 0xc4000000, - MIPSI_SWC1 = 0xe4000000, - MIPSI_LDC1 = 0xd4000000, - MIPSI_SDC1 = 0xf4000000, - - /* FP instructions. */ - MIPSI_MOV_S = 0x46000006, - MIPSI_MOV_D = 0x46200006, - MIPSI_MOVT_D = 0x46210011, - MIPSI_MOVF_D = 0x46200011, - - MIPSI_ABS_D = 0x46200005, - MIPSI_NEG_D = 0x46200007, - - MIPSI_ADD_D = 0x46200000, - MIPSI_SUB_D = 0x46200001, - MIPSI_MUL_D = 0x46200002, - MIPSI_DIV_D = 0x46200003, - MIPSI_SQRT_D = 0x46200004, - - MIPSI_ADD_S = 0x46000000, - MIPSI_SUB_S = 0x46000001, - - MIPSI_CVT_D_S = 0x46000021, - MIPSI_CVT_W_S = 0x46000024, - MIPSI_CVT_S_D = 0x46200020, - MIPSI_CVT_W_D = 0x46200024, - MIPSI_CVT_S_W = 0x46800020, - MIPSI_CVT_D_W = 0x46800021, - - MIPSI_TRUNC_W_S = 0x4600000d, - MIPSI_TRUNC_W_D = 0x4620000d, - MIPSI_FLOOR_W_S = 0x4600000f, - MIPSI_FLOOR_W_D = 0x4620000f, - - MIPSI_MFC1 = 0x44000000, - MIPSI_MTC1 = 0x44800000, - - MIPSI_BC1F = 0x45000000, - MIPSI_BC1T = 0x45010000, - - MIPSI_C_EQ_D = 0x46200032, - MIPSI_C_OLT_D = 0x46200034, - MIPSI_C_ULT_D = 0x46200035, - MIPSI_C_OLE_D = 0x46200036, - MIPSI_C_ULE_D = 0x46200037, - -} MIPSIns; - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_target_ppc.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_target_ppc.h deleted file mode 100644 index 475e04651..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_target_ppc.h +++ /dev/null @@ -1,280 +0,0 @@ -/* -** Definitions for PPC CPUs. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_TARGET_PPC_H -#define _LJ_TARGET_PPC_H - -/* -- Registers IDs ------------------------------------------------------- */ - -#define GPRDEF(_) \ - _(R0) _(SP) _(SYS1) _(R3) _(R4) _(R5) _(R6) _(R7) \ - _(R8) _(R9) _(R10) _(R11) _(R12) _(SYS2) _(R14) _(R15) \ - _(R16) _(R17) _(R18) _(R19) _(R20) _(R21) _(R22) _(R23) \ - _(R24) _(R25) _(R26) _(R27) _(R28) _(R29) _(R30) _(R31) -#define FPRDEF(_) \ - _(F0) _(F1) _(F2) _(F3) _(F4) _(F5) _(F6) _(F7) \ - _(F8) _(F9) _(F10) _(F11) _(F12) _(F13) _(F14) _(F15) \ - _(F16) _(F17) _(F18) _(F19) _(F20) _(F21) _(F22) _(F23) \ - _(F24) _(F25) _(F26) _(F27) _(F28) _(F29) _(F30) _(F31) -#define VRIDDEF(_) - -#define RIDENUM(name) RID_##name, - -enum { - GPRDEF(RIDENUM) /* General-purpose registers (GPRs). */ - FPRDEF(RIDENUM) /* Floating-point registers (FPRs). */ - RID_MAX, - RID_TMP = RID_R0, - - /* Calling conventions. */ - RID_RET = RID_R3, - RID_RETHI = RID_R3, - RID_RETLO = RID_R4, - RID_FPRET = RID_F1, - - /* These definitions must match with the *.dasc file(s): */ - RID_BASE = RID_R14, /* Interpreter BASE. */ - RID_LPC = RID_R16, /* Interpreter PC. */ - RID_DISPATCH = RID_R17, /* Interpreter DISPATCH table. */ - RID_LREG = RID_R18, /* Interpreter L. */ - RID_JGL = RID_R31, /* On-trace: global_State + 32768. */ - - /* Register ranges [min, max) and number of registers. */ - RID_MIN_GPR = RID_R0, - RID_MAX_GPR = RID_R31+1, - RID_MIN_FPR = RID_F0, - RID_MAX_FPR = RID_F31+1, - RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR, - RID_NUM_FPR = RID_MAX_FPR - RID_MIN_FPR -}; - -#define RID_NUM_KREF RID_NUM_GPR -#define RID_MIN_KREF RID_R0 - -/* -- Register sets ------------------------------------------------------- */ - -/* Make use of all registers, except TMP, SP, SYS1, SYS2 and JGL. */ -#define RSET_FIXED \ - (RID2RSET(RID_TMP)|RID2RSET(RID_SP)|RID2RSET(RID_SYS1)|\ - RID2RSET(RID_SYS2)|RID2RSET(RID_JGL)) -#define RSET_GPR (RSET_RANGE(RID_MIN_GPR, RID_MAX_GPR) - RSET_FIXED) -#define RSET_FPR RSET_RANGE(RID_MIN_FPR, RID_MAX_FPR) -#define RSET_ALL (RSET_GPR|RSET_FPR) -#define RSET_INIT RSET_ALL - -#define RSET_SCRATCH_GPR (RSET_RANGE(RID_R3, RID_R12+1)) -#define RSET_SCRATCH_FPR (RSET_RANGE(RID_F0, RID_F13+1)) -#define RSET_SCRATCH (RSET_SCRATCH_GPR|RSET_SCRATCH_FPR) -#define REGARG_FIRSTGPR RID_R3 -#define REGARG_LASTGPR RID_R10 -#define REGARG_NUMGPR 8 -#define REGARG_FIRSTFPR RID_F1 -#define REGARG_LASTFPR RID_F8 -#define REGARG_NUMFPR 8 - -/* -- Spill slots --------------------------------------------------------- */ - -/* Spill slots are 32 bit wide. An even/odd pair is used for FPRs. -** -** SPS_FIXED: Available fixed spill slots in interpreter frame. -** This definition must match with the *.dasc file(s). -** -** SPS_FIRST: First spill slot for general use. -** [sp+12] tmplo word \ -** [sp+ 8] tmphi word / tmp dword, parameter area for callee -** [sp+ 4] tmpw, LR of callee -** [sp+ 0] stack chain -*/ -#define SPS_FIXED 7 -#define SPS_FIRST 4 - -/* Stack offsets for temporary slots. Used for FP<->int conversions etc. */ -#define SPOFS_TMPW 4 -#define SPOFS_TMP 8 -#define SPOFS_TMPHI 8 -#define SPOFS_TMPLO 12 - -#define sps_scale(slot) (4 * (int32_t)(slot)) -#define sps_align(slot) (((slot) - SPS_FIXED + 3) & ~3) - -/* -- Exit state ---------------------------------------------------------- */ - -/* This definition must match with the *.dasc file(s). */ -typedef struct { - lua_Number fpr[RID_NUM_FPR]; /* Floating-point registers. */ - int32_t gpr[RID_NUM_GPR]; /* General-purpose registers. */ - int32_t spill[256]; /* Spill slots. */ -} ExitState; - -/* Highest exit + 1 indicates stack check. */ -#define EXITSTATE_CHECKEXIT 1 - -/* Return the address of a per-trace exit stub. */ -static LJ_AINLINE uint32_t *exitstub_trace_addr_(uint32_t *p, uint32_t exitno) -{ - while (*p == 0x60000000) p++; /* Skip PPCI_NOP. */ - return p + 3 + exitno; -} -/* Avoid dependence on lj_jit.h if only including lj_target.h. */ -#define exitstub_trace_addr(T, exitno) \ - exitstub_trace_addr_((MCode *)((char *)(T)->mcode + (T)->szmcode), (exitno)) - -/* -- Instructions -------------------------------------------------------- */ - -/* Instruction fields. */ -#define PPCF_CC(cc) ((((cc) & 3) << 16) | (((cc) & 4) << 22)) -#define PPCF_T(r) ((r) << 21) -#define PPCF_A(r) ((r) << 16) -#define PPCF_B(r) ((r) << 11) -#define PPCF_C(r) ((r) << 6) -#define PPCF_MB(n) ((n) << 6) -#define PPCF_ME(n) ((n) << 1) -#define PPCF_Y 0x00200000 -#define PPCF_DOT 0x00000001 - -typedef enum PPCIns { - /* Integer instructions. */ - PPCI_MR = 0x7c000378, - PPCI_NOP = 0x60000000, - - PPCI_LI = 0x38000000, - PPCI_LIS = 0x3c000000, - - PPCI_ADD = 0x7c000214, - PPCI_ADDC = 0x7c000014, - PPCI_ADDO = 0x7c000614, - PPCI_ADDE = 0x7c000114, - PPCI_ADDZE = 0x7c000194, - PPCI_ADDME = 0x7c0001d4, - PPCI_ADDI = 0x38000000, - PPCI_ADDIS = 0x3c000000, - PPCI_ADDIC = 0x30000000, - PPCI_ADDICDOT = 0x34000000, - - PPCI_SUBF = 0x7c000050, - PPCI_SUBFC = 0x7c000010, - PPCI_SUBFO = 0x7c000450, - PPCI_SUBFE = 0x7c000110, - PPCI_SUBFZE = 0x7c000190, - PPCI_SUBFME = 0x7c0001d0, - PPCI_SUBFIC = 0x20000000, - - PPCI_NEG = 0x7c0000d0, - - PPCI_AND = 0x7c000038, - PPCI_ANDC = 0x7c000078, - PPCI_NAND = 0x7c0003b8, - PPCI_ANDIDOT = 0x70000000, - PPCI_ANDISDOT = 0x74000000, - - PPCI_OR = 0x7c000378, - PPCI_NOR = 0x7c0000f8, - PPCI_ORI = 0x60000000, - PPCI_ORIS = 0x64000000, - - PPCI_XOR = 0x7c000278, - PPCI_EQV = 0x7c000238, - PPCI_XORI = 0x68000000, - PPCI_XORIS = 0x6c000000, - - PPCI_CMPW = 0x7c000000, - PPCI_CMPLW = 0x7c000040, - PPCI_CMPWI = 0x2c000000, - PPCI_CMPLWI = 0x28000000, - - PPCI_MULLW = 0x7c0001d6, - PPCI_MULLI = 0x1c000000, - PPCI_MULLWO = 0x7c0005d6, - - PPCI_EXTSB = 0x7c000774, - PPCI_EXTSH = 0x7c000734, - - PPCI_SLW = 0x7c000030, - PPCI_SRW = 0x7c000430, - PPCI_SRAW = 0x7c000630, - PPCI_SRAWI = 0x7c000670, - - PPCI_RLWNM = 0x5c000000, - PPCI_RLWINM = 0x54000000, - PPCI_RLWIMI = 0x50000000, - - PPCI_B = 0x48000000, - PPCI_BL = 0x48000001, - PPCI_BC = 0x40800000, - PPCI_BCL = 0x40800001, - PPCI_BCTR = 0x4e800420, - PPCI_BCTRL = 0x4e800421, - - PPCI_CRANDC = 0x4c000102, - PPCI_CRXOR = 0x4c000182, - PPCI_CRAND = 0x4c000202, - PPCI_CREQV = 0x4c000242, - PPCI_CRORC = 0x4c000342, - PPCI_CROR = 0x4c000382, - - PPCI_MFLR = 0x7c0802a6, - PPCI_MTCTR = 0x7c0903a6, - - PPCI_MCRXR = 0x7c000400, - - /* Load/store instructions. */ - PPCI_LWZ = 0x80000000, - PPCI_LBZ = 0x88000000, - PPCI_STW = 0x90000000, - PPCI_STB = 0x98000000, - PPCI_LHZ = 0xa0000000, - PPCI_LHA = 0xa8000000, - PPCI_STH = 0xb0000000, - - PPCI_STWU = 0x94000000, - - PPCI_LFS = 0xc0000000, - PPCI_LFD = 0xc8000000, - PPCI_STFS = 0xd0000000, - PPCI_STFD = 0xd8000000, - - PPCI_LWZX = 0x7c00002e, - PPCI_LBZX = 0x7c0000ae, - PPCI_STWX = 0x7c00012e, - PPCI_STBX = 0x7c0001ae, - PPCI_LHZX = 0x7c00022e, - PPCI_LHAX = 0x7c0002ae, - PPCI_STHX = 0x7c00032e, - - PPCI_LWBRX = 0x7c00042c, - PPCI_STWBRX = 0x7c00052c, - - PPCI_LFSX = 0x7c00042e, - PPCI_LFDX = 0x7c0004ae, - PPCI_STFSX = 0x7c00052e, - PPCI_STFDX = 0x7c0005ae, - - /* FP instructions. */ - PPCI_FMR = 0xfc000090, - PPCI_FNEG = 0xfc000050, - PPCI_FABS = 0xfc000210, - - PPCI_FRSP = 0xfc000018, - PPCI_FCTIWZ = 0xfc00001e, - - PPCI_FADD = 0xfc00002a, - PPCI_FSUB = 0xfc000028, - PPCI_FMUL = 0xfc000032, - PPCI_FDIV = 0xfc000024, - PPCI_FSQRT = 0xfc00002c, - - PPCI_FMADD = 0xfc00003a, - PPCI_FMSUB = 0xfc000038, - PPCI_FNMSUB = 0xfc00003c, - - PPCI_FCMPU = 0xfc000000, - PPCI_FSEL = 0xfc00002e, -} PPCIns; - -typedef enum PPCCC { - CC_GE, CC_LE, CC_NE, CC_NS, CC_LT, CC_GT, CC_EQ, CC_SO -} PPCCC; - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_target_x86.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_target_x86.h deleted file mode 100644 index 41f401b04..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_target_x86.h +++ /dev/null @@ -1,342 +0,0 @@ -/* -** Definitions for x86 and x64 CPUs. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_TARGET_X86_H -#define _LJ_TARGET_X86_H - -/* -- Registers IDs ------------------------------------------------------- */ - -#if LJ_64 -#define GPRDEF(_) \ - _(EAX) _(ECX) _(EDX) _(EBX) _(ESP) _(EBP) _(ESI) _(EDI) \ - _(R8D) _(R9D) _(R10D) _(R11D) _(R12D) _(R13D) _(R14D) _(R15D) -#define FPRDEF(_) \ - _(XMM0) _(XMM1) _(XMM2) _(XMM3) _(XMM4) _(XMM5) _(XMM6) _(XMM7) \ - _(XMM8) _(XMM9) _(XMM10) _(XMM11) _(XMM12) _(XMM13) _(XMM14) _(XMM15) -#else -#define GPRDEF(_) \ - _(EAX) _(ECX) _(EDX) _(EBX) _(ESP) _(EBP) _(ESI) _(EDI) -#define FPRDEF(_) \ - _(XMM0) _(XMM1) _(XMM2) _(XMM3) _(XMM4) _(XMM5) _(XMM6) _(XMM7) -#endif -#define VRIDDEF(_) \ - _(MRM) - -#define RIDENUM(name) RID_##name, - -enum { - GPRDEF(RIDENUM) /* General-purpose registers (GPRs). */ - FPRDEF(RIDENUM) /* Floating-point registers (FPRs). */ - RID_MAX, - RID_MRM = RID_MAX, /* Pseudo-id for ModRM operand. */ - - /* Calling conventions. */ - RID_RET = RID_EAX, -#if LJ_64 - RID_FPRET = RID_XMM0, -#else - RID_RETLO = RID_EAX, - RID_RETHI = RID_EDX, -#endif - - /* These definitions must match with the *.dasc file(s): */ - RID_BASE = RID_EDX, /* Interpreter BASE. */ -#if LJ_64 && !LJ_ABI_WIN - RID_LPC = RID_EBX, /* Interpreter PC. */ - RID_DISPATCH = RID_R14D, /* Interpreter DISPATCH table. */ -#else - RID_LPC = RID_ESI, /* Interpreter PC. */ - RID_DISPATCH = RID_EBX, /* Interpreter DISPATCH table. */ -#endif - - /* Register ranges [min, max) and number of registers. */ - RID_MIN_GPR = RID_EAX, - RID_MIN_FPR = RID_XMM0, - RID_MAX_GPR = RID_MIN_FPR, - RID_MAX_FPR = RID_MAX, - RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR, - RID_NUM_FPR = RID_MAX_FPR - RID_MIN_FPR, -}; - -/* -- Register sets ------------------------------------------------------- */ - -/* Make use of all registers, except the stack pointer. */ -#define RSET_GPR (RSET_RANGE(RID_MIN_GPR, RID_MAX_GPR)-RID2RSET(RID_ESP)) -#define RSET_FPR (RSET_RANGE(RID_MIN_FPR, RID_MAX_FPR)) -#define RSET_ALL (RSET_GPR|RSET_FPR) -#define RSET_INIT RSET_ALL - -#if LJ_64 -/* Note: this requires the use of FORCE_REX! */ -#define RSET_GPR8 RSET_GPR -#else -#define RSET_GPR8 (RSET_RANGE(RID_EAX, RID_EBX+1)) -#endif - -/* ABI-specific register sets. */ -#define RSET_ACD (RID2RSET(RID_EAX)|RID2RSET(RID_ECX)|RID2RSET(RID_EDX)) -#if LJ_64 -#if LJ_ABI_WIN -/* Windows x64 ABI. */ -#define RSET_SCRATCH \ - (RSET_ACD|RSET_RANGE(RID_R8D, RID_R11D+1)|RSET_RANGE(RID_XMM0, RID_XMM5+1)) -#define REGARG_GPRS \ - (RID_ECX|((RID_EDX|((RID_R8D|(RID_R9D<<5))<<5))<<5)) -#define REGARG_NUMGPR 4 -#define REGARG_NUMFPR 4 -#define REGARG_FIRSTFPR RID_XMM0 -#define REGARG_LASTFPR RID_XMM3 -#define STACKARG_OFS (4*8) -#else -/* The rest of the civilized x64 world has a common ABI. */ -#define RSET_SCRATCH \ - (RSET_ACD|RSET_RANGE(RID_ESI, RID_R11D+1)|RSET_FPR) -#define REGARG_GPRS \ - (RID_EDI|((RID_ESI|((RID_EDX|((RID_ECX|((RID_R8D|(RID_R9D \ - <<5))<<5))<<5))<<5))<<5)) -#define REGARG_NUMGPR 6 -#define REGARG_NUMFPR 8 -#define REGARG_FIRSTFPR RID_XMM0 -#define REGARG_LASTFPR RID_XMM7 -#define STACKARG_OFS 0 -#endif -#else -/* Common x86 ABI. */ -#define RSET_SCRATCH (RSET_ACD|RSET_FPR) -#define REGARG_GPRS (RID_ECX|(RID_EDX<<5)) /* Fastcall only. */ -#define REGARG_NUMGPR 2 /* Fastcall only. */ -#define REGARG_NUMFPR 0 -#define STACKARG_OFS 0 -#endif - -#if LJ_64 -/* Prefer the low 8 regs of each type to reduce REX prefixes. */ -#undef rset_picktop -#define rset_picktop(rs) (lj_fls(lj_bswap(rs)) ^ 0x18) -#endif - -/* -- Spill slots --------------------------------------------------------- */ - -/* Spill slots are 32 bit wide. An even/odd pair is used for FPRs. -** -** SPS_FIXED: Available fixed spill slots in interpreter frame. -** This definition must match with the *.dasc file(s). -** -** SPS_FIRST: First spill slot for general use. Reserve min. two 32 bit slots. -*/ -#if LJ_64 -#if LJ_ABI_WIN -#define SPS_FIXED (4*2) -#define SPS_FIRST (4*2) /* Don't use callee register save area. */ -#else -#define SPS_FIXED 4 -#define SPS_FIRST 2 -#endif -#else -#define SPS_FIXED 6 -#define SPS_FIRST 2 -#endif - -#define SPOFS_TMP 0 - -#define sps_scale(slot) (4 * (int32_t)(slot)) -#define sps_align(slot) (((slot) - SPS_FIXED + 3) & ~3) - -/* -- Exit state ---------------------------------------------------------- */ - -/* This definition must match with the *.dasc file(s). */ -typedef struct { - lua_Number fpr[RID_NUM_FPR]; /* Floating-point registers. */ - intptr_t gpr[RID_NUM_GPR]; /* General-purpose registers. */ - int32_t spill[256]; /* Spill slots. */ -} ExitState; - -/* Limited by the range of a short fwd jump (127): (2+2)*(32-1)-2 = 122. */ -#define EXITSTUB_SPACING (2+2) -#define EXITSTUBS_PER_GROUP 32 - -/* -- x86 ModRM operand encoding ------------------------------------------ */ - -typedef enum { - XM_OFS0 = 0x00, XM_OFS8 = 0x40, XM_OFS32 = 0x80, XM_REG = 0xc0, - XM_SCALE1 = 0x00, XM_SCALE2 = 0x40, XM_SCALE4 = 0x80, XM_SCALE8 = 0xc0, - XM_MASK = 0xc0 -} x86Mode; - -/* Structure to hold variable ModRM operand. */ -typedef struct { - int32_t ofs; /* Offset. */ - uint8_t base; /* Base register or RID_NONE. */ - uint8_t idx; /* Index register or RID_NONE. */ - uint8_t scale; /* Index scale (XM_SCALE1 .. XM_SCALE8). */ -} x86ModRM; - -/* -- Opcodes ------------------------------------------------------------- */ - -/* Macros to construct variable-length x86 opcodes. -(len+1) is in LSB. */ -#define XO_(o) ((uint32_t)(0x0000fe + (0x##o<<24))) -#define XO_FPU(a,b) ((uint32_t)(0x00fd + (0x##a<<16)+(0x##b<<24))) -#define XO_0f(o) ((uint32_t)(0x0f00fd + (0x##o<<24))) -#define XO_66(o) ((uint32_t)(0x6600fd + (0x##o<<24))) -#define XO_660f(o) ((uint32_t)(0x0f66fc + (0x##o<<24))) -#define XO_f20f(o) ((uint32_t)(0x0ff2fc + (0x##o<<24))) -#define XO_f30f(o) ((uint32_t)(0x0ff3fc + (0x##o<<24))) - -/* This list of x86 opcodes is not intended to be complete. Opcodes are only -** included when needed. Take a look at DynASM or jit.dis_x86 to see the -** whole mess. -*/ -typedef enum { - /* Fixed length opcodes. XI_* prefix. */ - XI_NOP = 0x90, - XI_XCHGa = 0x90, - XI_CALL = 0xe8, - XI_JMP = 0xe9, - XI_JMPs = 0xeb, - XI_PUSH = 0x50, /* Really 50+r. */ - XI_JCCs = 0x70, /* Really 7x. */ - XI_JCCn = 0x80, /* Really 0f8x. */ - XI_LEA = 0x8d, - XI_MOVrib = 0xb0, /* Really b0+r. */ - XI_MOVri = 0xb8, /* Really b8+r. */ - XI_ARITHib = 0x80, - XI_ARITHi = 0x81, - XI_ARITHi8 = 0x83, - XI_PUSHi8 = 0x6a, - XI_TESTb = 0x84, - XI_TEST = 0x85, - XI_MOVmi = 0xc7, - XI_GROUP5 = 0xff, - - /* Note: little-endian byte-order! */ - XI_FLDZ = 0xeed9, - XI_FLD1 = 0xe8d9, - XI_FLDLG2 = 0xecd9, - XI_FLDLN2 = 0xedd9, - XI_FDUP = 0xc0d9, /* Really fld st0. */ - XI_FPOP = 0xd8dd, /* Really fstp st0. */ - XI_FPOP1 = 0xd9dd, /* Really fstp st1. */ - XI_FRNDINT = 0xfcd9, - XI_FSIN = 0xfed9, - XI_FCOS = 0xffd9, - XI_FPTAN = 0xf2d9, - XI_FPATAN = 0xf3d9, - XI_FSCALE = 0xfdd9, - XI_FYL2X = 0xf1d9, - - /* Variable-length opcodes. XO_* prefix. */ - XO_MOV = XO_(8b), - XO_MOVto = XO_(89), - XO_MOVtow = XO_66(89), - XO_MOVtob = XO_(88), - XO_MOVmi = XO_(c7), - XO_MOVmib = XO_(c6), - XO_LEA = XO_(8d), - XO_ARITHib = XO_(80), - XO_ARITHi = XO_(81), - XO_ARITHi8 = XO_(83), - XO_ARITHiw8 = XO_66(83), - XO_SHIFTi = XO_(c1), - XO_SHIFT1 = XO_(d1), - XO_SHIFTcl = XO_(d3), - XO_IMUL = XO_0f(af), - XO_IMULi = XO_(69), - XO_IMULi8 = XO_(6b), - XO_CMP = XO_(3b), - XO_TESTb = XO_(84), - XO_TEST = XO_(85), - XO_GROUP3b = XO_(f6), - XO_GROUP3 = XO_(f7), - XO_GROUP5b = XO_(fe), - XO_GROUP5 = XO_(ff), - XO_MOVZXb = XO_0f(b6), - XO_MOVZXw = XO_0f(b7), - XO_MOVSXb = XO_0f(be), - XO_MOVSXw = XO_0f(bf), - XO_MOVSXd = XO_(63), - XO_BSWAP = XO_0f(c8), - XO_CMOV = XO_0f(40), - - XO_MOVSD = XO_f20f(10), - XO_MOVSDto = XO_f20f(11), - XO_MOVSS = XO_f30f(10), - XO_MOVSSto = XO_f30f(11), - XO_MOVLPD = XO_660f(12), - XO_MOVAPS = XO_0f(28), - XO_XORPS = XO_0f(57), - XO_ANDPS = XO_0f(54), - XO_ADDSD = XO_f20f(58), - XO_SUBSD = XO_f20f(5c), - XO_MULSD = XO_f20f(59), - XO_DIVSD = XO_f20f(5e), - XO_SQRTSD = XO_f20f(51), - XO_MINSD = XO_f20f(5d), - XO_MAXSD = XO_f20f(5f), - XO_ROUNDSD = 0x0b3a0ffc, /* Really 66 0f 3a 0b. See asm_fpmath. */ - XO_UCOMISD = XO_660f(2e), - XO_CVTSI2SD = XO_f20f(2a), - XO_CVTSD2SI = XO_f20f(2d), - XO_CVTTSD2SI= XO_f20f(2c), - XO_CVTSI2SS = XO_f30f(2a), - XO_CVTSS2SI = XO_f30f(2d), - XO_CVTTSS2SI= XO_f30f(2c), - XO_CVTSS2SD = XO_f30f(5a), - XO_CVTSD2SS = XO_f20f(5a), - XO_ADDSS = XO_f30f(58), - XO_MOVD = XO_660f(6e), - XO_MOVDto = XO_660f(7e), - - XO_FLDd = XO_(d9), XOg_FLDd = 0, - XO_FLDq = XO_(dd), XOg_FLDq = 0, - XO_FILDd = XO_(db), XOg_FILDd = 0, - XO_FILDq = XO_(df), XOg_FILDq = 5, - XO_FSTPd = XO_(d9), XOg_FSTPd = 3, - XO_FSTPq = XO_(dd), XOg_FSTPq = 3, - XO_FISTPq = XO_(df), XOg_FISTPq = 7, - XO_FISTTPq = XO_(dd), XOg_FISTTPq = 1, - XO_FADDq = XO_(dc), XOg_FADDq = 0, - XO_FLDCW = XO_(d9), XOg_FLDCW = 5, - XO_FNSTCW = XO_(d9), XOg_FNSTCW = 7 -} x86Op; - -/* x86 opcode groups. */ -typedef uint32_t x86Group; - -#define XG_(i8, i, g) ((x86Group)(((i8) << 16) + ((i) << 8) + (g))) -#define XG_ARITHi(g) XG_(XI_ARITHi8, XI_ARITHi, g) -#define XG_TOXOi(xg) ((x86Op)(0x000000fe + (((xg)<<16) & 0xff000000))) -#define XG_TOXOi8(xg) ((x86Op)(0x000000fe + (((xg)<<8) & 0xff000000))) - -#define XO_ARITH(a) ((x86Op)(0x030000fe + ((a)<<27))) -#define XO_ARITHw(a) ((x86Op)(0x036600fd + ((a)<<27))) - -typedef enum { - XOg_ADD, XOg_OR, XOg_ADC, XOg_SBB, XOg_AND, XOg_SUB, XOg_XOR, XOg_CMP, - XOg_X_IMUL -} x86Arith; - -typedef enum { - XOg_ROL, XOg_ROR, XOg_RCL, XOg_RCR, XOg_SHL, XOg_SHR, XOg_SAL, XOg_SAR -} x86Shift; - -typedef enum { - XOg_TEST, XOg_TEST_, XOg_NOT, XOg_NEG, XOg_MUL, XOg_IMUL, XOg_DIV, XOg_IDIV -} x86Group3; - -typedef enum { - XOg_INC, XOg_DEC, XOg_CALL, XOg_CALLfar, XOg_JMP, XOg_JMPfar, XOg_PUSH -} x86Group5; - -/* x86 condition codes. */ -typedef enum { - CC_O, CC_NO, CC_B, CC_NB, CC_E, CC_NE, CC_BE, CC_NBE, - CC_S, CC_NS, CC_P, CC_NP, CC_L, CC_NL, CC_LE, CC_NLE, - CC_C = CC_B, CC_NAE = CC_C, CC_NC = CC_NB, CC_AE = CC_NB, - CC_Z = CC_E, CC_NZ = CC_NE, CC_NA = CC_BE, CC_A = CC_NBE, - CC_PE = CC_P, CC_PO = CC_NP, CC_NGE = CC_L, CC_GE = CC_NL, - CC_NG = CC_LE, CC_G = CC_NLE -} x86CC; - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_trace.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_trace.c deleted file mode 100644 index 9e5e400f4..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_trace.c +++ /dev/null @@ -1,815 +0,0 @@ -/* -** Trace management. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_trace_c -#define LUA_CORE - -#include "lj_obj.h" - -#if LJ_HASJIT - -#include "lj_gc.h" -#include "lj_err.h" -#include "lj_debug.h" -#include "lj_str.h" -#include "lj_frame.h" -#include "lj_state.h" -#include "lj_bc.h" -#include "lj_ir.h" -#include "lj_jit.h" -#include "lj_iropt.h" -#include "lj_mcode.h" -#include "lj_trace.h" -#include "lj_snap.h" -#include "lj_gdbjit.h" -#include "lj_record.h" -#include "lj_asm.h" -#include "lj_dispatch.h" -#include "lj_vm.h" -#include "lj_vmevent.h" -#include "lj_target.h" - -/* -- Error handling ------------------------------------------------------ */ - -/* Synchronous abort with error message. */ -void lj_trace_err(jit_State *J, TraceError e) -{ - setnilV(&J->errinfo); /* No error info. */ - setintV(J->L->top++, (int32_t)e); - lj_err_throw(J->L, LUA_ERRRUN); -} - -/* Synchronous abort with error message and error info. */ -void lj_trace_err_info(jit_State *J, TraceError e) -{ - setintV(J->L->top++, (int32_t)e); - lj_err_throw(J->L, LUA_ERRRUN); -} - -/* -- Trace management ---------------------------------------------------- */ - -/* The current trace is first assembled in J->cur. The variable length -** arrays point to shared, growable buffers (J->irbuf etc.). When trace -** recording ends successfully, the current trace and its data structures -** are copied to a new (compact) GCtrace object. -*/ - -/* Find a free trace number. */ -static TraceNo trace_findfree(jit_State *J) -{ - MSize osz, lim; - if (J->freetrace == 0) - J->freetrace = 1; - for (; J->freetrace < J->sizetrace; J->freetrace++) - if (traceref(J, J->freetrace) == NULL) - return J->freetrace++; - /* Need to grow trace array. */ - lim = (MSize)J->param[JIT_P_maxtrace] + 1; - if (lim < 2) lim = 2; else if (lim > 65535) lim = 65535; - osz = J->sizetrace; - if (osz >= lim) - return 0; /* Too many traces. */ - lj_mem_growvec(J->L, J->trace, J->sizetrace, lim, GCRef); - for (; osz < J->sizetrace; osz++) - setgcrefnull(J->trace[osz]); - return J->freetrace; -} - -#define TRACE_APPENDVEC(field, szfield, tp) \ - T->field = (tp *)p; \ - memcpy(p, J->cur.field, J->cur.szfield*sizeof(tp)); \ - p += J->cur.szfield*sizeof(tp); - -#ifdef LUAJIT_USE_PERFTOOLS -/* -** Create symbol table of JIT-compiled code. For use with Linux perf tools. -** Example usage: -** perf record -f -e cycles luajit test.lua -** perf report -s symbol -** rm perf.data /tmp/perf-*.map -*/ -#include -#include - -static void perftools_addtrace(GCtrace *T) -{ - static FILE *fp; - GCproto *pt = &gcref(T->startpt)->pt; - const BCIns *startpc = mref(T->startpc, const BCIns); - const char *name = proto_chunknamestr(pt); - BCLine lineno; - if (name[0] == '@' || name[0] == '=') - name++; - else - name = "(string)"; - lua_assert(startpc >= proto_bc(pt) && startpc < proto_bc(pt) + pt->sizebc); - lineno = lj_debug_line(pt, proto_bcpos(pt, startpc)); - if (!fp) { - char fname[40]; - sprintf(fname, "/tmp/perf-%d.map", getpid()); - if (!(fp = fopen(fname, "w"))) return; - setlinebuf(fp); - } - fprintf(fp, "%lx %x TRACE_%d::%s:%u\n", - (long)T->mcode, T->szmcode, T->traceno, name, lineno); -} -#endif - -/* Save current trace by copying and compacting it. */ -static void trace_save(jit_State *J) -{ - size_t sztr = ((sizeof(GCtrace)+7)&~7); - size_t szins = (J->cur.nins-J->cur.nk)*sizeof(IRIns); - size_t sz = sztr + szins + - J->cur.nsnap*sizeof(SnapShot) + - J->cur.nsnapmap*sizeof(SnapEntry); - GCtrace *T = lj_mem_newt(J->L, (MSize)sz, GCtrace); - char *p = (char *)T + sztr; - memcpy(T, &J->cur, sizeof(GCtrace)); - setgcrefr(T->nextgc, J2G(J)->gc.root); - setgcrefp(J2G(J)->gc.root, T); - newwhite(J2G(J), T); - T->gct = ~LJ_TTRACE; - T->ir = (IRIns *)p - J->cur.nk; - memcpy(p, J->cur.ir+J->cur.nk, szins); - p += szins; - TRACE_APPENDVEC(snap, nsnap, SnapShot) - TRACE_APPENDVEC(snapmap, nsnapmap, SnapEntry) - J->cur.traceno = 0; - setgcrefp(J->trace[T->traceno], T); - lj_gc_barriertrace(J2G(J), T->traceno); - lj_gdbjit_addtrace(J, T); -#ifdef LUAJIT_USE_PERFTOOLS - perftools_addtrace(T); -#endif -} - -void LJ_FASTCALL lj_trace_free(global_State *g, GCtrace *T) -{ - jit_State *J = G2J(g); - if (T->traceno) { - lj_gdbjit_deltrace(J, T); - if (T->traceno < J->freetrace) - J->freetrace = T->traceno; - setgcrefnull(J->trace[T->traceno]); - } - lj_mem_free(g, T, - ((sizeof(GCtrace)+7)&~7) + (T->nins-T->nk)*sizeof(IRIns) + - T->nsnap*sizeof(SnapShot) + T->nsnapmap*sizeof(SnapEntry)); -} - -/* Re-enable compiling a prototype by unpatching any modified bytecode. */ -void lj_trace_reenableproto(GCproto *pt) -{ - if ((pt->flags & PROTO_ILOOP)) { - BCIns *bc = proto_bc(pt); - BCPos i, sizebc = pt->sizebc;; - pt->flags &= ~PROTO_ILOOP; - if (bc_op(bc[0]) == BC_IFUNCF) - setbc_op(&bc[0], BC_FUNCF); - for (i = 1; i < sizebc; i++) { - BCOp op = bc_op(bc[i]); - if (op == BC_IFORL || op == BC_IITERL || op == BC_ILOOP) - setbc_op(&bc[i], (int)op+(int)BC_LOOP-(int)BC_ILOOP); - } - } -} - -/* Unpatch the bytecode modified by a root trace. */ -static void trace_unpatch(jit_State *J, GCtrace *T) -{ - BCOp op = bc_op(T->startins); - BCIns *pc = mref(T->startpc, BCIns); - UNUSED(J); - if (op == BC_JMP) - return; /* No need to unpatch branches in parent traces (yet). */ - switch (bc_op(*pc)) { - case BC_JFORL: - lua_assert(traceref(J, bc_d(*pc)) == T); - *pc = T->startins; - pc += bc_j(T->startins); - lua_assert(bc_op(*pc) == BC_JFORI); - setbc_op(pc, BC_FORI); - break; - case BC_JITERL: - case BC_JLOOP: - lua_assert(op == BC_ITERL || op == BC_LOOP || bc_isret(op)); - *pc = T->startins; - break; - case BC_JMP: - lua_assert(op == BC_ITERL); - pc += bc_j(*pc)+2; - if (bc_op(*pc) == BC_JITERL) { - lua_assert(traceref(J, bc_d(*pc)) == T); - *pc = T->startins; - } - break; - case BC_JFUNCF: - lua_assert(op == BC_FUNCF); - *pc = T->startins; - break; - default: /* Already unpatched. */ - break; - } -} - -/* Flush a root trace. */ -static void trace_flushroot(jit_State *J, GCtrace *T) -{ - GCproto *pt = &gcref(T->startpt)->pt; - lua_assert(T->root == 0 && pt != NULL); - /* First unpatch any modified bytecode. */ - trace_unpatch(J, T); - /* Unlink root trace from chain anchored in prototype. */ - if (pt->trace == T->traceno) { /* Trace is first in chain. Easy. */ - pt->trace = T->nextroot; - } else if (pt->trace) { /* Otherwise search in chain of root traces. */ - GCtrace *T2 = traceref(J, pt->trace); - if (T2) { - for (; T2->nextroot; T2 = traceref(J, T2->nextroot)) - if (T2->nextroot == T->traceno) { - T2->nextroot = T->nextroot; /* Unlink from chain. */ - break; - } - } - } -} - -/* Flush a trace. Only root traces are considered. */ -void lj_trace_flush(jit_State *J, TraceNo traceno) -{ - if (traceno > 0 && traceno < J->sizetrace) { - GCtrace *T = traceref(J, traceno); - if (T && T->root == 0) - trace_flushroot(J, T); - } -} - -/* Flush all traces associated with a prototype. */ -void lj_trace_flushproto(global_State *g, GCproto *pt) -{ - while (pt->trace != 0) - trace_flushroot(G2J(g), traceref(G2J(g), pt->trace)); -} - -/* Flush all traces. */ -int lj_trace_flushall(lua_State *L) -{ - jit_State *J = L2J(L); - ptrdiff_t i; - if ((J2G(J)->hookmask & HOOK_GC)) - return 1; - for (i = (ptrdiff_t)J->sizetrace-1; i > 0; i--) { - GCtrace *T = traceref(J, i); - if (T) { - if (T->root == 0) - trace_flushroot(J, T); - lj_gdbjit_deltrace(J, T); - T->traceno = 0; - setgcrefnull(J->trace[i]); - } - } - J->cur.traceno = 0; - J->freetrace = 0; - /* Clear penalty cache. */ - memset(J->penalty, 0, sizeof(J->penalty)); - /* Free the whole machine code and invalidate all exit stub groups. */ - lj_mcode_free(J); - memset(J->exitstubgroup, 0, sizeof(J->exitstubgroup)); - lj_vmevent_send(L, TRACE, - setstrV(L, L->top++, lj_str_newlit(L, "flush")); - ); - return 0; -} - -/* Initialize JIT compiler state. */ -void lj_trace_initstate(global_State *g) -{ - jit_State *J = G2J(g); - TValue *tv; - /* Initialize SIMD constants. */ - tv = LJ_KSIMD(J, LJ_KSIMD_ABS); - tv[0].u64 = U64x(7fffffff,ffffffff); - tv[1].u64 = U64x(7fffffff,ffffffff); - tv = LJ_KSIMD(J, LJ_KSIMD_NEG); - tv[0].u64 = U64x(80000000,00000000); - tv[1].u64 = U64x(80000000,00000000); -} - -/* Free everything associated with the JIT compiler state. */ -void lj_trace_freestate(global_State *g) -{ - jit_State *J = G2J(g); -#ifdef LUA_USE_ASSERT - { /* This assumes all traces have already been freed. */ - ptrdiff_t i; - for (i = 1; i < (ptrdiff_t)J->sizetrace; i++) - lua_assert(i == (ptrdiff_t)J->cur.traceno || traceref(J, i) == NULL); - } -#endif - lj_mcode_free(J); - lj_ir_k64_freeall(J); - lj_mem_freevec(g, J->snapmapbuf, J->sizesnapmap, SnapEntry); - lj_mem_freevec(g, J->snapbuf, J->sizesnap, SnapShot); - lj_mem_freevec(g, J->irbuf + J->irbotlim, J->irtoplim - J->irbotlim, IRIns); - lj_mem_freevec(g, J->trace, J->sizetrace, GCRef); -} - -/* -- Penalties and blacklisting ------------------------------------------ */ - -/* Blacklist a bytecode instruction. */ -static void blacklist_pc(GCproto *pt, BCIns *pc) -{ - setbc_op(pc, (int)bc_op(*pc)+(int)BC_ILOOP-(int)BC_LOOP); - pt->flags |= PROTO_ILOOP; -} - -/* Penalize a bytecode instruction. */ -static void penalty_pc(jit_State *J, GCproto *pt, BCIns *pc, TraceError e) -{ - uint32_t i, val = PENALTY_MIN; - for (i = 0; i < PENALTY_SLOTS; i++) - if (mref(J->penalty[i].pc, const BCIns) == pc) { /* Cache slot found? */ - /* First try to bump its hotcount several times. */ - val = ((uint32_t)J->penalty[i].val << 1) + - LJ_PRNG_BITS(J, PENALTY_RNDBITS); - if (val > PENALTY_MAX) { - blacklist_pc(pt, pc); /* Blacklist it, if that didn't help. */ - return; - } - goto setpenalty; - } - /* Assign a new penalty cache slot. */ - i = J->penaltyslot; - J->penaltyslot = (J->penaltyslot + 1) & (PENALTY_SLOTS-1); - setmref(J->penalty[i].pc, pc); -setpenalty: - J->penalty[i].val = (uint16_t)val; - J->penalty[i].reason = e; - hotcount_set(J2GG(J), pc+1, val); -} - -/* -- Trace compiler state machine ---------------------------------------- */ - -/* Start tracing. */ -static void trace_start(jit_State *J) -{ - lua_State *L; - TraceNo traceno; - - if ((J->pt->flags & PROTO_NOJIT)) { /* JIT disabled for this proto? */ - if (J->parent == 0) { - /* Lazy bytecode patching to disable hotcount events. */ - lua_assert(bc_op(*J->pc) == BC_FORL || bc_op(*J->pc) == BC_ITERL || - bc_op(*J->pc) == BC_LOOP || bc_op(*J->pc) == BC_FUNCF); - setbc_op(J->pc, (int)bc_op(*J->pc)+(int)BC_ILOOP-(int)BC_LOOP); - J->pt->flags |= PROTO_ILOOP; - } - J->state = LJ_TRACE_IDLE; /* Silently ignored. */ - return; - } - - /* Get a new trace number. */ - traceno = trace_findfree(J); - if (LJ_UNLIKELY(traceno == 0)) { /* No free trace? */ - lua_assert((J2G(J)->hookmask & HOOK_GC) == 0); - lj_trace_flushall(J->L); - J->state = LJ_TRACE_IDLE; /* Silently ignored. */ - return; - } - setgcrefp(J->trace[traceno], &J->cur); - - /* Setup enough of the current trace to be able to send the vmevent. */ - memset(&J->cur, 0, sizeof(GCtrace)); - J->cur.traceno = traceno; - J->cur.nins = J->cur.nk = REF_BASE; - J->cur.ir = J->irbuf; - J->cur.snap = J->snapbuf; - J->cur.snapmap = J->snapmapbuf; - J->mergesnap = 0; - J->needsnap = 0; - J->bcskip = 0; - J->guardemit.irt = 0; - J->postproc = LJ_POST_NONE; - lj_resetsplit(J); - setgcref(J->cur.startpt, obj2gco(J->pt)); - - L = J->L; - lj_vmevent_send(L, TRACE, - setstrV(L, L->top++, lj_str_newlit(L, "start")); - setintV(L->top++, traceno); - setfuncV(L, L->top++, J->fn); - setintV(L->top++, proto_bcpos(J->pt, J->pc)); - if (J->parent) { - setintV(L->top++, J->parent); - setintV(L->top++, J->exitno); - } - ); - lj_record_setup(J); -} - -/* Stop tracing. */ -static void trace_stop(jit_State *J) -{ - BCIns *pc = mref(J->cur.startpc, BCIns); - BCOp op = bc_op(J->cur.startins); - GCproto *pt = &gcref(J->cur.startpt)->pt; - TraceNo traceno = J->cur.traceno; - lua_State *L; - - switch (op) { - case BC_FORL: - setbc_op(pc+bc_j(J->cur.startins), BC_JFORI); /* Patch FORI, too. */ - /* fallthrough */ - case BC_LOOP: - case BC_ITERL: - case BC_FUNCF: - /* Patch bytecode of starting instruction in root trace. */ - setbc_op(pc, (int)op+(int)BC_JLOOP-(int)BC_LOOP); - setbc_d(pc, traceno); - addroot: - /* Add to root trace chain in prototype. */ - J->cur.nextroot = pt->trace; - pt->trace = (TraceNo1)traceno; - break; - case BC_RET: - case BC_RET0: - case BC_RET1: - *pc = BCINS_AD(BC_JLOOP, J->cur.snap[0].nslots, traceno); - goto addroot; - case BC_JMP: - /* Patch exit branch in parent to side trace entry. */ - lua_assert(J->parent != 0 && J->cur.root != 0); - lj_asm_patchexit(J, traceref(J, J->parent), J->exitno, J->cur.mcode); - /* Avoid compiling a side trace twice (stack resizing uses parent exit). */ - traceref(J, J->parent)->snap[J->exitno].count = SNAPCOUNT_DONE; - /* Add to side trace chain in root trace. */ - { - GCtrace *root = traceref(J, J->cur.root); - root->nchild++; - J->cur.nextside = root->nextside; - root->nextside = (TraceNo1)traceno; - } - break; - default: - lua_assert(0); - break; - } - - /* Commit new mcode only after all patching is done. */ - lj_mcode_commit(J, J->cur.mcode); - J->postproc = LJ_POST_NONE; - trace_save(J); - - L = J->L; - lj_vmevent_send(L, TRACE, - setstrV(L, L->top++, lj_str_newlit(L, "stop")); - setintV(L->top++, traceno); - ); -} - -/* Start a new root trace for down-recursion. */ -static int trace_downrec(jit_State *J) -{ - /* Restart recording at the return instruction. */ - lua_assert(J->pt != NULL); - lua_assert(bc_isret(bc_op(*J->pc))); - if (bc_op(*J->pc) == BC_RETM) - return 0; /* NYI: down-recursion with RETM. */ - J->parent = 0; - J->exitno = 0; - J->state = LJ_TRACE_RECORD; - trace_start(J); - return 1; -} - -/* Abort tracing. */ -static int trace_abort(jit_State *J) -{ - lua_State *L = J->L; - TraceError e = LJ_TRERR_RECERR; - TraceNo traceno; - - J->postproc = LJ_POST_NONE; - lj_mcode_abort(J); - if (tvisnumber(L->top-1)) - e = (TraceError)numberVint(L->top-1); - if (e == LJ_TRERR_MCODELM) { - L->top--; /* Remove error object */ - J->state = LJ_TRACE_ASM; - return 1; /* Retry ASM with new MCode area. */ - } - /* Penalize or blacklist starting bytecode instruction. */ - if (J->parent == 0 && !bc_isret(bc_op(J->cur.startins))) - penalty_pc(J, &gcref(J->cur.startpt)->pt, mref(J->cur.startpc, BCIns), e); - - /* Is there anything to abort? */ - traceno = J->cur.traceno; - if (traceno) { - ptrdiff_t errobj = savestack(L, L->top-1); /* Stack may be resized. */ - J->cur.link = 0; - J->cur.linktype = LJ_TRLINK_NONE; - lj_vmevent_send(L, TRACE, - TValue *frame; - const BCIns *pc; - GCfunc *fn; - setstrV(L, L->top++, lj_str_newlit(L, "abort")); - setintV(L->top++, traceno); - /* Find original Lua function call to generate a better error message. */ - frame = J->L->base-1; - pc = J->pc; - while (!isluafunc(frame_func(frame))) { - pc = (frame_iscont(frame) ? frame_contpc(frame) : frame_pc(frame)) - 1; - frame = frame_prev(frame); - } - fn = frame_func(frame); - setfuncV(L, L->top++, fn); - setintV(L->top++, proto_bcpos(funcproto(fn), pc)); - copyTV(L, L->top++, restorestack(L, errobj)); - copyTV(L, L->top++, &J->errinfo); - ); - /* Drop aborted trace after the vmevent (which may still access it). */ - setgcrefnull(J->trace[traceno]); - if (traceno < J->freetrace) - J->freetrace = traceno; - J->cur.traceno = 0; - } - L->top--; /* Remove error object */ - if (e == LJ_TRERR_DOWNREC) - return trace_downrec(J); - else if (e == LJ_TRERR_MCODEAL) - lj_trace_flushall(L); - return 0; -} - -/* Perform pending re-patch of a bytecode instruction. */ -static LJ_AINLINE void trace_pendpatch(jit_State *J, int force) -{ - if (LJ_UNLIKELY(J->patchpc)) { - if (force || J->bcskip == 0) { - *J->patchpc = J->patchins; - J->patchpc = NULL; - } else { - J->bcskip = 0; - } - } -} - -/* State machine for the trace compiler. Protected callback. */ -static TValue *trace_state(lua_State *L, lua_CFunction dummy, void *ud) -{ - jit_State *J = (jit_State *)ud; - UNUSED(dummy); - do { - retry: - switch (J->state) { - case LJ_TRACE_START: - J->state = LJ_TRACE_RECORD; /* trace_start() may change state. */ - trace_start(J); - lj_dispatch_update(J2G(J)); - break; - - case LJ_TRACE_RECORD: - trace_pendpatch(J, 0); - setvmstate(J2G(J), RECORD); - lj_vmevent_send_(L, RECORD, - /* Save/restore tmptv state for trace recorder. */ - TValue savetv = J2G(J)->tmptv; - TValue savetv2 = J2G(J)->tmptv2; - setintV(L->top++, J->cur.traceno); - setfuncV(L, L->top++, J->fn); - setintV(L->top++, J->pt ? (int32_t)proto_bcpos(J->pt, J->pc) : -1); - setintV(L->top++, J->framedepth); - , - J2G(J)->tmptv = savetv; - J2G(J)->tmptv2 = savetv2; - ); - lj_record_ins(J); - break; - - case LJ_TRACE_END: - trace_pendpatch(J, 1); - J->loopref = 0; - if ((J->flags & JIT_F_OPT_LOOP) && - J->cur.link == J->cur.traceno && J->framedepth + J->retdepth == 0) { - setvmstate(J2G(J), OPT); - lj_opt_dce(J); - if (lj_opt_loop(J)) { /* Loop optimization failed? */ - J->cur.link = 0; - J->cur.linktype = LJ_TRLINK_NONE; - J->loopref = J->cur.nins; - J->state = LJ_TRACE_RECORD; /* Try to continue recording. */ - break; - } - J->loopref = J->chain[IR_LOOP]; /* Needed by assembler. */ - } - lj_opt_split(J); - lj_opt_sink(J); - J->state = LJ_TRACE_ASM; - break; - - case LJ_TRACE_ASM: - setvmstate(J2G(J), ASM); - lj_asm_trace(J, &J->cur); - trace_stop(J); - setvmstate(J2G(J), INTERP); - J->state = LJ_TRACE_IDLE; - lj_dispatch_update(J2G(J)); - return NULL; - - default: /* Trace aborted asynchronously. */ - setintV(L->top++, (int32_t)LJ_TRERR_RECERR); - /* fallthrough */ - case LJ_TRACE_ERR: - trace_pendpatch(J, 1); - if (trace_abort(J)) - goto retry; - setvmstate(J2G(J), INTERP); - J->state = LJ_TRACE_IDLE; - lj_dispatch_update(J2G(J)); - return NULL; - } - } while (J->state > LJ_TRACE_RECORD); - return NULL; -} - -/* -- Event handling ------------------------------------------------------ */ - -/* A bytecode instruction is about to be executed. Record it. */ -void lj_trace_ins(jit_State *J, const BCIns *pc) -{ - /* Note: J->L must already be set. pc is the true bytecode PC here. */ - J->pc = pc; - J->fn = curr_func(J->L); - J->pt = isluafunc(J->fn) ? funcproto(J->fn) : NULL; - while (lj_vm_cpcall(J->L, NULL, (void *)J, trace_state) != 0) - J->state = LJ_TRACE_ERR; -} - -/* A hotcount triggered. Start recording a root trace. */ -void LJ_FASTCALL lj_trace_hot(jit_State *J, const BCIns *pc) -{ - /* Note: pc is the interpreter bytecode PC here. It's offset by 1. */ - ERRNO_SAVE - /* Reset hotcount. */ - hotcount_set(J2GG(J), pc, J->param[JIT_P_hotloop]*HOTCOUNT_LOOP); - /* Only start a new trace if not recording or inside __gc call or vmevent. */ - if (J->state == LJ_TRACE_IDLE && - !(J2G(J)->hookmask & (HOOK_GC|HOOK_VMEVENT))) { - J->parent = 0; /* Root trace. */ - J->exitno = 0; - J->state = LJ_TRACE_START; - lj_trace_ins(J, pc-1); - } - ERRNO_RESTORE -} - -/* Check for a hot side exit. If yes, start recording a side trace. */ -static void trace_hotside(jit_State *J, const BCIns *pc) -{ - SnapShot *snap = &traceref(J, J->parent)->snap[J->exitno]; - if (!(J2G(J)->hookmask & (HOOK_GC|HOOK_VMEVENT)) && - snap->count != SNAPCOUNT_DONE && - ++snap->count >= J->param[JIT_P_hotexit]) { - lua_assert(J->state == LJ_TRACE_IDLE); - /* J->parent is non-zero for a side trace. */ - J->state = LJ_TRACE_START; - lj_trace_ins(J, pc); - } -} - -/* Tiny struct to pass data to protected call. */ -typedef struct ExitDataCP { - jit_State *J; - void *exptr; /* Pointer to exit state. */ - const BCIns *pc; /* Restart interpreter at this PC. */ -} ExitDataCP; - -/* Need to protect lj_snap_restore because it may throw. */ -static TValue *trace_exit_cp(lua_State *L, lua_CFunction dummy, void *ud) -{ - ExitDataCP *exd = (ExitDataCP *)ud; - cframe_errfunc(L->cframe) = -1; /* Inherit error function. */ - exd->pc = lj_snap_restore(exd->J, exd->exptr); - UNUSED(dummy); - return NULL; -} - -#ifndef LUAJIT_DISABLE_VMEVENT -/* Push all registers from exit state. */ -static void trace_exit_regs(lua_State *L, ExitState *ex) -{ - int32_t i; - setintV(L->top++, RID_NUM_GPR); - setintV(L->top++, RID_NUM_FPR); - for (i = 0; i < RID_NUM_GPR; i++) { - if (sizeof(ex->gpr[i]) == sizeof(int32_t)) - setintV(L->top++, (int32_t)ex->gpr[i]); - else - setnumV(L->top++, (lua_Number)ex->gpr[i]); - } -#if !LJ_SOFTFP - for (i = 0; i < RID_NUM_FPR; i++) { - setnumV(L->top, ex->fpr[i]); - if (LJ_UNLIKELY(tvisnan(L->top))) - setnanV(L->top); - L->top++; - } -#endif -} -#endif - -#ifdef EXITSTATE_PCREG -/* Determine trace number from pc of exit instruction. */ -static TraceNo trace_exit_find(jit_State *J, MCode *pc) -{ - TraceNo traceno; - for (traceno = 1; traceno < J->sizetrace; traceno++) { - GCtrace *T = traceref(J, traceno); - if (T && pc >= T->mcode && pc < (MCode *)((char *)T->mcode + T->szmcode)) - return traceno; - } - lua_assert(0); - return 0; -} -#endif - -/* A trace exited. Restore interpreter state. */ -int LJ_FASTCALL lj_trace_exit(jit_State *J, void *exptr) -{ - ERRNO_SAVE - lua_State *L = J->L; - ExitState *ex = (ExitState *)exptr; - ExitDataCP exd; - int errcode; - const BCIns *pc; - void *cf; - GCtrace *T; -#ifdef EXITSTATE_PCREG - J->parent = trace_exit_find(J, (MCode *)(intptr_t)ex->gpr[EXITSTATE_PCREG]); -#endif - T = traceref(J, J->parent); UNUSED(T); -#ifdef EXITSTATE_CHECKEXIT - if (J->exitno == T->nsnap) { /* Treat stack check like a parent exit. */ - lua_assert(T->root != 0); - J->exitno = T->ir[REF_BASE].op2; - J->parent = T->ir[REF_BASE].op1; - T = traceref(J, J->parent); - } -#endif - lua_assert(T != NULL && J->exitno < T->nsnap); - exd.J = J; - exd.exptr = exptr; - errcode = lj_vm_cpcall(L, NULL, &exd, trace_exit_cp); - if (errcode) - return -errcode; /* Return negated error code. */ - - lj_vmevent_send(L, TEXIT, - lj_state_checkstack(L, 4+RID_NUM_GPR+RID_NUM_FPR+LUA_MINSTACK); - setintV(L->top++, J->parent); - setintV(L->top++, J->exitno); - trace_exit_regs(L, ex); - ); - - pc = exd.pc; - cf = cframe_raw(L->cframe); - setcframe_pc(cf, pc); - if (G(L)->gc.state == GCSatomic || G(L)->gc.state == GCSfinalize) { - if (!(G(L)->hookmask & HOOK_GC)) - lj_gc_step(L); /* Exited because of GC: drive GC forward. */ - } else { - trace_hotside(J, pc); - } - if (bc_op(*pc) == BC_JLOOP) { - BCIns *retpc = &traceref(J, bc_d(*pc))->startins; - if (bc_isret(bc_op(*retpc))) { - if (J->state == LJ_TRACE_RECORD) { - J->patchins = *pc; - J->patchpc = (BCIns *)pc; - *J->patchpc = *retpc; - J->bcskip = 1; - } else { - pc = retpc; - setcframe_pc(cf, pc); - } - } - } - /* Return MULTRES or 0. */ - ERRNO_RESTORE - switch (bc_op(*pc)) { - case BC_CALLM: case BC_CALLMT: - return (int)((BCReg)(L->top - L->base) - bc_a(*pc) - bc_c(*pc)); - case BC_RETM: - return (int)((BCReg)(L->top - L->base) + 1 - bc_a(*pc) - bc_d(*pc)); - case BC_TSETM: - return (int)((BCReg)(L->top - L->base) + 1 - bc_a(*pc)); - default: - if (bc_op(*pc) >= BC_FUNCF) - return (int)((BCReg)(L->top - L->base) + 1); - return 0; - } -} - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_trace.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_trace.h deleted file mode 100644 index f3109081b..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_trace.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -** Trace management. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_TRACE_H -#define _LJ_TRACE_H - -#include "lj_obj.h" - -#if LJ_HASJIT -#include "lj_jit.h" -#include "lj_dispatch.h" - -/* Trace errors. */ -typedef enum { -#define TREDEF(name, msg) LJ_TRERR_##name, -#include "lj_traceerr.h" - LJ_TRERR__MAX -} TraceError; - -LJ_FUNC_NORET void lj_trace_err(jit_State *J, TraceError e); -LJ_FUNC_NORET void lj_trace_err_info(jit_State *J, TraceError e); - -/* Trace management. */ -LJ_FUNC void LJ_FASTCALL lj_trace_free(global_State *g, GCtrace *T); -LJ_FUNC void lj_trace_reenableproto(GCproto *pt); -LJ_FUNC void lj_trace_flushproto(global_State *g, GCproto *pt); -LJ_FUNC void lj_trace_flush(jit_State *J, TraceNo traceno); -LJ_FUNC int lj_trace_flushall(lua_State *L); -LJ_FUNC void lj_trace_initstate(global_State *g); -LJ_FUNC void lj_trace_freestate(global_State *g); - -/* Event handling. */ -LJ_FUNC void lj_trace_ins(jit_State *J, const BCIns *pc); -LJ_FUNCA void LJ_FASTCALL lj_trace_hot(jit_State *J, const BCIns *pc); -LJ_FUNCA int LJ_FASTCALL lj_trace_exit(jit_State *J, void *exptr); - -/* Signal asynchronous abort of trace or end of trace. */ -#define lj_trace_abort(g) (G2J(g)->state &= ~LJ_TRACE_ACTIVE) -#define lj_trace_end(J) (J->state = LJ_TRACE_END) - -#else - -#define lj_trace_flushall(L) (UNUSED(L), 0) -#define lj_trace_initstate(g) UNUSED(g) -#define lj_trace_freestate(g) UNUSED(g) -#define lj_trace_abort(g) UNUSED(g) -#define lj_trace_end(J) UNUSED(J) - -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_traceerr.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_traceerr.h deleted file mode 100644 index 521560a18..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_traceerr.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -** Trace compiler error messages. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -/* This file may be included multiple times with different TREDEF macros. */ - -/* Recording. */ -TREDEF(RECERR, "error thrown or hook called during recording") -TREDEF(TRACEOV, "trace too long") -TREDEF(STACKOV, "trace too deep") -TREDEF(SNAPOV, "too many snapshots") -TREDEF(BLACKL, "blacklisted") -TREDEF(NYIBC, "NYI: bytecode %d") - -/* Recording loop ops. */ -TREDEF(LLEAVE, "leaving loop in root trace") -TREDEF(LINNER, "inner loop in root trace") -TREDEF(LUNROLL, "loop unroll limit reached") - -/* Recording calls/returns. */ -TREDEF(BADTYPE, "bad argument type") -TREDEF(CJITOFF, "JIT compilation disabled for function") -TREDEF(CUNROLL, "call unroll limit reached") -TREDEF(DOWNREC, "down-recursion, restarting") -TREDEF(NYICF, "NYI: C function %p") -TREDEF(NYIFF, "NYI: FastFunc %s") -TREDEF(NYIFFU, "NYI: unsupported variant of FastFunc %s") -TREDEF(NYIRETL, "NYI: return to lower frame") - -/* Recording indexed load/store. */ -TREDEF(STORENN, "store with nil or NaN key") -TREDEF(NOMM, "missing metamethod") -TREDEF(IDXLOOP, "looping index lookup") -TREDEF(NYITMIX, "NYI: mixed sparse/dense table") - -/* Recording C data operations. */ -TREDEF(NOCACHE, "symbol not in cache") -TREDEF(NYICONV, "NYI: unsupported C type conversion") -TREDEF(NYICALL, "NYI: unsupported C function type") - -/* Optimizations. */ -TREDEF(GFAIL, "guard would always fail") -TREDEF(PHIOV, "too many PHIs") -TREDEF(TYPEINS, "persistent type instability") - -/* Assembler. */ -TREDEF(MCODEAL, "failed to allocate mcode memory") -TREDEF(MCODEOV, "machine code too long") -TREDEF(MCODELM, "hit mcode limit (retrying)") -TREDEF(SPILLOV, "too many spill slots") -TREDEF(BADRA, "inconsistent register allocation") -TREDEF(NYIIR, "NYI: cannot assemble IR instruction %d") -TREDEF(NYIPHI, "NYI: PHI shuffling too complex") -TREDEF(NYICOAL, "NYI: register coalescing too complex") - -#undef TREDEF - -/* Detecting unused error messages: - awk -F, '/^TREDEF/ { gsub(/TREDEF./, ""); printf "grep -q LJ_TRERR_%s *.[ch] || echo %s\n", $1, $1}' lj_traceerr.h | sh -*/ diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_udata.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_udata.c deleted file mode 100644 index 6cd357ec5..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_udata.c +++ /dev/null @@ -1,34 +0,0 @@ -/* -** Userdata handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_udata_c -#define LUA_CORE - -#include "lj_obj.h" -#include "lj_gc.h" -#include "lj_udata.h" - -GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env) -{ - GCudata *ud = lj_mem_newt(L, sizeof(GCudata) + sz, GCudata); - global_State *g = G(L); - newwhite(g, ud); /* Not finalized. */ - ud->gct = ~LJ_TUDATA; - ud->udtype = UDTYPE_USERDATA; - ud->len = sz; - /* NOBARRIER: The GCudata is new (marked white). */ - setgcrefnull(ud->metatable); - setgcref(ud->env, obj2gco(env)); - /* Chain to userdata list (after main thread). */ - setgcrefr(ud->nextgc, mainthread(g)->nextgc); - setgcref(mainthread(g)->nextgc, obj2gco(ud)); - return ud; -} - -void LJ_FASTCALL lj_udata_free(global_State *g, GCudata *ud) -{ - lj_mem_free(g, ud, sizeudata(ud)); -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_udata.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_udata.h deleted file mode 100644 index e03d9a3a8..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_udata.h +++ /dev/null @@ -1,14 +0,0 @@ -/* -** Userdata handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_UDATA_H -#define _LJ_UDATA_H - -#include "lj_obj.h" - -LJ_FUNC GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env); -LJ_FUNC void LJ_FASTCALL lj_udata_free(global_State *g, GCudata *ud); - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_vm.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_vm.h deleted file mode 100644 index 4a8f03f07..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_vm.h +++ /dev/null @@ -1,116 +0,0 @@ -/* -** Assembler VM interface definitions. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_VM_H -#define _LJ_VM_H - -#include "lj_obj.h" - -/* Entry points for ASM parts of VM. */ -LJ_ASMF void lj_vm_call(lua_State *L, TValue *base, int nres1); -LJ_ASMF int lj_vm_pcall(lua_State *L, TValue *base, int nres1, ptrdiff_t ef); -typedef TValue *(*lua_CPFunction)(lua_State *L, lua_CFunction func, void *ud); -LJ_ASMF int lj_vm_cpcall(lua_State *L, lua_CFunction func, void *ud, - lua_CPFunction cp); -LJ_ASMF int lj_vm_resume(lua_State *L, TValue *base, int nres1, ptrdiff_t ef); -LJ_ASMF_NORET void LJ_FASTCALL lj_vm_unwind_c(void *cframe, int errcode); -LJ_ASMF_NORET void LJ_FASTCALL lj_vm_unwind_ff(void *cframe); -LJ_ASMF void lj_vm_unwind_c_eh(void); -LJ_ASMF void lj_vm_unwind_ff_eh(void); -#if LJ_TARGET_X86ORX64 -LJ_ASMF void lj_vm_unwind_rethrow(void); -#endif - -/* Miscellaneous functions. */ -#if LJ_TARGET_X86ORX64 -LJ_ASMF int lj_vm_cpuid(uint32_t f, uint32_t res[4]); -#endif -#if LJ_TARGET_PPC -void lj_vm_cachesync(void *start, void *end); -#endif -LJ_ASMF double lj_vm_foldarith(double x, double y, int op); -#if LJ_HASJIT -LJ_ASMF double lj_vm_foldfpm(double x, int op); -#endif -#if !LJ_ARCH_HASFPU -/* Declared in lj_obj.h: LJ_ASMF int32_t lj_vm_tobit(double x); */ -#endif - -/* Dispatch targets for recording and hooks. */ -LJ_ASMF void lj_vm_record(void); -LJ_ASMF void lj_vm_inshook(void); -LJ_ASMF void lj_vm_rethook(void); -LJ_ASMF void lj_vm_callhook(void); - -/* Trace exit handling. */ -LJ_ASMF void lj_vm_exit_handler(void); -LJ_ASMF void lj_vm_exit_interp(void); - -/* Internal math helper functions. */ -#if LJ_TARGET_X86ORX64 || LJ_TARGET_PPC -#define lj_vm_floor floor -#define lj_vm_ceil ceil -#else -LJ_ASMF double lj_vm_floor(double); -LJ_ASMF double lj_vm_ceil(double); -#if LJ_TARGET_ARM -LJ_ASMF double lj_vm_floor_sf(double); -LJ_ASMF double lj_vm_ceil_sf(double); -#endif -#endif -#if defined(LUAJIT_NO_LOG2) || LJ_TARGET_X86ORX64 -LJ_ASMF double lj_vm_log2(double); -#else -#define lj_vm_log2 log2 -#endif - -#if LJ_HASJIT -#if LJ_TARGET_X86ORX64 -LJ_ASMF void lj_vm_floor_sse(void); -LJ_ASMF void lj_vm_ceil_sse(void); -LJ_ASMF void lj_vm_trunc_sse(void); -LJ_ASMF void lj_vm_exp_x87(void); -LJ_ASMF void lj_vm_exp2_x87(void); -LJ_ASMF void lj_vm_pow_sse(void); -LJ_ASMF void lj_vm_powi_sse(void); -#else -#if LJ_TARGET_PPC -#define lj_vm_trunc trunc -#else -LJ_ASMF double lj_vm_trunc(double); -#if LJ_TARGET_ARM -LJ_ASMF double lj_vm_trunc_sf(double); -#endif -#endif -LJ_ASMF double lj_vm_powi(double, int32_t); -#ifdef LUAJIT_NO_EXP2 -LJ_ASMF double lj_vm_exp2(double); -#else -#define lj_vm_exp2 exp2 -#endif -#endif -LJ_ASMF int32_t LJ_FASTCALL lj_vm_modi(int32_t, int32_t); -#if LJ_HASFFI -LJ_ASMF int lj_vm_errno(void); -#endif -#endif - -/* Continuations for metamethods. */ -LJ_ASMF void lj_cont_cat(void); /* Continue with concatenation. */ -LJ_ASMF void lj_cont_ra(void); /* Store result in RA from instruction. */ -LJ_ASMF void lj_cont_nop(void); /* Do nothing, just continue execution. */ -LJ_ASMF void lj_cont_condt(void); /* Branch if result is true. */ -LJ_ASMF void lj_cont_condf(void); /* Branch if result is false. */ -LJ_ASMF void lj_cont_hook(void); /* Continue from hook yield. */ - -enum { LJ_CONT_TAILCALL, LJ_CONT_FFI_CALLBACK }; /* Special continuations. */ - -/* Start of the ASM code. */ -LJ_ASMF char lj_vm_asm_begin[]; - -/* Bytecode offsets are relative to lj_vm_asm_begin. */ -#define makeasmfunc(ofs) ((ASMFunction)(lj_vm_asm_begin + (ofs))) - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_vmevent.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_vmevent.c deleted file mode 100644 index e14ad5b60..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_vmevent.c +++ /dev/null @@ -1,57 +0,0 @@ -/* -** VM event handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#include - -#define lj_vmevent_c -#define LUA_CORE - -#include "lj_obj.h" -#include "lj_str.h" -#include "lj_tab.h" -#include "lj_state.h" -#include "lj_dispatch.h" -#include "lj_vm.h" -#include "lj_vmevent.h" - -ptrdiff_t lj_vmevent_prepare(lua_State *L, VMEvent ev) -{ - global_State *g = G(L); - GCstr *s = lj_str_newlit(L, LJ_VMEVENTS_REGKEY); - cTValue *tv = lj_tab_getstr(tabV(registry(L)), s); - if (tvistab(tv)) { - int hash = VMEVENT_HASH(ev); - tv = lj_tab_getint(tabV(tv), hash); - if (tv && tvisfunc(tv)) { - lj_state_checkstack(L, LUA_MINSTACK); - setfuncV(L, L->top++, funcV(tv)); - return savestack(L, L->top); - } - } - g->vmevmask &= ~VMEVENT_MASK(ev); /* No handler: cache this fact. */ - return 0; -} - -void lj_vmevent_call(lua_State *L, ptrdiff_t argbase) -{ - global_State *g = G(L); - uint8_t oldmask = g->vmevmask; - uint8_t oldh = hook_save(g); - int status; - g->vmevmask = 0; /* Disable all events. */ - hook_vmevent(g); - status = lj_vm_pcall(L, restorestack(L, argbase), 0+1, 0); - if (LJ_UNLIKELY(status)) { - /* Really shouldn't use stderr here, but where else to complain? */ - L->top--; - fputs("VM handler failed: ", stderr); - fputs(tvisstr(L->top) ? strVdata(L->top) : "?", stderr); - fputc('\n', stderr); - } - hook_restore(g, oldh); - if (g->vmevmask != VMEVENT_NOCACHE) - g->vmevmask = oldmask; /* Restore event mask, but not if not modified. */ -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_vmevent.h b/source/libs/luajit/LuaJIT-2.0.3/src/lj_vmevent.h deleted file mode 100644 index 51bae015a..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_vmevent.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -** VM event handling. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LJ_VMEVENT_H -#define _LJ_VMEVENT_H - -#include "lj_obj.h" - -/* Registry key for VM event handler table. */ -#define LJ_VMEVENTS_REGKEY "_VMEVENTS" -#define LJ_VMEVENTS_HSIZE 4 - -#define VMEVENT_MASK(ev) ((uint8_t)1 << ((int)(ev) & 7)) -#define VMEVENT_HASH(ev) ((int)(ev) & ~7) -#define VMEVENT_HASHIDX(h) ((int)(h) << 3) -#define VMEVENT_NOCACHE 255 - -#define VMEVENT_DEF(name, hash) \ - LJ_VMEVENT_##name##_, \ - LJ_VMEVENT_##name = ((LJ_VMEVENT_##name##_) & 7)|((hash) << 3) - -/* VM event IDs. */ -typedef enum { - VMEVENT_DEF(BC, 0x00003883), - VMEVENT_DEF(TRACE, 0xb2d91467), - VMEVENT_DEF(RECORD, 0x9284bf4f), - VMEVENT_DEF(TEXIT, 0xb29df2b0), - LJ_VMEVENT__MAX -} VMEvent; - -#ifdef LUAJIT_DISABLE_VMEVENT -#define lj_vmevent_send(L, ev, args) UNUSED(L) -#define lj_vmevent_send_(L, ev, args, post) UNUSED(L) -#else -#define lj_vmevent_send(L, ev, args) \ - if (G(L)->vmevmask & VMEVENT_MASK(LJ_VMEVENT_##ev)) { \ - ptrdiff_t argbase = lj_vmevent_prepare(L, LJ_VMEVENT_##ev); \ - if (argbase) { \ - args \ - lj_vmevent_call(L, argbase); \ - } \ - } -#define lj_vmevent_send_(L, ev, args, post) \ - if (G(L)->vmevmask & VMEVENT_MASK(LJ_VMEVENT_##ev)) { \ - ptrdiff_t argbase = lj_vmevent_prepare(L, LJ_VMEVENT_##ev); \ - if (argbase) { \ - args \ - lj_vmevent_call(L, argbase); \ - post \ - } \ - } - -LJ_FUNC ptrdiff_t lj_vmevent_prepare(lua_State *L, VMEvent ev); -LJ_FUNC void lj_vmevent_call(lua_State *L, ptrdiff_t argbase); -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_vmmath.c b/source/libs/luajit/LuaJIT-2.0.3/src/lj_vmmath.c deleted file mode 100644 index 63886aa7e..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lj_vmmath.c +++ /dev/null @@ -1,140 +0,0 @@ -/* -** Math helper functions for assembler VM. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#define lj_vmmath_c -#define LUA_CORE - -#include -#include - -#include "lj_obj.h" -#include "lj_ir.h" -#include "lj_vm.h" - -/* -- Helper functions for generated machine code ------------------------- */ - -#if LJ_TARGET_X86ORX64 -/* Wrapper functions to avoid linker issues on OSX. */ -LJ_FUNCA double lj_vm_sinh(double x) { return sinh(x); } -LJ_FUNCA double lj_vm_cosh(double x) { return cosh(x); } -LJ_FUNCA double lj_vm_tanh(double x) { return tanh(x); } -#endif - -#if !LJ_TARGET_X86ORX64 -double lj_vm_foldarith(double x, double y, int op) -{ - switch (op) { - case IR_ADD - IR_ADD: return x+y; break; - case IR_SUB - IR_ADD: return x-y; break; - case IR_MUL - IR_ADD: return x*y; break; - case IR_DIV - IR_ADD: return x/y; break; - case IR_MOD - IR_ADD: return x-lj_vm_floor(x/y)*y; break; - case IR_POW - IR_ADD: return pow(x, y); break; - case IR_NEG - IR_ADD: return -x; break; - case IR_ABS - IR_ADD: return fabs(x); break; -#if LJ_HASJIT - case IR_ATAN2 - IR_ADD: return atan2(x, y); break; - case IR_LDEXP - IR_ADD: return ldexp(x, (int)y); break; - case IR_MIN - IR_ADD: return x > y ? y : x; break; - case IR_MAX - IR_ADD: return x < y ? y : x; break; -#endif - default: return x; - } -} -#endif - -#if LJ_HASJIT - -#ifdef LUAJIT_NO_LOG2 -double lj_vm_log2(double a) -{ - return log(a) * 1.4426950408889634074; -} -#endif - -#ifdef LUAJIT_NO_EXP2 -double lj_vm_exp2(double a) -{ - return exp(a * 0.6931471805599453); -} -#endif - -#if !(LJ_TARGET_ARM || LJ_TARGET_PPC) -int32_t LJ_FASTCALL lj_vm_modi(int32_t a, int32_t b) -{ - uint32_t y, ua, ub; - lua_assert(b != 0); /* This must be checked before using this function. */ - ua = a < 0 ? (uint32_t)-a : (uint32_t)a; - ub = b < 0 ? (uint32_t)-b : (uint32_t)b; - y = ua % ub; - if (y != 0 && (a^b) < 0) y = y - ub; - if (((int32_t)y^b) < 0) y = (uint32_t)-(int32_t)y; - return (int32_t)y; -} -#endif - -#if !LJ_TARGET_X86ORX64 -/* Unsigned x^k. */ -static double lj_vm_powui(double x, uint32_t k) -{ - double y; - lua_assert(k != 0); - for (; (k & 1) == 0; k >>= 1) x *= x; - y = x; - if ((k >>= 1) != 0) { - for (;;) { - x *= x; - if (k == 1) break; - if (k & 1) y *= x; - k >>= 1; - } - y *= x; - } - return y; -} - -/* Signed x^k. */ -double lj_vm_powi(double x, int32_t k) -{ - if (k > 1) - return lj_vm_powui(x, (uint32_t)k); - else if (k == 1) - return x; - else if (k == 0) - return 1.0; - else - return 1.0 / lj_vm_powui(x, (uint32_t)-k); -} - -/* Computes fpm(x) for extended math functions. */ -double lj_vm_foldfpm(double x, int fpm) -{ - switch (fpm) { - case IRFPM_FLOOR: return lj_vm_floor(x); - case IRFPM_CEIL: return lj_vm_ceil(x); - case IRFPM_TRUNC: return lj_vm_trunc(x); - case IRFPM_SQRT: return sqrt(x); - case IRFPM_EXP: return exp(x); - case IRFPM_EXP2: return lj_vm_exp2(x); - case IRFPM_LOG: return log(x); - case IRFPM_LOG2: return lj_vm_log2(x); - case IRFPM_LOG10: return log10(x); - case IRFPM_SIN: return sin(x); - case IRFPM_COS: return cos(x); - case IRFPM_TAN: return tan(x); - default: lua_assert(0); - } - return 0; -} -#endif - -#if LJ_HASFFI -int lj_vm_errno(void) -{ - return errno; -} -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/ljamalg.c b/source/libs/luajit/LuaJIT-2.0.3/src/ljamalg.c deleted file mode 100644 index 52a86153c..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/ljamalg.c +++ /dev/null @@ -1,93 +0,0 @@ -/* -** LuaJIT core and libraries amalgamation. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -/* -+--------------------------------------------------------------------------+ -| WARNING: Compiling the amalgamation needs a lot of virtual memory | -| (around 300 MB with GCC 4.x)! If you don't have enough physical memory | -| your machine will start swapping to disk and the compile will not finish | -| within a reasonable amount of time. | -| So either compile on a bigger machine or use the non-amalgamated build. | -+--------------------------------------------------------------------------+ -*/ - -#define ljamalg_c -#define LUA_CORE - -/* To get the mremap prototype. Must be defined before any system includes. */ -#if defined(__linux__) && !defined(_GNU_SOURCE) -#define _GNU_SOURCE -#endif - -#ifndef WINVER -#define WINVER 0x0501 -#endif - -#include "lua.h" -#include "lauxlib.h" - -#include "lj_gc.c" -#include "lj_err.c" -#include "lj_char.c" -#include "lj_bc.c" -#include "lj_obj.c" -#include "lj_str.c" -#include "lj_tab.c" -#include "lj_func.c" -#include "lj_udata.c" -#include "lj_meta.c" -#include "lj_debug.c" -#include "lj_state.c" -#include "lj_dispatch.c" -#include "lj_vmevent.c" -#include "lj_vmmath.c" -#include "lj_strscan.c" -#include "lj_api.c" -#include "lj_lex.c" -#include "lj_parse.c" -#include "lj_bcread.c" -#include "lj_bcwrite.c" -#include "lj_load.c" -#include "lj_ctype.c" -#include "lj_cdata.c" -#include "lj_cconv.c" -#include "lj_ccall.c" -#include "lj_ccallback.c" -#include "lj_carith.c" -#include "lj_clib.c" -#include "lj_cparse.c" -#include "lj_lib.c" -#include "lj_ir.c" -#include "lj_opt_mem.c" -#include "lj_opt_fold.c" -#include "lj_opt_narrow.c" -#include "lj_opt_dce.c" -#include "lj_opt_loop.c" -#include "lj_opt_split.c" -#include "lj_opt_sink.c" -#include "lj_mcode.c" -#include "lj_snap.c" -#include "lj_record.c" -#include "lj_crecord.c" -#include "lj_ffrecord.c" -#include "lj_asm.c" -#include "lj_trace.c" -#include "lj_gdbjit.c" -#include "lj_alloc.c" - -#include "lib_aux.c" -#include "lib_base.c" -#include "lib_math.c" -#include "lib_string.c" -#include "lib_table.c" -#include "lib_io.c" -#include "lib_os.c" -#include "lib_package.c" -#include "lib_debug.c" -#include "lib_bit.c" -#include "lib_jit.c" -#include "lib_ffi.c" -#include "lib_init.c" - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/luaconf.h b/source/libs/luajit/LuaJIT-2.0.3/src/luaconf.h deleted file mode 100644 index affb7da8f..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/luaconf.h +++ /dev/null @@ -1,156 +0,0 @@ -/* -** Configuration header. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef luaconf_h -#define luaconf_h - -#ifndef WINVER -#define WINVER 0x0501 -#endif -#include -#include - -/* Default path for loading Lua and C modules with require(). */ -#if defined(_WIN32) -/* -** In Windows, any exclamation mark ('!') in the path is replaced by the -** path of the directory of the executable file of the current process. -*/ -#define LUA_LDIR "!\\lua\\" -#define LUA_CDIR "!\\" -#define LUA_PATH_DEFAULT \ - ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" -#define LUA_CPATH_DEFAULT \ - ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" -#else -/* -** Note to distribution maintainers: do NOT patch the following lines! -** Please read ../doc/install.html#distro and pass PREFIX=/usr instead. -*/ -#ifndef LUA_MULTILIB -#define LUA_MULTILIB "lib" -#endif -#ifndef LUA_LMULTILIB -#define LUA_LMULTILIB "lib" -#endif -#define LUA_LROOT "/usr/local" -#define LUA_LUADIR "/lua/5.1/" -#define LUA_LJDIR "/luajit-2.0.3/" - -#ifdef LUA_ROOT -#define LUA_JROOT LUA_ROOT -#define LUA_RLDIR LUA_ROOT "/share" LUA_LUADIR -#define LUA_RCDIR LUA_ROOT "/" LUA_MULTILIB LUA_LUADIR -#define LUA_RLPATH ";" LUA_RLDIR "?.lua;" LUA_RLDIR "?/init.lua" -#define LUA_RCPATH ";" LUA_RCDIR "?.so" -#else -#define LUA_JROOT LUA_LROOT -#define LUA_RLPATH -#define LUA_RCPATH -#endif - -#define LUA_JPATH ";" LUA_JROOT "/share" LUA_LJDIR "?.lua" -#define LUA_LLDIR LUA_LROOT "/share" LUA_LUADIR -#define LUA_LCDIR LUA_LROOT "/" LUA_LMULTILIB LUA_LUADIR -#define LUA_LLPATH ";" LUA_LLDIR "?.lua;" LUA_LLDIR "?/init.lua" -#define LUA_LCPATH1 ";" LUA_LCDIR "?.so" -#define LUA_LCPATH2 ";" LUA_LCDIR "loadall.so" - -#define LUA_PATH_DEFAULT "./?.lua" LUA_JPATH LUA_LLPATH LUA_RLPATH -#define LUA_CPATH_DEFAULT "./?.so" LUA_LCPATH1 LUA_RCPATH LUA_LCPATH2 -#endif - -/* Environment variable names for path overrides and initialization code. */ -#define LUA_PATH "LUA_PATH" -#define LUA_CPATH "LUA_CPATH" -#define LUA_INIT "LUA_INIT" - -/* Special file system characters. */ -#if defined(_WIN32) -#define LUA_DIRSEP "\\" -#else -#define LUA_DIRSEP "/" -#endif -#define LUA_PATHSEP ";" -#define LUA_PATH_MARK "?" -#define LUA_EXECDIR "!" -#define LUA_IGMARK "-" -#define LUA_PATH_CONFIG \ - LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" \ - LUA_EXECDIR "\n" LUA_IGMARK - -/* Quoting in error messages. */ -#define LUA_QL(x) "'" x "'" -#define LUA_QS LUA_QL("%s") - -/* Various tunables. */ -#define LUAI_MAXSTACK 65500 /* Max. # of stack slots for a thread (<64K). */ -#define LUAI_MAXCSTACK 8000 /* Max. # of stack slots for a C func (<10K). */ -#define LUAI_GCPAUSE 200 /* Pause GC until memory is at 200%. */ -#define LUAI_GCMUL 200 /* Run GC at 200% of allocation speed. */ -#define LUA_MAXCAPTURES 32 /* Max. pattern captures. */ - -/* Compatibility with older library function names. */ -#define LUA_COMPAT_MOD /* OLD: math.mod, NEW: math.fmod */ -#define LUA_COMPAT_GFIND /* OLD: string.gfind, NEW: string.gmatch */ - -/* Configuration for the frontend (the luajit executable). */ -#if defined(luajit_c) -#define LUA_PROGNAME "luajit" /* Fallback frontend name. */ -#define LUA_PROMPT "> " /* Interactive prompt. */ -#define LUA_PROMPT2 ">> " /* Continuation prompt. */ -#define LUA_MAXINPUT 512 /* Max. input line length. */ -#endif - -/* Note: changing the following defines breaks the Lua 5.1 ABI. */ -#define LUA_INTEGER ptrdiff_t -#define LUA_IDSIZE 60 /* Size of lua_Debug.short_src. */ -/* -** Size of lauxlib and io.* on-stack buffers. Weird workaround to avoid using -** unreasonable amounts of stack space, but still retain ABI compatibility. -** Blame Lua for depending on BUFSIZ in the ABI, blame **** for wrecking it. -*/ -#define LUAL_BUFFERSIZE (BUFSIZ > 16384 ? 8192 : BUFSIZ) - -/* The following defines are here only for compatibility with luaconf.h -** from the standard Lua distribution. They must not be changed for LuaJIT. -*/ -#define LUA_NUMBER_DOUBLE -#define LUA_NUMBER double -#define LUAI_UACNUMBER double -#define LUA_NUMBER_SCAN "%lf" -#define LUA_NUMBER_FMT "%.14g" -#define lua_number2str(s, n) sprintf((s), LUA_NUMBER_FMT, (n)) -#define LUAI_MAXNUMBER2STR 32 -#define LUA_INTFRMLEN "l" -#define LUA_INTFRM_T long - -/* Linkage of public API functions. */ -#if defined(LUA_BUILD_AS_DLL) -#if defined(LUA_CORE) || defined(LUA_LIB) -#define LUA_API __declspec(dllexport) -#else -#define LUA_API __declspec(dllimport) -#endif -#else -#define LUA_API extern -#endif - -#define LUALIB_API LUA_API - -/* Support for internal assertions. */ -#if defined(LUA_USE_ASSERT) || defined(LUA_USE_APICHECK) -#include -#endif -#ifdef LUA_USE_ASSERT -#define lua_assert(x) assert(x) -#endif -#ifdef LUA_USE_APICHECK -#define luai_apicheck(L, o) { (void)L; assert(o); } -#else -#define luai_apicheck(L, o) { (void)L; } -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/luajit.c b/source/libs/luajit/LuaJIT-2.0.3/src/luajit.c deleted file mode 100644 index 4cccf04e6..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/luajit.c +++ /dev/null @@ -1,571 +0,0 @@ -/* -** LuaJIT frontend. Runs commands, scripts, read-eval-print (REPL) etc. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -** -** Major portions taken verbatim or adapted from the Lua interpreter. -** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h -*/ - -#include -#include -#include - -#define luajit_c - -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" -#include "luajit.h" - -#include "lj_arch.h" - -#if LJ_TARGET_POSIX -#include -#define lua_stdin_is_tty() isatty(0) -#elif LJ_TARGET_WINDOWS -#include -#ifdef __BORLANDC__ -#define lua_stdin_is_tty() isatty(_fileno(stdin)) -#else -#define lua_stdin_is_tty() _isatty(_fileno(stdin)) -#endif -#else -#define lua_stdin_is_tty() 1 -#endif - -#if !LJ_TARGET_CONSOLE -#include -#endif - -static lua_State *globalL = NULL; -static const char *progname = LUA_PROGNAME; - -#if !LJ_TARGET_CONSOLE -static void lstop(lua_State *L, lua_Debug *ar) -{ - (void)ar; /* unused arg. */ - lua_sethook(L, NULL, 0, 0); - /* Avoid luaL_error -- a C hook doesn't add an extra frame. */ - luaL_where(L, 0); - lua_pushfstring(L, "%sinterrupted!", lua_tostring(L, -1)); - lua_error(L); -} - -static void laction(int i) -{ - signal(i, SIG_DFL); /* if another SIGINT happens before lstop, - terminate process (default action) */ - lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1); -} -#endif - -static void print_usage(void) -{ - fprintf(stderr, - "usage: %s [options]... [script [args]...].\n" - "Available options are:\n" - " -e chunk Execute string " LUA_QL("chunk") ".\n" - " -l name Require library " LUA_QL("name") ".\n" - " -b ... Save or list bytecode.\n" - " -j cmd Perform LuaJIT control command.\n" - " -O[opt] Control LuaJIT optimizations.\n" - " -i Enter interactive mode after executing " LUA_QL("script") ".\n" - " -v Show version information.\n" - " -E Ignore environment variables.\n" - " -- Stop handling options.\n" - " - Execute stdin and stop handling options.\n" - , - progname); - fflush(stderr); -} - -static void l_message(const char *pname, const char *msg) -{ - if (pname) fprintf(stderr, "%s: ", pname); - fprintf(stderr, "%s\n", msg); - fflush(stderr); -} - -static int report(lua_State *L, int status) -{ - if (status && !lua_isnil(L, -1)) { - const char *msg = lua_tostring(L, -1); - if (msg == NULL) msg = "(error object is not a string)"; - l_message(progname, msg); - lua_pop(L, 1); - } - return status; -} - -static int traceback(lua_State *L) -{ - if (!lua_isstring(L, 1)) { /* Non-string error object? Try metamethod. */ - if (lua_isnoneornil(L, 1) || - !luaL_callmeta(L, 1, "__tostring") || - !lua_isstring(L, -1)) - return 1; /* Return non-string error object. */ - lua_remove(L, 1); /* Replace object by result of __tostring metamethod. */ - } - luaL_traceback(L, L, lua_tostring(L, 1), 1); - return 1; -} - -static int docall(lua_State *L, int narg, int clear) -{ - int status; - int base = lua_gettop(L) - narg; /* function index */ - lua_pushcfunction(L, traceback); /* push traceback function */ - lua_insert(L, base); /* put it under chunk and args */ -#if !LJ_TARGET_CONSOLE - signal(SIGINT, laction); -#endif - status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base); -#if !LJ_TARGET_CONSOLE - signal(SIGINT, SIG_DFL); -#endif - lua_remove(L, base); /* remove traceback function */ - /* force a complete garbage collection in case of errors */ - if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0); - return status; -} - -static void print_version(void) -{ - fputs(LUAJIT_VERSION " -- " LUAJIT_COPYRIGHT ". " LUAJIT_URL "\n", stdout); -} - -static void print_jit_status(lua_State *L) -{ - int n; - const char *s; - lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); - lua_getfield(L, -1, "jit"); /* Get jit.* module table. */ - lua_remove(L, -2); - lua_getfield(L, -1, "status"); - lua_remove(L, -2); - n = lua_gettop(L); - lua_call(L, 0, LUA_MULTRET); - fputs(lua_toboolean(L, n) ? "JIT: ON" : "JIT: OFF", stdout); - for (n++; (s = lua_tostring(L, n)); n++) { - putc(' ', stdout); - fputs(s, stdout); - } - putc('\n', stdout); -} - -static int getargs(lua_State *L, char **argv, int n) -{ - int narg; - int i; - int argc = 0; - while (argv[argc]) argc++; /* count total number of arguments */ - narg = argc - (n + 1); /* number of arguments to the script */ - luaL_checkstack(L, narg + 3, "too many arguments to script"); - for (i = n+1; i < argc; i++) - lua_pushstring(L, argv[i]); - lua_createtable(L, narg, n + 1); - for (i = 0; i < argc; i++) { - lua_pushstring(L, argv[i]); - lua_rawseti(L, -2, i - n); - } - return narg; -} - -static int dofile(lua_State *L, const char *name) -{ - int status = luaL_loadfile(L, name) || docall(L, 0, 1); - return report(L, status); -} - -static int dostring(lua_State *L, const char *s, const char *name) -{ - int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1); - return report(L, status); -} - -static int dolibrary(lua_State *L, const char *name) -{ - lua_getglobal(L, "require"); - lua_pushstring(L, name); - return report(L, docall(L, 1, 1)); -} - -static void write_prompt(lua_State *L, int firstline) -{ - const char *p; - lua_getfield(L, LUA_GLOBALSINDEX, firstline ? "_PROMPT" : "_PROMPT2"); - p = lua_tostring(L, -1); - if (p == NULL) p = firstline ? LUA_PROMPT : LUA_PROMPT2; - fputs(p, stdout); - fflush(stdout); - lua_pop(L, 1); /* remove global */ -} - -static int incomplete(lua_State *L, int status) -{ - if (status == LUA_ERRSYNTAX) { - size_t lmsg; - const char *msg = lua_tolstring(L, -1, &lmsg); - const char *tp = msg + lmsg - (sizeof(LUA_QL("")) - 1); - if (strstr(msg, LUA_QL("")) == tp) { - lua_pop(L, 1); - return 1; - } - } - return 0; /* else... */ -} - -static int pushline(lua_State *L, int firstline) -{ - char buf[LUA_MAXINPUT]; - write_prompt(L, firstline); - if (fgets(buf, LUA_MAXINPUT, stdin)) { - size_t len = strlen(buf); - if (len > 0 && buf[len-1] == '\n') - buf[len-1] = '\0'; - if (firstline && buf[0] == '=') - lua_pushfstring(L, "return %s", buf+1); - else - lua_pushstring(L, buf); - return 1; - } - return 0; -} - -static int loadline(lua_State *L) -{ - int status; - lua_settop(L, 0); - if (!pushline(L, 1)) - return -1; /* no input */ - for (;;) { /* repeat until gets a complete line */ - status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin"); - if (!incomplete(L, status)) break; /* cannot try to add lines? */ - if (!pushline(L, 0)) /* no more input? */ - return -1; - lua_pushliteral(L, "\n"); /* add a new line... */ - lua_insert(L, -2); /* ...between the two lines */ - lua_concat(L, 3); /* join them */ - } - lua_remove(L, 1); /* remove line */ - return status; -} - -static void dotty(lua_State *L) -{ - int status; - const char *oldprogname = progname; - progname = NULL; - while ((status = loadline(L)) != -1) { - if (status == 0) status = docall(L, 0, 0); - report(L, status); - if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */ - lua_getglobal(L, "print"); - lua_insert(L, 1); - if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0) - l_message(progname, - lua_pushfstring(L, "error calling " LUA_QL("print") " (%s)", - lua_tostring(L, -1))); - } - } - lua_settop(L, 0); /* clear stack */ - fputs("\n", stdout); - fflush(stdout); - progname = oldprogname; -} - -static int handle_script(lua_State *L, char **argv, int n) -{ - int status; - const char *fname; - int narg = getargs(L, argv, n); /* collect arguments */ - lua_setglobal(L, "arg"); - fname = argv[n]; - if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0) - fname = NULL; /* stdin */ - status = luaL_loadfile(L, fname); - lua_insert(L, -(narg+1)); - if (status == 0) - status = docall(L, narg, 0); - else - lua_pop(L, narg); - return report(L, status); -} - -/* Load add-on module. */ -static int loadjitmodule(lua_State *L) -{ - lua_getglobal(L, "require"); - lua_pushliteral(L, "jit."); - lua_pushvalue(L, -3); - lua_concat(L, 2); - if (lua_pcall(L, 1, 1, 0)) { - const char *msg = lua_tostring(L, -1); - if (msg && !strncmp(msg, "module ", 7)) { - err: - l_message(progname, - "unknown luaJIT command or jit.* modules not installed"); - return 1; - } else { - return report(L, 1); - } - } - lua_getfield(L, -1, "start"); - if (lua_isnil(L, -1)) goto err; - lua_remove(L, -2); /* Drop module table. */ - return 0; -} - -/* Run command with options. */ -static int runcmdopt(lua_State *L, const char *opt) -{ - int narg = 0; - if (opt && *opt) { - for (;;) { /* Split arguments. */ - const char *p = strchr(opt, ','); - narg++; - if (!p) break; - if (p == opt) - lua_pushnil(L); - else - lua_pushlstring(L, opt, (size_t)(p - opt)); - opt = p + 1; - } - if (*opt) - lua_pushstring(L, opt); - else - lua_pushnil(L); - } - return report(L, lua_pcall(L, narg, 0, 0)); -} - -/* JIT engine control command: try jit library first or load add-on module. */ -static int dojitcmd(lua_State *L, const char *cmd) -{ - const char *opt = strchr(cmd, '='); - lua_pushlstring(L, cmd, opt ? (size_t)(opt - cmd) : strlen(cmd)); - lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); - lua_getfield(L, -1, "jit"); /* Get jit.* module table. */ - lua_remove(L, -2); - lua_pushvalue(L, -2); - lua_gettable(L, -2); /* Lookup library function. */ - if (!lua_isfunction(L, -1)) { - lua_pop(L, 2); /* Drop non-function and jit.* table, keep module name. */ - if (loadjitmodule(L)) - return 1; - } else { - lua_remove(L, -2); /* Drop jit.* table. */ - } - lua_remove(L, -2); /* Drop module name. */ - return runcmdopt(L, opt ? opt+1 : opt); -} - -/* Optimization flags. */ -static int dojitopt(lua_State *L, const char *opt) -{ - lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); - lua_getfield(L, -1, "jit.opt"); /* Get jit.opt.* module table. */ - lua_remove(L, -2); - lua_getfield(L, -1, "start"); - lua_remove(L, -2); - return runcmdopt(L, opt); -} - -/* Save or list bytecode. */ -static int dobytecode(lua_State *L, char **argv) -{ - int narg = 0; - lua_pushliteral(L, "bcsave"); - if (loadjitmodule(L)) - return 1; - if (argv[0][2]) { - narg++; - argv[0][1] = '-'; - lua_pushstring(L, argv[0]+1); - } - for (argv++; *argv != NULL; narg++, argv++) - lua_pushstring(L, *argv); - return report(L, lua_pcall(L, narg, 0, 0)); -} - -/* check that argument has no extra characters at the end */ -#define notail(x) {if ((x)[2] != '\0') return -1;} - -#define FLAGS_INTERACTIVE 1 -#define FLAGS_VERSION 2 -#define FLAGS_EXEC 4 -#define FLAGS_OPTION 8 -#define FLAGS_NOENV 16 - -static int collectargs(char **argv, int *flags) -{ - int i; - for (i = 1; argv[i] != NULL; i++) { - if (argv[i][0] != '-') /* Not an option? */ - return i; - switch (argv[i][1]) { /* Check option. */ - case '-': - notail(argv[i]); - return (argv[i+1] != NULL ? i+1 : 0); - case '\0': - return i; - case 'i': - notail(argv[i]); - *flags |= FLAGS_INTERACTIVE; - /* fallthrough */ - case 'v': - notail(argv[i]); - *flags |= FLAGS_VERSION; - break; - case 'e': - *flags |= FLAGS_EXEC; - case 'j': /* LuaJIT extension */ - case 'l': - *flags |= FLAGS_OPTION; - if (argv[i][2] == '\0') { - i++; - if (argv[i] == NULL) return -1; - } - break; - case 'O': break; /* LuaJIT extension */ - case 'b': /* LuaJIT extension */ - if (*flags) return -1; - *flags |= FLAGS_EXEC; - return 0; - case 'E': - *flags |= FLAGS_NOENV; - break; - default: return -1; /* invalid option */ - } - } - return 0; -} - -static int runargs(lua_State *L, char **argv, int n) -{ - int i; - for (i = 1; i < n; i++) { - if (argv[i] == NULL) continue; - lua_assert(argv[i][0] == '-'); - switch (argv[i][1]) { /* option */ - case 'e': { - const char *chunk = argv[i] + 2; - if (*chunk == '\0') chunk = argv[++i]; - lua_assert(chunk != NULL); - if (dostring(L, chunk, "=(command line)") != 0) - return 1; - break; - } - case 'l': { - const char *filename = argv[i] + 2; - if (*filename == '\0') filename = argv[++i]; - lua_assert(filename != NULL); - if (dolibrary(L, filename)) - return 1; /* stop if file fails */ - break; - } - case 'j': { /* LuaJIT extension */ - const char *cmd = argv[i] + 2; - if (*cmd == '\0') cmd = argv[++i]; - lua_assert(cmd != NULL); - if (dojitcmd(L, cmd)) - return 1; - break; - } - case 'O': /* LuaJIT extension */ - if (dojitopt(L, argv[i] + 2)) - return 1; - break; - case 'b': /* LuaJIT extension */ - return dobytecode(L, argv+i); - default: break; - } - } - return 0; -} - -static int handle_luainit(lua_State *L) -{ -#if LJ_TARGET_CONSOLE - const char *init = NULL; -#else - const char *init = getenv(LUA_INIT); -#endif - if (init == NULL) - return 0; /* status OK */ - else if (init[0] == '@') - return dofile(L, init+1); - else - return dostring(L, init, "=" LUA_INIT); -} - -static struct Smain { - char **argv; - int argc; - int status; -} smain; - -static int pmain(lua_State *L) -{ - struct Smain *s = &smain; - char **argv = s->argv; - int script; - int flags = 0; - globalL = L; - if (argv[0] && argv[0][0]) progname = argv[0]; - LUAJIT_VERSION_SYM(); /* linker-enforced version check */ - script = collectargs(argv, &flags); - if (script < 0) { /* invalid args? */ - print_usage(); - s->status = 1; - return 0; - } - if ((flags & FLAGS_NOENV)) { - lua_pushboolean(L, 1); - lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV"); - } - lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ - luaL_openlibs(L); /* open libraries */ - lua_gc(L, LUA_GCRESTART, -1); - if (!(flags & FLAGS_NOENV)) { - s->status = handle_luainit(L); - if (s->status != 0) return 0; - } - if ((flags & FLAGS_VERSION)) print_version(); - s->status = runargs(L, argv, (script > 0) ? script : s->argc); - if (s->status != 0) return 0; - if (script) { - s->status = handle_script(L, argv, script); - if (s->status != 0) return 0; - } - if ((flags & FLAGS_INTERACTIVE)) { - print_jit_status(L); - dotty(L); - } else if (script == 0 && !(flags & (FLAGS_EXEC|FLAGS_VERSION))) { - if (lua_stdin_is_tty()) { - print_version(); - print_jit_status(L); - dotty(L); - } else { - dofile(L, NULL); /* executes stdin as a file */ - } - } - return 0; -} - -int main(int argc, char **argv) -{ - int status; - lua_State *L = lua_open(); /* create state */ - if (L == NULL) { - l_message(argv[0], "cannot create state: not enough memory"); - return EXIT_FAILURE; - } - smain.argc = argc; - smain.argv = argv; - status = lua_cpcall(L, pmain, NULL); - report(L, status); - lua_close(L); - return (status || smain.status) ? EXIT_FAILURE : EXIT_SUCCESS; -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/luajit.h b/source/libs/luajit/LuaJIT-2.0.3/src/luajit.h deleted file mode 100644 index be721cf4b..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/luajit.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -** LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/ -** -** Copyright (C) 2005-2014 Mike Pall. All rights reserved. -** -** Permission is hereby granted, free of charge, to any person obtaining -** a copy of this software and associated documentation files (the -** "Software"), to deal in the Software without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Software, and to -** permit persons to whom the Software is furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be -** included in all copies or substantial portions of the Software. -** -** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -** -** [ MIT license: http://www.opensource.org/licenses/mit-license.php ] -*/ - -#ifndef _LUAJIT_H -#define _LUAJIT_H - -#include "lua.h" - -#define LUAJIT_VERSION "LuaJIT 2.0.3" -#define LUAJIT_VERSION_NUM 20003 /* Version 2.0.3 = 02.00.03. */ -#define LUAJIT_VERSION_SYM luaJIT_version_2_0_3 -#define LUAJIT_COPYRIGHT "Copyright (C) 2005-2014 Mike Pall" -#define LUAJIT_URL "http://luajit.org/" - -/* Modes for luaJIT_setmode. */ -#define LUAJIT_MODE_MASK 0x00ff - -enum { - LUAJIT_MODE_ENGINE, /* Set mode for whole JIT engine. */ - LUAJIT_MODE_DEBUG, /* Set debug mode (idx = level). */ - - LUAJIT_MODE_FUNC, /* Change mode for a function. */ - LUAJIT_MODE_ALLFUNC, /* Recurse into subroutine protos. */ - LUAJIT_MODE_ALLSUBFUNC, /* Change only the subroutines. */ - - LUAJIT_MODE_TRACE, /* Flush a compiled trace. */ - - LUAJIT_MODE_WRAPCFUNC = 0x10, /* Set wrapper mode for C function calls. */ - - LUAJIT_MODE_MAX -}; - -/* Flags or'ed in to the mode. */ -#define LUAJIT_MODE_OFF 0x0000 /* Turn feature off. */ -#define LUAJIT_MODE_ON 0x0100 /* Turn feature on. */ -#define LUAJIT_MODE_FLUSH 0x0200 /* Flush JIT-compiled code. */ - -/* LuaJIT public C API. */ - -/* Control the JIT engine. */ -LUA_API int luaJIT_setmode(lua_State *L, int idx, int mode); - -/* Enforce (dynamic) linker error for version mismatches. Call from main. */ -LUA_API void LUAJIT_VERSION_SYM(void); - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lualib.h b/source/libs/luajit/LuaJIT-2.0.3/src/lualib.h deleted file mode 100644 index 90687bdd1..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/lualib.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -** Standard library header. -** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LUALIB_H -#define _LUALIB_H - -#include "lua.h" - -#define LUA_FILEHANDLE "FILE*" - -#define LUA_COLIBNAME "coroutine" -#define LUA_MATHLIBNAME "math" -#define LUA_STRLIBNAME "string" -#define LUA_TABLIBNAME "table" -#define LUA_IOLIBNAME "io" -#define LUA_OSLIBNAME "os" -#define LUA_LOADLIBNAME "package" -#define LUA_DBLIBNAME "debug" -#define LUA_BITLIBNAME "bit" -#define LUA_JITLIBNAME "jit" -#define LUA_FFILIBNAME "ffi" - -#define LUA_BITLIBNAME_32 "bit32" - -LUALIB_API int luaopen_base(lua_State *L); -LUALIB_API int luaopen_math(lua_State *L); -LUALIB_API int luaopen_string(lua_State *L); -LUALIB_API int luaopen_table(lua_State *L); -LUALIB_API int luaopen_io(lua_State *L); -LUALIB_API int luaopen_os(lua_State *L); -LUALIB_API int luaopen_package(lua_State *L); -LUALIB_API int luaopen_debug(lua_State *L); -LUALIB_API int luaopen_bit(lua_State *L); -LUALIB_API int luaopen_jit(lua_State *L); -LUALIB_API int luaopen_ffi(lua_State *L); - -LUALIB_API int luaopen_bit32(lua_State *L); - -LUALIB_API void luaL_openlibs(lua_State *L); - -#ifndef lua_assert -#define lua_assert(x) ((void)0) -#endif - -#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/msvcbuild.bat b/source/libs/luajit/LuaJIT-2.0.3/src/msvcbuild.bat deleted file mode 100644 index 9160e0f88..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/msvcbuild.bat +++ /dev/null @@ -1,113 +0,0 @@ -@rem Script to build LuaJIT with MSVC. -@rem Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -@rem -@rem Either open a "Visual Studio .NET Command Prompt" -@rem (Note that the Express Edition does not contain an x64 compiler) -@rem -or- -@rem Open a "Windows SDK Command Shell" and set the compiler environment: -@rem setenv /release /x86 -@rem -or- -@rem setenv /release /x64 -@rem -@rem Then cd to this directory and run this script. - -@if not defined INCLUDE goto :FAIL - -@setlocal -@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE -@set LJLINK=link /nologo -@set LJMT=mt /nologo -@set LJLIB=lib /nologo /nodefaultlib -@set DASMDIR=..\dynasm -@set DASM=%DASMDIR%\dynasm.lua -@set LJDLLNAME=lua51.dll -@set LJLIBNAME=lua51.lib -@set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c - -%LJCOMPILE% host\minilua.c -@if errorlevel 1 goto :BAD -%LJLINK% /out:minilua.exe minilua.obj -@if errorlevel 1 goto :BAD -if exist minilua.exe.manifest^ - %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe - -@set DASMFLAGS=-D WIN -D JIT -D FFI -D P64 -@set LJARCH=x64 -@minilua -@if errorlevel 8 goto :X64 -@set DASMFLAGS=-D WIN -D JIT -D FFI -@set LJARCH=x86 -:X64 -minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x86.dasc -@if errorlevel 1 goto :BAD - -%LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c -@if errorlevel 1 goto :BAD -%LJLINK% /out:buildvm.exe buildvm*.obj -@if errorlevel 1 goto :BAD -if exist buildvm.exe.manifest^ - %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe - -buildvm -m peobj -o lj_vm.obj -@if errorlevel 1 goto :BAD -buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% -@if errorlevel 1 goto :BAD -buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% -@if errorlevel 1 goto :BAD -buildvm -m libdef -o lj_libdef.h %ALL_LIB% -@if errorlevel 1 goto :BAD -buildvm -m recdef -o lj_recdef.h %ALL_LIB% -@if errorlevel 1 goto :BAD -buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% -@if errorlevel 1 goto :BAD -buildvm -m folddef -o lj_folddef.h lj_opt_fold.c -@if errorlevel 1 goto :BAD - -@if "%1" neq "debug" goto :NODEBUG -@shift -@set LJCOMPILE=%LJCOMPILE% /Zi -@set LJLINK=%LJLINK% /debug -:NODEBUG -@if "%1"=="amalg" goto :AMALGDLL -@if "%1"=="static" goto :STATIC -%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL lj_*.c lib_*.c -@if errorlevel 1 goto :BAD -%LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj -@if errorlevel 1 goto :BAD -@goto :MTDLL -:STATIC -%LJCOMPILE% lj_*.c lib_*.c -@if errorlevel 1 goto :BAD -%LJLIB% /OUT:%LJLIBNAME% lj_*.obj lib_*.obj -@if errorlevel 1 goto :BAD -@goto :MTDLL -:AMALGDLL -%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL ljamalg.c -@if errorlevel 1 goto :BAD -%LJLINK% /DLL /out:%LJDLLNAME% ljamalg.obj lj_vm.obj -@if errorlevel 1 goto :BAD -:MTDLL -if exist %LJDLLNAME%.manifest^ - %LJMT% -manifest %LJDLLNAME%.manifest -outputresource:%LJDLLNAME%;2 - -%LJCOMPILE% luajit.c -@if errorlevel 1 goto :BAD -%LJLINK% /out:luajit.exe luajit.obj %LJLIBNAME% -@if errorlevel 1 goto :BAD -if exist luajit.exe.manifest^ - %LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe - -@del *.obj *.manifest minilua.exe buildvm.exe -@echo. -@echo === Successfully built LuaJIT for Windows/%LJARCH% === - -@goto :END -:BAD -@echo. -@echo ******************************************************* -@echo *** Build FAILED -- Please check the error messages *** -@echo ******************************************************* -@goto :END -:FAIL -@echo You must open a "Visual Studio .NET Command Prompt" to run this script -:END diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/vm_arm.dasc b/source/libs/luajit/LuaJIT-2.0.3/src/vm_arm.dasc deleted file mode 100644 index 82cba909c..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/vm_arm.dasc +++ /dev/null @@ -1,4487 +0,0 @@ -|// Low-level VM code for ARM CPUs. -|// Bytecode interpreter, fast functions and helper functions. -|// Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -| -|.arch arm -|.section code_op, code_sub -| -|.actionlist build_actionlist -|.globals GLOB_ -|.globalnames globnames -|.externnames extnames -| -|// Note: The ragged indentation of the instructions is intentional. -|// The starting columns indicate data dependencies. -| -|//----------------------------------------------------------------------- -| -|// Fixed register assignments for the interpreter. -| -|// The following must be C callee-save. -|.define MASKR8, r4 // 255*8 constant for fast bytecode decoding. -|.define KBASE, r5 // Constants of current Lua function. -|.define PC, r6 // Next PC. -|.define DISPATCH, r7 // Opcode dispatch table. -|.define LREG, r8 // Register holding lua_State (also in SAVE_L). -| -|// C callee-save in EABI, but often refetched. Temporary in iOS 3.0+. -|.define BASE, r9 // Base of current Lua stack frame. -| -|// The following temporaries are not saved across C calls, except for RA/RC. -|.define RA, r10 // Callee-save. -|.define RC, r11 // Callee-save. -|.define RB, r12 -|.define OP, r12 // Overlaps RB, must not be lr. -|.define INS, lr -| -|// Calling conventions. Also used as temporaries. -|.define CARG1, r0 -|.define CARG2, r1 -|.define CARG3, r2 -|.define CARG4, r3 -|.define CARG12, r0 // For 1st soft-fp double. -|.define CARG34, r2 // For 2nd soft-fp double. -| -|.define CRET1, r0 -|.define CRET2, r1 -| -|// Stack layout while in interpreter. Must match with lj_frame.h. -|.define SAVE_R4, [sp, #28] -|.define CFRAME_SPACE, #28 -|.define SAVE_ERRF, [sp, #24] -|.define SAVE_NRES, [sp, #20] -|.define SAVE_CFRAME, [sp, #16] -|.define SAVE_L, [sp, #12] -|.define SAVE_PC, [sp, #8] -|.define SAVE_MULTRES, [sp, #4] -|.define ARG5, [sp] -| -|.define TMPDhi, [sp, #4] -|.define TMPDlo, [sp] -|.define TMPD, [sp] -|.define TMPDp, sp -| -|.if FPU -|.macro saveregs -| push {r5, r6, r7, r8, r9, r10, r11, lr} -| vpush {d8-d15} -| sub sp, sp, CFRAME_SPACE+4 -| str r4, SAVE_R4 -|.endmacro -|.macro restoreregs_ret -| ldr r4, SAVE_R4 -| add sp, sp, CFRAME_SPACE+4 -| vpop {d8-d15} -| pop {r5, r6, r7, r8, r9, r10, r11, pc} -|.endmacro -|.else -|.macro saveregs -| push {r4, r5, r6, r7, r8, r9, r10, r11, lr} -| sub sp, sp, CFRAME_SPACE -|.endmacro -|.macro restoreregs_ret -| add sp, sp, CFRAME_SPACE -| pop {r4, r5, r6, r7, r8, r9, r10, r11, pc} -|.endmacro -|.endif -| -|// Type definitions. Some of these are only used for documentation. -|.type L, lua_State, LREG -|.type GL, global_State -|.type TVALUE, TValue -|.type GCOBJ, GCobj -|.type STR, GCstr -|.type TAB, GCtab -|.type LFUNC, GCfuncL -|.type CFUNC, GCfuncC -|.type PROTO, GCproto -|.type UPVAL, GCupval -|.type NODE, Node -|.type NARGS8, int -|.type TRACE, GCtrace -| -|//----------------------------------------------------------------------- -| -|// Trap for not-yet-implemented parts. -|.macro NYI; ud; .endmacro -| -|//----------------------------------------------------------------------- -| -|// Access to frame relative to BASE. -|.define FRAME_FUNC, #-8 -|.define FRAME_PC, #-4 -| -|.macro decode_RA8, dst, ins; and dst, MASKR8, ins, lsr #5; .endmacro -|.macro decode_RB8, dst, ins; and dst, MASKR8, ins, lsr #21; .endmacro -|.macro decode_RC8, dst, ins; and dst, MASKR8, ins, lsr #13; .endmacro -|.macro decode_RD, dst, ins; lsr dst, ins, #16; .endmacro -|.macro decode_OP, dst, ins; and dst, ins, #255; .endmacro -| -|// Instruction fetch. -|.macro ins_NEXT1 -| ldrb OP, [PC] -|.endmacro -|.macro ins_NEXT2 -| ldr INS, [PC], #4 -|.endmacro -|// Instruction decode+dispatch. -|.macro ins_NEXT3 -| ldr OP, [DISPATCH, OP, lsl #2] -| decode_RA8 RA, INS -| decode_RD RC, INS -| bx OP -|.endmacro -|.macro ins_NEXT -| ins_NEXT1 -| ins_NEXT2 -| ins_NEXT3 -|.endmacro -| -|// Instruction footer. -|.if 1 -| // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. -| .define ins_next, ins_NEXT -| .define ins_next_, ins_NEXT -| .define ins_next1, ins_NEXT1 -| .define ins_next2, ins_NEXT2 -| .define ins_next3, ins_NEXT3 -|.else -| // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. -| // Affects only certain kinds of benchmarks (and only with -j off). -| .macro ins_next -| b ->ins_next -| .endmacro -| .macro ins_next1 -| .endmacro -| .macro ins_next2 -| .endmacro -| .macro ins_next3 -| b ->ins_next -| .endmacro -| .macro ins_next_ -| ->ins_next: -| ins_NEXT -| .endmacro -|.endif -| -|// Avoid register name substitution for field name. -#define field_pc pc -| -|// Call decode and dispatch. -|.macro ins_callt -| // BASE = new base, CARG3 = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC -| ldr PC, LFUNC:CARG3->field_pc -| ldrb OP, [PC] // STALL: load PC. early PC. -| ldr INS, [PC], #4 -| ldr OP, [DISPATCH, OP, lsl #2] // STALL: load OP. early OP. -| decode_RA8 RA, INS -| add RA, RA, BASE -| bx OP -|.endmacro -| -|.macro ins_call -| // BASE = new base, CARG3 = LFUNC/CFUNC, RC = nargs*8, PC = caller PC -| str PC, [BASE, FRAME_PC] -| ins_callt // STALL: locked PC. -|.endmacro -| -|//----------------------------------------------------------------------- -| -|// Macros to test operand types. -|.macro checktp, reg, tp; cmn reg, #-tp; .endmacro -|.macro checktpeq, reg, tp; cmneq reg, #-tp; .endmacro -|.macro checktpne, reg, tp; cmnne reg, #-tp; .endmacro -|.macro checkstr, reg, target; checktp reg, LJ_TSTR; bne target; .endmacro -|.macro checktab, reg, target; checktp reg, LJ_TTAB; bne target; .endmacro -|.macro checkfunc, reg, target; checktp reg, LJ_TFUNC; bne target; .endmacro -| -|// Assumes DISPATCH is relative to GL. -#define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) -#define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) -| -#define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) -| -|.macro hotcheck, delta -| lsr CARG1, PC, #1 -| and CARG1, CARG1, #126 -| sub CARG1, CARG1, #-GG_DISP2HOT -| ldrh CARG2, [DISPATCH, CARG1] -| subs CARG2, CARG2, #delta -| strh CARG2, [DISPATCH, CARG1] -|.endmacro -| -|.macro hotloop -| hotcheck HOTCOUNT_LOOP -| blo ->vm_hotloop -|.endmacro -| -|.macro hotcall -| hotcheck HOTCOUNT_CALL -| blo ->vm_hotcall -|.endmacro -| -|// Set current VM state. -|.macro mv_vmstate, reg, st; mvn reg, #LJ_VMST_..st; .endmacro -|.macro st_vmstate, reg; str reg, [DISPATCH, #DISPATCH_GL(vmstate)]; .endmacro -| -|// Move table write barrier back. Overwrites mark and tmp. -|.macro barrierback, tab, mark, tmp -| ldr tmp, [DISPATCH, #DISPATCH_GL(gc.grayagain)] -| bic mark, mark, #LJ_GC_BLACK // black2gray(tab) -| str tab, [DISPATCH, #DISPATCH_GL(gc.grayagain)] -| strb mark, tab->marked -| str tmp, tab->gclist -|.endmacro -| -|.macro .IOS, a, b -|.if IOS -| a, b -|.endif -|.endmacro -| -|//----------------------------------------------------------------------- - -#if !LJ_DUALNUM -#error "Only dual-number mode supported for ARM target" -#endif - -/* Generate subroutines used by opcodes and other parts of the VM. */ -/* The .code_sub section should be last to help static branch prediction. */ -static void build_subroutines(BuildCtx *ctx) -{ - |.code_sub - | - |//----------------------------------------------------------------------- - |//-- Return handling ---------------------------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_returnp: - | // See vm_return. Also: RB = previous base. - | tst PC, #FRAME_P - | beq ->cont_dispatch - | - | // Return from pcall or xpcall fast func. - | ldr PC, [RB, FRAME_PC] // Fetch PC of previous frame. - | mvn CARG2, #~LJ_TTRUE - | mov BASE, RB - | // Prepending may overwrite the pcall frame, so do it at the end. - | str CARG2, [RA, FRAME_PC] // Prepend true to results. - | sub RA, RA, #8 - | - |->vm_returnc: - | adds RC, RC, #8 // RC = (nresults+1)*8. - | mov CRET1, #LUA_YIELD - | beq ->vm_unwind_c_eh - | str RC, SAVE_MULTRES - | ands CARG1, PC, #FRAME_TYPE - | beq ->BC_RET_Z // Handle regular return to Lua. - | - |->vm_return: - | // BASE = base, RA = resultptr, RC/MULTRES = (nresults+1)*8, PC = return - | // CARG1 = PC & FRAME_TYPE - | bic RB, PC, #FRAME_TYPEP - | cmp CARG1, #FRAME_C - | sub RB, BASE, RB // RB = previous base. - | bne ->vm_returnp - | - | str RB, L->base - | ldr KBASE, SAVE_NRES - | mv_vmstate CARG4, C - | sub BASE, BASE, #8 - | subs CARG3, RC, #8 - | lsl KBASE, KBASE, #3 // KBASE = (nresults_wanted+1)*8 - | st_vmstate CARG4 - | beq >2 - |1: - | subs CARG3, CARG3, #8 - | ldrd CARG12, [RA], #8 - | strd CARG12, [BASE], #8 - | bne <1 - |2: - | cmp KBASE, RC // More/less results wanted? - | bne >6 - |3: - | str BASE, L->top // Store new top. - | - |->vm_leave_cp: - | ldr RC, SAVE_CFRAME // Restore previous C frame. - | mov CRET1, #0 // Ok return status for vm_pcall. - | str RC, L->cframe - | - |->vm_leave_unw: - | restoreregs_ret - | - |6: - | blt >7 // Less results wanted? - | // More results wanted. Check stack size and fill up results with nil. - | ldr CARG3, L->maxstack - | mvn CARG2, #~LJ_TNIL - | cmp BASE, CARG3 - | bhs >8 - | str CARG2, [BASE, #4] - | add RC, RC, #8 - | add BASE, BASE, #8 - | b <2 - | - |7: // Less results wanted. - | sub CARG1, RC, KBASE - | cmp KBASE, #0 // LUA_MULTRET+1 case? - | subne BASE, BASE, CARG1 // Either keep top or shrink it. - | b <3 - | - |8: // Corner case: need to grow stack for filling up results. - | // This can happen if: - | // - A C function grows the stack (a lot). - | // - The GC shrinks the stack in between. - | // - A return back from a lua_call() with (high) nresults adjustment. - | str BASE, L->top // Save current top held in BASE (yes). - | mov CARG2, KBASE - | mov CARG1, L - | bl extern lj_state_growstack // (lua_State *L, int n) - | ldr BASE, L->top // Need the (realloced) L->top in BASE. - | b <2 - | - |->vm_unwind_c: // Unwind C stack, return from vm_pcall. - | // (void *cframe, int errcode) - | mov sp, CARG1 - | mov CRET1, CARG2 - |->vm_unwind_c_eh: // Landing pad for external unwinder. - | ldr L, SAVE_L - | mv_vmstate CARG4, C - | ldr GL:CARG3, L->glref - | str CARG4, GL:CARG3->vmstate - | b ->vm_leave_unw - | - |->vm_unwind_ff: // Unwind C stack, return from ff pcall. - | // (void *cframe) - | bic CARG1, CARG1, #~CFRAME_RAWMASK // Use two steps: bic sp is deprecated. - | mov sp, CARG1 - |->vm_unwind_ff_eh: // Landing pad for external unwinder. - | ldr L, SAVE_L - | mov MASKR8, #255 - | mov RC, #16 // 2 results: false + error message. - | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. - | ldr BASE, L->base - | ldr DISPATCH, L->glref // Setup pointer to dispatch table. - | mvn CARG1, #~LJ_TFALSE - | sub RA, BASE, #8 // Results start at BASE-8. - | ldr PC, [BASE, FRAME_PC] // Fetch PC of previous frame. - | add DISPATCH, DISPATCH, #GG_G2DISP - | mv_vmstate CARG2, INTERP - | str CARG1, [BASE, #-4] // Prepend false to error message. - | st_vmstate CARG2 - | b ->vm_returnc - | - |//----------------------------------------------------------------------- - |//-- Grow stack for calls ----------------------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_growstack_c: // Grow stack for C function. - | // CARG1 = L - | mov CARG2, #LUA_MINSTACK - | b >2 - | - |->vm_growstack_l: // Grow stack for Lua function. - | // BASE = new base, RA = BASE+framesize*8, RC = nargs*8, PC = first PC - | add RC, BASE, RC - | sub RA, RA, BASE - | mov CARG1, L - | str BASE, L->base - | add PC, PC, #4 // Must point after first instruction. - | str RC, L->top - | lsr CARG3, RA, #3 - |2: - | // L->base = new base, L->top = top - | str PC, SAVE_PC - | bl extern lj_state_growstack // (lua_State *L, int n) - | ldr BASE, L->base - | ldr RC, L->top - | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] - | sub NARGS8:RC, RC, BASE - | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC - | ins_callt // Just retry the call. - | - |//----------------------------------------------------------------------- - |//-- Entry points into the assembler VM --------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_resume: // Setup C frame and resume thread. - | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) - | saveregs - | mov L, CARG1 - | ldr DISPATCH, L:CARG1->glref // Setup pointer to dispatch table. - | mov BASE, CARG2 - | add DISPATCH, DISPATCH, #GG_G2DISP - | str L, SAVE_L - | mov PC, #FRAME_CP - | str CARG3, SAVE_NRES - | add CARG2, sp, #CFRAME_RESUME - | ldrb CARG1, L->status - | str CARG3, SAVE_ERRF - | str CARG2, L->cframe - | str CARG3, SAVE_CFRAME - | cmp CARG1, #0 - | str L, SAVE_PC // Any value outside of bytecode is ok. - | beq >3 - | - | // Resume after yield (like a return). - | mov RA, BASE - | ldr BASE, L->base - | ldr CARG1, L->top - | mov MASKR8, #255 - | strb CARG3, L->status - | sub RC, CARG1, BASE - | ldr PC, [BASE, FRAME_PC] - | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. - | mv_vmstate CARG2, INTERP - | add RC, RC, #8 - | ands CARG1, PC, #FRAME_TYPE - | st_vmstate CARG2 - | str RC, SAVE_MULTRES - | beq ->BC_RET_Z - | b ->vm_return - | - |->vm_pcall: // Setup protected C frame and enter VM. - | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) - | saveregs - | mov PC, #FRAME_CP - | str CARG4, SAVE_ERRF - | b >1 - | - |->vm_call: // Setup C frame and enter VM. - | // (lua_State *L, TValue *base, int nres1) - | saveregs - | mov PC, #FRAME_C - | - |1: // Entry point for vm_pcall above (PC = ftype). - | ldr RC, L:CARG1->cframe - | str CARG3, SAVE_NRES - | mov L, CARG1 - | str CARG1, SAVE_L - | mov BASE, CARG2 - | str sp, L->cframe // Add our C frame to cframe chain. - | ldr DISPATCH, L->glref // Setup pointer to dispatch table. - | str CARG1, SAVE_PC // Any value outside of bytecode is ok. - | str RC, SAVE_CFRAME - | add DISPATCH, DISPATCH, #GG_G2DISP - | - |3: // Entry point for vm_cpcall/vm_resume (BASE = base, PC = ftype). - | ldr RB, L->base // RB = old base (for vmeta_call). - | ldr CARG1, L->top - | mov MASKR8, #255 - | add PC, PC, BASE - | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. - | sub PC, PC, RB // PC = frame delta + frame type - | mv_vmstate CARG2, INTERP - | sub NARGS8:RC, CARG1, BASE - | st_vmstate CARG2 - | - |->vm_call_dispatch: - | // RB = old base, BASE = new base, RC = nargs*8, PC = caller PC - | ldrd CARG34, [BASE, FRAME_FUNC] - | checkfunc CARG4, ->vmeta_call - | - |->vm_call_dispatch_f: - | ins_call - | // BASE = new base, CARG3 = func, RC = nargs*8, PC = caller PC - | - |->vm_cpcall: // Setup protected C frame, call C. - | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) - | saveregs - | mov L, CARG1 - | ldr RA, L:CARG1->stack - | str CARG1, SAVE_L - | ldr RB, L->top - | str CARG1, SAVE_PC // Any value outside of bytecode is ok. - | ldr RC, L->cframe - | sub RA, RA, RB // Compute -savestack(L, L->top). - | str sp, L->cframe // Add our C frame to cframe chain. - | mov RB, #0 - | str RA, SAVE_NRES // Neg. delta means cframe w/o frame. - | str RB, SAVE_ERRF // No error function. - | str RC, SAVE_CFRAME - | blx CARG4 // (lua_State *L, lua_CFunction func, void *ud) - | ldr DISPATCH, L->glref // Setup pointer to dispatch table. - | movs BASE, CRET1 - | mov PC, #FRAME_CP - | add DISPATCH, DISPATCH, #GG_G2DISP - | bne <3 // Else continue with the call. - | b ->vm_leave_cp // No base? Just remove C frame. - | - |//----------------------------------------------------------------------- - |//-- Metamethod handling ------------------------------------------------ - |//----------------------------------------------------------------------- - | - |//-- Continuation dispatch ---------------------------------------------- - | - |->cont_dispatch: - | // BASE = meta base, RA = resultptr, RC = (nresults+1)*8 - | ldr LFUNC:CARG3, [RB, FRAME_FUNC] - | ldr CARG1, [BASE, #-16] // Get continuation. - | mov CARG4, BASE - | mov BASE, RB // Restore caller BASE. - |.if FFI - | cmp CARG1, #1 - |.endif - | ldr PC, [CARG4, #-12] // Restore PC from [cont|PC]. - | ldr CARG3, LFUNC:CARG3->field_pc - | mvn INS, #~LJ_TNIL - | add CARG2, RA, RC - | str INS, [CARG2, #-4] // Ensure one valid arg. - |.if FFI - | bls >1 - |.endif - | ldr KBASE, [CARG3, #PC2PROTO(k)] - | // BASE = base, RA = resultptr, CARG4 = meta base - | bx CARG1 - | - |.if FFI - |1: - | beq ->cont_ffi_callback // cont = 1: return from FFI callback. - | // cont = 0: tailcall from C function. - | ldr CARG3, [BASE, FRAME_FUNC] - | sub CARG4, CARG4, #16 - | sub RC, CARG4, BASE - | b ->vm_call_tail - |.endif - | - |->cont_cat: // RA = resultptr, CARG4 = meta base - | ldr INS, [PC, #-4] - | sub CARG2, CARG4, #16 - | ldrd CARG34, [RA] - | str BASE, L->base - | decode_RB8 RC, INS - | decode_RA8 RA, INS - | add CARG1, BASE, RC - | subs CARG1, CARG2, CARG1 - | strdne CARG34, [CARG2] - | movne CARG3, CARG1 - | bne ->BC_CAT_Z - | strd CARG34, [BASE, RA] - | b ->cont_nop - | - |//-- Table indexing metamethods ----------------------------------------- - | - |->vmeta_tgets1: - | add CARG2, BASE, RB - | b >2 - | - |->vmeta_tgets: - | sub CARG2, DISPATCH, #-DISPATCH_GL(tmptv) - | mvn CARG4, #~LJ_TTAB - | str TAB:RB, [CARG2] - | str CARG4, [CARG2, #4] - |2: - | mvn CARG4, #~LJ_TSTR - | str STR:RC, TMPDlo - | str CARG4, TMPDhi - | mov CARG3, TMPDp - | b >1 - | - |->vmeta_tgetb: // RC = index - | decode_RB8 RB, INS - | str RC, TMPDlo - | mvn CARG4, #~LJ_TISNUM - | add CARG2, BASE, RB - | str CARG4, TMPDhi - | mov CARG3, TMPDp - | b >1 - | - |->vmeta_tgetv: - | add CARG2, BASE, RB - | add CARG3, BASE, RC - |1: - | str BASE, L->base - | mov CARG1, L - | str PC, SAVE_PC - | bl extern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) - | // Returns TValue * (finished) or NULL (metamethod). - | .IOS ldr BASE, L->base - | cmp CRET1, #0 - | beq >3 - | ldrd CARG34, [CRET1] - | ins_next1 - | ins_next2 - | strd CARG34, [BASE, RA] - | ins_next3 - | - |3: // Call __index metamethod. - | // BASE = base, L->top = new base, stack = cont/func/t/k - | rsb CARG1, BASE, #FRAME_CONT - | ldr BASE, L->top - | mov NARGS8:RC, #16 // 2 args for func(t, k). - | str PC, [BASE, #-12] // [cont|PC] - | add PC, CARG1, BASE - | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Guaranteed to be a function here. - | b ->vm_call_dispatch_f - | - |//----------------------------------------------------------------------- - | - |->vmeta_tsets1: - | add CARG2, BASE, RB - | b >2 - | - |->vmeta_tsets: - | sub CARG2, DISPATCH, #-DISPATCH_GL(tmptv) - | mvn CARG4, #~LJ_TTAB - | str TAB:RB, [CARG2] - | str CARG4, [CARG2, #4] - |2: - | mvn CARG4, #~LJ_TSTR - | str STR:RC, TMPDlo - | str CARG4, TMPDhi - | mov CARG3, TMPDp - | b >1 - | - |->vmeta_tsetb: // RC = index - | decode_RB8 RB, INS - | str RC, TMPDlo - | mvn CARG4, #~LJ_TISNUM - | add CARG2, BASE, RB - | str CARG4, TMPDhi - | mov CARG3, TMPDp - | b >1 - | - |->vmeta_tsetv: - | add CARG2, BASE, RB - | add CARG3, BASE, RC - |1: - | str BASE, L->base - | mov CARG1, L - | str PC, SAVE_PC - | bl extern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) - | // Returns TValue * (finished) or NULL (metamethod). - | .IOS ldr BASE, L->base - | cmp CRET1, #0 - | ldrd CARG34, [BASE, RA] - | beq >3 - | ins_next1 - | // NOBARRIER: lj_meta_tset ensures the table is not black. - | strd CARG34, [CRET1] - | ins_next2 - | ins_next3 - | - |3: // Call __newindex metamethod. - | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) - | rsb CARG1, BASE, #FRAME_CONT - | ldr BASE, L->top - | mov NARGS8:RC, #24 // 3 args for func(t, k, v). - | strd CARG34, [BASE, #16] // Copy value to third argument. - | str PC, [BASE, #-12] // [cont|PC] - | add PC, CARG1, BASE - | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Guaranteed to be a function here. - | b ->vm_call_dispatch_f - | - |//-- Comparison metamethods --------------------------------------------- - | - |->vmeta_comp: - | mov CARG1, L - | sub PC, PC, #4 - | mov CARG2, RA - | str BASE, L->base - | mov CARG3, RC - | str PC, SAVE_PC - | decode_OP CARG4, INS - | bl extern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) - | // Returns 0/1 or TValue * (metamethod). - |3: - | .IOS ldr BASE, L->base - | cmp CRET1, #1 - | bhi ->vmeta_binop - |4: - | ldrh RB, [PC, #2] - | add PC, PC, #4 - | add RB, PC, RB, lsl #2 - | subhs PC, RB, #0x20000 - |->cont_nop: - | ins_next - | - |->cont_ra: // RA = resultptr - | ldr INS, [PC, #-4] - | ldrd CARG12, [RA] - | decode_RA8 CARG3, INS - | strd CARG12, [BASE, CARG3] - | b ->cont_nop - | - |->cont_condt: // RA = resultptr - | ldr CARG2, [RA, #4] - | mvn CARG1, #~LJ_TTRUE - | cmp CARG1, CARG2 // Branch if result is true. - | b <4 - | - |->cont_condf: // RA = resultptr - | ldr CARG2, [RA, #4] - | checktp CARG2, LJ_TFALSE // Branch if result is false. - | b <4 - | - |->vmeta_equal: - | // CARG2, CARG3, CARG4 are already set by BC_ISEQV/BC_ISNEV. - | sub PC, PC, #4 - | str BASE, L->base - | mov CARG1, L - | str PC, SAVE_PC - | bl extern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) - | // Returns 0/1 or TValue * (metamethod). - | b <3 - | - |->vmeta_equal_cd: - |.if FFI - | sub PC, PC, #4 - | str BASE, L->base - | mov CARG1, L - | mov CARG2, INS - | str PC, SAVE_PC - | bl extern lj_meta_equal_cd // (lua_State *L, BCIns op) - | // Returns 0/1 or TValue * (metamethod). - | b <3 - |.endif - | - |//-- Arithmetic metamethods --------------------------------------------- - | - |->vmeta_arith_vn: - | decode_RB8 RB, INS - | decode_RC8 RC, INS - | add CARG3, BASE, RB - | add CARG4, KBASE, RC - | b >1 - | - |->vmeta_arith_nv: - | decode_RB8 RB, INS - | decode_RC8 RC, INS - | add CARG4, BASE, RB - | add CARG3, KBASE, RC - | b >1 - | - |->vmeta_unm: - | ldr INS, [PC, #-8] - | sub PC, PC, #4 - | add CARG3, BASE, RC - | add CARG4, BASE, RC - | b >1 - | - |->vmeta_arith_vv: - | decode_RB8 RB, INS - | decode_RC8 RC, INS - | add CARG3, BASE, RB - | add CARG4, BASE, RC - |1: - | decode_OP OP, INS - | add CARG2, BASE, RA - | str BASE, L->base - | mov CARG1, L - | str PC, SAVE_PC - | str OP, ARG5 - | bl extern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) - | // Returns NULL (finished) or TValue * (metamethod). - | .IOS ldr BASE, L->base - | cmp CRET1, #0 - | beq ->cont_nop - | - | // Call metamethod for binary op. - |->vmeta_binop: - | // BASE = old base, CRET1 = new base, stack = cont/func/o1/o2 - | sub CARG2, CRET1, BASE - | str PC, [CRET1, #-12] // [cont|PC] - | add PC, CARG2, #FRAME_CONT - | mov BASE, CRET1 - | mov NARGS8:RC, #16 // 2 args for func(o1, o2). - | b ->vm_call_dispatch - | - |->vmeta_len: - | add CARG2, BASE, RC - | str BASE, L->base - | mov CARG1, L - | str PC, SAVE_PC - | bl extern lj_meta_len // (lua_State *L, TValue *o) - | // Returns NULL (retry) or TValue * (metamethod base). - | .IOS ldr BASE, L->base -#if LJ_52 - | cmp CRET1, #0 - | bne ->vmeta_binop // Binop call for compatibility. - | ldr TAB:CARG1, [BASE, RC] - | b ->BC_LEN_Z -#else - | b ->vmeta_binop // Binop call for compatibility. -#endif - | - |//-- Call metamethod ---------------------------------------------------- - | - |->vmeta_call: // Resolve and call __call metamethod. - | // RB = old base, BASE = new base, RC = nargs*8 - | mov CARG1, L - | str RB, L->base // This is the callers base! - | sub CARG2, BASE, #8 - | str PC, SAVE_PC - | add CARG3, BASE, NARGS8:RC - | .IOS mov RA, BASE - | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) - | .IOS mov BASE, RA - | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Guaranteed to be a function here. - | add NARGS8:RC, NARGS8:RC, #8 // Got one more argument now. - | ins_call - | - |->vmeta_callt: // Resolve __call for BC_CALLT. - | // BASE = old base, RA = new base, RC = nargs*8 - | mov CARG1, L - | str BASE, L->base - | sub CARG2, RA, #8 - | str PC, SAVE_PC - | add CARG3, RA, NARGS8:RC - | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) - | .IOS ldr BASE, L->base - | ldr LFUNC:CARG3, [RA, FRAME_FUNC] // Guaranteed to be a function here. - | ldr PC, [BASE, FRAME_PC] - | add NARGS8:RC, NARGS8:RC, #8 // Got one more argument now. - | b ->BC_CALLT2_Z - | - |//-- Argument coercion for 'for' statement ------------------------------ - | - |->vmeta_for: - | mov CARG1, L - | str BASE, L->base - | mov CARG2, RA - | str PC, SAVE_PC - | bl extern lj_meta_for // (lua_State *L, TValue *base) - | .IOS ldr BASE, L->base - |.if JIT - | ldrb OP, [PC, #-4] - |.endif - | ldr INS, [PC, #-4] - |.if JIT - | cmp OP, #BC_JFORI - |.endif - | decode_RA8 RA, INS - | decode_RD RC, INS - |.if JIT - | beq =>BC_JFORI - |.endif - | b =>BC_FORI - | - |//----------------------------------------------------------------------- - |//-- Fast functions ----------------------------------------------------- - |//----------------------------------------------------------------------- - | - |.macro .ffunc, name - |->ff_ .. name: - |.endmacro - | - |.macro .ffunc_1, name - |->ff_ .. name: - | ldrd CARG12, [BASE] - | cmp NARGS8:RC, #8 - | blo ->fff_fallback - |.endmacro - | - |.macro .ffunc_2, name - |->ff_ .. name: - | ldrd CARG12, [BASE] - | ldrd CARG34, [BASE, #8] - | cmp NARGS8:RC, #16 - | blo ->fff_fallback - |.endmacro - | - |.macro .ffunc_n, name - | .ffunc_1 name - | checktp CARG2, LJ_TISNUM - | bhs ->fff_fallback - |.endmacro - | - |.macro .ffunc_nn, name - | .ffunc_2 name - | checktp CARG2, LJ_TISNUM - | cmnlo CARG4, #-LJ_TISNUM - | bhs ->fff_fallback - |.endmacro - | - |.macro .ffunc_d, name - | .ffunc name - | ldr CARG2, [BASE, #4] - | cmp NARGS8:RC, #8 - | vldr d0, [BASE] - | blo ->fff_fallback - | checktp CARG2, LJ_TISNUM - | bhs ->fff_fallback - |.endmacro - | - |.macro .ffunc_dd, name - | .ffunc name - | ldr CARG2, [BASE, #4] - | ldr CARG4, [BASE, #12] - | cmp NARGS8:RC, #16 - | vldr d0, [BASE] - | vldr d1, [BASE, #8] - | blo ->fff_fallback - | checktp CARG2, LJ_TISNUM - | cmnlo CARG4, #-LJ_TISNUM - | bhs ->fff_fallback - |.endmacro - | - |// Inlined GC threshold check. Caveat: uses CARG1 and CARG2. - |.macro ffgccheck - | ldr CARG1, [DISPATCH, #DISPATCH_GL(gc.total)] - | ldr CARG2, [DISPATCH, #DISPATCH_GL(gc.threshold)] - | cmp CARG1, CARG2 - | blge ->fff_gcstep - |.endmacro - | - |//-- Base library: checks ----------------------------------------------- - | - |.ffunc_1 assert - | checktp CARG2, LJ_TTRUE - | bhi ->fff_fallback - | ldr PC, [BASE, FRAME_PC] - | strd CARG12, [BASE, #-8] - | mov RB, BASE - | subs RA, NARGS8:RC, #8 - | add RC, NARGS8:RC, #8 // Compute (nresults+1)*8. - | beq ->fff_res // Done if exactly 1 argument. - |1: - | ldrd CARG12, [RB, #8] - | subs RA, RA, #8 - | strd CARG12, [RB], #8 - | bne <1 - | b ->fff_res - | - |.ffunc type - | ldr CARG2, [BASE, #4] - | cmp NARGS8:RC, #8 - | blo ->fff_fallback - | checktp CARG2, LJ_TISNUM - | mvnlo CARG2, #~LJ_TISNUM - | rsb CARG4, CARG2, #(int)(offsetof(GCfuncC, upvalue)>>3)-1 - | lsl CARG4, CARG4, #3 - | ldrd CARG12, [CFUNC:CARG3, CARG4] - | b ->fff_restv - | - |//-- Base library: getters and setters --------------------------------- - | - |.ffunc_1 getmetatable - | checktp CARG2, LJ_TTAB - | cmnne CARG2, #-LJ_TUDATA - | bne >6 - |1: // Field metatable must be at same offset for GCtab and GCudata! - | ldr TAB:RB, TAB:CARG1->metatable - |2: - | mvn CARG2, #~LJ_TNIL - | ldr STR:RC, [DISPATCH, #DISPATCH_GL(gcroot[GCROOT_MMNAME+MM_metatable])] - | cmp TAB:RB, #0 - | beq ->fff_restv - | ldr CARG3, TAB:RB->hmask - | ldr CARG4, STR:RC->hash - | ldr NODE:INS, TAB:RB->node - | and CARG3, CARG3, CARG4 // idx = str->hash & tab->hmask - | add CARG3, CARG3, CARG3, lsl #1 - | add NODE:INS, NODE:INS, CARG3, lsl #3 // node = tab->node + idx*3*8 - |3: // Rearranged logic, because we expect _not_ to find the key. - | ldrd CARG34, NODE:INS->key // STALL: early NODE:INS. - | ldrd CARG12, NODE:INS->val - | ldr NODE:INS, NODE:INS->next - | checktp CARG4, LJ_TSTR - | cmpeq CARG3, STR:RC - | beq >5 - | cmp NODE:INS, #0 - | bne <3 - |4: - | mov CARG1, RB // Use metatable as default result. - | mvn CARG2, #~LJ_TTAB - | b ->fff_restv - |5: - | checktp CARG2, LJ_TNIL - | bne ->fff_restv - | b <4 - | - |6: - | checktp CARG2, LJ_TISNUM - | mvnhs CARG2, CARG2 - | movlo CARG2, #~LJ_TISNUM - | add CARG4, DISPATCH, CARG2, lsl #2 - | ldr TAB:RB, [CARG4, #DISPATCH_GL(gcroot[GCROOT_BASEMT])] - | b <2 - | - |.ffunc_2 setmetatable - | // Fast path: no mt for table yet and not clearing the mt. - | checktp CARG2, LJ_TTAB - | ldreq TAB:RB, TAB:CARG1->metatable - | checktpeq CARG4, LJ_TTAB - | ldrbeq CARG4, TAB:CARG1->marked - | cmpeq TAB:RB, #0 - | bne ->fff_fallback - | tst CARG4, #LJ_GC_BLACK // isblack(table) - | str TAB:CARG3, TAB:CARG1->metatable - | beq ->fff_restv - | barrierback TAB:CARG1, CARG4, CARG3 - | b ->fff_restv - | - |.ffunc rawget - | ldrd CARG34, [BASE] - | cmp NARGS8:RC, #16 - | blo ->fff_fallback - | mov CARG2, CARG3 - | checktab CARG4, ->fff_fallback - | mov CARG1, L - | add CARG3, BASE, #8 - | .IOS mov RA, BASE - | bl extern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) - | // Returns cTValue *. - | .IOS mov BASE, RA - | ldrd CARG12, [CRET1] - | b ->fff_restv - | - |//-- Base library: conversions ------------------------------------------ - | - |.ffunc tonumber - | // Only handles the number case inline (without a base argument). - | ldrd CARG12, [BASE] - | cmp NARGS8:RC, #8 - | bne ->fff_fallback - | checktp CARG2, LJ_TISNUM - | bls ->fff_restv - | b ->fff_fallback - | - |.ffunc_1 tostring - | // Only handles the string or number case inline. - | checktp CARG2, LJ_TSTR - | // A __tostring method in the string base metatable is ignored. - | beq ->fff_restv - | // Handle numbers inline, unless a number base metatable is present. - | ldr CARG4, [DISPATCH, #DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])] - | str BASE, L->base - | checktp CARG2, LJ_TISNUM - | cmpls CARG4, #0 - | str PC, SAVE_PC // Redundant (but a defined value). - | bhi ->fff_fallback - | ffgccheck - | mov CARG1, L - | mov CARG2, BASE - | bl extern lj_str_fromnumber // (lua_State *L, cTValue *o) - | // Returns GCstr *. - | ldr BASE, L->base - | mvn CARG2, #~LJ_TSTR - | b ->fff_restv - | - |//-- Base library: iterators ------------------------------------------- - | - |.ffunc_1 next - | mvn CARG4, #~LJ_TNIL - | checktab CARG2, ->fff_fallback - | strd CARG34, [BASE, NARGS8:RC] // Set missing 2nd arg to nil. - | ldr PC, [BASE, FRAME_PC] - | mov CARG2, CARG1 - | str BASE, L->base // Add frame since C call can throw. - | mov CARG1, L - | str BASE, L->top // Dummy frame length is ok. - | add CARG3, BASE, #8 - | str PC, SAVE_PC - | bl extern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) - | // Returns 0 at end of traversal. - | .IOS ldr BASE, L->base - | cmp CRET1, #0 - | mvneq CRET2, #~LJ_TNIL - | beq ->fff_restv // End of traversal: return nil. - | ldrd CARG12, [BASE, #8] // Copy key and value to results. - | ldrd CARG34, [BASE, #16] - | mov RC, #(2+1)*8 - | strd CARG12, [BASE, #-8] - | strd CARG34, [BASE] - | b ->fff_res - | - |.ffunc_1 pairs - | checktab CARG2, ->fff_fallback -#if LJ_52 - | ldr TAB:RB, TAB:CARG1->metatable -#endif - | ldrd CFUNC:CARG34, CFUNC:CARG3->upvalue[0] - | ldr PC, [BASE, FRAME_PC] -#if LJ_52 - | cmp TAB:RB, #0 - | bne ->fff_fallback -#endif - | mvn CARG2, #~LJ_TNIL - | mov RC, #(3+1)*8 - | strd CFUNC:CARG34, [BASE, #-8] - | str CARG2, [BASE, #12] - | b ->fff_res - | - |.ffunc_2 ipairs_aux - | checktp CARG2, LJ_TTAB - | checktpeq CARG4, LJ_TISNUM - | bne ->fff_fallback - | ldr RB, TAB:CARG1->asize - | ldr RC, TAB:CARG1->array - | add CARG3, CARG3, #1 - | ldr PC, [BASE, FRAME_PC] - | cmp CARG3, RB - | add RC, RC, CARG3, lsl #3 - | strd CARG34, [BASE, #-8] - | ldrdlo CARG12, [RC] - | mov RC, #(0+1)*8 - | bhs >2 // Not in array part? - |1: - | checktp CARG2, LJ_TNIL - | movne RC, #(2+1)*8 - | strdne CARG12, [BASE] - | b ->fff_res - |2: // Check for empty hash part first. Otherwise call C function. - | ldr RB, TAB:CARG1->hmask - | mov CARG2, CARG3 - | cmp RB, #0 - | beq ->fff_res - | .IOS mov RA, BASE - | bl extern lj_tab_getinth // (GCtab *t, int32_t key) - | // Returns cTValue * or NULL. - | .IOS mov BASE, RA - | cmp CRET1, #0 - | beq ->fff_res - | ldrd CARG12, [CRET1] - | b <1 - | - |.ffunc_1 ipairs - | checktab CARG2, ->fff_fallback -#if LJ_52 - | ldr TAB:RB, TAB:CARG1->metatable -#endif - | ldrd CFUNC:CARG34, CFUNC:CARG3->upvalue[0] - | ldr PC, [BASE, FRAME_PC] -#if LJ_52 - | cmp TAB:RB, #0 - | bne ->fff_fallback -#endif - | mov CARG1, #0 - | mvn CARG2, #~LJ_TISNUM - | mov RC, #(3+1)*8 - | strd CFUNC:CARG34, [BASE, #-8] - | strd CARG12, [BASE, #8] - | b ->fff_res - | - |//-- Base library: catch errors ---------------------------------------- - | - |.ffunc pcall - | ldrb RA, [DISPATCH, #DISPATCH_GL(hookmask)] - | cmp NARGS8:RC, #8 - | blo ->fff_fallback - | tst RA, #HOOK_ACTIVE // Remember active hook before pcall. - | mov RB, BASE - | add BASE, BASE, #8 - | moveq PC, #8+FRAME_PCALL - | movne PC, #8+FRAME_PCALLH - | sub NARGS8:RC, NARGS8:RC, #8 - | b ->vm_call_dispatch - | - |.ffunc_2 xpcall - | ldrb RA, [DISPATCH, #DISPATCH_GL(hookmask)] - | checkfunc CARG4, ->fff_fallback // Traceback must be a function. - | mov RB, BASE - | strd CARG12, [BASE, #8] // Swap function and traceback. - | strd CARG34, [BASE] - | tst RA, #HOOK_ACTIVE // Remember active hook before pcall. - | add BASE, BASE, #16 - | moveq PC, #16+FRAME_PCALL - | movne PC, #16+FRAME_PCALLH - | sub NARGS8:RC, NARGS8:RC, #16 - | b ->vm_call_dispatch - | - |//-- Coroutine library -------------------------------------------------- - | - |.macro coroutine_resume_wrap, resume - |.if resume - |.ffunc_1 coroutine_resume - | checktp CARG2, LJ_TTHREAD - | bne ->fff_fallback - |.else - |.ffunc coroutine_wrap_aux - | ldr L:CARG1, CFUNC:CARG3->upvalue[0].gcr - |.endif - | ldr PC, [BASE, FRAME_PC] - | str BASE, L->base - | ldr CARG2, L:CARG1->top - | ldrb RA, L:CARG1->status - | ldr RB, L:CARG1->base - | add CARG3, CARG2, NARGS8:RC - | add CARG4, CARG2, RA - | str PC, SAVE_PC - | cmp CARG4, RB - | beq ->fff_fallback - | ldr CARG4, L:CARG1->maxstack - | ldr RB, L:CARG1->cframe - | cmp RA, #LUA_YIELD - | cmpls CARG3, CARG4 - | cmpls RB, #0 - | bhi ->fff_fallback - |1: - |.if resume - | sub CARG3, CARG3, #8 // Keep resumed thread in stack for GC. - | add BASE, BASE, #8 - | sub NARGS8:RC, NARGS8:RC, #8 - |.endif - | str CARG3, L:CARG1->top - | str BASE, L->top - |2: // Move args to coroutine. - | ldrd CARG34, [BASE, RB] - | cmp RB, NARGS8:RC - | strdne CARG34, [CARG2, RB] - | add RB, RB, #8 - | bne <2 - | - | mov CARG3, #0 - | mov L:RA, L:CARG1 - | mov CARG4, #0 - | bl ->vm_resume // (lua_State *L, TValue *base, 0, 0) - | // Returns thread status. - |4: - | ldr CARG3, L:RA->base - | mv_vmstate CARG2, INTERP - | ldr CARG4, L:RA->top - | st_vmstate CARG2 - | cmp CRET1, #LUA_YIELD - | ldr BASE, L->base - | bhi >8 - | subs RC, CARG4, CARG3 - | ldr CARG1, L->maxstack - | add CARG2, BASE, RC - | beq >6 // No results? - | cmp CARG2, CARG1 - | mov RB, #0 - | bhi >9 // Need to grow stack? - | - | sub CARG4, RC, #8 - | str CARG3, L:RA->top // Clear coroutine stack. - |5: // Move results from coroutine. - | ldrd CARG12, [CARG3, RB] - | cmp RB, CARG4 - | strd CARG12, [BASE, RB] - | add RB, RB, #8 - | bne <5 - |6: - |.if resume - | mvn CARG3, #~LJ_TTRUE - | add RC, RC, #16 - |7: - | str CARG3, [BASE, #-4] // Prepend true/false to results. - | sub RA, BASE, #8 - |.else - | mov RA, BASE - | add RC, RC, #8 - |.endif - | ands CARG1, PC, #FRAME_TYPE - | str PC, SAVE_PC - | str RC, SAVE_MULTRES - | beq ->BC_RET_Z - | b ->vm_return - | - |8: // Coroutine returned with error (at co->top-1). - |.if resume - | ldrd CARG12, [CARG4, #-8]! - | mvn CARG3, #~LJ_TFALSE - | mov RC, #(2+1)*8 - | str CARG4, L:RA->top // Remove error from coroutine stack. - | strd CARG12, [BASE] // Copy error message. - | b <7 - |.else - | mov CARG1, L - | mov CARG2, L:RA - | bl extern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co) - | // Never returns. - |.endif - | - |9: // Handle stack expansion on return from yield. - | mov CARG1, L - | lsr CARG2, RC, #3 - | bl extern lj_state_growstack // (lua_State *L, int n) - | mov CRET1, #0 - | b <4 - |.endmacro - | - | coroutine_resume_wrap 1 // coroutine.resume - | coroutine_resume_wrap 0 // coroutine.wrap - | - |.ffunc coroutine_yield - | ldr CARG1, L->cframe - | add CARG2, BASE, NARGS8:RC - | str BASE, L->base - | tst CARG1, #CFRAME_RESUME - | str CARG2, L->top - | mov CRET1, #LUA_YIELD - | mov CARG3, #0 - | beq ->fff_fallback - | str CARG3, L->cframe - | strb CRET1, L->status - | b ->vm_leave_unw - | - |//-- Math library ------------------------------------------------------- - | - |.macro math_round, func - | .ffunc_1 math_ .. func - | checktp CARG2, LJ_TISNUM - | beq ->fff_restv - | bhi ->fff_fallback - | // Round FP value and normalize result. - | lsl CARG3, CARG2, #1 - | adds RB, CARG3, #0x00200000 - | bpl >2 // |x| < 1? - | mvn CARG4, #0x3e0 - | subs RB, CARG4, RB, asr #21 - | lsl CARG4, CARG2, #11 - | lsl CARG3, CARG1, #11 - | orr CARG4, CARG4, #0x80000000 - | rsb INS, RB, #32 - | orr CARG4, CARG4, CARG1, lsr #21 - | bls >3 // |x| >= 2^31? - | orr CARG3, CARG3, CARG4, lsl INS - | lsr CARG1, CARG4, RB - |.if "func" == "floor" - | tst CARG3, CARG2, asr #31 - | addne CARG1, CARG1, #1 - |.else - | bics CARG3, CARG3, CARG2, asr #31 - | addsne CARG1, CARG1, #1 - | ldrdvs CARG12, >9 - | bvs ->fff_restv - |.endif - | cmp CARG2, #0 - | rsblt CARG1, CARG1, #0 - |1: - | mvn CARG2, #~LJ_TISNUM - | b ->fff_restv - | - |2: // |x| < 1 - | bcs ->fff_restv // |x| is not finite. - | orr CARG3, CARG3, CARG1 // ztest = abs(hi) | lo - |.if "func" == "floor" - | tst CARG3, CARG2, asr #31 // return (ztest & sign) == 0 ? 0 : -1 - | moveq CARG1, #0 - | mvnne CARG1, #0 - |.else - | bics CARG3, CARG3, CARG2, asr #31 // return (ztest & ~sign) == 0 ? 0 : 1 - | moveq CARG1, #0 - | movne CARG1, #1 - |.endif - | mvn CARG2, #~LJ_TISNUM - | b ->fff_restv - | - |3: // |x| >= 2^31. Check for x == -(2^31). - | cmpeq CARG4, #0x80000000 - |.if "func" == "floor" - | cmpeq CARG3, #0 - |.endif - | bne >4 - | cmp CARG2, #0 - | movmi CARG1, #0x80000000 - | bmi <1 - |4: - | bl ->vm_..func.._sf - | b ->fff_restv - |.endmacro - | - | math_round floor - | math_round ceil - | - |.align 8 - |9: - | .long 0x00000000, 0x41e00000 // 2^31. - | - |.ffunc_1 math_abs - | checktp CARG2, LJ_TISNUM - | bhi ->fff_fallback - | bicne CARG2, CARG2, #0x80000000 - | bne ->fff_restv - | cmp CARG1, #0 - | rsbslt CARG1, CARG1, #0 - | ldrdvs CARG12, <9 - | // Fallthrough. - | - |->fff_restv: - | // CARG12 = TValue result. - | ldr PC, [BASE, FRAME_PC] - | strd CARG12, [BASE, #-8] - |->fff_res1: - | // PC = return. - | mov RC, #(1+1)*8 - |->fff_res: - | // RC = (nresults+1)*8, PC = return. - | ands CARG1, PC, #FRAME_TYPE - | ldreq INS, [PC, #-4] - | str RC, SAVE_MULTRES - | sub RA, BASE, #8 - | bne ->vm_return - | decode_RB8 RB, INS - |5: - | cmp RB, RC // More results expected? - | bhi >6 - | decode_RA8 CARG1, INS - | ins_next1 - | ins_next2 - | // Adjust BASE. KBASE is assumed to be set for the calling frame. - | sub BASE, RA, CARG1 - | ins_next3 - | - |6: // Fill up results with nil. - | add CARG2, RA, RC - | mvn CARG1, #~LJ_TNIL - | add RC, RC, #8 - | str CARG1, [CARG2, #-4] - | b <5 - | - |.macro math_extern, func - |.if HFABI - | .ffunc_d math_ .. func - |.else - | .ffunc_n math_ .. func - |.endif - | .IOS mov RA, BASE - | bl extern func - | .IOS mov BASE, RA - |.if HFABI - | b ->fff_resd - |.else - | b ->fff_restv - |.endif - |.endmacro - | - |.macro math_extern2, func - |.if HFABI - | .ffunc_dd math_ .. func - |.else - | .ffunc_nn math_ .. func - |.endif - | .IOS mov RA, BASE - | bl extern func - | .IOS mov BASE, RA - |.if HFABI - | b ->fff_resd - |.else - | b ->fff_restv - |.endif - |.endmacro - | - |.if FPU - | .ffunc_d math_sqrt - | vsqrt.f64 d0, d0 - |->fff_resd: - | ldr PC, [BASE, FRAME_PC] - | vstr d0, [BASE, #-8] - | b ->fff_res1 - |.else - | math_extern sqrt - |.endif - | - |.ffunc math_log - |.if HFABI - | ldr CARG2, [BASE, #4] - | cmp NARGS8:RC, #8 // Need exactly 1 argument. - | vldr d0, [BASE] - | bne ->fff_fallback - |.else - | ldrd CARG12, [BASE] - | cmp NARGS8:RC, #8 // Need exactly 1 argument. - | bne ->fff_fallback - |.endif - | checktp CARG2, LJ_TISNUM - | bhs ->fff_fallback - | .IOS mov RA, BASE - | bl extern log - | .IOS mov BASE, RA - |.if HFABI - | b ->fff_resd - |.else - | b ->fff_restv - |.endif - | - | math_extern log10 - | math_extern exp - | math_extern sin - | math_extern cos - | math_extern tan - | math_extern asin - | math_extern acos - | math_extern atan - | math_extern sinh - | math_extern cosh - | math_extern tanh - | math_extern2 pow - | math_extern2 atan2 - | math_extern2 fmod - | - |->ff_math_deg: - |.if FPU - | .ffunc_d math_rad - | vldr d1, CFUNC:CARG3->upvalue[0] - | vmul.f64 d0, d0, d1 - | b ->fff_resd - |.else - | .ffunc_n math_rad - | ldrd CARG34, CFUNC:CARG3->upvalue[0] - | bl extern __aeabi_dmul - | b ->fff_restv - |.endif - | - |.if HFABI - | .ffunc math_ldexp - | ldr CARG4, [BASE, #4] - | ldrd CARG12, [BASE, #8] - | cmp NARGS8:RC, #16 - | blo ->fff_fallback - | vldr d0, [BASE] - | checktp CARG4, LJ_TISNUM - | bhs ->fff_fallback - | checktp CARG2, LJ_TISNUM - | bne ->fff_fallback - | .IOS mov RA, BASE - | bl extern ldexp // (double x, int exp) - | .IOS mov BASE, RA - | b ->fff_resd - |.else - |.ffunc_2 math_ldexp - | checktp CARG2, LJ_TISNUM - | bhs ->fff_fallback - | checktp CARG4, LJ_TISNUM - | bne ->fff_fallback - | .IOS mov RA, BASE - | bl extern ldexp // (double x, int exp) - | .IOS mov BASE, RA - | b ->fff_restv - |.endif - | - |.if HFABI - |.ffunc_d math_frexp - | mov CARG1, sp - | .IOS mov RA, BASE - | bl extern frexp - | .IOS mov BASE, RA - | ldr CARG3, [sp] - | mvn CARG4, #~LJ_TISNUM - | ldr PC, [BASE, FRAME_PC] - | vstr d0, [BASE, #-8] - | mov RC, #(2+1)*8 - | strd CARG34, [BASE] - | b ->fff_res - |.else - |.ffunc_n math_frexp - | mov CARG3, sp - | .IOS mov RA, BASE - | bl extern frexp - | .IOS mov BASE, RA - | ldr CARG3, [sp] - | mvn CARG4, #~LJ_TISNUM - | ldr PC, [BASE, FRAME_PC] - | strd CARG12, [BASE, #-8] - | mov RC, #(2+1)*8 - | strd CARG34, [BASE] - | b ->fff_res - |.endif - | - |.if HFABI - |.ffunc_d math_modf - | sub CARG1, BASE, #8 - | ldr PC, [BASE, FRAME_PC] - | .IOS mov RA, BASE - | bl extern modf - | .IOS mov BASE, RA - | mov RC, #(2+1)*8 - | vstr d0, [BASE] - | b ->fff_res - |.else - |.ffunc_n math_modf - | sub CARG3, BASE, #8 - | ldr PC, [BASE, FRAME_PC] - | .IOS mov RA, BASE - | bl extern modf - | .IOS mov BASE, RA - | mov RC, #(2+1)*8 - | strd CARG12, [BASE] - | b ->fff_res - |.endif - | - |.macro math_minmax, name, cond, fcond - |.if FPU - | .ffunc_1 name - | add RB, BASE, RC - | checktp CARG2, LJ_TISNUM - | add RA, BASE, #8 - | bne >4 - |1: // Handle integers. - | ldrd CARG34, [RA] - | cmp RA, RB - | bhs ->fff_restv - | checktp CARG4, LJ_TISNUM - | bne >3 - | cmp CARG1, CARG3 - | add RA, RA, #8 - | mov..cond CARG1, CARG3 - | b <1 - |3: // Convert intermediate result to number and continue below. - | vmov s4, CARG1 - | bhi ->fff_fallback - | vldr d1, [RA] - | vcvt.f64.s32 d0, s4 - | b >6 - | - |4: - | vldr d0, [BASE] - | bhi ->fff_fallback - |5: // Handle numbers. - | ldrd CARG34, [RA] - | vldr d1, [RA] - | cmp RA, RB - | bhs ->fff_resd - | checktp CARG4, LJ_TISNUM - | bhs >7 - |6: - | vcmp.f64 d0, d1 - | vmrs - | add RA, RA, #8 - | vmov..fcond.f64 d0, d1 - | b <5 - |7: // Convert integer to number and continue above. - | vmov s4, CARG3 - | bhi ->fff_fallback - | vcvt.f64.s32 d1, s4 - | b <6 - | - |.else - | - | .ffunc_1 name - | checktp CARG2, LJ_TISNUM - | mov RA, #8 - | bne >4 - |1: // Handle integers. - | ldrd CARG34, [BASE, RA] - | cmp RA, RC - | bhs ->fff_restv - | checktp CARG4, LJ_TISNUM - | bne >3 - | cmp CARG1, CARG3 - | add RA, RA, #8 - | mov..cond CARG1, CARG3 - | b <1 - |3: // Convert intermediate result to number and continue below. - | bhi ->fff_fallback - | bl extern __aeabi_i2d - | ldrd CARG34, [BASE, RA] - | b >6 - | - |4: - | bhi ->fff_fallback - |5: // Handle numbers. - | ldrd CARG34, [BASE, RA] - | cmp RA, RC - | bhs ->fff_restv - | checktp CARG4, LJ_TISNUM - | bhs >7 - |6: - | bl extern __aeabi_cdcmple - | add RA, RA, #8 - | mov..fcond CARG1, CARG3 - | mov..fcond CARG2, CARG4 - | b <5 - |7: // Convert integer to number and continue above. - | bhi ->fff_fallback - | strd CARG12, TMPD - | mov CARG1, CARG3 - | bl extern __aeabi_i2d - | ldrd CARG34, TMPD - | b <6 - |.endif - |.endmacro - | - | math_minmax math_min, gt, hi - | math_minmax math_max, lt, lo - | - |//-- String library ----------------------------------------------------- - | - |.ffunc_1 string_len - | checkstr CARG2, ->fff_fallback - | ldr CARG1, STR:CARG1->len - | mvn CARG2, #~LJ_TISNUM - | b ->fff_restv - | - |.ffunc string_byte // Only handle the 1-arg case here. - | ldrd CARG12, [BASE] - | ldr PC, [BASE, FRAME_PC] - | cmp NARGS8:RC, #8 - | checktpeq CARG2, LJ_TSTR // Need exactly 1 argument. - | bne ->fff_fallback - | ldr CARG3, STR:CARG1->len - | ldrb CARG1, STR:CARG1[1] // Access is always ok (NUL at end). - | mvn CARG2, #~LJ_TISNUM - | cmp CARG3, #0 - | moveq RC, #(0+1)*8 - | movne RC, #(1+1)*8 - | strd CARG12, [BASE, #-8] - | b ->fff_res - | - |.ffunc string_char // Only handle the 1-arg case here. - | ffgccheck - | ldrd CARG12, [BASE] - | ldr PC, [BASE, FRAME_PC] - | cmp NARGS8:RC, #8 // Need exactly 1 argument. - | checktpeq CARG2, LJ_TISNUM - | bicseq CARG4, CARG1, #255 - | mov CARG3, #1 - | bne ->fff_fallback - | str CARG1, TMPD - | mov CARG2, TMPDp // Points to stack. Little-endian. - |->fff_newstr: - | // CARG2 = str, CARG3 = len. - | str BASE, L->base - | mov CARG1, L - | str PC, SAVE_PC - | bl extern lj_str_new // (lua_State *L, char *str, size_t l) - | // Returns GCstr *. - | ldr BASE, L->base - | mvn CARG2, #~LJ_TSTR - | b ->fff_restv - | - |.ffunc string_sub - | ffgccheck - | ldrd CARG12, [BASE] - | ldrd CARG34, [BASE, #16] - | cmp NARGS8:RC, #16 - | mvn RB, #0 - | beq >1 - | blo ->fff_fallback - | checktp CARG4, LJ_TISNUM - | mov RB, CARG3 - | bne ->fff_fallback - |1: - | ldrd CARG34, [BASE, #8] - | checktp CARG2, LJ_TSTR - | ldreq CARG2, STR:CARG1->len - | checktpeq CARG4, LJ_TISNUM - | bne ->fff_fallback - | // CARG1 = str, CARG2 = str->len, CARG3 = start, RB = end - | add CARG4, CARG2, #1 - | cmp CARG3, #0 // if (start < 0) start += len+1 - | addlt CARG3, CARG3, CARG4 - | cmp CARG3, #1 // if (start < 1) start = 1 - | movlt CARG3, #1 - | cmp RB, #0 // if (end < 0) end += len+1 - | addlt RB, RB, CARG4 - | bic RB, RB, RB, asr #31 // if (end < 0) end = 0 - | cmp RB, CARG2 // if (end > len) end = len - | add CARG1, STR:CARG1, #sizeof(GCstr)-1 - | movgt RB, CARG2 - | add CARG2, CARG1, CARG3 - | subs CARG3, RB, CARG3 // len = end - start - | add CARG3, CARG3, #1 // len += 1 - | bge ->fff_newstr - |->fff_emptystr: - | sub STR:CARG1, DISPATCH, #-DISPATCH_GL(strempty) - | mvn CARG2, #~LJ_TSTR - | b ->fff_restv - | - |.ffunc string_rep // Only handle the 1-char case inline. - | ffgccheck - | ldrd CARG12, [BASE] - | ldrd CARG34, [BASE, #8] - | cmp NARGS8:RC, #16 - | bne ->fff_fallback // Exactly 2 arguments - | checktp CARG2, LJ_TSTR - | checktpeq CARG4, LJ_TISNUM - | bne ->fff_fallback - | subs CARG4, CARG3, #1 - | ldr CARG2, STR:CARG1->len - | blt ->fff_emptystr // Count <= 0? - | cmp CARG2, #1 - | blo ->fff_emptystr // Zero-length string? - | bne ->fff_fallback // Fallback for > 1-char strings. - | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.sz)] - | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.buf)] - | ldr CARG1, STR:CARG1[1] - | cmp RB, CARG3 - | blo ->fff_fallback - |1: // Fill buffer with char. - | strb CARG1, [CARG2, CARG4] - | subs CARG4, CARG4, #1 - | bge <1 - | b ->fff_newstr - | - |.ffunc string_reverse - | ffgccheck - | ldrd CARG12, [BASE] - | cmp NARGS8:RC, #8 - | blo ->fff_fallback - | checkstr CARG2, ->fff_fallback - | ldr CARG3, STR:CARG1->len - | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.sz)] - | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.buf)] - | mov CARG4, CARG3 - | add CARG1, STR:CARG1, #sizeof(GCstr) - | cmp RB, CARG3 - | blo ->fff_fallback - |1: // Reverse string copy. - | ldrb RB, [CARG1], #1 - | subs CARG4, CARG4, #1 - | blt ->fff_newstr - | strb RB, [CARG2, CARG4] - | b <1 - | - |.macro ffstring_case, name, lo - | .ffunc name - | ffgccheck - | ldrd CARG12, [BASE] - | cmp NARGS8:RC, #8 - | blo ->fff_fallback - | checkstr CARG2, ->fff_fallback - | ldr CARG3, STR:CARG1->len - | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.sz)] - | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.buf)] - | mov CARG4, #0 - | add CARG1, STR:CARG1, #sizeof(GCstr) - | cmp RB, CARG3 - | blo ->fff_fallback - |1: // ASCII case conversion. - | ldrb RB, [CARG1, CARG4] - | cmp CARG4, CARG3 - | bhs ->fff_newstr - | sub RC, RB, #lo - | cmp RC, #26 - | eorlo RB, RB, #0x20 - | strb RB, [CARG2, CARG4] - | add CARG4, CARG4, #1 - | b <1 - |.endmacro - | - |ffstring_case string_lower, 65 - |ffstring_case string_upper, 97 - | - |//-- Table library ------------------------------------------------------ - | - |.ffunc_1 table_getn - | checktab CARG2, ->fff_fallback - | .IOS mov RA, BASE - | bl extern lj_tab_len // (GCtab *t) - | // Returns uint32_t (but less than 2^31). - | .IOS mov BASE, RA - | mvn CARG2, #~LJ_TISNUM - | b ->fff_restv - | - |//-- Bit library -------------------------------------------------------- - | - |// FP number to bit conversion for soft-float. Clobbers r0-r3. - |->vm_tobit_fb: - | bhi ->fff_fallback - |->vm_tobit: - | lsl RB, CARG2, #1 - | adds RB, RB, #0x00200000 - | movpl CARG1, #0 // |x| < 1? - | bxpl lr - | mvn CARG4, #0x3e0 - | subs RB, CARG4, RB, asr #21 - | bmi >1 // |x| >= 2^32? - | lsl CARG4, CARG2, #11 - | orr CARG4, CARG4, #0x80000000 - | orr CARG4, CARG4, CARG1, lsr #21 - | cmp CARG2, #0 - | lsr CARG1, CARG4, RB - | rsblt CARG1, CARG1, #0 - | bx lr - |1: - | add RB, RB, #21 - | lsr CARG4, CARG1, RB - | rsb RB, RB, #20 - | lsl CARG1, CARG2, #12 - | cmp CARG2, #0 - | orr CARG1, CARG4, CARG1, lsl RB - | rsblt CARG1, CARG1, #0 - | bx lr - | - |.macro .ffunc_bit, name - | .ffunc_1 bit_..name - | checktp CARG2, LJ_TISNUM - | blne ->vm_tobit_fb - |.endmacro - | - |.ffunc_bit tobit - | mvn CARG2, #~LJ_TISNUM - | b ->fff_restv - | - |.macro .ffunc_bit_op, name, ins - | .ffunc_bit name - | mov CARG3, CARG1 - | mov RA, #8 - |1: - | ldrd CARG12, [BASE, RA] - | cmp RA, NARGS8:RC - | add RA, RA, #8 - | bge >2 - | checktp CARG2, LJ_TISNUM - | blne ->vm_tobit_fb - | ins CARG3, CARG3, CARG1 - | b <1 - |.endmacro - | - |.ffunc_bit_op band, and - |.ffunc_bit_op bor, orr - |.ffunc_bit_op bxor, eor - | - |2: - | mvn CARG4, #~LJ_TISNUM - | ldr PC, [BASE, FRAME_PC] - | strd CARG34, [BASE, #-8] - | b ->fff_res1 - | - |.ffunc_bit bswap - | eor CARG3, CARG1, CARG1, ror #16 - | bic CARG3, CARG3, #0x00ff0000 - | ror CARG1, CARG1, #8 - | mvn CARG2, #~LJ_TISNUM - | eor CARG1, CARG1, CARG3, lsr #8 - | b ->fff_restv - | - |.ffunc_bit bnot - | mvn CARG1, CARG1 - | mvn CARG2, #~LJ_TISNUM - | b ->fff_restv - | - |.macro .ffunc_bit_sh, name, ins, shmod - | .ffunc bit_..name - | ldrd CARG12, [BASE, #8] - | cmp NARGS8:RC, #16 - | blo ->fff_fallback - | checktp CARG2, LJ_TISNUM - | blne ->vm_tobit_fb - |.if shmod == 0 - | and RA, CARG1, #31 - |.else - | rsb RA, CARG1, #0 - |.endif - | ldrd CARG12, [BASE] - | checktp CARG2, LJ_TISNUM - | blne ->vm_tobit_fb - | ins CARG1, CARG1, RA - | mvn CARG2, #~LJ_TISNUM - | b ->fff_restv - |.endmacro - | - |.ffunc_bit_sh lshift, lsl, 0 - |.ffunc_bit_sh rshift, lsr, 0 - |.ffunc_bit_sh arshift, asr, 0 - |.ffunc_bit_sh rol, ror, 1 - |.ffunc_bit_sh ror, ror, 0 - | - |//----------------------------------------------------------------------- - | - |->fff_fallback: // Call fast function fallback handler. - | // BASE = new base, RC = nargs*8 - | ldr CARG3, [BASE, FRAME_FUNC] - | ldr CARG2, L->maxstack - | add CARG1, BASE, NARGS8:RC - | ldr PC, [BASE, FRAME_PC] // Fallback may overwrite PC. - | str CARG1, L->top - | ldr CARG3, CFUNC:CARG3->f - | str BASE, L->base - | add CARG1, CARG1, #8*LUA_MINSTACK - | str PC, SAVE_PC // Redundant (but a defined value). - | cmp CARG1, CARG2 - | mov CARG1, L - | bhi >5 // Need to grow stack. - | blx CARG3 // (lua_State *L) - | // Either throws an error, or recovers and returns -1, 0 or nresults+1. - | ldr BASE, L->base - | cmp CRET1, #0 - | lsl RC, CRET1, #3 - | sub RA, BASE, #8 - | bgt ->fff_res // Returned nresults+1? - |1: // Returned 0 or -1: retry fast path. - | ldr CARG1, L->top - | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] - | sub NARGS8:RC, CARG1, BASE - | bne ->vm_call_tail // Returned -1? - | ins_callt // Returned 0: retry fast path. - | - |// Reconstruct previous base for vmeta_call during tailcall. - |->vm_call_tail: - | ands CARG1, PC, #FRAME_TYPE - | bic CARG2, PC, #FRAME_TYPEP - | ldreq INS, [PC, #-4] - | andeq CARG2, MASKR8, INS, lsr #5 // Conditional decode_RA8. - | addeq CARG2, CARG2, #8 - | sub RB, BASE, CARG2 - | b ->vm_call_dispatch // Resolve again for tailcall. - | - |5: // Grow stack for fallback handler. - | mov CARG2, #LUA_MINSTACK - | bl extern lj_state_growstack // (lua_State *L, int n) - | ldr BASE, L->base - | cmp CARG1, CARG1 // Set zero-flag to force retry. - | b <1 - | - |->fff_gcstep: // Call GC step function. - | // BASE = new base, RC = nargs*8 - | mov RA, lr - | str BASE, L->base - | add CARG2, BASE, NARGS8:RC - | str PC, SAVE_PC // Redundant (but a defined value). - | str CARG2, L->top - | mov CARG1, L - | bl extern lj_gc_step // (lua_State *L) - | ldr BASE, L->base - | mov lr, RA // Help return address predictor. - | ldr CFUNC:CARG3, [BASE, FRAME_FUNC] - | bx lr - | - |//----------------------------------------------------------------------- - |//-- Special dispatch targets ------------------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_record: // Dispatch target for recording phase. - |.if JIT - | ldrb CARG1, [DISPATCH, #DISPATCH_GL(hookmask)] - | tst CARG1, #HOOK_VMEVENT // No recording while in vmevent. - | bne >5 - | // Decrement the hookcount for consistency, but always do the call. - | ldr CARG2, [DISPATCH, #DISPATCH_GL(hookcount)] - | tst CARG1, #HOOK_ACTIVE - | bne >1 - | sub CARG2, CARG2, #1 - | tst CARG1, #LUA_MASKLINE|LUA_MASKCOUNT - | strne CARG2, [DISPATCH, #DISPATCH_GL(hookcount)] - | b >1 - |.endif - | - |->vm_rethook: // Dispatch target for return hooks. - | ldrb CARG1, [DISPATCH, #DISPATCH_GL(hookmask)] - | tst CARG1, #HOOK_ACTIVE // Hook already active? - | beq >1 - |5: // Re-dispatch to static ins. - | decode_OP OP, INS - | add OP, DISPATCH, OP, lsl #2 - | ldr pc, [OP, #GG_DISP2STATIC] - | - |->vm_inshook: // Dispatch target for instr/line hooks. - | ldrb CARG1, [DISPATCH, #DISPATCH_GL(hookmask)] - | ldr CARG2, [DISPATCH, #DISPATCH_GL(hookcount)] - | tst CARG1, #HOOK_ACTIVE // Hook already active? - | bne <5 - | tst CARG1, #LUA_MASKLINE|LUA_MASKCOUNT - | beq <5 - | subs CARG2, CARG2, #1 - | str CARG2, [DISPATCH, #DISPATCH_GL(hookcount)] - | beq >1 - | tst CARG1, #LUA_MASKLINE - | beq <5 - |1: - | mov CARG1, L - | str BASE, L->base - | mov CARG2, PC - | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. - | bl extern lj_dispatch_ins // (lua_State *L, const BCIns *pc) - |3: - | ldr BASE, L->base - |4: // Re-dispatch to static ins. - | ldrb OP, [PC, #-4] - | ldr INS, [PC, #-4] - | add OP, DISPATCH, OP, lsl #2 - | ldr OP, [OP, #GG_DISP2STATIC] - | decode_RA8 RA, INS - | decode_RD RC, INS - | bx OP - | - |->cont_hook: // Continue from hook yield. - | ldr CARG1, [CARG4, #-24] - | add PC, PC, #4 - | str CARG1, SAVE_MULTRES // Restore MULTRES for *M ins. - | b <4 - | - |->vm_hotloop: // Hot loop counter underflow. - |.if JIT - | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Same as curr_topL(L). - | sub CARG1, DISPATCH, #-GG_DISP2J - | str PC, SAVE_PC - | ldr CARG3, LFUNC:CARG3->field_pc - | mov CARG2, PC - | str L, [DISPATCH, #DISPATCH_J(L)] - | ldrb CARG3, [CARG3, #PC2PROTO(framesize)] - | str BASE, L->base - | add CARG3, BASE, CARG3, lsl #3 - | str CARG3, L->top - | bl extern lj_trace_hot // (jit_State *J, const BCIns *pc) - | b <3 - |.endif - | - |->vm_callhook: // Dispatch target for call hooks. - | mov CARG2, PC - |.if JIT - | b >1 - |.endif - | - |->vm_hotcall: // Hot call counter underflow. - |.if JIT - | orr CARG2, PC, #1 - |1: - |.endif - | add CARG4, BASE, RC - | str PC, SAVE_PC - | mov CARG1, L - | str BASE, L->base - | sub RA, RA, BASE - | str CARG4, L->top - | bl extern lj_dispatch_call // (lua_State *L, const BCIns *pc) - | // Returns ASMFunction. - | ldr BASE, L->base - | ldr CARG4, L->top - | mov CARG2, #0 - | add RA, BASE, RA - | sub NARGS8:RC, CARG4, BASE - | str CARG2, SAVE_PC // Invalidate for subsequent line hook. - | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] - | ldr INS, [PC, #-4] - | bx CRET1 - | - |//----------------------------------------------------------------------- - |//-- Trace exit handler ------------------------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_exit_handler: - |.if JIT - | sub sp, sp, #12 - | push {r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12} - | ldr CARG1, [sp, #64] // Load original value of lr. - | ldr DISPATCH, [lr] // Load DISPATCH. - | add CARG3, sp, #64 // Recompute original value of sp. - | mv_vmstate CARG4, EXIT - | str CARG3, [sp, #52] // Store sp in RID_SP - | st_vmstate CARG4 - | ldr CARG2, [CARG1, #-4]! // Get exit instruction. - | str CARG1, [sp, #56] // Store exit pc in RID_LR and RID_PC. - | str CARG1, [sp, #60] - |.if FPU - | vpush {d0-d15} - |.endif - | lsl CARG2, CARG2, #8 - | add CARG1, CARG1, CARG2, asr #6 - | ldr CARG2, [lr, #4] // Load exit stub group offset. - | sub CARG1, CARG1, lr - | ldr L, [DISPATCH, #DISPATCH_GL(jit_L)] - | add CARG1, CARG2, CARG1, lsr #2 // Compute exit number. - | ldr BASE, [DISPATCH, #DISPATCH_GL(jit_base)] - | str CARG1, [DISPATCH, #DISPATCH_J(exitno)] - | mov CARG4, #0 - | str L, [DISPATCH, #DISPATCH_J(L)] - | str BASE, L->base - | str CARG4, [DISPATCH, #DISPATCH_GL(jit_L)] - | sub CARG1, DISPATCH, #-GG_DISP2J - | mov CARG2, sp - | bl extern lj_trace_exit // (jit_State *J, ExitState *ex) - | // Returns MULTRES (unscaled) or negated error code. - | ldr CARG2, L->cframe - | ldr BASE, L->base - | bic CARG2, CARG2, #~CFRAME_RAWMASK // Use two steps: bic sp is deprecated. - | mov sp, CARG2 - | ldr PC, SAVE_PC // Get SAVE_PC. - | str L, SAVE_L // Set SAVE_L (on-trace resume/yield). - | b >1 - |.endif - |->vm_exit_interp: - | // CARG1 = MULTRES or negated error code, BASE, PC and DISPATCH set. - |.if JIT - | ldr L, SAVE_L - |1: - | cmp CARG1, #0 - | blt >3 // Check for error from exit. - | lsl RC, CARG1, #3 - | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] - | str RC, SAVE_MULTRES - | mov CARG3, #0 - | ldr CARG2, LFUNC:CARG2->field_pc - | str CARG3, [DISPATCH, #DISPATCH_GL(jit_L)] - | mv_vmstate CARG4, INTERP - | ldr KBASE, [CARG2, #PC2PROTO(k)] - | // Modified copy of ins_next which handles function header dispatch, too. - | ldrb OP, [PC] - | mov MASKR8, #255 - | ldr INS, [PC], #4 - | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. - | st_vmstate CARG4 - | cmp OP, #BC_FUNCF // Function header? - | ldr OP, [DISPATCH, OP, lsl #2] - | decode_RA8 RA, INS - | lsrlo RC, INS, #16 // No: Decode operands A*8 and D. - | subhs RC, RC, #8 - | addhs RA, RA, BASE // Yes: RA = BASE+framesize*8, RC = nargs*8 - | bx OP - | - |3: // Rethrow error from the right C frame. - | rsb CARG2, CARG1, #0 - | mov CARG1, L - | bl extern lj_err_throw // (lua_State *L, int errcode) - |.endif - | - |//----------------------------------------------------------------------- - |//-- Math helper functions ---------------------------------------------- - |//----------------------------------------------------------------------- - | - |// FP value rounding. Called from JIT code. - |// - |// double lj_vm_floor/ceil/trunc(double x); - |.macro vm_round, func, hf - |.if hf == 1 - | vmov CARG1, CARG2, d0 - |.endif - | lsl CARG3, CARG2, #1 - | adds RB, CARG3, #0x00200000 - | bpl >2 // |x| < 1? - | mvn CARG4, #0x3cc - | subs RB, CARG4, RB, asr #21 // 2^0: RB = 51, 2^51: RB = 0. - | bxlo lr // |x| >= 2^52: done. - | mvn CARG4, #1 - | bic CARG3, CARG1, CARG4, lsl RB // ztest = lo & ~lomask - | and CARG1, CARG1, CARG4, lsl RB // lo &= lomask - | subs RB, RB, #32 - | bicpl CARG4, CARG2, CARG4, lsl RB // |x| <= 2^20: ztest |= hi & ~himask - | orrpl CARG3, CARG3, CARG4 - | mvnpl CARG4, #1 - | andpl CARG2, CARG2, CARG4, lsl RB // |x| <= 2^20: hi &= himask - |.if "func" == "floor" - | tst CARG3, CARG2, asr #31 // iszero = ((ztest & signmask) == 0) - |.else - | bics CARG3, CARG3, CARG2, asr #31 // iszero = ((ztest & ~signmask) == 0) - |.endif - |.if hf == 1 - | vmoveq d0, CARG1, CARG2 - |.endif - | bxeq lr // iszero: done. - | mvn CARG4, #1 - | cmp RB, #0 - | lslpl CARG3, CARG4, RB - | mvnmi CARG3, #0 - | add RB, RB, #32 - | subs CARG1, CARG1, CARG4, lsl RB // lo = lo-lomask - | sbc CARG2, CARG2, CARG3 // hi = hi-himask+carry - |.if hf == 1 - | vmov d0, CARG1, CARG2 - |.endif - | bx lr - | - |2: // |x| < 1: - | bxcs lr // |x| is not finite. - | orr CARG3, CARG3, CARG1 // ztest = (2*hi) | lo - |.if "func" == "floor" - | tst CARG3, CARG2, asr #31 // iszero = ((ztest & signmask) == 0) - |.else - | bics CARG3, CARG3, CARG2, asr #31 // iszero = ((ztest & ~signmask) == 0) - |.endif - | mov CARG1, #0 // lo = 0 - | and CARG2, CARG2, #0x80000000 - | ldrne CARG4, <9 // hi = sign(x) | (iszero ? 0.0 : 1.0) - | orrne CARG2, CARG2, CARG4 - |.if hf == 1 - | vmov d0, CARG1, CARG2 - |.endif - | bx lr - |.endmacro - | - |9: - | .long 0x3ff00000 // hiword(+1.0) - | - |->vm_floor: - |.if HFABI - | vm_round floor, 1 - |.endif - |->vm_floor_sf: - | vm_round floor, 0 - | - |->vm_ceil: - |.if HFABI - | vm_round ceil, 1 - |.endif - |->vm_ceil_sf: - | vm_round ceil, 0 - | - |.macro vm_trunc, hf - |.if JIT - |.if hf == 1 - | vmov CARG1, CARG2, d0 - |.endif - | lsl CARG3, CARG2, #1 - | adds RB, CARG3, #0x00200000 - | andpl CARG2, CARG2, #0x80000000 // |x| < 1? hi = sign(x), lo = 0. - | movpl CARG1, #0 - |.if hf == 1 - | vmovpl d0, CARG1, CARG2 - |.endif - | bxpl lr - | mvn CARG4, #0x3cc - | subs RB, CARG4, RB, asr #21 // 2^0: RB = 51, 2^51: RB = 0. - | bxlo lr // |x| >= 2^52: already done. - | mvn CARG4, #1 - | and CARG1, CARG1, CARG4, lsl RB // lo &= lomask - | subs RB, RB, #32 - | andpl CARG2, CARG2, CARG4, lsl RB // |x| <= 2^20: hi &= himask - |.if hf == 1 - | vmov d0, CARG1, CARG2 - |.endif - | bx lr - |.endif - |.endmacro - | - |->vm_trunc: - |.if HFABI - | vm_trunc 1 - |.endif - |->vm_trunc_sf: - | vm_trunc 0 - | - | // double lj_vm_mod(double dividend, double divisor); - |->vm_mod: - |.if FPU - | // Special calling convention. Also, RC (r11) is not preserved. - | vdiv.f64 d0, d6, d7 - | mov RC, lr - | vmov CARG1, CARG2, d0 - | bl ->vm_floor_sf - | vmov d0, CARG1, CARG2 - | vmul.f64 d0, d0, d7 - | mov lr, RC - | vsub.f64 d6, d6, d0 - | bx lr - |.else - | push {r0, r1, r2, r3, r4, lr} - | bl extern __aeabi_ddiv - | bl ->vm_floor_sf - | ldrd CARG34, [sp, #8] - | bl extern __aeabi_dmul - | ldrd CARG34, [sp] - | eor CARG2, CARG2, #0x80000000 - | bl extern __aeabi_dadd - | add sp, sp, #20 - | pop {pc} - |.endif - | - | // int lj_vm_modi(int dividend, int divisor); - |->vm_modi: - | ands RB, CARG1, #0x80000000 - | rsbmi CARG1, CARG1, #0 // a = |dividend| - | eor RB, RB, CARG2, asr #1 // Keep signdiff and sign(divisor). - | cmp CARG2, #0 - | rsbmi CARG2, CARG2, #0 // b = |divisor| - | subs CARG4, CARG2, #1 - | cmpne CARG1, CARG2 - | moveq CARG1, #0 // if (b == 1 || a == b) a = 0 - | tsthi CARG2, CARG4 - | andeq CARG1, CARG1, CARG4 // else if ((b & (b-1)) == 0) a &= b-1 - | bls >1 - | // Use repeated subtraction to get the remainder. - | clz CARG3, CARG1 - | clz CARG4, CARG2 - | sub CARG4, CARG4, CARG3 - | rsbs CARG3, CARG4, #31 // entry = (31-(clz(b)-clz(a)))*8 - | addne pc, pc, CARG3, lsl #3 // Duff's device. - | nop - { - int i; - for (i = 31; i >= 0; i--) { - | cmp CARG1, CARG2, lsl #i - | subhs CARG1, CARG1, CARG2, lsl #i - } - } - |1: - | cmp CARG1, #0 - | cmpne RB, #0 - | submi CARG1, CARG1, CARG2 // if (y != 0 && signdiff) y = y - b - | eors CARG2, CARG1, RB, lsl #1 - | rsbmi CARG1, CARG1, #0 // if (sign(divisor) != sign(y)) y = -y - | bx lr - | - |//----------------------------------------------------------------------- - |//-- Miscellaneous functions -------------------------------------------- - |//----------------------------------------------------------------------- - | - |//----------------------------------------------------------------------- - |//-- FFI helper functions ----------------------------------------------- - |//----------------------------------------------------------------------- - | - |// Handler for callback functions. - |// Saveregs already performed. Callback slot number in [sp], g in r12. - |->vm_ffi_callback: - |.if FFI - |.type CTSTATE, CTState, PC - | ldr CTSTATE, GL:r12->ctype_state - | add DISPATCH, r12, #GG_G2DISP - |.if FPU - | str r4, SAVE_R4 - | add r4, sp, CFRAME_SPACE+4+8*8 - | vstmdb r4!, {d8-d15} - |.endif - |.if HFABI - | add r12, CTSTATE, #offsetof(CTState, cb.fpr[8]) - |.endif - | strd CARG34, CTSTATE->cb.gpr[2] - | strd CARG12, CTSTATE->cb.gpr[0] - |.if HFABI - | vstmdb r12!, {d0-d7} - |.endif - | ldr CARG4, [sp] - | add CARG3, sp, #CFRAME_SIZE - | mov CARG1, CTSTATE - | lsr CARG4, CARG4, #3 - | str CARG3, CTSTATE->cb.stack - | mov CARG2, sp - | str CARG4, CTSTATE->cb.slot - | str CTSTATE, SAVE_PC // Any value outside of bytecode is ok. - | bl extern lj_ccallback_enter // (CTState *cts, void *cf) - | // Returns lua_State *. - | ldr BASE, L:CRET1->base - | mv_vmstate CARG2, INTERP - | ldr RC, L:CRET1->top - | mov MASKR8, #255 - | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] - | mov L, CRET1 - | sub RC, RC, BASE - | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. - | st_vmstate CARG2 - | ins_callt - |.endif - | - |->cont_ffi_callback: // Return from FFI callback. - |.if FFI - | ldr CTSTATE, [DISPATCH, #DISPATCH_GL(ctype_state)] - | str BASE, L->base - | str CARG4, L->top - | str L, CTSTATE->L - | mov CARG1, CTSTATE - | mov CARG2, RA - | bl extern lj_ccallback_leave // (CTState *cts, TValue *o) - | ldrd CARG12, CTSTATE->cb.gpr[0] - |.if HFABI - | vldr d0, CTSTATE->cb.fpr[0] - |.endif - | b ->vm_leave_unw - |.endif - | - |->vm_ffi_call: // Call C function via FFI. - | // Caveat: needs special frame unwinding, see below. - |.if FFI - | .type CCSTATE, CCallState, r4 - | push {CCSTATE, r5, r11, lr} - | mov CCSTATE, CARG1 - | ldr CARG1, CCSTATE:CARG1->spadj - | ldrb CARG2, CCSTATE->nsp - | add CARG3, CCSTATE, #offsetof(CCallState, stack) - |.if HFABI - | add RB, CCSTATE, #offsetof(CCallState, fpr[0]) - |.endif - | mov r11, sp - | sub sp, sp, CARG1 // Readjust stack. - | subs CARG2, CARG2, #1 - |.if HFABI - | vldm RB, {d0-d7} - |.endif - | ldr RB, CCSTATE->func - | bmi >2 - |1: // Copy stack slots. - | ldr CARG4, [CARG3, CARG2, lsl #2] - | str CARG4, [sp, CARG2, lsl #2] - | subs CARG2, CARG2, #1 - | bpl <1 - |2: - | ldrd CARG12, CCSTATE->gpr[0] - | ldrd CARG34, CCSTATE->gpr[2] - | blx RB - | mov sp, r11 - |.if HFABI - | add r12, CCSTATE, #offsetof(CCallState, fpr[4]) - |.endif - | strd CRET1, CCSTATE->gpr[0] - |.if HFABI - | vstmdb r12!, {d0-d3} - |.endif - | pop {CCSTATE, r5, r11, pc} - |.endif - |// Note: vm_ffi_call must be the last function in this object file! - | - |//----------------------------------------------------------------------- -} - -/* Generate the code for a single instruction. */ -static void build_ins(BuildCtx *ctx, BCOp op, int defop) -{ - int vk = 0; - |=>defop: - - switch (op) { - - /* -- Comparison ops ---------------------------------------------------- */ - - /* Remember: all ops branch for a true comparison, fall through otherwise. */ - - case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: - | // RA = src1*8, RC = src2, JMP with RC = target - | lsl RC, RC, #3 - | ldrd CARG12, [RA, BASE]! - | ldrh RB, [PC, #2] - | ldrd CARG34, [RC, BASE]! - | add PC, PC, #4 - | add RB, PC, RB, lsl #2 - | checktp CARG2, LJ_TISNUM - | bne >3 - | checktp CARG4, LJ_TISNUM - | bne >4 - | cmp CARG1, CARG3 - if (op == BC_ISLT) { - | sublt PC, RB, #0x20000 - } else if (op == BC_ISGE) { - | subge PC, RB, #0x20000 - } else if (op == BC_ISLE) { - | suble PC, RB, #0x20000 - } else { - | subgt PC, RB, #0x20000 - } - |1: - | ins_next - | - |3: // CARG12 is not an integer. - |.if FPU - | vldr d0, [RA] - | bhi ->vmeta_comp - | // d0 is a number. - | checktp CARG4, LJ_TISNUM - | vldr d1, [RC] - | blo >5 - | bhi ->vmeta_comp - | // d0 is a number, CARG3 is an integer. - | vmov s4, CARG3 - | vcvt.f64.s32 d1, s4 - | b >5 - |4: // CARG1 is an integer, CARG34 is not an integer. - | vldr d1, [RC] - | bhi ->vmeta_comp - | // CARG1 is an integer, d1 is a number. - | vmov s4, CARG1 - | vcvt.f64.s32 d0, s4 - |5: // d0 and d1 are numbers. - | vcmp.f64 d0, d1 - | vmrs - | // To preserve NaN semantics GE/GT branch on unordered, but LT/LE don't. - if (op == BC_ISLT) { - | sublo PC, RB, #0x20000 - } else if (op == BC_ISGE) { - | subhs PC, RB, #0x20000 - } else if (op == BC_ISLE) { - | subls PC, RB, #0x20000 - } else { - | subhi PC, RB, #0x20000 - } - | b <1 - |.else - | bhi ->vmeta_comp - | // CARG12 is a number. - | checktp CARG4, LJ_TISNUM - | movlo RA, RB // Save RB. - | blo >5 - | bhi ->vmeta_comp - | // CARG12 is a number, CARG3 is an integer. - | mov CARG1, CARG3 - | mov RC, RA - | mov RA, RB // Save RB. - | bl extern __aeabi_i2d - | mov CARG3, CARG1 - | mov CARG4, CARG2 - | ldrd CARG12, [RC] // Restore first operand. - | b >5 - |4: // CARG1 is an integer, CARG34 is not an integer. - | bhi ->vmeta_comp - | // CARG1 is an integer, CARG34 is a number. - | mov RA, RB // Save RB. - | bl extern __aeabi_i2d - | ldrd CARG34, [RC] // Restore second operand. - |5: // CARG12 and CARG34 are numbers. - | bl extern __aeabi_cdcmple - | // To preserve NaN semantics GE/GT branch on unordered, but LT/LE don't. - if (op == BC_ISLT) { - | sublo PC, RA, #0x20000 - } else if (op == BC_ISGE) { - | subhs PC, RA, #0x20000 - } else if (op == BC_ISLE) { - | subls PC, RA, #0x20000 - } else { - | subhi PC, RA, #0x20000 - } - | b <1 - |.endif - break; - - case BC_ISEQV: case BC_ISNEV: - vk = op == BC_ISEQV; - | // RA = src1*8, RC = src2, JMP with RC = target - | lsl RC, RC, #3 - | ldrd CARG12, [RA, BASE]! - | ldrh RB, [PC, #2] - | ldrd CARG34, [RC, BASE]! - | add PC, PC, #4 - | add RB, PC, RB, lsl #2 - | checktp CARG2, LJ_TISNUM - | cmnls CARG4, #-LJ_TISNUM - if (vk) { - | bls ->BC_ISEQN_Z - } else { - | bls ->BC_ISNEN_Z - } - | // Either or both types are not numbers. - |.if FFI - | checktp CARG2, LJ_TCDATA - | checktpne CARG4, LJ_TCDATA - | beq ->vmeta_equal_cd - |.endif - | cmp CARG2, CARG4 // Compare types. - | bne >2 // Not the same type? - | checktp CARG2, LJ_TISPRI - | bhs >1 // Same type and primitive type? - | - | // Same types and not a primitive type. Compare GCobj or pvalue. - | cmp CARG1, CARG3 - if (vk) { - | bne >3 // Different GCobjs or pvalues? - |1: // Branch if same. - | sub PC, RB, #0x20000 - |2: // Different. - | ins_next - |3: - | checktp CARG2, LJ_TISTABUD - | bhi <2 // Different objects and not table/ud? - } else { - | beq >1 // Same GCobjs or pvalues? - | checktp CARG2, LJ_TISTABUD - | bhi >2 // Different objects and not table/ud? - } - | // Different tables or userdatas. Need to check __eq metamethod. - | // Field metatable must be at same offset for GCtab and GCudata! - | ldr TAB:RA, TAB:CARG1->metatable - | cmp TAB:RA, #0 - if (vk) { - | beq <2 // No metatable? - } else { - | beq >2 // No metatable? - } - | ldrb RA, TAB:RA->nomm - | mov CARG4, #1-vk // ne = 0 or 1. - | mov CARG2, CARG1 - | tst RA, #1<vmeta_equal // 'no __eq' flag not set? - if (vk) { - | b <2 - } else { - |2: // Branch if different. - | sub PC, RB, #0x20000 - |1: // Same. - | ins_next - } - break; - - case BC_ISEQS: case BC_ISNES: - vk = op == BC_ISEQS; - | // RA = src*8, RC = str_const (~), JMP with RC = target - | mvn RC, RC - | ldrd CARG12, [BASE, RA] - | ldrh RB, [PC, #2] - | ldr STR:CARG3, [KBASE, RC, lsl #2] - | add PC, PC, #4 - | add RB, PC, RB, lsl #2 - | checktp CARG2, LJ_TSTR - |.if FFI - | bne >7 - | cmp CARG1, CARG3 - |.else - | cmpeq CARG1, CARG3 - |.endif - if (vk) { - | subeq PC, RB, #0x20000 - |1: - } else { - |1: - | subne PC, RB, #0x20000 - } - | ins_next - | - |.if FFI - |7: - | checktp CARG2, LJ_TCDATA - | bne <1 - | b ->vmeta_equal_cd - |.endif - break; - - case BC_ISEQN: case BC_ISNEN: - vk = op == BC_ISEQN; - | // RA = src*8, RC = num_const (~), JMP with RC = target - | lsl RC, RC, #3 - | ldrd CARG12, [RA, BASE]! - | ldrh RB, [PC, #2] - | ldrd CARG34, [RC, KBASE]! - | add PC, PC, #4 - | add RB, PC, RB, lsl #2 - if (vk) { - |->BC_ISEQN_Z: - } else { - |->BC_ISNEN_Z: - } - | checktp CARG2, LJ_TISNUM - | bne >3 - | checktp CARG4, LJ_TISNUM - | bne >4 - | cmp CARG1, CARG3 - if (vk) { - | subeq PC, RB, #0x20000 - |1: - } else { - |1: - | subne PC, RB, #0x20000 - } - |2: - | ins_next - | - |3: // CARG12 is not an integer. - |.if FFI - | bhi >7 - |.else - if (!vk) { - | subhi PC, RB, #0x20000 - } - | bhi <2 - |.endif - |.if FPU - | checktp CARG4, LJ_TISNUM - | vmov s4, CARG3 - | vldr d0, [RA] - | vldrlo d1, [RC] - | vcvths.f64.s32 d1, s4 - | b >5 - |4: // CARG1 is an integer, d1 is a number. - | vmov s4, CARG1 - | vldr d1, [RC] - | vcvt.f64.s32 d0, s4 - |5: // d0 and d1 are numbers. - | vcmp.f64 d0, d1 - | vmrs - if (vk) { - | subeq PC, RB, #0x20000 - } else { - | subne PC, RB, #0x20000 - } - | b <2 - |.else - | // CARG12 is a number. - | checktp CARG4, LJ_TISNUM - | movlo RA, RB // Save RB. - | blo >5 - | // CARG12 is a number, CARG3 is an integer. - | mov CARG1, CARG3 - | mov RC, RA - |4: // CARG1 is an integer, CARG34 is a number. - | mov RA, RB // Save RB. - | bl extern __aeabi_i2d - | ldrd CARG34, [RC] // Restore other operand. - |5: // CARG12 and CARG34 are numbers. - | bl extern __aeabi_cdcmpeq - if (vk) { - | subeq PC, RA, #0x20000 - } else { - | subne PC, RA, #0x20000 - } - | b <2 - |.endif - | - |.if FFI - |7: - | checktp CARG2, LJ_TCDATA - | bne <1 - | b ->vmeta_equal_cd - |.endif - break; - - case BC_ISEQP: case BC_ISNEP: - vk = op == BC_ISEQP; - | // RA = src*8, RC = primitive_type (~), JMP with RC = target - | ldrd CARG12, [BASE, RA] - | ldrh RB, [PC, #2] - | add PC, PC, #4 - | mvn RC, RC - | add RB, PC, RB, lsl #2 - |.if FFI - | checktp CARG2, LJ_TCDATA - | beq ->vmeta_equal_cd - |.endif - | cmp CARG2, RC - if (vk) { - | subeq PC, RB, #0x20000 - } else { - | subne PC, RB, #0x20000 - } - | ins_next - break; - - /* -- Unary test and copy ops ------------------------------------------- */ - - case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: - | // RA = dst*8 or unused, RC = src, JMP with RC = target - | add RC, BASE, RC, lsl #3 - | ldrh RB, [PC, #2] - | ldrd CARG12, [RC] - | add PC, PC, #4 - | add RB, PC, RB, lsl #2 - | checktp CARG2, LJ_TTRUE - if (op == BC_ISTC || op == BC_IST) { - | subls PC, RB, #0x20000 - if (op == BC_ISTC) { - | strdls CARG12, [BASE, RA] - } - } else { - | subhi PC, RB, #0x20000 - if (op == BC_ISFC) { - | strdhi CARG12, [BASE, RA] - } - } - | ins_next - break; - - /* -- Unary ops --------------------------------------------------------- */ - - case BC_MOV: - | // RA = dst*8, RC = src - | lsl RC, RC, #3 - | ins_next1 - | ldrd CARG12, [BASE, RC] - | ins_next2 - | strd CARG12, [BASE, RA] - | ins_next3 - break; - case BC_NOT: - | // RA = dst*8, RC = src - | add RC, BASE, RC, lsl #3 - | ins_next1 - | ldr CARG1, [RC, #4] - | add RA, BASE, RA - | ins_next2 - | checktp CARG1, LJ_TTRUE - | mvnls CARG2, #~LJ_TFALSE - | mvnhi CARG2, #~LJ_TTRUE - | str CARG2, [RA, #4] - | ins_next3 - break; - case BC_UNM: - | // RA = dst*8, RC = src - | lsl RC, RC, #3 - | ldrd CARG12, [BASE, RC] - | ins_next1 - | ins_next2 - | checktp CARG2, LJ_TISNUM - | bhi ->vmeta_unm - | eorne CARG2, CARG2, #0x80000000 - | bne >5 - | rsbseq CARG1, CARG1, #0 - | ldrdvs CARG12, >9 - |5: - | strd CARG12, [BASE, RA] - | ins_next3 - | - |.align 8 - |9: - | .long 0x00000000, 0x41e00000 // 2^31. - break; - case BC_LEN: - | // RA = dst*8, RC = src - | lsl RC, RC, #3 - | ldrd CARG12, [BASE, RC] - | checkstr CARG2, >2 - | ldr CARG1, STR:CARG1->len - |1: - | mvn CARG2, #~LJ_TISNUM - | ins_next1 - | ins_next2 - | strd CARG12, [BASE, RA] - | ins_next3 - |2: - | checktab CARG2, ->vmeta_len -#if LJ_52 - | ldr TAB:CARG3, TAB:CARG1->metatable - | cmp TAB:CARG3, #0 - | bne >9 - |3: -#endif - |->BC_LEN_Z: - | .IOS mov RC, BASE - | bl extern lj_tab_len // (GCtab *t) - | // Returns uint32_t (but less than 2^31). - | .IOS mov BASE, RC - | b <1 -#if LJ_52 - |9: - | ldrb CARG4, TAB:CARG3->nomm - | tst CARG4, #1<vmeta_len -#endif - break; - - /* -- Binary ops -------------------------------------------------------- */ - - |.macro ins_arithcheck, cond, ncond, target - ||if (vk == 1) { - | cmn CARG4, #-LJ_TISNUM - | cmn..cond CARG2, #-LJ_TISNUM - ||} else { - | cmn CARG2, #-LJ_TISNUM - | cmn..cond CARG4, #-LJ_TISNUM - ||} - | b..ncond target - |.endmacro - |.macro ins_arithcheck_int, target - | ins_arithcheck eq, ne, target - |.endmacro - |.macro ins_arithcheck_num, target - | ins_arithcheck lo, hs, target - |.endmacro - | - |.macro ins_arithpre - | decode_RB8 RB, INS - | decode_RC8 RC, INS - | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 - ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); - ||switch (vk) { - ||case 0: - | .if FPU - | ldrd CARG12, [RB, BASE]! - | ldrd CARG34, [RC, KBASE]! - | .else - | ldrd CARG12, [BASE, RB] - | ldrd CARG34, [KBASE, RC] - | .endif - || break; - ||case 1: - | .if FPU - | ldrd CARG34, [RB, BASE]! - | ldrd CARG12, [RC, KBASE]! - | .else - | ldrd CARG34, [BASE, RB] - | ldrd CARG12, [KBASE, RC] - | .endif - || break; - ||default: - | .if FPU - | ldrd CARG12, [RB, BASE]! - | ldrd CARG34, [RC, BASE]! - | .else - | ldrd CARG12, [BASE, RB] - | ldrd CARG34, [BASE, RC] - | .endif - || break; - ||} - |.endmacro - | - |.macro ins_arithpre_fpu, reg1, reg2 - |.if FPU - ||if (vk == 1) { - | vldr reg2, [RB] - | vldr reg1, [RC] - ||} else { - | vldr reg1, [RB] - | vldr reg2, [RC] - ||} - |.endif - |.endmacro - | - |.macro ins_arithpost_fpu, reg - | ins_next1 - | add RA, BASE, RA - | ins_next2 - | vstr reg, [RA] - | ins_next3 - |.endmacro - | - |.macro ins_arithfallback, ins - ||switch (vk) { - ||case 0: - | ins ->vmeta_arith_vn - || break; - ||case 1: - | ins ->vmeta_arith_nv - || break; - ||default: - | ins ->vmeta_arith_vv - || break; - ||} - |.endmacro - | - |.macro ins_arithdn, intins, fpins, fpcall - | ins_arithpre - |.if "intins" ~= "vm_modi" and not FPU - | ins_next1 - |.endif - | ins_arithcheck_int >5 - |.if "intins" == "smull" - | smull CARG1, RC, CARG3, CARG1 - | cmp RC, CARG1, asr #31 - | ins_arithfallback bne - |.elif "intins" == "vm_modi" - | movs CARG2, CARG3 - | ins_arithfallback beq - | bl ->vm_modi - | mvn CARG2, #~LJ_TISNUM - |.else - | intins CARG1, CARG1, CARG3 - | ins_arithfallback bvs - |.endif - |4: - |.if "intins" == "vm_modi" or FPU - | ins_next1 - |.endif - | ins_next2 - | strd CARG12, [BASE, RA] - | ins_next3 - |5: // FP variant. - | ins_arithpre_fpu d6, d7 - | ins_arithfallback ins_arithcheck_num - |.if FPU - |.if "intins" == "vm_modi" - | bl fpcall - |.else - | fpins d6, d6, d7 - |.endif - | ins_arithpost_fpu d6 - |.else - | bl fpcall - |.if "intins" ~= "vm_modi" - | ins_next1 - |.endif - | b <4 - |.endif - |.endmacro - | - |.macro ins_arithfp, fpins, fpcall - | ins_arithpre - |.if "fpins" ~= "extern" or HFABI - | ins_arithpre_fpu d0, d1 - |.endif - | ins_arithfallback ins_arithcheck_num - |.if "fpins" == "extern" - | .IOS mov RC, BASE - | bl fpcall - | .IOS mov BASE, RC - |.elif FPU - | fpins d0, d0, d1 - |.else - | bl fpcall - |.endif - |.if ("fpins" ~= "extern" or HFABI) and FPU - | ins_arithpost_fpu d0 - |.else - | ins_next1 - | ins_next2 - | strd CARG12, [BASE, RA] - | ins_next3 - |.endif - |.endmacro - - case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: - | ins_arithdn adds, vadd.f64, extern __aeabi_dadd - break; - case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: - | ins_arithdn subs, vsub.f64, extern __aeabi_dsub - break; - case BC_MULVN: case BC_MULNV: case BC_MULVV: - | ins_arithdn smull, vmul.f64, extern __aeabi_dmul - break; - case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: - | ins_arithfp vdiv.f64, extern __aeabi_ddiv - break; - case BC_MODVN: case BC_MODNV: case BC_MODVV: - | ins_arithdn vm_modi, vm_mod, ->vm_mod - break; - case BC_POW: - | // NYI: (partial) integer arithmetic. - | ins_arithfp extern, extern pow - break; - - case BC_CAT: - | decode_RB8 RC, INS - | decode_RC8 RB, INS - | // RA = dst*8, RC = src_start*8, RB = src_end*8 (note: RB/RC swapped!) - | sub CARG3, RB, RC - | str BASE, L->base - | add CARG2, BASE, RB - |->BC_CAT_Z: - | // RA = dst*8, RC = src_start*8, CARG2 = top-1 - | mov CARG1, L - | str PC, SAVE_PC - | lsr CARG3, CARG3, #3 - | bl extern lj_meta_cat // (lua_State *L, TValue *top, int left) - | // Returns NULL (finished) or TValue * (metamethod). - | ldr BASE, L->base - | cmp CRET1, #0 - | bne ->vmeta_binop - | ldrd CARG34, [BASE, RC] - | ins_next1 - | ins_next2 - | strd CARG34, [BASE, RA] // Copy result to RA. - | ins_next3 - break; - - /* -- Constant ops ------------------------------------------------------ */ - - case BC_KSTR: - | // RA = dst*8, RC = str_const (~) - | mvn RC, RC - | ins_next1 - | ldr CARG1, [KBASE, RC, lsl #2] - | mvn CARG2, #~LJ_TSTR - | ins_next2 - | strd CARG12, [BASE, RA] - | ins_next3 - break; - case BC_KCDATA: - |.if FFI - | // RA = dst*8, RC = cdata_const (~) - | mvn RC, RC - | ins_next1 - | ldr CARG1, [KBASE, RC, lsl #2] - | mvn CARG2, #~LJ_TCDATA - | ins_next2 - | strd CARG12, [BASE, RA] - | ins_next3 - |.endif - break; - case BC_KSHORT: - | // RA = dst*8, (RC = int16_literal) - | mov CARG1, INS, asr #16 // Refetch sign-extended reg. - | mvn CARG2, #~LJ_TISNUM - | ins_next1 - | ins_next2 - | strd CARG12, [BASE, RA] - | ins_next3 - break; - case BC_KNUM: - | // RA = dst*8, RC = num_const - | lsl RC, RC, #3 - | ins_next1 - | ldrd CARG12, [KBASE, RC] - | ins_next2 - | strd CARG12, [BASE, RA] - | ins_next3 - break; - case BC_KPRI: - | // RA = dst*8, RC = primitive_type (~) - | add RA, BASE, RA - | mvn RC, RC - | ins_next1 - | ins_next2 - | str RC, [RA, #4] - | ins_next3 - break; - case BC_KNIL: - | // RA = base*8, RC = end - | add RA, BASE, RA - | add RC, BASE, RC, lsl #3 - | mvn CARG1, #~LJ_TNIL - | str CARG1, [RA, #4] - | add RA, RA, #8 - |1: - | str CARG1, [RA, #4] - | cmp RA, RC - | add RA, RA, #8 - | blt <1 - | ins_next_ - break; - - /* -- Upvalue and function ops ------------------------------------------ */ - - case BC_UGET: - | // RA = dst*8, RC = uvnum - | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] - | lsl RC, RC, #2 - | add RC, RC, #offsetof(GCfuncL, uvptr) - | ldr UPVAL:CARG2, [LFUNC:CARG2, RC] - | ldr CARG2, UPVAL:CARG2->v - | ldrd CARG34, [CARG2] - | ins_next1 - | ins_next2 - | strd CARG34, [BASE, RA] - | ins_next3 - break; - case BC_USETV: - | // RA = uvnum*8, RC = src - | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] - | lsr RA, RA, #1 - | add RA, RA, #offsetof(GCfuncL, uvptr) - | lsl RC, RC, #3 - | ldr UPVAL:CARG2, [LFUNC:CARG2, RA] - | ldrd CARG34, [BASE, RC] - | ldrb RB, UPVAL:CARG2->marked - | ldrb RC, UPVAL:CARG2->closed - | ldr CARG2, UPVAL:CARG2->v - | tst RB, #LJ_GC_BLACK // isblack(uv) - | add RB, CARG4, #-LJ_TISGCV - | cmpne RC, #0 - | strd CARG34, [CARG2] - | bne >2 // Upvalue is closed and black? - |1: - | ins_next - | - |2: // Check if new value is collectable. - | cmn RB, #-(LJ_TNUMX - LJ_TISGCV) - | ldrbhi RC, GCOBJ:CARG3->gch.marked - | bls <1 // tvisgcv(v) - | sub CARG1, DISPATCH, #-GG_DISP2G - | tst RC, #LJ_GC_WHITES - | // Crossed a write barrier. Move the barrier forward. - |.if IOS - | beq <1 - | mov RC, BASE - | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) - | mov BASE, RC - |.else - | blne extern lj_gc_barrieruv // (global_State *g, TValue *tv) - |.endif - | b <1 - break; - case BC_USETS: - | // RA = uvnum*8, RC = str_const (~) - | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] - | lsr RA, RA, #1 - | add RA, RA, #offsetof(GCfuncL, uvptr) - | mvn RC, RC - | ldr UPVAL:CARG2, [LFUNC:CARG2, RA] - | ldr STR:CARG3, [KBASE, RC, lsl #2] - | mvn CARG4, #~LJ_TSTR - | ldrb RB, UPVAL:CARG2->marked - | ldr CARG2, UPVAL:CARG2->v - | ldrb RC, UPVAL:CARG2->closed - | tst RB, #LJ_GC_BLACK // isblack(uv) - | ldrb RB, STR:CARG3->marked - | strd CARG34, [CARG2] - | bne >2 - |1: - | ins_next - | - |2: // Check if string is white and ensure upvalue is closed. - | tst RB, #LJ_GC_WHITES // iswhite(str) - | cmpne RC, #0 - | sub CARG1, DISPATCH, #-GG_DISP2G - | // Crossed a write barrier. Move the barrier forward. - |.if IOS - | beq <1 - | mov RC, BASE - | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) - | mov BASE, RC - |.else - | blne extern lj_gc_barrieruv // (global_State *g, TValue *tv) - |.endif - | b <1 - break; - case BC_USETN: - | // RA = uvnum*8, RC = num_const - | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] - | lsr RA, RA, #1 - | add RA, RA, #offsetof(GCfuncL, uvptr) - | lsl RC, RC, #3 - | ldr UPVAL:CARG2, [LFUNC:CARG2, RA] - | ldrd CARG34, [KBASE, RC] - | ldr CARG2, UPVAL:CARG2->v - | ins_next1 - | ins_next2 - | strd CARG34, [CARG2] - | ins_next3 - break; - case BC_USETP: - | // RA = uvnum*8, RC = primitive_type (~) - | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] - | lsr RA, RA, #1 - | add RA, RA, #offsetof(GCfuncL, uvptr) - | ldr UPVAL:CARG2, [LFUNC:CARG2, RA] - | mvn RC, RC - | ldr CARG2, UPVAL:CARG2->v - | ins_next1 - | ins_next2 - | str RC, [CARG2, #4] - | ins_next3 - break; - - case BC_UCLO: - | // RA = level*8, RC = target - | ldr CARG3, L->openupval - | add RC, PC, RC, lsl #2 - | str BASE, L->base - | cmp CARG3, #0 - | sub PC, RC, #0x20000 - | beq >1 - | mov CARG1, L - | add CARG2, BASE, RA - | bl extern lj_func_closeuv // (lua_State *L, TValue *level) - | ldr BASE, L->base - |1: - | ins_next - break; - - case BC_FNEW: - | // RA = dst*8, RC = proto_const (~) (holding function prototype) - | mvn RC, RC - | str BASE, L->base - | ldr CARG2, [KBASE, RC, lsl #2] - | str PC, SAVE_PC - | ldr CARG3, [BASE, FRAME_FUNC] - | mov CARG1, L - | // (lua_State *L, GCproto *pt, GCfuncL *parent) - | bl extern lj_func_newL_gc - | // Returns GCfuncL *. - | ldr BASE, L->base - | mvn CARG2, #~LJ_TFUNC - | ins_next1 - | ins_next2 - | strd CARG12, [BASE, RA] - | ins_next3 - break; - - /* -- Table ops --------------------------------------------------------- */ - - case BC_TNEW: - case BC_TDUP: - | // RA = dst*8, RC = (hbits|asize) | tab_const (~) - if (op == BC_TDUP) { - | mvn RC, RC - } - | ldr CARG3, [DISPATCH, #DISPATCH_GL(gc.total)] - | ldr CARG4, [DISPATCH, #DISPATCH_GL(gc.threshold)] - | str BASE, L->base - | str PC, SAVE_PC - | cmp CARG3, CARG4 - | mov CARG1, L - | bhs >5 - |1: - if (op == BC_TNEW) { - | lsl CARG2, RC, #21 - | lsr CARG3, RC, #11 - | asr RC, CARG2, #21 - | lsr CARG2, CARG2, #21 - | cmn RC, #1 - | addeq CARG2, CARG2, #2 - | bl extern lj_tab_new // (lua_State *L, int32_t asize, uint32_t hbits) - | // Returns GCtab *. - } else { - | ldr CARG2, [KBASE, RC, lsl #2] - | bl extern lj_tab_dup // (lua_State *L, Table *kt) - | // Returns GCtab *. - } - | ldr BASE, L->base - | mvn CARG2, #~LJ_TTAB - | ins_next1 - | ins_next2 - | strd CARG12, [BASE, RA] - | ins_next3 - |5: - | bl extern lj_gc_step_fixtop // (lua_State *L) - | mov CARG1, L - | b <1 - break; - - case BC_GGET: - | // RA = dst*8, RC = str_const (~) - case BC_GSET: - | // RA = dst*8, RC = str_const (~) - | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] - | mvn RC, RC - | ldr TAB:CARG1, LFUNC:CARG2->env - | ldr STR:RC, [KBASE, RC, lsl #2] - if (op == BC_GGET) { - | b ->BC_TGETS_Z - } else { - | b ->BC_TSETS_Z - } - break; - - case BC_TGETV: - | decode_RB8 RB, INS - | decode_RC8 RC, INS - | // RA = dst*8, RB = table*8, RC = key*8 - | ldrd TAB:CARG12, [BASE, RB] - | ldrd CARG34, [BASE, RC] - | checktab CARG2, ->vmeta_tgetv // STALL: load CARG12. - | checktp CARG4, LJ_TISNUM // Integer key? - | ldreq CARG4, TAB:CARG1->array - | ldreq CARG2, TAB:CARG1->asize - | bne >9 - | - | add CARG4, CARG4, CARG3, lsl #3 - | cmp CARG3, CARG2 // In array part? - | ldrdlo CARG34, [CARG4] - | bhs ->vmeta_tgetv - | ins_next1 // Overwrites RB! - | checktp CARG4, LJ_TNIL - | beq >5 - |1: - | ins_next2 - | strd CARG34, [BASE, RA] - | ins_next3 - | - |5: // Check for __index if table value is nil. - | ldr TAB:CARG2, TAB:CARG1->metatable - | cmp TAB:CARG2, #0 - | beq <1 // No metatable: done. - | ldrb CARG2, TAB:CARG2->nomm - | tst CARG2, #1<vmeta_tgetv - | - |9: - | checktp CARG4, LJ_TSTR // String key? - | moveq STR:RC, CARG3 - | beq ->BC_TGETS_Z - | b ->vmeta_tgetv - break; - case BC_TGETS: - | decode_RB8 RB, INS - | and RC, RC, #255 - | // RA = dst*8, RB = table*8, RC = str_const (~) - | ldrd CARG12, [BASE, RB] - | mvn RC, RC - | ldr STR:RC, [KBASE, RC, lsl #2] // STALL: early RC. - | checktab CARG2, ->vmeta_tgets1 - |->BC_TGETS_Z: - | // (TAB:RB =) TAB:CARG1 = GCtab *, STR:RC = GCstr *, RA = dst*8 - | ldr CARG3, TAB:CARG1->hmask - | ldr CARG4, STR:RC->hash - | ldr NODE:INS, TAB:CARG1->node - | mov TAB:RB, TAB:CARG1 - | and CARG3, CARG3, CARG4 // idx = str->hash & tab->hmask - | add CARG3, CARG3, CARG3, lsl #1 - | add NODE:INS, NODE:INS, CARG3, lsl #3 // node = tab->node + idx*3*8 - |1: - | ldrd CARG12, NODE:INS->key // STALL: early NODE:INS. - | ldrd CARG34, NODE:INS->val - | ldr NODE:INS, NODE:INS->next - | checktp CARG2, LJ_TSTR - | cmpeq CARG1, STR:RC - | bne >4 - | checktp CARG4, LJ_TNIL - | beq >5 - |3: - | ins_next1 - | ins_next2 - | strd CARG34, [BASE, RA] - | ins_next3 - | - |4: // Follow hash chain. - | cmp NODE:INS, #0 - | bne <1 - | // End of hash chain: key not found, nil result. - | - |5: // Check for __index if table value is nil. - | ldr TAB:CARG1, TAB:RB->metatable - | mov CARG3, #0 // Optional clear of undef. value (during load stall). - | mvn CARG4, #~LJ_TNIL - | cmp TAB:CARG1, #0 - | beq <3 // No metatable: done. - | ldrb CARG2, TAB:CARG1->nomm - | tst CARG2, #1<vmeta_tgets - break; - case BC_TGETB: - | decode_RB8 RB, INS - | and RC, RC, #255 - | // RA = dst*8, RB = table*8, RC = index - | ldrd CARG12, [BASE, RB] - | checktab CARG2, ->vmeta_tgetb // STALL: load CARG12. - | ldr CARG3, TAB:CARG1->asize - | ldr CARG4, TAB:CARG1->array - | lsl CARG2, RC, #3 - | cmp RC, CARG3 - | ldrdlo CARG34, [CARG4, CARG2] - | bhs ->vmeta_tgetb - | ins_next1 // Overwrites RB! - | checktp CARG4, LJ_TNIL - | beq >5 - |1: - | ins_next2 - | strd CARG34, [BASE, RA] - | ins_next3 - | - |5: // Check for __index if table value is nil. - | ldr TAB:CARG2, TAB:CARG1->metatable - | cmp TAB:CARG2, #0 - | beq <1 // No metatable: done. - | ldrb CARG2, TAB:CARG2->nomm - | tst CARG2, #1<vmeta_tgetb - break; - - case BC_TSETV: - | decode_RB8 RB, INS - | decode_RC8 RC, INS - | // RA = src*8, RB = table*8, RC = key*8 - | ldrd TAB:CARG12, [BASE, RB] - | ldrd CARG34, [BASE, RC] - | checktab CARG2, ->vmeta_tsetv // STALL: load CARG12. - | checktp CARG4, LJ_TISNUM // Integer key? - | ldreq CARG2, TAB:CARG1->array - | ldreq CARG4, TAB:CARG1->asize - | bne >9 - | - | add CARG2, CARG2, CARG3, lsl #3 - | cmp CARG3, CARG4 // In array part? - | ldrlo INS, [CARG2, #4] - | bhs ->vmeta_tsetv - | ins_next1 // Overwrites RB! - | checktp INS, LJ_TNIL - | ldrb INS, TAB:CARG1->marked - | ldrd CARG34, [BASE, RA] - | beq >5 - |1: - | tst INS, #LJ_GC_BLACK // isblack(table) - | strd CARG34, [CARG2] - | bne >7 - |2: - | ins_next2 - | ins_next3 - | - |5: // Check for __newindex if previous value is nil. - | ldr TAB:RA, TAB:CARG1->metatable - | cmp TAB:RA, #0 - | beq <1 // No metatable: done. - | ldrb RA, TAB:RA->nomm - | tst RA, #1<vmeta_tsetv - | - |7: // Possible table write barrier for the value. Skip valiswhite check. - | barrierback TAB:CARG1, INS, CARG3 - | b <2 - | - |9: - | checktp CARG4, LJ_TSTR // String key? - | moveq STR:RC, CARG3 - | beq ->BC_TSETS_Z - | b ->vmeta_tsetv - break; - case BC_TSETS: - | decode_RB8 RB, INS - | and RC, RC, #255 - | // RA = src*8, RB = table*8, RC = str_const (~) - | ldrd CARG12, [BASE, RB] - | mvn RC, RC - | ldr STR:RC, [KBASE, RC, lsl #2] // STALL: early RC. - | checktab CARG2, ->vmeta_tsets1 - |->BC_TSETS_Z: - | // (TAB:RB =) TAB:CARG1 = GCtab *, STR:RC = GCstr *, RA = dst*8 - | ldr CARG3, TAB:CARG1->hmask - | ldr CARG4, STR:RC->hash - | ldr NODE:INS, TAB:CARG1->node - | mov TAB:RB, TAB:CARG1 - | and CARG3, CARG3, CARG4 // idx = str->hash & tab->hmask - | add CARG3, CARG3, CARG3, lsl #1 - | mov CARG4, #0 - | add NODE:INS, NODE:INS, CARG3, lsl #3 // node = tab->node + idx*3*8 - | strb CARG4, TAB:RB->nomm // Clear metamethod cache. - |1: - | ldrd CARG12, NODE:INS->key - | ldr CARG4, NODE:INS->val.it - | ldr NODE:CARG3, NODE:INS->next - | checktp CARG2, LJ_TSTR - | cmpeq CARG1, STR:RC - | bne >5 - | ldrb CARG2, TAB:RB->marked - | checktp CARG4, LJ_TNIL // Key found, but nil value? - | ldrd CARG34, [BASE, RA] - | beq >4 - |2: - | tst CARG2, #LJ_GC_BLACK // isblack(table) - | strd CARG34, NODE:INS->val - | bne >7 - |3: - | ins_next - | - |4: // Check for __newindex if previous value is nil. - | ldr TAB:CARG1, TAB:RB->metatable - | cmp TAB:CARG1, #0 - | beq <2 // No metatable: done. - | ldrb CARG1, TAB:CARG1->nomm - | tst CARG1, #1<vmeta_tsets - | - |5: // Follow hash chain. - | movs NODE:INS, NODE:CARG3 - | bne <1 - | // End of hash chain: key not found, add a new one. - | - | // But check for __newindex first. - | ldr TAB:CARG1, TAB:RB->metatable - | mov CARG3, TMPDp - | str PC, SAVE_PC - | cmp TAB:CARG1, #0 // No metatable: continue. - | str BASE, L->base - | ldrbne CARG2, TAB:CARG1->nomm - | mov CARG1, L - | beq >6 - | tst CARG2, #1<vmeta_tsets // 'no __newindex' flag NOT set: check. - |6: - | mvn CARG4, #~LJ_TSTR - | str STR:RC, TMPDlo - | mov CARG2, TAB:RB - | str CARG4, TMPDhi - | bl extern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k) - | // Returns TValue *. - | ldr BASE, L->base - | ldrd CARG34, [BASE, RA] - | strd CARG34, [CRET1] - | b <3 // No 2nd write barrier needed. - | - |7: // Possible table write barrier for the value. Skip valiswhite check. - | barrierback TAB:RB, CARG2, CARG3 - | b <3 - break; - case BC_TSETB: - | decode_RB8 RB, INS - | and RC, RC, #255 - | // RA = src*8, RB = table*8, RC = index - | ldrd CARG12, [BASE, RB] - | checktab CARG2, ->vmeta_tsetb // STALL: load CARG12. - | ldr CARG3, TAB:CARG1->asize - | ldr RB, TAB:CARG1->array - | lsl CARG2, RC, #3 - | cmp RC, CARG3 - | ldrdlo CARG34, [CARG2, RB]! - | bhs ->vmeta_tsetb - | ins_next1 // Overwrites RB! - | checktp CARG4, LJ_TNIL - | ldrb INS, TAB:CARG1->marked - | ldrd CARG34, [BASE, RA] - | beq >5 - |1: - | tst INS, #LJ_GC_BLACK // isblack(table) - | strd CARG34, [CARG2] - | bne >7 - |2: - | ins_next2 - | ins_next3 - | - |5: // Check for __newindex if previous value is nil. - | ldr TAB:RA, TAB:CARG1->metatable - | cmp TAB:RA, #0 - | beq <1 // No metatable: done. - | ldrb RA, TAB:RA->nomm - | tst RA, #1<vmeta_tsetb - | - |7: // Possible table write barrier for the value. Skip valiswhite check. - | barrierback TAB:CARG1, INS, CARG3 - | b <2 - break; - - case BC_TSETM: - | // RA = base*8 (table at base-1), RC = num_const (start index) - | add RA, BASE, RA - |1: - | ldr RB, SAVE_MULTRES - | ldr TAB:CARG2, [RA, #-8] // Guaranteed to be a table. - | ldr CARG1, [KBASE, RC, lsl #3] // Integer constant is in lo-word. - | subs RB, RB, #8 - | ldr CARG4, TAB:CARG2->asize - | beq >4 // Nothing to copy? - | add CARG3, CARG1, RB, lsr #3 - | cmp CARG3, CARG4 - | ldr CARG4, TAB:CARG2->array - | add RB, RA, RB - | bhi >5 - | add INS, CARG4, CARG1, lsl #3 - | ldrb CARG1, TAB:CARG2->marked - |3: // Copy result slots to table. - | ldrd CARG34, [RA], #8 - | strd CARG34, [INS], #8 - | cmp RA, RB - | blo <3 - | tst CARG1, #LJ_GC_BLACK // isblack(table) - | bne >7 - |4: - | ins_next - | - |5: // Need to resize array part. - | str BASE, L->base - | mov CARG1, L - | str PC, SAVE_PC - | bl extern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) - | // Must not reallocate the stack. - | .IOS ldr BASE, L->base - | b <1 - | - |7: // Possible table write barrier for any value. Skip valiswhite check. - | barrierback TAB:CARG2, CARG1, CARG3 - | b <4 - break; - - /* -- Calls and vararg handling ----------------------------------------- */ - - case BC_CALLM: - | // RA = base*8, (RB = nresults+1,) RC = extra_nargs - | ldr CARG1, SAVE_MULTRES - | decode_RC8 NARGS8:RC, INS - | add NARGS8:RC, NARGS8:RC, CARG1 - | b ->BC_CALL_Z - break; - case BC_CALL: - | decode_RC8 NARGS8:RC, INS - | // RA = base*8, (RB = nresults+1,) RC = (nargs+1)*8 - |->BC_CALL_Z: - | mov RB, BASE // Save old BASE for vmeta_call. - | ldrd CARG34, [BASE, RA]! - | sub NARGS8:RC, NARGS8:RC, #8 - | add BASE, BASE, #8 - | checkfunc CARG4, ->vmeta_call - | ins_call - break; - - case BC_CALLMT: - | // RA = base*8, (RB = 0,) RC = extra_nargs - | ldr CARG1, SAVE_MULTRES - | add NARGS8:RC, CARG1, RC, lsl #3 - | b ->BC_CALLT1_Z - break; - case BC_CALLT: - | lsl NARGS8:RC, RC, #3 - | // RA = base*8, (RB = 0,) RC = (nargs+1)*8 - |->BC_CALLT1_Z: - | ldrd LFUNC:CARG34, [RA, BASE]! - | sub NARGS8:RC, NARGS8:RC, #8 - | add RA, RA, #8 - | checkfunc CARG4, ->vmeta_callt - | ldr PC, [BASE, FRAME_PC] - |->BC_CALLT2_Z: - | mov RB, #0 - | ldrb CARG4, LFUNC:CARG3->ffid - | tst PC, #FRAME_TYPE - | bne >7 - |1: - | str LFUNC:CARG3, [BASE, FRAME_FUNC] // Copy function down, but keep PC. - | cmp NARGS8:RC, #0 - | beq >3 - |2: - | ldrd CARG12, [RA, RB] - | add INS, RB, #8 - | cmp INS, NARGS8:RC - | strd CARG12, [BASE, RB] - | mov RB, INS - | bne <2 - |3: - | cmp CARG4, #1 // (> FF_C) Calling a fast function? - | bhi >5 - |4: - | ins_callt - | - |5: // Tailcall to a fast function with a Lua frame below. - | ldr INS, [PC, #-4] - | decode_RA8 RA, INS - | sub CARG1, BASE, RA - | ldr LFUNC:CARG1, [CARG1, #-16] - | ldr CARG1, LFUNC:CARG1->field_pc - | ldr KBASE, [CARG1, #PC2PROTO(k)] - | b <4 - | - |7: // Tailcall from a vararg function. - | eor PC, PC, #FRAME_VARG - | tst PC, #FRAME_TYPEP // Vararg frame below? - | movne CARG4, #0 // Clear ffid if no Lua function below. - | bne <1 - | sub BASE, BASE, PC - | ldr PC, [BASE, FRAME_PC] - | tst PC, #FRAME_TYPE - | movne CARG4, #0 // Clear ffid if no Lua function below. - | b <1 - break; - - case BC_ITERC: - | // RA = base*8, (RB = nresults+1, RC = nargs+1 (2+1)) - | add RA, BASE, RA - | mov RB, BASE // Save old BASE for vmeta_call. - | ldrd CARG34, [RA, #-16] - | ldrd CARG12, [RA, #-8] - | add BASE, RA, #8 - | strd CARG34, [RA, #8] // Copy state. - | strd CARG12, [RA, #16] // Copy control var. - | // STALL: locked CARG34. - | ldrd LFUNC:CARG34, [RA, #-24] - | mov NARGS8:RC, #16 // Iterators get 2 arguments. - | // STALL: load CARG34. - | strd LFUNC:CARG34, [RA] // Copy callable. - | checkfunc CARG4, ->vmeta_call - | ins_call - break; - - case BC_ITERN: - | // RA = base*8, (RB = nresults+1, RC = nargs+1 (2+1)) - |.if JIT - | // NYI: add hotloop, record BC_ITERN. - |.endif - | add RA, BASE, RA - | ldr TAB:RB, [RA, #-16] - | ldr CARG1, [RA, #-8] // Get index from control var. - | ldr INS, TAB:RB->asize - | ldr CARG2, TAB:RB->array - | add PC, PC, #4 - |1: // Traverse array part. - | subs RC, CARG1, INS - | add CARG3, CARG2, CARG1, lsl #3 - | bhs >5 // Index points after array part? - | ldrd CARG34, [CARG3] - | checktp CARG4, LJ_TNIL - | addeq CARG1, CARG1, #1 // Skip holes in array part. - | beq <1 - | ldrh RC, [PC, #-2] - | mvn CARG2, #~LJ_TISNUM - | strd CARG34, [RA, #8] - | add RC, PC, RC, lsl #2 - | add RB, CARG1, #1 - | strd CARG12, [RA] - | sub PC, RC, #0x20000 - | str RB, [RA, #-8] // Update control var. - |3: - | ins_next - | - |5: // Traverse hash part. - | ldr CARG4, TAB:RB->hmask - | ldr NODE:RB, TAB:RB->node - |6: - | add CARG1, RC, RC, lsl #1 - | cmp RC, CARG4 // End of iteration? Branch to ITERL+1. - | add NODE:CARG3, NODE:RB, CARG1, lsl #3 // node = tab->node + idx*3*8 - | bhi <3 - | ldrd CARG12, NODE:CARG3->val - | checktp CARG2, LJ_TNIL - | add RC, RC, #1 - | beq <6 // Skip holes in hash part. - | ldrh RB, [PC, #-2] - | add RC, RC, INS - | ldrd CARG34, NODE:CARG3->key - | str RC, [RA, #-8] // Update control var. - | strd CARG12, [RA, #8] - | add RC, PC, RB, lsl #2 - | sub PC, RC, #0x20000 - | strd CARG34, [RA] - | b <3 - break; - - case BC_ISNEXT: - | // RA = base*8, RC = target (points to ITERN) - | add RA, BASE, RA - | add RC, PC, RC, lsl #2 - | ldrd CFUNC:CARG12, [RA, #-24] - | ldr CARG3, [RA, #-12] - | ldr CARG4, [RA, #-4] - | checktp CARG2, LJ_TFUNC - | ldrbeq CARG1, CFUNC:CARG1->ffid - | checktpeq CARG3, LJ_TTAB - | checktpeq CARG4, LJ_TNIL - | cmpeq CARG1, #FF_next_N - | subeq PC, RC, #0x20000 - | bne >5 - | ins_next1 - | ins_next2 - | mov CARG1, #0 - | mvn CARG2, #0x00018000 - | strd CARG1, [RA, #-8] // Initialize control var. - |1: - | ins_next3 - |5: // Despecialize bytecode if any of the checks fail. - | mov CARG1, #BC_JMP - | mov OP, #BC_ITERC - | strb CARG1, [PC, #-4] - | sub PC, RC, #0x20000 - | strb OP, [PC] // Subsumes ins_next1. - | ins_next2 - | b <1 - break; - - case BC_VARG: - | decode_RB8 RB, INS - | decode_RC8 RC, INS - | // RA = base*8, RB = (nresults+1)*8, RC = numparams*8 - | ldr CARG1, [BASE, FRAME_PC] - | add RC, BASE, RC - | add RA, BASE, RA - | add RC, RC, #FRAME_VARG - | add CARG4, RA, RB - | sub CARG3, BASE, #8 // CARG3 = vtop - | sub RC, RC, CARG1 // RC = vbase - | // Note: RC may now be even _above_ BASE if nargs was < numparams. - | cmp RB, #0 - | sub CARG1, CARG3, RC - | beq >5 // Copy all varargs? - | sub CARG4, CARG4, #16 - |1: // Copy vararg slots to destination slots. - | cmp RC, CARG3 - | ldrdlo CARG12, [RC], #8 - | mvnhs CARG2, #~LJ_TNIL - | cmp RA, CARG4 - | strd CARG12, [RA], #8 - | blo <1 - |2: - | ins_next - | - |5: // Copy all varargs. - | ldr CARG4, L->maxstack - | cmp CARG1, #0 - | movle RB, #8 // MULTRES = (0+1)*8 - | addgt RB, CARG1, #8 - | add CARG2, RA, CARG1 - | str RB, SAVE_MULTRES - | ble <2 - | cmp CARG2, CARG4 - | bhi >7 - |6: - | ldrd CARG12, [RC], #8 - | strd CARG12, [RA], #8 - | cmp RC, CARG3 - | blo <6 - | b <2 - | - |7: // Grow stack for varargs. - | lsr CARG2, CARG1, #3 - | str RA, L->top - | mov CARG1, L - | str BASE, L->base - | sub RC, RC, BASE // Need delta, because BASE may change. - | str PC, SAVE_PC - | sub RA, RA, BASE - | bl extern lj_state_growstack // (lua_State *L, int n) - | ldr BASE, L->base - | add RA, BASE, RA - | add RC, BASE, RC - | sub CARG3, BASE, #8 - | b <6 - break; - - /* -- Returns ----------------------------------------------------------- */ - - case BC_RETM: - | // RA = results*8, RC = extra results - | ldr CARG1, SAVE_MULTRES - | ldr PC, [BASE, FRAME_PC] - | add RA, BASE, RA - | add RC, CARG1, RC, lsl #3 - | b ->BC_RETM_Z - break; - - case BC_RET: - | // RA = results*8, RC = nresults+1 - | ldr PC, [BASE, FRAME_PC] - | lsl RC, RC, #3 - | add RA, BASE, RA - |->BC_RETM_Z: - | str RC, SAVE_MULTRES - |1: - | ands CARG1, PC, #FRAME_TYPE - | eor CARG2, PC, #FRAME_VARG - | bne ->BC_RETV2_Z - | - |->BC_RET_Z: - | // BASE = base, RA = resultptr, RC = (nresults+1)*8, PC = return - | ldr INS, [PC, #-4] - | subs CARG4, RC, #8 - | sub CARG3, BASE, #8 - | beq >3 - |2: - | ldrd CARG12, [RA], #8 - | add BASE, BASE, #8 - | subs CARG4, CARG4, #8 - | strd CARG12, [BASE, #-16] - | bne <2 - |3: - | decode_RA8 RA, INS - | sub CARG4, CARG3, RA - | decode_RB8 RB, INS - | ldr LFUNC:CARG1, [CARG4, FRAME_FUNC] - |5: - | cmp RB, RC // More results expected? - | bhi >6 - | mov BASE, CARG4 - | ldr CARG2, LFUNC:CARG1->field_pc - | ins_next1 - | ins_next2 - | ldr KBASE, [CARG2, #PC2PROTO(k)] - | ins_next3 - | - |6: // Fill up results with nil. - | mvn CARG2, #~LJ_TNIL - | add BASE, BASE, #8 - | add RC, RC, #8 - | str CARG2, [BASE, #-12] - | b <5 - | - |->BC_RETV1_Z: // Non-standard return case. - | add RA, BASE, RA - |->BC_RETV2_Z: - | tst CARG2, #FRAME_TYPEP - | bne ->vm_return - | // Return from vararg function: relocate BASE down. - | sub BASE, BASE, CARG2 - | ldr PC, [BASE, FRAME_PC] - | b <1 - break; - - case BC_RET0: case BC_RET1: - | // RA = results*8, RC = nresults+1 - | ldr PC, [BASE, FRAME_PC] - | lsl RC, RC, #3 - | str RC, SAVE_MULTRES - | ands CARG1, PC, #FRAME_TYPE - | eor CARG2, PC, #FRAME_VARG - | ldreq INS, [PC, #-4] - | bne ->BC_RETV1_Z - if (op == BC_RET1) { - | ldrd CARG12, [BASE, RA] - } - | sub CARG4, BASE, #8 - | decode_RA8 RA, INS - if (op == BC_RET1) { - | strd CARG12, [CARG4] - } - | sub BASE, CARG4, RA - | decode_RB8 RB, INS - | ldr LFUNC:CARG1, [BASE, FRAME_FUNC] - |5: - | cmp RB, RC - | bhi >6 - | ldr CARG2, LFUNC:CARG1->field_pc - | ins_next1 - | ins_next2 - | ldr KBASE, [CARG2, #PC2PROTO(k)] - | ins_next3 - | - |6: // Fill up results with nil. - | sub CARG2, CARG4, #4 - | mvn CARG3, #~LJ_TNIL - | str CARG3, [CARG2, RC] - | add RC, RC, #8 - | b <5 - break; - - /* -- Loops and branches ------------------------------------------------ */ - - |.define FOR_IDX, [RA]; .define FOR_TIDX, [RA, #4] - |.define FOR_STOP, [RA, #8]; .define FOR_TSTOP, [RA, #12] - |.define FOR_STEP, [RA, #16]; .define FOR_TSTEP, [RA, #20] - |.define FOR_EXT, [RA, #24]; .define FOR_TEXT, [RA, #28] - - case BC_FORL: - |.if JIT - | hotloop - |.endif - | // Fall through. Assumes BC_IFORL follows. - break; - - case BC_JFORI: - case BC_JFORL: -#if !LJ_HASJIT - break; -#endif - case BC_FORI: - case BC_IFORL: - | // RA = base*8, RC = target (after end of loop or start of loop) - vk = (op == BC_IFORL || op == BC_JFORL); - | ldrd CARG12, [RA, BASE]! - if (op != BC_JFORL) { - | add RC, PC, RC, lsl #2 - } - if (!vk) { - | ldrd CARG34, FOR_STOP - | checktp CARG2, LJ_TISNUM - | ldr RB, FOR_TSTEP - | bne >5 - | checktp CARG4, LJ_TISNUM - | ldr CARG4, FOR_STEP - | checktpeq RB, LJ_TISNUM - | bne ->vmeta_for - | cmp CARG4, #0 - | blt >4 - | cmp CARG1, CARG3 - } else { - | ldrd CARG34, FOR_STEP - | checktp CARG2, LJ_TISNUM - | bne >5 - | adds CARG1, CARG1, CARG3 - | ldr CARG4, FOR_STOP - if (op == BC_IFORL) { - | addvs RC, PC, #0x20000 // Overflow: prevent branch. - } else { - | bvs >2 // Overflow: do not enter mcode. - } - | cmp CARG3, #0 - | blt >4 - | cmp CARG1, CARG4 - } - |1: - if (op == BC_FORI) { - | subgt PC, RC, #0x20000 - } else if (op == BC_JFORI) { - | sub PC, RC, #0x20000 - | ldrhle RC, [PC, #-2] - } else if (op == BC_IFORL) { - | suble PC, RC, #0x20000 - } - if (vk) { - | strd CARG12, FOR_IDX - } - |2: - | ins_next1 - | ins_next2 - | strd CARG12, FOR_EXT - if (op == BC_JFORI || op == BC_JFORL) { - | ble =>BC_JLOOP - } - |3: - | ins_next3 - | - |4: // Invert check for negative step. - if (!vk) { - | cmp CARG3, CARG1 - } else { - | cmp CARG4, CARG1 - } - | b <1 - | - |5: // FP loop. - if (!vk) { - | cmnlo CARG4, #-LJ_TISNUM - | cmnlo RB, #-LJ_TISNUM - | bhs ->vmeta_for - |.if FPU - | vldr d0, FOR_IDX - | vldr d1, FOR_STOP - | cmp RB, #0 - | vstr d0, FOR_EXT - |.else - | cmp RB, #0 - | strd CARG12, FOR_EXT - | blt >8 - |.endif - } else { - |.if FPU - | vldr d0, FOR_IDX - | vldr d2, FOR_STEP - | vldr d1, FOR_STOP - | cmp CARG4, #0 - | vadd.f64 d0, d0, d2 - |.else - | cmp CARG4, #0 - | blt >8 - | bl extern __aeabi_dadd - | strd CARG12, FOR_IDX - | ldrd CARG34, FOR_STOP - | strd CARG12, FOR_EXT - |.endif - } - |6: - |.if FPU - | vcmpge.f64 d0, d1 - | vcmplt.f64 d1, d0 - | vmrs - |.else - | bl extern __aeabi_cdcmple - |.endif - if (vk) { - |.if FPU - | vstr d0, FOR_IDX - | vstr d0, FOR_EXT - |.endif - } - if (op == BC_FORI) { - | subhi PC, RC, #0x20000 - } else if (op == BC_JFORI) { - | sub PC, RC, #0x20000 - | ldrhls RC, [PC, #-2] - | bls =>BC_JLOOP - } else if (op == BC_IFORL) { - | subls PC, RC, #0x20000 - } else { - | bls =>BC_JLOOP - } - | ins_next1 - | ins_next2 - | b <3 - | - |.if not FPU - |8: // Invert check for negative step. - if (vk) { - | bl extern __aeabi_dadd - | strd CARG12, FOR_IDX - | strd CARG12, FOR_EXT - } - | mov CARG3, CARG1 - | mov CARG4, CARG2 - | ldrd CARG12, FOR_STOP - | b <6 - |.endif - break; - - case BC_ITERL: - |.if JIT - | hotloop - |.endif - | // Fall through. Assumes BC_IITERL follows. - break; - - case BC_JITERL: -#if !LJ_HASJIT - break; -#endif - case BC_IITERL: - | // RA = base*8, RC = target - | ldrd CARG12, [RA, BASE]! - if (op == BC_JITERL) { - | cmn CARG2, #-LJ_TNIL // Stop if iterator returned nil. - | strdne CARG12, [RA, #-8] - | bne =>BC_JLOOP - } else { - | add RC, PC, RC, lsl #2 - | // STALL: load CARG12. - | cmn CARG2, #-LJ_TNIL // Stop if iterator returned nil. - | subne PC, RC, #0x20000 // Otherwise save control var + branch. - | strdne CARG12, [RA, #-8] - } - | ins_next - break; - - case BC_LOOP: - | // RA = base*8, RC = target (loop extent) - | // Note: RA/RC is only used by trace recorder to determine scope/extent - | // This opcode does NOT jump, it's only purpose is to detect a hot loop. - |.if JIT - | hotloop - |.endif - | // Fall through. Assumes BC_ILOOP follows. - break; - - case BC_ILOOP: - | // RA = base*8, RC = target (loop extent) - | ins_next - break; - - case BC_JLOOP: - |.if JIT - | // RA = base (ignored), RC = traceno - | ldr CARG1, [DISPATCH, #DISPATCH_J(trace)] - | mov CARG2, #0 // Traces on ARM don't store the trace number, so use 0. - | ldr TRACE:RC, [CARG1, RC, lsl #2] - | st_vmstate CARG2 - | ldr RA, TRACE:RC->mcode - | str BASE, [DISPATCH, #DISPATCH_GL(jit_base)] - | str L, [DISPATCH, #DISPATCH_GL(jit_L)] - | bx RA - |.endif - break; - - case BC_JMP: - | // RA = base*8 (only used by trace recorder), RC = target - | add RC, PC, RC, lsl #2 - | sub PC, RC, #0x20000 - | ins_next - break; - - /* -- Function headers -------------------------------------------------- */ - - case BC_FUNCF: - |.if JIT - | hotcall - |.endif - case BC_FUNCV: /* NYI: compiled vararg functions. */ - | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow. - break; - - case BC_JFUNCF: -#if !LJ_HASJIT - break; -#endif - case BC_IFUNCF: - | // BASE = new base, RA = BASE+framesize*8, CARG3 = LFUNC, RC = nargs*8 - | ldr CARG1, L->maxstack - | ldrb CARG2, [PC, #-4+PC2PROTO(numparams)] - | ldr KBASE, [PC, #-4+PC2PROTO(k)] - | cmp RA, CARG1 - | bhi ->vm_growstack_l - if (op != BC_JFUNCF) { - | ins_next1 - | ins_next2 - } - |2: - | cmp NARGS8:RC, CARG2, lsl #3 // Check for missing parameters. - | mvn CARG4, #~LJ_TNIL - | blo >3 - if (op == BC_JFUNCF) { - | decode_RD RC, INS - | b =>BC_JLOOP - } else { - | ins_next3 - } - | - |3: // Clear missing parameters. - | strd CARG34, [BASE, NARGS8:RC] - | add NARGS8:RC, NARGS8:RC, #8 - | b <2 - break; - - case BC_JFUNCV: -#if !LJ_HASJIT - break; -#endif - | NYI // NYI: compiled vararg functions - break; /* NYI: compiled vararg functions. */ - - case BC_IFUNCV: - | // BASE = new base, RA = BASE+framesize*8, CARG3 = LFUNC, RC = nargs*8 - | ldr CARG1, L->maxstack - | add CARG4, BASE, RC - | add RA, RA, RC - | str LFUNC:CARG3, [CARG4] // Store copy of LFUNC. - | add CARG2, RC, #8+FRAME_VARG - | ldr KBASE, [PC, #-4+PC2PROTO(k)] - | cmp RA, CARG1 - | str CARG2, [CARG4, #4] // Store delta + FRAME_VARG. - | bhs ->vm_growstack_l - | ldrb RB, [PC, #-4+PC2PROTO(numparams)] - | mov RA, BASE - | mov RC, CARG4 - | cmp RB, #0 - | add BASE, CARG4, #8 - | beq >3 - | mvn CARG3, #~LJ_TNIL - |1: - | cmp RA, RC // Less args than parameters? - | ldrdlo CARG12, [RA], #8 - | movhs CARG2, CARG3 - | strlo CARG3, [RA, #-4] // Clear old fixarg slot (help the GC). - |2: - | subs RB, RB, #1 - | strd CARG12, [CARG4, #8]! - | bne <1 - |3: - | ins_next - break; - - case BC_FUNCC: - case BC_FUNCCW: - | // BASE = new base, RA = BASE+framesize*8, CARG3 = CFUNC, RC = nargs*8 - if (op == BC_FUNCC) { - | ldr CARG4, CFUNC:CARG3->f - } else { - | ldr CARG4, [DISPATCH, #DISPATCH_GL(wrapf)] - } - | add CARG2, RA, NARGS8:RC - | ldr CARG1, L->maxstack - | add RC, BASE, NARGS8:RC - | str BASE, L->base - | cmp CARG2, CARG1 - | str RC, L->top - if (op == BC_FUNCCW) { - | ldr CARG2, CFUNC:CARG3->f - } - | mv_vmstate CARG3, C - | mov CARG1, L - | bhi ->vm_growstack_c // Need to grow stack. - | st_vmstate CARG3 - | blx CARG4 // (lua_State *L [, lua_CFunction f]) - | // Returns nresults. - | ldr BASE, L->base - | mv_vmstate CARG3, INTERP - | ldr CRET2, L->top - | lsl RC, CRET1, #3 - | st_vmstate CARG3 - | ldr PC, [BASE, FRAME_PC] - | sub RA, CRET2, RC // RA = L->top - nresults*8 - | b ->vm_returnc - break; - - /* ---------------------------------------------------------------------- */ - - default: - fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); - exit(2); - break; - } -} - -static int build_backend(BuildCtx *ctx) -{ - int op; - - dasm_growpc(Dst, BC__MAX); - - build_subroutines(ctx); - - |.code_op - for (op = 0; op < BC__MAX; op++) - build_ins(ctx, (BCOp)op, op); - - return BC__MAX; -} - -/* Emit pseudo frame-info for all assembler functions. */ -static void emit_asm_debug(BuildCtx *ctx) -{ - int fcofs = (int)((uint8_t *)ctx->glob[GLOB_vm_ffi_call] - ctx->code); - int i; - switch (ctx->mode) { - case BUILD_elfasm: - fprintf(ctx->fp, "\t.section .debug_frame,\"\",%%progbits\n"); - fprintf(ctx->fp, - ".Lframe0:\n" - "\t.long .LECIE0-.LSCIE0\n" - ".LSCIE0:\n" - "\t.long 0xffffffff\n" - "\t.byte 0x1\n" - "\t.string \"\"\n" - "\t.uleb128 0x1\n" - "\t.sleb128 -4\n" - "\t.byte 0xe\n" /* Return address is in lr. */ - "\t.byte 0xc\n\t.uleb128 0xd\n\t.uleb128 0\n" /* def_cfa sp */ - "\t.align 2\n" - ".LECIE0:\n\n"); - fprintf(ctx->fp, - ".LSFDE0:\n" - "\t.long .LEFDE0-.LASFDE0\n" - ".LASFDE0:\n" - "\t.long .Lframe0\n" - "\t.long .Lbegin\n" - "\t.long %d\n" - "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ - "\t.byte 0x8e\n\t.uleb128 1\n", /* offset lr */ - fcofs, CFRAME_SIZE); - for (i = 11; i >= (LJ_ARCH_HASFPU ? 5 : 4); i--) /* offset r4-r11 */ - fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+i, 2+(11-i)); -#if LJ_ARCH_HASFPU - for (i = 15; i >= 8; i--) /* offset d8-d15 */ - fprintf(ctx->fp, "\t.byte 5\n\t.uleb128 %d, %d\n", - 64+2*i, 10+2*(15-i)); - fprintf(ctx->fp, "\t.byte 0x84\n\t.uleb128 %d\n", 25); /* offset r4 */ -#endif - fprintf(ctx->fp, - "\t.align 2\n" - ".LEFDE0:\n\n"); -#if LJ_HASFFI - fprintf(ctx->fp, - ".LSFDE1:\n" - "\t.long .LEFDE1-.LASFDE1\n" - ".LASFDE1:\n" - "\t.long .Lframe0\n" - "\t.long lj_vm_ffi_call\n" - "\t.long %d\n" - "\t.byte 0xe\n\t.uleb128 16\n" /* def_cfa_offset */ - "\t.byte 0x8e\n\t.uleb128 1\n" /* offset lr */ - "\t.byte 0x8b\n\t.uleb128 2\n" /* offset r11 */ - "\t.byte 0x85\n\t.uleb128 3\n" /* offset r5 */ - "\t.byte 0x84\n\t.uleb128 4\n" /* offset r4 */ - "\t.byte 0xd\n\t.uleb128 0xb\n" /* def_cfa_register r11 */ - "\t.align 2\n" - ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); -#endif - break; - default: - break; - } -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/vm_mips.dasc b/source/libs/luajit/LuaJIT-2.0.3/src/vm_mips.dasc deleted file mode 100644 index 0ec13e608..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/vm_mips.dasc +++ /dev/null @@ -1,4241 +0,0 @@ -|// Low-level VM code for MIPS CPUs. -|// Bytecode interpreter, fast functions and helper functions. -|// Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -| -|.arch mips -|.section code_op, code_sub -| -|.actionlist build_actionlist -|.globals GLOB_ -|.globalnames globnames -|.externnames extnames -| -|// Note: The ragged indentation of the instructions is intentional. -|// The starting columns indicate data dependencies. -| -|//----------------------------------------------------------------------- -| -|// Fixed register assignments for the interpreter. -|// Don't use: r0 = 0, r26/r27 = reserved, r28 = gp, r29 = sp, r31 = ra -| -|// The following must be C callee-save (but BASE is often refetched). -|.define BASE, r16 // Base of current Lua stack frame. -|.define KBASE, r17 // Constants of current Lua function. -|.define PC, r18 // Next PC. -|.define DISPATCH, r19 // Opcode dispatch table. -|.define LREG, r20 // Register holding lua_State (also in SAVE_L). -|.define MULTRES, r21 // Size of multi-result: (nresults+1)*8. -|// NYI: r22 currently unused. -| -|.define JGL, r30 // On-trace: global_State + 32768. -| -|// Constants for type-comparisons, stores and conversions. C callee-save. -|.define TISNIL, r30 -|.define TOBIT, f30 // 2^52 + 2^51. -| -|// The following temporaries are not saved across C calls, except for RA. -|.define RA, r23 // Callee-save. -|.define RB, r8 -|.define RC, r9 -|.define RD, r10 -|.define INS, r11 -| -|.define AT, r1 // Assembler temporary. -|.define TMP0, r12 -|.define TMP1, r13 -|.define TMP2, r14 -|.define TMP3, r15 -| -|// Calling conventions. -|.define CFUNCADDR, r25 -|.define CARG1, r4 -|.define CARG2, r5 -|.define CARG3, r6 -|.define CARG4, r7 -| -|.define CRET1, r2 -|.define CRET2, r3 -| -|.define FARG1, f12 -|.define FARG2, f14 -| -|.define FRET1, f0 -|.define FRET2, f2 -| -|// Stack layout while in interpreter. Must match with lj_frame.h. -|.define CFRAME_SPACE, 112 // Delta for sp. -| -|.define SAVE_ERRF, 124(sp) // 32 bit C frame info. -|.define SAVE_NRES, 120(sp) -|.define SAVE_CFRAME, 116(sp) -|.define SAVE_L, 112(sp) -|//----- 8 byte aligned, ^^^^ 16 byte register save area, owned by interpreter. -|.define SAVE_GPR_, 72 // .. 72+10*4: 32 bit GPR saves. -|.define SAVE_FPR_, 24 // .. 24+6*8: 64 bit FPR saves. -|.define SAVE_PC, 20(sp) -|.define ARG5, 16(sp) -|.define CSAVE_4, 12(sp) -|.define CSAVE_3, 8(sp) -|.define CSAVE_2, 4(sp) -|.define CSAVE_1, 0(sp) -|//----- 8 byte aligned, ^^^^ 16 byte register save area, owned by callee. -| -|.define ARG5_OFS, 16 -|.define SAVE_MULTRES, ARG5 -| -|.macro saveregs -| addiu sp, sp, -CFRAME_SPACE -| sw ra, SAVE_GPR_+9*4(sp) -| sw r30, SAVE_GPR_+8*4(sp) -| sdc1 f30, SAVE_FPR_+5*8(sp) -| sw r23, SAVE_GPR_+7*4(sp) -| sw r22, SAVE_GPR_+6*4(sp) -| sdc1 f28, SAVE_FPR_+4*8(sp) -| sw r21, SAVE_GPR_+5*4(sp) -| sw r20, SAVE_GPR_+4*4(sp) -| sdc1 f26, SAVE_FPR_+3*8(sp) -| sw r19, SAVE_GPR_+3*4(sp) -| sw r18, SAVE_GPR_+2*4(sp) -| sdc1 f24, SAVE_FPR_+2*8(sp) -| sw r17, SAVE_GPR_+1*4(sp) -| sw r16, SAVE_GPR_+0*4(sp) -| sdc1 f22, SAVE_FPR_+1*8(sp) -| sdc1 f20, SAVE_FPR_+0*8(sp) -|.endmacro -| -|.macro restoreregs_ret -| lw ra, SAVE_GPR_+9*4(sp) -| lw r30, SAVE_GPR_+8*4(sp) -| ldc1 f30, SAVE_FPR_+5*8(sp) -| lw r23, SAVE_GPR_+7*4(sp) -| lw r22, SAVE_GPR_+6*4(sp) -| ldc1 f28, SAVE_FPR_+4*8(sp) -| lw r21, SAVE_GPR_+5*4(sp) -| lw r20, SAVE_GPR_+4*4(sp) -| ldc1 f26, SAVE_FPR_+3*8(sp) -| lw r19, SAVE_GPR_+3*4(sp) -| lw r18, SAVE_GPR_+2*4(sp) -| ldc1 f24, SAVE_FPR_+2*8(sp) -| lw r17, SAVE_GPR_+1*4(sp) -| lw r16, SAVE_GPR_+0*4(sp) -| ldc1 f22, SAVE_FPR_+1*8(sp) -| ldc1 f20, SAVE_FPR_+0*8(sp) -| jr ra -| addiu sp, sp, CFRAME_SPACE -|.endmacro -| -|// Type definitions. Some of these are only used for documentation. -|.type L, lua_State, LREG -|.type GL, global_State -|.type TVALUE, TValue -|.type GCOBJ, GCobj -|.type STR, GCstr -|.type TAB, GCtab -|.type LFUNC, GCfuncL -|.type CFUNC, GCfuncC -|.type PROTO, GCproto -|.type UPVAL, GCupval -|.type NODE, Node -|.type NARGS8, int -|.type TRACE, GCtrace -| -|//----------------------------------------------------------------------- -| -|// Trap for not-yet-implemented parts. -|.macro NYI; .long 0xf0f0f0f0; .endmacro -| -|// Macros to mark delay slots. -|.macro ., a; a; .endmacro -|.macro ., a,b; a,b; .endmacro -|.macro ., a,b,c; a,b,c; .endmacro -| -|//----------------------------------------------------------------------- -| -|// Endian-specific defines. -|.define FRAME_PC, LJ_ENDIAN_SELECT(-4,-8) -|.define FRAME_FUNC, LJ_ENDIAN_SELECT(-8,-4) -|.define HI, LJ_ENDIAN_SELECT(4,0) -|.define LO, LJ_ENDIAN_SELECT(0,4) -|.define OFS_RD, LJ_ENDIAN_SELECT(2,0) -|.define OFS_RA, LJ_ENDIAN_SELECT(1,2) -|.define OFS_OP, LJ_ENDIAN_SELECT(0,3) -| -|// Instruction decode. -|.macro decode_OP1, dst, ins; andi dst, ins, 0xff; .endmacro -|.macro decode_OP4a, dst, ins; andi dst, ins, 0xff; .endmacro -|.macro decode_OP4b, dst; sll dst, dst, 2; .endmacro -|.macro decode_RC4a, dst, ins; srl dst, ins, 14; .endmacro -|.macro decode_RC4b, dst; andi dst, dst, 0x3fc; .endmacro -|.macro decode_RD4b, dst; sll dst, dst, 2; .endmacro -|.macro decode_RA8a, dst, ins; srl dst, ins, 5; .endmacro -|.macro decode_RA8b, dst; andi dst, dst, 0x7f8; .endmacro -|.macro decode_RB8a, dst, ins; srl dst, ins, 21; .endmacro -|.macro decode_RB8b, dst; andi dst, dst, 0x7f8; .endmacro -|.macro decode_RD8a, dst, ins; srl dst, ins, 16; .endmacro -|.macro decode_RD8b, dst; sll dst, dst, 3; .endmacro -|.macro decode_RDtoRC8, dst, src; andi dst, src, 0x7f8; .endmacro -| -|// Instruction fetch. -|.macro ins_NEXT1 -| lw INS, 0(PC) -| addiu PC, PC, 4 -|.endmacro -|// Instruction decode+dispatch. -|.macro ins_NEXT2 -| decode_OP4a TMP1, INS -| decode_OP4b TMP1 -| addu TMP0, DISPATCH, TMP1 -| decode_RD8a RD, INS -| lw AT, 0(TMP0) -| decode_RA8a RA, INS -| decode_RD8b RD -| jr AT -| decode_RA8b RA -|.endmacro -|.macro ins_NEXT -| ins_NEXT1 -| ins_NEXT2 -|.endmacro -| -|// Instruction footer. -|.if 1 -| // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. -| .define ins_next, ins_NEXT -| .define ins_next_, ins_NEXT -| .define ins_next1, ins_NEXT1 -| .define ins_next2, ins_NEXT2 -|.else -| // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. -| // Affects only certain kinds of benchmarks (and only with -j off). -| .macro ins_next -| b ->ins_next -| .endmacro -| .macro ins_next1 -| .endmacro -| .macro ins_next2 -| b ->ins_next -| .endmacro -| .macro ins_next_ -| ->ins_next: -| ins_NEXT -| .endmacro -|.endif -| -|// Call decode and dispatch. -|.macro ins_callt -| // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC -| lw PC, LFUNC:RB->pc -| lw INS, 0(PC) -| addiu PC, PC, 4 -| decode_OP4a TMP1, INS -| decode_RA8a RA, INS -| decode_OP4b TMP1 -| decode_RA8b RA -| addu TMP0, DISPATCH, TMP1 -| lw TMP0, 0(TMP0) -| jr TMP0 -| addu RA, RA, BASE -|.endmacro -| -|.macro ins_call -| // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, PC = caller PC -| sw PC, FRAME_PC(BASE) -| ins_callt -|.endmacro -| -|//----------------------------------------------------------------------- -| -|.macro branch_RD -| srl TMP0, RD, 1 -| lui AT, (-(BCBIAS_J*4 >> 16) & 65535) -| addu TMP0, TMP0, AT -| addu PC, PC, TMP0 -|.endmacro -| -|// Assumes DISPATCH is relative to GL. -#define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) -#define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) -#define GG_DISP2GOT (GG_OFS(got) - GG_OFS(dispatch)) -#define DISPATCH_GOT(name) (GG_DISP2GOT + 4*LJ_GOT_##name) -| -#define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) -| -|.macro load_got, func -| lw CFUNCADDR, DISPATCH_GOT(func)(DISPATCH) -|.endmacro -|// Much faster. Sadly, there's no easy way to force the required code layout. -|// .macro call_intern, func; bal extern func; .endmacro -|.macro call_intern, func; jalr CFUNCADDR; .endmacro -|.macro call_extern; jalr CFUNCADDR; .endmacro -|.macro jmp_extern; jr CFUNCADDR; .endmacro -| -|.macro hotcheck, delta, target -| srl TMP1, PC, 1 -| andi TMP1, TMP1, 126 -| addu TMP1, TMP1, DISPATCH -| lhu TMP2, GG_DISP2HOT(TMP1) -| addiu TMP2, TMP2, -delta -| bltz TMP2, target -|. sh TMP2, GG_DISP2HOT(TMP1) -|.endmacro -| -|.macro hotloop -| hotcheck HOTCOUNT_LOOP, ->vm_hotloop -|.endmacro -| -|.macro hotcall -| hotcheck HOTCOUNT_CALL, ->vm_hotcall -|.endmacro -| -|// Set current VM state. Uses TMP0. -|.macro li_vmstate, st; li TMP0, ~LJ_VMST_..st; .endmacro -|.macro st_vmstate; sw TMP0, DISPATCH_GL(vmstate)(DISPATCH); .endmacro -| -|// Move table write barrier back. Overwrites mark and tmp. -|.macro barrierback, tab, mark, tmp, target -| lw tmp, DISPATCH_GL(gc.grayagain)(DISPATCH) -| andi mark, mark, ~LJ_GC_BLACK & 255 // black2gray(tab) -| sw tab, DISPATCH_GL(gc.grayagain)(DISPATCH) -| sb mark, tab->marked -| b target -|. sw tmp, tab->gclist -|.endmacro -| -|//----------------------------------------------------------------------- - -/* Generate subroutines used by opcodes and other parts of the VM. */ -/* The .code_sub section should be last to help static branch prediction. */ -static void build_subroutines(BuildCtx *ctx) -{ - |.code_sub - | - |//----------------------------------------------------------------------- - |//-- Return handling ---------------------------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_returnp: - | // See vm_return. Also: TMP2 = previous base. - | andi AT, PC, FRAME_P - | beqz AT, ->cont_dispatch - |. li TMP1, LJ_TTRUE - | - | // Return from pcall or xpcall fast func. - | lw PC, FRAME_PC(TMP2) // Fetch PC of previous frame. - | move BASE, TMP2 // Restore caller base. - | // Prepending may overwrite the pcall frame, so do it at the end. - | sw TMP1, FRAME_PC(RA) // Prepend true to results. - | addiu RA, RA, -8 - | - |->vm_returnc: - | addiu RD, RD, 8 // RD = (nresults+1)*8. - | andi TMP0, PC, FRAME_TYPE - | beqz RD, ->vm_unwind_c_eh - |. li CRET1, LUA_YIELD - | beqz TMP0, ->BC_RET_Z // Handle regular return to Lua. - |. move MULTRES, RD - | - |->vm_return: - | // BASE = base, RA = resultptr, RD/MULTRES = (nresults+1)*8, PC = return - | // TMP0 = PC & FRAME_TYPE - | li TMP2, -8 - | xori AT, TMP0, FRAME_C - | and TMP2, PC, TMP2 - | bnez AT, ->vm_returnp - | subu TMP2, BASE, TMP2 // TMP2 = previous base. - | - | addiu TMP1, RD, -8 - | sw TMP2, L->base - | li_vmstate C - | lw TMP2, SAVE_NRES - | addiu BASE, BASE, -8 - | st_vmstate - | beqz TMP1, >2 - |. sll TMP2, TMP2, 3 - |1: - | addiu TMP1, TMP1, -8 - | ldc1 f0, 0(RA) - | addiu RA, RA, 8 - | sdc1 f0, 0(BASE) - | bnez TMP1, <1 - |. addiu BASE, BASE, 8 - | - |2: - | bne TMP2, RD, >6 - |3: - |. sw BASE, L->top // Store new top. - | - |->vm_leave_cp: - | lw TMP0, SAVE_CFRAME // Restore previous C frame. - | move CRET1, r0 // Ok return status for vm_pcall. - | sw TMP0, L->cframe - | - |->vm_leave_unw: - | restoreregs_ret - | - |6: - | lw TMP1, L->maxstack - | slt AT, TMP2, RD - | bnez AT, >7 // Less results wanted? - | // More results wanted. Check stack size and fill up results with nil. - |. slt AT, BASE, TMP1 - | beqz AT, >8 - |. nop - | sw TISNIL, HI(BASE) - | addiu RD, RD, 8 - | b <2 - |. addiu BASE, BASE, 8 - | - |7: // Less results wanted. - | subu TMP0, RD, TMP2 - | subu TMP0, BASE, TMP0 // Either keep top or shrink it. - | b <3 - |. movn BASE, TMP0, TMP2 // LUA_MULTRET+1 case? - | - |8: // Corner case: need to grow stack for filling up results. - | // This can happen if: - | // - A C function grows the stack (a lot). - | // - The GC shrinks the stack in between. - | // - A return back from a lua_call() with (high) nresults adjustment. - | load_got lj_state_growstack - | move MULTRES, RD - | move CARG2, TMP2 - | call_intern lj_state_growstack // (lua_State *L, int n) - |. move CARG1, L - | lw TMP2, SAVE_NRES - | lw BASE, L->top // Need the (realloced) L->top in BASE. - | move RD, MULTRES - | b <2 - |. sll TMP2, TMP2, 3 - | - |->vm_unwind_c: // Unwind C stack, return from vm_pcall. - | // (void *cframe, int errcode) - | move sp, CARG1 - | move CRET1, CARG2 - |->vm_unwind_c_eh: // Landing pad for external unwinder. - | lw L, SAVE_L - | li TMP0, ~LJ_VMST_C - | lw GL:TMP1, L->glref - | b ->vm_leave_unw - |. sw TMP0, GL:TMP1->vmstate - | - |->vm_unwind_ff: // Unwind C stack, return from ff pcall. - | // (void *cframe) - | li AT, -4 - | and sp, CARG1, AT - |->vm_unwind_ff_eh: // Landing pad for external unwinder. - | lw L, SAVE_L - | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). - | li TISNIL, LJ_TNIL - | lw BASE, L->base - | lw DISPATCH, L->glref // Setup pointer to dispatch table. - | mtc1 TMP3, TOBIT - | li TMP1, LJ_TFALSE - | li_vmstate INTERP - | lw PC, FRAME_PC(BASE) // Fetch PC of previous frame. - | cvt.d.s TOBIT, TOBIT - | addiu RA, BASE, -8 // Results start at BASE-8. - | addiu DISPATCH, DISPATCH, GG_G2DISP - | sw TMP1, HI(RA) // Prepend false to error message. - | st_vmstate - | b ->vm_returnc - |. li RD, 16 // 2 results: false + error message. - | - |//----------------------------------------------------------------------- - |//-- Grow stack for calls ----------------------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_growstack_c: // Grow stack for C function. - | b >2 - |. li CARG2, LUA_MINSTACK - | - |->vm_growstack_l: // Grow stack for Lua function. - | // BASE = new base, RA = BASE+framesize*8, RC = nargs*8, PC = first PC - | addu RC, BASE, RC - | subu RA, RA, BASE - | sw BASE, L->base - | addiu PC, PC, 4 // Must point after first instruction. - | sw RC, L->top - | srl CARG2, RA, 3 - |2: - | // L->base = new base, L->top = top - | load_got lj_state_growstack - | sw PC, SAVE_PC - | call_intern lj_state_growstack // (lua_State *L, int n) - |. move CARG1, L - | lw BASE, L->base - | lw RC, L->top - | lw LFUNC:RB, FRAME_FUNC(BASE) - | subu RC, RC, BASE - | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC - | ins_callt // Just retry the call. - | - |//----------------------------------------------------------------------- - |//-- Entry points into the assembler VM --------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_resume: // Setup C frame and resume thread. - | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) - | saveregs - | move L, CARG1 - | lw DISPATCH, L->glref // Setup pointer to dispatch table. - | move BASE, CARG2 - | lbu TMP1, L->status - | sw L, SAVE_L - | li PC, FRAME_CP - | addiu TMP0, sp, CFRAME_RESUME - | addiu DISPATCH, DISPATCH, GG_G2DISP - | sw r0, SAVE_NRES - | sw r0, SAVE_ERRF - | sw TMP0, L->cframe - | sw r0, SAVE_CFRAME - | beqz TMP1, >3 - |. sw CARG1, SAVE_PC // Any value outside of bytecode is ok. - | - | // Resume after yield (like a return). - | move RA, BASE - | lw BASE, L->base - | lw TMP1, L->top - | lw PC, FRAME_PC(BASE) - | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). - | subu RD, TMP1, BASE - | mtc1 TMP3, TOBIT - | sb r0, L->status - | cvt.d.s TOBIT, TOBIT - | li_vmstate INTERP - | addiu RD, RD, 8 - | st_vmstate - | move MULTRES, RD - | andi TMP0, PC, FRAME_TYPE - | beqz TMP0, ->BC_RET_Z - |. li TISNIL, LJ_TNIL - | b ->vm_return - |. nop - | - |->vm_pcall: // Setup protected C frame and enter VM. - | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) - | saveregs - | sw CARG4, SAVE_ERRF - | b >1 - |. li PC, FRAME_CP - | - |->vm_call: // Setup C frame and enter VM. - | // (lua_State *L, TValue *base, int nres1) - | saveregs - | li PC, FRAME_C - | - |1: // Entry point for vm_pcall above (PC = ftype). - | lw TMP1, L:CARG1->cframe - | sw CARG3, SAVE_NRES - | move L, CARG1 - | sw CARG1, SAVE_L - | move BASE, CARG2 - | sw sp, L->cframe // Add our C frame to cframe chain. - | lw DISPATCH, L->glref // Setup pointer to dispatch table. - | sw CARG1, SAVE_PC // Any value outside of bytecode is ok. - | sw TMP1, SAVE_CFRAME - | addiu DISPATCH, DISPATCH, GG_G2DISP - | - |3: // Entry point for vm_cpcall/vm_resume (BASE = base, PC = ftype). - | lw TMP2, L->base // TMP2 = old base (used in vmeta_call). - | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). - | lw TMP1, L->top - | mtc1 TMP3, TOBIT - | addu PC, PC, BASE - | subu NARGS8:RC, TMP1, BASE - | subu PC, PC, TMP2 // PC = frame delta + frame type - | cvt.d.s TOBIT, TOBIT - | li_vmstate INTERP - | li TISNIL, LJ_TNIL - | st_vmstate - | - |->vm_call_dispatch: - | // TMP2 = old base, BASE = new base, RC = nargs*8, PC = caller PC - | lw TMP0, FRAME_PC(BASE) - | li AT, LJ_TFUNC - | bne TMP0, AT, ->vmeta_call - |. lw LFUNC:RB, FRAME_FUNC(BASE) - | - |->vm_call_dispatch_f: - | ins_call - | // BASE = new base, RB = func, RC = nargs*8, PC = caller PC - | - |->vm_cpcall: // Setup protected C frame, call C. - | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) - | saveregs - | move L, CARG1 - | lw TMP0, L:CARG1->stack - | sw CARG1, SAVE_L - | lw TMP1, L->top - | sw CARG1, SAVE_PC // Any value outside of bytecode is ok. - | subu TMP0, TMP0, TMP1 // Compute -savestack(L, L->top). - | lw TMP1, L->cframe - | sw sp, L->cframe // Add our C frame to cframe chain. - | sw TMP0, SAVE_NRES // Neg. delta means cframe w/o frame. - | sw r0, SAVE_ERRF // No error function. - | move CFUNCADDR, CARG4 - | jalr CARG4 // (lua_State *L, lua_CFunction func, void *ud) - |. sw TMP1, SAVE_CFRAME - | move BASE, CRET1 - | lw DISPATCH, L->glref // Setup pointer to dispatch table. - | li PC, FRAME_CP - | bnez CRET1, <3 // Else continue with the call. - |. addiu DISPATCH, DISPATCH, GG_G2DISP - | b ->vm_leave_cp // No base? Just remove C frame. - |. nop - | - |//----------------------------------------------------------------------- - |//-- Metamethod handling ------------------------------------------------ - |//----------------------------------------------------------------------- - | - |// The lj_meta_* functions (except for lj_meta_cat) don't reallocate the - |// stack, so BASE doesn't need to be reloaded across these calls. - | - |//-- Continuation dispatch ---------------------------------------------- - | - |->cont_dispatch: - | // BASE = meta base, RA = resultptr, RD = (nresults+1)*8 - | lw TMP0, -16+LO(BASE) // Continuation. - | move RB, BASE - | move BASE, TMP2 // Restore caller BASE. - | lw LFUNC:TMP1, FRAME_FUNC(TMP2) - |.if FFI - | sltiu AT, TMP0, 2 - |.endif - | lw PC, -16+HI(RB) // Restore PC from [cont|PC]. - | addu TMP2, RA, RD - | lw TMP1, LFUNC:TMP1->pc - |.if FFI - | bnez AT, >1 - |.endif - |. sw TISNIL, -8+HI(TMP2) // Ensure one valid arg. - | // BASE = base, RA = resultptr, RB = meta base - | jr TMP0 // Jump to continuation. - |. lw KBASE, PC2PROTO(k)(TMP1) - | - |.if FFI - |1: - | bnez TMP0, ->cont_ffi_callback // cont = 1: return from FFI callback. - | // cont = 0: tailcall from C function. - |. addiu TMP1, RB, -16 - | b ->vm_call_tail - |. subu RC, TMP1, BASE - |.endif - | - |->cont_cat: // RA = resultptr, RB = meta base - | lw INS, -4(PC) - | addiu CARG2, RB, -16 - | ldc1 f0, 0(RA) - | decode_RB8a MULTRES, INS - | decode_RA8a RA, INS - | decode_RB8b MULTRES - | decode_RA8b RA - | addu TMP1, BASE, MULTRES - | sw BASE, L->base - | subu CARG3, CARG2, TMP1 - | bne TMP1, CARG2, ->BC_CAT_Z - |. sdc1 f0, 0(CARG2) - | addu RA, BASE, RA - | b ->cont_nop - |. sdc1 f0, 0(RA) - | - |//-- Table indexing metamethods ----------------------------------------- - | - |->vmeta_tgets1: - | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) - | li TMP0, LJ_TSTR - | sw STR:RC, LO(CARG3) - | b >1 - |. sw TMP0, HI(CARG3) - | - |->vmeta_tgets: - | addiu CARG2, DISPATCH, DISPATCH_GL(tmptv) - | li TMP0, LJ_TTAB - | sw TAB:RB, LO(CARG2) - | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv2) - | sw TMP0, HI(CARG2) - | li TMP1, LJ_TSTR - | sw STR:RC, LO(CARG3) - | b >1 - |. sw TMP1, HI(CARG3) - | - |->vmeta_tgetb: // TMP0 = index - | mtc1 TMP0, f0 - | cvt.d.w f0, f0 - | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) - | sdc1 f0, 0(CARG3) - | - |->vmeta_tgetv: - |1: - | load_got lj_meta_tget - | sw BASE, L->base - | sw PC, SAVE_PC - | call_intern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) - |. move CARG1, L - | // Returns TValue * (finished) or NULL (metamethod). - | beqz CRET1, >3 - |. addiu TMP1, BASE, -FRAME_CONT - | ldc1 f0, 0(CRET1) - | ins_next1 - | sdc1 f0, 0(RA) - | ins_next2 - | - |3: // Call __index metamethod. - | // BASE = base, L->top = new base, stack = cont/func/t/k - | lw BASE, L->top - | sw PC, -16+HI(BASE) // [cont|PC] - | subu PC, BASE, TMP1 - | lw LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. - | b ->vm_call_dispatch_f - |. li NARGS8:RC, 16 // 2 args for func(t, k). - | - |//----------------------------------------------------------------------- - | - |->vmeta_tsets1: - | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) - | li TMP0, LJ_TSTR - | sw STR:RC, LO(CARG3) - | b >1 - |. sw TMP0, HI(CARG3) - | - |->vmeta_tsets: - | addiu CARG2, DISPATCH, DISPATCH_GL(tmptv) - | li TMP0, LJ_TTAB - | sw TAB:RB, LO(CARG2) - | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv2) - | sw TMP0, HI(CARG2) - | li TMP1, LJ_TSTR - | sw STR:RC, LO(CARG3) - | b >1 - |. sw TMP1, HI(CARG3) - | - |->vmeta_tsetb: // TMP0 = index - | mtc1 TMP0, f0 - | cvt.d.w f0, f0 - | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) - | sdc1 f0, 0(CARG3) - | - |->vmeta_tsetv: - |1: - | load_got lj_meta_tset - | sw BASE, L->base - | sw PC, SAVE_PC - | call_intern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) - |. move CARG1, L - | // Returns TValue * (finished) or NULL (metamethod). - | beqz CRET1, >3 - |. ldc1 f0, 0(RA) - | // NOBARRIER: lj_meta_tset ensures the table is not black. - | ins_next1 - | sdc1 f0, 0(CRET1) - | ins_next2 - | - |3: // Call __newindex metamethod. - | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) - | addiu TMP1, BASE, -FRAME_CONT - | lw BASE, L->top - | sw PC, -16+HI(BASE) // [cont|PC] - | subu PC, BASE, TMP1 - | lw LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. - | sdc1 f0, 16(BASE) // Copy value to third argument. - | b ->vm_call_dispatch_f - |. li NARGS8:RC, 24 // 3 args for func(t, k, v) - | - |//-- Comparison metamethods --------------------------------------------- - | - |->vmeta_comp: - | // CARG2, CARG3 are already set by BC_ISLT/BC_ISGE/BC_ISLE/BC_ISGT. - | load_got lj_meta_comp - | addiu PC, PC, -4 - | sw BASE, L->base - | sw PC, SAVE_PC - | decode_OP1 CARG4, INS - | call_intern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) - |. move CARG1, L - | // Returns 0/1 or TValue * (metamethod). - |3: - | sltiu AT, CRET1, 2 - | beqz AT, ->vmeta_binop - | negu TMP2, CRET1 - |4: - | lhu RD, OFS_RD(PC) - | addiu PC, PC, 4 - | lui TMP1, (-(BCBIAS_J*4 >> 16) & 65535) - | sll RD, RD, 2 - | addu RD, RD, TMP1 - | and RD, RD, TMP2 - | addu PC, PC, RD - |->cont_nop: - | ins_next - | - |->cont_ra: // RA = resultptr - | lbu TMP1, -4+OFS_RA(PC) - | ldc1 f0, 0(RA) - | sll TMP1, TMP1, 3 - | addu TMP1, BASE, TMP1 - | b ->cont_nop - |. sdc1 f0, 0(TMP1) - | - |->cont_condt: // RA = resultptr - | lw TMP0, HI(RA) - | sltiu AT, TMP0, LJ_TISTRUECOND - | b <4 - |. negu TMP2, AT // Branch if result is true. - | - |->cont_condf: // RA = resultptr - | lw TMP0, HI(RA) - | sltiu AT, TMP0, LJ_TISTRUECOND - | b <4 - |. addiu TMP2, AT, -1 // Branch if result is false. - | - |->vmeta_equal: - | // CARG2, CARG3, CARG4 are already set by BC_ISEQV/BC_ISNEV. - | load_got lj_meta_equal - | addiu PC, PC, -4 - | sw BASE, L->base - | sw PC, SAVE_PC - | call_intern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) - |. move CARG1, L - | // Returns 0/1 or TValue * (metamethod). - | b <3 - |. nop - | - |->vmeta_equal_cd: - |.if FFI - | load_got lj_meta_equal_cd - | move CARG2, INS - | addiu PC, PC, -4 - | sw BASE, L->base - | sw PC, SAVE_PC - | call_intern lj_meta_equal_cd // (lua_State *L, BCIns op) - |. move CARG1, L - | // Returns 0/1 or TValue * (metamethod). - | b <3 - |. nop - |.endif - | - |//-- Arithmetic metamethods --------------------------------------------- - | - |->vmeta_unm: - | move CARG4, CARG3 - | - |->vmeta_arith: - | load_got lj_meta_arith - | decode_OP1 TMP0, INS - | sw BASE, L->base - | sw PC, SAVE_PC - | move CARG2, RA - | sw TMP0, ARG5 - | call_intern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) - |. move CARG1, L - | // Returns NULL (finished) or TValue * (metamethod). - | beqz CRET1, ->cont_nop - |. nop - | - | // Call metamethod for binary op. - |->vmeta_binop: - | // BASE = old base, CRET1 = new base, stack = cont/func/o1/o2 - | subu TMP1, CRET1, BASE - | sw PC, -16+HI(CRET1) // [cont|PC] - | move TMP2, BASE - | addiu PC, TMP1, FRAME_CONT - | move BASE, CRET1 - | b ->vm_call_dispatch - |. li NARGS8:RC, 16 // 2 args for func(o1, o2). - | - |->vmeta_len: - | // CARG2 already set by BC_LEN. -#if LJ_52 - | move MULTRES, CARG1 -#endif - | load_got lj_meta_len - | sw BASE, L->base - | sw PC, SAVE_PC - | call_intern lj_meta_len // (lua_State *L, TValue *o) - |. move CARG1, L - | // Returns NULL (retry) or TValue * (metamethod base). -#if LJ_52 - | bnez CRET1, ->vmeta_binop // Binop call for compatibility. - |. nop - | b ->BC_LEN_Z - |. move CARG1, MULTRES -#else - | b ->vmeta_binop // Binop call for compatibility. - |. nop -#endif - | - |//-- Call metamethod ---------------------------------------------------- - | - |->vmeta_call: // Resolve and call __call metamethod. - | // TMP2 = old base, BASE = new base, RC = nargs*8 - | load_got lj_meta_call - | sw TMP2, L->base // This is the callers base! - | addiu CARG2, BASE, -8 - | sw PC, SAVE_PC - | addu CARG3, BASE, RC - | move MULTRES, NARGS8:RC - | call_intern lj_meta_call // (lua_State *L, TValue *func, TValue *top) - |. move CARG1, L - | lw LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. - | addiu NARGS8:RC, MULTRES, 8 // Got one more argument now. - | ins_call - | - |->vmeta_callt: // Resolve __call for BC_CALLT. - | // BASE = old base, RA = new base, RC = nargs*8 - | load_got lj_meta_call - | sw BASE, L->base - | addiu CARG2, RA, -8 - | sw PC, SAVE_PC - | addu CARG3, RA, RC - | move MULTRES, NARGS8:RC - | call_intern lj_meta_call // (lua_State *L, TValue *func, TValue *top) - |. move CARG1, L - | lw TMP1, FRAME_PC(BASE) - | lw LFUNC:RB, FRAME_FUNC(RA) // Guaranteed to be a function here. - | b ->BC_CALLT_Z - |. addiu NARGS8:RC, MULTRES, 8 // Got one more argument now. - | - |//-- Argument coercion for 'for' statement ------------------------------ - | - |->vmeta_for: - | load_got lj_meta_for - | sw BASE, L->base - | move CARG2, RA - | sw PC, SAVE_PC - | move MULTRES, INS - | call_intern lj_meta_for // (lua_State *L, TValue *base) - |. move CARG1, L - |.if JIT - | decode_OP1 TMP0, MULTRES - | li AT, BC_JFORI - |.endif - | decode_RA8a RA, MULTRES - | decode_RD8a RD, MULTRES - | decode_RA8b RA - |.if JIT - | beq TMP0, AT, =>BC_JFORI - |. decode_RD8b RD - | b =>BC_FORI - |. nop - |.else - | b =>BC_FORI - |. decode_RD8b RD - |.endif - | - |//----------------------------------------------------------------------- - |//-- Fast functions ----------------------------------------------------- - |//----------------------------------------------------------------------- - | - |.macro .ffunc, name - |->ff_ .. name: - |.endmacro - | - |.macro .ffunc_1, name - |->ff_ .. name: - | beqz NARGS8:RC, ->fff_fallback - |. lw CARG3, HI(BASE) - | lw CARG1, LO(BASE) - |.endmacro - | - |.macro .ffunc_2, name - |->ff_ .. name: - | sltiu AT, NARGS8:RC, 16 - | lw CARG3, HI(BASE) - | bnez AT, ->fff_fallback - |. lw CARG4, 8+HI(BASE) - | lw CARG1, LO(BASE) - | lw CARG2, 8+LO(BASE) - |.endmacro - | - |.macro .ffunc_n, name // Caveat: has delay slot! - |->ff_ .. name: - | lw CARG3, HI(BASE) - | beqz NARGS8:RC, ->fff_fallback - |. ldc1 FARG1, 0(BASE) - | sltiu AT, CARG3, LJ_TISNUM - | beqz AT, ->fff_fallback - |.endmacro - | - |.macro .ffunc_nn, name // Caveat: has delay slot! - |->ff_ .. name: - | sltiu AT, NARGS8:RC, 16 - | lw CARG3, HI(BASE) - | bnez AT, ->fff_fallback - |. lw CARG4, 8+HI(BASE) - | ldc1 FARG1, 0(BASE) - | ldc1 FARG2, 8(BASE) - | sltiu TMP0, CARG3, LJ_TISNUM - | sltiu TMP1, CARG4, LJ_TISNUM - | and TMP0, TMP0, TMP1 - | beqz TMP0, ->fff_fallback - |.endmacro - | - |// Inlined GC threshold check. Caveat: uses TMP0 and TMP1 and has delay slot! - |.macro ffgccheck - | lw TMP0, DISPATCH_GL(gc.total)(DISPATCH) - | lw TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) - | subu AT, TMP0, TMP1 - | bgezal AT, ->fff_gcstep - |.endmacro - | - |//-- Base library: checks ----------------------------------------------- - | - |.ffunc_1 assert - | sltiu AT, CARG3, LJ_TISTRUECOND - | beqz AT, ->fff_fallback - |. addiu RA, BASE, -8 - | lw PC, FRAME_PC(BASE) - | addiu RD, NARGS8:RC, 8 // Compute (nresults+1)*8. - | addu TMP2, RA, NARGS8:RC - | sw CARG3, HI(RA) - | addiu TMP1, BASE, 8 - | beq BASE, TMP2, ->fff_res // Done if exactly 1 argument. - |. sw CARG1, LO(RA) - |1: - | ldc1 f0, 0(TMP1) - | sdc1 f0, -8(TMP1) - | bne TMP1, TMP2, <1 - |. addiu TMP1, TMP1, 8 - | b ->fff_res - |. nop - | - |.ffunc type - | lw CARG3, HI(BASE) - | li TMP1, LJ_TISNUM - | beqz NARGS8:RC, ->fff_fallback - |. sltiu TMP0, CARG3, LJ_TISNUM - | movz TMP1, CARG3, TMP0 - | not TMP1, TMP1 - | sll TMP1, TMP1, 3 - | addu TMP1, CFUNC:RB, TMP1 - | b ->fff_resn - |. ldc1 FRET1, CFUNC:TMP1->upvalue - | - |//-- Base library: getters and setters --------------------------------- - | - |.ffunc_1 getmetatable - | li AT, LJ_TTAB - | bne CARG3, AT, >6 - |. li AT, LJ_TUDATA - |1: // Field metatable must be at same offset for GCtab and GCudata! - | lw TAB:CARG1, TAB:CARG1->metatable - |2: - | lw STR:RC, DISPATCH_GL(gcroot[GCROOT_MMNAME+MM_metatable])(DISPATCH) - | beqz TAB:CARG1, ->fff_restv - |. li CARG3, LJ_TNIL - | lw TMP0, TAB:CARG1->hmask - | li CARG3, LJ_TTAB // Use metatable as default result. - | lw TMP1, STR:RC->hash - | lw NODE:TMP2, TAB:CARG1->node - | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask - | sll TMP0, TMP1, 5 - | sll TMP1, TMP1, 3 - | subu TMP1, TMP0, TMP1 - | addu NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) - | li AT, LJ_TSTR - |3: // Rearranged logic, because we expect _not_ to find the key. - | lw CARG4, offsetof(Node, key)+HI(NODE:TMP2) - | lw TMP0, offsetof(Node, key)+LO(NODE:TMP2) - | lw NODE:TMP3, NODE:TMP2->next - | bne CARG4, AT, >4 - |. lw CARG2, offsetof(Node, val)+HI(NODE:TMP2) - | beq TMP0, STR:RC, >5 - |. lw TMP1, offsetof(Node, val)+LO(NODE:TMP2) - |4: - | beqz NODE:TMP3, ->fff_restv // Not found, keep default result. - |. move NODE:TMP2, NODE:TMP3 - | b <3 - |. nop - |5: - | beq CARG2, TISNIL, ->fff_restv // Ditto for nil value. - |. nop - | move CARG3, CARG2 // Return value of mt.__metatable. - | b ->fff_restv - |. move CARG1, TMP1 - | - |6: - | beq CARG3, AT, <1 - |. sltiu TMP0, CARG3, LJ_TISNUM - | li TMP1, LJ_TISNUM - | movz TMP1, CARG3, TMP0 - | not TMP1, TMP1 - | sll TMP1, TMP1, 2 - | addu TMP1, DISPATCH, TMP1 - | b <2 - |. lw TAB:CARG1, DISPATCH_GL(gcroot[GCROOT_BASEMT])(TMP1) - | - |.ffunc_2 setmetatable - | // Fast path: no mt for table yet and not clearing the mt. - | li AT, LJ_TTAB - | bne CARG3, AT, ->fff_fallback - |. addiu CARG4, CARG4, -LJ_TTAB - | lw TAB:TMP1, TAB:CARG1->metatable - | lbu TMP3, TAB:CARG1->marked - | or AT, CARG4, TAB:TMP1 - | bnez AT, ->fff_fallback - |. andi AT, TMP3, LJ_GC_BLACK // isblack(table) - | beqz AT, ->fff_restv - |. sw TAB:CARG2, TAB:CARG1->metatable - | barrierback TAB:CARG1, TMP3, TMP0, ->fff_restv - | - |.ffunc rawget - | lw CARG4, HI(BASE) - | sltiu AT, NARGS8:RC, 16 - | lw TAB:CARG2, LO(BASE) - | load_got lj_tab_get - | addiu CARG4, CARG4, -LJ_TTAB - | or AT, AT, CARG4 - | bnez AT, ->fff_fallback - | addiu CARG3, BASE, 8 - | call_intern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) - |. move CARG1, L - | // Returns cTValue *. - | b ->fff_resn - |. ldc1 FRET1, 0(CRET1) - | - |//-- Base library: conversions ------------------------------------------ - | - |.ffunc tonumber - | // Only handles the number case inline (without a base argument). - | lw CARG1, HI(BASE) - | xori AT, NARGS8:RC, 8 - | sltiu CARG1, CARG1, LJ_TISNUM - | movn CARG1, r0, AT - | beqz CARG1, ->fff_fallback // Exactly one number argument. - |. ldc1 FRET1, 0(BASE) - | b ->fff_resn - |. nop - | - |.ffunc_1 tostring - | // Only handles the string or number case inline. - | li AT, LJ_TSTR - | // A __tostring method in the string base metatable is ignored. - | beq CARG3, AT, ->fff_restv // String key? - | // Handle numbers inline, unless a number base metatable is present. - |. lw TMP1, DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])(DISPATCH) - | sltiu TMP0, CARG3, LJ_TISNUM - | sltiu TMP1, TMP1, 1 - | and TMP0, TMP0, TMP1 - | beqz TMP0, ->fff_fallback - |. sw BASE, L->base // Add frame since C call can throw. - | ffgccheck - |. sw PC, SAVE_PC // Redundant (but a defined value). - | load_got lj_str_fromnum - | move CARG1, L - | call_intern lj_str_fromnum // (lua_State *L, lua_Number *np) - |. move CARG2, BASE - | // Returns GCstr *. - | li CARG3, LJ_TSTR - | b ->fff_restv - |. move CARG1, CRET1 - | - |//-- Base library: iterators ------------------------------------------- - | - |.ffunc next - | lw CARG1, HI(BASE) - | lw TAB:CARG2, LO(BASE) - | beqz NARGS8:RC, ->fff_fallback - |. addu TMP2, BASE, NARGS8:RC - | li AT, LJ_TTAB - | sw TISNIL, HI(TMP2) // Set missing 2nd arg to nil. - | bne CARG1, AT, ->fff_fallback - |. lw PC, FRAME_PC(BASE) - | load_got lj_tab_next - | sw BASE, L->base // Add frame since C call can throw. - | sw BASE, L->top // Dummy frame length is ok. - | addiu CARG3, BASE, 8 - | sw PC, SAVE_PC - | call_intern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) - |. move CARG1, L - | // Returns 0 at end of traversal. - | beqz CRET1, ->fff_restv // End of traversal: return nil. - |. li CARG3, LJ_TNIL - | ldc1 f0, 8(BASE) // Copy key and value to results. - | addiu RA, BASE, -8 - | ldc1 f2, 16(BASE) - | li RD, (2+1)*8 - | sdc1 f0, 0(RA) - | b ->fff_res - |. sdc1 f2, 8(RA) - | - |.ffunc_1 pairs - | li AT, LJ_TTAB - | bne CARG3, AT, ->fff_fallback - |. lw PC, FRAME_PC(BASE) -#if LJ_52 - | lw TAB:TMP2, TAB:CARG1->metatable - | ldc1 f0, CFUNC:RB->upvalue[0] - | bnez TAB:TMP2, ->fff_fallback -#else - | ldc1 f0, CFUNC:RB->upvalue[0] -#endif - |. addiu RA, BASE, -8 - | sw TISNIL, 8+HI(BASE) - | li RD, (3+1)*8 - | b ->fff_res - |. sdc1 f0, 0(RA) - | - |.ffunc ipairs_aux - | sltiu AT, NARGS8:RC, 16 - | lw CARG3, HI(BASE) - | lw TAB:CARG1, LO(BASE) - | lw CARG4, 8+HI(BASE) - | bnez AT, ->fff_fallback - |. ldc1 FARG2, 8(BASE) - | addiu CARG3, CARG3, -LJ_TTAB - | sltiu AT, CARG4, LJ_TISNUM - | li TMP0, 1 - | movn AT, r0, CARG3 - | mtc1 TMP0, FARG1 - | beqz AT, ->fff_fallback - |. lw PC, FRAME_PC(BASE) - | cvt.w.d FRET1, FARG2 - | cvt.d.w FARG1, FARG1 - | lw TMP0, TAB:CARG1->asize - | lw TMP1, TAB:CARG1->array - | mfc1 TMP2, FRET1 - | addiu RA, BASE, -8 - | add.d FARG2, FARG2, FARG1 - | addiu TMP2, TMP2, 1 - | sltu AT, TMP2, TMP0 - | sll TMP3, TMP2, 3 - | addu TMP3, TMP1, TMP3 - | beqz AT, >2 // Not in array part? - |. sdc1 FARG2, 0(RA) - | lw TMP2, HI(TMP3) - | ldc1 f0, 0(TMP3) - |1: - | beq TMP2, TISNIL, ->fff_res // End of iteration, return 0 results. - |. li RD, (0+1)*8 - | li RD, (2+1)*8 - | b ->fff_res - |. sdc1 f0, 8(RA) - |2: // Check for empty hash part first. Otherwise call C function. - | lw TMP0, TAB:CARG1->hmask - | load_got lj_tab_getinth - | beqz TMP0, ->fff_res - |. li RD, (0+1)*8 - | call_intern lj_tab_getinth // (GCtab *t, int32_t key) - |. move CARG2, TMP2 - | // Returns cTValue * or NULL. - | beqz CRET1, ->fff_res - |. li RD, (0+1)*8 - | lw TMP2, HI(CRET1) - | b <1 - |. ldc1 f0, 0(CRET1) - | - |.ffunc_1 ipairs - | li AT, LJ_TTAB - | bne CARG3, AT, ->fff_fallback - |. lw PC, FRAME_PC(BASE) -#if LJ_52 - | lw TAB:TMP2, TAB:CARG1->metatable - | ldc1 f0, CFUNC:RB->upvalue[0] - | bnez TAB:TMP2, ->fff_fallback -#else - | ldc1 f0, CFUNC:RB->upvalue[0] -#endif - |. addiu RA, BASE, -8 - | sw r0, 8+HI(BASE) - | sw r0, 8+LO(BASE) - | li RD, (3+1)*8 - | b ->fff_res - |. sdc1 f0, 0(RA) - | - |//-- Base library: catch errors ---------------------------------------- - | - |.ffunc pcall - | lbu TMP3, DISPATCH_GL(hookmask)(DISPATCH) - | beqz NARGS8:RC, ->fff_fallback - | move TMP2, BASE - | addiu BASE, BASE, 8 - | // Remember active hook before pcall. - | srl TMP3, TMP3, HOOK_ACTIVE_SHIFT - | andi TMP3, TMP3, 1 - | addiu PC, TMP3, 8+FRAME_PCALL - | b ->vm_call_dispatch - |. addiu NARGS8:RC, NARGS8:RC, -8 - | - |.ffunc xpcall - | sltiu AT, NARGS8:RC, 16 - | lw CARG4, 8+HI(BASE) - | bnez AT, ->fff_fallback - |. ldc1 FARG2, 8(BASE) - | ldc1 FARG1, 0(BASE) - | lbu TMP1, DISPATCH_GL(hookmask)(DISPATCH) - | li AT, LJ_TFUNC - | move TMP2, BASE - | bne CARG4, AT, ->fff_fallback // Traceback must be a function. - | addiu BASE, BASE, 16 - | // Remember active hook before pcall. - | srl TMP3, TMP3, HOOK_ACTIVE_SHIFT - | sdc1 FARG2, 0(TMP2) // Swap function and traceback. - | andi TMP3, TMP3, 1 - | sdc1 FARG1, 8(TMP2) - | addiu PC, TMP3, 16+FRAME_PCALL - | b ->vm_call_dispatch - |. addiu NARGS8:RC, NARGS8:RC, -16 - | - |//-- Coroutine library -------------------------------------------------- - | - |.macro coroutine_resume_wrap, resume - |.if resume - |.ffunc_1 coroutine_resume - | li AT, LJ_TTHREAD - | bne CARG3, AT, ->fff_fallback - |.else - |.ffunc coroutine_wrap_aux - | lw L:CARG1, CFUNC:RB->upvalue[0].gcr - |.endif - | lbu TMP0, L:CARG1->status - | lw TMP1, L:CARG1->cframe - | lw CARG2, L:CARG1->top - | lw TMP2, L:CARG1->base - | addiu TMP3, TMP0, -LUA_YIELD - | bgtz TMP3, ->fff_fallback // st > LUA_YIELD? - |. xor TMP2, TMP2, CARG2 - | bnez TMP1, ->fff_fallback // cframe != 0? - |. or AT, TMP2, TMP0 - | lw TMP0, L:CARG1->maxstack - | beqz AT, ->fff_fallback // base == top && st == 0? - |. lw PC, FRAME_PC(BASE) - | addu TMP2, CARG2, NARGS8:RC - | sltu AT, TMP0, TMP2 - | bnez AT, ->fff_fallback // Stack overflow? - |. sw PC, SAVE_PC - | sw BASE, L->base - |1: - |.if resume - | addiu BASE, BASE, 8 // Keep resumed thread in stack for GC. - | addiu NARGS8:RC, NARGS8:RC, -8 - | addiu TMP2, TMP2, -8 - |.endif - | sw TMP2, L:CARG1->top - | addu TMP1, BASE, NARGS8:RC - | move CARG3, CARG2 - | sw BASE, L->top - |2: // Move args to coroutine. - | ldc1 f0, 0(BASE) - | sltu AT, BASE, TMP1 - | beqz AT, >3 - |. addiu BASE, BASE, 8 - | sdc1 f0, 0(CARG3) - | b <2 - |. addiu CARG3, CARG3, 8 - |3: - | bal ->vm_resume // (lua_State *L, TValue *base, 0, 0) - |. move L:RA, L:CARG1 - | // Returns thread status. - |4: - | lw TMP2, L:RA->base - | sltiu AT, CRET1, LUA_YIELD+1 - | lw TMP3, L:RA->top - | li_vmstate INTERP - | lw BASE, L->base - | st_vmstate - | beqz AT, >8 - |. subu RD, TMP3, TMP2 - | lw TMP0, L->maxstack - | beqz RD, >6 // No results? - |. addu TMP1, BASE, RD - | sltu AT, TMP0, TMP1 - | bnez AT, >9 // Need to grow stack? - |. addu TMP3, TMP2, RD - | sw TMP2, L:RA->top // Clear coroutine stack. - | move TMP1, BASE - |5: // Move results from coroutine. - | ldc1 f0, 0(TMP2) - | addiu TMP2, TMP2, 8 - | sltu AT, TMP2, TMP3 - | sdc1 f0, 0(TMP1) - | bnez AT, <5 - |. addiu TMP1, TMP1, 8 - |6: - | andi TMP0, PC, FRAME_TYPE - |.if resume - | li TMP1, LJ_TTRUE - | addiu RA, BASE, -8 - | sw TMP1, -8+HI(BASE) // Prepend true to results. - | addiu RD, RD, 16 - |.else - | move RA, BASE - | addiu RD, RD, 8 - |.endif - |7: - | sw PC, SAVE_PC - | beqz TMP0, ->BC_RET_Z - |. move MULTRES, RD - | b ->vm_return - |. nop - | - |8: // Coroutine returned with error (at co->top-1). - |.if resume - | addiu TMP3, TMP3, -8 - | li TMP1, LJ_TFALSE - | ldc1 f0, 0(TMP3) - | sw TMP3, L:RA->top // Remove error from coroutine stack. - | li RD, (2+1)*8 - | sw TMP1, -8+HI(BASE) // Prepend false to results. - | addiu RA, BASE, -8 - | sdc1 f0, 0(BASE) // Copy error message. - | b <7 - |. andi TMP0, PC, FRAME_TYPE - |.else - | load_got lj_ffh_coroutine_wrap_err - | move CARG2, L:RA - | call_intern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co) - |. move CARG1, L - |.endif - | - |9: // Handle stack expansion on return from yield. - | load_got lj_state_growstack - | srl CARG2, RD, 3 - | call_intern lj_state_growstack // (lua_State *L, int n) - |. move CARG1, L - | b <4 - |. li CRET1, 0 - |.endmacro - | - | coroutine_resume_wrap 1 // coroutine.resume - | coroutine_resume_wrap 0 // coroutine.wrap - | - |.ffunc coroutine_yield - | lw TMP0, L->cframe - | addu TMP1, BASE, NARGS8:RC - | sw BASE, L->base - | andi TMP0, TMP0, CFRAME_RESUME - | sw TMP1, L->top - | beqz TMP0, ->fff_fallback - |. li CRET1, LUA_YIELD - | sw r0, L->cframe - | b ->vm_leave_unw - |. sb CRET1, L->status - | - |//-- Math library ------------------------------------------------------- - | - |.ffunc_n math_abs - |. abs.d FRET1, FARG1 - |->fff_resn: - | lw PC, FRAME_PC(BASE) - | addiu RA, BASE, -8 - | b ->fff_res1 - |. sdc1 FRET1, -8(BASE) - | - |->fff_restv: - | // CARG3/CARG1 = TValue result. - | lw PC, FRAME_PC(BASE) - | sw CARG3, -8+HI(BASE) - | addiu RA, BASE, -8 - | sw CARG1, -8+LO(BASE) - |->fff_res1: - | // RA = results, PC = return. - | li RD, (1+1)*8 - |->fff_res: - | // RA = results, RD = (nresults+1)*8, PC = return. - | andi TMP0, PC, FRAME_TYPE - | bnez TMP0, ->vm_return - |. move MULTRES, RD - | lw INS, -4(PC) - | decode_RB8a RB, INS - | decode_RB8b RB - |5: - | sltu AT, RD, RB - | bnez AT, >6 // More results expected? - |. decode_RA8a TMP0, INS - | decode_RA8b TMP0 - | ins_next1 - | // Adjust BASE. KBASE is assumed to be set for the calling frame. - | subu BASE, RA, TMP0 - | ins_next2 - | - |6: // Fill up results with nil. - | addu TMP1, RA, RD - | addiu RD, RD, 8 - | b <5 - |. sw TISNIL, -8+HI(TMP1) - | - |.macro math_extern, func - |->ff_math_ .. func: - | lw CARG3, HI(BASE) - | beqz NARGS8:RC, ->fff_fallback - |. load_got func - | sltiu AT, CARG3, LJ_TISNUM - | beqz AT, ->fff_fallback - |. nop - | call_extern - |. ldc1 FARG1, 0(BASE) - | b ->fff_resn - |. nop - |.endmacro - | - |.macro math_extern2, func - | .ffunc_nn math_ .. func - |. load_got func - | call_extern - |. nop - | b ->fff_resn - |. nop - |.endmacro - | - |.macro math_round, func - | .ffunc_n math_ .. func - |. nop - | bal ->vm_ .. func - |. nop - | b ->fff_resn - |. nop - |.endmacro - | - | math_round floor - | math_round ceil - | - |.ffunc math_log - | lw CARG3, HI(BASE) - | li AT, 8 - | bne NARGS8:RC, AT, ->fff_fallback // Exactly 1 argument. - |. load_got log - | sltiu AT, CARG3, LJ_TISNUM - | beqz AT, ->fff_fallback - |. nop - | call_extern - |. ldc1 FARG1, 0(BASE) - | b ->fff_resn - |. nop - | - | math_extern log10 - | math_extern exp - | math_extern sin - | math_extern cos - | math_extern tan - | math_extern asin - | math_extern acos - | math_extern atan - | math_extern sinh - | math_extern cosh - | math_extern tanh - | math_extern2 pow - | math_extern2 atan2 - | math_extern2 fmod - | - |.ffunc_n math_sqrt - |. sqrt.d FRET1, FARG1 - | b ->fff_resn - |. nop - | - |->ff_math_deg: - |.ffunc_n math_rad - |. ldc1 FARG2, CFUNC:RB->upvalue[0] - | b ->fff_resn - |. mul.d FRET1, FARG1, FARG2 - | - |.ffunc_nn math_ldexp - | cvt.w.d FARG2, FARG2 - | load_got ldexp - | mfc1 CARG3, FARG2 - | call_extern - |. nop - | b ->fff_resn - |. nop - | - |.ffunc_n math_frexp - | load_got frexp - | lw PC, FRAME_PC(BASE) - | call_extern - |. addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) - | lw TMP1, DISPATCH_GL(tmptv)(DISPATCH) - | addiu RA, BASE, -8 - | mtc1 TMP1, FARG2 - | sdc1 FRET1, 0(RA) - | cvt.d.w FARG2, FARG2 - | sdc1 FARG2, 8(RA) - | b ->fff_res - |. li RD, (2+1)*8 - | - |.ffunc_n math_modf - | load_got modf - | lw PC, FRAME_PC(BASE) - | call_extern - |. addiu CARG3, BASE, -8 - | addiu RA, BASE, -8 - | sdc1 FRET1, 0(BASE) - | b ->fff_res - |. li RD, (2+1)*8 - | - |.macro math_minmax, name, ismax - |->ff_ .. name: - | lw CARG3, HI(BASE) - | beqz NARGS8:RC, ->fff_fallback - |. ldc1 FRET1, 0(BASE) - | sltiu AT, CARG3, LJ_TISNUM - | beqz AT, ->fff_fallback - |. addu TMP2, BASE, NARGS8:RC - | addiu TMP1, BASE, 8 - | beq TMP1, TMP2, ->fff_resn - |1: - |. lw CARG3, HI(TMP1) - | ldc1 FARG1, 0(TMP1) - | addiu TMP1, TMP1, 8 - | sltiu AT, CARG3, LJ_TISNUM - | beqz AT, ->fff_fallback - |.if ismax - |. c.olt.d FARG1, FRET1 - |.else - |. c.olt.d FRET1, FARG1 - |.endif - | bne TMP1, TMP2, <1 - |. movf.d FRET1, FARG1 - | b ->fff_resn - |. nop - |.endmacro - | - | math_minmax math_min, 0 - | math_minmax math_max, 1 - | - |//-- String library ----------------------------------------------------- - | - |.ffunc_1 string_len - | li AT, LJ_TSTR - | bne CARG3, AT, ->fff_fallback - |. nop - | b ->fff_resi - |. lw CRET1, STR:CARG1->len - | - |.ffunc string_byte // Only handle the 1-arg case here. - | lw CARG3, HI(BASE) - | lw STR:CARG1, LO(BASE) - | xori AT, NARGS8:RC, 8 - | addiu CARG3, CARG3, -LJ_TSTR - | or AT, AT, CARG3 - | bnez AT, ->fff_fallback // Need exactly 1 string argument. - |. nop - | lw TMP0, STR:CARG1->len - | lbu TMP1, STR:CARG1[1] // Access is always ok (NUL at end). - | addiu RA, BASE, -8 - | sltu RD, r0, TMP0 - | mtc1 TMP1, f0 - | addiu RD, RD, 1 - | cvt.d.w f0, f0 - | lw PC, FRAME_PC(BASE) - | sll RD, RD, 3 // RD = ((str->len != 0)+1)*8 - | b ->fff_res - |. sdc1 f0, 0(RA) - | - |.ffunc string_char // Only handle the 1-arg case here. - | ffgccheck - | lw CARG3, HI(BASE) - | ldc1 FARG1, 0(BASE) - | li AT, 8 - | bne NARGS8:RC, AT, ->fff_fallback // Exactly 1 argument. - |. sltiu AT, CARG3, LJ_TISNUM - | beqz AT, ->fff_fallback - |. li CARG3, 1 - | cvt.w.d FARG1, FARG1 - | addiu CARG2, sp, ARG5_OFS - | sltiu AT, TMP0, 256 - | mfc1 TMP0, FARG1 - | beqz AT, ->fff_fallback - |. sw TMP0, ARG5 - |->fff_newstr: - | load_got lj_str_new - | sw BASE, L->base - | sw PC, SAVE_PC - | call_intern lj_str_new // (lua_State *L, char *str, size_t l) - |. move CARG1, L - | // Returns GCstr *. - | lw BASE, L->base - | move CARG1, CRET1 - | b ->fff_restv - |. li CARG3, LJ_TSTR - | - |.ffunc string_sub - | ffgccheck - | addiu AT, NARGS8:RC, -16 - | lw CARG3, 16+HI(BASE) - | ldc1 f0, 16(BASE) - | lw TMP0, HI(BASE) - | lw STR:CARG1, LO(BASE) - | bltz AT, ->fff_fallback - | lw CARG2, 8+HI(BASE) - | ldc1 f2, 8(BASE) - | beqz AT, >1 - |. li CARG4, -1 - | cvt.w.d f0, f0 - | sltiu AT, CARG3, LJ_TISNUM - | beqz AT, ->fff_fallback - |. mfc1 CARG4, f0 - |1: - | sltiu AT, CARG2, LJ_TISNUM - | beqz AT, ->fff_fallback - |. li AT, LJ_TSTR - | cvt.w.d f2, f2 - | bne TMP0, AT, ->fff_fallback - |. lw CARG2, STR:CARG1->len - | mfc1 CARG3, f2 - | // STR:CARG1 = str, CARG2 = str->len, CARG3 = start, CARG4 = end - | slt AT, CARG4, r0 - | addiu TMP0, CARG2, 1 - | addu TMP1, CARG4, TMP0 - | slt TMP3, CARG3, r0 - | movn CARG4, TMP1, AT // if (end < 0) end += len+1 - | addu TMP1, CARG3, TMP0 - | movn CARG3, TMP1, TMP3 // if (start < 0) start += len+1 - | li TMP2, 1 - | slt AT, CARG4, r0 - | slt TMP3, r0, CARG3 - | movn CARG4, r0, AT // if (end < 0) end = 0 - | movz CARG3, TMP2, TMP3 // if (start < 1) start = 1 - | slt AT, CARG2, CARG4 - | movn CARG4, CARG2, AT // if (end > len) end = len - | addu CARG2, STR:CARG1, CARG3 - | subu CARG3, CARG4, CARG3 // len = end - start - | addiu CARG2, CARG2, sizeof(GCstr)-1 - | bgez CARG3, ->fff_newstr - |. addiu CARG3, CARG3, 1 // len++ - |->fff_emptystr: // Return empty string. - | addiu STR:CARG1, DISPATCH, DISPATCH_GL(strempty) - | b ->fff_restv - |. li CARG3, LJ_TSTR - | - |.ffunc string_rep // Only handle the 1-char case inline. - | ffgccheck - | lw TMP0, HI(BASE) - | addiu AT, NARGS8:RC, -16 // Exactly 2 arguments. - | lw CARG4, 8+HI(BASE) - | lw STR:CARG1, LO(BASE) - | addiu TMP0, TMP0, -LJ_TSTR - | ldc1 f0, 8(BASE) - | or AT, AT, TMP0 - | bnez AT, ->fff_fallback - |. sltiu AT, CARG4, LJ_TISNUM - | cvt.w.d f0, f0 - | beqz AT, ->fff_fallback - |. lw TMP0, STR:CARG1->len - | mfc1 CARG3, f0 - | lw TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) - | li AT, 1 - | blez CARG3, ->fff_emptystr // Count <= 0? - |. sltu AT, AT, TMP0 - | beqz TMP0, ->fff_emptystr // Zero length string? - |. sltu TMP0, TMP1, CARG3 - | or AT, AT, TMP0 - | lw CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) - | bnez AT, ->fff_fallback // Fallback for > 1-char strings. - |. lbu TMP0, STR:CARG1[1] - | addu TMP2, CARG2, CARG3 - |1: // Fill buffer with char. Yes, this is suboptimal code (do you care?). - | addiu TMP2, TMP2, -1 - | sltu AT, CARG2, TMP2 - | bnez AT, <1 - |. sb TMP0, 0(TMP2) - | b ->fff_newstr - |. nop - | - |.ffunc string_reverse - | ffgccheck - | lw CARG3, HI(BASE) - | lw STR:CARG1, LO(BASE) - | beqz NARGS8:RC, ->fff_fallback - |. li AT, LJ_TSTR - | bne CARG3, AT, ->fff_fallback - |. lw TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) - | lw CARG3, STR:CARG1->len - | addiu CARG1, STR:CARG1, #STR - | lw CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) - | sltu AT, TMP1, CARG3 - | bnez AT, ->fff_fallback - |. addu TMP3, CARG1, CARG3 - | addu CARG4, CARG2, CARG3 - |1: // Reverse string copy. - | lbu TMP1, 0(CARG1) - | sltu AT, CARG1, TMP3 - | beqz AT, ->fff_newstr - |. addiu CARG1, CARG1, 1 - | addiu CARG4, CARG4, -1 - | b <1 - | sb TMP1, 0(CARG4) - | - |.macro ffstring_case, name, lo - | .ffunc name - | ffgccheck - | lw CARG3, HI(BASE) - | lw STR:CARG1, LO(BASE) - | beqz NARGS8:RC, ->fff_fallback - |. li AT, LJ_TSTR - | bne CARG3, AT, ->fff_fallback - |. lw TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) - | lw CARG3, STR:CARG1->len - | addiu CARG1, STR:CARG1, #STR - | lw CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) - | sltu AT, TMP1, CARG3 - | bnez AT, ->fff_fallback - |. addu TMP3, CARG1, CARG3 - | move CARG4, CARG2 - |1: // ASCII case conversion. - | lbu TMP1, 0(CARG1) - | sltu AT, CARG1, TMP3 - | beqz AT, ->fff_newstr - |. addiu TMP0, TMP1, -lo - | xori TMP2, TMP1, 0x20 - | sltiu AT, TMP0, 26 - | movn TMP1, TMP2, AT - | addiu CARG1, CARG1, 1 - | sb TMP1, 0(CARG4) - | b <1 - |. addiu CARG4, CARG4, 1 - |.endmacro - | - |ffstring_case string_lower, 65 - |ffstring_case string_upper, 97 - | - |//-- Table library ------------------------------------------------------ - | - |.ffunc_1 table_getn - | li AT, LJ_TTAB - | bne CARG3, AT, ->fff_fallback - |. load_got lj_tab_len - | call_intern lj_tab_len // (GCtab *t) - |. nop - | // Returns uint32_t (but less than 2^31). - | b ->fff_resi - |. nop - | - |//-- Bit library -------------------------------------------------------- - | - |.macro .ffunc_bit, name - | .ffunc_n bit_..name - |. add.d FARG1, FARG1, TOBIT - | mfc1 CRET1, FARG1 - |.endmacro - | - |.macro .ffunc_bit_op, name, ins - | .ffunc_bit name - | addiu TMP1, BASE, 8 - | addu TMP2, BASE, NARGS8:RC - |1: - | lw CARG4, HI(TMP1) - | beq TMP1, TMP2, ->fff_resi - |. ldc1 FARG1, 0(TMP1) - | sltiu AT, CARG4, LJ_TISNUM - | beqz AT, ->fff_fallback - | add.d FARG1, FARG1, TOBIT - | mfc1 CARG2, FARG1 - | ins CRET1, CRET1, CARG2 - | b <1 - |. addiu TMP1, TMP1, 8 - |.endmacro - | - |.ffunc_bit_op band, and - |.ffunc_bit_op bor, or - |.ffunc_bit_op bxor, xor - | - |.ffunc_bit bswap - | srl TMP0, CRET1, 24 - | srl TMP2, CRET1, 8 - | sll TMP1, CRET1, 24 - | andi TMP2, TMP2, 0xff00 - | or TMP0, TMP0, TMP1 - | andi CRET1, CRET1, 0xff00 - | or TMP0, TMP0, TMP2 - | sll CRET1, CRET1, 8 - | b ->fff_resi - |. or CRET1, TMP0, CRET1 - | - |.ffunc_bit bnot - | b ->fff_resi - |. not CRET1, CRET1 - | - |.macro .ffunc_bit_sh, name, ins, shmod - | .ffunc_nn bit_..name - |. add.d FARG1, FARG1, TOBIT - | add.d FARG2, FARG2, TOBIT - | mfc1 CARG1, FARG1 - | mfc1 CARG2, FARG2 - |.if shmod == 1 - | li AT, 32 - | subu TMP0, AT, CARG2 - | sllv CARG2, CARG1, CARG2 - | srlv CARG1, CARG1, TMP0 - |.elif shmod == 2 - | li AT, 32 - | subu TMP0, AT, CARG2 - | srlv CARG2, CARG1, CARG2 - | sllv CARG1, CARG1, TMP0 - |.endif - | b ->fff_resi - |. ins CRET1, CARG1, CARG2 - |.endmacro - | - |.ffunc_bit_sh lshift, sllv, 0 - |.ffunc_bit_sh rshift, srlv, 0 - |.ffunc_bit_sh arshift, srav, 0 - |// Can't use rotrv, since it's only in MIPS32R2. - |.ffunc_bit_sh rol, or, 1 - |.ffunc_bit_sh ror, or, 2 - | - |.ffunc_bit tobit - |->fff_resi: - | mtc1 CRET1, FRET1 - | b ->fff_resn - |. cvt.d.w FRET1, FRET1 - | - |//----------------------------------------------------------------------- - | - |->fff_fallback: // Call fast function fallback handler. - | // BASE = new base, RB = CFUNC, RC = nargs*8 - | lw TMP3, CFUNC:RB->f - | addu TMP1, BASE, NARGS8:RC - | lw PC, FRAME_PC(BASE) // Fallback may overwrite PC. - | addiu TMP0, TMP1, 8*LUA_MINSTACK - | lw TMP2, L->maxstack - | sw PC, SAVE_PC // Redundant (but a defined value). - | sltu AT, TMP2, TMP0 - | sw BASE, L->base - | sw TMP1, L->top - | bnez AT, >5 // Need to grow stack. - |. move CFUNCADDR, TMP3 - | jalr TMP3 // (lua_State *L) - |. move CARG1, L - | // Either throws an error, or recovers and returns -1, 0 or nresults+1. - | lw BASE, L->base - | sll RD, CRET1, 3 - | bgtz CRET1, ->fff_res // Returned nresults+1? - |. addiu RA, BASE, -8 - |1: // Returned 0 or -1: retry fast path. - | lw TMP0, L->top - | lw LFUNC:RB, FRAME_FUNC(BASE) - | bnez CRET1, ->vm_call_tail // Returned -1? - |. subu NARGS8:RC, TMP0, BASE - | ins_callt // Returned 0: retry fast path. - | - |// Reconstruct previous base for vmeta_call during tailcall. - |->vm_call_tail: - | andi TMP0, PC, FRAME_TYPE - | li AT, -4 - | bnez TMP0, >3 - |. and TMP1, PC, AT - | lbu TMP1, OFS_RA(PC) - | sll TMP1, TMP1, 3 - | addiu TMP1, TMP1, 8 - |3: - | b ->vm_call_dispatch // Resolve again for tailcall. - |. subu TMP2, BASE, TMP1 - | - |5: // Grow stack for fallback handler. - | load_got lj_state_growstack - | li CARG2, LUA_MINSTACK - | call_intern lj_state_growstack // (lua_State *L, int n) - |. move CARG1, L - | lw BASE, L->base - | b <1 - |. li CRET1, 0 // Force retry. - | - |->fff_gcstep: // Call GC step function. - | // BASE = new base, RC = nargs*8 - | move MULTRES, ra - | load_got lj_gc_step - | sw BASE, L->base - | addu TMP0, BASE, NARGS8:RC - | sw PC, SAVE_PC // Redundant (but a defined value). - | sw TMP0, L->top - | call_intern lj_gc_step // (lua_State *L) - |. move CARG1, L - | lw BASE, L->base - | move ra, MULTRES - | lw TMP0, L->top - | lw CFUNC:RB, FRAME_FUNC(BASE) - | jr ra - |. subu NARGS8:RC, TMP0, BASE - | - |//----------------------------------------------------------------------- - |//-- Special dispatch targets ------------------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_record: // Dispatch target for recording phase. - |.if JIT - | lbu TMP3, DISPATCH_GL(hookmask)(DISPATCH) - | andi AT, TMP3, HOOK_VMEVENT // No recording while in vmevent. - | bnez AT, >5 - | // Decrement the hookcount for consistency, but always do the call. - |. lw TMP2, DISPATCH_GL(hookcount)(DISPATCH) - | andi AT, TMP3, HOOK_ACTIVE - | bnez AT, >1 - |. addiu TMP2, TMP2, -1 - | andi AT, TMP3, LUA_MASKLINE|LUA_MASKCOUNT - | beqz AT, >1 - |. nop - | b >1 - |. sw TMP2, DISPATCH_GL(hookcount)(DISPATCH) - |.endif - | - |->vm_rethook: // Dispatch target for return hooks. - | lbu TMP3, DISPATCH_GL(hookmask)(DISPATCH) - | andi AT, TMP3, HOOK_ACTIVE // Hook already active? - | beqz AT, >1 - |5: // Re-dispatch to static ins. - |. lw AT, GG_DISP2STATIC(TMP0) // Assumes TMP0 holds DISPATCH+OP*4. - | jr AT - |. nop - | - |->vm_inshook: // Dispatch target for instr/line hooks. - | lbu TMP3, DISPATCH_GL(hookmask)(DISPATCH) - | lw TMP2, DISPATCH_GL(hookcount)(DISPATCH) - | andi AT, TMP3, HOOK_ACTIVE // Hook already active? - | bnez AT, <5 - |. andi AT, TMP3, LUA_MASKLINE|LUA_MASKCOUNT - | beqz AT, <5 - |. addiu TMP2, TMP2, -1 - | beqz TMP2, >1 - |. sw TMP2, DISPATCH_GL(hookcount)(DISPATCH) - | andi AT, TMP3, LUA_MASKLINE - | beqz AT, <5 - |1: - |. load_got lj_dispatch_ins - | sw MULTRES, SAVE_MULTRES - | move CARG2, PC - | sw BASE, L->base - | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. - | call_intern lj_dispatch_ins // (lua_State *L, const BCIns *pc) - |. move CARG1, L - |3: - | lw BASE, L->base - |4: // Re-dispatch to static ins. - | lw INS, -4(PC) - | decode_OP4a TMP1, INS - | decode_OP4b TMP1 - | addu TMP0, DISPATCH, TMP1 - | decode_RD8a RD, INS - | lw AT, GG_DISP2STATIC(TMP0) - | decode_RA8a RA, INS - | decode_RD8b RD - | jr AT - | decode_RA8b RA - | - |->cont_hook: // Continue from hook yield. - | addiu PC, PC, 4 - | b <4 - |. lw MULTRES, -24+LO(RB) // Restore MULTRES for *M ins. - | - |->vm_hotloop: // Hot loop counter underflow. - |.if JIT - | lw LFUNC:TMP1, FRAME_FUNC(BASE) - | addiu CARG1, DISPATCH, GG_DISP2J - | sw PC, SAVE_PC - | lw TMP1, LFUNC:TMP1->pc - | move CARG2, PC - | sw L, DISPATCH_J(L)(DISPATCH) - | lbu TMP1, PC2PROTO(framesize)(TMP1) - | load_got lj_trace_hot - | sw BASE, L->base - | sll TMP1, TMP1, 3 - | addu TMP1, BASE, TMP1 - | call_intern lj_trace_hot // (jit_State *J, const BCIns *pc) - |. sw TMP1, L->top - | b <3 - |. nop - |.endif - | - |->vm_callhook: // Dispatch target for call hooks. - |.if JIT - | b >1 - |.endif - |. move CARG2, PC - | - |->vm_hotcall: // Hot call counter underflow. - |.if JIT - | ori CARG2, PC, 1 - |1: - |.endif - | load_got lj_dispatch_call - | addu TMP0, BASE, RC - | sw PC, SAVE_PC - | sw BASE, L->base - | subu RA, RA, BASE - | sw TMP0, L->top - | call_intern lj_dispatch_call // (lua_State *L, const BCIns *pc) - |. move CARG1, L - | // Returns ASMFunction. - | lw BASE, L->base - | lw TMP0, L->top - | sw r0, SAVE_PC // Invalidate for subsequent line hook. - | subu NARGS8:RC, TMP0, BASE - | addu RA, BASE, RA - | lw LFUNC:RB, FRAME_FUNC(BASE) - | jr CRET1 - |. lw INS, -4(PC) - | - |//----------------------------------------------------------------------- - |//-- Trace exit handler ------------------------------------------------- - |//----------------------------------------------------------------------- - | - |.macro savex_, a, b - | sdc1 f..a, 16+a*8(sp) - | sw r..a, 16+32*8+a*4(sp) - | sw r..b, 16+32*8+b*4(sp) - |.endmacro - | - |->vm_exit_handler: - |.if JIT - | addiu sp, sp, -(16+32*8+32*4) - | savex_ 0, 1 - | savex_ 2, 3 - | savex_ 4, 5 - | savex_ 6, 7 - | savex_ 8, 9 - | savex_ 10, 11 - | savex_ 12, 13 - | savex_ 14, 15 - | savex_ 16, 17 - | savex_ 18, 19 - | savex_ 20, 21 - | savex_ 22, 23 - | savex_ 24, 25 - | savex_ 26, 27 - | sdc1 f28, 16+28*8(sp) - | sw r28, 16+32*8+28*4(sp) - | sdc1 f30, 16+30*8(sp) - | sw r30, 16+32*8+30*4(sp) - | sw r0, 16+32*8+31*4(sp) // Clear RID_TMP. - | li_vmstate EXIT - | addiu TMP2, sp, 16+32*8+32*4 // Recompute original value of sp. - | addiu DISPATCH, JGL, -GG_DISP2G-32768 - | lw TMP1, 0(TMP2) // Load exit number. - | st_vmstate - | sw TMP2, 16+32*8+29*4(sp) // Store sp in RID_SP. - | lw L, DISPATCH_GL(jit_L)(DISPATCH) - | lw BASE, DISPATCH_GL(jit_base)(DISPATCH) - | load_got lj_trace_exit - | sw L, DISPATCH_J(L)(DISPATCH) - | sw ra, DISPATCH_J(parent)(DISPATCH) // Store trace number. - | sw TMP1, DISPATCH_J(exitno)(DISPATCH) // Store exit number. - | addiu CARG1, DISPATCH, GG_DISP2J - | sw BASE, L->base - | call_intern lj_trace_exit // (jit_State *J, ExitState *ex) - |. addiu CARG2, sp, 16 - | // Returns MULTRES (unscaled) or negated error code. - | lw TMP1, L->cframe - | li AT, -4 - | lw BASE, L->base - | and sp, TMP1, AT - | lw PC, SAVE_PC // Get SAVE_PC. - | b >1 - |. sw L, SAVE_L // Set SAVE_L (on-trace resume/yield). - |.endif - |->vm_exit_interp: - |.if JIT - | // CRET1 = MULTRES or negated error code, BASE, PC and JGL set. - | lw L, SAVE_L - | addiu DISPATCH, JGL, -GG_DISP2G-32768 - |1: - | bltz CRET1, >3 // Check for error from exit. - |. lw LFUNC:TMP1, FRAME_FUNC(BASE) - | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). - | sll MULTRES, CRET1, 3 - | li TISNIL, LJ_TNIL - | sw MULTRES, SAVE_MULTRES - | mtc1 TMP3, TOBIT - | lw TMP1, LFUNC:TMP1->pc - | sw r0, DISPATCH_GL(jit_L)(DISPATCH) - | lw KBASE, PC2PROTO(k)(TMP1) - | cvt.d.s TOBIT, TOBIT - | // Modified copy of ins_next which handles function header dispatch, too. - | lw INS, 0(PC) - | addiu PC, PC, 4 - | // Assumes TISNIL == ~LJ_VMST_INTERP == -1 - | sw TISNIL, DISPATCH_GL(vmstate)(DISPATCH) - | decode_OP4a TMP1, INS - | decode_OP4b TMP1 - | sltiu TMP2, TMP1, BC_FUNCF*4 // Function header? - | addu TMP0, DISPATCH, TMP1 - | decode_RD8a RD, INS - | lw AT, 0(TMP0) - | decode_RA8a RA, INS - | beqz TMP2, >2 - |. decode_RA8b RA - | jr AT - |. decode_RD8b RD - |2: - | addiu RC, MULTRES, -8 - | jr AT - |. addu RA, RA, BASE - | - |3: // Rethrow error from the right C frame. - | load_got lj_err_throw - | negu CARG2, CRET1 - | call_intern lj_err_throw // (lua_State *L, int errcode) - |. move CARG1, L - |.endif - | - |//----------------------------------------------------------------------- - |//-- Math helper functions ---------------------------------------------- - |//----------------------------------------------------------------------- - | - |// Modifies AT, TMP0, FRET1, FRET2, f4. Keeps all others incl. FARG1. - |.macro vm_round, func - | lui TMP0, 0x4330 // Hiword of 2^52 (double). - | mtc1 r0, f4 - | mtc1 TMP0, f5 - | abs.d FRET2, FARG1 // |x| - | mfc1 AT, f13 - | c.olt.d 0, FRET2, f4 - | add.d FRET1, FRET2, f4 // (|x| + 2^52) - 2^52 - | bc1f 0, >1 // Truncate only if |x| < 2^52. - |. sub.d FRET1, FRET1, f4 - | slt AT, AT, r0 - |.if "func" == "ceil" - | lui TMP0, 0xbff0 // Hiword of -1 (double). Preserves -0. - |.else - | lui TMP0, 0x3ff0 // Hiword of +1 (double). - |.endif - |.if "func" == "trunc" - | mtc1 TMP0, f5 - | c.olt.d 0, FRET2, FRET1 // |x| < result? - | sub.d FRET2, FRET1, f4 - | movt.d FRET1, FRET2, 0 // If yes, subtract +1. - | neg.d FRET2, FRET1 - | jr ra - |. movn.d FRET1, FRET2, AT // Merge sign bit back in. - |.else - | neg.d FRET2, FRET1 - | mtc1 TMP0, f5 - | movn.d FRET1, FRET2, AT // Merge sign bit back in. - |.if "func" == "ceil" - | c.olt.d 0, FRET1, FARG1 // x > result? - |.else - | c.olt.d 0, FARG1, FRET1 // x < result? - |.endif - | sub.d FRET2, FRET1, f4 // If yes, subtract +-1. - | jr ra - |. movt.d FRET1, FRET2, 0 - |.endif - |1: - | jr ra - |. mov.d FRET1, FARG1 - |.endmacro - | - |->vm_floor: - | vm_round floor - |->vm_ceil: - | vm_round ceil - |->vm_trunc: - |.if JIT - | vm_round trunc - |.endif - | - |//----------------------------------------------------------------------- - |//-- Miscellaneous functions -------------------------------------------- - |//----------------------------------------------------------------------- - | - |//----------------------------------------------------------------------- - |//-- FFI helper functions ----------------------------------------------- - |//----------------------------------------------------------------------- - | - |// Handler for callback functions. Callback slot number in r1, g in r2. - |->vm_ffi_callback: - |.if FFI - |.type CTSTATE, CTState, PC - | saveregs - | lw CTSTATE, GL:r2->ctype_state - | addiu DISPATCH, r2, GG_G2DISP - | load_got lj_ccallback_enter - | sw r1, CTSTATE->cb.slot - | sw CARG1, CTSTATE->cb.gpr[0] - | sw CARG2, CTSTATE->cb.gpr[1] - | sdc1 FARG1, CTSTATE->cb.fpr[0] - | sw CARG3, CTSTATE->cb.gpr[2] - | sw CARG4, CTSTATE->cb.gpr[3] - | sdc1 FARG2, CTSTATE->cb.fpr[1] - | addiu TMP0, sp, CFRAME_SPACE+16 - | sw TMP0, CTSTATE->cb.stack - | sw r0, SAVE_PC // Any value outside of bytecode is ok. - | move CARG2, sp - | call_intern lj_ccallback_enter // (CTState *cts, void *cf) - |. move CARG1, CTSTATE - | // Returns lua_State *. - | lw BASE, L:CRET1->base - | lw RC, L:CRET1->top - | move L, CRET1 - | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). - | lw LFUNC:RB, FRAME_FUNC(BASE) - | mtc1 TMP3, TOBIT - | li_vmstate INTERP - | li TISNIL, LJ_TNIL - | subu RC, RC, BASE - | st_vmstate - | cvt.d.s TOBIT, TOBIT - | ins_callt - |.endif - | - |->cont_ffi_callback: // Return from FFI callback. - |.if FFI - | load_got lj_ccallback_leave - | lw CTSTATE, DISPATCH_GL(ctype_state)(DISPATCH) - | sw BASE, L->base - | sw RB, L->top - | sw L, CTSTATE->L - | move CARG2, RA - | call_intern lj_ccallback_leave // (CTState *cts, TValue *o) - |. move CARG1, CTSTATE - | lw CRET1, CTSTATE->cb.gpr[0] - | ldc1 FRET1, CTSTATE->cb.fpr[0] - | lw CRET2, CTSTATE->cb.gpr[1] - | b ->vm_leave_unw - |. ldc1 FRET2, CTSTATE->cb.fpr[1] - |.endif - | - |->vm_ffi_call: // Call C function via FFI. - | // Caveat: needs special frame unwinding, see below. - |.if FFI - | .type CCSTATE, CCallState, CARG1 - | lw TMP1, CCSTATE->spadj - | lbu CARG2, CCSTATE->nsp - | move TMP2, sp - | subu sp, sp, TMP1 - | sw ra, -4(TMP2) - | sll CARG2, CARG2, 2 - | sw r16, -8(TMP2) - | sw CCSTATE, -12(TMP2) - | move r16, TMP2 - | addiu TMP1, CCSTATE, offsetof(CCallState, stack) - | addiu TMP2, sp, 16 - | beqz CARG2, >2 - |. addu TMP3, TMP1, CARG2 - |1: - | lw TMP0, 0(TMP1) - | addiu TMP1, TMP1, 4 - | sltu AT, TMP1, TMP3 - | sw TMP0, 0(TMP2) - | bnez AT, <1 - |. addiu TMP2, TMP2, 4 - |2: - | lw CFUNCADDR, CCSTATE->func - | lw CARG2, CCSTATE->gpr[1] - | lw CARG3, CCSTATE->gpr[2] - | lw CARG4, CCSTATE->gpr[3] - | ldc1 FARG1, CCSTATE->fpr[0] - | ldc1 FARG2, CCSTATE->fpr[1] - | jalr CFUNCADDR - |. lw CARG1, CCSTATE->gpr[0] // Do this last, since CCSTATE is CARG1. - | lw CCSTATE:TMP1, -12(r16) - | lw TMP2, -8(r16) - | lw ra, -4(r16) - | sw CRET1, CCSTATE:TMP1->gpr[0] - | sw CRET2, CCSTATE:TMP1->gpr[1] - | sdc1 FRET1, CCSTATE:TMP1->fpr[0] - | sdc1 FRET2, CCSTATE:TMP1->fpr[1] - | move sp, r16 - | jr ra - |. move r16, TMP2 - |.endif - |// Note: vm_ffi_call must be the last function in this object file! - | - |//----------------------------------------------------------------------- -} - -/* Generate the code for a single instruction. */ -static void build_ins(BuildCtx *ctx, BCOp op, int defop) -{ - int vk = 0; - |=>defop: - - switch (op) { - - /* -- Comparison ops ---------------------------------------------------- */ - - /* Remember: all ops branch for a true comparison, fall through otherwise. */ - - case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: - | // RA = src1*8, RD = src2*8, JMP with RD = target - | addu CARG2, BASE, RA - | addu CARG3, BASE, RD - | lw TMP0, HI(CARG2) - | lw TMP1, HI(CARG3) - | ldc1 f0, 0(CARG2) - | ldc1 f2, 0(CARG3) - | sltiu TMP0, TMP0, LJ_TISNUM - | sltiu TMP1, TMP1, LJ_TISNUM - | lhu TMP2, OFS_RD(PC) - | and TMP0, TMP0, TMP1 - | addiu PC, PC, 4 - | beqz TMP0, ->vmeta_comp - |. lui TMP1, (-(BCBIAS_J*4 >> 16) & 65535) - | decode_RD4b TMP2 - | addu TMP2, TMP2, TMP1 - if (op == BC_ISLT || op == BC_ISGE) { - | c.olt.d f0, f2 - } else { - | c.ole.d f0, f2 - } - if (op == BC_ISLT || op == BC_ISLE) { - | movf TMP2, r0 - } else { - | movt TMP2, r0 - } - | addu PC, PC, TMP2 - |1: - | ins_next - break; - - case BC_ISEQV: case BC_ISNEV: - vk = op == BC_ISEQV; - | // RA = src1*8, RD = src2*8, JMP with RD = target - | addu RA, BASE, RA - | addiu PC, PC, 4 - | lw TMP0, HI(RA) - | ldc1 f0, 0(RA) - | addu RD, BASE, RD - | lhu TMP2, -4+OFS_RD(PC) - | lw TMP1, HI(RD) - | ldc1 f2, 0(RD) - | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) - | sltiu AT, TMP0, LJ_TISNUM - | sltiu CARG1, TMP1, LJ_TISNUM - | decode_RD4b TMP2 - | and AT, AT, CARG1 - | beqz AT, >5 - |. addu TMP2, TMP2, TMP3 - | c.eq.d f0, f2 - if (vk) { - | movf TMP2, r0 - } else { - | movt TMP2, r0 - } - |1: - | addu PC, PC, TMP2 - | ins_next - |5: // Either or both types are not numbers. - | lw CARG2, LO(RA) - | lw CARG3, LO(RD) - |.if FFI - | li TMP3, LJ_TCDATA - | beq TMP0, TMP3, ->vmeta_equal_cd - |.endif - |. sltiu AT, TMP0, LJ_TISPRI // Not a primitive? - |.if FFI - | beq TMP1, TMP3, ->vmeta_equal_cd - |.endif - |. xor TMP3, CARG2, CARG3 // Same tv? - | xor TMP1, TMP1, TMP0 // Same type? - | sltiu CARG1, TMP0, LJ_TISTABUD+1 // Table or userdata? - | movz TMP3, r0, AT // Ignore tv if primitive. - | movn CARG1, r0, TMP1 // Tab/ud and same type? - | or AT, TMP1, TMP3 // Same type && (pri||same tv). - | movz CARG1, r0, AT - | beqz CARG1, <1 // Done if not tab/ud or not same type or same tv. - if (vk) { - |. movn TMP2, r0, AT - } else { - |. movz TMP2, r0, AT - } - | // Different tables or userdatas. Need to check __eq metamethod. - | // Field metatable must be at same offset for GCtab and GCudata! - | lw TAB:TMP1, TAB:CARG2->metatable - | beqz TAB:TMP1, <1 // No metatable? - |. nop - | lbu TMP1, TAB:TMP1->nomm - | andi TMP1, TMP1, 1<vmeta_equal // Handle __eq metamethod. - |. li CARG4, 1-vk // ne = 0 or 1. - break; - - case BC_ISEQS: case BC_ISNES: - vk = op == BC_ISEQS; - | // RA = src*8, RD = str_const*8 (~), JMP with RD = target - | addu RA, BASE, RA - | addiu PC, PC, 4 - | lw TMP0, HI(RA) - | srl RD, RD, 1 - | lw STR:TMP3, LO(RA) - | subu RD, KBASE, RD - | lhu TMP2, -4+OFS_RD(PC) - |.if FFI - | li AT, LJ_TCDATA - | beq TMP0, AT, ->vmeta_equal_cd - |.endif - |. lw STR:TMP1, -4(RD) // KBASE-4-str_const*4 - | addiu TMP0, TMP0, -LJ_TSTR - | decode_RD4b TMP2 - | xor TMP1, STR:TMP1, STR:TMP3 - | or TMP0, TMP0, TMP1 - | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) - | addu TMP2, TMP2, TMP3 - if (vk) { - | movn TMP2, r0, TMP0 - } else { - | movz TMP2, r0, TMP0 - } - | addu PC, PC, TMP2 - | ins_next - break; - - case BC_ISEQN: case BC_ISNEN: - vk = op == BC_ISEQN; - | // RA = src*8, RD = num_const*8, JMP with RD = target - | addu RA, BASE, RA - | addiu PC, PC, 4 - | lw TMP0, HI(RA) - | ldc1 f0, 0(RA) - | addu RD, KBASE, RD - | lhu TMP2, -4+OFS_RD(PC) - | ldc1 f2, 0(RD) - | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) - | sltiu AT, TMP0, LJ_TISNUM - | decode_RD4b TMP2 - |.if FFI - | beqz AT, >5 - |.else - | beqz AT, >1 - |.endif - |. addu TMP2, TMP2, TMP3 - | c.eq.d f0, f2 - if (vk) { - | movf TMP2, r0 - | addu PC, PC, TMP2 - |1: - } else { - | movt TMP2, r0 - |1: - | addu PC, PC, TMP2 - } - | ins_next - |.if FFI - |5: - | li AT, LJ_TCDATA - | beq TMP0, AT, ->vmeta_equal_cd - |. nop - | b <1 - |. nop - |.endif - break; - - case BC_ISEQP: case BC_ISNEP: - vk = op == BC_ISEQP; - | // RA = src*8, RD = primitive_type*8 (~), JMP with RD = target - | addu RA, BASE, RA - | srl TMP1, RD, 3 - | lw TMP0, HI(RA) - | lhu TMP2, OFS_RD(PC) - | not TMP1, TMP1 - | addiu PC, PC, 4 - |.if FFI - | li AT, LJ_TCDATA - | beq TMP0, AT, ->vmeta_equal_cd - |.endif - |. xor TMP0, TMP0, TMP1 - | decode_RD4b TMP2 - | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) - | addu TMP2, TMP2, TMP3 - if (vk) { - | movn TMP2, r0, TMP0 - } else { - | movz TMP2, r0, TMP0 - } - | addu PC, PC, TMP2 - | ins_next - break; - - /* -- Unary test and copy ops ------------------------------------------- */ - - case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: - | // RA = dst*8 or unused, RD = src*8, JMP with RD = target - | addu RD, BASE, RD - | lhu TMP2, OFS_RD(PC) - | lw TMP0, HI(RD) - | addiu PC, PC, 4 - if (op == BC_IST || op == BC_ISF) { - | sltiu TMP0, TMP0, LJ_TISTRUECOND - | decode_RD4b TMP2 - | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) - | addu TMP2, TMP2, TMP3 - if (op == BC_IST) { - | movz TMP2, r0, TMP0 - } else { - | movn TMP2, r0, TMP0 - } - | addu PC, PC, TMP2 - } else { - | sltiu TMP0, TMP0, LJ_TISTRUECOND - | ldc1 f0, 0(RD) - if (op == BC_ISTC) { - | beqz TMP0, >1 - } else { - | bnez TMP0, >1 - } - |. addu RA, BASE, RA - | decode_RD4b TMP2 - | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) - | addu TMP2, TMP2, TMP3 - | sdc1 f0, 0(RA) - | addu PC, PC, TMP2 - |1: - } - | ins_next - break; - - /* -- Unary ops --------------------------------------------------------- */ - - case BC_MOV: - | // RA = dst*8, RD = src*8 - | addu RD, BASE, RD - | addu RA, BASE, RA - | ldc1 f0, 0(RD) - | ins_next1 - | sdc1 f0, 0(RA) - | ins_next2 - break; - case BC_NOT: - | // RA = dst*8, RD = src*8 - | addu RD, BASE, RD - | addu RA, BASE, RA - | lw TMP0, HI(RD) - | li TMP1, LJ_TFALSE - | sltiu TMP0, TMP0, LJ_TISTRUECOND - | addiu TMP1, TMP0, LJ_TTRUE - | ins_next1 - | sw TMP1, HI(RA) - | ins_next2 - break; - case BC_UNM: - | // RA = dst*8, RD = src*8 - | addu CARG3, BASE, RD - | addu RA, BASE, RA - | lw TMP0, HI(CARG3) - | ldc1 f0, 0(CARG3) - | sltiu AT, TMP0, LJ_TISNUM - | beqz AT, ->vmeta_unm - |. neg.d f0, f0 - | ins_next1 - | sdc1 f0, 0(RA) - | ins_next2 - break; - case BC_LEN: - | // RA = dst*8, RD = src*8 - | addu CARG2, BASE, RD - | addu RA, BASE, RA - | lw TMP0, HI(CARG2) - | lw CARG1, LO(CARG2) - | li AT, LJ_TSTR - | bne TMP0, AT, >2 - |. li AT, LJ_TTAB - | lw CRET1, STR:CARG1->len - |1: - | mtc1 CRET1, f0 - | cvt.d.w f0, f0 - | ins_next1 - | sdc1 f0, 0(RA) - | ins_next2 - |2: - | bne TMP0, AT, ->vmeta_len - |. nop -#if LJ_52 - | lw TAB:TMP2, TAB:CARG1->metatable - | bnez TAB:TMP2, >9 - |. nop - |3: -#endif - |->BC_LEN_Z: - | load_got lj_tab_len - | call_intern lj_tab_len // (GCtab *t) - |. nop - | // Returns uint32_t (but less than 2^31). - | b <1 - |. nop -#if LJ_52 - |9: - | lbu TMP0, TAB:TMP2->nomm - | andi TMP0, TMP0, 1<vmeta_len - |. nop -#endif - break; - - /* -- Binary ops -------------------------------------------------------- */ - - |.macro ins_arithpre - ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); - | decode_RB8a RB, INS - | decode_RB8b RB - | decode_RDtoRC8 RC, RD - | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 - ||switch (vk) { - ||case 0: - | addu CARG3, BASE, RB - | addu CARG4, KBASE, RC - | lw TMP1, HI(CARG3) - | ldc1 f20, 0(CARG3) - | ldc1 f22, 0(CARG4) - | sltiu AT, TMP1, LJ_TISNUM - || break; - ||case 1: - | addu CARG4, BASE, RB - | addu CARG3, KBASE, RC - | lw TMP1, HI(CARG4) - | ldc1 f22, 0(CARG4) - | ldc1 f20, 0(CARG3) - | sltiu AT, TMP1, LJ_TISNUM - || break; - ||default: - | addu CARG3, BASE, RB - | addu CARG4, BASE, RC - | lw TMP1, HI(CARG3) - | lw TMP2, HI(CARG4) - | ldc1 f20, 0(CARG3) - | ldc1 f22, 0(CARG4) - | sltiu AT, TMP1, LJ_TISNUM - | sltiu TMP0, TMP2, LJ_TISNUM - | and AT, AT, TMP0 - || break; - ||} - | beqz AT, ->vmeta_arith - |. addu RA, BASE, RA - |.endmacro - | - |.macro fpmod, a, b, c - |->BC_MODVN_Z: - | bal ->vm_floor // floor(b/c) - |. div.d FARG1, b, c - | mul.d a, FRET1, c - | sub.d a, b, a // b - floor(b/c)*c - |.endmacro - | - |.macro ins_arith, ins - | ins_arithpre - |.if "ins" == "fpmod_" - | b ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. - |. nop - |.else - | ins f0, f20, f22 - | ins_next1 - | sdc1 f0, 0(RA) - | ins_next2 - |.endif - |.endmacro - - case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: - | ins_arith add.d - break; - case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: - | ins_arith sub.d - break; - case BC_MULVN: case BC_MULNV: case BC_MULVV: - | ins_arith mul.d - break; - case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: - | ins_arith div.d - break; - case BC_MODVN: - | ins_arith fpmod - break; - case BC_MODNV: case BC_MODVV: - | ins_arith fpmod_ - break; - case BC_POW: - | decode_RB8a RB, INS - | decode_RB8b RB - | decode_RDtoRC8 RC, RD - | addu CARG3, BASE, RB - | addu CARG4, BASE, RC - | lw TMP1, HI(CARG3) - | lw TMP2, HI(CARG4) - | ldc1 FARG1, 0(CARG3) - | ldc1 FARG2, 0(CARG4) - | sltiu AT, TMP1, LJ_TISNUM - | sltiu TMP0, TMP2, LJ_TISNUM - | and AT, AT, TMP0 - | load_got pow - | beqz AT, ->vmeta_arith - |. addu RA, BASE, RA - | call_extern - |. nop - | ins_next1 - | sdc1 FRET1, 0(RA) - | ins_next2 - break; - - case BC_CAT: - | // RA = dst*8, RB = src_start*8, RC = src_end*8 - | decode_RB8a RB, INS - | decode_RB8b RB - | decode_RDtoRC8 RC, RD - | subu CARG3, RC, RB - | sw BASE, L->base - | addu CARG2, BASE, RC - | move MULTRES, RB - |->BC_CAT_Z: - | load_got lj_meta_cat - | srl CARG3, CARG3, 3 - | sw PC, SAVE_PC - | call_intern lj_meta_cat // (lua_State *L, TValue *top, int left) - |. move CARG1, L - | // Returns NULL (finished) or TValue * (metamethod). - | bnez CRET1, ->vmeta_binop - |. lw BASE, L->base - | addu RB, BASE, MULTRES - | ldc1 f0, 0(RB) - | addu RA, BASE, RA - | ins_next1 - | sdc1 f0, 0(RA) // Copy result from RB to RA. - | ins_next2 - break; - - /* -- Constant ops ------------------------------------------------------ */ - - case BC_KSTR: - | // RA = dst*8, RD = str_const*8 (~) - | srl TMP1, RD, 1 - | subu TMP1, KBASE, TMP1 - | ins_next1 - | lw TMP0, -4(TMP1) // KBASE-4-str_const*4 - | addu RA, BASE, RA - | li TMP2, LJ_TSTR - | sw TMP0, LO(RA) - | sw TMP2, HI(RA) - | ins_next2 - break; - case BC_KCDATA: - |.if FFI - | // RA = dst*8, RD = cdata_const*8 (~) - | srl TMP1, RD, 1 - | subu TMP1, KBASE, TMP1 - | ins_next1 - | lw TMP0, -4(TMP1) // KBASE-4-cdata_const*4 - | addu RA, BASE, RA - | li TMP2, LJ_TCDATA - | sw TMP0, LO(RA) - | sw TMP2, HI(RA) - | ins_next2 - |.endif - break; - case BC_KSHORT: - | // RA = dst*8, RD = int16_literal*8 - | sra RD, INS, 16 - | mtc1 RD, f0 - | addu RA, BASE, RA - | cvt.d.w f0, f0 - | ins_next1 - | sdc1 f0, 0(RA) - | ins_next2 - break; - case BC_KNUM: - | // RA = dst*8, RD = num_const*8 - | addu RD, KBASE, RD - | addu RA, BASE, RA - | ldc1 f0, 0(RD) - | ins_next1 - | sdc1 f0, 0(RA) - | ins_next2 - break; - case BC_KPRI: - | // RA = dst*8, RD = primitive_type*8 (~) - | srl TMP1, RD, 3 - | addu RA, BASE, RA - | not TMP0, TMP1 - | ins_next1 - | sw TMP0, HI(RA) - | ins_next2 - break; - case BC_KNIL: - | // RA = base*8, RD = end*8 - | addu RA, BASE, RA - | sw TISNIL, HI(RA) - | addiu RA, RA, 8 - | addu RD, BASE, RD - |1: - | sw TISNIL, HI(RA) - | slt AT, RA, RD - | bnez AT, <1 - |. addiu RA, RA, 8 - | ins_next_ - break; - - /* -- Upvalue and function ops ------------------------------------------ */ - - case BC_UGET: - | // RA = dst*8, RD = uvnum*8 - | lw LFUNC:RB, FRAME_FUNC(BASE) - | srl RD, RD, 1 - | addu RD, RD, LFUNC:RB - | lw UPVAL:RB, LFUNC:RD->uvptr - | ins_next1 - | lw TMP1, UPVAL:RB->v - | ldc1 f0, 0(TMP1) - | addu RA, BASE, RA - | sdc1 f0, 0(RA) - | ins_next2 - break; - case BC_USETV: - | // RA = uvnum*8, RD = src*8 - | lw LFUNC:RB, FRAME_FUNC(BASE) - | srl RA, RA, 1 - | addu RD, BASE, RD - | addu RA, RA, LFUNC:RB - | ldc1 f0, 0(RD) - | lw UPVAL:RB, LFUNC:RA->uvptr - | lbu TMP3, UPVAL:RB->marked - | lw CARG2, UPVAL:RB->v - | andi TMP3, TMP3, LJ_GC_BLACK // isblack(uv) - | lbu TMP0, UPVAL:RB->closed - | lw TMP2, HI(RD) - | sdc1 f0, 0(CARG2) - | li AT, LJ_GC_BLACK|1 - | or TMP3, TMP3, TMP0 - | beq TMP3, AT, >2 // Upvalue is closed and black? - |. addiu TMP2, TMP2, -(LJ_TNUMX+1) - |1: - | ins_next - | - |2: // Check if new value is collectable. - | sltiu AT, TMP2, LJ_TISGCV - (LJ_TNUMX+1) - | beqz AT, <1 // tvisgcv(v) - |. lw TMP1, LO(RD) - | lbu TMP3, GCOBJ:TMP1->gch.marked - | andi TMP3, TMP3, LJ_GC_WHITES // iswhite(v) - | beqz TMP3, <1 - |. load_got lj_gc_barrieruv - | // Crossed a write barrier. Move the barrier forward. - | call_intern lj_gc_barrieruv // (global_State *g, TValue *tv) - |. addiu CARG1, DISPATCH, GG_DISP2G - | b <1 - |. nop - break; - case BC_USETS: - | // RA = uvnum*8, RD = str_const*8 (~) - | lw LFUNC:RB, FRAME_FUNC(BASE) - | srl RA, RA, 1 - | srl TMP1, RD, 1 - | addu RA, RA, LFUNC:RB - | subu TMP1, KBASE, TMP1 - | lw UPVAL:RB, LFUNC:RA->uvptr - | lw STR:TMP1, -4(TMP1) // KBASE-4-str_const*4 - | lbu TMP2, UPVAL:RB->marked - | lw CARG2, UPVAL:RB->v - | lbu TMP3, STR:TMP1->marked - | andi AT, TMP2, LJ_GC_BLACK // isblack(uv) - | lbu TMP2, UPVAL:RB->closed - | li TMP0, LJ_TSTR - | sw STR:TMP1, LO(CARG2) - | bnez AT, >2 - |. sw TMP0, HI(CARG2) - |1: - | ins_next - | - |2: // Check if string is white and ensure upvalue is closed. - | beqz TMP2, <1 - |. andi AT, TMP3, LJ_GC_WHITES // iswhite(str) - | beqz AT, <1 - |. load_got lj_gc_barrieruv - | // Crossed a write barrier. Move the barrier forward. - | call_intern lj_gc_barrieruv // (global_State *g, TValue *tv) - |. addiu CARG1, DISPATCH, GG_DISP2G - | b <1 - |. nop - break; - case BC_USETN: - | // RA = uvnum*8, RD = num_const*8 - | lw LFUNC:RB, FRAME_FUNC(BASE) - | srl RA, RA, 1 - | addu RD, KBASE, RD - | addu RA, RA, LFUNC:RB - | ldc1 f0, 0(RD) - | lw UPVAL:RB, LFUNC:RA->uvptr - | ins_next1 - | lw TMP1, UPVAL:RB->v - | sdc1 f0, 0(TMP1) - | ins_next2 - break; - case BC_USETP: - | // RA = uvnum*8, RD = primitive_type*8 (~) - | lw LFUNC:RB, FRAME_FUNC(BASE) - | srl RA, RA, 1 - | srl TMP0, RD, 3 - | addu RA, RA, LFUNC:RB - | not TMP0, TMP0 - | lw UPVAL:RB, LFUNC:RA->uvptr - | ins_next1 - | lw TMP1, UPVAL:RB->v - | sw TMP0, HI(TMP1) - | ins_next2 - break; - - case BC_UCLO: - | // RA = level*8, RD = target - | lw TMP2, L->openupval - | branch_RD // Do this first since RD is not saved. - | load_got lj_func_closeuv - | sw BASE, L->base - | beqz TMP2, >1 - |. move CARG1, L - | call_intern lj_func_closeuv // (lua_State *L, TValue *level) - |. addu CARG2, BASE, RA - | lw BASE, L->base - |1: - | ins_next - break; - - case BC_FNEW: - | // RA = dst*8, RD = proto_const*8 (~) (holding function prototype) - | srl TMP1, RD, 1 - | load_got lj_func_newL_gc - | subu TMP1, KBASE, TMP1 - | lw CARG3, FRAME_FUNC(BASE) - | lw CARG2, -4(TMP1) // KBASE-4-tab_const*4 - | sw BASE, L->base - | sw PC, SAVE_PC - | // (lua_State *L, GCproto *pt, GCfuncL *parent) - | call_intern lj_func_newL_gc - |. move CARG1, L - | // Returns GCfuncL *. - | lw BASE, L->base - | li TMP0, LJ_TFUNC - | ins_next1 - | addu RA, BASE, RA - | sw TMP0, HI(RA) - | sw LFUNC:CRET1, LO(RA) - | ins_next2 - break; - - /* -- Table ops --------------------------------------------------------- */ - - case BC_TNEW: - case BC_TDUP: - | // RA = dst*8, RD = (hbits|asize)*8 | tab_const*8 (~) - | lw TMP0, DISPATCH_GL(gc.total)(DISPATCH) - | lw TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) - | sw BASE, L->base - | sw PC, SAVE_PC - | sltu AT, TMP0, TMP1 - | beqz AT, >5 - |1: - if (op == BC_TNEW) { - | load_got lj_tab_new - | srl CARG2, RD, 3 - | andi CARG2, CARG2, 0x7ff - | li TMP0, 0x801 - | addiu AT, CARG2, -0x7ff - | srl CARG3, RD, 14 - | movz CARG2, TMP0, AT - | // (lua_State *L, int32_t asize, uint32_t hbits) - | call_intern lj_tab_new - |. move CARG1, L - | // Returns Table *. - } else { - | load_got lj_tab_dup - | srl TMP1, RD, 1 - | subu TMP1, KBASE, TMP1 - | move CARG1, L - | call_intern lj_tab_dup // (lua_State *L, Table *kt) - |. lw CARG2, -4(TMP1) // KBASE-4-str_const*4 - | // Returns Table *. - } - | lw BASE, L->base - | ins_next1 - | addu RA, BASE, RA - | li TMP0, LJ_TTAB - | sw TAB:CRET1, LO(RA) - | sw TMP0, HI(RA) - | ins_next2 - |5: - | load_got lj_gc_step_fixtop - | move MULTRES, RD - | call_intern lj_gc_step_fixtop // (lua_State *L) - |. move CARG1, L - | b <1 - |. move RD, MULTRES - break; - - case BC_GGET: - | // RA = dst*8, RD = str_const*8 (~) - case BC_GSET: - | // RA = src*8, RD = str_const*8 (~) - | lw LFUNC:TMP2, FRAME_FUNC(BASE) - | srl TMP1, RD, 1 - | subu TMP1, KBASE, TMP1 - | lw TAB:RB, LFUNC:TMP2->env - | lw STR:RC, -4(TMP1) // KBASE-4-str_const*4 - if (op == BC_GGET) { - | b ->BC_TGETS_Z - } else { - | b ->BC_TSETS_Z - } - |. addu RA, BASE, RA - break; - - case BC_TGETV: - | // RA = dst*8, RB = table*8, RC = key*8 - | decode_RB8a RB, INS - | decode_RB8b RB - | decode_RDtoRC8 RC, RD - | addu CARG2, BASE, RB - | addu CARG3, BASE, RC - | lw TMP1, HI(CARG2) - | lw TMP2, HI(CARG3) - | lw TAB:RB, LO(CARG2) - | li AT, LJ_TTAB - | ldc1 f0, 0(CARG3) - | bne TMP1, AT, ->vmeta_tgetv - |. addu RA, BASE, RA - | sltiu AT, TMP2, LJ_TISNUM - | beqz AT, >5 - |. li AT, LJ_TSTR - | - | // Convert number key to integer, check for integerness and range. - | cvt.w.d f2, f0 - | lw TMP0, TAB:RB->asize - | mfc1 TMP2, f2 - | cvt.d.w f4, f2 - | lw TMP1, TAB:RB->array - | c.eq.d f0, f4 - | sltu AT, TMP2, TMP0 - | movf AT, r0 - | sll TMP2, TMP2, 3 - | beqz AT, ->vmeta_tgetv // Integer key and in array part? - |. addu TMP2, TMP1, TMP2 - | lw TMP0, HI(TMP2) - | beq TMP0, TISNIL, >2 - |. ldc1 f0, 0(TMP2) - |1: - | ins_next1 - | sdc1 f0, 0(RA) - | ins_next2 - | - |2: // Check for __index if table value is nil. - | lw TAB:TMP2, TAB:RB->metatable - | beqz TAB:TMP2, <1 // No metatable: done. - |. nop - | lbu TMP0, TAB:TMP2->nomm - | andi TMP0, TMP0, 1<vmeta_tgetv - |. nop - | - |5: - | bne TMP2, AT, ->vmeta_tgetv - |. lw STR:RC, LO(CARG3) - | b ->BC_TGETS_Z // String key? - |. nop - break; - case BC_TGETS: - | // RA = dst*8, RB = table*8, RC = str_const*4 (~) - | decode_RB8a RB, INS - | decode_RB8b RB - | addu CARG2, BASE, RB - | decode_RC4a RC, INS - | lw TMP0, HI(CARG2) - | decode_RC4b RC - | li AT, LJ_TTAB - | lw TAB:RB, LO(CARG2) - | subu CARG3, KBASE, RC - | lw STR:RC, -4(CARG3) // KBASE-4-str_const*4 - | bne TMP0, AT, ->vmeta_tgets1 - |. addu RA, BASE, RA - |->BC_TGETS_Z: - | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = dst*8 - | lw TMP0, TAB:RB->hmask - | lw TMP1, STR:RC->hash - | lw NODE:TMP2, TAB:RB->node - | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask - | sll TMP0, TMP1, 5 - | sll TMP1, TMP1, 3 - | subu TMP1, TMP0, TMP1 - | addu NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) - |1: - | lw CARG1, offsetof(Node, key)+HI(NODE:TMP2) - | lw TMP0, offsetof(Node, key)+LO(NODE:TMP2) - | lw NODE:TMP1, NODE:TMP2->next - | lw CARG2, offsetof(Node, val)+HI(NODE:TMP2) - | addiu CARG1, CARG1, -LJ_TSTR - | xor TMP0, TMP0, STR:RC - | or AT, CARG1, TMP0 - | bnez AT, >4 - |. lw TAB:TMP3, TAB:RB->metatable - | beq CARG2, TISNIL, >5 // Key found, but nil value? - |. lw CARG1, offsetof(Node, val)+LO(NODE:TMP2) - |3: - | ins_next1 - | sw CARG2, HI(RA) - | sw CARG1, LO(RA) - | ins_next2 - | - |4: // Follow hash chain. - | bnez NODE:TMP1, <1 - |. move NODE:TMP2, NODE:TMP1 - | // End of hash chain: key not found, nil result. - | - |5: // Check for __index if table value is nil. - | beqz TAB:TMP3, <3 // No metatable: done. - |. li CARG2, LJ_TNIL - | lbu TMP0, TAB:TMP3->nomm - | andi TMP0, TMP0, 1<vmeta_tgets - |. nop - break; - case BC_TGETB: - | // RA = dst*8, RB = table*8, RC = index*8 - | decode_RB8a RB, INS - | decode_RB8b RB - | addu CARG2, BASE, RB - | decode_RDtoRC8 RC, RD - | lw CARG1, HI(CARG2) - | li AT, LJ_TTAB - | lw TAB:RB, LO(CARG2) - | addu RA, BASE, RA - | bne CARG1, AT, ->vmeta_tgetb - |. srl TMP0, RC, 3 - | lw TMP1, TAB:RB->asize - | lw TMP2, TAB:RB->array - | sltu AT, TMP0, TMP1 - | beqz AT, ->vmeta_tgetb - |. addu RC, TMP2, RC - | lw TMP1, HI(RC) - | beq TMP1, TISNIL, >5 - |. ldc1 f0, 0(RC) - |1: - | ins_next1 - | sdc1 f0, 0(RA) - | ins_next2 - | - |5: // Check for __index if table value is nil. - | lw TAB:TMP2, TAB:RB->metatable - | beqz TAB:TMP2, <1 // No metatable: done. - |. nop - | lbu TMP1, TAB:TMP2->nomm - | andi TMP1, TMP1, 1<vmeta_tgetb // Caveat: preserve TMP0! - |. nop - break; - - case BC_TSETV: - | // RA = src*8, RB = table*8, RC = key*8 - | decode_RB8a RB, INS - | decode_RB8b RB - | decode_RDtoRC8 RC, RD - | addu CARG2, BASE, RB - | addu CARG3, BASE, RC - | lw TMP1, HI(CARG2) - | lw TMP2, HI(CARG3) - | lw TAB:RB, LO(CARG2) - | li AT, LJ_TTAB - | ldc1 f0, 0(CARG3) - | bne TMP1, AT, ->vmeta_tsetv - |. addu RA, BASE, RA - | sltiu AT, TMP2, LJ_TISNUM - | beqz AT, >5 - |. li AT, LJ_TSTR - | - | // Convert number key to integer, check for integerness and range. - | cvt.w.d f2, f0 - | lw TMP0, TAB:RB->asize - | mfc1 TMP2, f2 - | cvt.d.w f4, f2 - | lw TMP1, TAB:RB->array - | c.eq.d f0, f4 - | sltu AT, TMP2, TMP0 - | movf AT, r0 - | sll TMP2, TMP2, 3 - | beqz AT, ->vmeta_tsetv // Integer key and in array part? - |. addu TMP1, TMP1, TMP2 - | lbu TMP3, TAB:RB->marked - | lw TMP0, HI(TMP1) - | beq TMP0, TISNIL, >3 - |. ldc1 f0, 0(RA) - |1: - | andi AT, TMP3, LJ_GC_BLACK // isblack(table) - | bnez AT, >7 - |. sdc1 f0, 0(TMP1) - |2: - | ins_next - | - |3: // Check for __newindex if previous value is nil. - | lw TAB:TMP2, TAB:RB->metatable - | beqz TAB:TMP2, <1 // No metatable: done. - |. nop - | lbu TMP2, TAB:TMP2->nomm - | andi TMP2, TMP2, 1<vmeta_tsetv - |. nop - | - |5: - | bne TMP2, AT, ->vmeta_tsetv - |. lw STR:RC, LO(CARG3) - | b ->BC_TSETS_Z // String key? - |. nop - | - |7: // Possible table write barrier for the value. Skip valiswhite check. - | barrierback TAB:RB, TMP3, TMP0, <2 - break; - case BC_TSETS: - | // RA = src*8, RB = table*8, RC = str_const*8 (~) - | decode_RB8a RB, INS - | decode_RB8b RB - | addu CARG2, BASE, RB - | decode_RC4a RC, INS - | lw TMP0, HI(CARG2) - | decode_RC4b RC - | li AT, LJ_TTAB - | subu CARG3, KBASE, RC - | lw TAB:RB, LO(CARG2) - | lw STR:RC, -4(CARG3) // KBASE-4-str_const*4 - | bne TMP0, AT, ->vmeta_tsets1 - |. addu RA, BASE, RA - |->BC_TSETS_Z: - | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = BASE+src*8 - | lw TMP0, TAB:RB->hmask - | lw TMP1, STR:RC->hash - | lw NODE:TMP2, TAB:RB->node - | sb r0, TAB:RB->nomm // Clear metamethod cache. - | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask - | sll TMP0, TMP1, 5 - | sll TMP1, TMP1, 3 - | subu TMP1, TMP0, TMP1 - | addu NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) - | ldc1 f20, 0(RA) - |1: - | lw CARG1, offsetof(Node, key)+HI(NODE:TMP2) - | lw TMP0, offsetof(Node, key)+LO(NODE:TMP2) - | li AT, LJ_TSTR - | lw NODE:TMP1, NODE:TMP2->next - | bne CARG1, AT, >5 - |. lw CARG2, offsetof(Node, val)+HI(NODE:TMP2) - | bne TMP0, STR:RC, >5 - |. lbu TMP3, TAB:RB->marked - | beq CARG2, TISNIL, >4 // Key found, but nil value? - |. lw TAB:TMP0, TAB:RB->metatable - |2: - | andi AT, TMP3, LJ_GC_BLACK // isblack(table) - | bnez AT, >7 - |. sdc1 f20, NODE:TMP2->val - |3: - | ins_next - | - |4: // Check for __newindex if previous value is nil. - | beqz TAB:TMP0, <2 // No metatable: done. - |. nop - | lbu TMP0, TAB:TMP0->nomm - | andi TMP0, TMP0, 1<vmeta_tsets - |. nop - | - |5: // Follow hash chain. - | bnez NODE:TMP1, <1 - |. move NODE:TMP2, NODE:TMP1 - | // End of hash chain: key not found, add a new one - | - | // But check for __newindex first. - | lw TAB:TMP2, TAB:RB->metatable - | beqz TAB:TMP2, >6 // No metatable: continue. - |. addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) - | lbu TMP0, TAB:TMP2->nomm - | andi TMP0, TMP0, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. - |. li AT, LJ_TSTR - |6: - | load_got lj_tab_newkey - | sw STR:RC, LO(CARG3) - | sw AT, HI(CARG3) - | sw BASE, L->base - | move CARG2, TAB:RB - | sw PC, SAVE_PC - | call_intern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k - |. move CARG1, L - | // Returns TValue *. - | lw BASE, L->base - | b <3 // No 2nd write barrier needed. - |. sdc1 f20, 0(CRET1) - | - |7: // Possible table write barrier for the value. Skip valiswhite check. - | barrierback TAB:RB, TMP3, TMP0, <3 - break; - case BC_TSETB: - | // RA = src*8, RB = table*8, RC = index*8 - | decode_RB8a RB, INS - | decode_RB8b RB - | addu CARG2, BASE, RB - | decode_RDtoRC8 RC, RD - | lw CARG1, HI(CARG2) - | li AT, LJ_TTAB - | lw TAB:RB, LO(CARG2) - | addu RA, BASE, RA - | bne CARG1, AT, ->vmeta_tsetb - |. srl TMP0, RC, 3 - | lw TMP1, TAB:RB->asize - | lw TMP2, TAB:RB->array - | sltu AT, TMP0, TMP1 - | beqz AT, ->vmeta_tsetb - |. addu RC, TMP2, RC - | lw TMP1, HI(RC) - | lbu TMP3, TAB:RB->marked - | beq TMP1, TISNIL, >5 - |. ldc1 f0, 0(RA) - |1: - | andi AT, TMP3, LJ_GC_BLACK // isblack(table) - | bnez AT, >7 - |. sdc1 f0, 0(RC) - |2: - | ins_next - | - |5: // Check for __newindex if previous value is nil. - | lw TAB:TMP2, TAB:RB->metatable - | beqz TAB:TMP2, <1 // No metatable: done. - |. nop - | lbu TMP1, TAB:TMP2->nomm - | andi TMP1, TMP1, 1<vmeta_tsetb // Caveat: preserve TMP0! - |. nop - | - |7: // Possible table write barrier for the value. Skip valiswhite check. - | barrierback TAB:RB, TMP3, TMP0, <2 - break; - - case BC_TSETM: - | // RA = base*8 (table at base-1), RD = num_const*8 (start index) - | addu RA, BASE, RA - |1: - | addu TMP3, KBASE, RD - | lw TAB:CARG2, -8+LO(RA) // Guaranteed to be a table. - | addiu TMP0, MULTRES, -8 - | lw TMP3, LO(TMP3) // Integer constant is in lo-word. - | beqz TMP0, >4 // Nothing to copy? - |. srl CARG3, TMP0, 3 - | addu CARG3, CARG3, TMP3 - | lw TMP2, TAB:CARG2->asize - | sll TMP1, TMP3, 3 - | lbu TMP3, TAB:CARG2->marked - | lw CARG1, TAB:CARG2->array - | sltu AT, TMP2, CARG3 - | bnez AT, >5 - |. addu TMP2, RA, TMP0 - | addu TMP1, TMP1, CARG1 - | andi TMP0, TMP3, LJ_GC_BLACK // isblack(table) - |3: // Copy result slots to table. - | ldc1 f0, 0(RA) - | addiu RA, RA, 8 - | sltu AT, RA, TMP2 - | sdc1 f0, 0(TMP1) - | bnez AT, <3 - |. addiu TMP1, TMP1, 8 - | bnez TMP0, >7 - |. nop - |4: - | ins_next - | - |5: // Need to resize array part. - | load_got lj_tab_reasize - | sw BASE, L->base - | sw PC, SAVE_PC - | move BASE, RD - | call_intern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) - |. move CARG1, L - | // Must not reallocate the stack. - | move RD, BASE - | b <1 - |. lw BASE, L->base // Reload BASE for lack of a saved register. - | - |7: // Possible table write barrier for any value. Skip valiswhite check. - | barrierback TAB:CARG2, TMP3, TMP0, <4 - break; - - /* -- Calls and vararg handling ----------------------------------------- */ - - case BC_CALLM: - | // RA = base*8, (RB = (nresults+1)*8,) RC = extra_nargs*8 - | decode_RDtoRC8 NARGS8:RC, RD - | b ->BC_CALL_Z - |. addu NARGS8:RC, NARGS8:RC, MULTRES - break; - case BC_CALL: - | // RA = base*8, (RB = (nresults+1)*8,) RC = (nargs+1)*8 - | decode_RDtoRC8 NARGS8:RC, RD - |->BC_CALL_Z: - | move TMP2, BASE - | addu BASE, BASE, RA - | li AT, LJ_TFUNC - | lw TMP0, HI(BASE) - | lw LFUNC:RB, LO(BASE) - | addiu BASE, BASE, 8 - | bne TMP0, AT, ->vmeta_call - |. addiu NARGS8:RC, NARGS8:RC, -8 - | ins_call - break; - - case BC_CALLMT: - | // RA = base*8, (RB = 0,) RC = extra_nargs*8 - | addu NARGS8:RD, NARGS8:RD, MULTRES // BC_CALLT gets RC from RD. - | // Fall through. Assumes BC_CALLT follows. - break; - case BC_CALLT: - | // RA = base*8, (RB = 0,) RC = (nargs+1)*8 - | addu RA, BASE, RA - | li AT, LJ_TFUNC - | lw TMP0, HI(RA) - | lw LFUNC:RB, LO(RA) - | move NARGS8:RC, RD - | lw TMP1, FRAME_PC(BASE) - | addiu RA, RA, 8 - | bne TMP0, AT, ->vmeta_callt - |. addiu NARGS8:RC, NARGS8:RC, -8 - |->BC_CALLT_Z: - | andi TMP0, TMP1, FRAME_TYPE // Caveat: preserve TMP0 until the 'or'. - | lbu TMP3, LFUNC:RB->ffid - | bnez TMP0, >7 - |. xori TMP2, TMP1, FRAME_VARG - |1: - | sw LFUNC:RB, FRAME_FUNC(BASE) // Copy function down, but keep PC. - | sltiu AT, TMP3, 2 // (> FF_C) Calling a fast function? - | move TMP2, BASE - | beqz NARGS8:RC, >3 - |. move TMP3, NARGS8:RC - |2: - | ldc1 f0, 0(RA) - | addiu RA, RA, 8 - | addiu TMP3, TMP3, -8 - | sdc1 f0, 0(TMP2) - | bnez TMP3, <2 - |. addiu TMP2, TMP2, 8 - |3: - | or TMP0, TMP0, AT - | beqz TMP0, >5 - |. nop - |4: - | ins_callt - | - |5: // Tailcall to a fast function with a Lua frame below. - | lw INS, -4(TMP1) - | decode_RA8a RA, INS - | decode_RA8b RA - | subu TMP1, BASE, RA - | lw LFUNC:TMP1, -8+FRAME_FUNC(TMP1) - | lw TMP1, LFUNC:TMP1->pc - | b <4 - |. lw KBASE, PC2PROTO(k)(TMP1) // Need to prepare KBASE. - | - |7: // Tailcall from a vararg function. - | andi AT, TMP2, FRAME_TYPEP - | bnez AT, <1 // Vararg frame below? - |. subu TMP2, BASE, TMP2 // Relocate BASE down. - | move BASE, TMP2 - | lw TMP1, FRAME_PC(TMP2) - | b <1 - |. andi TMP0, TMP1, FRAME_TYPE - break; - - case BC_ITERC: - | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 ((2+1)*8)) - | move TMP2, BASE - | addu BASE, BASE, RA - | li AT, LJ_TFUNC - | lw TMP1, -24+HI(BASE) - | lw LFUNC:RB, -24+LO(BASE) - | ldc1 f2, -8(BASE) - | ldc1 f0, -16(BASE) - | sw TMP1, HI(BASE) // Copy callable. - | sw LFUNC:RB, LO(BASE) - | sdc1 f2, 16(BASE) // Copy control var. - | sdc1 f0, 8(BASE) // Copy state. - | addiu BASE, BASE, 8 - | bne TMP1, AT, ->vmeta_call - |. li NARGS8:RC, 16 // Iterators get 2 arguments. - | ins_call - break; - - case BC_ITERN: - | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 (2+1)*8) - |.if JIT - | // NYI: add hotloop, record BC_ITERN. - |.endif - | addu RA, BASE, RA - | lw TAB:RB, -16+LO(RA) - | lw RC, -8+LO(RA) // Get index from control var. - | lw TMP0, TAB:RB->asize - | lw TMP1, TAB:RB->array - | addiu PC, PC, 4 - |1: // Traverse array part. - | sltu AT, RC, TMP0 - | beqz AT, >5 // Index points after array part? - |. sll TMP3, RC, 3 - | addu TMP3, TMP1, TMP3 - | lw TMP2, HI(TMP3) - | ldc1 f0, 0(TMP3) - | mtc1 RC, f2 - | lhu RD, -4+OFS_RD(PC) - | beq TMP2, TISNIL, <1 // Skip holes in array part. - |. addiu RC, RC, 1 - | cvt.d.w f2, f2 - | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) - | sdc1 f0, 8(RA) - | decode_RD4b RD - | addu RD, RD, TMP3 - | sw RC, -8+LO(RA) // Update control var. - | addu PC, PC, RD - | sdc1 f2, 0(RA) - |3: - | ins_next - | - |5: // Traverse hash part. - | lw TMP1, TAB:RB->hmask - | subu RC, RC, TMP0 - | lw TMP2, TAB:RB->node - |6: - | sltu AT, TMP1, RC // End of iteration? Branch to ITERL+1. - | bnez AT, <3 - |. sll TMP3, RC, 5 - | sll RB, RC, 3 - | subu TMP3, TMP3, RB - | addu NODE:TMP3, TMP3, TMP2 - | lw RB, HI(NODE:TMP3) - | ldc1 f0, 0(NODE:TMP3) - | lhu RD, -4+OFS_RD(PC) - | beq RB, TISNIL, <6 // Skip holes in hash part. - |. addiu RC, RC, 1 - | ldc1 f2, NODE:TMP3->key - | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) - | sdc1 f0, 8(RA) - | addu RC, RC, TMP0 - | decode_RD4b RD - | addu RD, RD, TMP3 - | sdc1 f2, 0(RA) - | addu PC, PC, RD - | b <3 - |. sw RC, -8+LO(RA) // Update control var. - break; - - case BC_ISNEXT: - | // RA = base*8, RD = target (points to ITERN) - | addu RA, BASE, RA - | lw TMP0, -24+HI(RA) - | lw CFUNC:TMP1, -24+LO(RA) - | lw TMP2, -16+HI(RA) - | lw TMP3, -8+HI(RA) - | li AT, LJ_TFUNC - | bne TMP0, AT, >5 - |. addiu TMP2, TMP2, -LJ_TTAB - | lbu TMP1, CFUNC:TMP1->ffid - | addiu TMP3, TMP3, -LJ_TNIL - | srl TMP0, RD, 1 - | or TMP2, TMP2, TMP3 - | addiu TMP1, TMP1, -FF_next_N - | addu TMP0, PC, TMP0 - | or TMP1, TMP1, TMP2 - | bnez TMP1, >5 - |. lui TMP2, (-(BCBIAS_J*4 >> 16) & 65535) - | addu PC, TMP0, TMP2 - | lui TMP1, 0xfffe - | ori TMP1, TMP1, 0x7fff - | sw r0, -8+LO(RA) // Initialize control var. - | sw TMP1, -8+HI(RA) - |1: - | ins_next - |5: // Despecialize bytecode if any of the checks fail. - | li TMP3, BC_JMP - | li TMP1, BC_ITERC - | sb TMP3, -4+OFS_OP(PC) - | addu PC, TMP0, TMP2 - | b <1 - |. sb TMP1, OFS_OP(PC) - break; - - case BC_VARG: - | // RA = base*8, RB = (nresults+1)*8, RC = numparams*8 - | lw TMP0, FRAME_PC(BASE) - | decode_RDtoRC8 RC, RD - | decode_RB8a RB, INS - | addu RC, BASE, RC - | decode_RB8b RB - | addu RA, BASE, RA - | addiu RC, RC, FRAME_VARG - | addu TMP2, RA, RB - | addiu TMP3, BASE, -8 // TMP3 = vtop - | subu RC, RC, TMP0 // RC = vbase - | // Note: RC may now be even _above_ BASE if nargs was < numparams. - | beqz RB, >5 // Copy all varargs? - |. subu TMP1, TMP3, RC - | addiu TMP2, TMP2, -16 - |1: // Copy vararg slots to destination slots. - | lw CARG1, HI(RC) - | sltu AT, RC, TMP3 - | lw CARG2, LO(RC) - | addiu RC, RC, 8 - | movz CARG1, TISNIL, AT - | sw CARG1, HI(RA) - | sw CARG2, LO(RA) - | sltu AT, RA, TMP2 - | bnez AT, <1 - |. addiu RA, RA, 8 - |3: - | ins_next - | - |5: // Copy all varargs. - | lw TMP0, L->maxstack - | blez TMP1, <3 // No vararg slots? - |. li MULTRES, 8 // MULTRES = (0+1)*8 - | addu TMP2, RA, TMP1 - | sltu AT, TMP0, TMP2 - | bnez AT, >7 - |. addiu MULTRES, TMP1, 8 - |6: - | ldc1 f0, 0(RC) - | addiu RC, RC, 8 - | sdc1 f0, 0(RA) - | sltu AT, RC, TMP3 - | bnez AT, <6 // More vararg slots? - |. addiu RA, RA, 8 - | b <3 - |. nop - | - |7: // Grow stack for varargs. - | load_got lj_state_growstack - | sw RA, L->top - | subu RA, RA, BASE - | sw BASE, L->base - | subu BASE, RC, BASE // Need delta, because BASE may change. - | sw PC, SAVE_PC - | srl CARG2, TMP1, 3 - | call_intern lj_state_growstack // (lua_State *L, int n) - |. move CARG1, L - | move RC, BASE - | lw BASE, L->base - | addu RA, BASE, RA - | addu RC, BASE, RC - | b <6 - |. addiu TMP3, BASE, -8 - break; - - /* -- Returns ----------------------------------------------------------- */ - - case BC_RETM: - | // RA = results*8, RD = extra_nresults*8 - | addu RD, RD, MULTRES // MULTRES >= 8, so RD >= 8. - | // Fall through. Assumes BC_RET follows. - break; - - case BC_RET: - | // RA = results*8, RD = (nresults+1)*8 - | lw PC, FRAME_PC(BASE) - | addu RA, BASE, RA - | move MULTRES, RD - |1: - | andi TMP0, PC, FRAME_TYPE - | bnez TMP0, ->BC_RETV_Z - |. xori TMP1, PC, FRAME_VARG - | - |->BC_RET_Z: - | // BASE = base, RA = resultptr, RD = (nresults+1)*8, PC = return - | lw INS, -4(PC) - | addiu TMP2, BASE, -8 - | addiu RC, RD, -8 - | decode_RA8a TMP0, INS - | decode_RB8a RB, INS - | decode_RA8b TMP0 - | decode_RB8b RB - | addu TMP3, TMP2, RB - | beqz RC, >3 - |. subu BASE, TMP2, TMP0 - |2: - | ldc1 f0, 0(RA) - | addiu RA, RA, 8 - | addiu RC, RC, -8 - | sdc1 f0, 0(TMP2) - | bnez RC, <2 - |. addiu TMP2, TMP2, 8 - |3: - | addiu TMP3, TMP3, -8 - |5: - | sltu AT, TMP2, TMP3 - | bnez AT, >6 - |. lw LFUNC:TMP1, FRAME_FUNC(BASE) - | ins_next1 - | lw TMP1, LFUNC:TMP1->pc - | lw KBASE, PC2PROTO(k)(TMP1) - | ins_next2 - | - |6: // Fill up results with nil. - | sw TISNIL, HI(TMP2) - | b <5 - |. addiu TMP2, TMP2, 8 - | - |->BC_RETV_Z: // Non-standard return case. - | andi TMP2, TMP1, FRAME_TYPEP - | bnez TMP2, ->vm_return - |. nop - | // Return from vararg function: relocate BASE down. - | subu BASE, BASE, TMP1 - | b <1 - |. lw PC, FRAME_PC(BASE) - break; - - case BC_RET0: case BC_RET1: - | // RA = results*8, RD = (nresults+1)*8 - | lw PC, FRAME_PC(BASE) - | addu RA, BASE, RA - | move MULTRES, RD - | andi TMP0, PC, FRAME_TYPE - | bnez TMP0, ->BC_RETV_Z - |. xori TMP1, PC, FRAME_VARG - | - | lw INS, -4(PC) - | addiu TMP2, BASE, -8 - if (op == BC_RET1) { - | ldc1 f0, 0(RA) - } - | decode_RB8a RB, INS - | decode_RA8a RA, INS - | decode_RB8b RB - | decode_RA8b RA - if (op == BC_RET1) { - | sdc1 f0, 0(TMP2) - } - | subu BASE, TMP2, RA - |5: - | sltu AT, RD, RB - | bnez AT, >6 - |. lw LFUNC:TMP1, FRAME_FUNC(BASE) - | ins_next1 - | lw TMP1, LFUNC:TMP1->pc - | lw KBASE, PC2PROTO(k)(TMP1) - | ins_next2 - | - |6: // Fill up results with nil. - | addiu TMP2, TMP2, 8 - | addiu RD, RD, 8 - | b <5 - if (op == BC_RET1) { - |. sw TISNIL, HI(TMP2) - } else { - |. sw TISNIL, -8+HI(TMP2) - } - break; - - /* -- Loops and branches ------------------------------------------------ */ - - case BC_FORL: - |.if JIT - | hotloop - |.endif - | // Fall through. Assumes BC_IFORL follows. - break; - - case BC_JFORI: - case BC_JFORL: -#if !LJ_HASJIT - break; -#endif - case BC_FORI: - case BC_IFORL: - | // RA = base*8, RD = target (after end of loop or start of loop) - vk = (op == BC_IFORL || op == BC_JFORL); - | addu RA, BASE, RA - if (vk) { - | ldc1 f0, FORL_IDX*8(RA) - | ldc1 f4, FORL_STEP*8(RA) - | ldc1 f2, FORL_STOP*8(RA) - | lw TMP3, FORL_STEP*8+HI(RA) - | add.d f0, f0, f4 - | sdc1 f0, FORL_IDX*8(RA) - } else { - | lw TMP1, FORL_IDX*8+HI(RA) - | lw TMP3, FORL_STEP*8+HI(RA) - | lw TMP2, FORL_STOP*8+HI(RA) - | sltiu TMP1, TMP1, LJ_TISNUM - | sltiu TMP0, TMP3, LJ_TISNUM - | sltiu TMP2, TMP2, LJ_TISNUM - | and TMP1, TMP1, TMP0 - | and TMP1, TMP1, TMP2 - | ldc1 f0, FORL_IDX*8(RA) - | beqz TMP1, ->vmeta_for - |. ldc1 f2, FORL_STOP*8(RA) - } - if (op != BC_JFORL) { - | srl RD, RD, 1 - | lui TMP0, (-(BCBIAS_J*4 >> 16) & 65535) - } - | c.le.d 0, f0, f2 - | c.le.d 1, f2, f0 - | sdc1 f0, FORL_EXT*8(RA) - if (op == BC_JFORI) { - | li TMP1, 1 - | li TMP2, 1 - | addu TMP0, RD, TMP0 - | slt TMP3, TMP3, r0 - | movf TMP1, r0, 0 - | addu PC, PC, TMP0 - | movf TMP2, r0, 1 - | lhu RD, -4+OFS_RD(PC) - | movn TMP1, TMP2, TMP3 - | bnez TMP1, =>BC_JLOOP - |. decode_RD8b RD - } else if (op == BC_JFORL) { - | li TMP1, 1 - | li TMP2, 1 - | slt TMP3, TMP3, r0 - | movf TMP1, r0, 0 - | movf TMP2, r0, 1 - | movn TMP1, TMP2, TMP3 - | bnez TMP1, =>BC_JLOOP - |. nop - } else { - | addu TMP1, RD, TMP0 - | slt TMP3, TMP3, r0 - | move TMP2, TMP1 - if (op == BC_FORI) { - | movt TMP1, r0, 0 - | movt TMP2, r0, 1 - } else { - | movf TMP1, r0, 0 - | movf TMP2, r0, 1 - } - | movn TMP1, TMP2, TMP3 - | addu PC, PC, TMP1 - } - | ins_next - break; - - case BC_ITERL: - |.if JIT - | hotloop - |.endif - | // Fall through. Assumes BC_IITERL follows. - break; - - case BC_JITERL: -#if !LJ_HASJIT - break; -#endif - case BC_IITERL: - | // RA = base*8, RD = target - | addu RA, BASE, RA - | lw TMP1, HI(RA) - | beq TMP1, TISNIL, >1 // Stop if iterator returned nil. - |. lw TMP2, LO(RA) - if (op == BC_JITERL) { - | sw TMP1, -8+HI(RA) - | b =>BC_JLOOP - |. sw TMP2, -8+LO(RA) - } else { - | branch_RD // Otherwise save control var + branch. - | sw TMP1, -8+HI(RA) - | sw TMP2, -8+LO(RA) - } - |1: - | ins_next - break; - - case BC_LOOP: - | // RA = base*8, RD = target (loop extent) - | // Note: RA/RD is only used by trace recorder to determine scope/extent - | // This opcode does NOT jump, it's only purpose is to detect a hot loop. - |.if JIT - | hotloop - |.endif - | // Fall through. Assumes BC_ILOOP follows. - break; - - case BC_ILOOP: - | // RA = base*8, RD = target (loop extent) - | ins_next - break; - - case BC_JLOOP: - |.if JIT - | // RA = base*8 (ignored), RD = traceno*8 - | lw TMP1, DISPATCH_J(trace)(DISPATCH) - | srl RD, RD, 1 - | li AT, 0 - | addu TMP1, TMP1, RD - | // Traces on MIPS don't store the trace number, so use 0. - | sw AT, DISPATCH_GL(vmstate)(DISPATCH) - | lw TRACE:TMP2, 0(TMP1) - | sw BASE, DISPATCH_GL(jit_base)(DISPATCH) - | sw L, DISPATCH_GL(jit_L)(DISPATCH) - | lw TMP2, TRACE:TMP2->mcode - | jr TMP2 - |. addiu JGL, DISPATCH, GG_DISP2G+32768 - |.endif - break; - - case BC_JMP: - | // RA = base*8 (only used by trace recorder), RD = target - | branch_RD - | ins_next - break; - - /* -- Function headers -------------------------------------------------- */ - - case BC_FUNCF: - |.if JIT - | hotcall - |.endif - case BC_FUNCV: /* NYI: compiled vararg functions. */ - | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow. - break; - - case BC_JFUNCF: -#if !LJ_HASJIT - break; -#endif - case BC_IFUNCF: - | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 - | lw TMP2, L->maxstack - | lbu TMP1, -4+PC2PROTO(numparams)(PC) - | lw KBASE, -4+PC2PROTO(k)(PC) - | sltu AT, TMP2, RA - | bnez AT, ->vm_growstack_l - |. sll TMP1, TMP1, 3 - if (op != BC_JFUNCF) { - | ins_next1 - } - |2: - | sltu AT, NARGS8:RC, TMP1 // Check for missing parameters. - | bnez AT, >3 - |. addu AT, BASE, NARGS8:RC - if (op == BC_JFUNCF) { - | decode_RD8a RD, INS - | b =>BC_JLOOP - |. decode_RD8b RD - } else { - | ins_next2 - } - | - |3: // Clear missing parameters. - | sw TISNIL, HI(AT) - | b <2 - |. addiu NARGS8:RC, NARGS8:RC, 8 - break; - - case BC_JFUNCV: -#if !LJ_HASJIT - break; -#endif - | NYI // NYI: compiled vararg functions - break; /* NYI: compiled vararg functions. */ - - case BC_IFUNCV: - | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 - | addu TMP1, BASE, RC - | lw TMP2, L->maxstack - | addu TMP0, RA, RC - | sw LFUNC:RB, LO(TMP1) // Store copy of LFUNC. - | addiu TMP3, RC, 8+FRAME_VARG - | sltu AT, TMP0, TMP2 - | lw KBASE, -4+PC2PROTO(k)(PC) - | beqz AT, ->vm_growstack_l - |. sw TMP3, HI(TMP1) // Store delta + FRAME_VARG. - | lbu TMP2, -4+PC2PROTO(numparams)(PC) - | move RA, BASE - | move RC, TMP1 - | ins_next1 - | beqz TMP2, >3 - |. addiu BASE, TMP1, 8 - |1: - | lw TMP0, HI(RA) - | lw TMP3, LO(RA) - | sltu AT, RA, RC // Less args than parameters? - | move CARG1, TMP0 - | movz TMP0, TISNIL, AT // Clear missing parameters. - | movn CARG1, TISNIL, AT // Clear old fixarg slot (help the GC). - | sw TMP3, 8+LO(TMP1) - | addiu TMP2, TMP2, -1 - | sw TMP0, 8+HI(TMP1) - | addiu TMP1, TMP1, 8 - | sw CARG1, HI(RA) - | bnez TMP2, <1 - |. addiu RA, RA, 8 - |3: - | ins_next2 - break; - - case BC_FUNCC: - case BC_FUNCCW: - | // BASE = new base, RA = BASE+framesize*8, RB = CFUNC, RC = nargs*8 - if (op == BC_FUNCC) { - | lw CFUNCADDR, CFUNC:RB->f - } else { - | lw CFUNCADDR, DISPATCH_GL(wrapf)(DISPATCH) - } - | addu TMP1, RA, NARGS8:RC - | lw TMP2, L->maxstack - | addu RC, BASE, NARGS8:RC - | sw BASE, L->base - | sltu AT, TMP2, TMP1 - | sw RC, L->top - | li_vmstate C - if (op == BC_FUNCCW) { - | lw CARG2, CFUNC:RB->f - } - | bnez AT, ->vm_growstack_c // Need to grow stack. - |. move CARG1, L - | jalr CFUNCADDR // (lua_State *L [, lua_CFunction f]) - |. st_vmstate - | // Returns nresults. - | lw BASE, L->base - | sll RD, CRET1, 3 - | lw TMP1, L->top - | li_vmstate INTERP - | lw PC, FRAME_PC(BASE) // Fetch PC of caller. - | subu RA, TMP1, RD // RA = L->top - nresults*8 - | b ->vm_returnc - |. st_vmstate - break; - - /* ---------------------------------------------------------------------- */ - - default: - fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); - exit(2); - break; - } -} - -static int build_backend(BuildCtx *ctx) -{ - int op; - - dasm_growpc(Dst, BC__MAX); - - build_subroutines(ctx); - - |.code_op - for (op = 0; op < BC__MAX; op++) - build_ins(ctx, (BCOp)op, op); - - return BC__MAX; -} - -/* Emit pseudo frame-info for all assembler functions. */ -static void emit_asm_debug(BuildCtx *ctx) -{ - int fcofs = (int)((uint8_t *)ctx->glob[GLOB_vm_ffi_call] - ctx->code); - int i; - switch (ctx->mode) { - case BUILD_elfasm: - fprintf(ctx->fp, "\t.section .debug_frame,\"\",@progbits\n"); - fprintf(ctx->fp, - ".Lframe0:\n" - "\t.4byte .LECIE0-.LSCIE0\n" - ".LSCIE0:\n" - "\t.4byte 0xffffffff\n" - "\t.byte 0x1\n" - "\t.string \"\"\n" - "\t.uleb128 0x1\n" - "\t.sleb128 -4\n" - "\t.byte 31\n" - "\t.byte 0xc\n\t.uleb128 29\n\t.uleb128 0\n" - "\t.align 2\n" - ".LECIE0:\n\n"); - fprintf(ctx->fp, - ".LSFDE0:\n" - "\t.4byte .LEFDE0-.LASFDE0\n" - ".LASFDE0:\n" - "\t.4byte .Lframe0\n" - "\t.4byte .Lbegin\n" - "\t.4byte %d\n" - "\t.byte 0xe\n\t.uleb128 %d\n" - "\t.byte 0x9f\n\t.sleb128 1\n" - "\t.byte 0x9e\n\t.sleb128 2\n", - fcofs, CFRAME_SIZE); - for (i = 23; i >= 16; i--) - fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+i, 26-i); - for (i = 30; i >= 20; i -= 2) - fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+32+i, 42-i); - fprintf(ctx->fp, - "\t.align 2\n" - ".LEFDE0:\n\n"); -#if LJ_HASFFI - fprintf(ctx->fp, - ".LSFDE1:\n" - "\t.4byte .LEFDE1-.LASFDE1\n" - ".LASFDE1:\n" - "\t.4byte .Lframe0\n" - "\t.4byte lj_vm_ffi_call\n" - "\t.4byte %d\n" - "\t.byte 0x9f\n\t.uleb128 1\n" - "\t.byte 0x90\n\t.uleb128 2\n" - "\t.byte 0xd\n\t.uleb128 0x10\n" - "\t.align 2\n" - ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); -#endif - fprintf(ctx->fp, "\t.section .eh_frame,\"aw\",@progbits\n"); - fprintf(ctx->fp, - "\t.globl lj_err_unwind_dwarf\n" - ".Lframe1:\n" - "\t.4byte .LECIE1-.LSCIE1\n" - ".LSCIE1:\n" - "\t.4byte 0\n" - "\t.byte 0x1\n" - "\t.string \"zPR\"\n" - "\t.uleb128 0x1\n" - "\t.sleb128 -4\n" - "\t.byte 31\n" - "\t.uleb128 6\n" /* augmentation length */ - "\t.byte 0\n" - "\t.4byte lj_err_unwind_dwarf\n" - "\t.byte 0\n" - "\t.byte 0xc\n\t.uleb128 29\n\t.uleb128 0\n" - "\t.align 2\n" - ".LECIE1:\n\n"); - fprintf(ctx->fp, - ".LSFDE2:\n" - "\t.4byte .LEFDE2-.LASFDE2\n" - ".LASFDE2:\n" - "\t.4byte .LASFDE2-.Lframe1\n" - "\t.4byte .Lbegin\n" - "\t.4byte %d\n" - "\t.uleb128 0\n" /* augmentation length */ - "\t.byte 0xe\n\t.uleb128 %d\n" - "\t.byte 0x9f\n\t.sleb128 1\n" - "\t.byte 0x9e\n\t.sleb128 2\n", - fcofs, CFRAME_SIZE); - for (i = 23; i >= 16; i--) - fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+i, 26-i); - for (i = 30; i >= 20; i -= 2) - fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+32+i, 42-i); - fprintf(ctx->fp, - "\t.align 2\n" - ".LEFDE2:\n\n"); -#if LJ_HASFFI - fprintf(ctx->fp, - ".Lframe2:\n" - "\t.4byte .LECIE2-.LSCIE2\n" - ".LSCIE2:\n" - "\t.4byte 0\n" - "\t.byte 0x1\n" - "\t.string \"zR\"\n" - "\t.uleb128 0x1\n" - "\t.sleb128 -4\n" - "\t.byte 31\n" - "\t.uleb128 1\n" /* augmentation length */ - "\t.byte 0\n" - "\t.byte 0xc\n\t.uleb128 29\n\t.uleb128 0\n" - "\t.align 2\n" - ".LECIE2:\n\n"); - fprintf(ctx->fp, - ".LSFDE3:\n" - "\t.4byte .LEFDE3-.LASFDE3\n" - ".LASFDE3:\n" - "\t.4byte .LASFDE3-.Lframe2\n" - "\t.4byte lj_vm_ffi_call\n" - "\t.4byte %d\n" - "\t.uleb128 0\n" /* augmentation length */ - "\t.byte 0x9f\n\t.uleb128 1\n" - "\t.byte 0x90\n\t.uleb128 2\n" - "\t.byte 0xd\n\t.uleb128 0x10\n" - "\t.align 2\n" - ".LEFDE3:\n\n", (int)ctx->codesz - fcofs); -#endif - break; - default: - break; - } -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/vm_ppc.dasc b/source/libs/luajit/LuaJIT-2.0.3/src/vm_ppc.dasc deleted file mode 100644 index da75f556d..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/vm_ppc.dasc +++ /dev/null @@ -1,5137 +0,0 @@ -|// Low-level VM code for PowerPC CPUs. -|// Bytecode interpreter, fast functions and helper functions. -|// Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -| -|.arch ppc -|.section code_op, code_sub -| -|.actionlist build_actionlist -|.globals GLOB_ -|.globalnames globnames -|.externnames extnames -| -|// Note: The ragged indentation of the instructions is intentional. -|// The starting columns indicate data dependencies. -| -|//----------------------------------------------------------------------- -| -|// DynASM defines used by the PPC port: -|// -|// P64 64 bit pointers (only for GPR64 testing). -|// Note: a full PPC64 _LP64 port is not planned. -|// GPR64 64 bit registers (but possibly 32 bit pointers, e.g. PS3). -|// Affects reg saves, stack layout, carry/overflow/dot flags etc. -|// FRAME32 Use 32 bit frame layout, even with GPR64 (Xbox 360). -|// TOC Need table of contents (64 bit or 32 bit variant, e.g. PS3). -|// Function pointers are really a struct: code, TOC, env (optional). -|// TOCENV Function pointers have an environment pointer, too (not on PS3). -|// PPE Power Processor Element of Cell (PS3) or Xenon (Xbox 360). -|// Must avoid (slow) micro-coded instructions. -| -|.if P64 -|.define TOC, 1 -|.define TOCENV, 1 -|.macro lpx, a, b, c; ldx a, b, c; .endmacro -|.macro lp, a, b; ld a, b; .endmacro -|.macro stp, a, b; std a, b; .endmacro -|.define decode_OPP, decode_OP8 -|.if FFI -|// Missing: Calling conventions, 64 bit regs, TOC. -|.error lib_ffi not yet implemented for PPC64 -|.endif -|.else -|.macro lpx, a, b, c; lwzx a, b, c; .endmacro -|.macro lp, a, b; lwz a, b; .endmacro -|.macro stp, a, b; stw a, b; .endmacro -|.define decode_OPP, decode_OP4 -|.endif -| -|// Convenience macros for TOC handling. -|.if TOC -|// Linker needs a TOC patch area for every external call relocation. -|.macro blex, target; bl extern target@plt; nop; .endmacro -|.macro .toc, a, b; a, b; .endmacro -|.if P64 -|.define TOC_OFS, 8 -|.define ENV_OFS, 16 -|.else -|.define TOC_OFS, 4 -|.define ENV_OFS, 8 -|.endif -|.else // No TOC. -|.macro blex, target; bl extern target@plt; .endmacro -|.macro .toc, a, b; .endmacro -|.endif -|.macro .tocenv, a, b; .if TOCENV; a, b; .endif; .endmacro -| -|.macro .gpr64, a, b; .if GPR64; a, b; .endif; .endmacro -| -|.macro andix., y, a, i -|.if PPE -| rlwinm y, a, 0, 31-lj_fls(i), 31-lj_ffs(i) -| cmpwi y, 0 -|.else -| andi. y, a, i -|.endif -|.endmacro -| -|//----------------------------------------------------------------------- -| -|// Fixed register assignments for the interpreter. -|// Don't use: r1 = sp, r2 and r13 = reserved (TOC, TLS or SDATA) -| -|// The following must be C callee-save (but BASE is often refetched). -|.define BASE, r14 // Base of current Lua stack frame. -|.define KBASE, r15 // Constants of current Lua function. -|.define PC, r16 // Next PC. -|.define DISPATCH, r17 // Opcode dispatch table. -|.define LREG, r18 // Register holding lua_State (also in SAVE_L). -|.define MULTRES, r19 // Size of multi-result: (nresults+1)*8. -|.define JGL, r31 // On-trace: global_State + 32768. -| -|// Constants for type-comparisons, stores and conversions. C callee-save. -|.define TISNUM, r22 -|.define TISNIL, r23 -|.define ZERO, r24 -|.define TOBIT, f30 // 2^52 + 2^51. -|.define TONUM, f31 // 2^52 + 2^51 + 2^31. -| -|// The following temporaries are not saved across C calls, except for RA. -|.define RA, r20 // Callee-save. -|.define RB, r10 -|.define RC, r11 -|.define RD, r12 -|.define INS, r7 // Overlaps CARG5. -| -|.define TMP0, r0 -|.define TMP1, r8 -|.define TMP2, r9 -|.define TMP3, r6 // Overlaps CARG4. -| -|// Saved temporaries. -|.define SAVE0, r21 -| -|// Calling conventions. -|.define CARG1, r3 -|.define CARG2, r4 -|.define CARG3, r5 -|.define CARG4, r6 // Overlaps TMP3. -|.define CARG5, r7 // Overlaps INS. -| -|.define FARG1, f1 -|.define FARG2, f2 -| -|.define CRET1, r3 -|.define CRET2, r4 -| -|.define TOCREG, r2 // TOC register (only used by C code). -|.define ENVREG, r11 // Environment pointer (nested C functions). -| -|// Stack layout while in interpreter. Must match with lj_frame.h. -|.if GPR64 -|.if FRAME32 -| -|// 456(sp) // \ 32/64 bit C frame info -|.define TONUM_LO, 452(sp) // | -|.define TONUM_HI, 448(sp) // | -|.define TMPD_LO, 444(sp) // | -|.define TMPD_HI, 440(sp) // | -|.define SAVE_CR, 432(sp) // | 64 bit CR save. -|.define SAVE_ERRF, 424(sp) // > Parameter save area. -|.define SAVE_NRES, 420(sp) // | -|.define SAVE_L, 416(sp) // | -|.define SAVE_PC, 412(sp) // | -|.define SAVE_MULTRES, 408(sp) // | -|.define SAVE_CFRAME, 400(sp) // / 64 bit C frame chain. -|// 392(sp) // Reserved. -|.define CFRAME_SPACE, 384 // Delta for sp. -|// Back chain for sp: 384(sp) <-- sp entering interpreter -|.define SAVE_LR, 376(sp) // 32 bit LR stored in hi-part. -|.define SAVE_GPR_, 232 // .. 232+18*8: 64 bit GPR saves. -|.define SAVE_FPR_, 88 // .. 88+18*8: 64 bit FPR saves. -|// 80(sp) // Needed for 16 byte stack frame alignment. -|// 16(sp) // Callee parameter save area (ABI mandated). -|// 8(sp) // Reserved -|// Back chain for sp: 0(sp) <-- sp while in interpreter -|// 32 bit sp stored in hi-part of 0(sp). -| -|.define TMPD_BLO, 447(sp) -|.define TMPD, TMPD_HI -|.define TONUM_D, TONUM_HI -| -|.else -| -|// 508(sp) // \ 32 bit C frame info. -|.define SAVE_ERRF, 472(sp) // | -|.define SAVE_NRES, 468(sp) // | -|.define SAVE_L, 464(sp) // > Parameter save area. -|.define SAVE_PC, 460(sp) // | -|.define SAVE_MULTRES, 456(sp) // | -|.define SAVE_CFRAME, 448(sp) // / 64 bit C frame chain. -|.define SAVE_LR, 416(sp) -|.define CFRAME_SPACE, 400 // Delta for sp. -|// Back chain for sp: 400(sp) <-- sp entering interpreter -|.define SAVE_FPR_, 256 // .. 256+18*8: 64 bit FPR saves. -|.define SAVE_GPR_, 112 // .. 112+18*8: 64 bit GPR saves. -|// 48(sp) // Callee parameter save area (ABI mandated). -|.define SAVE_TOC, 40(sp) // TOC save area. -|.define TMPD_LO, 36(sp) // \ Link editor temp (ABI mandated). -|.define TMPD_HI, 32(sp) // / -|.define TONUM_LO, 28(sp) // \ Compiler temp (ABI mandated). -|.define TONUM_HI, 24(sp) // / -|// Next frame lr: 16(sp) -|.define SAVE_CR, 8(sp) // 64 bit CR save. -|// Back chain for sp: 0(sp) <-- sp while in interpreter -| -|.define TMPD_BLO, 39(sp) -|.define TMPD, TMPD_HI -|.define TONUM_D, TONUM_HI -| -|.endif -|.else -| -|.define SAVE_LR, 276(sp) -|.define CFRAME_SPACE, 272 // Delta for sp. -|// Back chain for sp: 272(sp) <-- sp entering interpreter -|.define SAVE_FPR_, 128 // .. 128+18*8: 64 bit FPR saves. -|.define SAVE_GPR_, 56 // .. 56+18*4: 32 bit GPR saves. -|.define SAVE_CR, 52(sp) // 32 bit CR save. -|.define SAVE_ERRF, 48(sp) // 32 bit C frame info. -|.define SAVE_NRES, 44(sp) -|.define SAVE_CFRAME, 40(sp) -|.define SAVE_L, 36(sp) -|.define SAVE_PC, 32(sp) -|.define SAVE_MULTRES, 28(sp) -|.define UNUSED1, 24(sp) -|.define TMPD_LO, 20(sp) -|.define TMPD_HI, 16(sp) -|.define TONUM_LO, 12(sp) -|.define TONUM_HI, 8(sp) -|// Next frame lr: 4(sp) -|// Back chain for sp: 0(sp) <-- sp while in interpreter -| -|.define TMPD_BLO, 23(sp) -|.define TMPD, TMPD_HI -|.define TONUM_D, TONUM_HI -| -|.endif -| -|.macro save_, reg -|.if GPR64 -| std r..reg, SAVE_GPR_+(reg-14)*8(sp) -|.else -| stw r..reg, SAVE_GPR_+(reg-14)*4(sp) -|.endif -| stfd f..reg, SAVE_FPR_+(reg-14)*8(sp) -|.endmacro -|.macro rest_, reg -|.if GPR64 -| ld r..reg, SAVE_GPR_+(reg-14)*8(sp) -|.else -| lwz r..reg, SAVE_GPR_+(reg-14)*4(sp) -|.endif -| lfd f..reg, SAVE_FPR_+(reg-14)*8(sp) -|.endmacro -| -|.macro saveregs -|.if GPR64 and not FRAME32 -| stdu sp, -CFRAME_SPACE(sp) -|.else -| stwu sp, -CFRAME_SPACE(sp) -|.endif -| save_ 14; save_ 15; save_ 16 -| mflr r0 -| save_ 17; save_ 18; save_ 19; save_ 20; save_ 21; save_ 22 -|.if GPR64 and not FRAME32 -| std r0, SAVE_LR -|.else -| stw r0, SAVE_LR -|.endif -| save_ 23; save_ 24; save_ 25 -| mfcr r0 -| save_ 26; save_ 27; save_ 28; save_ 29; save_ 30; save_ 31 -|.if GPR64 -| std r0, SAVE_CR -|.else -| stw r0, SAVE_CR -|.endif -| .toc std TOCREG, SAVE_TOC -|.endmacro -| -|.macro restoreregs -|.if GPR64 and not FRAME32 -| ld r0, SAVE_LR -|.else -| lwz r0, SAVE_LR -|.endif -|.if GPR64 -| ld r12, SAVE_CR -|.else -| lwz r12, SAVE_CR -|.endif -| rest_ 14; rest_ 15; rest_ 16; rest_ 17; rest_ 18; rest_ 19 -| mtlr r0; -|.if PPE; mtocrf 0x20, r12; .else; mtcrf 0x38, r12; .endif -| rest_ 20; rest_ 21; rest_ 22; rest_ 23; rest_ 24; rest_ 25 -|.if PPE; mtocrf 0x10, r12; .endif -| rest_ 26; rest_ 27; rest_ 28; rest_ 29; rest_ 30; rest_ 31 -|.if PPE; mtocrf 0x08, r12; .endif -| addi sp, sp, CFRAME_SPACE -|.endmacro -| -|// Type definitions. Some of these are only used for documentation. -|.type L, lua_State, LREG -|.type GL, global_State -|.type TVALUE, TValue -|.type GCOBJ, GCobj -|.type STR, GCstr -|.type TAB, GCtab -|.type LFUNC, GCfuncL -|.type CFUNC, GCfuncC -|.type PROTO, GCproto -|.type UPVAL, GCupval -|.type NODE, Node -|.type NARGS8, int -|.type TRACE, GCtrace -| -|//----------------------------------------------------------------------- -| -|// These basic macros should really be part of DynASM. -|.macro srwi, rx, ry, n; rlwinm rx, ry, 32-n, n, 31; .endmacro -|.macro slwi, rx, ry, n; rlwinm rx, ry, n, 0, 31-n; .endmacro -|.macro rotlwi, rx, ry, n; rlwinm rx, ry, n, 0, 31; .endmacro -|.macro rotlw, rx, ry, rn; rlwnm rx, ry, rn, 0, 31; .endmacro -|.macro subi, rx, ry, i; addi rx, ry, -i; .endmacro -| -|// Trap for not-yet-implemented parts. -|.macro NYI; tw 4, sp, sp; .endmacro -| -|// int/FP conversions. -|.macro tonum_i, freg, reg -| xoris reg, reg, 0x8000 -| stw reg, TONUM_LO -| lfd freg, TONUM_D -| fsub freg, freg, TONUM -|.endmacro -| -|.macro tonum_u, freg, reg -| stw reg, TONUM_LO -| lfd freg, TONUM_D -| fsub freg, freg, TOBIT -|.endmacro -| -|.macro toint, reg, freg, tmpfreg -| fctiwz tmpfreg, freg -| stfd tmpfreg, TMPD -| lwz reg, TMPD_LO -|.endmacro -| -|.macro toint, reg, freg -| toint reg, freg, freg -|.endmacro -| -|//----------------------------------------------------------------------- -| -|// Access to frame relative to BASE. -|.define FRAME_PC, -8 -|.define FRAME_FUNC, -4 -| -|// Instruction decode. -|.macro decode_OP4, dst, ins; rlwinm dst, ins, 2, 22, 29; .endmacro -|.macro decode_OP8, dst, ins; rlwinm dst, ins, 3, 21, 28; .endmacro -|.macro decode_RA8, dst, ins; rlwinm dst, ins, 27, 21, 28; .endmacro -|.macro decode_RB8, dst, ins; rlwinm dst, ins, 11, 21, 28; .endmacro -|.macro decode_RC8, dst, ins; rlwinm dst, ins, 19, 21, 28; .endmacro -|.macro decode_RD8, dst, ins; rlwinm dst, ins, 19, 13, 28; .endmacro -| -|.macro decode_OP1, dst, ins; rlwinm dst, ins, 0, 24, 31; .endmacro -|.macro decode_RD4, dst, ins; rlwinm dst, ins, 18, 14, 29; .endmacro -| -|// Instruction fetch. -|.macro ins_NEXT1 -| lwz INS, 0(PC) -| addi PC, PC, 4 -|.endmacro -|// Instruction decode+dispatch. Note: optimized for e300! -|.macro ins_NEXT2 -| decode_OPP TMP1, INS -| lpx TMP0, DISPATCH, TMP1 -| mtctr TMP0 -| decode_RB8 RB, INS -| decode_RD8 RD, INS -| decode_RA8 RA, INS -| decode_RC8 RC, INS -| bctr -|.endmacro -|.macro ins_NEXT -| ins_NEXT1 -| ins_NEXT2 -|.endmacro -| -|// Instruction footer. -|.if 1 -| // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. -| .define ins_next, ins_NEXT -| .define ins_next_, ins_NEXT -| .define ins_next1, ins_NEXT1 -| .define ins_next2, ins_NEXT2 -|.else -| // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. -| // Affects only certain kinds of benchmarks (and only with -j off). -| .macro ins_next -| b ->ins_next -| .endmacro -| .macro ins_next1 -| .endmacro -| .macro ins_next2 -| b ->ins_next -| .endmacro -| .macro ins_next_ -| ->ins_next: -| ins_NEXT -| .endmacro -|.endif -| -|// Call decode and dispatch. -|.macro ins_callt -| // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC -| lwz PC, LFUNC:RB->pc -| lwz INS, 0(PC) -| addi PC, PC, 4 -| decode_OPP TMP1, INS -| decode_RA8 RA, INS -| lpx TMP0, DISPATCH, TMP1 -| add RA, RA, BASE -| mtctr TMP0 -| bctr -|.endmacro -| -|.macro ins_call -| // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, PC = caller PC -| stw PC, FRAME_PC(BASE) -| ins_callt -|.endmacro -| -|//----------------------------------------------------------------------- -| -|// Macros to test operand types. -|.macro checknum, reg; cmplw reg, TISNUM; .endmacro -|.macro checknum, cr, reg; cmplw cr, reg, TISNUM; .endmacro -|.macro checkstr, reg; cmpwi reg, LJ_TSTR; .endmacro -|.macro checktab, reg; cmpwi reg, LJ_TTAB; .endmacro -|.macro checkfunc, reg; cmpwi reg, LJ_TFUNC; .endmacro -|.macro checknil, reg; cmpwi reg, LJ_TNIL; .endmacro -| -|.macro branch_RD -| srwi TMP0, RD, 1 -| addis PC, PC, -(BCBIAS_J*4 >> 16) -| add PC, PC, TMP0 -|.endmacro -| -|// Assumes DISPATCH is relative to GL. -#define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) -#define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) -| -#define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) -| -|.macro hotcheck, delta, target -| rlwinm TMP1, PC, 31, 25, 30 -| addi TMP1, TMP1, GG_DISP2HOT -| lhzx TMP2, DISPATCH, TMP1 -| addic. TMP2, TMP2, -delta -| sthx TMP2, DISPATCH, TMP1 -| blt target -|.endmacro -| -|.macro hotloop -| hotcheck HOTCOUNT_LOOP, ->vm_hotloop -|.endmacro -| -|.macro hotcall -| hotcheck HOTCOUNT_CALL, ->vm_hotcall -|.endmacro -| -|// Set current VM state. Uses TMP0. -|.macro li_vmstate, st; li TMP0, ~LJ_VMST_..st; .endmacro -|.macro st_vmstate; stw TMP0, DISPATCH_GL(vmstate)(DISPATCH); .endmacro -| -|// Move table write barrier back. Overwrites mark and tmp. -|.macro barrierback, tab, mark, tmp -| lwz tmp, DISPATCH_GL(gc.grayagain)(DISPATCH) -| // Assumes LJ_GC_BLACK is 0x04. -| rlwinm mark, mark, 0, 30, 28 // black2gray(tab) -| stw tab, DISPATCH_GL(gc.grayagain)(DISPATCH) -| stb mark, tab->marked -| stw tmp, tab->gclist -|.endmacro -| -|//----------------------------------------------------------------------- - -/* Generate subroutines used by opcodes and other parts of the VM. */ -/* The .code_sub section should be last to help static branch prediction. */ -static void build_subroutines(BuildCtx *ctx) -{ - |.code_sub - | - |//----------------------------------------------------------------------- - |//-- Return handling ---------------------------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_returnp: - | // See vm_return. Also: TMP2 = previous base. - | andix. TMP0, PC, FRAME_P - | li TMP1, LJ_TTRUE - | beq ->cont_dispatch - | - | // Return from pcall or xpcall fast func. - | lwz PC, FRAME_PC(TMP2) // Fetch PC of previous frame. - | mr BASE, TMP2 // Restore caller base. - | // Prepending may overwrite the pcall frame, so do it at the end. - | stwu TMP1, FRAME_PC(RA) // Prepend true to results. - | - |->vm_returnc: - | addi RD, RD, 8 // RD = (nresults+1)*8. - | andix. TMP0, PC, FRAME_TYPE - | cmpwi cr1, RD, 0 - | li CRET1, LUA_YIELD - | beq cr1, ->vm_unwind_c_eh - | mr MULTRES, RD - | beq ->BC_RET_Z // Handle regular return to Lua. - | - |->vm_return: - | // BASE = base, RA = resultptr, RD/MULTRES = (nresults+1)*8, PC = return - | // TMP0 = PC & FRAME_TYPE - | cmpwi TMP0, FRAME_C - | rlwinm TMP2, PC, 0, 0, 28 - | li_vmstate C - | sub TMP2, BASE, TMP2 // TMP2 = previous base. - | bney ->vm_returnp - | - | addic. TMP1, RD, -8 - | stp TMP2, L->base - | lwz TMP2, SAVE_NRES - | subi BASE, BASE, 8 - | st_vmstate - | slwi TMP2, TMP2, 3 - | beq >2 - |1: - | addic. TMP1, TMP1, -8 - | lfd f0, 0(RA) - | addi RA, RA, 8 - | stfd f0, 0(BASE) - | addi BASE, BASE, 8 - | bney <1 - | - |2: - | cmpw TMP2, RD // More/less results wanted? - | bne >6 - |3: - | stp BASE, L->top // Store new top. - | - |->vm_leave_cp: - | lp TMP0, SAVE_CFRAME // Restore previous C frame. - | li CRET1, 0 // Ok return status for vm_pcall. - | stp TMP0, L->cframe - | - |->vm_leave_unw: - | restoreregs - | blr - | - |6: - | ble >7 // Less results wanted? - | // More results wanted. Check stack size and fill up results with nil. - | lwz TMP1, L->maxstack - | cmplw BASE, TMP1 - | bge >8 - | stw TISNIL, 0(BASE) - | addi RD, RD, 8 - | addi BASE, BASE, 8 - | b <2 - | - |7: // Less results wanted. - | subfic TMP3, TMP2, 0 // LUA_MULTRET+1 case? - | sub TMP0, RD, TMP2 - | subfe TMP1, TMP1, TMP1 // TMP1 = TMP2 == 0 ? 0 : -1 - | and TMP0, TMP0, TMP1 - | sub BASE, BASE, TMP0 // Either keep top or shrink it. - | b <3 - | - |8: // Corner case: need to grow stack for filling up results. - | // This can happen if: - | // - A C function grows the stack (a lot). - | // - The GC shrinks the stack in between. - | // - A return back from a lua_call() with (high) nresults adjustment. - | stp BASE, L->top // Save current top held in BASE (yes). - | mr SAVE0, RD - | mr CARG2, TMP2 - | mr CARG1, L - | bl extern lj_state_growstack // (lua_State *L, int n) - | lwz TMP2, SAVE_NRES - | mr RD, SAVE0 - | slwi TMP2, TMP2, 3 - | lp BASE, L->top // Need the (realloced) L->top in BASE. - | b <2 - | - |->vm_unwind_c: // Unwind C stack, return from vm_pcall. - | // (void *cframe, int errcode) - | mr sp, CARG1 - | mr CRET1, CARG2 - |->vm_unwind_c_eh: // Landing pad for external unwinder. - | lwz L, SAVE_L - | .toc ld TOCREG, SAVE_TOC - | li TMP0, ~LJ_VMST_C - | lwz GL:TMP1, L->glref - | stw TMP0, GL:TMP1->vmstate - | b ->vm_leave_unw - | - |->vm_unwind_ff: // Unwind C stack, return from ff pcall. - | // (void *cframe) - |.if GPR64 - | rldicr sp, CARG1, 0, 61 - |.else - | rlwinm sp, CARG1, 0, 0, 29 - |.endif - |->vm_unwind_ff_eh: // Landing pad for external unwinder. - | lwz L, SAVE_L - | .toc ld TOCREG, SAVE_TOC - | li TISNUM, LJ_TISNUM // Setup type comparison constants. - | lp BASE, L->base - | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). - | lwz DISPATCH, L->glref // Setup pointer to dispatch table. - | li ZERO, 0 - | stw TMP3, TMPD - | li TMP1, LJ_TFALSE - | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). - | li TISNIL, LJ_TNIL - | li_vmstate INTERP - | lfs TOBIT, TMPD - | lwz PC, FRAME_PC(BASE) // Fetch PC of previous frame. - | la RA, -8(BASE) // Results start at BASE-8. - | stw TMP3, TMPD - | addi DISPATCH, DISPATCH, GG_G2DISP - | stw TMP1, 0(RA) // Prepend false to error message. - | li RD, 16 // 2 results: false + error message. - | st_vmstate - | lfs TONUM, TMPD - | b ->vm_returnc - | - |//----------------------------------------------------------------------- - |//-- Grow stack for calls ----------------------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_growstack_c: // Grow stack for C function. - | li CARG2, LUA_MINSTACK - | b >2 - | - |->vm_growstack_l: // Grow stack for Lua function. - | // BASE = new base, RA = BASE+framesize*8, RC = nargs*8, PC = first PC - | add RC, BASE, RC - | sub RA, RA, BASE - | stp BASE, L->base - | addi PC, PC, 4 // Must point after first instruction. - | stp RC, L->top - | srwi CARG2, RA, 3 - |2: - | // L->base = new base, L->top = top - | stw PC, SAVE_PC - | mr CARG1, L - | bl extern lj_state_growstack // (lua_State *L, int n) - | lp BASE, L->base - | lp RC, L->top - | lwz LFUNC:RB, FRAME_FUNC(BASE) - | sub RC, RC, BASE - | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC - | ins_callt // Just retry the call. - | - |//----------------------------------------------------------------------- - |//-- Entry points into the assembler VM --------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_resume: // Setup C frame and resume thread. - | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) - | saveregs - | mr L, CARG1 - | lwz DISPATCH, L->glref // Setup pointer to dispatch table. - | mr BASE, CARG2 - | lbz TMP1, L->status - | stw L, SAVE_L - | li PC, FRAME_CP - | addi TMP0, sp, CFRAME_RESUME - | addi DISPATCH, DISPATCH, GG_G2DISP - | stw CARG3, SAVE_NRES - | cmplwi TMP1, 0 - | stw CARG3, SAVE_ERRF - | stp TMP0, L->cframe - | stp CARG3, SAVE_CFRAME - | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. - | beq >3 - | - | // Resume after yield (like a return). - | mr RA, BASE - | lp BASE, L->base - | li TISNUM, LJ_TISNUM // Setup type comparison constants. - | lp TMP1, L->top - | lwz PC, FRAME_PC(BASE) - | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). - | stb CARG3, L->status - | stw TMP3, TMPD - | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). - | lfs TOBIT, TMPD - | sub RD, TMP1, BASE - | stw TMP3, TMPD - | lus TMP0, 0x4338 // Hiword of 2^52 + 2^51 (double) - | addi RD, RD, 8 - | stw TMP0, TONUM_HI - | li_vmstate INTERP - | li ZERO, 0 - | st_vmstate - | andix. TMP0, PC, FRAME_TYPE - | mr MULTRES, RD - | lfs TONUM, TMPD - | li TISNIL, LJ_TNIL - | beq ->BC_RET_Z - | b ->vm_return - | - |->vm_pcall: // Setup protected C frame and enter VM. - | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) - | saveregs - | li PC, FRAME_CP - | stw CARG4, SAVE_ERRF - | b >1 - | - |->vm_call: // Setup C frame and enter VM. - | // (lua_State *L, TValue *base, int nres1) - | saveregs - | li PC, FRAME_C - | - |1: // Entry point for vm_pcall above (PC = ftype). - | lp TMP1, L:CARG1->cframe - | stw CARG3, SAVE_NRES - | mr L, CARG1 - | stw CARG1, SAVE_L - | mr BASE, CARG2 - | stp sp, L->cframe // Add our C frame to cframe chain. - | lwz DISPATCH, L->glref // Setup pointer to dispatch table. - | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. - | stp TMP1, SAVE_CFRAME - | addi DISPATCH, DISPATCH, GG_G2DISP - | - |3: // Entry point for vm_cpcall/vm_resume (BASE = base, PC = ftype). - | lp TMP2, L->base // TMP2 = old base (used in vmeta_call). - | li TISNUM, LJ_TISNUM // Setup type comparison constants. - | lp TMP1, L->top - | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). - | add PC, PC, BASE - | stw TMP3, TMPD - | li ZERO, 0 - | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). - | lfs TOBIT, TMPD - | sub PC, PC, TMP2 // PC = frame delta + frame type - | stw TMP3, TMPD - | lus TMP0, 0x4338 // Hiword of 2^52 + 2^51 (double) - | sub NARGS8:RC, TMP1, BASE - | stw TMP0, TONUM_HI - | li_vmstate INTERP - | lfs TONUM, TMPD - | li TISNIL, LJ_TNIL - | st_vmstate - | - |->vm_call_dispatch: - | // TMP2 = old base, BASE = new base, RC = nargs*8, PC = caller PC - | lwz TMP0, FRAME_PC(BASE) - | lwz LFUNC:RB, FRAME_FUNC(BASE) - | checkfunc TMP0; bne ->vmeta_call - | - |->vm_call_dispatch_f: - | ins_call - | // BASE = new base, RB = func, RC = nargs*8, PC = caller PC - | - |->vm_cpcall: // Setup protected C frame, call C. - | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) - | saveregs - | mr L, CARG1 - | lwz TMP0, L:CARG1->stack - | stw CARG1, SAVE_L - | lp TMP1, L->top - | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. - | sub TMP0, TMP0, TMP1 // Compute -savestack(L, L->top). - | lp TMP1, L->cframe - | stp sp, L->cframe // Add our C frame to cframe chain. - | .toc lp CARG4, 0(CARG4) - | li TMP2, 0 - | stw TMP0, SAVE_NRES // Neg. delta means cframe w/o frame. - | stw TMP2, SAVE_ERRF // No error function. - | stp TMP1, SAVE_CFRAME - | mtctr CARG4 - | bctrl // (lua_State *L, lua_CFunction func, void *ud) - |.if PPE - | mr BASE, CRET1 - | cmpwi CRET1, 0 - |.else - | mr. BASE, CRET1 - |.endif - | lwz DISPATCH, L->glref // Setup pointer to dispatch table. - | li PC, FRAME_CP - | addi DISPATCH, DISPATCH, GG_G2DISP - | bne <3 // Else continue with the call. - | b ->vm_leave_cp // No base? Just remove C frame. - | - |//----------------------------------------------------------------------- - |//-- Metamethod handling ------------------------------------------------ - |//----------------------------------------------------------------------- - | - |// The lj_meta_* functions (except for lj_meta_cat) don't reallocate the - |// stack, so BASE doesn't need to be reloaded across these calls. - | - |//-- Continuation dispatch ---------------------------------------------- - | - |->cont_dispatch: - | // BASE = meta base, RA = resultptr, RD = (nresults+1)*8 - | lwz TMP0, -12(BASE) // Continuation. - | mr RB, BASE - | mr BASE, TMP2 // Restore caller BASE. - | lwz LFUNC:TMP1, FRAME_FUNC(TMP2) - |.if FFI - | cmplwi TMP0, 1 - |.endif - | lwz PC, -16(RB) // Restore PC from [cont|PC]. - | subi TMP2, RD, 8 - | lwz TMP1, LFUNC:TMP1->pc - | stwx TISNIL, RA, TMP2 // Ensure one valid arg. - |.if FFI - | ble >1 - |.endif - | lwz KBASE, PC2PROTO(k)(TMP1) - | // BASE = base, RA = resultptr, RB = meta base - | mtctr TMP0 - | bctr // Jump to continuation. - | - |.if FFI - |1: - | beq ->cont_ffi_callback // cont = 1: return from FFI callback. - | // cont = 0: tailcall from C function. - | subi TMP1, RB, 16 - | sub RC, TMP1, BASE - | b ->vm_call_tail - |.endif - | - |->cont_cat: // RA = resultptr, RB = meta base - | lwz INS, -4(PC) - | subi CARG2, RB, 16 - | decode_RB8 SAVE0, INS - | lfd f0, 0(RA) - | add TMP1, BASE, SAVE0 - | stp BASE, L->base - | cmplw TMP1, CARG2 - | sub CARG3, CARG2, TMP1 - | decode_RA8 RA, INS - | stfd f0, 0(CARG2) - | bney ->BC_CAT_Z - | stfdx f0, BASE, RA - | b ->cont_nop - | - |//-- Table indexing metamethods ----------------------------------------- - | - |->vmeta_tgets1: - | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) - | li TMP0, LJ_TSTR - | decode_RB8 RB, INS - | stw STR:RC, 4(CARG3) - | add CARG2, BASE, RB - | stw TMP0, 0(CARG3) - | b >1 - | - |->vmeta_tgets: - | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) - | li TMP0, LJ_TTAB - | stw TAB:RB, 4(CARG2) - | la CARG3, DISPATCH_GL(tmptv2)(DISPATCH) - | stw TMP0, 0(CARG2) - | li TMP1, LJ_TSTR - | stw STR:RC, 4(CARG3) - | stw TMP1, 0(CARG3) - | b >1 - | - |->vmeta_tgetb: // TMP0 = index - |.if not DUALNUM - | tonum_u f0, TMP0 - |.endif - | decode_RB8 RB, INS - | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) - | add CARG2, BASE, RB - |.if DUALNUM - | stw TISNUM, 0(CARG3) - | stw TMP0, 4(CARG3) - |.else - | stfd f0, 0(CARG3) - |.endif - | b >1 - | - |->vmeta_tgetv: - | decode_RB8 RB, INS - | decode_RC8 RC, INS - | add CARG2, BASE, RB - | add CARG3, BASE, RC - |1: - | stp BASE, L->base - | mr CARG1, L - | stw PC, SAVE_PC - | bl extern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) - | // Returns TValue * (finished) or NULL (metamethod). - | cmplwi CRET1, 0 - | beq >3 - | lfd f0, 0(CRET1) - | ins_next1 - | stfdx f0, BASE, RA - | ins_next2 - | - |3: // Call __index metamethod. - | // BASE = base, L->top = new base, stack = cont/func/t/k - | subfic TMP1, BASE, FRAME_CONT - | lp BASE, L->top - | stw PC, -16(BASE) // [cont|PC] - | add PC, TMP1, BASE - | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. - | li NARGS8:RC, 16 // 2 args for func(t, k). - | b ->vm_call_dispatch_f - | - |//----------------------------------------------------------------------- - | - |->vmeta_tsets1: - | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) - | li TMP0, LJ_TSTR - | decode_RB8 RB, INS - | stw STR:RC, 4(CARG3) - | add CARG2, BASE, RB - | stw TMP0, 0(CARG3) - | b >1 - | - |->vmeta_tsets: - | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) - | li TMP0, LJ_TTAB - | stw TAB:RB, 4(CARG2) - | la CARG3, DISPATCH_GL(tmptv2)(DISPATCH) - | stw TMP0, 0(CARG2) - | li TMP1, LJ_TSTR - | stw STR:RC, 4(CARG3) - | stw TMP1, 0(CARG3) - | b >1 - | - |->vmeta_tsetb: // TMP0 = index - |.if not DUALNUM - | tonum_u f0, TMP0 - |.endif - | decode_RB8 RB, INS - | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) - | add CARG2, BASE, RB - |.if DUALNUM - | stw TISNUM, 0(CARG3) - | stw TMP0, 4(CARG3) - |.else - | stfd f0, 0(CARG3) - |.endif - | b >1 - | - |->vmeta_tsetv: - | decode_RB8 RB, INS - | decode_RC8 RC, INS - | add CARG2, BASE, RB - | add CARG3, BASE, RC - |1: - | stp BASE, L->base - | mr CARG1, L - | stw PC, SAVE_PC - | bl extern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) - | // Returns TValue * (finished) or NULL (metamethod). - | cmplwi CRET1, 0 - | lfdx f0, BASE, RA - | beq >3 - | // NOBARRIER: lj_meta_tset ensures the table is not black. - | ins_next1 - | stfd f0, 0(CRET1) - | ins_next2 - | - |3: // Call __newindex metamethod. - | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) - | subfic TMP1, BASE, FRAME_CONT - | lp BASE, L->top - | stw PC, -16(BASE) // [cont|PC] - | add PC, TMP1, BASE - | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. - | li NARGS8:RC, 24 // 3 args for func(t, k, v) - | stfd f0, 16(BASE) // Copy value to third argument. - | b ->vm_call_dispatch_f - | - |//-- Comparison metamethods --------------------------------------------- - | - |->vmeta_comp: - | mr CARG1, L - | subi PC, PC, 4 - |.if DUALNUM - | mr CARG2, RA - |.else - | add CARG2, BASE, RA - |.endif - | stw PC, SAVE_PC - |.if DUALNUM - | mr CARG3, RD - |.else - | add CARG3, BASE, RD - |.endif - | stp BASE, L->base - | decode_OP1 CARG4, INS - | bl extern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) - | // Returns 0/1 or TValue * (metamethod). - |3: - | cmplwi CRET1, 1 - | bgt ->vmeta_binop - | subfic CRET1, CRET1, 0 - |4: - | lwz INS, 0(PC) - | addi PC, PC, 4 - | decode_RD4 TMP2, INS - | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) - | and TMP2, TMP2, CRET1 - | add PC, PC, TMP2 - |->cont_nop: - | ins_next - | - |->cont_ra: // RA = resultptr - | lwz INS, -4(PC) - | lfd f0, 0(RA) - | decode_RA8 TMP1, INS - | stfdx f0, BASE, TMP1 - | b ->cont_nop - | - |->cont_condt: // RA = resultptr - | lwz TMP0, 0(RA) - | .gpr64 extsw TMP0, TMP0 - | subfic TMP0, TMP0, LJ_TTRUE // Branch if result is true. - | subfe CRET1, CRET1, CRET1 - | not CRET1, CRET1 - | b <4 - | - |->cont_condf: // RA = resultptr - | lwz TMP0, 0(RA) - | .gpr64 extsw TMP0, TMP0 - | subfic TMP0, TMP0, LJ_TTRUE // Branch if result is false. - | subfe CRET1, CRET1, CRET1 - | b <4 - | - |->vmeta_equal: - | // CARG2, CARG3, CARG4 are already set by BC_ISEQV/BC_ISNEV. - | subi PC, PC, 4 - | stp BASE, L->base - | mr CARG1, L - | stw PC, SAVE_PC - | bl extern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) - | // Returns 0/1 or TValue * (metamethod). - | b <3 - | - |->vmeta_equal_cd: - |.if FFI - | mr CARG2, INS - | subi PC, PC, 4 - | stp BASE, L->base - | mr CARG1, L - | stw PC, SAVE_PC - | bl extern lj_meta_equal_cd // (lua_State *L, BCIns op) - | // Returns 0/1 or TValue * (metamethod). - | b <3 - |.endif - | - |//-- Arithmetic metamethods --------------------------------------------- - | - |->vmeta_arith_nv: - | add CARG3, KBASE, RC - | add CARG4, BASE, RB - | b >1 - |->vmeta_arith_nv2: - |.if DUALNUM - | mr CARG3, RC - | mr CARG4, RB - | b >1 - |.endif - | - |->vmeta_unm: - | mr CARG3, RD - | mr CARG4, RD - | b >1 - | - |->vmeta_arith_vn: - | add CARG3, BASE, RB - | add CARG4, KBASE, RC - | b >1 - | - |->vmeta_arith_vv: - | add CARG3, BASE, RB - | add CARG4, BASE, RC - |.if DUALNUM - | b >1 - |.endif - |->vmeta_arith_vn2: - |->vmeta_arith_vv2: - |.if DUALNUM - | mr CARG3, RB - | mr CARG4, RC - |.endif - |1: - | add CARG2, BASE, RA - | stp BASE, L->base - | mr CARG1, L - | stw PC, SAVE_PC - | decode_OP1 CARG5, INS // Caveat: CARG5 overlaps INS. - | bl extern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) - | // Returns NULL (finished) or TValue * (metamethod). - | cmplwi CRET1, 0 - | beq ->cont_nop - | - | // Call metamethod for binary op. - |->vmeta_binop: - | // BASE = old base, CRET1 = new base, stack = cont/func/o1/o2 - | sub TMP1, CRET1, BASE - | stw PC, -16(CRET1) // [cont|PC] - | mr TMP2, BASE - | addi PC, TMP1, FRAME_CONT - | mr BASE, CRET1 - | li NARGS8:RC, 16 // 2 args for func(o1, o2). - | b ->vm_call_dispatch - | - |->vmeta_len: -#if LJ_52 - | mr SAVE0, CARG1 -#endif - | mr CARG2, RD - | stp BASE, L->base - | mr CARG1, L - | stw PC, SAVE_PC - | bl extern lj_meta_len // (lua_State *L, TValue *o) - | // Returns NULL (retry) or TValue * (metamethod base). -#if LJ_52 - | cmplwi CRET1, 0 - | bne ->vmeta_binop // Binop call for compatibility. - | mr CARG1, SAVE0 - | b ->BC_LEN_Z -#else - | b ->vmeta_binop // Binop call for compatibility. -#endif - | - |//-- Call metamethod ---------------------------------------------------- - | - |->vmeta_call: // Resolve and call __call metamethod. - | // TMP2 = old base, BASE = new base, RC = nargs*8 - | mr CARG1, L - | stp TMP2, L->base // This is the callers base! - | subi CARG2, BASE, 8 - | stw PC, SAVE_PC - | add CARG3, BASE, RC - | mr SAVE0, NARGS8:RC - | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) - | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. - | addi NARGS8:RC, SAVE0, 8 // Got one more argument now. - | ins_call - | - |->vmeta_callt: // Resolve __call for BC_CALLT. - | // BASE = old base, RA = new base, RC = nargs*8 - | mr CARG1, L - | stp BASE, L->base - | subi CARG2, RA, 8 - | stw PC, SAVE_PC - | add CARG3, RA, RC - | mr SAVE0, NARGS8:RC - | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) - | lwz TMP1, FRAME_PC(BASE) - | addi NARGS8:RC, SAVE0, 8 // Got one more argument now. - | lwz LFUNC:RB, FRAME_FUNC(RA) // Guaranteed to be a function here. - | b ->BC_CALLT_Z - | - |//-- Argument coercion for 'for' statement ------------------------------ - | - |->vmeta_for: - | mr CARG1, L - | stp BASE, L->base - | mr CARG2, RA - | stw PC, SAVE_PC - | mr SAVE0, INS - | bl extern lj_meta_for // (lua_State *L, TValue *base) - |.if JIT - | decode_OP1 TMP0, SAVE0 - |.endif - | decode_RA8 RA, SAVE0 - |.if JIT - | cmpwi TMP0, BC_JFORI - |.endif - | decode_RD8 RD, SAVE0 - |.if JIT - | beqy =>BC_JFORI - |.endif - | b =>BC_FORI - | - |//----------------------------------------------------------------------- - |//-- Fast functions ----------------------------------------------------- - |//----------------------------------------------------------------------- - | - |.macro .ffunc, name - |->ff_ .. name: - |.endmacro - | - |.macro .ffunc_1, name - |->ff_ .. name: - | cmplwi NARGS8:RC, 8 - | lwz CARG3, 0(BASE) - | lwz CARG1, 4(BASE) - | blt ->fff_fallback - |.endmacro - | - |.macro .ffunc_2, name - |->ff_ .. name: - | cmplwi NARGS8:RC, 16 - | lwz CARG3, 0(BASE) - | lwz CARG4, 8(BASE) - | lwz CARG1, 4(BASE) - | lwz CARG2, 12(BASE) - | blt ->fff_fallback - |.endmacro - | - |.macro .ffunc_n, name - |->ff_ .. name: - | cmplwi NARGS8:RC, 8 - | lwz CARG3, 0(BASE) - | lfd FARG1, 0(BASE) - | blt ->fff_fallback - | checknum CARG3; bge ->fff_fallback - |.endmacro - | - |.macro .ffunc_nn, name - |->ff_ .. name: - | cmplwi NARGS8:RC, 16 - | lwz CARG3, 0(BASE) - | lfd FARG1, 0(BASE) - | lwz CARG4, 8(BASE) - | lfd FARG2, 8(BASE) - | blt ->fff_fallback - | checknum CARG3; bge ->fff_fallback - | checknum CARG4; bge ->fff_fallback - |.endmacro - | - |// Inlined GC threshold check. Caveat: uses TMP0 and TMP1. - |.macro ffgccheck - | lwz TMP0, DISPATCH_GL(gc.total)(DISPATCH) - | lwz TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) - | cmplw TMP0, TMP1 - | bgel ->fff_gcstep - |.endmacro - | - |//-- Base library: checks ----------------------------------------------- - | - |.ffunc_1 assert - | li TMP1, LJ_TFALSE - | la RA, -8(BASE) - | cmplw cr1, CARG3, TMP1 - | lwz PC, FRAME_PC(BASE) - | bge cr1, ->fff_fallback - | stw CARG3, 0(RA) - | addi RD, NARGS8:RC, 8 // Compute (nresults+1)*8. - | stw CARG1, 4(RA) - | beq ->fff_res // Done if exactly 1 argument. - | li TMP1, 8 - | subi RC, RC, 8 - |1: - | cmplw TMP1, RC - | lfdx f0, BASE, TMP1 - | stfdx f0, RA, TMP1 - | addi TMP1, TMP1, 8 - | bney <1 - | b ->fff_res - | - |.ffunc type - | cmplwi NARGS8:RC, 8 - | lwz CARG1, 0(BASE) - | blt ->fff_fallback - | .gpr64 extsw CARG1, CARG1 - | subfc TMP0, TISNUM, CARG1 - | subfe TMP2, CARG1, CARG1 - | orc TMP1, TMP2, TMP0 - | addi TMP1, TMP1, ~LJ_TISNUM+1 - | slwi TMP1, TMP1, 3 - | la TMP2, CFUNC:RB->upvalue - | lfdx FARG1, TMP2, TMP1 - | b ->fff_resn - | - |//-- Base library: getters and setters --------------------------------- - | - |.ffunc_1 getmetatable - | checktab CARG3; bne >6 - |1: // Field metatable must be at same offset for GCtab and GCudata! - | lwz TAB:CARG1, TAB:CARG1->metatable - |2: - | li CARG3, LJ_TNIL - | cmplwi TAB:CARG1, 0 - | lwz STR:RC, DISPATCH_GL(gcroot[GCROOT_MMNAME+MM_metatable])(DISPATCH) - | beq ->fff_restv - | lwz TMP0, TAB:CARG1->hmask - | li CARG3, LJ_TTAB // Use metatable as default result. - | lwz TMP1, STR:RC->hash - | lwz NODE:TMP2, TAB:CARG1->node - | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask - | slwi TMP0, TMP1, 5 - | slwi TMP1, TMP1, 3 - | sub TMP1, TMP0, TMP1 - | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) - |3: // Rearranged logic, because we expect _not_ to find the key. - | lwz CARG4, NODE:TMP2->key - | lwz TMP0, 4+offsetof(Node, key)(NODE:TMP2) - | lwz CARG2, NODE:TMP2->val - | lwz TMP1, 4+offsetof(Node, val)(NODE:TMP2) - | checkstr CARG4; bne >4 - | cmpw TMP0, STR:RC; beq >5 - |4: - | lwz NODE:TMP2, NODE:TMP2->next - | cmplwi NODE:TMP2, 0 - | beq ->fff_restv // Not found, keep default result. - | b <3 - |5: - | checknil CARG2 - | beq ->fff_restv // Ditto for nil value. - | mr CARG3, CARG2 // Return value of mt.__metatable. - | mr CARG1, TMP1 - | b ->fff_restv - | - |6: - | cmpwi CARG3, LJ_TUDATA; beq <1 - | .gpr64 extsw CARG3, CARG3 - | subfc TMP0, TISNUM, CARG3 - | subfe TMP2, CARG3, CARG3 - | orc TMP1, TMP2, TMP0 - | addi TMP1, TMP1, ~LJ_TISNUM+1 - | slwi TMP1, TMP1, 2 - | la TMP2, DISPATCH_GL(gcroot[GCROOT_BASEMT])(DISPATCH) - | lwzx TAB:CARG1, TMP2, TMP1 - | b <2 - | - |.ffunc_2 setmetatable - | // Fast path: no mt for table yet and not clearing the mt. - | checktab CARG3; bne ->fff_fallback - | lwz TAB:TMP1, TAB:CARG1->metatable - | checktab CARG4; bne ->fff_fallback - | cmplwi TAB:TMP1, 0 - | lbz TMP3, TAB:CARG1->marked - | bne ->fff_fallback - | andix. TMP0, TMP3, LJ_GC_BLACK // isblack(table) - | stw TAB:CARG2, TAB:CARG1->metatable - | beq ->fff_restv - | barrierback TAB:CARG1, TMP3, TMP0 - | b ->fff_restv - | - |.ffunc rawget - | cmplwi NARGS8:RC, 16 - | lwz CARG4, 0(BASE) - | lwz TAB:CARG2, 4(BASE) - | blt ->fff_fallback - | checktab CARG4; bne ->fff_fallback - | la CARG3, 8(BASE) - | mr CARG1, L - | bl extern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) - | // Returns cTValue *. - | lfd FARG1, 0(CRET1) - | b ->fff_resn - | - |//-- Base library: conversions ------------------------------------------ - | - |.ffunc tonumber - | // Only handles the number case inline (without a base argument). - | cmplwi NARGS8:RC, 8 - | lwz CARG1, 0(BASE) - | lfd FARG1, 0(BASE) - | bne ->fff_fallback // Exactly one argument. - | checknum CARG1; bgt ->fff_fallback - | b ->fff_resn - | - |.ffunc_1 tostring - | // Only handles the string or number case inline. - | checkstr CARG3 - | // A __tostring method in the string base metatable is ignored. - | beq ->fff_restv // String key? - | // Handle numbers inline, unless a number base metatable is present. - | lwz TMP0, DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])(DISPATCH) - | checknum CARG3 - | cmplwi cr1, TMP0, 0 - | stp BASE, L->base // Add frame since C call can throw. - | crorc 4*cr0+eq, 4*cr0+gt, 4*cr1+eq - | stw PC, SAVE_PC // Redundant (but a defined value). - | beq ->fff_fallback - | ffgccheck - | mr CARG1, L - | mr CARG2, BASE - |.if DUALNUM - | bl extern lj_str_fromnumber // (lua_State *L, cTValue *o) - |.else - | bl extern lj_str_fromnum // (lua_State *L, lua_Number *np) - |.endif - | // Returns GCstr *. - | li CARG3, LJ_TSTR - | b ->fff_restv - | - |//-- Base library: iterators ------------------------------------------- - | - |.ffunc next - | cmplwi NARGS8:RC, 8 - | lwz CARG1, 0(BASE) - | lwz TAB:CARG2, 4(BASE) - | blt ->fff_fallback - | stwx TISNIL, BASE, NARGS8:RC // Set missing 2nd arg to nil. - | checktab CARG1 - | lwz PC, FRAME_PC(BASE) - | bne ->fff_fallback - | stp BASE, L->base // Add frame since C call can throw. - | mr CARG1, L - | stp BASE, L->top // Dummy frame length is ok. - | la CARG3, 8(BASE) - | stw PC, SAVE_PC - | bl extern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) - | // Returns 0 at end of traversal. - | cmplwi CRET1, 0 - | li CARG3, LJ_TNIL - | beq ->fff_restv // End of traversal: return nil. - | lfd f0, 8(BASE) // Copy key and value to results. - | la RA, -8(BASE) - | lfd f1, 16(BASE) - | stfd f0, 0(RA) - | li RD, (2+1)*8 - | stfd f1, 8(RA) - | b ->fff_res - | - |.ffunc_1 pairs - | checktab CARG3 - | lwz PC, FRAME_PC(BASE) - | bne ->fff_fallback -#if LJ_52 - | lwz TAB:TMP2, TAB:CARG1->metatable - | lfd f0, CFUNC:RB->upvalue[0] - | cmplwi TAB:TMP2, 0 - | la RA, -8(BASE) - | bne ->fff_fallback -#else - | lfd f0, CFUNC:RB->upvalue[0] - | la RA, -8(BASE) -#endif - | stw TISNIL, 8(BASE) - | li RD, (3+1)*8 - | stfd f0, 0(RA) - | b ->fff_res - | - |.ffunc ipairs_aux - | cmplwi NARGS8:RC, 16 - | lwz CARG3, 0(BASE) - | lwz TAB:CARG1, 4(BASE) - | lwz CARG4, 8(BASE) - |.if DUALNUM - | lwz TMP2, 12(BASE) - |.else - | lfd FARG2, 8(BASE) - |.endif - | blt ->fff_fallback - | checktab CARG3 - | checknum cr1, CARG4 - | lwz PC, FRAME_PC(BASE) - |.if DUALNUM - | bne ->fff_fallback - | bne cr1, ->fff_fallback - |.else - | lus TMP0, 0x3ff0 - | stw ZERO, TMPD_LO - | bne ->fff_fallback - | stw TMP0, TMPD_HI - | bge cr1, ->fff_fallback - | lfd FARG1, TMPD - | toint TMP2, FARG2, f0 - |.endif - | lwz TMP0, TAB:CARG1->asize - | lwz TMP1, TAB:CARG1->array - |.if not DUALNUM - | fadd FARG2, FARG2, FARG1 - |.endif - | addi TMP2, TMP2, 1 - | la RA, -8(BASE) - | cmplw TMP0, TMP2 - |.if DUALNUM - | stw TISNUM, 0(RA) - | slwi TMP3, TMP2, 3 - | stw TMP2, 4(RA) - |.else - | slwi TMP3, TMP2, 3 - | stfd FARG2, 0(RA) - |.endif - | ble >2 // Not in array part? - | lwzx TMP2, TMP1, TMP3 - | lfdx f0, TMP1, TMP3 - |1: - | checknil TMP2 - | li RD, (0+1)*8 - | beq ->fff_res // End of iteration, return 0 results. - | li RD, (2+1)*8 - | stfd f0, 8(RA) - | b ->fff_res - |2: // Check for empty hash part first. Otherwise call C function. - | lwz TMP0, TAB:CARG1->hmask - | cmplwi TMP0, 0 - | li RD, (0+1)*8 - | beq ->fff_res - | mr CARG2, TMP2 - | bl extern lj_tab_getinth // (GCtab *t, int32_t key) - | // Returns cTValue * or NULL. - | cmplwi CRET1, 0 - | li RD, (0+1)*8 - | beq ->fff_res - | lwz TMP2, 0(CRET1) - | lfd f0, 0(CRET1) - | b <1 - | - |.ffunc_1 ipairs - | checktab CARG3 - | lwz PC, FRAME_PC(BASE) - | bne ->fff_fallback -#if LJ_52 - | lwz TAB:TMP2, TAB:CARG1->metatable - | lfd f0, CFUNC:RB->upvalue[0] - | cmplwi TAB:TMP2, 0 - | la RA, -8(BASE) - | bne ->fff_fallback -#else - | lfd f0, CFUNC:RB->upvalue[0] - | la RA, -8(BASE) -#endif - |.if DUALNUM - | stw TISNUM, 8(BASE) - |.else - | stw ZERO, 8(BASE) - |.endif - | stw ZERO, 12(BASE) - | li RD, (3+1)*8 - | stfd f0, 0(RA) - | b ->fff_res - | - |//-- Base library: catch errors ---------------------------------------- - | - |.ffunc pcall - | cmplwi NARGS8:RC, 8 - | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) - | blt ->fff_fallback - | mr TMP2, BASE - | la BASE, 8(BASE) - | // Remember active hook before pcall. - | rlwinm TMP3, TMP3, 32-HOOK_ACTIVE_SHIFT, 31, 31 - | subi NARGS8:RC, NARGS8:RC, 8 - | addi PC, TMP3, 8+FRAME_PCALL - | b ->vm_call_dispatch - | - |.ffunc xpcall - | cmplwi NARGS8:RC, 16 - | lwz CARG4, 8(BASE) - | lfd FARG2, 8(BASE) - | lfd FARG1, 0(BASE) - | blt ->fff_fallback - | lbz TMP1, DISPATCH_GL(hookmask)(DISPATCH) - | mr TMP2, BASE - | checkfunc CARG4; bne ->fff_fallback // Traceback must be a function. - | la BASE, 16(BASE) - | // Remember active hook before pcall. - | rlwinm TMP1, TMP1, 32-HOOK_ACTIVE_SHIFT, 31, 31 - | stfd FARG2, 0(TMP2) // Swap function and traceback. - | subi NARGS8:RC, NARGS8:RC, 16 - | stfd FARG1, 8(TMP2) - | addi PC, TMP1, 16+FRAME_PCALL - | b ->vm_call_dispatch - | - |//-- Coroutine library -------------------------------------------------- - | - |.macro coroutine_resume_wrap, resume - |.if resume - |.ffunc_1 coroutine_resume - | cmpwi CARG3, LJ_TTHREAD; bne ->fff_fallback - |.else - |.ffunc coroutine_wrap_aux - | lwz L:CARG1, CFUNC:RB->upvalue[0].gcr - |.endif - | lbz TMP0, L:CARG1->status - | lp TMP1, L:CARG1->cframe - | lp CARG2, L:CARG1->top - | cmplwi cr0, TMP0, LUA_YIELD - | lp TMP2, L:CARG1->base - | cmplwi cr1, TMP1, 0 - | lwz TMP0, L:CARG1->maxstack - | cmplw cr7, CARG2, TMP2 - | lwz PC, FRAME_PC(BASE) - | crorc 4*cr6+lt, 4*cr0+gt, 4*cr1+eq // st>LUA_YIELD || cframe!=0 - | add TMP2, CARG2, NARGS8:RC - | crandc 4*cr6+gt, 4*cr7+eq, 4*cr0+eq // base==top && st!=LUA_YIELD - | cmplw cr1, TMP2, TMP0 - | cror 4*cr6+lt, 4*cr6+lt, 4*cr6+gt - | stw PC, SAVE_PC - | cror 4*cr6+lt, 4*cr6+lt, 4*cr1+gt // cond1 || cond2 || stackov - | stp BASE, L->base - | blt cr6, ->fff_fallback - |1: - |.if resume - | addi BASE, BASE, 8 // Keep resumed thread in stack for GC. - | subi NARGS8:RC, NARGS8:RC, 8 - | subi TMP2, TMP2, 8 - |.endif - | stp TMP2, L:CARG1->top - | li TMP1, 0 - | stp BASE, L->top - |2: // Move args to coroutine. - | cmpw TMP1, NARGS8:RC - | lfdx f0, BASE, TMP1 - | beq >3 - | stfdx f0, CARG2, TMP1 - | addi TMP1, TMP1, 8 - | b <2 - |3: - | li CARG3, 0 - | mr L:SAVE0, L:CARG1 - | li CARG4, 0 - | bl ->vm_resume // (lua_State *L, TValue *base, 0, 0) - | // Returns thread status. - |4: - | lp TMP2, L:SAVE0->base - | cmplwi CRET1, LUA_YIELD - | lp TMP3, L:SAVE0->top - | li_vmstate INTERP - | lp BASE, L->base - | st_vmstate - | bgt >8 - | sub RD, TMP3, TMP2 - | lwz TMP0, L->maxstack - | cmplwi RD, 0 - | add TMP1, BASE, RD - | beq >6 // No results? - | cmplw TMP1, TMP0 - | li TMP1, 0 - | bgt >9 // Need to grow stack? - | - | subi TMP3, RD, 8 - | stp TMP2, L:SAVE0->top // Clear coroutine stack. - |5: // Move results from coroutine. - | cmplw TMP1, TMP3 - | lfdx f0, TMP2, TMP1 - | stfdx f0, BASE, TMP1 - | addi TMP1, TMP1, 8 - | bne <5 - |6: - | andix. TMP0, PC, FRAME_TYPE - |.if resume - | li TMP1, LJ_TTRUE - | la RA, -8(BASE) - | stw TMP1, -8(BASE) // Prepend true to results. - | addi RD, RD, 16 - |.else - | mr RA, BASE - | addi RD, RD, 8 - |.endif - |7: - | stw PC, SAVE_PC - | mr MULTRES, RD - | beq ->BC_RET_Z - | b ->vm_return - | - |8: // Coroutine returned with error (at co->top-1). - |.if resume - | andix. TMP0, PC, FRAME_TYPE - | la TMP3, -8(TMP3) - | li TMP1, LJ_TFALSE - | lfd f0, 0(TMP3) - | stp TMP3, L:SAVE0->top // Remove error from coroutine stack. - | li RD, (2+1)*8 - | stw TMP1, -8(BASE) // Prepend false to results. - | la RA, -8(BASE) - | stfd f0, 0(BASE) // Copy error message. - | b <7 - |.else - | mr CARG1, L - | mr CARG2, L:SAVE0 - | bl extern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co) - |.endif - | - |9: // Handle stack expansion on return from yield. - | mr CARG1, L - | srwi CARG2, RD, 3 - | bl extern lj_state_growstack // (lua_State *L, int n) - | li CRET1, 0 - | b <4 - |.endmacro - | - | coroutine_resume_wrap 1 // coroutine.resume - | coroutine_resume_wrap 0 // coroutine.wrap - | - |.ffunc coroutine_yield - | lp TMP0, L->cframe - | add TMP1, BASE, NARGS8:RC - | stp BASE, L->base - | andix. TMP0, TMP0, CFRAME_RESUME - | stp TMP1, L->top - | li CRET1, LUA_YIELD - | beq ->fff_fallback - | stp ZERO, L->cframe - | stb CRET1, L->status - | b ->vm_leave_unw - | - |//-- Math library ------------------------------------------------------- - | - |.ffunc_1 math_abs - | checknum CARG3 - |.if DUALNUM - | bne >2 - | srawi TMP1, CARG1, 31 - | xor TMP2, TMP1, CARG1 - |.if GPR64 - | lus TMP0, 0x8000 - | sub CARG1, TMP2, TMP1 - | cmplw CARG1, TMP0 - | beq >1 - |.else - | sub. CARG1, TMP2, TMP1 - | blt >1 - |.endif - |->fff_resi: - | lwz PC, FRAME_PC(BASE) - | la RA, -8(BASE) - | stw TISNUM, -8(BASE) - | stw CRET1, -4(BASE) - | b ->fff_res1 - |1: - | lus CARG3, 0x41e0 // 2^31. - | li CARG1, 0 - | b ->fff_restv - |2: - |.endif - | bge ->fff_fallback - | rlwinm CARG3, CARG3, 0, 1, 31 - | // Fallthrough. - | - |->fff_restv: - | // CARG3/CARG1 = TValue result. - | lwz PC, FRAME_PC(BASE) - | stw CARG3, -8(BASE) - | la RA, -8(BASE) - | stw CARG1, -4(BASE) - |->fff_res1: - | // RA = results, PC = return. - | li RD, (1+1)*8 - |->fff_res: - | // RA = results, RD = (nresults+1)*8, PC = return. - | andix. TMP0, PC, FRAME_TYPE - | mr MULTRES, RD - | bney ->vm_return - | lwz INS, -4(PC) - | decode_RB8 RB, INS - |5: - | cmplw RB, RD // More results expected? - | decode_RA8 TMP0, INS - | bgt >6 - | ins_next1 - | // Adjust BASE. KBASE is assumed to be set for the calling frame. - | sub BASE, RA, TMP0 - | ins_next2 - | - |6: // Fill up results with nil. - | subi TMP1, RD, 8 - | addi RD, RD, 8 - | stwx TISNIL, RA, TMP1 - | b <5 - | - |.macro math_extern, func - | .ffunc_n math_ .. func - | blex func - | b ->fff_resn - |.endmacro - | - |.macro math_extern2, func - | .ffunc_nn math_ .. func - | blex func - | b ->fff_resn - |.endmacro - | - |.macro math_round, func - | .ffunc_1 math_ .. func - | checknum CARG3; beqy ->fff_restv - | rlwinm TMP2, CARG3, 12, 21, 31 - | bge ->fff_fallback - | addic. TMP2, TMP2, -1023 // exp = exponent(x) - 1023 - | cmplwi cr1, TMP2, 31 // 0 <= exp < 31? - | subfic TMP0, TMP2, 31 - | blt >3 - | slwi TMP1, CARG3, 11 - | srwi TMP3, CARG1, 21 - | oris TMP1, TMP1, 0x8000 - | addi TMP2, TMP2, 1 - | or TMP1, TMP1, TMP3 - | slwi CARG2, CARG1, 11 - | bge cr1, >4 - | slw TMP3, TMP1, TMP2 - | srw RD, TMP1, TMP0 - | or TMP3, TMP3, CARG2 - | srawi TMP2, CARG3, 31 - |.if "func" == "floor" - | and TMP1, TMP3, TMP2 - | addic TMP0, TMP1, -1 - | subfe TMP1, TMP0, TMP1 - | add CARG1, RD, TMP1 - | xor CARG1, CARG1, TMP2 - | sub CARG1, CARG1, TMP2 - | b ->fff_resi - |.else - | andc TMP1, TMP3, TMP2 - | addic TMP0, TMP1, -1 - | subfe TMP1, TMP0, TMP1 - | add CARG1, RD, TMP1 - | cmpw CARG1, RD - | xor CARG1, CARG1, TMP2 - | sub CARG1, CARG1, TMP2 - | bge ->fff_resi - | // Overflow to 2^31. - | lus CARG3, 0x41e0 // 2^31. - | li CARG1, 0 - | b ->fff_restv - |.endif - |3: // |x| < 1 - | slwi TMP2, CARG3, 1 - | srawi TMP1, CARG3, 31 - | or TMP2, CARG1, TMP2 // ztest = (hi+hi) | lo - |.if "func" == "floor" - | and TMP1, TMP2, TMP1 // (ztest & sign) == 0 ? 0 : -1 - | subfic TMP2, TMP1, 0 - | subfe CARG1, CARG1, CARG1 - |.else - | andc TMP1, TMP2, TMP1 // (ztest & ~sign) == 0 ? 0 : 1 - | addic TMP2, TMP1, -1 - | subfe CARG1, TMP2, TMP1 - |.endif - | b ->fff_resi - |4: // exp >= 31. Check for -(2^31). - | xoris TMP1, TMP1, 0x8000 - | srawi TMP2, CARG3, 31 - |.if "func" == "floor" - | or TMP1, TMP1, CARG2 - |.endif - |.if PPE - | orc TMP1, TMP1, TMP2 - | cmpwi TMP1, 0 - |.else - | orc. TMP1, TMP1, TMP2 - |.endif - | crand 4*cr0+eq, 4*cr0+eq, 4*cr1+eq - | lus CARG1, 0x8000 // -(2^31). - | beqy ->fff_resi - |5: - | lfd FARG1, 0(BASE) - | blex func - | b ->fff_resn - |.endmacro - | - |.if DUALNUM - | math_round floor - | math_round ceil - |.else - | // NYI: use internal implementation. - | math_extern floor - | math_extern ceil - |.endif - | - |.if SQRT - |.ffunc_n math_sqrt - | fsqrt FARG1, FARG1 - | b ->fff_resn - |.else - | math_extern sqrt - |.endif - | - |.ffunc math_log - | cmplwi NARGS8:RC, 8 - | lwz CARG3, 0(BASE) - | lfd FARG1, 0(BASE) - | bne ->fff_fallback // Need exactly 1 argument. - | checknum CARG3; bge ->fff_fallback - | blex log - | b ->fff_resn - | - | math_extern log10 - | math_extern exp - | math_extern sin - | math_extern cos - | math_extern tan - | math_extern asin - | math_extern acos - | math_extern atan - | math_extern sinh - | math_extern cosh - | math_extern tanh - | math_extern2 pow - | math_extern2 atan2 - | math_extern2 fmod - | - |->ff_math_deg: - |.ffunc_n math_rad - | lfd FARG2, CFUNC:RB->upvalue[0] - | fmul FARG1, FARG1, FARG2 - | b ->fff_resn - | - |.if DUALNUM - |.ffunc math_ldexp - | cmplwi NARGS8:RC, 16 - | lwz CARG3, 0(BASE) - | lfd FARG1, 0(BASE) - | lwz CARG4, 8(BASE) - |.if GPR64 - | lwz CARG2, 12(BASE) - |.else - | lwz CARG1, 12(BASE) - |.endif - | blt ->fff_fallback - | checknum CARG3; bge ->fff_fallback - | checknum CARG4; bne ->fff_fallback - |.else - |.ffunc_nn math_ldexp - |.if GPR64 - | toint CARG2, FARG2 - |.else - | toint CARG1, FARG2 - |.endif - |.endif - | blex ldexp - | b ->fff_resn - | - |.ffunc_n math_frexp - |.if GPR64 - | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) - |.else - | la CARG1, DISPATCH_GL(tmptv)(DISPATCH) - |.endif - | lwz PC, FRAME_PC(BASE) - | blex frexp - | lwz TMP1, DISPATCH_GL(tmptv)(DISPATCH) - | la RA, -8(BASE) - |.if not DUALNUM - | tonum_i FARG2, TMP1 - |.endif - | stfd FARG1, 0(RA) - | li RD, (2+1)*8 - |.if DUALNUM - | stw TISNUM, 8(RA) - | stw TMP1, 12(RA) - |.else - | stfd FARG2, 8(RA) - |.endif - | b ->fff_res - | - |.ffunc_n math_modf - |.if GPR64 - | la CARG2, -8(BASE) - |.else - | la CARG1, -8(BASE) - |.endif - | lwz PC, FRAME_PC(BASE) - | blex modf - | la RA, -8(BASE) - | stfd FARG1, 0(BASE) - | li RD, (2+1)*8 - | b ->fff_res - | - |.macro math_minmax, name, ismax - |.if DUALNUM - | .ffunc_1 name - | checknum CARG3 - | addi TMP1, BASE, 8 - | add TMP2, BASE, NARGS8:RC - | bne >4 - |1: // Handle integers. - | lwz CARG4, 0(TMP1) - | cmplw cr1, TMP1, TMP2 - | lwz CARG2, 4(TMP1) - | bge cr1, ->fff_resi - | checknum CARG4 - | xoris TMP0, CARG1, 0x8000 - | xoris TMP3, CARG2, 0x8000 - | bne >3 - | subfc TMP3, TMP3, TMP0 - | subfe TMP0, TMP0, TMP0 - |.if ismax - | andc TMP3, TMP3, TMP0 - |.else - | and TMP3, TMP3, TMP0 - |.endif - | add CARG1, TMP3, CARG2 - |.if GPR64 - | rldicl CARG1, CARG1, 0, 32 - |.endif - | addi TMP1, TMP1, 8 - | b <1 - |3: - | bge ->fff_fallback - | // Convert intermediate result to number and continue below. - | tonum_i FARG1, CARG1 - | lfd FARG2, 0(TMP1) - | b >6 - |4: - | lfd FARG1, 0(BASE) - | bge ->fff_fallback - |5: // Handle numbers. - | lwz CARG4, 0(TMP1) - | cmplw cr1, TMP1, TMP2 - | lfd FARG2, 0(TMP1) - | bge cr1, ->fff_resn - | checknum CARG4; bge >7 - |6: - | fsub f0, FARG1, FARG2 - | addi TMP1, TMP1, 8 - |.if ismax - | fsel FARG1, f0, FARG1, FARG2 - |.else - | fsel FARG1, f0, FARG2, FARG1 - |.endif - | b <5 - |7: // Convert integer to number and continue above. - | lwz CARG2, 4(TMP1) - | bne ->fff_fallback - | tonum_i FARG2, CARG2 - | b <6 - |.else - | .ffunc_n name - | li TMP1, 8 - |1: - | lwzx CARG2, BASE, TMP1 - | lfdx FARG2, BASE, TMP1 - | cmplw cr1, TMP1, NARGS8:RC - | checknum CARG2 - | bge cr1, ->fff_resn - | bge ->fff_fallback - | fsub f0, FARG1, FARG2 - | addi TMP1, TMP1, 8 - |.if ismax - | fsel FARG1, f0, FARG1, FARG2 - |.else - | fsel FARG1, f0, FARG2, FARG1 - |.endif - | b <1 - |.endif - |.endmacro - | - | math_minmax math_min, 0 - | math_minmax math_max, 1 - | - |//-- String library ----------------------------------------------------- - | - |.ffunc_1 string_len - | checkstr CARG3; bne ->fff_fallback - | lwz CRET1, STR:CARG1->len - | b ->fff_resi - | - |.ffunc string_byte // Only handle the 1-arg case here. - | cmplwi NARGS8:RC, 8 - | lwz CARG3, 0(BASE) - | lwz STR:CARG1, 4(BASE) - | bne ->fff_fallback // Need exactly 1 argument. - | checkstr CARG3 - | bne ->fff_fallback - | lwz TMP0, STR:CARG1->len - |.if DUALNUM - | lbz CARG1, STR:CARG1[1] // Access is always ok (NUL at end). - | li RD, (0+1)*8 - | lwz PC, FRAME_PC(BASE) - | cmplwi TMP0, 0 - | la RA, -8(BASE) - | beqy ->fff_res - | b ->fff_resi - |.else - | lbz TMP1, STR:CARG1[1] // Access is always ok (NUL at end). - | addic TMP3, TMP0, -1 // RD = ((str->len != 0)+1)*8 - | subfe RD, TMP3, TMP0 - | stw TMP1, TONUM_LO // Inlined tonum_u f0, TMP1. - | addi RD, RD, 1 - | lfd f0, TONUM_D - | la RA, -8(BASE) - | lwz PC, FRAME_PC(BASE) - | fsub f0, f0, TOBIT - | slwi RD, RD, 3 - | stfd f0, 0(RA) - | b ->fff_res - |.endif - | - |.ffunc string_char // Only handle the 1-arg case here. - | ffgccheck - | cmplwi NARGS8:RC, 8 - | lwz CARG3, 0(BASE) - |.if DUALNUM - | lwz TMP0, 4(BASE) - | bne ->fff_fallback // Exactly 1 argument. - | checknum CARG3; bne ->fff_fallback - | la CARG2, 7(BASE) - |.else - | lfd FARG1, 0(BASE) - | bne ->fff_fallback // Exactly 1 argument. - | checknum CARG3; bge ->fff_fallback - | toint TMP0, FARG1 - | la CARG2, TMPD_BLO - |.endif - | li CARG3, 1 - | cmplwi TMP0, 255; bgt ->fff_fallback - |->fff_newstr: - | mr CARG1, L - | stp BASE, L->base - | stw PC, SAVE_PC - | bl extern lj_str_new // (lua_State *L, char *str, size_t l) - | // Returns GCstr *. - | lp BASE, L->base - | li CARG3, LJ_TSTR - | b ->fff_restv - | - |.ffunc string_sub - | ffgccheck - | cmplwi NARGS8:RC, 16 - | lwz CARG3, 16(BASE) - |.if not DUALNUM - | lfd f0, 16(BASE) - |.endif - | lwz TMP0, 0(BASE) - | lwz STR:CARG1, 4(BASE) - | blt ->fff_fallback - | lwz CARG2, 8(BASE) - |.if DUALNUM - | lwz TMP1, 12(BASE) - |.else - | lfd f1, 8(BASE) - |.endif - | li TMP2, -1 - | beq >1 - |.if DUALNUM - | checknum CARG3 - | lwz TMP2, 20(BASE) - | bne ->fff_fallback - |1: - | checknum CARG2; bne ->fff_fallback - |.else - | checknum CARG3; bge ->fff_fallback - | toint TMP2, f0 - |1: - | checknum CARG2; bge ->fff_fallback - |.endif - | checkstr TMP0; bne ->fff_fallback - |.if not DUALNUM - | toint TMP1, f1 - |.endif - | lwz TMP0, STR:CARG1->len - | cmplw TMP0, TMP2 // len < end? (unsigned compare) - | addi TMP3, TMP2, 1 - | blt >5 - |2: - | cmpwi TMP1, 0 // start <= 0? - | add TMP3, TMP1, TMP0 - | ble >7 - |3: - | sub CARG3, TMP2, TMP1 - | addi CARG2, STR:CARG1, #STR-1 - | srawi TMP0, CARG3, 31 - | addi CARG3, CARG3, 1 - | add CARG2, CARG2, TMP1 - | andc CARG3, CARG3, TMP0 - |.if GPR64 - | rldicl CARG2, CARG2, 0, 32 - | rldicl CARG3, CARG3, 0, 32 - |.endif - | b ->fff_newstr - | - |5: // Negative end or overflow. - | cmpw TMP0, TMP2 // len >= end? (signed compare) - | add TMP2, TMP0, TMP3 // Negative end: end = end+len+1. - | bge <2 - | mr TMP2, TMP0 // Overflow: end = len. - | b <2 - | - |7: // Negative start or underflow. - | .gpr64 extsw TMP1, TMP1 - | addic CARG3, TMP1, -1 - | subfe CARG3, CARG3, CARG3 - | srawi CARG2, TMP3, 31 // Note: modifies carry. - | andc TMP3, TMP3, CARG3 - | andc TMP1, TMP3, CARG2 - | addi TMP1, TMP1, 1 // start = 1 + (start ? start+len : 0) - | b <3 - | - |.ffunc string_rep // Only handle the 1-char case inline. - | ffgccheck - | cmplwi NARGS8:RC, 16 - | lwz TMP0, 0(BASE) - | lwz STR:CARG1, 4(BASE) - | lwz CARG4, 8(BASE) - |.if DUALNUM - | lwz CARG3, 12(BASE) - |.else - | lfd FARG2, 8(BASE) - |.endif - | bne ->fff_fallback // Exactly 2 arguments. - | checkstr TMP0; bne ->fff_fallback - |.if DUALNUM - | checknum CARG4; bne ->fff_fallback - |.else - | checknum CARG4; bge ->fff_fallback - | toint CARG3, FARG2 - |.endif - | lwz TMP0, STR:CARG1->len - | cmpwi CARG3, 0 - | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) - | ble >2 // Count <= 0? (or non-int) - | cmplwi TMP0, 1 - | subi TMP2, CARG3, 1 - | blt >2 // Zero length string? - | cmplw cr1, TMP1, CARG3 - | bne ->fff_fallback // Fallback for > 1-char strings. - | lbz TMP0, STR:CARG1[1] - | lp CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) - | blt cr1, ->fff_fallback - |1: // Fill buffer with char. Yes, this is suboptimal code (do you care?). - | cmplwi TMP2, 0 - | stbx TMP0, CARG2, TMP2 - | subi TMP2, TMP2, 1 - | bne <1 - | b ->fff_newstr - |2: // Return empty string. - | la STR:CARG1, DISPATCH_GL(strempty)(DISPATCH) - | li CARG3, LJ_TSTR - | b ->fff_restv - | - |.ffunc string_reverse - | ffgccheck - | cmplwi NARGS8:RC, 8 - | lwz CARG3, 0(BASE) - | lwz STR:CARG1, 4(BASE) - | blt ->fff_fallback - | checkstr CARG3 - | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) - | bne ->fff_fallback - | lwz CARG3, STR:CARG1->len - | la CARG1, #STR(STR:CARG1) - | lp CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) - | li TMP2, 0 - | cmplw TMP1, CARG3 - | subi TMP3, CARG3, 1 - | blt ->fff_fallback - |1: // Reverse string copy. - | cmpwi TMP3, 0 - | lbzx TMP1, CARG1, TMP2 - | blty ->fff_newstr - | stbx TMP1, CARG2, TMP3 - | subi TMP3, TMP3, 1 - | addi TMP2, TMP2, 1 - | b <1 - | - |.macro ffstring_case, name, lo - | .ffunc name - | ffgccheck - | cmplwi NARGS8:RC, 8 - | lwz CARG3, 0(BASE) - | lwz STR:CARG1, 4(BASE) - | blt ->fff_fallback - | checkstr CARG3 - | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) - | bne ->fff_fallback - | lwz CARG3, STR:CARG1->len - | la CARG1, #STR(STR:CARG1) - | lp CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) - | cmplw TMP1, CARG3 - | li TMP2, 0 - | blt ->fff_fallback - |1: // ASCII case conversion. - | cmplw TMP2, CARG3 - | lbzx TMP1, CARG1, TMP2 - | bgey ->fff_newstr - | subi TMP0, TMP1, lo - | xori TMP3, TMP1, 0x20 - | addic TMP0, TMP0, -26 - | subfe TMP3, TMP3, TMP3 - | rlwinm TMP3, TMP3, 0, 26, 26 // x &= 0x20. - | xor TMP1, TMP1, TMP3 - | stbx TMP1, CARG2, TMP2 - | addi TMP2, TMP2, 1 - | b <1 - |.endmacro - | - |ffstring_case string_lower, 65 - |ffstring_case string_upper, 97 - | - |//-- Table library ------------------------------------------------------ - | - |.ffunc_1 table_getn - | checktab CARG3; bne ->fff_fallback - | bl extern lj_tab_len // (GCtab *t) - | // Returns uint32_t (but less than 2^31). - | b ->fff_resi - | - |//-- Bit library -------------------------------------------------------- - | - |.macro .ffunc_bit, name - |.if DUALNUM - | .ffunc_1 bit_..name - | checknum CARG3; bnel ->fff_tobit_fb - |.else - | .ffunc_n bit_..name - | fadd FARG1, FARG1, TOBIT - | stfd FARG1, TMPD - | lwz CARG1, TMPD_LO - |.endif - |.endmacro - | - |.macro .ffunc_bit_op, name, ins - | .ffunc_bit name - | addi TMP1, BASE, 8 - | add TMP2, BASE, NARGS8:RC - |1: - | lwz CARG4, 0(TMP1) - | cmplw cr1, TMP1, TMP2 - |.if DUALNUM - | lwz CARG2, 4(TMP1) - |.else - | lfd FARG1, 0(TMP1) - |.endif - | bgey cr1, ->fff_resi - | checknum CARG4 - |.if DUALNUM - | bnel ->fff_bitop_fb - |.else - | fadd FARG1, FARG1, TOBIT - | bge ->fff_fallback - | stfd FARG1, TMPD - | lwz CARG2, TMPD_LO - |.endif - | ins CARG1, CARG1, CARG2 - | addi TMP1, TMP1, 8 - | b <1 - |.endmacro - | - |.ffunc_bit_op band, and - |.ffunc_bit_op bor, or - |.ffunc_bit_op bxor, xor - | - |.ffunc_bit bswap - | rotlwi TMP0, CARG1, 8 - | rlwimi TMP0, CARG1, 24, 0, 7 - | rlwimi TMP0, CARG1, 24, 16, 23 - | mr CRET1, TMP0 - | b ->fff_resi - | - |.ffunc_bit bnot - | not CRET1, CARG1 - | b ->fff_resi - | - |.macro .ffunc_bit_sh, name, ins, shmod - |.if DUALNUM - | .ffunc_2 bit_..name - | checknum CARG3; bnel ->fff_tobit_fb - | // Note: no inline conversion from number for 2nd argument! - | checknum CARG4; bne ->fff_fallback - |.else - | .ffunc_nn bit_..name - | fadd FARG1, FARG1, TOBIT - | fadd FARG2, FARG2, TOBIT - | stfd FARG1, TMPD - | lwz CARG1, TMPD_LO - | stfd FARG2, TMPD - | lwz CARG2, TMPD_LO - |.endif - |.if shmod == 1 - | rlwinm CARG2, CARG2, 0, 27, 31 - |.elif shmod == 2 - | neg CARG2, CARG2 - |.endif - | ins CRET1, CARG1, CARG2 - | b ->fff_resi - |.endmacro - | - |.ffunc_bit_sh lshift, slw, 1 - |.ffunc_bit_sh rshift, srw, 1 - |.ffunc_bit_sh arshift, sraw, 1 - |.ffunc_bit_sh rol, rotlw, 0 - |.ffunc_bit_sh ror, rotlw, 2 - | - |.ffunc_bit tobit - |.if DUALNUM - | b ->fff_resi - |.else - |->fff_resi: - | tonum_i FARG1, CRET1 - |.endif - |->fff_resn: - | lwz PC, FRAME_PC(BASE) - | la RA, -8(BASE) - | stfd FARG1, -8(BASE) - | b ->fff_res1 - | - |// Fallback FP number to bit conversion. - |->fff_tobit_fb: - |.if DUALNUM - | lfd FARG1, 0(BASE) - | bgt ->fff_fallback - | fadd FARG1, FARG1, TOBIT - | stfd FARG1, TMPD - | lwz CARG1, TMPD_LO - | blr - |.endif - |->fff_bitop_fb: - |.if DUALNUM - | lfd FARG1, 0(TMP1) - | bgt ->fff_fallback - | fadd FARG1, FARG1, TOBIT - | stfd FARG1, TMPD - | lwz CARG2, TMPD_LO - | blr - |.endif - | - |//----------------------------------------------------------------------- - | - |->fff_fallback: // Call fast function fallback handler. - | // BASE = new base, RB = CFUNC, RC = nargs*8 - | lp TMP3, CFUNC:RB->f - | add TMP1, BASE, NARGS8:RC - | lwz PC, FRAME_PC(BASE) // Fallback may overwrite PC. - | addi TMP0, TMP1, 8*LUA_MINSTACK - | lwz TMP2, L->maxstack - | stw PC, SAVE_PC // Redundant (but a defined value). - | .toc lp TMP3, 0(TMP3) - | cmplw TMP0, TMP2 - | stp BASE, L->base - | stp TMP1, L->top - | mr CARG1, L - | bgt >5 // Need to grow stack. - | mtctr TMP3 - | bctrl // (lua_State *L) - | // Either throws an error, or recovers and returns -1, 0 or nresults+1. - | lp BASE, L->base - | cmpwi CRET1, 0 - | slwi RD, CRET1, 3 - | la RA, -8(BASE) - | bgt ->fff_res // Returned nresults+1? - |1: // Returned 0 or -1: retry fast path. - | lp TMP0, L->top - | lwz LFUNC:RB, FRAME_FUNC(BASE) - | sub NARGS8:RC, TMP0, BASE - | bne ->vm_call_tail // Returned -1? - | ins_callt // Returned 0: retry fast path. - | - |// Reconstruct previous base for vmeta_call during tailcall. - |->vm_call_tail: - | andix. TMP0, PC, FRAME_TYPE - | rlwinm TMP1, PC, 0, 0, 28 - | bne >3 - | lwz INS, -4(PC) - | decode_RA8 TMP1, INS - | addi TMP1, TMP1, 8 - |3: - | sub TMP2, BASE, TMP1 - | b ->vm_call_dispatch // Resolve again for tailcall. - | - |5: // Grow stack for fallback handler. - | li CARG2, LUA_MINSTACK - | bl extern lj_state_growstack // (lua_State *L, int n) - | lp BASE, L->base - | cmpw TMP0, TMP0 // Set 4*cr0+eq to force retry. - | b <1 - | - |->fff_gcstep: // Call GC step function. - | // BASE = new base, RC = nargs*8 - | mflr SAVE0 - | stp BASE, L->base - | add TMP0, BASE, NARGS8:RC - | stw PC, SAVE_PC // Redundant (but a defined value). - | stp TMP0, L->top - | mr CARG1, L - | bl extern lj_gc_step // (lua_State *L) - | lp BASE, L->base - | mtlr SAVE0 - | lp TMP0, L->top - | sub NARGS8:RC, TMP0, BASE - | lwz CFUNC:RB, FRAME_FUNC(BASE) - | blr - | - |//----------------------------------------------------------------------- - |//-- Special dispatch targets ------------------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_record: // Dispatch target for recording phase. - |.if JIT - | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) - | andix. TMP0, TMP3, HOOK_VMEVENT // No recording while in vmevent. - | bne >5 - | // Decrement the hookcount for consistency, but always do the call. - | lwz TMP2, DISPATCH_GL(hookcount)(DISPATCH) - | andix. TMP0, TMP3, HOOK_ACTIVE - | bne >1 - | subi TMP2, TMP2, 1 - | andi. TMP0, TMP3, LUA_MASKLINE|LUA_MASKCOUNT - | beqy >1 - | stw TMP2, DISPATCH_GL(hookcount)(DISPATCH) - | b >1 - |.endif - | - |->vm_rethook: // Dispatch target for return hooks. - | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) - | andix. TMP0, TMP3, HOOK_ACTIVE // Hook already active? - | beq >1 - |5: // Re-dispatch to static ins. - | addi TMP1, TMP1, GG_DISP2STATIC // Assumes decode_OPP TMP1, INS. - | lpx TMP0, DISPATCH, TMP1 - | mtctr TMP0 - | bctr - | - |->vm_inshook: // Dispatch target for instr/line hooks. - | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) - | lwz TMP2, DISPATCH_GL(hookcount)(DISPATCH) - | andix. TMP0, TMP3, HOOK_ACTIVE // Hook already active? - | rlwinm TMP0, TMP3, 31-LUA_HOOKLINE, 31, 0 - | bne <5 - | - | cmpwi cr1, TMP0, 0 - | addic. TMP2, TMP2, -1 - | beq cr1, <5 - | stw TMP2, DISPATCH_GL(hookcount)(DISPATCH) - | beq >1 - | bge cr1, <5 - |1: - | mr CARG1, L - | stw MULTRES, SAVE_MULTRES - | mr CARG2, PC - | stp BASE, L->base - | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. - | bl extern lj_dispatch_ins // (lua_State *L, const BCIns *pc) - |3: - | lp BASE, L->base - |4: // Re-dispatch to static ins. - | lwz INS, -4(PC) - | decode_OPP TMP1, INS - | decode_RB8 RB, INS - | addi TMP1, TMP1, GG_DISP2STATIC - | decode_RD8 RD, INS - | lpx TMP0, DISPATCH, TMP1 - | decode_RA8 RA, INS - | decode_RC8 RC, INS - | mtctr TMP0 - | bctr - | - |->cont_hook: // Continue from hook yield. - | addi PC, PC, 4 - | lwz MULTRES, -20(RB) // Restore MULTRES for *M ins. - | b <4 - | - |->vm_hotloop: // Hot loop counter underflow. - |.if JIT - | lwz LFUNC:TMP1, FRAME_FUNC(BASE) - | addi CARG1, DISPATCH, GG_DISP2J - | stw PC, SAVE_PC - | lwz TMP1, LFUNC:TMP1->pc - | mr CARG2, PC - | stw L, DISPATCH_J(L)(DISPATCH) - | lbz TMP1, PC2PROTO(framesize)(TMP1) - | stp BASE, L->base - | slwi TMP1, TMP1, 3 - | add TMP1, BASE, TMP1 - | stp TMP1, L->top - | bl extern lj_trace_hot // (jit_State *J, const BCIns *pc) - | b <3 - |.endif - | - |->vm_callhook: // Dispatch target for call hooks. - | mr CARG2, PC - |.if JIT - | b >1 - |.endif - | - |->vm_hotcall: // Hot call counter underflow. - |.if JIT - | ori CARG2, PC, 1 - |1: - |.endif - | add TMP0, BASE, RC - | stw PC, SAVE_PC - | mr CARG1, L - | stp BASE, L->base - | sub RA, RA, BASE - | stp TMP0, L->top - | bl extern lj_dispatch_call // (lua_State *L, const BCIns *pc) - | // Returns ASMFunction. - | lp BASE, L->base - | lp TMP0, L->top - | stw ZERO, SAVE_PC // Invalidate for subsequent line hook. - | sub NARGS8:RC, TMP0, BASE - | add RA, BASE, RA - | lwz LFUNC:RB, FRAME_FUNC(BASE) - | lwz INS, -4(PC) - | mtctr CRET1 - | bctr - | - |//----------------------------------------------------------------------- - |//-- Trace exit handler ------------------------------------------------- - |//----------------------------------------------------------------------- - | - |.macro savex_, a, b, c, d - | stfd f..a, 16+a*8(sp) - | stfd f..b, 16+b*8(sp) - | stfd f..c, 16+c*8(sp) - | stfd f..d, 16+d*8(sp) - |.endmacro - | - |->vm_exit_handler: - |.if JIT - | addi sp, sp, -(16+32*8+32*4) - | stmw r2, 16+32*8+2*4(sp) - | addi DISPATCH, JGL, -GG_DISP2G-32768 - | li CARG2, ~LJ_VMST_EXIT - | lwz CARG1, 16+32*8+32*4(sp) // Get stack chain. - | stw CARG2, DISPATCH_GL(vmstate)(DISPATCH) - | savex_ 0,1,2,3 - | stw CARG1, 0(sp) // Store extended stack chain. - | mcrxr cr0 // Clear SO flag. - | savex_ 4,5,6,7 - | addi CARG2, sp, 16+32*8+32*4 // Recompute original value of sp. - | savex_ 8,9,10,11 - | stw CARG2, 16+32*8+1*4(sp) // Store sp in RID_SP. - | savex_ 12,13,14,15 - | mflr CARG3 - | li TMP1, 0 - | savex_ 16,17,18,19 - | stw TMP1, 16+32*8+0*4(sp) // Clear RID_TMP. - | savex_ 20,21,22,23 - | lhz CARG4, 2(CARG3) // Load trace number. - | savex_ 24,25,26,27 - | lwz L, DISPATCH_GL(jit_L)(DISPATCH) - | savex_ 28,29,30,31 - | sub CARG3, TMP0, CARG3 // Compute exit number. - | lp BASE, DISPATCH_GL(jit_base)(DISPATCH) - | srwi CARG3, CARG3, 2 - | stw L, DISPATCH_J(L)(DISPATCH) - | subi CARG3, CARG3, 2 - | stw TMP1, DISPATCH_GL(jit_L)(DISPATCH) - | stw CARG4, DISPATCH_J(parent)(DISPATCH) - | stp BASE, L->base - | addi CARG1, DISPATCH, GG_DISP2J - | stw CARG3, DISPATCH_J(exitno)(DISPATCH) - | addi CARG2, sp, 16 - | bl extern lj_trace_exit // (jit_State *J, ExitState *ex) - | // Returns MULTRES (unscaled) or negated error code. - | lp TMP1, L->cframe - | lwz TMP2, 0(sp) - | lp BASE, L->base - |.if GPR64 - | rldicr sp, TMP1, 0, 61 - |.else - | rlwinm sp, TMP1, 0, 0, 29 - |.endif - | lwz PC, SAVE_PC // Get SAVE_PC. - | stw TMP2, 0(sp) - | stw L, SAVE_L // Set SAVE_L (on-trace resume/yield). - | b >1 - |.endif - |->vm_exit_interp: - |.if JIT - | // CARG1 = MULTRES or negated error code, BASE, PC and JGL set. - | lwz L, SAVE_L - | addi DISPATCH, JGL, -GG_DISP2G-32768 - |1: - | cmpwi CARG1, 0 - | blt >3 // Check for error from exit. - | lwz LFUNC:TMP1, FRAME_FUNC(BASE) - | slwi MULTRES, CARG1, 3 - | li TMP2, 0 - | stw MULTRES, SAVE_MULTRES - | lwz TMP1, LFUNC:TMP1->pc - | stw TMP2, DISPATCH_GL(jit_L)(DISPATCH) - | lwz KBASE, PC2PROTO(k)(TMP1) - | // Setup type comparison constants. - | li TISNUM, LJ_TISNUM - | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). - | stw TMP3, TMPD - | li ZERO, 0 - | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). - | lfs TOBIT, TMPD - | stw TMP3, TMPD - | lus TMP0, 0x4338 // Hiword of 2^52 + 2^51 (double) - | li TISNIL, LJ_TNIL - | stw TMP0, TONUM_HI - | lfs TONUM, TMPD - | // Modified copy of ins_next which handles function header dispatch, too. - | lwz INS, 0(PC) - | addi PC, PC, 4 - | // Assumes TISNIL == ~LJ_VMST_INTERP == -1. - | stw TISNIL, DISPATCH_GL(vmstate)(DISPATCH) - | decode_OPP TMP1, INS - | decode_RA8 RA, INS - | lpx TMP0, DISPATCH, TMP1 - | mtctr TMP0 - | cmplwi TMP1, BC_FUNCF*4 // Function header? - | bge >2 - | decode_RB8 RB, INS - | decode_RD8 RD, INS - | decode_RC8 RC, INS - | bctr - |2: - | subi RC, MULTRES, 8 - | add RA, RA, BASE - | bctr - | - |3: // Rethrow error from the right C frame. - | neg CARG2, CARG1 - | mr CARG1, L - | bl extern lj_err_throw // (lua_State *L, int errcode) - |.endif - | - |//----------------------------------------------------------------------- - |//-- Math helper functions ---------------------------------------------- - |//----------------------------------------------------------------------- - | - |// NYI: Use internal implementations of floor, ceil, trunc. - | - |->vm_modi: - | divwo. TMP0, CARG1, CARG2 - | bso >1 - |.if GPR64 - | xor CARG3, CARG1, CARG2 - | cmpwi CARG3, 0 - |.else - | xor. CARG3, CARG1, CARG2 - |.endif - | mullw TMP0, TMP0, CARG2 - | sub CARG1, CARG1, TMP0 - | bgelr - | cmpwi CARG1, 0; beqlr - | add CARG1, CARG1, CARG2 - | blr - |1: - | cmpwi CARG2, 0 - | li CARG1, 0 - | beqlr - | mcrxr cr0 // Clear SO for -2147483648 % -1 and return 0. - | blr - | - |//----------------------------------------------------------------------- - |//-- Miscellaneous functions -------------------------------------------- - |//----------------------------------------------------------------------- - | - |// void lj_vm_cachesync(void *start, void *end) - |// Flush D-Cache and invalidate I-Cache. Assumes 32 byte cache line size. - |// This is a good lower bound, except for very ancient PPC models. - |->vm_cachesync: - |.if JIT or FFI - | // Compute start of first cache line and number of cache lines. - | rlwinm CARG1, CARG1, 0, 0, 26 - | sub CARG2, CARG2, CARG1 - | addi CARG2, CARG2, 31 - | rlwinm. CARG2, CARG2, 27, 5, 31 - | beqlr - | mtctr CARG2 - | mr CARG3, CARG1 - |1: // Flush D-Cache. - | dcbst r0, CARG1 - | addi CARG1, CARG1, 32 - | bdnz <1 - | sync - | mtctr CARG2 - |1: // Invalidate I-Cache. - | icbi r0, CARG3 - | addi CARG3, CARG3, 32 - | bdnz <1 - | isync - | blr - |.endif - | - |//----------------------------------------------------------------------- - |//-- FFI helper functions ----------------------------------------------- - |//----------------------------------------------------------------------- - | - |// Handler for callback functions. Callback slot number in r11, g in r12. - |->vm_ffi_callback: - |.if FFI - |.type CTSTATE, CTState, PC - | saveregs - | lwz CTSTATE, GL:r12->ctype_state - | addi DISPATCH, r12, GG_G2DISP - | stw r11, CTSTATE->cb.slot - | stw r3, CTSTATE->cb.gpr[0] - | stfd f1, CTSTATE->cb.fpr[0] - | stw r4, CTSTATE->cb.gpr[1] - | stfd f2, CTSTATE->cb.fpr[1] - | stw r5, CTSTATE->cb.gpr[2] - | stfd f3, CTSTATE->cb.fpr[2] - | stw r6, CTSTATE->cb.gpr[3] - | stfd f4, CTSTATE->cb.fpr[3] - | stw r7, CTSTATE->cb.gpr[4] - | stfd f5, CTSTATE->cb.fpr[4] - | stw r8, CTSTATE->cb.gpr[5] - | stfd f6, CTSTATE->cb.fpr[5] - | stw r9, CTSTATE->cb.gpr[6] - | stfd f7, CTSTATE->cb.fpr[6] - | stw r10, CTSTATE->cb.gpr[7] - | stfd f8, CTSTATE->cb.fpr[7] - | addi TMP0, sp, CFRAME_SPACE+8 - | stw TMP0, CTSTATE->cb.stack - | mr CARG1, CTSTATE - | stw CTSTATE, SAVE_PC // Any value outside of bytecode is ok. - | mr CARG2, sp - | bl extern lj_ccallback_enter // (CTState *cts, void *cf) - | // Returns lua_State *. - | lp BASE, L:CRET1->base - | li TISNUM, LJ_TISNUM // Setup type comparison constants. - | lp RC, L:CRET1->top - | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). - | li ZERO, 0 - | mr L, CRET1 - | stw TMP3, TMPD - | lus TMP0, 0x4338 // Hiword of 2^52 + 2^51 (double) - | lwz LFUNC:RB, FRAME_FUNC(BASE) - | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). - | stw TMP0, TONUM_HI - | li TISNIL, LJ_TNIL - | li_vmstate INTERP - | lfs TOBIT, TMPD - | stw TMP3, TMPD - | sub RC, RC, BASE - | st_vmstate - | lfs TONUM, TMPD - | ins_callt - |.endif - | - |->cont_ffi_callback: // Return from FFI callback. - |.if FFI - | lwz CTSTATE, DISPATCH_GL(ctype_state)(DISPATCH) - | stp BASE, L->base - | stp RB, L->top - | stp L, CTSTATE->L - | mr CARG1, CTSTATE - | mr CARG2, RA - | bl extern lj_ccallback_leave // (CTState *cts, TValue *o) - | lwz CRET1, CTSTATE->cb.gpr[0] - | lfd FARG1, CTSTATE->cb.fpr[0] - | lwz CRET2, CTSTATE->cb.gpr[1] - | b ->vm_leave_unw - |.endif - | - |->vm_ffi_call: // Call C function via FFI. - | // Caveat: needs special frame unwinding, see below. - |.if FFI - | .type CCSTATE, CCallState, CARG1 - | lwz TMP1, CCSTATE->spadj - | mflr TMP0 - | lbz CARG2, CCSTATE->nsp - | lbz CARG3, CCSTATE->nfpr - | neg TMP1, TMP1 - | stw TMP0, 4(sp) - | cmpwi cr1, CARG3, 0 - | mr TMP2, sp - | addic. CARG2, CARG2, -1 - | stwux sp, sp, TMP1 - | crnot 4*cr1+eq, 4*cr1+eq // For vararg calls. - | stw r14, -4(TMP2) - | stw CCSTATE, -8(TMP2) - | mr r14, TMP2 - | la TMP1, CCSTATE->stack - | slwi CARG2, CARG2, 2 - | blty >2 - | la TMP2, 8(sp) - |1: - | lwzx TMP0, TMP1, CARG2 - | stwx TMP0, TMP2, CARG2 - | addic. CARG2, CARG2, -4 - | bge <1 - |2: - | bney cr1, >3 - | lfd f1, CCSTATE->fpr[0] - | lfd f2, CCSTATE->fpr[1] - | lfd f3, CCSTATE->fpr[2] - | lfd f4, CCSTATE->fpr[3] - | lfd f5, CCSTATE->fpr[4] - | lfd f6, CCSTATE->fpr[5] - | lfd f7, CCSTATE->fpr[6] - | lfd f8, CCSTATE->fpr[7] - |3: - | lp TMP0, CCSTATE->func - | lwz CARG2, CCSTATE->gpr[1] - | lwz CARG3, CCSTATE->gpr[2] - | lwz CARG4, CCSTATE->gpr[3] - | lwz CARG5, CCSTATE->gpr[4] - | mtctr TMP0 - | lwz r8, CCSTATE->gpr[5] - | lwz r9, CCSTATE->gpr[6] - | lwz r10, CCSTATE->gpr[7] - | lwz CARG1, CCSTATE->gpr[0] // Do this last, since CCSTATE is CARG1. - | bctrl - | lwz CCSTATE:TMP1, -8(r14) - | lwz TMP2, -4(r14) - | lwz TMP0, 4(r14) - | stw CARG1, CCSTATE:TMP1->gpr[0] - | stfd FARG1, CCSTATE:TMP1->fpr[0] - | stw CARG2, CCSTATE:TMP1->gpr[1] - | mtlr TMP0 - | stw CARG3, CCSTATE:TMP1->gpr[2] - | mr sp, r14 - | stw CARG4, CCSTATE:TMP1->gpr[3] - | mr r14, TMP2 - | blr - |.endif - |// Note: vm_ffi_call must be the last function in this object file! - | - |//----------------------------------------------------------------------- -} - -/* Generate the code for a single instruction. */ -static void build_ins(BuildCtx *ctx, BCOp op, int defop) -{ - int vk = 0; - |=>defop: - - switch (op) { - - /* -- Comparison ops ---------------------------------------------------- */ - - /* Remember: all ops branch for a true comparison, fall through otherwise. */ - - case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: - | // RA = src1*8, RD = src2*8, JMP with RD = target - |.if DUALNUM - | lwzux TMP0, RA, BASE - | addi PC, PC, 4 - | lwz CARG2, 4(RA) - | lwzux TMP1, RD, BASE - | lwz TMP2, -4(PC) - | checknum cr0, TMP0 - | lwz CARG3, 4(RD) - | decode_RD4 TMP2, TMP2 - | checknum cr1, TMP1 - | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) - | bne cr0, >7 - | bne cr1, >8 - | cmpw CARG2, CARG3 - if (op == BC_ISLT) { - | bge >2 - } else if (op == BC_ISGE) { - | blt >2 - } else if (op == BC_ISLE) { - | bgt >2 - } else { - | ble >2 - } - |1: - | add PC, PC, TMP2 - |2: - | ins_next - | - |7: // RA is not an integer. - | bgt cr0, ->vmeta_comp - | // RA is a number. - | lfd f0, 0(RA) - | bgt cr1, ->vmeta_comp - | blt cr1, >4 - | // RA is a number, RD is an integer. - | tonum_i f1, CARG3 - | b >5 - | - |8: // RA is an integer, RD is not an integer. - | bgt cr1, ->vmeta_comp - | // RA is an integer, RD is a number. - | tonum_i f0, CARG2 - |4: - | lfd f1, 0(RD) - |5: - | fcmpu cr0, f0, f1 - if (op == BC_ISLT) { - | bge <2 - } else if (op == BC_ISGE) { - | blt <2 - } else if (op == BC_ISLE) { - | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+eq - | bge <2 - } else { - | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+eq - | blt <2 - } - | b <1 - |.else - | lwzx TMP0, BASE, RA - | addi PC, PC, 4 - | lfdx f0, BASE, RA - | lwzx TMP1, BASE, RD - | checknum cr0, TMP0 - | lwz TMP2, -4(PC) - | lfdx f1, BASE, RD - | checknum cr1, TMP1 - | decode_RD4 TMP2, TMP2 - | bge cr0, ->vmeta_comp - | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) - | bge cr1, ->vmeta_comp - | fcmpu cr0, f0, f1 - if (op == BC_ISLT) { - | bge >1 - } else if (op == BC_ISGE) { - | blt >1 - } else if (op == BC_ISLE) { - | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+eq - | bge >1 - } else { - | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+eq - | blt >1 - } - | add PC, PC, TMP2 - |1: - | ins_next - |.endif - break; - - case BC_ISEQV: case BC_ISNEV: - vk = op == BC_ISEQV; - | // RA = src1*8, RD = src2*8, JMP with RD = target - |.if DUALNUM - | lwzux TMP0, RA, BASE - | addi PC, PC, 4 - | lwz CARG2, 4(RA) - | lwzux TMP1, RD, BASE - | checknum cr0, TMP0 - | lwz TMP2, -4(PC) - | checknum cr1, TMP1 - | decode_RD4 TMP2, TMP2 - | lwz CARG3, 4(RD) - | cror 4*cr7+gt, 4*cr0+gt, 4*cr1+gt - | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) - if (vk) { - | ble cr7, ->BC_ISEQN_Z - } else { - | ble cr7, ->BC_ISNEN_Z - } - |.else - | lwzux TMP0, RA, BASE - | lwz TMP2, 0(PC) - | lfd f0, 0(RA) - | addi PC, PC, 4 - | lwzux TMP1, RD, BASE - | checknum cr0, TMP0 - | decode_RD4 TMP2, TMP2 - | lfd f1, 0(RD) - | checknum cr1, TMP1 - | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) - | bge cr0, >5 - | bge cr1, >5 - | fcmpu cr0, f0, f1 - if (vk) { - | bne >1 - | add PC, PC, TMP2 - } else { - | beq >1 - | add PC, PC, TMP2 - } - |1: - | ins_next - |.endif - |5: // Either or both types are not numbers. - |.if not DUALNUM - | lwz CARG2, 4(RA) - | lwz CARG3, 4(RD) - |.endif - |.if FFI - | cmpwi cr7, TMP0, LJ_TCDATA - | cmpwi cr5, TMP1, LJ_TCDATA - |.endif - | not TMP3, TMP0 - | cmplw TMP0, TMP1 - | cmplwi cr1, TMP3, ~LJ_TISPRI // Primitive? - |.if FFI - | cror 4*cr7+eq, 4*cr7+eq, 4*cr5+eq - |.endif - | cmplwi cr6, TMP3, ~LJ_TISTABUD // Table or userdata? - |.if FFI - | beq cr7, ->vmeta_equal_cd - |.endif - | cmplw cr5, CARG2, CARG3 - | crandc 4*cr0+gt, 4*cr0+eq, 4*cr1+gt // 2: Same type and primitive. - | crorc 4*cr0+lt, 4*cr5+eq, 4*cr0+eq // 1: Same tv or different type. - | crand 4*cr0+eq, 4*cr0+eq, 4*cr5+eq // 0: Same type and same tv. - | mr SAVE0, PC - | cror 4*cr0+eq, 4*cr0+eq, 4*cr0+gt // 0 or 2. - | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+gt // 1 or 2. - if (vk) { - | bne cr0, >6 - | add PC, PC, TMP2 - |6: - } else { - | beq cr0, >6 - | add PC, PC, TMP2 - |6: - } - |.if DUALNUM - | bge cr0, >2 // Done if 1 or 2. - |1: - | ins_next - |2: - |.else - | blt cr0, <1 // Done if 1 or 2. - |.endif - | blt cr6, <1 // Done if not tab/ud. - | - | // Different tables or userdatas. Need to check __eq metamethod. - | // Field metatable must be at same offset for GCtab and GCudata! - | lwz TAB:TMP2, TAB:CARG2->metatable - | li CARG4, 1-vk // ne = 0 or 1. - | cmplwi TAB:TMP2, 0 - | beq <1 // No metatable? - | lbz TMP2, TAB:TMP2->nomm - | andix. TMP2, TMP2, 1<vmeta_equal // Handle __eq metamethod. - break; - - case BC_ISEQS: case BC_ISNES: - vk = op == BC_ISEQS; - | // RA = src*8, RD = str_const*8 (~), JMP with RD = target - | lwzux TMP0, RA, BASE - | srwi RD, RD, 1 - | lwz STR:TMP3, 4(RA) - | lwz TMP2, 0(PC) - | subfic RD, RD, -4 - | addi PC, PC, 4 - |.if FFI - | cmpwi TMP0, LJ_TCDATA - |.endif - | lwzx STR:TMP1, KBASE, RD // KBASE-4-str_const*4 - | .gpr64 extsw TMP0, TMP0 - | subfic TMP0, TMP0, LJ_TSTR - |.if FFI - | beq ->vmeta_equal_cd - |.endif - | sub TMP1, STR:TMP1, STR:TMP3 - | or TMP0, TMP0, TMP1 - | decode_RD4 TMP2, TMP2 - | subfic TMP0, TMP0, 0 - | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) - | subfe TMP1, TMP1, TMP1 - if (vk) { - | andc TMP2, TMP2, TMP1 - } else { - | and TMP2, TMP2, TMP1 - } - | add PC, PC, TMP2 - | ins_next - break; - - case BC_ISEQN: case BC_ISNEN: - vk = op == BC_ISEQN; - | // RA = src*8, RD = num_const*8, JMP with RD = target - |.if DUALNUM - | lwzux TMP0, RA, BASE - | addi PC, PC, 4 - | lwz CARG2, 4(RA) - | lwzux TMP1, RD, KBASE - | checknum cr0, TMP0 - | lwz TMP2, -4(PC) - | checknum cr1, TMP1 - | decode_RD4 TMP2, TMP2 - | lwz CARG3, 4(RD) - | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) - if (vk) { - |->BC_ISEQN_Z: - } else { - |->BC_ISNEN_Z: - } - | bne cr0, >7 - | bne cr1, >8 - | cmpw CARG2, CARG3 - |4: - |.else - if (vk) { - |->BC_ISEQN_Z: // Dummy label. - } else { - |->BC_ISNEN_Z: // Dummy label. - } - | lwzx TMP0, BASE, RA - | addi PC, PC, 4 - | lfdx f0, BASE, RA - | lwz TMP2, -4(PC) - | lfdx f1, KBASE, RD - | decode_RD4 TMP2, TMP2 - | checknum TMP0 - | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) - | bge >3 - | fcmpu cr0, f0, f1 - |.endif - if (vk) { - | bne >1 - | add PC, PC, TMP2 - |1: - |.if not FFI - |3: - |.endif - } else { - | beq >2 - |1: - |.if not FFI - |3: - |.endif - | add PC, PC, TMP2 - |2: - } - | ins_next - |.if FFI - |3: - | cmpwi TMP0, LJ_TCDATA - | beq ->vmeta_equal_cd - | b <1 - |.endif - |.if DUALNUM - |7: // RA is not an integer. - | bge cr0, <3 - | // RA is a number. - | lfd f0, 0(RA) - | blt cr1, >1 - | // RA is a number, RD is an integer. - | tonum_i f1, CARG3 - | b >2 - | - |8: // RA is an integer, RD is a number. - | tonum_i f0, CARG2 - |1: - | lfd f1, 0(RD) - |2: - | fcmpu cr0, f0, f1 - | b <4 - |.endif - break; - - case BC_ISEQP: case BC_ISNEP: - vk = op == BC_ISEQP; - | // RA = src*8, RD = primitive_type*8 (~), JMP with RD = target - | lwzx TMP0, BASE, RA - | srwi TMP1, RD, 3 - | lwz TMP2, 0(PC) - | not TMP1, TMP1 - | addi PC, PC, 4 - |.if FFI - | cmpwi TMP0, LJ_TCDATA - |.endif - | sub TMP0, TMP0, TMP1 - |.if FFI - | beq ->vmeta_equal_cd - |.endif - | decode_RD4 TMP2, TMP2 - | .gpr64 extsw TMP0, TMP0 - | addic TMP0, TMP0, -1 - | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) - | subfe TMP1, TMP1, TMP1 - if (vk) { - | and TMP2, TMP2, TMP1 - } else { - | andc TMP2, TMP2, TMP1 - } - | add PC, PC, TMP2 - | ins_next - break; - - /* -- Unary test and copy ops ------------------------------------------- */ - - case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: - | // RA = dst*8 or unused, RD = src*8, JMP with RD = target - | lwzx TMP0, BASE, RD - | lwz INS, 0(PC) - | addi PC, PC, 4 - if (op == BC_IST || op == BC_ISF) { - | .gpr64 extsw TMP0, TMP0 - | subfic TMP0, TMP0, LJ_TTRUE - | decode_RD4 TMP2, INS - | subfe TMP1, TMP1, TMP1 - | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) - if (op == BC_IST) { - | andc TMP2, TMP2, TMP1 - } else { - | and TMP2, TMP2, TMP1 - } - | add PC, PC, TMP2 - } else { - | li TMP1, LJ_TFALSE - | lfdx f0, BASE, RD - | cmplw TMP0, TMP1 - if (op == BC_ISTC) { - | bge >1 - } else { - | blt >1 - } - | addis PC, PC, -(BCBIAS_J*4 >> 16) - | decode_RD4 TMP2, INS - | stfdx f0, BASE, RA - | add PC, PC, TMP2 - |1: - } - | ins_next - break; - - /* -- Unary ops --------------------------------------------------------- */ - - case BC_MOV: - | // RA = dst*8, RD = src*8 - | ins_next1 - | lfdx f0, BASE, RD - | stfdx f0, BASE, RA - | ins_next2 - break; - case BC_NOT: - | // RA = dst*8, RD = src*8 - | ins_next1 - | lwzx TMP0, BASE, RD - | .gpr64 extsw TMP0, TMP0 - | subfic TMP1, TMP0, LJ_TTRUE - | adde TMP0, TMP0, TMP1 - | stwx TMP0, BASE, RA - | ins_next2 - break; - case BC_UNM: - | // RA = dst*8, RD = src*8 - | lwzux TMP1, RD, BASE - | lwz TMP0, 4(RD) - | checknum TMP1 - |.if DUALNUM - | bne >5 - |.if GPR64 - | lus TMP2, 0x8000 - | neg TMP0, TMP0 - | cmplw TMP0, TMP2 - | beq >4 - |.else - | nego. TMP0, TMP0 - | bso >4 - |1: - |.endif - | ins_next1 - | stwux TISNUM, RA, BASE - | stw TMP0, 4(RA) - |3: - | ins_next2 - |4: - |.if not GPR64 - | // Potential overflow. - | mcrxr cr0; bley <1 // Ignore unrelated overflow. - |.endif - | lus TMP1, 0x41e0 // 2^31. - | li TMP0, 0 - | b >7 - |.endif - |5: - | bge ->vmeta_unm - | xoris TMP1, TMP1, 0x8000 - |7: - | ins_next1 - | stwux TMP1, RA, BASE - | stw TMP0, 4(RA) - |.if DUALNUM - | b <3 - |.else - | ins_next2 - |.endif - break; - case BC_LEN: - | // RA = dst*8, RD = src*8 - | lwzux TMP0, RD, BASE - | lwz CARG1, 4(RD) - | checkstr TMP0; bne >2 - | lwz CRET1, STR:CARG1->len - |1: - |.if DUALNUM - | ins_next1 - | stwux TISNUM, RA, BASE - | stw CRET1, 4(RA) - |.else - | tonum_u f0, CRET1 // Result is a non-negative integer. - | ins_next1 - | stfdx f0, BASE, RA - |.endif - | ins_next2 - |2: - | checktab TMP0; bne ->vmeta_len -#if LJ_52 - | lwz TAB:TMP2, TAB:CARG1->metatable - | cmplwi TAB:TMP2, 0 - | bne >9 - |3: -#endif - |->BC_LEN_Z: - | bl extern lj_tab_len // (GCtab *t) - | // Returns uint32_t (but less than 2^31). - | b <1 -#if LJ_52 - |9: - | lbz TMP0, TAB:TMP2->nomm - | andix. TMP0, TMP0, 1<vmeta_len -#endif - break; - - /* -- Binary ops -------------------------------------------------------- */ - - |.macro ins_arithpre - | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 - ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); - ||switch (vk) { - ||case 0: - | lwzx TMP1, BASE, RB - | .if DUALNUM - | lwzx TMP2, KBASE, RC - | .endif - | lfdx f14, BASE, RB - | lfdx f15, KBASE, RC - | .if DUALNUM - | checknum cr0, TMP1 - | checknum cr1, TMP2 - | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt - | bge ->vmeta_arith_vn - | .else - | checknum TMP1; bge ->vmeta_arith_vn - | .endif - || break; - ||case 1: - | lwzx TMP1, BASE, RB - | .if DUALNUM - | lwzx TMP2, KBASE, RC - | .endif - | lfdx f15, BASE, RB - | lfdx f14, KBASE, RC - | .if DUALNUM - | checknum cr0, TMP1 - | checknum cr1, TMP2 - | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt - | bge ->vmeta_arith_nv - | .else - | checknum TMP1; bge ->vmeta_arith_nv - | .endif - || break; - ||default: - | lwzx TMP1, BASE, RB - | lwzx TMP2, BASE, RC - | lfdx f14, BASE, RB - | lfdx f15, BASE, RC - | checknum cr0, TMP1 - | checknum cr1, TMP2 - | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt - | bge ->vmeta_arith_vv - || break; - ||} - |.endmacro - | - |.macro ins_arithfallback, ins - ||switch (vk) { - ||case 0: - | ins ->vmeta_arith_vn2 - || break; - ||case 1: - | ins ->vmeta_arith_nv2 - || break; - ||default: - | ins ->vmeta_arith_vv2 - || break; - ||} - |.endmacro - | - |.macro intmod, a, b, c - | bl ->vm_modi - |.endmacro - | - |.macro fpmod, a, b, c - |->BC_MODVN_Z: - | fdiv FARG1, b, c - | // NYI: Use internal implementation of floor. - | blex floor // floor(b/c) - | fmul a, FARG1, c - | fsub a, b, a // b - floor(b/c)*c - |.endmacro - | - |.macro ins_arithfp, fpins - | ins_arithpre - |.if "fpins" == "fpmod_" - | b ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. - |.else - | fpins f0, f14, f15 - | ins_next1 - | stfdx f0, BASE, RA - | ins_next2 - |.endif - |.endmacro - | - |.macro ins_arithdn, intins, fpins - | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 - ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); - ||switch (vk) { - ||case 0: - | lwzux TMP1, RB, BASE - | lwzux TMP2, RC, KBASE - | lwz CARG1, 4(RB) - | checknum cr0, TMP1 - | lwz CARG2, 4(RC) - || break; - ||case 1: - | lwzux TMP1, RB, BASE - | lwzux TMP2, RC, KBASE - | lwz CARG2, 4(RB) - | checknum cr0, TMP1 - | lwz CARG1, 4(RC) - || break; - ||default: - | lwzux TMP1, RB, BASE - | lwzux TMP2, RC, BASE - | lwz CARG1, 4(RB) - | checknum cr0, TMP1 - | lwz CARG2, 4(RC) - || break; - ||} - | checknum cr1, TMP2 - | bne >5 - | bne cr1, >5 - | intins CARG1, CARG1, CARG2 - | bso >4 - |1: - | ins_next1 - | stwux TISNUM, RA, BASE - | stw CARG1, 4(RA) - |2: - | ins_next2 - |4: // Overflow. - | mcrxr cr0; bley <1 // Ignore unrelated overflow. - | ins_arithfallback b - |5: // FP variant. - ||if (vk == 1) { - | lfd f15, 0(RB) - | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt - | lfd f14, 0(RC) - ||} else { - | lfd f14, 0(RB) - | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt - | lfd f15, 0(RC) - ||} - | ins_arithfallback bge - |.if "fpins" == "fpmod_" - | b ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. - |.else - | fpins f0, f14, f15 - | ins_next1 - | stfdx f0, BASE, RA - | b <2 - |.endif - |.endmacro - | - |.macro ins_arith, intins, fpins - |.if DUALNUM - | ins_arithdn intins, fpins - |.else - | ins_arithfp fpins - |.endif - |.endmacro - - case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: - |.if GPR64 - |.macro addo32., y, a, b - | // Need to check overflow for (a<<32) + (b<<32). - | rldicr TMP0, a, 32, 31 - | rldicr TMP3, b, 32, 31 - | addo. TMP0, TMP0, TMP3 - | add y, a, b - |.endmacro - | ins_arith addo32., fadd - |.else - | ins_arith addo., fadd - |.endif - break; - case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: - |.if GPR64 - |.macro subo32., y, a, b - | // Need to check overflow for (a<<32) - (b<<32). - | rldicr TMP0, a, 32, 31 - | rldicr TMP3, b, 32, 31 - | subo. TMP0, TMP0, TMP3 - | sub y, a, b - |.endmacro - | ins_arith subo32., fsub - |.else - | ins_arith subo., fsub - |.endif - break; - case BC_MULVN: case BC_MULNV: case BC_MULVV: - | ins_arith mullwo., fmul - break; - case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: - | ins_arithfp fdiv - break; - case BC_MODVN: - | ins_arith intmod, fpmod - break; - case BC_MODNV: case BC_MODVV: - | ins_arith intmod, fpmod_ - break; - case BC_POW: - | // NYI: (partial) integer arithmetic. - | lwzx TMP1, BASE, RB - | lfdx FARG1, BASE, RB - | lwzx TMP2, BASE, RC - | lfdx FARG2, BASE, RC - | checknum cr0, TMP1 - | checknum cr1, TMP2 - | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt - | bge ->vmeta_arith_vv - | blex pow - | ins_next1 - | stfdx FARG1, BASE, RA - | ins_next2 - break; - - case BC_CAT: - | // RA = dst*8, RB = src_start*8, RC = src_end*8 - | sub CARG3, RC, RB - | stp BASE, L->base - | add CARG2, BASE, RC - | mr SAVE0, RB - |->BC_CAT_Z: - | stw PC, SAVE_PC - | mr CARG1, L - | srwi CARG3, CARG3, 3 - | bl extern lj_meta_cat // (lua_State *L, TValue *top, int left) - | // Returns NULL (finished) or TValue * (metamethod). - | cmplwi CRET1, 0 - | lp BASE, L->base - | bne ->vmeta_binop - | ins_next1 - | lfdx f0, BASE, SAVE0 // Copy result from RB to RA. - | stfdx f0, BASE, RA - | ins_next2 - break; - - /* -- Constant ops ------------------------------------------------------ */ - - case BC_KSTR: - | // RA = dst*8, RD = str_const*8 (~) - | srwi TMP1, RD, 1 - | subfic TMP1, TMP1, -4 - | ins_next1 - | lwzx TMP0, KBASE, TMP1 // KBASE-4-str_const*4 - | li TMP2, LJ_TSTR - | stwux TMP2, RA, BASE - | stw TMP0, 4(RA) - | ins_next2 - break; - case BC_KCDATA: - |.if FFI - | // RA = dst*8, RD = cdata_const*8 (~) - | srwi TMP1, RD, 1 - | subfic TMP1, TMP1, -4 - | ins_next1 - | lwzx TMP0, KBASE, TMP1 // KBASE-4-cdata_const*4 - | li TMP2, LJ_TCDATA - | stwux TMP2, RA, BASE - | stw TMP0, 4(RA) - | ins_next2 - |.endif - break; - case BC_KSHORT: - | // RA = dst*8, RD = int16_literal*8 - |.if DUALNUM - | slwi RD, RD, 13 - | srawi RD, RD, 16 - | ins_next1 - | stwux TISNUM, RA, BASE - | stw RD, 4(RA) - | ins_next2 - |.else - | // The soft-float approach is faster. - | slwi RD, RD, 13 - | srawi TMP1, RD, 31 - | xor TMP2, TMP1, RD - | sub TMP2, TMP2, TMP1 // TMP2 = abs(x) - | cntlzw TMP3, TMP2 - | subfic TMP1, TMP3, 0x40d // TMP1 = exponent-1 - | slw TMP2, TMP2, TMP3 // TMP2 = left aligned mantissa - | subfic TMP3, RD, 0 - | slwi TMP1, TMP1, 20 - | rlwimi RD, TMP2, 21, 1, 31 // hi = sign(x) | (mantissa>>11) - | subfe TMP0, TMP0, TMP0 - | add RD, RD, TMP1 // hi = hi + exponent-1 - | and RD, RD, TMP0 // hi = x == 0 ? 0 : hi - | ins_next1 - | stwux RD, RA, BASE - | stw ZERO, 4(RA) - | ins_next2 - |.endif - break; - case BC_KNUM: - | // RA = dst*8, RD = num_const*8 - | ins_next1 - | lfdx f0, KBASE, RD - | stfdx f0, BASE, RA - | ins_next2 - break; - case BC_KPRI: - | // RA = dst*8, RD = primitive_type*8 (~) - | srwi TMP1, RD, 3 - | not TMP0, TMP1 - | ins_next1 - | stwx TMP0, BASE, RA - | ins_next2 - break; - case BC_KNIL: - | // RA = base*8, RD = end*8 - | stwx TISNIL, BASE, RA - | addi RA, RA, 8 - |1: - | stwx TISNIL, BASE, RA - | cmpw RA, RD - | addi RA, RA, 8 - | blt <1 - | ins_next_ - break; - - /* -- Upvalue and function ops ------------------------------------------ */ - - case BC_UGET: - | // RA = dst*8, RD = uvnum*8 - | lwz LFUNC:RB, FRAME_FUNC(BASE) - | srwi RD, RD, 1 - | addi RD, RD, offsetof(GCfuncL, uvptr) - | lwzx UPVAL:RB, LFUNC:RB, RD - | ins_next1 - | lwz TMP1, UPVAL:RB->v - | lfd f0, 0(TMP1) - | stfdx f0, BASE, RA - | ins_next2 - break; - case BC_USETV: - | // RA = uvnum*8, RD = src*8 - | lwz LFUNC:RB, FRAME_FUNC(BASE) - | srwi RA, RA, 1 - | addi RA, RA, offsetof(GCfuncL, uvptr) - | lfdux f0, RD, BASE - | lwzx UPVAL:RB, LFUNC:RB, RA - | lbz TMP3, UPVAL:RB->marked - | lwz CARG2, UPVAL:RB->v - | andix. TMP3, TMP3, LJ_GC_BLACK // isblack(uv) - | lbz TMP0, UPVAL:RB->closed - | lwz TMP2, 0(RD) - | stfd f0, 0(CARG2) - | cmplwi cr1, TMP0, 0 - | lwz TMP1, 4(RD) - | cror 4*cr0+eq, 4*cr0+eq, 4*cr1+eq - | subi TMP2, TMP2, (LJ_TNUMX+1) - | bne >2 // Upvalue is closed and black? - |1: - | ins_next - | - |2: // Check if new value is collectable. - | cmplwi TMP2, LJ_TISGCV - (LJ_TNUMX+1) - | bge <1 // tvisgcv(v) - | lbz TMP3, GCOBJ:TMP1->gch.marked - | andix. TMP3, TMP3, LJ_GC_WHITES // iswhite(v) - | la CARG1, GG_DISP2G(DISPATCH) - | // Crossed a write barrier. Move the barrier forward. - | beq <1 - | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) - | b <1 - break; - case BC_USETS: - | // RA = uvnum*8, RD = str_const*8 (~) - | lwz LFUNC:RB, FRAME_FUNC(BASE) - | srwi TMP1, RD, 1 - | srwi RA, RA, 1 - | subfic TMP1, TMP1, -4 - | addi RA, RA, offsetof(GCfuncL, uvptr) - | lwzx STR:TMP1, KBASE, TMP1 // KBASE-4-str_const*4 - | lwzx UPVAL:RB, LFUNC:RB, RA - | lbz TMP3, UPVAL:RB->marked - | lwz CARG2, UPVAL:RB->v - | andix. TMP3, TMP3, LJ_GC_BLACK // isblack(uv) - | lbz TMP3, STR:TMP1->marked - | lbz TMP2, UPVAL:RB->closed - | li TMP0, LJ_TSTR - | stw STR:TMP1, 4(CARG2) - | stw TMP0, 0(CARG2) - | bne >2 - |1: - | ins_next - | - |2: // Check if string is white and ensure upvalue is closed. - | andix. TMP3, TMP3, LJ_GC_WHITES // iswhite(str) - | cmplwi cr1, TMP2, 0 - | cror 4*cr0+eq, 4*cr0+eq, 4*cr1+eq - | la CARG1, GG_DISP2G(DISPATCH) - | // Crossed a write barrier. Move the barrier forward. - | beq <1 - | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) - | b <1 - break; - case BC_USETN: - | // RA = uvnum*8, RD = num_const*8 - | lwz LFUNC:RB, FRAME_FUNC(BASE) - | srwi RA, RA, 1 - | addi RA, RA, offsetof(GCfuncL, uvptr) - | lfdx f0, KBASE, RD - | lwzx UPVAL:RB, LFUNC:RB, RA - | ins_next1 - | lwz TMP1, UPVAL:RB->v - | stfd f0, 0(TMP1) - | ins_next2 - break; - case BC_USETP: - | // RA = uvnum*8, RD = primitive_type*8 (~) - | lwz LFUNC:RB, FRAME_FUNC(BASE) - | srwi RA, RA, 1 - | srwi TMP0, RD, 3 - | addi RA, RA, offsetof(GCfuncL, uvptr) - | not TMP0, TMP0 - | lwzx UPVAL:RB, LFUNC:RB, RA - | ins_next1 - | lwz TMP1, UPVAL:RB->v - | stw TMP0, 0(TMP1) - | ins_next2 - break; - - case BC_UCLO: - | // RA = level*8, RD = target - | lwz TMP1, L->openupval - | branch_RD // Do this first since RD is not saved. - | stp BASE, L->base - | cmplwi TMP1, 0 - | mr CARG1, L - | beq >1 - | add CARG2, BASE, RA - | bl extern lj_func_closeuv // (lua_State *L, TValue *level) - | lp BASE, L->base - |1: - | ins_next - break; - - case BC_FNEW: - | // RA = dst*8, RD = proto_const*8 (~) (holding function prototype) - | srwi TMP1, RD, 1 - | stp BASE, L->base - | subfic TMP1, TMP1, -4 - | stw PC, SAVE_PC - | lwzx CARG2, KBASE, TMP1 // KBASE-4-tab_const*4 - | mr CARG1, L - | lwz CARG3, FRAME_FUNC(BASE) - | // (lua_State *L, GCproto *pt, GCfuncL *parent) - | bl extern lj_func_newL_gc - | // Returns GCfuncL *. - | lp BASE, L->base - | li TMP0, LJ_TFUNC - | stwux TMP0, RA, BASE - | stw LFUNC:CRET1, 4(RA) - | ins_next - break; - - /* -- Table ops --------------------------------------------------------- */ - - case BC_TNEW: - case BC_TDUP: - | // RA = dst*8, RD = (hbits|asize)*8 | tab_const*8 (~) - | lwz TMP0, DISPATCH_GL(gc.total)(DISPATCH) - | mr CARG1, L - | lwz TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) - | stp BASE, L->base - | cmplw TMP0, TMP1 - | stw PC, SAVE_PC - | bge >5 - |1: - if (op == BC_TNEW) { - | rlwinm CARG2, RD, 29, 21, 31 - | rlwinm CARG3, RD, 18, 27, 31 - | cmpwi CARG2, 0x7ff; beq >3 - |2: - | bl extern lj_tab_new // (lua_State *L, int32_t asize, uint32_t hbits) - | // Returns Table *. - } else { - | srwi TMP1, RD, 1 - | subfic TMP1, TMP1, -4 - | lwzx CARG2, KBASE, TMP1 // KBASE-4-tab_const*4 - | bl extern lj_tab_dup // (lua_State *L, Table *kt) - | // Returns Table *. - } - | lp BASE, L->base - | li TMP0, LJ_TTAB - | stwux TMP0, RA, BASE - | stw TAB:CRET1, 4(RA) - | ins_next - if (op == BC_TNEW) { - |3: - | li CARG2, 0x801 - | b <2 - } - |5: - | mr SAVE0, RD - | bl extern lj_gc_step_fixtop // (lua_State *L) - | mr RD, SAVE0 - | mr CARG1, L - | b <1 - break; - - case BC_GGET: - | // RA = dst*8, RD = str_const*8 (~) - case BC_GSET: - | // RA = src*8, RD = str_const*8 (~) - | lwz LFUNC:TMP2, FRAME_FUNC(BASE) - | srwi TMP1, RD, 1 - | lwz TAB:RB, LFUNC:TMP2->env - | subfic TMP1, TMP1, -4 - | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 - if (op == BC_GGET) { - | b ->BC_TGETS_Z - } else { - | b ->BC_TSETS_Z - } - break; - - case BC_TGETV: - | // RA = dst*8, RB = table*8, RC = key*8 - | lwzux CARG1, RB, BASE - | lwzux CARG2, RC, BASE - | lwz TAB:RB, 4(RB) - |.if DUALNUM - | lwz RC, 4(RC) - |.else - | lfd f0, 0(RC) - |.endif - | checktab CARG1 - | checknum cr1, CARG2 - | bne ->vmeta_tgetv - |.if DUALNUM - | lwz TMP0, TAB:RB->asize - | bne cr1, >5 - | lwz TMP1, TAB:RB->array - | cmplw TMP0, RC - | slwi TMP2, RC, 3 - |.else - | bge cr1, >5 - | // Convert number key to integer, check for integerness and range. - | fctiwz f1, f0 - | fadd f2, f0, TOBIT - | stfd f1, TMPD - | lwz TMP0, TAB:RB->asize - | fsub f2, f2, TOBIT - | lwz TMP2, TMPD_LO - | lwz TMP1, TAB:RB->array - | fcmpu cr1, f0, f2 - | cmplw cr0, TMP0, TMP2 - | crand 4*cr0+gt, 4*cr0+gt, 4*cr1+eq - | slwi TMP2, TMP2, 3 - |.endif - | ble ->vmeta_tgetv // Integer key and in array part? - | lwzx TMP0, TMP1, TMP2 - | lfdx f14, TMP1, TMP2 - | checknil TMP0; beq >2 - |1: - | ins_next1 - | stfdx f14, BASE, RA - | ins_next2 - | - |2: // Check for __index if table value is nil. - | lwz TAB:TMP2, TAB:RB->metatable - | cmplwi TAB:TMP2, 0 - | beq <1 // No metatable: done. - | lbz TMP0, TAB:TMP2->nomm - | andix. TMP0, TMP0, 1<vmeta_tgetv - | - |5: - | checkstr CARG2; bne ->vmeta_tgetv - |.if not DUALNUM - | lwz STR:RC, 4(RC) - |.endif - | b ->BC_TGETS_Z // String key? - break; - case BC_TGETS: - | // RA = dst*8, RB = table*8, RC = str_const*8 (~) - | lwzux CARG1, RB, BASE - | srwi TMP1, RC, 1 - | lwz TAB:RB, 4(RB) - | subfic TMP1, TMP1, -4 - | checktab CARG1 - | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 - | bne ->vmeta_tgets1 - |->BC_TGETS_Z: - | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = dst*8 - | lwz TMP0, TAB:RB->hmask - | lwz TMP1, STR:RC->hash - | lwz NODE:TMP2, TAB:RB->node - | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask - | slwi TMP0, TMP1, 5 - | slwi TMP1, TMP1, 3 - | sub TMP1, TMP0, TMP1 - | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) - |1: - | lwz CARG1, NODE:TMP2->key - | lwz TMP0, 4+offsetof(Node, key)(NODE:TMP2) - | lwz CARG2, NODE:TMP2->val - | lwz TMP1, 4+offsetof(Node, val)(NODE:TMP2) - | checkstr CARG1; bne >4 - | cmpw TMP0, STR:RC; bne >4 - | checknil CARG2; beq >5 // Key found, but nil value? - |3: - | stwux CARG2, RA, BASE - | stw TMP1, 4(RA) - | ins_next - | - |4: // Follow hash chain. - | lwz NODE:TMP2, NODE:TMP2->next - | cmplwi NODE:TMP2, 0 - | bne <1 - | // End of hash chain: key not found, nil result. - | li CARG2, LJ_TNIL - | - |5: // Check for __index if table value is nil. - | lwz TAB:TMP2, TAB:RB->metatable - | cmplwi TAB:TMP2, 0 - | beq <3 // No metatable: done. - | lbz TMP0, TAB:TMP2->nomm - | andix. TMP0, TMP0, 1<vmeta_tgets - break; - case BC_TGETB: - | // RA = dst*8, RB = table*8, RC = index*8 - | lwzux CARG1, RB, BASE - | srwi TMP0, RC, 3 - | lwz TAB:RB, 4(RB) - | checktab CARG1; bne ->vmeta_tgetb - | lwz TMP1, TAB:RB->asize - | lwz TMP2, TAB:RB->array - | cmplw TMP0, TMP1; bge ->vmeta_tgetb - | lwzx TMP1, TMP2, RC - | lfdx f0, TMP2, RC - | checknil TMP1; beq >5 - |1: - | ins_next1 - | stfdx f0, BASE, RA - | ins_next2 - | - |5: // Check for __index if table value is nil. - | lwz TAB:TMP2, TAB:RB->metatable - | cmplwi TAB:TMP2, 0 - | beq <1 // No metatable: done. - | lbz TMP2, TAB:TMP2->nomm - | andix. TMP2, TMP2, 1<vmeta_tgetb // Caveat: preserve TMP0! - break; - - case BC_TSETV: - | // RA = src*8, RB = table*8, RC = key*8 - | lwzux CARG1, RB, BASE - | lwzux CARG2, RC, BASE - | lwz TAB:RB, 4(RB) - |.if DUALNUM - | lwz RC, 4(RC) - |.else - | lfd f0, 0(RC) - |.endif - | checktab CARG1 - | checknum cr1, CARG2 - | bne ->vmeta_tsetv - |.if DUALNUM - | lwz TMP0, TAB:RB->asize - | bne cr1, >5 - | lwz TMP1, TAB:RB->array - | cmplw TMP0, RC - | slwi TMP0, RC, 3 - |.else - | bge cr1, >5 - | // Convert number key to integer, check for integerness and range. - | fctiwz f1, f0 - | fadd f2, f0, TOBIT - | stfd f1, TMPD - | lwz TMP0, TAB:RB->asize - | fsub f2, f2, TOBIT - | lwz TMP2, TMPD_LO - | lwz TMP1, TAB:RB->array - | fcmpu cr1, f0, f2 - | cmplw cr0, TMP0, TMP2 - | crand 4*cr0+gt, 4*cr0+gt, 4*cr1+eq - | slwi TMP0, TMP2, 3 - |.endif - | ble ->vmeta_tsetv // Integer key and in array part? - | lwzx TMP2, TMP1, TMP0 - | lbz TMP3, TAB:RB->marked - | lfdx f14, BASE, RA - | checknil TMP2; beq >3 - |1: - | andix. TMP2, TMP3, LJ_GC_BLACK // isblack(table) - | stfdx f14, TMP1, TMP0 - | bne >7 - |2: - | ins_next - | - |3: // Check for __newindex if previous value is nil. - | lwz TAB:TMP2, TAB:RB->metatable - | cmplwi TAB:TMP2, 0 - | beq <1 // No metatable: done. - | lbz TMP2, TAB:TMP2->nomm - | andix. TMP2, TMP2, 1<vmeta_tsetv - | - |5: - | checkstr CARG2; bne ->vmeta_tsetv - |.if not DUALNUM - | lwz STR:RC, 4(RC) - |.endif - | b ->BC_TSETS_Z // String key? - | - |7: // Possible table write barrier for the value. Skip valiswhite check. - | barrierback TAB:RB, TMP3, TMP0 - | b <2 - break; - case BC_TSETS: - | // RA = src*8, RB = table*8, RC = str_const*8 (~) - | lwzux CARG1, RB, BASE - | srwi TMP1, RC, 1 - | lwz TAB:RB, 4(RB) - | subfic TMP1, TMP1, -4 - | checktab CARG1 - | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 - | bne ->vmeta_tsets1 - |->BC_TSETS_Z: - | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = src*8 - | lwz TMP0, TAB:RB->hmask - | lwz TMP1, STR:RC->hash - | lwz NODE:TMP2, TAB:RB->node - | stb ZERO, TAB:RB->nomm // Clear metamethod cache. - | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask - | lfdx f14, BASE, RA - | slwi TMP0, TMP1, 5 - | slwi TMP1, TMP1, 3 - | sub TMP1, TMP0, TMP1 - | lbz TMP3, TAB:RB->marked - | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) - |1: - | lwz CARG1, NODE:TMP2->key - | lwz TMP0, 4+offsetof(Node, key)(NODE:TMP2) - | lwz CARG2, NODE:TMP2->val - | lwz NODE:TMP1, NODE:TMP2->next - | checkstr CARG1; bne >5 - | cmpw TMP0, STR:RC; bne >5 - | checknil CARG2; beq >4 // Key found, but nil value? - |2: - | andix. TMP0, TMP3, LJ_GC_BLACK // isblack(table) - | stfd f14, NODE:TMP2->val - | bne >7 - |3: - | ins_next - | - |4: // Check for __newindex if previous value is nil. - | lwz TAB:TMP1, TAB:RB->metatable - | cmplwi TAB:TMP1, 0 - | beq <2 // No metatable: done. - | lbz TMP0, TAB:TMP1->nomm - | andix. TMP0, TMP0, 1<vmeta_tsets - | - |5: // Follow hash chain. - | cmplwi NODE:TMP1, 0 - | mr NODE:TMP2, NODE:TMP1 - | bne <1 - | // End of hash chain: key not found, add a new one. - | - | // But check for __newindex first. - | lwz TAB:TMP1, TAB:RB->metatable - | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) - | stw PC, SAVE_PC - | mr CARG1, L - | cmplwi TAB:TMP1, 0 - | stp BASE, L->base - | beq >6 // No metatable: continue. - | lbz TMP0, TAB:TMP1->nomm - | andix. TMP0, TMP0, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. - |6: - | li TMP0, LJ_TSTR - | stw STR:RC, 4(CARG3) - | mr CARG2, TAB:RB - | stw TMP0, 0(CARG3) - | bl extern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k) - | // Returns TValue *. - | lp BASE, L->base - | stfd f14, 0(CRET1) - | b <3 // No 2nd write barrier needed. - | - |7: // Possible table write barrier for the value. Skip valiswhite check. - | barrierback TAB:RB, TMP3, TMP0 - | b <3 - break; - case BC_TSETB: - | // RA = src*8, RB = table*8, RC = index*8 - | lwzux CARG1, RB, BASE - | srwi TMP0, RC, 3 - | lwz TAB:RB, 4(RB) - | checktab CARG1; bne ->vmeta_tsetb - | lwz TMP1, TAB:RB->asize - | lwz TMP2, TAB:RB->array - | lbz TMP3, TAB:RB->marked - | cmplw TMP0, TMP1 - | lfdx f14, BASE, RA - | bge ->vmeta_tsetb - | lwzx TMP1, TMP2, RC - | checknil TMP1; beq >5 - |1: - | andix. TMP0, TMP3, LJ_GC_BLACK // isblack(table) - | stfdx f14, TMP2, RC - | bne >7 - |2: - | ins_next - | - |5: // Check for __newindex if previous value is nil. - | lwz TAB:TMP1, TAB:RB->metatable - | cmplwi TAB:TMP1, 0 - | beq <1 // No metatable: done. - | lbz TMP1, TAB:TMP1->nomm - | andix. TMP1, TMP1, 1<vmeta_tsetb // Caveat: preserve TMP0! - | - |7: // Possible table write barrier for the value. Skip valiswhite check. - | barrierback TAB:RB, TMP3, TMP0 - | b <2 - break; - - case BC_TSETM: - | // RA = base*8 (table at base-1), RD = num_const*8 (start index) - | add RA, BASE, RA - |1: - | add TMP3, KBASE, RD - | lwz TAB:CARG2, -4(RA) // Guaranteed to be a table. - | addic. TMP0, MULTRES, -8 - | lwz TMP3, 4(TMP3) // Integer constant is in lo-word. - | srwi CARG3, TMP0, 3 - | beq >4 // Nothing to copy? - | add CARG3, CARG3, TMP3 - | lwz TMP2, TAB:CARG2->asize - | slwi TMP1, TMP3, 3 - | lbz TMP3, TAB:CARG2->marked - | cmplw CARG3, TMP2 - | add TMP2, RA, TMP0 - | lwz TMP0, TAB:CARG2->array - | bgt >5 - | add TMP1, TMP1, TMP0 - | andix. TMP0, TMP3, LJ_GC_BLACK // isblack(table) - |3: // Copy result slots to table. - | lfd f0, 0(RA) - | addi RA, RA, 8 - | cmpw cr1, RA, TMP2 - | stfd f0, 0(TMP1) - | addi TMP1, TMP1, 8 - | blt cr1, <3 - | bne >7 - |4: - | ins_next - | - |5: // Need to resize array part. - | stp BASE, L->base - | mr CARG1, L - | stw PC, SAVE_PC - | mr SAVE0, RD - | bl extern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) - | // Must not reallocate the stack. - | mr RD, SAVE0 - | b <1 - | - |7: // Possible table write barrier for any value. Skip valiswhite check. - | barrierback TAB:CARG2, TMP3, TMP0 - | b <4 - break; - - /* -- Calls and vararg handling ----------------------------------------- */ - - case BC_CALLM: - | // RA = base*8, (RB = (nresults+1)*8,) RC = extra_nargs*8 - | add NARGS8:RC, NARGS8:RC, MULTRES - | // Fall through. Assumes BC_CALL follows. - break; - case BC_CALL: - | // RA = base*8, (RB = (nresults+1)*8,) RC = (nargs+1)*8 - | mr TMP2, BASE - | lwzux TMP0, BASE, RA - | lwz LFUNC:RB, 4(BASE) - | subi NARGS8:RC, NARGS8:RC, 8 - | addi BASE, BASE, 8 - | checkfunc TMP0; bne ->vmeta_call - | ins_call - break; - - case BC_CALLMT: - | // RA = base*8, (RB = 0,) RC = extra_nargs*8 - | add NARGS8:RC, NARGS8:RC, MULTRES - | // Fall through. Assumes BC_CALLT follows. - break; - case BC_CALLT: - | // RA = base*8, (RB = 0,) RC = (nargs+1)*8 - | lwzux TMP0, RA, BASE - | lwz LFUNC:RB, 4(RA) - | subi NARGS8:RC, NARGS8:RC, 8 - | lwz TMP1, FRAME_PC(BASE) - | checkfunc TMP0 - | addi RA, RA, 8 - | bne ->vmeta_callt - |->BC_CALLT_Z: - | andix. TMP0, TMP1, FRAME_TYPE // Caveat: preserve cr0 until the crand. - | lbz TMP3, LFUNC:RB->ffid - | xori TMP2, TMP1, FRAME_VARG - | cmplwi cr1, NARGS8:RC, 0 - | bne >7 - |1: - | stw LFUNC:RB, FRAME_FUNC(BASE) // Copy function down, but keep PC. - | li TMP2, 0 - | cmplwi cr7, TMP3, 1 // (> FF_C) Calling a fast function? - | beq cr1, >3 - |2: - | addi TMP3, TMP2, 8 - | lfdx f0, RA, TMP2 - | cmplw cr1, TMP3, NARGS8:RC - | stfdx f0, BASE, TMP2 - | mr TMP2, TMP3 - | bne cr1, <2 - |3: - | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+gt - | beq >5 - |4: - | ins_callt - | - |5: // Tailcall to a fast function with a Lua frame below. - | lwz INS, -4(TMP1) - | decode_RA8 RA, INS - | sub TMP1, BASE, RA - | lwz LFUNC:TMP1, FRAME_FUNC-8(TMP1) - | lwz TMP1, LFUNC:TMP1->pc - | lwz KBASE, PC2PROTO(k)(TMP1) // Need to prepare KBASE. - | b <4 - | - |7: // Tailcall from a vararg function. - | andix. TMP0, TMP2, FRAME_TYPEP - | bne <1 // Vararg frame below? - | sub BASE, BASE, TMP2 // Relocate BASE down. - | lwz TMP1, FRAME_PC(BASE) - | andix. TMP0, TMP1, FRAME_TYPE - | b <1 - break; - - case BC_ITERC: - | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 ((2+1)*8)) - | mr TMP2, BASE - | add BASE, BASE, RA - | lwz TMP1, -24(BASE) - | lwz LFUNC:RB, -20(BASE) - | lfd f1, -8(BASE) - | lfd f0, -16(BASE) - | stw TMP1, 0(BASE) // Copy callable. - | stw LFUNC:RB, 4(BASE) - | checkfunc TMP1 - | stfd f1, 16(BASE) // Copy control var. - | li NARGS8:RC, 16 // Iterators get 2 arguments. - | stfdu f0, 8(BASE) // Copy state. - | bne ->vmeta_call - | ins_call - break; - - case BC_ITERN: - | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 (2+1)*8) - |.if JIT - | // NYI: add hotloop, record BC_ITERN. - |.endif - | add RA, BASE, RA - | lwz TAB:RB, -12(RA) - | lwz RC, -4(RA) // Get index from control var. - | lwz TMP0, TAB:RB->asize - | lwz TMP1, TAB:RB->array - | addi PC, PC, 4 - |1: // Traverse array part. - | cmplw RC, TMP0 - | slwi TMP3, RC, 3 - | bge >5 // Index points after array part? - | lwzx TMP2, TMP1, TMP3 - | lfdx f0, TMP1, TMP3 - | checknil TMP2 - | lwz INS, -4(PC) - | beq >4 - |.if DUALNUM - | stw RC, 4(RA) - | stw TISNUM, 0(RA) - |.else - | tonum_u f1, RC - |.endif - | addi RC, RC, 1 - | addis TMP3, PC, -(BCBIAS_J*4 >> 16) - | stfd f0, 8(RA) - | decode_RD4 TMP1, INS - | stw RC, -4(RA) // Update control var. - | add PC, TMP1, TMP3 - |.if not DUALNUM - | stfd f1, 0(RA) - |.endif - |3: - | ins_next - | - |4: // Skip holes in array part. - | addi RC, RC, 1 - | b <1 - | - |5: // Traverse hash part. - | lwz TMP1, TAB:RB->hmask - | sub RC, RC, TMP0 - | lwz TMP2, TAB:RB->node - |6: - | cmplw RC, TMP1 // End of iteration? Branch to ITERL+1. - | slwi TMP3, RC, 5 - | bgty <3 - | slwi RB, RC, 3 - | sub TMP3, TMP3, RB - | lwzx RB, TMP2, TMP3 - | lfdx f0, TMP2, TMP3 - | add NODE:TMP3, TMP2, TMP3 - | checknil RB - | lwz INS, -4(PC) - | beq >7 - | lfd f1, NODE:TMP3->key - | addis TMP2, PC, -(BCBIAS_J*4 >> 16) - | stfd f0, 8(RA) - | add RC, RC, TMP0 - | decode_RD4 TMP1, INS - | stfd f1, 0(RA) - | addi RC, RC, 1 - | add PC, TMP1, TMP2 - | stw RC, -4(RA) // Update control var. - | b <3 - | - |7: // Skip holes in hash part. - | addi RC, RC, 1 - | b <6 - break; - - case BC_ISNEXT: - | // RA = base*8, RD = target (points to ITERN) - | add RA, BASE, RA - | lwz TMP0, -24(RA) - | lwz CFUNC:TMP1, -20(RA) - | lwz TMP2, -16(RA) - | lwz TMP3, -8(RA) - | cmpwi cr0, TMP2, LJ_TTAB - | cmpwi cr1, TMP0, LJ_TFUNC - | cmpwi cr6, TMP3, LJ_TNIL - | bne cr1, >5 - | lbz TMP1, CFUNC:TMP1->ffid - | crand 4*cr0+eq, 4*cr0+eq, 4*cr6+eq - | cmpwi cr7, TMP1, FF_next_N - | srwi TMP0, RD, 1 - | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+eq - | add TMP3, PC, TMP0 - | bne cr0, >5 - | lus TMP1, 0xfffe - | ori TMP1, TMP1, 0x7fff - | stw ZERO, -4(RA) // Initialize control var. - | stw TMP1, -8(RA) - | addis PC, TMP3, -(BCBIAS_J*4 >> 16) - |1: - | ins_next - |5: // Despecialize bytecode if any of the checks fail. - | li TMP0, BC_JMP - | li TMP1, BC_ITERC - | stb TMP0, -1(PC) - | addis PC, TMP3, -(BCBIAS_J*4 >> 16) - | stb TMP1, 3(PC) - | b <1 - break; - - case BC_VARG: - | // RA = base*8, RB = (nresults+1)*8, RC = numparams*8 - | lwz TMP0, FRAME_PC(BASE) - | add RC, BASE, RC - | add RA, BASE, RA - | addi RC, RC, FRAME_VARG - | add TMP2, RA, RB - | subi TMP3, BASE, 8 // TMP3 = vtop - | sub RC, RC, TMP0 // RC = vbase - | // Note: RC may now be even _above_ BASE if nargs was < numparams. - | cmplwi cr1, RB, 0 - |.if PPE - | sub TMP1, TMP3, RC - | cmpwi TMP1, 0 - |.else - | sub. TMP1, TMP3, RC - |.endif - | beq cr1, >5 // Copy all varargs? - | subi TMP2, TMP2, 16 - | ble >2 // No vararg slots? - |1: // Copy vararg slots to destination slots. - | lfd f0, 0(RC) - | addi RC, RC, 8 - | stfd f0, 0(RA) - | cmplw RA, TMP2 - | cmplw cr1, RC, TMP3 - | bge >3 // All destination slots filled? - | addi RA, RA, 8 - | blt cr1, <1 // More vararg slots? - |2: // Fill up remainder with nil. - | stw TISNIL, 0(RA) - | cmplw RA, TMP2 - | addi RA, RA, 8 - | blt <2 - |3: - | ins_next - | - |5: // Copy all varargs. - | lwz TMP0, L->maxstack - | li MULTRES, 8 // MULTRES = (0+1)*8 - | bley <3 // No vararg slots? - | add TMP2, RA, TMP1 - | cmplw TMP2, TMP0 - | addi MULTRES, TMP1, 8 - | bgt >7 - |6: - | lfd f0, 0(RC) - | addi RC, RC, 8 - | stfd f0, 0(RA) - | cmplw RC, TMP3 - | addi RA, RA, 8 - | blt <6 // More vararg slots? - | b <3 - | - |7: // Grow stack for varargs. - | mr CARG1, L - | stp RA, L->top - | sub SAVE0, RC, BASE // Need delta, because BASE may change. - | stp BASE, L->base - | sub RA, RA, BASE - | stw PC, SAVE_PC - | srwi CARG2, TMP1, 3 - | bl extern lj_state_growstack // (lua_State *L, int n) - | lp BASE, L->base - | add RA, BASE, RA - | add RC, BASE, SAVE0 - | subi TMP3, BASE, 8 - | b <6 - break; - - /* -- Returns ----------------------------------------------------------- */ - - case BC_RETM: - | // RA = results*8, RD = extra_nresults*8 - | add RD, RD, MULTRES // MULTRES >= 8, so RD >= 8. - | // Fall through. Assumes BC_RET follows. - break; - - case BC_RET: - | // RA = results*8, RD = (nresults+1)*8 - | lwz PC, FRAME_PC(BASE) - | add RA, BASE, RA - | mr MULTRES, RD - |1: - | andix. TMP0, PC, FRAME_TYPE - | xori TMP1, PC, FRAME_VARG - | bne ->BC_RETV_Z - | - |->BC_RET_Z: - | // BASE = base, RA = resultptr, RD = (nresults+1)*8, PC = return - | lwz INS, -4(PC) - | cmpwi RD, 8 - | subi TMP2, BASE, 8 - | subi RC, RD, 8 - | decode_RB8 RB, INS - | beq >3 - | li TMP1, 0 - |2: - | addi TMP3, TMP1, 8 - | lfdx f0, RA, TMP1 - | cmpw TMP3, RC - | stfdx f0, TMP2, TMP1 - | beq >3 - | addi TMP1, TMP3, 8 - | lfdx f1, RA, TMP3 - | cmpw TMP1, RC - | stfdx f1, TMP2, TMP3 - | bne <2 - |3: - |5: - | cmplw RB, RD - | decode_RA8 RA, INS - | bgt >6 - | sub BASE, TMP2, RA - | lwz LFUNC:TMP1, FRAME_FUNC(BASE) - | ins_next1 - | lwz TMP1, LFUNC:TMP1->pc - | lwz KBASE, PC2PROTO(k)(TMP1) - | ins_next2 - | - |6: // Fill up results with nil. - | subi TMP1, RD, 8 - | addi RD, RD, 8 - | stwx TISNIL, TMP2, TMP1 - | b <5 - | - |->BC_RETV_Z: // Non-standard return case. - | andix. TMP2, TMP1, FRAME_TYPEP - | bne ->vm_return - | // Return from vararg function: relocate BASE down. - | sub BASE, BASE, TMP1 - | lwz PC, FRAME_PC(BASE) - | b <1 - break; - - case BC_RET0: case BC_RET1: - | // RA = results*8, RD = (nresults+1)*8 - | lwz PC, FRAME_PC(BASE) - | add RA, BASE, RA - | mr MULTRES, RD - | andix. TMP0, PC, FRAME_TYPE - | xori TMP1, PC, FRAME_VARG - | bney ->BC_RETV_Z - | - | lwz INS, -4(PC) - | subi TMP2, BASE, 8 - | decode_RB8 RB, INS - if (op == BC_RET1) { - | lfd f0, 0(RA) - | stfd f0, 0(TMP2) - } - |5: - | cmplw RB, RD - | decode_RA8 RA, INS - | bgt >6 - | sub BASE, TMP2, RA - | lwz LFUNC:TMP1, FRAME_FUNC(BASE) - | ins_next1 - | lwz TMP1, LFUNC:TMP1->pc - | lwz KBASE, PC2PROTO(k)(TMP1) - | ins_next2 - | - |6: // Fill up results with nil. - | subi TMP1, RD, 8 - | addi RD, RD, 8 - | stwx TISNIL, TMP2, TMP1 - | b <5 - break; - - /* -- Loops and branches ------------------------------------------------ */ - - case BC_FORL: - |.if JIT - | hotloop - |.endif - | // Fall through. Assumes BC_IFORL follows. - break; - - case BC_JFORI: - case BC_JFORL: -#if !LJ_HASJIT - break; -#endif - case BC_FORI: - case BC_IFORL: - | // RA = base*8, RD = target (after end of loop or start of loop) - vk = (op == BC_IFORL || op == BC_JFORL); - |.if DUALNUM - | // Integer loop. - | lwzux TMP1, RA, BASE - | lwz CARG1, FORL_IDX*8+4(RA) - | cmplw cr0, TMP1, TISNUM - if (vk) { - | lwz CARG3, FORL_STEP*8+4(RA) - | bne >9 - |.if GPR64 - | // Need to check overflow for (a<<32) + (b<<32). - | rldicr TMP0, CARG1, 32, 31 - | rldicr TMP2, CARG3, 32, 31 - | add CARG1, CARG1, CARG3 - | addo. TMP0, TMP0, TMP2 - |.else - | addo. CARG1, CARG1, CARG3 - |.endif - | cmpwi cr6, CARG3, 0 - | lwz CARG2, FORL_STOP*8+4(RA) - | bso >6 - |4: - | stw CARG1, FORL_IDX*8+4(RA) - } else { - | lwz TMP3, FORL_STEP*8(RA) - | lwz CARG3, FORL_STEP*8+4(RA) - | lwz TMP2, FORL_STOP*8(RA) - | lwz CARG2, FORL_STOP*8+4(RA) - | cmplw cr7, TMP3, TISNUM - | cmplw cr1, TMP2, TISNUM - | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+eq - | crand 4*cr0+eq, 4*cr0+eq, 4*cr1+eq - | cmpwi cr6, CARG3, 0 - | bne >9 - } - | blt cr6, >5 - | cmpw CARG1, CARG2 - |1: - | stw TISNUM, FORL_EXT*8(RA) - if (op != BC_JFORL) { - | srwi RD, RD, 1 - } - | stw CARG1, FORL_EXT*8+4(RA) - if (op != BC_JFORL) { - | add RD, PC, RD - } - if (op == BC_FORI) { - | bgt >3 // See FP loop below. - } else if (op == BC_JFORI) { - | addis PC, RD, -(BCBIAS_J*4 >> 16) - | bley >7 - } else if (op == BC_IFORL) { - | bgt >2 - | addis PC, RD, -(BCBIAS_J*4 >> 16) - } else { - | bley =>BC_JLOOP - } - |2: - | ins_next - |5: // Invert check for negative step. - | cmpw CARG2, CARG1 - | b <1 - if (vk) { - |6: // Potential overflow. - | mcrxr cr0; bley <4 // Ignore unrelated overflow. - | b <2 - } - |.endif - if (vk) { - |.if DUALNUM - |9: // FP loop. - | lfd f1, FORL_IDX*8(RA) - |.else - | lfdux f1, RA, BASE - |.endif - | lfd f3, FORL_STEP*8(RA) - | lfd f2, FORL_STOP*8(RA) - | lwz TMP3, FORL_STEP*8(RA) - | fadd f1, f1, f3 - | stfd f1, FORL_IDX*8(RA) - } else { - |.if DUALNUM - |9: // FP loop. - |.else - | lwzux TMP1, RA, BASE - | lwz TMP3, FORL_STEP*8(RA) - | lwz TMP2, FORL_STOP*8(RA) - | cmplw cr0, TMP1, TISNUM - | cmplw cr7, TMP3, TISNUM - | cmplw cr1, TMP2, TISNUM - |.endif - | lfd f1, FORL_IDX*8(RA) - | crand 4*cr0+lt, 4*cr0+lt, 4*cr7+lt - | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt - | lfd f2, FORL_STOP*8(RA) - | bge ->vmeta_for - } - | cmpwi cr6, TMP3, 0 - if (op != BC_JFORL) { - | srwi RD, RD, 1 - } - | stfd f1, FORL_EXT*8(RA) - if (op != BC_JFORL) { - | add RD, PC, RD - } - | fcmpu cr0, f1, f2 - if (op == BC_JFORI) { - | addis PC, RD, -(BCBIAS_J*4 >> 16) - } - | blt cr6, >5 - if (op == BC_FORI) { - | bgt >3 - } else if (op == BC_IFORL) { - |.if DUALNUM - | bgty <2 - |.else - | bgt >2 - |.endif - |1: - | addis PC, RD, -(BCBIAS_J*4 >> 16) - } else if (op == BC_JFORI) { - | bley >7 - } else { - | bley =>BC_JLOOP - } - |.if DUALNUM - | b <2 - |.else - |2: - | ins_next - |.endif - |5: // Negative step. - if (op == BC_FORI) { - | bge <2 - |3: // Used by integer loop, too. - | addis PC, RD, -(BCBIAS_J*4 >> 16) - } else if (op == BC_IFORL) { - | bgey <1 - } else if (op == BC_JFORI) { - | bgey >7 - } else { - | bgey =>BC_JLOOP - } - | b <2 - if (op == BC_JFORI) { - |7: - | lwz INS, -4(PC) - | decode_RD8 RD, INS - | b =>BC_JLOOP - } - break; - - case BC_ITERL: - |.if JIT - | hotloop - |.endif - | // Fall through. Assumes BC_IITERL follows. - break; - - case BC_JITERL: -#if !LJ_HASJIT - break; -#endif - case BC_IITERL: - | // RA = base*8, RD = target - | lwzux TMP1, RA, BASE - | lwz TMP2, 4(RA) - | checknil TMP1; beq >1 // Stop if iterator returned nil. - if (op == BC_JITERL) { - | stw TMP1, -8(RA) - | stw TMP2, -4(RA) - | b =>BC_JLOOP - } else { - | branch_RD // Otherwise save control var + branch. - | stw TMP1, -8(RA) - | stw TMP2, -4(RA) - } - |1: - | ins_next - break; - - case BC_LOOP: - | // RA = base*8, RD = target (loop extent) - | // Note: RA/RD is only used by trace recorder to determine scope/extent - | // This opcode does NOT jump, it's only purpose is to detect a hot loop. - |.if JIT - | hotloop - |.endif - | // Fall through. Assumes BC_ILOOP follows. - break; - - case BC_ILOOP: - | // RA = base*8, RD = target (loop extent) - | ins_next - break; - - case BC_JLOOP: - |.if JIT - | // RA = base*8 (ignored), RD = traceno*8 - | lwz TMP1, DISPATCH_J(trace)(DISPATCH) - | srwi RD, RD, 1 - | // Traces on PPC don't store the trace number, so use 0. - | stw ZERO, DISPATCH_GL(vmstate)(DISPATCH) - | lwzx TRACE:TMP2, TMP1, RD - | mcrxr cr0 // Clear SO flag. - | lp TMP2, TRACE:TMP2->mcode - | stw BASE, DISPATCH_GL(jit_base)(DISPATCH) - | mtctr TMP2 - | stw L, DISPATCH_GL(jit_L)(DISPATCH) - | addi JGL, DISPATCH, GG_DISP2G+32768 - | bctr - |.endif - break; - - case BC_JMP: - | // RA = base*8 (only used by trace recorder), RD = target - | branch_RD - | ins_next - break; - - /* -- Function headers -------------------------------------------------- */ - - case BC_FUNCF: - |.if JIT - | hotcall - |.endif - case BC_FUNCV: /* NYI: compiled vararg functions. */ - | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow. - break; - - case BC_JFUNCF: -#if !LJ_HASJIT - break; -#endif - case BC_IFUNCF: - | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 - | lwz TMP2, L->maxstack - | lbz TMP1, -4+PC2PROTO(numparams)(PC) - | lwz KBASE, -4+PC2PROTO(k)(PC) - | cmplw RA, TMP2 - | slwi TMP1, TMP1, 3 - | bgt ->vm_growstack_l - if (op != BC_JFUNCF) { - | ins_next1 - } - |2: - | cmplw NARGS8:RC, TMP1 // Check for missing parameters. - | blt >3 - if (op == BC_JFUNCF) { - | decode_RD8 RD, INS - | b =>BC_JLOOP - } else { - | ins_next2 - } - | - |3: // Clear missing parameters. - | stwx TISNIL, BASE, NARGS8:RC - | addi NARGS8:RC, NARGS8:RC, 8 - | b <2 - break; - - case BC_JFUNCV: -#if !LJ_HASJIT - break; -#endif - | NYI // NYI: compiled vararg functions - break; /* NYI: compiled vararg functions. */ - - case BC_IFUNCV: - | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 - | lwz TMP2, L->maxstack - | add TMP1, BASE, RC - | add TMP0, RA, RC - | stw LFUNC:RB, 4(TMP1) // Store copy of LFUNC. - | addi TMP3, RC, 8+FRAME_VARG - | lwz KBASE, -4+PC2PROTO(k)(PC) - | cmplw TMP0, TMP2 - | stw TMP3, 0(TMP1) // Store delta + FRAME_VARG. - | bge ->vm_growstack_l - | lbz TMP2, -4+PC2PROTO(numparams)(PC) - | mr RA, BASE - | mr RC, TMP1 - | ins_next1 - | cmpwi TMP2, 0 - | addi BASE, TMP1, 8 - | beq >3 - |1: - | cmplw RA, RC // Less args than parameters? - | lwz TMP0, 0(RA) - | lwz TMP3, 4(RA) - | bge >4 - | stw TISNIL, 0(RA) // Clear old fixarg slot (help the GC). - | addi RA, RA, 8 - |2: - | addic. TMP2, TMP2, -1 - | stw TMP0, 8(TMP1) - | stw TMP3, 12(TMP1) - | addi TMP1, TMP1, 8 - | bne <1 - |3: - | ins_next2 - | - |4: // Clear missing parameters. - | li TMP0, LJ_TNIL - | b <2 - break; - - case BC_FUNCC: - case BC_FUNCCW: - | // BASE = new base, RA = BASE+framesize*8, RB = CFUNC, RC = nargs*8 - if (op == BC_FUNCC) { - | lp RD, CFUNC:RB->f - } else { - | lp RD, DISPATCH_GL(wrapf)(DISPATCH) - } - | add TMP1, RA, NARGS8:RC - | lwz TMP2, L->maxstack - | .toc lp TMP3, 0(RD) - | add RC, BASE, NARGS8:RC - | stp BASE, L->base - | cmplw TMP1, TMP2 - | stp RC, L->top - | li_vmstate C - |.if TOC - | mtctr TMP3 - |.else - | mtctr RD - |.endif - if (op == BC_FUNCCW) { - | lp CARG2, CFUNC:RB->f - } - | mr CARG1, L - | bgt ->vm_growstack_c // Need to grow stack. - | .toc lp TOCREG, TOC_OFS(RD) - | .tocenv lp ENVREG, ENV_OFS(RD) - | st_vmstate - | bctrl // (lua_State *L [, lua_CFunction f]) - | // Returns nresults. - | lp BASE, L->base - | .toc ld TOCREG, SAVE_TOC - | slwi RD, CRET1, 3 - | lp TMP1, L->top - | li_vmstate INTERP - | lwz PC, FRAME_PC(BASE) // Fetch PC of caller. - | sub RA, TMP1, RD // RA = L->top - nresults*8 - | st_vmstate - | b ->vm_returnc - break; - - /* ---------------------------------------------------------------------- */ - - default: - fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); - exit(2); - break; - } -} - -static int build_backend(BuildCtx *ctx) -{ - int op; - - dasm_growpc(Dst, BC__MAX); - - build_subroutines(ctx); - - |.code_op - for (op = 0; op < BC__MAX; op++) - build_ins(ctx, (BCOp)op, op); - - return BC__MAX; -} - -/* Emit pseudo frame-info for all assembler functions. */ -static void emit_asm_debug(BuildCtx *ctx) -{ - int fcofs = (int)((uint8_t *)ctx->glob[GLOB_vm_ffi_call] - ctx->code); - int i; - switch (ctx->mode) { - case BUILD_elfasm: - fprintf(ctx->fp, "\t.section .debug_frame,\"\",@progbits\n"); - fprintf(ctx->fp, - ".Lframe0:\n" - "\t.long .LECIE0-.LSCIE0\n" - ".LSCIE0:\n" - "\t.long 0xffffffff\n" - "\t.byte 0x1\n" - "\t.string \"\"\n" - "\t.uleb128 0x1\n" - "\t.sleb128 -4\n" - "\t.byte 65\n" - "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" - "\t.align 2\n" - ".LECIE0:\n\n"); - fprintf(ctx->fp, - ".LSFDE0:\n" - "\t.long .LEFDE0-.LASFDE0\n" - ".LASFDE0:\n" - "\t.long .Lframe0\n" - "\t.long .Lbegin\n" - "\t.long %d\n" - "\t.byte 0xe\n\t.uleb128 %d\n" - "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" - "\t.byte 0x5\n\t.uleb128 70\n\t.uleb128 55\n", - fcofs, CFRAME_SIZE); - for (i = 14; i <= 31; i++) - fprintf(ctx->fp, - "\t.byte %d\n\t.uleb128 %d\n" - "\t.byte %d\n\t.uleb128 %d\n", - 0x80+i, 37+(31-i), 0x80+32+i, 2+2*(31-i)); - fprintf(ctx->fp, - "\t.align 2\n" - ".LEFDE0:\n\n"); -#if LJ_HASFFI - fprintf(ctx->fp, - ".LSFDE1:\n" - "\t.long .LEFDE1-.LASFDE1\n" - ".LASFDE1:\n" - "\t.long .Lframe0\n" -#if LJ_TARGET_PS3 - "\t.long .lj_vm_ffi_call\n" -#else - "\t.long lj_vm_ffi_call\n" -#endif - "\t.long %d\n" - "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" - "\t.byte 0x8e\n\t.uleb128 2\n" - "\t.byte 0xd\n\t.uleb128 0xe\n" - "\t.align 2\n" - ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); -#endif -#if !LJ_NO_UNWIND - fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n"); - fprintf(ctx->fp, - ".Lframe1:\n" - "\t.long .LECIE1-.LSCIE1\n" - ".LSCIE1:\n" - "\t.long 0\n" - "\t.byte 0x1\n" - "\t.string \"zPR\"\n" - "\t.uleb128 0x1\n" - "\t.sleb128 -4\n" - "\t.byte 65\n" - "\t.uleb128 6\n" /* augmentation length */ - "\t.byte 0x1b\n" /* pcrel|sdata4 */ - "\t.long lj_err_unwind_dwarf-.\n" - "\t.byte 0x1b\n" /* pcrel|sdata4 */ - "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" - "\t.align 2\n" - ".LECIE1:\n\n"); - fprintf(ctx->fp, - ".LSFDE2:\n" - "\t.long .LEFDE2-.LASFDE2\n" - ".LASFDE2:\n" - "\t.long .LASFDE2-.Lframe1\n" - "\t.long .Lbegin-.\n" - "\t.long %d\n" - "\t.uleb128 0\n" /* augmentation length */ - "\t.byte 0xe\n\t.uleb128 %d\n" - "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" - "\t.byte 0x5\n\t.uleb128 70\n\t.uleb128 55\n", - fcofs, CFRAME_SIZE); - for (i = 14; i <= 31; i++) - fprintf(ctx->fp, - "\t.byte %d\n\t.uleb128 %d\n" - "\t.byte %d\n\t.uleb128 %d\n", - 0x80+i, 37+(31-i), 0x80+32+i, 2+2*(31-i)); - fprintf(ctx->fp, - "\t.align 2\n" - ".LEFDE2:\n\n"); -#if LJ_HASFFI - fprintf(ctx->fp, - ".Lframe2:\n" - "\t.long .LECIE2-.LSCIE2\n" - ".LSCIE2:\n" - "\t.long 0\n" - "\t.byte 0x1\n" - "\t.string \"zR\"\n" - "\t.uleb128 0x1\n" - "\t.sleb128 -4\n" - "\t.byte 65\n" - "\t.uleb128 1\n" /* augmentation length */ - "\t.byte 0x1b\n" /* pcrel|sdata4 */ - "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" - "\t.align 2\n" - ".LECIE2:\n\n"); - fprintf(ctx->fp, - ".LSFDE3:\n" - "\t.long .LEFDE3-.LASFDE3\n" - ".LASFDE3:\n" - "\t.long .LASFDE3-.Lframe2\n" - "\t.long lj_vm_ffi_call-.\n" - "\t.long %d\n" - "\t.uleb128 0\n" /* augmentation length */ - "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" - "\t.byte 0x8e\n\t.uleb128 2\n" - "\t.byte 0xd\n\t.uleb128 0xe\n" - "\t.align 2\n" - ".LEFDE3:\n\n", (int)ctx->codesz - fcofs); -#endif -#endif - break; - default: - break; - } -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/vm_ppcspe.dasc b/source/libs/luajit/LuaJIT-2.0.3/src/vm_ppcspe.dasc deleted file mode 100644 index adcec244a..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/vm_ppcspe.dasc +++ /dev/null @@ -1,3691 +0,0 @@ -|// Low-level VM code for PowerPC/e500 CPUs. -|// Bytecode interpreter, fast functions and helper functions. -|// Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -| -|.arch ppc -|.section code_op, code_sub -| -|.actionlist build_actionlist -|.globals GLOB_ -|.globalnames globnames -|.externnames extnames -| -|// Note: The ragged indentation of the instructions is intentional. -|// The starting columns indicate data dependencies. -| -|//----------------------------------------------------------------------- -| -|// Fixed register assignments for the interpreter. -|// Don't use: r1 = sp, r2 and r13 = reserved and/or small data area ptr -| -|// The following must be C callee-save (but BASE is often refetched). -|.define BASE, r14 // Base of current Lua stack frame. -|.define KBASE, r15 // Constants of current Lua function. -|.define PC, r16 // Next PC. -|.define DISPATCH, r17 // Opcode dispatch table. -|.define LREG, r18 // Register holding lua_State (also in SAVE_L). -|.define MULTRES, r19 // Size of multi-result: (nresults+1)*8. -| -|// Constants for vectorized type-comparisons (hi+low GPR). C callee-save. -|.define TISNUM, r22 -|.define TISSTR, r23 -|.define TISTAB, r24 -|.define TISFUNC, r25 -|.define TISNIL, r26 -|.define TOBIT, r27 -|.define ZERO, TOBIT // Zero in lo word. -| -|// The following temporaries are not saved across C calls, except for RA. -|.define RA, r20 // Callee-save. -|.define RB, r10 -|.define RC, r11 -|.define RD, r12 -|.define INS, r7 // Overlaps CARG5. -| -|.define TMP0, r0 -|.define TMP1, r8 -|.define TMP2, r9 -|.define TMP3, r6 // Overlaps CARG4. -| -|// Saved temporaries. -|.define SAVE0, r21 -| -|// Calling conventions. -|.define CARG1, r3 -|.define CARG2, r4 -|.define CARG3, r5 -|.define CARG4, r6 // Overlaps TMP3. -|.define CARG5, r7 // Overlaps INS. -| -|.define CRET1, r3 -|.define CRET2, r4 -| -|// Stack layout while in interpreter. Must match with lj_frame.h. -|.define SAVE_LR, 188(sp) -|.define CFRAME_SPACE, 184 // Delta for sp. -|// Back chain for sp: 184(sp) <-- sp entering interpreter -|.define SAVE_r31, 176(sp) // 64 bit register saves. -|.define SAVE_r30, 168(sp) -|.define SAVE_r29, 160(sp) -|.define SAVE_r28, 152(sp) -|.define SAVE_r27, 144(sp) -|.define SAVE_r26, 136(sp) -|.define SAVE_r25, 128(sp) -|.define SAVE_r24, 120(sp) -|.define SAVE_r23, 112(sp) -|.define SAVE_r22, 104(sp) -|.define SAVE_r21, 96(sp) -|.define SAVE_r20, 88(sp) -|.define SAVE_r19, 80(sp) -|.define SAVE_r18, 72(sp) -|.define SAVE_r17, 64(sp) -|.define SAVE_r16, 56(sp) -|.define SAVE_r15, 48(sp) -|.define SAVE_r14, 40(sp) -|.define SAVE_CR, 36(sp) -|.define UNUSED1, 32(sp) -|.define SAVE_ERRF, 28(sp) // 32 bit C frame info. -|.define SAVE_NRES, 24(sp) -|.define SAVE_CFRAME, 20(sp) -|.define SAVE_L, 16(sp) -|.define SAVE_PC, 12(sp) -|.define SAVE_MULTRES, 8(sp) -|// Next frame lr: 4(sp) -|// Back chain for sp: 0(sp) <-- sp while in interpreter -| -|.macro save_, reg; evstdd reg, SAVE_..reg; .endmacro -|.macro rest_, reg; evldd reg, SAVE_..reg; .endmacro -| -|.macro saveregs -| stwu sp, -CFRAME_SPACE(sp) -| save_ r14; save_ r15; save_ r16; save_ r17; save_ r18; save_ r19 -| mflr r0; mfcr r12 -| save_ r20; save_ r21; save_ r22; save_ r23; save_ r24; save_ r25 -| stw r0, SAVE_LR; stw r12, SAVE_CR -| save_ r26; save_ r27; save_ r28; save_ r29; save_ r30; save_ r31 -|.endmacro -| -|.macro restoreregs -| lwz r0, SAVE_LR; lwz r12, SAVE_CR -| rest_ r14; rest_ r15; rest_ r16; rest_ r17; rest_ r18; rest_ r19 -| mtlr r0; mtcrf 0x38, r12 -| rest_ r20; rest_ r21; rest_ r22; rest_ r23; rest_ r24; rest_ r25 -| rest_ r26; rest_ r27; rest_ r28; rest_ r29; rest_ r30; rest_ r31 -| addi sp, sp, CFRAME_SPACE -|.endmacro -| -|// Type definitions. Some of these are only used for documentation. -|.type L, lua_State, LREG -|.type GL, global_State -|.type TVALUE, TValue -|.type GCOBJ, GCobj -|.type STR, GCstr -|.type TAB, GCtab -|.type LFUNC, GCfuncL -|.type CFUNC, GCfuncC -|.type PROTO, GCproto -|.type UPVAL, GCupval -|.type NODE, Node -|.type NARGS8, int -|.type TRACE, GCtrace -| -|//----------------------------------------------------------------------- -| -|// These basic macros should really be part of DynASM. -|.macro srwi, rx, ry, n; rlwinm rx, ry, 32-n, n, 31; .endmacro -|.macro slwi, rx, ry, n; rlwinm rx, ry, n, 0, 31-n; .endmacro -|.macro rotlwi, rx, ry, n; rlwinm rx, ry, n, 0, 31; .endmacro -|.macro rotlw, rx, ry, rn; rlwnm rx, ry, rn, 0, 31; .endmacro -|.macro subi, rx, ry, i; addi rx, ry, -i; .endmacro -| -|// Trap for not-yet-implemented parts. -|.macro NYI; tw 4, sp, sp; .endmacro -| -|//----------------------------------------------------------------------- -| -|// Access to frame relative to BASE. -|.define FRAME_PC, -8 -|.define FRAME_FUNC, -4 -| -|// Instruction decode. -|.macro decode_OP4, dst, ins; rlwinm dst, ins, 2, 22, 29; .endmacro -|.macro decode_RA8, dst, ins; rlwinm dst, ins, 27, 21, 28; .endmacro -|.macro decode_RB8, dst, ins; rlwinm dst, ins, 11, 21, 28; .endmacro -|.macro decode_RC8, dst, ins; rlwinm dst, ins, 19, 21, 28; .endmacro -|.macro decode_RD8, dst, ins; rlwinm dst, ins, 19, 13, 28; .endmacro -| -|.macro decode_OP1, dst, ins; rlwinm dst, ins, 0, 24, 31; .endmacro -|.macro decode_RD4, dst, ins; rlwinm dst, ins, 18, 14, 29; .endmacro -| -|// Instruction fetch. -|.macro ins_NEXT1 -| lwz INS, 0(PC) -| addi PC, PC, 4 -|.endmacro -|// Instruction decode+dispatch. -|.macro ins_NEXT2 -| decode_OP4 TMP1, INS -| decode_RB8 RB, INS -| decode_RD8 RD, INS -| lwzx TMP0, DISPATCH, TMP1 -| decode_RA8 RA, INS -| decode_RC8 RC, INS -| mtctr TMP0 -| bctr -|.endmacro -|.macro ins_NEXT -| ins_NEXT1 -| ins_NEXT2 -|.endmacro -| -|// Instruction footer. -|.if 1 -| // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. -| .define ins_next, ins_NEXT -| .define ins_next_, ins_NEXT -| .define ins_next1, ins_NEXT1 -| .define ins_next2, ins_NEXT2 -|.else -| // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. -| // Affects only certain kinds of benchmarks (and only with -j off). -| .macro ins_next -| b ->ins_next -| .endmacro -| .macro ins_next1 -| .endmacro -| .macro ins_next2 -| b ->ins_next -| .endmacro -| .macro ins_next_ -| ->ins_next: -| ins_NEXT -| .endmacro -|.endif -| -|// Call decode and dispatch. -|.macro ins_callt -| // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC -| lwz PC, LFUNC:RB->pc -| lwz INS, 0(PC) -| addi PC, PC, 4 -| decode_OP4 TMP1, INS -| decode_RA8 RA, INS -| lwzx TMP0, DISPATCH, TMP1 -| add RA, RA, BASE -| mtctr TMP0 -| bctr -|.endmacro -| -|.macro ins_call -| // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, PC = caller PC -| stw PC, FRAME_PC(BASE) -| ins_callt -|.endmacro -| -|//----------------------------------------------------------------------- -| -|// Macros to test operand types. -|.macro checknum, reg; evcmpltu reg, TISNUM; .endmacro -|.macro checkstr, reg; evcmpeq reg, TISSTR; .endmacro -|.macro checktab, reg; evcmpeq reg, TISTAB; .endmacro -|.macro checkfunc, reg; evcmpeq reg, TISFUNC; .endmacro -|.macro checknil, reg; evcmpeq reg, TISNIL; .endmacro -|.macro checkok, label; blt label; .endmacro -|.macro checkfail, label; bge label; .endmacro -|.macro checkanyfail, label; bns label; .endmacro -|.macro checkallok, label; bso label; .endmacro -| -|.macro branch_RD -| srwi TMP0, RD, 1 -| add PC, PC, TMP0 -| addis PC, PC, -(BCBIAS_J*4 >> 16) -|.endmacro -| -|// Assumes DISPATCH is relative to GL. -#define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) -#define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) -| -#define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) -| -|.macro hotloop -| NYI -|.endmacro -| -|.macro hotcall -| NYI -|.endmacro -| -|// Set current VM state. Uses TMP0. -|.macro li_vmstate, st; li TMP0, ~LJ_VMST_..st; .endmacro -|.macro st_vmstate; stw TMP0, DISPATCH_GL(vmstate)(DISPATCH); .endmacro -| -|// Move table write barrier back. Overwrites mark and tmp. -|.macro barrierback, tab, mark, tmp -| lwz tmp, DISPATCH_GL(gc.grayagain)(DISPATCH) -| // Assumes LJ_GC_BLACK is 0x04. -| rlwinm mark, mark, 0, 30, 28 // black2gray(tab) -| stw tab, DISPATCH_GL(gc.grayagain)(DISPATCH) -| stb mark, tab->marked -| stw tmp, tab->gclist -|.endmacro -| -|//----------------------------------------------------------------------- - -/* Generate subroutines used by opcodes and other parts of the VM. */ -/* The .code_sub section should be last to help static branch prediction. */ -static void build_subroutines(BuildCtx *ctx) -{ - |.code_sub - | - |//----------------------------------------------------------------------- - |//-- Return handling ---------------------------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_returnp: - | // See vm_return. Also: TMP2 = previous base. - | andi. TMP0, PC, FRAME_P - | evsplati TMP1, LJ_TTRUE - | beq ->cont_dispatch - | - | // Return from pcall or xpcall fast func. - | lwz PC, FRAME_PC(TMP2) // Fetch PC of previous frame. - | mr BASE, TMP2 // Restore caller base. - | // Prepending may overwrite the pcall frame, so do it at the end. - | stwu TMP1, FRAME_PC(RA) // Prepend true to results. - | - |->vm_returnc: - | addi RD, RD, 8 // RD = (nresults+1)*8. - | andi. TMP0, PC, FRAME_TYPE - | cmpwi cr1, RD, 0 - | li CRET1, LUA_YIELD - | beq cr1, ->vm_unwind_c_eh - | mr MULTRES, RD - | beq ->BC_RET_Z // Handle regular return to Lua. - | - |->vm_return: - | // BASE = base, RA = resultptr, RD/MULTRES = (nresults+1)*8, PC = return - | // TMP0 = PC & FRAME_TYPE - | cmpwi TMP0, FRAME_C - | rlwinm TMP2, PC, 0, 0, 28 - | li_vmstate C - | sub TMP2, BASE, TMP2 // TMP2 = previous base. - | bne ->vm_returnp - | - | addic. TMP1, RD, -8 - | stw TMP2, L->base - | lwz TMP2, SAVE_NRES - | subi BASE, BASE, 8 - | st_vmstate - | slwi TMP2, TMP2, 3 - | beq >2 - |1: - | addic. TMP1, TMP1, -8 - | evldd TMP0, 0(RA) - | addi RA, RA, 8 - | evstdd TMP0, 0(BASE) - | addi BASE, BASE, 8 - | bne <1 - | - |2: - | cmpw TMP2, RD // More/less results wanted? - | bne >6 - |3: - | stw BASE, L->top // Store new top. - | - |->vm_leave_cp: - | lwz TMP0, SAVE_CFRAME // Restore previous C frame. - | li CRET1, 0 // Ok return status for vm_pcall. - | stw TMP0, L->cframe - | - |->vm_leave_unw: - | restoreregs - | blr - | - |6: - | ble >7 // Less results wanted? - | // More results wanted. Check stack size and fill up results with nil. - | lwz TMP1, L->maxstack - | cmplw BASE, TMP1 - | bge >8 - | evstdd TISNIL, 0(BASE) - | addi RD, RD, 8 - | addi BASE, BASE, 8 - | b <2 - | - |7: // Less results wanted. - | sub TMP0, RD, TMP2 - | cmpwi TMP2, 0 // LUA_MULTRET+1 case? - | sub TMP0, BASE, TMP0 // Subtract the difference. - | iseleq BASE, BASE, TMP0 // Either keep top or shrink it. - | b <3 - | - |8: // Corner case: need to grow stack for filling up results. - | // This can happen if: - | // - A C function grows the stack (a lot). - | // - The GC shrinks the stack in between. - | // - A return back from a lua_call() with (high) nresults adjustment. - | stw BASE, L->top // Save current top held in BASE (yes). - | mr SAVE0, RD - | mr CARG2, TMP2 - | mr CARG1, L - | bl extern lj_state_growstack // (lua_State *L, int n) - | lwz TMP2, SAVE_NRES - | mr RD, SAVE0 - | slwi TMP2, TMP2, 3 - | lwz BASE, L->top // Need the (realloced) L->top in BASE. - | b <2 - | - |->vm_unwind_c: // Unwind C stack, return from vm_pcall. - | // (void *cframe, int errcode) - | mr sp, CARG1 - | mr CRET1, CARG2 - |->vm_unwind_c_eh: // Landing pad for external unwinder. - | lwz L, SAVE_L - | li TMP0, ~LJ_VMST_C - | lwz GL:TMP1, L->glref - | stw TMP0, GL:TMP1->vmstate - | b ->vm_leave_unw - | - |->vm_unwind_ff: // Unwind C stack, return from ff pcall. - | // (void *cframe) - | rlwinm sp, CARG1, 0, 0, 29 - |->vm_unwind_ff_eh: // Landing pad for external unwinder. - | lwz L, SAVE_L - | evsplati TISNUM, LJ_TISNUM+1 // Setup type comparison constants. - | evsplati TISFUNC, LJ_TFUNC - | lus TOBIT, 0x4338 - | evsplati TISTAB, LJ_TTAB - | li TMP0, 0 - | lwz BASE, L->base - | evmergelo TOBIT, TOBIT, TMP0 - | lwz DISPATCH, L->glref // Setup pointer to dispatch table. - | evsplati TISSTR, LJ_TSTR - | li TMP1, LJ_TFALSE - | evsplati TISNIL, LJ_TNIL - | li_vmstate INTERP - | lwz PC, FRAME_PC(BASE) // Fetch PC of previous frame. - | la RA, -8(BASE) // Results start at BASE-8. - | addi DISPATCH, DISPATCH, GG_G2DISP - | stw TMP1, 0(RA) // Prepend false to error message. - | li RD, 16 // 2 results: false + error message. - | st_vmstate - | b ->vm_returnc - | - |//----------------------------------------------------------------------- - |//-- Grow stack for calls ----------------------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_growstack_c: // Grow stack for C function. - | li CARG2, LUA_MINSTACK - | b >2 - | - |->vm_growstack_l: // Grow stack for Lua function. - | // BASE = new base, RA = BASE+framesize*8, RC = nargs*8, PC = first PC - | add RC, BASE, RC - | sub RA, RA, BASE - | stw BASE, L->base - | addi PC, PC, 4 // Must point after first instruction. - | stw RC, L->top - | srwi CARG2, RA, 3 - |2: - | // L->base = new base, L->top = top - | stw PC, SAVE_PC - | mr CARG1, L - | bl extern lj_state_growstack // (lua_State *L, int n) - | lwz BASE, L->base - | lwz RC, L->top - | lwz LFUNC:RB, FRAME_FUNC(BASE) - | sub RC, RC, BASE - | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC - | ins_callt // Just retry the call. - | - |//----------------------------------------------------------------------- - |//-- Entry points into the assembler VM --------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_resume: // Setup C frame and resume thread. - | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) - | saveregs - | mr L, CARG1 - | lwz DISPATCH, L->glref // Setup pointer to dispatch table. - | mr BASE, CARG2 - | lbz TMP1, L->status - | stw L, SAVE_L - | li PC, FRAME_CP - | addi TMP0, sp, CFRAME_RESUME - | addi DISPATCH, DISPATCH, GG_G2DISP - | stw CARG3, SAVE_NRES - | cmplwi TMP1, 0 - | stw CARG3, SAVE_ERRF - | stw TMP0, L->cframe - | stw CARG3, SAVE_CFRAME - | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. - | beq >3 - | - | // Resume after yield (like a return). - | mr RA, BASE - | lwz BASE, L->base - | evsplati TISNUM, LJ_TISNUM+1 // Setup type comparison constants. - | lwz TMP1, L->top - | evsplati TISFUNC, LJ_TFUNC - | lus TOBIT, 0x4338 - | evsplati TISTAB, LJ_TTAB - | lwz PC, FRAME_PC(BASE) - | li TMP2, 0 - | evsplati TISSTR, LJ_TSTR - | sub RD, TMP1, BASE - | evmergelo TOBIT, TOBIT, TMP2 - | stb CARG3, L->status - | andi. TMP0, PC, FRAME_TYPE - | li_vmstate INTERP - | addi RD, RD, 8 - | evsplati TISNIL, LJ_TNIL - | mr MULTRES, RD - | st_vmstate - | beq ->BC_RET_Z - | b ->vm_return - | - |->vm_pcall: // Setup protected C frame and enter VM. - | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) - | saveregs - | li PC, FRAME_CP - | stw CARG4, SAVE_ERRF - | b >1 - | - |->vm_call: // Setup C frame and enter VM. - | // (lua_State *L, TValue *base, int nres1) - | saveregs - | li PC, FRAME_C - | - |1: // Entry point for vm_pcall above (PC = ftype). - | lwz TMP1, L:CARG1->cframe - | stw CARG3, SAVE_NRES - | mr L, CARG1 - | stw CARG1, SAVE_L - | mr BASE, CARG2 - | stw sp, L->cframe // Add our C frame to cframe chain. - | lwz DISPATCH, L->glref // Setup pointer to dispatch table. - | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. - | stw TMP1, SAVE_CFRAME - | addi DISPATCH, DISPATCH, GG_G2DISP - | - |3: // Entry point for vm_cpcall/vm_resume (BASE = base, PC = ftype). - | lwz TMP2, L->base // TMP2 = old base (used in vmeta_call). - | evsplati TISNUM, LJ_TISNUM+1 // Setup type comparison constants. - | lwz TMP1, L->top - | evsplati TISFUNC, LJ_TFUNC - | add PC, PC, BASE - | evsplati TISTAB, LJ_TTAB - | lus TOBIT, 0x4338 - | li TMP0, 0 - | sub PC, PC, TMP2 // PC = frame delta + frame type - | evsplati TISSTR, LJ_TSTR - | sub NARGS8:RC, TMP1, BASE - | evmergelo TOBIT, TOBIT, TMP0 - | li_vmstate INTERP - | evsplati TISNIL, LJ_TNIL - | st_vmstate - | - |->vm_call_dispatch: - | // TMP2 = old base, BASE = new base, RC = nargs*8, PC = caller PC - | li TMP0, -8 - | evlddx LFUNC:RB, BASE, TMP0 - | checkfunc LFUNC:RB - | checkfail ->vmeta_call - | - |->vm_call_dispatch_f: - | ins_call - | // BASE = new base, RB = func, RC = nargs*8, PC = caller PC - | - |->vm_cpcall: // Setup protected C frame, call C. - | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) - | saveregs - | mr L, CARG1 - | lwz TMP0, L:CARG1->stack - | stw CARG1, SAVE_L - | lwz TMP1, L->top - | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. - | sub TMP0, TMP0, TMP1 // Compute -savestack(L, L->top). - | lwz TMP1, L->cframe - | stw sp, L->cframe // Add our C frame to cframe chain. - | li TMP2, 0 - | stw TMP0, SAVE_NRES // Neg. delta means cframe w/o frame. - | stw TMP2, SAVE_ERRF // No error function. - | stw TMP1, SAVE_CFRAME - | mtctr CARG4 - | bctrl // (lua_State *L, lua_CFunction func, void *ud) - | mr. BASE, CRET1 - | lwz DISPATCH, L->glref // Setup pointer to dispatch table. - | li PC, FRAME_CP - | addi DISPATCH, DISPATCH, GG_G2DISP - | bne <3 // Else continue with the call. - | b ->vm_leave_cp // No base? Just remove C frame. - | - |//----------------------------------------------------------------------- - |//-- Metamethod handling ------------------------------------------------ - |//----------------------------------------------------------------------- - | - |// The lj_meta_* functions (except for lj_meta_cat) don't reallocate the - |// stack, so BASE doesn't need to be reloaded across these calls. - | - |//-- Continuation dispatch ---------------------------------------------- - | - |->cont_dispatch: - | // BASE = meta base, RA = resultptr, RD = (nresults+1)*8 - | lwz TMP0, -12(BASE) // Continuation. - | mr RB, BASE - | mr BASE, TMP2 // Restore caller BASE. - | lwz LFUNC:TMP1, FRAME_FUNC(TMP2) - | cmplwi TMP0, 0 - | lwz PC, -16(RB) // Restore PC from [cont|PC]. - | beq >1 - | subi TMP2, RD, 8 - | lwz TMP1, LFUNC:TMP1->pc - | evstddx TISNIL, RA, TMP2 // Ensure one valid arg. - | lwz KBASE, PC2PROTO(k)(TMP1) - | // BASE = base, RA = resultptr, RB = meta base - | mtctr TMP0 - | bctr // Jump to continuation. - | - |1: // Tail call from C function. - | subi TMP1, RB, 16 - | sub RC, TMP1, BASE - | b ->vm_call_tail - | - |->cont_cat: // RA = resultptr, RB = meta base - | lwz INS, -4(PC) - | subi CARG2, RB, 16 - | decode_RB8 SAVE0, INS - | evldd TMP0, 0(RA) - | add TMP1, BASE, SAVE0 - | stw BASE, L->base - | cmplw TMP1, CARG2 - | sub CARG3, CARG2, TMP1 - | decode_RA8 RA, INS - | evstdd TMP0, 0(CARG2) - | bne ->BC_CAT_Z - | evstddx TMP0, BASE, RA - | b ->cont_nop - | - |//-- Table indexing metamethods ----------------------------------------- - | - |->vmeta_tgets1: - | evmergelo STR:RC, TISSTR, STR:RC - | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) - | decode_RB8 RB, INS - | evstdd STR:RC, 0(CARG3) - | add CARG2, BASE, RB - | b >1 - | - |->vmeta_tgets: - | evmergelo TAB:RB, TISTAB, TAB:RB - | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) - | evmergelo STR:RC, TISSTR, STR:RC - | evstdd TAB:RB, 0(CARG2) - | la CARG3, DISPATCH_GL(tmptv2)(DISPATCH) - | evstdd STR:RC, 0(CARG3) - | b >1 - | - |->vmeta_tgetb: // TMP0 = index - | efdcfsi TMP0, TMP0 - | decode_RB8 RB, INS - | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) - | add CARG2, BASE, RB - | evstdd TMP0, 0(CARG3) - | b >1 - | - |->vmeta_tgetv: - | decode_RB8 RB, INS - | decode_RC8 RC, INS - | add CARG2, BASE, RB - | add CARG3, BASE, RC - |1: - | stw BASE, L->base - | mr CARG1, L - | stw PC, SAVE_PC - | bl extern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) - | // Returns TValue * (finished) or NULL (metamethod). - | cmplwi CRET1, 0 - | beq >3 - | evldd TMP0, 0(CRET1) - | evstddx TMP0, BASE, RA - | ins_next - | - |3: // Call __index metamethod. - | // BASE = base, L->top = new base, stack = cont/func/t/k - | subfic TMP1, BASE, FRAME_CONT - | lwz BASE, L->top - | stw PC, -16(BASE) // [cont|PC] - | add PC, TMP1, BASE - | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. - | li NARGS8:RC, 16 // 2 args for func(t, k). - | b ->vm_call_dispatch_f - | - |//----------------------------------------------------------------------- - | - |->vmeta_tsets1: - | evmergelo STR:RC, TISSTR, STR:RC - | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) - | decode_RB8 RB, INS - | evstdd STR:RC, 0(CARG3) - | add CARG2, BASE, RB - | b >1 - | - |->vmeta_tsets: - | evmergelo TAB:RB, TISTAB, TAB:RB - | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) - | evmergelo STR:RC, TISSTR, STR:RC - | evstdd TAB:RB, 0(CARG2) - | la CARG3, DISPATCH_GL(tmptv2)(DISPATCH) - | evstdd STR:RC, 0(CARG3) - | b >1 - | - |->vmeta_tsetb: // TMP0 = index - | efdcfsi TMP0, TMP0 - | decode_RB8 RB, INS - | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) - | add CARG2, BASE, RB - | evstdd TMP0, 0(CARG3) - | b >1 - | - |->vmeta_tsetv: - | decode_RB8 RB, INS - | decode_RC8 RC, INS - | add CARG2, BASE, RB - | add CARG3, BASE, RC - |1: - | stw BASE, L->base - | mr CARG1, L - | stw PC, SAVE_PC - | bl extern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) - | // Returns TValue * (finished) or NULL (metamethod). - | cmplwi CRET1, 0 - | evlddx TMP0, BASE, RA - | beq >3 - | // NOBARRIER: lj_meta_tset ensures the table is not black. - | evstdd TMP0, 0(CRET1) - | ins_next - | - |3: // Call __newindex metamethod. - | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) - | subfic TMP1, BASE, FRAME_CONT - | lwz BASE, L->top - | stw PC, -16(BASE) // [cont|PC] - | add PC, TMP1, BASE - | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. - | li NARGS8:RC, 24 // 3 args for func(t, k, v) - | evstdd TMP0, 16(BASE) // Copy value to third argument. - | b ->vm_call_dispatch_f - | - |//-- Comparison metamethods --------------------------------------------- - | - |->vmeta_comp: - | mr CARG1, L - | subi PC, PC, 4 - | add CARG2, BASE, RA - | stw PC, SAVE_PC - | add CARG3, BASE, RD - | stw BASE, L->base - | decode_OP1 CARG4, INS - | bl extern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) - | // Returns 0/1 or TValue * (metamethod). - |3: - | cmplwi CRET1, 1 - | bgt ->vmeta_binop - |4: - | lwz INS, 0(PC) - | addi PC, PC, 4 - | decode_RD4 TMP2, INS - | addis TMP3, PC, -(BCBIAS_J*4 >> 16) - | add TMP2, TMP2, TMP3 - | isellt PC, PC, TMP2 - |->cont_nop: - | ins_next - | - |->cont_ra: // RA = resultptr - | lwz INS, -4(PC) - | evldd TMP0, 0(RA) - | decode_RA8 TMP1, INS - | evstddx TMP0, BASE, TMP1 - | b ->cont_nop - | - |->cont_condt: // RA = resultptr - | lwz TMP0, 0(RA) - | li TMP1, LJ_TTRUE - | cmplw TMP1, TMP0 // Branch if result is true. - | b <4 - | - |->cont_condf: // RA = resultptr - | lwz TMP0, 0(RA) - | li TMP1, LJ_TFALSE - | cmplw TMP0, TMP1 // Branch if result is false. - | b <4 - | - |->vmeta_equal: - | // CARG2, CARG3, CARG4 are already set by BC_ISEQV/BC_ISNEV. - | subi PC, PC, 4 - | stw BASE, L->base - | mr CARG1, L - | stw PC, SAVE_PC - | bl extern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) - | // Returns 0/1 or TValue * (metamethod). - | b <3 - | - |//-- Arithmetic metamethods --------------------------------------------- - | - |->vmeta_arith_vn: - | add CARG3, BASE, RB - | add CARG4, KBASE, RC - | b >1 - | - |->vmeta_arith_nv: - | add CARG3, KBASE, RC - | add CARG4, BASE, RB - | b >1 - | - |->vmeta_unm: - | add CARG3, BASE, RD - | mr CARG4, CARG3 - | b >1 - | - |->vmeta_arith_vv: - | add CARG3, BASE, RB - | add CARG4, BASE, RC - |1: - | add CARG2, BASE, RA - | stw BASE, L->base - | mr CARG1, L - | stw PC, SAVE_PC - | decode_OP1 CARG5, INS // Caveat: CARG5 overlaps INS. - | bl extern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) - | // Returns NULL (finished) or TValue * (metamethod). - | cmplwi CRET1, 0 - | beq ->cont_nop - | - | // Call metamethod for binary op. - |->vmeta_binop: - | // BASE = old base, CRET1 = new base, stack = cont/func/o1/o2 - | sub TMP1, CRET1, BASE - | stw PC, -16(CRET1) // [cont|PC] - | mr TMP2, BASE - | addi PC, TMP1, FRAME_CONT - | mr BASE, CRET1 - | li NARGS8:RC, 16 // 2 args for func(o1, o2). - | b ->vm_call_dispatch - | - |->vmeta_len: -#if LJ_52 - | mr SAVE0, CARG1 -#endif - | add CARG2, BASE, RD - | stw BASE, L->base - | mr CARG1, L - | stw PC, SAVE_PC - | bl extern lj_meta_len // (lua_State *L, TValue *o) - | // Returns NULL (retry) or TValue * (metamethod base). -#if LJ_52 - | cmplwi CRET1, 0 - | bne ->vmeta_binop // Binop call for compatibility. - | mr CARG1, SAVE0 - | b ->BC_LEN_Z -#else - | b ->vmeta_binop // Binop call for compatibility. -#endif - | - |//-- Call metamethod ---------------------------------------------------- - | - |->vmeta_call: // Resolve and call __call metamethod. - | // TMP2 = old base, BASE = new base, RC = nargs*8 - | mr CARG1, L - | stw TMP2, L->base // This is the callers base! - | subi CARG2, BASE, 8 - | stw PC, SAVE_PC - | add CARG3, BASE, RC - | mr SAVE0, NARGS8:RC - | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) - | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. - | addi NARGS8:RC, SAVE0, 8 // Got one more argument now. - | ins_call - | - |->vmeta_callt: // Resolve __call for BC_CALLT. - | // BASE = old base, RA = new base, RC = nargs*8 - | mr CARG1, L - | stw BASE, L->base - | subi CARG2, RA, 8 - | stw PC, SAVE_PC - | add CARG3, RA, RC - | mr SAVE0, NARGS8:RC - | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) - | lwz TMP1, FRAME_PC(BASE) - | addi NARGS8:RC, SAVE0, 8 // Got one more argument now. - | lwz LFUNC:RB, FRAME_FUNC(RA) // Guaranteed to be a function here. - | b ->BC_CALLT_Z - | - |//-- Argument coercion for 'for' statement ------------------------------ - | - |->vmeta_for: - | mr CARG1, L - | stw BASE, L->base - | mr CARG2, RA - | stw PC, SAVE_PC - | mr SAVE0, INS - | bl extern lj_meta_for // (lua_State *L, TValue *base) - |.if JIT - | decode_OP1 TMP0, SAVE0 - |.endif - | decode_RA8 RA, SAVE0 - |.if JIT - | cmpwi TMP0, BC_JFORI - |.endif - | decode_RD8 RD, SAVE0 - |.if JIT - | beq =>BC_JFORI - |.endif - | b =>BC_FORI - | - |//----------------------------------------------------------------------- - |//-- Fast functions ----------------------------------------------------- - |//----------------------------------------------------------------------- - | - |.macro .ffunc, name - |->ff_ .. name: - |.endmacro - | - |.macro .ffunc_1, name - |->ff_ .. name: - | cmplwi NARGS8:RC, 8 - | evldd CARG1, 0(BASE) - | blt ->fff_fallback - |.endmacro - | - |.macro .ffunc_2, name - |->ff_ .. name: - | cmplwi NARGS8:RC, 16 - | evldd CARG1, 0(BASE) - | evldd CARG2, 8(BASE) - | blt ->fff_fallback - |.endmacro - | - |.macro .ffunc_n, name - | .ffunc_1 name - | checknum CARG1 - | checkfail ->fff_fallback - |.endmacro - | - |.macro .ffunc_nn, name - | .ffunc_2 name - | evmergehi TMP0, CARG1, CARG2 - | checknum TMP0 - | checkanyfail ->fff_fallback - |.endmacro - | - |// Inlined GC threshold check. Caveat: uses TMP0 and TMP1. - |.macro ffgccheck - | lwz TMP0, DISPATCH_GL(gc.total)(DISPATCH) - | lwz TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) - | cmplw TMP0, TMP1 - | bgel ->fff_gcstep - |.endmacro - | - |//-- Base library: checks ----------------------------------------------- - | - |.ffunc assert - | cmplwi NARGS8:RC, 8 - | evldd TMP0, 0(BASE) - | blt ->fff_fallback - | evaddw TMP1, TISNIL, TISNIL // Synthesize LJ_TFALSE. - | la RA, -8(BASE) - | evcmpltu cr1, TMP0, TMP1 - | lwz PC, FRAME_PC(BASE) - | bge cr1, ->fff_fallback - | evstdd TMP0, 0(RA) - | addi RD, NARGS8:RC, 8 // Compute (nresults+1)*8. - | beq ->fff_res // Done if exactly 1 argument. - | li TMP1, 8 - | subi RC, RC, 8 - |1: - | cmplw TMP1, RC - | evlddx TMP0, BASE, TMP1 - | evstddx TMP0, RA, TMP1 - | addi TMP1, TMP1, 8 - | bne <1 - | b ->fff_res - | - |.ffunc type - | cmplwi NARGS8:RC, 8 - | lwz CARG1, 0(BASE) - | blt ->fff_fallback - | li TMP2, ~LJ_TNUMX - | cmplw CARG1, TISNUM - | not TMP1, CARG1 - | isellt TMP1, TMP2, TMP1 - | slwi TMP1, TMP1, 3 - | la TMP2, CFUNC:RB->upvalue - | evlddx STR:CRET1, TMP2, TMP1 - | b ->fff_restv - | - |//-- Base library: getters and setters --------------------------------- - | - |.ffunc_1 getmetatable - | checktab CARG1 - | evmergehi TMP1, CARG1, CARG1 - | checkfail >6 - |1: // Field metatable must be at same offset for GCtab and GCudata! - | lwz TAB:RB, TAB:CARG1->metatable - |2: - | evmr CRET1, TISNIL - | cmplwi TAB:RB, 0 - | lwz STR:RC, DISPATCH_GL(gcroot[GCROOT_MMNAME+MM_metatable])(DISPATCH) - | beq ->fff_restv - | lwz TMP0, TAB:RB->hmask - | evmergelo CRET1, TISTAB, TAB:RB // Use metatable as default result. - | lwz TMP1, STR:RC->hash - | lwz NODE:TMP2, TAB:RB->node - | evmergelo STR:RC, TISSTR, STR:RC - | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask - | slwi TMP0, TMP1, 5 - | slwi TMP1, TMP1, 3 - | sub TMP1, TMP0, TMP1 - | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) - |3: // Rearranged logic, because we expect _not_ to find the key. - | evldd TMP0, NODE:TMP2->key - | evldd TMP1, NODE:TMP2->val - | evcmpeq TMP0, STR:RC - | lwz NODE:TMP2, NODE:TMP2->next - | checkallok >5 - | cmplwi NODE:TMP2, 0 - | beq ->fff_restv // Not found, keep default result. - | b <3 - |5: - | checknil TMP1 - | checkok ->fff_restv // Ditto for nil value. - | evmr CRET1, TMP1 // Return value of mt.__metatable. - | b ->fff_restv - | - |6: - | cmpwi TMP1, LJ_TUDATA - | not TMP1, TMP1 - | beq <1 - | checknum CARG1 - | slwi TMP1, TMP1, 2 - | li TMP2, 4*~LJ_TNUMX - | isellt TMP1, TMP2, TMP1 - | la TMP2, DISPATCH_GL(gcroot[GCROOT_BASEMT])(DISPATCH) - | lwzx TAB:RB, TMP2, TMP1 - | b <2 - | - |.ffunc_2 setmetatable - | // Fast path: no mt for table yet and not clearing the mt. - | evmergehi TMP0, TAB:CARG1, TAB:CARG2 - | checktab TMP0 - | checkanyfail ->fff_fallback - | lwz TAB:TMP1, TAB:CARG1->metatable - | cmplwi TAB:TMP1, 0 - | lbz TMP3, TAB:CARG1->marked - | bne ->fff_fallback - | andi. TMP0, TMP3, LJ_GC_BLACK // isblack(table) - | stw TAB:CARG2, TAB:CARG1->metatable - | beq ->fff_restv - | barrierback TAB:CARG1, TMP3, TMP0 - | b ->fff_restv - | - |.ffunc rawget - | cmplwi NARGS8:RC, 16 - | evldd CARG2, 0(BASE) - | blt ->fff_fallback - | checktab CARG2 - | la CARG3, 8(BASE) - | checkfail ->fff_fallback - | mr CARG1, L - | bl extern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) - | // Returns cTValue *. - | evldd CRET1, 0(CRET1) - | b ->fff_restv - | - |//-- Base library: conversions ------------------------------------------ - | - |.ffunc tonumber - | // Only handles the number case inline (without a base argument). - | cmplwi NARGS8:RC, 8 - | evldd CARG1, 0(BASE) - | bne ->fff_fallback // Exactly one argument. - | checknum CARG1 - | checkok ->fff_restv - | b ->fff_fallback - | - |.ffunc_1 tostring - | // Only handles the string or number case inline. - | checkstr CARG1 - | // A __tostring method in the string base metatable is ignored. - | checkok ->fff_restv // String key? - | // Handle numbers inline, unless a number base metatable is present. - | lwz TMP0, DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])(DISPATCH) - | checknum CARG1 - | cmplwi cr1, TMP0, 0 - | stw BASE, L->base // Add frame since C call can throw. - | crand 4*cr0+eq, 4*cr0+lt, 4*cr1+eq - | stw PC, SAVE_PC // Redundant (but a defined value). - | bne ->fff_fallback - | ffgccheck - | mr CARG1, L - | mr CARG2, BASE - | bl extern lj_str_fromnum // (lua_State *L, lua_Number *np) - | // Returns GCstr *. - | evmergelo STR:CRET1, TISSTR, STR:CRET1 - | b ->fff_restv - | - |//-- Base library: iterators ------------------------------------------- - | - |.ffunc next - | cmplwi NARGS8:RC, 8 - | evldd CARG2, 0(BASE) - | blt ->fff_fallback - | evstddx TISNIL, BASE, NARGS8:RC // Set missing 2nd arg to nil. - | checktab TAB:CARG2 - | lwz PC, FRAME_PC(BASE) - | checkfail ->fff_fallback - | stw BASE, L->base // Add frame since C call can throw. - | mr CARG1, L - | stw BASE, L->top // Dummy frame length is ok. - | la CARG3, 8(BASE) - | stw PC, SAVE_PC - | bl extern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) - | // Returns 0 at end of traversal. - | cmplwi CRET1, 0 - | evmr CRET1, TISNIL - | beq ->fff_restv // End of traversal: return nil. - | evldd TMP0, 8(BASE) // Copy key and value to results. - | la RA, -8(BASE) - | evldd TMP1, 16(BASE) - | evstdd TMP0, 0(RA) - | li RD, (2+1)*8 - | evstdd TMP1, 8(RA) - | b ->fff_res - | - |.ffunc_1 pairs - | checktab TAB:CARG1 - | lwz PC, FRAME_PC(BASE) - | checkfail ->fff_fallback -#if LJ_52 - | lwz TAB:TMP2, TAB:CARG1->metatable - | evldd CFUNC:TMP0, CFUNC:RB->upvalue[0] - | cmplwi TAB:TMP2, 0 - | la RA, -8(BASE) - | bne ->fff_fallback -#else - | evldd CFUNC:TMP0, CFUNC:RB->upvalue[0] - | la RA, -8(BASE) -#endif - | evstdd TISNIL, 8(BASE) - | li RD, (3+1)*8 - | evstdd CFUNC:TMP0, 0(RA) - | b ->fff_res - | - |.ffunc_2 ipairs_aux - | checktab TAB:CARG1 - | lwz PC, FRAME_PC(BASE) - | checkfail ->fff_fallback - | checknum CARG2 - | lus TMP3, 0x3ff0 - | checkfail ->fff_fallback - | efdctsi TMP2, CARG2 - | lwz TMP0, TAB:CARG1->asize - | evmergelo TMP3, TMP3, ZERO - | lwz TMP1, TAB:CARG1->array - | efdadd CARG2, CARG2, TMP3 - | addi TMP2, TMP2, 1 - | la RA, -8(BASE) - | cmplw TMP0, TMP2 - | slwi TMP3, TMP2, 3 - | evstdd CARG2, 0(RA) - | ble >2 // Not in array part? - | evlddx TMP1, TMP1, TMP3 - |1: - | checknil TMP1 - | li RD, (0+1)*8 - | checkok ->fff_res // End of iteration, return 0 results. - | li RD, (2+1)*8 - | evstdd TMP1, 8(RA) - | b ->fff_res - |2: // Check for empty hash part first. Otherwise call C function. - | lwz TMP0, TAB:CARG1->hmask - | cmplwi TMP0, 0 - | li RD, (0+1)*8 - | beq ->fff_res - | mr CARG2, TMP2 - | bl extern lj_tab_getinth // (GCtab *t, int32_t key) - | // Returns cTValue * or NULL. - | cmplwi CRET1, 0 - | li RD, (0+1)*8 - | beq ->fff_res - | evldd TMP1, 0(CRET1) - | b <1 - | - |.ffunc_1 ipairs - | checktab TAB:CARG1 - | lwz PC, FRAME_PC(BASE) - | checkfail ->fff_fallback -#if LJ_52 - | lwz TAB:TMP2, TAB:CARG1->metatable - | evldd CFUNC:TMP0, CFUNC:RB->upvalue[0] - | cmplwi TAB:TMP2, 0 - | la RA, -8(BASE) - | bne ->fff_fallback -#else - | evldd CFUNC:TMP0, CFUNC:RB->upvalue[0] - | la RA, -8(BASE) -#endif - | evsplati TMP1, 0 - | li RD, (3+1)*8 - | evstdd TMP1, 8(BASE) - | evstdd CFUNC:TMP0, 0(RA) - | b ->fff_res - | - |//-- Base library: catch errors ---------------------------------------- - | - |.ffunc pcall - | cmplwi NARGS8:RC, 8 - | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) - | blt ->fff_fallback - | mr TMP2, BASE - | la BASE, 8(BASE) - | // Remember active hook before pcall. - | rlwinm TMP3, TMP3, 32-HOOK_ACTIVE_SHIFT, 31, 31 - | subi NARGS8:RC, NARGS8:RC, 8 - | addi PC, TMP3, 8+FRAME_PCALL - | b ->vm_call_dispatch - | - |.ffunc_2 xpcall - | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) - | mr TMP2, BASE - | checkfunc CARG2 // Traceback must be a function. - | checkfail ->fff_fallback - | la BASE, 16(BASE) - | // Remember active hook before pcall. - | rlwinm TMP3, TMP3, 32-HOOK_ACTIVE_SHIFT, 31, 31 - | evstdd CARG2, 0(TMP2) // Swap function and traceback. - | subi NARGS8:RC, NARGS8:RC, 16 - | evstdd CARG1, 8(TMP2) - | addi PC, TMP3, 16+FRAME_PCALL - | b ->vm_call_dispatch - | - |//-- Coroutine library -------------------------------------------------- - | - |.macro coroutine_resume_wrap, resume - |.if resume - |.ffunc_1 coroutine_resume - | evmergehi TMP0, L:CARG1, L:CARG1 - |.else - |.ffunc coroutine_wrap_aux - | lwz L:CARG1, CFUNC:RB->upvalue[0].gcr - |.endif - |.if resume - | cmpwi TMP0, LJ_TTHREAD - | bne ->fff_fallback - |.endif - | lbz TMP0, L:CARG1->status - | lwz TMP1, L:CARG1->cframe - | lwz CARG2, L:CARG1->top - | cmplwi cr0, TMP0, LUA_YIELD - | lwz TMP2, L:CARG1->base - | cmplwi cr1, TMP1, 0 - | lwz TMP0, L:CARG1->maxstack - | cmplw cr7, CARG2, TMP2 - | lwz PC, FRAME_PC(BASE) - | crorc 4*cr6+lt, 4*cr0+gt, 4*cr1+eq // st>LUA_YIELD || cframe!=0 - | add TMP2, CARG2, NARGS8:RC - | crandc 4*cr6+gt, 4*cr7+eq, 4*cr0+eq // base==top && st!=LUA_YIELD - | cmplw cr1, TMP2, TMP0 - | cror 4*cr6+lt, 4*cr6+lt, 4*cr6+gt - | stw PC, SAVE_PC - | cror 4*cr6+lt, 4*cr6+lt, 4*cr1+gt // cond1 || cond2 || stackov - | stw BASE, L->base - | blt cr6, ->fff_fallback - |1: - |.if resume - | addi BASE, BASE, 8 // Keep resumed thread in stack for GC. - | subi NARGS8:RC, NARGS8:RC, 8 - | subi TMP2, TMP2, 8 - |.endif - | stw TMP2, L:CARG1->top - | li TMP1, 0 - | stw BASE, L->top - |2: // Move args to coroutine. - | cmpw TMP1, NARGS8:RC - | evlddx TMP0, BASE, TMP1 - | beq >3 - | evstddx TMP0, CARG2, TMP1 - | addi TMP1, TMP1, 8 - | b <2 - |3: - | li CARG3, 0 - | mr L:SAVE0, L:CARG1 - | li CARG4, 0 - | bl ->vm_resume // (lua_State *L, TValue *base, 0, 0) - | // Returns thread status. - |4: - | lwz TMP2, L:SAVE0->base - | cmplwi CRET1, LUA_YIELD - | lwz TMP3, L:SAVE0->top - | li_vmstate INTERP - | lwz BASE, L->base - | st_vmstate - | bgt >8 - | sub RD, TMP3, TMP2 - | lwz TMP0, L->maxstack - | cmplwi RD, 0 - | add TMP1, BASE, RD - | beq >6 // No results? - | cmplw TMP1, TMP0 - | li TMP1, 0 - | bgt >9 // Need to grow stack? - | - | subi TMP3, RD, 8 - | stw TMP2, L:SAVE0->top // Clear coroutine stack. - |5: // Move results from coroutine. - | cmplw TMP1, TMP3 - | evlddx TMP0, TMP2, TMP1 - | evstddx TMP0, BASE, TMP1 - | addi TMP1, TMP1, 8 - | bne <5 - |6: - | andi. TMP0, PC, FRAME_TYPE - |.if resume - | li TMP1, LJ_TTRUE - | la RA, -8(BASE) - | stw TMP1, -8(BASE) // Prepend true to results. - | addi RD, RD, 16 - |.else - | mr RA, BASE - | addi RD, RD, 8 - |.endif - |7: - | stw PC, SAVE_PC - | mr MULTRES, RD - | beq ->BC_RET_Z - | b ->vm_return - | - |8: // Coroutine returned with error (at co->top-1). - |.if resume - | andi. TMP0, PC, FRAME_TYPE - | la TMP3, -8(TMP3) - | li TMP1, LJ_TFALSE - | evldd TMP0, 0(TMP3) - | stw TMP3, L:SAVE0->top // Remove error from coroutine stack. - | li RD, (2+1)*8 - | stw TMP1, -8(BASE) // Prepend false to results. - | la RA, -8(BASE) - | evstdd TMP0, 0(BASE) // Copy error message. - | b <7 - |.else - | mr CARG1, L - | mr CARG2, L:SAVE0 - | bl extern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co) - |.endif - | - |9: // Handle stack expansion on return from yield. - | mr CARG1, L - | srwi CARG2, RD, 3 - | bl extern lj_state_growstack // (lua_State *L, int n) - | li CRET1, 0 - | b <4 - |.endmacro - | - | coroutine_resume_wrap 1 // coroutine.resume - | coroutine_resume_wrap 0 // coroutine.wrap - | - |.ffunc coroutine_yield - | lwz TMP0, L->cframe - | add TMP1, BASE, NARGS8:RC - | stw BASE, L->base - | andi. TMP0, TMP0, CFRAME_RESUME - | stw TMP1, L->top - | li CRET1, LUA_YIELD - | beq ->fff_fallback - | stw ZERO, L->cframe - | stb CRET1, L->status - | b ->vm_leave_unw - | - |//-- Math library ------------------------------------------------------- - | - |.ffunc_n math_abs - | efdabs CRET1, CARG1 - | // Fallthrough. - | - |->fff_restv: - | // CRET1 = TValue result. - | lwz PC, FRAME_PC(BASE) - | la RA, -8(BASE) - | evstdd CRET1, 0(RA) - |->fff_res1: - | // RA = results, PC = return. - | li RD, (1+1)*8 - |->fff_res: - | // RA = results, RD = (nresults+1)*8, PC = return. - | andi. TMP0, PC, FRAME_TYPE - | mr MULTRES, RD - | bne ->vm_return - | lwz INS, -4(PC) - | decode_RB8 RB, INS - |5: - | cmplw RB, RD // More results expected? - | decode_RA8 TMP0, INS - | bgt >6 - | ins_next1 - | // Adjust BASE. KBASE is assumed to be set for the calling frame. - | sub BASE, RA, TMP0 - | ins_next2 - | - |6: // Fill up results with nil. - | subi TMP1, RD, 8 - | addi RD, RD, 8 - | evstddx TISNIL, RA, TMP1 - | b <5 - | - |.macro math_extern, func - | .ffunc math_ .. func - | cmplwi NARGS8:RC, 8 - | evldd CARG2, 0(BASE) - | blt ->fff_fallback - | checknum CARG2 - | evmergehi CARG1, CARG2, CARG2 - | checkfail ->fff_fallback - | bl extern func@plt - | evmergelo CRET1, CRET1, CRET2 - | b ->fff_restv - |.endmacro - | - |.macro math_extern2, func - | .ffunc math_ .. func - | cmplwi NARGS8:RC, 16 - | evldd CARG2, 0(BASE) - | evldd CARG4, 8(BASE) - | blt ->fff_fallback - | evmergehi CARG1, CARG4, CARG2 - | checknum CARG1 - | evmergehi CARG3, CARG4, CARG4 - | checkanyfail ->fff_fallback - | bl extern func@plt - | evmergelo CRET1, CRET1, CRET2 - | b ->fff_restv - |.endmacro - | - |.macro math_round, func - | .ffunc math_ .. func - | cmplwi NARGS8:RC, 8 - | evldd CARG2, 0(BASE) - | blt ->fff_fallback - | checknum CARG2 - | evmergehi CARG1, CARG2, CARG2 - | checkfail ->fff_fallback - | lwz PC, FRAME_PC(BASE) - | bl ->vm_..func.._hilo; - | la RA, -8(BASE) - | evstdd CRET2, 0(RA) - | b ->fff_res1 - |.endmacro - | - | math_round floor - | math_round ceil - | - | math_extern sqrt - | - |.ffunc math_log - | cmplwi NARGS8:RC, 8 - | evldd CARG2, 0(BASE) - | bne ->fff_fallback // Need exactly 1 argument. - | checknum CARG2 - | evmergehi CARG1, CARG2, CARG2 - | checkfail ->fff_fallback - | bl extern log@plt - | evmergelo CRET1, CRET1, CRET2 - | b ->fff_restv - | - | math_extern log10 - | math_extern exp - | math_extern sin - | math_extern cos - | math_extern tan - | math_extern asin - | math_extern acos - | math_extern atan - | math_extern sinh - | math_extern cosh - | math_extern tanh - | math_extern2 pow - | math_extern2 atan2 - | math_extern2 fmod - | - |->ff_math_deg: - |.ffunc_n math_rad - | evldd CARG2, CFUNC:RB->upvalue[0] - | efdmul CRET1, CARG1, CARG2 - | b ->fff_restv - | - |.ffunc math_ldexp - | cmplwi NARGS8:RC, 16 - | evldd CARG2, 0(BASE) - | evldd CARG4, 8(BASE) - | blt ->fff_fallback - | evmergehi CARG1, CARG4, CARG2 - | checknum CARG1 - | checkanyfail ->fff_fallback - | efdctsi CARG3, CARG4 - | bl extern ldexp@plt - | evmergelo CRET1, CRET1, CRET2 - | b ->fff_restv - | - |.ffunc math_frexp - | cmplwi NARGS8:RC, 8 - | evldd CARG2, 0(BASE) - | blt ->fff_fallback - | checknum CARG2 - | evmergehi CARG1, CARG2, CARG2 - | checkfail ->fff_fallback - | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) - | lwz PC, FRAME_PC(BASE) - | bl extern frexp@plt - | lwz TMP1, DISPATCH_GL(tmptv)(DISPATCH) - | evmergelo CRET1, CRET1, CRET2 - | efdcfsi CRET2, TMP1 - | la RA, -8(BASE) - | evstdd CRET1, 0(RA) - | li RD, (2+1)*8 - | evstdd CRET2, 8(RA) - | b ->fff_res - | - |.ffunc math_modf - | cmplwi NARGS8:RC, 8 - | evldd CARG2, 0(BASE) - | blt ->fff_fallback - | checknum CARG2 - | evmergehi CARG1, CARG2, CARG2 - | checkfail ->fff_fallback - | la CARG3, -8(BASE) - | lwz PC, FRAME_PC(BASE) - | bl extern modf@plt - | evmergelo CRET1, CRET1, CRET2 - | la RA, -8(BASE) - | evstdd CRET1, 0(BASE) - | li RD, (2+1)*8 - | b ->fff_res - | - |.macro math_minmax, name, cmpop - | .ffunc_1 name - | checknum CARG1 - | li TMP1, 8 - | checkfail ->fff_fallback - |1: - | evlddx CARG2, BASE, TMP1 - | cmplw cr1, TMP1, NARGS8:RC - | checknum CARG2 - | bge cr1, ->fff_restv // Ok, since CRET1 = CARG1. - | checkfail ->fff_fallback - | cmpop CARG2, CARG1 - | addi TMP1, TMP1, 8 - | crmove 4*cr0+lt, 4*cr0+gt - | evsel CARG1, CARG2, CARG1 - | b <1 - |.endmacro - | - | math_minmax math_min, efdtstlt - | math_minmax math_max, efdtstgt - | - |//-- String library ----------------------------------------------------- - | - |.ffunc_1 string_len - | checkstr STR:CARG1 - | checkfail ->fff_fallback - | lwz TMP0, STR:CARG1->len - | efdcfsi CRET1, TMP0 - | b ->fff_restv - | - |.ffunc string_byte // Only handle the 1-arg case here. - | cmplwi NARGS8:RC, 8 - | evldd STR:CARG1, 0(BASE) - | bne ->fff_fallback // Need exactly 1 argument. - | checkstr STR:CARG1 - | la RA, -8(BASE) - | checkfail ->fff_fallback - | lwz TMP0, STR:CARG1->len - | li RD, (0+1)*8 - | lbz TMP1, STR:CARG1[1] // Access is always ok (NUL at end). - | li TMP2, (1+1)*8 - | cmplwi TMP0, 0 - | lwz PC, FRAME_PC(BASE) - | efdcfsi CRET1, TMP1 - | iseleq RD, RD, TMP2 - | evstdd CRET1, 0(RA) - | b ->fff_res - | - |.ffunc string_char // Only handle the 1-arg case here. - | ffgccheck - | cmplwi NARGS8:RC, 8 - | evldd CARG1, 0(BASE) - | bne ->fff_fallback // Exactly 1 argument. - | checknum CARG1 - | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) - | checkfail ->fff_fallback - | efdctsiz TMP0, CARG1 - | li CARG3, 1 - | cmplwi TMP0, 255 - | stb TMP0, 0(CARG2) - | bgt ->fff_fallback - |->fff_newstr: - | mr CARG1, L - | stw BASE, L->base - | stw PC, SAVE_PC - | bl extern lj_str_new // (lua_State *L, char *str, size_t l) - | // Returns GCstr *. - | lwz BASE, L->base - | evmergelo STR:CRET1, TISSTR, STR:CRET1 - | b ->fff_restv - | - |.ffunc string_sub - | ffgccheck - | cmplwi NARGS8:RC, 16 - | evldd CARG3, 16(BASE) - | evldd STR:CARG1, 0(BASE) - | blt ->fff_fallback - | evldd CARG2, 8(BASE) - | li TMP2, -1 - | beq >1 - | checknum CARG3 - | checkfail ->fff_fallback - | efdctsiz TMP2, CARG3 - |1: - | checknum CARG2 - | checkfail ->fff_fallback - | checkstr STR:CARG1 - | efdctsiz TMP1, CARG2 - | checkfail ->fff_fallback - | lwz TMP0, STR:CARG1->len - | cmplw TMP0, TMP2 // len < end? (unsigned compare) - | add TMP3, TMP2, TMP0 - | blt >5 - |2: - | cmpwi TMP1, 0 // start <= 0? - | add TMP3, TMP1, TMP0 - | ble >7 - |3: - | sub. CARG3, TMP2, TMP1 - | addi CARG2, STR:CARG1, #STR-1 - | addi CARG3, CARG3, 1 - | add CARG2, CARG2, TMP1 - | isellt CARG3, r0, CARG3 - | b ->fff_newstr - | - |5: // Negative end or overflow. - | cmpw TMP0, TMP2 - | addi TMP3, TMP3, 1 - | iselgt TMP2, TMP3, TMP0 // end = end > len ? len : end+len+1 - | b <2 - | - |7: // Negative start or underflow. - | cmpwi cr1, TMP3, 0 - | iseleq TMP1, r0, TMP3 - | isel TMP1, r0, TMP1, 4*cr1+lt - | addi TMP1, TMP1, 1 // start = 1 + (start ? start+len : 0) - | b <3 - | - |.ffunc string_rep // Only handle the 1-char case inline. - | ffgccheck - | cmplwi NARGS8:RC, 16 - | evldd CARG1, 0(BASE) - | evldd CARG2, 8(BASE) - | bne ->fff_fallback // Exactly 2 arguments. - | checknum CARG2 - | checkfail ->fff_fallback - | checkstr STR:CARG1 - | efdctsiz CARG3, CARG2 - | checkfail ->fff_fallback - | lwz TMP0, STR:CARG1->len - | cmpwi CARG3, 0 - | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) - | ble >2 // Count <= 0? (or non-int) - | cmplwi TMP0, 1 - | subi TMP2, CARG3, 1 - | blt >2 // Zero length string? - | cmplw cr1, TMP1, CARG3 - | bne ->fff_fallback // Fallback for > 1-char strings. - | lbz TMP0, STR:CARG1[1] - | lwz CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) - | blt cr1, ->fff_fallback - |1: // Fill buffer with char. Yes, this is suboptimal code (do you care?). - | cmplwi TMP2, 0 - | stbx TMP0, CARG2, TMP2 - | subi TMP2, TMP2, 1 - | bne <1 - | b ->fff_newstr - |2: // Return empty string. - | la STR:CRET1, DISPATCH_GL(strempty)(DISPATCH) - | evmergelo CRET1, TISSTR, STR:CRET1 - | b ->fff_restv - | - |.ffunc string_reverse - | ffgccheck - | cmplwi NARGS8:RC, 8 - | evldd CARG1, 0(BASE) - | blt ->fff_fallback - | checkstr STR:CARG1 - | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) - | checkfail ->fff_fallback - | lwz CARG3, STR:CARG1->len - | la CARG1, #STR(STR:CARG1) - | lwz CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) - | li TMP2, 0 - | cmplw TMP1, CARG3 - | subi TMP3, CARG3, 1 - | blt ->fff_fallback - |1: // Reverse string copy. - | cmpwi TMP3, 0 - | lbzx TMP1, CARG1, TMP2 - | blt ->fff_newstr - | stbx TMP1, CARG2, TMP3 - | subi TMP3, TMP3, 1 - | addi TMP2, TMP2, 1 - | b <1 - | - |.macro ffstring_case, name, lo - | .ffunc name - | ffgccheck - | cmplwi NARGS8:RC, 8 - | evldd CARG1, 0(BASE) - | blt ->fff_fallback - | checkstr STR:CARG1 - | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) - | checkfail ->fff_fallback - | lwz CARG3, STR:CARG1->len - | la CARG1, #STR(STR:CARG1) - | lwz CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) - | cmplw TMP1, CARG3 - | li TMP2, 0 - | blt ->fff_fallback - |1: // ASCII case conversion. - | cmplw TMP2, CARG3 - | lbzx TMP1, CARG1, TMP2 - | bge ->fff_newstr - | subi TMP0, TMP1, lo - | xori TMP3, TMP1, 0x20 - | cmplwi TMP0, 26 - | isellt TMP1, TMP3, TMP1 - | stbx TMP1, CARG2, TMP2 - | addi TMP2, TMP2, 1 - | b <1 - |.endmacro - | - |ffstring_case string_lower, 65 - |ffstring_case string_upper, 97 - | - |//-- Table library ------------------------------------------------------ - | - |.ffunc_1 table_getn - | checktab CARG1 - | checkfail ->fff_fallback - | bl extern lj_tab_len // (GCtab *t) - | // Returns uint32_t (but less than 2^31). - | efdcfsi CRET1, CRET1 - | b ->fff_restv - | - |//-- Bit library -------------------------------------------------------- - | - |.macro .ffunc_bit, name - | .ffunc_n bit_..name - | efdadd CARG1, CARG1, TOBIT - |.endmacro - | - |.ffunc_bit tobit - |->fff_resbit: - | efdcfsi CRET1, CARG1 - | b ->fff_restv - | - |.macro .ffunc_bit_op, name, ins - | .ffunc_bit name - | li TMP1, 8 - |1: - | evlddx CARG2, BASE, TMP1 - | cmplw cr1, TMP1, NARGS8:RC - | checknum CARG2 - | bge cr1, ->fff_resbit - | checkfail ->fff_fallback - | efdadd CARG2, CARG2, TOBIT - | ins CARG1, CARG1, CARG2 - | addi TMP1, TMP1, 8 - | b <1 - |.endmacro - | - |.ffunc_bit_op band, and - |.ffunc_bit_op bor, or - |.ffunc_bit_op bxor, xor - | - |.ffunc_bit bswap - | rotlwi TMP0, CARG1, 8 - | rlwimi TMP0, CARG1, 24, 0, 7 - | rlwimi TMP0, CARG1, 24, 16, 23 - | efdcfsi CRET1, TMP0 - | b ->fff_restv - | - |.ffunc_bit bnot - | not TMP0, CARG1 - | efdcfsi CRET1, TMP0 - | b ->fff_restv - | - |.macro .ffunc_bit_sh, name, ins, shmod - | .ffunc_nn bit_..name - | efdadd CARG2, CARG2, TOBIT - | efdadd CARG1, CARG1, TOBIT - |.if shmod == 1 - | rlwinm CARG2, CARG2, 0, 27, 31 - |.elif shmod == 2 - | neg CARG2, CARG2 - |.endif - | ins TMP0, CARG1, CARG2 - | efdcfsi CRET1, TMP0 - | b ->fff_restv - |.endmacro - | - |.ffunc_bit_sh lshift, slw, 1 - |.ffunc_bit_sh rshift, srw, 1 - |.ffunc_bit_sh arshift, sraw, 1 - |.ffunc_bit_sh rol, rotlw, 0 - |.ffunc_bit_sh ror, rotlw, 2 - | - |//----------------------------------------------------------------------- - | - |->fff_fallback: // Call fast function fallback handler. - | // BASE = new base, RB = CFUNC, RC = nargs*8 - | lwz TMP3, CFUNC:RB->f - | add TMP1, BASE, NARGS8:RC - | lwz PC, FRAME_PC(BASE) // Fallback may overwrite PC. - | addi TMP0, TMP1, 8*LUA_MINSTACK - | lwz TMP2, L->maxstack - | stw PC, SAVE_PC // Redundant (but a defined value). - | cmplw TMP0, TMP2 - | stw BASE, L->base - | stw TMP1, L->top - | mr CARG1, L - | bgt >5 // Need to grow stack. - | mtctr TMP3 - | bctrl // (lua_State *L) - | // Either throws an error, or recovers and returns -1, 0 or nresults+1. - | lwz BASE, L->base - | cmpwi CRET1, 0 - | slwi RD, CRET1, 3 - | la RA, -8(BASE) - | bgt ->fff_res // Returned nresults+1? - |1: // Returned 0 or -1: retry fast path. - | lwz TMP0, L->top - | lwz LFUNC:RB, FRAME_FUNC(BASE) - | sub NARGS8:RC, TMP0, BASE - | bne ->vm_call_tail // Returned -1? - | ins_callt // Returned 0: retry fast path. - | - |// Reconstruct previous base for vmeta_call during tailcall. - |->vm_call_tail: - | andi. TMP0, PC, FRAME_TYPE - | rlwinm TMP1, PC, 0, 0, 28 - | bne >3 - | lwz INS, -4(PC) - | decode_RA8 TMP1, INS - | addi TMP1, TMP1, 8 - |3: - | sub TMP2, BASE, TMP1 - | b ->vm_call_dispatch // Resolve again for tailcall. - | - |5: // Grow stack for fallback handler. - | li CARG2, LUA_MINSTACK - | bl extern lj_state_growstack // (lua_State *L, int n) - | lwz BASE, L->base - | cmpw TMP0, TMP0 // Set 4*cr0+eq to force retry. - | b <1 - | - |->fff_gcstep: // Call GC step function. - | // BASE = new base, RC = nargs*8 - | mflr SAVE0 - | stw BASE, L->base - | add TMP0, BASE, NARGS8:RC - | stw PC, SAVE_PC // Redundant (but a defined value). - | stw TMP0, L->top - | mr CARG1, L - | bl extern lj_gc_step // (lua_State *L) - | lwz BASE, L->base - | mtlr SAVE0 - | lwz TMP0, L->top - | sub NARGS8:RC, TMP0, BASE - | lwz CFUNC:RB, FRAME_FUNC(BASE) - | blr - | - |//----------------------------------------------------------------------- - |//-- Special dispatch targets ------------------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_record: // Dispatch target for recording phase. - |.if JIT - | NYI - |.endif - | - |->vm_rethook: // Dispatch target for return hooks. - | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) - | andi. TMP0, TMP3, HOOK_ACTIVE // Hook already active? - | beq >1 - |5: // Re-dispatch to static ins. - | addi TMP1, TMP1, GG_DISP2STATIC // Assumes decode_OP4 TMP1, INS. - | lwzx TMP0, DISPATCH, TMP1 - | mtctr TMP0 - | bctr - | - |->vm_inshook: // Dispatch target for instr/line hooks. - | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) - | lwz TMP2, DISPATCH_GL(hookcount)(DISPATCH) - | andi. TMP0, TMP3, HOOK_ACTIVE // Hook already active? - | rlwinm TMP0, TMP3, 31-LUA_HOOKLINE, 31, 0 - | bne <5 - | - | cmpwi cr1, TMP0, 0 - | addic. TMP2, TMP2, -1 - | beq cr1, <5 - | stw TMP2, DISPATCH_GL(hookcount)(DISPATCH) - | beq >1 - | bge cr1, <5 - |1: - | mr CARG1, L - | stw MULTRES, SAVE_MULTRES - | mr CARG2, PC - | stw BASE, L->base - | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. - | bl extern lj_dispatch_ins // (lua_State *L, const BCIns *pc) - |3: - | lwz BASE, L->base - |4: // Re-dispatch to static ins. - | lwz INS, -4(PC) - | decode_OP4 TMP1, INS - | decode_RB8 RB, INS - | addi TMP1, TMP1, GG_DISP2STATIC - | decode_RD8 RD, INS - | lwzx TMP0, DISPATCH, TMP1 - | decode_RA8 RA, INS - | decode_RC8 RC, INS - | mtctr TMP0 - | bctr - | - |->cont_hook: // Continue from hook yield. - | addi PC, PC, 4 - | lwz MULTRES, -20(RB) // Restore MULTRES for *M ins. - | b <4 - | - |->vm_hotloop: // Hot loop counter underflow. - |.if JIT - | NYI - |.endif - | - |->vm_callhook: // Dispatch target for call hooks. - | mr CARG2, PC - |.if JIT - | b >1 - |.endif - | - |->vm_hotcall: // Hot call counter underflow. - |.if JIT - | ori CARG2, PC, 1 - |1: - |.endif - | add TMP0, BASE, RC - | stw PC, SAVE_PC - | mr CARG1, L - | stw BASE, L->base - | sub RA, RA, BASE - | stw TMP0, L->top - | bl extern lj_dispatch_call // (lua_State *L, const BCIns *pc) - | // Returns ASMFunction. - | lwz BASE, L->base - | lwz TMP0, L->top - | stw ZERO, SAVE_PC // Invalidate for subsequent line hook. - | sub NARGS8:RC, TMP0, BASE - | add RA, BASE, RA - | lwz LFUNC:RB, FRAME_FUNC(BASE) - | mtctr CRET1 - | bctr - | - |//----------------------------------------------------------------------- - |//-- Trace exit handler ------------------------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_exit_handler: - |.if JIT - | NYI - |.endif - |->vm_exit_interp: - |.if JIT - | NYI - |.endif - | - |//----------------------------------------------------------------------- - |//-- Math helper functions ---------------------------------------------- - |//----------------------------------------------------------------------- - | - |// FP value rounding. Called by math.floor/math.ceil fast functions - |// and from JIT code. - |// - |// This can be inlined if the CPU has the frin/friz/frip/frim instructions. - |// The alternative hard-float approaches have a deep dependency chain. - |// The resulting latency is at least 3x-7x the double-precision FP latency - |// (e500v2: 6cy, e600: 5cy, Cell: 10cy) or around 20-70 cycles. - |// - |// The soft-float approach is tedious, but much faster (e500v2: ~11cy/~6cy). - |// However it relies on a fast way to transfer the FP value to GPRs - |// (e500v2: 0cy for lo-word, 1cy for hi-word). - |// - |.macro vm_round, name, mode - | // Used temporaries: TMP0, TMP1, TMP2, TMP3. - |->name.._efd: // Input: CARG2, output: CRET2 - | evmergehi CARG1, CARG2, CARG2 - |->name.._hilo: - | // Input: CARG1 (hi), CARG2 (hi, lo), output: CRET2 - | rlwinm TMP2, CARG1, 12, 21, 31 - | addic. TMP2, TMP2, -1023 // exp = exponent(x) - 1023 - | li TMP1, -1 - | cmplwi cr1, TMP2, 51 // 0 <= exp <= 51? - | subfic TMP0, TMP2, 52 - | bgt cr1, >1 - | lus TMP3, 0xfff0 - | slw TMP0, TMP1, TMP0 // lomask = -1 << (52-exp) - | sraw TMP1, TMP3, TMP2 // himask = (int32_t)0xfff00000 >> exp - |.if mode == 2 // trunc(x): - | evmergelo TMP0, TMP1, TMP0 - | evand CRET2, CARG2, TMP0 // hi &= himask, lo &= lomask - |.else - | andc TMP2, CARG2, TMP0 - | andc TMP3, CARG1, TMP1 - | or TMP2, TMP2, TMP3 // ztest = (hi&~himask) | (lo&~lomask) - | srawi TMP3, CARG1, 31 // signmask = (int32_t)hi >> 31 - |.if mode == 0 // floor(x): - | and. TMP2, TMP2, TMP3 // iszero = ((ztest & signmask) == 0) - |.else // ceil(x): - | andc. TMP2, TMP2, TMP3 // iszero = ((ztest & ~signmask) == 0) - |.endif - | and CARG2, CARG2, TMP0 // lo &= lomask - | and CARG1, CARG1, TMP1 // hi &= himask - | subc TMP0, CARG2, TMP0 - | iseleq TMP0, CARG2, TMP0 // lo = iszero ? lo : lo-lomask - | sube TMP1, CARG1, TMP1 - | iseleq TMP1, CARG1, TMP1 // hi = iszero ? hi : hi-himask+carry - | evmergelo CRET2, TMP1, TMP0 - |.endif - | blr - |1: - | bgtlr // Already done if >=2^52, +-inf or nan. - |.if mode == 2 // trunc(x): - | rlwinm TMP1, CARG1, 0, 0, 0 // hi = sign(x) - | li TMP0, 0 - | evmergelo CRET2, TMP1, TMP0 - |.else - | rlwinm TMP2, CARG1, 0, 1, 31 - | srawi TMP0, CARG1, 31 // signmask = (int32_t)hi >> 31 - | or TMP2, TMP2, CARG2 // ztest = abs(hi) | lo - | lus TMP1, 0x3ff0 - |.if mode == 0 // floor(x): - | and. TMP2, TMP2, TMP0 // iszero = ((ztest & signmask) == 0) - |.else // ceil(x): - | andc. TMP2, TMP2, TMP0 // iszero = ((ztest & ~signmask) == 0) - |.endif - | li TMP0, 0 - | iseleq TMP1, r0, TMP1 - | rlwimi CARG1, TMP1, 0, 1, 31 // hi = sign(x) | (iszero ? 0.0 : 1.0) - | evmergelo CRET2, CARG1, TMP0 - |.endif - | blr - |.endmacro - | - |->vm_floor: - | mflr CARG3 - | evmergelo CARG2, CARG1, CARG2 - | bl ->vm_floor_hilo - | mtlr CARG3 - | evmergehi CRET1, CRET2, CRET2 - | blr - | - | vm_round vm_floor, 0 - | vm_round vm_ceil, 1 - |.if JIT - | vm_round vm_trunc, 2 - |.else - |->vm_trunc_efd: - |->vm_trunc_hilo: - |.endif - | - |//----------------------------------------------------------------------- - |//-- Miscellaneous functions -------------------------------------------- - |//----------------------------------------------------------------------- - | - |//----------------------------------------------------------------------- - |//-- FFI helper functions ----------------------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_ffi_call: - |.if FFI - | NYI - |.endif - | - |//----------------------------------------------------------------------- -} - -/* Generate the code for a single instruction. */ -static void build_ins(BuildCtx *ctx, BCOp op, int defop) -{ - int vk = 0; - |=>defop: - - switch (op) { - - /* -- Comparison ops ---------------------------------------------------- */ - - /* Remember: all ops branch for a true comparison, fall through otherwise. */ - - case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: - | // RA = src1*8, RD = src2*8, JMP with RD = target - | evlddx TMP0, BASE, RA - | addi PC, PC, 4 - | evlddx TMP1, BASE, RD - | addis TMP3, PC, -(BCBIAS_J*4 >> 16) - | lwz TMP2, -4(PC) - | evmergehi RB, TMP0, TMP1 - | decode_RD4 TMP2, TMP2 - | checknum RB - | add TMP2, TMP2, TMP3 - | checkanyfail ->vmeta_comp - | efdcmplt TMP0, TMP1 - if (op == BC_ISLE || op == BC_ISGT) { - | efdcmpeq cr1, TMP0, TMP1 - | cror 4*cr0+gt, 4*cr0+gt, 4*cr1+gt - } - if (op == BC_ISLT || op == BC_ISLE) { - | iselgt PC, TMP2, PC - } else { - | iselgt PC, PC, TMP2 - } - | ins_next - break; - - case BC_ISEQV: case BC_ISNEV: - vk = op == BC_ISEQV; - | // RA = src1*8, RD = src2*8, JMP with RD = target - | evlddx CARG2, BASE, RA - | addi PC, PC, 4 - | evlddx CARG3, BASE, RD - | addis TMP3, PC, -(BCBIAS_J*4 >> 16) - | lwz TMP2, -4(PC) - | evmergehi RB, CARG2, CARG3 - | decode_RD4 TMP2, TMP2 - | checknum RB - | add TMP2, TMP2, TMP3 - | checkanyfail >5 - | efdcmpeq CARG2, CARG3 - if (vk) { - | iselgt PC, TMP2, PC - } else { - | iselgt PC, PC, TMP2 - } - |1: - | ins_next - | - |5: // Either or both types are not numbers. - | evcmpeq CARG2, CARG3 - | not TMP3, RB - | cmplwi cr1, TMP3, ~LJ_TISPRI // Primitive? - | crorc 4*cr7+lt, 4*cr0+so, 4*cr0+lt // 1: Same tv or different type. - | cmplwi cr6, TMP3, ~LJ_TISTABUD // Table or userdata? - | crandc 4*cr7+gt, 4*cr0+lt, 4*cr1+gt // 2: Same type and primitive. - | mr SAVE0, PC - if (vk) { - | isel PC, TMP2, PC, 4*cr7+gt - } else { - | isel TMP2, PC, TMP2, 4*cr7+gt - } - | cror 4*cr7+lt, 4*cr7+lt, 4*cr7+gt // 1 or 2. - if (vk) { - | isel PC, TMP2, PC, 4*cr0+so - } else { - | isel PC, PC, TMP2, 4*cr0+so - } - | blt cr7, <1 // Done if 1 or 2. - | blt cr6, <1 // Done if not tab/ud. - | - | // Different tables or userdatas. Need to check __eq metamethod. - | // Field metatable must be at same offset for GCtab and GCudata! - | lwz TAB:TMP2, TAB:CARG2->metatable - | li CARG4, 1-vk // ne = 0 or 1. - | cmplwi TAB:TMP2, 0 - | beq <1 // No metatable? - | lbz TMP2, TAB:TMP2->nomm - | andi. TMP2, TMP2, 1<vmeta_equal // Handle __eq metamethod. - break; - - case BC_ISEQS: case BC_ISNES: - vk = op == BC_ISEQS; - | // RA = src*8, RD = str_const*8 (~), JMP with RD = target - | evlddx TMP0, BASE, RA - | srwi RD, RD, 1 - | lwz INS, 0(PC) - | subfic RD, RD, -4 - | addi PC, PC, 4 - | lwzx STR:TMP1, KBASE, RD // KBASE-4-str_const*4 - | addis TMP3, PC, -(BCBIAS_J*4 >> 16) - | decode_RD4 TMP2, INS - | evmergelo STR:TMP1, TISSTR, STR:TMP1 - | add TMP2, TMP2, TMP3 - | evcmpeq TMP0, STR:TMP1 - if (vk) { - | isel PC, TMP2, PC, 4*cr0+so - } else { - | isel PC, PC, TMP2, 4*cr0+so - } - | ins_next - break; - - case BC_ISEQN: case BC_ISNEN: - vk = op == BC_ISEQN; - | // RA = src*8, RD = num_const*8, JMP with RD = target - | evlddx TMP0, BASE, RA - | addi PC, PC, 4 - | evlddx TMP1, KBASE, RD - | addis TMP3, PC, -(BCBIAS_J*4 >> 16) - | lwz INS, -4(PC) - | checknum TMP0 - | checkfail >5 - | efdcmpeq TMP0, TMP1 - |1: - | decode_RD4 TMP2, INS - | add TMP2, TMP2, TMP3 - if (vk) { - | iselgt PC, TMP2, PC - |5: - } else { - | iselgt PC, PC, TMP2 - } - |3: - | ins_next - if (!vk) { - |5: - | decode_RD4 TMP2, INS - | add PC, TMP2, TMP3 - | b <3 - } - break; - - case BC_ISEQP: case BC_ISNEP: - vk = op == BC_ISEQP; - | // RA = src*8, RD = primitive_type*8 (~), JMP with RD = target - | lwzx TMP0, BASE, RA - | srwi TMP1, RD, 3 - | lwz INS, 0(PC) - | addi PC, PC, 4 - | not TMP1, TMP1 - | addis TMP3, PC, -(BCBIAS_J*4 >> 16) - | cmplw TMP0, TMP1 - | decode_RD4 TMP2, INS - | add TMP2, TMP2, TMP3 - if (vk) { - | iseleq PC, TMP2, PC - } else { - | iseleq PC, PC, TMP2 - } - | ins_next - break; - - /* -- Unary test and copy ops ------------------------------------------- */ - - case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: - | // RA = dst*8 or unused, RD = src*8, JMP with RD = target - | evlddx TMP0, BASE, RD - | evaddw TMP1, TISNIL, TISNIL // Synthesize LJ_TFALSE. - | lwz INS, 0(PC) - | evcmpltu TMP0, TMP1 - | addi PC, PC, 4 - if (op == BC_IST || op == BC_ISF) { - | addis TMP3, PC, -(BCBIAS_J*4 >> 16) - | decode_RD4 TMP2, INS - | add TMP2, TMP2, TMP3 - if (op == BC_IST) { - | isellt PC, TMP2, PC - } else { - | isellt PC, PC, TMP2 - } - } else { - if (op == BC_ISTC) { - | checkfail >1 - } else { - | checkok >1 - } - | addis PC, PC, -(BCBIAS_J*4 >> 16) - | decode_RD4 TMP2, INS - | evstddx TMP0, BASE, RA - | add PC, PC, TMP2 - |1: - } - | ins_next - break; - - /* -- Unary ops --------------------------------------------------------- */ - - case BC_MOV: - | // RA = dst*8, RD = src*8 - | ins_next1 - | evlddx TMP0, BASE, RD - | evstddx TMP0, BASE, RA - | ins_next2 - break; - case BC_NOT: - | // RA = dst*8, RD = src*8 - | ins_next1 - | lwzx TMP0, BASE, RD - | subfic TMP1, TMP0, LJ_TTRUE - | adde TMP0, TMP0, TMP1 - | stwx TMP0, BASE, RA - | ins_next2 - break; - case BC_UNM: - | // RA = dst*8, RD = src*8 - | evlddx TMP0, BASE, RD - | checknum TMP0 - | checkfail ->vmeta_unm - | efdneg TMP0, TMP0 - | ins_next1 - | evstddx TMP0, BASE, RA - | ins_next2 - break; - case BC_LEN: - | // RA = dst*8, RD = src*8 - | evlddx CARG1, BASE, RD - | checkstr CARG1 - | checkfail >2 - | lwz CRET1, STR:CARG1->len - |1: - | ins_next1 - | efdcfsi TMP0, CRET1 - | evstddx TMP0, BASE, RA - | ins_next2 - |2: - | checktab CARG1 - | checkfail ->vmeta_len -#if LJ_52 - | lwz TAB:TMP2, TAB:CARG1->metatable - | cmplwi TAB:TMP2, 0 - | bne >9 - |3: -#endif - |->BC_LEN_Z: - | bl extern lj_tab_len // (GCtab *t) - | // Returns uint32_t (but less than 2^31). - | b <1 -#if LJ_52 - |9: - | lbz TMP0, TAB:TMP2->nomm - | andi. TMP0, TMP0, 1<vmeta_len -#endif - break; - - /* -- Binary ops -------------------------------------------------------- */ - - |.macro ins_arithpre, t0, t1 - | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 - ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); - ||switch (vk) { - ||case 0: - | evlddx t0, BASE, RB - | checknum t0 - | evlddx t1, KBASE, RC - | checkfail ->vmeta_arith_vn - || break; - ||case 1: - | evlddx t1, BASE, RB - | checknum t1 - | evlddx t0, KBASE, RC - | checkfail ->vmeta_arith_nv - || break; - ||default: - | evlddx t0, BASE, RB - | evlddx t1, BASE, RC - | evmergehi TMP2, t0, t1 - | checknum TMP2 - | checkanyfail ->vmeta_arith_vv - || break; - ||} - |.endmacro - | - |.macro ins_arith, ins - | ins_arithpre TMP0, TMP1 - | ins_next1 - | ins TMP0, TMP0, TMP1 - | evstddx TMP0, BASE, RA - | ins_next2 - |.endmacro - - case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: - | ins_arith efdadd - break; - case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: - | ins_arith efdsub - break; - case BC_MULVN: case BC_MULNV: case BC_MULVV: - | ins_arith efdmul - break; - case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: - | ins_arith efddiv - break; - case BC_MODVN: - | ins_arithpre RD, SAVE0 - |->BC_MODVN_Z: - | efddiv CARG2, RD, SAVE0 - | bl ->vm_floor_efd // floor(b/c) - | efdmul TMP0, CRET2, SAVE0 - | ins_next1 - | efdsub TMP0, RD, TMP0 // b - floor(b/c)*c - | evstddx TMP0, BASE, RA - | ins_next2 - break; - case BC_MODNV: case BC_MODVV: - | ins_arithpre RD, SAVE0 - | b ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. - break; - case BC_POW: - | evlddx CARG2, BASE, RB - | evlddx CARG4, BASE, RC - | evmergehi CARG1, CARG4, CARG2 - | checknum CARG1 - | evmergehi CARG3, CARG4, CARG4 - | checkanyfail ->vmeta_arith_vv - | bl extern pow@plt - | evmergelo CRET2, CRET1, CRET2 - | evstddx CRET2, BASE, RA - | ins_next - break; - - case BC_CAT: - | // RA = dst*8, RB = src_start*8, RC = src_end*8 - | sub CARG3, RC, RB - | stw BASE, L->base - | add CARG2, BASE, RC - | mr SAVE0, RB - |->BC_CAT_Z: - | stw PC, SAVE_PC - | mr CARG1, L - | srwi CARG3, CARG3, 3 - | bl extern lj_meta_cat // (lua_State *L, TValue *top, int left) - | // Returns NULL (finished) or TValue * (metamethod). - | cmplwi CRET1, 0 - | lwz BASE, L->base - | bne ->vmeta_binop - | evlddx TMP0, BASE, SAVE0 // Copy result from RB to RA. - | evstddx TMP0, BASE, RA - | ins_next - break; - - /* -- Constant ops ------------------------------------------------------ */ - - case BC_KSTR: - | // RA = dst*8, RD = str_const*8 (~) - | ins_next1 - | srwi TMP1, RD, 1 - | subfic TMP1, TMP1, -4 - | lwzx TMP0, KBASE, TMP1 // KBASE-4-str_const*4 - | evmergelo TMP0, TISSTR, TMP0 - | evstddx TMP0, BASE, RA - | ins_next2 - break; - case BC_KCDATA: - |.if FFI - | // RA = dst*8, RD = cdata_const*8 (~) - | ins_next1 - | srwi TMP1, RD, 1 - | subfic TMP1, TMP1, -4 - | lwzx TMP0, KBASE, TMP1 // KBASE-4-cdata_const*4 - | li TMP2, LJ_TCDATA - | evmergelo TMP0, TMP2, TMP0 - | evstddx TMP0, BASE, RA - | ins_next2 - |.endif - break; - case BC_KSHORT: - | // RA = dst*8, RD = int16_literal*8 - | srwi TMP1, RD, 3 - | extsh TMP1, TMP1 - | ins_next1 - | efdcfsi TMP0, TMP1 - | evstddx TMP0, BASE, RA - | ins_next2 - break; - case BC_KNUM: - | // RA = dst*8, RD = num_const*8 - | evlddx TMP0, KBASE, RD - | ins_next1 - | evstddx TMP0, BASE, RA - | ins_next2 - break; - case BC_KPRI: - | // RA = dst*8, RD = primitive_type*8 (~) - | srwi TMP1, RD, 3 - | not TMP0, TMP1 - | ins_next1 - | stwx TMP0, BASE, RA - | ins_next2 - break; - case BC_KNIL: - | // RA = base*8, RD = end*8 - | evstddx TISNIL, BASE, RA - | addi RA, RA, 8 - |1: - | evstddx TISNIL, BASE, RA - | cmpw RA, RD - | addi RA, RA, 8 - | blt <1 - | ins_next_ - break; - - /* -- Upvalue and function ops ------------------------------------------ */ - - case BC_UGET: - | // RA = dst*8, RD = uvnum*8 - | ins_next1 - | lwz LFUNC:RB, FRAME_FUNC(BASE) - | srwi RD, RD, 1 - | addi RD, RD, offsetof(GCfuncL, uvptr) - | lwzx UPVAL:RB, LFUNC:RB, RD - | lwz TMP1, UPVAL:RB->v - | evldd TMP0, 0(TMP1) - | evstddx TMP0, BASE, RA - | ins_next2 - break; - case BC_USETV: - | // RA = uvnum*8, RD = src*8 - | lwz LFUNC:RB, FRAME_FUNC(BASE) - | srwi RA, RA, 1 - | addi RA, RA, offsetof(GCfuncL, uvptr) - | evlddx TMP1, BASE, RD - | lwzx UPVAL:RB, LFUNC:RB, RA - | lbz TMP3, UPVAL:RB->marked - | lwz CARG2, UPVAL:RB->v - | andi. TMP3, TMP3, LJ_GC_BLACK // isblack(uv) - | lbz TMP0, UPVAL:RB->closed - | evmergehi TMP2, TMP1, TMP1 - | evstdd TMP1, 0(CARG2) - | cmplwi cr1, TMP0, 0 - | cror 4*cr0+eq, 4*cr0+eq, 4*cr1+eq - | subi TMP2, TMP2, (LJ_TISNUM+1) - | bne >2 // Upvalue is closed and black? - |1: - | ins_next - | - |2: // Check if new value is collectable. - | cmplwi TMP2, LJ_TISGCV - (LJ_TISNUM+1) - | bge <1 // tvisgcv(v) - | lbz TMP3, GCOBJ:TMP1->gch.marked - | andi. TMP3, TMP3, LJ_GC_WHITES // iswhite(v) - | la CARG1, GG_DISP2G(DISPATCH) - | // Crossed a write barrier. Move the barrier forward. - | beq <1 - | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) - | b <1 - break; - case BC_USETS: - | // RA = uvnum*8, RD = str_const*8 (~) - | lwz LFUNC:RB, FRAME_FUNC(BASE) - | srwi TMP1, RD, 1 - | srwi RA, RA, 1 - | subfic TMP1, TMP1, -4 - | addi RA, RA, offsetof(GCfuncL, uvptr) - | lwzx STR:TMP1, KBASE, TMP1 // KBASE-4-str_const*4 - | lwzx UPVAL:RB, LFUNC:RB, RA - | evmergelo STR:TMP1, TISSTR, STR:TMP1 - | lbz TMP3, UPVAL:RB->marked - | lwz CARG2, UPVAL:RB->v - | andi. TMP3, TMP3, LJ_GC_BLACK // isblack(uv) - | lbz TMP3, STR:TMP1->marked - | lbz TMP2, UPVAL:RB->closed - | evstdd STR:TMP1, 0(CARG2) - | bne >2 - |1: - | ins_next - | - |2: // Check if string is white and ensure upvalue is closed. - | andi. TMP3, TMP3, LJ_GC_WHITES // iswhite(str) - | cmplwi cr1, TMP2, 0 - | cror 4*cr0+eq, 4*cr0+eq, 4*cr1+eq - | la CARG1, GG_DISP2G(DISPATCH) - | // Crossed a write barrier. Move the barrier forward. - | beq <1 - | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) - | b <1 - break; - case BC_USETN: - | // RA = uvnum*8, RD = num_const*8 - | ins_next1 - | lwz LFUNC:RB, FRAME_FUNC(BASE) - | srwi RA, RA, 1 - | addi RA, RA, offsetof(GCfuncL, uvptr) - | evlddx TMP0, KBASE, RD - | lwzx UPVAL:RB, LFUNC:RB, RA - | lwz TMP1, UPVAL:RB->v - | evstdd TMP0, 0(TMP1) - | ins_next2 - break; - case BC_USETP: - | // RA = uvnum*8, RD = primitive_type*8 (~) - | ins_next1 - | lwz LFUNC:RB, FRAME_FUNC(BASE) - | srwi RA, RA, 1 - | addi RA, RA, offsetof(GCfuncL, uvptr) - | srwi TMP0, RD, 3 - | lwzx UPVAL:RB, LFUNC:RB, RA - | not TMP0, TMP0 - | lwz TMP1, UPVAL:RB->v - | stw TMP0, 0(TMP1) - | ins_next2 - break; - - case BC_UCLO: - | // RA = level*8, RD = target - | lwz TMP1, L->openupval - | branch_RD // Do this first since RD is not saved. - | stw BASE, L->base - | cmplwi TMP1, 0 - | mr CARG1, L - | beq >1 - | add CARG2, BASE, RA - | bl extern lj_func_closeuv // (lua_State *L, TValue *level) - | lwz BASE, L->base - |1: - | ins_next - break; - - case BC_FNEW: - | // RA = dst*8, RD = proto_const*8 (~) (holding function prototype) - | srwi TMP1, RD, 1 - | stw BASE, L->base - | subfic TMP1, TMP1, -4 - | stw PC, SAVE_PC - | lwzx CARG2, KBASE, TMP1 // KBASE-4-tab_const*4 - | mr CARG1, L - | lwz CARG3, FRAME_FUNC(BASE) - | // (lua_State *L, GCproto *pt, GCfuncL *parent) - | bl extern lj_func_newL_gc - | // Returns GCfuncL *. - | lwz BASE, L->base - | evmergelo LFUNC:CRET1, TISFUNC, LFUNC:CRET1 - | evstddx LFUNC:CRET1, BASE, RA - | ins_next - break; - - /* -- Table ops --------------------------------------------------------- */ - - case BC_TNEW: - case BC_TDUP: - | // RA = dst*8, RD = (hbits|asize)*8 | tab_const*8 (~) - | lwz TMP0, DISPATCH_GL(gc.total)(DISPATCH) - | mr CARG1, L - | lwz TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) - | stw BASE, L->base - | cmplw TMP0, TMP1 - | stw PC, SAVE_PC - | bge >5 - |1: - if (op == BC_TNEW) { - | rlwinm CARG2, RD, 29, 21, 31 - | rlwinm CARG3, RD, 18, 27, 31 - | cmpwi CARG2, 0x7ff - | li TMP1, 0x801 - | iseleq CARG2, TMP1, CARG2 - | bl extern lj_tab_new // (lua_State *L, int32_t asize, uint32_t hbits) - | // Returns Table *. - } else { - | srwi TMP1, RD, 1 - | subfic TMP1, TMP1, -4 - | lwzx CARG2, KBASE, TMP1 // KBASE-4-tab_const*4 - | bl extern lj_tab_dup // (lua_State *L, Table *kt) - | // Returns Table *. - } - | lwz BASE, L->base - | evmergelo TAB:CRET1, TISTAB, TAB:CRET1 - | evstddx TAB:CRET1, BASE, RA - | ins_next - |5: - | mr SAVE0, RD - | bl extern lj_gc_step_fixtop // (lua_State *L) - | mr RD, SAVE0 - | mr CARG1, L - | b <1 - break; - - case BC_GGET: - | // RA = dst*8, RD = str_const*8 (~) - case BC_GSET: - | // RA = src*8, RD = str_const*8 (~) - | lwz LFUNC:TMP2, FRAME_FUNC(BASE) - | srwi TMP1, RD, 1 - | lwz TAB:RB, LFUNC:TMP2->env - | subfic TMP1, TMP1, -4 - | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 - if (op == BC_GGET) { - | b ->BC_TGETS_Z - } else { - | b ->BC_TSETS_Z - } - break; - - case BC_TGETV: - | // RA = dst*8, RB = table*8, RC = key*8 - | evlddx TAB:RB, BASE, RB - | evlddx RC, BASE, RC - | checktab TAB:RB - | checkfail ->vmeta_tgetv - | checknum RC - | checkfail >5 - | // Convert number key to integer - | efdctsi TMP2, RC - | lwz TMP0, TAB:RB->asize - | efdcfsi TMP1, TMP2 - | cmplw cr0, TMP0, TMP2 - | efdcmpeq cr1, RC, TMP1 - | lwz TMP1, TAB:RB->array - | crand 4*cr0+gt, 4*cr0+gt, 4*cr1+gt - | slwi TMP2, TMP2, 3 - | ble ->vmeta_tgetv // Integer key and in array part? - | evlddx TMP1, TMP1, TMP2 - | checknil TMP1 - | checkok >2 - |1: - | evstddx TMP1, BASE, RA - | ins_next - | - |2: // Check for __index if table value is nil. - | lwz TAB:TMP2, TAB:RB->metatable - | cmplwi TAB:TMP2, 0 - | beq <1 // No metatable: done. - | lbz TMP0, TAB:TMP2->nomm - | andi. TMP0, TMP0, 1<vmeta_tgetv - | - |5: - | checkstr STR:RC // String key? - | checkok ->BC_TGETS_Z - | b ->vmeta_tgetv - break; - case BC_TGETS: - | // RA = dst*8, RB = table*8, RC = str_const*8 (~) - | evlddx TAB:RB, BASE, RB - | srwi TMP1, RC, 1 - | checktab TAB:RB - | subfic TMP1, TMP1, -4 - | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 - | checkfail ->vmeta_tgets1 - |->BC_TGETS_Z: - | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = dst*8 - | lwz TMP0, TAB:RB->hmask - | lwz TMP1, STR:RC->hash - | lwz NODE:TMP2, TAB:RB->node - | evmergelo STR:RC, TISSTR, STR:RC - | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask - | slwi TMP0, TMP1, 5 - | slwi TMP1, TMP1, 3 - | sub TMP1, TMP0, TMP1 - | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) - |1: - | evldd TMP0, NODE:TMP2->key - | evldd TMP1, NODE:TMP2->val - | evcmpeq TMP0, STR:RC - | checkanyfail >4 - | checknil TMP1 - | checkok >5 // Key found, but nil value? - |3: - | evstddx TMP1, BASE, RA - | ins_next - | - |4: // Follow hash chain. - | lwz NODE:TMP2, NODE:TMP2->next - | cmplwi NODE:TMP2, 0 - | bne <1 - | // End of hash chain: key not found, nil result. - | evmr TMP1, TISNIL - | - |5: // Check for __index if table value is nil. - | lwz TAB:TMP2, TAB:RB->metatable - | cmplwi TAB:TMP2, 0 - | beq <3 // No metatable: done. - | lbz TMP0, TAB:TMP2->nomm - | andi. TMP0, TMP0, 1<vmeta_tgets - break; - case BC_TGETB: - | // RA = dst*8, RB = table*8, RC = index*8 - | evlddx TAB:RB, BASE, RB - | srwi TMP0, RC, 3 - | checktab TAB:RB - | checkfail ->vmeta_tgetb - | lwz TMP1, TAB:RB->asize - | lwz TMP2, TAB:RB->array - | cmplw TMP0, TMP1 - | bge ->vmeta_tgetb - | evlddx TMP1, TMP2, RC - | checknil TMP1 - | checkok >5 - |1: - | ins_next1 - | evstddx TMP1, BASE, RA - | ins_next2 - | - |5: // Check for __index if table value is nil. - | lwz TAB:TMP2, TAB:RB->metatable - | cmplwi TAB:TMP2, 0 - | beq <1 // No metatable: done. - | lbz TMP2, TAB:TMP2->nomm - | andi. TMP2, TMP2, 1<vmeta_tgetb // Caveat: preserve TMP0! - break; - - case BC_TSETV: - | // RA = src*8, RB = table*8, RC = key*8 - | evlddx TAB:RB, BASE, RB - | evlddx RC, BASE, RC - | checktab TAB:RB - | checkfail ->vmeta_tsetv - | checknum RC - | checkfail >5 - | // Convert number key to integer - | efdctsi TMP2, RC - | evlddx SAVE0, BASE, RA - | lwz TMP0, TAB:RB->asize - | efdcfsi TMP1, TMP2 - | cmplw cr0, TMP0, TMP2 - | efdcmpeq cr1, RC, TMP1 - | lwz TMP1, TAB:RB->array - | crand 4*cr0+gt, 4*cr0+gt, 4*cr1+gt - | slwi TMP0, TMP2, 3 - | ble ->vmeta_tsetv // Integer key and in array part? - | lbz TMP3, TAB:RB->marked - | evlddx TMP2, TMP1, TMP0 - | checknil TMP2 - | checkok >3 - |1: - | andi. TMP2, TMP3, LJ_GC_BLACK // isblack(table) - | evstddx SAVE0, TMP1, TMP0 - | bne >7 - |2: - | ins_next - | - |3: // Check for __newindex if previous value is nil. - | lwz TAB:TMP2, TAB:RB->metatable - | cmplwi TAB:TMP2, 0 - | beq <1 // No metatable: done. - | lbz TMP2, TAB:TMP2->nomm - | andi. TMP2, TMP2, 1<vmeta_tsetv - | - |5: - | checkstr STR:RC // String key? - | checkok ->BC_TSETS_Z - | b ->vmeta_tsetv - | - |7: // Possible table write barrier for the value. Skip valiswhite check. - | barrierback TAB:RB, TMP3, TMP0 - | b <2 - break; - case BC_TSETS: - | // RA = src*8, RB = table*8, RC = str_const*8 (~) - | evlddx TAB:RB, BASE, RB - | srwi TMP1, RC, 1 - | checktab TAB:RB - | subfic TMP1, TMP1, -4 - | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 - | checkfail ->vmeta_tsets1 - |->BC_TSETS_Z: - | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = src*8 - | lwz TMP0, TAB:RB->hmask - | lwz TMP1, STR:RC->hash - | lwz NODE:TMP2, TAB:RB->node - | evmergelo STR:RC, TISSTR, STR:RC - | stb ZERO, TAB:RB->nomm // Clear metamethod cache. - | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask - | evlddx SAVE0, BASE, RA - | slwi TMP0, TMP1, 5 - | slwi TMP1, TMP1, 3 - | sub TMP1, TMP0, TMP1 - | lbz TMP3, TAB:RB->marked - | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) - |1: - | evldd TMP0, NODE:TMP2->key - | evldd TMP1, NODE:TMP2->val - | evcmpeq TMP0, STR:RC - | checkanyfail >5 - | checknil TMP1 - | checkok >4 // Key found, but nil value? - |2: - | andi. TMP0, TMP3, LJ_GC_BLACK // isblack(table) - | evstdd SAVE0, NODE:TMP2->val - | bne >7 - |3: - | ins_next - | - |4: // Check for __newindex if previous value is nil. - | lwz TAB:TMP1, TAB:RB->metatable - | cmplwi TAB:TMP1, 0 - | beq <2 // No metatable: done. - | lbz TMP0, TAB:TMP1->nomm - | andi. TMP0, TMP0, 1<vmeta_tsets - | - |5: // Follow hash chain. - | lwz NODE:TMP2, NODE:TMP2->next - | cmplwi NODE:TMP2, 0 - | bne <1 - | // End of hash chain: key not found, add a new one. - | - | // But check for __newindex first. - | lwz TAB:TMP1, TAB:RB->metatable - | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) - | stw PC, SAVE_PC - | mr CARG1, L - | cmplwi TAB:TMP1, 0 - | stw BASE, L->base - | beq >6 // No metatable: continue. - | lbz TMP0, TAB:TMP1->nomm - | andi. TMP0, TMP0, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. - |6: - | mr CARG2, TAB:RB - | evstdd STR:RC, 0(CARG3) - | bl extern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k) - | // Returns TValue *. - | lwz BASE, L->base - | evstdd SAVE0, 0(CRET1) - | b <3 // No 2nd write barrier needed. - | - |7: // Possible table write barrier for the value. Skip valiswhite check. - | barrierback TAB:RB, TMP3, TMP0 - | b <3 - break; - case BC_TSETB: - | // RA = src*8, RB = table*8, RC = index*8 - | evlddx TAB:RB, BASE, RB - | srwi TMP0, RC, 3 - | checktab TAB:RB - | checkfail ->vmeta_tsetb - | lwz TMP1, TAB:RB->asize - | lwz TMP2, TAB:RB->array - | lbz TMP3, TAB:RB->marked - | cmplw TMP0, TMP1 - | evlddx SAVE0, BASE, RA - | bge ->vmeta_tsetb - | evlddx TMP1, TMP2, RC - | checknil TMP1 - | checkok >5 - |1: - | andi. TMP0, TMP3, LJ_GC_BLACK // isblack(table) - | evstddx SAVE0, TMP2, RC - | bne >7 - |2: - | ins_next - | - |5: // Check for __newindex if previous value is nil. - | lwz TAB:TMP1, TAB:RB->metatable - | cmplwi TAB:TMP1, 0 - | beq <1 // No metatable: done. - | lbz TMP1, TAB:TMP1->nomm - | andi. TMP1, TMP1, 1<vmeta_tsetb // Caveat: preserve TMP0! - | - |7: // Possible table write barrier for the value. Skip valiswhite check. - | barrierback TAB:RB, TMP3, TMP0 - | b <2 - break; - - case BC_TSETM: - | // RA = base*8 (table at base-1), RD = num_const*8 (start index) - | add RA, BASE, RA - |1: - | add TMP3, KBASE, RD - | lwz TAB:CARG2, -4(RA) // Guaranteed to be a table. - | addic. TMP0, MULTRES, -8 - | lwz TMP3, 4(TMP3) // Integer constant is in lo-word. - | srwi CARG3, TMP0, 3 - | beq >4 // Nothing to copy? - | add CARG3, CARG3, TMP3 - | lwz TMP2, TAB:CARG2->asize - | slwi TMP1, TMP3, 3 - | lbz TMP3, TAB:CARG2->marked - | cmplw CARG3, TMP2 - | add TMP2, RA, TMP0 - | lwz TMP0, TAB:CARG2->array - | bgt >5 - | add TMP1, TMP1, TMP0 - | andi. TMP0, TMP3, LJ_GC_BLACK // isblack(table) - |3: // Copy result slots to table. - | evldd TMP0, 0(RA) - | addi RA, RA, 8 - | cmpw cr1, RA, TMP2 - | evstdd TMP0, 0(TMP1) - | addi TMP1, TMP1, 8 - | blt cr1, <3 - | bne >7 - |4: - | ins_next - | - |5: // Need to resize array part. - | stw BASE, L->base - | mr CARG1, L - | stw PC, SAVE_PC - | mr SAVE0, RD - | bl extern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) - | // Must not reallocate the stack. - | mr RD, SAVE0 - | b <1 - | - |7: // Possible table write barrier for any value. Skip valiswhite check. - | barrierback TAB:CARG2, TMP3, TMP0 - | b <4 - break; - - /* -- Calls and vararg handling ----------------------------------------- */ - - case BC_CALLM: - | // RA = base*8, (RB = (nresults+1)*8,) RC = extra_nargs*8 - | add NARGS8:RC, NARGS8:RC, MULTRES - | // Fall through. Assumes BC_CALL follows. - break; - case BC_CALL: - | // RA = base*8, (RB = (nresults+1)*8,) RC = (nargs+1)*8 - | evlddx LFUNC:RB, BASE, RA - | mr TMP2, BASE - | add BASE, BASE, RA - | subi NARGS8:RC, NARGS8:RC, 8 - | checkfunc LFUNC:RB - | addi BASE, BASE, 8 - | checkfail ->vmeta_call - | ins_call - break; - - case BC_CALLMT: - | // RA = base*8, (RB = 0,) RC = extra_nargs*8 - | add NARGS8:RC, NARGS8:RC, MULTRES - | // Fall through. Assumes BC_CALLT follows. - break; - case BC_CALLT: - | // RA = base*8, (RB = 0,) RC = (nargs+1)*8 - | evlddx LFUNC:RB, BASE, RA - | add RA, BASE, RA - | lwz TMP1, FRAME_PC(BASE) - | subi NARGS8:RC, NARGS8:RC, 8 - | checkfunc LFUNC:RB - | addi RA, RA, 8 - | checkfail ->vmeta_callt - |->BC_CALLT_Z: - | andi. TMP0, TMP1, FRAME_TYPE // Caveat: preserve cr0 until the crand. - | lbz TMP3, LFUNC:RB->ffid - | xori TMP2, TMP1, FRAME_VARG - | cmplwi cr1, NARGS8:RC, 0 - | bne >7 - |1: - | stw LFUNC:RB, FRAME_FUNC(BASE) // Copy function down, but keep PC. - | li TMP2, 0 - | cmplwi cr7, TMP3, 1 // (> FF_C) Calling a fast function? - | beq cr1, >3 - |2: - | addi TMP3, TMP2, 8 - | evlddx TMP0, RA, TMP2 - | cmplw cr1, TMP3, NARGS8:RC - | evstddx TMP0, BASE, TMP2 - | mr TMP2, TMP3 - | bne cr1, <2 - |3: - | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+gt - | beq >5 - |4: - | ins_callt - | - |5: // Tailcall to a fast function with a Lua frame below. - | lwz INS, -4(TMP1) - | decode_RA8 RA, INS - | sub TMP1, BASE, RA - | lwz LFUNC:TMP1, FRAME_FUNC-8(TMP1) - | lwz TMP1, LFUNC:TMP1->pc - | lwz KBASE, PC2PROTO(k)(TMP1) // Need to prepare KBASE. - | b <4 - | - |7: // Tailcall from a vararg function. - | andi. TMP0, TMP2, FRAME_TYPEP - | bne <1 // Vararg frame below? - | sub BASE, BASE, TMP2 // Relocate BASE down. - | lwz TMP1, FRAME_PC(BASE) - | andi. TMP0, TMP1, FRAME_TYPE - | b <1 - break; - - case BC_ITERC: - | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 ((2+1)*8)) - | subi RA, RA, 24 // evldd doesn't support neg. offsets. - | mr TMP2, BASE - | evlddx LFUNC:RB, BASE, RA - | add BASE, BASE, RA - | evldd TMP0, 8(BASE) - | evldd TMP1, 16(BASE) - | evstdd LFUNC:RB, 24(BASE) // Copy callable. - | checkfunc LFUNC:RB - | evstdd TMP0, 32(BASE) // Copy state. - | li NARGS8:RC, 16 // Iterators get 2 arguments. - | evstdd TMP1, 40(BASE) // Copy control var. - | addi BASE, BASE, 32 - | checkfail ->vmeta_call - | ins_call - break; - - case BC_ITERN: - | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 (2+1)*8) - |.if JIT - | // NYI: add hotloop, record BC_ITERN. - |.endif - | add RA, BASE, RA - | lwz TAB:RB, -12(RA) - | lwz RC, -4(RA) // Get index from control var. - | lwz TMP0, TAB:RB->asize - | lwz TMP1, TAB:RB->array - | addi PC, PC, 4 - |1: // Traverse array part. - | cmplw RC, TMP0 - | slwi TMP3, RC, 3 - | bge >5 // Index points after array part? - | evlddx TMP2, TMP1, TMP3 - | checknil TMP2 - | lwz INS, -4(PC) - | checkok >4 - | efdcfsi TMP0, RC - | addi RC, RC, 1 - | addis TMP3, PC, -(BCBIAS_J*4 >> 16) - | evstdd TMP2, 8(RA) - | decode_RD4 TMP1, INS - | stw RC, -4(RA) // Update control var. - | add PC, TMP1, TMP3 - | evstdd TMP0, 0(RA) - |3: - | ins_next - | - |4: // Skip holes in array part. - | addi RC, RC, 1 - | b <1 - | - |5: // Traverse hash part. - | lwz TMP1, TAB:RB->hmask - | sub RC, RC, TMP0 - | lwz TMP2, TAB:RB->node - |6: - | cmplw RC, TMP1 // End of iteration? Branch to ITERL+1. - | slwi TMP3, RC, 5 - | bgt <3 - | slwi RB, RC, 3 - | sub TMP3, TMP3, RB - | evlddx RB, TMP2, TMP3 - | add NODE:TMP3, TMP2, TMP3 - | checknil RB - | lwz INS, -4(PC) - | checkok >7 - | evldd TMP3, NODE:TMP3->key - | addis TMP2, PC, -(BCBIAS_J*4 >> 16) - | evstdd RB, 8(RA) - | add RC, RC, TMP0 - | decode_RD4 TMP1, INS - | evstdd TMP3, 0(RA) - | addi RC, RC, 1 - | add PC, TMP1, TMP2 - | stw RC, -4(RA) // Update control var. - | b <3 - | - |7: // Skip holes in hash part. - | addi RC, RC, 1 - | b <6 - break; - - case BC_ISNEXT: - | // RA = base*8, RD = target (points to ITERN) - | add RA, BASE, RA - | li TMP2, -24 - | evlddx CFUNC:TMP1, RA, TMP2 - | lwz TMP2, -16(RA) - | lwz TMP3, -8(RA) - | evmergehi TMP0, CFUNC:TMP1, CFUNC:TMP1 - | cmpwi cr0, TMP2, LJ_TTAB - | cmpwi cr1, TMP0, LJ_TFUNC - | cmpwi cr6, TMP3, LJ_TNIL - | bne cr1, >5 - | lbz TMP1, CFUNC:TMP1->ffid - | crand 4*cr0+eq, 4*cr0+eq, 4*cr6+eq - | cmpwi cr7, TMP1, FF_next_N - | srwi TMP0, RD, 1 - | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+eq - | add TMP3, PC, TMP0 - | bne cr0, >5 - | lus TMP1, 0xfffe - | ori TMP1, TMP1, 0x7fff - | stw ZERO, -4(RA) // Initialize control var. - | stw TMP1, -8(RA) - | addis PC, TMP3, -(BCBIAS_J*4 >> 16) - |1: - | ins_next - |5: // Despecialize bytecode if any of the checks fail. - | li TMP0, BC_JMP - | li TMP1, BC_ITERC - | stb TMP0, -1(PC) - | addis PC, TMP3, -(BCBIAS_J*4 >> 16) - | stb TMP1, 3(PC) - | b <1 - break; - - case BC_VARG: - | // RA = base*8, RB = (nresults+1)*8, RC = numparams*8 - | lwz TMP0, FRAME_PC(BASE) - | add RC, BASE, RC - | add RA, BASE, RA - | addi RC, RC, FRAME_VARG - | add TMP2, RA, RB - | subi TMP3, BASE, 8 // TMP3 = vtop - | sub RC, RC, TMP0 // RC = vbase - | // Note: RC may now be even _above_ BASE if nargs was < numparams. - | cmplwi cr1, RB, 0 - | sub. TMP1, TMP3, RC - | beq cr1, >5 // Copy all varargs? - | subi TMP2, TMP2, 16 - | ble >2 // No vararg slots? - |1: // Copy vararg slots to destination slots. - | evldd TMP0, 0(RC) - | addi RC, RC, 8 - | evstdd TMP0, 0(RA) - | cmplw RA, TMP2 - | cmplw cr1, RC, TMP3 - | bge >3 // All destination slots filled? - | addi RA, RA, 8 - | blt cr1, <1 // More vararg slots? - |2: // Fill up remainder with nil. - | evstdd TISNIL, 0(RA) - | cmplw RA, TMP2 - | addi RA, RA, 8 - | blt <2 - |3: - | ins_next - | - |5: // Copy all varargs. - | lwz TMP0, L->maxstack - | li MULTRES, 8 // MULTRES = (0+1)*8 - | ble <3 // No vararg slots? - | add TMP2, RA, TMP1 - | cmplw TMP2, TMP0 - | addi MULTRES, TMP1, 8 - | bgt >7 - |6: - | evldd TMP0, 0(RC) - | addi RC, RC, 8 - | evstdd TMP0, 0(RA) - | cmplw RC, TMP3 - | addi RA, RA, 8 - | blt <6 // More vararg slots? - | b <3 - | - |7: // Grow stack for varargs. - | mr CARG1, L - | stw RA, L->top - | sub SAVE0, RC, BASE // Need delta, because BASE may change. - | stw BASE, L->base - | sub RA, RA, BASE - | stw PC, SAVE_PC - | srwi CARG2, TMP1, 3 - | bl extern lj_state_growstack // (lua_State *L, int n) - | lwz BASE, L->base - | add RA, BASE, RA - | add RC, BASE, SAVE0 - | subi TMP3, BASE, 8 - | b <6 - break; - - /* -- Returns ----------------------------------------------------------- */ - - case BC_RETM: - | // RA = results*8, RD = extra_nresults*8 - | add RD, RD, MULTRES // MULTRES >= 8, so RD >= 8. - | // Fall through. Assumes BC_RET follows. - break; - - case BC_RET: - | // RA = results*8, RD = (nresults+1)*8 - | lwz PC, FRAME_PC(BASE) - | add RA, BASE, RA - | mr MULTRES, RD - |1: - | andi. TMP0, PC, FRAME_TYPE - | xori TMP1, PC, FRAME_VARG - | bne ->BC_RETV_Z - | - |->BC_RET_Z: - | // BASE = base, RA = resultptr, RD = (nresults+1)*8, PC = return - | lwz INS, -4(PC) - | cmpwi RD, 8 - | subi TMP2, BASE, 8 - | subi RC, RD, 8 - | decode_RB8 RB, INS - | beq >3 - | li TMP1, 0 - |2: - | addi TMP3, TMP1, 8 - | evlddx TMP0, RA, TMP1 - | cmpw TMP3, RC - | evstddx TMP0, TMP2, TMP1 - | beq >3 - | addi TMP1, TMP3, 8 - | evlddx TMP0, RA, TMP3 - | cmpw TMP1, RC - | evstddx TMP0, TMP2, TMP3 - | bne <2 - |3: - |5: - | cmplw RB, RD - | decode_RA8 RA, INS - | bgt >6 - | sub BASE, TMP2, RA - | lwz LFUNC:TMP1, FRAME_FUNC(BASE) - | ins_next1 - | lwz TMP1, LFUNC:TMP1->pc - | lwz KBASE, PC2PROTO(k)(TMP1) - | ins_next2 - | - |6: // Fill up results with nil. - | subi TMP1, RD, 8 - | addi RD, RD, 8 - | evstddx TISNIL, TMP2, TMP1 - | b <5 - | - |->BC_RETV_Z: // Non-standard return case. - | andi. TMP2, TMP1, FRAME_TYPEP - | bne ->vm_return - | // Return from vararg function: relocate BASE down. - | sub BASE, BASE, TMP1 - | lwz PC, FRAME_PC(BASE) - | b <1 - break; - - case BC_RET0: case BC_RET1: - | // RA = results*8, RD = (nresults+1)*8 - | lwz PC, FRAME_PC(BASE) - | add RA, BASE, RA - | mr MULTRES, RD - | andi. TMP0, PC, FRAME_TYPE - | xori TMP1, PC, FRAME_VARG - | bne ->BC_RETV_Z - | - | lwz INS, -4(PC) - | subi TMP2, BASE, 8 - | decode_RB8 RB, INS - if (op == BC_RET1) { - | evldd TMP0, 0(RA) - | evstdd TMP0, 0(TMP2) - } - |5: - | cmplw RB, RD - | decode_RA8 RA, INS - | bgt >6 - | sub BASE, TMP2, RA - | lwz LFUNC:TMP1, FRAME_FUNC(BASE) - | ins_next1 - | lwz TMP1, LFUNC:TMP1->pc - | lwz KBASE, PC2PROTO(k)(TMP1) - | ins_next2 - | - |6: // Fill up results with nil. - | subi TMP1, RD, 8 - | addi RD, RD, 8 - | evstddx TISNIL, TMP2, TMP1 - | b <5 - break; - - /* -- Loops and branches ------------------------------------------------ */ - - case BC_FORL: - |.if JIT - | hotloop - |.endif - | // Fall through. Assumes BC_IFORL follows. - break; - - case BC_JFORI: - case BC_JFORL: -#if !LJ_HASJIT - break; -#endif - case BC_FORI: - case BC_IFORL: - | // RA = base*8, RD = target (after end of loop or start of loop) - vk = (op == BC_IFORL || op == BC_JFORL); - | add RA, BASE, RA - | evldd TMP1, FORL_IDX*8(RA) - | evldd TMP3, FORL_STEP*8(RA) - | evldd TMP2, FORL_STOP*8(RA) - if (!vk) { - | evcmpgtu cr0, TMP1, TISNUM - | evcmpgtu cr7, TMP3, TISNUM - | evcmpgtu cr1, TMP2, TISNUM - | cror 4*cr0+lt, 4*cr0+lt, 4*cr7+lt - | cror 4*cr0+lt, 4*cr0+lt, 4*cr1+lt - | blt ->vmeta_for - } - if (vk) { - | efdadd TMP1, TMP1, TMP3 - | evstdd TMP1, FORL_IDX*8(RA) - } - | evcmpgts TMP3, TISNIL - | evstdd TMP1, FORL_EXT*8(RA) - | bge >2 - | efdcmpgt TMP1, TMP2 - |1: - if (op != BC_JFORL) { - | srwi RD, RD, 1 - | add RD, PC, RD - if (op == BC_JFORI) { - | addis PC, RD, -(BCBIAS_J*4 >> 16) - } else { - | addis RD, RD, -(BCBIAS_J*4 >> 16) - } - } - if (op == BC_FORI) { - | iselgt PC, RD, PC - } else if (op == BC_IFORL) { - | iselgt PC, PC, RD - } else { - | ble =>BC_JLOOP - } - | ins_next - |2: - | efdcmpgt TMP2, TMP1 - | b <1 - break; - - case BC_ITERL: - |.if JIT - | hotloop - |.endif - | // Fall through. Assumes BC_IITERL follows. - break; - - case BC_JITERL: -#if !LJ_HASJIT - break; -#endif - case BC_IITERL: - | // RA = base*8, RD = target - | evlddx TMP1, BASE, RA - | subi RA, RA, 8 - | checknil TMP1 - | checkok >1 // Stop if iterator returned nil. - if (op == BC_JITERL) { - | NYI - } else { - | branch_RD // Otherwise save control var + branch. - | evstddx TMP1, BASE, RA - } - |1: - | ins_next - break; - - case BC_LOOP: - | // RA = base*8, RD = target (loop extent) - | // Note: RA/RD is only used by trace recorder to determine scope/extent - | // This opcode does NOT jump, it's only purpose is to detect a hot loop. - |.if JIT - | hotloop - |.endif - | // Fall through. Assumes BC_ILOOP follows. - break; - - case BC_ILOOP: - | // RA = base*8, RD = target (loop extent) - | ins_next - break; - - case BC_JLOOP: - |.if JIT - | NYI - |.endif - break; - - case BC_JMP: - | // RA = base*8 (only used by trace recorder), RD = target - | branch_RD - | ins_next - break; - - /* -- Function headers -------------------------------------------------- */ - - case BC_FUNCF: - |.if JIT - | hotcall - |.endif - case BC_FUNCV: /* NYI: compiled vararg functions. */ - | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow. - break; - - case BC_JFUNCF: -#if !LJ_HASJIT - break; -#endif - case BC_IFUNCF: - | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 - | lwz TMP2, L->maxstack - | lbz TMP1, -4+PC2PROTO(numparams)(PC) - | lwz KBASE, -4+PC2PROTO(k)(PC) - | cmplw RA, TMP2 - | slwi TMP1, TMP1, 3 - | bgt ->vm_growstack_l - | ins_next1 - |2: - | cmplw NARGS8:RC, TMP1 // Check for missing parameters. - | ble >3 - if (op == BC_JFUNCF) { - | NYI - } else { - | ins_next2 - } - | - |3: // Clear missing parameters. - | evstddx TISNIL, BASE, NARGS8:RC - | addi NARGS8:RC, NARGS8:RC, 8 - | b <2 - break; - - case BC_JFUNCV: -#if !LJ_HASJIT - break; -#endif - | NYI // NYI: compiled vararg functions - break; /* NYI: compiled vararg functions. */ - - case BC_IFUNCV: - | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 - | lwz TMP2, L->maxstack - | add TMP1, BASE, RC - | add TMP0, RA, RC - | stw LFUNC:RB, 4(TMP1) // Store copy of LFUNC. - | addi TMP3, RC, 8+FRAME_VARG - | lwz KBASE, -4+PC2PROTO(k)(PC) - | cmplw TMP0, TMP2 - | stw TMP3, 0(TMP1) // Store delta + FRAME_VARG. - | bge ->vm_growstack_l - | lbz TMP2, -4+PC2PROTO(numparams)(PC) - | mr RA, BASE - | mr RC, TMP1 - | ins_next1 - | cmpwi TMP2, 0 - | addi BASE, TMP1, 8 - | beq >3 - |1: - | cmplw RA, RC // Less args than parameters? - | evldd TMP0, 0(RA) - | bge >4 - | evstdd TISNIL, 0(RA) // Clear old fixarg slot (help the GC). - | addi RA, RA, 8 - |2: - | addic. TMP2, TMP2, -1 - | evstdd TMP0, 8(TMP1) - | addi TMP1, TMP1, 8 - | bne <1 - |3: - | ins_next2 - | - |4: // Clear missing parameters. - | evmr TMP0, TISNIL - | b <2 - break; - - case BC_FUNCC: - case BC_FUNCCW: - | // BASE = new base, RA = BASE+framesize*8, RB = CFUNC, RC = nargs*8 - if (op == BC_FUNCC) { - | lwz TMP3, CFUNC:RB->f - } else { - | lwz TMP3, DISPATCH_GL(wrapf)(DISPATCH) - } - | add TMP1, RA, NARGS8:RC - | lwz TMP2, L->maxstack - | add RC, BASE, NARGS8:RC - | stw BASE, L->base - | cmplw TMP1, TMP2 - | stw RC, L->top - | li_vmstate C - | mtctr TMP3 - if (op == BC_FUNCCW) { - | lwz CARG2, CFUNC:RB->f - } - | mr CARG1, L - | bgt ->vm_growstack_c // Need to grow stack. - | st_vmstate - | bctrl // (lua_State *L [, lua_CFunction f]) - | // Returns nresults. - | lwz TMP1, L->top - | slwi RD, CRET1, 3 - | lwz BASE, L->base - | li_vmstate INTERP - | lwz PC, FRAME_PC(BASE) // Fetch PC of caller. - | sub RA, TMP1, RD // RA = L->top - nresults*8 - | st_vmstate - | b ->vm_returnc - break; - - /* ---------------------------------------------------------------------- */ - - default: - fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); - exit(2); - break; - } -} - -static int build_backend(BuildCtx *ctx) -{ - int op; - - dasm_growpc(Dst, BC__MAX); - - build_subroutines(ctx); - - |.code_op - for (op = 0; op < BC__MAX; op++) - build_ins(ctx, (BCOp)op, op); - - return BC__MAX; -} - -/* Emit pseudo frame-info for all assembler functions. */ -static void emit_asm_debug(BuildCtx *ctx) -{ - int i; - switch (ctx->mode) { - case BUILD_elfasm: - fprintf(ctx->fp, "\t.section .debug_frame,\"\",@progbits\n"); - fprintf(ctx->fp, - ".Lframe0:\n" - "\t.long .LECIE0-.LSCIE0\n" - ".LSCIE0:\n" - "\t.long 0xffffffff\n" - "\t.byte 0x1\n" - "\t.string \"\"\n" - "\t.uleb128 0x1\n" - "\t.sleb128 -4\n" - "\t.byte 65\n" - "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" - "\t.align 2\n" - ".LECIE0:\n\n"); - fprintf(ctx->fp, - ".LSFDE0:\n" - "\t.long .LEFDE0-.LASFDE0\n" - ".LASFDE0:\n" - "\t.long .Lframe0\n" - "\t.long .Lbegin\n" - "\t.long %d\n" - "\t.byte 0xe\n\t.uleb128 %d\n" - "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" - "\t.byte 0x5\n\t.uleb128 70\n\t.sleb128 37\n", - (int)ctx->codesz, CFRAME_SIZE); - for (i = 14; i <= 31; i++) - fprintf(ctx->fp, - "\t.byte %d\n\t.uleb128 %d\n" - "\t.byte 5\n\t.uleb128 %d\n\t.uleb128 %d\n", - 0x80+i, 1+2*(31-i), 1200+i, 2+2*(31-i)); - fprintf(ctx->fp, - "\t.align 2\n" - ".LEFDE0:\n\n"); - fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n"); - fprintf(ctx->fp, - ".Lframe1:\n" - "\t.long .LECIE1-.LSCIE1\n" - ".LSCIE1:\n" - "\t.long 0\n" - "\t.byte 0x1\n" - "\t.string \"zPR\"\n" - "\t.uleb128 0x1\n" - "\t.sleb128 -4\n" - "\t.byte 65\n" - "\t.uleb128 6\n" /* augmentation length */ - "\t.byte 0x1b\n" /* pcrel|sdata4 */ - "\t.long lj_err_unwind_dwarf-.\n" - "\t.byte 0x1b\n" /* pcrel|sdata4 */ - "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" - "\t.align 2\n" - ".LECIE1:\n\n"); - fprintf(ctx->fp, - ".LSFDE1:\n" - "\t.long .LEFDE1-.LASFDE1\n" - ".LASFDE1:\n" - "\t.long .LASFDE1-.Lframe1\n" - "\t.long .Lbegin-.\n" - "\t.long %d\n" - "\t.uleb128 0\n" /* augmentation length */ - "\t.byte 0xe\n\t.uleb128 %d\n" - "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" - "\t.byte 0x5\n\t.uleb128 70\n\t.sleb128 37\n", - (int)ctx->codesz, CFRAME_SIZE); - for (i = 14; i <= 31; i++) - fprintf(ctx->fp, - "\t.byte %d\n\t.uleb128 %d\n" - "\t.byte 5\n\t.uleb128 %d\n\t.uleb128 %d\n", - 0x80+i, 1+2*(31-i), 1200+i, 2+2*(31-i)); - fprintf(ctx->fp, - "\t.align 2\n" - ".LEFDE1:\n\n"); - break; - default: - break; - } -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/vm_x86.dasc b/source/libs/luajit/LuaJIT-2.0.3/src/vm_x86.dasc deleted file mode 100644 index 8a9b536df..000000000 --- a/source/libs/luajit/LuaJIT-2.0.3/src/vm_x86.dasc +++ /dev/null @@ -1,6374 +0,0 @@ -|// Low-level VM code for x86 CPUs. -|// Bytecode interpreter, fast functions and helper functions. -|// Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h -| -|.if P64 -|.arch x64 -|.else -|.arch x86 -|.endif -|.section code_op, code_sub -| -|.actionlist build_actionlist -|.globals GLOB_ -|.globalnames globnames -|.externnames extnames -| -|//----------------------------------------------------------------------- -| -|.if P64 -|.define X64, 1 -|.define SSE, 1 -|.if WIN -|.define X64WIN, 1 -|.endif -|.endif -| -|// Fixed register assignments for the interpreter. -|// This is very fragile and has many dependencies. Caveat emptor. -|.define BASE, edx // Not C callee-save, refetched anyway. -|.if not X64 -|.define KBASE, edi // Must be C callee-save. -|.define KBASEa, KBASE -|.define PC, esi // Must be C callee-save. -|.define PCa, PC -|.define DISPATCH, ebx // Must be C callee-save. -|.elif X64WIN -|.define KBASE, edi // Must be C callee-save. -|.define KBASEa, rdi -|.define PC, esi // Must be C callee-save. -|.define PCa, rsi -|.define DISPATCH, ebx // Must be C callee-save. -|.else -|.define KBASE, r15d // Must be C callee-save. -|.define KBASEa, r15 -|.define PC, ebx // Must be C callee-save. -|.define PCa, rbx -|.define DISPATCH, r14d // Must be C callee-save. -|.endif -| -|.define RA, ecx -|.define RAH, ch -|.define RAL, cl -|.define RB, ebp // Must be ebp (C callee-save). -|.define RC, eax // Must be eax. -|.define RCW, ax -|.define RCH, ah -|.define RCL, al -|.define OP, RB -|.define RD, RC -|.define RDW, RCW -|.define RDL, RCL -|.if X64 -|.define RAa, rcx -|.define RBa, rbp -|.define RCa, rax -|.define RDa, rax -|.else -|.define RAa, RA -|.define RBa, RB -|.define RCa, RC -|.define RDa, RD -|.endif -| -|.if not X64 -|.define FCARG1, ecx // x86 fastcall arguments. -|.define FCARG2, edx -|.elif X64WIN -|.define CARG1, rcx // x64/WIN64 C call arguments. -|.define CARG2, rdx -|.define CARG3, r8 -|.define CARG4, r9 -|.define CARG1d, ecx -|.define CARG2d, edx -|.define CARG3d, r8d -|.define CARG4d, r9d -|.define FCARG1, CARG1d // Upwards compatible to x86 fastcall. -|.define FCARG2, CARG2d -|.else -|.define CARG1, rdi // x64/POSIX C call arguments. -|.define CARG2, rsi -|.define CARG3, rdx -|.define CARG4, rcx -|.define CARG5, r8 -|.define CARG6, r9 -|.define CARG1d, edi -|.define CARG2d, esi -|.define CARG3d, edx -|.define CARG4d, ecx -|.define CARG5d, r8d -|.define CARG6d, r9d -|.define FCARG1, CARG1d // Simulate x86 fastcall. -|.define FCARG2, CARG2d -|.endif -| -|// Type definitions. Some of these are only used for documentation. -|.type L, lua_State -|.type GL, global_State -|.type TVALUE, TValue -|.type GCOBJ, GCobj -|.type STR, GCstr -|.type TAB, GCtab -|.type LFUNC, GCfuncL -|.type CFUNC, GCfuncC -|.type PROTO, GCproto -|.type UPVAL, GCupval -|.type NODE, Node -|.type NARGS, int -|.type TRACE, GCtrace -| -|// Stack layout while in interpreter. Must match with lj_frame.h. -|//----------------------------------------------------------------------- -|.if not X64 // x86 stack layout. -| -|.define CFRAME_SPACE, aword*7 // Delta for esp (see <--). -|.macro saveregs_ -| push edi; push esi; push ebx -| sub esp, CFRAME_SPACE -|.endmacro -|.macro saveregs -| push ebp; saveregs_ -|.endmacro -|.macro restoreregs -| add esp, CFRAME_SPACE -| pop ebx; pop esi; pop edi; pop ebp -|.endmacro -| -|.define SAVE_ERRF, aword [esp+aword*15] // vm_pcall/vm_cpcall only. -|.define SAVE_NRES, aword [esp+aword*14] -|.define SAVE_CFRAME, aword [esp+aword*13] -|.define SAVE_L, aword [esp+aword*12] -|//----- 16 byte aligned, ^^^ arguments from C caller -|.define SAVE_RET, aword [esp+aword*11] //<-- esp entering interpreter. -|.define SAVE_R4, aword [esp+aword*10] -|.define SAVE_R3, aword [esp+aword*9] -|.define SAVE_R2, aword [esp+aword*8] -|//----- 16 byte aligned -|.define SAVE_R1, aword [esp+aword*7] //<-- esp after register saves. -|.define SAVE_PC, aword [esp+aword*6] -|.define TMP2, aword [esp+aword*5] -|.define TMP1, aword [esp+aword*4] -|//----- 16 byte aligned -|.define ARG4, aword [esp+aword*3] -|.define ARG3, aword [esp+aword*2] -|.define ARG2, aword [esp+aword*1] -|.define ARG1, aword [esp] //<-- esp while in interpreter. -|//----- 16 byte aligned, ^^^ arguments for C callee -| -|// FPARGx overlaps ARGx and ARG(x+1) on x86. -|.define FPARG3, qword [esp+qword*1] -|.define FPARG1, qword [esp] -|// TMPQ overlaps TMP1/TMP2. ARG5/MULTRES overlap TMP1/TMP2 (and TMPQ). -|.define TMPQ, qword [esp+aword*4] -|.define TMP3, ARG4 -|.define ARG5, TMP1 -|.define TMPa, TMP1 -|.define MULTRES, TMP2 -| -|// Arguments for vm_call and vm_pcall. -|.define INARG_BASE, SAVE_CFRAME // Overwritten by SAVE_CFRAME! -| -|// Arguments for vm_cpcall. -|.define INARG_CP_CALL, SAVE_ERRF -|.define INARG_CP_UD, SAVE_NRES -|.define INARG_CP_FUNC, SAVE_CFRAME -| -|//----------------------------------------------------------------------- -|.elif X64WIN // x64/Windows stack layout -| -|.define CFRAME_SPACE, aword*5 // Delta for rsp (see <--). -|.macro saveregs_ -| push rdi; push rsi; push rbx -| sub rsp, CFRAME_SPACE -|.endmacro -|.macro saveregs -| push rbp; saveregs_ -|.endmacro -|.macro restoreregs -| add rsp, CFRAME_SPACE -| pop rbx; pop rsi; pop rdi; pop rbp -|.endmacro -| -|.define SAVE_CFRAME, aword [rsp+aword*13] -|.define SAVE_PC, dword [rsp+dword*25] -|.define SAVE_L, dword [rsp+dword*24] -|.define SAVE_ERRF, dword [rsp+dword*23] -|.define SAVE_NRES, dword [rsp+dword*22] -|.define TMP2, dword [rsp+dword*21] -|.define TMP1, dword [rsp+dword*20] -|//----- 16 byte aligned, ^^^ 32 byte register save area, owned by interpreter -|.define SAVE_RET, aword [rsp+aword*9] //<-- rsp entering interpreter. -|.define SAVE_R4, aword [rsp+aword*8] -|.define SAVE_R3, aword [rsp+aword*7] -|.define SAVE_R2, aword [rsp+aword*6] -|.define SAVE_R1, aword [rsp+aword*5] //<-- rsp after register saves. -|.define ARG5, aword [rsp+aword*4] -|.define CSAVE_4, aword [rsp+aword*3] -|.define CSAVE_3, aword [rsp+aword*2] -|.define CSAVE_2, aword [rsp+aword*1] -|.define CSAVE_1, aword [rsp] //<-- rsp while in interpreter. -|//----- 16 byte aligned, ^^^ 32 byte register save area, owned by callee -| -|// TMPQ overlaps TMP1/TMP2. MULTRES overlaps TMP2 (and TMPQ). -|.define TMPQ, qword [rsp+aword*10] -|.define MULTRES, TMP2 -|.define TMPa, ARG5 -|.define ARG5d, dword [rsp+aword*4] -|.define TMP3, ARG5d -| -|//----------------------------------------------------------------------- -|.else // x64/POSIX stack layout -| -|.define CFRAME_SPACE, aword*5 // Delta for rsp (see <--). -|.macro saveregs_ -| push rbx; push r15; push r14 -| sub rsp, CFRAME_SPACE -|.endmacro -|.macro saveregs -| push rbp; saveregs_ -|.endmacro -|.macro restoreregs -| add rsp, CFRAME_SPACE -| pop r14; pop r15; pop rbx; pop rbp -|.endmacro -| -|//----- 16 byte aligned, -|.define SAVE_RET, aword [rsp+aword*9] //<-- rsp entering interpreter. -|.define SAVE_R4, aword [rsp+aword*8] -|.define SAVE_R3, aword [rsp+aword*7] -|.define SAVE_R2, aword [rsp+aword*6] -|.define SAVE_R1, aword [rsp+aword*5] //<-- rsp after register saves. -|.define SAVE_CFRAME, aword [rsp+aword*4] -|.define SAVE_PC, dword [rsp+dword*7] -|.define SAVE_L, dword [rsp+dword*6] -|.define SAVE_ERRF, dword [rsp+dword*5] -|.define SAVE_NRES, dword [rsp+dword*4] -|.define TMPa, aword [rsp+aword*1] -|.define TMP2, dword [rsp+dword*1] -|.define TMP1, dword [rsp] //<-- rsp while in interpreter. -|//----- 16 byte aligned -| -|// TMPQ overlaps TMP1/TMP2. MULTRES overlaps TMP2 (and TMPQ). -|.define TMPQ, qword [rsp] -|.define TMP3, dword [rsp+aword*1] -|.define MULTRES, TMP2 -| -|.endif -| -|//----------------------------------------------------------------------- -| -|// Instruction headers. -|.macro ins_A; .endmacro -|.macro ins_AD; .endmacro -|.macro ins_AJ; .endmacro -|.macro ins_ABC; movzx RB, RCH; movzx RC, RCL; .endmacro -|.macro ins_AB_; movzx RB, RCH; .endmacro -|.macro ins_A_C; movzx RC, RCL; .endmacro -|.macro ins_AND; not RDa; .endmacro -| -|// Instruction decode+dispatch. Carefully tuned (nope, lodsd is not faster). -|.macro ins_NEXT -| mov RC, [PC] -| movzx RA, RCH -| movzx OP, RCL -| add PC, 4 -| shr RC, 16 -|.if X64 -| jmp aword [DISPATCH+OP*8] -|.else -| jmp aword [DISPATCH+OP*4] -|.endif -|.endmacro -| -|// Instruction footer. -|.if 1 -| // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. -| .define ins_next, ins_NEXT -| .define ins_next_, ins_NEXT -|.else -| // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. -| // Affects only certain kinds of benchmarks (and only with -j off). -| // Around 10%-30% slower on Core2, a lot more slower on P4. -| .macro ins_next -| jmp ->ins_next -| .endmacro -| .macro ins_next_ -| ->ins_next: -| ins_NEXT -| .endmacro -|.endif -| -|// Call decode and dispatch. -|.macro ins_callt -| // BASE = new base, RB = LFUNC, RD = nargs+1, [BASE-4] = PC -| mov PC, LFUNC:RB->pc -| mov RA, [PC] -| movzx OP, RAL -| movzx RA, RAH -| add PC, 4 -|.if X64 -| jmp aword [DISPATCH+OP*8] -|.else -| jmp aword [DISPATCH+OP*4] -|.endif -|.endmacro -| -|.macro ins_call -| // BASE = new base, RB = LFUNC, RD = nargs+1 -| mov [BASE-4], PC -| ins_callt -|.endmacro -| -|//----------------------------------------------------------------------- -| -|// Macros to test operand types. -|.macro checktp, reg, tp; cmp dword [BASE+reg*8+4], tp; .endmacro -|.macro checknum, reg, target; checktp reg, LJ_TISNUM; jae target; .endmacro -|.macro checkint, reg, target; checktp reg, LJ_TISNUM; jne target; .endmacro -|.macro checkstr, reg, target; checktp reg, LJ_TSTR; jne target; .endmacro -|.macro checktab, reg, target; checktp reg, LJ_TTAB; jne target; .endmacro -| -|// These operands must be used with movzx. -|.define PC_OP, byte [PC-4] -|.define PC_RA, byte [PC-3] -|.define PC_RB, byte [PC-1] -|.define PC_RC, byte [PC-2] -|.define PC_RD, word [PC-2] -| -|.macro branchPC, reg -| lea PC, [PC+reg*4-BCBIAS_J*4] -|.endmacro -| -|// Assumes DISPATCH is relative to GL. -#define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) -#define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) -| -#define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) -| -|// Decrement hashed hotcount and trigger trace recorder if zero. -|.macro hotloop, reg -| mov reg, PC -| shr reg, 1 -| and reg, HOTCOUNT_PCMASK -| sub word [DISPATCH+reg+GG_DISP2HOT], HOTCOUNT_LOOP -| jb ->vm_hotloop -|.endmacro -| -|.macro hotcall, reg -| mov reg, PC -| shr reg, 1 -| and reg, HOTCOUNT_PCMASK -| sub word [DISPATCH+reg+GG_DISP2HOT], HOTCOUNT_CALL -| jb ->vm_hotcall -|.endmacro -| -|// Set current VM state. -|.macro set_vmstate, st -| mov dword [DISPATCH+DISPATCH_GL(vmstate)], ~LJ_VMST_..st -|.endmacro -| -|// x87 compares. -|.macro fcomparepp // Compare and pop st0 >< st1. -| fucomip st1 -| fpop -|.endmacro -| -|.macro fdup; fld st0; .endmacro -|.macro fpop1; fstp st1; .endmacro -| -|// Synthesize SSE FP constants. -|.macro sseconst_abs, reg, tmp // Synthesize abs mask. -|.if X64 -| mov64 tmp, U64x(7fffffff,ffffffff); movd reg, tmp -|.else -| pxor reg, reg; pcmpeqd reg, reg; psrlq reg, 1 -|.endif -|.endmacro -| -|.macro sseconst_hi, reg, tmp, val // Synthesize hi-32 bit const. -|.if X64 -| mov64 tmp, U64x(val,00000000); movd reg, tmp -|.else -| mov tmp, 0x .. val; movd reg, tmp; pshufd reg, reg, 0x51 -|.endif -|.endmacro -| -|.macro sseconst_sign, reg, tmp // Synthesize sign mask. -| sseconst_hi reg, tmp, 80000000 -|.endmacro -|.macro sseconst_1, reg, tmp // Synthesize 1.0. -| sseconst_hi reg, tmp, 3ff00000 -|.endmacro -|.macro sseconst_m1, reg, tmp // Synthesize -1.0. -| sseconst_hi reg, tmp, bff00000 -|.endmacro -|.macro sseconst_2p52, reg, tmp // Synthesize 2^52. -| sseconst_hi reg, tmp, 43300000 -|.endmacro -|.macro sseconst_tobit, reg, tmp // Synthesize 2^52 + 2^51. -| sseconst_hi reg, tmp, 43380000 -|.endmacro -| -|// Move table write barrier back. Overwrites reg. -|.macro barrierback, tab, reg -| and byte tab->marked, (uint8_t)~LJ_GC_BLACK // black2gray(tab) -| mov reg, [DISPATCH+DISPATCH_GL(gc.grayagain)] -| mov [DISPATCH+DISPATCH_GL(gc.grayagain)], tab -| mov tab->gclist, reg -|.endmacro -| -|//----------------------------------------------------------------------- - -/* Generate subroutines used by opcodes and other parts of the VM. */ -/* The .code_sub section should be last to help static branch prediction. */ -static void build_subroutines(BuildCtx *ctx) -{ - |.code_sub - | - |//----------------------------------------------------------------------- - |//-- Return handling ---------------------------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_returnp: - | test PC, FRAME_P - | jz ->cont_dispatch - | - | // Return from pcall or xpcall fast func. - | and PC, -8 - | sub BASE, PC // Restore caller base. - | lea RAa, [RA+PC-8] // Rebase RA and prepend one result. - | mov PC, [BASE-4] // Fetch PC of previous frame. - | // Prepending may overwrite the pcall frame, so do it at the end. - | mov dword [BASE+RA+4], LJ_TTRUE // Prepend true to results. - | - |->vm_returnc: - | add RD, 1 // RD = nresults+1 - | jz ->vm_unwind_yield - | mov MULTRES, RD - | test PC, FRAME_TYPE - | jz ->BC_RET_Z // Handle regular return to Lua. - | - |->vm_return: - | // BASE = base, RA = resultofs, RD = nresults+1 (= MULTRES), PC = return - | xor PC, FRAME_C - | test PC, FRAME_TYPE - | jnz ->vm_returnp - | - | // Return to C. - | set_vmstate C - | and PC, -8 - | sub PC, BASE - | neg PC // Previous base = BASE - delta. - | - | sub RD, 1 - | jz >2 - |1: // Move results down. - |.if X64 - | mov RBa, [BASE+RA] - | mov [BASE-8], RBa - |.else - | mov RB, [BASE+RA] - | mov [BASE-8], RB - | mov RB, [BASE+RA+4] - | mov [BASE-4], RB - |.endif - | add BASE, 8 - | sub RD, 1 - | jnz <1 - |2: - | mov L:RB, SAVE_L - | mov L:RB->base, PC - |3: - | mov RD, MULTRES - | mov RA, SAVE_NRES // RA = wanted nresults+1 - |4: - | cmp RA, RD - | jne >6 // More/less results wanted? - |5: - | sub BASE, 8 - | mov L:RB->top, BASE - | - |->vm_leave_cp: - | mov RAa, SAVE_CFRAME // Restore previous C frame. - | mov L:RB->cframe, RAa - | xor eax, eax // Ok return status for vm_pcall. - | - |->vm_leave_unw: - | restoreregs - | ret - | - |6: - | jb >7 // Less results wanted? - | // More results wanted. Check stack size and fill up results with nil. - | cmp BASE, L:RB->maxstack - | ja >8 - | mov dword [BASE-4], LJ_TNIL - | add BASE, 8 - | add RD, 1 - | jmp <4 - | - |7: // Less results wanted. - | test RA, RA - | jz <5 // But check for LUA_MULTRET+1. - | sub RA, RD // Negative result! - | lea BASE, [BASE+RA*8] // Correct top. - | jmp <5 - | - |8: // Corner case: need to grow stack for filling up results. - | // This can happen if: - | // - A C function grows the stack (a lot). - | // - The GC shrinks the stack in between. - | // - A return back from a lua_call() with (high) nresults adjustment. - | mov L:RB->top, BASE // Save current top held in BASE (yes). - | mov MULTRES, RD // Need to fill only remainder with nil. - | mov FCARG2, RA - | mov FCARG1, L:RB - | call extern lj_state_growstack@8 // (lua_State *L, int n) - | mov BASE, L:RB->top // Need the (realloced) L->top in BASE. - | jmp <3 - | - |->vm_unwind_yield: - | mov al, LUA_YIELD - | jmp ->vm_unwind_c_eh - | - |->vm_unwind_c@8: // Unwind C stack, return from vm_pcall. - | // (void *cframe, int errcode) - |.if X64 - | mov eax, CARG2d // Error return status for vm_pcall. - | mov rsp, CARG1 - |.else - | mov eax, FCARG2 // Error return status for vm_pcall. - | mov esp, FCARG1 - |.endif - |->vm_unwind_c_eh: // Landing pad for external unwinder. - | mov L:RB, SAVE_L - | mov GL:RB, L:RB->glref - | mov dword GL:RB->vmstate, ~LJ_VMST_C - | jmp ->vm_leave_unw - | - |->vm_unwind_rethrow: - |.if X64 and not X64WIN - | mov FCARG1, SAVE_L - | mov FCARG2, eax - | restoreregs - | jmp extern lj_err_throw@8 // (lua_State *L, int errcode) - |.endif - | - |->vm_unwind_ff@4: // Unwind C stack, return from ff pcall. - | // (void *cframe) - |.if X64 - | and CARG1, CFRAME_RAWMASK - | mov rsp, CARG1 - |.else - | and FCARG1, CFRAME_RAWMASK - | mov esp, FCARG1 - |.endif - |->vm_unwind_ff_eh: // Landing pad for external unwinder. - | mov L:RB, SAVE_L - | mov RAa, -8 // Results start at BASE+RA = BASE-8. - | mov RD, 1+1 // Really 1+2 results, incr. later. - | mov BASE, L:RB->base - | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table. - | add DISPATCH, GG_G2DISP - | mov PC, [BASE-4] // Fetch PC of previous frame. - | mov dword [BASE-4], LJ_TFALSE // Prepend false to error message. - | set_vmstate INTERP - | jmp ->vm_returnc // Increments RD/MULTRES and returns. - | - |//----------------------------------------------------------------------- - |//-- Grow stack for calls ----------------------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_growstack_c: // Grow stack for C function. - | mov FCARG2, LUA_MINSTACK - | jmp >2 - | - |->vm_growstack_v: // Grow stack for vararg Lua function. - | sub RD, 8 - | jmp >1 - | - |->vm_growstack_f: // Grow stack for fixarg Lua function. - | // BASE = new base, RD = nargs+1, RB = L, PC = first PC - | lea RD, [BASE+NARGS:RD*8-8] - |1: - | movzx RA, byte [PC-4+PC2PROTO(framesize)] - | add PC, 4 // Must point after first instruction. - | mov L:RB->base, BASE - | mov L:RB->top, RD - | mov SAVE_PC, PC - | mov FCARG2, RA - |2: - | // RB = L, L->base = new base, L->top = top - | mov FCARG1, L:RB - | call extern lj_state_growstack@8 // (lua_State *L, int n) - | mov BASE, L:RB->base - | mov RD, L:RB->top - | mov LFUNC:RB, [BASE-8] - | sub RD, BASE - | shr RD, 3 - | add NARGS:RD, 1 - | // BASE = new base, RB = LFUNC, RD = nargs+1 - | ins_callt // Just retry the call. - | - |//----------------------------------------------------------------------- - |//-- Entry points into the assembler VM --------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_resume: // Setup C frame and resume thread. - | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) - | saveregs - |.if X64 - | mov L:RB, CARG1d // Caveat: CARG1d may be RA. - | mov SAVE_L, CARG1d - | mov RA, CARG2d - |.else - | mov L:RB, SAVE_L - | mov RA, INARG_BASE // Caveat: overlaps SAVE_CFRAME! - |.endif - | mov PC, FRAME_CP - | xor RD, RD - | lea KBASEa, [esp+CFRAME_RESUME] - | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table. - | add DISPATCH, GG_G2DISP - | mov L:RB->cframe, KBASEa - | mov SAVE_PC, RD // Any value outside of bytecode is ok. - | mov SAVE_CFRAME, RDa - |.if X64 - | mov SAVE_NRES, RD - | mov SAVE_ERRF, RD - |.endif - | cmp byte L:RB->status, RDL - | je >3 // Initial resume (like a call). - | - | // Resume after yield (like a return). - | set_vmstate INTERP - | mov byte L:RB->status, RDL - | mov BASE, L:RB->base - | mov RD, L:RB->top - | sub RD, RA - | shr RD, 3 - | add RD, 1 // RD = nresults+1 - | sub RA, BASE // RA = resultofs - | mov PC, [BASE-4] - | mov MULTRES, RD - | test PC, FRAME_TYPE - | jz ->BC_RET_Z - | jmp ->vm_return - | - |->vm_pcall: // Setup protected C frame and enter VM. - | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) - | saveregs - | mov PC, FRAME_CP - |.if X64 - | mov SAVE_ERRF, CARG4d - |.endif - | jmp >1 - | - |->vm_call: // Setup C frame and enter VM. - | // (lua_State *L, TValue *base, int nres1) - | saveregs - | mov PC, FRAME_C - | - |1: // Entry point for vm_pcall above (PC = ftype). - |.if X64 - | mov SAVE_NRES, CARG3d - | mov L:RB, CARG1d // Caveat: CARG1d may be RA. - | mov SAVE_L, CARG1d - | mov RA, CARG2d - |.else - | mov L:RB, SAVE_L - | mov RA, INARG_BASE // Caveat: overlaps SAVE_CFRAME! - |.endif - | - | mov KBASEa, L:RB->cframe // Add our C frame to cframe chain. - | mov SAVE_CFRAME, KBASEa - | mov SAVE_PC, L:RB // Any value outside of bytecode is ok. - |.if X64 - | mov L:RB->cframe, rsp - |.else - | mov L:RB->cframe, esp - |.endif - | - |2: // Entry point for vm_cpcall below (RA = base, RB = L, PC = ftype). - | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table. - | add DISPATCH, GG_G2DISP - | - |3: // Entry point for vm_resume above (RA = base, RB = L, PC = ftype). - | set_vmstate INTERP - | mov BASE, L:RB->base // BASE = old base (used in vmeta_call). - | add PC, RA - | sub PC, BASE // PC = frame delta + frame type - | - | mov RD, L:RB->top - | sub RD, RA - | shr NARGS:RD, 3 - | add NARGS:RD, 1 // RD = nargs+1 - | - |->vm_call_dispatch: - | mov LFUNC:RB, [RA-8] - | cmp dword [RA-4], LJ_TFUNC - | jne ->vmeta_call // Ensure KBASE defined and != BASE. - | - |->vm_call_dispatch_f: - | mov BASE, RA - | ins_call - | // BASE = new base, RB = func, RD = nargs+1, PC = caller PC - | - |->vm_cpcall: // Setup protected C frame, call C. - | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) - | saveregs - |.if X64 - | mov L:RB, CARG1d // Caveat: CARG1d may be RA. - | mov SAVE_L, CARG1d - |.else - | mov L:RB, SAVE_L - | // Caveat: INARG_CP_* and SAVE_CFRAME/SAVE_NRES/SAVE_ERRF overlap! - | mov RC, INARG_CP_UD // Get args before they are overwritten. - | mov RA, INARG_CP_FUNC - | mov BASE, INARG_CP_CALL - |.endif - | mov SAVE_PC, L:RB // Any value outside of bytecode is ok. - | - | mov KBASE, L:RB->stack // Compute -savestack(L, L->top). - | sub KBASE, L:RB->top - | mov SAVE_ERRF, 0 // No error function. - | mov SAVE_NRES, KBASE // Neg. delta means cframe w/o frame. - | // Handler may change cframe_nres(L->cframe) or cframe_errfunc(L->cframe). - | - |.if X64 - | mov KBASEa, L:RB->cframe // Add our C frame to cframe chain. - | mov SAVE_CFRAME, KBASEa - | mov L:RB->cframe, rsp - | - | call CARG4 // (lua_State *L, lua_CFunction func, void *ud) - |.else - | mov ARG3, RC // Have to copy args downwards. - | mov ARG2, RA - | mov ARG1, L:RB - | - | mov KBASE, L:RB->cframe // Add our C frame to cframe chain. - | mov SAVE_CFRAME, KBASE - | mov L:RB->cframe, esp - | - | call BASE // (lua_State *L, lua_CFunction func, void *ud) - |.endif - | // TValue * (new base) or NULL returned in eax (RC). - | test RC, RC - | jz ->vm_leave_cp // No base? Just remove C frame. - | mov RA, RC - | mov PC, FRAME_CP - | jmp <2 // Else continue with the call. - | - |//----------------------------------------------------------------------- - |//-- Metamethod handling ------------------------------------------------ - |//----------------------------------------------------------------------- - | - |//-- Continuation dispatch ---------------------------------------------- - | - |->cont_dispatch: - | // BASE = meta base, RA = resultofs, RD = nresults+1 (also in MULTRES) - | add RA, BASE - | and PC, -8 - | mov RB, BASE - | sub BASE, PC // Restore caller BASE. - | mov dword [RA+RD*8-4], LJ_TNIL // Ensure one valid arg. - | mov RC, RA // ... in [RC] - | mov PC, [RB-12] // Restore PC from [cont|PC]. - |.if X64 - | movsxd RAa, dword [RB-16] // May be negative on WIN64 with debug. - |.if FFI - | cmp RA, 1 - | jbe >1 - |.endif - | lea KBASEa, qword [=>0] - | add RAa, KBASEa - |.else - | mov RA, dword [RB-16] - |.if FFI - | cmp RA, 1 - | jbe >1 - |.endif - |.endif - | mov LFUNC:KBASE, [BASE-8] - | mov KBASE, LFUNC:KBASE->pc - | mov KBASE, [KBASE+PC2PROTO(k)] - | // BASE = base, RC = result, RB = meta base - | jmp RAa // Jump to continuation. - | - |.if FFI - |1: - | je ->cont_ffi_callback // cont = 1: return from FFI callback. - | // cont = 0: Tail call from C function. - | sub RB, BASE - | shr RB, 3 - | lea RD, [RB-1] - | jmp ->vm_call_tail - |.endif - | - |->cont_cat: // BASE = base, RC = result, RB = mbase - | movzx RA, PC_RB - | sub RB, 16 - | lea RA, [BASE+RA*8] - | sub RA, RB - | je ->cont_ra - | neg RA - | shr RA, 3 - |.if X64WIN - | mov CARG3d, RA - | mov L:CARG1d, SAVE_L - | mov L:CARG1d->base, BASE - | mov RCa, [RC] - | mov [RB], RCa - | mov CARG2d, RB - |.elif X64 - | mov L:CARG1d, SAVE_L - | mov L:CARG1d->base, BASE - | mov CARG3d, RA - | mov RAa, [RC] - | mov [RB], RAa - | mov CARG2d, RB - |.else - | mov ARG3, RA - | mov RA, [RC+4] - | mov RC, [RC] - | mov [RB+4], RA - | mov [RB], RC - | mov ARG2, RB - |.endif - | jmp ->BC_CAT_Z - | - |//-- Table indexing metamethods ----------------------------------------- - | - |->vmeta_tgets: - | mov TMP1, RC // RC = GCstr * - | mov TMP2, LJ_TSTR - | lea RCa, TMP1 // Store temp. TValue in TMP1/TMP2. - | cmp PC_OP, BC_GGET - | jne >1 - | lea RA, [DISPATCH+DISPATCH_GL(tmptv)] // Store fn->l.env in g->tmptv. - | mov [RA], TAB:RB // RB = GCtab * - | mov dword [RA+4], LJ_TTAB - | mov RB, RA - | jmp >2 - | - |->vmeta_tgetb: - | movzx RC, PC_RC - |.if DUALNUM - | mov TMP2, LJ_TISNUM - | mov TMP1, RC - |.elif SSE - | cvtsi2sd xmm0, RC - | movsd TMPQ, xmm0 - |.else - | mov ARG4, RC - | fild ARG4 - | fstp TMPQ - |.endif - | lea RCa, TMPQ // Store temp. TValue in TMPQ. - | jmp >1 - | - |->vmeta_tgetv: - | movzx RC, PC_RC // Reload TValue *k from RC. - | lea RC, [BASE+RC*8] - |1: - | movzx RB, PC_RB // Reload TValue *t from RB. - | lea RB, [BASE+RB*8] - |2: - |.if X64 - | mov L:CARG1d, SAVE_L - | mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE. - | mov CARG2d, RB - | mov CARG3, RCa // May be 64 bit ptr to stack. - | mov L:RB, L:CARG1d - |.else - | mov ARG2, RB - | mov L:RB, SAVE_L - | mov ARG3, RC - | mov ARG1, L:RB - | mov L:RB->base, BASE - |.endif - | mov SAVE_PC, PC - | call extern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) - | // TValue * (finished) or NULL (metamethod) returned in eax (RC). - | mov BASE, L:RB->base - | test RC, RC - | jz >3 - |->cont_ra: // BASE = base, RC = result - | movzx RA, PC_RA - |.if X64 - | mov RBa, [RC] - | mov [BASE+RA*8], RBa - |.else - | mov RB, [RC+4] - | mov RC, [RC] - | mov [BASE+RA*8+4], RB - | mov [BASE+RA*8], RC - |.endif - | ins_next - | - |3: // Call __index metamethod. - | // BASE = base, L->top = new base, stack = cont/func/t/k - | mov RA, L:RB->top - | mov [RA-12], PC // [cont|PC] - | lea PC, [RA+FRAME_CONT] - | sub PC, BASE - | mov LFUNC:RB, [RA-8] // Guaranteed to be a function here. - | mov NARGS:RD, 2+1 // 2 args for func(t, k). - | jmp ->vm_call_dispatch_f - | - |//----------------------------------------------------------------------- - | - |->vmeta_tsets: - | mov TMP1, RC // RC = GCstr * - | mov TMP2, LJ_TSTR - | lea RCa, TMP1 // Store temp. TValue in TMP1/TMP2. - | cmp PC_OP, BC_GSET - | jne >1 - | lea RA, [DISPATCH+DISPATCH_GL(tmptv)] // Store fn->l.env in g->tmptv. - | mov [RA], TAB:RB // RB = GCtab * - | mov dword [RA+4], LJ_TTAB - | mov RB, RA - | jmp >2 - | - |->vmeta_tsetb: - | movzx RC, PC_RC - |.if DUALNUM - | mov TMP2, LJ_TISNUM - | mov TMP1, RC - |.elif SSE - | cvtsi2sd xmm0, RC - | movsd TMPQ, xmm0 - |.else - | mov ARG4, RC - | fild ARG4 - | fstp TMPQ - |.endif - | lea RCa, TMPQ // Store temp. TValue in TMPQ. - | jmp >1 - | - |->vmeta_tsetv: - | movzx RC, PC_RC // Reload TValue *k from RC. - | lea RC, [BASE+RC*8] - |1: - | movzx RB, PC_RB // Reload TValue *t from RB. - | lea RB, [BASE+RB*8] - |2: - |.if X64 - | mov L:CARG1d, SAVE_L - | mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE. - | mov CARG2d, RB - | mov CARG3, RCa // May be 64 bit ptr to stack. - | mov L:RB, L:CARG1d - |.else - | mov ARG2, RB - | mov L:RB, SAVE_L - | mov ARG3, RC - | mov ARG1, L:RB - | mov L:RB->base, BASE - |.endif - | mov SAVE_PC, PC - | call extern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) - | // TValue * (finished) or NULL (metamethod) returned in eax (RC). - | mov BASE, L:RB->base - | test RC, RC - | jz >3 - | // NOBARRIER: lj_meta_tset ensures the table is not black. - | movzx RA, PC_RA - |.if X64 - | mov RBa, [BASE+RA*8] - | mov [RC], RBa - |.else - | mov RB, [BASE+RA*8+4] - | mov RA, [BASE+RA*8] - | mov [RC+4], RB - | mov [RC], RA - |.endif - |->cont_nop: // BASE = base, (RC = result) - | ins_next - | - |3: // Call __newindex metamethod. - | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) - | mov RA, L:RB->top - | mov [RA-12], PC // [cont|PC] - | movzx RC, PC_RA - | // Copy value to third argument. - |.if X64 - | mov RBa, [BASE+RC*8] - | mov [RA+16], RBa - |.else - | mov RB, [BASE+RC*8+4] - | mov RC, [BASE+RC*8] - | mov [RA+20], RB - | mov [RA+16], RC - |.endif - | lea PC, [RA+FRAME_CONT] - | sub PC, BASE - | mov LFUNC:RB, [RA-8] // Guaranteed to be a function here. - | mov NARGS:RD, 3+1 // 3 args for func(t, k, v). - | jmp ->vm_call_dispatch_f - | - |//-- Comparison metamethods --------------------------------------------- - | - |->vmeta_comp: - |.if X64 - | mov L:RB, SAVE_L - | mov L:RB->base, BASE // Caveat: CARG2d/CARG3d == BASE. - |.if X64WIN - | lea CARG3d, [BASE+RD*8] - | lea CARG2d, [BASE+RA*8] - |.else - | lea CARG2d, [BASE+RA*8] - | lea CARG3d, [BASE+RD*8] - |.endif - | mov CARG1d, L:RB // Caveat: CARG1d/CARG4d == RA. - | movzx CARG4d, PC_OP - |.else - | movzx RB, PC_OP - | lea RD, [BASE+RD*8] - | lea RA, [BASE+RA*8] - | mov ARG4, RB - | mov L:RB, SAVE_L - | mov ARG3, RD - | mov ARG2, RA - | mov ARG1, L:RB - | mov L:RB->base, BASE - |.endif - | mov SAVE_PC, PC - | call extern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) - | // 0/1 or TValue * (metamethod) returned in eax (RC). - |3: - | mov BASE, L:RB->base - | cmp RC, 1 - | ja ->vmeta_binop - |4: - | lea PC, [PC+4] - | jb >6 - |5: - | movzx RD, PC_RD - | branchPC RD - |6: - | ins_next - | - |->cont_condt: // BASE = base, RC = result - | add PC, 4 - | cmp dword [RC+4], LJ_TISTRUECOND // Branch if result is true. - | jb <5 - | jmp <6 - | - |->cont_condf: // BASE = base, RC = result - | cmp dword [RC+4], LJ_TISTRUECOND // Branch if result is false. - | jmp <4 - | - |->vmeta_equal: - | sub PC, 4 - |.if X64WIN - | mov CARG3d, RD - | mov CARG4d, RB - | mov L:RB, SAVE_L - | mov L:RB->base, BASE // Caveat: CARG2d == BASE. - | mov CARG2d, RA - | mov CARG1d, L:RB // Caveat: CARG1d == RA. - |.elif X64 - | mov CARG2d, RA - | mov CARG4d, RB // Caveat: CARG4d == RA. - | mov L:RB, SAVE_L - | mov L:RB->base, BASE // Caveat: CARG3d == BASE. - | mov CARG3d, RD - | mov CARG1d, L:RB - |.else - | mov ARG4, RB - | mov L:RB, SAVE_L - | mov ARG3, RD - | mov ARG2, RA - | mov ARG1, L:RB - | mov L:RB->base, BASE - |.endif - | mov SAVE_PC, PC - | call extern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) - | // 0/1 or TValue * (metamethod) returned in eax (RC). - | jmp <3 - | - |->vmeta_equal_cd: - |.if FFI - | sub PC, 4 - | mov L:RB, SAVE_L - | mov L:RB->base, BASE - | mov FCARG1, L:RB - | mov FCARG2, dword [PC-4] - | mov SAVE_PC, PC - | call extern lj_meta_equal_cd@8 // (lua_State *L, BCIns ins) - | // 0/1 or TValue * (metamethod) returned in eax (RC). - | jmp <3 - |.endif - | - |//-- Arithmetic metamethods --------------------------------------------- - | - |->vmeta_arith_vno: - |.if DUALNUM - | movzx RB, PC_RB - |.endif - |->vmeta_arith_vn: - | lea RC, [KBASE+RC*8] - | jmp >1 - | - |->vmeta_arith_nvo: - |.if DUALNUM - | movzx RC, PC_RC - |.endif - |->vmeta_arith_nv: - | lea RC, [KBASE+RC*8] - | lea RB, [BASE+RB*8] - | xchg RB, RC - | jmp >2 - | - |->vmeta_unm: - | lea RC, [BASE+RD*8] - | mov RB, RC - | jmp >2 - | - |->vmeta_arith_vvo: - |.if DUALNUM - | movzx RB, PC_RB - |.endif - |->vmeta_arith_vv: - | lea RC, [BASE+RC*8] - |1: - | lea RB, [BASE+RB*8] - |2: - | lea RA, [BASE+RA*8] - |.if X64WIN - | mov CARG3d, RB - | mov CARG4d, RC - | movzx RC, PC_OP - | mov ARG5d, RC - | mov L:RB, SAVE_L - | mov L:RB->base, BASE // Caveat: CARG2d == BASE. - | mov CARG2d, RA - | mov CARG1d, L:RB // Caveat: CARG1d == RA. - |.elif X64 - | movzx CARG5d, PC_OP - | mov CARG2d, RA - | mov CARG4d, RC // Caveat: CARG4d == RA. - | mov L:CARG1d, SAVE_L - | mov L:CARG1d->base, BASE // Caveat: CARG3d == BASE. - | mov CARG3d, RB - | mov L:RB, L:CARG1d - |.else - | mov ARG3, RB - | mov L:RB, SAVE_L - | mov ARG4, RC - | movzx RC, PC_OP - | mov ARG2, RA - | mov ARG5, RC - | mov ARG1, L:RB - | mov L:RB->base, BASE - |.endif - | mov SAVE_PC, PC - | call extern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) - | // NULL (finished) or TValue * (metamethod) returned in eax (RC). - | mov BASE, L:RB->base - | test RC, RC - | jz ->cont_nop - | - | // Call metamethod for binary op. - |->vmeta_binop: - | // BASE = base, RC = new base, stack = cont/func/o1/o2 - | mov RA, RC - | sub RC, BASE - | mov [RA-12], PC // [cont|PC] - | lea PC, [RC+FRAME_CONT] - | mov NARGS:RD, 2+1 // 2 args for func(o1, o2). - | jmp ->vm_call_dispatch - | - |->vmeta_len: - | mov L:RB, SAVE_L - | mov L:RB->base, BASE - | lea FCARG2, [BASE+RD*8] // Caveat: FCARG2 == BASE - | mov L:FCARG1, L:RB - | mov SAVE_PC, PC - | call extern lj_meta_len@8 // (lua_State *L, TValue *o) - | // NULL (retry) or TValue * (metamethod) returned in eax (RC). - | mov BASE, L:RB->base -#if LJ_52 - | test RC, RC - | jne ->vmeta_binop // Binop call for compatibility. - | movzx RD, PC_RD - | mov TAB:FCARG1, [BASE+RD*8] - | jmp ->BC_LEN_Z -#else - | jmp ->vmeta_binop // Binop call for compatibility. -#endif - | - |//-- Call metamethod ---------------------------------------------------- - | - |->vmeta_call_ra: - | lea RA, [BASE+RA*8+8] - |->vmeta_call: // Resolve and call __call metamethod. - | // BASE = old base, RA = new base, RC = nargs+1, PC = return - | mov TMP2, RA // Save RA, RC for us. - | mov TMP1, NARGS:RD - | sub RA, 8 - |.if X64 - | mov L:RB, SAVE_L - | mov L:RB->base, BASE // Caveat: CARG2d/CARG3d may be BASE. - | mov CARG2d, RA - | lea CARG3d, [RA+NARGS:RD*8] - | mov CARG1d, L:RB // Caveat: CARG1d may be RA. - |.else - | lea RC, [RA+NARGS:RD*8] - | mov L:RB, SAVE_L - | mov ARG2, RA - | mov ARG3, RC - | mov ARG1, L:RB - | mov L:RB->base, BASE // This is the callers base! - |.endif - | mov SAVE_PC, PC - | call extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) - | mov BASE, L:RB->base - | mov RA, TMP2 - | mov NARGS:RD, TMP1 - | mov LFUNC:RB, [RA-8] - | add NARGS:RD, 1 - | // This is fragile. L->base must not move, KBASE must always be defined. - | cmp KBASE, BASE // Continue with CALLT if flag set. - | je ->BC_CALLT_Z - | mov BASE, RA - | ins_call // Otherwise call resolved metamethod. - | - |//-- Argument coercion for 'for' statement ------------------------------ - | - |->vmeta_for: - | mov L:RB, SAVE_L - | mov L:RB->base, BASE - | mov FCARG2, RA // Caveat: FCARG2 == BASE - | mov L:FCARG1, L:RB // Caveat: FCARG1 == RA - | mov SAVE_PC, PC - | call extern lj_meta_for@8 // (lua_State *L, TValue *base) - | mov BASE, L:RB->base - | mov RC, [PC-4] - | movzx RA, RCH - | movzx OP, RCL - | shr RC, 16 - |.if X64 - | jmp aword [DISPATCH+OP*8+GG_DISP2STATIC] // Retry FORI or JFORI. - |.else - | jmp aword [DISPATCH+OP*4+GG_DISP2STATIC] // Retry FORI or JFORI. - |.endif - | - |//----------------------------------------------------------------------- - |//-- Fast functions ----------------------------------------------------- - |//----------------------------------------------------------------------- - | - |.macro .ffunc, name - |->ff_ .. name: - |.endmacro - | - |.macro .ffunc_1, name - |->ff_ .. name: - | cmp NARGS:RD, 1+1; jb ->fff_fallback - |.endmacro - | - |.macro .ffunc_2, name - |->ff_ .. name: - | cmp NARGS:RD, 2+1; jb ->fff_fallback - |.endmacro - | - |.macro .ffunc_n, name - | .ffunc_1 name - | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback - | fld qword [BASE] - |.endmacro - | - |.macro .ffunc_n, name, op - | .ffunc_1 name - | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback - | op - | fld qword [BASE] - |.endmacro - | - |.macro .ffunc_nsse, name, op - | .ffunc_1 name - | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback - | op xmm0, qword [BASE] - |.endmacro - | - |.macro .ffunc_nsse, name - | .ffunc_nsse name, movsd - |.endmacro - | - |.macro .ffunc_nn, name - | .ffunc_2 name - | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback - | cmp dword [BASE+12], LJ_TISNUM; jae ->fff_fallback - | fld qword [BASE] - | fld qword [BASE+8] - |.endmacro - | - |.macro .ffunc_nnsse, name - | .ffunc_2 name - | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback - | cmp dword [BASE+12], LJ_TISNUM; jae ->fff_fallback - | movsd xmm0, qword [BASE] - | movsd xmm1, qword [BASE+8] - |.endmacro - | - |.macro .ffunc_nnr, name - | .ffunc_2 name - | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback - | cmp dword [BASE+12], LJ_TISNUM; jae ->fff_fallback - | fld qword [BASE+8] - | fld qword [BASE] - |.endmacro - | - |// Inlined GC threshold check. Caveat: uses label 1. - |.macro ffgccheck - | mov RB, [DISPATCH+DISPATCH_GL(gc.total)] - | cmp RB, [DISPATCH+DISPATCH_GL(gc.threshold)] - | jb >1 - | call ->fff_gcstep - |1: - |.endmacro - | - |//-- Base library: checks ----------------------------------------------- - | - |.ffunc_1 assert - | mov RB, [BASE+4] - | cmp RB, LJ_TISTRUECOND; jae ->fff_fallback - | mov PC, [BASE-4] - | mov MULTRES, RD - | mov [BASE-4], RB - | mov RB, [BASE] - | mov [BASE-8], RB - | sub RD, 2 - | jz >2 - | mov RA, BASE - |1: - | add RA, 8 - |.if X64 - | mov RBa, [RA] - | mov [RA-8], RBa - |.else - | mov RB, [RA+4] - | mov [RA-4], RB - | mov RB, [RA] - | mov [RA-8], RB - |.endif - | sub RD, 1 - | jnz <1 - |2: - | mov RD, MULTRES - | jmp ->fff_res_ - | - |.ffunc_1 type - | mov RB, [BASE+4] - |.if X64 - | mov RA, RB - | sar RA, 15 - | cmp RA, -2 - | je >3 - |.endif - | mov RC, ~LJ_TNUMX - | not RB - | cmp RC, RB - | cmova RC, RB - |2: - | mov CFUNC:RB, [BASE-8] - | mov STR:RC, [CFUNC:RB+RC*8+((char *)(&((GCfuncC *)0)->upvalue))] - | mov PC, [BASE-4] - | mov dword [BASE-4], LJ_TSTR - | mov [BASE-8], STR:RC - | jmp ->fff_res1 - |.if X64 - |3: - | mov RC, ~LJ_TLIGHTUD - | jmp <2 - |.endif - | - |//-- Base library: getters and setters --------------------------------- - | - |.ffunc_1 getmetatable - | mov RB, [BASE+4] - | mov PC, [BASE-4] - | cmp RB, LJ_TTAB; jne >6 - |1: // Field metatable must be at same offset for GCtab and GCudata! - | mov TAB:RB, [BASE] - | mov TAB:RB, TAB:RB->metatable - |2: - | test TAB:RB, TAB:RB - | mov dword [BASE-4], LJ_TNIL - | jz ->fff_res1 - | mov STR:RC, [DISPATCH+DISPATCH_GL(gcroot)+4*(GCROOT_MMNAME+MM_metatable)] - | mov dword [BASE-4], LJ_TTAB // Store metatable as default result. - | mov [BASE-8], TAB:RB - | mov RA, TAB:RB->hmask - | and RA, STR:RC->hash - | imul RA, #NODE - | add NODE:RA, TAB:RB->node - |3: // Rearranged logic, because we expect _not_ to find the key. - | cmp dword NODE:RA->key.it, LJ_TSTR - | jne >4 - | cmp dword NODE:RA->key.gcr, STR:RC - | je >5 - |4: - | mov NODE:RA, NODE:RA->next - | test NODE:RA, NODE:RA - | jnz <3 - | jmp ->fff_res1 // Not found, keep default result. - |5: - | mov RB, [RA+4] - | cmp RB, LJ_TNIL; je ->fff_res1 // Ditto for nil value. - | mov RC, [RA] - | mov [BASE-4], RB // Return value of mt.__metatable. - | mov [BASE-8], RC - | jmp ->fff_res1 - | - |6: - | cmp RB, LJ_TUDATA; je <1 - |.if X64 - | cmp RB, LJ_TNUMX; ja >8 - | cmp RB, LJ_TISNUM; jbe >7 - | mov RB, LJ_TLIGHTUD - | jmp >8 - |7: - |.else - | cmp RB, LJ_TISNUM; ja >8 - |.endif - | mov RB, LJ_TNUMX - |8: - | not RB - | mov TAB:RB, [DISPATCH+RB*4+DISPATCH_GL(gcroot[GCROOT_BASEMT])] - | jmp <2 - | - |.ffunc_2 setmetatable - | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback - | // Fast path: no mt for table yet and not clearing the mt. - | mov TAB:RB, [BASE] - | cmp dword TAB:RB->metatable, 0; jne ->fff_fallback - | cmp dword [BASE+12], LJ_TTAB; jne ->fff_fallback - | mov TAB:RC, [BASE+8] - | mov TAB:RB->metatable, TAB:RC - | mov PC, [BASE-4] - | mov dword [BASE-4], LJ_TTAB // Return original table. - | mov [BASE-8], TAB:RB - | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) - | jz >1 - | // Possible write barrier. Table is black, but skip iswhite(mt) check. - | barrierback TAB:RB, RC - |1: - | jmp ->fff_res1 - | - |.ffunc_2 rawget - | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback - |.if X64WIN - | mov RB, BASE // Save BASE. - | lea CARG3d, [BASE+8] - | mov CARG2d, [BASE] // Caveat: CARG2d == BASE. - | mov CARG1d, SAVE_L - |.elif X64 - | mov RB, BASE // Save BASE. - | mov CARG2d, [BASE] - | lea CARG3d, [BASE+8] // Caveat: CARG3d == BASE. - | mov CARG1d, SAVE_L - |.else - | mov TAB:RD, [BASE] - | mov L:RB, SAVE_L - | mov ARG2, TAB:RD - | mov ARG1, L:RB - | mov RB, BASE // Save BASE. - | add BASE, 8 - | mov ARG3, BASE - |.endif - | call extern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) - | // cTValue * returned in eax (RD). - | mov BASE, RB // Restore BASE. - | // Copy table slot. - |.if X64 - | mov RBa, [RD] - | mov PC, [BASE-4] - | mov [BASE-8], RBa - |.else - | mov RB, [RD] - | mov RD, [RD+4] - | mov PC, [BASE-4] - | mov [BASE-8], RB - | mov [BASE-4], RD - |.endif - | jmp ->fff_res1 - | - |//-- Base library: conversions ------------------------------------------ - | - |.ffunc tonumber - | // Only handles the number case inline (without a base argument). - | cmp NARGS:RD, 1+1; jne ->fff_fallback // Exactly one argument. - | cmp dword [BASE+4], LJ_TISNUM - |.if DUALNUM - | jne >1 - | mov RB, dword [BASE]; jmp ->fff_resi - |1: - | ja ->fff_fallback - |.else - | jae ->fff_fallback - |.endif - |.if SSE - | movsd xmm0, qword [BASE]; jmp ->fff_resxmm0 - |.else - | fld qword [BASE]; jmp ->fff_resn - |.endif - | - |.ffunc_1 tostring - | // Only handles the string or number case inline. - | mov PC, [BASE-4] - | cmp dword [BASE+4], LJ_TSTR; jne >3 - | // A __tostring method in the string base metatable is ignored. - | mov STR:RD, [BASE] - |2: - | mov dword [BASE-4], LJ_TSTR - | mov [BASE-8], STR:RD - | jmp ->fff_res1 - |3: // Handle numbers inline, unless a number base metatable is present. - | cmp dword [BASE+4], LJ_TISNUM; ja ->fff_fallback - | cmp dword [DISPATCH+DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])], 0 - | jne ->fff_fallback - | ffgccheck // Caveat: uses label 1. - | mov L:RB, SAVE_L - | mov L:RB->base, BASE // Add frame since C call can throw. - | mov SAVE_PC, PC // Redundant (but a defined value). - |.if X64 and not X64WIN - | mov FCARG2, BASE // Otherwise: FCARG2 == BASE - |.endif - | mov L:FCARG1, L:RB - |.if DUALNUM - | call extern lj_str_fromnumber@8 // (lua_State *L, cTValue *o) - |.else - | call extern lj_str_fromnum@8 // (lua_State *L, lua_Number *np) - |.endif - | // GCstr returned in eax (RD). - | mov BASE, L:RB->base - | jmp <2 - | - |//-- Base library: iterators ------------------------------------------- - | - |.ffunc_1 next - | je >2 // Missing 2nd arg? - |1: - | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback - | mov L:RB, SAVE_L - | mov L:RB->base, BASE // Add frame since C call can throw. - | mov L:RB->top, BASE // Dummy frame length is ok. - | mov PC, [BASE-4] - |.if X64WIN - | lea CARG3d, [BASE+8] - | mov CARG2d, [BASE] // Caveat: CARG2d == BASE. - | mov CARG1d, L:RB - |.elif X64 - | mov CARG2d, [BASE] - | lea CARG3d, [BASE+8] // Caveat: CARG3d == BASE. - | mov CARG1d, L:RB - |.else - | mov TAB:RD, [BASE] - | mov ARG2, TAB:RD - | mov ARG1, L:RB - | add BASE, 8 - | mov ARG3, BASE - |.endif - | mov SAVE_PC, PC // Needed for ITERN fallback. - | call extern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) - | // Flag returned in eax (RD). - | mov BASE, L:RB->base - | test RD, RD; jz >3 // End of traversal? - | // Copy key and value to results. - |.if X64 - | mov RBa, [BASE+8] - | mov RDa, [BASE+16] - | mov [BASE-8], RBa - | mov [BASE], RDa - |.else - | mov RB, [BASE+8] - | mov RD, [BASE+12] - | mov [BASE-8], RB - | mov [BASE-4], RD - | mov RB, [BASE+16] - | mov RD, [BASE+20] - | mov [BASE], RB - | mov [BASE+4], RD - |.endif - |->fff_res2: - | mov RD, 1+2 - | jmp ->fff_res - |2: // Set missing 2nd arg to nil. - | mov dword [BASE+12], LJ_TNIL - | jmp <1 - |3: // End of traversal: return nil. - | mov dword [BASE-4], LJ_TNIL - | jmp ->fff_res1 - | - |.ffunc_1 pairs - | mov TAB:RB, [BASE] - | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback -#if LJ_52 - | cmp dword TAB:RB->metatable, 0; jne ->fff_fallback -#endif - | mov CFUNC:RB, [BASE-8] - | mov CFUNC:RD, CFUNC:RB->upvalue[0] - | mov PC, [BASE-4] - | mov dword [BASE-4], LJ_TFUNC - | mov [BASE-8], CFUNC:RD - | mov dword [BASE+12], LJ_TNIL - | mov RD, 1+3 - | jmp ->fff_res - | - |.ffunc_1 ipairs_aux - | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback - | cmp dword [BASE+12], LJ_TISNUM - |.if DUALNUM - | jne ->fff_fallback - |.else - | jae ->fff_fallback - |.endif - | mov PC, [BASE-4] - |.if DUALNUM - | mov RD, dword [BASE+8] - | add RD, 1 - | mov dword [BASE-4], LJ_TISNUM - | mov dword [BASE-8], RD - |.elif SSE - | movsd xmm0, qword [BASE+8] - | sseconst_1 xmm1, RBa - | addsd xmm0, xmm1 - | cvtsd2si RD, xmm0 - | movsd qword [BASE-8], xmm0 - |.else - | fld qword [BASE+8] - | fld1 - | faddp st1 - | fist ARG1 - | fstp qword [BASE-8] - | mov RD, ARG1 - |.endif - | mov TAB:RB, [BASE] - | cmp RD, TAB:RB->asize; jae >2 // Not in array part? - | shl RD, 3 - | add RD, TAB:RB->array - |1: - | cmp dword [RD+4], LJ_TNIL; je ->fff_res0 - | // Copy array slot. - |.if X64 - | mov RBa, [RD] - | mov [BASE], RBa - |.else - | mov RB, [RD] - | mov RD, [RD+4] - | mov [BASE], RB - | mov [BASE+4], RD - |.endif - | jmp ->fff_res2 - |2: // Check for empty hash part first. Otherwise call C function. - | cmp dword TAB:RB->hmask, 0; je ->fff_res0 - | mov FCARG1, TAB:RB - | mov RB, BASE // Save BASE. - | mov FCARG2, RD // Caveat: FCARG2 == BASE - | call extern lj_tab_getinth@8 // (GCtab *t, int32_t key) - | // cTValue * or NULL returned in eax (RD). - | mov BASE, RB - | test RD, RD - | jnz <1 - |->fff_res0: - | mov RD, 1+0 - | jmp ->fff_res - | - |.ffunc_1 ipairs - | mov TAB:RB, [BASE] - | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback -#if LJ_52 - | cmp dword TAB:RB->metatable, 0; jne ->fff_fallback -#endif - | mov CFUNC:RB, [BASE-8] - | mov CFUNC:RD, CFUNC:RB->upvalue[0] - | mov PC, [BASE-4] - | mov dword [BASE-4], LJ_TFUNC - | mov [BASE-8], CFUNC:RD - |.if DUALNUM - | mov dword [BASE+12], LJ_TISNUM - | mov dword [BASE+8], 0 - |.elif SSE - | xorps xmm0, xmm0 - | movsd qword [BASE+8], xmm0 - |.else - | fldz - | fstp qword [BASE+8] - |.endif - | mov RD, 1+3 - | jmp ->fff_res - | - |//-- Base library: catch errors ---------------------------------------- - | - |.ffunc_1 pcall - | lea RA, [BASE+8] - | sub NARGS:RD, 1 - | mov PC, 8+FRAME_PCALL - |1: - | movzx RB, byte [DISPATCH+DISPATCH_GL(hookmask)] - | shr RB, HOOK_ACTIVE_SHIFT - | and RB, 1 - | add PC, RB // Remember active hook before pcall. - | jmp ->vm_call_dispatch - | - |.ffunc_2 xpcall - | cmp dword [BASE+12], LJ_TFUNC; jne ->fff_fallback - | mov RB, [BASE+4] // Swap function and traceback. - | mov [BASE+12], RB - | mov dword [BASE+4], LJ_TFUNC - | mov LFUNC:RB, [BASE] - | mov PC, [BASE+8] - | mov [BASE+8], LFUNC:RB - | mov [BASE], PC - | lea RA, [BASE+16] - | sub NARGS:RD, 2 - | mov PC, 16+FRAME_PCALL - | jmp <1 - | - |//-- Coroutine library -------------------------------------------------- - | - |.macro coroutine_resume_wrap, resume - |.if resume - |.ffunc_1 coroutine_resume - | mov L:RB, [BASE] - |.else - |.ffunc coroutine_wrap_aux - | mov CFUNC:RB, [BASE-8] - | mov L:RB, CFUNC:RB->upvalue[0].gcr - |.endif - | mov PC, [BASE-4] - | mov SAVE_PC, PC - |.if X64 - | mov TMP1, L:RB - |.else - | mov ARG1, L:RB - |.endif - |.if resume - | cmp dword [BASE+4], LJ_TTHREAD; jne ->fff_fallback - |.endif - | cmp aword L:RB->cframe, 0; jne ->fff_fallback - | cmp byte L:RB->status, LUA_YIELD; ja ->fff_fallback - | mov RA, L:RB->top - | je >1 // Status != LUA_YIELD (i.e. 0)? - | cmp RA, L:RB->base // Check for presence of initial func. - | je ->fff_fallback - |1: - |.if resume - | lea PC, [RA+NARGS:RD*8-16] // Check stack space (-1-thread). - |.else - | lea PC, [RA+NARGS:RD*8-8] // Check stack space (-1). - |.endif - | cmp PC, L:RB->maxstack; ja ->fff_fallback - | mov L:RB->top, PC - | - | mov L:RB, SAVE_L - | mov L:RB->base, BASE - |.if resume - | add BASE, 8 // Keep resumed thread in stack for GC. - |.endif - | mov L:RB->top, BASE - |.if resume - | lea RB, [BASE+NARGS:RD*8-24] // RB = end of source for stack move. - |.else - | lea RB, [BASE+NARGS:RD*8-16] // RB = end of source for stack move. - |.endif - | sub RBa, PCa // Relative to PC. - | - | cmp PC, RA - | je >3 - |2: // Move args to coroutine. - |.if X64 - | mov RCa, [PC+RB] - | mov [PC-8], RCa - |.else - | mov RC, [PC+RB+4] - | mov [PC-4], RC - | mov RC, [PC+RB] - | mov [PC-8], RC - |.endif - | sub PC, 8 - | cmp PC, RA - | jne <2 - |3: - |.if X64 - | mov CARG2d, RA - | mov CARG1d, TMP1 - |.else - | mov ARG2, RA - | xor RA, RA - | mov ARG4, RA - | mov ARG3, RA - |.endif - | call ->vm_resume // (lua_State *L, TValue *base, 0, 0) - | set_vmstate INTERP - | - | mov L:RB, SAVE_L - |.if X64 - | mov L:PC, TMP1 - |.else - | mov L:PC, ARG1 // The callee doesn't modify SAVE_L. - |.endif - | mov BASE, L:RB->base - | cmp eax, LUA_YIELD - | ja >8 - |4: - | mov RA, L:PC->base - | mov KBASE, L:PC->top - | mov L:PC->top, RA // Clear coroutine stack. - | mov PC, KBASE - | sub PC, RA - | je >6 // No results? - | lea RD, [BASE+PC] - | shr PC, 3 - | cmp RD, L:RB->maxstack - | ja >9 // Need to grow stack? - | - | mov RB, BASE - | sub RBa, RAa - |5: // Move results from coroutine. - |.if X64 - | mov RDa, [RA] - | mov [RA+RB], RDa - |.else - | mov RD, [RA] - | mov [RA+RB], RD - | mov RD, [RA+4] - | mov [RA+RB+4], RD - |.endif - | add RA, 8 - | cmp RA, KBASE - | jne <5 - |6: - |.if resume - | lea RD, [PC+2] // nresults+1 = 1 + true + results. - | mov dword [BASE-4], LJ_TTRUE // Prepend true to results. - |.else - | lea RD, [PC+1] // nresults+1 = 1 + results. - |.endif - |7: - | mov PC, SAVE_PC - | mov MULTRES, RD - |.if resume - | mov RAa, -8 - |.else - | xor RA, RA - |.endif - | test PC, FRAME_TYPE - | jz ->BC_RET_Z - | jmp ->vm_return - | - |8: // Coroutine returned with error (at co->top-1). - |.if resume - | mov dword [BASE-4], LJ_TFALSE // Prepend false to results. - | mov RA, L:PC->top - | sub RA, 8 - | mov L:PC->top, RA // Clear error from coroutine stack. - | // Copy error message. - |.if X64 - | mov RDa, [RA] - | mov [BASE], RDa - |.else - | mov RD, [RA] - | mov [BASE], RD - | mov RD, [RA+4] - | mov [BASE+4], RD - |.endif - | mov RD, 1+2 // nresults+1 = 1 + false + error. - | jmp <7 - |.else - | mov FCARG2, L:PC - | mov FCARG1, L:RB - | call extern lj_ffh_coroutine_wrap_err@8 // (lua_State *L, lua_State *co) - | // Error function does not return. - |.endif - | - |9: // Handle stack expansion on return from yield. - |.if X64 - | mov L:RA, TMP1 - |.else - | mov L:RA, ARG1 // The callee doesn't modify SAVE_L. - |.endif - | mov L:RA->top, KBASE // Undo coroutine stack clearing. - | mov FCARG2, PC - | mov FCARG1, L:RB - | call extern lj_state_growstack@8 // (lua_State *L, int n) - |.if X64 - | mov L:PC, TMP1 - |.else - | mov L:PC, ARG1 - |.endif - | mov BASE, L:RB->base - | jmp <4 // Retry the stack move. - |.endmacro - | - | coroutine_resume_wrap 1 // coroutine.resume - | coroutine_resume_wrap 0 // coroutine.wrap - | - |.ffunc coroutine_yield - | mov L:RB, SAVE_L - | test aword L:RB->cframe, CFRAME_RESUME - | jz ->fff_fallback - | mov L:RB->base, BASE - | lea RD, [BASE+NARGS:RD*8-8] - | mov L:RB->top, RD - | xor RD, RD - | mov aword L:RB->cframe, RDa - | mov al, LUA_YIELD - | mov byte L:RB->status, al - | jmp ->vm_leave_unw - | - |//-- Math library ------------------------------------------------------- - | - |.if not DUALNUM - |->fff_resi: // Dummy. - |.endif - | - |.if SSE - |->fff_resn: - | mov PC, [BASE-4] - | fstp qword [BASE-8] - | jmp ->fff_res1 - |.endif - | - | .ffunc_1 math_abs - |.if DUALNUM - | cmp dword [BASE+4], LJ_TISNUM; jne >2 - | mov RB, dword [BASE] - | cmp RB, 0; jns ->fff_resi - | neg RB; js >1 - |->fff_resbit: - |->fff_resi: - | mov PC, [BASE-4] - | mov dword [BASE-4], LJ_TISNUM - | mov dword [BASE-8], RB - | jmp ->fff_res1 - |1: - | mov PC, [BASE-4] - | mov dword [BASE-4], 0x41e00000 // 2^31. - | mov dword [BASE-8], 0 - | jmp ->fff_res1 - |2: - | ja ->fff_fallback - |.else - | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback - |.endif - | - |.if SSE - | movsd xmm0, qword [BASE] - | sseconst_abs xmm1, RDa - | andps xmm0, xmm1 - |->fff_resxmm0: - | mov PC, [BASE-4] - | movsd qword [BASE-8], xmm0 - | // fallthrough - |.else - | fld qword [BASE] - | fabs - | // fallthrough - |->fff_resxmm0: // Dummy. - |->fff_resn: - | mov PC, [BASE-4] - | fstp qword [BASE-8] - |.endif - | - |->fff_res1: - | mov RD, 1+1 - |->fff_res: - | mov MULTRES, RD - |->fff_res_: - | test PC, FRAME_TYPE - | jnz >7 - |5: - | cmp PC_RB, RDL // More results expected? - | ja >6 - | // Adjust BASE. KBASE is assumed to be set for the calling frame. - | movzx RA, PC_RA - | not RAa // Note: ~RA = -(RA+1) - | lea BASE, [BASE+RA*8] // base = base - (RA+1)*8 - | ins_next - | - |6: // Fill up results with nil. - | mov dword [BASE+RD*8-12], LJ_TNIL - | add RD, 1 - | jmp <5 - | - |7: // Non-standard return case. - | mov RAa, -8 // Results start at BASE+RA = BASE-8. - | jmp ->vm_return - | - |.macro math_round, func - | .ffunc math_ .. func - |.if DUALNUM - | cmp dword [BASE+4], LJ_TISNUM; jne >1 - | mov RB, dword [BASE]; jmp ->fff_resi - |1: - | ja ->fff_fallback - |.else - | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback - |.endif - |.if SSE - | movsd xmm0, qword [BASE] - | call ->vm_ .. func - | .if DUALNUM - | cvtsd2si RB, xmm0 - | cmp RB, 0x80000000 - | jne ->fff_resi - | cvtsi2sd xmm1, RB - | ucomisd xmm0, xmm1 - | jp ->fff_resxmm0 - | je ->fff_resi - | .endif - | jmp ->fff_resxmm0 - |.else - | fld qword [BASE] - | call ->vm_ .. func - | .if DUALNUM - | fist ARG1 - | mov RB, ARG1 - | cmp RB, 0x80000000; jne >2 - | fdup - | fild ARG1 - | fcomparepp - | jp ->fff_resn - | jne ->fff_resn - |2: - | fpop - | jmp ->fff_resi - | .else - | jmp ->fff_resn - | .endif - |.endif - |.endmacro - | - | math_round floor - | math_round ceil - | - |.if SSE - |.ffunc_nsse math_sqrt, sqrtsd; jmp ->fff_resxmm0 - |.else - |.ffunc_n math_sqrt; fsqrt; jmp ->fff_resn - |.endif - | - |.ffunc math_log - | cmp NARGS:RD, 1+1; jne ->fff_fallback // Exactly one argument. - | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback - | fldln2; fld qword [BASE]; fyl2x; jmp ->fff_resn - | - |.ffunc_n math_log10, fldlg2; fyl2x; jmp ->fff_resn - |.ffunc_n math_exp; call ->vm_exp_x87; jmp ->fff_resn - | - |.ffunc_n math_sin; fsin; jmp ->fff_resn - |.ffunc_n math_cos; fcos; jmp ->fff_resn - |.ffunc_n math_tan; fptan; fpop; jmp ->fff_resn - | - |.ffunc_n math_asin - | fdup; fmul st0; fld1; fsubrp st1; fsqrt; fpatan - | jmp ->fff_resn - |.ffunc_n math_acos - | fdup; fmul st0; fld1; fsubrp st1; fsqrt; fxch; fpatan - | jmp ->fff_resn - |.ffunc_n math_atan; fld1; fpatan; jmp ->fff_resn - | - |.macro math_extern, func - |.if SSE - | .ffunc_nsse math_ .. func - | .if not X64 - | movsd FPARG1, xmm0 - | .endif - |.else - | .ffunc_n math_ .. func - | fstp FPARG1 - |.endif - | mov RB, BASE - | call extern lj_vm_ .. func - | mov BASE, RB - | .if X64 - | jmp ->fff_resxmm0 - | .else - | jmp ->fff_resn - | .endif - |.endmacro - | - | math_extern sinh - | math_extern cosh - | math_extern tanh - | - |->ff_math_deg: - |.if SSE - |.ffunc_nsse math_rad - | mov CFUNC:RB, [BASE-8] - | mulsd xmm0, qword CFUNC:RB->upvalue[0] - | jmp ->fff_resxmm0 - |.else - |.ffunc_n math_rad - | mov CFUNC:RB, [BASE-8] - | fmul qword CFUNC:RB->upvalue[0] - | jmp ->fff_resn - |.endif - | - |.ffunc_nn math_atan2; fpatan; jmp ->fff_resn - |.ffunc_nnr math_ldexp; fscale; fpop1; jmp ->fff_resn - | - |.ffunc_1 math_frexp - | mov RB, [BASE+4] - | cmp RB, LJ_TISNUM; jae ->fff_fallback - | mov PC, [BASE-4] - | mov RC, [BASE] - | mov [BASE-4], RB; mov [BASE-8], RC - | shl RB, 1; cmp RB, 0xffe00000; jae >3 - | or RC, RB; jz >3 - | mov RC, 1022 - | cmp RB, 0x00200000; jb >4 - |1: - | shr RB, 21; sub RB, RC // Extract and unbias exponent. - |.if SSE - | cvtsi2sd xmm0, RB - |.else - | mov TMP1, RB; fild TMP1 - |.endif - | mov RB, [BASE-4] - | and RB, 0x800fffff // Mask off exponent. - | or RB, 0x3fe00000 // Put mantissa in range [0.5,1) or 0. - | mov [BASE-4], RB - |2: - |.if SSE - | movsd qword [BASE], xmm0 - |.else - | fstp qword [BASE] - |.endif - | mov RD, 1+2 - | jmp ->fff_res - |3: // Return +-0, +-Inf, NaN unmodified and an exponent of 0. - |.if SSE - | xorps xmm0, xmm0; jmp <2 - |.else - | fldz; jmp <2 - |.endif - |4: // Handle denormals by multiplying with 2^54 and adjusting the bias. - |.if SSE - | movsd xmm0, qword [BASE] - | sseconst_hi xmm1, RBa, 43500000 // 2^54. - | mulsd xmm0, xmm1 - | movsd qword [BASE-8], xmm0 - |.else - | fld qword [BASE] - | mov TMP1, 0x5a800000; fmul TMP1 // x = x*2^54 - | fstp qword [BASE-8] - |.endif - | mov RB, [BASE-4]; mov RC, 1076; shl RB, 1; jmp <1 - | - |.if SSE - |.ffunc_nsse math_modf - |.else - |.ffunc_n math_modf - |.endif - | mov RB, [BASE+4] - | mov PC, [BASE-4] - | shl RB, 1; cmp RB, 0xffe00000; je >4 // +-Inf? - |.if SSE - | movaps xmm4, xmm0 - | call ->vm_trunc - | subsd xmm4, xmm0 - |1: - | movsd qword [BASE-8], xmm0 - | movsd qword [BASE], xmm4 - |.else - | fdup - | call ->vm_trunc - | fsub st1, st0 - |1: - | fstp qword [BASE-8] - | fstp qword [BASE] - |.endif - | mov RC, [BASE-4]; mov RB, [BASE+4] - | xor RC, RB; js >3 // Need to adjust sign? - |2: - | mov RD, 1+2 - | jmp ->fff_res - |3: - | xor RB, 0x80000000; mov [BASE+4], RB // Flip sign of fraction. - | jmp <2 - |4: - |.if SSE - | xorps xmm4, xmm4; jmp <1 // Return +-Inf and +-0. - |.else - | fldz; fxch; jmp <1 // Return +-Inf and +-0. - |.endif - | - |.ffunc_nnr math_fmod - |1: ; fprem; fnstsw ax; sahf; jp <1 - | fpop1 - | jmp ->fff_resn - | - |.if SSE - |.ffunc_nnsse math_pow; call ->vm_pow; jmp ->fff_resxmm0 - |.else - |.ffunc_nn math_pow; call ->vm_pow; jmp ->fff_resn - |.endif - | - |.macro math_minmax, name, cmovop, fcmovop, sseop - | .ffunc name - | mov RA, 2 - | cmp dword [BASE+4], LJ_TISNUM - |.if DUALNUM - | jne >4 - | mov RB, dword [BASE] - |1: // Handle integers. - | cmp RA, RD; jae ->fff_resi - | cmp dword [BASE+RA*8-4], LJ_TISNUM; jne >3 - | cmp RB, dword [BASE+RA*8-8] - | cmovop RB, dword [BASE+RA*8-8] - | add RA, 1 - | jmp <1 - |3: - | ja ->fff_fallback - | // Convert intermediate result to number and continue below. - |.if SSE - | cvtsi2sd xmm0, RB - |.else - | mov TMP1, RB - | fild TMP1 - |.endif - | jmp >6 - |4: - | ja ->fff_fallback - |.else - | jae ->fff_fallback - |.endif - | - |.if SSE - | movsd xmm0, qword [BASE] - |5: // Handle numbers or integers. - | cmp RA, RD; jae ->fff_resxmm0 - | cmp dword [BASE+RA*8-4], LJ_TISNUM - |.if DUALNUM - | jb >6 - | ja ->fff_fallback - | cvtsi2sd xmm1, dword [BASE+RA*8-8] - | jmp >7 - |.else - | jae ->fff_fallback - |.endif - |6: - | movsd xmm1, qword [BASE+RA*8-8] - |7: - | sseop xmm0, xmm1 - | add RA, 1 - | jmp <5 - |.else - | fld qword [BASE] - |5: // Handle numbers or integers. - | cmp RA, RD; jae ->fff_resn - | cmp dword [BASE+RA*8-4], LJ_TISNUM - |.if DUALNUM - | jb >6 - | ja >9 - | fild dword [BASE+RA*8-8] - | jmp >7 - |.else - | jae >9 - |.endif - |6: - | fld qword [BASE+RA*8-8] - |7: - | fucomi st1; fcmovop st1; fpop1 - | add RA, 1 - | jmp <5 - |.endif - |.endmacro - | - | math_minmax math_min, cmovg, fcmovnbe, minsd - | math_minmax math_max, cmovl, fcmovbe, maxsd - |.if not SSE - |9: - | fpop; jmp ->fff_fallback - |.endif - | - |//-- String library ----------------------------------------------------- - | - |.ffunc_1 string_len - | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback - | mov STR:RB, [BASE] - |.if DUALNUM - | mov RB, dword STR:RB->len; jmp ->fff_resi - |.elif SSE - | cvtsi2sd xmm0, dword STR:RB->len; jmp ->fff_resxmm0 - |.else - | fild dword STR:RB->len; jmp ->fff_resn - |.endif - | - |.ffunc string_byte // Only handle the 1-arg case here. - | cmp NARGS:RD, 1+1; jne ->fff_fallback - | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback - | mov STR:RB, [BASE] - | mov PC, [BASE-4] - | cmp dword STR:RB->len, 1 - | jb ->fff_res0 // Return no results for empty string. - | movzx RB, byte STR:RB[1] - |.if DUALNUM - | jmp ->fff_resi - |.elif SSE - | cvtsi2sd xmm0, RB; jmp ->fff_resxmm0 - |.else - | mov TMP1, RB; fild TMP1; jmp ->fff_resn - |.endif - | - |.ffunc string_char // Only handle the 1-arg case here. - | ffgccheck - | cmp NARGS:RD, 1+1; jne ->fff_fallback // *Exactly* 1 arg. - | cmp dword [BASE+4], LJ_TISNUM - |.if DUALNUM - | jne ->fff_fallback - | mov RB, dword [BASE] - | cmp RB, 255; ja ->fff_fallback - | mov TMP2, RB - |.elif SSE - | jae ->fff_fallback - | cvttsd2si RB, qword [BASE] - | cmp RB, 255; ja ->fff_fallback - | mov TMP2, RB - |.else - | jae ->fff_fallback - | fld qword [BASE] - | fistp TMP2 - | cmp TMP2, 255; ja ->fff_fallback - |.endif - |.if X64 - | mov TMP3, 1 - |.else - | mov ARG3, 1 - |.endif - | lea RDa, TMP2 // Points to stack. Little-endian. - |->fff_newstr: - | mov L:RB, SAVE_L - | mov L:RB->base, BASE - |.if X64 - | mov CARG3d, TMP3 // Zero-extended to size_t. - | mov CARG2, RDa // May be 64 bit ptr to stack. - | mov CARG1d, L:RB - |.else - | mov ARG2, RD - | mov ARG1, L:RB - |.endif - | mov SAVE_PC, PC - | call extern lj_str_new // (lua_State *L, char *str, size_t l) - | // GCstr * returned in eax (RD). - | mov BASE, L:RB->base - | mov PC, [BASE-4] - | mov dword [BASE-4], LJ_TSTR - | mov [BASE-8], STR:RD - | jmp ->fff_res1 - | - |.ffunc string_sub - | ffgccheck - | mov TMP2, -1 - | cmp NARGS:RD, 1+2; jb ->fff_fallback - | jna >1 - | cmp dword [BASE+20], LJ_TISNUM - |.if DUALNUM - | jne ->fff_fallback - | mov RB, dword [BASE+16] - | mov TMP2, RB - |.elif SSE - | jae ->fff_fallback - | cvttsd2si RB, qword [BASE+16] - | mov TMP2, RB - |.else - | jae ->fff_fallback - | fld qword [BASE+16] - | fistp TMP2 - |.endif - |1: - | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback - | cmp dword [BASE+12], LJ_TISNUM - |.if DUALNUM - | jne ->fff_fallback - |.else - | jae ->fff_fallback - |.endif - | mov STR:RB, [BASE] - | mov TMP3, STR:RB - | mov RB, STR:RB->len - |.if DUALNUM - | mov RA, dword [BASE+8] - |.elif SSE - | cvttsd2si RA, qword [BASE+8] - |.else - | fld qword [BASE+8] - | fistp ARG3 - | mov RA, ARG3 - |.endif - | mov RC, TMP2 - | cmp RB, RC // len < end? (unsigned compare) - | jb >5 - |2: - | test RA, RA // start <= 0? - | jle >7 - |3: - | mov STR:RB, TMP3 - | sub RC, RA // start > end? - | jl ->fff_emptystr - | lea RB, [STR:RB+RA+#STR-1] - | add RC, 1 - |4: - |.if X64 - | mov TMP3, RC - |.else - | mov ARG3, RC - |.endif - | mov RD, RB - | jmp ->fff_newstr - | - |5: // Negative end or overflow. - | jl >6 - | lea RC, [RC+RB+1] // end = end+(len+1) - | jmp <2 - |6: // Overflow. - | mov RC, RB // end = len - | jmp <2 - | - |7: // Negative start or underflow. - | je >8 - | add RA, RB // start = start+(len+1) - | add RA, 1 - | jg <3 // start > 0? - |8: // Underflow. - | mov RA, 1 // start = 1 - | jmp <3 - | - |->fff_emptystr: // Range underflow. - | xor RC, RC // Zero length. Any ptr in RB is ok. - | jmp <4 - | - |.ffunc string_rep // Only handle the 1-char case inline. - | ffgccheck - | cmp NARGS:RD, 2+1; jne ->fff_fallback // Exactly 2 arguments. - | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback - | cmp dword [BASE+12], LJ_TISNUM - | mov STR:RB, [BASE] - |.if DUALNUM - | jne ->fff_fallback - | mov RC, dword [BASE+8] - |.elif SSE - | jae ->fff_fallback - | cvttsd2si RC, qword [BASE+8] - |.else - | jae ->fff_fallback - | fld qword [BASE+8] - | fistp TMP2 - | mov RC, TMP2 - |.endif - | test RC, RC - | jle ->fff_emptystr // Count <= 0? (or non-int) - | cmp dword STR:RB->len, 1 - | jb ->fff_emptystr // Zero length string? - | jne ->fff_fallback_2 // Fallback for > 1-char strings. - | cmp [DISPATCH+DISPATCH_GL(tmpbuf.sz)], RC; jb ->fff_fallback_2 - | movzx RA, byte STR:RB[1] - | mov RB, [DISPATCH+DISPATCH_GL(tmpbuf.buf)] - |.if X64 - | mov TMP3, RC - |.else - | mov ARG3, RC - |.endif - |1: // Fill buffer with char. Yes, this is suboptimal code (do you care?). - | mov [RB], RAL - | add RB, 1 - | sub RC, 1 - | jnz <1 - | mov RD, [DISPATCH+DISPATCH_GL(tmpbuf.buf)] - | jmp ->fff_newstr - | - |.ffunc_1 string_reverse - | ffgccheck - | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback - | mov STR:RB, [BASE] - | mov RC, STR:RB->len - | test RC, RC - | jz ->fff_emptystr // Zero length string? - | cmp [DISPATCH+DISPATCH_GL(tmpbuf.sz)], RC; jb ->fff_fallback_1 - | add RB, #STR - | mov TMP2, PC // Need another temp register. - |.if X64 - | mov TMP3, RC - |.else - | mov ARG3, RC - |.endif - | mov PC, [DISPATCH+DISPATCH_GL(tmpbuf.buf)] - |1: - | movzx RA, byte [RB] - | add RB, 1 - | sub RC, 1 - | mov [PC+RC], RAL - | jnz <1 - | mov RD, PC - | mov PC, TMP2 - | jmp ->fff_newstr - | - |.macro ffstring_case, name, lo, hi - | .ffunc_1 name - | ffgccheck - | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback - | mov STR:RB, [BASE] - | mov RC, STR:RB->len - | cmp [DISPATCH+DISPATCH_GL(tmpbuf.sz)], RC; jb ->fff_fallback_1 - | add RB, #STR - | mov TMP2, PC // Need another temp register. - |.if X64 - | mov TMP3, RC - |.else - | mov ARG3, RC - |.endif - | mov PC, [DISPATCH+DISPATCH_GL(tmpbuf.buf)] - | jmp >3 - |1: // ASCII case conversion. Yes, this is suboptimal code (do you care?). - | movzx RA, byte [RB+RC] - | cmp RA, lo - | jb >2 - | cmp RA, hi - | ja >2 - | xor RA, 0x20 - |2: - | mov [PC+RC], RAL - |3: - | sub RC, 1 - | jns <1 - | mov RD, PC - | mov PC, TMP2 - | jmp ->fff_newstr - |.endmacro - | - |ffstring_case string_lower, 0x41, 0x5a - |ffstring_case string_upper, 0x61, 0x7a - | - |//-- Table library ------------------------------------------------------ - | - |.ffunc_1 table_getn - | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback - | mov RB, BASE // Save BASE. - | mov TAB:FCARG1, [BASE] - | call extern lj_tab_len@4 // LJ_FASTCALL (GCtab *t) - | // Length of table returned in eax (RD). - | mov BASE, RB // Restore BASE. - |.if DUALNUM - | mov RB, RD; jmp ->fff_resi - |.elif SSE - | cvtsi2sd xmm0, RD; jmp ->fff_resxmm0 - |.else - | mov ARG1, RD; fild ARG1; jmp ->fff_resn - |.endif - | - |//-- Bit library -------------------------------------------------------- - | - |.define TOBIT_BIAS, 0x59c00000 // 2^52 + 2^51 (float, not double!). - | - |.macro .ffunc_bit, name, kind - | .ffunc_1 name - |.if kind == 2 - |.if SSE - | sseconst_tobit xmm1, RBa - |.else - | mov TMP1, TOBIT_BIAS - |.endif - |.endif - | cmp dword [BASE+4], LJ_TISNUM - |.if DUALNUM - | jne >1 - | mov RB, dword [BASE] - |.if kind > 0 - | jmp >2 - |.else - | jmp ->fff_resbit - |.endif - |1: - | ja ->fff_fallback - |.else - | jae ->fff_fallback - |.endif - |.if SSE - | movsd xmm0, qword [BASE] - |.if kind < 2 - | sseconst_tobit xmm1, RBa - |.endif - | addsd xmm0, xmm1 - | movd RB, xmm0 - |.else - | fld qword [BASE] - |.if kind < 2 - | mov TMP1, TOBIT_BIAS - |.endif - | fadd TMP1 - | fstp FPARG1 - |.if kind > 0 - | mov RB, ARG1 - |.endif - |.endif - |2: - |.endmacro - | - |.ffunc_bit bit_tobit, 0 - |.if DUALNUM or SSE - |.if not SSE - | mov RB, ARG1 - |.endif - | jmp ->fff_resbit - |.else - | fild ARG1 - | jmp ->fff_resn - |.endif - | - |.macro .ffunc_bit_op, name, ins - | .ffunc_bit name, 2 - | mov TMP2, NARGS:RD // Save for fallback. - | lea RD, [BASE+NARGS:RD*8-16] - |1: - | cmp RD, BASE - | jbe ->fff_resbit - | cmp dword [RD+4], LJ_TISNUM - |.if DUALNUM - | jne >2 - | ins RB, dword [RD] - | sub RD, 8 - | jmp <1 - |2: - | ja ->fff_fallback_bit_op - |.else - | jae ->fff_fallback_bit_op - |.endif - |.if SSE - | movsd xmm0, qword [RD] - | addsd xmm0, xmm1 - | movd RA, xmm0 - | ins RB, RA - |.else - | fld qword [RD] - | fadd TMP1 - | fstp FPARG1 - | ins RB, ARG1 - |.endif - | sub RD, 8 - | jmp <1 - |.endmacro - | - |.ffunc_bit_op bit_band, and - |.ffunc_bit_op bit_bor, or - |.ffunc_bit_op bit_bxor, xor - | - |.ffunc_bit bit_bswap, 1 - | bswap RB - | jmp ->fff_resbit - | - |.ffunc_bit bit_bnot, 1 - | not RB - |.if DUALNUM - | jmp ->fff_resbit - |.elif SSE - |->fff_resbit: - | cvtsi2sd xmm0, RB - | jmp ->fff_resxmm0 - |.else - |->fff_resbit: - | mov ARG1, RB - | fild ARG1 - | jmp ->fff_resn - |.endif - | - |->fff_fallback_bit_op: - | mov NARGS:RD, TMP2 // Restore for fallback - | jmp ->fff_fallback - | - |.macro .ffunc_bit_sh, name, ins - |.if DUALNUM - | .ffunc_bit name, 1 - | // Note: no inline conversion from number for 2nd argument! - | cmp dword [BASE+12], LJ_TISNUM; jne ->fff_fallback - | mov RA, dword [BASE+8] - |.elif SSE - | .ffunc_nnsse name - | sseconst_tobit xmm2, RBa - | addsd xmm0, xmm2 - | addsd xmm1, xmm2 - | movd RB, xmm0 - | movd RA, xmm1 - |.else - | .ffunc_nn name - | mov TMP1, TOBIT_BIAS - | fadd TMP1 - | fstp FPARG3 - | fadd TMP1 - | fstp FPARG1 - | mov RA, ARG3 - | mov RB, ARG1 - |.endif - | ins RB, cl // Assumes RA is ecx. - | jmp ->fff_resbit - |.endmacro - | - |.ffunc_bit_sh bit_lshift, shl - |.ffunc_bit_sh bit_rshift, shr - |.ffunc_bit_sh bit_arshift, sar - |.ffunc_bit_sh bit_rol, rol - |.ffunc_bit_sh bit_ror, ror - | - |//----------------------------------------------------------------------- - | - |->fff_fallback_2: - | mov NARGS:RD, 1+2 // Other args are ignored, anyway. - | jmp ->fff_fallback - |->fff_fallback_1: - | mov NARGS:RD, 1+1 // Other args are ignored, anyway. - |->fff_fallback: // Call fast function fallback handler. - | // BASE = new base, RD = nargs+1 - | mov L:RB, SAVE_L - | mov PC, [BASE-4] // Fallback may overwrite PC. - | mov SAVE_PC, PC // Redundant (but a defined value). - | mov L:RB->base, BASE - | lea RD, [BASE+NARGS:RD*8-8] - | lea RA, [RD+8*LUA_MINSTACK] // Ensure enough space for handler. - | mov L:RB->top, RD - | mov CFUNC:RD, [BASE-8] - | cmp RA, L:RB->maxstack - | ja >5 // Need to grow stack. - |.if X64 - | mov CARG1d, L:RB - |.else - | mov ARG1, L:RB - |.endif - | call aword CFUNC:RD->f // (lua_State *L) - | mov BASE, L:RB->base - | // Either throws an error, or recovers and returns -1, 0 or nresults+1. - | test RD, RD; jg ->fff_res // Returned nresults+1? - |1: - | mov RA, L:RB->top - | sub RA, BASE - | shr RA, 3 - | test RD, RD - | lea NARGS:RD, [RA+1] - | mov LFUNC:RB, [BASE-8] - | jne ->vm_call_tail // Returned -1? - | ins_callt // Returned 0: retry fast path. - | - |// Reconstruct previous base for vmeta_call during tailcall. - |->vm_call_tail: - | mov RA, BASE - | test PC, FRAME_TYPE - | jnz >3 - | movzx RB, PC_RA - | not RBa // Note: ~RB = -(RB+1) - | lea BASE, [BASE+RB*8] // base = base - (RB+1)*8 - | jmp ->vm_call_dispatch // Resolve again for tailcall. - |3: - | mov RB, PC - | and RB, -8 - | sub BASE, RB - | jmp ->vm_call_dispatch // Resolve again for tailcall. - | - |5: // Grow stack for fallback handler. - | mov FCARG2, LUA_MINSTACK - | mov FCARG1, L:RB - | call extern lj_state_growstack@8 // (lua_State *L, int n) - | mov BASE, L:RB->base - | xor RD, RD // Simulate a return 0. - | jmp <1 // Dumb retry (goes through ff first). - | - |->fff_gcstep: // Call GC step function. - | // BASE = new base, RD = nargs+1 - | pop RBa // Must keep stack at same level. - | mov TMPa, RBa // Save return address - | mov L:RB, SAVE_L - | mov SAVE_PC, PC // Redundant (but a defined value). - | mov L:RB->base, BASE - | lea RD, [BASE+NARGS:RD*8-8] - | mov FCARG1, L:RB - | mov L:RB->top, RD - | call extern lj_gc_step@4 // (lua_State *L) - | mov BASE, L:RB->base - | mov RD, L:RB->top - | sub RD, BASE - | shr RD, 3 - | add NARGS:RD, 1 - | mov RBa, TMPa - | push RBa // Restore return address. - | ret - | - |//----------------------------------------------------------------------- - |//-- Special dispatch targets ------------------------------------------- - |//----------------------------------------------------------------------- - | - |->vm_record: // Dispatch target for recording phase. - |.if JIT - | movzx RD, byte [DISPATCH+DISPATCH_GL(hookmask)] - | test RDL, HOOK_VMEVENT // No recording while in vmevent. - | jnz >5 - | // Decrement the hookcount for consistency, but always do the call. - | test RDL, HOOK_ACTIVE - | jnz >1 - | test RDL, LUA_MASKLINE|LUA_MASKCOUNT - | jz >1 - | dec dword [DISPATCH+DISPATCH_GL(hookcount)] - | jmp >1 - |.endif - | - |->vm_rethook: // Dispatch target for return hooks. - | movzx RD, byte [DISPATCH+DISPATCH_GL(hookmask)] - | test RDL, HOOK_ACTIVE // Hook already active? - | jnz >5 - | jmp >1 - | - |->vm_inshook: // Dispatch target for instr/line hooks. - | movzx RD, byte [DISPATCH+DISPATCH_GL(hookmask)] - | test RDL, HOOK_ACTIVE // Hook already active? - | jnz >5 - | - | test RDL, LUA_MASKLINE|LUA_MASKCOUNT - | jz >5 - | dec dword [DISPATCH+DISPATCH_GL(hookcount)] - | jz >1 - | test RDL, LUA_MASKLINE - | jz >5 - |1: - | mov L:RB, SAVE_L - | mov L:RB->base, BASE - | mov FCARG2, PC // Caveat: FCARG2 == BASE - | mov FCARG1, L:RB - | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. - | call extern lj_dispatch_ins@8 // (lua_State *L, BCIns *pc) - |3: - | mov BASE, L:RB->base - |4: - | movzx RA, PC_RA - |5: - | movzx OP, PC_OP - | movzx RD, PC_RD - |.if X64 - | jmp aword [DISPATCH+OP*8+GG_DISP2STATIC] // Re-dispatch to static ins. - |.else - | jmp aword [DISPATCH+OP*4+GG_DISP2STATIC] // Re-dispatch to static ins. - |.endif - | - |->cont_hook: // Continue from hook yield. - | add PC, 4 - | mov RA, [RB-24] - | mov MULTRES, RA // Restore MULTRES for *M ins. - | jmp <4 - | - |->vm_hotloop: // Hot loop counter underflow. - |.if JIT - | mov LFUNC:RB, [BASE-8] // Same as curr_topL(L). - | mov RB, LFUNC:RB->pc - | movzx RD, byte [RB+PC2PROTO(framesize)] - | lea RD, [BASE+RD*8] - | mov L:RB, SAVE_L - | mov L:RB->base, BASE - | mov L:RB->top, RD - | mov FCARG2, PC - | lea FCARG1, [DISPATCH+GG_DISP2J] - | mov aword [DISPATCH+DISPATCH_J(L)], L:RBa - | mov SAVE_PC, PC - | call extern lj_trace_hot@8 // (jit_State *J, const BCIns *pc) - | jmp <3 - |.endif - | - |->vm_callhook: // Dispatch target for call hooks. - | mov SAVE_PC, PC - |.if JIT - | jmp >1 - |.endif - | - |->vm_hotcall: // Hot call counter underflow. - |.if JIT - | mov SAVE_PC, PC - | or PC, 1 // Marker for hot call. - |1: - |.endif - | lea RD, [BASE+NARGS:RD*8-8] - | mov L:RB, SAVE_L - | mov L:RB->base, BASE - | mov L:RB->top, RD - | mov FCARG2, PC - | mov FCARG1, L:RB - | call extern lj_dispatch_call@8 // (lua_State *L, const BCIns *pc) - | // ASMFunction returned in eax/rax (RDa). - | mov SAVE_PC, 0 // Invalidate for subsequent line hook. - |.if JIT - | and PC, -2 - |.endif - | mov BASE, L:RB->base - | mov RAa, RDa - | mov RD, L:RB->top - | sub RD, BASE - | mov RBa, RAa - | movzx RA, PC_RA - | shr RD, 3 - | add NARGS:RD, 1 - | jmp RBa - | - |//----------------------------------------------------------------------- - |//-- Trace exit handler ------------------------------------------------- - |//----------------------------------------------------------------------- - | - |// Called from an exit stub with the exit number on the stack. - |// The 16 bit exit number is stored with two (sign-extended) push imm8. - |->vm_exit_handler: - |.if JIT - |.if X64 - | push r13; push r12 - | push r11; push r10; push r9; push r8 - | push rdi; push rsi; push rbp; lea rbp, [rsp+88]; push rbp - | push rbx; push rdx; push rcx; push rax - | movzx RC, byte [rbp-8] // Reconstruct exit number. - | mov RCH, byte [rbp-16] - | mov [rbp-8], r15; mov [rbp-16], r14 - |.else - | push ebp; lea ebp, [esp+12]; push ebp - | push ebx; push edx; push ecx; push eax - | movzx RC, byte [ebp-4] // Reconstruct exit number. - | mov RCH, byte [ebp-8] - | mov [ebp-4], edi; mov [ebp-8], esi - |.endif - | // Caveat: DISPATCH is ebx. - | mov DISPATCH, [ebp] - | mov RA, [DISPATCH+DISPATCH_GL(vmstate)] // Get trace number. - | set_vmstate EXIT - | mov [DISPATCH+DISPATCH_J(exitno)], RC - | mov [DISPATCH+DISPATCH_J(parent)], RA - |.if X64 - |.if X64WIN - | sub rsp, 16*8+4*8 // Room for SSE regs + save area. - |.else - | sub rsp, 16*8 // Room for SSE regs. - |.endif - | add rbp, -128 - | movsd qword [rbp-8], xmm15; movsd qword [rbp-16], xmm14 - | movsd qword [rbp-24], xmm13; movsd qword [rbp-32], xmm12 - | movsd qword [rbp-40], xmm11; movsd qword [rbp-48], xmm10 - | movsd qword [rbp-56], xmm9; movsd qword [rbp-64], xmm8 - | movsd qword [rbp-72], xmm7; movsd qword [rbp-80], xmm6 - | movsd qword [rbp-88], xmm5; movsd qword [rbp-96], xmm4 - | movsd qword [rbp-104], xmm3; movsd qword [rbp-112], xmm2 - | movsd qword [rbp-120], xmm1; movsd qword [rbp-128], xmm0 - |.else - | sub esp, 8*8+16 // Room for SSE regs + args. - | movsd qword [ebp-40], xmm7; movsd qword [ebp-48], xmm6 - | movsd qword [ebp-56], xmm5; movsd qword [ebp-64], xmm4 - | movsd qword [ebp-72], xmm3; movsd qword [ebp-80], xmm2 - | movsd qword [ebp-88], xmm1; movsd qword [ebp-96], xmm0 - |.endif - | // Caveat: RB is ebp. - | mov L:RB, [DISPATCH+DISPATCH_GL(jit_L)] - | mov BASE, [DISPATCH+DISPATCH_GL(jit_base)] - | mov aword [DISPATCH+DISPATCH_J(L)], L:RBa - | mov dword [DISPATCH+DISPATCH_GL(jit_L)], 0 - | mov L:RB->base, BASE - |.if X64WIN - | lea CARG2, [rsp+4*8] - |.elif X64 - | mov CARG2, rsp - |.else - | lea FCARG2, [esp+16] - |.endif - | lea FCARG1, [DISPATCH+GG_DISP2J] - | call extern lj_trace_exit@8 // (jit_State *J, ExitState *ex) - | // MULTRES or negated error code returned in eax (RD). - | mov RAa, L:RB->cframe - | and RAa, CFRAME_RAWMASK - |.if X64WIN - | // Reposition stack later. - |.elif X64 - | mov rsp, RAa // Reposition stack to C frame. - |.else - | mov esp, RAa // Reposition stack to C frame. - |.endif - | mov [RAa+CFRAME_OFS_L], L:RB // Set SAVE_L (on-trace resume/yield). - | mov BASE, L:RB->base - | mov PC, [RAa+CFRAME_OFS_PC] // Get SAVE_PC. - |.if X64 - | jmp >1 - |.endif - |.endif - |->vm_exit_interp: - | // RD = MULTRES or negated error code, BASE, PC and DISPATCH set. - |.if JIT - |.if X64 - | // Restore additional callee-save registers only used in compiled code. - |.if X64WIN - | lea RAa, [rsp+9*16+4*8] - |1: - | movdqa xmm15, [RAa-9*16] - | movdqa xmm14, [RAa-8*16] - | movdqa xmm13, [RAa-7*16] - | movdqa xmm12, [RAa-6*16] - | movdqa xmm11, [RAa-5*16] - | movdqa xmm10, [RAa-4*16] - | movdqa xmm9, [RAa-3*16] - | movdqa xmm8, [RAa-2*16] - | movdqa xmm7, [RAa-1*16] - | mov rsp, RAa // Reposition stack to C frame. - | movdqa xmm6, [RAa] - | mov r15, CSAVE_3 - | mov r14, CSAVE_4 - |.else - | add rsp, 16 // Reposition stack to C frame. - |1: - |.endif - | mov r13, TMPa - | mov r12, TMPQ - |.endif - | test RD, RD; js >3 // Check for error from exit. - | mov MULTRES, RD - | mov LFUNC:KBASE, [BASE-8] - | mov KBASE, LFUNC:KBASE->pc - | mov KBASE, [KBASE+PC2PROTO(k)] - | mov dword [DISPATCH+DISPATCH_GL(jit_L)], 0 - | set_vmstate INTERP - | // Modified copy of ins_next which handles function header dispatch, too. - | mov RC, [PC] - | movzx RA, RCH - | movzx OP, RCL - | add PC, 4 - | shr RC, 16 - | cmp OP, BC_FUNCF // Function header? - | jb >2 - | mov RC, MULTRES // RC/RD holds nres+1. - |2: - |.if X64 - | jmp aword [DISPATCH+OP*8] - |.else - | jmp aword [DISPATCH+OP*4] - |.endif - | - |3: // Rethrow error from the right C frame. - | neg RD - | mov FCARG1, L:RB - | mov FCARG2, RD - | call extern lj_err_throw@8 // (lua_State *L, int errcode) - |.endif - | - |//----------------------------------------------------------------------- - |//-- Math helper functions ---------------------------------------------- - |//----------------------------------------------------------------------- - | - |// FP value rounding. Called by math.floor/math.ceil fast functions - |// and from JIT code. - | - |// x87 variant: Arg/ret on x87 stack. No int/xmm registers modified. - |.macro vm_round_x87, mode1, mode2 - | fnstcw word [esp+4] // Caveat: overwrites ARG1 and ARG2. - | mov [esp+8], eax - | mov ax, mode1 - | or ax, [esp+4] - |.if mode2 ~= 0xffff - | and ax, mode2 - |.endif - | mov [esp+6], ax - | fldcw word [esp+6] - | frndint - | fldcw word [esp+4] - | mov eax, [esp+8] - | ret - |.endmacro - | - |// SSE variant: arg/ret is xmm0. xmm0-xmm3 and RD (eax) modified. - |.macro vm_round_sse, mode - | sseconst_abs xmm2, RDa - | sseconst_2p52 xmm3, RDa - | movaps xmm1, xmm0 - | andpd xmm1, xmm2 // |x| - | ucomisd xmm3, xmm1 // No truncation if 2^52 <= |x|. - | jbe >1 - | andnpd xmm2, xmm0 // Isolate sign bit. - |.if mode == 2 // trunc(x)? - | movaps xmm0, xmm1 - | addsd xmm1, xmm3 // (|x| + 2^52) - 2^52 - | subsd xmm1, xmm3 - | sseconst_1 xmm3, RDa - | cmpsd xmm0, xmm1, 1 // |x| < result? - | andpd xmm0, xmm3 - | subsd xmm1, xmm0 // If yes, subtract -1. - | orpd xmm1, xmm2 // Merge sign bit back in. - |.else - | addsd xmm1, xmm3 // (|x| + 2^52) - 2^52 - | subsd xmm1, xmm3 - | orpd xmm1, xmm2 // Merge sign bit back in. - | .if mode == 1 // ceil(x)? - | sseconst_m1 xmm2, RDa // Must subtract -1 to preserve -0. - | cmpsd xmm0, xmm1, 6 // x > result? - | .else // floor(x)? - | sseconst_1 xmm2, RDa - | cmpsd xmm0, xmm1, 1 // x < result? - | .endif - | andpd xmm0, xmm2 - | subsd xmm1, xmm0 // If yes, subtract +-1. - |.endif - | movaps xmm0, xmm1 - |1: - | ret - |.endmacro - | - |.macro vm_round, name, ssemode, mode1, mode2 - |->name: - |.if not SSE - | vm_round_x87 mode1, mode2 - |.endif - |->name .. _sse: - | vm_round_sse ssemode - |.endmacro - | - | vm_round vm_floor, 0, 0x0400, 0xf7ff - | vm_round vm_ceil, 1, 0x0800, 0xfbff - | vm_round vm_trunc, 2, 0x0c00, 0xffff - | - |// FP modulo x%y. Called by BC_MOD* and vm_arith. - |->vm_mod: - |.if SSE - |// Args in xmm0/xmm1, return value in xmm0. - |// Caveat: xmm0-xmm5 and RC (eax) modified! - | movaps xmm5, xmm0 - | divsd xmm0, xmm1 - | sseconst_abs xmm2, RDa - | sseconst_2p52 xmm3, RDa - | movaps xmm4, xmm0 - | andpd xmm4, xmm2 // |x/y| - | ucomisd xmm3, xmm4 // No truncation if 2^52 <= |x/y|. - | jbe >1 - | andnpd xmm2, xmm0 // Isolate sign bit. - | addsd xmm4, xmm3 // (|x/y| + 2^52) - 2^52 - | subsd xmm4, xmm3 - | orpd xmm4, xmm2 // Merge sign bit back in. - | sseconst_1 xmm2, RDa - | cmpsd xmm0, xmm4, 1 // x/y < result? - | andpd xmm0, xmm2 - | subsd xmm4, xmm0 // If yes, subtract 1.0. - | movaps xmm0, xmm5 - | mulsd xmm1, xmm4 - | subsd xmm0, xmm1 - | ret - |1: - | mulsd xmm1, xmm0 - | movaps xmm0, xmm5 - | subsd xmm0, xmm1 - | ret - |.else - |// Args/ret on x87 stack (y on top). No xmm registers modified. - |// Caveat: needs 3 slots on x87 stack! RC (eax) modified! - | fld st1 - | fdiv st1 - | fnstcw word [esp+4] - | mov ax, 0x0400 - | or ax, [esp+4] - | and ax, 0xf7ff - | mov [esp+6], ax - | fldcw word [esp+6] - | frndint - | fldcw word [esp+4] - | fmulp st1 - | fsubp st1 - | ret - |.endif - | - |// FP log2(x). Called by math.log(x, base). - |->vm_log2: - |.if X64WIN - | movsd qword [rsp+8], xmm0 // Use scratch area. - | fld1 - | fld qword [rsp+8] - | fyl2x - | fstp qword [rsp+8] - | movsd xmm0, qword [rsp+8] - |.elif X64 - | movsd qword [rsp-8], xmm0 // Use red zone. - | fld1 - | fld qword [rsp-8] - | fyl2x - | fstp qword [rsp-8] - | movsd xmm0, qword [rsp-8] - |.else - | fld1 - | fld qword [esp+4] - | fyl2x - |.endif - | ret - | - |// FP exponentiation e^x and 2^x. Called by math.exp fast function and - |// from JIT code. Arg/ret on x87 stack. No int/xmm regs modified. - |// Caveat: needs 3 slots on x87 stack! - |->vm_exp_x87: - | fldl2e; fmulp st1 // e^x ==> 2^(x*log2(e)) - |->vm_exp2_x87: - | .if X64WIN - | .define expscratch, dword [rsp+8] // Use scratch area. - | .elif X64 - | .define expscratch, dword [rsp-8] // Use red zone. - | .else - | .define expscratch, dword [esp+4] // Needs 4 byte scratch area. - | .endif - | fst expscratch // Caveat: overwrites ARG1. - | cmp expscratch, 0x7f800000; je >1 // Special case: e^+Inf = +Inf - | cmp expscratch, 0xff800000; je >2 // Special case: e^-Inf = 0 - |->vm_exp2raw: // Entry point for vm_pow. Without +-Inf check. - | fdup; frndint; fsub st1, st0; fxch // Split into frac/int part. - | f2xm1; fld1; faddp st1; fscale; fpop1 // ==> (2^frac-1 +1) << int - |1: - | ret - |2: - | fpop; fldz; ret - | - |// Generic power function x^y. Called by BC_POW, math.pow fast function, - |// and vm_arith. - |// Args/ret on x87 stack (y on top). RC (eax) modified. - |// Caveat: needs 3 slots on x87 stack! - |->vm_pow: - |.if not SSE - | fist dword [esp+4] // Store/reload int before comparison. - | fild dword [esp+4] // Integral exponent used in vm_powi. - | fucomip st1 - | jnz >8 // Branch for FP exponents. - | jp >9 // Branch for NaN exponent. - | fpop // Pop y and fallthrough to vm_powi. - | - |// FP/int power function x^i. Arg1/ret on x87 stack. - |// Arg2 (int) on C stack. RC (eax) modified. - |// Caveat: needs 2 slots on x87 stack! - | mov eax, [esp+4] - | cmp eax, 1; jle >6 // i<=1? - | // Now 1 < (unsigned)i <= 0x80000000. - |1: // Handle leading zeros. - | test eax, 1; jnz >2 - | fmul st0 - | shr eax, 1 - | jmp <1 - |2: - | shr eax, 1; jz >5 - | fdup - |3: // Handle trailing bits. - | fmul st0 - | shr eax, 1; jz >4 - | jnc <3 - | fmul st1, st0 - | jmp <3 - |4: - | fmulp st1 - |5: - | ret - |6: - | je <5 // x^1 ==> x - | jb >7 - | fld1; fdivrp st1 - | neg eax - | cmp eax, 1; je <5 // x^-1 ==> 1/x - | jmp <1 // x^-i ==> (1/x)^i - |7: - | fpop; fld1 // x^0 ==> 1 - | ret - | - |8: // FP/FP power function x^y. - | fst dword [esp+4] - | fxch - | fst dword [esp+8] - | mov eax, [esp+4]; shl eax, 1 - | cmp eax, 0xff000000; je >2 // x^+-Inf? - | mov eax, [esp+8]; shl eax, 1; je >4 // +-0^y? - | cmp eax, 0xff000000; je >4 // +-Inf^y? - | fyl2x - | jmp ->vm_exp2raw - | - |9: // Handle x^NaN. - | fld1 - | fucomip st2 - | je >1 // 1^NaN ==> 1 - | fxch // x^NaN ==> NaN - |1: - | fpop - | ret - | - |2: // Handle x^+-Inf. - | fabs - | fld1 - | fucomip st1 - | je >3 // +-1^+-Inf ==> 1 - | fpop; fabs; fldz; mov eax, 0; setc al - | ror eax, 1; xor eax, [esp+4]; jns >3 // |x|<>1, x^+-Inf ==> +Inf/0 - | fxch - |3: - | fpop1; fabs - | ret - | - |4: // Handle +-0^y or +-Inf^y. - | cmp dword [esp+4], 0; jge <3 // y >= 0, x^y ==> |x| - | fpop; fpop - | test eax, eax; jz >5 // y < 0, +-0^y ==> +Inf - | fldz // y < 0, +-Inf^y ==> 0 - | ret - |5: - | mov dword [esp+4], 0x7f800000 // Return +Inf. - | fld dword [esp+4] - | ret - |.endif - | - |// Args in xmm0/xmm1. Ret in xmm0. xmm0-xmm2 and RC (eax) modified. - |// Needs 16 byte scratch area for x86. Also called from JIT code. - |->vm_pow_sse: - | cvtsd2si eax, xmm1 - | cvtsi2sd xmm2, eax - | ucomisd xmm1, xmm2 - | jnz >8 // Branch for FP exponents. - | jp >9 // Branch for NaN exponent. - | // Fallthrough to vm_powi_sse. - | - |// Args in xmm0/eax. Ret in xmm0. xmm0-xmm1 and eax modified. - |->vm_powi_sse: - | cmp eax, 1; jle >6 // i<=1? - | // Now 1 < (unsigned)i <= 0x80000000. - |1: // Handle leading zeros. - | test eax, 1; jnz >2 - | mulsd xmm0, xmm0 - | shr eax, 1 - | jmp <1 - |2: - | shr eax, 1; jz >5 - | movaps xmm1, xmm0 - |3: // Handle trailing bits. - | mulsd xmm0, xmm0 - | shr eax, 1; jz >4 - | jnc <3 - | mulsd xmm1, xmm0 - | jmp <3 - |4: - | mulsd xmm0, xmm1 - |5: - | ret - |6: - | je <5 // x^1 ==> x - | jb >7 // x^0 ==> 1 - | neg eax - | call <1 - | sseconst_1 xmm1, RDa - | divsd xmm1, xmm0 - | movaps xmm0, xmm1 - | ret - |7: - | sseconst_1 xmm0, RDa - | ret - | - |8: // FP/FP power function x^y. - |.if X64 - | movd rax, xmm1; shl rax, 1 - | rol rax, 12; cmp rax, 0xffe; je >2 // x^+-Inf? - | movd rax, xmm0; shl rax, 1; je >4 // +-0^y? - | rol rax, 12; cmp rax, 0xffe; je >5 // +-Inf^y? - | .if X64WIN - | movsd qword [rsp+16], xmm1 // Use scratch area. - | movsd qword [rsp+8], xmm0 - | fld qword [rsp+16] - | fld qword [rsp+8] - | .else - | movsd qword [rsp-16], xmm1 // Use red zone. - | movsd qword [rsp-8], xmm0 - | fld qword [rsp-16] - | fld qword [rsp-8] - | .endif - |.else - | movsd qword [esp+12], xmm1 // Needs 16 byte scratch area. - | movsd qword [esp+4], xmm0 - | cmp dword [esp+12], 0; jne >1 - | mov eax, [esp+16]; shl eax, 1 - | cmp eax, 0xffe00000; je >2 // x^+-Inf? - |1: - | cmp dword [esp+4], 0; jne >1 - | mov eax, [esp+8]; shl eax, 1; je >4 // +-0^y? - | cmp eax, 0xffe00000; je >5 // +-Inf^y? - |1: - | fld qword [esp+12] - | fld qword [esp+4] - |.endif - | fyl2x // y*log2(x) - | fdup; frndint; fsub st1, st0; fxch // Split into frac/int part. - | f2xm1; fld1; faddp st1; fscale; fpop1 // ==> (2^frac-1 +1) << int - |.if X64WIN - | fstp qword [rsp+8] // Use scratch area. - | movsd xmm0, qword [rsp+8] - |.elif X64 - | fstp qword [rsp-8] // Use red zone. - | movsd xmm0, qword [rsp-8] - |.else - | fstp qword [esp+4] // Needs 8 byte scratch area. - | movsd xmm0, qword [esp+4] - |.endif - | ret - | - |9: // Handle x^NaN. - | sseconst_1 xmm2, RDa - | ucomisd xmm0, xmm2; je >1 // 1^NaN ==> 1 - | movaps xmm0, xmm1 // x^NaN ==> NaN - |1: - | ret - | - |2: // Handle x^+-Inf. - | sseconst_abs xmm2, RDa - | andpd xmm0, xmm2 // |x| - | sseconst_1 xmm2, RDa - | ucomisd xmm0, xmm2; je <1 // +-1^+-Inf ==> 1 - | movmskpd eax, xmm1 - | xorps xmm0, xmm0 - | mov ah, al; setc al; xor al, ah; jne <1 // |x|<>1, x^+-Inf ==> +Inf/0 - |3: - | sseconst_hi xmm0, RDa, 7ff00000 // +Inf - | ret - | - |4: // Handle +-0^y. - | movmskpd eax, xmm1; test eax, eax; jnz <3 // y < 0, +-0^y ==> +Inf - | xorps xmm0, xmm0 // y >= 0, +-0^y ==> 0 - | ret - | - |5: // Handle +-Inf^y. - | movmskpd eax, xmm1; test eax, eax; jz <3 // y >= 0, +-Inf^y ==> +Inf - | xorps xmm0, xmm0 // y < 0, +-Inf^y ==> 0 - | ret - | - |// Callable from C: double lj_vm_foldfpm(double x, int fpm) - |// Computes fpm(x) for extended math functions. ORDER FPM. - |->vm_foldfpm: - |.if JIT - |.if X64 - | .if X64WIN - | .define fpmop, CARG2d - | .else - | .define fpmop, CARG1d - | .endif - | cmp fpmop, 1; jb ->vm_floor; je ->vm_ceil - | cmp fpmop, 3; jb ->vm_trunc; ja >2 - | sqrtsd xmm0, xmm0; ret - |2: - | .if X64WIN - | movsd qword [rsp+8], xmm0 // Use scratch area. - | fld qword [rsp+8] - | .else - | movsd qword [rsp-8], xmm0 // Use red zone. - | fld qword [rsp-8] - | .endif - | cmp fpmop, 5; ja >2 - | .if X64WIN; pop rax; .endif - | je >1 - | call ->vm_exp_x87 - | .if X64WIN; push rax; .endif - | jmp >7 - |1: - | call ->vm_exp2_x87 - | .if X64WIN; push rax; .endif - | jmp >7 - |2: ; cmp fpmop, 7; je >1; ja >2 - | fldln2; fxch; fyl2x; jmp >7 - |1: ; fld1; fxch; fyl2x; jmp >7 - |2: ; cmp fpmop, 9; je >1; ja >2 - | fldlg2; fxch; fyl2x; jmp >7 - |1: ; fsin; jmp >7 - |2: ; cmp fpmop, 11; je >1; ja >9 - | fcos; jmp >7 - |1: ; fptan; fpop - |7: - | .if X64WIN - | fstp qword [rsp+8] // Use scratch area. - | movsd xmm0, qword [rsp+8] - | .else - | fstp qword [rsp-8] // Use red zone. - | movsd xmm0, qword [rsp-8] - | .endif - | ret - |.else // x86 calling convention. - | .define fpmop, eax - |.if SSE - | mov fpmop, [esp+12] - | movsd xmm0, qword [esp+4] - | cmp fpmop, 1; je >1; ja >2 - | call ->vm_floor; jmp >7 - |1: ; call ->vm_ceil; jmp >7 - |2: ; cmp fpmop, 3; je >1; ja >2 - | call ->vm_trunc; jmp >7 - |1: - | sqrtsd xmm0, xmm0 - |7: - | movsd qword [esp+4], xmm0 // Overwrite callee-owned args. - | fld qword [esp+4] - | ret - |2: ; fld qword [esp+4] - | cmp fpmop, 5; jb ->vm_exp_x87; je ->vm_exp2_x87 - |2: ; cmp fpmop, 7; je >1; ja >2 - | fldln2; fxch; fyl2x; ret - |1: ; fld1; fxch; fyl2x; ret - |2: ; cmp fpmop, 9; je >1; ja >2 - | fldlg2; fxch; fyl2x; ret - |1: ; fsin; ret - |2: ; cmp fpmop, 11; je >1; ja >9 - | fcos; ret - |1: ; fptan; fpop; ret - |.else - | mov fpmop, [esp+12] - | fld qword [esp+4] - | cmp fpmop, 1; jb ->vm_floor; je ->vm_ceil - | cmp fpmop, 3; jb ->vm_trunc; ja >2 - | fsqrt; ret - |2: ; cmp fpmop, 5; jb ->vm_exp_x87; je ->vm_exp2_x87 - | cmp fpmop, 7; je >1; ja >2 - | fldln2; fxch; fyl2x; ret - |1: ; fld1; fxch; fyl2x; ret - |2: ; cmp fpmop, 9; je >1; ja >2 - | fldlg2; fxch; fyl2x; ret - |1: ; fsin; ret - |2: ; cmp fpmop, 11; je >1; ja >9 - | fcos; ret - |1: ; fptan; fpop; ret - |.endif - |.endif - |9: ; int3 // Bad fpm. - |.endif - | - |// Callable from C: double lj_vm_foldarith(double x, double y, int op) - |// Compute x op y for basic arithmetic operators (+ - * / % ^ and unary -) - |// and basic math functions. ORDER ARITH - |->vm_foldarith: - |.if X64 - | - | .if X64WIN - | .define foldop, CARG3d - | .else - | .define foldop, CARG1d - | .endif - | cmp foldop, 1; je >1; ja >2 - | addsd xmm0, xmm1; ret - |1: ; subsd xmm0, xmm1; ret - |2: ; cmp foldop, 3; je >1; ja >2 - | mulsd xmm0, xmm1; ret - |1: ; divsd xmm0, xmm1; ret - |2: ; cmp foldop, 5; jb ->vm_mod; je ->vm_pow - | cmp foldop, 7; je >1; ja >2 - | sseconst_sign xmm1, RDa; xorps xmm0, xmm1; ret - |1: ; sseconst_abs xmm1, RDa; andps xmm0, xmm1; ret - |2: ; cmp foldop, 9; ja >2 - |.if X64WIN - | movsd qword [rsp+8], xmm0 // Use scratch area. - | movsd qword [rsp+16], xmm1 - | fld qword [rsp+8] - | fld qword [rsp+16] - |.else - | movsd qword [rsp-8], xmm0 // Use red zone. - | movsd qword [rsp-16], xmm1 - | fld qword [rsp-8] - | fld qword [rsp-16] - |.endif - | je >1 - | fpatan - |7: - |.if X64WIN - | fstp qword [rsp+8] // Use scratch area. - | movsd xmm0, qword [rsp+8] - |.else - | fstp qword [rsp-8] // Use red zone. - | movsd xmm0, qword [rsp-8] - |.endif - | ret - |1: ; fxch; fscale; fpop1; jmp <7 - |2: ; cmp foldop, 11; je >1; ja >9 - | minsd xmm0, xmm1; ret - |1: ; maxsd xmm0, xmm1; ret - |9: ; int3 // Bad op. - | - |.elif SSE // x86 calling convention with SSE ops. - | - | .define foldop, eax - | mov foldop, [esp+20] - | movsd xmm0, qword [esp+4] - | movsd xmm1, qword [esp+12] - | cmp foldop, 1; je >1; ja >2 - | addsd xmm0, xmm1 - |7: - | movsd qword [esp+4], xmm0 // Overwrite callee-owned args. - | fld qword [esp+4] - | ret - |1: ; subsd xmm0, xmm1; jmp <7 - |2: ; cmp foldop, 3; je >1; ja >2 - | mulsd xmm0, xmm1; jmp <7 - |1: ; divsd xmm0, xmm1; jmp <7 - |2: ; cmp foldop, 5 - | je >1; ja >2 - | call ->vm_mod; jmp <7 - |1: ; pop edx; call ->vm_pow; push edx; jmp <7 // Writes to scratch area. - |2: ; cmp foldop, 7; je >1; ja >2 - | sseconst_sign xmm1, RDa; xorps xmm0, xmm1; jmp <7 - |1: ; sseconst_abs xmm1, RDa; andps xmm0, xmm1; jmp <7 - |2: ; cmp foldop, 9; ja >2 - | fld qword [esp+4] // Reload from stack - | fld qword [esp+12] - | je >1 - | fpatan; ret - |1: ; fxch; fscale; fpop1; ret - |2: ; cmp foldop, 11; je >1; ja >9 - | minsd xmm0, xmm1; jmp <7 - |1: ; maxsd xmm0, xmm1; jmp <7 - |9: ; int3 // Bad op. - | - |.else // x86 calling convention with x87 ops. - | - | mov eax, [esp+20] - | fld qword [esp+4] - | fld qword [esp+12] - | cmp eax, 1; je >1; ja >2 - | faddp st1; ret - |1: ; fsubp st1; ret - |2: ; cmp eax, 3; je >1; ja >2 - | fmulp st1; ret - |1: ; fdivp st1; ret - |2: ; cmp eax, 5; jb ->vm_mod; je ->vm_pow - | cmp eax, 7; je >1; ja >2 - | fpop; fchs; ret - |1: ; fpop; fabs; ret - |2: ; cmp eax, 9; je >1; ja >2 - | fpatan; ret - |1: ; fxch; fscale; fpop1; ret - |2: ; cmp eax, 11; je >1; ja >9 - | fucomi st1; fcmovnbe st1; fpop1; ret - |1: ; fucomi st1; fcmovbe st1; fpop1; ret - |9: ; int3 // Bad op. - | - |.endif - | - |//----------------------------------------------------------------------- - |//-- Miscellaneous functions -------------------------------------------- - |//----------------------------------------------------------------------- - | - |// int lj_vm_cpuid(uint32_t f, uint32_t res[4]) - |->vm_cpuid: - |.if X64 - | mov eax, CARG1d - | .if X64WIN; push rsi; mov rsi, CARG2; .endif - | push rbx - | cpuid - | mov [rsi], eax - | mov [rsi+4], ebx - | mov [rsi+8], ecx - | mov [rsi+12], edx - | pop rbx - | .if X64WIN; pop rsi; .endif - | ret - |.else - | pushfd - | pop edx - | mov ecx, edx - | xor edx, 0x00200000 // Toggle ID bit in flags. - | push edx - | popfd - | pushfd - | pop edx - | xor eax, eax // Zero means no features supported. - | cmp ecx, edx - | jz >1 // No ID toggle means no CPUID support. - | mov eax, [esp+4] // Argument 1 is function number. - | push edi - | push ebx - | cpuid - | mov edi, [esp+16] // Argument 2 is result area. - | mov [edi], eax - | mov [edi+4], ebx - | mov [edi+8], ecx - | mov [edi+12], edx - | pop ebx - | pop edi - |1: - | ret - |.endif - | - |//----------------------------------------------------------------------- - |//-- Assertions --------------------------------------------------------- - |//----------------------------------------------------------------------- - | - |->assert_bad_for_arg_type: -#ifdef LUA_USE_ASSERT - | int3 -#endif - | int3 - | - |//----------------------------------------------------------------------- - |//-- FFI helper functions ----------------------------------------------- - |//----------------------------------------------------------------------- - | - |// Handler for callback functions. Callback slot number in ah/al. - |->vm_ffi_callback: - |.if FFI - |.type CTSTATE, CTState, PC - |.if not X64 - | sub esp, 16 // Leave room for SAVE_ERRF etc. - |.endif - | saveregs_ // ebp/rbp already saved. ebp now holds global_State *. - | lea DISPATCH, [ebp+GG_G2DISP] - | mov CTSTATE, GL:ebp->ctype_state - | movzx eax, ax - | mov CTSTATE->cb.slot, eax - |.if X64 - | mov CTSTATE->cb.gpr[0], CARG1 - | mov CTSTATE->cb.gpr[1], CARG2 - | mov CTSTATE->cb.gpr[2], CARG3 - | mov CTSTATE->cb.gpr[3], CARG4 - | movsd qword CTSTATE->cb.fpr[0], xmm0 - | movsd qword CTSTATE->cb.fpr[1], xmm1 - | movsd qword CTSTATE->cb.fpr[2], xmm2 - | movsd qword CTSTATE->cb.fpr[3], xmm3 - |.if X64WIN - | lea rax, [rsp+CFRAME_SIZE+4*8] - |.else - | lea rax, [rsp+CFRAME_SIZE] - | mov CTSTATE->cb.gpr[4], CARG5 - | mov CTSTATE->cb.gpr[5], CARG6 - | movsd qword CTSTATE->cb.fpr[4], xmm4 - | movsd qword CTSTATE->cb.fpr[5], xmm5 - | movsd qword CTSTATE->cb.fpr[6], xmm6 - | movsd qword CTSTATE->cb.fpr[7], xmm7 - |.endif - | mov CTSTATE->cb.stack, rax - | mov CARG2, rsp - |.else - | lea eax, [esp+CFRAME_SIZE+16] - | mov CTSTATE->cb.gpr[0], FCARG1 - | mov CTSTATE->cb.gpr[1], FCARG2 - | mov CTSTATE->cb.stack, eax - | mov FCARG1, [esp+CFRAME_SIZE+12] // Move around misplaced retaddr/ebp. - | mov FCARG2, [esp+CFRAME_SIZE+8] - | mov SAVE_RET, FCARG1 - | mov SAVE_R4, FCARG2 - | mov FCARG2, esp - |.endif - | mov SAVE_PC, CTSTATE // Any value outside of bytecode is ok. - | mov FCARG1, CTSTATE - | call extern lj_ccallback_enter@8 // (CTState *cts, void *cf) - | // lua_State * returned in eax (RD). - | set_vmstate INTERP - | mov BASE, L:RD->base - | mov RD, L:RD->top - | sub RD, BASE - | mov LFUNC:RB, [BASE-8] - | shr RD, 3 - | add RD, 1 - | ins_callt - |.endif - | - |->cont_ffi_callback: // Return from FFI callback. - |.if FFI - | mov L:RA, SAVE_L - | mov CTSTATE, [DISPATCH+DISPATCH_GL(ctype_state)] - | mov aword CTSTATE->L, L:RAa - | mov L:RA->base, BASE - | mov L:RA->top, RB - | mov FCARG1, CTSTATE - | mov FCARG2, RC - | call extern lj_ccallback_leave@8 // (CTState *cts, TValue *o) - |.if X64 - | mov rax, CTSTATE->cb.gpr[0] - | movsd xmm0, qword CTSTATE->cb.fpr[0] - | jmp ->vm_leave_unw - |.else - | mov L:RB, SAVE_L - | mov eax, CTSTATE->cb.gpr[0] - | mov edx, CTSTATE->cb.gpr[1] - | cmp dword CTSTATE->cb.gpr[2], 1 - | jb >7 - | je >6 - | fld qword CTSTATE->cb.fpr[0].d - | jmp >7 - |6: - | fld dword CTSTATE->cb.fpr[0].f - |7: - | mov ecx, L:RB->top - | movzx ecx, word [ecx+6] // Get stack adjustment and copy up. - | mov SAVE_L, ecx // Must be one slot above SAVE_RET - | restoreregs - | pop ecx // Move return addr from SAVE_RET. - | add esp, [esp] // Adjust stack. - | add esp, 16 - | push ecx - | ret - |.endif - |.endif - | - |->vm_ffi_call@4: // Call C function via FFI. - | // Caveat: needs special frame unwinding, see below. - |.if FFI - |.if X64 - | .type CCSTATE, CCallState, rbx - | push rbp; mov rbp, rsp; push rbx; mov CCSTATE, CARG1 - |.else - | .type CCSTATE, CCallState, ebx - | push ebp; mov ebp, esp; push ebx; mov CCSTATE, FCARG1 - |.endif - | - | // Readjust stack. - |.if X64 - | mov eax, CCSTATE->spadj - | sub rsp, rax - |.else - | sub esp, CCSTATE->spadj - |.if WIN - | mov CCSTATE->spadj, esp - |.endif - |.endif - | - | // Copy stack slots. - | movzx ecx, byte CCSTATE->nsp - | sub ecx, 1 - | js >2 - |1: - |.if X64 - | mov rax, [CCSTATE+rcx*8+offsetof(CCallState, stack)] - | mov [rsp+rcx*8+CCALL_SPS_EXTRA*8], rax - |.else - | mov eax, [CCSTATE+ecx*4+offsetof(CCallState, stack)] - | mov [esp+ecx*4], eax - |.endif - | sub ecx, 1 - | jns <1 - |2: - | - |.if X64 - | movzx eax, byte CCSTATE->nfpr - | mov CARG1, CCSTATE->gpr[0] - | mov CARG2, CCSTATE->gpr[1] - | mov CARG3, CCSTATE->gpr[2] - | mov CARG4, CCSTATE->gpr[3] - |.if not X64WIN - | mov CARG5, CCSTATE->gpr[4] - | mov CARG6, CCSTATE->gpr[5] - |.endif - | test eax, eax; jz >5 - | movaps xmm0, CCSTATE->fpr[0] - | movaps xmm1, CCSTATE->fpr[1] - | movaps xmm2, CCSTATE->fpr[2] - | movaps xmm3, CCSTATE->fpr[3] - |.if not X64WIN - | cmp eax, 4; jbe >5 - | movaps xmm4, CCSTATE->fpr[4] - | movaps xmm5, CCSTATE->fpr[5] - | movaps xmm6, CCSTATE->fpr[6] - | movaps xmm7, CCSTATE->fpr[7] - |.endif - |5: - |.else - | mov FCARG1, CCSTATE->gpr[0] - | mov FCARG2, CCSTATE->gpr[1] - |.endif - | - | call aword CCSTATE->func - | - |.if X64 - | mov CCSTATE->gpr[0], rax - | movaps CCSTATE->fpr[0], xmm0 - |.if not X64WIN - | mov CCSTATE->gpr[1], rdx - | movaps CCSTATE->fpr[1], xmm1 - |.endif - |.else - | mov CCSTATE->gpr[0], eax - | mov CCSTATE->gpr[1], edx - | cmp byte CCSTATE->resx87, 1 - | jb >7 - | je >6 - | fstp qword CCSTATE->fpr[0].d[0] - | jmp >7 - |6: - | fstp dword CCSTATE->fpr[0].f[0] - |7: - |.if WIN - | sub CCSTATE->spadj, esp - |.endif - |.endif - | - |.if X64 - | mov rbx, [rbp-8]; leave; ret - |.else - | mov ebx, [ebp-4]; leave; ret - |.endif - |.endif - |// Note: vm_ffi_call must be the last function in this object file! - | - |//----------------------------------------------------------------------- -} - -/* Generate the code for a single instruction. */ -static void build_ins(BuildCtx *ctx, BCOp op, int defop) -{ - int vk = 0; - |// Note: aligning all instructions does not pay off. - |=>defop: - - switch (op) { - - /* -- Comparison ops ---------------------------------------------------- */ - - /* Remember: all ops branch for a true comparison, fall through otherwise. */ - - |.macro jmp_comp, lt, ge, le, gt, target - ||switch (op) { - ||case BC_ISLT: - | lt target - ||break; - ||case BC_ISGE: - | ge target - ||break; - ||case BC_ISLE: - | le target - ||break; - ||case BC_ISGT: - | gt target - ||break; - ||default: break; /* Shut up GCC. */ - ||} - |.endmacro - - case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: - | // RA = src1, RD = src2, JMP with RD = target - | ins_AD - |.if DUALNUM - | checkint RA, >7 - | checkint RD, >8 - | mov RB, dword [BASE+RA*8] - | add PC, 4 - | cmp RB, dword [BASE+RD*8] - | jmp_comp jge, jl, jg, jle, >9 - |6: - | movzx RD, PC_RD - | branchPC RD - |9: - | ins_next - | - |7: // RA is not an integer. - | ja ->vmeta_comp - | // RA is a number. - | cmp dword [BASE+RD*8+4], LJ_TISNUM; jb >1; jne ->vmeta_comp - | // RA is a number, RD is an integer. - |.if SSE - | cvtsi2sd xmm0, dword [BASE+RD*8] - | jmp >2 - |.else - | fld qword [BASE+RA*8] - | fild dword [BASE+RD*8] - | jmp >3 - |.endif - | - |8: // RA is an integer, RD is not an integer. - | ja ->vmeta_comp - | // RA is an integer, RD is a number. - |.if SSE - | cvtsi2sd xmm1, dword [BASE+RA*8] - | movsd xmm0, qword [BASE+RD*8] - | add PC, 4 - | ucomisd xmm0, xmm1 - | jmp_comp jbe, ja, jb, jae, <9 - | jmp <6 - |.else - | fild dword [BASE+RA*8] - | jmp >2 - |.endif - |.else - | checknum RA, ->vmeta_comp - | checknum RD, ->vmeta_comp - |.endif - |.if SSE - |1: - | movsd xmm0, qword [BASE+RD*8] - |2: - | add PC, 4 - | ucomisd xmm0, qword [BASE+RA*8] - |3: - |.else - |1: - | fld qword [BASE+RA*8] // Reverse order, i.e like cmp D, A. - |2: - | fld qword [BASE+RD*8] - |3: - | add PC, 4 - | fcomparepp - |.endif - | // Unordered: all of ZF CF PF set, ordered: PF clear. - | // To preserve NaN semantics GE/GT branch on unordered, but LT/LE don't. - |.if DUALNUM - | jmp_comp jbe, ja, jb, jae, <9 - | jmp <6 - |.else - | jmp_comp jbe, ja, jb, jae, >1 - | movzx RD, PC_RD - | branchPC RD - |1: - | ins_next - |.endif - break; - - case BC_ISEQV: case BC_ISNEV: - vk = op == BC_ISEQV; - | ins_AD // RA = src1, RD = src2, JMP with RD = target - | mov RB, [BASE+RD*8+4] - | add PC, 4 - |.if DUALNUM - | cmp RB, LJ_TISNUM; jne >7 - | checkint RA, >8 - | mov RB, dword [BASE+RD*8] - | cmp RB, dword [BASE+RA*8] - if (vk) { - | jne >9 - } else { - | je >9 - } - | movzx RD, PC_RD - | branchPC RD - |9: - | ins_next - | - |7: // RD is not an integer. - | ja >5 - | // RD is a number. - | cmp dword [BASE+RA*8+4], LJ_TISNUM; jb >1; jne >5 - | // RD is a number, RA is an integer. - |.if SSE - | cvtsi2sd xmm0, dword [BASE+RA*8] - |.else - | fild dword [BASE+RA*8] - |.endif - | jmp >2 - | - |8: // RD is an integer, RA is not an integer. - | ja >5 - | // RD is an integer, RA is a number. - |.if SSE - | cvtsi2sd xmm0, dword [BASE+RD*8] - | ucomisd xmm0, qword [BASE+RA*8] - |.else - | fild dword [BASE+RD*8] - | fld qword [BASE+RA*8] - |.endif - | jmp >4 - | - |.else - | cmp RB, LJ_TISNUM; jae >5 - | checknum RA, >5 - |.endif - |.if SSE - |1: - | movsd xmm0, qword [BASE+RA*8] - |2: - | ucomisd xmm0, qword [BASE+RD*8] - |4: - |.else - |1: - | fld qword [BASE+RA*8] - |2: - | fld qword [BASE+RD*8] - |4: - | fcomparepp - |.endif - iseqne_fp: - if (vk) { - | jp >2 // Unordered means not equal. - | jne >2 - } else { - | jp >2 // Unordered means not equal. - | je >1 - } - iseqne_end: - if (vk) { - |1: // EQ: Branch to the target. - | movzx RD, PC_RD - | branchPC RD - |2: // NE: Fallthrough to next instruction. - |.if not FFI - |3: - |.endif - } else { - |.if not FFI - |3: - |.endif - |2: // NE: Branch to the target. - | movzx RD, PC_RD - | branchPC RD - |1: // EQ: Fallthrough to next instruction. - } - if (LJ_DUALNUM && (op == BC_ISEQV || op == BC_ISNEV || - op == BC_ISEQN || op == BC_ISNEN)) { - | jmp <9 - } else { - | ins_next - } - | - if (op == BC_ISEQV || op == BC_ISNEV) { - |5: // Either or both types are not numbers. - |.if FFI - | cmp RB, LJ_TCDATA; je ->vmeta_equal_cd - | checktp RA, LJ_TCDATA; je ->vmeta_equal_cd - |.endif - | checktp RA, RB // Compare types. - | jne <2 // Not the same type? - | cmp RB, LJ_TISPRI - | jae <1 // Same type and primitive type? - | - | // Same types and not a primitive type. Compare GCobj or pvalue. - | mov RA, [BASE+RA*8] - | mov RD, [BASE+RD*8] - | cmp RA, RD - | je <1 // Same GCobjs or pvalues? - | cmp RB, LJ_TISTABUD - | ja <2 // Different objects and not table/ud? - |.if X64 - | cmp RB, LJ_TUDATA // And not 64 bit lightuserdata. - | jb <2 - |.endif - | - | // Different tables or userdatas. Need to check __eq metamethod. - | // Field metatable must be at same offset for GCtab and GCudata! - | mov TAB:RB, TAB:RA->metatable - | test TAB:RB, TAB:RB - | jz <2 // No metatable? - | test byte TAB:RB->nomm, 1<vmeta_equal // Handle __eq metamethod. - } else { - |.if FFI - |3: - | cmp RB, LJ_TCDATA - if (LJ_DUALNUM && vk) { - | jne <9 - } else { - | jne <2 - } - | jmp ->vmeta_equal_cd - |.endif - } - break; - case BC_ISEQS: case BC_ISNES: - vk = op == BC_ISEQS; - | ins_AND // RA = src, RD = str const, JMP with RD = target - | mov RB, [BASE+RA*8+4] - | add PC, 4 - | cmp RB, LJ_TSTR; jne >3 - | mov RA, [BASE+RA*8] - | cmp RA, [KBASE+RD*4] - iseqne_test: - if (vk) { - | jne >2 - } else { - | je >1 - } - goto iseqne_end; - case BC_ISEQN: case BC_ISNEN: - vk = op == BC_ISEQN; - | ins_AD // RA = src, RD = num const, JMP with RD = target - | mov RB, [BASE+RA*8+4] - | add PC, 4 - |.if DUALNUM - | cmp RB, LJ_TISNUM; jne >7 - | cmp dword [KBASE+RD*8+4], LJ_TISNUM; jne >8 - | mov RB, dword [KBASE+RD*8] - | cmp RB, dword [BASE+RA*8] - if (vk) { - | jne >9 - } else { - | je >9 - } - | movzx RD, PC_RD - | branchPC RD - |9: - | ins_next - | - |7: // RA is not an integer. - | ja >3 - | // RA is a number. - | cmp dword [KBASE+RD*8+4], LJ_TISNUM; jb >1 - | // RA is a number, RD is an integer. - |.if SSE - | cvtsi2sd xmm0, dword [KBASE+RD*8] - |.else - | fild dword [KBASE+RD*8] - |.endif - | jmp >2 - | - |8: // RA is an integer, RD is a number. - |.if SSE - | cvtsi2sd xmm0, dword [BASE+RA*8] - | ucomisd xmm0, qword [KBASE+RD*8] - |.else - | fild dword [BASE+RA*8] - | fld qword [KBASE+RD*8] - |.endif - | jmp >4 - |.else - | cmp RB, LJ_TISNUM; jae >3 - |.endif - |.if SSE - |1: - | movsd xmm0, qword [KBASE+RD*8] - |2: - | ucomisd xmm0, qword [BASE+RA*8] - |4: - |.else - |1: - | fld qword [KBASE+RD*8] - |2: - | fld qword [BASE+RA*8] - |4: - | fcomparepp - |.endif - goto iseqne_fp; - case BC_ISEQP: case BC_ISNEP: - vk = op == BC_ISEQP; - | ins_AND // RA = src, RD = primitive type (~), JMP with RD = target - | mov RB, [BASE+RA*8+4] - | add PC, 4 - | cmp RB, RD - if (!LJ_HASFFI) goto iseqne_test; - if (vk) { - | jne >3 - | movzx RD, PC_RD - | branchPC RD - |2: - | ins_next - |3: - | cmp RB, LJ_TCDATA; jne <2 - | jmp ->vmeta_equal_cd - } else { - | je >2 - | cmp RB, LJ_TCDATA; je ->vmeta_equal_cd - | movzx RD, PC_RD - | branchPC RD - |2: - | ins_next - } - break; - - /* -- Unary test and copy ops ------------------------------------------- */ - - case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: - | ins_AD // RA = dst or unused, RD = src, JMP with RD = target - | mov RB, [BASE+RD*8+4] - | add PC, 4 - | cmp RB, LJ_TISTRUECOND - if (op == BC_IST || op == BC_ISTC) { - | jae >1 - } else { - | jb >1 - } - if (op == BC_ISTC || op == BC_ISFC) { - | mov [BASE+RA*8+4], RB - | mov RB, [BASE+RD*8] - | mov [BASE+RA*8], RB - } - | movzx RD, PC_RD - | branchPC RD - |1: // Fallthrough to the next instruction. - | ins_next - break; - - /* -- Unary ops --------------------------------------------------------- */ - - case BC_MOV: - | ins_AD // RA = dst, RD = src - |.if X64 - | mov RBa, [BASE+RD*8] - | mov [BASE+RA*8], RBa - |.else - | mov RB, [BASE+RD*8+4] - | mov RD, [BASE+RD*8] - | mov [BASE+RA*8+4], RB - | mov [BASE+RA*8], RD - |.endif - | ins_next_ - break; - case BC_NOT: - | ins_AD // RA = dst, RD = src - | xor RB, RB - | checktp RD, LJ_TISTRUECOND - | adc RB, LJ_TTRUE - | mov [BASE+RA*8+4], RB - | ins_next - break; - case BC_UNM: - | ins_AD // RA = dst, RD = src - |.if DUALNUM - | checkint RD, >5 - | mov RB, [BASE+RD*8] - | neg RB - | jo >4 - | mov dword [BASE+RA*8+4], LJ_TISNUM - | mov dword [BASE+RA*8], RB - |9: - | ins_next - |4: - | mov dword [BASE+RA*8+4], 0x41e00000 // 2^31. - | mov dword [BASE+RA*8], 0 - | jmp <9 - |5: - | ja ->vmeta_unm - |.else - | checknum RD, ->vmeta_unm - |.endif - |.if SSE - | movsd xmm0, qword [BASE+RD*8] - | sseconst_sign xmm1, RDa - | xorps xmm0, xmm1 - | movsd qword [BASE+RA*8], xmm0 - |.else - | fld qword [BASE+RD*8] - | fchs - | fstp qword [BASE+RA*8] - |.endif - |.if DUALNUM - | jmp <9 - |.else - | ins_next - |.endif - break; - case BC_LEN: - | ins_AD // RA = dst, RD = src - | checkstr RD, >2 - | mov STR:RD, [BASE+RD*8] - |.if DUALNUM - | mov RD, dword STR:RD->len - |1: - | mov dword [BASE+RA*8+4], LJ_TISNUM - | mov dword [BASE+RA*8], RD - |.elif SSE - | xorps xmm0, xmm0 - | cvtsi2sd xmm0, dword STR:RD->len - |1: - | movsd qword [BASE+RA*8], xmm0 - |.else - | fild dword STR:RD->len - |1: - | fstp qword [BASE+RA*8] - |.endif - | ins_next - |2: - | checktab RD, ->vmeta_len - | mov TAB:FCARG1, [BASE+RD*8] -#if LJ_52 - | mov TAB:RB, TAB:FCARG1->metatable - | cmp TAB:RB, 0 - | jnz >9 - |3: -#endif - |->BC_LEN_Z: - | mov RB, BASE // Save BASE. - | call extern lj_tab_len@4 // (GCtab *t) - | // Length of table returned in eax (RD). - |.if DUALNUM - | // Nothing to do. - |.elif SSE - | cvtsi2sd xmm0, RD - |.else - | mov ARG1, RD - | fild ARG1 - |.endif - | mov BASE, RB // Restore BASE. - | movzx RA, PC_RA - | jmp <1 -#if LJ_52 - |9: // Check for __len. - | test byte TAB:RB->nomm, 1<vmeta_len // 'no __len' flag NOT set: check. -#endif - break; - - /* -- Binary ops -------------------------------------------------------- */ - - |.macro ins_arithpre, x87ins, sseins, ssereg - | ins_ABC - ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); - ||switch (vk) { - ||case 0: - | checknum RB, ->vmeta_arith_vn - | .if DUALNUM - | cmp dword [KBASE+RC*8+4], LJ_TISNUM; jae ->vmeta_arith_vn - | .endif - | .if SSE - | movsd xmm0, qword [BASE+RB*8] - | sseins ssereg, qword [KBASE+RC*8] - | .else - | fld qword [BASE+RB*8] - | x87ins qword [KBASE+RC*8] - | .endif - || break; - ||case 1: - | checknum RB, ->vmeta_arith_nv - | .if DUALNUM - | cmp dword [KBASE+RC*8+4], LJ_TISNUM; jae ->vmeta_arith_nv - | .endif - | .if SSE - | movsd xmm0, qword [KBASE+RC*8] - | sseins ssereg, qword [BASE+RB*8] - | .else - | fld qword [KBASE+RC*8] - | x87ins qword [BASE+RB*8] - | .endif - || break; - ||default: - | checknum RB, ->vmeta_arith_vv - | checknum RC, ->vmeta_arith_vv - | .if SSE - | movsd xmm0, qword [BASE+RB*8] - | sseins ssereg, qword [BASE+RC*8] - | .else - | fld qword [BASE+RB*8] - | x87ins qword [BASE+RC*8] - | .endif - || break; - ||} - |.endmacro - | - |.macro ins_arithdn, intins - | ins_ABC - ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); - ||switch (vk) { - ||case 0: - | checkint RB, ->vmeta_arith_vn - | cmp dword [KBASE+RC*8+4], LJ_TISNUM; jne ->vmeta_arith_vn - | mov RB, [BASE+RB*8] - | intins RB, [KBASE+RC*8]; jo ->vmeta_arith_vno - || break; - ||case 1: - | checkint RB, ->vmeta_arith_nv - | cmp dword [KBASE+RC*8+4], LJ_TISNUM; jne ->vmeta_arith_nv - | mov RC, [KBASE+RC*8] - | intins RC, [BASE+RB*8]; jo ->vmeta_arith_nvo - || break; - ||default: - | checkint RB, ->vmeta_arith_vv - | checkint RC, ->vmeta_arith_vv - | mov RB, [BASE+RB*8] - | intins RB, [BASE+RC*8]; jo ->vmeta_arith_vvo - || break; - ||} - | mov dword [BASE+RA*8+4], LJ_TISNUM - ||if (vk == 1) { - | mov dword [BASE+RA*8], RC - ||} else { - | mov dword [BASE+RA*8], RB - ||} - | ins_next - |.endmacro - | - |.macro ins_arithpost - |.if SSE - | movsd qword [BASE+RA*8], xmm0 - |.else - | fstp qword [BASE+RA*8] - |.endif - |.endmacro - | - |.macro ins_arith, x87ins, sseins - | ins_arithpre x87ins, sseins, xmm0 - | ins_arithpost - | ins_next - |.endmacro - | - |.macro ins_arith, intins, x87ins, sseins - |.if DUALNUM - | ins_arithdn intins - |.else - | ins_arith, x87ins, sseins - |.endif - |.endmacro - - | // RA = dst, RB = src1 or num const, RC = src2 or num const - case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: - | ins_arith add, fadd, addsd - break; - case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: - | ins_arith sub, fsub, subsd - break; - case BC_MULVN: case BC_MULNV: case BC_MULVV: - | ins_arith imul, fmul, mulsd - break; - case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: - | ins_arith fdiv, divsd - break; - case BC_MODVN: - | ins_arithpre fld, movsd, xmm1 - |->BC_MODVN_Z: - | call ->vm_mod - | ins_arithpost - | ins_next - break; - case BC_MODNV: case BC_MODVV: - | ins_arithpre fld, movsd, xmm1 - | jmp ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. - break; - case BC_POW: - | ins_arithpre fld, movsd, xmm1 - | call ->vm_pow - | ins_arithpost - | ins_next - break; - - case BC_CAT: - | ins_ABC // RA = dst, RB = src_start, RC = src_end - |.if X64 - | mov L:CARG1d, SAVE_L - | mov L:CARG1d->base, BASE - | lea CARG2d, [BASE+RC*8] - | mov CARG3d, RC - | sub CARG3d, RB - |->BC_CAT_Z: - | mov L:RB, L:CARG1d - |.else - | lea RA, [BASE+RC*8] - | sub RC, RB - | mov ARG2, RA - | mov ARG3, RC - |->BC_CAT_Z: - | mov L:RB, SAVE_L - | mov ARG1, L:RB - | mov L:RB->base, BASE - |.endif - | mov SAVE_PC, PC - | call extern lj_meta_cat // (lua_State *L, TValue *top, int left) - | // NULL (finished) or TValue * (metamethod) returned in eax (RC). - | mov BASE, L:RB->base - | test RC, RC - | jnz ->vmeta_binop - | movzx RB, PC_RB // Copy result to Stk[RA] from Stk[RB]. - | movzx RA, PC_RA - |.if X64 - | mov RCa, [BASE+RB*8] - | mov [BASE+RA*8], RCa - |.else - | mov RC, [BASE+RB*8+4] - | mov RB, [BASE+RB*8] - | mov [BASE+RA*8+4], RC - | mov [BASE+RA*8], RB - |.endif - | ins_next - break; - - /* -- Constant ops ------------------------------------------------------ */ - - case BC_KSTR: - | ins_AND // RA = dst, RD = str const (~) - | mov RD, [KBASE+RD*4] - | mov dword [BASE+RA*8+4], LJ_TSTR - | mov [BASE+RA*8], RD - | ins_next - break; - case BC_KCDATA: - |.if FFI - | ins_AND // RA = dst, RD = cdata const (~) - | mov RD, [KBASE+RD*4] - | mov dword [BASE+RA*8+4], LJ_TCDATA - | mov [BASE+RA*8], RD - | ins_next - |.endif - break; - case BC_KSHORT: - | ins_AD // RA = dst, RD = signed int16 literal - |.if DUALNUM - | movsx RD, RDW - | mov dword [BASE+RA*8+4], LJ_TISNUM - | mov dword [BASE+RA*8], RD - |.elif SSE - | movsx RD, RDW // Sign-extend literal. - | cvtsi2sd xmm0, RD - | movsd qword [BASE+RA*8], xmm0 - |.else - | fild PC_RD // Refetch signed RD from instruction. - | fstp qword [BASE+RA*8] - |.endif - | ins_next - break; - case BC_KNUM: - | ins_AD // RA = dst, RD = num const - |.if SSE - | movsd xmm0, qword [KBASE+RD*8] - | movsd qword [BASE+RA*8], xmm0 - |.else - | fld qword [KBASE+RD*8] - | fstp qword [BASE+RA*8] - |.endif - | ins_next - break; - case BC_KPRI: - | ins_AND // RA = dst, RD = primitive type (~) - | mov [BASE+RA*8+4], RD - | ins_next - break; - case BC_KNIL: - | ins_AD // RA = dst_start, RD = dst_end - | lea RA, [BASE+RA*8+12] - | lea RD, [BASE+RD*8+4] - | mov RB, LJ_TNIL - | mov [RA-8], RB // Sets minimum 2 slots. - |1: - | mov [RA], RB - | add RA, 8 - | cmp RA, RD - | jbe <1 - | ins_next - break; - - /* -- Upvalue and function ops ------------------------------------------ */ - - case BC_UGET: - | ins_AD // RA = dst, RD = upvalue # - | mov LFUNC:RB, [BASE-8] - | mov UPVAL:RB, [LFUNC:RB+RD*4+offsetof(GCfuncL, uvptr)] - | mov RB, UPVAL:RB->v - |.if X64 - | mov RDa, [RB] - | mov [BASE+RA*8], RDa - |.else - | mov RD, [RB+4] - | mov RB, [RB] - | mov [BASE+RA*8+4], RD - | mov [BASE+RA*8], RB - |.endif - | ins_next - break; - case BC_USETV: -#define TV2MARKOFS \ - ((int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)) - | ins_AD // RA = upvalue #, RD = src - | mov LFUNC:RB, [BASE-8] - | mov UPVAL:RB, [LFUNC:RB+RA*4+offsetof(GCfuncL, uvptr)] - | cmp byte UPVAL:RB->closed, 0 - | mov RB, UPVAL:RB->v - | mov RA, [BASE+RD*8] - | mov RD, [BASE+RD*8+4] - | mov [RB], RA - | mov [RB+4], RD - | jz >1 - | // Check barrier for closed upvalue. - | test byte [RB+TV2MARKOFS], LJ_GC_BLACK // isblack(uv) - | jnz >2 - |1: - | ins_next - | - |2: // Upvalue is black. Check if new value is collectable and white. - | sub RD, LJ_TISGCV - | cmp RD, LJ_TNUMX - LJ_TISGCV // tvisgcv(v) - | jbe <1 - | test byte GCOBJ:RA->gch.marked, LJ_GC_WHITES // iswhite(v) - | jz <1 - | // Crossed a write barrier. Move the barrier forward. - |.if X64 and not X64WIN - | mov FCARG2, RB - | mov RB, BASE // Save BASE. - |.else - | xchg FCARG2, RB // Save BASE (FCARG2 == BASE). - |.endif - | lea GL:FCARG1, [DISPATCH+GG_DISP2G] - | call extern lj_gc_barrieruv@8 // (global_State *g, TValue *tv) - | mov BASE, RB // Restore BASE. - | jmp <1 - break; -#undef TV2MARKOFS - case BC_USETS: - | ins_AND // RA = upvalue #, RD = str const (~) - | mov LFUNC:RB, [BASE-8] - | mov UPVAL:RB, [LFUNC:RB+RA*4+offsetof(GCfuncL, uvptr)] - | mov GCOBJ:RA, [KBASE+RD*4] - | mov RD, UPVAL:RB->v - | mov [RD], GCOBJ:RA - | mov dword [RD+4], LJ_TSTR - | test byte UPVAL:RB->marked, LJ_GC_BLACK // isblack(uv) - | jnz >2 - |1: - | ins_next - | - |2: // Check if string is white and ensure upvalue is closed. - | test byte GCOBJ:RA->gch.marked, LJ_GC_WHITES // iswhite(str) - | jz <1 - | cmp byte UPVAL:RB->closed, 0 - | jz <1 - | // Crossed a write barrier. Move the barrier forward. - | mov RB, BASE // Save BASE (FCARG2 == BASE). - | mov FCARG2, RD - | lea GL:FCARG1, [DISPATCH+GG_DISP2G] - | call extern lj_gc_barrieruv@8 // (global_State *g, TValue *tv) - | mov BASE, RB // Restore BASE. - | jmp <1 - break; - case BC_USETN: - | ins_AD // RA = upvalue #, RD = num const - | mov LFUNC:RB, [BASE-8] - |.if SSE - | movsd xmm0, qword [KBASE+RD*8] - |.else - | fld qword [KBASE+RD*8] - |.endif - | mov UPVAL:RB, [LFUNC:RB+RA*4+offsetof(GCfuncL, uvptr)] - | mov RA, UPVAL:RB->v - |.if SSE - | movsd qword [RA], xmm0 - |.else - | fstp qword [RA] - |.endif - | ins_next - break; - case BC_USETP: - | ins_AND // RA = upvalue #, RD = primitive type (~) - | mov LFUNC:RB, [BASE-8] - | mov UPVAL:RB, [LFUNC:RB+RA*4+offsetof(GCfuncL, uvptr)] - | mov RA, UPVAL:RB->v - | mov [RA+4], RD - | ins_next - break; - case BC_UCLO: - | ins_AD // RA = level, RD = target - | branchPC RD // Do this first to free RD. - | mov L:RB, SAVE_L - | cmp dword L:RB->openupval, 0 - | je >1 - | mov L:RB->base, BASE - | lea FCARG2, [BASE+RA*8] // Caveat: FCARG2 == BASE - | mov L:FCARG1, L:RB // Caveat: FCARG1 == RA - | call extern lj_func_closeuv@8 // (lua_State *L, TValue *level) - | mov BASE, L:RB->base - |1: - | ins_next - break; - - case BC_FNEW: - | ins_AND // RA = dst, RD = proto const (~) (holding function prototype) - |.if X64 - | mov L:RB, SAVE_L - | mov L:RB->base, BASE // Caveat: CARG2d/CARG3d may be BASE. - | mov CARG3d, [BASE-8] - | mov CARG2d, [KBASE+RD*4] // Fetch GCproto *. - | mov CARG1d, L:RB - |.else - | mov LFUNC:RA, [BASE-8] - | mov PROTO:RD, [KBASE+RD*4] // Fetch GCproto *. - | mov L:RB, SAVE_L - | mov ARG3, LFUNC:RA - | mov ARG2, PROTO:RD - | mov ARG1, L:RB - | mov L:RB->base, BASE - |.endif - | mov SAVE_PC, PC - | // (lua_State *L, GCproto *pt, GCfuncL *parent) - | call extern lj_func_newL_gc - | // GCfuncL * returned in eax (RC). - | mov BASE, L:RB->base - | movzx RA, PC_RA - | mov [BASE+RA*8], LFUNC:RC - | mov dword [BASE+RA*8+4], LJ_TFUNC - | ins_next - break; - - /* -- Table ops --------------------------------------------------------- */ - - case BC_TNEW: - | ins_AD // RA = dst, RD = hbits|asize - | mov L:RB, SAVE_L - | mov L:RB->base, BASE - | mov RA, [DISPATCH+DISPATCH_GL(gc.total)] - | cmp RA, [DISPATCH+DISPATCH_GL(gc.threshold)] - | mov SAVE_PC, PC - | jae >5 - |1: - |.if X64 - | mov CARG3d, RD - | and RD, 0x7ff - | shr CARG3d, 11 - |.else - | mov RA, RD - | and RD, 0x7ff - | shr RA, 11 - | mov ARG3, RA - |.endif - | cmp RD, 0x7ff - | je >3 - |2: - |.if X64 - | mov L:CARG1d, L:RB - | mov CARG2d, RD - |.else - | mov ARG1, L:RB - | mov ARG2, RD - |.endif - | call extern lj_tab_new // (lua_State *L, int32_t asize, uint32_t hbits) - | // Table * returned in eax (RC). - | mov BASE, L:RB->base - | movzx RA, PC_RA - | mov [BASE+RA*8], TAB:RC - | mov dword [BASE+RA*8+4], LJ_TTAB - | ins_next - |3: // Turn 0x7ff into 0x801. - | mov RD, 0x801 - | jmp <2 - |5: - | mov L:FCARG1, L:RB - | call extern lj_gc_step_fixtop@4 // (lua_State *L) - | movzx RD, PC_RD - | jmp <1 - break; - case BC_TDUP: - | ins_AND // RA = dst, RD = table const (~) (holding template table) - | mov L:RB, SAVE_L - | mov RA, [DISPATCH+DISPATCH_GL(gc.total)] - | mov SAVE_PC, PC - | cmp RA, [DISPATCH+DISPATCH_GL(gc.threshold)] - | mov L:RB->base, BASE - | jae >3 - |2: - | mov TAB:FCARG2, [KBASE+RD*4] // Caveat: FCARG2 == BASE - | mov L:FCARG1, L:RB // Caveat: FCARG1 == RA - | call extern lj_tab_dup@8 // (lua_State *L, Table *kt) - | // Table * returned in eax (RC). - | mov BASE, L:RB->base - | movzx RA, PC_RA - | mov [BASE+RA*8], TAB:RC - | mov dword [BASE+RA*8+4], LJ_TTAB - | ins_next - |3: - | mov L:FCARG1, L:RB - | call extern lj_gc_step_fixtop@4 // (lua_State *L) - | movzx RD, PC_RD // Need to reload RD. - | not RDa - | jmp <2 - break; - - case BC_GGET: - | ins_AND // RA = dst, RD = str const (~) - | mov LFUNC:RB, [BASE-8] - | mov TAB:RB, LFUNC:RB->env - | mov STR:RC, [KBASE+RD*4] - | jmp ->BC_TGETS_Z - break; - case BC_GSET: - | ins_AND // RA = src, RD = str const (~) - | mov LFUNC:RB, [BASE-8] - | mov TAB:RB, LFUNC:RB->env - | mov STR:RC, [KBASE+RD*4] - | jmp ->BC_TSETS_Z - break; - - case BC_TGETV: - | ins_ABC // RA = dst, RB = table, RC = key - | checktab RB, ->vmeta_tgetv - | mov TAB:RB, [BASE+RB*8] - | - | // Integer key? - |.if DUALNUM - | checkint RC, >5 - | mov RC, dword [BASE+RC*8] - |.else - | // Convert number to int and back and compare. - | checknum RC, >5 - |.if SSE - | movsd xmm0, qword [BASE+RC*8] - | cvtsd2si RC, xmm0 - | cvtsi2sd xmm1, RC - | ucomisd xmm0, xmm1 - |.else - | fld qword [BASE+RC*8] - | fist ARG1 - | fild ARG1 - | fcomparepp - | mov RC, ARG1 - |.endif - | jne ->vmeta_tgetv // Generic numeric key? Use fallback. - |.endif - | cmp RC, TAB:RB->asize // Takes care of unordered, too. - | jae ->vmeta_tgetv // Not in array part? Use fallback. - | shl RC, 3 - | add RC, TAB:RB->array - | cmp dword [RC+4], LJ_TNIL // Avoid overwriting RB in fastpath. - | je >2 - | // Get array slot. - |.if X64 - | mov RBa, [RC] - | mov [BASE+RA*8], RBa - |.else - | mov RB, [RC] - | mov RC, [RC+4] - | mov [BASE+RA*8], RB - | mov [BASE+RA*8+4], RC - |.endif - |1: - | ins_next - | - |2: // Check for __index if table value is nil. - | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. - | jz >3 - | mov TAB:RA, TAB:RB->metatable - | test byte TAB:RA->nomm, 1<vmeta_tgetv // 'no __index' flag NOT set: check. - | movzx RA, PC_RA // Restore RA. - |3: - | mov dword [BASE+RA*8+4], LJ_TNIL - | jmp <1 - | - |5: // String key? - | checkstr RC, ->vmeta_tgetv - | mov STR:RC, [BASE+RC*8] - | jmp ->BC_TGETS_Z - break; - case BC_TGETS: - | ins_ABC // RA = dst, RB = table, RC = str const (~) - | not RCa - | mov STR:RC, [KBASE+RC*4] - | checktab RB, ->vmeta_tgets - | mov TAB:RB, [BASE+RB*8] - |->BC_TGETS_Z: // RB = GCtab *, RC = GCstr *, refetches PC_RA. - | mov RA, TAB:RB->hmask - | and RA, STR:RC->hash - | imul RA, #NODE - | add NODE:RA, TAB:RB->node - |1: - | cmp dword NODE:RA->key.it, LJ_TSTR - | jne >4 - | cmp dword NODE:RA->key.gcr, STR:RC - | jne >4 - | // Ok, key found. Assumes: offsetof(Node, val) == 0 - | cmp dword [RA+4], LJ_TNIL // Avoid overwriting RB in fastpath. - | je >5 // Key found, but nil value? - | movzx RC, PC_RA - | // Get node value. - |.if X64 - | mov RBa, [RA] - | mov [BASE+RC*8], RBa - |.else - | mov RB, [RA] - | mov RA, [RA+4] - | mov [BASE+RC*8], RB - | mov [BASE+RC*8+4], RA - |.endif - |2: - | ins_next - | - |3: - | movzx RC, PC_RA - | mov dword [BASE+RC*8+4], LJ_TNIL - | jmp <2 - | - |4: // Follow hash chain. - | mov NODE:RA, NODE:RA->next - | test NODE:RA, NODE:RA - | jnz <1 - | // End of hash chain: key not found, nil result. - | - |5: // Check for __index if table value is nil. - | mov TAB:RA, TAB:RB->metatable - | test TAB:RA, TAB:RA - | jz <3 // No metatable: done. - | test byte TAB:RA->nomm, 1<vmeta_tgets // Caveat: preserve STR:RC. - break; - case BC_TGETB: - | ins_ABC // RA = dst, RB = table, RC = byte literal - | checktab RB, ->vmeta_tgetb - | mov TAB:RB, [BASE+RB*8] - | cmp RC, TAB:RB->asize - | jae ->vmeta_tgetb - | shl RC, 3 - | add RC, TAB:RB->array - | cmp dword [RC+4], LJ_TNIL // Avoid overwriting RB in fastpath. - | je >2 - | // Get array slot. - |.if X64 - | mov RBa, [RC] - | mov [BASE+RA*8], RBa - |.else - | mov RB, [RC] - | mov RC, [RC+4] - | mov [BASE+RA*8], RB - | mov [BASE+RA*8+4], RC - |.endif - |1: - | ins_next - | - |2: // Check for __index if table value is nil. - | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. - | jz >3 - | mov TAB:RA, TAB:RB->metatable - | test byte TAB:RA->nomm, 1<vmeta_tgetb // 'no __index' flag NOT set: check. - | movzx RA, PC_RA // Restore RA. - |3: - | mov dword [BASE+RA*8+4], LJ_TNIL - | jmp <1 - break; - - case BC_TSETV: - | ins_ABC // RA = src, RB = table, RC = key - | checktab RB, ->vmeta_tsetv - | mov TAB:RB, [BASE+RB*8] - | - | // Integer key? - |.if DUALNUM - | checkint RC, >5 - | mov RC, dword [BASE+RC*8] - |.else - | // Convert number to int and back and compare. - | checknum RC, >5 - |.if SSE - | movsd xmm0, qword [BASE+RC*8] - | cvtsd2si RC, xmm0 - | cvtsi2sd xmm1, RC - | ucomisd xmm0, xmm1 - |.else - | fld qword [BASE+RC*8] - | fist ARG1 - | fild ARG1 - | fcomparepp - | mov RC, ARG1 - |.endif - | jne ->vmeta_tsetv // Generic numeric key? Use fallback. - |.endif - | cmp RC, TAB:RB->asize // Takes care of unordered, too. - | jae ->vmeta_tsetv - | shl RC, 3 - | add RC, TAB:RB->array - | cmp dword [RC+4], LJ_TNIL - | je >3 // Previous value is nil? - |1: - | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) - | jnz >7 - |2: // Set array slot. - |.if X64 - | mov RBa, [BASE+RA*8] - | mov [RC], RBa - |.else - | mov RB, [BASE+RA*8+4] - | mov RA, [BASE+RA*8] - | mov [RC+4], RB - | mov [RC], RA - |.endif - | ins_next - | - |3: // Check for __newindex if previous value is nil. - | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. - | jz <1 - | mov TAB:RA, TAB:RB->metatable - | test byte TAB:RA->nomm, 1<vmeta_tsetv // 'no __newindex' flag NOT set: check. - | movzx RA, PC_RA // Restore RA. - | jmp <1 - | - |5: // String key? - | checkstr RC, ->vmeta_tsetv - | mov STR:RC, [BASE+RC*8] - | jmp ->BC_TSETS_Z - | - |7: // Possible table write barrier for the value. Skip valiswhite check. - | barrierback TAB:RB, RA - | movzx RA, PC_RA // Restore RA. - | jmp <2 - break; - case BC_TSETS: - | ins_ABC // RA = src, RB = table, RC = str const (~) - | not RCa - | mov STR:RC, [KBASE+RC*4] - | checktab RB, ->vmeta_tsets - | mov TAB:RB, [BASE+RB*8] - |->BC_TSETS_Z: // RB = GCtab *, RC = GCstr *, refetches PC_RA. - | mov RA, TAB:RB->hmask - | and RA, STR:RC->hash - | imul RA, #NODE - | mov byte TAB:RB->nomm, 0 // Clear metamethod cache. - | add NODE:RA, TAB:RB->node - |1: - | cmp dword NODE:RA->key.it, LJ_TSTR - | jne >5 - | cmp dword NODE:RA->key.gcr, STR:RC - | jne >5 - | // Ok, key found. Assumes: offsetof(Node, val) == 0 - | cmp dword [RA+4], LJ_TNIL - | je >4 // Previous value is nil? - |2: - | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) - | jnz >7 - |3: // Set node value. - | movzx RC, PC_RA - |.if X64 - | mov RBa, [BASE+RC*8] - | mov [RA], RBa - |.else - | mov RB, [BASE+RC*8+4] - | mov RC, [BASE+RC*8] - | mov [RA+4], RB - | mov [RA], RC - |.endif - | ins_next - | - |4: // Check for __newindex if previous value is nil. - | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. - | jz <2 - | mov TMP1, RA // Save RA. - | mov TAB:RA, TAB:RB->metatable - | test byte TAB:RA->nomm, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. - | mov RA, TMP1 // Restore RA. - | jmp <2 - | - |5: // Follow hash chain. - | mov NODE:RA, NODE:RA->next - | test NODE:RA, NODE:RA - | jnz <1 - | // End of hash chain: key not found, add a new one. - | - | // But check for __newindex first. - | mov TAB:RA, TAB:RB->metatable - | test TAB:RA, TAB:RA - | jz >6 // No metatable: continue. - | test byte TAB:RA->nomm, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. - |6: - | mov TMP1, STR:RC - | mov TMP2, LJ_TSTR - | mov TMP3, TAB:RB // Save TAB:RB for us. - |.if X64 - | mov L:CARG1d, SAVE_L - | mov L:CARG1d->base, BASE - | lea CARG3, TMP1 - | mov CARG2d, TAB:RB - | mov L:RB, L:CARG1d - |.else - | lea RC, TMP1 // Store temp. TValue in TMP1/TMP2. - | mov ARG2, TAB:RB - | mov L:RB, SAVE_L - | mov ARG3, RC - | mov ARG1, L:RB - | mov L:RB->base, BASE - |.endif - | mov SAVE_PC, PC - | call extern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k) - | // Handles write barrier for the new key. TValue * returned in eax (RC). - | mov BASE, L:RB->base - | mov TAB:RB, TMP3 // Need TAB:RB for barrier. - | mov RA, eax - | jmp <2 // Must check write barrier for value. - | - |7: // Possible table write barrier for the value. Skip valiswhite check. - | barrierback TAB:RB, RC // Destroys STR:RC. - | jmp <3 - break; - case BC_TSETB: - | ins_ABC // RA = src, RB = table, RC = byte literal - | checktab RB, ->vmeta_tsetb - | mov TAB:RB, [BASE+RB*8] - | cmp RC, TAB:RB->asize - | jae ->vmeta_tsetb - | shl RC, 3 - | add RC, TAB:RB->array - | cmp dword [RC+4], LJ_TNIL - | je >3 // Previous value is nil? - |1: - | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) - | jnz >7 - |2: // Set array slot. - |.if X64 - | mov RAa, [BASE+RA*8] - | mov [RC], RAa - |.else - | mov RB, [BASE+RA*8+4] - | mov RA, [BASE+RA*8] - | mov [RC+4], RB - | mov [RC], RA - |.endif - | ins_next - | - |3: // Check for __newindex if previous value is nil. - | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. - | jz <1 - | mov TAB:RA, TAB:RB->metatable - | test byte TAB:RA->nomm, 1<vmeta_tsetb // 'no __newindex' flag NOT set: check. - | movzx RA, PC_RA // Restore RA. - | jmp <1 - | - |7: // Possible table write barrier for the value. Skip valiswhite check. - | barrierback TAB:RB, RA - | movzx RA, PC_RA // Restore RA. - | jmp <2 - break; - - case BC_TSETM: - | ins_AD // RA = base (table at base-1), RD = num const (start index) - | mov TMP1, KBASE // Need one more free register. - | mov KBASE, dword [KBASE+RD*8] // Integer constant is in lo-word. - |1: - | lea RA, [BASE+RA*8] - | mov TAB:RB, [RA-8] // Guaranteed to be a table. - | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) - | jnz >7 - |2: - | mov RD, MULTRES - | sub RD, 1 - | jz >4 // Nothing to copy? - | add RD, KBASE // Compute needed size. - | cmp RD, TAB:RB->asize - | ja >5 // Doesn't fit into array part? - | sub RD, KBASE - | shl KBASE, 3 - | add KBASE, TAB:RB->array - |3: // Copy result slots to table. - |.if X64 - | mov RBa, [RA] - | add RA, 8 - | mov [KBASE], RBa - |.else - | mov RB, [RA] - | mov [KBASE], RB - | mov RB, [RA+4] - | add RA, 8 - | mov [KBASE+4], RB - |.endif - | add KBASE, 8 - | sub RD, 1 - | jnz <3 - |4: - | mov KBASE, TMP1 - | ins_next - | - |5: // Need to resize array part. - |.if X64 - | mov L:CARG1d, SAVE_L - | mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE. - | mov CARG2d, TAB:RB - | mov CARG3d, RD - | mov L:RB, L:CARG1d - |.else - | mov ARG2, TAB:RB - | mov L:RB, SAVE_L - | mov L:RB->base, BASE - | mov ARG3, RD - | mov ARG1, L:RB - |.endif - | mov SAVE_PC, PC - | call extern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) - | mov BASE, L:RB->base - | movzx RA, PC_RA // Restore RA. - | jmp <1 // Retry. - | - |7: // Possible table write barrier for any value. Skip valiswhite check. - | barrierback TAB:RB, RD - | jmp <2 - break; - - /* -- Calls and vararg handling ----------------------------------------- */ - - case BC_CALL: case BC_CALLM: - | ins_A_C // RA = base, (RB = nresults+1,) RC = nargs+1 | extra_nargs - if (op == BC_CALLM) { - | add NARGS:RD, MULTRES - } - | cmp dword [BASE+RA*8+4], LJ_TFUNC - | mov LFUNC:RB, [BASE+RA*8] - | jne ->vmeta_call_ra - | lea BASE, [BASE+RA*8+8] - | ins_call - break; - - case BC_CALLMT: - | ins_AD // RA = base, RD = extra_nargs - | add NARGS:RD, MULTRES - | // Fall through. Assumes BC_CALLT follows and ins_AD is a no-op. - break; - case BC_CALLT: - | ins_AD // RA = base, RD = nargs+1 - | lea RA, [BASE+RA*8+8] - | mov KBASE, BASE // Use KBASE for move + vmeta_call hint. - | mov LFUNC:RB, [RA-8] - | cmp dword [RA-4], LJ_TFUNC - | jne ->vmeta_call - |->BC_CALLT_Z: - | mov PC, [BASE-4] - | test PC, FRAME_TYPE - | jnz >7 - |1: - | mov [BASE-8], LFUNC:RB // Copy function down, reloaded below. - | mov MULTRES, NARGS:RD - | sub NARGS:RD, 1 - | jz >3 - |2: // Move args down. - |.if X64 - | mov RBa, [RA] - | add RA, 8 - | mov [KBASE], RBa - |.else - | mov RB, [RA] - | mov [KBASE], RB - | mov RB, [RA+4] - | add RA, 8 - | mov [KBASE+4], RB - |.endif - | add KBASE, 8 - | sub NARGS:RD, 1 - | jnz <2 - | - | mov LFUNC:RB, [BASE-8] - |3: - | mov NARGS:RD, MULTRES - | cmp byte LFUNC:RB->ffid, 1 // (> FF_C) Calling a fast function? - | ja >5 - |4: - | ins_callt - | - |5: // Tailcall to a fast function. - | test PC, FRAME_TYPE // Lua frame below? - | jnz <4 - | movzx RA, PC_RA - | not RAa - | lea RA, [BASE+RA*8] - | mov LFUNC:KBASE, [RA-8] // Need to prepare KBASE. - | mov KBASE, LFUNC:KBASE->pc - | mov KBASE, [KBASE+PC2PROTO(k)] - | jmp <4 - | - |7: // Tailcall from a vararg function. - | sub PC, FRAME_VARG - | test PC, FRAME_TYPEP - | jnz >8 // Vararg frame below? - | sub BASE, PC // Need to relocate BASE/KBASE down. - | mov KBASE, BASE - | mov PC, [BASE-4] - | jmp <1 - |8: - | add PC, FRAME_VARG - | jmp <1 - break; - - case BC_ITERC: - | ins_A // RA = base, (RB = nresults+1,) RC = nargs+1 (2+1) - | lea RA, [BASE+RA*8+8] // fb = base+1 - |.if X64 - | mov RBa, [RA-24] // Copy state. fb[0] = fb[-3]. - | mov RCa, [RA-16] // Copy control var. fb[1] = fb[-2]. - | mov [RA], RBa - | mov [RA+8], RCa - |.else - | mov RB, [RA-24] // Copy state. fb[0] = fb[-3]. - | mov RC, [RA-20] - | mov [RA], RB - | mov [RA+4], RC - | mov RB, [RA-16] // Copy control var. fb[1] = fb[-2]. - | mov RC, [RA-12] - | mov [RA+8], RB - | mov [RA+12], RC - |.endif - | mov LFUNC:RB, [RA-32] // Copy callable. fb[-1] = fb[-4] - | mov RC, [RA-28] - | mov [RA-8], LFUNC:RB - | mov [RA-4], RC - | cmp RC, LJ_TFUNC // Handle like a regular 2-arg call. - | mov NARGS:RD, 2+1 - | jne ->vmeta_call - | mov BASE, RA - | ins_call - break; - - case BC_ITERN: - | ins_A // RA = base, (RB = nresults+1, RC = nargs+1 (2+1)) - |.if JIT - | // NYI: add hotloop, record BC_ITERN. - |.endif - | mov TMP1, KBASE // Need two more free registers. - | mov TMP2, DISPATCH - | mov TAB:RB, [BASE+RA*8-16] - | mov RC, [BASE+RA*8-8] // Get index from control var. - | mov DISPATCH, TAB:RB->asize - | add PC, 4 - | mov KBASE, TAB:RB->array - |1: // Traverse array part. - | cmp RC, DISPATCH; jae >5 // Index points after array part? - | cmp dword [KBASE+RC*8+4], LJ_TNIL; je >4 - |.if DUALNUM - | mov dword [BASE+RA*8+4], LJ_TISNUM - | mov dword [BASE+RA*8], RC - |.elif SSE - | cvtsi2sd xmm0, RC - |.else - | fild dword [BASE+RA*8-8] - |.endif - | // Copy array slot to returned value. - |.if X64 - | mov RBa, [KBASE+RC*8] - | mov [BASE+RA*8+8], RBa - |.else - | mov RB, [KBASE+RC*8+4] - | mov [BASE+RA*8+12], RB - | mov RB, [KBASE+RC*8] - | mov [BASE+RA*8+8], RB - |.endif - | add RC, 1 - | // Return array index as a numeric key. - |.if DUALNUM - | // See above. - |.elif SSE - | movsd qword [BASE+RA*8], xmm0 - |.else - | fstp qword [BASE+RA*8] - |.endif - | mov [BASE+RA*8-8], RC // Update control var. - |2: - | movzx RD, PC_RD // Get target from ITERL. - | branchPC RD - |3: - | mov DISPATCH, TMP2 - | mov KBASE, TMP1 - | ins_next - | - |4: // Skip holes in array part. - | add RC, 1 - |.if not (DUALNUM or SSE) - | mov [BASE+RA*8-8], RC - |.endif - | jmp <1 - | - |5: // Traverse hash part. - | sub RC, DISPATCH - |6: - | cmp RC, TAB:RB->hmask; ja <3 // End of iteration? Branch to ITERL+1. - | imul KBASE, RC, #NODE - | add NODE:KBASE, TAB:RB->node - | cmp dword NODE:KBASE->val.it, LJ_TNIL; je >7 - | lea DISPATCH, [RC+DISPATCH+1] - | // Copy key and value from hash slot. - |.if X64 - | mov RBa, NODE:KBASE->key - | mov RCa, NODE:KBASE->val - | mov [BASE+RA*8], RBa - | mov [BASE+RA*8+8], RCa - |.else - | mov RB, NODE:KBASE->key.gcr - | mov RC, NODE:KBASE->key.it - | mov [BASE+RA*8], RB - | mov [BASE+RA*8+4], RC - | mov RB, NODE:KBASE->val.gcr - | mov RC, NODE:KBASE->val.it - | mov [BASE+RA*8+8], RB - | mov [BASE+RA*8+12], RC - |.endif - | mov [BASE+RA*8-8], DISPATCH - | jmp <2 - | - |7: // Skip holes in hash part. - | add RC, 1 - | jmp <6 - break; - - case BC_ISNEXT: - | ins_AD // RA = base, RD = target (points to ITERN) - | cmp dword [BASE+RA*8-20], LJ_TFUNC; jne >5 - | mov CFUNC:RB, [BASE+RA*8-24] - | cmp dword [BASE+RA*8-12], LJ_TTAB; jne >5 - | cmp dword [BASE+RA*8-4], LJ_TNIL; jne >5 - | cmp byte CFUNC:RB->ffid, FF_next_N; jne >5 - | branchPC RD - | mov dword [BASE+RA*8-8], 0 // Initialize control var. - | mov dword [BASE+RA*8-4], 0xfffe7fff - |1: - | ins_next - |5: // Despecialize bytecode if any of the checks fail. - | mov PC_OP, BC_JMP - | branchPC RD - | mov byte [PC], BC_ITERC - | jmp <1 - break; - - case BC_VARG: - | ins_ABC // RA = base, RB = nresults+1, RC = numparams - | mov TMP1, KBASE // Need one more free register. - | lea KBASE, [BASE+RC*8+(8+FRAME_VARG)] - | lea RA, [BASE+RA*8] - | sub KBASE, [BASE-4] - | // Note: KBASE may now be even _above_ BASE if nargs was < numparams. - | test RB, RB - | jz >5 // Copy all varargs? - | lea RB, [RA+RB*8-8] - | cmp KBASE, BASE // No vararg slots? - | jnb >2 - |1: // Copy vararg slots to destination slots. - |.if X64 - | mov RCa, [KBASE-8] - | add KBASE, 8 - | mov [RA], RCa - |.else - | mov RC, [KBASE-8] - | mov [RA], RC - | mov RC, [KBASE-4] - | add KBASE, 8 - | mov [RA+4], RC - |.endif - | add RA, 8 - | cmp RA, RB // All destination slots filled? - | jnb >3 - | cmp KBASE, BASE // No more vararg slots? - | jb <1 - |2: // Fill up remainder with nil. - | mov dword [RA+4], LJ_TNIL - | add RA, 8 - | cmp RA, RB - | jb <2 - |3: - | mov KBASE, TMP1 - | ins_next - | - |5: // Copy all varargs. - | mov MULTRES, 1 // MULTRES = 0+1 - | mov RC, BASE - | sub RC, KBASE - | jbe <3 // No vararg slots? - | mov RB, RC - | shr RB, 3 - | add RB, 1 - | mov MULTRES, RB // MULTRES = #varargs+1 - | mov L:RB, SAVE_L - | add RC, RA - | cmp RC, L:RB->maxstack - | ja >7 // Need to grow stack? - |6: // Copy all vararg slots. - |.if X64 - | mov RCa, [KBASE-8] - | add KBASE, 8 - | mov [RA], RCa - |.else - | mov RC, [KBASE-8] - | mov [RA], RC - | mov RC, [KBASE-4] - | add KBASE, 8 - | mov [RA+4], RC - |.endif - | add RA, 8 - | cmp KBASE, BASE // No more vararg slots? - | jb <6 - | jmp <3 - | - |7: // Grow stack for varargs. - | mov L:RB->base, BASE - | mov L:RB->top, RA - | mov SAVE_PC, PC - | sub KBASE, BASE // Need delta, because BASE may change. - | mov FCARG2, MULTRES - | sub FCARG2, 1 - | mov FCARG1, L:RB - | call extern lj_state_growstack@8 // (lua_State *L, int n) - | mov BASE, L:RB->base - | mov RA, L:RB->top - | add KBASE, BASE - | jmp <6 - break; - - /* -- Returns ----------------------------------------------------------- */ - - case BC_RETM: - | ins_AD // RA = results, RD = extra_nresults - | add RD, MULTRES // MULTRES >=1, so RD >=1. - | // Fall through. Assumes BC_RET follows and ins_AD is a no-op. - break; - - case BC_RET: case BC_RET0: case BC_RET1: - | ins_AD // RA = results, RD = nresults+1 - if (op != BC_RET0) { - | shl RA, 3 - } - |1: - | mov PC, [BASE-4] - | mov MULTRES, RD // Save nresults+1. - | test PC, FRAME_TYPE // Check frame type marker. - | jnz >7 // Not returning to a fixarg Lua func? - switch (op) { - case BC_RET: - |->BC_RET_Z: - | mov KBASE, BASE // Use KBASE for result move. - | sub RD, 1 - | jz >3 - |2: // Move results down. - |.if X64 - | mov RBa, [KBASE+RA] - | mov [KBASE-8], RBa - |.else - | mov RB, [KBASE+RA] - | mov [KBASE-8], RB - | mov RB, [KBASE+RA+4] - | mov [KBASE-4], RB - |.endif - | add KBASE, 8 - | sub RD, 1 - | jnz <2 - |3: - | mov RD, MULTRES // Note: MULTRES may be >255. - | movzx RB, PC_RB // So cannot compare with RDL! - |5: - | cmp RB, RD // More results expected? - | ja >6 - break; - case BC_RET1: - |.if X64 - | mov RBa, [BASE+RA] - | mov [BASE-8], RBa - |.else - | mov RB, [BASE+RA+4] - | mov [BASE-4], RB - | mov RB, [BASE+RA] - | mov [BASE-8], RB - |.endif - /* fallthrough */ - case BC_RET0: - |5: - | cmp PC_RB, RDL // More results expected? - | ja >6 - default: - break; - } - | movzx RA, PC_RA - | not RAa // Note: ~RA = -(RA+1) - | lea BASE, [BASE+RA*8] // base = base - (RA+1)*8 - | mov LFUNC:KBASE, [BASE-8] - | mov KBASE, LFUNC:KBASE->pc - | mov KBASE, [KBASE+PC2PROTO(k)] - | ins_next - | - |6: // Fill up results with nil. - if (op == BC_RET) { - | mov dword [KBASE-4], LJ_TNIL // Note: relies on shifted base. - | add KBASE, 8 - } else { - | mov dword [BASE+RD*8-12], LJ_TNIL - } - | add RD, 1 - | jmp <5 - | - |7: // Non-standard return case. - | lea RB, [PC-FRAME_VARG] - | test RB, FRAME_TYPEP - | jnz ->vm_return - | // Return from vararg function: relocate BASE down and RA up. - | sub BASE, RB - if (op != BC_RET0) { - | add RA, RB - } - | jmp <1 - break; - - /* -- Loops and branches ------------------------------------------------ */ - - |.define FOR_IDX, [RA]; .define FOR_TIDX, dword [RA+4] - |.define FOR_STOP, [RA+8]; .define FOR_TSTOP, dword [RA+12] - |.define FOR_STEP, [RA+16]; .define FOR_TSTEP, dword [RA+20] - |.define FOR_EXT, [RA+24]; .define FOR_TEXT, dword [RA+28] - - case BC_FORL: - |.if JIT - | hotloop RB - |.endif - | // Fall through. Assumes BC_IFORL follows and ins_AJ is a no-op. - break; - - case BC_JFORI: - case BC_JFORL: -#if !LJ_HASJIT - break; -#endif - case BC_FORI: - case BC_IFORL: - vk = (op == BC_IFORL || op == BC_JFORL); - | ins_AJ // RA = base, RD = target (after end of loop or start of loop) - | lea RA, [BASE+RA*8] - if (LJ_DUALNUM) { - | cmp FOR_TIDX, LJ_TISNUM; jne >9 - if (!vk) { - | cmp FOR_TSTOP, LJ_TISNUM; jne ->vmeta_for - | cmp FOR_TSTEP, LJ_TISNUM; jne ->vmeta_for - | mov RB, dword FOR_IDX - | cmp dword FOR_STEP, 0; jl >5 - } else { -#ifdef LUA_USE_ASSERT - | cmp FOR_TSTOP, LJ_TISNUM; jne ->assert_bad_for_arg_type - | cmp FOR_TSTEP, LJ_TISNUM; jne ->assert_bad_for_arg_type -#endif - | mov RB, dword FOR_STEP - | test RB, RB; js >5 - | add RB, dword FOR_IDX; jo >1 - | mov dword FOR_IDX, RB - } - | cmp RB, dword FOR_STOP - | mov FOR_TEXT, LJ_TISNUM - | mov dword FOR_EXT, RB - if (op == BC_FORI) { - | jle >7 - |1: - |6: - | branchPC RD - } else if (op == BC_JFORI) { - | branchPC RD - | movzx RD, PC_RD - | jle =>BC_JLOOP - |1: - |6: - } else if (op == BC_IFORL) { - | jg >7 - |6: - | branchPC RD - |1: - } else { - | jle =>BC_JLOOP - |1: - |6: - } - |7: - | ins_next - | - |5: // Invert check for negative step. - if (vk) { - | add RB, dword FOR_IDX; jo <1 - | mov dword FOR_IDX, RB - } - | cmp RB, dword FOR_STOP - | mov FOR_TEXT, LJ_TISNUM - | mov dword FOR_EXT, RB - if (op == BC_FORI) { - | jge <7 - } else if (op == BC_JFORI) { - | branchPC RD - | movzx RD, PC_RD - | jge =>BC_JLOOP - } else if (op == BC_IFORL) { - | jl <7 - } else { - | jge =>BC_JLOOP - } - | jmp <6 - |9: // Fallback to FP variant. - } else if (!vk) { - | cmp FOR_TIDX, LJ_TISNUM - } - if (!vk) { - | jae ->vmeta_for - | cmp FOR_TSTOP, LJ_TISNUM; jae ->vmeta_for - } else { -#ifdef LUA_USE_ASSERT - | cmp FOR_TSTOP, LJ_TISNUM; jae ->assert_bad_for_arg_type - | cmp FOR_TSTEP, LJ_TISNUM; jae ->assert_bad_for_arg_type -#endif - } - | mov RB, FOR_TSTEP // Load type/hiword of for step. - if (!vk) { - | cmp RB, LJ_TISNUM; jae ->vmeta_for - } - |.if SSE - | movsd xmm0, qword FOR_IDX - | movsd xmm1, qword FOR_STOP - if (vk) { - | addsd xmm0, qword FOR_STEP - | movsd qword FOR_IDX, xmm0 - | test RB, RB; js >3 - } else { - | jl >3 - } - | ucomisd xmm1, xmm0 - |1: - | movsd qword FOR_EXT, xmm0 - |.else - | fld qword FOR_STOP - | fld qword FOR_IDX - if (vk) { - | fadd qword FOR_STEP // nidx = idx + step - | fst qword FOR_IDX - | fst qword FOR_EXT - | test RB, RB; js >1 - } else { - | fst qword FOR_EXT - | jl >1 - } - | fxch // Swap lim/(n)idx if step non-negative. - |1: - | fcomparepp - |.endif - if (op == BC_FORI) { - |.if DUALNUM - | jnb <7 - |.else - | jnb >2 - | branchPC RD - |.endif - } else if (op == BC_JFORI) { - | branchPC RD - | movzx RD, PC_RD - | jnb =>BC_JLOOP - } else if (op == BC_IFORL) { - |.if DUALNUM - | jb <7 - |.else - | jb >2 - | branchPC RD - |.endif - } else { - | jnb =>BC_JLOOP - } - |.if DUALNUM - | jmp <6 - |.else - |2: - | ins_next - |.endif - |.if SSE - |3: // Invert comparison if step is negative. - | ucomisd xmm0, xmm1 - | jmp <1 - |.endif - break; - - case BC_ITERL: - |.if JIT - | hotloop RB - |.endif - | // Fall through. Assumes BC_IITERL follows and ins_AJ is a no-op. - break; - - case BC_JITERL: -#if !LJ_HASJIT - break; -#endif - case BC_IITERL: - | ins_AJ // RA = base, RD = target - | lea RA, [BASE+RA*8] - | mov RB, [RA+4] - | cmp RB, LJ_TNIL; je >1 // Stop if iterator returned nil. - if (op == BC_JITERL) { - | mov [RA-4], RB - | mov RB, [RA] - | mov [RA-8], RB - | jmp =>BC_JLOOP - } else { - | branchPC RD // Otherwise save control var + branch. - | mov RD, [RA] - | mov [RA-4], RB - | mov [RA-8], RD - } - |1: - | ins_next - break; - - case BC_LOOP: - | ins_A // RA = base, RD = target (loop extent) - | // Note: RA/RD is only used by trace recorder to determine scope/extent - | // This opcode does NOT jump, it's only purpose is to detect a hot loop. - |.if JIT - | hotloop RB - |.endif - | // Fall through. Assumes BC_ILOOP follows and ins_A is a no-op. - break; - - case BC_ILOOP: - | ins_A // RA = base, RD = target (loop extent) - | ins_next - break; - - case BC_JLOOP: - |.if JIT - | ins_AD // RA = base (ignored), RD = traceno - | mov RA, [DISPATCH+DISPATCH_J(trace)] - | mov TRACE:RD, [RA+RD*4] - | mov RDa, TRACE:RD->mcode - | mov L:RB, SAVE_L - | mov [DISPATCH+DISPATCH_GL(jit_base)], BASE - | mov [DISPATCH+DISPATCH_GL(jit_L)], L:RB - | // Save additional callee-save registers only used in compiled code. - |.if X64WIN - | mov TMPQ, r12 - | mov TMPa, r13 - | mov CSAVE_4, r14 - | mov CSAVE_3, r15 - | mov RAa, rsp - | sub rsp, 9*16+4*8 - | movdqa [RAa], xmm6 - | movdqa [RAa-1*16], xmm7 - | movdqa [RAa-2*16], xmm8 - | movdqa [RAa-3*16], xmm9 - | movdqa [RAa-4*16], xmm10 - | movdqa [RAa-5*16], xmm11 - | movdqa [RAa-6*16], xmm12 - | movdqa [RAa-7*16], xmm13 - | movdqa [RAa-8*16], xmm14 - | movdqa [RAa-9*16], xmm15 - |.elif X64 - | mov TMPQ, r12 - | mov TMPa, r13 - | sub rsp, 16 - |.endif - | jmp RDa - |.endif - break; - - case BC_JMP: - | ins_AJ // RA = unused, RD = target - | branchPC RD - | ins_next - break; - - /* -- Function headers -------------------------------------------------- */ - - /* - ** Reminder: A function may be called with func/args above L->maxstack, - ** i.e. occupying EXTRA_STACK slots. And vmeta_call may add one extra slot, - ** too. This means all FUNC* ops (including fast functions) must check - ** for stack overflow _before_ adding more slots! - */ - - case BC_FUNCF: - |.if JIT - | hotcall RB - |.endif - case BC_FUNCV: /* NYI: compiled vararg functions. */ - | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow and ins_AD is a no-op. - break; - - case BC_JFUNCF: -#if !LJ_HASJIT - break; -#endif - case BC_IFUNCF: - | ins_AD // BASE = new base, RA = framesize, RD = nargs+1 - | mov KBASE, [PC-4+PC2PROTO(k)] - | mov L:RB, SAVE_L - | lea RA, [BASE+RA*8] // Top of frame. - | cmp RA, L:RB->maxstack - | ja ->vm_growstack_f - | movzx RA, byte [PC-4+PC2PROTO(numparams)] - | cmp NARGS:RD, RA // Check for missing parameters. - | jbe >3 - |2: - if (op == BC_JFUNCF) { - | movzx RD, PC_RD - | jmp =>BC_JLOOP - } else { - | ins_next - } - | - |3: // Clear missing parameters. - | mov dword [BASE+NARGS:RD*8-4], LJ_TNIL - | add NARGS:RD, 1 - | cmp NARGS:RD, RA - | jbe <3 - | jmp <2 - break; - - case BC_JFUNCV: -#if !LJ_HASJIT - break; -#endif - | int3 // NYI: compiled vararg functions - break; /* NYI: compiled vararg functions. */ - - case BC_IFUNCV: - | ins_AD // BASE = new base, RA = framesize, RD = nargs+1 - | lea RB, [NARGS:RD*8+FRAME_VARG] - | lea RD, [BASE+NARGS:RD*8] - | mov LFUNC:KBASE, [BASE-8] - | mov [RD-4], RB // Store delta + FRAME_VARG. - | mov [RD-8], LFUNC:KBASE // Store copy of LFUNC. - | mov L:RB, SAVE_L - | lea RA, [RD+RA*8] - | cmp RA, L:RB->maxstack - | ja ->vm_growstack_v // Need to grow stack. - | mov RA, BASE - | mov BASE, RD - | movzx RB, byte [PC-4+PC2PROTO(numparams)] - | test RB, RB - | jz >2 - |1: // Copy fixarg slots up to new frame. - | add RA, 8 - | cmp RA, BASE - | jnb >3 // Less args than parameters? - | mov KBASE, [RA-8] - | mov [RD], KBASE - | mov KBASE, [RA-4] - | mov [RD+4], KBASE - | add RD, 8 - | mov dword [RA-4], LJ_TNIL // Clear old fixarg slot (help the GC). - | sub RB, 1 - | jnz <1 - |2: - if (op == BC_JFUNCV) { - | movzx RD, PC_RD - | jmp =>BC_JLOOP - } else { - | mov KBASE, [PC-4+PC2PROTO(k)] - | ins_next - } - | - |3: // Clear missing parameters. - | mov dword [RD+4], LJ_TNIL - | add RD, 8 - | sub RB, 1 - | jnz <3 - | jmp <2 - break; - - case BC_FUNCC: - case BC_FUNCCW: - | ins_AD // BASE = new base, RA = ins RA|RD (unused), RD = nargs+1 - | mov CFUNC:RB, [BASE-8] - | mov KBASEa, CFUNC:RB->f - | mov L:RB, SAVE_L - | lea RD, [BASE+NARGS:RD*8-8] - | mov L:RB->base, BASE - | lea RA, [RD+8*LUA_MINSTACK] - | cmp RA, L:RB->maxstack - | mov L:RB->top, RD - if (op == BC_FUNCC) { - |.if X64 - | mov CARG1d, L:RB // Caveat: CARG1d may be RA. - |.else - | mov ARG1, L:RB - |.endif - } else { - |.if X64 - | mov CARG2, KBASEa - | mov CARG1d, L:RB // Caveat: CARG1d may be RA. - |.else - | mov ARG2, KBASEa - | mov ARG1, L:RB - |.endif - } - | ja ->vm_growstack_c // Need to grow stack. - | set_vmstate C - if (op == BC_FUNCC) { - | call KBASEa // (lua_State *L) - } else { - | // (lua_State *L, lua_CFunction f) - | call aword [DISPATCH+DISPATCH_GL(wrapf)] - } - | set_vmstate INTERP - | // nresults returned in eax (RD). - | mov BASE, L:RB->base - | lea RA, [BASE+RD*8] - | neg RA - | add RA, L:RB->top // RA = (L->top-(L->base+nresults))*8 - | mov PC, [BASE-4] // Fetch PC of caller. - | jmp ->vm_returnc - break; - - /* ---------------------------------------------------------------------- */ - - default: - fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); - exit(2); - break; - } -} - -static int build_backend(BuildCtx *ctx) -{ - int op; - dasm_growpc(Dst, BC__MAX); - build_subroutines(ctx); - |.code_op - for (op = 0; op < BC__MAX; op++) - build_ins(ctx, (BCOp)op, op); - return BC__MAX; -} - -/* Emit pseudo frame-info for all assembler functions. */ -static void emit_asm_debug(BuildCtx *ctx) -{ - int fcofs = (int)((uint8_t *)ctx->glob[GLOB_vm_ffi_call] - ctx->code); -#if LJ_64 -#define SZPTR "8" -#define BSZPTR "3" -#define REG_SP "0x7" -#define REG_RA "0x10" -#else -#define SZPTR "4" -#define BSZPTR "2" -#define REG_SP "0x4" -#define REG_RA "0x8" -#endif - switch (ctx->mode) { - case BUILD_elfasm: - fprintf(ctx->fp, "\t.section .debug_frame,\"\",@progbits\n"); - fprintf(ctx->fp, - ".Lframe0:\n" - "\t.long .LECIE0-.LSCIE0\n" - ".LSCIE0:\n" - "\t.long 0xffffffff\n" - "\t.byte 0x1\n" - "\t.string \"\"\n" - "\t.uleb128 0x1\n" - "\t.sleb128 -" SZPTR "\n" - "\t.byte " REG_RA "\n" - "\t.byte 0xc\n\t.uleb128 " REG_SP "\n\t.uleb128 " SZPTR "\n" - "\t.byte 0x80+" REG_RA "\n\t.uleb128 0x1\n" - "\t.align " SZPTR "\n" - ".LECIE0:\n\n"); - fprintf(ctx->fp, - ".LSFDE0:\n" - "\t.long .LEFDE0-.LASFDE0\n" - ".LASFDE0:\n" - "\t.long .Lframe0\n" -#if LJ_64 - "\t.quad .Lbegin\n" - "\t.quad %d\n" - "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ - "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ - "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ - "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */ - "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */ -#else - "\t.long .Lbegin\n" - "\t.long %d\n" - "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ - "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ - "\t.byte 0x87\n\t.uleb128 0x3\n" /* offset edi */ - "\t.byte 0x86\n\t.uleb128 0x4\n" /* offset esi */ - "\t.byte 0x83\n\t.uleb128 0x5\n" /* offset ebx */ -#endif - "\t.align " SZPTR "\n" - ".LEFDE0:\n\n", fcofs, CFRAME_SIZE); -#if LJ_HASFFI - fprintf(ctx->fp, - ".LSFDE1:\n" - "\t.long .LEFDE1-.LASFDE1\n" - ".LASFDE1:\n" - "\t.long .Lframe0\n" -#if LJ_64 - "\t.quad lj_vm_ffi_call\n" - "\t.quad %d\n" - "\t.byte 0xe\n\t.uleb128 16\n" /* def_cfa_offset */ - "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ - "\t.byte 0xd\n\t.uleb128 0x6\n" /* def_cfa_register rbp */ - "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ -#else - "\t.long lj_vm_ffi_call\n" - "\t.long %d\n" - "\t.byte 0xe\n\t.uleb128 8\n" /* def_cfa_offset */ - "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ - "\t.byte 0xd\n\t.uleb128 0x5\n" /* def_cfa_register ebp */ - "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset ebx */ -#endif - "\t.align " SZPTR "\n" - ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); -#endif -#if (defined(__sun__) && defined(__svr4__)) -#if LJ_64 - fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@unwind\n"); -#else - fprintf(ctx->fp, "\t.section .eh_frame,\"aw\",@progbits\n"); -#endif -#else - fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n"); -#endif - fprintf(ctx->fp, - ".Lframe1:\n" - "\t.long .LECIE1-.LSCIE1\n" - ".LSCIE1:\n" - "\t.long 0\n" - "\t.byte 0x1\n" - "\t.string \"zPR\"\n" - "\t.uleb128 0x1\n" - "\t.sleb128 -" SZPTR "\n" - "\t.byte " REG_RA "\n" - "\t.uleb128 6\n" /* augmentation length */ - "\t.byte 0x1b\n" /* pcrel|sdata4 */ - "\t.long lj_err_unwind_dwarf-.\n" - "\t.byte 0x1b\n" /* pcrel|sdata4 */ - "\t.byte 0xc\n\t.uleb128 " REG_SP "\n\t.uleb128 " SZPTR "\n" - "\t.byte 0x80+" REG_RA "\n\t.uleb128 0x1\n" - "\t.align " SZPTR "\n" - ".LECIE1:\n\n"); - fprintf(ctx->fp, - ".LSFDE2:\n" - "\t.long .LEFDE2-.LASFDE2\n" - ".LASFDE2:\n" - "\t.long .LASFDE2-.Lframe1\n" - "\t.long .Lbegin-.\n" - "\t.long %d\n" - "\t.uleb128 0\n" /* augmentation length */ - "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ -#if LJ_64 - "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ - "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ - "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */ - "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */ -#else - "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ - "\t.byte 0x87\n\t.uleb128 0x3\n" /* offset edi */ - "\t.byte 0x86\n\t.uleb128 0x4\n" /* offset esi */ - "\t.byte 0x83\n\t.uleb128 0x5\n" /* offset ebx */ -#endif - "\t.align " SZPTR "\n" - ".LEFDE2:\n\n", fcofs, CFRAME_SIZE); -#if LJ_HASFFI - fprintf(ctx->fp, - ".Lframe2:\n" - "\t.long .LECIE2-.LSCIE2\n" - ".LSCIE2:\n" - "\t.long 0\n" - "\t.byte 0x1\n" - "\t.string \"zR\"\n" - "\t.uleb128 0x1\n" - "\t.sleb128 -" SZPTR "\n" - "\t.byte " REG_RA "\n" - "\t.uleb128 1\n" /* augmentation length */ - "\t.byte 0x1b\n" /* pcrel|sdata4 */ - "\t.byte 0xc\n\t.uleb128 " REG_SP "\n\t.uleb128 " SZPTR "\n" - "\t.byte 0x80+" REG_RA "\n\t.uleb128 0x1\n" - "\t.align " SZPTR "\n" - ".LECIE2:\n\n"); - fprintf(ctx->fp, - ".LSFDE3:\n" - "\t.long .LEFDE3-.LASFDE3\n" - ".LASFDE3:\n" - "\t.long .LASFDE3-.Lframe2\n" - "\t.long lj_vm_ffi_call-.\n" - "\t.long %d\n" - "\t.uleb128 0\n" /* augmentation length */ -#if LJ_64 - "\t.byte 0xe\n\t.uleb128 16\n" /* def_cfa_offset */ - "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ - "\t.byte 0xd\n\t.uleb128 0x6\n" /* def_cfa_register rbp */ - "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ -#else - "\t.byte 0xe\n\t.uleb128 8\n" /* def_cfa_offset */ - "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ - "\t.byte 0xd\n\t.uleb128 0x5\n" /* def_cfa_register ebp */ - "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset ebx */ -#endif - "\t.align " SZPTR "\n" - ".LEFDE3:\n\n", (int)ctx->codesz - fcofs); -#endif - break; - /* Mental note: never let Apple design an assembler. - ** Or a linker. Or a plastic case. But I digress. - */ - case BUILD_machasm: { -#if LJ_HASFFI - int fcsize = 0; -#endif - int i; - fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n"); - fprintf(ctx->fp, - "EH_frame1:\n" - "\t.set L$set$x,LECIEX-LSCIEX\n" - "\t.long L$set$x\n" - "LSCIEX:\n" - "\t.long 0\n" - "\t.byte 0x1\n" - "\t.ascii \"zPR\\0\"\n" - "\t.byte 0x1\n" - "\t.byte 128-" SZPTR "\n" - "\t.byte " REG_RA "\n" - "\t.byte 6\n" /* augmentation length */ - "\t.byte 0x9b\n" /* indirect|pcrel|sdata4 */ -#if LJ_64 - "\t.long _lj_err_unwind_dwarf+4@GOTPCREL\n" - "\t.byte 0x1b\n" /* pcrel|sdata4 */ - "\t.byte 0xc\n\t.byte " REG_SP "\n\t.byte " SZPTR "\n" -#else - "\t.long L_lj_err_unwind_dwarf$non_lazy_ptr-.\n" - "\t.byte 0x1b\n" /* pcrel|sdata4 */ - "\t.byte 0xc\n\t.byte 0x5\n\t.byte 0x4\n" /* esp=5 on 32 bit MACH-O. */ -#endif - "\t.byte 0x80+" REG_RA "\n\t.byte 0x1\n" - "\t.align " BSZPTR "\n" - "LECIEX:\n\n"); - for (i = 0; i < ctx->nsym; i++) { - const char *name = ctx->sym[i].name; - int32_t size = ctx->sym[i+1].ofs - ctx->sym[i].ofs; - if (size == 0) continue; -#if LJ_HASFFI - if (!strcmp(name, "_lj_vm_ffi_call")) { fcsize = size; continue; } -#endif - fprintf(ctx->fp, - "%s.eh:\n" - "LSFDE%d:\n" - "\t.set L$set$%d,LEFDE%d-LASFDE%d\n" - "\t.long L$set$%d\n" - "LASFDE%d:\n" - "\t.long LASFDE%d-EH_frame1\n" - "\t.long %s-.\n" - "\t.long %d\n" - "\t.byte 0\n" /* augmentation length */ - "\t.byte 0xe\n\t.byte %d\n" /* def_cfa_offset */ -#if LJ_64 - "\t.byte 0x86\n\t.byte 0x2\n" /* offset rbp */ - "\t.byte 0x83\n\t.byte 0x3\n" /* offset rbx */ - "\t.byte 0x8f\n\t.byte 0x4\n" /* offset r15 */ - "\t.byte 0x8e\n\t.byte 0x5\n" /* offset r14 */ -#else - "\t.byte 0x84\n\t.byte 0x2\n" /* offset ebp (4 for MACH-O)*/ - "\t.byte 0x87\n\t.byte 0x3\n" /* offset edi */ - "\t.byte 0x86\n\t.byte 0x4\n" /* offset esi */ - "\t.byte 0x83\n\t.byte 0x5\n" /* offset ebx */ -#endif - "\t.align " BSZPTR "\n" - "LEFDE%d:\n\n", - name, i, i, i, i, i, i, i, name, size, CFRAME_SIZE, i); - } -#if LJ_HASFFI - if (fcsize) { - fprintf(ctx->fp, - "EH_frame2:\n" - "\t.set L$set$y,LECIEY-LSCIEY\n" - "\t.long L$set$y\n" - "LSCIEY:\n" - "\t.long 0\n" - "\t.byte 0x1\n" - "\t.ascii \"zR\\0\"\n" - "\t.byte 0x1\n" - "\t.byte 128-" SZPTR "\n" - "\t.byte " REG_RA "\n" - "\t.byte 1\n" /* augmentation length */ -#if LJ_64 - "\t.byte 0x1b\n" /* pcrel|sdata4 */ - "\t.byte 0xc\n\t.byte " REG_SP "\n\t.byte " SZPTR "\n" -#else - "\t.byte 0x1b\n" /* pcrel|sdata4 */ - "\t.byte 0xc\n\t.byte 0x5\n\t.byte 0x4\n" /* esp=5 on 32 bit MACH. */ -#endif - "\t.byte 0x80+" REG_RA "\n\t.byte 0x1\n" - "\t.align " BSZPTR "\n" - "LECIEY:\n\n"); - fprintf(ctx->fp, - "_lj_vm_ffi_call.eh:\n" - "LSFDEY:\n" - "\t.set L$set$yy,LEFDEY-LASFDEY\n" - "\t.long L$set$yy\n" - "LASFDEY:\n" - "\t.long LASFDEY-EH_frame2\n" - "\t.long _lj_vm_ffi_call-.\n" - "\t.long %d\n" - "\t.byte 0\n" /* augmentation length */ -#if LJ_64 - "\t.byte 0xe\n\t.byte 16\n" /* def_cfa_offset */ - "\t.byte 0x86\n\t.byte 0x2\n" /* offset rbp */ - "\t.byte 0xd\n\t.byte 0x6\n" /* def_cfa_register rbp */ - "\t.byte 0x83\n\t.byte 0x3\n" /* offset rbx */ -#else - "\t.byte 0xe\n\t.byte 8\n" /* def_cfa_offset */ - "\t.byte 0x84\n\t.byte 0x2\n" /* offset ebp (4 for MACH-O)*/ - "\t.byte 0xd\n\t.byte 0x4\n" /* def_cfa_register ebp */ - "\t.byte 0x83\n\t.byte 0x3\n" /* offset ebx */ -#endif - "\t.align " BSZPTR "\n" - "LEFDEY:\n\n", fcsize); - } -#endif -#if LJ_64 - fprintf(ctx->fp, "\t.subsections_via_symbols\n"); -#else - fprintf(ctx->fp, - "\t.non_lazy_symbol_pointer\n" - "L_lj_err_unwind_dwarf$non_lazy_ptr:\n" - ".indirect_symbol _lj_err_unwind_dwarf\n" - ".long 0\n"); -#endif - } - break; - default: /* Difficult for other modes. */ - break; - } -} - diff --git a/source/libs/luajit/LuaJIT-2.0.3-PATCHES/ChangeLog b/source/libs/luajit/LuaJIT-2.0.4-PATCHES/ChangeLog similarity index 100% rename from source/libs/luajit/LuaJIT-2.0.3-PATCHES/ChangeLog rename to source/libs/luajit/LuaJIT-2.0.4-PATCHES/ChangeLog diff --git a/source/libs/luajit/LuaJIT-2.0.3-PATCHES/TL-Changes b/source/libs/luajit/LuaJIT-2.0.4-PATCHES/TL-Changes similarity index 100% rename from source/libs/luajit/LuaJIT-2.0.3-PATCHES/TL-Changes rename to source/libs/luajit/LuaJIT-2.0.4-PATCHES/TL-Changes diff --git a/source/libs/luajit/LuaJIT-2.0.4-PATCHES/patch-01-LuaJITTeX b/source/libs/luajit/LuaJIT-2.0.4-PATCHES/patch-01-LuaJITTeX new file mode 100644 index 000000000..db988a6a4 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4-PATCHES/patch-01-LuaJITTeX @@ -0,0 +1,176 @@ +diff -ur -x lbitlib.c LuaJIT-2.0.4.orig/src/lauxlib.h LuaJIT-2.0.4/src/lauxlib.h +--- LuaJIT-2.0.4.orig/src/lauxlib.h 2015-05-14 20:30:00.000000000 +0200 ++++ LuaJIT-2.0.4/src/lauxlib.h 2015-06-12 11:04:08.000000000 +0200 +@@ -86,6 +86,32 @@ + int level); + + ++ ++/* ++** {====================================================== ++** File handles for IO library ++** ======================================================= ++*/ ++ ++/* ++** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and ++** initial structure 'luaL_Stream' (it may contain other fields ++** after that initial structure). ++*/ ++ ++#define LUA_FILEHANDLE "FILE*" ++ ++ ++typedef struct luaL_Stream { ++ FILE *f; /* stream (NULL for incompletely created streams) */ ++ lua_CFunction closef; /* to close stream (NULL for closed streams) */ ++} luaL_Stream; ++ ++/* }====================================================== */ ++ ++ ++ ++ + /* + ** =============================================================== + ** some useful macros +diff -ur -x lbitlib.c LuaJIT-2.0.4.orig/src/lib_init.c LuaJIT-2.0.4/src/lib_init.c +--- LuaJIT-2.0.4.orig/src/lib_init.c 2015-05-14 20:30:00.000000000 +0200 ++++ LuaJIT-2.0.4/src/lib_init.c 2015-06-12 11:04:08.000000000 +0200 +@@ -26,6 +26,7 @@ + { LUA_DBLIBNAME, luaopen_debug }, + { LUA_BITLIBNAME, luaopen_bit }, + { LUA_JITLIBNAME, luaopen_jit }, ++ { LUA_BITLIBNAME_32, luaopen_bit32 }, + { NULL, NULL } + }; + +diff -ur -x lbitlib.c LuaJIT-2.0.4.orig/src/lib_package.c LuaJIT-2.0.4/src/lib_package.c +--- LuaJIT-2.0.4.orig/src/lib_package.c 2015-05-14 20:30:00.000000000 +0200 ++++ LuaJIT-2.0.4/src/lib_package.c 2015-06-12 11:04:08.000000000 +0200 +@@ -354,6 +354,29 @@ + return 1; /* library loaded successfully */ + } + ++#define LUA_POF "luaopen_" ++#define LUA_OFSEP "_" ++#define POF LUA_POF ++ ++static const char *mkfuncname (lua_State *L, const char *modname) { ++ const char *funcname; ++ const char *mark = strchr(modname, *LUA_IGMARK); ++ if (mark) modname = mark + 1; ++ funcname = luaL_gsub(L, modname, ".", LUA_OFSEP); ++ funcname = lua_pushfstring(L, POF"%s", funcname); ++ lua_remove(L, -2); /* remove 'gsub' result */ ++ return funcname; ++} ++ ++ ++int loader_C_luatex (lua_State *L, const char *name, const char *filename) { ++ const char *funcname; ++ funcname = mkfuncname(L, name); ++ if (ll_loadfunc(L, filename, funcname,0) != 0) ++ loaderror(L, filename); ++ return 1; /* library loaded successfully */ ++} ++ + static int lj_cf_package_loader_croot(lua_State *L) + { + const char *filename; +@@ -373,6 +396,21 @@ + return 1; + } + ++int loader_Call_luatex (lua_State *L, const char *name, const char *filename) { ++ const char *funcname; ++ int stat; ++ if (filename == NULL) return 1; /* root not found */ ++ funcname = mkfuncname(L, name); ++ if ((stat = ll_loadfunc(L, filename, funcname,0)) != 0) { ++ if (stat != PACKAGE_ERR_FUNC) loaderror(L, filename); /* real error */ ++ lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, ++ name, filename); ++ return 1; /* function not found */ ++ } ++ return 1; /* library loaded successfully */ ++} ++ ++ + static int lj_cf_package_loader_preload(lua_State *L) + { + const char *name = luaL_checkstring(L, 1); +diff -ur -x lbitlib.c LuaJIT-2.0.4.orig/src/lua.h LuaJIT-2.0.4/src/lua.h +--- LuaJIT-2.0.4.orig/src/lua.h 2015-05-14 20:30:00.000000000 +0200 ++++ LuaJIT-2.0.4/src/lua.h 2015-06-12 11:04:08.000000000 +0200 +@@ -348,6 +348,16 @@ + const char *chunkname, const char *mode); + + ++#define LUA_OPEQ 0 ++#define LUA_OPLT 1 ++#define LUA_OPLE 2 ++#define LUA_OK 0 ++ ++/* see http://comments.gmane.org/gmane.comp.programming.swig/18673 */ ++# define lua_rawlen lua_objlen ++ ++ ++ + struct lua_Debug { + int event; + const char *name; /* (n) */ +diff -ur -x lbitlib.c LuaJIT-2.0.4.orig/src/lualib.h LuaJIT-2.0.4/src/lualib.h +--- LuaJIT-2.0.4.orig/src/lualib.h 2015-05-14 20:30:00.000000000 +0200 ++++ LuaJIT-2.0.4/src/lualib.h 2015-06-12 11:04:08.000000000 +0200 +@@ -22,6 +22,8 @@ + #define LUA_JITLIBNAME "jit" + #define LUA_FFILIBNAME "ffi" + ++#define LUA_BITLIBNAME_32 "bit32" ++ + LUALIB_API int luaopen_base(lua_State *L); + LUALIB_API int luaopen_math(lua_State *L); + LUALIB_API int luaopen_string(lua_State *L); +@@ -34,6 +36,8 @@ + LUALIB_API int luaopen_jit(lua_State *L); + LUALIB_API int luaopen_ffi(lua_State *L); + ++LUALIB_API int luaopen_bit32(lua_State *L); ++ + LUALIB_API void luaL_openlibs(lua_State *L); + + #ifndef lua_assert +diff -ur -x lbitlib.c LuaJIT-2.0.4.orig/src/Makefile LuaJIT-2.0.4/src/Makefile +--- LuaJIT-2.0.4.orig/src/Makefile 2015-05-14 20:30:00.000000000 +0200 ++++ LuaJIT-2.0.4/src/Makefile 2015-06-12 11:04:08.000000000 +0200 +@@ -100,7 +100,7 @@ + # enabled by default. Some other features that *might* break some existing + # code (e.g. __pairs or os.execute() return values) can be enabled here. + # Note: this does not provide full compatibility with Lua 5.2 at this time. +-#XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT ++XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT + # + # Disable the JIT compiler, i.e. turn LuaJIT into a pure interpreter. + #XCFLAGS+= -DLUAJIT_DISABLE_JIT +@@ -448,7 +448,7 @@ + LJVM_BOUT= $(LJVM_S) + LJVM_MODE= elfasm + +-LJLIB_O= lib_base.o lib_math.o lib_bit.o lib_string.o lib_table.o \ ++LJLIB_O= lib_base.o lib_math.o lbitlib.o lib_bit.o lib_string.o lib_table.o \ + lib_io.o lib_os.o lib_package.o lib_debug.o lib_jit.o lib_ffi.o + LJLIB_C= $(LJLIB_O:.o=.c) + +diff -ur -x lbitlib.c LuaJIT-2.0.4.orig/src/Makefile.dep LuaJIT-2.0.4/src/Makefile.dep +--- LuaJIT-2.0.4.orig/src/Makefile.dep 2015-05-14 20:30:00.000000000 +0200 ++++ LuaJIT-2.0.4/src/Makefile.dep 2015-06-12 11:04:08.000000000 +0200 +@@ -6,6 +6,7 @@ + lj_tab.h lj_meta.h lj_state.h lj_ctype.h lj_cconv.h lj_bc.h lj_ff.h \ + lj_ffdef.h lj_dispatch.h lj_jit.h lj_ir.h lj_char.h lj_strscan.h \ + lj_lib.h lj_libdef.h ++lbitlib.o: lbitlib.c lua.h luaconf.h lauxlib.h lualib.h + lib_bit.o: lib_bit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ + lj_arch.h lj_err.h lj_errmsg.h lj_str.h lj_lib.h lj_libdef.h + lib_debug.o: lib_debug.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ +Only in LuaJIT-2.0.4/src: Makefile.orig diff --git a/source/libs/luajit/LuaJIT-2.0.4-PATCHES/patch-05-LuaJITTeX b/source/libs/luajit/LuaJIT-2.0.4-PATCHES/patch-05-LuaJITTeX new file mode 100644 index 000000000..6d091a020 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4-PATCHES/patch-05-LuaJITTeX @@ -0,0 +1,108 @@ +diff -ur -x lbitlib.c LuaJIT-2.0.4.orig/src/lj_def.h LuaJIT-2.0.4/src/lj_def.h +--- LuaJIT-2.0.4.orig/src/lj_def.h 2015-05-14 20:30:00.000000000 +0200 ++++ LuaJIT-2.0.4/src/lj_def.h 2015-06-12 11:05:39.000000000 +0200 +@@ -62,7 +62,7 @@ + #define LJ_MAX_BCINS (1<<26) /* Max. # of bytecode instructions. */ + #define LJ_MAX_SLOTS 250 /* Max. # of slots in a Lua func. */ + #define LJ_MAX_LOCVAR 200 /* Max. # of local variables. */ +-#define LJ_MAX_UPVAL 60 /* Max. # of upvalues. */ ++#define LJ_MAX_UPVAL 249 /* Max. # of upvalues. */ + + #define LJ_MAX_IDXCHAIN 100 /* __index/__newindex chain limit. */ + #define LJ_STACK_EXTRA 5 /* Extra stack space (metamethods). */ +diff -ur -x lbitlib.c LuaJIT-2.0.4.orig/src/lj_str.c LuaJIT-2.0.4/src/lj_str.c +--- LuaJIT-2.0.4.orig/src/lj_str.c 2015-05-14 20:30:00.000000000 +0200 ++++ LuaJIT-2.0.4/src/lj_str.c 2015-06-12 11:05:39.000000000 +0200 +@@ -90,6 +90,16 @@ + g->strhash = newhash; + } + ++/* ++** Lua will use at most ~(2^LUAI_HASHLIMIT) bytes from a string to ++** compute its hash ++*/ ++#if !defined(LUAI_HASHLIMIT) ++#define LUAI_HASHLIMIT 5 ++#endif ++ ++#define cast(t, exp) ((t)(exp)) ++int luajittex_choose_hash_function = 0 ; + /* Intern a string and return string object. */ + GCstr *lj_str_new(lua_State *L, const char *str, size_t lenx) + { +@@ -98,27 +108,44 @@ + GCobj *o; + MSize len = (MSize)lenx; + MSize a, b, h = len; ++ size_t step ; ++ size_t l1 ; + if (lenx >= LJ_MAX_STR) + lj_err_msg(L, LJ_ERR_STROV); + g = G(L); ++ ++ if (len==0) ++ return &g->strempty; ++ if (luajittex_choose_hash_function==0) { ++ /* Lua 5.1.5 hash function */ ++ /* for 5.2 max methods we also need to patch the vm eq */ ++ step = (len>>LUAI_HASHLIMIT)+1; /* if string is too long, don't hash all its chars */ ++ for (l1=len; l1>=step; l1-=step) /* compute hash */ ++ h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); ++ } else { ++ /* LuaJIT 2.0.2 hash function */ + /* Compute string hash. Constants taken from lookup3 hash by Bob Jenkins. */ +- if (len >= 4) { /* Caveat: unaligned access! */ +- a = lj_getu32(str); +- h ^= lj_getu32(str+len-4); +- b = lj_getu32(str+(len>>1)-2); +- h ^= b; h -= lj_rol(b, 14); +- b += lj_getu32(str+(len>>2)-1); +- } else if (len > 0) { +- a = *(const uint8_t *)str; +- h ^= *(const uint8_t *)(str+len-1); +- b = *(const uint8_t *)(str+(len>>1)); +- h ^= b; h -= lj_rol(b, 14); +- } else { +- return &g->strempty; +- } +- a ^= h; a -= lj_rol(h, 11); +- b ^= a; b -= lj_rol(a, 25); +- h ^= b; h -= lj_rol(b, 16); ++ if (len >= 4) { /* Caveat: unaligned access! */ ++ a = lj_getu32(str); ++ h ^= lj_getu32(str+len-4); ++ b = lj_getu32(str+(len>>1)-2); ++ h ^= b; h -= lj_rol(b, 14); ++ b += lj_getu32(str+(len>>2)-1); ++ } else if (len > 0) { ++ a = *(const uint8_t *)str; ++ h ^= *(const uint8_t *)(str+len-1); ++ b = *(const uint8_t *)(str+(len>>1)); ++ h ^= b; h -= lj_rol(b, 14); ++ } else { ++ /* Already done, kept for reference */ ++ return &g->strempty; ++ } ++ a ^= h; a -= lj_rol(h, 11); ++ b ^= a; b -= lj_rol(a, 25); ++ h ^= b; h -= lj_rol(b, 16); ++ } ++ ++ + /* Check if the string has already been interned. */ + o = gcref(g->strhash[h & g->strmask]); + if (LJ_LIKELY((((uintptr_t)str+len-1) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4)) { +diff -ur -x lbitlib.c LuaJIT-2.0.4.orig/src/lua.h LuaJIT-2.0.4/src/lua.h +--- LuaJIT-2.0.4.orig/src/lua.h 2015-06-12 11:04:08.000000000 +0200 ++++ LuaJIT-2.0.4/src/lua.h 2015-06-12 11:05:39.000000000 +0200 +@@ -103,6 +103,9 @@ + typedef LUA_INTEGER lua_Integer; + + ++/* communication with LuaJiTTeX */ ++LUA_API int luajittex_choose_hash_function; ++ + + /* + ** state manipulation +Only in LuaJIT-2.0.4/src: Makefile.orig diff --git a/source/libs/luajit/LuaJIT-2.0.4-PATCHES/patch-06-ppc-darwin b/source/libs/luajit/LuaJIT-2.0.4-PATCHES/patch-06-ppc-darwin new file mode 100644 index 000000000..35ed49523 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4-PATCHES/patch-06-ppc-darwin @@ -0,0 +1,26 @@ +diff -ur -x lbitlib.c LuaJIT-2.0.4.orig/src/host/buildvm.c LuaJIT-2.0.4/src/host/buildvm.c +--- LuaJIT-2.0.4.orig/src/host/buildvm.c 2015-05-14 20:30:00.000000000 +0200 ++++ LuaJIT-2.0.4/src/host/buildvm.c 2015-06-12 11:06:32.000000000 +0200 +@@ -113,7 +113,7 @@ + name[0] = '@'; + else + *p = '\0'; +-#elif (LJ_TARGET_PPC || LJ_TARGET_PPCSPE) && !LJ_TARGET_CONSOLE ++#elif ((LJ_TARGET_PPC && !LJ_TARGET_OSX) || LJ_TARGET_PPCSPE) && !LJ_TARGET_CONSOLE + /* Keep @plt. */ + #else + *p = '\0'; +diff -ur -x lbitlib.c LuaJIT-2.0.4.orig/src/lj_arch.h LuaJIT-2.0.4/src/lj_arch.h +--- LuaJIT-2.0.4.orig/src/lj_arch.h 2015-05-14 20:30:00.000000000 +0200 ++++ LuaJIT-2.0.4/src/lj_arch.h 2015-06-12 11:06:32.000000000 +0200 +@@ -301,7 +301,7 @@ + #if __GNUC__ < 4 + #error "Need at least GCC 4.0 or newer" + #endif +-#elif LJ_TARGET_ARM ++#elif LJ_TARGET_ARM || LJ_TARGET_PPC + #if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 2) + #error "Need at least GCC 4.2 or newer" + #endif +Only in LuaJIT-2.0.4/src: lj_arch.h.orig +Only in LuaJIT-2.0.4/src: Makefile.orig diff --git a/source/libs/luajit/LuaJIT-2.0.4/COPYRIGHT b/source/libs/luajit/LuaJIT-2.0.4/COPYRIGHT new file mode 100644 index 000000000..1ef7df624 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/COPYRIGHT @@ -0,0 +1,56 @@ +=============================================================================== +LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/ + +Copyright (C) 2005-2015 Mike Pall. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +[ MIT license: http://www.opensource.org/licenses/mit-license.php ] + +=============================================================================== +[ LuaJIT includes code from Lua 5.1/5.2, which has this license statement: ] + +Copyright (C) 1994-2012 Lua.org, PUC-Rio. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +=============================================================================== +[ LuaJIT includes code from dlmalloc, which has this license statement: ] + +This is a version (aka dlmalloc) of malloc/free/realloc written by +Doug Lea and released to the public domain, as explained at +http://creativecommons.org/licenses/publicdomain + +=============================================================================== diff --git a/source/libs/luajit/LuaJIT-2.0.4/Makefile b/source/libs/luajit/LuaJIT-2.0.4/Makefile new file mode 100644 index 000000000..0cbe741a4 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/Makefile @@ -0,0 +1,151 @@ +############################################################################## +# LuaJIT top level Makefile for installation. Requires GNU Make. +# +# Please read doc/install.html before changing any variables! +# +# Suitable for POSIX platforms (Linux, *BSD, OSX etc.). +# Note: src/Makefile has many more configurable options. +# +# ##### This Makefile is NOT useful for Windows! ##### +# For MSVC, please follow the instructions given in src/msvcbuild.bat. +# For MinGW and Cygwin, cd to src and run make with the Makefile there. +# +# Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +############################################################################## + +MAJVER= 2 +MINVER= 0 +RELVER= 4 +VERSION= $(MAJVER).$(MINVER).$(RELVER) +ABIVER= 5.1 + +############################################################################## +# +# Change the installation path as needed. This automatically adjusts +# the paths in src/luaconf.h, too. Note: PREFIX must be an absolute path! +# +export PREFIX= /usr/local +export MULTILIB= lib +############################################################################## + +DPREFIX= $(DESTDIR)$(PREFIX) +INSTALL_BIN= $(DPREFIX)/bin +INSTALL_LIB= $(DPREFIX)/$(MULTILIB) +INSTALL_SHARE= $(DPREFIX)/share +INSTALL_INC= $(DPREFIX)/include/luajit-$(MAJVER).$(MINVER) + +INSTALL_LJLIBD= $(INSTALL_SHARE)/luajit-$(VERSION) +INSTALL_JITLIB= $(INSTALL_LJLIBD)/jit +INSTALL_LMODD= $(INSTALL_SHARE)/lua +INSTALL_LMOD= $(INSTALL_LMODD)/$(ABIVER) +INSTALL_CMODD= $(INSTALL_LIB)/lua +INSTALL_CMOD= $(INSTALL_CMODD)/$(ABIVER) +INSTALL_MAN= $(INSTALL_SHARE)/man/man1 +INSTALL_PKGCONFIG= $(INSTALL_LIB)/pkgconfig + +INSTALL_TNAME= luajit-$(VERSION) +INSTALL_TSYMNAME= luajit +INSTALL_ANAME= libluajit-$(ABIVER).a +INSTALL_SONAME= libluajit-$(ABIVER).so.$(MAJVER).$(MINVER).$(RELVER) +INSTALL_SOSHORT= libluajit-$(ABIVER).so +INSTALL_DYLIBNAME= libluajit-$(ABIVER).$(MAJVER).$(MINVER).$(RELVER).dylib +INSTALL_DYLIBSHORT1= libluajit-$(ABIVER).dylib +INSTALL_DYLIBSHORT2= libluajit-$(ABIVER).$(MAJVER).dylib +INSTALL_PCNAME= luajit.pc + +INSTALL_STATIC= $(INSTALL_LIB)/$(INSTALL_ANAME) +INSTALL_DYN= $(INSTALL_LIB)/$(INSTALL_SONAME) +INSTALL_SHORT1= $(INSTALL_LIB)/$(INSTALL_SOSHORT) +INSTALL_SHORT2= $(INSTALL_LIB)/$(INSTALL_SOSHORT) +INSTALL_T= $(INSTALL_BIN)/$(INSTALL_TNAME) +INSTALL_TSYM= $(INSTALL_BIN)/$(INSTALL_TSYMNAME) +INSTALL_PC= $(INSTALL_PKGCONFIG)/$(INSTALL_PCNAME) + +INSTALL_DIRS= $(INSTALL_BIN) $(INSTALL_LIB) $(INSTALL_INC) $(INSTALL_MAN) \ + $(INSTALL_PKGCONFIG) $(INSTALL_JITLIB) $(INSTALL_LMOD) $(INSTALL_CMOD) +UNINSTALL_DIRS= $(INSTALL_JITLIB) $(INSTALL_LJLIBD) $(INSTALL_INC) \ + $(INSTALL_LMOD) $(INSTALL_LMODD) $(INSTALL_CMOD) $(INSTALL_CMODD) + +RM= rm -f +MKDIR= mkdir -p +RMDIR= rmdir 2>/dev/null +SYMLINK= ln -sf +INSTALL_X= install -m 0755 +INSTALL_F= install -m 0644 +UNINSTALL= $(RM) +LDCONFIG= ldconfig -n +SED_PC= sed -e "s|^prefix=.*|prefix=$(PREFIX)|" \ + -e "s|^multilib=.*|multilib=$(MULTILIB)|" + +FILE_T= luajit +FILE_A= libluajit.a +FILE_SO= libluajit.so +FILE_MAN= luajit.1 +FILE_PC= luajit.pc +FILES_INC= lua.h lualib.h lauxlib.h luaconf.h lua.hpp luajit.h +FILES_JITLIB= bc.lua v.lua dump.lua dis_x86.lua dis_x64.lua dis_arm.lua \ + dis_ppc.lua dis_mips.lua dis_mipsel.lua bcsave.lua vmdef.lua + +ifeq (,$(findstring Windows,$(OS))) + ifeq (Darwin,$(shell uname -s)) + INSTALL_SONAME= $(INSTALL_DYLIBNAME) + INSTALL_SHORT1= $(INSTALL_LIB)/$(INSTALL_DYLIBSHORT1) + INSTALL_SHORT2= $(INSTALL_LIB)/$(INSTALL_DYLIBSHORT2) + LDCONFIG= : + endif +endif + +############################################################################## + +INSTALL_DEP= src/luajit + +default all $(INSTALL_DEP): + @echo "==== Building LuaJIT $(VERSION) ====" + $(MAKE) -C src + @echo "==== Successfully built LuaJIT $(VERSION) ====" + +install: $(INSTALL_DEP) + @echo "==== Installing LuaJIT $(VERSION) to $(PREFIX) ====" + $(MKDIR) $(INSTALL_DIRS) + cd src && $(INSTALL_X) $(FILE_T) $(INSTALL_T) + cd src && test -f $(FILE_A) && $(INSTALL_F) $(FILE_A) $(INSTALL_STATIC) || : + $(RM) $(INSTALL_TSYM) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2) + cd src && test -f $(FILE_SO) && \ + $(INSTALL_X) $(FILE_SO) $(INSTALL_DYN) && \ + $(LDCONFIG) $(INSTALL_LIB) && \ + $(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT1) && \ + $(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT2) || : + cd etc && $(INSTALL_F) $(FILE_MAN) $(INSTALL_MAN) + cd etc && $(SED_PC) $(FILE_PC) > $(FILE_PC).tmp && \ + $(INSTALL_F) $(FILE_PC).tmp $(INSTALL_PC) && \ + $(RM) $(FILE_PC).tmp + cd src && $(INSTALL_F) $(FILES_INC) $(INSTALL_INC) + cd src/jit && $(INSTALL_F) $(FILES_JITLIB) $(INSTALL_JITLIB) + $(SYMLINK) $(INSTALL_TNAME) $(INSTALL_TSYM) + @echo "==== Successfully installed LuaJIT $(VERSION) to $(PREFIX) ====" + +uninstall: + @echo "==== Uninstalling LuaJIT $(VERSION) from $(PREFIX) ====" + $(UNINSTALL) $(INSTALL_TSYM) $(INSTALL_T) $(INSTALL_STATIC) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2) $(INSTALL_MAN)/$(FILE_MAN) $(INSTALL_PC) + for file in $(FILES_JITLIB); do \ + $(UNINSTALL) $(INSTALL_JITLIB)/$$file; \ + done + for file in $(FILES_INC); do \ + $(UNINSTALL) $(INSTALL_INC)/$$file; \ + done + $(LDCONFIG) $(INSTALL_LIB) + $(RMDIR) $(UNINSTALL_DIRS) || : + @echo "==== Successfully uninstalled LuaJIT $(VERSION) from $(PREFIX) ====" + +############################################################################## + +amalg: + @echo "Building LuaJIT $(VERSION)" + $(MAKE) -C src amalg + +clean: + $(MAKE) -C src clean + +.PHONY: all install amalg clean + +############################################################################## diff --git a/source/libs/luajit/LuaJIT-2.0.4/README b/source/libs/luajit/LuaJIT-2.0.4/README new file mode 100644 index 000000000..44366af51 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/README @@ -0,0 +1,16 @@ +README for LuaJIT 2.0.4 +----------------------- + +LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language. + +Project Homepage: http://luajit.org/ + +LuaJIT is Copyright (C) 2005-2015 Mike Pall. +LuaJIT is free software, released under the MIT license. +See full Copyright Notice in the COPYRIGHT file or in luajit.h. + +Documentation for LuaJIT is available in HTML format. +Please point your favorite browser to: + + doc/luajit.html + diff --git a/source/libs/luajit/LuaJIT-2.0.4/doc/bluequad-print.css b/source/libs/luajit/LuaJIT-2.0.4/doc/bluequad-print.css new file mode 100644 index 000000000..07f5c84a5 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/doc/bluequad-print.css @@ -0,0 +1,166 @@ +/* Copyright (C) 2004-2015 Mike Pall. + * + * You are welcome to use the general ideas of this design for your own sites. + * But please do not steal the stylesheet, the layout or the color scheme. + */ +body { + font-family: serif; + font-size: 11pt; + margin: 0 3em; + padding: 0; + border: none; +} +a:link, a:visited, a:hover, a:active { + text-decoration: none; + background: transparent; + color: #0000ff; +} +h1, h2, h3 { + font-family: sans-serif; + font-weight: bold; + text-align: left; + margin: 0.5em 0; + padding: 0; +} +h1 { + font-size: 200%; +} +h2 { + font-size: 150%; +} +h3 { + font-size: 125%; +} +p { + margin: 0 0 0.5em 0; + padding: 0; +} +ul, ol { + margin: 0.5em 0; + padding: 0 0 0 2em; +} +ul { + list-style: outside square; +} +ol { + list-style: outside decimal; +} +li { + margin: 0; + padding: 0; +} +dl { + margin: 1em 0; + padding: 1em; + border: 1px solid black; +} +dt { + font-weight: bold; + margin: 0; + padding: 0; +} +dt sup { + float: right; + margin-left: 1em; +} +dd { + margin: 0.5em 0 0 2em; + padding: 0; +} +table { + table-layout: fixed; + width: 100%; + margin: 1em 0; + padding: 0; + border: 1px solid black; + border-spacing: 0; + border-collapse: collapse; +} +tr { + margin: 0; + padding: 0; + border: none; +} +td { + text-align: left; + margin: 0; + padding: 0.2em 0.5em; + border-top: 1px solid black; + border-bottom: 1px solid black; +} +tr.separate td { + border-top: double; +} +tt, pre, code, kbd, samp { + font-family: monospace; + font-size: 75%; +} +kbd { + font-weight: bolder; +} +blockquote, pre { + margin: 1em 2em; + padding: 0; +} +img { + border: none; + vertical-align: baseline; + margin: 0; + padding: 0; +} +img.left { + float: left; + margin: 0.5em 1em 0.5em 0; +} +img.right { + float: right; + margin: 0.5em 0 0.5em 1em; +} +.flush { + clear: both; + visibility: hidden; +} +.hide, .noprint, #nav { + display: none !important; +} +.pagebreak { + page-break-before: always; +} +#site { + text-align: right; + font-family: sans-serif; + font-weight: bold; + margin: 0 1em; + border-bottom: 1pt solid black; +} +#site a { + font-size: 1.2em; +} +#site a:link, #site a:visited { + text-decoration: none; + font-weight: bold; + background: transparent; + color: #ffffff; +} +#logo { + color: #ff8000; +} +#head { + clear: both; + margin: 0 1em; +} +#main { + line-height: 1.3; + text-align: justify; + margin: 1em; +} +#foot { + clear: both; + font-size: 80%; + text-align: center; + margin: 0 1.25em; + padding: 0.5em 0 0 0; + border-top: 1pt solid black; + page-break-before: avoid; + page-break-after: avoid; +} diff --git a/source/libs/luajit/LuaJIT-2.0.4/doc/bluequad.css b/source/libs/luajit/LuaJIT-2.0.4/doc/bluequad.css new file mode 100644 index 000000000..ae531430d --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/doc/bluequad.css @@ -0,0 +1,325 @@ +/* Copyright (C) 2004-2015 Mike Pall. + * + * You are welcome to use the general ideas of this design for your own sites. + * But please do not steal the stylesheet, the layout or the color scheme. + */ +/* colorscheme: + * + * site | head #4162bf/white | #6078bf/#e6ecff + * ------+------ ----------------+------------------- + * nav | main #bfcfff | #e6ecff/black + * + * nav: hiback loback #c5d5ff #b9c9f9 + * hiborder loborder #e6ecff #97a7d7 + * link hover #2142bf #ff0000 + * + * link: link visited hover #2142bf #8122bf #ff0000 + * + * main: boxback boxborder #f0f4ff #bfcfff + */ +body { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10pt; + margin: 0; + padding: 0; + border: none; + background: #e0e0e0; + color: #000000; +} +a:link { + text-decoration: none; + background: transparent; + color: #2142bf; +} +a:visited { + text-decoration: none; + background: transparent; + color: #8122bf; +} +a:hover, a:active { + text-decoration: underline; + background: transparent; + color: #ff0000; +} +h1, h2, h3 { + font-weight: bold; + text-align: left; + margin: 0.5em 0; + padding: 0; + background: transparent; +} +h1 { + font-size: 200%; + line-height: 3em; /* really 6em relative to body, match #site span */ + margin: 0; +} +h2 { + font-size: 150%; + color: #606060; +} +h3 { + font-size: 125%; + color: #404040; +} +p { + max-width: 600px; + margin: 0 0 0.5em 0; + padding: 0; +} +b { + color: #404040; +} +ul, ol { + max-width: 600px; + margin: 0.5em 0; + padding: 0 0 0 2em; +} +ul { + list-style: outside square; +} +ol { + list-style: outside decimal; +} +li { + margin: 0; + padding: 0; +} +dl { + max-width: 600px; + margin: 1em 0; + padding: 1em; + border: 1px solid #bfcfff; + background: #f0f4ff; +} +dt { + font-weight: bold; + margin: 0; + padding: 0; +} +dt sup { + float: right; + margin-left: 1em; + color: #808080; +} +dt a:visited { + text-decoration: none; + color: #2142bf; +} +dt a:hover, dt a:active { + text-decoration: none; + color: #ff0000; +} +dd { + margin: 0.5em 0 0 2em; + padding: 0; +} +div.tablewrap { /* for IE *sigh* */ + max-width: 600px; +} +table { + table-layout: fixed; + border-spacing: 0; + border-collapse: collapse; + max-width: 600px; + width: 100%; + margin: 1em 0; + padding: 0; + border: 1px solid #bfcfff; +} +tr { + margin: 0; + padding: 0; + border: none; +} +tr.odd { + background: #f0f4ff; +} +tr.separate td { + border-top: 1px solid #bfcfff; +} +td { + text-align: left; + margin: 0; + padding: 0.2em 0.5em; + border: none; +} +tt, code, kbd, samp { + font-family: Courier New, Courier, monospace; + line-height: 1.2; + font-size: 110%; +} +kbd { + font-weight: bolder; +} +blockquote, pre { + max-width: 600px; + margin: 1em 2em; + padding: 0; +} +pre { + line-height: 1.1; +} +pre.code { + line-height: 1.4; + margin: 0.5em 0 1em 0.5em; + padding: 0.5em 1em; + border: 1px solid #bfcfff; + background: #f0f4ff; +} +pre.mark { + padding-left: 2em; +} +span.codemark { + position:absolute; + left: 16em; + color: #4040c0; +} +span.mark { + color: #4040c0; + font-family: Courier New, Courier, monospace; + line-height: 1.1; +} +img { + border: none; + vertical-align: baseline; + margin: 0; + padding: 0; +} +img.left { + float: left; + margin: 0.5em 1em 0.5em 0; +} +img.right { + float: right; + margin: 0.5em 0 0.5em 1em; +} +.indent { + padding-left: 1em; +} +.flush { + clear: both; + visibility: hidden; +} +.hide, .noscreen { + display: none !important; +} +.ext { + color: #ff8000; +} +.new { + font-size: 6pt; + vertical-align: middle; + background: #ff8000; + color: #ffffff; +} +#site { + clear: both; + float: left; + width: 13em; + text-align: center; + font-weight: bold; + margin: 0; + padding: 0; + background: transparent; + color: #ffffff; +} +#site a { + font-size: 200%; +} +#site a:link, #site a:visited { + text-decoration: none; + font-weight: bold; + background: transparent; + color: #ffffff; +} +#site span { + line-height: 3em; /* really 6em relative to body, match h1 */ +} +#logo { + color: #ffb380; +} +#head { + margin: 0; + padding: 0 0 0 2em; + border-left: solid 13em #4162bf; + border-right: solid 3em #6078bf; + background: #6078bf; + color: #e6ecff; +} +#nav { + clear: both; + float: left; + overflow: hidden; + text-align: left; + line-height: 1.5; + width: 13em; + padding-top: 1em; + background: transparent; +} +#nav ul { + list-style: none outside; + margin: 0; + padding: 0; +} +#nav li { + margin: 0; + padding: 0; +} +#nav a { + display: block; + text-decoration: none; + font-weight: bold; + margin: 0; + padding: 2px 1em; + border-top: 1px solid transparent; + border-bottom: 1px solid transparent; + background: transparent; + color: #2142bf; +} +#nav a:hover, #nav a:active { + text-decoration: none; + border-top: 1px solid #97a7d7; + border-bottom: 1px solid #e6ecff; + background: #b9c9f9; + color: #ff0000; +} +#nav a.current, #nav a.current:hover, #nav a.current:active { + border-top: 1px solid #e6ecff; + border-bottom: 1px solid #97a7d7; + background: #c5d5ff; + color: #2142bf; +} +#nav ul ul a { + padding: 0 1em 0 1.7em; +} +#nav ul ul ul a { + padding: 0 0.5em 0 2.4em; +} +#main { + line-height: 1.5; + text-align: left; + margin: 0; + padding: 1em 2em; + border-left: solid 13em #bfcfff; + border-right: solid 3em #e6ecff; + background: #e6ecff; +} +#foot { + clear: both; + font-size: 80%; + text-align: center; + margin: 0; + padding: 0.5em; + background: #6078bf; + color: #ffffff; +} +#foot a:link, #foot a:visited { + text-decoration: underline; + background: transparent; + color: #ffffff; +} +#foot a:hover, #foot a:active { + text-decoration: underline; + background: transparent; + color: #bfcfff; +} diff --git a/source/libs/luajit/LuaJIT-2.0.4/doc/changes.html b/source/libs/luajit/LuaJIT-2.0.4/doc/changes.html new file mode 100644 index 000000000..d7b83ce68 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/doc/changes.html @@ -0,0 +1,978 @@ + + + +LuaJIT Change History + + + + + + + + + +
+Lua +
+ + +
+

+This is a list of changes between the released versions of LuaJIT.
+The current stable version is LuaJIT 2.0.4.
+

+

+Please check the +» Online Change History +to see whether newer versions are available. +

+ +
+

LuaJIT 2.0.4 — 2015-05-14

+
    +
  • Fix stack check in narrowing optimization.
  • +
  • Fix Lua/C API typecheck error for special indexes.
  • +
  • Fix string to number conversion.
  • +
  • Fix lexer error for chunks without tokens.
  • +
  • Don't compile IR_RETF after CALLT to ff with-side effects.
  • +
  • Fix BC_UCLO/BC_JMP join optimization in Lua parser.
  • +
  • Fix corner case in string to number conversion.
  • +
  • Gracefully handle lua_error() for a suspended coroutine.
  • +
  • Avoid error messages when building with Clang.
  • +
  • Fix snapshot #0 handling for traces with a stack check on entry.
  • +
  • Fix fused constant loads under high register pressure.
  • +
  • Invalidate backpropagation cache after DCE.
  • +
  • Fix ABC elimination.
  • +
  • Fix debug info for main chunk of stripped bytecode.
  • +
  • Fix FOLD rule for string.sub(s, ...) == k.
  • +
  • Fix FOLD rule for STRREF of SNEW.
  • +
  • Fix frame traversal while searching for error function.
  • +
  • Prevent GC estimate miscalculation due to buffer growth.
  • +
  • Prevent adding side traces for stack checks.
  • +
  • Fix top slot calculation for snapshots with continuations.
  • +
  • Fix check for reuse of SCEV results in FORL.
  • +
  • Add PS Vita port.
  • +
  • Fix compatibility issues with Illumos.
  • +
  • Fix DragonFly build (unsupported).
  • +
  • OpenBSD/x86: Better executable memory allocation for W^X mode.
  • +
  • x86: Fix argument checks for ipairs() iterator.
  • +
  • x86: lj_math_random_step() clobbers XMM regs on OSX Clang.
  • +
  • x86: Fix code generation for unused result of math.random().
  • +
  • x64: Allow building with LUAJIT_USE_SYSMALLOC and LUAJIT_USE_VALGRIND.
  • +
  • x86/x64: Fix argument check for bit shifts.
  • +
  • x86/x64: Fix code generation for fused test/arith ops.
  • +
  • ARM: Fix write barrier check in BC_USETS.
  • +
  • PPC: Fix red zone overflow in machine code generation.
  • +
  • PPC: Don't use mcrxr on PPE.
  • +
  • Various archs: Fix excess stack growth in interpreter.
  • +
  • FFI: Fix FOLD rule for TOBIT + CONV num.u32.
  • +
  • FFI: Prevent DSE across ffi.string().
  • +
  • FFI: No meta fallback when indexing pointer to incomplete struct.
  • +
  • FFI: Fix initialization of unions of subtypes.
  • +
  • FFI: Fix cdata vs. non-cdata arithmetic and comparisons.
  • +
  • FFI: Fix __index/__newindex metamethod resolution for ctypes.
  • +
  • FFI: Fix compilation of reference field access.
  • +
  • FFI: Fix frame traversal for backtraces with FFI callbacks.
  • +
  • FFI: Fix recording of indexing a struct pointer ctype object itself.
  • +
  • FFI: Allow non-scalar cdata to be compared for equality by address.
  • +
  • FFI: Fix pseudo type conversions for type punning.
  • +
+ +

LuaJIT 2.0.3 — 2014-03-12

+
    +
  • Add PS4 port.
  • +
  • Add support for multilib distro builds.
  • +
  • Fix OSX build.
  • +
  • Fix MinGW build.
  • +
  • Fix Xbox 360 build.
  • +
  • Improve ULOAD forwarding for open upvalues.
  • +
  • Fix GC steps threshold handling when called by JIT-compiled code.
  • +
  • Fix argument checks for math.deg() and math.rad().
  • +
  • Fix jit.flush(func|true).
  • +
  • Respect jit.off(func) when returning to a function, too.
  • +
  • Fix compilation of string.byte(s, nil, n).
  • +
  • Fix line number for relocated bytecode after closure fixup
  • +
  • Fix frame traversal for backtraces.
  • +
  • Fix ABC elimination.
  • +
  • Fix handling of redundant PHIs.
  • +
  • Fix snapshot restore for exit to function header.
  • +
  • Fix type punning alias analysis for constified pointers
  • +
  • Fix call unroll checks in the presence of metamethod frames.
  • +
  • Fix initial maxslot for down-recursive traces.
  • +
  • Prevent BASE register coalescing if parent uses IR_RETF.
  • +
  • Don't purge modified function from stack slots in BC_RET.
  • +
  • Fix recording of BC_VARG.
  • +
  • Don't access dangling reference to reallocated IR.
  • +
  • Fix frame depth display for bytecode dump in -jdump.
  • +
  • ARM: Fix register allocation when rematerializing FPRs.
  • +
  • x64: Fix store to upvalue for lightuserdata values.
  • +
  • FFI: Add missing GC steps for callback argument conversions.
  • +
  • FFI: Properly unload loaded DLLs.
  • +
  • FFI: Fix argument checks for ffi.string().
  • +
  • FFI/x64: Fix passing of vector arguments to calls.
  • +
  • FFI: Rehash finalizer table after GC cycle, if needed.
  • +
  • FFI: Fix cts->L for cdata unsinking in snapshot restore.
  • +
+ +

LuaJIT 2.0.2 — 2013-06-03

+
    +
  • Fix memory access check for fast string interning.
  • +
  • Fix MSVC intrinsics for older versions.
  • +
  • Add missing GC steps for io.* functions.
  • +
  • Fix spurious red zone overflows in machine code generation.
  • +
  • Fix jump-range constrained mcode allocation.
  • +
  • Inhibit DSE for implicit loads via calls.
  • +
  • Fix builtin string to number conversion for overflow digits.
  • +
  • Fix optional argument handling while recording builtins.
  • +
  • Fix optional argument handling in table.concat().
  • +
  • Add partial support for building with MingW64 GCC 4.8-SEH.
  • +
  • Add missing PHI barrier to string.sub(str, a, b) == kstr FOLD rule.
  • +
  • Fix compatibility issues with Illumos.
  • +
  • ARM: Fix cache flush/sync for exit stubs of JIT-compiled code.
  • +
  • MIPS: Fix cache flush/sync for JIT-compiled code jump area.
  • +
  • PPC: Add plt suffix for external calls from assembler code.
  • +
  • FFI: Fix snapshot substitution in SPLIT pass.
  • +
  • FFI/x86: Fix register allocation for 64 bit comparisons.
  • +
  • FFI: Fix tailcall in lowest frame to C function with bool result.
  • +
  • FFI: Ignore long type specifier in ffi.istype().
  • +
  • FFI: Fix calling conventions for 32 bit OSX and iOS simulator (struct returns).
  • +
  • FFI: Fix calling conventions for ARM hard-float EABI (nested structs).
  • +
  • FFI: Improve error messages for arithmetic and comparison operators.
  • +
  • FFI: Insert no-op type conversion for pointer to integer cast.
  • +
  • FFI: Fix unroll limit for ffi.fill().
  • +
  • FFI: Must sink XBAR together with XSTOREs.
  • +
  • FFI: Preserve intermediate string for const char * conversion.
  • +
+ +

LuaJIT 2.0.1 — 2013-02-19

+
    +
  • Don't clear frame for out-of-memory error.
  • +
  • Leave hook when resume catches error thrown from hook.
  • +
  • Add missing GC steps for template table creation.
  • +
  • Fix discharge order of comparisons in Lua parser.
  • +
  • Improve buffer handling for io.read().
  • +
  • OSX: Add support for Mach-O object files to -b option.
  • +
  • Fix PS3 port.
  • +
  • Fix/enable Xbox 360 port.
  • +
  • x86/x64: Always mark ref for shift count as non-weak.
  • +
  • x64: Don't fuse implicitly 32-to-64 extended operands.
  • +
  • ARM: Fix armhf call argument handling.
  • +
  • ARM: Fix code generation for integer math.min/math.max.
  • +
  • PPC/e500: Fix lj_vm_floor() for Inf/NaN.
  • +
  • FFI: Change priority of table initializer variants for structs.
  • +
  • FFI: Fix code generation for bool call result check on x86/x64.
  • +
  • FFI: Load FFI library on-demand for bytecode with cdata literals.
  • +
  • FFI: Fix handling of qualified transparent structs/unions.
  • +
+ +

LuaJIT 2.0.0 — 2012-11-08

+
    +
  • Correctness and completeness: +
      +
    • Fix Android/x86 build.
    • +
    • Fix recording of equality comparisons with __eq metamethods.
    • +
    • Fix detection of immutable upvalues.
    • +
    • Replace error with PANIC for callbacks from JIT-compiled code.
    • +
    • Fix builtin string to number conversion for INT_MIN.
    • +
    • Don't create unneeded array part for template tables.
    • +
    • Fix CONV.num.int sinking.
    • +
    • Don't propagate implicitly widened number to index metamethods.
    • +
    • ARM: Fix ordered comparisons of number vs. non-number.
    • +
    • FFI: Fix code generation for replay of sunk float fields.
    • +
    • FFI: Fix signedness of bool.
    • +
    • FFI: Fix recording of bool call result check on x86/x64.
    • +
    • FFI: Fix stack-adjustment for __thiscall callbacks.
    • +
  • +
+ +

LuaJIT 2.0.0-beta11 — 2012-10-16

+
    +
  • New features: +
      +
    • Use ARM VFP instructions, if available (build-time detection).
    • +
    • Add support for ARM hard-float EABI (armhf).
    • +
    • Add PS3 port.
    • +
    • Add many features from Lua 5.2, e.g. goto/labels. + Refer to this list.
    • +
    • FFI: Add parameterized C types.
    • +
    • FFI: Add support for copy constructors.
    • +
    • FFI: Equality comparisons never raise an error (treat as unequal instead).
    • +
    • FFI: Box all accessed or returned enums.
    • +
    • FFI: Check for __new metamethod when calling a constructor.
    • +
    • FFI: Handle __pairs/__ipairs metamethods for cdata objects.
    • +
    • FFI: Convert io.* file handle to FILE * pointer (but as a void *).
    • +
    • FFI: Detect and support type punning through unions.
    • +
    • FFI: Improve various error messages.
    • +
  • +
  • Build-system reorganization: +
      +
    • Reorganize directory layout:
      + lib/*src/jit/*
      + src/buildvm_*.dascsrc/vm_*.dasc
      + src/buildvm_*.h → removed
      + src/buildvm*src/host/*
    • +
    • Add minified Lua interpreter plus Lua BitOp (minilua) to run DynASM.
    • +
    • Change DynASM bit operations to use Lua BitOp
    • +
    • Translate only vm_*.dasc for detected target architecture.
    • +
    • Improve target detection for msvcbuild.bat.
    • +
    • Fix build issues on Cygwin and MinGW with optional MSys.
    • +
    • Handle cross-compiles with FPU/no-FPU or hard-fp/soft-fp ABI mismatch.
    • +
    • Remove some library functions for no-JIT/no-FFI builds.
    • +
    • Add uninstall target to top-level Makefile.
    • +
  • +
  • Correctness and completeness: +
      +
    • Preserve snapshot #0 PC for all traces.
    • +
    • Fix argument checks for coroutine.create().
    • +
    • Command line prints version and JIT status to stdout, not stderr.
    • +
    • Fix userdata __gc separations at Lua state close.
    • +
    • Fix TDUP to HLOAD forwarding for LJ_DUALNUM builds.
    • +
    • Fix buffer check in bytecode writer.
    • +
    • Make os.date() thread-safe.
    • +
    • Add missing declarations for MSVC intrinsics.
    • +
    • Fix dispatch table modifications for return hooks.
    • +
    • Workaround for MSVC conversion bug (doubleuint32_tint32_t).
    • +
    • Fix FOLD rule (i-j)-i => 0-j.
    • +
    • Never use DWARF unwinder on Windows.
    • +
    • Fix shrinking of direct mapped blocks in builtin allocator.
    • +
    • Limit recursion depth in string.match() et al.
    • +
    • Fix late despecialization of ITERN after loop has been entered.
    • +
    • Fix 'f' and 'L' options for debug.getinfo() and lua_getinfo().
    • +
    • Fix package.searchpath().
    • +
    • OSX: Change dylib names to be consistent with other platforms.
    • +
    • Android: Workaround for broken sprintf("%g", -0.0).
    • +
    • x86: Remove support for ancient CPUs without CMOV (before Pentium Pro).
    • +
    • x86: Fix register allocation for calls returning register pair.
    • +
    • x86/x64: Fix fusion of unsigned byte comparisons with swapped operands.
    • +
    • ARM: Fix tonumber() argument check.
    • +
    • ARM: Fix modulo operator and math.floor()/math.ceil() for inf/nan.
    • +
    • ARM: Invoke SPLIT pass for leftover IR_TOBIT.
    • +
    • ARM: Fix BASE register coalescing.
    • +
    • PPC: Fix interpreter state setup in callbacks.
    • +
    • PPC: Fix string.sub() range check.
    • +
    • MIPS: Support generation of MIPS/MIPSEL bytecode object files.
    • +
    • MIPS: Fix calls to floor()/ceil()/trunc().
    • +
    • ARM/PPC: Detect more target architecture variants.
    • +
    • ARM/PPC/e500/MIPS: Fix tailcalls from fast functions, esp. tostring().
    • +
    • ARM/PPC/MIPS: Fix rematerialization of FP constants.
    • +
    • FFI: Don't call FreeLibrary() on our own EXE/DLL.
    • +
    • FFI: Resolve metamethods for constructors, too.
    • +
    • FFI: Properly disable callbacks on iOS (would require executable memory).
    • +
    • FFI: Fix cdecl string parsing during recording.
    • +
    • FFI: Show address pointed to for tostring(ref), too.
    • +
    • FFI: Fix alignment of C call argument/return structure.
    • +
    • FFI: Initialize all fields of standard types.
    • +
    • FFI: Fix callback handling when new C types are declared in callback.
    • +
    • FFI: Fix recording of constructors for pointers.
    • +
    • FFI: Always resolve metamethods for pointers to structs.
    • +
    • FFI: Correctly propagate alignment when interning nested types.
    • +
  • +
  • Structural and performance enhancements: +
      +
    • Add allocation sinking and store sinking optimization.
    • +
    • Constify immutable upvalues.
    • +
    • Add builtin string to integer or FP number conversion. Improves cross-platform consistency and correctness.
    • +
    • Create string hash slots in template tables for non-const values, too. Avoids later table resizes.
    • +
    • Eliminate HREFK guard for template table references.
    • +
    • Add various new FOLD rules.
    • +
    • Don't use stack unwinding for lua_yield() (slow on x64).
    • +
    • ARM, PPC, MIPS: Improve XLOAD operand fusion and register hinting.
    • +
    • PPC, MIPS: Compile math.sqrt() to sqrt instruction, if available.
    • +
    • FFI: Fold KPTR + constant offset in SPLIT pass.
    • +
    • FFI: Optimize/inline ffi.copy() and ffi.fill().
    • +
    • FFI: Compile and optimize array/struct copies.
    • +
    • FFI: Compile ffi.typeof(cdata|ctype), ffi.sizeof(), ffi.alignof(), ffi.offsetof() and ffi.gc().
    • +
  • +
+ +

LuaJIT 2.0.0-beta10 — 2012-05-09

+
    +
  • New features: +
      +
    • The MIPS of LuaJIT is complete. It requires a CPU conforming to the +MIPS32 R1 architecture with hardware FPU. O32 hard-fp ABI, +little-endian or big-endian.
    • +
    • Auto-detect target arch via cross-compiler. No need for +TARGET=arch anymore.
    • +
    • Make DynASM compatible with Lua 5.2.
    • +
    • From Lua 5.2: Try __tostring metamethod on non-string error +messages..
    • +
  • +
  • Correctness and completeness: +
      +
    • Fix parsing of hex literals with exponents.
    • +
    • Fix bytecode dump for certain number constants.
    • +
    • Fix argument type in error message for relative arguments.
    • +
    • Fix argument error handling on Lua stacks without a frame.
    • +
    • Add missing mcode limit check in assembler backend.
    • +
    • Fix compilation on OpenBSD.
    • +
    • Avoid recursive GC steps after GC-triggered trace exit.
    • +
    • Replace <unwind.h> definitions with our own.
    • +
    • Fix OSX build issues. Bump minimum required OSX version to 10.4.
    • +
    • Fix discharge order of comparisons in Lua parser.
    • +
    • Ensure running __gc of userdata created in __gc +at state close.
    • +
    • Limit number of userdata __gc separations at state close.
    • +
    • Fix bytecode JMP slot range when optimizing +and/or with constant LHS.
    • +
    • Fix DSE of USTORE.
    • +
    • Make lua_concat() work from C hook with partial frame.
    • +
    • Add required PHIs for implicit conversions, e.g. via XREF +forwarding.
    • +
    • Add more comparison variants to Valgrind suppressions file.
    • +
    • Disable loading bytecode with an extra header (BOM or #!).
    • +
    • Fix PHI stack slot syncing.
    • +
    • ARM: Reorder type/value tests to silence Valgrind.
    • +
    • ARM: Fix register allocation for ldrd-optimized +HREFK.
    • +
    • ARM: Fix conditional branch fixup for OBAR.
    • +
    • ARM: Invoke SPLIT pass for double args in FFI call.
    • +
    • ARM: Handle all CALL* ops with double results in +SPLIT pass.
    • +
    • ARM: Fix rejoin of POW in SPLIT pass.
    • +
    • ARM: Fix compilation of math.sinh, math.cosh, +math.tanh.
    • +
    • ARM, PPC: Avoid pointless arg clearing in BC_IFUNCF.
    • +
    • PPC: Fix resume after yield from hook.
    • +
    • PPC: Fix argument checking for rawget().
    • +
    • PPC: Fix fusion of floating-point XLOAD/XSTORE.
    • +
    • PPC: Fix HREFK code generation for huge tables.
    • +
    • PPC: Use builtin D-Cache/I-Cache sync code.
    • +
  • +
  • FFI library: +
      +
    • Ignore empty statements in ffi.cdef().
    • +
    • Ignore number parsing errors while skipping definitions.
    • +
    • Don't touch frame in callbacks with tailcalls to fast functions.
    • +
    • Fix library unloading on POSIX systems.
    • +
    • Finalize cdata before userdata when closing the state.
    • +
    • Change ffi.load() library name resolution for Cygwin.
    • +
    • Fix resolving of function name redirects on Windows/x86.
    • +
    • Fix symbol resolving error messages on Windows.
    • +
    • Fix blacklisting of C functions calling callbacks.
    • +
    • Fix result type of pointer difference.
    • +
    • Use correct PC in FFI metamethod error message.
    • +
    • Allow 'typedef _Bool int BOOL;' for the Windows API.
    • +
    • Don't record test for bool result of call, if ignored.
    • +
  • +
+ +

LuaJIT 2.0.0-beta9 — 2011-12-14

+
    +
  • New features: +
      +
    • PPC port of LuaJIT is complete. Default is the dual-number port +(usually faster). Single-number port selectable via src/Makefile +at build time.
    • +
    • Add FFI callback support.
    • +
    • Extend -b to generate .c, .h or .obj/.o +files with embedded bytecode.
    • +
    • Allow loading embedded bytecode with require().
    • +
    • From Lua 5.2: Change to '\z' escape. Reject undefined escape +sequences.
    • +
  • +
  • Correctness and completeness: +
      +
    • Fix OSX 10.7 build. Fix install_name and versioning on OSX.
    • +
    • Fix iOS build.
    • +
    • Install dis_arm.lua, too.
    • +
    • Mark installed shared library as executable.
    • +
    • Add debug option to msvcbuild.bat and improve error handling.
    • +
    • Fix data-flow analysis for iterators.
    • +
    • Fix forced unwinding triggered by external unwinder.
    • +
    • Record missing for loop slot loads (return to lower frame).
    • +
    • Always use ANSI variants of Windows system functions.
    • +
    • Fix GC barrier for multi-result table constructor (TSETM).
    • +
    • Fix/add various FOLD rules.
    • +
    • Add potential PHI for number conversions due to type instability.
    • +
    • Do not eliminate PHIs only referenced from other PHIs.
    • +
    • Correctly anchor implicit number to string conversions in Lua/C API.
    • +
    • Fix various stack limit checks.
    • +
    • x64: Use thread-safe exceptions for external unwinding (GCC platforms).
    • +
    • x64: Fix result type of cdata index conversions.
    • +
    • x64: Fix math.random() and bit.bswap() code generation.
    • +
    • x64: Fix lightuserdata comparisons.
    • +
    • x64: Always extend stack-passed arguments to pointer size.
    • +
    • ARM: Many fixes to code generation backend.
    • +
    • PPC/e500: Fix dispatch for binop metamethods.
    • +
    • PPC/e500: Save/restore condition registers when entering/leaving the VM.
    • +
    • PPC/e500: Fix write barrier in stores of strings to upvalues.
    • +
  • +
  • FFI library: +
      +
    • Fix C comment parsing.
    • +
    • Fix snapshot optimization for cdata comparisons.
    • +
    • Fix recording of const/enum lookups in namespaces.
    • +
    • Fix call argument and return handling for I8/U8/I16/U16 types.
    • +
    • Fix unfused loads of float fields.
    • +
    • Fix ffi.string() recording.
    • +
    • Save GetLastError() around ffi.load() and symbol +resolving, too.
    • +
    • Improve ld script detection in ffi.load().
    • +
    • Record loads/stores to external variables in namespaces.
    • +
    • Compile calls to stdcall, fastcall and vararg functions.
    • +
    • Treat function ctypes like pointers in comparisons.
    • +
    • Resolve __call metamethod for pointers, too.
    • +
    • Record C function calls with bool return values.
    • +
    • Record ffi.errno().
    • +
    • x86: Fix number to uint32_t conversion rounding.
    • +
    • x86: Fix 64 bit arithmetic in assembler backend.
    • +
    • x64: Fix struct-by-value calling conventions.
    • +
    • ARM: Ensure invocation of SPLIT pass for float conversions.
    • +
  • +
  • Structural and performance enhancements: +
      +
    • Display trace types with -jv and -jdump.
    • +
    • Record isolated calls. But prefer recording loops over calls.
    • +
    • Specialize to prototype for non-monomorphic functions. Solves the +trace-explosion problem for closure-heavy programming styles.
    • +
    • Always generate a portable vmdef.lua. Easier for distros.
    • +
  • +
+ +

LuaJIT 2.0.0-beta8 — 2011-06-23

+
    +
  • New features: +
      +
    • Soft-float ARM port of LuaJIT is complete.
    • +
    • Add support for bytecode loading/saving and -b command line +option.
    • +
    • From Lua 5.2: __len metamethod for tables +(disabled by default).
    • +
  • +
  • Correctness and completeness: +
      +
    • ARM: Misc. fixes for interpreter.
    • +
    • x86/x64: Fix bit.* argument checking in interpreter.
    • +
    • Catch early out-of-memory in memory allocator initialization.
    • +
    • Fix data-flow analysis for paths leading to an upvalue close.
    • +
    • Fix check for missing arguments in string.format().
    • +
    • Fix Solaris/x86 build (note: not a supported target).
    • +
    • Fix recording of loops with instable directions in side traces.
    • +
    • x86/x64: Fix fusion of comparisons with u8/u16 +XLOAD.
    • +
    • x86/x64: Fix register allocation for variable shifts.
    • +
  • +
  • FFI library: +
      +
    • Add ffi.errno(). Save errno/GetLastError() +around allocations etc.
    • +
    • Fix __gc for VLA/VLS cdata objects.
    • +
    • Fix recording of casts from 32 bit cdata pointers to integers.
    • +
    • tonumber(cdata) returns nil for non-numbers.
    • +
    • Show address pointed to for tostring(pointer).
    • +
    • Print NULL pointers as "cdata<... *>: NULL".
    • +
    • Support __tostring metamethod for pointers to structs, too.
    • +
  • +
  • Structural and performance enhancements: +
      +
    • More tuning for loop unrolling heuristics.
    • +
    • Flatten and compress in-memory debug info (saves ~70%).
    • +
  • +
+ +

LuaJIT 2.0.0-beta7 — 2011-05-05

+
    +
  • New features: +
      +
    • ARM port of the LuaJIT interpreter is complete.
    • +
    • FFI library: Add ffi.gc(), ffi.metatype(), +ffi.istype().
    • +
    • FFI library: Resolve ld script redirection in ffi.load().
    • +
    • From Lua 5.2: package.searchpath(), fp:read("*L"), +load(string).
    • +
    • From Lua 5.2, disabled by default: empty statement, +table.unpack(), modified coroutine.running().
    • +
  • +
  • Correctness and completeness: +
      +
    • FFI library: numerous fixes.
    • +
    • Fix type mismatches in store-to-load forwarding.
    • +
    • Fix error handling within metamethods.
    • +
    • Fix table.maxn().
    • +
    • Improve accuracy of x^-k on x64.
    • +
    • Fix code generation for Intel Atom in x64 mode.
    • +
    • Fix narrowing of POW.
    • +
    • Fix recording of retried fast functions.
    • +
    • Fix code generation for bit.bnot() and multiplies.
    • +
    • Fix error location within cpcall frames.
    • +
    • Add workaround for old libgcc unwind bug.
    • +
    • Fix lua_yield() and getmetatable(lightuserdata) on x64.
    • +
    • Misc. fixes for PPC/e500 interpreter.
    • +
    • Fix stack slot updates for down-recursion.
    • +
  • +
  • Structural and performance enhancements: +
      +
    • Add dual-number mode (int/double) for the VM. Enabled for ARM.
    • +
    • Improve narrowing of arithmetic operators and for loops.
    • +
    • Tune loop unrolling heuristics and increase trace recorder limits.
    • +
    • Eliminate dead slots in snapshots using bytecode data-flow analysis.
    • +
    • Avoid phantom stores to proxy tables.
    • +
    • Optimize lookups in empty proxy tables.
    • +
    • Improve bytecode optimization of and/or operators.
    • +
  • +
+ +

LuaJIT 2.0.0-beta6 — 2011-02-11

+
    +
  • New features: +
      +
    • PowerPC/e500v2 port of the LuaJIT interpreter is complete.
    • +
    • Various minor features from Lua 5.2: Hex escapes in literals, +'\*' escape, reversible string.format("%q",s), +"%g" pattern, table.sort checks callbacks, +os.exit(status|true|false[,close]).
    • +
    • Lua 5.2 __pairs and __ipairs metamethods +(disabled by default).
    • +
    • Initial release of the FFI library.
    • +
  • +
  • Correctness and completeness: +
      +
    • Fix string.format() for non-finite numbers.
    • +
    • Fix memory leak when compiled to use the built-in allocator.
    • +
    • x86/x64: Fix unnecessary resize in TSETM bytecode.
    • +
    • Fix various GC issues with traces and jit.flush().
    • +
    • x64: Fix fusion of indexes for array references.
    • +
    • x86/x64: Fix stack overflow handling for coroutine results.
    • +
    • Enable low-2GB memory allocation on FreeBSD/x64.
    • +
    • Fix collectgarbage("count") result if more than 2GB is in use.
    • +
    • Fix parsing of hex floats.
    • +
    • x86/x64: Fix loop branch inversion with trailing +HREF+NE/EQ.
    • +
    • Add jit.os string.
    • +
    • coroutine.create() permits running C functions, too.
    • +
    • Fix OSX build to work with newer ld64 versions.
    • +
    • Fix bytecode optimization of and/or operators.
    • +
  • +
  • Structural and performance enhancements: +
      +
    • Emit specialized bytecode for pairs()/next().
    • +
    • Improve bytecode coalescing of nil constants.
    • +
    • Compile calls to vararg functions.
    • +
    • Compile select().
    • +
    • Improve alias analysis, esp. for loads from allocations.
    • +
    • Tuning of various compiler heuristics.
    • +
    • Refactor and extend IR conversion instructions.
    • +
    • x86/x64: Various backend enhancements related to the FFI.
    • +
    • Add SPLIT pass to split 64 bit IR instructions for 32 bit CPUs.
    • +
  • +
+ +

LuaJIT 2.0.0-beta5 — 2010-08-24

+
    +
  • Correctness and completeness: +
      +
    • Fix trace exit dispatch to function headers.
    • +
    • Fix Windows and OSX builds with LUAJIT_DISABLE_JIT.
    • +
    • Reorganize and fix placement of generated machine code on x64.
    • +
    • Fix TNEW in x64 interpreter.
    • +
    • Do not eliminate PHIs for values only referenced from side exits.
    • +
    • OS-independent canonicalization of strings for non-finite numbers.
    • +
    • Fix string.char() range check on x64.
    • +
    • Fix tostring() resolving within print().
    • +
    • Fix error handling for next().
    • +
    • Fix passing of constant arguments to external calls on x64.
    • +
    • Fix interpreter argument check for two-argument SSE math functions.
    • +
    • Fix C frame chain corruption caused by lua_cpcall().
    • +
    • Fix return from pcall() within active hook.
    • +
  • +
  • Structural and performance enhancements: +
      +
    • Replace on-trace GC frame syncing with interpreter exit.
    • +
    • Improve hash lookup specialization by not removing dead keys during GC.
    • +
    • Turn traces into true GC objects.
    • +
    • Avoid starting a GC cycle immediately after library init.
    • +
    • Add weak guards to improve dead-code elimination.
    • +
    • Speed up string interning.
    • +
  • +
+ +

LuaJIT 2.0.0-beta4 — 2010-03-28

+
    +
  • Correctness and completeness: +
      +
    • Fix precondition for on-trace creation of table keys.
    • +
    • Fix {f()} on x64 when table is resized.
    • +
    • Fix folding of ordered comparisons with same references.
    • +
    • Fix snapshot restores for multi-result bytecodes.
    • +
    • Fix potential hang when recording bytecode with nested closures.
    • +
    • Fix recording of getmetatable(), tonumber() and bad argument types.
    • +
    • Fix SLOAD fusion across returns to lower frames.
    • +
  • +
  • Structural and performance enhancements: +
      +
    • Add array bounds check elimination. -Oabc is enabled by default.
    • +
    • More tuning for x64, e.g. smaller table objects.
    • +
  • +
+ +

LuaJIT 2.0.0-beta3 — 2010-03-07

+
    +
  • LuaJIT x64 port: +
      +
    • Port integrated memory allocator to Linux/x64, Windows/x64 and OSX/x64.
    • +
    • Port interpreter and JIT compiler to x64.
    • +
    • Port DynASM to x64.
    • +
    • Many 32/64 bit cleanups in the VM.
    • +
    • Allow building the interpreter with either x87 or SSE2 arithmetics.
    • +
    • Add external unwinding and C++ exception interop (default on x64).
    • +
  • +
  • Correctness and completeness: +
      +
    • Fix constructor bytecode generation for certain conditional values.
    • +
    • Fix some cases of ordered string comparisons.
    • +
    • Fix lua_tocfunction().
    • +
    • Fix cutoff register in JMP bytecode for some conditional expressions.
    • +
    • Fix PHI marking algorithm for references from variant slots.
    • +
    • Fix package.cpath for non-default PREFIX.
    • +
    • Fix DWARF2 frame unwind information for interpreter on OSX.
    • +
    • Drive the GC forward on string allocations in the parser.
    • +
    • Implement call/return hooks (zero-cost if disabled).
    • +
    • Implement yield from C hooks.
    • +
    • Disable JIT compiler on older non-SSE2 CPUs instead of aborting.
    • +
  • +
  • Structural and performance enhancements: +
      +
    • Compile recursive code (tail-, up- and down-recursion).
    • +
    • Improve heuristics for bytecode penalties and blacklisting.
    • +
    • Split CALL/FUNC recording and clean up fast function call semantics.
    • +
    • Major redesign of internal function call handling.
    • +
    • Improve FOR loop const specialization and integerness checks.
    • +
    • Switch to pre-initialized stacks. Avoid frame-clearing.
    • +
    • Colocation of prototypes and related data: bytecode, constants, debug info.
    • +
    • Cleanup parser and streamline bytecode generation.
    • +
    • Add support for weak IR references to register allocator.
    • +
    • Switch to compressed, extensible snapshots.
    • +
    • Compile returns to frames below the start frame.
    • +
    • Improve alias analysis of upvalues using a disambiguation hash value.
    • +
    • Compile floor/ceil/trunc to SSE2 helper calls or SSE4.1 instructions.
    • +
    • Add generic C call handling to IR and backend.
    • +
    • Improve KNUM fuse vs. load heuristics.
    • +
    • Compile various io.*() functions.
    • +
    • Compile math.sinh(), math.cosh(), math.tanh() +and math.random().
    • +
  • +
+ +

LuaJIT 2.0.0-beta2 — 2009-11-09

+
    +
  • Reorganize build system. Build static+shared library on POSIX.
  • +
  • Allow C++ exception conversion on all platforms +using a wrapper function.
  • +
  • Automatically catch C++ exceptions and rethrow Lua error +(DWARF2 only).
  • +
  • Check for the correct x87 FPU precision at strategic points.
  • +
  • Always use wrappers for libm functions.
  • +
  • Resurrect metamethod name strings before copying them.
  • +
  • Mark current trace, even if compiler is idle.
  • +
  • Ensure FILE metatable is created only once.
  • +
  • Fix type comparisons when different integer types are involved.
  • +
  • Fix getmetatable() recording.
  • +
  • Fix TDUP with dead keys in template table.
  • +
  • jit.flush(tr) returns status. +Prevent manual flush of a trace that's still linked.
  • +
  • Improve register allocation heuristics for invariant references.
  • +
  • Compile the push/pop variants of table.insert() and +table.remove().
  • +
  • Compatibility with MSVC link /debug.
  • +
  • Fix lua_iscfunction().
  • +
  • Fix math.random() when compiled with -fpic (OSX).
  • +
  • Fix table.maxn().
  • +
  • Bump MACOSX_DEPLOYMENT_TARGET to 10.4
  • +
  • luaL_check*() and luaL_opt*() now support +negative arguments, too.
    +This matches the behavior of Lua 5.1, but not the specification.
  • +
+ +

LuaJIT 2.0.0-beta1 — 2009-10-31

+
    +
  • This is the first public release of LuaJIT 2.0.
  • +
  • The whole VM has been rewritten from the ground up, so there's +no point in listing differences over earlier versions.
  • +
+
+ +
+

LuaJIT 1.1.8 — 2012-04-16

+ + +

LuaJIT 1.1.7 — 2011-05-05

+ + +

LuaJIT 1.1.6 — 2010-03-28

+
    +
  • Added fixes for the +» currently known bugs in Lua 5.1.4.
  • +
  • Removed wrong GC check in jit_createstate(). +Thanks to Tim Mensch.
  • +
  • Fixed bad assertions while compiling table.insert() and +table.remove().
  • +
+ +

LuaJIT 1.1.5 — 2008-10-25

+ + +

LuaJIT 1.1.4 — 2008-02-05

+
    +
  • Merged with Lua 5.1.3. Fixes all +» known bugs in Lua 5.1.2.
  • +
  • Fixed possible (but unlikely) stack corruption while compiling +k^x expressions.
  • +
  • Fixed DynASM template for cmpss instruction.
  • +
+ +

LuaJIT 1.1.3 — 2007-05-24

+
    +
  • Merged with Lua 5.1.2. Fixes all +» known bugs in Lua 5.1.1.
  • +
  • Merged pending Lua 5.1.x fixes: "return -nil" bug, spurious count hook call.
  • +
  • Remove a (sometimes) wrong assertion in luaJIT_findpc().
  • +
  • DynASM now allows labels for displacements and .aword.
  • +
  • Fix some compiler warnings for DynASM glue (internal API change).
  • +
  • Correct naming for SSSE3 (temporarily known as SSE4) in DynASM and x86 disassembler.
  • +
  • The loadable debug modules now handle redirection to stdout +(e.g. -j trace=-).
  • +
+ +

LuaJIT 1.1.2 — 2006-06-24

+
    +
  • Fix MSVC inline assembly: use only local variables with +lua_number2int().
  • +
  • Fix "attempt to call a thread value" bug on Mac OS X: +make values of consts used as lightuserdata keys unique +to avoid joining by the compiler/linker.
  • +
+ +

LuaJIT 1.1.1 — 2006-06-20

+
    +
  • Merged with Lua 5.1.1. Fixes all +» known bugs in Lua 5.1.
  • +
  • Enforce (dynamic) linker error for EXE/DLL version mismatches.
  • +
  • Minor changes to DynASM: faster pre-processing, smaller encoding +for some immediates.
  • +
+

+This release is in sync with Coco 1.1.1 (see the +» Coco Change History). +

+ +

LuaJIT 1.1.0 — 2006-03-13

+
    +
  • Merged with Lua 5.1 (final).
  • + +
  • New JIT call frame setup: +
      +
    • The C stack is kept 16 byte aligned (faster). +Mandatory for Mac OS X on Intel, too.
    • +
    • Faster calling conventions for internal C helper functions.
    • +
    • Better instruction scheduling for function prologue, OP_CALL and +OP_RETURN.
    • +
  • + +
  • Miscellaneous optimizations: +
      +
    • Faster loads of FP constants. Remove narrow-to-wide store-to-load +forwarding stalls.
    • +
    • Use (scalar) SSE2 ops (if the CPU supports it) to speed up slot moves +and FP to integer conversions.
    • +
    • Optimized the two-argument form of OP_CONCAT (a..b).
    • +
    • Inlined OP_MOD (a%b). +With better accuracy than the C variant, too.
    • +
    • Inlined OP_POW (a^b). Unroll x^k or +use k^x = 2^(log2(k)*x) or call pow().
    • +
  • + +
  • Changes in the optimizer: +
      +
    • Improved hinting for table keys derived from table values +(t1[t2[x]]).
    • +
    • Lookup hinting now works with arbitrary object types and +supports index chains, too.
    • +
    • Generate type hints for arithmetic and comparison operators, +OP_LEN, OP_CONCAT and OP_FORPREP.
    • +
    • Remove several hint definitions in favour of a generic COMBINE hint.
    • +
    • Complete rewrite of jit.opt_inline module +(ex jit.opt_lib).
    • +
  • + +
  • Use adaptive deoptimization: +
      +
    • If runtime verification of a contract fails, the affected +instruction is recompiled and patched on-the-fly. +Regular programs will trigger deoptimization only occasionally.
    • +
    • This avoids generating code for uncommon fallback cases +most of the time. Generated code is up to 30% smaller compared to +LuaJIT 1.0.3.
    • +
    • Deoptimization is used for many opcodes and contracts: +
        +
      • OP_CALL, OP_TAILCALL: type mismatch for callable.
      • +
      • Inlined calls: closure mismatch, parameter number and type mismatches.
      • +
      • OP_GETTABLE, OP_SETTABLE: table or key type and range mismatches.
      • +
      • All arithmetic and comparison operators, OP_LEN, OP_CONCAT, +OP_FORPREP: operand type and range mismatches.
      • +
    • +
    • Complete redesign of the debug and traceback info +(bytecode ↔ mcode) to support deoptimization. +Much more flexible and needs only 50% of the space.
    • +
    • The modules jit.trace, jit.dumphints and +jit.dump handle deoptimization.
    • +
  • + +
  • Inlined many popular library functions +(for commonly used arguments only): +
      +
    • Most math.* functions (the 18 most used ones) +[2x-10x faster].
    • +
    • string.len, string.sub and string.char +[2x-10x faster].
    • +
    • table.insert, table.remove and table.getn +[3x-5x faster].
    • +
    • coroutine.yield and coroutine.resume +[3x-5x faster].
    • +
    • pairs, ipairs and the corresponding iterators +[8x-15x faster].
    • +
  • + +
  • Changes in the core and loadable modules and the stand-alone executable: +
      +
    • Added jit.version, jit.version_num +and jit.arch.
    • +
    • Reorganized some internal API functions (jit.util.*mcode*).
    • +
    • The -j dump output now shows JSUB names, too.
    • +
    • New x86 disassembler module written in pure Lua. No dependency +on ndisasm anymore. Flexible API, very compact (500 lines) +and complete (x87, MMX, SSE, SSE2, SSE3, SSSE3, privileged instructions).
    • +
    • luajit -v prints the LuaJIT version and copyright +on a separate line.
    • +
  • + +
  • Added SSE, SSE2, SSE3 and SSSE3 support to DynASM.
  • +
  • Miscellaneous doc changes. Added a section about +embedding LuaJIT.
  • +
+

+This release is in sync with Coco 1.1.0 (see the +» Coco Change History). +

+
+ +
+

LuaJIT 1.0.3 — 2005-09-08

+
    +
  • Even more docs.
  • +
  • Unified closure checks in jit.*.
  • +
  • Fixed some range checks in jit.util.*.
  • +
  • Fixed __newindex call originating from jit_settable_str().
  • +
  • Merged with Lua 5.1 alpha (including early bug fixes).
  • +
+

+This is the first public release of LuaJIT. +

+ +

LuaJIT 1.0.2 — 2005-09-02

+
    +
  • Add support for flushing the Valgrind translation cache
    +(MYCFLAGS= -DUSE_VALGRIND).
  • +
  • Add support for freeing executable mcode memory to the mmap()-based +variant for POSIX systems.
  • +
  • Reorganized the C function signature handling in +jit.opt_lib.
  • +
  • Changed to index-based hints for inlining C functions. +Still no support in the backend for inlining.
  • +
  • Hardcode HEAP_CREATE_ENABLE_EXECUTE value if undefined.
  • +
  • Misc. changes to the jit.* modules.
  • +
  • Misc. changes to the Makefiles.
  • +
  • Lots of new docs.
  • +
  • Complete doc reorg.
  • +
+

+Not released because Lua 5.1 alpha came out today. +

+ +

LuaJIT 1.0.1 — 2005-08-31

+
    +
  • Missing GC step in OP_CONCAT.
  • +
  • Fix result handling for C –> JIT calls.
  • +
  • Detect CPU feature bits.
  • +
  • Encode conditional moves (fucomip) only when supported.
  • +
  • Add fallback instructions for FP compares.
  • +
  • Add support for LUA_COMPAT_VARARG. Still disabled by default.
  • +
  • MSVC needs a specific place for the CALLBACK attribute +(David Burgess).
  • +
  • Misc. doc updates.
  • +
+

+Interim non-public release. +Special thanks to Adam D. Moss for reporting most of the bugs. +

+ +

LuaJIT 1.0.0 — 2005-08-29

+

+This is the initial non-public release of LuaJIT. +

+
+
+
+ + + diff --git a/source/libs/luajit/LuaJIT-2.0.4/doc/contact.html b/source/libs/luajit/LuaJIT-2.0.4/doc/contact.html new file mode 100644 index 000000000..0ef01a7c1 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/doc/contact.html @@ -0,0 +1,102 @@ + + + +Contact + + + + + + + + +
+Lua +
+ + +
+

+Please send general questions to the +» LuaJIT mailing list. +You can also send any questions you have directly to me: +

+ + + + + +

Copyright

+

+All documentation is +Copyright © 2005-2015 Mike Pall. +

+ + +
+
+ + + diff --git a/source/libs/luajit/LuaJIT-2.0.4/doc/ext_c_api.html b/source/libs/luajit/LuaJIT-2.0.4/doc/ext_c_api.html new file mode 100644 index 000000000..65981806d --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/doc/ext_c_api.html @@ -0,0 +1,187 @@ + + + +Lua/C API Extensions + + + + + + + + +
+Lua +
+ + +
+

+LuaJIT adds some extensions to the standard Lua/C API. The LuaJIT include +directory must be in the compiler search path (-Ipath) +to be able to include the required header for C code: +

+
+#include "luajit.h"
+
+

+Or for C++ code: +

+
+#include "lua.hpp"
+
+ +

luaJIT_setmode(L, idx, mode) +— Control VM

+

+This is a C API extension to allow control of the VM from C code. The +full prototype of LuaJIT_setmode is: +

+
+LUA_API int luaJIT_setmode(lua_State *L, int idx, int mode);
+
+

+The returned status is either success (1) or failure (0). +The second argument is either 0 or a stack index (similar to the +other Lua/C API functions). +

+

+The third argument specifies the mode, which is 'or'ed with a flag. +The flag can be LUAJIT_MODE_OFF to turn a feature on, +LUAJIT_MODE_ON to turn a feature off, or +LUAJIT_MODE_FLUSH to flush cached code. +

+

+The following modes are defined: +

+ +

luaJIT_setmode(L, 0, LUAJIT_MODE_ENGINE|flag)

+

+Turn the whole JIT compiler on or off or flush the whole cache of compiled code. +

+ +

luaJIT_setmode(L, idx, LUAJIT_MODE_FUNC|flag)
+luaJIT_setmode(L, idx, LUAJIT_MODE_ALLFUNC|flag)
+luaJIT_setmode(L, idx, LUAJIT_MODE_ALLSUBFUNC|flag)

+

+This sets the mode for the function at the stack index idx or +the parent of the calling function (idx = 0). It either +enables JIT compilation for a function, disables it and flushes any +already compiled code or only flushes already compiled code. This +applies recursively to all sub-functions of the function with +LUAJIT_MODE_ALLFUNC or only to the sub-functions with +LUAJIT_MODE_ALLSUBFUNC. +

+ +

luaJIT_setmode(L, trace,
+  LUAJIT_MODE_TRACE|LUAJIT_MODE_FLUSH)

+

+Flushes the specified root trace and all of its side traces from the cache. +The code for the trace will be retained as long as there are any other +traces which link to it. +

+ +

luaJIT_setmode(L, idx, LUAJIT_MODE_WRAPCFUNC|flag)

+

+This mode defines a wrapper function for calls to C functions. If +called with LUAJIT_MODE_ON, the stack index at idx +must be a lightuserdata object holding a pointer to the wrapper +function. From now on all C functions are called through the wrapper +function. If called with LUAJIT_MODE_OFF this mode is turned +off and all C functions are directly called. +

+

+The wrapper function can be used for debugging purposes or to catch +and convert foreign exceptions. But please read the section on +C++ exception interoperability +first. Recommended usage can be seen in this C++ code excerpt: +

+
+#include <exception>
+#include "lua.hpp"
+
+// Catch C++ exceptions and convert them to Lua error messages.
+// Customize as needed for your own exception classes.
+static int wrap_exceptions(lua_State *L, lua_CFunction f)
+{
+  try {
+    return f(L);  // Call wrapped function and return result.
+  } catch (const char *s) {  // Catch and convert exceptions.
+    lua_pushstring(L, s);
+  } catch (std::exception& e) {
+    lua_pushstring(L, e.what());
+  } catch (...) {
+    lua_pushliteral(L, "caught (...)");
+  }
+  return lua_error(L);  // Rethrow as a Lua error.
+}
+
+static int myinit(lua_State *L)
+{
+  ...
+  // Define wrapper function and enable it.
+  lua_pushlightuserdata(L, (void *)wrap_exceptions);
+  luaJIT_setmode(L, -1, LUAJIT_MODE_WRAPCFUNC|LUAJIT_MODE_ON);
+  lua_pop(L, 1);
+  ...
+}
+
+

+Note that you can only define a single global wrapper function, +so be careful when using this mechanism from multiple C++ modules. +Also note that this mechanism is not without overhead. +

+
+
+ + + diff --git a/source/libs/luajit/LuaJIT-2.0.4/doc/ext_ffi.html b/source/libs/luajit/LuaJIT-2.0.4/doc/ext_ffi.html new file mode 100644 index 000000000..77b8e26c5 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/doc/ext_ffi.html @@ -0,0 +1,330 @@ + + + +FFI Library + + + + + + + + +
+Lua +
+ + +
+

+ +The FFI library allows calling external C functions and +using C data structures from pure Lua code. + +

+

+ +The FFI library largely obviates the need to write tedious manual +Lua/C bindings in C. No need to learn a separate binding language +— it parses plain C declarations! These can be +cut-n-pasted from C header files or reference manuals. It's up to +the task of binding large libraries without the need for dealing with +fragile binding generators. + +

+

+The FFI library is tightly integrated into LuaJIT (it's not available +as a separate module). The code generated by the JIT-compiler for +accesses to C data structures from Lua code is on par with the +code a C compiler would generate. Calls to C functions can +be inlined in JIT-compiled code, unlike calls to functions bound via +the classic Lua/C API. +

+

+This page gives a short introduction to the usage of the FFI library. +Please use the FFI sub-topics in the navigation bar to learn more. +

+ +

Motivating Example: Calling External C Functions

+

+It's really easy to call an external C library function: +

+
+①
+②
+
+
+③local ffi = require("ffi")
+ffi.cdef[[
+int printf(const char *fmt, ...);
+]]
+ffi.C.printf("Hello %s!", "world")
+
+

+So, let's pick that apart: +

+

+ Load the FFI library. +

+

+ Add a C declaration +for the function. The part inside the double-brackets (in green) is +just standard C syntax. +

+

+ Call the named +C function — Yes, it's that simple! +

+

+Actually, what goes on behind the scenes is far from simple: makes use of the standard +C library namespace ffi.C. Indexing this namespace with +a symbol name ("printf") automatically binds it to the +standard C library. The result is a special kind of object which, +when called, runs the printf function. The arguments passed +to this function are automatically converted from Lua objects to the +corresponding C types. +

+

+Ok, so maybe the use of printf() wasn't such a spectacular +example. You could have done that with io.write() and +string.format(), too. But you get the idea ... +

+

+So here's something to pop up a message box on Windows: +

+
+local ffi = require("ffi")
+ffi.cdef[[
+int MessageBoxA(void *w, const char *txt, const char *cap, int type);
+]]
+ffi.C.MessageBoxA(nil, "Hello world!", "Test", 0)
+
+

+Bing! Again, that was far too easy, no? +

+

+Compare this with the effort required to bind that function using the +classic Lua/C API: create an extra C file, add a C function +that retrieves and checks the argument types passed from Lua and calls +the actual C function, add a list of module functions and their +names, add a luaopen_* function and register all module +functions, compile and link it into a shared library (DLL), move it to +the proper path, add Lua code that loads the module aaaand ... finally +call the binding function. Phew! +

+ +

Motivating Example: Using C Data Structures

+

+The FFI library allows you to create and access C data +structures. Of course the main use for this is for interfacing with +C functions. But they can be used stand-alone, too. +

+

+Lua is built upon high-level data types. They are flexible, extensible +and dynamic. That's why we all love Lua so much. Alas, this can be +inefficient for certain tasks, where you'd really want a low-level +data type. E.g. a large array of a fixed structure needs to be +implemented with a big table holding lots of tiny tables. This imposes +both a substantial memory overhead as well as a performance overhead. +

+

+Here's a sketch of a library that operates on color images plus a +simple benchmark. First, the plain Lua version: +

+
+local floor = math.floor
+
+local function image_ramp_green(n)
+  local img = {}
+  local f = 255/(n-1)
+  for i=1,n do
+    img[i] = { red = 0, green = floor((i-1)*f), blue = 0, alpha = 255 }
+  end
+  return img
+end
+
+local function image_to_grey(img, n)
+  for i=1,n do
+    local y = floor(0.3*img[i].red + 0.59*img[i].green + 0.11*img[i].blue)
+    img[i].red = y; img[i].green = y; img[i].blue = y
+  end
+end
+
+local N = 400*400
+local img = image_ramp_green(N)
+for i=1,1000 do
+  image_to_grey(img, N)
+end
+
+

+This creates a table with 160.000 pixels, each of which is a table +holding four number values in the range of 0-255. First an image with +a green ramp is created (1D for simplicity), then the image is +converted to greyscale 1000 times. Yes, that's silly, but I was in +need of a simple example ... +

+

+And here's the FFI version. The modified parts have been marked in +bold: +

+
+①
+
+
+
+
+
+②
+
+③
+④
+
+
+
+
+
+
+③
+⑤local ffi = require("ffi")
+ffi.cdef[[
+typedef struct { uint8_t red, green, blue, alpha; } rgba_pixel;
+]]
+
+local function image_ramp_green(n)
+  local img = ffi.new("rgba_pixel[?]", n)
+  local f = 255/(n-1)
+  for i=0,n-1 do
+    img[i].green = i*f
+    img[i].alpha = 255
+  end
+  return img
+end
+
+local function image_to_grey(img, n)
+  for i=0,n-1 do
+    local y = 0.3*img[i].red + 0.59*img[i].green + 0.11*img[i].blue
+    img[i].red = y; img[i].green = y; img[i].blue = y
+  end
+end
+
+local N = 400*400
+local img = image_ramp_green(N)
+for i=1,1000 do
+  image_to_grey(img, N)
+end
+
+

+Ok, so that wasn't too difficult: +

+

+ First, load the FFI +library and declare the low-level data type. Here we choose a +struct which holds four byte fields, one for each component +of a 4x8 bit RGBA pixel. +

+

+ Creating the data +structure with ffi.new() is straightforward — the +'?' is a placeholder for the number of elements of a +variable-length array. +

+

+ C arrays are +zero-based, so the indexes have to run from 0 to +n-1. One might want to allocate one more element instead to +simplify converting legacy code. +

+

+ Since ffi.new() +zero-fills the array by default, we only need to set the green and the +alpha fields. +

+

+ The calls to +math.floor() can be omitted here, because floating-point +numbers are already truncated towards zero when converting them to an +integer. This happens implicitly when the number is stored in the +fields of each pixel. +

+

+Now let's have a look at the impact of the changes: first, memory +consumption for the image is down from 22 Megabytes to +640 Kilobytes (400*400*4 bytes). That's a factor of 35x less! So, +yes, tables do have a noticeable overhead. BTW: The original program +would consume 40 Megabytes in plain Lua (on x64). +

+

+Next, performance: the pure Lua version runs in 9.57 seconds (52.9 +seconds with the Lua interpreter) and the FFI version runs in 0.48 +seconds on my machine (YMMV). That's a factor of 20x faster (110x +faster than the Lua interpreter). +

+

+The avid reader may notice that converting the pure Lua version over +to use array indexes for the colors ([1] instead of +.red, [2] instead of .green etc.) ought to +be more compact and faster. This is certainly true (by a factor of +~1.7x). Switching to a struct-of-arrays would help, too. +

+

+However the resulting code would be less idiomatic and rather +error-prone. And it still doesn't get even close to the performance of +the FFI version of the code. Also, high-level data structures cannot +be easily passed to other C functions, especially I/O functions, +without undue conversion penalties. +

+
+
+ + + diff --git a/source/libs/luajit/LuaJIT-2.0.4/doc/ext_ffi_api.html b/source/libs/luajit/LuaJIT-2.0.4/doc/ext_ffi_api.html new file mode 100644 index 000000000..8f577e9fe --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/doc/ext_ffi_api.html @@ -0,0 +1,566 @@ + + + +ffi.* API Functions + + + + + + + + + +
+Lua +
+ + +
+

+This page describes the API functions provided by the FFI library in +detail. It's recommended to read through the +introduction and the +FFI tutorial first. +

+ +

Glossary

+
    +
  • cdecl — An abstract C type declaration (a Lua +string).
  • +
  • ctype — A C type object. This is a special kind of +cdata returned by ffi.typeof(). It serves as a +cdata constructor when called.
  • +
  • cdata — A C data object. It holds a value of the +corresponding ctype.
  • +
  • ct — A C type specification which can be used for +most of the API functions. Either a cdecl, a ctype or a +cdata serving as a template type.
  • +
  • cb — A callback object. This is a C data object +holding a special function pointer. Calling this function from +C code runs an associated Lua function.
  • +
  • VLA — A variable-length array is declared with a +? instead of the number of elements, e.g. "int[?]". +The number of elements (nelem) must be given when it's +created.
  • +
  • VLS — A variable-length struct is a struct C +type where the last element is a VLA. The same rules for +declaration and creation apply.
  • +
+ +

Declaring and Accessing External Symbols

+

+External symbols must be declared first and can then be accessed by +indexing a C library +namespace, which automatically binds the symbol to a specific +library. +

+ +

ffi.cdef(def)

+

+Adds multiple C declarations for types or external symbols (named +variables or functions). def must be a Lua string. It's +recommended to use the syntactic sugar for string arguments as +follows: +

+
+ffi.cdef[[
+typedef struct foo { int a, b; } foo_t;  // Declare a struct and typedef.
+int dofoo(foo_t *f, int n);  /* Declare an external C function. */
+]]
+
+

+The contents of the string (the part in green above) must be a +sequence of +C declarations, +separated by semicolons. The trailing semicolon for a single +declaration may be omitted. +

+

+Please note that external symbols are only declared, but they +are not bound to any specific address, yet. Binding is +achieved with C library namespaces (see below). +

+

+C declarations are not passed through a C pre-processor, +yet. No pre-processor tokens are allowed, except for +#pragma pack. Replace #define in existing +C header files with enum, static const +or typedef and/or pass the files through an external +C pre-processor (once). Be careful not to include unneeded or +redundant declarations from unrelated header files. +

+ +

ffi.C

+

+This is the default C library namespace — note the +uppercase 'C'. It binds to the default set of symbols or +libraries on the target system. These are more or less the same as a +C compiler would offer by default, without specifying extra link +libraries. +

+

+On POSIX systems, this binds to symbols in the default or global +namespace. This includes all exported symbols from the executable and +any libraries loaded into the global namespace. This includes at least +libc, libm, libdl (on Linux), +libgcc (if compiled with GCC), as well as any exported +symbols from the Lua/C API provided by LuaJIT itself. +

+

+On Windows systems, this binds to symbols exported from the +*.exe, the lua51.dll (i.e. the Lua/C API +provided by LuaJIT itself), the C runtime library LuaJIT was linked +with (msvcrt*.dll), kernel32.dll, +user32.dll and gdi32.dll. +

+ +

clib = ffi.load(name [,global])

+

+This loads the dynamic library given by name and returns +a new C library namespace which binds to its symbols. On POSIX +systems, if global is true, the library symbols are +loaded into the global namespace, too. +

+

+If name is a path, the library is loaded from this path. +Otherwise name is canonicalized in a system-dependent way and +searched in the default search path for dynamic libraries: +

+

+On POSIX systems, if the name contains no dot, the extension +.so is appended. Also, the lib prefix is prepended +if necessary. So ffi.load("z") looks for "libz.so" +in the default shared library search path. +

+

+On Windows systems, if the name contains no dot, the extension +.dll is appended. So ffi.load("ws2_32") looks for +"ws2_32.dll" in the default DLL search path. +

+ +

Creating cdata Objects

+

+The following API functions create cdata objects (type() +returns "cdata"). All created cdata objects are +garbage collected. +

+ +

cdata = ffi.new(ct [,nelem] [,init...])
+cdata = ctype([nelem,] [init...])

+

+Creates a cdata object for the given ct. VLA/VLS types +require the nelem argument. The second syntax uses a ctype as +a constructor and is otherwise fully equivalent. +

+

+The cdata object is initialized according to the +rules for initializers, +using the optional init arguments. Excess initializers cause +an error. +

+

+Performance notice: if you want to create many objects of one kind, +parse the cdecl only once and get its ctype with +ffi.typeof(). Then use the ctype as a constructor repeatedly. +

+

+Please note that an anonymous struct declaration implicitly +creates a new and distinguished ctype every time you use it for +ffi.new(). This is probably not what you want, +especially if you create more than one cdata object. Different anonymous +structs are not considered assignment-compatible by the +C standard, even though they may have the same fields! Also, they +are considered different types by the JIT-compiler, which may cause an +excessive number of traces. It's strongly suggested to either declare +a named struct or typedef with ffi.cdef() +or to create a single ctype object for an anonymous struct +with ffi.typeof(). +

+ +

ctype = ffi.typeof(ct)

+

+Creates a ctype object for the given ct. +

+

+This function is especially useful to parse a cdecl only once and then +use the resulting ctype object as a constructor. +

+ +

cdata = ffi.cast(ct, init)

+

+Creates a scalar cdata object for the given ct. The cdata +object is initialized with init using the "cast" variant of +the C type conversion +rules. +

+

+This functions is mainly useful to override the pointer compatibility +checks or to convert pointers to addresses or vice versa. +

+ +

ctype = ffi.metatype(ct, metatable)

+

+Creates a ctype object for the given ct and associates it with +a metatable. Only struct/union types, complex numbers +and vectors are allowed. Other types may be wrapped in a +struct, if needed. +

+

+The association with a metatable is permanent and cannot be changed +afterwards. Neither the contents of the metatable nor the +contents of an __index table (if any) may be modified +afterwards. The associated metatable automatically applies to all uses +of this type, no matter how the objects are created or where they +originate from. Note that pre-defined operations on types have +precedence (e.g. declared field names cannot be overriden). +

+

+All standard Lua metamethods are implemented. These are called directly, +without shortcuts and on any mix of types. For binary operations, the +left operand is checked first for a valid ctype metamethod. The +__gc metamethod only applies to struct/union +types and performs an implicit ffi.gc() +call during creation of an instance. +

+ +

cdata = ffi.gc(cdata, finalizer)

+

+Associates a finalizer with a pointer or aggregate cdata object. The +cdata object is returned unchanged. +

+

+This function allows safe integration of unmanaged resources into the +automatic memory management of the LuaJIT garbage collector. Typical +usage: +

+
+local p = ffi.gc(ffi.C.malloc(n), ffi.C.free)
+...
+p = nil -- Last reference to p is gone.
+-- GC will eventually run finalizer: ffi.C.free(p)
+
+

+A cdata finalizer works like the __gc metamethod for userdata +objects: when the last reference to a cdata object is gone, the +associated finalizer is called with the cdata object as an argument. The +finalizer can be a Lua function or a cdata function or cdata function +pointer. An existing finalizer can be removed by setting a nil +finalizer, e.g. right before explicitly deleting a resource: +

+
+ffi.C.free(ffi.gc(p, nil)) -- Manually free the memory.
+
+ +

C Type Information

+

+The following API functions return information about C types. +They are most useful for inspecting cdata objects. +

+ +

size = ffi.sizeof(ct [,nelem])

+

+Returns the size of ct in bytes. Returns nil if +the size is not known (e.g. for "void" or function types). +Requires nelem for VLA/VLS types, except for cdata objects. +

+ +

align = ffi.alignof(ct)

+

+Returns the minimum required alignment for ct in bytes. +

+ +

ofs [,bpos,bsize] = ffi.offsetof(ct, field)

+

+Returns the offset (in bytes) of field relative to the start +of ct, which must be a struct. Additionally returns +the position and the field size (in bits) for bit fields. +

+ +

status = ffi.istype(ct, obj)

+

+Returns true if obj has the C type given by +ct. Returns false otherwise. +

+

+C type qualifiers (const etc.) are ignored. Pointers are +checked with the standard pointer compatibility rules, but without any +special treatment for void *. If ct specifies a +struct/union, then a pointer to this type is accepted, +too. Otherwise the types must match exactly. +

+

+Note: this function accepts all kinds of Lua objects for the +obj argument, but always returns false for non-cdata +objects. +

+ +

Utility Functions

+ +

err = ffi.errno([newerr])

+

+Returns the error number set by the last C function call which +indicated an error condition. If the optional newerr argument +is present, the error number is set to the new value and the previous +value is returned. +

+

+This function offers a portable and OS-independent way to get and set the +error number. Note that only some C functions set the error +number. And it's only significant if the function actually indicated an +error condition (e.g. with a return value of -1 or +NULL). Otherwise, it may or may not contain any previously set +value. +

+

+You're advised to call this function only when needed and as close as +possible after the return of the related C function. The +errno value is preserved across hooks, memory allocations, +invocations of the JIT compiler and other internal VM activity. The same +applies to the value returned by GetLastError() on Windows, but +you need to declare and call it yourself. +

+ +

str = ffi.string(ptr [,len])

+

+Creates an interned Lua string from the data pointed to by +ptr. +

+

+If the optional argument len is missing, ptr is +converted to a "char *" and the data is assumed to be +zero-terminated. The length of the string is computed with +strlen(). +

+

+Otherwise ptr is converted to a "void *" and +len gives the length of the data. The data may contain +embedded zeros and need not be byte-oriented (though this may cause +endianess issues). +

+

+This function is mainly useful to convert (temporary) +"const char *" pointers returned by +C functions to Lua strings and store them or pass them to other +functions expecting a Lua string. The Lua string is an (interned) copy +of the data and bears no relation to the original data area anymore. +Lua strings are 8 bit clean and may be used to hold arbitrary, +non-character data. +

+

+Performance notice: it's faster to pass the length of the string, if +it's known. E.g. when the length is returned by a C call like +sprintf(). +

+ +

ffi.copy(dst, src, len)
+ffi.copy(dst, str)

+

+Copies the data pointed to by src to dst. +dst is converted to a "void *" and src +is converted to a "const void *". +

+

+In the first syntax, len gives the number of bytes to copy. +Caveat: if src is a Lua string, then len must not +exceed #src+1. +

+

+In the second syntax, the source of the copy must be a Lua string. All +bytes of the string plus a zero-terminator are copied to +dst (i.e. #src+1 bytes). +

+

+Performance notice: ffi.copy() may be used as a faster +(inlinable) replacement for the C library functions +memcpy(), strcpy() and strncpy(). +

+ +

ffi.fill(dst, len [,c])

+

+Fills the data pointed to by dst with len constant +bytes, given by c. If c is omitted, the data is +zero-filled. +

+

+Performance notice: ffi.fill() may be used as a faster +(inlinable) replacement for the C library function +memset(dst, c, len). Please note the different +order of arguments! +

+ +

Target-specific Information

+ +

status = ffi.abi(param)

+

+Returns true if param (a Lua string) applies for the +target ABI (Application Binary Interface). Returns false +otherwise. The following parameters are currently defined: +

+ + + + + + + + + + + + + + + + + + + + + + + +
ParameterDescription
32bit32 bit architecture
64bit64 bit architecture
leLittle-endian architecture
beBig-endian architecture
fpuTarget has a hardware FPU
softfpsoftfp calling conventions
hardfphardfp calling conventions
eabiEABI variant of the standard ABI
winWindows variant of the standard ABI
+ +

ffi.os

+

+Contains the target OS name. Same contents as +jit.os. +

+ +

ffi.arch

+

+Contains the target architecture name. Same contents as +jit.arch. +

+ +

Methods for Callbacks

+

+The C types for callbacks +have some extra methods: +

+ +

cb:free()

+

+Free the resources associated with a callback. The associated Lua +function is unanchored and may be garbage collected. The callback +function pointer is no longer valid and must not be called anymore +(it may be reused by a subsequently created callback). +

+ +

cb:set(func)

+

+Associate a new Lua function with a callback. The C type of the +callback and the callback function pointer are unchanged. +

+

+This method is useful to dynamically switch the receiver of callbacks +without creating a new callback each time and registering it again (e.g. +with a GUI library). +

+ +

Extended Standard Library Functions

+

+The following standard library functions have been extended to work +with cdata objects: +

+ +

n = tonumber(cdata)

+

+Converts a number cdata object to a double and returns it as +a Lua number. This is particularly useful for boxed 64 bit +integer values. Caveat: this conversion may incur a precision loss. +

+ +

s = tostring(cdata)

+

+Returns a string representation of the value of 64 bit integers +("nnnLL" or "nnnULL") or +complex numbers ("re±imi"). Otherwise +returns a string representation of the C type of a ctype object +("ctype<type>") or a cdata object +("cdata<type>: address"), unless you +override it with a __tostring metamethod (see +ffi.metatype()). +

+ +

iter, obj, start = pairs(cdata)
+iter, obj, start = ipairs(cdata)

+

+Calls the __pairs or __ipairs metamethod of the +corresponding ctype. +

+ +

Extensions to the Lua Parser

+

+The parser for Lua source code treats numeric literals with the +suffixes LL or ULL as signed or unsigned 64 bit +integers. Case doesn't matter, but uppercase is recommended for +readability. It handles both decimal (42LL) and hexadecimal +(0x2aLL) literals. +

+

+The imaginary part of complex numbers can be specified by suffixing +number literals with i or I, e.g. 12.5i. +Caveat: you'll need to use 1i to get an imaginary part with +the value one, since i itself still refers to a variable +named i. +

+
+
+ + + diff --git a/source/libs/luajit/LuaJIT-2.0.4/doc/ext_ffi_semantics.html b/source/libs/luajit/LuaJIT-2.0.4/doc/ext_ffi_semantics.html new file mode 100644 index 000000000..c267b5556 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/doc/ext_ffi_semantics.html @@ -0,0 +1,1245 @@ + + + +FFI Semantics + + + + + + + + + +
+Lua +
+ + +
+

+This page describes the detailed semantics underlying the FFI library +and its interaction with both Lua and C code. +

+

+Given that the FFI library is designed to interface with C code +and that declarations can be written in plain C syntax, it +closely follows the C language semantics, wherever possible. +Some minor concessions are needed for smoother interoperation with Lua +language semantics. +

+

+Please don't be overwhelmed by the contents of this page — this +is a reference and you may need to consult it, if in doubt. It doesn't +hurt to skim this page, but most of the semantics "just work" as you'd +expect them to work. It should be straightforward to write +applications using the LuaJIT FFI for developers with a C or C++ +background. +

+ +

C Language Support

+

+The FFI library has a built-in C parser with a minimal memory +footprint. It's used by the ffi.* library +functions to declare C types or external symbols. +

+

+It's only purpose is to parse C declarations, as found e.g. in +C header files. Although it does evaluate constant expressions, +it's not a C compiler. The body of inline +C function definitions is simply ignored. +

+

+Also, this is not a validating C parser. It expects and +accepts correctly formed C declarations, but it may choose to +ignore bad declarations or show rather generic error messages. If in +doubt, please check the input against your favorite C compiler. +

+

+The C parser complies to the C99 language standard plus +the following extensions: +

+
    + +
  • The '\e' escape in character and string literals.
  • + +
  • The C99/C++ boolean type, declared with the keywords bool +or _Bool.
  • + +
  • Complex numbers, declared with the keywords complex or +_Complex.
  • + +
  • Two complex number types: complex (aka +complex double) and complex float.
  • + +
  • Vector types, declared with the GCC mode or +vector_size attribute.
  • + +
  • Unnamed ('transparent') struct/union fields +inside a struct/union.
  • + +
  • Incomplete enum declarations, handled like incomplete +struct declarations.
  • + +
  • Unnamed enum fields inside a +struct/union. This is similar to a scoped C++ +enum, except that declared constants are visible in the +global namespace, too.
  • + +
  • Scoped static const declarations inside a +struct/union (from C++).
  • + +
  • Zero-length arrays ([0]), empty +struct/union, variable-length arrays (VLA, +[?]) and variable-length structs (VLS, with a trailing +VLA).
  • + +
  • C++ reference types (int &x).
  • + +
  • Alternate GCC keywords with '__', e.g. +__const__.
  • + +
  • GCC __attribute__ with the following attributes: +aligned, packed, mode, +vector_size, cdecl, fastcall, +stdcall, thiscall.
  • + +
  • The GCC __extension__ keyword and the GCC +__alignof__ operator.
  • + +
  • GCC __asm__("symname") symbol name redirection for +function declarations.
  • + +
  • MSVC keywords for fixed-length types: __int8, +__int16, __int32 and __int64.
  • + +
  • MSVC __cdecl, __fastcall, __stdcall, +__thiscall, __ptr32, __ptr64, +__declspec(align(n)) and #pragma pack.
  • + +
  • All other GCC/MSVC-specific attributes are ignored.
  • + +
+

+The following C types are pre-defined by the C parser (like +a typedef, except re-declarations will be ignored): +

+
    + +
  • Vararg handling: va_list, __builtin_va_list, +__gnuc_va_list.
  • + +
  • From <stddef.h>: ptrdiff_t, +size_t, wchar_t.
  • + +
  • From <stdint.h>: int8_t, int16_t, +int32_t, int64_t, uint8_t, +uint16_t, uint32_t, uint64_t, +intptr_t, uintptr_t.
  • + +
+

+You're encouraged to use these types in preference to +compiler-specific extensions or target-dependent standard types. +E.g. char differs in signedness and long differs in +size, depending on the target architecture and platform ABI. +

+

+The following C features are not supported: +

+
    + +
  • A declaration must always have a type specifier; it doesn't +default to an int type.
  • + +
  • Old-style empty function declarations (K&R) are not allowed. +All C functions must have a proper prototype declaration. A +function declared without parameters (int foo();) is +treated as a function taking zero arguments, like in C++.
  • + +
  • The long double C type is parsed correctly, but +there's no support for the related conversions, accesses or arithmetic +operations.
  • + +
  • Wide character strings and character literals are not +supported.
  • + +
  • See below for features that are currently +not implemented.
  • + +
+ +

C Type Conversion Rules

+ +

Conversions from C types to Lua objects

+

+These conversion rules apply for read accesses to +C types: indexing pointers, arrays or +struct/union types; reading external variables or +constant values; retrieving return values from C calls: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
InputConversionOutput
int8_t, int16_tsign-ext int32_tdoublenumber
uint8_t, uint16_tzero-ext int32_tdoublenumber
int32_t, uint32_tdoublenumber
int64_t, uint64_tboxed value64 bit int cdata
double, floatdoublenumber
bool0 → false, otherwise trueboolean
enumboxed valueenum cdata
Complex numberboxed valuecomplex cdata
Vectorboxed valuevector cdata
Pointerboxed valuepointer cdata
Arrayboxed referencereference cdata
struct/unionboxed referencereference cdata
+

+Bitfields are treated like their underlying type. +

+

+Reference types are dereferenced before a conversion can take +place — the conversion is applied to the C type pointed to +by the reference. +

+ +

Conversions from Lua objects to C types

+

+These conversion rules apply for write accesses to +C types: indexing pointers, arrays or +struct/union types; initializing cdata objects; +casts to C types; writing to external variables; passing +arguments to C calls: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
InputConversionOutput
numberdouble
booleanfalse → 0, true → 1bool
nilNULL(void *)
lightuserdatalightuserdata address →(void *)
userdatauserdata payload →(void *)
io.* fileget FILE * handle →(void *)
stringmatch against enum constantenum
stringcopy string data + zero-byteint8_t[], uint8_t[]
stringstring data →const char[]
functioncreate callbackC function type
tabletable initializerArray
tabletable initializerstruct/union
cdatacdata payload →C type
+

+If the result type of this conversion doesn't match the +C type of the destination, the +conversion rules between C types +are applied. +

+

+Reference types are immutable after initialization ("no re-seating of +references"). For initialization purposes or when passing values to +reference parameters, they are treated like pointers. Note that unlike +in C++, there's no way to implement automatic reference generation of +variables under the Lua language semantics. If you want to call a +function with a reference parameter, you need to explicitly pass a +one-element array. +

+ +

Conversions between C types

+

+These conversion rules are more or less the same as the standard +C conversion rules. Some rules only apply to casts, or require +pointer or type compatibility: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
InputConversionOutput
Signed integernarrow or sign-extendInteger
Unsigned integernarrow or zero-extendInteger
Integerrounddouble, float
double, floattrunc int32_tnarrow(u)int8_t, (u)int16_t
double, floattrunc(u)int32_t, (u)int64_t
double, floatroundfloat, double
Numbern == 0 → 0, otherwise 1bool
boolfalse → 0, true → 1Number
Complex numberconvert real partNumber
Numberconvert real part, imag = 0Complex number
Complex numberconvert real and imag partComplex number
Numberconvert scalar and replicateVector
Vectorcopy (same size)Vector
struct/uniontake base address (compat)Pointer
Arraytake base address (compat)Pointer
Functiontake function addressFunction pointer
Numberconvert via uintptr_t (cast)Pointer
Pointerconvert address (compat/cast)Pointer
Pointerconvert address (cast)Integer
Arrayconvert base address (cast)Integer
Arraycopy (compat)Array
struct/unioncopy (identical type)struct/union
+

+Bitfields or enum types are treated like their underlying +type. +

+

+Conversions not listed above will raise an error. E.g. it's not +possible to convert a pointer to a complex number or vice versa. +

+ +

Conversions for vararg C function arguments

+

+The following default conversion rules apply when passing Lua objects +to the variable argument part of vararg C functions: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
InputConversionOutput
numberdouble
booleanfalse → 0, true → 1bool
nilNULL(void *)
userdatauserdata payload →(void *)
lightuserdatalightuserdata address →(void *)
stringstring data →const char *
float cdatadouble
Array cdatatake base addressElement pointer
struct/union cdatatake base addressstruct/union pointer
Function cdatatake function addressFunction pointer
Any other cdatano conversionC type
+

+To pass a Lua object, other than a cdata object, as a specific type, +you need to override the conversion rules: create a temporary cdata +object with a constructor or a cast and initialize it with the value +to pass: +

+

+Assuming x is a Lua number, here's how to pass it as an +integer to a vararg function: +

+
+ffi.cdef[[
+int printf(const char *fmt, ...);
+]]
+ffi.C.printf("integer value: %d\n", ffi.new("int", x))
+
+

+If you don't do this, the default Lua number → double +conversion rule applies. A vararg C function expecting an integer +will see a garbled or uninitialized value. +

+ +

Initializers

+

+Creating a cdata object with +ffi.new() or the +equivalent constructor syntax always initializes its contents, too. +Different rules apply, depending on the number of optional +initializers and the C types involved: +

+
    +
  • If no initializers are given, the object is filled with zero bytes.
  • + +
  • Scalar types (numbers and pointers) accept a single initializer. +The Lua object is converted to the scalar +C type.
  • + +
  • Valarrays (complex numbers and vectors) are treated like scalars +when a single initializer is given. Otherwise they are treated like +regular arrays.
  • + +
  • Aggregate types (arrays and structs) accept either a single cdata +initializer of the same type (copy constructor), a single +table initializer, or a flat list of +initializers.
  • + +
  • The elements of an array are initialized, starting at index zero. +If a single initializer is given for an array, it's repeated for all +remaining elements. This doesn't happen if two or more initializers +are given: all remaining uninitialized elements are filled with zero +bytes.
  • + +
  • Byte arrays may also be initialized with a Lua string. This copies +the whole string plus a terminating zero-byte. The copy stops early only +if the array has a known, fixed size.
  • + +
  • The fields of a struct are initialized in the order of +their declaration. Uninitialized fields are filled with zero +bytes.
  • + +
  • Only the first field of a union can be initialized with a +flat initializer.
  • + +
  • Elements or fields which are aggregates themselves are initialized +with a single initializer, but this may be a table +initializer or a compatible aggregate.
  • + +
  • Excess initializers cause an error.
  • + +
+ +

Table Initializers

+

+The following rules apply if a Lua table is used to initialize an +Array or a struct/union: +

+
    + +
  • If the table index [0] is non-nil, then the +table is assumed to be zero-based. Otherwise it's assumed to be +one-based.
  • + +
  • Array elements, starting at index zero, are initialized one-by-one +with the consecutive table elements, starting at either index +[0] or [1]. This process stops at the first +nil table element.
  • + +
  • If exactly one array element was initialized, it's repeated for +all the remaining elements. Otherwise all remaining uninitialized +elements are filled with zero bytes.
  • + +
  • The above logic only applies to arrays with a known fixed size. +A VLA is only initialized with the element(s) given in the table. +Depending on the use case, you may need to explicitly add a +NULL or 0 terminator to a VLA.
  • + +
  • A struct/union can be initialized in the +order of the declaration of its fields. Each field is initialized with +consecutive table elements, starting at either index [0] +or [1]. This process stops at the first nil table +element.
  • + +
  • Otherwise, if neither index [0] nor [1] is present, +a struct/union is initialized by looking up each field +name (as a string key) in the table. Each non-nil value is +used to initialize the corresponding field.
  • + +
  • Uninitialized fields of a struct are filled with zero +bytes, except for the trailing VLA of a VLS.
  • + +
  • Initialization of a union stops after one field has been +initialized. If no field has been initialized, the union is +filled with zero bytes.
  • + +
  • Elements or fields which are aggregates themselves are initialized +with a single initializer, but this may be a nested table +initializer (or a compatible aggregate).
  • + +
  • Excess initializers for an array cause an error. Excess +initializers for a struct/union are ignored. +Unrelated table entries are ignored, too.
  • + +
+

+Example: +

+
+local ffi = require("ffi")
+
+ffi.cdef[[
+struct foo { int a, b; };
+union bar { int i; double d; };
+struct nested { int x; struct foo y; };
+]]
+
+ffi.new("int[3]", {})            --> 0, 0, 0
+ffi.new("int[3]", {1})           --> 1, 1, 1
+ffi.new("int[3]", {1,2})         --> 1, 2, 0
+ffi.new("int[3]", {1,2,3})       --> 1, 2, 3
+ffi.new("int[3]", {[0]=1})       --> 1, 1, 1
+ffi.new("int[3]", {[0]=1,2})     --> 1, 2, 0
+ffi.new("int[3]", {[0]=1,2,3})   --> 1, 2, 3
+ffi.new("int[3]", {[0]=1,2,3,4}) --> error: too many initializers
+
+ffi.new("struct foo", {})            --> a = 0, b = 0
+ffi.new("struct foo", {1})           --> a = 1, b = 0
+ffi.new("struct foo", {1,2})         --> a = 1, b = 2
+ffi.new("struct foo", {[0]=1,2})     --> a = 1, b = 2
+ffi.new("struct foo", {b=2})         --> a = 0, b = 2
+ffi.new("struct foo", {a=1,b=2,c=3}) --> a = 1, b = 2  'c' is ignored
+
+ffi.new("union bar", {})        --> i = 0, d = 0.0
+ffi.new("union bar", {1})       --> i = 1, d = ?
+ffi.new("union bar", {[0]=1,2}) --> i = 1, d = ?    '2' is ignored
+ffi.new("union bar", {d=2})     --> i = ?, d = 2.0
+
+ffi.new("struct nested", {1,{2,3}})     --> x = 1, y.a = 2, y.b = 3
+ffi.new("struct nested", {x=1,y={2,3}}) --> x = 1, y.a = 2, y.b = 3
+
+ +

Operations on cdata Objects

+

+All of the standard Lua operators can be applied to cdata objects or a +mix of a cdata object and another Lua object. The following list shows +the pre-defined operations. +

+

+Reference types are dereferenced before performing each of +the operations below — the operation is applied to the +C type pointed to by the reference. +

+

+The pre-defined operations are always tried first before deferring to a +metamethod or index table (if any) for the corresponding ctype (except +for __new). An error is raised if the metamethod lookup or +index table lookup fails. +

+ +

Indexing a cdata object

+
    + +
  • Indexing a pointer/array: a cdata pointer/array can be +indexed by a cdata number or a Lua number. The element address is +computed as the base address plus the number value multiplied by the +element size in bytes. A read access loads the element value and +converts it to a Lua object. A write +access converts a Lua object to the element +type and stores the converted value to the element. An error is +raised if the element size is undefined or a write access to a +constant element is attempted.
  • + +
  • Dereferencing a struct/union field: a +cdata struct/union or a pointer to a +struct/union can be dereferenced by a string key, +giving the field name. The field address is computed as the base +address plus the relative offset of the field. A read access loads the +field value and converts it to a Lua +object. A write access converts a Lua +object to the field type and stores the converted value to the +field. An error is raised if a write access to a constant +struct/union or a constant field is attempted. +Scoped enum constants or static constants are treated like a constant +field.
  • + +
  • Indexing a complex number: a complex number can be indexed +either by a cdata number or a Lua number with the values 0 or 1, or by +the strings "re" or "im". A read access loads the +real part ([0], .re) or the imaginary part +([1], .im) part of a complex number and +converts it to a Lua number. The +sub-parts of a complex number are immutable — assigning to an +index of a complex number raises an error. Accessing out-of-bound +indexes returns unspecified results, but is guaranteed not to trigger +memory access violations.
  • + +
  • Indexing a vector: a vector is treated like an array for +indexing purposes, except the vector elements are immutable — +assigning to an index of a vector raises an error.
  • + +
+

+A ctype object can be indexed with a string key, too. The only +pre-defined operation is reading scoped constants of +struct/union types. All other accesses defer +to the corresponding metamethods or index tables (if any). +

+

+Note: since there's (deliberately) no address-of operator, a cdata +object holding a value type is effectively immutable after +initialization. The JIT compiler benefits from this fact when applying +certain optimizations. +

+

+As a consequence, the elements of complex numbers and +vectors are immutable. But the elements of an aggregate holding these +types may be modified of course. I.e. you cannot assign to +foo.c.im, but you can assign a (newly created) complex number +to foo.c. +

+

+The JIT compiler implements strict aliasing rules: accesses to different +types do not alias, except for differences in signedness (this +applies even to char pointers, unlike C99). Type punning +through unions is explicitly detected and allowed. +

+ +

Calling a cdata object

+
    + +
  • Constructor: a ctype object can be called and used as a +constructor. This is equivalent +to ffi.new(ct, ...), unless a __new metamethod is +defined. The __new metamethod is called with the ctype object +plus any other arguments passed to the contructor. Note that you have to +use ffi.new inside of it, since calling ct(...) would +cause infinite recursion.
  • + +
  • C function call: a cdata function or cdata function +pointer can be called. The passed arguments are +converted to the C types of the +parameters given by the function declaration. Arguments passed to the +variable argument part of vararg C function use +special conversion rules. This +C function is called and the return value (if any) is +converted to a Lua object.
    +On Windows/x86 systems, __stdcall functions are automatically +detected and a function declared as __cdecl (the default) is +silently fixed up after the first call.
  • + +
+ +

Arithmetic on cdata objects

+
    + +
  • Pointer arithmetic: a cdata pointer/array and a cdata +number or a Lua number can be added or subtracted. The number must be +on the right hand side for a subtraction. The result is a pointer of +the same type with an address plus or minus the number value +multiplied by the element size in bytes. An error is raised if the +element size is undefined.
  • + +
  • Pointer difference: two compatible cdata pointers/arrays +can be subtracted. The result is the difference between their +addresses, divided by the element size in bytes. An error is raised if +the element size is undefined or zero.
  • + +
  • 64 bit integer arithmetic: the standard arithmetic +operators (+ - * / % ^ and unary +minus) can be applied to two cdata numbers, or a cdata number and a +Lua number. If one of them is an uint64_t, the other side is +converted to an uint64_t and an unsigned arithmetic operation +is performed. Otherwise both sides are converted to an +int64_t and a signed arithmetic operation is performed. The +result is a boxed 64 bit cdata object.
    + +If one of the operands is an enum and the other operand is a +string, the string is converted to the value of a matching enum +constant before the above conversion.
    + +These rules ensure that 64 bit integers are "sticky". Any +expression involving at least one 64 bit integer operand results +in another one. The undefined cases for the division, modulo and power +operators return 2LL ^ 63 or +2ULL ^ 63.
    + +You'll have to explicitly convert a 64 bit integer to a Lua +number (e.g. for regular floating-point calculations) with +tonumber(). But note this may incur a precision loss.
  • + +
+ +

Comparisons of cdata objects

+
    + +
  • Pointer comparison: two compatible cdata pointers/arrays +can be compared. The result is the same as an unsigned comparison of +their addresses. nil is treated like a NULL pointer, +which is compatible with any other pointer type.
  • + +
  • 64 bit integer comparison: two cdata numbers, or a +cdata number and a Lua number can be compared with each other. If one +of them is an uint64_t, the other side is converted to an +uint64_t and an unsigned comparison is performed. Otherwise +both sides are converted to an int64_t and a signed +comparison is performed.
    + +If one of the operands is an enum and the other operand is a +string, the string is converted to the value of a matching enum +constant before the above conversion.
    + +
  • Comparisons for equality/inequality never raise an error. +Even incompatible pointers can be compared for equality by address. Any +other incompatible comparison (also with non-cdata objects) treats the +two sides as unequal.
  • + +
+ +

cdata objects as table keys

+

+Lua tables may be indexed by cdata objects, but this doesn't provide +any useful semantics — cdata objects are unsuitable as table +keys! +

+

+A cdata object is treated like any other garbage-collected object and +is hashed and compared by its address for table indexing. Since +there's no interning for cdata value types, the same value may be +boxed in different cdata objects with different addresses. Thus +t[1LL+1LL] and t[2LL] usually do not point to +the same hash slot and they certainly do not point to the same +hash slot as t[2]. +

+

+It would seriously drive up implementation complexity and slow down +the common case, if one were to add extra handling for by-value +hashing and comparisons to Lua tables. Given the ubiquity of their use +inside the VM, this is not acceptable. +

+

+There are three viable alternatives, if you really need to use cdata +objects as keys: +

+
    + +
  • If you can get by with the precision of Lua numbers +(52 bits), then use tonumber() on a cdata number or +combine multiple fields of a cdata aggregate to a Lua number. Then use +the resulting Lua number as a key when indexing tables.
    +One obvious benefit: t[tonumber(2LL)] does point to +the same slot as t[2].
  • + +
  • Otherwise use either tostring() on 64 bit integers +or complex numbers or combine multiple fields of a cdata aggregate to +a Lua string (e.g. with +ffi.string()). Then +use the resulting Lua string as a key when indexing tables.
  • + +
  • Create your own specialized hash table implementation using the +C types provided by the FFI library, just like you would in +C code. Ultimately this may give much better performance than the +other alternatives or what a generic by-value hash table could +possibly provide.
  • + +
+ +

Parameterized Types

+

+To facilitate some abstractions, the two functions +ffi.typeof and +ffi.cdef support +parameterized types in C declarations. Note: none of the other API +functions taking a cdecl allow this. +

+

+Any place you can write a typedef name, an +identifier or a number in a declaration, you can write +$ (the dollar sign) instead. These placeholders are replaced in +order of appearance with the arguments following the cdecl string: +

+
+-- Declare a struct with a parameterized field type and name:
+ffi.cdef([[
+typedef struct { $ $; } foo_t;
+]], type1, name1)
+
+-- Anonymous struct with dynamic names:
+local bar_t = ffi.typeof("struct { int $, $; }", name1, name2)
+-- Derived pointer type:
+local bar_ptr_t = ffi.typeof("$ *", bar_t)
+
+-- Parameterized dimensions work even where a VLA won't work:
+local matrix_t = ffi.typeof("uint8_t[$][$]", width, height)
+
+

+Caveat: this is not simple text substitution! A passed ctype or +cdata object is treated like the underlying type, a passed string is +considered an identifier and a number is considered a number. You must +not mix this up: e.g. passing "int" as a string doesn't work in +place of a type, you'd need to use ffi.typeof("int") instead. +

+

+The main use for parameterized types are libraries implementing abstract +data types +(» example), +similar to what can be achieved with C++ template metaprogramming. +Another use case are derived types of anonymous structs, which avoids +pollution of the global struct namespace. +

+

+Please note that parameterized types are a nice tool and indispensable +for certain use cases. But you'll want to use them sparingly in regular +code, e.g. when all types are actually fixed. +

+ +

Garbage Collection of cdata Objects

+

+All explicitly (ffi.new(), ffi.cast() etc.) or +implicitly (accessors) created cdata objects are garbage collected. +You need to ensure to retain valid references to cdata objects +somewhere on a Lua stack, an upvalue or in a Lua table while they are +still in use. Once the last reference to a cdata object is gone, the +garbage collector will automatically free the memory used by it (at +the end of the next GC cycle). +

+

+Please note that pointers themselves are cdata objects, however they +are not followed by the garbage collector. So e.g. if you +assign a cdata array to a pointer, you must keep the cdata object +holding the array alive as long as the pointer is still in use: +

+
+ffi.cdef[[
+typedef struct { int *a; } foo_t;
+]]
+
+local s = ffi.new("foo_t", ffi.new("int[10]")) -- WRONG!
+
+local a = ffi.new("int[10]") -- OK
+local s = ffi.new("foo_t", a)
+-- Now do something with 's', but keep 'a' alive until you're done.
+
+

+Similar rules apply for Lua strings which are implicitly converted to +"const char *": the string object itself must be +referenced somewhere or it'll be garbage collected eventually. The +pointer will then point to stale data, which may have already been +overwritten. Note that string literals are automatically kept +alive as long as the function containing it (actually its prototype) +is not garbage collected. +

+

+Objects which are passed as an argument to an external C function +are kept alive until the call returns. So it's generally safe to +create temporary cdata objects in argument lists. This is a common +idiom for passing specific C types to +vararg functions. +

+

+Memory areas returned by C functions (e.g. from malloc()) +must be manually managed, of course (or use +ffi.gc()). Pointers to +cdata objects are indistinguishable from pointers returned by C +functions (which is one of the reasons why the GC cannot follow them). +

+ +

Callbacks

+

+The LuaJIT FFI automatically generates special callback functions +whenever a Lua function is converted to a C function pointer. This +associates the generated callback function pointer with the C type +of the function pointer and the Lua function object (closure). +

+

+This can happen implicitly due to the usual conversions, e.g. when +passing a Lua function to a function pointer argument. Or you can use +ffi.cast() to explicitly cast a Lua function to a +C function pointer. +

+

+Currently only certain C function types can be used as callback +functions. Neither C vararg functions nor functions with +pass-by-value aggregate argument or result types are supported. There +are no restrictions for the kind of Lua functions that can be called +from the callback — no checks for the proper number of arguments +are made. The return value of the Lua function will be converted to the +result type and an error will be thrown for invalid conversions. +

+

+It's allowed to throw errors across a callback invocation, but it's not +advisable in general. Do this only if you know the C function, that +called the callback, copes with the forced stack unwinding and doesn't +leak resources. +

+

+One thing that's not allowed, is to let an FFI call into a C function +get JIT-compiled, which in turn calls a callback, calling into Lua again. +Usually this attempt is caught by the interpreter first and the +C function is blacklisted for compilation. +

+

+However, this heuristic may fail under specific circumstances: e.g. a +message polling function might not run Lua callbacks right away and the call +gets JIT-compiled. If it later happens to call back into Lua (e.g. a rarely +invoked error callback), you'll get a VM PANIC with the message +"bad callback". Then you'll need to manually turn off +JIT-compilation with +jit.off() for the +surrounding Lua function that invokes such a message polling function (or +similar). +

+ +

Callback resource handling

+

+Callbacks take up resources — you can only have a limited number +of them at the same time (500 - 1000, depending on the +architecture). The associated Lua functions are anchored to prevent +garbage collection, too. +

+

+Callbacks due to implicit conversions are permanent! There is no +way to guess their lifetime, since the C side might store the +function pointer for later use (typical for GUI toolkits). The associated +resources cannot be reclaimed until termination: +

+
+ffi.cdef[[
+typedef int (__stdcall *WNDENUMPROC)(void *hwnd, intptr_t l);
+int EnumWindows(WNDENUMPROC func, intptr_t l);
+]]
+
+-- Implicit conversion to a callback via function pointer argument.
+local count = 0
+ffi.C.EnumWindows(function(hwnd, l)
+  count = count + 1
+  return true
+end, 0)
+-- The callback is permanent and its resources cannot be reclaimed!
+-- Ok, so this may not be a problem, if you do this only once.
+
+

+Note: this example shows that you must properly declare +__stdcall callbacks on Windows/x86 systems. The calling +convention cannot be automatically detected, unlike for +__stdcall calls to Windows functions. +

+

+For some use cases it's necessary to free up the resources or to +dynamically redirect callbacks. Use an explicit cast to a +C function pointer and keep the resulting cdata object. Then use +the cb:free() +or cb:set() methods +on the cdata object: +

+
+-- Explicitly convert to a callback via cast.
+local count = 0
+local cb = ffi.cast("WNDENUMPROC", function(hwnd, l)
+  count = count + 1
+  return true
+end)
+
+-- Pass it to a C function.
+ffi.C.EnumWindows(cb, 0)
+-- EnumWindows doesn't need the callback after it returns, so free it.
+
+cb:free()
+-- The callback function pointer is no longer valid and its resources
+-- will be reclaimed. The created Lua closure will be garbage collected.
+
+ +

Callback performance

+

+Callbacks are slow! First, the C to Lua transition itself +has an unavoidable cost, similar to a lua_call() or +lua_pcall(). Argument and result marshalling add to that cost. +And finally, neither the C compiler nor LuaJIT can inline or +optimize across the language barrier and hoist repeated computations out +of a callback function. +

+

+Do not use callbacks for performance-sensitive work: e.g. consider a +numerical integration routine which takes a user-defined function to +integrate over. It's a bad idea to call a user-defined Lua function from +C code millions of times. The callback overhead will be absolutely +detrimental for performance. +

+

+It's considerably faster to write the numerical integration routine +itself in Lua — the JIT compiler will be able to inline the +user-defined function and optimize it together with its calling context, +with very competitive performance. +

+

+As a general guideline: use callbacks only when you must, because +of existing C APIs. E.g. callback performance is irrelevant for a +GUI application, which waits for user input most of the time, anyway. +

+

+For new designs avoid push-style APIs: a C function repeatedly +calling a callback for each result. Instead use pull-style APIs: +call a C function repeatedly to get a new result. Calls from Lua +to C via the FFI are much faster than the other way round. Most well-designed +libraries already use pull-style APIs (read/write, get/put). +

+ +

C Library Namespaces

+

+A C library namespace is a special kind of object which allows +access to the symbols contained in shared libraries or the default +symbol namespace. The default +ffi.C namespace is +automatically created when the FFI library is loaded. C library +namespaces for specific shared libraries may be created with the +ffi.load() API +function. +

+

+Indexing a C library namespace object with a symbol name (a Lua +string) automatically binds it to the library. First the symbol type +is resolved — it must have been declared with +ffi.cdef. Then the +symbol address is resolved by searching for the symbol name in the +associated shared libraries or the default symbol namespace. Finally, +the resulting binding between the symbol name, the symbol type and its +address is cached. Missing symbol declarations or nonexistent symbol +names cause an error. +

+

+This is what happens on a read access for the different kinds of +symbols: +

+
    + +
  • External functions: a cdata object with the type of the function +and its address is returned.
  • + +
  • External variables: the symbol address is dereferenced and the +loaded value is converted to a Lua object +and returned.
  • + +
  • Constant values (static const or enum +constants): the constant is converted to a +Lua object and returned.
  • + +
+

+This is what happens on a write access: +

+
    + +
  • External variables: the value to be written is +converted to the C type of the +variable and then stored at the symbol address.
  • + +
  • Writing to constant variables or to any other symbol type causes +an error, like any other attempted write to a constant location.
  • + +
+

+C library namespaces themselves are garbage collected objects. If +the last reference to the namespace object is gone, the garbage +collector will eventually release the shared library reference and +remove all memory associated with the namespace. Since this may +trigger the removal of the shared library from the memory of the +running process, it's generally not safe to use function +cdata objects obtained from a library if the namespace object may be +unreferenced. +

+

+Performance notice: the JIT compiler specializes to the identity of +namespace objects and to the strings used to index it. This +effectively turns function cdata objects into constants. It's not +useful and actually counter-productive to explicitly cache these +function objects, e.g. local strlen = ffi.C.strlen. OTOH it +is useful to cache the namespace itself, e.g. local C = +ffi.C. +

+ +

No Hand-holding!

+

+The FFI library has been designed as a low-level library. The +goal is to interface with C code and C data types with a +minimum of overhead. This means you can do anything you can do +from C: access all memory, overwrite anything in memory, call +machine code at any memory address and so on. +

+

+The FFI library provides no memory safety, unlike regular Lua +code. It will happily allow you to dereference a NULL +pointer, to access arrays out of bounds or to misdeclare +C functions. If you make a mistake, your application might crash, +just like equivalent C code would. +

+

+This behavior is inevitable, since the goal is to provide full +interoperability with C code. Adding extra safety measures, like +bounds checks, would be futile. There's no way to detect +misdeclarations of C functions, since shared libraries only +provide symbol names, but no type information. Likewise there's no way +to infer the valid range of indexes for a returned pointer. +

+

+Again: the FFI library is a low-level library. This implies it needs +to be used with care, but it's flexibility and performance often +outweigh this concern. If you're a C or C++ developer, it'll be easy +to apply your existing knowledge. OTOH writing code for the FFI +library is not for the faint of heart and probably shouldn't be the +first exercise for someone with little experience in Lua, C or C++. +

+

+As a corollary of the above, the FFI library is not safe for use by +untrusted Lua code. If you're sandboxing untrusted Lua code, you +definitely don't want to give this code access to the FFI library or +to any cdata object (except 64 bit integers or complex +numbers). Any properly engineered Lua sandbox needs to provide safety +wrappers for many of the standard Lua library functions — +similar wrappers need to be written for high-level operations on FFI +data types, too. +

+ +

Current Status

+

+The initial release of the FFI library has some limitations and is +missing some features. Most of these will be fixed in future releases. +

+

+C language support is +currently incomplete: +

+
    +
  • C declarations are not passed through a C pre-processor, +yet.
  • +
  • The C parser is able to evaluate most constant expressions +commonly found in C header files. However it doesn't handle the +full range of C expression semantics and may fail for some +obscure constructs.
  • +
  • static const declarations only work for integer types +up to 32 bits. Neither declaring string constants nor +floating-point constants is supported.
  • +
  • Packed struct bitfields that cross container boundaries +are not implemented.
  • +
  • Native vector types may be defined with the GCC mode or +vector_size attribute. But no operations other than loading, +storing and initializing them are supported, yet.
  • +
  • The volatile type qualifier is currently ignored by +compiled code.
  • +
  • ffi.cdef silently +ignores most re-declarations. Note: avoid re-declarations which do not +conform to C99. The implementation will eventually be changed to +perform strict checks.
  • +
+

+The JIT compiler already handles a large subset of all FFI operations. +It automatically falls back to the interpreter for unimplemented +operations (you can check for this with the +-jv command line option). +The following operations are currently not compiled and may exhibit +suboptimal performance, especially when used in inner loops: +

+
    +
  • Bitfield accesses and initializations.
  • +
  • Vector operations.
  • +
  • Table initializers.
  • +
  • Initialization of nested struct/union types.
  • +
  • Allocations of variable-length arrays or structs.
  • +
  • Allocations of C types with a size > 128 bytes or an +alignment > 8 bytes.
  • +
  • Conversions from lightuserdata to void *.
  • +
  • Pointer differences for element sizes that are not a power of +two.
  • +
  • Calls to C functions with aggregates passed or returned by +value.
  • +
  • Calls to ctype metamethods which are not plain functions.
  • +
  • ctype __newindex tables and non-string lookups in ctype +__index tables.
  • +
  • tostring() for cdata types.
  • +
  • Calls to ffi.cdef(), ffi.load() and +ffi.metatype().
  • +
+

+Other missing features: +

+
    +
  • Bit operations for 64 bit types.
  • +
  • Arithmetic for complex numbers.
  • +
  • Passing structs by value to vararg C functions.
  • +
  • C++ exception interoperability +does not extend to C functions called via the FFI, if the call is +compiled.
  • +
+
+
+ + + diff --git a/source/libs/luajit/LuaJIT-2.0.4/doc/ext_ffi_tutorial.html b/source/libs/luajit/LuaJIT-2.0.4/doc/ext_ffi_tutorial.html new file mode 100644 index 000000000..8f99bfb1b --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/doc/ext_ffi_tutorial.html @@ -0,0 +1,601 @@ + + + +FFI Tutorial + + + + + + + + + +
+Lua +
+ + +
+

+This page is intended to give you an overview of the features of the FFI +library by presenting a few use cases and guidelines. +

+

+This page makes no attempt to explain all of the FFI library, though. +You'll want to have a look at the ffi.* API +function reference and the FFI +semantics to learn more. +

+ +

Loading the FFI Library

+

+The FFI library is built into LuaJIT by default, but it's not loaded +and initialized by default. The suggested way to use the FFI library +is to add the following to the start of every Lua file that needs one +of its functions: +

+
+local ffi = require("ffi")
+
+

+Please note this doesn't define an ffi variable in the table +of globals — you really need to use the local variable. The +require function ensures the library is only loaded once. +

+

+Note: If you want to experiment with the FFI from the interactive prompt +of the command line executable, omit the local, as it doesn't +preserve local variables across lines. +

+ +

Accessing Standard System Functions

+

+The following code explains how to access standard system functions. +We slowly print two lines of dots by sleeping for 10 milliseconds +after each dot: +

+
+ 
+①
+
+
+
+
+
+②
+③
+④
+
+
+
+⑤
+
+
+
+
+
+⑥local ffi = require("ffi")
+ffi.cdef[[
+void Sleep(int ms);
+int poll(struct pollfd *fds, unsigned long nfds, int timeout);
+]]
+
+local sleep
+if ffi.os == "Windows" then
+  function sleep(s)
+    ffi.C.Sleep(s*1000)
+  end
+else
+  function sleep(s)
+    ffi.C.poll(nil, 0, s*1000)
+  end
+end
+
+for i=1,160 do
+  io.write("."); io.flush()
+  sleep(0.01)
+end
+io.write("\n")
+
+

+Here's the step-by-step explanation: +

+

+ This defines the +C library functions we're going to use. The part inside the +double-brackets (in green) is just standard C syntax. You can +usually get this info from the C header files or the +documentation provided by each C library or C compiler. +

+

+ The difficulty we're +facing here, is that there are different standards to choose from. +Windows has a simple Sleep() function. On other systems there +are a variety of functions available to achieve sub-second sleeps, but +with no clear consensus. Thankfully poll() can be used for +this task, too, and it's present on most non-Windows systems. The +check for ffi.os makes sure we use the Windows-specific +function only on Windows systems. +

+

+ Here we're wrapping the +call to the C function in a Lua function. This isn't strictly +necessary, but it's helpful to deal with system-specific issues only +in one part of the code. The way we're wrapping it ensures the check +for the OS is only done during initialization and not for every call. +

+

+ A more subtle point is +that we defined our sleep() function (for the sake of this +example) as taking the number of seconds, but accepting fractional +seconds. Multiplying this by 1000 gets us milliseconds, but that still +leaves it a Lua number, which is a floating-point value. Alas, the +Sleep() function only accepts an integer value. Luckily for +us, the FFI library automatically performs the conversion when calling +the function (truncating the FP value towards zero, like in C). +

+

+Some readers will notice that Sleep() is part of +KERNEL32.DLL and is also a stdcall function. So how +can this possibly work? The FFI library provides the ffi.C +default C library namespace, which allows calling functions from +the default set of libraries, like a C compiler would. Also, the +FFI library automatically detects stdcall functions, so you +don't need to declare them as such. +

+

+ The poll() +function takes a couple more arguments we're not going to use. You can +simply use nil to pass a NULL pointer and 0 +for the nfds parameter. Please note that the +number 0 does not convert to a pointer value, +unlike in C++. You really have to pass pointers to pointer arguments +and numbers to number arguments. +

+

+The page on FFI semantics has all +of the gory details about +conversions between Lua +objects and C types. For the most part you don't have to deal +with this, as it's performed automatically and it's carefully designed +to bridge the semantic differences between Lua and C. +

+

+ Now that we have defined +our own sleep() function, we can just call it from plain Lua +code. That wasn't so bad, huh? Turning these boring animated dots into +a fascinating best-selling game is left as an exercise for the reader. +:-) +

+ +

Accessing the zlib Compression Library

+

+The following code shows how to access the zlib compression library from Lua code. +We'll define two convenience wrapper functions that take a string and +compress or uncompress it to another string: +

+
+ 
+①
+
+
+
+
+
+
+②
+
+
+③
+
+④
+
+
+⑤
+
+
+⑥
+
+
+
+
+
+
+
+⑦local ffi = require("ffi")
+ffi.cdef[[
+unsigned long compressBound(unsigned long sourceLen);
+int compress2(uint8_t *dest, unsigned long *destLen,
+	      const uint8_t *source, unsigned long sourceLen, int level);
+int uncompress(uint8_t *dest, unsigned long *destLen,
+	       const uint8_t *source, unsigned long sourceLen);
+]]
+local zlib = ffi.load(ffi.os == "Windows" and "zlib1" or "z")
+
+local function compress(txt)
+  local n = zlib.compressBound(#txt)
+  local buf = ffi.new("uint8_t[?]", n)
+  local buflen = ffi.new("unsigned long[1]", n)
+  local res = zlib.compress2(buf, buflen, txt, #txt, 9)
+  assert(res == 0)
+  return ffi.string(buf, buflen[0])
+end
+
+local function uncompress(comp, n)
+  local buf = ffi.new("uint8_t[?]", n)
+  local buflen = ffi.new("unsigned long[1]", n)
+  local res = zlib.uncompress(buf, buflen, comp, #comp)
+  assert(res == 0)
+  return ffi.string(buf, buflen[0])
+end
+
+-- Simple test code.
+local txt = string.rep("abcd", 1000)
+print("Uncompressed size: ", #txt)
+local c = compress(txt)
+print("Compressed size: ", #c)
+local txt2 = uncompress(c, #txt)
+assert(txt2 == txt)
+
+

+Here's the step-by-step explanation: +

+

+ This defines some of the +C functions provided by zlib. For the sake of this example, some +type indirections have been reduced and it uses the pre-defined +fixed-size integer types, while still adhering to the zlib API/ABI. +

+

+ This loads the zlib shared +library. On POSIX systems it's named libz.so and usually +comes pre-installed. Since ffi.load() automatically adds any +missing standard prefixes/suffixes, we can simply load the +"z" library. On Windows it's named zlib1.dll and +you'll have to download it first from the +» zlib site. The check for +ffi.os makes sure we pass the right name to +ffi.load(). +

+

+ First, the maximum size of +the compression buffer is obtained by calling the +zlib.compressBound function with the length of the +uncompressed string. The next line allocates a byte buffer of this +size. The [?] in the type specification indicates a +variable-length array (VLA). The actual number of elements of this +array is given as the 2nd argument to ffi.new(). +

+

+ This may look strange at +first, but have a look at the declaration of the compress2 +function from zlib: the destination length is defined as a pointer! +This is because you pass in the maximum buffer size and get back the +actual length that was used. +

+

+In C you'd pass in the address of a local variable +(&buflen). But since there's no address-of operator in +Lua, we'll just pass in a one-element array. Conveniently it can be +initialized with the maximum buffer size in one step. Calling the +actual zlib.compress2 function is then straightforward. +

+

+ We want to return the +compressed data as a Lua string, so we'll use ffi.string(). +It needs a pointer to the start of the data and the actual length. The +length has been returned in the buflen array, so we'll just +get it from there. +

+

+Note that since the function returns now, the buf and +buflen variables will eventually be garbage collected. This +is fine, because ffi.string() has copied the contents to a +newly created (interned) Lua string. If you plan to call this function +lots of times, consider reusing the buffers and/or handing back the +results in buffers instead of strings. This will reduce the overhead +for garbage collection and string interning. +

+

+ The uncompress +functions does the exact opposite of the compress function. +The compressed data doesn't include the size of the original string, +so this needs to be passed in. Otherwise no surprises here. +

+

+ The code, that makes use +of the functions we just defined, is just plain Lua code. It doesn't +need to know anything about the LuaJIT FFI — the convenience +wrapper functions completely hide it. +

+

+One major advantage of the LuaJIT FFI is that you are now able to +write those wrappers in Lua. And at a fraction of the time it +would cost you to create an extra C module using the Lua/C API. +Many of the simpler C functions can probably be used directly +from your Lua code, without any wrappers. +

+

+Side note: the zlib API uses the long type for passing +lengths and sizes around. But all those zlib functions actually only +deal with 32 bit values. This is an unfortunate choice for a +public API, but may be explained by zlib's history — we'll just +have to deal with it. +

+

+First, you should know that a long is a 64 bit type e.g. +on POSIX/x64 systems, but a 32 bit type on Windows/x64 and on +32 bit systems. Thus a long result can be either a plain +Lua number or a boxed 64 bit integer cdata object, depending on +the target system. +

+

+Ok, so the ffi.* functions generally accept cdata objects +wherever you'd want to use a number. That's why we get a away with +passing n to ffi.string() above. But other Lua +library functions or modules don't know how to deal with this. So for +maximum portability one needs to use tonumber() on returned +long results before passing them on. Otherwise the +application might work on some systems, but would fail in a POSIX/x64 +environment. +

+ +

Defining Metamethods for a C Type

+

+The following code explains how to define metamethods for a C type. +We define a simple point type and add some operations to it: +

+
+ 
+①
+
+
+
+②
+
+③
+
+④
+
+
+
+⑤
+
+⑥local ffi = require("ffi")
+ffi.cdef[[
+typedef struct { double x, y; } point_t;
+]]
+
+local point
+local mt = {
+  __add = function(a, b) return point(a.x+b.x, a.y+b.y) end,
+  __len = function(a) return math.sqrt(a.x*a.x + a.y*a.y) end,
+  __index = {
+    area = function(a) return a.x*a.x + a.y*a.y end,
+  },
+}
+point = ffi.metatype("point_t", mt)
+
+local a = point(3, 4)
+print(a.x, a.y)  --> 3  4
+print(#a)        --> 5
+print(a:area())  --> 25
+local b = a + point(0.5, 8)
+print(#b)        --> 12.5
+
+

+Here's the step-by-step explanation: +

+

+ This defines the C type for a +two-dimensional point object. +

+

+ We have to declare the variable +holding the point constructor first, because it's used inside of a +metamethod. +

+

+ Let's define an __add +metamethod which adds the coordinates of two points and creates a new +point object. For simplicity, this function assumes that both arguments +are points. But it could be any mix of objects, if at least one operand +is of the required type (e.g. adding a point plus a number or vice +versa). Our __len metamethod returns the distance of a point to +the origin. +

+

+ If we run out of operators, we can +define named methods, too. Here the __index table defines an +area function. For custom indexing needs, one might want to +define __index and __newindex functions instead. +

+

+ This associates the metamethods with +our C type. This only needs to be done once. For convenience, a +constructor is returned by +ffi.metatype(). +We're not required to use it, though. The original C type can still +be used e.g. to create an array of points. The metamethods automatically +apply to any and all uses of this type. +

+

+Please note that the association with a metatable is permanent and +the metatable must not be modified afterwards! Ditto for the +__index table. +

+

+ Here are some simple usage examples +for the point type and their expected results. The pre-defined +operations (such as a.x) can be freely mixed with the newly +defined metamethods. Note that area is a method and must be +called with the Lua syntax for methods: a:area(), not +a.area(). +

+

+The C type metamethod mechanism is most useful when used in +conjunction with C libraries that are written in an object-oriented +style. Creators return a pointer to a new instance and methods take an +instance pointer as the first argument. Sometimes you can just point +__index to the library namespace and __gc to the +destructor and you're done. But often enough you'll want to add +convenience wrappers, e.g. to return actual Lua strings or when +returning multiple values. +

+

+Some C libraries only declare instance pointers as an opaque +void * type. In this case you can use a fake type for all +declarations, e.g. a pointer to a named (incomplete) struct will do: +typedef struct foo_type *foo_handle. The C side doesn't +know what you declare with the LuaJIT FFI, but as long as the underlying +types are compatible, everything still works. +

+ +

Translating C Idioms

+

+Here's a list of common C idioms and their translation to the +LuaJIT FFI: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdiomC codeLua code
Pointer dereference
int *p;
x = *p;
*p = y;
x = p[0]
p[0] = y
Pointer indexing
int i, *p;
x = p[i];
p[i+1] = y;
x = p[i]
p[i+1] = y
Array indexing
int i, a[];
x = a[i];
a[i+1] = y;
x = a[i]
a[i+1] = y
struct/union dereference
struct foo s;
x = s.field;
s.field = y;
x = s.field
s.field = y
struct/union pointer deref.
struct foo *sp;
x = sp->field;
sp->field = y;
x = s.field
s.field = y
Pointer arithmetic
int i, *p;
x = p + i;
y = p - i;
x = p + i
y = p - i
Pointer difference
int *p1, *p2;
x = p1 - p2;x = p1 - p2
Array element pointer
int i, a[];
x = &a[i];x = a+i
Cast pointer to address
int *p;
x = (intptr_t)p;x = tonumber(
 ffi.cast("intptr_t",
          p))
Functions with outargs
void foo(int *inoutlen);
int len = x;
foo(&len);
y = len;
local len =
  ffi.new("int[1]", x)
foo(len)
y = len[0]
Vararg conversions
int printf(char *fmt, ...);
printf("%g", 1.0);
printf("%d", 1);
 
printf("%g", 1);
printf("%d",
  ffi.new("int", 1))
+ +

To Cache or Not to Cache

+

+It's a common Lua idiom to cache library functions in local variables +or upvalues, e.g.: +

+
+local byte, char = string.byte, string.char
+local function foo(x)
+  return char(byte(x)+1)
+end
+
+

+This replaces several hash-table lookups with a (faster) direct use of +a local or an upvalue. This is less important with LuaJIT, since the +JIT compiler optimizes hash-table lookups a lot and is even able to +hoist most of them out of the inner loops. It can't eliminate +all of them, though, and it saves some typing for often-used +functions. So there's still a place for this, even with LuaJIT. +

+

+The situation is a bit different with C function calls via the +FFI library. The JIT compiler has special logic to eliminate all +of the lookup overhead for functions resolved from a +C library namespace! +Thus it's not helpful and actually counter-productive to cache +individual C functions like this: +

+
+local funca, funcb = ffi.C.funca, ffi.C.funcb -- Not helpful!
+local function foo(x, n)
+  for i=1,n do funcb(funca(x, i), 1) end
+end
+
+

+This turns them into indirect calls and generates bigger and slower +machine code. Instead you'll want to cache the namespace itself and +rely on the JIT compiler to eliminate the lookups: +

+
+local C = ffi.C          -- Instead use this!
+local function foo(x, n)
+  for i=1,n do C.funcb(C.funca(x, i), 1) end
+end
+
+

+This generates both shorter and faster code. So don't cache +C functions, but do cache namespaces! Most often the +namespace is already in a local variable at an outer scope, e.g. from +local lib = ffi.load(...). Note that copying +it to a local variable in the function scope is unnecessary. +

+
+
+ + + diff --git a/source/libs/luajit/LuaJIT-2.0.4/doc/ext_jit.html b/source/libs/luajit/LuaJIT-2.0.4/doc/ext_jit.html new file mode 100644 index 000000000..27351dd64 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/doc/ext_jit.html @@ -0,0 +1,199 @@ + + + +jit.* Library + + + + + + + + +
+Lua +
+ + +
+

+The functions in this built-in module control the behavior of the JIT +compiler engine. Note that JIT-compilation is fully automatic — +you probably won't need to use any of the following functions unless +you have special needs. +

+ +

jit.on()
+jit.off()

+

+Turns the whole JIT compiler on (default) or off. +

+

+These functions are typically used with the command line options +-j on or -j off. +

+ +

jit.flush()

+

+Flushes the whole cache of compiled code. +

+ +

jit.on(func|true [,true|false])
+jit.off(func|true [,true|false])
+jit.flush(func|true [,true|false])

+

+jit.on enables JIT compilation for a Lua function (this is +the default). +

+

+jit.off disables JIT compilation for a Lua function and +flushes any already compiled code from the code cache. +

+

+jit.flush flushes the code, but doesn't affect the +enable/disable status. +

+

+The current function, i.e. the Lua function calling this library +function, can also be specified by passing true as the first +argument. +

+

+If the second argument is true, JIT compilation is also +enabled, disabled or flushed recursively for all sub-functions of a +function. With false only the sub-functions are affected. +

+

+The jit.on and jit.off functions only set a flag +which is checked when the function is about to be compiled. They do +not trigger immediate compilation. +

+

+Typical usage is jit.off(true, true) in the main chunk +of a module to turn off JIT compilation for the whole module for +debugging purposes. +

+ +

jit.flush(tr)

+

+Flushes the root trace, specified by its number, and all of its side +traces from the cache. The code for the trace will be retained as long +as there are any other traces which link to it. +

+ +

status, ... = jit.status()

+

+Returns the current status of the JIT compiler. The first result is +either true or false if the JIT compiler is turned +on or off. The remaining results are strings for CPU-specific features +and enabled optimizations. +

+ +

jit.version

+

+Contains the LuaJIT version string. +

+ +

jit.version_num

+

+Contains the version number of the LuaJIT core. Version xx.yy.zz +is represented by the decimal number xxyyzz. +

+ +

jit.os

+

+Contains the target OS name: +"Windows", "Linux", "OSX", "BSD", "POSIX" or "Other". +

+ +

jit.arch

+

+Contains the target architecture name: +"x86", "x64", "arm", "ppc", "ppcspe", or "mips". +

+ +

jit.opt.* — JIT compiler optimization control

+

+This sub-module provides the backend for the -O command line +option. +

+

+You can also use it programmatically, e.g.: +

+
+jit.opt.start(2) -- same as -O2
+jit.opt.start("-dce")
+jit.opt.start("hotloop=10", "hotexit=2")
+
+

+Unlike in LuaJIT 1.x, the module is built-in and +optimization is turned on by default! +It's no longer necessary to run require("jit.opt").start(), +which was one of the ways to enable optimization. +

+ +

jit.util.* — JIT compiler introspection

+

+This sub-module holds functions to introspect the bytecode, generated +traces, the IR and the generated machine code. The functionality +provided by this module is still in flux and therefore undocumented. +

+

+The debug modules -jbc, -jv and -jdump make +extensive use of these functions. Please check out their source code, +if you want to know more. +

+
+
+ + + diff --git a/source/libs/luajit/LuaJIT-2.0.4/doc/extensions.html b/source/libs/luajit/LuaJIT-2.0.4/doc/extensions.html new file mode 100644 index 000000000..e9cd136cc --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/doc/extensions.html @@ -0,0 +1,408 @@ + + + +Extensions + + + + + + + + + +
+Lua +
+ + +
+

+LuaJIT is fully upwards-compatible with Lua 5.1. It supports all +» standard Lua +library functions and the full set of +» Lua/C API +functions. +

+

+LuaJIT is also fully ABI-compatible to Lua 5.1 at the linker/dynamic +loader level. This means you can compile a C module against the +standard Lua headers and load the same shared library from either Lua +or LuaJIT. +

+

+LuaJIT extends the standard Lua VM with new functionality and adds +several extension modules. Please note this page is only about +functional enhancements and not about performance enhancements, +such as the optimized VM, the faster interpreter or the JIT compiler. +

+ +

Extensions Modules

+

+LuaJIT comes with several built-in extension modules: +

+ +

bit.* — Bitwise operations

+

+LuaJIT supports all bitwise operations as defined by +» Lua BitOp: +

+
+bit.tobit  bit.tohex  bit.bnot    bit.band bit.bor  bit.bxor
+bit.lshift bit.rshift bit.arshift bit.rol  bit.ror  bit.bswap
+
+

+This module is a LuaJIT built-in — you don't need to download or +install Lua BitOp. The Lua BitOp site has full documentation for all +» Lua BitOp API functions. +

+

+Please make sure to require the module before using any of +its functions: +

+
+local bit = require("bit")
+
+

+An already installed Lua BitOp module is ignored by LuaJIT. +This way you can use bit operations from both Lua and LuaJIT on a +shared installation. +

+ +

ffi.* — FFI library

+

+The FFI library allows calling external +C functions and the use of C data structures from pure Lua +code. +

+ +

jit.* — JIT compiler control

+

+The functions in this module +control the behavior of the JIT compiler engine. +

+ +

C API extensions

+

+LuaJIT adds some +extra functions to the Lua/C API. +

+ +

Enhanced Standard Library Functions

+ +

xpcall(f, err [,args...]) passes arguments

+

+Unlike the standard implementation in Lua 5.1, xpcall() +passes any arguments after the error function to the function +which is called in a protected context. +

+ +

loadfile() etc. handle UTF-8 source code

+

+Non-ASCII characters are handled transparently by the Lua source code parser. +This allows the use of UTF-8 characters in identifiers and strings. +A UTF-8 BOM is skipped at the start of the source code. +

+ +

tostring() etc. canonicalize NaN and ±Inf

+

+All number-to-string conversions consistently convert non-finite numbers +to the same strings on all platforms. NaN results in "nan", +positive infinity results in "inf" and negative infinity results +in "-inf". +

+ +

tonumber() etc. use builtin string to number conversion

+

+All string-to-number conversions consistently convert integer and +floating-point inputs in decimal and hexadecimal on all platforms. +strtod() is not used anymore, which avoids numerous +problems with poor C library implementations. The builtin conversion +function provides full precision according to the IEEE-754 standard, it +works independently of the current locale and it supports hex floating-point +numbers (e.g. 0x1.5p-3). +

+ +

string.dump(f [,strip]) generates portable bytecode

+

+An extra argument has been added to string.dump(). If set to +true, 'stripped' bytecode without debug information is +generated. This speeds up later bytecode loading and reduces memory +usage. See also the +-b command line option. +

+

+The generated bytecode is portable and can be loaded on any architecture +that LuaJIT supports, independent of word size or endianess. However the +bytecode compatibility versions must match. Bytecode stays compatible +for dot releases (x.y.0 → x.y.1), but may change with major or +minor releases (2.0 → 2.1) or between any beta release. Foreign +bytecode (e.g. from Lua 5.1) is incompatible and cannot be loaded. +

+ +

Enhanced PRNG for math.random()

+

+LuaJIT uses a Tausworthe PRNG with period 2^223 to implement +math.random() and math.randomseed(). The quality of +the PRNG results is much superior compared to the standard Lua +implementation which uses the platform-specific ANSI rand(). +

+

+The PRNG generates the same sequences from the same seeds on all +platforms and makes use of all bits in the seed argument. +math.random() without arguments generates 52 pseudo-random bits +for every call. The result is uniformly distributed between 0.0 and 1.0. +It's correctly scaled up and rounded for math.random(n [,m]) to +preserve uniformity. +

+ +

io.* functions handle 64 bit file offsets

+

+The file I/O functions in the standard io.* library handle +64 bit file offsets. In particular this means it's possible +to open files larger than 2 Gigabytes and to reposition or obtain +the current file position for offsets beyond 2 GB +(fp:seek() method). +

+ +

debug.* functions identify metamethods

+

+debug.getinfo() and lua_getinfo() also return information +about invoked metamethods. The namewhat field is set to +"metamethod" and the name field has the name of +the corresponding metamethod (e.g. "__index"). +

+ +

Fully Resumable VM

+

+The LuaJIT VM is fully resumable. This means you can yield from a +coroutine even across contexts, where this would not possible with +the standard Lua 5.1 VM: e.g. you can yield across pcall() +and xpcall(), across iterators and across metamethods. +

+ +

Extensions from Lua 5.2

+

+LuaJIT supports some language and library extensions from Lua 5.2. +Features that are unlikely to break existing code are unconditionally +enabled: +

+
    +
  • goto and ::labels::.
  • +
  • Hex escapes '\x3F' and '\*' escape in strings.
  • +
  • load(string|reader [, chunkname [,mode [,env]]]).
  • +
  • loadstring() is an alias for load().
  • +
  • loadfile(filename [,mode [,env]]).
  • +
  • math.log(x [,base]). +
  • string.rep(s, n [,sep]). +
  • string.format(): %q reversible. +%s checks __tostring. +%a and "%A added.
  • +
  • String matching pattern %g added.
  • +
  • io.read("*L").
  • +
  • io.lines() and file:lines() process +io.read() options.
  • +
  • os.exit(status|true|false [,close]).
  • +
  • package.searchpath(name, path [, sep [, rep]]).
  • +
  • package.loadlib(name, "*").
  • +
  • debug.getinfo() returns nparams and isvararg +for option "u".
  • +
  • debug.getlocal() accepts function instead of level.
  • +
  • debug.getlocal() and debug.setlocal() accept negative +indexes for varargs.
  • +
  • debug.getupvalue() and debug.setupvalue() handle +C functions.
  • +
  • debug.upvalueid() and debug.upvaluejoin().
  • +
  • Command line option -E.
  • +
  • Command line checks __tostring for errors.
  • +
+

+Other features are only enabled, if LuaJIT is built with +-DLUAJIT_ENABLE_LUA52COMPAT: +

+
    +
  • goto is a keyword and not a valid variable name anymore.
  • +
  • break can be placed anywhere. Empty statements (;;) +are allowed.
  • +
  • __lt, __le are invoked for mixed types.
  • +
  • __len for tables. rawlen() library function.
  • +
  • pairs() and ipairs() check for __pairs and +__ipairs.
  • +
  • coroutine.running() returns two results.
  • +
  • table.pack() and table.unpack() +(same as unpack()).
  • +
  • io.write() and file:write() return file handle +instead of true.
  • +
  • os.execute() and pipe:close() return detailed +exit status.
  • +
  • debug.setmetatable() returns object.
  • +
  • debug.getuservalue() and debug.setuservalue().
  • +
  • Remove math.mod(), string.gfind(). +
+

+Note: this provides only partial compatibility with Lua 5.2 at the +language and Lua library level. LuaJIT is API+ABI-compatible with +Lua 5.1, which prevents implementing features that would otherwise +break the Lua/C API and ABI (e.g. _ENV). +

+ +

C++ Exception Interoperability

+

+LuaJIT has built-in support for interoperating with C++ exceptions. +The available range of features depends on the target platform and +the toolchain used to compile LuaJIT: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PlatformCompilerInteroperability
POSIX/x64, DWARF2 unwindingGCC 4.3+Full
Other platforms, DWARF2 unwindingGCCLimited
Windows/x64MSVC or WinSDKFull
Windows/x86AnyNo
Other platformsOther compilersNo
+

+Full interoperability means: +

+
    +
  • C++ exceptions can be caught on the Lua side with pcall(), +lua_pcall() etc.
  • +
  • C++ exceptions will be converted to the generic Lua error +"C++ exception", unless you use the +C call wrapper feature.
  • +
  • It's safe to throw C++ exceptions across non-protected Lua frames +on the C stack. The contents of the C++ exception object +pass through unmodified.
  • +
  • Lua errors can be caught on the C++ side with catch(...). +The corresponding Lua error message can be retrieved from the Lua stack.
  • +
  • Throwing Lua errors across C++ frames is safe. C++ destructors +will be called.
  • +
+

+Limited interoperability means: +

+
    +
  • C++ exceptions can be caught on the Lua side with pcall(), +lua_pcall() etc.
  • +
  • C++ exceptions will be converted to the generic Lua error +"C++ exception", unless you use the +C call wrapper feature.
  • +
  • C++ exceptions will be caught by non-protected Lua frames and +are rethrown as a generic Lua error. The C++ exception object will +be destroyed.
  • +
  • Lua errors cannot be caught on the C++ side.
  • +
  • Throwing Lua errors across C++ frames will not call +C++ destructors.
  • +
+ +

+No interoperability means: +

+
    +
  • It's not safe to throw C++ exceptions across Lua frames.
  • +
  • C++ exceptions cannot be caught on the Lua side.
  • +
  • Lua errors cannot be caught on the C++ side.
  • +
  • Throwing Lua errors across C++ frames will not call +C++ destructors.
  • +
  • Additionally, on Windows/x86 with SEH-based C++ exceptions: +it's not safe to throw a Lua error across any frames containing +a C++ function with any try/catch construct or using variables with +(implicit) destructors. This also applies to any functions which may be +inlined in such a function. It doesn't matter whether lua_error() +is called inside or outside of a try/catch or whether any object actually +needs to be destroyed: the SEH chain is corrupted and this will eventually +lead to the termination of the process.
  • +
+
+
+ + + diff --git a/source/libs/luajit/LuaJIT-2.0.4/doc/faq.html b/source/libs/luajit/LuaJIT-2.0.4/doc/faq.html new file mode 100644 index 000000000..9902f0903 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/doc/faq.html @@ -0,0 +1,184 @@ + + + +Frequently Asked Questions (FAQ) + + + + + + + + + +
+Lua +
+ + +
+
+
Q: Where can I learn more about LuaJIT and Lua?
+
+ +
+ +
+
Q: Where can I learn more about the compiler technology used by LuaJIT?
+
+I'm planning to write more documentation about the internals of LuaJIT. +In the meantime, please use the following Google Scholar searches +to find relevant papers:
+Search for: » Trace Compiler
+Search for: » JIT Compiler
+Search for: » Dynamic Language Optimizations
+Search for: » SSA Form
+Search for: » Linear Scan Register Allocation
+Here is a list of the » innovative features in LuaJIT.
+And, you know, reading the source is of course the only way to enlightenment. :-) +
+
+ +
+
Q: Why do I get this error: "attempt to index global 'arg' (a nil value)"?
+Q: My vararg functions fail after switching to LuaJIT!
+
LuaJIT is compatible to the Lua 5.1 language standard. It doesn't +support the implicit arg parameter for old-style vararg +functions from Lua 5.0.
Please convert your code to the +» Lua 5.1 +vararg syntax.
+
+ +
+
Q: Why do I get this error: "bad FPU precision"?
+
Q: I get weird behavior after initializing Direct3D.
+
Q: Some FPU operations crash after I load a Delphi DLL.
+
+
+ +DirectX/Direct3D (up to version 9) sets the x87 FPU to single-precision +mode by default. This violates the Windows ABI and interferes with the +operation of many programs — LuaJIT is affected, too. Please make +sure you always use the D3DCREATE_FPU_PRESERVE flag when +initializing Direct3D.
+ +Direct3D version 10 or higher do not show this behavior anymore. +Consider testing your application with older versions, too.
+ +Similarly, the Borland/Delphi runtime modifies the FPU control word and +enables FP exceptions. Of course this violates the Windows ABI, too. +Please check the Delphi docs for the Set8087CW method. + +
+ +
+
Q: Sometimes Ctrl-C fails to stop my Lua program. Why?
+
The interrupt signal handler sets a Lua debug hook. But this is +currently ignored by compiled code (this will eventually be fixed). If +your program is running in a tight loop and never falls back to the +interpreter, the debug hook never runs and can't throw the +"interrupted!" error.
In the meantime you have to press Ctrl-C +twice to get stop your program. That's similar to when it's stuck +running inside a C function under the Lua interpreter.
+
+ +
+
Q: Why doesn't my favorite power-patch for Lua apply against LuaJIT?
+
Because it's a completely redesigned VM and has very little code +in common with Lua anymore. Also, if the patch introduces changes to +the Lua semantics, these would need to be reflected everywhere in the +VM, from the interpreter up to all stages of the compiler.
Please +use only standard Lua language constructs. For many common needs you +can use source transformations or use wrapper or proxy functions. +The compiler will happily optimize away such indirections.
+
+ +
+
Q: Lua runs everywhere. Why doesn't LuaJIT support my CPU?
+
Because it's a compiler — it needs to generate native +machine code. This means the code generator must be ported to each +architecture. And the fast interpreter is written in assembler and +must be ported, too. This is quite an undertaking.
+The install documentation shows the supported +architectures. Other architectures will follow based on sufficient user +demand and/or sponsoring.
+
+ +
+
Q: When will feature X be added? When will the next version be released?
+
When it's ready.
+C'mon, it's open source — I'm doing it on my own time and you're +getting it for free. You can either contribute a patch or sponsor +the development of certain features, if they are important to you. +
+
+
+
+ + + diff --git a/source/libs/luajit/LuaJIT-2.0.3/doc/img/contact.png b/source/libs/luajit/LuaJIT-2.0.4/doc/img/contact.png similarity index 100% rename from source/libs/luajit/LuaJIT-2.0.3/doc/img/contact.png rename to source/libs/luajit/LuaJIT-2.0.4/doc/img/contact.png diff --git a/source/libs/luajit/LuaJIT-2.0.4/doc/install.html b/source/libs/luajit/LuaJIT-2.0.4/doc/install.html new file mode 100644 index 000000000..7a878b1cf --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/doc/install.html @@ -0,0 +1,646 @@ + + + +Installation + + + + + + + + + +
+Lua +
+ + +
+

+LuaJIT is only distributed as a source package. This page explains +how to build and install LuaJIT with different operating systems +and C compilers. +

+

+For the impatient (on POSIX systems): +

+
+make && sudo make install
+
+

+LuaJIT currently builds out-of-the box on most systems. +Here's the compatibility matrix for the supported combinations of +operating systems, CPUs and compilers: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CPU / OSLinux or
Android
*BSD, OtherOSX 10.4+ or
iOS 3.0+
Windows
XP/Vista/7
x86 (32 bit)GCC 4.x
GCC 3.4
GCC 4.x
GCC 3.4
GCC 4.x
GCC 3.4
MSVC, MSVC/EE
WinSDK
MinGW, Cygwin
x64 (64 bit)GCC 4.xORBIS (PS4)GCC 4.xMSVC + SDK v7.0
WinSDK v7.0
ARMv5+
ARM9E+
GCC 4.2+GCC 4.2+
PSP2 (PS VITA)
GCC 4.2+ 
PPCGCC 4.3+GCC 4.3+
GCC 4.1 (PS3)
 XEDK (Xbox 360)
PPC/e500v2GCC 4.3+GCC 4.3+  
MIPSGCC 4.3+GCC 4.3+  
+ +

Configuring LuaJIT

+

+The standard configuration should work fine for most installations. +Usually there is no need to tweak the settings. The following files +hold all user-configurable settings: +

+
    +
  • src/luaconf.h sets some configuration variables.
  • +
  • Makefile has settings for installing LuaJIT (POSIX +only).
  • +
  • src/Makefile has settings for compiling LuaJIT +under POSIX, MinGW or Cygwin.
  • +
  • src/msvcbuild.bat has settings for compiling LuaJIT with +MSVC or WinSDK.
  • +
+

+Please read the instructions given in these files, before changing +any settings. +

+ +

POSIX Systems (Linux, OSX, *BSD etc.)

+

Prerequisites

+

+Depending on your distribution, you may need to install a package for +GCC, the development headers and/or a complete SDK. E.g. on a current +Debian/Ubuntu, install libc6-dev with the package manager. +

+

+Download the current source package of LuaJIT (pick the .tar.gz), +if you haven't already done so. Move it to a directory of your choice, +open a terminal window and change to this directory. Now unpack the archive +and change to the newly created directory: +

+
+tar zxf LuaJIT-2.0.4.tar.gz
+cd LuaJIT-2.0.4
+

Building LuaJIT

+

+The supplied Makefiles try to auto-detect the settings needed for your +operating system and your compiler. They need to be run with GNU Make, +which is probably the default on your system, anyway. Simply run: +

+
+make
+
+

+This always builds a native x86, x64 or PPC binary, depending on the host OS +you're running this command on. Check the section on +cross-compilation for more options. +

+

+By default, modules are only searched under the prefix /usr/local. +You can add an extra prefix to the search paths by appending the +PREFIX option, e.g.: +

+
+make PREFIX=/home/myself/lj2
+
+

+Note for OSX: if the MACOSX_DEPLOYMENT_TARGET environment +variable is not set, then it's forced to 10.4. +

+

Installing LuaJIT

+

+The top-level Makefile installs LuaJIT by default under +/usr/local, i.e. the executable ends up in +/usr/local/bin and so on. You need root privileges +to write to this path. So, assuming sudo is installed on your system, +run the following command and enter your sudo password: +

+
+sudo make install
+
+

+Otherwise specify the directory prefix as an absolute path, e.g.: +

+
+make install PREFIX=/home/myself/lj2
+
+

+Obviously the prefixes given during build and installation need to be the same. +

+ +

Windows Systems

+

Prerequisites

+

+Either install one of the open source SDKs +(» MinGW or +» Cygwin), which come with a modified +GCC plus the required development headers. +

+

+Or install Microsoft's Visual C++ (MSVC). The freely downloadable +» Express Edition +works just fine, but only contains an x86 compiler. +

+

+The freely downloadable +» Windows SDK +only comes with command line tools, but this is all you need to build LuaJIT. +It contains x86 and x64 compilers. +

+

+Next, download the source package and unpack it using an archive manager +(e.g. the Windows Explorer) to a directory of your choice. +

+

Building with MSVC

+

+Open a "Visual Studio .NET Command Prompt", cd to the +directory where you've unpacked the sources and run these commands: +

+
+cd src
+msvcbuild
+
+

+Then follow the installation instructions below. +

+

Building with the Windows SDK

+

+Open a "Windows SDK Command Shell" and select the x86 compiler: +

+
+setenv /release /x86
+
+

+Or select the x64 compiler: +

+
+setenv /release /x64
+
+

+Then cd to the directory where you've unpacked the sources +and run these commands: +

+
+cd src
+msvcbuild
+
+

+Then follow the installation instructions below. +

+

Building with MinGW or Cygwin

+

+Open a command prompt window and make sure the MinGW or Cygwin programs +are in your path. Then cd to the directory where +you've unpacked the sources and run this command for MinGW: +

+
+mingw32-make
+
+

+Or this command for Cygwin: +

+
+make
+
+

+Then follow the installation instructions below. +

+

Installing LuaJIT

+

+Copy luajit.exe and lua51.dll (built in the src +directory) to a newly created directory (any location is ok). +Add lua and lua\jit directories below it and copy +all Lua files from the src\jit directory of the distribution +to the latter directory. +

+

+There are no hardcoded +absolute path names — all modules are loaded relative to the +directory where luajit.exe is installed +(see src/luaconf.h). +

+ +

Cross-compiling LuaJIT

+

+The GNU Makefile-based build system allows cross-compiling on any host +for any supported target, as long as both architectures have the same +pointer size. If you want to cross-compile to any 32 bit target on an +x64 OS, you need to install the multilib development package (e.g. +libc6-dev-i386 on Debian/Ubuntu) and build a 32 bit host part +(HOST_CC="gcc -m32"). +

+

+You need to specify TARGET_SYS whenever the host OS and the +target OS differ, or you'll get assembler or linker errors. E.g. if +you're compiling on a Windows or OSX host for embedded Linux or Android, +you need to add TARGET_SYS=Linux to the examples below. For a +minimal target OS, you may need to disable the built-in allocator in +src/Makefile and use TARGET_SYS=Other. The examples +below only show some popular targets — please check the comments +in src/Makefile for more details. +

+
+# Cross-compile to a 32 bit binary on a multilib x64 OS
+make CC="gcc -m32"
+
+# Cross-compile on Debian/Ubuntu for Windows (mingw32 package)
+make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows
+
+

+The CROSS prefix allows specifying a standard GNU cross-compile +toolchain (Binutils, GCC and a matching libc). The prefix may vary +depending on the --target the toolchain was built for (note the +CROSS prefix has a trailing "-"). The examples below +use the canonical toolchain triplets for Linux. +

+

+Since there's often no easy way to detect CPU features at runtime, it's +important to compile with the proper CPU or architecture settings. You +can specify these when building the toolchain yourself. Or add +-mcpu=... or -march=... to TARGET_CFLAGS. For +ARM it's important to have the correct -mfloat-abi=... setting, +too. Otherwise LuaJIT may not run at the full performance of your target +CPU. +

+
+# ARM soft-float
+make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
+     TARGET_CFLAGS="-mfloat-abi=soft"
+
+# ARM soft-float ABI with VFP (example for Cortex-A8)
+make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
+     TARGET_CFLAGS="-mcpu=cortex-a8 -mfloat-abi=softfp"
+
+# ARM hard-float ABI with VFP (armhf, requires recent toolchain)
+make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabihf-
+
+# PPC
+make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu-
+# PPC/e500v2 (fast interpreter only)
+make HOST_CC="gcc -m32" CROSS=powerpc-e500v2-linux-gnuspe-
+
+# MIPS big-endian
+make HOST_CC="gcc -m32" CROSS=mips-linux-
+# MIPS little-endian
+make HOST_CC="gcc -m32" CROSS=mipsel-linux-
+
+

+You can cross-compile for Android using the » Android NDK. +The environment variables need to match the install locations and the +desired target platform. E.g. Android 4.0 corresponds to ABI level 14. +For details check the folder docs in the NDK directory. +

+

+Only a few common variations for the different CPUs, ABIs and platforms +are listed. Please use your own judgement for which combination you want +to build/deploy or which lowest common denominator you want to pick: +

+
+# Android/ARM, armeabi (ARMv5TE soft-float), Android 2.2+ (Froyo)
+NDK=/opt/android/ndk
+NDKABI=8
+NDKVER=$NDK/toolchains/arm-linux-androideabi-4.6
+NDKP=$NDKVER/prebuilt/linux-x86/bin/arm-linux-androideabi-
+NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm"
+make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF"
+
+# Android/ARM, armeabi-v7a (ARMv7 VFP), Android 4.0+ (ICS)
+NDK=/opt/android/ndk
+NDKABI=14
+NDKVER=$NDK/toolchains/arm-linux-androideabi-4.6
+NDKP=$NDKVER/prebuilt/linux-x86/bin/arm-linux-androideabi-
+NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm"
+NDKARCH="-march=armv7-a -mfloat-abi=softfp -Wl,--fix-cortex-a8"
+make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF $NDKARCH"
+
+# Android/MIPS, mips (MIPS32R1 hard-float), Android 4.0+ (ICS)
+NDK=/opt/android/ndk
+NDKABI=14
+NDKVER=$NDK/toolchains/mipsel-linux-android-4.6
+NDKP=$NDKVER/prebuilt/linux-x86/bin/mipsel-linux-android-
+NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-mips"
+make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF"
+
+# Android/x86, x86 (i686 SSE3), Android 4.0+ (ICS)
+NDK=/opt/android/ndk
+NDKABI=14
+NDKVER=$NDK/toolchains/x86-4.6
+NDKP=$NDKVER/prebuilt/linux-x86/bin/i686-linux-android-
+NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-x86"
+make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF"
+
+

+You can cross-compile for iOS 3.0+ (iPhone/iPad) using the » iOS SDK. +The environment variables need to match the iOS SDK version: +

+

+Note: the JIT compiler is disabled for iOS, because regular iOS Apps +are not allowed to generate code at runtime. You'll only get the performance +of the LuaJIT interpreter on iOS. This is still faster than plain Lua, but +much slower than the JIT compiler. Please complain to Apple, not me. +Or use Android. :-p +

+
+IXCODE=`xcode-select -print-path`
+ISDK=$IXCODE/Platforms/iPhoneOS.platform/Developer
+ISDKVER=iPhoneOS6.0.sdk
+ISDKP=$ISDK/usr/bin/
+ISDKF="-arch armv7 -isysroot $ISDK/SDKs/$ISDKVER"
+make HOST_CC="gcc -m32 -arch i386" CROSS=$ISDKP TARGET_FLAGS="$ISDKF" \
+     TARGET_SYS=iOS
+
+ +

Cross-compiling for consoles

+

+Building LuaJIT for consoles requires both a supported host compiler +(x86 or x64) and a cross-compiler (to PPC or ARM) from the official +console SDK. +

+

+Due to restrictions on consoles, the JIT compiler is disabled and only +the fast interpreter is built. This is still faster than plain Lua, +but much slower than the JIT compiler. The FFI is disabled, too, since +it's not very useful in such an environment. +

+

+The following commands build a static library libluajit.a, +which can be linked against your game, just like the Lua library. +

+

+To cross-compile for PS3 from a Linux host (requires +32 bit GCC, i.e. multilib Linux/x64) or a Windows host (requires +32 bit MinGW), run this command: +

+
+make HOST_CC="gcc -m32" CROSS=ppu-lv2-
+
+

+To cross-compile for PS4 from a Windows host, +open a "Visual Studio .NET Command Prompt" (64 bit host compiler), +cd to the directory where you've unpacked the sources and +run the following commands: +

+
+cd src
+ps4build
+
+

+To cross-compile for PS Vita from a Windows host, +open a "Visual Studio .NET Command Prompt" (32 bit host compiler), +cd to the directory where you've unpacked the sources and +run the following commands: +

+
+cd src
+psvitabuild
+
+

+To cross-compile for Xbox 360 from a Windows host, +open a "Visual Studio .NET Command Prompt" (32 bit host compiler), +cd to the directory where you've unpacked the sources and run +the following commands: +

+
+cd src
+xedkbuild
+
+ +

Embedding LuaJIT

+

+LuaJIT is API-compatible with Lua 5.1. If you've already embedded Lua +into your application, you probably don't need to do anything to switch +to LuaJIT, except link with a different library: +

+
    +
  • It's strongly suggested to build LuaJIT separately using the supplied +build system. Please do not attempt to integrate the individual +source files into your build tree. You'll most likely get the internal build +dependencies wrong or mess up the compiler flags. Treat LuaJIT like any +other external library and link your application with either the dynamic +or static library, depending on your needs.
  • +
  • If you want to load C modules compiled for plain Lua +with require(), you need to make sure the public symbols +(e.g. lua_pushnumber) are exported, too: +
    • On POSIX systems you can either link to the shared library +or link the static library into your application. In the latter case +you'll need to export all public symbols from your main executable +(e.g. -Wl,-E on Linux) and add the external dependencies +(e.g. -lm -ldl on Linux).
    • +
    • Since Windows symbols are bound to a specific DLL name, you need to +link to the lua51.dll created by the LuaJIT build (do not rename +the DLL). You may link LuaJIT statically on Windows only if you don't +intend to load Lua/C modules at runtime. +
    +
  • +
  • +If you're building a 64 bit application on OSX which links directly or +indirectly against LuaJIT, you need to link your main executable +with these flags: +
    +-pagezero_size 10000 -image_base 100000000
    +
    +Also, it's recommended to rebase all (self-compiled) shared libraries +which are loaded at runtime on OSX/x64 (e.g. C extension modules for Lua). +See: man rebase +
  • +
+

Additional hints for initializing LuaJIT using the C API functions:

+
    +
  • Here's a +» simple example +for embedding Lua or LuaJIT into your application.
  • +
  • Make sure you use luaL_newstate. Avoid using +lua_newstate, since this uses the (slower) default memory +allocator from your system (no support for this on x64).
  • +
  • Make sure you use luaL_openlibs and not the old Lua 5.0 style +of calling luaopen_base etc. directly.
  • +
  • To change or extend the list of standard libraries to load, copy +src/lib_init.c to your project and modify it accordingly. +Make sure the jit library is loaded or the JIT compiler +will not be activated.
  • +
  • The bit.* module for bitwise operations +is already built-in. There's no need to statically link +» Lua BitOp to your application.
  • +
+ +

Hints for Distribution Maintainers

+

+The LuaJIT build system has extra provisions for the needs of most +POSIX-based distributions. If you're a package maintainer for +a distribution, please make use of these features and +avoid patching, subverting, autotoolizing or messing up the build system +in unspeakable ways. +

+

+There should be absolutely no need to patch luaconf.h or any +of the Makefiles. And please do not hand-pick files for your packages — +simply use whatever make install creates. There's a reason +for all of the files and directories it creates. +

+

+The build system uses GNU make and auto-detects most settings based on +the host you're building it on. This should work fine for native builds, +even when sandboxed. You may need to pass some of the following flags to +both the make and the make install command lines +for a regular distribution build: +

+
    +
  • PREFIX overrides the installation path and should usually +be set to /usr. Setting this also changes the module paths and +the paths needed to locate the shared library.
  • +
  • DESTDIR is an absolute path which allows you to install +to a shadow tree instead of the root tree of the build system.
  • +
  • MULTILIB sets the architecture-specific library path component +for multilib systems. The default is lib.
  • +
  • Have a look at the top-level Makefile and src/Makefile +for additional variables to tweak. The following variables may be +overridden, but it's not recommended, except for special needs +like cross-builds: +BUILDMODE, CC, HOST_CC, STATIC_CC, DYNAMIC_CC, CFLAGS, HOST_CFLAGS, +TARGET_CFLAGS, LDFLAGS, HOST_LDFLAGS, TARGET_LDFLAGS, TARGET_SHLDFLAGS, +TARGET_FLAGS, LIBS, HOST_LIBS, TARGET_LIBS, CROSS, HOST_SYS, TARGET_SYS +
  • +
+

+The build system has a special target for an amalgamated build, i.e. +make amalg. This compiles the LuaJIT core as one huge C file +and allows GCC to generate faster and shorter code. Alas, this requires +lots of memory during the build. This may be a problem for some users, +that's why it's not enabled by default. But it shouldn't be a problem for +most build farms. It's recommended that binary distributions use this +target for their LuaJIT builds. +

+

+The tl;dr version of the above: +

+
+make amalg PREFIX=/usr && \
+make install PREFIX=/usr DESTDIR=/tmp/buildroot
+
+

+Finally, if you encounter any difficulties, please +contact me first, instead of releasing a broken +package onto unsuspecting users. Because they'll usually gonna complain +to me (the upstream) and not you (the package maintainer), anyway. +

+
+
+ + + diff --git a/source/libs/luajit/LuaJIT-2.0.4/doc/luajit.html b/source/libs/luajit/LuaJIT-2.0.4/doc/luajit.html new file mode 100644 index 000000000..45507c122 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/doc/luajit.html @@ -0,0 +1,234 @@ + + + +LuaJIT + + + + + + + + + + +
+Lua +
+ + +
+

+LuaJIT is a Just-In-Time Compiler (JIT) for the +» Lua programming language. +Lua is a powerful, dynamic and light-weight programming language. +It may be embedded or used as a general-purpose, stand-alone language. +

+

+LuaJIT is Copyright © 2005-2015 Mike Pall, released under the +» MIT open source license. +

+

+

+ +

Compatibility

+ + +
WindowsLinuxBSDOSXPOSIX
+ + +
EmbeddedAndroidiOS
+ + +
PS3PS4PS VitaXbox 360
+ + +
GCCCLANG
LLVM
MSVC
+ + +
x86x64ARMPPCe500MIPS
+ + +
Lua 5.1
API+ABI
+ JIT+ BitOp+ FFIDrop-in
DLL/.so
+ +

Overview

+ + + + + + + + + +
3x
-  100x
115 KB
VM
90 KB
JIT
63 KLOC
C
24 KLOC
ASM
11 KLOC
Lua
+

+LuaJIT has been successfully used as a scripting middleware in +games, appliances, network and graphics apps, numerical simulations, +trading platforms and many other specialty applications. It scales from +embedded devices, smartphones, desktops up to server farms. It combines +high flexibility with » high performance +and an unmatched low memory footprint. +

+

+LuaJIT has been in continuous development since 2005. It's widely +considered to be one of the fastest dynamic language +implementations. It has outperformed other dynamic languages on many +cross-language benchmarks since its first release — often by a +substantial margin. +

+

+For LuaJIT 2.0, the whole VM has been rewritten from the ground up +and relentlessly optimized for performance. It combines a high-speed +interpreter, written in assembler, with a state-of-the-art JIT +compiler. +

+

+An innovative trace compiler is integrated with advanced, +SSA-based optimizations and highly tuned code generation backends. +A substantial reduction of the overhead associated with dynamic languages +allows it to break into the performance range traditionally reserved for +offline, static language compilers. +

+ +

More ...

+

+Please select a sub-topic in the navigation bar to learn more about LuaJIT. +

+
+
+ + + diff --git a/source/libs/luajit/LuaJIT-2.0.4/doc/running.html b/source/libs/luajit/LuaJIT-2.0.4/doc/running.html new file mode 100644 index 000000000..c6e1c296e --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/doc/running.html @@ -0,0 +1,306 @@ + + + +Running LuaJIT + + + + + + + + + +
+Lua +
+ + +
+

+LuaJIT has only a single stand-alone executable, called luajit on +POSIX systems or luajit.exe on Windows. It can be used to run simple +Lua statements or whole Lua applications from the command line. It has an +interactive mode, too. +

+ +

Command Line Options

+

+The luajit stand-alone executable is just a slightly modified +version of the regular lua stand-alone executable. +It supports the same basic options, too. luajit -h +prints a short list of the available options. Please have a look at the +» Lua manual +for details. +

+

+LuaJIT has some additional options: +

+ +

-b[options] input output

+

+This option saves or lists bytecode. The following additional options +are accepted: +

+
    +
  • -l — Only list bytecode.
  • +
  • -s — Strip debug info (this is the default).
  • +
  • -g — Keep debug info.
  • +
  • -n name — Set module name (default: auto-detect from input name)
  • +
  • -t type — Set output file type (default: auto-detect from output name).
  • +
  • -a arch — Override architecture for object files (default: native).
  • +
  • -o os — Override OS for object files (default: native).
  • +
  • -e chunk — Use chunk string as input.
  • +
  • - (a single minus sign) — Use stdin as input and/or stdout as output.
  • +
+

+The output file type is auto-detected from the extension of the output +file name: +

+
    +
  • c — C source file, exported bytecode data.
  • +
  • h — C header file, static bytecode data.
  • +
  • obj or o — Object file, exported bytecode data +(OS- and architecture-specific).
  • +
  • raw or any other extension — Raw bytecode file (portable). +
+

+Notes: +

+
    +
  • See also string.dump() +for information on bytecode portability and compatibility.
  • +
  • A file in raw bytecode format is auto-detected and can be loaded like +any Lua source file. E.g. directly from the command line or with +loadfile(), dofile() etc.
  • +
  • To statically embed the bytecode of a module in your application, +generate an object file and just link it with your application.
  • +
  • On most ELF-based systems (e.g. Linux) you need to explicitly export the +global symbols when linking your application, e.g. with: -Wl,-E
  • +
  • require() tries to load embedded bytecode data from exported +symbols (in *.exe or lua51.dll on Windows) and from +shared libraries in package.cpath.
  • +
+

+Typical usage examples: +

+
+luajit -b test.lua test.out                 # Save bytecode to test.out
+luajit -bg test.lua test.out                # Keep debug info
+luajit -be "print('hello world')" test.out  # Save cmdline script
+
+luajit -bl test.lua                         # List to stdout
+luajit -bl test.lua test.txt                # List to test.txt
+luajit -ble "print('hello world')"          # List cmdline script
+
+luajit -b test.lua test.obj                 # Generate object file
+# Link test.obj with your application and load it with require("test")
+
+ +

-j cmd[=arg[,arg...]]

+

+This option performs a LuaJIT control command or activates one of the +loadable extension modules. The command is first looked up in the +jit.* library. If no matching function is found, a module +named jit.<cmd> is loaded and the start() +function of the module is called with the specified arguments (if +any). The space between -j and cmd is optional. +

+

+Here are the available LuaJIT control commands: +

+
    +
  • -jon — Turns the JIT compiler on (default).
  • +
  • -joff — Turns the JIT compiler off (only use the interpreter).
  • +
  • -jflush — Flushes the whole cache of compiled code.
  • +
  • -jv — Shows verbose information about the progress of the JIT compiler.
  • +
  • -jdump — Dumps the code and structures used in various compiler stages.
  • +
+

+The -jv and -jdump commands are extension modules +written in Lua. They are mainly used for debugging the JIT compiler +itself. For a description of their options and output format, please +read the comment block at the start of their source. +They can be found in the lib directory of the source +distribution or installed under the jit directory. By default +this is /usr/local/share/luajit-2.0.4/jit on POSIX +systems. +

+ +

-O[level]
+-O[+]flag   -O-flag
+-Oparam=value

+

+This options allows fine-tuned control of the optimizations used by +the JIT compiler. This is mainly intended for debugging LuaJIT itself. +Please note that the JIT compiler is extremely fast (we are talking +about the microsecond to millisecond range). Disabling optimizations +doesn't have any visible impact on its overhead, but usually generates +code that runs slower. +

+

+The first form sets an optimization level — this enables a +specific mix of optimization flags. -O0 turns off all +optimizations and higher numbers enable more optimizations. Omitting +the level (i.e. just -O) sets the default optimization level, +which is -O3 in the current version. +

+

+The second form adds or removes individual optimization flags. +The third form sets a parameter for the VM or the JIT compiler +to a specific value. +

+

+You can either use this option multiple times (like -Ocse +-O-dce -Ohotloop=10) or separate several settings with a comma +(like -O+cse,-dce,hotloop=10). The settings are applied from +left to right and later settings override earlier ones. You can freely +mix the three forms, but note that setting an optimization level +overrides all earlier flags. +

+

+Here are the available flags and at what optimization levels they +are enabled: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Flag-O1-O2-O3 
foldConstant Folding, Simplifications and Reassociation
cseCommon-Subexpression Elimination
dceDead-Code Elimination
narrow Narrowing of numbers to integers
loop Loop Optimizations (code hoisting)
fwd  Load Forwarding (L2L) and Store Forwarding (S2L)
dse  Dead-Store Elimination
abc  Array Bounds Check Elimination
sink  Allocation/Store Sinking
fuse  Fusion of operands into instructions
+

+Here are the parameters and their default settings: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterDefault 
maxtrace1000Max. number of traces in the cache
maxrecord4000Max. number of recorded IR instructions
maxirconst500Max. number of IR constants of a trace
maxside100Max. number of side traces of a root trace
maxsnap500Max. number of snapshots for a trace
hotloop56Number of iterations to detect a hot loop or hot call
hotexit10Number of taken exits to start a side trace
tryside4Number of attempts to compile a side trace
instunroll4Max. unroll factor for instable loops
loopunroll15Max. unroll factor for loop ops in side traces
callunroll3Max. unroll factor for pseudo-recursive calls
recunroll2Min. unroll factor for true recursion
sizemcode32Size of each machine code area in KBytes (Windows: 64K)
maxmcode512Max. total size of all machine code areas in KBytes
+
+
+ + + diff --git a/source/libs/luajit/LuaJIT-2.0.4/doc/status.html b/source/libs/luajit/LuaJIT-2.0.4/doc/status.html new file mode 100644 index 000000000..b4bbec793 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/doc/status.html @@ -0,0 +1,116 @@ + + + +Status + + + + + + + + + +
+Lua +
+ + +
+

+LuaJIT 2.0 is the current +stable branch. This branch is in +feature-freeze — new features will only be added to LuaJIT 2.1. +

+ +

Current Status

+

+LuaJIT ought to run all Lua 5.1-compatible source code just fine. +It's considered a serious bug if the VM crashes or produces unexpected +results — please report this. +

+

+Known incompatibilities and issues in LuaJIT 2.0: +

+
    +
  • +There are some differences in implementation-defined behavior. +These either have a good reason, are arbitrary design choices +or are due to quirks in the VM. The latter cases may get fixed if a +demonstrable need is shown. +
  • +
  • +The Lua debug API is missing a couple of features (return +hooks for non-Lua functions) and shows slightly different behavior +in LuaJIT (no per-coroutine hooks, no tail call counting). +
  • +
  • +Some checks are missing in the JIT-compiled code for obscure situations +with open upvalues aliasing one of the SSA slots later on (or +vice versa). Bonus points, if you can find a real world test case for +this. +
  • +
  • +Currently some out-of-memory errors from on-trace code are not +handled correctly. The error may fall through an on-trace +pcall or it may be passed on to the function set with +lua_atpanic on x64. This issue will be fixed with the new +garbage collector. +
  • +
+
+
+ + + diff --git a/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_arm.h b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_arm.h new file mode 100644 index 000000000..57e0116f5 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_arm.h @@ -0,0 +1,456 @@ +/* +** DynASM ARM encoding engine. +** Copyright (C) 2005-2015 Mike Pall. All rights reserved. +** Released under the MIT license. See dynasm.lua for full copyright notice. +*/ + +#include +#include +#include +#include + +#define DASM_ARCH "arm" + +#ifndef DASM_EXTERN +#define DASM_EXTERN(a,b,c,d) 0 +#endif + +/* Action definitions. */ +enum { + DASM_STOP, DASM_SECTION, DASM_ESC, DASM_REL_EXT, + /* The following actions need a buffer position. */ + DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG, + /* The following actions also have an argument. */ + DASM_REL_PC, DASM_LABEL_PC, + DASM_IMM, DASM_IMM12, DASM_IMM16, DASM_IMML8, DASM_IMML12, DASM_IMMV8, + DASM__MAX +}; + +/* Maximum number of section buffer positions for a single dasm_put() call. */ +#define DASM_MAXSECPOS 25 + +/* DynASM encoder status codes. Action list offset or number are or'ed in. */ +#define DASM_S_OK 0x00000000 +#define DASM_S_NOMEM 0x01000000 +#define DASM_S_PHASE 0x02000000 +#define DASM_S_MATCH_SEC 0x03000000 +#define DASM_S_RANGE_I 0x11000000 +#define DASM_S_RANGE_SEC 0x12000000 +#define DASM_S_RANGE_LG 0x13000000 +#define DASM_S_RANGE_PC 0x14000000 +#define DASM_S_RANGE_REL 0x15000000 +#define DASM_S_UNDEF_LG 0x21000000 +#define DASM_S_UNDEF_PC 0x22000000 + +/* Macros to convert positions (8 bit section + 24 bit index). */ +#define DASM_POS2IDX(pos) ((pos)&0x00ffffff) +#define DASM_POS2BIAS(pos) ((pos)&0xff000000) +#define DASM_SEC2POS(sec) ((sec)<<24) +#define DASM_POS2SEC(pos) ((pos)>>24) +#define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) + +/* Action list type. */ +typedef const unsigned int *dasm_ActList; + +/* Per-section structure. */ +typedef struct dasm_Section { + int *rbuf; /* Biased buffer pointer (negative section bias). */ + int *buf; /* True buffer pointer. */ + size_t bsize; /* Buffer size in bytes. */ + int pos; /* Biased buffer position. */ + int epos; /* End of biased buffer position - max single put. */ + int ofs; /* Byte offset into section. */ +} dasm_Section; + +/* Core structure holding the DynASM encoding state. */ +struct dasm_State { + size_t psize; /* Allocated size of this structure. */ + dasm_ActList actionlist; /* Current actionlist pointer. */ + int *lglabels; /* Local/global chain/pos ptrs. */ + size_t lgsize; + int *pclabels; /* PC label chains/pos ptrs. */ + size_t pcsize; + void **globals; /* Array of globals (bias -10). */ + dasm_Section *section; /* Pointer to active section. */ + size_t codesize; /* Total size of all code sections. */ + int maxsection; /* 0 <= sectionidx < maxsection. */ + int status; /* Status code. */ + dasm_Section sections[1]; /* All sections. Alloc-extended. */ +}; + +/* The size of the core structure depends on the max. number of sections. */ +#define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section)) + + +/* Initialize DynASM state. */ +void dasm_init(Dst_DECL, int maxsection) +{ + dasm_State *D; + size_t psz = 0; + int i; + Dst_REF = NULL; + DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); + D = Dst_REF; + D->psize = psz; + D->lglabels = NULL; + D->lgsize = 0; + D->pclabels = NULL; + D->pcsize = 0; + D->globals = NULL; + D->maxsection = maxsection; + for (i = 0; i < maxsection; i++) { + D->sections[i].buf = NULL; /* Need this for pass3. */ + D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i); + D->sections[i].bsize = 0; + D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ + } +} + +/* Free DynASM state. */ +void dasm_free(Dst_DECL) +{ + dasm_State *D = Dst_REF; + int i; + for (i = 0; i < D->maxsection; i++) + if (D->sections[i].buf) + DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize); + if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize); + if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize); + DASM_M_FREE(Dst, D, D->psize); +} + +/* Setup global label array. Must be called before dasm_setup(). */ +void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) +{ + dasm_State *D = Dst_REF; + D->globals = gl - 10; /* Negative bias to compensate for locals. */ + DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); +} + +/* Grow PC label array. Can be called after dasm_setup(), too. */ +void dasm_growpc(Dst_DECL, unsigned int maxpc) +{ + dasm_State *D = Dst_REF; + size_t osz = D->pcsize; + DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int)); + memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz); +} + +/* Setup encoder. */ +void dasm_setup(Dst_DECL, const void *actionlist) +{ + dasm_State *D = Dst_REF; + int i; + D->actionlist = (dasm_ActList)actionlist; + D->status = DASM_S_OK; + D->section = &D->sections[0]; + memset((void *)D->lglabels, 0, D->lgsize); + if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); + for (i = 0; i < D->maxsection; i++) { + D->sections[i].pos = DASM_SEC2POS(i); + D->sections[i].ofs = 0; + } +} + + +#ifdef DASM_CHECKS +#define CK(x, st) \ + do { if (!(x)) { \ + D->status = DASM_S_##st|(p-D->actionlist-1); return; } } while (0) +#define CKPL(kind, st) \ + do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \ + D->status = DASM_S_RANGE_##st|(p-D->actionlist-1); return; } } while (0) +#else +#define CK(x, st) ((void)0) +#define CKPL(kind, st) ((void)0) +#endif + +static int dasm_imm12(unsigned int n) +{ + int i; + for (i = 0; i < 16; i++, n = (n << 2) | (n >> 30)) + if (n <= 255) return (int)(n + (i << 8)); + return -1; +} + +/* Pass 1: Store actions and args, link branches/labels, estimate offsets. */ +void dasm_put(Dst_DECL, int start, ...) +{ + va_list ap; + dasm_State *D = Dst_REF; + dasm_ActList p = D->actionlist + start; + dasm_Section *sec = D->section; + int pos = sec->pos, ofs = sec->ofs; + int *b; + + if (pos >= sec->epos) { + DASM_M_GROW(Dst, int, sec->buf, sec->bsize, + sec->bsize + 2*DASM_MAXSECPOS*sizeof(int)); + sec->rbuf = sec->buf - DASM_POS2BIAS(pos); + sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos); + } + + b = sec->rbuf; + b[pos++] = start; + + va_start(ap, start); + while (1) { + unsigned int ins = *p++; + unsigned int action = (ins >> 16); + if (action >= DASM__MAX) { + ofs += 4; + } else { + int *pl, n = action >= DASM_REL_PC ? va_arg(ap, int) : 0; + switch (action) { + case DASM_STOP: goto stop; + case DASM_SECTION: + n = (ins & 255); CK(n < D->maxsection, RANGE_SEC); + D->section = &D->sections[n]; goto stop; + case DASM_ESC: p++; ofs += 4; break; + case DASM_REL_EXT: break; + case DASM_ALIGN: ofs += (ins & 255); b[pos++] = ofs; break; + case DASM_REL_LG: + n = (ins & 2047) - 10; pl = D->lglabels + n; + /* Bkwd rel or global. */ + if (n >= 0) { CK(n>=10||*pl<0, RANGE_LG); CKPL(lg, LG); goto putrel; } + pl += 10; n = *pl; + if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */ + goto linkrel; + case DASM_REL_PC: + pl = D->pclabels + n; CKPL(pc, PC); + putrel: + n = *pl; + if (n < 0) { /* Label exists. Get label pos and store it. */ + b[pos] = -n; + } else { + linkrel: + b[pos] = n; /* Else link to rel chain, anchored at label. */ + *pl = pos; + } + pos++; + break; + case DASM_LABEL_LG: + pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel; + case DASM_LABEL_PC: + pl = D->pclabels + n; CKPL(pc, PC); + putlabel: + n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */ + while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; + } + *pl = -pos; /* Label exists now. */ + b[pos++] = ofs; /* Store pass1 offset estimate. */ + break; + case DASM_IMM: + case DASM_IMM16: +#ifdef DASM_CHECKS + CK((n & ((1<<((ins>>10)&31))-1)) == 0, RANGE_I); + if ((ins & 0x8000)) + CK(((n + (1<<(((ins>>5)&31)-1)))>>((ins>>5)&31)) == 0, RANGE_I); + else + CK((n>>((ins>>5)&31)) == 0, RANGE_I); +#endif + b[pos++] = n; + break; + case DASM_IMMV8: + CK((n & 3) == 0, RANGE_I); + n >>= 2; + case DASM_IMML8: + case DASM_IMML12: + CK(n >= 0 ? ((n>>((ins>>5)&31)) == 0) : + (((-n)>>((ins>>5)&31)) == 0), RANGE_I); + b[pos++] = n; + break; + case DASM_IMM12: + CK(dasm_imm12((unsigned int)n) != -1, RANGE_I); + b[pos++] = n; + break; + } + } + } +stop: + va_end(ap); + sec->pos = pos; + sec->ofs = ofs; +} +#undef CK + +/* Pass 2: Link sections, shrink aligns, fix label offsets. */ +int dasm_link(Dst_DECL, size_t *szp) +{ + dasm_State *D = Dst_REF; + int secnum; + int ofs = 0; + +#ifdef DASM_CHECKS + *szp = 0; + if (D->status != DASM_S_OK) return D->status; + { + int pc; + for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) + if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; + } +#endif + + { /* Handle globals not defined in this translation unit. */ + int idx; + for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) { + int n = D->lglabels[idx]; + /* Undefined label: Collapse rel chain and replace with marker (< 0). */ + while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } + } + } + + /* Combine all code sections. No support for data sections (yet). */ + for (secnum = 0; secnum < D->maxsection; secnum++) { + dasm_Section *sec = D->sections + secnum; + int *b = sec->rbuf; + int pos = DASM_SEC2POS(secnum); + int lastpos = sec->pos; + + while (pos != lastpos) { + dasm_ActList p = D->actionlist + b[pos++]; + while (1) { + unsigned int ins = *p++; + unsigned int action = (ins >> 16); + switch (action) { + case DASM_STOP: case DASM_SECTION: goto stop; + case DASM_ESC: p++; break; + case DASM_REL_EXT: break; + case DASM_ALIGN: ofs -= (b[pos++] + ofs) & (ins & 255); break; + case DASM_REL_LG: case DASM_REL_PC: pos++; break; + case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break; + case DASM_IMM: case DASM_IMM12: case DASM_IMM16: + case DASM_IMML8: case DASM_IMML12: case DASM_IMMV8: pos++; break; + } + } + stop: (void)0; + } + ofs += sec->ofs; /* Next section starts right after current section. */ + } + + D->codesize = ofs; /* Total size of all code sections */ + *szp = ofs; + return DASM_S_OK; +} + +#ifdef DASM_CHECKS +#define CK(x, st) \ + do { if (!(x)) return DASM_S_##st|(p-D->actionlist-1); } while (0) +#else +#define CK(x, st) ((void)0) +#endif + +/* Pass 3: Encode sections. */ +int dasm_encode(Dst_DECL, void *buffer) +{ + dasm_State *D = Dst_REF; + char *base = (char *)buffer; + unsigned int *cp = (unsigned int *)buffer; + int secnum; + + /* Encode all code sections. No support for data sections (yet). */ + for (secnum = 0; secnum < D->maxsection; secnum++) { + dasm_Section *sec = D->sections + secnum; + int *b = sec->buf; + int *endb = sec->rbuf + sec->pos; + + while (b != endb) { + dasm_ActList p = D->actionlist + *b++; + while (1) { + unsigned int ins = *p++; + unsigned int action = (ins >> 16); + int n = (action >= DASM_ALIGN && action < DASM__MAX) ? *b++ : 0; + switch (action) { + case DASM_STOP: case DASM_SECTION: goto stop; + case DASM_ESC: *cp++ = *p++; break; + case DASM_REL_EXT: + n = DASM_EXTERN(Dst, (unsigned char *)cp, (ins&2047), !(ins&2048)); + goto patchrel; + case DASM_ALIGN: + ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0xe1a00000; + break; + case DASM_REL_LG: + CK(n >= 0, UNDEF_LG); + case DASM_REL_PC: + CK(n >= 0, UNDEF_PC); + n = *DASM_POS2PTR(D, n) - (int)((char *)cp - base) - 4; + patchrel: + if ((ins & 0x800) == 0) { + CK((n & 3) == 0 && ((n+0x02000000) >> 26) == 0, RANGE_REL); + cp[-1] |= ((n >> 2) & 0x00ffffff); + } else if ((ins & 0x1000)) { + CK((n & 3) == 0 && -256 <= n && n <= 256, RANGE_REL); + goto patchimml8; + } else if ((ins & 0x2000) == 0) { + CK((n & 3) == 0 && -4096 <= n && n <= 4096, RANGE_REL); + goto patchimml; + } else { + CK((n & 3) == 0 && -1020 <= n && n <= 1020, RANGE_REL); + n >>= 2; + goto patchimml; + } + break; + case DASM_LABEL_LG: + ins &= 2047; if (ins >= 20) D->globals[ins-10] = (void *)(base + n); + break; + case DASM_LABEL_PC: break; + case DASM_IMM: + cp[-1] |= ((n>>((ins>>10)&31)) & ((1<<((ins>>5)&31))-1)) << (ins&31); + break; + case DASM_IMM12: + cp[-1] |= dasm_imm12((unsigned int)n); + break; + case DASM_IMM16: + cp[-1] |= ((n & 0xf000) << 4) | (n & 0x0fff); + break; + case DASM_IMML8: patchimml8: + cp[-1] |= n >= 0 ? (0x00800000 | (n & 0x0f) | ((n & 0xf0) << 4)) : + ((-n & 0x0f) | ((-n & 0xf0) << 4)); + break; + case DASM_IMML12: case DASM_IMMV8: patchimml: + cp[-1] |= n >= 0 ? (0x00800000 | n) : (-n); + break; + default: *cp++ = ins; break; + } + } + stop: (void)0; + } + } + + if (base + D->codesize != (char *)cp) /* Check for phase errors. */ + return DASM_S_PHASE; + return DASM_S_OK; +} +#undef CK + +/* Get PC label offset. */ +int dasm_getpclabel(Dst_DECL, unsigned int pc) +{ + dasm_State *D = Dst_REF; + if (pc*sizeof(int) < D->pcsize) { + int pos = D->pclabels[pc]; + if (pos < 0) return *DASM_POS2PTR(D, -pos); + if (pos > 0) return -1; /* Undefined. */ + } + return -2; /* Unused or out of range. */ +} + +#ifdef DASM_CHECKS +/* Optional sanity checker to call between isolated encoding steps. */ +int dasm_checkstep(Dst_DECL, int secmatch) +{ + dasm_State *D = Dst_REF; + if (D->status == DASM_S_OK) { + int i; + for (i = 1; i <= 9; i++) { + if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_LG|i; break; } + D->lglabels[i] = 0; + } + } + if (D->status == DASM_S_OK && secmatch >= 0 && + D->section != &D->sections[secmatch]) + D->status = DASM_S_MATCH_SEC|(D->section-D->sections); + return D->status; +} +#endif + diff --git a/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_arm.lua b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_arm.lua new file mode 100644 index 000000000..90a259c5c --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_arm.lua @@ -0,0 +1,1125 @@ +------------------------------------------------------------------------------ +-- DynASM ARM module. +-- +-- Copyright (C) 2005-2015 Mike Pall. All rights reserved. +-- See dynasm.lua for full copyright notice. +------------------------------------------------------------------------------ + +-- Module information: +local _info = { + arch = "arm", + description = "DynASM ARM module", + version = "1.3.0", + vernum = 10300, + release = "2011-05-05", + author = "Mike Pall", + license = "MIT", +} + +-- Exported glue functions for the arch-specific module. +local _M = { _info = _info } + +-- Cache library functions. +local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs +local assert, setmetatable, rawget = assert, setmetatable, rawget +local _s = string +local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char +local match, gmatch, gsub = _s.match, _s.gmatch, _s.gsub +local concat, sort, insert = table.concat, table.sort, table.insert +local bit = bit or require("bit") +local band, shl, shr, sar = bit.band, bit.lshift, bit.rshift, bit.arshift +local ror, tohex = bit.ror, bit.tohex + +-- Inherited tables and callbacks. +local g_opt, g_arch +local wline, werror, wfatal, wwarn + +-- Action name list. +-- CHECK: Keep this in sync with the C code! +local action_names = { + "STOP", "SECTION", "ESC", "REL_EXT", + "ALIGN", "REL_LG", "LABEL_LG", + "REL_PC", "LABEL_PC", "IMM", "IMM12", "IMM16", "IMML8", "IMML12", "IMMV8", +} + +-- Maximum number of section buffer positions for dasm_put(). +-- CHECK: Keep this in sync with the C code! +local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines. + +-- Action name -> action number. +local map_action = {} +for n,name in ipairs(action_names) do + map_action[name] = n-1 +end + +-- Action list buffer. +local actlist = {} + +-- Argument list for next dasm_put(). Start with offset 0 into action list. +local actargs = { 0 } + +-- Current number of section buffer positions for dasm_put(). +local secpos = 1 + +------------------------------------------------------------------------------ + +-- Dump action names and numbers. +local function dumpactions(out) + out:write("DynASM encoding engine action codes:\n") + for n,name in ipairs(action_names) do + local num = map_action[name] + out:write(format(" %-10s %02X %d\n", name, num, num)) + end + out:write("\n") +end + +-- Write action list buffer as a huge static C array. +local function writeactions(out, name) + local nn = #actlist + if nn == 0 then nn = 1; actlist[0] = map_action.STOP end + out:write("static const unsigned int ", name, "[", nn, "] = {\n") + for i = 1,nn-1 do + assert(out:write("0x", tohex(actlist[i]), ",\n")) + end + assert(out:write("0x", tohex(actlist[nn]), "\n};\n\n")) +end + +------------------------------------------------------------------------------ + +-- Add word to action list. +local function wputxw(n) + assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") + actlist[#actlist+1] = n +end + +-- Add action to list with optional arg. Advance buffer pos, too. +local function waction(action, val, a, num) + local w = assert(map_action[action], "bad action name `"..action.."'") + wputxw(w * 0x10000 + (val or 0)) + if a then actargs[#actargs+1] = a end + if a or num then secpos = secpos + (num or 1) end +end + +-- Flush action list (intervening C code or buffer pos overflow). +local function wflush(term) + if #actlist == actargs[1] then return end -- Nothing to flush. + if not term then waction("STOP") end -- Terminate action list. + wline(format("dasm_put(Dst, %s);", concat(actargs, ", ")), true) + actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put(). + secpos = 1 -- The actionlist offset occupies a buffer position, too. +end + +-- Put escaped word. +local function wputw(n) + if n <= 0x000fffff then waction("ESC") end + wputxw(n) +end + +-- Reserve position for word. +local function wpos() + local pos = #actlist+1 + actlist[pos] = "" + return pos +end + +-- Store word to reserved position. +local function wputpos(pos, n) + assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") + if n <= 0x000fffff then + insert(actlist, pos+1, n) + n = map_action.ESC * 0x10000 + end + actlist[pos] = n +end + +------------------------------------------------------------------------------ + +-- Global label name -> global label number. With auto assignment on 1st use. +local next_global = 20 +local map_global = setmetatable({}, { __index = function(t, name) + if not match(name, "^[%a_][%w_]*$") then werror("bad global label") end + local n = next_global + if n > 2047 then werror("too many global labels") end + next_global = n + 1 + t[name] = n + return n +end}) + +-- Dump global labels. +local function dumpglobals(out, lvl) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("Global labels:\n") + for i=20,next_global-1 do + out:write(format(" %s\n", t[i])) + end + out:write("\n") +end + +-- Write global label enum. +local function writeglobals(out, prefix) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("enum {\n") + for i=20,next_global-1 do + out:write(" ", prefix, t[i], ",\n") + end + out:write(" ", prefix, "_MAX\n};\n") +end + +-- Write global label names. +local function writeglobalnames(out, name) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("static const char *const ", name, "[] = {\n") + for i=20,next_global-1 do + out:write(" \"", t[i], "\",\n") + end + out:write(" (const char *)0\n};\n") +end + +------------------------------------------------------------------------------ + +-- Extern label name -> extern label number. With auto assignment on 1st use. +local next_extern = 0 +local map_extern_ = {} +local map_extern = setmetatable({}, { __index = function(t, name) + -- No restrictions on the name for now. + local n = next_extern + if n > 2047 then werror("too many extern labels") end + next_extern = n + 1 + t[name] = n + map_extern_[n] = name + return n +end}) + +-- Dump extern labels. +local function dumpexterns(out, lvl) + out:write("Extern labels:\n") + for i=0,next_extern-1 do + out:write(format(" %s\n", map_extern_[i])) + end + out:write("\n") +end + +-- Write extern label names. +local function writeexternnames(out, name) + out:write("static const char *const ", name, "[] = {\n") + for i=0,next_extern-1 do + out:write(" \"", map_extern_[i], "\",\n") + end + out:write(" (const char *)0\n};\n") +end + +------------------------------------------------------------------------------ + +-- Arch-specific maps. + +-- Ext. register name -> int. name. +local map_archdef = { sp = "r13", lr = "r14", pc = "r15", } + +-- Int. register name -> ext. name. +local map_reg_rev = { r13 = "sp", r14 = "lr", r15 = "pc", } + +local map_type = {} -- Type name -> { ctype, reg } +local ctypenum = 0 -- Type number (for Dt... macros). + +-- Reverse defines for registers. +function _M.revdef(s) + return map_reg_rev[s] or s +end + +local map_shift = { lsl = 0, lsr = 1, asr = 2, ror = 3, } + +local map_cond = { + eq = 0, ne = 1, cs = 2, cc = 3, mi = 4, pl = 5, vs = 6, vc = 7, + hi = 8, ls = 9, ge = 10, lt = 11, gt = 12, le = 13, al = 14, + hs = 2, lo = 3, +} + +------------------------------------------------------------------------------ + +-- Template strings for ARM instructions. +local map_op = { + -- Basic data processing instructions. + and_3 = "e0000000DNPs", + eor_3 = "e0200000DNPs", + sub_3 = "e0400000DNPs", + rsb_3 = "e0600000DNPs", + add_3 = "e0800000DNPs", + adc_3 = "e0a00000DNPs", + sbc_3 = "e0c00000DNPs", + rsc_3 = "e0e00000DNPs", + tst_2 = "e1100000NP", + teq_2 = "e1300000NP", + cmp_2 = "e1500000NP", + cmn_2 = "e1700000NP", + orr_3 = "e1800000DNPs", + mov_2 = "e1a00000DPs", + bic_3 = "e1c00000DNPs", + mvn_2 = "e1e00000DPs", + + and_4 = "e0000000DNMps", + eor_4 = "e0200000DNMps", + sub_4 = "e0400000DNMps", + rsb_4 = "e0600000DNMps", + add_4 = "e0800000DNMps", + adc_4 = "e0a00000DNMps", + sbc_4 = "e0c00000DNMps", + rsc_4 = "e0e00000DNMps", + tst_3 = "e1100000NMp", + teq_3 = "e1300000NMp", + cmp_3 = "e1500000NMp", + cmn_3 = "e1700000NMp", + orr_4 = "e1800000DNMps", + mov_3 = "e1a00000DMps", + bic_4 = "e1c00000DNMps", + mvn_3 = "e1e00000DMps", + + lsl_3 = "e1a00000DMws", + lsr_3 = "e1a00020DMws", + asr_3 = "e1a00040DMws", + ror_3 = "e1a00060DMws", + rrx_2 = "e1a00060DMs", + + -- Multiply and multiply-accumulate. + mul_3 = "e0000090NMSs", + mla_4 = "e0200090NMSDs", + umaal_4 = "e0400090DNMSs", -- v6 + mls_4 = "e0600090DNMSs", -- v6T2 + umull_4 = "e0800090DNMSs", + umlal_4 = "e0a00090DNMSs", + smull_4 = "e0c00090DNMSs", + smlal_4 = "e0e00090DNMSs", + + -- Halfword multiply and multiply-accumulate. + smlabb_4 = "e1000080NMSD", -- v5TE + smlatb_4 = "e10000a0NMSD", -- v5TE + smlabt_4 = "e10000c0NMSD", -- v5TE + smlatt_4 = "e10000e0NMSD", -- v5TE + smlawb_4 = "e1200080NMSD", -- v5TE + smulwb_3 = "e12000a0NMS", -- v5TE + smlawt_4 = "e12000c0NMSD", -- v5TE + smulwt_3 = "e12000e0NMS", -- v5TE + smlalbb_4 = "e1400080NMSD", -- v5TE + smlaltb_4 = "e14000a0NMSD", -- v5TE + smlalbt_4 = "e14000c0NMSD", -- v5TE + smlaltt_4 = "e14000e0NMSD", -- v5TE + smulbb_3 = "e1600080NMS", -- v5TE + smultb_3 = "e16000a0NMS", -- v5TE + smulbt_3 = "e16000c0NMS", -- v5TE + smultt_3 = "e16000e0NMS", -- v5TE + + -- Miscellaneous data processing instructions. + clz_2 = "e16f0f10DM", -- v5T + rev_2 = "e6bf0f30DM", -- v6 + rev16_2 = "e6bf0fb0DM", -- v6 + revsh_2 = "e6ff0fb0DM", -- v6 + sel_3 = "e6800fb0DNM", -- v6 + usad8_3 = "e780f010NMS", -- v6 + usada8_4 = "e7800010NMSD", -- v6 + rbit_2 = "e6ff0f30DM", -- v6T2 + movw_2 = "e3000000DW", -- v6T2 + movt_2 = "e3400000DW", -- v6T2 + -- Note: the X encodes width-1, not width. + sbfx_4 = "e7a00050DMvX", -- v6T2 + ubfx_4 = "e7e00050DMvX", -- v6T2 + -- Note: the X encodes the msb field, not the width. + bfc_3 = "e7c0001fDvX", -- v6T2 + bfi_4 = "e7c00010DMvX", -- v6T2 + + -- Packing and unpacking instructions. + pkhbt_3 = "e6800010DNM", pkhbt_4 = "e6800010DNMv", -- v6 + pkhtb_3 = "e6800050DNM", pkhtb_4 = "e6800050DNMv", -- v6 + sxtab_3 = "e6a00070DNM", sxtab_4 = "e6a00070DNMv", -- v6 + sxtab16_3 = "e6800070DNM", sxtab16_4 = "e6800070DNMv", -- v6 + sxtah_3 = "e6b00070DNM", sxtah_4 = "e6b00070DNMv", -- v6 + sxtb_2 = "e6af0070DM", sxtb_3 = "e6af0070DMv", -- v6 + sxtb16_2 = "e68f0070DM", sxtb16_3 = "e68f0070DMv", -- v6 + sxth_2 = "e6bf0070DM", sxth_3 = "e6bf0070DMv", -- v6 + uxtab_3 = "e6e00070DNM", uxtab_4 = "e6e00070DNMv", -- v6 + uxtab16_3 = "e6c00070DNM", uxtab16_4 = "e6c00070DNMv", -- v6 + uxtah_3 = "e6f00070DNM", uxtah_4 = "e6f00070DNMv", -- v6 + uxtb_2 = "e6ef0070DM", uxtb_3 = "e6ef0070DMv", -- v6 + uxtb16_2 = "e6cf0070DM", uxtb16_3 = "e6cf0070DMv", -- v6 + uxth_2 = "e6ff0070DM", uxth_3 = "e6ff0070DMv", -- v6 + + -- Saturating instructions. + qadd_3 = "e1000050DMN", -- v5TE + qsub_3 = "e1200050DMN", -- v5TE + qdadd_3 = "e1400050DMN", -- v5TE + qdsub_3 = "e1600050DMN", -- v5TE + -- Note: the X for ssat* encodes sat_imm-1, not sat_imm. + ssat_3 = "e6a00010DXM", ssat_4 = "e6a00010DXMp", -- v6 + usat_3 = "e6e00010DXM", usat_4 = "e6e00010DXMp", -- v6 + ssat16_3 = "e6a00f30DXM", -- v6 + usat16_3 = "e6e00f30DXM", -- v6 + + -- Parallel addition and subtraction. + sadd16_3 = "e6100f10DNM", -- v6 + sasx_3 = "e6100f30DNM", -- v6 + ssax_3 = "e6100f50DNM", -- v6 + ssub16_3 = "e6100f70DNM", -- v6 + sadd8_3 = "e6100f90DNM", -- v6 + ssub8_3 = "e6100ff0DNM", -- v6 + qadd16_3 = "e6200f10DNM", -- v6 + qasx_3 = "e6200f30DNM", -- v6 + qsax_3 = "e6200f50DNM", -- v6 + qsub16_3 = "e6200f70DNM", -- v6 + qadd8_3 = "e6200f90DNM", -- v6 + qsub8_3 = "e6200ff0DNM", -- v6 + shadd16_3 = "e6300f10DNM", -- v6 + shasx_3 = "e6300f30DNM", -- v6 + shsax_3 = "e6300f50DNM", -- v6 + shsub16_3 = "e6300f70DNM", -- v6 + shadd8_3 = "e6300f90DNM", -- v6 + shsub8_3 = "e6300ff0DNM", -- v6 + uadd16_3 = "e6500f10DNM", -- v6 + uasx_3 = "e6500f30DNM", -- v6 + usax_3 = "e6500f50DNM", -- v6 + usub16_3 = "e6500f70DNM", -- v6 + uadd8_3 = "e6500f90DNM", -- v6 + usub8_3 = "e6500ff0DNM", -- v6 + uqadd16_3 = "e6600f10DNM", -- v6 + uqasx_3 = "e6600f30DNM", -- v6 + uqsax_3 = "e6600f50DNM", -- v6 + uqsub16_3 = "e6600f70DNM", -- v6 + uqadd8_3 = "e6600f90DNM", -- v6 + uqsub8_3 = "e6600ff0DNM", -- v6 + uhadd16_3 = "e6700f10DNM", -- v6 + uhasx_3 = "e6700f30DNM", -- v6 + uhsax_3 = "e6700f50DNM", -- v6 + uhsub16_3 = "e6700f70DNM", -- v6 + uhadd8_3 = "e6700f90DNM", -- v6 + uhsub8_3 = "e6700ff0DNM", -- v6 + + -- Load/store instructions. + str_2 = "e4000000DL", str_3 = "e4000000DL", str_4 = "e4000000DL", + strb_2 = "e4400000DL", strb_3 = "e4400000DL", strb_4 = "e4400000DL", + ldr_2 = "e4100000DL", ldr_3 = "e4100000DL", ldr_4 = "e4100000DL", + ldrb_2 = "e4500000DL", ldrb_3 = "e4500000DL", ldrb_4 = "e4500000DL", + strh_2 = "e00000b0DL", strh_3 = "e00000b0DL", + ldrh_2 = "e01000b0DL", ldrh_3 = "e01000b0DL", + ldrd_2 = "e00000d0DL", ldrd_3 = "e00000d0DL", -- v5TE + ldrsb_2 = "e01000d0DL", ldrsb_3 = "e01000d0DL", + strd_2 = "e00000f0DL", strd_3 = "e00000f0DL", -- v5TE + ldrsh_2 = "e01000f0DL", ldrsh_3 = "e01000f0DL", + + ldm_2 = "e8900000oR", ldmia_2 = "e8900000oR", ldmfd_2 = "e8900000oR", + ldmda_2 = "e8100000oR", ldmfa_2 = "e8100000oR", + ldmdb_2 = "e9100000oR", ldmea_2 = "e9100000oR", + ldmib_2 = "e9900000oR", ldmed_2 = "e9900000oR", + stm_2 = "e8800000oR", stmia_2 = "e8800000oR", stmfd_2 = "e8800000oR", + stmda_2 = "e8000000oR", stmfa_2 = "e8000000oR", + stmdb_2 = "e9000000oR", stmea_2 = "e9000000oR", + stmib_2 = "e9800000oR", stmed_2 = "e9800000oR", + pop_1 = "e8bd0000R", push_1 = "e92d0000R", + + -- Branch instructions. + b_1 = "ea000000B", + bl_1 = "eb000000B", + blx_1 = "e12fff30C", + bx_1 = "e12fff10M", + + -- Miscellaneous instructions. + nop_0 = "e1a00000", + mrs_1 = "e10f0000D", + bkpt_1 = "e1200070K", -- v5T + svc_1 = "ef000000T", swi_1 = "ef000000T", + ud_0 = "e7f001f0", + + -- VFP instructions. + ["vadd.f32_3"] = "ee300a00dnm", + ["vadd.f64_3"] = "ee300b00Gdnm", + ["vsub.f32_3"] = "ee300a40dnm", + ["vsub.f64_3"] = "ee300b40Gdnm", + ["vmul.f32_3"] = "ee200a00dnm", + ["vmul.f64_3"] = "ee200b00Gdnm", + ["vnmul.f32_3"] = "ee200a40dnm", + ["vnmul.f64_3"] = "ee200b40Gdnm", + ["vmla.f32_3"] = "ee000a00dnm", + ["vmla.f64_3"] = "ee000b00Gdnm", + ["vmls.f32_3"] = "ee000a40dnm", + ["vmls.f64_3"] = "ee000b40Gdnm", + ["vnmla.f32_3"] = "ee100a40dnm", + ["vnmla.f64_3"] = "ee100b40Gdnm", + ["vnmls.f32_3"] = "ee100a00dnm", + ["vnmls.f64_3"] = "ee100b00Gdnm", + ["vdiv.f32_3"] = "ee800a00dnm", + ["vdiv.f64_3"] = "ee800b00Gdnm", + + ["vabs.f32_2"] = "eeb00ac0dm", + ["vabs.f64_2"] = "eeb00bc0Gdm", + ["vneg.f32_2"] = "eeb10a40dm", + ["vneg.f64_2"] = "eeb10b40Gdm", + ["vsqrt.f32_2"] = "eeb10ac0dm", + ["vsqrt.f64_2"] = "eeb10bc0Gdm", + ["vcmp.f32_2"] = "eeb40a40dm", + ["vcmp.f64_2"] = "eeb40b40Gdm", + ["vcmpe.f32_2"] = "eeb40ac0dm", + ["vcmpe.f64_2"] = "eeb40bc0Gdm", + ["vcmpz.f32_1"] = "eeb50a40d", + ["vcmpz.f64_1"] = "eeb50b40Gd", + ["vcmpze.f32_1"] = "eeb50ac0d", + ["vcmpze.f64_1"] = "eeb50bc0Gd", + + vldr_2 = "ed100a00dl|ed100b00Gdl", + vstr_2 = "ed000a00dl|ed000b00Gdl", + vldm_2 = "ec900a00or", + vldmia_2 = "ec900a00or", + vldmdb_2 = "ed100a00or", + vpop_1 = "ecbd0a00r", + vstm_2 = "ec800a00or", + vstmia_2 = "ec800a00or", + vstmdb_2 = "ed000a00or", + vpush_1 = "ed2d0a00r", + + ["vmov.f32_2"] = "eeb00a40dm|eeb00a00dY", -- #imm is VFPv3 only + ["vmov.f64_2"] = "eeb00b40Gdm|eeb00b00GdY", -- #imm is VFPv3 only + vmov_2 = "ee100a10Dn|ee000a10nD", + vmov_3 = "ec500a10DNm|ec400a10mDN|ec500b10GDNm|ec400b10GmDN", + + vmrs_0 = "eef1fa10", + vmrs_1 = "eef10a10D", + vmsr_1 = "eee10a10D", + + ["vcvt.s32.f32_2"] = "eebd0ac0dm", + ["vcvt.s32.f64_2"] = "eebd0bc0dGm", + ["vcvt.u32.f32_2"] = "eebc0ac0dm", + ["vcvt.u32.f64_2"] = "eebc0bc0dGm", + ["vcvtr.s32.f32_2"] = "eebd0a40dm", + ["vcvtr.s32.f64_2"] = "eebd0b40dGm", + ["vcvtr.u32.f32_2"] = "eebc0a40dm", + ["vcvtr.u32.f64_2"] = "eebc0b40dGm", + ["vcvt.f32.s32_2"] = "eeb80ac0dm", + ["vcvt.f64.s32_2"] = "eeb80bc0GdFm", + ["vcvt.f32.u32_2"] = "eeb80a40dm", + ["vcvt.f64.u32_2"] = "eeb80b40GdFm", + ["vcvt.f32.f64_2"] = "eeb70bc0dGm", + ["vcvt.f64.f32_2"] = "eeb70ac0GdFm", + + -- VFPv4 only: + ["vfma.f32_3"] = "eea00a00dnm", + ["vfma.f64_3"] = "eea00b00Gdnm", + ["vfms.f32_3"] = "eea00a40dnm", + ["vfms.f64_3"] = "eea00b40Gdnm", + ["vfnma.f32_3"] = "ee900a40dnm", + ["vfnma.f64_3"] = "ee900b40Gdnm", + ["vfnms.f32_3"] = "ee900a00dnm", + ["vfnms.f64_3"] = "ee900b00Gdnm", + + -- NYI: Advanced SIMD instructions. + + -- NYI: I have no need for these instructions right now: + -- swp, swpb, strex, ldrex, strexd, ldrexd, strexb, ldrexb, strexh, ldrexh + -- msr, nopv6, yield, wfe, wfi, sev, dbg, bxj, smc, srs, rfe + -- cps, setend, pli, pld, pldw, clrex, dsb, dmb, isb + -- stc, ldc, mcr, mcr2, mrc, mrc2, mcrr, mcrr2, mrrc, mrrc2, cdp, cdp2 +} + +-- Add mnemonics for "s" variants. +do + local t = {} + for k,v in pairs(map_op) do + if sub(v, -1) == "s" then + local v2 = sub(v, 1, 2)..char(byte(v, 3)+1)..sub(v, 4, -2) + t[sub(k, 1, -3).."s"..sub(k, -2)] = v2 + end + end + for k,v in pairs(t) do + map_op[k] = v + end +end + +------------------------------------------------------------------------------ + +local function parse_gpr(expr) + local tname, ovreg = match(expr, "^([%w_]+):(r1?[0-9])$") + local tp = map_type[tname or expr] + if tp then + local reg = ovreg or tp.reg + if not reg then + werror("type `"..(tname or expr).."' needs a register override") + end + expr = reg + end + local r = match(expr, "^r(1?[0-9])$") + if r then + r = tonumber(r) + if r <= 15 then return r, tp end + end + werror("bad register name `"..expr.."'") +end + +local function parse_gpr_pm(expr) + local pm, expr2 = match(expr, "^([+-]?)(.*)$") + return parse_gpr(expr2), (pm == "-") +end + +local function parse_vr(expr, tp) + local t, r = match(expr, "^([sd])([0-9]+)$") + if t == tp then + r = tonumber(r) + if r <= 31 then + if t == "s" then return shr(r, 1), band(r, 1) end + return band(r, 15), shr(r, 4) + end + end + werror("bad register name `"..expr.."'") +end + +local function parse_reglist(reglist) + reglist = match(reglist, "^{%s*([^}]*)}$") + if not reglist then werror("register list expected") end + local rr = 0 + for p in gmatch(reglist..",", "%s*([^,]*),") do + local rbit = shl(1, parse_gpr(gsub(p, "%s+$", ""))) + if band(rr, rbit) ~= 0 then + werror("duplicate register `"..p.."'") + end + rr = rr + rbit + end + return rr +end + +local function parse_vrlist(reglist) + local ta, ra, tb, rb = match(reglist, + "^{%s*([sd])([0-9]+)%s*%-%s*([sd])([0-9]+)%s*}$") + ra, rb = tonumber(ra), tonumber(rb) + if ta and ta == tb and ra and rb and ra <= 31 and rb <= 31 and ra <= rb then + local nr = rb+1 - ra + if ta == "s" then + return shl(shr(ra,1),12)+shl(band(ra,1),22) + nr + else + return shl(band(ra,15),12)+shl(shr(ra,4),22) + nr*2 + 0x100 + end + end + werror("register list expected") +end + +local function parse_imm(imm, bits, shift, scale, signed) + imm = match(imm, "^#(.*)$") + if not imm then werror("expected immediate operand") end + local n = tonumber(imm) + if n then + local m = sar(n, scale) + if shl(m, scale) == n then + if signed then + local s = sar(m, bits-1) + if s == 0 then return shl(m, shift) + elseif s == -1 then return shl(m + shl(1, bits), shift) end + else + if sar(m, bits) == 0 then return shl(m, shift) end + end + end + werror("out of range immediate `"..imm.."'") + else + waction("IMM", (signed and 32768 or 0)+scale*1024+bits*32+shift, imm) + return 0 + end +end + +local function parse_imm12(imm) + local n = tonumber(imm) + if n then + local m = band(n) + for i=0,-15,-1 do + if shr(m, 8) == 0 then return m + shl(band(i, 15), 8) end + m = ror(m, 2) + end + werror("out of range immediate `"..imm.."'") + else + waction("IMM12", 0, imm) + return 0 + end +end + +local function parse_imm16(imm) + imm = match(imm, "^#(.*)$") + if not imm then werror("expected immediate operand") end + local n = tonumber(imm) + if n then + if shr(n, 16) == 0 then return band(n, 0x0fff) + shl(band(n, 0xf000), 4) end + werror("out of range immediate `"..imm.."'") + else + waction("IMM16", 32*16, imm) + return 0 + end +end + +local function parse_imm_load(imm, ext) + local n = tonumber(imm) + if n then + if ext then + if n >= -255 and n <= 255 then + local up = 0x00800000 + if n < 0 then n = -n; up = 0 end + return shl(band(n, 0xf0), 4) + band(n, 0x0f) + up + end + else + if n >= -4095 and n <= 4095 then + if n >= 0 then return n+0x00800000 end + return -n + end + end + werror("out of range immediate `"..imm.."'") + else + waction(ext and "IMML8" or "IMML12", 32768 + shl(ext and 8 or 12, 5), imm) + return 0 + end +end + +local function parse_shift(shift, gprok) + if shift == "rrx" then + return 3 * 32 + else + local s, s2 = match(shift, "^(%S+)%s*(.*)$") + s = map_shift[s] + if not s then werror("expected shift operand") end + if sub(s2, 1, 1) == "#" then + return parse_imm(s2, 5, 7, 0, false) + shl(s, 5) + else + if not gprok then werror("expected immediate shift operand") end + return shl(parse_gpr(s2), 8) + shl(s, 5) + 16 + end + end +end + +local function parse_label(label, def) + local prefix = sub(label, 1, 2) + -- =>label (pc label reference) + if prefix == "=>" then + return "PC", 0, sub(label, 3) + end + -- ->name (global label reference) + if prefix == "->" then + return "LG", map_global[sub(label, 3)] + end + if def then + -- [1-9] (local label definition) + if match(label, "^[1-9]$") then + return "LG", 10+tonumber(label) + end + else + -- [<>][1-9] (local label reference) + local dir, lnum = match(label, "^([<>])([1-9])$") + if dir then -- Fwd: 1-9, Bkwd: 11-19. + return "LG", lnum + (dir == ">" and 0 or 10) + end + -- extern label (extern label reference) + local extname = match(label, "^extern%s+(%S+)$") + if extname then + return "EXT", map_extern[extname] + end + end + werror("bad label `"..label.."'") +end + +local function parse_load(params, nparams, n, op) + local oplo = band(op, 255) + local ext, ldrd = (oplo ~= 0), (oplo == 208) + local d + if (ldrd or oplo == 240) then + d = band(shr(op, 12), 15) + if band(d, 1) ~= 0 then werror("odd destination register") end + end + local pn = params[n] + local p1, wb = match(pn, "^%[%s*(.-)%s*%](!?)$") + local p2 = params[n+1] + if not p1 then + if not p2 then + if match(pn, "^[<>=%-]") or match(pn, "^extern%s+") then + local mode, n, s = parse_label(pn, false) + waction("REL_"..mode, n + (ext and 0x1800 or 0x0800), s, 1) + return op + 15 * 65536 + 0x01000000 + (ext and 0x00400000 or 0) + end + local reg, tailr = match(pn, "^([%w_:]+)%s*(.*)$") + if reg and tailr ~= "" then + local d, tp = parse_gpr(reg) + if tp then + waction(ext and "IMML8" or "IMML12", 32768 + 32*(ext and 8 or 12), + format(tp.ctypefmt, tailr)) + return op + shl(d, 16) + 0x01000000 + (ext and 0x00400000 or 0) + end + end + end + werror("expected address operand") + end + if wb == "!" then op = op + 0x00200000 end + if p2 then + if wb == "!" then werror("bad use of '!'") end + local p3 = params[n+2] + op = op + shl(parse_gpr(p1), 16) + local imm = match(p2, "^#(.*)$") + if imm then + local m = parse_imm_load(imm, ext) + if p3 then werror("too many parameters") end + op = op + m + (ext and 0x00400000 or 0) + else + local m, neg = parse_gpr_pm(p2) + if ldrd and (m == d or m-1 == d) then werror("register conflict") end + op = op + m + (neg and 0 or 0x00800000) + (ext and 0 or 0x02000000) + if p3 then op = op + parse_shift(p3) end + end + else + local p1a, p2 = match(p1, "^([^,%s]*)%s*(.*)$") + op = op + shl(parse_gpr(p1a), 16) + 0x01000000 + if p2 ~= "" then + local imm = match(p2, "^,%s*#(.*)$") + if imm then + local m = parse_imm_load(imm, ext) + op = op + m + (ext and 0x00400000 or 0) + else + local p2a, p3 = match(p2, "^,%s*([^,%s]*)%s*,?%s*(.*)$") + local m, neg = parse_gpr_pm(p2a) + if ldrd and (m == d or m-1 == d) then werror("register conflict") end + op = op + m + (neg and 0 or 0x00800000) + (ext and 0 or 0x02000000) + if p3 ~= "" then + if ext then werror("too many parameters") end + op = op + parse_shift(p3) + end + end + else + if wb == "!" then werror("bad use of '!'") end + op = op + (ext and 0x00c00000 or 0x00800000) + end + end + return op +end + +local function parse_vload(q) + local reg, imm = match(q, "^%[%s*([^,%s]*)%s*(.*)%]$") + if reg then + local d = shl(parse_gpr(reg), 16) + if imm == "" then return d end + imm = match(imm, "^,%s*#(.*)$") + if imm then + local n = tonumber(imm) + if n then + if n >= -1020 and n <= 1020 and n%4 == 0 then + return d + (n >= 0 and n/4+0x00800000 or -n/4) + end + werror("out of range immediate `"..imm.."'") + else + waction("IMMV8", 32768 + 32*8, imm) + return d + end + end + else + if match(q, "^[<>=%-]") or match(q, "^extern%s+") then + local mode, n, s = parse_label(q, false) + waction("REL_"..mode, n + 0x2800, s, 1) + return 15 * 65536 + end + local reg, tailr = match(q, "^([%w_:]+)%s*(.*)$") + if reg and tailr ~= "" then + local d, tp = parse_gpr(reg) + if tp then + waction("IMMV8", 32768 + 32*8, format(tp.ctypefmt, tailr)) + return shl(d, 16) + end + end + end + werror("expected address operand") +end + +------------------------------------------------------------------------------ + +-- Handle opcodes defined with template strings. +local function parse_template(params, template, nparams, pos) + local op = tonumber(sub(template, 1, 8), 16) + local n = 1 + local vr = "s" + + -- Process each character. + for p in gmatch(sub(template, 9), ".") do + local q = params[n] + if p == "D" then + op = op + shl(parse_gpr(q), 12); n = n + 1 + elseif p == "N" then + op = op + shl(parse_gpr(q), 16); n = n + 1 + elseif p == "S" then + op = op + shl(parse_gpr(q), 8); n = n + 1 + elseif p == "M" then + op = op + parse_gpr(q); n = n + 1 + elseif p == "d" then + local r,h = parse_vr(q, vr); op = op+shl(r,12)+shl(h,22); n = n + 1 + elseif p == "n" then + local r,h = parse_vr(q, vr); op = op+shl(r,16)+shl(h,7); n = n + 1 + elseif p == "m" then + local r,h = parse_vr(q, vr); op = op+r+shl(h,5); n = n + 1 + elseif p == "P" then + local imm = match(q, "^#(.*)$") + if imm then + op = op + parse_imm12(imm) + 0x02000000 + else + op = op + parse_gpr(q) + end + n = n + 1 + elseif p == "p" then + op = op + parse_shift(q, true); n = n + 1 + elseif p == "L" then + op = parse_load(params, nparams, n, op) + elseif p == "l" then + op = op + parse_vload(q) + elseif p == "B" then + local mode, n, s = parse_label(q, false) + waction("REL_"..mode, n, s, 1) + elseif p == "C" then -- blx gpr vs. blx label. + if match(q, "^([%w_]+):(r1?[0-9])$") or match(q, "^r(1?[0-9])$") then + op = op + parse_gpr(q) + else + if op < 0xe0000000 then werror("unconditional instruction") end + local mode, n, s = parse_label(q, false) + waction("REL_"..mode, n, s, 1) + op = 0xfa000000 + end + elseif p == "F" then + vr = "s" + elseif p == "G" then + vr = "d" + elseif p == "o" then + local r, wb = match(q, "^([^!]*)(!?)$") + op = op + shl(parse_gpr(r), 16) + (wb == "!" and 0x00200000 or 0) + n = n + 1 + elseif p == "R" then + op = op + parse_reglist(q); n = n + 1 + elseif p == "r" then + op = op + parse_vrlist(q); n = n + 1 + elseif p == "W" then + op = op + parse_imm16(q); n = n + 1 + elseif p == "v" then + op = op + parse_imm(q, 5, 7, 0, false); n = n + 1 + elseif p == "w" then + local imm = match(q, "^#(.*)$") + if imm then + op = op + parse_imm(q, 5, 7, 0, false); n = n + 1 + else + op = op + shl(parse_gpr(q), 8) + 16 + end + elseif p == "X" then + op = op + parse_imm(q, 5, 16, 0, false); n = n + 1 + elseif p == "Y" then + local imm = tonumber(match(q, "^#(.*)$")); n = n + 1 + if not imm or shr(imm, 8) ~= 0 then + werror("bad immediate operand") + end + op = op + shl(band(imm, 0xf0), 12) + band(imm, 0x0f) + elseif p == "K" then + local imm = tonumber(match(q, "^#(.*)$")); n = n + 1 + if not imm or shr(imm, 16) ~= 0 then + werror("bad immediate operand") + end + op = op + shl(band(imm, 0xfff0), 4) + band(imm, 0x000f) + elseif p == "T" then + op = op + parse_imm(q, 24, 0, 0, false); n = n + 1 + elseif p == "s" then + -- Ignored. + else + assert(false) + end + end + wputpos(pos, op) +end + +map_op[".template__"] = function(params, template, nparams) + if not params then return template:gsub("%x%x%x%x%x%x%x%x", "") end + + -- Limit number of section buffer positions used by a single dasm_put(). + -- A single opcode needs a maximum of 3 positions. + if secpos+3 > maxsecpos then wflush() end + local pos = wpos() + local lpos, apos, spos = #actlist, #actargs, secpos + + local ok, err + for t in gmatch(template, "[^|]+") do + ok, err = pcall(parse_template, params, t, nparams, pos) + if ok then return end + secpos = spos + actlist[lpos+1] = nil + actlist[lpos+2] = nil + actlist[lpos+3] = nil + actargs[apos+1] = nil + actargs[apos+2] = nil + actargs[apos+3] = nil + end + error(err, 0) +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcode to mark the position where the action list is to be emitted. +map_op[".actionlist_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeactions(out, name) end) +end + +-- Pseudo-opcode to mark the position where the global enum is to be emitted. +map_op[".globals_1"] = function(params) + if not params then return "prefix" end + local prefix = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeglobals(out, prefix) end) +end + +-- Pseudo-opcode to mark the position where the global names are to be emitted. +map_op[".globalnames_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeglobalnames(out, name) end) +end + +-- Pseudo-opcode to mark the position where the extern names are to be emitted. +map_op[".externnames_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeexternnames(out, name) end) +end + +------------------------------------------------------------------------------ + +-- Label pseudo-opcode (converted from trailing colon form). +map_op[".label_1"] = function(params) + if not params then return "[1-9] | ->global | =>pcexpr" end + if secpos+1 > maxsecpos then wflush() end + local mode, n, s = parse_label(params[1], true) + if mode == "EXT" then werror("bad label definition") end + waction("LABEL_"..mode, n, s, 1) +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcodes for data storage. +map_op[".long_*"] = function(params) + if not params then return "imm..." end + for _,p in ipairs(params) do + local n = tonumber(p) + if not n then werror("bad immediate `"..p.."'") end + if n < 0 then n = n + 2^32 end + wputw(n) + if secpos+2 > maxsecpos then wflush() end + end +end + +-- Alignment pseudo-opcode. +map_op[".align_1"] = function(params) + if not params then return "numpow2" end + if secpos+1 > maxsecpos then wflush() end + local align = tonumber(params[1]) + if align then + local x = align + -- Must be a power of 2 in the range (2 ... 256). + for i=1,8 do + x = x / 2 + if x == 1 then + waction("ALIGN", align-1, nil, 1) -- Action byte is 2**n-1. + return + end + end + end + werror("bad alignment") +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcode for (primitive) type definitions (map to C types). +map_op[".type_3"] = function(params, nparams) + if not params then + return nparams == 2 and "name, ctype" or "name, ctype, reg" + end + local name, ctype, reg = params[1], params[2], params[3] + if not match(name, "^[%a_][%w_]*$") then + werror("bad type name `"..name.."'") + end + local tp = map_type[name] + if tp then + werror("duplicate type `"..name.."'") + end + -- Add #type to defines. A bit unclean to put it in map_archdef. + map_archdef["#"..name] = "sizeof("..ctype..")" + -- Add new type and emit shortcut define. + local num = ctypenum + 1 + map_type[name] = { + ctype = ctype, + ctypefmt = format("Dt%X(%%s)", num), + reg = reg, + } + wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype)) + ctypenum = num +end +map_op[".type_2"] = map_op[".type_3"] + +-- Dump type definitions. +local function dumptypes(out, lvl) + local t = {} + for name in pairs(map_type) do t[#t+1] = name end + sort(t) + out:write("Type definitions:\n") + for _,name in ipairs(t) do + local tp = map_type[name] + local reg = tp.reg or "" + out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg)) + end + out:write("\n") +end + +------------------------------------------------------------------------------ + +-- Set the current section. +function _M.section(num) + waction("SECTION", num) + wflush(true) -- SECTION is a terminal action. +end + +------------------------------------------------------------------------------ + +-- Dump architecture description. +function _M.dumparch(out) + out:write(format("DynASM %s version %s, released %s\n\n", + _info.arch, _info.version, _info.release)) + dumpactions(out) +end + +-- Dump all user defined elements. +function _M.dumpdef(out, lvl) + dumptypes(out, lvl) + dumpglobals(out, lvl) + dumpexterns(out, lvl) +end + +------------------------------------------------------------------------------ + +-- Pass callbacks from/to the DynASM core. +function _M.passcb(wl, we, wf, ww) + wline, werror, wfatal, wwarn = wl, we, wf, ww + return wflush +end + +-- Setup the arch-specific module. +function _M.setup(arch, opt) + g_arch, g_opt = arch, opt +end + +-- Merge the core maps and the arch-specific maps. +function _M.mergemaps(map_coreop, map_def) + setmetatable(map_op, { __index = function(t, k) + local v = map_coreop[k] + if v then return v end + local k1, cc, k2 = match(k, "^(.-)(..)([._].*)$") + local cv = map_cond[cc] + if cv then + local v = rawget(t, k1..k2) + if type(v) == "string" then + local scv = format("%x", cv) + return gsub(scv..sub(v, 2), "|e", "|"..scv) + end + end + end }) + setmetatable(map_def, { __index = map_archdef }) + return map_op, map_def +end + +return _M + +------------------------------------------------------------------------------ + diff --git a/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_mips.h b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_mips.h new file mode 100644 index 000000000..2f4c2d222 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_mips.h @@ -0,0 +1,416 @@ +/* +** DynASM MIPS encoding engine. +** Copyright (C) 2005-2015 Mike Pall. All rights reserved. +** Released under the MIT license. See dynasm.lua for full copyright notice. +*/ + +#include +#include +#include +#include + +#define DASM_ARCH "mips" + +#ifndef DASM_EXTERN +#define DASM_EXTERN(a,b,c,d) 0 +#endif + +/* Action definitions. */ +enum { + DASM_STOP, DASM_SECTION, DASM_ESC, DASM_REL_EXT, + /* The following actions need a buffer position. */ + DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG, + /* The following actions also have an argument. */ + DASM_REL_PC, DASM_LABEL_PC, DASM_IMM, + DASM__MAX +}; + +/* Maximum number of section buffer positions for a single dasm_put() call. */ +#define DASM_MAXSECPOS 25 + +/* DynASM encoder status codes. Action list offset or number are or'ed in. */ +#define DASM_S_OK 0x00000000 +#define DASM_S_NOMEM 0x01000000 +#define DASM_S_PHASE 0x02000000 +#define DASM_S_MATCH_SEC 0x03000000 +#define DASM_S_RANGE_I 0x11000000 +#define DASM_S_RANGE_SEC 0x12000000 +#define DASM_S_RANGE_LG 0x13000000 +#define DASM_S_RANGE_PC 0x14000000 +#define DASM_S_RANGE_REL 0x15000000 +#define DASM_S_UNDEF_LG 0x21000000 +#define DASM_S_UNDEF_PC 0x22000000 + +/* Macros to convert positions (8 bit section + 24 bit index). */ +#define DASM_POS2IDX(pos) ((pos)&0x00ffffff) +#define DASM_POS2BIAS(pos) ((pos)&0xff000000) +#define DASM_SEC2POS(sec) ((sec)<<24) +#define DASM_POS2SEC(pos) ((pos)>>24) +#define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) + +/* Action list type. */ +typedef const unsigned int *dasm_ActList; + +/* Per-section structure. */ +typedef struct dasm_Section { + int *rbuf; /* Biased buffer pointer (negative section bias). */ + int *buf; /* True buffer pointer. */ + size_t bsize; /* Buffer size in bytes. */ + int pos; /* Biased buffer position. */ + int epos; /* End of biased buffer position - max single put. */ + int ofs; /* Byte offset into section. */ +} dasm_Section; + +/* Core structure holding the DynASM encoding state. */ +struct dasm_State { + size_t psize; /* Allocated size of this structure. */ + dasm_ActList actionlist; /* Current actionlist pointer. */ + int *lglabels; /* Local/global chain/pos ptrs. */ + size_t lgsize; + int *pclabels; /* PC label chains/pos ptrs. */ + size_t pcsize; + void **globals; /* Array of globals (bias -10). */ + dasm_Section *section; /* Pointer to active section. */ + size_t codesize; /* Total size of all code sections. */ + int maxsection; /* 0 <= sectionidx < maxsection. */ + int status; /* Status code. */ + dasm_Section sections[1]; /* All sections. Alloc-extended. */ +}; + +/* The size of the core structure depends on the max. number of sections. */ +#define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section)) + + +/* Initialize DynASM state. */ +void dasm_init(Dst_DECL, int maxsection) +{ + dasm_State *D; + size_t psz = 0; + int i; + Dst_REF = NULL; + DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); + D = Dst_REF; + D->psize = psz; + D->lglabels = NULL; + D->lgsize = 0; + D->pclabels = NULL; + D->pcsize = 0; + D->globals = NULL; + D->maxsection = maxsection; + for (i = 0; i < maxsection; i++) { + D->sections[i].buf = NULL; /* Need this for pass3. */ + D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i); + D->sections[i].bsize = 0; + D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ + } +} + +/* Free DynASM state. */ +void dasm_free(Dst_DECL) +{ + dasm_State *D = Dst_REF; + int i; + for (i = 0; i < D->maxsection; i++) + if (D->sections[i].buf) + DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize); + if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize); + if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize); + DASM_M_FREE(Dst, D, D->psize); +} + +/* Setup global label array. Must be called before dasm_setup(). */ +void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) +{ + dasm_State *D = Dst_REF; + D->globals = gl - 10; /* Negative bias to compensate for locals. */ + DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); +} + +/* Grow PC label array. Can be called after dasm_setup(), too. */ +void dasm_growpc(Dst_DECL, unsigned int maxpc) +{ + dasm_State *D = Dst_REF; + size_t osz = D->pcsize; + DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int)); + memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz); +} + +/* Setup encoder. */ +void dasm_setup(Dst_DECL, const void *actionlist) +{ + dasm_State *D = Dst_REF; + int i; + D->actionlist = (dasm_ActList)actionlist; + D->status = DASM_S_OK; + D->section = &D->sections[0]; + memset((void *)D->lglabels, 0, D->lgsize); + if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); + for (i = 0; i < D->maxsection; i++) { + D->sections[i].pos = DASM_SEC2POS(i); + D->sections[i].ofs = 0; + } +} + + +#ifdef DASM_CHECKS +#define CK(x, st) \ + do { if (!(x)) { \ + D->status = DASM_S_##st|(p-D->actionlist-1); return; } } while (0) +#define CKPL(kind, st) \ + do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \ + D->status = DASM_S_RANGE_##st|(p-D->actionlist-1); return; } } while (0) +#else +#define CK(x, st) ((void)0) +#define CKPL(kind, st) ((void)0) +#endif + +/* Pass 1: Store actions and args, link branches/labels, estimate offsets. */ +void dasm_put(Dst_DECL, int start, ...) +{ + va_list ap; + dasm_State *D = Dst_REF; + dasm_ActList p = D->actionlist + start; + dasm_Section *sec = D->section; + int pos = sec->pos, ofs = sec->ofs; + int *b; + + if (pos >= sec->epos) { + DASM_M_GROW(Dst, int, sec->buf, sec->bsize, + sec->bsize + 2*DASM_MAXSECPOS*sizeof(int)); + sec->rbuf = sec->buf - DASM_POS2BIAS(pos); + sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos); + } + + b = sec->rbuf; + b[pos++] = start; + + va_start(ap, start); + while (1) { + unsigned int ins = *p++; + unsigned int action = (ins >> 16) - 0xff00; + if (action >= DASM__MAX) { + ofs += 4; + } else { + int *pl, n = action >= DASM_REL_PC ? va_arg(ap, int) : 0; + switch (action) { + case DASM_STOP: goto stop; + case DASM_SECTION: + n = (ins & 255); CK(n < D->maxsection, RANGE_SEC); + D->section = &D->sections[n]; goto stop; + case DASM_ESC: p++; ofs += 4; break; + case DASM_REL_EXT: break; + case DASM_ALIGN: ofs += (ins & 255); b[pos++] = ofs; break; + case DASM_REL_LG: + n = (ins & 2047) - 10; pl = D->lglabels + n; + /* Bkwd rel or global. */ + if (n >= 0) { CK(n>=10||*pl<0, RANGE_LG); CKPL(lg, LG); goto putrel; } + pl += 10; n = *pl; + if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */ + goto linkrel; + case DASM_REL_PC: + pl = D->pclabels + n; CKPL(pc, PC); + putrel: + n = *pl; + if (n < 0) { /* Label exists. Get label pos and store it. */ + b[pos] = -n; + } else { + linkrel: + b[pos] = n; /* Else link to rel chain, anchored at label. */ + *pl = pos; + } + pos++; + break; + case DASM_LABEL_LG: + pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel; + case DASM_LABEL_PC: + pl = D->pclabels + n; CKPL(pc, PC); + putlabel: + n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */ + while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; + } + *pl = -pos; /* Label exists now. */ + b[pos++] = ofs; /* Store pass1 offset estimate. */ + break; + case DASM_IMM: +#ifdef DASM_CHECKS + CK((n & ((1<<((ins>>10)&31))-1)) == 0, RANGE_I); +#endif + n >>= ((ins>>10)&31); +#ifdef DASM_CHECKS + if (ins & 0x8000) + CK(((n + (1<<(((ins>>5)&31)-1)))>>((ins>>5)&31)) == 0, RANGE_I); + else + CK((n>>((ins>>5)&31)) == 0, RANGE_I); +#endif + b[pos++] = n; + break; + } + } + } +stop: + va_end(ap); + sec->pos = pos; + sec->ofs = ofs; +} +#undef CK + +/* Pass 2: Link sections, shrink aligns, fix label offsets. */ +int dasm_link(Dst_DECL, size_t *szp) +{ + dasm_State *D = Dst_REF; + int secnum; + int ofs = 0; + +#ifdef DASM_CHECKS + *szp = 0; + if (D->status != DASM_S_OK) return D->status; + { + int pc; + for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) + if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; + } +#endif + + { /* Handle globals not defined in this translation unit. */ + int idx; + for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) { + int n = D->lglabels[idx]; + /* Undefined label: Collapse rel chain and replace with marker (< 0). */ + while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } + } + } + + /* Combine all code sections. No support for data sections (yet). */ + for (secnum = 0; secnum < D->maxsection; secnum++) { + dasm_Section *sec = D->sections + secnum; + int *b = sec->rbuf; + int pos = DASM_SEC2POS(secnum); + int lastpos = sec->pos; + + while (pos != lastpos) { + dasm_ActList p = D->actionlist + b[pos++]; + while (1) { + unsigned int ins = *p++; + unsigned int action = (ins >> 16) - 0xff00; + switch (action) { + case DASM_STOP: case DASM_SECTION: goto stop; + case DASM_ESC: p++; break; + case DASM_REL_EXT: break; + case DASM_ALIGN: ofs -= (b[pos++] + ofs) & (ins & 255); break; + case DASM_REL_LG: case DASM_REL_PC: pos++; break; + case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break; + case DASM_IMM: pos++; break; + } + } + stop: (void)0; + } + ofs += sec->ofs; /* Next section starts right after current section. */ + } + + D->codesize = ofs; /* Total size of all code sections */ + *szp = ofs; + return DASM_S_OK; +} + +#ifdef DASM_CHECKS +#define CK(x, st) \ + do { if (!(x)) return DASM_S_##st|(p-D->actionlist-1); } while (0) +#else +#define CK(x, st) ((void)0) +#endif + +/* Pass 3: Encode sections. */ +int dasm_encode(Dst_DECL, void *buffer) +{ + dasm_State *D = Dst_REF; + char *base = (char *)buffer; + unsigned int *cp = (unsigned int *)buffer; + int secnum; + + /* Encode all code sections. No support for data sections (yet). */ + for (secnum = 0; secnum < D->maxsection; secnum++) { + dasm_Section *sec = D->sections + secnum; + int *b = sec->buf; + int *endb = sec->rbuf + sec->pos; + + while (b != endb) { + dasm_ActList p = D->actionlist + *b++; + while (1) { + unsigned int ins = *p++; + unsigned int action = (ins >> 16) - 0xff00; + int n = (action >= DASM_ALIGN && action < DASM__MAX) ? *b++ : 0; + switch (action) { + case DASM_STOP: case DASM_SECTION: goto stop; + case DASM_ESC: *cp++ = *p++; break; + case DASM_REL_EXT: + n = DASM_EXTERN(Dst, (unsigned char *)cp, (ins & 2047), 1); + goto patchrel; + case DASM_ALIGN: + ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0x60000000; + break; + case DASM_REL_LG: + CK(n >= 0, UNDEF_LG); + case DASM_REL_PC: + CK(n >= 0, UNDEF_PC); + n = *DASM_POS2PTR(D, n); + if (ins & 2048) + n = n - (int)((char *)cp - base); + else + n = (n + (int)base) & 0x0fffffff; + patchrel: + CK((n & 3) == 0 && + ((n + ((ins & 2048) ? 0x00020000 : 0)) >> + ((ins & 2048) ? 18 : 28)) == 0, RANGE_REL); + cp[-1] |= ((n>>2) & ((ins & 2048) ? 0x0000ffff: 0x03ffffff)); + break; + case DASM_LABEL_LG: + ins &= 2047; if (ins >= 20) D->globals[ins-10] = (void *)(base + n); + break; + case DASM_LABEL_PC: break; + case DASM_IMM: + cp[-1] |= (n & ((1<<((ins>>5)&31))-1)) << (ins&31); + break; + default: *cp++ = ins; break; + } + } + stop: (void)0; + } + } + + if (base + D->codesize != (char *)cp) /* Check for phase errors. */ + return DASM_S_PHASE; + return DASM_S_OK; +} +#undef CK + +/* Get PC label offset. */ +int dasm_getpclabel(Dst_DECL, unsigned int pc) +{ + dasm_State *D = Dst_REF; + if (pc*sizeof(int) < D->pcsize) { + int pos = D->pclabels[pc]; + if (pos < 0) return *DASM_POS2PTR(D, -pos); + if (pos > 0) return -1; /* Undefined. */ + } + return -2; /* Unused or out of range. */ +} + +#ifdef DASM_CHECKS +/* Optional sanity checker to call between isolated encoding steps. */ +int dasm_checkstep(Dst_DECL, int secmatch) +{ + dasm_State *D = Dst_REF; + if (D->status == DASM_S_OK) { + int i; + for (i = 1; i <= 9; i++) { + if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_LG|i; break; } + D->lglabels[i] = 0; + } + } + if (D->status == DASM_S_OK && secmatch >= 0 && + D->section != &D->sections[secmatch]) + D->status = DASM_S_MATCH_SEC|(D->section-D->sections); + return D->status; +} +#endif + diff --git a/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_mips.lua b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_mips.lua new file mode 100644 index 000000000..ae0dbd7a9 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_mips.lua @@ -0,0 +1,953 @@ +------------------------------------------------------------------------------ +-- DynASM MIPS module. +-- +-- Copyright (C) 2005-2015 Mike Pall. All rights reserved. +-- See dynasm.lua for full copyright notice. +------------------------------------------------------------------------------ + +-- Module information: +local _info = { + arch = "mips", + description = "DynASM MIPS module", + version = "1.3.0", + vernum = 10300, + release = "2012-01-23", + author = "Mike Pall", + license = "MIT", +} + +-- Exported glue functions for the arch-specific module. +local _M = { _info = _info } + +-- Cache library functions. +local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs +local assert, setmetatable = assert, setmetatable +local _s = string +local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char +local match, gmatch = _s.match, _s.gmatch +local concat, sort = table.concat, table.sort +local bit = bit or require("bit") +local band, shl, sar, tohex = bit.band, bit.lshift, bit.arshift, bit.tohex + +-- Inherited tables and callbacks. +local g_opt, g_arch +local wline, werror, wfatal, wwarn + +-- Action name list. +-- CHECK: Keep this in sync with the C code! +local action_names = { + "STOP", "SECTION", "ESC", "REL_EXT", + "ALIGN", "REL_LG", "LABEL_LG", + "REL_PC", "LABEL_PC", "IMM", +} + +-- Maximum number of section buffer positions for dasm_put(). +-- CHECK: Keep this in sync with the C code! +local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines. + +-- Action name -> action number. +local map_action = {} +for n,name in ipairs(action_names) do + map_action[name] = n-1 +end + +-- Action list buffer. +local actlist = {} + +-- Argument list for next dasm_put(). Start with offset 0 into action list. +local actargs = { 0 } + +-- Current number of section buffer positions for dasm_put(). +local secpos = 1 + +------------------------------------------------------------------------------ + +-- Dump action names and numbers. +local function dumpactions(out) + out:write("DynASM encoding engine action codes:\n") + for n,name in ipairs(action_names) do + local num = map_action[name] + out:write(format(" %-10s %02X %d\n", name, num, num)) + end + out:write("\n") +end + +-- Write action list buffer as a huge static C array. +local function writeactions(out, name) + local nn = #actlist + if nn == 0 then nn = 1; actlist[0] = map_action.STOP end + out:write("static const unsigned int ", name, "[", nn, "] = {\n") + for i = 1,nn-1 do + assert(out:write("0x", tohex(actlist[i]), ",\n")) + end + assert(out:write("0x", tohex(actlist[nn]), "\n};\n\n")) +end + +------------------------------------------------------------------------------ + +-- Add word to action list. +local function wputxw(n) + assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") + actlist[#actlist+1] = n +end + +-- Add action to list with optional arg. Advance buffer pos, too. +local function waction(action, val, a, num) + local w = assert(map_action[action], "bad action name `"..action.."'") + wputxw(0xff000000 + w * 0x10000 + (val or 0)) + if a then actargs[#actargs+1] = a end + if a or num then secpos = secpos + (num or 1) end +end + +-- Flush action list (intervening C code or buffer pos overflow). +local function wflush(term) + if #actlist == actargs[1] then return end -- Nothing to flush. + if not term then waction("STOP") end -- Terminate action list. + wline(format("dasm_put(Dst, %s);", concat(actargs, ", ")), true) + actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put(). + secpos = 1 -- The actionlist offset occupies a buffer position, too. +end + +-- Put escaped word. +local function wputw(n) + if n >= 0xff000000 then waction("ESC") end + wputxw(n) +end + +-- Reserve position for word. +local function wpos() + local pos = #actlist+1 + actlist[pos] = "" + return pos +end + +-- Store word to reserved position. +local function wputpos(pos, n) + assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") + actlist[pos] = n +end + +------------------------------------------------------------------------------ + +-- Global label name -> global label number. With auto assignment on 1st use. +local next_global = 20 +local map_global = setmetatable({}, { __index = function(t, name) + if not match(name, "^[%a_][%w_]*$") then werror("bad global label") end + local n = next_global + if n > 2047 then werror("too many global labels") end + next_global = n + 1 + t[name] = n + return n +end}) + +-- Dump global labels. +local function dumpglobals(out, lvl) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("Global labels:\n") + for i=20,next_global-1 do + out:write(format(" %s\n", t[i])) + end + out:write("\n") +end + +-- Write global label enum. +local function writeglobals(out, prefix) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("enum {\n") + for i=20,next_global-1 do + out:write(" ", prefix, t[i], ",\n") + end + out:write(" ", prefix, "_MAX\n};\n") +end + +-- Write global label names. +local function writeglobalnames(out, name) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("static const char *const ", name, "[] = {\n") + for i=20,next_global-1 do + out:write(" \"", t[i], "\",\n") + end + out:write(" (const char *)0\n};\n") +end + +------------------------------------------------------------------------------ + +-- Extern label name -> extern label number. With auto assignment on 1st use. +local next_extern = 0 +local map_extern_ = {} +local map_extern = setmetatable({}, { __index = function(t, name) + -- No restrictions on the name for now. + local n = next_extern + if n > 2047 then werror("too many extern labels") end + next_extern = n + 1 + t[name] = n + map_extern_[n] = name + return n +end}) + +-- Dump extern labels. +local function dumpexterns(out, lvl) + out:write("Extern labels:\n") + for i=0,next_extern-1 do + out:write(format(" %s\n", map_extern_[i])) + end + out:write("\n") +end + +-- Write extern label names. +local function writeexternnames(out, name) + out:write("static const char *const ", name, "[] = {\n") + for i=0,next_extern-1 do + out:write(" \"", map_extern_[i], "\",\n") + end + out:write(" (const char *)0\n};\n") +end + +------------------------------------------------------------------------------ + +-- Arch-specific maps. +local map_archdef = { sp="r29", ra="r31" } -- Ext. register name -> int. name. + +local map_type = {} -- Type name -> { ctype, reg } +local ctypenum = 0 -- Type number (for Dt... macros). + +-- Reverse defines for registers. +function _M.revdef(s) + if s == "r29" then return "sp" + elseif s == "r31" then return "ra" end + return s +end + +------------------------------------------------------------------------------ + +-- Template strings for MIPS instructions. +local map_op = { + -- First-level opcodes. + j_1 = "08000000J", + jal_1 = "0c000000J", + b_1 = "10000000B", + beqz_2 = "10000000SB", + beq_3 = "10000000STB", + bnez_2 = "14000000SB", + bne_3 = "14000000STB", + blez_2 = "18000000SB", + bgtz_2 = "1c000000SB", + addi_3 = "20000000TSI", + li_2 = "24000000TI", + addiu_3 = "24000000TSI", + slti_3 = "28000000TSI", + sltiu_3 = "2c000000TSI", + andi_3 = "30000000TSU", + lu_2 = "34000000TU", + ori_3 = "34000000TSU", + xori_3 = "38000000TSU", + lui_2 = "3c000000TU", + beqzl_2 = "50000000SB", + beql_3 = "50000000STB", + bnezl_2 = "54000000SB", + bnel_3 = "54000000STB", + blezl_2 = "58000000SB", + bgtzl_2 = "5c000000SB", + lb_2 = "80000000TO", + lh_2 = "84000000TO", + lwl_2 = "88000000TO", + lw_2 = "8c000000TO", + lbu_2 = "90000000TO", + lhu_2 = "94000000TO", + lwr_2 = "98000000TO", + sb_2 = "a0000000TO", + sh_2 = "a4000000TO", + swl_2 = "a8000000TO", + sw_2 = "ac000000TO", + swr_2 = "b8000000TO", + cache_2 = "bc000000NO", + ll_2 = "c0000000TO", + lwc1_2 = "c4000000HO", + pref_2 = "cc000000NO", + ldc1_2 = "d4000000HO", + sc_2 = "e0000000TO", + swc1_2 = "e4000000HO", + sdc1_2 = "f4000000HO", + + -- Opcode SPECIAL. + nop_0 = "00000000", + sll_3 = "00000000DTA", + movf_2 = "00000001DS", + movf_3 = "00000001DSC", + movt_2 = "00010001DS", + movt_3 = "00010001DSC", + srl_3 = "00000002DTA", + rotr_3 = "00200002DTA", + sra_3 = "00000003DTA", + sllv_3 = "00000004DTS", + srlv_3 = "00000006DTS", + rotrv_3 = "00000046DTS", + srav_3 = "00000007DTS", + jr_1 = "00000008S", + jalr_1 = "0000f809S", + jalr_2 = "00000009DS", + movz_3 = "0000000aDST", + movn_3 = "0000000bDST", + syscall_0 = "0000000c", + syscall_1 = "0000000cY", + break_0 = "0000000d", + break_1 = "0000000dY", + sync_0 = "0000000f", + mfhi_1 = "00000010D", + mthi_1 = "00000011S", + mflo_1 = "00000012D", + mtlo_1 = "00000013S", + mult_2 = "00000018ST", + multu_2 = "00000019ST", + div_2 = "0000001aST", + divu_2 = "0000001bST", + add_3 = "00000020DST", + move_2 = "00000021DS", + addu_3 = "00000021DST", + sub_3 = "00000022DST", + negu_2 = "00000023DT", + subu_3 = "00000023DST", + and_3 = "00000024DST", + or_3 = "00000025DST", + xor_3 = "00000026DST", + not_2 = "00000027DS", + nor_3 = "00000027DST", + slt_3 = "0000002aDST", + sltu_3 = "0000002bDST", + tge_2 = "00000030ST", + tge_3 = "00000030STZ", + tgeu_2 = "00000031ST", + tgeu_3 = "00000031STZ", + tlt_2 = "00000032ST", + tlt_3 = "00000032STZ", + tltu_2 = "00000033ST", + tltu_3 = "00000033STZ", + teq_2 = "00000034ST", + teq_3 = "00000034STZ", + tne_2 = "00000036ST", + tne_3 = "00000036STZ", + + -- Opcode REGIMM. + bltz_2 = "04000000SB", + bgez_2 = "04010000SB", + bltzl_2 = "04020000SB", + bgezl_2 = "04030000SB", + tgei_2 = "04080000SI", + tgeiu_2 = "04090000SI", + tlti_2 = "040a0000SI", + tltiu_2 = "040b0000SI", + teqi_2 = "040c0000SI", + tnei_2 = "040e0000SI", + bltzal_2 = "04100000SB", + bal_1 = "04110000B", + bgezal_2 = "04110000SB", + bltzall_2 = "04120000SB", + bgezall_2 = "04130000SB", + synci_1 = "041f0000O", + + -- Opcode SPECIAL2. + madd_2 = "70000000ST", + maddu_2 = "70000001ST", + mul_3 = "70000002DST", + msub_2 = "70000004ST", + msubu_2 = "70000005ST", + clz_2 = "70000020DS=", + clo_2 = "70000021DS=", + sdbbp_0 = "7000003f", + sdbbp_1 = "7000003fY", + + -- Opcode SPECIAL3. + ext_4 = "7c000000TSAM", -- Note: last arg is msbd = size-1 + ins_4 = "7c000004TSAM", -- Note: last arg is msb = pos+size-1 + wsbh_2 = "7c0000a0DT", + seb_2 = "7c000420DT", + seh_2 = "7c000620DT", + rdhwr_2 = "7c00003bTD", + + -- Opcode COP0. + mfc0_2 = "40000000TD", + mfc0_3 = "40000000TDW", + mtc0_2 = "40800000TD", + mtc0_3 = "40800000TDW", + rdpgpr_2 = "41400000DT", + di_0 = "41606000", + di_1 = "41606000T", + ei_0 = "41606020", + ei_1 = "41606020T", + wrpgpr_2 = "41c00000DT", + tlbr_0 = "42000001", + tlbwi_0 = "42000002", + tlbwr_0 = "42000006", + tlbp_0 = "42000008", + eret_0 = "42000018", + deret_0 = "4200001f", + wait_0 = "42000020", + + -- Opcode COP1. + mfc1_2 = "44000000TG", + cfc1_2 = "44400000TG", + mfhc1_2 = "44600000TG", + mtc1_2 = "44800000TG", + ctc1_2 = "44c00000TG", + mthc1_2 = "44e00000TG", + + bc1f_1 = "45000000B", + bc1f_2 = "45000000CB", + bc1t_1 = "45010000B", + bc1t_2 = "45010000CB", + bc1fl_1 = "45020000B", + bc1fl_2 = "45020000CB", + bc1tl_1 = "45030000B", + bc1tl_2 = "45030000CB", + + ["add.s_3"] = "46000000FGH", + ["sub.s_3"] = "46000001FGH", + ["mul.s_3"] = "46000002FGH", + ["div.s_3"] = "46000003FGH", + ["sqrt.s_2"] = "46000004FG", + ["abs.s_2"] = "46000005FG", + ["mov.s_2"] = "46000006FG", + ["neg.s_2"] = "46000007FG", + ["round.l.s_2"] = "46000008FG", + ["trunc.l.s_2"] = "46000009FG", + ["ceil.l.s_2"] = "4600000aFG", + ["floor.l.s_2"] = "4600000bFG", + ["round.w.s_2"] = "4600000cFG", + ["trunc.w.s_2"] = "4600000dFG", + ["ceil.w.s_2"] = "4600000eFG", + ["floor.w.s_2"] = "4600000fFG", + ["movf.s_2"] = "46000011FG", + ["movf.s_3"] = "46000011FGC", + ["movt.s_2"] = "46010011FG", + ["movt.s_3"] = "46010011FGC", + ["movz.s_3"] = "46000012FGT", + ["movn.s_3"] = "46000013FGT", + ["recip.s_2"] = "46000015FG", + ["rsqrt.s_2"] = "46000016FG", + ["cvt.d.s_2"] = "46000021FG", + ["cvt.w.s_2"] = "46000024FG", + ["cvt.l.s_2"] = "46000025FG", + ["cvt.ps.s_3"] = "46000026FGH", + ["c.f.s_2"] = "46000030GH", + ["c.f.s_3"] = "46000030VGH", + ["c.un.s_2"] = "46000031GH", + ["c.un.s_3"] = "46000031VGH", + ["c.eq.s_2"] = "46000032GH", + ["c.eq.s_3"] = "46000032VGH", + ["c.ueq.s_2"] = "46000033GH", + ["c.ueq.s_3"] = "46000033VGH", + ["c.olt.s_2"] = "46000034GH", + ["c.olt.s_3"] = "46000034VGH", + ["c.ult.s_2"] = "46000035GH", + ["c.ult.s_3"] = "46000035VGH", + ["c.ole.s_2"] = "46000036GH", + ["c.ole.s_3"] = "46000036VGH", + ["c.ule.s_2"] = "46000037GH", + ["c.ule.s_3"] = "46000037VGH", + ["c.sf.s_2"] = "46000038GH", + ["c.sf.s_3"] = "46000038VGH", + ["c.ngle.s_2"] = "46000039GH", + ["c.ngle.s_3"] = "46000039VGH", + ["c.seq.s_2"] = "4600003aGH", + ["c.seq.s_3"] = "4600003aVGH", + ["c.ngl.s_2"] = "4600003bGH", + ["c.ngl.s_3"] = "4600003bVGH", + ["c.lt.s_2"] = "4600003cGH", + ["c.lt.s_3"] = "4600003cVGH", + ["c.nge.s_2"] = "4600003dGH", + ["c.nge.s_3"] = "4600003dVGH", + ["c.le.s_2"] = "4600003eGH", + ["c.le.s_3"] = "4600003eVGH", + ["c.ngt.s_2"] = "4600003fGH", + ["c.ngt.s_3"] = "4600003fVGH", + + ["add.d_3"] = "46200000FGH", + ["sub.d_3"] = "46200001FGH", + ["mul.d_3"] = "46200002FGH", + ["div.d_3"] = "46200003FGH", + ["sqrt.d_2"] = "46200004FG", + ["abs.d_2"] = "46200005FG", + ["mov.d_2"] = "46200006FG", + ["neg.d_2"] = "46200007FG", + ["round.l.d_2"] = "46200008FG", + ["trunc.l.d_2"] = "46200009FG", + ["ceil.l.d_2"] = "4620000aFG", + ["floor.l.d_2"] = "4620000bFG", + ["round.w.d_2"] = "4620000cFG", + ["trunc.w.d_2"] = "4620000dFG", + ["ceil.w.d_2"] = "4620000eFG", + ["floor.w.d_2"] = "4620000fFG", + ["movf.d_2"] = "46200011FG", + ["movf.d_3"] = "46200011FGC", + ["movt.d_2"] = "46210011FG", + ["movt.d_3"] = "46210011FGC", + ["movz.d_3"] = "46200012FGT", + ["movn.d_3"] = "46200013FGT", + ["recip.d_2"] = "46200015FG", + ["rsqrt.d_2"] = "46200016FG", + ["cvt.s.d_2"] = "46200020FG", + ["cvt.w.d_2"] = "46200024FG", + ["cvt.l.d_2"] = "46200025FG", + ["c.f.d_2"] = "46200030GH", + ["c.f.d_3"] = "46200030VGH", + ["c.un.d_2"] = "46200031GH", + ["c.un.d_3"] = "46200031VGH", + ["c.eq.d_2"] = "46200032GH", + ["c.eq.d_3"] = "46200032VGH", + ["c.ueq.d_2"] = "46200033GH", + ["c.ueq.d_3"] = "46200033VGH", + ["c.olt.d_2"] = "46200034GH", + ["c.olt.d_3"] = "46200034VGH", + ["c.ult.d_2"] = "46200035GH", + ["c.ult.d_3"] = "46200035VGH", + ["c.ole.d_2"] = "46200036GH", + ["c.ole.d_3"] = "46200036VGH", + ["c.ule.d_2"] = "46200037GH", + ["c.ule.d_3"] = "46200037VGH", + ["c.sf.d_2"] = "46200038GH", + ["c.sf.d_3"] = "46200038VGH", + ["c.ngle.d_2"] = "46200039GH", + ["c.ngle.d_3"] = "46200039VGH", + ["c.seq.d_2"] = "4620003aGH", + ["c.seq.d_3"] = "4620003aVGH", + ["c.ngl.d_2"] = "4620003bGH", + ["c.ngl.d_3"] = "4620003bVGH", + ["c.lt.d_2"] = "4620003cGH", + ["c.lt.d_3"] = "4620003cVGH", + ["c.nge.d_2"] = "4620003dGH", + ["c.nge.d_3"] = "4620003dVGH", + ["c.le.d_2"] = "4620003eGH", + ["c.le.d_3"] = "4620003eVGH", + ["c.ngt.d_2"] = "4620003fGH", + ["c.ngt.d_3"] = "4620003fVGH", + + ["add.ps_3"] = "46c00000FGH", + ["sub.ps_3"] = "46c00001FGH", + ["mul.ps_3"] = "46c00002FGH", + ["abs.ps_2"] = "46c00005FG", + ["mov.ps_2"] = "46c00006FG", + ["neg.ps_2"] = "46c00007FG", + ["movf.ps_2"] = "46c00011FG", + ["movf.ps_3"] = "46c00011FGC", + ["movt.ps_2"] = "46c10011FG", + ["movt.ps_3"] = "46c10011FGC", + ["movz.ps_3"] = "46c00012FGT", + ["movn.ps_3"] = "46c00013FGT", + ["cvt.s.pu_2"] = "46c00020FG", + ["cvt.s.pl_2"] = "46c00028FG", + ["pll.ps_3"] = "46c0002cFGH", + ["plu.ps_3"] = "46c0002dFGH", + ["pul.ps_3"] = "46c0002eFGH", + ["puu.ps_3"] = "46c0002fFGH", + ["c.f.ps_2"] = "46c00030GH", + ["c.f.ps_3"] = "46c00030VGH", + ["c.un.ps_2"] = "46c00031GH", + ["c.un.ps_3"] = "46c00031VGH", + ["c.eq.ps_2"] = "46c00032GH", + ["c.eq.ps_3"] = "46c00032VGH", + ["c.ueq.ps_2"] = "46c00033GH", + ["c.ueq.ps_3"] = "46c00033VGH", + ["c.olt.ps_2"] = "46c00034GH", + ["c.olt.ps_3"] = "46c00034VGH", + ["c.ult.ps_2"] = "46c00035GH", + ["c.ult.ps_3"] = "46c00035VGH", + ["c.ole.ps_2"] = "46c00036GH", + ["c.ole.ps_3"] = "46c00036VGH", + ["c.ule.ps_2"] = "46c00037GH", + ["c.ule.ps_3"] = "46c00037VGH", + ["c.sf.ps_2"] = "46c00038GH", + ["c.sf.ps_3"] = "46c00038VGH", + ["c.ngle.ps_2"] = "46c00039GH", + ["c.ngle.ps_3"] = "46c00039VGH", + ["c.seq.ps_2"] = "46c0003aGH", + ["c.seq.ps_3"] = "46c0003aVGH", + ["c.ngl.ps_2"] = "46c0003bGH", + ["c.ngl.ps_3"] = "46c0003bVGH", + ["c.lt.ps_2"] = "46c0003cGH", + ["c.lt.ps_3"] = "46c0003cVGH", + ["c.nge.ps_2"] = "46c0003dGH", + ["c.nge.ps_3"] = "46c0003dVGH", + ["c.le.ps_2"] = "46c0003eGH", + ["c.le.ps_3"] = "46c0003eVGH", + ["c.ngt.ps_2"] = "46c0003fGH", + ["c.ngt.ps_3"] = "46c0003fVGH", + + ["cvt.s.w_2"] = "46800020FG", + ["cvt.d.w_2"] = "46800021FG", + + ["cvt.s.l_2"] = "46a00020FG", + ["cvt.d.l_2"] = "46a00021FG", + + -- Opcode COP1X. + lwxc1_2 = "4c000000FX", + ldxc1_2 = "4c000001FX", + luxc1_2 = "4c000005FX", + swxc1_2 = "4c000008FX", + sdxc1_2 = "4c000009FX", + suxc1_2 = "4c00000dFX", + prefx_2 = "4c00000fMX", + ["alnv.ps_4"] = "4c00001eFGHS", + ["madd.s_4"] = "4c000020FRGH", + ["madd.d_4"] = "4c000021FRGH", + ["madd.ps_4"] = "4c000026FRGH", + ["msub.s_4"] = "4c000028FRGH", + ["msub.d_4"] = "4c000029FRGH", + ["msub.ps_4"] = "4c00002eFRGH", + ["nmadd.s_4"] = "4c000030FRGH", + ["nmadd.d_4"] = "4c000031FRGH", + ["nmadd.ps_4"] = "4c000036FRGH", + ["nmsub.s_4"] = "4c000038FRGH", + ["nmsub.d_4"] = "4c000039FRGH", + ["nmsub.ps_4"] = "4c00003eFRGH", +} + +------------------------------------------------------------------------------ + +local function parse_gpr(expr) + local tname, ovreg = match(expr, "^([%w_]+):(r[1-3]?[0-9])$") + local tp = map_type[tname or expr] + if tp then + local reg = ovreg or tp.reg + if not reg then + werror("type `"..(tname or expr).."' needs a register override") + end + expr = reg + end + local r = match(expr, "^r([1-3]?[0-9])$") + if r then + r = tonumber(r) + if r <= 31 then return r, tp end + end + werror("bad register name `"..expr.."'") +end + +local function parse_fpr(expr) + local r = match(expr, "^f([1-3]?[0-9])$") + if r then + r = tonumber(r) + if r <= 31 then return r end + end + werror("bad register name `"..expr.."'") +end + +local function parse_imm(imm, bits, shift, scale, signed) + local n = tonumber(imm) + if n then + local m = sar(n, scale) + if shl(m, scale) == n then + if signed then + local s = sar(m, bits-1) + if s == 0 then return shl(m, shift) + elseif s == -1 then return shl(m + shl(1, bits), shift) end + else + if sar(m, bits) == 0 then return shl(m, shift) end + end + end + werror("out of range immediate `"..imm.."'") + elseif match(imm, "^[rf]([1-3]?[0-9])$") or + match(imm, "^([%w_]+):([rf][1-3]?[0-9])$") then + werror("expected immediate operand, got register") + else + waction("IMM", (signed and 32768 or 0)+scale*1024+bits*32+shift, imm) + return 0 + end +end + +local function parse_disp(disp) + local imm, reg = match(disp, "^(.*)%(([%w_:]+)%)$") + if imm then + local r = shl(parse_gpr(reg), 21) + local extname = match(imm, "^extern%s+(%S+)$") + if extname then + waction("REL_EXT", map_extern[extname], nil, 1) + return r + else + return r + parse_imm(imm, 16, 0, 0, true) + end + end + local reg, tailr = match(disp, "^([%w_:]+)%s*(.*)$") + if reg and tailr ~= "" then + local r, tp = parse_gpr(reg) + if tp then + waction("IMM", 32768+16*32, format(tp.ctypefmt, tailr)) + return shl(r, 21) + end + end + werror("bad displacement `"..disp.."'") +end + +local function parse_index(idx) + local rt, rs = match(idx, "^(.*)%(([%w_:]+)%)$") + if rt then + rt = parse_gpr(rt) + rs = parse_gpr(rs) + return shl(rt, 16) + shl(rs, 21) + end + werror("bad index `"..idx.."'") +end + +local function parse_label(label, def) + local prefix = sub(label, 1, 2) + -- =>label (pc label reference) + if prefix == "=>" then + return "PC", 0, sub(label, 3) + end + -- ->name (global label reference) + if prefix == "->" then + return "LG", map_global[sub(label, 3)] + end + if def then + -- [1-9] (local label definition) + if match(label, "^[1-9]$") then + return "LG", 10+tonumber(label) + end + else + -- [<>][1-9] (local label reference) + local dir, lnum = match(label, "^([<>])([1-9])$") + if dir then -- Fwd: 1-9, Bkwd: 11-19. + return "LG", lnum + (dir == ">" and 0 or 10) + end + -- extern label (extern label reference) + local extname = match(label, "^extern%s+(%S+)$") + if extname then + return "EXT", map_extern[extname] + end + end + werror("bad label `"..label.."'") +end + +------------------------------------------------------------------------------ + +-- Handle opcodes defined with template strings. +map_op[".template__"] = function(params, template, nparams) + if not params then return sub(template, 9) end + local op = tonumber(sub(template, 1, 8), 16) + local n = 1 + + -- Limit number of section buffer positions used by a single dasm_put(). + -- A single opcode needs a maximum of 2 positions (ins/ext). + if secpos+2 > maxsecpos then wflush() end + local pos = wpos() + + -- Process each character. + for p in gmatch(sub(template, 9), ".") do + if p == "D" then + op = op + shl(parse_gpr(params[n]), 11); n = n + 1 + elseif p == "T" then + op = op + shl(parse_gpr(params[n]), 16); n = n + 1 + elseif p == "S" then + op = op + shl(parse_gpr(params[n]), 21); n = n + 1 + elseif p == "F" then + op = op + shl(parse_fpr(params[n]), 6); n = n + 1 + elseif p == "G" then + op = op + shl(parse_fpr(params[n]), 11); n = n + 1 + elseif p == "H" then + op = op + shl(parse_fpr(params[n]), 16); n = n + 1 + elseif p == "R" then + op = op + shl(parse_fpr(params[n]), 21); n = n + 1 + elseif p == "I" then + op = op + parse_imm(params[n], 16, 0, 0, true); n = n + 1 + elseif p == "U" then + op = op + parse_imm(params[n], 16, 0, 0, false); n = n + 1 + elseif p == "O" then + op = op + parse_disp(params[n]); n = n + 1 + elseif p == "X" then + op = op + parse_index(params[n]); n = n + 1 + elseif p == "B" or p == "J" then + local mode, n, s = parse_label(params[n], false) + if p == "B" then n = n + 2048 end + waction("REL_"..mode, n, s, 1) + n = n + 1 + elseif p == "A" then + op = op + parse_imm(params[n], 5, 6, 0, false); n = n + 1 + elseif p == "M" then + op = op + parse_imm(params[n], 5, 11, 0, false); n = n + 1 + elseif p == "N" then + op = op + parse_imm(params[n], 5, 16, 0, false); n = n + 1 + elseif p == "C" then + op = op + parse_imm(params[n], 3, 18, 0, false); n = n + 1 + elseif p == "V" then + op = op + parse_imm(params[n], 3, 8, 0, false); n = n + 1 + elseif p == "W" then + op = op + parse_imm(params[n], 3, 0, 0, false); n = n + 1 + elseif p == "Y" then + op = op + parse_imm(params[n], 20, 6, 0, false); n = n + 1 + elseif p == "Z" then + op = op + parse_imm(params[n], 10, 6, 0, false); n = n + 1 + elseif p == "=" then + op = op + shl(band(op, 0xf800), 5) -- Copy D to T for clz, clo. + else + assert(false) + end + end + wputpos(pos, op) +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcode to mark the position where the action list is to be emitted. +map_op[".actionlist_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeactions(out, name) end) +end + +-- Pseudo-opcode to mark the position where the global enum is to be emitted. +map_op[".globals_1"] = function(params) + if not params then return "prefix" end + local prefix = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeglobals(out, prefix) end) +end + +-- Pseudo-opcode to mark the position where the global names are to be emitted. +map_op[".globalnames_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeglobalnames(out, name) end) +end + +-- Pseudo-opcode to mark the position where the extern names are to be emitted. +map_op[".externnames_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeexternnames(out, name) end) +end + +------------------------------------------------------------------------------ + +-- Label pseudo-opcode (converted from trailing colon form). +map_op[".label_1"] = function(params) + if not params then return "[1-9] | ->global | =>pcexpr" end + if secpos+1 > maxsecpos then wflush() end + local mode, n, s = parse_label(params[1], true) + if mode == "EXT" then werror("bad label definition") end + waction("LABEL_"..mode, n, s, 1) +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcodes for data storage. +map_op[".long_*"] = function(params) + if not params then return "imm..." end + for _,p in ipairs(params) do + local n = tonumber(p) + if not n then werror("bad immediate `"..p.."'") end + if n < 0 then n = n + 2^32 end + wputw(n) + if secpos+2 > maxsecpos then wflush() end + end +end + +-- Alignment pseudo-opcode. +map_op[".align_1"] = function(params) + if not params then return "numpow2" end + if secpos+1 > maxsecpos then wflush() end + local align = tonumber(params[1]) + if align then + local x = align + -- Must be a power of 2 in the range (2 ... 256). + for i=1,8 do + x = x / 2 + if x == 1 then + waction("ALIGN", align-1, nil, 1) -- Action byte is 2**n-1. + return + end + end + end + werror("bad alignment") +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcode for (primitive) type definitions (map to C types). +map_op[".type_3"] = function(params, nparams) + if not params then + return nparams == 2 and "name, ctype" or "name, ctype, reg" + end + local name, ctype, reg = params[1], params[2], params[3] + if not match(name, "^[%a_][%w_]*$") then + werror("bad type name `"..name.."'") + end + local tp = map_type[name] + if tp then + werror("duplicate type `"..name.."'") + end + -- Add #type to defines. A bit unclean to put it in map_archdef. + map_archdef["#"..name] = "sizeof("..ctype..")" + -- Add new type and emit shortcut define. + local num = ctypenum + 1 + map_type[name] = { + ctype = ctype, + ctypefmt = format("Dt%X(%%s)", num), + reg = reg, + } + wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype)) + ctypenum = num +end +map_op[".type_2"] = map_op[".type_3"] + +-- Dump type definitions. +local function dumptypes(out, lvl) + local t = {} + for name in pairs(map_type) do t[#t+1] = name end + sort(t) + out:write("Type definitions:\n") + for _,name in ipairs(t) do + local tp = map_type[name] + local reg = tp.reg or "" + out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg)) + end + out:write("\n") +end + +------------------------------------------------------------------------------ + +-- Set the current section. +function _M.section(num) + waction("SECTION", num) + wflush(true) -- SECTION is a terminal action. +end + +------------------------------------------------------------------------------ + +-- Dump architecture description. +function _M.dumparch(out) + out:write(format("DynASM %s version %s, released %s\n\n", + _info.arch, _info.version, _info.release)) + dumpactions(out) +end + +-- Dump all user defined elements. +function _M.dumpdef(out, lvl) + dumptypes(out, lvl) + dumpglobals(out, lvl) + dumpexterns(out, lvl) +end + +------------------------------------------------------------------------------ + +-- Pass callbacks from/to the DynASM core. +function _M.passcb(wl, we, wf, ww) + wline, werror, wfatal, wwarn = wl, we, wf, ww + return wflush +end + +-- Setup the arch-specific module. +function _M.setup(arch, opt) + g_arch, g_opt = arch, opt +end + +-- Merge the core maps and the arch-specific maps. +function _M.mergemaps(map_coreop, map_def) + setmetatable(map_op, { __index = map_coreop }) + setmetatable(map_def, { __index = map_archdef }) + return map_op, map_def +end + +return _M + +------------------------------------------------------------------------------ + diff --git a/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_ppc.h b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_ppc.h new file mode 100644 index 000000000..7df493654 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_ppc.h @@ -0,0 +1,412 @@ +/* +** DynASM PPC encoding engine. +** Copyright (C) 2005-2015 Mike Pall. All rights reserved. +** Released under the MIT license. See dynasm.lua for full copyright notice. +*/ + +#include +#include +#include +#include + +#define DASM_ARCH "ppc" + +#ifndef DASM_EXTERN +#define DASM_EXTERN(a,b,c,d) 0 +#endif + +/* Action definitions. */ +enum { + DASM_STOP, DASM_SECTION, DASM_ESC, DASM_REL_EXT, + /* The following actions need a buffer position. */ + DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG, + /* The following actions also have an argument. */ + DASM_REL_PC, DASM_LABEL_PC, DASM_IMM, + DASM__MAX +}; + +/* Maximum number of section buffer positions for a single dasm_put() call. */ +#define DASM_MAXSECPOS 25 + +/* DynASM encoder status codes. Action list offset or number are or'ed in. */ +#define DASM_S_OK 0x00000000 +#define DASM_S_NOMEM 0x01000000 +#define DASM_S_PHASE 0x02000000 +#define DASM_S_MATCH_SEC 0x03000000 +#define DASM_S_RANGE_I 0x11000000 +#define DASM_S_RANGE_SEC 0x12000000 +#define DASM_S_RANGE_LG 0x13000000 +#define DASM_S_RANGE_PC 0x14000000 +#define DASM_S_RANGE_REL 0x15000000 +#define DASM_S_UNDEF_LG 0x21000000 +#define DASM_S_UNDEF_PC 0x22000000 + +/* Macros to convert positions (8 bit section + 24 bit index). */ +#define DASM_POS2IDX(pos) ((pos)&0x00ffffff) +#define DASM_POS2BIAS(pos) ((pos)&0xff000000) +#define DASM_SEC2POS(sec) ((sec)<<24) +#define DASM_POS2SEC(pos) ((pos)>>24) +#define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) + +/* Action list type. */ +typedef const unsigned int *dasm_ActList; + +/* Per-section structure. */ +typedef struct dasm_Section { + int *rbuf; /* Biased buffer pointer (negative section bias). */ + int *buf; /* True buffer pointer. */ + size_t bsize; /* Buffer size in bytes. */ + int pos; /* Biased buffer position. */ + int epos; /* End of biased buffer position - max single put. */ + int ofs; /* Byte offset into section. */ +} dasm_Section; + +/* Core structure holding the DynASM encoding state. */ +struct dasm_State { + size_t psize; /* Allocated size of this structure. */ + dasm_ActList actionlist; /* Current actionlist pointer. */ + int *lglabels; /* Local/global chain/pos ptrs. */ + size_t lgsize; + int *pclabels; /* PC label chains/pos ptrs. */ + size_t pcsize; + void **globals; /* Array of globals (bias -10). */ + dasm_Section *section; /* Pointer to active section. */ + size_t codesize; /* Total size of all code sections. */ + int maxsection; /* 0 <= sectionidx < maxsection. */ + int status; /* Status code. */ + dasm_Section sections[1]; /* All sections. Alloc-extended. */ +}; + +/* The size of the core structure depends on the max. number of sections. */ +#define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section)) + + +/* Initialize DynASM state. */ +void dasm_init(Dst_DECL, int maxsection) +{ + dasm_State *D; + size_t psz = 0; + int i; + Dst_REF = NULL; + DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); + D = Dst_REF; + D->psize = psz; + D->lglabels = NULL; + D->lgsize = 0; + D->pclabels = NULL; + D->pcsize = 0; + D->globals = NULL; + D->maxsection = maxsection; + for (i = 0; i < maxsection; i++) { + D->sections[i].buf = NULL; /* Need this for pass3. */ + D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i); + D->sections[i].bsize = 0; + D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ + } +} + +/* Free DynASM state. */ +void dasm_free(Dst_DECL) +{ + dasm_State *D = Dst_REF; + int i; + for (i = 0; i < D->maxsection; i++) + if (D->sections[i].buf) + DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize); + if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize); + if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize); + DASM_M_FREE(Dst, D, D->psize); +} + +/* Setup global label array. Must be called before dasm_setup(). */ +void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) +{ + dasm_State *D = Dst_REF; + D->globals = gl - 10; /* Negative bias to compensate for locals. */ + DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); +} + +/* Grow PC label array. Can be called after dasm_setup(), too. */ +void dasm_growpc(Dst_DECL, unsigned int maxpc) +{ + dasm_State *D = Dst_REF; + size_t osz = D->pcsize; + DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int)); + memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz); +} + +/* Setup encoder. */ +void dasm_setup(Dst_DECL, const void *actionlist) +{ + dasm_State *D = Dst_REF; + int i; + D->actionlist = (dasm_ActList)actionlist; + D->status = DASM_S_OK; + D->section = &D->sections[0]; + memset((void *)D->lglabels, 0, D->lgsize); + if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); + for (i = 0; i < D->maxsection; i++) { + D->sections[i].pos = DASM_SEC2POS(i); + D->sections[i].ofs = 0; + } +} + + +#ifdef DASM_CHECKS +#define CK(x, st) \ + do { if (!(x)) { \ + D->status = DASM_S_##st|(p-D->actionlist-1); return; } } while (0) +#define CKPL(kind, st) \ + do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \ + D->status = DASM_S_RANGE_##st|(p-D->actionlist-1); return; } } while (0) +#else +#define CK(x, st) ((void)0) +#define CKPL(kind, st) ((void)0) +#endif + +/* Pass 1: Store actions and args, link branches/labels, estimate offsets. */ +void dasm_put(Dst_DECL, int start, ...) +{ + va_list ap; + dasm_State *D = Dst_REF; + dasm_ActList p = D->actionlist + start; + dasm_Section *sec = D->section; + int pos = sec->pos, ofs = sec->ofs; + int *b; + + if (pos >= sec->epos) { + DASM_M_GROW(Dst, int, sec->buf, sec->bsize, + sec->bsize + 2*DASM_MAXSECPOS*sizeof(int)); + sec->rbuf = sec->buf - DASM_POS2BIAS(pos); + sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos); + } + + b = sec->rbuf; + b[pos++] = start; + + va_start(ap, start); + while (1) { + unsigned int ins = *p++; + unsigned int action = (ins >> 16); + if (action >= DASM__MAX) { + ofs += 4; + } else { + int *pl, n = action >= DASM_REL_PC ? va_arg(ap, int) : 0; + switch (action) { + case DASM_STOP: goto stop; + case DASM_SECTION: + n = (ins & 255); CK(n < D->maxsection, RANGE_SEC); + D->section = &D->sections[n]; goto stop; + case DASM_ESC: p++; ofs += 4; break; + case DASM_REL_EXT: break; + case DASM_ALIGN: ofs += (ins & 255); b[pos++] = ofs; break; + case DASM_REL_LG: + n = (ins & 2047) - 10; pl = D->lglabels + n; + /* Bkwd rel or global. */ + if (n >= 0) { CK(n>=10||*pl<0, RANGE_LG); CKPL(lg, LG); goto putrel; } + pl += 10; n = *pl; + if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */ + goto linkrel; + case DASM_REL_PC: + pl = D->pclabels + n; CKPL(pc, PC); + putrel: + n = *pl; + if (n < 0) { /* Label exists. Get label pos and store it. */ + b[pos] = -n; + } else { + linkrel: + b[pos] = n; /* Else link to rel chain, anchored at label. */ + *pl = pos; + } + pos++; + break; + case DASM_LABEL_LG: + pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel; + case DASM_LABEL_PC: + pl = D->pclabels + n; CKPL(pc, PC); + putlabel: + n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */ + while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; + } + *pl = -pos; /* Label exists now. */ + b[pos++] = ofs; /* Store pass1 offset estimate. */ + break; + case DASM_IMM: +#ifdef DASM_CHECKS + CK((n & ((1<<((ins>>10)&31))-1)) == 0, RANGE_I); +#endif + n >>= ((ins>>10)&31); +#ifdef DASM_CHECKS + if (ins & 0x8000) + CK(((n + (1<<(((ins>>5)&31)-1)))>>((ins>>5)&31)) == 0, RANGE_I); + else + CK((n>>((ins>>5)&31)) == 0, RANGE_I); +#endif + b[pos++] = n; + break; + } + } + } +stop: + va_end(ap); + sec->pos = pos; + sec->ofs = ofs; +} +#undef CK + +/* Pass 2: Link sections, shrink aligns, fix label offsets. */ +int dasm_link(Dst_DECL, size_t *szp) +{ + dasm_State *D = Dst_REF; + int secnum; + int ofs = 0; + +#ifdef DASM_CHECKS + *szp = 0; + if (D->status != DASM_S_OK) return D->status; + { + int pc; + for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) + if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; + } +#endif + + { /* Handle globals not defined in this translation unit. */ + int idx; + for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) { + int n = D->lglabels[idx]; + /* Undefined label: Collapse rel chain and replace with marker (< 0). */ + while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } + } + } + + /* Combine all code sections. No support for data sections (yet). */ + for (secnum = 0; secnum < D->maxsection; secnum++) { + dasm_Section *sec = D->sections + secnum; + int *b = sec->rbuf; + int pos = DASM_SEC2POS(secnum); + int lastpos = sec->pos; + + while (pos != lastpos) { + dasm_ActList p = D->actionlist + b[pos++]; + while (1) { + unsigned int ins = *p++; + unsigned int action = (ins >> 16); + switch (action) { + case DASM_STOP: case DASM_SECTION: goto stop; + case DASM_ESC: p++; break; + case DASM_REL_EXT: break; + case DASM_ALIGN: ofs -= (b[pos++] + ofs) & (ins & 255); break; + case DASM_REL_LG: case DASM_REL_PC: pos++; break; + case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break; + case DASM_IMM: pos++; break; + } + } + stop: (void)0; + } + ofs += sec->ofs; /* Next section starts right after current section. */ + } + + D->codesize = ofs; /* Total size of all code sections */ + *szp = ofs; + return DASM_S_OK; +} + +#ifdef DASM_CHECKS +#define CK(x, st) \ + do { if (!(x)) return DASM_S_##st|(p-D->actionlist-1); } while (0) +#else +#define CK(x, st) ((void)0) +#endif + +/* Pass 3: Encode sections. */ +int dasm_encode(Dst_DECL, void *buffer) +{ + dasm_State *D = Dst_REF; + char *base = (char *)buffer; + unsigned int *cp = (unsigned int *)buffer; + int secnum; + + /* Encode all code sections. No support for data sections (yet). */ + for (secnum = 0; secnum < D->maxsection; secnum++) { + dasm_Section *sec = D->sections + secnum; + int *b = sec->buf; + int *endb = sec->rbuf + sec->pos; + + while (b != endb) { + dasm_ActList p = D->actionlist + *b++; + while (1) { + unsigned int ins = *p++; + unsigned int action = (ins >> 16); + int n = (action >= DASM_ALIGN && action < DASM__MAX) ? *b++ : 0; + switch (action) { + case DASM_STOP: case DASM_SECTION: goto stop; + case DASM_ESC: *cp++ = *p++; break; + case DASM_REL_EXT: + n = DASM_EXTERN(Dst, (unsigned char *)cp, (ins & 2047), 1) - 4; + goto patchrel; + case DASM_ALIGN: + ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0x60000000; + break; + case DASM_REL_LG: + CK(n >= 0, UNDEF_LG); + case DASM_REL_PC: + CK(n >= 0, UNDEF_PC); + n = *DASM_POS2PTR(D, n) - (int)((char *)cp - base); + patchrel: + CK((n & 3) == 0 && + (((n+4) + ((ins & 2048) ? 0x00008000 : 0x02000000)) >> + ((ins & 2048) ? 16 : 26)) == 0, RANGE_REL); + cp[-1] |= ((n+4) & ((ins & 2048) ? 0x0000fffc: 0x03fffffc)); + break; + case DASM_LABEL_LG: + ins &= 2047; if (ins >= 20) D->globals[ins-10] = (void *)(base + n); + break; + case DASM_LABEL_PC: break; + case DASM_IMM: + cp[-1] |= (n & ((1<<((ins>>5)&31))-1)) << (ins&31); + break; + default: *cp++ = ins; break; + } + } + stop: (void)0; + } + } + + if (base + D->codesize != (char *)cp) /* Check for phase errors. */ + return DASM_S_PHASE; + return DASM_S_OK; +} +#undef CK + +/* Get PC label offset. */ +int dasm_getpclabel(Dst_DECL, unsigned int pc) +{ + dasm_State *D = Dst_REF; + if (pc*sizeof(int) < D->pcsize) { + int pos = D->pclabels[pc]; + if (pos < 0) return *DASM_POS2PTR(D, -pos); + if (pos > 0) return -1; /* Undefined. */ + } + return -2; /* Unused or out of range. */ +} + +#ifdef DASM_CHECKS +/* Optional sanity checker to call between isolated encoding steps. */ +int dasm_checkstep(Dst_DECL, int secmatch) +{ + dasm_State *D = Dst_REF; + if (D->status == DASM_S_OK) { + int i; + for (i = 1; i <= 9; i++) { + if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_LG|i; break; } + D->lglabels[i] = 0; + } + } + if (D->status == DASM_S_OK && secmatch >= 0 && + D->section != &D->sections[secmatch]) + D->status = DASM_S_MATCH_SEC|(D->section-D->sections); + return D->status; +} +#endif + diff --git a/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_ppc.lua b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_ppc.lua new file mode 100644 index 000000000..91f4ff9a4 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_ppc.lua @@ -0,0 +1,1249 @@ +------------------------------------------------------------------------------ +-- DynASM PPC module. +-- +-- Copyright (C) 2005-2015 Mike Pall. All rights reserved. +-- See dynasm.lua for full copyright notice. +------------------------------------------------------------------------------ + +-- Module information: +local _info = { + arch = "ppc", + description = "DynASM PPC module", + version = "1.3.0", + vernum = 10300, + release = "2011-05-05", + author = "Mike Pall", + license = "MIT", +} + +-- Exported glue functions for the arch-specific module. +local _M = { _info = _info } + +-- Cache library functions. +local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs +local assert, setmetatable = assert, setmetatable +local _s = string +local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char +local match, gmatch = _s.match, _s.gmatch +local concat, sort = table.concat, table.sort +local bit = bit or require("bit") +local band, shl, shr, sar = bit.band, bit.lshift, bit.rshift, bit.arshift +local tohex = bit.tohex + +-- Inherited tables and callbacks. +local g_opt, g_arch +local wline, werror, wfatal, wwarn + +-- Action name list. +-- CHECK: Keep this in sync with the C code! +local action_names = { + "STOP", "SECTION", "ESC", "REL_EXT", + "ALIGN", "REL_LG", "LABEL_LG", + "REL_PC", "LABEL_PC", "IMM", +} + +-- Maximum number of section buffer positions for dasm_put(). +-- CHECK: Keep this in sync with the C code! +local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines. + +-- Action name -> action number. +local map_action = {} +for n,name in ipairs(action_names) do + map_action[name] = n-1 +end + +-- Action list buffer. +local actlist = {} + +-- Argument list for next dasm_put(). Start with offset 0 into action list. +local actargs = { 0 } + +-- Current number of section buffer positions for dasm_put(). +local secpos = 1 + +------------------------------------------------------------------------------ + +-- Dump action names and numbers. +local function dumpactions(out) + out:write("DynASM encoding engine action codes:\n") + for n,name in ipairs(action_names) do + local num = map_action[name] + out:write(format(" %-10s %02X %d\n", name, num, num)) + end + out:write("\n") +end + +-- Write action list buffer as a huge static C array. +local function writeactions(out, name) + local nn = #actlist + if nn == 0 then nn = 1; actlist[0] = map_action.STOP end + out:write("static const unsigned int ", name, "[", nn, "] = {\n") + for i = 1,nn-1 do + assert(out:write("0x", tohex(actlist[i]), ",\n")) + end + assert(out:write("0x", tohex(actlist[nn]), "\n};\n\n")) +end + +------------------------------------------------------------------------------ + +-- Add word to action list. +local function wputxw(n) + assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") + actlist[#actlist+1] = n +end + +-- Add action to list with optional arg. Advance buffer pos, too. +local function waction(action, val, a, num) + local w = assert(map_action[action], "bad action name `"..action.."'") + wputxw(w * 0x10000 + (val or 0)) + if a then actargs[#actargs+1] = a end + if a or num then secpos = secpos + (num or 1) end +end + +-- Flush action list (intervening C code or buffer pos overflow). +local function wflush(term) + if #actlist == actargs[1] then return end -- Nothing to flush. + if not term then waction("STOP") end -- Terminate action list. + wline(format("dasm_put(Dst, %s);", concat(actargs, ", ")), true) + actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put(). + secpos = 1 -- The actionlist offset occupies a buffer position, too. +end + +-- Put escaped word. +local function wputw(n) + if n <= 0xffffff then waction("ESC") end + wputxw(n) +end + +-- Reserve position for word. +local function wpos() + local pos = #actlist+1 + actlist[pos] = "" + return pos +end + +-- Store word to reserved position. +local function wputpos(pos, n) + assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") + actlist[pos] = n +end + +------------------------------------------------------------------------------ + +-- Global label name -> global label number. With auto assignment on 1st use. +local next_global = 20 +local map_global = setmetatable({}, { __index = function(t, name) + if not match(name, "^[%a_][%w_]*$") then werror("bad global label") end + local n = next_global + if n > 2047 then werror("too many global labels") end + next_global = n + 1 + t[name] = n + return n +end}) + +-- Dump global labels. +local function dumpglobals(out, lvl) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("Global labels:\n") + for i=20,next_global-1 do + out:write(format(" %s\n", t[i])) + end + out:write("\n") +end + +-- Write global label enum. +local function writeglobals(out, prefix) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("enum {\n") + for i=20,next_global-1 do + out:write(" ", prefix, t[i], ",\n") + end + out:write(" ", prefix, "_MAX\n};\n") +end + +-- Write global label names. +local function writeglobalnames(out, name) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("static const char *const ", name, "[] = {\n") + for i=20,next_global-1 do + out:write(" \"", t[i], "\",\n") + end + out:write(" (const char *)0\n};\n") +end + +------------------------------------------------------------------------------ + +-- Extern label name -> extern label number. With auto assignment on 1st use. +local next_extern = 0 +local map_extern_ = {} +local map_extern = setmetatable({}, { __index = function(t, name) + -- No restrictions on the name for now. + local n = next_extern + if n > 2047 then werror("too many extern labels") end + next_extern = n + 1 + t[name] = n + map_extern_[n] = name + return n +end}) + +-- Dump extern labels. +local function dumpexterns(out, lvl) + out:write("Extern labels:\n") + for i=0,next_extern-1 do + out:write(format(" %s\n", map_extern_[i])) + end + out:write("\n") +end + +-- Write extern label names. +local function writeexternnames(out, name) + out:write("static const char *const ", name, "[] = {\n") + for i=0,next_extern-1 do + out:write(" \"", map_extern_[i], "\",\n") + end + out:write(" (const char *)0\n};\n") +end + +------------------------------------------------------------------------------ + +-- Arch-specific maps. +local map_archdef = { sp = "r1" } -- Ext. register name -> int. name. + +local map_type = {} -- Type name -> { ctype, reg } +local ctypenum = 0 -- Type number (for Dt... macros). + +-- Reverse defines for registers. +function _M.revdef(s) + if s == "r1" then return "sp" end + return s +end + +local map_cond = { + lt = 0, gt = 1, eq = 2, so = 3, + ge = 4, le = 5, ne = 6, ns = 7, +} + +------------------------------------------------------------------------------ + +-- Template strings for PPC instructions. +local map_op = { + tdi_3 = "08000000ARI", + twi_3 = "0c000000ARI", + mulli_3 = "1c000000RRI", + subfic_3 = "20000000RRI", + cmplwi_3 = "28000000XRU", + cmplwi_2 = "28000000-RU", + cmpldi_3 = "28200000XRU", + cmpldi_2 = "28200000-RU", + cmpwi_3 = "2c000000XRI", + cmpwi_2 = "2c000000-RI", + cmpdi_3 = "2c200000XRI", + cmpdi_2 = "2c200000-RI", + addic_3 = "30000000RRI", + ["addic._3"] = "34000000RRI", + addi_3 = "38000000RR0I", + li_2 = "38000000RI", + la_2 = "38000000RD", + addis_3 = "3c000000RR0I", + lis_2 = "3c000000RI", + lus_2 = "3c000000RU", + bc_3 = "40000000AAK", + bcl_3 = "40000001AAK", + bdnz_1 = "42000000K", + bdz_1 = "42400000K", + sc_0 = "44000000", + b_1 = "48000000J", + bl_1 = "48000001J", + rlwimi_5 = "50000000RR~AAA.", + rlwinm_5 = "54000000RR~AAA.", + rlwnm_5 = "5c000000RR~RAA.", + ori_3 = "60000000RR~U", + nop_0 = "60000000", + oris_3 = "64000000RR~U", + xori_3 = "68000000RR~U", + xoris_3 = "6c000000RR~U", + ["andi._3"] = "70000000RR~U", + ["andis._3"] = "74000000RR~U", + lwz_2 = "80000000RD", + lwzu_2 = "84000000RD", + lbz_2 = "88000000RD", + lbzu_2 = "8c000000RD", + stw_2 = "90000000RD", + stwu_2 = "94000000RD", + stb_2 = "98000000RD", + stbu_2 = "9c000000RD", + lhz_2 = "a0000000RD", + lhzu_2 = "a4000000RD", + lha_2 = "a8000000RD", + lhau_2 = "ac000000RD", + sth_2 = "b0000000RD", + sthu_2 = "b4000000RD", + lmw_2 = "b8000000RD", + stmw_2 = "bc000000RD", + lfs_2 = "c0000000FD", + lfsu_2 = "c4000000FD", + lfd_2 = "c8000000FD", + lfdu_2 = "cc000000FD", + stfs_2 = "d0000000FD", + stfsu_2 = "d4000000FD", + stfd_2 = "d8000000FD", + stfdu_2 = "dc000000FD", + ld_2 = "e8000000RD", -- NYI: displacement must be divisible by 4. + ldu_2 = "e8000001RD", + lwa_2 = "e8000002RD", + std_2 = "f8000000RD", + stdu_2 = "f8000001RD", + + -- Primary opcode 19: + mcrf_2 = "4c000000XX", + isync_0 = "4c00012c", + crnor_3 = "4c000042CCC", + crnot_2 = "4c000042CC=", + crandc_3 = "4c000102CCC", + crxor_3 = "4c000182CCC", + crclr_1 = "4c000182C==", + crnand_3 = "4c0001c2CCC", + crand_3 = "4c000202CCC", + creqv_3 = "4c000242CCC", + crset_1 = "4c000242C==", + crorc_3 = "4c000342CCC", + cror_3 = "4c000382CCC", + crmove_2 = "4c000382CC=", + bclr_2 = "4c000020AA", + bclrl_2 = "4c000021AA", + bcctr_2 = "4c000420AA", + bcctrl_2 = "4c000421AA", + blr_0 = "4e800020", + blrl_0 = "4e800021", + bctr_0 = "4e800420", + bctrl_0 = "4e800421", + + -- Primary opcode 31: + cmpw_3 = "7c000000XRR", + cmpw_2 = "7c000000-RR", + cmpd_3 = "7c200000XRR", + cmpd_2 = "7c200000-RR", + tw_3 = "7c000008ARR", + subfc_3 = "7c000010RRR.", + subc_3 = "7c000010RRR~.", + mulhdu_3 = "7c000012RRR.", + addc_3 = "7c000014RRR.", + mulhwu_3 = "7c000016RRR.", + isel_4 = "7c00001eRRRC", + isellt_3 = "7c00001eRRR", + iselgt_3 = "7c00005eRRR", + iseleq_3 = "7c00009eRRR", + mfcr_1 = "7c000026R", + mfocrf_2 = "7c100026RG", + mtcrf_2 = "7c000120GR", + mtocrf_2 = "7c100120GR", + lwarx_3 = "7c000028RR0R", + ldx_3 = "7c00002aRR0R", + lwzx_3 = "7c00002eRR0R", + slw_3 = "7c000030RR~R.", + cntlzw_2 = "7c000034RR~", + sld_3 = "7c000036RR~R.", + and_3 = "7c000038RR~R.", + cmplw_3 = "7c000040XRR", + cmplw_2 = "7c000040-RR", + cmpld_3 = "7c200040XRR", + cmpld_2 = "7c200040-RR", + subf_3 = "7c000050RRR.", + sub_3 = "7c000050RRR~.", + ldux_3 = "7c00006aRR0R", + dcbst_2 = "7c00006c-RR", + lwzux_3 = "7c00006eRR0R", + cntlzd_2 = "7c000074RR~", + andc_3 = "7c000078RR~R.", + td_3 = "7c000088ARR", + mulhd_3 = "7c000092RRR.", + mulhw_3 = "7c000096RRR.", + ldarx_3 = "7c0000a8RR0R", + dcbf_2 = "7c0000ac-RR", + lbzx_3 = "7c0000aeRR0R", + neg_2 = "7c0000d0RR.", + lbzux_3 = "7c0000eeRR0R", + popcntb_2 = "7c0000f4RR~", + not_2 = "7c0000f8RR~%.", + nor_3 = "7c0000f8RR~R.", + subfe_3 = "7c000110RRR.", + sube_3 = "7c000110RRR~.", + adde_3 = "7c000114RRR.", + stdx_3 = "7c00012aRR0R", + stwcx_3 = "7c00012cRR0R.", + stwx_3 = "7c00012eRR0R", + prtyw_2 = "7c000134RR~", + stdux_3 = "7c00016aRR0R", + stwux_3 = "7c00016eRR0R", + prtyd_2 = "7c000174RR~", + subfze_2 = "7c000190RR.", + addze_2 = "7c000194RR.", + stdcx_3 = "7c0001acRR0R.", + stbx_3 = "7c0001aeRR0R", + subfme_2 = "7c0001d0RR.", + mulld_3 = "7c0001d2RRR.", + addme_2 = "7c0001d4RR.", + mullw_3 = "7c0001d6RRR.", + dcbtst_2 = "7c0001ec-RR", + stbux_3 = "7c0001eeRR0R", + add_3 = "7c000214RRR.", + dcbt_2 = "7c00022c-RR", + lhzx_3 = "7c00022eRR0R", + eqv_3 = "7c000238RR~R.", + eciwx_3 = "7c00026cRR0R", + lhzux_3 = "7c00026eRR0R", + xor_3 = "7c000278RR~R.", + mfspefscr_1 = "7c0082a6R", + mfxer_1 = "7c0102a6R", + mflr_1 = "7c0802a6R", + mfctr_1 = "7c0902a6R", + lwax_3 = "7c0002aaRR0R", + lhax_3 = "7c0002aeRR0R", + mftb_1 = "7c0c42e6R", + mftbu_1 = "7c0d42e6R", + lwaux_3 = "7c0002eaRR0R", + lhaux_3 = "7c0002eeRR0R", + sthx_3 = "7c00032eRR0R", + orc_3 = "7c000338RR~R.", + ecowx_3 = "7c00036cRR0R", + sthux_3 = "7c00036eRR0R", + or_3 = "7c000378RR~R.", + mr_2 = "7c000378RR~%.", + divdu_3 = "7c000392RRR.", + divwu_3 = "7c000396RRR.", + mtspefscr_1 = "7c0083a6R", + mtxer_1 = "7c0103a6R", + mtlr_1 = "7c0803a6R", + mtctr_1 = "7c0903a6R", + dcbi_2 = "7c0003ac-RR", + nand_3 = "7c0003b8RR~R.", + divd_3 = "7c0003d2RRR.", + divw_3 = "7c0003d6RRR.", + cmpb_3 = "7c0003f8RR~R.", + mcrxr_1 = "7c000400X", + subfco_3 = "7c000410RRR.", + subco_3 = "7c000410RRR~.", + addco_3 = "7c000414RRR.", + ldbrx_3 = "7c000428RR0R", + lswx_3 = "7c00042aRR0R", + lwbrx_3 = "7c00042cRR0R", + lfsx_3 = "7c00042eFR0R", + srw_3 = "7c000430RR~R.", + srd_3 = "7c000436RR~R.", + subfo_3 = "7c000450RRR.", + subo_3 = "7c000450RRR~.", + lfsux_3 = "7c00046eFR0R", + lswi_3 = "7c0004aaRR0A", + sync_0 = "7c0004ac", + lwsync_0 = "7c2004ac", + ptesync_0 = "7c4004ac", + lfdx_3 = "7c0004aeFR0R", + nego_2 = "7c0004d0RR.", + lfdux_3 = "7c0004eeFR0R", + subfeo_3 = "7c000510RRR.", + subeo_3 = "7c000510RRR~.", + addeo_3 = "7c000514RRR.", + stdbrx_3 = "7c000528RR0R", + stswx_3 = "7c00052aRR0R", + stwbrx_3 = "7c00052cRR0R", + stfsx_3 = "7c00052eFR0R", + stfsux_3 = "7c00056eFR0R", + subfzeo_2 = "7c000590RR.", + addzeo_2 = "7c000594RR.", + stswi_3 = "7c0005aaRR0A", + stfdx_3 = "7c0005aeFR0R", + subfmeo_2 = "7c0005d0RR.", + mulldo_3 = "7c0005d2RRR.", + addmeo_2 = "7c0005d4RR.", + mullwo_3 = "7c0005d6RRR.", + dcba_2 = "7c0005ec-RR", + stfdux_3 = "7c0005eeFR0R", + addo_3 = "7c000614RRR.", + lhbrx_3 = "7c00062cRR0R", + sraw_3 = "7c000630RR~R.", + srad_3 = "7c000634RR~R.", + srawi_3 = "7c000670RR~A.", + sradi_3 = "7c000674RR~H.", + eieio_0 = "7c0006ac", + lfiwax_3 = "7c0006aeFR0R", + sthbrx_3 = "7c00072cRR0R", + extsh_2 = "7c000734RR~.", + extsb_2 = "7c000774RR~.", + divduo_3 = "7c000792RRR.", + divwou_3 = "7c000796RRR.", + icbi_2 = "7c0007ac-RR", + stfiwx_3 = "7c0007aeFR0R", + extsw_2 = "7c0007b4RR~.", + divdo_3 = "7c0007d2RRR.", + divwo_3 = "7c0007d6RRR.", + dcbz_2 = "7c0007ec-RR", + + -- Primary opcode 30: + rldicl_4 = "78000000RR~HM.", + rldicr_4 = "78000004RR~HM.", + rldic_4 = "78000008RR~HM.", + rldimi_4 = "7800000cRR~HM.", + rldcl_4 = "78000010RR~RM.", + rldcr_4 = "78000012RR~RM.", + + -- Primary opcode 59: + fdivs_3 = "ec000024FFF.", + fsubs_3 = "ec000028FFF.", + fadds_3 = "ec00002aFFF.", + fsqrts_2 = "ec00002cF-F.", + fres_2 = "ec000030F-F.", + fmuls_3 = "ec000032FF-F.", + frsqrtes_2 = "ec000034F-F.", + fmsubs_4 = "ec000038FFFF~.", + fmadds_4 = "ec00003aFFFF~.", + fnmsubs_4 = "ec00003cFFFF~.", + fnmadds_4 = "ec00003eFFFF~.", + + -- Primary opcode 63: + fdiv_3 = "fc000024FFF.", + fsub_3 = "fc000028FFF.", + fadd_3 = "fc00002aFFF.", + fsqrt_2 = "fc00002cF-F.", + fsel_4 = "fc00002eFFFF~.", + fre_2 = "fc000030F-F.", + fmul_3 = "fc000032FF-F.", + frsqrte_2 = "fc000034F-F.", + fmsub_4 = "fc000038FFFF~.", + fmadd_4 = "fc00003aFFFF~.", + fnmsub_4 = "fc00003cFFFF~.", + fnmadd_4 = "fc00003eFFFF~.", + fcmpu_3 = "fc000000XFF", + fcpsgn_3 = "fc000010FFF.", + fcmpo_3 = "fc000040XFF", + mtfsb1_1 = "fc00004cA", + fneg_2 = "fc000050F-F.", + mcrfs_2 = "fc000080XX", + mtfsb0_1 = "fc00008cA", + fmr_2 = "fc000090F-F.", + frsp_2 = "fc000018F-F.", + fctiw_2 = "fc00001cF-F.", + fctiwz_2 = "fc00001eF-F.", + mtfsfi_2 = "fc00010cAA", -- NYI: upshift. + fnabs_2 = "fc000110F-F.", + fabs_2 = "fc000210F-F.", + frin_2 = "fc000310F-F.", + friz_2 = "fc000350F-F.", + frip_2 = "fc000390F-F.", + frim_2 = "fc0003d0F-F.", + mffs_1 = "fc00048eF.", + -- NYI: mtfsf, mtfsb0, mtfsb1. + fctid_2 = "fc00065cF-F.", + fctidz_2 = "fc00065eF-F.", + fcfid_2 = "fc00069cF-F.", + + -- Primary opcode 4, SPE APU extension: + evaddw_3 = "10000200RRR", + evaddiw_3 = "10000202RAR~", + evsubw_3 = "10000204RRR~", + evsubiw_3 = "10000206RAR~", + evabs_2 = "10000208RR", + evneg_2 = "10000209RR", + evextsb_2 = "1000020aRR", + evextsh_2 = "1000020bRR", + evrndw_2 = "1000020cRR", + evcntlzw_2 = "1000020dRR", + evcntlsw_2 = "1000020eRR", + brinc_3 = "1000020fRRR", + evand_3 = "10000211RRR", + evandc_3 = "10000212RRR", + evxor_3 = "10000216RRR", + evor_3 = "10000217RRR", + evmr_2 = "10000217RR=", + evnor_3 = "10000218RRR", + evnot_2 = "10000218RR=", + eveqv_3 = "10000219RRR", + evorc_3 = "1000021bRRR", + evnand_3 = "1000021eRRR", + evsrwu_3 = "10000220RRR", + evsrws_3 = "10000221RRR", + evsrwiu_3 = "10000222RRA", + evsrwis_3 = "10000223RRA", + evslw_3 = "10000224RRR", + evslwi_3 = "10000226RRA", + evrlw_3 = "10000228RRR", + evsplati_2 = "10000229RS", + evrlwi_3 = "1000022aRRA", + evsplatfi_2 = "1000022bRS", + evmergehi_3 = "1000022cRRR", + evmergelo_3 = "1000022dRRR", + evcmpgtu_3 = "10000230XRR", + evcmpgtu_2 = "10000230-RR", + evcmpgts_3 = "10000231XRR", + evcmpgts_2 = "10000231-RR", + evcmpltu_3 = "10000232XRR", + evcmpltu_2 = "10000232-RR", + evcmplts_3 = "10000233XRR", + evcmplts_2 = "10000233-RR", + evcmpeq_3 = "10000234XRR", + evcmpeq_2 = "10000234-RR", + evsel_4 = "10000278RRRW", + evsel_3 = "10000278RRR", + evfsadd_3 = "10000280RRR", + evfssub_3 = "10000281RRR", + evfsabs_2 = "10000284RR", + evfsnabs_2 = "10000285RR", + evfsneg_2 = "10000286RR", + evfsmul_3 = "10000288RRR", + evfsdiv_3 = "10000289RRR", + evfscmpgt_3 = "1000028cXRR", + evfscmpgt_2 = "1000028c-RR", + evfscmplt_3 = "1000028dXRR", + evfscmplt_2 = "1000028d-RR", + evfscmpeq_3 = "1000028eXRR", + evfscmpeq_2 = "1000028e-RR", + evfscfui_2 = "10000290R-R", + evfscfsi_2 = "10000291R-R", + evfscfuf_2 = "10000292R-R", + evfscfsf_2 = "10000293R-R", + evfsctui_2 = "10000294R-R", + evfsctsi_2 = "10000295R-R", + evfsctuf_2 = "10000296R-R", + evfsctsf_2 = "10000297R-R", + evfsctuiz_2 = "10000298R-R", + evfsctsiz_2 = "1000029aR-R", + evfststgt_3 = "1000029cXRR", + evfststgt_2 = "1000029c-RR", + evfststlt_3 = "1000029dXRR", + evfststlt_2 = "1000029d-RR", + evfststeq_3 = "1000029eXRR", + evfststeq_2 = "1000029e-RR", + efsadd_3 = "100002c0RRR", + efssub_3 = "100002c1RRR", + efsabs_2 = "100002c4RR", + efsnabs_2 = "100002c5RR", + efsneg_2 = "100002c6RR", + efsmul_3 = "100002c8RRR", + efsdiv_3 = "100002c9RRR", + efscmpgt_3 = "100002ccXRR", + efscmpgt_2 = "100002cc-RR", + efscmplt_3 = "100002cdXRR", + efscmplt_2 = "100002cd-RR", + efscmpeq_3 = "100002ceXRR", + efscmpeq_2 = "100002ce-RR", + efscfd_2 = "100002cfR-R", + efscfui_2 = "100002d0R-R", + efscfsi_2 = "100002d1R-R", + efscfuf_2 = "100002d2R-R", + efscfsf_2 = "100002d3R-R", + efsctui_2 = "100002d4R-R", + efsctsi_2 = "100002d5R-R", + efsctuf_2 = "100002d6R-R", + efsctsf_2 = "100002d7R-R", + efsctuiz_2 = "100002d8R-R", + efsctsiz_2 = "100002daR-R", + efststgt_3 = "100002dcXRR", + efststgt_2 = "100002dc-RR", + efststlt_3 = "100002ddXRR", + efststlt_2 = "100002dd-RR", + efststeq_3 = "100002deXRR", + efststeq_2 = "100002de-RR", + efdadd_3 = "100002e0RRR", + efdsub_3 = "100002e1RRR", + efdcfuid_2 = "100002e2R-R", + efdcfsid_2 = "100002e3R-R", + efdabs_2 = "100002e4RR", + efdnabs_2 = "100002e5RR", + efdneg_2 = "100002e6RR", + efdmul_3 = "100002e8RRR", + efddiv_3 = "100002e9RRR", + efdctuidz_2 = "100002eaR-R", + efdctsidz_2 = "100002ebR-R", + efdcmpgt_3 = "100002ecXRR", + efdcmpgt_2 = "100002ec-RR", + efdcmplt_3 = "100002edXRR", + efdcmplt_2 = "100002ed-RR", + efdcmpeq_3 = "100002eeXRR", + efdcmpeq_2 = "100002ee-RR", + efdcfs_2 = "100002efR-R", + efdcfui_2 = "100002f0R-R", + efdcfsi_2 = "100002f1R-R", + efdcfuf_2 = "100002f2R-R", + efdcfsf_2 = "100002f3R-R", + efdctui_2 = "100002f4R-R", + efdctsi_2 = "100002f5R-R", + efdctuf_2 = "100002f6R-R", + efdctsf_2 = "100002f7R-R", + efdctuiz_2 = "100002f8R-R", + efdctsiz_2 = "100002faR-R", + efdtstgt_3 = "100002fcXRR", + efdtstgt_2 = "100002fc-RR", + efdtstlt_3 = "100002fdXRR", + efdtstlt_2 = "100002fd-RR", + efdtsteq_3 = "100002feXRR", + efdtsteq_2 = "100002fe-RR", + evlddx_3 = "10000300RR0R", + evldd_2 = "10000301R8", + evldwx_3 = "10000302RR0R", + evldw_2 = "10000303R8", + evldhx_3 = "10000304RR0R", + evldh_2 = "10000305R8", + evlwhex_3 = "10000310RR0R", + evlwhe_2 = "10000311R4", + evlwhoux_3 = "10000314RR0R", + evlwhou_2 = "10000315R4", + evlwhosx_3 = "10000316RR0R", + evlwhos_2 = "10000317R4", + evstddx_3 = "10000320RR0R", + evstdd_2 = "10000321R8", + evstdwx_3 = "10000322RR0R", + evstdw_2 = "10000323R8", + evstdhx_3 = "10000324RR0R", + evstdh_2 = "10000325R8", + evstwhex_3 = "10000330RR0R", + evstwhe_2 = "10000331R4", + evstwhox_3 = "10000334RR0R", + evstwho_2 = "10000335R4", + evstwwex_3 = "10000338RR0R", + evstwwe_2 = "10000339R4", + evstwwox_3 = "1000033cRR0R", + evstwwo_2 = "1000033dR4", + evmhessf_3 = "10000403RRR", + evmhossf_3 = "10000407RRR", + evmheumi_3 = "10000408RRR", + evmhesmi_3 = "10000409RRR", + evmhesmf_3 = "1000040bRRR", + evmhoumi_3 = "1000040cRRR", + evmhosmi_3 = "1000040dRRR", + evmhosmf_3 = "1000040fRRR", + evmhessfa_3 = "10000423RRR", + evmhossfa_3 = "10000427RRR", + evmheumia_3 = "10000428RRR", + evmhesmia_3 = "10000429RRR", + evmhesmfa_3 = "1000042bRRR", + evmhoumia_3 = "1000042cRRR", + evmhosmia_3 = "1000042dRRR", + evmhosmfa_3 = "1000042fRRR", + evmwhssf_3 = "10000447RRR", + evmwlumi_3 = "10000448RRR", + evmwhumi_3 = "1000044cRRR", + evmwhsmi_3 = "1000044dRRR", + evmwhsmf_3 = "1000044fRRR", + evmwssf_3 = "10000453RRR", + evmwumi_3 = "10000458RRR", + evmwsmi_3 = "10000459RRR", + evmwsmf_3 = "1000045bRRR", + evmwhssfa_3 = "10000467RRR", + evmwlumia_3 = "10000468RRR", + evmwhumia_3 = "1000046cRRR", + evmwhsmia_3 = "1000046dRRR", + evmwhsmfa_3 = "1000046fRRR", + evmwssfa_3 = "10000473RRR", + evmwumia_3 = "10000478RRR", + evmwsmia_3 = "10000479RRR", + evmwsmfa_3 = "1000047bRRR", + evmra_2 = "100004c4RR", + evdivws_3 = "100004c6RRR", + evdivwu_3 = "100004c7RRR", + evmwssfaa_3 = "10000553RRR", + evmwumiaa_3 = "10000558RRR", + evmwsmiaa_3 = "10000559RRR", + evmwsmfaa_3 = "1000055bRRR", + evmwssfan_3 = "100005d3RRR", + evmwumian_3 = "100005d8RRR", + evmwsmian_3 = "100005d9RRR", + evmwsmfan_3 = "100005dbRRR", + evmergehilo_3 = "1000022eRRR", + evmergelohi_3 = "1000022fRRR", + evlhhesplatx_3 = "10000308RR0R", + evlhhesplat_2 = "10000309R2", + evlhhousplatx_3 = "1000030cRR0R", + evlhhousplat_2 = "1000030dR2", + evlhhossplatx_3 = "1000030eRR0R", + evlhhossplat_2 = "1000030fR2", + evlwwsplatx_3 = "10000318RR0R", + evlwwsplat_2 = "10000319R4", + evlwhsplatx_3 = "1000031cRR0R", + evlwhsplat_2 = "1000031dR4", + evaddusiaaw_2 = "100004c0RR", + evaddssiaaw_2 = "100004c1RR", + evsubfusiaaw_2 = "100004c2RR", + evsubfssiaaw_2 = "100004c3RR", + evaddumiaaw_2 = "100004c8RR", + evaddsmiaaw_2 = "100004c9RR", + evsubfumiaaw_2 = "100004caRR", + evsubfsmiaaw_2 = "100004cbRR", + evmheusiaaw_3 = "10000500RRR", + evmhessiaaw_3 = "10000501RRR", + evmhessfaaw_3 = "10000503RRR", + evmhousiaaw_3 = "10000504RRR", + evmhossiaaw_3 = "10000505RRR", + evmhossfaaw_3 = "10000507RRR", + evmheumiaaw_3 = "10000508RRR", + evmhesmiaaw_3 = "10000509RRR", + evmhesmfaaw_3 = "1000050bRRR", + evmhoumiaaw_3 = "1000050cRRR", + evmhosmiaaw_3 = "1000050dRRR", + evmhosmfaaw_3 = "1000050fRRR", + evmhegumiaa_3 = "10000528RRR", + evmhegsmiaa_3 = "10000529RRR", + evmhegsmfaa_3 = "1000052bRRR", + evmhogumiaa_3 = "1000052cRRR", + evmhogsmiaa_3 = "1000052dRRR", + evmhogsmfaa_3 = "1000052fRRR", + evmwlusiaaw_3 = "10000540RRR", + evmwlssiaaw_3 = "10000541RRR", + evmwlumiaaw_3 = "10000548RRR", + evmwlsmiaaw_3 = "10000549RRR", + evmheusianw_3 = "10000580RRR", + evmhessianw_3 = "10000581RRR", + evmhessfanw_3 = "10000583RRR", + evmhousianw_3 = "10000584RRR", + evmhossianw_3 = "10000585RRR", + evmhossfanw_3 = "10000587RRR", + evmheumianw_3 = "10000588RRR", + evmhesmianw_3 = "10000589RRR", + evmhesmfanw_3 = "1000058bRRR", + evmhoumianw_3 = "1000058cRRR", + evmhosmianw_3 = "1000058dRRR", + evmhosmfanw_3 = "1000058fRRR", + evmhegumian_3 = "100005a8RRR", + evmhegsmian_3 = "100005a9RRR", + evmhegsmfan_3 = "100005abRRR", + evmhogumian_3 = "100005acRRR", + evmhogsmian_3 = "100005adRRR", + evmhogsmfan_3 = "100005afRRR", + evmwlusianw_3 = "100005c0RRR", + evmwlssianw_3 = "100005c1RRR", + evmwlumianw_3 = "100005c8RRR", + evmwlsmianw_3 = "100005c9RRR", + + -- NYI: Book E instructions. +} + +-- Add mnemonics for "." variants. +do + local t = {} + for k,v in pairs(map_op) do + if sub(v, -1) == "." then + local v2 = sub(v, 1, 7)..char(byte(v, 8)+1)..sub(v, 9, -2) + t[sub(k, 1, -3).."."..sub(k, -2)] = v2 + end + end + for k,v in pairs(t) do + map_op[k] = v + end +end + +-- Add more branch mnemonics. +for cond,c in pairs(map_cond) do + local b1 = "b"..cond + local c1 = shl(band(c, 3), 16) + (c < 4 and 0x01000000 or 0) + -- bX[l] + map_op[b1.."_1"] = tohex(0x40800000 + c1).."K" + map_op[b1.."y_1"] = tohex(0x40a00000 + c1).."K" + map_op[b1.."l_1"] = tohex(0x40800001 + c1).."K" + map_op[b1.."_2"] = tohex(0x40800000 + c1).."-XK" + map_op[b1.."y_2"] = tohex(0x40a00000 + c1).."-XK" + map_op[b1.."l_2"] = tohex(0x40800001 + c1).."-XK" + -- bXlr[l] + map_op[b1.."lr_0"] = tohex(0x4c800020 + c1) + map_op[b1.."lrl_0"] = tohex(0x4c800021 + c1) + map_op[b1.."ctr_0"] = tohex(0x4c800420 + c1) + map_op[b1.."ctrl_0"] = tohex(0x4c800421 + c1) + -- bXctr[l] + map_op[b1.."lr_1"] = tohex(0x4c800020 + c1).."-X" + map_op[b1.."lrl_1"] = tohex(0x4c800021 + c1).."-X" + map_op[b1.."ctr_1"] = tohex(0x4c800420 + c1).."-X" + map_op[b1.."ctrl_1"] = tohex(0x4c800421 + c1).."-X" +end + +------------------------------------------------------------------------------ + +local function parse_gpr(expr) + local tname, ovreg = match(expr, "^([%w_]+):(r[1-3]?[0-9])$") + local tp = map_type[tname or expr] + if tp then + local reg = ovreg or tp.reg + if not reg then + werror("type `"..(tname or expr).."' needs a register override") + end + expr = reg + end + local r = match(expr, "^r([1-3]?[0-9])$") + if r then + r = tonumber(r) + if r <= 31 then return r, tp end + end + werror("bad register name `"..expr.."'") +end + +local function parse_fpr(expr) + local r = match(expr, "^f([1-3]?[0-9])$") + if r then + r = tonumber(r) + if r <= 31 then return r end + end + werror("bad register name `"..expr.."'") +end + +local function parse_cr(expr) + local r = match(expr, "^cr([0-7])$") + if r then return tonumber(r) end + werror("bad condition register name `"..expr.."'") +end + +local function parse_cond(expr) + local r, cond = match(expr, "^4%*cr([0-7])%+(%w%w)$") + if r then + r = tonumber(r) + local c = map_cond[cond] + if c and c < 4 then return r*4+c end + end + werror("bad condition bit name `"..expr.."'") +end + +local function parse_imm(imm, bits, shift, scale, signed) + local n = tonumber(imm) + if n then + local m = sar(n, scale) + if shl(m, scale) == n then + if signed then + local s = sar(m, bits-1) + if s == 0 then return shl(m, shift) + elseif s == -1 then return shl(m + shl(1, bits), shift) end + else + if sar(m, bits) == 0 then return shl(m, shift) end + end + end + werror("out of range immediate `"..imm.."'") + elseif match(imm, "^r([1-3]?[0-9])$") or + match(imm, "^([%w_]+):(r[1-3]?[0-9])$") then + werror("expected immediate operand, got register") + else + waction("IMM", (signed and 32768 or 0)+scale*1024+bits*32+shift, imm) + return 0 + end +end + +local function parse_shiftmask(imm, isshift) + local n = tonumber(imm) + if n then + if shr(n, 6) == 0 then + local lsb = band(imm, 31) + local msb = imm - lsb + return isshift and (shl(lsb, 11)+shr(msb, 4)) or (shl(lsb, 6)+msb) + end + werror("out of range immediate `"..imm.."'") + elseif match(imm, "^r([1-3]?[0-9])$") or + match(imm, "^([%w_]+):(r[1-3]?[0-9])$") then + werror("expected immediate operand, got register") + else + werror("NYI: parameterized 64 bit shift/mask") + end +end + +local function parse_disp(disp) + local imm, reg = match(disp, "^(.*)%(([%w_:]+)%)$") + if imm then + local r = parse_gpr(reg) + if r == 0 then werror("cannot use r0 in displacement") end + return shl(r, 16) + parse_imm(imm, 16, 0, 0, true) + end + local reg, tailr = match(disp, "^([%w_:]+)%s*(.*)$") + if reg and tailr ~= "" then + local r, tp = parse_gpr(reg) + if r == 0 then werror("cannot use r0 in displacement") end + if tp then + waction("IMM", 32768+16*32, format(tp.ctypefmt, tailr)) + return shl(r, 16) + end + end + werror("bad displacement `"..disp.."'") +end + +local function parse_u5disp(disp, scale) + local imm, reg = match(disp, "^(.*)%(([%w_:]+)%)$") + if imm then + local r = parse_gpr(reg) + if r == 0 then werror("cannot use r0 in displacement") end + return shl(r, 16) + parse_imm(imm, 5, 11, scale, false) + end + local reg, tailr = match(disp, "^([%w_:]+)%s*(.*)$") + if reg and tailr ~= "" then + local r, tp = parse_gpr(reg) + if r == 0 then werror("cannot use r0 in displacement") end + if tp then + waction("IMM", scale*1024+5*32+11, format(tp.ctypefmt, tailr)) + return shl(r, 16) + end + end + werror("bad displacement `"..disp.."'") +end + +local function parse_label(label, def) + local prefix = sub(label, 1, 2) + -- =>label (pc label reference) + if prefix == "=>" then + return "PC", 0, sub(label, 3) + end + -- ->name (global label reference) + if prefix == "->" then + return "LG", map_global[sub(label, 3)] + end + if def then + -- [1-9] (local label definition) + if match(label, "^[1-9]$") then + return "LG", 10+tonumber(label) + end + else + -- [<>][1-9] (local label reference) + local dir, lnum = match(label, "^([<>])([1-9])$") + if dir then -- Fwd: 1-9, Bkwd: 11-19. + return "LG", lnum + (dir == ">" and 0 or 10) + end + -- extern label (extern label reference) + local extname = match(label, "^extern%s+(%S+)$") + if extname then + return "EXT", map_extern[extname] + end + end + werror("bad label `"..label.."'") +end + +------------------------------------------------------------------------------ + +-- Handle opcodes defined with template strings. +map_op[".template__"] = function(params, template, nparams) + if not params then return sub(template, 9) end + local op = tonumber(sub(template, 1, 8), 16) + local n, rs = 1, 26 + + -- Limit number of section buffer positions used by a single dasm_put(). + -- A single opcode needs a maximum of 3 positions (rlwinm). + if secpos+3 > maxsecpos then wflush() end + local pos = wpos() + + -- Process each character. + for p in gmatch(sub(template, 9), ".") do + if p == "R" then + rs = rs - 5; op = op + shl(parse_gpr(params[n]), rs); n = n + 1 + elseif p == "F" then + rs = rs - 5; op = op + shl(parse_fpr(params[n]), rs); n = n + 1 + elseif p == "A" then + rs = rs - 5; op = op + parse_imm(params[n], 5, rs, 0, false); n = n + 1 + elseif p == "S" then + rs = rs - 5; op = op + parse_imm(params[n], 5, rs, 0, true); n = n + 1 + elseif p == "I" then + op = op + parse_imm(params[n], 16, 0, 0, true); n = n + 1 + elseif p == "U" then + op = op + parse_imm(params[n], 16, 0, 0, false); n = n + 1 + elseif p == "D" then + op = op + parse_disp(params[n]); n = n + 1 + elseif p == "2" then + op = op + parse_u5disp(params[n], 1); n = n + 1 + elseif p == "4" then + op = op + parse_u5disp(params[n], 2); n = n + 1 + elseif p == "8" then + op = op + parse_u5disp(params[n], 3); n = n + 1 + elseif p == "C" then + rs = rs - 5; op = op + shl(parse_cond(params[n]), rs); n = n + 1 + elseif p == "X" then + rs = rs - 5; op = op + shl(parse_cr(params[n]), rs+2); n = n + 1 + elseif p == "W" then + op = op + parse_cr(params[n]); n = n + 1 + elseif p == "G" then + op = op + parse_imm(params[n], 8, 12, 0, false); n = n + 1 + elseif p == "H" then + op = op + parse_shiftmask(params[n], true); n = n + 1 + elseif p == "M" then + op = op + parse_shiftmask(params[n], false); n = n + 1 + elseif p == "J" or p == "K" then + local mode, n, s = parse_label(params[n], false) + if p == "K" then n = n + 2048 end + waction("REL_"..mode, n, s, 1) + n = n + 1 + elseif p == "0" then + if band(shr(op, rs), 31) == 0 then werror("cannot use r0") end + elseif p == "=" or p == "%" then + local t = band(shr(op, p == "%" and rs+5 or rs), 31) + rs = rs - 5 + op = op + shl(t, rs) + elseif p == "~" then + local mm = shl(31, rs) + local lo = band(op, mm) + local hi = band(op, shl(mm, 5)) + op = op - lo - hi + shl(lo, 5) + shr(hi, 5) + elseif p == "-" then + rs = rs - 5 + elseif p == "." then + -- Ignored. + else + assert(false) + end + end + wputpos(pos, op) +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcode to mark the position where the action list is to be emitted. +map_op[".actionlist_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeactions(out, name) end) +end + +-- Pseudo-opcode to mark the position where the global enum is to be emitted. +map_op[".globals_1"] = function(params) + if not params then return "prefix" end + local prefix = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeglobals(out, prefix) end) +end + +-- Pseudo-opcode to mark the position where the global names are to be emitted. +map_op[".globalnames_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeglobalnames(out, name) end) +end + +-- Pseudo-opcode to mark the position where the extern names are to be emitted. +map_op[".externnames_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeexternnames(out, name) end) +end + +------------------------------------------------------------------------------ + +-- Label pseudo-opcode (converted from trailing colon form). +map_op[".label_1"] = function(params) + if not params then return "[1-9] | ->global | =>pcexpr" end + if secpos+1 > maxsecpos then wflush() end + local mode, n, s = parse_label(params[1], true) + if mode == "EXT" then werror("bad label definition") end + waction("LABEL_"..mode, n, s, 1) +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcodes for data storage. +map_op[".long_*"] = function(params) + if not params then return "imm..." end + for _,p in ipairs(params) do + local n = tonumber(p) + if not n then werror("bad immediate `"..p.."'") end + if n < 0 then n = n + 2^32 end + wputw(n) + if secpos+2 > maxsecpos then wflush() end + end +end + +-- Alignment pseudo-opcode. +map_op[".align_1"] = function(params) + if not params then return "numpow2" end + if secpos+1 > maxsecpos then wflush() end + local align = tonumber(params[1]) + if align then + local x = align + -- Must be a power of 2 in the range (2 ... 256). + for i=1,8 do + x = x / 2 + if x == 1 then + waction("ALIGN", align-1, nil, 1) -- Action byte is 2**n-1. + return + end + end + end + werror("bad alignment") +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcode for (primitive) type definitions (map to C types). +map_op[".type_3"] = function(params, nparams) + if not params then + return nparams == 2 and "name, ctype" or "name, ctype, reg" + end + local name, ctype, reg = params[1], params[2], params[3] + if not match(name, "^[%a_][%w_]*$") then + werror("bad type name `"..name.."'") + end + local tp = map_type[name] + if tp then + werror("duplicate type `"..name.."'") + end + -- Add #type to defines. A bit unclean to put it in map_archdef. + map_archdef["#"..name] = "sizeof("..ctype..")" + -- Add new type and emit shortcut define. + local num = ctypenum + 1 + map_type[name] = { + ctype = ctype, + ctypefmt = format("Dt%X(%%s)", num), + reg = reg, + } + wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype)) + ctypenum = num +end +map_op[".type_2"] = map_op[".type_3"] + +-- Dump type definitions. +local function dumptypes(out, lvl) + local t = {} + for name in pairs(map_type) do t[#t+1] = name end + sort(t) + out:write("Type definitions:\n") + for _,name in ipairs(t) do + local tp = map_type[name] + local reg = tp.reg or "" + out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg)) + end + out:write("\n") +end + +------------------------------------------------------------------------------ + +-- Set the current section. +function _M.section(num) + waction("SECTION", num) + wflush(true) -- SECTION is a terminal action. +end + +------------------------------------------------------------------------------ + +-- Dump architecture description. +function _M.dumparch(out) + out:write(format("DynASM %s version %s, released %s\n\n", + _info.arch, _info.version, _info.release)) + dumpactions(out) +end + +-- Dump all user defined elements. +function _M.dumpdef(out, lvl) + dumptypes(out, lvl) + dumpglobals(out, lvl) + dumpexterns(out, lvl) +end + +------------------------------------------------------------------------------ + +-- Pass callbacks from/to the DynASM core. +function _M.passcb(wl, we, wf, ww) + wline, werror, wfatal, wwarn = wl, we, wf, ww + return wflush +end + +-- Setup the arch-specific module. +function _M.setup(arch, opt) + g_arch, g_opt = arch, opt +end + +-- Merge the core maps and the arch-specific maps. +function _M.mergemaps(map_coreop, map_def) + setmetatable(map_op, { __index = map_coreop }) + setmetatable(map_def, { __index = map_archdef }) + return map_op, map_def +end + +return _M + +------------------------------------------------------------------------------ + diff --git a/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_proto.h b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_proto.h new file mode 100644 index 000000000..a8bc6fd28 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_proto.h @@ -0,0 +1,83 @@ +/* +** DynASM encoding engine prototypes. +** Copyright (C) 2005-2015 Mike Pall. All rights reserved. +** Released under the MIT license. See dynasm.lua for full copyright notice. +*/ + +#ifndef _DASM_PROTO_H +#define _DASM_PROTO_H + +#include +#include + +#define DASM_IDENT "DynASM 1.3.0" +#define DASM_VERSION 10300 /* 1.3.0 */ + +#ifndef Dst_DECL +#define Dst_DECL dasm_State **Dst +#endif + +#ifndef Dst_REF +#define Dst_REF (*Dst) +#endif + +#ifndef DASM_FDEF +#define DASM_FDEF extern +#endif + +#ifndef DASM_M_GROW +#define DASM_M_GROW(ctx, t, p, sz, need) \ + do { \ + size_t _sz = (sz), _need = (need); \ + if (_sz < _need) { \ + if (_sz < 16) _sz = 16; \ + while (_sz < _need) _sz += _sz; \ + (p) = (t *)realloc((p), _sz); \ + if ((p) == NULL) exit(1); \ + (sz) = _sz; \ + } \ + } while(0) +#endif + +#ifndef DASM_M_FREE +#define DASM_M_FREE(ctx, p, sz) free(p) +#endif + +/* Internal DynASM encoder state. */ +typedef struct dasm_State dasm_State; + + +/* Initialize and free DynASM state. */ +DASM_FDEF void dasm_init(Dst_DECL, int maxsection); +DASM_FDEF void dasm_free(Dst_DECL); + +/* Setup global array. Must be called before dasm_setup(). */ +DASM_FDEF void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl); + +/* Grow PC label array. Can be called after dasm_setup(), too. */ +DASM_FDEF void dasm_growpc(Dst_DECL, unsigned int maxpc); + +/* Setup encoder. */ +DASM_FDEF void dasm_setup(Dst_DECL, const void *actionlist); + +/* Feed encoder with actions. Calls are generated by pre-processor. */ +DASM_FDEF void dasm_put(Dst_DECL, int start, ...); + +/* Link sections and return the resulting size. */ +DASM_FDEF int dasm_link(Dst_DECL, size_t *szp); + +/* Encode sections into buffer. */ +DASM_FDEF int dasm_encode(Dst_DECL, void *buffer); + +/* Get PC label offset. */ +DASM_FDEF int dasm_getpclabel(Dst_DECL, unsigned int pc); + +#ifdef DASM_CHECKS +/* Optional sanity checker to call between isolated encoding steps. */ +DASM_FDEF int dasm_checkstep(Dst_DECL, int secmatch); +#else +#define dasm_checkstep(a, b) 0 +#endif + + +#endif /* _DASM_PROTO_H */ diff --git a/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_x64.lua b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_x64.lua new file mode 100644 index 000000000..b1b62022f --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_x64.lua @@ -0,0 +1,12 @@ +------------------------------------------------------------------------------ +-- DynASM x64 module. +-- +-- Copyright (C) 2005-2015 Mike Pall. All rights reserved. +-- See dynasm.lua for full copyright notice. +------------------------------------------------------------------------------ +-- This module just sets 64 bit mode for the combined x86/x64 module. +-- All the interesting stuff is there. +------------------------------------------------------------------------------ + +x64 = true -- Using a global is an ugly, but effective solution. +return require("dasm_x86") diff --git a/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_x86.h b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_x86.h new file mode 100644 index 000000000..652e8c99b --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_x86.h @@ -0,0 +1,471 @@ +/* +** DynASM x86 encoding engine. +** Copyright (C) 2005-2015 Mike Pall. All rights reserved. +** Released under the MIT license. See dynasm.lua for full copyright notice. +*/ + +#include +#include +#include +#include + +#define DASM_ARCH "x86" + +#ifndef DASM_EXTERN +#define DASM_EXTERN(a,b,c,d) 0 +#endif + +/* Action definitions. DASM_STOP must be 255. */ +enum { + DASM_DISP = 233, + DASM_IMM_S, DASM_IMM_B, DASM_IMM_W, DASM_IMM_D, DASM_IMM_WB, DASM_IMM_DB, + DASM_VREG, DASM_SPACE, DASM_SETLABEL, DASM_REL_A, DASM_REL_LG, DASM_REL_PC, + DASM_IMM_LG, DASM_IMM_PC, DASM_LABEL_LG, DASM_LABEL_PC, DASM_ALIGN, + DASM_EXTERN, DASM_ESC, DASM_MARK, DASM_SECTION, DASM_STOP +}; + +/* Maximum number of section buffer positions for a single dasm_put() call. */ +#define DASM_MAXSECPOS 25 + +/* DynASM encoder status codes. Action list offset or number are or'ed in. */ +#define DASM_S_OK 0x00000000 +#define DASM_S_NOMEM 0x01000000 +#define DASM_S_PHASE 0x02000000 +#define DASM_S_MATCH_SEC 0x03000000 +#define DASM_S_RANGE_I 0x11000000 +#define DASM_S_RANGE_SEC 0x12000000 +#define DASM_S_RANGE_LG 0x13000000 +#define DASM_S_RANGE_PC 0x14000000 +#define DASM_S_RANGE_VREG 0x15000000 +#define DASM_S_UNDEF_L 0x21000000 +#define DASM_S_UNDEF_PC 0x22000000 + +/* Macros to convert positions (8 bit section + 24 bit index). */ +#define DASM_POS2IDX(pos) ((pos)&0x00ffffff) +#define DASM_POS2BIAS(pos) ((pos)&0xff000000) +#define DASM_SEC2POS(sec) ((sec)<<24) +#define DASM_POS2SEC(pos) ((pos)>>24) +#define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) + +/* Action list type. */ +typedef const unsigned char *dasm_ActList; + +/* Per-section structure. */ +typedef struct dasm_Section { + int *rbuf; /* Biased buffer pointer (negative section bias). */ + int *buf; /* True buffer pointer. */ + size_t bsize; /* Buffer size in bytes. */ + int pos; /* Biased buffer position. */ + int epos; /* End of biased buffer position - max single put. */ + int ofs; /* Byte offset into section. */ +} dasm_Section; + +/* Core structure holding the DynASM encoding state. */ +struct dasm_State { + size_t psize; /* Allocated size of this structure. */ + dasm_ActList actionlist; /* Current actionlist pointer. */ + int *lglabels; /* Local/global chain/pos ptrs. */ + size_t lgsize; + int *pclabels; /* PC label chains/pos ptrs. */ + size_t pcsize; + void **globals; /* Array of globals (bias -10). */ + dasm_Section *section; /* Pointer to active section. */ + size_t codesize; /* Total size of all code sections. */ + int maxsection; /* 0 <= sectionidx < maxsection. */ + int status; /* Status code. */ + dasm_Section sections[1]; /* All sections. Alloc-extended. */ +}; + +/* The size of the core structure depends on the max. number of sections. */ +#define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section)) + + +/* Initialize DynASM state. */ +void dasm_init(Dst_DECL, int maxsection) +{ + dasm_State *D; + size_t psz = 0; + int i; + Dst_REF = NULL; + DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); + D = Dst_REF; + D->psize = psz; + D->lglabels = NULL; + D->lgsize = 0; + D->pclabels = NULL; + D->pcsize = 0; + D->globals = NULL; + D->maxsection = maxsection; + for (i = 0; i < maxsection; i++) { + D->sections[i].buf = NULL; /* Need this for pass3. */ + D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i); + D->sections[i].bsize = 0; + D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ + } +} + +/* Free DynASM state. */ +void dasm_free(Dst_DECL) +{ + dasm_State *D = Dst_REF; + int i; + for (i = 0; i < D->maxsection; i++) + if (D->sections[i].buf) + DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize); + if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize); + if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize); + DASM_M_FREE(Dst, D, D->psize); +} + +/* Setup global label array. Must be called before dasm_setup(). */ +void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) +{ + dasm_State *D = Dst_REF; + D->globals = gl - 10; /* Negative bias to compensate for locals. */ + DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); +} + +/* Grow PC label array. Can be called after dasm_setup(), too. */ +void dasm_growpc(Dst_DECL, unsigned int maxpc) +{ + dasm_State *D = Dst_REF; + size_t osz = D->pcsize; + DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int)); + memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz); +} + +/* Setup encoder. */ +void dasm_setup(Dst_DECL, const void *actionlist) +{ + dasm_State *D = Dst_REF; + int i; + D->actionlist = (dasm_ActList)actionlist; + D->status = DASM_S_OK; + D->section = &D->sections[0]; + memset((void *)D->lglabels, 0, D->lgsize); + if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); + for (i = 0; i < D->maxsection; i++) { + D->sections[i].pos = DASM_SEC2POS(i); + D->sections[i].ofs = 0; + } +} + + +#ifdef DASM_CHECKS +#define CK(x, st) \ + do { if (!(x)) { \ + D->status = DASM_S_##st|(int)(p-D->actionlist-1); return; } } while (0) +#define CKPL(kind, st) \ + do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \ + D->status=DASM_S_RANGE_##st|(int)(p-D->actionlist-1); return; } } while (0) +#else +#define CK(x, st) ((void)0) +#define CKPL(kind, st) ((void)0) +#endif + +/* Pass 1: Store actions and args, link branches/labels, estimate offsets. */ +void dasm_put(Dst_DECL, int start, ...) +{ + va_list ap; + dasm_State *D = Dst_REF; + dasm_ActList p = D->actionlist + start; + dasm_Section *sec = D->section; + int pos = sec->pos, ofs = sec->ofs, mrm = 4; + int *b; + + if (pos >= sec->epos) { + DASM_M_GROW(Dst, int, sec->buf, sec->bsize, + sec->bsize + 2*DASM_MAXSECPOS*sizeof(int)); + sec->rbuf = sec->buf - DASM_POS2BIAS(pos); + sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos); + } + + b = sec->rbuf; + b[pos++] = start; + + va_start(ap, start); + while (1) { + int action = *p++; + if (action < DASM_DISP) { + ofs++; + } else if (action <= DASM_REL_A) { + int n = va_arg(ap, int); + b[pos++] = n; + switch (action) { + case DASM_DISP: + if (n == 0) { if ((mrm&7) == 4) mrm = p[-2]; if ((mrm&7) != 5) break; } + case DASM_IMM_DB: if (((n+128)&-256) == 0) goto ob; + case DASM_REL_A: /* Assumes ptrdiff_t is int. !x64 */ + case DASM_IMM_D: ofs += 4; break; + case DASM_IMM_S: CK(((n+128)&-256) == 0, RANGE_I); goto ob; + case DASM_IMM_B: CK((n&-256) == 0, RANGE_I); ob: ofs++; break; + case DASM_IMM_WB: if (((n+128)&-256) == 0) goto ob; + case DASM_IMM_W: CK((n&-65536) == 0, RANGE_I); ofs += 2; break; + case DASM_SPACE: p++; ofs += n; break; + case DASM_SETLABEL: b[pos-2] = -0x40000000; break; /* Neg. label ofs. */ + case DASM_VREG: CK((n&-8) == 0 && (n != 4 || (*p&1) == 0), RANGE_VREG); + if (*p++ == 1 && *p == DASM_DISP) mrm = n; continue; + } + mrm = 4; + } else { + int *pl, n; + switch (action) { + case DASM_REL_LG: + case DASM_IMM_LG: + n = *p++; pl = D->lglabels + n; + /* Bkwd rel or global. */ + if (n <= 246) { CK(n>=10||*pl<0, RANGE_LG); CKPL(lg, LG); goto putrel; } + pl -= 246; n = *pl; + if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */ + goto linkrel; + case DASM_REL_PC: + case DASM_IMM_PC: pl = D->pclabels + va_arg(ap, int); CKPL(pc, PC); + putrel: + n = *pl; + if (n < 0) { /* Label exists. Get label pos and store it. */ + b[pos] = -n; + } else { + linkrel: + b[pos] = n; /* Else link to rel chain, anchored at label. */ + *pl = pos; + } + pos++; + ofs += 4; /* Maximum offset needed. */ + if (action == DASM_REL_LG || action == DASM_REL_PC) + b[pos++] = ofs; /* Store pass1 offset estimate. */ + break; + case DASM_LABEL_LG: pl = D->lglabels + *p++; CKPL(lg, LG); goto putlabel; + case DASM_LABEL_PC: pl = D->pclabels + va_arg(ap, int); CKPL(pc, PC); + putlabel: + n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */ + while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; } + *pl = -pos; /* Label exists now. */ + b[pos++] = ofs; /* Store pass1 offset estimate. */ + break; + case DASM_ALIGN: + ofs += *p++; /* Maximum alignment needed (arg is 2**n-1). */ + b[pos++] = ofs; /* Store pass1 offset estimate. */ + break; + case DASM_EXTERN: p += 2; ofs += 4; break; + case DASM_ESC: p++; ofs++; break; + case DASM_MARK: mrm = p[-2]; break; + case DASM_SECTION: + n = *p; CK(n < D->maxsection, RANGE_SEC); D->section = &D->sections[n]; + case DASM_STOP: goto stop; + } + } + } +stop: + va_end(ap); + sec->pos = pos; + sec->ofs = ofs; +} +#undef CK + +/* Pass 2: Link sections, shrink branches/aligns, fix label offsets. */ +int dasm_link(Dst_DECL, size_t *szp) +{ + dasm_State *D = Dst_REF; + int secnum; + int ofs = 0; + +#ifdef DASM_CHECKS + *szp = 0; + if (D->status != DASM_S_OK) return D->status; + { + int pc; + for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) + if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; + } +#endif + + { /* Handle globals not defined in this translation unit. */ + int idx; + for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) { + int n = D->lglabels[idx]; + /* Undefined label: Collapse rel chain and replace with marker (< 0). */ + while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } + } + } + + /* Combine all code sections. No support for data sections (yet). */ + for (secnum = 0; secnum < D->maxsection; secnum++) { + dasm_Section *sec = D->sections + secnum; + int *b = sec->rbuf; + int pos = DASM_SEC2POS(secnum); + int lastpos = sec->pos; + + while (pos != lastpos) { + dasm_ActList p = D->actionlist + b[pos++]; + while (1) { + int op, action = *p++; + switch (action) { + case DASM_REL_LG: p++; op = p[-3]; goto rel_pc; + case DASM_REL_PC: op = p[-2]; rel_pc: { + int shrink = op == 0xe9 ? 3 : ((op&0xf0) == 0x80 ? 4 : 0); + if (shrink) { /* Shrinkable branch opcode? */ + int lofs, lpos = b[pos]; + if (lpos < 0) goto noshrink; /* Ext global? */ + lofs = *DASM_POS2PTR(D, lpos); + if (lpos > pos) { /* Fwd label: add cumulative section offsets. */ + int i; + for (i = secnum; i < DASM_POS2SEC(lpos); i++) + lofs += D->sections[i].ofs; + } else { + lofs -= ofs; /* Bkwd label: unfix offset. */ + } + lofs -= b[pos+1]; /* Short branch ok? */ + if (lofs >= -128-shrink && lofs <= 127) ofs -= shrink; /* Yes. */ + else { noshrink: shrink = 0; } /* No, cannot shrink op. */ + } + b[pos+1] = shrink; + pos += 2; + break; + } + case DASM_SPACE: case DASM_IMM_LG: case DASM_VREG: p++; + case DASM_DISP: case DASM_IMM_S: case DASM_IMM_B: case DASM_IMM_W: + case DASM_IMM_D: case DASM_IMM_WB: case DASM_IMM_DB: + case DASM_SETLABEL: case DASM_REL_A: case DASM_IMM_PC: pos++; break; + case DASM_LABEL_LG: p++; + case DASM_LABEL_PC: b[pos++] += ofs; break; /* Fix label offset. */ + case DASM_ALIGN: ofs -= (b[pos++]+ofs)&*p++; break; /* Adjust ofs. */ + case DASM_EXTERN: p += 2; break; + case DASM_ESC: p++; break; + case DASM_MARK: break; + case DASM_SECTION: case DASM_STOP: goto stop; + } + } + stop: (void)0; + } + ofs += sec->ofs; /* Next section starts right after current section. */ + } + + D->codesize = ofs; /* Total size of all code sections */ + *szp = ofs; + return DASM_S_OK; +} + +#define dasmb(x) *cp++ = (unsigned char)(x) +#ifndef DASM_ALIGNED_WRITES +#define dasmw(x) \ + do { *((unsigned short *)cp) = (unsigned short)(x); cp+=2; } while (0) +#define dasmd(x) \ + do { *((unsigned int *)cp) = (unsigned int)(x); cp+=4; } while (0) +#else +#define dasmw(x) do { dasmb(x); dasmb((x)>>8); } while (0) +#define dasmd(x) do { dasmw(x); dasmw((x)>>16); } while (0) +#endif + +/* Pass 3: Encode sections. */ +int dasm_encode(Dst_DECL, void *buffer) +{ + dasm_State *D = Dst_REF; + unsigned char *base = (unsigned char *)buffer; + unsigned char *cp = base; + int secnum; + + /* Encode all code sections. No support for data sections (yet). */ + for (secnum = 0; secnum < D->maxsection; secnum++) { + dasm_Section *sec = D->sections + secnum; + int *b = sec->buf; + int *endb = sec->rbuf + sec->pos; + + while (b != endb) { + dasm_ActList p = D->actionlist + *b++; + unsigned char *mark = NULL; + while (1) { + int action = *p++; + int n = (action >= DASM_DISP && action <= DASM_ALIGN) ? *b++ : 0; + switch (action) { + case DASM_DISP: if (!mark) mark = cp; { + unsigned char *mm = mark; + if (*p != DASM_IMM_DB && *p != DASM_IMM_WB) mark = NULL; + if (n == 0) { int mrm = mm[-1]&7; if (mrm == 4) mrm = mm[0]&7; + if (mrm != 5) { mm[-1] -= 0x80; break; } } + if (((n+128) & -256) != 0) goto wd; else mm[-1] -= 0x40; + } + case DASM_IMM_S: case DASM_IMM_B: wb: dasmb(n); break; + case DASM_IMM_DB: if (((n+128)&-256) == 0) { + db: if (!mark) mark = cp; mark[-2] += 2; mark = NULL; goto wb; + } else mark = NULL; + case DASM_IMM_D: wd: dasmd(n); break; + case DASM_IMM_WB: if (((n+128)&-256) == 0) goto db; else mark = NULL; + case DASM_IMM_W: dasmw(n); break; + case DASM_VREG: { int t = *p++; if (t >= 2) n<<=3; cp[-1] |= n; break; } + case DASM_REL_LG: p++; if (n >= 0) goto rel_pc; + b++; n = (int)(ptrdiff_t)D->globals[-n]; + case DASM_REL_A: rel_a: n -= (int)(ptrdiff_t)(cp+4); goto wd; /* !x64 */ + case DASM_REL_PC: rel_pc: { + int shrink = *b++; + int *pb = DASM_POS2PTR(D, n); if (*pb < 0) { n = pb[1]; goto rel_a; } + n = *pb - ((int)(cp-base) + 4-shrink); + if (shrink == 0) goto wd; + if (shrink == 4) { cp--; cp[-1] = *cp-0x10; } else cp[-1] = 0xeb; + goto wb; + } + case DASM_IMM_LG: + p++; if (n < 0) { n = (int)(ptrdiff_t)D->globals[-n]; goto wd; } + case DASM_IMM_PC: { + int *pb = DASM_POS2PTR(D, n); + n = *pb < 0 ? pb[1] : (*pb + (int)(ptrdiff_t)base); + goto wd; + } + case DASM_LABEL_LG: { + int idx = *p++; + if (idx >= 10) + D->globals[idx] = (void *)(base + (*p == DASM_SETLABEL ? *b : n)); + break; + } + case DASM_LABEL_PC: case DASM_SETLABEL: break; + case DASM_SPACE: { int fill = *p++; while (n--) *cp++ = fill; break; } + case DASM_ALIGN: + n = *p++; + while (((cp-base) & n)) *cp++ = 0x90; /* nop */ + break; + case DASM_EXTERN: n = DASM_EXTERN(Dst, cp, p[1], *p); p += 2; goto wd; + case DASM_MARK: mark = cp; break; + case DASM_ESC: action = *p++; + default: *cp++ = action; break; + case DASM_SECTION: case DASM_STOP: goto stop; + } + } + stop: (void)0; + } + } + + if (base + D->codesize != cp) /* Check for phase errors. */ + return DASM_S_PHASE; + return DASM_S_OK; +} + +/* Get PC label offset. */ +int dasm_getpclabel(Dst_DECL, unsigned int pc) +{ + dasm_State *D = Dst_REF; + if (pc*sizeof(int) < D->pcsize) { + int pos = D->pclabels[pc]; + if (pos < 0) return *DASM_POS2PTR(D, -pos); + if (pos > 0) return -1; /* Undefined. */ + } + return -2; /* Unused or out of range. */ +} + +#ifdef DASM_CHECKS +/* Optional sanity checker to call between isolated encoding steps. */ +int dasm_checkstep(Dst_DECL, int secmatch) +{ + dasm_State *D = Dst_REF; + if (D->status == DASM_S_OK) { + int i; + for (i = 1; i <= 9; i++) { + if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_L|i; break; } + D->lglabels[i] = 0; + } + } + if (D->status == DASM_S_OK && secmatch >= 0 && + D->section != &D->sections[secmatch]) + D->status = DASM_S_MATCH_SEC|(int)(D->section-D->sections); + return D->status; +} +#endif + diff --git a/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_x86.lua b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_x86.lua new file mode 100644 index 000000000..7ca061d22 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dasm_x86.lua @@ -0,0 +1,1945 @@ +------------------------------------------------------------------------------ +-- DynASM x86/x64 module. +-- +-- Copyright (C) 2005-2015 Mike Pall. All rights reserved. +-- See dynasm.lua for full copyright notice. +------------------------------------------------------------------------------ + +local x64 = x64 + +-- Module information: +local _info = { + arch = x64 and "x64" or "x86", + description = "DynASM x86/x64 module", + version = "1.3.0", + vernum = 10300, + release = "2011-05-05", + author = "Mike Pall", + license = "MIT", +} + +-- Exported glue functions for the arch-specific module. +local _M = { _info = _info } + +-- Cache library functions. +local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs +local assert, unpack, setmetatable = assert, unpack or table.unpack, setmetatable +local _s = string +local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char +local find, match, gmatch, gsub = _s.find, _s.match, _s.gmatch, _s.gsub +local concat, sort = table.concat, table.sort +local bit = bit or require("bit") +local band, shl, shr = bit.band, bit.lshift, bit.rshift + +-- Inherited tables and callbacks. +local g_opt, g_arch +local wline, werror, wfatal, wwarn + +-- Action name list. +-- CHECK: Keep this in sync with the C code! +local action_names = { + -- int arg, 1 buffer pos: + "DISP", "IMM_S", "IMM_B", "IMM_W", "IMM_D", "IMM_WB", "IMM_DB", + -- action arg (1 byte), int arg, 1 buffer pos (reg/num): + "VREG", "SPACE", -- !x64: VREG support NYI. + -- ptrdiff_t arg, 1 buffer pos (address): !x64 + "SETLABEL", "REL_A", + -- action arg (1 byte) or int arg, 2 buffer pos (link, offset): + "REL_LG", "REL_PC", + -- action arg (1 byte) or int arg, 1 buffer pos (link): + "IMM_LG", "IMM_PC", + -- action arg (1 byte) or int arg, 1 buffer pos (offset): + "LABEL_LG", "LABEL_PC", + -- action arg (1 byte), 1 buffer pos (offset): + "ALIGN", + -- action args (2 bytes), no buffer pos. + "EXTERN", + -- action arg (1 byte), no buffer pos. + "ESC", + -- no action arg, no buffer pos. + "MARK", + -- action arg (1 byte), no buffer pos, terminal action: + "SECTION", + -- no args, no buffer pos, terminal action: + "STOP" +} + +-- Maximum number of section buffer positions for dasm_put(). +-- CHECK: Keep this in sync with the C code! +local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines. + +-- Action name -> action number (dynamically generated below). +local map_action = {} +-- First action number. Everything below does not need to be escaped. +local actfirst = 256-#action_names + +-- Action list buffer and string (only used to remove dupes). +local actlist = {} +local actstr = "" + +-- Argument list for next dasm_put(). Start with offset 0 into action list. +local actargs = { 0 } + +-- Current number of section buffer positions for dasm_put(). +local secpos = 1 + +------------------------------------------------------------------------------ + +-- Compute action numbers for action names. +for n,name in ipairs(action_names) do + local num = actfirst + n - 1 + map_action[name] = num +end + +-- Dump action names and numbers. +local function dumpactions(out) + out:write("DynASM encoding engine action codes:\n") + for n,name in ipairs(action_names) do + local num = map_action[name] + out:write(format(" %-10s %02X %d\n", name, num, num)) + end + out:write("\n") +end + +-- Write action list buffer as a huge static C array. +local function writeactions(out, name) + local nn = #actlist + local last = actlist[nn] or 255 + actlist[nn] = nil -- Remove last byte. + if nn == 0 then nn = 1 end + out:write("static const unsigned char ", name, "[", nn, "] = {\n") + local s = " " + for n,b in ipairs(actlist) do + s = s..b.."," + if #s >= 75 then + assert(out:write(s, "\n")) + s = " " + end + end + out:write(s, last, "\n};\n\n") -- Add last byte back. +end + +------------------------------------------------------------------------------ + +-- Add byte to action list. +local function wputxb(n) + assert(n >= 0 and n <= 255 and n % 1 == 0, "byte out of range") + actlist[#actlist+1] = n +end + +-- Add action to list with optional arg. Advance buffer pos, too. +local function waction(action, a, num) + wputxb(assert(map_action[action], "bad action name `"..action.."'")) + if a then actargs[#actargs+1] = a end + if a or num then secpos = secpos + (num or 1) end +end + +-- Add call to embedded DynASM C code. +local function wcall(func, args) + wline(format("dasm_%s(Dst, %s);", func, concat(args, ", ")), true) +end + +-- Delete duplicate action list chunks. A tad slow, but so what. +local function dedupechunk(offset) + local al, as = actlist, actstr + local chunk = char(unpack(al, offset+1, #al)) + local orig = find(as, chunk, 1, true) + if orig then + actargs[1] = orig-1 -- Replace with original offset. + for i=offset+1,#al do al[i] = nil end -- Kill dupe. + else + actstr = as..chunk + end +end + +-- Flush action list (intervening C code or buffer pos overflow). +local function wflush(term) + local offset = actargs[1] + if #actlist == offset then return end -- Nothing to flush. + if not term then waction("STOP") end -- Terminate action list. + dedupechunk(offset) + wcall("put", actargs) -- Add call to dasm_put(). + actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put(). + secpos = 1 -- The actionlist offset occupies a buffer position, too. +end + +-- Put escaped byte. +local function wputb(n) + if n >= actfirst then waction("ESC") end -- Need to escape byte. + wputxb(n) +end + +------------------------------------------------------------------------------ + +-- Global label name -> global label number. With auto assignment on 1st use. +local next_global = 10 +local map_global = setmetatable({}, { __index = function(t, name) + if not match(name, "^[%a_][%w_@]*$") then werror("bad global label") end + local n = next_global + if n > 246 then werror("too many global labels") end + next_global = n + 1 + t[name] = n + return n +end}) + +-- Dump global labels. +local function dumpglobals(out, lvl) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("Global labels:\n") + for i=10,next_global-1 do + out:write(format(" %s\n", t[i])) + end + out:write("\n") +end + +-- Write global label enum. +local function writeglobals(out, prefix) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("enum {\n") + for i=10,next_global-1 do + out:write(" ", prefix, gsub(t[i], "@.*", ""), ",\n") + end + out:write(" ", prefix, "_MAX\n};\n") +end + +-- Write global label names. +local function writeglobalnames(out, name) + local t = {} + for name, n in pairs(map_global) do t[n] = name end + out:write("static const char *const ", name, "[] = {\n") + for i=10,next_global-1 do + out:write(" \"", t[i], "\",\n") + end + out:write(" (const char *)0\n};\n") +end + +------------------------------------------------------------------------------ + +-- Extern label name -> extern label number. With auto assignment on 1st use. +local next_extern = -1 +local map_extern = setmetatable({}, { __index = function(t, name) + -- No restrictions on the name for now. + local n = next_extern + if n < -256 then werror("too many extern labels") end + next_extern = n - 1 + t[name] = n + return n +end}) + +-- Dump extern labels. +local function dumpexterns(out, lvl) + local t = {} + for name, n in pairs(map_extern) do t[-n] = name end + out:write("Extern labels:\n") + for i=1,-next_extern-1 do + out:write(format(" %s\n", t[i])) + end + out:write("\n") +end + +-- Write extern label names. +local function writeexternnames(out, name) + local t = {} + for name, n in pairs(map_extern) do t[-n] = name end + out:write("static const char *const ", name, "[] = {\n") + for i=1,-next_extern-1 do + out:write(" \"", t[i], "\",\n") + end + out:write(" (const char *)0\n};\n") +end + +------------------------------------------------------------------------------ + +-- Arch-specific maps. +local map_archdef = {} -- Ext. register name -> int. name. +local map_reg_rev = {} -- Int. register name -> ext. name. +local map_reg_num = {} -- Int. register name -> register number. +local map_reg_opsize = {} -- Int. register name -> operand size. +local map_reg_valid_base = {} -- Int. register name -> valid base register? +local map_reg_valid_index = {} -- Int. register name -> valid index register? +local map_reg_needrex = {} -- Int. register name -> need rex vs. no rex. +local reg_list = {} -- Canonical list of int. register names. + +local map_type = {} -- Type name -> { ctype, reg } +local ctypenum = 0 -- Type number (for _PTx macros). + +local addrsize = x64 and "q" or "d" -- Size for address operands. + +-- Helper functions to fill register maps. +local function mkrmap(sz, cl, names) + local cname = format("@%s", sz) + reg_list[#reg_list+1] = cname + map_archdef[cl] = cname + map_reg_rev[cname] = cl + map_reg_num[cname] = -1 + map_reg_opsize[cname] = sz + if sz == addrsize or sz == "d" then + map_reg_valid_base[cname] = true + map_reg_valid_index[cname] = true + end + if names then + for n,name in ipairs(names) do + local iname = format("@%s%x", sz, n-1) + reg_list[#reg_list+1] = iname + map_archdef[name] = iname + map_reg_rev[iname] = name + map_reg_num[iname] = n-1 + map_reg_opsize[iname] = sz + if sz == "b" and n > 4 then map_reg_needrex[iname] = false end + if sz == addrsize or sz == "d" then + map_reg_valid_base[iname] = true + map_reg_valid_index[iname] = true + end + end + end + for i=0,(x64 and sz ~= "f") and 15 or 7 do + local needrex = sz == "b" and i > 3 + local iname = format("@%s%x%s", sz, i, needrex and "R" or "") + if needrex then map_reg_needrex[iname] = true end + local name + if sz == "o" then name = format("xmm%d", i) + elseif sz == "f" then name = format("st%d", i) + else name = format("r%d%s", i, sz == addrsize and "" or sz) end + map_archdef[name] = iname + if not map_reg_rev[iname] then + reg_list[#reg_list+1] = iname + map_reg_rev[iname] = name + map_reg_num[iname] = i + map_reg_opsize[iname] = sz + if sz == addrsize or sz == "d" then + map_reg_valid_base[iname] = true + map_reg_valid_index[iname] = true + end + end + end + reg_list[#reg_list+1] = "" +end + +-- Integer registers (qword, dword, word and byte sized). +if x64 then + mkrmap("q", "Rq", {"rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi"}) +end +mkrmap("d", "Rd", {"eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi"}) +mkrmap("w", "Rw", {"ax", "cx", "dx", "bx", "sp", "bp", "si", "di"}) +mkrmap("b", "Rb", {"al", "cl", "dl", "bl", "ah", "ch", "dh", "bh"}) +map_reg_valid_index[map_archdef.esp] = false +if x64 then map_reg_valid_index[map_archdef.rsp] = false end +map_archdef["Ra"] = "@"..addrsize + +-- FP registers (internally tword sized, but use "f" as operand size). +mkrmap("f", "Rf") + +-- SSE registers (oword sized, but qword and dword accessible). +mkrmap("o", "xmm") + +-- Operand size prefixes to codes. +local map_opsize = { + byte = "b", word = "w", dword = "d", qword = "q", oword = "o", tword = "t", + aword = addrsize, +} + +-- Operand size code to number. +local map_opsizenum = { + b = 1, w = 2, d = 4, q = 8, o = 16, t = 10, +} + +-- Operand size code to name. +local map_opsizename = { + b = "byte", w = "word", d = "dword", q = "qword", o = "oword", t = "tword", + f = "fpword", +} + +-- Valid index register scale factors. +local map_xsc = { + ["1"] = 0, ["2"] = 1, ["4"] = 2, ["8"] = 3, +} + +-- Condition codes. +local map_cc = { + o = 0, no = 1, b = 2, nb = 3, e = 4, ne = 5, be = 6, nbe = 7, + s = 8, ns = 9, p = 10, np = 11, l = 12, nl = 13, le = 14, nle = 15, + c = 2, nae = 2, nc = 3, ae = 3, z = 4, nz = 5, na = 6, a = 7, + pe = 10, po = 11, nge = 12, ge = 13, ng = 14, g = 15, +} + + +-- Reverse defines for registers. +function _M.revdef(s) + return gsub(s, "@%w+", map_reg_rev) +end + +-- Dump register names and numbers +local function dumpregs(out) + out:write("Register names, sizes and internal numbers:\n") + for _,reg in ipairs(reg_list) do + if reg == "" then + out:write("\n") + else + local name = map_reg_rev[reg] + local num = map_reg_num[reg] + local opsize = map_opsizename[map_reg_opsize[reg]] + out:write(format(" %-5s %-8s %s\n", name, opsize, + num < 0 and "(variable)" or num)) + end + end +end + +------------------------------------------------------------------------------ + +-- Put action for label arg (IMM_LG, IMM_PC, REL_LG, REL_PC). +local function wputlabel(aprefix, imm, num) + if type(imm) == "number" then + if imm < 0 then + waction("EXTERN") + wputxb(aprefix == "IMM_" and 0 or 1) + imm = -imm-1 + else + waction(aprefix.."LG", nil, num); + end + wputxb(imm) + else + waction(aprefix.."PC", imm, num) + end +end + +-- Put signed byte or arg. +local function wputsbarg(n) + if type(n) == "number" then + if n < -128 or n > 127 then + werror("signed immediate byte out of range") + end + if n < 0 then n = n + 256 end + wputb(n) + else waction("IMM_S", n) end +end + +-- Put unsigned byte or arg. +local function wputbarg(n) + if type(n) == "number" then + if n < 0 or n > 255 then + werror("unsigned immediate byte out of range") + end + wputb(n) + else waction("IMM_B", n) end +end + +-- Put unsigned word or arg. +local function wputwarg(n) + if type(n) == "number" then + if shr(n, 16) ~= 0 then + werror("unsigned immediate word out of range") + end + wputb(band(n, 255)); wputb(shr(n, 8)); + else waction("IMM_W", n) end +end + +-- Put signed or unsigned dword or arg. +local function wputdarg(n) + local tn = type(n) + if tn == "number" then + wputb(band(n, 255)) + wputb(band(shr(n, 8), 255)) + wputb(band(shr(n, 16), 255)) + wputb(shr(n, 24)) + elseif tn == "table" then + wputlabel("IMM_", n[1], 1) + else + waction("IMM_D", n) + end +end + +-- Put operand-size dependent number or arg (defaults to dword). +local function wputszarg(sz, n) + if not sz or sz == "d" or sz == "q" then wputdarg(n) + elseif sz == "w" then wputwarg(n) + elseif sz == "b" then wputbarg(n) + elseif sz == "s" then wputsbarg(n) + else werror("bad operand size") end +end + +-- Put multi-byte opcode with operand-size dependent modifications. +local function wputop(sz, op, rex) + local r + if rex ~= 0 and not x64 then werror("bad operand size") end + if sz == "w" then wputb(102) end + -- Needs >32 bit numbers, but only for crc32 eax, word [ebx] + if op >= 4294967296 then r = op%4294967296 wputb((op-r)/4294967296) op = r end + if op >= 16777216 then wputb(shr(op, 24)); op = band(op, 0xffffff) end + if op >= 65536 then + if rex ~= 0 then + local opc3 = band(op, 0xffff00) + if opc3 == 0x0f3a00 or opc3 == 0x0f3800 then + wputb(64 + band(rex, 15)); rex = 0 + end + end + wputb(shr(op, 16)); op = band(op, 0xffff) + end + if op >= 256 then + local b = shr(op, 8) + if b == 15 and rex ~= 0 then wputb(64 + band(rex, 15)); rex = 0 end + wputb(b) + op = band(op, 255) + end + if rex ~= 0 then wputb(64 + band(rex, 15)) end + if sz == "b" then op = op - 1 end + wputb(op) +end + +-- Put ModRM or SIB formatted byte. +local function wputmodrm(m, s, rm, vs, vrm) + assert(m < 4 and s < 16 and rm < 16, "bad modrm operands") + wputb(shl(m, 6) + shl(band(s, 7), 3) + band(rm, 7)) +end + +-- Put ModRM/SIB plus optional displacement. +local function wputmrmsib(t, imark, s, vsreg) + local vreg, vxreg + local reg, xreg = t.reg, t.xreg + if reg and reg < 0 then reg = 0; vreg = t.vreg end + if xreg and xreg < 0 then xreg = 0; vxreg = t.vxreg end + if s < 0 then s = 0 end + + -- Register mode. + if sub(t.mode, 1, 1) == "r" then + wputmodrm(3, s, reg) + if vsreg then waction("VREG", vsreg); wputxb(2) end + if vreg then waction("VREG", vreg); wputxb(0) end + return + end + + local disp = t.disp + local tdisp = type(disp) + -- No base register? + if not reg then + local riprel = false + if xreg then + -- Indexed mode with index register only. + -- [xreg*xsc+disp] -> (0, s, esp) (xsc, xreg, ebp) + wputmodrm(0, s, 4) + if imark == "I" then waction("MARK") end + if vsreg then waction("VREG", vsreg); wputxb(2) end + wputmodrm(t.xsc, xreg, 5) + if vxreg then waction("VREG", vxreg); wputxb(3) end + else + -- Pure 32 bit displacement. + if x64 and tdisp ~= "table" then + wputmodrm(0, s, 4) -- [disp] -> (0, s, esp) (0, esp, ebp) + if imark == "I" then waction("MARK") end + wputmodrm(0, 4, 5) + else + riprel = x64 + wputmodrm(0, s, 5) -- [disp|rip-label] -> (0, s, ebp) + if imark == "I" then waction("MARK") end + end + if vsreg then waction("VREG", vsreg); wputxb(2) end + end + if riprel then -- Emit rip-relative displacement. + if match("UWSiI", imark) then + werror("NYI: rip-relative displacement followed by immediate") + end + -- The previous byte in the action buffer cannot be 0xe9 or 0x80-0x8f. + wputlabel("REL_", disp[1], 2) + else + wputdarg(disp) + end + return + end + + local m + if tdisp == "number" then -- Check displacement size at assembly time. + if disp == 0 and band(reg, 7) ~= 5 then -- [ebp] -> [ebp+0] (in SIB, too) + if not vreg then m = 0 end -- Force DISP to allow [Rd(5)] -> [ebp+0] + elseif disp >= -128 and disp <= 127 then m = 1 + else m = 2 end + elseif tdisp == "table" then + m = 2 + end + + -- Index register present or esp as base register: need SIB encoding. + if xreg or band(reg, 7) == 4 then + wputmodrm(m or 2, s, 4) -- ModRM. + if m == nil or imark == "I" then waction("MARK") end + if vsreg then waction("VREG", vsreg); wputxb(2) end + wputmodrm(t.xsc or 0, xreg or 4, reg) -- SIB. + if vxreg then waction("VREG", vxreg); wputxb(3) end + if vreg then waction("VREG", vreg); wputxb(1) end + else + wputmodrm(m or 2, s, reg) -- ModRM. + if (imark == "I" and (m == 1 or m == 2)) or + (m == nil and (vsreg or vreg)) then waction("MARK") end + if vsreg then waction("VREG", vsreg); wputxb(2) end + if vreg then waction("VREG", vreg); wputxb(1) end + end + + -- Put displacement. + if m == 1 then wputsbarg(disp) + elseif m == 2 then wputdarg(disp) + elseif m == nil then waction("DISP", disp) end +end + +------------------------------------------------------------------------------ + +-- Return human-readable operand mode string. +local function opmodestr(op, args) + local m = {} + for i=1,#args do + local a = args[i] + m[#m+1] = sub(a.mode, 1, 1)..(a.opsize or "?") + end + return op.." "..concat(m, ",") +end + +-- Convert number to valid integer or nil. +local function toint(expr) + local n = tonumber(expr) + if n then + if n % 1 ~= 0 or n < -2147483648 or n > 4294967295 then + werror("bad integer number `"..expr.."'") + end + return n + end +end + +-- Parse immediate expression. +local function immexpr(expr) + -- &expr (pointer) + if sub(expr, 1, 1) == "&" then + return "iPJ", format("(ptrdiff_t)(%s)", sub(expr,2)) + end + + local prefix = sub(expr, 1, 2) + -- =>expr (pc label reference) + if prefix == "=>" then + return "iJ", sub(expr, 3) + end + -- ->name (global label reference) + if prefix == "->" then + return "iJ", map_global[sub(expr, 3)] + end + + -- [<>][1-9] (local label reference) + local dir, lnum = match(expr, "^([<>])([1-9])$") + if dir then -- Fwd: 247-255, Bkwd: 1-9. + return "iJ", lnum + (dir == ">" and 246 or 0) + end + + local extname = match(expr, "^extern%s+(%S+)$") + if extname then + return "iJ", map_extern[extname] + end + + -- expr (interpreted as immediate) + return "iI", expr +end + +-- Parse displacement expression: +-num, +-expr, +-opsize*num +local function dispexpr(expr) + local disp = expr == "" and 0 or toint(expr) + if disp then return disp end + local c, dispt = match(expr, "^([+-])%s*(.+)$") + if c == "+" then + expr = dispt + elseif not c then + werror("bad displacement expression `"..expr.."'") + end + local opsize, tailops = match(dispt, "^(%w+)%s*%*%s*(.+)$") + local ops, imm = map_opsize[opsize], toint(tailops) + if ops and imm then + if c == "-" then imm = -imm end + return imm*map_opsizenum[ops] + end + local mode, iexpr = immexpr(dispt) + if mode == "iJ" then + if c == "-" then werror("cannot invert label reference") end + return { iexpr } + end + return expr -- Need to return original signed expression. +end + +-- Parse register or type expression. +local function rtexpr(expr) + if not expr then return end + local tname, ovreg = match(expr, "^([%w_]+):(@[%w_]+)$") + local tp = map_type[tname or expr] + if tp then + local reg = ovreg or tp.reg + local rnum = map_reg_num[reg] + if not rnum then + werror("type `"..(tname or expr).."' needs a register override") + end + if not map_reg_valid_base[reg] then + werror("bad base register override `"..(map_reg_rev[reg] or reg).."'") + end + return reg, rnum, tp + end + return expr, map_reg_num[expr] +end + +-- Parse operand and return { mode, opsize, reg, xreg, xsc, disp, imm }. +local function parseoperand(param) + local t = {} + + local expr = param + local opsize, tailops = match(param, "^(%w+)%s*(.+)$") + if opsize then + t.opsize = map_opsize[opsize] + if t.opsize then expr = tailops end + end + + local br = match(expr, "^%[%s*(.-)%s*%]$") + repeat + if br then + t.mode = "xm" + + -- [disp] + t.disp = toint(br) + if t.disp then + t.mode = x64 and "xm" or "xmO" + break + end + + -- [reg...] + local tp + local reg, tailr = match(br, "^([@%w_:]+)%s*(.*)$") + reg, t.reg, tp = rtexpr(reg) + if not t.reg then + -- [expr] + t.mode = x64 and "xm" or "xmO" + t.disp = dispexpr("+"..br) + break + end + + if t.reg == -1 then + t.vreg, tailr = match(tailr, "^(%b())(.*)$") + if not t.vreg then werror("bad variable register expression") end + end + + -- [xreg*xsc] or [xreg*xsc+-disp] or [xreg*xsc+-expr] + local xsc, tailsc = match(tailr, "^%*%s*([1248])%s*(.*)$") + if xsc then + if not map_reg_valid_index[reg] then + werror("bad index register `"..map_reg_rev[reg].."'") + end + t.xsc = map_xsc[xsc] + t.xreg = t.reg + t.vxreg = t.vreg + t.reg = nil + t.vreg = nil + t.disp = dispexpr(tailsc) + break + end + if not map_reg_valid_base[reg] then + werror("bad base register `"..map_reg_rev[reg].."'") + end + + -- [reg] or [reg+-disp] + t.disp = toint(tailr) or (tailr == "" and 0) + if t.disp then break end + + -- [reg+xreg...] + local xreg, tailx = match(tailr, "^+%s*([@%w_:]+)%s*(.*)$") + xreg, t.xreg, tp = rtexpr(xreg) + if not t.xreg then + -- [reg+-expr] + t.disp = dispexpr(tailr) + break + end + if not map_reg_valid_index[xreg] then + werror("bad index register `"..map_reg_rev[xreg].."'") + end + + if t.xreg == -1 then + t.vxreg, tailx = match(tailx, "^(%b())(.*)$") + if not t.vxreg then werror("bad variable register expression") end + end + + -- [reg+xreg*xsc...] + local xsc, tailsc = match(tailx, "^%*%s*([1248])%s*(.*)$") + if xsc then + t.xsc = map_xsc[xsc] + tailx = tailsc + end + + -- [...] or [...+-disp] or [...+-expr] + t.disp = dispexpr(tailx) + else + -- imm or opsize*imm + local imm = toint(expr) + if not imm and sub(expr, 1, 1) == "*" and t.opsize then + imm = toint(sub(expr, 2)) + if imm then + imm = imm * map_opsizenum[t.opsize] + t.opsize = nil + end + end + if imm then + if t.opsize then werror("bad operand size override") end + local m = "i" + if imm == 1 then m = m.."1" end + if imm >= 4294967168 and imm <= 4294967295 then imm = imm-4294967296 end + if imm >= -128 and imm <= 127 then m = m.."S" end + t.imm = imm + t.mode = m + break + end + + local tp + local reg, tailr = match(expr, "^([@%w_:]+)%s*(.*)$") + reg, t.reg, tp = rtexpr(reg) + if t.reg then + if t.reg == -1 then + t.vreg, tailr = match(tailr, "^(%b())(.*)$") + if not t.vreg then werror("bad variable register expression") end + end + -- reg + if tailr == "" then + if t.opsize then werror("bad operand size override") end + t.opsize = map_reg_opsize[reg] + if t.opsize == "f" then + t.mode = t.reg == 0 and "fF" or "f" + else + if reg == "@w4" or (x64 and reg == "@d4") then + wwarn("bad idea, try again with `"..(x64 and "rsp'" or "esp'")) + end + t.mode = t.reg == 0 and "rmR" or (reg == "@b1" and "rmC" or "rm") + end + t.needrex = map_reg_needrex[reg] + break + end + + -- type[idx], type[idx].field, type->field -> [reg+offset_expr] + if not tp then werror("bad operand `"..param.."'") end + t.mode = "xm" + t.disp = format(tp.ctypefmt, tailr) + else + t.mode, t.imm = immexpr(expr) + if sub(t.mode, -1) == "J" then + if t.opsize and t.opsize ~= addrsize then + werror("bad operand size override") + end + t.opsize = addrsize + end + end + end + until true + return t +end + +------------------------------------------------------------------------------ +-- x86 Template String Description +-- =============================== +-- +-- Each template string is a list of [match:]pattern pairs, +-- separated by "|". The first match wins. No match means a +-- bad or unsupported combination of operand modes or sizes. +-- +-- The match part and the ":" is omitted if the operation has +-- no operands. Otherwise the first N characters are matched +-- against the mode strings of each of the N operands. +-- +-- The mode string for each operand type is (see parseoperand()): +-- Integer register: "rm", +"R" for eax, ax, al, +"C" for cl +-- FP register: "f", +"F" for st0 +-- Index operand: "xm", +"O" for [disp] (pure offset) +-- Immediate: "i", +"S" for signed 8 bit, +"1" for 1, +-- +"I" for arg, +"P" for pointer +-- Any: +"J" for valid jump targets +-- +-- So a match character "m" (mixed) matches both an integer register +-- and an index operand (to be encoded with the ModRM/SIB scheme). +-- But "r" matches only a register and "x" only an index operand +-- (e.g. for FP memory access operations). +-- +-- The operand size match string starts right after the mode match +-- characters and ends before the ":". "dwb" or "qdwb" is assumed, if empty. +-- The effective data size of the operation is matched against this list. +-- +-- If only the regular "b", "w", "d", "q", "t" operand sizes are +-- present, then all operands must be the same size. Unspecified sizes +-- are ignored, but at least one operand must have a size or the pattern +-- won't match (use the "byte", "word", "dword", "qword", "tword" +-- operand size overrides. E.g.: mov dword [eax], 1). +-- +-- If the list has a "1" or "2" prefix, the operand size is taken +-- from the respective operand and any other operand sizes are ignored. +-- If the list contains only ".", all operand sizes are ignored. +-- If the list has a "/" prefix, the concatenated (mixed) operand sizes +-- are compared to the match. +-- +-- E.g. "rrdw" matches for either two dword registers or two word +-- registers. "Fx2dq" matches an st0 operand plus an index operand +-- pointing to a dword (float) or qword (double). +-- +-- Every character after the ":" is part of the pattern string: +-- Hex chars are accumulated to form the opcode (left to right). +-- "n" disables the standard opcode mods +-- (otherwise: -1 for "b", o16 prefix for "w", rex.w for "q") +-- "X" Force REX.W. +-- "r"/"R" adds the reg. number from the 1st/2nd operand to the opcode. +-- "m"/"M" generates ModRM/SIB from the 1st/2nd operand. +-- The spare 3 bits are either filled with the last hex digit or +-- the result from a previous "r"/"R". The opcode is restored. +-- +-- All of the following characters force a flush of the opcode: +-- "o"/"O" stores a pure 32 bit disp (offset) from the 1st/2nd operand. +-- "S" stores a signed 8 bit immediate from the last operand. +-- "U" stores an unsigned 8 bit immediate from the last operand. +-- "W" stores an unsigned 16 bit immediate from the last operand. +-- "i" stores an operand sized immediate from the last operand. +-- "I" dito, but generates an action code to optionally modify +-- the opcode (+2) for a signed 8 bit immediate. +-- "J" generates one of the REL action codes from the last operand. +-- +------------------------------------------------------------------------------ + +-- Template strings for x86 instructions. Ordered by first opcode byte. +-- Unimplemented opcodes (deliberate omissions) are marked with *. +local map_op = { + -- 00-05: add... + -- 06: *push es + -- 07: *pop es + -- 08-0D: or... + -- 0E: *push cs + -- 0F: two byte opcode prefix + -- 10-15: adc... + -- 16: *push ss + -- 17: *pop ss + -- 18-1D: sbb... + -- 1E: *push ds + -- 1F: *pop ds + -- 20-25: and... + es_0 = "26", + -- 27: *daa + -- 28-2D: sub... + cs_0 = "2E", + -- 2F: *das + -- 30-35: xor... + ss_0 = "36", + -- 37: *aaa + -- 38-3D: cmp... + ds_0 = "3E", + -- 3F: *aas + inc_1 = x64 and "m:FF0m" or "rdw:40r|m:FF0m", + dec_1 = x64 and "m:FF1m" or "rdw:48r|m:FF1m", + push_1 = (x64 and "rq:n50r|rw:50r|mq:nFF6m|mw:FF6m" or + "rdw:50r|mdw:FF6m").."|S.:6AS|ib:n6Ai|i.:68i", + pop_1 = x64 and "rq:n58r|rw:58r|mq:n8F0m|mw:8F0m" or "rdw:58r|mdw:8F0m", + -- 60: *pusha, *pushad, *pushaw + -- 61: *popa, *popad, *popaw + -- 62: *bound rdw,x + -- 63: x86: *arpl mw,rw + movsxd_2 = x64 and "rm/qd:63rM", + fs_0 = "64", + gs_0 = "65", + o16_0 = "66", + a16_0 = not x64 and "67" or nil, + a32_0 = x64 and "67", + -- 68: push idw + -- 69: imul rdw,mdw,idw + -- 6A: push ib + -- 6B: imul rdw,mdw,S + -- 6C: *insb + -- 6D: *insd, *insw + -- 6E: *outsb + -- 6F: *outsd, *outsw + -- 70-7F: jcc lb + -- 80: add... mb,i + -- 81: add... mdw,i + -- 82: *undefined + -- 83: add... mdw,S + test_2 = "mr:85Rm|rm:85rM|Ri:A9ri|mi:F70mi", + -- 86: xchg rb,mb + -- 87: xchg rdw,mdw + -- 88: mov mb,r + -- 89: mov mdw,r + -- 8A: mov r,mb + -- 8B: mov r,mdw + -- 8C: *mov mdw,seg + lea_2 = "rx1dq:8DrM", + -- 8E: *mov seg,mdw + -- 8F: pop mdw + nop_0 = "90", + xchg_2 = "Rrqdw:90R|rRqdw:90r|rm:87rM|mr:87Rm", + cbw_0 = "6698", + cwde_0 = "98", + cdqe_0 = "4898", + cwd_0 = "6699", + cdq_0 = "99", + cqo_0 = "4899", + -- 9A: *call iw:idw + wait_0 = "9B", + fwait_0 = "9B", + pushf_0 = "9C", + pushfd_0 = not x64 and "9C", + pushfq_0 = x64 and "9C", + popf_0 = "9D", + popfd_0 = not x64 and "9D", + popfq_0 = x64 and "9D", + sahf_0 = "9E", + lahf_0 = "9F", + mov_2 = "OR:A3o|RO:A1O|mr:89Rm|rm:8BrM|rib:nB0ri|ridw:B8ri|mi:C70mi", + movsb_0 = "A4", + movsw_0 = "66A5", + movsd_0 = "A5", + cmpsb_0 = "A6", + cmpsw_0 = "66A7", + cmpsd_0 = "A7", + -- A8: test Rb,i + -- A9: test Rdw,i + stosb_0 = "AA", + stosw_0 = "66AB", + stosd_0 = "AB", + lodsb_0 = "AC", + lodsw_0 = "66AD", + lodsd_0 = "AD", + scasb_0 = "AE", + scasw_0 = "66AF", + scasd_0 = "AF", + -- B0-B7: mov rb,i + -- B8-BF: mov rdw,i + -- C0: rol... mb,i + -- C1: rol... mdw,i + ret_1 = "i.:nC2W", + ret_0 = "C3", + -- C4: *les rdw,mq + -- C5: *lds rdw,mq + -- C6: mov mb,i + -- C7: mov mdw,i + -- C8: *enter iw,ib + leave_0 = "C9", + -- CA: *retf iw + -- CB: *retf + int3_0 = "CC", + int_1 = "i.:nCDU", + into_0 = "CE", + -- CF: *iret + -- D0: rol... mb,1 + -- D1: rol... mdw,1 + -- D2: rol... mb,cl + -- D3: rol... mb,cl + -- D4: *aam ib + -- D5: *aad ib + -- D6: *salc + -- D7: *xlat + -- D8-DF: floating point ops + -- E0: *loopne + -- E1: *loope + -- E2: *loop + -- E3: *jcxz, *jecxz + -- E4: *in Rb,ib + -- E5: *in Rdw,ib + -- E6: *out ib,Rb + -- E7: *out ib,Rdw + call_1 = x64 and "mq:nFF2m|J.:E8nJ" or "md:FF2m|J.:E8J", + jmp_1 = x64 and "mq:nFF4m|J.:E9nJ" or "md:FF4m|J.:E9J", -- short: EB + -- EA: *jmp iw:idw + -- EB: jmp ib + -- EC: *in Rb,dx + -- ED: *in Rdw,dx + -- EE: *out dx,Rb + -- EF: *out dx,Rdw + lock_0 = "F0", + int1_0 = "F1", + repne_0 = "F2", + repnz_0 = "F2", + rep_0 = "F3", + repe_0 = "F3", + repz_0 = "F3", + -- F4: *hlt + cmc_0 = "F5", + -- F6: test... mb,i; div... mb + -- F7: test... mdw,i; div... mdw + clc_0 = "F8", + stc_0 = "F9", + -- FA: *cli + cld_0 = "FC", + std_0 = "FD", + -- FE: inc... mb + -- FF: inc... mdw + + -- misc ops + not_1 = "m:F72m", + neg_1 = "m:F73m", + mul_1 = "m:F74m", + imul_1 = "m:F75m", + div_1 = "m:F76m", + idiv_1 = "m:F77m", + + imul_2 = "rmqdw:0FAFrM|rIqdw:69rmI|rSqdw:6BrmS|riqdw:69rmi", + imul_3 = "rmIqdw:69rMI|rmSqdw:6BrMS|rmiqdw:69rMi", + + movzx_2 = "rm/db:0FB6rM|rm/qb:|rm/wb:0FB6rM|rm/dw:0FB7rM|rm/qw:", + movsx_2 = "rm/db:0FBErM|rm/qb:|rm/wb:0FBErM|rm/dw:0FBFrM|rm/qw:", + + bswap_1 = "rqd:0FC8r", + bsf_2 = "rmqdw:0FBCrM", + bsr_2 = "rmqdw:0FBDrM", + bt_2 = "mrqdw:0FA3Rm|miqdw:0FBA4mU", + btc_2 = "mrqdw:0FBBRm|miqdw:0FBA7mU", + btr_2 = "mrqdw:0FB3Rm|miqdw:0FBA6mU", + bts_2 = "mrqdw:0FABRm|miqdw:0FBA5mU", + + shld_3 = "mriqdw:0FA4RmU|mrCqdw:0FA5Rm", + shrd_3 = "mriqdw:0FACRmU|mrCqdw:0FADRm", + + rdtsc_0 = "0F31", -- P1+ + cpuid_0 = "0FA2", -- P1+ + + -- floating point ops + fst_1 = "ff:DDD0r|xd:D92m|xq:nDD2m", + fstp_1 = "ff:DDD8r|xd:D93m|xq:nDD3m|xt:DB7m", + fld_1 = "ff:D9C0r|xd:D90m|xq:nDD0m|xt:DB5m", + + fpop_0 = "DDD8", -- Alias for fstp st0. + + fist_1 = "xw:nDF2m|xd:DB2m", + fistp_1 = "xw:nDF3m|xd:DB3m|xq:nDF7m", + fild_1 = "xw:nDF0m|xd:DB0m|xq:nDF5m", + + fxch_0 = "D9C9", + fxch_1 = "ff:D9C8r", + fxch_2 = "fFf:D9C8r|Fff:D9C8R", + + fucom_1 = "ff:DDE0r", + fucom_2 = "Fff:DDE0R", + fucomp_1 = "ff:DDE8r", + fucomp_2 = "Fff:DDE8R", + fucomi_1 = "ff:DBE8r", -- P6+ + fucomi_2 = "Fff:DBE8R", -- P6+ + fucomip_1 = "ff:DFE8r", -- P6+ + fucomip_2 = "Fff:DFE8R", -- P6+ + fcomi_1 = "ff:DBF0r", -- P6+ + fcomi_2 = "Fff:DBF0R", -- P6+ + fcomip_1 = "ff:DFF0r", -- P6+ + fcomip_2 = "Fff:DFF0R", -- P6+ + fucompp_0 = "DAE9", + fcompp_0 = "DED9", + + fldenv_1 = "x.:D94m", + fnstenv_1 = "x.:D96m", + fstenv_1 = "x.:9BD96m", + fldcw_1 = "xw:nD95m", + fstcw_1 = "xw:n9BD97m", + fnstcw_1 = "xw:nD97m", + fstsw_1 = "Rw:n9BDFE0|xw:n9BDD7m", + fnstsw_1 = "Rw:nDFE0|xw:nDD7m", + fclex_0 = "9BDBE2", + fnclex_0 = "DBE2", + + fnop_0 = "D9D0", + -- D9D1-D9DF: unassigned + + fchs_0 = "D9E0", + fabs_0 = "D9E1", + -- D9E2: unassigned + -- D9E3: unassigned + ftst_0 = "D9E4", + fxam_0 = "D9E5", + -- D9E6: unassigned + -- D9E7: unassigned + fld1_0 = "D9E8", + fldl2t_0 = "D9E9", + fldl2e_0 = "D9EA", + fldpi_0 = "D9EB", + fldlg2_0 = "D9EC", + fldln2_0 = "D9ED", + fldz_0 = "D9EE", + -- D9EF: unassigned + + f2xm1_0 = "D9F0", + fyl2x_0 = "D9F1", + fptan_0 = "D9F2", + fpatan_0 = "D9F3", + fxtract_0 = "D9F4", + fprem1_0 = "D9F5", + fdecstp_0 = "D9F6", + fincstp_0 = "D9F7", + fprem_0 = "D9F8", + fyl2xp1_0 = "D9F9", + fsqrt_0 = "D9FA", + fsincos_0 = "D9FB", + frndint_0 = "D9FC", + fscale_0 = "D9FD", + fsin_0 = "D9FE", + fcos_0 = "D9FF", + + -- SSE, SSE2 + andnpd_2 = "rmo:660F55rM", + andnps_2 = "rmo:0F55rM", + andpd_2 = "rmo:660F54rM", + andps_2 = "rmo:0F54rM", + clflush_1 = "x.:0FAE7m", + cmppd_3 = "rmio:660FC2rMU", + cmpps_3 = "rmio:0FC2rMU", + cmpsd_3 = "rrio:F20FC2rMU|rxi/oq:", + cmpss_3 = "rrio:F30FC2rMU|rxi/od:", + comisd_2 = "rro:660F2FrM|rx/oq:", + comiss_2 = "rro:0F2FrM|rx/od:", + cvtdq2pd_2 = "rro:F30FE6rM|rx/oq:", + cvtdq2ps_2 = "rmo:0F5BrM", + cvtpd2dq_2 = "rmo:F20FE6rM", + cvtpd2ps_2 = "rmo:660F5ArM", + cvtpi2pd_2 = "rx/oq:660F2ArM", + cvtpi2ps_2 = "rx/oq:0F2ArM", + cvtps2dq_2 = "rmo:660F5BrM", + cvtps2pd_2 = "rro:0F5ArM|rx/oq:", + cvtsd2si_2 = "rr/do:F20F2DrM|rr/qo:|rx/dq:|rxq:", + cvtsd2ss_2 = "rro:F20F5ArM|rx/oq:", + cvtsi2sd_2 = "rm/od:F20F2ArM|rm/oq:F20F2ArXM", + cvtsi2ss_2 = "rm/od:F30F2ArM|rm/oq:F30F2ArXM", + cvtss2sd_2 = "rro:F30F5ArM|rx/od:", + cvtss2si_2 = "rr/do:F20F2CrM|rr/qo:|rxd:|rx/qd:", + cvttpd2dq_2 = "rmo:660FE6rM", + cvttps2dq_2 = "rmo:F30F5BrM", + cvttsd2si_2 = "rr/do:F20F2CrM|rr/qo:|rx/dq:|rxq:", + cvttss2si_2 = "rr/do:F30F2CrM|rr/qo:|rxd:|rx/qd:", + fxsave_1 = "x.:0FAE0m", + fxrstor_1 = "x.:0FAE1m", + ldmxcsr_1 = "xd:0FAE2m", + lfence_0 = "0FAEE8", + maskmovdqu_2 = "rro:660FF7rM", + mfence_0 = "0FAEF0", + movapd_2 = "rmo:660F28rM|mro:660F29Rm", + movaps_2 = "rmo:0F28rM|mro:0F29Rm", + movd_2 = "rm/od:660F6ErM|rm/oq:660F6ErXM|mr/do:660F7ERm|mr/qo:", + movdqa_2 = "rmo:660F6FrM|mro:660F7FRm", + movdqu_2 = "rmo:F30F6FrM|mro:F30F7FRm", + movhlps_2 = "rro:0F12rM", + movhpd_2 = "rx/oq:660F16rM|xr/qo:n660F17Rm", + movhps_2 = "rx/oq:0F16rM|xr/qo:n0F17Rm", + movlhps_2 = "rro:0F16rM", + movlpd_2 = "rx/oq:660F12rM|xr/qo:n660F13Rm", + movlps_2 = "rx/oq:0F12rM|xr/qo:n0F13Rm", + movmskpd_2 = "rr/do:660F50rM", + movmskps_2 = "rr/do:0F50rM", + movntdq_2 = "xro:660FE7Rm", + movnti_2 = "xrqd:0FC3Rm", + movntpd_2 = "xro:660F2BRm", + movntps_2 = "xro:0F2BRm", + movq_2 = "rro:F30F7ErM|rx/oq:|xr/qo:n660FD6Rm", + movsd_2 = "rro:F20F10rM|rx/oq:|xr/qo:nF20F11Rm", + movss_2 = "rro:F30F10rM|rx/od:|xr/do:F30F11Rm", + movupd_2 = "rmo:660F10rM|mro:660F11Rm", + movups_2 = "rmo:0F10rM|mro:0F11Rm", + orpd_2 = "rmo:660F56rM", + orps_2 = "rmo:0F56rM", + packssdw_2 = "rmo:660F6BrM", + packsswb_2 = "rmo:660F63rM", + packuswb_2 = "rmo:660F67rM", + paddb_2 = "rmo:660FFCrM", + paddd_2 = "rmo:660FFErM", + paddq_2 = "rmo:660FD4rM", + paddsb_2 = "rmo:660FECrM", + paddsw_2 = "rmo:660FEDrM", + paddusb_2 = "rmo:660FDCrM", + paddusw_2 = "rmo:660FDDrM", + paddw_2 = "rmo:660FFDrM", + pand_2 = "rmo:660FDBrM", + pandn_2 = "rmo:660FDFrM", + pause_0 = "F390", + pavgb_2 = "rmo:660FE0rM", + pavgw_2 = "rmo:660FE3rM", + pcmpeqb_2 = "rmo:660F74rM", + pcmpeqd_2 = "rmo:660F76rM", + pcmpeqw_2 = "rmo:660F75rM", + pcmpgtb_2 = "rmo:660F64rM", + pcmpgtd_2 = "rmo:660F66rM", + pcmpgtw_2 = "rmo:660F65rM", + pextrw_3 = "rri/do:660FC5rMU|xri/wo:660F3A15nrMU", -- Mem op: SSE4.1 only. + pinsrw_3 = "rri/od:660FC4rMU|rxi/ow:", + pmaddwd_2 = "rmo:660FF5rM", + pmaxsw_2 = "rmo:660FEErM", + pmaxub_2 = "rmo:660FDErM", + pminsw_2 = "rmo:660FEArM", + pminub_2 = "rmo:660FDArM", + pmovmskb_2 = "rr/do:660FD7rM", + pmulhuw_2 = "rmo:660FE4rM", + pmulhw_2 = "rmo:660FE5rM", + pmullw_2 = "rmo:660FD5rM", + pmuludq_2 = "rmo:660FF4rM", + por_2 = "rmo:660FEBrM", + prefetchnta_1 = "xb:n0F180m", + prefetcht0_1 = "xb:n0F181m", + prefetcht1_1 = "xb:n0F182m", + prefetcht2_1 = "xb:n0F183m", + psadbw_2 = "rmo:660FF6rM", + pshufd_3 = "rmio:660F70rMU", + pshufhw_3 = "rmio:F30F70rMU", + pshuflw_3 = "rmio:F20F70rMU", + pslld_2 = "rmo:660FF2rM|rio:660F726mU", + pslldq_2 = "rio:660F737mU", + psllq_2 = "rmo:660FF3rM|rio:660F736mU", + psllw_2 = "rmo:660FF1rM|rio:660F716mU", + psrad_2 = "rmo:660FE2rM|rio:660F724mU", + psraw_2 = "rmo:660FE1rM|rio:660F714mU", + psrld_2 = "rmo:660FD2rM|rio:660F722mU", + psrldq_2 = "rio:660F733mU", + psrlq_2 = "rmo:660FD3rM|rio:660F732mU", + psrlw_2 = "rmo:660FD1rM|rio:660F712mU", + psubb_2 = "rmo:660FF8rM", + psubd_2 = "rmo:660FFArM", + psubq_2 = "rmo:660FFBrM", + psubsb_2 = "rmo:660FE8rM", + psubsw_2 = "rmo:660FE9rM", + psubusb_2 = "rmo:660FD8rM", + psubusw_2 = "rmo:660FD9rM", + psubw_2 = "rmo:660FF9rM", + punpckhbw_2 = "rmo:660F68rM", + punpckhdq_2 = "rmo:660F6ArM", + punpckhqdq_2 = "rmo:660F6DrM", + punpckhwd_2 = "rmo:660F69rM", + punpcklbw_2 = "rmo:660F60rM", + punpckldq_2 = "rmo:660F62rM", + punpcklqdq_2 = "rmo:660F6CrM", + punpcklwd_2 = "rmo:660F61rM", + pxor_2 = "rmo:660FEFrM", + rcpps_2 = "rmo:0F53rM", + rcpss_2 = "rro:F30F53rM|rx/od:", + rsqrtps_2 = "rmo:0F52rM", + rsqrtss_2 = "rmo:F30F52rM", + sfence_0 = "0FAEF8", + shufpd_3 = "rmio:660FC6rMU", + shufps_3 = "rmio:0FC6rMU", + stmxcsr_1 = "xd:0FAE3m", + ucomisd_2 = "rro:660F2ErM|rx/oq:", + ucomiss_2 = "rro:0F2ErM|rx/od:", + unpckhpd_2 = "rmo:660F15rM", + unpckhps_2 = "rmo:0F15rM", + unpcklpd_2 = "rmo:660F14rM", + unpcklps_2 = "rmo:0F14rM", + xorpd_2 = "rmo:660F57rM", + xorps_2 = "rmo:0F57rM", + + -- SSE3 ops + fisttp_1 = "xw:nDF1m|xd:DB1m|xq:nDD1m", + addsubpd_2 = "rmo:660FD0rM", + addsubps_2 = "rmo:F20FD0rM", + haddpd_2 = "rmo:660F7CrM", + haddps_2 = "rmo:F20F7CrM", + hsubpd_2 = "rmo:660F7DrM", + hsubps_2 = "rmo:F20F7DrM", + lddqu_2 = "rxo:F20FF0rM", + movddup_2 = "rmo:F20F12rM", + movshdup_2 = "rmo:F30F16rM", + movsldup_2 = "rmo:F30F12rM", + + -- SSSE3 ops + pabsb_2 = "rmo:660F381CrM", + pabsd_2 = "rmo:660F381ErM", + pabsw_2 = "rmo:660F381DrM", + palignr_3 = "rmio:660F3A0FrMU", + phaddd_2 = "rmo:660F3802rM", + phaddsw_2 = "rmo:660F3803rM", + phaddw_2 = "rmo:660F3801rM", + phsubd_2 = "rmo:660F3806rM", + phsubsw_2 = "rmo:660F3807rM", + phsubw_2 = "rmo:660F3805rM", + pmaddubsw_2 = "rmo:660F3804rM", + pmulhrsw_2 = "rmo:660F380BrM", + pshufb_2 = "rmo:660F3800rM", + psignb_2 = "rmo:660F3808rM", + psignd_2 = "rmo:660F380ArM", + psignw_2 = "rmo:660F3809rM", + + -- SSE4.1 ops + blendpd_3 = "rmio:660F3A0DrMU", + blendps_3 = "rmio:660F3A0CrMU", + blendvpd_3 = "rmRo:660F3815rM", + blendvps_3 = "rmRo:660F3814rM", + dppd_3 = "rmio:660F3A41rMU", + dpps_3 = "rmio:660F3A40rMU", + extractps_3 = "mri/do:660F3A17RmU|rri/qo:660F3A17RXmU", + insertps_3 = "rrio:660F3A41rMU|rxi/od:", + movntdqa_2 = "rmo:660F382ArM", + mpsadbw_3 = "rmio:660F3A42rMU", + packusdw_2 = "rmo:660F382BrM", + pblendvb_3 = "rmRo:660F3810rM", + pblendw_3 = "rmio:660F3A0ErMU", + pcmpeqq_2 = "rmo:660F3829rM", + pextrb_3 = "rri/do:660F3A14nRmU|rri/qo:|xri/bo:", + pextrd_3 = "mri/do:660F3A16RmU", + pextrq_3 = "mri/qo:660F3A16RmU", + -- pextrw is SSE2, mem operand is SSE4.1 only + phminposuw_2 = "rmo:660F3841rM", + pinsrb_3 = "rri/od:660F3A20nrMU|rxi/ob:", + pinsrd_3 = "rmi/od:660F3A22rMU", + pinsrq_3 = "rmi/oq:660F3A22rXMU", + pmaxsb_2 = "rmo:660F383CrM", + pmaxsd_2 = "rmo:660F383DrM", + pmaxud_2 = "rmo:660F383FrM", + pmaxuw_2 = "rmo:660F383ErM", + pminsb_2 = "rmo:660F3838rM", + pminsd_2 = "rmo:660F3839rM", + pminud_2 = "rmo:660F383BrM", + pminuw_2 = "rmo:660F383ArM", + pmovsxbd_2 = "rro:660F3821rM|rx/od:", + pmovsxbq_2 = "rro:660F3822rM|rx/ow:", + pmovsxbw_2 = "rro:660F3820rM|rx/oq:", + pmovsxdq_2 = "rro:660F3825rM|rx/oq:", + pmovsxwd_2 = "rro:660F3823rM|rx/oq:", + pmovsxwq_2 = "rro:660F3824rM|rx/od:", + pmovzxbd_2 = "rro:660F3831rM|rx/od:", + pmovzxbq_2 = "rro:660F3832rM|rx/ow:", + pmovzxbw_2 = "rro:660F3830rM|rx/oq:", + pmovzxdq_2 = "rro:660F3835rM|rx/oq:", + pmovzxwd_2 = "rro:660F3833rM|rx/oq:", + pmovzxwq_2 = "rro:660F3834rM|rx/od:", + pmuldq_2 = "rmo:660F3828rM", + pmulld_2 = "rmo:660F3840rM", + ptest_2 = "rmo:660F3817rM", + roundpd_3 = "rmio:660F3A09rMU", + roundps_3 = "rmio:660F3A08rMU", + roundsd_3 = "rrio:660F3A0BrMU|rxi/oq:", + roundss_3 = "rrio:660F3A0ArMU|rxi/od:", + + -- SSE4.2 ops + crc32_2 = "rmqd:F20F38F1rM|rm/dw:66F20F38F1rM|rm/db:F20F38F0rM|rm/qb:", + pcmpestri_3 = "rmio:660F3A61rMU", + pcmpestrm_3 = "rmio:660F3A60rMU", + pcmpgtq_2 = "rmo:660F3837rM", + pcmpistri_3 = "rmio:660F3A63rMU", + pcmpistrm_3 = "rmio:660F3A62rMU", + popcnt_2 = "rmqdw:F30FB8rM", + + -- SSE4a + extrq_2 = "rro:660F79rM", + extrq_3 = "riio:660F780mUU", + insertq_2 = "rro:F20F79rM", + insertq_4 = "rriio:F20F78rMUU", + lzcnt_2 = "rmqdw:F30FBDrM", + movntsd_2 = "xr/qo:nF20F2BRm", + movntss_2 = "xr/do:F30F2BRm", + -- popcnt is also in SSE4.2 +} + +------------------------------------------------------------------------------ + +-- Arithmetic ops. +for name,n in pairs{ add = 0, ["or"] = 1, adc = 2, sbb = 3, + ["and"] = 4, sub = 5, xor = 6, cmp = 7 } do + local n8 = shl(n, 3) + map_op[name.."_2"] = format( + "mr:%02XRm|rm:%02XrM|mI1qdw:81%XmI|mS1qdw:83%XmS|Ri1qdwb:%02Xri|mi1qdwb:81%Xmi", + 1+n8, 3+n8, n, n, 5+n8, n) +end + +-- Shift ops. +for name,n in pairs{ rol = 0, ror = 1, rcl = 2, rcr = 3, + shl = 4, shr = 5, sar = 7, sal = 4 } do + map_op[name.."_2"] = format("m1:D1%Xm|mC1qdwb:D3%Xm|mi:C1%XmU", n, n, n) +end + +-- Conditional ops. +for cc,n in pairs(map_cc) do + map_op["j"..cc.."_1"] = format("J.:n0F8%XJ", n) -- short: 7%X + map_op["set"..cc.."_1"] = format("mb:n0F9%X2m", n) + map_op["cmov"..cc.."_2"] = format("rmqdw:0F4%XrM", n) -- P6+ +end + +-- FP arithmetic ops. +for name,n in pairs{ add = 0, mul = 1, com = 2, comp = 3, + sub = 4, subr = 5, div = 6, divr = 7 } do + local nc = 0xc0 + shl(n, 3) + local nr = nc + (n < 4 and 0 or (n % 2 == 0 and 8 or -8)) + local fn = "f"..name + map_op[fn.."_1"] = format("ff:D8%02Xr|xd:D8%Xm|xq:nDC%Xm", nc, n, n) + if n == 2 or n == 3 then + map_op[fn.."_2"] = format("Fff:D8%02XR|Fx2d:D8%XM|Fx2q:nDC%XM", nc, n, n) + else + map_op[fn.."_2"] = format("Fff:D8%02XR|fFf:DC%02Xr|Fx2d:D8%XM|Fx2q:nDC%XM", nc, nr, n, n) + map_op[fn.."p_1"] = format("ff:DE%02Xr", nr) + map_op[fn.."p_2"] = format("fFf:DE%02Xr", nr) + end + map_op["fi"..name.."_1"] = format("xd:DA%Xm|xw:nDE%Xm", n, n) +end + +-- FP conditional moves. +for cc,n in pairs{ b=0, e=1, be=2, u=3, nb=4, ne=5, nbe=6, nu=7 } do + local nc = 0xdac0 + shl(band(n, 3), 3) + shl(band(n, 4), 6) + map_op["fcmov"..cc.."_1"] = format("ff:%04Xr", nc) -- P6+ + map_op["fcmov"..cc.."_2"] = format("Fff:%04XR", nc) -- P6+ +end + +-- SSE FP arithmetic ops. +for name,n in pairs{ sqrt = 1, add = 8, mul = 9, + sub = 12, min = 13, div = 14, max = 15 } do + map_op[name.."ps_2"] = format("rmo:0F5%XrM", n) + map_op[name.."ss_2"] = format("rro:F30F5%XrM|rx/od:", n) + map_op[name.."pd_2"] = format("rmo:660F5%XrM", n) + map_op[name.."sd_2"] = format("rro:F20F5%XrM|rx/oq:", n) +end + +------------------------------------------------------------------------------ + +-- Process pattern string. +local function dopattern(pat, args, sz, op, needrex) + local digit, addin + local opcode = 0 + local szov = sz + local narg = 1 + local rex = 0 + + -- Limit number of section buffer positions used by a single dasm_put(). + -- A single opcode needs a maximum of 5 positions. + if secpos+5 > maxsecpos then wflush() end + + -- Process each character. + for c in gmatch(pat.."|", ".") do + if match(c, "%x") then -- Hex digit. + digit = byte(c) - 48 + if digit > 48 then digit = digit - 39 + elseif digit > 16 then digit = digit - 7 end + opcode = opcode*16 + digit + addin = nil + elseif c == "n" then -- Disable operand size mods for opcode. + szov = nil + elseif c == "X" then -- Force REX.W. + rex = 8 + elseif c == "r" then -- Merge 1st operand regno. into opcode. + addin = args[1]; opcode = opcode + (addin.reg % 8) + if narg < 2 then narg = 2 end + elseif c == "R" then -- Merge 2nd operand regno. into opcode. + addin = args[2]; opcode = opcode + (addin.reg % 8) + narg = 3 + elseif c == "m" or c == "M" then -- Encode ModRM/SIB. + local s + if addin then + s = addin.reg + opcode = opcode - band(s, 7) -- Undo regno opcode merge. + else + s = band(opcode, 15) -- Undo last digit. + opcode = shr(opcode, 4) + end + local nn = c == "m" and 1 or 2 + local t = args[nn] + if narg <= nn then narg = nn + 1 end + if szov == "q" and rex == 0 then rex = rex + 8 end + if t.reg and t.reg > 7 then rex = rex + 1 end + if t.xreg and t.xreg > 7 then rex = rex + 2 end + if s > 7 then rex = rex + 4 end + if needrex then rex = rex + 16 end + wputop(szov, opcode, rex); opcode = nil + local imark = sub(pat, -1) -- Force a mark (ugly). + -- Put ModRM/SIB with regno/last digit as spare. + wputmrmsib(t, imark, s, addin and addin.vreg) + addin = nil + else + if opcode then -- Flush opcode. + if szov == "q" and rex == 0 then rex = rex + 8 end + if needrex then rex = rex + 16 end + if addin and addin.reg == -1 then + wputop(szov, opcode - 7, rex) + waction("VREG", addin.vreg); wputxb(0) + else + if addin and addin.reg > 7 then rex = rex + 1 end + wputop(szov, opcode, rex) + end + opcode = nil + end + if c == "|" then break end + if c == "o" then -- Offset (pure 32 bit displacement). + wputdarg(args[1].disp); if narg < 2 then narg = 2 end + elseif c == "O" then + wputdarg(args[2].disp); narg = 3 + else + -- Anything else is an immediate operand. + local a = args[narg] + narg = narg + 1 + local mode, imm = a.mode, a.imm + if mode == "iJ" and not match("iIJ", c) then + werror("bad operand size for label") + end + if c == "S" then + wputsbarg(imm) + elseif c == "U" then + wputbarg(imm) + elseif c == "W" then + wputwarg(imm) + elseif c == "i" or c == "I" then + if mode == "iJ" then + wputlabel("IMM_", imm, 1) + elseif mode == "iI" and c == "I" then + waction(sz == "w" and "IMM_WB" or "IMM_DB", imm) + else + wputszarg(sz, imm) + end + elseif c == "J" then + if mode == "iPJ" then + waction("REL_A", imm) -- !x64 (secpos) + else + wputlabel("REL_", imm, 2) + end + else + werror("bad char `"..c.."' in pattern `"..pat.."' for `"..op.."'") + end + end + end + end +end + +------------------------------------------------------------------------------ + +-- Mapping of operand modes to short names. Suppress output with '#'. +local map_modename = { + r = "reg", R = "eax", C = "cl", x = "mem", m = "mrm", i = "imm", + f = "stx", F = "st0", J = "lbl", ["1"] = "1", + I = "#", S = "#", O = "#", +} + +-- Return a table/string showing all possible operand modes. +local function templatehelp(template, nparams) + if nparams == 0 then return "" end + local t = {} + for tm in gmatch(template, "[^%|]+") do + local s = map_modename[sub(tm, 1, 1)] + s = s..gsub(sub(tm, 2, nparams), ".", function(c) + return ", "..map_modename[c] + end) + if not match(s, "#") then t[#t+1] = s end + end + return t +end + +-- Match operand modes against mode match part of template. +local function matchtm(tm, args) + for i=1,#args do + if not match(args[i].mode, sub(tm, i, i)) then return end + end + return true +end + +-- Handle opcodes defined with template strings. +map_op[".template__"] = function(params, template, nparams) + if not params then return templatehelp(template, nparams) end + local args = {} + + -- Zero-operand opcodes have no match part. + if #params == 0 then + dopattern(template, args, "d", params.op, nil) + return + end + + -- Determine common operand size (coerce undefined size) or flag as mixed. + local sz, szmix, needrex + for i,p in ipairs(params) do + args[i] = parseoperand(p) + local nsz = args[i].opsize + if nsz then + if sz and sz ~= nsz then szmix = true else sz = nsz end + end + local nrex = args[i].needrex + if nrex ~= nil then + if needrex == nil then + needrex = nrex + elseif needrex ~= nrex then + werror("bad mix of byte-addressable registers") + end + end + end + + -- Try all match:pattern pairs (separated by '|'). + local gotmatch, lastpat + for tm in gmatch(template, "[^%|]+") do + -- Split off size match (starts after mode match) and pattern string. + local szm, pat = match(tm, "^(.-):(.*)$", #args+1) + if pat == "" then pat = lastpat else lastpat = pat end + if matchtm(tm, args) then + local prefix = sub(szm, 1, 1) + if prefix == "/" then -- Match both operand sizes. + if args[1].opsize == sub(szm, 2, 2) and + args[2].opsize == sub(szm, 3, 3) then + dopattern(pat, args, sz, params.op, needrex) -- Process pattern. + return + end + else -- Match common operand size. + local szp = sz + if szm == "" then szm = x64 and "qdwb" or "dwb" end -- Default sizes. + if prefix == "1" then szp = args[1].opsize; szmix = nil + elseif prefix == "2" then szp = args[2].opsize; szmix = nil end + if not szmix and (prefix == "." or match(szm, szp or "#")) then + dopattern(pat, args, szp, params.op, needrex) -- Process pattern. + return + end + end + gotmatch = true + end + end + + local msg = "bad operand mode" + if gotmatch then + if szmix then + msg = "mixed operand size" + else + msg = sz and "bad operand size" or "missing operand size" + end + end + + werror(msg.." in `"..opmodestr(params.op, args).."'") +end + +------------------------------------------------------------------------------ + +-- x64-specific opcode for 64 bit immediates and displacements. +if x64 then + function map_op.mov64_2(params) + if not params then return { "reg, imm", "reg, [disp]", "[disp], reg" } end + if secpos+2 > maxsecpos then wflush() end + local opcode, op64, sz, rex, vreg + local op64 = match(params[1], "^%[%s*(.-)%s*%]$") + if op64 then + local a = parseoperand(params[2]) + if a.mode ~= "rmR" then werror("bad operand mode") end + sz = a.opsize + rex = sz == "q" and 8 or 0 + opcode = 0xa3 + else + op64 = match(params[2], "^%[%s*(.-)%s*%]$") + local a = parseoperand(params[1]) + if op64 then + if a.mode ~= "rmR" then werror("bad operand mode") end + sz = a.opsize + rex = sz == "q" and 8 or 0 + opcode = 0xa1 + else + if sub(a.mode, 1, 1) ~= "r" or a.opsize ~= "q" then + werror("bad operand mode") + end + op64 = params[2] + if a.reg == -1 then + vreg = a.vreg + opcode = 0xb8 + else + opcode = 0xb8 + band(a.reg, 7) + end + rex = a.reg > 7 and 9 or 8 + end + end + wputop(sz, opcode, rex) + if vreg then waction("VREG", vreg); wputxb(0) end + waction("IMM_D", format("(unsigned int)(%s)", op64)) + waction("IMM_D", format("(unsigned int)((%s)>>32)", op64)) + end +end + +------------------------------------------------------------------------------ + +-- Pseudo-opcodes for data storage. +local function op_data(params) + if not params then return "imm..." end + local sz = sub(params.op, 2, 2) + if sz == "a" then sz = addrsize end + for _,p in ipairs(params) do + local a = parseoperand(p) + if sub(a.mode, 1, 1) ~= "i" or (a.opsize and a.opsize ~= sz) then + werror("bad mode or size in `"..p.."'") + end + if a.mode == "iJ" then + wputlabel("IMM_", a.imm, 1) + else + wputszarg(sz, a.imm) + end + if secpos+2 > maxsecpos then wflush() end + end +end + +map_op[".byte_*"] = op_data +map_op[".sbyte_*"] = op_data +map_op[".word_*"] = op_data +map_op[".dword_*"] = op_data +map_op[".aword_*"] = op_data + +------------------------------------------------------------------------------ + +-- Pseudo-opcode to mark the position where the action list is to be emitted. +map_op[".actionlist_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeactions(out, name) end) +end + +-- Pseudo-opcode to mark the position where the global enum is to be emitted. +map_op[".globals_1"] = function(params) + if not params then return "prefix" end + local prefix = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeglobals(out, prefix) end) +end + +-- Pseudo-opcode to mark the position where the global names are to be emitted. +map_op[".globalnames_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeglobalnames(out, name) end) +end + +-- Pseudo-opcode to mark the position where the extern names are to be emitted. +map_op[".externnames_1"] = function(params) + if not params then return "cvar" end + local name = params[1] -- No syntax check. You get to keep the pieces. + wline(function(out) writeexternnames(out, name) end) +end + +------------------------------------------------------------------------------ + +-- Label pseudo-opcode (converted from trailing colon form). +map_op[".label_2"] = function(params) + if not params then return "[1-9] | ->global | =>pcexpr [, addr]" end + if secpos+2 > maxsecpos then wflush() end + local a = parseoperand(params[1]) + local mode, imm = a.mode, a.imm + if type(imm) == "number" and (mode == "iJ" or (imm >= 1 and imm <= 9)) then + -- Local label (1: ... 9:) or global label (->global:). + waction("LABEL_LG", nil, 1) + wputxb(imm) + elseif mode == "iJ" then + -- PC label (=>pcexpr:). + waction("LABEL_PC", imm) + else + werror("bad label definition") + end + -- SETLABEL must immediately follow LABEL_LG/LABEL_PC. + local addr = params[2] + if addr then + local a = parseoperand(addr) + if a.mode == "iPJ" then + waction("SETLABEL", a.imm) + else + werror("bad label assignment") + end + end +end +map_op[".label_1"] = map_op[".label_2"] + +------------------------------------------------------------------------------ + +-- Alignment pseudo-opcode. +map_op[".align_1"] = function(params) + if not params then return "numpow2" end + if secpos+1 > maxsecpos then wflush() end + local align = tonumber(params[1]) or map_opsizenum[map_opsize[params[1]]] + if align then + local x = align + -- Must be a power of 2 in the range (2 ... 256). + for i=1,8 do + x = x / 2 + if x == 1 then + waction("ALIGN", nil, 1) + wputxb(align-1) -- Action byte is 2**n-1. + return + end + end + end + werror("bad alignment") +end + +-- Spacing pseudo-opcode. +map_op[".space_2"] = function(params) + if not params then return "num [, filler]" end + if secpos+1 > maxsecpos then wflush() end + waction("SPACE", params[1]) + local fill = params[2] + if fill then + fill = tonumber(fill) + if not fill or fill < 0 or fill > 255 then werror("bad filler") end + end + wputxb(fill or 0) +end +map_op[".space_1"] = map_op[".space_2"] + +------------------------------------------------------------------------------ + +-- Pseudo-opcode for (primitive) type definitions (map to C types). +map_op[".type_3"] = function(params, nparams) + if not params then + return nparams == 2 and "name, ctype" or "name, ctype, reg" + end + local name, ctype, reg = params[1], params[2], params[3] + if not match(name, "^[%a_][%w_]*$") then + werror("bad type name `"..name.."'") + end + local tp = map_type[name] + if tp then + werror("duplicate type `"..name.."'") + end + if reg and not map_reg_valid_base[reg] then + werror("bad base register `"..(map_reg_rev[reg] or reg).."'") + end + -- Add #type to defines. A bit unclean to put it in map_archdef. + map_archdef["#"..name] = "sizeof("..ctype..")" + -- Add new type and emit shortcut define. + local num = ctypenum + 1 + map_type[name] = { + ctype = ctype, + ctypefmt = format("Dt%X(%%s)", num), + reg = reg, + } + wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype)) + ctypenum = num +end +map_op[".type_2"] = map_op[".type_3"] + +-- Dump type definitions. +local function dumptypes(out, lvl) + local t = {} + for name in pairs(map_type) do t[#t+1] = name end + sort(t) + out:write("Type definitions:\n") + for _,name in ipairs(t) do + local tp = map_type[name] + local reg = tp.reg and map_reg_rev[tp.reg] or "" + out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg)) + end + out:write("\n") +end + +------------------------------------------------------------------------------ + +-- Set the current section. +function _M.section(num) + waction("SECTION") + wputxb(num) + wflush(true) -- SECTION is a terminal action. +end + +------------------------------------------------------------------------------ + +-- Dump architecture description. +function _M.dumparch(out) + out:write(format("DynASM %s version %s, released %s\n\n", + _info.arch, _info.version, _info.release)) + dumpregs(out) + dumpactions(out) +end + +-- Dump all user defined elements. +function _M.dumpdef(out, lvl) + dumptypes(out, lvl) + dumpglobals(out, lvl) + dumpexterns(out, lvl) +end + +------------------------------------------------------------------------------ + +-- Pass callbacks from/to the DynASM core. +function _M.passcb(wl, we, wf, ww) + wline, werror, wfatal, wwarn = wl, we, wf, ww + return wflush +end + +-- Setup the arch-specific module. +function _M.setup(arch, opt) + g_arch, g_opt = arch, opt +end + +-- Merge the core maps and the arch-specific maps. +function _M.mergemaps(map_coreop, map_def) + setmetatable(map_op, { __index = map_coreop }) + setmetatable(map_def, { __index = map_archdef }) + return map_op, map_def +end + +return _M + +------------------------------------------------------------------------------ + diff --git a/source/libs/luajit/LuaJIT-2.0.4/dynasm/dynasm.lua b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dynasm.lua new file mode 100644 index 000000000..fffda7513 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/dynasm/dynasm.lua @@ -0,0 +1,1094 @@ +------------------------------------------------------------------------------ +-- DynASM. A dynamic assembler for code generation engines. +-- Originally designed and implemented for LuaJIT. +-- +-- Copyright (C) 2005-2015 Mike Pall. All rights reserved. +-- See below for full copyright notice. +------------------------------------------------------------------------------ + +-- Application information. +local _info = { + name = "DynASM", + description = "A dynamic assembler for code generation engines", + version = "1.3.0", + vernum = 10300, + release = "2011-05-05", + author = "Mike Pall", + url = "http://luajit.org/dynasm.html", + license = "MIT", + copyright = [[ +Copyright (C) 2005-2015 Mike Pall. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +[ MIT license: http://www.opensource.org/licenses/mit-license.php ] +]], +} + +-- Cache library functions. +local type, pairs, ipairs = type, pairs, ipairs +local pcall, error, assert = pcall, error, assert +local _s = string +local sub, match, gmatch, gsub = _s.sub, _s.match, _s.gmatch, _s.gsub +local format, rep, upper = _s.format, _s.rep, _s.upper +local _t = table +local insert, remove, concat, sort = _t.insert, _t.remove, _t.concat, _t.sort +local exit = os.exit +local io = io +local stdin, stdout, stderr = io.stdin, io.stdout, io.stderr + +------------------------------------------------------------------------------ + +-- Program options. +local g_opt = {} + +-- Global state for current file. +local g_fname, g_curline, g_indent, g_lineno, g_synclineno, g_arch +local g_errcount = 0 + +-- Write buffer for output file. +local g_wbuffer, g_capbuffer + +------------------------------------------------------------------------------ + +-- Write an output line (or callback function) to the buffer. +local function wline(line, needindent) + local buf = g_capbuffer or g_wbuffer + buf[#buf+1] = needindent and g_indent..line or line + g_synclineno = g_synclineno + 1 +end + +-- Write assembler line as a comment, if requestd. +local function wcomment(aline) + if g_opt.comment then + wline(g_opt.comment..aline..g_opt.endcomment, true) + end +end + +-- Resync CPP line numbers. +local function wsync() + if g_synclineno ~= g_lineno and g_opt.cpp then + wline("#line "..g_lineno..' "'..g_fname..'"') + g_synclineno = g_lineno + end +end + +-- Dummy action flush function. Replaced with arch-specific function later. +local function wflush(term) +end + +-- Dump all buffered output lines. +local function wdumplines(out, buf) + for _,line in ipairs(buf) do + if type(line) == "string" then + assert(out:write(line, "\n")) + else + -- Special callback to dynamically insert lines after end of processing. + line(out) + end + end +end + +------------------------------------------------------------------------------ + +-- Emit an error. Processing continues with next statement. +local function werror(msg) + error(format("%s:%s: error: %s:\n%s", g_fname, g_lineno, msg, g_curline), 0) +end + +-- Emit a fatal error. Processing stops. +local function wfatal(msg) + g_errcount = "fatal" + werror(msg) +end + +-- Print a warning. Processing continues. +local function wwarn(msg) + stderr:write(format("%s:%s: warning: %s:\n%s\n", + g_fname, g_lineno, msg, g_curline)) +end + +-- Print caught error message. But suppress excessive errors. +local function wprinterr(...) + if type(g_errcount) == "number" then + -- Regular error. + g_errcount = g_errcount + 1 + if g_errcount < 21 then -- Seems to be a reasonable limit. + stderr:write(...) + elseif g_errcount == 21 then + stderr:write(g_fname, + ":*: warning: too many errors (suppressed further messages).\n") + end + else + -- Fatal error. + stderr:write(...) + return true -- Stop processing. + end +end + +------------------------------------------------------------------------------ + +-- Map holding all option handlers. +local opt_map = {} +local opt_current + +-- Print error and exit with error status. +local function opterror(...) + stderr:write("dynasm.lua: ERROR: ", ...) + stderr:write("\n") + exit(1) +end + +-- Get option parameter. +local function optparam(args) + local argn = args.argn + local p = args[argn] + if not p then + opterror("missing parameter for option `", opt_current, "'.") + end + args.argn = argn + 1 + return p +end + +------------------------------------------------------------------------------ + +-- Core pseudo-opcodes. +local map_coreop = {} +-- Dummy opcode map. Replaced by arch-specific map. +local map_op = {} + +-- Forward declarations. +local dostmt +local readfile + +------------------------------------------------------------------------------ + +-- Map for defines (initially empty, chains to arch-specific map). +local map_def = {} + +-- Pseudo-opcode to define a substitution. +map_coreop[".define_2"] = function(params, nparams) + if not params then return nparams == 1 and "name" or "name, subst" end + local name, def = params[1], params[2] or "1" + if not match(name, "^[%a_][%w_]*$") then werror("bad or duplicate define") end + map_def[name] = def +end +map_coreop[".define_1"] = map_coreop[".define_2"] + +-- Define a substitution on the command line. +function opt_map.D(args) + local namesubst = optparam(args) + local name, subst = match(namesubst, "^([%a_][%w_]*)=(.*)$") + if name then + map_def[name] = subst + elseif match(namesubst, "^[%a_][%w_]*$") then + map_def[namesubst] = "1" + else + opterror("bad define") + end +end + +-- Undefine a substitution on the command line. +function opt_map.U(args) + local name = optparam(args) + if match(name, "^[%a_][%w_]*$") then + map_def[name] = nil + else + opterror("bad define") + end +end + +-- Helper for definesubst. +local gotsubst + +local function definesubst_one(word) + local subst = map_def[word] + if subst then gotsubst = word; return subst else return word end +end + +-- Iteratively substitute defines. +local function definesubst(stmt) + -- Limit number of iterations. + for i=1,100 do + gotsubst = false + stmt = gsub(stmt, "#?[%w_]+", definesubst_one) + if not gotsubst then break end + end + if gotsubst then wfatal("recursive define involving `"..gotsubst.."'") end + return stmt +end + +-- Dump all defines. +local function dumpdefines(out, lvl) + local t = {} + for name in pairs(map_def) do + t[#t+1] = name + end + sort(t) + out:write("Defines:\n") + for _,name in ipairs(t) do + local subst = map_def[name] + if g_arch then subst = g_arch.revdef(subst) end + out:write(format(" %-20s %s\n", name, subst)) + end + out:write("\n") +end + +------------------------------------------------------------------------------ + +-- Support variables for conditional assembly. +local condlevel = 0 +local condstack = {} + +-- Evaluate condition with a Lua expression. Substitutions already performed. +local function cond_eval(cond) + local func, err + if setfenv then + func, err = loadstring("return "..cond, "=expr") + else + -- No globals. All unknown identifiers evaluate to nil. + func, err = load("return "..cond, "=expr", "t", {}) + end + if func then + if setfenv then + setfenv(func, {}) -- No globals. All unknown identifiers evaluate to nil. + end + local ok, res = pcall(func) + if ok then + if res == 0 then return false end -- Oh well. + return not not res + end + err = res + end + wfatal("bad condition: "..err) +end + +-- Skip statements until next conditional pseudo-opcode at the same level. +local function stmtskip() + local dostmt_save = dostmt + local lvl = 0 + dostmt = function(stmt) + local op = match(stmt, "^%s*(%S+)") + if op == ".if" then + lvl = lvl + 1 + elseif lvl ~= 0 then + if op == ".endif" then lvl = lvl - 1 end + elseif op == ".elif" or op == ".else" or op == ".endif" then + dostmt = dostmt_save + dostmt(stmt) + end + end +end + +-- Pseudo-opcodes for conditional assembly. +map_coreop[".if_1"] = function(params) + if not params then return "condition" end + local lvl = condlevel + 1 + local res = cond_eval(params[1]) + condlevel = lvl + condstack[lvl] = res + if not res then stmtskip() end +end + +map_coreop[".elif_1"] = function(params) + if not params then return "condition" end + if condlevel == 0 then wfatal(".elif without .if") end + local lvl = condlevel + local res = condstack[lvl] + if res then + if res == "else" then wfatal(".elif after .else") end + else + res = cond_eval(params[1]) + if res then + condstack[lvl] = res + return + end + end + stmtskip() +end + +map_coreop[".else_0"] = function(params) + if condlevel == 0 then wfatal(".else without .if") end + local lvl = condlevel + local res = condstack[lvl] + condstack[lvl] = "else" + if res then + if res == "else" then wfatal(".else after .else") end + stmtskip() + end +end + +map_coreop[".endif_0"] = function(params) + local lvl = condlevel + if lvl == 0 then wfatal(".endif without .if") end + condlevel = lvl - 1 +end + +-- Check for unfinished conditionals. +local function checkconds() + if g_errcount ~= "fatal" and condlevel ~= 0 then + wprinterr(g_fname, ":*: error: unbalanced conditional\n") + end +end + +------------------------------------------------------------------------------ + +-- Search for a file in the given path and open it for reading. +local function pathopen(path, name) + local dirsep = package and match(package.path, "\\") and "\\" or "/" + for _,p in ipairs(path) do + local fullname = p == "" and name or p..dirsep..name + local fin = io.open(fullname, "r") + if fin then + g_fname = fullname + return fin + end + end +end + +-- Include a file. +map_coreop[".include_1"] = function(params) + if not params then return "filename" end + local name = params[1] + -- Save state. Ugly, I know. but upvalues are fast. + local gf, gl, gcl, gi = g_fname, g_lineno, g_curline, g_indent + -- Read the included file. + local fatal = readfile(pathopen(g_opt.include, name) or + wfatal("include file `"..name.."' not found")) + -- Restore state. + g_synclineno = -1 + g_fname, g_lineno, g_curline, g_indent = gf, gl, gcl, gi + if fatal then wfatal("in include file") end +end + +-- Make .include and conditionals initially available, too. +map_op[".include_1"] = map_coreop[".include_1"] +map_op[".if_1"] = map_coreop[".if_1"] +map_op[".elif_1"] = map_coreop[".elif_1"] +map_op[".else_0"] = map_coreop[".else_0"] +map_op[".endif_0"] = map_coreop[".endif_0"] + +------------------------------------------------------------------------------ + +-- Support variables for macros. +local mac_capture, mac_lineno, mac_name +local mac_active = {} +local mac_list = {} + +-- Pseudo-opcode to define a macro. +map_coreop[".macro_*"] = function(mparams) + if not mparams then return "name [, params...]" end + -- Split off and validate macro name. + local name = remove(mparams, 1) + if not name then werror("missing macro name") end + if not (match(name, "^[%a_][%w_%.]*$") or match(name, "^%.[%w_%.]*$")) then + wfatal("bad macro name `"..name.."'") + end + -- Validate macro parameter names. + local mdup = {} + for _,mp in ipairs(mparams) do + if not match(mp, "^[%a_][%w_]*$") then + wfatal("bad macro parameter name `"..mp.."'") + end + if mdup[mp] then wfatal("duplicate macro parameter name `"..mp.."'") end + mdup[mp] = true + end + -- Check for duplicate or recursive macro definitions. + local opname = name.."_"..#mparams + if map_op[opname] or map_op[name.."_*"] then + wfatal("duplicate macro `"..name.."' ("..#mparams.." parameters)") + end + if mac_capture then wfatal("recursive macro definition") end + + -- Enable statement capture. + local lines = {} + mac_lineno = g_lineno + mac_name = name + mac_capture = function(stmt) -- Statement capture function. + -- Stop macro definition with .endmacro pseudo-opcode. + if not match(stmt, "^%s*.endmacro%s*$") then + lines[#lines+1] = stmt + return + end + mac_capture = nil + mac_lineno = nil + mac_name = nil + mac_list[#mac_list+1] = opname + -- Add macro-op definition. + map_op[opname] = function(params) + if not params then return mparams, lines end + -- Protect against recursive macro invocation. + if mac_active[opname] then wfatal("recursive macro invocation") end + mac_active[opname] = true + -- Setup substitution map. + local subst = {} + for i,mp in ipairs(mparams) do subst[mp] = params[i] end + local mcom + if g_opt.maccomment and g_opt.comment then + mcom = " MACRO "..name.." ("..#mparams..")" + wcomment("{"..mcom) + end + -- Loop through all captured statements + for _,stmt in ipairs(lines) do + -- Substitute macro parameters. + local st = gsub(stmt, "[%w_]+", subst) + st = definesubst(st) + st = gsub(st, "%s*%.%.%s*", "") -- Token paste a..b. + if mcom and sub(st, 1, 1) ~= "|" then wcomment(st) end + -- Emit statement. Use a protected call for better diagnostics. + local ok, err = pcall(dostmt, st) + if not ok then + -- Add the captured statement to the error. + wprinterr(err, "\n", g_indent, "| ", stmt, + "\t[MACRO ", name, " (", #mparams, ")]\n") + end + end + if mcom then wcomment("}"..mcom) end + mac_active[opname] = nil + end + end +end + +-- An .endmacro pseudo-opcode outside of a macro definition is an error. +map_coreop[".endmacro_0"] = function(params) + wfatal(".endmacro without .macro") +end + +-- Dump all macros and their contents (with -PP only). +local function dumpmacros(out, lvl) + sort(mac_list) + out:write("Macros:\n") + for _,opname in ipairs(mac_list) do + local name = sub(opname, 1, -3) + local params, lines = map_op[opname]() + out:write(format(" %-20s %s\n", name, concat(params, ", "))) + if lvl > 1 then + for _,line in ipairs(lines) do + out:write(" |", line, "\n") + end + out:write("\n") + end + end + out:write("\n") +end + +-- Check for unfinished macro definitions. +local function checkmacros() + if mac_capture then + wprinterr(g_fname, ":", mac_lineno, + ": error: unfinished .macro `", mac_name ,"'\n") + end +end + +------------------------------------------------------------------------------ + +-- Support variables for captures. +local cap_lineno, cap_name +local cap_buffers = {} +local cap_used = {} + +-- Start a capture. +map_coreop[".capture_1"] = function(params) + if not params then return "name" end + wflush() + local name = params[1] + if not match(name, "^[%a_][%w_]*$") then + wfatal("bad capture name `"..name.."'") + end + if cap_name then + wfatal("already capturing to `"..cap_name.."' since line "..cap_lineno) + end + cap_name = name + cap_lineno = g_lineno + -- Create or continue a capture buffer and start the output line capture. + local buf = cap_buffers[name] + if not buf then buf = {}; cap_buffers[name] = buf end + g_capbuffer = buf + g_synclineno = 0 +end + +-- Stop a capture. +map_coreop[".endcapture_0"] = function(params) + wflush() + if not cap_name then wfatal(".endcapture without a valid .capture") end + cap_name = nil + cap_lineno = nil + g_capbuffer = nil + g_synclineno = 0 +end + +-- Dump a capture buffer. +map_coreop[".dumpcapture_1"] = function(params) + if not params then return "name" end + wflush() + local name = params[1] + if not match(name, "^[%a_][%w_]*$") then + wfatal("bad capture name `"..name.."'") + end + cap_used[name] = true + wline(function(out) + local buf = cap_buffers[name] + if buf then wdumplines(out, buf) end + end) + g_synclineno = 0 +end + +-- Dump all captures and their buffers (with -PP only). +local function dumpcaptures(out, lvl) + out:write("Captures:\n") + for name,buf in pairs(cap_buffers) do + out:write(format(" %-20s %4s)\n", name, "("..#buf)) + if lvl > 1 then + local bar = rep("=", 76) + out:write(" ", bar, "\n") + for _,line in ipairs(buf) do + out:write(" ", line, "\n") + end + out:write(" ", bar, "\n\n") + end + end + out:write("\n") +end + +-- Check for unfinished or unused captures. +local function checkcaptures() + if cap_name then + wprinterr(g_fname, ":", cap_lineno, + ": error: unfinished .capture `", cap_name,"'\n") + return + end + for name in pairs(cap_buffers) do + if not cap_used[name] then + wprinterr(g_fname, ":*: error: missing .dumpcapture ", name ,"\n") + end + end +end + +------------------------------------------------------------------------------ + +-- Sections names. +local map_sections = {} + +-- Pseudo-opcode to define code sections. +-- TODO: Data sections, BSS sections. Needs extra C code and API. +map_coreop[".section_*"] = function(params) + if not params then return "name..." end + if #map_sections > 0 then werror("duplicate section definition") end + wflush() + for sn,name in ipairs(params) do + local opname = "."..name.."_0" + if not match(name, "^[%a][%w_]*$") or + map_op[opname] or map_op["."..name.."_*"] then + werror("bad section name `"..name.."'") + end + map_sections[#map_sections+1] = name + wline(format("#define DASM_SECTION_%s\t%d", upper(name), sn-1)) + map_op[opname] = function(params) g_arch.section(sn-1) end + end + wline(format("#define DASM_MAXSECTION\t\t%d", #map_sections)) +end + +-- Dump all sections. +local function dumpsections(out, lvl) + out:write("Sections:\n") + for _,name in ipairs(map_sections) do + out:write(format(" %s\n", name)) + end + out:write("\n") +end + +------------------------------------------------------------------------------ + +-- Replacement for customized Lua, which lacks the package library. +local prefix = "" +if not require then + function require(name) + local fp = assert(io.open(prefix..name..".lua")) + local s = fp:read("*a") + assert(fp:close()) + return assert(loadstring(s, "@"..name..".lua"))() + end +end + +-- Load architecture-specific module. +local function loadarch(arch) + if not match(arch, "^[%w_]+$") then return "bad arch name" end + local ok, m_arch = pcall(require, "dasm_"..arch) + if not ok then return "cannot load module: "..m_arch end + g_arch = m_arch + wflush = m_arch.passcb(wline, werror, wfatal, wwarn) + m_arch.setup(arch, g_opt) + map_op, map_def = m_arch.mergemaps(map_coreop, map_def) +end + +-- Dump architecture description. +function opt_map.dumparch(args) + local name = optparam(args) + if not g_arch then + local err = loadarch(name) + if err then opterror(err) end + end + + local t = {} + for name in pairs(map_coreop) do t[#t+1] = name end + for name in pairs(map_op) do t[#t+1] = name end + sort(t) + + local out = stdout + local _arch = g_arch._info + out:write(format("%s version %s, released %s, %s\n", + _info.name, _info.version, _info.release, _info.url)) + g_arch.dumparch(out) + + local pseudo = true + out:write("Pseudo-Opcodes:\n") + for _,sname in ipairs(t) do + local name, nparam = match(sname, "^(.+)_([0-9%*])$") + if name then + if pseudo and sub(name, 1, 1) ~= "." then + out:write("\nOpcodes:\n") + pseudo = false + end + local f = map_op[sname] + local s + if nparam ~= "*" then nparam = nparam + 0 end + if nparam == 0 then + s = "" + elseif type(f) == "string" then + s = map_op[".template__"](nil, f, nparam) + else + s = f(nil, nparam) + end + if type(s) == "table" then + for _,s2 in ipairs(s) do + out:write(format(" %-12s %s\n", name, s2)) + end + else + out:write(format(" %-12s %s\n", name, s)) + end + end + end + out:write("\n") + exit(0) +end + +-- Pseudo-opcode to set the architecture. +-- Only initially available (map_op is replaced when called). +map_op[".arch_1"] = function(params) + if not params then return "name" end + local err = loadarch(params[1]) + if err then wfatal(err) end + wline(format("#if DASM_VERSION != %d", _info.vernum)) + wline('#error "Version mismatch between DynASM and included encoding engine"') + wline("#endif") +end + +-- Dummy .arch pseudo-opcode to improve the error report. +map_coreop[".arch_1"] = function(params) + if not params then return "name" end + wfatal("duplicate .arch statement") +end + +------------------------------------------------------------------------------ + +-- Dummy pseudo-opcode. Don't confuse '.nop' with 'nop'. +map_coreop[".nop_*"] = function(params) + if not params then return "[ignored...]" end +end + +-- Pseudo-opcodes to raise errors. +map_coreop[".error_1"] = function(params) + if not params then return "message" end + werror(params[1]) +end + +map_coreop[".fatal_1"] = function(params) + if not params then return "message" end + wfatal(params[1]) +end + +-- Dump all user defined elements. +local function dumpdef(out) + local lvl = g_opt.dumpdef + if lvl == 0 then return end + dumpsections(out, lvl) + dumpdefines(out, lvl) + if g_arch then g_arch.dumpdef(out, lvl) end + dumpmacros(out, lvl) + dumpcaptures(out, lvl) +end + +------------------------------------------------------------------------------ + +-- Helper for splitstmt. +local splitlvl + +local function splitstmt_one(c) + if c == "(" then + splitlvl = ")"..splitlvl + elseif c == "[" then + splitlvl = "]"..splitlvl + elseif c == "{" then + splitlvl = "}"..splitlvl + elseif c == ")" or c == "]" or c == "}" then + if sub(splitlvl, 1, 1) ~= c then werror("unbalanced (), [] or {}") end + splitlvl = sub(splitlvl, 2) + elseif splitlvl == "" then + return " \0 " + end + return c +end + +-- Split statement into (pseudo-)opcode and params. +local function splitstmt(stmt) + -- Convert label with trailing-colon into .label statement. + local label = match(stmt, "^%s*(.+):%s*$") + if label then return ".label", {label} end + + -- Split at commas and equal signs, but obey parentheses and brackets. + splitlvl = "" + stmt = gsub(stmt, "[,%(%)%[%]{}]", splitstmt_one) + if splitlvl ~= "" then werror("unbalanced () or []") end + + -- Split off opcode. + local op, other = match(stmt, "^%s*([^%s%z]+)%s*(.*)$") + if not op then werror("bad statement syntax") end + + -- Split parameters. + local params = {} + for p in gmatch(other, "%s*(%Z+)%z?") do + params[#params+1] = gsub(p, "%s+$", "") + end + if #params > 16 then werror("too many parameters") end + + params.op = op + return op, params +end + +-- Process a single statement. +dostmt = function(stmt) + -- Ignore empty statements. + if match(stmt, "^%s*$") then return end + + -- Capture macro defs before substitution. + if mac_capture then return mac_capture(stmt) end + stmt = definesubst(stmt) + + -- Emit C code without parsing the line. + if sub(stmt, 1, 1) == "|" then + local tail = sub(stmt, 2) + wflush() + if sub(tail, 1, 2) == "//" then wcomment(tail) else wline(tail, true) end + return + end + + -- Split into (pseudo-)opcode and params. + local op, params = splitstmt(stmt) + + -- Get opcode handler (matching # of parameters or generic handler). + local f = map_op[op.."_"..#params] or map_op[op.."_*"] + if not f then + if not g_arch then wfatal("first statement must be .arch") end + -- Improve error report. + for i=0,9 do + if map_op[op.."_"..i] then + werror("wrong number of parameters for `"..op.."'") + end + end + werror("unknown statement `"..op.."'") + end + + -- Call opcode handler or special handler for template strings. + if type(f) == "string" then + map_op[".template__"](params, f) + else + f(params) + end +end + +-- Process a single line. +local function doline(line) + if g_opt.flushline then wflush() end + + -- Assembler line? + local indent, aline = match(line, "^(%s*)%|(.*)$") + if not aline then + -- No, plain C code line, need to flush first. + wflush() + wsync() + wline(line, false) + return + end + + g_indent = indent -- Remember current line indentation. + + -- Emit C code (even from macros). Avoids echo and line parsing. + if sub(aline, 1, 1) == "|" then + if not mac_capture then + wsync() + elseif g_opt.comment then + wsync() + wcomment(aline) + end + dostmt(aline) + return + end + + -- Echo assembler line as a comment. + if g_opt.comment then + wsync() + wcomment(aline) + end + + -- Strip assembler comments. + aline = gsub(aline, "//.*$", "") + + -- Split line into statements at semicolons. + if match(aline, ";") then + for stmt in gmatch(aline, "[^;]+") do dostmt(stmt) end + else + dostmt(aline) + end +end + +------------------------------------------------------------------------------ + +-- Write DynASM header. +local function dasmhead(out) + out:write(format([[ +/* +** This file has been pre-processed with DynASM. +** %s +** DynASM version %s, DynASM %s version %s +** DO NOT EDIT! The original file is in "%s". +*/ + +]], _info.url, + _info.version, g_arch._info.arch, g_arch._info.version, + g_fname)) +end + +-- Read input file. +readfile = function(fin) + g_indent = "" + g_lineno = 0 + g_synclineno = -1 + + -- Process all lines. + for line in fin:lines() do + g_lineno = g_lineno + 1 + g_curline = line + local ok, err = pcall(doline, line) + if not ok and wprinterr(err, "\n") then return true end + end + wflush() + + -- Close input file. + assert(fin == stdin or fin:close()) +end + +-- Write output file. +local function writefile(outfile) + local fout + + -- Open output file. + if outfile == nil or outfile == "-" then + fout = stdout + else + fout = assert(io.open(outfile, "w")) + end + + -- Write all buffered lines + wdumplines(fout, g_wbuffer) + + -- Close output file. + assert(fout == stdout or fout:close()) + + -- Optionally dump definitions. + dumpdef(fout == stdout and stderr or stdout) +end + +-- Translate an input file to an output file. +local function translate(infile, outfile) + g_wbuffer = {} + g_indent = "" + g_lineno = 0 + g_synclineno = -1 + + -- Put header. + wline(dasmhead) + + -- Read input file. + local fin + if infile == "-" then + g_fname = "(stdin)" + fin = stdin + else + g_fname = infile + fin = assert(io.open(infile, "r")) + end + readfile(fin) + + -- Check for errors. + if not g_arch then + wprinterr(g_fname, ":*: error: missing .arch directive\n") + end + checkconds() + checkmacros() + checkcaptures() + + if g_errcount ~= 0 then + stderr:write(g_fname, ":*: info: ", g_errcount, " error", + (type(g_errcount) == "number" and g_errcount > 1) and "s" or "", + " in input file -- no output file generated.\n") + dumpdef(stderr) + exit(1) + end + + -- Write output file. + writefile(outfile) +end + +------------------------------------------------------------------------------ + +-- Print help text. +function opt_map.help() + stdout:write("DynASM -- ", _info.description, ".\n") + stdout:write("DynASM ", _info.version, " ", _info.release, " ", _info.url, "\n") + stdout:write[[ + +Usage: dynasm [OPTION]... INFILE.dasc|- + + -h, --help Display this help text. + -V, --version Display version and copyright information. + + -o, --outfile FILE Output file name (default is stdout). + -I, --include DIR Add directory to the include search path. + + -c, --ccomment Use /* */ comments for assembler lines. + -C, --cppcomment Use // comments for assembler lines (default). + -N, --nocomment Suppress assembler lines in output. + -M, --maccomment Show macro expansions as comments (default off). + + -L, --nolineno Suppress CPP line number information in output. + -F, --flushline Flush action list for every line. + + -D NAME[=SUBST] Define a substitution. + -U NAME Undefine a substitution. + + -P, --dumpdef Dump defines, macros, etc. Repeat for more output. + -A, --dumparch ARCH Load architecture ARCH and dump description. +]] + exit(0) +end + +-- Print version information. +function opt_map.version() + stdout:write(format("%s version %s, released %s\n%s\n\n%s", + _info.name, _info.version, _info.release, _info.url, _info.copyright)) + exit(0) +end + +-- Misc. options. +function opt_map.outfile(args) g_opt.outfile = optparam(args) end +function opt_map.include(args) insert(g_opt.include, 1, optparam(args)) end +function opt_map.ccomment() g_opt.comment = "/*|"; g_opt.endcomment = " */" end +function opt_map.cppcomment() g_opt.comment = "//|"; g_opt.endcomment = "" end +function opt_map.nocomment() g_opt.comment = false end +function opt_map.maccomment() g_opt.maccomment = true end +function opt_map.nolineno() g_opt.cpp = false end +function opt_map.flushline() g_opt.flushline = true end +function opt_map.dumpdef() g_opt.dumpdef = g_opt.dumpdef + 1 end + +------------------------------------------------------------------------------ + +-- Short aliases for long options. +local opt_alias = { + h = "help", ["?"] = "help", V = "version", + o = "outfile", I = "include", + c = "ccomment", C = "cppcomment", N = "nocomment", M = "maccomment", + L = "nolineno", F = "flushline", + P = "dumpdef", A = "dumparch", +} + +-- Parse single option. +local function parseopt(opt, args) + opt_current = #opt == 1 and "-"..opt or "--"..opt + local f = opt_map[opt] or opt_map[opt_alias[opt]] + if not f then + opterror("unrecognized option `", opt_current, "'. Try `--help'.\n") + end + f(args) +end + +-- Parse arguments. +local function parseargs(args) + -- Default options. + g_opt.comment = "//|" + g_opt.endcomment = "" + g_opt.cpp = true + g_opt.dumpdef = 0 + g_opt.include = { "" } + + -- Process all option arguments. + args.argn = 1 + repeat + local a = args[args.argn] + if not a then break end + local lopt, opt = match(a, "^%-(%-?)(.+)") + if not opt then break end + args.argn = args.argn + 1 + if lopt == "" then + -- Loop through short options. + for o in gmatch(opt, ".") do parseopt(o, args) end + else + -- Long option. + parseopt(opt, args) + end + until false + + -- Check for proper number of arguments. + local nargs = #args - args.argn + 1 + if nargs ~= 1 then + if nargs == 0 then + if g_opt.dumpdef > 0 then return dumpdef(stdout) end + end + opt_map.help() + end + + -- Translate a single input file to a single output file + -- TODO: Handle multiple files? + translate(args[args.argn], g_opt.outfile) +end + +------------------------------------------------------------------------------ + +-- Add the directory dynasm.lua resides in to the Lua module search path. +local arg = arg +if arg and arg[0] then + prefix = match(arg[0], "^(.*[/\\])") + if package and prefix then package.path = prefix.."?.lua;"..package.path end +end + +-- Start DynASM. +parseargs{...} + +------------------------------------------------------------------------------ + diff --git a/source/libs/luajit/LuaJIT-2.0.4/etc/luajit.1 b/source/libs/luajit/LuaJIT-2.0.4/etc/luajit.1 new file mode 100644 index 000000000..fd38b0a92 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/etc/luajit.1 @@ -0,0 +1,88 @@ +.TH luajit 1 "" "" "LuaJIT documentation" +.SH NAME +luajit \- Just-In-Time Compiler for the Lua Language +\fB +.SH SYNOPSIS +.B luajit +[\fIoptions\fR]... [\fIscript\fR [\fIargs\fR]...] +.SH "WEB SITE" +.IR http://luajit.org +.SH DESCRIPTION +.PP +This is the command-line program to run Lua programs with \fBLuaJIT\fR. +.PP +\fBLuaJIT\fR is a just-in-time (JIT) compiler for the Lua language. +The virtual machine (VM) is based on a fast interpreter combined with +a trace compiler. It can significantly improve the performance of Lua programs. +.PP +\fBLuaJIT\fR is API\- and ABI-compatible with the VM of the standard +Lua\ 5.1 interpreter. When embedding the VM into an application, +the built library can be used as a drop-in replacement. +.SH OPTIONS +.TP +.BI "\-e " chunk +Run the given chunk of Lua code. +.TP +.BI "\-l " library +Load the named library, just like \fBrequire("\fR\fIlibrary\fR\fB")\fR. +.TP +.BI "\-b " ... +Save or list bytecode. Run without arguments to get help on options. +.TP +.BI "\-j " command +Perform LuaJIT control command (optional space after \fB\-j\fR). +.TP +.BI "\-O" [opt] +Control LuaJIT optimizations. +.TP +.B "\-i" +Run in interactive mode. +.TP +.B "\-v" +Show \fBLuaJIT\fR version. +.TP +.B "\-E" +Ignore environment variables. +.TP +.B "\-\-" +Stop processing options. +.TP +.B "\-" +Read script from stdin instead. +.PP +After all options are processed, the given \fIscript\fR is run. +The arguments are passed in the global \fIarg\fR table. +.PP +Interactive mode is only entered, if no \fIscript\fR and no \fB\-e\fR +option is given. Interactive mode can be left with EOF (\fICtrl\-Z\fB). +.SH EXAMPLES +.TP +luajit hello.lua world + +Prints "Hello world", assuming \fIhello.lua\fR contains: +.br + print("Hello", arg[1]) +.TP +luajit \-e "local x=0; for i=1,1e9 do x=x+i end; print(x)" + +Calculates the sum of the numbers from 1 to 1000000000. +.br +And finishes in a reasonable amount of time, too. +.TP +luajit \-jv \-e "for i=1,10 do for j=1,10 do for k=1,100 do end end end" + +Runs some nested loops and shows the resulting traces. +.SH COPYRIGHT +.PP +\fBLuaJIT\fR is Copyright \(co 2005-2015 Mike Pall. +.br +\fBLuaJIT\fR is open source software, released under the MIT license. +.SH SEE ALSO +.PP +More details in the provided HTML docs or at: +.IR http://luajit.org +.br +More about the Lua language can be found at: +.IR http://lua.org/docs.html +.PP +lua(1) diff --git a/source/libs/luajit/LuaJIT-2.0.4/etc/luajit.pc b/source/libs/luajit/LuaJIT-2.0.4/etc/luajit.pc new file mode 100644 index 000000000..a652b40d4 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/etc/luajit.pc @@ -0,0 +1,25 @@ +# Package information for LuaJIT to be used by pkg-config. +majver=2 +minver=0 +relver=4 +version=${majver}.${minver}.${relver} +abiver=5.1 + +prefix=/usr/local +multilib=lib +exec_prefix=${prefix} +libdir=${exec_prefix}/${multilib} +libname=luajit-${abiver} +includedir=${prefix}/include/luajit-${majver}.${minver} + +INSTALL_LMOD=${prefix}/share/lua/${abiver} +INSTALL_CMOD=${prefix}/${multilib}/lua/${abiver} + +Name: LuaJIT +Description: Just-in-time compiler for Lua +URL: http://luajit.org +Version: ${version} +Requires: +Libs: -L${libdir} -l${libname} +Libs.private: -Wl,-E -lm -ldl +Cflags: -I${includedir} diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/Makefile b/source/libs/luajit/LuaJIT-2.0.4/src/Makefile new file mode 100644 index 000000000..00381e82f --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/Makefile @@ -0,0 +1,684 @@ +############################################################################## +# LuaJIT Makefile. Requires GNU Make. +# +# Please read doc/install.html before changing any variables! +# +# Suitable for POSIX platforms (Linux, *BSD, OSX etc.). +# Also works with MinGW and Cygwin on Windows. +# Please check msvcbuild.bat for building with MSVC on Windows. +# +# Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +############################################################################## + +MAJVER= 2 +MINVER= 0 +RELVER= 4 +ABIVER= 5.1 +NODOTABIVER= 51 + +############################################################################## +############################# COMPILER OPTIONS ############################# +############################################################################## +# These options mainly affect the speed of the JIT compiler itself, not the +# speed of the JIT-compiled code. Turn any of the optional settings on by +# removing the '#' in front of them. Make sure you force a full recompile +# with "make clean", followed by "make" if you change any options. +# +# LuaJIT builds as a native 32 or 64 bit binary by default. +CC= gcc +# +# Use this if you want to force a 32 bit build on a 64 bit multilib OS. +#CC= gcc -m32 +# +# Since the assembler part does NOT maintain a frame pointer, it's pointless +# to slow down the C part by not omitting it. Debugging, tracebacks and +# unwinding are not affected -- the assembler part has frame unwind +# information and GCC emits it where needed (x64) or with -g (see CCDEBUG). +CCOPT= -O2 -fomit-frame-pointer +# Use this if you want to generate a smaller binary (but it's slower): +#CCOPT= -Os -fomit-frame-pointer +# Note: it's no longer recommended to use -O3 with GCC 4.x. +# The I-Cache bloat usually outweighs the benefits from aggressive inlining. +# +# Target-specific compiler options: +# +# x86 only: it's recommended to compile at least for i686. Better yet, +# compile for an architecture that has SSE2, too (-msse -msse2). +# +# x86/x64 only: For GCC 4.2 or higher and if you don't intend to distribute +# the binaries to a different machine you could also use: -march=native +# +CCOPT_x86= -march=i686 +CCOPT_x64= +CCOPT_arm= +CCOPT_ppc= +CCOPT_ppcspe= +CCOPT_mips= +# +CCDEBUG= +# Uncomment the next line to generate debug information: +#CCDEBUG= -g +# +CCWARN= -Wall +# Uncomment the next line to enable more warnings: +#CCWARN+= -Wextra -Wdeclaration-after-statement -Wredundant-decls -Wshadow -Wpointer-arith +# +############################################################################## + +############################################################################## +################################ BUILD MODE ################################ +############################################################################## +# The default build mode is mixed mode on POSIX. On Windows this is the same +# as dynamic mode. +# +# Mixed mode creates a static + dynamic library and a statically linked luajit. +BUILDMODE= mixed +# +# Static mode creates a static library and a statically linked luajit. +#BUILDMODE= static +# +# Dynamic mode creates a dynamic library and a dynamically linked luajit. +# Note: this executable will only run when the library is installed! +#BUILDMODE= dynamic +# +############################################################################## + +############################################################################## +################################# FEATURES ################################# +############################################################################## +# Enable/disable these features as needed, but make sure you force a full +# recompile with "make clean", followed by "make". +XCFLAGS= +# +# Permanently disable the FFI extension to reduce the size of the LuaJIT +# executable. But please consider that the FFI library is compiled-in, +# but NOT loaded by default. It only allocates any memory, if you actually +# make use of it. +#XCFLAGS+= -DLUAJIT_DISABLE_FFI +# +# Features from Lua 5.2 that are unlikely to break existing code are +# enabled by default. Some other features that *might* break some existing +# code (e.g. __pairs or os.execute() return values) can be enabled here. +# Note: this does not provide full compatibility with Lua 5.2 at this time. +XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT +# +# Disable the JIT compiler, i.e. turn LuaJIT into a pure interpreter. +#XCFLAGS+= -DLUAJIT_DISABLE_JIT +# +# Some architectures (e.g. PPC) can use either single-number (1) or +# dual-number (2) mode. Uncomment one of these lines to override the +# default mode. Please see LJ_ARCH_NUMMODE in lj_arch.h for details. +#XCFLAGS+= -DLUAJIT_NUMMODE=1 +#XCFLAGS+= -DLUAJIT_NUMMODE=2 +# +############################################################################## + +############################################################################## +############################ DEBUGGING SUPPORT ############################# +############################################################################## +# Enable these options as needed, but make sure you force a full recompile +# with "make clean", followed by "make". +# Note that most of these are NOT suitable for benchmarking or release mode! +# +# Use the system provided memory allocator (realloc) instead of the +# bundled memory allocator. This is slower, but sometimes helpful for +# debugging. This option cannot be enabled on x64, since realloc usually +# doesn't return addresses in the right address range. +# OTOH this option is mandatory for Valgrind's memcheck tool on x64 and +# the only way to get useful results from it for all other architectures. +#XCFLAGS+= -DLUAJIT_USE_SYSMALLOC +# +# This define is required to run LuaJIT under Valgrind. The Valgrind +# header files must be installed. You should enable debug information, too. +# Use --suppressions=lj.supp to avoid some false positives. +#XCFLAGS+= -DLUAJIT_USE_VALGRIND +# +# This is the client for the GDB JIT API. GDB 7.0 or higher is required +# to make use of it. See lj_gdbjit.c for details. Enabling this causes +# a non-negligible overhead, even when not running under GDB. +#XCFLAGS+= -DLUAJIT_USE_GDBJIT +# +# Turn on assertions for the Lua/C API to debug problems with lua_* calls. +# This is rather slow -- use only while developing C libraries/embeddings. +#XCFLAGS+= -DLUA_USE_APICHECK +# +# Turn on assertions for the whole LuaJIT VM. This significantly slows down +# everything. Use only if you suspect a problem with LuaJIT itself. +#XCFLAGS+= -DLUA_USE_ASSERT +# +############################################################################## +# You probably don't need to change anything below this line! +############################################################################## + +############################################################################## +# Flags and options for host and target. +############################################################################## + +# You can override the following variables at the make command line: +# CC HOST_CC STATIC_CC DYNAMIC_CC +# CFLAGS HOST_CFLAGS TARGET_CFLAGS +# LDFLAGS HOST_LDFLAGS TARGET_LDFLAGS TARGET_SHLDFLAGS +# LIBS HOST_LIBS TARGET_LIBS +# CROSS HOST_SYS TARGET_SYS TARGET_FLAGS +# +# Cross-compilation examples: +# make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows +# make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu- + +CCOPTIONS= $(CCDEBUG) $(CCOPT) $(CCWARN) $(XCFLAGS) $(CFLAGS) +LDOPTIONS= $(CCDEBUG) $(LDFLAGS) + +HOST_CC= $(CC) +HOST_RM= rm -f +# If left blank, minilua is built and used. You can supply an installed +# copy of (plain) Lua 5.1 or 5.2, plus Lua BitOp. E.g. with: HOST_LUA=lua +HOST_LUA= + +HOST_XCFLAGS= -I. +HOST_XLDFLAGS= +HOST_XLIBS= +HOST_ACFLAGS= $(CCOPTIONS) $(HOST_XCFLAGS) $(TARGET_ARCH) $(HOST_CFLAGS) +HOST_ALDFLAGS= $(LDOPTIONS) $(HOST_XLDFLAGS) $(HOST_LDFLAGS) +HOST_ALIBS= $(HOST_XLIBS) $(LIBS) $(HOST_LIBS) + +STATIC_CC = $(CROSS)$(CC) +DYNAMIC_CC = $(CROSS)$(CC) -fPIC +TARGET_CC= $(STATIC_CC) +TARGET_STCC= $(STATIC_CC) +TARGET_DYNCC= $(DYNAMIC_CC) +TARGET_LD= $(CROSS)$(CC) +TARGET_AR= $(CROSS)ar rcus +TARGET_STRIP= $(CROSS)strip + +TARGET_LIBPATH= $(or $(PREFIX),/usr/local)/$(or $(MULTILIB),lib) +TARGET_SONAME= libluajit-$(ABIVER).so.$(MAJVER) +TARGET_DYLIBNAME= libluajit-$(ABIVER).$(MAJVER).dylib +TARGET_DYLIBPATH= $(TARGET_LIBPATH)/$(TARGET_DYLIBNAME) +TARGET_DLLNAME= lua$(NODOTABIVER).dll +TARGET_XSHLDFLAGS= -shared -fPIC -Wl,-soname,$(TARGET_SONAME) +TARGET_DYNXLDOPTS= + +TARGET_LFSFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE +TARGET_XCFLAGS= $(TARGET_LFSFLAGS) -U_FORTIFY_SOURCE +TARGET_XLDFLAGS= +TARGET_XLIBS= -lm +TARGET_TCFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS) +TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS) +TARGET_ALDFLAGS= $(LDOPTIONS) $(TARGET_XLDFLAGS) $(TARGET_FLAGS) $(TARGET_LDFLAGS) +TARGET_ASHLDFLAGS= $(LDOPTIONS) $(TARGET_XSHLDFLAGS) $(TARGET_FLAGS) $(TARGET_SHLDFLAGS) +TARGET_ALIBS= $(TARGET_XLIBS) $(LIBS) $(TARGET_LIBS) + +TARGET_TESTARCH=$(shell $(TARGET_CC) $(TARGET_TCFLAGS) -E lj_arch.h -dM) +ifneq (,$(findstring LJ_TARGET_X64 ,$(TARGET_TESTARCH))) + TARGET_LJARCH= x64 +else +ifneq (,$(findstring LJ_TARGET_X86 ,$(TARGET_TESTARCH))) + TARGET_LJARCH= x86 +else +ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH))) + TARGET_LJARCH= arm +else +ifneq (,$(findstring LJ_TARGET_PPC ,$(TARGET_TESTARCH))) + TARGET_LJARCH= ppc +else +ifneq (,$(findstring LJ_TARGET_PPCSPE ,$(TARGET_TESTARCH))) + TARGET_LJARCH= ppcspe +else +ifneq (,$(findstring LJ_TARGET_MIPS ,$(TARGET_TESTARCH))) + ifneq (,$(findstring MIPSEL ,$(TARGET_TESTARCH))) + TARGET_ARCH= -D__MIPSEL__=1 + endif + TARGET_LJARCH= mips +else + $(error Unsupported target architecture) +endif +endif +endif +endif +endif +endif + +ifneq (,$(findstring LJ_TARGET_PS3 1,$(TARGET_TESTARCH))) + TARGET_SYS= PS3 + TARGET_ARCH+= -D__CELLOS_LV2__ + TARGET_XCFLAGS+= -DLUAJIT_USE_SYSMALLOC +endif +ifneq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH))) + TARGET_ARCH+= -DLUAJIT_NO_UNWIND +endif + +TARGET_XCFLAGS+= $(CCOPT_$(TARGET_LJARCH)) +TARGET_ARCH+= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_LJARCH)) + +ifneq (,$(PREFIX)) +ifneq (/usr/local,$(PREFIX)) + TARGET_XCFLAGS+= -DLUA_ROOT=\"$(PREFIX)\" + ifneq (/usr,$(PREFIX)) + TARGET_DYNXLDOPTS= -Wl,-rpath,$(TARGET_LIBPATH) + endif +endif +endif +ifneq (,$(MULTILIB)) + TARGET_XCFLAGS+= -DLUA_MULTILIB=\"$(MULTILIB)\" +endif +ifneq (,$(LMULTILIB)) + TARGET_XCFLAGS+= -DLUA_LMULTILIB=\"$(LMULTILIB)\" +endif + +############################################################################## +# System detection. +############################################################################## + +ifeq (Windows,$(findstring Windows,$(OS))$(MSYSTEM)$(TERM)) + HOST_SYS= Windows + HOST_RM= del +else + HOST_SYS:= $(shell uname -s) + ifneq (,$(findstring MINGW,$(HOST_SYS))) + HOST_SYS= Windows + HOST_MSYS= mingw + endif + ifneq (,$(findstring CYGWIN,$(HOST_SYS))) + HOST_SYS= Windows + HOST_MSYS= cygwin + endif +endif + +TARGET_SYS?= $(HOST_SYS) +ifeq (Windows,$(TARGET_SYS)) + TARGET_STRIP+= --strip-unneeded + TARGET_XSHLDFLAGS= -shared + TARGET_DYNXLDOPTS= +else +ifeq (,$(shell $(TARGET_CC) -o /dev/null -c -x c /dev/null -fno-stack-protector 2>/dev/null || echo 1)) + TARGET_XCFLAGS+= -fno-stack-protector +endif +ifeq (Darwin,$(TARGET_SYS)) + ifeq (,$(MACOSX_DEPLOYMENT_TARGET)) + export MACOSX_DEPLOYMENT_TARGET=10.4 + endif + TARGET_STRIP+= -x + TARGET_AR+= 2>/dev/null + TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC + TARGET_DYNXLDOPTS= + TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) + ifeq (x64,$(TARGET_LJARCH)) + TARGET_XLDFLAGS+= -pagezero_size 10000 -image_base 100000000 + TARGET_XSHLDFLAGS+= -image_base 7fff04c4a000 + endif +else +ifeq (iOS,$(TARGET_SYS)) + TARGET_STRIP+= -x + TARGET_AR+= 2>/dev/null + TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC + TARGET_DYNXLDOPTS= + TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) +else + ifneq (SunOS,$(TARGET_SYS)) + ifneq (PS3,$(TARGET_SYS)) + TARGET_XLDFLAGS+= -Wl,-E + endif + endif + ifeq (Linux,$(TARGET_SYS)) + TARGET_XLIBS+= -ldl + endif + ifeq (GNU/kFreeBSD,$(TARGET_SYS)) + TARGET_XLIBS+= -ldl + endif +endif +endif +endif + +ifneq ($(HOST_SYS),$(TARGET_SYS)) + ifeq (Windows,$(TARGET_SYS)) + HOST_XCFLAGS+= -malign-double -DLUAJIT_OS=LUAJIT_OS_WINDOWS + else + ifeq (Linux,$(TARGET_SYS)) + HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_LINUX + else + ifeq (Darwin,$(TARGET_SYS)) + HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX + else + ifeq (iOS,$(TARGET_SYS)) + HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX + else + HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OTHER + endif + endif + endif + endif +endif + +ifneq (,$(CCDEBUG)) + TARGET_STRIP= @: +endif + +############################################################################## +# Files and pathnames. +############################################################################## + +MINILUA_O= host/minilua.o +MINILUA_LIBS= -lm +MINILUA_T= host/minilua +MINILUA_X= $(MINILUA_T) + +ifeq (,$(HOST_LUA)) + HOST_LUA= $(MINILUA_X) + DASM_DEP= $(MINILUA_T) +endif + +DASM_DIR= ../dynasm +DASM= $(HOST_LUA) $(DASM_DIR)/dynasm.lua +DASM_XFLAGS= +DASM_AFLAGS= +DASM_ARCH= $(TARGET_LJARCH) + +ifneq (,$(findstring LJ_ARCH_BITS 64,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D P64 +endif +ifneq (,$(findstring LJ_HASJIT 1,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D JIT +endif +ifneq (,$(findstring LJ_HASFFI 1,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D FFI +endif +ifneq (,$(findstring LJ_DUALNUM 1,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D DUALNUM +endif +ifneq (,$(findstring LJ_ARCH_HASFPU 1,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D FPU + TARGET_ARCH+= -DLJ_ARCH_HASFPU=1 +else + TARGET_ARCH+= -DLJ_ARCH_HASFPU=0 +endif +ifeq (,$(findstring LJ_ABI_SOFTFP 1,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D HFABI + TARGET_ARCH+= -DLJ_ABI_SOFTFP=0 +else + TARGET_ARCH+= -DLJ_ABI_SOFTFP=1 +endif +DASM_AFLAGS+= -D VER=$(subst LJ_ARCH_VERSION_,,$(filter LJ_ARCH_VERSION_%,$(subst LJ_ARCH_VERSION ,LJ_ARCH_VERSION_,$(TARGET_TESTARCH)))) +ifeq (Windows,$(TARGET_SYS)) + DASM_AFLAGS+= -D WIN +endif +ifeq (x86,$(TARGET_LJARCH)) + ifneq (,$(findstring __SSE2__ 1,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D SSE + endif +else +ifeq (x64,$(TARGET_LJARCH)) + DASM_ARCH= x86 +else +ifeq (arm,$(TARGET_LJARCH)) + ifeq (iOS,$(TARGET_SYS)) + DASM_AFLAGS+= -D IOS + endif +else +ifeq (ppc,$(TARGET_LJARCH)) + ifneq (,$(findstring LJ_ARCH_SQRT 1,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D SQRT + endif + ifneq (,$(findstring LJ_ARCH_ROUND 1,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D ROUND + endif + ifneq (,$(findstring LJ_ARCH_PPC64 1,$(TARGET_TESTARCH))) + DASM_AFLAGS+= -D GPR64 + endif + ifeq (PS3,$(TARGET_SYS)) + DASM_AFLAGS+= -D PPE -D TOC + endif +endif +endif +endif +endif + +DASM_FLAGS= $(DASM_XFLAGS) $(DASM_AFLAGS) +DASM_DASC= vm_$(DASM_ARCH).dasc + +BUILDVM_O= host/buildvm.o host/buildvm_asm.o host/buildvm_peobj.o \ + host/buildvm_lib.o host/buildvm_fold.o +BUILDVM_T= host/buildvm +BUILDVM_X= $(BUILDVM_T) + +HOST_O= $(MINILUA_O) $(BUILDVM_O) +HOST_T= $(MINILUA_T) $(BUILDVM_T) + +LJVM_S= lj_vm.s +LJVM_O= lj_vm.o +LJVM_BOUT= $(LJVM_S) +LJVM_MODE= elfasm + +LJLIB_O= lib_base.o lib_math.o lbitlib.o lib_bit.o lib_string.o lib_table.o \ + lib_io.o lib_os.o lib_package.o lib_debug.o lib_jit.o lib_ffi.o +LJLIB_C= $(LJLIB_O:.o=.c) + +LJCORE_O= lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o \ + lj_str.o lj_tab.o lj_func.o lj_udata.o lj_meta.o lj_debug.o \ + lj_state.o lj_dispatch.o lj_vmevent.o lj_vmmath.o lj_strscan.o \ + lj_api.o lj_lex.o lj_parse.o lj_bcread.o lj_bcwrite.o lj_load.o \ + lj_ir.o lj_opt_mem.o lj_opt_fold.o lj_opt_narrow.o \ + lj_opt_dce.o lj_opt_loop.o lj_opt_split.o lj_opt_sink.o \ + lj_mcode.o lj_snap.o lj_record.o lj_crecord.o lj_ffrecord.o \ + lj_asm.o lj_trace.o lj_gdbjit.o \ + lj_ctype.o lj_cdata.o lj_cconv.o lj_ccall.o lj_ccallback.o \ + lj_carith.o lj_clib.o lj_cparse.o \ + lj_lib.o lj_alloc.o lib_aux.o \ + $(LJLIB_O) lib_init.o + +LJVMCORE_O= $(LJVM_O) $(LJCORE_O) +LJVMCORE_DYNO= $(LJVMCORE_O:.o=_dyn.o) + +LIB_VMDEF= jit/vmdef.lua +LIB_VMDEFP= $(LIB_VMDEF) + +LUAJIT_O= luajit.o +LUAJIT_A= libluajit.a +LUAJIT_SO= libluajit.so +LUAJIT_T= luajit + +ALL_T= $(LUAJIT_T) $(LUAJIT_A) $(LUAJIT_SO) $(HOST_T) +ALL_HDRGEN= lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h \ + host/buildvm_arch.h +ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) $(LIB_VMDEFP) +WIN_RM= *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk +ALL_RM= $(ALL_T) $(ALL_GEN) *.o host/*.o $(WIN_RM) + +############################################################################## +# Build mode handling. +############################################################################## + +# Mixed mode defaults. +TARGET_O= $(LUAJIT_A) +TARGET_T= $(LUAJIT_T) $(LUAJIT_SO) +TARGET_DEP= $(LIB_VMDEF) $(LUAJIT_SO) + +ifeq (Windows,$(TARGET_SYS)) + TARGET_DYNCC= $(STATIC_CC) + LJVM_MODE= peobj + LJVM_BOUT= $(LJVM_O) + LUAJIT_T= luajit.exe + ifeq (cygwin,$(HOST_MSYS)) + LUAJIT_SO= cyg$(TARGET_DLLNAME) + else + LUAJIT_SO= $(TARGET_DLLNAME) + endif + # Mixed mode is not supported on Windows. And static mode doesn't work well. + # C modules cannot be loaded, because they bind to lua51.dll. + ifneq (static,$(BUILDMODE)) + BUILDMODE= dynamic + TARGET_XCFLAGS+= -DLUA_BUILD_AS_DLL + endif +endif +ifeq (Darwin,$(TARGET_SYS)) + LJVM_MODE= machasm +endif +ifeq (iOS,$(TARGET_SYS)) + LJVM_MODE= machasm +endif +ifeq (SunOS,$(TARGET_SYS)) + BUILDMODE= static +endif +ifeq (PS3,$(TARGET_SYS)) + BUILDMODE= static +endif + +ifeq (Windows,$(HOST_SYS)) + MINILUA_T= host/minilua.exe + BUILDVM_T= host/buildvm.exe + ifeq (,$(HOST_MSYS)) + MINILUA_X= host\minilua + BUILDVM_X= host\buildvm + ALL_RM:= $(subst /,\,$(ALL_RM)) + endif +endif + +ifeq (static,$(BUILDMODE)) + TARGET_DYNCC= @: + TARGET_T= $(LUAJIT_T) + TARGET_DEP= $(LIB_VMDEF) +else +ifeq (dynamic,$(BUILDMODE)) + ifneq (Windows,$(TARGET_SYS)) + TARGET_CC= $(DYNAMIC_CC) + endif + TARGET_DYNCC= @: + LJVMCORE_DYNO= $(LJVMCORE_O) + TARGET_O= $(LUAJIT_SO) + TARGET_XLDFLAGS+= $(TARGET_DYNXLDOPTS) +else +ifeq (Darwin,$(TARGET_SYS)) + TARGET_DYNCC= @: + LJVMCORE_DYNO= $(LJVMCORE_O) +endif +ifeq (iOS,$(TARGET_SYS)) + TARGET_DYNCC= @: + LJVMCORE_DYNO= $(LJVMCORE_O) +endif +endif +endif + +Q= @ +E= @echo +#Q= +#E= @: + +############################################################################## +# Make targets. +############################################################################## + +default all: $(TARGET_T) + +amalg: + @grep "^[+|]" ljamalg.c + $(MAKE) all "LJCORE_O=ljamalg.o" + +clean: + $(HOST_RM) $(ALL_RM) + +depend: + @for file in $(ALL_HDRGEN); do \ + test -f $$file || touch $$file; \ + done + @$(HOST_CC) $(HOST_ACFLAGS) -MM *.c host/*.c | \ + sed -e "s| [^ ]*/dasm_\S*\.h||g" \ + -e "s|^\([^l ]\)|host/\1|" \ + -e "s| lj_target_\S*\.h| lj_target_*.h|g" \ + -e "s| lj_emit_\S*\.h| lj_emit_*.h|g" \ + -e "s| lj_asm_\S*\.h| lj_asm_*.h|g" >Makefile.dep + @for file in $(ALL_HDRGEN); do \ + test -s $$file || $(HOST_RM) $$file; \ + done + +.PHONY: default all amalg clean depend + +############################################################################## +# Rules for generated files. +############################################################################## + +$(MINILUA_T): $(MINILUA_O) + $(E) "HOSTLINK $@" + $(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(MINILUA_O) $(MINILUA_LIBS) $(HOST_ALIBS) + +host/buildvm_arch.h: $(DASM_DASC) $(DASM_DEP) + $(E) "DYNASM $@" + $(Q)$(DASM) $(DASM_FLAGS) -o $@ $(DASM_DASC) + +host/buildvm.o: $(DASM_DIR)/dasm_*.h + +$(BUILDVM_T): $(BUILDVM_O) + $(E) "HOSTLINK $@" + $(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(BUILDVM_O) $(HOST_ALIBS) + +$(LJVM_BOUT): $(BUILDVM_T) + $(E) "BUILDVM $@" + $(Q)$(BUILDVM_X) -m $(LJVM_MODE) -o $@ + +lj_bcdef.h: $(BUILDVM_T) $(LJLIB_C) + $(E) "BUILDVM $@" + $(Q)$(BUILDVM_X) -m bcdef -o $@ $(LJLIB_C) + +lj_ffdef.h: $(BUILDVM_T) $(LJLIB_C) + $(E) "BUILDVM $@" + $(Q)$(BUILDVM_X) -m ffdef -o $@ $(LJLIB_C) + +lj_libdef.h: $(BUILDVM_T) $(LJLIB_C) + $(E) "BUILDVM $@" + $(Q)$(BUILDVM_X) -m libdef -o $@ $(LJLIB_C) + +lj_recdef.h: $(BUILDVM_T) $(LJLIB_C) + $(E) "BUILDVM $@" + $(Q)$(BUILDVM_X) -m recdef -o $@ $(LJLIB_C) + +$(LIB_VMDEF): $(BUILDVM_T) $(LJLIB_C) + $(E) "BUILDVM $@" + $(Q)$(BUILDVM_X) -m vmdef -o $(LIB_VMDEFP) $(LJLIB_C) + +lj_folddef.h: $(BUILDVM_T) lj_opt_fold.c + $(E) "BUILDVM $@" + $(Q)$(BUILDVM_X) -m folddef -o $@ lj_opt_fold.c + +############################################################################## +# Object file rules. +############################################################################## + +%.o: %.c + $(E) "CC $@" + $(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $< + $(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $< + +%.o: %.s + $(E) "ASM $@" + $(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $< + $(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $< + +$(LUAJIT_O): + $(E) "CC $@" + $(Q)$(TARGET_STCC) $(TARGET_ACFLAGS) -c -o $@ $< + +$(HOST_O): %.o: %.c + $(E) "HOSTCC $@" + $(Q)$(HOST_CC) $(HOST_ACFLAGS) -c -o $@ $< + +include Makefile.dep + +############################################################################## +# Target file rules. +############################################################################## + +$(LUAJIT_A): $(LJVMCORE_O) + $(E) "AR $@" + $(Q)$(TARGET_AR) $@ $(LJVMCORE_O) + +# The dependency on _O, but linking with _DYNO is intentional. +$(LUAJIT_SO): $(LJVMCORE_O) + $(E) "DYNLINK $@" + $(Q)$(TARGET_LD) $(TARGET_ASHLDFLAGS) -o $@ $(LJVMCORE_DYNO) $(TARGET_ALIBS) + $(Q)$(TARGET_STRIP) $@ + +$(LUAJIT_T): $(TARGET_O) $(LUAJIT_O) $(TARGET_DEP) + $(E) "LINK $@" + $(Q)$(TARGET_LD) $(TARGET_ALDFLAGS) -o $@ $(LUAJIT_O) $(TARGET_O) $(TARGET_ALIBS) + $(Q)$(TARGET_STRIP) $@ + $(E) "OK Successfully built LuaJIT" + +############################################################################## diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/Makefile.dep b/source/libs/luajit/LuaJIT-2.0.4/src/Makefile.dep new file mode 100644 index 000000000..17c524219 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/Makefile.dep @@ -0,0 +1,227 @@ +lib_aux.o: lib_aux.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \ + lj_arch.h lj_err.h lj_errmsg.h lj_state.h lj_trace.h lj_jit.h lj_ir.h \ + lj_dispatch.h lj_bc.h lj_traceerr.h lj_lib.h lj_alloc.h +lib_base.o: lib_base.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ + lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h \ + lj_tab.h lj_meta.h lj_state.h lj_ctype.h lj_cconv.h lj_bc.h lj_ff.h \ + lj_ffdef.h lj_dispatch.h lj_jit.h lj_ir.h lj_char.h lj_strscan.h \ + lj_lib.h lj_libdef.h +lbitlib.o: lbitlib.c lua.h luaconf.h lauxlib.h lualib.h +lib_bit.o: lib_bit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ + lj_arch.h lj_err.h lj_errmsg.h lj_str.h lj_lib.h lj_libdef.h +lib_debug.o: lib_debug.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ + lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_lib.h \ + lj_libdef.h +lib_ffi.o: lib_ffi.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ + lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h \ + lj_ctype.h lj_cparse.h lj_cdata.h lj_cconv.h lj_carith.h lj_ccall.h \ + lj_ccallback.h lj_clib.h lj_ff.h lj_ffdef.h lj_lib.h lj_libdef.h +lib_init.o: lib_init.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h +lib_io.o: lib_io.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ + lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_state.h lj_ff.h \ + lj_ffdef.h lj_lib.h lj_libdef.h +lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h \ + lj_obj.h lj_def.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h \ + lj_bc.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_target.h \ + lj_target_*.h lj_dispatch.h lj_vm.h lj_vmevent.h lj_lib.h luajit.h \ + lj_libdef.h +lib_math.o: lib_math.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ + lj_def.h lj_arch.h lj_lib.h lj_vm.h lj_libdef.h +lib_os.o: lib_os.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ + lj_arch.h lj_err.h lj_errmsg.h lj_lib.h lj_libdef.h +lib_package.o: lib_package.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ + lj_def.h lj_arch.h lj_err.h lj_errmsg.h lj_lib.h +lib_string.o: lib_string.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ + lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h \ + lj_meta.h lj_state.h lj_ff.h lj_ffdef.h lj_bcdump.h lj_lex.h lj_char.h \ + lj_lib.h lj_libdef.h +lib_table.o: lib_table.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ + lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_tab.h lj_lib.h \ + lj_libdef.h +lj_alloc.o: lj_alloc.c lj_def.h lua.h luaconf.h lj_arch.h lj_alloc.h +lj_api.o: lj_api.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_func.h lj_udata.h \ + lj_meta.h lj_state.h lj_bc.h lj_frame.h lj_trace.h lj_jit.h lj_ir.h \ + lj_dispatch.h lj_traceerr.h lj_vm.h lj_strscan.h +lj_asm.o: lj_asm.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ctype.h lj_ir.h lj_jit.h \ + lj_ircall.h lj_iropt.h lj_mcode.h lj_trace.h lj_dispatch.h lj_traceerr.h \ + lj_snap.h lj_asm.h lj_vm.h lj_target.h lj_target_*.h lj_emit_*.h \ + lj_asm_*.h +lj_bc.o: lj_bc.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_bc.h \ + lj_bcdef.h +lj_bcread.o: lj_bcread.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_bc.h lj_ctype.h \ + lj_cdata.h lualib.h lj_lex.h lj_bcdump.h lj_state.h +lj_bcwrite.o: lj_bcwrite.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_str.h lj_bc.h lj_ctype.h lj_dispatch.h lj_jit.h lj_ir.h \ + lj_bcdump.h lj_lex.h lj_err.h lj_errmsg.h lj_vm.h +lj_carith.o: lj_carith.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_tab.h lj_meta.h lj_ctype.h lj_cconv.h \ + lj_cdata.h lj_carith.h +lj_ccall.o: lj_ccall.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_cconv.h \ + lj_cdata.h lj_ccall.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_bc.h \ + lj_traceerr.h +lj_ccallback.o: lj_ccallback.c lj_obj.h lua.h luaconf.h lj_def.h \ + lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_tab.h lj_state.h lj_frame.h \ + lj_bc.h lj_ctype.h lj_cconv.h lj_ccall.h lj_ccallback.h lj_target.h \ + lj_target_*.h lj_mcode.h lj_jit.h lj_ir.h lj_trace.h lj_dispatch.h \ + lj_traceerr.h lj_vm.h +lj_cconv.o: lj_cconv.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_err.h lj_errmsg.h lj_tab.h lj_ctype.h lj_gc.h lj_cdata.h lj_cconv.h \ + lj_ccallback.h +lj_cdata.o: lj_cdata.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_cconv.h \ + lj_cdata.h +lj_char.o: lj_char.c lj_char.h lj_def.h lua.h luaconf.h +lj_clib.o: lj_clib.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_err.h lj_errmsg.h lj_tab.h lj_str.h lj_udata.h lj_ctype.h lj_cconv.h \ + lj_cdata.h lj_clib.h +lj_cparse.o: lj_cparse.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_ctype.h lj_cparse.h lj_frame.h \ + lj_bc.h lj_vm.h lj_char.h lj_strscan.h +lj_crecord.o: lj_crecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ctype.h \ + lj_gc.h lj_cdata.h lj_cparse.h lj_cconv.h lj_clib.h lj_ccall.h lj_ff.h \ + lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \ + lj_dispatch.h lj_traceerr.h lj_record.h lj_ffrecord.h lj_snap.h \ + lj_crecord.h +lj_ctype.o: lj_ctype.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_ccallback.h +lj_debug.o: lj_debug.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_state.h lj_frame.h \ + lj_bc.h lj_vm.h lj_jit.h lj_ir.h +lj_dispatch.o: lj_dispatch.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_err.h lj_errmsg.h lj_func.h lj_str.h lj_tab.h lj_meta.h lj_debug.h \ + lj_state.h lj_frame.h lj_bc.h lj_ff.h lj_ffdef.h lj_jit.h lj_ir.h \ + lj_ccallback.h lj_ctype.h lj_gc.h lj_trace.h lj_dispatch.h lj_traceerr.h \ + lj_vm.h luajit.h +lj_err.o: lj_err.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_err.h \ + lj_errmsg.h lj_debug.h lj_str.h lj_func.h lj_state.h lj_frame.h lj_bc.h \ + lj_ff.h lj_ffdef.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h \ + lj_traceerr.h lj_vm.h +lj_ffrecord.o: lj_ffrecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ff.h \ + lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \ + lj_dispatch.h lj_traceerr.h lj_record.h lj_ffrecord.h lj_crecord.h \ + lj_vm.h lj_strscan.h lj_recdef.h +lj_func.o: lj_func.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_func.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_bc.h \ + lj_traceerr.h lj_vm.h +lj_gc.o: lj_gc.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_udata.h lj_meta.h \ + lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_cdata.h lj_trace.h lj_jit.h \ + lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h +lj_gdbjit.o: lj_gdbjit.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_frame.h lj_bc.h lj_jit.h \ + lj_ir.h lj_dispatch.h +lj_ir.o: lj_ir.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \ + lj_dispatch.h lj_bc.h lj_traceerr.h lj_ctype.h lj_cdata.h lj_carith.h \ + lj_vm.h lj_strscan.h lj_lib.h +lj_lex.o: lj_lex.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_cdata.h lualib.h \ + lj_state.h lj_lex.h lj_parse.h lj_char.h lj_strscan.h +lj_lib.o: lj_lib.c lauxlib.h lua.h luaconf.h lj_obj.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_bc.h \ + lj_dispatch.h lj_jit.h lj_ir.h lj_vm.h lj_strscan.h lj_lib.h +lj_load.o: lj_load.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \ + lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_func.h lj_frame.h \ + lj_bc.h lj_vm.h lj_lex.h lj_bcdump.h lj_parse.h +lj_mcode.o: lj_mcode.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_jit.h lj_ir.h lj_mcode.h lj_trace.h \ + lj_dispatch.h lj_bc.h lj_traceerr.h lj_vm.h +lj_meta.o: lj_meta.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h lj_frame.h lj_bc.h \ + lj_vm.h lj_strscan.h +lj_obj.o: lj_obj.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h +lj_opt_dce.o: lj_opt_dce.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_ir.h lj_jit.h lj_iropt.h +lj_opt_fold.o: lj_opt_fold.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \ + lj_bc.h lj_traceerr.h lj_ctype.h lj_gc.h lj_carith.h lj_vm.h \ + lj_strscan.h lj_folddef.h +lj_opt_loop.o: lj_opt_loop.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_err.h lj_errmsg.h lj_str.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h \ + lj_dispatch.h lj_bc.h lj_traceerr.h lj_snap.h lj_vm.h +lj_opt_mem.o: lj_opt_mem.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_tab.h lj_ir.h lj_jit.h lj_iropt.h +lj_opt_narrow.o: lj_opt_narrow.c lj_obj.h lua.h luaconf.h lj_def.h \ + lj_arch.h lj_bc.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \ + lj_traceerr.h lj_vm.h lj_strscan.h +lj_opt_sink.o: lj_opt_sink.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_ir.h lj_jit.h lj_iropt.h lj_target.h lj_target_*.h +lj_opt_split.o: lj_opt_split.c lj_obj.h lua.h luaconf.h lj_def.h \ + lj_arch.h lj_err.h lj_errmsg.h lj_str.h lj_ir.h lj_jit.h lj_ircall.h \ + lj_iropt.h lj_vm.h +lj_parse.o: lj_parse.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_func.h \ + lj_state.h lj_bc.h lj_ctype.h lj_lex.h lj_parse.h lj_vm.h lj_vmevent.h +lj_record.o: lj_record.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h lj_frame.h lj_bc.h \ + lj_ctype.h lj_gc.h lj_ff.h lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h \ + lj_iropt.h lj_trace.h lj_dispatch.h lj_traceerr.h lj_record.h \ + lj_ffrecord.h lj_snap.h lj_vm.h +lj_snap.o: lj_snap.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_tab.h lj_state.h lj_frame.h lj_bc.h lj_ir.h lj_jit.h lj_iropt.h \ + lj_trace.h lj_dispatch.h lj_traceerr.h lj_snap.h lj_target.h \ + lj_target_*.h lj_ctype.h lj_cdata.h +lj_state.o: lj_state.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_meta.h \ + lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_trace.h lj_jit.h lj_ir.h \ + lj_dispatch.h lj_traceerr.h lj_vm.h lj_lex.h lj_alloc.h +lj_str.o: lj_str.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_err.h lj_errmsg.h lj_str.h lj_state.h lj_char.h +lj_strscan.o: lj_strscan.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_char.h lj_strscan.h +lj_tab.o: lj_tab.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_err.h lj_errmsg.h lj_tab.h +lj_trace.o: lj_trace.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_frame.h lj_bc.h \ + lj_state.h lj_ir.h lj_jit.h lj_iropt.h lj_mcode.h lj_trace.h \ + lj_dispatch.h lj_traceerr.h lj_snap.h lj_gdbjit.h lj_record.h lj_asm.h \ + lj_vm.h lj_vmevent.h lj_target.h lj_target_*.h +lj_udata.o: lj_udata.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_udata.h +lj_vmevent.o: lj_vmevent.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_str.h lj_tab.h lj_state.h lj_dispatch.h lj_bc.h lj_jit.h lj_ir.h \ + lj_vm.h lj_vmevent.h +lj_vmmath.o: lj_vmmath.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_ir.h lj_vm.h +ljamalg.o: ljamalg.c lua.h luaconf.h lauxlib.h lj_gc.c lj_obj.h lj_def.h \ + lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h \ + lj_udata.h lj_meta.h lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_cdata.h \ + lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h lj_err.c \ + lj_debug.h lj_ff.h lj_ffdef.h lj_char.c lj_char.h lj_bc.c lj_bcdef.h \ + lj_obj.c lj_str.c lj_tab.c lj_func.c lj_udata.c lj_meta.c lj_strscan.h \ + lj_debug.c lj_state.c lj_lex.h lj_alloc.h lj_dispatch.c lj_ccallback.h \ + luajit.h lj_vmevent.c lj_vmevent.h lj_vmmath.c lj_strscan.c lj_api.c \ + lj_lex.c lualib.h lj_parse.h lj_parse.c lj_bcread.c lj_bcdump.h \ + lj_bcwrite.c lj_load.c lj_ctype.c lj_cdata.c lj_cconv.h lj_cconv.c \ + lj_ccall.c lj_ccall.h lj_ccallback.c lj_target.h lj_target_*.h \ + lj_mcode.h lj_carith.c lj_carith.h lj_clib.c lj_clib.h lj_cparse.c \ + lj_cparse.h lj_lib.c lj_lib.h lj_ir.c lj_ircall.h lj_iropt.h \ + lj_opt_mem.c lj_opt_fold.c lj_folddef.h lj_opt_narrow.c lj_opt_dce.c \ + lj_opt_loop.c lj_snap.h lj_opt_split.c lj_opt_sink.c lj_mcode.c \ + lj_snap.c lj_record.c lj_record.h lj_ffrecord.h lj_crecord.c \ + lj_crecord.h lj_ffrecord.c lj_recdef.h lj_asm.c lj_asm.h lj_emit_*.h \ + lj_asm_*.h lj_trace.c lj_gdbjit.h lj_gdbjit.c lj_alloc.c lib_aux.c \ + lib_base.c lj_libdef.h lib_math.c lib_string.c lib_table.c lib_io.c \ + lib_os.c lib_package.c lib_debug.c lib_bit.c lib_jit.c lib_ffi.c \ + lib_init.c +luajit.o: luajit.c lua.h luaconf.h lauxlib.h lualib.h luajit.h lj_arch.h +host/buildvm.o: host/buildvm.c host/buildvm.h lj_def.h lua.h luaconf.h \ + lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_gc.h lj_obj.h lj_bc.h lj_ir.h \ + lj_ircall.h lj_ir.h lj_jit.h lj_frame.h lj_bc.h lj_dispatch.h lj_ctype.h \ + lj_gc.h lj_ccall.h lj_ctype.h luajit.h \ + host/buildvm_arch.h lj_traceerr.h +host/buildvm_asm.o: host/buildvm_asm.c host/buildvm.h lj_def.h lua.h luaconf.h \ + lj_arch.h lj_bc.h lj_def.h lj_arch.h +host/buildvm_fold.o: host/buildvm_fold.c host/buildvm.h lj_def.h lua.h \ + luaconf.h lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_ir.h lj_obj.h +host/buildvm_lib.o: host/buildvm_lib.c host/buildvm.h lj_def.h lua.h luaconf.h \ + lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_lib.h lj_obj.h +host/buildvm_peobj.o: host/buildvm_peobj.c host/buildvm.h lj_def.h lua.h \ + luaconf.h lj_arch.h lj_bc.h lj_def.h lj_arch.h +host/minilua.o: host/minilua.c diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/host/README b/source/libs/luajit/LuaJIT-2.0.4/src/host/README similarity index 100% rename from source/libs/luajit/LuaJIT-2.0.3/src/host/README rename to source/libs/luajit/LuaJIT-2.0.4/src/host/README diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm.c b/source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm.c new file mode 100644 index 000000000..11f666076 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm.c @@ -0,0 +1,516 @@ +/* +** LuaJIT VM builder. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** This is a tool to build the hand-tuned assembler code required for +** LuaJIT's bytecode interpreter. It supports a variety of output formats +** to feed different toolchains (see usage() below). +** +** This tool is not particularly optimized because it's only used while +** _building_ LuaJIT. There's no point in distributing or installing it. +** Only the object code generated by this tool is linked into LuaJIT. +** +** Caveat: some memory is not free'd, error handling is lazy. +** It's a one-shot tool -- any effort fixing this would be wasted. +*/ + +#include "buildvm.h" +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_bc.h" +#include "lj_ir.h" +#include "lj_ircall.h" +#include "lj_frame.h" +#include "lj_dispatch.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#include "lj_ccall.h" +#endif +#include "luajit.h" + +#if defined(_WIN32) +#include +#include +#endif + +/* ------------------------------------------------------------------------ */ + +/* DynASM glue definitions. */ +#define Dst ctx +#define Dst_DECL BuildCtx *ctx +#define Dst_REF (ctx->D) +#define DASM_CHECKS 1 + +#include "../dynasm/dasm_proto.h" + +/* Glue macros for DynASM. */ +static int collect_reloc(BuildCtx *ctx, uint8_t *addr, int idx, int type); + +#define DASM_EXTERN(ctx, addr, idx, type) \ + collect_reloc(ctx, addr, idx, type) + +/* ------------------------------------------------------------------------ */ + +/* Avoid trouble if cross-compiling for an x86 target. Speed doesn't matter. */ +#define DASM_ALIGNED_WRITES 1 + +/* Embed architecture-specific DynASM encoder. */ +#if LJ_TARGET_X86ORX64 +#include "../dynasm/dasm_x86.h" +#elif LJ_TARGET_ARM +#include "../dynasm/dasm_arm.h" +#elif LJ_TARGET_PPC +#include "../dynasm/dasm_ppc.h" +#elif LJ_TARGET_PPCSPE +#include "../dynasm/dasm_ppc.h" +#elif LJ_TARGET_MIPS +#include "../dynasm/dasm_mips.h" +#else +#error "No support for this architecture (yet)" +#endif + +/* Embed generated architecture-specific backend. */ +#include "buildvm_arch.h" + +/* ------------------------------------------------------------------------ */ + +void owrite(BuildCtx *ctx, const void *ptr, size_t sz) +{ + if (fwrite(ptr, 1, sz, ctx->fp) != sz) { + fprintf(stderr, "Error: cannot write to output file: %s\n", + strerror(errno)); + exit(1); + } +} + +/* ------------------------------------------------------------------------ */ + +/* Emit code as raw bytes. Only used for DynASM debugging. */ +static void emit_raw(BuildCtx *ctx) +{ + owrite(ctx, ctx->code, ctx->codesz); +} + +/* -- Build machine code -------------------------------------------------- */ + +static const char *sym_decorate(BuildCtx *ctx, + const char *prefix, const char *suffix) +{ + char name[256]; + char *p; +#if LJ_64 + const char *symprefix = ctx->mode == BUILD_machasm ? "_" : ""; +#elif LJ_TARGET_XBOX360 + const char *symprefix = ""; +#else + const char *symprefix = ctx->mode != BUILD_elfasm ? "_" : ""; +#endif + sprintf(name, "%s%s%s", symprefix, prefix, suffix); + p = strchr(name, '@'); + if (p) { +#if LJ_TARGET_X86ORX64 + if (!LJ_64 && (ctx->mode == BUILD_coffasm || ctx->mode == BUILD_peobj)) + name[0] = '@'; + else + *p = '\0'; +#elif ((LJ_TARGET_PPC && !LJ_TARGET_OSX) || LJ_TARGET_PPCSPE) && !LJ_TARGET_CONSOLE + /* Keep @plt. */ +#else + *p = '\0'; +#endif + } + p = (char *)malloc(strlen(name)+1); /* MSVC doesn't like strdup. */ + strcpy(p, name); + return p; +} + +#define NRELOCSYM (sizeof(extnames)/sizeof(extnames[0])-1) + +static int relocmap[NRELOCSYM]; + +/* Collect external relocations. */ +static int collect_reloc(BuildCtx *ctx, uint8_t *addr, int idx, int type) +{ + if (ctx->nreloc >= BUILD_MAX_RELOC) { + fprintf(stderr, "Error: too many relocations, increase BUILD_MAX_RELOC.\n"); + exit(1); + } + if (relocmap[idx] < 0) { + relocmap[idx] = ctx->nrelocsym; + ctx->relocsym[ctx->nrelocsym] = sym_decorate(ctx, "", extnames[idx]); + ctx->nrelocsym++; + } + ctx->reloc[ctx->nreloc].ofs = (int32_t)(addr - ctx->code); + ctx->reloc[ctx->nreloc].sym = relocmap[idx]; + ctx->reloc[ctx->nreloc].type = type; + ctx->nreloc++; +#if LJ_TARGET_XBOX360 + return (int)(ctx->code - addr) + 4; /* Encode symbol offset of .text. */ +#else + return 0; /* Encode symbol offset of 0. */ +#endif +} + +/* Naive insertion sort. Performance doesn't matter here. */ +static void sym_insert(BuildCtx *ctx, int32_t ofs, + const char *prefix, const char *suffix) +{ + ptrdiff_t i = ctx->nsym++; + while (i > 0) { + if (ctx->sym[i-1].ofs <= ofs) + break; + ctx->sym[i] = ctx->sym[i-1]; + i--; + } + ctx->sym[i].ofs = ofs; + ctx->sym[i].name = sym_decorate(ctx, prefix, suffix); +} + +/* Build the machine code. */ +static int build_code(BuildCtx *ctx) +{ + int status; + int i; + + /* Initialize DynASM structures. */ + ctx->nglob = GLOB__MAX; + ctx->glob = (void **)malloc(ctx->nglob*sizeof(void *)); + memset(ctx->glob, 0, ctx->nglob*sizeof(void *)); + ctx->nreloc = 0; + + ctx->globnames = globnames; + ctx->relocsym = (const char **)malloc(NRELOCSYM*sizeof(const char *)); + ctx->nrelocsym = 0; + for (i = 0; i < (int)NRELOCSYM; i++) relocmap[i] = -1; + + ctx->dasm_ident = DASM_IDENT; + ctx->dasm_arch = DASM_ARCH; + + dasm_init(Dst, DASM_MAXSECTION); + dasm_setupglobal(Dst, ctx->glob, ctx->nglob); + dasm_setup(Dst, build_actionlist); + + /* Call arch-specific backend to emit the code. */ + ctx->npc = build_backend(ctx); + + /* Finalize the code. */ + (void)dasm_checkstep(Dst, -1); + if ((status = dasm_link(Dst, &ctx->codesz))) return status; + ctx->code = (uint8_t *)malloc(ctx->codesz); + if ((status = dasm_encode(Dst, (void *)ctx->code))) return status; + + /* Allocate symbol table and bytecode offsets. */ + ctx->beginsym = sym_decorate(ctx, "", LABEL_PREFIX "vm_asm_begin"); + ctx->sym = (BuildSym *)malloc((ctx->npc+ctx->nglob+1)*sizeof(BuildSym)); + ctx->nsym = 0; + ctx->bc_ofs = (int32_t *)malloc(ctx->npc*sizeof(int32_t)); + + /* Collect the opcodes (PC labels). */ + for (i = 0; i < ctx->npc; i++) { + int32_t ofs = dasm_getpclabel(Dst, i); + if (ofs < 0) return 0x22000000|i; + ctx->bc_ofs[i] = ofs; + if ((LJ_HASJIT || + !(i == BC_JFORI || i == BC_JFORL || i == BC_JITERL || i == BC_JLOOP || + i == BC_IFORL || i == BC_IITERL || i == BC_ILOOP)) && + (LJ_HASFFI || i != BC_KCDATA)) + sym_insert(ctx, ofs, LABEL_PREFIX_BC, bc_names[i]); + } + + /* Collect the globals (named labels). */ + for (i = 0; i < ctx->nglob; i++) { + const char *gl = globnames[i]; + int len = (int)strlen(gl); + if (!ctx->glob[i]) { + fprintf(stderr, "Error: undefined global %s\n", gl); + exit(2); + } + /* Skip the _Z symbols. */ + if (!(len >= 2 && gl[len-2] == '_' && gl[len-1] == 'Z')) + sym_insert(ctx, (int32_t)((uint8_t *)(ctx->glob[i]) - ctx->code), + LABEL_PREFIX, globnames[i]); + } + + /* Close the address range. */ + sym_insert(ctx, (int32_t)ctx->codesz, "", ""); + ctx->nsym--; + + dasm_free(Dst); + + return 0; +} + +/* -- Generate VM enums --------------------------------------------------- */ + +const char *const bc_names[] = { +#define BCNAME(name, ma, mb, mc, mt) #name, +BCDEF(BCNAME) +#undef BCNAME + NULL +}; + +const char *const ir_names[] = { +#define IRNAME(name, m, m1, m2) #name, +IRDEF(IRNAME) +#undef IRNAME + NULL +}; + +const char *const irt_names[] = { +#define IRTNAME(name, size) #name, +IRTDEF(IRTNAME) +#undef IRTNAME + NULL +}; + +const char *const irfpm_names[] = { +#define FPMNAME(name) #name, +IRFPMDEF(FPMNAME) +#undef FPMNAME + NULL +}; + +const char *const irfield_names[] = { +#define FLNAME(name, ofs) #name, +IRFLDEF(FLNAME) +#undef FLNAME + NULL +}; + +const char *const ircall_names[] = { +#define IRCALLNAME(cond, name, nargs, kind, type, flags) #name, +IRCALLDEF(IRCALLNAME) +#undef IRCALLNAME + NULL +}; + +static const char *const trace_errors[] = { +#define TREDEF(name, msg) msg, +#include "lj_traceerr.h" + NULL +}; + +static const char *lower(char *buf, const char *s) +{ + char *p = buf; + while (*s) { + *p++ = (*s >= 'A' && *s <= 'Z') ? *s+0x20 : *s; + s++; + } + *p = '\0'; + return buf; +} + +/* Emit C source code for bytecode-related definitions. */ +static void emit_bcdef(BuildCtx *ctx) +{ + int i; + fprintf(ctx->fp, "/* This is a generated file. DO NOT EDIT! */\n\n"); + fprintf(ctx->fp, "LJ_DATADEF const uint16_t lj_bc_ofs[] = {\n"); + for (i = 0; i < ctx->npc; i++) { + if (i != 0) + fprintf(ctx->fp, ",\n"); + fprintf(ctx->fp, "%d", ctx->bc_ofs[i]); + } +} + +/* Emit VM definitions as Lua code for debug modules. */ +static void emit_vmdef(BuildCtx *ctx) +{ + char buf[80]; + int i; + fprintf(ctx->fp, "-- This is a generated file. DO NOT EDIT!\n\n"); + fprintf(ctx->fp, "module(...)\n\n"); + + fprintf(ctx->fp, "bcnames = \""); + for (i = 0; bc_names[i]; i++) fprintf(ctx->fp, "%-6s", bc_names[i]); + fprintf(ctx->fp, "\"\n\n"); + + fprintf(ctx->fp, "irnames = \""); + for (i = 0; ir_names[i]; i++) fprintf(ctx->fp, "%-6s", ir_names[i]); + fprintf(ctx->fp, "\"\n\n"); + + fprintf(ctx->fp, "irfpm = { [0]="); + for (i = 0; irfpm_names[i]; i++) + fprintf(ctx->fp, "\"%s\", ", lower(buf, irfpm_names[i])); + fprintf(ctx->fp, "}\n\n"); + + fprintf(ctx->fp, "irfield = { [0]="); + for (i = 0; irfield_names[i]; i++) { + char *p; + lower(buf, irfield_names[i]); + p = strchr(buf, '_'); + if (p) *p = '.'; + fprintf(ctx->fp, "\"%s\", ", buf); + } + fprintf(ctx->fp, "}\n\n"); + + fprintf(ctx->fp, "ircall = {\n[0]="); + for (i = 0; ircall_names[i]; i++) + fprintf(ctx->fp, "\"%s\",\n", ircall_names[i]); + fprintf(ctx->fp, "}\n\n"); + + fprintf(ctx->fp, "traceerr = {\n[0]="); + for (i = 0; trace_errors[i]; i++) + fprintf(ctx->fp, "\"%s\",\n", trace_errors[i]); + fprintf(ctx->fp, "}\n\n"); +} + +/* -- Argument parsing ---------------------------------------------------- */ + +/* Build mode names. */ +static const char *const modenames[] = { +#define BUILDNAME(name) #name, +BUILDDEF(BUILDNAME) +#undef BUILDNAME + NULL +}; + +/* Print usage information and exit. */ +static void usage(void) +{ + int i; + fprintf(stderr, LUAJIT_VERSION " VM builder.\n"); + fprintf(stderr, LUAJIT_COPYRIGHT ", " LUAJIT_URL "\n"); + fprintf(stderr, "Target architecture: " LJ_ARCH_NAME "\n\n"); + fprintf(stderr, "Usage: buildvm -m mode [-o outfile] [infiles...]\n\n"); + fprintf(stderr, "Available modes:\n"); + for (i = 0; i < BUILD__MAX; i++) + fprintf(stderr, " %s\n", modenames[i]); + exit(1); +} + +/* Parse the output mode name. */ +static BuildMode parsemode(const char *mode) +{ + int i; + for (i = 0; modenames[i]; i++) + if (!strcmp(mode, modenames[i])) + return (BuildMode)i; + usage(); + return (BuildMode)-1; +} + +/* Parse arguments. */ +static void parseargs(BuildCtx *ctx, char **argv) +{ + const char *a; + int i; + ctx->mode = (BuildMode)-1; + ctx->outname = "-"; + for (i = 1; (a = argv[i]) != NULL; i++) { + if (a[0] != '-') + break; + switch (a[1]) { + case '-': + if (a[2]) goto err; + i++; + goto ok; + case '\0': + goto ok; + case 'm': + i++; + if (a[2] || argv[i] == NULL) goto err; + ctx->mode = parsemode(argv[i]); + break; + case 'o': + i++; + if (a[2] || argv[i] == NULL) goto err; + ctx->outname = argv[i]; + break; + default: err: + usage(); + break; + } + } +ok: + ctx->args = argv+i; + if (ctx->mode == (BuildMode)-1) goto err; +} + +int main(int argc, char **argv) +{ + BuildCtx ctx_; + BuildCtx *ctx = &ctx_; + int status, binmode; + + if (sizeof(void *) != 4*LJ_32+8*LJ_64) { + fprintf(stderr,"Error: pointer size mismatch in cross-build.\n"); + fprintf(stderr,"Try: make HOST_CC=\"gcc -m32\" CROSS=...\n\n"); + return 1; + } + + UNUSED(argc); + parseargs(ctx, argv); + + if ((status = build_code(ctx))) { + fprintf(stderr,"Error: DASM error %08x\n", status); + return 1; + } + + switch (ctx->mode) { + case BUILD_peobj: + case BUILD_raw: + binmode = 1; + break; + default: + binmode = 0; + break; + } + + if (ctx->outname[0] == '-' && ctx->outname[1] == '\0') { + ctx->fp = stdout; +#if defined(_WIN32) + if (binmode) + _setmode(_fileno(stdout), _O_BINARY); /* Yuck. */ +#endif + } else if (!(ctx->fp = fopen(ctx->outname, binmode ? "wb" : "w"))) { + fprintf(stderr, "Error: cannot open output file '%s': %s\n", + ctx->outname, strerror(errno)); + exit(1); + } + + switch (ctx->mode) { + case BUILD_elfasm: + case BUILD_coffasm: + case BUILD_machasm: + emit_asm(ctx); + emit_asm_debug(ctx); + break; + case BUILD_peobj: + emit_peobj(ctx); + break; + case BUILD_raw: + emit_raw(ctx); + break; + case BUILD_bcdef: + emit_bcdef(ctx); + emit_lib(ctx); + break; + case BUILD_vmdef: + emit_vmdef(ctx); + emit_lib(ctx); + break; + case BUILD_ffdef: + case BUILD_libdef: + case BUILD_recdef: + emit_lib(ctx); + break; + case BUILD_folddef: + emit_fold(ctx); + break; + default: + break; + } + + fflush(ctx->fp); + if (ferror(ctx->fp)) { + fprintf(stderr, "Error: cannot write to output file: %s\n", + strerror(errno)); + exit(1); + } + fclose(ctx->fp); + + return 0; +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm.h b/source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm.h new file mode 100644 index 000000000..b26218502 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm.h @@ -0,0 +1,104 @@ +/* +** LuaJIT VM builder. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _BUILDVM_H +#define _BUILDVM_H + +#include +#include +#include +#include +#include + +#include "lj_def.h" +#include "lj_arch.h" + +/* Hardcoded limits. Increase as needed. */ +#define BUILD_MAX_RELOC 200 /* Max. number of relocations. */ +#define BUILD_MAX_FOLD 4096 /* Max. number of fold rules. */ + +/* Prefix for scanned library definitions. */ +#define LIBDEF_PREFIX "LJLIB_" + +/* Prefix for scanned fold definitions. */ +#define FOLDDEF_PREFIX "LJFOLD" + +/* Prefixes for generated labels. */ +#define LABEL_PREFIX "lj_" +#define LABEL_PREFIX_BC LABEL_PREFIX "BC_" +#define LABEL_PREFIX_FF LABEL_PREFIX "ff_" +#define LABEL_PREFIX_CF LABEL_PREFIX "cf_" +#define LABEL_PREFIX_FFH LABEL_PREFIX "ffh_" +#define LABEL_PREFIX_LIBCF LABEL_PREFIX "lib_cf_" +#define LABEL_PREFIX_LIBINIT LABEL_PREFIX "lib_init_" + +/* Forward declaration. */ +struct dasm_State; + +/* Build modes. */ +#define BUILDDEF(_) \ + _(elfasm) _(coffasm) _(machasm) _(peobj) _(raw) \ + _(bcdef) _(ffdef) _(libdef) _(recdef) _(vmdef) \ + _(folddef) + +typedef enum { +#define BUILDENUM(name) BUILD_##name, +BUILDDEF(BUILDENUM) +#undef BUILDENUM + BUILD__MAX +} BuildMode; + +/* Code relocation. */ +typedef struct BuildReloc { + int32_t ofs; + int sym; + int type; +} BuildReloc; + +typedef struct BuildSym { + const char *name; + int32_t ofs; +} BuildSym; + +/* Build context structure. */ +typedef struct BuildCtx { + /* DynASM state pointer. Should be first member. */ + struct dasm_State *D; + /* Parsed command line. */ + BuildMode mode; + FILE *fp; + const char *outname; + char **args; + /* Code and symbols generated by DynASM. */ + uint8_t *code; + size_t codesz; + int npc, nglob, nsym, nreloc, nrelocsym; + void **glob; + BuildSym *sym; + const char **relocsym; + int32_t *bc_ofs; + const char *beginsym; + /* Strings generated by DynASM. */ + const char *const *globnames; + const char *dasm_ident; + const char *dasm_arch; + /* Relocations. */ + BuildReloc reloc[BUILD_MAX_RELOC]; +} BuildCtx; + +extern void owrite(BuildCtx *ctx, const void *ptr, size_t sz); +extern void emit_asm(BuildCtx *ctx); +extern void emit_peobj(BuildCtx *ctx); +extern void emit_lib(BuildCtx *ctx); +extern void emit_fold(BuildCtx *ctx); + +extern const char *const bc_names[]; +extern const char *const ir_names[]; +extern const char *const irt_names[]; +extern const char *const irfpm_names[]; +extern const char *const irfield_names[]; +extern const char *const ircall_names[]; + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm_asm.c b/source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm_asm.c new file mode 100644 index 000000000..2c9a2d482 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm_asm.c @@ -0,0 +1,313 @@ +/* +** LuaJIT VM builder: Assembler source code emitter. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "buildvm.h" +#include "lj_bc.h" + +/* ------------------------------------------------------------------------ */ + +#if LJ_TARGET_X86ORX64 +/* Emit bytes piecewise as assembler text. */ +static void emit_asm_bytes(BuildCtx *ctx, uint8_t *p, int n) +{ + int i; + for (i = 0; i < n; i++) { + if ((i & 15) == 0) + fprintf(ctx->fp, "\t.byte %d", p[i]); + else + fprintf(ctx->fp, ",%d", p[i]); + if ((i & 15) == 15) putc('\n', ctx->fp); + } + if ((n & 15) != 0) putc('\n', ctx->fp); +} + +/* Emit relocation */ +static void emit_asm_reloc(BuildCtx *ctx, int type, const char *sym) +{ + switch (ctx->mode) { + case BUILD_elfasm: + if (type) + fprintf(ctx->fp, "\t.long %s-.-4\n", sym); + else + fprintf(ctx->fp, "\t.long %s\n", sym); + break; + case BUILD_coffasm: + fprintf(ctx->fp, "\t.def %s; .scl 3; .type 32; .endef\n", sym); + if (type) + fprintf(ctx->fp, "\t.long %s-.-4\n", sym); + else + fprintf(ctx->fp, "\t.long %s\n", sym); + break; + default: /* BUILD_machasm for relative relocations handled below. */ + fprintf(ctx->fp, "\t.long %s\n", sym); + break; + } +} + +static const char *const jccnames[] = { + "jo", "jno", "jb", "jnb", "jz", "jnz", "jbe", "ja", + "js", "jns", "jpe", "jpo", "jl", "jge", "jle", "jg" +}; + +/* Emit relocation for the incredibly stupid OSX assembler. */ +static void emit_asm_reloc_mach(BuildCtx *ctx, uint8_t *cp, int n, + const char *sym) +{ + const char *opname = NULL; + if (--n < 0) goto err; + if (cp[n] == 0xe8) { + opname = "call"; + } else if (cp[n] == 0xe9) { + opname = "jmp"; + } else if (cp[n] >= 0x80 && cp[n] <= 0x8f && n > 0 && cp[n-1] == 0x0f) { + opname = jccnames[cp[n]-0x80]; + n--; + } else { +err: + fprintf(stderr, "Error: unsupported opcode for %s symbol relocation.\n", + sym); + exit(1); + } + emit_asm_bytes(ctx, cp, n); + fprintf(ctx->fp, "\t%s %s\n", opname, sym); +} +#else +/* Emit words piecewise as assembler text. */ +static void emit_asm_words(BuildCtx *ctx, uint8_t *p, int n) +{ + int i; + for (i = 0; i < n; i += 4) { + if ((i & 15) == 0) + fprintf(ctx->fp, "\t.long 0x%08x", *(uint32_t *)(p+i)); + else + fprintf(ctx->fp, ",0x%08x", *(uint32_t *)(p+i)); + if ((i & 15) == 12) putc('\n', ctx->fp); + } + if ((n & 15) != 0) putc('\n', ctx->fp); +} + +/* Emit relocation as part of an instruction. */ +static void emit_asm_wordreloc(BuildCtx *ctx, uint8_t *p, int n, + const char *sym) +{ + uint32_t ins; + emit_asm_words(ctx, p, n-4); + ins = *(uint32_t *)(p+n-4); +#if LJ_TARGET_ARM + if ((ins & 0xff000000u) == 0xfa000000u) { + fprintf(ctx->fp, "\tblx %s\n", sym); + } else if ((ins & 0x0e000000u) == 0x0a000000u) { + fprintf(ctx->fp, "\t%s%.2s %s\n", (ins & 0x01000000u) ? "bl" : "b", + &"eqnecsccmiplvsvchilsgeltgtle"[2*(ins >> 28)], sym); + } else { + fprintf(stderr, + "Error: unsupported opcode %08x for %s symbol relocation.\n", + ins, sym); + exit(1); + } +#elif LJ_TARGET_PPC || LJ_TARGET_PPCSPE +#if LJ_TARGET_PS3 +#define TOCPREFIX "." +#else +#define TOCPREFIX "" +#endif + if ((ins >> 26) == 16) { + fprintf(ctx->fp, "\t%s %d, %d, " TOCPREFIX "%s\n", + (ins & 1) ? "bcl" : "bc", (ins >> 21) & 31, (ins >> 16) & 31, sym); + } else if ((ins >> 26) == 18) { + fprintf(ctx->fp, "\t%s " TOCPREFIX "%s\n", (ins & 1) ? "bl" : "b", sym); + } else { + fprintf(stderr, + "Error: unsupported opcode %08x for %s symbol relocation.\n", + ins, sym); + exit(1); + } +#elif LJ_TARGET_MIPS + fprintf(stderr, + "Error: unsupported opcode %08x for %s symbol relocation.\n", + ins, sym); + exit(1); +#else +#error "missing relocation support for this architecture" +#endif +} +#endif + +#if LJ_TARGET_ARM +#define ELFASM_PX "%%" +#else +#define ELFASM_PX "@" +#endif + +/* Emit an assembler label. */ +static void emit_asm_label(BuildCtx *ctx, const char *name, int size, int isfunc) +{ + switch (ctx->mode) { + case BUILD_elfasm: +#if LJ_TARGET_PS3 + if (!strncmp(name, "lj_vm_", 6) && + strcmp(name, ctx->beginsym) && + !strstr(name, "hook")) { + fprintf(ctx->fp, + "\n\t.globl %s\n" + "\t.section \".opd\",\"aw\"\n" + "%s:\n" + "\t.long .%s,.TOC.@tocbase32\n" + "\t.size %s,8\n" + "\t.previous\n" + "\t.globl .%s\n" + "\t.hidden .%s\n" + "\t.type .%s, " ELFASM_PX "function\n" + "\t.size .%s, %d\n" + ".%s:\n", + name, name, name, name, name, name, name, name, size, name); + break; + } +#endif + fprintf(ctx->fp, + "\n\t.globl %s\n" + "\t.hidden %s\n" + "\t.type %s, " ELFASM_PX "%s\n" + "\t.size %s, %d\n" + "%s:\n", + name, name, name, isfunc ? "function" : "object", name, size, name); + break; + case BUILD_coffasm: + fprintf(ctx->fp, "\n\t.globl %s\n", name); + if (isfunc) + fprintf(ctx->fp, "\t.def %s; .scl 3; .type 32; .endef\n", name); + fprintf(ctx->fp, "%s:\n", name); + break; + case BUILD_machasm: + fprintf(ctx->fp, + "\n\t.private_extern %s\n" + "%s:\n", name, name); + break; + default: + break; + } +} + +/* Emit alignment. */ +static void emit_asm_align(BuildCtx *ctx, int bits) +{ + switch (ctx->mode) { + case BUILD_elfasm: + case BUILD_coffasm: + fprintf(ctx->fp, "\t.p2align %d\n", bits); + break; + case BUILD_machasm: + fprintf(ctx->fp, "\t.align %d\n", bits); + break; + default: + break; + } +} + +/* ------------------------------------------------------------------------ */ + +/* Emit assembler source code. */ +void emit_asm(BuildCtx *ctx) +{ + int i, rel; + + fprintf(ctx->fp, "\t.file \"buildvm_%s.dasc\"\n", ctx->dasm_arch); + fprintf(ctx->fp, "\t.text\n"); + emit_asm_align(ctx, 4); + +#if LJ_TARGET_PS3 + emit_asm_label(ctx, ctx->beginsym, ctx->codesz, 0); +#else + emit_asm_label(ctx, ctx->beginsym, 0, 0); +#endif + if (ctx->mode != BUILD_machasm) + fprintf(ctx->fp, ".Lbegin:\n"); + +#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND + /* This should really be moved into buildvm_arm.dasc. */ + fprintf(ctx->fp, + ".fnstart\n" + ".save {r4, r5, r6, r7, r8, r9, r10, r11, lr}\n" + ".pad #28\n"); +#endif +#if LJ_TARGET_MIPS + fprintf(ctx->fp, ".set nomips16\n.abicalls\n.set noreorder\n.set nomacro\n"); +#endif + + for (i = rel = 0; i < ctx->nsym; i++) { + int32_t ofs = ctx->sym[i].ofs; + int32_t next = ctx->sym[i+1].ofs; +#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND && LJ_HASFFI + if (!strcmp(ctx->sym[i].name, "lj_vm_ffi_call")) + fprintf(ctx->fp, + ".globl lj_err_unwind_arm\n" + ".personality lj_err_unwind_arm\n" + ".fnend\n" + ".fnstart\n" + ".save {r4, r5, r11, lr}\n" + ".setfp r11, sp\n"); +#endif + emit_asm_label(ctx, ctx->sym[i].name, next - ofs, 1); + while (rel < ctx->nreloc && ctx->reloc[rel].ofs <= next) { + BuildReloc *r = &ctx->reloc[rel]; + int n = r->ofs - ofs; +#if LJ_TARGET_X86ORX64 + if (ctx->mode == BUILD_machasm && r->type != 0) { + emit_asm_reloc_mach(ctx, ctx->code+ofs, n, ctx->relocsym[r->sym]); + } else { + emit_asm_bytes(ctx, ctx->code+ofs, n); + emit_asm_reloc(ctx, r->type, ctx->relocsym[r->sym]); + } + ofs += n+4; +#else + emit_asm_wordreloc(ctx, ctx->code+ofs, n, ctx->relocsym[r->sym]); + ofs += n; +#endif + rel++; + } +#if LJ_TARGET_X86ORX64 + emit_asm_bytes(ctx, ctx->code+ofs, next-ofs); +#else + emit_asm_words(ctx, ctx->code+ofs, next-ofs); +#endif + } + +#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND + fprintf(ctx->fp, +#if !LJ_HASFFI + ".globl lj_err_unwind_arm\n" + ".personality lj_err_unwind_arm\n" +#endif + ".fnend\n"); +#endif + + fprintf(ctx->fp, "\n"); + switch (ctx->mode) { + case BUILD_elfasm: +#if !(LJ_TARGET_PS3 || LJ_TARGET_PSVITA) + fprintf(ctx->fp, "\t.section .note.GNU-stack,\"\"," ELFASM_PX "progbits\n"); +#endif +#if LJ_TARGET_PPCSPE + /* Soft-float ABI + SPE. */ + fprintf(ctx->fp, "\t.gnu_attribute 4, 2\n\t.gnu_attribute 8, 3\n"); +#elif LJ_TARGET_PPC && !LJ_TARGET_PS3 + /* Hard-float ABI. */ + fprintf(ctx->fp, "\t.gnu_attribute 4, 1\n"); +#endif + /* fallthrough */ + case BUILD_coffasm: + fprintf(ctx->fp, "\t.ident \"%s\"\n", ctx->dasm_ident); + break; + case BUILD_machasm: + fprintf(ctx->fp, + "\t.cstring\n" + "\t.ascii \"%s\\0\"\n", ctx->dasm_ident); + break; + default: + break; + } + fprintf(ctx->fp, "\n"); +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm_fold.c b/source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm_fold.c new file mode 100644 index 000000000..daed7eccb --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm_fold.c @@ -0,0 +1,229 @@ +/* +** LuaJIT VM builder: IR folding hash table generator. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "buildvm.h" +#include "lj_obj.h" +#include "lj_ir.h" + +/* Context for the folding hash table generator. */ +static int lineno; +static int funcidx; +static uint32_t foldkeys[BUILD_MAX_FOLD]; +static uint32_t nkeys; + +/* Try to fill the hash table with keys using the hash parameters. */ +static int tryhash(uint32_t *htab, uint32_t sz, uint32_t r, int dorol) +{ + uint32_t i; + if (dorol && ((r & 31) == 0 || (r>>5) == 0)) + return 0; /* Avoid zero rotates. */ + memset(htab, 0xff, (sz+1)*sizeof(uint32_t)); + for (i = 0; i < nkeys; i++) { + uint32_t key = foldkeys[i]; + uint32_t k = key & 0xffffff; + uint32_t h = (dorol ? lj_rol(lj_rol(k, r>>5) - k, r&31) : + (((k << (r>>5)) - k) << (r&31))) % sz; + if (htab[h] != 0xffffffff) { /* Collision on primary slot. */ + if (htab[h+1] != 0xffffffff) { /* Collision on secondary slot. */ + /* Try to move the colliding key, if possible. */ + if (h < sz-1 && htab[h+2] == 0xffffffff) { + uint32_t k2 = htab[h+1] & 0xffffff; + uint32_t h2 = (dorol ? lj_rol(lj_rol(k2, r>>5) - k2, r&31) : + (((k2 << (r>>5)) - k2) << (r&31))) % sz; + if (h2 != h+1) return 0; /* Cannot resolve collision. */ + htab[h+2] = htab[h+1]; /* Move colliding key to secondary slot. */ + } else { + return 0; /* Collision. */ + } + } + htab[h+1] = key; + } else { + htab[h] = key; + } + } + return 1; /* Success, all keys could be stored. */ +} + +/* Print the generated hash table. */ +static void printhash(BuildCtx *ctx, uint32_t *htab, uint32_t sz) +{ + uint32_t i; + fprintf(ctx->fp, "static const uint32_t fold_hash[%d] = {\n0x%08x", + sz+1, htab[0]); + for (i = 1; i < sz+1; i++) + fprintf(ctx->fp, ",\n0x%08x", htab[i]); + fprintf(ctx->fp, "\n};\n\n"); +} + +/* Exhaustive search for the shortest semi-perfect hash table. */ +static void makehash(BuildCtx *ctx) +{ + uint32_t htab[BUILD_MAX_FOLD*2+1]; + uint32_t sz, r; + /* Search for the smallest hash table with an odd size. */ + for (sz = (nkeys|1); sz < BUILD_MAX_FOLD*2; sz += 2) { + /* First try all shift hash combinations. */ + for (r = 0; r < 32*32; r++) { + if (tryhash(htab, sz, r, 0)) { + printhash(ctx, htab, sz); + fprintf(ctx->fp, + "#define fold_hashkey(k)\t(((((k)<<%u)-(k))<<%u)%%%u)\n\n", + r>>5, r&31, sz); + return; + } + } + /* Then try all rotate hash combinations. */ + for (r = 0; r < 32*32; r++) { + if (tryhash(htab, sz, r, 1)) { + printhash(ctx, htab, sz); + fprintf(ctx->fp, + "#define fold_hashkey(k)\t(lj_rol(lj_rol((k),%u)-(k),%u)%%%u)\n\n", + r>>5, r&31, sz); + return; + } + } + } + fprintf(stderr, "Error: search for perfect hash failed\n"); + exit(1); +} + +/* Parse one token of a fold rule. */ +static uint32_t nexttoken(char **pp, int allowlit, int allowany) +{ + char *p = *pp; + if (p) { + uint32_t i; + char *q = strchr(p, ' '); + if (q) *q++ = '\0'; + *pp = q; + if (allowlit && !strncmp(p, "IRFPM_", 6)) { + for (i = 0; irfpm_names[i]; i++) + if (!strcmp(irfpm_names[i], p+6)) + return i; + } else if (allowlit && !strncmp(p, "IRFL_", 5)) { + for (i = 0; irfield_names[i]; i++) + if (!strcmp(irfield_names[i], p+5)) + return i; + } else if (allowlit && !strncmp(p, "IRCALL_", 7)) { + for (i = 0; ircall_names[i]; i++) + if (!strcmp(ircall_names[i], p+7)) + return i; + } else if (allowlit && !strncmp(p, "IRCONV_", 7)) { + for (i = 0; irt_names[i]; i++) { + const char *r = strchr(p+7, '_'); + if (r && !strncmp(irt_names[i], p+7, r-(p+7))) { + uint32_t j; + for (j = 0; irt_names[j]; j++) + if (!strcmp(irt_names[j], r+1)) + return (i << 5) + j; + } + } + } else if (allowlit && *p >= '0' && *p <= '9') { + for (i = 0; *p >= '0' && *p <= '9'; p++) + i = i*10 + (*p - '0'); + if (*p == '\0') + return i; + } else if (allowany && !strcmp("any", p)) { + return allowany; + } else { + for (i = 0; ir_names[i]; i++) + if (!strcmp(ir_names[i], p)) + return i; + } + fprintf(stderr, "Error: bad fold definition token \"%s\" at line %d\n", p, lineno); + exit(1); + } + return 0; +} + +/* Parse a fold rule. */ +static void foldrule(char *p) +{ + uint32_t op = nexttoken(&p, 0, 0); + uint32_t left = nexttoken(&p, 0, 0x7f); + uint32_t right = nexttoken(&p, 1, 0x3ff); + uint32_t key = (funcidx << 24) | (op << 17) | (left << 10) | right; + uint32_t i; + if (nkeys >= BUILD_MAX_FOLD) { + fprintf(stderr, "Error: too many fold rules, increase BUILD_MAX_FOLD.\n"); + exit(1); + } + /* Simple insertion sort to detect duplicates. */ + for (i = nkeys; i > 0; i--) { + if ((foldkeys[i-1]&0xffffff) < (key & 0xffffff)) + break; + if ((foldkeys[i-1]&0xffffff) == (key & 0xffffff)) { + fprintf(stderr, "Error: duplicate fold definition at line %d\n", lineno); + exit(1); + } + foldkeys[i] = foldkeys[i-1]; + } + foldkeys[i] = key; + nkeys++; +} + +/* Emit C source code for IR folding hash table. */ +void emit_fold(BuildCtx *ctx) +{ + char buf[256]; /* We don't care about analyzing lines longer than that. */ + const char *fname = ctx->args[0]; + FILE *fp; + + if (fname == NULL) { + fprintf(stderr, "Error: missing input filename\n"); + exit(1); + } + + if (fname[0] == '-' && fname[1] == '\0') { + fp = stdin; + } else { + fp = fopen(fname, "r"); + if (!fp) { + fprintf(stderr, "Error: cannot open input file '%s': %s\n", + fname, strerror(errno)); + exit(1); + } + } + + fprintf(ctx->fp, "/* This is a generated file. DO NOT EDIT! */\n\n"); + fprintf(ctx->fp, "static const FoldFunc fold_func[] = {\n"); + + lineno = 0; + funcidx = 0; + nkeys = 0; + while (fgets(buf, sizeof(buf), fp) != NULL) { + lineno++; + /* The prefix must be at the start of a line, otherwise it's ignored. */ + if (!strncmp(buf, FOLDDEF_PREFIX, sizeof(FOLDDEF_PREFIX)-1)) { + char *p = buf+sizeof(FOLDDEF_PREFIX)-1; + char *q = strchr(p, ')'); + if (p[0] == '(' && q) { + p++; + *q = '\0'; + foldrule(p); + } else if ((p[0] == 'F' || p[0] == 'X') && p[1] == '(' && q) { + p += 2; + *q = '\0'; + if (funcidx) + fprintf(ctx->fp, ",\n"); + if (p[-2] == 'X') + fprintf(ctx->fp, " %s", p); + else + fprintf(ctx->fp, " fold_%s", p); + funcidx++; + } else { + buf[strlen(buf)-1] = '\0'; + fprintf(stderr, "Error: unknown fold definition tag %s%s at line %d\n", + FOLDDEF_PREFIX, p, lineno); + exit(1); + } + } + } + fclose(fp); + fprintf(ctx->fp, "\n};\n\n"); + + makehash(ctx); +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm_lib.c b/source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm_lib.c new file mode 100644 index 000000000..c37301d46 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm_lib.c @@ -0,0 +1,398 @@ +/* +** LuaJIT VM builder: library definition compiler. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "buildvm.h" +#include "lj_obj.h" +#include "lj_lib.h" + +/* Context for library definitions. */ +static uint8_t obuf[8192]; +static uint8_t *optr; +static char modname[80]; +static size_t modnamelen; +static char funcname[80]; +static int modstate, regfunc; +static int ffid, recffid, ffasmfunc; + +enum { + REGFUNC_OK, + REGFUNC_NOREG, + REGFUNC_NOREGUV +}; + +static void libdef_name(const char *p, int kind) +{ + size_t n = strlen(p); + if (kind != LIBINIT_STRING) { + if (n > modnamelen && p[modnamelen] == '_' && + !strncmp(p, modname, modnamelen)) { + p += modnamelen+1; + n -= modnamelen+1; + } + } + if (n > LIBINIT_MAXSTR) { + fprintf(stderr, "Error: string too long: '%s'\n", p); + exit(1); + } + if (optr+1+n+2 > obuf+sizeof(obuf)) { /* +2 for caller. */ + fprintf(stderr, "Error: output buffer overflow\n"); + exit(1); + } + *optr++ = (uint8_t)(n | kind); + memcpy(optr, p, n); + optr += n; +} + +static void libdef_endmodule(BuildCtx *ctx) +{ + if (modstate != 0) { + char line[80]; + const uint8_t *p; + int n; + if (modstate == 1) + fprintf(ctx->fp, " (lua_CFunction)0"); + fprintf(ctx->fp, "\n};\n"); + fprintf(ctx->fp, "static const uint8_t %s%s[] = {\n", + LABEL_PREFIX_LIBINIT, modname); + line[0] = '\0'; + for (n = 0, p = obuf; p < optr; p++) { + n += sprintf(line+n, "%d,", *p); + if (n >= 75) { + fprintf(ctx->fp, "%s\n", line); + n = 0; + line[0] = '\0'; + } + } + fprintf(ctx->fp, "%s%d\n};\n#endif\n\n", line, LIBINIT_END); + } +} + +static void libdef_module(BuildCtx *ctx, char *p, int arg) +{ + UNUSED(arg); + if (ctx->mode == BUILD_libdef) { + libdef_endmodule(ctx); + optr = obuf; + *optr++ = (uint8_t)ffid; + *optr++ = (uint8_t)ffasmfunc; + *optr++ = 0; /* Hash table size. */ + modstate = 1; + fprintf(ctx->fp, "#ifdef %sMODULE_%s\n", LIBDEF_PREFIX, p); + fprintf(ctx->fp, "#undef %sMODULE_%s\n", LIBDEF_PREFIX, p); + fprintf(ctx->fp, "static const lua_CFunction %s%s[] = {\n", + LABEL_PREFIX_LIBCF, p); + } + modnamelen = strlen(p); + if (modnamelen > sizeof(modname)-1) { + fprintf(stderr, "Error: module name too long: '%s'\n", p); + exit(1); + } + strcpy(modname, p); +} + +static int find_ffofs(BuildCtx *ctx, const char *name) +{ + int i; + for (i = 0; i < ctx->nglob; i++) { + const char *gl = ctx->globnames[i]; + if (gl[0] == 'f' && gl[1] == 'f' && gl[2] == '_' && !strcmp(gl+3, name)) { + return (int)((uint8_t *)ctx->glob[i] - ctx->code); + } + } + fprintf(stderr, "Error: undefined fast function %s%s\n", + LABEL_PREFIX_FF, name); + exit(1); +} + +static void libdef_func(BuildCtx *ctx, char *p, int arg) +{ + if (arg != LIBINIT_CF) + ffasmfunc++; + if (ctx->mode == BUILD_libdef) { + if (modstate == 0) { + fprintf(stderr, "Error: no module for function definition %s\n", p); + exit(1); + } + if (regfunc == REGFUNC_NOREG) { + if (optr+1 > obuf+sizeof(obuf)) { + fprintf(stderr, "Error: output buffer overflow\n"); + exit(1); + } + *optr++ = LIBINIT_FFID; + } else { + if (arg != LIBINIT_ASM_) { + if (modstate != 1) fprintf(ctx->fp, ",\n"); + modstate = 2; + fprintf(ctx->fp, " %s%s", arg ? LABEL_PREFIX_FFH : LABEL_PREFIX_CF, p); + } + if (regfunc != REGFUNC_NOREGUV) obuf[2]++; /* Bump hash table size. */ + libdef_name(regfunc == REGFUNC_NOREGUV ? "" : p, arg); + } + } else if (ctx->mode == BUILD_ffdef) { + fprintf(ctx->fp, "FFDEF(%s)\n", p); + } else if (ctx->mode == BUILD_recdef) { + if (strlen(p) > sizeof(funcname)-1) { + fprintf(stderr, "Error: function name too long: '%s'\n", p); + exit(1); + } + strcpy(funcname, p); + } else if (ctx->mode == BUILD_vmdef) { + int i; + for (i = 1; p[i] && modname[i-1]; i++) + if (p[i] == '_') p[i] = '.'; + fprintf(ctx->fp, "\"%s\",\n", p); + } else if (ctx->mode == BUILD_bcdef) { + if (arg != LIBINIT_CF) + fprintf(ctx->fp, ",\n%d", find_ffofs(ctx, p)); + } + ffid++; + regfunc = REGFUNC_OK; +} + +static uint32_t find_rec(char *name) +{ + char *p = (char *)obuf; + uint32_t n; + for (n = 2; *p; n++) { + if (strcmp(p, name) == 0) + return n; + p += strlen(p)+1; + } + if (p+strlen(name)+1 >= (char *)obuf+sizeof(obuf)) { + fprintf(stderr, "Error: output buffer overflow\n"); + exit(1); + } + strcpy(p, name); + return n; +} + +static void libdef_rec(BuildCtx *ctx, char *p, int arg) +{ + UNUSED(arg); + if (ctx->mode == BUILD_recdef) { + char *q; + uint32_t n; + for (; recffid+1 < ffid; recffid++) + fprintf(ctx->fp, ",\n0"); + recffid = ffid; + if (*p == '.') p = funcname; + q = strchr(p, ' '); + if (q) *q++ = '\0'; + n = find_rec(p); + if (q) + fprintf(ctx->fp, ",\n0x%02x00+(%s)", n, q); + else + fprintf(ctx->fp, ",\n0x%02x00", n); + } +} + +static void memcpy_endian(void *dst, void *src, size_t n) +{ + union { uint8_t b; uint32_t u; } host_endian; + host_endian.u = 1; + if (host_endian.b == LJ_ENDIAN_SELECT(1, 0)) { + memcpy(dst, src, n); + } else { + size_t i; + for (i = 0; i < n; i++) + ((uint8_t *)dst)[i] = ((uint8_t *)src)[n-i-1]; + } +} + +static void libdef_push(BuildCtx *ctx, char *p, int arg) +{ + UNUSED(arg); + if (ctx->mode == BUILD_libdef) { + int len = (int)strlen(p); + if (*p == '"') { + if (len > 1 && p[len-1] == '"') { + p[len-1] = '\0'; + libdef_name(p+1, LIBINIT_STRING); + return; + } + } else if (*p >= '0' && *p <= '9') { + char *ep; + double d = strtod(p, &ep); + if (*ep == '\0') { + if (optr+1+sizeof(double) > obuf+sizeof(obuf)) { + fprintf(stderr, "Error: output buffer overflow\n"); + exit(1); + } + *optr++ = LIBINIT_NUMBER; + memcpy_endian(optr, &d, sizeof(double)); + optr += sizeof(double); + return; + } + } else if (!strcmp(p, "lastcl")) { + if (optr+1 > obuf+sizeof(obuf)) { + fprintf(stderr, "Error: output buffer overflow\n"); + exit(1); + } + *optr++ = LIBINIT_LASTCL; + return; + } else if (len > 4 && !strncmp(p, "top-", 4)) { + if (optr+2 > obuf+sizeof(obuf)) { + fprintf(stderr, "Error: output buffer overflow\n"); + exit(1); + } + *optr++ = LIBINIT_COPY; + *optr++ = (uint8_t)atoi(p+4); + return; + } + fprintf(stderr, "Error: bad value for %sPUSH(%s)\n", LIBDEF_PREFIX, p); + exit(1); + } +} + +static void libdef_set(BuildCtx *ctx, char *p, int arg) +{ + UNUSED(arg); + if (ctx->mode == BUILD_libdef) { + if (p[0] == '!' && p[1] == '\0') p[0] = '\0'; /* Set env. */ + libdef_name(p, LIBINIT_STRING); + *optr++ = LIBINIT_SET; + obuf[2]++; /* Bump hash table size. */ + } +} + +static void libdef_regfunc(BuildCtx *ctx, char *p, int arg) +{ + UNUSED(ctx); UNUSED(p); + regfunc = arg; +} + +typedef void (*LibDefFunc)(BuildCtx *ctx, char *p, int arg); + +typedef struct LibDefHandler { + const char *suffix; + const char *stop; + const LibDefFunc func; + const int arg; +} LibDefHandler; + +static const LibDefHandler libdef_handlers[] = { + { "MODULE_", " \t\r\n", libdef_module, 0 }, + { "CF(", ")", libdef_func, LIBINIT_CF }, + { "ASM(", ")", libdef_func, LIBINIT_ASM }, + { "ASM_(", ")", libdef_func, LIBINIT_ASM_ }, + { "REC(", ")", libdef_rec, 0 }, + { "PUSH(", ")", libdef_push, 0 }, + { "SET(", ")", libdef_set, 0 }, + { "NOREGUV", NULL, libdef_regfunc, REGFUNC_NOREGUV }, + { "NOREG", NULL, libdef_regfunc, REGFUNC_NOREG }, + { NULL, NULL, (LibDefFunc)0, 0 } +}; + +/* Emit C source code for library function definitions. */ +void emit_lib(BuildCtx *ctx) +{ + const char *fname; + + if (ctx->mode == BUILD_ffdef || ctx->mode == BUILD_libdef || + ctx->mode == BUILD_recdef) + fprintf(ctx->fp, "/* This is a generated file. DO NOT EDIT! */\n\n"); + else if (ctx->mode == BUILD_vmdef) + fprintf(ctx->fp, "ffnames = {\n[0]=\"Lua\",\n\"C\",\n"); + if (ctx->mode == BUILD_recdef) + fprintf(ctx->fp, "static const uint16_t recff_idmap[] = {\n0,\n0x0100"); + recffid = ffid = FF_C+1; + ffasmfunc = 0; + + while ((fname = *ctx->args++)) { + char buf[256]; /* We don't care about analyzing lines longer than that. */ + FILE *fp; + if (fname[0] == '-' && fname[1] == '\0') { + fp = stdin; + } else { + fp = fopen(fname, "r"); + if (!fp) { + fprintf(stderr, "Error: cannot open input file '%s': %s\n", + fname, strerror(errno)); + exit(1); + } + } + modstate = 0; + regfunc = REGFUNC_OK; + while (fgets(buf, sizeof(buf), fp) != NULL) { + char *p; + /* Simplistic pre-processor. Only handles top-level #if/#endif. */ + if (buf[0] == '#' && buf[1] == 'i' && buf[2] == 'f') { + int ok = 1; + if (!strcmp(buf, "#if LJ_52\n")) + ok = LJ_52; + else if (!strcmp(buf, "#if LJ_HASJIT\n")) + ok = LJ_HASJIT; + else if (!strcmp(buf, "#if LJ_HASFFI\n")) + ok = LJ_HASFFI; + if (!ok) { + int lvl = 1; + while (fgets(buf, sizeof(buf), fp) != NULL) { + if (buf[0] == '#' && buf[1] == 'e' && buf[2] == 'n') { + if (--lvl == 0) break; + } else if (buf[0] == '#' && buf[1] == 'i' && buf[2] == 'f') { + lvl++; + } + } + continue; + } + } + for (p = buf; (p = strstr(p, LIBDEF_PREFIX)) != NULL; ) { + const LibDefHandler *ldh; + p += sizeof(LIBDEF_PREFIX)-1; + for (ldh = libdef_handlers; ldh->suffix != NULL; ldh++) { + size_t n, len = strlen(ldh->suffix); + if (!strncmp(p, ldh->suffix, len)) { + p += len; + n = ldh->stop ? strcspn(p, ldh->stop) : 0; + if (!p[n]) break; + p[n] = '\0'; + ldh->func(ctx, p, ldh->arg); + p += n+1; + break; + } + } + if (ldh->suffix == NULL) { + buf[strlen(buf)-1] = '\0'; + fprintf(stderr, "Error: unknown library definition tag %s%s\n", + LIBDEF_PREFIX, p); + exit(1); + } + } + } + fclose(fp); + if (ctx->mode == BUILD_libdef) { + libdef_endmodule(ctx); + } + } + + if (ctx->mode == BUILD_ffdef) { + fprintf(ctx->fp, "\n#undef FFDEF\n\n"); + fprintf(ctx->fp, + "#ifndef FF_NUM_ASMFUNC\n#define FF_NUM_ASMFUNC %d\n#endif\n\n", + ffasmfunc); + } else if (ctx->mode == BUILD_vmdef) { + fprintf(ctx->fp, "}\n\n"); + } else if (ctx->mode == BUILD_bcdef) { + int i; + fprintf(ctx->fp, "\n};\n\n"); + fprintf(ctx->fp, "LJ_DATADEF const uint16_t lj_bc_mode[] = {\n"); + fprintf(ctx->fp, "BCDEF(BCMODE)\n"); + for (i = ffasmfunc-1; i > 0; i--) + fprintf(ctx->fp, "BCMODE_FF,\n"); + fprintf(ctx->fp, "BCMODE_FF\n};\n\n"); + } else if (ctx->mode == BUILD_recdef) { + char *p = (char *)obuf; + fprintf(ctx->fp, "\n};\n\n"); + fprintf(ctx->fp, "static const RecordFunc recff_func[] = {\n" + "recff_nyi,\n" + "recff_c"); + while (*p) { + fprintf(ctx->fp, ",\nrecff_%s", p); + p += strlen(p)+1; + } + fprintf(ctx->fp, "\n};\n\n"); + } +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm_peobj.c b/source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm_peobj.c new file mode 100644 index 000000000..4279f5005 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/host/buildvm_peobj.c @@ -0,0 +1,368 @@ +/* +** LuaJIT VM builder: PE object emitter. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Only used for building on Windows, since we cannot assume the presence +** of a suitable assembler. The host and target byte order must match. +*/ + +#include "buildvm.h" +#include "lj_bc.h" + +#if LJ_TARGET_X86ORX64 || LJ_TARGET_PPC + +/* Context for PE object emitter. */ +static char *strtab; +static size_t strtabofs; + +/* -- PE object definitions ----------------------------------------------- */ + +/* PE header. */ +typedef struct PEheader { + uint16_t arch; + uint16_t nsects; + uint32_t time; + uint32_t symtabofs; + uint32_t nsyms; + uint16_t opthdrsz; + uint16_t flags; +} PEheader; + +/* PE section. */ +typedef struct PEsection { + char name[8]; + uint32_t vsize; + uint32_t vaddr; + uint32_t size; + uint32_t ofs; + uint32_t relocofs; + uint32_t lineofs; + uint16_t nreloc; + uint16_t nline; + uint32_t flags; +} PEsection; + +/* PE relocation. */ +typedef struct PEreloc { + uint32_t vaddr; + uint32_t symidx; + uint16_t type; +} PEreloc; + +/* Cannot use sizeof, because it pads up to the max. alignment. */ +#define PEOBJ_RELOC_SIZE (4+4+2) + +/* PE symbol table entry. */ +typedef struct PEsym { + union { + char name[8]; + uint32_t nameref[2]; + } n; + uint32_t value; + int16_t sect; + uint16_t type; + uint8_t scl; + uint8_t naux; +} PEsym; + +/* PE symbol table auxiliary entry for a section. */ +typedef struct PEsymaux { + uint32_t size; + uint16_t nreloc; + uint16_t nline; + uint32_t cksum; + uint16_t assoc; + uint8_t comdatsel; + uint8_t unused[3]; +} PEsymaux; + +/* Cannot use sizeof, because it pads up to the max. alignment. */ +#define PEOBJ_SYM_SIZE (8+4+2+2+1+1) + +/* PE object CPU specific defines. */ +#if LJ_TARGET_X86 +#define PEOBJ_ARCH_TARGET 0x014c +#define PEOBJ_RELOC_REL32 0x14 /* MS: REL32, GNU: DISP32. */ +#define PEOBJ_RELOC_DIR32 0x06 +#define PEOBJ_RELOC_OFS 0 +#define PEOBJ_TEXT_FLAGS 0x60500020 /* 60=r+x, 50=align16, 20=code. */ +#elif LJ_TARGET_X64 +#define PEOBJ_ARCH_TARGET 0x8664 +#define PEOBJ_RELOC_REL32 0x04 /* MS: REL32, GNU: DISP32. */ +#define PEOBJ_RELOC_DIR32 0x02 +#define PEOBJ_RELOC_ADDR32NB 0x03 +#define PEOBJ_RELOC_OFS 0 +#define PEOBJ_TEXT_FLAGS 0x60500020 /* 60=r+x, 50=align16, 20=code. */ +#elif LJ_TARGET_PPC +#define PEOBJ_ARCH_TARGET 0x01f2 +#define PEOBJ_RELOC_REL32 0x06 +#define PEOBJ_RELOC_DIR32 0x02 +#define PEOBJ_RELOC_OFS (-4) +#define PEOBJ_TEXT_FLAGS 0x60400020 /* 60=r+x, 40=align8, 20=code. */ +#endif + +/* Section numbers (0-based). */ +enum { + PEOBJ_SECT_ABS = -2, + PEOBJ_SECT_UNDEF = -1, + PEOBJ_SECT_TEXT, +#if LJ_TARGET_X64 + PEOBJ_SECT_PDATA, + PEOBJ_SECT_XDATA, +#endif + PEOBJ_SECT_RDATA_Z, + PEOBJ_NSECTIONS +}; + +/* Symbol types. */ +#define PEOBJ_TYPE_NULL 0 +#define PEOBJ_TYPE_FUNC 0x20 + +/* Symbol storage class. */ +#define PEOBJ_SCL_EXTERN 2 +#define PEOBJ_SCL_STATIC 3 + +/* -- PE object emitter --------------------------------------------------- */ + +/* Emit PE object symbol. */ +static void emit_peobj_sym(BuildCtx *ctx, const char *name, uint32_t value, + int sect, int type, int scl) +{ + PEsym sym; + size_t len = strlen(name); + if (!strtab) { /* Pass 1: only calculate string table length. */ + if (len > 8) strtabofs += len+1; + return; + } + if (len <= 8) { + memcpy(sym.n.name, name, len); + memset(sym.n.name+len, 0, 8-len); + } else { + sym.n.nameref[0] = 0; + sym.n.nameref[1] = (uint32_t)strtabofs; + memcpy(strtab + strtabofs, name, len); + strtab[strtabofs+len] = 0; + strtabofs += len+1; + } + sym.value = value; + sym.sect = (int16_t)(sect+1); /* 1-based section number. */ + sym.type = (uint16_t)type; + sym.scl = (uint8_t)scl; + sym.naux = 0; + owrite(ctx, &sym, PEOBJ_SYM_SIZE); +} + +/* Emit PE object section symbol. */ +static void emit_peobj_sym_sect(BuildCtx *ctx, PEsection *pesect, int sect) +{ + PEsym sym; + PEsymaux aux; + if (!strtab) return; /* Pass 1: no output. */ + memcpy(sym.n.name, pesect[sect].name, 8); + sym.value = 0; + sym.sect = (int16_t)(sect+1); /* 1-based section number. */ + sym.type = PEOBJ_TYPE_NULL; + sym.scl = PEOBJ_SCL_STATIC; + sym.naux = 1; + owrite(ctx, &sym, PEOBJ_SYM_SIZE); + memset(&aux, 0, sizeof(PEsymaux)); + aux.size = pesect[sect].size; + aux.nreloc = pesect[sect].nreloc; + owrite(ctx, &aux, PEOBJ_SYM_SIZE); +} + +/* Emit Windows PE object file. */ +void emit_peobj(BuildCtx *ctx) +{ + PEheader pehdr; + PEsection pesect[PEOBJ_NSECTIONS]; + uint32_t sofs; + int i, nrsym; + union { uint8_t b; uint32_t u; } host_endian; + + sofs = sizeof(PEheader) + PEOBJ_NSECTIONS*sizeof(PEsection); + + /* Fill in PE sections. */ + memset(&pesect, 0, PEOBJ_NSECTIONS*sizeof(PEsection)); + memcpy(pesect[PEOBJ_SECT_TEXT].name, ".text", sizeof(".text")-1); + pesect[PEOBJ_SECT_TEXT].ofs = sofs; + sofs += (pesect[PEOBJ_SECT_TEXT].size = (uint32_t)ctx->codesz); + pesect[PEOBJ_SECT_TEXT].relocofs = sofs; + sofs += (pesect[PEOBJ_SECT_TEXT].nreloc = (uint16_t)ctx->nreloc) * PEOBJ_RELOC_SIZE; + /* Flags: 60 = read+execute, 50 = align16, 20 = code. */ + pesect[PEOBJ_SECT_TEXT].flags = PEOBJ_TEXT_FLAGS; + +#if LJ_TARGET_X64 + memcpy(pesect[PEOBJ_SECT_PDATA].name, ".pdata", sizeof(".pdata")-1); + pesect[PEOBJ_SECT_PDATA].ofs = sofs; + sofs += (pesect[PEOBJ_SECT_PDATA].size = 6*4); + pesect[PEOBJ_SECT_PDATA].relocofs = sofs; + sofs += (pesect[PEOBJ_SECT_PDATA].nreloc = 6) * PEOBJ_RELOC_SIZE; + /* Flags: 40 = read, 30 = align4, 40 = initialized data. */ + pesect[PEOBJ_SECT_PDATA].flags = 0x40300040; + + memcpy(pesect[PEOBJ_SECT_XDATA].name, ".xdata", sizeof(".xdata")-1); + pesect[PEOBJ_SECT_XDATA].ofs = sofs; + sofs += (pesect[PEOBJ_SECT_XDATA].size = 8*2+4+6*2); /* See below. */ + pesect[PEOBJ_SECT_XDATA].relocofs = sofs; + sofs += (pesect[PEOBJ_SECT_XDATA].nreloc = 1) * PEOBJ_RELOC_SIZE; + /* Flags: 40 = read, 30 = align4, 40 = initialized data. */ + pesect[PEOBJ_SECT_XDATA].flags = 0x40300040; +#endif + + memcpy(pesect[PEOBJ_SECT_RDATA_Z].name, ".rdata$Z", sizeof(".rdata$Z")-1); + pesect[PEOBJ_SECT_RDATA_Z].ofs = sofs; + sofs += (pesect[PEOBJ_SECT_RDATA_Z].size = (uint32_t)strlen(ctx->dasm_ident)+1); + /* Flags: 40 = read, 30 = align4, 40 = initialized data. */ + pesect[PEOBJ_SECT_RDATA_Z].flags = 0x40300040; + + /* Fill in PE header. */ + pehdr.arch = PEOBJ_ARCH_TARGET; + pehdr.nsects = PEOBJ_NSECTIONS; + pehdr.time = 0; /* Timestamp is optional. */ + pehdr.symtabofs = sofs; + pehdr.opthdrsz = 0; + pehdr.flags = 0; + + /* Compute the size of the symbol table: + ** @feat.00 + nsections*2 + ** + asm_start + nsym + ** + nrsym + */ + nrsym = ctx->nrelocsym; + pehdr.nsyms = 1+PEOBJ_NSECTIONS*2 + 1+ctx->nsym + nrsym; +#if LJ_TARGET_X64 + pehdr.nsyms += 1; /* Symbol for lj_err_unwind_win64. */ +#endif + + /* Write PE object header and all sections. */ + owrite(ctx, &pehdr, sizeof(PEheader)); + owrite(ctx, &pesect, sizeof(PEsection)*PEOBJ_NSECTIONS); + + /* Write .text section. */ + host_endian.u = 1; + if (host_endian.b != LJ_ENDIAN_SELECT(1, 0)) { +#if LJ_TARGET_PPC + uint32_t *p = (uint32_t *)ctx->code; + int n = (int)(ctx->codesz >> 2); + for (i = 0; i < n; i++, p++) + *p = lj_bswap(*p); /* Byteswap .text section. */ +#else + fprintf(stderr, "Error: different byte order for host and target\n"); + exit(1); +#endif + } + owrite(ctx, ctx->code, ctx->codesz); + for (i = 0; i < ctx->nreloc; i++) { + PEreloc reloc; + reloc.vaddr = (uint32_t)ctx->reloc[i].ofs + PEOBJ_RELOC_OFS; + reloc.symidx = 1+2+ctx->reloc[i].sym; /* Reloc syms are after .text sym. */ + reloc.type = ctx->reloc[i].type ? PEOBJ_RELOC_REL32 : PEOBJ_RELOC_DIR32; + owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); + } + +#if LJ_TARGET_X64 + { /* Write .pdata section. */ + uint32_t fcofs = (uint32_t)ctx->sym[ctx->nsym-1].ofs; + uint32_t pdata[3]; /* Start of .text, end of .text and .xdata. */ + PEreloc reloc; + pdata[0] = 0; pdata[1] = fcofs; pdata[2] = 0; + owrite(ctx, &pdata, sizeof(pdata)); + pdata[0] = fcofs; pdata[1] = (uint32_t)ctx->codesz; pdata[2] = 20; + owrite(ctx, &pdata, sizeof(pdata)); + reloc.vaddr = 0; reloc.symidx = 1+2+nrsym+2+2+1; + reloc.type = PEOBJ_RELOC_ADDR32NB; + owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); + reloc.vaddr = 4; reloc.symidx = 1+2+nrsym+2+2+1; + reloc.type = PEOBJ_RELOC_ADDR32NB; + owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); + reloc.vaddr = 8; reloc.symidx = 1+2+nrsym+2; + reloc.type = PEOBJ_RELOC_ADDR32NB; + owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); + reloc.vaddr = 12; reloc.symidx = 1+2+nrsym+2+2+1; + reloc.type = PEOBJ_RELOC_ADDR32NB; + owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); + reloc.vaddr = 16; reloc.symidx = 1+2+nrsym+2+2+1; + reloc.type = PEOBJ_RELOC_ADDR32NB; + owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); + reloc.vaddr = 20; reloc.symidx = 1+2+nrsym+2; + reloc.type = PEOBJ_RELOC_ADDR32NB; + owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); + } + { /* Write .xdata section. */ + uint16_t xdata[8+2+6]; + PEreloc reloc; + xdata[0] = 0x01|0x08|0x10; /* Ver. 1, uhandler/ehandler, prolog size 0. */ + xdata[1] = 0x0005; /* Number of unwind codes, no frame pointer. */ + xdata[2] = 0x4200; /* Stack offset 4*8+8 = aword*5. */ + xdata[3] = 0x3000; /* Push rbx. */ + xdata[4] = 0x6000; /* Push rsi. */ + xdata[5] = 0x7000; /* Push rdi. */ + xdata[6] = 0x5000; /* Push rbp. */ + xdata[7] = 0; /* Alignment. */ + xdata[8] = xdata[9] = 0; /* Relocated address of exception handler. */ + xdata[10] = 0x01; /* Ver. 1, no handler, prolog size 0. */ + xdata[11] = 0x1504; /* Number of unwind codes, fp = rbp, fpofs = 16. */ + xdata[12] = 0x0300; /* set_fpreg. */ + xdata[13] = 0x0200; /* stack offset 0*8+8 = aword*1. */ + xdata[14] = 0x3000; /* Push rbx. */ + xdata[15] = 0x5000; /* Push rbp. */ + owrite(ctx, &xdata, sizeof(xdata)); + reloc.vaddr = 2*8; reloc.symidx = 1+2+nrsym+2+2; + reloc.type = PEOBJ_RELOC_ADDR32NB; + owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); + } +#endif + + /* Write .rdata$Z section. */ + owrite(ctx, ctx->dasm_ident, strlen(ctx->dasm_ident)+1); + + /* Write symbol table. */ + strtab = NULL; /* 1st pass: collect string sizes. */ + for (;;) { + strtabofs = 4; + /* Mark as SafeSEH compliant. */ + emit_peobj_sym(ctx, "@feat.00", 1, + PEOBJ_SECT_ABS, PEOBJ_TYPE_NULL, PEOBJ_SCL_STATIC); + + emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_TEXT); + for (i = 0; i < nrsym; i++) + emit_peobj_sym(ctx, ctx->relocsym[i], 0, + PEOBJ_SECT_UNDEF, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN); + +#if LJ_TARGET_X64 + emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_PDATA); + emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_XDATA); + emit_peobj_sym(ctx, "lj_err_unwind_win64", 0, + PEOBJ_SECT_UNDEF, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN); +#endif + + emit_peobj_sym(ctx, ctx->beginsym, 0, + PEOBJ_SECT_TEXT, PEOBJ_TYPE_NULL, PEOBJ_SCL_EXTERN); + for (i = 0; i < ctx->nsym; i++) + emit_peobj_sym(ctx, ctx->sym[i].name, (uint32_t)ctx->sym[i].ofs, + PEOBJ_SECT_TEXT, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN); + + emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_RDATA_Z); + + if (strtab) + break; + /* 2nd pass: alloc strtab, write syms and copy strings. */ + strtab = (char *)malloc(strtabofs); + *(uint32_t *)strtab = (uint32_t)strtabofs; + } + + /* Write string table. */ + owrite(ctx, strtab, strtabofs); +} + +#else + +void emit_peobj(BuildCtx *ctx) +{ + UNUSED(ctx); + fprintf(stderr, "Error: no PE object support for this target\n"); + exit(1); +} + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/host/genminilua.lua b/source/libs/luajit/LuaJIT-2.0.4/src/host/genminilua.lua new file mode 100644 index 000000000..cd0d94662 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/host/genminilua.lua @@ -0,0 +1,428 @@ +---------------------------------------------------------------------------- +-- Lua script to generate a customized, minified version of Lua. +-- The resulting 'minilua' is used for the build process of LuaJIT. +---------------------------------------------------------------------------- +-- Copyright (C) 2005-2015 Mike Pall. All rights reserved. +-- Released under the MIT license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- + +local sub, match, gsub = string.sub, string.match, string.gsub + +local LUA_VERSION = "5.1.5" +local LUA_SOURCE + +local function usage() + io.stderr:write("Usage: ", arg and arg[0] or "genminilua", + " lua-", LUA_VERSION, "-source-dir\n") + os.exit(1) +end + +local function find_sources() + LUA_SOURCE = arg and arg[1] + if not LUA_SOURCE then usage() end + if sub(LUA_SOURCE, -1) ~= "/" then LUA_SOURCE = LUA_SOURCE.."/" end + local fp = io.open(LUA_SOURCE .. "lua.h") + if not fp then + LUA_SOURCE = LUA_SOURCE.."src/" + fp = io.open(LUA_SOURCE .. "lua.h") + if not fp then usage() end + end + local all = fp:read("*a") + fp:close() + if not match(all, 'LUA_RELEASE%s*"Lua '..LUA_VERSION..'"') then + io.stderr:write("Error: version mismatch\n") + usage() + end +end + +local LUA_FILES = { +"lmem.c", "lobject.c", "ltm.c", "lfunc.c", "ldo.c", "lstring.c", "ltable.c", +"lgc.c", "lstate.c", "ldebug.c", "lzio.c", "lopcodes.c", +"llex.c", "lcode.c", "lparser.c", "lvm.c", "lapi.c", "lauxlib.c", +"lbaselib.c", "ltablib.c", "liolib.c", "loslib.c", "lstrlib.c", "linit.c", +} + +local REMOVE_LIB = {} +gsub([[ +collectgarbage dofile gcinfo getfenv getmetatable load print rawequal rawset +select tostring xpcall +foreach foreachi getn maxn setn +popen tmpfile seek setvbuf __tostring +clock date difftime execute getenv rename setlocale time tmpname +dump gfind len reverse +LUA_LOADLIBNAME LUA_MATHLIBNAME LUA_DBLIBNAME +]], "%S+", function(name) + REMOVE_LIB[name] = true +end) + +local REMOVE_EXTINC = { [""] = true, [""] = true, } + +local CUSTOM_MAIN = [[ +typedef unsigned int UB; +static UB barg(lua_State *L,int idx){ +union{lua_Number n;U64 b;}bn; +bn.n=lua_tonumber(L,idx)+6755399441055744.0; +if (bn.n==0.0&&!lua_isnumber(L,idx))luaL_typerror(L,idx,"number"); +return(UB)bn.b; +} +#define BRET(b) lua_pushnumber(L,(lua_Number)(int)(b));return 1; +static int tobit(lua_State *L){ +BRET(barg(L,1))} +static int bnot(lua_State *L){ +BRET(~barg(L,1))} +static int band(lua_State *L){ +int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b&=barg(L,i);BRET(b)} +static int bor(lua_State *L){ +int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b|=barg(L,i);BRET(b)} +static int bxor(lua_State *L){ +int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b^=barg(L,i);BRET(b)} +static int lshift(lua_State *L){ +UB b=barg(L,1),n=barg(L,2)&31;BRET(b<>n)} +static int arshift(lua_State *L){ +UB b=barg(L,1),n=barg(L,2)&31;BRET((int)b>>n)} +static int rol(lua_State *L){ +UB b=barg(L,1),n=barg(L,2)&31;BRET((b<>(32-n)))} +static int ror(lua_State *L){ +UB b=barg(L,1),n=barg(L,2)&31;BRET((b>>n)|(b<<(32-n)))} +static int bswap(lua_State *L){ +UB b=barg(L,1);b=(b>>24)|((b>>8)&0xff00)|((b&0xff00)<<8)|(b<<24);BRET(b)} +static int tohex(lua_State *L){ +UB b=barg(L,1); +int n=lua_isnone(L,2)?8:(int)barg(L,2); +const char *hexdigits="0123456789abcdef"; +char buf[8]; +int i; +if(n<0){n=-n;hexdigits="0123456789ABCDEF";} +if(n>8)n=8; +for(i=(int)n;--i>=0;){buf[i]=hexdigits[b&15];b>>=4;} +lua_pushlstring(L,buf,(size_t)n); +return 1; +} +static const struct luaL_Reg bitlib[] = { +{"tobit",tobit}, +{"bnot",bnot}, +{"band",band}, +{"bor",bor}, +{"bxor",bxor}, +{"lshift",lshift}, +{"rshift",rshift}, +{"arshift",arshift}, +{"rol",rol}, +{"ror",ror}, +{"bswap",bswap}, +{"tohex",tohex}, +{NULL,NULL} +}; +int main(int argc, char **argv){ + lua_State *L = luaL_newstate(); + int i; + luaL_openlibs(L); + luaL_register(L, "bit", bitlib); + if (argc < 2) return sizeof(void *); + lua_createtable(L, 0, 1); + lua_pushstring(L, argv[1]); + lua_rawseti(L, -2, 0); + lua_setglobal(L, "arg"); + if (luaL_loadfile(L, argv[1])) + goto err; + for (i = 2; i < argc; i++) + lua_pushstring(L, argv[i]); + if (lua_pcall(L, argc - 2, 0, 0)) { + err: + fprintf(stderr, "Error: %s\n", lua_tostring(L, -1)); + return 1; + } + lua_close(L); + return 0; +} +]] + +local function read_sources() + local t = {} + for i, name in ipairs(LUA_FILES) do + local fp = assert(io.open(LUA_SOURCE..name, "r")) + t[i] = fp:read("*a") + assert(fp:close()) + end + t[#t+1] = CUSTOM_MAIN + return table.concat(t) +end + +local includes = {} + +local function merge_includes(src) + return gsub(src, '#include%s*"([^"]*)"%s*\n', function(name) + if includes[name] then return "" end + includes[name] = true + local fp = assert(io.open(LUA_SOURCE..name, "r")) + local src = fp:read("*a") + assert(fp:close()) + src = gsub(src, "#ifndef%s+%w+_h\n#define%s+%w+_h\n", "") + src = gsub(src, "#endif%s*$", "") + return merge_includes(src) + end) +end + +local function get_license(src) + return match(src, "/%*+\n%* Copyright %(.-%*/\n") +end + +local function fold_lines(src) + return gsub(src, "\\\n", " ") +end + +local strings = {} + +local function save_str(str) + local n = #strings+1 + strings[n] = str + return "\1"..n.."\2" +end + +local function save_strings(src) + src = gsub(src, '"[^"\n]*"', save_str) + return gsub(src, "'[^'\n]*'", save_str) +end + +local function restore_strings(src) + return gsub(src, "\1(%d+)\2", function(numstr) + return strings[tonumber(numstr)] + end) +end + +local function def_istrue(def) + return def == "INT_MAX > 2147483640L" or + def == "LUAI_BITSINT >= 32" or + def == "SIZE_Bx < LUAI_BITSINT-1" or + def == "cast" or + def == "defined(LUA_CORE)" or + def == "MINSTRTABSIZE" or + def == "LUA_MINBUFFER" or + def == "HARDSTACKTESTS" or + def == "UNUSED" +end + +local head, defs = {[[ +#ifdef _MSC_VER +typedef unsigned __int64 U64; +#else +typedef unsigned long long U64; +#endif +int _CRT_glob = 0; +]]}, {} + +local function preprocess(src) + local t = { match(src, "^(.-)#") } + local lvl, on, oldon = 0, true, {} + for pp, def, txt in string.gmatch(src, "#(%w+) *([^\n]*)\n([^#]*)") do + if pp == "if" or pp == "ifdef" or pp == "ifndef" then + lvl = lvl + 1 + oldon[lvl] = on + on = def_istrue(def) + elseif pp == "else" then + if oldon[lvl] then + if on == false then on = true else on = false end + end + elseif pp == "elif" then + if oldon[lvl] then + on = def_istrue(def) + end + elseif pp == "endif" then + on = oldon[lvl] + lvl = lvl - 1 + elseif on then + if pp == "include" then + if not head[def] and not REMOVE_EXTINC[def] then + head[def] = true + head[#head+1] = "#include "..def.."\n" + end + elseif pp == "define" then + local k, sp, v = match(def, "([%w_]+)(%s*)(.*)") + if k and not (sp == "" and sub(v, 1, 1) == "(") then + defs[k] = gsub(v, "%a[%w_]*", function(tok) + return defs[tok] or tok + end) + else + t[#t+1] = "#define "..def.."\n" + end + elseif pp ~= "undef" then + error("unexpected directive: "..pp.." "..def) + end + end + if on then t[#t+1] = txt end + end + return gsub(table.concat(t), "%a[%w_]*", function(tok) + return defs[tok] or tok + end) +end + +local function merge_header(src, license) + local hdr = string.format([[ +/* This is a heavily customized and minimized copy of Lua %s. */ +/* It's only used to build LuaJIT. It does NOT have all standard functions! */ +]], LUA_VERSION) + return hdr..license..table.concat(head)..src +end + +local function strip_unused1(src) + return gsub(src, '( {"?([%w_]+)"?,%s+%a[%w_]*},\n)', function(line, func) + return REMOVE_LIB[func] and "" or line + end) +end + +local function strip_unused2(src) + return gsub(src, "Symbolic Execution.-}=", "") +end + +local function strip_unused3(src) + src = gsub(src, "extern", "static") + src = gsub(src, "\nstatic([^\n]-)%(([^)]*)%)%(", "\nstatic%1 %2(") + src = gsub(src, "#define lua_assert[^\n]*\n", "") + src = gsub(src, "lua_assert%b();?", "") + src = gsub(src, "default:\n}", "default:;\n}") + src = gsub(src, "lua_lock%b();", "") + src = gsub(src, "lua_unlock%b();", "") + src = gsub(src, "luai_threadyield%b();", "") + src = gsub(src, "luai_userstateopen%b();", "{}") + src = gsub(src, "luai_userstate%w+%b();", "") + src = gsub(src, "%(%(c==.*luaY_parser%)", "luaY_parser") + src = gsub(src, "trydecpoint%(ls,seminfo%)", + "luaX_lexerror(ls,\"malformed number\",TK_NUMBER)") + src = gsub(src, "int c=luaZ_lookahead%b();", "") + src = gsub(src, "luaL_register%(L,[^,]*,co_funcs%);\nreturn 2;", + "return 1;") + src = gsub(src, "getfuncname%b():", "NULL:") + src = gsub(src, "getobjname%b():", "NULL:") + src = gsub(src, "if%([^\n]*hookmask[^\n]*%)\n[^\n]*\n", "") + src = gsub(src, "if%([^\n]*hookmask[^\n]*%)%b{}\n", "") + src = gsub(src, "if%([^\n]*hookmask[^\n]*&&\n[^\n]*%b{}\n", "") + src = gsub(src, "(twoto%b()%()", "%1(size_t)") + src = gsub(src, "i -- BYTECODE -- [...] +-- print(bc.line(foo, 2)) --> 0002 KSTR 1 1 ; "hello" +-- +-- local out = { +-- -- Do something with each line: +-- write = function(t, ...) io.write(...) end, +-- close = function(t) end, +-- flush = function(t) end, +-- } +-- bc.dump(foo, out) +-- +------------------------------------------------------------------------------ + +-- Cache some library functions and objects. +local jit = require("jit") +assert(jit.version_num == 20004, "LuaJIT core/library version mismatch") +local jutil = require("jit.util") +local vmdef = require("jit.vmdef") +local bit = require("bit") +local sub, gsub, format = string.sub, string.gsub, string.format +local byte, band, shr = string.byte, bit.band, bit.rshift +local funcinfo, funcbc, funck = jutil.funcinfo, jutil.funcbc, jutil.funck +local funcuvname = jutil.funcuvname +local bcnames = vmdef.bcnames +local stdout, stderr = io.stdout, io.stderr + +------------------------------------------------------------------------------ + +local function ctlsub(c) + if c == "\n" then return "\\n" + elseif c == "\r" then return "\\r" + elseif c == "\t" then return "\\t" + else return format("\\%03d", byte(c)) + end +end + +-- Return one bytecode line. +local function bcline(func, pc, prefix) + local ins, m = funcbc(func, pc) + if not ins then return end + local ma, mb, mc = band(m, 7), band(m, 15*8), band(m, 15*128) + local a = band(shr(ins, 8), 0xff) + local oidx = 6*band(ins, 0xff) + local op = sub(bcnames, oidx+1, oidx+6) + local s = format("%04d %s %-6s %3s ", + pc, prefix or " ", op, ma == 0 and "" or a) + local d = shr(ins, 16) + if mc == 13*128 then -- BCMjump + return format("%s=> %04d\n", s, pc+d-0x7fff) + end + if mb ~= 0 then + d = band(d, 0xff) + elseif mc == 0 then + return s.."\n" + end + local kc + if mc == 10*128 then -- BCMstr + kc = funck(func, -d-1) + kc = format(#kc > 40 and '"%.40s"~' or '"%s"', gsub(kc, "%c", ctlsub)) + elseif mc == 9*128 then -- BCMnum + kc = funck(func, d) + if op == "TSETM " then kc = kc - 2^52 end + elseif mc == 12*128 then -- BCMfunc + local fi = funcinfo(funck(func, -d-1)) + if fi.ffid then + kc = vmdef.ffnames[fi.ffid] + else + kc = fi.loc + end + elseif mc == 5*128 then -- BCMuv + kc = funcuvname(func, d) + end + if ma == 5 then -- BCMuv + local ka = funcuvname(func, a) + if kc then kc = ka.." ; "..kc else kc = ka end + end + if mb ~= 0 then + local b = shr(ins, 24) + if kc then return format("%s%3d %3d ; %s\n", s, b, d, kc) end + return format("%s%3d %3d\n", s, b, d) + end + if kc then return format("%s%3d ; %s\n", s, d, kc) end + if mc == 7*128 and d > 32767 then d = d - 65536 end -- BCMlits + return format("%s%3d\n", s, d) +end + +-- Collect branch targets of a function. +local function bctargets(func) + local target = {} + for pc=1,1000000000 do + local ins, m = funcbc(func, pc) + if not ins then break end + if band(m, 15*128) == 13*128 then target[pc+shr(ins, 16)-0x7fff] = true end + end + return target +end + +-- Dump bytecode instructions of a function. +local function bcdump(func, out, all) + if not out then out = stdout end + local fi = funcinfo(func) + if all and fi.children then + for n=-1,-1000000000,-1 do + local k = funck(func, n) + if not k then break end + if type(k) == "proto" then bcdump(k, out, true) end + end + end + out:write(format("-- BYTECODE -- %s-%d\n", fi.loc, fi.lastlinedefined)) + local target = bctargets(func) + for pc=1,1000000000 do + local s = bcline(func, pc, target[pc] and "=>") + if not s then break end + out:write(s) + end + out:write("\n") + out:flush() +end + +------------------------------------------------------------------------------ + +-- Active flag and output file handle. +local active, out + +-- List handler. +local function h_list(func) + return bcdump(func, out) +end + +-- Detach list handler. +local function bclistoff() + if active then + active = false + jit.attach(h_list) + if out and out ~= stdout and out ~= stderr then out:close() end + out = nil + end +end + +-- Open the output file and attach list handler. +local function bcliston(outfile) + if active then bclistoff() end + if not outfile then outfile = os.getenv("LUAJIT_LISTFILE") end + if outfile then + out = outfile == "-" and stdout or assert(io.open(outfile, "w")) + else + out = stderr + end + jit.attach(h_list, "bc") + active = true +end + +-- Public module functions. +module(...) + +line = bcline +dump = bcdump +targets = bctargets + +on = bcliston +off = bclistoff +start = bcliston -- For -j command line option. + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/jit/bcsave.lua b/source/libs/luajit/LuaJIT-2.0.4/src/jit/bcsave.lua new file mode 100644 index 000000000..0319b3d25 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/jit/bcsave.lua @@ -0,0 +1,659 @@ +---------------------------------------------------------------------------- +-- LuaJIT module to save/list bytecode. +-- +-- Copyright (C) 2005-2015 Mike Pall. All rights reserved. +-- Released under the MIT license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- +-- +-- This module saves or lists the bytecode for an input file. +-- It's run by the -b command line option. +-- +------------------------------------------------------------------------------ + +local jit = require("jit") +assert(jit.version_num == 20004, "LuaJIT core/library version mismatch") +local bit = require("bit") + +-- Symbol name prefix for LuaJIT bytecode. +local LJBC_PREFIX = "luaJIT_BC_" + +------------------------------------------------------------------------------ + +local function usage() + io.stderr:write[[ +Save LuaJIT bytecode: luajit -b[options] input output + -l Only list bytecode. + -s Strip debug info (default). + -g Keep debug info. + -n name Set module name (default: auto-detect from input name). + -t type Set output file type (default: auto-detect from output name). + -a arch Override architecture for object files (default: native). + -o os Override OS for object files (default: native). + -e chunk Use chunk string as input. + -- Stop handling options. + - Use stdin as input and/or stdout as output. + +File types: c h obj o raw (default) +]] + os.exit(1) +end + +local function check(ok, ...) + if ok then return ok, ... end + io.stderr:write("luajit: ", ...) + io.stderr:write("\n") + os.exit(1) +end + +local function readfile(input) + if type(input) == "function" then return input end + if input == "-" then input = nil end + return check(loadfile(input)) +end + +local function savefile(name, mode) + if name == "-" then return io.stdout end + return check(io.open(name, mode)) +end + +------------------------------------------------------------------------------ + +local map_type = { + raw = "raw", c = "c", h = "h", o = "obj", obj = "obj", +} + +local map_arch = { + x86 = true, x64 = true, arm = true, ppc = true, ppcspe = true, + mips = true, mipsel = true, +} + +local map_os = { + linux = true, windows = true, osx = true, freebsd = true, netbsd = true, + openbsd = true, dragonfly = true, solaris = true, +} + +local function checkarg(str, map, err) + str = string.lower(str) + local s = check(map[str], "unknown ", err) + return s == true and str or s +end + +local function detecttype(str) + local ext = string.match(string.lower(str), "%.(%a+)$") + return map_type[ext] or "raw" +end + +local function checkmodname(str) + check(string.match(str, "^[%w_.%-]+$"), "bad module name") + return string.gsub(str, "[%.%-]", "_") +end + +local function detectmodname(str) + if type(str) == "string" then + local tail = string.match(str, "[^/\\]+$") + if tail then str = tail end + local head = string.match(str, "^(.*)%.[^.]*$") + if head then str = head end + str = string.match(str, "^[%w_.%-]+") + else + str = nil + end + check(str, "cannot derive module name, use -n name") + return string.gsub(str, "[%.%-]", "_") +end + +------------------------------------------------------------------------------ + +local function bcsave_tail(fp, output, s) + local ok, err = fp:write(s) + if ok and output ~= "-" then ok, err = fp:close() end + check(ok, "cannot write ", output, ": ", err) +end + +local function bcsave_raw(output, s) + local fp = savefile(output, "wb") + bcsave_tail(fp, output, s) +end + +local function bcsave_c(ctx, output, s) + local fp = savefile(output, "w") + if ctx.type == "c" then + fp:write(string.format([[ +#ifdef _cplusplus +extern "C" +#endif +#ifdef _WIN32 +__declspec(dllexport) +#endif +const char %s%s[] = { +]], LJBC_PREFIX, ctx.modname)) + else + fp:write(string.format([[ +#define %s%s_SIZE %d +static const char %s%s[] = { +]], LJBC_PREFIX, ctx.modname, #s, LJBC_PREFIX, ctx.modname)) + end + local t, n, m = {}, 0, 0 + for i=1,#s do + local b = tostring(string.byte(s, i)) + m = m + #b + 1 + if m > 78 then + fp:write(table.concat(t, ",", 1, n), ",\n") + n, m = 0, #b + 1 + end + n = n + 1 + t[n] = b + end + bcsave_tail(fp, output, table.concat(t, ",", 1, n).."\n};\n") +end + +local function bcsave_elfobj(ctx, output, s, ffi) + ffi.cdef[[ +typedef struct { + uint8_t emagic[4], eclass, eendian, eversion, eosabi, eabiversion, epad[7]; + uint16_t type, machine; + uint32_t version; + uint32_t entry, phofs, shofs; + uint32_t flags; + uint16_t ehsize, phentsize, phnum, shentsize, shnum, shstridx; +} ELF32header; +typedef struct { + uint8_t emagic[4], eclass, eendian, eversion, eosabi, eabiversion, epad[7]; + uint16_t type, machine; + uint32_t version; + uint64_t entry, phofs, shofs; + uint32_t flags; + uint16_t ehsize, phentsize, phnum, shentsize, shnum, shstridx; +} ELF64header; +typedef struct { + uint32_t name, type, flags, addr, ofs, size, link, info, align, entsize; +} ELF32sectheader; +typedef struct { + uint32_t name, type; + uint64_t flags, addr, ofs, size; + uint32_t link, info; + uint64_t align, entsize; +} ELF64sectheader; +typedef struct { + uint32_t name, value, size; + uint8_t info, other; + uint16_t sectidx; +} ELF32symbol; +typedef struct { + uint32_t name; + uint8_t info, other; + uint16_t sectidx; + uint64_t value, size; +} ELF64symbol; +typedef struct { + ELF32header hdr; + ELF32sectheader sect[6]; + ELF32symbol sym[2]; + uint8_t space[4096]; +} ELF32obj; +typedef struct { + ELF64header hdr; + ELF64sectheader sect[6]; + ELF64symbol sym[2]; + uint8_t space[4096]; +} ELF64obj; +]] + local symname = LJBC_PREFIX..ctx.modname + local is64, isbe = false, false + if ctx.arch == "x64" then + is64 = true + elseif ctx.arch == "ppc" or ctx.arch == "ppcspe" or ctx.arch == "mips" then + isbe = true + end + + -- Handle different host/target endianess. + local function f32(x) return x end + local f16, fofs = f32, f32 + if ffi.abi("be") ~= isbe then + f32 = bit.bswap + function f16(x) return bit.rshift(bit.bswap(x), 16) end + if is64 then + local two32 = ffi.cast("int64_t", 2^32) + function fofs(x) return bit.bswap(x)*two32 end + else + fofs = f32 + end + end + + -- Create ELF object and fill in header. + local o = ffi.new(is64 and "ELF64obj" or "ELF32obj") + local hdr = o.hdr + if ctx.os == "bsd" or ctx.os == "other" then -- Determine native hdr.eosabi. + local bf = assert(io.open("/bin/ls", "rb")) + local bs = bf:read(9) + bf:close() + ffi.copy(o, bs, 9) + check(hdr.emagic[0] == 127, "no support for writing native object files") + else + hdr.emagic = "\127ELF" + hdr.eosabi = ({ freebsd=9, netbsd=2, openbsd=12, solaris=6 })[ctx.os] or 0 + end + hdr.eclass = is64 and 2 or 1 + hdr.eendian = isbe and 2 or 1 + hdr.eversion = 1 + hdr.type = f16(1) + hdr.machine = f16(({ x86=3, x64=62, arm=40, ppc=20, ppcspe=20, mips=8, mipsel=8 })[ctx.arch]) + if ctx.arch == "mips" or ctx.arch == "mipsel" then + hdr.flags = 0x50001006 + end + hdr.version = f32(1) + hdr.shofs = fofs(ffi.offsetof(o, "sect")) + hdr.ehsize = f16(ffi.sizeof(hdr)) + hdr.shentsize = f16(ffi.sizeof(o.sect[0])) + hdr.shnum = f16(6) + hdr.shstridx = f16(2) + + -- Fill in sections and symbols. + local sofs, ofs = ffi.offsetof(o, "space"), 1 + for i,name in ipairs{ + ".symtab", ".shstrtab", ".strtab", ".rodata", ".note.GNU-stack", + } do + local sect = o.sect[i] + sect.align = fofs(1) + sect.name = f32(ofs) + ffi.copy(o.space+ofs, name) + ofs = ofs + #name+1 + end + o.sect[1].type = f32(2) -- .symtab + o.sect[1].link = f32(3) + o.sect[1].info = f32(1) + o.sect[1].align = fofs(8) + o.sect[1].ofs = fofs(ffi.offsetof(o, "sym")) + o.sect[1].entsize = fofs(ffi.sizeof(o.sym[0])) + o.sect[1].size = fofs(ffi.sizeof(o.sym)) + o.sym[1].name = f32(1) + o.sym[1].sectidx = f16(4) + o.sym[1].size = fofs(#s) + o.sym[1].info = 17 + o.sect[2].type = f32(3) -- .shstrtab + o.sect[2].ofs = fofs(sofs) + o.sect[2].size = fofs(ofs) + o.sect[3].type = f32(3) -- .strtab + o.sect[3].ofs = fofs(sofs + ofs) + o.sect[3].size = fofs(#symname+1) + ffi.copy(o.space+ofs+1, symname) + ofs = ofs + #symname + 2 + o.sect[4].type = f32(1) -- .rodata + o.sect[4].flags = fofs(2) + o.sect[4].ofs = fofs(sofs + ofs) + o.sect[4].size = fofs(#s) + o.sect[5].type = f32(1) -- .note.GNU-stack + o.sect[5].ofs = fofs(sofs + ofs + #s) + + -- Write ELF object file. + local fp = savefile(output, "wb") + fp:write(ffi.string(o, ffi.sizeof(o)-4096+ofs)) + bcsave_tail(fp, output, s) +end + +local function bcsave_peobj(ctx, output, s, ffi) + ffi.cdef[[ +typedef struct { + uint16_t arch, nsects; + uint32_t time, symtabofs, nsyms; + uint16_t opthdrsz, flags; +} PEheader; +typedef struct { + char name[8]; + uint32_t vsize, vaddr, size, ofs, relocofs, lineofs; + uint16_t nreloc, nline; + uint32_t flags; +} PEsection; +typedef struct __attribute((packed)) { + union { + char name[8]; + uint32_t nameref[2]; + }; + uint32_t value; + int16_t sect; + uint16_t type; + uint8_t scl, naux; +} PEsym; +typedef struct __attribute((packed)) { + uint32_t size; + uint16_t nreloc, nline; + uint32_t cksum; + uint16_t assoc; + uint8_t comdatsel, unused[3]; +} PEsymaux; +typedef struct { + PEheader hdr; + PEsection sect[2]; + // Must be an even number of symbol structs. + PEsym sym0; + PEsymaux sym0aux; + PEsym sym1; + PEsymaux sym1aux; + PEsym sym2; + PEsym sym3; + uint32_t strtabsize; + uint8_t space[4096]; +} PEobj; +]] + local symname = LJBC_PREFIX..ctx.modname + local is64 = false + if ctx.arch == "x86" then + symname = "_"..symname + elseif ctx.arch == "x64" then + is64 = true + end + local symexport = " /EXPORT:"..symname..",DATA " + + -- The file format is always little-endian. Swap if the host is big-endian. + local function f32(x) return x end + local f16 = f32 + if ffi.abi("be") then + f32 = bit.bswap + function f16(x) return bit.rshift(bit.bswap(x), 16) end + end + + -- Create PE object and fill in header. + local o = ffi.new("PEobj") + local hdr = o.hdr + hdr.arch = f16(({ x86=0x14c, x64=0x8664, arm=0x1c0, ppc=0x1f2, mips=0x366, mipsel=0x366 })[ctx.arch]) + hdr.nsects = f16(2) + hdr.symtabofs = f32(ffi.offsetof(o, "sym0")) + hdr.nsyms = f32(6) + + -- Fill in sections and symbols. + o.sect[0].name = ".drectve" + o.sect[0].size = f32(#symexport) + o.sect[0].flags = f32(0x00100a00) + o.sym0.sect = f16(1) + o.sym0.scl = 3 + o.sym0.name = ".drectve" + o.sym0.naux = 1 + o.sym0aux.size = f32(#symexport) + o.sect[1].name = ".rdata" + o.sect[1].size = f32(#s) + o.sect[1].flags = f32(0x40300040) + o.sym1.sect = f16(2) + o.sym1.scl = 3 + o.sym1.name = ".rdata" + o.sym1.naux = 1 + o.sym1aux.size = f32(#s) + o.sym2.sect = f16(2) + o.sym2.scl = 2 + o.sym2.nameref[1] = f32(4) + o.sym3.sect = f16(-1) + o.sym3.scl = 2 + o.sym3.value = f32(1) + o.sym3.name = "@feat.00" -- Mark as SafeSEH compliant. + ffi.copy(o.space, symname) + local ofs = #symname + 1 + o.strtabsize = f32(ofs + 4) + o.sect[0].ofs = f32(ffi.offsetof(o, "space") + ofs) + ffi.copy(o.space + ofs, symexport) + ofs = ofs + #symexport + o.sect[1].ofs = f32(ffi.offsetof(o, "space") + ofs) + + -- Write PE object file. + local fp = savefile(output, "wb") + fp:write(ffi.string(o, ffi.sizeof(o)-4096+ofs)) + bcsave_tail(fp, output, s) +end + +local function bcsave_machobj(ctx, output, s, ffi) + ffi.cdef[[ +typedef struct +{ + uint32_t magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds, flags; +} mach_header; +typedef struct +{ + mach_header; uint32_t reserved; +} mach_header_64; +typedef struct { + uint32_t cmd, cmdsize; + char segname[16]; + uint32_t vmaddr, vmsize, fileoff, filesize; + uint32_t maxprot, initprot, nsects, flags; +} mach_segment_command; +typedef struct { + uint32_t cmd, cmdsize; + char segname[16]; + uint64_t vmaddr, vmsize, fileoff, filesize; + uint32_t maxprot, initprot, nsects, flags; +} mach_segment_command_64; +typedef struct { + char sectname[16], segname[16]; + uint32_t addr, size; + uint32_t offset, align, reloff, nreloc, flags; + uint32_t reserved1, reserved2; +} mach_section; +typedef struct { + char sectname[16], segname[16]; + uint64_t addr, size; + uint32_t offset, align, reloff, nreloc, flags; + uint32_t reserved1, reserved2, reserved3; +} mach_section_64; +typedef struct { + uint32_t cmd, cmdsize, symoff, nsyms, stroff, strsize; +} mach_symtab_command; +typedef struct { + int32_t strx; + uint8_t type, sect; + int16_t desc; + uint32_t value; +} mach_nlist; +typedef struct { + uint32_t strx; + uint8_t type, sect; + uint16_t desc; + uint64_t value; +} mach_nlist_64; +typedef struct +{ + uint32_t magic, nfat_arch; +} mach_fat_header; +typedef struct +{ + uint32_t cputype, cpusubtype, offset, size, align; +} mach_fat_arch; +typedef struct { + struct { + mach_header hdr; + mach_segment_command seg; + mach_section sec; + mach_symtab_command sym; + } arch[1]; + mach_nlist sym_entry; + uint8_t space[4096]; +} mach_obj; +typedef struct { + struct { + mach_header_64 hdr; + mach_segment_command_64 seg; + mach_section_64 sec; + mach_symtab_command sym; + } arch[1]; + mach_nlist_64 sym_entry; + uint8_t space[4096]; +} mach_obj_64; +typedef struct { + mach_fat_header fat; + mach_fat_arch fat_arch[4]; + struct { + mach_header hdr; + mach_segment_command seg; + mach_section sec; + mach_symtab_command sym; + } arch[4]; + mach_nlist sym_entry; + uint8_t space[4096]; +} mach_fat_obj; +]] + local symname = '_'..LJBC_PREFIX..ctx.modname + local isfat, is64, align, mobj = false, false, 4, "mach_obj" + if ctx.arch == "x64" then + is64, align, mobj = true, 8, "mach_obj_64" + elseif ctx.arch == "arm" then + isfat, mobj = true, "mach_fat_obj" + else + check(ctx.arch == "x86", "unsupported architecture for OSX") + end + local function aligned(v, a) return bit.band(v+a-1, -a) end + local be32 = bit.bswap -- Mach-O FAT is BE, supported archs are LE. + + -- Create Mach-O object and fill in header. + local o = ffi.new(mobj) + local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, align) + local cputype = ({ x86={7}, x64={0x01000007}, arm={7,12,12,12} })[ctx.arch] + local cpusubtype = ({ x86={3}, x64={3}, arm={3,6,9,11} })[ctx.arch] + if isfat then + o.fat.magic = be32(0xcafebabe) + o.fat.nfat_arch = be32(#cpusubtype) + end + + -- Fill in sections and symbols. + for i=0,#cpusubtype-1 do + local ofs = 0 + if isfat then + local a = o.fat_arch[i] + a.cputype = be32(cputype[i+1]) + a.cpusubtype = be32(cpusubtype[i+1]) + -- Subsequent slices overlap each other to share data. + ofs = ffi.offsetof(o, "arch") + i*ffi.sizeof(o.arch[0]) + a.offset = be32(ofs) + a.size = be32(mach_size-ofs+#s) + end + local a = o.arch[i] + a.hdr.magic = is64 and 0xfeedfacf or 0xfeedface + a.hdr.cputype = cputype[i+1] + a.hdr.cpusubtype = cpusubtype[i+1] + a.hdr.filetype = 1 + a.hdr.ncmds = 2 + a.hdr.sizeofcmds = ffi.sizeof(a.seg)+ffi.sizeof(a.sec)+ffi.sizeof(a.sym) + a.seg.cmd = is64 and 0x19 or 0x1 + a.seg.cmdsize = ffi.sizeof(a.seg)+ffi.sizeof(a.sec) + a.seg.vmsize = #s + a.seg.fileoff = mach_size-ofs + a.seg.filesize = #s + a.seg.maxprot = 1 + a.seg.initprot = 1 + a.seg.nsects = 1 + ffi.copy(a.sec.sectname, "__data") + ffi.copy(a.sec.segname, "__DATA") + a.sec.size = #s + a.sec.offset = mach_size-ofs + a.sym.cmd = 2 + a.sym.cmdsize = ffi.sizeof(a.sym) + a.sym.symoff = ffi.offsetof(o, "sym_entry")-ofs + a.sym.nsyms = 1 + a.sym.stroff = ffi.offsetof(o, "sym_entry")+ffi.sizeof(o.sym_entry)-ofs + a.sym.strsize = aligned(#symname+2, align) + end + o.sym_entry.type = 0xf + o.sym_entry.sect = 1 + o.sym_entry.strx = 1 + ffi.copy(o.space+1, symname) + + -- Write Macho-O object file. + local fp = savefile(output, "wb") + fp:write(ffi.string(o, mach_size)) + bcsave_tail(fp, output, s) +end + +local function bcsave_obj(ctx, output, s) + local ok, ffi = pcall(require, "ffi") + check(ok, "FFI library required to write this file type") + if ctx.os == "windows" then + return bcsave_peobj(ctx, output, s, ffi) + elseif ctx.os == "osx" then + return bcsave_machobj(ctx, output, s, ffi) + else + return bcsave_elfobj(ctx, output, s, ffi) + end +end + +------------------------------------------------------------------------------ + +local function bclist(input, output) + local f = readfile(input) + require("jit.bc").dump(f, savefile(output, "w"), true) +end + +local function bcsave(ctx, input, output) + local f = readfile(input) + local s = string.dump(f, ctx.strip) + local t = ctx.type + if not t then + t = detecttype(output) + ctx.type = t + end + if t == "raw" then + bcsave_raw(output, s) + else + if not ctx.modname then ctx.modname = detectmodname(input) end + if t == "obj" then + bcsave_obj(ctx, output, s) + else + bcsave_c(ctx, output, s) + end + end +end + +local function docmd(...) + local arg = {...} + local n = 1 + local list = false + local ctx = { + strip = true, arch = jit.arch, os = string.lower(jit.os), + type = false, modname = false, + } + while n <= #arg do + local a = arg[n] + if type(a) == "string" and string.sub(a, 1, 1) == "-" and a ~= "-" then + table.remove(arg, n) + if a == "--" then break end + for m=2,#a do + local opt = string.sub(a, m, m) + if opt == "l" then + list = true + elseif opt == "s" then + ctx.strip = true + elseif opt == "g" then + ctx.strip = false + else + if arg[n] == nil or m ~= #a then usage() end + if opt == "e" then + if n ~= 1 then usage() end + arg[1] = check(loadstring(arg[1])) + elseif opt == "n" then + ctx.modname = checkmodname(table.remove(arg, n)) + elseif opt == "t" then + ctx.type = checkarg(table.remove(arg, n), map_type, "file type") + elseif opt == "a" then + ctx.arch = checkarg(table.remove(arg, n), map_arch, "architecture") + elseif opt == "o" then + ctx.os = checkarg(table.remove(arg, n), map_os, "OS name") + else + usage() + end + end + end + else + n = n + 1 + end + end + if list then + if #arg == 0 or #arg > 2 then usage() end + bclist(arg[1], arg[2] or "-") + else + if #arg ~= 2 then usage() end + bcsave(ctx, arg[1], arg[2]) + end +end + +------------------------------------------------------------------------------ + +-- Public module functions. +module(...) + +start = docmd -- Process -b command line option. + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_arm.lua b/source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_arm.lua new file mode 100644 index 000000000..59be715a9 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_arm.lua @@ -0,0 +1,689 @@ +---------------------------------------------------------------------------- +-- LuaJIT ARM disassembler module. +-- +-- Copyright (C) 2005-2015 Mike Pall. All rights reserved. +-- Released under the MIT license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- +-- This is a helper module used by the LuaJIT machine code dumper module. +-- +-- It disassembles most user-mode ARMv7 instructions +-- NYI: Advanced SIMD and VFP instructions. +------------------------------------------------------------------------------ + +local type = type +local sub, byte, format = string.sub, string.byte, string.format +local match, gmatch, gsub = string.match, string.gmatch, string.gsub +local concat = table.concat +local bit = require("bit") +local band, bor, ror, tohex = bit.band, bit.bor, bit.ror, bit.tohex +local lshift, rshift, arshift = bit.lshift, bit.rshift, bit.arshift + +------------------------------------------------------------------------------ +-- Opcode maps +------------------------------------------------------------------------------ + +local map_loadc = { + shift = 8, mask = 15, + [10] = { + shift = 20, mask = 1, + [0] = { + shift = 23, mask = 3, + [0] = "vmovFmDN", "vstmFNdr", + _ = { + shift = 21, mask = 1, + [0] = "vstrFdl", + { shift = 16, mask = 15, [13] = "vpushFdr", _ = "vstmdbFNdr", } + }, + }, + { + shift = 23, mask = 3, + [0] = "vmovFDNm", + { shift = 16, mask = 15, [13] = "vpopFdr", _ = "vldmFNdr", }, + _ = { + shift = 21, mask = 1, + [0] = "vldrFdl", "vldmdbFNdr", + }, + }, + }, + [11] = { + shift = 20, mask = 1, + [0] = { + shift = 23, mask = 3, + [0] = "vmovGmDN", "vstmGNdr", + _ = { + shift = 21, mask = 1, + [0] = "vstrGdl", + { shift = 16, mask = 15, [13] = "vpushGdr", _ = "vstmdbGNdr", } + }, + }, + { + shift = 23, mask = 3, + [0] = "vmovGDNm", + { shift = 16, mask = 15, [13] = "vpopGdr", _ = "vldmGNdr", }, + _ = { + shift = 21, mask = 1, + [0] = "vldrGdl", "vldmdbGNdr", + }, + }, + }, + _ = { + shift = 0, mask = 0 -- NYI ldc, mcrr, mrrc. + }, +} + +local map_vfps = { + shift = 6, mask = 0x2c001, + [0] = "vmlaF.dnm", "vmlsF.dnm", + [0x04000] = "vnmlsF.dnm", [0x04001] = "vnmlaF.dnm", + [0x08000] = "vmulF.dnm", [0x08001] = "vnmulF.dnm", + [0x0c000] = "vaddF.dnm", [0x0c001] = "vsubF.dnm", + [0x20000] = "vdivF.dnm", + [0x24000] = "vfnmsF.dnm", [0x24001] = "vfnmaF.dnm", + [0x28000] = "vfmaF.dnm", [0x28001] = "vfmsF.dnm", + [0x2c000] = "vmovF.dY", + [0x2c001] = { + shift = 7, mask = 0x1e01, + [0] = "vmovF.dm", "vabsF.dm", + [0x0200] = "vnegF.dm", [0x0201] = "vsqrtF.dm", + [0x0800] = "vcmpF.dm", [0x0801] = "vcmpeF.dm", + [0x0a00] = "vcmpzF.d", [0x0a01] = "vcmpzeF.d", + [0x0e01] = "vcvtG.dF.m", + [0x1000] = "vcvt.f32.u32Fdm", [0x1001] = "vcvt.f32.s32Fdm", + [0x1800] = "vcvtr.u32F.dm", [0x1801] = "vcvt.u32F.dm", + [0x1a00] = "vcvtr.s32F.dm", [0x1a01] = "vcvt.s32F.dm", + }, +} + +local map_vfpd = { + shift = 6, mask = 0x2c001, + [0] = "vmlaG.dnm", "vmlsG.dnm", + [0x04000] = "vnmlsG.dnm", [0x04001] = "vnmlaG.dnm", + [0x08000] = "vmulG.dnm", [0x08001] = "vnmulG.dnm", + [0x0c000] = "vaddG.dnm", [0x0c001] = "vsubG.dnm", + [0x20000] = "vdivG.dnm", + [0x24000] = "vfnmsG.dnm", [0x24001] = "vfnmaG.dnm", + [0x28000] = "vfmaG.dnm", [0x28001] = "vfmsG.dnm", + [0x2c000] = "vmovG.dY", + [0x2c001] = { + shift = 7, mask = 0x1e01, + [0] = "vmovG.dm", "vabsG.dm", + [0x0200] = "vnegG.dm", [0x0201] = "vsqrtG.dm", + [0x0800] = "vcmpG.dm", [0x0801] = "vcmpeG.dm", + [0x0a00] = "vcmpzG.d", [0x0a01] = "vcmpzeG.d", + [0x0e01] = "vcvtF.dG.m", + [0x1000] = "vcvt.f64.u32GdFm", [0x1001] = "vcvt.f64.s32GdFm", + [0x1800] = "vcvtr.u32FdG.m", [0x1801] = "vcvt.u32FdG.m", + [0x1a00] = "vcvtr.s32FdG.m", [0x1a01] = "vcvt.s32FdG.m", + }, +} + +local map_datac = { + shift = 24, mask = 1, + [0] = { + shift = 4, mask = 1, + [0] = { + shift = 8, mask = 15, + [10] = map_vfps, + [11] = map_vfpd, + -- NYI cdp, mcr, mrc. + }, + { + shift = 8, mask = 15, + [10] = { + shift = 20, mask = 15, + [0] = "vmovFnD", "vmovFDn", + [14] = "vmsrD", + [15] = { shift = 12, mask = 15, [15] = "vmrs", _ = "vmrsD", }, + }, + }, + }, + "svcT", +} + +local map_loadcu = { + shift = 0, mask = 0, -- NYI unconditional CP load/store. +} + +local map_datacu = { + shift = 0, mask = 0, -- NYI unconditional CP data. +} + +local map_simddata = { + shift = 0, mask = 0, -- NYI SIMD data. +} + +local map_simdload = { + shift = 0, mask = 0, -- NYI SIMD load/store, preload. +} + +local map_preload = { + shift = 0, mask = 0, -- NYI preload. +} + +local map_media = { + shift = 20, mask = 31, + [0] = false, + { --01 + shift = 5, mask = 7, + [0] = "sadd16DNM", "sasxDNM", "ssaxDNM", "ssub16DNM", + "sadd8DNM", false, false, "ssub8DNM", + }, + { --02 + shift = 5, mask = 7, + [0] = "qadd16DNM", "qasxDNM", "qsaxDNM", "qsub16DNM", + "qadd8DNM", false, false, "qsub8DNM", + }, + { --03 + shift = 5, mask = 7, + [0] = "shadd16DNM", "shasxDNM", "shsaxDNM", "shsub16DNM", + "shadd8DNM", false, false, "shsub8DNM", + }, + false, + { --05 + shift = 5, mask = 7, + [0] = "uadd16DNM", "uasxDNM", "usaxDNM", "usub16DNM", + "uadd8DNM", false, false, "usub8DNM", + }, + { --06 + shift = 5, mask = 7, + [0] = "uqadd16DNM", "uqasxDNM", "uqsaxDNM", "uqsub16DNM", + "uqadd8DNM", false, false, "uqsub8DNM", + }, + { --07 + shift = 5, mask = 7, + [0] = "uhadd16DNM", "uhasxDNM", "uhsaxDNM", "uhsub16DNM", + "uhadd8DNM", false, false, "uhsub8DNM", + }, + { --08 + shift = 5, mask = 7, + [0] = "pkhbtDNMU", false, "pkhtbDNMU", + { shift = 16, mask = 15, [15] = "sxtb16DMU", _ = "sxtab16DNMU", }, + "pkhbtDNMU", "selDNM", "pkhtbDNMU", + }, + false, + { --0a + shift = 5, mask = 7, + [0] = "ssatDxMu", "ssat16DxM", "ssatDxMu", + { shift = 16, mask = 15, [15] = "sxtbDMU", _ = "sxtabDNMU", }, + "ssatDxMu", false, "ssatDxMu", + }, + { --0b + shift = 5, mask = 7, + [0] = "ssatDxMu", "revDM", "ssatDxMu", + { shift = 16, mask = 15, [15] = "sxthDMU", _ = "sxtahDNMU", }, + "ssatDxMu", "rev16DM", "ssatDxMu", + }, + { --0c + shift = 5, mask = 7, + [3] = { shift = 16, mask = 15, [15] = "uxtb16DMU", _ = "uxtab16DNMU", }, + }, + false, + { --0e + shift = 5, mask = 7, + [0] = "usatDwMu", "usat16DwM", "usatDwMu", + { shift = 16, mask = 15, [15] = "uxtbDMU", _ = "uxtabDNMU", }, + "usatDwMu", false, "usatDwMu", + }, + { --0f + shift = 5, mask = 7, + [0] = "usatDwMu", "rbitDM", "usatDwMu", + { shift = 16, mask = 15, [15] = "uxthDMU", _ = "uxtahDNMU", }, + "usatDwMu", "revshDM", "usatDwMu", + }, + { --10 + shift = 12, mask = 15, + [15] = { + shift = 5, mask = 7, + "smuadNMS", "smuadxNMS", "smusdNMS", "smusdxNMS", + }, + _ = { + shift = 5, mask = 7, + [0] = "smladNMSD", "smladxNMSD", "smlsdNMSD", "smlsdxNMSD", + }, + }, + false, false, false, + { --14 + shift = 5, mask = 7, + [0] = "smlaldDNMS", "smlaldxDNMS", "smlsldDNMS", "smlsldxDNMS", + }, + { --15 + shift = 5, mask = 7, + [0] = { shift = 12, mask = 15, [15] = "smmulNMS", _ = "smmlaNMSD", }, + { shift = 12, mask = 15, [15] = "smmulrNMS", _ = "smmlarNMSD", }, + false, false, false, false, + "smmlsNMSD", "smmlsrNMSD", + }, + false, false, + { --18 + shift = 5, mask = 7, + [0] = { shift = 12, mask = 15, [15] = "usad8NMS", _ = "usada8NMSD", }, + }, + false, + { --1a + shift = 5, mask = 3, [2] = "sbfxDMvw", + }, + { --1b + shift = 5, mask = 3, [2] = "sbfxDMvw", + }, + { --1c + shift = 5, mask = 3, + [0] = { shift = 0, mask = 15, [15] = "bfcDvX", _ = "bfiDMvX", }, + }, + { --1d + shift = 5, mask = 3, + [0] = { shift = 0, mask = 15, [15] = "bfcDvX", _ = "bfiDMvX", }, + }, + { --1e + shift = 5, mask = 3, [2] = "ubfxDMvw", + }, + { --1f + shift = 5, mask = 3, [2] = "ubfxDMvw", + }, +} + +local map_load = { + shift = 21, mask = 9, + { + shift = 20, mask = 5, + [0] = "strtDL", "ldrtDL", [4] = "strbtDL", [5] = "ldrbtDL", + }, + _ = { + shift = 20, mask = 5, + [0] = "strDL", "ldrDL", [4] = "strbDL", [5] = "ldrbDL", + } +} + +local map_load1 = { + shift = 4, mask = 1, + [0] = map_load, map_media, +} + +local map_loadm = { + shift = 20, mask = 1, + [0] = { + shift = 23, mask = 3, + [0] = "stmdaNR", "stmNR", + { shift = 16, mask = 63, [45] = "pushR", _ = "stmdbNR", }, "stmibNR", + }, + { + shift = 23, mask = 3, + [0] = "ldmdaNR", { shift = 16, mask = 63, [61] = "popR", _ = "ldmNR", }, + "ldmdbNR", "ldmibNR", + }, +} + +local map_data = { + shift = 21, mask = 15, + [0] = "andDNPs", "eorDNPs", "subDNPs", "rsbDNPs", + "addDNPs", "adcDNPs", "sbcDNPs", "rscDNPs", + "tstNP", "teqNP", "cmpNP", "cmnNP", + "orrDNPs", "movDPs", "bicDNPs", "mvnDPs", +} + +local map_mul = { + shift = 21, mask = 7, + [0] = "mulNMSs", "mlaNMSDs", "umaalDNMS", "mlsDNMS", + "umullDNMSs", "umlalDNMSs", "smullDNMSs", "smlalDNMSs", +} + +local map_sync = { + shift = 20, mask = 15, -- NYI: brackets around N. R(D+1) for ldrexd/strexd. + [0] = "swpDMN", false, false, false, + "swpbDMN", false, false, false, + "strexDMN", "ldrexDN", "strexdDN", "ldrexdDN", + "strexbDMN", "ldrexbDN", "strexhDN", "ldrexhDN", +} + +local map_mulh = { + shift = 21, mask = 3, + [0] = { shift = 5, mask = 3, + [0] = "smlabbNMSD", "smlatbNMSD", "smlabtNMSD", "smlattNMSD", }, + { shift = 5, mask = 3, + [0] = "smlawbNMSD", "smulwbNMS", "smlawtNMSD", "smulwtNMS", }, + { shift = 5, mask = 3, + [0] = "smlalbbDNMS", "smlaltbDNMS", "smlalbtDNMS", "smlalttDNMS", }, + { shift = 5, mask = 3, + [0] = "smulbbNMS", "smultbNMS", "smulbtNMS", "smulttNMS", }, +} + +local map_misc = { + shift = 4, mask = 7, + -- NYI: decode PSR bits of msr. + [0] = { shift = 21, mask = 1, [0] = "mrsD", "msrM", }, + { shift = 21, mask = 3, "bxM", false, "clzDM", }, + { shift = 21, mask = 3, "bxjM", }, + { shift = 21, mask = 3, "blxM", }, + false, + { shift = 21, mask = 3, [0] = "qaddDMN", "qsubDMN", "qdaddDMN", "qdsubDMN", }, + false, + { shift = 21, mask = 3, "bkptK", }, +} + +local map_datar = { + shift = 4, mask = 9, + [9] = { + shift = 5, mask = 3, + [0] = { shift = 24, mask = 1, [0] = map_mul, map_sync, }, + { shift = 20, mask = 1, [0] = "strhDL", "ldrhDL", }, + { shift = 20, mask = 1, [0] = "ldrdDL", "ldrsbDL", }, + { shift = 20, mask = 1, [0] = "strdDL", "ldrshDL", }, + }, + _ = { + shift = 20, mask = 25, + [16] = { shift = 7, mask = 1, [0] = map_misc, map_mulh, }, + _ = { + shift = 0, mask = 0xffffffff, + [bor(0xe1a00000)] = "nop", + _ = map_data, + } + }, +} + +local map_datai = { + shift = 20, mask = 31, -- NYI: decode PSR bits of msr. Decode imm12. + [16] = "movwDW", [20] = "movtDW", + [18] = { shift = 0, mask = 0xf00ff, [0] = "nopv6", _ = "msrNW", }, + [22] = "msrNW", + _ = map_data, +} + +local map_branch = { + shift = 24, mask = 1, + [0] = "bB", "blB" +} + +local map_condins = { + [0] = map_datar, map_datai, map_load, map_load1, + map_loadm, map_branch, map_loadc, map_datac +} + +-- NYI: setend. +local map_uncondins = { + [0] = false, map_simddata, map_simdload, map_preload, + false, "blxB", map_loadcu, map_datacu, +} + +------------------------------------------------------------------------------ + +local map_gpr = { + [0] = "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", + "r8", "r9", "r10", "r11", "r12", "sp", "lr", "pc", +} + +local map_cond = { + [0] = "eq", "ne", "hs", "lo", "mi", "pl", "vs", "vc", + "hi", "ls", "ge", "lt", "gt", "le", "al", +} + +local map_shift = { [0] = "lsl", "lsr", "asr", "ror", } + +------------------------------------------------------------------------------ + +-- Output a nicely formatted line with an opcode and operands. +local function putop(ctx, text, operands) + local pos = ctx.pos + local extra = "" + if ctx.rel then + local sym = ctx.symtab[ctx.rel] + if sym then + extra = "\t->"..sym + elseif band(ctx.op, 0x0e000000) ~= 0x0a000000 then + extra = "\t; 0x"..tohex(ctx.rel) + end + end + if ctx.hexdump > 0 then + ctx.out(format("%08x %s %-5s %s%s\n", + ctx.addr+pos, tohex(ctx.op), text, concat(operands, ", "), extra)) + else + ctx.out(format("%08x %-5s %s%s\n", + ctx.addr+pos, text, concat(operands, ", "), extra)) + end + ctx.pos = pos + 4 +end + +-- Fallback for unknown opcodes. +local function unknown(ctx) + return putop(ctx, ".long", { "0x"..tohex(ctx.op) }) +end + +-- Format operand 2 of load/store opcodes. +local function fmtload(ctx, op, pos) + local base = map_gpr[band(rshift(op, 16), 15)] + local x, ofs + local ext = (band(op, 0x04000000) == 0) + if not ext and band(op, 0x02000000) == 0 then + ofs = band(op, 4095) + if band(op, 0x00800000) == 0 then ofs = -ofs end + if base == "pc" then ctx.rel = ctx.addr + pos + 8 + ofs end + ofs = "#"..ofs + elseif ext and band(op, 0x00400000) ~= 0 then + ofs = band(op, 15) + band(rshift(op, 4), 0xf0) + if band(op, 0x00800000) == 0 then ofs = -ofs end + if base == "pc" then ctx.rel = ctx.addr + pos + 8 + ofs end + ofs = "#"..ofs + else + ofs = map_gpr[band(op, 15)] + if ext or band(op, 0xfe0) == 0 then + elseif band(op, 0xfe0) == 0x60 then + ofs = format("%s, rrx", ofs) + else + local sh = band(rshift(op, 7), 31) + if sh == 0 then sh = 32 end + ofs = format("%s, %s #%d", ofs, map_shift[band(rshift(op, 5), 3)], sh) + end + if band(op, 0x00800000) == 0 then ofs = "-"..ofs end + end + if ofs == "#0" then + x = format("[%s]", base) + elseif band(op, 0x01000000) == 0 then + x = format("[%s], %s", base, ofs) + else + x = format("[%s, %s]", base, ofs) + end + if band(op, 0x01200000) == 0x01200000 then x = x.."!" end + return x +end + +-- Format operand 2 of vector load/store opcodes. +local function fmtvload(ctx, op, pos) + local base = map_gpr[band(rshift(op, 16), 15)] + local ofs = band(op, 255)*4 + if band(op, 0x00800000) == 0 then ofs = -ofs end + if base == "pc" then ctx.rel = ctx.addr + pos + 8 + ofs end + if ofs == 0 then + return format("[%s]", base) + else + return format("[%s, #%d]", base, ofs) + end +end + +local function fmtvr(op, vr, sh0, sh1) + if vr == "s" then + return format("s%d", 2*band(rshift(op, sh0), 15)+band(rshift(op, sh1), 1)) + else + return format("d%d", band(rshift(op, sh0), 15)+band(rshift(op, sh1-4), 16)) + end +end + +-- Disassemble a single instruction. +local function disass_ins(ctx) + local pos = ctx.pos + local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4) + local op = bor(lshift(b3, 24), lshift(b2, 16), lshift(b1, 8), b0) + local operands = {} + local suffix = "" + local last, name, pat + local vr + ctx.op = op + ctx.rel = nil + + local cond = rshift(op, 28) + local opat + if cond == 15 then + opat = map_uncondins[band(rshift(op, 25), 7)] + else + if cond ~= 14 then suffix = map_cond[cond] end + opat = map_condins[band(rshift(op, 25), 7)] + end + while type(opat) ~= "string" do + if not opat then return unknown(ctx) end + opat = opat[band(rshift(op, opat.shift), opat.mask)] or opat._ + end + name, pat = match(opat, "^([a-z0-9]*)(.*)") + if sub(pat, 1, 1) == "." then + local s2, p2 = match(pat, "^([a-z0-9.]*)(.*)") + suffix = suffix..s2 + pat = p2 + end + + for p in gmatch(pat, ".") do + local x = nil + if p == "D" then + x = map_gpr[band(rshift(op, 12), 15)] + elseif p == "N" then + x = map_gpr[band(rshift(op, 16), 15)] + elseif p == "S" then + x = map_gpr[band(rshift(op, 8), 15)] + elseif p == "M" then + x = map_gpr[band(op, 15)] + elseif p == "d" then + x = fmtvr(op, vr, 12, 22) + elseif p == "n" then + x = fmtvr(op, vr, 16, 7) + elseif p == "m" then + x = fmtvr(op, vr, 0, 5) + elseif p == "P" then + if band(op, 0x02000000) ~= 0 then + x = ror(band(op, 255), 2*band(rshift(op, 8), 15)) + else + x = map_gpr[band(op, 15)] + if band(op, 0xff0) ~= 0 then + operands[#operands+1] = x + local s = map_shift[band(rshift(op, 5), 3)] + local r = nil + if band(op, 0xf90) == 0 then + if s == "ror" then s = "rrx" else r = "#32" end + elseif band(op, 0x10) == 0 then + r = "#"..band(rshift(op, 7), 31) + else + r = map_gpr[band(rshift(op, 8), 15)] + end + if name == "mov" then name = s; x = r + elseif r then x = format("%s %s", s, r) + else x = s end + end + end + elseif p == "L" then + x = fmtload(ctx, op, pos) + elseif p == "l" then + x = fmtvload(ctx, op, pos) + elseif p == "B" then + local addr = ctx.addr + pos + 8 + arshift(lshift(op, 8), 6) + if cond == 15 then addr = addr + band(rshift(op, 23), 2) end + ctx.rel = addr + x = "0x"..tohex(addr) + elseif p == "F" then + vr = "s" + elseif p == "G" then + vr = "d" + elseif p == "." then + suffix = suffix..(vr == "s" and ".f32" or ".f64") + elseif p == "R" then + if band(op, 0x00200000) ~= 0 and #operands == 1 then + operands[1] = operands[1].."!" + end + local t = {} + for i=0,15 do + if band(rshift(op, i), 1) == 1 then t[#t+1] = map_gpr[i] end + end + x = "{"..concat(t, ", ").."}" + elseif p == "r" then + if band(op, 0x00200000) ~= 0 and #operands == 2 then + operands[1] = operands[1].."!" + end + local s = tonumber(sub(last, 2)) + local n = band(op, 255) + if vr == "d" then n = rshift(n, 1) end + operands[#operands] = format("{%s-%s%d}", last, vr, s+n-1) + elseif p == "W" then + x = band(op, 0x0fff) + band(rshift(op, 4), 0xf000) + elseif p == "T" then + x = "#0x"..tohex(band(op, 0x00ffffff), 6) + elseif p == "U" then + x = band(rshift(op, 7), 31) + if x == 0 then x = nil end + elseif p == "u" then + x = band(rshift(op, 7), 31) + if band(op, 0x40) == 0 then + if x == 0 then x = nil else x = "lsl #"..x end + else + if x == 0 then x = "asr #32" else x = "asr #"..x end + end + elseif p == "v" then + x = band(rshift(op, 7), 31) + elseif p == "w" then + x = band(rshift(op, 16), 31) + elseif p == "x" then + x = band(rshift(op, 16), 31) + 1 + elseif p == "X" then + x = band(rshift(op, 16), 31) - last + 1 + elseif p == "Y" then + x = band(rshift(op, 12), 0xf0) + band(op, 0x0f) + elseif p == "K" then + x = "#0x"..tohex(band(rshift(op, 4), 0x0000fff0) + band(op, 15), 4) + elseif p == "s" then + if band(op, 0x00100000) ~= 0 then suffix = "s"..suffix end + else + assert(false) + end + if x then + last = x + if type(x) == "number" then x = "#"..x end + operands[#operands+1] = x + end + end + + return putop(ctx, name..suffix, operands) +end + +------------------------------------------------------------------------------ + +-- Disassemble a block of code. +local function disass_block(ctx, ofs, len) + if not ofs then ofs = 0 end + local stop = len and ofs+len or #ctx.code + ctx.pos = ofs + ctx.rel = nil + while ctx.pos < stop do disass_ins(ctx) end +end + +-- Extended API: create a disassembler context. Then call ctx:disass(ofs, len). +local function create_(code, addr, out) + local ctx = {} + ctx.code = code + ctx.addr = addr or 0 + ctx.out = out or io.write + ctx.symtab = {} + ctx.disass = disass_block + ctx.hexdump = 8 + return ctx +end + +-- Simple API: disassemble code (a string) at address and output via out. +local function disass_(code, addr, out) + create_(code, addr, out):disass() +end + +-- Return register name for RID. +local function regname_(r) + if r < 16 then return map_gpr[r] end + return "d"..(r-16) +end + +-- Public module functions. +module(...) + +create = create_ +disass = disass_ +regname = regname_ + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_mips.lua b/source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_mips.lua new file mode 100644 index 000000000..acdd2be16 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_mips.lua @@ -0,0 +1,428 @@ +---------------------------------------------------------------------------- +-- LuaJIT MIPS disassembler module. +-- +-- Copyright (C) 2005-2015 Mike Pall. All rights reserved. +-- Released under the MIT/X license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- +-- This is a helper module used by the LuaJIT machine code dumper module. +-- +-- It disassembles all standard MIPS32R1/R2 instructions. +-- Default mode is big-endian, but see: dis_mipsel.lua +------------------------------------------------------------------------------ + +local type = type +local sub, byte, format = string.sub, string.byte, string.format +local match, gmatch, gsub = string.match, string.gmatch, string.gsub +local concat = table.concat +local bit = require("bit") +local band, bor, tohex = bit.band, bit.bor, bit.tohex +local lshift, rshift, arshift = bit.lshift, bit.rshift, bit.arshift + +------------------------------------------------------------------------------ +-- Primary and extended opcode maps +------------------------------------------------------------------------------ + +local map_movci = { shift = 16, mask = 1, [0] = "movfDSC", "movtDSC", } +local map_srl = { shift = 21, mask = 1, [0] = "srlDTA", "rotrDTA", } +local map_srlv = { shift = 6, mask = 1, [0] = "srlvDTS", "rotrvDTS", } + +local map_special = { + shift = 0, mask = 63, + [0] = { shift = 0, mask = -1, [0] = "nop", _ = "sllDTA" }, + map_movci, map_srl, "sraDTA", + "sllvDTS", false, map_srlv, "sravDTS", + "jrS", "jalrD1S", "movzDST", "movnDST", + "syscallY", "breakY", false, "sync", + "mfhiD", "mthiS", "mfloD", "mtloS", + false, false, false, false, + "multST", "multuST", "divST", "divuST", + false, false, false, false, + "addDST", "addu|moveDST0", "subDST", "subu|neguDS0T", + "andDST", "orDST", "xorDST", "nor|notDST0", + false, false, "sltDST", "sltuDST", + false, false, false, false, + "tgeSTZ", "tgeuSTZ", "tltSTZ", "tltuSTZ", + "teqSTZ", false, "tneSTZ", +} + +local map_special2 = { + shift = 0, mask = 63, + [0] = "maddST", "madduST", "mulDST", false, + "msubST", "msubuST", + [32] = "clzDS", [33] = "cloDS", + [63] = "sdbbpY", +} + +local map_bshfl = { + shift = 6, mask = 31, + [2] = "wsbhDT", + [16] = "sebDT", + [24] = "sehDT", +} + +local map_special3 = { + shift = 0, mask = 63, + [0] = "extTSAK", [4] = "insTSAL", + [32] = map_bshfl, + [59] = "rdhwrTD", +} + +local map_regimm = { + shift = 16, mask = 31, + [0] = "bltzSB", "bgezSB", "bltzlSB", "bgezlSB", + false, false, false, false, + "tgeiSI", "tgeiuSI", "tltiSI", "tltiuSI", + "teqiSI", false, "tneiSI", false, + "bltzalSB", "bgezalSB", "bltzallSB", "bgezallSB", + false, false, false, false, + false, false, false, false, + false, false, false, "synciSO", +} + +local map_cop0 = { + shift = 25, mask = 1, + [0] = { + shift = 21, mask = 15, + [0] = "mfc0TDW", [4] = "mtc0TDW", + [10] = "rdpgprDT", + [11] = { shift = 5, mask = 1, [0] = "diT0", "eiT0", }, + [14] = "wrpgprDT", + }, { + shift = 0, mask = 63, + [1] = "tlbr", [2] = "tlbwi", [6] = "tlbwr", [8] = "tlbp", + [24] = "eret", [31] = "deret", + [32] = "wait", + }, +} + +local map_cop1s = { + shift = 0, mask = 63, + [0] = "add.sFGH", "sub.sFGH", "mul.sFGH", "div.sFGH", + "sqrt.sFG", "abs.sFG", "mov.sFG", "neg.sFG", + "round.l.sFG", "trunc.l.sFG", "ceil.l.sFG", "floor.l.sFG", + "round.w.sFG", "trunc.w.sFG", "ceil.w.sFG", "floor.w.sFG", + false, + { shift = 16, mask = 1, [0] = "movf.sFGC", "movt.sFGC" }, + "movz.sFGT", "movn.sFGT", + false, "recip.sFG", "rsqrt.sFG", false, + false, false, false, false, + false, false, false, false, + false, "cvt.d.sFG", false, false, + "cvt.w.sFG", "cvt.l.sFG", "cvt.ps.sFGH", false, + false, false, false, false, + false, false, false, false, + "c.f.sVGH", "c.un.sVGH", "c.eq.sVGH", "c.ueq.sVGH", + "c.olt.sVGH", "c.ult.sVGH", "c.ole.sVGH", "c.ule.sVGH", + "c.sf.sVGH", "c.ngle.sVGH", "c.seq.sVGH", "c.ngl.sVGH", + "c.lt.sVGH", "c.nge.sVGH", "c.le.sVGH", "c.ngt.sVGH", +} + +local map_cop1d = { + shift = 0, mask = 63, + [0] = "add.dFGH", "sub.dFGH", "mul.dFGH", "div.dFGH", + "sqrt.dFG", "abs.dFG", "mov.dFG", "neg.dFG", + "round.l.dFG", "trunc.l.dFG", "ceil.l.dFG", "floor.l.dFG", + "round.w.dFG", "trunc.w.dFG", "ceil.w.dFG", "floor.w.dFG", + false, + { shift = 16, mask = 1, [0] = "movf.dFGC", "movt.dFGC" }, + "movz.dFGT", "movn.dFGT", + false, "recip.dFG", "rsqrt.dFG", false, + false, false, false, false, + false, false, false, false, + "cvt.s.dFG", false, false, false, + "cvt.w.dFG", "cvt.l.dFG", false, false, + false, false, false, false, + false, false, false, false, + "c.f.dVGH", "c.un.dVGH", "c.eq.dVGH", "c.ueq.dVGH", + "c.olt.dVGH", "c.ult.dVGH", "c.ole.dVGH", "c.ule.dVGH", + "c.df.dVGH", "c.ngle.dVGH", "c.deq.dVGH", "c.ngl.dVGH", + "c.lt.dVGH", "c.nge.dVGH", "c.le.dVGH", "c.ngt.dVGH", +} + +local map_cop1ps = { + shift = 0, mask = 63, + [0] = "add.psFGH", "sub.psFGH", "mul.psFGH", false, + false, "abs.psFG", "mov.psFG", "neg.psFG", + false, false, false, false, + false, false, false, false, + false, + { shift = 16, mask = 1, [0] = "movf.psFGC", "movt.psFGC" }, + "movz.psFGT", "movn.psFGT", + false, false, false, false, + false, false, false, false, + false, false, false, false, + "cvt.s.puFG", false, false, false, + false, false, false, false, + "cvt.s.plFG", false, false, false, + "pll.psFGH", "plu.psFGH", "pul.psFGH", "puu.psFGH", + "c.f.psVGH", "c.un.psVGH", "c.eq.psVGH", "c.ueq.psVGH", + "c.olt.psVGH", "c.ult.psVGH", "c.ole.psVGH", "c.ule.psVGH", + "c.psf.psVGH", "c.ngle.psVGH", "c.pseq.psVGH", "c.ngl.psVGH", + "c.lt.psVGH", "c.nge.psVGH", "c.le.psVGH", "c.ngt.psVGH", +} + +local map_cop1w = { + shift = 0, mask = 63, + [32] = "cvt.s.wFG", [33] = "cvt.d.wFG", +} + +local map_cop1l = { + shift = 0, mask = 63, + [32] = "cvt.s.lFG", [33] = "cvt.d.lFG", +} + +local map_cop1bc = { + shift = 16, mask = 3, + [0] = "bc1fCB", "bc1tCB", "bc1flCB", "bc1tlCB", +} + +local map_cop1 = { + shift = 21, mask = 31, + [0] = "mfc1TG", false, "cfc1TG", "mfhc1TG", + "mtc1TG", false, "ctc1TG", "mthc1TG", + map_cop1bc, false, false, false, + false, false, false, false, + map_cop1s, map_cop1d, false, false, + map_cop1w, map_cop1l, map_cop1ps, +} + +local map_cop1x = { + shift = 0, mask = 63, + [0] = "lwxc1FSX", "ldxc1FSX", false, false, + false, "luxc1FSX", false, false, + "swxc1FSX", "sdxc1FSX", false, false, + false, "suxc1FSX", false, "prefxMSX", + false, false, false, false, + false, false, false, false, + false, false, false, false, + false, false, "alnv.psFGHS", false, + "madd.sFRGH", "madd.dFRGH", false, false, + false, false, "madd.psFRGH", false, + "msub.sFRGH", "msub.dFRGH", false, false, + false, false, "msub.psFRGH", false, + "nmadd.sFRGH", "nmadd.dFRGH", false, false, + false, false, "nmadd.psFRGH", false, + "nmsub.sFRGH", "nmsub.dFRGH", false, false, + false, false, "nmsub.psFRGH", false, +} + +local map_pri = { + [0] = map_special, map_regimm, "jJ", "jalJ", + "beq|beqz|bST00B", "bne|bnezST0B", "blezSB", "bgtzSB", + "addiTSI", "addiu|liTS0I", "sltiTSI", "sltiuTSI", + "andiTSU", "ori|liTS0U", "xoriTSU", "luiTU", + map_cop0, map_cop1, false, map_cop1x, + "beql|beqzlST0B", "bnel|bnezlST0B", "blezlSB", "bgtzlSB", + false, false, false, false, + map_special2, false, false, map_special3, + "lbTSO", "lhTSO", "lwlTSO", "lwTSO", + "lbuTSO", "lhuTSO", "lwrTSO", false, + "sbTSO", "shTSO", "swlTSO", "swTSO", + false, false, "swrTSO", "cacheNSO", + "llTSO", "lwc1HSO", "lwc2TSO", "prefNSO", + false, "ldc1HSO", "ldc2TSO", false, + "scTSO", "swc1HSO", "swc2TSO", false, + false, "sdc1HSO", "sdc2TSO", false, +} + +------------------------------------------------------------------------------ + +local map_gpr = { + [0] = "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", + "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", + "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", + "r24", "r25", "r26", "r27", "r28", "sp", "r30", "ra", +} + +------------------------------------------------------------------------------ + +-- Output a nicely formatted line with an opcode and operands. +local function putop(ctx, text, operands) + local pos = ctx.pos + local extra = "" + if ctx.rel then + local sym = ctx.symtab[ctx.rel] + if sym then extra = "\t->"..sym end + end + if ctx.hexdump > 0 then + ctx.out(format("%08x %s %-7s %s%s\n", + ctx.addr+pos, tohex(ctx.op), text, concat(operands, ", "), extra)) + else + ctx.out(format("%08x %-7s %s%s\n", + ctx.addr+pos, text, concat(operands, ", "), extra)) + end + ctx.pos = pos + 4 +end + +-- Fallback for unknown opcodes. +local function unknown(ctx) + return putop(ctx, ".long", { "0x"..tohex(ctx.op) }) +end + +local function get_be(ctx) + local pos = ctx.pos + local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4) + return bor(lshift(b0, 24), lshift(b1, 16), lshift(b2, 8), b3) +end + +local function get_le(ctx) + local pos = ctx.pos + local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4) + return bor(lshift(b3, 24), lshift(b2, 16), lshift(b1, 8), b0) +end + +-- Disassemble a single instruction. +local function disass_ins(ctx) + local op = ctx:get() + local operands = {} + local last = nil + ctx.op = op + ctx.rel = nil + + local opat = map_pri[rshift(op, 26)] + while type(opat) ~= "string" do + if not opat then return unknown(ctx) end + opat = opat[band(rshift(op, opat.shift), opat.mask)] or opat._ + end + local name, pat = match(opat, "^([a-z0-9_.]*)(.*)") + local altname, pat2 = match(pat, "|([a-z0-9_.|]*)(.*)") + if altname then pat = pat2 end + + for p in gmatch(pat, ".") do + local x = nil + if p == "S" then + x = map_gpr[band(rshift(op, 21), 31)] + elseif p == "T" then + x = map_gpr[band(rshift(op, 16), 31)] + elseif p == "D" then + x = map_gpr[band(rshift(op, 11), 31)] + elseif p == "F" then + x = "f"..band(rshift(op, 6), 31) + elseif p == "G" then + x = "f"..band(rshift(op, 11), 31) + elseif p == "H" then + x = "f"..band(rshift(op, 16), 31) + elseif p == "R" then + x = "f"..band(rshift(op, 21), 31) + elseif p == "A" then + x = band(rshift(op, 6), 31) + elseif p == "M" then + x = band(rshift(op, 11), 31) + elseif p == "N" then + x = band(rshift(op, 16), 31) + elseif p == "C" then + x = band(rshift(op, 18), 7) + if x == 0 then x = nil end + elseif p == "K" then + x = band(rshift(op, 11), 31) + 1 + elseif p == "L" then + x = band(rshift(op, 11), 31) - last + 1 + elseif p == "I" then + x = arshift(lshift(op, 16), 16) + elseif p == "U" then + x = band(op, 0xffff) + elseif p == "O" then + local disp = arshift(lshift(op, 16), 16) + operands[#operands] = format("%d(%s)", disp, last) + elseif p == "X" then + local index = map_gpr[band(rshift(op, 16), 31)] + operands[#operands] = format("%s(%s)", index, last) + elseif p == "B" then + x = ctx.addr + ctx.pos + arshift(lshift(op, 16), 16)*4 + 4 + ctx.rel = x + x = "0x"..tohex(x) + elseif p == "J" then + x = band(ctx.addr + ctx.pos, 0xf0000000) + band(op, 0x03ffffff)*4 + ctx.rel = x + x = "0x"..tohex(x) + elseif p == "V" then + x = band(rshift(op, 8), 7) + if x == 0 then x = nil end + elseif p == "W" then + x = band(op, 7) + if x == 0 then x = nil end + elseif p == "Y" then + x = band(rshift(op, 6), 0x000fffff) + if x == 0 then x = nil end + elseif p == "Z" then + x = band(rshift(op, 6), 1023) + if x == 0 then x = nil end + elseif p == "0" then + if last == "r0" or last == 0 then + local n = #operands + operands[n] = nil + last = operands[n-1] + if altname then + local a1, a2 = match(altname, "([^|]*)|(.*)") + if a1 then name, altname = a1, a2 + else name = altname end + end + end + elseif p == "1" then + if last == "ra" then + operands[#operands] = nil + end + else + assert(false) + end + if x then operands[#operands+1] = x; last = x end + end + + return putop(ctx, name, operands) +end + +------------------------------------------------------------------------------ + +-- Disassemble a block of code. +local function disass_block(ctx, ofs, len) + if not ofs then ofs = 0 end + local stop = len and ofs+len or #ctx.code + stop = stop - stop % 4 + ctx.pos = ofs - ofs % 4 + ctx.rel = nil + while ctx.pos < stop do disass_ins(ctx) end +end + +-- Extended API: create a disassembler context. Then call ctx:disass(ofs, len). +local function create_(code, addr, out) + local ctx = {} + ctx.code = code + ctx.addr = addr or 0 + ctx.out = out or io.write + ctx.symtab = {} + ctx.disass = disass_block + ctx.hexdump = 8 + ctx.get = get_be + return ctx +end + +local function create_el_(code, addr, out) + local ctx = create_(code, addr, out) + ctx.get = get_le + return ctx +end + +-- Simple API: disassemble code (a string) at address and output via out. +local function disass_(code, addr, out) + create_(code, addr, out):disass() +end + +local function disass_el_(code, addr, out) + create_el_(code, addr, out):disass() +end + +-- Return register name for RID. +local function regname_(r) + if r < 32 then return map_gpr[r] end + return "f"..(r-32) +end + +-- Public module functions. +module(...) + +create = create_ +create_el = create_el_ +disass = disass_ +disass_el = disass_el_ +regname = regname_ + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_mipsel.lua b/source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_mipsel.lua new file mode 100644 index 000000000..dd9d26ae6 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_mipsel.lua @@ -0,0 +1,20 @@ +---------------------------------------------------------------------------- +-- LuaJIT MIPSEL disassembler wrapper module. +-- +-- Copyright (C) 2005-2015 Mike Pall. All rights reserved. +-- Released under the MIT license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- +-- This module just exports the little-endian functions from the +-- MIPS disassembler module. All the interesting stuff is there. +------------------------------------------------------------------------------ + +local require = require + +module(...) + +local dis_mips = require(_PACKAGE.."dis_mips") + +create = dis_mips.create_el +disass = dis_mips.disass_el +regname = dis_mips.regname + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_ppc.lua b/source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_ppc.lua new file mode 100644 index 000000000..d05c43111 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_ppc.lua @@ -0,0 +1,591 @@ +---------------------------------------------------------------------------- +-- LuaJIT PPC disassembler module. +-- +-- Copyright (C) 2005-2015 Mike Pall. All rights reserved. +-- Released under the MIT/X license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- +-- This is a helper module used by the LuaJIT machine code dumper module. +-- +-- It disassembles all common, non-privileged 32/64 bit PowerPC instructions +-- plus the e500 SPE instructions and some Cell/Xenon extensions. +-- +-- NYI: VMX, VMX128 +------------------------------------------------------------------------------ + +local type = type +local sub, byte, format = string.sub, string.byte, string.format +local match, gmatch, gsub = string.match, string.gmatch, string.gsub +local concat = table.concat +local bit = require("bit") +local band, bor, tohex = bit.band, bit.bor, bit.tohex +local lshift, rshift, arshift = bit.lshift, bit.rshift, bit.arshift + +------------------------------------------------------------------------------ +-- Primary and extended opcode maps +------------------------------------------------------------------------------ + +local map_crops = { + shift = 1, mask = 1023, + [0] = "mcrfXX", + [33] = "crnor|crnotCCC=", [129] = "crandcCCC", + [193] = "crxor|crclrCCC%", [225] = "crnandCCC", + [257] = "crandCCC", [289] = "creqv|crsetCCC%", + [417] = "crorcCCC", [449] = "cror|crmoveCCC=", + [16] = "b_lrKB", [528] = "b_ctrKB", + [150] = "isync", +} + +local map_rlwinm = setmetatable({ + shift = 0, mask = -1, +}, +{ __index = function(t, x) + local rot = band(rshift(x, 11), 31) + local mb = band(rshift(x, 6), 31) + local me = band(rshift(x, 1), 31) + if mb == 0 and me == 31-rot then + return "slwiRR~A." + elseif me == 31 and mb == 32-rot then + return "srwiRR~-A." + else + return "rlwinmRR~AAA." + end + end +}) + +local map_rld = { + shift = 2, mask = 7, + [0] = "rldiclRR~HM.", "rldicrRR~HM.", "rldicRR~HM.", "rldimiRR~HM.", + { + shift = 1, mask = 1, + [0] = "rldclRR~RM.", "rldcrRR~RM.", + }, +} + +local map_ext = setmetatable({ + shift = 1, mask = 1023, + + [0] = "cmp_YLRR", [32] = "cmpl_YLRR", + [4] = "twARR", [68] = "tdARR", + + [8] = "subfcRRR.", [40] = "subfRRR.", + [104] = "negRR.", [136] = "subfeRRR.", + [200] = "subfzeRR.", [232] = "subfmeRR.", + [520] = "subfcoRRR.", [552] = "subfoRRR.", + [616] = "negoRR.", [648] = "subfeoRRR.", + [712] = "subfzeoRR.", [744] = "subfmeoRR.", + + [9] = "mulhduRRR.", [73] = "mulhdRRR.", [233] = "mulldRRR.", + [457] = "divduRRR.", [489] = "divdRRR.", + [745] = "mulldoRRR.", + [969] = "divduoRRR.", [1001] = "divdoRRR.", + + [10] = "addcRRR.", [138] = "addeRRR.", + [202] = "addzeRR.", [234] = "addmeRR.", [266] = "addRRR.", + [522] = "addcoRRR.", [650] = "addeoRRR.", + [714] = "addzeoRR.", [746] = "addmeoRR.", [778] = "addoRRR.", + + [11] = "mulhwuRRR.", [75] = "mulhwRRR.", [235] = "mullwRRR.", + [459] = "divwuRRR.", [491] = "divwRRR.", + [747] = "mullwoRRR.", + [971] = "divwouRRR.", [1003] = "divwoRRR.", + + [15] = "iselltRRR", [47] = "iselgtRRR", [79] = "iseleqRRR", + + [144] = { shift = 20, mask = 1, [0] = "mtcrfRZ~", "mtocrfRZ~", }, + [19] = { shift = 20, mask = 1, [0] = "mfcrR", "mfocrfRZ", }, + [371] = { shift = 11, mask = 1023, [392] = "mftbR", [424] = "mftbuR", }, + [339] = { + shift = 11, mask = 1023, + [32] = "mferR", [256] = "mflrR", [288] = "mfctrR", [16] = "mfspefscrR", + }, + [467] = { + shift = 11, mask = 1023, + [32] = "mtxerR", [256] = "mtlrR", [288] = "mtctrR", [16] = "mtspefscrR", + }, + + [20] = "lwarxRR0R", [84] = "ldarxRR0R", + + [21] = "ldxRR0R", [53] = "lduxRRR", + [149] = "stdxRR0R", [181] = "stduxRRR", + [341] = "lwaxRR0R", [373] = "lwauxRRR", + + [23] = "lwzxRR0R", [55] = "lwzuxRRR", + [87] = "lbzxRR0R", [119] = "lbzuxRRR", + [151] = "stwxRR0R", [183] = "stwuxRRR", + [215] = "stbxRR0R", [247] = "stbuxRRR", + [279] = "lhzxRR0R", [311] = "lhzuxRRR", + [343] = "lhaxRR0R", [375] = "lhauxRRR", + [407] = "sthxRR0R", [439] = "sthuxRRR", + + [54] = "dcbst-R0R", [86] = "dcbf-R0R", + [150] = "stwcxRR0R.", [214] = "stdcxRR0R.", + [246] = "dcbtst-R0R", [278] = "dcbt-R0R", + [310] = "eciwxRR0R", [438] = "ecowxRR0R", + [470] = "dcbi-RR", + + [598] = { + shift = 21, mask = 3, + [0] = "sync", "lwsync", "ptesync", + }, + [758] = "dcba-RR", + [854] = "eieio", [982] = "icbi-R0R", [1014] = "dcbz-R0R", + + [26] = "cntlzwRR~", [58] = "cntlzdRR~", + [122] = "popcntbRR~", + [154] = "prtywRR~", [186] = "prtydRR~", + + [28] = "andRR~R.", [60] = "andcRR~R.", [124] = "nor|notRR~R=.", + [284] = "eqvRR~R.", [316] = "xorRR~R.", + [412] = "orcRR~R.", [444] = "or|mrRR~R=.", [476] = "nandRR~R.", + [508] = "cmpbRR~R", + + [512] = "mcrxrX", + + [532] = "ldbrxRR0R", [660] = "stdbrxRR0R", + + [533] = "lswxRR0R", [597] = "lswiRR0A", + [661] = "stswxRR0R", [725] = "stswiRR0A", + + [534] = "lwbrxRR0R", [662] = "stwbrxRR0R", + [790] = "lhbrxRR0R", [918] = "sthbrxRR0R", + + [535] = "lfsxFR0R", [567] = "lfsuxFRR", + [599] = "lfdxFR0R", [631] = "lfduxFRR", + [663] = "stfsxFR0R", [695] = "stfsuxFRR", + [727] = "stfdxFR0R", [759] = "stfduxFR0R", + [855] = "lfiwaxFR0R", + [983] = "stfiwxFR0R", + + [24] = "slwRR~R.", + + [27] = "sldRR~R.", [536] = "srwRR~R.", + [792] = "srawRR~R.", [824] = "srawiRR~A.", + + [794] = "sradRR~R.", [826] = "sradiRR~H.", [827] = "sradiRR~H.", + [922] = "extshRR~.", [954] = "extsbRR~.", [986] = "extswRR~.", + + [539] = "srdRR~R.", +}, +{ __index = function(t, x) + if band(x, 31) == 15 then return "iselRRRC" end + end +}) + +local map_ld = { + shift = 0, mask = 3, + [0] = "ldRRE", "lduRRE", "lwaRRE", +} + +local map_std = { + shift = 0, mask = 3, + [0] = "stdRRE", "stduRRE", +} + +local map_fps = { + shift = 5, mask = 1, + { + shift = 1, mask = 15, + [0] = false, false, "fdivsFFF.", false, + "fsubsFFF.", "faddsFFF.", "fsqrtsF-F.", false, + "fresF-F.", "fmulsFF-F.", "frsqrtesF-F.", false, + "fmsubsFFFF~.", "fmaddsFFFF~.", "fnmsubsFFFF~.", "fnmaddsFFFF~.", + } +} + +local map_fpd = { + shift = 5, mask = 1, + [0] = { + shift = 1, mask = 1023, + [0] = "fcmpuXFF", [32] = "fcmpoXFF", [64] = "mcrfsXX", + [38] = "mtfsb1A.", [70] = "mtfsb0A.", [134] = "mtfsfiA>>-A>", + [8] = "fcpsgnFFF.", [40] = "fnegF-F.", [72] = "fmrF-F.", + [136] = "fnabsF-F.", [264] = "fabsF-F.", + [12] = "frspF-F.", + [14] = "fctiwF-F.", [15] = "fctiwzF-F.", + [583] = "mffsF.", [711] = "mtfsfZF.", + [392] = "frinF-F.", [424] = "frizF-F.", + [456] = "fripF-F.", [488] = "frimF-F.", + [814] = "fctidF-F.", [815] = "fctidzF-F.", [846] = "fcfidF-F.", + }, + { + shift = 1, mask = 15, + [0] = false, false, "fdivFFF.", false, + "fsubFFF.", "faddFFF.", "fsqrtF-F.", "fselFFFF~.", + "freF-F.", "fmulFF-F.", "frsqrteF-F.", false, + "fmsubFFFF~.", "fmaddFFFF~.", "fnmsubFFFF~.", "fnmaddFFFF~.", + } +} + +local map_spe = { + shift = 0, mask = 2047, + + [512] = "evaddwRRR", [514] = "evaddiwRAR~", + [516] = "evsubwRRR~", [518] = "evsubiwRAR~", + [520] = "evabsRR", [521] = "evnegRR", + [522] = "evextsbRR", [523] = "evextshRR", [524] = "evrndwRR", + [525] = "evcntlzwRR", [526] = "evcntlswRR", + + [527] = "brincRRR", + + [529] = "evandRRR", [530] = "evandcRRR", [534] = "evxorRRR", + [535] = "evor|evmrRRR=", [536] = "evnor|evnotRRR=", + [537] = "eveqvRRR", [539] = "evorcRRR", [542] = "evnandRRR", + + [544] = "evsrwuRRR", [545] = "evsrwsRRR", + [546] = "evsrwiuRRA", [547] = "evsrwisRRA", + [548] = "evslwRRR", [550] = "evslwiRRA", + [552] = "evrlwRRR", [553] = "evsplatiRS", + [554] = "evrlwiRRA", [555] = "evsplatfiRS", + [556] = "evmergehiRRR", [557] = "evmergeloRRR", + [558] = "evmergehiloRRR", [559] = "evmergelohiRRR", + + [560] = "evcmpgtuYRR", [561] = "evcmpgtsYRR", + [562] = "evcmpltuYRR", [563] = "evcmpltsYRR", + [564] = "evcmpeqYRR", + + [632] = "evselRRR", [633] = "evselRRRW", + [634] = "evselRRRW", [635] = "evselRRRW", + [636] = "evselRRRW", [637] = "evselRRRW", + [638] = "evselRRRW", [639] = "evselRRRW", + + [640] = "evfsaddRRR", [641] = "evfssubRRR", + [644] = "evfsabsRR", [645] = "evfsnabsRR", [646] = "evfsnegRR", + [648] = "evfsmulRRR", [649] = "evfsdivRRR", + [652] = "evfscmpgtYRR", [653] = "evfscmpltYRR", [654] = "evfscmpeqYRR", + [656] = "evfscfuiR-R", [657] = "evfscfsiR-R", + [658] = "evfscfufR-R", [659] = "evfscfsfR-R", + [660] = "evfsctuiR-R", [661] = "evfsctsiR-R", + [662] = "evfsctufR-R", [663] = "evfsctsfR-R", + [664] = "evfsctuizR-R", [666] = "evfsctsizR-R", + [668] = "evfststgtYRR", [669] = "evfststltYRR", [670] = "evfststeqYRR", + + [704] = "efsaddRRR", [705] = "efssubRRR", + [708] = "efsabsRR", [709] = "efsnabsRR", [710] = "efsnegRR", + [712] = "efsmulRRR", [713] = "efsdivRRR", + [716] = "efscmpgtYRR", [717] = "efscmpltYRR", [718] = "efscmpeqYRR", + [719] = "efscfdR-R", + [720] = "efscfuiR-R", [721] = "efscfsiR-R", + [722] = "efscfufR-R", [723] = "efscfsfR-R", + [724] = "efsctuiR-R", [725] = "efsctsiR-R", + [726] = "efsctufR-R", [727] = "efsctsfR-R", + [728] = "efsctuizR-R", [730] = "efsctsizR-R", + [732] = "efststgtYRR", [733] = "efststltYRR", [734] = "efststeqYRR", + + [736] = "efdaddRRR", [737] = "efdsubRRR", + [738] = "efdcfuidR-R", [739] = "efdcfsidR-R", + [740] = "efdabsRR", [741] = "efdnabsRR", [742] = "efdnegRR", + [744] = "efdmulRRR", [745] = "efddivRRR", + [746] = "efdctuidzR-R", [747] = "efdctsidzR-R", + [748] = "efdcmpgtYRR", [749] = "efdcmpltYRR", [750] = "efdcmpeqYRR", + [751] = "efdcfsR-R", + [752] = "efdcfuiR-R", [753] = "efdcfsiR-R", + [754] = "efdcfufR-R", [755] = "efdcfsfR-R", + [756] = "efdctuiR-R", [757] = "efdctsiR-R", + [758] = "efdctufR-R", [759] = "efdctsfR-R", + [760] = "efdctuizR-R", [762] = "efdctsizR-R", + [764] = "efdtstgtYRR", [765] = "efdtstltYRR", [766] = "efdtsteqYRR", + + [768] = "evlddxRR0R", [769] = "evlddRR8", + [770] = "evldwxRR0R", [771] = "evldwRR8", + [772] = "evldhxRR0R", [773] = "evldhRR8", + [776] = "evlhhesplatxRR0R", [777] = "evlhhesplatRR2", + [780] = "evlhhousplatxRR0R", [781] = "evlhhousplatRR2", + [782] = "evlhhossplatxRR0R", [783] = "evlhhossplatRR2", + [784] = "evlwhexRR0R", [785] = "evlwheRR4", + [788] = "evlwhouxRR0R", [789] = "evlwhouRR4", + [790] = "evlwhosxRR0R", [791] = "evlwhosRR4", + [792] = "evlwwsplatxRR0R", [793] = "evlwwsplatRR4", + [796] = "evlwhsplatxRR0R", [797] = "evlwhsplatRR4", + + [800] = "evstddxRR0R", [801] = "evstddRR8", + [802] = "evstdwxRR0R", [803] = "evstdwRR8", + [804] = "evstdhxRR0R", [805] = "evstdhRR8", + [816] = "evstwhexRR0R", [817] = "evstwheRR4", + [820] = "evstwhoxRR0R", [821] = "evstwhoRR4", + [824] = "evstwwexRR0R", [825] = "evstwweRR4", + [828] = "evstwwoxRR0R", [829] = "evstwwoRR4", + + [1027] = "evmhessfRRR", [1031] = "evmhossfRRR", [1032] = "evmheumiRRR", + [1033] = "evmhesmiRRR", [1035] = "evmhesmfRRR", [1036] = "evmhoumiRRR", + [1037] = "evmhosmiRRR", [1039] = "evmhosmfRRR", [1059] = "evmhessfaRRR", + [1063] = "evmhossfaRRR", [1064] = "evmheumiaRRR", [1065] = "evmhesmiaRRR", + [1067] = "evmhesmfaRRR", [1068] = "evmhoumiaRRR", [1069] = "evmhosmiaRRR", + [1071] = "evmhosmfaRRR", [1095] = "evmwhssfRRR", [1096] = "evmwlumiRRR", + [1100] = "evmwhumiRRR", [1101] = "evmwhsmiRRR", [1103] = "evmwhsmfRRR", + [1107] = "evmwssfRRR", [1112] = "evmwumiRRR", [1113] = "evmwsmiRRR", + [1115] = "evmwsmfRRR", [1127] = "evmwhssfaRRR", [1128] = "evmwlumiaRRR", + [1132] = "evmwhumiaRRR", [1133] = "evmwhsmiaRRR", [1135] = "evmwhsmfaRRR", + [1139] = "evmwssfaRRR", [1144] = "evmwumiaRRR", [1145] = "evmwsmiaRRR", + [1147] = "evmwsmfaRRR", + + [1216] = "evaddusiaawRR", [1217] = "evaddssiaawRR", + [1218] = "evsubfusiaawRR", [1219] = "evsubfssiaawRR", + [1220] = "evmraRR", + [1222] = "evdivwsRRR", [1223] = "evdivwuRRR", + [1224] = "evaddumiaawRR", [1225] = "evaddsmiaawRR", + [1226] = "evsubfumiaawRR", [1227] = "evsubfsmiaawRR", + + [1280] = "evmheusiaawRRR", [1281] = "evmhessiaawRRR", + [1283] = "evmhessfaawRRR", [1284] = "evmhousiaawRRR", + [1285] = "evmhossiaawRRR", [1287] = "evmhossfaawRRR", + [1288] = "evmheumiaawRRR", [1289] = "evmhesmiaawRRR", + [1291] = "evmhesmfaawRRR", [1292] = "evmhoumiaawRRR", + [1293] = "evmhosmiaawRRR", [1295] = "evmhosmfaawRRR", + [1320] = "evmhegumiaaRRR", [1321] = "evmhegsmiaaRRR", + [1323] = "evmhegsmfaaRRR", [1324] = "evmhogumiaaRRR", + [1325] = "evmhogsmiaaRRR", [1327] = "evmhogsmfaaRRR", + [1344] = "evmwlusiaawRRR", [1345] = "evmwlssiaawRRR", + [1352] = "evmwlumiaawRRR", [1353] = "evmwlsmiaawRRR", + [1363] = "evmwssfaaRRR", [1368] = "evmwumiaaRRR", + [1369] = "evmwsmiaaRRR", [1371] = "evmwsmfaaRRR", + [1408] = "evmheusianwRRR", [1409] = "evmhessianwRRR", + [1411] = "evmhessfanwRRR", [1412] = "evmhousianwRRR", + [1413] = "evmhossianwRRR", [1415] = "evmhossfanwRRR", + [1416] = "evmheumianwRRR", [1417] = "evmhesmianwRRR", + [1419] = "evmhesmfanwRRR", [1420] = "evmhoumianwRRR", + [1421] = "evmhosmianwRRR", [1423] = "evmhosmfanwRRR", + [1448] = "evmhegumianRRR", [1449] = "evmhegsmianRRR", + [1451] = "evmhegsmfanRRR", [1452] = "evmhogumianRRR", + [1453] = "evmhogsmianRRR", [1455] = "evmhogsmfanRRR", + [1472] = "evmwlusianwRRR", [1473] = "evmwlssianwRRR", + [1480] = "evmwlumianwRRR", [1481] = "evmwlsmianwRRR", + [1491] = "evmwssfanRRR", [1496] = "evmwumianRRR", + [1497] = "evmwsmianRRR", [1499] = "evmwsmfanRRR", +} + +local map_pri = { + [0] = false, false, "tdiARI", "twiARI", + map_spe, false, false, "mulliRRI", + "subficRRI", false, "cmpl_iYLRU", "cmp_iYLRI", + "addicRRI", "addic.RRI", "addi|liRR0I", "addis|lisRR0I", + "b_KBJ", "sc", "bKJ", map_crops, + "rlwimiRR~AAA.", map_rlwinm, false, "rlwnmRR~RAA.", + "oriNRR~U", "orisRR~U", "xoriRR~U", "xorisRR~U", + "andi.RR~U", "andis.RR~U", map_rld, map_ext, + "lwzRRD", "lwzuRRD", "lbzRRD", "lbzuRRD", + "stwRRD", "stwuRRD", "stbRRD", "stbuRRD", + "lhzRRD", "lhzuRRD", "lhaRRD", "lhauRRD", + "sthRRD", "sthuRRD", "lmwRRD", "stmwRRD", + "lfsFRD", "lfsuFRD", "lfdFRD", "lfduFRD", + "stfsFRD", "stfsuFRD", "stfdFRD", "stfduFRD", + false, false, map_ld, map_fps, + false, false, map_std, map_fpd, +} + +------------------------------------------------------------------------------ + +local map_gpr = { + [0] = "r0", "sp", "r2", "r3", "r4", "r5", "r6", "r7", + "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", + "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", + "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", +} + +local map_cond = { [0] = "lt", "gt", "eq", "so", "ge", "le", "ne", "ns", } + +-- Format a condition bit. +local function condfmt(cond) + if cond <= 3 then + return map_cond[band(cond, 3)] + else + return format("4*cr%d+%s", rshift(cond, 2), map_cond[band(cond, 3)]) + end +end + +------------------------------------------------------------------------------ + +-- Output a nicely formatted line with an opcode and operands. +local function putop(ctx, text, operands) + local pos = ctx.pos + local extra = "" + if ctx.rel then + local sym = ctx.symtab[ctx.rel] + if sym then extra = "\t->"..sym end + end + if ctx.hexdump > 0 then + ctx.out(format("%08x %s %-7s %s%s\n", + ctx.addr+pos, tohex(ctx.op), text, concat(operands, ", "), extra)) + else + ctx.out(format("%08x %-7s %s%s\n", + ctx.addr+pos, text, concat(operands, ", "), extra)) + end + ctx.pos = pos + 4 +end + +-- Fallback for unknown opcodes. +local function unknown(ctx) + return putop(ctx, ".long", { "0x"..tohex(ctx.op) }) +end + +-- Disassemble a single instruction. +local function disass_ins(ctx) + local pos = ctx.pos + local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4) + local op = bor(lshift(b0, 24), lshift(b1, 16), lshift(b2, 8), b3) + local operands = {} + local last = nil + local rs = 21 + ctx.op = op + ctx.rel = nil + + local opat = map_pri[rshift(b0, 2)] + while type(opat) ~= "string" do + if not opat then return unknown(ctx) end + opat = opat[band(rshift(op, opat.shift), opat.mask)] + end + local name, pat = match(opat, "^([a-z0-9_.]*)(.*)") + local altname, pat2 = match(pat, "|([a-z0-9_.]*)(.*)") + if altname then pat = pat2 end + + for p in gmatch(pat, ".") do + local x = nil + if p == "R" then + x = map_gpr[band(rshift(op, rs), 31)] + rs = rs - 5 + elseif p == "F" then + x = "f"..band(rshift(op, rs), 31) + rs = rs - 5 + elseif p == "A" then + x = band(rshift(op, rs), 31) + rs = rs - 5 + elseif p == "S" then + x = arshift(lshift(op, 27-rs), 27) + rs = rs - 5 + elseif p == "I" then + x = arshift(lshift(op, 16), 16) + elseif p == "U" then + x = band(op, 0xffff) + elseif p == "D" or p == "E" then + local disp = arshift(lshift(op, 16), 16) + if p == "E" then disp = band(disp, -4) end + if last == "r0" then last = "0" end + operands[#operands] = format("%d(%s)", disp, last) + elseif p >= "2" and p <= "8" then + local disp = band(rshift(op, rs), 31) * p + if last == "r0" then last = "0" end + operands[#operands] = format("%d(%s)", disp, last) + elseif p == "H" then + x = band(rshift(op, rs), 31) + lshift(band(op, 2), 4) + rs = rs - 5 + elseif p == "M" then + x = band(rshift(op, rs), 31) + band(op, 0x20) + elseif p == "C" then + x = condfmt(band(rshift(op, rs), 31)) + rs = rs - 5 + elseif p == "B" then + local bo = rshift(op, 21) + local cond = band(rshift(op, 16), 31) + local cn = "" + rs = rs - 10 + if band(bo, 4) == 0 then + cn = band(bo, 2) == 0 and "dnz" or "dz" + if band(bo, 0x10) == 0 then + cn = cn..(band(bo, 8) == 0 and "f" or "t") + end + if band(bo, 0x10) == 0 then x = condfmt(cond) end + name = name..(band(bo, 1) == band(rshift(op, 15), 1) and "-" or "+") + elseif band(bo, 0x10) == 0 then + cn = map_cond[band(cond, 3) + (band(bo, 8) == 0 and 4 or 0)] + if cond > 3 then x = "cr"..rshift(cond, 2) end + name = name..(band(bo, 1) == band(rshift(op, 15), 1) and "-" or "+") + end + name = gsub(name, "_", cn) + elseif p == "J" then + x = arshift(lshift(op, 27-rs), 29-rs)*4 + if band(op, 2) == 0 then x = ctx.addr + pos + x end + ctx.rel = x + x = "0x"..tohex(x) + elseif p == "K" then + if band(op, 1) ~= 0 then name = name.."l" end + if band(op, 2) ~= 0 then name = name.."a" end + elseif p == "X" or p == "Y" then + x = band(rshift(op, rs+2), 7) + if x == 0 and p == "Y" then x = nil else x = "cr"..x end + rs = rs - 5 + elseif p == "W" then + x = "cr"..band(op, 7) + elseif p == "Z" then + x = band(rshift(op, rs-4), 255) + rs = rs - 10 + elseif p == ">" then + operands[#operands] = rshift(operands[#operands], 1) + elseif p == "0" then + if last == "r0" then + operands[#operands] = nil + if altname then name = altname end + end + elseif p == "L" then + name = gsub(name, "_", band(op, 0x00200000) ~= 0 and "d" or "w") + elseif p == "." then + if band(op, 1) == 1 then name = name.."." end + elseif p == "N" then + if op == 0x60000000 then name = "nop"; break end + elseif p == "~" then + local n = #operands + operands[n-1], operands[n] = operands[n], operands[n-1] + elseif p == "=" then + local n = #operands + if last == operands[n-1] then + operands[n] = nil + name = altname + end + elseif p == "%" then + local n = #operands + if last == operands[n-1] and last == operands[n-2] then + operands[n] = nil + operands[n-1] = nil + name = altname + end + elseif p == "-" then + rs = rs - 5 + else + assert(false) + end + if x then operands[#operands+1] = x; last = x end + end + + return putop(ctx, name, operands) +end + +------------------------------------------------------------------------------ + +-- Disassemble a block of code. +local function disass_block(ctx, ofs, len) + if not ofs then ofs = 0 end + local stop = len and ofs+len or #ctx.code + stop = stop - stop % 4 + ctx.pos = ofs - ofs % 4 + ctx.rel = nil + while ctx.pos < stop do disass_ins(ctx) end +end + +-- Extended API: create a disassembler context. Then call ctx:disass(ofs, len). +local function create_(code, addr, out) + local ctx = {} + ctx.code = code + ctx.addr = addr or 0 + ctx.out = out or io.write + ctx.symtab = {} + ctx.disass = disass_block + ctx.hexdump = 8 + return ctx +end + +-- Simple API: disassemble code (a string) at address and output via out. +local function disass_(code, addr, out) + create_(code, addr, out):disass() +end + +-- Return register name for RID. +local function regname_(r) + if r < 32 then return map_gpr[r] end + return "f"..(r-32) +end + +-- Public module functions. +module(...) + +create = create_ +disass = disass_ +regname = regname_ + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_x64.lua b/source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_x64.lua new file mode 100644 index 000000000..a80981bd5 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_x64.lua @@ -0,0 +1,20 @@ +---------------------------------------------------------------------------- +-- LuaJIT x64 disassembler wrapper module. +-- +-- Copyright (C) 2005-2015 Mike Pall. All rights reserved. +-- Released under the MIT license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- +-- This module just exports the 64 bit functions from the combined +-- x86/x64 disassembler module. All the interesting stuff is there. +------------------------------------------------------------------------------ + +local require = require + +module(...) + +local dis_x86 = require(_PACKAGE.."dis_x86") + +create = dis_x86.create64 +disass = dis_x86.disass64 +regname = dis_x86.regname64 + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_x86.lua b/source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_x86.lua new file mode 100644 index 000000000..078d6094d --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/jit/dis_x86.lua @@ -0,0 +1,836 @@ +---------------------------------------------------------------------------- +-- LuaJIT x86/x64 disassembler module. +-- +-- Copyright (C) 2005-2015 Mike Pall. All rights reserved. +-- Released under the MIT license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- +-- This is a helper module used by the LuaJIT machine code dumper module. +-- +-- Sending small code snippets to an external disassembler and mixing the +-- output with our own stuff was too fragile. So I had to bite the bullet +-- and write yet another x86 disassembler. Oh well ... +-- +-- The output format is very similar to what ndisasm generates. But it has +-- been developed independently by looking at the opcode tables from the +-- Intel and AMD manuals. The supported instruction set is quite extensive +-- and reflects what a current generation Intel or AMD CPU implements in +-- 32 bit and 64 bit mode. Yes, this includes MMX, SSE, SSE2, SSE3, SSSE3, +-- SSE4.1, SSE4.2, SSE4a and even privileged and hypervisor (VMX/SVM) +-- instructions. +-- +-- Notes: +-- * The (useless) a16 prefix, 3DNow and pre-586 opcodes are unsupported. +-- * No attempt at optimization has been made -- it's fast enough for my needs. +-- * The public API may change when more architectures are added. +------------------------------------------------------------------------------ + +local type = type +local sub, byte, format = string.sub, string.byte, string.format +local match, gmatch, gsub = string.match, string.gmatch, string.gsub +local lower, rep = string.lower, string.rep + +-- Map for 1st opcode byte in 32 bit mode. Ugly? Well ... read on. +local map_opc1_32 = { +--0x +[0]="addBmr","addVmr","addBrm","addVrm","addBai","addVai","push es","pop es", +"orBmr","orVmr","orBrm","orVrm","orBai","orVai","push cs","opc2*", +--1x +"adcBmr","adcVmr","adcBrm","adcVrm","adcBai","adcVai","push ss","pop ss", +"sbbBmr","sbbVmr","sbbBrm","sbbVrm","sbbBai","sbbVai","push ds","pop ds", +--2x +"andBmr","andVmr","andBrm","andVrm","andBai","andVai","es:seg","daa", +"subBmr","subVmr","subBrm","subVrm","subBai","subVai","cs:seg","das", +--3x +"xorBmr","xorVmr","xorBrm","xorVrm","xorBai","xorVai","ss:seg","aaa", +"cmpBmr","cmpVmr","cmpBrm","cmpVrm","cmpBai","cmpVai","ds:seg","aas", +--4x +"incVR","incVR","incVR","incVR","incVR","incVR","incVR","incVR", +"decVR","decVR","decVR","decVR","decVR","decVR","decVR","decVR", +--5x +"pushUR","pushUR","pushUR","pushUR","pushUR","pushUR","pushUR","pushUR", +"popUR","popUR","popUR","popUR","popUR","popUR","popUR","popUR", +--6x +"sz*pushaw,pusha","sz*popaw,popa","boundVrm","arplWmr", +"fs:seg","gs:seg","o16:","a16", +"pushUi","imulVrmi","pushBs","imulVrms", +"insb","insVS","outsb","outsVS", +--7x +"joBj","jnoBj","jbBj","jnbBj","jzBj","jnzBj","jbeBj","jaBj", +"jsBj","jnsBj","jpeBj","jpoBj","jlBj","jgeBj","jleBj","jgBj", +--8x +"arith!Bmi","arith!Vmi","arith!Bmi","arith!Vms", +"testBmr","testVmr","xchgBrm","xchgVrm", +"movBmr","movVmr","movBrm","movVrm", +"movVmg","leaVrm","movWgm","popUm", +--9x +"nop*xchgVaR|pause|xchgWaR|repne nop","xchgVaR","xchgVaR","xchgVaR", +"xchgVaR","xchgVaR","xchgVaR","xchgVaR", +"sz*cbw,cwde,cdqe","sz*cwd,cdq,cqo","call farViw","wait", +"sz*pushfw,pushf","sz*popfw,popf","sahf","lahf", +--Ax +"movBao","movVao","movBoa","movVoa", +"movsb","movsVS","cmpsb","cmpsVS", +"testBai","testVai","stosb","stosVS", +"lodsb","lodsVS","scasb","scasVS", +--Bx +"movBRi","movBRi","movBRi","movBRi","movBRi","movBRi","movBRi","movBRi", +"movVRI","movVRI","movVRI","movVRI","movVRI","movVRI","movVRI","movVRI", +--Cx +"shift!Bmu","shift!Vmu","retBw","ret","$lesVrm","$ldsVrm","movBmi","movVmi", +"enterBwu","leave","retfBw","retf","int3","intBu","into","iretVS", +--Dx +"shift!Bm1","shift!Vm1","shift!Bmc","shift!Vmc","aamBu","aadBu","salc","xlatb", +"fp*0","fp*1","fp*2","fp*3","fp*4","fp*5","fp*6","fp*7", +--Ex +"loopneBj","loopeBj","loopBj","sz*jcxzBj,jecxzBj,jrcxzBj", +"inBau","inVau","outBua","outVua", +"callVj","jmpVj","jmp farViw","jmpBj","inBad","inVad","outBda","outVda", +--Fx +"lock:","int1","repne:rep","rep:","hlt","cmc","testb!Bm","testv!Vm", +"clc","stc","cli","sti","cld","std","incb!Bm","incd!Vm", +} +assert(#map_opc1_32 == 255) + +-- Map for 1st opcode byte in 64 bit mode (overrides only). +local map_opc1_64 = setmetatable({ + [0x06]=false, [0x07]=false, [0x0e]=false, + [0x16]=false, [0x17]=false, [0x1e]=false, [0x1f]=false, + [0x27]=false, [0x2f]=false, [0x37]=false, [0x3f]=false, + [0x60]=false, [0x61]=false, [0x62]=false, [0x63]="movsxdVrDmt", [0x67]="a32:", + [0x40]="rex*", [0x41]="rex*b", [0x42]="rex*x", [0x43]="rex*xb", + [0x44]="rex*r", [0x45]="rex*rb", [0x46]="rex*rx", [0x47]="rex*rxb", + [0x48]="rex*w", [0x49]="rex*wb", [0x4a]="rex*wx", [0x4b]="rex*wxb", + [0x4c]="rex*wr", [0x4d]="rex*wrb", [0x4e]="rex*wrx", [0x4f]="rex*wrxb", + [0x82]=false, [0x9a]=false, [0xc4]=false, [0xc5]=false, [0xce]=false, + [0xd4]=false, [0xd5]=false, [0xd6]=false, [0xea]=false, +}, { __index = map_opc1_32 }) + +-- Map for 2nd opcode byte (0F xx). True CISC hell. Hey, I told you. +-- Prefix dependent MMX/SSE opcodes: (none)|rep|o16|repne, -|F3|66|F2 +local map_opc2 = { +--0x +[0]="sldt!Dmp","sgdt!Ump","larVrm","lslVrm",nil,"syscall","clts","sysret", +"invd","wbinvd",nil,"ud1",nil,"$prefetch!Bm","femms","3dnowMrmu", +--1x +"movupsXrm|movssXrm|movupdXrm|movsdXrm", +"movupsXmr|movssXmr|movupdXmr|movsdXmr", +"movhlpsXrm$movlpsXrm|movsldupXrm|movlpdXrm|movddupXrm", +"movlpsXmr||movlpdXmr", +"unpcklpsXrm||unpcklpdXrm", +"unpckhpsXrm||unpckhpdXrm", +"movlhpsXrm$movhpsXrm|movshdupXrm|movhpdXrm", +"movhpsXmr||movhpdXmr", +"$prefetcht!Bm","hintnopVm","hintnopVm","hintnopVm", +"hintnopVm","hintnopVm","hintnopVm","hintnopVm", +--2x +"movUmx$","movUmy$","movUxm$","movUym$","movUmz$",nil,"movUzm$",nil, +"movapsXrm||movapdXrm", +"movapsXmr||movapdXmr", +"cvtpi2psXrMm|cvtsi2ssXrVmt|cvtpi2pdXrMm|cvtsi2sdXrVmt", +"movntpsXmr|movntssXmr|movntpdXmr|movntsdXmr", +"cvttps2piMrXm|cvttss2siVrXm|cvttpd2piMrXm|cvttsd2siVrXm", +"cvtps2piMrXm|cvtss2siVrXm|cvtpd2piMrXm|cvtsd2siVrXm", +"ucomissXrm||ucomisdXrm", +"comissXrm||comisdXrm", +--3x +"wrmsr","rdtsc","rdmsr","rdpmc","sysenter","sysexit",nil,"getsec", +"opc3*38",nil,"opc3*3a",nil,nil,nil,nil,nil, +--4x +"cmovoVrm","cmovnoVrm","cmovbVrm","cmovnbVrm", +"cmovzVrm","cmovnzVrm","cmovbeVrm","cmovaVrm", +"cmovsVrm","cmovnsVrm","cmovpeVrm","cmovpoVrm", +"cmovlVrm","cmovgeVrm","cmovleVrm","cmovgVrm", +--5x +"movmskpsVrXm$||movmskpdVrXm$","sqrtpsXrm|sqrtssXrm|sqrtpdXrm|sqrtsdXrm", +"rsqrtpsXrm|rsqrtssXrm","rcppsXrm|rcpssXrm", +"andpsXrm||andpdXrm","andnpsXrm||andnpdXrm", +"orpsXrm||orpdXrm","xorpsXrm||xorpdXrm", +"addpsXrm|addssXrm|addpdXrm|addsdXrm","mulpsXrm|mulssXrm|mulpdXrm|mulsdXrm", +"cvtps2pdXrm|cvtss2sdXrm|cvtpd2psXrm|cvtsd2ssXrm", +"cvtdq2psXrm|cvttps2dqXrm|cvtps2dqXrm", +"subpsXrm|subssXrm|subpdXrm|subsdXrm","minpsXrm|minssXrm|minpdXrm|minsdXrm", +"divpsXrm|divssXrm|divpdXrm|divsdXrm","maxpsXrm|maxssXrm|maxpdXrm|maxsdXrm", +--6x +"punpcklbwPrm","punpcklwdPrm","punpckldqPrm","packsswbPrm", +"pcmpgtbPrm","pcmpgtwPrm","pcmpgtdPrm","packuswbPrm", +"punpckhbwPrm","punpckhwdPrm","punpckhdqPrm","packssdwPrm", +"||punpcklqdqXrm","||punpckhqdqXrm", +"movPrVSm","movqMrm|movdquXrm|movdqaXrm", +--7x +"pshufwMrmu|pshufhwXrmu|pshufdXrmu|pshuflwXrmu","pshiftw!Pmu", +"pshiftd!Pmu","pshiftq!Mmu||pshiftdq!Xmu", +"pcmpeqbPrm","pcmpeqwPrm","pcmpeqdPrm","emms|", +"vmreadUmr||extrqXmuu$|insertqXrmuu$","vmwriteUrm||extrqXrm$|insertqXrm$", +nil,nil, +"||haddpdXrm|haddpsXrm","||hsubpdXrm|hsubpsXrm", +"movVSmMr|movqXrm|movVSmXr","movqMmr|movdquXmr|movdqaXmr", +--8x +"joVj","jnoVj","jbVj","jnbVj","jzVj","jnzVj","jbeVj","jaVj", +"jsVj","jnsVj","jpeVj","jpoVj","jlVj","jgeVj","jleVj","jgVj", +--9x +"setoBm","setnoBm","setbBm","setnbBm","setzBm","setnzBm","setbeBm","setaBm", +"setsBm","setnsBm","setpeBm","setpoBm","setlBm","setgeBm","setleBm","setgBm", +--Ax +"push fs","pop fs","cpuid","btVmr","shldVmru","shldVmrc",nil,nil, +"push gs","pop gs","rsm","btsVmr","shrdVmru","shrdVmrc","fxsave!Dmp","imulVrm", +--Bx +"cmpxchgBmr","cmpxchgVmr","$lssVrm","btrVmr", +"$lfsVrm","$lgsVrm","movzxVrBmt","movzxVrWmt", +"|popcntVrm","ud2Dp","bt!Vmu","btcVmr", +"bsfVrm","bsrVrm|lzcntVrm|bsrWrm","movsxVrBmt","movsxVrWmt", +--Cx +"xaddBmr","xaddVmr", +"cmppsXrmu|cmpssXrmu|cmppdXrmu|cmpsdXrmu","$movntiVmr|", +"pinsrwPrWmu","pextrwDrPmu", +"shufpsXrmu||shufpdXrmu","$cmpxchg!Qmp", +"bswapVR","bswapVR","bswapVR","bswapVR","bswapVR","bswapVR","bswapVR","bswapVR", +--Dx +"||addsubpdXrm|addsubpsXrm","psrlwPrm","psrldPrm","psrlqPrm", +"paddqPrm","pmullwPrm", +"|movq2dqXrMm|movqXmr|movdq2qMrXm$","pmovmskbVrMm||pmovmskbVrXm", +"psubusbPrm","psubuswPrm","pminubPrm","pandPrm", +"paddusbPrm","padduswPrm","pmaxubPrm","pandnPrm", +--Ex +"pavgbPrm","psrawPrm","psradPrm","pavgwPrm", +"pmulhuwPrm","pmulhwPrm", +"|cvtdq2pdXrm|cvttpd2dqXrm|cvtpd2dqXrm","$movntqMmr||$movntdqXmr", +"psubsbPrm","psubswPrm","pminswPrm","porPrm", +"paddsbPrm","paddswPrm","pmaxswPrm","pxorPrm", +--Fx +"|||lddquXrm","psllwPrm","pslldPrm","psllqPrm", +"pmuludqPrm","pmaddwdPrm","psadbwPrm","maskmovqMrm||maskmovdquXrm$", +"psubbPrm","psubwPrm","psubdPrm","psubqPrm", +"paddbPrm","paddwPrm","padddPrm","ud", +} +assert(map_opc2[255] == "ud") + +-- Map for three-byte opcodes. Can't wait for their next invention. +local map_opc3 = { +["38"] = { -- [66] 0f 38 xx +--0x +[0]="pshufbPrm","phaddwPrm","phadddPrm","phaddswPrm", +"pmaddubswPrm","phsubwPrm","phsubdPrm","phsubswPrm", +"psignbPrm","psignwPrm","psigndPrm","pmulhrswPrm", +nil,nil,nil,nil, +--1x +"||pblendvbXrma",nil,nil,nil, +"||blendvpsXrma","||blendvpdXrma",nil,"||ptestXrm", +nil,nil,nil,nil, +"pabsbPrm","pabswPrm","pabsdPrm",nil, +--2x +"||pmovsxbwXrm","||pmovsxbdXrm","||pmovsxbqXrm","||pmovsxwdXrm", +"||pmovsxwqXrm","||pmovsxdqXrm",nil,nil, +"||pmuldqXrm","||pcmpeqqXrm","||$movntdqaXrm","||packusdwXrm", +nil,nil,nil,nil, +--3x +"||pmovzxbwXrm","||pmovzxbdXrm","||pmovzxbqXrm","||pmovzxwdXrm", +"||pmovzxwqXrm","||pmovzxdqXrm",nil,"||pcmpgtqXrm", +"||pminsbXrm","||pminsdXrm","||pminuwXrm","||pminudXrm", +"||pmaxsbXrm","||pmaxsdXrm","||pmaxuwXrm","||pmaxudXrm", +--4x +"||pmulddXrm","||phminposuwXrm", +--Fx +[0xf0] = "|||crc32TrBmt",[0xf1] = "|||crc32TrVmt", +}, + +["3a"] = { -- [66] 0f 3a xx +--0x +[0x00]=nil,nil,nil,nil,nil,nil,nil,nil, +"||roundpsXrmu","||roundpdXrmu","||roundssXrmu","||roundsdXrmu", +"||blendpsXrmu","||blendpdXrmu","||pblendwXrmu","palignrPrmu", +--1x +nil,nil,nil,nil, +"||pextrbVmXru","||pextrwVmXru","||pextrVmSXru","||extractpsVmXru", +nil,nil,nil,nil,nil,nil,nil,nil, +--2x +"||pinsrbXrVmu","||insertpsXrmu","||pinsrXrVmuS",nil, +--4x +[0x40] = "||dppsXrmu", +[0x41] = "||dppdXrmu", +[0x42] = "||mpsadbwXrmu", +--6x +[0x60] = "||pcmpestrmXrmu",[0x61] = "||pcmpestriXrmu", +[0x62] = "||pcmpistrmXrmu",[0x63] = "||pcmpistriXrmu", +}, +} + +-- Map for VMX/SVM opcodes 0F 01 C0-FF (sgdt group with register operands). +local map_opcvm = { +[0xc1]="vmcall",[0xc2]="vmlaunch",[0xc3]="vmresume",[0xc4]="vmxoff", +[0xc8]="monitor",[0xc9]="mwait", +[0xd8]="vmrun",[0xd9]="vmmcall",[0xda]="vmload",[0xdb]="vmsave", +[0xdc]="stgi",[0xdd]="clgi",[0xde]="skinit",[0xdf]="invlpga", +[0xf8]="swapgs",[0xf9]="rdtscp", +} + +-- Map for FP opcodes. And you thought stack machines are simple? +local map_opcfp = { +-- D8-DF 00-BF: opcodes with a memory operand. +-- D8 +[0]="faddFm","fmulFm","fcomFm","fcompFm","fsubFm","fsubrFm","fdivFm","fdivrFm", +"fldFm",nil,"fstFm","fstpFm","fldenvVm","fldcwWm","fnstenvVm","fnstcwWm", +-- DA +"fiaddDm","fimulDm","ficomDm","ficompDm", +"fisubDm","fisubrDm","fidivDm","fidivrDm", +-- DB +"fildDm","fisttpDm","fistDm","fistpDm",nil,"fld twordFmp",nil,"fstp twordFmp", +-- DC +"faddGm","fmulGm","fcomGm","fcompGm","fsubGm","fsubrGm","fdivGm","fdivrGm", +-- DD +"fldGm","fisttpQm","fstGm","fstpGm","frstorDmp",nil,"fnsaveDmp","fnstswWm", +-- DE +"fiaddWm","fimulWm","ficomWm","ficompWm", +"fisubWm","fisubrWm","fidivWm","fidivrWm", +-- DF +"fildWm","fisttpWm","fistWm","fistpWm", +"fbld twordFmp","fildQm","fbstp twordFmp","fistpQm", +-- xx C0-FF: opcodes with a pseudo-register operand. +-- D8 +"faddFf","fmulFf","fcomFf","fcompFf","fsubFf","fsubrFf","fdivFf","fdivrFf", +-- D9 +"fldFf","fxchFf",{"fnop"},nil, +{"fchs","fabs",nil,nil,"ftst","fxam"}, +{"fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz"}, +{"f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp"}, +{"fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos"}, +-- DA +"fcmovbFf","fcmoveFf","fcmovbeFf","fcmovuFf",nil,{nil,"fucompp"},nil,nil, +-- DB +"fcmovnbFf","fcmovneFf","fcmovnbeFf","fcmovnuFf", +{nil,nil,"fnclex","fninit"},"fucomiFf","fcomiFf",nil, +-- DC +"fadd toFf","fmul toFf",nil,nil, +"fsub toFf","fsubr toFf","fdivr toFf","fdiv toFf", +-- DD +"ffreeFf",nil,"fstFf","fstpFf","fucomFf","fucompFf",nil,nil, +-- DE +"faddpFf","fmulpFf",nil,{nil,"fcompp"}, +"fsubrpFf","fsubpFf","fdivrpFf","fdivpFf", +-- DF +nil,nil,nil,nil,{"fnstsw ax"},"fucomipFf","fcomipFf",nil, +} +assert(map_opcfp[126] == "fcomipFf") + +-- Map for opcode groups. The subkey is sp from the ModRM byte. +local map_opcgroup = { + arith = { "add", "or", "adc", "sbb", "and", "sub", "xor", "cmp" }, + shift = { "rol", "ror", "rcl", "rcr", "shl", "shr", "sal", "sar" }, + testb = { "testBmi", "testBmi", "not", "neg", "mul", "imul", "div", "idiv" }, + testv = { "testVmi", "testVmi", "not", "neg", "mul", "imul", "div", "idiv" }, + incb = { "inc", "dec" }, + incd = { "inc", "dec", "callUmp", "$call farDmp", + "jmpUmp", "$jmp farDmp", "pushUm" }, + sldt = { "sldt", "str", "lldt", "ltr", "verr", "verw" }, + sgdt = { "vm*$sgdt", "vm*$sidt", "$lgdt", "vm*$lidt", + "smsw", nil, "lmsw", "vm*$invlpg" }, + bt = { nil, nil, nil, nil, "bt", "bts", "btr", "btc" }, + cmpxchg = { nil, "sz*,cmpxchg8bQmp,cmpxchg16bXmp", nil, nil, + nil, nil, "vmptrld|vmxon|vmclear", "vmptrst" }, + pshiftw = { nil, nil, "psrlw", nil, "psraw", nil, "psllw" }, + pshiftd = { nil, nil, "psrld", nil, "psrad", nil, "pslld" }, + pshiftq = { nil, nil, "psrlq", nil, nil, nil, "psllq" }, + pshiftdq = { nil, nil, "psrlq", "psrldq", nil, nil, "psllq", "pslldq" }, + fxsave = { "$fxsave", "$fxrstor", "$ldmxcsr", "$stmxcsr", + nil, "lfenceDp$", "mfenceDp$", "sfenceDp$clflush" }, + prefetch = { "prefetch", "prefetchw" }, + prefetcht = { "prefetchnta", "prefetcht0", "prefetcht1", "prefetcht2" }, +} + +------------------------------------------------------------------------------ + +-- Maps for register names. +local map_regs = { + B = { "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh", + "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b" }, + B64 = { "al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil", + "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b" }, + W = { "ax", "cx", "dx", "bx", "sp", "bp", "si", "di", + "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w" }, + D = { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", + "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d" }, + Q = { "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi", + "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" }, + M = { "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7", + "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7" }, -- No x64 ext! + X = { "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", + "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15" }, +} +local map_segregs = { "es", "cs", "ss", "ds", "fs", "gs", "segr6", "segr7" } + +-- Maps for size names. +local map_sz2n = { + B = 1, W = 2, D = 4, Q = 8, M = 8, X = 16, +} +local map_sz2prefix = { + B = "byte", W = "word", D = "dword", + Q = "qword", + M = "qword", X = "xword", + F = "dword", G = "qword", -- No need for sizes/register names for these two. +} + +------------------------------------------------------------------------------ + +-- Output a nicely formatted line with an opcode and operands. +local function putop(ctx, text, operands) + local code, pos, hex = ctx.code, ctx.pos, "" + local hmax = ctx.hexdump + if hmax > 0 then + for i=ctx.start,pos-1 do + hex = hex..format("%02X", byte(code, i, i)) + end + if #hex > hmax then hex = sub(hex, 1, hmax)..". " + else hex = hex..rep(" ", hmax-#hex+2) end + end + if operands then text = text.." "..operands end + if ctx.o16 then text = "o16 "..text; ctx.o16 = false end + if ctx.a32 then text = "a32 "..text; ctx.a32 = false end + if ctx.rep then text = ctx.rep.." "..text; ctx.rep = false end + if ctx.rex then + local t = (ctx.rexw and "w" or "")..(ctx.rexr and "r" or "").. + (ctx.rexx and "x" or "")..(ctx.rexb and "b" or "") + if t ~= "" then text = "rex."..t.." "..text end + ctx.rexw = false; ctx.rexr = false; ctx.rexx = false; ctx.rexb = false + ctx.rex = false + end + if ctx.seg then + local text2, n = gsub(text, "%[", "["..ctx.seg..":") + if n == 0 then text = ctx.seg.." "..text else text = text2 end + ctx.seg = false + end + if ctx.lock then text = "lock "..text; ctx.lock = false end + local imm = ctx.imm + if imm then + local sym = ctx.symtab[imm] + if sym then text = text.."\t->"..sym end + end + ctx.out(format("%08x %s%s\n", ctx.addr+ctx.start, hex, text)) + ctx.mrm = false + ctx.start = pos + ctx.imm = nil +end + +-- Clear all prefix flags. +local function clearprefixes(ctx) + ctx.o16 = false; ctx.seg = false; ctx.lock = false; ctx.rep = false + ctx.rexw = false; ctx.rexr = false; ctx.rexx = false; ctx.rexb = false + ctx.rex = false; ctx.a32 = false +end + +-- Fallback for incomplete opcodes at the end. +local function incomplete(ctx) + ctx.pos = ctx.stop+1 + clearprefixes(ctx) + return putop(ctx, "(incomplete)") +end + +-- Fallback for unknown opcodes. +local function unknown(ctx) + clearprefixes(ctx) + return putop(ctx, "(unknown)") +end + +-- Return an immediate of the specified size. +local function getimm(ctx, pos, n) + if pos+n-1 > ctx.stop then return incomplete(ctx) end + local code = ctx.code + if n == 1 then + local b1 = byte(code, pos, pos) + return b1 + elseif n == 2 then + local b1, b2 = byte(code, pos, pos+1) + return b1+b2*256 + else + local b1, b2, b3, b4 = byte(code, pos, pos+3) + local imm = b1+b2*256+b3*65536+b4*16777216 + ctx.imm = imm + return imm + end +end + +-- Process pattern string and generate the operands. +local function putpat(ctx, name, pat) + local operands, regs, sz, mode, sp, rm, sc, rx, sdisp + local code, pos, stop = ctx.code, ctx.pos, ctx.stop + + -- Chars used: 1DFGIMPQRSTUVWXacdfgijmoprstuwxyz + for p in gmatch(pat, ".") do + local x = nil + if p == "V" or p == "U" then + if ctx.rexw then sz = "Q"; ctx.rexw = false + elseif ctx.o16 then sz = "W"; ctx.o16 = false + elseif p == "U" and ctx.x64 then sz = "Q" + else sz = "D" end + regs = map_regs[sz] + elseif p == "T" then + if ctx.rexw then sz = "Q"; ctx.rexw = false else sz = "D" end + regs = map_regs[sz] + elseif p == "B" then + sz = "B" + regs = ctx.rex and map_regs.B64 or map_regs.B + elseif match(p, "[WDQMXFG]") then + sz = p + regs = map_regs[sz] + elseif p == "P" then + sz = ctx.o16 and "X" or "M"; ctx.o16 = false + regs = map_regs[sz] + elseif p == "S" then + name = name..lower(sz) + elseif p == "s" then + local imm = getimm(ctx, pos, 1); if not imm then return end + x = imm <= 127 and format("+0x%02x", imm) + or format("-0x%02x", 256-imm) + pos = pos+1 + elseif p == "u" then + local imm = getimm(ctx, pos, 1); if not imm then return end + x = format("0x%02x", imm) + pos = pos+1 + elseif p == "w" then + local imm = getimm(ctx, pos, 2); if not imm then return end + x = format("0x%x", imm) + pos = pos+2 + elseif p == "o" then -- [offset] + if ctx.x64 then + local imm1 = getimm(ctx, pos, 4); if not imm1 then return end + local imm2 = getimm(ctx, pos+4, 4); if not imm2 then return end + x = format("[0x%08x%08x]", imm2, imm1) + pos = pos+8 + else + local imm = getimm(ctx, pos, 4); if not imm then return end + x = format("[0x%08x]", imm) + pos = pos+4 + end + elseif p == "i" or p == "I" then + local n = map_sz2n[sz] + if n == 8 and ctx.x64 and p == "I" then + local imm1 = getimm(ctx, pos, 4); if not imm1 then return end + local imm2 = getimm(ctx, pos+4, 4); if not imm2 then return end + x = format("0x%08x%08x", imm2, imm1) + else + if n == 8 then n = 4 end + local imm = getimm(ctx, pos, n); if not imm then return end + if sz == "Q" and (imm < 0 or imm > 0x7fffffff) then + imm = (0xffffffff+1)-imm + x = format(imm > 65535 and "-0x%08x" or "-0x%x", imm) + else + x = format(imm > 65535 and "0x%08x" or "0x%x", imm) + end + end + pos = pos+n + elseif p == "j" then + local n = map_sz2n[sz] + if n == 8 then n = 4 end + local imm = getimm(ctx, pos, n); if not imm then return end + if sz == "B" and imm > 127 then imm = imm-256 + elseif imm > 2147483647 then imm = imm-4294967296 end + pos = pos+n + imm = imm + pos + ctx.addr + if imm > 4294967295 and not ctx.x64 then imm = imm-4294967296 end + ctx.imm = imm + if sz == "W" then + x = format("word 0x%04x", imm%65536) + elseif ctx.x64 then + local lo = imm % 0x1000000 + x = format("0x%02x%06x", (imm-lo) / 0x1000000, lo) + else + x = format("0x%08x", imm) + end + elseif p == "R" then + local r = byte(code, pos-1, pos-1)%8 + if ctx.rexb then r = r + 8; ctx.rexb = false end + x = regs[r+1] + elseif p == "a" then x = regs[1] + elseif p == "c" then x = "cl" + elseif p == "d" then x = "dx" + elseif p == "1" then x = "1" + else + if not mode then + mode = ctx.mrm + if not mode then + if pos > stop then return incomplete(ctx) end + mode = byte(code, pos, pos) + pos = pos+1 + end + rm = mode%8; mode = (mode-rm)/8 + sp = mode%8; mode = (mode-sp)/8 + sdisp = "" + if mode < 3 then + if rm == 4 then + if pos > stop then return incomplete(ctx) end + sc = byte(code, pos, pos) + pos = pos+1 + rm = sc%8; sc = (sc-rm)/8 + rx = sc%8; sc = (sc-rx)/8 + if ctx.rexx then rx = rx + 8; ctx.rexx = false end + if rx == 4 then rx = nil end + end + if mode > 0 or rm == 5 then + local dsz = mode + if dsz ~= 1 then dsz = 4 end + local disp = getimm(ctx, pos, dsz); if not disp then return end + if mode == 0 then rm = nil end + if rm or rx or (not sc and ctx.x64 and not ctx.a32) then + if dsz == 1 and disp > 127 then + sdisp = format("-0x%x", 256-disp) + elseif disp >= 0 and disp <= 0x7fffffff then + sdisp = format("+0x%x", disp) + else + sdisp = format("-0x%x", (0xffffffff+1)-disp) + end + else + sdisp = format(ctx.x64 and not ctx.a32 and + not (disp >= 0 and disp <= 0x7fffffff) + and "0xffffffff%08x" or "0x%08x", disp) + end + pos = pos+dsz + end + end + if rm and ctx.rexb then rm = rm + 8; ctx.rexb = false end + if ctx.rexr then sp = sp + 8; ctx.rexr = false end + end + if p == "m" then + if mode == 3 then x = regs[rm+1] + else + local aregs = ctx.a32 and map_regs.D or ctx.aregs + local srm, srx = "", "" + if rm then srm = aregs[rm+1] + elseif not sc and ctx.x64 and not ctx.a32 then srm = "rip" end + ctx.a32 = false + if rx then + if rm then srm = srm.."+" end + srx = aregs[rx+1] + if sc > 0 then srx = srx.."*"..(2^sc) end + end + x = format("[%s%s%s]", srm, srx, sdisp) + end + if mode < 3 and + (not match(pat, "[aRrgp]") or match(pat, "t")) then -- Yuck. + x = map_sz2prefix[sz].." "..x + end + elseif p == "r" then x = regs[sp+1] + elseif p == "g" then x = map_segregs[sp+1] + elseif p == "p" then -- Suppress prefix. + elseif p == "f" then x = "st"..rm + elseif p == "x" then + if sp == 0 and ctx.lock and not ctx.x64 then + x = "CR8"; ctx.lock = false + else + x = "CR"..sp + end + elseif p == "y" then x = "DR"..sp + elseif p == "z" then x = "TR"..sp + elseif p == "t" then + else + error("bad pattern `"..pat.."'") + end + end + if x then operands = operands and operands..", "..x or x end + end + ctx.pos = pos + return putop(ctx, name, operands) +end + +-- Forward declaration. +local map_act + +-- Fetch and cache MRM byte. +local function getmrm(ctx) + local mrm = ctx.mrm + if not mrm then + local pos = ctx.pos + if pos > ctx.stop then return nil end + mrm = byte(ctx.code, pos, pos) + ctx.pos = pos+1 + ctx.mrm = mrm + end + return mrm +end + +-- Dispatch to handler depending on pattern. +local function dispatch(ctx, opat, patgrp) + if not opat then return unknown(ctx) end + if match(opat, "%|") then -- MMX/SSE variants depending on prefix. + local p + if ctx.rep then + p = ctx.rep=="rep" and "%|([^%|]*)" or "%|[^%|]*%|[^%|]*%|([^%|]*)" + ctx.rep = false + elseif ctx.o16 then p = "%|[^%|]*%|([^%|]*)"; ctx.o16 = false + else p = "^[^%|]*" end + opat = match(opat, p) + if not opat then return unknown(ctx) end +-- ctx.rep = false; ctx.o16 = false + --XXX fails for 66 f2 0f 38 f1 06 crc32 eax,WORD PTR [esi] + --XXX remove in branches? + end + if match(opat, "%$") then -- reg$mem variants. + local mrm = getmrm(ctx); if not mrm then return incomplete(ctx) end + opat = match(opat, mrm >= 192 and "^[^%$]*" or "%$(.*)") + if opat == "" then return unknown(ctx) end + end + if opat == "" then return unknown(ctx) end + local name, pat = match(opat, "^([a-z0-9 ]*)(.*)") + if pat == "" and patgrp then pat = patgrp end + return map_act[sub(pat, 1, 1)](ctx, name, pat) +end + +-- Get a pattern from an opcode map and dispatch to handler. +local function dispatchmap(ctx, opcmap) + local pos = ctx.pos + local opat = opcmap[byte(ctx.code, pos, pos)] + pos = pos + 1 + ctx.pos = pos + return dispatch(ctx, opat) +end + +-- Map for action codes. The key is the first char after the name. +map_act = { + -- Simple opcodes without operands. + [""] = function(ctx, name, pat) + return putop(ctx, name) + end, + + -- Operand size chars fall right through. + B = putpat, W = putpat, D = putpat, Q = putpat, + V = putpat, U = putpat, T = putpat, + M = putpat, X = putpat, P = putpat, + F = putpat, G = putpat, + + -- Collect prefixes. + [":"] = function(ctx, name, pat) + ctx[pat == ":" and name or sub(pat, 2)] = name + if ctx.pos - ctx.start > 5 then return unknown(ctx) end -- Limit #prefixes. + end, + + -- Chain to special handler specified by name. + ["*"] = function(ctx, name, pat) + return map_act[name](ctx, name, sub(pat, 2)) + end, + + -- Use named subtable for opcode group. + ["!"] = function(ctx, name, pat) + local mrm = getmrm(ctx); if not mrm then return incomplete(ctx) end + return dispatch(ctx, map_opcgroup[name][((mrm-(mrm%8))/8)%8+1], sub(pat, 2)) + end, + + -- o16,o32[,o64] variants. + sz = function(ctx, name, pat) + if ctx.o16 then ctx.o16 = false + else + pat = match(pat, ",(.*)") + if ctx.rexw then + local p = match(pat, ",(.*)") + if p then pat = p; ctx.rexw = false end + end + end + pat = match(pat, "^[^,]*") + return dispatch(ctx, pat) + end, + + -- Two-byte opcode dispatch. + opc2 = function(ctx, name, pat) + return dispatchmap(ctx, map_opc2) + end, + + -- Three-byte opcode dispatch. + opc3 = function(ctx, name, pat) + return dispatchmap(ctx, map_opc3[pat]) + end, + + -- VMX/SVM dispatch. + vm = function(ctx, name, pat) + return dispatch(ctx, map_opcvm[ctx.mrm]) + end, + + -- Floating point opcode dispatch. + fp = function(ctx, name, pat) + local mrm = getmrm(ctx); if not mrm then return incomplete(ctx) end + local rm = mrm%8 + local idx = pat*8 + ((mrm-rm)/8)%8 + if mrm >= 192 then idx = idx + 64 end + local opat = map_opcfp[idx] + if type(opat) == "table" then opat = opat[rm+1] end + return dispatch(ctx, opat) + end, + + -- REX prefix. + rex = function(ctx, name, pat) + if ctx.rex then return unknown(ctx) end -- Only 1 REX prefix allowed. + for p in gmatch(pat, ".") do ctx["rex"..p] = true end + ctx.rex = true + end, + + -- Special case for nop with REX prefix. + nop = function(ctx, name, pat) + return dispatch(ctx, ctx.rex and pat or "nop") + end, +} + +------------------------------------------------------------------------------ + +-- Disassemble a block of code. +local function disass_block(ctx, ofs, len) + if not ofs then ofs = 0 end + local stop = len and ofs+len or #ctx.code + ofs = ofs + 1 + ctx.start = ofs + ctx.pos = ofs + ctx.stop = stop + ctx.imm = nil + ctx.mrm = false + clearprefixes(ctx) + while ctx.pos <= stop do dispatchmap(ctx, ctx.map1) end + if ctx.pos ~= ctx.start then incomplete(ctx) end +end + +-- Extended API: create a disassembler context. Then call ctx:disass(ofs, len). +local function create_(code, addr, out) + local ctx = {} + ctx.code = code + ctx.addr = (addr or 0) - 1 + ctx.out = out or io.write + ctx.symtab = {} + ctx.disass = disass_block + ctx.hexdump = 16 + ctx.x64 = false + ctx.map1 = map_opc1_32 + ctx.aregs = map_regs.D + return ctx +end + +local function create64_(code, addr, out) + local ctx = create_(code, addr, out) + ctx.x64 = true + ctx.map1 = map_opc1_64 + ctx.aregs = map_regs.Q + return ctx +end + +-- Simple API: disassemble code (a string) at address and output via out. +local function disass_(code, addr, out) + create_(code, addr, out):disass() +end + +local function disass64_(code, addr, out) + create64_(code, addr, out):disass() +end + +-- Return register name for RID. +local function regname_(r) + if r < 8 then return map_regs.D[r+1] end + return map_regs.X[r-7] +end + +local function regname64_(r) + if r < 16 then return map_regs.Q[r+1] end + return map_regs.X[r-15] +end + +-- Public module functions. +module(...) + +create = create_ +create64 = create64_ +disass = disass_ +disass64 = disass64_ +regname = regname_ +regname64 = regname64_ + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/jit/dump.lua b/source/libs/luajit/LuaJIT-2.0.4/src/jit/dump.lua new file mode 100644 index 000000000..d15c528ea --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/jit/dump.lua @@ -0,0 +1,699 @@ +---------------------------------------------------------------------------- +-- LuaJIT compiler dump module. +-- +-- Copyright (C) 2005-2015 Mike Pall. All rights reserved. +-- Released under the MIT license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- +-- +-- This module can be used to debug the JIT compiler itself. It dumps the +-- code representations and structures used in various compiler stages. +-- +-- Example usage: +-- +-- luajit -jdump -e "local x=0; for i=1,1e6 do x=x+i end; print(x)" +-- luajit -jdump=im -e "for i=1,1000 do for j=1,1000 do end end" | less -R +-- luajit -jdump=is myapp.lua | less -R +-- luajit -jdump=-b myapp.lua +-- luajit -jdump=+aH,myapp.html myapp.lua +-- luajit -jdump=ixT,myapp.dump myapp.lua +-- +-- The first argument specifies the dump mode. The second argument gives +-- the output file name. Default output is to stdout, unless the environment +-- variable LUAJIT_DUMPFILE is set. The file is overwritten every time the +-- module is started. +-- +-- Different features can be turned on or off with the dump mode. If the +-- mode starts with a '+', the following features are added to the default +-- set of features; a '-' removes them. Otherwise the features are replaced. +-- +-- The following dump features are available (* marks the default): +-- +-- * t Print a line for each started, ended or aborted trace (see also -jv). +-- * b Dump the traced bytecode. +-- * i Dump the IR (intermediate representation). +-- r Augment the IR with register/stack slots. +-- s Dump the snapshot map. +-- * m Dump the generated machine code. +-- x Print each taken trace exit. +-- X Print each taken trace exit and the contents of all registers. +-- a Print the IR of aborted traces, too. +-- +-- The output format can be set with the following characters: +-- +-- T Plain text output. +-- A ANSI-colored text output +-- H Colorized HTML + CSS output. +-- +-- The default output format is plain text. It's set to ANSI-colored text +-- if the COLORTERM variable is set. Note: this is independent of any output +-- redirection, which is actually considered a feature. +-- +-- You probably want to use less -R to enjoy viewing ANSI-colored text from +-- a pipe or a file. Add this to your ~/.bashrc: export LESS="-R" +-- +------------------------------------------------------------------------------ + +-- Cache some library functions and objects. +local jit = require("jit") +assert(jit.version_num == 20004, "LuaJIT core/library version mismatch") +local jutil = require("jit.util") +local vmdef = require("jit.vmdef") +local funcinfo, funcbc = jutil.funcinfo, jutil.funcbc +local traceinfo, traceir, tracek = jutil.traceinfo, jutil.traceir, jutil.tracek +local tracemc, tracesnap = jutil.tracemc, jutil.tracesnap +local traceexitstub, ircalladdr = jutil.traceexitstub, jutil.ircalladdr +local bit = require("bit") +local band, shl, shr = bit.band, bit.lshift, bit.rshift +local sub, gsub, format = string.sub, string.gsub, string.format +local byte, char, rep = string.byte, string.char, string.rep +local type, tostring = type, tostring +local stdout, stderr = io.stdout, io.stderr + +-- Load other modules on-demand. +local bcline, disass + +-- Active flag, output file handle and dump mode. +local active, out, dumpmode + +------------------------------------------------------------------------------ + +local symtabmt = { __index = false } +local symtab = {} +local nexitsym = 0 + +-- Fill nested symbol table with per-trace exit stub addresses. +local function fillsymtab_tr(tr, nexit) + local t = {} + symtabmt.__index = t + if jit.arch == "mips" or jit.arch == "mipsel" then + t[traceexitstub(tr, 0)] = "exit" + return + end + for i=0,nexit-1 do + local addr = traceexitstub(tr, i) + t[addr] = tostring(i) + end + local addr = traceexitstub(tr, nexit) + if addr then t[addr] = "stack_check" end +end + +-- Fill symbol table with trace exit stub addresses. +local function fillsymtab(tr, nexit) + local t = symtab + if nexitsym == 0 then + local ircall = vmdef.ircall + for i=0,#ircall do + local addr = ircalladdr(i) + if addr ~= 0 then t[addr] = ircall[i] end + end + end + if nexitsym == 1000000 then -- Per-trace exit stubs. + fillsymtab_tr(tr, nexit) + elseif nexit > nexitsym then -- Shared exit stubs. + for i=nexitsym,nexit-1 do + local addr = traceexitstub(i) + if addr == nil then -- Fall back to per-trace exit stubs. + fillsymtab_tr(tr, nexit) + setmetatable(symtab, symtabmt) + nexit = 1000000 + break + end + t[addr] = tostring(i) + end + nexitsym = nexit + end + return t +end + +local function dumpwrite(s) + out:write(s) +end + +-- Disassemble machine code. +local function dump_mcode(tr) + local info = traceinfo(tr) + if not info then return end + local mcode, addr, loop = tracemc(tr) + if not mcode then return end + if not disass then disass = require("jit.dis_"..jit.arch) end + out:write("---- TRACE ", tr, " mcode ", #mcode, "\n") + local ctx = disass.create(mcode, addr, dumpwrite) + ctx.hexdump = 0 + ctx.symtab = fillsymtab(tr, info.nexit) + if loop ~= 0 then + symtab[addr+loop] = "LOOP" + ctx:disass(0, loop) + out:write("->LOOP:\n") + ctx:disass(loop, #mcode-loop) + symtab[addr+loop] = nil + else + ctx:disass(0, #mcode) + end +end + +------------------------------------------------------------------------------ + +local irtype_text = { + [0] = "nil", + "fal", + "tru", + "lud", + "str", + "p32", + "thr", + "pro", + "fun", + "p64", + "cdt", + "tab", + "udt", + "flt", + "num", + "i8 ", + "u8 ", + "i16", + "u16", + "int", + "u32", + "i64", + "u64", + "sfp", +} + +local colortype_ansi = { + [0] = "%s", + "%s", + "%s", + "\027[36m%s\027[m", + "\027[32m%s\027[m", + "%s", + "\027[1m%s\027[m", + "%s", + "\027[1m%s\027[m", + "%s", + "\027[33m%s\027[m", + "\027[31m%s\027[m", + "\027[36m%s\027[m", + "\027[34m%s\027[m", + "\027[34m%s\027[m", + "\027[35m%s\027[m", + "\027[35m%s\027[m", + "\027[35m%s\027[m", + "\027[35m%s\027[m", + "\027[35m%s\027[m", + "\027[35m%s\027[m", + "\027[35m%s\027[m", + "\027[35m%s\027[m", + "\027[35m%s\027[m", +} + +local function colorize_text(s, t) + return s +end + +local function colorize_ansi(s, t) + return format(colortype_ansi[t], s) +end + +local irtype_ansi = setmetatable({}, + { __index = function(tab, t) + local s = colorize_ansi(irtype_text[t], t); tab[t] = s; return s; end }) + +local html_escape = { ["<"] = "<", [">"] = ">", ["&"] = "&", } + +local function colorize_html(s, t) + s = gsub(s, "[<>&]", html_escape) + return format('%s', irtype_text[t], s) +end + +local irtype_html = setmetatable({}, + { __index = function(tab, t) + local s = colorize_html(irtype_text[t], t); tab[t] = s; return s; end }) + +local header_html = [[ + +]] + +local colorize, irtype + +-- Lookup tables to convert some literals into names. +local litname = { + ["SLOAD "] = setmetatable({}, { __index = function(t, mode) + local s = "" + if band(mode, 1) ~= 0 then s = s.."P" end + if band(mode, 2) ~= 0 then s = s.."F" end + if band(mode, 4) ~= 0 then s = s.."T" end + if band(mode, 8) ~= 0 then s = s.."C" end + if band(mode, 16) ~= 0 then s = s.."R" end + if band(mode, 32) ~= 0 then s = s.."I" end + t[mode] = s + return s + end}), + ["XLOAD "] = { [0] = "", "R", "V", "RV", "U", "RU", "VU", "RVU", }, + ["CONV "] = setmetatable({}, { __index = function(t, mode) + local s = irtype[band(mode, 31)] + s = irtype[band(shr(mode, 5), 31)].."."..s + if band(mode, 0x400) ~= 0 then s = s.." trunc" + elseif band(mode, 0x800) ~= 0 then s = s.." sext" end + local c = shr(mode, 14) + if c == 2 then s = s.." index" elseif c == 3 then s = s.." check" end + t[mode] = s + return s + end}), + ["FLOAD "] = vmdef.irfield, + ["FREF "] = vmdef.irfield, + ["FPMATH"] = vmdef.irfpm, +} + +local function ctlsub(c) + if c == "\n" then return "\\n" + elseif c == "\r" then return "\\r" + elseif c == "\t" then return "\\t" + else return format("\\%03d", byte(c)) + end +end + +local function fmtfunc(func, pc) + local fi = funcinfo(func, pc) + if fi.loc then + return fi.loc + elseif fi.ffid then + return vmdef.ffnames[fi.ffid] + elseif fi.addr then + return format("C:%x", fi.addr) + else + return "(?)" + end +end + +local function formatk(tr, idx) + local k, t, slot = tracek(tr, idx) + local tn = type(k) + local s + if tn == "number" then + if k == 2^52+2^51 then + s = "bias" + else + s = format("%+.14g", k) + end + elseif tn == "string" then + s = format(#k > 20 and '"%.20s"~' or '"%s"', gsub(k, "%c", ctlsub)) + elseif tn == "function" then + s = fmtfunc(k) + elseif tn == "table" then + s = format("{%p}", k) + elseif tn == "userdata" then + if t == 12 then + s = format("userdata:%p", k) + else + s = format("[%p]", k) + if s == "[0x00000000]" then s = "NULL" end + end + elseif t == 21 then -- int64_t + s = sub(tostring(k), 1, -3) + if sub(s, 1, 1) ~= "-" then s = "+"..s end + else + s = tostring(k) -- For primitives. + end + s = colorize(format("%-4s", s), t) + if slot then + s = format("%s @%d", s, slot) + end + return s +end + +local function printsnap(tr, snap) + local n = 2 + for s=0,snap[1]-1 do + local sn = snap[n] + if shr(sn, 24) == s then + n = n + 1 + local ref = band(sn, 0xffff) - 0x8000 -- REF_BIAS + if ref < 0 then + out:write(formatk(tr, ref)) + elseif band(sn, 0x80000) ~= 0 then -- SNAP_SOFTFPNUM + out:write(colorize(format("%04d/%04d", ref, ref+1), 14)) + else + local m, ot, op1, op2 = traceir(tr, ref) + out:write(colorize(format("%04d", ref), band(ot, 31))) + end + out:write(band(sn, 0x10000) == 0 and " " or "|") -- SNAP_FRAME + else + out:write("---- ") + end + end + out:write("]\n") +end + +-- Dump snapshots (not interleaved with IR). +local function dump_snap(tr) + out:write("---- TRACE ", tr, " snapshots\n") + for i=0,1000000000 do + local snap = tracesnap(tr, i) + if not snap then break end + out:write(format("#%-3d %04d [ ", i, snap[0])) + printsnap(tr, snap) + end +end + +-- Return a register name or stack slot for a rid/sp location. +local function ridsp_name(ridsp, ins) + if not disass then disass = require("jit.dis_"..jit.arch) end + local rid, slot = band(ridsp, 0xff), shr(ridsp, 8) + if rid == 253 or rid == 254 then + return (slot == 0 or slot == 255) and " {sink" or format(" {%04d", ins-slot) + end + if ridsp > 255 then return format("[%x]", slot*4) end + if rid < 128 then return disass.regname(rid) end + return "" +end + +-- Dump CALL* function ref and return optional ctype. +local function dumpcallfunc(tr, ins) + local ctype + if ins > 0 then + local m, ot, op1, op2 = traceir(tr, ins) + if band(ot, 31) == 0 then -- nil type means CARG(func, ctype). + ins = op1 + ctype = formatk(tr, op2) + end + end + if ins < 0 then + out:write(format("[0x%x](", tonumber((tracek(tr, ins))))) + else + out:write(format("%04d (", ins)) + end + return ctype +end + +-- Recursively gather CALL* args and dump them. +local function dumpcallargs(tr, ins) + if ins < 0 then + out:write(formatk(tr, ins)) + else + local m, ot, op1, op2 = traceir(tr, ins) + local oidx = 6*shr(ot, 8) + local op = sub(vmdef.irnames, oidx+1, oidx+6) + if op == "CARG " then + dumpcallargs(tr, op1) + if op2 < 0 then + out:write(" ", formatk(tr, op2)) + else + out:write(" ", format("%04d", op2)) + end + else + out:write(format("%04d", ins)) + end + end +end + +-- Dump IR and interleaved snapshots. +local function dump_ir(tr, dumpsnap, dumpreg) + local info = traceinfo(tr) + if not info then return end + local nins = info.nins + out:write("---- TRACE ", tr, " IR\n") + local irnames = vmdef.irnames + local snapref = 65536 + local snap, snapno + if dumpsnap then + snap = tracesnap(tr, 0) + snapref = snap[0] + snapno = 0 + end + for ins=1,nins do + if ins >= snapref then + if dumpreg then + out:write(format(".... SNAP #%-3d [ ", snapno)) + else + out:write(format(".... SNAP #%-3d [ ", snapno)) + end + printsnap(tr, snap) + snapno = snapno + 1 + snap = tracesnap(tr, snapno) + snapref = snap and snap[0] or 65536 + end + local m, ot, op1, op2, ridsp = traceir(tr, ins) + local oidx, t = 6*shr(ot, 8), band(ot, 31) + local op = sub(irnames, oidx+1, oidx+6) + if op == "LOOP " then + if dumpreg then + out:write(format("%04d ------------ LOOP ------------\n", ins)) + else + out:write(format("%04d ------ LOOP ------------\n", ins)) + end + elseif op ~= "NOP " and op ~= "CARG " and + (dumpreg or op ~= "RENAME") then + local rid = band(ridsp, 255) + if dumpreg then + out:write(format("%04d %-6s", ins, ridsp_name(ridsp, ins))) + else + out:write(format("%04d ", ins)) + end + out:write(format("%s%s %s %s ", + (rid == 254 or rid == 253) and "}" or + (band(ot, 128) == 0 and " " or ">"), + band(ot, 64) == 0 and " " or "+", + irtype[t], op)) + local m1, m2 = band(m, 3), band(m, 3*4) + if sub(op, 1, 4) == "CALL" then + local ctype + if m2 == 1*4 then -- op2 == IRMlit + out:write(format("%-10s (", vmdef.ircall[op2])) + else + ctype = dumpcallfunc(tr, op2) + end + if op1 ~= -1 then dumpcallargs(tr, op1) end + out:write(")") + if ctype then out:write(" ctype ", ctype) end + elseif op == "CNEW " and op2 == -1 then + out:write(formatk(tr, op1)) + elseif m1 ~= 3 then -- op1 != IRMnone + if op1 < 0 then + out:write(formatk(tr, op1)) + else + out:write(format(m1 == 0 and "%04d" or "#%-3d", op1)) + end + if m2 ~= 3*4 then -- op2 != IRMnone + if m2 == 1*4 then -- op2 == IRMlit + local litn = litname[op] + if litn and litn[op2] then + out:write(" ", litn[op2]) + elseif op == "UREFO " or op == "UREFC " then + out:write(format(" #%-3d", shr(op2, 8))) + else + out:write(format(" #%-3d", op2)) + end + elseif op2 < 0 then + out:write(" ", formatk(tr, op2)) + else + out:write(format(" %04d", op2)) + end + end + end + out:write("\n") + end + end + if snap then + if dumpreg then + out:write(format(".... SNAP #%-3d [ ", snapno)) + else + out:write(format(".... SNAP #%-3d [ ", snapno)) + end + printsnap(tr, snap) + end +end + +------------------------------------------------------------------------------ + +local recprefix = "" +local recdepth = 0 + +-- Format trace error message. +local function fmterr(err, info) + if type(err) == "number" then + if type(info) == "function" then info = fmtfunc(info) end + err = format(vmdef.traceerr[err], info) + end + return err +end + +-- Dump trace states. +local function dump_trace(what, tr, func, pc, otr, oex) + if what == "stop" or (what == "abort" and dumpmode.a) then + if dumpmode.i then dump_ir(tr, dumpmode.s, dumpmode.r and what == "stop") + elseif dumpmode.s then dump_snap(tr) end + if dumpmode.m then dump_mcode(tr) end + end + if what == "start" then + if dumpmode.H then out:write('
\n') end
+    out:write("---- TRACE ", tr, " ", what)
+    if otr then out:write(" ", otr, "/", oex) end
+    out:write(" ", fmtfunc(func, pc), "\n")
+  elseif what == "stop" or what == "abort" then
+    out:write("---- TRACE ", tr, " ", what)
+    if what == "abort" then
+      out:write(" ", fmtfunc(func, pc), " -- ", fmterr(otr, oex), "\n")
+    else
+      local info = traceinfo(tr)
+      local link, ltype = info.link, info.linktype
+      if link == tr or link == 0 then
+	out:write(" -> ", ltype, "\n")
+      elseif ltype == "root" then
+	out:write(" -> ", link, "\n")
+      else
+	out:write(" -> ", link, " ", ltype, "\n")
+      end
+    end
+    if dumpmode.H then out:write("
\n\n") else out:write("\n") end + else + out:write("---- TRACE ", what, "\n\n") + end + out:flush() +end + +-- Dump recorded bytecode. +local function dump_record(tr, func, pc, depth, callee) + if depth ~= recdepth then + recdepth = depth + recprefix = rep(" .", depth) + end + local line + if pc >= 0 then + line = bcline(func, pc, recprefix) + if dumpmode.H then line = gsub(line, "[<>&]", html_escape) end + else + line = "0000 "..recprefix.." FUNCC \n" + callee = func + end + if pc <= 0 then + out:write(sub(line, 1, -2), " ; ", fmtfunc(func), "\n") + else + out:write(line) + end + if pc >= 0 and band(funcbc(func, pc), 0xff) < 16 then -- ORDER BC + out:write(bcline(func, pc+1, recprefix)) -- Write JMP for cond. + end +end + +------------------------------------------------------------------------------ + +-- Dump taken trace exits. +local function dump_texit(tr, ex, ngpr, nfpr, ...) + out:write("---- TRACE ", tr, " exit ", ex, "\n") + if dumpmode.X then + local regs = {...} + if jit.arch == "x64" then + for i=1,ngpr do + out:write(format(" %016x", regs[i])) + if i % 4 == 0 then out:write("\n") end + end + else + for i=1,ngpr do + out:write(format(" %08x", regs[i])) + if i % 8 == 0 then out:write("\n") end + end + end + if jit.arch == "mips" or jit.arch == "mipsel" then + for i=1,nfpr,2 do + out:write(format(" %+17.14g", regs[ngpr+i])) + if i % 8 == 7 then out:write("\n") end + end + else + for i=1,nfpr do + out:write(format(" %+17.14g", regs[ngpr+i])) + if i % 4 == 0 then out:write("\n") end + end + end + end +end + +------------------------------------------------------------------------------ + +-- Detach dump handlers. +local function dumpoff() + if active then + active = false + jit.attach(dump_texit) + jit.attach(dump_record) + jit.attach(dump_trace) + if out and out ~= stdout and out ~= stderr then out:close() end + out = nil + end +end + +-- Open the output file and attach dump handlers. +local function dumpon(opt, outfile) + if active then dumpoff() end + + local colormode = os.getenv("COLORTERM") and "A" or "T" + if opt then + opt = gsub(opt, "[TAH]", function(mode) colormode = mode; return ""; end) + end + + local m = { t=true, b=true, i=true, m=true, } + if opt and opt ~= "" then + local o = sub(opt, 1, 1) + if o ~= "+" and o ~= "-" then m = {} end + for i=1,#opt do m[sub(opt, i, i)] = (o ~= "-") end + end + dumpmode = m + + if m.t or m.b or m.i or m.s or m.m then + jit.attach(dump_trace, "trace") + end + if m.b then + jit.attach(dump_record, "record") + if not bcline then bcline = require("jit.bc").line end + end + if m.x or m.X then + jit.attach(dump_texit, "texit") + end + + if not outfile then outfile = os.getenv("LUAJIT_DUMPFILE") end + if outfile then + out = outfile == "-" and stdout or assert(io.open(outfile, "w")) + else + out = stdout + end + + m[colormode] = true + if colormode == "A" then + colorize = colorize_ansi + irtype = irtype_ansi + elseif colormode == "H" then + colorize = colorize_html + irtype = irtype_html + out:write(header_html) + else + colorize = colorize_text + irtype = irtype_text + end + + active = true +end + +-- Public module functions. +module(...) + +on = dumpon +off = dumpoff +start = dumpon -- For -j command line option. + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/jit/v.lua b/source/libs/luajit/LuaJIT-2.0.4/src/jit/v.lua new file mode 100644 index 000000000..32666fd1a --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/jit/v.lua @@ -0,0 +1,167 @@ +---------------------------------------------------------------------------- +-- Verbose mode of the LuaJIT compiler. +-- +-- Copyright (C) 2005-2015 Mike Pall. All rights reserved. +-- Released under the MIT license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- +-- +-- This module shows verbose information about the progress of the +-- JIT compiler. It prints one line for each generated trace. This module +-- is useful to see which code has been compiled or where the compiler +-- punts and falls back to the interpreter. +-- +-- Example usage: +-- +-- luajit -jv -e "for i=1,1000 do for j=1,1000 do end end" +-- luajit -jv=myapp.out myapp.lua +-- +-- Default output is to stderr. To redirect the output to a file, pass a +-- filename as an argument (use '-' for stdout) or set the environment +-- variable LUAJIT_VERBOSEFILE. The file is overwritten every time the +-- module is started. +-- +-- The output from the first example should look like this: +-- +-- [TRACE 1 (command line):1 loop] +-- [TRACE 2 (1/3) (command line):1 -> 1] +-- +-- The first number in each line is the internal trace number. Next are +-- the file name ('(command line)') and the line number (':1') where the +-- trace has started. Side traces also show the parent trace number and +-- the exit number where they are attached to in parentheses ('(1/3)'). +-- An arrow at the end shows where the trace links to ('-> 1'), unless +-- it loops to itself. +-- +-- In this case the inner loop gets hot and is traced first, generating +-- a root trace. Then the last exit from the 1st trace gets hot, too, +-- and triggers generation of the 2nd trace. The side trace follows the +-- path along the outer loop and *around* the inner loop, back to its +-- start, and then links to the 1st trace. Yes, this may seem unusual, +-- if you know how traditional compilers work. Trace compilers are full +-- of surprises like this -- have fun! :-) +-- +-- Aborted traces are shown like this: +-- +-- [TRACE --- foo.lua:44 -- leaving loop in root trace at foo:lua:50] +-- +-- Don't worry -- trace aborts are quite common, even in programs which +-- can be fully compiled. The compiler may retry several times until it +-- finds a suitable trace. +-- +-- Of course this doesn't work with features that are not-yet-implemented +-- (NYI error messages). The VM simply falls back to the interpreter. This +-- may not matter at all if the particular trace is not very high up in +-- the CPU usage profile. Oh, and the interpreter is quite fast, too. +-- +-- Also check out the -jdump module, which prints all the gory details. +-- +------------------------------------------------------------------------------ + +-- Cache some library functions and objects. +local jit = require("jit") +assert(jit.version_num == 20004, "LuaJIT core/library version mismatch") +local jutil = require("jit.util") +local vmdef = require("jit.vmdef") +local funcinfo, traceinfo = jutil.funcinfo, jutil.traceinfo +local type, format = type, string.format +local stdout, stderr = io.stdout, io.stderr + +-- Active flag and output file handle. +local active, out + +------------------------------------------------------------------------------ + +local startloc, startex + +local function fmtfunc(func, pc) + local fi = funcinfo(func, pc) + if fi.loc then + return fi.loc + elseif fi.ffid then + return vmdef.ffnames[fi.ffid] + elseif fi.addr then + return format("C:%x", fi.addr) + else + return "(?)" + end +end + +-- Format trace error message. +local function fmterr(err, info) + if type(err) == "number" then + if type(info) == "function" then info = fmtfunc(info) end + err = format(vmdef.traceerr[err], info) + end + return err +end + +-- Dump trace states. +local function dump_trace(what, tr, func, pc, otr, oex) + if what == "start" then + startloc = fmtfunc(func, pc) + startex = otr and "("..otr.."/"..oex..") " or "" + else + if what == "abort" then + local loc = fmtfunc(func, pc) + if loc ~= startloc then + out:write(format("[TRACE --- %s%s -- %s at %s]\n", + startex, startloc, fmterr(otr, oex), loc)) + else + out:write(format("[TRACE --- %s%s -- %s]\n", + startex, startloc, fmterr(otr, oex))) + end + elseif what == "stop" then + local info = traceinfo(tr) + local link, ltype = info.link, info.linktype + if ltype == "interpreter" then + out:write(format("[TRACE %3s %s%s -- fallback to interpreter]\n", + tr, startex, startloc)) + elseif link == tr or link == 0 then + out:write(format("[TRACE %3s %s%s %s]\n", + tr, startex, startloc, ltype)) + elseif ltype == "root" then + out:write(format("[TRACE %3s %s%s -> %d]\n", + tr, startex, startloc, link)) + else + out:write(format("[TRACE %3s %s%s -> %d %s]\n", + tr, startex, startloc, link, ltype)) + end + else + out:write(format("[TRACE %s]\n", what)) + end + out:flush() + end +end + +------------------------------------------------------------------------------ + +-- Detach dump handlers. +local function dumpoff() + if active then + active = false + jit.attach(dump_trace) + if out and out ~= stdout and out ~= stderr then out:close() end + out = nil + end +end + +-- Open the output file and attach dump handlers. +local function dumpon(outfile) + if active then dumpoff() end + if not outfile then outfile = os.getenv("LUAJIT_VERBOSEFILE") end + if outfile then + out = outfile == "-" and stdout or assert(io.open(outfile, "w")) + else + out = stderr + end + jit.attach(dump_trace, "trace") + active = true +end + +-- Public module functions. +module(...) + +on = dumpon +off = dumpoff +start = dumpon -- For -j command line option. + diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lauxlib.h b/source/libs/luajit/LuaJIT-2.0.4/src/lauxlib.h similarity index 100% rename from source/libs/luajit/LuaJIT-2.0.3/src/lauxlib.h rename to source/libs/luajit/LuaJIT-2.0.4/src/lauxlib.h diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lbitlib.c b/source/libs/luajit/LuaJIT-2.0.4/src/lbitlib.c similarity index 100% rename from source/libs/luajit/LuaJIT-2.0.3/src/lbitlib.c rename to source/libs/luajit/LuaJIT-2.0.4/src/lbitlib.c diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lib_aux.c b/source/libs/luajit/LuaJIT-2.0.4/src/lib_aux.c new file mode 100644 index 000000000..4a1b70ddc --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lib_aux.c @@ -0,0 +1,356 @@ +/* +** Auxiliary library for the Lua/C API. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Major parts taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#include +#include +#include + +#define lib_aux_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" + +#include "lj_obj.h" +#include "lj_err.h" +#include "lj_state.h" +#include "lj_trace.h" +#include "lj_lib.h" + +#if LJ_TARGET_POSIX +#include +#endif + +/* -- I/O error handling -------------------------------------------------- */ + +LUALIB_API int luaL_fileresult(lua_State *L, int stat, const char *fname) +{ + if (stat) { + setboolV(L->top++, 1); + return 1; + } else { + int en = errno; /* Lua API calls may change this value. */ + setnilV(L->top++); + if (fname) + lua_pushfstring(L, "%s: %s", fname, strerror(en)); + else + lua_pushfstring(L, "%s", strerror(en)); + setintV(L->top++, en); + lj_trace_abort(G(L)); + return 3; + } +} + +LUALIB_API int luaL_execresult(lua_State *L, int stat) +{ + if (stat != -1) { +#if LJ_TARGET_POSIX + if (WIFSIGNALED(stat)) { + stat = WTERMSIG(stat); + setnilV(L->top++); + lua_pushliteral(L, "signal"); + } else { + if (WIFEXITED(stat)) + stat = WEXITSTATUS(stat); + if (stat == 0) + setboolV(L->top++, 1); + else + setnilV(L->top++); + lua_pushliteral(L, "exit"); + } +#else + if (stat == 0) + setboolV(L->top++, 1); + else + setnilV(L->top++); + lua_pushliteral(L, "exit"); +#endif + setintV(L->top++, stat); + return 3; + } + return luaL_fileresult(L, 0, NULL); +} + +/* -- Module registration ------------------------------------------------- */ + +LUALIB_API const char *luaL_findtable(lua_State *L, int idx, + const char *fname, int szhint) +{ + const char *e; + lua_pushvalue(L, idx); + do { + e = strchr(fname, '.'); + if (e == NULL) e = fname + strlen(fname); + lua_pushlstring(L, fname, (size_t)(e - fname)); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { /* no such field? */ + lua_pop(L, 1); /* remove this nil */ + lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ + lua_pushlstring(L, fname, (size_t)(e - fname)); + lua_pushvalue(L, -2); + lua_settable(L, -4); /* set new table into field */ + } else if (!lua_istable(L, -1)) { /* field has a non-table value? */ + lua_pop(L, 2); /* remove table and value */ + return fname; /* return problematic part of the name */ + } + lua_remove(L, -2); /* remove previous table */ + fname = e + 1; + } while (*e == '.'); + return NULL; +} + +static int libsize(const luaL_Reg *l) +{ + int size = 0; + for (; l->name; l++) size++; + return size; +} + +LUALIB_API void luaL_openlib(lua_State *L, const char *libname, + const luaL_Reg *l, int nup) +{ + lj_lib_checkfpu(L); + if (libname) { + int size = libsize(l); + /* check whether lib already exists */ + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 16); + lua_getfield(L, -1, libname); /* get _LOADED[libname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL) + lj_err_callerv(L, LJ_ERR_BADMODN, libname); + lua_pushvalue(L, -1); + lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ + } + lua_remove(L, -2); /* remove _LOADED table */ + lua_insert(L, -(nup+1)); /* move library table to below upvalues */ + } + for (; l->name; l++) { + int i; + for (i = 0; i < nup; i++) /* copy upvalues to the top */ + lua_pushvalue(L, -nup); + lua_pushcclosure(L, l->func, nup); + lua_setfield(L, -(nup+2), l->name); + } + lua_pop(L, nup); /* remove upvalues */ +} + +LUALIB_API void luaL_register(lua_State *L, const char *libname, + const luaL_Reg *l) +{ + luaL_openlib(L, libname, l, 0); +} + +LUALIB_API const char *luaL_gsub(lua_State *L, const char *s, + const char *p, const char *r) +{ + const char *wild; + size_t l = strlen(p); + luaL_Buffer b; + luaL_buffinit(L, &b); + while ((wild = strstr(s, p)) != NULL) { + luaL_addlstring(&b, s, (size_t)(wild - s)); /* push prefix */ + luaL_addstring(&b, r); /* push replacement in place of pattern */ + s = wild + l; /* continue after `p' */ + } + luaL_addstring(&b, s); /* push last suffix */ + luaL_pushresult(&b); + return lua_tostring(L, -1); +} + +/* -- Buffer handling ----------------------------------------------------- */ + +#define bufflen(B) ((size_t)((B)->p - (B)->buffer)) +#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B))) + +static int emptybuffer(luaL_Buffer *B) +{ + size_t l = bufflen(B); + if (l == 0) + return 0; /* put nothing on stack */ + lua_pushlstring(B->L, B->buffer, l); + B->p = B->buffer; + B->lvl++; + return 1; +} + +static void adjuststack(luaL_Buffer *B) +{ + if (B->lvl > 1) { + lua_State *L = B->L; + int toget = 1; /* number of levels to concat */ + size_t toplen = lua_strlen(L, -1); + do { + size_t l = lua_strlen(L, -(toget+1)); + if (!(B->lvl - toget + 1 >= LUA_MINSTACK/2 || toplen > l)) + break; + toplen += l; + toget++; + } while (toget < B->lvl); + lua_concat(L, toget); + B->lvl = B->lvl - toget + 1; + } +} + +LUALIB_API char *luaL_prepbuffer(luaL_Buffer *B) +{ + if (emptybuffer(B)) + adjuststack(B); + return B->buffer; +} + +LUALIB_API void luaL_addlstring(luaL_Buffer *B, const char *s, size_t l) +{ + while (l--) + luaL_addchar(B, *s++); +} + +LUALIB_API void luaL_addstring(luaL_Buffer *B, const char *s) +{ + luaL_addlstring(B, s, strlen(s)); +} + +LUALIB_API void luaL_pushresult(luaL_Buffer *B) +{ + emptybuffer(B); + lua_concat(B->L, B->lvl); + B->lvl = 1; +} + +LUALIB_API void luaL_addvalue(luaL_Buffer *B) +{ + lua_State *L = B->L; + size_t vl; + const char *s = lua_tolstring(L, -1, &vl); + if (vl <= bufffree(B)) { /* fit into buffer? */ + memcpy(B->p, s, vl); /* put it there */ + B->p += vl; + lua_pop(L, 1); /* remove from stack */ + } else { + if (emptybuffer(B)) + lua_insert(L, -2); /* put buffer before new value */ + B->lvl++; /* add new value into B stack */ + adjuststack(B); + } +} + +LUALIB_API void luaL_buffinit(lua_State *L, luaL_Buffer *B) +{ + B->L = L; + B->p = B->buffer; + B->lvl = 0; +} + +/* -- Reference management ------------------------------------------------ */ + +#define FREELIST_REF 0 + +/* Convert a stack index to an absolute index. */ +#define abs_index(L, i) \ + ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : lua_gettop(L) + (i) + 1) + +LUALIB_API int luaL_ref(lua_State *L, int t) +{ + int ref; + t = abs_index(L, t); + if (lua_isnil(L, -1)) { + lua_pop(L, 1); /* remove from stack */ + return LUA_REFNIL; /* `nil' has a unique fixed reference */ + } + lua_rawgeti(L, t, FREELIST_REF); /* get first free element */ + ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */ + lua_pop(L, 1); /* remove it from stack */ + if (ref != 0) { /* any free element? */ + lua_rawgeti(L, t, ref); /* remove it from list */ + lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ + } else { /* no free elements */ + ref = (int)lua_objlen(L, t); + ref++; /* create new reference */ + } + lua_rawseti(L, t, ref); + return ref; +} + +LUALIB_API void luaL_unref(lua_State *L, int t, int ref) +{ + if (ref >= 0) { + t = abs_index(L, t); + lua_rawgeti(L, t, FREELIST_REF); + lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */ + lua_pushinteger(L, ref); + lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */ + } +} + +/* -- Default allocator and panic function -------------------------------- */ + +static int panic(lua_State *L) +{ + const char *s = lua_tostring(L, -1); + fputs("PANIC: unprotected error in call to Lua API (", stderr); + fputs(s ? s : "?", stderr); + fputc(')', stderr); fputc('\n', stderr); + fflush(stderr); + return 0; +} + +#ifdef LUAJIT_USE_SYSMALLOC + +#if LJ_64 && !defined(LUAJIT_USE_VALGRIND) +#error "Must use builtin allocator for 64 bit target" +#endif + +static void *mem_alloc(void *ud, void *ptr, size_t osize, size_t nsize) +{ + (void)ud; + (void)osize; + if (nsize == 0) { + free(ptr); + return NULL; + } else { + return realloc(ptr, nsize); + } +} + +LUALIB_API lua_State *luaL_newstate(void) +{ + lua_State *L = lua_newstate(mem_alloc, NULL); + if (L) G(L)->panic = panic; + return L; +} + +#else + +#include "lj_alloc.h" + +LUALIB_API lua_State *luaL_newstate(void) +{ + lua_State *L; + void *ud = lj_alloc_create(); + if (ud == NULL) return NULL; +#if LJ_64 + L = lj_state_newstate(lj_alloc_f, ud); +#else + L = lua_newstate(lj_alloc_f, ud); +#endif + if (L) G(L)->panic = panic; + return L; +} + +#if LJ_64 +LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) +{ + UNUSED(f); UNUSED(ud); + fputs("Must use luaL_newstate() for 64 bit target\n", stderr); + return NULL; +} +#endif + +#endif + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lib_base.c b/source/libs/luajit/LuaJIT-2.0.4/src/lib_base.c new file mode 100644 index 000000000..17b9525d6 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lib_base.c @@ -0,0 +1,683 @@ +/* +** Base and coroutine library. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#include + +#define lib_base_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_debug.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_meta.h" +#include "lj_state.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#include "lj_cconv.h" +#endif +#include "lj_bc.h" +#include "lj_ff.h" +#include "lj_dispatch.h" +#include "lj_char.h" +#include "lj_strscan.h" +#include "lj_lib.h" + +/* -- Base library: checks ------------------------------------------------ */ + +#define LJLIB_MODULE_base + +LJLIB_ASM(assert) LJLIB_REC(.) +{ + GCstr *s; + lj_lib_checkany(L, 1); + s = lj_lib_optstr(L, 2); + if (s) + lj_err_callermsg(L, strdata(s)); + else + lj_err_caller(L, LJ_ERR_ASSERT); + return FFH_UNREACHABLE; +} + +/* ORDER LJ_T */ +LJLIB_PUSH("nil") +LJLIB_PUSH("boolean") +LJLIB_PUSH(top-1) /* boolean */ +LJLIB_PUSH("userdata") +LJLIB_PUSH("string") +LJLIB_PUSH("upval") +LJLIB_PUSH("thread") +LJLIB_PUSH("proto") +LJLIB_PUSH("function") +LJLIB_PUSH("trace") +LJLIB_PUSH("cdata") +LJLIB_PUSH("table") +LJLIB_PUSH(top-9) /* userdata */ +LJLIB_PUSH("number") +LJLIB_ASM_(type) LJLIB_REC(.) +/* Recycle the lj_lib_checkany(L, 1) from assert. */ + +/* -- Base library: iterators --------------------------------------------- */ + +/* This solves a circular dependency problem -- change FF_next_N as needed. */ +LJ_STATIC_ASSERT((int)FF_next == FF_next_N); + +LJLIB_ASM(next) +{ + lj_lib_checktab(L, 1); + return FFH_UNREACHABLE; +} + +#if LJ_52 || LJ_HASFFI +static int ffh_pairs(lua_State *L, MMS mm) +{ + TValue *o = lj_lib_checkany(L, 1); + cTValue *mo = lj_meta_lookup(L, o, mm); + if ((LJ_52 || tviscdata(o)) && !tvisnil(mo)) { + L->top = o+1; /* Only keep one argument. */ + copyTV(L, L->base-1, mo); /* Replace callable. */ + return FFH_TAILCALL; + } else { + if (!tvistab(o)) lj_err_argt(L, 1, LUA_TTABLE); + setfuncV(L, o-1, funcV(lj_lib_upvalue(L, 1))); + if (mm == MM_pairs) setnilV(o+1); else setintV(o+1, 0); + return FFH_RES(3); + } +} +#else +#define ffh_pairs(L, mm) (lj_lib_checktab(L, 1), FFH_UNREACHABLE) +#endif + +LJLIB_PUSH(lastcl) +LJLIB_ASM(pairs) +{ + return ffh_pairs(L, MM_pairs); +} + +LJLIB_NOREGUV LJLIB_ASM(ipairs_aux) LJLIB_REC(.) +{ + lj_lib_checktab(L, 1); + lj_lib_checkint(L, 2); + return FFH_UNREACHABLE; +} + +LJLIB_PUSH(lastcl) +LJLIB_ASM(ipairs) LJLIB_REC(.) +{ + return ffh_pairs(L, MM_ipairs); +} + +/* -- Base library: getters and setters ----------------------------------- */ + +LJLIB_ASM_(getmetatable) LJLIB_REC(.) +/* Recycle the lj_lib_checkany(L, 1) from assert. */ + +LJLIB_ASM(setmetatable) LJLIB_REC(.) +{ + GCtab *t = lj_lib_checktab(L, 1); + GCtab *mt = lj_lib_checktabornil(L, 2); + if (!tvisnil(lj_meta_lookup(L, L->base, MM_metatable))) + lj_err_caller(L, LJ_ERR_PROTMT); + setgcref(t->metatable, obj2gco(mt)); + if (mt) { lj_gc_objbarriert(L, t, mt); } + settabV(L, L->base-1, t); + return FFH_RES(1); +} + +LJLIB_CF(getfenv) +{ + GCfunc *fn; + cTValue *o = L->base; + if (!(o < L->top && tvisfunc(o))) { + int level = lj_lib_optint(L, 1, 1); + o = lj_debug_frame(L, level, &level); + if (o == NULL) + lj_err_arg(L, 1, LJ_ERR_INVLVL); + } + fn = &gcval(o)->fn; + settabV(L, L->top++, isluafunc(fn) ? tabref(fn->l.env) : tabref(L->env)); + return 1; +} + +LJLIB_CF(setfenv) +{ + GCfunc *fn; + GCtab *t = lj_lib_checktab(L, 2); + cTValue *o = L->base; + if (!(o < L->top && tvisfunc(o))) { + int level = lj_lib_checkint(L, 1); + if (level == 0) { + /* NOBARRIER: A thread (i.e. L) is never black. */ + setgcref(L->env, obj2gco(t)); + return 0; + } + o = lj_debug_frame(L, level, &level); + if (o == NULL) + lj_err_arg(L, 1, LJ_ERR_INVLVL); + } + fn = &gcval(o)->fn; + if (!isluafunc(fn)) + lj_err_caller(L, LJ_ERR_SETFENV); + setgcref(fn->l.env, obj2gco(t)); + lj_gc_objbarrier(L, obj2gco(fn), t); + setfuncV(L, L->top++, fn); + return 1; +} + +LJLIB_ASM(rawget) LJLIB_REC(.) +{ + lj_lib_checktab(L, 1); + lj_lib_checkany(L, 2); + return FFH_UNREACHABLE; +} + +LJLIB_CF(rawset) LJLIB_REC(.) +{ + lj_lib_checktab(L, 1); + lj_lib_checkany(L, 2); + L->top = 1+lj_lib_checkany(L, 3); + lua_rawset(L, 1); + return 1; +} + +LJLIB_CF(rawequal) LJLIB_REC(.) +{ + cTValue *o1 = lj_lib_checkany(L, 1); + cTValue *o2 = lj_lib_checkany(L, 2); + setboolV(L->top-1, lj_obj_equal(o1, o2)); + return 1; +} + +#if LJ_52 +LJLIB_CF(rawlen) LJLIB_REC(.) +{ + cTValue *o = L->base; + int32_t len; + if (L->top > o && tvisstr(o)) + len = (int32_t)strV(o)->len; + else + len = (int32_t)lj_tab_len(lj_lib_checktab(L, 1)); + setintV(L->top-1, len); + return 1; +} +#endif + +LJLIB_CF(unpack) +{ + GCtab *t = lj_lib_checktab(L, 1); + int32_t n, i = lj_lib_optint(L, 2, 1); + int32_t e = (L->base+3-1 < L->top && !tvisnil(L->base+3-1)) ? + lj_lib_checkint(L, 3) : (int32_t)lj_tab_len(t); + if (i > e) return 0; + n = e - i + 1; + if (n <= 0 || !lua_checkstack(L, n)) + lj_err_caller(L, LJ_ERR_UNPACK); + do { + cTValue *tv = lj_tab_getint(t, i); + if (tv) { + copyTV(L, L->top++, tv); + } else { + setnilV(L->top++); + } + } while (i++ < e); + return n; +} + +LJLIB_CF(select) LJLIB_REC(.) +{ + int32_t n = (int32_t)(L->top - L->base); + if (n >= 1 && tvisstr(L->base) && *strVdata(L->base) == '#') { + setintV(L->top-1, n-1); + return 1; + } else { + int32_t i = lj_lib_checkint(L, 1); + if (i < 0) i = n + i; else if (i > n) i = n; + if (i < 1) + lj_err_arg(L, 1, LJ_ERR_IDXRNG); + return n - i; + } +} + +/* -- Base library: conversions ------------------------------------------- */ + +LJLIB_ASM(tonumber) LJLIB_REC(.) +{ + int32_t base = lj_lib_optint(L, 2, 10); + if (base == 10) { + TValue *o = lj_lib_checkany(L, 1); + if (lj_strscan_numberobj(o)) { + copyTV(L, L->base-1, o); + return FFH_RES(1); + } +#if LJ_HASFFI + if (tviscdata(o)) { + CTState *cts = ctype_cts(L); + CType *ct = lj_ctype_rawref(cts, cdataV(o)->ctypeid); + if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); + if (ctype_isnum(ct->info) || ctype_iscomplex(ct->info)) { + if (LJ_DUALNUM && ctype_isinteger_or_bool(ct->info) && + ct->size <= 4 && !(ct->size == 4 && (ct->info & CTF_UNSIGNED))) { + int32_t i; + lj_cconv_ct_tv(cts, ctype_get(cts, CTID_INT32), (uint8_t *)&i, o, 0); + setintV(L->base-1, i); + return FFH_RES(1); + } + lj_cconv_ct_tv(cts, ctype_get(cts, CTID_DOUBLE), + (uint8_t *)&(L->base-1)->n, o, 0); + return FFH_RES(1); + } + } +#endif + } else { + const char *p = strdata(lj_lib_checkstr(L, 1)); + char *ep; + unsigned long ul; + if (base < 2 || base > 36) + lj_err_arg(L, 2, LJ_ERR_BASERNG); + ul = strtoul(p, &ep, base); + if (p != ep) { + while (lj_char_isspace((unsigned char)(*ep))) ep++; + if (*ep == '\0') { + if (LJ_DUALNUM && LJ_LIKELY(ul < 0x80000000u)) + setintV(L->base-1, (int32_t)ul); + else + setnumV(L->base-1, (lua_Number)ul); + return FFH_RES(1); + } + } + } + setnilV(L->base-1); + return FFH_RES(1); +} + +LJLIB_PUSH("nil") +LJLIB_PUSH("false") +LJLIB_PUSH("true") +LJLIB_ASM(tostring) LJLIB_REC(.) +{ + TValue *o = lj_lib_checkany(L, 1); + cTValue *mo; + L->top = o+1; /* Only keep one argument. */ + if (!tvisnil(mo = lj_meta_lookup(L, o, MM_tostring))) { + copyTV(L, L->base-1, mo); /* Replace callable. */ + return FFH_TAILCALL; + } else { + GCstr *s; + if (tvisnumber(o)) { + s = lj_str_fromnumber(L, o); + } else if (tvispri(o)) { + s = strV(lj_lib_upvalue(L, -(int32_t)itype(o))); + } else { + if (tvisfunc(o) && isffunc(funcV(o))) + lua_pushfstring(L, "function: builtin#%d", funcV(o)->c.ffid); + else + lua_pushfstring(L, "%s: %p", lj_typename(o), lua_topointer(L, 1)); + /* Note: lua_pushfstring calls the GC which may invalidate o. */ + s = strV(L->top-1); + } + setstrV(L, L->base-1, s); + return FFH_RES(1); + } +} + +/* -- Base library: throw and catch errors -------------------------------- */ + +LJLIB_CF(error) +{ + int32_t level = lj_lib_optint(L, 2, 1); + lua_settop(L, 1); + if (lua_isstring(L, 1) && level > 0) { + luaL_where(L, level); + lua_pushvalue(L, 1); + lua_concat(L, 2); + } + return lua_error(L); +} + +LJLIB_ASM(pcall) LJLIB_REC(.) +{ + lj_lib_checkany(L, 1); + lj_lib_checkfunc(L, 2); /* For xpcall only. */ + return FFH_UNREACHABLE; +} +LJLIB_ASM_(xpcall) LJLIB_REC(.) + +/* -- Base library: load Lua code ----------------------------------------- */ + +static int load_aux(lua_State *L, int status, int envarg) +{ + if (status == 0) { + if (tvistab(L->base+envarg-1)) { + GCfunc *fn = funcV(L->top-1); + GCtab *t = tabV(L->base+envarg-1); + setgcref(fn->c.env, obj2gco(t)); + lj_gc_objbarrier(L, fn, t); + } + return 1; + } else { + setnilV(L->top-2); + return 2; + } +} + +LJLIB_CF(loadfile) +{ + GCstr *fname = lj_lib_optstr(L, 1); + GCstr *mode = lj_lib_optstr(L, 2); + int status; + lua_settop(L, 3); /* Ensure env arg exists. */ + status = luaL_loadfilex(L, fname ? strdata(fname) : NULL, + mode ? strdata(mode) : NULL); + return load_aux(L, status, 3); +} + +static const char *reader_func(lua_State *L, void *ud, size_t *size) +{ + UNUSED(ud); + luaL_checkstack(L, 2, "too many nested functions"); + copyTV(L, L->top++, L->base); + lua_call(L, 0, 1); /* Call user-supplied function. */ + L->top--; + if (tvisnil(L->top)) { + *size = 0; + return NULL; + } else if (tvisstr(L->top) || tvisnumber(L->top)) { + copyTV(L, L->base+4, L->top); /* Anchor string in reserved stack slot. */ + return lua_tolstring(L, 5, size); + } else { + lj_err_caller(L, LJ_ERR_RDRSTR); + return NULL; + } +} + +LJLIB_CF(load) +{ + GCstr *name = lj_lib_optstr(L, 2); + GCstr *mode = lj_lib_optstr(L, 3); + int status; + if (L->base < L->top && (tvisstr(L->base) || tvisnumber(L->base))) { + GCstr *s = lj_lib_checkstr(L, 1); + lua_settop(L, 4); /* Ensure env arg exists. */ + status = luaL_loadbufferx(L, strdata(s), s->len, strdata(name ? name : s), + mode ? strdata(mode) : NULL); + } else { + lj_lib_checkfunc(L, 1); + lua_settop(L, 5); /* Reserve a slot for the string from the reader. */ + status = lua_loadx(L, reader_func, NULL, name ? strdata(name) : "=(load)", + mode ? strdata(mode) : NULL); + } + return load_aux(L, status, 4); +} + +LJLIB_CF(loadstring) +{ + return lj_cf_load(L); +} + +LJLIB_CF(dofile) +{ + GCstr *fname = lj_lib_optstr(L, 1); + setnilV(L->top); + L->top = L->base+1; + if (luaL_loadfile(L, fname ? strdata(fname) : NULL) != 0) + lua_error(L); + lua_call(L, 0, LUA_MULTRET); + return (int)(L->top - L->base) - 1; +} + +/* -- Base library: GC control -------------------------------------------- */ + +LJLIB_CF(gcinfo) +{ + setintV(L->top++, (G(L)->gc.total >> 10)); + return 1; +} + +LJLIB_CF(collectgarbage) +{ + int opt = lj_lib_checkopt(L, 1, LUA_GCCOLLECT, /* ORDER LUA_GC* */ + "\4stop\7restart\7collect\5count\1\377\4step\10setpause\12setstepmul"); + int32_t data = lj_lib_optint(L, 2, 0); + if (opt == LUA_GCCOUNT) { + setnumV(L->top, (lua_Number)G(L)->gc.total/1024.0); + } else { + int res = lua_gc(L, opt, data); + if (opt == LUA_GCSTEP) + setboolV(L->top, res); + else + setintV(L->top, res); + } + L->top++; + return 1; +} + +/* -- Base library: miscellaneous functions ------------------------------- */ + +LJLIB_PUSH(top-2) /* Upvalue holds weak table. */ +LJLIB_CF(newproxy) +{ + lua_settop(L, 1); + lua_newuserdata(L, 0); + if (lua_toboolean(L, 1) == 0) { /* newproxy(): without metatable. */ + return 1; + } else if (lua_isboolean(L, 1)) { /* newproxy(true): with metatable. */ + lua_newtable(L); + lua_pushvalue(L, -1); + lua_pushboolean(L, 1); + lua_rawset(L, lua_upvalueindex(1)); /* Remember mt in weak table. */ + } else { /* newproxy(proxy): inherit metatable. */ + int validproxy = 0; + if (lua_getmetatable(L, 1)) { + lua_rawget(L, lua_upvalueindex(1)); + validproxy = lua_toboolean(L, -1); + lua_pop(L, 1); + } + if (!validproxy) + lj_err_arg(L, 1, LJ_ERR_NOPROXY); + lua_getmetatable(L, 1); + } + lua_setmetatable(L, 2); + return 1; +} + +LJLIB_PUSH("tostring") +LJLIB_CF(print) +{ + ptrdiff_t i, nargs = L->top - L->base; + cTValue *tv = lj_tab_getstr(tabref(L->env), strV(lj_lib_upvalue(L, 1))); + int shortcut; + if (tv && !tvisnil(tv)) { + copyTV(L, L->top++, tv); + } else { + setstrV(L, L->top++, strV(lj_lib_upvalue(L, 1))); + lua_gettable(L, LUA_GLOBALSINDEX); + tv = L->top-1; + } + shortcut = (tvisfunc(tv) && funcV(tv)->c.ffid == FF_tostring); + for (i = 0; i < nargs; i++) { + const char *str; + size_t size; + cTValue *o = &L->base[i]; + if (shortcut && tvisstr(o)) { + str = strVdata(o); + size = strV(o)->len; + } else if (shortcut && tvisint(o)) { + char buf[LJ_STR_INTBUF]; + char *p = lj_str_bufint(buf, intV(o)); + size = (size_t)(buf+LJ_STR_INTBUF-p); + str = p; + } else if (shortcut && tvisnum(o)) { + char buf[LJ_STR_NUMBUF]; + size = lj_str_bufnum(buf, o); + str = buf; + } else { + copyTV(L, L->top+1, o); + copyTV(L, L->top, L->top-1); + L->top += 2; + lua_call(L, 1, 1); + str = lua_tolstring(L, -1, &size); + if (!str) + lj_err_caller(L, LJ_ERR_PRTOSTR); + L->top--; + } + if (i) + putchar('\t'); + fwrite(str, 1, size, stdout); + } + putchar('\n'); + return 0; +} + +LJLIB_PUSH(top-3) +LJLIB_SET(_VERSION) + +#include "lj_libdef.h" + +/* -- Coroutine library --------------------------------------------------- */ + +#define LJLIB_MODULE_coroutine + +LJLIB_CF(coroutine_status) +{ + const char *s; + lua_State *co; + if (!(L->top > L->base && tvisthread(L->base))) + lj_err_arg(L, 1, LJ_ERR_NOCORO); + co = threadV(L->base); + if (co == L) s = "running"; + else if (co->status == LUA_YIELD) s = "suspended"; + else if (co->status != 0) s = "dead"; + else if (co->base > tvref(co->stack)+1) s = "normal"; + else if (co->top == co->base) s = "dead"; + else s = "suspended"; + lua_pushstring(L, s); + return 1; +} + +LJLIB_CF(coroutine_running) +{ +#if LJ_52 + int ismain = lua_pushthread(L); + setboolV(L->top++, ismain); + return 2; +#else + if (lua_pushthread(L)) + setnilV(L->top++); + return 1; +#endif +} + +LJLIB_CF(coroutine_create) +{ + lua_State *L1; + if (!(L->base < L->top && tvisfunc(L->base))) + lj_err_argt(L, 1, LUA_TFUNCTION); + L1 = lua_newthread(L); + setfuncV(L, L1->top++, funcV(L->base)); + return 1; +} + +LJLIB_ASM(coroutine_yield) +{ + lj_err_caller(L, LJ_ERR_CYIELD); + return FFH_UNREACHABLE; +} + +static int ffh_resume(lua_State *L, lua_State *co, int wrap) +{ + if (co->cframe != NULL || co->status > LUA_YIELD || + (co->status == 0 && co->top == co->base)) { + ErrMsg em = co->cframe ? LJ_ERR_CORUN : LJ_ERR_CODEAD; + if (wrap) lj_err_caller(L, em); + setboolV(L->base-1, 0); + setstrV(L, L->base, lj_err_str(L, em)); + return FFH_RES(2); + } + lj_state_growstack(co, (MSize)(L->top - L->base)); + return FFH_RETRY; +} + +LJLIB_ASM(coroutine_resume) +{ + if (!(L->top > L->base && tvisthread(L->base))) + lj_err_arg(L, 1, LJ_ERR_NOCORO); + return ffh_resume(L, threadV(L->base), 0); +} + +LJLIB_NOREG LJLIB_ASM(coroutine_wrap_aux) +{ + return ffh_resume(L, threadV(lj_lib_upvalue(L, 1)), 1); +} + +/* Inline declarations. */ +LJ_ASMF void lj_ff_coroutine_wrap_aux(void); +#if !(LJ_TARGET_MIPS && defined(ljamalg_c)) +LJ_FUNCA_NORET void LJ_FASTCALL lj_ffh_coroutine_wrap_err(lua_State *L, + lua_State *co); +#endif + +/* Error handler, called from assembler VM. */ +void LJ_FASTCALL lj_ffh_coroutine_wrap_err(lua_State *L, lua_State *co) +{ + co->top--; copyTV(L, L->top, co->top); L->top++; + if (tvisstr(L->top-1)) + lj_err_callermsg(L, strVdata(L->top-1)); + else + lj_err_run(L); +} + +/* Forward declaration. */ +static void setpc_wrap_aux(lua_State *L, GCfunc *fn); + +LJLIB_CF(coroutine_wrap) +{ + lj_cf_coroutine_create(L); + lj_lib_pushcc(L, lj_ffh_coroutine_wrap_aux, FF_coroutine_wrap_aux, 1); + setpc_wrap_aux(L, funcV(L->top-1)); + return 1; +} + +#include "lj_libdef.h" + +/* Fix the PC of wrap_aux. Really ugly workaround. */ +static void setpc_wrap_aux(lua_State *L, GCfunc *fn) +{ + setmref(fn->c.pc, &L2GG(L)->bcff[lj_lib_init_coroutine[1]+2]); +} + +/* ------------------------------------------------------------------------ */ + +static void newproxy_weaktable(lua_State *L) +{ + /* NOBARRIER: The table is new (marked white). */ + GCtab *t = lj_tab_new(L, 0, 1); + settabV(L, L->top++, t); + setgcref(t->metatable, obj2gco(t)); + setstrV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "__mode")), + lj_str_newlit(L, "kv")); + t->nomm = (uint8_t)(~(1u<env); + settabV(L, lj_tab_setstr(L, env, lj_str_newlit(L, "_G")), env); + lua_pushliteral(L, LUA_VERSION); /* top-3. */ + newproxy_weaktable(L); /* top-2. */ + LJ_LIB_REG(L, "_G", base); + LJ_LIB_REG(L, LUA_COLIBNAME, coroutine); + return 2; +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lib_bit.c b/source/libs/luajit/LuaJIT-2.0.4/src/lib_bit.c new file mode 100644 index 000000000..583e04b0c --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lib_bit.c @@ -0,0 +1,74 @@ +/* +** Bit manipulation library. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lib_bit_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_obj.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_lib.h" + +/* ------------------------------------------------------------------------ */ + +#define LJLIB_MODULE_bit + +LJLIB_ASM(bit_tobit) LJLIB_REC(bit_unary IR_TOBIT) +{ + lj_lib_checknumber(L, 1); + return FFH_RETRY; +} +LJLIB_ASM_(bit_bnot) LJLIB_REC(bit_unary IR_BNOT) +LJLIB_ASM_(bit_bswap) LJLIB_REC(bit_unary IR_BSWAP) + +LJLIB_ASM(bit_lshift) LJLIB_REC(bit_shift IR_BSHL) +{ + lj_lib_checknumber(L, 1); + lj_lib_checkbit(L, 2); + return FFH_RETRY; +} +LJLIB_ASM_(bit_rshift) LJLIB_REC(bit_shift IR_BSHR) +LJLIB_ASM_(bit_arshift) LJLIB_REC(bit_shift IR_BSAR) +LJLIB_ASM_(bit_rol) LJLIB_REC(bit_shift IR_BROL) +LJLIB_ASM_(bit_ror) LJLIB_REC(bit_shift IR_BROR) + +LJLIB_ASM(bit_band) LJLIB_REC(bit_nary IR_BAND) +{ + int i = 0; + do { lj_lib_checknumber(L, ++i); } while (L->base+i < L->top); + return FFH_RETRY; +} +LJLIB_ASM_(bit_bor) LJLIB_REC(bit_nary IR_BOR) +LJLIB_ASM_(bit_bxor) LJLIB_REC(bit_nary IR_BXOR) + +/* ------------------------------------------------------------------------ */ + +LJLIB_CF(bit_tohex) +{ + uint32_t b = (uint32_t)lj_lib_checkbit(L, 1); + int32_t i, n = L->base+1 >= L->top ? 8 : lj_lib_checkbit(L, 2); + const char *hexdigits = "0123456789abcdef"; + char buf[8]; + if (n < 0) { n = -n; hexdigits = "0123456789ABCDEF"; } + if (n > 8) n = 8; + for (i = n; --i >= 0; ) { buf[i] = hexdigits[b & 15]; b >>= 4; } + lua_pushlstring(L, buf, (size_t)n); + return 1; +} + +/* ------------------------------------------------------------------------ */ + +#include "lj_libdef.h" + +LUALIB_API int luaopen_bit(lua_State *L) +{ + LJ_LIB_REG(L, LUA_BITLIBNAME, bit); + return 1; +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lib_debug.c b/source/libs/luajit/LuaJIT-2.0.4/src/lib_debug.c new file mode 100644 index 000000000..e87c35cfe --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lib_debug.c @@ -0,0 +1,405 @@ +/* +** Debug library. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lib_debug_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_debug.h" +#include "lj_lib.h" + +/* ------------------------------------------------------------------------ */ + +#define LJLIB_MODULE_debug + +LJLIB_CF(debug_getregistry) +{ + copyTV(L, L->top++, registry(L)); + return 1; +} + +LJLIB_CF(debug_getmetatable) +{ + lj_lib_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + setnilV(L->top-1); + } + return 1; +} + +LJLIB_CF(debug_setmetatable) +{ + lj_lib_checktabornil(L, 2); + L->top = L->base+2; + lua_setmetatable(L, 1); +#if !LJ_52 + setboolV(L->top-1, 1); +#endif + return 1; +} + +LJLIB_CF(debug_getfenv) +{ + lj_lib_checkany(L, 1); + lua_getfenv(L, 1); + return 1; +} + +LJLIB_CF(debug_setfenv) +{ + lj_lib_checktab(L, 2); + L->top = L->base+2; + if (!lua_setfenv(L, 1)) + lj_err_caller(L, LJ_ERR_SETFENV); + return 1; +} + +/* ------------------------------------------------------------------------ */ + +static void settabss(lua_State *L, const char *i, const char *v) +{ + lua_pushstring(L, v); + lua_setfield(L, -2, i); +} + +static void settabsi(lua_State *L, const char *i, int v) +{ + lua_pushinteger(L, v); + lua_setfield(L, -2, i); +} + +static void settabsb(lua_State *L, const char *i, int v) +{ + lua_pushboolean(L, v); + lua_setfield(L, -2, i); +} + +static lua_State *getthread(lua_State *L, int *arg) +{ + if (L->base < L->top && tvisthread(L->base)) { + *arg = 1; + return threadV(L->base); + } else { + *arg = 0; + return L; + } +} + +static void treatstackoption(lua_State *L, lua_State *L1, const char *fname) +{ + if (L == L1) { + lua_pushvalue(L, -2); + lua_remove(L, -3); + } + else + lua_xmove(L1, L, 1); + lua_setfield(L, -2, fname); +} + +LJLIB_CF(debug_getinfo) +{ + lj_Debug ar; + int arg, opt_f = 0, opt_L = 0; + lua_State *L1 = getthread(L, &arg); + const char *options = luaL_optstring(L, arg+2, "flnSu"); + if (lua_isnumber(L, arg+1)) { + if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), (lua_Debug *)&ar)) { + setnilV(L->top-1); + return 1; + } + } else if (L->base+arg < L->top && tvisfunc(L->base+arg)) { + options = lua_pushfstring(L, ">%s", options); + setfuncV(L1, L1->top++, funcV(L->base+arg)); + } else { + lj_err_arg(L, arg+1, LJ_ERR_NOFUNCL); + } + if (!lj_debug_getinfo(L1, options, &ar, 1)) + lj_err_arg(L, arg+2, LJ_ERR_INVOPT); + lua_createtable(L, 0, 16); /* Create result table. */ + for (; *options; options++) { + switch (*options) { + case 'S': + settabss(L, "source", ar.source); + settabss(L, "short_src", ar.short_src); + settabsi(L, "linedefined", ar.linedefined); + settabsi(L, "lastlinedefined", ar.lastlinedefined); + settabss(L, "what", ar.what); + break; + case 'l': + settabsi(L, "currentline", ar.currentline); + break; + case 'u': + settabsi(L, "nups", ar.nups); + settabsi(L, "nparams", ar.nparams); + settabsb(L, "isvararg", ar.isvararg); + break; + case 'n': + settabss(L, "name", ar.name); + settabss(L, "namewhat", ar.namewhat); + break; + case 'f': opt_f = 1; break; + case 'L': opt_L = 1; break; + default: break; + } + } + if (opt_L) treatstackoption(L, L1, "activelines"); + if (opt_f) treatstackoption(L, L1, "func"); + return 1; /* Return result table. */ +} + +LJLIB_CF(debug_getlocal) +{ + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + const char *name; + int slot = lj_lib_checkint(L, arg+2); + if (tvisfunc(L->base+arg)) { + L->top = L->base+arg+1; + lua_pushstring(L, lua_getlocal(L, NULL, slot)); + return 1; + } + if (!lua_getstack(L1, lj_lib_checkint(L, arg+1), &ar)) + lj_err_arg(L, arg+1, LJ_ERR_LVLRNG); + name = lua_getlocal(L1, &ar, slot); + if (name) { + lua_xmove(L1, L, 1); + lua_pushstring(L, name); + lua_pushvalue(L, -2); + return 2; + } else { + setnilV(L->top-1); + return 1; + } +} + +LJLIB_CF(debug_setlocal) +{ + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + TValue *tv; + if (!lua_getstack(L1, lj_lib_checkint(L, arg+1), &ar)) + lj_err_arg(L, arg+1, LJ_ERR_LVLRNG); + tv = lj_lib_checkany(L, arg+3); + copyTV(L1, L1->top++, tv); + lua_pushstring(L, lua_setlocal(L1, &ar, lj_lib_checkint(L, arg+2))); + return 1; +} + +static int debug_getupvalue(lua_State *L, int get) +{ + int32_t n = lj_lib_checkint(L, 2); + const char *name; + lj_lib_checkfunc(L, 1); + name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); + if (name) { + lua_pushstring(L, name); + if (!get) return 1; + copyTV(L, L->top, L->top-2); + L->top++; + return 2; + } + return 0; +} + +LJLIB_CF(debug_getupvalue) +{ + return debug_getupvalue(L, 1); +} + +LJLIB_CF(debug_setupvalue) +{ + lj_lib_checkany(L, 3); + return debug_getupvalue(L, 0); +} + +LJLIB_CF(debug_upvalueid) +{ + GCfunc *fn = lj_lib_checkfunc(L, 1); + int32_t n = lj_lib_checkint(L, 2) - 1; + if ((uint32_t)n >= fn->l.nupvalues) + lj_err_arg(L, 2, LJ_ERR_IDXRNG); + setlightudV(L->top-1, isluafunc(fn) ? (void *)gcref(fn->l.uvptr[n]) : + (void *)&fn->c.upvalue[n]); + return 1; +} + +LJLIB_CF(debug_upvaluejoin) +{ + GCfunc *fn[2]; + GCRef *p[2]; + int i; + for (i = 0; i < 2; i++) { + int32_t n; + fn[i] = lj_lib_checkfunc(L, 2*i+1); + if (!isluafunc(fn[i])) + lj_err_arg(L, 2*i+1, LJ_ERR_NOLFUNC); + n = lj_lib_checkint(L, 2*i+2) - 1; + if ((uint32_t)n >= fn[i]->l.nupvalues) + lj_err_arg(L, 2*i+2, LJ_ERR_IDXRNG); + p[i] = &fn[i]->l.uvptr[n]; + } + setgcrefr(*p[0], *p[1]); + lj_gc_objbarrier(L, fn[0], gcref(*p[1])); + return 0; +} + +#if LJ_52 +LJLIB_CF(debug_getuservalue) +{ + TValue *o = L->base; + if (o < L->top && tvisudata(o)) + settabV(L, o, tabref(udataV(o)->env)); + else + setnilV(o); + L->top = o+1; + return 1; +} + +LJLIB_CF(debug_setuservalue) +{ + TValue *o = L->base; + if (!(o < L->top && tvisudata(o))) + lj_err_argt(L, 1, LUA_TUSERDATA); + if (!(o+1 < L->top && tvistab(o+1))) + lj_err_argt(L, 2, LUA_TTABLE); + L->top = o+2; + lua_setfenv(L, 1); + return 1; +} +#endif + +/* ------------------------------------------------------------------------ */ + +static const char KEY_HOOK = 'h'; + +static void hookf(lua_State *L, lua_Debug *ar) +{ + static const char *const hooknames[] = + {"call", "return", "line", "count", "tail return"}; + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_isfunction(L, -1)) { + lua_pushstring(L, hooknames[(int)ar->event]); + if (ar->currentline >= 0) + lua_pushinteger(L, ar->currentline); + else lua_pushnil(L); + lua_call(L, 2, 0); + } +} + +static int makemask(const char *smask, int count) +{ + int mask = 0; + if (strchr(smask, 'c')) mask |= LUA_MASKCALL; + if (strchr(smask, 'r')) mask |= LUA_MASKRET; + if (strchr(smask, 'l')) mask |= LUA_MASKLINE; + if (count > 0) mask |= LUA_MASKCOUNT; + return mask; +} + +static char *unmakemask(int mask, char *smask) +{ + int i = 0; + if (mask & LUA_MASKCALL) smask[i++] = 'c'; + if (mask & LUA_MASKRET) smask[i++] = 'r'; + if (mask & LUA_MASKLINE) smask[i++] = 'l'; + smask[i] = '\0'; + return smask; +} + +LJLIB_CF(debug_sethook) +{ + int arg, mask, count; + lua_Hook func; + (void)getthread(L, &arg); + if (lua_isnoneornil(L, arg+1)) { + lua_settop(L, arg+1); + func = NULL; mask = 0; count = 0; /* turn off hooks */ + } else { + const char *smask = luaL_checkstring(L, arg+2); + luaL_checktype(L, arg+1, LUA_TFUNCTION); + count = luaL_optint(L, arg+3, 0); + func = hookf; mask = makemask(smask, count); + } + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_pushvalue(L, arg+1); + lua_rawset(L, LUA_REGISTRYINDEX); + lua_sethook(L, func, mask, count); + return 0; +} + +LJLIB_CF(debug_gethook) +{ + char buff[5]; + int mask = lua_gethookmask(L); + lua_Hook hook = lua_gethook(L); + if (hook != NULL && hook != hookf) { /* external hook? */ + lua_pushliteral(L, "external hook"); + } else { + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); /* get hook */ + } + lua_pushstring(L, unmakemask(mask, buff)); + lua_pushinteger(L, lua_gethookcount(L)); + return 3; +} + +/* ------------------------------------------------------------------------ */ + +LJLIB_CF(debug_debug) +{ + for (;;) { + char buffer[250]; + fputs("lua_debug> ", stderr); + if (fgets(buffer, sizeof(buffer), stdin) == 0 || + strcmp(buffer, "cont\n") == 0) + return 0; + if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || + lua_pcall(L, 0, 0, 0)) { + fputs(lua_tostring(L, -1), stderr); + fputs("\n", stderr); + } + lua_settop(L, 0); /* remove eventual returns */ + } +} + +/* ------------------------------------------------------------------------ */ + +#define LEVELS1 12 /* size of the first part of the stack */ +#define LEVELS2 10 /* size of the second part of the stack */ + +LJLIB_CF(debug_traceback) +{ + int arg; + lua_State *L1 = getthread(L, &arg); + const char *msg = lua_tostring(L, arg+1); + if (msg == NULL && L->top > L->base+arg) + L->top = L->base+arg+1; + else + luaL_traceback(L, L1, msg, lj_lib_optint(L, arg+2, (L == L1))); + return 1; +} + +/* ------------------------------------------------------------------------ */ + +#include "lj_libdef.h" + +LUALIB_API int luaopen_debug(lua_State *L) +{ + LJ_LIB_REG(L, LUA_DBLIBNAME, debug); + return 1; +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lib_ffi.c b/source/libs/luajit/LuaJIT-2.0.4/src/lib_ffi.c new file mode 100644 index 000000000..f6df39d67 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lib_ffi.c @@ -0,0 +1,851 @@ +/* +** FFI library. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lib_ffi_c +#define LUA_LIB + +#include + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_obj.h" + +#if LJ_HASFFI + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_meta.h" +#include "lj_ctype.h" +#include "lj_cparse.h" +#include "lj_cdata.h" +#include "lj_cconv.h" +#include "lj_carith.h" +#include "lj_ccall.h" +#include "lj_ccallback.h" +#include "lj_clib.h" +#include "lj_ff.h" +#include "lj_lib.h" + +/* -- C type checks ------------------------------------------------------- */ + +/* Check first argument for a C type and returns its ID. */ +static CTypeID ffi_checkctype(lua_State *L, CTState *cts, TValue *param) +{ + TValue *o = L->base; + if (!(o < L->top)) { + err_argtype: + lj_err_argtype(L, 1, "C type"); + } + if (tvisstr(o)) { /* Parse an abstract C type declaration. */ + GCstr *s = strV(o); + CPState cp; + int errcode; + cp.L = L; + cp.cts = cts; + cp.srcname = strdata(s); + cp.p = strdata(s); + cp.param = param; + cp.mode = CPARSE_MODE_ABSTRACT|CPARSE_MODE_NOIMPLICIT; + errcode = lj_cparse(&cp); + if (errcode) lj_err_throw(L, errcode); /* Propagate errors. */ + return cp.val.id; + } else { + GCcdata *cd; + if (!tviscdata(o)) goto err_argtype; + if (param && param < L->top) lj_err_arg(L, 1, LJ_ERR_FFI_NUMPARAM); + cd = cdataV(o); + return cd->ctypeid == CTID_CTYPEID ? *(CTypeID *)cdataptr(cd) : cd->ctypeid; + } +} + +/* Check argument for C data and return it. */ +static GCcdata *ffi_checkcdata(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (!(o < L->top && tviscdata(o))) + lj_err_argt(L, narg, LUA_TCDATA); + return cdataV(o); +} + +/* Convert argument to C pointer. */ +static void *ffi_checkptr(lua_State *L, int narg, CTypeID id) +{ + CTState *cts = ctype_cts(L); + TValue *o = L->base + narg-1; + void *p; + if (o >= L->top) + lj_err_arg(L, narg, LJ_ERR_NOVAL); + lj_cconv_ct_tv(cts, ctype_get(cts, id), (uint8_t *)&p, o, CCF_ARG(narg)); + return p; +} + +/* Convert argument to int32_t. */ +static int32_t ffi_checkint(lua_State *L, int narg) +{ + CTState *cts = ctype_cts(L); + TValue *o = L->base + narg-1; + int32_t i; + if (o >= L->top) + lj_err_arg(L, narg, LJ_ERR_NOVAL); + lj_cconv_ct_tv(cts, ctype_get(cts, CTID_INT32), (uint8_t *)&i, o, + CCF_ARG(narg)); + return i; +} + +/* -- C type metamethods -------------------------------------------------- */ + +#define LJLIB_MODULE_ffi_meta + +/* Handle ctype __index/__newindex metamethods. */ +static int ffi_index_meta(lua_State *L, CTState *cts, CType *ct, MMS mm) +{ + CTypeID id = ctype_typeid(cts, ct); + cTValue *tv = lj_ctype_meta(cts, id, mm); + TValue *base = L->base; + if (!tv) { + const char *s; + err_index: + s = strdata(lj_ctype_repr(L, id, NULL)); + if (tvisstr(L->base+1)) { + lj_err_callerv(L, LJ_ERR_FFI_BADMEMBER, s, strVdata(L->base+1)); + } else { + const char *key = tviscdata(L->base+1) ? + strdata(lj_ctype_repr(L, cdataV(L->base+1)->ctypeid, NULL)) : + lj_typename(L->base+1); + lj_err_callerv(L, LJ_ERR_FFI_BADIDXW, s, key); + } + } + if (!tvisfunc(tv)) { + if (mm == MM_index) { + cTValue *o = lj_meta_tget(L, tv, base+1); + if (o) { + if (tvisnil(o)) goto err_index; + copyTV(L, L->top-1, o); + return 1; + } + } else { + TValue *o = lj_meta_tset(L, tv, base+1); + if (o) { + copyTV(L, o, base+2); + return 0; + } + } + copyTV(L, base, L->top); + tv = L->top-1; + } + return lj_meta_tailcall(L, tv); +} + +LJLIB_CF(ffi_meta___index) LJLIB_REC(cdata_index 0) +{ + CTState *cts = ctype_cts(L); + CTInfo qual = 0; + CType *ct; + uint8_t *p; + TValue *o = L->base; + if (!(o+1 < L->top && tviscdata(o))) /* Also checks for presence of key. */ + lj_err_argt(L, 1, LUA_TCDATA); + ct = lj_cdata_index(cts, cdataV(o), o+1, &p, &qual); + if ((qual & 1)) + return ffi_index_meta(L, cts, ct, MM_index); + if (lj_cdata_get(cts, ct, L->top-1, p)) + lj_gc_check(L); + return 1; +} + +LJLIB_CF(ffi_meta___newindex) LJLIB_REC(cdata_index 1) +{ + CTState *cts = ctype_cts(L); + CTInfo qual = 0; + CType *ct; + uint8_t *p; + TValue *o = L->base; + if (!(o+2 < L->top && tviscdata(o))) /* Also checks for key and value. */ + lj_err_argt(L, 1, LUA_TCDATA); + ct = lj_cdata_index(cts, cdataV(o), o+1, &p, &qual); + if ((qual & 1)) { + if ((qual & CTF_CONST)) + lj_err_caller(L, LJ_ERR_FFI_WRCONST); + return ffi_index_meta(L, cts, ct, MM_newindex); + } + lj_cdata_set(cts, ct, p, o+2, qual); + return 0; +} + +/* Common handler for cdata arithmetic. */ +static int ffi_arith(lua_State *L) +{ + MMS mm = (MMS)(curr_func(L)->c.ffid - (int)FF_ffi_meta___eq + (int)MM_eq); + return lj_carith_op(L, mm); +} + +/* The following functions must be in contiguous ORDER MM. */ +LJLIB_CF(ffi_meta___eq) LJLIB_REC(cdata_arith MM_eq) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___len) LJLIB_REC(cdata_arith MM_len) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___lt) LJLIB_REC(cdata_arith MM_lt) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___le) LJLIB_REC(cdata_arith MM_le) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___concat) LJLIB_REC(cdata_arith MM_concat) +{ + return ffi_arith(L); +} + +/* Forward declaration. */ +static int lj_cf_ffi_new(lua_State *L); + +LJLIB_CF(ffi_meta___call) LJLIB_REC(cdata_call) +{ + CTState *cts = ctype_cts(L); + GCcdata *cd = ffi_checkcdata(L, 1); + CTypeID id = cd->ctypeid; + CType *ct; + cTValue *tv; + MMS mm = MM_call; + if (cd->ctypeid == CTID_CTYPEID) { + id = *(CTypeID *)cdataptr(cd); + mm = MM_new; + } else { + int ret = lj_ccall_func(L, cd); + if (ret >= 0) + return ret; + } + /* Handle ctype __call/__new metamethod. */ + ct = ctype_raw(cts, id); + if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); + tv = lj_ctype_meta(cts, id, mm); + if (tv) + return lj_meta_tailcall(L, tv); + else if (mm == MM_call) + lj_err_callerv(L, LJ_ERR_FFI_BADCALL, strdata(lj_ctype_repr(L, id, NULL))); + return lj_cf_ffi_new(L); +} + +LJLIB_CF(ffi_meta___add) LJLIB_REC(cdata_arith MM_add) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___sub) LJLIB_REC(cdata_arith MM_sub) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___mul) LJLIB_REC(cdata_arith MM_mul) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___div) LJLIB_REC(cdata_arith MM_div) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___mod) LJLIB_REC(cdata_arith MM_mod) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___pow) LJLIB_REC(cdata_arith MM_pow) +{ + return ffi_arith(L); +} + +LJLIB_CF(ffi_meta___unm) LJLIB_REC(cdata_arith MM_unm) +{ + return ffi_arith(L); +} +/* End of contiguous ORDER MM. */ + +LJLIB_CF(ffi_meta___tostring) +{ + GCcdata *cd = ffi_checkcdata(L, 1); + const char *msg = "cdata<%s>: %p"; + CTypeID id = cd->ctypeid; + void *p = cdataptr(cd); + if (id == CTID_CTYPEID) { + msg = "ctype<%s>"; + id = *(CTypeID *)p; + } else { + CTState *cts = ctype_cts(L); + CType *ct = ctype_raw(cts, id); + if (ctype_isref(ct->info)) { + p = *(void **)p; + ct = ctype_rawchild(cts, ct); + } + if (ctype_iscomplex(ct->info)) { + setstrV(L, L->top-1, lj_ctype_repr_complex(L, cdataptr(cd), ct->size)); + goto checkgc; + } else if (ct->size == 8 && ctype_isinteger(ct->info)) { + setstrV(L, L->top-1, lj_ctype_repr_int64(L, *(uint64_t *)cdataptr(cd), + (ct->info & CTF_UNSIGNED))); + goto checkgc; + } else if (ctype_isfunc(ct->info)) { + p = *(void **)p; + } else if (ctype_isenum(ct->info)) { + msg = "cdata<%s>: %d"; + p = (void *)(uintptr_t)*(uint32_t **)p; + } else { + if (ctype_isptr(ct->info)) { + p = cdata_getptr(p, ct->size); + ct = ctype_rawchild(cts, ct); + } + if (ctype_isstruct(ct->info) || ctype_isvector(ct->info)) { + /* Handle ctype __tostring metamethod. */ + cTValue *tv = lj_ctype_meta(cts, ctype_typeid(cts, ct), MM_tostring); + if (tv) + return lj_meta_tailcall(L, tv); + } + } + } + lj_str_pushf(L, msg, strdata(lj_ctype_repr(L, id, NULL)), p); +checkgc: + lj_gc_check(L); + return 1; +} + +static int ffi_pairs(lua_State *L, MMS mm) +{ + CTState *cts = ctype_cts(L); + CTypeID id = ffi_checkcdata(L, 1)->ctypeid; + CType *ct = ctype_raw(cts, id); + cTValue *tv; + if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); + tv = lj_ctype_meta(cts, id, mm); + if (!tv) + lj_err_callerv(L, LJ_ERR_FFI_BADMM, strdata(lj_ctype_repr(L, id, NULL)), + strdata(mmname_str(G(L), mm))); + return lj_meta_tailcall(L, tv); +} + +LJLIB_CF(ffi_meta___pairs) +{ + return ffi_pairs(L, MM_pairs); +} + +LJLIB_CF(ffi_meta___ipairs) +{ + return ffi_pairs(L, MM_ipairs); +} + +LJLIB_PUSH("ffi") LJLIB_SET(__metatable) + +#include "lj_libdef.h" + +/* -- C library metamethods ----------------------------------------------- */ + +#define LJLIB_MODULE_ffi_clib + +/* Index C library by a name. */ +static TValue *ffi_clib_index(lua_State *L) +{ + TValue *o = L->base; + CLibrary *cl; + if (!(o < L->top && tvisudata(o) && udataV(o)->udtype == UDTYPE_FFI_CLIB)) + lj_err_argt(L, 1, LUA_TUSERDATA); + cl = (CLibrary *)uddata(udataV(o)); + if (!(o+1 < L->top && tvisstr(o+1))) + lj_err_argt(L, 2, LUA_TSTRING); + return lj_clib_index(L, cl, strV(o+1)); +} + +LJLIB_CF(ffi_clib___index) LJLIB_REC(clib_index 1) +{ + TValue *tv = ffi_clib_index(L); + if (tviscdata(tv)) { + CTState *cts = ctype_cts(L); + GCcdata *cd = cdataV(tv); + CType *s = ctype_get(cts, cd->ctypeid); + if (ctype_isextern(s->info)) { + CTypeID sid = ctype_cid(s->info); + void *sp = *(void **)cdataptr(cd); + CType *ct = ctype_raw(cts, sid); + if (lj_cconv_tv_ct(cts, ct, sid, L->top-1, sp)) + lj_gc_check(L); + return 1; + } + } + copyTV(L, L->top-1, tv); + return 1; +} + +LJLIB_CF(ffi_clib___newindex) LJLIB_REC(clib_index 0) +{ + TValue *tv = ffi_clib_index(L); + TValue *o = L->base+2; + if (o < L->top && tviscdata(tv)) { + CTState *cts = ctype_cts(L); + GCcdata *cd = cdataV(tv); + CType *d = ctype_get(cts, cd->ctypeid); + if (ctype_isextern(d->info)) { + CTInfo qual = 0; + for (;;) { /* Skip attributes and collect qualifiers. */ + d = ctype_child(cts, d); + if (!ctype_isattrib(d->info)) break; + if (ctype_attrib(d->info) == CTA_QUAL) qual |= d->size; + } + if (!((d->info|qual) & CTF_CONST)) { + lj_cconv_ct_tv(cts, d, *(void **)cdataptr(cd), o, 0); + return 0; + } + } + } + lj_err_caller(L, LJ_ERR_FFI_WRCONST); + return 0; /* unreachable */ +} + +LJLIB_CF(ffi_clib___gc) +{ + TValue *o = L->base; + if (o < L->top && tvisudata(o) && udataV(o)->udtype == UDTYPE_FFI_CLIB) + lj_clib_unload((CLibrary *)uddata(udataV(o))); + return 0; +} + +#include "lj_libdef.h" + +/* -- Callback function metamethods --------------------------------------- */ + +#define LJLIB_MODULE_ffi_callback + +static int ffi_callback_set(lua_State *L, GCfunc *fn) +{ + GCcdata *cd = ffi_checkcdata(L, 1); + CTState *cts = ctype_cts(L); + CType *ct = ctype_raw(cts, cd->ctypeid); + if (ctype_isptr(ct->info) && (LJ_32 || ct->size == 8)) { + MSize slot = lj_ccallback_ptr2slot(cts, *(void **)cdataptr(cd)); + if (slot < cts->cb.sizeid && cts->cb.cbid[slot] != 0) { + GCtab *t = cts->miscmap; + TValue *tv = lj_tab_setint(L, t, (int32_t)slot); + if (fn) { + setfuncV(L, tv, fn); + lj_gc_anybarriert(L, t); + } else { + setnilV(tv); + cts->cb.cbid[slot] = 0; + cts->cb.topid = slot < cts->cb.topid ? slot : cts->cb.topid; + } + return 0; + } + } + lj_err_caller(L, LJ_ERR_FFI_BADCBACK); + return 0; +} + +LJLIB_CF(ffi_callback_free) +{ + return ffi_callback_set(L, NULL); +} + +LJLIB_CF(ffi_callback_set) +{ + GCfunc *fn = lj_lib_checkfunc(L, 2); + return ffi_callback_set(L, fn); +} + +LJLIB_PUSH(top-1) LJLIB_SET(__index) + +#include "lj_libdef.h" + +/* -- FFI library functions ----------------------------------------------- */ + +#define LJLIB_MODULE_ffi + +LJLIB_CF(ffi_cdef) +{ + GCstr *s = lj_lib_checkstr(L, 1); + CPState cp; + int errcode; + cp.L = L; + cp.cts = ctype_cts(L); + cp.srcname = strdata(s); + cp.p = strdata(s); + cp.param = L->base+1; + cp.mode = CPARSE_MODE_MULTI|CPARSE_MODE_DIRECT; + errcode = lj_cparse(&cp); + if (errcode) lj_err_throw(L, errcode); /* Propagate errors. */ + lj_gc_check(L); + return 0; +} + +LJLIB_CF(ffi_new) LJLIB_REC(.) +{ + CTState *cts = ctype_cts(L); + CTypeID id = ffi_checkctype(L, cts, NULL); + CType *ct = ctype_raw(cts, id); + CTSize sz; + CTInfo info = lj_ctype_info(cts, id, &sz); + TValue *o = L->base+1; + GCcdata *cd; + if ((info & CTF_VLA)) { + o++; + sz = lj_ctype_vlsize(cts, ct, (CTSize)ffi_checkint(L, 2)); + } + if (sz == CTSIZE_INVALID) + lj_err_arg(L, 1, LJ_ERR_FFI_INVSIZE); + if (!(info & CTF_VLA) && ctype_align(info) <= CT_MEMALIGN) + cd = lj_cdata_new(cts, id, sz); + else + cd = lj_cdata_newv(cts, id, sz, ctype_align(info)); + setcdataV(L, o-1, cd); /* Anchor the uninitialized cdata. */ + lj_cconv_ct_init(cts, ct, sz, cdataptr(cd), + o, (MSize)(L->top - o)); /* Initialize cdata. */ + if (ctype_isstruct(ct->info)) { + /* Handle ctype __gc metamethod. Use the fast lookup here. */ + cTValue *tv = lj_tab_getinth(cts->miscmap, -(int32_t)id); + if (tv && tvistab(tv) && (tv = lj_meta_fast(L, tabV(tv), MM_gc))) { + GCtab *t = cts->finalizer; + if (gcref(t->metatable)) { + /* Add to finalizer table, if still enabled. */ + copyTV(L, lj_tab_set(L, t, o-1), tv); + lj_gc_anybarriert(L, t); + cd->marked |= LJ_GC_CDATA_FIN; + } + } + } + L->top = o; /* Only return the cdata itself. */ + lj_gc_check(L); + return 1; +} + +LJLIB_CF(ffi_cast) LJLIB_REC(ffi_new) +{ + CTState *cts = ctype_cts(L); + CTypeID id = ffi_checkctype(L, cts, NULL); + CType *d = ctype_raw(cts, id); + TValue *o = lj_lib_checkany(L, 2); + L->top = o+1; /* Make sure this is the last item on the stack. */ + if (!(ctype_isnum(d->info) || ctype_isptr(d->info) || ctype_isenum(d->info))) + lj_err_arg(L, 1, LJ_ERR_FFI_INVTYPE); + if (!(tviscdata(o) && cdataV(o)->ctypeid == id)) { + GCcdata *cd = lj_cdata_new(cts, id, d->size); + lj_cconv_ct_tv(cts, d, cdataptr(cd), o, CCF_CAST); + setcdataV(L, o, cd); + lj_gc_check(L); + } + return 1; +} + +LJLIB_CF(ffi_typeof) LJLIB_REC(.) +{ + CTState *cts = ctype_cts(L); + CTypeID id = ffi_checkctype(L, cts, L->base+1); + GCcdata *cd = lj_cdata_new(cts, CTID_CTYPEID, 4); + *(CTypeID *)cdataptr(cd) = id; + setcdataV(L, L->top-1, cd); + lj_gc_check(L); + return 1; +} + +LJLIB_CF(ffi_istype) LJLIB_REC(.) +{ + CTState *cts = ctype_cts(L); + CTypeID id1 = ffi_checkctype(L, cts, NULL); + TValue *o = lj_lib_checkany(L, 2); + int b = 0; + if (tviscdata(o)) { + GCcdata *cd = cdataV(o); + CTypeID id2 = cd->ctypeid == CTID_CTYPEID ? *(CTypeID *)cdataptr(cd) : + cd->ctypeid; + CType *ct1 = lj_ctype_rawref(cts, id1); + CType *ct2 = lj_ctype_rawref(cts, id2); + if (ct1 == ct2) { + b = 1; + } else if (ctype_type(ct1->info) == ctype_type(ct2->info) && + ct1->size == ct2->size) { + if (ctype_ispointer(ct1->info)) + b = lj_cconv_compatptr(cts, ct1, ct2, CCF_IGNQUAL); + else if (ctype_isnum(ct1->info) || ctype_isvoid(ct1->info)) + b = (((ct1->info ^ ct2->info) & ~(CTF_QUAL|CTF_LONG)) == 0); + } else if (ctype_isstruct(ct1->info) && ctype_isptr(ct2->info) && + ct1 == ctype_rawchild(cts, ct2)) { + b = 1; + } + } + setboolV(L->top-1, b); + setboolV(&G(L)->tmptv2, b); /* Remember for trace recorder. */ + return 1; +} + +LJLIB_CF(ffi_sizeof) LJLIB_REC(ffi_xof FF_ffi_sizeof) +{ + CTState *cts = ctype_cts(L); + CTypeID id = ffi_checkctype(L, cts, NULL); + CTSize sz; + if (LJ_UNLIKELY(tviscdata(L->base) && cdataisv(cdataV(L->base)))) { + sz = cdatavlen(cdataV(L->base)); + } else { + CType *ct = lj_ctype_rawref(cts, id); + if (ctype_isvltype(ct->info)) + sz = lj_ctype_vlsize(cts, ct, (CTSize)ffi_checkint(L, 2)); + else + sz = ctype_hassize(ct->info) ? ct->size : CTSIZE_INVALID; + if (LJ_UNLIKELY(sz == CTSIZE_INVALID)) { + setnilV(L->top-1); + return 1; + } + } + setintV(L->top-1, (int32_t)sz); + return 1; +} + +LJLIB_CF(ffi_alignof) LJLIB_REC(ffi_xof FF_ffi_alignof) +{ + CTState *cts = ctype_cts(L); + CTypeID id = ffi_checkctype(L, cts, NULL); + CTSize sz = 0; + CTInfo info = lj_ctype_info(cts, id, &sz); + setintV(L->top-1, 1 << ctype_align(info)); + return 1; +} + +LJLIB_CF(ffi_offsetof) LJLIB_REC(ffi_xof FF_ffi_offsetof) +{ + CTState *cts = ctype_cts(L); + CTypeID id = ffi_checkctype(L, cts, NULL); + GCstr *name = lj_lib_checkstr(L, 2); + CType *ct = lj_ctype_rawref(cts, id); + CTSize ofs; + if (ctype_isstruct(ct->info) && ct->size != CTSIZE_INVALID) { + CType *fct = lj_ctype_getfield(cts, ct, name, &ofs); + if (fct) { + setintV(L->top-1, ofs); + if (ctype_isfield(fct->info)) { + return 1; + } else if (ctype_isbitfield(fct->info)) { + setintV(L->top++, ctype_bitpos(fct->info)); + setintV(L->top++, ctype_bitbsz(fct->info)); + return 3; + } + } + } + return 0; +} + +LJLIB_CF(ffi_errno) LJLIB_REC(.) +{ + int err = errno; + if (L->top > L->base) + errno = ffi_checkint(L, 1); + setintV(L->top++, err); + return 1; +} + +LJLIB_CF(ffi_string) LJLIB_REC(.) +{ + CTState *cts = ctype_cts(L); + TValue *o = lj_lib_checkany(L, 1); + const char *p; + size_t len; + if (o+1 < L->top && !tvisnil(o+1)) { + len = (size_t)ffi_checkint(L, 2); + lj_cconv_ct_tv(cts, ctype_get(cts, CTID_P_CVOID), (uint8_t *)&p, o, + CCF_ARG(1)); + } else { + lj_cconv_ct_tv(cts, ctype_get(cts, CTID_P_CCHAR), (uint8_t *)&p, o, + CCF_ARG(1)); + len = strlen(p); + } + L->top = o+1; /* Make sure this is the last item on the stack. */ + setstrV(L, o, lj_str_new(L, p, len)); + lj_gc_check(L); + return 1; +} + +LJLIB_CF(ffi_copy) LJLIB_REC(.) +{ + void *dp = ffi_checkptr(L, 1, CTID_P_VOID); + void *sp = ffi_checkptr(L, 2, CTID_P_CVOID); + TValue *o = L->base+1; + CTSize len; + if (tvisstr(o) && o+1 >= L->top) + len = strV(o)->len+1; /* Copy Lua string including trailing '\0'. */ + else + len = (CTSize)ffi_checkint(L, 3); + memcpy(dp, sp, len); + return 0; +} + +LJLIB_CF(ffi_fill) LJLIB_REC(.) +{ + void *dp = ffi_checkptr(L, 1, CTID_P_VOID); + CTSize len = (CTSize)ffi_checkint(L, 2); + int32_t fill = 0; + if (L->base+2 < L->top && !tvisnil(L->base+2)) fill = ffi_checkint(L, 3); + memset(dp, fill, len); + return 0; +} + +#define H_(le, be) LJ_ENDIAN_SELECT(0x##le, 0x##be) + +/* Test ABI string. */ +LJLIB_CF(ffi_abi) LJLIB_REC(.) +{ + GCstr *s = lj_lib_checkstr(L, 1); + int b = 0; + switch (s->hash) { +#if LJ_64 + case H_(849858eb,ad35fd06): b = 1; break; /* 64bit */ +#else + case H_(662d3c79,d0e22477): b = 1; break; /* 32bit */ +#endif +#if LJ_ARCH_HASFPU + case H_(e33ee463,e33ee463): b = 1; break; /* fpu */ +#endif +#if LJ_ABI_SOFTFP + case H_(61211a23,c2e8c81c): b = 1; break; /* softfp */ +#else + case H_(539417a8,8ce0812f): b = 1; break; /* hardfp */ +#endif +#if LJ_ABI_EABI + case H_(2182df8f,f2ed1152): b = 1; break; /* eabi */ +#endif +#if LJ_ABI_WIN + case H_(4ab624a8,4ab624a8): b = 1; break; /* win */ +#endif + case H_(3af93066,1f001464): b = 1; break; /* le/be */ + default: + break; + } + setboolV(L->top-1, b); + setboolV(&G(L)->tmptv2, b); /* Remember for trace recorder. */ + return 1; +} + +#undef H_ + +LJLIB_PUSH(top-8) LJLIB_SET(!) /* Store reference to miscmap table. */ + +LJLIB_CF(ffi_metatype) +{ + CTState *cts = ctype_cts(L); + CTypeID id = ffi_checkctype(L, cts, NULL); + GCtab *mt = lj_lib_checktab(L, 2); + GCtab *t = cts->miscmap; + CType *ct = ctype_get(cts, id); /* Only allow raw types. */ + TValue *tv; + GCcdata *cd; + if (!(ctype_isstruct(ct->info) || ctype_iscomplex(ct->info) || + ctype_isvector(ct->info))) + lj_err_arg(L, 1, LJ_ERR_FFI_INVTYPE); + tv = lj_tab_setinth(L, t, -(int32_t)id); + if (!tvisnil(tv)) + lj_err_caller(L, LJ_ERR_PROTMT); + settabV(L, tv, mt); + lj_gc_anybarriert(L, t); + cd = lj_cdata_new(cts, CTID_CTYPEID, 4); + *(CTypeID *)cdataptr(cd) = id; + setcdataV(L, L->top-1, cd); + lj_gc_check(L); + return 1; +} + +LJLIB_PUSH(top-7) LJLIB_SET(!) /* Store reference to finalizer table. */ + +LJLIB_CF(ffi_gc) LJLIB_REC(.) +{ + GCcdata *cd = ffi_checkcdata(L, 1); + TValue *fin = lj_lib_checkany(L, 2); + CTState *cts = ctype_cts(L); + GCtab *t = cts->finalizer; + CType *ct = ctype_raw(cts, cd->ctypeid); + if (!(ctype_isptr(ct->info) || ctype_isstruct(ct->info) || + ctype_isrefarray(ct->info))) + lj_err_arg(L, 1, LJ_ERR_FFI_INVTYPE); + if (gcref(t->metatable)) { /* Update finalizer table, if still enabled. */ + copyTV(L, lj_tab_set(L, t, L->base), fin); + lj_gc_anybarriert(L, t); + if (!tvisnil(fin)) + cd->marked |= LJ_GC_CDATA_FIN; + else + cd->marked &= ~LJ_GC_CDATA_FIN; + } + L->top = L->base+1; /* Pass through the cdata object. */ + return 1; +} + +LJLIB_PUSH(top-5) LJLIB_SET(!) /* Store clib metatable in func environment. */ + +LJLIB_CF(ffi_load) +{ + GCstr *name = lj_lib_checkstr(L, 1); + int global = (L->base+1 < L->top && tvistruecond(L->base+1)); + lj_clib_load(L, tabref(curr_func(L)->c.env), name, global); + return 1; +} + +LJLIB_PUSH(top-4) LJLIB_SET(C) +LJLIB_PUSH(top-3) LJLIB_SET(os) +LJLIB_PUSH(top-2) LJLIB_SET(arch) + +#include "lj_libdef.h" + +/* ------------------------------------------------------------------------ */ + +/* Create special weak-keyed finalizer table. */ +static GCtab *ffi_finalizer(lua_State *L) +{ + /* NOBARRIER: The table is new (marked white). */ + GCtab *t = lj_tab_new(L, 0, 1); + settabV(L, L->top++, t); + setgcref(t->metatable, obj2gco(t)); + setstrV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "__mode")), + lj_str_newlit(L, "K")); + t->nomm = (uint8_t)(~(1u<top-1); + lj_gc_anybarriert(L, t); + } +} + +LUALIB_API int luaopen_ffi(lua_State *L) +{ + CTState *cts = lj_ctype_init(L); + settabV(L, L->top++, (cts->miscmap = lj_tab_new(L, 0, 1))); + cts->finalizer = ffi_finalizer(L); + LJ_LIB_REG(L, NULL, ffi_meta); + /* NOBARRIER: basemt is a GC root. */ + setgcref(basemt_it(G(L), LJ_TCDATA), obj2gco(tabV(L->top-1))); + LJ_LIB_REG(L, NULL, ffi_clib); + LJ_LIB_REG(L, NULL, ffi_callback); + /* NOBARRIER: the key is new and lj_tab_newkey() handles the barrier. */ + settabV(L, lj_tab_setstr(L, cts->miscmap, &cts->g->strempty), tabV(L->top-1)); + L->top--; + lj_clib_default(L, tabV(L->top-1)); /* Create ffi.C default namespace. */ + lua_pushliteral(L, LJ_OS_NAME); + lua_pushliteral(L, LJ_ARCH_NAME); + LJ_LIB_REG(L, NULL, ffi); /* Note: no global "ffi" created! */ + ffi_register_module(L); + return 1; +} + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lib_init.c b/source/libs/luajit/LuaJIT-2.0.4/src/lib_init.c new file mode 100644 index 000000000..8e0d4428f --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lib_init.c @@ -0,0 +1,56 @@ +/* +** Library initialization. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Major parts taken verbatim from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lib_init_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_arch.h" + +static const luaL_Reg lj_lib_load[] = { + { "", luaopen_base }, + { LUA_LOADLIBNAME, luaopen_package }, + { LUA_TABLIBNAME, luaopen_table }, + { LUA_IOLIBNAME, luaopen_io }, + { LUA_OSLIBNAME, luaopen_os }, + { LUA_STRLIBNAME, luaopen_string }, + { LUA_MATHLIBNAME, luaopen_math }, + { LUA_DBLIBNAME, luaopen_debug }, + { LUA_BITLIBNAME, luaopen_bit }, + { LUA_JITLIBNAME, luaopen_jit }, + { LUA_BITLIBNAME_32, luaopen_bit32 }, + { NULL, NULL } +}; + +static const luaL_Reg lj_lib_preload[] = { +#if LJ_HASFFI + { LUA_FFILIBNAME, luaopen_ffi }, +#endif + { NULL, NULL } +}; + +LUALIB_API void luaL_openlibs(lua_State *L) +{ + const luaL_Reg *lib; + for (lib = lj_lib_load; lib->func; lib++) { + lua_pushcfunction(L, lib->func); + lua_pushstring(L, lib->name); + lua_call(L, 1, 0); + } + luaL_findtable(L, LUA_REGISTRYINDEX, "_PRELOAD", + sizeof(lj_lib_preload)/sizeof(lj_lib_preload[0])-1); + for (lib = lj_lib_preload; lib->func; lib++) { + lua_pushcfunction(L, lib->func); + lua_setfield(L, -2, lib->name); + } + lua_pop(L, 1); +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lib_io.c b/source/libs/luajit/LuaJIT-2.0.4/src/lib_io.c new file mode 100644 index 000000000..037aa28e5 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lib_io.c @@ -0,0 +1,539 @@ +/* +** I/O library. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#include +#include + +#define lib_io_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_state.h" +#include "lj_ff.h" +#include "lj_lib.h" + +/* Userdata payload for I/O file. */ +typedef struct IOFileUD { + FILE *fp; /* File handle. */ + uint32_t type; /* File type. */ +} IOFileUD; + +#define IOFILE_TYPE_FILE 0 /* Regular file. */ +#define IOFILE_TYPE_PIPE 1 /* Pipe. */ +#define IOFILE_TYPE_STDF 2 /* Standard file handle. */ +#define IOFILE_TYPE_MASK 3 + +#define IOFILE_FLAG_CLOSE 4 /* Close after io.lines() iterator. */ + +#define IOSTDF_UD(L, id) (&gcref(G(L)->gcroot[(id)])->ud) +#define IOSTDF_IOF(L, id) ((IOFileUD *)uddata(IOSTDF_UD(L, (id)))) + +/* -- Open/close helpers -------------------------------------------------- */ + +static IOFileUD *io_tofilep(lua_State *L) +{ + if (!(L->base < L->top && tvisudata(L->base) && + udataV(L->base)->udtype == UDTYPE_IO_FILE)) + lj_err_argtype(L, 1, "FILE*"); + return (IOFileUD *)uddata(udataV(L->base)); +} + +static IOFileUD *io_tofile(lua_State *L) +{ + IOFileUD *iof = io_tofilep(L); + if (iof->fp == NULL) + lj_err_caller(L, LJ_ERR_IOCLFL); + return iof; +} + +static FILE *io_stdfile(lua_State *L, ptrdiff_t id) +{ + IOFileUD *iof = IOSTDF_IOF(L, id); + if (iof->fp == NULL) + lj_err_caller(L, LJ_ERR_IOSTDCL); + return iof->fp; +} + +static IOFileUD *io_file_new(lua_State *L) +{ + IOFileUD *iof = (IOFileUD *)lua_newuserdata(L, sizeof(IOFileUD)); + GCudata *ud = udataV(L->top-1); + ud->udtype = UDTYPE_IO_FILE; + /* NOBARRIER: The GCudata is new (marked white). */ + setgcrefr(ud->metatable, curr_func(L)->c.env); + iof->fp = NULL; + iof->type = IOFILE_TYPE_FILE; + return iof; +} + +static IOFileUD *io_file_open(lua_State *L, const char *mode) +{ + const char *fname = strdata(lj_lib_checkstr(L, 1)); + IOFileUD *iof = io_file_new(L); + iof->fp = fopen(fname, mode); + if (iof->fp == NULL) + luaL_argerror(L, 1, lj_str_pushf(L, "%s: %s", fname, strerror(errno))); + return iof; +} + +static int io_file_close(lua_State *L, IOFileUD *iof) +{ + int ok; + if ((iof->type & IOFILE_TYPE_MASK) == IOFILE_TYPE_FILE) { + ok = (fclose(iof->fp) == 0); + } else if ((iof->type & IOFILE_TYPE_MASK) == IOFILE_TYPE_PIPE) { + int stat = -1; +#if LJ_TARGET_POSIX + stat = pclose(iof->fp); +#elif LJ_TARGET_WINDOWS + stat = _pclose(iof->fp); +#else + lua_assert(0); + return 0; +#endif +#if LJ_52 + iof->fp = NULL; + return luaL_execresult(L, stat); +#else + ok = (stat != -1); +#endif + } else { + lua_assert((iof->type & IOFILE_TYPE_MASK) == IOFILE_TYPE_STDF); + setnilV(L->top++); + lua_pushliteral(L, "cannot close standard file"); + return 2; + } + iof->fp = NULL; + return luaL_fileresult(L, ok, NULL); +} + +/* -- Read/write helpers -------------------------------------------------- */ + +static int io_file_readnum(lua_State *L, FILE *fp) +{ + lua_Number d; + if (fscanf(fp, LUA_NUMBER_SCAN, &d) == 1) { + if (LJ_DUALNUM) { + int32_t i = lj_num2int(d); + if (d == (lua_Number)i && !tvismzero((cTValue *)&d)) { + setintV(L->top++, i); + return 1; + } + } + setnumV(L->top++, d); + return 1; + } else { + setnilV(L->top++); + return 0; + } +} + +static int io_file_readline(lua_State *L, FILE *fp, MSize chop) +{ + MSize m = LUAL_BUFFERSIZE, n = 0, ok = 0; + char *buf; + for (;;) { + buf = lj_str_needbuf(L, &G(L)->tmpbuf, m); + if (fgets(buf+n, m-n, fp) == NULL) break; + n += (MSize)strlen(buf+n); + ok |= n; + if (n && buf[n-1] == '\n') { n -= chop; break; } + if (n >= m - 64) m += m; + } + setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n)); + lj_gc_check(L); + return (int)ok; +} + +static void io_file_readall(lua_State *L, FILE *fp) +{ + MSize m, n; + for (m = LUAL_BUFFERSIZE, n = 0; ; m += m) { + char *buf = lj_str_needbuf(L, &G(L)->tmpbuf, m); + n += (MSize)fread(buf+n, 1, m-n, fp); + if (n != m) { + setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n)); + lj_gc_check(L); + return; + } + } +} + +static int io_file_readlen(lua_State *L, FILE *fp, MSize m) +{ + if (m) { + char *buf = lj_str_needbuf(L, &G(L)->tmpbuf, m); + MSize n = (MSize)fread(buf, 1, m, fp); + setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n)); + lj_gc_check(L); + return (n > 0 || m == 0); + } else { + int c = getc(fp); + ungetc(c, fp); + setstrV(L, L->top++, &G(L)->strempty); + return (c != EOF); + } +} + +static int io_file_read(lua_State *L, FILE *fp, int start) +{ + int ok, n, nargs = (int)(L->top - L->base) - start; + clearerr(fp); + if (nargs == 0) { + ok = io_file_readline(L, fp, 1); + n = start+1; /* Return 1 result. */ + } else { + /* The results plus the buffers go on top of the args. */ + luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); + ok = 1; + for (n = start; nargs-- && ok; n++) { + if (tvisstr(L->base+n)) { + const char *p = strVdata(L->base+n); + if (p[0] != '*') + lj_err_arg(L, n+1, LJ_ERR_INVOPT); + if (p[1] == 'n') + ok = io_file_readnum(L, fp); + else if ((p[1] & ~0x20) == 'L') + ok = io_file_readline(L, fp, (p[1] == 'l')); + else if (p[1] == 'a') + io_file_readall(L, fp); + else + lj_err_arg(L, n+1, LJ_ERR_INVFMT); + } else if (tvisnumber(L->base+n)) { + ok = io_file_readlen(L, fp, (MSize)lj_lib_checkint(L, n+1)); + } else { + lj_err_arg(L, n+1, LJ_ERR_INVOPT); + } + } + } + if (ferror(fp)) + return luaL_fileresult(L, 0, NULL); + if (!ok) + setnilV(L->top-1); /* Replace last result with nil. */ + return n - start; +} + +static int io_file_write(lua_State *L, FILE *fp, int start) +{ + cTValue *tv; + int status = 1; + for (tv = L->base+start; tv < L->top; tv++) { + if (tvisstr(tv)) { + MSize len = strV(tv)->len; + status = status && (fwrite(strVdata(tv), 1, len, fp) == len); + } else if (tvisint(tv)) { + char buf[LJ_STR_INTBUF]; + char *p = lj_str_bufint(buf, intV(tv)); + size_t len = (size_t)(buf+LJ_STR_INTBUF-p); + status = status && (fwrite(p, 1, len, fp) == len); + } else if (tvisnum(tv)) { + status = status && (fprintf(fp, LUA_NUMBER_FMT, numV(tv)) > 0); + } else { + lj_err_argt(L, (int)(tv - L->base) + 1, LUA_TSTRING); + } + } + if (LJ_52 && status) { + L->top = L->base+1; + if (start == 0) + setudataV(L, L->base, IOSTDF_UD(L, GCROOT_IO_OUTPUT)); + return 1; + } + return luaL_fileresult(L, status, NULL); +} + +static int io_file_iter(lua_State *L) +{ + GCfunc *fn = curr_func(L); + IOFileUD *iof = uddata(udataV(&fn->c.upvalue[0])); + int n = fn->c.nupvalues - 1; + if (iof->fp == NULL) + lj_err_caller(L, LJ_ERR_IOCLFL); + L->top = L->base; + if (n) { /* Copy upvalues with options to stack. */ + if (n > LUAI_MAXCSTACK) + lj_err_caller(L, LJ_ERR_STKOV); + lj_state_checkstack(L, (MSize)n); + memcpy(L->top, &fn->c.upvalue[1], n*sizeof(TValue)); + L->top += n; + } + n = io_file_read(L, iof->fp, 0); + if (ferror(iof->fp)) + lj_err_callermsg(L, strVdata(L->top-2)); + if (tvisnil(L->base) && (iof->type & IOFILE_FLAG_CLOSE)) { + io_file_close(L, iof); /* Return values are ignored. */ + return 0; + } + return n; +} + +/* -- I/O file methods ---------------------------------------------------- */ + +#define LJLIB_MODULE_io_method + +LJLIB_CF(io_method_close) +{ + IOFileUD *iof = L->base < L->top ? io_tofile(L) : + IOSTDF_IOF(L, GCROOT_IO_OUTPUT); + return io_file_close(L, iof); +} + +LJLIB_CF(io_method_read) +{ + return io_file_read(L, io_tofile(L)->fp, 1); +} + +LJLIB_CF(io_method_write) LJLIB_REC(io_write 0) +{ + return io_file_write(L, io_tofile(L)->fp, 1); +} + +LJLIB_CF(io_method_flush) LJLIB_REC(io_flush 0) +{ + return luaL_fileresult(L, fflush(io_tofile(L)->fp) == 0, NULL); +} + +LJLIB_CF(io_method_seek) +{ + FILE *fp = io_tofile(L)->fp; + int opt = lj_lib_checkopt(L, 2, 1, "\3set\3cur\3end"); + int64_t ofs = 0; + cTValue *o; + int res; + if (opt == 0) opt = SEEK_SET; + else if (opt == 1) opt = SEEK_CUR; + else if (opt == 2) opt = SEEK_END; + o = L->base+2; + if (o < L->top) { + if (tvisint(o)) + ofs = (int64_t)intV(o); + else if (tvisnum(o)) + ofs = (int64_t)numV(o); + else if (!tvisnil(o)) + lj_err_argt(L, 3, LUA_TNUMBER); + } +#if LJ_TARGET_POSIX + res = fseeko(fp, ofs, opt); +#elif _MSC_VER >= 1400 + res = _fseeki64(fp, ofs, opt); +#elif defined(__MINGW32__) + res = fseeko64(fp, ofs, opt); +#else + res = fseek(fp, (long)ofs, opt); +#endif + if (res) + return luaL_fileresult(L, 0, NULL); +#if LJ_TARGET_POSIX + ofs = ftello(fp); +#elif _MSC_VER >= 1400 + ofs = _ftelli64(fp); +#elif defined(__MINGW32__) + ofs = ftello64(fp); +#else + ofs = (int64_t)ftell(fp); +#endif + setint64V(L->top-1, ofs); + return 1; +} + +LJLIB_CF(io_method_setvbuf) +{ + FILE *fp = io_tofile(L)->fp; + int opt = lj_lib_checkopt(L, 2, -1, "\4full\4line\2no"); + size_t sz = (size_t)lj_lib_optint(L, 3, LUAL_BUFFERSIZE); + if (opt == 0) opt = _IOFBF; + else if (opt == 1) opt = _IOLBF; + else if (opt == 2) opt = _IONBF; + return luaL_fileresult(L, setvbuf(fp, NULL, opt, sz) == 0, NULL); +} + +LJLIB_CF(io_method_lines) +{ + io_tofile(L); + lua_pushcclosure(L, io_file_iter, (int)(L->top - L->base)); + return 1; +} + +LJLIB_CF(io_method___gc) +{ + IOFileUD *iof = io_tofilep(L); + if (iof->fp != NULL && (iof->type & IOFILE_TYPE_MASK) != IOFILE_TYPE_STDF) + io_file_close(L, iof); + return 0; +} + +LJLIB_CF(io_method___tostring) +{ + IOFileUD *iof = io_tofilep(L); + if (iof->fp != NULL) + lua_pushfstring(L, "file (%p)", iof->fp); + else + lua_pushliteral(L, "file (closed)"); + return 1; +} + +LJLIB_PUSH(top-1) LJLIB_SET(__index) + +#include "lj_libdef.h" + +/* -- I/O library functions ----------------------------------------------- */ + +#define LJLIB_MODULE_io + +LJLIB_PUSH(top-2) LJLIB_SET(!) /* Set environment. */ + +LJLIB_CF(io_open) +{ + const char *fname = strdata(lj_lib_checkstr(L, 1)); + GCstr *s = lj_lib_optstr(L, 2); + const char *mode = s ? strdata(s) : "r"; + IOFileUD *iof = io_file_new(L); + iof->fp = fopen(fname, mode); + return iof->fp != NULL ? 1 : luaL_fileresult(L, 0, fname); +} + +LJLIB_CF(io_popen) +{ +#if LJ_TARGET_POSIX || LJ_TARGET_WINDOWS + const char *fname = strdata(lj_lib_checkstr(L, 1)); + GCstr *s = lj_lib_optstr(L, 2); + const char *mode = s ? strdata(s) : "r"; + IOFileUD *iof = io_file_new(L); + iof->type = IOFILE_TYPE_PIPE; +#if LJ_TARGET_POSIX + fflush(NULL); + iof->fp = popen(fname, mode); +#else + iof->fp = _popen(fname, mode); +#endif + return iof->fp != NULL ? 1 : luaL_fileresult(L, 0, fname); +#else + return luaL_error(L, LUA_QL("popen") " not supported"); +#endif +} + +LJLIB_CF(io_tmpfile) +{ + IOFileUD *iof = io_file_new(L); +#if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA + iof->fp = NULL; errno = ENOSYS; +#else + iof->fp = tmpfile(); +#endif + return iof->fp != NULL ? 1 : luaL_fileresult(L, 0, NULL); +} + +LJLIB_CF(io_close) +{ + return lj_cf_io_method_close(L); +} + +LJLIB_CF(io_read) +{ + return io_file_read(L, io_stdfile(L, GCROOT_IO_INPUT), 0); +} + +LJLIB_CF(io_write) LJLIB_REC(io_write GCROOT_IO_OUTPUT) +{ + return io_file_write(L, io_stdfile(L, GCROOT_IO_OUTPUT), 0); +} + +LJLIB_CF(io_flush) LJLIB_REC(io_flush GCROOT_IO_OUTPUT) +{ + return luaL_fileresult(L, fflush(io_stdfile(L, GCROOT_IO_OUTPUT)) == 0, NULL); +} + +static int io_std_getset(lua_State *L, ptrdiff_t id, const char *mode) +{ + if (L->base < L->top && !tvisnil(L->base)) { + if (tvisudata(L->base)) { + io_tofile(L); + L->top = L->base+1; + } else { + io_file_open(L, mode); + } + /* NOBARRIER: The standard I/O handles are GC roots. */ + setgcref(G(L)->gcroot[id], gcV(L->top-1)); + } else { + setudataV(L, L->top++, IOSTDF_UD(L, id)); + } + return 1; +} + +LJLIB_CF(io_input) +{ + return io_std_getset(L, GCROOT_IO_INPUT, "r"); +} + +LJLIB_CF(io_output) +{ + return io_std_getset(L, GCROOT_IO_OUTPUT, "w"); +} + +LJLIB_CF(io_lines) +{ + if (L->base == L->top) setnilV(L->top++); + if (!tvisnil(L->base)) { /* io.lines(fname) */ + IOFileUD *iof = io_file_open(L, "r"); + iof->type = IOFILE_TYPE_FILE|IOFILE_FLAG_CLOSE; + L->top--; + setudataV(L, L->base, udataV(L->top)); + } else { /* io.lines() iterates over stdin. */ + setudataV(L, L->base, IOSTDF_UD(L, GCROOT_IO_INPUT)); + } + lua_pushcclosure(L, io_file_iter, (int)(L->top - L->base)); + return 1; +} + +LJLIB_CF(io_type) +{ + cTValue *o = lj_lib_checkany(L, 1); + if (!(tvisudata(o) && udataV(o)->udtype == UDTYPE_IO_FILE)) + setnilV(L->top++); + else if (((IOFileUD *)uddata(udataV(o)))->fp != NULL) + lua_pushliteral(L, "file"); + else + lua_pushliteral(L, "closed file"); + return 1; +} + +#include "lj_libdef.h" + +/* ------------------------------------------------------------------------ */ + +static GCobj *io_std_new(lua_State *L, FILE *fp, const char *name) +{ + IOFileUD *iof = (IOFileUD *)lua_newuserdata(L, sizeof(IOFileUD)); + GCudata *ud = udataV(L->top-1); + ud->udtype = UDTYPE_IO_FILE; + /* NOBARRIER: The GCudata is new (marked white). */ + setgcref(ud->metatable, gcV(L->top-3)); + iof->fp = fp; + iof->type = IOFILE_TYPE_STDF; + lua_setfield(L, -2, name); + return obj2gco(ud); +} + +LUALIB_API int luaopen_io(lua_State *L) +{ + LJ_LIB_REG(L, NULL, io_method); + copyTV(L, L->top, L->top-1); L->top++; + lua_setfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE); + LJ_LIB_REG(L, LUA_IOLIBNAME, io); + setgcref(G(L)->gcroot[GCROOT_IO_INPUT], io_std_new(L, stdin, "stdin")); + setgcref(G(L)->gcroot[GCROOT_IO_OUTPUT], io_std_new(L, stdout, "stdout")); + io_std_new(L, stderr, "stderr"); + return 1; +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lib_jit.c b/source/libs/luajit/LuaJIT-2.0.4/src/lib_jit.c new file mode 100644 index 000000000..96525faf2 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lib_jit.c @@ -0,0 +1,663 @@ +/* +** JIT library. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lib_jit_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_arch.h" +#include "lj_obj.h" +#include "lj_err.h" +#include "lj_debug.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_bc.h" +#if LJ_HASJIT +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_ircall.h" +#include "lj_iropt.h" +#include "lj_target.h" +#endif +#include "lj_dispatch.h" +#include "lj_vm.h" +#include "lj_vmevent.h" +#include "lj_lib.h" + +#include "luajit.h" + +/* -- jit.* functions ----------------------------------------------------- */ + +#define LJLIB_MODULE_jit + +static int setjitmode(lua_State *L, int mode) +{ + int idx = 0; + if (L->base == L->top || tvisnil(L->base)) { /* jit.on/off/flush([nil]) */ + mode |= LUAJIT_MODE_ENGINE; + } else { + /* jit.on/off/flush(func|proto, nil|true|false) */ + if (tvisfunc(L->base) || tvisproto(L->base)) + idx = 1; + else if (!tvistrue(L->base)) /* jit.on/off/flush(true, nil|true|false) */ + goto err; + if (L->base+1 < L->top && tvisbool(L->base+1)) + mode |= boolV(L->base+1) ? LUAJIT_MODE_ALLFUNC : LUAJIT_MODE_ALLSUBFUNC; + else + mode |= LUAJIT_MODE_FUNC; + } + if (luaJIT_setmode(L, idx, mode) != 1) { + if ((mode & LUAJIT_MODE_MASK) == LUAJIT_MODE_ENGINE) + lj_err_caller(L, LJ_ERR_NOJIT); + err: + lj_err_argt(L, 1, LUA_TFUNCTION); + } + return 0; +} + +LJLIB_CF(jit_on) +{ + return setjitmode(L, LUAJIT_MODE_ON); +} + +LJLIB_CF(jit_off) +{ + return setjitmode(L, LUAJIT_MODE_OFF); +} + +LJLIB_CF(jit_flush) +{ +#if LJ_HASJIT + if (L->base < L->top && tvisnumber(L->base)) { + int traceno = lj_lib_checkint(L, 1); + luaJIT_setmode(L, traceno, LUAJIT_MODE_FLUSH|LUAJIT_MODE_TRACE); + return 0; + } +#endif + return setjitmode(L, LUAJIT_MODE_FLUSH); +} + +#if LJ_HASJIT +/* Push a string for every flag bit that is set. */ +static void flagbits_to_strings(lua_State *L, uint32_t flags, uint32_t base, + const char *str) +{ + for (; *str; base <<= 1, str += 1+*str) + if (flags & base) + setstrV(L, L->top++, lj_str_new(L, str+1, *(uint8_t *)str)); +} +#endif + +LJLIB_CF(jit_status) +{ +#if LJ_HASJIT + jit_State *J = L2J(L); + L->top = L->base; + setboolV(L->top++, (J->flags & JIT_F_ON) ? 1 : 0); + flagbits_to_strings(L, J->flags, JIT_F_CPU_FIRST, JIT_F_CPUSTRING); + flagbits_to_strings(L, J->flags, JIT_F_OPT_FIRST, JIT_F_OPTSTRING); + return (int)(L->top - L->base); +#else + setboolV(L->top++, 0); + return 1; +#endif +} + +LJLIB_CF(jit_attach) +{ +#ifdef LUAJIT_DISABLE_VMEVENT + luaL_error(L, "vmevent API disabled"); +#else + GCfunc *fn = lj_lib_checkfunc(L, 1); + GCstr *s = lj_lib_optstr(L, 2); + luaL_findtable(L, LUA_REGISTRYINDEX, LJ_VMEVENTS_REGKEY, LJ_VMEVENTS_HSIZE); + if (s) { /* Attach to given event. */ + const uint8_t *p = (const uint8_t *)strdata(s); + uint32_t h = s->len; + while (*p) h = h ^ (lj_rol(h, 6) + *p++); + lua_pushvalue(L, 1); + lua_rawseti(L, -2, VMEVENT_HASHIDX(h)); + G(L)->vmevmask = VMEVENT_NOCACHE; /* Invalidate cache. */ + } else { /* Detach if no event given. */ + setnilV(L->top++); + while (lua_next(L, -2)) { + L->top--; + if (tvisfunc(L->top) && funcV(L->top) == fn) { + setnilV(lj_tab_set(L, tabV(L->top-2), L->top-1)); + } + } + } +#endif + return 0; +} + +LJLIB_PUSH(top-5) LJLIB_SET(os) +LJLIB_PUSH(top-4) LJLIB_SET(arch) +LJLIB_PUSH(top-3) LJLIB_SET(version_num) +LJLIB_PUSH(top-2) LJLIB_SET(version) + +#include "lj_libdef.h" + +/* -- jit.util.* functions ------------------------------------------------ */ + +#define LJLIB_MODULE_jit_util + +/* -- Reflection API for Lua functions ------------------------------------ */ + +/* Return prototype of first argument (Lua function or prototype object) */ +static GCproto *check_Lproto(lua_State *L, int nolua) +{ + TValue *o = L->base; + if (L->top > o) { + if (tvisproto(o)) { + return protoV(o); + } else if (tvisfunc(o)) { + if (isluafunc(funcV(o))) + return funcproto(funcV(o)); + else if (nolua) + return NULL; + } + } + lj_err_argt(L, 1, LUA_TFUNCTION); + return NULL; /* unreachable */ +} + +static void setintfield(lua_State *L, GCtab *t, const char *name, int32_t val) +{ + setintV(lj_tab_setstr(L, t, lj_str_newz(L, name)), val); +} + +/* local info = jit.util.funcinfo(func [,pc]) */ +LJLIB_CF(jit_util_funcinfo) +{ + GCproto *pt = check_Lproto(L, 1); + if (pt) { + BCPos pc = (BCPos)lj_lib_optint(L, 2, 0); + GCtab *t; + lua_createtable(L, 0, 16); /* Increment hash size if fields are added. */ + t = tabV(L->top-1); + setintfield(L, t, "linedefined", pt->firstline); + setintfield(L, t, "lastlinedefined", pt->firstline + pt->numline); + setintfield(L, t, "stackslots", pt->framesize); + setintfield(L, t, "params", pt->numparams); + setintfield(L, t, "bytecodes", (int32_t)pt->sizebc); + setintfield(L, t, "gcconsts", (int32_t)pt->sizekgc); + setintfield(L, t, "nconsts", (int32_t)pt->sizekn); + setintfield(L, t, "upvalues", (int32_t)pt->sizeuv); + if (pc < pt->sizebc) + setintfield(L, t, "currentline", lj_debug_line(pt, pc)); + lua_pushboolean(L, (pt->flags & PROTO_VARARG)); + lua_setfield(L, -2, "isvararg"); + lua_pushboolean(L, (pt->flags & PROTO_CHILD)); + lua_setfield(L, -2, "children"); + setstrV(L, L->top++, proto_chunkname(pt)); + lua_setfield(L, -2, "source"); + lj_debug_pushloc(L, pt, pc); + lua_setfield(L, -2, "loc"); + } else { + GCfunc *fn = funcV(L->base); + GCtab *t; + lua_createtable(L, 0, 4); /* Increment hash size if fields are added. */ + t = tabV(L->top-1); + if (!iscfunc(fn)) + setintfield(L, t, "ffid", fn->c.ffid); + setintptrV(lj_tab_setstr(L, t, lj_str_newlit(L, "addr")), + (intptr_t)(void *)fn->c.f); + setintfield(L, t, "upvalues", fn->c.nupvalues); + } + return 1; +} + +/* local ins, m = jit.util.funcbc(func, pc) */ +LJLIB_CF(jit_util_funcbc) +{ + GCproto *pt = check_Lproto(L, 0); + BCPos pc = (BCPos)lj_lib_checkint(L, 2); + if (pc < pt->sizebc) { + BCIns ins = proto_bc(pt)[pc]; + BCOp op = bc_op(ins); + lua_assert(op < BC__MAX); + setintV(L->top, ins); + setintV(L->top+1, lj_bc_mode[op]); + L->top += 2; + return 2; + } + return 0; +} + +/* local k = jit.util.funck(func, idx) */ +LJLIB_CF(jit_util_funck) +{ + GCproto *pt = check_Lproto(L, 0); + ptrdiff_t idx = (ptrdiff_t)lj_lib_checkint(L, 2); + if (idx >= 0) { + if (idx < (ptrdiff_t)pt->sizekn) { + copyTV(L, L->top-1, proto_knumtv(pt, idx)); + return 1; + } + } else { + if (~idx < (ptrdiff_t)pt->sizekgc) { + GCobj *gc = proto_kgc(pt, idx); + setgcV(L, L->top-1, gc, ~gc->gch.gct); + return 1; + } + } + return 0; +} + +/* local name = jit.util.funcuvname(func, idx) */ +LJLIB_CF(jit_util_funcuvname) +{ + GCproto *pt = check_Lproto(L, 0); + uint32_t idx = (uint32_t)lj_lib_checkint(L, 2); + if (idx < pt->sizeuv) { + setstrV(L, L->top-1, lj_str_newz(L, lj_debug_uvname(pt, idx))); + return 1; + } + return 0; +} + +/* -- Reflection API for traces ------------------------------------------- */ + +#if LJ_HASJIT + +/* Check trace argument. Must not throw for non-existent trace numbers. */ +static GCtrace *jit_checktrace(lua_State *L) +{ + TraceNo tr = (TraceNo)lj_lib_checkint(L, 1); + jit_State *J = L2J(L); + if (tr > 0 && tr < J->sizetrace) + return traceref(J, tr); + return NULL; +} + +/* Names of link types. ORDER LJ_TRLINK */ +static const char *const jit_trlinkname[] = { + "none", "root", "loop", "tail-recursion", "up-recursion", "down-recursion", + "interpreter", "return" +}; + +/* local info = jit.util.traceinfo(tr) */ +LJLIB_CF(jit_util_traceinfo) +{ + GCtrace *T = jit_checktrace(L); + if (T) { + GCtab *t; + lua_createtable(L, 0, 8); /* Increment hash size if fields are added. */ + t = tabV(L->top-1); + setintfield(L, t, "nins", (int32_t)T->nins - REF_BIAS - 1); + setintfield(L, t, "nk", REF_BIAS - (int32_t)T->nk); + setintfield(L, t, "link", T->link); + setintfield(L, t, "nexit", T->nsnap); + setstrV(L, L->top++, lj_str_newz(L, jit_trlinkname[T->linktype])); + lua_setfield(L, -2, "linktype"); + /* There are many more fields. Add them only when needed. */ + return 1; + } + return 0; +} + +/* local m, ot, op1, op2, prev = jit.util.traceir(tr, idx) */ +LJLIB_CF(jit_util_traceir) +{ + GCtrace *T = jit_checktrace(L); + IRRef ref = (IRRef)lj_lib_checkint(L, 2) + REF_BIAS; + if (T && ref >= REF_BIAS && ref < T->nins) { + IRIns *ir = &T->ir[ref]; + int32_t m = lj_ir_mode[ir->o]; + setintV(L->top-2, m); + setintV(L->top-1, ir->ot); + setintV(L->top++, (int32_t)ir->op1 - (irm_op1(m)==IRMref ? REF_BIAS : 0)); + setintV(L->top++, (int32_t)ir->op2 - (irm_op2(m)==IRMref ? REF_BIAS : 0)); + setintV(L->top++, ir->prev); + return 5; + } + return 0; +} + +/* local k, t [, slot] = jit.util.tracek(tr, idx) */ +LJLIB_CF(jit_util_tracek) +{ + GCtrace *T = jit_checktrace(L); + IRRef ref = (IRRef)lj_lib_checkint(L, 2) + REF_BIAS; + if (T && ref >= T->nk && ref < REF_BIAS) { + IRIns *ir = &T->ir[ref]; + int32_t slot = -1; + if (ir->o == IR_KSLOT) { + slot = ir->op2; + ir = &T->ir[ir->op1]; + } + lj_ir_kvalue(L, L->top-2, ir); + setintV(L->top-1, (int32_t)irt_type(ir->t)); + if (slot == -1) + return 2; + setintV(L->top++, slot); + return 3; + } + return 0; +} + +/* local snap = jit.util.tracesnap(tr, sn) */ +LJLIB_CF(jit_util_tracesnap) +{ + GCtrace *T = jit_checktrace(L); + SnapNo sn = (SnapNo)lj_lib_checkint(L, 2); + if (T && sn < T->nsnap) { + SnapShot *snap = &T->snap[sn]; + SnapEntry *map = &T->snapmap[snap->mapofs]; + MSize n, nent = snap->nent; + GCtab *t; + lua_createtable(L, nent+2, 0); + t = tabV(L->top-1); + setintV(lj_tab_setint(L, t, 0), (int32_t)snap->ref - REF_BIAS); + setintV(lj_tab_setint(L, t, 1), (int32_t)snap->nslots); + for (n = 0; n < nent; n++) + setintV(lj_tab_setint(L, t, (int32_t)(n+2)), (int32_t)map[n]); + setintV(lj_tab_setint(L, t, (int32_t)(nent+2)), (int32_t)SNAP(255, 0, 0)); + return 1; + } + return 0; +} + +/* local mcode, addr, loop = jit.util.tracemc(tr) */ +LJLIB_CF(jit_util_tracemc) +{ + GCtrace *T = jit_checktrace(L); + if (T && T->mcode != NULL) { + setstrV(L, L->top-1, lj_str_new(L, (const char *)T->mcode, T->szmcode)); + setintptrV(L->top++, (intptr_t)(void *)T->mcode); + setintV(L->top++, T->mcloop); + return 3; + } + return 0; +} + +/* local addr = jit.util.traceexitstub([tr,] exitno) */ +LJLIB_CF(jit_util_traceexitstub) +{ +#ifdef EXITSTUBS_PER_GROUP + ExitNo exitno = (ExitNo)lj_lib_checkint(L, 1); + jit_State *J = L2J(L); + if (exitno < EXITSTUBS_PER_GROUP*LJ_MAX_EXITSTUBGR) { + setintptrV(L->top-1, (intptr_t)(void *)exitstub_addr(J, exitno)); + return 1; + } +#else + if (L->top > L->base+1) { /* Don't throw for one-argument variant. */ + GCtrace *T = jit_checktrace(L); + ExitNo exitno = (ExitNo)lj_lib_checkint(L, 2); + ExitNo maxexit = T->root ? T->nsnap+1 : T->nsnap; + if (T && T->mcode != NULL && exitno < maxexit) { + setintptrV(L->top-1, (intptr_t)(void *)exitstub_trace_addr(T, exitno)); + return 1; + } + } +#endif + return 0; +} + +/* local addr = jit.util.ircalladdr(idx) */ +LJLIB_CF(jit_util_ircalladdr) +{ + uint32_t idx = (uint32_t)lj_lib_checkint(L, 1); + if (idx < IRCALL__MAX) { + setintptrV(L->top-1, (intptr_t)(void *)lj_ir_callinfo[idx].func); + return 1; + } + return 0; +} + +#endif + +#include "lj_libdef.h" + +/* -- jit.opt module ------------------------------------------------------ */ + +#if LJ_HASJIT + +#define LJLIB_MODULE_jit_opt + +/* Parse optimization level. */ +static int jitopt_level(jit_State *J, const char *str) +{ + if (str[0] >= '0' && str[0] <= '9' && str[1] == '\0') { + uint32_t flags; + if (str[0] == '0') flags = JIT_F_OPT_0; + else if (str[0] == '1') flags = JIT_F_OPT_1; + else if (str[0] == '2') flags = JIT_F_OPT_2; + else flags = JIT_F_OPT_3; + J->flags = (J->flags & ~JIT_F_OPT_MASK) | flags; + return 1; /* Ok. */ + } + return 0; /* No match. */ +} + +/* Parse optimization flag. */ +static int jitopt_flag(jit_State *J, const char *str) +{ + const char *lst = JIT_F_OPTSTRING; + uint32_t opt; + int set = 1; + if (str[0] == '+') { + str++; + } else if (str[0] == '-') { + str++; + set = 0; + } else if (str[0] == 'n' && str[1] == 'o') { + str += str[2] == '-' ? 3 : 2; + set = 0; + } + for (opt = JIT_F_OPT_FIRST; ; opt <<= 1) { + size_t len = *(const uint8_t *)lst; + if (len == 0) + break; + if (strncmp(str, lst+1, len) == 0 && str[len] == '\0') { + if (set) J->flags |= opt; else J->flags &= ~opt; + return 1; /* Ok. */ + } + lst += 1+len; + } + return 0; /* No match. */ +} + +/* Parse optimization parameter. */ +static int jitopt_param(jit_State *J, const char *str) +{ + const char *lst = JIT_P_STRING; + int i; + for (i = 0; i < JIT_P__MAX; i++) { + size_t len = *(const uint8_t *)lst; + lua_assert(len != 0); + if (strncmp(str, lst+1, len) == 0 && str[len] == '=') { + int32_t n = 0; + const char *p = &str[len+1]; + while (*p >= '0' && *p <= '9') + n = n*10 + (*p++ - '0'); + if (*p) return 0; /* Malformed number. */ + J->param[i] = n; + if (i == JIT_P_hotloop) + lj_dispatch_init_hotcount(J2G(J)); + return 1; /* Ok. */ + } + lst += 1+len; + } + return 0; /* No match. */ +} + +/* jit.opt.start(flags...) */ +LJLIB_CF(jit_opt_start) +{ + jit_State *J = L2J(L); + int nargs = (int)(L->top - L->base); + if (nargs == 0) { + J->flags = (J->flags & ~JIT_F_OPT_MASK) | JIT_F_OPT_DEFAULT; + } else { + int i; + for (i = 1; i <= nargs; i++) { + const char *str = strdata(lj_lib_checkstr(L, i)); + if (!jitopt_level(J, str) && + !jitopt_flag(J, str) && + !jitopt_param(J, str)) + lj_err_callerv(L, LJ_ERR_JITOPT, str); + } + } + return 0; +} + +#include "lj_libdef.h" + +#endif + +/* -- JIT compiler initialization ----------------------------------------- */ + +#if LJ_HASJIT +/* Default values for JIT parameters. */ +static const int32_t jit_param_default[JIT_P__MAX+1] = { +#define JIT_PARAMINIT(len, name, value) (value), +JIT_PARAMDEF(JIT_PARAMINIT) +#undef JIT_PARAMINIT + 0 +}; +#endif + +#if LJ_TARGET_ARM && LJ_TARGET_LINUX +#include +#endif + +/* Arch-dependent CPU detection. */ +static uint32_t jit_cpudetect(lua_State *L) +{ + uint32_t flags = 0; +#if LJ_TARGET_X86ORX64 + uint32_t vendor[4]; + uint32_t features[4]; + if (lj_vm_cpuid(0, vendor) && lj_vm_cpuid(1, features)) { +#if !LJ_HASJIT +#define JIT_F_CMOV 1 +#define JIT_F_SSE2 2 +#endif + flags |= ((features[3] >> 15)&1) * JIT_F_CMOV; + flags |= ((features[3] >> 26)&1) * JIT_F_SSE2; +#if LJ_HASJIT + flags |= ((features[2] >> 0)&1) * JIT_F_SSE3; + flags |= ((features[2] >> 19)&1) * JIT_F_SSE4_1; + if (vendor[2] == 0x6c65746e) { /* Intel. */ + if ((features[0] & 0x0ff00f00) == 0x00000f00) /* P4. */ + flags |= JIT_F_P4; /* Currently unused. */ + else if ((features[0] & 0x0fff0ff0) == 0x000106c0) /* Atom. */ + flags |= JIT_F_LEA_AGU; + } else if (vendor[2] == 0x444d4163) { /* AMD. */ + uint32_t fam = (features[0] & 0x0ff00f00); + if (fam == 0x00000f00) /* K8. */ + flags |= JIT_F_SPLIT_XMM; + if (fam >= 0x00000f00) /* K8, K10. */ + flags |= JIT_F_PREFER_IMUL; + } +#endif + } + /* Check for required instruction set support on x86 (unnecessary on x64). */ +#if LJ_TARGET_X86 +#if !defined(LUAJIT_CPU_NOCMOV) + if (!(flags & JIT_F_CMOV)) + luaL_error(L, "CPU not supported"); +#endif +#if defined(LUAJIT_CPU_SSE2) + if (!(flags & JIT_F_SSE2)) + luaL_error(L, "CPU does not support SSE2 (recompile without -DLUAJIT_CPU_SSE2)"); +#endif +#endif +#elif LJ_TARGET_ARM +#if LJ_HASJIT + int ver = LJ_ARCH_VERSION; /* Compile-time ARM CPU detection. */ +#if LJ_TARGET_LINUX + if (ver < 70) { /* Runtime ARM CPU detection. */ + struct utsname ut; + uname(&ut); + if (strncmp(ut.machine, "armv", 4) == 0) { + if (ut.machine[4] >= '7') + ver = 70; + else if (ut.machine[4] == '6') + ver = 60; + } + } +#endif + flags |= ver >= 70 ? JIT_F_ARMV7 : + ver >= 61 ? JIT_F_ARMV6T2_ : + ver >= 60 ? JIT_F_ARMV6_ : 0; + flags |= LJ_ARCH_HASFPU == 0 ? 0 : ver >= 70 ? JIT_F_VFPV3 : JIT_F_VFPV2; +#endif +#elif LJ_TARGET_PPC +#if LJ_HASJIT +#if LJ_ARCH_SQRT + flags |= JIT_F_SQRT; +#endif +#if LJ_ARCH_ROUND + flags |= JIT_F_ROUND; +#endif +#endif +#elif LJ_TARGET_PPCSPE + /* Nothing to do. */ +#elif LJ_TARGET_MIPS +#if LJ_HASJIT + /* Compile-time MIPS CPU detection. */ +#if LJ_ARCH_VERSION >= 20 + flags |= JIT_F_MIPS32R2; +#endif + /* Runtime MIPS CPU detection. */ +#if defined(__GNUC__) + if (!(flags & JIT_F_MIPS32R2)) { + int x; + /* On MIPS32R1 rotr is treated as srl. rotr r2,r2,1 -> srl r2,r2,1. */ + __asm__("li $2, 1\n\t.long 0x00221042\n\tmove %0, $2" : "=r"(x) : : "$2"); + if (x) flags |= JIT_F_MIPS32R2; /* Either 0x80000000 (R2) or 0 (R1). */ + } +#endif +#endif +#else +#error "Missing CPU detection for this architecture" +#endif + UNUSED(L); + return flags; +} + +/* Initialize JIT compiler. */ +static void jit_init(lua_State *L) +{ + uint32_t flags = jit_cpudetect(L); +#if LJ_HASJIT + jit_State *J = L2J(L); +#if LJ_TARGET_X86 + /* Silently turn off the JIT compiler on CPUs without SSE2. */ + if ((flags & JIT_F_SSE2)) +#endif + J->flags = flags | JIT_F_ON | JIT_F_OPT_DEFAULT; + memcpy(J->param, jit_param_default, sizeof(J->param)); + lj_dispatch_update(G(L)); +#else + UNUSED(flags); +#endif +} + +LUALIB_API int luaopen_jit(lua_State *L) +{ + lua_pushliteral(L, LJ_OS_NAME); + lua_pushliteral(L, LJ_ARCH_NAME); + lua_pushinteger(L, LUAJIT_VERSION_NUM); + lua_pushliteral(L, LUAJIT_VERSION); + LJ_LIB_REG(L, LUA_JITLIBNAME, jit); +#ifndef LUAJIT_DISABLE_JITUTIL + LJ_LIB_REG(L, "jit.util", jit_util); +#endif +#if LJ_HASJIT + LJ_LIB_REG(L, "jit.opt", jit_opt); +#endif + L->top -= 2; + jit_init(L); + return 1; +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lib_math.c b/source/libs/luajit/LuaJIT-2.0.4/src/lib_math.c new file mode 100644 index 000000000..40f29142d --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lib_math.c @@ -0,0 +1,233 @@ +/* +** Math library. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include + +#define lib_math_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_obj.h" +#include "lj_lib.h" +#include "lj_vm.h" + +/* ------------------------------------------------------------------------ */ + +#define LJLIB_MODULE_math + +LJLIB_ASM(math_abs) LJLIB_REC(.) +{ + lj_lib_checknumber(L, 1); + return FFH_RETRY; +} +LJLIB_ASM_(math_floor) LJLIB_REC(math_round IRFPM_FLOOR) +LJLIB_ASM_(math_ceil) LJLIB_REC(math_round IRFPM_CEIL) + +LJLIB_ASM(math_sqrt) LJLIB_REC(math_unary IRFPM_SQRT) +{ + lj_lib_checknum(L, 1); + return FFH_RETRY; +} +LJLIB_ASM_(math_log10) LJLIB_REC(math_unary IRFPM_LOG10) +LJLIB_ASM_(math_exp) LJLIB_REC(math_unary IRFPM_EXP) +LJLIB_ASM_(math_sin) LJLIB_REC(math_unary IRFPM_SIN) +LJLIB_ASM_(math_cos) LJLIB_REC(math_unary IRFPM_COS) +LJLIB_ASM_(math_tan) LJLIB_REC(math_unary IRFPM_TAN) +LJLIB_ASM_(math_asin) LJLIB_REC(math_atrig FF_math_asin) +LJLIB_ASM_(math_acos) LJLIB_REC(math_atrig FF_math_acos) +LJLIB_ASM_(math_atan) LJLIB_REC(math_atrig FF_math_atan) +LJLIB_ASM_(math_sinh) LJLIB_REC(math_htrig IRCALL_sinh) +LJLIB_ASM_(math_cosh) LJLIB_REC(math_htrig IRCALL_cosh) +LJLIB_ASM_(math_tanh) LJLIB_REC(math_htrig IRCALL_tanh) +LJLIB_ASM_(math_frexp) +LJLIB_ASM_(math_modf) LJLIB_REC(.) + +LJLIB_PUSH(57.29577951308232) +LJLIB_ASM_(math_deg) LJLIB_REC(math_degrad) + +LJLIB_PUSH(0.017453292519943295) +LJLIB_ASM_(math_rad) LJLIB_REC(math_degrad) + +LJLIB_ASM(math_log) LJLIB_REC(math_log) +{ + double x = lj_lib_checknum(L, 1); + if (L->base+1 < L->top) { + double y = lj_lib_checknum(L, 2); +#ifdef LUAJIT_NO_LOG2 + x = log(x); y = 1.0 / log(y); +#else + x = lj_vm_log2(x); y = 1.0 / lj_vm_log2(y); +#endif + setnumV(L->base-1, x*y); /* Do NOT join the expression to x / y. */ + return FFH_RES(1); + } + return FFH_RETRY; +} + +LJLIB_ASM(math_atan2) LJLIB_REC(.) +{ + lj_lib_checknum(L, 1); + lj_lib_checknum(L, 2); + return FFH_RETRY; +} +LJLIB_ASM_(math_pow) LJLIB_REC(.) +LJLIB_ASM_(math_fmod) + +LJLIB_ASM(math_ldexp) LJLIB_REC(.) +{ + lj_lib_checknum(L, 1); +#if LJ_DUALNUM && !LJ_TARGET_X86ORX64 + lj_lib_checkint(L, 2); +#else + lj_lib_checknum(L, 2); +#endif + return FFH_RETRY; +} + +LJLIB_ASM(math_min) LJLIB_REC(math_minmax IR_MIN) +{ + int i = 0; + do { lj_lib_checknumber(L, ++i); } while (L->base+i < L->top); + return FFH_RETRY; +} +LJLIB_ASM_(math_max) LJLIB_REC(math_minmax IR_MAX) + +LJLIB_PUSH(3.14159265358979323846) LJLIB_SET(pi) +LJLIB_PUSH(1e310) LJLIB_SET(huge) + +/* ------------------------------------------------------------------------ */ + +/* This implements a Tausworthe PRNG with period 2^223. Based on: +** Tables of maximally-equidistributed combined LFSR generators, +** Pierre L'Ecuyer, 1991, table 3, 1st entry. +** Full-period ME-CF generator with L=64, J=4, k=223, N1=49. +*/ + +/* PRNG state. */ +struct RandomState { + uint64_t gen[4]; /* State of the 4 LFSR generators. */ + int valid; /* State is valid. */ +}; + +/* Union needed for bit-pattern conversion between uint64_t and double. */ +typedef union { uint64_t u64; double d; } U64double; + +/* Update generator i and compute a running xor of all states. */ +#define TW223_GEN(i, k, q, s) \ + z = rs->gen[i]; \ + z = (((z<> (k-s)) ^ ((z&((uint64_t)(int64_t)-1 << (64-k)))<gen[i] = z; + +/* PRNG step function. Returns a double in the range 1.0 <= d < 2.0. */ +LJ_NOINLINE uint64_t LJ_FASTCALL lj_math_random_step(RandomState *rs) +{ + uint64_t z, r = 0; + TW223_GEN(0, 63, 31, 18) + TW223_GEN(1, 58, 19, 28) + TW223_GEN(2, 55, 24, 7) + TW223_GEN(3, 47, 21, 8) + return (r & U64x(000fffff,ffffffff)) | U64x(3ff00000,00000000); +} + +/* PRNG initialization function. */ +static void random_init(RandomState *rs, double d) +{ + uint32_t r = 0x11090601; /* 64-k[i] as four 8 bit constants. */ + int i; + for (i = 0; i < 4; i++) { + U64double u; + uint32_t m = 1u << (r&255); + r >>= 8; + u.d = d = d * 3.14159265358979323846 + 2.7182818284590452354; + if (u.u64 < m) u.u64 += m; /* Ensure k[i] MSB of gen[i] are non-zero. */ + rs->gen[i] = u.u64; + } + rs->valid = 1; + for (i = 0; i < 10; i++) + lj_math_random_step(rs); +} + +/* PRNG extract function. */ +LJLIB_PUSH(top-2) /* Upvalue holds userdata with RandomState. */ +LJLIB_CF(math_random) LJLIB_REC(.) +{ + int n = (int)(L->top - L->base); + RandomState *rs = (RandomState *)(uddata(udataV(lj_lib_upvalue(L, 1)))); + U64double u; + double d; + if (LJ_UNLIKELY(!rs->valid)) random_init(rs, 0.0); + u.u64 = lj_math_random_step(rs); + d = u.d - 1.0; + if (n > 0) { +#if LJ_DUALNUM + int isint = 1; + double r1; + lj_lib_checknumber(L, 1); + if (tvisint(L->base)) { + r1 = (lua_Number)intV(L->base); + } else { + isint = 0; + r1 = numV(L->base); + } +#else + double r1 = lj_lib_checknum(L, 1); +#endif + if (n == 1) { + d = lj_vm_floor(d*r1) + 1.0; /* d is an int in range [1, r1] */ + } else { +#if LJ_DUALNUM + double r2; + lj_lib_checknumber(L, 2); + if (tvisint(L->base+1)) { + r2 = (lua_Number)intV(L->base+1); + } else { + isint = 0; + r2 = numV(L->base+1); + } +#else + double r2 = lj_lib_checknum(L, 2); +#endif + d = lj_vm_floor(d*(r2-r1+1.0)) + r1; /* d is an int in range [r1, r2] */ + } +#if LJ_DUALNUM + if (isint) { + setintV(L->top-1, lj_num2int(d)); + return 1; + } +#endif + } /* else: d is a double in range [0, 1] */ + setnumV(L->top++, d); + return 1; +} + +/* PRNG seed function. */ +LJLIB_PUSH(top-2) /* Upvalue holds userdata with RandomState. */ +LJLIB_CF(math_randomseed) +{ + RandomState *rs = (RandomState *)(uddata(udataV(lj_lib_upvalue(L, 1)))); + random_init(rs, lj_lib_checknum(L, 1)); + return 0; +} + +/* ------------------------------------------------------------------------ */ + +#include "lj_libdef.h" + +LUALIB_API int luaopen_math(lua_State *L) +{ + RandomState *rs; + rs = (RandomState *)lua_newuserdata(L, sizeof(RandomState)); + rs->valid = 0; /* Use lazy initialization to save some time on startup. */ + LJ_LIB_REG(L, LUA_MATHLIBNAME, math); +#if defined(LUA_COMPAT_MOD) && !LJ_52 + lua_getfield(L, -1, "fmod"); + lua_setfield(L, -2, "mod"); +#endif + return 1; +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lib_os.c b/source/libs/luajit/LuaJIT-2.0.4/src/lib_os.c new file mode 100644 index 000000000..bb5a141e3 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lib_os.c @@ -0,0 +1,287 @@ +/* +** OS library. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#include +#include + +#define lib_os_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_obj.h" +#include "lj_err.h" +#include "lj_lib.h" + +#if LJ_TARGET_POSIX +#include +#else +#include +#endif + +#if !LJ_TARGET_PSVITA +#include +#endif + +/* ------------------------------------------------------------------------ */ + +#define LJLIB_MODULE_os + +LJLIB_CF(os_execute) +{ +#if LJ_TARGET_CONSOLE +#if LJ_52 + errno = ENOSYS; + return luaL_fileresult(L, 0, NULL); +#else + lua_pushinteger(L, -1); + return 1; +#endif +#else + const char *cmd = luaL_optstring(L, 1, NULL); + int stat = system(cmd); +#if LJ_52 + if (cmd) + return luaL_execresult(L, stat); + setboolV(L->top++, 1); +#else + setintV(L->top++, stat); +#endif + return 1; +#endif +} + +LJLIB_CF(os_remove) +{ + const char *filename = luaL_checkstring(L, 1); + return luaL_fileresult(L, remove(filename) == 0, filename); +} + +LJLIB_CF(os_rename) +{ + const char *fromname = luaL_checkstring(L, 1); + const char *toname = luaL_checkstring(L, 2); + return luaL_fileresult(L, rename(fromname, toname) == 0, fromname); +} + +LJLIB_CF(os_tmpname) +{ +#if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA + lj_err_caller(L, LJ_ERR_OSUNIQF); + return 0; +#else +#if LJ_TARGET_POSIX + char buf[15+1]; + int fp; + strcpy(buf, "/tmp/lua_XXXXXX"); + fp = mkstemp(buf); + if (fp != -1) + close(fp); + else + lj_err_caller(L, LJ_ERR_OSUNIQF); +#else + char buf[L_tmpnam]; + if (tmpnam(buf) == NULL) + lj_err_caller(L, LJ_ERR_OSUNIQF); +#endif + lua_pushstring(L, buf); + return 1; +#endif +} + +LJLIB_CF(os_getenv) +{ +#if LJ_TARGET_CONSOLE + lua_pushnil(L); +#else + lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ +#endif + return 1; +} + +LJLIB_CF(os_exit) +{ + int status; + if (L->base < L->top && tvisbool(L->base)) + status = boolV(L->base) ? EXIT_SUCCESS : EXIT_FAILURE; + else + status = lj_lib_optint(L, 1, EXIT_SUCCESS); + if (L->base+1 < L->top && tvistruecond(L->base+1)) + lua_close(L); + exit(status); + return 0; /* Unreachable. */ +} + +LJLIB_CF(os_clock) +{ + setnumV(L->top++, ((lua_Number)clock())*(1.0/(lua_Number)CLOCKS_PER_SEC)); + return 1; +} + +/* ------------------------------------------------------------------------ */ + +static void setfield(lua_State *L, const char *key, int value) +{ + lua_pushinteger(L, value); + lua_setfield(L, -2, key); +} + +static void setboolfield(lua_State *L, const char *key, int value) +{ + if (value < 0) /* undefined? */ + return; /* does not set field */ + lua_pushboolean(L, value); + lua_setfield(L, -2, key); +} + +static int getboolfield(lua_State *L, const char *key) +{ + int res; + lua_getfield(L, -1, key); + res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1); + lua_pop(L, 1); + return res; +} + +static int getfield(lua_State *L, const char *key, int d) +{ + int res; + lua_getfield(L, -1, key); + if (lua_isnumber(L, -1)) { + res = (int)lua_tointeger(L, -1); + } else { + if (d < 0) + lj_err_callerv(L, LJ_ERR_OSDATEF, key); + res = d; + } + lua_pop(L, 1); + return res; +} + +LJLIB_CF(os_date) +{ + const char *s = luaL_optstring(L, 1, "%c"); + time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL)); + struct tm *stm; +#if LJ_TARGET_POSIX + struct tm rtm; +#endif + if (*s == '!') { /* UTC? */ + s++; /* Skip '!' */ +#if LJ_TARGET_POSIX + stm = gmtime_r(&t, &rtm); +#else + stm = gmtime(&t); +#endif + } else { +#if LJ_TARGET_POSIX + stm = localtime_r(&t, &rtm); +#else + stm = localtime(&t); +#endif + } + if (stm == NULL) { /* Invalid date? */ + setnilV(L->top-1); + } else if (strcmp(s, "*t") == 0) { + lua_createtable(L, 0, 9); /* 9 = number of fields */ + setfield(L, "sec", stm->tm_sec); + setfield(L, "min", stm->tm_min); + setfield(L, "hour", stm->tm_hour); + setfield(L, "day", stm->tm_mday); + setfield(L, "month", stm->tm_mon+1); + setfield(L, "year", stm->tm_year+1900); + setfield(L, "wday", stm->tm_wday+1); + setfield(L, "yday", stm->tm_yday+1); + setboolfield(L, "isdst", stm->tm_isdst); + } else { + char cc[3]; + luaL_Buffer b; + cc[0] = '%'; cc[2] = '\0'; + luaL_buffinit(L, &b); + for (; *s; s++) { + if (*s != '%' || *(s + 1) == '\0') { /* No conversion specifier? */ + luaL_addchar(&b, *s); + } else { + size_t reslen; + char buff[200]; /* Should be big enough for any conversion result. */ + cc[1] = *(++s); + reslen = strftime(buff, sizeof(buff), cc, stm); + luaL_addlstring(&b, buff, reslen); + } + } + luaL_pushresult(&b); + } + return 1; +} + +LJLIB_CF(os_time) +{ + time_t t; + if (lua_isnoneornil(L, 1)) { /* called without args? */ + t = time(NULL); /* get current time */ + } else { + struct tm ts; + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 1); /* make sure table is at the top */ + ts.tm_sec = getfield(L, "sec", 0); + ts.tm_min = getfield(L, "min", 0); + ts.tm_hour = getfield(L, "hour", 12); + ts.tm_mday = getfield(L, "day", -1); + ts.tm_mon = getfield(L, "month", -1) - 1; + ts.tm_year = getfield(L, "year", -1) - 1900; + ts.tm_isdst = getboolfield(L, "isdst"); + t = mktime(&ts); + } + if (t == (time_t)(-1)) + lua_pushnil(L); + else + lua_pushnumber(L, (lua_Number)t); + return 1; +} + +LJLIB_CF(os_difftime) +{ + lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)), + (time_t)(luaL_optnumber(L, 2, (lua_Number)0)))); + return 1; +} + +/* ------------------------------------------------------------------------ */ + +LJLIB_CF(os_setlocale) +{ +#if LJ_TARGET_PSVITA + lua_pushliteral(L, "C"); +#else + GCstr *s = lj_lib_optstr(L, 1); + const char *str = s ? strdata(s) : NULL; + int opt = lj_lib_checkopt(L, 2, 6, + "\5ctype\7numeric\4time\7collate\10monetary\1\377\3all"); + if (opt == 0) opt = LC_CTYPE; + else if (opt == 1) opt = LC_NUMERIC; + else if (opt == 2) opt = LC_TIME; + else if (opt == 3) opt = LC_COLLATE; + else if (opt == 4) opt = LC_MONETARY; + else if (opt == 6) opt = LC_ALL; + lua_pushstring(L, setlocale(opt, str)); +#endif + return 1; +} + +/* ------------------------------------------------------------------------ */ + +#include "lj_libdef.h" + +LUALIB_API int luaopen_os(lua_State *L) +{ + LJ_LIB_REG(L, LUA_OSLIBNAME, os); + return 1; +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lib_package.c b/source/libs/luajit/LuaJIT-2.0.4/src/lib_package.c new file mode 100644 index 000000000..a668193b1 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lib_package.c @@ -0,0 +1,640 @@ +/* +** Package library. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2012 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lib_package_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_obj.h" +#include "lj_err.h" +#include "lj_lib.h" + +/* ------------------------------------------------------------------------ */ + +/* Error codes for ll_loadfunc. */ +#define PACKAGE_ERR_LIB 1 +#define PACKAGE_ERR_FUNC 2 +#define PACKAGE_ERR_LOAD 3 + +/* Redefined in platform specific part. */ +#define PACKAGE_LIB_FAIL "open" +#define setprogdir(L) ((void)0) + +/* Symbol name prefixes. */ +#define SYMPREFIX_CF "luaopen_%s" +#define SYMPREFIX_BC "luaJIT_BC_%s" + +#if LJ_TARGET_DLOPEN + +#include + +static void ll_unloadlib(void *lib) +{ + dlclose(lib); +} + +static void *ll_load(lua_State *L, const char *path, int gl) +{ + void *lib = dlopen(path, RTLD_NOW | (gl ? RTLD_GLOBAL : RTLD_LOCAL)); + if (lib == NULL) lua_pushstring(L, dlerror()); + return lib; +} + +static lua_CFunction ll_sym(lua_State *L, void *lib, const char *sym) +{ + lua_CFunction f = (lua_CFunction)dlsym(lib, sym); + if (f == NULL) lua_pushstring(L, dlerror()); + return f; +} + +static const char *ll_bcsym(void *lib, const char *sym) +{ +#if defined(RTLD_DEFAULT) + if (lib == NULL) lib = RTLD_DEFAULT; +#elif LJ_TARGET_OSX || LJ_TARGET_BSD + if (lib == NULL) lib = (void *)(intptr_t)-2; +#endif + return (const char *)dlsym(lib, sym); +} + +#elif LJ_TARGET_WINDOWS + +#define WIN32_LEAN_AND_MEAN +#include + +#ifndef GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS +#define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 4 +#define GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT 2 +BOOL WINAPI GetModuleHandleExA(DWORD, LPCSTR, HMODULE*); +#endif + +#undef setprogdir + +static void setprogdir(lua_State *L) +{ + char buff[MAX_PATH + 1]; + char *lb; + DWORD nsize = sizeof(buff); + DWORD n = GetModuleFileNameA(NULL, buff, nsize); + if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) { + luaL_error(L, "unable to get ModuleFileName"); + } else { + *lb = '\0'; + luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff); + lua_remove(L, -2); /* remove original string */ + } +} + +static void pusherror(lua_State *L) +{ + DWORD error = GetLastError(); + char buffer[128]; + if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, error, 0, buffer, sizeof(buffer), NULL)) + lua_pushstring(L, buffer); + else + lua_pushfstring(L, "system error %d\n", error); +} + +static void ll_unloadlib(void *lib) +{ + FreeLibrary((HINSTANCE)lib); +} + +static void *ll_load(lua_State *L, const char *path, int gl) +{ + HINSTANCE lib = LoadLibraryA(path); + if (lib == NULL) pusherror(L); + UNUSED(gl); + return lib; +} + +static lua_CFunction ll_sym(lua_State *L, void *lib, const char *sym) +{ + lua_CFunction f = (lua_CFunction)GetProcAddress((HINSTANCE)lib, sym); + if (f == NULL) pusherror(L); + return f; +} + +static const char *ll_bcsym(void *lib, const char *sym) +{ + if (lib) { + return (const char *)GetProcAddress((HINSTANCE)lib, sym); + } else { + HINSTANCE h = GetModuleHandleA(NULL); + const char *p = (const char *)GetProcAddress(h, sym); + if (p == NULL && GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + (const char *)ll_bcsym, &h)) + p = (const char *)GetProcAddress(h, sym); + return p; + } +} + +#else + +#undef PACKAGE_LIB_FAIL +#define PACKAGE_LIB_FAIL "absent" + +#define DLMSG "dynamic libraries not enabled; no support for target OS" + +static void ll_unloadlib(void *lib) +{ + UNUSED(lib); +} + +static void *ll_load(lua_State *L, const char *path, int gl) +{ + UNUSED(path); UNUSED(gl); + lua_pushliteral(L, DLMSG); + return NULL; +} + +static lua_CFunction ll_sym(lua_State *L, void *lib, const char *sym) +{ + UNUSED(lib); UNUSED(sym); + lua_pushliteral(L, DLMSG); + return NULL; +} + +static const char *ll_bcsym(void *lib, const char *sym) +{ + UNUSED(lib); UNUSED(sym); + return NULL; +} + +#endif + +/* ------------------------------------------------------------------------ */ + +static void **ll_register(lua_State *L, const char *path) +{ + void **plib; + lua_pushfstring(L, "LOADLIB: %s", path); + lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */ + if (!lua_isnil(L, -1)) { /* is there an entry? */ + plib = (void **)lua_touserdata(L, -1); + } else { /* no entry yet; create one */ + lua_pop(L, 1); + plib = (void **)lua_newuserdata(L, sizeof(void *)); + *plib = NULL; + luaL_getmetatable(L, "_LOADLIB"); + lua_setmetatable(L, -2); + lua_pushfstring(L, "LOADLIB: %s", path); + lua_pushvalue(L, -2); + lua_settable(L, LUA_REGISTRYINDEX); + } + return plib; +} + +static const char *mksymname(lua_State *L, const char *modname, + const char *prefix) +{ + const char *funcname; + const char *mark = strchr(modname, *LUA_IGMARK); + if (mark) modname = mark + 1; + funcname = luaL_gsub(L, modname, ".", "_"); + funcname = lua_pushfstring(L, prefix, funcname); + lua_remove(L, -2); /* remove 'gsub' result */ + return funcname; +} + +static int ll_loadfunc(lua_State *L, const char *path, const char *name, int r) +{ + void **reg = ll_register(L, path); + if (*reg == NULL) *reg = ll_load(L, path, (*name == '*')); + if (*reg == NULL) { + return PACKAGE_ERR_LIB; /* Unable to load library. */ + } else if (*name == '*') { /* Only load library into global namespace. */ + lua_pushboolean(L, 1); + return 0; + } else { + const char *sym = r ? name : mksymname(L, name, SYMPREFIX_CF); + lua_CFunction f = ll_sym(L, *reg, sym); + if (f) { + lua_pushcfunction(L, f); + return 0; + } + if (!r) { + const char *bcdata = ll_bcsym(*reg, mksymname(L, name, SYMPREFIX_BC)); + lua_pop(L, 1); + if (bcdata) { + if (luaL_loadbuffer(L, bcdata, ~(size_t)0, name) != 0) + return PACKAGE_ERR_LOAD; + return 0; + } + } + return PACKAGE_ERR_FUNC; /* Unable to find function. */ + } +} + +static int lj_cf_package_loadlib(lua_State *L) +{ + const char *path = luaL_checkstring(L, 1); + const char *init = luaL_checkstring(L, 2); + int st = ll_loadfunc(L, path, init, 1); + if (st == 0) { /* no errors? */ + return 1; /* return the loaded function */ + } else { /* error; error message is on stack top */ + lua_pushnil(L); + lua_insert(L, -2); + lua_pushstring(L, (st == PACKAGE_ERR_LIB) ? PACKAGE_LIB_FAIL : "init"); + return 3; /* return nil, error message, and where */ + } +} + +static int lj_cf_package_unloadlib(lua_State *L) +{ + void **lib = (void **)luaL_checkudata(L, 1, "_LOADLIB"); + if (*lib) ll_unloadlib(*lib); + *lib = NULL; /* mark library as closed */ + return 0; +} + +/* ------------------------------------------------------------------------ */ + +static int readable(const char *filename) +{ + FILE *f = fopen(filename, "r"); /* try to open file */ + if (f == NULL) return 0; /* open failed */ + fclose(f); + return 1; +} + +static const char *pushnexttemplate(lua_State *L, const char *path) +{ + const char *l; + while (*path == *LUA_PATHSEP) path++; /* skip separators */ + if (*path == '\0') return NULL; /* no more templates */ + l = strchr(path, *LUA_PATHSEP); /* find next separator */ + if (l == NULL) l = path + strlen(path); + lua_pushlstring(L, path, (size_t)(l - path)); /* template */ + return l; +} + +static const char *searchpath (lua_State *L, const char *name, + const char *path, const char *sep, + const char *dirsep) +{ + luaL_Buffer msg; /* to build error message */ + luaL_buffinit(L, &msg); + if (*sep != '\0') /* non-empty separator? */ + name = luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */ + while ((path = pushnexttemplate(L, path)) != NULL) { + const char *filename = luaL_gsub(L, lua_tostring(L, -1), + LUA_PATH_MARK, name); + lua_remove(L, -2); /* remove path template */ + if (readable(filename)) /* does file exist and is readable? */ + return filename; /* return that file name */ + lua_pushfstring(L, "\n\tno file " LUA_QS, filename); + lua_remove(L, -2); /* remove file name */ + luaL_addvalue(&msg); /* concatenate error msg. entry */ + } + luaL_pushresult(&msg); /* create error message */ + return NULL; /* not found */ +} + +static int lj_cf_package_searchpath(lua_State *L) +{ + const char *f = searchpath(L, luaL_checkstring(L, 1), + luaL_checkstring(L, 2), + luaL_optstring(L, 3, "."), + luaL_optstring(L, 4, LUA_DIRSEP)); + if (f != NULL) { + return 1; + } else { /* error message is on top of the stack */ + lua_pushnil(L); + lua_insert(L, -2); + return 2; /* return nil + error message */ + } +} + +static const char *findfile(lua_State *L, const char *name, + const char *pname) +{ + const char *path; + lua_getfield(L, LUA_ENVIRONINDEX, pname); + path = lua_tostring(L, -1); + if (path == NULL) + luaL_error(L, LUA_QL("package.%s") " must be a string", pname); + return searchpath(L, name, path, ".", LUA_DIRSEP); +} + +static void loaderror(lua_State *L, const char *filename) +{ + luaL_error(L, "error loading module " LUA_QS " from file " LUA_QS ":\n\t%s", + lua_tostring(L, 1), filename, lua_tostring(L, -1)); +} + +static int lj_cf_package_loader_lua(lua_State *L) +{ + const char *filename; + const char *name = luaL_checkstring(L, 1); + filename = findfile(L, name, "path"); + if (filename == NULL) return 1; /* library not found in this path */ + if (luaL_loadfile(L, filename) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + +static int lj_cf_package_loader_c(lua_State *L) +{ + const char *name = luaL_checkstring(L, 1); + const char *filename = findfile(L, name, "cpath"); + if (filename == NULL) return 1; /* library not found in this path */ + if (ll_loadfunc(L, filename, name, 0) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + +#define LUA_POF "luaopen_" +#define LUA_OFSEP "_" +#define POF LUA_POF + +static const char *mkfuncname (lua_State *L, const char *modname) { + const char *funcname; + const char *mark = strchr(modname, *LUA_IGMARK); + if (mark) modname = mark + 1; + funcname = luaL_gsub(L, modname, ".", LUA_OFSEP); + funcname = lua_pushfstring(L, POF"%s", funcname); + lua_remove(L, -2); /* remove 'gsub' result */ + return funcname; +} + + +int loader_C_luatex (lua_State *L, const char *name, const char *filename) { + const char *funcname; + funcname = mkfuncname(L, name); + if (ll_loadfunc(L, filename, funcname,0) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + +static int lj_cf_package_loader_croot(lua_State *L) +{ + const char *filename; + const char *name = luaL_checkstring(L, 1); + const char *p = strchr(name, '.'); + int st; + if (p == NULL) return 0; /* is root */ + lua_pushlstring(L, name, (size_t)(p - name)); + filename = findfile(L, lua_tostring(L, -1), "cpath"); + if (filename == NULL) return 1; /* root not found */ + if ((st = ll_loadfunc(L, filename, name, 0)) != 0) { + if (st != PACKAGE_ERR_FUNC) loaderror(L, filename); /* real error */ + lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, + name, filename); + return 1; /* function not found */ + } + return 1; +} + +int loader_Call_luatex (lua_State *L, const char *name, const char *filename) { + const char *funcname; + int stat; + if (filename == NULL) return 1; /* root not found */ + funcname = mkfuncname(L, name); + if ((stat = ll_loadfunc(L, filename, funcname,0)) != 0) { + if (stat != PACKAGE_ERR_FUNC) loaderror(L, filename); /* real error */ + lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, + name, filename); + return 1; /* function not found */ + } + return 1; /* library loaded successfully */ +} + + +static int lj_cf_package_loader_preload(lua_State *L) +{ + const char *name = luaL_checkstring(L, 1); + lua_getfield(L, LUA_ENVIRONINDEX, "preload"); + if (!lua_istable(L, -1)) + luaL_error(L, LUA_QL("package.preload") " must be a table"); + lua_getfield(L, -1, name); + if (lua_isnil(L, -1)) { /* Not found? */ + const char *bcname = mksymname(L, name, SYMPREFIX_BC); + const char *bcdata = ll_bcsym(NULL, bcname); + if (bcdata == NULL || luaL_loadbuffer(L, bcdata, ~(size_t)0, name) != 0) + lua_pushfstring(L, "\n\tno field package.preload['%s']", name); + } + return 1; +} + +/* ------------------------------------------------------------------------ */ + +static const int sentinel_ = 0; +#define sentinel ((void *)&sentinel_) + +static int lj_cf_package_require(lua_State *L) +{ + const char *name = luaL_checkstring(L, 1); + int i; + lua_settop(L, 1); /* _LOADED table will be at index 2 */ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, 2, name); + if (lua_toboolean(L, -1)) { /* is it there? */ + if (lua_touserdata(L, -1) == sentinel) /* check loops */ + luaL_error(L, "loop or previous error loading module " LUA_QS, name); + return 1; /* package is already loaded */ + } + /* else must load it; iterate over available loaders */ + lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); + if (!lua_istable(L, -1)) + luaL_error(L, LUA_QL("package.loaders") " must be a table"); + lua_pushliteral(L, ""); /* error message accumulator */ + for (i = 1; ; i++) { + lua_rawgeti(L, -2, i); /* get a loader */ + if (lua_isnil(L, -1)) + luaL_error(L, "module " LUA_QS " not found:%s", + name, lua_tostring(L, -2)); + lua_pushstring(L, name); + lua_call(L, 1, 1); /* call it */ + if (lua_isfunction(L, -1)) /* did it find module? */ + break; /* module loaded successfully */ + else if (lua_isstring(L, -1)) /* loader returned error message? */ + lua_concat(L, 2); /* accumulate it */ + else + lua_pop(L, 1); + } + lua_pushlightuserdata(L, sentinel); + lua_setfield(L, 2, name); /* _LOADED[name] = sentinel */ + lua_pushstring(L, name); /* pass name as argument to module */ + lua_call(L, 1, 1); /* run loaded module */ + if (!lua_isnil(L, -1)) /* non-nil return? */ + lua_setfield(L, 2, name); /* _LOADED[name] = returned value */ + lua_getfield(L, 2, name); + if (lua_touserdata(L, -1) == sentinel) { /* module did not set a value? */ + lua_pushboolean(L, 1); /* use true as result */ + lua_pushvalue(L, -1); /* extra copy to be returned */ + lua_setfield(L, 2, name); /* _LOADED[name] = true */ + } + lj_lib_checkfpu(L); + return 1; +} + +/* ------------------------------------------------------------------------ */ + +static void setfenv(lua_State *L) +{ + lua_Debug ar; + if (lua_getstack(L, 1, &ar) == 0 || + lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ + lua_iscfunction(L, -1)) + luaL_error(L, LUA_QL("module") " not called from a Lua function"); + lua_pushvalue(L, -2); + lua_setfenv(L, -2); + lua_pop(L, 1); +} + +static void dooptions(lua_State *L, int n) +{ + int i; + for (i = 2; i <= n; i++) { + lua_pushvalue(L, i); /* get option (a function) */ + lua_pushvalue(L, -2); /* module */ + lua_call(L, 1, 0); + } +} + +static void modinit(lua_State *L, const char *modname) +{ + const char *dot; + lua_pushvalue(L, -1); + lua_setfield(L, -2, "_M"); /* module._M = module */ + lua_pushstring(L, modname); + lua_setfield(L, -2, "_NAME"); + dot = strrchr(modname, '.'); /* look for last dot in module name */ + if (dot == NULL) dot = modname; else dot++; + /* set _PACKAGE as package name (full module name minus last part) */ + lua_pushlstring(L, modname, (size_t)(dot - modname)); + lua_setfield(L, -2, "_PACKAGE"); +} + +static int lj_cf_package_module(lua_State *L) +{ + const char *modname = luaL_checkstring(L, 1); + int loaded = lua_gettop(L) + 1; /* index of _LOADED table */ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, loaded, modname); /* get _LOADED[modname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, 1) != NULL) + lj_err_callerv(L, LJ_ERR_BADMODN, modname); + lua_pushvalue(L, -1); + lua_setfield(L, loaded, modname); /* _LOADED[modname] = new table */ + } + /* check whether table already has a _NAME field */ + lua_getfield(L, -1, "_NAME"); + if (!lua_isnil(L, -1)) { /* is table an initialized module? */ + lua_pop(L, 1); + } else { /* no; initialize it */ + lua_pop(L, 1); + modinit(L, modname); + } + lua_pushvalue(L, -1); + setfenv(L); + dooptions(L, loaded - 1); + return 0; +} + +static int lj_cf_package_seeall(lua_State *L) +{ + luaL_checktype(L, 1, LUA_TTABLE); + if (!lua_getmetatable(L, 1)) { + lua_createtable(L, 0, 1); /* create new metatable */ + lua_pushvalue(L, -1); + lua_setmetatable(L, 1); + } + lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_setfield(L, -2, "__index"); /* mt.__index = _G */ + return 0; +} + +/* ------------------------------------------------------------------------ */ + +#define AUXMARK "\1" + +static void setpath(lua_State *L, const char *fieldname, const char *envname, + const char *def, int noenv) +{ +#if LJ_TARGET_CONSOLE + const char *path = NULL; + UNUSED(envname); +#else + const char *path = getenv(envname); +#endif + if (path == NULL || noenv) { + lua_pushstring(L, def); + } else { + path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP, + LUA_PATHSEP AUXMARK LUA_PATHSEP); + luaL_gsub(L, path, AUXMARK, def); + lua_remove(L, -2); + } + setprogdir(L); + lua_setfield(L, -2, fieldname); +} + +static const luaL_Reg package_lib[] = { + { "loadlib", lj_cf_package_loadlib }, + { "searchpath", lj_cf_package_searchpath }, + { "seeall", lj_cf_package_seeall }, + { NULL, NULL } +}; + +static const luaL_Reg package_global[] = { + { "module", lj_cf_package_module }, + { "require", lj_cf_package_require }, + { NULL, NULL } +}; + +static const lua_CFunction package_loaders[] = +{ + lj_cf_package_loader_preload, + lj_cf_package_loader_lua, + lj_cf_package_loader_c, + lj_cf_package_loader_croot, + NULL +}; + +LUALIB_API int luaopen_package(lua_State *L) +{ + int i; + int noenv; + luaL_newmetatable(L, "_LOADLIB"); + lj_lib_pushcf(L, lj_cf_package_unloadlib, 1); + lua_setfield(L, -2, "__gc"); + luaL_register(L, LUA_LOADLIBNAME, package_lib); + lua_pushvalue(L, -1); + lua_replace(L, LUA_ENVIRONINDEX); + lua_createtable(L, sizeof(package_loaders)/sizeof(package_loaders[0])-1, 0); + for (i = 0; package_loaders[i] != NULL; i++) { + lj_lib_pushcf(L, package_loaders[i], 1); + lua_rawseti(L, -2, i+1); + } + lua_setfield(L, -2, "loaders"); + lua_getfield(L, LUA_REGISTRYINDEX, "LUA_NOENV"); + noenv = lua_toboolean(L, -1); + lua_pop(L, 1); + setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT, noenv); + setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT, noenv); + lua_pushliteral(L, LUA_PATH_CONFIG); + lua_setfield(L, -2, "config"); + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 16); + lua_setfield(L, -2, "loaded"); + luaL_findtable(L, LUA_REGISTRYINDEX, "_PRELOAD", 4); + lua_setfield(L, -2, "preload"); + lua_pushvalue(L, LUA_GLOBALSINDEX); + luaL_register(L, NULL, package_global); + lua_pop(L, 1); + return 1; +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lib_string.c b/source/libs/luajit/LuaJIT-2.0.4/src/lib_string.c new file mode 100644 index 000000000..c6168edbb --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lib_string.c @@ -0,0 +1,940 @@ +/* +** String library. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#include + +#define lib_string_c +#define LUA_LIB + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_meta.h" +#include "lj_state.h" +#include "lj_ff.h" +#include "lj_bcdump.h" +#include "lj_char.h" +#include "lj_lib.h" + +/* ------------------------------------------------------------------------ */ + +#define LJLIB_MODULE_string + +LJLIB_ASM(string_len) LJLIB_REC(.) +{ + lj_lib_checkstr(L, 1); + return FFH_RETRY; +} + +LJLIB_ASM(string_byte) LJLIB_REC(string_range 0) +{ + GCstr *s = lj_lib_checkstr(L, 1); + int32_t len = (int32_t)s->len; + int32_t start = lj_lib_optint(L, 2, 1); + int32_t stop = lj_lib_optint(L, 3, start); + int32_t n, i; + const unsigned char *p; + if (stop < 0) stop += len+1; + if (start < 0) start += len+1; + if (start <= 0) start = 1; + if (stop > len) stop = len; + if (start > stop) return FFH_RES(0); /* Empty interval: return no results. */ + start--; + n = stop - start; + if ((uint32_t)n > LUAI_MAXCSTACK) + lj_err_caller(L, LJ_ERR_STRSLC); + lj_state_checkstack(L, (MSize)n); + p = (const unsigned char *)strdata(s) + start; + for (i = 0; i < n; i++) + setintV(L->base + i-1, p[i]); + return FFH_RES(n); +} + +LJLIB_ASM(string_char) +{ + int i, nargs = (int)(L->top - L->base); + char *buf = lj_str_needbuf(L, &G(L)->tmpbuf, (MSize)nargs); + for (i = 1; i <= nargs; i++) { + int32_t k = lj_lib_checkint(L, i); + if (!checku8(k)) + lj_err_arg(L, i, LJ_ERR_BADVAL); + buf[i-1] = (char)k; + } + setstrV(L, L->base-1, lj_str_new(L, buf, (size_t)nargs)); + return FFH_RES(1); +} + +LJLIB_ASM(string_sub) LJLIB_REC(string_range 1) +{ + lj_lib_checkstr(L, 1); + lj_lib_checkint(L, 2); + setintV(L->base+2, lj_lib_optint(L, 3, -1)); + return FFH_RETRY; +} + +LJLIB_ASM(string_rep) +{ + GCstr *s = lj_lib_checkstr(L, 1); + int32_t k = lj_lib_checkint(L, 2); + GCstr *sep = lj_lib_optstr(L, 3); + int32_t len = (int32_t)s->len; + global_State *g = G(L); + int64_t tlen; + const char *src; + char *buf; + if (k <= 0) { + empty: + setstrV(L, L->base-1, &g->strempty); + return FFH_RES(1); + } + if (sep) { + tlen = (int64_t)len + sep->len; + if (tlen > LJ_MAX_STR) + lj_err_caller(L, LJ_ERR_STROV); + tlen *= k; + if (tlen > LJ_MAX_STR) + lj_err_caller(L, LJ_ERR_STROV); + } else { + tlen = (int64_t)k * len; + if (tlen > LJ_MAX_STR) + lj_err_caller(L, LJ_ERR_STROV); + } + if (tlen == 0) goto empty; + buf = lj_str_needbuf(L, &g->tmpbuf, (MSize)tlen); + src = strdata(s); + if (sep) { + tlen -= sep->len; /* Ignore trailing separator. */ + if (k > 1) { /* Paste one string and one separator. */ + int32_t i; + i = 0; while (i < len) *buf++ = src[i++]; + src = strdata(sep); len = sep->len; + i = 0; while (i < len) *buf++ = src[i++]; + src = g->tmpbuf.buf; len += s->len; k--; /* Now copy that k-1 times. */ + } + } + do { + int32_t i = 0; + do { *buf++ = src[i++]; } while (i < len); + } while (--k > 0); + setstrV(L, L->base-1, lj_str_new(L, g->tmpbuf.buf, (size_t)tlen)); + return FFH_RES(1); +} + +LJLIB_ASM(string_reverse) +{ + GCstr *s = lj_lib_checkstr(L, 1); + lj_str_needbuf(L, &G(L)->tmpbuf, s->len); + return FFH_RETRY; +} +LJLIB_ASM_(string_lower) +LJLIB_ASM_(string_upper) + +/* ------------------------------------------------------------------------ */ + +static int writer_buf(lua_State *L, const void *p, size_t size, void *b) +{ + luaL_addlstring((luaL_Buffer *)b, (const char *)p, size); + UNUSED(L); + return 0; +} + +LJLIB_CF(string_dump) +{ + GCfunc *fn = lj_lib_checkfunc(L, 1); + int strip = L->base+1 < L->top && tvistruecond(L->base+1); + luaL_Buffer b; + L->top = L->base+1; + luaL_buffinit(L, &b); + if (!isluafunc(fn) || lj_bcwrite(L, funcproto(fn), writer_buf, &b, strip)) + lj_err_caller(L, LJ_ERR_STRDUMP); + luaL_pushresult(&b); + return 1; +} + +/* ------------------------------------------------------------------------ */ + +/* macro to `unsign' a character */ +#define uchar(c) ((unsigned char)(c)) + +#define CAP_UNFINISHED (-1) +#define CAP_POSITION (-2) + +typedef struct MatchState { + const char *src_init; /* init of source string */ + const char *src_end; /* end (`\0') of source string */ + lua_State *L; + int level; /* total number of captures (finished or unfinished) */ + int depth; + struct { + const char *init; + ptrdiff_t len; + } capture[LUA_MAXCAPTURES]; +} MatchState; + +#define L_ESC '%' +#define SPECIALS "^$*+?.([%-" + +static int check_capture(MatchState *ms, int l) +{ + l -= '1'; + if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED) + lj_err_caller(ms->L, LJ_ERR_STRCAPI); + return l; +} + +static int capture_to_close(MatchState *ms) +{ + int level = ms->level; + for (level--; level>=0; level--) + if (ms->capture[level].len == CAP_UNFINISHED) return level; + lj_err_caller(ms->L, LJ_ERR_STRPATC); + return 0; /* unreachable */ +} + +static const char *classend(MatchState *ms, const char *p) +{ + switch (*p++) { + case L_ESC: + if (*p == '\0') + lj_err_caller(ms->L, LJ_ERR_STRPATE); + return p+1; + case '[': + if (*p == '^') p++; + do { /* look for a `]' */ + if (*p == '\0') + lj_err_caller(ms->L, LJ_ERR_STRPATM); + if (*(p++) == L_ESC && *p != '\0') + p++; /* skip escapes (e.g. `%]') */ + } while (*p != ']'); + return p+1; + default: + return p; + } +} + +static const unsigned char match_class_map[32] = { + 0,LJ_CHAR_ALPHA,0,LJ_CHAR_CNTRL,LJ_CHAR_DIGIT,0,0,LJ_CHAR_GRAPH,0,0,0,0, + LJ_CHAR_LOWER,0,0,0,LJ_CHAR_PUNCT,0,0,LJ_CHAR_SPACE,0, + LJ_CHAR_UPPER,0,LJ_CHAR_ALNUM,LJ_CHAR_XDIGIT,0,0,0,0,0,0,0 +}; + +static int match_class(int c, int cl) +{ + if ((cl & 0xc0) == 0x40) { + int t = match_class_map[(cl&0x1f)]; + if (t) { + t = lj_char_isa(c, t); + return (cl & 0x20) ? t : !t; + } + if (cl == 'z') return c == 0; + if (cl == 'Z') return c != 0; + } + return (cl == c); +} + +static int matchbracketclass(int c, const char *p, const char *ec) +{ + int sig = 1; + if (*(p+1) == '^') { + sig = 0; + p++; /* skip the `^' */ + } + while (++p < ec) { + if (*p == L_ESC) { + p++; + if (match_class(c, uchar(*p))) + return sig; + } + else if ((*(p+1) == '-') && (p+2 < ec)) { + p+=2; + if (uchar(*(p-2)) <= c && c <= uchar(*p)) + return sig; + } + else if (uchar(*p) == c) return sig; + } + return !sig; +} + +static int singlematch(int c, const char *p, const char *ep) +{ + switch (*p) { + case '.': return 1; /* matches any char */ + case L_ESC: return match_class(c, uchar(*(p+1))); + case '[': return matchbracketclass(c, p, ep-1); + default: return (uchar(*p) == c); + } +} + +static const char *match(MatchState *ms, const char *s, const char *p); + +static const char *matchbalance(MatchState *ms, const char *s, const char *p) +{ + if (*p == 0 || *(p+1) == 0) + lj_err_caller(ms->L, LJ_ERR_STRPATU); + if (*s != *p) { + return NULL; + } else { + int b = *p; + int e = *(p+1); + int cont = 1; + while (++s < ms->src_end) { + if (*s == e) { + if (--cont == 0) return s+1; + } else if (*s == b) { + cont++; + } + } + } + return NULL; /* string ends out of balance */ +} + +static const char *max_expand(MatchState *ms, const char *s, + const char *p, const char *ep) +{ + ptrdiff_t i = 0; /* counts maximum expand for item */ + while ((s+i)src_end && singlematch(uchar(*(s+i)), p, ep)) + i++; + /* keeps trying to match with the maximum repetitions */ + while (i>=0) { + const char *res = match(ms, (s+i), ep+1); + if (res) return res; + i--; /* else didn't match; reduce 1 repetition to try again */ + } + return NULL; +} + +static const char *min_expand(MatchState *ms, const char *s, + const char *p, const char *ep) +{ + for (;;) { + const char *res = match(ms, s, ep+1); + if (res != NULL) + return res; + else if (ssrc_end && singlematch(uchar(*s), p, ep)) + s++; /* try with one more repetition */ + else + return NULL; + } +} + +static const char *start_capture(MatchState *ms, const char *s, + const char *p, int what) +{ + const char *res; + int level = ms->level; + if (level >= LUA_MAXCAPTURES) lj_err_caller(ms->L, LJ_ERR_STRCAPN); + ms->capture[level].init = s; + ms->capture[level].len = what; + ms->level = level+1; + if ((res=match(ms, s, p)) == NULL) /* match failed? */ + ms->level--; /* undo capture */ + return res; +} + +static const char *end_capture(MatchState *ms, const char *s, + const char *p) +{ + int l = capture_to_close(ms); + const char *res; + ms->capture[l].len = s - ms->capture[l].init; /* close capture */ + if ((res = match(ms, s, p)) == NULL) /* match failed? */ + ms->capture[l].len = CAP_UNFINISHED; /* undo capture */ + return res; +} + +static const char *match_capture(MatchState *ms, const char *s, int l) +{ + size_t len; + l = check_capture(ms, l); + len = (size_t)ms->capture[l].len; + if ((size_t)(ms->src_end-s) >= len && + memcmp(ms->capture[l].init, s, len) == 0) + return s+len; + else + return NULL; +} + +static const char *match(MatchState *ms, const char *s, const char *p) +{ + if (++ms->depth > LJ_MAX_XLEVEL) + lj_err_caller(ms->L, LJ_ERR_STRPATX); + init: /* using goto's to optimize tail recursion */ + switch (*p) { + case '(': /* start capture */ + if (*(p+1) == ')') /* position capture? */ + s = start_capture(ms, s, p+2, CAP_POSITION); + else + s = start_capture(ms, s, p+1, CAP_UNFINISHED); + break; + case ')': /* end capture */ + s = end_capture(ms, s, p+1); + break; + case L_ESC: + switch (*(p+1)) { + case 'b': /* balanced string? */ + s = matchbalance(ms, s, p+2); + if (s == NULL) break; + p+=4; + goto init; /* else s = match(ms, s, p+4); */ + case 'f': { /* frontier? */ + const char *ep; char previous; + p += 2; + if (*p != '[') + lj_err_caller(ms->L, LJ_ERR_STRPATB); + ep = classend(ms, p); /* points to what is next */ + previous = (s == ms->src_init) ? '\0' : *(s-1); + if (matchbracketclass(uchar(previous), p, ep-1) || + !matchbracketclass(uchar(*s), p, ep-1)) { s = NULL; break; } + p=ep; + goto init; /* else s = match(ms, s, ep); */ + } + default: + if (lj_char_isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */ + s = match_capture(ms, s, uchar(*(p+1))); + if (s == NULL) break; + p+=2; + goto init; /* else s = match(ms, s, p+2) */ + } + goto dflt; /* case default */ + } + break; + case '\0': /* end of pattern */ + break; /* match succeeded */ + case '$': + /* is the `$' the last char in pattern? */ + if (*(p+1) != '\0') goto dflt; + if (s != ms->src_end) s = NULL; /* check end of string */ + break; + default: dflt: { /* it is a pattern item */ + const char *ep = classend(ms, p); /* points to what is next */ + int m = ssrc_end && singlematch(uchar(*s), p, ep); + switch (*ep) { + case '?': { /* optional */ + const char *res; + if (m && ((res=match(ms, s+1, ep+1)) != NULL)) { + s = res; + break; + } + p=ep+1; + goto init; /* else s = match(ms, s, ep+1); */ + } + case '*': /* 0 or more repetitions */ + s = max_expand(ms, s, p, ep); + break; + case '+': /* 1 or more repetitions */ + s = (m ? max_expand(ms, s+1, p, ep) : NULL); + break; + case '-': /* 0 or more repetitions (minimum) */ + s = min_expand(ms, s, p, ep); + break; + default: + if (m) { s++; p=ep; goto init; } /* else s = match(ms, s+1, ep); */ + s = NULL; + break; + } + break; + } + } + ms->depth--; + return s; +} + +static const char *lmemfind(const char *s1, size_t l1, + const char *s2, size_t l2) +{ + if (l2 == 0) { + return s1; /* empty strings are everywhere */ + } else if (l2 > l1) { + return NULL; /* avoids a negative `l1' */ + } else { + const char *init; /* to search for a `*s2' inside `s1' */ + l2--; /* 1st char will be checked by `memchr' */ + l1 = l1-l2; /* `s2' cannot be found after that */ + while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) { + init++; /* 1st char is already checked */ + if (memcmp(init, s2+1, l2) == 0) { + return init-1; + } else { /* correct `l1' and `s1' to try again */ + l1 -= (size_t)(init-s1); + s1 = init; + } + } + return NULL; /* not found */ + } +} + +static void push_onecapture(MatchState *ms, int i, const char *s, const char *e) +{ + if (i >= ms->level) { + if (i == 0) /* ms->level == 0, too */ + lua_pushlstring(ms->L, s, (size_t)(e - s)); /* add whole match */ + else + lj_err_caller(ms->L, LJ_ERR_STRCAPI); + } else { + ptrdiff_t l = ms->capture[i].len; + if (l == CAP_UNFINISHED) lj_err_caller(ms->L, LJ_ERR_STRCAPU); + if (l == CAP_POSITION) + lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); + else + lua_pushlstring(ms->L, ms->capture[i].init, (size_t)l); + } +} + +static int push_captures(MatchState *ms, const char *s, const char *e) +{ + int i; + int nlevels = (ms->level == 0 && s) ? 1 : ms->level; + luaL_checkstack(ms->L, nlevels, "too many captures"); + for (i = 0; i < nlevels; i++) + push_onecapture(ms, i, s, e); + return nlevels; /* number of strings pushed */ +} + +static ptrdiff_t posrelat(ptrdiff_t pos, size_t len) +{ + /* relative string position: negative means back from end */ + if (pos < 0) pos += (ptrdiff_t)len + 1; + return (pos >= 0) ? pos : 0; +} + +static int str_find_aux(lua_State *L, int find) +{ + size_t l1, l2; + const char *s = luaL_checklstring(L, 1, &l1); + const char *p = luaL_checklstring(L, 2, &l2); + ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1; + if (init < 0) { + init = 0; + } else if ((size_t)(init) > l1) { +#if LJ_52 + setnilV(L->top-1); + return 1; +#else + init = (ptrdiff_t)l1; +#endif + } + if (find && (lua_toboolean(L, 4) || /* explicit request? */ + strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */ + /* do a plain search */ + const char *s2 = lmemfind(s+init, l1-(size_t)init, p, l2); + if (s2) { + lua_pushinteger(L, s2-s+1); + lua_pushinteger(L, s2-s+(ptrdiff_t)l2); + return 2; + } + } else { + MatchState ms; + int anchor = (*p == '^') ? (p++, 1) : 0; + const char *s1=s+init; + ms.L = L; + ms.src_init = s; + ms.src_end = s+l1; + do { + const char *res; + ms.level = ms.depth = 0; + if ((res=match(&ms, s1, p)) != NULL) { + if (find) { + lua_pushinteger(L, s1-s+1); /* start */ + lua_pushinteger(L, res-s); /* end */ + return push_captures(&ms, NULL, 0) + 2; + } else { + return push_captures(&ms, s1, res); + } + } + } while (s1++ < ms.src_end && !anchor); + } + lua_pushnil(L); /* not found */ + return 1; +} + +LJLIB_CF(string_find) +{ + return str_find_aux(L, 1); +} + +LJLIB_CF(string_match) +{ + return str_find_aux(L, 0); +} + +LJLIB_NOREG LJLIB_CF(string_gmatch_aux) +{ + const char *p = strVdata(lj_lib_upvalue(L, 2)); + GCstr *str = strV(lj_lib_upvalue(L, 1)); + const char *s = strdata(str); + TValue *tvpos = lj_lib_upvalue(L, 3); + const char *src = s + tvpos->u32.lo; + MatchState ms; + ms.L = L; + ms.src_init = s; + ms.src_end = s + str->len; + for (; src <= ms.src_end; src++) { + const char *e; + ms.level = ms.depth = 0; + if ((e = match(&ms, src, p)) != NULL) { + int32_t pos = (int32_t)(e - s); + if (e == src) pos++; /* Ensure progress for empty match. */ + tvpos->u32.lo = (uint32_t)pos; + return push_captures(&ms, src, e); + } + } + return 0; /* not found */ +} + +LJLIB_CF(string_gmatch) +{ + lj_lib_checkstr(L, 1); + lj_lib_checkstr(L, 2); + L->top = L->base+3; + (L->top-1)->u64 = 0; + lj_lib_pushcc(L, lj_cf_string_gmatch_aux, FF_string_gmatch_aux, 3); + return 1; +} + +static void add_s(MatchState *ms, luaL_Buffer *b, const char *s, const char *e) +{ + size_t l, i; + const char *news = lua_tolstring(ms->L, 3, &l); + for (i = 0; i < l; i++) { + if (news[i] != L_ESC) { + luaL_addchar(b, news[i]); + } else { + i++; /* skip ESC */ + if (!lj_char_isdigit(uchar(news[i]))) { + luaL_addchar(b, news[i]); + } else if (news[i] == '0') { + luaL_addlstring(b, s, (size_t)(e - s)); + } else { + push_onecapture(ms, news[i] - '1', s, e); + luaL_addvalue(b); /* add capture to accumulated result */ + } + } + } +} + +static void add_value(MatchState *ms, luaL_Buffer *b, + const char *s, const char *e) +{ + lua_State *L = ms->L; + switch (lua_type(L, 3)) { + case LUA_TNUMBER: + case LUA_TSTRING: { + add_s(ms, b, s, e); + return; + } + case LUA_TFUNCTION: { + int n; + lua_pushvalue(L, 3); + n = push_captures(ms, s, e); + lua_call(L, n, 1); + break; + } + case LUA_TTABLE: { + push_onecapture(ms, 0, s, e); + lua_gettable(L, 3); + break; + } + } + if (!lua_toboolean(L, -1)) { /* nil or false? */ + lua_pop(L, 1); + lua_pushlstring(L, s, (size_t)(e - s)); /* keep original text */ + } else if (!lua_isstring(L, -1)) { + lj_err_callerv(L, LJ_ERR_STRGSRV, luaL_typename(L, -1)); + } + luaL_addvalue(b); /* add result to accumulator */ +} + +LJLIB_CF(string_gsub) +{ + size_t srcl; + const char *src = luaL_checklstring(L, 1, &srcl); + const char *p = luaL_checkstring(L, 2); + int tr = lua_type(L, 3); + int max_s = luaL_optint(L, 4, (int)(srcl+1)); + int anchor = (*p == '^') ? (p++, 1) : 0; + int n = 0; + MatchState ms; + luaL_Buffer b; + if (!(tr == LUA_TNUMBER || tr == LUA_TSTRING || + tr == LUA_TFUNCTION || tr == LUA_TTABLE)) + lj_err_arg(L, 3, LJ_ERR_NOSFT); + luaL_buffinit(L, &b); + ms.L = L; + ms.src_init = src; + ms.src_end = src+srcl; + while (n < max_s) { + const char *e; + ms.level = ms.depth = 0; + e = match(&ms, src, p); + if (e) { + n++; + add_value(&ms, &b, src, e); + } + if (e && e>src) /* non empty match? */ + src = e; /* skip it */ + else if (src < ms.src_end) + luaL_addchar(&b, *src++); + else + break; + if (anchor) + break; + } + luaL_addlstring(&b, src, (size_t)(ms.src_end-src)); + luaL_pushresult(&b); + lua_pushinteger(L, n); /* number of substitutions */ + return 2; +} + +/* ------------------------------------------------------------------------ */ + +/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */ +#define MAX_FMTITEM 512 +/* valid flags in a format specification */ +#define FMT_FLAGS "-+ #0" +/* +** maximum size of each format specification (such as '%-099.99d') +** (+10 accounts for %99.99x plus margin of error) +*/ +#define MAX_FMTSPEC (sizeof(FMT_FLAGS) + sizeof(LUA_INTFRMLEN) + 10) + +static void addquoted(lua_State *L, luaL_Buffer *b, int arg) +{ + GCstr *str = lj_lib_checkstr(L, arg); + int32_t len = (int32_t)str->len; + const char *s = strdata(str); + luaL_addchar(b, '"'); + while (len--) { + uint32_t c = uchar(*s); + if (c == '"' || c == '\\' || c == '\n') { + luaL_addchar(b, '\\'); + } else if (lj_char_iscntrl(c)) { /* This can only be 0-31 or 127. */ + uint32_t d; + luaL_addchar(b, '\\'); + if (c >= 100 || lj_char_isdigit(uchar(s[1]))) { + luaL_addchar(b, '0'+(c >= 100)); if (c >= 100) c -= 100; + goto tens; + } else if (c >= 10) { + tens: + d = (c * 205) >> 11; c -= d * 10; luaL_addchar(b, '0'+d); + } + c += '0'; + } + luaL_addchar(b, c); + s++; + } + luaL_addchar(b, '"'); +} + +static const char *scanformat(lua_State *L, const char *strfrmt, char *form) +{ + const char *p = strfrmt; + while (*p != '\0' && strchr(FMT_FLAGS, *p) != NULL) p++; /* skip flags */ + if ((size_t)(p - strfrmt) >= sizeof(FMT_FLAGS)) + lj_err_caller(L, LJ_ERR_STRFMTR); + if (lj_char_isdigit(uchar(*p))) p++; /* skip width */ + if (lj_char_isdigit(uchar(*p))) p++; /* (2 digits at most) */ + if (*p == '.') { + p++; + if (lj_char_isdigit(uchar(*p))) p++; /* skip precision */ + if (lj_char_isdigit(uchar(*p))) p++; /* (2 digits at most) */ + } + if (lj_char_isdigit(uchar(*p))) + lj_err_caller(L, LJ_ERR_STRFMTW); + *(form++) = '%'; + strncpy(form, strfrmt, (size_t)(p - strfrmt + 1)); + form += p - strfrmt + 1; + *form = '\0'; + return p; +} + +static void addintlen(char *form) +{ + size_t l = strlen(form); + char spec = form[l - 1]; + strcpy(form + l - 1, LUA_INTFRMLEN); + form[l + sizeof(LUA_INTFRMLEN) - 2] = spec; + form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0'; +} + +static unsigned LUA_INTFRM_T num2intfrm(lua_State *L, int arg) +{ + if (sizeof(LUA_INTFRM_T) == 4) { + return (LUA_INTFRM_T)lj_lib_checkbit(L, arg); + } else { + cTValue *o; + lj_lib_checknumber(L, arg); + o = L->base+arg-1; + if (tvisint(o)) + return (LUA_INTFRM_T)intV(o); + else + return (LUA_INTFRM_T)numV(o); + } +} + +static unsigned LUA_INTFRM_T num2uintfrm(lua_State *L, int arg) +{ + if (sizeof(LUA_INTFRM_T) == 4) { + return (unsigned LUA_INTFRM_T)lj_lib_checkbit(L, arg); + } else { + cTValue *o; + lj_lib_checknumber(L, arg); + o = L->base+arg-1; + if (tvisint(o)) + return (unsigned LUA_INTFRM_T)intV(o); + else if ((int32_t)o->u32.hi < 0) + return (unsigned LUA_INTFRM_T)(LUA_INTFRM_T)numV(o); + else + return (unsigned LUA_INTFRM_T)numV(o); + } +} + +static GCstr *meta_tostring(lua_State *L, int arg) +{ + TValue *o = L->base+arg-1; + cTValue *mo; + lua_assert(o < L->top); /* Caller already checks for existence. */ + if (LJ_LIKELY(tvisstr(o))) + return strV(o); + if (!tvisnil(mo = lj_meta_lookup(L, o, MM_tostring))) { + copyTV(L, L->top++, mo); + copyTV(L, L->top++, o); + lua_call(L, 1, 1); + L->top--; + if (tvisstr(L->top)) + return strV(L->top); + o = L->base+arg-1; + copyTV(L, o, L->top); + } + if (tvisnumber(o)) { + return lj_str_fromnumber(L, o); + } else if (tvisnil(o)) { + return lj_str_newlit(L, "nil"); + } else if (tvisfalse(o)) { + return lj_str_newlit(L, "false"); + } else if (tvistrue(o)) { + return lj_str_newlit(L, "true"); + } else { + if (tvisfunc(o) && isffunc(funcV(o))) + lj_str_pushf(L, "function: builtin#%d", funcV(o)->c.ffid); + else + lj_str_pushf(L, "%s: %p", lj_typename(o), lua_topointer(L, arg)); + L->top--; + return strV(L->top); + } +} + +LJLIB_CF(string_format) +{ + int arg = 1, top = (int)(L->top - L->base); + GCstr *fmt = lj_lib_checkstr(L, arg); + const char *strfrmt = strdata(fmt); + const char *strfrmt_end = strfrmt + fmt->len; + luaL_Buffer b; + luaL_buffinit(L, &b); + while (strfrmt < strfrmt_end) { + if (*strfrmt != L_ESC) { + luaL_addchar(&b, *strfrmt++); + } else if (*++strfrmt == L_ESC) { + luaL_addchar(&b, *strfrmt++); /* %% */ + } else { /* format item */ + char form[MAX_FMTSPEC]; /* to store the format (`%...') */ + char buff[MAX_FMTITEM]; /* to store the formatted item */ + if (++arg > top) + luaL_argerror(L, arg, lj_obj_typename[0]); + strfrmt = scanformat(L, strfrmt, form); + switch (*strfrmt++) { + case 'c': + sprintf(buff, form, lj_lib_checkint(L, arg)); + break; + case 'd': case 'i': + addintlen(form); + sprintf(buff, form, num2intfrm(L, arg)); + break; + case 'o': case 'u': case 'x': case 'X': + addintlen(form); + sprintf(buff, form, num2uintfrm(L, arg)); + break; + case 'e': case 'E': case 'f': case 'g': case 'G': case 'a': case 'A': { + TValue tv; + tv.n = lj_lib_checknum(L, arg); + if (LJ_UNLIKELY((tv.u32.hi << 1) >= 0xffe00000)) { + /* Canonicalize output of non-finite values. */ + char *p, nbuf[LJ_STR_NUMBUF]; + size_t len = lj_str_bufnum(nbuf, &tv); + if (strfrmt[-1] < 'a') { + nbuf[len-3] = nbuf[len-3] - 0x20; + nbuf[len-2] = nbuf[len-2] - 0x20; + nbuf[len-1] = nbuf[len-1] - 0x20; + } + nbuf[len] = '\0'; + for (p = form; *p < 'A' && *p != '.'; p++) ; + *p++ = 's'; *p = '\0'; + sprintf(buff, form, nbuf); + break; + } + sprintf(buff, form, (double)tv.n); + break; + } + case 'q': + addquoted(L, &b, arg); + continue; + case 'p': + lj_str_pushf(L, "%p", lua_topointer(L, arg)); + luaL_addvalue(&b); + continue; + case 's': { + GCstr *str = meta_tostring(L, arg); + if (!strchr(form, '.') && str->len >= 100) { + /* no precision and string is too long to be formatted; + keep original string */ + setstrV(L, L->top++, str); + luaL_addvalue(&b); + continue; + } + sprintf(buff, form, strdata(str)); + break; + } + default: + lj_err_callerv(L, LJ_ERR_STRFMTO, *(strfrmt -1)); + break; + } + luaL_addlstring(&b, buff, strlen(buff)); + } + } + luaL_pushresult(&b); + return 1; +} + +/* ------------------------------------------------------------------------ */ + +#include "lj_libdef.h" + +LUALIB_API int luaopen_string(lua_State *L) +{ + GCtab *mt; + global_State *g; + LJ_LIB_REG(L, LUA_STRLIBNAME, string); +#if defined(LUA_COMPAT_GFIND) && !LJ_52 + lua_getfield(L, -1, "gmatch"); + lua_setfield(L, -2, "gfind"); +#endif + mt = lj_tab_new(L, 0, 1); + /* NOBARRIER: basemt is a GC root. */ + g = G(L); + setgcref(basemt_it(g, LJ_TSTR), obj2gco(mt)); + settabV(L, lj_tab_setstr(L, mt, mmname_str(g, MM_index)), tabV(L->top-1)); + mt->nomm = (uint8_t)(~(1u<top, func); + setintV(L->top+1, i); + val = lj_tab_getint(t, (int32_t)i); + if (val) { copyTV(L, L->top+2, val); } else { setnilV(L->top+2); } + L->top += 3; + lua_call(L, 2, 1); + if (!tvisnil(L->top-1)) + return 1; + L->top--; + } + return 0; +} + +LJLIB_CF(table_foreach) +{ + GCtab *t = lj_lib_checktab(L, 1); + GCfunc *func = lj_lib_checkfunc(L, 2); + L->top = L->base+3; + setnilV(L->top-1); + while (lj_tab_next(L, t, L->top-1)) { + copyTV(L, L->top+2, L->top); + copyTV(L, L->top+1, L->top-1); + setfuncV(L, L->top, func); + L->top += 3; + lua_call(L, 2, 1); + if (!tvisnil(L->top-1)) + return 1; + L->top--; + } + return 0; +} + +LJLIB_ASM(table_getn) LJLIB_REC(.) +{ + lj_lib_checktab(L, 1); + return FFH_UNREACHABLE; +} + +LJLIB_CF(table_maxn) +{ + GCtab *t = lj_lib_checktab(L, 1); + TValue *array = tvref(t->array); + Node *node; + lua_Number m = 0; + ptrdiff_t i; + for (i = (ptrdiff_t)t->asize - 1; i >= 0; i--) + if (!tvisnil(&array[i])) { + m = (lua_Number)(int32_t)i; + break; + } + node = noderef(t->node); + for (i = (ptrdiff_t)t->hmask; i >= 0; i--) + if (!tvisnil(&node[i].val) && tvisnumber(&node[i].key)) { + lua_Number n = numberVnum(&node[i].key); + if (n > m) m = n; + } + setnumV(L->top-1, m); + return 1; +} + +LJLIB_CF(table_insert) LJLIB_REC(.) +{ + GCtab *t = lj_lib_checktab(L, 1); + int32_t n, i = (int32_t)lj_tab_len(t) + 1; + int nargs = (int)((char *)L->top - (char *)L->base); + if (nargs != 2*sizeof(TValue)) { + if (nargs != 3*sizeof(TValue)) + lj_err_caller(L, LJ_ERR_TABINS); + /* NOBARRIER: This just moves existing elements around. */ + for (n = lj_lib_checkint(L, 2); i > n; i--) { + /* The set may invalidate the get pointer, so need to do it first! */ + TValue *dst = lj_tab_setint(L, t, i); + cTValue *src = lj_tab_getint(t, i-1); + if (src) { + copyTV(L, dst, src); + } else { + setnilV(dst); + } + } + i = n; + } + { + TValue *dst = lj_tab_setint(L, t, i); + copyTV(L, dst, L->top-1); /* Set new value. */ + lj_gc_barriert(L, t, dst); + } + return 0; +} + +LJLIB_CF(table_remove) LJLIB_REC(.) +{ + GCtab *t = lj_lib_checktab(L, 1); + int32_t e = (int32_t)lj_tab_len(t); + int32_t pos = lj_lib_optint(L, 2, e); + if (!(1 <= pos && pos <= e)) /* Nothing to remove? */ + return 0; + lua_rawgeti(L, 1, pos); /* Get previous value. */ + /* NOBARRIER: This just moves existing elements around. */ + for (; pos < e; pos++) { + cTValue *src = lj_tab_getint(t, pos+1); + TValue *dst = lj_tab_setint(L, t, pos); + if (src) { + copyTV(L, dst, src); + } else { + setnilV(dst); + } + } + setnilV(lj_tab_setint(L, t, e)); /* Remove (last) value. */ + return 1; /* Return previous value. */ +} + +LJLIB_CF(table_concat) +{ + luaL_Buffer b; + GCtab *t = lj_lib_checktab(L, 1); + GCstr *sep = lj_lib_optstr(L, 2); + MSize seplen = sep ? sep->len : 0; + int32_t i = lj_lib_optint(L, 3, 1); + int32_t e = (L->base+3 < L->top && !tvisnil(L->base+3)) ? + lj_lib_checkint(L, 4) : (int32_t)lj_tab_len(t); + luaL_buffinit(L, &b); + if (i <= e) { + for (;;) { + cTValue *o; + lua_rawgeti(L, 1, i); + o = L->top-1; + if (!(tvisstr(o) || tvisnumber(o))) + lj_err_callerv(L, LJ_ERR_TABCAT, lj_typename(o), i); + luaL_addvalue(&b); + if (i++ == e) break; + if (seplen) + luaL_addlstring(&b, strdata(sep), seplen); + } + } + luaL_pushresult(&b); + return 1; +} + +/* ------------------------------------------------------------------------ */ + +static void set2(lua_State *L, int i, int j) +{ + lua_rawseti(L, 1, i); + lua_rawseti(L, 1, j); +} + +static int sort_comp(lua_State *L, int a, int b) +{ + if (!lua_isnil(L, 2)) { /* function? */ + int res; + lua_pushvalue(L, 2); + lua_pushvalue(L, a-1); /* -1 to compensate function */ + lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */ + lua_call(L, 2, 1); + res = lua_toboolean(L, -1); + lua_pop(L, 1); + return res; + } else { /* a < b? */ + return lua_lessthan(L, a, b); + } +} + +static void auxsort(lua_State *L, int l, int u) +{ + while (l < u) { /* for tail recursion */ + int i, j; + /* sort elements a[l], a[(l+u)/2] and a[u] */ + lua_rawgeti(L, 1, l); + lua_rawgeti(L, 1, u); + if (sort_comp(L, -1, -2)) /* a[u] < a[l]? */ + set2(L, l, u); /* swap a[l] - a[u] */ + else + lua_pop(L, 2); + if (u-l == 1) break; /* only 2 elements */ + i = (l+u)/2; + lua_rawgeti(L, 1, i); + lua_rawgeti(L, 1, l); + if (sort_comp(L, -2, -1)) { /* a[i]= P */ + while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { + if (i>=u) lj_err_caller(L, LJ_ERR_TABSORT); + lua_pop(L, 1); /* remove a[i] */ + } + /* repeat --j until a[j] <= P */ + while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { + if (j<=l) lj_err_caller(L, LJ_ERR_TABSORT); + lua_pop(L, 1); /* remove a[j] */ + } + if (jbase+1)) + lj_lib_checkfunc(L, 2); + auxsort(L, 1, n); + return 0; +} + +#if LJ_52 +LJLIB_PUSH("n") +LJLIB_CF(table_pack) +{ + TValue *array, *base = L->base; + MSize i, n = (uint32_t)(L->top - base); + GCtab *t = lj_tab_new(L, n ? n+1 : 0, 1); + /* NOBARRIER: The table is new (marked white). */ + setintV(lj_tab_setstr(L, t, strV(lj_lib_upvalue(L, 1))), (int32_t)n); + for (array = tvref(t->array) + 1, i = 0; i < n; i++) + copyTV(L, &array[i], &base[i]); + settabV(L, base, t); + L->top = base+1; + lj_gc_check(L); + return 1; +} +#endif + +/* ------------------------------------------------------------------------ */ + +#include "lj_libdef.h" + +LUALIB_API int luaopen_table(lua_State *L) +{ + LJ_LIB_REG(L, LUA_TABLIBNAME, table); +#if LJ_52 + lua_getglobal(L, "unpack"); + lua_setfield(L, -2, "unpack"); +#endif + return 1; +} + diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj.supp b/source/libs/luajit/LuaJIT-2.0.4/src/lj.supp similarity index 100% rename from source/libs/luajit/LuaJIT-2.0.3/src/lj.supp rename to source/libs/luajit/LuaJIT-2.0.4/src/lj.supp diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_alloc.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_alloc.c new file mode 100644 index 000000000..7c7ec6787 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_alloc.c @@ -0,0 +1,1396 @@ +/* +** Bundled memory allocator. +** +** Beware: this is a HEAVILY CUSTOMIZED version of dlmalloc. +** The original bears the following remark: +** +** This is a version (aka dlmalloc) of malloc/free/realloc written by +** Doug Lea and released to the public domain, as explained at +** http://creativecommons.org/licenses/publicdomain. +** +** * Version pre-2.8.4 Wed Mar 29 19:46:29 2006 (dl at gee) +** +** No additional copyright is claimed over the customizations. +** Please do NOT bother the original author about this version here! +** +** If you want to use dlmalloc in another project, you should get +** the original from: ftp://gee.cs.oswego.edu/pub/misc/ +** For thread-safe derivatives, take a look at: +** - ptmalloc: http://www.malloc.de/ +** - nedmalloc: http://www.nedprod.com/programs/portable/nedmalloc/ +*/ + +#define lj_alloc_c +#define LUA_CORE + +/* To get the mremap prototype. Must be defined before any system includes. */ +#if defined(__linux__) && !defined(_GNU_SOURCE) +#define _GNU_SOURCE +#endif + +#include "lj_def.h" +#include "lj_arch.h" +#include "lj_alloc.h" + +#ifndef LUAJIT_USE_SYSMALLOC + +#define MAX_SIZE_T (~(size_t)0) +#define MALLOC_ALIGNMENT ((size_t)8U) + +#define DEFAULT_GRANULARITY ((size_t)128U * (size_t)1024U) +#define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U) +#define DEFAULT_MMAP_THRESHOLD ((size_t)128U * (size_t)1024U) +#define MAX_RELEASE_CHECK_RATE 255 + +/* ------------------- size_t and alignment properties -------------------- */ + +/* The byte and bit size of a size_t */ +#define SIZE_T_SIZE (sizeof(size_t)) +#define SIZE_T_BITSIZE (sizeof(size_t) << 3) + +/* Some constants coerced to size_t */ +/* Annoying but necessary to avoid errors on some platforms */ +#define SIZE_T_ZERO ((size_t)0) +#define SIZE_T_ONE ((size_t)1) +#define SIZE_T_TWO ((size_t)2) +#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1) +#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2) +#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES) + +/* The bit mask value corresponding to MALLOC_ALIGNMENT */ +#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) + +/* the number of bytes to offset an address to align it */ +#define align_offset(A)\ + ((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\ + ((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK)) + +/* -------------------------- MMAP support ------------------------------- */ + +#define MFAIL ((void *)(MAX_SIZE_T)) +#define CMFAIL ((char *)(MFAIL)) /* defined for convenience */ + +#define IS_DIRECT_BIT (SIZE_T_ONE) + +#if LJ_TARGET_WINDOWS + +#define WIN32_LEAN_AND_MEAN +#include + +#if LJ_64 + +/* Undocumented, but hey, that's what we all love so much about Windows. */ +typedef long (*PNTAVM)(HANDLE handle, void **addr, ULONG zbits, + size_t *size, ULONG alloctype, ULONG prot); +static PNTAVM ntavm; + +/* Number of top bits of the lower 32 bits of an address that must be zero. +** Apparently 0 gives us full 64 bit addresses and 1 gives us the lower 2GB. +*/ +#define NTAVM_ZEROBITS 1 + +static void INIT_MMAP(void) +{ + ntavm = (PNTAVM)GetProcAddress(GetModuleHandleA("ntdll.dll"), + "NtAllocateVirtualMemory"); +} + +/* Win64 32 bit MMAP via NtAllocateVirtualMemory. */ +static LJ_AINLINE void *CALL_MMAP(size_t size) +{ + DWORD olderr = GetLastError(); + void *ptr = NULL; + long st = ntavm(INVALID_HANDLE_VALUE, &ptr, NTAVM_ZEROBITS, &size, + MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); + SetLastError(olderr); + return st == 0 ? ptr : MFAIL; +} + +/* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ +static LJ_AINLINE void *DIRECT_MMAP(size_t size) +{ + DWORD olderr = GetLastError(); + void *ptr = NULL; + long st = ntavm(INVALID_HANDLE_VALUE, &ptr, NTAVM_ZEROBITS, &size, + MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, PAGE_READWRITE); + SetLastError(olderr); + return st == 0 ? ptr : MFAIL; +} + +#else + +#define INIT_MMAP() ((void)0) + +/* Win32 MMAP via VirtualAlloc */ +static LJ_AINLINE void *CALL_MMAP(size_t size) +{ + DWORD olderr = GetLastError(); + void *ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); + SetLastError(olderr); + return ptr ? ptr : MFAIL; +} + +/* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ +static LJ_AINLINE void *DIRECT_MMAP(size_t size) +{ + DWORD olderr = GetLastError(); + void *ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, + PAGE_READWRITE); + SetLastError(olderr); + return ptr ? ptr : MFAIL; +} + +#endif + +/* This function supports releasing coalesed segments */ +static LJ_AINLINE int CALL_MUNMAP(void *ptr, size_t size) +{ + DWORD olderr = GetLastError(); + MEMORY_BASIC_INFORMATION minfo; + char *cptr = (char *)ptr; + while (size) { + if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) + return -1; + if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr || + minfo.State != MEM_COMMIT || minfo.RegionSize > size) + return -1; + if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) + return -1; + cptr += minfo.RegionSize; + size -= minfo.RegionSize; + } + SetLastError(olderr); + return 0; +} + +#else + +#include +#include + +#define MMAP_PROT (PROT_READ|PROT_WRITE) +#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) +#define MAP_ANONYMOUS MAP_ANON +#endif +#define MMAP_FLAGS (MAP_PRIVATE|MAP_ANONYMOUS) + +#if LJ_64 +/* 64 bit mode needs special support for allocating memory in the lower 2GB. */ + +#if defined(MAP_32BIT) + +#if defined(__sun__) +#define MMAP_REGION_START ((uintptr_t)0x1000) +#else +/* Actually this only gives us max. 1GB in current Linux kernels. */ +#define MMAP_REGION_START ((uintptr_t)0) +#endif + +static LJ_AINLINE void *CALL_MMAP(size_t size) +{ + int olderr = errno; + void *ptr = mmap((void *)MMAP_REGION_START, size, MMAP_PROT, MAP_32BIT|MMAP_FLAGS, -1, 0); + errno = olderr; + return ptr; +} + +#elif LJ_TARGET_OSX || LJ_TARGET_PS4 || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__sun__) + +/* OSX and FreeBSD mmap() use a naive first-fit linear search. +** That's perfect for us. Except that -pagezero_size must be set for OSX, +** otherwise the lower 4GB are blocked. And the 32GB RLIMIT_DATA needs +** to be reduced to 250MB on FreeBSD. +*/ +#if LJ_TARGET_OSX || defined(__DragonFly__) +#define MMAP_REGION_START ((uintptr_t)0x10000) +#elif LJ_TARGET_PS4 +#define MMAP_REGION_START ((uintptr_t)0x4000) +#else +#define MMAP_REGION_START ((uintptr_t)0x10000000) +#endif +#define MMAP_REGION_END ((uintptr_t)0x80000000) + +#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && !LJ_TARGET_PS4 +#include +#endif + +static LJ_AINLINE void *CALL_MMAP(size_t size) +{ + int olderr = errno; + /* Hint for next allocation. Doesn't need to be thread-safe. */ + static uintptr_t alloc_hint = MMAP_REGION_START; + int retry = 0; +#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && !LJ_TARGET_PS4 + static int rlimit_modified = 0; + if (LJ_UNLIKELY(rlimit_modified == 0)) { + struct rlimit rlim; + rlim.rlim_cur = rlim.rlim_max = MMAP_REGION_START; + setrlimit(RLIMIT_DATA, &rlim); /* Ignore result. May fail below. */ + rlimit_modified = 1; + } +#endif + for (;;) { + void *p = mmap((void *)alloc_hint, size, MMAP_PROT, MMAP_FLAGS, -1, 0); + if ((uintptr_t)p >= MMAP_REGION_START && + (uintptr_t)p + size < MMAP_REGION_END) { + alloc_hint = (uintptr_t)p + size; + errno = olderr; + return p; + } + if (p != CMFAIL) munmap(p, size); +#if defined(__sun__) || defined(__DragonFly__) + alloc_hint += 0x1000000; /* Need near-exhaustive linear scan. */ + if (alloc_hint + size < MMAP_REGION_END) continue; +#endif + if (retry) break; + retry = 1; + alloc_hint = MMAP_REGION_START; + } + errno = olderr; + return CMFAIL; +} + +#else + +#error "NYI: need an equivalent of MAP_32BIT for this 64 bit OS" + +#endif + +#else + +/* 32 bit mode is easy. */ +static LJ_AINLINE void *CALL_MMAP(size_t size) +{ + int olderr = errno; + void *ptr = mmap(NULL, size, MMAP_PROT, MMAP_FLAGS, -1, 0); + errno = olderr; + return ptr; +} + +#endif + +#define INIT_MMAP() ((void)0) +#define DIRECT_MMAP(s) CALL_MMAP(s) + +static LJ_AINLINE int CALL_MUNMAP(void *ptr, size_t size) +{ + int olderr = errno; + int ret = munmap(ptr, size); + errno = olderr; + return ret; +} + +#if LJ_TARGET_LINUX +/* Need to define _GNU_SOURCE to get the mremap prototype. */ +static LJ_AINLINE void *CALL_MREMAP_(void *ptr, size_t osz, size_t nsz, + int flags) +{ + int olderr = errno; + ptr = mremap(ptr, osz, nsz, flags); + errno = olderr; + return ptr; +} + +#define CALL_MREMAP(addr, osz, nsz, mv) CALL_MREMAP_((addr), (osz), (nsz), (mv)) +#define CALL_MREMAP_NOMOVE 0 +#define CALL_MREMAP_MAYMOVE 1 +#if LJ_64 +#define CALL_MREMAP_MV CALL_MREMAP_NOMOVE +#else +#define CALL_MREMAP_MV CALL_MREMAP_MAYMOVE +#endif +#endif + +#endif + +#ifndef CALL_MREMAP +#define CALL_MREMAP(addr, osz, nsz, mv) ((void)osz, MFAIL) +#endif + +/* ----------------------- Chunk representations ------------------------ */ + +struct malloc_chunk { + size_t prev_foot; /* Size of previous chunk (if free). */ + size_t head; /* Size and inuse bits. */ + struct malloc_chunk *fd; /* double links -- used only if free. */ + struct malloc_chunk *bk; +}; + +typedef struct malloc_chunk mchunk; +typedef struct malloc_chunk *mchunkptr; +typedef struct malloc_chunk *sbinptr; /* The type of bins of chunks */ +typedef size_t bindex_t; /* Described below */ +typedef unsigned int binmap_t; /* Described below */ +typedef unsigned int flag_t; /* The type of various bit flag sets */ + +/* ------------------- Chunks sizes and alignments ----------------------- */ + +#define MCHUNK_SIZE (sizeof(mchunk)) + +#define CHUNK_OVERHEAD (SIZE_T_SIZE) + +/* Direct chunks need a second word of overhead ... */ +#define DIRECT_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) +/* ... and additional padding for fake next-chunk at foot */ +#define DIRECT_FOOT_PAD (FOUR_SIZE_T_SIZES) + +/* The smallest size we can malloc is an aligned minimal chunk */ +#define MIN_CHUNK_SIZE\ + ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) + +/* conversion from malloc headers to user pointers, and back */ +#define chunk2mem(p) ((void *)((char *)(p) + TWO_SIZE_T_SIZES)) +#define mem2chunk(mem) ((mchunkptr)((char *)(mem) - TWO_SIZE_T_SIZES)) +/* chunk associated with aligned address A */ +#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) + +/* Bounds on request (not chunk) sizes. */ +#define MAX_REQUEST ((~MIN_CHUNK_SIZE+1) << 2) +#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) + +/* pad request bytes into a usable size */ +#define pad_request(req) \ + (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) + +/* pad request, checking for minimum (but not maximum) */ +#define request2size(req) \ + (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req)) + +/* ------------------ Operations on head and foot fields ----------------- */ + +#define PINUSE_BIT (SIZE_T_ONE) +#define CINUSE_BIT (SIZE_T_TWO) +#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT) + +/* Head value for fenceposts */ +#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE) + +/* extraction of fields from head words */ +#define cinuse(p) ((p)->head & CINUSE_BIT) +#define pinuse(p) ((p)->head & PINUSE_BIT) +#define chunksize(p) ((p)->head & ~(INUSE_BITS)) + +#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) +#define clear_cinuse(p) ((p)->head &= ~CINUSE_BIT) + +/* Treat space at ptr +/- offset as a chunk */ +#define chunk_plus_offset(p, s) ((mchunkptr)(((char *)(p)) + (s))) +#define chunk_minus_offset(p, s) ((mchunkptr)(((char *)(p)) - (s))) + +/* Ptr to next or previous physical malloc_chunk. */ +#define next_chunk(p) ((mchunkptr)(((char *)(p)) + ((p)->head & ~INUSE_BITS))) +#define prev_chunk(p) ((mchunkptr)(((char *)(p)) - ((p)->prev_foot) )) + +/* extract next chunk's pinuse bit */ +#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) + +/* Get/set size at footer */ +#define get_foot(p, s) (((mchunkptr)((char *)(p) + (s)))->prev_foot) +#define set_foot(p, s) (((mchunkptr)((char *)(p) + (s)))->prev_foot = (s)) + +/* Set size, pinuse bit, and foot */ +#define set_size_and_pinuse_of_free_chunk(p, s)\ + ((p)->head = (s|PINUSE_BIT), set_foot(p, s)) + +/* Set size, pinuse bit, foot, and clear next pinuse */ +#define set_free_with_pinuse(p, s, n)\ + (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) + +#define is_direct(p)\ + (!((p)->head & PINUSE_BIT) && ((p)->prev_foot & IS_DIRECT_BIT)) + +/* Get the internal overhead associated with chunk p */ +#define overhead_for(p)\ + (is_direct(p)? DIRECT_CHUNK_OVERHEAD : CHUNK_OVERHEAD) + +/* ---------------------- Overlaid data structures ----------------------- */ + +struct malloc_tree_chunk { + /* The first four fields must be compatible with malloc_chunk */ + size_t prev_foot; + size_t head; + struct malloc_tree_chunk *fd; + struct malloc_tree_chunk *bk; + + struct malloc_tree_chunk *child[2]; + struct malloc_tree_chunk *parent; + bindex_t index; +}; + +typedef struct malloc_tree_chunk tchunk; +typedef struct malloc_tree_chunk *tchunkptr; +typedef struct malloc_tree_chunk *tbinptr; /* The type of bins of trees */ + +/* A little helper macro for trees */ +#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) + +/* ----------------------------- Segments -------------------------------- */ + +struct malloc_segment { + char *base; /* base address */ + size_t size; /* allocated size */ + struct malloc_segment *next; /* ptr to next segment */ +}; + +typedef struct malloc_segment msegment; +typedef struct malloc_segment *msegmentptr; + +/* ---------------------------- malloc_state ----------------------------- */ + +/* Bin types, widths and sizes */ +#define NSMALLBINS (32U) +#define NTREEBINS (32U) +#define SMALLBIN_SHIFT (3U) +#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) +#define TREEBIN_SHIFT (8U) +#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) +#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) +#define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) + +struct malloc_state { + binmap_t smallmap; + binmap_t treemap; + size_t dvsize; + size_t topsize; + mchunkptr dv; + mchunkptr top; + size_t trim_check; + size_t release_checks; + mchunkptr smallbins[(NSMALLBINS+1)*2]; + tbinptr treebins[NTREEBINS]; + msegment seg; +}; + +typedef struct malloc_state *mstate; + +#define is_initialized(M) ((M)->top != 0) + +/* -------------------------- system alloc setup ------------------------- */ + +/* page-align a size */ +#define page_align(S)\ + (((S) + (LJ_PAGESIZE - SIZE_T_ONE)) & ~(LJ_PAGESIZE - SIZE_T_ONE)) + +/* granularity-align a size */ +#define granularity_align(S)\ + (((S) + (DEFAULT_GRANULARITY - SIZE_T_ONE))\ + & ~(DEFAULT_GRANULARITY - SIZE_T_ONE)) + +#if LJ_TARGET_WINDOWS +#define mmap_align(S) granularity_align(S) +#else +#define mmap_align(S) page_align(S) +#endif + +/* True if segment S holds address A */ +#define segment_holds(S, A)\ + ((char *)(A) >= S->base && (char *)(A) < S->base + S->size) + +/* Return segment holding given address */ +static msegmentptr segment_holding(mstate m, char *addr) +{ + msegmentptr sp = &m->seg; + for (;;) { + if (addr >= sp->base && addr < sp->base + sp->size) + return sp; + if ((sp = sp->next) == 0) + return 0; + } +} + +/* Return true if segment contains a segment link */ +static int has_segment_link(mstate m, msegmentptr ss) +{ + msegmentptr sp = &m->seg; + for (;;) { + if ((char *)sp >= ss->base && (char *)sp < ss->base + ss->size) + return 1; + if ((sp = sp->next) == 0) + return 0; + } +} + +/* + TOP_FOOT_SIZE is padding at the end of a segment, including space + that may be needed to place segment records and fenceposts when new + noncontiguous segments are added. +*/ +#define TOP_FOOT_SIZE\ + (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE) + +/* ---------------------------- Indexing Bins ---------------------------- */ + +#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) +#define small_index(s) ((s) >> SMALLBIN_SHIFT) +#define small_index2size(i) ((i) << SMALLBIN_SHIFT) +#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) + +/* addressing by index. See above about smallbin repositioning */ +#define smallbin_at(M, i) ((sbinptr)((char *)&((M)->smallbins[(i)<<1]))) +#define treebin_at(M,i) (&((M)->treebins[i])) + +/* assign tree index for size S to variable I */ +#define compute_tree_index(S, I)\ +{\ + unsigned int X = (unsigned int)(S >> TREEBIN_SHIFT);\ + if (X == 0) {\ + I = 0;\ + } else if (X > 0xFFFF) {\ + I = NTREEBINS-1;\ + } else {\ + unsigned int K = lj_fls(X);\ + I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ + }\ +} + +/* Bit representing maximum resolved size in a treebin at i */ +#define bit_for_tree_index(i) \ + (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2) + +/* Shift placing maximum resolved bit in a treebin at i as sign bit */ +#define leftshift_for_tree_index(i) \ + ((i == NTREEBINS-1)? 0 : \ + ((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) + +/* The size of the smallest chunk held in bin with index i */ +#define minsize_for_tree_index(i) \ + ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ + (((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) + +/* ------------------------ Operations on bin maps ----------------------- */ + +/* bit corresponding to given index */ +#define idx2bit(i) ((binmap_t)(1) << (i)) + +/* Mark/Clear bits with given index */ +#define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i)) +#define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i)) +#define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i)) + +#define mark_treemap(M,i) ((M)->treemap |= idx2bit(i)) +#define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i)) +#define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i)) + +/* mask with all bits to left of least bit of x on */ +#define left_bits(x) ((x<<1) | (~(x<<1)+1)) + +/* Set cinuse bit and pinuse bit of next chunk */ +#define set_inuse(M,p,s)\ + ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ + ((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT) + +/* Set cinuse and pinuse of this chunk and pinuse of next chunk */ +#define set_inuse_and_pinuse(M,p,s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ + ((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT) + +/* Set size, cinuse and pinuse bit of this chunk */ +#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT)) + +/* ----------------------- Operations on smallbins ----------------------- */ + +/* Link a free chunk into a smallbin */ +#define insert_small_chunk(M, P, S) {\ + bindex_t I = small_index(S);\ + mchunkptr B = smallbin_at(M, I);\ + mchunkptr F = B;\ + if (!smallmap_is_marked(M, I))\ + mark_smallmap(M, I);\ + else\ + F = B->fd;\ + B->fd = P;\ + F->bk = P;\ + P->fd = F;\ + P->bk = B;\ +} + +/* Unlink a chunk from a smallbin */ +#define unlink_small_chunk(M, P, S) {\ + mchunkptr F = P->fd;\ + mchunkptr B = P->bk;\ + bindex_t I = small_index(S);\ + if (F == B) {\ + clear_smallmap(M, I);\ + } else {\ + F->bk = B;\ + B->fd = F;\ + }\ +} + +/* Unlink the first chunk from a smallbin */ +#define unlink_first_small_chunk(M, B, P, I) {\ + mchunkptr F = P->fd;\ + if (B == F) {\ + clear_smallmap(M, I);\ + } else {\ + B->fd = F;\ + F->bk = B;\ + }\ +} + +/* Replace dv node, binning the old one */ +/* Used only when dvsize known to be small */ +#define replace_dv(M, P, S) {\ + size_t DVS = M->dvsize;\ + if (DVS != 0) {\ + mchunkptr DV = M->dv;\ + insert_small_chunk(M, DV, DVS);\ + }\ + M->dvsize = S;\ + M->dv = P;\ +} + +/* ------------------------- Operations on trees ------------------------- */ + +/* Insert chunk into tree */ +#define insert_large_chunk(M, X, S) {\ + tbinptr *H;\ + bindex_t I;\ + compute_tree_index(S, I);\ + H = treebin_at(M, I);\ + X->index = I;\ + X->child[0] = X->child[1] = 0;\ + if (!treemap_is_marked(M, I)) {\ + mark_treemap(M, I);\ + *H = X;\ + X->parent = (tchunkptr)H;\ + X->fd = X->bk = X;\ + } else {\ + tchunkptr T = *H;\ + size_t K = S << leftshift_for_tree_index(I);\ + for (;;) {\ + if (chunksize(T) != S) {\ + tchunkptr *C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\ + K <<= 1;\ + if (*C != 0) {\ + T = *C;\ + } else {\ + *C = X;\ + X->parent = T;\ + X->fd = X->bk = X;\ + break;\ + }\ + } else {\ + tchunkptr F = T->fd;\ + T->fd = F->bk = X;\ + X->fd = F;\ + X->bk = T;\ + X->parent = 0;\ + break;\ + }\ + }\ + }\ +} + +#define unlink_large_chunk(M, X) {\ + tchunkptr XP = X->parent;\ + tchunkptr R;\ + if (X->bk != X) {\ + tchunkptr F = X->fd;\ + R = X->bk;\ + F->bk = R;\ + R->fd = F;\ + } else {\ + tchunkptr *RP;\ + if (((R = *(RP = &(X->child[1]))) != 0) ||\ + ((R = *(RP = &(X->child[0]))) != 0)) {\ + tchunkptr *CP;\ + while ((*(CP = &(R->child[1])) != 0) ||\ + (*(CP = &(R->child[0])) != 0)) {\ + R = *(RP = CP);\ + }\ + *RP = 0;\ + }\ + }\ + if (XP != 0) {\ + tbinptr *H = treebin_at(M, X->index);\ + if (X == *H) {\ + if ((*H = R) == 0) \ + clear_treemap(M, X->index);\ + } else {\ + if (XP->child[0] == X) \ + XP->child[0] = R;\ + else \ + XP->child[1] = R;\ + }\ + if (R != 0) {\ + tchunkptr C0, C1;\ + R->parent = XP;\ + if ((C0 = X->child[0]) != 0) {\ + R->child[0] = C0;\ + C0->parent = R;\ + }\ + if ((C1 = X->child[1]) != 0) {\ + R->child[1] = C1;\ + C1->parent = R;\ + }\ + }\ + }\ +} + +/* Relays to large vs small bin operations */ + +#define insert_chunk(M, P, S)\ + if (is_small(S)) { insert_small_chunk(M, P, S)\ + } else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); } + +#define unlink_chunk(M, P, S)\ + if (is_small(S)) { unlink_small_chunk(M, P, S)\ + } else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); } + +/* ----------------------- Direct-mmapping chunks ----------------------- */ + +static void *direct_alloc(size_t nb) +{ + size_t mmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + if (LJ_LIKELY(mmsize > nb)) { /* Check for wrap around 0 */ + char *mm = (char *)(DIRECT_MMAP(mmsize)); + if (mm != CMFAIL) { + size_t offset = align_offset(chunk2mem(mm)); + size_t psize = mmsize - offset - DIRECT_FOOT_PAD; + mchunkptr p = (mchunkptr)(mm + offset); + p->prev_foot = offset | IS_DIRECT_BIT; + p->head = psize|CINUSE_BIT; + chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; + chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; + return chunk2mem(p); + } + } + return NULL; +} + +static mchunkptr direct_resize(mchunkptr oldp, size_t nb) +{ + size_t oldsize = chunksize(oldp); + if (is_small(nb)) /* Can't shrink direct regions below small size */ + return NULL; + /* Keep old chunk if big enough but not too big */ + if (oldsize >= nb + SIZE_T_SIZE && + (oldsize - nb) <= (DEFAULT_GRANULARITY >> 1)) { + return oldp; + } else { + size_t offset = oldp->prev_foot & ~IS_DIRECT_BIT; + size_t oldmmsize = oldsize + offset + DIRECT_FOOT_PAD; + size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + char *cp = (char *)CALL_MREMAP((char *)oldp - offset, + oldmmsize, newmmsize, CALL_MREMAP_MV); + if (cp != CMFAIL) { + mchunkptr newp = (mchunkptr)(cp + offset); + size_t psize = newmmsize - offset - DIRECT_FOOT_PAD; + newp->head = psize|CINUSE_BIT; + chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; + chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; + return newp; + } + } + return NULL; +} + +/* -------------------------- mspace management -------------------------- */ + +/* Initialize top chunk and its size */ +static void init_top(mstate m, mchunkptr p, size_t psize) +{ + /* Ensure alignment */ + size_t offset = align_offset(chunk2mem(p)); + p = (mchunkptr)((char *)p + offset); + psize -= offset; + + m->top = p; + m->topsize = psize; + p->head = psize | PINUSE_BIT; + /* set size of fake trailing chunk holding overhead space only once */ + chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; + m->trim_check = DEFAULT_TRIM_THRESHOLD; /* reset on each update */ +} + +/* Initialize bins for a new mstate that is otherwise zeroed out */ +static void init_bins(mstate m) +{ + /* Establish circular links for smallbins */ + bindex_t i; + for (i = 0; i < NSMALLBINS; i++) { + sbinptr bin = smallbin_at(m,i); + bin->fd = bin->bk = bin; + } +} + +/* Allocate chunk and prepend remainder with chunk in successor base. */ +static void *prepend_alloc(mstate m, char *newbase, char *oldbase, size_t nb) +{ + mchunkptr p = align_as_chunk(newbase); + mchunkptr oldfirst = align_as_chunk(oldbase); + size_t psize = (size_t)((char *)oldfirst - (char *)p); + mchunkptr q = chunk_plus_offset(p, nb); + size_t qsize = psize - nb; + set_size_and_pinuse_of_inuse_chunk(m, p, nb); + + /* consolidate remainder with first chunk of old base */ + if (oldfirst == m->top) { + size_t tsize = m->topsize += qsize; + m->top = q; + q->head = tsize | PINUSE_BIT; + } else if (oldfirst == m->dv) { + size_t dsize = m->dvsize += qsize; + m->dv = q; + set_size_and_pinuse_of_free_chunk(q, dsize); + } else { + if (!cinuse(oldfirst)) { + size_t nsize = chunksize(oldfirst); + unlink_chunk(m, oldfirst, nsize); + oldfirst = chunk_plus_offset(oldfirst, nsize); + qsize += nsize; + } + set_free_with_pinuse(q, qsize, oldfirst); + insert_chunk(m, q, qsize); + } + + return chunk2mem(p); +} + +/* Add a segment to hold a new noncontiguous region */ +static void add_segment(mstate m, char *tbase, size_t tsize) +{ + /* Determine locations and sizes of segment, fenceposts, old top */ + char *old_top = (char *)m->top; + msegmentptr oldsp = segment_holding(m, old_top); + char *old_end = oldsp->base + oldsp->size; + size_t ssize = pad_request(sizeof(struct malloc_segment)); + char *rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + size_t offset = align_offset(chunk2mem(rawsp)); + char *asp = rawsp + offset; + char *csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; + mchunkptr sp = (mchunkptr)csp; + msegmentptr ss = (msegmentptr)(chunk2mem(sp)); + mchunkptr tnext = chunk_plus_offset(sp, ssize); + mchunkptr p = tnext; + + /* reset top to new space */ + init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); + + /* Set up segment record */ + set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); + *ss = m->seg; /* Push current record */ + m->seg.base = tbase; + m->seg.size = tsize; + m->seg.next = ss; + + /* Insert trailing fenceposts */ + for (;;) { + mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); + p->head = FENCEPOST_HEAD; + if ((char *)(&(nextp->head)) < old_end) + p = nextp; + else + break; + } + + /* Insert the rest of old top into a bin as an ordinary free chunk */ + if (csp != old_top) { + mchunkptr q = (mchunkptr)old_top; + size_t psize = (size_t)(csp - old_top); + mchunkptr tn = chunk_plus_offset(q, psize); + set_free_with_pinuse(q, psize, tn); + insert_chunk(m, q, psize); + } +} + +/* -------------------------- System allocation -------------------------- */ + +static void *alloc_sys(mstate m, size_t nb) +{ + char *tbase = CMFAIL; + size_t tsize = 0; + + /* Directly map large chunks */ + if (LJ_UNLIKELY(nb >= DEFAULT_MMAP_THRESHOLD)) { + void *mem = direct_alloc(nb); + if (mem != 0) + return mem; + } + + { + size_t req = nb + TOP_FOOT_SIZE + SIZE_T_ONE; + size_t rsize = granularity_align(req); + if (LJ_LIKELY(rsize > nb)) { /* Fail if wraps around zero */ + char *mp = (char *)(CALL_MMAP(rsize)); + if (mp != CMFAIL) { + tbase = mp; + tsize = rsize; + } + } + } + + if (tbase != CMFAIL) { + msegmentptr sp = &m->seg; + /* Try to merge with an existing segment */ + while (sp != 0 && tbase != sp->base + sp->size) + sp = sp->next; + if (sp != 0 && segment_holds(sp, m->top)) { /* append */ + sp->size += tsize; + init_top(m, m->top, m->topsize + tsize); + } else { + sp = &m->seg; + while (sp != 0 && sp->base != tbase + tsize) + sp = sp->next; + if (sp != 0) { + char *oldbase = sp->base; + sp->base = tbase; + sp->size += tsize; + return prepend_alloc(m, tbase, oldbase, nb); + } else { + add_segment(m, tbase, tsize); + } + } + + if (nb < m->topsize) { /* Allocate from new or extended top space */ + size_t rsize = m->topsize -= nb; + mchunkptr p = m->top; + mchunkptr r = m->top = chunk_plus_offset(p, nb); + r->head = rsize | PINUSE_BIT; + set_size_and_pinuse_of_inuse_chunk(m, p, nb); + return chunk2mem(p); + } + } + + return NULL; +} + +/* ----------------------- system deallocation -------------------------- */ + +/* Unmap and unlink any mmapped segments that don't contain used chunks */ +static size_t release_unused_segments(mstate m) +{ + size_t released = 0; + size_t nsegs = 0; + msegmentptr pred = &m->seg; + msegmentptr sp = pred->next; + while (sp != 0) { + char *base = sp->base; + size_t size = sp->size; + msegmentptr next = sp->next; + nsegs++; + { + mchunkptr p = align_as_chunk(base); + size_t psize = chunksize(p); + /* Can unmap if first chunk holds entire segment and not pinned */ + if (!cinuse(p) && (char *)p + psize >= base + size - TOP_FOOT_SIZE) { + tchunkptr tp = (tchunkptr)p; + if (p == m->dv) { + m->dv = 0; + m->dvsize = 0; + } else { + unlink_large_chunk(m, tp); + } + if (CALL_MUNMAP(base, size) == 0) { + released += size; + /* unlink obsoleted record */ + sp = pred; + sp->next = next; + } else { /* back out if cannot unmap */ + insert_large_chunk(m, tp, psize); + } + } + } + pred = sp; + sp = next; + } + /* Reset check counter */ + m->release_checks = nsegs > MAX_RELEASE_CHECK_RATE ? + nsegs : MAX_RELEASE_CHECK_RATE; + return released; +} + +static int alloc_trim(mstate m, size_t pad) +{ + size_t released = 0; + if (pad < MAX_REQUEST && is_initialized(m)) { + pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ + + if (m->topsize > pad) { + /* Shrink top space in granularity-size units, keeping at least one */ + size_t unit = DEFAULT_GRANULARITY; + size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - + SIZE_T_ONE) * unit; + msegmentptr sp = segment_holding(m, (char *)m->top); + + if (sp->size >= extra && + !has_segment_link(m, sp)) { /* can't shrink if pinned */ + size_t newsize = sp->size - extra; + /* Prefer mremap, fall back to munmap */ + if ((CALL_MREMAP(sp->base, sp->size, newsize, CALL_MREMAP_NOMOVE) != MFAIL) || + (CALL_MUNMAP(sp->base + newsize, extra) == 0)) { + released = extra; + } + } + + if (released != 0) { + sp->size -= released; + init_top(m, m->top, m->topsize - released); + } + } + + /* Unmap any unused mmapped segments */ + released += release_unused_segments(m); + + /* On failure, disable autotrim to avoid repeated failed future calls */ + if (released == 0 && m->topsize > m->trim_check) + m->trim_check = MAX_SIZE_T; + } + + return (released != 0)? 1 : 0; +} + +/* ---------------------------- malloc support --------------------------- */ + +/* allocate a large request from the best fitting chunk in a treebin */ +static void *tmalloc_large(mstate m, size_t nb) +{ + tchunkptr v = 0; + size_t rsize = ~nb+1; /* Unsigned negation */ + tchunkptr t; + bindex_t idx; + compute_tree_index(nb, idx); + + if ((t = *treebin_at(m, idx)) != 0) { + /* Traverse tree for this bin looking for node with size == nb */ + size_t sizebits = nb << leftshift_for_tree_index(idx); + tchunkptr rst = 0; /* The deepest untaken right subtree */ + for (;;) { + tchunkptr rt; + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + v = t; + if ((rsize = trem) == 0) + break; + } + rt = t->child[1]; + t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; + if (rt != 0 && rt != t) + rst = rt; + if (t == 0) { + t = rst; /* set t to least subtree holding sizes > nb */ + break; + } + sizebits <<= 1; + } + } + + if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ + binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; + if (leftbits != 0) + t = *treebin_at(m, lj_ffs(leftbits)); + } + + while (t != 0) { /* find smallest of tree or subtree */ + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + rsize = trem; + v = t; + } + t = leftmost_child(t); + } + + /* If dv is a better fit, return NULL so malloc will use it */ + if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { + mchunkptr r = chunk_plus_offset(v, nb); + unlink_large_chunk(m, v); + if (rsize < MIN_CHUNK_SIZE) { + set_inuse_and_pinuse(m, v, (rsize + nb)); + } else { + set_size_and_pinuse_of_inuse_chunk(m, v, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + insert_chunk(m, r, rsize); + } + return chunk2mem(v); + } + return NULL; +} + +/* allocate a small request from the best fitting chunk in a treebin */ +static void *tmalloc_small(mstate m, size_t nb) +{ + tchunkptr t, v; + mchunkptr r; + size_t rsize; + bindex_t i = lj_ffs(m->treemap); + + v = t = *treebin_at(m, i); + rsize = chunksize(t) - nb; + + while ((t = leftmost_child(t)) != 0) { + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + rsize = trem; + v = t; + } + } + + r = chunk_plus_offset(v, nb); + unlink_large_chunk(m, v); + if (rsize < MIN_CHUNK_SIZE) { + set_inuse_and_pinuse(m, v, (rsize + nb)); + } else { + set_size_and_pinuse_of_inuse_chunk(m, v, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(m, r, rsize); + } + return chunk2mem(v); +} + +/* ----------------------------------------------------------------------- */ + +void *lj_alloc_create(void) +{ + size_t tsize = DEFAULT_GRANULARITY; + char *tbase; + INIT_MMAP(); + tbase = (char *)(CALL_MMAP(tsize)); + if (tbase != CMFAIL) { + size_t msize = pad_request(sizeof(struct malloc_state)); + mchunkptr mn; + mchunkptr msp = align_as_chunk(tbase); + mstate m = (mstate)(chunk2mem(msp)); + memset(m, 0, msize); + msp->head = (msize|PINUSE_BIT|CINUSE_BIT); + m->seg.base = tbase; + m->seg.size = tsize; + m->release_checks = MAX_RELEASE_CHECK_RATE; + init_bins(m); + mn = next_chunk(mem2chunk(m)); + init_top(m, mn, (size_t)((tbase + tsize) - (char *)mn) - TOP_FOOT_SIZE); + return m; + } + return NULL; +} + +void lj_alloc_destroy(void *msp) +{ + mstate ms = (mstate)msp; + msegmentptr sp = &ms->seg; + while (sp != 0) { + char *base = sp->base; + size_t size = sp->size; + sp = sp->next; + CALL_MUNMAP(base, size); + } +} + +static LJ_NOINLINE void *lj_alloc_malloc(void *msp, size_t nsize) +{ + mstate ms = (mstate)msp; + void *mem; + size_t nb; + if (nsize <= MAX_SMALL_REQUEST) { + bindex_t idx; + binmap_t smallbits; + nb = (nsize < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(nsize); + idx = small_index(nb); + smallbits = ms->smallmap >> idx; + + if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ + mchunkptr b, p; + idx += ~smallbits & 1; /* Uses next bin if idx empty */ + b = smallbin_at(ms, idx); + p = b->fd; + unlink_first_small_chunk(ms, b, p, idx); + set_inuse_and_pinuse(ms, p, small_index2size(idx)); + mem = chunk2mem(p); + return mem; + } else if (nb > ms->dvsize) { + if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ + mchunkptr b, p, r; + size_t rsize; + binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); + bindex_t i = lj_ffs(leftbits); + b = smallbin_at(ms, i); + p = b->fd; + unlink_first_small_chunk(ms, b, p, i); + rsize = small_index2size(i) - nb; + /* Fit here cannot be remainderless if 4byte sizes */ + if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) { + set_inuse_and_pinuse(ms, p, small_index2size(i)); + } else { + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + r = chunk_plus_offset(p, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(ms, r, rsize); + } + mem = chunk2mem(p); + return mem; + } else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) { + return mem; + } + } + } else if (nsize >= MAX_REQUEST) { + nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ + } else { + nb = pad_request(nsize); + if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) { + return mem; + } + } + + if (nb <= ms->dvsize) { + size_t rsize = ms->dvsize - nb; + mchunkptr p = ms->dv; + if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ + mchunkptr r = ms->dv = chunk_plus_offset(p, nb); + ms->dvsize = rsize; + set_size_and_pinuse_of_free_chunk(r, rsize); + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + } else { /* exhaust dv */ + size_t dvs = ms->dvsize; + ms->dvsize = 0; + ms->dv = 0; + set_inuse_and_pinuse(ms, p, dvs); + } + mem = chunk2mem(p); + return mem; + } else if (nb < ms->topsize) { /* Split top */ + size_t rsize = ms->topsize -= nb; + mchunkptr p = ms->top; + mchunkptr r = ms->top = chunk_plus_offset(p, nb); + r->head = rsize | PINUSE_BIT; + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + mem = chunk2mem(p); + return mem; + } + return alloc_sys(ms, nb); +} + +static LJ_NOINLINE void *lj_alloc_free(void *msp, void *ptr) +{ + if (ptr != 0) { + mchunkptr p = mem2chunk(ptr); + mstate fm = (mstate)msp; + size_t psize = chunksize(p); + mchunkptr next = chunk_plus_offset(p, psize); + if (!pinuse(p)) { + size_t prevsize = p->prev_foot; + if ((prevsize & IS_DIRECT_BIT) != 0) { + prevsize &= ~IS_DIRECT_BIT; + psize += prevsize + DIRECT_FOOT_PAD; + CALL_MUNMAP((char *)p - prevsize, psize); + return NULL; + } else { + mchunkptr prev = chunk_minus_offset(p, prevsize); + psize += prevsize; + p = prev; + /* consolidate backward */ + if (p != fm->dv) { + unlink_chunk(fm, p, prevsize); + } else if ((next->head & INUSE_BITS) == INUSE_BITS) { + fm->dvsize = psize; + set_free_with_pinuse(p, psize, next); + return NULL; + } + } + } + if (!cinuse(next)) { /* consolidate forward */ + if (next == fm->top) { + size_t tsize = fm->topsize += psize; + fm->top = p; + p->head = tsize | PINUSE_BIT; + if (p == fm->dv) { + fm->dv = 0; + fm->dvsize = 0; + } + if (tsize > fm->trim_check) + alloc_trim(fm, 0); + return NULL; + } else if (next == fm->dv) { + size_t dsize = fm->dvsize += psize; + fm->dv = p; + set_size_and_pinuse_of_free_chunk(p, dsize); + return NULL; + } else { + size_t nsize = chunksize(next); + psize += nsize; + unlink_chunk(fm, next, nsize); + set_size_and_pinuse_of_free_chunk(p, psize); + if (p == fm->dv) { + fm->dvsize = psize; + return NULL; + } + } + } else { + set_free_with_pinuse(p, psize, next); + } + + if (is_small(psize)) { + insert_small_chunk(fm, p, psize); + } else { + tchunkptr tp = (tchunkptr)p; + insert_large_chunk(fm, tp, psize); + if (--fm->release_checks == 0) + release_unused_segments(fm); + } + } + return NULL; +} + +static LJ_NOINLINE void *lj_alloc_realloc(void *msp, void *ptr, size_t nsize) +{ + if (nsize >= MAX_REQUEST) { + return NULL; + } else { + mstate m = (mstate)msp; + mchunkptr oldp = mem2chunk(ptr); + size_t oldsize = chunksize(oldp); + mchunkptr next = chunk_plus_offset(oldp, oldsize); + mchunkptr newp = 0; + size_t nb = request2size(nsize); + + /* Try to either shrink or extend into top. Else malloc-copy-free */ + if (is_direct(oldp)) { + newp = direct_resize(oldp, nb); /* this may return NULL. */ + } else if (oldsize >= nb) { /* already big enough */ + size_t rsize = oldsize - nb; + newp = oldp; + if (rsize >= MIN_CHUNK_SIZE) { + mchunkptr rem = chunk_plus_offset(newp, nb); + set_inuse(m, newp, nb); + set_inuse(m, rem, rsize); + lj_alloc_free(m, chunk2mem(rem)); + } + } else if (next == m->top && oldsize + m->topsize > nb) { + /* Expand into top */ + size_t newsize = oldsize + m->topsize; + size_t newtopsize = newsize - nb; + mchunkptr newtop = chunk_plus_offset(oldp, nb); + set_inuse(m, oldp, nb); + newtop->head = newtopsize |PINUSE_BIT; + m->top = newtop; + m->topsize = newtopsize; + newp = oldp; + } + + if (newp != 0) { + return chunk2mem(newp); + } else { + void *newmem = lj_alloc_malloc(m, nsize); + if (newmem != 0) { + size_t oc = oldsize - overhead_for(oldp); + memcpy(newmem, ptr, oc < nsize ? oc : nsize); + lj_alloc_free(m, ptr); + } + return newmem; + } + } +} + +void *lj_alloc_f(void *msp, void *ptr, size_t osize, size_t nsize) +{ + (void)osize; + if (nsize == 0) { + return lj_alloc_free(msp, ptr); + } else if (ptr == NULL) { + return lj_alloc_malloc(msp, nsize); + } else { + return lj_alloc_realloc(msp, ptr, nsize); + } +} + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_alloc.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_alloc.h similarity index 100% rename from source/libs/luajit/LuaJIT-2.0.3/src/lj_alloc.h rename to source/libs/luajit/LuaJIT-2.0.4/src/lj_alloc.h diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_api.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_api.c new file mode 100644 index 000000000..3bedb39fd --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_api.c @@ -0,0 +1,1200 @@ +/* +** Public Lua/C API. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lj_api_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_debug.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_func.h" +#include "lj_udata.h" +#include "lj_meta.h" +#include "lj_state.h" +#include "lj_bc.h" +#include "lj_frame.h" +#include "lj_trace.h" +#include "lj_vm.h" +#include "lj_strscan.h" + +/* -- Common helper functions --------------------------------------------- */ + +#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base)) +#define api_checkvalidindex(L, i) api_check(L, (i) != niltv(L)) + +static TValue *index2adr(lua_State *L, int idx) +{ + if (idx > 0) { + TValue *o = L->base + (idx - 1); + return o < L->top ? o : niltv(L); + } else if (idx > LUA_REGISTRYINDEX) { + api_check(L, idx != 0 && -idx <= L->top - L->base); + return L->top + idx; + } else if (idx == LUA_GLOBALSINDEX) { + TValue *o = &G(L)->tmptv; + settabV(L, o, tabref(L->env)); + return o; + } else if (idx == LUA_REGISTRYINDEX) { + return registry(L); + } else { + GCfunc *fn = curr_func(L); + api_check(L, fn->c.gct == ~LJ_TFUNC && !isluafunc(fn)); + if (idx == LUA_ENVIRONINDEX) { + TValue *o = &G(L)->tmptv; + settabV(L, o, tabref(fn->c.env)); + return o; + } else { + idx = LUA_GLOBALSINDEX - idx; + return idx <= fn->c.nupvalues ? &fn->c.upvalue[idx-1] : niltv(L); + } + } +} + +static TValue *stkindex2adr(lua_State *L, int idx) +{ + if (idx > 0) { + TValue *o = L->base + (idx - 1); + return o < L->top ? o : niltv(L); + } else { + api_check(L, idx != 0 && -idx <= L->top - L->base); + return L->top + idx; + } +} + +static GCtab *getcurrenv(lua_State *L) +{ + GCfunc *fn = curr_func(L); + return fn->c.gct == ~LJ_TFUNC ? tabref(fn->c.env) : tabref(L->env); +} + +/* -- Miscellaneous API functions ----------------------------------------- */ + +LUA_API int lua_status(lua_State *L) +{ + return L->status; +} + +LUA_API int lua_checkstack(lua_State *L, int size) +{ + if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK) { + return 0; /* Stack overflow. */ + } else if (size > 0) { + lj_state_checkstack(L, (MSize)size); + } + return 1; +} + +LUALIB_API void luaL_checkstack(lua_State *L, int size, const char *msg) +{ + if (!lua_checkstack(L, size)) + lj_err_callerv(L, LJ_ERR_STKOVM, msg); +} + +LUA_API void lua_xmove(lua_State *from, lua_State *to, int n) +{ + TValue *f, *t; + if (from == to) return; + api_checknelems(from, n); + api_check(from, G(from) == G(to)); + lj_state_checkstack(to, (MSize)n); + f = from->top; + t = to->top = to->top + n; + while (--n >= 0) copyTV(to, --t, --f); + from->top = f; +} + +/* -- Stack manipulation -------------------------------------------------- */ + +LUA_API int lua_gettop(lua_State *L) +{ + return (int)(L->top - L->base); +} + +LUA_API void lua_settop(lua_State *L, int idx) +{ + if (idx >= 0) { + api_check(L, idx <= tvref(L->maxstack) - L->base); + if (L->base + idx > L->top) { + if (L->base + idx >= tvref(L->maxstack)) + lj_state_growstack(L, (MSize)idx - (MSize)(L->top - L->base)); + do { setnilV(L->top++); } while (L->top < L->base + idx); + } else { + L->top = L->base + idx; + } + } else { + api_check(L, -(idx+1) <= (L->top - L->base)); + L->top += idx+1; /* Shrinks top (idx < 0). */ + } +} + +LUA_API void lua_remove(lua_State *L, int idx) +{ + TValue *p = stkindex2adr(L, idx); + api_checkvalidindex(L, p); + while (++p < L->top) copyTV(L, p-1, p); + L->top--; +} + +LUA_API void lua_insert(lua_State *L, int idx) +{ + TValue *q, *p = stkindex2adr(L, idx); + api_checkvalidindex(L, p); + for (q = L->top; q > p; q--) copyTV(L, q, q-1); + copyTV(L, p, L->top); +} + +LUA_API void lua_replace(lua_State *L, int idx) +{ + api_checknelems(L, 1); + if (idx == LUA_GLOBALSINDEX) { + api_check(L, tvistab(L->top-1)); + /* NOBARRIER: A thread (i.e. L) is never black. */ + setgcref(L->env, obj2gco(tabV(L->top-1))); + } else if (idx == LUA_ENVIRONINDEX) { + GCfunc *fn = curr_func(L); + if (fn->c.gct != ~LJ_TFUNC) + lj_err_msg(L, LJ_ERR_NOENV); + api_check(L, tvistab(L->top-1)); + setgcref(fn->c.env, obj2gco(tabV(L->top-1))); + lj_gc_barrier(L, fn, L->top-1); + } else { + TValue *o = index2adr(L, idx); + api_checkvalidindex(L, o); + copyTV(L, o, L->top-1); + if (idx < LUA_GLOBALSINDEX) /* Need a barrier for upvalues. */ + lj_gc_barrier(L, curr_func(L), L->top-1); + } + L->top--; +} + +LUA_API void lua_pushvalue(lua_State *L, int idx) +{ + copyTV(L, L->top, index2adr(L, idx)); + incr_top(L); +} + +/* -- Stack getters ------------------------------------------------------- */ + +LUA_API int lua_type(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + if (tvisnumber(o)) { + return LUA_TNUMBER; +#if LJ_64 + } else if (tvislightud(o)) { + return LUA_TLIGHTUSERDATA; +#endif + } else if (o == niltv(L)) { + return LUA_TNONE; + } else { /* Magic internal/external tag conversion. ORDER LJ_T */ + uint32_t t = ~itype(o); +#if LJ_64 + int tt = (int)((U64x(75a06,98042110) >> 4*t) & 15u); +#else + int tt = (int)(((t < 8 ? 0x98042110u : 0x75a06u) >> 4*(t&7)) & 15u); +#endif + lua_assert(tt != LUA_TNIL || tvisnil(o)); + return tt; + } +} + +LUALIB_API void luaL_checktype(lua_State *L, int idx, int tt) +{ + if (lua_type(L, idx) != tt) + lj_err_argt(L, idx, tt); +} + +LUALIB_API void luaL_checkany(lua_State *L, int idx) +{ + if (index2adr(L, idx) == niltv(L)) + lj_err_arg(L, idx, LJ_ERR_NOVAL); +} + +LUA_API const char *lua_typename(lua_State *L, int t) +{ + UNUSED(L); + return lj_obj_typename[t+1]; +} + +LUA_API int lua_iscfunction(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + return tvisfunc(o) && !isluafunc(funcV(o)); +} + +LUA_API int lua_isnumber(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + TValue tmp; + return (tvisnumber(o) || (tvisstr(o) && lj_strscan_number(strV(o), &tmp))); +} + +LUA_API int lua_isstring(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + return (tvisstr(o) || tvisnumber(o)); +} + +LUA_API int lua_isuserdata(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + return (tvisudata(o) || tvislightud(o)); +} + +LUA_API int lua_rawequal(lua_State *L, int idx1, int idx2) +{ + cTValue *o1 = index2adr(L, idx1); + cTValue *o2 = index2adr(L, idx2); + return (o1 == niltv(L) || o2 == niltv(L)) ? 0 : lj_obj_equal(o1, o2); +} + +LUA_API int lua_equal(lua_State *L, int idx1, int idx2) +{ + cTValue *o1 = index2adr(L, idx1); + cTValue *o2 = index2adr(L, idx2); + if (tvisint(o1) && tvisint(o2)) { + return intV(o1) == intV(o2); + } else if (tvisnumber(o1) && tvisnumber(o2)) { + return numberVnum(o1) == numberVnum(o2); + } else if (itype(o1) != itype(o2)) { + return 0; + } else if (tvispri(o1)) { + return o1 != niltv(L) && o2 != niltv(L); +#if LJ_64 + } else if (tvislightud(o1)) { + return o1->u64 == o2->u64; +#endif + } else if (gcrefeq(o1->gcr, o2->gcr)) { + return 1; + } else if (!tvistabud(o1)) { + return 0; + } else { + TValue *base = lj_meta_equal(L, gcV(o1), gcV(o2), 0); + if ((uintptr_t)base <= 1) { + return (int)(uintptr_t)base; + } else { + L->top = base+2; + lj_vm_call(L, base, 1+1); + L->top -= 2; + return tvistruecond(L->top+1); + } + } +} + +LUA_API int lua_lessthan(lua_State *L, int idx1, int idx2) +{ + cTValue *o1 = index2adr(L, idx1); + cTValue *o2 = index2adr(L, idx2); + if (o1 == niltv(L) || o2 == niltv(L)) { + return 0; + } else if (tvisint(o1) && tvisint(o2)) { + return intV(o1) < intV(o2); + } else if (tvisnumber(o1) && tvisnumber(o2)) { + return numberVnum(o1) < numberVnum(o2); + } else { + TValue *base = lj_meta_comp(L, o1, o2, 0); + if ((uintptr_t)base <= 1) { + return (int)(uintptr_t)base; + } else { + L->top = base+2; + lj_vm_call(L, base, 1+1); + L->top -= 2; + return tvistruecond(L->top+1); + } + } +} + +LUA_API lua_Number lua_tonumber(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + TValue tmp; + if (LJ_LIKELY(tvisnumber(o))) + return numberVnum(o); + else if (tvisstr(o) && lj_strscan_num(strV(o), &tmp)) + return numV(&tmp); + else + return 0; +} + +LUALIB_API lua_Number luaL_checknumber(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + TValue tmp; + if (LJ_LIKELY(tvisnumber(o))) + return numberVnum(o); + else if (!(tvisstr(o) && lj_strscan_num(strV(o), &tmp))) + lj_err_argt(L, idx, LUA_TNUMBER); + return numV(&tmp); +} + +LUALIB_API lua_Number luaL_optnumber(lua_State *L, int idx, lua_Number def) +{ + cTValue *o = index2adr(L, idx); + TValue tmp; + if (LJ_LIKELY(tvisnumber(o))) + return numberVnum(o); + else if (tvisnil(o)) + return def; + else if (!(tvisstr(o) && lj_strscan_num(strV(o), &tmp))) + lj_err_argt(L, idx, LUA_TNUMBER); + return numV(&tmp); +} + +LUA_API lua_Integer lua_tointeger(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + TValue tmp; + lua_Number n; + if (LJ_LIKELY(tvisint(o))) { + return intV(o); + } else if (LJ_LIKELY(tvisnum(o))) { + n = numV(o); + } else { + if (!(tvisstr(o) && lj_strscan_number(strV(o), &tmp))) + return 0; + if (tvisint(&tmp)) + return (lua_Integer)intV(&tmp); + n = numV(&tmp); + } +#if LJ_64 + return (lua_Integer)n; +#else + return lj_num2int(n); +#endif +} + +LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + TValue tmp; + lua_Number n; + if (LJ_LIKELY(tvisint(o))) { + return intV(o); + } else if (LJ_LIKELY(tvisnum(o))) { + n = numV(o); + } else { + if (!(tvisstr(o) && lj_strscan_number(strV(o), &tmp))) + lj_err_argt(L, idx, LUA_TNUMBER); + if (tvisint(&tmp)) + return (lua_Integer)intV(&tmp); + n = numV(&tmp); + } +#if LJ_64 + return (lua_Integer)n; +#else + return lj_num2int(n); +#endif +} + +LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int idx, lua_Integer def) +{ + cTValue *o = index2adr(L, idx); + TValue tmp; + lua_Number n; + if (LJ_LIKELY(tvisint(o))) { + return intV(o); + } else if (LJ_LIKELY(tvisnum(o))) { + n = numV(o); + } else if (tvisnil(o)) { + return def; + } else { + if (!(tvisstr(o) && lj_strscan_number(strV(o), &tmp))) + lj_err_argt(L, idx, LUA_TNUMBER); + if (tvisint(&tmp)) + return (lua_Integer)intV(&tmp); + n = numV(&tmp); + } +#if LJ_64 + return (lua_Integer)n; +#else + return lj_num2int(n); +#endif +} + +LUA_API int lua_toboolean(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + return tvistruecond(o); +} + +LUA_API const char *lua_tolstring(lua_State *L, int idx, size_t *len) +{ + TValue *o = index2adr(L, idx); + GCstr *s; + if (LJ_LIKELY(tvisstr(o))) { + s = strV(o); + } else if (tvisnumber(o)) { + lj_gc_check(L); + o = index2adr(L, idx); /* GC may move the stack. */ + s = lj_str_fromnumber(L, o); + setstrV(L, o, s); + } else { + if (len != NULL) *len = 0; + return NULL; + } + if (len != NULL) *len = s->len; + return strdata(s); +} + +LUALIB_API const char *luaL_checklstring(lua_State *L, int idx, size_t *len) +{ + TValue *o = index2adr(L, idx); + GCstr *s; + if (LJ_LIKELY(tvisstr(o))) { + s = strV(o); + } else if (tvisnumber(o)) { + lj_gc_check(L); + o = index2adr(L, idx); /* GC may move the stack. */ + s = lj_str_fromnumber(L, o); + setstrV(L, o, s); + } else { + lj_err_argt(L, idx, LUA_TSTRING); + } + if (len != NULL) *len = s->len; + return strdata(s); +} + +LUALIB_API const char *luaL_optlstring(lua_State *L, int idx, + const char *def, size_t *len) +{ + TValue *o = index2adr(L, idx); + GCstr *s; + if (LJ_LIKELY(tvisstr(o))) { + s = strV(o); + } else if (tvisnil(o)) { + if (len != NULL) *len = def ? strlen(def) : 0; + return def; + } else if (tvisnumber(o)) { + lj_gc_check(L); + o = index2adr(L, idx); /* GC may move the stack. */ + s = lj_str_fromnumber(L, o); + setstrV(L, o, s); + } else { + lj_err_argt(L, idx, LUA_TSTRING); + } + if (len != NULL) *len = s->len; + return strdata(s); +} + +LUALIB_API int luaL_checkoption(lua_State *L, int idx, const char *def, + const char *const lst[]) +{ + ptrdiff_t i; + const char *s = lua_tolstring(L, idx, NULL); + if (s == NULL && (s = def) == NULL) + lj_err_argt(L, idx, LUA_TSTRING); + for (i = 0; lst[i]; i++) + if (strcmp(lst[i], s) == 0) + return (int)i; + lj_err_argv(L, idx, LJ_ERR_INVOPTM, s); +} + +LUA_API size_t lua_objlen(lua_State *L, int idx) +{ + TValue *o = index2adr(L, idx); + if (tvisstr(o)) { + return strV(o)->len; + } else if (tvistab(o)) { + return (size_t)lj_tab_len(tabV(o)); + } else if (tvisudata(o)) { + return udataV(o)->len; + } else if (tvisnumber(o)) { + GCstr *s = lj_str_fromnumber(L, o); + setstrV(L, o, s); + return s->len; + } else { + return 0; + } +} + +LUA_API lua_CFunction lua_tocfunction(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + if (tvisfunc(o)) { + BCOp op = bc_op(*mref(funcV(o)->c.pc, BCIns)); + if (op == BC_FUNCC || op == BC_FUNCCW) + return funcV(o)->c.f; + } + return NULL; +} + +LUA_API void *lua_touserdata(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + if (tvisudata(o)) + return uddata(udataV(o)); + else if (tvislightud(o)) + return lightudV(o); + else + return NULL; +} + +LUA_API lua_State *lua_tothread(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + return (!tvisthread(o)) ? NULL : threadV(o); +} + +LUA_API const void *lua_topointer(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + if (tvisudata(o)) + return uddata(udataV(o)); + else if (tvislightud(o)) + return lightudV(o); + else if (tviscdata(o)) + return cdataptr(cdataV(o)); + else if (tvisgcv(o)) + return gcV(o); + else + return NULL; +} + +/* -- Stack setters (object creation) ------------------------------------- */ + +LUA_API void lua_pushnil(lua_State *L) +{ + setnilV(L->top); + incr_top(L); +} + +LUA_API void lua_pushnumber(lua_State *L, lua_Number n) +{ + setnumV(L->top, n); + if (LJ_UNLIKELY(tvisnan(L->top))) + setnanV(L->top); /* Canonicalize injected NaNs. */ + incr_top(L); +} + +LUA_API void lua_pushinteger(lua_State *L, lua_Integer n) +{ + setintptrV(L->top, n); + incr_top(L); +} + +LUA_API void lua_pushlstring(lua_State *L, const char *str, size_t len) +{ + GCstr *s; + lj_gc_check(L); + s = lj_str_new(L, str, len); + setstrV(L, L->top, s); + incr_top(L); +} + +LUA_API void lua_pushstring(lua_State *L, const char *str) +{ + if (str == NULL) { + setnilV(L->top); + } else { + GCstr *s; + lj_gc_check(L); + s = lj_str_newz(L, str); + setstrV(L, L->top, s); + } + incr_top(L); +} + +LUA_API const char *lua_pushvfstring(lua_State *L, const char *fmt, + va_list argp) +{ + lj_gc_check(L); + return lj_str_pushvf(L, fmt, argp); +} + +LUA_API const char *lua_pushfstring(lua_State *L, const char *fmt, ...) +{ + const char *ret; + va_list argp; + lj_gc_check(L); + va_start(argp, fmt); + ret = lj_str_pushvf(L, fmt, argp); + va_end(argp); + return ret; +} + +LUA_API void lua_pushcclosure(lua_State *L, lua_CFunction f, int n) +{ + GCfunc *fn; + lj_gc_check(L); + api_checknelems(L, n); + fn = lj_func_newC(L, (MSize)n, getcurrenv(L)); + fn->c.f = f; + L->top -= n; + while (n--) + copyTV(L, &fn->c.upvalue[n], L->top+n); + setfuncV(L, L->top, fn); + lua_assert(iswhite(obj2gco(fn))); + incr_top(L); +} + +LUA_API void lua_pushboolean(lua_State *L, int b) +{ + setboolV(L->top, (b != 0)); + incr_top(L); +} + +LUA_API void lua_pushlightuserdata(lua_State *L, void *p) +{ + setlightudV(L->top, checklightudptr(L, p)); + incr_top(L); +} + +LUA_API void lua_createtable(lua_State *L, int narray, int nrec) +{ + GCtab *t; + lj_gc_check(L); + t = lj_tab_new(L, (uint32_t)(narray > 0 ? narray+1 : 0), hsize2hbits(nrec)); + settabV(L, L->top, t); + incr_top(L); +} + +LUALIB_API int luaL_newmetatable(lua_State *L, const char *tname) +{ + GCtab *regt = tabV(registry(L)); + TValue *tv = lj_tab_setstr(L, regt, lj_str_newz(L, tname)); + if (tvisnil(tv)) { + GCtab *mt = lj_tab_new(L, 0, 1); + settabV(L, tv, mt); + settabV(L, L->top++, mt); + lj_gc_anybarriert(L, regt); + return 1; + } else { + copyTV(L, L->top++, tv); + return 0; + } +} + +LUA_API int lua_pushthread(lua_State *L) +{ + setthreadV(L, L->top, L); + incr_top(L); + return (mainthread(G(L)) == L); +} + +LUA_API lua_State *lua_newthread(lua_State *L) +{ + lua_State *L1; + lj_gc_check(L); + L1 = lj_state_new(L); + setthreadV(L, L->top, L1); + incr_top(L); + return L1; +} + +LUA_API void *lua_newuserdata(lua_State *L, size_t size) +{ + GCudata *ud; + lj_gc_check(L); + if (size > LJ_MAX_UDATA) + lj_err_msg(L, LJ_ERR_UDATAOV); + ud = lj_udata_new(L, (MSize)size, getcurrenv(L)); + setudataV(L, L->top, ud); + incr_top(L); + return uddata(ud); +} + +LUA_API void lua_concat(lua_State *L, int n) +{ + api_checknelems(L, n); + if (n >= 2) { + n--; + do { + TValue *top = lj_meta_cat(L, L->top-1, -n); + if (top == NULL) { + L->top -= n; + break; + } + n -= (int)(L->top - top); + L->top = top+2; + lj_vm_call(L, top, 1+1); + L->top--; + copyTV(L, L->top-1, L->top); + } while (--n > 0); + } else if (n == 0) { /* Push empty string. */ + setstrV(L, L->top, &G(L)->strempty); + incr_top(L); + } + /* else n == 1: nothing to do. */ +} + +/* -- Object getters ------------------------------------------------------ */ + +LUA_API void lua_gettable(lua_State *L, int idx) +{ + cTValue *v, *t = index2adr(L, idx); + api_checkvalidindex(L, t); + v = lj_meta_tget(L, t, L->top-1); + if (v == NULL) { + L->top += 2; + lj_vm_call(L, L->top-2, 1+1); + L->top -= 2; + v = L->top+1; + } + copyTV(L, L->top-1, v); +} + +LUA_API void lua_getfield(lua_State *L, int idx, const char *k) +{ + cTValue *v, *t = index2adr(L, idx); + TValue key; + api_checkvalidindex(L, t); + setstrV(L, &key, lj_str_newz(L, k)); + v = lj_meta_tget(L, t, &key); + if (v == NULL) { + L->top += 2; + lj_vm_call(L, L->top-2, 1+1); + L->top -= 2; + v = L->top+1; + } + copyTV(L, L->top, v); + incr_top(L); +} + +LUA_API void lua_rawget(lua_State *L, int idx) +{ + cTValue *t = index2adr(L, idx); + api_check(L, tvistab(t)); + copyTV(L, L->top-1, lj_tab_get(L, tabV(t), L->top-1)); +} + +LUA_API void lua_rawgeti(lua_State *L, int idx, int n) +{ + cTValue *v, *t = index2adr(L, idx); + api_check(L, tvistab(t)); + v = lj_tab_getint(tabV(t), n); + if (v) { + copyTV(L, L->top, v); + } else { + setnilV(L->top); + } + incr_top(L); +} + +LUA_API int lua_getmetatable(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + GCtab *mt = NULL; + if (tvistab(o)) + mt = tabref(tabV(o)->metatable); + else if (tvisudata(o)) + mt = tabref(udataV(o)->metatable); + else + mt = tabref(basemt_obj(G(L), o)); + if (mt == NULL) + return 0; + settabV(L, L->top, mt); + incr_top(L); + return 1; +} + +LUALIB_API int luaL_getmetafield(lua_State *L, int idx, const char *field) +{ + if (lua_getmetatable(L, idx)) { + cTValue *tv = lj_tab_getstr(tabV(L->top-1), lj_str_newz(L, field)); + if (tv && !tvisnil(tv)) { + copyTV(L, L->top-1, tv); + return 1; + } + L->top--; + } + return 0; +} + +LUA_API void lua_getfenv(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + api_checkvalidindex(L, o); + if (tvisfunc(o)) { + settabV(L, L->top, tabref(funcV(o)->c.env)); + } else if (tvisudata(o)) { + settabV(L, L->top, tabref(udataV(o)->env)); + } else if (tvisthread(o)) { + settabV(L, L->top, tabref(threadV(o)->env)); + } else { + setnilV(L->top); + } + incr_top(L); +} + +LUA_API int lua_next(lua_State *L, int idx) +{ + cTValue *t = index2adr(L, idx); + int more; + api_check(L, tvistab(t)); + more = lj_tab_next(L, tabV(t), L->top-1); + if (more) { + incr_top(L); /* Return new key and value slot. */ + } else { /* End of traversal. */ + L->top--; /* Remove key slot. */ + } + return more; +} + +LUA_API const char *lua_getupvalue(lua_State *L, int idx, int n) +{ + TValue *val; + const char *name = lj_debug_uvnamev(index2adr(L, idx), (uint32_t)(n-1), &val); + if (name) { + copyTV(L, L->top, val); + incr_top(L); + } + return name; +} + +LUA_API void *lua_upvalueid(lua_State *L, int idx, int n) +{ + GCfunc *fn = funcV(index2adr(L, idx)); + n--; + api_check(L, (uint32_t)n < fn->l.nupvalues); + return isluafunc(fn) ? (void *)gcref(fn->l.uvptr[n]) : + (void *)&fn->c.upvalue[n]; +} + +LUA_API void lua_upvaluejoin(lua_State *L, int idx1, int n1, int idx2, int n2) +{ + GCfunc *fn1 = funcV(index2adr(L, idx1)); + GCfunc *fn2 = funcV(index2adr(L, idx2)); + n1--; n2--; + api_check(L, isluafunc(fn1) && (uint32_t)n1 < fn1->l.nupvalues); + api_check(L, isluafunc(fn2) && (uint32_t)n2 < fn2->l.nupvalues); + setgcrefr(fn1->l.uvptr[n1], fn2->l.uvptr[n2]); + lj_gc_objbarrier(L, fn1, gcref(fn1->l.uvptr[n1])); +} + +LUALIB_API void *luaL_checkudata(lua_State *L, int idx, const char *tname) +{ + cTValue *o = index2adr(L, idx); + if (tvisudata(o)) { + GCudata *ud = udataV(o); + cTValue *tv = lj_tab_getstr(tabV(registry(L)), lj_str_newz(L, tname)); + if (tv && tvistab(tv) && tabV(tv) == tabref(ud->metatable)) + return uddata(ud); + } + lj_err_argtype(L, idx, tname); + return NULL; /* unreachable */ +} + +/* -- Object setters ------------------------------------------------------ */ + +LUA_API void lua_settable(lua_State *L, int idx) +{ + TValue *o; + cTValue *t = index2adr(L, idx); + api_checknelems(L, 2); + api_checkvalidindex(L, t); + o = lj_meta_tset(L, t, L->top-2); + if (o) { + /* NOBARRIER: lj_meta_tset ensures the table is not black. */ + copyTV(L, o, L->top-1); + L->top -= 2; + } else { + L->top += 3; + copyTV(L, L->top-1, L->top-6); + lj_vm_call(L, L->top-3, 0+1); + L->top -= 3; + } +} + +LUA_API void lua_setfield(lua_State *L, int idx, const char *k) +{ + TValue *o; + TValue key; + cTValue *t = index2adr(L, idx); + api_checknelems(L, 1); + api_checkvalidindex(L, t); + setstrV(L, &key, lj_str_newz(L, k)); + o = lj_meta_tset(L, t, &key); + if (o) { + L->top--; + /* NOBARRIER: lj_meta_tset ensures the table is not black. */ + copyTV(L, o, L->top); + } else { + L->top += 3; + copyTV(L, L->top-1, L->top-6); + lj_vm_call(L, L->top-3, 0+1); + L->top -= 2; + } +} + +LUA_API void lua_rawset(lua_State *L, int idx) +{ + GCtab *t = tabV(index2adr(L, idx)); + TValue *dst, *key; + api_checknelems(L, 2); + key = L->top-2; + dst = lj_tab_set(L, t, key); + copyTV(L, dst, key+1); + lj_gc_anybarriert(L, t); + L->top = key; +} + +LUA_API void lua_rawseti(lua_State *L, int idx, int n) +{ + GCtab *t = tabV(index2adr(L, idx)); + TValue *dst, *src; + api_checknelems(L, 1); + dst = lj_tab_setint(L, t, n); + src = L->top-1; + copyTV(L, dst, src); + lj_gc_barriert(L, t, dst); + L->top = src; +} + +LUA_API int lua_setmetatable(lua_State *L, int idx) +{ + global_State *g; + GCtab *mt; + cTValue *o = index2adr(L, idx); + api_checknelems(L, 1); + api_checkvalidindex(L, o); + if (tvisnil(L->top-1)) { + mt = NULL; + } else { + api_check(L, tvistab(L->top-1)); + mt = tabV(L->top-1); + } + g = G(L); + if (tvistab(o)) { + setgcref(tabV(o)->metatable, obj2gco(mt)); + if (mt) + lj_gc_objbarriert(L, tabV(o), mt); + } else if (tvisudata(o)) { + setgcref(udataV(o)->metatable, obj2gco(mt)); + if (mt) + lj_gc_objbarrier(L, udataV(o), mt); + } else { + /* Flush cache, since traces specialize to basemt. But not during __gc. */ + if (lj_trace_flushall(L)) + lj_err_caller(L, LJ_ERR_NOGCMM); + if (tvisbool(o)) { + /* NOBARRIER: basemt is a GC root. */ + setgcref(basemt_it(g, LJ_TTRUE), obj2gco(mt)); + setgcref(basemt_it(g, LJ_TFALSE), obj2gco(mt)); + } else { + /* NOBARRIER: basemt is a GC root. */ + setgcref(basemt_obj(g, o), obj2gco(mt)); + } + } + L->top--; + return 1; +} + +LUA_API int lua_setfenv(lua_State *L, int idx) +{ + cTValue *o = index2adr(L, idx); + GCtab *t; + api_checknelems(L, 1); + api_checkvalidindex(L, o); + api_check(L, tvistab(L->top-1)); + t = tabV(L->top-1); + if (tvisfunc(o)) { + setgcref(funcV(o)->c.env, obj2gco(t)); + } else if (tvisudata(o)) { + setgcref(udataV(o)->env, obj2gco(t)); + } else if (tvisthread(o)) { + setgcref(threadV(o)->env, obj2gco(t)); + } else { + L->top--; + return 0; + } + lj_gc_objbarrier(L, gcV(o), t); + L->top--; + return 1; +} + +LUA_API const char *lua_setupvalue(lua_State *L, int idx, int n) +{ + cTValue *f = index2adr(L, idx); + TValue *val; + const char *name; + api_checknelems(L, 1); + name = lj_debug_uvnamev(f, (uint32_t)(n-1), &val); + if (name) { + L->top--; + copyTV(L, val, L->top); + lj_gc_barrier(L, funcV(f), L->top); + } + return name; +} + +/* -- Calls --------------------------------------------------------------- */ + +LUA_API void lua_call(lua_State *L, int nargs, int nresults) +{ + api_check(L, L->status == 0 || L->status == LUA_ERRERR); + api_checknelems(L, nargs+1); + lj_vm_call(L, L->top - nargs, nresults+1); +} + +LUA_API int lua_pcall(lua_State *L, int nargs, int nresults, int errfunc) +{ + global_State *g = G(L); + uint8_t oldh = hook_save(g); + ptrdiff_t ef; + int status; + api_check(L, L->status == 0 || L->status == LUA_ERRERR); + api_checknelems(L, nargs+1); + if (errfunc == 0) { + ef = 0; + } else { + cTValue *o = stkindex2adr(L, errfunc); + api_checkvalidindex(L, o); + ef = savestack(L, o); + } + status = lj_vm_pcall(L, L->top - nargs, nresults+1, ef); + if (status) hook_restore(g, oldh); + return status; +} + +static TValue *cpcall(lua_State *L, lua_CFunction func, void *ud) +{ + GCfunc *fn = lj_func_newC(L, 0, getcurrenv(L)); + fn->c.f = func; + setfuncV(L, L->top, fn); + setlightudV(L->top+1, checklightudptr(L, ud)); + cframe_nres(L->cframe) = 1+0; /* Zero results. */ + L->top += 2; + return L->top-1; /* Now call the newly allocated C function. */ +} + +LUA_API int lua_cpcall(lua_State *L, lua_CFunction func, void *ud) +{ + global_State *g = G(L); + uint8_t oldh = hook_save(g); + int status; + api_check(L, L->status == 0 || L->status == LUA_ERRERR); + status = lj_vm_cpcall(L, func, ud, cpcall); + if (status) hook_restore(g, oldh); + return status; +} + +LUALIB_API int luaL_callmeta(lua_State *L, int idx, const char *field) +{ + if (luaL_getmetafield(L, idx, field)) { + TValue *base = L->top--; + copyTV(L, base, index2adr(L, idx)); + L->top = base+1; + lj_vm_call(L, base, 1+1); + return 1; + } + return 0; +} + +/* -- Coroutine yield and resume ------------------------------------------ */ + +LUA_API int lua_yield(lua_State *L, int nresults) +{ + void *cf = L->cframe; + global_State *g = G(L); + if (cframe_canyield(cf)) { + cf = cframe_raw(cf); + if (!hook_active(g)) { /* Regular yield: move results down if needed. */ + cTValue *f = L->top - nresults; + if (f > L->base) { + TValue *t = L->base; + while (--nresults >= 0) copyTV(L, t++, f++); + L->top = t; + } + L->cframe = NULL; + L->status = LUA_YIELD; + return -1; + } else { /* Yield from hook: add a pseudo-frame. */ + TValue *top = L->top; + hook_leave(g); + top->u64 = cframe_multres(cf); + setcont(top+1, lj_cont_hook); + setframe_pc(top+1, cframe_pc(cf)-1); + setframe_gc(top+2, obj2gco(L)); + setframe_ftsz(top+2, (int)((char *)(top+3)-(char *)L->base)+FRAME_CONT); + L->top = L->base = top+3; +#if LJ_TARGET_X64 + lj_err_throw(L, LUA_YIELD); +#else + L->cframe = NULL; + L->status = LUA_YIELD; + lj_vm_unwind_c(cf, LUA_YIELD); +#endif + } + } + lj_err_msg(L, LJ_ERR_CYIELD); + return 0; /* unreachable */ +} + +LUA_API int lua_resume(lua_State *L, int nargs) +{ + if (L->cframe == NULL && L->status <= LUA_YIELD) + return lj_vm_resume(L, L->top - nargs, 0, 0); + L->top = L->base; + setstrV(L, L->top, lj_err_str(L, LJ_ERR_COSUSP)); + incr_top(L); + return LUA_ERRRUN; +} + +/* -- GC and memory management -------------------------------------------- */ + +LUA_API int lua_gc(lua_State *L, int what, int data) +{ + global_State *g = G(L); + int res = 0; + switch (what) { + case LUA_GCSTOP: + g->gc.threshold = LJ_MAX_MEM; + break; + case LUA_GCRESTART: + g->gc.threshold = data == -1 ? (g->gc.total/100)*g->gc.pause : g->gc.total; + break; + case LUA_GCCOLLECT: + lj_gc_fullgc(L); + break; + case LUA_GCCOUNT: + res = (int)(g->gc.total >> 10); + break; + case LUA_GCCOUNTB: + res = (int)(g->gc.total & 0x3ff); + break; + case LUA_GCSTEP: { + MSize a = (MSize)data << 10; + g->gc.threshold = (a <= g->gc.total) ? (g->gc.total - a) : 0; + while (g->gc.total >= g->gc.threshold) + if (lj_gc_step(L) > 0) { + res = 1; + break; + } + break; + } + case LUA_GCSETPAUSE: + res = (int)(g->gc.pause); + g->gc.pause = (MSize)data; + break; + case LUA_GCSETSTEPMUL: + res = (int)(g->gc.stepmul); + g->gc.stepmul = (MSize)data; + break; + default: + res = -1; /* Invalid option. */ + } + return res; +} + +LUA_API lua_Alloc lua_getallocf(lua_State *L, void **ud) +{ + global_State *g = G(L); + if (ud) *ud = g->allocd; + return g->allocf; +} + +LUA_API void lua_setallocf(lua_State *L, lua_Alloc f, void *ud) +{ + global_State *g = G(L); + g->allocd = ud; + g->allocf = f; +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_arch.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_arch.h new file mode 100644 index 000000000..20d1eb118 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_arch.h @@ -0,0 +1,437 @@ +/* +** Target architecture selection. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_ARCH_H +#define _LJ_ARCH_H + +#include "lua.h" + +/* Target endianess. */ +#define LUAJIT_LE 0 +#define LUAJIT_BE 1 + +/* Target architectures. */ +#define LUAJIT_ARCH_X86 1 +#define LUAJIT_ARCH_x86 1 +#define LUAJIT_ARCH_X64 2 +#define LUAJIT_ARCH_x64 2 +#define LUAJIT_ARCH_ARM 3 +#define LUAJIT_ARCH_arm 3 +#define LUAJIT_ARCH_PPC 4 +#define LUAJIT_ARCH_ppc 4 +#define LUAJIT_ARCH_PPCSPE 5 +#define LUAJIT_ARCH_ppcspe 5 +#define LUAJIT_ARCH_MIPS 6 +#define LUAJIT_ARCH_mips 6 + +/* Target OS. */ +#define LUAJIT_OS_OTHER 0 +#define LUAJIT_OS_WINDOWS 1 +#define LUAJIT_OS_LINUX 2 +#define LUAJIT_OS_OSX 3 +#define LUAJIT_OS_BSD 4 +#define LUAJIT_OS_POSIX 5 + +/* Select native target if no target defined. */ +#ifndef LUAJIT_TARGET + +#if defined(__i386) || defined(__i386__) || defined(_M_IX86) +#define LUAJIT_TARGET LUAJIT_ARCH_X86 +#elif defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) +#define LUAJIT_TARGET LUAJIT_ARCH_X64 +#elif defined(__arm__) || defined(__arm) || defined(__ARM__) || defined(__ARM) +#define LUAJIT_TARGET LUAJIT_ARCH_ARM +#elif defined(__ppc__) || defined(__ppc) || defined(__PPC__) || defined(__PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__POWERPC) || defined(_M_PPC) +#ifdef __NO_FPRS__ +#define LUAJIT_TARGET LUAJIT_ARCH_PPCSPE +#else +#define LUAJIT_TARGET LUAJIT_ARCH_PPC +#endif +#elif defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(__MIPS) +#define LUAJIT_TARGET LUAJIT_ARCH_MIPS +#else +#error "No support for this architecture (yet)" +#endif + +#endif + +/* Select native OS if no target OS defined. */ +#ifndef LUAJIT_OS + +#if defined(_WIN32) && !defined(_XBOX_VER) +#define LUAJIT_OS LUAJIT_OS_WINDOWS +#elif defined(__linux__) +#define LUAJIT_OS LUAJIT_OS_LINUX +#elif defined(__MACH__) && defined(__APPLE__) +#define LUAJIT_OS LUAJIT_OS_OSX +#elif (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ + defined(__NetBSD__) || defined(__OpenBSD__) || \ + defined(__DragonFly__)) && !defined(__ORBIS__) +#define LUAJIT_OS LUAJIT_OS_BSD +#elif (defined(__sun__) && defined(__svr4__)) || defined(__CYGWIN__) +#define LUAJIT_OS LUAJIT_OS_POSIX +#else +#define LUAJIT_OS LUAJIT_OS_OTHER +#endif + +#endif + +/* Set target OS properties. */ +#if LUAJIT_OS == LUAJIT_OS_WINDOWS +#define LJ_OS_NAME "Windows" +#elif LUAJIT_OS == LUAJIT_OS_LINUX +#define LJ_OS_NAME "Linux" +#elif LUAJIT_OS == LUAJIT_OS_OSX +#define LJ_OS_NAME "OSX" +#elif LUAJIT_OS == LUAJIT_OS_BSD +#define LJ_OS_NAME "BSD" +#elif LUAJIT_OS == LUAJIT_OS_POSIX +#define LJ_OS_NAME "POSIX" +#else +#define LJ_OS_NAME "Other" +#endif + +#define LJ_TARGET_WINDOWS (LUAJIT_OS == LUAJIT_OS_WINDOWS) +#define LJ_TARGET_LINUX (LUAJIT_OS == LUAJIT_OS_LINUX) +#define LJ_TARGET_OSX (LUAJIT_OS == LUAJIT_OS_OSX) +#define LJ_TARGET_IOS (LJ_TARGET_OSX && LUAJIT_TARGET == LUAJIT_ARCH_ARM) +#define LJ_TARGET_POSIX (LUAJIT_OS > LUAJIT_OS_WINDOWS) +#define LJ_TARGET_DLOPEN LJ_TARGET_POSIX + +#ifdef __CELLOS_LV2__ +#define LJ_TARGET_PS3 1 +#define LJ_TARGET_CONSOLE 1 +#endif + +#ifdef __ORBIS__ +#define LJ_TARGET_PS4 1 +#define LJ_TARGET_CONSOLE 1 +#undef NULL +#define NULL ((void*)0) +#endif + +#ifdef __psp2__ +#define LJ_TARGET_PSVITA 1 +#define LJ_TARGET_CONSOLE 1 +#endif + +#if _XBOX_VER >= 200 +#define LJ_TARGET_XBOX360 1 +#define LJ_TARGET_CONSOLE 1 +#endif + +#define LJ_NUMMODE_SINGLE 0 /* Single-number mode only. */ +#define LJ_NUMMODE_SINGLE_DUAL 1 /* Default to single-number mode. */ +#define LJ_NUMMODE_DUAL 2 /* Dual-number mode only. */ +#define LJ_NUMMODE_DUAL_SINGLE 3 /* Default to dual-number mode. */ + +/* Set target architecture properties. */ +#if LUAJIT_TARGET == LUAJIT_ARCH_X86 + +#define LJ_ARCH_NAME "x86" +#define LJ_ARCH_BITS 32 +#define LJ_ARCH_ENDIAN LUAJIT_LE +#if LJ_TARGET_WINDOWS || __CYGWIN__ +#define LJ_ABI_WIN 1 +#else +#define LJ_ABI_WIN 0 +#endif +#define LJ_TARGET_X86 1 +#define LJ_TARGET_X86ORX64 1 +#define LJ_TARGET_EHRETREG 0 +#define LJ_TARGET_MASKSHIFT 1 +#define LJ_TARGET_MASKROT 1 +#define LJ_TARGET_UNALIGNED 1 +#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE_DUAL + +#elif LUAJIT_TARGET == LUAJIT_ARCH_X64 + +#define LJ_ARCH_NAME "x64" +#define LJ_ARCH_BITS 64 +#define LJ_ARCH_ENDIAN LUAJIT_LE +#define LJ_ABI_WIN LJ_TARGET_WINDOWS +#define LJ_TARGET_X64 1 +#define LJ_TARGET_X86ORX64 1 +#define LJ_TARGET_EHRETREG 0 +#define LJ_TARGET_JUMPRANGE 31 /* +-2^31 = +-2GB */ +#define LJ_TARGET_MASKSHIFT 1 +#define LJ_TARGET_MASKROT 1 +#define LJ_TARGET_UNALIGNED 1 +#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE_DUAL + +#elif LUAJIT_TARGET == LUAJIT_ARCH_ARM + +#define LJ_ARCH_NAME "arm" +#define LJ_ARCH_BITS 32 +#define LJ_ARCH_ENDIAN LUAJIT_LE +#if !defined(LJ_ARCH_HASFPU) && __SOFTFP__ +#define LJ_ARCH_HASFPU 0 +#endif +#if !defined(LJ_ABI_SOFTFP) && !__ARM_PCS_VFP +#define LJ_ABI_SOFTFP 1 +#endif +#define LJ_ABI_EABI 1 +#define LJ_TARGET_ARM 1 +#define LJ_TARGET_EHRETREG 0 +#define LJ_TARGET_JUMPRANGE 25 /* +-2^25 = +-32MB */ +#define LJ_TARGET_MASKSHIFT 0 +#define LJ_TARGET_MASKROT 1 +#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */ +#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL + +#if __ARM_ARCH____ARM_ARCH_8__ || __ARM_ARCH_8A__ +#define LJ_ARCH_VERSION 80 +#elif __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH_7S__ || __ARM_ARCH_7VE__ +#define LJ_ARCH_VERSION 70 +#elif __ARM_ARCH_6T2__ +#define LJ_ARCH_VERSION 61 +#elif __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6K__ || __ARM_ARCH_6Z__ || __ARM_ARCH_6ZK__ +#define LJ_ARCH_VERSION 60 +#else +#define LJ_ARCH_VERSION 50 +#endif + +#elif LUAJIT_TARGET == LUAJIT_ARCH_PPC + +#define LJ_ARCH_NAME "ppc" +#if _LP64 +#define LJ_ARCH_BITS 64 +#else +#define LJ_ARCH_BITS 32 +#endif +#define LJ_ARCH_ENDIAN LUAJIT_BE +#define LJ_TARGET_PPC 1 +#define LJ_TARGET_EHRETREG 3 +#define LJ_TARGET_JUMPRANGE 25 /* +-2^25 = +-32MB */ +#define LJ_TARGET_MASKSHIFT 0 +#define LJ_TARGET_MASKROT 1 +#define LJ_TARGET_UNIFYROT 1 /* Want only IR_BROL. */ +#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL_SINGLE + +#if _ARCH_PWR7 +#define LJ_ARCH_VERSION 70 +#elif _ARCH_PWR6 +#define LJ_ARCH_VERSION 60 +#elif _ARCH_PWR5X +#define LJ_ARCH_VERSION 51 +#elif _ARCH_PWR5 +#define LJ_ARCH_VERSION 50 +#elif _ARCH_PWR4 +#define LJ_ARCH_VERSION 40 +#else +#define LJ_ARCH_VERSION 0 +#endif +#if __PPC64__ || __powerpc64__ || LJ_TARGET_CONSOLE +#define LJ_ARCH_PPC64 1 +#define LJ_ARCH_NOFFI 1 +#endif +#if _ARCH_PPCSQ +#define LJ_ARCH_SQRT 1 +#endif +#if _ARCH_PWR5X +#define LJ_ARCH_ROUND 1 +#endif +#if __PPU__ +#define LJ_ARCH_CELL 1 +#endif +#if LJ_TARGET_XBOX360 +#define LJ_ARCH_XENON 1 +#endif + +#elif LUAJIT_TARGET == LUAJIT_ARCH_PPCSPE + +#define LJ_ARCH_NAME "ppcspe" +#define LJ_ARCH_BITS 32 +#define LJ_ARCH_ENDIAN LUAJIT_BE +#ifndef LJ_ABI_SOFTFP +#define LJ_ABI_SOFTFP 1 +#endif +#define LJ_ABI_EABI 1 +#define LJ_TARGET_PPCSPE 1 +#define LJ_TARGET_EHRETREG 3 +#define LJ_TARGET_JUMPRANGE 25 /* +-2^25 = +-32MB */ +#define LJ_TARGET_MASKSHIFT 0 +#define LJ_TARGET_MASKROT 1 +#define LJ_TARGET_UNIFYROT 1 /* Want only IR_BROL. */ +#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE +#define LJ_ARCH_NOFFI 1 /* NYI: comparisons, calls. */ +#define LJ_ARCH_NOJIT 1 + +#elif LUAJIT_TARGET == LUAJIT_ARCH_MIPS + +#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) +#define LJ_ARCH_NAME "mipsel" +#define LJ_ARCH_ENDIAN LUAJIT_LE +#else +#define LJ_ARCH_NAME "mips" +#define LJ_ARCH_ENDIAN LUAJIT_BE +#endif +#define LJ_ARCH_BITS 32 +#define LJ_TARGET_MIPS 1 +#define LJ_TARGET_EHRETREG 4 +#define LJ_TARGET_JUMPRANGE 27 /* 2*2^27 = 256MB-aligned region */ +#define LJ_TARGET_MASKSHIFT 1 +#define LJ_TARGET_MASKROT 1 +#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */ +#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE + +#if _MIPS_ARCH_MIPS32R2 +#define LJ_ARCH_VERSION 20 +#else +#define LJ_ARCH_VERSION 10 +#endif + +#else +#error "No target architecture defined" +#endif + +#ifndef LJ_PAGESIZE +#define LJ_PAGESIZE 4096 +#endif + +/* Check for minimum required compiler versions. */ +#if defined(__GNUC__) +#if LJ_TARGET_X86 +#if (__GNUC__ < 3) || ((__GNUC__ == 3) && __GNUC_MINOR__ < 4) +#error "Need at least GCC 3.4 or newer" +#endif +#elif LJ_TARGET_X64 +#if __GNUC__ < 4 +#error "Need at least GCC 4.0 or newer" +#endif +#elif LJ_TARGET_ARM || LJ_TARGET_PPC +#if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 2) +#error "Need at least GCC 4.2 or newer" +#endif +#elif !LJ_TARGET_PS3 +#if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 3) +#error "Need at least GCC 4.3 or newer" +#endif +#endif +#endif + +/* Check target-specific constraints. */ +#ifndef _BUILDVM_H +#if LJ_TARGET_X64 +#if __USING_SJLJ_EXCEPTIONS__ +#error "Need a C compiler with native exception handling on x64" +#endif +#elif LJ_TARGET_ARM +#if defined(__ARMEB__) +#error "No support for big-endian ARM" +#endif +#if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__ +#error "No support for Cortex-M CPUs" +#endif +#if !(__ARM_EABI__ || LJ_TARGET_IOS) +#error "Only ARM EABI or iOS 3.0+ ABI is supported" +#endif +#elif LJ_TARGET_PPC || LJ_TARGET_PPCSPE +#if defined(_SOFT_FLOAT) || defined(_SOFT_DOUBLE) +#error "No support for PowerPC CPUs without double-precision FPU" +#endif +#if defined(_LITTLE_ENDIAN) +#error "No support for little-endian PowerPC" +#endif +#if defined(_LP64) +#error "No support for PowerPC 64 bit mode" +#endif +#elif LJ_TARGET_MIPS +#if defined(__mips_soft_float) +#error "No support for MIPS CPUs without FPU" +#endif +#if defined(_LP64) +#error "No support for MIPS64" +#endif +#endif +#endif + +/* Enable or disable the dual-number mode for the VM. */ +#if (LJ_ARCH_NUMMODE == LJ_NUMMODE_SINGLE && LUAJIT_NUMMODE == 2) || \ + (LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL && LUAJIT_NUMMODE == 1) +#error "No support for this number mode on this architecture" +#endif +#if LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL || \ + (LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL_SINGLE && LUAJIT_NUMMODE != 1) || \ + (LJ_ARCH_NUMMODE == LJ_NUMMODE_SINGLE_DUAL && LUAJIT_NUMMODE == 2) +#define LJ_DUALNUM 1 +#else +#define LJ_DUALNUM 0 +#endif + +#if LJ_TARGET_IOS || LJ_TARGET_CONSOLE +/* Runtime code generation is restricted on iOS. Complain to Apple, not me. */ +/* Ditto for the consoles. Complain to Sony or MS, not me. */ +#ifndef LUAJIT_ENABLE_JIT +#define LJ_OS_NOJIT 1 +#endif +#endif + +/* Disable or enable the JIT compiler. */ +#if defined(LUAJIT_DISABLE_JIT) || defined(LJ_ARCH_NOJIT) || defined(LJ_OS_NOJIT) +#define LJ_HASJIT 0 +#else +#define LJ_HASJIT 1 +#endif + +/* Disable or enable the FFI extension. */ +#if defined(LUAJIT_DISABLE_FFI) || defined(LJ_ARCH_NOFFI) +#define LJ_HASFFI 0 +#else +#define LJ_HASFFI 1 +#endif + +#ifndef LJ_ARCH_HASFPU +#define LJ_ARCH_HASFPU 1 +#endif +#ifndef LJ_ABI_SOFTFP +#define LJ_ABI_SOFTFP 0 +#endif +#define LJ_SOFTFP (!LJ_ARCH_HASFPU) + +#if LJ_ARCH_ENDIAN == LUAJIT_BE +#define LJ_LE 0 +#define LJ_BE 1 +#define LJ_ENDIAN_SELECT(le, be) be +#define LJ_ENDIAN_LOHI(lo, hi) hi lo +#else +#define LJ_LE 1 +#define LJ_BE 0 +#define LJ_ENDIAN_SELECT(le, be) le +#define LJ_ENDIAN_LOHI(lo, hi) lo hi +#endif + +#if LJ_ARCH_BITS == 32 +#define LJ_32 1 +#define LJ_64 0 +#else +#define LJ_32 0 +#define LJ_64 1 +#endif + +#ifndef LJ_TARGET_UNALIGNED +#define LJ_TARGET_UNALIGNED 0 +#endif + +/* Various workarounds for embedded operating systems. */ +#if (defined(__ANDROID__) && !defined(LJ_TARGET_X86ORX64)) || defined(__symbian__) || LJ_TARGET_XBOX360 +#define LUAJIT_NO_LOG2 +#endif +#if defined(__symbian__) +#define LUAJIT_NO_EXP2 +#endif + +#if defined(LUAJIT_NO_UNWIND) || defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3 +#define LJ_NO_UNWIND 1 +#endif + +/* Compatibility with Lua 5.1 vs. 5.2. */ +#ifdef LUAJIT_ENABLE_LUA52COMPAT +#define LJ_52 1 +#else +#define LJ_52 0 +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_asm.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_asm.c new file mode 100644 index 000000000..804b4dc80 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_asm.c @@ -0,0 +1,1920 @@ +/* +** IR assembler (SSA IR -> machine code). +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_asm_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_gc.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_frame.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#endif +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_ircall.h" +#include "lj_iropt.h" +#include "lj_mcode.h" +#include "lj_iropt.h" +#include "lj_trace.h" +#include "lj_snap.h" +#include "lj_asm.h" +#include "lj_dispatch.h" +#include "lj_vm.h" +#include "lj_target.h" + +#ifdef LUA_USE_ASSERT +#include +#endif + +/* -- Assembler state and common macros ----------------------------------- */ + +/* Assembler state. */ +typedef struct ASMState { + RegCost cost[RID_MAX]; /* Reference and blended allocation cost for regs. */ + + MCode *mcp; /* Current MCode pointer (grows down). */ + MCode *mclim; /* Lower limit for MCode memory + red zone. */ +#ifdef LUA_USE_ASSERT + MCode *mcp_prev; /* Red zone overflow check. */ +#endif + + IRIns *ir; /* Copy of pointer to IR instructions/constants. */ + jit_State *J; /* JIT compiler state. */ + +#if LJ_TARGET_X86ORX64 + x86ModRM mrm; /* Fused x86 address operand. */ +#endif + + RegSet freeset; /* Set of free registers. */ + RegSet modset; /* Set of registers modified inside the loop. */ + RegSet weakset; /* Set of weakly referenced registers. */ + RegSet phiset; /* Set of PHI registers. */ + + uint32_t flags; /* Copy of JIT compiler flags. */ + int loopinv; /* Loop branch inversion (0:no, 1:yes, 2:yes+CC_P). */ + + int32_t evenspill; /* Next even spill slot. */ + int32_t oddspill; /* Next odd spill slot (or 0). */ + + IRRef curins; /* Reference of current instruction. */ + IRRef stopins; /* Stop assembly before hitting this instruction. */ + IRRef orignins; /* Original T->nins. */ + + IRRef snapref; /* Current snapshot is active after this reference. */ + IRRef snaprename; /* Rename highwater mark for snapshot check. */ + SnapNo snapno; /* Current snapshot number. */ + SnapNo loopsnapno; /* Loop snapshot number. */ + + IRRef fuseref; /* Fusion limit (loopref, 0 or FUSE_DISABLED). */ + IRRef sectref; /* Section base reference (loopref or 0). */ + IRRef loopref; /* Reference of LOOP instruction (or 0). */ + + BCReg topslot; /* Number of slots for stack check (unless 0). */ + int32_t gcsteps; /* Accumulated number of GC steps (per section). */ + + GCtrace *T; /* Trace to assemble. */ + GCtrace *parent; /* Parent trace (or NULL). */ + + MCode *mcbot; /* Bottom of reserved MCode. */ + MCode *mctop; /* Top of generated MCode. */ + MCode *mcloop; /* Pointer to loop MCode (or NULL). */ + MCode *invmcp; /* Points to invertible loop branch (or NULL). */ + MCode *flagmcp; /* Pending opportunity to merge flag setting ins. */ + MCode *realign; /* Realign loop if not NULL. */ + +#ifdef RID_NUM_KREF + int32_t krefk[RID_NUM_KREF]; +#endif + IRRef1 phireg[RID_MAX]; /* PHI register references. */ + uint16_t parentmap[LJ_MAX_JSLOTS]; /* Parent instruction to RegSP map. */ +} ASMState; + +#define IR(ref) (&as->ir[(ref)]) + +#define ASMREF_TMP1 REF_TRUE /* Temp. register. */ +#define ASMREF_TMP2 REF_FALSE /* Temp. register. */ +#define ASMREF_L REF_NIL /* Stores register for L. */ + +/* Check for variant to invariant references. */ +#define iscrossref(as, ref) ((ref) < as->sectref) + +/* Inhibit memory op fusion from variant to invariant references. */ +#define FUSE_DISABLED (~(IRRef)0) +#define mayfuse(as, ref) ((ref) > as->fuseref) +#define neverfuse(as) (as->fuseref == FUSE_DISABLED) +#define canfuse(as, ir) (!neverfuse(as) && !irt_isphi((ir)->t)) +#define opisfusableload(o) \ + ((o) == IR_ALOAD || (o) == IR_HLOAD || (o) == IR_ULOAD || \ + (o) == IR_FLOAD || (o) == IR_XLOAD || (o) == IR_SLOAD || (o) == IR_VLOAD) + +/* Sparse limit checks using a red zone before the actual limit. */ +#define MCLIM_REDZONE 64 + +static LJ_NORET LJ_NOINLINE void asm_mclimit(ASMState *as) +{ + lj_mcode_limiterr(as->J, (size_t)(as->mctop - as->mcp + 4*MCLIM_REDZONE)); +} + +static LJ_AINLINE void checkmclim(ASMState *as) +{ +#ifdef LUA_USE_ASSERT + if (as->mcp + MCLIM_REDZONE < as->mcp_prev) { + IRIns *ir = IR(as->curins+1); + fprintf(stderr, "RED ZONE OVERFLOW: %p IR %04d %02d %04d %04d\n", as->mcp, + as->curins+1-REF_BIAS, ir->o, ir->op1-REF_BIAS, ir->op2-REF_BIAS); + lua_assert(0); + } +#endif + if (LJ_UNLIKELY(as->mcp < as->mclim)) asm_mclimit(as); +#ifdef LUA_USE_ASSERT + as->mcp_prev = as->mcp; +#endif +} + +#ifdef RID_NUM_KREF +#define ra_iskref(ref) ((ref) < RID_NUM_KREF) +#define ra_krefreg(ref) ((Reg)(RID_MIN_KREF + (Reg)(ref))) +#define ra_krefk(as, ref) (as->krefk[(ref)]) + +static LJ_AINLINE void ra_setkref(ASMState *as, Reg r, int32_t k) +{ + IRRef ref = (IRRef)(r - RID_MIN_KREF); + as->krefk[ref] = k; + as->cost[r] = REGCOST(ref, ref); +} + +#else +#define ra_iskref(ref) 0 +#define ra_krefreg(ref) RID_MIN_GPR +#define ra_krefk(as, ref) 0 +#endif + +/* Arch-specific field offsets. */ +static const uint8_t field_ofs[IRFL__MAX+1] = { +#define FLOFS(name, ofs) (uint8_t)(ofs), +IRFLDEF(FLOFS) +#undef FLOFS + 0 +}; + +/* -- Target-specific instruction emitter --------------------------------- */ + +#if LJ_TARGET_X86ORX64 +#include "lj_emit_x86.h" +#elif LJ_TARGET_ARM +#include "lj_emit_arm.h" +#elif LJ_TARGET_PPC +#include "lj_emit_ppc.h" +#elif LJ_TARGET_MIPS +#include "lj_emit_mips.h" +#else +#error "Missing instruction emitter for target CPU" +#endif + +/* -- Register allocator debugging ---------------------------------------- */ + +/* #define LUAJIT_DEBUG_RA */ + +#ifdef LUAJIT_DEBUG_RA + +#include +#include + +#define RIDNAME(name) #name, +static const char *const ra_regname[] = { + GPRDEF(RIDNAME) + FPRDEF(RIDNAME) + VRIDDEF(RIDNAME) + NULL +}; +#undef RIDNAME + +static char ra_dbg_buf[65536]; +static char *ra_dbg_p; +static char *ra_dbg_merge; +static MCode *ra_dbg_mcp; + +static void ra_dstart(void) +{ + ra_dbg_p = ra_dbg_buf; + ra_dbg_merge = NULL; + ra_dbg_mcp = NULL; +} + +static void ra_dflush(void) +{ + fwrite(ra_dbg_buf, 1, (size_t)(ra_dbg_p-ra_dbg_buf), stdout); + ra_dstart(); +} + +static void ra_dprintf(ASMState *as, const char *fmt, ...) +{ + char *p; + va_list argp; + va_start(argp, fmt); + p = ra_dbg_mcp == as->mcp ? ra_dbg_merge : ra_dbg_p; + ra_dbg_mcp = NULL; + p += sprintf(p, "%08x \e[36m%04d ", (uintptr_t)as->mcp, as->curins-REF_BIAS); + for (;;) { + const char *e = strchr(fmt, '$'); + if (e == NULL) break; + memcpy(p, fmt, (size_t)(e-fmt)); + p += e-fmt; + if (e[1] == 'r') { + Reg r = va_arg(argp, Reg) & RID_MASK; + if (r <= RID_MAX) { + const char *q; + for (q = ra_regname[r]; *q; q++) + *p++ = *q >= 'A' && *q <= 'Z' ? *q + 0x20 : *q; + } else { + *p++ = '?'; + lua_assert(0); + } + } else if (e[1] == 'f' || e[1] == 'i') { + IRRef ref; + if (e[1] == 'f') + ref = va_arg(argp, IRRef); + else + ref = va_arg(argp, IRIns *) - as->ir; + if (ref >= REF_BIAS) + p += sprintf(p, "%04d", ref - REF_BIAS); + else + p += sprintf(p, "K%03d", REF_BIAS - ref); + } else if (e[1] == 's') { + uint32_t slot = va_arg(argp, uint32_t); + p += sprintf(p, "[sp+0x%x]", sps_scale(slot)); + } else if (e[1] == 'x') { + p += sprintf(p, "%08x", va_arg(argp, int32_t)); + } else { + lua_assert(0); + } + fmt = e+2; + } + va_end(argp); + while (*fmt) + *p++ = *fmt++; + *p++ = '\e'; *p++ = '['; *p++ = 'm'; *p++ = '\n'; + if (p > ra_dbg_buf+sizeof(ra_dbg_buf)-256) { + fwrite(ra_dbg_buf, 1, (size_t)(p-ra_dbg_buf), stdout); + p = ra_dbg_buf; + } + ra_dbg_p = p; +} + +#define RA_DBG_START() ra_dstart() +#define RA_DBG_FLUSH() ra_dflush() +#define RA_DBG_REF() \ + do { char *_p = ra_dbg_p; ra_dprintf(as, ""); \ + ra_dbg_merge = _p; ra_dbg_mcp = as->mcp; } while (0) +#define RA_DBGX(x) ra_dprintf x + +#else +#define RA_DBG_START() ((void)0) +#define RA_DBG_FLUSH() ((void)0) +#define RA_DBG_REF() ((void)0) +#define RA_DBGX(x) ((void)0) +#endif + +/* -- Register allocator -------------------------------------------------- */ + +#define ra_free(as, r) rset_set(as->freeset, (r)) +#define ra_modified(as, r) rset_set(as->modset, (r)) +#define ra_weak(as, r) rset_set(as->weakset, (r)) +#define ra_noweak(as, r) rset_clear(as->weakset, (r)) + +#define ra_used(ir) (ra_hasreg((ir)->r) || ra_hasspill((ir)->s)) + +/* Setup register allocator. */ +static void ra_setup(ASMState *as) +{ + Reg r; + /* Initially all regs (except the stack pointer) are free for use. */ + as->freeset = RSET_INIT; + as->modset = RSET_EMPTY; + as->weakset = RSET_EMPTY; + as->phiset = RSET_EMPTY; + memset(as->phireg, 0, sizeof(as->phireg)); + for (r = RID_MIN_GPR; r < RID_MAX; r++) + as->cost[r] = REGCOST(~0u, 0u); +} + +/* Rematerialize constants. */ +static Reg ra_rematk(ASMState *as, IRRef ref) +{ + IRIns *ir; + Reg r; + if (ra_iskref(ref)) { + r = ra_krefreg(ref); + lua_assert(!rset_test(as->freeset, r)); + ra_free(as, r); + ra_modified(as, r); + emit_loadi(as, r, ra_krefk(as, ref)); + return r; + } + ir = IR(ref); + r = ir->r; + lua_assert(ra_hasreg(r) && !ra_hasspill(ir->s)); + ra_free(as, r); + ra_modified(as, r); + ir->r = RID_INIT; /* Do not keep any hint. */ + RA_DBGX((as, "remat $i $r", ir, r)); +#if !LJ_SOFTFP + if (ir->o == IR_KNUM) { + emit_loadn(as, r, ir_knum(ir)); + } else +#endif + if (emit_canremat(REF_BASE) && ir->o == IR_BASE) { + ra_sethint(ir->r, RID_BASE); /* Restore BASE register hint. */ + emit_getgl(as, r, jit_base); + } else if (emit_canremat(ASMREF_L) && ir->o == IR_KPRI) { + lua_assert(irt_isnil(ir->t)); /* REF_NIL stores ASMREF_L register. */ + emit_getgl(as, r, jit_L); +#if LJ_64 + } else if (ir->o == IR_KINT64) { + emit_loadu64(as, r, ir_kint64(ir)->u64); +#endif + } else { + lua_assert(ir->o == IR_KINT || ir->o == IR_KGC || + ir->o == IR_KPTR || ir->o == IR_KKPTR || ir->o == IR_KNULL); + emit_loadi(as, r, ir->i); + } + return r; +} + +/* Force a spill. Allocate a new spill slot if needed. */ +static int32_t ra_spill(ASMState *as, IRIns *ir) +{ + int32_t slot = ir->s; + lua_assert(ir >= as->ir + REF_TRUE); + if (!ra_hasspill(slot)) { + if (irt_is64(ir->t)) { + slot = as->evenspill; + as->evenspill += 2; + } else if (as->oddspill) { + slot = as->oddspill; + as->oddspill = 0; + } else { + slot = as->evenspill; + as->oddspill = slot+1; + as->evenspill += 2; + } + if (as->evenspill > 256) + lj_trace_err(as->J, LJ_TRERR_SPILLOV); + ir->s = (uint8_t)slot; + } + return sps_scale(slot); +} + +/* Release the temporarily allocated register in ASMREF_TMP1/ASMREF_TMP2. */ +static Reg ra_releasetmp(ASMState *as, IRRef ref) +{ + IRIns *ir = IR(ref); + Reg r = ir->r; + lua_assert(ra_hasreg(r) && !ra_hasspill(ir->s)); + ra_free(as, r); + ra_modified(as, r); + ir->r = RID_INIT; + return r; +} + +/* Restore a register (marked as free). Rematerialize or force a spill. */ +static Reg ra_restore(ASMState *as, IRRef ref) +{ + if (emit_canremat(ref)) { + return ra_rematk(as, ref); + } else { + IRIns *ir = IR(ref); + int32_t ofs = ra_spill(as, ir); /* Force a spill slot. */ + Reg r = ir->r; + lua_assert(ra_hasreg(r)); + ra_sethint(ir->r, r); /* Keep hint. */ + ra_free(as, r); + if (!rset_test(as->weakset, r)) { /* Only restore non-weak references. */ + ra_modified(as, r); + RA_DBGX((as, "restore $i $r", ir, r)); + emit_spload(as, ir, r, ofs); + } + return r; + } +} + +/* Save a register to a spill slot. */ +static void ra_save(ASMState *as, IRIns *ir, Reg r) +{ + RA_DBGX((as, "save $i $r", ir, r)); + emit_spstore(as, ir, r, sps_scale(ir->s)); +} + +#define MINCOST(name) \ + if (rset_test(RSET_ALL, RID_##name) && \ + LJ_LIKELY(allow&RID2RSET(RID_##name)) && as->cost[RID_##name] < cost) \ + cost = as->cost[RID_##name]; + +/* Evict the register with the lowest cost, forcing a restore. */ +static Reg ra_evict(ASMState *as, RegSet allow) +{ + IRRef ref; + RegCost cost = ~(RegCost)0; + lua_assert(allow != RSET_EMPTY); + if (RID_NUM_FPR == 0 || allow < RID2RSET(RID_MAX_GPR)) { + GPRDEF(MINCOST) + } else { + FPRDEF(MINCOST) + } + ref = regcost_ref(cost); + lua_assert(ra_iskref(ref) || (ref >= as->T->nk && ref < as->T->nins)); + /* Preferably pick any weak ref instead of a non-weak, non-const ref. */ + if (!irref_isk(ref) && (as->weakset & allow)) { + IRIns *ir = IR(ref); + if (!rset_test(as->weakset, ir->r)) + ref = regcost_ref(as->cost[rset_pickbot((as->weakset & allow))]); + } + return ra_restore(as, ref); +} + +/* Pick any register (marked as free). Evict on-demand. */ +static Reg ra_pick(ASMState *as, RegSet allow) +{ + RegSet pick = as->freeset & allow; + if (!pick) + return ra_evict(as, allow); + else + return rset_picktop(pick); +} + +/* Get a scratch register (marked as free). */ +static Reg ra_scratch(ASMState *as, RegSet allow) +{ + Reg r = ra_pick(as, allow); + ra_modified(as, r); + RA_DBGX((as, "scratch $r", r)); + return r; +} + +/* Evict all registers from a set (if not free). */ +static void ra_evictset(ASMState *as, RegSet drop) +{ + RegSet work; + as->modset |= drop; +#if !LJ_SOFTFP + work = (drop & ~as->freeset) & RSET_FPR; + while (work) { + Reg r = rset_pickbot(work); + ra_restore(as, regcost_ref(as->cost[r])); + rset_clear(work, r); + checkmclim(as); + } +#endif + work = (drop & ~as->freeset); + while (work) { + Reg r = rset_pickbot(work); + ra_restore(as, regcost_ref(as->cost[r])); + rset_clear(work, r); + checkmclim(as); + } +} + +/* Evict (rematerialize) all registers allocated to constants. */ +static void ra_evictk(ASMState *as) +{ + RegSet work; +#if !LJ_SOFTFP + work = ~as->freeset & RSET_FPR; + while (work) { + Reg r = rset_pickbot(work); + IRRef ref = regcost_ref(as->cost[r]); + if (emit_canremat(ref) && irref_isk(ref)) { + ra_rematk(as, ref); + checkmclim(as); + } + rset_clear(work, r); + } +#endif + work = ~as->freeset & RSET_GPR; + while (work) { + Reg r = rset_pickbot(work); + IRRef ref = regcost_ref(as->cost[r]); + if (emit_canremat(ref) && irref_isk(ref)) { + ra_rematk(as, ref); + checkmclim(as); + } + rset_clear(work, r); + } +} + +#ifdef RID_NUM_KREF +/* Allocate a register for a constant. */ +static Reg ra_allock(ASMState *as, int32_t k, RegSet allow) +{ + /* First try to find a register which already holds the same constant. */ + RegSet pick, work = ~as->freeset & RSET_GPR; + Reg r; + while (work) { + IRRef ref; + r = rset_pickbot(work); + ref = regcost_ref(as->cost[r]); + if (ref < ASMREF_L && + k == (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i)) + return r; + rset_clear(work, r); + } + pick = as->freeset & allow; + if (pick) { + /* Constants should preferably get unmodified registers. */ + if ((pick & ~as->modset)) + pick &= ~as->modset; + r = rset_pickbot(pick); /* Reduce conflicts with inverse allocation. */ + } else { + r = ra_evict(as, allow); + } + RA_DBGX((as, "allock $x $r", k, r)); + ra_setkref(as, r, k); + rset_clear(as->freeset, r); + ra_noweak(as, r); + return r; +} + +/* Allocate a specific register for a constant. */ +static void ra_allockreg(ASMState *as, int32_t k, Reg r) +{ + Reg kr = ra_allock(as, k, RID2RSET(r)); + if (kr != r) { + IRIns irdummy; + irdummy.t.irt = IRT_INT; + ra_scratch(as, RID2RSET(r)); + emit_movrr(as, &irdummy, r, kr); + } +} +#else +#define ra_allockreg(as, k, r) emit_loadi(as, (r), (k)) +#endif + +/* Allocate a register for ref from the allowed set of registers. +** Note: this function assumes the ref does NOT have a register yet! +** Picks an optimal register, sets the cost and marks the register as non-free. +*/ +static Reg ra_allocref(ASMState *as, IRRef ref, RegSet allow) +{ + IRIns *ir = IR(ref); + RegSet pick = as->freeset & allow; + Reg r; + lua_assert(ra_noreg(ir->r)); + if (pick) { + /* First check register hint from propagation or PHI. */ + if (ra_hashint(ir->r)) { + r = ra_gethint(ir->r); + if (rset_test(pick, r)) /* Use hint register if possible. */ + goto found; + /* Rematerialization is cheaper than missing a hint. */ + if (rset_test(allow, r) && emit_canremat(regcost_ref(as->cost[r]))) { + ra_rematk(as, regcost_ref(as->cost[r])); + goto found; + } + RA_DBGX((as, "hintmiss $f $r", ref, r)); + } + /* Invariants should preferably get unmodified registers. */ + if (ref < as->loopref && !irt_isphi(ir->t)) { + if ((pick & ~as->modset)) + pick &= ~as->modset; + r = rset_pickbot(pick); /* Reduce conflicts with inverse allocation. */ + } else { + /* We've got plenty of regs, so get callee-save regs if possible. */ + if (RID_NUM_GPR > 8 && (pick & ~RSET_SCRATCH)) + pick &= ~RSET_SCRATCH; + r = rset_picktop(pick); + } + } else { + r = ra_evict(as, allow); + } +found: + RA_DBGX((as, "alloc $f $r", ref, r)); + ir->r = (uint8_t)r; + rset_clear(as->freeset, r); + ra_noweak(as, r); + as->cost[r] = REGCOST_REF_T(ref, irt_t(ir->t)); + return r; +} + +/* Allocate a register on-demand. */ +static Reg ra_alloc1(ASMState *as, IRRef ref, RegSet allow) +{ + Reg r = IR(ref)->r; + /* Note: allow is ignored if the register is already allocated. */ + if (ra_noreg(r)) r = ra_allocref(as, ref, allow); + ra_noweak(as, r); + return r; +} + +/* Rename register allocation and emit move. */ +static void ra_rename(ASMState *as, Reg down, Reg up) +{ + IRRef ren, ref = regcost_ref(as->cost[up] = as->cost[down]); + IRIns *ir = IR(ref); + ir->r = (uint8_t)up; + as->cost[down] = 0; + lua_assert((down < RID_MAX_GPR) == (up < RID_MAX_GPR)); + lua_assert(!rset_test(as->freeset, down) && rset_test(as->freeset, up)); + ra_free(as, down); /* 'down' is free ... */ + ra_modified(as, down); + rset_clear(as->freeset, up); /* ... and 'up' is now allocated. */ + ra_noweak(as, up); + RA_DBGX((as, "rename $f $r $r", regcost_ref(as->cost[up]), down, up)); + emit_movrr(as, ir, down, up); /* Backwards codegen needs inverse move. */ + if (!ra_hasspill(IR(ref)->s)) { /* Add the rename to the IR. */ + lj_ir_set(as->J, IRT(IR_RENAME, IRT_NIL), ref, as->snapno); + ren = tref_ref(lj_ir_emit(as->J)); + as->ir = as->T->ir; /* The IR may have been reallocated. */ + IR(ren)->r = (uint8_t)down; + IR(ren)->s = SPS_NONE; + } +} + +/* Pick a destination register (marked as free). +** Caveat: allow is ignored if there's already a destination register. +** Use ra_destreg() to get a specific register. +*/ +static Reg ra_dest(ASMState *as, IRIns *ir, RegSet allow) +{ + Reg dest = ir->r; + if (ra_hasreg(dest)) { + ra_free(as, dest); + ra_modified(as, dest); + } else { + if (ra_hashint(dest) && rset_test((as->freeset&allow), ra_gethint(dest))) { + dest = ra_gethint(dest); + ra_modified(as, dest); + RA_DBGX((as, "dest $r", dest)); + } else { + dest = ra_scratch(as, allow); + } + ir->r = dest; + } + if (LJ_UNLIKELY(ra_hasspill(ir->s))) ra_save(as, ir, dest); + return dest; +} + +/* Force a specific destination register (marked as free). */ +static void ra_destreg(ASMState *as, IRIns *ir, Reg r) +{ + Reg dest = ra_dest(as, ir, RID2RSET(r)); + if (dest != r) { + lua_assert(rset_test(as->freeset, r)); + ra_modified(as, r); + emit_movrr(as, ir, dest, r); + } +} + +#if LJ_TARGET_X86ORX64 +/* Propagate dest register to left reference. Emit moves as needed. +** This is a required fixup step for all 2-operand machine instructions. +*/ +static void ra_left(ASMState *as, Reg dest, IRRef lref) +{ + IRIns *ir = IR(lref); + Reg left = ir->r; + if (ra_noreg(left)) { + if (irref_isk(lref)) { + if (ir->o == IR_KNUM) { + cTValue *tv = ir_knum(ir); + /* FP remat needs a load except for +0. Still better than eviction. */ + if (tvispzero(tv) || !(as->freeset & RSET_FPR)) { + emit_loadn(as, dest, tv); + return; + } +#if LJ_64 + } else if (ir->o == IR_KINT64) { + emit_loadu64(as, dest, ir_kint64(ir)->u64); + return; +#endif + } else { + lua_assert(ir->o == IR_KINT || ir->o == IR_KGC || + ir->o == IR_KPTR || ir->o == IR_KKPTR || ir->o == IR_KNULL); + emit_loadi(as, dest, ir->i); + return; + } + } + if (!ra_hashint(left) && !iscrossref(as, lref)) + ra_sethint(ir->r, dest); /* Propagate register hint. */ + left = ra_allocref(as, lref, dest < RID_MAX_GPR ? RSET_GPR : RSET_FPR); + } + ra_noweak(as, left); + /* Move needed for true 3-operand instruction: y=a+b ==> y=a; y+=b. */ + if (dest != left) { + /* Use register renaming if dest is the PHI reg. */ + if (irt_isphi(ir->t) && as->phireg[dest] == lref) { + ra_modified(as, left); + ra_rename(as, left, dest); + } else { + emit_movrr(as, ir, dest, left); + } + } +} +#else +/* Similar to ra_left, except we override any hints. */ +static void ra_leftov(ASMState *as, Reg dest, IRRef lref) +{ + IRIns *ir = IR(lref); + Reg left = ir->r; + if (ra_noreg(left)) { + ra_sethint(ir->r, dest); /* Propagate register hint. */ + left = ra_allocref(as, lref, + (LJ_SOFTFP || dest < RID_MAX_GPR) ? RSET_GPR : RSET_FPR); + } + ra_noweak(as, left); + if (dest != left) { + /* Use register renaming if dest is the PHI reg. */ + if (irt_isphi(ir->t) && as->phireg[dest] == lref) { + ra_modified(as, left); + ra_rename(as, left, dest); + } else { + emit_movrr(as, ir, dest, left); + } + } +} +#endif + +#if !LJ_64 +/* Force a RID_RETLO/RID_RETHI destination register pair (marked as free). */ +static void ra_destpair(ASMState *as, IRIns *ir) +{ + Reg destlo = ir->r, desthi = (ir+1)->r; + /* First spill unrelated refs blocking the destination registers. */ + if (!rset_test(as->freeset, RID_RETLO) && + destlo != RID_RETLO && desthi != RID_RETLO) + ra_restore(as, regcost_ref(as->cost[RID_RETLO])); + if (!rset_test(as->freeset, RID_RETHI) && + destlo != RID_RETHI && desthi != RID_RETHI) + ra_restore(as, regcost_ref(as->cost[RID_RETHI])); + /* Next free the destination registers (if any). */ + if (ra_hasreg(destlo)) { + ra_free(as, destlo); + ra_modified(as, destlo); + } else { + destlo = RID_RETLO; + } + if (ra_hasreg(desthi)) { + ra_free(as, desthi); + ra_modified(as, desthi); + } else { + desthi = RID_RETHI; + } + /* Check for conflicts and shuffle the registers as needed. */ + if (destlo == RID_RETHI) { + if (desthi == RID_RETLO) { +#if LJ_TARGET_X86 + *--as->mcp = XI_XCHGa + RID_RETHI; +#else + emit_movrr(as, ir, RID_RETHI, RID_TMP); + emit_movrr(as, ir, RID_RETLO, RID_RETHI); + emit_movrr(as, ir, RID_TMP, RID_RETLO); +#endif + } else { + emit_movrr(as, ir, RID_RETHI, RID_RETLO); + if (desthi != RID_RETHI) emit_movrr(as, ir, desthi, RID_RETHI); + } + } else if (desthi == RID_RETLO) { + emit_movrr(as, ir, RID_RETLO, RID_RETHI); + if (destlo != RID_RETLO) emit_movrr(as, ir, destlo, RID_RETLO); + } else { + if (desthi != RID_RETHI) emit_movrr(as, ir, desthi, RID_RETHI); + if (destlo != RID_RETLO) emit_movrr(as, ir, destlo, RID_RETLO); + } + /* Restore spill slots (if any). */ + if (ra_hasspill((ir+1)->s)) ra_save(as, ir+1, RID_RETHI); + if (ra_hasspill(ir->s)) ra_save(as, ir, RID_RETLO); +} +#endif + +/* -- Snapshot handling --------- ----------------------------------------- */ + +/* Can we rematerialize a KNUM instead of forcing a spill? */ +static int asm_snap_canremat(ASMState *as) +{ + Reg r; + for (r = RID_MIN_FPR; r < RID_MAX_FPR; r++) + if (irref_isk(regcost_ref(as->cost[r]))) + return 1; + return 0; +} + +/* Check whether a sunk store corresponds to an allocation. */ +static int asm_sunk_store(ASMState *as, IRIns *ira, IRIns *irs) +{ + if (irs->s == 255) { + if (irs->o == IR_ASTORE || irs->o == IR_HSTORE || + irs->o == IR_FSTORE || irs->o == IR_XSTORE) { + IRIns *irk = IR(irs->op1); + if (irk->o == IR_AREF || irk->o == IR_HREFK) + irk = IR(irk->op1); + return (IR(irk->op1) == ira); + } + return 0; + } else { + return (ira + irs->s == irs); /* Quick check. */ + } +} + +/* Allocate register or spill slot for a ref that escapes to a snapshot. */ +static void asm_snap_alloc1(ASMState *as, IRRef ref) +{ + IRIns *ir = IR(ref); + if (!irref_isk(ref) && (!(ra_used(ir) || ir->r == RID_SUNK))) { + if (ir->r == RID_SINK) { + ir->r = RID_SUNK; +#if LJ_HASFFI + if (ir->o == IR_CNEWI) { /* Allocate CNEWI value. */ + asm_snap_alloc1(as, ir->op2); + if (LJ_32 && (ir+1)->o == IR_HIOP) + asm_snap_alloc1(as, (ir+1)->op2); + } else +#endif + { /* Allocate stored values for TNEW, TDUP and CNEW. */ + IRIns *irs; + lua_assert(ir->o == IR_TNEW || ir->o == IR_TDUP || ir->o == IR_CNEW); + for (irs = IR(as->snapref-1); irs > ir; irs--) + if (irs->r == RID_SINK && asm_sunk_store(as, ir, irs)) { + lua_assert(irs->o == IR_ASTORE || irs->o == IR_HSTORE || + irs->o == IR_FSTORE || irs->o == IR_XSTORE); + asm_snap_alloc1(as, irs->op2); + if (LJ_32 && (irs+1)->o == IR_HIOP) + asm_snap_alloc1(as, (irs+1)->op2); + } + } + } else { + RegSet allow; + if (ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT) { + IRIns *irc; + for (irc = IR(as->curins); irc > ir; irc--) + if ((irc->op1 == ref || irc->op2 == ref) && + !(irc->r == RID_SINK || irc->r == RID_SUNK)) + goto nosink; /* Don't sink conversion if result is used. */ + asm_snap_alloc1(as, ir->op1); + return; + } + nosink: + allow = (!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR; + if ((as->freeset & allow) || + (allow == RSET_FPR && asm_snap_canremat(as))) { + /* Get a weak register if we have a free one or can rematerialize. */ + Reg r = ra_allocref(as, ref, allow); /* Allocate a register. */ + if (!irt_isphi(ir->t)) + ra_weak(as, r); /* But mark it as weakly referenced. */ + checkmclim(as); + RA_DBGX((as, "snapreg $f $r", ref, ir->r)); + } else { + ra_spill(as, ir); /* Otherwise force a spill slot. */ + RA_DBGX((as, "snapspill $f $s", ref, ir->s)); + } + } + } +} + +/* Allocate refs escaping to a snapshot. */ +static void asm_snap_alloc(ASMState *as) +{ + SnapShot *snap = &as->T->snap[as->snapno]; + SnapEntry *map = &as->T->snapmap[snap->mapofs]; + MSize n, nent = snap->nent; + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + IRRef ref = snap_ref(sn); + if (!irref_isk(ref)) { + asm_snap_alloc1(as, ref); + if (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM)) { + lua_assert(irt_type(IR(ref+1)->t) == IRT_SOFTFP); + asm_snap_alloc1(as, ref+1); + } + } + } +} + +/* All guards for a snapshot use the same exitno. This is currently the +** same as the snapshot number. Since the exact origin of the exit cannot +** be determined, all guards for the same snapshot must exit with the same +** RegSP mapping. +** A renamed ref which has been used in a prior guard for the same snapshot +** would cause an inconsistency. The easy way out is to force a spill slot. +*/ +static int asm_snap_checkrename(ASMState *as, IRRef ren) +{ + SnapShot *snap = &as->T->snap[as->snapno]; + SnapEntry *map = &as->T->snapmap[snap->mapofs]; + MSize n, nent = snap->nent; + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + IRRef ref = snap_ref(sn); + if (ref == ren || (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM) && ++ref == ren)) { + IRIns *ir = IR(ref); + ra_spill(as, ir); /* Register renamed, so force a spill slot. */ + RA_DBGX((as, "snaprensp $f $s", ref, ir->s)); + return 1; /* Found. */ + } + } + return 0; /* Not found. */ +} + +/* Prepare snapshot for next guard instruction. */ +static void asm_snap_prep(ASMState *as) +{ + if (as->curins < as->snapref) { + do { + if (as->snapno == 0) return; /* Called by sunk stores before snap #0. */ + as->snapno--; + as->snapref = as->T->snap[as->snapno].ref; + } while (as->curins < as->snapref); + asm_snap_alloc(as); + as->snaprename = as->T->nins; + } else { + /* Process any renames above the highwater mark. */ + for (; as->snaprename < as->T->nins; as->snaprename++) { + IRIns *ir = IR(as->snaprename); + if (asm_snap_checkrename(as, ir->op1)) + ir->op2 = REF_BIAS-1; /* Kill rename. */ + } + } +} + +/* -- Miscellaneous helpers ----------------------------------------------- */ + +/* Collect arguments from CALL* and CARG instructions. */ +static void asm_collectargs(ASMState *as, IRIns *ir, + const CCallInfo *ci, IRRef *args) +{ + uint32_t n = CCI_NARGS(ci); + lua_assert(n <= CCI_NARGS_MAX*2); /* Account for split args. */ + if ((ci->flags & CCI_L)) { *args++ = ASMREF_L; n--; } + while (n-- > 1) { + ir = IR(ir->op1); + lua_assert(ir->o == IR_CARG); + args[n] = ir->op2 == REF_NIL ? 0 : ir->op2; + } + args[0] = ir->op1 == REF_NIL ? 0 : ir->op1; + lua_assert(IR(ir->op1)->o != IR_CARG); +} + +/* Reconstruct CCallInfo flags for CALLX*. */ +static uint32_t asm_callx_flags(ASMState *as, IRIns *ir) +{ + uint32_t nargs = 0; + if (ir->op1 != REF_NIL) { /* Count number of arguments first. */ + IRIns *ira = IR(ir->op1); + nargs++; + while (ira->o == IR_CARG) { nargs++; ira = IR(ira->op1); } + } +#if LJ_HASFFI + if (IR(ir->op2)->o == IR_CARG) { /* Copy calling convention info. */ + CTypeID id = (CTypeID)IR(IR(ir->op2)->op2)->i; + CType *ct = ctype_get(ctype_ctsG(J2G(as->J)), id); + nargs |= ((ct->info & CTF_VARARG) ? CCI_VARARG : 0); +#if LJ_TARGET_X86 + nargs |= (ctype_cconv(ct->info) << CCI_CC_SHIFT); +#endif + } +#endif + return (nargs | (ir->t.irt << CCI_OTSHIFT)); +} + +/* Calculate stack adjustment. */ +static int32_t asm_stack_adjust(ASMState *as) +{ + if (as->evenspill <= SPS_FIXED) + return 0; + return sps_scale(sps_align(as->evenspill)); +} + +/* Must match with hash*() in lj_tab.c. */ +static uint32_t ir_khash(IRIns *ir) +{ + uint32_t lo, hi; + if (irt_isstr(ir->t)) { + return ir_kstr(ir)->hash; + } else if (irt_isnum(ir->t)) { + lo = ir_knum(ir)->u32.lo; + hi = ir_knum(ir)->u32.hi << 1; + } else if (irt_ispri(ir->t)) { + lua_assert(!irt_isnil(ir->t)); + return irt_type(ir->t)-IRT_FALSE; + } else { + lua_assert(irt_isgcv(ir->t)); + lo = u32ptr(ir_kgc(ir)); + hi = lo + HASH_BIAS; + } + return hashrot(lo, hi); +} + +/* -- Allocations --------------------------------------------------------- */ + +static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args); +static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci); + +static void asm_snew(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_new]; + IRRef args[3]; + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ir->op1; /* const char *str */ + args[2] = ir->op2; /* size_t len */ + as->gcsteps++; + asm_setupresult(as, ir, ci); /* GCstr * */ + asm_gencall(as, ci, args); +} + +static void asm_tnew(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_new1]; + IRRef args[2]; + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ASMREF_TMP1; /* uint32_t ahsize */ + as->gcsteps++; + asm_setupresult(as, ir, ci); /* GCtab * */ + asm_gencall(as, ci, args); + ra_allockreg(as, ir->op1 | (ir->op2 << 24), ra_releasetmp(as, ASMREF_TMP1)); +} + +static void asm_tdup(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_dup]; + IRRef args[2]; + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ir->op1; /* const GCtab *kt */ + as->gcsteps++; + asm_setupresult(as, ir, ci); /* GCtab * */ + asm_gencall(as, ci, args); +} + +static void asm_gc_check(ASMState *as); + +/* Explicit GC step. */ +static void asm_gcstep(ASMState *as, IRIns *ir) +{ + IRIns *ira; + for (ira = IR(as->stopins+1); ira < ir; ira++) + if ((ira->o == IR_TNEW || ira->o == IR_TDUP || + (LJ_HASFFI && (ira->o == IR_CNEW || ira->o == IR_CNEWI))) && + ra_used(ira)) + as->gcsteps++; + if (as->gcsteps) + asm_gc_check(as); + as->gcsteps = 0x80000000; /* Prevent implicit GC check further up. */ +} + +/* -- PHI and loop handling ----------------------------------------------- */ + +/* Break a PHI cycle by renaming to a free register (evict if needed). */ +static void asm_phi_break(ASMState *as, RegSet blocked, RegSet blockedby, + RegSet allow) +{ + RegSet candidates = blocked & allow; + if (candidates) { /* If this register file has candidates. */ + /* Note: the set for ra_pick cannot be empty, since each register file + ** has some registers never allocated to PHIs. + */ + Reg down, up = ra_pick(as, ~blocked & allow); /* Get a free register. */ + if (candidates & ~blockedby) /* Optimize shifts, else it's a cycle. */ + candidates = candidates & ~blockedby; + down = rset_picktop(candidates); /* Pick candidate PHI register. */ + ra_rename(as, down, up); /* And rename it to the free register. */ + } +} + +/* PHI register shuffling. +** +** The allocator tries hard to preserve PHI register assignments across +** the loop body. Most of the time this loop does nothing, since there +** are no register mismatches. +** +** If a register mismatch is detected and ... +** - the register is currently free: rename it. +** - the register is blocked by an invariant: restore/remat and rename it. +** - Otherwise the register is used by another PHI, so mark it as blocked. +** +** The renames are order-sensitive, so just retry the loop if a register +** is marked as blocked, but has been freed in the meantime. A cycle is +** detected if all of the blocked registers are allocated. To break the +** cycle rename one of them to a free register and retry. +** +** Note that PHI spill slots are kept in sync and don't need to be shuffled. +*/ +static void asm_phi_shuffle(ASMState *as) +{ + RegSet work; + + /* Find and resolve PHI register mismatches. */ + for (;;) { + RegSet blocked = RSET_EMPTY; + RegSet blockedby = RSET_EMPTY; + RegSet phiset = as->phiset; + while (phiset) { /* Check all left PHI operand registers. */ + Reg r = rset_pickbot(phiset); + IRIns *irl = IR(as->phireg[r]); + Reg left = irl->r; + if (r != left) { /* Mismatch? */ + if (!rset_test(as->freeset, r)) { /* PHI register blocked? */ + IRRef ref = regcost_ref(as->cost[r]); + /* Blocked by other PHI (w/reg)? */ + if (!ra_iskref(ref) && irt_ismarked(IR(ref)->t)) { + rset_set(blocked, r); + if (ra_hasreg(left)) + rset_set(blockedby, left); + left = RID_NONE; + } else { /* Otherwise grab register from invariant. */ + ra_restore(as, ref); + checkmclim(as); + } + } + if (ra_hasreg(left)) { + ra_rename(as, left, r); + checkmclim(as); + } + } + rset_clear(phiset, r); + } + if (!blocked) break; /* Finished. */ + if (!(as->freeset & blocked)) { /* Break cycles if none are free. */ + asm_phi_break(as, blocked, blockedby, RSET_GPR); + if (!LJ_SOFTFP) asm_phi_break(as, blocked, blockedby, RSET_FPR); + checkmclim(as); + } /* Else retry some more renames. */ + } + + /* Restore/remat invariants whose registers are modified inside the loop. */ +#if !LJ_SOFTFP + work = as->modset & ~(as->freeset | as->phiset) & RSET_FPR; + while (work) { + Reg r = rset_pickbot(work); + ra_restore(as, regcost_ref(as->cost[r])); + rset_clear(work, r); + checkmclim(as); + } +#endif + work = as->modset & ~(as->freeset | as->phiset); + while (work) { + Reg r = rset_pickbot(work); + ra_restore(as, regcost_ref(as->cost[r])); + rset_clear(work, r); + checkmclim(as); + } + + /* Allocate and save all unsaved PHI regs and clear marks. */ + work = as->phiset; + while (work) { + Reg r = rset_picktop(work); + IRRef lref = as->phireg[r]; + IRIns *ir = IR(lref); + if (ra_hasspill(ir->s)) { /* Left PHI gained a spill slot? */ + irt_clearmark(ir->t); /* Handled here, so clear marker now. */ + ra_alloc1(as, lref, RID2RSET(r)); + ra_save(as, ir, r); /* Save to spill slot inside the loop. */ + checkmclim(as); + } + rset_clear(work, r); + } +} + +/* Copy unsynced left/right PHI spill slots. Rarely needed. */ +static void asm_phi_copyspill(ASMState *as) +{ + int need = 0; + IRIns *ir; + for (ir = IR(as->orignins-1); ir->o == IR_PHI; ir--) + if (ra_hasspill(ir->s) && ra_hasspill(IR(ir->op1)->s)) + need |= irt_isfp(ir->t) ? 2 : 1; /* Unsynced spill slot? */ + if ((need & 1)) { /* Copy integer spill slots. */ +#if !LJ_TARGET_X86ORX64 + Reg r = RID_TMP; +#else + Reg r = RID_RET; + if ((as->freeset & RSET_GPR)) + r = rset_pickbot((as->freeset & RSET_GPR)); + else + emit_spload(as, IR(regcost_ref(as->cost[r])), r, SPOFS_TMP); +#endif + for (ir = IR(as->orignins-1); ir->o == IR_PHI; ir--) { + if (ra_hasspill(ir->s)) { + IRIns *irl = IR(ir->op1); + if (ra_hasspill(irl->s) && !irt_isfp(ir->t)) { + emit_spstore(as, irl, r, sps_scale(irl->s)); + emit_spload(as, ir, r, sps_scale(ir->s)); + checkmclim(as); + } + } + } +#if LJ_TARGET_X86ORX64 + if (!rset_test(as->freeset, r)) + emit_spstore(as, IR(regcost_ref(as->cost[r])), r, SPOFS_TMP); +#endif + } +#if !LJ_SOFTFP + if ((need & 2)) { /* Copy FP spill slots. */ +#if LJ_TARGET_X86 + Reg r = RID_XMM0; +#else + Reg r = RID_FPRET; +#endif + if ((as->freeset & RSET_FPR)) + r = rset_pickbot((as->freeset & RSET_FPR)); + if (!rset_test(as->freeset, r)) + emit_spload(as, IR(regcost_ref(as->cost[r])), r, SPOFS_TMP); + for (ir = IR(as->orignins-1); ir->o == IR_PHI; ir--) { + if (ra_hasspill(ir->s)) { + IRIns *irl = IR(ir->op1); + if (ra_hasspill(irl->s) && irt_isfp(ir->t)) { + emit_spstore(as, irl, r, sps_scale(irl->s)); + emit_spload(as, ir, r, sps_scale(ir->s)); + checkmclim(as); + } + } + } + if (!rset_test(as->freeset, r)) + emit_spstore(as, IR(regcost_ref(as->cost[r])), r, SPOFS_TMP); + } +#endif +} + +/* Emit renames for left PHIs which are only spilled outside the loop. */ +static void asm_phi_fixup(ASMState *as) +{ + RegSet work = as->phiset; + while (work) { + Reg r = rset_picktop(work); + IRRef lref = as->phireg[r]; + IRIns *ir = IR(lref); + if (irt_ismarked(ir->t)) { + irt_clearmark(ir->t); + /* Left PHI gained a spill slot before the loop? */ + if (ra_hasspill(ir->s)) { + IRRef ren; + lj_ir_set(as->J, IRT(IR_RENAME, IRT_NIL), lref, as->loopsnapno); + ren = tref_ref(lj_ir_emit(as->J)); + as->ir = as->T->ir; /* The IR may have been reallocated. */ + IR(ren)->r = (uint8_t)r; + IR(ren)->s = SPS_NONE; + } + } + rset_clear(work, r); + } +} + +/* Setup right PHI reference. */ +static void asm_phi(ASMState *as, IRIns *ir) +{ + RegSet allow = ((!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR) & + ~as->phiset; + RegSet afree = (as->freeset & allow); + IRIns *irl = IR(ir->op1); + IRIns *irr = IR(ir->op2); + if (ir->r == RID_SINK) /* Sink PHI. */ + return; + /* Spill slot shuffling is not implemented yet (but rarely needed). */ + if (ra_hasspill(irl->s) || ra_hasspill(irr->s)) + lj_trace_err(as->J, LJ_TRERR_NYIPHI); + /* Leave at least one register free for non-PHIs (and PHI cycle breaking). */ + if ((afree & (afree-1))) { /* Two or more free registers? */ + Reg r; + if (ra_noreg(irr->r)) { /* Get a register for the right PHI. */ + r = ra_allocref(as, ir->op2, allow); + } else { /* Duplicate right PHI, need a copy (rare). */ + r = ra_scratch(as, allow); + emit_movrr(as, irr, r, irr->r); + } + ir->r = (uint8_t)r; + rset_set(as->phiset, r); + as->phireg[r] = (IRRef1)ir->op1; + irt_setmark(irl->t); /* Marks left PHIs _with_ register. */ + if (ra_noreg(irl->r)) + ra_sethint(irl->r, r); /* Set register hint for left PHI. */ + } else { /* Otherwise allocate a spill slot. */ + /* This is overly restrictive, but it triggers only on synthetic code. */ + if (ra_hasreg(irl->r) || ra_hasreg(irr->r)) + lj_trace_err(as->J, LJ_TRERR_NYIPHI); + ra_spill(as, ir); + irr->s = ir->s; /* Set right PHI spill slot. Sync left slot later. */ + } +} + +static void asm_loop_fixup(ASMState *as); + +/* Middle part of a loop. */ +static void asm_loop(ASMState *as) +{ + MCode *mcspill; + /* LOOP is a guard, so the snapno is up to date. */ + as->loopsnapno = as->snapno; + if (as->gcsteps) + asm_gc_check(as); + /* LOOP marks the transition from the variant to the invariant part. */ + as->flagmcp = as->invmcp = NULL; + as->sectref = 0; + if (!neverfuse(as)) as->fuseref = 0; + asm_phi_shuffle(as); + mcspill = as->mcp; + asm_phi_copyspill(as); + asm_loop_fixup(as); + as->mcloop = as->mcp; + RA_DBGX((as, "===== LOOP =====")); + if (!as->realign) RA_DBG_FLUSH(); + if (as->mcp != mcspill) + emit_jmp(as, mcspill); +} + +/* -- Target-specific assembler ------------------------------------------- */ + +#if LJ_TARGET_X86ORX64 +#include "lj_asm_x86.h" +#elif LJ_TARGET_ARM +#include "lj_asm_arm.h" +#elif LJ_TARGET_PPC +#include "lj_asm_ppc.h" +#elif LJ_TARGET_MIPS +#include "lj_asm_mips.h" +#else +#error "Missing assembler for target CPU" +#endif + +/* -- Head of trace ------------------------------------------------------- */ + +/* Head of a root trace. */ +static void asm_head_root(ASMState *as) +{ + int32_t spadj; + asm_head_root_base(as); + emit_setvmstate(as, (int32_t)as->T->traceno); + spadj = asm_stack_adjust(as); + as->T->spadjust = (uint16_t)spadj; + emit_spsub(as, spadj); + /* Root traces assume a checked stack for the starting proto. */ + as->T->topslot = gcref(as->T->startpt)->pt.framesize; +} + +/* Head of a side trace. +** +** The current simplistic algorithm requires that all slots inherited +** from the parent are live in a register between pass 2 and pass 3. This +** avoids the complexity of stack slot shuffling. But of course this may +** overflow the register set in some cases and cause the dreaded error: +** "NYI: register coalescing too complex". A refined algorithm is needed. +*/ +static void asm_head_side(ASMState *as) +{ + IRRef1 sloadins[RID_MAX]; + RegSet allow = RSET_ALL; /* Inverse of all coalesced registers. */ + RegSet live = RSET_EMPTY; /* Live parent registers. */ + IRIns *irp = &as->parent->ir[REF_BASE]; /* Parent base. */ + int32_t spadj, spdelta; + int pass2 = 0; + int pass3 = 0; + IRRef i; + + if (as->snapno && as->topslot > as->parent->topslot) { + /* Force snap #0 alloc to prevent register overwrite in stack check. */ + as->snapno = 0; + asm_snap_alloc(as); + } + allow = asm_head_side_base(as, irp, allow); + + /* Scan all parent SLOADs and collect register dependencies. */ + for (i = as->stopins; i > REF_BASE; i--) { + IRIns *ir = IR(i); + RegSP rs; + lua_assert((ir->o == IR_SLOAD && (ir->op2 & IRSLOAD_PARENT)) || + (LJ_SOFTFP && ir->o == IR_HIOP) || ir->o == IR_PVAL); + rs = as->parentmap[i - REF_FIRST]; + if (ra_hasreg(ir->r)) { + rset_clear(allow, ir->r); + if (ra_hasspill(ir->s)) { + ra_save(as, ir, ir->r); + checkmclim(as); + } + } else if (ra_hasspill(ir->s)) { + irt_setmark(ir->t); + pass2 = 1; + } + if (ir->r == rs) { /* Coalesce matching registers right now. */ + ra_free(as, ir->r); + } else if (ra_hasspill(regsp_spill(rs))) { + if (ra_hasreg(ir->r)) + pass3 = 1; + } else if (ra_used(ir)) { + sloadins[rs] = (IRRef1)i; + rset_set(live, rs); /* Block live parent register. */ + } + } + + /* Calculate stack frame adjustment. */ + spadj = asm_stack_adjust(as); + spdelta = spadj - (int32_t)as->parent->spadjust; + if (spdelta < 0) { /* Don't shrink the stack frame. */ + spadj = (int32_t)as->parent->spadjust; + spdelta = 0; + } + as->T->spadjust = (uint16_t)spadj; + + /* Reload spilled target registers. */ + if (pass2) { + for (i = as->stopins; i > REF_BASE; i--) { + IRIns *ir = IR(i); + if (irt_ismarked(ir->t)) { + RegSet mask; + Reg r; + RegSP rs; + irt_clearmark(ir->t); + rs = as->parentmap[i - REF_FIRST]; + if (!ra_hasspill(regsp_spill(rs))) + ra_sethint(ir->r, rs); /* Hint may be gone, set it again. */ + else if (sps_scale(regsp_spill(rs))+spdelta == sps_scale(ir->s)) + continue; /* Same spill slot, do nothing. */ + mask = ((!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR) & allow; + if (mask == RSET_EMPTY) + lj_trace_err(as->J, LJ_TRERR_NYICOAL); + r = ra_allocref(as, i, mask); + ra_save(as, ir, r); + rset_clear(allow, r); + if (r == rs) { /* Coalesce matching registers right now. */ + ra_free(as, r); + rset_clear(live, r); + } else if (ra_hasspill(regsp_spill(rs))) { + pass3 = 1; + } + checkmclim(as); + } + } + } + + /* Store trace number and adjust stack frame relative to the parent. */ + emit_setvmstate(as, (int32_t)as->T->traceno); + emit_spsub(as, spdelta); + +#if !LJ_TARGET_X86ORX64 + /* Restore BASE register from parent spill slot. */ + if (ra_hasspill(irp->s)) + emit_spload(as, IR(REF_BASE), IR(REF_BASE)->r, sps_scale(irp->s)); +#endif + + /* Restore target registers from parent spill slots. */ + if (pass3) { + RegSet work = ~as->freeset & RSET_ALL; + while (work) { + Reg r = rset_pickbot(work); + IRRef ref = regcost_ref(as->cost[r]); + RegSP rs = as->parentmap[ref - REF_FIRST]; + rset_clear(work, r); + if (ra_hasspill(regsp_spill(rs))) { + int32_t ofs = sps_scale(regsp_spill(rs)); + ra_free(as, r); + emit_spload(as, IR(ref), r, ofs); + checkmclim(as); + } + } + } + + /* Shuffle registers to match up target regs with parent regs. */ + for (;;) { + RegSet work; + + /* Repeatedly coalesce free live registers by moving to their target. */ + while ((work = as->freeset & live) != RSET_EMPTY) { + Reg rp = rset_pickbot(work); + IRIns *ir = IR(sloadins[rp]); + rset_clear(live, rp); + rset_clear(allow, rp); + ra_free(as, ir->r); + emit_movrr(as, ir, ir->r, rp); + checkmclim(as); + } + + /* We're done if no live registers remain. */ + if (live == RSET_EMPTY) + break; + + /* Break cycles by renaming one target to a temp. register. */ + if (live & RSET_GPR) { + RegSet tmpset = as->freeset & ~live & allow & RSET_GPR; + if (tmpset == RSET_EMPTY) + lj_trace_err(as->J, LJ_TRERR_NYICOAL); + ra_rename(as, rset_pickbot(live & RSET_GPR), rset_pickbot(tmpset)); + } + if (!LJ_SOFTFP && (live & RSET_FPR)) { + RegSet tmpset = as->freeset & ~live & allow & RSET_FPR; + if (tmpset == RSET_EMPTY) + lj_trace_err(as->J, LJ_TRERR_NYICOAL); + ra_rename(as, rset_pickbot(live & RSET_FPR), rset_pickbot(tmpset)); + } + checkmclim(as); + /* Continue with coalescing to fix up the broken cycle(s). */ + } + + /* Inherit top stack slot already checked by parent trace. */ + as->T->topslot = as->parent->topslot; + if (as->topslot > as->T->topslot) { /* Need to check for higher slot? */ +#ifdef EXITSTATE_CHECKEXIT + /* Highest exit + 1 indicates stack check. */ + ExitNo exitno = as->T->nsnap; +#else + /* Reuse the parent exit in the context of the parent trace. */ + ExitNo exitno = as->J->exitno; +#endif + as->T->topslot = (uint8_t)as->topslot; /* Remember for child traces. */ + asm_stack_check(as, as->topslot, irp, allow & RSET_GPR, exitno); + } +} + +/* -- Tail of trace ------------------------------------------------------- */ + +/* Get base slot for a snapshot. */ +static BCReg asm_baseslot(ASMState *as, SnapShot *snap, int *gotframe) +{ + SnapEntry *map = &as->T->snapmap[snap->mapofs]; + MSize n; + for (n = snap->nent; n > 0; n--) { + SnapEntry sn = map[n-1]; + if ((sn & SNAP_FRAME)) { + *gotframe = 1; + return snap_slot(sn); + } + } + return 0; +} + +/* Link to another trace. */ +static void asm_tail_link(ASMState *as) +{ + SnapNo snapno = as->T->nsnap-1; /* Last snapshot. */ + SnapShot *snap = &as->T->snap[snapno]; + int gotframe = 0; + BCReg baseslot = asm_baseslot(as, snap, &gotframe); + + as->topslot = snap->topslot; + checkmclim(as); + ra_allocref(as, REF_BASE, RID2RSET(RID_BASE)); + + if (as->T->link == 0) { + /* Setup fixed registers for exit to interpreter. */ + const BCIns *pc = snap_pc(as->T->snapmap[snap->mapofs + snap->nent]); + int32_t mres; + if (bc_op(*pc) == BC_JLOOP) { /* NYI: find a better way to do this. */ + BCIns *retpc = &traceref(as->J, bc_d(*pc))->startins; + if (bc_isret(bc_op(*retpc))) + pc = retpc; + } + ra_allockreg(as, i32ptr(J2GG(as->J)->dispatch), RID_DISPATCH); + ra_allockreg(as, i32ptr(pc), RID_LPC); + mres = (int32_t)(snap->nslots - baseslot); + switch (bc_op(*pc)) { + case BC_CALLM: case BC_CALLMT: + mres -= (int32_t)(1 + bc_a(*pc) + bc_c(*pc)); break; + case BC_RETM: mres -= (int32_t)(bc_a(*pc) + bc_d(*pc)); break; + case BC_TSETM: mres -= (int32_t)bc_a(*pc); break; + default: if (bc_op(*pc) < BC_FUNCF) mres = 0; break; + } + ra_allockreg(as, mres, RID_RET); /* Return MULTRES or 0. */ + } else if (baseslot) { + /* Save modified BASE for linking to trace with higher start frame. */ + emit_setgl(as, RID_BASE, jit_base); + } + emit_addptr(as, RID_BASE, 8*(int32_t)baseslot); + + /* Sync the interpreter state with the on-trace state. */ + asm_stack_restore(as, snap); + + /* Root traces that add frames need to check the stack at the end. */ + if (!as->parent && gotframe) + asm_stack_check(as, as->topslot, NULL, as->freeset & RSET_GPR, snapno); +} + +/* -- Trace setup --------------------------------------------------------- */ + +/* Clear reg/sp for all instructions and add register hints. */ +static void asm_setup_regsp(ASMState *as) +{ + GCtrace *T = as->T; + int sink = T->sinktags; + IRRef nins = T->nins; + IRIns *ir, *lastir; + int inloop; +#if LJ_TARGET_ARM + uint32_t rload = 0xa6402a64; +#endif + + ra_setup(as); + + /* Clear reg/sp for constants. */ + for (ir = IR(T->nk), lastir = IR(REF_BASE); ir < lastir; ir++) + ir->prev = REGSP_INIT; + + /* REF_BASE is used for implicit references to the BASE register. */ + lastir->prev = REGSP_HINT(RID_BASE); + + ir = IR(nins-1); + if (ir->o == IR_RENAME) { + do { ir--; nins--; } while (ir->o == IR_RENAME); + T->nins = nins; /* Remove any renames left over from ASM restart. */ + } + as->snaprename = nins; + as->snapref = nins; + as->snapno = T->nsnap; + + as->stopins = REF_BASE; + as->orignins = nins; + as->curins = nins; + + /* Setup register hints for parent link instructions. */ + ir = IR(REF_FIRST); + if (as->parent) { + uint16_t *p; + lastir = lj_snap_regspmap(as->parent, as->J->exitno, ir); + if (lastir - ir > LJ_MAX_JSLOTS) + lj_trace_err(as->J, LJ_TRERR_NYICOAL); + as->stopins = (IRRef)((lastir-1) - as->ir); + for (p = as->parentmap; ir < lastir; ir++) { + RegSP rs = ir->prev; + *p++ = (uint16_t)rs; /* Copy original parent RegSP to parentmap. */ + if (!ra_hasspill(regsp_spill(rs))) + ir->prev = (uint16_t)REGSP_HINT(regsp_reg(rs)); + else + ir->prev = REGSP_INIT; + } + } + + inloop = 0; + as->evenspill = SPS_FIRST; + for (lastir = IR(nins); ir < lastir; ir++) { + if (sink) { + if (ir->r == RID_SINK) + continue; + if (ir->r == RID_SUNK) { /* Revert after ASM restart. */ + ir->r = RID_SINK; + continue; + } + } + switch (ir->o) { + case IR_LOOP: + inloop = 1; + break; +#if LJ_TARGET_ARM + case IR_SLOAD: + if (!((ir->op2 & IRSLOAD_TYPECHECK) || (ir+1)->o == IR_HIOP)) + break; + /* fallthrough */ + case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: + if (!LJ_SOFTFP && irt_isnum(ir->t)) break; + ir->prev = (uint16_t)REGSP_HINT((rload & 15)); + rload = lj_ror(rload, 4); + continue; +#endif + case IR_CALLXS: { + CCallInfo ci; + ci.flags = asm_callx_flags(as, ir); + ir->prev = asm_setup_call_slots(as, ir, &ci); + if (inloop) + as->modset |= RSET_SCRATCH; + continue; + } + case IR_CALLN: case IR_CALLL: case IR_CALLS: { + const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; + ir->prev = asm_setup_call_slots(as, ir, ci); + if (inloop) + as->modset |= (ci->flags & CCI_NOFPRCLOBBER) ? + (RSET_SCRATCH & ~RSET_FPR) : RSET_SCRATCH; + continue; + } +#if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) + case IR_HIOP: + switch ((ir-1)->o) { +#if LJ_SOFTFP && LJ_TARGET_ARM + case IR_SLOAD: case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: + if (ra_hashint((ir-1)->r)) { + ir->prev = (ir-1)->prev + 1; + continue; + } + break; +#endif +#if !LJ_SOFTFP && LJ_NEED_FP64 + case IR_CONV: + if (irt_isfp((ir-1)->t)) { + ir->prev = REGSP_HINT(RID_FPRET); + continue; + } + /* fallthrough */ +#endif + case IR_CALLN: case IR_CALLXS: +#if LJ_SOFTFP + case IR_MIN: case IR_MAX: +#endif + (ir-1)->prev = REGSP_HINT(RID_RETLO); + ir->prev = REGSP_HINT(RID_RETHI); + continue; + default: + break; + } + break; +#endif +#if LJ_SOFTFP + case IR_MIN: case IR_MAX: + if ((ir+1)->o != IR_HIOP) break; + /* fallthrough */ +#endif + /* C calls evict all scratch regs and return results in RID_RET. */ + case IR_SNEW: case IR_XSNEW: case IR_NEWREF: + if (REGARG_NUMGPR < 3 && as->evenspill < 3) + as->evenspill = 3; /* lj_str_new and lj_tab_newkey need 3 args. */ + case IR_TNEW: case IR_TDUP: case IR_CNEW: case IR_CNEWI: case IR_TOSTR: + ir->prev = REGSP_HINT(RID_RET); + if (inloop) + as->modset = RSET_SCRATCH; + continue; + case IR_STRTO: case IR_OBAR: + if (inloop) + as->modset = RSET_SCRATCH; + break; +#if !LJ_TARGET_X86ORX64 && !LJ_SOFTFP + case IR_ATAN2: case IR_LDEXP: +#endif + case IR_POW: + if (!LJ_SOFTFP && irt_isnum(ir->t)) { +#if LJ_TARGET_X86ORX64 + ir->prev = REGSP_HINT(RID_XMM0); + if (inloop) + as->modset |= RSET_RANGE(RID_XMM0, RID_XMM1+1)|RID2RSET(RID_EAX); +#else + ir->prev = REGSP_HINT(RID_FPRET); + if (inloop) + as->modset |= RSET_SCRATCH; +#endif + continue; + } + /* fallthrough for integer POW */ + case IR_DIV: case IR_MOD: + if (!irt_isnum(ir->t)) { + ir->prev = REGSP_HINT(RID_RET); + if (inloop) + as->modset |= (RSET_SCRATCH & RSET_GPR); + continue; + } + break; + case IR_FPMATH: +#if LJ_TARGET_X86ORX64 + if (ir->op2 == IRFPM_EXP2) { /* May be joined to lj_vm_pow_sse. */ + ir->prev = REGSP_HINT(RID_XMM0); +#if !LJ_64 + if (as->evenspill < 4) /* Leave room for 16 byte scratch area. */ + as->evenspill = 4; +#endif + if (inloop) + as->modset |= RSET_RANGE(RID_XMM0, RID_XMM2+1)|RID2RSET(RID_EAX); + continue; + } else if (ir->op2 <= IRFPM_TRUNC && !(as->flags & JIT_F_SSE4_1)) { + ir->prev = REGSP_HINT(RID_XMM0); + if (inloop) + as->modset |= RSET_RANGE(RID_XMM0, RID_XMM3+1)|RID2RSET(RID_EAX); + continue; + } + break; +#else + ir->prev = REGSP_HINT(RID_FPRET); + if (inloop) + as->modset |= RSET_SCRATCH; + continue; +#endif +#if LJ_TARGET_X86ORX64 + /* Non-constant shift counts need to be in RID_ECX on x86/x64. */ + case IR_BSHL: case IR_BSHR: case IR_BSAR: case IR_BROL: case IR_BROR: + if (!irref_isk(ir->op2) && !ra_hashint(IR(ir->op2)->r)) { + IR(ir->op2)->r = REGSP_HINT(RID_ECX); + if (inloop) + rset_set(as->modset, RID_ECX); + } + break; +#endif + /* Do not propagate hints across type conversions or loads. */ + case IR_TOBIT: + case IR_XLOAD: +#if !LJ_TARGET_ARM + case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: +#endif + break; + case IR_CONV: + if (irt_isfp(ir->t) || (ir->op2 & IRCONV_SRCMASK) == IRT_NUM || + (ir->op2 & IRCONV_SRCMASK) == IRT_FLOAT) + break; + /* fallthrough */ + default: + /* Propagate hints across likely 'op reg, imm' or 'op reg'. */ + if (irref_isk(ir->op2) && !irref_isk(ir->op1) && + ra_hashint(regsp_reg(IR(ir->op1)->prev))) { + ir->prev = IR(ir->op1)->prev; + continue; + } + break; + } + ir->prev = REGSP_INIT; + } + if ((as->evenspill & 1)) + as->oddspill = as->evenspill++; + else + as->oddspill = 0; +} + +/* -- Assembler core ------------------------------------------------------ */ + +/* Assemble a trace. */ +void lj_asm_trace(jit_State *J, GCtrace *T) +{ + ASMState as_; + ASMState *as = &as_; + MCode *origtop; + + /* Ensure an initialized instruction beyond the last one for HIOP checks. */ + J->cur.nins = lj_ir_nextins(J); + J->cur.ir[J->cur.nins].o = IR_NOP; + + /* Setup initial state. Copy some fields to reduce indirections. */ + as->J = J; + as->T = T; + as->ir = T->ir; + as->flags = J->flags; + as->loopref = J->loopref; + as->realign = NULL; + as->loopinv = 0; + as->parent = J->parent ? traceref(J, J->parent) : NULL; + + /* Reserve MCode memory. */ + as->mctop = origtop = lj_mcode_reserve(J, &as->mcbot); + as->mcp = as->mctop; + as->mclim = as->mcbot + MCLIM_REDZONE; + asm_setup_target(as); + + do { + as->mcp = as->mctop; +#ifdef LUA_USE_ASSERT + as->mcp_prev = as->mcp; +#endif + as->curins = T->nins; + RA_DBG_START(); + RA_DBGX((as, "===== STOP =====")); + + /* General trace setup. Emit tail of trace. */ + asm_tail_prep(as); + as->mcloop = NULL; + as->flagmcp = NULL; + as->topslot = 0; + as->gcsteps = 0; + as->sectref = as->loopref; + as->fuseref = (as->flags & JIT_F_OPT_FUSE) ? as->loopref : FUSE_DISABLED; + asm_setup_regsp(as); + if (!as->loopref) + asm_tail_link(as); + + /* Assemble a trace in linear backwards order. */ + for (as->curins--; as->curins > as->stopins; as->curins--) { + IRIns *ir = IR(as->curins); + lua_assert(!(LJ_32 && irt_isint64(ir->t))); /* Handled by SPLIT. */ + if (!ra_used(ir) && !ir_sideeff(ir) && (as->flags & JIT_F_OPT_DCE)) + continue; /* Dead-code elimination can be soooo easy. */ + if (irt_isguard(ir->t)) + asm_snap_prep(as); + RA_DBG_REF(); + checkmclim(as); + asm_ir(as, ir); + } + } while (as->realign); /* Retry in case the MCode needs to be realigned. */ + + /* Emit head of trace. */ + RA_DBG_REF(); + checkmclim(as); + if (as->gcsteps > 0) { + as->curins = as->T->snap[0].ref; + asm_snap_prep(as); /* The GC check is a guard. */ + asm_gc_check(as); + } + ra_evictk(as); + if (as->parent) + asm_head_side(as); + else + asm_head_root(as); + asm_phi_fixup(as); + + RA_DBGX((as, "===== START ====")); + RA_DBG_FLUSH(); + if (as->freeset != RSET_ALL) + lj_trace_err(as->J, LJ_TRERR_BADRA); /* Ouch! Should never happen. */ + + /* Set trace entry point before fixing up tail to allow link to self. */ + T->mcode = as->mcp; + T->mcloop = as->mcloop ? (MSize)((char *)as->mcloop - (char *)as->mcp) : 0; + if (!as->loopref) + asm_tail_fixup(as, T->link); /* Note: this may change as->mctop! */ + T->szmcode = (MSize)((char *)as->mctop - (char *)as->mcp); + lj_mcode_sync(T->mcode, origtop); +} + +#undef IR + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_asm.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_asm.h new file mode 100644 index 000000000..85f297632 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_asm.h @@ -0,0 +1,17 @@ +/* +** IR assembler (SSA IR -> machine code). +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_ASM_H +#define _LJ_ASM_H + +#include "lj_jit.h" + +#if LJ_HASJIT +LJ_FUNC void lj_asm_trace(jit_State *J, GCtrace *T); +LJ_FUNC void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, + MCode *target); +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_arm.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_arm.h new file mode 100644 index 000000000..9e4cf4367 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_arm.h @@ -0,0 +1,2361 @@ +/* +** ARM IR assembler (SSA IR -> machine code). +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* -- Register allocator extensions --------------------------------------- */ + +/* Allocate a register with a hint. */ +static Reg ra_hintalloc(ASMState *as, IRRef ref, Reg hint, RegSet allow) +{ + Reg r = IR(ref)->r; + if (ra_noreg(r)) { + if (!ra_hashint(r) && !iscrossref(as, ref)) + ra_sethint(IR(ref)->r, hint); /* Propagate register hint. */ + r = ra_allocref(as, ref, allow); + } + ra_noweak(as, r); + return r; +} + +/* Allocate a scratch register pair. */ +static Reg ra_scratchpair(ASMState *as, RegSet allow) +{ + RegSet pick1 = as->freeset & allow; + RegSet pick2 = pick1 & (pick1 >> 1) & RSET_GPREVEN; + Reg r; + if (pick2) { + r = rset_picktop(pick2); + } else { + RegSet pick = pick1 & (allow >> 1) & RSET_GPREVEN; + if (pick) { + r = rset_picktop(pick); + ra_restore(as, regcost_ref(as->cost[r+1])); + } else { + pick = pick1 & (allow << 1) & RSET_GPRODD; + if (pick) { + r = ra_restore(as, regcost_ref(as->cost[rset_picktop(pick)-1])); + } else { + r = ra_evict(as, allow & (allow >> 1) & RSET_GPREVEN); + ra_restore(as, regcost_ref(as->cost[r+1])); + } + } + } + lua_assert(rset_test(RSET_GPREVEN, r)); + ra_modified(as, r); + ra_modified(as, r+1); + RA_DBGX((as, "scratchpair $r $r", r, r+1)); + return r; +} + +#if !LJ_SOFTFP +/* Allocate two source registers for three-operand instructions. */ +static Reg ra_alloc2(ASMState *as, IRIns *ir, RegSet allow) +{ + IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); + Reg left = irl->r, right = irr->r; + if (ra_hasreg(left)) { + ra_noweak(as, left); + if (ra_noreg(right)) + right = ra_allocref(as, ir->op2, rset_exclude(allow, left)); + else + ra_noweak(as, right); + } else if (ra_hasreg(right)) { + ra_noweak(as, right); + left = ra_allocref(as, ir->op1, rset_exclude(allow, right)); + } else if (ra_hashint(right)) { + right = ra_allocref(as, ir->op2, allow); + left = ra_alloc1(as, ir->op1, rset_exclude(allow, right)); + } else { + left = ra_allocref(as, ir->op1, allow); + right = ra_alloc1(as, ir->op2, rset_exclude(allow, left)); + } + return left | (right << 8); +} +#endif + +/* -- Guard handling ------------------------------------------------------ */ + +/* Generate an exit stub group at the bottom of the reserved MCode memory. */ +static MCode *asm_exitstub_gen(ASMState *as, ExitNo group) +{ + MCode *mxp = as->mcbot; + int i; + if (mxp + 4*4+4*EXITSTUBS_PER_GROUP >= as->mctop) + asm_mclimit(as); + /* str lr, [sp]; bl ->vm_exit_handler; .long DISPATCH_address, group. */ + *mxp++ = ARMI_STR|ARMI_LS_P|ARMI_LS_U|ARMF_D(RID_LR)|ARMF_N(RID_SP); + *mxp = ARMI_BL|((((MCode *)(void *)lj_vm_exit_handler-mxp)-2)&0x00ffffffu); + mxp++; + *mxp++ = (MCode)i32ptr(J2GG(as->J)->dispatch); /* DISPATCH address */ + *mxp++ = group*EXITSTUBS_PER_GROUP; + for (i = 0; i < EXITSTUBS_PER_GROUP; i++) + *mxp++ = ARMI_B|((-6-i)&0x00ffffffu); + lj_mcode_sync(as->mcbot, mxp); + lj_mcode_commitbot(as->J, mxp); + as->mcbot = mxp; + as->mclim = as->mcbot + MCLIM_REDZONE; + return mxp - EXITSTUBS_PER_GROUP; +} + +/* Setup all needed exit stubs. */ +static void asm_exitstub_setup(ASMState *as, ExitNo nexits) +{ + ExitNo i; + if (nexits >= EXITSTUBS_PER_GROUP*LJ_MAX_EXITSTUBGR) + lj_trace_err(as->J, LJ_TRERR_SNAPOV); + for (i = 0; i < (nexits+EXITSTUBS_PER_GROUP-1)/EXITSTUBS_PER_GROUP; i++) + if (as->J->exitstubgroup[i] == NULL) + as->J->exitstubgroup[i] = asm_exitstub_gen(as, i); +} + +/* Emit conditional branch to exit for guard. */ +static void asm_guardcc(ASMState *as, ARMCC cc) +{ + MCode *target = exitstub_addr(as->J, as->snapno); + MCode *p = as->mcp; + if (LJ_UNLIKELY(p == as->invmcp)) { + as->loopinv = 1; + *p = ARMI_BL | ((target-p-2) & 0x00ffffffu); + emit_branch(as, ARMF_CC(ARMI_B, cc^1), p+1); + return; + } + emit_branch(as, ARMF_CC(ARMI_BL, cc), target); +} + +/* -- Operand fusion ------------------------------------------------------ */ + +/* Limit linear search to this distance. Avoids O(n^2) behavior. */ +#define CONFLICT_SEARCH_LIM 31 + +/* Check if there's no conflicting instruction between curins and ref. */ +static int noconflict(ASMState *as, IRRef ref, IROp conflict) +{ + IRIns *ir = as->ir; + IRRef i = as->curins; + if (i > ref + CONFLICT_SEARCH_LIM) + return 0; /* Give up, ref is too far away. */ + while (--i > ref) + if (ir[i].o == conflict) + return 0; /* Conflict found. */ + return 1; /* Ok, no conflict. */ +} + +/* Fuse the array base of colocated arrays. */ +static int32_t asm_fuseabase(ASMState *as, IRRef ref) +{ + IRIns *ir = IR(ref); + if (ir->o == IR_TNEW && ir->op1 <= LJ_MAX_COLOSIZE && + !neverfuse(as) && noconflict(as, ref, IR_NEWREF)) + return (int32_t)sizeof(GCtab); + return 0; +} + +/* Fuse array/hash/upvalue reference into register+offset operand. */ +static Reg asm_fuseahuref(ASMState *as, IRRef ref, int32_t *ofsp, RegSet allow, + int lim) +{ + IRIns *ir = IR(ref); + if (ra_noreg(ir->r)) { + if (ir->o == IR_AREF) { + if (mayfuse(as, ref)) { + if (irref_isk(ir->op2)) { + IRRef tab = IR(ir->op1)->op1; + int32_t ofs = asm_fuseabase(as, tab); + IRRef refa = ofs ? tab : ir->op1; + ofs += 8*IR(ir->op2)->i; + if (ofs > -lim && ofs < lim) { + *ofsp = ofs; + return ra_alloc1(as, refa, allow); + } + } + } + } else if (ir->o == IR_HREFK) { + if (mayfuse(as, ref)) { + int32_t ofs = (int32_t)(IR(ir->op2)->op2 * sizeof(Node)); + if (ofs < lim) { + *ofsp = ofs; + return ra_alloc1(as, ir->op1, allow); + } + } + } else if (ir->o == IR_UREFC) { + if (irref_isk(ir->op1)) { + GCfunc *fn = ir_kfunc(IR(ir->op1)); + int32_t ofs = i32ptr(&gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.tv); + *ofsp = (ofs & 255); /* Mask out less bits to allow LDRD. */ + return ra_allock(as, (ofs & ~255), allow); + } + } + } + *ofsp = 0; + return ra_alloc1(as, ref, allow); +} + +/* Fuse m operand into arithmetic/logic instructions. */ +static uint32_t asm_fuseopm(ASMState *as, ARMIns ai, IRRef ref, RegSet allow) +{ + IRIns *ir = IR(ref); + if (ra_hasreg(ir->r)) { + ra_noweak(as, ir->r); + return ARMF_M(ir->r); + } else if (irref_isk(ref)) { + uint32_t k = emit_isk12(ai, ir->i); + if (k) + return k; + } else if (mayfuse(as, ref)) { + if (ir->o >= IR_BSHL && ir->o <= IR_BROR) { + Reg m = ra_alloc1(as, ir->op1, allow); + ARMShift sh = ir->o == IR_BSHL ? ARMSH_LSL : + ir->o == IR_BSHR ? ARMSH_LSR : + ir->o == IR_BSAR ? ARMSH_ASR : ARMSH_ROR; + if (irref_isk(ir->op2)) { + return m | ARMF_SH(sh, (IR(ir->op2)->i & 31)); + } else { + Reg s = ra_alloc1(as, ir->op2, rset_exclude(allow, m)); + return m | ARMF_RSH(sh, s); + } + } else if (ir->o == IR_ADD && ir->op1 == ir->op2) { + Reg m = ra_alloc1(as, ir->op1, allow); + return m | ARMF_SH(ARMSH_LSL, 1); + } + } + return ra_allocref(as, ref, allow); +} + +/* Fuse shifts into loads/stores. Only bother with BSHL 2 => lsl #2. */ +static IRRef asm_fuselsl2(ASMState *as, IRRef ref) +{ + IRIns *ir = IR(ref); + if (ra_noreg(ir->r) && mayfuse(as, ref) && ir->o == IR_BSHL && + irref_isk(ir->op2) && IR(ir->op2)->i == 2) + return ir->op1; + return 0; /* No fusion. */ +} + +/* Fuse XLOAD/XSTORE reference into load/store operand. */ +static void asm_fusexref(ASMState *as, ARMIns ai, Reg rd, IRRef ref, + RegSet allow, int32_t ofs) +{ + IRIns *ir = IR(ref); + Reg base; + if (ra_noreg(ir->r) && canfuse(as, ir)) { + int32_t lim = (!LJ_SOFTFP && (ai & 0x08000000)) ? 1024 : + (ai & 0x04000000) ? 4096 : 256; + if (ir->o == IR_ADD) { + int32_t ofs2; + if (irref_isk(ir->op2) && + (ofs2 = ofs + IR(ir->op2)->i) > -lim && ofs2 < lim && + (!(!LJ_SOFTFP && (ai & 0x08000000)) || !(ofs2 & 3))) { + ofs = ofs2; + ref = ir->op1; + } else if (ofs == 0 && !(!LJ_SOFTFP && (ai & 0x08000000))) { + IRRef lref = ir->op1, rref = ir->op2; + Reg rn, rm; + if ((ai & 0x04000000)) { + IRRef sref = asm_fuselsl2(as, rref); + if (sref) { + rref = sref; + ai |= ARMF_SH(ARMSH_LSL, 2); + } else if ((sref = asm_fuselsl2(as, lref)) != 0) { + lref = rref; + rref = sref; + ai |= ARMF_SH(ARMSH_LSL, 2); + } + } + rn = ra_alloc1(as, lref, allow); + rm = ra_alloc1(as, rref, rset_exclude(allow, rn)); + if ((ai & 0x04000000)) ai |= ARMI_LS_R; + emit_dnm(as, ai|ARMI_LS_P|ARMI_LS_U, rd, rn, rm); + return; + } + } else if (ir->o == IR_STRREF && !(!LJ_SOFTFP && (ai & 0x08000000))) { + lua_assert(ofs == 0); + ofs = (int32_t)sizeof(GCstr); + if (irref_isk(ir->op2)) { + ofs += IR(ir->op2)->i; + ref = ir->op1; + } else if (irref_isk(ir->op1)) { + ofs += IR(ir->op1)->i; + ref = ir->op2; + } else { + /* NYI: Fuse ADD with constant. */ + Reg rn = ra_alloc1(as, ir->op1, allow); + uint32_t m = asm_fuseopm(as, 0, ir->op2, rset_exclude(allow, rn)); + if ((ai & 0x04000000)) + emit_lso(as, ai, rd, rd, ofs); + else + emit_lsox(as, ai, rd, rd, ofs); + emit_dn(as, ARMI_ADD^m, rd, rn); + return; + } + if (ofs <= -lim || ofs >= lim) { + Reg rn = ra_alloc1(as, ref, allow); + Reg rm = ra_allock(as, ofs, rset_exclude(allow, rn)); + if ((ai & 0x04000000)) ai |= ARMI_LS_R; + emit_dnm(as, ai|ARMI_LS_P|ARMI_LS_U, rd, rn, rm); + return; + } + } + } + base = ra_alloc1(as, ref, allow); +#if !LJ_SOFTFP + if ((ai & 0x08000000)) + emit_vlso(as, ai, rd, base, ofs); + else +#endif + if ((ai & 0x04000000)) + emit_lso(as, ai, rd, base, ofs); + else + emit_lsox(as, ai, rd, base, ofs); +} + +#if !LJ_SOFTFP +/* Fuse to multiply-add/sub instruction. */ +static int asm_fusemadd(ASMState *as, IRIns *ir, ARMIns ai, ARMIns air) +{ + IRRef lref = ir->op1, rref = ir->op2; + IRIns *irm; + if (lref != rref && + ((mayfuse(as, lref) && (irm = IR(lref), irm->o == IR_MUL) && + ra_noreg(irm->r)) || + (mayfuse(as, rref) && (irm = IR(rref), irm->o == IR_MUL) && + (rref = lref, ai = air, ra_noreg(irm->r))))) { + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg add = ra_hintalloc(as, rref, dest, RSET_FPR); + Reg right, left = ra_alloc2(as, irm, + rset_exclude(rset_exclude(RSET_FPR, dest), add)); + right = (left >> 8); left &= 255; + emit_dnm(as, ai, (dest & 15), (left & 15), (right & 15)); + if (dest != add) emit_dm(as, ARMI_VMOV_D, (dest & 15), (add & 15)); + return 1; + } + return 0; +} +#endif + +/* -- Calls --------------------------------------------------------------- */ + +/* Generate a call to a C function. */ +static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args) +{ + uint32_t n, nargs = CCI_NARGS(ci); + int32_t ofs = 0; +#if LJ_SOFTFP + Reg gpr = REGARG_FIRSTGPR; +#else + Reg gpr, fpr = REGARG_FIRSTFPR, fprodd = 0; +#endif + if ((void *)ci->func) + emit_call(as, (void *)ci->func); +#if !LJ_SOFTFP + for (gpr = REGARG_FIRSTGPR; gpr <= REGARG_LASTGPR; gpr++) + as->cost[gpr] = REGCOST(~0u, ASMREF_L); + gpr = REGARG_FIRSTGPR; +#endif + for (n = 0; n < nargs; n++) { /* Setup args. */ + IRRef ref = args[n]; + IRIns *ir = IR(ref); +#if !LJ_SOFTFP + if (ref && irt_isfp(ir->t)) { + RegSet of = as->freeset; + Reg src; + if (!LJ_ABI_SOFTFP && !(ci->flags & CCI_VARARG)) { + if (irt_isnum(ir->t)) { + if (fpr <= REGARG_LASTFPR) { + ra_leftov(as, fpr, ref); + fpr++; + continue; + } + } else if (fprodd) { /* Ick. */ + src = ra_alloc1(as, ref, RSET_FPR); + emit_dm(as, ARMI_VMOV_S, (fprodd & 15), (src & 15) | 0x00400000); + fprodd = 0; + continue; + } else if (fpr <= REGARG_LASTFPR) { + ra_leftov(as, fpr, ref); + fprodd = fpr++; + continue; + } + /* Workaround to protect argument GPRs from being used for remat. */ + as->freeset &= ~RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1); + src = ra_alloc1(as, ref, RSET_FPR); /* May alloc GPR to remat FPR. */ + as->freeset |= (of & RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1)); + fprodd = 0; + goto stackfp; + } + /* Workaround to protect argument GPRs from being used for remat. */ + as->freeset &= ~RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1); + src = ra_alloc1(as, ref, RSET_FPR); /* May alloc GPR to remat FPR. */ + as->freeset |= (of & RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1)); + if (irt_isnum(ir->t)) gpr = (gpr+1) & ~1u; + if (gpr <= REGARG_LASTGPR) { + lua_assert(rset_test(as->freeset, gpr)); /* Must have been evicted. */ + if (irt_isnum(ir->t)) { + lua_assert(rset_test(as->freeset, gpr+1)); /* Ditto. */ + emit_dnm(as, ARMI_VMOV_RR_D, gpr, gpr+1, (src & 15)); + gpr += 2; + } else { + emit_dn(as, ARMI_VMOV_R_S, gpr, (src & 15)); + gpr++; + } + } else { + stackfp: + if (irt_isnum(ir->t)) ofs = (ofs + 4) & ~4; + emit_spstore(as, ir, src, ofs); + ofs += irt_isnum(ir->t) ? 8 : 4; + } + } else +#endif + { + if (gpr <= REGARG_LASTGPR) { + lua_assert(rset_test(as->freeset, gpr)); /* Must have been evicted. */ + if (ref) ra_leftov(as, gpr, ref); + gpr++; + } else { + if (ref) { + Reg r = ra_alloc1(as, ref, RSET_GPR); + emit_spstore(as, ir, r, ofs); + } + ofs += 4; + } + } + } +} + +/* Setup result reg/sp for call. Evict scratch regs. */ +static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci) +{ + RegSet drop = RSET_SCRATCH; + int hiop = ((ir+1)->o == IR_HIOP); + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + if (hiop && ra_hasreg((ir+1)->r)) + rset_clear(drop, (ir+1)->r); /* Dest reg handled below. */ + ra_evictset(as, drop); /* Evictions must be performed first. */ + if (ra_used(ir)) { + lua_assert(!irt_ispri(ir->t)); + if (!LJ_SOFTFP && irt_isfp(ir->t)) { + if (LJ_ABI_SOFTFP || (ci->flags & (CCI_CASTU64|CCI_VARARG))) { + Reg dest = (ra_dest(as, ir, RSET_FPR) & 15); + if (irt_isnum(ir->t)) + emit_dnm(as, ARMI_VMOV_D_RR, RID_RETLO, RID_RETHI, dest); + else + emit_dn(as, ARMI_VMOV_S_R, RID_RET, dest); + } else { + ra_destreg(as, ir, RID_FPRET); + } + } else if (hiop) { + ra_destpair(as, ir); + } else { + ra_destreg(as, ir, RID_RET); + } + } + UNUSED(ci); +} + +static void asm_call(ASMState *as, IRIns *ir) +{ + IRRef args[CCI_NARGS_MAX]; + const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; + asm_collectargs(as, ir, ci, args); + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} + +static void asm_callx(ASMState *as, IRIns *ir) +{ + IRRef args[CCI_NARGS_MAX*2]; + CCallInfo ci; + IRRef func; + IRIns *irf; + ci.flags = asm_callx_flags(as, ir); + asm_collectargs(as, ir, &ci, args); + asm_setupresult(as, ir, &ci); + func = ir->op2; irf = IR(func); + if (irf->o == IR_CARG) { func = irf->op1; irf = IR(func); } + if (irref_isk(func)) { /* Call to constant address. */ + ci.func = (ASMFunction)(void *)(irf->i); + } else { /* Need a non-argument register for indirect calls. */ + Reg freg = ra_alloc1(as, func, RSET_RANGE(RID_R4, RID_R12+1)); + emit_m(as, ARMI_BLXr, freg); + ci.func = (ASMFunction)(void *)0; + } + asm_gencall(as, &ci, args); +} + +/* -- Returns ------------------------------------------------------------- */ + +/* Return to lower frame. Guard that it goes to the right spot. */ +static void asm_retf(ASMState *as, IRIns *ir) +{ + Reg base = ra_alloc1(as, REF_BASE, RSET_GPR); + void *pc = ir_kptr(IR(ir->op2)); + int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); + as->topslot -= (BCReg)delta; + if ((int32_t)as->topslot < 0) as->topslot = 0; + irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */ + /* Need to force a spill on REF_BASE now to update the stack slot. */ + emit_lso(as, ARMI_STR, base, RID_SP, ra_spill(as, IR(REF_BASE))); + emit_setgl(as, base, jit_base); + emit_addptr(as, base, -8*delta); + asm_guardcc(as, CC_NE); + emit_nm(as, ARMI_CMP, RID_TMP, + ra_allock(as, i32ptr(pc), rset_exclude(RSET_GPR, base))); + emit_lso(as, ARMI_LDR, RID_TMP, base, -4); +} + +/* -- Type conversions ---------------------------------------------------- */ + +#if !LJ_SOFTFP +static void asm_tointg(ASMState *as, IRIns *ir, Reg left) +{ + Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); + Reg dest = ra_dest(as, ir, RSET_GPR); + asm_guardcc(as, CC_NE); + emit_d(as, ARMI_VMRS, 0); + emit_dm(as, ARMI_VCMP_D, (tmp & 15), (left & 15)); + emit_dm(as, ARMI_VCVT_F64_S32, (tmp & 15), (tmp & 15)); + emit_dn(as, ARMI_VMOV_R_S, dest, (tmp & 15)); + emit_dm(as, ARMI_VCVT_S32_F64, (tmp & 15), (left & 15)); +} + +static void asm_tobit(ASMState *as, IRIns *ir) +{ + RegSet allow = RSET_FPR; + Reg left = ra_alloc1(as, ir->op1, allow); + Reg right = ra_alloc1(as, ir->op2, rset_clear(allow, left)); + Reg tmp = ra_scratch(as, rset_clear(allow, right)); + Reg dest = ra_dest(as, ir, RSET_GPR); + emit_dn(as, ARMI_VMOV_R_S, dest, (tmp & 15)); + emit_dnm(as, ARMI_VADD_D, (tmp & 15), (left & 15), (right & 15)); +} +#endif + +static void asm_conv(ASMState *as, IRIns *ir) +{ + IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); +#if !LJ_SOFTFP + int stfp = (st == IRT_NUM || st == IRT_FLOAT); +#endif + IRRef lref = ir->op1; + /* 64 bit integer conversions are handled by SPLIT. */ + lua_assert(!irt_isint64(ir->t) && !(st == IRT_I64 || st == IRT_U64)); +#if LJ_SOFTFP + /* FP conversions are handled by SPLIT. */ + lua_assert(!irt_isfp(ir->t) && !(st == IRT_NUM || st == IRT_FLOAT)); + /* Can't check for same types: SPLIT uses CONV int.int + BXOR for sfp NEG. */ +#else + lua_assert(irt_type(ir->t) != st); + if (irt_isfp(ir->t)) { + Reg dest = ra_dest(as, ir, RSET_FPR); + if (stfp) { /* FP to FP conversion. */ + emit_dm(as, st == IRT_NUM ? ARMI_VCVT_F32_F64 : ARMI_VCVT_F64_F32, + (dest & 15), (ra_alloc1(as, lref, RSET_FPR) & 15)); + } else { /* Integer to FP conversion. */ + Reg left = ra_alloc1(as, lref, RSET_GPR); + ARMIns ai = irt_isfloat(ir->t) ? + (st == IRT_INT ? ARMI_VCVT_F32_S32 : ARMI_VCVT_F32_U32) : + (st == IRT_INT ? ARMI_VCVT_F64_S32 : ARMI_VCVT_F64_U32); + emit_dm(as, ai, (dest & 15), (dest & 15)); + emit_dn(as, ARMI_VMOV_S_R, left, (dest & 15)); + } + } else if (stfp) { /* FP to integer conversion. */ + if (irt_isguard(ir->t)) { + /* Checked conversions are only supported from number to int. */ + lua_assert(irt_isint(ir->t) && st == IRT_NUM); + asm_tointg(as, ir, ra_alloc1(as, lref, RSET_FPR)); + } else { + Reg left = ra_alloc1(as, lref, RSET_FPR); + Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); + Reg dest = ra_dest(as, ir, RSET_GPR); + ARMIns ai; + emit_dn(as, ARMI_VMOV_R_S, dest, (tmp & 15)); + ai = irt_isint(ir->t) ? + (st == IRT_NUM ? ARMI_VCVT_S32_F64 : ARMI_VCVT_S32_F32) : + (st == IRT_NUM ? ARMI_VCVT_U32_F64 : ARMI_VCVT_U32_F32); + emit_dm(as, ai, (tmp & 15), (left & 15)); + } + } else +#endif + { + Reg dest = ra_dest(as, ir, RSET_GPR); + if (st >= IRT_I8 && st <= IRT_U16) { /* Extend to 32 bit integer. */ + Reg left = ra_alloc1(as, lref, RSET_GPR); + lua_assert(irt_isint(ir->t) || irt_isu32(ir->t)); + if ((as->flags & JIT_F_ARMV6)) { + ARMIns ai = st == IRT_I8 ? ARMI_SXTB : + st == IRT_U8 ? ARMI_UXTB : + st == IRT_I16 ? ARMI_SXTH : ARMI_UXTH; + emit_dm(as, ai, dest, left); + } else if (st == IRT_U8) { + emit_dn(as, ARMI_AND|ARMI_K12|255, dest, left); + } else { + uint32_t shift = st == IRT_I8 ? 24 : 16; + ARMShift sh = st == IRT_U16 ? ARMSH_LSR : ARMSH_ASR; + emit_dm(as, ARMI_MOV|ARMF_SH(sh, shift), dest, RID_TMP); + emit_dm(as, ARMI_MOV|ARMF_SH(ARMSH_LSL, shift), RID_TMP, left); + } + } else { /* Handle 32/32 bit no-op (cast). */ + ra_leftov(as, dest, lref); /* Do nothing, but may need to move regs. */ + } + } +} + +#if !LJ_SOFTFP && LJ_HASFFI +static void asm_conv64(ASMState *as, IRIns *ir) +{ + IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK); + IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH); + IRCallID id; + CCallInfo ci; + IRRef args[2]; + args[0] = (ir-1)->op1; + args[1] = ir->op1; + if (st == IRT_NUM || st == IRT_FLOAT) { + id = IRCALL_fp64_d2l + ((st == IRT_FLOAT) ? 2 : 0) + (dt - IRT_I64); + ir--; + } else { + id = IRCALL_fp64_l2d + ((dt == IRT_FLOAT) ? 2 : 0) + (st - IRT_I64); + } + ci = lj_ir_callinfo[id]; +#if !LJ_ABI_SOFTFP + ci.flags |= CCI_VARARG; /* These calls don't use the hard-float ABI! */ +#endif + asm_setupresult(as, ir, &ci); + asm_gencall(as, &ci, args); +} +#endif + +static void asm_strto(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_strscan_num]; + IRRef args[2]; + Reg rlo = 0, rhi = 0, tmp; + int destused = ra_used(ir); + int32_t ofs = 0; + ra_evictset(as, RSET_SCRATCH); +#if LJ_SOFTFP + if (destused) { + if (ra_hasspill(ir->s) && ra_hasspill((ir+1)->s) && + (ir->s & 1) == 0 && ir->s + 1 == (ir+1)->s) { + int i; + for (i = 0; i < 2; i++) { + Reg r = (ir+i)->r; + if (ra_hasreg(r)) { + ra_free(as, r); + ra_modified(as, r); + emit_spload(as, ir+i, r, sps_scale((ir+i)->s)); + } + } + ofs = sps_scale(ir->s); + destused = 0; + } else { + rhi = ra_dest(as, ir+1, RSET_GPR); + rlo = ra_dest(as, ir, rset_exclude(RSET_GPR, rhi)); + } + } + asm_guardcc(as, CC_EQ); + if (destused) { + emit_lso(as, ARMI_LDR, rhi, RID_SP, 4); + emit_lso(as, ARMI_LDR, rlo, RID_SP, 0); + } +#else + UNUSED(rhi); + if (destused) { + if (ra_hasspill(ir->s)) { + ofs = sps_scale(ir->s); + destused = 0; + if (ra_hasreg(ir->r)) { + ra_free(as, ir->r); + ra_modified(as, ir->r); + emit_spload(as, ir, ir->r, ofs); + } + } else { + rlo = ra_dest(as, ir, RSET_FPR); + } + } + asm_guardcc(as, CC_EQ); + if (destused) + emit_vlso(as, ARMI_VLDR_D, rlo, RID_SP, 0); +#endif + emit_n(as, ARMI_CMP|ARMI_K12|0, RID_RET); /* Test return status. */ + args[0] = ir->op1; /* GCstr *str */ + args[1] = ASMREF_TMP1; /* TValue *n */ + asm_gencall(as, ci, args); + tmp = ra_releasetmp(as, ASMREF_TMP1); + if (ofs == 0) + emit_dm(as, ARMI_MOV, tmp, RID_SP); + else + emit_opk(as, ARMI_ADD, tmp, RID_SP, ofs, RSET_GPR); +} + +/* Get pointer to TValue. */ +static void asm_tvptr(ASMState *as, Reg dest, IRRef ref) +{ + IRIns *ir = IR(ref); + if (irt_isnum(ir->t)) { + if (irref_isk(ref)) { + /* Use the number constant itself as a TValue. */ + ra_allockreg(as, i32ptr(ir_knum(ir)), dest); + } else { +#if LJ_SOFTFP + lua_assert(0); +#else + /* Otherwise force a spill and use the spill slot. */ + emit_opk(as, ARMI_ADD, dest, RID_SP, ra_spill(as, ir), RSET_GPR); +#endif + } + } else { + /* Otherwise use [sp] and [sp+4] to hold the TValue. */ + RegSet allow = rset_exclude(RSET_GPR, dest); + Reg type; + emit_dm(as, ARMI_MOV, dest, RID_SP); + if (!irt_ispri(ir->t)) { + Reg src = ra_alloc1(as, ref, allow); + emit_lso(as, ARMI_STR, src, RID_SP, 0); + } + if ((ir+1)->o == IR_HIOP) + type = ra_alloc1(as, ref+1, allow); + else + type = ra_allock(as, irt_toitype(ir->t), allow); + emit_lso(as, ARMI_STR, type, RID_SP, 4); + } +} + +static void asm_tostr(ASMState *as, IRIns *ir) +{ + IRRef args[2]; + args[0] = ASMREF_L; + as->gcsteps++; + if (irt_isnum(IR(ir->op1)->t) || (ir+1)->o == IR_HIOP) { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromnum]; + args[1] = ASMREF_TMP1; /* const lua_Number * */ + asm_setupresult(as, ir, ci); /* GCstr * */ + asm_gencall(as, ci, args); + asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op1); + } else { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromint]; + args[1] = ir->op1; /* int32_t k */ + asm_setupresult(as, ir, ci); /* GCstr * */ + asm_gencall(as, ci, args); + } +} + +/* -- Memory references --------------------------------------------------- */ + +static void asm_aref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg idx, base; + if (irref_isk(ir->op2)) { + IRRef tab = IR(ir->op1)->op1; + int32_t ofs = asm_fuseabase(as, tab); + IRRef refa = ofs ? tab : ir->op1; + uint32_t k = emit_isk12(ARMI_ADD, ofs + 8*IR(ir->op2)->i); + if (k) { + base = ra_alloc1(as, refa, RSET_GPR); + emit_dn(as, ARMI_ADD^k, dest, base); + return; + } + } + base = ra_alloc1(as, ir->op1, RSET_GPR); + idx = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, base)); + emit_dnm(as, ARMI_ADD|ARMF_SH(ARMSH_LSL, 3), dest, base, idx); +} + +/* Inlined hash lookup. Specialized for key type and for const keys. +** The equivalent C code is: +** Node *n = hashkey(t, key); +** do { +** if (lj_obj_equal(&n->key, key)) return &n->val; +** } while ((n = nextnode(n))); +** return niltv(L); +*/ +static void asm_href(ASMState *as, IRIns *ir, IROp merge) +{ + RegSet allow = RSET_GPR; + int destused = ra_used(ir); + Reg dest = ra_dest(as, ir, allow); + Reg tab = ra_alloc1(as, ir->op1, rset_clear(allow, dest)); + Reg key = 0, keyhi = 0, keynumhi = RID_NONE, tmp = RID_TMP; + IRRef refkey = ir->op2; + IRIns *irkey = IR(refkey); + IRType1 kt = irkey->t; + int32_t k = 0, khi = emit_isk12(ARMI_CMP, irt_toitype(kt)); + uint32_t khash; + MCLabel l_end, l_loop; + rset_clear(allow, tab); + if (!irref_isk(refkey) || irt_isstr(kt)) { +#if LJ_SOFTFP + key = ra_alloc1(as, refkey, allow); + rset_clear(allow, key); + if (irkey[1].o == IR_HIOP) { + if (ra_hasreg((irkey+1)->r)) { + keynumhi = (irkey+1)->r; + keyhi = RID_TMP; + ra_noweak(as, keynumhi); + } else { + keyhi = keynumhi = ra_allocref(as, refkey+1, allow); + } + rset_clear(allow, keynumhi); + khi = 0; + } +#else + if (irt_isnum(kt)) { + key = ra_scratch(as, allow); + rset_clear(allow, key); + keyhi = keynumhi = ra_scratch(as, allow); + rset_clear(allow, keyhi); + khi = 0; + } else { + key = ra_alloc1(as, refkey, allow); + rset_clear(allow, key); + } +#endif + } else if (irt_isnum(kt)) { + int32_t val = (int32_t)ir_knum(irkey)->u32.lo; + k = emit_isk12(ARMI_CMP, val); + if (!k) { + key = ra_allock(as, val, allow); + rset_clear(allow, key); + } + val = (int32_t)ir_knum(irkey)->u32.hi; + khi = emit_isk12(ARMI_CMP, val); + if (!khi) { + keyhi = ra_allock(as, val, allow); + rset_clear(allow, keyhi); + } + } else if (!irt_ispri(kt)) { + k = emit_isk12(ARMI_CMP, irkey->i); + if (!k) { + key = ra_alloc1(as, refkey, allow); + rset_clear(allow, key); + } + } + if (!irt_ispri(kt)) + tmp = ra_scratchpair(as, allow); + + /* Key not found in chain: jump to exit (if merged) or load niltv. */ + l_end = emit_label(as); + as->invmcp = NULL; + if (merge == IR_NE) + asm_guardcc(as, CC_AL); + else if (destused) + emit_loada(as, dest, niltvg(J2G(as->J))); + + /* Follow hash chain until the end. */ + l_loop = --as->mcp; + emit_n(as, ARMI_CMP|ARMI_K12|0, dest); + emit_lso(as, ARMI_LDR, dest, dest, (int32_t)offsetof(Node, next)); + + /* Type and value comparison. */ + if (merge == IR_EQ) + asm_guardcc(as, CC_EQ); + else + emit_branch(as, ARMF_CC(ARMI_B, CC_EQ), l_end); + if (!irt_ispri(kt)) { + emit_nm(as, ARMF_CC(ARMI_CMP, CC_EQ)^k, tmp, key); + emit_nm(as, ARMI_CMP^khi, tmp+1, keyhi); + emit_lsox(as, ARMI_LDRD, tmp, dest, (int32_t)offsetof(Node, key)); + } else { + emit_n(as, ARMI_CMP^khi, tmp); + emit_lso(as, ARMI_LDR, tmp, dest, (int32_t)offsetof(Node, key.it)); + } + *l_loop = ARMF_CC(ARMI_B, CC_NE) | ((as->mcp-l_loop-2) & 0x00ffffffu); + + /* Load main position relative to tab->node into dest. */ + khash = irref_isk(refkey) ? ir_khash(irkey) : 1; + if (khash == 0) { + emit_lso(as, ARMI_LDR, dest, tab, (int32_t)offsetof(GCtab, node)); + } else { + emit_dnm(as, ARMI_ADD|ARMF_SH(ARMSH_LSL, 3), dest, dest, tmp); + emit_dnm(as, ARMI_ADD|ARMF_SH(ARMSH_LSL, 1), tmp, tmp, tmp); + if (irt_isstr(kt)) { /* Fetch of str->hash is cheaper than ra_allock. */ + emit_dnm(as, ARMI_AND, tmp, tmp+1, RID_TMP); + emit_lso(as, ARMI_LDR, dest, tab, (int32_t)offsetof(GCtab, node)); + emit_lso(as, ARMI_LDR, tmp+1, key, (int32_t)offsetof(GCstr, hash)); + emit_lso(as, ARMI_LDR, RID_TMP, tab, (int32_t)offsetof(GCtab, hmask)); + } else if (irref_isk(refkey)) { + emit_opk(as, ARMI_AND, tmp, RID_TMP, (int32_t)khash, + rset_exclude(rset_exclude(RSET_GPR, tab), dest)); + emit_lso(as, ARMI_LDR, dest, tab, (int32_t)offsetof(GCtab, node)); + emit_lso(as, ARMI_LDR, RID_TMP, tab, (int32_t)offsetof(GCtab, hmask)); + } else { /* Must match with hash*() in lj_tab.c. */ + if (ra_hasreg(keynumhi)) { /* Canonicalize +-0.0 to 0.0. */ + if (keyhi == RID_TMP) + emit_dm(as, ARMF_CC(ARMI_MOV, CC_NE), keyhi, keynumhi); + emit_d(as, ARMF_CC(ARMI_MOV, CC_EQ)|ARMI_K12|0, keyhi); + } + emit_dnm(as, ARMI_AND, tmp, tmp, RID_TMP); + emit_dnm(as, ARMI_SUB|ARMF_SH(ARMSH_ROR, 32-HASH_ROT3), tmp, tmp, tmp+1); + emit_lso(as, ARMI_LDR, dest, tab, (int32_t)offsetof(GCtab, node)); + emit_dnm(as, ARMI_EOR|ARMF_SH(ARMSH_ROR, 32-((HASH_ROT2+HASH_ROT1)&31)), + tmp, tmp+1, tmp); + emit_lso(as, ARMI_LDR, RID_TMP, tab, (int32_t)offsetof(GCtab, hmask)); + emit_dnm(as, ARMI_SUB|ARMF_SH(ARMSH_ROR, 32-HASH_ROT1), tmp+1, tmp+1, tmp); + if (ra_hasreg(keynumhi)) { + emit_dnm(as, ARMI_EOR, tmp+1, tmp, key); + emit_dnm(as, ARMI_ORR|ARMI_S, RID_TMP, tmp, key); /* Test for +-0.0. */ + emit_dnm(as, ARMI_ADD, tmp, keynumhi, keynumhi); +#if !LJ_SOFTFP + emit_dnm(as, ARMI_VMOV_RR_D, key, keynumhi, + (ra_alloc1(as, refkey, RSET_FPR) & 15)); +#endif + } else { + emit_dnm(as, ARMI_EOR, tmp+1, tmp, key); + emit_opk(as, ARMI_ADD, tmp, key, (int32_t)HASH_BIAS, + rset_exclude(rset_exclude(RSET_GPR, tab), key)); + } + } + } +} + +static void asm_hrefk(ASMState *as, IRIns *ir) +{ + IRIns *kslot = IR(ir->op2); + IRIns *irkey = IR(kslot->op1); + int32_t ofs = (int32_t)(kslot->op2 * sizeof(Node)); + int32_t kofs = ofs + (int32_t)offsetof(Node, key); + Reg dest = (ra_used(ir) || ofs > 4095) ? ra_dest(as, ir, RSET_GPR) : RID_NONE; + Reg node = ra_alloc1(as, ir->op1, RSET_GPR); + Reg key = RID_NONE, type = RID_TMP, idx = node; + RegSet allow = rset_exclude(RSET_GPR, node); + lua_assert(ofs % sizeof(Node) == 0); + if (ofs > 4095) { + idx = dest; + rset_clear(allow, dest); + kofs = (int32_t)offsetof(Node, key); + } else if (ra_hasreg(dest)) { + emit_opk(as, ARMI_ADD, dest, node, ofs, allow); + } + asm_guardcc(as, CC_NE); + if (!irt_ispri(irkey->t)) { + RegSet even = (as->freeset & allow); + even = even & (even >> 1) & RSET_GPREVEN; + if (even) { + key = ra_scratch(as, even); + if (rset_test(as->freeset, key+1)) { + type = key+1; + ra_modified(as, type); + } + } else { + key = ra_scratch(as, allow); + } + rset_clear(allow, key); + } + rset_clear(allow, type); + if (irt_isnum(irkey->t)) { + emit_opk(as, ARMF_CC(ARMI_CMP, CC_EQ), 0, type, + (int32_t)ir_knum(irkey)->u32.hi, allow); + emit_opk(as, ARMI_CMP, 0, key, + (int32_t)ir_knum(irkey)->u32.lo, allow); + } else { + if (ra_hasreg(key)) + emit_opk(as, ARMF_CC(ARMI_CMP, CC_EQ), 0, key, irkey->i, allow); + emit_n(as, ARMI_CMN|ARMI_K12|-irt_toitype(irkey->t), type); + } + emit_lso(as, ARMI_LDR, type, idx, kofs+4); + if (ra_hasreg(key)) emit_lso(as, ARMI_LDR, key, idx, kofs); + if (ofs > 4095) + emit_opk(as, ARMI_ADD, dest, node, ofs, RSET_GPR); +} + +static void asm_newref(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_newkey]; + IRRef args[3]; + if (ir->r == RID_SINK) + return; + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ir->op1; /* GCtab *t */ + args[2] = ASMREF_TMP1; /* cTValue *key */ + asm_setupresult(as, ir, ci); /* TValue * */ + asm_gencall(as, ci, args); + asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op2); +} + +static void asm_uref(ASMState *as, IRIns *ir) +{ + /* NYI: Check that UREFO is still open and not aliasing a slot. */ + Reg dest = ra_dest(as, ir, RSET_GPR); + if (irref_isk(ir->op1)) { + GCfunc *fn = ir_kfunc(IR(ir->op1)); + MRef *v = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.v; + emit_lsptr(as, ARMI_LDR, dest, v); + } else { + Reg uv = ra_scratch(as, RSET_GPR); + Reg func = ra_alloc1(as, ir->op1, RSET_GPR); + if (ir->o == IR_UREFC) { + asm_guardcc(as, CC_NE); + emit_n(as, ARMI_CMP|ARMI_K12|1, RID_TMP); + emit_opk(as, ARMI_ADD, dest, uv, + (int32_t)offsetof(GCupval, tv), RSET_GPR); + emit_lso(as, ARMI_LDRB, RID_TMP, uv, (int32_t)offsetof(GCupval, closed)); + } else { + emit_lso(as, ARMI_LDR, dest, uv, (int32_t)offsetof(GCupval, v)); + } + emit_lso(as, ARMI_LDR, uv, func, + (int32_t)offsetof(GCfuncL, uvptr) + 4*(int32_t)(ir->op2 >> 8)); + } +} + +static void asm_fref(ASMState *as, IRIns *ir) +{ + UNUSED(as); UNUSED(ir); + lua_assert(!ra_used(ir)); +} + +static void asm_strref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + IRRef ref = ir->op2, refk = ir->op1; + Reg r; + if (irref_isk(ref)) { + IRRef tmp = refk; refk = ref; ref = tmp; + } else if (!irref_isk(refk)) { + uint32_t k, m = ARMI_K12|sizeof(GCstr); + Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); + IRIns *irr = IR(ir->op2); + if (ra_hasreg(irr->r)) { + ra_noweak(as, irr->r); + right = irr->r; + } else if (mayfuse(as, irr->op2) && + irr->o == IR_ADD && irref_isk(irr->op2) && + (k = emit_isk12(ARMI_ADD, + (int32_t)sizeof(GCstr) + IR(irr->op2)->i))) { + m = k; + right = ra_alloc1(as, irr->op1, rset_exclude(RSET_GPR, left)); + } else { + right = ra_allocref(as, ir->op2, rset_exclude(RSET_GPR, left)); + } + emit_dn(as, ARMI_ADD^m, dest, dest); + emit_dnm(as, ARMI_ADD, dest, left, right); + return; + } + r = ra_alloc1(as, ref, RSET_GPR); + emit_opk(as, ARMI_ADD, dest, r, + sizeof(GCstr) + IR(refk)->i, rset_exclude(RSET_GPR, r)); +} + +/* -- Loads and stores ---------------------------------------------------- */ + +static ARMIns asm_fxloadins(IRIns *ir) +{ + switch (irt_type(ir->t)) { + case IRT_I8: return ARMI_LDRSB; + case IRT_U8: return ARMI_LDRB; + case IRT_I16: return ARMI_LDRSH; + case IRT_U16: return ARMI_LDRH; + case IRT_NUM: lua_assert(!LJ_SOFTFP); return ARMI_VLDR_D; + case IRT_FLOAT: if (!LJ_SOFTFP) return ARMI_VLDR_S; + default: return ARMI_LDR; + } +} + +static ARMIns asm_fxstoreins(IRIns *ir) +{ + switch (irt_type(ir->t)) { + case IRT_I8: case IRT_U8: return ARMI_STRB; + case IRT_I16: case IRT_U16: return ARMI_STRH; + case IRT_NUM: lua_assert(!LJ_SOFTFP); return ARMI_VSTR_D; + case IRT_FLOAT: if (!LJ_SOFTFP) return ARMI_VSTR_S; + default: return ARMI_STR; + } +} + +static void asm_fload(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg idx = ra_alloc1(as, ir->op1, RSET_GPR); + ARMIns ai = asm_fxloadins(ir); + int32_t ofs; + if (ir->op2 == IRFL_TAB_ARRAY) { + ofs = asm_fuseabase(as, ir->op1); + if (ofs) { /* Turn the t->array load into an add for colocated arrays. */ + emit_dn(as, ARMI_ADD|ARMI_K12|ofs, dest, idx); + return; + } + } + ofs = field_ofs[ir->op2]; + if ((ai & 0x04000000)) + emit_lso(as, ai, dest, idx, ofs); + else + emit_lsox(as, ai, dest, idx, ofs); +} + +static void asm_fstore(ASMState *as, IRIns *ir) +{ + if (ir->r != RID_SINK) { + Reg src = ra_alloc1(as, ir->op2, RSET_GPR); + IRIns *irf = IR(ir->op1); + Reg idx = ra_alloc1(as, irf->op1, rset_exclude(RSET_GPR, src)); + int32_t ofs = field_ofs[irf->op2]; + ARMIns ai = asm_fxstoreins(ir); + if ((ai & 0x04000000)) + emit_lso(as, ai, src, idx, ofs); + else + emit_lsox(as, ai, src, idx, ofs); + } +} + +static void asm_xload(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, + (!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR); + lua_assert(!(ir->op2 & IRXLOAD_UNALIGNED)); + asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR, 0); +} + +static void asm_xstore(ASMState *as, IRIns *ir, int32_t ofs) +{ + if (ir->r != RID_SINK) { + Reg src = ra_alloc1(as, ir->op2, + (!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR); + asm_fusexref(as, asm_fxstoreins(ir), src, ir->op1, + rset_exclude(RSET_GPR, src), ofs); + } +} + +static void asm_ahuvload(ASMState *as, IRIns *ir) +{ + int hiop = (LJ_SOFTFP && (ir+1)->o == IR_HIOP); + IRType t = hiop ? IRT_NUM : irt_type(ir->t); + Reg dest = RID_NONE, type = RID_NONE, idx; + RegSet allow = RSET_GPR; + int32_t ofs = 0; + if (hiop && ra_used(ir+1)) { + type = ra_dest(as, ir+1, allow); + rset_clear(allow, type); + } + if (ra_used(ir)) { + lua_assert((LJ_SOFTFP ? 0 : irt_isnum(ir->t)) || + irt_isint(ir->t) || irt_isaddr(ir->t)); + dest = ra_dest(as, ir, (!LJ_SOFTFP && t == IRT_NUM) ? RSET_FPR : allow); + rset_clear(allow, dest); + } + idx = asm_fuseahuref(as, ir->op1, &ofs, allow, + (!LJ_SOFTFP && t == IRT_NUM) ? 1024 : 4096); + if (!hiop || type == RID_NONE) { + rset_clear(allow, idx); + if (ofs < 256 && ra_hasreg(dest) && (dest & 1) == 0 && + rset_test((as->freeset & allow), dest+1)) { + type = dest+1; + ra_modified(as, type); + } else { + type = RID_TMP; + } + } + asm_guardcc(as, t == IRT_NUM ? CC_HS : CC_NE); + emit_n(as, ARMI_CMN|ARMI_K12|-irt_toitype_(t), type); + if (ra_hasreg(dest)) { +#if !LJ_SOFTFP + if (t == IRT_NUM) + emit_vlso(as, ARMI_VLDR_D, dest, idx, ofs); + else +#endif + emit_lso(as, ARMI_LDR, dest, idx, ofs); + } + emit_lso(as, ARMI_LDR, type, idx, ofs+4); +} + +static void asm_ahustore(ASMState *as, IRIns *ir) +{ + if (ir->r != RID_SINK) { + RegSet allow = RSET_GPR; + Reg idx, src = RID_NONE, type = RID_NONE; + int32_t ofs = 0; +#if !LJ_SOFTFP + if (irt_isnum(ir->t)) { + src = ra_alloc1(as, ir->op2, RSET_FPR); + idx = asm_fuseahuref(as, ir->op1, &ofs, allow, 1024); + emit_vlso(as, ARMI_VSTR_D, src, idx, ofs); + } else +#endif + { + int hiop = (LJ_SOFTFP && (ir+1)->o == IR_HIOP); + if (!irt_ispri(ir->t)) { + src = ra_alloc1(as, ir->op2, allow); + rset_clear(allow, src); + } + if (hiop) + type = ra_alloc1(as, (ir+1)->op2, allow); + else + type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); + idx = asm_fuseahuref(as, ir->op1, &ofs, rset_exclude(allow, type), 4096); + if (ra_hasreg(src)) emit_lso(as, ARMI_STR, src, idx, ofs); + emit_lso(as, ARMI_STR, type, idx, ofs+4); + } + } +} + +static void asm_sload(ASMState *as, IRIns *ir) +{ + int32_t ofs = 8*((int32_t)ir->op1-1) + ((ir->op2 & IRSLOAD_FRAME) ? 4 : 0); + int hiop = (LJ_SOFTFP && (ir+1)->o == IR_HIOP); + IRType t = hiop ? IRT_NUM : irt_type(ir->t); + Reg dest = RID_NONE, type = RID_NONE, base; + RegSet allow = RSET_GPR; + lua_assert(!(ir->op2 & IRSLOAD_PARENT)); /* Handled by asm_head_side(). */ + lua_assert(irt_isguard(ir->t) || !(ir->op2 & IRSLOAD_TYPECHECK)); +#if LJ_SOFTFP + lua_assert(!(ir->op2 & IRSLOAD_CONVERT)); /* Handled by LJ_SOFTFP SPLIT. */ + if (hiop && ra_used(ir+1)) { + type = ra_dest(as, ir+1, allow); + rset_clear(allow, type); + } +#else + if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(ir->t) && t == IRT_INT) { + dest = ra_scratch(as, RSET_FPR); + asm_tointg(as, ir, dest); + t = IRT_NUM; /* Continue with a regular number type check. */ + } else +#endif + if (ra_used(ir)) { + Reg tmp = RID_NONE; + if ((ir->op2 & IRSLOAD_CONVERT)) + tmp = ra_scratch(as, t == IRT_INT ? RSET_FPR : RSET_GPR); + lua_assert((LJ_SOFTFP ? 0 : irt_isnum(ir->t)) || + irt_isint(ir->t) || irt_isaddr(ir->t)); + dest = ra_dest(as, ir, (!LJ_SOFTFP && t == IRT_NUM) ? RSET_FPR : allow); + rset_clear(allow, dest); + base = ra_alloc1(as, REF_BASE, allow); + if ((ir->op2 & IRSLOAD_CONVERT)) { + if (t == IRT_INT) { + emit_dn(as, ARMI_VMOV_R_S, dest, (tmp & 15)); + emit_dm(as, ARMI_VCVT_S32_F64, (tmp & 15), (tmp & 15)); + t = IRT_NUM; /* Check for original type. */ + } else { + emit_dm(as, ARMI_VCVT_F64_S32, (dest & 15), (dest & 15)); + emit_dn(as, ARMI_VMOV_S_R, tmp, (dest & 15)); + t = IRT_INT; /* Check for original type. */ + } + dest = tmp; + } + goto dotypecheck; + } + base = ra_alloc1(as, REF_BASE, allow); +dotypecheck: + rset_clear(allow, base); + if ((ir->op2 & IRSLOAD_TYPECHECK)) { + if (ra_noreg(type)) { + if (ofs < 256 && ra_hasreg(dest) && (dest & 1) == 0 && + rset_test((as->freeset & allow), dest+1)) { + type = dest+1; + ra_modified(as, type); + } else { + type = RID_TMP; + } + } + asm_guardcc(as, t == IRT_NUM ? CC_HS : CC_NE); + emit_n(as, ARMI_CMN|ARMI_K12|-irt_toitype_(t), type); + } + if (ra_hasreg(dest)) { +#if !LJ_SOFTFP + if (t == IRT_NUM) { + if (ofs < 1024) { + emit_vlso(as, ARMI_VLDR_D, dest, base, ofs); + } else { + if (ra_hasreg(type)) emit_lso(as, ARMI_LDR, type, base, ofs+4); + emit_vlso(as, ARMI_VLDR_D, dest, RID_TMP, 0); + emit_opk(as, ARMI_ADD, RID_TMP, base, ofs, allow); + return; + } + } else +#endif + emit_lso(as, ARMI_LDR, dest, base, ofs); + } + if (ra_hasreg(type)) emit_lso(as, ARMI_LDR, type, base, ofs+4); +} + +/* -- Allocations --------------------------------------------------------- */ + +#if LJ_HASFFI +static void asm_cnew(ASMState *as, IRIns *ir) +{ + CTState *cts = ctype_ctsG(J2G(as->J)); + CTypeID ctypeid = (CTypeID)IR(ir->op1)->i; + CTSize sz = (ir->o == IR_CNEWI || ir->op2 == REF_NIL) ? + lj_ctype_size(cts, ctypeid) : (CTSize)IR(ir->op2)->i; + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco]; + IRRef args[2]; + RegSet allow = (RSET_GPR & ~RSET_SCRATCH); + RegSet drop = RSET_SCRATCH; + lua_assert(sz != CTSIZE_INVALID); + + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ASMREF_TMP1; /* MSize size */ + as->gcsteps++; + + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + ra_evictset(as, drop); + if (ra_used(ir)) + ra_destreg(as, ir, RID_RET); /* GCcdata * */ + + /* Initialize immutable cdata object. */ + if (ir->o == IR_CNEWI) { + int32_t ofs = sizeof(GCcdata); + lua_assert(sz == 4 || sz == 8); + if (sz == 8) { + ofs += 4; ir++; + lua_assert(ir->o == IR_HIOP); + } + for (;;) { + Reg r = ra_alloc1(as, ir->op2, allow); + emit_lso(as, ARMI_STR, r, RID_RET, ofs); + rset_clear(allow, r); + if (ofs == sizeof(GCcdata)) break; + ofs -= 4; ir--; + } + } + /* Initialize gct and ctypeid. lj_mem_newgco() already sets marked. */ + { + uint32_t k = emit_isk12(ARMI_MOV, ctypeid); + Reg r = k ? RID_R1 : ra_allock(as, ctypeid, allow); + emit_lso(as, ARMI_STRB, RID_TMP, RID_RET, offsetof(GCcdata, gct)); + emit_lsox(as, ARMI_STRH, r, RID_RET, offsetof(GCcdata, ctypeid)); + emit_d(as, ARMI_MOV|ARMI_K12|~LJ_TCDATA, RID_TMP); + if (k) emit_d(as, ARMI_MOV^k, RID_R1); + } + asm_gencall(as, ci, args); + ra_allockreg(as, (int32_t)(sz+sizeof(GCcdata)), + ra_releasetmp(as, ASMREF_TMP1)); +} +#else +#define asm_cnew(as, ir) ((void)0) +#endif + +/* -- Write barriers ------------------------------------------------------ */ + +static void asm_tbar(ASMState *as, IRIns *ir) +{ + Reg tab = ra_alloc1(as, ir->op1, RSET_GPR); + Reg link = ra_scratch(as, rset_exclude(RSET_GPR, tab)); + Reg gr = ra_allock(as, i32ptr(J2G(as->J)), + rset_exclude(rset_exclude(RSET_GPR, tab), link)); + Reg mark = RID_TMP; + MCLabel l_end = emit_label(as); + emit_lso(as, ARMI_STR, link, tab, (int32_t)offsetof(GCtab, gclist)); + emit_lso(as, ARMI_STRB, mark, tab, (int32_t)offsetof(GCtab, marked)); + emit_lso(as, ARMI_STR, tab, gr, + (int32_t)offsetof(global_State, gc.grayagain)); + emit_dn(as, ARMI_BIC|ARMI_K12|LJ_GC_BLACK, mark, mark); + emit_lso(as, ARMI_LDR, link, gr, + (int32_t)offsetof(global_State, gc.grayagain)); + emit_branch(as, ARMF_CC(ARMI_B, CC_EQ), l_end); + emit_n(as, ARMI_TST|ARMI_K12|LJ_GC_BLACK, mark); + emit_lso(as, ARMI_LDRB, mark, tab, (int32_t)offsetof(GCtab, marked)); +} + +static void asm_obar(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_barrieruv]; + IRRef args[2]; + MCLabel l_end; + Reg obj, val, tmp; + /* No need for other object barriers (yet). */ + lua_assert(IR(ir->op1)->o == IR_UREFC); + ra_evictset(as, RSET_SCRATCH); + l_end = emit_label(as); + args[0] = ASMREF_TMP1; /* global_State *g */ + args[1] = ir->op1; /* TValue *tv */ + asm_gencall(as, ci, args); + if ((l_end[-1] >> 28) == CC_AL) + l_end[-1] = ARMF_CC(l_end[-1], CC_NE); + else + emit_branch(as, ARMF_CC(ARMI_B, CC_EQ), l_end); + ra_allockreg(as, i32ptr(J2G(as->J)), ra_releasetmp(as, ASMREF_TMP1)); + obj = IR(ir->op1)->r; + tmp = ra_scratch(as, rset_exclude(RSET_GPR, obj)); + emit_n(as, ARMF_CC(ARMI_TST, CC_NE)|ARMI_K12|LJ_GC_BLACK, tmp); + emit_n(as, ARMI_TST|ARMI_K12|LJ_GC_WHITES, RID_TMP); + val = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, obj)); + emit_lso(as, ARMI_LDRB, tmp, obj, + (int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)); + emit_lso(as, ARMI_LDRB, RID_TMP, val, (int32_t)offsetof(GChead, marked)); +} + +/* -- Arithmetic and logic operations ------------------------------------- */ + +#if !LJ_SOFTFP +static void asm_fparith(ASMState *as, IRIns *ir, ARMIns ai) +{ + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg right, left = ra_alloc2(as, ir, RSET_FPR); + right = (left >> 8); left &= 255; + emit_dnm(as, ai, (dest & 15), (left & 15), (right & 15)); +} + +static void asm_fpunary(ASMState *as, IRIns *ir, ARMIns ai) +{ + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg left = ra_hintalloc(as, ir->op1, dest, RSET_FPR); + emit_dm(as, ai, (dest & 15), (left & 15)); +} + +static int asm_fpjoin_pow(ASMState *as, IRIns *ir) +{ + IRIns *irp = IR(ir->op1); + if (irp == ir-1 && irp->o == IR_MUL && !ra_used(irp)) { + IRIns *irpp = IR(irp->op1); + if (irpp == ir-2 && irpp->o == IR_FPMATH && + irpp->op2 == IRFPM_LOG2 && !ra_used(irpp)) { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_pow]; + IRRef args[2]; + args[0] = irpp->op1; + args[1] = irp->op2; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); + return 1; + } + } + return 0; +} +#endif + +static int asm_swapops(ASMState *as, IRRef lref, IRRef rref) +{ + IRIns *ir; + if (irref_isk(rref)) + return 0; /* Don't swap constants to the left. */ + if (irref_isk(lref)) + return 1; /* But swap constants to the right. */ + ir = IR(rref); + if ((ir->o >= IR_BSHL && ir->o <= IR_BROR) || + (ir->o == IR_ADD && ir->op1 == ir->op2)) + return 0; /* Don't swap fusable operands to the left. */ + ir = IR(lref); + if ((ir->o >= IR_BSHL && ir->o <= IR_BROR) || + (ir->o == IR_ADD && ir->op1 == ir->op2)) + return 1; /* But swap fusable operands to the right. */ + return 0; /* Otherwise don't swap. */ +} + +static void asm_intop(ASMState *as, IRIns *ir, ARMIns ai) +{ + IRRef lref = ir->op1, rref = ir->op2; + Reg left, dest = ra_dest(as, ir, RSET_GPR); + uint32_t m; + if (asm_swapops(as, lref, rref)) { + IRRef tmp = lref; lref = rref; rref = tmp; + if ((ai & ~ARMI_S) == ARMI_SUB || (ai & ~ARMI_S) == ARMI_SBC) + ai ^= (ARMI_SUB^ARMI_RSB); + } + left = ra_hintalloc(as, lref, dest, RSET_GPR); + m = asm_fuseopm(as, ai, rref, rset_exclude(RSET_GPR, left)); + if (irt_isguard(ir->t)) { /* For IR_ADDOV etc. */ + asm_guardcc(as, CC_VS); + ai |= ARMI_S; + } + emit_dn(as, ai^m, dest, left); +} + +static void asm_intop_s(ASMState *as, IRIns *ir, ARMIns ai) +{ + if (as->flagmcp == as->mcp) { /* Drop cmp r, #0. */ + as->flagmcp = NULL; + as->mcp++; + ai |= ARMI_S; + } + asm_intop(as, ir, ai); +} + +static void asm_bitop(ASMState *as, IRIns *ir, ARMIns ai) +{ + if (as->flagmcp == as->mcp) { /* Try to drop cmp r, #0. */ + uint32_t cc = (as->mcp[1] >> 28); + as->flagmcp = NULL; + if (cc <= CC_NE) { + as->mcp++; + ai |= ARMI_S; + } else if (cc == CC_GE) { + *++as->mcp ^= ((CC_GE^CC_PL) << 28); + ai |= ARMI_S; + } else if (cc == CC_LT) { + *++as->mcp ^= ((CC_LT^CC_MI) << 28); + ai |= ARMI_S; + } /* else: other conds don't work with bit ops. */ + } + if (ir->op2 == 0) { + Reg dest = ra_dest(as, ir, RSET_GPR); + uint32_t m = asm_fuseopm(as, ai, ir->op1, RSET_GPR); + emit_d(as, ai^m, dest); + } else { + /* NYI: Turn BAND !k12 into uxtb, uxth or bfc or shl+shr. */ + asm_intop(as, ir, ai); + } +} + +static void asm_intneg(ASMState *as, IRIns *ir, ARMIns ai) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + emit_dn(as, ai|ARMI_K12|0, dest, left); +} + +/* NYI: use add/shift for MUL(OV) with constants. FOLD only does 2^k. */ +static void asm_intmul(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, ir->op1, rset_exclude(RSET_GPR, dest)); + Reg right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + Reg tmp = RID_NONE; + /* ARMv5 restriction: dest != left and dest_hi != left. */ + if (dest == left && left != right) { left = right; right = dest; } + if (irt_isguard(ir->t)) { /* IR_MULOV */ + if (!(as->flags & JIT_F_ARMV6) && dest == left) + tmp = left = ra_scratch(as, rset_exclude(RSET_GPR, left)); + asm_guardcc(as, CC_NE); + emit_nm(as, ARMI_TEQ|ARMF_SH(ARMSH_ASR, 31), RID_TMP, dest); + emit_dnm(as, ARMI_SMULL|ARMF_S(right), dest, RID_TMP, left); + } else { + if (!(as->flags & JIT_F_ARMV6) && dest == left) tmp = left = RID_TMP; + emit_nm(as, ARMI_MUL|ARMF_S(right), dest, left); + } + /* Only need this for the dest == left == right case. */ + if (ra_hasreg(tmp)) emit_dm(as, ARMI_MOV, tmp, right); +} + +static void asm_add(ASMState *as, IRIns *ir) +{ +#if !LJ_SOFTFP + if (irt_isnum(ir->t)) { + if (!asm_fusemadd(as, ir, ARMI_VMLA_D, ARMI_VMLA_D)) + asm_fparith(as, ir, ARMI_VADD_D); + return; + } +#endif + asm_intop_s(as, ir, ARMI_ADD); +} + +static void asm_sub(ASMState *as, IRIns *ir) +{ +#if !LJ_SOFTFP + if (irt_isnum(ir->t)) { + if (!asm_fusemadd(as, ir, ARMI_VNMLS_D, ARMI_VMLS_D)) + asm_fparith(as, ir, ARMI_VSUB_D); + return; + } +#endif + asm_intop_s(as, ir, ARMI_SUB); +} + +static void asm_mul(ASMState *as, IRIns *ir) +{ +#if !LJ_SOFTFP + if (irt_isnum(ir->t)) { + asm_fparith(as, ir, ARMI_VMUL_D); + return; + } +#endif + asm_intmul(as, ir); +} + +static void asm_neg(ASMState *as, IRIns *ir) +{ +#if !LJ_SOFTFP + if (irt_isnum(ir->t)) { + asm_fpunary(as, ir, ARMI_VNEG_D); + return; + } +#endif + asm_intneg(as, ir, ARMI_RSB); +} + +static void asm_callid(ASMState *as, IRIns *ir, IRCallID id) +{ + const CCallInfo *ci = &lj_ir_callinfo[id]; + IRRef args[2]; + args[0] = ir->op1; + args[1] = ir->op2; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} + +#if !LJ_SOFTFP +static void asm_callround(ASMState *as, IRIns *ir, int id) +{ + /* The modified regs must match with the *.dasc implementation. */ + RegSet drop = RID2RSET(RID_R0)|RID2RSET(RID_R1)|RID2RSET(RID_R2)| + RID2RSET(RID_R3)|RID2RSET(RID_R12); + RegSet of; + Reg dest, src; + ra_evictset(as, drop); + dest = ra_dest(as, ir, RSET_FPR); + emit_dnm(as, ARMI_VMOV_D_RR, RID_RETLO, RID_RETHI, (dest & 15)); + emit_call(as, id == IRFPM_FLOOR ? (void *)lj_vm_floor_sf : + id == IRFPM_CEIL ? (void *)lj_vm_ceil_sf : + (void *)lj_vm_trunc_sf); + /* Workaround to protect argument GPRs from being used for remat. */ + of = as->freeset; + as->freeset &= ~RSET_RANGE(RID_R0, RID_R1+1); + as->cost[RID_R0] = as->cost[RID_R1] = REGCOST(~0u, ASMREF_L); + src = ra_alloc1(as, ir->op1, RSET_FPR); /* May alloc GPR to remat FPR. */ + as->freeset |= (of & RSET_RANGE(RID_R0, RID_R1+1)); + emit_dnm(as, ARMI_VMOV_RR_D, RID_R0, RID_R1, (src & 15)); +} +#endif + +static void asm_bitswap(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, ir->op1, RSET_GPR); + if ((as->flags & JIT_F_ARMV6)) { + emit_dm(as, ARMI_REV, dest, left); + } else { + Reg tmp2 = dest; + if (tmp2 == left) + tmp2 = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, dest), left)); + emit_dnm(as, ARMI_EOR|ARMF_SH(ARMSH_LSR, 8), dest, tmp2, RID_TMP); + emit_dm(as, ARMI_MOV|ARMF_SH(ARMSH_ROR, 8), tmp2, left); + emit_dn(as, ARMI_BIC|ARMI_K12|256*8|255, RID_TMP, RID_TMP); + emit_dnm(as, ARMI_EOR|ARMF_SH(ARMSH_ROR, 16), RID_TMP, left, left); + } +} + +static void asm_bitshift(ASMState *as, IRIns *ir, ARMShift sh) +{ + if (irref_isk(ir->op2)) { /* Constant shifts. */ + /* NYI: Turn SHL+SHR or BAND+SHR into uxtb, uxth or ubfx. */ + /* NYI: Turn SHL+ASR into sxtb, sxth or sbfx. */ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, ir->op1, RSET_GPR); + int32_t shift = (IR(ir->op2)->i & 31); + emit_dm(as, ARMI_MOV|ARMF_SH(sh, shift), dest, left); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, ir->op1, RSET_GPR); + Reg right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_dm(as, ARMI_MOV|ARMF_RSH(sh, right), dest, left); + } +} + +static void asm_intmin_max(ASMState *as, IRIns *ir, int cc) +{ + uint32_t kcmp = 0, kmov = 0; + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + Reg right = 0; + if (irref_isk(ir->op2)) { + kcmp = emit_isk12(ARMI_CMP, IR(ir->op2)->i); + if (kcmp) kmov = emit_isk12(ARMI_MOV, IR(ir->op2)->i); + } + if (!kmov) { + kcmp = 0; + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + } + if (kmov || dest != right) { + emit_dm(as, ARMF_CC(ARMI_MOV, cc)^kmov, dest, right); + cc ^= 1; /* Must use opposite conditions for paired moves. */ + } else { + cc ^= (CC_LT^CC_GT); /* Otherwise may swap CC_LT <-> CC_GT. */ + } + if (dest != left) emit_dm(as, ARMF_CC(ARMI_MOV, cc), dest, left); + emit_nm(as, ARMI_CMP^kcmp, left, right); +} + +#if LJ_SOFTFP +static void asm_sfpmin_max(ASMState *as, IRIns *ir, int cc) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_softfp_cmp]; + RegSet drop = RSET_SCRATCH; + Reg r; + IRRef args[4]; + args[0] = ir->op1; args[1] = (ir+1)->op1; + args[2] = ir->op2; args[3] = (ir+1)->op2; + /* __aeabi_cdcmple preserves r0-r3. */ + if (ra_hasreg(ir->r)) rset_clear(drop, ir->r); + if (ra_hasreg((ir+1)->r)) rset_clear(drop, (ir+1)->r); + if (!rset_test(as->freeset, RID_R2) && + regcost_ref(as->cost[RID_R2]) == args[2]) rset_clear(drop, RID_R2); + if (!rset_test(as->freeset, RID_R3) && + regcost_ref(as->cost[RID_R3]) == args[3]) rset_clear(drop, RID_R3); + ra_evictset(as, drop); + ra_destpair(as, ir); + emit_dm(as, ARMF_CC(ARMI_MOV, cc), RID_RETHI, RID_R3); + emit_dm(as, ARMF_CC(ARMI_MOV, cc), RID_RETLO, RID_R2); + emit_call(as, (void *)ci->func); + for (r = RID_R0; r <= RID_R3; r++) + ra_leftov(as, r, args[r-RID_R0]); +} +#else +static void asm_fpmin_max(ASMState *as, IRIns *ir, int cc) +{ + Reg dest = (ra_dest(as, ir, RSET_FPR) & 15); + Reg right, left = ra_alloc2(as, ir, RSET_FPR); + right = ((left >> 8) & 15); left &= 15; + if (dest != left) emit_dm(as, ARMF_CC(ARMI_VMOV_D, cc^1), dest, left); + if (dest != right) emit_dm(as, ARMF_CC(ARMI_VMOV_D, cc), dest, right); + emit_d(as, ARMI_VMRS, 0); + emit_dm(as, ARMI_VCMP_D, left, right); +} +#endif + +static void asm_min_max(ASMState *as, IRIns *ir, int cc, int fcc) +{ +#if LJ_SOFTFP + UNUSED(fcc); +#else + if (irt_isnum(ir->t)) + asm_fpmin_max(as, ir, fcc); + else +#endif + asm_intmin_max(as, ir, cc); +} + +/* -- Comparisons --------------------------------------------------------- */ + +/* Map of comparisons to flags. ORDER IR. */ +static const uint8_t asm_compmap[IR_ABC+1] = { + /* op FP swp int cc FP cc */ + /* LT */ CC_GE + (CC_HS << 4), + /* GE x */ CC_LT + (CC_HI << 4), + /* LE */ CC_GT + (CC_HI << 4), + /* GT x */ CC_LE + (CC_HS << 4), + /* ULT x */ CC_HS + (CC_LS << 4), + /* UGE */ CC_LO + (CC_LO << 4), + /* ULE x */ CC_HI + (CC_LO << 4), + /* UGT */ CC_LS + (CC_LS << 4), + /* EQ */ CC_NE + (CC_NE << 4), + /* NE */ CC_EQ + (CC_EQ << 4), + /* ABC */ CC_LS + (CC_LS << 4) /* Same as UGT. */ +}; + +#if LJ_SOFTFP +/* FP comparisons. */ +static void asm_sfpcomp(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_softfp_cmp]; + RegSet drop = RSET_SCRATCH; + Reg r; + IRRef args[4]; + int swp = (((ir->o ^ (ir->o >> 2)) & ~(ir->o >> 3) & 1) << 1); + args[swp^0] = ir->op1; args[swp^1] = (ir+1)->op1; + args[swp^2] = ir->op2; args[swp^3] = (ir+1)->op2; + /* __aeabi_cdcmple preserves r0-r3. This helps to reduce spills. */ + for (r = RID_R0; r <= RID_R3; r++) + if (!rset_test(as->freeset, r) && + regcost_ref(as->cost[r]) == args[r-RID_R0]) rset_clear(drop, r); + ra_evictset(as, drop); + asm_guardcc(as, (asm_compmap[ir->o] >> 4)); + emit_call(as, (void *)ci->func); + for (r = RID_R0; r <= RID_R3; r++) + ra_leftov(as, r, args[r-RID_R0]); +} +#else +/* FP comparisons. */ +static void asm_fpcomp(ASMState *as, IRIns *ir) +{ + Reg left, right; + ARMIns ai; + int swp = ((ir->o ^ (ir->o >> 2)) & ~(ir->o >> 3) & 1); + if (!swp && irref_isk(ir->op2) && ir_knum(IR(ir->op2))->u64 == 0) { + left = (ra_alloc1(as, ir->op1, RSET_FPR) & 15); + right = 0; + ai = ARMI_VCMPZ_D; + } else { + left = ra_alloc2(as, ir, RSET_FPR); + if (swp) { + right = (left & 15); left = ((left >> 8) & 15); + } else { + right = ((left >> 8) & 15); left &= 15; + } + ai = ARMI_VCMP_D; + } + asm_guardcc(as, (asm_compmap[ir->o] >> 4)); + emit_d(as, ARMI_VMRS, 0); + emit_dm(as, ai, left, right); +} +#endif + +/* Integer comparisons. */ +static void asm_intcomp(ASMState *as, IRIns *ir) +{ + ARMCC cc = (asm_compmap[ir->o] & 15); + IRRef lref = ir->op1, rref = ir->op2; + Reg left; + uint32_t m; + int cmpprev0 = 0; + lua_assert(irt_isint(ir->t) || irt_isu32(ir->t) || irt_isaddr(ir->t)); + if (asm_swapops(as, lref, rref)) { + Reg tmp = lref; lref = rref; rref = tmp; + if (cc >= CC_GE) cc ^= 7; /* LT <-> GT, LE <-> GE */ + else if (cc > CC_NE) cc ^= 11; /* LO <-> HI, LS <-> HS */ + } + if (irref_isk(rref) && IR(rref)->i == 0) { + IRIns *irl = IR(lref); + cmpprev0 = (irl+1 == ir); + /* Combine comp(BAND(left, right), 0) into tst left, right. */ + if (cmpprev0 && irl->o == IR_BAND && !ra_used(irl)) { + IRRef blref = irl->op1, brref = irl->op2; + uint32_t m2 = 0; + Reg bleft; + if (asm_swapops(as, blref, brref)) { + Reg tmp = blref; blref = brref; brref = tmp; + } + if (irref_isk(brref)) { + m2 = emit_isk12(ARMI_AND, IR(brref)->i); + if ((m2 & (ARMI_AND^ARMI_BIC))) + goto notst; /* Not beneficial if we miss a constant operand. */ + } + if (cc == CC_GE) cc = CC_PL; + else if (cc == CC_LT) cc = CC_MI; + else if (cc > CC_NE) goto notst; /* Other conds don't work with tst. */ + bleft = ra_alloc1(as, blref, RSET_GPR); + if (!m2) m2 = asm_fuseopm(as, 0, brref, rset_exclude(RSET_GPR, bleft)); + asm_guardcc(as, cc); + emit_n(as, ARMI_TST^m2, bleft); + return; + } + } +notst: + left = ra_alloc1(as, lref, RSET_GPR); + m = asm_fuseopm(as, ARMI_CMP, rref, rset_exclude(RSET_GPR, left)); + asm_guardcc(as, cc); + emit_n(as, ARMI_CMP^m, left); + /* Signed comparison with zero and referencing previous ins? */ + if (cmpprev0 && (cc <= CC_NE || cc >= CC_GE)) + as->flagmcp = as->mcp; /* Allow elimination of the compare. */ +} + +#if LJ_HASFFI +/* 64 bit integer comparisons. */ +static void asm_int64comp(ASMState *as, IRIns *ir) +{ + int signedcomp = (ir->o <= IR_GT); + ARMCC cclo, cchi; + Reg leftlo, lefthi; + uint32_t mlo, mhi; + RegSet allow = RSET_GPR, oldfree; + + /* Always use unsigned comparison for loword. */ + cclo = asm_compmap[ir->o + (signedcomp ? 4 : 0)] & 15; + leftlo = ra_alloc1(as, ir->op1, allow); + oldfree = as->freeset; + mlo = asm_fuseopm(as, ARMI_CMP, ir->op2, rset_clear(allow, leftlo)); + allow &= ~(oldfree & ~as->freeset); /* Update for allocs of asm_fuseopm. */ + + /* Use signed or unsigned comparison for hiword. */ + cchi = asm_compmap[ir->o] & 15; + lefthi = ra_alloc1(as, (ir+1)->op1, allow); + mhi = asm_fuseopm(as, ARMI_CMP, (ir+1)->op2, rset_clear(allow, lefthi)); + + /* All register allocations must be performed _before_ this point. */ + if (signedcomp) { + MCLabel l_around = emit_label(as); + asm_guardcc(as, cclo); + emit_n(as, ARMI_CMP^mlo, leftlo); + emit_branch(as, ARMF_CC(ARMI_B, CC_NE), l_around); + if (cchi == CC_GE || cchi == CC_LE) cchi ^= 6; /* GE -> GT, LE -> LT */ + asm_guardcc(as, cchi); + } else { + asm_guardcc(as, cclo); + emit_n(as, ARMF_CC(ARMI_CMP, CC_EQ)^mlo, leftlo); + } + emit_n(as, ARMI_CMP^mhi, lefthi); +} +#endif + +/* -- Support for 64 bit ops in 32 bit mode ------------------------------- */ + +/* Hiword op of a split 64 bit op. Previous op must be the loword op. */ +static void asm_hiop(ASMState *as, IRIns *ir) +{ +#if LJ_HASFFI || LJ_SOFTFP + /* HIOP is marked as a store because it needs its own DCE logic. */ + int uselo = ra_used(ir-1), usehi = ra_used(ir); /* Loword/hiword used? */ + if (LJ_UNLIKELY(!(as->flags & JIT_F_OPT_DCE))) uselo = usehi = 1; + if ((ir-1)->o <= IR_NE) { /* 64 bit integer or FP comparisons. ORDER IR. */ + as->curins--; /* Always skip the loword comparison. */ +#if LJ_SOFTFP + if (!irt_isint(ir->t)) { + asm_sfpcomp(as, ir-1); + return; + } +#endif +#if LJ_HASFFI + asm_int64comp(as, ir-1); +#endif + return; +#if LJ_SOFTFP + } else if ((ir-1)->o == IR_MIN || (ir-1)->o == IR_MAX) { + as->curins--; /* Always skip the loword min/max. */ + if (uselo || usehi) + asm_sfpmin_max(as, ir-1, (ir-1)->o == IR_MIN ? CC_HI : CC_LO); + return; +#elif LJ_HASFFI + } else if ((ir-1)->o == IR_CONV) { + as->curins--; /* Always skip the CONV. */ + if (usehi || uselo) + asm_conv64(as, ir); + return; +#endif + } else if ((ir-1)->o == IR_XSTORE) { + if ((ir-1)->r != RID_SINK) + asm_xstore(as, ir, 4); + return; + } + if (!usehi) return; /* Skip unused hiword op for all remaining ops. */ + switch ((ir-1)->o) { +#if LJ_HASFFI + case IR_ADD: + as->curins--; + asm_intop(as, ir, ARMI_ADC); + asm_intop(as, ir-1, ARMI_ADD|ARMI_S); + break; + case IR_SUB: + as->curins--; + asm_intop(as, ir, ARMI_SBC); + asm_intop(as, ir-1, ARMI_SUB|ARMI_S); + break; + case IR_NEG: + as->curins--; + asm_intneg(as, ir, ARMI_RSC); + asm_intneg(as, ir-1, ARMI_RSB|ARMI_S); + break; +#endif +#if LJ_SOFTFP + case IR_SLOAD: case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: + case IR_STRTO: + if (!uselo) + ra_allocref(as, ir->op1, RSET_GPR); /* Mark lo op as used. */ + break; +#endif + case IR_CALLN: + case IR_CALLS: + case IR_CALLXS: + if (!uselo) + ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */ + break; +#if LJ_SOFTFP + case IR_ASTORE: case IR_HSTORE: case IR_USTORE: case IR_TOSTR: +#endif + case IR_CNEWI: + /* Nothing to do here. Handled by lo op itself. */ + break; + default: lua_assert(0); break; + } +#else + UNUSED(as); UNUSED(ir); lua_assert(0); +#endif +} + +/* -- Stack handling ------------------------------------------------------ */ + +/* Check Lua stack size for overflow. Use exit handler as fallback. */ +static void asm_stack_check(ASMState *as, BCReg topslot, + IRIns *irp, RegSet allow, ExitNo exitno) +{ + Reg pbase; + uint32_t k; + if (irp) { + if (!ra_hasspill(irp->s)) { + pbase = irp->r; + lua_assert(ra_hasreg(pbase)); + } else if (allow) { + pbase = rset_pickbot(allow); + } else { + pbase = RID_RET; + emit_lso(as, ARMI_LDR, RID_RET, RID_SP, 0); /* Restore temp. register. */ + } + } else { + pbase = RID_BASE; + } + emit_branch(as, ARMF_CC(ARMI_BL, CC_LS), exitstub_addr(as->J, exitno)); + k = emit_isk12(0, (int32_t)(8*topslot)); + lua_assert(k); + emit_n(as, ARMI_CMP^k, RID_TMP); + emit_dnm(as, ARMI_SUB, RID_TMP, RID_TMP, pbase); + emit_lso(as, ARMI_LDR, RID_TMP, RID_TMP, + (int32_t)offsetof(lua_State, maxstack)); + if (irp) { /* Must not spill arbitrary registers in head of side trace. */ + int32_t i = i32ptr(&J2G(as->J)->jit_L); + if (ra_hasspill(irp->s)) + emit_lso(as, ARMI_LDR, pbase, RID_SP, sps_scale(irp->s)); + emit_lso(as, ARMI_LDR, RID_TMP, RID_TMP, (i & 4095)); + if (ra_hasspill(irp->s) && !allow) + emit_lso(as, ARMI_STR, RID_RET, RID_SP, 0); /* Save temp. register. */ + emit_loadi(as, RID_TMP, (i & ~4095)); + } else { + emit_getgl(as, RID_TMP, jit_L); + } +} + +/* Restore Lua stack from on-trace state. */ +static void asm_stack_restore(ASMState *as, SnapShot *snap) +{ + SnapEntry *map = &as->T->snapmap[snap->mapofs]; + SnapEntry *flinks = &as->T->snapmap[snap_nextofs(as->T, snap)-1]; + MSize n, nent = snap->nent; + /* Store the value of all modified slots to the Lua stack. */ + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + BCReg s = snap_slot(sn); + int32_t ofs = 8*((int32_t)s-1); + IRRef ref = snap_ref(sn); + IRIns *ir = IR(ref); + if ((sn & SNAP_NORESTORE)) + continue; + if (irt_isnum(ir->t)) { +#if LJ_SOFTFP + RegSet odd = rset_exclude(RSET_GPRODD, RID_BASE); + Reg tmp; + lua_assert(irref_isk(ref)); /* LJ_SOFTFP: must be a number constant. */ + tmp = ra_allock(as, (int32_t)ir_knum(ir)->u32.lo, + rset_exclude(RSET_GPREVEN, RID_BASE)); + emit_lso(as, ARMI_STR, tmp, RID_BASE, ofs); + if (rset_test(as->freeset, tmp+1)) odd = RID2RSET(tmp+1); + tmp = ra_allock(as, (int32_t)ir_knum(ir)->u32.hi, odd); + emit_lso(as, ARMI_STR, tmp, RID_BASE, ofs+4); +#else + Reg src = ra_alloc1(as, ref, RSET_FPR); + emit_vlso(as, ARMI_VSTR_D, src, RID_BASE, ofs); +#endif + } else { + RegSet odd = rset_exclude(RSET_GPRODD, RID_BASE); + Reg type; + lua_assert(irt_ispri(ir->t) || irt_isaddr(ir->t) || irt_isinteger(ir->t)); + if (!irt_ispri(ir->t)) { + Reg src = ra_alloc1(as, ref, rset_exclude(RSET_GPREVEN, RID_BASE)); + emit_lso(as, ARMI_STR, src, RID_BASE, ofs); + if (rset_test(as->freeset, src+1)) odd = RID2RSET(src+1); + } + if ((sn & (SNAP_CONT|SNAP_FRAME))) { + if (s == 0) continue; /* Do not overwrite link to previous frame. */ + type = ra_allock(as, (int32_t)(*flinks--), odd); +#if LJ_SOFTFP + } else if ((sn & SNAP_SOFTFPNUM)) { + type = ra_alloc1(as, ref+1, rset_exclude(RSET_GPRODD, RID_BASE)); +#endif + } else { + type = ra_allock(as, (int32_t)irt_toitype(ir->t), odd); + } + emit_lso(as, ARMI_STR, type, RID_BASE, ofs+4); + } + checkmclim(as); + } + lua_assert(map + nent == flinks); +} + +/* -- GC handling --------------------------------------------------------- */ + +/* Check GC threshold and do one or more GC steps. */ +static void asm_gc_check(ASMState *as) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_step_jit]; + IRRef args[2]; + MCLabel l_end; + Reg tmp1, tmp2; + ra_evictset(as, RSET_SCRATCH); + l_end = emit_label(as); + /* Exit trace if in GCSatomic or GCSfinalize. Avoids syncing GC objects. */ + asm_guardcc(as, CC_NE); /* Assumes asm_snap_prep() already done. */ + emit_n(as, ARMI_CMP|ARMI_K12|0, RID_RET); + args[0] = ASMREF_TMP1; /* global_State *g */ + args[1] = ASMREF_TMP2; /* MSize steps */ + asm_gencall(as, ci, args); + tmp1 = ra_releasetmp(as, ASMREF_TMP1); + tmp2 = ra_releasetmp(as, ASMREF_TMP2); + emit_loadi(as, tmp2, as->gcsteps); + /* Jump around GC step if GC total < GC threshold. */ + emit_branch(as, ARMF_CC(ARMI_B, CC_LS), l_end); + emit_nm(as, ARMI_CMP, RID_TMP, tmp2); + emit_lso(as, ARMI_LDR, tmp2, tmp1, + (int32_t)offsetof(global_State, gc.threshold)); + emit_lso(as, ARMI_LDR, RID_TMP, tmp1, + (int32_t)offsetof(global_State, gc.total)); + ra_allockreg(as, i32ptr(J2G(as->J)), tmp1); + as->gcsteps = 0; + checkmclim(as); +} + +/* -- Loop handling ------------------------------------------------------- */ + +/* Fixup the loop branch. */ +static void asm_loop_fixup(ASMState *as) +{ + MCode *p = as->mctop; + MCode *target = as->mcp; + if (as->loopinv) { /* Inverted loop branch? */ + /* asm_guardcc already inverted the bcc and patched the final bl. */ + p[-2] |= ((uint32_t)(target-p) & 0x00ffffffu); + } else { + p[-1] = ARMI_B | ((uint32_t)((target-p)-1) & 0x00ffffffu); + } +} + +/* -- Head of trace ------------------------------------------------------- */ + +/* Reload L register from g->jit_L. */ +static void asm_head_lreg(ASMState *as) +{ + IRIns *ir = IR(ASMREF_L); + if (ra_used(ir)) { + Reg r = ra_dest(as, ir, RSET_GPR); + emit_getgl(as, r, jit_L); + ra_evictk(as); + } +} + +/* Coalesce BASE register for a root trace. */ +static void asm_head_root_base(ASMState *as) +{ + IRIns *ir; + asm_head_lreg(as); + ir = IR(REF_BASE); + if (ra_hasreg(ir->r) && (rset_test(as->modset, ir->r) || irt_ismarked(ir->t))) + ra_spill(as, ir); + ra_destreg(as, ir, RID_BASE); +} + +/* Coalesce BASE register for a side trace. */ +static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) +{ + IRIns *ir; + asm_head_lreg(as); + ir = IR(REF_BASE); + if (ra_hasreg(ir->r) && (rset_test(as->modset, ir->r) || irt_ismarked(ir->t))) + ra_spill(as, ir); + if (ra_hasspill(irp->s)) { + rset_clear(allow, ra_dest(as, ir, allow)); + } else { + Reg r = irp->r; + lua_assert(ra_hasreg(r)); + rset_clear(allow, r); + if (r != ir->r && !rset_test(as->freeset, r)) + ra_restore(as, regcost_ref(as->cost[r])); + ra_destreg(as, ir, r); + } + return allow; +} + +/* -- Tail of trace ------------------------------------------------------- */ + +/* Fixup the tail code. */ +static void asm_tail_fixup(ASMState *as, TraceNo lnk) +{ + MCode *p = as->mctop; + MCode *target; + int32_t spadj = as->T->spadjust; + if (spadj == 0) { + as->mctop = --p; + } else { + /* Patch stack adjustment. */ + uint32_t k = emit_isk12(ARMI_ADD, spadj); + lua_assert(k); + p[-2] = (ARMI_ADD^k) | ARMF_D(RID_SP) | ARMF_N(RID_SP); + } + /* Patch exit branch. */ + target = lnk ? traceref(as->J, lnk)->mcode : (MCode *)lj_vm_exit_interp; + p[-1] = ARMI_B|(((target-p)-1)&0x00ffffffu); +} + +/* Prepare tail of code. */ +static void asm_tail_prep(ASMState *as) +{ + MCode *p = as->mctop - 1; /* Leave room for exit branch. */ + if (as->loopref) { + as->invmcp = as->mcp = p; + } else { + as->mcp = p-1; /* Leave room for stack pointer adjustment. */ + as->invmcp = NULL; + } + *p = 0; /* Prevent load/store merging. */ +} + +/* -- Instruction dispatch ------------------------------------------------ */ + +/* Assemble a single instruction. */ +static void asm_ir(ASMState *as, IRIns *ir) +{ + switch ((IROp)ir->o) { + /* Miscellaneous ops. */ + case IR_LOOP: asm_loop(as); break; + case IR_NOP: case IR_XBAR: lua_assert(!ra_used(ir)); break; + case IR_USE: + ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break; + case IR_PHI: asm_phi(as, ir); break; + case IR_HIOP: asm_hiop(as, ir); break; + case IR_GCSTEP: asm_gcstep(as, ir); break; + + /* Guarded assertions. */ + case IR_EQ: case IR_NE: + if ((ir-1)->o == IR_HREF && ir->op1 == as->curins-1) { + as->curins--; + asm_href(as, ir-1, (IROp)ir->o); + break; + } + /* fallthrough */ + case IR_LT: case IR_GE: case IR_LE: case IR_GT: + case IR_ULT: case IR_UGE: case IR_ULE: case IR_UGT: + case IR_ABC: +#if !LJ_SOFTFP + if (irt_isnum(ir->t)) { asm_fpcomp(as, ir); break; } +#endif + asm_intcomp(as, ir); + break; + + case IR_RETF: asm_retf(as, ir); break; + + /* Bit ops. */ + case IR_BNOT: asm_bitop(as, ir, ARMI_MVN); break; + case IR_BSWAP: asm_bitswap(as, ir); break; + + case IR_BAND: asm_bitop(as, ir, ARMI_AND); break; + case IR_BOR: asm_bitop(as, ir, ARMI_ORR); break; + case IR_BXOR: asm_bitop(as, ir, ARMI_EOR); break; + + case IR_BSHL: asm_bitshift(as, ir, ARMSH_LSL); break; + case IR_BSHR: asm_bitshift(as, ir, ARMSH_LSR); break; + case IR_BSAR: asm_bitshift(as, ir, ARMSH_ASR); break; + case IR_BROR: asm_bitshift(as, ir, ARMSH_ROR); break; + case IR_BROL: lua_assert(0); break; + + /* Arithmetic ops. */ + case IR_ADD: case IR_ADDOV: asm_add(as, ir); break; + case IR_SUB: case IR_SUBOV: asm_sub(as, ir); break; + case IR_MUL: case IR_MULOV: asm_mul(as, ir); break; + case IR_MOD: asm_callid(as, ir, IRCALL_lj_vm_modi); break; + case IR_NEG: asm_neg(as, ir); break; + +#if LJ_SOFTFP + case IR_DIV: case IR_POW: case IR_ABS: + case IR_ATAN2: case IR_LDEXP: case IR_FPMATH: case IR_TOBIT: + lua_assert(0); /* Unused for LJ_SOFTFP. */ + break; +#else + case IR_DIV: asm_fparith(as, ir, ARMI_VDIV_D); break; + case IR_POW: asm_callid(as, ir, IRCALL_lj_vm_powi); break; + case IR_ABS: asm_fpunary(as, ir, ARMI_VABS_D); break; + case IR_ATAN2: asm_callid(as, ir, IRCALL_atan2); break; + case IR_LDEXP: asm_callid(as, ir, IRCALL_ldexp); break; + case IR_FPMATH: + if (ir->op2 == IRFPM_EXP2 && asm_fpjoin_pow(as, ir)) + break; + if (ir->op2 <= IRFPM_TRUNC) + asm_callround(as, ir, ir->op2); + else if (ir->op2 == IRFPM_SQRT) + asm_fpunary(as, ir, ARMI_VSQRT_D); + else + asm_callid(as, ir, IRCALL_lj_vm_floor + ir->op2); + break; + case IR_TOBIT: asm_tobit(as, ir); break; +#endif + + case IR_MIN: asm_min_max(as, ir, CC_GT, CC_HI); break; + case IR_MAX: asm_min_max(as, ir, CC_LT, CC_LO); break; + + /* Memory references. */ + case IR_AREF: asm_aref(as, ir); break; + case IR_HREF: asm_href(as, ir, 0); break; + case IR_HREFK: asm_hrefk(as, ir); break; + case IR_NEWREF: asm_newref(as, ir); break; + case IR_UREFO: case IR_UREFC: asm_uref(as, ir); break; + case IR_FREF: asm_fref(as, ir); break; + case IR_STRREF: asm_strref(as, ir); break; + + /* Loads and stores. */ + case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: + asm_ahuvload(as, ir); + break; + case IR_FLOAD: asm_fload(as, ir); break; + case IR_XLOAD: asm_xload(as, ir); break; + case IR_SLOAD: asm_sload(as, ir); break; + + case IR_ASTORE: case IR_HSTORE: case IR_USTORE: asm_ahustore(as, ir); break; + case IR_FSTORE: asm_fstore(as, ir); break; + case IR_XSTORE: asm_xstore(as, ir, 0); break; + + /* Allocations. */ + case IR_SNEW: case IR_XSNEW: asm_snew(as, ir); break; + case IR_TNEW: asm_tnew(as, ir); break; + case IR_TDUP: asm_tdup(as, ir); break; + case IR_CNEW: case IR_CNEWI: asm_cnew(as, ir); break; + + /* Write barriers. */ + case IR_TBAR: asm_tbar(as, ir); break; + case IR_OBAR: asm_obar(as, ir); break; + + /* Type conversions. */ + case IR_CONV: asm_conv(as, ir); break; + case IR_TOSTR: asm_tostr(as, ir); break; + case IR_STRTO: asm_strto(as, ir); break; + + /* Calls. */ + case IR_CALLN: case IR_CALLL: case IR_CALLS: asm_call(as, ir); break; + case IR_CALLXS: asm_callx(as, ir); break; + case IR_CARG: break; + + default: + setintV(&as->J->errinfo, ir->o); + lj_trace_err_info(as->J, LJ_TRERR_NYIIR); + break; + } +} + +/* -- Trace setup --------------------------------------------------------- */ + +/* Ensure there are enough stack slots for call arguments. */ +static Reg asm_setup_call_slots(ASMState *as, IRIns *ir, const CCallInfo *ci) +{ + IRRef args[CCI_NARGS_MAX*2]; + uint32_t i, nargs = (int)CCI_NARGS(ci); + int nslots = 0, ngpr = REGARG_NUMGPR, nfpr = REGARG_NUMFPR, fprodd = 0; + asm_collectargs(as, ir, ci, args); + for (i = 0; i < nargs; i++) { + if (!LJ_SOFTFP && args[i] && irt_isfp(IR(args[i])->t)) { + if (!LJ_ABI_SOFTFP && !(ci->flags & CCI_VARARG)) { + if (irt_isnum(IR(args[i])->t)) { + if (nfpr > 0) nfpr--; + else fprodd = 0, nslots = (nslots + 3) & ~1; + } else { + if (fprodd) fprodd--; + else if (nfpr > 0) fprodd = 1, nfpr--; + else nslots++; + } + } else if (irt_isnum(IR(args[i])->t)) { + ngpr &= ~1; + if (ngpr > 0) ngpr -= 2; else nslots += 2; + } else { + if (ngpr > 0) ngpr--; else nslots++; + } + } else { + if (ngpr > 0) ngpr--; else nslots++; + } + } + if (nslots > as->evenspill) /* Leave room for args in stack slots. */ + as->evenspill = nslots; + return REGSP_HINT(RID_RET); +} + +static void asm_setup_target(ASMState *as) +{ + /* May need extra exit for asm_stack_check on side traces. */ + asm_exitstub_setup(as, as->T->nsnap + (as->parent ? 1 : 0)); +} + +/* -- Trace patching ------------------------------------------------------ */ + +/* Patch exit jumps of existing machine code to a new target. */ +void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target) +{ + MCode *p = T->mcode; + MCode *pe = (MCode *)((char *)p + T->szmcode); + MCode *cstart = NULL, *cend = p; + MCode *mcarea = lj_mcode_patch(J, p, 0); + MCode *px = exitstub_addr(J, exitno) - 2; + for (; p < pe; p++) { + /* Look for bl_cc exitstub, replace with b_cc target. */ + uint32_t ins = *p; + if ((ins & 0x0f000000u) == 0x0b000000u && ins < 0xf0000000u && + ((ins ^ (px-p)) & 0x00ffffffu) == 0) { + *p = (ins & 0xfe000000u) | (((target-p)-2) & 0x00ffffffu); + cend = p+1; + if (!cstart) cstart = p; + } + } + lua_assert(cstart != NULL); + lj_mcode_sync(cstart, cend); + lj_mcode_patch(J, mcarea, 1); +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_mips.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_mips.h new file mode 100644 index 000000000..78bd26d5d --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_mips.h @@ -0,0 +1,1977 @@ +/* +** MIPS IR assembler (SSA IR -> machine code). +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* -- Register allocator extensions --------------------------------------- */ + +/* Allocate a register with a hint. */ +static Reg ra_hintalloc(ASMState *as, IRRef ref, Reg hint, RegSet allow) +{ + Reg r = IR(ref)->r; + if (ra_noreg(r)) { + if (!ra_hashint(r) && !iscrossref(as, ref)) + ra_sethint(IR(ref)->r, hint); /* Propagate register hint. */ + r = ra_allocref(as, ref, allow); + } + ra_noweak(as, r); + return r; +} + +/* Allocate a register or RID_ZERO. */ +static Reg ra_alloc1z(ASMState *as, IRRef ref, RegSet allow) +{ + Reg r = IR(ref)->r; + if (ra_noreg(r)) { + if (!(allow & RSET_FPR) && irref_isk(ref) && IR(ref)->i == 0) + return RID_ZERO; + r = ra_allocref(as, ref, allow); + } else { + ra_noweak(as, r); + } + return r; +} + +/* Allocate two source registers for three-operand instructions. */ +static Reg ra_alloc2(ASMState *as, IRIns *ir, RegSet allow) +{ + IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); + Reg left = irl->r, right = irr->r; + if (ra_hasreg(left)) { + ra_noweak(as, left); + if (ra_noreg(right)) + right = ra_alloc1z(as, ir->op2, rset_exclude(allow, left)); + else + ra_noweak(as, right); + } else if (ra_hasreg(right)) { + ra_noweak(as, right); + left = ra_alloc1z(as, ir->op1, rset_exclude(allow, right)); + } else if (ra_hashint(right)) { + right = ra_alloc1z(as, ir->op2, allow); + left = ra_alloc1z(as, ir->op1, rset_exclude(allow, right)); + } else { + left = ra_alloc1z(as, ir->op1, allow); + right = ra_alloc1z(as, ir->op2, rset_exclude(allow, left)); + } + return left | (right << 8); +} + +/* -- Guard handling ------------------------------------------------------ */ + +/* Need some spare long-range jump slots, for out-of-range branches. */ +#define MIPS_SPAREJUMP 4 + +/* Setup spare long-range jump slots per mcarea. */ +static void asm_sparejump_setup(ASMState *as) +{ + MCode *mxp = as->mcbot; + /* Assumes sizeof(MCLink) == 8. */ + if (((uintptr_t)mxp & (LJ_PAGESIZE-1)) == 8) { + lua_assert(MIPSI_NOP == 0); + memset(mxp+2, 0, MIPS_SPAREJUMP*8); + mxp += MIPS_SPAREJUMP*2; + lua_assert(mxp < as->mctop); + lj_mcode_sync(as->mcbot, mxp); + lj_mcode_commitbot(as->J, mxp); + as->mcbot = mxp; + as->mclim = as->mcbot + MCLIM_REDZONE; + } +} + +/* Setup exit stub after the end of each trace. */ +static void asm_exitstub_setup(ASMState *as) +{ + MCode *mxp = as->mctop; + /* sw TMP, 0(sp); j ->vm_exit_handler; li TMP, traceno */ + *--mxp = MIPSI_LI|MIPSF_T(RID_TMP)|as->T->traceno; + *--mxp = MIPSI_J|((((uintptr_t)(void *)lj_vm_exit_handler)>>2)&0x03ffffffu); + lua_assert(((uintptr_t)mxp ^ (uintptr_t)(void *)lj_vm_exit_handler)>>28 == 0); + *--mxp = MIPSI_SW|MIPSF_T(RID_TMP)|MIPSF_S(RID_SP)|0; + as->mctop = mxp; +} + +/* Keep this in-sync with exitstub_trace_addr(). */ +#define asm_exitstub_addr(as) ((as)->mctop) + +/* Emit conditional branch to exit for guard. */ +static void asm_guard(ASMState *as, MIPSIns mi, Reg rs, Reg rt) +{ + MCode *target = asm_exitstub_addr(as); + MCode *p = as->mcp; + if (LJ_UNLIKELY(p == as->invmcp)) { + as->invmcp = NULL; + as->loopinv = 1; + as->mcp = p+1; + mi = mi ^ ((mi>>28) == 1 ? 0x04000000u : 0x00010000u); /* Invert cond. */ + target = p; /* Patch target later in asm_loop_fixup. */ + } + emit_ti(as, MIPSI_LI, RID_TMP, as->snapno); + emit_branch(as, mi, rs, rt, target); +} + +/* -- Operand fusion ------------------------------------------------------ */ + +/* Limit linear search to this distance. Avoids O(n^2) behavior. */ +#define CONFLICT_SEARCH_LIM 31 + +/* Check if there's no conflicting instruction between curins and ref. */ +static int noconflict(ASMState *as, IRRef ref, IROp conflict) +{ + IRIns *ir = as->ir; + IRRef i = as->curins; + if (i > ref + CONFLICT_SEARCH_LIM) + return 0; /* Give up, ref is too far away. */ + while (--i > ref) + if (ir[i].o == conflict) + return 0; /* Conflict found. */ + return 1; /* Ok, no conflict. */ +} + +/* Fuse the array base of colocated arrays. */ +static int32_t asm_fuseabase(ASMState *as, IRRef ref) +{ + IRIns *ir = IR(ref); + if (ir->o == IR_TNEW && ir->op1 <= LJ_MAX_COLOSIZE && + !neverfuse(as) && noconflict(as, ref, IR_NEWREF)) + return (int32_t)sizeof(GCtab); + return 0; +} + +/* Fuse array/hash/upvalue reference into register+offset operand. */ +static Reg asm_fuseahuref(ASMState *as, IRRef ref, int32_t *ofsp, RegSet allow) +{ + IRIns *ir = IR(ref); + if (ra_noreg(ir->r)) { + if (ir->o == IR_AREF) { + if (mayfuse(as, ref)) { + if (irref_isk(ir->op2)) { + IRRef tab = IR(ir->op1)->op1; + int32_t ofs = asm_fuseabase(as, tab); + IRRef refa = ofs ? tab : ir->op1; + ofs += 8*IR(ir->op2)->i; + if (checki16(ofs)) { + *ofsp = ofs; + return ra_alloc1(as, refa, allow); + } + } + } + } else if (ir->o == IR_HREFK) { + if (mayfuse(as, ref)) { + int32_t ofs = (int32_t)(IR(ir->op2)->op2 * sizeof(Node)); + if (checki16(ofs)) { + *ofsp = ofs; + return ra_alloc1(as, ir->op1, allow); + } + } + } else if (ir->o == IR_UREFC) { + if (irref_isk(ir->op1)) { + GCfunc *fn = ir_kfunc(IR(ir->op1)); + int32_t ofs = i32ptr(&gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.tv); + int32_t jgl = (intptr_t)J2G(as->J); + if ((uint32_t)(ofs-jgl) < 65536) { + *ofsp = ofs-jgl-32768; + return RID_JGL; + } else { + *ofsp = (int16_t)ofs; + return ra_allock(as, ofs-(int16_t)ofs, allow); + } + } + } + } + *ofsp = 0; + return ra_alloc1(as, ref, allow); +} + +/* Fuse XLOAD/XSTORE reference into load/store operand. */ +static void asm_fusexref(ASMState *as, MIPSIns mi, Reg rt, IRRef ref, + RegSet allow, int32_t ofs) +{ + IRIns *ir = IR(ref); + Reg base; + if (ra_noreg(ir->r) && canfuse(as, ir)) { + if (ir->o == IR_ADD) { + int32_t ofs2; + if (irref_isk(ir->op2) && (ofs2 = ofs + IR(ir->op2)->i, checki16(ofs2))) { + ref = ir->op1; + ofs = ofs2; + } + } else if (ir->o == IR_STRREF) { + int32_t ofs2 = 65536; + lua_assert(ofs == 0); + ofs = (int32_t)sizeof(GCstr); + if (irref_isk(ir->op2)) { + ofs2 = ofs + IR(ir->op2)->i; + ref = ir->op1; + } else if (irref_isk(ir->op1)) { + ofs2 = ofs + IR(ir->op1)->i; + ref = ir->op2; + } + if (!checki16(ofs2)) { + /* NYI: Fuse ADD with constant. */ + Reg right, left = ra_alloc2(as, ir, allow); + right = (left >> 8); left &= 255; + emit_hsi(as, mi, rt, RID_TMP, ofs); + emit_dst(as, MIPSI_ADDU, RID_TMP, left, right); + return; + } + ofs = ofs2; + } + } + base = ra_alloc1(as, ref, allow); + emit_hsi(as, mi, rt, base, ofs); +} + +/* -- Calls --------------------------------------------------------------- */ + +/* Generate a call to a C function. */ +static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args) +{ + uint32_t n, nargs = CCI_NARGS(ci); + int32_t ofs = 16; + Reg gpr, fpr = REGARG_FIRSTFPR; + if ((void *)ci->func) + emit_call(as, (void *)ci->func); + for (gpr = REGARG_FIRSTGPR; gpr <= REGARG_LASTGPR; gpr++) + as->cost[gpr] = REGCOST(~0u, ASMREF_L); + gpr = REGARG_FIRSTGPR; + for (n = 0; n < nargs; n++) { /* Setup args. */ + IRRef ref = args[n]; + if (ref) { + IRIns *ir = IR(ref); + if (irt_isfp(ir->t) && fpr <= REGARG_LASTFPR && + !(ci->flags & CCI_VARARG)) { + lua_assert(rset_test(as->freeset, fpr)); /* Already evicted. */ + ra_leftov(as, fpr, ref); + fpr += 2; + gpr += irt_isnum(ir->t) ? 2 : 1; + } else { + fpr = REGARG_LASTFPR+1; + if (irt_isnum(ir->t)) gpr = (gpr+1) & ~1; + if (gpr <= REGARG_LASTGPR) { + lua_assert(rset_test(as->freeset, gpr)); /* Already evicted. */ + if (irt_isfp(ir->t)) { + RegSet of = as->freeset; + Reg r; + /* Workaround to protect argument GPRs from being used for remat. */ + as->freeset &= ~RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1); + r = ra_alloc1(as, ref, RSET_FPR); + as->freeset |= (of & RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1)); + if (irt_isnum(ir->t)) { + emit_tg(as, MIPSI_MFC1, gpr+(LJ_BE?0:1), r+1); + emit_tg(as, MIPSI_MFC1, gpr+(LJ_BE?1:0), r); + lua_assert(rset_test(as->freeset, gpr+1)); /* Already evicted. */ + gpr += 2; + } else if (irt_isfloat(ir->t)) { + emit_tg(as, MIPSI_MFC1, gpr, r); + gpr++; + } + } else { + ra_leftov(as, gpr, ref); + gpr++; + } + } else { + Reg r = ra_alloc1z(as, ref, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); + if (irt_isnum(ir->t)) ofs = (ofs + 4) & ~4; + emit_spstore(as, ir, r, ofs); + ofs += irt_isnum(ir->t) ? 8 : 4; + } + } + } else { + fpr = REGARG_LASTFPR+1; + if (gpr <= REGARG_LASTGPR) + gpr++; + else + ofs += 4; + } + checkmclim(as); + } +} + +/* Setup result reg/sp for call. Evict scratch regs. */ +static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci) +{ + RegSet drop = RSET_SCRATCH; + int hiop = ((ir+1)->o == IR_HIOP); + if ((ci->flags & CCI_NOFPRCLOBBER)) + drop &= ~RSET_FPR; + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + if (hiop && ra_hasreg((ir+1)->r)) + rset_clear(drop, (ir+1)->r); /* Dest reg handled below. */ + ra_evictset(as, drop); /* Evictions must be performed first. */ + if (ra_used(ir)) { + lua_assert(!irt_ispri(ir->t)); + if (irt_isfp(ir->t)) { + if ((ci->flags & CCI_CASTU64)) { + int32_t ofs = sps_scale(ir->s); + Reg dest = ir->r; + if (ra_hasreg(dest)) { + ra_free(as, dest); + ra_modified(as, dest); + emit_tg(as, MIPSI_MTC1, RID_RETHI, dest+1); + emit_tg(as, MIPSI_MTC1, RID_RETLO, dest); + } + if (ofs) { + emit_tsi(as, MIPSI_SW, RID_RETLO, RID_SP, ofs+(LJ_BE?4:0)); + emit_tsi(as, MIPSI_SW, RID_RETHI, RID_SP, ofs+(LJ_BE?0:4)); + } + } else { + ra_destreg(as, ir, RID_FPRET); + } + } else if (hiop) { + ra_destpair(as, ir); + } else { + ra_destreg(as, ir, RID_RET); + } + } +} + +static void asm_call(ASMState *as, IRIns *ir) +{ + IRRef args[CCI_NARGS_MAX]; + const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; + asm_collectargs(as, ir, ci, args); + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} + +static void asm_callx(ASMState *as, IRIns *ir) +{ + IRRef args[CCI_NARGS_MAX*2]; + CCallInfo ci; + IRRef func; + IRIns *irf; + ci.flags = asm_callx_flags(as, ir); + asm_collectargs(as, ir, &ci, args); + asm_setupresult(as, ir, &ci); + func = ir->op2; irf = IR(func); + if (irf->o == IR_CARG) { func = irf->op1; irf = IR(func); } + if (irref_isk(func)) { /* Call to constant address. */ + ci.func = (ASMFunction)(void *)(irf->i); + } else { /* Need specific register for indirect calls. */ + Reg r = ra_alloc1(as, func, RID2RSET(RID_CFUNCADDR)); + MCode *p = as->mcp; + if (r == RID_CFUNCADDR) + *--p = MIPSI_NOP; + else + *--p = MIPSI_MOVE | MIPSF_D(RID_CFUNCADDR) | MIPSF_S(r); + *--p = MIPSI_JALR | MIPSF_S(r); + as->mcp = p; + ci.func = (ASMFunction)(void *)0; + } + asm_gencall(as, &ci, args); +} + +static void asm_callid(ASMState *as, IRIns *ir, IRCallID id) +{ + const CCallInfo *ci = &lj_ir_callinfo[id]; + IRRef args[2]; + args[0] = ir->op1; + args[1] = ir->op2; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} + +static void asm_callround(ASMState *as, IRIns *ir, IRCallID id) +{ + /* The modified regs must match with the *.dasc implementation. */ + RegSet drop = RID2RSET(RID_R1)|RID2RSET(RID_R12)|RID2RSET(RID_FPRET)| + RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(REGARG_FIRSTFPR); + if (ra_hasreg(ir->r)) rset_clear(drop, ir->r); + ra_evictset(as, drop); + ra_destreg(as, ir, RID_FPRET); + emit_call(as, (void *)lj_ir_callinfo[id].func); + ra_leftov(as, REGARG_FIRSTFPR, ir->op1); +} + +/* -- Returns ------------------------------------------------------------- */ + +/* Return to lower frame. Guard that it goes to the right spot. */ +static void asm_retf(ASMState *as, IRIns *ir) +{ + Reg base = ra_alloc1(as, REF_BASE, RSET_GPR); + void *pc = ir_kptr(IR(ir->op2)); + int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); + as->topslot -= (BCReg)delta; + if ((int32_t)as->topslot < 0) as->topslot = 0; + irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */ + emit_setgl(as, base, jit_base); + emit_addptr(as, base, -8*delta); + asm_guard(as, MIPSI_BNE, RID_TMP, + ra_allock(as, i32ptr(pc), rset_exclude(RSET_GPR, base))); + emit_tsi(as, MIPSI_LW, RID_TMP, base, -8); +} + +/* -- Type conversions ---------------------------------------------------- */ + +static void asm_tointg(ASMState *as, IRIns *ir, Reg left) +{ + Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); + Reg dest = ra_dest(as, ir, RSET_GPR); + asm_guard(as, MIPSI_BC1F, 0, 0); + emit_fgh(as, MIPSI_C_EQ_D, 0, tmp, left); + emit_fg(as, MIPSI_CVT_D_W, tmp, tmp); + emit_tg(as, MIPSI_MFC1, dest, tmp); + emit_fg(as, MIPSI_CVT_W_D, tmp, left); +} + +static void asm_tobit(ASMState *as, IRIns *ir) +{ + RegSet allow = RSET_FPR; + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, ir->op1, allow); + Reg right = ra_alloc1(as, ir->op2, rset_clear(allow, left)); + Reg tmp = ra_scratch(as, rset_clear(allow, right)); + emit_tg(as, MIPSI_MFC1, dest, tmp); + emit_fgh(as, MIPSI_ADD_D, tmp, left, right); +} + +static void asm_conv(ASMState *as, IRIns *ir) +{ + IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); + int stfp = (st == IRT_NUM || st == IRT_FLOAT); + IRRef lref = ir->op1; + lua_assert(irt_type(ir->t) != st); + lua_assert(!(irt_isint64(ir->t) || + (st == IRT_I64 || st == IRT_U64))); /* Handled by SPLIT. */ + if (irt_isfp(ir->t)) { + Reg dest = ra_dest(as, ir, RSET_FPR); + if (stfp) { /* FP to FP conversion. */ + emit_fg(as, st == IRT_NUM ? MIPSI_CVT_S_D : MIPSI_CVT_D_S, + dest, ra_alloc1(as, lref, RSET_FPR)); + } else if (st == IRT_U32) { /* U32 to FP conversion. */ + /* y = (x ^ 0x8000000) + 2147483648.0 */ + Reg left = ra_alloc1(as, lref, RSET_GPR); + Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, dest)); + emit_fgh(as, irt_isfloat(ir->t) ? MIPSI_ADD_S : MIPSI_ADD_D, + dest, dest, tmp); + emit_fg(as, irt_isfloat(ir->t) ? MIPSI_CVT_S_W : MIPSI_CVT_D_W, + dest, dest); + if (irt_isfloat(ir->t)) + emit_lsptr(as, MIPSI_LWC1, (tmp & 31), + (void *)lj_ir_k64_find(as->J, U64x(4f000000,4f000000)), + RSET_GPR); + else + emit_lsptr(as, MIPSI_LDC1, (tmp & 31), + (void *)lj_ir_k64_find(as->J, U64x(41e00000,00000000)), + RSET_GPR); + emit_tg(as, MIPSI_MTC1, RID_TMP, dest); + emit_dst(as, MIPSI_XOR, RID_TMP, RID_TMP, left); + emit_ti(as, MIPSI_LUI, RID_TMP, 0x8000); + } else { /* Integer to FP conversion. */ + Reg left = ra_alloc1(as, lref, RSET_GPR); + emit_fg(as, irt_isfloat(ir->t) ? MIPSI_CVT_S_W : MIPSI_CVT_D_W, + dest, dest); + emit_tg(as, MIPSI_MTC1, left, dest); + } + } else if (stfp) { /* FP to integer conversion. */ + if (irt_isguard(ir->t)) { + /* Checked conversions are only supported from number to int. */ + lua_assert(irt_isint(ir->t) && st == IRT_NUM); + asm_tointg(as, ir, ra_alloc1(as, lref, RSET_FPR)); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, lref, RSET_FPR); + Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); + if (irt_isu32(ir->t)) { + /* y = (int)floor(x - 2147483648.0) ^ 0x80000000 */ + emit_dst(as, MIPSI_XOR, dest, dest, RID_TMP); + emit_ti(as, MIPSI_LUI, RID_TMP, 0x8000); + emit_tg(as, MIPSI_MFC1, dest, tmp); + emit_fg(as, st == IRT_FLOAT ? MIPSI_FLOOR_W_S : MIPSI_FLOOR_W_D, + tmp, tmp); + emit_fgh(as, st == IRT_FLOAT ? MIPSI_SUB_S : MIPSI_SUB_D, + tmp, left, tmp); + if (st == IRT_FLOAT) + emit_lsptr(as, MIPSI_LWC1, (tmp & 31), + (void *)lj_ir_k64_find(as->J, U64x(4f000000,4f000000)), + RSET_GPR); + else + emit_lsptr(as, MIPSI_LDC1, (tmp & 31), + (void *)lj_ir_k64_find(as->J, U64x(41e00000,00000000)), + RSET_GPR); + } else { + emit_tg(as, MIPSI_MFC1, dest, tmp); + emit_fg(as, st == IRT_FLOAT ? MIPSI_TRUNC_W_S : MIPSI_TRUNC_W_D, + tmp, left); + } + } + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + if (st >= IRT_I8 && st <= IRT_U16) { /* Extend to 32 bit integer. */ + Reg left = ra_alloc1(as, ir->op1, RSET_GPR); + lua_assert(irt_isint(ir->t) || irt_isu32(ir->t)); + if ((ir->op2 & IRCONV_SEXT)) { + if ((as->flags & JIT_F_MIPS32R2)) { + emit_dst(as, st == IRT_I8 ? MIPSI_SEB : MIPSI_SEH, dest, 0, left); + } else { + uint32_t shift = st == IRT_I8 ? 24 : 16; + emit_dta(as, MIPSI_SRA, dest, dest, shift); + emit_dta(as, MIPSI_SLL, dest, left, shift); + } + } else { + emit_tsi(as, MIPSI_ANDI, dest, left, + (int32_t)(st == IRT_U8 ? 0xff : 0xffff)); + } + } else { /* 32/64 bit integer conversions. */ + /* Only need to handle 32/32 bit no-op (cast) on 32 bit archs. */ + ra_leftov(as, dest, lref); /* Do nothing, but may need to move regs. */ + } + } +} + +#if LJ_HASFFI +static void asm_conv64(ASMState *as, IRIns *ir) +{ + IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK); + IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH); + IRCallID id; + const CCallInfo *ci; + IRRef args[2]; + args[LJ_BE?0:1] = ir->op1; + args[LJ_BE?1:0] = (ir-1)->op1; + if (st == IRT_NUM || st == IRT_FLOAT) { + id = IRCALL_fp64_d2l + ((st == IRT_FLOAT) ? 2 : 0) + (dt - IRT_I64); + ir--; + } else { + id = IRCALL_fp64_l2d + ((dt == IRT_FLOAT) ? 2 : 0) + (st - IRT_I64); + } + ci = &lj_ir_callinfo[id]; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} +#endif + +static void asm_strto(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_strscan_num]; + IRRef args[2]; + RegSet drop = RSET_SCRATCH; + if (ra_hasreg(ir->r)) rset_set(drop, ir->r); /* Spill dest reg (if any). */ + ra_evictset(as, drop); + asm_guard(as, MIPSI_BEQ, RID_RET, RID_ZERO); /* Test return status. */ + args[0] = ir->op1; /* GCstr *str */ + args[1] = ASMREF_TMP1; /* TValue *n */ + asm_gencall(as, ci, args); + /* Store the result to the spill slot or temp slots. */ + emit_tsi(as, MIPSI_ADDIU, ra_releasetmp(as, ASMREF_TMP1), + RID_SP, sps_scale(ir->s)); +} + +/* Get pointer to TValue. */ +static void asm_tvptr(ASMState *as, Reg dest, IRRef ref) +{ + IRIns *ir = IR(ref); + if (irt_isnum(ir->t)) { + if (irref_isk(ref)) /* Use the number constant itself as a TValue. */ + ra_allockreg(as, i32ptr(ir_knum(ir)), dest); + else /* Otherwise force a spill and use the spill slot. */ + emit_tsi(as, MIPSI_ADDIU, dest, RID_SP, ra_spill(as, ir)); + } else { + /* Otherwise use g->tmptv to hold the TValue. */ + RegSet allow = rset_exclude(RSET_GPR, dest); + Reg type; + emit_tsi(as, MIPSI_ADDIU, dest, RID_JGL, offsetof(global_State, tmptv)-32768); + if (!irt_ispri(ir->t)) { + Reg src = ra_alloc1(as, ref, allow); + emit_setgl(as, src, tmptv.gcr); + } + type = ra_allock(as, irt_toitype(ir->t), allow); + emit_setgl(as, type, tmptv.it); + } +} + +static void asm_tostr(ASMState *as, IRIns *ir) +{ + IRRef args[2]; + args[0] = ASMREF_L; + as->gcsteps++; + if (irt_isnum(IR(ir->op1)->t) || (ir+1)->o == IR_HIOP) { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromnum]; + args[1] = ASMREF_TMP1; /* const lua_Number * */ + asm_setupresult(as, ir, ci); /* GCstr * */ + asm_gencall(as, ci, args); + asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op1); + } else { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromint]; + args[1] = ir->op1; /* int32_t k */ + asm_setupresult(as, ir, ci); /* GCstr * */ + asm_gencall(as, ci, args); + } +} + +/* -- Memory references --------------------------------------------------- */ + +static void asm_aref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg idx, base; + if (irref_isk(ir->op2)) { + IRRef tab = IR(ir->op1)->op1; + int32_t ofs = asm_fuseabase(as, tab); + IRRef refa = ofs ? tab : ir->op1; + ofs += 8*IR(ir->op2)->i; + if (checki16(ofs)) { + base = ra_alloc1(as, refa, RSET_GPR); + emit_tsi(as, MIPSI_ADDIU, dest, base, ofs); + return; + } + } + base = ra_alloc1(as, ir->op1, RSET_GPR); + idx = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, base)); + emit_dst(as, MIPSI_ADDU, dest, RID_TMP, base); + emit_dta(as, MIPSI_SLL, RID_TMP, idx, 3); +} + +/* Inlined hash lookup. Specialized for key type and for const keys. +** The equivalent C code is: +** Node *n = hashkey(t, key); +** do { +** if (lj_obj_equal(&n->key, key)) return &n->val; +** } while ((n = nextnode(n))); +** return niltv(L); +*/ +static void asm_href(ASMState *as, IRIns *ir) +{ + RegSet allow = RSET_GPR; + int destused = ra_used(ir); + Reg dest = ra_dest(as, ir, allow); + Reg tab = ra_alloc1(as, ir->op1, rset_clear(allow, dest)); + Reg key = RID_NONE, type = RID_NONE, tmpnum = RID_NONE, tmp1 = RID_TMP, tmp2; + IRRef refkey = ir->op2; + IRIns *irkey = IR(refkey); + IRType1 kt = irkey->t; + uint32_t khash; + MCLabel l_end, l_loop, l_next; + + rset_clear(allow, tab); + if (irt_isnum(kt)) { + key = ra_alloc1(as, refkey, RSET_FPR); + tmpnum = ra_scratch(as, rset_exclude(RSET_FPR, key)); + } else if (!irt_ispri(kt)) { + key = ra_alloc1(as, refkey, allow); + rset_clear(allow, key); + type = ra_allock(as, irt_toitype(irkey->t), allow); + rset_clear(allow, type); + } + tmp2 = ra_scratch(as, allow); + rset_clear(allow, tmp2); + + /* Key not found in chain: load niltv. */ + l_end = emit_label(as); + if (destused) + emit_loada(as, dest, niltvg(J2G(as->J))); + else + *--as->mcp = MIPSI_NOP; + /* Follow hash chain until the end. */ + emit_move(as, dest, tmp1); + l_loop = --as->mcp; + emit_tsi(as, MIPSI_LW, tmp1, dest, (int32_t)offsetof(Node, next)); + l_next = emit_label(as); + + /* Type and value comparison. */ + if (irt_isnum(kt)) { + emit_branch(as, MIPSI_BC1T, 0, 0, l_end); + emit_fgh(as, MIPSI_C_EQ_D, 0, tmpnum, key); + emit_tg(as, MIPSI_MFC1, tmp1, key+1); + emit_branch(as, MIPSI_BEQ, tmp1, RID_ZERO, l_next); + emit_tsi(as, MIPSI_SLTIU, tmp1, tmp1, (int32_t)LJ_TISNUM); + emit_hsi(as, MIPSI_LDC1, tmpnum, dest, (int32_t)offsetof(Node, key.n)); + } else { + if (irt_ispri(kt)) { + emit_branch(as, MIPSI_BEQ, tmp1, type, l_end); + } else { + emit_branch(as, MIPSI_BEQ, tmp2, key, l_end); + emit_tsi(as, MIPSI_LW, tmp2, dest, (int32_t)offsetof(Node, key.gcr)); + emit_branch(as, MIPSI_BNE, tmp1, type, l_next); + } + } + emit_tsi(as, MIPSI_LW, tmp1, dest, (int32_t)offsetof(Node, key.it)); + *l_loop = MIPSI_BNE | MIPSF_S(tmp1) | ((as->mcp-l_loop-1) & 0xffffu); + + /* Load main position relative to tab->node into dest. */ + khash = irref_isk(refkey) ? ir_khash(irkey) : 1; + if (khash == 0) { + emit_tsi(as, MIPSI_LW, dest, tab, (int32_t)offsetof(GCtab, node)); + } else { + Reg tmphash = tmp1; + if (irref_isk(refkey)) + tmphash = ra_allock(as, khash, allow); + emit_dst(as, MIPSI_ADDU, dest, dest, tmp1); + lua_assert(sizeof(Node) == 24); + emit_dst(as, MIPSI_SUBU, tmp1, tmp2, tmp1); + emit_dta(as, MIPSI_SLL, tmp1, tmp1, 3); + emit_dta(as, MIPSI_SLL, tmp2, tmp1, 5); + emit_dst(as, MIPSI_AND, tmp1, tmp2, tmphash); + emit_tsi(as, MIPSI_LW, dest, tab, (int32_t)offsetof(GCtab, node)); + emit_tsi(as, MIPSI_LW, tmp2, tab, (int32_t)offsetof(GCtab, hmask)); + if (irref_isk(refkey)) { + /* Nothing to do. */ + } else if (irt_isstr(kt)) { + emit_tsi(as, MIPSI_LW, tmp1, key, (int32_t)offsetof(GCstr, hash)); + } else { /* Must match with hash*() in lj_tab.c. */ + emit_dst(as, MIPSI_SUBU, tmp1, tmp1, tmp2); + emit_rotr(as, tmp2, tmp2, dest, (-HASH_ROT3)&31); + emit_dst(as, MIPSI_XOR, tmp1, tmp1, tmp2); + emit_rotr(as, tmp1, tmp1, dest, (-HASH_ROT2-HASH_ROT1)&31); + emit_dst(as, MIPSI_SUBU, tmp2, tmp2, dest); + if (irt_isnum(kt)) { + emit_dst(as, MIPSI_XOR, tmp2, tmp2, tmp1); + if ((as->flags & JIT_F_MIPS32R2)) { + emit_dta(as, MIPSI_ROTR, dest, tmp1, (-HASH_ROT1)&31); + } else { + emit_dst(as, MIPSI_OR, dest, dest, tmp1); + emit_dta(as, MIPSI_SLL, tmp1, tmp1, HASH_ROT1); + emit_dta(as, MIPSI_SRL, dest, tmp1, (-HASH_ROT1)&31); + } + emit_dst(as, MIPSI_ADDU, tmp1, tmp1, tmp1); + emit_tg(as, MIPSI_MFC1, tmp2, key); + emit_tg(as, MIPSI_MFC1, tmp1, key+1); + } else { + emit_dst(as, MIPSI_XOR, tmp2, key, tmp1); + emit_rotr(as, dest, tmp1, tmp2, (-HASH_ROT1)&31); + emit_dst(as, MIPSI_ADDU, tmp1, key, ra_allock(as, HASH_BIAS, allow)); + } + } + } +} + +static void asm_hrefk(ASMState *as, IRIns *ir) +{ + IRIns *kslot = IR(ir->op2); + IRIns *irkey = IR(kslot->op1); + int32_t ofs = (int32_t)(kslot->op2 * sizeof(Node)); + int32_t kofs = ofs + (int32_t)offsetof(Node, key); + Reg dest = (ra_used(ir)||ofs > 32736) ? ra_dest(as, ir, RSET_GPR) : RID_NONE; + Reg node = ra_alloc1(as, ir->op1, RSET_GPR); + Reg key = RID_NONE, type = RID_TMP, idx = node; + RegSet allow = rset_exclude(RSET_GPR, node); + int32_t lo, hi; + lua_assert(ofs % sizeof(Node) == 0); + if (ofs > 32736) { + idx = dest; + rset_clear(allow, dest); + kofs = (int32_t)offsetof(Node, key); + } else if (ra_hasreg(dest)) { + emit_tsi(as, MIPSI_ADDIU, dest, node, ofs); + } + if (!irt_ispri(irkey->t)) { + key = ra_scratch(as, allow); + rset_clear(allow, key); + } + if (irt_isnum(irkey->t)) { + lo = (int32_t)ir_knum(irkey)->u32.lo; + hi = (int32_t)ir_knum(irkey)->u32.hi; + } else { + lo = irkey->i; + hi = irt_toitype(irkey->t); + if (!ra_hasreg(key)) + goto nolo; + } + asm_guard(as, MIPSI_BNE, key, lo ? ra_allock(as, lo, allow) : RID_ZERO); +nolo: + asm_guard(as, MIPSI_BNE, type, hi ? ra_allock(as, hi, allow) : RID_ZERO); + if (ra_hasreg(key)) emit_tsi(as, MIPSI_LW, key, idx, kofs+(LJ_BE?4:0)); + emit_tsi(as, MIPSI_LW, type, idx, kofs+(LJ_BE?0:4)); + if (ofs > 32736) + emit_tsi(as, MIPSI_ADDU, dest, node, ra_allock(as, ofs, allow)); +} + +static void asm_newref(ASMState *as, IRIns *ir) +{ + if (ir->r != RID_SINK) { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_newkey]; + IRRef args[3]; + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ir->op1; /* GCtab *t */ + args[2] = ASMREF_TMP1; /* cTValue *key */ + asm_setupresult(as, ir, ci); /* TValue * */ + asm_gencall(as, ci, args); + asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op2); + } +} + +static void asm_uref(ASMState *as, IRIns *ir) +{ + /* NYI: Check that UREFO is still open and not aliasing a slot. */ + Reg dest = ra_dest(as, ir, RSET_GPR); + if (irref_isk(ir->op1)) { + GCfunc *fn = ir_kfunc(IR(ir->op1)); + MRef *v = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.v; + emit_lsptr(as, MIPSI_LW, dest, v, RSET_GPR); + } else { + Reg uv = ra_scratch(as, RSET_GPR); + Reg func = ra_alloc1(as, ir->op1, RSET_GPR); + if (ir->o == IR_UREFC) { + asm_guard(as, MIPSI_BEQ, RID_TMP, RID_ZERO); + emit_tsi(as, MIPSI_ADDIU, dest, uv, (int32_t)offsetof(GCupval, tv)); + emit_tsi(as, MIPSI_LBU, RID_TMP, uv, (int32_t)offsetof(GCupval, closed)); + } else { + emit_tsi(as, MIPSI_LW, dest, uv, (int32_t)offsetof(GCupval, v)); + } + emit_tsi(as, MIPSI_LW, uv, func, + (int32_t)offsetof(GCfuncL, uvptr) + 4*(int32_t)(ir->op2 >> 8)); + } +} + +static void asm_fref(ASMState *as, IRIns *ir) +{ + UNUSED(as); UNUSED(ir); + lua_assert(!ra_used(ir)); +} + +static void asm_strref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + IRRef ref = ir->op2, refk = ir->op1; + int32_t ofs = (int32_t)sizeof(GCstr); + Reg r; + if (irref_isk(ref)) { + IRRef tmp = refk; refk = ref; ref = tmp; + } else if (!irref_isk(refk)) { + Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); + IRIns *irr = IR(ir->op2); + if (ra_hasreg(irr->r)) { + ra_noweak(as, irr->r); + right = irr->r; + } else if (mayfuse(as, irr->op2) && + irr->o == IR_ADD && irref_isk(irr->op2) && + checki16(ofs + IR(irr->op2)->i)) { + ofs += IR(irr->op2)->i; + right = ra_alloc1(as, irr->op1, rset_exclude(RSET_GPR, left)); + } else { + right = ra_allocref(as, ir->op2, rset_exclude(RSET_GPR, left)); + } + emit_tsi(as, MIPSI_ADDIU, dest, dest, ofs); + emit_dst(as, MIPSI_ADDU, dest, left, right); + return; + } + r = ra_alloc1(as, ref, RSET_GPR); + ofs += IR(refk)->i; + if (checki16(ofs)) + emit_tsi(as, MIPSI_ADDIU, dest, r, ofs); + else + emit_dst(as, MIPSI_ADDU, dest, r, + ra_allock(as, ofs, rset_exclude(RSET_GPR, r))); +} + +/* -- Loads and stores ---------------------------------------------------- */ + +static MIPSIns asm_fxloadins(IRIns *ir) +{ + switch (irt_type(ir->t)) { + case IRT_I8: return MIPSI_LB; + case IRT_U8: return MIPSI_LBU; + case IRT_I16: return MIPSI_LH; + case IRT_U16: return MIPSI_LHU; + case IRT_NUM: return MIPSI_LDC1; + case IRT_FLOAT: return MIPSI_LWC1; + default: return MIPSI_LW; + } +} + +static MIPSIns asm_fxstoreins(IRIns *ir) +{ + switch (irt_type(ir->t)) { + case IRT_I8: case IRT_U8: return MIPSI_SB; + case IRT_I16: case IRT_U16: return MIPSI_SH; + case IRT_NUM: return MIPSI_SDC1; + case IRT_FLOAT: return MIPSI_SWC1; + default: return MIPSI_SW; + } +} + +static void asm_fload(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg idx = ra_alloc1(as, ir->op1, RSET_GPR); + MIPSIns mi = asm_fxloadins(ir); + int32_t ofs; + if (ir->op2 == IRFL_TAB_ARRAY) { + ofs = asm_fuseabase(as, ir->op1); + if (ofs) { /* Turn the t->array load into an add for colocated arrays. */ + emit_tsi(as, MIPSI_ADDIU, dest, idx, ofs); + return; + } + } + ofs = field_ofs[ir->op2]; + lua_assert(!irt_isfp(ir->t)); + emit_tsi(as, mi, dest, idx, ofs); +} + +static void asm_fstore(ASMState *as, IRIns *ir) +{ + if (ir->r != RID_SINK) { + Reg src = ra_alloc1z(as, ir->op2, RSET_GPR); + IRIns *irf = IR(ir->op1); + Reg idx = ra_alloc1(as, irf->op1, rset_exclude(RSET_GPR, src)); + int32_t ofs = field_ofs[irf->op2]; + MIPSIns mi = asm_fxstoreins(ir); + lua_assert(!irt_isfp(ir->t)); + emit_tsi(as, mi, src, idx, ofs); + } +} + +static void asm_xload(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); + lua_assert(!(ir->op2 & IRXLOAD_UNALIGNED)); + asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR, 0); +} + +static void asm_xstore(ASMState *as, IRIns *ir, int32_t ofs) +{ + if (ir->r != RID_SINK) { + Reg src = ra_alloc1z(as, ir->op2, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); + asm_fusexref(as, asm_fxstoreins(ir), src, ir->op1, + rset_exclude(RSET_GPR, src), ofs); + } +} + +static void asm_ahuvload(ASMState *as, IRIns *ir) +{ + IRType1 t = ir->t; + Reg dest = RID_NONE, type = RID_TMP, idx; + RegSet allow = RSET_GPR; + int32_t ofs = 0; + if (ra_used(ir)) { + lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); + dest = ra_dest(as, ir, irt_isnum(t) ? RSET_FPR : RSET_GPR); + rset_clear(allow, dest); + } + idx = asm_fuseahuref(as, ir->op1, &ofs, allow); + rset_clear(allow, idx); + if (irt_isnum(t)) { + asm_guard(as, MIPSI_BEQ, type, RID_ZERO); + emit_tsi(as, MIPSI_SLTIU, type, type, (int32_t)LJ_TISNUM); + if (ra_hasreg(dest)) + emit_hsi(as, MIPSI_LDC1, dest, idx, ofs); + } else { + asm_guard(as, MIPSI_BNE, type, ra_allock(as, irt_toitype(t), allow)); + if (ra_hasreg(dest)) emit_tsi(as, MIPSI_LW, dest, idx, ofs+(LJ_BE?4:0)); + } + emit_tsi(as, MIPSI_LW, type, idx, ofs+(LJ_BE?0:4)); +} + +static void asm_ahustore(ASMState *as, IRIns *ir) +{ + RegSet allow = RSET_GPR; + Reg idx, src = RID_NONE, type = RID_NONE; + int32_t ofs = 0; + if (ir->r == RID_SINK) + return; + if (irt_isnum(ir->t)) { + src = ra_alloc1(as, ir->op2, RSET_FPR); + } else { + if (!irt_ispri(ir->t)) { + src = ra_alloc1(as, ir->op2, allow); + rset_clear(allow, src); + } + type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); + rset_clear(allow, type); + } + idx = asm_fuseahuref(as, ir->op1, &ofs, allow); + if (irt_isnum(ir->t)) { + emit_hsi(as, MIPSI_SDC1, src, idx, ofs); + } else { + if (ra_hasreg(src)) + emit_tsi(as, MIPSI_SW, src, idx, ofs+(LJ_BE?4:0)); + emit_tsi(as, MIPSI_SW, type, idx, ofs+(LJ_BE?0:4)); + } +} + +static void asm_sload(ASMState *as, IRIns *ir) +{ + int32_t ofs = 8*((int32_t)ir->op1-1) + ((ir->op2 & IRSLOAD_FRAME) ? 4 : 0); + IRType1 t = ir->t; + Reg dest = RID_NONE, type = RID_NONE, base; + RegSet allow = RSET_GPR; + lua_assert(!(ir->op2 & IRSLOAD_PARENT)); /* Handled by asm_head_side(). */ + lua_assert(irt_isguard(t) || !(ir->op2 & IRSLOAD_TYPECHECK)); + lua_assert(!irt_isint(t) || (ir->op2 & (IRSLOAD_CONVERT|IRSLOAD_FRAME))); + if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(t) && irt_isint(t)) { + dest = ra_scratch(as, RSET_FPR); + asm_tointg(as, ir, dest); + t.irt = IRT_NUM; /* Continue with a regular number type check. */ + } else if (ra_used(ir)) { + lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); + dest = ra_dest(as, ir, irt_isnum(t) ? RSET_FPR : RSET_GPR); + rset_clear(allow, dest); + base = ra_alloc1(as, REF_BASE, allow); + rset_clear(allow, base); + if ((ir->op2 & IRSLOAD_CONVERT)) { + if (irt_isint(t)) { + Reg tmp = ra_scratch(as, RSET_FPR); + emit_tg(as, MIPSI_MFC1, dest, tmp); + emit_fg(as, MIPSI_CVT_W_D, tmp, tmp); + dest = tmp; + t.irt = IRT_NUM; /* Check for original type. */ + } else { + Reg tmp = ra_scratch(as, RSET_GPR); + emit_fg(as, MIPSI_CVT_D_W, dest, dest); + emit_tg(as, MIPSI_MTC1, tmp, dest); + dest = tmp; + t.irt = IRT_INT; /* Check for original type. */ + } + } + goto dotypecheck; + } + base = ra_alloc1(as, REF_BASE, allow); + rset_clear(allow, base); +dotypecheck: + if (irt_isnum(t)) { + if ((ir->op2 & IRSLOAD_TYPECHECK)) { + asm_guard(as, MIPSI_BEQ, RID_TMP, RID_ZERO); + emit_tsi(as, MIPSI_SLTIU, RID_TMP, RID_TMP, (int32_t)LJ_TISNUM); + type = RID_TMP; + } + if (ra_hasreg(dest)) emit_hsi(as, MIPSI_LDC1, dest, base, ofs); + } else { + if ((ir->op2 & IRSLOAD_TYPECHECK)) { + Reg ktype = ra_allock(as, irt_toitype(t), allow); + asm_guard(as, MIPSI_BNE, RID_TMP, ktype); + type = RID_TMP; + } + if (ra_hasreg(dest)) emit_tsi(as, MIPSI_LW, dest, base, ofs ^ (LJ_BE?4:0)); + } + if (ra_hasreg(type)) emit_tsi(as, MIPSI_LW, type, base, ofs ^ (LJ_BE?0:4)); +} + +/* -- Allocations --------------------------------------------------------- */ + +#if LJ_HASFFI +static void asm_cnew(ASMState *as, IRIns *ir) +{ + CTState *cts = ctype_ctsG(J2G(as->J)); + CTypeID ctypeid = (CTypeID)IR(ir->op1)->i; + CTSize sz = (ir->o == IR_CNEWI || ir->op2 == REF_NIL) ? + lj_ctype_size(cts, ctypeid) : (CTSize)IR(ir->op2)->i; + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco]; + IRRef args[2]; + RegSet allow = (RSET_GPR & ~RSET_SCRATCH); + RegSet drop = RSET_SCRATCH; + lua_assert(sz != CTSIZE_INVALID); + + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ASMREF_TMP1; /* MSize size */ + as->gcsteps++; + + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + ra_evictset(as, drop); + if (ra_used(ir)) + ra_destreg(as, ir, RID_RET); /* GCcdata * */ + + /* Initialize immutable cdata object. */ + if (ir->o == IR_CNEWI) { + int32_t ofs = sizeof(GCcdata); + lua_assert(sz == 4 || sz == 8); + if (sz == 8) { + ofs += 4; + lua_assert((ir+1)->o == IR_HIOP); + if (LJ_LE) ir++; + } + for (;;) { + Reg r = ra_alloc1z(as, ir->op2, allow); + emit_tsi(as, MIPSI_SW, r, RID_RET, ofs); + rset_clear(allow, r); + if (ofs == sizeof(GCcdata)) break; + ofs -= 4; if (LJ_BE) ir++; else ir--; + } + } + /* Initialize gct and ctypeid. lj_mem_newgco() already sets marked. */ + emit_tsi(as, MIPSI_SB, RID_RET+1, RID_RET, offsetof(GCcdata, gct)); + emit_tsi(as, MIPSI_SH, RID_TMP, RID_RET, offsetof(GCcdata, ctypeid)); + emit_ti(as, MIPSI_LI, RID_RET+1, ~LJ_TCDATA); + emit_ti(as, MIPSI_LI, RID_TMP, ctypeid); /* Lower 16 bit used. Sign-ext ok. */ + asm_gencall(as, ci, args); + ra_allockreg(as, (int32_t)(sz+sizeof(GCcdata)), + ra_releasetmp(as, ASMREF_TMP1)); +} +#else +#define asm_cnew(as, ir) ((void)0) +#endif + +/* -- Write barriers ------------------------------------------------------ */ + +static void asm_tbar(ASMState *as, IRIns *ir) +{ + Reg tab = ra_alloc1(as, ir->op1, RSET_GPR); + Reg mark = ra_scratch(as, rset_exclude(RSET_GPR, tab)); + Reg link = RID_TMP; + MCLabel l_end = emit_label(as); + emit_tsi(as, MIPSI_SW, link, tab, (int32_t)offsetof(GCtab, gclist)); + emit_tsi(as, MIPSI_SB, mark, tab, (int32_t)offsetof(GCtab, marked)); + emit_setgl(as, tab, gc.grayagain); + emit_getgl(as, link, gc.grayagain); + emit_dst(as, MIPSI_XOR, mark, mark, RID_TMP); /* Clear black bit. */ + emit_branch(as, MIPSI_BEQ, RID_TMP, RID_ZERO, l_end); + emit_tsi(as, MIPSI_ANDI, RID_TMP, mark, LJ_GC_BLACK); + emit_tsi(as, MIPSI_LBU, mark, tab, (int32_t)offsetof(GCtab, marked)); +} + +static void asm_obar(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_barrieruv]; + IRRef args[2]; + MCLabel l_end; + Reg obj, val, tmp; + /* No need for other object barriers (yet). */ + lua_assert(IR(ir->op1)->o == IR_UREFC); + ra_evictset(as, RSET_SCRATCH); + l_end = emit_label(as); + args[0] = ASMREF_TMP1; /* global_State *g */ + args[1] = ir->op1; /* TValue *tv */ + asm_gencall(as, ci, args); + emit_tsi(as, MIPSI_ADDIU, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768); + obj = IR(ir->op1)->r; + tmp = ra_scratch(as, rset_exclude(RSET_GPR, obj)); + emit_branch(as, MIPSI_BEQ, RID_TMP, RID_ZERO, l_end); + emit_tsi(as, MIPSI_ANDI, tmp, tmp, LJ_GC_BLACK); + emit_branch(as, MIPSI_BEQ, RID_TMP, RID_ZERO, l_end); + emit_tsi(as, MIPSI_ANDI, RID_TMP, RID_TMP, LJ_GC_WHITES); + val = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, obj)); + emit_tsi(as, MIPSI_LBU, tmp, obj, + (int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)); + emit_tsi(as, MIPSI_LBU, RID_TMP, val, (int32_t)offsetof(GChead, marked)); +} + +/* -- Arithmetic and logic operations ------------------------------------- */ + +static void asm_fparith(ASMState *as, IRIns *ir, MIPSIns mi) +{ + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg right, left = ra_alloc2(as, ir, RSET_FPR); + right = (left >> 8); left &= 255; + emit_fgh(as, mi, dest, left, right); +} + +static void asm_fpunary(ASMState *as, IRIns *ir, MIPSIns mi) +{ + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg left = ra_hintalloc(as, ir->op1, dest, RSET_FPR); + emit_fg(as, mi, dest, left); +} + +static int asm_fpjoin_pow(ASMState *as, IRIns *ir) +{ + IRIns *irp = IR(ir->op1); + if (irp == ir-1 && irp->o == IR_MUL && !ra_used(irp)) { + IRIns *irpp = IR(irp->op1); + if (irpp == ir-2 && irpp->o == IR_FPMATH && + irpp->op2 == IRFPM_LOG2 && !ra_used(irpp)) { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_pow]; + IRRef args[2]; + args[0] = irpp->op1; + args[1] = irp->op2; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); + return 1; + } + } + return 0; +} + +static void asm_add(ASMState *as, IRIns *ir) +{ + if (irt_isnum(ir->t)) { + asm_fparith(as, ir, MIPSI_ADD_D); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (checki16(k)) { + emit_tsi(as, MIPSI_ADDIU, dest, left, k); + return; + } + } + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_dst(as, MIPSI_ADDU, dest, left, right); + } +} + +static void asm_sub(ASMState *as, IRIns *ir) +{ + if (irt_isnum(ir->t)) { + asm_fparith(as, ir, MIPSI_SUB_D); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + emit_dst(as, MIPSI_SUBU, dest, left, right); + } +} + +static void asm_mul(ASMState *as, IRIns *ir) +{ + if (irt_isnum(ir->t)) { + asm_fparith(as, ir, MIPSI_MUL_D); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + emit_dst(as, MIPSI_MUL, dest, left, right); + } +} + +static void asm_neg(ASMState *as, IRIns *ir) +{ + if (irt_isnum(ir->t)) { + asm_fpunary(as, ir, MIPSI_NEG_D); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + emit_dst(as, MIPSI_SUBU, dest, RID_ZERO, left); + } +} + +static void asm_arithov(ASMState *as, IRIns *ir) +{ + Reg right, left, tmp, dest = ra_dest(as, ir, RSET_GPR); + if (irref_isk(ir->op2)) { + int k = IR(ir->op2)->i; + if (ir->o == IR_SUBOV) k = -k; + if (checki16(k)) { /* (dest < left) == (k >= 0 ? 1 : 0) */ + left = ra_alloc1(as, ir->op1, RSET_GPR); + asm_guard(as, k >= 0 ? MIPSI_BNE : MIPSI_BEQ, RID_TMP, RID_ZERO); + emit_dst(as, MIPSI_SLT, RID_TMP, dest, dest == left ? RID_TMP : left); + emit_tsi(as, MIPSI_ADDIU, dest, left, k); + if (dest == left) emit_move(as, RID_TMP, left); + return; + } + } + left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + tmp = ra_scratch(as, rset_exclude(rset_exclude(rset_exclude(RSET_GPR, left), + right), dest)); + asm_guard(as, MIPSI_BLTZ, RID_TMP, 0); + emit_dst(as, MIPSI_AND, RID_TMP, RID_TMP, tmp); + if (ir->o == IR_ADDOV) { /* ((dest^left) & (dest^right)) < 0 */ + emit_dst(as, MIPSI_XOR, RID_TMP, dest, dest == right ? RID_TMP : right); + } else { /* ((dest^left) & (dest^~right)) < 0 */ + emit_dst(as, MIPSI_XOR, RID_TMP, RID_TMP, dest); + emit_dst(as, MIPSI_NOR, RID_TMP, dest == right ? RID_TMP : right, RID_ZERO); + } + emit_dst(as, MIPSI_XOR, tmp, dest, dest == left ? RID_TMP : left); + emit_dst(as, ir->o == IR_ADDOV ? MIPSI_ADDU : MIPSI_SUBU, dest, left, right); + if (dest == left || dest == right) + emit_move(as, RID_TMP, dest == left ? left : right); +} + +static void asm_mulov(ASMState *as, IRIns *ir) +{ +#if LJ_DUALNUM +#error "NYI: MULOV" +#else + UNUSED(as); UNUSED(ir); lua_assert(0); /* Unused in single-number mode. */ +#endif +} + +#if LJ_HASFFI +static void asm_add64(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (k == 0) { + emit_dst(as, MIPSI_ADDU, dest, left, RID_TMP); + goto loarith; + } else if (checki16(k)) { + emit_dst(as, MIPSI_ADDU, dest, dest, RID_TMP); + emit_tsi(as, MIPSI_ADDIU, dest, left, k); + goto loarith; + } + } + emit_dst(as, MIPSI_ADDU, dest, dest, RID_TMP); + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_dst(as, MIPSI_ADDU, dest, left, right); +loarith: + ir--; + dest = ra_dest(as, ir, RSET_GPR); + left = ra_alloc1(as, ir->op1, RSET_GPR); + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (k == 0) { + if (dest != left) + emit_move(as, dest, left); + return; + } else if (checki16(k)) { + if (dest == left) { + Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, left)); + emit_move(as, dest, tmp); + dest = tmp; + } + emit_dst(as, MIPSI_SLTU, RID_TMP, dest, left); + emit_tsi(as, MIPSI_ADDIU, dest, left, k); + return; + } + } + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + if (dest == left && dest == right) { + Reg tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, left), right)); + emit_move(as, dest, tmp); + dest = tmp; + } + emit_dst(as, MIPSI_SLTU, RID_TMP, dest, dest == left ? right : left); + emit_dst(as, MIPSI_ADDU, dest, left, right); +} + +static void asm_sub64(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + emit_dst(as, MIPSI_SUBU, dest, dest, RID_TMP); + emit_dst(as, MIPSI_SUBU, dest, left, right); + ir--; + dest = ra_dest(as, ir, RSET_GPR); + left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + if (dest == left) { + Reg tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, left), right)); + emit_move(as, dest, tmp); + dest = tmp; + } + emit_dst(as, MIPSI_SLTU, RID_TMP, left, dest); + emit_dst(as, MIPSI_SUBU, dest, left, right); +} + +static void asm_neg64(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, ir->op1, RSET_GPR); + emit_dst(as, MIPSI_SUBU, dest, dest, RID_TMP); + emit_dst(as, MIPSI_SUBU, dest, RID_ZERO, left); + ir--; + dest = ra_dest(as, ir, RSET_GPR); + left = ra_alloc1(as, ir->op1, RSET_GPR); + emit_dst(as, MIPSI_SLTU, RID_TMP, RID_ZERO, dest); + emit_dst(as, MIPSI_SUBU, dest, RID_ZERO, left); +} +#endif + +static void asm_bitnot(ASMState *as, IRIns *ir) +{ + Reg left, right, dest = ra_dest(as, ir, RSET_GPR); + IRIns *irl = IR(ir->op1); + if (mayfuse(as, ir->op1) && irl->o == IR_BOR) { + left = ra_alloc2(as, irl, RSET_GPR); + right = (left >> 8); left &= 255; + } else { + left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + right = RID_ZERO; + } + emit_dst(as, MIPSI_NOR, dest, left, right); +} + +static void asm_bitswap(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, ir->op1, RSET_GPR); + if ((as->flags & JIT_F_MIPS32R2)) { + emit_dta(as, MIPSI_ROTR, dest, RID_TMP, 16); + emit_dst(as, MIPSI_WSBH, RID_TMP, 0, left); + } else { + Reg tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, left), dest)); + emit_dst(as, MIPSI_OR, dest, dest, tmp); + emit_dst(as, MIPSI_OR, dest, dest, RID_TMP); + emit_tsi(as, MIPSI_ANDI, dest, dest, 0xff00); + emit_dta(as, MIPSI_SLL, RID_TMP, RID_TMP, 8); + emit_dta(as, MIPSI_SRL, dest, left, 8); + emit_tsi(as, MIPSI_ANDI, RID_TMP, left, 0xff00); + emit_dst(as, MIPSI_OR, tmp, tmp, RID_TMP); + emit_dta(as, MIPSI_SRL, tmp, left, 24); + emit_dta(as, MIPSI_SLL, RID_TMP, left, 24); + } +} + +static void asm_bitop(ASMState *as, IRIns *ir, MIPSIns mi, MIPSIns mik) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (checku16(k)) { + emit_tsi(as, mik, dest, left, k); + return; + } + } + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_dst(as, mi, dest, left, right); +} + +static void asm_bitshift(ASMState *as, IRIns *ir, MIPSIns mi, MIPSIns mik) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + if (irref_isk(ir->op2)) { /* Constant shifts. */ + uint32_t shift = (uint32_t)(IR(ir->op2)->i & 31); + emit_dta(as, mik, dest, ra_hintalloc(as, ir->op1, dest, RSET_GPR), shift); + } else { + Reg right, left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + emit_dst(as, mi, dest, right, left); /* Shift amount is in rs. */ + } +} + +static void asm_bitror(ASMState *as, IRIns *ir) +{ + if ((as->flags & JIT_F_MIPS32R2)) { + asm_bitshift(as, ir, MIPSI_ROTRV, MIPSI_ROTR); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + if (irref_isk(ir->op2)) { /* Constant shifts. */ + uint32_t shift = (uint32_t)(IR(ir->op2)->i & 31); + Reg left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + emit_rotr(as, dest, left, RID_TMP, shift); + } else { + Reg right, left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + emit_dst(as, MIPSI_OR, dest, dest, RID_TMP); + emit_dst(as, MIPSI_SRLV, dest, right, left); + emit_dst(as, MIPSI_SLLV, RID_TMP, RID_TMP, left); + emit_dst(as, MIPSI_SUBU, RID_TMP, ra_allock(as, 32, RSET_GPR), right); + } + } +} + +static void asm_min_max(ASMState *as, IRIns *ir, int ismax) +{ + if (irt_isnum(ir->t)) { + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg right, left = ra_alloc2(as, ir, RSET_FPR); + right = (left >> 8); left &= 255; + if (dest == left) { + emit_fg(as, MIPSI_MOVT_D, dest, right); + } else { + emit_fg(as, MIPSI_MOVF_D, dest, left); + if (dest != right) emit_fg(as, MIPSI_MOV_D, dest, right); + } + emit_fgh(as, MIPSI_C_OLT_D, 0, ismax ? left : right, ismax ? right : left); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + if (dest == left) { + emit_dst(as, MIPSI_MOVN, dest, right, RID_TMP); + } else { + emit_dst(as, MIPSI_MOVZ, dest, left, RID_TMP); + if (dest != right) emit_move(as, dest, right); + } + emit_dst(as, MIPSI_SLT, RID_TMP, + ismax ? left : right, ismax ? right : left); + } +} + +/* -- Comparisons --------------------------------------------------------- */ + +static void asm_comp(ASMState *as, IRIns *ir) +{ + /* ORDER IR: LT GE LE GT ULT UGE ULE UGT. */ + IROp op = ir->o; + if (irt_isnum(ir->t)) { + Reg right, left = ra_alloc2(as, ir, RSET_FPR); + right = (left >> 8); left &= 255; + asm_guard(as, (op&1) ? MIPSI_BC1T : MIPSI_BC1F, 0, 0); + emit_fgh(as, MIPSI_C_OLT_D + ((op&3) ^ ((op>>2)&1)), 0, left, right); + } else { + Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); + if (op == IR_ABC) op = IR_UGT; + if ((op&4) == 0 && irref_isk(ir->op2) && IR(ir->op2)->i == 0) { + MIPSIns mi = (op&2) ? ((op&1) ? MIPSI_BLEZ : MIPSI_BGTZ) : + ((op&1) ? MIPSI_BLTZ : MIPSI_BGEZ); + asm_guard(as, mi, left, 0); + } else { + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if ((op&2)) k++; + if (checki16(k)) { + asm_guard(as, (op&1) ? MIPSI_BNE : MIPSI_BEQ, RID_TMP, RID_ZERO); + emit_tsi(as, (op&4) ? MIPSI_SLTIU : MIPSI_SLTI, + RID_TMP, left, k); + return; + } + } + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + asm_guard(as, ((op^(op>>1))&1) ? MIPSI_BNE : MIPSI_BEQ, RID_TMP, RID_ZERO); + emit_dst(as, (op&4) ? MIPSI_SLTU : MIPSI_SLT, + RID_TMP, (op&2) ? right : left, (op&2) ? left : right); + } + } +} + +static void asm_compeq(ASMState *as, IRIns *ir) +{ + Reg right, left = ra_alloc2(as, ir, irt_isnum(ir->t) ? RSET_FPR : RSET_GPR); + right = (left >> 8); left &= 255; + if (irt_isnum(ir->t)) { + asm_guard(as, (ir->o & 1) ? MIPSI_BC1T : MIPSI_BC1F, 0, 0); + emit_fgh(as, MIPSI_C_EQ_D, 0, left, right); + } else { + asm_guard(as, (ir->o & 1) ? MIPSI_BEQ : MIPSI_BNE, left, right); + } +} + +#if LJ_HASFFI +/* 64 bit integer comparisons. */ +static void asm_comp64(ASMState *as, IRIns *ir) +{ + /* ORDER IR: LT GE LE GT ULT UGE ULE UGT. */ + IROp op = (ir-1)->o; + MCLabel l_end; + Reg rightlo, leftlo, righthi, lefthi = ra_alloc2(as, ir, RSET_GPR); + righthi = (lefthi >> 8); lefthi &= 255; + leftlo = ra_alloc2(as, ir-1, + rset_exclude(rset_exclude(RSET_GPR, lefthi), righthi)); + rightlo = (leftlo >> 8); leftlo &= 255; + asm_guard(as, ((op^(op>>1))&1) ? MIPSI_BNE : MIPSI_BEQ, RID_TMP, RID_ZERO); + l_end = emit_label(as); + if (lefthi != righthi) + emit_dst(as, (op&4) ? MIPSI_SLTU : MIPSI_SLT, RID_TMP, + (op&2) ? righthi : lefthi, (op&2) ? lefthi : righthi); + emit_dst(as, MIPSI_SLTU, RID_TMP, + (op&2) ? rightlo : leftlo, (op&2) ? leftlo : rightlo); + if (lefthi != righthi) + emit_branch(as, MIPSI_BEQ, lefthi, righthi, l_end); +} + +static void asm_comp64eq(ASMState *as, IRIns *ir) +{ + Reg tmp, right, left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + asm_guard(as, ((ir-1)->o & 1) ? MIPSI_BEQ : MIPSI_BNE, RID_TMP, RID_ZERO); + tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, left), right)); + emit_dst(as, MIPSI_OR, RID_TMP, RID_TMP, tmp); + emit_dst(as, MIPSI_XOR, tmp, left, right); + left = ra_alloc2(as, ir-1, RSET_GPR); + right = (left >> 8); left &= 255; + emit_dst(as, MIPSI_XOR, RID_TMP, left, right); +} +#endif + +/* -- Support for 64 bit ops in 32 bit mode ------------------------------- */ + +/* Hiword op of a split 64 bit op. Previous op must be the loword op. */ +static void asm_hiop(ASMState *as, IRIns *ir) +{ +#if LJ_HASFFI + /* HIOP is marked as a store because it needs its own DCE logic. */ + int uselo = ra_used(ir-1), usehi = ra_used(ir); /* Loword/hiword used? */ + if (LJ_UNLIKELY(!(as->flags & JIT_F_OPT_DCE))) uselo = usehi = 1; + if ((ir-1)->o == IR_CONV) { /* Conversions to/from 64 bit. */ + as->curins--; /* Always skip the CONV. */ + if (usehi || uselo) + asm_conv64(as, ir); + return; + } else if ((ir-1)->o < IR_EQ) { /* 64 bit integer comparisons. ORDER IR. */ + as->curins--; /* Always skip the loword comparison. */ + asm_comp64(as, ir); + return; + } else if ((ir-1)->o <= IR_NE) { /* 64 bit integer comparisons. ORDER IR. */ + as->curins--; /* Always skip the loword comparison. */ + asm_comp64eq(as, ir); + return; + } else if ((ir-1)->o == IR_XSTORE) { + as->curins--; /* Handle both stores here. */ + if ((ir-1)->r != RID_SINK) { + asm_xstore(as, ir, LJ_LE ? 4 : 0); + asm_xstore(as, ir-1, LJ_LE ? 0 : 4); + } + return; + } + if (!usehi) return; /* Skip unused hiword op for all remaining ops. */ + switch ((ir-1)->o) { + case IR_ADD: as->curins--; asm_add64(as, ir); break; + case IR_SUB: as->curins--; asm_sub64(as, ir); break; + case IR_NEG: as->curins--; asm_neg64(as, ir); break; + case IR_CALLN: + case IR_CALLXS: + if (!uselo) + ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */ + break; + case IR_CNEWI: + /* Nothing to do here. Handled by lo op itself. */ + break; + default: lua_assert(0); break; + } +#else + UNUSED(as); UNUSED(ir); lua_assert(0); /* Unused without FFI. */ +#endif +} + +/* -- Stack handling ------------------------------------------------------ */ + +/* Check Lua stack size for overflow. Use exit handler as fallback. */ +static void asm_stack_check(ASMState *as, BCReg topslot, + IRIns *irp, RegSet allow, ExitNo exitno) +{ + /* Try to get an unused temp. register, otherwise spill/restore RID_RET*. */ + Reg tmp, pbase = irp ? (ra_hasreg(irp->r) ? irp->r : RID_TMP) : RID_BASE; + ExitNo oldsnap = as->snapno; + rset_clear(allow, pbase); + tmp = allow ? rset_pickbot(allow) : + (pbase == RID_RETHI ? RID_RETLO : RID_RETHI); + as->snapno = exitno; + asm_guard(as, MIPSI_BNE, RID_TMP, RID_ZERO); + as->snapno = oldsnap; + if (allow == RSET_EMPTY) /* Restore temp. register. */ + emit_tsi(as, MIPSI_LW, tmp, RID_SP, 0); + else + ra_modified(as, tmp); + emit_tsi(as, MIPSI_SLTIU, RID_TMP, RID_TMP, (int32_t)(8*topslot)); + emit_dst(as, MIPSI_SUBU, RID_TMP, tmp, pbase); + emit_tsi(as, MIPSI_LW, tmp, tmp, offsetof(lua_State, maxstack)); + if (pbase == RID_TMP) + emit_getgl(as, RID_TMP, jit_base); + emit_getgl(as, tmp, jit_L); + if (allow == RSET_EMPTY) /* Spill temp. register. */ + emit_tsi(as, MIPSI_SW, tmp, RID_SP, 0); +} + +/* Restore Lua stack from on-trace state. */ +static void asm_stack_restore(ASMState *as, SnapShot *snap) +{ + SnapEntry *map = &as->T->snapmap[snap->mapofs]; + SnapEntry *flinks = &as->T->snapmap[snap_nextofs(as->T, snap)-1]; + MSize n, nent = snap->nent; + /* Store the value of all modified slots to the Lua stack. */ + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + BCReg s = snap_slot(sn); + int32_t ofs = 8*((int32_t)s-1); + IRRef ref = snap_ref(sn); + IRIns *ir = IR(ref); + if ((sn & SNAP_NORESTORE)) + continue; + if (irt_isnum(ir->t)) { + Reg src = ra_alloc1(as, ref, RSET_FPR); + emit_hsi(as, MIPSI_SDC1, src, RID_BASE, ofs); + } else { + Reg type; + RegSet allow = rset_exclude(RSET_GPR, RID_BASE); + lua_assert(irt_ispri(ir->t) || irt_isaddr(ir->t) || irt_isinteger(ir->t)); + if (!irt_ispri(ir->t)) { + Reg src = ra_alloc1(as, ref, allow); + rset_clear(allow, src); + emit_tsi(as, MIPSI_SW, src, RID_BASE, ofs+(LJ_BE?4:0)); + } + if ((sn & (SNAP_CONT|SNAP_FRAME))) { + if (s == 0) continue; /* Do not overwrite link to previous frame. */ + type = ra_allock(as, (int32_t)(*flinks--), allow); + } else { + type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); + } + emit_tsi(as, MIPSI_SW, type, RID_BASE, ofs+(LJ_BE?0:4)); + } + checkmclim(as); + } + lua_assert(map + nent == flinks); +} + +/* -- GC handling --------------------------------------------------------- */ + +/* Check GC threshold and do one or more GC steps. */ +static void asm_gc_check(ASMState *as) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_step_jit]; + IRRef args[2]; + MCLabel l_end; + Reg tmp; + ra_evictset(as, RSET_SCRATCH); + l_end = emit_label(as); + /* Exit trace if in GCSatomic or GCSfinalize. Avoids syncing GC objects. */ + /* Assumes asm_snap_prep() already done. */ + asm_guard(as, MIPSI_BNE, RID_RET, RID_ZERO); + args[0] = ASMREF_TMP1; /* global_State *g */ + args[1] = ASMREF_TMP2; /* MSize steps */ + asm_gencall(as, ci, args); + emit_tsi(as, MIPSI_ADDIU, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768); + tmp = ra_releasetmp(as, ASMREF_TMP2); + emit_loadi(as, tmp, as->gcsteps); + /* Jump around GC step if GC total < GC threshold. */ + emit_branch(as, MIPSI_BNE, RID_TMP, RID_ZERO, l_end); + emit_dst(as, MIPSI_SLTU, RID_TMP, RID_TMP, tmp); + emit_getgl(as, tmp, gc.threshold); + emit_getgl(as, RID_TMP, gc.total); + as->gcsteps = 0; + checkmclim(as); +} + +/* -- Loop handling ------------------------------------------------------- */ + +/* Fixup the loop branch. */ +static void asm_loop_fixup(ASMState *as) +{ + MCode *p = as->mctop; + MCode *target = as->mcp; + p[-1] = MIPSI_NOP; + if (as->loopinv) { /* Inverted loop branch? */ + /* asm_guard already inverted the cond branch. Only patch the target. */ + p[-3] |= ((target-p+2) & 0x0000ffffu); + } else { + p[-2] = MIPSI_J|(((uintptr_t)target>>2)&0x03ffffffu); + } +} + +/* -- Head of trace ------------------------------------------------------- */ + +/* Coalesce BASE register for a root trace. */ +static void asm_head_root_base(ASMState *as) +{ + IRIns *ir = IR(REF_BASE); + Reg r = ir->r; + if (as->loopinv) as->mctop--; + if (ra_hasreg(r)) { + ra_free(as, r); + if (rset_test(as->modset, r) || irt_ismarked(ir->t)) + ir->r = RID_INIT; /* No inheritance for modified BASE register. */ + if (r != RID_BASE) + emit_move(as, r, RID_BASE); + } +} + +/* Coalesce BASE register for a side trace. */ +static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) +{ + IRIns *ir = IR(REF_BASE); + Reg r = ir->r; + if (as->loopinv) as->mctop--; + if (ra_hasreg(r)) { + ra_free(as, r); + if (rset_test(as->modset, r) || irt_ismarked(ir->t)) + ir->r = RID_INIT; /* No inheritance for modified BASE register. */ + if (irp->r == r) { + rset_clear(allow, r); /* Mark same BASE register as coalesced. */ + } else if (ra_hasreg(irp->r) && rset_test(as->freeset, irp->r)) { + rset_clear(allow, irp->r); + emit_move(as, r, irp->r); /* Move from coalesced parent reg. */ + } else { + emit_getgl(as, r, jit_base); /* Otherwise reload BASE. */ + } + } + return allow; +} + +/* -- Tail of trace ------------------------------------------------------- */ + +/* Fixup the tail code. */ +static void asm_tail_fixup(ASMState *as, TraceNo lnk) +{ + MCode *target = lnk ? traceref(as->J,lnk)->mcode : (MCode *)lj_vm_exit_interp; + int32_t spadj = as->T->spadjust; + MCode *p = as->mctop-1; + *p = spadj ? (MIPSI_ADDIU|MIPSF_T(RID_SP)|MIPSF_S(RID_SP)|spadj) : MIPSI_NOP; + p[-1] = MIPSI_J|(((uintptr_t)target>>2)&0x03ffffffu); +} + +/* Prepare tail of code. */ +static void asm_tail_prep(ASMState *as) +{ + as->mcp = as->mctop-2; /* Leave room for branch plus nop or stack adj. */ + as->invmcp = as->loopref ? as->mcp : NULL; +} + +/* -- Instruction dispatch ------------------------------------------------ */ + +/* Assemble a single instruction. */ +static void asm_ir(ASMState *as, IRIns *ir) +{ + switch ((IROp)ir->o) { + /* Miscellaneous ops. */ + case IR_LOOP: asm_loop(as); break; + case IR_NOP: case IR_XBAR: lua_assert(!ra_used(ir)); break; + case IR_USE: + ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break; + case IR_PHI: asm_phi(as, ir); break; + case IR_HIOP: asm_hiop(as, ir); break; + case IR_GCSTEP: asm_gcstep(as, ir); break; + + /* Guarded assertions. */ + case IR_EQ: case IR_NE: asm_compeq(as, ir); break; + case IR_LT: case IR_GE: case IR_LE: case IR_GT: + case IR_ULT: case IR_UGE: case IR_ULE: case IR_UGT: + case IR_ABC: + asm_comp(as, ir); + break; + + case IR_RETF: asm_retf(as, ir); break; + + /* Bit ops. */ + case IR_BNOT: asm_bitnot(as, ir); break; + case IR_BSWAP: asm_bitswap(as, ir); break; + + case IR_BAND: asm_bitop(as, ir, MIPSI_AND, MIPSI_ANDI); break; + case IR_BOR: asm_bitop(as, ir, MIPSI_OR, MIPSI_ORI); break; + case IR_BXOR: asm_bitop(as, ir, MIPSI_XOR, MIPSI_XORI); break; + + case IR_BSHL: asm_bitshift(as, ir, MIPSI_SLLV, MIPSI_SLL); break; + case IR_BSHR: asm_bitshift(as, ir, MIPSI_SRLV, MIPSI_SRL); break; + case IR_BSAR: asm_bitshift(as, ir, MIPSI_SRAV, MIPSI_SRA); break; + case IR_BROL: lua_assert(0); break; + case IR_BROR: asm_bitror(as, ir); break; + + /* Arithmetic ops. */ + case IR_ADD: asm_add(as, ir); break; + case IR_SUB: asm_sub(as, ir); break; + case IR_MUL: asm_mul(as, ir); break; + case IR_DIV: asm_fparith(as, ir, MIPSI_DIV_D); break; + case IR_MOD: asm_callid(as, ir, IRCALL_lj_vm_modi); break; + case IR_POW: asm_callid(as, ir, IRCALL_lj_vm_powi); break; + case IR_NEG: asm_neg(as, ir); break; + + case IR_ABS: asm_fpunary(as, ir, MIPSI_ABS_D); break; + case IR_ATAN2: asm_callid(as, ir, IRCALL_atan2); break; + case IR_LDEXP: asm_callid(as, ir, IRCALL_ldexp); break; + case IR_MIN: asm_min_max(as, ir, 0); break; + case IR_MAX: asm_min_max(as, ir, 1); break; + case IR_FPMATH: + if (ir->op2 == IRFPM_EXP2 && asm_fpjoin_pow(as, ir)) + break; + if (ir->op2 <= IRFPM_TRUNC) + asm_callround(as, ir, IRCALL_lj_vm_floor + ir->op2); + else if (ir->op2 == IRFPM_SQRT) + asm_fpunary(as, ir, MIPSI_SQRT_D); + else + asm_callid(as, ir, IRCALL_lj_vm_floor + ir->op2); + break; + + /* Overflow-checking arithmetic ops. */ + case IR_ADDOV: asm_arithov(as, ir); break; + case IR_SUBOV: asm_arithov(as, ir); break; + case IR_MULOV: asm_mulov(as, ir); break; + + /* Memory references. */ + case IR_AREF: asm_aref(as, ir); break; + case IR_HREF: asm_href(as, ir); break; + case IR_HREFK: asm_hrefk(as, ir); break; + case IR_NEWREF: asm_newref(as, ir); break; + case IR_UREFO: case IR_UREFC: asm_uref(as, ir); break; + case IR_FREF: asm_fref(as, ir); break; + case IR_STRREF: asm_strref(as, ir); break; + + /* Loads and stores. */ + case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: + asm_ahuvload(as, ir); + break; + case IR_FLOAD: asm_fload(as, ir); break; + case IR_XLOAD: asm_xload(as, ir); break; + case IR_SLOAD: asm_sload(as, ir); break; + + case IR_ASTORE: case IR_HSTORE: case IR_USTORE: asm_ahustore(as, ir); break; + case IR_FSTORE: asm_fstore(as, ir); break; + case IR_XSTORE: asm_xstore(as, ir, 0); break; + + /* Allocations. */ + case IR_SNEW: case IR_XSNEW: asm_snew(as, ir); break; + case IR_TNEW: asm_tnew(as, ir); break; + case IR_TDUP: asm_tdup(as, ir); break; + case IR_CNEW: case IR_CNEWI: asm_cnew(as, ir); break; + + /* Write barriers. */ + case IR_TBAR: asm_tbar(as, ir); break; + case IR_OBAR: asm_obar(as, ir); break; + + /* Type conversions. */ + case IR_CONV: asm_conv(as, ir); break; + case IR_TOBIT: asm_tobit(as, ir); break; + case IR_TOSTR: asm_tostr(as, ir); break; + case IR_STRTO: asm_strto(as, ir); break; + + /* Calls. */ + case IR_CALLN: case IR_CALLL: case IR_CALLS: asm_call(as, ir); break; + case IR_CALLXS: asm_callx(as, ir); break; + case IR_CARG: break; + + default: + setintV(&as->J->errinfo, ir->o); + lj_trace_err_info(as->J, LJ_TRERR_NYIIR); + break; + } +} + +/* -- Trace setup --------------------------------------------------------- */ + +/* Ensure there are enough stack slots for call arguments. */ +static Reg asm_setup_call_slots(ASMState *as, IRIns *ir, const CCallInfo *ci) +{ + IRRef args[CCI_NARGS_MAX*2]; + uint32_t i, nargs = (int)CCI_NARGS(ci); + int nslots = 4, ngpr = REGARG_NUMGPR, nfpr = REGARG_NUMFPR; + asm_collectargs(as, ir, ci, args); + for (i = 0; i < nargs; i++) { + if (args[i] && irt_isfp(IR(args[i])->t) && + nfpr > 0 && !(ci->flags & CCI_VARARG)) { + nfpr--; + ngpr -= irt_isnum(IR(args[i])->t) ? 2 : 1; + } else if (args[i] && irt_isnum(IR(args[i])->t)) { + nfpr = 0; + ngpr = ngpr & ~1; + if (ngpr > 0) ngpr -= 2; else nslots = (nslots+3) & ~1; + } else { + nfpr = 0; + if (ngpr > 0) ngpr--; else nslots++; + } + } + if (nslots > as->evenspill) /* Leave room for args in stack slots. */ + as->evenspill = nslots; + return irt_isfp(ir->t) ? REGSP_HINT(RID_FPRET) : REGSP_HINT(RID_RET); +} + +static void asm_setup_target(ASMState *as) +{ + asm_sparejump_setup(as); + asm_exitstub_setup(as); +} + +/* -- Trace patching ------------------------------------------------------ */ + +/* Patch exit jumps of existing machine code to a new target. */ +void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target) +{ + MCode *p = T->mcode; + MCode *pe = (MCode *)((char *)p + T->szmcode); + MCode *px = exitstub_trace_addr(T, exitno); + MCode *cstart = NULL, *cstop = NULL; + MCode *mcarea = lj_mcode_patch(J, p, 0); + MCode exitload = MIPSI_LI | MIPSF_T(RID_TMP) | exitno; + MCode tjump = MIPSI_J|(((uintptr_t)target>>2)&0x03ffffffu); + for (p++; p < pe; p++) { + if (*p == exitload) { /* Look for load of exit number. */ + if (((p[-1] ^ (px-p)) & 0xffffu) == 0) { /* Look for exitstub branch. */ + ptrdiff_t delta = target - p; + if (((delta + 0x8000) >> 16) == 0) { /* Patch in-range branch. */ + patchbranch: + p[-1] = (p[-1] & 0xffff0000u) | (delta & 0xffffu); + *p = MIPSI_NOP; /* Replace the load of the exit number. */ + cstop = p; + if (!cstart) cstart = p-1; + } else { /* Branch out of range. Use spare jump slot in mcarea. */ + int i; + for (i = 2; i < 2+MIPS_SPAREJUMP*2; i += 2) { + if (mcarea[i] == tjump) { + delta = mcarea+i - p; + goto patchbranch; + } else if (mcarea[i] == MIPSI_NOP) { + mcarea[i] = tjump; + cstart = mcarea+i; + delta = mcarea+i - p; + goto patchbranch; + } + } + /* Ignore jump slot overflow. Child trace is simply not attached. */ + } + } else if (p+1 == pe) { + /* Patch NOP after code for inverted loop branch. Use of J is ok. */ + lua_assert(p[1] == MIPSI_NOP); + p[1] = tjump; + *p = MIPSI_NOP; /* Replace the load of the exit number. */ + cstop = p+2; + if (!cstart) cstart = p+1; + } + } + } + if (cstart) lj_mcode_sync(cstart, cstop); + lj_mcode_patch(J, mcarea, 1); +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_ppc.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_ppc.h new file mode 100644 index 000000000..2c5d74a8d --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_ppc.h @@ -0,0 +1,2169 @@ +/* +** PPC IR assembler (SSA IR -> machine code). +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* -- Register allocator extensions --------------------------------------- */ + +/* Allocate a register with a hint. */ +static Reg ra_hintalloc(ASMState *as, IRRef ref, Reg hint, RegSet allow) +{ + Reg r = IR(ref)->r; + if (ra_noreg(r)) { + if (!ra_hashint(r) && !iscrossref(as, ref)) + ra_sethint(IR(ref)->r, hint); /* Propagate register hint. */ + r = ra_allocref(as, ref, allow); + } + ra_noweak(as, r); + return r; +} + +/* Allocate two source registers for three-operand instructions. */ +static Reg ra_alloc2(ASMState *as, IRIns *ir, RegSet allow) +{ + IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); + Reg left = irl->r, right = irr->r; + if (ra_hasreg(left)) { + ra_noweak(as, left); + if (ra_noreg(right)) + right = ra_allocref(as, ir->op2, rset_exclude(allow, left)); + else + ra_noweak(as, right); + } else if (ra_hasreg(right)) { + ra_noweak(as, right); + left = ra_allocref(as, ir->op1, rset_exclude(allow, right)); + } else if (ra_hashint(right)) { + right = ra_allocref(as, ir->op2, allow); + left = ra_alloc1(as, ir->op1, rset_exclude(allow, right)); + } else { + left = ra_allocref(as, ir->op1, allow); + right = ra_alloc1(as, ir->op2, rset_exclude(allow, left)); + } + return left | (right << 8); +} + +/* -- Guard handling ------------------------------------------------------ */ + +/* Setup exit stubs after the end of each trace. */ +static void asm_exitstub_setup(ASMState *as, ExitNo nexits) +{ + ExitNo i; + MCode *mxp = as->mctop; + if (mxp - (nexits + 3 + MCLIM_REDZONE) < as->mclim) + asm_mclimit(as); + /* 1: mflr r0; bl ->vm_exit_handler; li r0, traceno; bl <1; bl <1; ... */ + for (i = nexits-1; (int32_t)i >= 0; i--) + *--mxp = PPCI_BL|(((-3-i)&0x00ffffffu)<<2); + *--mxp = PPCI_LI|PPCF_T(RID_TMP)|as->T->traceno; /* Read by exit handler. */ + mxp--; + *mxp = PPCI_BL|((((MCode *)(void *)lj_vm_exit_handler-mxp)&0x00ffffffu)<<2); + *--mxp = PPCI_MFLR|PPCF_T(RID_TMP); + as->mctop = mxp; +} + +static MCode *asm_exitstub_addr(ASMState *as, ExitNo exitno) +{ + /* Keep this in-sync with exitstub_trace_addr(). */ + return as->mctop + exitno + 3; +} + +/* Emit conditional branch to exit for guard. */ +static void asm_guardcc(ASMState *as, PPCCC cc) +{ + MCode *target = asm_exitstub_addr(as, as->snapno); + MCode *p = as->mcp; + if (LJ_UNLIKELY(p == as->invmcp)) { + as->loopinv = 1; + *p = PPCI_B | (((target-p) & 0x00ffffffu) << 2); + emit_condbranch(as, PPCI_BC, cc^4, p); + return; + } + emit_condbranch(as, PPCI_BC, cc, target); +} + +/* -- Operand fusion ------------------------------------------------------ */ + +/* Limit linear search to this distance. Avoids O(n^2) behavior. */ +#define CONFLICT_SEARCH_LIM 31 + +/* Check if there's no conflicting instruction between curins and ref. */ +static int noconflict(ASMState *as, IRRef ref, IROp conflict) +{ + IRIns *ir = as->ir; + IRRef i = as->curins; + if (i > ref + CONFLICT_SEARCH_LIM) + return 0; /* Give up, ref is too far away. */ + while (--i > ref) + if (ir[i].o == conflict) + return 0; /* Conflict found. */ + return 1; /* Ok, no conflict. */ +} + +/* Fuse the array base of colocated arrays. */ +static int32_t asm_fuseabase(ASMState *as, IRRef ref) +{ + IRIns *ir = IR(ref); + if (ir->o == IR_TNEW && ir->op1 <= LJ_MAX_COLOSIZE && + !neverfuse(as) && noconflict(as, ref, IR_NEWREF)) + return (int32_t)sizeof(GCtab); + return 0; +} + +/* Indicates load/store indexed is ok. */ +#define AHUREF_LSX ((int32_t)0x80000000) + +/* Fuse array/hash/upvalue reference into register+offset operand. */ +static Reg asm_fuseahuref(ASMState *as, IRRef ref, int32_t *ofsp, RegSet allow) +{ + IRIns *ir = IR(ref); + if (ra_noreg(ir->r)) { + if (ir->o == IR_AREF) { + if (mayfuse(as, ref)) { + if (irref_isk(ir->op2)) { + IRRef tab = IR(ir->op1)->op1; + int32_t ofs = asm_fuseabase(as, tab); + IRRef refa = ofs ? tab : ir->op1; + ofs += 8*IR(ir->op2)->i; + if (checki16(ofs)) { + *ofsp = ofs; + return ra_alloc1(as, refa, allow); + } + } + if (*ofsp == AHUREF_LSX) { + Reg base = ra_alloc1(as, ir->op1, allow); + Reg idx = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, base)); + return base | (idx << 8); + } + } + } else if (ir->o == IR_HREFK) { + if (mayfuse(as, ref)) { + int32_t ofs = (int32_t)(IR(ir->op2)->op2 * sizeof(Node)); + if (checki16(ofs)) { + *ofsp = ofs; + return ra_alloc1(as, ir->op1, allow); + } + } + } else if (ir->o == IR_UREFC) { + if (irref_isk(ir->op1)) { + GCfunc *fn = ir_kfunc(IR(ir->op1)); + int32_t ofs = i32ptr(&gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.tv); + int32_t jgl = (intptr_t)J2G(as->J); + if ((uint32_t)(ofs-jgl) < 65536) { + *ofsp = ofs-jgl-32768; + return RID_JGL; + } else { + *ofsp = (int16_t)ofs; + return ra_allock(as, ofs-(int16_t)ofs, allow); + } + } + } + } + *ofsp = 0; + return ra_alloc1(as, ref, allow); +} + +/* Fuse XLOAD/XSTORE reference into load/store operand. */ +static void asm_fusexref(ASMState *as, PPCIns pi, Reg rt, IRRef ref, + RegSet allow, int32_t ofs) +{ + IRIns *ir = IR(ref); + Reg base; + if (ra_noreg(ir->r) && canfuse(as, ir)) { + if (ir->o == IR_ADD) { + int32_t ofs2; + if (irref_isk(ir->op2) && (ofs2 = ofs + IR(ir->op2)->i, checki16(ofs2))) { + ofs = ofs2; + ref = ir->op1; + } else if (ofs == 0) { + Reg right, left = ra_alloc2(as, ir, allow); + right = (left >> 8); left &= 255; + emit_fab(as, PPCI_LWZX | ((pi >> 20) & 0x780), rt, left, right); + return; + } + } else if (ir->o == IR_STRREF) { + lua_assert(ofs == 0); + ofs = (int32_t)sizeof(GCstr); + if (irref_isk(ir->op2)) { + ofs += IR(ir->op2)->i; + ref = ir->op1; + } else if (irref_isk(ir->op1)) { + ofs += IR(ir->op1)->i; + ref = ir->op2; + } else { + /* NYI: Fuse ADD with constant. */ + Reg tmp, right, left = ra_alloc2(as, ir, allow); + right = (left >> 8); left &= 255; + tmp = ra_scratch(as, rset_exclude(rset_exclude(allow, left), right)); + emit_fai(as, pi, rt, tmp, ofs); + emit_tab(as, PPCI_ADD, tmp, left, right); + return; + } + if (!checki16(ofs)) { + Reg left = ra_alloc1(as, ref, allow); + Reg right = ra_allock(as, ofs, rset_exclude(allow, left)); + emit_fab(as, PPCI_LWZX | ((pi >> 20) & 0x780), rt, left, right); + return; + } + } + } + base = ra_alloc1(as, ref, allow); + emit_fai(as, pi, rt, base, ofs); +} + +/* Fuse XLOAD/XSTORE reference into indexed-only load/store operand. */ +static void asm_fusexrefx(ASMState *as, PPCIns pi, Reg rt, IRRef ref, + RegSet allow) +{ + IRIns *ira = IR(ref); + Reg right, left; + if (canfuse(as, ira) && ira->o == IR_ADD && ra_noreg(ira->r)) { + left = ra_alloc2(as, ira, allow); + right = (left >> 8); left &= 255; + } else { + right = ra_alloc1(as, ref, allow); + left = RID_R0; + } + emit_tab(as, pi, rt, left, right); +} + +/* Fuse to multiply-add/sub instruction. */ +static int asm_fusemadd(ASMState *as, IRIns *ir, PPCIns pi, PPCIns pir) +{ + IRRef lref = ir->op1, rref = ir->op2; + IRIns *irm; + if (lref != rref && + ((mayfuse(as, lref) && (irm = IR(lref), irm->o == IR_MUL) && + ra_noreg(irm->r)) || + (mayfuse(as, rref) && (irm = IR(rref), irm->o == IR_MUL) && + (rref = lref, pi = pir, ra_noreg(irm->r))))) { + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg add = ra_alloc1(as, rref, RSET_FPR); + Reg right, left = ra_alloc2(as, irm, rset_exclude(RSET_FPR, add)); + right = (left >> 8); left &= 255; + emit_facb(as, pi, dest, left, right, add); + return 1; + } + return 0; +} + +/* -- Calls --------------------------------------------------------------- */ + +/* Generate a call to a C function. */ +static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args) +{ + uint32_t n, nargs = CCI_NARGS(ci); + int32_t ofs = 8; + Reg gpr = REGARG_FIRSTGPR, fpr = REGARG_FIRSTFPR; + if ((void *)ci->func) + emit_call(as, (void *)ci->func); + for (n = 0; n < nargs; n++) { /* Setup args. */ + IRRef ref = args[n]; + if (ref) { + IRIns *ir = IR(ref); + if (irt_isfp(ir->t)) { + if (fpr <= REGARG_LASTFPR) { + lua_assert(rset_test(as->freeset, fpr)); /* Already evicted. */ + ra_leftov(as, fpr, ref); + fpr++; + } else { + Reg r = ra_alloc1(as, ref, RSET_FPR); + if (irt_isnum(ir->t)) ofs = (ofs + 4) & ~4; + emit_spstore(as, ir, r, ofs); + ofs += irt_isnum(ir->t) ? 8 : 4; + } + } else { + if (gpr <= REGARG_LASTGPR) { + lua_assert(rset_test(as->freeset, gpr)); /* Already evicted. */ + ra_leftov(as, gpr, ref); + gpr++; + } else { + Reg r = ra_alloc1(as, ref, RSET_GPR); + emit_spstore(as, ir, r, ofs); + ofs += 4; + } + } + } else { + if (gpr <= REGARG_LASTGPR) + gpr++; + else + ofs += 4; + } + checkmclim(as); + } + if ((ci->flags & CCI_VARARG)) /* Vararg calls need to know about FPR use. */ + emit_tab(as, fpr == REGARG_FIRSTFPR ? PPCI_CRXOR : PPCI_CREQV, 6, 6, 6); +} + +/* Setup result reg/sp for call. Evict scratch regs. */ +static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci) +{ + RegSet drop = RSET_SCRATCH; + int hiop = ((ir+1)->o == IR_HIOP); + if ((ci->flags & CCI_NOFPRCLOBBER)) + drop &= ~RSET_FPR; + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + if (hiop && ra_hasreg((ir+1)->r)) + rset_clear(drop, (ir+1)->r); /* Dest reg handled below. */ + ra_evictset(as, drop); /* Evictions must be performed first. */ + if (ra_used(ir)) { + lua_assert(!irt_ispri(ir->t)); + if (irt_isfp(ir->t)) { + if ((ci->flags & CCI_CASTU64)) { + /* Use spill slot or temp slots. */ + int32_t ofs = ir->s ? sps_scale(ir->s) : SPOFS_TMP; + Reg dest = ir->r; + if (ra_hasreg(dest)) { + ra_free(as, dest); + ra_modified(as, dest); + emit_fai(as, PPCI_LFD, dest, RID_SP, ofs); + } + emit_tai(as, PPCI_STW, RID_RETHI, RID_SP, ofs); + emit_tai(as, PPCI_STW, RID_RETLO, RID_SP, ofs+4); + } else { + ra_destreg(as, ir, RID_FPRET); + } + } else if (hiop) { + ra_destpair(as, ir); + } else { + ra_destreg(as, ir, RID_RET); + } + } +} + +static void asm_call(ASMState *as, IRIns *ir) +{ + IRRef args[CCI_NARGS_MAX]; + const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; + asm_collectargs(as, ir, ci, args); + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} + +static void asm_callx(ASMState *as, IRIns *ir) +{ + IRRef args[CCI_NARGS_MAX*2]; + CCallInfo ci; + IRRef func; + IRIns *irf; + ci.flags = asm_callx_flags(as, ir); + asm_collectargs(as, ir, &ci, args); + asm_setupresult(as, ir, &ci); + func = ir->op2; irf = IR(func); + if (irf->o == IR_CARG) { func = irf->op1; irf = IR(func); } + if (irref_isk(func)) { /* Call to constant address. */ + ci.func = (ASMFunction)(void *)(irf->i); + } else { /* Need a non-argument register for indirect calls. */ + RegSet allow = RSET_GPR & ~RSET_RANGE(RID_R0, REGARG_LASTGPR+1); + Reg freg = ra_alloc1(as, func, allow); + *--as->mcp = PPCI_BCTRL; + *--as->mcp = PPCI_MTCTR | PPCF_T(freg); + ci.func = (ASMFunction)(void *)0; + } + asm_gencall(as, &ci, args); +} + +static void asm_callid(ASMState *as, IRIns *ir, IRCallID id) +{ + const CCallInfo *ci = &lj_ir_callinfo[id]; + IRRef args[2]; + args[0] = ir->op1; + args[1] = ir->op2; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} + +/* -- Returns ------------------------------------------------------------- */ + +/* Return to lower frame. Guard that it goes to the right spot. */ +static void asm_retf(ASMState *as, IRIns *ir) +{ + Reg base = ra_alloc1(as, REF_BASE, RSET_GPR); + void *pc = ir_kptr(IR(ir->op2)); + int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); + as->topslot -= (BCReg)delta; + if ((int32_t)as->topslot < 0) as->topslot = 0; + irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */ + emit_setgl(as, base, jit_base); + emit_addptr(as, base, -8*delta); + asm_guardcc(as, CC_NE); + emit_ab(as, PPCI_CMPW, RID_TMP, + ra_allock(as, i32ptr(pc), rset_exclude(RSET_GPR, base))); + emit_tai(as, PPCI_LWZ, RID_TMP, base, -8); +} + +/* -- Type conversions ---------------------------------------------------- */ + +static void asm_tointg(ASMState *as, IRIns *ir, Reg left) +{ + RegSet allow = RSET_FPR; + Reg tmp = ra_scratch(as, rset_clear(allow, left)); + Reg fbias = ra_scratch(as, rset_clear(allow, tmp)); + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg hibias = ra_allock(as, 0x43300000, rset_exclude(RSET_GPR, dest)); + asm_guardcc(as, CC_NE); + emit_fab(as, PPCI_FCMPU, 0, tmp, left); + emit_fab(as, PPCI_FSUB, tmp, tmp, fbias); + emit_fai(as, PPCI_LFD, tmp, RID_SP, SPOFS_TMP); + emit_tai(as, PPCI_STW, RID_TMP, RID_SP, SPOFS_TMPLO); + emit_tai(as, PPCI_STW, hibias, RID_SP, SPOFS_TMPHI); + emit_asi(as, PPCI_XORIS, RID_TMP, dest, 0x8000); + emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO); + emit_lsptr(as, PPCI_LFS, (fbias & 31), + (void *)lj_ir_k64_find(as->J, U64x(59800004,59800000)), + RSET_GPR); + emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); + emit_fb(as, PPCI_FCTIWZ, tmp, left); +} + +static void asm_tobit(ASMState *as, IRIns *ir) +{ + RegSet allow = RSET_FPR; + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, ir->op1, allow); + Reg right = ra_alloc1(as, ir->op2, rset_clear(allow, left)); + Reg tmp = ra_scratch(as, rset_clear(allow, right)); + emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO); + emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); + emit_fab(as, PPCI_FADD, tmp, left, right); +} + +static void asm_conv(ASMState *as, IRIns *ir) +{ + IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); + int stfp = (st == IRT_NUM || st == IRT_FLOAT); + IRRef lref = ir->op1; + lua_assert(irt_type(ir->t) != st); + lua_assert(!(irt_isint64(ir->t) || + (st == IRT_I64 || st == IRT_U64))); /* Handled by SPLIT. */ + if (irt_isfp(ir->t)) { + Reg dest = ra_dest(as, ir, RSET_FPR); + if (stfp) { /* FP to FP conversion. */ + if (st == IRT_NUM) /* double -> float conversion. */ + emit_fb(as, PPCI_FRSP, dest, ra_alloc1(as, lref, RSET_FPR)); + else /* float -> double conversion is a no-op on PPC. */ + ra_leftov(as, dest, lref); /* Do nothing, but may need to move regs. */ + } else { /* Integer to FP conversion. */ + /* IRT_INT: Flip hibit, bias with 2^52, subtract 2^52+2^31. */ + /* IRT_U32: Bias with 2^52, subtract 2^52. */ + RegSet allow = RSET_GPR; + Reg left = ra_alloc1(as, lref, allow); + Reg hibias = ra_allock(as, 0x43300000, rset_clear(allow, left)); + Reg fbias = ra_scratch(as, rset_exclude(RSET_FPR, dest)); + const float *kbias; + if (irt_isfloat(ir->t)) emit_fb(as, PPCI_FRSP, dest, dest); + emit_fab(as, PPCI_FSUB, dest, dest, fbias); + emit_fai(as, PPCI_LFD, dest, RID_SP, SPOFS_TMP); + kbias = (const float *)lj_ir_k64_find(as->J, U64x(59800004,59800000)); + if (st == IRT_U32) kbias++; + emit_lsptr(as, PPCI_LFS, (fbias & 31), (void *)kbias, + rset_clear(allow, hibias)); + emit_tai(as, PPCI_STW, st == IRT_U32 ? left : RID_TMP, + RID_SP, SPOFS_TMPLO); + emit_tai(as, PPCI_STW, hibias, RID_SP, SPOFS_TMPHI); + if (st != IRT_U32) emit_asi(as, PPCI_XORIS, RID_TMP, left, 0x8000); + } + } else if (stfp) { /* FP to integer conversion. */ + if (irt_isguard(ir->t)) { + /* Checked conversions are only supported from number to int. */ + lua_assert(irt_isint(ir->t) && st == IRT_NUM); + asm_tointg(as, ir, ra_alloc1(as, lref, RSET_FPR)); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, lref, RSET_FPR); + Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); + if (irt_isu32(ir->t)) { + /* Convert both x and x-2^31 to int and merge results. */ + Reg tmpi = ra_scratch(as, rset_exclude(RSET_GPR, dest)); + emit_asb(as, PPCI_OR, dest, dest, tmpi); /* Select with mask idiom. */ + emit_asb(as, PPCI_AND, tmpi, tmpi, RID_TMP); + emit_asb(as, PPCI_ANDC, dest, dest, RID_TMP); + emit_tai(as, PPCI_LWZ, tmpi, RID_SP, SPOFS_TMPLO); /* tmp = (int)(x) */ + emit_tai(as, PPCI_ADDIS, dest, dest, 0x8000); /* dest += 2^31 */ + emit_asb(as, PPCI_SRAWI, RID_TMP, dest, 31); /* mask = -(dest < 0) */ + emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); + emit_tai(as, PPCI_LWZ, dest, + RID_SP, SPOFS_TMPLO); /* dest = (int)(x-2^31) */ + emit_fb(as, PPCI_FCTIWZ, tmp, left); + emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); + emit_fb(as, PPCI_FCTIWZ, tmp, tmp); + emit_fab(as, PPCI_FSUB, tmp, left, tmp); + emit_lsptr(as, PPCI_LFS, (tmp & 31), + (void *)lj_ir_k64_find(as->J, U64x(4f000000,00000000)), + RSET_GPR); + } else { + emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO); + emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); + emit_fb(as, PPCI_FCTIWZ, tmp, left); + } + } + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + if (st >= IRT_I8 && st <= IRT_U16) { /* Extend to 32 bit integer. */ + Reg left = ra_alloc1(as, ir->op1, RSET_GPR); + lua_assert(irt_isint(ir->t) || irt_isu32(ir->t)); + if ((ir->op2 & IRCONV_SEXT)) + emit_as(as, st == IRT_I8 ? PPCI_EXTSB : PPCI_EXTSH, dest, left); + else + emit_rot(as, PPCI_RLWINM, dest, left, 0, st == IRT_U8 ? 24 : 16, 31); + } else { /* 32/64 bit integer conversions. */ + /* Only need to handle 32/32 bit no-op (cast) on 32 bit archs. */ + ra_leftov(as, dest, lref); /* Do nothing, but may need to move regs. */ + } + } +} + +#if LJ_HASFFI +static void asm_conv64(ASMState *as, IRIns *ir) +{ + IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK); + IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH); + IRCallID id; + const CCallInfo *ci; + IRRef args[2]; + args[0] = ir->op1; + args[1] = (ir-1)->op1; + if (st == IRT_NUM || st == IRT_FLOAT) { + id = IRCALL_fp64_d2l + ((st == IRT_FLOAT) ? 2 : 0) + (dt - IRT_I64); + ir--; + } else { + id = IRCALL_fp64_l2d + ((dt == IRT_FLOAT) ? 2 : 0) + (st - IRT_I64); + } + ci = &lj_ir_callinfo[id]; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} +#endif + +static void asm_strto(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_strscan_num]; + IRRef args[2]; + int32_t ofs; + RegSet drop = RSET_SCRATCH; + if (ra_hasreg(ir->r)) rset_set(drop, ir->r); /* Spill dest reg (if any). */ + ra_evictset(as, drop); + asm_guardcc(as, CC_EQ); + emit_ai(as, PPCI_CMPWI, RID_RET, 0); /* Test return status. */ + args[0] = ir->op1; /* GCstr *str */ + args[1] = ASMREF_TMP1; /* TValue *n */ + asm_gencall(as, ci, args); + /* Store the result to the spill slot or temp slots. */ + ofs = ir->s ? sps_scale(ir->s) : SPOFS_TMP; + emit_tai(as, PPCI_ADDI, ra_releasetmp(as, ASMREF_TMP1), RID_SP, ofs); +} + +/* Get pointer to TValue. */ +static void asm_tvptr(ASMState *as, Reg dest, IRRef ref) +{ + IRIns *ir = IR(ref); + if (irt_isnum(ir->t)) { + if (irref_isk(ref)) /* Use the number constant itself as a TValue. */ + ra_allockreg(as, i32ptr(ir_knum(ir)), dest); + else /* Otherwise force a spill and use the spill slot. */ + emit_tai(as, PPCI_ADDI, dest, RID_SP, ra_spill(as, ir)); + } else { + /* Otherwise use g->tmptv to hold the TValue. */ + RegSet allow = rset_exclude(RSET_GPR, dest); + Reg type; + emit_tai(as, PPCI_ADDI, dest, RID_JGL, offsetof(global_State, tmptv)-32768); + if (!irt_ispri(ir->t)) { + Reg src = ra_alloc1(as, ref, allow); + emit_setgl(as, src, tmptv.gcr); + } + type = ra_allock(as, irt_toitype(ir->t), allow); + emit_setgl(as, type, tmptv.it); + } +} + +static void asm_tostr(ASMState *as, IRIns *ir) +{ + IRRef args[2]; + args[0] = ASMREF_L; + as->gcsteps++; + if (irt_isnum(IR(ir->op1)->t) || (ir+1)->o == IR_HIOP) { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromnum]; + args[1] = ASMREF_TMP1; /* const lua_Number * */ + asm_setupresult(as, ir, ci); /* GCstr * */ + asm_gencall(as, ci, args); + asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op1); + } else { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromint]; + args[1] = ir->op1; /* int32_t k */ + asm_setupresult(as, ir, ci); /* GCstr * */ + asm_gencall(as, ci, args); + } +} + +/* -- Memory references --------------------------------------------------- */ + +static void asm_aref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg idx, base; + if (irref_isk(ir->op2)) { + IRRef tab = IR(ir->op1)->op1; + int32_t ofs = asm_fuseabase(as, tab); + IRRef refa = ofs ? tab : ir->op1; + ofs += 8*IR(ir->op2)->i; + if (checki16(ofs)) { + base = ra_alloc1(as, refa, RSET_GPR); + emit_tai(as, PPCI_ADDI, dest, base, ofs); + return; + } + } + base = ra_alloc1(as, ir->op1, RSET_GPR); + idx = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, base)); + emit_tab(as, PPCI_ADD, dest, RID_TMP, base); + emit_slwi(as, RID_TMP, idx, 3); +} + +/* Inlined hash lookup. Specialized for key type and for const keys. +** The equivalent C code is: +** Node *n = hashkey(t, key); +** do { +** if (lj_obj_equal(&n->key, key)) return &n->val; +** } while ((n = nextnode(n))); +** return niltv(L); +*/ +static void asm_href(ASMState *as, IRIns *ir, IROp merge) +{ + RegSet allow = RSET_GPR; + int destused = ra_used(ir); + Reg dest = ra_dest(as, ir, allow); + Reg tab = ra_alloc1(as, ir->op1, rset_clear(allow, dest)); + Reg key = RID_NONE, tmp1 = RID_TMP, tmp2; + Reg tisnum = RID_NONE, tmpnum = RID_NONE; + IRRef refkey = ir->op2; + IRIns *irkey = IR(refkey); + IRType1 kt = irkey->t; + uint32_t khash; + MCLabel l_end, l_loop, l_next; + + rset_clear(allow, tab); + if (irt_isnum(kt)) { + key = ra_alloc1(as, refkey, RSET_FPR); + tmpnum = ra_scratch(as, rset_exclude(RSET_FPR, key)); + tisnum = ra_allock(as, (int32_t)LJ_TISNUM, allow); + rset_clear(allow, tisnum); + } else if (!irt_ispri(kt)) { + key = ra_alloc1(as, refkey, allow); + rset_clear(allow, key); + } + tmp2 = ra_scratch(as, allow); + rset_clear(allow, tmp2); + + /* Key not found in chain: jump to exit (if merged) or load niltv. */ + l_end = emit_label(as); + as->invmcp = NULL; + if (merge == IR_NE) + asm_guardcc(as, CC_EQ); + else if (destused) + emit_loada(as, dest, niltvg(J2G(as->J))); + + /* Follow hash chain until the end. */ + l_loop = --as->mcp; + emit_ai(as, PPCI_CMPWI, dest, 0); + emit_tai(as, PPCI_LWZ, dest, dest, (int32_t)offsetof(Node, next)); + l_next = emit_label(as); + + /* Type and value comparison. */ + if (merge == IR_EQ) + asm_guardcc(as, CC_EQ); + else + emit_condbranch(as, PPCI_BC|PPCF_Y, CC_EQ, l_end); + if (irt_isnum(kt)) { + emit_fab(as, PPCI_FCMPU, 0, tmpnum, key); + emit_condbranch(as, PPCI_BC, CC_GE, l_next); + emit_ab(as, PPCI_CMPLW, tmp1, tisnum); + emit_fai(as, PPCI_LFD, tmpnum, dest, (int32_t)offsetof(Node, key.n)); + } else { + if (!irt_ispri(kt)) { + emit_ab(as, PPCI_CMPW, tmp2, key); + emit_condbranch(as, PPCI_BC, CC_NE, l_next); + } + emit_ai(as, PPCI_CMPWI, tmp1, irt_toitype(irkey->t)); + if (!irt_ispri(kt)) + emit_tai(as, PPCI_LWZ, tmp2, dest, (int32_t)offsetof(Node, key.gcr)); + } + emit_tai(as, PPCI_LWZ, tmp1, dest, (int32_t)offsetof(Node, key.it)); + *l_loop = PPCI_BC | PPCF_Y | PPCF_CC(CC_NE) | + (((char *)as->mcp-(char *)l_loop) & 0xffffu); + + /* Load main position relative to tab->node into dest. */ + khash = irref_isk(refkey) ? ir_khash(irkey) : 1; + if (khash == 0) { + emit_tai(as, PPCI_LWZ, dest, tab, (int32_t)offsetof(GCtab, node)); + } else { + Reg tmphash = tmp1; + if (irref_isk(refkey)) + tmphash = ra_allock(as, khash, allow); + emit_tab(as, PPCI_ADD, dest, dest, tmp1); + emit_tai(as, PPCI_MULLI, tmp1, tmp1, sizeof(Node)); + emit_asb(as, PPCI_AND, tmp1, tmp2, tmphash); + emit_tai(as, PPCI_LWZ, dest, tab, (int32_t)offsetof(GCtab, node)); + emit_tai(as, PPCI_LWZ, tmp2, tab, (int32_t)offsetof(GCtab, hmask)); + if (irref_isk(refkey)) { + /* Nothing to do. */ + } else if (irt_isstr(kt)) { + emit_tai(as, PPCI_LWZ, tmp1, key, (int32_t)offsetof(GCstr, hash)); + } else { /* Must match with hash*() in lj_tab.c. */ + emit_tab(as, PPCI_SUBF, tmp1, tmp2, tmp1); + emit_rotlwi(as, tmp2, tmp2, HASH_ROT3); + emit_asb(as, PPCI_XOR, tmp1, tmp1, tmp2); + emit_rotlwi(as, tmp1, tmp1, (HASH_ROT2+HASH_ROT1)&31); + emit_tab(as, PPCI_SUBF, tmp2, dest, tmp2); + if (irt_isnum(kt)) { + int32_t ofs = ra_spill(as, irkey); + emit_asb(as, PPCI_XOR, tmp2, tmp2, tmp1); + emit_rotlwi(as, dest, tmp1, HASH_ROT1); + emit_tab(as, PPCI_ADD, tmp1, tmp1, tmp1); + emit_tai(as, PPCI_LWZ, tmp2, RID_SP, ofs+4); + emit_tai(as, PPCI_LWZ, tmp1, RID_SP, ofs); + } else { + emit_asb(as, PPCI_XOR, tmp2, key, tmp1); + emit_rotlwi(as, dest, tmp1, HASH_ROT1); + emit_tai(as, PPCI_ADDI, tmp1, tmp2, HASH_BIAS); + emit_tai(as, PPCI_ADDIS, tmp2, key, (HASH_BIAS + 32768)>>16); + } + } + } +} + +static void asm_hrefk(ASMState *as, IRIns *ir) +{ + IRIns *kslot = IR(ir->op2); + IRIns *irkey = IR(kslot->op1); + int32_t ofs = (int32_t)(kslot->op2 * sizeof(Node)); + int32_t kofs = ofs + (int32_t)offsetof(Node, key); + Reg dest = (ra_used(ir)||ofs > 32736) ? ra_dest(as, ir, RSET_GPR) : RID_NONE; + Reg node = ra_alloc1(as, ir->op1, RSET_GPR); + Reg key = RID_NONE, type = RID_TMP, idx = node; + RegSet allow = rset_exclude(RSET_GPR, node); + lua_assert(ofs % sizeof(Node) == 0); + if (ofs > 32736) { + idx = dest; + rset_clear(allow, dest); + kofs = (int32_t)offsetof(Node, key); + } else if (ra_hasreg(dest)) { + emit_tai(as, PPCI_ADDI, dest, node, ofs); + } + asm_guardcc(as, CC_NE); + if (!irt_ispri(irkey->t)) { + key = ra_scratch(as, allow); + rset_clear(allow, key); + } + rset_clear(allow, type); + if (irt_isnum(irkey->t)) { + emit_cmpi(as, key, (int32_t)ir_knum(irkey)->u32.lo); + asm_guardcc(as, CC_NE); + emit_cmpi(as, type, (int32_t)ir_knum(irkey)->u32.hi); + } else { + if (ra_hasreg(key)) { + emit_cmpi(as, key, irkey->i); /* May use RID_TMP, i.e. type. */ + asm_guardcc(as, CC_NE); + } + emit_ai(as, PPCI_CMPWI, type, irt_toitype(irkey->t)); + } + if (ra_hasreg(key)) emit_tai(as, PPCI_LWZ, key, idx, kofs+4); + emit_tai(as, PPCI_LWZ, type, idx, kofs); + if (ofs > 32736) { + emit_tai(as, PPCI_ADDIS, dest, dest, (ofs + 32768) >> 16); + emit_tai(as, PPCI_ADDI, dest, node, ofs); + } +} + +static void asm_newref(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_newkey]; + IRRef args[3]; + if (ir->r == RID_SINK) + return; + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ir->op1; /* GCtab *t */ + args[2] = ASMREF_TMP1; /* cTValue *key */ + asm_setupresult(as, ir, ci); /* TValue * */ + asm_gencall(as, ci, args); + asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op2); +} + +static void asm_uref(ASMState *as, IRIns *ir) +{ + /* NYI: Check that UREFO is still open and not aliasing a slot. */ + Reg dest = ra_dest(as, ir, RSET_GPR); + if (irref_isk(ir->op1)) { + GCfunc *fn = ir_kfunc(IR(ir->op1)); + MRef *v = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.v; + emit_lsptr(as, PPCI_LWZ, dest, v, RSET_GPR); + } else { + Reg uv = ra_scratch(as, RSET_GPR); + Reg func = ra_alloc1(as, ir->op1, RSET_GPR); + if (ir->o == IR_UREFC) { + asm_guardcc(as, CC_NE); + emit_ai(as, PPCI_CMPWI, RID_TMP, 1); + emit_tai(as, PPCI_ADDI, dest, uv, (int32_t)offsetof(GCupval, tv)); + emit_tai(as, PPCI_LBZ, RID_TMP, uv, (int32_t)offsetof(GCupval, closed)); + } else { + emit_tai(as, PPCI_LWZ, dest, uv, (int32_t)offsetof(GCupval, v)); + } + emit_tai(as, PPCI_LWZ, uv, func, + (int32_t)offsetof(GCfuncL, uvptr) + 4*(int32_t)(ir->op2 >> 8)); + } +} + +static void asm_fref(ASMState *as, IRIns *ir) +{ + UNUSED(as); UNUSED(ir); + lua_assert(!ra_used(ir)); +} + +static void asm_strref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + IRRef ref = ir->op2, refk = ir->op1; + int32_t ofs = (int32_t)sizeof(GCstr); + Reg r; + if (irref_isk(ref)) { + IRRef tmp = refk; refk = ref; ref = tmp; + } else if (!irref_isk(refk)) { + Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); + IRIns *irr = IR(ir->op2); + if (ra_hasreg(irr->r)) { + ra_noweak(as, irr->r); + right = irr->r; + } else if (mayfuse(as, irr->op2) && + irr->o == IR_ADD && irref_isk(irr->op2) && + checki16(ofs + IR(irr->op2)->i)) { + ofs += IR(irr->op2)->i; + right = ra_alloc1(as, irr->op1, rset_exclude(RSET_GPR, left)); + } else { + right = ra_allocref(as, ir->op2, rset_exclude(RSET_GPR, left)); + } + emit_tai(as, PPCI_ADDI, dest, dest, ofs); + emit_tab(as, PPCI_ADD, dest, left, right); + return; + } + r = ra_alloc1(as, ref, RSET_GPR); + ofs += IR(refk)->i; + if (checki16(ofs)) + emit_tai(as, PPCI_ADDI, dest, r, ofs); + else + emit_tab(as, PPCI_ADD, dest, r, + ra_allock(as, ofs, rset_exclude(RSET_GPR, r))); +} + +/* -- Loads and stores ---------------------------------------------------- */ + +static PPCIns asm_fxloadins(IRIns *ir) +{ + switch (irt_type(ir->t)) { + case IRT_I8: return PPCI_LBZ; /* Needs sign-extension. */ + case IRT_U8: return PPCI_LBZ; + case IRT_I16: return PPCI_LHA; + case IRT_U16: return PPCI_LHZ; + case IRT_NUM: return PPCI_LFD; + case IRT_FLOAT: return PPCI_LFS; + default: return PPCI_LWZ; + } +} + +static PPCIns asm_fxstoreins(IRIns *ir) +{ + switch (irt_type(ir->t)) { + case IRT_I8: case IRT_U8: return PPCI_STB; + case IRT_I16: case IRT_U16: return PPCI_STH; + case IRT_NUM: return PPCI_STFD; + case IRT_FLOAT: return PPCI_STFS; + default: return PPCI_STW; + } +} + +static void asm_fload(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg idx = ra_alloc1(as, ir->op1, RSET_GPR); + PPCIns pi = asm_fxloadins(ir); + int32_t ofs; + if (ir->op2 == IRFL_TAB_ARRAY) { + ofs = asm_fuseabase(as, ir->op1); + if (ofs) { /* Turn the t->array load into an add for colocated arrays. */ + emit_tai(as, PPCI_ADDI, dest, idx, ofs); + return; + } + } + ofs = field_ofs[ir->op2]; + lua_assert(!irt_isi8(ir->t)); + emit_tai(as, pi, dest, idx, ofs); +} + +static void asm_fstore(ASMState *as, IRIns *ir) +{ + if (ir->r != RID_SINK) { + Reg src = ra_alloc1(as, ir->op2, RSET_GPR); + IRIns *irf = IR(ir->op1); + Reg idx = ra_alloc1(as, irf->op1, rset_exclude(RSET_GPR, src)); + int32_t ofs = field_ofs[irf->op2]; + PPCIns pi = asm_fxstoreins(ir); + emit_tai(as, pi, src, idx, ofs); + } +} + +static void asm_xload(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); + lua_assert(!(ir->op2 & IRXLOAD_UNALIGNED)); + if (irt_isi8(ir->t)) + emit_as(as, PPCI_EXTSB, dest, dest); + asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR, 0); +} + +static void asm_xstore(ASMState *as, IRIns *ir, int32_t ofs) +{ + IRIns *irb; + if (ir->r == RID_SINK) + return; + if (ofs == 0 && mayfuse(as, ir->op2) && (irb = IR(ir->op2))->o == IR_BSWAP && + ra_noreg(irb->r) && (irt_isint(ir->t) || irt_isu32(ir->t))) { + /* Fuse BSWAP with XSTORE to stwbrx. */ + Reg src = ra_alloc1(as, irb->op1, RSET_GPR); + asm_fusexrefx(as, PPCI_STWBRX, src, ir->op1, rset_exclude(RSET_GPR, src)); + } else { + Reg src = ra_alloc1(as, ir->op2, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); + asm_fusexref(as, asm_fxstoreins(ir), src, ir->op1, + rset_exclude(RSET_GPR, src), ofs); + } +} + +static void asm_ahuvload(ASMState *as, IRIns *ir) +{ + IRType1 t = ir->t; + Reg dest = RID_NONE, type = RID_TMP, tmp = RID_TMP, idx; + RegSet allow = RSET_GPR; + int32_t ofs = AHUREF_LSX; + if (ra_used(ir)) { + lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); + if (!irt_isnum(t)) ofs = 0; + dest = ra_dest(as, ir, irt_isnum(t) ? RSET_FPR : RSET_GPR); + rset_clear(allow, dest); + } + idx = asm_fuseahuref(as, ir->op1, &ofs, allow); + if (irt_isnum(t)) { + Reg tisnum = ra_allock(as, (int32_t)LJ_TISNUM, rset_exclude(allow, idx)); + asm_guardcc(as, CC_GE); + emit_ab(as, PPCI_CMPLW, type, tisnum); + if (ra_hasreg(dest)) { + if (ofs == AHUREF_LSX) { + tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, + (idx&255)), (idx>>8))); + emit_fab(as, PPCI_LFDX, dest, (idx&255), tmp); + } else { + emit_fai(as, PPCI_LFD, dest, idx, ofs); + } + } + } else { + asm_guardcc(as, CC_NE); + emit_ai(as, PPCI_CMPWI, type, irt_toitype(t)); + if (ra_hasreg(dest)) emit_tai(as, PPCI_LWZ, dest, idx, ofs+4); + } + if (ofs == AHUREF_LSX) { + emit_tab(as, PPCI_LWZX, type, (idx&255), tmp); + emit_slwi(as, tmp, (idx>>8), 3); + } else { + emit_tai(as, PPCI_LWZ, type, idx, ofs); + } +} + +static void asm_ahustore(ASMState *as, IRIns *ir) +{ + RegSet allow = RSET_GPR; + Reg idx, src = RID_NONE, type = RID_NONE; + int32_t ofs = AHUREF_LSX; + if (ir->r == RID_SINK) + return; + if (irt_isnum(ir->t)) { + src = ra_alloc1(as, ir->op2, RSET_FPR); + } else { + if (!irt_ispri(ir->t)) { + src = ra_alloc1(as, ir->op2, allow); + rset_clear(allow, src); + ofs = 0; + } + type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); + rset_clear(allow, type); + } + idx = asm_fuseahuref(as, ir->op1, &ofs, allow); + if (irt_isnum(ir->t)) { + if (ofs == AHUREF_LSX) { + emit_fab(as, PPCI_STFDX, src, (idx&255), RID_TMP); + emit_slwi(as, RID_TMP, (idx>>8), 3); + } else { + emit_fai(as, PPCI_STFD, src, idx, ofs); + } + } else { + if (ra_hasreg(src)) + emit_tai(as, PPCI_STW, src, idx, ofs+4); + if (ofs == AHUREF_LSX) { + emit_tab(as, PPCI_STWX, type, (idx&255), RID_TMP); + emit_slwi(as, RID_TMP, (idx>>8), 3); + } else { + emit_tai(as, PPCI_STW, type, idx, ofs); + } + } +} + +static void asm_sload(ASMState *as, IRIns *ir) +{ + int32_t ofs = 8*((int32_t)ir->op1-1) + ((ir->op2 & IRSLOAD_FRAME) ? 0 : 4); + IRType1 t = ir->t; + Reg dest = RID_NONE, type = RID_NONE, base; + RegSet allow = RSET_GPR; + lua_assert(!(ir->op2 & IRSLOAD_PARENT)); /* Handled by asm_head_side(). */ + lua_assert(irt_isguard(t) || !(ir->op2 & IRSLOAD_TYPECHECK)); + lua_assert(LJ_DUALNUM || + !irt_isint(t) || (ir->op2 & (IRSLOAD_CONVERT|IRSLOAD_FRAME))); + if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(t) && irt_isint(t)) { + dest = ra_scratch(as, RSET_FPR); + asm_tointg(as, ir, dest); + t.irt = IRT_NUM; /* Continue with a regular number type check. */ + } else if (ra_used(ir)) { + lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); + dest = ra_dest(as, ir, irt_isnum(t) ? RSET_FPR : RSET_GPR); + rset_clear(allow, dest); + base = ra_alloc1(as, REF_BASE, allow); + rset_clear(allow, base); + if ((ir->op2 & IRSLOAD_CONVERT)) { + if (irt_isint(t)) { + emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO); + dest = ra_scratch(as, RSET_FPR); + emit_fai(as, PPCI_STFD, dest, RID_SP, SPOFS_TMP); + emit_fb(as, PPCI_FCTIWZ, dest, dest); + t.irt = IRT_NUM; /* Check for original type. */ + } else { + Reg tmp = ra_scratch(as, allow); + Reg hibias = ra_allock(as, 0x43300000, rset_clear(allow, tmp)); + Reg fbias = ra_scratch(as, rset_exclude(RSET_FPR, dest)); + emit_fab(as, PPCI_FSUB, dest, dest, fbias); + emit_fai(as, PPCI_LFD, dest, RID_SP, SPOFS_TMP); + emit_lsptr(as, PPCI_LFS, (fbias & 31), + (void *)lj_ir_k64_find(as->J, U64x(59800004,59800000)), + rset_clear(allow, hibias)); + emit_tai(as, PPCI_STW, tmp, RID_SP, SPOFS_TMPLO); + emit_tai(as, PPCI_STW, hibias, RID_SP, SPOFS_TMPHI); + emit_asi(as, PPCI_XORIS, tmp, tmp, 0x8000); + dest = tmp; + t.irt = IRT_INT; /* Check for original type. */ + } + } + goto dotypecheck; + } + base = ra_alloc1(as, REF_BASE, allow); + rset_clear(allow, base); +dotypecheck: + if (irt_isnum(t)) { + if ((ir->op2 & IRSLOAD_TYPECHECK)) { + Reg tisnum = ra_allock(as, (int32_t)LJ_TISNUM, allow); + asm_guardcc(as, CC_GE); + emit_ab(as, PPCI_CMPLW, RID_TMP, tisnum); + type = RID_TMP; + } + if (ra_hasreg(dest)) emit_fai(as, PPCI_LFD, dest, base, ofs-4); + } else { + if ((ir->op2 & IRSLOAD_TYPECHECK)) { + asm_guardcc(as, CC_NE); + emit_ai(as, PPCI_CMPWI, RID_TMP, irt_toitype(t)); + type = RID_TMP; + } + if (ra_hasreg(dest)) emit_tai(as, PPCI_LWZ, dest, base, ofs); + } + if (ra_hasreg(type)) emit_tai(as, PPCI_LWZ, type, base, ofs-4); +} + +/* -- Allocations --------------------------------------------------------- */ + +#if LJ_HASFFI +static void asm_cnew(ASMState *as, IRIns *ir) +{ + CTState *cts = ctype_ctsG(J2G(as->J)); + CTypeID ctypeid = (CTypeID)IR(ir->op1)->i; + CTSize sz = (ir->o == IR_CNEWI || ir->op2 == REF_NIL) ? + lj_ctype_size(cts, ctypeid) : (CTSize)IR(ir->op2)->i; + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco]; + IRRef args[2]; + RegSet allow = (RSET_GPR & ~RSET_SCRATCH); + RegSet drop = RSET_SCRATCH; + lua_assert(sz != CTSIZE_INVALID); + + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ASMREF_TMP1; /* MSize size */ + as->gcsteps++; + + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + ra_evictset(as, drop); + if (ra_used(ir)) + ra_destreg(as, ir, RID_RET); /* GCcdata * */ + + /* Initialize immutable cdata object. */ + if (ir->o == IR_CNEWI) { + int32_t ofs = sizeof(GCcdata); + lua_assert(sz == 4 || sz == 8); + if (sz == 8) { + ofs += 4; + lua_assert((ir+1)->o == IR_HIOP); + } + for (;;) { + Reg r = ra_alloc1(as, ir->op2, allow); + emit_tai(as, PPCI_STW, r, RID_RET, ofs); + rset_clear(allow, r); + if (ofs == sizeof(GCcdata)) break; + ofs -= 4; ir++; + } + } + /* Initialize gct and ctypeid. lj_mem_newgco() already sets marked. */ + emit_tai(as, PPCI_STB, RID_RET+1, RID_RET, offsetof(GCcdata, gct)); + emit_tai(as, PPCI_STH, RID_TMP, RID_RET, offsetof(GCcdata, ctypeid)); + emit_ti(as, PPCI_LI, RID_RET+1, ~LJ_TCDATA); + emit_ti(as, PPCI_LI, RID_TMP, ctypeid); /* Lower 16 bit used. Sign-ext ok. */ + asm_gencall(as, ci, args); + ra_allockreg(as, (int32_t)(sz+sizeof(GCcdata)), + ra_releasetmp(as, ASMREF_TMP1)); +} +#else +#define asm_cnew(as, ir) ((void)0) +#endif + +/* -- Write barriers ------------------------------------------------------ */ + +static void asm_tbar(ASMState *as, IRIns *ir) +{ + Reg tab = ra_alloc1(as, ir->op1, RSET_GPR); + Reg mark = ra_scratch(as, rset_exclude(RSET_GPR, tab)); + Reg link = RID_TMP; + MCLabel l_end = emit_label(as); + emit_tai(as, PPCI_STW, link, tab, (int32_t)offsetof(GCtab, gclist)); + emit_tai(as, PPCI_STB, mark, tab, (int32_t)offsetof(GCtab, marked)); + emit_setgl(as, tab, gc.grayagain); + lua_assert(LJ_GC_BLACK == 0x04); + emit_rot(as, PPCI_RLWINM, mark, mark, 0, 30, 28); /* Clear black bit. */ + emit_getgl(as, link, gc.grayagain); + emit_condbranch(as, PPCI_BC|PPCF_Y, CC_EQ, l_end); + emit_asi(as, PPCI_ANDIDOT, RID_TMP, mark, LJ_GC_BLACK); + emit_tai(as, PPCI_LBZ, mark, tab, (int32_t)offsetof(GCtab, marked)); +} + +static void asm_obar(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_barrieruv]; + IRRef args[2]; + MCLabel l_end; + Reg obj, val, tmp; + /* No need for other object barriers (yet). */ + lua_assert(IR(ir->op1)->o == IR_UREFC); + ra_evictset(as, RSET_SCRATCH); + l_end = emit_label(as); + args[0] = ASMREF_TMP1; /* global_State *g */ + args[1] = ir->op1; /* TValue *tv */ + asm_gencall(as, ci, args); + emit_tai(as, PPCI_ADDI, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768); + obj = IR(ir->op1)->r; + tmp = ra_scratch(as, rset_exclude(RSET_GPR, obj)); + emit_condbranch(as, PPCI_BC|PPCF_Y, CC_EQ, l_end); + emit_asi(as, PPCI_ANDIDOT, tmp, tmp, LJ_GC_BLACK); + emit_condbranch(as, PPCI_BC, CC_EQ, l_end); + emit_asi(as, PPCI_ANDIDOT, RID_TMP, RID_TMP, LJ_GC_WHITES); + val = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, obj)); + emit_tai(as, PPCI_LBZ, tmp, obj, + (int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)); + emit_tai(as, PPCI_LBZ, RID_TMP, val, (int32_t)offsetof(GChead, marked)); +} + +/* -- Arithmetic and logic operations ------------------------------------- */ + +static void asm_fparith(ASMState *as, IRIns *ir, PPCIns pi) +{ + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg right, left = ra_alloc2(as, ir, RSET_FPR); + right = (left >> 8); left &= 255; + if (pi == PPCI_FMUL) + emit_fac(as, pi, dest, left, right); + else + emit_fab(as, pi, dest, left, right); +} + +static void asm_fpunary(ASMState *as, IRIns *ir, PPCIns pi) +{ + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg left = ra_hintalloc(as, ir->op1, dest, RSET_FPR); + emit_fb(as, pi, dest, left); +} + +static int asm_fpjoin_pow(ASMState *as, IRIns *ir) +{ + IRIns *irp = IR(ir->op1); + if (irp == ir-1 && irp->o == IR_MUL && !ra_used(irp)) { + IRIns *irpp = IR(irp->op1); + if (irpp == ir-2 && irpp->o == IR_FPMATH && + irpp->op2 == IRFPM_LOG2 && !ra_used(irpp)) { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_pow]; + IRRef args[2]; + args[0] = irpp->op1; + args[1] = irp->op2; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); + return 1; + } + } + return 0; +} + +static void asm_add(ASMState *as, IRIns *ir) +{ + if (irt_isnum(ir->t)) { + if (!asm_fusemadd(as, ir, PPCI_FMADD, PPCI_FMADD)) + asm_fparith(as, ir, PPCI_FADD); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + PPCIns pi; + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (checki16(k)) { + pi = PPCI_ADDI; + /* May fail due to spills/restores above, but simplifies the logic. */ + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + pi = PPCI_ADDICDOT; + } + emit_tai(as, pi, dest, left, k); + return; + } else if ((k & 0xffff) == 0) { + emit_tai(as, PPCI_ADDIS, dest, left, (k >> 16)); + return; + } else if (!as->sectref) { + emit_tai(as, PPCI_ADDIS, dest, dest, (k + 32768) >> 16); + emit_tai(as, PPCI_ADDI, dest, left, k); + return; + } + } + pi = PPCI_ADD; + /* May fail due to spills/restores above, but simplifies the logic. */ + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + pi |= PPCF_DOT; + } + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_tab(as, pi, dest, left, right); + } +} + +static void asm_sub(ASMState *as, IRIns *ir) +{ + if (irt_isnum(ir->t)) { + if (!asm_fusemadd(as, ir, PPCI_FMSUB, PPCI_FNMSUB)) + asm_fparith(as, ir, PPCI_FSUB); + } else { + PPCIns pi = PPCI_SUBF; + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left, right; + if (irref_isk(ir->op1)) { + int32_t k = IR(ir->op1)->i; + if (checki16(k)) { + right = ra_alloc1(as, ir->op2, RSET_GPR); + emit_tai(as, PPCI_SUBFIC, dest, right, k); + return; + } + } + /* May fail due to spills/restores above, but simplifies the logic. */ + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + pi |= PPCF_DOT; + } + left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_tab(as, pi, dest, right, left); /* Subtract right _from_ left. */ + } +} + +static void asm_mul(ASMState *as, IRIns *ir) +{ + if (irt_isnum(ir->t)) { + asm_fparith(as, ir, PPCI_FMUL); + } else { + PPCIns pi = PPCI_MULLW; + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (checki16(k)) { + emit_tai(as, PPCI_MULLI, dest, left, k); + return; + } + } + /* May fail due to spills/restores above, but simplifies the logic. */ + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + pi |= PPCF_DOT; + } + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_tab(as, pi, dest, left, right); + } +} + +static void asm_neg(ASMState *as, IRIns *ir) +{ + if (irt_isnum(ir->t)) { + asm_fpunary(as, ir, PPCI_FNEG); + } else { + Reg dest, left; + PPCIns pi = PPCI_NEG; + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + pi |= PPCF_DOT; + } + dest = ra_dest(as, ir, RSET_GPR); + left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + emit_tab(as, pi, dest, left, 0); + } +} + +static void asm_arithov(ASMState *as, IRIns *ir, PPCIns pi) +{ + Reg dest, left, right; + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + } + asm_guardcc(as, CC_SO); + dest = ra_dest(as, ir, RSET_GPR); + left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + if (pi == PPCI_SUBFO) { Reg tmp = left; left = right; right = tmp; } + emit_tab(as, pi|PPCF_DOT, dest, left, right); +} + +#if LJ_HASFFI +static void asm_add64(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); + PPCIns pi = PPCI_ADDE; + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (k == 0) + pi = PPCI_ADDZE; + else if (k == -1) + pi = PPCI_ADDME; + else + goto needright; + right = 0; + } else { + needright: + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + } + emit_tab(as, pi, dest, left, right); + ir--; + dest = ra_dest(as, ir, RSET_GPR); + left = ra_alloc1(as, ir->op1, RSET_GPR); + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (checki16(k)) { + emit_tai(as, PPCI_ADDIC, dest, left, k); + return; + } + } + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_tab(as, PPCI_ADDC, dest, left, right); +} + +static void asm_sub64(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left, right = ra_alloc1(as, ir->op2, RSET_GPR); + PPCIns pi = PPCI_SUBFE; + if (irref_isk(ir->op1)) { + int32_t k = IR(ir->op1)->i; + if (k == 0) + pi = PPCI_SUBFZE; + else if (k == -1) + pi = PPCI_SUBFME; + else + goto needleft; + left = 0; + } else { + needleft: + left = ra_alloc1(as, ir->op1, rset_exclude(RSET_GPR, right)); + } + emit_tab(as, pi, dest, right, left); /* Subtract right _from_ left. */ + ir--; + dest = ra_dest(as, ir, RSET_GPR); + right = ra_alloc1(as, ir->op2, RSET_GPR); + if (irref_isk(ir->op1)) { + int32_t k = IR(ir->op1)->i; + if (checki16(k)) { + emit_tai(as, PPCI_SUBFIC, dest, right, k); + return; + } + } + left = ra_alloc1(as, ir->op1, rset_exclude(RSET_GPR, right)); + emit_tab(as, PPCI_SUBFC, dest, right, left); +} + +static void asm_neg64(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg left = ra_alloc1(as, ir->op1, RSET_GPR); + emit_tab(as, PPCI_SUBFZE, dest, left, 0); + ir--; + dest = ra_dest(as, ir, RSET_GPR); + left = ra_alloc1(as, ir->op1, RSET_GPR); + emit_tai(as, PPCI_SUBFIC, dest, left, 0); +} +#endif + +static void asm_bitnot(ASMState *as, IRIns *ir) +{ + Reg dest, left, right; + PPCIns pi = PPCI_NOR; + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + pi |= PPCF_DOT; + } + dest = ra_dest(as, ir, RSET_GPR); + if (mayfuse(as, ir->op1)) { + IRIns *irl = IR(ir->op1); + if (irl->o == IR_BAND) + pi ^= (PPCI_NOR ^ PPCI_NAND); + else if (irl->o == IR_BXOR) + pi ^= (PPCI_NOR ^ PPCI_EQV); + else if (irl->o != IR_BOR) + goto nofuse; + left = ra_hintalloc(as, irl->op1, dest, RSET_GPR); + right = ra_alloc1(as, irl->op2, rset_exclude(RSET_GPR, left)); + } else { +nofuse: + left = right = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + } + emit_asb(as, pi, dest, left, right); +} + +static void asm_bitswap(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + IRIns *irx; + if (mayfuse(as, ir->op1) && (irx = IR(ir->op1))->o == IR_XLOAD && + ra_noreg(irx->r) && (irt_isint(irx->t) || irt_isu32(irx->t))) { + /* Fuse BSWAP with XLOAD to lwbrx. */ + asm_fusexrefx(as, PPCI_LWBRX, dest, irx->op1, RSET_GPR); + } else { + Reg left = ra_alloc1(as, ir->op1, RSET_GPR); + Reg tmp = dest; + if (tmp == left) { + tmp = RID_TMP; + emit_mr(as, dest, RID_TMP); + } + emit_rot(as, PPCI_RLWIMI, tmp, left, 24, 16, 23); + emit_rot(as, PPCI_RLWIMI, tmp, left, 24, 0, 7); + emit_rotlwi(as, tmp, left, 8); + } +} + +static void asm_bitop(ASMState *as, IRIns *ir, PPCIns pi, PPCIns pik) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + Reg tmp = left; + if ((checku16(k) || (k & 0xffff) == 0) || (tmp = dest, !as->sectref)) { + if (!checku16(k)) { + emit_asi(as, pik ^ (PPCI_ORI ^ PPCI_ORIS), dest, tmp, (k >> 16)); + if ((k & 0xffff) == 0) return; + } + emit_asi(as, pik, dest, left, k); + return; + } + } + /* May fail due to spills/restores above, but simplifies the logic. */ + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + pi |= PPCF_DOT; + } + right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_asb(as, pi, dest, left, right); +} + +/* Fuse BAND with contiguous bitmask and a shift to rlwinm. */ +static void asm_fuseandsh(ASMState *as, PPCIns pi, int32_t mask, IRRef ref) +{ + IRIns *ir; + Reg left; + if (mayfuse(as, ref) && (ir = IR(ref), ra_noreg(ir->r)) && + irref_isk(ir->op2) && ir->o >= IR_BSHL && ir->o <= IR_BROR) { + int32_t sh = (IR(ir->op2)->i & 31); + switch (ir->o) { + case IR_BSHL: + if ((mask & ((1u<>sh))) goto nofuse; + sh = ((32-sh)&31); + break; + case IR_BROL: + break; + default: + goto nofuse; + } + left = ra_alloc1(as, ir->op1, RSET_GPR); + *--as->mcp = pi | PPCF_T(left) | PPCF_B(sh); + return; + } +nofuse: + left = ra_alloc1(as, ref, RSET_GPR); + *--as->mcp = pi | PPCF_T(left); +} + +static void asm_bitand(ASMState *as, IRIns *ir) +{ + Reg dest, left, right; + IRRef lref = ir->op1; + PPCIns dot = 0; + IRRef op2; + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + dot = PPCF_DOT; + } + dest = ra_dest(as, ir, RSET_GPR); + if (irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (k) { + /* First check for a contiguous bitmask as used by rlwinm. */ + uint32_t s1 = lj_ffs((uint32_t)k); + uint32_t k1 = ((uint32_t)k >> s1); + if ((k1 & (k1+1)) == 0) { + asm_fuseandsh(as, PPCI_RLWINM|dot | PPCF_A(dest) | + PPCF_MB(31-lj_fls((uint32_t)k)) | PPCF_ME(31-s1), + k, lref); + return; + } + if (~(uint32_t)k) { + uint32_t s2 = lj_ffs(~(uint32_t)k); + uint32_t k2 = (~(uint32_t)k >> s2); + if ((k2 & (k2+1)) == 0) { + asm_fuseandsh(as, PPCI_RLWINM|dot | PPCF_A(dest) | + PPCF_MB(32-s2) | PPCF_ME(30-lj_fls(~(uint32_t)k)), + k, lref); + return; + } + } + } + if (checku16(k)) { + left = ra_alloc1(as, lref, RSET_GPR); + emit_asi(as, PPCI_ANDIDOT, dest, left, k); + return; + } else if ((k & 0xffff) == 0) { + left = ra_alloc1(as, lref, RSET_GPR); + emit_asi(as, PPCI_ANDISDOT, dest, left, (k >> 16)); + return; + } + } + op2 = ir->op2; + if (mayfuse(as, op2) && IR(op2)->o == IR_BNOT && ra_noreg(IR(op2)->r)) { + dot ^= (PPCI_AND ^ PPCI_ANDC); + op2 = IR(op2)->op1; + } + left = ra_hintalloc(as, lref, dest, RSET_GPR); + right = ra_alloc1(as, op2, rset_exclude(RSET_GPR, left)); + emit_asb(as, PPCI_AND ^ dot, dest, left, right); +} + +static void asm_bitshift(ASMState *as, IRIns *ir, PPCIns pi, PPCIns pik) +{ + Reg dest, left; + Reg dot = 0; + if (as->flagmcp == as->mcp) { + as->flagmcp = NULL; + as->mcp++; + dot = PPCF_DOT; + } + dest = ra_dest(as, ir, RSET_GPR); + left = ra_alloc1(as, ir->op1, RSET_GPR); + if (irref_isk(ir->op2)) { /* Constant shifts. */ + int32_t shift = (IR(ir->op2)->i & 31); + if (pik == 0) /* SLWI */ + emit_rot(as, PPCI_RLWINM|dot, dest, left, shift, 0, 31-shift); + else if (pik == 1) /* SRWI */ + emit_rot(as, PPCI_RLWINM|dot, dest, left, (32-shift)&31, shift, 31); + else + emit_asb(as, pik|dot, dest, left, shift); + } else { + Reg right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); + emit_asb(as, pi|dot, dest, left, right); + } +} + +static void asm_min_max(ASMState *as, IRIns *ir, int ismax) +{ + if (irt_isnum(ir->t)) { + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg tmp = dest; + Reg right, left = ra_alloc2(as, ir, RSET_FPR); + right = (left >> 8); left &= 255; + if (tmp == left || tmp == right) + tmp = ra_scratch(as, rset_exclude(rset_exclude(rset_exclude(RSET_FPR, + dest), left), right)); + emit_facb(as, PPCI_FSEL, dest, tmp, + ismax ? left : right, ismax ? right : left); + emit_fab(as, PPCI_FSUB, tmp, left, right); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg tmp1 = RID_TMP, tmp2 = dest; + Reg right, left = ra_alloc2(as, ir, RSET_GPR); + right = (left >> 8); left &= 255; + if (tmp2 == left || tmp2 == right) + tmp2 = ra_scratch(as, rset_exclude(rset_exclude(rset_exclude(RSET_GPR, + dest), left), right)); + emit_tab(as, PPCI_ADD, dest, tmp2, right); + emit_asb(as, ismax ? PPCI_ANDC : PPCI_AND, tmp2, tmp2, tmp1); + emit_tab(as, PPCI_SUBFE, tmp1, tmp1, tmp1); + emit_tab(as, PPCI_SUBFC, tmp2, tmp2, tmp1); + emit_asi(as, PPCI_XORIS, tmp2, right, 0x8000); + emit_asi(as, PPCI_XORIS, tmp1, left, 0x8000); + } +} + +/* -- Comparisons --------------------------------------------------------- */ + +#define CC_UNSIGNED 0x08 /* Unsigned integer comparison. */ +#define CC_TWO 0x80 /* Check two flags for FP comparison. */ + +/* Map of comparisons to flags. ORDER IR. */ +static const uint8_t asm_compmap[IR_ABC+1] = { + /* op int cc FP cc */ + /* LT */ CC_GE + (CC_GE<<4), + /* GE */ CC_LT + (CC_LE<<4) + CC_TWO, + /* LE */ CC_GT + (CC_GE<<4) + CC_TWO, + /* GT */ CC_LE + (CC_LE<<4), + /* ULT */ CC_GE + CC_UNSIGNED + (CC_GT<<4) + CC_TWO, + /* UGE */ CC_LT + CC_UNSIGNED + (CC_LT<<4), + /* ULE */ CC_GT + CC_UNSIGNED + (CC_GT<<4), + /* UGT */ CC_LE + CC_UNSIGNED + (CC_LT<<4) + CC_TWO, + /* EQ */ CC_NE + (CC_NE<<4), + /* NE */ CC_EQ + (CC_EQ<<4), + /* ABC */ CC_LE + CC_UNSIGNED + (CC_LT<<4) + CC_TWO /* Same as UGT. */ +}; + +static void asm_intcomp_(ASMState *as, IRRef lref, IRRef rref, Reg cr, PPCCC cc) +{ + Reg right, left = ra_alloc1(as, lref, RSET_GPR); + if (irref_isk(rref)) { + int32_t k = IR(rref)->i; + if ((cc & CC_UNSIGNED) == 0) { /* Signed comparison with constant. */ + if (checki16(k)) { + emit_tai(as, PPCI_CMPWI, cr, left, k); + /* Signed comparison with zero and referencing previous ins? */ + if (k == 0 && lref == as->curins-1) + as->flagmcp = as->mcp; /* Allow elimination of the compare. */ + return; + } else if ((cc & 3) == (CC_EQ & 3)) { /* Use CMPLWI for EQ or NE. */ + if (checku16(k)) { + emit_tai(as, PPCI_CMPLWI, cr, left, k); + return; + } else if (!as->sectref && ra_noreg(IR(rref)->r)) { + emit_tai(as, PPCI_CMPLWI, cr, RID_TMP, k); + emit_asi(as, PPCI_XORIS, RID_TMP, left, (k >> 16)); + return; + } + } + } else { /* Unsigned comparison with constant. */ + if (checku16(k)) { + emit_tai(as, PPCI_CMPLWI, cr, left, k); + return; + } + } + } + right = ra_alloc1(as, rref, rset_exclude(RSET_GPR, left)); + emit_tab(as, (cc & CC_UNSIGNED) ? PPCI_CMPLW : PPCI_CMPW, cr, left, right); +} + +static void asm_comp(ASMState *as, IRIns *ir) +{ + PPCCC cc = asm_compmap[ir->o]; + if (irt_isnum(ir->t)) { + Reg right, left = ra_alloc2(as, ir, RSET_FPR); + right = (left >> 8); left &= 255; + asm_guardcc(as, (cc >> 4)); + if ((cc & CC_TWO)) + emit_tab(as, PPCI_CROR, ((cc>>4)&3), ((cc>>4)&3), (CC_EQ&3)); + emit_fab(as, PPCI_FCMPU, 0, left, right); + } else { + IRRef lref = ir->op1, rref = ir->op2; + if (irref_isk(lref) && !irref_isk(rref)) { + /* Swap constants to the right (only for ABC). */ + IRRef tmp = lref; lref = rref; rref = tmp; + if ((cc & 2) == 0) cc ^= 1; /* LT <-> GT, LE <-> GE */ + } + asm_guardcc(as, cc); + asm_intcomp_(as, lref, rref, 0, cc); + } +} + +#if LJ_HASFFI +/* 64 bit integer comparisons. */ +static void asm_comp64(ASMState *as, IRIns *ir) +{ + PPCCC cc = asm_compmap[(ir-1)->o]; + if ((cc&3) == (CC_EQ&3)) { + asm_guardcc(as, cc); + emit_tab(as, (cc&4) ? PPCI_CRAND : PPCI_CROR, + (CC_EQ&3), (CC_EQ&3), 4+(CC_EQ&3)); + } else { + asm_guardcc(as, CC_EQ); + emit_tab(as, PPCI_CROR, (CC_EQ&3), (CC_EQ&3), ((cc^~(cc>>2))&1)); + emit_tab(as, (cc&4) ? PPCI_CRAND : PPCI_CRANDC, + (CC_EQ&3), (CC_EQ&3), 4+(cc&3)); + } + /* Loword comparison sets cr1 and is unsigned, except for equality. */ + asm_intcomp_(as, (ir-1)->op1, (ir-1)->op2, 4, + cc | ((cc&3) == (CC_EQ&3) ? 0 : CC_UNSIGNED)); + /* Hiword comparison sets cr0. */ + asm_intcomp_(as, ir->op1, ir->op2, 0, cc); + as->flagmcp = NULL; /* Doesn't work here. */ +} +#endif + +/* -- Support for 64 bit ops in 32 bit mode ------------------------------- */ + +/* Hiword op of a split 64 bit op. Previous op must be the loword op. */ +static void asm_hiop(ASMState *as, IRIns *ir) +{ +#if LJ_HASFFI + /* HIOP is marked as a store because it needs its own DCE logic. */ + int uselo = ra_used(ir-1), usehi = ra_used(ir); /* Loword/hiword used? */ + if (LJ_UNLIKELY(!(as->flags & JIT_F_OPT_DCE))) uselo = usehi = 1; + if ((ir-1)->o == IR_CONV) { /* Conversions to/from 64 bit. */ + as->curins--; /* Always skip the CONV. */ + if (usehi || uselo) + asm_conv64(as, ir); + return; + } else if ((ir-1)->o <= IR_NE) { /* 64 bit integer comparisons. ORDER IR. */ + as->curins--; /* Always skip the loword comparison. */ + asm_comp64(as, ir); + return; + } else if ((ir-1)->o == IR_XSTORE) { + as->curins--; /* Handle both stores here. */ + if ((ir-1)->r != RID_SINK) { + asm_xstore(as, ir, 0); + asm_xstore(as, ir-1, 4); + } + return; + } + if (!usehi) return; /* Skip unused hiword op for all remaining ops. */ + switch ((ir-1)->o) { + case IR_ADD: as->curins--; asm_add64(as, ir); break; + case IR_SUB: as->curins--; asm_sub64(as, ir); break; + case IR_NEG: as->curins--; asm_neg64(as, ir); break; + case IR_CALLN: + case IR_CALLXS: + if (!uselo) + ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */ + break; + case IR_CNEWI: + /* Nothing to do here. Handled by lo op itself. */ + break; + default: lua_assert(0); break; + } +#else + UNUSED(as); UNUSED(ir); lua_assert(0); /* Unused without FFI. */ +#endif +} + +/* -- Stack handling ------------------------------------------------------ */ + +/* Check Lua stack size for overflow. Use exit handler as fallback. */ +static void asm_stack_check(ASMState *as, BCReg topslot, + IRIns *irp, RegSet allow, ExitNo exitno) +{ + /* Try to get an unused temp. register, otherwise spill/restore RID_RET*. */ + Reg tmp, pbase = irp ? (ra_hasreg(irp->r) ? irp->r : RID_TMP) : RID_BASE; + rset_clear(allow, pbase); + tmp = allow ? rset_pickbot(allow) : + (pbase == RID_RETHI ? RID_RETLO : RID_RETHI); + emit_condbranch(as, PPCI_BC, CC_LT, asm_exitstub_addr(as, exitno)); + if (allow == RSET_EMPTY) /* Restore temp. register. */ + emit_tai(as, PPCI_LWZ, tmp, RID_SP, SPOFS_TMPW); + else + ra_modified(as, tmp); + emit_ai(as, PPCI_CMPLWI, RID_TMP, (int32_t)(8*topslot)); + emit_tab(as, PPCI_SUBF, RID_TMP, pbase, tmp); + emit_tai(as, PPCI_LWZ, tmp, tmp, offsetof(lua_State, maxstack)); + if (pbase == RID_TMP) + emit_getgl(as, RID_TMP, jit_base); + emit_getgl(as, tmp, jit_L); + if (allow == RSET_EMPTY) /* Spill temp. register. */ + emit_tai(as, PPCI_STW, tmp, RID_SP, SPOFS_TMPW); +} + +/* Restore Lua stack from on-trace state. */ +static void asm_stack_restore(ASMState *as, SnapShot *snap) +{ + SnapEntry *map = &as->T->snapmap[snap->mapofs]; + SnapEntry *flinks = &as->T->snapmap[snap_nextofs(as->T, snap)-1]; + MSize n, nent = snap->nent; + /* Store the value of all modified slots to the Lua stack. */ + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + BCReg s = snap_slot(sn); + int32_t ofs = 8*((int32_t)s-1); + IRRef ref = snap_ref(sn); + IRIns *ir = IR(ref); + if ((sn & SNAP_NORESTORE)) + continue; + if (irt_isnum(ir->t)) { + Reg src = ra_alloc1(as, ref, RSET_FPR); + emit_fai(as, PPCI_STFD, src, RID_BASE, ofs); + } else { + Reg type; + RegSet allow = rset_exclude(RSET_GPR, RID_BASE); + lua_assert(irt_ispri(ir->t) || irt_isaddr(ir->t) || irt_isinteger(ir->t)); + if (!irt_ispri(ir->t)) { + Reg src = ra_alloc1(as, ref, allow); + rset_clear(allow, src); + emit_tai(as, PPCI_STW, src, RID_BASE, ofs+4); + } + if ((sn & (SNAP_CONT|SNAP_FRAME))) { + if (s == 0) continue; /* Do not overwrite link to previous frame. */ + type = ra_allock(as, (int32_t)(*flinks--), allow); + } else { + type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); + } + emit_tai(as, PPCI_STW, type, RID_BASE, ofs); + } + checkmclim(as); + } + lua_assert(map + nent == flinks); +} + +/* -- GC handling --------------------------------------------------------- */ + +/* Check GC threshold and do one or more GC steps. */ +static void asm_gc_check(ASMState *as) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_step_jit]; + IRRef args[2]; + MCLabel l_end; + Reg tmp; + ra_evictset(as, RSET_SCRATCH); + l_end = emit_label(as); + /* Exit trace if in GCSatomic or GCSfinalize. Avoids syncing GC objects. */ + asm_guardcc(as, CC_NE); /* Assumes asm_snap_prep() already done. */ + emit_ai(as, PPCI_CMPWI, RID_RET, 0); + args[0] = ASMREF_TMP1; /* global_State *g */ + args[1] = ASMREF_TMP2; /* MSize steps */ + asm_gencall(as, ci, args); + emit_tai(as, PPCI_ADDI, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768); + tmp = ra_releasetmp(as, ASMREF_TMP2); + emit_loadi(as, tmp, as->gcsteps); + /* Jump around GC step if GC total < GC threshold. */ + emit_condbranch(as, PPCI_BC|PPCF_Y, CC_LT, l_end); + emit_ab(as, PPCI_CMPLW, RID_TMP, tmp); + emit_getgl(as, tmp, gc.threshold); + emit_getgl(as, RID_TMP, gc.total); + as->gcsteps = 0; + checkmclim(as); +} + +/* -- Loop handling ------------------------------------------------------- */ + +/* Fixup the loop branch. */ +static void asm_loop_fixup(ASMState *as) +{ + MCode *p = as->mctop; + MCode *target = as->mcp; + if (as->loopinv) { /* Inverted loop branch? */ + /* asm_guardcc already inverted the cond branch and patched the final b. */ + p[-2] = (p[-2] & (0xffff0000u & ~PPCF_Y)) | (((target-p+2) & 0x3fffu) << 2); + } else { + p[-1] = PPCI_B|(((target-p+1)&0x00ffffffu)<<2); + } +} + +/* -- Head of trace ------------------------------------------------------- */ + +/* Coalesce BASE register for a root trace. */ +static void asm_head_root_base(ASMState *as) +{ + IRIns *ir = IR(REF_BASE); + Reg r = ir->r; + if (ra_hasreg(r)) { + ra_free(as, r); + if (rset_test(as->modset, r) || irt_ismarked(ir->t)) + ir->r = RID_INIT; /* No inheritance for modified BASE register. */ + if (r != RID_BASE) + emit_mr(as, r, RID_BASE); + } +} + +/* Coalesce BASE register for a side trace. */ +static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) +{ + IRIns *ir = IR(REF_BASE); + Reg r = ir->r; + if (ra_hasreg(r)) { + ra_free(as, r); + if (rset_test(as->modset, r) || irt_ismarked(ir->t)) + ir->r = RID_INIT; /* No inheritance for modified BASE register. */ + if (irp->r == r) { + rset_clear(allow, r); /* Mark same BASE register as coalesced. */ + } else if (ra_hasreg(irp->r) && rset_test(as->freeset, irp->r)) { + rset_clear(allow, irp->r); + emit_mr(as, r, irp->r); /* Move from coalesced parent reg. */ + } else { + emit_getgl(as, r, jit_base); /* Otherwise reload BASE. */ + } + } + return allow; +} + +/* -- Tail of trace ------------------------------------------------------- */ + +/* Fixup the tail code. */ +static void asm_tail_fixup(ASMState *as, TraceNo lnk) +{ + MCode *p = as->mctop; + MCode *target; + int32_t spadj = as->T->spadjust; + if (spadj == 0) { + *--p = PPCI_NOP; + *--p = PPCI_NOP; + as->mctop = p; + } else { + /* Patch stack adjustment. */ + lua_assert(checki16(CFRAME_SIZE+spadj)); + p[-3] = PPCI_ADDI | PPCF_T(RID_TMP) | PPCF_A(RID_SP) | (CFRAME_SIZE+spadj); + p[-2] = PPCI_STWU | PPCF_T(RID_TMP) | PPCF_A(RID_SP) | spadj; + } + /* Patch exit branch. */ + target = lnk ? traceref(as->J, lnk)->mcode : (MCode *)lj_vm_exit_interp; + p[-1] = PPCI_B|(((target-p+1)&0x00ffffffu)<<2); +} + +/* Prepare tail of code. */ +static void asm_tail_prep(ASMState *as) +{ + MCode *p = as->mctop - 1; /* Leave room for exit branch. */ + if (as->loopref) { + as->invmcp = as->mcp = p; + } else { + as->mcp = p-2; /* Leave room for stack pointer adjustment. */ + as->invmcp = NULL; + } +} + +/* -- Instruction dispatch ------------------------------------------------ */ + +/* Assemble a single instruction. */ +static void asm_ir(ASMState *as, IRIns *ir) +{ + switch ((IROp)ir->o) { + /* Miscellaneous ops. */ + case IR_LOOP: asm_loop(as); break; + case IR_NOP: case IR_XBAR: lua_assert(!ra_used(ir)); break; + case IR_USE: + ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break; + case IR_PHI: asm_phi(as, ir); break; + case IR_HIOP: asm_hiop(as, ir); break; + case IR_GCSTEP: asm_gcstep(as, ir); break; + + /* Guarded assertions. */ + case IR_EQ: case IR_NE: + if ((ir-1)->o == IR_HREF && ir->op1 == as->curins-1) { + as->curins--; + asm_href(as, ir-1, (IROp)ir->o); + break; + } + /* fallthrough */ + case IR_LT: case IR_GE: case IR_LE: case IR_GT: + case IR_ULT: case IR_UGE: case IR_ULE: case IR_UGT: + case IR_ABC: + asm_comp(as, ir); + break; + + case IR_RETF: asm_retf(as, ir); break; + + /* Bit ops. */ + case IR_BNOT: asm_bitnot(as, ir); break; + case IR_BSWAP: asm_bitswap(as, ir); break; + + case IR_BAND: asm_bitand(as, ir); break; + case IR_BOR: asm_bitop(as, ir, PPCI_OR, PPCI_ORI); break; + case IR_BXOR: asm_bitop(as, ir, PPCI_XOR, PPCI_XORI); break; + + case IR_BSHL: asm_bitshift(as, ir, PPCI_SLW, 0); break; + case IR_BSHR: asm_bitshift(as, ir, PPCI_SRW, 1); break; + case IR_BSAR: asm_bitshift(as, ir, PPCI_SRAW, PPCI_SRAWI); break; + case IR_BROL: asm_bitshift(as, ir, PPCI_RLWNM|PPCF_MB(0)|PPCF_ME(31), + PPCI_RLWINM|PPCF_MB(0)|PPCF_ME(31)); break; + case IR_BROR: lua_assert(0); break; + + /* Arithmetic ops. */ + case IR_ADD: asm_add(as, ir); break; + case IR_SUB: asm_sub(as, ir); break; + case IR_MUL: asm_mul(as, ir); break; + case IR_DIV: asm_fparith(as, ir, PPCI_FDIV); break; + case IR_MOD: asm_callid(as, ir, IRCALL_lj_vm_modi); break; + case IR_POW: asm_callid(as, ir, IRCALL_lj_vm_powi); break; + case IR_NEG: asm_neg(as, ir); break; + + case IR_ABS: asm_fpunary(as, ir, PPCI_FABS); break; + case IR_ATAN2: asm_callid(as, ir, IRCALL_atan2); break; + case IR_LDEXP: asm_callid(as, ir, IRCALL_ldexp); break; + case IR_MIN: asm_min_max(as, ir, 0); break; + case IR_MAX: asm_min_max(as, ir, 1); break; + case IR_FPMATH: + if (ir->op2 == IRFPM_EXP2 && asm_fpjoin_pow(as, ir)) + break; + if (ir->op2 == IRFPM_SQRT && (as->flags & JIT_F_SQRT)) + asm_fpunary(as, ir, PPCI_FSQRT); + else + asm_callid(as, ir, IRCALL_lj_vm_floor + ir->op2); + break; + + /* Overflow-checking arithmetic ops. */ + case IR_ADDOV: asm_arithov(as, ir, PPCI_ADDO); break; + case IR_SUBOV: asm_arithov(as, ir, PPCI_SUBFO); break; + case IR_MULOV: asm_arithov(as, ir, PPCI_MULLWO); break; + + /* Memory references. */ + case IR_AREF: asm_aref(as, ir); break; + case IR_HREF: asm_href(as, ir, 0); break; + case IR_HREFK: asm_hrefk(as, ir); break; + case IR_NEWREF: asm_newref(as, ir); break; + case IR_UREFO: case IR_UREFC: asm_uref(as, ir); break; + case IR_FREF: asm_fref(as, ir); break; + case IR_STRREF: asm_strref(as, ir); break; + + /* Loads and stores. */ + case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: + asm_ahuvload(as, ir); + break; + case IR_FLOAD: asm_fload(as, ir); break; + case IR_XLOAD: asm_xload(as, ir); break; + case IR_SLOAD: asm_sload(as, ir); break; + + case IR_ASTORE: case IR_HSTORE: case IR_USTORE: asm_ahustore(as, ir); break; + case IR_FSTORE: asm_fstore(as, ir); break; + case IR_XSTORE: asm_xstore(as, ir, 0); break; + + /* Allocations. */ + case IR_SNEW: case IR_XSNEW: asm_snew(as, ir); break; + case IR_TNEW: asm_tnew(as, ir); break; + case IR_TDUP: asm_tdup(as, ir); break; + case IR_CNEW: case IR_CNEWI: asm_cnew(as, ir); break; + + /* Write barriers. */ + case IR_TBAR: asm_tbar(as, ir); break; + case IR_OBAR: asm_obar(as, ir); break; + + /* Type conversions. */ + case IR_CONV: asm_conv(as, ir); break; + case IR_TOBIT: asm_tobit(as, ir); break; + case IR_TOSTR: asm_tostr(as, ir); break; + case IR_STRTO: asm_strto(as, ir); break; + + /* Calls. */ + case IR_CALLN: case IR_CALLL: case IR_CALLS: asm_call(as, ir); break; + case IR_CALLXS: asm_callx(as, ir); break; + case IR_CARG: break; + + default: + setintV(&as->J->errinfo, ir->o); + lj_trace_err_info(as->J, LJ_TRERR_NYIIR); + break; + } +} + +/* -- Trace setup --------------------------------------------------------- */ + +/* Ensure there are enough stack slots for call arguments. */ +static Reg asm_setup_call_slots(ASMState *as, IRIns *ir, const CCallInfo *ci) +{ + IRRef args[CCI_NARGS_MAX*2]; + uint32_t i, nargs = (int)CCI_NARGS(ci); + int nslots = 2, ngpr = REGARG_NUMGPR, nfpr = REGARG_NUMFPR; + asm_collectargs(as, ir, ci, args); + for (i = 0; i < nargs; i++) + if (args[i] && irt_isfp(IR(args[i])->t)) { + if (nfpr > 0) nfpr--; else nslots = (nslots+3) & ~1; + } else { + if (ngpr > 0) ngpr--; else nslots++; + } + if (nslots > as->evenspill) /* Leave room for args in stack slots. */ + as->evenspill = nslots; + return irt_isfp(ir->t) ? REGSP_HINT(RID_FPRET) : REGSP_HINT(RID_RET); +} + +static void asm_setup_target(ASMState *as) +{ + asm_exitstub_setup(as, as->T->nsnap + (as->parent ? 1 : 0)); +} + +/* -- Trace patching ------------------------------------------------------ */ + +/* Patch exit jumps of existing machine code to a new target. */ +void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target) +{ + MCode *p = T->mcode; + MCode *pe = (MCode *)((char *)p + T->szmcode); + MCode *px = exitstub_trace_addr(T, exitno); + MCode *cstart = NULL; + MCode *mcarea = lj_mcode_patch(J, p, 0); + int clearso = 0; + for (; p < pe; p++) { + /* Look for exitstub branch, try to replace with branch to target. */ + uint32_t ins = *p; + if ((ins & 0xfc000000u) == 0x40000000u && + ((ins ^ ((char *)px-(char *)p)) & 0xffffu) == 0) { + ptrdiff_t delta = (char *)target - (char *)p; + if (((ins >> 16) & 3) == (CC_SO&3)) { + clearso = sizeof(MCode); + delta -= sizeof(MCode); + } + /* Many, but not all short-range branches can be patched directly. */ + if (((delta + 0x8000) >> 16) == 0) { + *p = (ins & 0xffdf0000u) | ((uint32_t)delta & 0xffffu) | + ((delta & 0x8000) * (PPCF_Y/0x8000)); + if (!cstart) cstart = p; + } + } else if ((ins & 0xfc000000u) == PPCI_B && + ((ins ^ ((char *)px-(char *)p)) & 0x03ffffffu) == 0) { + ptrdiff_t delta = (char *)target - (char *)p; + lua_assert(((delta + 0x02000000) >> 26) == 0); + *p = PPCI_B | ((uint32_t)delta & 0x03ffffffu); + if (!cstart) cstart = p; + } + } + { /* Always patch long-range branch in exit stub itself. */ + ptrdiff_t delta = (char *)target - (char *)px - clearso; + lua_assert(((delta + 0x02000000) >> 26) == 0); + *px = PPCI_B | ((uint32_t)delta & 0x03ffffffu); + } + if (!cstart) cstart = px; + lj_mcode_sync(cstart, px+1); + if (clearso) { /* Extend the current trace. Ugly workaround. */ + MCode *pp = J->cur.mcode; + J->cur.szmcode += sizeof(MCode); + *--pp = PPCI_MCRXR; /* Clear SO flag. */ + J->cur.mcode = pp; + lj_mcode_sync(pp, pp+1); + } + lj_mcode_patch(J, mcarea, 1); +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_x86.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_x86.h new file mode 100644 index 000000000..0b6b2d4a5 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_asm_x86.h @@ -0,0 +1,2806 @@ +/* +** x86/x64 IR assembler (SSA IR -> machine code). +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* -- Guard handling ------------------------------------------------------ */ + +/* Generate an exit stub group at the bottom of the reserved MCode memory. */ +static MCode *asm_exitstub_gen(ASMState *as, ExitNo group) +{ + ExitNo i, groupofs = (group*EXITSTUBS_PER_GROUP) & 0xff; + MCode *mxp = as->mcbot; + MCode *mxpstart = mxp; + if (mxp + (2+2)*EXITSTUBS_PER_GROUP+8+5 >= as->mctop) + asm_mclimit(as); + /* Push low byte of exitno for each exit stub. */ + *mxp++ = XI_PUSHi8; *mxp++ = (MCode)groupofs; + for (i = 1; i < EXITSTUBS_PER_GROUP; i++) { + *mxp++ = XI_JMPs; *mxp++ = (MCode)((2+2)*(EXITSTUBS_PER_GROUP - i) - 2); + *mxp++ = XI_PUSHi8; *mxp++ = (MCode)(groupofs + i); + } + /* Push the high byte of the exitno for each exit stub group. */ + *mxp++ = XI_PUSHi8; *mxp++ = (MCode)((group*EXITSTUBS_PER_GROUP)>>8); + /* Store DISPATCH at original stack slot 0. Account for the two push ops. */ + *mxp++ = XI_MOVmi; + *mxp++ = MODRM(XM_OFS8, 0, RID_ESP); + *mxp++ = MODRM(XM_SCALE1, RID_ESP, RID_ESP); + *mxp++ = 2*sizeof(void *); + *(int32_t *)mxp = ptr2addr(J2GG(as->J)->dispatch); mxp += 4; + /* Jump to exit handler which fills in the ExitState. */ + *mxp++ = XI_JMP; mxp += 4; + *((int32_t *)(mxp-4)) = jmprel(mxp, (MCode *)(void *)lj_vm_exit_handler); + /* Commit the code for this group (even if assembly fails later on). */ + lj_mcode_commitbot(as->J, mxp); + as->mcbot = mxp; + as->mclim = as->mcbot + MCLIM_REDZONE; + return mxpstart; +} + +/* Setup all needed exit stubs. */ +static void asm_exitstub_setup(ASMState *as, ExitNo nexits) +{ + ExitNo i; + if (nexits >= EXITSTUBS_PER_GROUP*LJ_MAX_EXITSTUBGR) + lj_trace_err(as->J, LJ_TRERR_SNAPOV); + for (i = 0; i < (nexits+EXITSTUBS_PER_GROUP-1)/EXITSTUBS_PER_GROUP; i++) + if (as->J->exitstubgroup[i] == NULL) + as->J->exitstubgroup[i] = asm_exitstub_gen(as, i); +} + +/* Emit conditional branch to exit for guard. +** It's important to emit this *after* all registers have been allocated, +** because rematerializations may invalidate the flags. +*/ +static void asm_guardcc(ASMState *as, int cc) +{ + MCode *target = exitstub_addr(as->J, as->snapno); + MCode *p = as->mcp; + if (LJ_UNLIKELY(p == as->invmcp)) { + as->loopinv = 1; + *(int32_t *)(p+1) = jmprel(p+5, target); + target = p; + cc ^= 1; + if (as->realign) { + emit_sjcc(as, cc, target); + return; + } + } + emit_jcc(as, cc, target); +} + +/* -- Memory operand fusion ----------------------------------------------- */ + +/* Limit linear search to this distance. Avoids O(n^2) behavior. */ +#define CONFLICT_SEARCH_LIM 31 + +/* Check if a reference is a signed 32 bit constant. */ +static int asm_isk32(ASMState *as, IRRef ref, int32_t *k) +{ + if (irref_isk(ref)) { + IRIns *ir = IR(ref); + if (ir->o != IR_KINT64) { + *k = ir->i; + return 1; + } else if (checki32((int64_t)ir_kint64(ir)->u64)) { + *k = (int32_t)ir_kint64(ir)->u64; + return 1; + } + } + return 0; +} + +/* Check if there's no conflicting instruction between curins and ref. +** Also avoid fusing loads if there are multiple references. +*/ +static int noconflict(ASMState *as, IRRef ref, IROp conflict, int noload) +{ + IRIns *ir = as->ir; + IRRef i = as->curins; + if (i > ref + CONFLICT_SEARCH_LIM) + return 0; /* Give up, ref is too far away. */ + while (--i > ref) { + if (ir[i].o == conflict) + return 0; /* Conflict found. */ + else if (!noload && (ir[i].op1 == ref || ir[i].op2 == ref)) + return 0; + } + return 1; /* Ok, no conflict. */ +} + +/* Fuse array base into memory operand. */ +static IRRef asm_fuseabase(ASMState *as, IRRef ref) +{ + IRIns *irb = IR(ref); + as->mrm.ofs = 0; + if (irb->o == IR_FLOAD) { + IRIns *ira = IR(irb->op1); + lua_assert(irb->op2 == IRFL_TAB_ARRAY); + /* We can avoid the FLOAD of t->array for colocated arrays. */ + if (ira->o == IR_TNEW && ira->op1 <= LJ_MAX_COLOSIZE && + !neverfuse(as) && noconflict(as, irb->op1, IR_NEWREF, 1)) { + as->mrm.ofs = (int32_t)sizeof(GCtab); /* Ofs to colocated array. */ + return irb->op1; /* Table obj. */ + } + } else if (irb->o == IR_ADD && irref_isk(irb->op2)) { + /* Fuse base offset (vararg load). */ + as->mrm.ofs = IR(irb->op2)->i; + return irb->op1; + } + return ref; /* Otherwise use the given array base. */ +} + +/* Fuse array reference into memory operand. */ +static void asm_fusearef(ASMState *as, IRIns *ir, RegSet allow) +{ + IRIns *irx; + lua_assert(ir->o == IR_AREF); + as->mrm.base = (uint8_t)ra_alloc1(as, asm_fuseabase(as, ir->op1), allow); + irx = IR(ir->op2); + if (irref_isk(ir->op2)) { + as->mrm.ofs += 8*irx->i; + as->mrm.idx = RID_NONE; + } else { + rset_clear(allow, as->mrm.base); + as->mrm.scale = XM_SCALE8; + /* Fuse a constant ADD (e.g. t[i+1]) into the offset. + ** Doesn't help much without ABCelim, but reduces register pressure. + */ + if (!LJ_64 && /* Has bad effects with negative index on x64. */ + mayfuse(as, ir->op2) && ra_noreg(irx->r) && + irx->o == IR_ADD && irref_isk(irx->op2)) { + as->mrm.ofs += 8*IR(irx->op2)->i; + as->mrm.idx = (uint8_t)ra_alloc1(as, irx->op1, allow); + } else { + as->mrm.idx = (uint8_t)ra_alloc1(as, ir->op2, allow); + } + } +} + +/* Fuse array/hash/upvalue reference into memory operand. +** Caveat: this may allocate GPRs for the base/idx registers. Be sure to +** pass the final allow mask, excluding any GPRs used for other inputs. +** In particular: 2-operand GPR instructions need to call ra_dest() first! +*/ +static void asm_fuseahuref(ASMState *as, IRRef ref, RegSet allow) +{ + IRIns *ir = IR(ref); + if (ra_noreg(ir->r)) { + switch ((IROp)ir->o) { + case IR_AREF: + if (mayfuse(as, ref)) { + asm_fusearef(as, ir, allow); + return; + } + break; + case IR_HREFK: + if (mayfuse(as, ref)) { + as->mrm.base = (uint8_t)ra_alloc1(as, ir->op1, allow); + as->mrm.ofs = (int32_t)(IR(ir->op2)->op2 * sizeof(Node)); + as->mrm.idx = RID_NONE; + return; + } + break; + case IR_UREFC: + if (irref_isk(ir->op1)) { + GCfunc *fn = ir_kfunc(IR(ir->op1)); + GCupval *uv = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv; + as->mrm.ofs = ptr2addr(&uv->tv); + as->mrm.base = as->mrm.idx = RID_NONE; + return; + } + break; + default: + lua_assert(ir->o == IR_HREF || ir->o == IR_NEWREF || ir->o == IR_UREFO || + ir->o == IR_KKPTR); + break; + } + } + as->mrm.base = (uint8_t)ra_alloc1(as, ref, allow); + as->mrm.ofs = 0; + as->mrm.idx = RID_NONE; +} + +/* Fuse FLOAD/FREF reference into memory operand. */ +static void asm_fusefref(ASMState *as, IRIns *ir, RegSet allow) +{ + lua_assert(ir->o == IR_FLOAD || ir->o == IR_FREF); + as->mrm.ofs = field_ofs[ir->op2]; + as->mrm.idx = RID_NONE; + if (irref_isk(ir->op1)) { + as->mrm.ofs += IR(ir->op1)->i; + as->mrm.base = RID_NONE; + } else { + as->mrm.base = (uint8_t)ra_alloc1(as, ir->op1, allow); + } +} + +/* Fuse string reference into memory operand. */ +static void asm_fusestrref(ASMState *as, IRIns *ir, RegSet allow) +{ + IRIns *irr; + lua_assert(ir->o == IR_STRREF); + as->mrm.base = as->mrm.idx = RID_NONE; + as->mrm.scale = XM_SCALE1; + as->mrm.ofs = sizeof(GCstr); + if (irref_isk(ir->op1)) { + as->mrm.ofs += IR(ir->op1)->i; + } else { + Reg r = ra_alloc1(as, ir->op1, allow); + rset_clear(allow, r); + as->mrm.base = (uint8_t)r; + } + irr = IR(ir->op2); + if (irref_isk(ir->op2)) { + as->mrm.ofs += irr->i; + } else { + Reg r; + /* Fuse a constant add into the offset, e.g. string.sub(s, i+10). */ + if (!LJ_64 && /* Has bad effects with negative index on x64. */ + mayfuse(as, ir->op2) && irr->o == IR_ADD && irref_isk(irr->op2)) { + as->mrm.ofs += IR(irr->op2)->i; + r = ra_alloc1(as, irr->op1, allow); + } else { + r = ra_alloc1(as, ir->op2, allow); + } + if (as->mrm.base == RID_NONE) + as->mrm.base = (uint8_t)r; + else + as->mrm.idx = (uint8_t)r; + } +} + +static void asm_fusexref(ASMState *as, IRRef ref, RegSet allow) +{ + IRIns *ir = IR(ref); + as->mrm.idx = RID_NONE; + if (ir->o == IR_KPTR || ir->o == IR_KKPTR) { + as->mrm.ofs = ir->i; + as->mrm.base = RID_NONE; + } else if (ir->o == IR_STRREF) { + asm_fusestrref(as, ir, allow); + } else { + as->mrm.ofs = 0; + if (canfuse(as, ir) && ir->o == IR_ADD && ra_noreg(ir->r)) { + /* Gather (base+idx*sz)+ofs as emitted by cdata ptr/array indexing. */ + IRIns *irx; + IRRef idx; + Reg r; + if (asm_isk32(as, ir->op2, &as->mrm.ofs)) { /* Recognize x+ofs. */ + ref = ir->op1; + ir = IR(ref); + if (!(ir->o == IR_ADD && canfuse(as, ir) && ra_noreg(ir->r))) + goto noadd; + } + as->mrm.scale = XM_SCALE1; + idx = ir->op1; + ref = ir->op2; + irx = IR(idx); + if (!(irx->o == IR_BSHL || irx->o == IR_ADD)) { /* Try other operand. */ + idx = ir->op2; + ref = ir->op1; + irx = IR(idx); + } + if (canfuse(as, irx) && ra_noreg(irx->r)) { + if (irx->o == IR_BSHL && irref_isk(irx->op2) && IR(irx->op2)->i <= 3) { + /* Recognize idx<op1; + as->mrm.scale = (uint8_t)(IR(irx->op2)->i << 6); + } else if (irx->o == IR_ADD && irx->op1 == irx->op2) { + /* FOLD does idx*2 ==> idx<<1 ==> idx+idx. */ + idx = irx->op1; + as->mrm.scale = XM_SCALE2; + } + } + r = ra_alloc1(as, idx, allow); + rset_clear(allow, r); + as->mrm.idx = (uint8_t)r; + } + noadd: + as->mrm.base = (uint8_t)ra_alloc1(as, ref, allow); + } +} + +/* Fuse load into memory operand. */ +static Reg asm_fuseload(ASMState *as, IRRef ref, RegSet allow) +{ + IRIns *ir = IR(ref); + if (ra_hasreg(ir->r)) { + if (allow != RSET_EMPTY) { /* Fast path. */ + ra_noweak(as, ir->r); + return ir->r; + } + fusespill: + /* Force a spill if only memory operands are allowed (asm_x87load). */ + as->mrm.base = RID_ESP; + as->mrm.ofs = ra_spill(as, ir); + as->mrm.idx = RID_NONE; + return RID_MRM; + } + if (ir->o == IR_KNUM) { + RegSet avail = as->freeset & ~as->modset & RSET_FPR; + lua_assert(allow != RSET_EMPTY); + if (!(avail & (avail-1))) { /* Fuse if less than two regs available. */ + as->mrm.ofs = ptr2addr(ir_knum(ir)); + as->mrm.base = as->mrm.idx = RID_NONE; + return RID_MRM; + } + } else if (ir->o == IR_KINT64) { + RegSet avail = as->freeset & ~as->modset & RSET_GPR; + lua_assert(allow != RSET_EMPTY); + if (!(avail & (avail-1))) { /* Fuse if less than two regs available. */ + as->mrm.ofs = ptr2addr(ir_kint64(ir)); + as->mrm.base = as->mrm.idx = RID_NONE; + return RID_MRM; + } + } else if (mayfuse(as, ref)) { + RegSet xallow = (allow & RSET_GPR) ? allow : RSET_GPR; + if (ir->o == IR_SLOAD) { + if (!(ir->op2 & (IRSLOAD_PARENT|IRSLOAD_CONVERT)) && + noconflict(as, ref, IR_RETF, 0)) { + as->mrm.base = (uint8_t)ra_alloc1(as, REF_BASE, xallow); + as->mrm.ofs = 8*((int32_t)ir->op1-1) + ((ir->op2&IRSLOAD_FRAME)?4:0); + as->mrm.idx = RID_NONE; + return RID_MRM; + } + } else if (ir->o == IR_FLOAD) { + /* Generic fusion is only ok for 32 bit operand (but see asm_comp). */ + if ((irt_isint(ir->t) || irt_isu32(ir->t) || irt_isaddr(ir->t)) && + noconflict(as, ref, IR_FSTORE, 0)) { + asm_fusefref(as, ir, xallow); + return RID_MRM; + } + } else if (ir->o == IR_ALOAD || ir->o == IR_HLOAD || ir->o == IR_ULOAD) { + if (noconflict(as, ref, ir->o + IRDELTA_L2S, 0)) { + asm_fuseahuref(as, ir->op1, xallow); + return RID_MRM; + } + } else if (ir->o == IR_XLOAD) { + /* Generic fusion is not ok for 8/16 bit operands (but see asm_comp). + ** Fusing unaligned memory operands is ok on x86 (except for SIMD types). + */ + if ((!irt_typerange(ir->t, IRT_I8, IRT_U16)) && + noconflict(as, ref, IR_XSTORE, 0)) { + asm_fusexref(as, ir->op1, xallow); + return RID_MRM; + } + } else if (ir->o == IR_VLOAD) { + asm_fuseahuref(as, ir->op1, xallow); + return RID_MRM; + } + } + if (!(as->freeset & allow) && !irref_isk(ref) && + (allow == RSET_EMPTY || ra_hasspill(ir->s) || iscrossref(as, ref))) + goto fusespill; + return ra_allocref(as, ref, allow); +} + +#if LJ_64 +/* Don't fuse a 32 bit load into a 64 bit operation. */ +static Reg asm_fuseloadm(ASMState *as, IRRef ref, RegSet allow, int is64) +{ + if (is64 && !irt_is64(IR(ref)->t)) + return ra_alloc1(as, ref, allow); + return asm_fuseload(as, ref, allow); +} +#else +#define asm_fuseloadm(as, ref, allow, is64) asm_fuseload(as, (ref), (allow)) +#endif + +/* -- Calls --------------------------------------------------------------- */ + +/* Count the required number of stack slots for a call. */ +static int asm_count_call_slots(ASMState *as, const CCallInfo *ci, IRRef *args) +{ + uint32_t i, nargs = CCI_NARGS(ci); + int nslots = 0; +#if LJ_64 + if (LJ_ABI_WIN) { + nslots = (int)(nargs*2); /* Only matters for more than four args. */ + } else { + int ngpr = REGARG_NUMGPR, nfpr = REGARG_NUMFPR; + for (i = 0; i < nargs; i++) + if (args[i] && irt_isfp(IR(args[i])->t)) { + if (nfpr > 0) nfpr--; else nslots += 2; + } else { + if (ngpr > 0) ngpr--; else nslots += 2; + } + } +#else + int ngpr = 0; + if ((ci->flags & CCI_CC_MASK) == CCI_CC_FASTCALL) + ngpr = 2; + else if ((ci->flags & CCI_CC_MASK) == CCI_CC_THISCALL) + ngpr = 1; + for (i = 0; i < nargs; i++) + if (args[i] && irt_isfp(IR(args[i])->t)) { + nslots += irt_isnum(IR(args[i])->t) ? 2 : 1; + } else { + if (ngpr > 0) ngpr--; else nslots++; + } +#endif + return nslots; +} + +/* Generate a call to a C function. */ +static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args) +{ + uint32_t n, nargs = CCI_NARGS(ci); + int32_t ofs = STACKARG_OFS; +#if LJ_64 + uint32_t gprs = REGARG_GPRS; + Reg fpr = REGARG_FIRSTFPR; +#if !LJ_ABI_WIN + MCode *patchnfpr = NULL; +#endif +#else + uint32_t gprs = 0; + if ((ci->flags & CCI_CC_MASK) != CCI_CC_CDECL) { + if ((ci->flags & CCI_CC_MASK) == CCI_CC_THISCALL) + gprs = (REGARG_GPRS & 31); + else if ((ci->flags & CCI_CC_MASK) == CCI_CC_FASTCALL) + gprs = REGARG_GPRS; + } +#endif + if ((void *)ci->func) + emit_call(as, ci->func); +#if LJ_64 + if ((ci->flags & CCI_VARARG)) { /* Special handling for vararg calls. */ +#if LJ_ABI_WIN + for (n = 0; n < 4 && n < nargs; n++) { + IRIns *ir = IR(args[n]); + if (irt_isfp(ir->t)) /* Duplicate FPRs in GPRs. */ + emit_rr(as, XO_MOVDto, (irt_isnum(ir->t) ? REX_64 : 0) | (fpr+n), + ((gprs >> (n*5)) & 31)); /* Either MOVD or MOVQ. */ + } +#else + patchnfpr = --as->mcp; /* Indicate number of used FPRs in register al. */ + *--as->mcp = XI_MOVrib | RID_EAX; +#endif + } +#endif + for (n = 0; n < nargs; n++) { /* Setup args. */ + IRRef ref = args[n]; + IRIns *ir = IR(ref); + Reg r; +#if LJ_64 && LJ_ABI_WIN + /* Windows/x64 argument registers are strictly positional. */ + r = irt_isfp(ir->t) ? (fpr <= REGARG_LASTFPR ? fpr : 0) : (gprs & 31); + fpr++; gprs >>= 5; +#elif LJ_64 + /* POSIX/x64 argument registers are used in order of appearance. */ + if (irt_isfp(ir->t)) { + r = fpr <= REGARG_LASTFPR ? fpr++ : 0; + } else { + r = gprs & 31; gprs >>= 5; + } +#else + if (ref && irt_isfp(ir->t)) { + r = 0; + } else { + r = gprs & 31; gprs >>= 5; + if (!ref) continue; + } +#endif + if (r) { /* Argument is in a register. */ + if (r < RID_MAX_GPR && ref < ASMREF_TMP1) { +#if LJ_64 + if (ir->o == IR_KINT64) + emit_loadu64(as, r, ir_kint64(ir)->u64); + else +#endif + emit_loadi(as, r, ir->i); + } else { + lua_assert(rset_test(as->freeset, r)); /* Must have been evicted. */ + if (ra_hasreg(ir->r)) { + ra_noweak(as, ir->r); + emit_movrr(as, ir, r, ir->r); + } else { + ra_allocref(as, ref, RID2RSET(r)); + } + } + } else if (irt_isfp(ir->t)) { /* FP argument is on stack. */ + lua_assert(!(irt_isfloat(ir->t) && irref_isk(ref))); /* No float k. */ + if (LJ_32 && (ofs & 4) && irref_isk(ref)) { + /* Split stores for unaligned FP consts. */ + emit_movmroi(as, RID_ESP, ofs, (int32_t)ir_knum(ir)->u32.lo); + emit_movmroi(as, RID_ESP, ofs+4, (int32_t)ir_knum(ir)->u32.hi); + } else { + r = ra_alloc1(as, ref, RSET_FPR); + emit_rmro(as, irt_isnum(ir->t) ? XO_MOVSDto : XO_MOVSSto, + r, RID_ESP, ofs); + } + ofs += (LJ_32 && irt_isfloat(ir->t)) ? 4 : 8; + } else { /* Non-FP argument is on stack. */ + if (LJ_32 && ref < ASMREF_TMP1) { + emit_movmroi(as, RID_ESP, ofs, ir->i); + } else { + r = ra_alloc1(as, ref, RSET_GPR); + emit_movtomro(as, REX_64 + r, RID_ESP, ofs); + } + ofs += sizeof(intptr_t); + } + checkmclim(as); + } +#if LJ_64 && !LJ_ABI_WIN + if (patchnfpr) *patchnfpr = fpr - REGARG_FIRSTFPR; +#endif +} + +/* Setup result reg/sp for call. Evict scratch regs. */ +static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci) +{ + RegSet drop = RSET_SCRATCH; + int hiop = (LJ_32 && (ir+1)->o == IR_HIOP); + if ((ci->flags & CCI_NOFPRCLOBBER)) + drop &= ~RSET_FPR; + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + if (hiop && ra_hasreg((ir+1)->r)) + rset_clear(drop, (ir+1)->r); /* Dest reg handled below. */ + ra_evictset(as, drop); /* Evictions must be performed first. */ + if (ra_used(ir)) { + if (irt_isfp(ir->t)) { + int32_t ofs = sps_scale(ir->s); /* Use spill slot or temp slots. */ +#if LJ_64 + if ((ci->flags & CCI_CASTU64)) { + Reg dest = ir->r; + if (ra_hasreg(dest)) { + ra_free(as, dest); + ra_modified(as, dest); + emit_rr(as, XO_MOVD, dest|REX_64, RID_RET); /* Really MOVQ. */ + } + if (ofs) emit_movtomro(as, RID_RET|REX_64, RID_ESP, ofs); + } else { + ra_destreg(as, ir, RID_FPRET); + } +#else + /* Number result is in x87 st0 for x86 calling convention. */ + Reg dest = ir->r; + if (ra_hasreg(dest)) { + ra_free(as, dest); + ra_modified(as, dest); + emit_rmro(as, irt_isnum(ir->t) ? XMM_MOVRM(as) : XO_MOVSS, + dest, RID_ESP, ofs); + } + if ((ci->flags & CCI_CASTU64)) { + emit_movtomro(as, RID_RETLO, RID_ESP, ofs); + emit_movtomro(as, RID_RETHI, RID_ESP, ofs+4); + } else { + emit_rmro(as, irt_isnum(ir->t) ? XO_FSTPq : XO_FSTPd, + irt_isnum(ir->t) ? XOg_FSTPq : XOg_FSTPd, RID_ESP, ofs); + } +#endif +#if LJ_32 + } else if (hiop) { + ra_destpair(as, ir); +#endif + } else { + lua_assert(!irt_ispri(ir->t)); + ra_destreg(as, ir, RID_RET); + } + } else if (LJ_32 && irt_isfp(ir->t) && !(ci->flags & CCI_CASTU64)) { + emit_x87op(as, XI_FPOP); /* Pop unused result from x87 st0. */ + } +} + +static void asm_call(ASMState *as, IRIns *ir) +{ + IRRef args[CCI_NARGS_MAX]; + const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; + asm_collectargs(as, ir, ci, args); + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} + +/* Return a constant function pointer or NULL for indirect calls. */ +static void *asm_callx_func(ASMState *as, IRIns *irf, IRRef func) +{ +#if LJ_32 + UNUSED(as); + if (irref_isk(func)) + return (void *)irf->i; +#else + if (irref_isk(func)) { + MCode *p; + if (irf->o == IR_KINT64) + p = (MCode *)(void *)ir_k64(irf)->u64; + else + p = (MCode *)(void *)(uintptr_t)(uint32_t)irf->i; + if (p - as->mcp == (int32_t)(p - as->mcp)) + return p; /* Call target is still in +-2GB range. */ + /* Avoid the indirect case of emit_call(). Try to hoist func addr. */ + } +#endif + return NULL; +} + +static void asm_callx(ASMState *as, IRIns *ir) +{ + IRRef args[CCI_NARGS_MAX*2]; + CCallInfo ci; + IRRef func; + IRIns *irf; + int32_t spadj = 0; + ci.flags = asm_callx_flags(as, ir); + asm_collectargs(as, ir, &ci, args); + asm_setupresult(as, ir, &ci); +#if LJ_32 + /* Have to readjust stack after non-cdecl calls due to callee cleanup. */ + if ((ci.flags & CCI_CC_MASK) != CCI_CC_CDECL) + spadj = 4 * asm_count_call_slots(as, &ci, args); +#endif + func = ir->op2; irf = IR(func); + if (irf->o == IR_CARG) { func = irf->op1; irf = IR(func); } + ci.func = (ASMFunction)asm_callx_func(as, irf, func); + if (!(void *)ci.func) { + /* Use a (hoistable) non-scratch register for indirect calls. */ + RegSet allow = (RSET_GPR & ~RSET_SCRATCH); + Reg r = ra_alloc1(as, func, allow); + if (LJ_32) emit_spsub(as, spadj); /* Above code may cause restores! */ + emit_rr(as, XO_GROUP5, XOg_CALL, r); + } else if (LJ_32) { + emit_spsub(as, spadj); + } + asm_gencall(as, &ci, args); +} + +/* -- Returns ------------------------------------------------------------- */ + +/* Return to lower frame. Guard that it goes to the right spot. */ +static void asm_retf(ASMState *as, IRIns *ir) +{ + Reg base = ra_alloc1(as, REF_BASE, RSET_GPR); + void *pc = ir_kptr(IR(ir->op2)); + int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); + as->topslot -= (BCReg)delta; + if ((int32_t)as->topslot < 0) as->topslot = 0; + irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */ + emit_setgl(as, base, jit_base); + emit_addptr(as, base, -8*delta); + asm_guardcc(as, CC_NE); + emit_gmroi(as, XG_ARITHi(XOg_CMP), base, -4, ptr2addr(pc)); +} + +/* -- Type conversions ---------------------------------------------------- */ + +static void asm_tointg(ASMState *as, IRIns *ir, Reg left) +{ + Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); + Reg dest = ra_dest(as, ir, RSET_GPR); + asm_guardcc(as, CC_P); + asm_guardcc(as, CC_NE); + emit_rr(as, XO_UCOMISD, left, tmp); + emit_rr(as, XO_CVTSI2SD, tmp, dest); + if (!(as->flags & JIT_F_SPLIT_XMM)) + emit_rr(as, XO_XORPS, tmp, tmp); /* Avoid partial register stall. */ + emit_rr(as, XO_CVTTSD2SI, dest, left); + /* Can't fuse since left is needed twice. */ +} + +static void asm_tobit(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + Reg tmp = ra_noreg(IR(ir->op1)->r) ? + ra_alloc1(as, ir->op1, RSET_FPR) : + ra_scratch(as, RSET_FPR); + Reg right = asm_fuseload(as, ir->op2, rset_exclude(RSET_FPR, tmp)); + emit_rr(as, XO_MOVDto, tmp, dest); + emit_mrm(as, XO_ADDSD, tmp, right); + ra_left(as, tmp, ir->op1); +} + +static void asm_conv(ASMState *as, IRIns *ir) +{ + IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); + int st64 = (st == IRT_I64 || st == IRT_U64 || (LJ_64 && st == IRT_P64)); + int stfp = (st == IRT_NUM || st == IRT_FLOAT); + IRRef lref = ir->op1; + lua_assert(irt_type(ir->t) != st); + lua_assert(!(LJ_32 && (irt_isint64(ir->t) || st64))); /* Handled by SPLIT. */ + if (irt_isfp(ir->t)) { + Reg dest = ra_dest(as, ir, RSET_FPR); + if (stfp) { /* FP to FP conversion. */ + Reg left = asm_fuseload(as, lref, RSET_FPR); + emit_mrm(as, st == IRT_NUM ? XO_CVTSD2SS : XO_CVTSS2SD, dest, left); + if (left == dest) return; /* Avoid the XO_XORPS. */ + } else if (LJ_32 && st == IRT_U32) { /* U32 to FP conversion on x86. */ + /* number = (2^52+2^51 .. u32) - (2^52+2^51) */ + cTValue *k = lj_ir_k64_find(as->J, U64x(43380000,00000000)); + Reg bias = ra_scratch(as, rset_exclude(RSET_FPR, dest)); + if (irt_isfloat(ir->t)) + emit_rr(as, XO_CVTSD2SS, dest, dest); + emit_rr(as, XO_SUBSD, dest, bias); /* Subtract 2^52+2^51 bias. */ + emit_rr(as, XO_XORPS, dest, bias); /* Merge bias and integer. */ + emit_loadn(as, bias, k); + emit_mrm(as, XO_MOVD, dest, asm_fuseload(as, lref, RSET_GPR)); + return; + } else { /* Integer to FP conversion. */ + Reg left = (LJ_64 && (st == IRT_U32 || st == IRT_U64)) ? + ra_alloc1(as, lref, RSET_GPR) : + asm_fuseloadm(as, lref, RSET_GPR, st64); + if (LJ_64 && st == IRT_U64) { + MCLabel l_end = emit_label(as); + const void *k = lj_ir_k64_find(as->J, U64x(43f00000,00000000)); + emit_rma(as, XO_ADDSD, dest, k); /* Add 2^64 to compensate. */ + emit_sjcc(as, CC_NS, l_end); + emit_rr(as, XO_TEST, left|REX_64, left); /* Check if u64 >= 2^63. */ + } + emit_mrm(as, irt_isnum(ir->t) ? XO_CVTSI2SD : XO_CVTSI2SS, + dest|((LJ_64 && (st64 || st == IRT_U32)) ? REX_64 : 0), left); + } + if (!(as->flags & JIT_F_SPLIT_XMM)) + emit_rr(as, XO_XORPS, dest, dest); /* Avoid partial register stall. */ + } else if (stfp) { /* FP to integer conversion. */ + if (irt_isguard(ir->t)) { + /* Checked conversions are only supported from number to int. */ + lua_assert(irt_isint(ir->t) && st == IRT_NUM); + asm_tointg(as, ir, ra_alloc1(as, lref, RSET_FPR)); + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + x86Op op = st == IRT_NUM ? + ((ir->op2 & IRCONV_TRUNC) ? XO_CVTTSD2SI : XO_CVTSD2SI) : + ((ir->op2 & IRCONV_TRUNC) ? XO_CVTTSS2SI : XO_CVTSS2SI); + if (LJ_64 ? irt_isu64(ir->t) : irt_isu32(ir->t)) { + /* LJ_64: For inputs >= 2^63 add -2^64, convert again. */ + /* LJ_32: For inputs >= 2^31 add -2^31, convert again and add 2^31. */ + Reg tmp = ra_noreg(IR(lref)->r) ? ra_alloc1(as, lref, RSET_FPR) : + ra_scratch(as, RSET_FPR); + MCLabel l_end = emit_label(as); + if (LJ_32) + emit_gri(as, XG_ARITHi(XOg_ADD), dest, (int32_t)0x80000000); + emit_rr(as, op, dest|REX_64, tmp); + if (st == IRT_NUM) + emit_rma(as, XO_ADDSD, tmp, lj_ir_k64_find(as->J, + LJ_64 ? U64x(c3f00000,00000000) : U64x(c1e00000,00000000))); + else + emit_rma(as, XO_ADDSS, tmp, lj_ir_k64_find(as->J, + LJ_64 ? U64x(00000000,df800000) : U64x(00000000,cf000000))); + emit_sjcc(as, CC_NS, l_end); + emit_rr(as, XO_TEST, dest|REX_64, dest); /* Check if dest negative. */ + emit_rr(as, op, dest|REX_64, tmp); + ra_left(as, tmp, lref); + } else { + Reg left = asm_fuseload(as, lref, RSET_FPR); + if (LJ_64 && irt_isu32(ir->t)) + emit_rr(as, XO_MOV, dest, dest); /* Zero hiword. */ + emit_mrm(as, op, + dest|((LJ_64 && + (irt_is64(ir->t) || irt_isu32(ir->t))) ? REX_64 : 0), + left); + } + } + } else if (st >= IRT_I8 && st <= IRT_U16) { /* Extend to 32 bit integer. */ + Reg left, dest = ra_dest(as, ir, RSET_GPR); + RegSet allow = RSET_GPR; + x86Op op; + lua_assert(irt_isint(ir->t) || irt_isu32(ir->t)); + if (st == IRT_I8) { + op = XO_MOVSXb; allow = RSET_GPR8; dest |= FORCE_REX; + } else if (st == IRT_U8) { + op = XO_MOVZXb; allow = RSET_GPR8; dest |= FORCE_REX; + } else if (st == IRT_I16) { + op = XO_MOVSXw; + } else { + op = XO_MOVZXw; + } + left = asm_fuseload(as, lref, allow); + /* Add extra MOV if source is already in wrong register. */ + if (!LJ_64 && left != RID_MRM && !rset_test(allow, left)) { + Reg tmp = ra_scratch(as, allow); + emit_rr(as, op, dest, tmp); + emit_rr(as, XO_MOV, tmp, left); + } else { + emit_mrm(as, op, dest, left); + } + } else { /* 32/64 bit integer conversions. */ + if (LJ_32) { /* Only need to handle 32/32 bit no-op (cast) on x86. */ + Reg dest = ra_dest(as, ir, RSET_GPR); + ra_left(as, dest, lref); /* Do nothing, but may need to move regs. */ + } else if (irt_is64(ir->t)) { + Reg dest = ra_dest(as, ir, RSET_GPR); + if (st64 || !(ir->op2 & IRCONV_SEXT)) { + /* 64/64 bit no-op (cast) or 32 to 64 bit zero extension. */ + ra_left(as, dest, lref); /* Do nothing, but may need to move regs. */ + } else { /* 32 to 64 bit sign extension. */ + Reg left = asm_fuseload(as, lref, RSET_GPR); + emit_mrm(as, XO_MOVSXd, dest|REX_64, left); + } + } else { + Reg dest = ra_dest(as, ir, RSET_GPR); + if (st64) { + Reg left = asm_fuseload(as, lref, RSET_GPR); + /* This is either a 32 bit reg/reg mov which zeroes the hiword + ** or a load of the loword from a 64 bit address. + */ + emit_mrm(as, XO_MOV, dest, left); + } else { /* 32/32 bit no-op (cast). */ + ra_left(as, dest, lref); /* Do nothing, but may need to move regs. */ + } + } + } +} + +#if LJ_32 && LJ_HASFFI +/* No SSE conversions to/from 64 bit on x86, so resort to ugly x87 code. */ + +/* 64 bit integer to FP conversion in 32 bit mode. */ +static void asm_conv_fp_int64(ASMState *as, IRIns *ir) +{ + Reg hi = ra_alloc1(as, ir->op1, RSET_GPR); + Reg lo = ra_alloc1(as, (ir-1)->op1, rset_exclude(RSET_GPR, hi)); + int32_t ofs = sps_scale(ir->s); /* Use spill slot or temp slots. */ + Reg dest = ir->r; + if (ra_hasreg(dest)) { + ra_free(as, dest); + ra_modified(as, dest); + emit_rmro(as, irt_isnum(ir->t) ? XMM_MOVRM(as) : XO_MOVSS, + dest, RID_ESP, ofs); + } + emit_rmro(as, irt_isnum(ir->t) ? XO_FSTPq : XO_FSTPd, + irt_isnum(ir->t) ? XOg_FSTPq : XOg_FSTPd, RID_ESP, ofs); + if (((ir-1)->op2 & IRCONV_SRCMASK) == IRT_U64) { + /* For inputs in [2^63,2^64-1] add 2^64 to compensate. */ + MCLabel l_end = emit_label(as); + emit_rma(as, XO_FADDq, XOg_FADDq, + lj_ir_k64_find(as->J, U64x(43f00000,00000000))); + emit_sjcc(as, CC_NS, l_end); + emit_rr(as, XO_TEST, hi, hi); /* Check if u64 >= 2^63. */ + } else { + lua_assert(((ir-1)->op2 & IRCONV_SRCMASK) == IRT_I64); + } + emit_rmro(as, XO_FILDq, XOg_FILDq, RID_ESP, 0); + /* NYI: Avoid narrow-to-wide store-to-load forwarding stall. */ + emit_rmro(as, XO_MOVto, hi, RID_ESP, 4); + emit_rmro(as, XO_MOVto, lo, RID_ESP, 0); +} + +/* FP to 64 bit integer conversion in 32 bit mode. */ +static void asm_conv_int64_fp(ASMState *as, IRIns *ir) +{ + IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK); + IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH); + Reg lo, hi; + lua_assert(st == IRT_NUM || st == IRT_FLOAT); + lua_assert(dt == IRT_I64 || dt == IRT_U64); + lua_assert(((ir-1)->op2 & IRCONV_TRUNC)); + hi = ra_dest(as, ir, RSET_GPR); + lo = ra_dest(as, ir-1, rset_exclude(RSET_GPR, hi)); + if (ra_used(ir-1)) emit_rmro(as, XO_MOV, lo, RID_ESP, 0); + /* NYI: Avoid wide-to-narrow store-to-load forwarding stall. */ + if (!(as->flags & JIT_F_SSE3)) { /* Set FPU rounding mode to default. */ + emit_rmro(as, XO_FLDCW, XOg_FLDCW, RID_ESP, 4); + emit_rmro(as, XO_MOVto, lo, RID_ESP, 4); + emit_gri(as, XG_ARITHi(XOg_AND), lo, 0xf3ff); + } + if (dt == IRT_U64) { + /* For inputs in [2^63,2^64-1] add -2^64 and convert again. */ + MCLabel l_pop, l_end = emit_label(as); + emit_x87op(as, XI_FPOP); + l_pop = emit_label(as); + emit_sjmp(as, l_end); + emit_rmro(as, XO_MOV, hi, RID_ESP, 4); + if ((as->flags & JIT_F_SSE3)) + emit_rmro(as, XO_FISTTPq, XOg_FISTTPq, RID_ESP, 0); + else + emit_rmro(as, XO_FISTPq, XOg_FISTPq, RID_ESP, 0); + emit_rma(as, XO_FADDq, XOg_FADDq, + lj_ir_k64_find(as->J, U64x(c3f00000,00000000))); + emit_sjcc(as, CC_NS, l_pop); + emit_rr(as, XO_TEST, hi, hi); /* Check if out-of-range (2^63). */ + } + emit_rmro(as, XO_MOV, hi, RID_ESP, 4); + if ((as->flags & JIT_F_SSE3)) { /* Truncation is easy with SSE3. */ + emit_rmro(as, XO_FISTTPq, XOg_FISTTPq, RID_ESP, 0); + } else { /* Otherwise set FPU rounding mode to truncate before the store. */ + emit_rmro(as, XO_FISTPq, XOg_FISTPq, RID_ESP, 0); + emit_rmro(as, XO_FLDCW, XOg_FLDCW, RID_ESP, 0); + emit_rmro(as, XO_MOVtow, lo, RID_ESP, 0); + emit_rmro(as, XO_ARITHw(XOg_OR), lo, RID_ESP, 0); + emit_loadi(as, lo, 0xc00); + emit_rmro(as, XO_FNSTCW, XOg_FNSTCW, RID_ESP, 0); + } + if (dt == IRT_U64) + emit_x87op(as, XI_FDUP); + emit_mrm(as, st == IRT_NUM ? XO_FLDq : XO_FLDd, + st == IRT_NUM ? XOg_FLDq: XOg_FLDd, + asm_fuseload(as, ir->op1, RSET_EMPTY)); +} +#endif + +static void asm_strto(ASMState *as, IRIns *ir) +{ + /* Force a spill slot for the destination register (if any). */ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_strscan_num]; + IRRef args[2]; + RegSet drop = RSET_SCRATCH; + if ((drop & RSET_FPR) != RSET_FPR && ra_hasreg(ir->r)) + rset_set(drop, ir->r); /* WIN64 doesn't spill all FPRs. */ + ra_evictset(as, drop); + asm_guardcc(as, CC_E); + emit_rr(as, XO_TEST, RID_RET, RID_RET); /* Test return status. */ + args[0] = ir->op1; /* GCstr *str */ + args[1] = ASMREF_TMP1; /* TValue *n */ + asm_gencall(as, ci, args); + /* Store the result to the spill slot or temp slots. */ + emit_rmro(as, XO_LEA, ra_releasetmp(as, ASMREF_TMP1)|REX_64, + RID_ESP, sps_scale(ir->s)); +} + +static void asm_tostr(ASMState *as, IRIns *ir) +{ + IRIns *irl = IR(ir->op1); + IRRef args[2]; + args[0] = ASMREF_L; + as->gcsteps++; + if (irt_isnum(irl->t)) { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromnum]; + args[1] = ASMREF_TMP1; /* const lua_Number * */ + asm_setupresult(as, ir, ci); /* GCstr * */ + asm_gencall(as, ci, args); + emit_rmro(as, XO_LEA, ra_releasetmp(as, ASMREF_TMP1)|REX_64, + RID_ESP, ra_spill(as, irl)); + } else { + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromint]; + args[1] = ir->op1; /* int32_t k */ + asm_setupresult(as, ir, ci); /* GCstr * */ + asm_gencall(as, ci, args); + } +} + +/* -- Memory references --------------------------------------------------- */ + +static void asm_aref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + asm_fusearef(as, ir, RSET_GPR); + if (!(as->mrm.idx == RID_NONE && as->mrm.ofs == 0)) + emit_mrm(as, XO_LEA, dest, RID_MRM); + else if (as->mrm.base != dest) + emit_rr(as, XO_MOV, dest, as->mrm.base); +} + +/* Merge NE(HREF, niltv) check. */ +static MCode *merge_href_niltv(ASMState *as, IRIns *ir) +{ + /* Assumes nothing else generates NE of HREF. */ + if ((ir[1].o == IR_NE || ir[1].o == IR_EQ) && ir[1].op1 == as->curins && + ra_hasreg(ir->r)) { + MCode *p = as->mcp; + p += (LJ_64 && *p != XI_ARITHi) ? 7+6 : 6+6; + /* Ensure no loop branch inversion happened. */ + if (p[-6] == 0x0f && p[-5] == XI_JCCn+(CC_NE^(ir[1].o & 1))) { + as->mcp = p; /* Kill cmp reg, imm32 + jz exit. */ + return p + *(int32_t *)(p-4); /* Return exit address. */ + } + } + return NULL; +} + +/* Inlined hash lookup. Specialized for key type and for const keys. +** The equivalent C code is: +** Node *n = hashkey(t, key); +** do { +** if (lj_obj_equal(&n->key, key)) return &n->val; +** } while ((n = nextnode(n))); +** return niltv(L); +*/ +static void asm_href(ASMState *as, IRIns *ir) +{ + MCode *nilexit = merge_href_niltv(as, ir); /* Do this before any restores. */ + RegSet allow = RSET_GPR; + Reg dest = ra_dest(as, ir, allow); + Reg tab = ra_alloc1(as, ir->op1, rset_clear(allow, dest)); + Reg key = RID_NONE, tmp = RID_NONE; + IRIns *irkey = IR(ir->op2); + int isk = irref_isk(ir->op2); + IRType1 kt = irkey->t; + uint32_t khash; + MCLabel l_end, l_loop, l_next; + + if (!isk) { + rset_clear(allow, tab); + key = ra_alloc1(as, ir->op2, irt_isnum(kt) ? RSET_FPR : allow); + if (!irt_isstr(kt)) + tmp = ra_scratch(as, rset_exclude(allow, key)); + } + + /* Key not found in chain: jump to exit (if merged with NE) or load niltv. */ + l_end = emit_label(as); + if (nilexit && ir[1].o == IR_NE) { + emit_jcc(as, CC_E, nilexit); /* XI_JMP is not found by lj_asm_patchexit. */ + nilexit = NULL; + } else { + emit_loada(as, dest, niltvg(J2G(as->J))); + } + + /* Follow hash chain until the end. */ + l_loop = emit_sjcc_label(as, CC_NZ); + emit_rr(as, XO_TEST, dest, dest); + emit_rmro(as, XO_MOV, dest, dest, offsetof(Node, next)); + l_next = emit_label(as); + + /* Type and value comparison. */ + if (nilexit) + emit_jcc(as, CC_E, nilexit); + else + emit_sjcc(as, CC_E, l_end); + if (irt_isnum(kt)) { + if (isk) { + /* Assumes -0.0 is already canonicalized to +0.0. */ + emit_gmroi(as, XG_ARITHi(XOg_CMP), dest, offsetof(Node, key.u32.lo), + (int32_t)ir_knum(irkey)->u32.lo); + emit_sjcc(as, CC_NE, l_next); + emit_gmroi(as, XG_ARITHi(XOg_CMP), dest, offsetof(Node, key.u32.hi), + (int32_t)ir_knum(irkey)->u32.hi); + } else { + emit_sjcc(as, CC_P, l_next); + emit_rmro(as, XO_UCOMISD, key, dest, offsetof(Node, key.n)); + emit_sjcc(as, CC_AE, l_next); + /* The type check avoids NaN penalties and complaints from Valgrind. */ +#if LJ_64 + emit_u32(as, LJ_TISNUM); + emit_rmro(as, XO_ARITHi, XOg_CMP, dest, offsetof(Node, key.it)); +#else + emit_i8(as, LJ_TISNUM); + emit_rmro(as, XO_ARITHi8, XOg_CMP, dest, offsetof(Node, key.it)); +#endif + } +#if LJ_64 + } else if (irt_islightud(kt)) { + emit_rmro(as, XO_CMP, key|REX_64, dest, offsetof(Node, key.u64)); +#endif + } else { + if (!irt_ispri(kt)) { + lua_assert(irt_isaddr(kt)); + if (isk) + emit_gmroi(as, XG_ARITHi(XOg_CMP), dest, offsetof(Node, key.gcr), + ptr2addr(ir_kgc(irkey))); + else + emit_rmro(as, XO_CMP, key, dest, offsetof(Node, key.gcr)); + emit_sjcc(as, CC_NE, l_next); + } + lua_assert(!irt_isnil(kt)); + emit_i8(as, irt_toitype(kt)); + emit_rmro(as, XO_ARITHi8, XOg_CMP, dest, offsetof(Node, key.it)); + } + emit_sfixup(as, l_loop); + checkmclim(as); + + /* Load main position relative to tab->node into dest. */ + khash = isk ? ir_khash(irkey) : 1; + if (khash == 0) { + emit_rmro(as, XO_MOV, dest, tab, offsetof(GCtab, node)); + } else { + emit_rmro(as, XO_ARITH(XOg_ADD), dest, tab, offsetof(GCtab, node)); + if ((as->flags & JIT_F_PREFER_IMUL)) { + emit_i8(as, sizeof(Node)); + emit_rr(as, XO_IMULi8, dest, dest); + } else { + emit_shifti(as, XOg_SHL, dest, 3); + emit_rmrxo(as, XO_LEA, dest, dest, dest, XM_SCALE2, 0); + } + if (isk) { + emit_gri(as, XG_ARITHi(XOg_AND), dest, (int32_t)khash); + emit_rmro(as, XO_MOV, dest, tab, offsetof(GCtab, hmask)); + } else if (irt_isstr(kt)) { + emit_rmro(as, XO_ARITH(XOg_AND), dest, key, offsetof(GCstr, hash)); + emit_rmro(as, XO_MOV, dest, tab, offsetof(GCtab, hmask)); + } else { /* Must match with hashrot() in lj_tab.c. */ + emit_rmro(as, XO_ARITH(XOg_AND), dest, tab, offsetof(GCtab, hmask)); + emit_rr(as, XO_ARITH(XOg_SUB), dest, tmp); + emit_shifti(as, XOg_ROL, tmp, HASH_ROT3); + emit_rr(as, XO_ARITH(XOg_XOR), dest, tmp); + emit_shifti(as, XOg_ROL, dest, HASH_ROT2); + emit_rr(as, XO_ARITH(XOg_SUB), tmp, dest); + emit_shifti(as, XOg_ROL, dest, HASH_ROT1); + emit_rr(as, XO_ARITH(XOg_XOR), tmp, dest); + if (irt_isnum(kt)) { + emit_rr(as, XO_ARITH(XOg_ADD), dest, dest); +#if LJ_64 + emit_shifti(as, XOg_SHR|REX_64, dest, 32); + emit_rr(as, XO_MOV, tmp, dest); + emit_rr(as, XO_MOVDto, key|REX_64, dest); +#else + emit_rmro(as, XO_MOV, dest, RID_ESP, ra_spill(as, irkey)+4); + emit_rr(as, XO_MOVDto, key, tmp); +#endif + } else { + emit_rr(as, XO_MOV, tmp, key); + emit_rmro(as, XO_LEA, dest, key, HASH_BIAS); + } + } + } +} + +static void asm_hrefk(ASMState *as, IRIns *ir) +{ + IRIns *kslot = IR(ir->op2); + IRIns *irkey = IR(kslot->op1); + int32_t ofs = (int32_t)(kslot->op2 * sizeof(Node)); + Reg dest = ra_used(ir) ? ra_dest(as, ir, RSET_GPR) : RID_NONE; + Reg node = ra_alloc1(as, ir->op1, RSET_GPR); +#if !LJ_64 + MCLabel l_exit; +#endif + lua_assert(ofs % sizeof(Node) == 0); + if (ra_hasreg(dest)) { + if (ofs != 0) { + if (dest == node && !(as->flags & JIT_F_LEA_AGU)) + emit_gri(as, XG_ARITHi(XOg_ADD), dest, ofs); + else + emit_rmro(as, XO_LEA, dest, node, ofs); + } else if (dest != node) { + emit_rr(as, XO_MOV, dest, node); + } + } + asm_guardcc(as, CC_NE); +#if LJ_64 + if (!irt_ispri(irkey->t)) { + Reg key = ra_scratch(as, rset_exclude(RSET_GPR, node)); + emit_rmro(as, XO_CMP, key|REX_64, node, + ofs + (int32_t)offsetof(Node, key.u64)); + lua_assert(irt_isnum(irkey->t) || irt_isgcv(irkey->t)); + /* Assumes -0.0 is already canonicalized to +0.0. */ + emit_loadu64(as, key, irt_isnum(irkey->t) ? ir_knum(irkey)->u64 : + ((uint64_t)irt_toitype(irkey->t) << 32) | + (uint64_t)(uint32_t)ptr2addr(ir_kgc(irkey))); + } else { + lua_assert(!irt_isnil(irkey->t)); + emit_i8(as, irt_toitype(irkey->t)); + emit_rmro(as, XO_ARITHi8, XOg_CMP, node, + ofs + (int32_t)offsetof(Node, key.it)); + } +#else + l_exit = emit_label(as); + if (irt_isnum(irkey->t)) { + /* Assumes -0.0 is already canonicalized to +0.0. */ + emit_gmroi(as, XG_ARITHi(XOg_CMP), node, + ofs + (int32_t)offsetof(Node, key.u32.lo), + (int32_t)ir_knum(irkey)->u32.lo); + emit_sjcc(as, CC_NE, l_exit); + emit_gmroi(as, XG_ARITHi(XOg_CMP), node, + ofs + (int32_t)offsetof(Node, key.u32.hi), + (int32_t)ir_knum(irkey)->u32.hi); + } else { + if (!irt_ispri(irkey->t)) { + lua_assert(irt_isgcv(irkey->t)); + emit_gmroi(as, XG_ARITHi(XOg_CMP), node, + ofs + (int32_t)offsetof(Node, key.gcr), + ptr2addr(ir_kgc(irkey))); + emit_sjcc(as, CC_NE, l_exit); + } + lua_assert(!irt_isnil(irkey->t)); + emit_i8(as, irt_toitype(irkey->t)); + emit_rmro(as, XO_ARITHi8, XOg_CMP, node, + ofs + (int32_t)offsetof(Node, key.it)); + } +#endif +} + +static void asm_newref(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_newkey]; + IRRef args[3]; + IRIns *irkey; + Reg tmp; + if (ir->r == RID_SINK) + return; + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ir->op1; /* GCtab *t */ + args[2] = ASMREF_TMP1; /* cTValue *key */ + asm_setupresult(as, ir, ci); /* TValue * */ + asm_gencall(as, ci, args); + tmp = ra_releasetmp(as, ASMREF_TMP1); + irkey = IR(ir->op2); + if (irt_isnum(irkey->t)) { + /* For numbers use the constant itself or a spill slot as a TValue. */ + if (irref_isk(ir->op2)) + emit_loada(as, tmp, ir_knum(irkey)); + else + emit_rmro(as, XO_LEA, tmp|REX_64, RID_ESP, ra_spill(as, irkey)); + } else { + /* Otherwise use g->tmptv to hold the TValue. */ + if (!irref_isk(ir->op2)) { + Reg src = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, tmp)); + emit_movtomro(as, REX_64IR(irkey, src), tmp, 0); + } else if (!irt_ispri(irkey->t)) { + emit_movmroi(as, tmp, 0, irkey->i); + } + if (!(LJ_64 && irt_islightud(irkey->t))) + emit_movmroi(as, tmp, 4, irt_toitype(irkey->t)); + emit_loada(as, tmp, &J2G(as->J)->tmptv); + } +} + +static void asm_uref(ASMState *as, IRIns *ir) +{ + /* NYI: Check that UREFO is still open and not aliasing a slot. */ + Reg dest = ra_dest(as, ir, RSET_GPR); + if (irref_isk(ir->op1)) { + GCfunc *fn = ir_kfunc(IR(ir->op1)); + MRef *v = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.v; + emit_rma(as, XO_MOV, dest, v); + } else { + Reg uv = ra_scratch(as, RSET_GPR); + Reg func = ra_alloc1(as, ir->op1, RSET_GPR); + if (ir->o == IR_UREFC) { + emit_rmro(as, XO_LEA, dest, uv, offsetof(GCupval, tv)); + asm_guardcc(as, CC_NE); + emit_i8(as, 1); + emit_rmro(as, XO_ARITHib, XOg_CMP, uv, offsetof(GCupval, closed)); + } else { + emit_rmro(as, XO_MOV, dest, uv, offsetof(GCupval, v)); + } + emit_rmro(as, XO_MOV, uv, func, + (int32_t)offsetof(GCfuncL, uvptr) + 4*(int32_t)(ir->op2 >> 8)); + } +} + +static void asm_fref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + asm_fusefref(as, ir, RSET_GPR); + emit_mrm(as, XO_LEA, dest, RID_MRM); +} + +static void asm_strref(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + asm_fusestrref(as, ir, RSET_GPR); + if (as->mrm.base == RID_NONE) + emit_loadi(as, dest, as->mrm.ofs); + else if (as->mrm.base == dest && as->mrm.idx == RID_NONE) + emit_gri(as, XG_ARITHi(XOg_ADD), dest, as->mrm.ofs); + else + emit_mrm(as, XO_LEA, dest, RID_MRM); +} + +/* -- Loads and stores ---------------------------------------------------- */ + +static void asm_fxload(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); + x86Op xo; + if (ir->o == IR_FLOAD) + asm_fusefref(as, ir, RSET_GPR); + else + asm_fusexref(as, ir->op1, RSET_GPR); + /* ir->op2 is ignored -- unaligned loads are ok on x86. */ + switch (irt_type(ir->t)) { + case IRT_I8: xo = XO_MOVSXb; break; + case IRT_U8: xo = XO_MOVZXb; break; + case IRT_I16: xo = XO_MOVSXw; break; + case IRT_U16: xo = XO_MOVZXw; break; + case IRT_NUM: xo = XMM_MOVRM(as); break; + case IRT_FLOAT: xo = XO_MOVSS; break; + default: + if (LJ_64 && irt_is64(ir->t)) + dest |= REX_64; + else + lua_assert(irt_isint(ir->t) || irt_isu32(ir->t) || irt_isaddr(ir->t)); + xo = XO_MOV; + break; + } + emit_mrm(as, xo, dest, RID_MRM); +} + +static void asm_fxstore(ASMState *as, IRIns *ir) +{ + RegSet allow = RSET_GPR; + Reg src = RID_NONE, osrc = RID_NONE; + int32_t k = 0; + if (ir->r == RID_SINK) + return; + /* The IRT_I16/IRT_U16 stores should never be simplified for constant + ** values since mov word [mem], imm16 has a length-changing prefix. + */ + if (irt_isi16(ir->t) || irt_isu16(ir->t) || irt_isfp(ir->t) || + !asm_isk32(as, ir->op2, &k)) { + RegSet allow8 = irt_isfp(ir->t) ? RSET_FPR : + (irt_isi8(ir->t) || irt_isu8(ir->t)) ? RSET_GPR8 : RSET_GPR; + src = osrc = ra_alloc1(as, ir->op2, allow8); + if (!LJ_64 && !rset_test(allow8, src)) { /* Already in wrong register. */ + rset_clear(allow, osrc); + src = ra_scratch(as, allow8); + } + rset_clear(allow, src); + } + if (ir->o == IR_FSTORE) { + asm_fusefref(as, IR(ir->op1), allow); + } else { + asm_fusexref(as, ir->op1, allow); + if (LJ_32 && ir->o == IR_HIOP) as->mrm.ofs += 4; + } + if (ra_hasreg(src)) { + x86Op xo; + switch (irt_type(ir->t)) { + case IRT_I8: case IRT_U8: xo = XO_MOVtob; src |= FORCE_REX; break; + case IRT_I16: case IRT_U16: xo = XO_MOVtow; break; + case IRT_NUM: xo = XO_MOVSDto; break; + case IRT_FLOAT: xo = XO_MOVSSto; break; +#if LJ_64 + case IRT_LIGHTUD: lua_assert(0); /* NYI: mask 64 bit lightuserdata. */ +#endif + default: + if (LJ_64 && irt_is64(ir->t)) + src |= REX_64; + else + lua_assert(irt_isint(ir->t) || irt_isu32(ir->t) || irt_isaddr(ir->t)); + xo = XO_MOVto; + break; + } + emit_mrm(as, xo, src, RID_MRM); + if (!LJ_64 && src != osrc) { + ra_noweak(as, osrc); + emit_rr(as, XO_MOV, src, osrc); + } + } else { + if (irt_isi8(ir->t) || irt_isu8(ir->t)) { + emit_i8(as, k); + emit_mrm(as, XO_MOVmib, 0, RID_MRM); + } else { + lua_assert(irt_is64(ir->t) || irt_isint(ir->t) || irt_isu32(ir->t) || + irt_isaddr(ir->t)); + emit_i32(as, k); + emit_mrm(as, XO_MOVmi, REX_64IR(ir, 0), RID_MRM); + } + } +} + +#if LJ_64 +static Reg asm_load_lightud64(ASMState *as, IRIns *ir, int typecheck) +{ + if (ra_used(ir) || typecheck) { + Reg dest = ra_dest(as, ir, RSET_GPR); + if (typecheck) { + Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, dest)); + asm_guardcc(as, CC_NE); + emit_i8(as, -2); + emit_rr(as, XO_ARITHi8, XOg_CMP, tmp); + emit_shifti(as, XOg_SAR|REX_64, tmp, 47); + emit_rr(as, XO_MOV, tmp|REX_64, dest); + } + return dest; + } else { + return RID_NONE; + } +} +#endif + +static void asm_ahuvload(ASMState *as, IRIns *ir) +{ + lua_assert(irt_isnum(ir->t) || irt_ispri(ir->t) || irt_isaddr(ir->t) || + (LJ_DUALNUM && irt_isint(ir->t))); +#if LJ_64 + if (irt_islightud(ir->t)) { + Reg dest = asm_load_lightud64(as, ir, 1); + if (ra_hasreg(dest)) { + asm_fuseahuref(as, ir->op1, RSET_GPR); + emit_mrm(as, XO_MOV, dest|REX_64, RID_MRM); + } + return; + } else +#endif + if (ra_used(ir)) { + RegSet allow = irt_isnum(ir->t) ? RSET_FPR : RSET_GPR; + Reg dest = ra_dest(as, ir, allow); + asm_fuseahuref(as, ir->op1, RSET_GPR); + emit_mrm(as, dest < RID_MAX_GPR ? XO_MOV : XMM_MOVRM(as), dest, RID_MRM); + } else { + asm_fuseahuref(as, ir->op1, RSET_GPR); + } + /* Always do the type check, even if the load result is unused. */ + as->mrm.ofs += 4; + asm_guardcc(as, irt_isnum(ir->t) ? CC_AE : CC_NE); + if (LJ_64 && irt_type(ir->t) >= IRT_NUM) { + lua_assert(irt_isinteger(ir->t) || irt_isnum(ir->t)); + emit_u32(as, LJ_TISNUM); + emit_mrm(as, XO_ARITHi, XOg_CMP, RID_MRM); + } else { + emit_i8(as, irt_toitype(ir->t)); + emit_mrm(as, XO_ARITHi8, XOg_CMP, RID_MRM); + } +} + +static void asm_ahustore(ASMState *as, IRIns *ir) +{ + if (ir->r == RID_SINK) + return; + if (irt_isnum(ir->t)) { + Reg src = ra_alloc1(as, ir->op2, RSET_FPR); + asm_fuseahuref(as, ir->op1, RSET_GPR); + emit_mrm(as, XO_MOVSDto, src, RID_MRM); +#if LJ_64 + } else if (irt_islightud(ir->t)) { + Reg src = ra_alloc1(as, ir->op2, RSET_GPR); + asm_fuseahuref(as, ir->op1, rset_exclude(RSET_GPR, src)); + emit_mrm(as, XO_MOVto, src|REX_64, RID_MRM); +#endif + } else { + IRIns *irr = IR(ir->op2); + RegSet allow = RSET_GPR; + Reg src = RID_NONE; + if (!irref_isk(ir->op2)) { + src = ra_alloc1(as, ir->op2, allow); + rset_clear(allow, src); + } + asm_fuseahuref(as, ir->op1, allow); + if (ra_hasreg(src)) { + emit_mrm(as, XO_MOVto, src, RID_MRM); + } else if (!irt_ispri(irr->t)) { + lua_assert(irt_isaddr(ir->t) || (LJ_DUALNUM && irt_isinteger(ir->t))); + emit_i32(as, irr->i); + emit_mrm(as, XO_MOVmi, 0, RID_MRM); + } + as->mrm.ofs += 4; + emit_i32(as, (int32_t)irt_toitype(ir->t)); + emit_mrm(as, XO_MOVmi, 0, RID_MRM); + } +} + +static void asm_sload(ASMState *as, IRIns *ir) +{ + int32_t ofs = 8*((int32_t)ir->op1-1) + ((ir->op2 & IRSLOAD_FRAME) ? 4 : 0); + IRType1 t = ir->t; + Reg base; + lua_assert(!(ir->op2 & IRSLOAD_PARENT)); /* Handled by asm_head_side(). */ + lua_assert(irt_isguard(t) || !(ir->op2 & IRSLOAD_TYPECHECK)); + lua_assert(LJ_DUALNUM || + !irt_isint(t) || (ir->op2 & (IRSLOAD_CONVERT|IRSLOAD_FRAME))); + if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(t) && irt_isint(t)) { + Reg left = ra_scratch(as, RSET_FPR); + asm_tointg(as, ir, left); /* Frees dest reg. Do this before base alloc. */ + base = ra_alloc1(as, REF_BASE, RSET_GPR); + emit_rmro(as, XMM_MOVRM(as), left, base, ofs); + t.irt = IRT_NUM; /* Continue with a regular number type check. */ +#if LJ_64 + } else if (irt_islightud(t)) { + Reg dest = asm_load_lightud64(as, ir, (ir->op2 & IRSLOAD_TYPECHECK)); + if (ra_hasreg(dest)) { + base = ra_alloc1(as, REF_BASE, RSET_GPR); + emit_rmro(as, XO_MOV, dest|REX_64, base, ofs); + } + return; +#endif + } else if (ra_used(ir)) { + RegSet allow = irt_isnum(t) ? RSET_FPR : RSET_GPR; + Reg dest = ra_dest(as, ir, allow); + base = ra_alloc1(as, REF_BASE, RSET_GPR); + lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); + if ((ir->op2 & IRSLOAD_CONVERT)) { + t.irt = irt_isint(t) ? IRT_NUM : IRT_INT; /* Check for original type. */ + emit_rmro(as, irt_isint(t) ? XO_CVTSI2SD : XO_CVTSD2SI, dest, base, ofs); + } else if (irt_isnum(t)) { + emit_rmro(as, XMM_MOVRM(as), dest, base, ofs); + } else { + emit_rmro(as, XO_MOV, dest, base, ofs); + } + } else { + if (!(ir->op2 & IRSLOAD_TYPECHECK)) + return; /* No type check: avoid base alloc. */ + base = ra_alloc1(as, REF_BASE, RSET_GPR); + } + if ((ir->op2 & IRSLOAD_TYPECHECK)) { + /* Need type check, even if the load result is unused. */ + asm_guardcc(as, irt_isnum(t) ? CC_AE : CC_NE); + if (LJ_64 && irt_type(t) >= IRT_NUM) { + lua_assert(irt_isinteger(t) || irt_isnum(t)); + emit_u32(as, LJ_TISNUM); + emit_rmro(as, XO_ARITHi, XOg_CMP, base, ofs+4); + } else { + emit_i8(as, irt_toitype(t)); + emit_rmro(as, XO_ARITHi8, XOg_CMP, base, ofs+4); + } + } +} + +/* -- Allocations --------------------------------------------------------- */ + +#if LJ_HASFFI +static void asm_cnew(ASMState *as, IRIns *ir) +{ + CTState *cts = ctype_ctsG(J2G(as->J)); + CTypeID ctypeid = (CTypeID)IR(ir->op1)->i; + CTSize sz = (ir->o == IR_CNEWI || ir->op2 == REF_NIL) ? + lj_ctype_size(cts, ctypeid) : (CTSize)IR(ir->op2)->i; + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco]; + IRRef args[2]; + lua_assert(sz != CTSIZE_INVALID); + + args[0] = ASMREF_L; /* lua_State *L */ + args[1] = ASMREF_TMP1; /* MSize size */ + as->gcsteps++; + asm_setupresult(as, ir, ci); /* GCcdata * */ + + /* Initialize immutable cdata object. */ + if (ir->o == IR_CNEWI) { + RegSet allow = (RSET_GPR & ~RSET_SCRATCH); +#if LJ_64 + Reg r64 = sz == 8 ? REX_64 : 0; + if (irref_isk(ir->op2)) { + IRIns *irk = IR(ir->op2); + uint64_t k = irk->o == IR_KINT64 ? ir_k64(irk)->u64 : + (uint64_t)(uint32_t)irk->i; + if (sz == 4 || checki32((int64_t)k)) { + emit_i32(as, (int32_t)k); + emit_rmro(as, XO_MOVmi, r64, RID_RET, sizeof(GCcdata)); + } else { + emit_movtomro(as, RID_ECX + r64, RID_RET, sizeof(GCcdata)); + emit_loadu64(as, RID_ECX, k); + } + } else { + Reg r = ra_alloc1(as, ir->op2, allow); + emit_movtomro(as, r + r64, RID_RET, sizeof(GCcdata)); + } +#else + int32_t ofs = sizeof(GCcdata); + if (sz == 8) { + ofs += 4; ir++; + lua_assert(ir->o == IR_HIOP); + } + do { + if (irref_isk(ir->op2)) { + emit_movmroi(as, RID_RET, ofs, IR(ir->op2)->i); + } else { + Reg r = ra_alloc1(as, ir->op2, allow); + emit_movtomro(as, r, RID_RET, ofs); + rset_clear(allow, r); + } + if (ofs == sizeof(GCcdata)) break; + ofs -= 4; ir--; + } while (1); +#endif + lua_assert(sz == 4 || sz == 8); + } + + /* Combine initialization of marked, gct and ctypeid. */ + emit_movtomro(as, RID_ECX, RID_RET, offsetof(GCcdata, marked)); + emit_gri(as, XG_ARITHi(XOg_OR), RID_ECX, + (int32_t)((~LJ_TCDATA<<8)+(ctypeid<<16))); + emit_gri(as, XG_ARITHi(XOg_AND), RID_ECX, LJ_GC_WHITES); + emit_opgl(as, XO_MOVZXb, RID_ECX, gc.currentwhite); + + asm_gencall(as, ci, args); + emit_loadi(as, ra_releasetmp(as, ASMREF_TMP1), (int32_t)(sz+sizeof(GCcdata))); +} +#else +#define asm_cnew(as, ir) ((void)0) +#endif + +/* -- Write barriers ------------------------------------------------------ */ + +static void asm_tbar(ASMState *as, IRIns *ir) +{ + Reg tab = ra_alloc1(as, ir->op1, RSET_GPR); + Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, tab)); + MCLabel l_end = emit_label(as); + emit_movtomro(as, tmp, tab, offsetof(GCtab, gclist)); + emit_setgl(as, tab, gc.grayagain); + emit_getgl(as, tmp, gc.grayagain); + emit_i8(as, ~LJ_GC_BLACK); + emit_rmro(as, XO_ARITHib, XOg_AND, tab, offsetof(GCtab, marked)); + emit_sjcc(as, CC_Z, l_end); + emit_i8(as, LJ_GC_BLACK); + emit_rmro(as, XO_GROUP3b, XOg_TEST, tab, offsetof(GCtab, marked)); +} + +static void asm_obar(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_barrieruv]; + IRRef args[2]; + MCLabel l_end; + Reg obj; + /* No need for other object barriers (yet). */ + lua_assert(IR(ir->op1)->o == IR_UREFC); + ra_evictset(as, RSET_SCRATCH); + l_end = emit_label(as); + args[0] = ASMREF_TMP1; /* global_State *g */ + args[1] = ir->op1; /* TValue *tv */ + asm_gencall(as, ci, args); + emit_loada(as, ra_releasetmp(as, ASMREF_TMP1), J2G(as->J)); + obj = IR(ir->op1)->r; + emit_sjcc(as, CC_Z, l_end); + emit_i8(as, LJ_GC_WHITES); + if (irref_isk(ir->op2)) { + GCobj *vp = ir_kgc(IR(ir->op2)); + emit_rma(as, XO_GROUP3b, XOg_TEST, &vp->gch.marked); + } else { + Reg val = ra_alloc1(as, ir->op2, rset_exclude(RSET_SCRATCH&RSET_GPR, obj)); + emit_rmro(as, XO_GROUP3b, XOg_TEST, val, (int32_t)offsetof(GChead, marked)); + } + emit_sjcc(as, CC_Z, l_end); + emit_i8(as, LJ_GC_BLACK); + emit_rmro(as, XO_GROUP3b, XOg_TEST, obj, + (int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)); +} + +/* -- FP/int arithmetic and logic operations ------------------------------ */ + +/* Load reference onto x87 stack. Force a spill to memory if needed. */ +static void asm_x87load(ASMState *as, IRRef ref) +{ + IRIns *ir = IR(ref); + if (ir->o == IR_KNUM) { + cTValue *tv = ir_knum(ir); + if (tvispzero(tv)) /* Use fldz only for +0. */ + emit_x87op(as, XI_FLDZ); + else if (tvispone(tv)) + emit_x87op(as, XI_FLD1); + else + emit_rma(as, XO_FLDq, XOg_FLDq, tv); + } else if (ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT && !ra_used(ir) && + !irref_isk(ir->op1) && mayfuse(as, ir->op1)) { + IRIns *iri = IR(ir->op1); + emit_rmro(as, XO_FILDd, XOg_FILDd, RID_ESP, ra_spill(as, iri)); + } else { + emit_mrm(as, XO_FLDq, XOg_FLDq, asm_fuseload(as, ref, RSET_EMPTY)); + } +} + +/* Try to rejoin pow from EXP2, MUL and LOG2 (if still unsplit). */ +static int fpmjoin_pow(ASMState *as, IRIns *ir) +{ + IRIns *irp = IR(ir->op1); + if (irp == ir-1 && irp->o == IR_MUL && !ra_used(irp)) { + IRIns *irpp = IR(irp->op1); + if (irpp == ir-2 && irpp->o == IR_FPMATH && + irpp->op2 == IRFPM_LOG2 && !ra_used(irpp)) { + /* The modified regs must match with the *.dasc implementation. */ + RegSet drop = RSET_RANGE(RID_XMM0, RID_XMM2+1)|RID2RSET(RID_EAX); + IRIns *irx; + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + ra_evictset(as, drop); + ra_destreg(as, ir, RID_XMM0); + emit_call(as, lj_vm_pow_sse); + irx = IR(irpp->op1); + if (ra_noreg(irx->r) && ra_gethint(irx->r) == RID_XMM1) + irx->r = RID_INIT; /* Avoid allocating xmm1 for x. */ + ra_left(as, RID_XMM0, irpp->op1); + ra_left(as, RID_XMM1, irp->op2); + return 1; + } + } + return 0; +} + +static void asm_fpmath(ASMState *as, IRIns *ir) +{ + IRFPMathOp fpm = ir->o == IR_FPMATH ? (IRFPMathOp)ir->op2 : IRFPM_OTHER; + if (fpm == IRFPM_SQRT) { + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg left = asm_fuseload(as, ir->op1, RSET_FPR); + emit_mrm(as, XO_SQRTSD, dest, left); + } else if (fpm <= IRFPM_TRUNC) { + if (as->flags & JIT_F_SSE4_1) { /* SSE4.1 has a rounding instruction. */ + Reg dest = ra_dest(as, ir, RSET_FPR); + Reg left = asm_fuseload(as, ir->op1, RSET_FPR); + /* ROUNDSD has a 4-byte opcode which doesn't fit in x86Op. + ** Let's pretend it's a 3-byte opcode, and compensate afterwards. + ** This is atrocious, but the alternatives are much worse. + */ + /* Round down/up/trunc == 1001/1010/1011. */ + emit_i8(as, 0x09 + fpm); + emit_mrm(as, XO_ROUNDSD, dest, left); + if (LJ_64 && as->mcp[1] != (MCode)(XO_ROUNDSD >> 16)) { + as->mcp[0] = as->mcp[1]; as->mcp[1] = 0x0f; /* Swap 0F and REX. */ + } + *--as->mcp = 0x66; /* 1st byte of ROUNDSD opcode. */ + } else { /* Call helper functions for SSE2 variant. */ + /* The modified regs must match with the *.dasc implementation. */ + RegSet drop = RSET_RANGE(RID_XMM0, RID_XMM3+1)|RID2RSET(RID_EAX); + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + ra_evictset(as, drop); + ra_destreg(as, ir, RID_XMM0); + emit_call(as, fpm == IRFPM_FLOOR ? lj_vm_floor_sse : + fpm == IRFPM_CEIL ? lj_vm_ceil_sse : lj_vm_trunc_sse); + ra_left(as, RID_XMM0, ir->op1); + } + } else if (fpm == IRFPM_EXP2 && fpmjoin_pow(as, ir)) { + /* Rejoined to pow(). */ + } else { /* Handle x87 ops. */ + int32_t ofs = sps_scale(ir->s); /* Use spill slot or temp slots. */ + Reg dest = ir->r; + if (ra_hasreg(dest)) { + ra_free(as, dest); + ra_modified(as, dest); + emit_rmro(as, XMM_MOVRM(as), dest, RID_ESP, ofs); + } + emit_rmro(as, XO_FSTPq, XOg_FSTPq, RID_ESP, ofs); + switch (fpm) { /* st0 = lj_vm_*(st0) */ + case IRFPM_EXP: emit_call(as, lj_vm_exp_x87); break; + case IRFPM_EXP2: emit_call(as, lj_vm_exp2_x87); break; + case IRFPM_SIN: emit_x87op(as, XI_FSIN); break; + case IRFPM_COS: emit_x87op(as, XI_FCOS); break; + case IRFPM_TAN: emit_x87op(as, XI_FPOP); emit_x87op(as, XI_FPTAN); break; + case IRFPM_LOG: case IRFPM_LOG2: case IRFPM_LOG10: + /* Note: the use of fyl2xp1 would be pointless here. When computing + ** log(1.0+eps) the precision is already lost after 1.0 is added. + ** Subtracting 1.0 won't recover it. OTOH math.log1p would make sense. + */ + emit_x87op(as, XI_FYL2X); break; + case IRFPM_OTHER: + switch (ir->o) { + case IR_ATAN2: + emit_x87op(as, XI_FPATAN); asm_x87load(as, ir->op2); break; + case IR_LDEXP: + emit_x87op(as, XI_FPOP1); emit_x87op(as, XI_FSCALE); break; + default: lua_assert(0); break; + } + break; + default: lua_assert(0); break; + } + asm_x87load(as, ir->op1); + switch (fpm) { + case IRFPM_LOG: emit_x87op(as, XI_FLDLN2); break; + case IRFPM_LOG2: emit_x87op(as, XI_FLD1); break; + case IRFPM_LOG10: emit_x87op(as, XI_FLDLG2); break; + case IRFPM_OTHER: + if (ir->o == IR_LDEXP) asm_x87load(as, ir->op2); + break; + default: break; + } + } +} + +static void asm_fppowi(ASMState *as, IRIns *ir) +{ + /* The modified regs must match with the *.dasc implementation. */ + RegSet drop = RSET_RANGE(RID_XMM0, RID_XMM1+1)|RID2RSET(RID_EAX); + if (ra_hasreg(ir->r)) + rset_clear(drop, ir->r); /* Dest reg handled below. */ + ra_evictset(as, drop); + ra_destreg(as, ir, RID_XMM0); + emit_call(as, lj_vm_powi_sse); + ra_left(as, RID_XMM0, ir->op1); + ra_left(as, RID_EAX, ir->op2); +} + +#if LJ_64 && LJ_HASFFI +static void asm_arith64(ASMState *as, IRIns *ir, IRCallID id) +{ + const CCallInfo *ci = &lj_ir_callinfo[id]; + IRRef args[2]; + args[0] = ir->op1; + args[1] = ir->op2; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} +#endif + +static void asm_intmod(ASMState *as, IRIns *ir) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_vm_modi]; + IRRef args[2]; + args[0] = ir->op1; + args[1] = ir->op2; + asm_setupresult(as, ir, ci); + asm_gencall(as, ci, args); +} + +static int asm_swapops(ASMState *as, IRIns *ir) +{ + IRIns *irl = IR(ir->op1); + IRIns *irr = IR(ir->op2); + lua_assert(ra_noreg(irr->r)); + if (!irm_iscomm(lj_ir_mode[ir->o])) + return 0; /* Can't swap non-commutative operations. */ + if (irref_isk(ir->op2)) + return 0; /* Don't swap constants to the left. */ + if (ra_hasreg(irl->r)) + return 1; /* Swap if left already has a register. */ + if (ra_samehint(ir->r, irr->r)) + return 1; /* Swap if dest and right have matching hints. */ + if (as->curins > as->loopref) { /* In variant part? */ + if (ir->op2 < as->loopref && !irt_isphi(irr->t)) + return 0; /* Keep invariants on the right. */ + if (ir->op1 < as->loopref && !irt_isphi(irl->t)) + return 1; /* Swap invariants to the right. */ + } + if (opisfusableload(irl->o)) + return 1; /* Swap fusable loads to the right. */ + return 0; /* Otherwise don't swap. */ +} + +static void asm_fparith(ASMState *as, IRIns *ir, x86Op xo) +{ + IRRef lref = ir->op1; + IRRef rref = ir->op2; + RegSet allow = RSET_FPR; + Reg dest; + Reg right = IR(rref)->r; + if (ra_hasreg(right)) { + rset_clear(allow, right); + ra_noweak(as, right); + } + dest = ra_dest(as, ir, allow); + if (lref == rref) { + right = dest; + } else if (ra_noreg(right)) { + if (asm_swapops(as, ir)) { + IRRef tmp = lref; lref = rref; rref = tmp; + } + right = asm_fuseload(as, rref, rset_clear(allow, dest)); + } + emit_mrm(as, xo, dest, right); + ra_left(as, dest, lref); +} + +static void asm_intarith(ASMState *as, IRIns *ir, x86Arith xa) +{ + IRRef lref = ir->op1; + IRRef rref = ir->op2; + RegSet allow = RSET_GPR; + Reg dest, right; + int32_t k = 0; + if (as->flagmcp == as->mcp) { /* Drop test r,r instruction. */ + MCode *p = as->mcp + ((LJ_64 && *as->mcp < XI_TESTb) ? 3 : 2); + if ((p[1] & 15) < 14) { + if ((p[1] & 15) >= 12) p[1] -= 4; /* L <->S, NL <-> NS */ + as->flagmcp = NULL; + as->mcp = p; + } /* else: cannot transform LE/NLE to cc without use of OF. */ + } + right = IR(rref)->r; + if (ra_hasreg(right)) { + rset_clear(allow, right); + ra_noweak(as, right); + } + dest = ra_dest(as, ir, allow); + if (lref == rref) { + right = dest; + } else if (ra_noreg(right) && !asm_isk32(as, rref, &k)) { + if (asm_swapops(as, ir)) { + IRRef tmp = lref; lref = rref; rref = tmp; + } + right = asm_fuseloadm(as, rref, rset_clear(allow, dest), irt_is64(ir->t)); + } + if (irt_isguard(ir->t)) /* For IR_ADDOV etc. */ + asm_guardcc(as, CC_O); + if (xa != XOg_X_IMUL) { + if (ra_hasreg(right)) + emit_mrm(as, XO_ARITH(xa), REX_64IR(ir, dest), right); + else + emit_gri(as, XG_ARITHi(xa), REX_64IR(ir, dest), k); + } else if (ra_hasreg(right)) { /* IMUL r, mrm. */ + emit_mrm(as, XO_IMUL, REX_64IR(ir, dest), right); + } else { /* IMUL r, r, k. */ + /* NYI: use lea/shl/add/sub (FOLD only does 2^k) depending on CPU. */ + Reg left = asm_fuseloadm(as, lref, RSET_GPR, irt_is64(ir->t)); + x86Op xo; + if (checki8(k)) { emit_i8(as, k); xo = XO_IMULi8; + } else { emit_i32(as, k); xo = XO_IMULi; } + emit_mrm(as, xo, REX_64IR(ir, dest), left); + return; + } + ra_left(as, dest, lref); +} + +/* LEA is really a 4-operand ADD with an independent destination register, +** up to two source registers and an immediate. One register can be scaled +** by 1, 2, 4 or 8. This can be used to avoid moves or to fuse several +** instructions. +** +** Currently only a few common cases are supported: +** - 3-operand ADD: y = a+b; y = a+k with a and b already allocated +** - Left ADD fusion: y = (a+b)+k; y = (a+k)+b +** - Right ADD fusion: y = a+(b+k) +** The ommited variants have already been reduced by FOLD. +** +** There are more fusion opportunities, like gathering shifts or joining +** common references. But these are probably not worth the trouble, since +** array indexing is not decomposed and already makes use of all fields +** of the ModRM operand. +*/ +static int asm_lea(ASMState *as, IRIns *ir) +{ + IRIns *irl = IR(ir->op1); + IRIns *irr = IR(ir->op2); + RegSet allow = RSET_GPR; + Reg dest; + as->mrm.base = as->mrm.idx = RID_NONE; + as->mrm.scale = XM_SCALE1; + as->mrm.ofs = 0; + if (ra_hasreg(irl->r)) { + rset_clear(allow, irl->r); + ra_noweak(as, irl->r); + as->mrm.base = irl->r; + if (irref_isk(ir->op2) || ra_hasreg(irr->r)) { + /* The PHI renaming logic does a better job in some cases. */ + if (ra_hasreg(ir->r) && + ((irt_isphi(irl->t) && as->phireg[ir->r] == ir->op1) || + (irt_isphi(irr->t) && as->phireg[ir->r] == ir->op2))) + return 0; + if (irref_isk(ir->op2)) { + as->mrm.ofs = irr->i; + } else { + rset_clear(allow, irr->r); + ra_noweak(as, irr->r); + as->mrm.idx = irr->r; + } + } else if (irr->o == IR_ADD && mayfuse(as, ir->op2) && + irref_isk(irr->op2)) { + Reg idx = ra_alloc1(as, irr->op1, allow); + rset_clear(allow, idx); + as->mrm.idx = (uint8_t)idx; + as->mrm.ofs = IR(irr->op2)->i; + } else { + return 0; + } + } else if (ir->op1 != ir->op2 && irl->o == IR_ADD && mayfuse(as, ir->op1) && + (irref_isk(ir->op2) || irref_isk(irl->op2))) { + Reg idx, base = ra_alloc1(as, irl->op1, allow); + rset_clear(allow, base); + as->mrm.base = (uint8_t)base; + if (irref_isk(ir->op2)) { + as->mrm.ofs = irr->i; + idx = ra_alloc1(as, irl->op2, allow); + } else { + as->mrm.ofs = IR(irl->op2)->i; + idx = ra_alloc1(as, ir->op2, allow); + } + rset_clear(allow, idx); + as->mrm.idx = (uint8_t)idx; + } else { + return 0; + } + dest = ra_dest(as, ir, allow); + emit_mrm(as, XO_LEA, dest, RID_MRM); + return 1; /* Success. */ +} + +static void asm_add(ASMState *as, IRIns *ir) +{ + if (irt_isnum(ir->t)) + asm_fparith(as, ir, XO_ADDSD); + else if ((as->flags & JIT_F_LEA_AGU) || as->flagmcp == as->mcp || + irt_is64(ir->t) || !asm_lea(as, ir)) + asm_intarith(as, ir, XOg_ADD); +} + +static void asm_neg_not(ASMState *as, IRIns *ir, x86Group3 xg) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + emit_rr(as, XO_GROUP3, REX_64IR(ir, xg), dest); + ra_left(as, dest, ir->op1); +} + +static void asm_min_max(ASMState *as, IRIns *ir, int cc) +{ + Reg right, dest = ra_dest(as, ir, RSET_GPR); + IRRef lref = ir->op1, rref = ir->op2; + if (irref_isk(rref)) { lref = rref; rref = ir->op1; } + right = ra_alloc1(as, rref, rset_exclude(RSET_GPR, dest)); + emit_rr(as, XO_CMOV + (cc<<24), REX_64IR(ir, dest), right); + emit_rr(as, XO_CMP, REX_64IR(ir, dest), right); + ra_left(as, dest, lref); +} + +static void asm_bitswap(ASMState *as, IRIns *ir) +{ + Reg dest = ra_dest(as, ir, RSET_GPR); + as->mcp = emit_op(XO_BSWAP + ((dest&7) << 24), + REX_64IR(ir, 0), dest, 0, as->mcp, 1); + ra_left(as, dest, ir->op1); +} + +static void asm_bitshift(ASMState *as, IRIns *ir, x86Shift xs) +{ + IRRef rref = ir->op2; + IRIns *irr = IR(rref); + Reg dest; + if (irref_isk(rref)) { /* Constant shifts. */ + int shift; + dest = ra_dest(as, ir, RSET_GPR); + shift = irr->i & (irt_is64(ir->t) ? 63 : 31); + switch (shift) { + case 0: break; + case 1: emit_rr(as, XO_SHIFT1, REX_64IR(ir, xs), dest); break; + default: emit_shifti(as, REX_64IR(ir, xs), dest, shift); break; + } + } else { /* Variable shifts implicitly use register cl (i.e. ecx). */ + Reg right; + dest = ra_dest(as, ir, rset_exclude(RSET_GPR, RID_ECX)); + if (dest == RID_ECX) { + dest = ra_scratch(as, rset_exclude(RSET_GPR, RID_ECX)); + emit_rr(as, XO_MOV, RID_ECX, dest); + } + right = irr->r; + if (ra_noreg(right)) + right = ra_allocref(as, rref, RID2RSET(RID_ECX)); + else if (right != RID_ECX) + ra_scratch(as, RID2RSET(RID_ECX)); + emit_rr(as, XO_SHIFTcl, REX_64IR(ir, xs), dest); + ra_noweak(as, right); + if (right != RID_ECX) + emit_rr(as, XO_MOV, RID_ECX, right); + } + ra_left(as, dest, ir->op1); + /* + ** Note: avoid using the flags resulting from a shift or rotate! + ** All of them cause a partial flag stall, except for r,1 shifts + ** (but not rotates). And a shift count of 0 leaves the flags unmodified. + */ +} + +/* -- Comparisons --------------------------------------------------------- */ + +/* Virtual flags for unordered FP comparisons. */ +#define VCC_U 0x1000 /* Unordered. */ +#define VCC_P 0x2000 /* Needs extra CC_P branch. */ +#define VCC_S 0x4000 /* Swap avoids CC_P branch. */ +#define VCC_PS (VCC_P|VCC_S) + +/* Map of comparisons to flags. ORDER IR. */ +#define COMPFLAGS(ci, cin, cu, cf) ((ci)+((cu)<<4)+((cin)<<8)+(cf)) +static const uint16_t asm_compmap[IR_ABC+1] = { + /* signed non-eq unsigned flags */ + /* LT */ COMPFLAGS(CC_GE, CC_G, CC_AE, VCC_PS), + /* GE */ COMPFLAGS(CC_L, CC_L, CC_B, 0), + /* LE */ COMPFLAGS(CC_G, CC_G, CC_A, VCC_PS), + /* GT */ COMPFLAGS(CC_LE, CC_L, CC_BE, 0), + /* ULT */ COMPFLAGS(CC_AE, CC_A, CC_AE, VCC_U), + /* UGE */ COMPFLAGS(CC_B, CC_B, CC_B, VCC_U|VCC_PS), + /* ULE */ COMPFLAGS(CC_A, CC_A, CC_A, VCC_U), + /* UGT */ COMPFLAGS(CC_BE, CC_B, CC_BE, VCC_U|VCC_PS), + /* EQ */ COMPFLAGS(CC_NE, CC_NE, CC_NE, VCC_P), + /* NE */ COMPFLAGS(CC_E, CC_E, CC_E, VCC_U|VCC_P), + /* ABC */ COMPFLAGS(CC_BE, CC_B, CC_BE, VCC_U|VCC_PS) /* Same as UGT. */ +}; + +/* FP and integer comparisons. */ +static void asm_comp(ASMState *as, IRIns *ir, uint32_t cc) +{ + if (irt_isnum(ir->t)) { + IRRef lref = ir->op1; + IRRef rref = ir->op2; + Reg left, right; + MCLabel l_around; + /* + ** An extra CC_P branch is required to preserve ordered/unordered + ** semantics for FP comparisons. This can be avoided by swapping + ** the operands and inverting the condition (except for EQ and UNE). + ** So always try to swap if possible. + ** + ** Another option would be to swap operands to achieve better memory + ** operand fusion. But it's unlikely that this outweighs the cost + ** of the extra branches. + */ + if (cc & VCC_S) { /* Swap? */ + IRRef tmp = lref; lref = rref; rref = tmp; + cc ^= (VCC_PS|(5<<4)); /* A <-> B, AE <-> BE, PS <-> none */ + } + left = ra_alloc1(as, lref, RSET_FPR); + right = asm_fuseload(as, rref, rset_exclude(RSET_FPR, left)); + l_around = emit_label(as); + asm_guardcc(as, cc >> 4); + if (cc & VCC_P) { /* Extra CC_P branch required? */ + if (!(cc & VCC_U)) { + asm_guardcc(as, CC_P); /* Branch to exit for ordered comparisons. */ + } else if (l_around != as->invmcp) { + emit_sjcc(as, CC_P, l_around); /* Branch around for unordered. */ + } else { + /* Patched to mcloop by asm_loop_fixup. */ + as->loopinv = 2; + if (as->realign) + emit_sjcc(as, CC_P, as->mcp); + else + emit_jcc(as, CC_P, as->mcp); + } + } + emit_mrm(as, XO_UCOMISD, left, right); + } else { + IRRef lref = ir->op1, rref = ir->op2; + IROp leftop = (IROp)(IR(lref)->o); + Reg r64 = REX_64IR(ir, 0); + int32_t imm = 0; + lua_assert(irt_is64(ir->t) || irt_isint(ir->t) || + irt_isu32(ir->t) || irt_isaddr(ir->t) || irt_isu8(ir->t)); + /* Swap constants (only for ABC) and fusable loads to the right. */ + if (irref_isk(lref) || (!irref_isk(rref) && opisfusableload(leftop))) { + if ((cc & 0xc) == 0xc) cc ^= 0x53; /* L <-> G, LE <-> GE */ + else if ((cc & 0xa) == 0x2) cc ^= 0x55; /* A <-> B, AE <-> BE */ + lref = ir->op2; rref = ir->op1; + } + if (asm_isk32(as, rref, &imm)) { + IRIns *irl = IR(lref); + /* Check wether we can use test ins. Not for unsigned, since CF=0. */ + int usetest = (imm == 0 && (cc & 0xa) != 0x2); + if (usetest && irl->o == IR_BAND && irl+1 == ir && !ra_used(irl)) { + /* Combine comp(BAND(ref, r/imm), 0) into test mrm, r/imm. */ + Reg right, left = RID_NONE; + RegSet allow = RSET_GPR; + if (!asm_isk32(as, irl->op2, &imm)) { + left = ra_alloc1(as, irl->op2, allow); + rset_clear(allow, left); + } else { /* Try to Fuse IRT_I8/IRT_U8 loads, too. See below. */ + IRIns *irll = IR(irl->op1); + if (opisfusableload((IROp)irll->o) && + (irt_isi8(irll->t) || irt_isu8(irll->t))) { + IRType1 origt = irll->t; /* Temporarily flip types. */ + irll->t.irt = (irll->t.irt & ~IRT_TYPE) | IRT_INT; + as->curins--; /* Skip to BAND to avoid failing in noconflict(). */ + right = asm_fuseload(as, irl->op1, RSET_GPR); + as->curins++; + irll->t = origt; + if (right != RID_MRM) goto test_nofuse; + /* Fusion succeeded, emit test byte mrm, imm8. */ + asm_guardcc(as, cc); + emit_i8(as, (imm & 0xff)); + emit_mrm(as, XO_GROUP3b, XOg_TEST, RID_MRM); + return; + } + } + as->curins--; /* Skip to BAND to avoid failing in noconflict(). */ + right = asm_fuseloadm(as, irl->op1, allow, r64); + as->curins++; /* Undo the above. */ + test_nofuse: + asm_guardcc(as, cc); + if (ra_noreg(left)) { + emit_i32(as, imm); + emit_mrm(as, XO_GROUP3, r64 + XOg_TEST, right); + } else { + emit_mrm(as, XO_TEST, r64 + left, right); + } + } else { + Reg left; + if (opisfusableload((IROp)irl->o) && + ((irt_isu8(irl->t) && checku8(imm)) || + ((irt_isi8(irl->t) || irt_isi16(irl->t)) && checki8(imm)) || + (irt_isu16(irl->t) && checku16(imm) && checki8((int16_t)imm)))) { + /* Only the IRT_INT case is fused by asm_fuseload. + ** The IRT_I8/IRT_U8 loads and some IRT_I16/IRT_U16 loads + ** are handled here. + ** Note that cmp word [mem], imm16 should not be generated, + ** since it has a length-changing prefix. Compares of a word + ** against a sign-extended imm8 are ok, however. + */ + IRType1 origt = irl->t; /* Temporarily flip types. */ + irl->t.irt = (irl->t.irt & ~IRT_TYPE) | IRT_INT; + left = asm_fuseload(as, lref, RSET_GPR); + irl->t = origt; + if (left == RID_MRM) { /* Fusion succeeded? */ + if (irt_isu8(irl->t) || irt_isu16(irl->t)) + cc >>= 4; /* Need unsigned compare. */ + asm_guardcc(as, cc); + emit_i8(as, imm); + emit_mrm(as, (irt_isi8(origt) || irt_isu8(origt)) ? + XO_ARITHib : XO_ARITHiw8, r64 + XOg_CMP, RID_MRM); + return; + } /* Otherwise handle register case as usual. */ + } else { + left = asm_fuseloadm(as, lref, + irt_isu8(ir->t) ? RSET_GPR8 : RSET_GPR, r64); + } + asm_guardcc(as, cc); + if (usetest && left != RID_MRM) { + /* Use test r,r instead of cmp r,0. */ + x86Op xo = XO_TEST; + if (irt_isu8(ir->t)) { + lua_assert(ir->o == IR_EQ || ir->o == IR_NE); + xo = XO_TESTb; + if (!rset_test(RSET_RANGE(RID_EAX, RID_EBX+1), left)) { + if (LJ_64) { + left |= FORCE_REX; + } else { + emit_i32(as, 0xff); + emit_mrm(as, XO_GROUP3, XOg_TEST, left); + return; + } + } + } + emit_rr(as, xo, r64 + left, left); + if (irl+1 == ir) /* Referencing previous ins? */ + as->flagmcp = as->mcp; /* Set flag to drop test r,r if possible. */ + } else { + emit_gmrmi(as, XG_ARITHi(XOg_CMP), r64 + left, imm); + } + } + } else { + Reg left = ra_alloc1(as, lref, RSET_GPR); + Reg right = asm_fuseloadm(as, rref, rset_exclude(RSET_GPR, left), r64); + asm_guardcc(as, cc); + emit_mrm(as, XO_CMP, r64 + left, right); + } + } +} + +#if LJ_32 && LJ_HASFFI +/* 64 bit integer comparisons in 32 bit mode. */ +static void asm_comp_int64(ASMState *as, IRIns *ir) +{ + uint32_t cc = asm_compmap[(ir-1)->o]; + RegSet allow = RSET_GPR; + Reg lefthi = RID_NONE, leftlo = RID_NONE; + Reg righthi = RID_NONE, rightlo = RID_NONE; + MCLabel l_around; + x86ModRM mrm; + + as->curins--; /* Skip loword ins. Avoids failing in noconflict(), too. */ + + /* Allocate/fuse hiword operands. */ + if (irref_isk(ir->op2)) { + lefthi = asm_fuseload(as, ir->op1, allow); + } else { + lefthi = ra_alloc1(as, ir->op1, allow); + rset_clear(allow, lefthi); + righthi = asm_fuseload(as, ir->op2, allow); + if (righthi == RID_MRM) { + if (as->mrm.base != RID_NONE) rset_clear(allow, as->mrm.base); + if (as->mrm.idx != RID_NONE) rset_clear(allow, as->mrm.idx); + } else { + rset_clear(allow, righthi); + } + } + mrm = as->mrm; /* Save state for hiword instruction. */ + + /* Allocate/fuse loword operands. */ + if (irref_isk((ir-1)->op2)) { + leftlo = asm_fuseload(as, (ir-1)->op1, allow); + } else { + leftlo = ra_alloc1(as, (ir-1)->op1, allow); + rset_clear(allow, leftlo); + rightlo = asm_fuseload(as, (ir-1)->op2, allow); + } + + /* All register allocations must be performed _before_ this point. */ + l_around = emit_label(as); + as->invmcp = as->flagmcp = NULL; /* Cannot use these optimizations. */ + + /* Loword comparison and branch. */ + asm_guardcc(as, cc >> 4); /* Always use unsigned compare for loword. */ + if (ra_noreg(rightlo)) { + int32_t imm = IR((ir-1)->op2)->i; + if (imm == 0 && ((cc >> 4) & 0xa) != 0x2 && leftlo != RID_MRM) + emit_rr(as, XO_TEST, leftlo, leftlo); + else + emit_gmrmi(as, XG_ARITHi(XOg_CMP), leftlo, imm); + } else { + emit_mrm(as, XO_CMP, leftlo, rightlo); + } + + /* Hiword comparison and branches. */ + if ((cc & 15) != CC_NE) + emit_sjcc(as, CC_NE, l_around); /* Hiword unequal: skip loword compare. */ + if ((cc & 15) != CC_E) + asm_guardcc(as, cc >> 8); /* Hiword compare without equality check. */ + as->mrm = mrm; /* Restore state. */ + if (ra_noreg(righthi)) { + int32_t imm = IR(ir->op2)->i; + if (imm == 0 && (cc & 0xa) != 0x2 && lefthi != RID_MRM) + emit_rr(as, XO_TEST, lefthi, lefthi); + else + emit_gmrmi(as, XG_ARITHi(XOg_CMP), lefthi, imm); + } else { + emit_mrm(as, XO_CMP, lefthi, righthi); + } +} +#endif + +/* -- Support for 64 bit ops in 32 bit mode ------------------------------- */ + +/* Hiword op of a split 64 bit op. Previous op must be the loword op. */ +static void asm_hiop(ASMState *as, IRIns *ir) +{ +#if LJ_32 && LJ_HASFFI + /* HIOP is marked as a store because it needs its own DCE logic. */ + int uselo = ra_used(ir-1), usehi = ra_used(ir); /* Loword/hiword used? */ + if (LJ_UNLIKELY(!(as->flags & JIT_F_OPT_DCE))) uselo = usehi = 1; + if ((ir-1)->o == IR_CONV) { /* Conversions to/from 64 bit. */ + if (usehi || uselo) { + if (irt_isfp(ir->t)) + asm_conv_fp_int64(as, ir); + else + asm_conv_int64_fp(as, ir); + } + as->curins--; /* Always skip the CONV. */ + return; + } else if ((ir-1)->o <= IR_NE) { /* 64 bit integer comparisons. ORDER IR. */ + asm_comp_int64(as, ir); + return; + } else if ((ir-1)->o == IR_XSTORE) { + if ((ir-1)->r != RID_SINK) + asm_fxstore(as, ir); + return; + } + if (!usehi) return; /* Skip unused hiword op for all remaining ops. */ + switch ((ir-1)->o) { + case IR_ADD: + as->flagmcp = NULL; + as->curins--; + asm_intarith(as, ir, XOg_ADC); + asm_intarith(as, ir-1, XOg_ADD); + break; + case IR_SUB: + as->flagmcp = NULL; + as->curins--; + asm_intarith(as, ir, XOg_SBB); + asm_intarith(as, ir-1, XOg_SUB); + break; + case IR_NEG: { + Reg dest = ra_dest(as, ir, RSET_GPR); + emit_rr(as, XO_GROUP3, XOg_NEG, dest); + emit_i8(as, 0); + emit_rr(as, XO_ARITHi8, XOg_ADC, dest); + ra_left(as, dest, ir->op1); + as->curins--; + asm_neg_not(as, ir-1, XOg_NEG); + break; + } + case IR_CALLN: + case IR_CALLXS: + if (!uselo) + ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */ + break; + case IR_CNEWI: + /* Nothing to do here. Handled by CNEWI itself. */ + break; + default: lua_assert(0); break; + } +#else + UNUSED(as); UNUSED(ir); lua_assert(0); /* Unused on x64 or without FFI. */ +#endif +} + +/* -- Stack handling ------------------------------------------------------ */ + +/* Check Lua stack size for overflow. Use exit handler as fallback. */ +static void asm_stack_check(ASMState *as, BCReg topslot, + IRIns *irp, RegSet allow, ExitNo exitno) +{ + /* Try to get an unused temp. register, otherwise spill/restore eax. */ + Reg pbase = irp ? irp->r : RID_BASE; + Reg r = allow ? rset_pickbot(allow) : RID_EAX; + emit_jcc(as, CC_B, exitstub_addr(as->J, exitno)); + if (allow == RSET_EMPTY) /* Restore temp. register. */ + emit_rmro(as, XO_MOV, r|REX_64, RID_ESP, 0); + else + ra_modified(as, r); + emit_gri(as, XG_ARITHi(XOg_CMP), r, (int32_t)(8*topslot)); + if (ra_hasreg(pbase) && pbase != r) + emit_rr(as, XO_ARITH(XOg_SUB), r, pbase); + else + emit_rmro(as, XO_ARITH(XOg_SUB), r, RID_NONE, + ptr2addr(&J2G(as->J)->jit_base)); + emit_rmro(as, XO_MOV, r, r, offsetof(lua_State, maxstack)); + emit_getgl(as, r, jit_L); + if (allow == RSET_EMPTY) /* Spill temp. register. */ + emit_rmro(as, XO_MOVto, r|REX_64, RID_ESP, 0); +} + +/* Restore Lua stack from on-trace state. */ +static void asm_stack_restore(ASMState *as, SnapShot *snap) +{ + SnapEntry *map = &as->T->snapmap[snap->mapofs]; + SnapEntry *flinks = &as->T->snapmap[snap_nextofs(as->T, snap)-1]; + MSize n, nent = snap->nent; + /* Store the value of all modified slots to the Lua stack. */ + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + BCReg s = snap_slot(sn); + int32_t ofs = 8*((int32_t)s-1); + IRRef ref = snap_ref(sn); + IRIns *ir = IR(ref); + if ((sn & SNAP_NORESTORE)) + continue; + if (irt_isnum(ir->t)) { + Reg src = ra_alloc1(as, ref, RSET_FPR); + emit_rmro(as, XO_MOVSDto, src, RID_BASE, ofs); + } else { + lua_assert(irt_ispri(ir->t) || irt_isaddr(ir->t) || + (LJ_DUALNUM && irt_isinteger(ir->t))); + if (!irref_isk(ref)) { + Reg src = ra_alloc1(as, ref, rset_exclude(RSET_GPR, RID_BASE)); + emit_movtomro(as, REX_64IR(ir, src), RID_BASE, ofs); + } else if (!irt_ispri(ir->t)) { + emit_movmroi(as, RID_BASE, ofs, ir->i); + } + if ((sn & (SNAP_CONT|SNAP_FRAME))) { + if (s != 0) /* Do not overwrite link to previous frame. */ + emit_movmroi(as, RID_BASE, ofs+4, (int32_t)(*flinks--)); + } else { + if (!(LJ_64 && irt_islightud(ir->t))) + emit_movmroi(as, RID_BASE, ofs+4, irt_toitype(ir->t)); + } + } + checkmclim(as); + } + lua_assert(map + nent == flinks); +} + +/* -- GC handling --------------------------------------------------------- */ + +/* Check GC threshold and do one or more GC steps. */ +static void asm_gc_check(ASMState *as) +{ + const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_step_jit]; + IRRef args[2]; + MCLabel l_end; + Reg tmp; + ra_evictset(as, RSET_SCRATCH); + l_end = emit_label(as); + /* Exit trace if in GCSatomic or GCSfinalize. Avoids syncing GC objects. */ + asm_guardcc(as, CC_NE); /* Assumes asm_snap_prep() already done. */ + emit_rr(as, XO_TEST, RID_RET, RID_RET); + args[0] = ASMREF_TMP1; /* global_State *g */ + args[1] = ASMREF_TMP2; /* MSize steps */ + asm_gencall(as, ci, args); + tmp = ra_releasetmp(as, ASMREF_TMP1); + emit_loada(as, tmp, J2G(as->J)); + emit_loadi(as, ra_releasetmp(as, ASMREF_TMP2), as->gcsteps); + /* Jump around GC step if GC total < GC threshold. */ + emit_sjcc(as, CC_B, l_end); + emit_opgl(as, XO_ARITH(XOg_CMP), tmp, gc.threshold); + emit_getgl(as, tmp, gc.total); + as->gcsteps = 0; + checkmclim(as); +} + +/* -- Loop handling ------------------------------------------------------- */ + +/* Fixup the loop branch. */ +static void asm_loop_fixup(ASMState *as) +{ + MCode *p = as->mctop; + MCode *target = as->mcp; + if (as->realign) { /* Realigned loops use short jumps. */ + as->realign = NULL; /* Stop another retry. */ + lua_assert(((intptr_t)target & 15) == 0); + if (as->loopinv) { /* Inverted loop branch? */ + p -= 5; + p[0] = XI_JMP; + lua_assert(target - p >= -128); + p[-1] = (MCode)(target - p); /* Patch sjcc. */ + if (as->loopinv == 2) + p[-3] = (MCode)(target - p + 2); /* Patch opt. short jp. */ + } else { + lua_assert(target - p >= -128); + p[-1] = (MCode)(int8_t)(target - p); /* Patch short jmp. */ + p[-2] = XI_JMPs; + } + } else { + MCode *newloop; + p[-5] = XI_JMP; + if (as->loopinv) { /* Inverted loop branch? */ + /* asm_guardcc already inverted the jcc and patched the jmp. */ + p -= 5; + newloop = target+4; + *(int32_t *)(p-4) = (int32_t)(target - p); /* Patch jcc. */ + if (as->loopinv == 2) { + *(int32_t *)(p-10) = (int32_t)(target - p + 6); /* Patch opt. jp. */ + newloop = target+8; + } + } else { /* Otherwise just patch jmp. */ + *(int32_t *)(p-4) = (int32_t)(target - p); + newloop = target+3; + } + /* Realign small loops and shorten the loop branch. */ + if (newloop >= p - 128) { + as->realign = newloop; /* Force a retry and remember alignment. */ + as->curins = as->stopins; /* Abort asm_trace now. */ + as->T->nins = as->orignins; /* Remove any added renames. */ + } + } +} + +/* -- Head of trace ------------------------------------------------------- */ + +/* Coalesce BASE register for a root trace. */ +static void asm_head_root_base(ASMState *as) +{ + IRIns *ir = IR(REF_BASE); + Reg r = ir->r; + if (ra_hasreg(r)) { + ra_free(as, r); + if (rset_test(as->modset, r) || irt_ismarked(ir->t)) + ir->r = RID_INIT; /* No inheritance for modified BASE register. */ + if (r != RID_BASE) + emit_rr(as, XO_MOV, r, RID_BASE); + } +} + +/* Coalesce or reload BASE register for a side trace. */ +static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) +{ + IRIns *ir = IR(REF_BASE); + Reg r = ir->r; + if (ra_hasreg(r)) { + ra_free(as, r); + if (rset_test(as->modset, r) || irt_ismarked(ir->t)) + ir->r = RID_INIT; /* No inheritance for modified BASE register. */ + if (irp->r == r) { + rset_clear(allow, r); /* Mark same BASE register as coalesced. */ + } else if (ra_hasreg(irp->r) && rset_test(as->freeset, irp->r)) { + rset_clear(allow, irp->r); + emit_rr(as, XO_MOV, r, irp->r); /* Move from coalesced parent reg. */ + } else { + emit_getgl(as, r, jit_base); /* Otherwise reload BASE. */ + } + } + return allow; +} + +/* -- Tail of trace ------------------------------------------------------- */ + +/* Fixup the tail code. */ +static void asm_tail_fixup(ASMState *as, TraceNo lnk) +{ + /* Note: don't use as->mcp swap + emit_*: emit_op overwrites more bytes. */ + MCode *p = as->mctop; + MCode *target, *q; + int32_t spadj = as->T->spadjust; + if (spadj == 0) { + p -= ((as->flags & JIT_F_LEA_AGU) ? 7 : 6) + (LJ_64 ? 1 : 0); + } else { + MCode *p1; + /* Patch stack adjustment. */ + if (checki8(spadj)) { + p -= 3; + p1 = p-6; + *p1 = (MCode)spadj; + } else { + p1 = p-9; + *(int32_t *)p1 = spadj; + } + if ((as->flags & JIT_F_LEA_AGU)) { +#if LJ_64 + p1[-4] = 0x48; +#endif + p1[-3] = (MCode)XI_LEA; + p1[-2] = MODRM(checki8(spadj) ? XM_OFS8 : XM_OFS32, RID_ESP, RID_ESP); + p1[-1] = MODRM(XM_SCALE1, RID_ESP, RID_ESP); + } else { +#if LJ_64 + p1[-3] = 0x48; +#endif + p1[-2] = (MCode)(checki8(spadj) ? XI_ARITHi8 : XI_ARITHi); + p1[-1] = MODRM(XM_REG, XOg_ADD, RID_ESP); + } + } + /* Patch exit branch. */ + target = lnk ? traceref(as->J, lnk)->mcode : (MCode *)lj_vm_exit_interp; + *(int32_t *)(p-4) = jmprel(p, target); + p[-5] = XI_JMP; + /* Drop unused mcode tail. Fill with NOPs to make the prefetcher happy. */ + for (q = as->mctop-1; q >= p; q--) + *q = XI_NOP; + as->mctop = p; +} + +/* Prepare tail of code. */ +static void asm_tail_prep(ASMState *as) +{ + MCode *p = as->mctop; + /* Realign and leave room for backwards loop branch or exit branch. */ + if (as->realign) { + int i = ((int)(intptr_t)as->realign) & 15; + /* Fill unused mcode tail with NOPs to make the prefetcher happy. */ + while (i-- > 0) + *--p = XI_NOP; + as->mctop = p; + p -= (as->loopinv ? 5 : 2); /* Space for short/near jmp. */ + } else { + p -= 5; /* Space for exit branch (near jmp). */ + } + if (as->loopref) { + as->invmcp = as->mcp = p; + } else { + /* Leave room for ESP adjustment: add esp, imm or lea esp, [esp+imm] */ + as->mcp = p - (((as->flags & JIT_F_LEA_AGU) ? 7 : 6) + (LJ_64 ? 1 : 0)); + as->invmcp = NULL; + } +} + +/* -- Instruction dispatch ------------------------------------------------ */ + +/* Assemble a single instruction. */ +static void asm_ir(ASMState *as, IRIns *ir) +{ + switch ((IROp)ir->o) { + /* Miscellaneous ops. */ + case IR_LOOP: asm_loop(as); break; + case IR_NOP: case IR_XBAR: lua_assert(!ra_used(ir)); break; + case IR_USE: + ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break; + case IR_PHI: asm_phi(as, ir); break; + case IR_HIOP: asm_hiop(as, ir); break; + case IR_GCSTEP: asm_gcstep(as, ir); break; + + /* Guarded assertions. */ + case IR_LT: case IR_GE: case IR_LE: case IR_GT: + case IR_ULT: case IR_UGE: case IR_ULE: case IR_UGT: + case IR_EQ: case IR_NE: case IR_ABC: + asm_comp(as, ir, asm_compmap[ir->o]); + break; + + case IR_RETF: asm_retf(as, ir); break; + + /* Bit ops. */ + case IR_BNOT: asm_neg_not(as, ir, XOg_NOT); break; + case IR_BSWAP: asm_bitswap(as, ir); break; + + case IR_BAND: asm_intarith(as, ir, XOg_AND); break; + case IR_BOR: asm_intarith(as, ir, XOg_OR); break; + case IR_BXOR: asm_intarith(as, ir, XOg_XOR); break; + + case IR_BSHL: asm_bitshift(as, ir, XOg_SHL); break; + case IR_BSHR: asm_bitshift(as, ir, XOg_SHR); break; + case IR_BSAR: asm_bitshift(as, ir, XOg_SAR); break; + case IR_BROL: asm_bitshift(as, ir, XOg_ROL); break; + case IR_BROR: asm_bitshift(as, ir, XOg_ROR); break; + + /* Arithmetic ops. */ + case IR_ADD: asm_add(as, ir); break; + case IR_SUB: + if (irt_isnum(ir->t)) + asm_fparith(as, ir, XO_SUBSD); + else /* Note: no need for LEA trick here. i-k is encoded as i+(-k). */ + asm_intarith(as, ir, XOg_SUB); + break; + case IR_MUL: + if (irt_isnum(ir->t)) + asm_fparith(as, ir, XO_MULSD); + else + asm_intarith(as, ir, XOg_X_IMUL); + break; + case IR_DIV: +#if LJ_64 && LJ_HASFFI + if (!irt_isnum(ir->t)) + asm_arith64(as, ir, irt_isi64(ir->t) ? IRCALL_lj_carith_divi64 : + IRCALL_lj_carith_divu64); + else +#endif + asm_fparith(as, ir, XO_DIVSD); + break; + case IR_MOD: +#if LJ_64 && LJ_HASFFI + if (!irt_isint(ir->t)) + asm_arith64(as, ir, irt_isi64(ir->t) ? IRCALL_lj_carith_modi64 : + IRCALL_lj_carith_modu64); + else +#endif + asm_intmod(as, ir); + break; + + case IR_NEG: + if (irt_isnum(ir->t)) + asm_fparith(as, ir, XO_XORPS); + else + asm_neg_not(as, ir, XOg_NEG); + break; + case IR_ABS: asm_fparith(as, ir, XO_ANDPS); break; + + case IR_MIN: + if (irt_isnum(ir->t)) + asm_fparith(as, ir, XO_MINSD); + else + asm_min_max(as, ir, CC_G); + break; + case IR_MAX: + if (irt_isnum(ir->t)) + asm_fparith(as, ir, XO_MAXSD); + else + asm_min_max(as, ir, CC_L); + break; + + case IR_FPMATH: case IR_ATAN2: case IR_LDEXP: + asm_fpmath(as, ir); + break; + case IR_POW: +#if LJ_64 && LJ_HASFFI + if (!irt_isnum(ir->t)) + asm_arith64(as, ir, irt_isi64(ir->t) ? IRCALL_lj_carith_powi64 : + IRCALL_lj_carith_powu64); + else +#endif + asm_fppowi(as, ir); + break; + + /* Overflow-checking arithmetic ops. Note: don't use LEA here! */ + case IR_ADDOV: asm_intarith(as, ir, XOg_ADD); break; + case IR_SUBOV: asm_intarith(as, ir, XOg_SUB); break; + case IR_MULOV: asm_intarith(as, ir, XOg_X_IMUL); break; + + /* Memory references. */ + case IR_AREF: asm_aref(as, ir); break; + case IR_HREF: asm_href(as, ir); break; + case IR_HREFK: asm_hrefk(as, ir); break; + case IR_NEWREF: asm_newref(as, ir); break; + case IR_UREFO: case IR_UREFC: asm_uref(as, ir); break; + case IR_FREF: asm_fref(as, ir); break; + case IR_STRREF: asm_strref(as, ir); break; + + /* Loads and stores. */ + case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: + asm_ahuvload(as, ir); + break; + case IR_FLOAD: case IR_XLOAD: asm_fxload(as, ir); break; + case IR_SLOAD: asm_sload(as, ir); break; + + case IR_ASTORE: case IR_HSTORE: case IR_USTORE: asm_ahustore(as, ir); break; + case IR_FSTORE: case IR_XSTORE: asm_fxstore(as, ir); break; + + /* Allocations. */ + case IR_SNEW: case IR_XSNEW: asm_snew(as, ir); break; + case IR_TNEW: asm_tnew(as, ir); break; + case IR_TDUP: asm_tdup(as, ir); break; + case IR_CNEW: case IR_CNEWI: asm_cnew(as, ir); break; + + /* Write barriers. */ + case IR_TBAR: asm_tbar(as, ir); break; + case IR_OBAR: asm_obar(as, ir); break; + + /* Type conversions. */ + case IR_TOBIT: asm_tobit(as, ir); break; + case IR_CONV: asm_conv(as, ir); break; + case IR_TOSTR: asm_tostr(as, ir); break; + case IR_STRTO: asm_strto(as, ir); break; + + /* Calls. */ + case IR_CALLN: case IR_CALLL: case IR_CALLS: asm_call(as, ir); break; + case IR_CALLXS: asm_callx(as, ir); break; + case IR_CARG: break; + + default: + setintV(&as->J->errinfo, ir->o); + lj_trace_err_info(as->J, LJ_TRERR_NYIIR); + break; + } +} + +/* -- Trace setup --------------------------------------------------------- */ + +/* Ensure there are enough stack slots for call arguments. */ +static Reg asm_setup_call_slots(ASMState *as, IRIns *ir, const CCallInfo *ci) +{ + IRRef args[CCI_NARGS_MAX*2]; + int nslots; + asm_collectargs(as, ir, ci, args); + nslots = asm_count_call_slots(as, ci, args); + if (nslots > as->evenspill) /* Leave room for args in stack slots. */ + as->evenspill = nslots; +#if LJ_64 + return irt_isfp(ir->t) ? REGSP_HINT(RID_FPRET) : REGSP_HINT(RID_RET); +#else + return irt_isfp(ir->t) ? REGSP_INIT : REGSP_HINT(RID_RET); +#endif +} + +/* Target-specific setup. */ +static void asm_setup_target(ASMState *as) +{ + asm_exitstub_setup(as, as->T->nsnap); +} + +/* -- Trace patching ------------------------------------------------------ */ + +/* Patch exit jumps of existing machine code to a new target. */ +void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target) +{ + MCode *p = T->mcode; + MCode *mcarea = lj_mcode_patch(J, p, 0); + MSize len = T->szmcode; + MCode *px = exitstub_addr(J, exitno) - 6; + MCode *pe = p+len-6; + uint32_t stateaddr = u32ptr(&J2G(J)->vmstate); + if (len > 5 && p[len-5] == XI_JMP && p+len-6 + *(int32_t *)(p+len-4) == px) + *(int32_t *)(p+len-4) = jmprel(p+len, target); + /* Do not patch parent exit for a stack check. Skip beyond vmstate update. */ + for (; p < pe; p++) + if (*(uint32_t *)(p+(LJ_64 ? 3 : 2)) == stateaddr && p[0] == XI_MOVmi) { + p += LJ_64 ? 11 : 10; + break; + } + lua_assert(p < pe); + for (; p < pe; p++) { + if ((*(uint16_t *)p & 0xf0ff) == 0x800f && p + *(int32_t *)(p+2) == px) { + *(int32_t *)(p+2) = jmprel(p+6, target); + p += 5; + } + } + lj_mcode_sync(T->mcode, T->mcode + T->szmcode); + lj_mcode_patch(J, mcarea, 1); +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_bc.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_bc.c new file mode 100644 index 000000000..a8f444c26 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_bc.c @@ -0,0 +1,14 @@ +/* +** Bytecode instruction modes. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_bc_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_bc.h" + +/* Bytecode offsets and bytecode instruction modes. */ +#include "lj_bcdef.h" + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_bc.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_bc.h new file mode 100644 index 000000000..7436fabfe --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_bc.h @@ -0,0 +1,261 @@ +/* +** Bytecode instruction format. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_BC_H +#define _LJ_BC_H + +#include "lj_def.h" +#include "lj_arch.h" + +/* Bytecode instruction format, 32 bit wide, fields of 8 or 16 bit: +** +** +----+----+----+----+ +** | B | C | A | OP | Format ABC +** +----+----+----+----+ +** | D | A | OP | Format AD +** +-------------------- +** MSB LSB +** +** In-memory instructions are always stored in host byte order. +*/ + +/* Operand ranges and related constants. */ +#define BCMAX_A 0xff +#define BCMAX_B 0xff +#define BCMAX_C 0xff +#define BCMAX_D 0xffff +#define BCBIAS_J 0x8000 +#define NO_REG BCMAX_A +#define NO_JMP (~(BCPos)0) + +/* Macros to get instruction fields. */ +#define bc_op(i) ((BCOp)((i)&0xff)) +#define bc_a(i) ((BCReg)(((i)>>8)&0xff)) +#define bc_b(i) ((BCReg)((i)>>24)) +#define bc_c(i) ((BCReg)(((i)>>16)&0xff)) +#define bc_d(i) ((BCReg)((i)>>16)) +#define bc_j(i) ((ptrdiff_t)bc_d(i)-BCBIAS_J) + +/* Macros to set instruction fields. */ +#define setbc_byte(p, x, ofs) \ + ((uint8_t *)(p))[LJ_ENDIAN_SELECT(ofs, 3-ofs)] = (uint8_t)(x) +#define setbc_op(p, x) setbc_byte(p, (x), 0) +#define setbc_a(p, x) setbc_byte(p, (x), 1) +#define setbc_b(p, x) setbc_byte(p, (x), 3) +#define setbc_c(p, x) setbc_byte(p, (x), 2) +#define setbc_d(p, x) \ + ((uint16_t *)(p))[LJ_ENDIAN_SELECT(1, 0)] = (uint16_t)(x) +#define setbc_j(p, x) setbc_d(p, (BCPos)((int32_t)(x)+BCBIAS_J)) + +/* Macros to compose instructions. */ +#define BCINS_ABC(o, a, b, c) \ + (((BCIns)(o))|((BCIns)(a)<<8)|((BCIns)(b)<<24)|((BCIns)(c)<<16)) +#define BCINS_AD(o, a, d) \ + (((BCIns)(o))|((BCIns)(a)<<8)|((BCIns)(d)<<16)) +#define BCINS_AJ(o, a, j) BCINS_AD(o, a, (BCPos)((int32_t)(j)+BCBIAS_J)) + +/* Bytecode instruction definition. Order matters, see below. +** +** (name, filler, Amode, Bmode, Cmode or Dmode, metamethod) +** +** The opcode name suffixes specify the type for RB/RC or RD: +** V = variable slot +** S = string const +** N = number const +** P = primitive type (~itype) +** B = unsigned byte literal +** M = multiple args/results +*/ +#define BCDEF(_) \ + /* Comparison ops. ORDER OPR. */ \ + _(ISLT, var, ___, var, lt) \ + _(ISGE, var, ___, var, lt) \ + _(ISLE, var, ___, var, le) \ + _(ISGT, var, ___, var, le) \ + \ + _(ISEQV, var, ___, var, eq) \ + _(ISNEV, var, ___, var, eq) \ + _(ISEQS, var, ___, str, eq) \ + _(ISNES, var, ___, str, eq) \ + _(ISEQN, var, ___, num, eq) \ + _(ISNEN, var, ___, num, eq) \ + _(ISEQP, var, ___, pri, eq) \ + _(ISNEP, var, ___, pri, eq) \ + \ + /* Unary test and copy ops. */ \ + _(ISTC, dst, ___, var, ___) \ + _(ISFC, dst, ___, var, ___) \ + _(IST, ___, ___, var, ___) \ + _(ISF, ___, ___, var, ___) \ + \ + /* Unary ops. */ \ + _(MOV, dst, ___, var, ___) \ + _(NOT, dst, ___, var, ___) \ + _(UNM, dst, ___, var, unm) \ + _(LEN, dst, ___, var, len) \ + \ + /* Binary ops. ORDER OPR. VV last, POW must be next. */ \ + _(ADDVN, dst, var, num, add) \ + _(SUBVN, dst, var, num, sub) \ + _(MULVN, dst, var, num, mul) \ + _(DIVVN, dst, var, num, div) \ + _(MODVN, dst, var, num, mod) \ + \ + _(ADDNV, dst, var, num, add) \ + _(SUBNV, dst, var, num, sub) \ + _(MULNV, dst, var, num, mul) \ + _(DIVNV, dst, var, num, div) \ + _(MODNV, dst, var, num, mod) \ + \ + _(ADDVV, dst, var, var, add) \ + _(SUBVV, dst, var, var, sub) \ + _(MULVV, dst, var, var, mul) \ + _(DIVVV, dst, var, var, div) \ + _(MODVV, dst, var, var, mod) \ + \ + _(POW, dst, var, var, pow) \ + _(CAT, dst, rbase, rbase, concat) \ + \ + /* Constant ops. */ \ + _(KSTR, dst, ___, str, ___) \ + _(KCDATA, dst, ___, cdata, ___) \ + _(KSHORT, dst, ___, lits, ___) \ + _(KNUM, dst, ___, num, ___) \ + _(KPRI, dst, ___, pri, ___) \ + _(KNIL, base, ___, base, ___) \ + \ + /* Upvalue and function ops. */ \ + _(UGET, dst, ___, uv, ___) \ + _(USETV, uv, ___, var, ___) \ + _(USETS, uv, ___, str, ___) \ + _(USETN, uv, ___, num, ___) \ + _(USETP, uv, ___, pri, ___) \ + _(UCLO, rbase, ___, jump, ___) \ + _(FNEW, dst, ___, func, gc) \ + \ + /* Table ops. */ \ + _(TNEW, dst, ___, lit, gc) \ + _(TDUP, dst, ___, tab, gc) \ + _(GGET, dst, ___, str, index) \ + _(GSET, var, ___, str, newindex) \ + _(TGETV, dst, var, var, index) \ + _(TGETS, dst, var, str, index) \ + _(TGETB, dst, var, lit, index) \ + _(TSETV, var, var, var, newindex) \ + _(TSETS, var, var, str, newindex) \ + _(TSETB, var, var, lit, newindex) \ + _(TSETM, base, ___, num, newindex) \ + \ + /* Calls and vararg handling. T = tail call. */ \ + _(CALLM, base, lit, lit, call) \ + _(CALL, base, lit, lit, call) \ + _(CALLMT, base, ___, lit, call) \ + _(CALLT, base, ___, lit, call) \ + _(ITERC, base, lit, lit, call) \ + _(ITERN, base, lit, lit, call) \ + _(VARG, base, lit, lit, ___) \ + _(ISNEXT, base, ___, jump, ___) \ + \ + /* Returns. */ \ + _(RETM, base, ___, lit, ___) \ + _(RET, rbase, ___, lit, ___) \ + _(RET0, rbase, ___, lit, ___) \ + _(RET1, rbase, ___, lit, ___) \ + \ + /* Loops and branches. I/J = interp/JIT, I/C/L = init/call/loop. */ \ + _(FORI, base, ___, jump, ___) \ + _(JFORI, base, ___, jump, ___) \ + \ + _(FORL, base, ___, jump, ___) \ + _(IFORL, base, ___, jump, ___) \ + _(JFORL, base, ___, lit, ___) \ + \ + _(ITERL, base, ___, jump, ___) \ + _(IITERL, base, ___, jump, ___) \ + _(JITERL, base, ___, lit, ___) \ + \ + _(LOOP, rbase, ___, jump, ___) \ + _(ILOOP, rbase, ___, jump, ___) \ + _(JLOOP, rbase, ___, lit, ___) \ + \ + _(JMP, rbase, ___, jump, ___) \ + \ + /* Function headers. I/J = interp/JIT, F/V/C = fixarg/vararg/C func. */ \ + _(FUNCF, rbase, ___, ___, ___) \ + _(IFUNCF, rbase, ___, ___, ___) \ + _(JFUNCF, rbase, ___, lit, ___) \ + _(FUNCV, rbase, ___, ___, ___) \ + _(IFUNCV, rbase, ___, ___, ___) \ + _(JFUNCV, rbase, ___, lit, ___) \ + _(FUNCC, rbase, ___, ___, ___) \ + _(FUNCCW, rbase, ___, ___, ___) + +/* Bytecode opcode numbers. */ +typedef enum { +#define BCENUM(name, ma, mb, mc, mt) BC_##name, +BCDEF(BCENUM) +#undef BCENUM + BC__MAX +} BCOp; + +LJ_STATIC_ASSERT((int)BC_ISEQV+1 == (int)BC_ISNEV); +LJ_STATIC_ASSERT(((int)BC_ISEQV^1) == (int)BC_ISNEV); +LJ_STATIC_ASSERT(((int)BC_ISEQS^1) == (int)BC_ISNES); +LJ_STATIC_ASSERT(((int)BC_ISEQN^1) == (int)BC_ISNEN); +LJ_STATIC_ASSERT(((int)BC_ISEQP^1) == (int)BC_ISNEP); +LJ_STATIC_ASSERT(((int)BC_ISLT^1) == (int)BC_ISGE); +LJ_STATIC_ASSERT(((int)BC_ISLE^1) == (int)BC_ISGT); +LJ_STATIC_ASSERT(((int)BC_ISLT^3) == (int)BC_ISGT); +LJ_STATIC_ASSERT((int)BC_IST-(int)BC_ISTC == (int)BC_ISF-(int)BC_ISFC); +LJ_STATIC_ASSERT((int)BC_CALLT-(int)BC_CALL == (int)BC_CALLMT-(int)BC_CALLM); +LJ_STATIC_ASSERT((int)BC_CALLMT + 1 == (int)BC_CALLT); +LJ_STATIC_ASSERT((int)BC_RETM + 1 == (int)BC_RET); +LJ_STATIC_ASSERT((int)BC_FORL + 1 == (int)BC_IFORL); +LJ_STATIC_ASSERT((int)BC_FORL + 2 == (int)BC_JFORL); +LJ_STATIC_ASSERT((int)BC_ITERL + 1 == (int)BC_IITERL); +LJ_STATIC_ASSERT((int)BC_ITERL + 2 == (int)BC_JITERL); +LJ_STATIC_ASSERT((int)BC_LOOP + 1 == (int)BC_ILOOP); +LJ_STATIC_ASSERT((int)BC_LOOP + 2 == (int)BC_JLOOP); +LJ_STATIC_ASSERT((int)BC_FUNCF + 1 == (int)BC_IFUNCF); +LJ_STATIC_ASSERT((int)BC_FUNCF + 2 == (int)BC_JFUNCF); +LJ_STATIC_ASSERT((int)BC_FUNCV + 1 == (int)BC_IFUNCV); +LJ_STATIC_ASSERT((int)BC_FUNCV + 2 == (int)BC_JFUNCV); + +/* This solves a circular dependency problem, change as needed. */ +#define FF_next_N 4 + +/* Stack slots used by FORI/FORL, relative to operand A. */ +enum { + FORL_IDX, FORL_STOP, FORL_STEP, FORL_EXT +}; + +/* Bytecode operand modes. ORDER BCMode */ +typedef enum { + BCMnone, BCMdst, BCMbase, BCMvar, BCMrbase, BCMuv, /* Mode A must be <= 7 */ + BCMlit, BCMlits, BCMpri, BCMnum, BCMstr, BCMtab, BCMfunc, BCMjump, BCMcdata, + BCM_max +} BCMode; +#define BCM___ BCMnone + +#define bcmode_a(op) ((BCMode)(lj_bc_mode[op] & 7)) +#define bcmode_b(op) ((BCMode)((lj_bc_mode[op]>>3) & 15)) +#define bcmode_c(op) ((BCMode)((lj_bc_mode[op]>>7) & 15)) +#define bcmode_d(op) bcmode_c(op) +#define bcmode_hasd(op) ((lj_bc_mode[op] & (15<<3)) == (BCMnone<<3)) +#define bcmode_mm(op) ((MMS)(lj_bc_mode[op]>>11)) + +#define BCMODE(name, ma, mb, mc, mm) \ + (BCM##ma|(BCM##mb<<3)|(BCM##mc<<7)|(MM_##mm<<11)), +#define BCMODE_FF 0 + +static LJ_AINLINE int bc_isret(BCOp op) +{ + return (op == BC_RETM || op == BC_RET || op == BC_RET0 || op == BC_RET1); +} + +LJ_DATA const uint16_t lj_bc_mode[]; +LJ_DATA const uint16_t lj_bc_ofs[]; + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_bcdump.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_bcdump.h new file mode 100644 index 000000000..812d0e151 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_bcdump.h @@ -0,0 +1,66 @@ +/* +** Bytecode dump definitions. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_BCDUMP_H +#define _LJ_BCDUMP_H + +#include "lj_obj.h" +#include "lj_lex.h" + +/* -- Bytecode dump format ------------------------------------------------ */ + +/* +** dump = header proto+ 0U +** header = ESC 'L' 'J' versionB flagsU [namelenU nameB*] +** proto = lengthU pdata +** pdata = phead bcinsW* uvdataH* kgc* knum* [debugB*] +** phead = flagsB numparamsB framesizeB numuvB numkgcU numknU numbcU +** [debuglenU [firstlineU numlineU]] +** kgc = kgctypeU { ktab | (loU hiU) | (rloU rhiU iloU ihiU) | strB* } +** knum = intU0 | (loU1 hiU) +** ktab = narrayU nhashU karray* khash* +** karray = ktabk +** khash = ktabk ktabk +** ktabk = ktabtypeU { intU | (loU hiU) | strB* } +** +** B = 8 bit, H = 16 bit, W = 32 bit, U = ULEB128 of W, U0/U1 = ULEB128 of W+1 +*/ + +/* Bytecode dump header. */ +#define BCDUMP_HEAD1 0x1b +#define BCDUMP_HEAD2 0x4c +#define BCDUMP_HEAD3 0x4a + +/* If you perform *any* kind of private modifications to the bytecode itself +** or to the dump format, you *must* set BCDUMP_VERSION to 0x80 or higher. +*/ +#define BCDUMP_VERSION 1 + +/* Compatibility flags. */ +#define BCDUMP_F_BE 0x01 +#define BCDUMP_F_STRIP 0x02 +#define BCDUMP_F_FFI 0x04 + +#define BCDUMP_F_KNOWN (BCDUMP_F_FFI*2-1) + +/* Type codes for the GC constants of a prototype. Plus length for strings. */ +enum { + BCDUMP_KGC_CHILD, BCDUMP_KGC_TAB, BCDUMP_KGC_I64, BCDUMP_KGC_U64, + BCDUMP_KGC_COMPLEX, BCDUMP_KGC_STR +}; + +/* Type codes for the keys/values of a constant table. */ +enum { + BCDUMP_KTAB_NIL, BCDUMP_KTAB_FALSE, BCDUMP_KTAB_TRUE, + BCDUMP_KTAB_INT, BCDUMP_KTAB_NUM, BCDUMP_KTAB_STR +}; + +/* -- Bytecode reader/writer ---------------------------------------------- */ + +LJ_FUNC int lj_bcwrite(lua_State *L, GCproto *pt, lua_Writer writer, + void *data, int strip); +LJ_FUNC GCproto *lj_bcread(LexState *ls); + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_bcread.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_bcread.c new file mode 100644 index 000000000..25859d2fa --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_bcread.c @@ -0,0 +1,476 @@ +/* +** Bytecode reader. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_bcread_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_bc.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#include "lj_cdata.h" +#include "lualib.h" +#endif +#include "lj_lex.h" +#include "lj_bcdump.h" +#include "lj_state.h" + +/* Reuse some lexer fields for our own purposes. */ +#define bcread_flags(ls) ls->level +#define bcread_swap(ls) \ + ((bcread_flags(ls) & BCDUMP_F_BE) != LJ_BE*BCDUMP_F_BE) +#define bcread_oldtop(L, ls) restorestack(L, ls->lastline) +#define bcread_savetop(L, ls, top) \ + ls->lastline = (BCLine)savestack(L, (top)) + +/* -- Input buffer handling ----------------------------------------------- */ + +/* Throw reader error. */ +static LJ_NOINLINE void bcread_error(LexState *ls, ErrMsg em) +{ + lua_State *L = ls->L; + const char *name = ls->chunkarg; + if (*name == BCDUMP_HEAD1) name = "(binary)"; + else if (*name == '@' || *name == '=') name++; + lj_str_pushf(L, "%s: %s", name, err2msg(em)); + lj_err_throw(L, LUA_ERRSYNTAX); +} + +/* Resize input buffer. */ +static void bcread_resize(LexState *ls, MSize len) +{ + if (ls->sb.sz < len) { + MSize sz = ls->sb.sz * 2; + while (len > sz) sz = sz * 2; + lj_str_resizebuf(ls->L, &ls->sb, sz); + /* Caveat: this may change ls->sb.buf which may affect ls->p. */ + } +} + +/* Refill buffer if needed. */ +static LJ_NOINLINE void bcread_fill(LexState *ls, MSize len, int need) +{ + lua_assert(len != 0); + if (len > LJ_MAX_MEM || ls->current < 0) + bcread_error(ls, LJ_ERR_BCBAD); + do { + const char *buf; + size_t size; + if (ls->n) { /* Copy remainder to buffer. */ + if (ls->sb.n) { /* Move down in buffer. */ + lua_assert(ls->p + ls->n == ls->sb.buf + ls->sb.n); + if (ls->n != ls->sb.n) + memmove(ls->sb.buf, ls->p, ls->n); + } else { /* Copy from buffer provided by reader. */ + bcread_resize(ls, len); + memcpy(ls->sb.buf, ls->p, ls->n); + } + ls->p = ls->sb.buf; + } + ls->sb.n = ls->n; + buf = ls->rfunc(ls->L, ls->rdata, &size); /* Get more data from reader. */ + if (buf == NULL || size == 0) { /* EOF? */ + if (need) bcread_error(ls, LJ_ERR_BCBAD); + ls->current = -1; /* Only bad if we get called again. */ + break; + } + if (ls->sb.n) { /* Append to buffer. */ + MSize n = ls->sb.n + (MSize)size; + bcread_resize(ls, n < len ? len : n); + memcpy(ls->sb.buf + ls->sb.n, buf, size); + ls->n = ls->sb.n = n; + ls->p = ls->sb.buf; + } else { /* Return buffer provided by reader. */ + ls->n = (MSize)size; + ls->p = buf; + } + } while (ls->n < len); +} + +/* Need a certain number of bytes. */ +static LJ_AINLINE void bcread_need(LexState *ls, MSize len) +{ + if (LJ_UNLIKELY(ls->n < len)) + bcread_fill(ls, len, 1); +} + +/* Want to read up to a certain number of bytes, but may need less. */ +static LJ_AINLINE void bcread_want(LexState *ls, MSize len) +{ + if (LJ_UNLIKELY(ls->n < len)) + bcread_fill(ls, len, 0); +} + +#define bcread_dec(ls) check_exp(ls->n > 0, ls->n--) +#define bcread_consume(ls, len) check_exp(ls->n >= (len), ls->n -= (len)) + +/* Return memory block from buffer. */ +static uint8_t *bcread_mem(LexState *ls, MSize len) +{ + uint8_t *p = (uint8_t *)ls->p; + bcread_consume(ls, len); + ls->p = (char *)p + len; + return p; +} + +/* Copy memory block from buffer. */ +static void bcread_block(LexState *ls, void *q, MSize len) +{ + memcpy(q, bcread_mem(ls, len), len); +} + +/* Read byte from buffer. */ +static LJ_AINLINE uint32_t bcread_byte(LexState *ls) +{ + bcread_dec(ls); + return (uint32_t)(uint8_t)*ls->p++; +} + +/* Read ULEB128 value from buffer. */ +static uint32_t bcread_uleb128(LexState *ls) +{ + const uint8_t *p = (const uint8_t *)ls->p; + uint32_t v = *p++; + if (LJ_UNLIKELY(v >= 0x80)) { + int sh = 0; + v &= 0x7f; + do { + v |= ((*p & 0x7f) << (sh += 7)); + bcread_dec(ls); + } while (*p++ >= 0x80); + } + bcread_dec(ls); + ls->p = (char *)p; + return v; +} + +/* Read top 32 bits of 33 bit ULEB128 value from buffer. */ +static uint32_t bcread_uleb128_33(LexState *ls) +{ + const uint8_t *p = (const uint8_t *)ls->p; + uint32_t v = (*p++ >> 1); + if (LJ_UNLIKELY(v >= 0x40)) { + int sh = -1; + v &= 0x3f; + do { + v |= ((*p & 0x7f) << (sh += 7)); + bcread_dec(ls); + } while (*p++ >= 0x80); + } + bcread_dec(ls); + ls->p = (char *)p; + return v; +} + +/* -- Bytecode reader ----------------------------------------------------- */ + +/* Read debug info of a prototype. */ +static void bcread_dbg(LexState *ls, GCproto *pt, MSize sizedbg) +{ + void *lineinfo = (void *)proto_lineinfo(pt); + bcread_block(ls, lineinfo, sizedbg); + /* Swap lineinfo if the endianess differs. */ + if (bcread_swap(ls) && pt->numline >= 256) { + MSize i, n = pt->sizebc-1; + if (pt->numline < 65536) { + uint16_t *p = (uint16_t *)lineinfo; + for (i = 0; i < n; i++) p[i] = (uint16_t)((p[i] >> 8)|(p[i] << 8)); + } else { + uint32_t *p = (uint32_t *)lineinfo; + for (i = 0; i < n; i++) p[i] = lj_bswap(p[i]); + } + } +} + +/* Find pointer to varinfo. */ +static const void *bcread_varinfo(GCproto *pt) +{ + const uint8_t *p = proto_uvinfo(pt); + MSize n = pt->sizeuv; + if (n) while (*p++ || --n) ; + return p; +} + +/* Read a single constant key/value of a template table. */ +static void bcread_ktabk(LexState *ls, TValue *o) +{ + MSize tp = bcread_uleb128(ls); + if (tp >= BCDUMP_KTAB_STR) { + MSize len = tp - BCDUMP_KTAB_STR; + const char *p = (const char *)bcread_mem(ls, len); + setstrV(ls->L, o, lj_str_new(ls->L, p, len)); + } else if (tp == BCDUMP_KTAB_INT) { + setintV(o, (int32_t)bcread_uleb128(ls)); + } else if (tp == BCDUMP_KTAB_NUM) { + o->u32.lo = bcread_uleb128(ls); + o->u32.hi = bcread_uleb128(ls); + } else { + lua_assert(tp <= BCDUMP_KTAB_TRUE); + setitype(o, ~tp); + } +} + +/* Read a template table. */ +static GCtab *bcread_ktab(LexState *ls) +{ + MSize narray = bcread_uleb128(ls); + MSize nhash = bcread_uleb128(ls); + GCtab *t = lj_tab_new(ls->L, narray, hsize2hbits(nhash)); + if (narray) { /* Read array entries. */ + MSize i; + TValue *o = tvref(t->array); + for (i = 0; i < narray; i++, o++) + bcread_ktabk(ls, o); + } + if (nhash) { /* Read hash entries. */ + MSize i; + for (i = 0; i < nhash; i++) { + TValue key; + bcread_ktabk(ls, &key); + lua_assert(!tvisnil(&key)); + bcread_ktabk(ls, lj_tab_set(ls->L, t, &key)); + } + } + return t; +} + +/* Read GC constants of a prototype. */ +static void bcread_kgc(LexState *ls, GCproto *pt, MSize sizekgc) +{ + MSize i; + GCRef *kr = mref(pt->k, GCRef) - (ptrdiff_t)sizekgc; + for (i = 0; i < sizekgc; i++, kr++) { + MSize tp = bcread_uleb128(ls); + if (tp >= BCDUMP_KGC_STR) { + MSize len = tp - BCDUMP_KGC_STR; + const char *p = (const char *)bcread_mem(ls, len); + setgcref(*kr, obj2gco(lj_str_new(ls->L, p, len))); + } else if (tp == BCDUMP_KGC_TAB) { + setgcref(*kr, obj2gco(bcread_ktab(ls))); +#if LJ_HASFFI + } else if (tp != BCDUMP_KGC_CHILD) { + CTypeID id = tp == BCDUMP_KGC_COMPLEX ? CTID_COMPLEX_DOUBLE : + tp == BCDUMP_KGC_I64 ? CTID_INT64 : CTID_UINT64; + CTSize sz = tp == BCDUMP_KGC_COMPLEX ? 16 : 8; + GCcdata *cd = lj_cdata_new_(ls->L, id, sz); + TValue *p = (TValue *)cdataptr(cd); + setgcref(*kr, obj2gco(cd)); + p[0].u32.lo = bcread_uleb128(ls); + p[0].u32.hi = bcread_uleb128(ls); + if (tp == BCDUMP_KGC_COMPLEX) { + p[1].u32.lo = bcread_uleb128(ls); + p[1].u32.hi = bcread_uleb128(ls); + } +#endif + } else { + lua_State *L = ls->L; + lua_assert(tp == BCDUMP_KGC_CHILD); + if (L->top <= bcread_oldtop(L, ls)) /* Stack underflow? */ + bcread_error(ls, LJ_ERR_BCBAD); + L->top--; + setgcref(*kr, obj2gco(protoV(L->top))); + } + } +} + +/* Read number constants of a prototype. */ +static void bcread_knum(LexState *ls, GCproto *pt, MSize sizekn) +{ + MSize i; + TValue *o = mref(pt->k, TValue); + for (i = 0; i < sizekn; i++, o++) { + int isnum = (ls->p[0] & 1); + uint32_t lo = bcread_uleb128_33(ls); + if (isnum) { + o->u32.lo = lo; + o->u32.hi = bcread_uleb128(ls); + } else { + setintV(o, lo); + } + } +} + +/* Read bytecode instructions. */ +static void bcread_bytecode(LexState *ls, GCproto *pt, MSize sizebc) +{ + BCIns *bc = proto_bc(pt); + bc[0] = BCINS_AD((pt->flags & PROTO_VARARG) ? BC_FUNCV : BC_FUNCF, + pt->framesize, 0); + bcread_block(ls, bc+1, (sizebc-1)*(MSize)sizeof(BCIns)); + /* Swap bytecode instructions if the endianess differs. */ + if (bcread_swap(ls)) { + MSize i; + for (i = 1; i < sizebc; i++) bc[i] = lj_bswap(bc[i]); + } +} + +/* Read upvalue refs. */ +static void bcread_uv(LexState *ls, GCproto *pt, MSize sizeuv) +{ + if (sizeuv) { + uint16_t *uv = proto_uv(pt); + bcread_block(ls, uv, sizeuv*2); + /* Swap upvalue refs if the endianess differs. */ + if (bcread_swap(ls)) { + MSize i; + for (i = 0; i < sizeuv; i++) + uv[i] = (uint16_t)((uv[i] >> 8)|(uv[i] << 8)); + } + } +} + +/* Read a prototype. */ +static GCproto *bcread_proto(LexState *ls) +{ + GCproto *pt; + MSize framesize, numparams, flags, sizeuv, sizekgc, sizekn, sizebc, sizept; + MSize ofsk, ofsuv, ofsdbg; + MSize sizedbg = 0; + BCLine firstline = 0, numline = 0; + MSize len, startn; + + /* Read length. */ + if (ls->n > 0 && ls->p[0] == 0) { /* Shortcut EOF. */ + ls->n--; ls->p++; + return NULL; + } + bcread_want(ls, 5); + len = bcread_uleb128(ls); + if (!len) return NULL; /* EOF */ + bcread_need(ls, len); + startn = ls->n; + + /* Read prototype header. */ + flags = bcread_byte(ls); + numparams = bcread_byte(ls); + framesize = bcread_byte(ls); + sizeuv = bcread_byte(ls); + sizekgc = bcread_uleb128(ls); + sizekn = bcread_uleb128(ls); + sizebc = bcread_uleb128(ls) + 1; + if (!(bcread_flags(ls) & BCDUMP_F_STRIP)) { + sizedbg = bcread_uleb128(ls); + if (sizedbg) { + firstline = bcread_uleb128(ls); + numline = bcread_uleb128(ls); + } + } + + /* Calculate total size of prototype including all colocated arrays. */ + sizept = (MSize)sizeof(GCproto) + + sizebc*(MSize)sizeof(BCIns) + + sizekgc*(MSize)sizeof(GCRef); + sizept = (sizept + (MSize)sizeof(TValue)-1) & ~((MSize)sizeof(TValue)-1); + ofsk = sizept; sizept += sizekn*(MSize)sizeof(TValue); + ofsuv = sizept; sizept += ((sizeuv+1)&~1)*2; + ofsdbg = sizept; sizept += sizedbg; + + /* Allocate prototype object and initialize its fields. */ + pt = (GCproto *)lj_mem_newgco(ls->L, (MSize)sizept); + pt->gct = ~LJ_TPROTO; + pt->numparams = (uint8_t)numparams; + pt->framesize = (uint8_t)framesize; + pt->sizebc = sizebc; + setmref(pt->k, (char *)pt + ofsk); + setmref(pt->uv, (char *)pt + ofsuv); + pt->sizekgc = 0; /* Set to zero until fully initialized. */ + pt->sizekn = sizekn; + pt->sizept = sizept; + pt->sizeuv = (uint8_t)sizeuv; + pt->flags = (uint8_t)flags; + pt->trace = 0; + setgcref(pt->chunkname, obj2gco(ls->chunkname)); + + /* Close potentially uninitialized gap between bc and kgc. */ + *(uint32_t *)((char *)pt + ofsk - sizeof(GCRef)*(sizekgc+1)) = 0; + + /* Read bytecode instructions and upvalue refs. */ + bcread_bytecode(ls, pt, sizebc); + bcread_uv(ls, pt, sizeuv); + + /* Read constants. */ + bcread_kgc(ls, pt, sizekgc); + pt->sizekgc = sizekgc; + bcread_knum(ls, pt, sizekn); + + /* Read and initialize debug info. */ + pt->firstline = firstline; + pt->numline = numline; + if (sizedbg) { + MSize sizeli = (sizebc-1) << (numline < 256 ? 0 : numline < 65536 ? 1 : 2); + setmref(pt->lineinfo, (char *)pt + ofsdbg); + setmref(pt->uvinfo, (char *)pt + ofsdbg + sizeli); + bcread_dbg(ls, pt, sizedbg); + setmref(pt->varinfo, bcread_varinfo(pt)); + } else { + setmref(pt->lineinfo, NULL); + setmref(pt->uvinfo, NULL); + setmref(pt->varinfo, NULL); + } + + if (len != startn - ls->n) + bcread_error(ls, LJ_ERR_BCBAD); + return pt; +} + +/* Read and check header of bytecode dump. */ +static int bcread_header(LexState *ls) +{ + uint32_t flags; + bcread_want(ls, 3+5+5); + if (bcread_byte(ls) != BCDUMP_HEAD2 || + bcread_byte(ls) != BCDUMP_HEAD3 || + bcread_byte(ls) != BCDUMP_VERSION) return 0; + bcread_flags(ls) = flags = bcread_uleb128(ls); + if ((flags & ~(BCDUMP_F_KNOWN)) != 0) return 0; + if ((flags & BCDUMP_F_FFI)) { +#if LJ_HASFFI + lua_State *L = ls->L; + if (!ctype_ctsG(G(L))) { + ptrdiff_t oldtop = savestack(L, L->top); + luaopen_ffi(L); /* Load FFI library on-demand. */ + L->top = restorestack(L, oldtop); + } +#else + return 0; +#endif + } + if ((flags & BCDUMP_F_STRIP)) { + ls->chunkname = lj_str_newz(ls->L, ls->chunkarg); + } else { + MSize len = bcread_uleb128(ls); + bcread_need(ls, len); + ls->chunkname = lj_str_new(ls->L, (const char *)bcread_mem(ls, len), len); + } + return 1; /* Ok. */ +} + +/* Read a bytecode dump. */ +GCproto *lj_bcread(LexState *ls) +{ + lua_State *L = ls->L; + lua_assert(ls->current == BCDUMP_HEAD1); + bcread_savetop(L, ls, L->top); + lj_str_resetbuf(&ls->sb); + /* Check for a valid bytecode dump header. */ + if (!bcread_header(ls)) + bcread_error(ls, LJ_ERR_BCFMT); + for (;;) { /* Process all prototypes in the bytecode dump. */ + GCproto *pt = bcread_proto(ls); + if (!pt) break; + setprotoV(L, L->top, pt); + incr_top(L); + } + if ((int32_t)ls->n > 0 || L->top-1 != bcread_oldtop(L, ls)) + bcread_error(ls, LJ_ERR_BCBAD); + /* Pop off last prototype. */ + L->top--; + return protoV(L->top); +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_bcwrite.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_bcwrite.c new file mode 100644 index 000000000..ff97450b8 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_bcwrite.c @@ -0,0 +1,396 @@ +/* +** Bytecode writer. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_bcwrite_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_str.h" +#include "lj_bc.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#endif +#if LJ_HASJIT +#include "lj_dispatch.h" +#include "lj_jit.h" +#endif +#include "lj_bcdump.h" +#include "lj_vm.h" + +/* Context for bytecode writer. */ +typedef struct BCWriteCtx { + SBuf sb; /* Output buffer. */ + lua_State *L; /* Lua state. */ + GCproto *pt; /* Root prototype. */ + lua_Writer wfunc; /* Writer callback. */ + void *wdata; /* Writer callback data. */ + int strip; /* Strip debug info. */ + int status; /* Status from writer callback. */ +} BCWriteCtx; + +/* -- Output buffer handling ---------------------------------------------- */ + +/* Resize buffer if needed. */ +static LJ_NOINLINE void bcwrite_resize(BCWriteCtx *ctx, MSize len) +{ + MSize sz = ctx->sb.sz * 2; + while (ctx->sb.n + len > sz) sz = sz * 2; + lj_str_resizebuf(ctx->L, &ctx->sb, sz); +} + +/* Need a certain amount of buffer space. */ +static LJ_AINLINE void bcwrite_need(BCWriteCtx *ctx, MSize len) +{ + if (LJ_UNLIKELY(ctx->sb.n + len > ctx->sb.sz)) + bcwrite_resize(ctx, len); +} + +/* Add memory block to buffer. */ +static void bcwrite_block(BCWriteCtx *ctx, const void *p, MSize len) +{ + uint8_t *q = (uint8_t *)(ctx->sb.buf + ctx->sb.n); + MSize i; + ctx->sb.n += len; + for (i = 0; i < len; i++) q[i] = ((uint8_t *)p)[i]; +} + +/* Add byte to buffer. */ +static LJ_AINLINE void bcwrite_byte(BCWriteCtx *ctx, uint8_t b) +{ + ctx->sb.buf[ctx->sb.n++] = b; +} + +/* Add ULEB128 value to buffer. */ +static void bcwrite_uleb128(BCWriteCtx *ctx, uint32_t v) +{ + MSize n = ctx->sb.n; + uint8_t *p = (uint8_t *)ctx->sb.buf; + for (; v >= 0x80; v >>= 7) + p[n++] = (uint8_t)((v & 0x7f) | 0x80); + p[n++] = (uint8_t)v; + ctx->sb.n = n; +} + +/* -- Bytecode writer ----------------------------------------------------- */ + +/* Write a single constant key/value of a template table. */ +static void bcwrite_ktabk(BCWriteCtx *ctx, cTValue *o, int narrow) +{ + bcwrite_need(ctx, 1+10); + if (tvisstr(o)) { + const GCstr *str = strV(o); + MSize len = str->len; + bcwrite_need(ctx, 5+len); + bcwrite_uleb128(ctx, BCDUMP_KTAB_STR+len); + bcwrite_block(ctx, strdata(str), len); + } else if (tvisint(o)) { + bcwrite_byte(ctx, BCDUMP_KTAB_INT); + bcwrite_uleb128(ctx, intV(o)); + } else if (tvisnum(o)) { + if (!LJ_DUALNUM && narrow) { /* Narrow number constants to integers. */ + lua_Number num = numV(o); + int32_t k = lj_num2int(num); + if (num == (lua_Number)k) { /* -0 is never a constant. */ + bcwrite_byte(ctx, BCDUMP_KTAB_INT); + bcwrite_uleb128(ctx, k); + return; + } + } + bcwrite_byte(ctx, BCDUMP_KTAB_NUM); + bcwrite_uleb128(ctx, o->u32.lo); + bcwrite_uleb128(ctx, o->u32.hi); + } else { + lua_assert(tvispri(o)); + bcwrite_byte(ctx, BCDUMP_KTAB_NIL+~itype(o)); + } +} + +/* Write a template table. */ +static void bcwrite_ktab(BCWriteCtx *ctx, const GCtab *t) +{ + MSize narray = 0, nhash = 0; + if (t->asize > 0) { /* Determine max. length of array part. */ + ptrdiff_t i; + TValue *array = tvref(t->array); + for (i = (ptrdiff_t)t->asize-1; i >= 0; i--) + if (!tvisnil(&array[i])) + break; + narray = (MSize)(i+1); + } + if (t->hmask > 0) { /* Count number of used hash slots. */ + MSize i, hmask = t->hmask; + Node *node = noderef(t->node); + for (i = 0; i <= hmask; i++) + nhash += !tvisnil(&node[i].val); + } + /* Write number of array slots and hash slots. */ + bcwrite_uleb128(ctx, narray); + bcwrite_uleb128(ctx, nhash); + if (narray) { /* Write array entries (may contain nil). */ + MSize i; + TValue *o = tvref(t->array); + for (i = 0; i < narray; i++, o++) + bcwrite_ktabk(ctx, o, 1); + } + if (nhash) { /* Write hash entries. */ + MSize i = nhash; + Node *node = noderef(t->node) + t->hmask; + for (;; node--) + if (!tvisnil(&node->val)) { + bcwrite_ktabk(ctx, &node->key, 0); + bcwrite_ktabk(ctx, &node->val, 1); + if (--i == 0) break; + } + } +} + +/* Write GC constants of a prototype. */ +static void bcwrite_kgc(BCWriteCtx *ctx, GCproto *pt) +{ + MSize i, sizekgc = pt->sizekgc; + GCRef *kr = mref(pt->k, GCRef) - (ptrdiff_t)sizekgc; + for (i = 0; i < sizekgc; i++, kr++) { + GCobj *o = gcref(*kr); + MSize tp, need = 1; + /* Determine constant type and needed size. */ + if (o->gch.gct == ~LJ_TSTR) { + tp = BCDUMP_KGC_STR + gco2str(o)->len; + need = 5+gco2str(o)->len; + } else if (o->gch.gct == ~LJ_TPROTO) { + lua_assert((pt->flags & PROTO_CHILD)); + tp = BCDUMP_KGC_CHILD; +#if LJ_HASFFI + } else if (o->gch.gct == ~LJ_TCDATA) { + CTypeID id = gco2cd(o)->ctypeid; + need = 1+4*5; + if (id == CTID_INT64) { + tp = BCDUMP_KGC_I64; + } else if (id == CTID_UINT64) { + tp = BCDUMP_KGC_U64; + } else { + lua_assert(id == CTID_COMPLEX_DOUBLE); + tp = BCDUMP_KGC_COMPLEX; + } +#endif + } else { + lua_assert(o->gch.gct == ~LJ_TTAB); + tp = BCDUMP_KGC_TAB; + need = 1+2*5; + } + /* Write constant type. */ + bcwrite_need(ctx, need); + bcwrite_uleb128(ctx, tp); + /* Write constant data (if any). */ + if (tp >= BCDUMP_KGC_STR) { + bcwrite_block(ctx, strdata(gco2str(o)), gco2str(o)->len); + } else if (tp == BCDUMP_KGC_TAB) { + bcwrite_ktab(ctx, gco2tab(o)); +#if LJ_HASFFI + } else if (tp != BCDUMP_KGC_CHILD) { + cTValue *p = (TValue *)cdataptr(gco2cd(o)); + bcwrite_uleb128(ctx, p[0].u32.lo); + bcwrite_uleb128(ctx, p[0].u32.hi); + if (tp == BCDUMP_KGC_COMPLEX) { + bcwrite_uleb128(ctx, p[1].u32.lo); + bcwrite_uleb128(ctx, p[1].u32.hi); + } +#endif + } + } +} + +/* Write number constants of a prototype. */ +static void bcwrite_knum(BCWriteCtx *ctx, GCproto *pt) +{ + MSize i, sizekn = pt->sizekn; + cTValue *o = mref(pt->k, TValue); + bcwrite_need(ctx, 10*sizekn); + for (i = 0; i < sizekn; i++, o++) { + int32_t k; + if (tvisint(o)) { + k = intV(o); + goto save_int; + } else { + /* Write a 33 bit ULEB128 for the int (lsb=0) or loword (lsb=1). */ + if (!LJ_DUALNUM) { /* Narrow number constants to integers. */ + lua_Number num = numV(o); + k = lj_num2int(num); + if (num == (lua_Number)k) { /* -0 is never a constant. */ + save_int: + bcwrite_uleb128(ctx, 2*(uint32_t)k | ((uint32_t)k & 0x80000000u)); + if (k < 0) { + char *p = &ctx->sb.buf[ctx->sb.n-1]; + *p = (*p & 7) | ((k>>27) & 0x18); + } + continue; + } + } + bcwrite_uleb128(ctx, 1+(2*o->u32.lo | (o->u32.lo & 0x80000000u))); + if (o->u32.lo >= 0x80000000u) { + char *p = &ctx->sb.buf[ctx->sb.n-1]; + *p = (*p & 7) | ((o->u32.lo>>27) & 0x18); + } + bcwrite_uleb128(ctx, o->u32.hi); + } + } +} + +/* Write bytecode instructions. */ +static void bcwrite_bytecode(BCWriteCtx *ctx, GCproto *pt) +{ + MSize nbc = pt->sizebc-1; /* Omit the [JI]FUNC* header. */ +#if LJ_HASJIT + uint8_t *p = (uint8_t *)&ctx->sb.buf[ctx->sb.n]; +#endif + bcwrite_block(ctx, proto_bc(pt)+1, nbc*(MSize)sizeof(BCIns)); +#if LJ_HASJIT + /* Unpatch modified bytecode containing ILOOP/JLOOP etc. */ + if ((pt->flags & PROTO_ILOOP) || pt->trace) { + jit_State *J = L2J(ctx->L); + MSize i; + for (i = 0; i < nbc; i++, p += sizeof(BCIns)) { + BCOp op = (BCOp)p[LJ_ENDIAN_SELECT(0, 3)]; + if (op == BC_IFORL || op == BC_IITERL || op == BC_ILOOP || + op == BC_JFORI) { + p[LJ_ENDIAN_SELECT(0, 3)] = (uint8_t)(op-BC_IFORL+BC_FORL); + } else if (op == BC_JFORL || op == BC_JITERL || op == BC_JLOOP) { + BCReg rd = p[LJ_ENDIAN_SELECT(2, 1)] + (p[LJ_ENDIAN_SELECT(3, 0)] << 8); + BCIns ins = traceref(J, rd)->startins; + p[LJ_ENDIAN_SELECT(0, 3)] = (uint8_t)(op-BC_JFORL+BC_FORL); + p[LJ_ENDIAN_SELECT(2, 1)] = bc_c(ins); + p[LJ_ENDIAN_SELECT(3, 0)] = bc_b(ins); + } + } + } +#endif +} + +/* Write prototype. */ +static void bcwrite_proto(BCWriteCtx *ctx, GCproto *pt) +{ + MSize sizedbg = 0; + + /* Recursively write children of prototype. */ + if ((pt->flags & PROTO_CHILD)) { + ptrdiff_t i, n = pt->sizekgc; + GCRef *kr = mref(pt->k, GCRef) - 1; + for (i = 0; i < n; i++, kr--) { + GCobj *o = gcref(*kr); + if (o->gch.gct == ~LJ_TPROTO) + bcwrite_proto(ctx, gco2pt(o)); + } + } + + /* Start writing the prototype info to a buffer. */ + lj_str_resetbuf(&ctx->sb); + ctx->sb.n = 5; /* Leave room for final size. */ + bcwrite_need(ctx, 4+6*5+(pt->sizebc-1)*(MSize)sizeof(BCIns)+pt->sizeuv*2); + + /* Write prototype header. */ + bcwrite_byte(ctx, (pt->flags & (PROTO_CHILD|PROTO_VARARG|PROTO_FFI))); + bcwrite_byte(ctx, pt->numparams); + bcwrite_byte(ctx, pt->framesize); + bcwrite_byte(ctx, pt->sizeuv); + bcwrite_uleb128(ctx, pt->sizekgc); + bcwrite_uleb128(ctx, pt->sizekn); + bcwrite_uleb128(ctx, pt->sizebc-1); + if (!ctx->strip) { + if (proto_lineinfo(pt)) + sizedbg = pt->sizept - (MSize)((char *)proto_lineinfo(pt) - (char *)pt); + bcwrite_uleb128(ctx, sizedbg); + if (sizedbg) { + bcwrite_uleb128(ctx, pt->firstline); + bcwrite_uleb128(ctx, pt->numline); + } + } + + /* Write bytecode instructions and upvalue refs. */ + bcwrite_bytecode(ctx, pt); + bcwrite_block(ctx, proto_uv(pt), pt->sizeuv*2); + + /* Write constants. */ + bcwrite_kgc(ctx, pt); + bcwrite_knum(ctx, pt); + + /* Write debug info, if not stripped. */ + if (sizedbg) { + bcwrite_need(ctx, sizedbg); + bcwrite_block(ctx, proto_lineinfo(pt), sizedbg); + } + + /* Pass buffer to writer function. */ + if (ctx->status == 0) { + MSize n = ctx->sb.n - 5; + MSize nn = (lj_fls(n)+8)*9 >> 6; + ctx->sb.n = 5 - nn; + bcwrite_uleb128(ctx, n); /* Fill in final size. */ + lua_assert(ctx->sb.n == 5); + ctx->status = ctx->wfunc(ctx->L, ctx->sb.buf+5-nn, nn+n, ctx->wdata); + } +} + +/* Write header of bytecode dump. */ +static void bcwrite_header(BCWriteCtx *ctx) +{ + GCstr *chunkname = proto_chunkname(ctx->pt); + const char *name = strdata(chunkname); + MSize len = chunkname->len; + lj_str_resetbuf(&ctx->sb); + bcwrite_need(ctx, 5+5+len); + bcwrite_byte(ctx, BCDUMP_HEAD1); + bcwrite_byte(ctx, BCDUMP_HEAD2); + bcwrite_byte(ctx, BCDUMP_HEAD3); + bcwrite_byte(ctx, BCDUMP_VERSION); + bcwrite_byte(ctx, (ctx->strip ? BCDUMP_F_STRIP : 0) + + (LJ_BE ? BCDUMP_F_BE : 0) + + ((ctx->pt->flags & PROTO_FFI) ? BCDUMP_F_FFI : 0)); + if (!ctx->strip) { + bcwrite_uleb128(ctx, len); + bcwrite_block(ctx, name, len); + } + ctx->status = ctx->wfunc(ctx->L, ctx->sb.buf, ctx->sb.n, ctx->wdata); +} + +/* Write footer of bytecode dump. */ +static void bcwrite_footer(BCWriteCtx *ctx) +{ + if (ctx->status == 0) { + uint8_t zero = 0; + ctx->status = ctx->wfunc(ctx->L, &zero, 1, ctx->wdata); + } +} + +/* Protected callback for bytecode writer. */ +static TValue *cpwriter(lua_State *L, lua_CFunction dummy, void *ud) +{ + BCWriteCtx *ctx = (BCWriteCtx *)ud; + UNUSED(dummy); + lj_str_resizebuf(L, &ctx->sb, 1024); /* Avoids resize for most prototypes. */ + bcwrite_header(ctx); + bcwrite_proto(ctx, ctx->pt); + bcwrite_footer(ctx); + return NULL; +} + +/* Write bytecode for a prototype. */ +int lj_bcwrite(lua_State *L, GCproto *pt, lua_Writer writer, void *data, + int strip) +{ + BCWriteCtx ctx; + int status; + ctx.L = L; + ctx.pt = pt; + ctx.wfunc = writer; + ctx.wdata = data; + ctx.strip = strip; + ctx.status = 0; + lj_str_initbuf(&ctx.sb); + status = lj_vm_cpcall(L, NULL, &ctx, cpwriter); + if (status == 0) status = ctx.status; + lj_str_freebuf(G(ctx.L), &ctx.sb); + return status; +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_carith.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_carith.c new file mode 100644 index 000000000..2a358a9bb --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_carith.c @@ -0,0 +1,353 @@ +/* +** C data arithmetic. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "lj_obj.h" + +#if LJ_HASFFI + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_tab.h" +#include "lj_meta.h" +#include "lj_ctype.h" +#include "lj_cconv.h" +#include "lj_cdata.h" +#include "lj_carith.h" + +/* -- C data arithmetic --------------------------------------------------- */ + +/* Binary operands of an operator converted to ctypes. */ +typedef struct CDArith { + uint8_t *p[2]; + CType *ct[2]; +} CDArith; + +/* Check arguments for arithmetic metamethods. */ +static int carith_checkarg(lua_State *L, CTState *cts, CDArith *ca) +{ + TValue *o = L->base; + int ok = 1; + MSize i; + if (o+1 >= L->top) + lj_err_argt(L, 1, LUA_TCDATA); + for (i = 0; i < 2; i++, o++) { + if (tviscdata(o)) { + GCcdata *cd = cdataV(o); + CTypeID id = (CTypeID)cd->ctypeid; + CType *ct = ctype_raw(cts, id); + uint8_t *p = (uint8_t *)cdataptr(cd); + if (ctype_isptr(ct->info)) { + p = (uint8_t *)cdata_getptr(p, ct->size); + if (ctype_isref(ct->info)) ct = ctype_rawchild(cts, ct); + } else if (ctype_isfunc(ct->info)) { + p = (uint8_t *)*(void **)p; + ct = ctype_get(cts, + lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|id), CTSIZE_PTR)); + } + if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); + ca->ct[i] = ct; + ca->p[i] = p; + } else if (tvisint(o)) { + ca->ct[i] = ctype_get(cts, CTID_INT32); + ca->p[i] = (uint8_t *)&o->i; + } else if (tvisnum(o)) { + ca->ct[i] = ctype_get(cts, CTID_DOUBLE); + ca->p[i] = (uint8_t *)&o->n; + } else if (tvisnil(o)) { + ca->ct[i] = ctype_get(cts, CTID_P_VOID); + ca->p[i] = (uint8_t *)0; + } else if (tvisstr(o)) { + TValue *o2 = i == 0 ? o+1 : o-1; + CType *ct = ctype_raw(cts, cdataV(o2)->ctypeid); + ca->ct[i] = NULL; + ca->p[i] = (uint8_t *)strVdata(o); + ok = 0; + if (ctype_isenum(ct->info)) { + CTSize ofs; + CType *cct = lj_ctype_getfield(cts, ct, strV(o), &ofs); + if (cct && ctype_isconstval(cct->info)) { + ca->ct[i] = ctype_child(cts, cct); + ca->p[i] = (uint8_t *)&cct->size; /* Assumes ct does not grow. */ + ok = 1; + } else { + ca->ct[1-i] = ct; /* Use enum to improve error message. */ + ca->p[1-i] = NULL; + break; + } + } + } else { + ca->ct[i] = NULL; + ca->p[i] = (void *)(intptr_t)1; /* To make it unequal. */ + ok = 0; + } + } + return ok; +} + +/* Pointer arithmetic. */ +static int carith_ptr(lua_State *L, CTState *cts, CDArith *ca, MMS mm) +{ + CType *ctp = ca->ct[0]; + uint8_t *pp = ca->p[0]; + ptrdiff_t idx; + CTSize sz; + CTypeID id; + GCcdata *cd; + if (ctype_isptr(ctp->info) || ctype_isrefarray(ctp->info)) { + if ((mm == MM_sub || mm == MM_eq || mm == MM_lt || mm == MM_le) && + (ctype_isptr(ca->ct[1]->info) || ctype_isrefarray(ca->ct[1]->info))) { + uint8_t *pp2 = ca->p[1]; + if (mm == MM_eq) { /* Pointer equality. Incompatible pointers are ok. */ + setboolV(L->top-1, (pp == pp2)); + return 1; + } + if (!lj_cconv_compatptr(cts, ctp, ca->ct[1], CCF_IGNQUAL)) + return 0; + if (mm == MM_sub) { /* Pointer difference. */ + intptr_t diff; + sz = lj_ctype_size(cts, ctype_cid(ctp->info)); /* Element size. */ + if (sz == 0 || sz == CTSIZE_INVALID) + return 0; + diff = ((intptr_t)pp - (intptr_t)pp2) / (int32_t)sz; + /* All valid pointer differences on x64 are in (-2^47, +2^47), + ** which fits into a double without loss of precision. + */ + setintptrV(L->top-1, (int32_t)diff); + return 1; + } else if (mm == MM_lt) { /* Pointer comparison (unsigned). */ + setboolV(L->top-1, ((uintptr_t)pp < (uintptr_t)pp2)); + return 1; + } else { + lua_assert(mm == MM_le); + setboolV(L->top-1, ((uintptr_t)pp <= (uintptr_t)pp2)); + return 1; + } + } + if (!((mm == MM_add || mm == MM_sub) && ctype_isnum(ca->ct[1]->info))) + return 0; + lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT_PSZ), ca->ct[1], + (uint8_t *)&idx, ca->p[1], 0); + if (mm == MM_sub) idx = -idx; + } else if (mm == MM_add && ctype_isnum(ctp->info) && + (ctype_isptr(ca->ct[1]->info) || ctype_isrefarray(ca->ct[1]->info))) { + /* Swap pointer and index. */ + ctp = ca->ct[1]; pp = ca->p[1]; + lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT_PSZ), ca->ct[0], + (uint8_t *)&idx, ca->p[0], 0); + } else { + return 0; + } + sz = lj_ctype_size(cts, ctype_cid(ctp->info)); /* Element size. */ + if (sz == CTSIZE_INVALID) + return 0; + pp += idx*(int32_t)sz; /* Compute pointer + index. */ + id = lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|ctype_cid(ctp->info)), + CTSIZE_PTR); + cd = lj_cdata_new(cts, id, CTSIZE_PTR); + *(uint8_t **)cdataptr(cd) = pp; + setcdataV(L, L->top-1, cd); + lj_gc_check(L); + return 1; +} + +/* 64 bit integer arithmetic. */ +static int carith_int64(lua_State *L, CTState *cts, CDArith *ca, MMS mm) +{ + if (ctype_isnum(ca->ct[0]->info) && ca->ct[0]->size <= 8 && + ctype_isnum(ca->ct[1]->info) && ca->ct[1]->size <= 8) { + CTypeID id = (((ca->ct[0]->info & CTF_UNSIGNED) && ca->ct[0]->size == 8) || + ((ca->ct[1]->info & CTF_UNSIGNED) && ca->ct[1]->size == 8)) ? + CTID_UINT64 : CTID_INT64; + CType *ct = ctype_get(cts, id); + GCcdata *cd; + uint64_t u0, u1, *up; + lj_cconv_ct_ct(cts, ct, ca->ct[0], (uint8_t *)&u0, ca->p[0], 0); + if (mm != MM_unm) + lj_cconv_ct_ct(cts, ct, ca->ct[1], (uint8_t *)&u1, ca->p[1], 0); + switch (mm) { + case MM_eq: + setboolV(L->top-1, (u0 == u1)); + return 1; + case MM_lt: + setboolV(L->top-1, + id == CTID_INT64 ? ((int64_t)u0 < (int64_t)u1) : (u0 < u1)); + return 1; + case MM_le: + setboolV(L->top-1, + id == CTID_INT64 ? ((int64_t)u0 <= (int64_t)u1) : (u0 <= u1)); + return 1; + default: break; + } + cd = lj_cdata_new(cts, id, 8); + up = (uint64_t *)cdataptr(cd); + setcdataV(L, L->top-1, cd); + switch (mm) { + case MM_add: *up = u0 + u1; break; + case MM_sub: *up = u0 - u1; break; + case MM_mul: *up = u0 * u1; break; + case MM_div: + if (id == CTID_INT64) + *up = (uint64_t)lj_carith_divi64((int64_t)u0, (int64_t)u1); + else + *up = lj_carith_divu64(u0, u1); + break; + case MM_mod: + if (id == CTID_INT64) + *up = (uint64_t)lj_carith_modi64((int64_t)u0, (int64_t)u1); + else + *up = lj_carith_modu64(u0, u1); + break; + case MM_pow: + if (id == CTID_INT64) + *up = (uint64_t)lj_carith_powi64((int64_t)u0, (int64_t)u1); + else + *up = lj_carith_powu64(u0, u1); + break; + case MM_unm: *up = (uint64_t)-(int64_t)u0; break; + default: lua_assert(0); break; + } + lj_gc_check(L); + return 1; + } + return 0; +} + +/* Handle ctype arithmetic metamethods. */ +static int lj_carith_meta(lua_State *L, CTState *cts, CDArith *ca, MMS mm) +{ + cTValue *tv = NULL; + if (tviscdata(L->base)) { + CTypeID id = cdataV(L->base)->ctypeid; + CType *ct = ctype_raw(cts, id); + if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); + tv = lj_ctype_meta(cts, id, mm); + } + if (!tv && L->base+1 < L->top && tviscdata(L->base+1)) { + CTypeID id = cdataV(L->base+1)->ctypeid; + CType *ct = ctype_raw(cts, id); + if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); + tv = lj_ctype_meta(cts, id, mm); + } + if (!tv) { + const char *repr[2]; + int i, isenum = -1, isstr = -1; + if (mm == MM_eq) { /* Equality checks never raise an error. */ + int eq = ca->p[0] == ca->p[1]; + setboolV(L->top-1, eq); + setboolV(&G(L)->tmptv2, eq); /* Remember for trace recorder. */ + return 1; + } + for (i = 0; i < 2; i++) { + if (ca->ct[i] && tviscdata(L->base+i)) { + if (ctype_isenum(ca->ct[i]->info)) isenum = i; + repr[i] = strdata(lj_ctype_repr(L, ctype_typeid(cts, ca->ct[i]), NULL)); + } else { + if (tvisstr(&L->base[i])) isstr = i; + repr[i] = lj_typename(&L->base[i]); + } + } + if ((isenum ^ isstr) == 1) + lj_err_callerv(L, LJ_ERR_FFI_BADCONV, repr[isstr], repr[isenum]); + lj_err_callerv(L, mm == MM_len ? LJ_ERR_FFI_BADLEN : + mm == MM_concat ? LJ_ERR_FFI_BADCONCAT : + mm < MM_add ? LJ_ERR_FFI_BADCOMP : LJ_ERR_FFI_BADARITH, + repr[0], repr[1]); + } + return lj_meta_tailcall(L, tv); +} + +/* Arithmetic operators for cdata. */ +int lj_carith_op(lua_State *L, MMS mm) +{ + CTState *cts = ctype_cts(L); + CDArith ca; + if (carith_checkarg(L, cts, &ca)) { + if (carith_int64(L, cts, &ca, mm) || carith_ptr(L, cts, &ca, mm)) { + copyTV(L, &G(L)->tmptv2, L->top-1); /* Remember for trace recorder. */ + return 1; + } + } + return lj_carith_meta(L, cts, &ca, mm); +} + +/* -- 64 bit integer arithmetic helpers ----------------------------------- */ + +#if LJ_32 && LJ_HASJIT +/* Signed/unsigned 64 bit multiplication. */ +int64_t lj_carith_mul64(int64_t a, int64_t b) +{ + return a * b; +} +#endif + +/* Unsigned 64 bit division. */ +uint64_t lj_carith_divu64(uint64_t a, uint64_t b) +{ + if (b == 0) return U64x(80000000,00000000); + return a / b; +} + +/* Signed 64 bit division. */ +int64_t lj_carith_divi64(int64_t a, int64_t b) +{ + if (b == 0 || (a == (int64_t)U64x(80000000,00000000) && b == -1)) + return U64x(80000000,00000000); + return a / b; +} + +/* Unsigned 64 bit modulo. */ +uint64_t lj_carith_modu64(uint64_t a, uint64_t b) +{ + if (b == 0) return U64x(80000000,00000000); + return a % b; +} + +/* Signed 64 bit modulo. */ +int64_t lj_carith_modi64(int64_t a, int64_t b) +{ + if (b == 0) return U64x(80000000,00000000); + if (a == (int64_t)U64x(80000000,00000000) && b == -1) return 0; + return a % b; +} + +/* Unsigned 64 bit x^k. */ +uint64_t lj_carith_powu64(uint64_t x, uint64_t k) +{ + uint64_t y; + if (k == 0) + return 1; + for (; (k & 1) == 0; k >>= 1) x *= x; + y = x; + if ((k >>= 1) != 0) { + for (;;) { + x *= x; + if (k == 1) break; + if (k & 1) y *= x; + k >>= 1; + } + y *= x; + } + return y; +} + +/* Signed 64 bit x^k. */ +int64_t lj_carith_powi64(int64_t x, int64_t k) +{ + if (k == 0) + return 1; + if (k < 0) { + if (x == 0) + return U64x(7fffffff,ffffffff); + else if (x == 1) + return 1; + else if (x == -1) + return (k & 1) ? -1 : 1; + else + return 0; + } + return (int64_t)lj_carith_powu64((uint64_t)x, (uint64_t)k); +} + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_carith.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_carith.h new file mode 100644 index 000000000..8c4bdbbe2 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_carith.h @@ -0,0 +1,27 @@ +/* +** C data arithmetic. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_CARITH_H +#define _LJ_CARITH_H + +#include "lj_obj.h" + +#if LJ_HASFFI + +LJ_FUNC int lj_carith_op(lua_State *L, MMS mm); + +#if LJ_32 && LJ_HASJIT +LJ_FUNC int64_t lj_carith_mul64(int64_t x, int64_t k); +#endif +LJ_FUNC uint64_t lj_carith_divu64(uint64_t a, uint64_t b); +LJ_FUNC int64_t lj_carith_divi64(int64_t a, int64_t b); +LJ_FUNC uint64_t lj_carith_modu64(uint64_t a, uint64_t b); +LJ_FUNC int64_t lj_carith_modi64(int64_t a, int64_t b); +LJ_FUNC uint64_t lj_carith_powu64(uint64_t x, uint64_t k); +LJ_FUNC int64_t lj_carith_powi64(int64_t x, int64_t k); + +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_ccall.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ccall.c new file mode 100644 index 000000000..998417c1c --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ccall.c @@ -0,0 +1,900 @@ +/* +** FFI C call handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "lj_obj.h" + +#if LJ_HASFFI + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_ctype.h" +#include "lj_cconv.h" +#include "lj_cdata.h" +#include "lj_ccall.h" +#include "lj_trace.h" + +/* Target-specific handling of register arguments. */ +#if LJ_TARGET_X86 +/* -- x86 calling conventions --------------------------------------------- */ + +#if LJ_ABI_WIN + +#define CCALL_HANDLE_STRUCTRET \ + /* Return structs bigger than 8 by reference (on stack only). */ \ + cc->retref = (sz > 8); \ + if (cc->retref) cc->stack[nsp++] = (GPRArg)dp; + +#define CCALL_HANDLE_COMPLEXRET CCALL_HANDLE_STRUCTRET + +#else + +#if LJ_TARGET_OSX + +#define CCALL_HANDLE_STRUCTRET \ + /* Return structs of size 1, 2, 4 or 8 in registers. */ \ + cc->retref = !(sz == 1 || sz == 2 || sz == 4 || sz == 8); \ + if (cc->retref) { \ + if (ngpr < maxgpr) \ + cc->gpr[ngpr++] = (GPRArg)dp; \ + else \ + cc->stack[nsp++] = (GPRArg)dp; \ + } else { /* Struct with single FP field ends up in FPR. */ \ + cc->resx87 = ccall_classify_struct(cts, ctr); \ + } + +#define CCALL_HANDLE_STRUCTRET2 \ + if (cc->resx87) sp = (uint8_t *)&cc->fpr[0]; \ + memcpy(dp, sp, ctr->size); + +#else + +#define CCALL_HANDLE_STRUCTRET \ + cc->retref = 1; /* Return all structs by reference (in reg or on stack). */ \ + if (ngpr < maxgpr) \ + cc->gpr[ngpr++] = (GPRArg)dp; \ + else \ + cc->stack[nsp++] = (GPRArg)dp; + +#endif + +#define CCALL_HANDLE_COMPLEXRET \ + /* Return complex float in GPRs and complex double by reference. */ \ + cc->retref = (sz > 8); \ + if (cc->retref) { \ + if (ngpr < maxgpr) \ + cc->gpr[ngpr++] = (GPRArg)dp; \ + else \ + cc->stack[nsp++] = (GPRArg)dp; \ + } + +#endif + +#define CCALL_HANDLE_COMPLEXRET2 \ + if (!cc->retref) \ + *(int64_t *)dp = *(int64_t *)sp; /* Copy complex float from GPRs. */ + +#define CCALL_HANDLE_STRUCTARG \ + ngpr = maxgpr; /* Pass all structs by value on the stack. */ + +#define CCALL_HANDLE_COMPLEXARG \ + isfp = 1; /* Pass complex by value on stack. */ + +#define CCALL_HANDLE_REGARG \ + if (!isfp) { /* Only non-FP values may be passed in registers. */ \ + if (n > 1) { /* Anything > 32 bit is passed on the stack. */ \ + if (!LJ_ABI_WIN) ngpr = maxgpr; /* Prevent reordering. */ \ + } else if (ngpr + 1 <= maxgpr) { \ + dp = &cc->gpr[ngpr]; \ + ngpr += n; \ + goto done; \ + } \ + } + +#elif LJ_TARGET_X64 && LJ_ABI_WIN +/* -- Windows/x64 calling conventions ------------------------------------- */ + +#define CCALL_HANDLE_STRUCTRET \ + /* Return structs of size 1, 2, 4 or 8 in a GPR. */ \ + cc->retref = !(sz == 1 || sz == 2 || sz == 4 || sz == 8); \ + if (cc->retref) cc->gpr[ngpr++] = (GPRArg)dp; + +#define CCALL_HANDLE_COMPLEXRET CCALL_HANDLE_STRUCTRET + +#define CCALL_HANDLE_COMPLEXRET2 \ + if (!cc->retref) \ + *(int64_t *)dp = *(int64_t *)sp; /* Copy complex float from GPRs. */ + +#define CCALL_HANDLE_STRUCTARG \ + /* Pass structs of size 1, 2, 4 or 8 in a GPR by value. */ \ + if (!(sz == 1 || sz == 2 || sz == 4 || sz == 8)) { \ + rp = cdataptr(lj_cdata_new(cts, did, sz)); \ + sz = CTSIZE_PTR; /* Pass all other structs by reference. */ \ + } + +#define CCALL_HANDLE_COMPLEXARG \ + /* Pass complex float in a GPR and complex double by reference. */ \ + if (sz != 2*sizeof(float)) { \ + rp = cdataptr(lj_cdata_new(cts, did, sz)); \ + sz = CTSIZE_PTR; \ + } + +/* Windows/x64 argument registers are strictly positional (use ngpr). */ +#define CCALL_HANDLE_REGARG \ + if (isfp) { \ + if (ngpr < maxgpr) { dp = &cc->fpr[ngpr++]; nfpr = ngpr; goto done; } \ + } else { \ + if (ngpr < maxgpr) { dp = &cc->gpr[ngpr++]; goto done; } \ + } + +#elif LJ_TARGET_X64 +/* -- POSIX/x64 calling conventions --------------------------------------- */ + +#define CCALL_HANDLE_STRUCTRET \ + int rcl[2]; rcl[0] = rcl[1] = 0; \ + if (ccall_classify_struct(cts, ctr, rcl, 0)) { \ + cc->retref = 1; /* Return struct by reference. */ \ + cc->gpr[ngpr++] = (GPRArg)dp; \ + } else { \ + cc->retref = 0; /* Return small structs in registers. */ \ + } + +#define CCALL_HANDLE_STRUCTRET2 \ + int rcl[2]; rcl[0] = rcl[1] = 0; \ + ccall_classify_struct(cts, ctr, rcl, 0); \ + ccall_struct_ret(cc, rcl, dp, ctr->size); + +#define CCALL_HANDLE_COMPLEXRET \ + /* Complex values are returned in one or two FPRs. */ \ + cc->retref = 0; + +#define CCALL_HANDLE_COMPLEXRET2 \ + if (ctr->size == 2*sizeof(float)) { /* Copy complex float from FPR. */ \ + *(int64_t *)dp = cc->fpr[0].l[0]; \ + } else { /* Copy non-contiguous complex double from FPRs. */ \ + ((int64_t *)dp)[0] = cc->fpr[0].l[0]; \ + ((int64_t *)dp)[1] = cc->fpr[1].l[0]; \ + } + +#define CCALL_HANDLE_STRUCTARG \ + int rcl[2]; rcl[0] = rcl[1] = 0; \ + if (!ccall_classify_struct(cts, d, rcl, 0)) { \ + cc->nsp = nsp; cc->ngpr = ngpr; cc->nfpr = nfpr; \ + if (ccall_struct_arg(cc, cts, d, rcl, o, narg)) goto err_nyi; \ + nsp = cc->nsp; ngpr = cc->ngpr; nfpr = cc->nfpr; \ + continue; \ + } /* Pass all other structs by value on stack. */ + +#define CCALL_HANDLE_COMPLEXARG \ + isfp = 2; /* Pass complex in FPRs or on stack. Needs postprocessing. */ + +#define CCALL_HANDLE_REGARG \ + if (isfp) { /* Try to pass argument in FPRs. */ \ + int n2 = ctype_isvector(d->info) ? 1 : n; \ + if (nfpr + n2 <= CCALL_NARG_FPR) { \ + dp = &cc->fpr[nfpr]; \ + nfpr += n2; \ + goto done; \ + } \ + } else { /* Try to pass argument in GPRs. */ \ + /* Note that reordering is explicitly allowed in the x64 ABI. */ \ + if (n <= 2 && ngpr + n <= maxgpr) { \ + dp = &cc->gpr[ngpr]; \ + ngpr += n; \ + goto done; \ + } \ + } + +#elif LJ_TARGET_ARM +/* -- ARM calling conventions --------------------------------------------- */ + +#if LJ_ABI_SOFTFP + +#define CCALL_HANDLE_STRUCTRET \ + /* Return structs of size <= 4 in a GPR. */ \ + cc->retref = !(sz <= 4); \ + if (cc->retref) cc->gpr[ngpr++] = (GPRArg)dp; + +#define CCALL_HANDLE_COMPLEXRET \ + cc->retref = 1; /* Return all complex values by reference. */ \ + cc->gpr[ngpr++] = (GPRArg)dp; + +#define CCALL_HANDLE_COMPLEXRET2 \ + UNUSED(dp); /* Nothing to do. */ + +#define CCALL_HANDLE_STRUCTARG \ + /* Pass all structs by value in registers and/or on the stack. */ + +#define CCALL_HANDLE_COMPLEXARG \ + /* Pass complex by value in 2 or 4 GPRs. */ + +#define CCALL_HANDLE_REGARG_FP1 +#define CCALL_HANDLE_REGARG_FP2 + +#else + +#define CCALL_HANDLE_STRUCTRET \ + cc->retref = !ccall_classify_struct(cts, ctr, ct); \ + if (cc->retref) cc->gpr[ngpr++] = (GPRArg)dp; + +#define CCALL_HANDLE_STRUCTRET2 \ + if (ccall_classify_struct(cts, ctr, ct) > 1) sp = (uint8_t *)&cc->fpr[0]; \ + memcpy(dp, sp, ctr->size); + +#define CCALL_HANDLE_COMPLEXRET \ + if (!(ct->info & CTF_VARARG)) cc->retref = 0; /* Return complex in FPRs. */ + +#define CCALL_HANDLE_COMPLEXRET2 \ + if (!(ct->info & CTF_VARARG)) memcpy(dp, &cc->fpr[0], ctr->size); + +#define CCALL_HANDLE_STRUCTARG \ + isfp = (ccall_classify_struct(cts, d, ct) > 1); + /* Pass all structs by value in registers and/or on the stack. */ + +#define CCALL_HANDLE_COMPLEXARG \ + isfp = 1; /* Pass complex by value in FPRs or on stack. */ + +#define CCALL_HANDLE_REGARG_FP1 \ + if (isfp && !(ct->info & CTF_VARARG)) { \ + if ((d->info & CTF_ALIGN) > CTALIGN_PTR) { \ + if (nfpr + (n >> 1) <= CCALL_NARG_FPR) { \ + dp = &cc->fpr[nfpr]; \ + nfpr += (n >> 1); \ + goto done; \ + } \ + } else { \ + if (sz > 1 && fprodd != nfpr) fprodd = 0; \ + if (fprodd) { \ + if (2*nfpr+n <= 2*CCALL_NARG_FPR+1) { \ + dp = (void *)&cc->fpr[fprodd-1].f[1]; \ + nfpr += (n >> 1); \ + if ((n & 1)) fprodd = 0; else fprodd = nfpr-1; \ + goto done; \ + } \ + } else { \ + if (2*nfpr+n <= 2*CCALL_NARG_FPR) { \ + dp = (void *)&cc->fpr[nfpr]; \ + nfpr += (n >> 1); \ + if ((n & 1)) fprodd = ++nfpr; else fprodd = 0; \ + goto done; \ + } \ + } \ + } \ + fprodd = 0; /* No reordering after the first FP value is on stack. */ \ + } else { + +#define CCALL_HANDLE_REGARG_FP2 } + +#endif + +#define CCALL_HANDLE_REGARG \ + CCALL_HANDLE_REGARG_FP1 \ + if ((d->info & CTF_ALIGN) > CTALIGN_PTR) { \ + if (ngpr < maxgpr) \ + ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \ + } \ + if (ngpr < maxgpr) { \ + dp = &cc->gpr[ngpr]; \ + if (ngpr + n > maxgpr) { \ + nsp += ngpr + n - maxgpr; /* Assumes contiguous gpr/stack fields. */ \ + if (nsp > CCALL_MAXSTACK) goto err_nyi; /* Too many arguments. */ \ + ngpr = maxgpr; \ + } else { \ + ngpr += n; \ + } \ + goto done; \ + } CCALL_HANDLE_REGARG_FP2 + +#define CCALL_HANDLE_RET \ + if ((ct->info & CTF_VARARG)) sp = (uint8_t *)&cc->gpr[0]; + +#elif LJ_TARGET_PPC +/* -- PPC calling conventions --------------------------------------------- */ + +#define CCALL_HANDLE_STRUCTRET \ + cc->retref = 1; /* Return all structs by reference. */ \ + cc->gpr[ngpr++] = (GPRArg)dp; + +#define CCALL_HANDLE_COMPLEXRET \ + /* Complex values are returned in 2 or 4 GPRs. */ \ + cc->retref = 0; + +#define CCALL_HANDLE_COMPLEXRET2 \ + memcpy(dp, sp, ctr->size); /* Copy complex from GPRs. */ + +#define CCALL_HANDLE_STRUCTARG \ + rp = cdataptr(lj_cdata_new(cts, did, sz)); \ + sz = CTSIZE_PTR; /* Pass all structs by reference. */ + +#define CCALL_HANDLE_COMPLEXARG \ + /* Pass complex by value in 2 or 4 GPRs. */ + +#define CCALL_HANDLE_REGARG \ + if (isfp) { /* Try to pass argument in FPRs. */ \ + if (nfpr + 1 <= CCALL_NARG_FPR) { \ + dp = &cc->fpr[nfpr]; \ + nfpr += 1; \ + d = ctype_get(cts, CTID_DOUBLE); /* FPRs always hold doubles. */ \ + goto done; \ + } \ + } else { /* Try to pass argument in GPRs. */ \ + if (n > 1) { \ + lua_assert(n == 2 || n == 4); /* int64_t or complex (float). */ \ + if (ctype_isinteger(d->info)) \ + ngpr = (ngpr + 1u) & ~1u; /* Align int64_t to regpair. */ \ + else if (ngpr + n > maxgpr) \ + ngpr = maxgpr; /* Prevent reordering. */ \ + } \ + if (ngpr + n <= maxgpr) { \ + dp = &cc->gpr[ngpr]; \ + ngpr += n; \ + goto done; \ + } \ + } + +#define CCALL_HANDLE_RET \ + if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \ + ctr = ctype_get(cts, CTID_DOUBLE); /* FPRs always hold doubles. */ + +#elif LJ_TARGET_PPCSPE +/* -- PPC/SPE calling conventions ----------------------------------------- */ + +#define CCALL_HANDLE_STRUCTRET \ + cc->retref = 1; /* Return all structs by reference. */ \ + cc->gpr[ngpr++] = (GPRArg)dp; + +#define CCALL_HANDLE_COMPLEXRET \ + /* Complex values are returned in 2 or 4 GPRs. */ \ + cc->retref = 0; + +#define CCALL_HANDLE_COMPLEXRET2 \ + memcpy(dp, sp, ctr->size); /* Copy complex from GPRs. */ + +#define CCALL_HANDLE_STRUCTARG \ + rp = cdataptr(lj_cdata_new(cts, did, sz)); \ + sz = CTSIZE_PTR; /* Pass all structs by reference. */ + +#define CCALL_HANDLE_COMPLEXARG \ + /* Pass complex by value in 2 or 4 GPRs. */ + +/* PPC/SPE has a softfp ABI. */ +#define CCALL_HANDLE_REGARG \ + if (n > 1) { /* Doesn't fit in a single GPR? */ \ + lua_assert(n == 2 || n == 4); /* int64_t, double or complex (float). */ \ + if (n == 2) \ + ngpr = (ngpr + 1u) & ~1u; /* Only align 64 bit value to regpair. */ \ + else if (ngpr + n > maxgpr) \ + ngpr = maxgpr; /* Prevent reordering. */ \ + } \ + if (ngpr + n <= maxgpr) { \ + dp = &cc->gpr[ngpr]; \ + ngpr += n; \ + goto done; \ + } + +#elif LJ_TARGET_MIPS +/* -- MIPS calling conventions -------------------------------------------- */ + +#define CCALL_HANDLE_STRUCTRET \ + cc->retref = 1; /* Return all structs by reference. */ \ + cc->gpr[ngpr++] = (GPRArg)dp; + +#define CCALL_HANDLE_COMPLEXRET \ + /* Complex values are returned in 1 or 2 FPRs. */ \ + cc->retref = 0; + +#define CCALL_HANDLE_COMPLEXRET2 \ + if (ctr->size == 2*sizeof(float)) { /* Copy complex float from FPRs. */ \ + ((float *)dp)[0] = cc->fpr[0].f; \ + ((float *)dp)[1] = cc->fpr[1].f; \ + } else { /* Copy complex double from FPRs. */ \ + ((double *)dp)[0] = cc->fpr[0].d; \ + ((double *)dp)[1] = cc->fpr[1].d; \ + } + +#define CCALL_HANDLE_STRUCTARG \ + /* Pass all structs by value in registers and/or on the stack. */ + +#define CCALL_HANDLE_COMPLEXARG \ + /* Pass complex by value in 2 or 4 GPRs. */ + +#define CCALL_HANDLE_REGARG \ + if (isfp && nfpr < CCALL_NARG_FPR && !(ct->info & CTF_VARARG)) { \ + /* Try to pass argument in FPRs. */ \ + dp = n == 1 ? (void *)&cc->fpr[nfpr].f : (void *)&cc->fpr[nfpr].d; \ + nfpr++; ngpr += n; \ + goto done; \ + } else { /* Try to pass argument in GPRs. */ \ + nfpr = CCALL_NARG_FPR; \ + if ((d->info & CTF_ALIGN) > CTALIGN_PTR) \ + ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \ + if (ngpr < maxgpr) { \ + dp = &cc->gpr[ngpr]; \ + if (ngpr + n > maxgpr) { \ + nsp += ngpr + n - maxgpr; /* Assumes contiguous gpr/stack fields. */ \ + if (nsp > CCALL_MAXSTACK) goto err_nyi; /* Too many arguments. */ \ + ngpr = maxgpr; \ + } else { \ + ngpr += n; \ + } \ + goto done; \ + } \ + } + +#define CCALL_HANDLE_RET \ + if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \ + sp = (uint8_t *)&cc->fpr[0].f; + +#else +#error "Missing calling convention definitions for this architecture" +#endif + +#ifndef CCALL_HANDLE_STRUCTRET2 +#define CCALL_HANDLE_STRUCTRET2 \ + memcpy(dp, sp, ctr->size); /* Copy struct return value from GPRs. */ +#endif + +/* -- x86 OSX ABI struct classification ----------------------------------- */ + +#if LJ_TARGET_X86 && LJ_TARGET_OSX + +/* Check for struct with single FP field. */ +static int ccall_classify_struct(CTState *cts, CType *ct) +{ + CTSize sz = ct->size; + if (!(sz == sizeof(float) || sz == sizeof(double))) return 0; + if ((ct->info & CTF_UNION)) return 0; + while (ct->sib) { + ct = ctype_get(cts, ct->sib); + if (ctype_isfield(ct->info)) { + CType *sct = ctype_rawchild(cts, ct); + if (ctype_isfp(sct->info)) { + if (sct->size == sz) + return (sz >> 2); /* Return 1 for float or 2 for double. */ + } else if (ctype_isstruct(sct->info)) { + if (sct->size) + return ccall_classify_struct(cts, sct); + } else { + break; + } + } else if (ctype_isbitfield(ct->info)) { + break; + } else if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) { + CType *sct = ctype_rawchild(cts, ct); + if (sct->size) + return ccall_classify_struct(cts, sct); + } + } + return 0; +} + +#endif + +/* -- x64 struct classification ------------------------------------------- */ + +#if LJ_TARGET_X64 && !LJ_ABI_WIN + +/* Register classes for x64 struct classification. */ +#define CCALL_RCL_INT 1 +#define CCALL_RCL_SSE 2 +#define CCALL_RCL_MEM 4 +/* NYI: classify vectors. */ + +static int ccall_classify_struct(CTState *cts, CType *ct, int *rcl, CTSize ofs); + +/* Classify a C type. */ +static void ccall_classify_ct(CTState *cts, CType *ct, int *rcl, CTSize ofs) +{ + if (ctype_isarray(ct->info)) { + CType *cct = ctype_rawchild(cts, ct); + CTSize eofs, esz = cct->size, asz = ct->size; + for (eofs = 0; eofs < asz; eofs += esz) + ccall_classify_ct(cts, cct, rcl, ofs+eofs); + } else if (ctype_isstruct(ct->info)) { + ccall_classify_struct(cts, ct, rcl, ofs); + } else { + int cl = ctype_isfp(ct->info) ? CCALL_RCL_SSE : CCALL_RCL_INT; + lua_assert(ctype_hassize(ct->info)); + if ((ofs & (ct->size-1))) cl = CCALL_RCL_MEM; /* Unaligned. */ + rcl[(ofs >= 8)] |= cl; + } +} + +/* Recursively classify a struct based on its fields. */ +static int ccall_classify_struct(CTState *cts, CType *ct, int *rcl, CTSize ofs) +{ + if (ct->size > 16) return CCALL_RCL_MEM; /* Too big, gets memory class. */ + while (ct->sib) { + CTSize fofs; + ct = ctype_get(cts, ct->sib); + fofs = ofs+ct->size; + if (ctype_isfield(ct->info)) + ccall_classify_ct(cts, ctype_rawchild(cts, ct), rcl, fofs); + else if (ctype_isbitfield(ct->info)) + rcl[(fofs >= 8)] |= CCALL_RCL_INT; /* NYI: unaligned bitfields? */ + else if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) + ccall_classify_struct(cts, ctype_rawchild(cts, ct), rcl, fofs); + } + return ((rcl[0]|rcl[1]) & CCALL_RCL_MEM); /* Memory class? */ +} + +/* Try to split up a small struct into registers. */ +static int ccall_struct_reg(CCallState *cc, GPRArg *dp, int *rcl) +{ + MSize ngpr = cc->ngpr, nfpr = cc->nfpr; + uint32_t i; + for (i = 0; i < 2; i++) { + lua_assert(!(rcl[i] & CCALL_RCL_MEM)); + if ((rcl[i] & CCALL_RCL_INT)) { /* Integer class takes precedence. */ + if (ngpr >= CCALL_NARG_GPR) return 1; /* Register overflow. */ + cc->gpr[ngpr++] = dp[i]; + } else if ((rcl[i] & CCALL_RCL_SSE)) { + if (nfpr >= CCALL_NARG_FPR) return 1; /* Register overflow. */ + cc->fpr[nfpr++].l[0] = dp[i]; + } + } + cc->ngpr = ngpr; cc->nfpr = nfpr; + return 0; /* Ok. */ +} + +/* Pass a small struct argument. */ +static int ccall_struct_arg(CCallState *cc, CTState *cts, CType *d, int *rcl, + TValue *o, int narg) +{ + GPRArg dp[2]; + dp[0] = dp[1] = 0; + /* Convert to temp. struct. */ + lj_cconv_ct_tv(cts, d, (uint8_t *)dp, o, CCF_ARG(narg)); + if (ccall_struct_reg(cc, dp, rcl)) { /* Register overflow? Pass on stack. */ + MSize nsp = cc->nsp, n = rcl[1] ? 2 : 1; + if (nsp + n > CCALL_MAXSTACK) return 1; /* Too many arguments. */ + cc->nsp = nsp + n; + memcpy(&cc->stack[nsp], dp, n*CTSIZE_PTR); + } + return 0; /* Ok. */ +} + +/* Combine returned small struct. */ +static void ccall_struct_ret(CCallState *cc, int *rcl, uint8_t *dp, CTSize sz) +{ + GPRArg sp[2]; + MSize ngpr = 0, nfpr = 0; + uint32_t i; + for (i = 0; i < 2; i++) { + if ((rcl[i] & CCALL_RCL_INT)) { /* Integer class takes precedence. */ + sp[i] = cc->gpr[ngpr++]; + } else if ((rcl[i] & CCALL_RCL_SSE)) { + sp[i] = cc->fpr[nfpr++].l[0]; + } + } + memcpy(dp, sp, sz); +} +#endif + +/* -- ARM hard-float ABI struct classification ---------------------------- */ + +#if LJ_TARGET_ARM && !LJ_ABI_SOFTFP + +/* Classify a struct based on its fields. */ +static unsigned int ccall_classify_struct(CTState *cts, CType *ct, CType *ctf) +{ + CTSize sz = ct->size; + unsigned int r = 0, n = 0, isu = (ct->info & CTF_UNION); + if ((ctf->info & CTF_VARARG)) goto noth; + while (ct->sib) { + CType *sct; + ct = ctype_get(cts, ct->sib); + if (ctype_isfield(ct->info)) { + sct = ctype_rawchild(cts, ct); + if (ctype_isfp(sct->info)) { + r |= sct->size; + if (!isu) n++; else if (n == 0) n = 1; + } else if (ctype_iscomplex(sct->info)) { + r |= (sct->size >> 1); + if (!isu) n += 2; else if (n < 2) n = 2; + } else if (ctype_isstruct(sct->info)) { + goto substruct; + } else { + goto noth; + } + } else if (ctype_isbitfield(ct->info)) { + goto noth; + } else if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) { + sct = ctype_rawchild(cts, ct); + substruct: + if (sct->size > 0) { + unsigned int s = ccall_classify_struct(cts, sct, ctf); + if (s <= 1) goto noth; + r |= (s & 255); + if (!isu) n += (s >> 8); else if (n < (s >>8)) n = (s >> 8); + } + } + } + if ((r == 4 || r == 8) && n <= 4) + return r + (n << 8); +noth: /* Not a homogeneous float/double aggregate. */ + return (sz <= 4); /* Return structs of size <= 4 in a GPR. */ +} + +#endif + +/* -- Common C call handling ---------------------------------------------- */ + +/* Infer the destination CTypeID for a vararg argument. */ +CTypeID lj_ccall_ctid_vararg(CTState *cts, cTValue *o) +{ + if (tvisnumber(o)) { + return CTID_DOUBLE; + } else if (tviscdata(o)) { + CTypeID id = cdataV(o)->ctypeid; + CType *s = ctype_get(cts, id); + if (ctype_isrefarray(s->info)) { + return lj_ctype_intern(cts, + CTINFO(CT_PTR, CTALIGN_PTR|ctype_cid(s->info)), CTSIZE_PTR); + } else if (ctype_isstruct(s->info) || ctype_isfunc(s->info)) { + /* NYI: how to pass a struct by value in a vararg argument? */ + return lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|id), CTSIZE_PTR); + } else if (ctype_isfp(s->info) && s->size == sizeof(float)) { + return CTID_DOUBLE; + } else { + return id; + } + } else if (tvisstr(o)) { + return CTID_P_CCHAR; + } else if (tvisbool(o)) { + return CTID_BOOL; + } else { + return CTID_P_VOID; + } +} + +/* Setup arguments for C call. */ +static int ccall_set_args(lua_State *L, CTState *cts, CType *ct, + CCallState *cc) +{ + int gcsteps = 0; + TValue *o, *top = L->top; + CTypeID fid; + CType *ctr; + MSize maxgpr, ngpr = 0, nsp = 0, narg; +#if CCALL_NARG_FPR + MSize nfpr = 0; +#if LJ_TARGET_ARM + MSize fprodd = 0; +#endif +#endif + + /* Clear unused regs to get some determinism in case of misdeclaration. */ + memset(cc->gpr, 0, sizeof(cc->gpr)); +#if CCALL_NUM_FPR + memset(cc->fpr, 0, sizeof(cc->fpr)); +#endif + +#if LJ_TARGET_X86 + /* x86 has several different calling conventions. */ + cc->resx87 = 0; + switch (ctype_cconv(ct->info)) { + case CTCC_FASTCALL: maxgpr = 2; break; + case CTCC_THISCALL: maxgpr = 1; break; + default: maxgpr = 0; break; + } +#else + maxgpr = CCALL_NARG_GPR; +#endif + + /* Perform required setup for some result types. */ + ctr = ctype_rawchild(cts, ct); + if (ctype_isvector(ctr->info)) { + if (!(CCALL_VECTOR_REG && (ctr->size == 8 || ctr->size == 16))) + goto err_nyi; + } else if (ctype_iscomplex(ctr->info) || ctype_isstruct(ctr->info)) { + /* Preallocate cdata object and anchor it after arguments. */ + CTSize sz = ctr->size; + GCcdata *cd = lj_cdata_new(cts, ctype_cid(ct->info), sz); + void *dp = cdataptr(cd); + setcdataV(L, L->top++, cd); + if (ctype_isstruct(ctr->info)) { + CCALL_HANDLE_STRUCTRET + } else { + CCALL_HANDLE_COMPLEXRET + } +#if LJ_TARGET_X86 + } else if (ctype_isfp(ctr->info)) { + cc->resx87 = ctr->size == sizeof(float) ? 1 : 2; +#endif + } + + /* Skip initial attributes. */ + fid = ct->sib; + while (fid) { + CType *ctf = ctype_get(cts, fid); + if (!ctype_isattrib(ctf->info)) break; + fid = ctf->sib; + } + + /* Walk through all passed arguments. */ + for (o = L->base+1, narg = 1; o < top; o++, narg++) { + CTypeID did; + CType *d; + CTSize sz; + MSize n, isfp = 0, isva = 0; + void *dp, *rp = NULL; + + if (fid) { /* Get argument type from field. */ + CType *ctf = ctype_get(cts, fid); + fid = ctf->sib; + lua_assert(ctype_isfield(ctf->info)); + did = ctype_cid(ctf->info); + } else { + if (!(ct->info & CTF_VARARG)) + lj_err_caller(L, LJ_ERR_FFI_NUMARG); /* Too many arguments. */ + did = lj_ccall_ctid_vararg(cts, o); /* Infer vararg type. */ + isva = 1; + } + d = ctype_raw(cts, did); + sz = d->size; + + /* Find out how (by value/ref) and where (GPR/FPR) to pass an argument. */ + if (ctype_isnum(d->info)) { + if (sz > 8) goto err_nyi; + if ((d->info & CTF_FP)) + isfp = 1; + } else if (ctype_isvector(d->info)) { + if (CCALL_VECTOR_REG && (sz == 8 || sz == 16)) + isfp = 1; + else + goto err_nyi; + } else if (ctype_isstruct(d->info)) { + CCALL_HANDLE_STRUCTARG + } else if (ctype_iscomplex(d->info)) { + CCALL_HANDLE_COMPLEXARG + } else { + sz = CTSIZE_PTR; + } + sz = (sz + CTSIZE_PTR-1) & ~(CTSIZE_PTR-1); + n = sz / CTSIZE_PTR; /* Number of GPRs or stack slots needed. */ + + CCALL_HANDLE_REGARG /* Handle register arguments. */ + + /* Otherwise pass argument on stack. */ + if (CCALL_ALIGN_STACKARG && !rp && (d->info & CTF_ALIGN) > CTALIGN_PTR) { + MSize align = (1u << ctype_align(d->info-CTALIGN_PTR)) -1; + nsp = (nsp + align) & ~align; /* Align argument on stack. */ + } + if (nsp + n > CCALL_MAXSTACK) { /* Too many arguments. */ + err_nyi: + lj_err_caller(L, LJ_ERR_FFI_NYICALL); + } + dp = &cc->stack[nsp]; + nsp += n; + isva = 0; + + done: + if (rp) { /* Pass by reference. */ + gcsteps++; + *(void **)dp = rp; + dp = rp; + } + lj_cconv_ct_tv(cts, d, (uint8_t *)dp, o, CCF_ARG(narg)); + /* Extend passed integers to 32 bits at least. */ + if (ctype_isinteger_or_bool(d->info) && d->size < 4) { + if (d->info & CTF_UNSIGNED) + *(uint32_t *)dp = d->size == 1 ? (uint32_t)*(uint8_t *)dp : + (uint32_t)*(uint16_t *)dp; + else + *(int32_t *)dp = d->size == 1 ? (int32_t)*(int8_t *)dp : + (int32_t)*(int16_t *)dp; + } +#if LJ_TARGET_X64 && LJ_ABI_WIN + if (isva) { /* Windows/x64 mirrors varargs in both register sets. */ + if (nfpr == ngpr) + cc->gpr[ngpr-1] = cc->fpr[ngpr-1].l[0]; + else + cc->fpr[ngpr-1].l[0] = cc->gpr[ngpr-1]; + } +#else + UNUSED(isva); +#endif +#if LJ_TARGET_X64 && !LJ_ABI_WIN + if (isfp == 2 && n == 2 && (uint8_t *)dp == (uint8_t *)&cc->fpr[nfpr-2]) { + cc->fpr[nfpr-1].d[0] = cc->fpr[nfpr-2].d[1]; /* Split complex double. */ + cc->fpr[nfpr-2].d[1] = 0; + } +#else + UNUSED(isfp); +#endif + } + if (fid) lj_err_caller(L, LJ_ERR_FFI_NUMARG); /* Too few arguments. */ + +#if LJ_TARGET_X64 || LJ_TARGET_PPC + cc->nfpr = nfpr; /* Required for vararg functions. */ +#endif + cc->nsp = nsp; + cc->spadj = (CCALL_SPS_FREE + CCALL_SPS_EXTRA)*CTSIZE_PTR; + if (nsp > CCALL_SPS_FREE) + cc->spadj += (((nsp-CCALL_SPS_FREE)*CTSIZE_PTR + 15u) & ~15u); + return gcsteps; +} + +/* Get results from C call. */ +static int ccall_get_results(lua_State *L, CTState *cts, CType *ct, + CCallState *cc, int *ret) +{ + CType *ctr = ctype_rawchild(cts, ct); + uint8_t *sp = (uint8_t *)&cc->gpr[0]; + if (ctype_isvoid(ctr->info)) { + *ret = 0; /* Zero results. */ + return 0; /* No additional GC step. */ + } + *ret = 1; /* One result. */ + if (ctype_isstruct(ctr->info)) { + /* Return cdata object which is already on top of stack. */ + if (!cc->retref) { + void *dp = cdataptr(cdataV(L->top-1)); /* Use preallocated object. */ + CCALL_HANDLE_STRUCTRET2 + } + return 1; /* One GC step. */ + } + if (ctype_iscomplex(ctr->info)) { + /* Return cdata object which is already on top of stack. */ + void *dp = cdataptr(cdataV(L->top-1)); /* Use preallocated object. */ + CCALL_HANDLE_COMPLEXRET2 + return 1; /* One GC step. */ + } + if (LJ_BE && ctype_isinteger_or_bool(ctr->info) && ctr->size < CTSIZE_PTR) + sp += (CTSIZE_PTR - ctr->size); +#if CCALL_NUM_FPR + if (ctype_isfp(ctr->info) || ctype_isvector(ctr->info)) + sp = (uint8_t *)&cc->fpr[0]; +#endif +#ifdef CCALL_HANDLE_RET + CCALL_HANDLE_RET +#endif + /* No reference types end up here, so there's no need for the CTypeID. */ + lua_assert(!(ctype_isrefarray(ctr->info) || ctype_isstruct(ctr->info))); + return lj_cconv_tv_ct(cts, ctr, 0, L->top-1, sp); +} + +/* Call C function. */ +int lj_ccall_func(lua_State *L, GCcdata *cd) +{ + CTState *cts = ctype_cts(L); + CType *ct = ctype_raw(cts, cd->ctypeid); + CTSize sz = CTSIZE_PTR; + if (ctype_isptr(ct->info)) { + sz = ct->size; + ct = ctype_rawchild(cts, ct); + } + if (ctype_isfunc(ct->info)) { + CCallState cc; + int gcsteps, ret; + cc.func = (void (*)(void))cdata_getptr(cdataptr(cd), sz); + gcsteps = ccall_set_args(L, cts, ct, &cc); + ct = (CType *)((intptr_t)ct-(intptr_t)cts->tab); + cts->cb.slot = ~0u; + lj_vm_ffi_call(&cc); + if (cts->cb.slot != ~0u) { /* Blacklist function that called a callback. */ + TValue tv; + setlightudV(&tv, (void *)cc.func); + setboolV(lj_tab_set(L, cts->miscmap, &tv), 1); + } + ct = (CType *)((intptr_t)ct+(intptr_t)cts->tab); /* May be reallocated. */ + gcsteps += ccall_get_results(L, cts, ct, &cc, &ret); +#if LJ_TARGET_X86 && LJ_ABI_WIN + /* Automatically detect __stdcall and fix up C function declaration. */ + if (cc.spadj && ctype_cconv(ct->info) == CTCC_CDECL) { + CTF_INSERT(ct->info, CCONV, CTCC_STDCALL); + lj_trace_abort(G(L)); + } +#endif + while (gcsteps-- > 0) + lj_gc_check(L); + return ret; + } + return -1; /* Not a function. */ +} + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_ccall.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ccall.h new file mode 100644 index 000000000..f55301093 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ccall.h @@ -0,0 +1,171 @@ +/* +** FFI C call handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_CCALL_H +#define _LJ_CCALL_H + +#include "lj_obj.h" +#include "lj_ctype.h" + +#if LJ_HASFFI + +/* -- C calling conventions ----------------------------------------------- */ + +#if LJ_TARGET_X86ORX64 + +#if LJ_TARGET_X86 +#define CCALL_NARG_GPR 2 /* For fastcall arguments. */ +#define CCALL_NARG_FPR 0 +#define CCALL_NRET_GPR 2 +#define CCALL_NRET_FPR 1 /* For FP results on x87 stack. */ +#define CCALL_ALIGN_STACKARG 0 /* Don't align argument on stack. */ +#elif LJ_ABI_WIN +#define CCALL_NARG_GPR 4 +#define CCALL_NARG_FPR 4 +#define CCALL_NRET_GPR 1 +#define CCALL_NRET_FPR 1 +#define CCALL_SPS_EXTRA 4 +#else +#define CCALL_NARG_GPR 6 +#define CCALL_NARG_FPR 8 +#define CCALL_NRET_GPR 2 +#define CCALL_NRET_FPR 2 +#define CCALL_VECTOR_REG 1 /* Pass vectors in registers. */ +#endif + +#define CCALL_SPS_FREE 1 +#define CCALL_ALIGN_CALLSTATE 16 + +typedef LJ_ALIGN(16) union FPRArg { + double d[2]; + float f[4]; + uint8_t b[16]; + uint16_t s[8]; + int i[4]; + int64_t l[2]; +} FPRArg; + +typedef intptr_t GPRArg; + +#elif LJ_TARGET_ARM + +#define CCALL_NARG_GPR 4 +#define CCALL_NRET_GPR 2 /* For softfp double. */ +#if LJ_ABI_SOFTFP +#define CCALL_NARG_FPR 0 +#define CCALL_NRET_FPR 0 +#else +#define CCALL_NARG_FPR 8 +#define CCALL_NRET_FPR 4 +#endif +#define CCALL_SPS_FREE 0 + +typedef intptr_t GPRArg; +typedef union FPRArg { + double d; + float f[2]; +} FPRArg; + +#elif LJ_TARGET_PPC + +#define CCALL_NARG_GPR 8 +#define CCALL_NARG_FPR 8 +#define CCALL_NRET_GPR 4 /* For complex double. */ +#define CCALL_NRET_FPR 1 +#define CCALL_SPS_EXTRA 4 +#define CCALL_SPS_FREE 0 + +typedef intptr_t GPRArg; +typedef double FPRArg; + +#elif LJ_TARGET_PPCSPE + +#define CCALL_NARG_GPR 8 +#define CCALL_NARG_FPR 0 +#define CCALL_NRET_GPR 4 /* For softfp complex double. */ +#define CCALL_NRET_FPR 0 +#define CCALL_SPS_FREE 0 /* NYI */ + +typedef intptr_t GPRArg; + +#elif LJ_TARGET_MIPS + +#define CCALL_NARG_GPR 4 +#define CCALL_NARG_FPR 2 +#define CCALL_NRET_GPR 2 +#define CCALL_NRET_FPR 2 +#define CCALL_SPS_EXTRA 7 +#define CCALL_SPS_FREE 1 + +typedef intptr_t GPRArg; +typedef union FPRArg { + double d; + struct { LJ_ENDIAN_LOHI(float f; , float g;) }; +} FPRArg; + +#else +#error "Missing calling convention definitions for this architecture" +#endif + +#ifndef CCALL_SPS_EXTRA +#define CCALL_SPS_EXTRA 0 +#endif +#ifndef CCALL_VECTOR_REG +#define CCALL_VECTOR_REG 0 +#endif +#ifndef CCALL_ALIGN_STACKARG +#define CCALL_ALIGN_STACKARG 1 +#endif +#ifndef CCALL_ALIGN_CALLSTATE +#define CCALL_ALIGN_CALLSTATE 8 +#endif + +#define CCALL_NUM_GPR \ + (CCALL_NARG_GPR > CCALL_NRET_GPR ? CCALL_NARG_GPR : CCALL_NRET_GPR) +#define CCALL_NUM_FPR \ + (CCALL_NARG_FPR > CCALL_NRET_FPR ? CCALL_NARG_FPR : CCALL_NRET_FPR) + +/* Check against constants in lj_ctype.h. */ +LJ_STATIC_ASSERT(CCALL_NUM_GPR <= CCALL_MAX_GPR); +LJ_STATIC_ASSERT(CCALL_NUM_FPR <= CCALL_MAX_FPR); + +#define CCALL_MAXSTACK 32 + +/* -- C call state -------------------------------------------------------- */ + +typedef LJ_ALIGN(CCALL_ALIGN_CALLSTATE) struct CCallState { + void (*func)(void); /* Pointer to called function. */ + uint32_t spadj; /* Stack pointer adjustment. */ + uint8_t nsp; /* Number of stack slots. */ + uint8_t retref; /* Return value by reference. */ +#if LJ_TARGET_X64 + uint8_t ngpr; /* Number of arguments in GPRs. */ + uint8_t nfpr; /* Number of arguments in FPRs. */ +#elif LJ_TARGET_X86 + uint8_t resx87; /* Result on x87 stack: 1:float, 2:double. */ +#elif LJ_TARGET_PPC + uint8_t nfpr; /* Number of arguments in FPRs. */ +#endif +#if LJ_32 + int32_t align1; +#endif +#if CCALL_NUM_FPR + FPRArg fpr[CCALL_NUM_FPR]; /* Arguments/results in FPRs. */ +#endif + GPRArg gpr[CCALL_NUM_GPR]; /* Arguments/results in GPRs. */ + GPRArg stack[CCALL_MAXSTACK]; /* Stack slots. */ +} CCallState; + +/* -- C call handling ----------------------------------------------------- */ + +/* Really belongs to lj_vm.h. */ +LJ_ASMF void LJ_FASTCALL lj_vm_ffi_call(CCallState *cc); + +LJ_FUNC CTypeID lj_ccall_ctid_vararg(CTState *cts, cTValue *o); +LJ_FUNC int lj_ccall_func(lua_State *L, GCcdata *cd); + +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_ccallback.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ccallback.c new file mode 100644 index 000000000..b210641f9 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ccallback.c @@ -0,0 +1,644 @@ +/* +** FFI C callback handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "lj_obj.h" + +#if LJ_HASFFI + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_tab.h" +#include "lj_state.h" +#include "lj_frame.h" +#include "lj_ctype.h" +#include "lj_cconv.h" +#include "lj_ccall.h" +#include "lj_ccallback.h" +#include "lj_target.h" +#include "lj_mcode.h" +#include "lj_trace.h" +#include "lj_vm.h" + +/* -- Target-specific handling of callback slots -------------------------- */ + +#define CALLBACK_MCODE_SIZE (LJ_PAGESIZE * LJ_NUM_CBPAGE) + +#if LJ_OS_NOJIT + +/* Disabled callback support. */ +#define CALLBACK_SLOT2OFS(slot) (0*(slot)) +#define CALLBACK_OFS2SLOT(ofs) (0*(ofs)) +#define CALLBACK_MAX_SLOT 0 + +#elif LJ_TARGET_X86ORX64 + +#define CALLBACK_MCODE_HEAD (LJ_64 ? 8 : 0) +#define CALLBACK_MCODE_GROUP (-2+1+2+5+(LJ_64 ? 6 : 5)) + +#define CALLBACK_SLOT2OFS(slot) \ + (CALLBACK_MCODE_HEAD + CALLBACK_MCODE_GROUP*((slot)/32) + 4*(slot)) + +static MSize CALLBACK_OFS2SLOT(MSize ofs) +{ + MSize group; + ofs -= CALLBACK_MCODE_HEAD; + group = ofs / (32*4 + CALLBACK_MCODE_GROUP); + return (ofs % (32*4 + CALLBACK_MCODE_GROUP))/4 + group*32; +} + +#define CALLBACK_MAX_SLOT \ + (((CALLBACK_MCODE_SIZE-CALLBACK_MCODE_HEAD)/(CALLBACK_MCODE_GROUP+4*32))*32) + +#elif LJ_TARGET_ARM + +#define CALLBACK_MCODE_HEAD 32 +#define CALLBACK_SLOT2OFS(slot) (CALLBACK_MCODE_HEAD + 8*(slot)) +#define CALLBACK_OFS2SLOT(ofs) (((ofs)-CALLBACK_MCODE_HEAD)/8) +#define CALLBACK_MAX_SLOT (CALLBACK_OFS2SLOT(CALLBACK_MCODE_SIZE)) + +#elif LJ_TARGET_PPC + +#define CALLBACK_MCODE_HEAD 24 +#define CALLBACK_SLOT2OFS(slot) (CALLBACK_MCODE_HEAD + 8*(slot)) +#define CALLBACK_OFS2SLOT(ofs) (((ofs)-CALLBACK_MCODE_HEAD)/8) +#define CALLBACK_MAX_SLOT (CALLBACK_OFS2SLOT(CALLBACK_MCODE_SIZE)) + +#elif LJ_TARGET_MIPS + +#define CALLBACK_MCODE_HEAD 24 +#define CALLBACK_SLOT2OFS(slot) (CALLBACK_MCODE_HEAD + 8*(slot)) +#define CALLBACK_OFS2SLOT(ofs) (((ofs)-CALLBACK_MCODE_HEAD)/8) +#define CALLBACK_MAX_SLOT (CALLBACK_OFS2SLOT(CALLBACK_MCODE_SIZE)) + +#else + +/* Missing support for this architecture. */ +#define CALLBACK_SLOT2OFS(slot) (0*(slot)) +#define CALLBACK_OFS2SLOT(ofs) (0*(ofs)) +#define CALLBACK_MAX_SLOT 0 + +#endif + +/* Convert callback slot number to callback function pointer. */ +static void *callback_slot2ptr(CTState *cts, MSize slot) +{ + return (uint8_t *)cts->cb.mcode + CALLBACK_SLOT2OFS(slot); +} + +/* Convert callback function pointer to slot number. */ +MSize lj_ccallback_ptr2slot(CTState *cts, void *p) +{ + uintptr_t ofs = (uintptr_t)((uint8_t *)p -(uint8_t *)cts->cb.mcode); + if (ofs < CALLBACK_MCODE_SIZE) { + MSize slot = CALLBACK_OFS2SLOT((MSize)ofs); + if (CALLBACK_SLOT2OFS(slot) == (MSize)ofs) + return slot; + } + return ~0u; /* Not a known callback function pointer. */ +} + +/* Initialize machine code for callback function pointers. */ +#if LJ_OS_NOJIT +/* Disabled callback support. */ +#define callback_mcode_init(g, p) UNUSED(p) +#elif LJ_TARGET_X86ORX64 +static void callback_mcode_init(global_State *g, uint8_t *page) +{ + uint8_t *p = page; + uint8_t *target = (uint8_t *)(void *)lj_vm_ffi_callback; + MSize slot; +#if LJ_64 + *(void **)p = target; p += 8; +#endif + for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) { + /* mov al, slot; jmp group */ + *p++ = XI_MOVrib | RID_EAX; *p++ = (uint8_t)slot; + if ((slot & 31) == 31 || slot == CALLBACK_MAX_SLOT-1) { + /* push ebp/rbp; mov ah, slot>>8; mov ebp, &g. */ + *p++ = XI_PUSH + RID_EBP; + *p++ = XI_MOVrib | (RID_EAX+4); *p++ = (uint8_t)(slot >> 8); + *p++ = XI_MOVri | RID_EBP; + *(int32_t *)p = i32ptr(g); p += 4; +#if LJ_64 + /* jmp [rip-pageofs] where lj_vm_ffi_callback is stored. */ + *p++ = XI_GROUP5; *p++ = XM_OFS0 + (XOg_JMP<<3) + RID_EBP; + *(int32_t *)p = (int32_t)(page-(p+4)); p += 4; +#else + /* jmp lj_vm_ffi_callback. */ + *p++ = XI_JMP; *(int32_t *)p = target-(p+4); p += 4; +#endif + } else { + *p++ = XI_JMPs; *p++ = (uint8_t)((2+2)*(31-(slot&31)) - 2); + } + } + lua_assert(p - page <= CALLBACK_MCODE_SIZE); +} +#elif LJ_TARGET_ARM +static void callback_mcode_init(global_State *g, uint32_t *page) +{ + uint32_t *p = page; + void *target = (void *)lj_vm_ffi_callback; + MSize slot; + /* This must match with the saveregs macro in buildvm_arm.dasc. */ + *p++ = ARMI_SUB|ARMF_D(RID_R12)|ARMF_N(RID_R12)|ARMF_M(RID_PC); + *p++ = ARMI_PUSH|ARMF_N(RID_SP)|RSET_RANGE(RID_R4,RID_R11+1)|RID2RSET(RID_LR); + *p++ = ARMI_SUB|ARMI_K12|ARMF_D(RID_R12)|ARMF_N(RID_R12)|CALLBACK_MCODE_HEAD; + *p++ = ARMI_STR|ARMI_LS_P|ARMI_LS_W|ARMF_D(RID_R12)|ARMF_N(RID_SP)|(CFRAME_SIZE-4*9); + *p++ = ARMI_LDR|ARMI_LS_P|ARMI_LS_U|ARMF_D(RID_R12)|ARMF_N(RID_PC); + *p++ = ARMI_LDR|ARMI_LS_P|ARMI_LS_U|ARMF_D(RID_PC)|ARMF_N(RID_PC); + *p++ = u32ptr(g); + *p++ = u32ptr(target); + for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) { + *p++ = ARMI_MOV|ARMF_D(RID_R12)|ARMF_M(RID_PC); + *p = ARMI_B | ((page-p-2) & 0x00ffffffu); + p++; + } + lua_assert(p - page <= CALLBACK_MCODE_SIZE); +} +#elif LJ_TARGET_PPC +static void callback_mcode_init(global_State *g, uint32_t *page) +{ + uint32_t *p = page; + void *target = (void *)lj_vm_ffi_callback; + MSize slot; + *p++ = PPCI_LIS | PPCF_T(RID_TMP) | (u32ptr(target) >> 16); + *p++ = PPCI_LIS | PPCF_T(RID_R12) | (u32ptr(g) >> 16); + *p++ = PPCI_ORI | PPCF_A(RID_TMP)|PPCF_T(RID_TMP) | (u32ptr(target) & 0xffff); + *p++ = PPCI_ORI | PPCF_A(RID_R12)|PPCF_T(RID_R12) | (u32ptr(g) & 0xffff); + *p++ = PPCI_MTCTR | PPCF_T(RID_TMP); + *p++ = PPCI_BCTR; + for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) { + *p++ = PPCI_LI | PPCF_T(RID_R11) | slot; + *p = PPCI_B | (((page-p) & 0x00ffffffu) << 2); + p++; + } + lua_assert(p - page <= CALLBACK_MCODE_SIZE); +} +#elif LJ_TARGET_MIPS +static void callback_mcode_init(global_State *g, uint32_t *page) +{ + uint32_t *p = page; + void *target = (void *)lj_vm_ffi_callback; + MSize slot; + *p++ = MIPSI_SW | MIPSF_T(RID_R1)|MIPSF_S(RID_SP) | 0; + *p++ = MIPSI_LUI | MIPSF_T(RID_R3) | (u32ptr(target) >> 16); + *p++ = MIPSI_LUI | MIPSF_T(RID_R2) | (u32ptr(g) >> 16); + *p++ = MIPSI_ORI | MIPSF_T(RID_R3)|MIPSF_S(RID_R3) |(u32ptr(target)&0xffff); + *p++ = MIPSI_JR | MIPSF_S(RID_R3); + *p++ = MIPSI_ORI | MIPSF_T(RID_R2)|MIPSF_S(RID_R2) | (u32ptr(g)&0xffff); + for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) { + *p = MIPSI_B | ((page-p-1) & 0x0000ffffu); + p++; + *p++ = MIPSI_LI | MIPSF_T(RID_R1) | slot; + } + lua_assert(p - page <= CALLBACK_MCODE_SIZE); +} +#else +/* Missing support for this architecture. */ +#define callback_mcode_init(g, p) UNUSED(p) +#endif + +/* -- Machine code management --------------------------------------------- */ + +#if LJ_TARGET_WINDOWS + +#define WIN32_LEAN_AND_MEAN +#include + +#elif LJ_TARGET_POSIX + +#include +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + +#endif + +/* Allocate and initialize area for callback function pointers. */ +static void callback_mcode_new(CTState *cts) +{ + size_t sz = (size_t)CALLBACK_MCODE_SIZE; + void *p; + if (CALLBACK_MAX_SLOT == 0) + lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV); +#if LJ_TARGET_WINDOWS + p = VirtualAlloc(NULL, sz, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); + if (!p) + lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV); +#elif LJ_TARGET_POSIX + p = mmap(NULL, sz, (PROT_READ|PROT_WRITE), MAP_PRIVATE|MAP_ANONYMOUS, + -1, 0); + if (p == MAP_FAILED) + lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV); +#else + /* Fallback allocator. Fails if memory is not executable by default. */ + p = lj_mem_new(cts->L, sz); +#endif + cts->cb.mcode = p; + callback_mcode_init(cts->g, p); + lj_mcode_sync(p, (char *)p + sz); +#if LJ_TARGET_WINDOWS + { + DWORD oprot; + VirtualProtect(p, sz, PAGE_EXECUTE_READ, &oprot); + } +#elif LJ_TARGET_POSIX + mprotect(p, sz, (PROT_READ|PROT_EXEC)); +#endif +} + +/* Free area for callback function pointers. */ +void lj_ccallback_mcode_free(CTState *cts) +{ + size_t sz = (size_t)CALLBACK_MCODE_SIZE; + void *p = cts->cb.mcode; + if (p == NULL) return; +#if LJ_TARGET_WINDOWS + VirtualFree(p, 0, MEM_RELEASE); + UNUSED(sz); +#elif LJ_TARGET_POSIX + munmap(p, sz); +#else + lj_mem_free(cts->g, p, sz); +#endif +} + +/* -- C callback entry ---------------------------------------------------- */ + +/* Target-specific handling of register arguments. Similar to lj_ccall.c. */ +#if LJ_TARGET_X86 + +#define CALLBACK_HANDLE_REGARG \ + if (!isfp) { /* Only non-FP values may be passed in registers. */ \ + if (n > 1) { /* Anything > 32 bit is passed on the stack. */ \ + if (!LJ_ABI_WIN) ngpr = maxgpr; /* Prevent reordering. */ \ + } else if (ngpr + 1 <= maxgpr) { \ + sp = &cts->cb.gpr[ngpr]; \ + ngpr += n; \ + goto done; \ + } \ + } + +#elif LJ_TARGET_X64 && LJ_ABI_WIN + +/* Windows/x64 argument registers are strictly positional (use ngpr). */ +#define CALLBACK_HANDLE_REGARG \ + if (isfp) { \ + if (ngpr < maxgpr) { sp = &cts->cb.fpr[ngpr++]; UNUSED(nfpr); goto done; } \ + } else { \ + if (ngpr < maxgpr) { sp = &cts->cb.gpr[ngpr++]; goto done; } \ + } + +#elif LJ_TARGET_X64 + +#define CALLBACK_HANDLE_REGARG \ + if (isfp) { \ + if (nfpr + n <= CCALL_NARG_FPR) { \ + sp = &cts->cb.fpr[nfpr]; \ + nfpr += n; \ + goto done; \ + } \ + } else { \ + if (ngpr + n <= maxgpr) { \ + sp = &cts->cb.gpr[ngpr]; \ + ngpr += n; \ + goto done; \ + } \ + } + +#elif LJ_TARGET_ARM + +#if LJ_ABI_SOFTFP + +#define CALLBACK_HANDLE_REGARG_FP1 UNUSED(isfp); +#define CALLBACK_HANDLE_REGARG_FP2 + +#else + +#define CALLBACK_HANDLE_REGARG_FP1 \ + if (isfp) { \ + if (n == 1) { \ + if (fprodd) { \ + sp = &cts->cb.fpr[fprodd-1]; \ + fprodd = 0; \ + goto done; \ + } else if (nfpr + 1 <= CCALL_NARG_FPR) { \ + sp = &cts->cb.fpr[nfpr++]; \ + fprodd = nfpr; \ + goto done; \ + } \ + } else { \ + if (nfpr + 1 <= CCALL_NARG_FPR) { \ + sp = &cts->cb.fpr[nfpr++]; \ + goto done; \ + } \ + } \ + fprodd = 0; /* No reordering after the first FP value is on stack. */ \ + } else { + +#define CALLBACK_HANDLE_REGARG_FP2 } + +#endif + +#define CALLBACK_HANDLE_REGARG \ + CALLBACK_HANDLE_REGARG_FP1 \ + if (n > 1) ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \ + if (ngpr + n <= maxgpr) { \ + sp = &cts->cb.gpr[ngpr]; \ + ngpr += n; \ + goto done; \ + } CALLBACK_HANDLE_REGARG_FP2 + +#elif LJ_TARGET_PPC + +#define CALLBACK_HANDLE_REGARG \ + if (isfp) { \ + if (nfpr + 1 <= CCALL_NARG_FPR) { \ + sp = &cts->cb.fpr[nfpr++]; \ + cta = ctype_get(cts, CTID_DOUBLE); /* FPRs always hold doubles. */ \ + goto done; \ + } \ + } else { /* Try to pass argument in GPRs. */ \ + if (n > 1) { \ + lua_assert(ctype_isinteger(cta->info) && n == 2); /* int64_t. */ \ + ngpr = (ngpr + 1u) & ~1u; /* Align int64_t to regpair. */ \ + } \ + if (ngpr + n <= maxgpr) { \ + sp = &cts->cb.gpr[ngpr]; \ + ngpr += n; \ + goto done; \ + } \ + } + +#define CALLBACK_HANDLE_RET \ + if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \ + *(double *)dp = *(float *)dp; /* FPRs always hold doubles. */ + +#elif LJ_TARGET_MIPS + +#define CALLBACK_HANDLE_REGARG \ + if (isfp && nfpr < CCALL_NARG_FPR) { /* Try to pass argument in FPRs. */ \ + sp = (void *)((uint8_t *)&cts->cb.fpr[nfpr] + ((LJ_BE && n==1) ? 4 : 0)); \ + nfpr++; ngpr += n; \ + goto done; \ + } else { /* Try to pass argument in GPRs. */ \ + nfpr = CCALL_NARG_FPR; \ + if (n > 1) ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \ + if (ngpr + n <= maxgpr) { \ + sp = &cts->cb.gpr[ngpr]; \ + ngpr += n; \ + goto done; \ + } \ + } + +#define CALLBACK_HANDLE_RET \ + if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \ + ((float *)dp)[1] = *(float *)dp; + +#else +#error "Missing calling convention definitions for this architecture" +#endif + +/* Convert and push callback arguments to Lua stack. */ +static void callback_conv_args(CTState *cts, lua_State *L) +{ + TValue *o = L->top; + intptr_t *stack = cts->cb.stack; + MSize slot = cts->cb.slot; + CTypeID id = 0, rid, fid; + int gcsteps = 0; + CType *ct; + GCfunc *fn; + MSize ngpr = 0, nsp = 0, maxgpr = CCALL_NARG_GPR; +#if CCALL_NARG_FPR + MSize nfpr = 0; +#if LJ_TARGET_ARM + MSize fprodd = 0; +#endif +#endif + + if (slot < cts->cb.sizeid && (id = cts->cb.cbid[slot]) != 0) { + ct = ctype_get(cts, id); + rid = ctype_cid(ct->info); + fn = funcV(lj_tab_getint(cts->miscmap, (int32_t)slot)); + } else { /* Must set up frame first, before throwing the error. */ + ct = NULL; + rid = 0; + fn = (GCfunc *)L; + } + o->u32.lo = LJ_CONT_FFI_CALLBACK; /* Continuation returns from callback. */ + o->u32.hi = rid; /* Return type. x86: +(spadj<<16). */ + o++; + setframe_gc(o, obj2gco(fn)); + setframe_ftsz(o, (int)((char *)(o+1) - (char *)L->base) + FRAME_CONT); + L->top = L->base = ++o; + if (!ct) + lj_err_caller(cts->L, LJ_ERR_FFI_BADCBACK); + if (isluafunc(fn)) + setcframe_pc(L->cframe, proto_bc(funcproto(fn))+1); + lj_state_checkstack(L, LUA_MINSTACK); /* May throw. */ + o = L->base; /* Might have been reallocated. */ + +#if LJ_TARGET_X86 + /* x86 has several different calling conventions. */ + switch (ctype_cconv(ct->info)) { + case CTCC_FASTCALL: maxgpr = 2; break; + case CTCC_THISCALL: maxgpr = 1; break; + default: maxgpr = 0; break; + } +#endif + + fid = ct->sib; + while (fid) { + CType *ctf = ctype_get(cts, fid); + if (!ctype_isattrib(ctf->info)) { + CType *cta; + void *sp; + CTSize sz; + int isfp; + MSize n; + lua_assert(ctype_isfield(ctf->info)); + cta = ctype_rawchild(cts, ctf); + isfp = ctype_isfp(cta->info); + sz = (cta->size + CTSIZE_PTR-1) & ~(CTSIZE_PTR-1); + n = sz / CTSIZE_PTR; /* Number of GPRs or stack slots needed. */ + + CALLBACK_HANDLE_REGARG /* Handle register arguments. */ + + /* Otherwise pass argument on stack. */ + if (CCALL_ALIGN_STACKARG && LJ_32 && sz == 8) + nsp = (nsp + 1) & ~1u; /* Align 64 bit argument on stack. */ + sp = &stack[nsp]; + nsp += n; + + done: + if (LJ_BE && cta->size < CTSIZE_PTR) + sp = (void *)((uint8_t *)sp + CTSIZE_PTR-cta->size); + gcsteps += lj_cconv_tv_ct(cts, cta, 0, o++, sp); + } + fid = ctf->sib; + } + L->top = o; +#if LJ_TARGET_X86 + /* Store stack adjustment for returns from non-cdecl callbacks. */ + if (ctype_cconv(ct->info) != CTCC_CDECL) + (L->base-2)->u32.hi |= (nsp << (16+2)); +#endif + while (gcsteps-- > 0) + lj_gc_check(L); +} + +/* Convert Lua object to callback result. */ +static void callback_conv_result(CTState *cts, lua_State *L, TValue *o) +{ + CType *ctr = ctype_raw(cts, (uint16_t)(L->base-2)->u32.hi); +#if LJ_TARGET_X86 + cts->cb.gpr[2] = 0; +#endif + if (!ctype_isvoid(ctr->info)) { + uint8_t *dp = (uint8_t *)&cts->cb.gpr[0]; +#if CCALL_NUM_FPR + if (ctype_isfp(ctr->info)) + dp = (uint8_t *)&cts->cb.fpr[0]; +#endif + lj_cconv_ct_tv(cts, ctr, dp, o, 0); +#ifdef CALLBACK_HANDLE_RET + CALLBACK_HANDLE_RET +#endif + /* Extend returned integers to (at least) 32 bits. */ + if (ctype_isinteger_or_bool(ctr->info) && ctr->size < 4) { + if (ctr->info & CTF_UNSIGNED) + *(uint32_t *)dp = ctr->size == 1 ? (uint32_t)*(uint8_t *)dp : + (uint32_t)*(uint16_t *)dp; + else + *(int32_t *)dp = ctr->size == 1 ? (int32_t)*(int8_t *)dp : + (int32_t)*(int16_t *)dp; + } +#if LJ_TARGET_X86 + if (ctype_isfp(ctr->info)) + cts->cb.gpr[2] = ctr->size == sizeof(float) ? 1 : 2; +#endif + } +} + +/* Enter callback. */ +lua_State * LJ_FASTCALL lj_ccallback_enter(CTState *cts, void *cf) +{ + lua_State *L = cts->L; + global_State *g = cts->g; + lua_assert(L != NULL); + if (gcref(g->jit_L)) { + setstrV(L, L->top++, lj_err_str(L, LJ_ERR_FFI_BADCBACK)); + if (g->panic) g->panic(L); + exit(EXIT_FAILURE); + } + lj_trace_abort(g); /* Never record across callback. */ + /* Setup C frame. */ + cframe_prev(cf) = L->cframe; + setcframe_L(cf, L); + cframe_errfunc(cf) = -1; + cframe_nres(cf) = 0; + L->cframe = cf; + callback_conv_args(cts, L); + return L; /* Now call the function on this stack. */ +} + +/* Leave callback. */ +void LJ_FASTCALL lj_ccallback_leave(CTState *cts, TValue *o) +{ + lua_State *L = cts->L; + GCfunc *fn; + TValue *obase = L->base; + L->base = L->top; /* Keep continuation frame for throwing errors. */ + if (o >= L->base) { + /* PC of RET* is lost. Point to last line for result conv. errors. */ + fn = curr_func(L); + if (isluafunc(fn)) { + GCproto *pt = funcproto(fn); + setcframe_pc(L->cframe, proto_bc(pt)+pt->sizebc+1); + } + } + callback_conv_result(cts, L, o); + /* Finally drop C frame and continuation frame. */ + L->cframe = cframe_prev(L->cframe); + L->top -= 2; + L->base = obase; + cts->cb.slot = 0; /* Blacklist C function that called the callback. */ +} + +/* -- C callback management ----------------------------------------------- */ + +/* Get an unused slot in the callback slot table. */ +static MSize callback_slot_new(CTState *cts, CType *ct) +{ + CTypeID id = ctype_typeid(cts, ct); + CTypeID1 *cbid = cts->cb.cbid; + MSize top; + for (top = cts->cb.topid; top < cts->cb.sizeid; top++) + if (LJ_LIKELY(cbid[top] == 0)) + goto found; +#if CALLBACK_MAX_SLOT + if (top >= CALLBACK_MAX_SLOT) +#endif + lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV); + if (!cts->cb.mcode) + callback_mcode_new(cts); + lj_mem_growvec(cts->L, cbid, cts->cb.sizeid, CALLBACK_MAX_SLOT, CTypeID1); + cts->cb.cbid = cbid; + memset(cbid+top, 0, (cts->cb.sizeid-top)*sizeof(CTypeID1)); +found: + cbid[top] = id; + cts->cb.topid = top+1; + return top; +} + +/* Check for function pointer and supported argument/result types. */ +static CType *callback_checkfunc(CTState *cts, CType *ct) +{ + int narg = 0; + if (!ctype_isptr(ct->info) || (LJ_64 && ct->size != CTSIZE_PTR)) + return NULL; + ct = ctype_rawchild(cts, ct); + if (ctype_isfunc(ct->info)) { + CType *ctr = ctype_rawchild(cts, ct); + CTypeID fid = ct->sib; + if (!(ctype_isvoid(ctr->info) || ctype_isenum(ctr->info) || + ctype_isptr(ctr->info) || (ctype_isnum(ctr->info) && ctr->size <= 8))) + return NULL; + if ((ct->info & CTF_VARARG)) + return NULL; + while (fid) { + CType *ctf = ctype_get(cts, fid); + if (!ctype_isattrib(ctf->info)) { + CType *cta; + lua_assert(ctype_isfield(ctf->info)); + cta = ctype_rawchild(cts, ctf); + if (!(ctype_isenum(cta->info) || ctype_isptr(cta->info) || + (ctype_isnum(cta->info) && cta->size <= 8)) || + ++narg >= LUA_MINSTACK-3) + return NULL; + } + fid = ctf->sib; + } + return ct; + } + return NULL; +} + +/* Create a new callback and return the callback function pointer. */ +void *lj_ccallback_new(CTState *cts, CType *ct, GCfunc *fn) +{ + ct = callback_checkfunc(cts, ct); + if (ct) { + MSize slot = callback_slot_new(cts, ct); + GCtab *t = cts->miscmap; + setfuncV(cts->L, lj_tab_setint(cts->L, t, (int32_t)slot), fn); + lj_gc_anybarriert(cts->L, t); + return callback_slot2ptr(cts, slot); + } + return NULL; /* Bad conversion. */ +} + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_ccallback.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ccallback.h new file mode 100644 index 000000000..83dbe048b --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ccallback.h @@ -0,0 +1,25 @@ +/* +** FFI C callback handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_CCALLBACK_H +#define _LJ_CCALLBACK_H + +#include "lj_obj.h" +#include "lj_ctype.h" + +#if LJ_HASFFI + +/* Really belongs to lj_vm.h. */ +LJ_ASMF void lj_vm_ffi_callback(void); + +LJ_FUNC MSize lj_ccallback_ptr2slot(CTState *cts, void *p); +LJ_FUNCA lua_State * LJ_FASTCALL lj_ccallback_enter(CTState *cts, void *cf); +LJ_FUNCA void LJ_FASTCALL lj_ccallback_leave(CTState *cts, TValue *o); +LJ_FUNC void *lj_ccallback_new(CTState *cts, CType *ct, GCfunc *fn); +LJ_FUNC void lj_ccallback_mcode_free(CTState *cts); + +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_cconv.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_cconv.c new file mode 100644 index 000000000..8a270766f --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_cconv.c @@ -0,0 +1,752 @@ +/* +** C type conversions. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "lj_obj.h" + +#if LJ_HASFFI + +#include "lj_err.h" +#include "lj_tab.h" +#include "lj_ctype.h" +#include "lj_cdata.h" +#include "lj_cconv.h" +#include "lj_ccallback.h" + +/* -- Conversion errors --------------------------------------------------- */ + +/* Bad conversion. */ +LJ_NORET static void cconv_err_conv(CTState *cts, CType *d, CType *s, + CTInfo flags) +{ + const char *dst = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, d), NULL)); + const char *src; + if ((flags & CCF_FROMTV)) + src = lj_obj_typename[1+(ctype_isnum(s->info) ? LUA_TNUMBER : + ctype_isarray(s->info) ? LUA_TSTRING : LUA_TNIL)]; + else + src = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, s), NULL)); + if (CCF_GETARG(flags)) + lj_err_argv(cts->L, CCF_GETARG(flags), LJ_ERR_FFI_BADCONV, src, dst); + else + lj_err_callerv(cts->L, LJ_ERR_FFI_BADCONV, src, dst); +} + +/* Bad conversion from TValue. */ +LJ_NORET static void cconv_err_convtv(CTState *cts, CType *d, TValue *o, + CTInfo flags) +{ + const char *dst = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, d), NULL)); + const char *src = lj_typename(o); + if (CCF_GETARG(flags)) + lj_err_argv(cts->L, CCF_GETARG(flags), LJ_ERR_FFI_BADCONV, src, dst); + else + lj_err_callerv(cts->L, LJ_ERR_FFI_BADCONV, src, dst); +} + +/* Initializer overflow. */ +LJ_NORET static void cconv_err_initov(CTState *cts, CType *d) +{ + const char *dst = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, d), NULL)); + lj_err_callerv(cts->L, LJ_ERR_FFI_INITOV, dst); +} + +/* -- C type compatibility checks ----------------------------------------- */ + +/* Get raw type and qualifiers for a child type. Resolves enums, too. */ +static CType *cconv_childqual(CTState *cts, CType *ct, CTInfo *qual) +{ + ct = ctype_child(cts, ct); + for (;;) { + if (ctype_isattrib(ct->info)) { + if (ctype_attrib(ct->info) == CTA_QUAL) *qual |= ct->size; + } else if (!ctype_isenum(ct->info)) { + break; + } + ct = ctype_child(cts, ct); + } + *qual |= (ct->info & CTF_QUAL); + return ct; +} + +/* Check for compatible types when converting to a pointer. +** Note: these checks are more relaxed than what C99 mandates. +*/ +int lj_cconv_compatptr(CTState *cts, CType *d, CType *s, CTInfo flags) +{ + if (!((flags & CCF_CAST) || d == s)) { + CTInfo dqual = 0, squal = 0; + d = cconv_childqual(cts, d, &dqual); + if (!ctype_isstruct(s->info)) + s = cconv_childqual(cts, s, &squal); + if ((flags & CCF_SAME)) { + if (dqual != squal) + return 0; /* Different qualifiers. */ + } else if (!(flags & CCF_IGNQUAL)) { + if ((dqual & squal) != squal) + return 0; /* Discarded qualifiers. */ + if (ctype_isvoid(d->info) || ctype_isvoid(s->info)) + return 1; /* Converting to/from void * is always ok. */ + } + if (ctype_type(d->info) != ctype_type(s->info) || + d->size != s->size) + return 0; /* Different type or different size. */ + if (ctype_isnum(d->info)) { + if (((d->info ^ s->info) & (CTF_BOOL|CTF_FP))) + return 0; /* Different numeric types. */ + } else if (ctype_ispointer(d->info)) { + /* Check child types for compatibility. */ + return lj_cconv_compatptr(cts, d, s, flags|CCF_SAME); + } else if (ctype_isstruct(d->info)) { + if (d != s) + return 0; /* Must be exact same type for struct/union. */ + } else if (ctype_isfunc(d->info)) { + /* NYI: structural equality of functions. */ + } + } + return 1; /* Types are compatible. */ +} + +/* -- C type to C type conversion ----------------------------------------- */ + +/* Convert C type to C type. Caveat: expects to get the raw CType! +** +** Note: This is only used by the interpreter and not optimized at all. +** The JIT compiler will do a much better job specializing for each case. +*/ +void lj_cconv_ct_ct(CTState *cts, CType *d, CType *s, + uint8_t *dp, uint8_t *sp, CTInfo flags) +{ + CTSize dsize = d->size, ssize = s->size; + CTInfo dinfo = d->info, sinfo = s->info; + void *tmpptr; + + lua_assert(!ctype_isenum(dinfo) && !ctype_isenum(sinfo)); + lua_assert(!ctype_isattrib(dinfo) && !ctype_isattrib(sinfo)); + + if (ctype_type(dinfo) > CT_MAYCONVERT || ctype_type(sinfo) > CT_MAYCONVERT) + goto err_conv; + + /* Some basic sanity checks. */ + lua_assert(!ctype_isnum(dinfo) || dsize > 0); + lua_assert(!ctype_isnum(sinfo) || ssize > 0); + lua_assert(!ctype_isbool(dinfo) || dsize == 1 || dsize == 4); + lua_assert(!ctype_isbool(sinfo) || ssize == 1 || ssize == 4); + lua_assert(!ctype_isinteger(dinfo) || (1u< ssize) { /* Zero-extend or sign-extend LSB. */ +#if LJ_LE + uint8_t fill = (!(sinfo & CTF_UNSIGNED) && (sp[ssize-1]&0x80)) ? 0xff : 0; + memcpy(dp, sp, ssize); + memset(dp + ssize, fill, dsize-ssize); +#else + uint8_t fill = (!(sinfo & CTF_UNSIGNED) && (sp[0]&0x80)) ? 0xff : 0; + memset(dp, fill, dsize-ssize); + memcpy(dp + (dsize-ssize), sp, ssize); +#endif + } else { /* Copy LSB. */ +#if LJ_LE + memcpy(dp, sp, dsize); +#else + memcpy(dp, sp + (ssize-dsize), dsize); +#endif + } + break; + case CCX(I, F): { + double n; /* Always convert via double. */ + conv_I_F: + /* Convert source to double. */ + if (ssize == sizeof(double)) n = *(double *)sp; + else if (ssize == sizeof(float)) n = (double)*(float *)sp; + else goto err_conv; /* NYI: long double. */ + /* Then convert double to integer. */ + /* The conversion must exactly match the semantics of JIT-compiled code! */ + if (dsize < 4 || (dsize == 4 && !(dinfo & CTF_UNSIGNED))) { + int32_t i = (int32_t)n; + if (dsize == 4) *(int32_t *)dp = i; + else if (dsize == 2) *(int16_t *)dp = (int16_t)i; + else *(int8_t *)dp = (int8_t)i; + } else if (dsize == 4) { + *(uint32_t *)dp = (uint32_t)n; + } else if (dsize == 8) { + if (!(dinfo & CTF_UNSIGNED)) + *(int64_t *)dp = (int64_t)n; + else + *(uint64_t *)dp = lj_num2u64(n); + } else { + goto err_conv; /* NYI: conversion to >64 bit integers. */ + } + break; + } + case CCX(I, C): + s = ctype_child(cts, s); + sinfo = s->info; + ssize = s->size; + goto conv_I_F; /* Just convert re. */ + case CCX(I, P): + if (!(flags & CCF_CAST)) goto err_conv; + sinfo = CTINFO(CT_NUM, CTF_UNSIGNED); + goto conv_I_I; + case CCX(I, A): + if (!(flags & CCF_CAST)) goto err_conv; + sinfo = CTINFO(CT_NUM, CTF_UNSIGNED); + ssize = CTSIZE_PTR; + tmpptr = sp; + sp = (uint8_t *)&tmpptr; + goto conv_I_I; + + /* Destination is a floating-point number. */ + case CCX(F, B): + case CCX(F, I): { + double n; /* Always convert via double. */ + conv_F_I: + /* First convert source to double. */ + /* The conversion must exactly match the semantics of JIT-compiled code! */ + if (ssize < 4 || (ssize == 4 && !(sinfo & CTF_UNSIGNED))) { + int32_t i; + if (ssize == 4) { + i = *(int32_t *)sp; + } else if (!(sinfo & CTF_UNSIGNED)) { + if (ssize == 2) i = *(int16_t *)sp; + else i = *(int8_t *)sp; + } else { + if (ssize == 2) i = *(uint16_t *)sp; + else i = *(uint8_t *)sp; + } + n = (double)i; + } else if (ssize == 4) { + n = (double)*(uint32_t *)sp; + } else if (ssize == 8) { + if (!(sinfo & CTF_UNSIGNED)) n = (double)*(int64_t *)sp; + else n = (double)*(uint64_t *)sp; + } else { + goto err_conv; /* NYI: conversion from >64 bit integers. */ + } + /* Convert double to destination. */ + if (dsize == sizeof(double)) *(double *)dp = n; + else if (dsize == sizeof(float)) *(float *)dp = (float)n; + else goto err_conv; /* NYI: long double. */ + break; + } + case CCX(F, F): { + double n; /* Always convert via double. */ + conv_F_F: + if (ssize == dsize) goto copyval; + /* Convert source to double. */ + if (ssize == sizeof(double)) n = *(double *)sp; + else if (ssize == sizeof(float)) n = (double)*(float *)sp; + else goto err_conv; /* NYI: long double. */ + /* Convert double to destination. */ + if (dsize == sizeof(double)) *(double *)dp = n; + else if (dsize == sizeof(float)) *(float *)dp = (float)n; + else goto err_conv; /* NYI: long double. */ + break; + } + case CCX(F, C): + s = ctype_child(cts, s); + sinfo = s->info; + ssize = s->size; + goto conv_F_F; /* Ignore im, and convert from re. */ + + /* Destination is a complex number. */ + case CCX(C, I): + d = ctype_child(cts, d); + dinfo = d->info; + dsize = d->size; + memset(dp + dsize, 0, dsize); /* Clear im. */ + goto conv_F_I; /* Convert to re. */ + case CCX(C, F): + d = ctype_child(cts, d); + dinfo = d->info; + dsize = d->size; + memset(dp + dsize, 0, dsize); /* Clear im. */ + goto conv_F_F; /* Convert to re. */ + + case CCX(C, C): + if (dsize != ssize) { /* Different types: convert re/im separately. */ + CType *dc = ctype_child(cts, d); + CType *sc = ctype_child(cts, s); + lj_cconv_ct_ct(cts, dc, sc, dp, sp, flags); + lj_cconv_ct_ct(cts, dc, sc, dp + dc->size, sp + sc->size, flags); + return; + } + goto copyval; /* Otherwise this is easy. */ + + /* Destination is a vector. */ + case CCX(V, I): + case CCX(V, F): + case CCX(V, C): { + CType *dc = ctype_child(cts, d); + CTSize esize; + /* First convert the scalar to the first element. */ + lj_cconv_ct_ct(cts, dc, s, dp, sp, flags); + /* Then replicate it to the other elements (splat). */ + for (sp = dp, esize = dc->size; dsize > esize; dsize -= esize) { + dp += esize; + memcpy(dp, sp, esize); + } + break; + } + + case CCX(V, V): + /* Copy same-sized vectors, even for different lengths/element-types. */ + if (dsize != ssize) goto err_conv; + goto copyval; + + /* Destination is a pointer. */ + case CCX(P, I): + if (!(flags & CCF_CAST)) goto err_conv; + dinfo = CTINFO(CT_NUM, CTF_UNSIGNED); + goto conv_I_I; + + case CCX(P, F): + if (!(flags & CCF_CAST) || !(flags & CCF_FROMTV)) goto err_conv; + /* The signed conversion is cheaper. x64 really has 47 bit pointers. */ + dinfo = CTINFO(CT_NUM, (LJ_64 && dsize == 8) ? 0 : CTF_UNSIGNED); + goto conv_I_F; + + case CCX(P, P): + if (!lj_cconv_compatptr(cts, d, s, flags)) goto err_conv; + cdata_setptr(dp, dsize, cdata_getptr(sp, ssize)); + break; + + case CCX(P, A): + case CCX(P, S): + if (!lj_cconv_compatptr(cts, d, s, flags)) goto err_conv; + cdata_setptr(dp, dsize, sp); + break; + + /* Destination is an array. */ + case CCX(A, A): + if ((flags & CCF_CAST) || (d->info & CTF_VLA) || dsize != ssize || + d->size == CTSIZE_INVALID || !lj_cconv_compatptr(cts, d, s, flags)) + goto err_conv; + goto copyval; + + /* Destination is a struct/union. */ + case CCX(S, S): + if ((flags & CCF_CAST) || (d->info & CTF_VLA) || d != s) + goto err_conv; /* Must be exact same type. */ +copyval: /* Copy value. */ + lua_assert(dsize == ssize); + memcpy(dp, sp, dsize); + break; + + default: + err_conv: + cconv_err_conv(cts, d, s, flags); + } +} + +/* -- C type to TValue conversion ----------------------------------------- */ + +/* Convert C type to TValue. Caveat: expects to get the raw CType! */ +int lj_cconv_tv_ct(CTState *cts, CType *s, CTypeID sid, + TValue *o, uint8_t *sp) +{ + CTInfo sinfo = s->info; + if (ctype_isnum(sinfo)) { + if (!ctype_isbool(sinfo)) { + if (ctype_isinteger(sinfo) && s->size > 4) goto copyval; + if (LJ_DUALNUM && ctype_isinteger(sinfo)) { + int32_t i; + lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT32), s, + (uint8_t *)&i, sp, 0); + if ((sinfo & CTF_UNSIGNED) && i < 0) + setnumV(o, (lua_Number)(uint32_t)i); + else + setintV(o, i); + } else { + lj_cconv_ct_ct(cts, ctype_get(cts, CTID_DOUBLE), s, + (uint8_t *)&o->n, sp, 0); + /* Numbers are NOT canonicalized here! Beware of uninitialized data. */ + lua_assert(tvisnum(o)); + } + } else { + uint32_t b = s->size == 1 ? (*sp != 0) : (*(int *)sp != 0); + setboolV(o, b); + setboolV(&cts->g->tmptv2, b); /* Remember for trace recorder. */ + } + return 0; + } else if (ctype_isrefarray(sinfo) || ctype_isstruct(sinfo)) { + /* Create reference. */ + setcdataV(cts->L, o, lj_cdata_newref(cts, sp, sid)); + return 1; /* Need GC step. */ + } else { + GCcdata *cd; + CTSize sz; + copyval: /* Copy value. */ + sz = s->size; + lua_assert(sz != CTSIZE_INVALID); + /* Attributes are stripped, qualifiers are kept (but mostly ignored). */ + cd = lj_cdata_new(cts, ctype_typeid(cts, s), sz); + setcdataV(cts->L, o, cd); + memcpy(cdataptr(cd), sp, sz); + return 1; /* Need GC step. */ + } +} + +/* Convert bitfield to TValue. */ +int lj_cconv_tv_bf(CTState *cts, CType *s, TValue *o, uint8_t *sp) +{ + CTInfo info = s->info; + CTSize pos, bsz; + uint32_t val; + lua_assert(ctype_isbitfield(info)); + /* NYI: packed bitfields may cause misaligned reads. */ + switch (ctype_bitcsz(info)) { + case 4: val = *(uint32_t *)sp; break; + case 2: val = *(uint16_t *)sp; break; + case 1: val = *(uint8_t *)sp; break; + default: lua_assert(0); val = 0; break; + } + /* Check if a packed bitfield crosses a container boundary. */ + pos = ctype_bitpos(info); + bsz = ctype_bitbsz(info); + lua_assert(pos < 8*ctype_bitcsz(info)); + lua_assert(bsz > 0 && bsz <= 8*ctype_bitcsz(info)); + if (pos + bsz > 8*ctype_bitcsz(info)) + lj_err_caller(cts->L, LJ_ERR_FFI_NYIPACKBIT); + if (!(info & CTF_BOOL)) { + CTSize shift = 32 - bsz; + if (!(info & CTF_UNSIGNED)) { + setintV(o, (int32_t)(val << (shift-pos)) >> shift); + } else { + val = (val << (shift-pos)) >> shift; + if (!LJ_DUALNUM || (int32_t)val < 0) + setnumV(o, (lua_Number)(uint32_t)val); + else + setintV(o, (int32_t)val); + } + } else { + lua_assert(bsz == 1); + setboolV(o, (val >> pos) & 1); + } + return 0; /* No GC step needed. */ +} + +/* -- TValue to C type conversion ----------------------------------------- */ + +/* Convert table to array. */ +static void cconv_array_tab(CTState *cts, CType *d, + uint8_t *dp, GCtab *t, CTInfo flags) +{ + int32_t i; + CType *dc = ctype_rawchild(cts, d); /* Array element type. */ + CTSize size = d->size, esize = dc->size, ofs = 0; + for (i = 0; ; i++) { + TValue *tv = (TValue *)lj_tab_getint(t, i); + if (!tv || tvisnil(tv)) { + if (i == 0) continue; /* Try again for 1-based tables. */ + break; /* Stop at first nil. */ + } + if (ofs >= size) + cconv_err_initov(cts, d); + lj_cconv_ct_tv(cts, dc, dp + ofs, tv, flags); + ofs += esize; + } + if (size != CTSIZE_INVALID) { /* Only fill up arrays with known size. */ + if (ofs == esize) { /* Replicate a single element. */ + for (; ofs < size; ofs += esize) memcpy(dp + ofs, dp, esize); + } else { /* Otherwise fill the remainder with zero. */ + memset(dp + ofs, 0, size - ofs); + } + } +} + +/* Convert table to sub-struct/union. */ +static void cconv_substruct_tab(CTState *cts, CType *d, uint8_t *dp, + GCtab *t, int32_t *ip, CTInfo flags) +{ + CTypeID id = d->sib; + while (id) { + CType *df = ctype_get(cts, id); + id = df->sib; + if (ctype_isfield(df->info) || ctype_isbitfield(df->info)) { + TValue *tv; + int32_t i = *ip, iz = i; + if (!gcref(df->name)) continue; /* Ignore unnamed fields. */ + if (i >= 0) { + retry: + tv = (TValue *)lj_tab_getint(t, i); + if (!tv || tvisnil(tv)) { + if (i == 0) { i = 1; goto retry; } /* 1-based tables. */ + if (iz == 0) { *ip = i = -1; goto tryname; } /* Init named fields. */ + break; /* Stop at first nil. */ + } + *ip = i + 1; + } else { + tryname: + tv = (TValue *)lj_tab_getstr(t, gco2str(gcref(df->name))); + if (!tv || tvisnil(tv)) continue; + } + if (ctype_isfield(df->info)) + lj_cconv_ct_tv(cts, ctype_rawchild(cts, df), dp+df->size, tv, flags); + else + lj_cconv_bf_tv(cts, df, dp+df->size, tv); + if ((d->info & CTF_UNION)) break; + } else if (ctype_isxattrib(df->info, CTA_SUBTYPE)) { + cconv_substruct_tab(cts, ctype_rawchild(cts, df), + dp+df->size, t, ip, flags); + } /* Ignore all other entries in the chain. */ + } +} + +/* Convert table to struct/union. */ +static void cconv_struct_tab(CTState *cts, CType *d, + uint8_t *dp, GCtab *t, CTInfo flags) +{ + int32_t i = 0; + memset(dp, 0, d->size); /* Much simpler to clear the struct first. */ + cconv_substruct_tab(cts, d, dp, t, &i, flags); +} + +/* Convert TValue to C type. Caveat: expects to get the raw CType! */ +void lj_cconv_ct_tv(CTState *cts, CType *d, + uint8_t *dp, TValue *o, CTInfo flags) +{ + CTypeID sid = CTID_P_VOID; + CType *s; + void *tmpptr; + uint8_t tmpbool, *sp = (uint8_t *)&tmpptr; + if (LJ_LIKELY(tvisint(o))) { + sp = (uint8_t *)&o->i; + sid = CTID_INT32; + flags |= CCF_FROMTV; + } else if (LJ_LIKELY(tvisnum(o))) { + sp = (uint8_t *)&o->n; + sid = CTID_DOUBLE; + flags |= CCF_FROMTV; + } else if (tviscdata(o)) { + sp = cdataptr(cdataV(o)); + sid = cdataV(o)->ctypeid; + s = ctype_get(cts, sid); + if (ctype_isref(s->info)) { /* Resolve reference for value. */ + lua_assert(s->size == CTSIZE_PTR); + sp = *(void **)sp; + sid = ctype_cid(s->info); + } + s = ctype_raw(cts, sid); + if (ctype_isfunc(s->info)) { + sid = lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|sid), CTSIZE_PTR); + } else { + if (ctype_isenum(s->info)) s = ctype_child(cts, s); + goto doconv; + } + } else if (tvisstr(o)) { + GCstr *str = strV(o); + if (ctype_isenum(d->info)) { /* Match string against enum constant. */ + CTSize ofs; + CType *cct = lj_ctype_getfield(cts, d, str, &ofs); + if (!cct || !ctype_isconstval(cct->info)) + goto err_conv; + lua_assert(d->size == 4); + sp = (uint8_t *)&cct->size; + sid = ctype_cid(cct->info); + } else if (ctype_isrefarray(d->info)) { /* Copy string to array. */ + CType *dc = ctype_rawchild(cts, d); + CTSize sz = str->len+1; + if (!ctype_isinteger(dc->info) || dc->size != 1) + goto err_conv; + if (d->size != 0 && d->size < sz) + sz = d->size; + memcpy(dp, strdata(str), sz); + return; + } else { /* Otherwise pass it as a const char[]. */ + sp = (uint8_t *)strdata(str); + sid = CTID_A_CCHAR; + flags |= CCF_FROMTV; + } + } else if (tvistab(o)) { + if (ctype_isarray(d->info)) { + cconv_array_tab(cts, d, dp, tabV(o), flags); + return; + } else if (ctype_isstruct(d->info)) { + cconv_struct_tab(cts, d, dp, tabV(o), flags); + return; + } else { + goto err_conv; + } + } else if (tvisbool(o)) { + tmpbool = boolV(o); + sp = &tmpbool; + sid = CTID_BOOL; + } else if (tvisnil(o)) { + tmpptr = (void *)0; + flags |= CCF_FROMTV; + } else if (tvisudata(o)) { + GCudata *ud = udataV(o); + tmpptr = uddata(ud); + if (ud->udtype == UDTYPE_IO_FILE) + tmpptr = *(void **)tmpptr; + } else if (tvislightud(o)) { + tmpptr = lightudV(o); + } else if (tvisfunc(o)) { + void *p = lj_ccallback_new(cts, d, funcV(o)); + if (p) { + *(void **)dp = p; + return; + } + goto err_conv; + } else { + err_conv: + cconv_err_convtv(cts, d, o, flags); + } + s = ctype_get(cts, sid); +doconv: + if (ctype_isenum(d->info)) d = ctype_child(cts, d); + lj_cconv_ct_ct(cts, d, s, dp, sp, flags); +} + +/* Convert TValue to bitfield. */ +void lj_cconv_bf_tv(CTState *cts, CType *d, uint8_t *dp, TValue *o) +{ + CTInfo info = d->info; + CTSize pos, bsz; + uint32_t val, mask; + lua_assert(ctype_isbitfield(info)); + if ((info & CTF_BOOL)) { + uint8_t tmpbool; + lua_assert(ctype_bitbsz(info) == 1); + lj_cconv_ct_tv(cts, ctype_get(cts, CTID_BOOL), &tmpbool, o, 0); + val = tmpbool; + } else { + CTypeID did = (info & CTF_UNSIGNED) ? CTID_UINT32 : CTID_INT32; + lj_cconv_ct_tv(cts, ctype_get(cts, did), (uint8_t *)&val, o, 0); + } + pos = ctype_bitpos(info); + bsz = ctype_bitbsz(info); + lua_assert(pos < 8*ctype_bitcsz(info)); + lua_assert(bsz > 0 && bsz <= 8*ctype_bitcsz(info)); + /* Check if a packed bitfield crosses a container boundary. */ + if (pos + bsz > 8*ctype_bitcsz(info)) + lj_err_caller(cts->L, LJ_ERR_FFI_NYIPACKBIT); + mask = ((1u << bsz) - 1u) << pos; + val = (val << pos) & mask; + /* NYI: packed bitfields may cause misaligned reads/writes. */ + switch (ctype_bitcsz(info)) { + case 4: *(uint32_t *)dp = (*(uint32_t *)dp & ~mask) | (uint32_t)val; break; + case 2: *(uint16_t *)dp = (*(uint16_t *)dp & ~mask) | (uint16_t)val; break; + case 1: *(uint8_t *)dp = (*(uint8_t *)dp & ~mask) | (uint8_t)val; break; + default: lua_assert(0); break; + } +} + +/* -- Initialize C type with TValues -------------------------------------- */ + +/* Initialize an array with TValues. */ +static void cconv_array_init(CTState *cts, CType *d, CTSize sz, uint8_t *dp, + TValue *o, MSize len) +{ + CType *dc = ctype_rawchild(cts, d); /* Array element type. */ + CTSize ofs, esize = dc->size; + MSize i; + if (len*esize > sz) + cconv_err_initov(cts, d); + for (i = 0, ofs = 0; i < len; i++, ofs += esize) + lj_cconv_ct_tv(cts, dc, dp + ofs, o + i, 0); + if (ofs == esize) { /* Replicate a single element. */ + for (; ofs < sz; ofs += esize) memcpy(dp + ofs, dp, esize); + } else { /* Otherwise fill the remainder with zero. */ + memset(dp + ofs, 0, sz - ofs); + } +} + +/* Initialize a sub-struct/union with TValues. */ +static void cconv_substruct_init(CTState *cts, CType *d, uint8_t *dp, + TValue *o, MSize len, MSize *ip) +{ + CTypeID id = d->sib; + while (id) { + CType *df = ctype_get(cts, id); + id = df->sib; + if (ctype_isfield(df->info) || ctype_isbitfield(df->info)) { + MSize i = *ip; + if (!gcref(df->name)) continue; /* Ignore unnamed fields. */ + if (i >= len) break; + *ip = i + 1; + if (ctype_isfield(df->info)) + lj_cconv_ct_tv(cts, ctype_rawchild(cts, df), dp+df->size, o + i, 0); + else + lj_cconv_bf_tv(cts, df, dp+df->size, o + i); + if ((d->info & CTF_UNION)) break; + } else if (ctype_isxattrib(df->info, CTA_SUBTYPE)) { + cconv_substruct_init(cts, ctype_rawchild(cts, df), + dp+df->size, o, len, ip); + if ((d->info & CTF_UNION)) break; + } /* Ignore all other entries in the chain. */ + } +} + +/* Initialize a struct/union with TValues. */ +static void cconv_struct_init(CTState *cts, CType *d, CTSize sz, uint8_t *dp, + TValue *o, MSize len) +{ + MSize i = 0; + memset(dp, 0, sz); /* Much simpler to clear the struct first. */ + cconv_substruct_init(cts, d, dp, o, len, &i); + if (i < len) + cconv_err_initov(cts, d); +} + +/* Check whether to use a multi-value initializer. +** This is true if an aggregate is to be initialized with a value. +** Valarrays are treated as values here so ct_tv handles (V|C, I|F). +*/ +int lj_cconv_multi_init(CTState *cts, CType *d, TValue *o) +{ + if (!(ctype_isrefarray(d->info) || ctype_isstruct(d->info))) + return 0; /* Destination is not an aggregate. */ + if (tvistab(o) || (tvisstr(o) && !ctype_isstruct(d->info))) + return 0; /* Initializer is not a value. */ + if (tviscdata(o) && lj_ctype_rawref(cts, cdataV(o)->ctypeid) == d) + return 0; /* Source and destination are identical aggregates. */ + return 1; /* Otherwise the initializer is a value. */ +} + +/* Initialize C type with TValues. Caveat: expects to get the raw CType! */ +void lj_cconv_ct_init(CTState *cts, CType *d, CTSize sz, + uint8_t *dp, TValue *o, MSize len) +{ + if (len == 0) + memset(dp, 0, sz); + else if (len == 1 && !lj_cconv_multi_init(cts, d, o)) + lj_cconv_ct_tv(cts, d, dp, o, 0); + else if (ctype_isarray(d->info)) /* Also handles valarray init with len>1. */ + cconv_array_init(cts, d, sz, dp, o, len); + else if (ctype_isstruct(d->info)) + cconv_struct_init(cts, d, sz, dp, o, len); + else + cconv_err_initov(cts, d); +} + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_cconv.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_cconv.h new file mode 100644 index 000000000..2bd50ff46 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_cconv.h @@ -0,0 +1,70 @@ +/* +** C type conversions. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_CCONV_H +#define _LJ_CCONV_H + +#include "lj_obj.h" +#include "lj_ctype.h" + +#if LJ_HASFFI + +/* Compressed C type index. ORDER CCX. */ +enum { + CCX_B, /* Bool. */ + CCX_I, /* Integer. */ + CCX_F, /* Floating-point number. */ + CCX_C, /* Complex. */ + CCX_V, /* Vector. */ + CCX_P, /* Pointer. */ + CCX_A, /* Refarray. */ + CCX_S /* Struct/union. */ +}; + +/* Convert C type info to compressed C type index. ORDER CT. ORDER CCX. */ +static LJ_AINLINE uint32_t cconv_idx(CTInfo info) +{ + uint32_t idx = ((info >> 26) & 15u); /* Dispatch bits. */ + lua_assert(ctype_type(info) <= CT_MAYCONVERT); +#if LJ_64 + idx = ((uint32_t)(U64x(f436fff5,fff7f021) >> 4*idx) & 15u); +#else + idx = (((idx < 8 ? 0xfff7f021u : 0xf436fff5) >> 4*(idx & 7u)) & 15u); +#endif + lua_assert(idx < 8); + return idx; +} + +#define cconv_idx2(dinfo, sinfo) \ + ((cconv_idx((dinfo)) << 3) + cconv_idx((sinfo))) + +#define CCX(dst, src) ((CCX_##dst << 3) + CCX_##src) + +/* Conversion flags. */ +#define CCF_CAST 0x00000001u +#define CCF_FROMTV 0x00000002u +#define CCF_SAME 0x00000004u +#define CCF_IGNQUAL 0x00000008u + +#define CCF_ARG_SHIFT 8 +#define CCF_ARG(n) ((n) << CCF_ARG_SHIFT) +#define CCF_GETARG(f) ((f) >> CCF_ARG_SHIFT) + +LJ_FUNC int lj_cconv_compatptr(CTState *cts, CType *d, CType *s, CTInfo flags); +LJ_FUNC void lj_cconv_ct_ct(CTState *cts, CType *d, CType *s, + uint8_t *dp, uint8_t *sp, CTInfo flags); +LJ_FUNC int lj_cconv_tv_ct(CTState *cts, CType *s, CTypeID sid, + TValue *o, uint8_t *sp); +LJ_FUNC int lj_cconv_tv_bf(CTState *cts, CType *s, TValue *o, uint8_t *sp); +LJ_FUNC void lj_cconv_ct_tv(CTState *cts, CType *d, + uint8_t *dp, TValue *o, CTInfo flags); +LJ_FUNC void lj_cconv_bf_tv(CTState *cts, CType *d, uint8_t *dp, TValue *o); +LJ_FUNC int lj_cconv_multi_init(CTState *cts, CType *d, TValue *o); +LJ_FUNC void lj_cconv_ct_init(CTState *cts, CType *d, CTSize sz, + uint8_t *dp, TValue *o, MSize len); + +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_cdata.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_cdata.c new file mode 100644 index 000000000..39fc13a9f --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_cdata.c @@ -0,0 +1,285 @@ +/* +** C data management. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "lj_obj.h" + +#if LJ_HASFFI + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_ctype.h" +#include "lj_cconv.h" +#include "lj_cdata.h" + +/* -- C data allocation --------------------------------------------------- */ + +/* Allocate a new C data object holding a reference to another object. */ +GCcdata *lj_cdata_newref(CTState *cts, const void *p, CTypeID id) +{ + CTypeID refid = lj_ctype_intern(cts, CTINFO_REF(id), CTSIZE_PTR); + GCcdata *cd = lj_cdata_new(cts, refid, CTSIZE_PTR); + *(const void **)cdataptr(cd) = p; + return cd; +} + +/* Allocate variable-sized or specially aligned C data object. */ +GCcdata *lj_cdata_newv(CTState *cts, CTypeID id, CTSize sz, CTSize align) +{ + global_State *g; + MSize extra = sizeof(GCcdataVar) + sizeof(GCcdata) + + (align > CT_MEMALIGN ? (1u<L, extra + sz, char); + uintptr_t adata = (uintptr_t)p + sizeof(GCcdataVar) + sizeof(GCcdata); + uintptr_t almask = (1u << align) - 1u; + GCcdata *cd = (GCcdata *)(((adata + almask) & ~almask) - sizeof(GCcdata)); + lua_assert((char *)cd - p < 65536); + cdatav(cd)->offset = (uint16_t)((char *)cd - p); + cdatav(cd)->extra = extra; + cdatav(cd)->len = sz; + g = cts->g; + setgcrefr(cd->nextgc, g->gc.root); + setgcref(g->gc.root, obj2gco(cd)); + newwhite(g, obj2gco(cd)); + cd->marked |= 0x80; + cd->gct = ~LJ_TCDATA; + cd->ctypeid = id; + return cd; +} + +/* Free a C data object. */ +void LJ_FASTCALL lj_cdata_free(global_State *g, GCcdata *cd) +{ + if (LJ_UNLIKELY(cd->marked & LJ_GC_CDATA_FIN)) { + GCobj *root; + makewhite(g, obj2gco(cd)); + markfinalized(obj2gco(cd)); + if ((root = gcref(g->gc.mmudata)) != NULL) { + setgcrefr(cd->nextgc, root->gch.nextgc); + setgcref(root->gch.nextgc, obj2gco(cd)); + setgcref(g->gc.mmudata, obj2gco(cd)); + } else { + setgcref(cd->nextgc, obj2gco(cd)); + setgcref(g->gc.mmudata, obj2gco(cd)); + } + } else if (LJ_LIKELY(!cdataisv(cd))) { + CType *ct = ctype_raw(ctype_ctsG(g), cd->ctypeid); + CTSize sz = ctype_hassize(ct->info) ? ct->size : CTSIZE_PTR; + lua_assert(ctype_hassize(ct->info) || ctype_isfunc(ct->info) || + ctype_isextern(ct->info)); + lj_mem_free(g, cd, sizeof(GCcdata) + sz); + } else { + lj_mem_free(g, memcdatav(cd), sizecdatav(cd)); + } +} + +TValue * LJ_FASTCALL lj_cdata_setfin(lua_State *L, GCcdata *cd) +{ + global_State *g = G(L); + GCtab *t = ctype_ctsG(g)->finalizer; + if (gcref(t->metatable)) { + /* Add cdata to finalizer table, if still enabled. */ + TValue *tv, tmp; + setcdataV(L, &tmp, cd); + lj_gc_anybarriert(L, t); + tv = lj_tab_set(L, t, &tmp); + cd->marked |= LJ_GC_CDATA_FIN; + return tv; + } else { + /* Otherwise return dummy TValue. */ + return &g->tmptv; + } +} + +/* -- C data indexing ----------------------------------------------------- */ + +/* Index C data by a TValue. Return CType and pointer. */ +CType *lj_cdata_index(CTState *cts, GCcdata *cd, cTValue *key, uint8_t **pp, + CTInfo *qual) +{ + uint8_t *p = (uint8_t *)cdataptr(cd); + CType *ct = ctype_get(cts, cd->ctypeid); + ptrdiff_t idx; + + /* Resolve reference for cdata object. */ + if (ctype_isref(ct->info)) { + lua_assert(ct->size == CTSIZE_PTR); + p = *(uint8_t **)p; + ct = ctype_child(cts, ct); + } + +collect_attrib: + /* Skip attributes and collect qualifiers. */ + while (ctype_isattrib(ct->info)) { + if (ctype_attrib(ct->info) == CTA_QUAL) *qual |= ct->size; + ct = ctype_child(cts, ct); + } + lua_assert(!ctype_isref(ct->info)); /* Interning rejects refs to refs. */ + + if (tvisint(key)) { + idx = (ptrdiff_t)intV(key); + goto integer_key; + } else if (tvisnum(key)) { /* Numeric key. */ + idx = LJ_64 ? (ptrdiff_t)numV(key) : (ptrdiff_t)lj_num2int(numV(key)); + integer_key: + if (ctype_ispointer(ct->info)) { + CTSize sz = lj_ctype_size(cts, ctype_cid(ct->info)); /* Element size. */ + if (sz == CTSIZE_INVALID) + lj_err_caller(cts->L, LJ_ERR_FFI_INVSIZE); + if (ctype_isptr(ct->info)) { + p = (uint8_t *)cdata_getptr(p, ct->size); + } else if ((ct->info & (CTF_VECTOR|CTF_COMPLEX))) { + if ((ct->info & CTF_COMPLEX)) idx &= 1; + *qual |= CTF_CONST; /* Valarray elements are constant. */ + } + *pp = p + idx*(int32_t)sz; + return ct; + } + } else if (tviscdata(key)) { /* Integer cdata key. */ + GCcdata *cdk = cdataV(key); + CType *ctk = ctype_raw(cts, cdk->ctypeid); + if (ctype_isenum(ctk->info)) ctk = ctype_child(cts, ctk); + if (ctype_isinteger(ctk->info)) { + lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT_PSZ), ctk, + (uint8_t *)&idx, cdataptr(cdk), 0); + goto integer_key; + } + } else if (tvisstr(key)) { /* String key. */ + GCstr *name = strV(key); + if (ctype_isstruct(ct->info)) { + CTSize ofs; + CType *fct = lj_ctype_getfieldq(cts, ct, name, &ofs, qual); + if (fct) { + *pp = p + ofs; + return fct; + } + } else if (ctype_iscomplex(ct->info)) { + if (name->len == 2) { + *qual |= CTF_CONST; /* Complex fields are constant. */ + if (strdata(name)[0] == 'r' && strdata(name)[1] == 'e') { + *pp = p; + return ct; + } else if (strdata(name)[0] == 'i' && strdata(name)[1] == 'm') { + *pp = p + (ct->size >> 1); + return ct; + } + } + } else if (cd->ctypeid == CTID_CTYPEID) { + /* Allow indexing a (pointer to) struct constructor to get constants. */ + CType *sct = ctype_raw(cts, *(CTypeID *)p); + if (ctype_isptr(sct->info)) + sct = ctype_rawchild(cts, sct); + if (ctype_isstruct(sct->info)) { + CTSize ofs; + CType *fct = lj_ctype_getfield(cts, sct, name, &ofs); + if (fct && ctype_isconstval(fct->info)) + return fct; + } + ct = sct; /* Allow resolving metamethods for constructors, too. */ + } + } + if (ctype_isptr(ct->info)) { /* Automatically perform '->'. */ + if (ctype_isstruct(ctype_rawchild(cts, ct)->info)) { + p = (uint8_t *)cdata_getptr(p, ct->size); + ct = ctype_child(cts, ct); + goto collect_attrib; + } + } + *qual |= 1; /* Lookup failed. */ + return ct; /* But return the resolved raw type. */ +} + +/* -- C data getters ------------------------------------------------------ */ + +/* Get constant value and convert to TValue. */ +static void cdata_getconst(CTState *cts, TValue *o, CType *ct) +{ + CType *ctt = ctype_child(cts, ct); + lua_assert(ctype_isinteger(ctt->info) && ctt->size <= 4); + /* Constants are already zero-extended/sign-extended to 32 bits. */ + if ((ctt->info & CTF_UNSIGNED) && (int32_t)ct->size < 0) + setnumV(o, (lua_Number)(uint32_t)ct->size); + else + setintV(o, (int32_t)ct->size); +} + +/* Get C data value and convert to TValue. */ +int lj_cdata_get(CTState *cts, CType *s, TValue *o, uint8_t *sp) +{ + CTypeID sid; + + if (ctype_isconstval(s->info)) { + cdata_getconst(cts, o, s); + return 0; /* No GC step needed. */ + } else if (ctype_isbitfield(s->info)) { + return lj_cconv_tv_bf(cts, s, o, sp); + } + + /* Get child type of pointer/array/field. */ + lua_assert(ctype_ispointer(s->info) || ctype_isfield(s->info)); + sid = ctype_cid(s->info); + s = ctype_get(cts, sid); + + /* Resolve reference for field. */ + if (ctype_isref(s->info)) { + lua_assert(s->size == CTSIZE_PTR); + sp = *(uint8_t **)sp; + sid = ctype_cid(s->info); + s = ctype_get(cts, sid); + } + + /* Skip attributes. */ + while (ctype_isattrib(s->info)) + s = ctype_child(cts, s); + + return lj_cconv_tv_ct(cts, s, sid, o, sp); +} + +/* -- C data setters ------------------------------------------------------ */ + +/* Convert TValue and set C data value. */ +void lj_cdata_set(CTState *cts, CType *d, uint8_t *dp, TValue *o, CTInfo qual) +{ + if (ctype_isconstval(d->info)) { + goto err_const; + } else if (ctype_isbitfield(d->info)) { + if (((d->info|qual) & CTF_CONST)) goto err_const; + lj_cconv_bf_tv(cts, d, dp, o); + return; + } + + /* Get child type of pointer/array/field. */ + lua_assert(ctype_ispointer(d->info) || ctype_isfield(d->info)); + d = ctype_child(cts, d); + + /* Resolve reference for field. */ + if (ctype_isref(d->info)) { + lua_assert(d->size == CTSIZE_PTR); + dp = *(uint8_t **)dp; + d = ctype_child(cts, d); + } + + /* Skip attributes and collect qualifiers. */ + for (;;) { + if (ctype_isattrib(d->info)) { + if (ctype_attrib(d->info) == CTA_QUAL) qual |= d->size; + } else { + break; + } + d = ctype_child(cts, d); + } + + lua_assert(ctype_hassize(d->info) && !ctype_isvoid(d->info)); + + if (((d->info|qual) & CTF_CONST)) { + err_const: + lj_err_caller(cts->L, LJ_ERR_FFI_WRCONST); + } + + lj_cconv_ct_tv(cts, d, dp, o, 0); +} + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_cdata.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_cdata.h new file mode 100644 index 000000000..3a1275e6c --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_cdata.h @@ -0,0 +1,75 @@ +/* +** C data management. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_CDATA_H +#define _LJ_CDATA_H + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_ctype.h" + +#if LJ_HASFFI + +/* Get C data pointer. */ +static LJ_AINLINE void *cdata_getptr(void *p, CTSize sz) +{ + if (LJ_64 && sz == 4) { /* Support 32 bit pointers on 64 bit targets. */ + return ((void *)(uintptr_t)*(uint32_t *)p); + } else { + lua_assert(sz == CTSIZE_PTR); + return *(void **)p; + } +} + +/* Set C data pointer. */ +static LJ_AINLINE void cdata_setptr(void *p, CTSize sz, const void *v) +{ + if (LJ_64 && sz == 4) { /* Support 32 bit pointers on 64 bit targets. */ + *(uint32_t *)p = (uint32_t)(uintptr_t)v; + } else { + lua_assert(sz == CTSIZE_PTR); + *(void **)p = (void *)v; + } +} + +/* Allocate fixed-size C data object. */ +static LJ_AINLINE GCcdata *lj_cdata_new(CTState *cts, CTypeID id, CTSize sz) +{ + GCcdata *cd; +#ifdef LUA_USE_ASSERT + CType *ct = ctype_raw(cts, id); + lua_assert((ctype_hassize(ct->info) ? ct->size : CTSIZE_PTR) == sz); +#endif + cd = (GCcdata *)lj_mem_newgco(cts->L, sizeof(GCcdata) + sz); + cd->gct = ~LJ_TCDATA; + cd->ctypeid = ctype_check(cts, id); + return cd; +} + +/* Variant which works without a valid CTState. */ +static LJ_AINLINE GCcdata *lj_cdata_new_(lua_State *L, CTypeID id, CTSize sz) +{ + GCcdata *cd = (GCcdata *)lj_mem_newgco(L, sizeof(GCcdata) + sz); + cd->gct = ~LJ_TCDATA; + cd->ctypeid = id; + return cd; +} + +LJ_FUNC GCcdata *lj_cdata_newref(CTState *cts, const void *pp, CTypeID id); +LJ_FUNC GCcdata *lj_cdata_newv(CTState *cts, CTypeID id, CTSize sz, + CTSize align); + +LJ_FUNC void LJ_FASTCALL lj_cdata_free(global_State *g, GCcdata *cd); +LJ_FUNCA TValue * LJ_FASTCALL lj_cdata_setfin(lua_State *L, GCcdata *cd); + +LJ_FUNC CType *lj_cdata_index(CTState *cts, GCcdata *cd, cTValue *key, + uint8_t **pp, CTInfo *qual); +LJ_FUNC int lj_cdata_get(CTState *cts, CType *s, TValue *o, uint8_t *sp); +LJ_FUNC void lj_cdata_set(CTState *cts, CType *d, uint8_t *dp, TValue *o, + CTInfo qual); + +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_char.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_char.c similarity index 100% rename from source/libs/luajit/LuaJIT-2.0.3/src/lj_char.c rename to source/libs/luajit/LuaJIT-2.0.4/src/lj_char.c diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lj_char.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_char.h similarity index 100% rename from source/libs/luajit/LuaJIT-2.0.3/src/lj_char.h rename to source/libs/luajit/LuaJIT-2.0.4/src/lj_char.h diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_clib.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_clib.c new file mode 100644 index 000000000..d35260909 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_clib.c @@ -0,0 +1,409 @@ +/* +** FFI C library loader. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "lj_obj.h" + +#if LJ_HASFFI + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_tab.h" +#include "lj_str.h" +#include "lj_udata.h" +#include "lj_ctype.h" +#include "lj_cconv.h" +#include "lj_cdata.h" +#include "lj_clib.h" + +/* -- OS-specific functions ----------------------------------------------- */ + +#if LJ_TARGET_DLOPEN + +#include +#include + +#if defined(RTLD_DEFAULT) +#define CLIB_DEFHANDLE RTLD_DEFAULT +#elif LJ_TARGET_OSX || LJ_TARGET_BSD +#define CLIB_DEFHANDLE ((void *)(intptr_t)-2) +#else +#define CLIB_DEFHANDLE NULL +#endif + +LJ_NORET LJ_NOINLINE static void clib_error_(lua_State *L) +{ + lj_err_callermsg(L, dlerror()); +} + +#define clib_error(L, fmt, name) clib_error_(L) + +#if defined(__CYGWIN__) +#define CLIB_SOPREFIX "cyg" +#else +#define CLIB_SOPREFIX "lib" +#endif + +#if LJ_TARGET_OSX +#define CLIB_SOEXT "%s.dylib" +#elif defined(__CYGWIN__) +#define CLIB_SOEXT "%s.dll" +#else +#define CLIB_SOEXT "%s.so" +#endif + +static const char *clib_extname(lua_State *L, const char *name) +{ + if (!strchr(name, '/') +#ifdef __CYGWIN__ + && !strchr(name, '\\') +#endif + ) { + if (!strchr(name, '.')) { + name = lj_str_pushf(L, CLIB_SOEXT, name); + L->top--; +#ifdef __CYGWIN__ + } else { + return name; +#endif + } + if (!(name[0] == CLIB_SOPREFIX[0] && name[1] == CLIB_SOPREFIX[1] && + name[2] == CLIB_SOPREFIX[2])) { + name = lj_str_pushf(L, CLIB_SOPREFIX "%s", name); + L->top--; + } + } + return name; +} + +/* Check for a recognized ld script line. */ +static const char *clib_check_lds(lua_State *L, const char *buf) +{ + char *p, *e; + if ((!strncmp(buf, "GROUP", 5) || !strncmp(buf, "INPUT", 5)) && + (p = strchr(buf, '('))) { + while (*++p == ' ') ; + for (e = p; *e && *e != ' ' && *e != ')'; e++) ; + return strdata(lj_str_new(L, p, e-p)); + } + return NULL; +} + +/* Quick and dirty solution to resolve shared library name from ld script. */ +static const char *clib_resolve_lds(lua_State *L, const char *name) +{ + FILE *fp = fopen(name, "r"); + const char *p = NULL; + if (fp) { + char buf[256]; + if (fgets(buf, sizeof(buf), fp)) { + if (!strncmp(buf, "/* GNU ld script", 16)) { /* ld script magic? */ + while (fgets(buf, sizeof(buf), fp)) { /* Check all lines. */ + p = clib_check_lds(L, buf); + if (p) break; + } + } else { /* Otherwise check only the first line. */ + p = clib_check_lds(L, buf); + } + } + fclose(fp); + } + return p; +} + +static void *clib_loadlib(lua_State *L, const char *name, int global) +{ + void *h = dlopen(clib_extname(L, name), + RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL)); + if (!h) { + const char *e, *err = dlerror(); + if (*err == '/' && (e = strchr(err, ':')) && + (name = clib_resolve_lds(L, strdata(lj_str_new(L, err, e-err))))) { + h = dlopen(name, RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL)); + if (h) return h; + err = dlerror(); + } + lj_err_callermsg(L, err); + } + return h; +} + +static void clib_unloadlib(CLibrary *cl) +{ + if (cl->handle && cl->handle != CLIB_DEFHANDLE) + dlclose(cl->handle); +} + +static void *clib_getsym(CLibrary *cl, const char *name) +{ + void *p = dlsym(cl->handle, name); + return p; +} + +#elif LJ_TARGET_WINDOWS + +#define WIN32_LEAN_AND_MEAN +#include + +#ifndef GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS +#define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 4 +#define GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT 2 +BOOL WINAPI GetModuleHandleExA(DWORD, LPCSTR, HMODULE*); +#endif + +#define CLIB_DEFHANDLE ((void *)-1) + +/* Default libraries. */ +enum { + CLIB_HANDLE_EXE, + CLIB_HANDLE_DLL, + CLIB_HANDLE_CRT, + CLIB_HANDLE_KERNEL32, + CLIB_HANDLE_USER32, + CLIB_HANDLE_GDI32, + CLIB_HANDLE_MAX +}; + +static void *clib_def_handle[CLIB_HANDLE_MAX]; + +LJ_NORET LJ_NOINLINE static void clib_error(lua_State *L, const char *fmt, + const char *name) +{ + DWORD err = GetLastError(); + char buf[128]; + if (!FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_SYSTEM, + NULL, err, 0, buf, sizeof(buf), NULL)) + buf[0] = '\0'; + lj_err_callermsg(L, lj_str_pushf(L, fmt, name, buf)); +} + +static int clib_needext(const char *s) +{ + while (*s) { + if (*s == '/' || *s == '\\' || *s == '.') return 0; + s++; + } + return 1; +} + +static const char *clib_extname(lua_State *L, const char *name) +{ + if (clib_needext(name)) { + name = lj_str_pushf(L, "%s.dll", name); + L->top--; + } + return name; +} + +static void *clib_loadlib(lua_State *L, const char *name, int global) +{ + DWORD oldwerr = GetLastError(); + void *h = (void *)LoadLibraryA(clib_extname(L, name)); + if (!h) clib_error(L, "cannot load module " LUA_QS ": %s", name); + SetLastError(oldwerr); + UNUSED(global); + return h; +} + +static void clib_unloadlib(CLibrary *cl) +{ + if (cl->handle == CLIB_DEFHANDLE) { + MSize i; + for (i = CLIB_HANDLE_KERNEL32; i < CLIB_HANDLE_MAX; i++) { + void *h = clib_def_handle[i]; + if (h) { + clib_def_handle[i] = NULL; + FreeLibrary((HINSTANCE)h); + } + } + } else if (cl->handle) { + FreeLibrary((HINSTANCE)cl->handle); + } +} + +static void *clib_getsym(CLibrary *cl, const char *name) +{ + void *p = NULL; + if (cl->handle == CLIB_DEFHANDLE) { /* Search default libraries. */ + MSize i; + for (i = 0; i < CLIB_HANDLE_MAX; i++) { + HINSTANCE h = (HINSTANCE)clib_def_handle[i]; + if (!(void *)h) { /* Resolve default library handles (once). */ + switch (i) { + case CLIB_HANDLE_EXE: GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, &h); break; + case CLIB_HANDLE_DLL: + GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + (const char *)clib_def_handle, &h); + break; + case CLIB_HANDLE_CRT: + GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + (const char *)&_fmode, &h); + break; + case CLIB_HANDLE_KERNEL32: h = LoadLibraryA("kernel32.dll"); break; + case CLIB_HANDLE_USER32: h = LoadLibraryA("user32.dll"); break; + case CLIB_HANDLE_GDI32: h = LoadLibraryA("gdi32.dll"); break; + } + if (!h) continue; + clib_def_handle[i] = (void *)h; + } + p = (void *)GetProcAddress(h, name); + if (p) break; + } + } else { + p = (void *)GetProcAddress((HINSTANCE)cl->handle, name); + } + return p; +} + +#else + +#define CLIB_DEFHANDLE NULL + +LJ_NORET LJ_NOINLINE static void clib_error(lua_State *L, const char *fmt, + const char *name) +{ + lj_err_callermsg(L, lj_str_pushf(L, fmt, name, "no support for this OS")); +} + +static void *clib_loadlib(lua_State *L, const char *name, int global) +{ + lj_err_callermsg(L, "no support for loading dynamic libraries for this OS"); + UNUSED(name); UNUSED(global); + return NULL; +} + +static void clib_unloadlib(CLibrary *cl) +{ + UNUSED(cl); +} + +static void *clib_getsym(CLibrary *cl, const char *name) +{ + UNUSED(cl); UNUSED(name); + return NULL; +} + +#endif + +/* -- C library indexing -------------------------------------------------- */ + +#if LJ_TARGET_X86 && LJ_ABI_WIN +/* Compute argument size for fastcall/stdcall functions. */ +static CTSize clib_func_argsize(CTState *cts, CType *ct) +{ + CTSize n = 0; + while (ct->sib) { + CType *d; + ct = ctype_get(cts, ct->sib); + if (ctype_isfield(ct->info)) { + d = ctype_rawchild(cts, ct); + n += ((d->size + 3) & ~3); + } + } + return n; +} +#endif + +/* Get redirected or mangled external symbol. */ +static const char *clib_extsym(CTState *cts, CType *ct, GCstr *name) +{ + if (ct->sib) { + CType *ctf = ctype_get(cts, ct->sib); + if (ctype_isxattrib(ctf->info, CTA_REDIR)) + return strdata(gco2str(gcref(ctf->name))); + } + return strdata(name); +} + +/* Index a C library by name. */ +TValue *lj_clib_index(lua_State *L, CLibrary *cl, GCstr *name) +{ + TValue *tv = lj_tab_setstr(L, cl->cache, name); + if (LJ_UNLIKELY(tvisnil(tv))) { + CTState *cts = ctype_cts(L); + CType *ct; + CTypeID id = lj_ctype_getname(cts, &ct, name, CLNS_INDEX); + if (!id) + lj_err_callerv(L, LJ_ERR_FFI_NODECL, strdata(name)); + if (ctype_isconstval(ct->info)) { + CType *ctt = ctype_child(cts, ct); + lua_assert(ctype_isinteger(ctt->info) && ctt->size <= 4); + if ((ctt->info & CTF_UNSIGNED) && (int32_t)ct->size < 0) + setnumV(tv, (lua_Number)(uint32_t)ct->size); + else + setintV(tv, (int32_t)ct->size); + } else { + const char *sym = clib_extsym(cts, ct, name); +#if LJ_TARGET_WINDOWS + DWORD oldwerr = GetLastError(); +#endif + void *p = clib_getsym(cl, sym); + GCcdata *cd; + lua_assert(ctype_isfunc(ct->info) || ctype_isextern(ct->info)); +#if LJ_TARGET_X86 && LJ_ABI_WIN + /* Retry with decorated name for fastcall/stdcall functions. */ + if (!p && ctype_isfunc(ct->info)) { + CTInfo cconv = ctype_cconv(ct->info); + if (cconv == CTCC_FASTCALL || cconv == CTCC_STDCALL) { + CTSize sz = clib_func_argsize(cts, ct); + const char *symd = lj_str_pushf(L, + cconv == CTCC_FASTCALL ? "@%s@%d" : "_%s@%d", + sym, sz); + L->top--; + p = clib_getsym(cl, symd); + } + } +#endif + if (!p) + clib_error(L, "cannot resolve symbol " LUA_QS ": %s", sym); +#if LJ_TARGET_WINDOWS + SetLastError(oldwerr); +#endif + cd = lj_cdata_new(cts, id, CTSIZE_PTR); + *(void **)cdataptr(cd) = p; + setcdataV(L, tv, cd); + } + } + return tv; +} + +/* -- C library management ------------------------------------------------ */ + +/* Create a new CLibrary object and push it on the stack. */ +static CLibrary *clib_new(lua_State *L, GCtab *mt) +{ + GCtab *t = lj_tab_new(L, 0, 0); + GCudata *ud = lj_udata_new(L, sizeof(CLibrary), t); + CLibrary *cl = (CLibrary *)uddata(ud); + cl->cache = t; + ud->udtype = UDTYPE_FFI_CLIB; + /* NOBARRIER: The GCudata is new (marked white). */ + setgcref(ud->metatable, obj2gco(mt)); + setudataV(L, L->top++, ud); + return cl; +} + +/* Load a C library. */ +void lj_clib_load(lua_State *L, GCtab *mt, GCstr *name, int global) +{ + void *handle = clib_loadlib(L, strdata(name), global); + CLibrary *cl = clib_new(L, mt); + cl->handle = handle; +} + +/* Unload a C library. */ +void lj_clib_unload(CLibrary *cl) +{ + clib_unloadlib(cl); + cl->handle = NULL; +} + +/* Create the default C library object. */ +void lj_clib_default(lua_State *L, GCtab *mt) +{ + CLibrary *cl = clib_new(L, mt); + cl->handle = CLIB_DEFHANDLE; +} + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_clib.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_clib.h new file mode 100644 index 000000000..e5dc98e1c --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_clib.h @@ -0,0 +1,29 @@ +/* +** FFI C library loader. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_CLIB_H +#define _LJ_CLIB_H + +#include "lj_obj.h" + +#if LJ_HASFFI + +/* Namespace for C library indexing. */ +#define CLNS_INDEX ((1u<env. */ +} CLibrary; + +LJ_FUNC TValue *lj_clib_index(lua_State *L, CLibrary *cl, GCstr *name); +LJ_FUNC void lj_clib_load(lua_State *L, GCtab *mt, GCstr *name, int global); +LJ_FUNC void lj_clib_unload(CLibrary *cl); +LJ_FUNC void lj_clib_default(lua_State *L, GCtab *mt); + +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_cparse.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_cparse.c new file mode 100644 index 000000000..b9df88d77 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_cparse.c @@ -0,0 +1,1872 @@ +/* +** C declaration parser. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "lj_obj.h" + +#if LJ_HASFFI + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_ctype.h" +#include "lj_cparse.h" +#include "lj_frame.h" +#include "lj_vm.h" +#include "lj_char.h" +#include "lj_strscan.h" + +/* +** Important note: this is NOT a validating C parser! This is a minimal +** C declaration parser, solely for use by the LuaJIT FFI. +** +** It ought to return correct results for properly formed C declarations, +** but it may accept some invalid declarations, too (and return nonsense). +** Also, it shows rather generic error messages to avoid unnecessary bloat. +** If in doubt, please check the input against your favorite C compiler. +*/ + +/* -- C lexer ------------------------------------------------------------- */ + +/* C lexer token names. */ +static const char *const ctoknames[] = { +#define CTOKSTR(name, str) str, +CTOKDEF(CTOKSTR) +#undef CTOKSTR + NULL +}; + +/* Forward declaration. */ +LJ_NORET static void cp_err(CPState *cp, ErrMsg em); + +static const char *cp_tok2str(CPState *cp, CPToken tok) +{ + lua_assert(tok < CTOK_FIRSTDECL); + if (tok > CTOK_OFS) + return ctoknames[tok-CTOK_OFS-1]; + else if (!lj_char_iscntrl(tok)) + return lj_str_pushf(cp->L, "%c", tok); + else + return lj_str_pushf(cp->L, "char(%d)", tok); +} + +/* End-of-line? */ +static LJ_AINLINE int cp_iseol(CPChar c) +{ + return (c == '\n' || c == '\r'); +} + +/* Peek next raw character. */ +static LJ_AINLINE CPChar cp_rawpeek(CPState *cp) +{ + return (CPChar)(uint8_t)(*cp->p); +} + +static LJ_NOINLINE CPChar cp_get_bs(CPState *cp); + +/* Get next character. */ +static LJ_AINLINE CPChar cp_get(CPState *cp) +{ + cp->c = (CPChar)(uint8_t)(*cp->p++); + if (LJ_LIKELY(cp->c != '\\')) return cp->c; + return cp_get_bs(cp); +} + +/* Transparently skip backslash-escaped line breaks. */ +static LJ_NOINLINE CPChar cp_get_bs(CPState *cp) +{ + CPChar c2, c = cp_rawpeek(cp); + if (!cp_iseol(c)) return cp->c; + cp->p++; + c2 = cp_rawpeek(cp); + if (cp_iseol(c2) && c2 != c) cp->p++; + cp->linenumber++; + return cp_get(cp); +} + +/* Grow save buffer. */ +static LJ_NOINLINE void cp_save_grow(CPState *cp, CPChar c) +{ + MSize newsize; + if (cp->sb.sz >= CPARSE_MAX_BUF/2) + cp_err(cp, LJ_ERR_XELEM); + newsize = cp->sb.sz * 2; + lj_str_resizebuf(cp->L, &cp->sb, newsize); + cp->sb.buf[cp->sb.n++] = (char)c; +} + +/* Save character in buffer. */ +static LJ_AINLINE void cp_save(CPState *cp, CPChar c) +{ + if (LJ_UNLIKELY(cp->sb.n + 1 > cp->sb.sz)) + cp_save_grow(cp, c); + else + cp->sb.buf[cp->sb.n++] = (char)c; +} + +/* Skip line break. Handles "\n", "\r", "\r\n" or "\n\r". */ +static void cp_newline(CPState *cp) +{ + CPChar c = cp_rawpeek(cp); + if (cp_iseol(c) && c != cp->c) cp->p++; + cp->linenumber++; +} + +LJ_NORET static void cp_errmsg(CPState *cp, CPToken tok, ErrMsg em, ...) +{ + const char *msg, *tokstr; + lua_State *L; + va_list argp; + if (tok == 0) { + tokstr = NULL; + } else if (tok == CTOK_IDENT || tok == CTOK_INTEGER || tok == CTOK_STRING || + tok >= CTOK_FIRSTDECL) { + if (cp->sb.n == 0) cp_save(cp, '$'); + cp_save(cp, '\0'); + tokstr = cp->sb.buf; + } else { + tokstr = cp_tok2str(cp, tok); + } + L = cp->L; + va_start(argp, em); + msg = lj_str_pushvf(L, err2msg(em), argp); + va_end(argp); + if (tokstr) + msg = lj_str_pushf(L, err2msg(LJ_ERR_XNEAR), msg, tokstr); + if (cp->linenumber > 1) + msg = lj_str_pushf(L, "%s at line %d", msg, cp->linenumber); + lj_err_callermsg(L, msg); +} + +LJ_NORET LJ_NOINLINE static void cp_err_token(CPState *cp, CPToken tok) +{ + cp_errmsg(cp, cp->tok, LJ_ERR_XTOKEN, cp_tok2str(cp, tok)); +} + +LJ_NORET LJ_NOINLINE static void cp_err_badidx(CPState *cp, CType *ct) +{ + GCstr *s = lj_ctype_repr(cp->cts->L, ctype_typeid(cp->cts, ct), NULL); + cp_errmsg(cp, 0, LJ_ERR_FFI_BADIDX, strdata(s)); +} + +LJ_NORET LJ_NOINLINE static void cp_err(CPState *cp, ErrMsg em) +{ + cp_errmsg(cp, 0, em); +} + +/* -- Main lexical scanner ------------------------------------------------ */ + +/* Parse number literal. Only handles int32_t/uint32_t right now. */ +static CPToken cp_number(CPState *cp) +{ + StrScanFmt fmt; + TValue o; + do { cp_save(cp, cp->c); } while (lj_char_isident(cp_get(cp))); + cp_save(cp, '\0'); + fmt = lj_strscan_scan((const uint8_t *)cp->sb.buf, &o, STRSCAN_OPT_C); + if (fmt == STRSCAN_INT) cp->val.id = CTID_INT32; + else if (fmt == STRSCAN_U32) cp->val.id = CTID_UINT32; + else if (!(cp->mode & CPARSE_MODE_SKIP)) + cp_errmsg(cp, CTOK_INTEGER, LJ_ERR_XNUMBER); + cp->val.u32 = (uint32_t)o.i; + return CTOK_INTEGER; +} + +/* Parse identifier or keyword. */ +static CPToken cp_ident(CPState *cp) +{ + do { cp_save(cp, cp->c); } while (lj_char_isident(cp_get(cp))); + cp->str = lj_str_new(cp->L, cp->sb.buf, cp->sb.n); + cp->val.id = lj_ctype_getname(cp->cts, &cp->ct, cp->str, cp->tmask); + if (ctype_type(cp->ct->info) == CT_KW) + return ctype_cid(cp->ct->info); + return CTOK_IDENT; +} + +/* Parse parameter. */ +static CPToken cp_param(CPState *cp) +{ + CPChar c = cp_get(cp); + TValue *o = cp->param; + if (lj_char_isident(c) || c == '$') /* Reserve $xyz for future extensions. */ + cp_errmsg(cp, c, LJ_ERR_XSYNTAX); + if (!o || o >= cp->L->top) + cp_err(cp, LJ_ERR_FFI_NUMPARAM); + cp->param = o+1; + if (tvisstr(o)) { + cp->str = strV(o); + cp->val.id = 0; + cp->ct = &cp->cts->tab[0]; + return CTOK_IDENT; + } else if (tvisnumber(o)) { + cp->val.i32 = numberVint(o); + cp->val.id = CTID_INT32; + return CTOK_INTEGER; + } else { + GCcdata *cd; + if (!tviscdata(o)) + lj_err_argtype(cp->L, (int)(o-cp->L->base)+1, "type parameter"); + cd = cdataV(o); + if (cd->ctypeid == CTID_CTYPEID) + cp->val.id = *(CTypeID *)cdataptr(cd); + else + cp->val.id = cd->ctypeid; + return '$'; + } +} + +/* Parse string or character constant. */ +static CPToken cp_string(CPState *cp) +{ + CPChar delim = cp->c; + cp_get(cp); + while (cp->c != delim) { + CPChar c = cp->c; + if (c == '\0') cp_errmsg(cp, CTOK_EOF, LJ_ERR_XSTR); + if (c == '\\') { + c = cp_get(cp); + switch (c) { + case '\0': cp_errmsg(cp, CTOK_EOF, LJ_ERR_XSTR); break; + case 'a': c = '\a'; break; + case 'b': c = '\b'; break; + case 'f': c = '\f'; break; + case 'n': c = '\n'; break; + case 'r': c = '\r'; break; + case 't': c = '\t'; break; + case 'v': c = '\v'; break; + case 'e': c = 27; break; + case 'x': + c = 0; + while (lj_char_isxdigit(cp_get(cp))) + c = (c<<4) + (lj_char_isdigit(cp->c) ? cp->c-'0' : (cp->c&15)+9); + cp_save(cp, (c & 0xff)); + continue; + default: + if (lj_char_isdigit(c)) { + c -= '0'; + if (lj_char_isdigit(cp_get(cp))) { + c = c*8 + (cp->c - '0'); + if (lj_char_isdigit(cp_get(cp))) { + c = c*8 + (cp->c - '0'); + cp_get(cp); + } + } + cp_save(cp, (c & 0xff)); + continue; + } + break; + } + } + cp_save(cp, c); + cp_get(cp); + } + cp_get(cp); + if (delim == '"') { + cp->str = lj_str_new(cp->L, cp->sb.buf, cp->sb.n); + return CTOK_STRING; + } else { + if (cp->sb.n != 1) cp_err_token(cp, '\''); + cp->val.i32 = (int32_t)(char)cp->sb.buf[0]; + cp->val.id = CTID_INT32; + return CTOK_INTEGER; + } +} + +/* Skip C comment. */ +static void cp_comment_c(CPState *cp) +{ + do { + if (cp_get(cp) == '*') { + do { + if (cp_get(cp) == '/') { cp_get(cp); return; } + } while (cp->c == '*'); + } + if (cp_iseol(cp->c)) cp_newline(cp); + } while (cp->c != '\0'); +} + +/* Skip C++ comment. */ +static void cp_comment_cpp(CPState *cp) +{ + while (!cp_iseol(cp_get(cp)) && cp->c != '\0') + ; +} + +/* Lexical scanner for C. Only a minimal subset is implemented. */ +static CPToken cp_next_(CPState *cp) +{ + lj_str_resetbuf(&cp->sb); + for (;;) { + if (lj_char_isident(cp->c)) + return lj_char_isdigit(cp->c) ? cp_number(cp) : cp_ident(cp); + switch (cp->c) { + case '\n': case '\r': cp_newline(cp); /* fallthrough. */ + case ' ': case '\t': case '\v': case '\f': cp_get(cp); break; + case '"': case '\'': return cp_string(cp); + case '/': + if (cp_get(cp) == '*') cp_comment_c(cp); + else if (cp->c == '/') cp_comment_cpp(cp); + else return '/'; + break; + case '|': + if (cp_get(cp) != '|') return '|'; cp_get(cp); return CTOK_OROR; + case '&': + if (cp_get(cp) != '&') return '&'; cp_get(cp); return CTOK_ANDAND; + case '=': + if (cp_get(cp) != '=') return '='; cp_get(cp); return CTOK_EQ; + case '!': + if (cp_get(cp) != '=') return '!'; cp_get(cp); return CTOK_NE; + case '<': + if (cp_get(cp) == '=') { cp_get(cp); return CTOK_LE; } + else if (cp->c == '<') { cp_get(cp); return CTOK_SHL; } + return '<'; + case '>': + if (cp_get(cp) == '=') { cp_get(cp); return CTOK_GE; } + else if (cp->c == '>') { cp_get(cp); return CTOK_SHR; } + return '>'; + case '-': + if (cp_get(cp) != '>') return '-'; cp_get(cp); return CTOK_DEREF; + case '$': + return cp_param(cp); + case '\0': return CTOK_EOF; + default: { CPToken c = cp->c; cp_get(cp); return c; } + } + } +} + +static LJ_NOINLINE CPToken cp_next(CPState *cp) +{ + return (cp->tok = cp_next_(cp)); +} + +/* -- C parser ------------------------------------------------------------ */ + +/* Namespaces for resolving identifiers. */ +#define CPNS_DEFAULT \ + ((1u<linenumber = 1; + cp->depth = 0; + cp->curpack = 0; + cp->packstack[0] = 255; + lj_str_initbuf(&cp->sb); + lj_str_resizebuf(cp->L, &cp->sb, LJ_MIN_SBUF); + lua_assert(cp->p != NULL); + cp_get(cp); /* Read-ahead first char. */ + cp->tok = 0; + cp->tmask = CPNS_DEFAULT; + cp_next(cp); /* Read-ahead first token. */ +} + +/* Cleanup C parser state. */ +static void cp_cleanup(CPState *cp) +{ + global_State *g = G(cp->L); + lj_str_freebuf(g, &cp->sb); +} + +/* Check and consume optional token. */ +static int cp_opt(CPState *cp, CPToken tok) +{ + if (cp->tok == tok) { cp_next(cp); return 1; } + return 0; +} + +/* Check and consume token. */ +static void cp_check(CPState *cp, CPToken tok) +{ + if (cp->tok != tok) cp_err_token(cp, tok); + cp_next(cp); +} + +/* Check if the next token may start a type declaration. */ +static int cp_istypedecl(CPState *cp) +{ + if (cp->tok >= CTOK_FIRSTDECL && cp->tok <= CTOK_LASTDECL) return 1; + if (cp->tok == CTOK_IDENT && ctype_istypedef(cp->ct->info)) return 1; + if (cp->tok == '$') return 1; + return 0; +} + +/* -- Constant expression evaluator --------------------------------------- */ + +/* Forward declarations. */ +static void cp_expr_unary(CPState *cp, CPValue *k); +static void cp_expr_sub(CPState *cp, CPValue *k, int pri); + +/* Please note that type handling is very weak here. Most ops simply +** assume integer operands. Accessors are only needed to compute types and +** return synthetic values. The only purpose of the expression evaluator +** is to compute the values of constant expressions one would typically +** find in C header files. And again: this is NOT a validating C parser! +*/ + +/* Parse comma separated expression and return last result. */ +static void cp_expr_comma(CPState *cp, CPValue *k) +{ + do { cp_expr_sub(cp, k, 0); } while (cp_opt(cp, ',')); +} + +/* Parse sizeof/alignof operator. */ +static void cp_expr_sizeof(CPState *cp, CPValue *k, int wantsz) +{ + CTSize sz; + CTInfo info; + if (cp_opt(cp, '(')) { + if (cp_istypedecl(cp)) + k->id = cp_decl_abstract(cp); + else + cp_expr_comma(cp, k); + cp_check(cp, ')'); + } else { + cp_expr_unary(cp, k); + } + info = lj_ctype_info(cp->cts, k->id, &sz); + if (wantsz) { + if (sz != CTSIZE_INVALID) + k->u32 = sz; + else if (k->id != CTID_A_CCHAR) /* Special case for sizeof("string"). */ + cp_err(cp, LJ_ERR_FFI_INVSIZE); + } else { + k->u32 = 1u << ctype_align(info); + } + k->id = CTID_UINT32; /* Really size_t. */ +} + +/* Parse prefix operators. */ +static void cp_expr_prefix(CPState *cp, CPValue *k) +{ + if (cp->tok == CTOK_INTEGER) { + *k = cp->val; cp_next(cp); + } else if (cp_opt(cp, '+')) { + cp_expr_unary(cp, k); /* Nothing to do (well, integer promotion). */ + } else if (cp_opt(cp, '-')) { + cp_expr_unary(cp, k); k->i32 = -k->i32; + } else if (cp_opt(cp, '~')) { + cp_expr_unary(cp, k); k->i32 = ~k->i32; + } else if (cp_opt(cp, '!')) { + cp_expr_unary(cp, k); k->i32 = !k->i32; k->id = CTID_INT32; + } else if (cp_opt(cp, '(')) { + if (cp_istypedecl(cp)) { /* Cast operator. */ + CTypeID id = cp_decl_abstract(cp); + cp_check(cp, ')'); + cp_expr_unary(cp, k); + k->id = id; /* No conversion performed. */ + } else { /* Sub-expression. */ + cp_expr_comma(cp, k); + cp_check(cp, ')'); + } + } else if (cp_opt(cp, '*')) { /* Indirection. */ + CType *ct; + cp_expr_unary(cp, k); + ct = lj_ctype_rawref(cp->cts, k->id); + if (!ctype_ispointer(ct->info)) + cp_err_badidx(cp, ct); + k->u32 = 0; k->id = ctype_cid(ct->info); + } else if (cp_opt(cp, '&')) { /* Address operator. */ + cp_expr_unary(cp, k); + k->id = lj_ctype_intern(cp->cts, CTINFO(CT_PTR, CTALIGN_PTR+k->id), + CTSIZE_PTR); + } else if (cp_opt(cp, CTOK_SIZEOF)) { + cp_expr_sizeof(cp, k, 1); + } else if (cp_opt(cp, CTOK_ALIGNOF)) { + cp_expr_sizeof(cp, k, 0); + } else if (cp->tok == CTOK_IDENT) { + if (ctype_type(cp->ct->info) == CT_CONSTVAL) { + k->u32 = cp->ct->size; k->id = ctype_cid(cp->ct->info); + } else if (ctype_type(cp->ct->info) == CT_EXTERN) { + k->u32 = cp->val.id; k->id = ctype_cid(cp->ct->info); + } else if (ctype_type(cp->ct->info) == CT_FUNC) { + k->u32 = cp->val.id; k->id = cp->val.id; + } else { + goto err_expr; + } + cp_next(cp); + } else if (cp->tok == CTOK_STRING) { + CTSize sz = cp->str->len; + while (cp_next(cp) == CTOK_STRING) + sz += cp->str->len; + k->u32 = sz + 1; + k->id = CTID_A_CCHAR; + } else { + err_expr: + cp_errmsg(cp, cp->tok, LJ_ERR_XSYMBOL); + } +} + +/* Parse postfix operators. */ +static void cp_expr_postfix(CPState *cp, CPValue *k) +{ + for (;;) { + CType *ct; + if (cp_opt(cp, '[')) { /* Array/pointer index. */ + CPValue k2; + cp_expr_comma(cp, &k2); + ct = lj_ctype_rawref(cp->cts, k->id); + if (!ctype_ispointer(ct->info)) { + ct = lj_ctype_rawref(cp->cts, k2.id); + if (!ctype_ispointer(ct->info)) + cp_err_badidx(cp, ct); + } + cp_check(cp, ']'); + k->u32 = 0; + } else if (cp->tok == '.' || cp->tok == CTOK_DEREF) { /* Struct deref. */ + CTSize ofs; + CType *fct; + ct = lj_ctype_rawref(cp->cts, k->id); + if (cp->tok == CTOK_DEREF) { + if (!ctype_ispointer(ct->info)) + cp_err_badidx(cp, ct); + ct = lj_ctype_rawref(cp->cts, ctype_cid(ct->info)); + } + cp_next(cp); + if (cp->tok != CTOK_IDENT) cp_err_token(cp, CTOK_IDENT); + if (!ctype_isstruct(ct->info) || ct->size == CTSIZE_INVALID || + !(fct = lj_ctype_getfield(cp->cts, ct, cp->str, &ofs)) || + ctype_isbitfield(fct->info)) { + GCstr *s = lj_ctype_repr(cp->cts->L, ctype_typeid(cp->cts, ct), NULL); + cp_errmsg(cp, 0, LJ_ERR_FFI_BADMEMBER, strdata(s), strdata(cp->str)); + } + ct = fct; + k->u32 = ctype_isconstval(ct->info) ? ct->size : 0; + cp_next(cp); + } else { + return; + } + k->id = ctype_cid(ct->info); + } +} + +/* Parse infix operators. */ +static void cp_expr_infix(CPState *cp, CPValue *k, int pri) +{ + CPValue k2; + k2.u32 = 0; k2.id = 0; /* Silence the compiler. */ + for (;;) { + switch (pri) { + case 0: + if (cp_opt(cp, '?')) { + CPValue k3; + cp_expr_comma(cp, &k2); /* Right-associative. */ + cp_check(cp, ':'); + cp_expr_sub(cp, &k3, 0); + k->u32 = k->u32 ? k2.u32 : k3.u32; + k->id = k2.id > k3.id ? k2.id : k3.id; + continue; + } + case 1: + if (cp_opt(cp, CTOK_OROR)) { + cp_expr_sub(cp, &k2, 2); k->i32 = k->u32 || k2.u32; k->id = CTID_INT32; + continue; + } + case 2: + if (cp_opt(cp, CTOK_ANDAND)) { + cp_expr_sub(cp, &k2, 3); k->i32 = k->u32 && k2.u32; k->id = CTID_INT32; + continue; + } + case 3: + if (cp_opt(cp, '|')) { + cp_expr_sub(cp, &k2, 4); k->u32 = k->u32 | k2.u32; goto arith_result; + } + case 4: + if (cp_opt(cp, '^')) { + cp_expr_sub(cp, &k2, 5); k->u32 = k->u32 ^ k2.u32; goto arith_result; + } + case 5: + if (cp_opt(cp, '&')) { + cp_expr_sub(cp, &k2, 6); k->u32 = k->u32 & k2.u32; goto arith_result; + } + case 6: + if (cp_opt(cp, CTOK_EQ)) { + cp_expr_sub(cp, &k2, 7); k->i32 = k->u32 == k2.u32; k->id = CTID_INT32; + continue; + } else if (cp_opt(cp, CTOK_NE)) { + cp_expr_sub(cp, &k2, 7); k->i32 = k->u32 != k2.u32; k->id = CTID_INT32; + continue; + } + case 7: + if (cp_opt(cp, '<')) { + cp_expr_sub(cp, &k2, 8); + if (k->id == CTID_INT32 && k2.id == CTID_INT32) + k->i32 = k->i32 < k2.i32; + else + k->i32 = k->u32 < k2.u32; + k->id = CTID_INT32; + continue; + } else if (cp_opt(cp, '>')) { + cp_expr_sub(cp, &k2, 8); + if (k->id == CTID_INT32 && k2.id == CTID_INT32) + k->i32 = k->i32 > k2.i32; + else + k->i32 = k->u32 > k2.u32; + k->id = CTID_INT32; + continue; + } else if (cp_opt(cp, CTOK_LE)) { + cp_expr_sub(cp, &k2, 8); + if (k->id == CTID_INT32 && k2.id == CTID_INT32) + k->i32 = k->i32 <= k2.i32; + else + k->i32 = k->u32 <= k2.u32; + k->id = CTID_INT32; + continue; + } else if (cp_opt(cp, CTOK_GE)) { + cp_expr_sub(cp, &k2, 8); + if (k->id == CTID_INT32 && k2.id == CTID_INT32) + k->i32 = k->i32 >= k2.i32; + else + k->i32 = k->u32 >= k2.u32; + k->id = CTID_INT32; + continue; + } + case 8: + if (cp_opt(cp, CTOK_SHL)) { + cp_expr_sub(cp, &k2, 9); k->u32 = k->u32 << k2.u32; + continue; + } else if (cp_opt(cp, CTOK_SHR)) { + cp_expr_sub(cp, &k2, 9); + if (k->id == CTID_INT32) + k->i32 = k->i32 >> k2.i32; + else + k->u32 = k->u32 >> k2.u32; + continue; + } + case 9: + if (cp_opt(cp, '+')) { + cp_expr_sub(cp, &k2, 10); k->u32 = k->u32 + k2.u32; + arith_result: + if (k2.id > k->id) k->id = k2.id; /* Trivial promotion to unsigned. */ + continue; + } else if (cp_opt(cp, '-')) { + cp_expr_sub(cp, &k2, 10); k->u32 = k->u32 - k2.u32; goto arith_result; + } + case 10: + if (cp_opt(cp, '*')) { + cp_expr_unary(cp, &k2); k->u32 = k->u32 * k2.u32; goto arith_result; + } else if (cp_opt(cp, '/')) { + cp_expr_unary(cp, &k2); + if (k2.id > k->id) k->id = k2.id; /* Trivial promotion to unsigned. */ + if (k2.u32 == 0 || + (k->id == CTID_INT32 && k->u32 == 0x80000000u && k2.i32 == -1)) + cp_err(cp, LJ_ERR_BADVAL); + if (k->id == CTID_INT32) + k->i32 = k->i32 / k2.i32; + else + k->u32 = k->u32 / k2.u32; + continue; + } else if (cp_opt(cp, '%')) { + cp_expr_unary(cp, &k2); + if (k2.id > k->id) k->id = k2.id; /* Trivial promotion to unsigned. */ + if (k2.u32 == 0 || + (k->id == CTID_INT32 && k->u32 == 0x80000000u && k2.i32 == -1)) + cp_err(cp, LJ_ERR_BADVAL); + if (k->id == CTID_INT32) + k->i32 = k->i32 % k2.i32; + else + k->u32 = k->u32 % k2.u32; + continue; + } + default: + return; + } + } +} + +/* Parse and evaluate unary expression. */ +static void cp_expr_unary(CPState *cp, CPValue *k) +{ + if (++cp->depth > CPARSE_MAX_DECLDEPTH) cp_err(cp, LJ_ERR_XLEVELS); + cp_expr_prefix(cp, k); + cp_expr_postfix(cp, k); + cp->depth--; +} + +/* Parse and evaluate sub-expression. */ +static void cp_expr_sub(CPState *cp, CPValue *k, int pri) +{ + cp_expr_unary(cp, k); + cp_expr_infix(cp, k, pri); +} + +/* Parse constant integer expression. */ +static void cp_expr_kint(CPState *cp, CPValue *k) +{ + CType *ct; + cp_expr_sub(cp, k, 0); + ct = ctype_raw(cp->cts, k->id); + if (!ctype_isinteger(ct->info)) cp_err(cp, LJ_ERR_BADVAL); +} + +/* Parse (non-negative) size expression. */ +static CTSize cp_expr_ksize(CPState *cp) +{ + CPValue k; + cp_expr_kint(cp, &k); + if (k.u32 >= 0x80000000u) cp_err(cp, LJ_ERR_FFI_INVSIZE); + return k.u32; +} + +/* -- Type declaration stack management ----------------------------------- */ + +/* Add declaration element behind the insertion position. */ +static CPDeclIdx cp_add(CPDecl *decl, CTInfo info, CTSize size) +{ + CPDeclIdx top = decl->top; + if (top >= CPARSE_MAX_DECLSTACK) cp_err(decl->cp, LJ_ERR_XLEVELS); + decl->stack[top].info = info; + decl->stack[top].size = size; + decl->stack[top].sib = 0; + setgcrefnull(decl->stack[top].name); + decl->stack[top].next = decl->stack[decl->pos].next; + decl->stack[decl->pos].next = (CTypeID1)top; + decl->top = top+1; + return top; +} + +/* Push declaration element before the insertion position. */ +static CPDeclIdx cp_push(CPDecl *decl, CTInfo info, CTSize size) +{ + return (decl->pos = cp_add(decl, info, size)); +} + +/* Push or merge attributes. */ +static void cp_push_attributes(CPDecl *decl) +{ + CType *ct = &decl->stack[decl->pos]; + if (ctype_isfunc(ct->info)) { /* Ok to modify in-place. */ +#if LJ_TARGET_X86 + if ((decl->fattr & CTFP_CCONV)) + ct->info = (ct->info & (CTMASK_NUM|CTF_VARARG|CTMASK_CID)) + + (decl->fattr & ~CTMASK_CID); +#endif + } else { + if ((decl->attr & CTFP_ALIGNED) && !(decl->mode & CPARSE_MODE_FIELD)) + cp_push(decl, CTINFO(CT_ATTRIB, CTATTRIB(CTA_ALIGN)), + ctype_align(decl->attr)); + } +} + +/* Push unrolled type to declaration stack and merge qualifiers. */ +static void cp_push_type(CPDecl *decl, CTypeID id) +{ + CType *ct = ctype_get(decl->cp->cts, id); + CTInfo info = ct->info; + CTSize size = ct->size; + switch (ctype_type(info)) { + case CT_STRUCT: case CT_ENUM: + cp_push(decl, CTINFO(CT_TYPEDEF, id), 0); /* Don't copy unique types. */ + if ((decl->attr & CTF_QUAL)) { /* Push unmerged qualifiers. */ + cp_push(decl, CTINFO(CT_ATTRIB, CTATTRIB(CTA_QUAL)), + (decl->attr & CTF_QUAL)); + decl->attr &= ~CTF_QUAL; + } + break; + case CT_ATTRIB: + if (ctype_isxattrib(info, CTA_QUAL)) + decl->attr &= ~size; /* Remove redundant qualifiers. */ + cp_push_type(decl, ctype_cid(info)); /* Unroll. */ + cp_push(decl, info & ~CTMASK_CID, size); /* Copy type. */ + break; + case CT_ARRAY: + cp_push_type(decl, ctype_cid(info)); /* Unroll. */ + cp_push(decl, info & ~CTMASK_CID, size); /* Copy type. */ + decl->stack[decl->pos].sib = 1; /* Mark as already checked and sized. */ + /* Note: this is not copied to the ct->sib in the C type table. */ + break; + case CT_FUNC: + /* Copy type, link parameters (shared). */ + decl->stack[cp_push(decl, info, size)].sib = ct->sib; + break; + default: + /* Copy type, merge common qualifiers. */ + cp_push(decl, info|(decl->attr & CTF_QUAL), size); + decl->attr &= ~CTF_QUAL; + break; + } +} + +/* Consume the declaration element chain and intern the C type. */ +static CTypeID cp_decl_intern(CPState *cp, CPDecl *decl) +{ + CTypeID id = 0; + CPDeclIdx idx = 0; + CTSize csize = CTSIZE_INVALID; + CTSize cinfo = 0; + do { + CType *ct = &decl->stack[idx]; + CTInfo info = ct->info; + CTInfo size = ct->size; + /* The cid is already part of info for copies of pointers/functions. */ + idx = ct->next; + if (ctype_istypedef(info)) { + lua_assert(id == 0); + id = ctype_cid(info); + /* Always refetch info/size, since struct/enum may have been completed. */ + cinfo = ctype_get(cp->cts, id)->info; + csize = ctype_get(cp->cts, id)->size; + lua_assert(ctype_isstruct(cinfo) || ctype_isenum(cinfo)); + } else if (ctype_isfunc(info)) { /* Intern function. */ + CType *fct; + CTypeID fid; + CTypeID sib; + if (id) { + CType *refct = ctype_raw(cp->cts, id); + /* Reject function or refarray return types. */ + if (ctype_isfunc(refct->info) || ctype_isrefarray(refct->info)) + cp_err(cp, LJ_ERR_FFI_INVTYPE); + } + /* No intervening attributes allowed, skip forward. */ + while (idx) { + CType *ctn = &decl->stack[idx]; + if (!ctype_isattrib(ctn->info)) break; + idx = ctn->next; /* Skip attribute. */ + } + sib = ct->sib; /* Next line may reallocate the C type table. */ + fid = lj_ctype_new(cp->cts, &fct); + csize = CTSIZE_INVALID; + fct->info = cinfo = info + id; + fct->size = size; + fct->sib = sib; + id = fid; + } else if (ctype_isattrib(info)) { + if (ctype_isxattrib(info, CTA_QUAL)) + cinfo |= size; + else if (ctype_isxattrib(info, CTA_ALIGN)) + CTF_INSERT(cinfo, ALIGN, size); + id = lj_ctype_intern(cp->cts, info+id, size); + /* Inherit csize/cinfo from original type. */ + } else { + if (ctype_isnum(info)) { /* Handle mode/vector-size attributes. */ + lua_assert(id == 0); + if (!(info & CTF_BOOL)) { + CTSize msize = ctype_msizeP(decl->attr); + CTSize vsize = ctype_vsizeP(decl->attr); + if (msize && (!(info & CTF_FP) || (msize == 4 || msize == 8))) { + CTSize malign = lj_fls(msize); + if (malign > 4) malign = 4; /* Limit alignment. */ + CTF_INSERT(info, ALIGN, malign); + size = msize; /* Override size via mode. */ + } + if (vsize) { /* Vector size set? */ + CTSize esize = lj_fls(size); + if (vsize >= esize) { + /* Intern the element type first. */ + id = lj_ctype_intern(cp->cts, info, size); + /* Then create a vector (array) with vsize alignment. */ + size = (1u << vsize); + if (vsize > 4) vsize = 4; /* Limit alignment. */ + if (ctype_align(info) > vsize) vsize = ctype_align(info); + info = CTINFO(CT_ARRAY, (info & CTF_QUAL) + CTF_VECTOR + + CTALIGN(vsize)); + } + } + } + } else if (ctype_isptr(info)) { + /* Reject pointer/ref to ref. */ + if (id && ctype_isref(ctype_raw(cp->cts, id)->info)) + cp_err(cp, LJ_ERR_FFI_INVTYPE); + if (ctype_isref(info)) { + info &= ~CTF_VOLATILE; /* Refs are always const, never volatile. */ + /* No intervening attributes allowed, skip forward. */ + while (idx) { + CType *ctn = &decl->stack[idx]; + if (!ctype_isattrib(ctn->info)) break; + idx = ctn->next; /* Skip attribute. */ + } + } + } else if (ctype_isarray(info)) { /* Check for valid array size etc. */ + if (ct->sib == 0) { /* Only check/size arrays not copied by unroll. */ + if (ctype_isref(cinfo)) /* Reject arrays of refs. */ + cp_err(cp, LJ_ERR_FFI_INVTYPE); + /* Reject VLS or unknown-sized types. */ + if (ctype_isvltype(cinfo) || csize == CTSIZE_INVALID) + cp_err(cp, LJ_ERR_FFI_INVSIZE); + /* a[] and a[?] keep their invalid size. */ + if (size != CTSIZE_INVALID) { + uint64_t xsz = (uint64_t)size * csize; + if (xsz >= 0x80000000u) cp_err(cp, LJ_ERR_FFI_INVSIZE); + size = (CTSize)xsz; + } + } + if ((cinfo & CTF_ALIGN) > (info & CTF_ALIGN)) /* Find max. align. */ + info = (info & ~CTF_ALIGN) | (cinfo & CTF_ALIGN); + info |= (cinfo & CTF_QUAL); /* Inherit qual. */ + } else { + lua_assert(ctype_isvoid(info)); + } + csize = size; + cinfo = info+id; + id = lj_ctype_intern(cp->cts, info+id, size); + } + } while (idx); + return id; +} + +/* -- C declaration parser ------------------------------------------------ */ + +#define H_(le, be) LJ_ENDIAN_SELECT(0x##le, 0x##be) + +/* Reset declaration state to declaration specifier. */ +static void cp_decl_reset(CPDecl *decl) +{ + decl->pos = decl->specpos; + decl->top = decl->specpos+1; + decl->stack[decl->specpos].next = 0; + decl->attr = decl->specattr; + decl->fattr = decl->specfattr; + decl->name = NULL; + decl->redir = NULL; +} + +/* Parse constant initializer. */ +/* NYI: FP constants and strings as initializers. */ +static CTypeID cp_decl_constinit(CPState *cp, CType **ctp, CTypeID ctypeid) +{ + CType *ctt = ctype_get(cp->cts, ctypeid); + CTInfo info; + CTSize size; + CPValue k; + CTypeID constid; + while (ctype_isattrib(ctt->info)) { /* Skip attributes. */ + ctypeid = ctype_cid(ctt->info); /* Update ID, too. */ + ctt = ctype_get(cp->cts, ctypeid); + } + info = ctt->info; + size = ctt->size; + if (!ctype_isinteger(info) || !(info & CTF_CONST) || size > 4) + cp_err(cp, LJ_ERR_FFI_INVTYPE); + cp_check(cp, '='); + cp_expr_sub(cp, &k, 0); + constid = lj_ctype_new(cp->cts, ctp); + (*ctp)->info = CTINFO(CT_CONSTVAL, CTF_CONST|ctypeid); + k.u32 <<= 8*(4-size); + if ((info & CTF_UNSIGNED)) + k.u32 >>= 8*(4-size); + else + k.u32 = (uint32_t)((int32_t)k.u32 >> 8*(4-size)); + (*ctp)->size = k.u32; + return constid; +} + +/* Parse size in parentheses as part of attribute. */ +static CTSize cp_decl_sizeattr(CPState *cp) +{ + CTSize sz; + uint32_t oldtmask = cp->tmask; + cp->tmask = CPNS_DEFAULT; /* Required for expression evaluator. */ + cp_check(cp, '('); + sz = cp_expr_ksize(cp); + cp->tmask = oldtmask; + cp_check(cp, ')'); + return sz; +} + +/* Parse alignment attribute. */ +static void cp_decl_align(CPState *cp, CPDecl *decl) +{ + CTSize al = 4; /* Unspecified alignment is 16 bytes. */ + if (cp->tok == '(') { + al = cp_decl_sizeattr(cp); + al = al ? lj_fls(al) : 0; + } + CTF_INSERT(decl->attr, ALIGN, al); + decl->attr |= CTFP_ALIGNED; +} + +/* Parse GCC asm("name") redirect. */ +static void cp_decl_asm(CPState *cp, CPDecl *decl) +{ + UNUSED(decl); + cp_next(cp); + cp_check(cp, '('); + if (cp->tok == CTOK_STRING) { + GCstr *str = cp->str; + while (cp_next(cp) == CTOK_STRING) { + lj_str_pushf(cp->L, "%s%s", strdata(str), strdata(cp->str)); + cp->L->top--; + str = strV(cp->L->top); + } + decl->redir = str; + } + cp_check(cp, ')'); +} + +/* Parse GCC __attribute__((mode(...))). */ +static void cp_decl_mode(CPState *cp, CPDecl *decl) +{ + cp_check(cp, '('); + if (cp->tok == CTOK_IDENT) { + const char *s = strdata(cp->str); + CTSize sz = 0, vlen = 0; + if (s[0] == '_' && s[1] == '_') s += 2; + if (*s == 'V') { + s++; + vlen = *s++ - '0'; + if (*s >= '0' && *s <= '9') + vlen = vlen*10 + (*s++ - '0'); + } + switch (*s++) { + case 'Q': sz = 1; break; + case 'H': sz = 2; break; + case 'S': sz = 4; break; + case 'D': sz = 8; break; + case 'T': sz = 16; break; + case 'O': sz = 32; break; + default: goto bad_size; + } + if (*s == 'I' || *s == 'F') { + CTF_INSERT(decl->attr, MSIZEP, sz); + if (vlen) CTF_INSERT(decl->attr, VSIZEP, lj_fls(vlen*sz)); + } + bad_size: + cp_next(cp); + } + cp_check(cp, ')'); +} + +/* Parse GCC __attribute__((...)). */ +static void cp_decl_gccattribute(CPState *cp, CPDecl *decl) +{ + cp_next(cp); + cp_check(cp, '('); + cp_check(cp, '('); + while (cp->tok != ')') { + if (cp->tok == CTOK_IDENT) { + GCstr *attrstr = cp->str; + cp_next(cp); + switch (attrstr->hash) { + case H_(64a9208e,8ce14319): case H_(8e6331b2,95a282af): /* aligned */ + cp_decl_align(cp, decl); + break; + case H_(42eb47de,f0ede26c): case H_(29f48a09,cf383e0c): /* packed */ + decl->attr |= CTFP_PACKED; + break; + case H_(0a84eef6,8dfab04c): case H_(995cf92c,d5696591): /* mode */ + cp_decl_mode(cp, decl); + break; + case H_(0ab31997,2d5213fa): case H_(bf875611,200e9990): /* vector_size */ + { + CTSize vsize = cp_decl_sizeattr(cp); + if (vsize) CTF_INSERT(decl->attr, VSIZEP, lj_fls(vsize)); + } + break; +#if LJ_TARGET_X86 + case H_(5ad22db8,c689b848): case H_(439150fa,65ea78cb): /* regparm */ + CTF_INSERT(decl->fattr, REGPARM, cp_decl_sizeattr(cp)); + decl->fattr |= CTFP_CCONV; + break; + case H_(18fc0b98,7ff4c074): case H_(4e62abed,0a747424): /* cdecl */ + CTF_INSERT(decl->fattr, CCONV, CTCC_CDECL); + decl->fattr |= CTFP_CCONV; + break; + case H_(72b2e41b,494c5a44): case H_(f2356d59,f25fc9bd): /* thiscall */ + CTF_INSERT(decl->fattr, CCONV, CTCC_THISCALL); + decl->fattr |= CTFP_CCONV; + break; + case H_(0d0ffc42,ab746f88): case H_(21c54ba1,7f0ca7e3): /* fastcall */ + CTF_INSERT(decl->fattr, CCONV, CTCC_FASTCALL); + decl->fattr |= CTFP_CCONV; + break; + case H_(ef76b040,9412e06a): case H_(de56697b,c750e6e1): /* stdcall */ + CTF_INSERT(decl->fattr, CCONV, CTCC_STDCALL); + decl->fattr |= CTFP_CCONV; + break; + case H_(ea78b622,f234bd8e): case H_(252ffb06,8d50f34b): /* sseregparm */ + decl->fattr |= CTF_SSEREGPARM; + decl->fattr |= CTFP_CCONV; + break; +#endif + default: /* Skip all other attributes. */ + goto skip_attr; + } + } else if (cp->tok >= CTOK_FIRSTDECL) { /* For __attribute((const)) etc. */ + cp_next(cp); + skip_attr: + if (cp_opt(cp, '(')) { + while (cp->tok != ')' && cp->tok != CTOK_EOF) cp_next(cp); + cp_check(cp, ')'); + } + } else { + break; + } + if (!cp_opt(cp, ',')) break; + } + cp_check(cp, ')'); + cp_check(cp, ')'); +} + +/* Parse MSVC __declspec(...). */ +static void cp_decl_msvcattribute(CPState *cp, CPDecl *decl) +{ + cp_next(cp); + cp_check(cp, '('); + while (cp->tok == CTOK_IDENT) { + GCstr *attrstr = cp->str; + cp_next(cp); + switch (attrstr->hash) { + case H_(bc2395fa,98f267f8): /* align */ + cp_decl_align(cp, decl); + break; + default: /* Ignore all other attributes. */ + if (cp_opt(cp, '(')) { + while (cp->tok != ')' && cp->tok != CTOK_EOF) cp_next(cp); + cp_check(cp, ')'); + } + break; + } + } + cp_check(cp, ')'); +} + +/* Parse declaration attributes (and common qualifiers). */ +static void cp_decl_attributes(CPState *cp, CPDecl *decl) +{ + for (;;) { + switch (cp->tok) { + case CTOK_CONST: decl->attr |= CTF_CONST; break; + case CTOK_VOLATILE: decl->attr |= CTF_VOLATILE; break; + case CTOK_RESTRICT: break; /* Ignore. */ + case CTOK_EXTENSION: break; /* Ignore. */ + case CTOK_ATTRIBUTE: cp_decl_gccattribute(cp, decl); continue; + case CTOK_ASM: cp_decl_asm(cp, decl); continue; + case CTOK_DECLSPEC: cp_decl_msvcattribute(cp, decl); continue; + case CTOK_CCDECL: +#if LJ_TARGET_X86 + CTF_INSERT(decl->fattr, CCONV, cp->ct->size); + decl->fattr |= CTFP_CCONV; +#endif + break; + case CTOK_PTRSZ: +#if LJ_64 + CTF_INSERT(decl->attr, MSIZEP, cp->ct->size); +#endif + break; + default: return; + } + cp_next(cp); + } +} + +/* Parse struct/union/enum name. */ +static CTypeID cp_struct_name(CPState *cp, CPDecl *sdecl, CTInfo info) +{ + CTypeID sid; + CType *ct; + cp->tmask = CPNS_STRUCT; + cp_next(cp); + cp_decl_attributes(cp, sdecl); + cp->tmask = CPNS_DEFAULT; + if (cp->tok != '{') { + if (cp->tok != CTOK_IDENT) cp_err_token(cp, CTOK_IDENT); + if (cp->val.id) { /* Name of existing struct/union/enum. */ + sid = cp->val.id; + ct = cp->ct; + if ((ct->info ^ info) & (CTMASK_NUM|CTF_UNION)) /* Wrong type. */ + cp_errmsg(cp, 0, LJ_ERR_FFI_REDEF, strdata(gco2str(gcref(ct->name)))); + } else { /* Create named, incomplete struct/union/enum. */ + if ((cp->mode & CPARSE_MODE_NOIMPLICIT)) + cp_errmsg(cp, 0, LJ_ERR_FFI_BADTAG, strdata(cp->str)); + sid = lj_ctype_new(cp->cts, &ct); + ct->info = info; + ct->size = CTSIZE_INVALID; + ctype_setname(ct, cp->str); + lj_ctype_addname(cp->cts, ct, sid); + } + cp_next(cp); + } else { /* Create anonymous, incomplete struct/union/enum. */ + sid = lj_ctype_new(cp->cts, &ct); + ct->info = info; + ct->size = CTSIZE_INVALID; + } + if (cp->tok == '{') { + if (ct->size != CTSIZE_INVALID || ct->sib) + cp_errmsg(cp, 0, LJ_ERR_FFI_REDEF, strdata(gco2str(gcref(ct->name)))); + ct->sib = 1; /* Indicate the type is currently being defined. */ + } + return sid; +} + +/* Determine field alignment. */ +static CTSize cp_field_align(CPState *cp, CType *ct, CTInfo info) +{ + CTSize align = ctype_align(info); + UNUSED(cp); UNUSED(ct); +#if (LJ_TARGET_X86 && !LJ_ABI_WIN) || (LJ_TARGET_ARM && __APPLE__) + /* The SYSV i386 and iOS ABIs limit alignment of non-vector fields to 2^2. */ + if (align > 2 && !(info & CTFP_ALIGNED)) { + if (ctype_isarray(info) && !(info & CTF_VECTOR)) { + do { + ct = ctype_rawchild(cp->cts, ct); + info = ct->info; + } while (ctype_isarray(info) && !(info & CTF_VECTOR)); + } + if (ctype_isnum(info) || ctype_isenum(info)) + align = 2; + } +#endif + return align; +} + +/* Layout struct/union fields. */ +static void cp_struct_layout(CPState *cp, CTypeID sid, CTInfo sattr) +{ + CTSize bofs = 0, bmaxofs = 0; /* Bit offset and max. bit offset. */ + CTSize maxalign = ctype_align(sattr); + CType *sct = ctype_get(cp->cts, sid); + CTInfo sinfo = sct->info; + CTypeID fieldid = sct->sib; + while (fieldid) { + CType *ct = ctype_get(cp->cts, fieldid); + CTInfo attr = ct->size; /* Field declaration attributes (temp.). */ + + if (ctype_isfield(ct->info) || + (ctype_isxattrib(ct->info, CTA_SUBTYPE) && attr)) { + CTSize align, amask; /* Alignment (pow2) and alignment mask (bits). */ + CTSize sz; + CTInfo info = lj_ctype_info(cp->cts, ctype_cid(ct->info), &sz); + CTSize bsz, csz = 8*sz; /* Field size and container size (in bits). */ + sinfo |= (info & (CTF_QUAL|CTF_VLA)); /* Merge pseudo-qualifiers. */ + + /* Check for size overflow and determine alignment. */ + if (sz >= 0x20000000u || bofs + csz < bofs || (info & CTF_VLA)) { + if (!(sz == CTSIZE_INVALID && ctype_isarray(info) && + !(sinfo & CTF_UNION))) + cp_err(cp, LJ_ERR_FFI_INVSIZE); + csz = sz = 0; /* Treat a[] and a[?] as zero-sized. */ + } + align = cp_field_align(cp, ct, info); + if (((attr|sattr) & CTFP_PACKED) || + ((attr & CTFP_ALIGNED) && ctype_align(attr) > align)) + align = ctype_align(attr); + if (cp->packstack[cp->curpack] < align) + align = cp->packstack[cp->curpack]; + if (align > maxalign) maxalign = align; + amask = (8u << align) - 1; + + bsz = ctype_bitcsz(ct->info); /* Bitfield size (temp.). */ + if (bsz == CTBSZ_FIELD || !ctype_isfield(ct->info)) { + bsz = csz; /* Regular fields or subtypes always fill the container. */ + bofs = (bofs + amask) & ~amask; /* Start new aligned field. */ + ct->size = (bofs >> 3); /* Store field offset. */ + } else { /* Bitfield. */ + if (bsz == 0 || (attr & CTFP_ALIGNED) || + (!((attr|sattr) & CTFP_PACKED) && (bofs & amask) + bsz > csz)) + bofs = (bofs + amask) & ~amask; /* Start new aligned field. */ + + /* Prefer regular field over bitfield. */ + if (bsz == csz && (bofs & amask) == 0) { + ct->info = CTINFO(CT_FIELD, ctype_cid(ct->info)); + ct->size = (bofs >> 3); /* Store field offset. */ + } else { + ct->info = CTINFO(CT_BITFIELD, + (info & (CTF_QUAL|CTF_UNSIGNED|CTF_BOOL)) + + (csz << (CTSHIFT_BITCSZ-3)) + (bsz << CTSHIFT_BITBSZ)); +#if LJ_BE + ct->info += ((csz - (bofs & (csz-1)) - bsz) << CTSHIFT_BITPOS); +#else + ct->info += ((bofs & (csz-1)) << CTSHIFT_BITPOS); +#endif + ct->size = ((bofs & ~(csz-1)) >> 3); /* Store container offset. */ + } + } + + /* Determine next offset or max. offset. */ + if ((sinfo & CTF_UNION)) { + if (bsz > bmaxofs) bmaxofs = bsz; + } else { + bofs += bsz; + } + } /* All other fields in the chain are already set up. */ + + fieldid = ct->sib; + } + + /* Complete struct/union. */ + sct->info = sinfo + CTALIGN(maxalign); + bofs = (sinfo & CTF_UNION) ? bmaxofs : bofs; + maxalign = (8u << maxalign) - 1; + sct->size = (((bofs + maxalign) & ~maxalign) >> 3); +} + +/* Parse struct/union declaration. */ +static CTypeID cp_decl_struct(CPState *cp, CPDecl *sdecl, CTInfo sinfo) +{ + CTypeID sid = cp_struct_name(cp, sdecl, sinfo); + if (cp_opt(cp, '{')) { /* Struct/union definition. */ + CTypeID lastid = sid; + int lastdecl = 0; + while (cp->tok != '}') { + CPDecl decl; + CPscl scl = cp_decl_spec(cp, &decl, CDF_STATIC); + decl.mode = scl ? CPARSE_MODE_DIRECT : + CPARSE_MODE_DIRECT|CPARSE_MODE_ABSTRACT|CPARSE_MODE_FIELD; + + for (;;) { + CTypeID ctypeid; + + if (lastdecl) cp_err_token(cp, '}'); + + /* Parse field declarator. */ + decl.bits = CTSIZE_INVALID; + cp_declarator(cp, &decl); + ctypeid = cp_decl_intern(cp, &decl); + + if ((scl & CDF_STATIC)) { /* Static constant in struct namespace. */ + CType *ct; + CTypeID fieldid = cp_decl_constinit(cp, &ct, ctypeid); + ctype_get(cp->cts, lastid)->sib = fieldid; + lastid = fieldid; + ctype_setname(ct, decl.name); + } else { + CTSize bsz = CTBSZ_FIELD; /* Temp. for layout phase. */ + CType *ct; + CTypeID fieldid = lj_ctype_new(cp->cts, &ct); /* Do this first. */ + CType *tct = ctype_raw(cp->cts, ctypeid); + + if (decl.bits == CTSIZE_INVALID) { /* Regular field. */ + if (ctype_isarray(tct->info) && tct->size == CTSIZE_INVALID) + lastdecl = 1; /* a[] or a[?] must be the last declared field. */ + + /* Accept transparent struct/union/enum. */ + if (!decl.name) { + if (!((ctype_isstruct(tct->info) && !(tct->info & CTF_VLA)) || + ctype_isenum(tct->info))) + cp_err_token(cp, CTOK_IDENT); + ct->info = CTINFO(CT_ATTRIB, CTATTRIB(CTA_SUBTYPE) + ctypeid); + ct->size = ctype_isstruct(tct->info) ? + (decl.attr|0x80000000u) : 0; /* For layout phase. */ + goto add_field; + } + } else { /* Bitfield. */ + bsz = decl.bits; + if (!ctype_isinteger_or_bool(tct->info) || + (bsz == 0 && decl.name) || 8*tct->size > CTBSZ_MAX || + bsz > ((tct->info & CTF_BOOL) ? 1 : 8*tct->size)) + cp_errmsg(cp, ':', LJ_ERR_BADVAL); + } + + /* Create temporary field for layout phase. */ + ct->info = CTINFO(CT_FIELD, ctypeid + (bsz << CTSHIFT_BITCSZ)); + ct->size = decl.attr; + if (decl.name) ctype_setname(ct, decl.name); + + add_field: + ctype_get(cp->cts, lastid)->sib = fieldid; + lastid = fieldid; + } + if (!cp_opt(cp, ',')) break; + cp_decl_reset(&decl); + } + cp_check(cp, ';'); + } + cp_check(cp, '}'); + ctype_get(cp->cts, lastid)->sib = 0; /* Drop sib = 1 for empty structs. */ + cp_decl_attributes(cp, sdecl); /* Layout phase needs postfix attributes. */ + cp_struct_layout(cp, sid, sdecl->attr); + } + return sid; +} + +/* Parse enum declaration. */ +static CTypeID cp_decl_enum(CPState *cp, CPDecl *sdecl) +{ + CTypeID eid = cp_struct_name(cp, sdecl, CTINFO(CT_ENUM, CTID_VOID)); + CTInfo einfo = CTINFO(CT_ENUM, CTALIGN(2) + CTID_UINT32); + CTSize esize = 4; /* Only 32 bit enums are supported. */ + if (cp_opt(cp, '{')) { /* Enum definition. */ + CPValue k; + CTypeID lastid = eid; + k.u32 = 0; + k.id = CTID_INT32; + do { + GCstr *name = cp->str; + if (cp->tok != CTOK_IDENT) cp_err_token(cp, CTOK_IDENT); + if (cp->val.id) cp_errmsg(cp, 0, LJ_ERR_FFI_REDEF, strdata(name)); + cp_next(cp); + if (cp_opt(cp, '=')) { + cp_expr_kint(cp, &k); + if (k.id == CTID_UINT32) { + /* C99 says that enum constants are always (signed) integers. + ** But since unsigned constants like 0x80000000 are quite common, + ** those are left as uint32_t. + */ + if (k.i32 >= 0) k.id = CTID_INT32; + } else { + /* OTOH it's common practice and even mandated by some ABIs + ** that the enum type itself is unsigned, unless there are any + ** negative constants. + */ + k.id = CTID_INT32; + if (k.i32 < 0) einfo = CTINFO(CT_ENUM, CTALIGN(2) + CTID_INT32); + } + } + /* Add named enum constant. */ + { + CType *ct; + CTypeID constid = lj_ctype_new(cp->cts, &ct); + ctype_get(cp->cts, lastid)->sib = constid; + lastid = constid; + ctype_setname(ct, name); + ct->info = CTINFO(CT_CONSTVAL, CTF_CONST|k.id); + ct->size = k.u32++; + if (k.u32 == 0x80000000u) k.id = CTID_UINT32; + lj_ctype_addname(cp->cts, ct, constid); + } + if (!cp_opt(cp, ',')) break; + } while (cp->tok != '}'); /* Trailing ',' is ok. */ + cp_check(cp, '}'); + /* Complete enum. */ + ctype_get(cp->cts, eid)->info = einfo; + ctype_get(cp->cts, eid)->size = esize; + } + return eid; +} + +/* Parse declaration specifiers. */ +static CPscl cp_decl_spec(CPState *cp, CPDecl *decl, CPscl scl) +{ + uint32_t cds = 0, sz = 0; + CTypeID tdef = 0; + + decl->cp = cp; + decl->mode = cp->mode; + decl->name = NULL; + decl->redir = NULL; + decl->attr = 0; + decl->fattr = 0; + decl->pos = decl->top = 0; + decl->stack[0].next = 0; + + for (;;) { /* Parse basic types. */ + cp_decl_attributes(cp, decl); + if (cp->tok >= CTOK_FIRSTDECL && cp->tok <= CTOK_LASTDECLFLAG) { + uint32_t cbit; + if (cp->ct->size) { + if (sz) goto end_decl; + sz = cp->ct->size; + } + cbit = (1u << (cp->tok - CTOK_FIRSTDECL)); + cds = cds | cbit | ((cbit & cds & CDF_LONG) << 1); + if (cp->tok >= CTOK_FIRSTSCL) { + if (!(scl & cbit)) cp_errmsg(cp, cp->tok, LJ_ERR_FFI_BADSCL); + } else if (tdef) { + goto end_decl; + } + cp_next(cp); + continue; + } + if (sz || tdef || + (cds & (CDF_SHORT|CDF_LONG|CDF_SIGNED|CDF_UNSIGNED|CDF_COMPLEX))) + break; + switch (cp->tok) { + case CTOK_STRUCT: + tdef = cp_decl_struct(cp, decl, CTINFO(CT_STRUCT, 0)); + continue; + case CTOK_UNION: + tdef = cp_decl_struct(cp, decl, CTINFO(CT_STRUCT, CTF_UNION)); + continue; + case CTOK_ENUM: + tdef = cp_decl_enum(cp, decl); + continue; + case CTOK_IDENT: + if (ctype_istypedef(cp->ct->info)) { + tdef = ctype_cid(cp->ct->info); /* Get typedef. */ + cp_next(cp); + continue; + } + break; + case '$': + tdef = cp->val.id; + cp_next(cp); + continue; + default: + break; + } + break; + } +end_decl: + + if ((cds & CDF_COMPLEX)) /* Use predefined complex types. */ + tdef = sz == 4 ? CTID_COMPLEX_FLOAT : CTID_COMPLEX_DOUBLE; + + if (tdef) { + cp_push_type(decl, tdef); + } else if ((cds & CDF_VOID)) { + cp_push(decl, CTINFO(CT_VOID, (decl->attr & CTF_QUAL)), CTSIZE_INVALID); + decl->attr &= ~CTF_QUAL; + } else { + /* Determine type info and size. */ + CTInfo info = CTINFO(CT_NUM, (cds & CDF_UNSIGNED) ? CTF_UNSIGNED : 0); + if ((cds & CDF_BOOL)) { + if ((cds & ~(CDF_SCL|CDF_BOOL|CDF_INT|CDF_SIGNED|CDF_UNSIGNED))) + cp_errmsg(cp, 0, LJ_ERR_FFI_INVTYPE); + info |= CTF_BOOL; + if (!(cds & CDF_SIGNED)) info |= CTF_UNSIGNED; + if (!sz) { + sz = 1; + } + } else if ((cds & CDF_FP)) { + info = CTINFO(CT_NUM, CTF_FP); + if ((cds & CDF_LONG)) sz = sizeof(long double); + } else if ((cds & CDF_CHAR)) { + if ((cds & (CDF_CHAR|CDF_SIGNED|CDF_UNSIGNED)) == CDF_CHAR) + info |= CTF_UCHAR; /* Handle platforms where char is unsigned. */ + } else if ((cds & CDF_SHORT)) { + sz = sizeof(short); + } else if ((cds & CDF_LONGLONG)) { + sz = 8; + } else if ((cds & CDF_LONG)) { + info |= CTF_LONG; + sz = sizeof(long); + } else if (!sz) { + if (!(cds & (CDF_SIGNED|CDF_UNSIGNED))) + cp_errmsg(cp, cp->tok, LJ_ERR_FFI_DECLSPEC); + sz = sizeof(int); + } + lua_assert(sz != 0); + info += CTALIGN(lj_fls(sz)); /* Use natural alignment. */ + info += (decl->attr & CTF_QUAL); /* Merge qualifiers. */ + cp_push(decl, info, sz); + decl->attr &= ~CTF_QUAL; + } + decl->specpos = decl->pos; + decl->specattr = decl->attr; + decl->specfattr = decl->fattr; + return (cds & CDF_SCL); /* Return storage class. */ +} + +/* Parse array declaration. */ +static void cp_decl_array(CPState *cp, CPDecl *decl) +{ + CTInfo info = CTINFO(CT_ARRAY, 0); + CTSize nelem = CTSIZE_INVALID; /* Default size for a[] or a[?]. */ + cp_decl_attributes(cp, decl); + if (cp_opt(cp, '?')) + info |= CTF_VLA; /* Create variable-length array a[?]. */ + else if (cp->tok != ']') + nelem = cp_expr_ksize(cp); + cp_check(cp, ']'); + cp_add(decl, info, nelem); +} + +/* Parse function declaration. */ +static void cp_decl_func(CPState *cp, CPDecl *fdecl) +{ + CTSize nargs = 0; + CTInfo info = CTINFO(CT_FUNC, 0); + CTypeID lastid = 0, anchor = 0; + if (cp->tok != ')') { + do { + CPDecl decl; + CTypeID ctypeid, fieldid; + CType *ct; + if (cp_opt(cp, '.')) { /* Vararg function. */ + cp_check(cp, '.'); /* Workaround for the minimalistic lexer. */ + cp_check(cp, '.'); + info |= CTF_VARARG; + break; + } + cp_decl_spec(cp, &decl, CDF_REGISTER); + decl.mode = CPARSE_MODE_DIRECT|CPARSE_MODE_ABSTRACT; + cp_declarator(cp, &decl); + ctypeid = cp_decl_intern(cp, &decl); + ct = ctype_raw(cp->cts, ctypeid); + if (ctype_isvoid(ct->info)) + break; + else if (ctype_isrefarray(ct->info)) + ctypeid = lj_ctype_intern(cp->cts, + CTINFO(CT_PTR, CTALIGN_PTR|ctype_cid(ct->info)), CTSIZE_PTR); + else if (ctype_isfunc(ct->info)) + ctypeid = lj_ctype_intern(cp->cts, + CTINFO(CT_PTR, CTALIGN_PTR|ctypeid), CTSIZE_PTR); + /* Add new parameter. */ + fieldid = lj_ctype_new(cp->cts, &ct); + if (anchor) + ctype_get(cp->cts, lastid)->sib = fieldid; + else + anchor = fieldid; + lastid = fieldid; + if (decl.name) ctype_setname(ct, decl.name); + ct->info = CTINFO(CT_FIELD, ctypeid); + ct->size = nargs++; + } while (cp_opt(cp, ',')); + } + cp_check(cp, ')'); + if (cp_opt(cp, '{')) { /* Skip function definition. */ + int level = 1; + cp->mode |= CPARSE_MODE_SKIP; + for (;;) { + if (cp->tok == '{') level++; + else if (cp->tok == '}' && --level == 0) break; + else if (cp->tok == CTOK_EOF) cp_err_token(cp, '}'); + cp_next(cp); + } + cp->mode &= ~CPARSE_MODE_SKIP; + cp->tok = ';'; /* Ok for cp_decl_multi(), error in cp_decl_single(). */ + } + info |= (fdecl->fattr & ~CTMASK_CID); + fdecl->fattr = 0; + fdecl->stack[cp_add(fdecl, info, nargs)].sib = anchor; +} + +/* Parse declarator. */ +static void cp_declarator(CPState *cp, CPDecl *decl) +{ + if (++cp->depth > CPARSE_MAX_DECLDEPTH) cp_err(cp, LJ_ERR_XLEVELS); + + for (;;) { /* Head of declarator. */ + if (cp_opt(cp, '*')) { /* Pointer. */ + CTSize sz; + CTInfo info; + cp_decl_attributes(cp, decl); + sz = CTSIZE_PTR; + info = CTINFO(CT_PTR, CTALIGN_PTR); +#if LJ_64 + if (ctype_msizeP(decl->attr) == 4) { + sz = 4; + info = CTINFO(CT_PTR, CTALIGN(2)); + } +#endif + info += (decl->attr & (CTF_QUAL|CTF_REF)); + decl->attr &= ~(CTF_QUAL|(CTMASK_MSIZEP<attr &= ~(CTF_QUAL|(CTMASK_MSIZEP<mode & CPARSE_MODE_ABSTRACT) && + (cp->tok == ')' || cp_istypedecl(cp))) goto func_decl; + pos = decl->pos; + cp_declarator(cp, decl); + cp_check(cp, ')'); + decl->pos = pos; + } else if (cp->tok == CTOK_IDENT) { /* Direct declarator. */ + if (!(decl->mode & CPARSE_MODE_DIRECT)) cp_err_token(cp, CTOK_EOF); + decl->name = cp->str; + decl->nameid = cp->val.id; + cp_next(cp); + } else { /* Abstract declarator. */ + if (!(decl->mode & CPARSE_MODE_ABSTRACT)) cp_err_token(cp, CTOK_IDENT); + } + + for (;;) { /* Tail of declarator. */ + if (cp_opt(cp, '[')) { /* Array. */ + cp_decl_array(cp, decl); + } else if (cp_opt(cp, '(')) { /* Function. */ + func_decl: + cp_decl_func(cp, decl); + } else { + break; + } + } + + if ((decl->mode & CPARSE_MODE_FIELD) && cp_opt(cp, ':')) /* Field width. */ + decl->bits = cp_expr_ksize(cp); + + /* Process postfix attributes. */ + cp_decl_attributes(cp, decl); + cp_push_attributes(decl); + + cp->depth--; +} + +/* Parse an abstract type declaration and return it's C type ID. */ +static CTypeID cp_decl_abstract(CPState *cp) +{ + CPDecl decl; + cp_decl_spec(cp, &decl, 0); + decl.mode = CPARSE_MODE_ABSTRACT; + cp_declarator(cp, &decl); + return cp_decl_intern(cp, &decl); +} + +/* Handle pragmas. */ +static void cp_pragma(CPState *cp, BCLine pragmaline) +{ + cp_next(cp); + if (cp->tok == CTOK_IDENT && + cp->str->hash == H_(e79b999f,42ca3e85)) { /* pack */ + cp_next(cp); + cp_check(cp, '('); + if (cp->tok == CTOK_IDENT) { + if (cp->str->hash == H_(738e923c,a1b65954)) { /* push */ + if (cp->curpack < CPARSE_MAX_PACKSTACK) { + cp->packstack[cp->curpack+1] = cp->packstack[cp->curpack]; + cp->curpack++; + } + } else if (cp->str->hash == H_(6c71cf27,6c71cf27)) { /* pop */ + if (cp->curpack > 0) cp->curpack--; + } else { + cp_errmsg(cp, cp->tok, LJ_ERR_XSYMBOL); + } + cp_next(cp); + if (!cp_opt(cp, ',')) goto end_pack; + } + if (cp->tok == CTOK_INTEGER) { + cp->packstack[cp->curpack] = cp->val.u32 ? lj_fls(cp->val.u32) : 0; + cp_next(cp); + } else { + cp->packstack[cp->curpack] = 255; + } + end_pack: + cp_check(cp, ')'); + } else { /* Ignore all other pragmas. */ + while (cp->tok != CTOK_EOF && cp->linenumber == pragmaline) + cp_next(cp); + } +} + +/* Parse multiple C declarations of types or extern identifiers. */ +static void cp_decl_multi(CPState *cp) +{ + int first = 1; + while (cp->tok != CTOK_EOF) { + CPDecl decl; + CPscl scl; + if (cp_opt(cp, ';')) { /* Skip empty statements. */ + first = 0; + continue; + } + if (cp->tok == '#') { /* Workaround, since we have no preprocessor, yet. */ + BCLine pragmaline = cp->linenumber; + if (!(cp_next(cp) == CTOK_IDENT && + cp->str->hash == H_(f5e6b4f8,1d509107))) /* pragma */ + cp_errmsg(cp, cp->tok, LJ_ERR_XSYMBOL); + cp_pragma(cp, pragmaline); + continue; + } + scl = cp_decl_spec(cp, &decl, CDF_TYPEDEF|CDF_EXTERN|CDF_STATIC); + if ((cp->tok == ';' || cp->tok == CTOK_EOF) && + ctype_istypedef(decl.stack[0].info)) { + CTInfo info = ctype_rawchild(cp->cts, &decl.stack[0])->info; + if (ctype_isstruct(info) || ctype_isenum(info)) + goto decl_end; /* Accept empty declaration of struct/union/enum. */ + } + for (;;) { + CTypeID ctypeid; + cp_declarator(cp, &decl); + ctypeid = cp_decl_intern(cp, &decl); + if (decl.name && !decl.nameid) { /* NYI: redeclarations are ignored. */ + CType *ct; + CTypeID id; + if ((scl & CDF_TYPEDEF)) { /* Create new typedef. */ + id = lj_ctype_new(cp->cts, &ct); + ct->info = CTINFO(CT_TYPEDEF, ctypeid); + goto noredir; + } else if (ctype_isfunc(ctype_get(cp->cts, ctypeid)->info)) { + /* Treat both static and extern function declarations as extern. */ + ct = ctype_get(cp->cts, ctypeid); + /* We always get new anonymous functions (typedefs are copied). */ + lua_assert(gcref(ct->name) == NULL); + id = ctypeid; /* Just name it. */ + } else if ((scl & CDF_STATIC)) { /* Accept static constants. */ + id = cp_decl_constinit(cp, &ct, ctypeid); + goto noredir; + } else { /* External references have extern or no storage class. */ + id = lj_ctype_new(cp->cts, &ct); + ct->info = CTINFO(CT_EXTERN, ctypeid); + } + if (decl.redir) { /* Add attribute for redirected symbol name. */ + CType *cta; + CTypeID aid = lj_ctype_new(cp->cts, &cta); + ct = ctype_get(cp->cts, id); /* Table may have been reallocated. */ + cta->info = CTINFO(CT_ATTRIB, CTATTRIB(CTA_REDIR)); + cta->sib = ct->sib; + ct->sib = aid; + ctype_setname(cta, decl.redir); + } + noredir: + ctype_setname(ct, decl.name); + lj_ctype_addname(cp->cts, ct, id); + } + if (!cp_opt(cp, ',')) break; + cp_decl_reset(&decl); + } + decl_end: + if (cp->tok == CTOK_EOF && first) break; /* May omit ';' for 1 decl. */ + first = 0; + cp_check(cp, ';'); + } +} + +/* Parse a single C type declaration. */ +static void cp_decl_single(CPState *cp) +{ + CPDecl decl; + cp_decl_spec(cp, &decl, 0); + cp_declarator(cp, &decl); + cp->val.id = cp_decl_intern(cp, &decl); + if (cp->tok != CTOK_EOF) cp_err_token(cp, CTOK_EOF); +} + +#undef H_ + +/* ------------------------------------------------------------------------ */ + +/* Protected callback for C parser. */ +static TValue *cpcparser(lua_State *L, lua_CFunction dummy, void *ud) +{ + CPState *cp = (CPState *)ud; + UNUSED(dummy); + cframe_errfunc(L->cframe) = -1; /* Inherit error function. */ + cp_init(cp); + if ((cp->mode & CPARSE_MODE_MULTI)) + cp_decl_multi(cp); + else + cp_decl_single(cp); + if (cp->param && cp->param != cp->L->top) + cp_err(cp, LJ_ERR_FFI_NUMPARAM); + lua_assert(cp->depth == 0); + return NULL; +} + +/* C parser. */ +int lj_cparse(CPState *cp) +{ + LJ_CTYPE_SAVE(cp->cts); + int errcode = lj_vm_cpcall(cp->L, NULL, cp, cpcparser); + if (errcode) + LJ_CTYPE_RESTORE(cp->cts); + cp_cleanup(cp); + return errcode; +} + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_cparse.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_cparse.h new file mode 100644 index 000000000..441580de6 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_cparse.h @@ -0,0 +1,65 @@ +/* +** C declaration parser. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_CPARSE_H +#define _LJ_CPARSE_H + +#include "lj_obj.h" +#include "lj_ctype.h" + +#if LJ_HASFFI + +/* C parser limits. */ +#define CPARSE_MAX_BUF 32768 /* Max. token buffer size. */ +#define CPARSE_MAX_DECLSTACK 100 /* Max. declaration stack depth. */ +#define CPARSE_MAX_DECLDEPTH 20 /* Max. recursive declaration depth. */ +#define CPARSE_MAX_PACKSTACK 7 /* Max. pack pragma stack depth. */ + +/* Flags for C parser mode. */ +#define CPARSE_MODE_MULTI 1 /* Process multiple declarations. */ +#define CPARSE_MODE_ABSTRACT 2 /* Accept abstract declarators. */ +#define CPARSE_MODE_DIRECT 4 /* Accept direct declarators. */ +#define CPARSE_MODE_FIELD 8 /* Accept field width in bits, too. */ +#define CPARSE_MODE_NOIMPLICIT 16 /* Reject implicit declarations. */ +#define CPARSE_MODE_SKIP 32 /* Skip definitions, ignore errors. */ + +typedef int CPChar; /* C parser character. Unsigned ext. from char. */ +typedef int CPToken; /* C parser token. */ + +/* C parser internal value representation. */ +typedef struct CPValue { + union { + int32_t i32; /* Value for CTID_INT32. */ + uint32_t u32; /* Value for CTID_UINT32. */ + }; + CTypeID id; /* C Type ID of the value. */ +} CPValue; + +/* C parser state. */ +typedef struct CPState { + CPChar c; /* Current character. */ + CPToken tok; /* Current token. */ + CPValue val; /* Token value. */ + GCstr *str; /* Interned string of identifier/keyword. */ + CType *ct; /* C type table entry. */ + const char *p; /* Current position in input buffer. */ + SBuf sb; /* String buffer for tokens. */ + lua_State *L; /* Lua state. */ + CTState *cts; /* C type state. */ + TValue *param; /* C type parameters. */ + const char *srcname; /* Current source name. */ + BCLine linenumber; /* Input line counter. */ + int depth; /* Recursive declaration depth. */ + uint32_t tmask; /* Type mask for next identifier. */ + uint32_t mode; /* C parser mode. */ + uint8_t packstack[CPARSE_MAX_PACKSTACK]; /* Stack for pack pragmas. */ + uint8_t curpack; /* Current position in pack pragma stack. */ +} CPState; + +LJ_FUNC int lj_cparse(CPState *cp); + +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_crecord.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_crecord.c new file mode 100644 index 000000000..a46665e9a --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_crecord.c @@ -0,0 +1,1671 @@ +/* +** Trace recorder for C data operations. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_ffrecord_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT && LJ_HASFFI + +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_frame.h" +#include "lj_ctype.h" +#include "lj_cdata.h" +#include "lj_cparse.h" +#include "lj_cconv.h" +#include "lj_clib.h" +#include "lj_ccall.h" +#include "lj_ff.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_ircall.h" +#include "lj_iropt.h" +#include "lj_trace.h" +#include "lj_record.h" +#include "lj_ffrecord.h" +#include "lj_snap.h" +#include "lj_crecord.h" +#include "lj_dispatch.h" + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) + +/* Pass IR on to next optimization in chain (FOLD). */ +#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) + +#define emitconv(a, dt, st, flags) \ + emitir(IRT(IR_CONV, (dt)), (a), (st)|((dt) << 5)|(flags)) + +/* -- C type checks ------------------------------------------------------- */ + +static GCcdata *argv2cdata(jit_State *J, TRef tr, cTValue *o) +{ + GCcdata *cd; + TRef trtypeid; + if (!tref_iscdata(tr)) + lj_trace_err(J, LJ_TRERR_BADTYPE); + cd = cdataV(o); + /* Specialize to the CTypeID. */ + trtypeid = emitir(IRT(IR_FLOAD, IRT_U16), tr, IRFL_CDATA_CTYPEID); + emitir(IRTG(IR_EQ, IRT_INT), trtypeid, lj_ir_kint(J, (int32_t)cd->ctypeid)); + return cd; +} + +/* Specialize to the CTypeID held by a cdata constructor. */ +static CTypeID crec_constructor(jit_State *J, GCcdata *cd, TRef tr) +{ + CTypeID id; + lua_assert(tref_iscdata(tr) && cd->ctypeid == CTID_CTYPEID); + id = *(CTypeID *)cdataptr(cd); + tr = emitir(IRT(IR_FLOAD, IRT_INT), tr, IRFL_CDATA_INT); + emitir(IRTG(IR_EQ, IRT_INT), tr, lj_ir_kint(J, (int32_t)id)); + return id; +} + +static CTypeID argv2ctype(jit_State *J, TRef tr, cTValue *o) +{ + if (tref_isstr(tr)) { + GCstr *s = strV(o); + CPState cp; + CTypeID oldtop; + /* Specialize to the string containing the C type declaration. */ + emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, s)); + cp.L = J->L; + cp.cts = ctype_ctsG(J2G(J)); + oldtop = cp.cts->top; + cp.srcname = strdata(s); + cp.p = strdata(s); + cp.param = NULL; + cp.mode = CPARSE_MODE_ABSTRACT|CPARSE_MODE_NOIMPLICIT; + if (lj_cparse(&cp) || cp.cts->top > oldtop) /* Avoid new struct defs. */ + lj_trace_err(J, LJ_TRERR_BADTYPE); + return cp.val.id; + } else { + GCcdata *cd = argv2cdata(J, tr, o); + return cd->ctypeid == CTID_CTYPEID ? crec_constructor(J, cd, tr) : + cd->ctypeid; + } +} + +/* Convert CType to IRType (if possible). */ +static IRType crec_ct2irt(CTState *cts, CType *ct) +{ + if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); + if (LJ_LIKELY(ctype_isnum(ct->info))) { + if ((ct->info & CTF_FP)) { + if (ct->size == sizeof(double)) + return IRT_NUM; + else if (ct->size == sizeof(float)) + return IRT_FLOAT; + } else { + uint32_t b = lj_fls(ct->size); + if (b <= 3) + return IRT_I8 + 2*b + ((ct->info & CTF_UNSIGNED) ? 1 : 0); + } + } else if (ctype_isptr(ct->info)) { + return (LJ_64 && ct->size == 8) ? IRT_P64 : IRT_P32; + } else if (ctype_iscomplex(ct->info)) { + if (ct->size == 2*sizeof(double)) + return IRT_NUM; + else if (ct->size == 2*sizeof(float)) + return IRT_FLOAT; + } + return IRT_CDATA; +} + +/* -- Optimized memory fill and copy -------------------------------------- */ + +/* Maximum length and unroll of inlined copy/fill. */ +#define CREC_COPY_MAXUNROLL 16 +#define CREC_COPY_MAXLEN 128 + +#define CREC_FILL_MAXUNROLL 16 + +/* Number of windowed registers used for optimized memory copy. */ +#if LJ_TARGET_X86 +#define CREC_COPY_REGWIN 2 +#elif LJ_TARGET_PPC || LJ_TARGET_MIPS +#define CREC_COPY_REGWIN 8 +#else +#define CREC_COPY_REGWIN 4 +#endif + +/* List of memory offsets for copy/fill. */ +typedef struct CRecMemList { + CTSize ofs; /* Offset in bytes. */ + IRType tp; /* Type of load/store. */ + TRef trofs; /* TRef of interned offset. */ + TRef trval; /* TRef of load value. */ +} CRecMemList; + +/* Generate copy list for element-wise struct copy. */ +static MSize crec_copy_struct(CRecMemList *ml, CTState *cts, CType *ct) +{ + CTypeID fid = ct->sib; + MSize mlp = 0; + while (fid) { + CType *df = ctype_get(cts, fid); + fid = df->sib; + if (ctype_isfield(df->info)) { + CType *cct; + IRType tp; + if (!gcref(df->name)) continue; /* Ignore unnamed fields. */ + cct = ctype_rawchild(cts, df); /* Field type. */ + tp = crec_ct2irt(cts, cct); + if (tp == IRT_CDATA) return 0; /* NYI: aggregates. */ + if (mlp >= CREC_COPY_MAXUNROLL) return 0; + ml[mlp].ofs = df->size; + ml[mlp].tp = tp; + mlp++; + if (ctype_iscomplex(cct->info)) { + if (mlp >= CREC_COPY_MAXUNROLL) return 0; + ml[mlp].ofs = df->size + (cct->size >> 1); + ml[mlp].tp = tp; + mlp++; + } + } else if (!ctype_isconstval(df->info)) { + /* NYI: bitfields and sub-structures. */ + return 0; + } + } + return mlp; +} + +/* Generate unrolled copy list, from highest to lowest step size/alignment. */ +static MSize crec_copy_unroll(CRecMemList *ml, CTSize len, CTSize step, + IRType tp) +{ + CTSize ofs = 0; + MSize mlp = 0; + if (tp == IRT_CDATA) tp = IRT_U8 + 2*lj_fls(step); + do { + while (ofs + step <= len) { + if (mlp >= CREC_COPY_MAXUNROLL) return 0; + ml[mlp].ofs = ofs; + ml[mlp].tp = tp; + mlp++; + ofs += step; + } + step >>= 1; + tp -= 2; + } while (ofs < len); + return mlp; +} + +/* +** Emit copy list with windowed loads/stores. +** LJ_TARGET_UNALIGNED: may emit unaligned loads/stores (not marked as such). +*/ +static void crec_copy_emit(jit_State *J, CRecMemList *ml, MSize mlp, + TRef trdst, TRef trsrc) +{ + MSize i, j, rwin = 0; + for (i = 0, j = 0; i < mlp; ) { + TRef trofs = lj_ir_kintp(J, ml[i].ofs); + TRef trsptr = emitir(IRT(IR_ADD, IRT_PTR), trsrc, trofs); + ml[i].trval = emitir(IRT(IR_XLOAD, ml[i].tp), trsptr, 0); + ml[i].trofs = trofs; + i++; + rwin += (LJ_SOFTFP && ml[i].tp == IRT_NUM) ? 2 : 1; + if (rwin >= CREC_COPY_REGWIN || i >= mlp) { /* Flush buffered stores. */ + rwin = 0; + for ( ; j < i; j++) { + TRef trdptr = emitir(IRT(IR_ADD, IRT_PTR), trdst, ml[j].trofs); + emitir(IRT(IR_XSTORE, ml[j].tp), trdptr, ml[j].trval); + } + } + } +} + +/* Optimized memory copy. */ +static void crec_copy(jit_State *J, TRef trdst, TRef trsrc, TRef trlen, + CType *ct) +{ + if (tref_isk(trlen)) { /* Length must be constant. */ + CRecMemList ml[CREC_COPY_MAXUNROLL]; + MSize mlp = 0; + CTSize step = 1, len = (CTSize)IR(tref_ref(trlen))->i; + IRType tp = IRT_CDATA; + int needxbar = 0; + if (len == 0) return; /* Shortcut. */ + if (len > CREC_COPY_MAXLEN) goto fallback; + if (ct) { + CTState *cts = ctype_ctsG(J2G(J)); + lua_assert(ctype_isarray(ct->info) || ctype_isstruct(ct->info)); + if (ctype_isarray(ct->info)) { + CType *cct = ctype_rawchild(cts, ct); + tp = crec_ct2irt(cts, cct); + if (tp == IRT_CDATA) goto rawcopy; + step = lj_ir_type_size[tp]; + lua_assert((len & (step-1)) == 0); + } else if ((ct->info & CTF_UNION)) { + step = (1u << ctype_align(ct->info)); + goto rawcopy; + } else { + mlp = crec_copy_struct(ml, cts, ct); + goto emitcopy; + } + } else { + rawcopy: + needxbar = 1; + if (LJ_TARGET_UNALIGNED || step >= CTSIZE_PTR) + step = CTSIZE_PTR; + } + mlp = crec_copy_unroll(ml, len, step, tp); + emitcopy: + if (mlp) { + crec_copy_emit(J, ml, mlp, trdst, trsrc); + if (needxbar) + emitir(IRT(IR_XBAR, IRT_NIL), 0, 0); + return; + } + } +fallback: + /* Call memcpy. Always needs a barrier to disable alias analysis. */ + lj_ir_call(J, IRCALL_memcpy, trdst, trsrc, trlen); + emitir(IRT(IR_XBAR, IRT_NIL), 0, 0); +} + +/* Generate unrolled fill list, from highest to lowest step size/alignment. */ +static MSize crec_fill_unroll(CRecMemList *ml, CTSize len, CTSize step) +{ + CTSize ofs = 0; + MSize mlp = 0; + IRType tp = IRT_U8 + 2*lj_fls(step); + do { + while (ofs + step <= len) { + if (mlp >= CREC_COPY_MAXUNROLL) return 0; + ml[mlp].ofs = ofs; + ml[mlp].tp = tp; + mlp++; + ofs += step; + } + step >>= 1; + tp -= 2; + } while (ofs < len); + return mlp; +} + +/* +** Emit stores for fill list. +** LJ_TARGET_UNALIGNED: may emit unaligned stores (not marked as such). +*/ +static void crec_fill_emit(jit_State *J, CRecMemList *ml, MSize mlp, + TRef trdst, TRef trfill) +{ + MSize i; + for (i = 0; i < mlp; i++) { + TRef trofs = lj_ir_kintp(J, ml[i].ofs); + TRef trdptr = emitir(IRT(IR_ADD, IRT_PTR), trdst, trofs); + emitir(IRT(IR_XSTORE, ml[i].tp), trdptr, trfill); + } +} + +/* Optimized memory fill. */ +static void crec_fill(jit_State *J, TRef trdst, TRef trlen, TRef trfill, + CTSize step) +{ + if (tref_isk(trlen)) { /* Length must be constant. */ + CRecMemList ml[CREC_FILL_MAXUNROLL]; + MSize mlp; + CTSize len = (CTSize)IR(tref_ref(trlen))->i; + if (len == 0) return; /* Shortcut. */ + if (LJ_TARGET_UNALIGNED || step >= CTSIZE_PTR) + step = CTSIZE_PTR; + if (step * CREC_FILL_MAXUNROLL < len) goto fallback; + mlp = crec_fill_unroll(ml, len, step); + if (!mlp) goto fallback; + if (tref_isk(trfill) || ml[0].tp != IRT_U8) + trfill = emitconv(trfill, IRT_INT, IRT_U8, 0); + if (ml[0].tp != IRT_U8) { /* Scatter U8 to U16/U32/U64. */ + if (CTSIZE_PTR == 8 && ml[0].tp == IRT_U64) { + if (tref_isk(trfill)) /* Pointless on x64 with zero-extended regs. */ + trfill = emitconv(trfill, IRT_U64, IRT_U32, 0); + trfill = emitir(IRT(IR_MUL, IRT_U64), trfill, + lj_ir_kint64(J, U64x(01010101,01010101))); + } else { + trfill = emitir(IRTI(IR_MUL), trfill, + lj_ir_kint(J, ml[0].tp == IRT_U16 ? 0x0101 : 0x01010101)); + } + } + crec_fill_emit(J, ml, mlp, trdst, trfill); + } else { +fallback: + /* Call memset. Always needs a barrier to disable alias analysis. */ + lj_ir_call(J, IRCALL_memset, trdst, trfill, trlen); /* Note: arg order! */ + } + emitir(IRT(IR_XBAR, IRT_NIL), 0, 0); +} + +/* -- Convert C type to C type -------------------------------------------- */ + +/* +** This code mirrors the code in lj_cconv.c. It performs the same steps +** for the trace recorder that lj_cconv.c does for the interpreter. +** +** One major difference is that we can get away with much fewer checks +** here. E.g. checks for casts, constness or correct types can often be +** omitted, even if they might fail. The interpreter subsequently throws +** an error, which aborts the trace. +** +** All operations are specialized to their C types, so the on-trace +** outcome must be the same as the outcome in the interpreter. If the +** interpreter doesn't throw an error, then the trace is correct, too. +** Care must be taken not to generate invalid (temporary) IR or to +** trigger asserts. +*/ + +/* Determine whether a passed number or cdata number is non-zero. */ +static int crec_isnonzero(CType *s, void *p) +{ + if (p == (void *)0) + return 0; + if (p == (void *)1) + return 1; + if ((s->info & CTF_FP)) { + if (s->size == sizeof(float)) + return (*(float *)p != 0); + else + return (*(double *)p != 0); + } else { + if (s->size == 1) + return (*(uint8_t *)p != 0); + else if (s->size == 2) + return (*(uint16_t *)p != 0); + else if (s->size == 4) + return (*(uint32_t *)p != 0); + else + return (*(uint64_t *)p != 0); + } +} + +static TRef crec_ct_ct(jit_State *J, CType *d, CType *s, TRef dp, TRef sp, + void *svisnz) +{ + IRType dt = crec_ct2irt(ctype_ctsG(J2G(J)), d); + IRType st = crec_ct2irt(ctype_ctsG(J2G(J)), s); + CTSize dsize = d->size, ssize = s->size; + CTInfo dinfo = d->info, sinfo = s->info; + + if (ctype_type(dinfo) > CT_MAYCONVERT || ctype_type(sinfo) > CT_MAYCONVERT) + goto err_conv; + + /* + ** Note: Unlike lj_cconv_ct_ct(), sp holds the _value_ of pointers and + ** numbers up to 8 bytes. Otherwise sp holds a pointer. + */ + + switch (cconv_idx2(dinfo, sinfo)) { + /* Destination is a bool. */ + case CCX(B, B): + goto xstore; /* Source operand is already normalized. */ + case CCX(B, I): + case CCX(B, F): + if (st != IRT_CDATA) { + /* Specialize to the result of a comparison against 0. */ + TRef zero = (st == IRT_NUM || st == IRT_FLOAT) ? lj_ir_knum(J, 0) : + (st == IRT_I64 || st == IRT_U64) ? lj_ir_kint64(J, 0) : + lj_ir_kint(J, 0); + int isnz = crec_isnonzero(s, svisnz); + emitir(IRTG(isnz ? IR_NE : IR_EQ, st), sp, zero); + sp = lj_ir_kint(J, isnz); + goto xstore; + } + goto err_nyi; + + /* Destination is an integer. */ + case CCX(I, B): + case CCX(I, I): + conv_I_I: + if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; + /* Extend 32 to 64 bit integer. */ + if (dsize == 8 && ssize < 8 && !(LJ_64 && (sinfo & CTF_UNSIGNED))) + sp = emitconv(sp, dt, ssize < 4 ? IRT_INT : st, + (sinfo & CTF_UNSIGNED) ? 0 : IRCONV_SEXT); + else if (dsize < 8 && ssize == 8) /* Truncate from 64 bit integer. */ + sp = emitconv(sp, dsize < 4 ? IRT_INT : dt, st, 0); + else if (st == IRT_INT) + sp = lj_opt_narrow_toint(J, sp); + xstore: + if (dt == IRT_I64 || dt == IRT_U64) lj_needsplit(J); + if (dp == 0) return sp; + emitir(IRT(IR_XSTORE, dt), dp, sp); + break; + case CCX(I, C): + sp = emitir(IRT(IR_XLOAD, st), sp, 0); /* Load re. */ + /* fallthrough */ + case CCX(I, F): + if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; + sp = emitconv(sp, dsize < 4 ? IRT_INT : dt, st, IRCONV_TRUNC|IRCONV_ANY); + goto xstore; + case CCX(I, P): + case CCX(I, A): + sinfo = CTINFO(CT_NUM, CTF_UNSIGNED); + ssize = CTSIZE_PTR; + st = IRT_UINTP; + if (((dsize ^ ssize) & 8) == 0) { /* Must insert no-op type conversion. */ + sp = emitconv(sp, dsize < 4 ? IRT_INT : dt, IRT_PTR, 0); + goto xstore; + } + goto conv_I_I; + + /* Destination is a floating-point number. */ + case CCX(F, B): + case CCX(F, I): + conv_F_I: + if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; + sp = emitconv(sp, dt, ssize < 4 ? IRT_INT : st, 0); + goto xstore; + case CCX(F, C): + sp = emitir(IRT(IR_XLOAD, st), sp, 0); /* Load re. */ + /* fallthrough */ + case CCX(F, F): + conv_F_F: + if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; + if (dt != st) sp = emitconv(sp, dt, st, 0); + goto xstore; + + /* Destination is a complex number. */ + case CCX(C, I): + case CCX(C, F): + { /* Clear im. */ + TRef ptr = emitir(IRT(IR_ADD, IRT_PTR), dp, lj_ir_kintp(J, (dsize >> 1))); + emitir(IRT(IR_XSTORE, dt), ptr, lj_ir_knum(J, 0)); + } + /* Convert to re. */ + if ((sinfo & CTF_FP)) goto conv_F_F; else goto conv_F_I; + + case CCX(C, C): + if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; + { + TRef re, im, ptr; + re = emitir(IRT(IR_XLOAD, st), sp, 0); + ptr = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, (ssize >> 1))); + im = emitir(IRT(IR_XLOAD, st), ptr, 0); + if (dt != st) { + re = emitconv(re, dt, st, 0); + im = emitconv(im, dt, st, 0); + } + emitir(IRT(IR_XSTORE, dt), dp, re); + ptr = emitir(IRT(IR_ADD, IRT_PTR), dp, lj_ir_kintp(J, (dsize >> 1))); + emitir(IRT(IR_XSTORE, dt), ptr, im); + } + break; + + /* Destination is a vector. */ + case CCX(V, I): + case CCX(V, F): + case CCX(V, C): + case CCX(V, V): + goto err_nyi; + + /* Destination is a pointer. */ + case CCX(P, P): + case CCX(P, A): + case CCX(P, S): + /* There are only 32 bit pointers/addresses on 32 bit machines. + ** Also ok on x64, since all 32 bit ops clear the upper part of the reg. + */ + goto xstore; + case CCX(P, I): + if (st == IRT_CDATA) goto err_nyi; + if (!LJ_64 && ssize == 8) /* Truncate from 64 bit integer. */ + sp = emitconv(sp, IRT_U32, st, 0); + goto xstore; + case CCX(P, F): + if (st == IRT_CDATA) goto err_nyi; + /* The signed conversion is cheaper. x64 really has 47 bit pointers. */ + sp = emitconv(sp, (LJ_64 && dsize == 8) ? IRT_I64 : IRT_U32, + st, IRCONV_TRUNC|IRCONV_ANY); + goto xstore; + + /* Destination is an array. */ + case CCX(A, A): + /* Destination is a struct/union. */ + case CCX(S, S): + if (dp == 0) goto err_conv; + crec_copy(J, dp, sp, lj_ir_kint(J, dsize), d); + break; + + default: + err_conv: + err_nyi: + lj_trace_err(J, LJ_TRERR_NYICONV); + break; + } + return 0; +} + +/* -- Convert C type to TValue (load) ------------------------------------- */ + +static TRef crec_tv_ct(jit_State *J, CType *s, CTypeID sid, TRef sp) +{ + CTState *cts = ctype_ctsG(J2G(J)); + IRType t = crec_ct2irt(cts, s); + CTInfo sinfo = s->info; + if (ctype_isnum(sinfo)) { + TRef tr; + if (t == IRT_CDATA) + goto err_nyi; /* NYI: copyval of >64 bit integers. */ + tr = emitir(IRT(IR_XLOAD, t), sp, 0); + if (t == IRT_FLOAT || t == IRT_U32) { /* Keep uint32_t/float as numbers. */ + return emitconv(tr, IRT_NUM, t, 0); + } else if (t == IRT_I64 || t == IRT_U64) { /* Box 64 bit integer. */ + sp = tr; + lj_needsplit(J); + } else if ((sinfo & CTF_BOOL)) { + /* Assume not equal to zero. Fixup and emit pending guard later. */ + lj_ir_set(J, IRTGI(IR_NE), tr, lj_ir_kint(J, 0)); + J->postproc = LJ_POST_FIXGUARD; + return TREF_TRUE; + } else { + return tr; + } + } else if (ctype_isptr(sinfo) || ctype_isenum(sinfo)) { + sp = emitir(IRT(IR_XLOAD, t), sp, 0); /* Box pointers and enums. */ + } else if (ctype_isrefarray(sinfo) || ctype_isstruct(sinfo)) { + cts->L = J->L; + sid = lj_ctype_intern(cts, CTINFO_REF(sid), CTSIZE_PTR); /* Create ref. */ + } else if (ctype_iscomplex(sinfo)) { /* Unbox/box complex. */ + ptrdiff_t esz = (ptrdiff_t)(s->size >> 1); + TRef ptr, tr1, tr2, dp; + dp = emitir(IRTG(IR_CNEW, IRT_CDATA), lj_ir_kint(J, sid), TREF_NIL); + tr1 = emitir(IRT(IR_XLOAD, t), sp, 0); + ptr = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, esz)); + tr2 = emitir(IRT(IR_XLOAD, t), ptr, 0); + ptr = emitir(IRT(IR_ADD, IRT_PTR), dp, lj_ir_kintp(J, sizeof(GCcdata))); + emitir(IRT(IR_XSTORE, t), ptr, tr1); + ptr = emitir(IRT(IR_ADD, IRT_PTR), dp, lj_ir_kintp(J, sizeof(GCcdata)+esz)); + emitir(IRT(IR_XSTORE, t), ptr, tr2); + return dp; + } else { + /* NYI: copyval of vectors. */ + err_nyi: + lj_trace_err(J, LJ_TRERR_NYICONV); + } + /* Box pointer, ref, enum or 64 bit integer. */ + return emitir(IRTG(IR_CNEWI, IRT_CDATA), lj_ir_kint(J, sid), sp); +} + +/* -- Convert TValue to C type (store) ------------------------------------ */ + +static TRef crec_ct_tv(jit_State *J, CType *d, TRef dp, TRef sp, cTValue *sval) +{ + CTState *cts = ctype_ctsG(J2G(J)); + CTypeID sid = CTID_P_VOID; + void *svisnz = 0; + CType *s; + if (LJ_LIKELY(tref_isinteger(sp))) { + sid = CTID_INT32; + svisnz = (void *)(intptr_t)(tvisint(sval)?(intV(sval)!=0):!tviszero(sval)); + } else if (tref_isnum(sp)) { + sid = CTID_DOUBLE; + svisnz = (void *)(intptr_t)(tvisint(sval)?(intV(sval)!=0):!tviszero(sval)); + } else if (tref_isbool(sp)) { + sp = lj_ir_kint(J, tref_istrue(sp) ? 1 : 0); + sid = CTID_BOOL; + } else if (tref_isnil(sp)) { + sp = lj_ir_kptr(J, NULL); + } else if (tref_isudata(sp)) { + GCudata *ud = udataV(sval); + if (ud->udtype == UDTYPE_IO_FILE) { + TRef tr = emitir(IRT(IR_FLOAD, IRT_U8), sp, IRFL_UDATA_UDTYPE); + emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, UDTYPE_IO_FILE)); + sp = emitir(IRT(IR_FLOAD, IRT_PTR), sp, IRFL_UDATA_FILE); + } else { + sp = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, sizeof(GCudata))); + } + } else if (tref_isstr(sp)) { + if (ctype_isenum(d->info)) { /* Match string against enum constant. */ + GCstr *str = strV(sval); + CTSize ofs; + CType *cct = lj_ctype_getfield(cts, d, str, &ofs); + /* Specialize to the name of the enum constant. */ + emitir(IRTG(IR_EQ, IRT_STR), sp, lj_ir_kstr(J, str)); + if (cct && ctype_isconstval(cct->info)) { + lua_assert(ctype_child(cts, cct)->size == 4); + svisnz = (void *)(intptr_t)(ofs != 0); + sp = lj_ir_kint(J, (int32_t)ofs); + sid = ctype_cid(cct->info); + } /* else: interpreter will throw. */ + } else if (ctype_isrefarray(d->info)) { /* Copy string to array. */ + lj_trace_err(J, LJ_TRERR_BADTYPE); /* NYI */ + } else { /* Otherwise pass the string data as a const char[]. */ + /* Don't use STRREF. It folds with SNEW, which loses the trailing NUL. */ + sp = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, sizeof(GCstr))); + sid = CTID_A_CCHAR; + } + } else { /* NYI: tref_istab(sp), tref_islightud(sp). */ + IRType t; + sid = argv2cdata(J, sp, sval)->ctypeid; + s = ctype_raw(cts, sid); + svisnz = cdataptr(cdataV(sval)); + t = crec_ct2irt(cts, s); + if (ctype_isptr(s->info)) { + sp = emitir(IRT(IR_FLOAD, t), sp, IRFL_CDATA_PTR); + if (ctype_isref(s->info)) { + svisnz = *(void **)svisnz; + s = ctype_rawchild(cts, s); + if (ctype_isenum(s->info)) s = ctype_child(cts, s); + t = crec_ct2irt(cts, s); + } else { + goto doconv; + } + } else if (t == IRT_I64 || t == IRT_U64) { + sp = emitir(IRT(IR_FLOAD, t), sp, IRFL_CDATA_INT64); + lj_needsplit(J); + goto doconv; + } else if (t == IRT_INT || t == IRT_U32) { + if (ctype_isenum(s->info)) s = ctype_child(cts, s); + sp = emitir(IRT(IR_FLOAD, t), sp, IRFL_CDATA_INT); + goto doconv; + } else { + sp = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, sizeof(GCcdata))); + } + if (ctype_isnum(s->info) && t != IRT_CDATA) + sp = emitir(IRT(IR_XLOAD, t), sp, 0); /* Load number value. */ + goto doconv; + } + s = ctype_get(cts, sid); +doconv: + if (ctype_isenum(d->info)) d = ctype_child(cts, d); + return crec_ct_ct(J, d, s, dp, sp, svisnz); +} + +/* -- C data metamethods -------------------------------------------------- */ + +/* This would be rather difficult in FOLD, so do it here: +** (base+k)+(idx*sz)+ofs ==> (base+idx*sz)+(ofs+k) +** (base+(idx+k)*sz)+ofs ==> (base+idx*sz)+(ofs+k*sz) +*/ +static TRef crec_reassoc_ofs(jit_State *J, TRef tr, ptrdiff_t *ofsp, MSize sz) +{ + IRIns *ir = IR(tref_ref(tr)); + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && irref_isk(ir->op2) && + (ir->o == IR_ADD || ir->o == IR_ADDOV || ir->o == IR_SUBOV)) { + IRIns *irk = IR(ir->op2); + ptrdiff_t k; + if (LJ_64 && irk->o == IR_KINT64) + k = (ptrdiff_t)ir_kint64(irk)->u64 * sz; + else + k = (ptrdiff_t)irk->i * sz; + if (ir->o == IR_SUBOV) *ofsp -= k; else *ofsp += k; + tr = ir->op1; /* Not a TRef, but the caller doesn't care. */ + } + return tr; +} + +/* Record ctype __index/__newindex metamethods. */ +static void crec_index_meta(jit_State *J, CTState *cts, CType *ct, + RecordFFData *rd) +{ + CTypeID id = ctype_typeid(cts, ct); + cTValue *tv = lj_ctype_meta(cts, id, rd->data ? MM_newindex : MM_index); + if (!tv) + lj_trace_err(J, LJ_TRERR_BADTYPE); + if (tvisfunc(tv)) { + J->base[-1] = lj_ir_kfunc(J, funcV(tv)) | TREF_FRAME; + rd->nres = -1; /* Pending tailcall. */ + } else if (rd->data == 0 && tvistab(tv) && tref_isstr(J->base[1])) { + /* Specialize to result of __index lookup. */ + cTValue *o = lj_tab_get(J->L, tabV(tv), &rd->argv[1]); + J->base[0] = lj_record_constify(J, o); + if (!J->base[0]) + lj_trace_err(J, LJ_TRERR_BADTYPE); + /* Always specialize to the key. */ + emitir(IRTG(IR_EQ, IRT_STR), J->base[1], lj_ir_kstr(J, strV(&rd->argv[1]))); + } else { + /* NYI: resolving of non-function metamethods. */ + /* NYI: non-string keys for __index table. */ + /* NYI: stores to __newindex table. */ + lj_trace_err(J, LJ_TRERR_BADTYPE); + } +} + +void LJ_FASTCALL recff_cdata_index(jit_State *J, RecordFFData *rd) +{ + TRef idx, ptr = J->base[0]; + ptrdiff_t ofs = sizeof(GCcdata); + GCcdata *cd = argv2cdata(J, ptr, &rd->argv[0]); + CTState *cts = ctype_ctsG(J2G(J)); + CType *ct = ctype_raw(cts, cd->ctypeid); + CTypeID sid = 0; + + /* Resolve pointer or reference for cdata object. */ + if (ctype_isptr(ct->info)) { + IRType t = (LJ_64 && ct->size == 8) ? IRT_P64 : IRT_P32; + if (ctype_isref(ct->info)) ct = ctype_rawchild(cts, ct); + ptr = emitir(IRT(IR_FLOAD, t), ptr, IRFL_CDATA_PTR); + ofs = 0; + ptr = crec_reassoc_ofs(J, ptr, &ofs, 1); + } + +again: + idx = J->base[1]; + if (tref_isnumber(idx)) { + idx = lj_opt_narrow_cindex(J, idx); + if (ctype_ispointer(ct->info)) { + CTSize sz; + integer_key: + if ((ct->info & CTF_COMPLEX)) + idx = emitir(IRT(IR_BAND, IRT_INTP), idx, lj_ir_kintp(J, 1)); + sz = lj_ctype_size(cts, (sid = ctype_cid(ct->info))); + idx = crec_reassoc_ofs(J, idx, &ofs, sz); +#if LJ_TARGET_ARM || LJ_TARGET_PPC + /* Hoist base add to allow fusion of index/shift into operands. */ + if (LJ_LIKELY(J->flags & JIT_F_OPT_LOOP) && ofs +#if LJ_TARGET_ARM + && (sz == 1 || sz == 4) +#endif + ) { + ptr = emitir(IRT(IR_ADD, IRT_PTR), ptr, lj_ir_kintp(J, ofs)); + ofs = 0; + } +#endif + idx = emitir(IRT(IR_MUL, IRT_INTP), idx, lj_ir_kintp(J, sz)); + ptr = emitir(IRT(IR_ADD, IRT_PTR), idx, ptr); + } + } else if (tref_iscdata(idx)) { + GCcdata *cdk = cdataV(&rd->argv[1]); + CType *ctk = ctype_raw(cts, cdk->ctypeid); + IRType t = crec_ct2irt(cts, ctk); + if (ctype_ispointer(ct->info) && t >= IRT_I8 && t <= IRT_U64) { + if (ctk->size == 8) { + idx = emitir(IRT(IR_FLOAD, t), idx, IRFL_CDATA_INT64); + } else if (ctk->size == 4) { + idx = emitir(IRT(IR_FLOAD, t), idx, IRFL_CDATA_INT); + } else { + idx = emitir(IRT(IR_ADD, IRT_PTR), idx, + lj_ir_kintp(J, sizeof(GCcdata))); + idx = emitir(IRT(IR_XLOAD, t), idx, 0); + } + if (LJ_64 && ctk->size < sizeof(intptr_t) && !(ctk->info & CTF_UNSIGNED)) + idx = emitconv(idx, IRT_INTP, IRT_INT, IRCONV_SEXT); + if (!LJ_64 && ctk->size > sizeof(intptr_t)) { + idx = emitconv(idx, IRT_INTP, t, 0); + lj_needsplit(J); + } + goto integer_key; + } + } else if (tref_isstr(idx)) { + GCstr *name = strV(&rd->argv[1]); + if (cd && cd->ctypeid == CTID_CTYPEID) + ct = ctype_raw(cts, crec_constructor(J, cd, ptr)); + if (ctype_isstruct(ct->info)) { + CTSize fofs; + CType *fct; + fct = lj_ctype_getfield(cts, ct, name, &fofs); + if (fct) { + /* Always specialize to the field name. */ + emitir(IRTG(IR_EQ, IRT_STR), idx, lj_ir_kstr(J, name)); + if (ctype_isconstval(fct->info)) { + if (fct->size >= 0x80000000u && + (ctype_child(cts, fct)->info & CTF_UNSIGNED)) { + J->base[0] = lj_ir_knum(J, (lua_Number)(uint32_t)fct->size); + return; + } + J->base[0] = lj_ir_kint(J, (int32_t)fct->size); + return; /* Interpreter will throw for newindex. */ + } else if (ctype_isbitfield(fct->info)) { + lj_trace_err(J, LJ_TRERR_NYICONV); + } else { + lua_assert(ctype_isfield(fct->info)); + sid = ctype_cid(fct->info); + } + ofs += (ptrdiff_t)fofs; + } + } else if (ctype_iscomplex(ct->info)) { + if (name->len == 2 && + ((strdata(name)[0] == 'r' && strdata(name)[1] == 'e') || + (strdata(name)[0] == 'i' && strdata(name)[1] == 'm'))) { + /* Always specialize to the field name. */ + emitir(IRTG(IR_EQ, IRT_STR), idx, lj_ir_kstr(J, name)); + if (strdata(name)[0] == 'i') ofs += (ct->size >> 1); + sid = ctype_cid(ct->info); + } + } + } + if (!sid) { + if (ctype_isptr(ct->info)) { /* Automatically perform '->'. */ + CType *cct = ctype_rawchild(cts, ct); + if (ctype_isstruct(cct->info)) { + ct = cct; + cd = NULL; + if (tref_isstr(idx)) goto again; + } + } + crec_index_meta(J, cts, ct, rd); + return; + } + + if (ofs) + ptr = emitir(IRT(IR_ADD, IRT_PTR), ptr, lj_ir_kintp(J, ofs)); + + /* Resolve reference for field. */ + ct = ctype_get(cts, sid); + if (ctype_isref(ct->info)) { + ptr = emitir(IRT(IR_XLOAD, IRT_PTR), ptr, 0); + sid = ctype_cid(ct->info); + ct = ctype_get(cts, sid); + } + + while (ctype_isattrib(ct->info)) + ct = ctype_child(cts, ct); /* Skip attributes. */ + + if (rd->data == 0) { /* __index metamethod. */ + J->base[0] = crec_tv_ct(J, ct, sid, ptr); + } else { /* __newindex metamethod. */ + rd->nres = 0; + J->needsnap = 1; + crec_ct_tv(J, ct, ptr, J->base[2], &rd->argv[2]); + } +} + +/* Record setting a finalizer. */ +static void crec_finalizer(jit_State *J, TRef trcd, cTValue *fin) +{ + TRef trlo = lj_ir_call(J, IRCALL_lj_cdata_setfin, trcd); + TRef trhi = emitir(IRT(IR_ADD, IRT_P32), trlo, lj_ir_kint(J, 4)); + if (LJ_BE) { TRef tmp = trlo; trlo = trhi; trhi = tmp; } + if (tvisfunc(fin)) { + emitir(IRT(IR_XSTORE, IRT_P32), trlo, lj_ir_kfunc(J, funcV(fin))); + emitir(IRTI(IR_XSTORE), trhi, lj_ir_kint(J, LJ_TFUNC)); + } else if (tviscdata(fin)) { + emitir(IRT(IR_XSTORE, IRT_P32), trlo, + lj_ir_kgc(J, obj2gco(cdataV(fin)), IRT_CDATA)); + emitir(IRTI(IR_XSTORE), trhi, lj_ir_kint(J, LJ_TCDATA)); + } else { + lj_trace_err(J, LJ_TRERR_BADTYPE); + } + J->needsnap = 1; +} + +/* Record cdata allocation. */ +static void crec_alloc(jit_State *J, RecordFFData *rd, CTypeID id) +{ + CTState *cts = ctype_ctsG(J2G(J)); + CTSize sz; + CTInfo info = lj_ctype_info(cts, id, &sz); + CType *d = ctype_raw(cts, id); + TRef trid; + if (!sz || sz > 128 || (info & CTF_VLA) || ctype_align(info) > CT_MEMALIGN) + lj_trace_err(J, LJ_TRERR_NYICONV); /* NYI: large/special allocations. */ + trid = lj_ir_kint(J, id); + /* Use special instruction to box pointer or 32/64 bit integer. */ + if (ctype_isptr(info) || (ctype_isinteger(info) && (sz == 4 || sz == 8))) { + TRef sp = J->base[1] ? crec_ct_tv(J, d, 0, J->base[1], &rd->argv[1]) : + ctype_isptr(info) ? lj_ir_kptr(J, NULL) : + sz == 4 ? lj_ir_kint(J, 0) : + (lj_needsplit(J), lj_ir_kint64(J, 0)); + J->base[0] = emitir(IRTG(IR_CNEWI, IRT_CDATA), trid, sp); + } else { + TRef trcd = emitir(IRTG(IR_CNEW, IRT_CDATA), trid, TREF_NIL); + cTValue *fin; + J->base[0] = trcd; + if (J->base[1] && !J->base[2] && + !lj_cconv_multi_init(cts, d, &rd->argv[1])) { + goto single_init; + } else if (ctype_isarray(d->info)) { + CType *dc = ctype_rawchild(cts, d); /* Array element type. */ + CTSize ofs, esize = dc->size; + TRef sp = 0; + TValue tv; + TValue *sval = &tv; + MSize i; + tv.u64 = 0; + if (!(ctype_isnum(dc->info) || ctype_isptr(dc->info))) + lj_trace_err(J, LJ_TRERR_NYICONV); /* NYI: init array of aggregates. */ + for (i = 1, ofs = 0; ofs < sz; ofs += esize) { + TRef dp = emitir(IRT(IR_ADD, IRT_PTR), trcd, + lj_ir_kintp(J, ofs + sizeof(GCcdata))); + if (J->base[i]) { + sp = J->base[i]; + sval = &rd->argv[i]; + i++; + } else if (i != 2) { + sp = ctype_isnum(dc->info) ? lj_ir_kint(J, 0) : TREF_NIL; + } + crec_ct_tv(J, dc, dp, sp, sval); + } + } else if (ctype_isstruct(d->info)) { + CTypeID fid = d->sib; + MSize i = 1; + while (fid) { + CType *df = ctype_get(cts, fid); + fid = df->sib; + if (ctype_isfield(df->info)) { + CType *dc; + TRef sp, dp; + TValue tv; + TValue *sval = &tv; + setintV(&tv, 0); + if (!gcref(df->name)) continue; /* Ignore unnamed fields. */ + dc = ctype_rawchild(cts, df); /* Field type. */ + if (!(ctype_isnum(dc->info) || ctype_isptr(dc->info) || + ctype_isenum(dc->info))) + lj_trace_err(J, LJ_TRERR_NYICONV); /* NYI: init aggregates. */ + if (J->base[i]) { + sp = J->base[i]; + sval = &rd->argv[i]; + i++; + } else { + sp = ctype_isptr(dc->info) ? TREF_NIL : lj_ir_kint(J, 0); + } + dp = emitir(IRT(IR_ADD, IRT_PTR), trcd, + lj_ir_kintp(J, df->size + sizeof(GCcdata))); + crec_ct_tv(J, dc, dp, sp, sval); + } else if (!ctype_isconstval(df->info)) { + /* NYI: init bitfields and sub-structures. */ + lj_trace_err(J, LJ_TRERR_NYICONV); + } + } + } else { + TRef dp; + single_init: + dp = emitir(IRT(IR_ADD, IRT_PTR), trcd, lj_ir_kintp(J, sizeof(GCcdata))); + if (J->base[1]) { + crec_ct_tv(J, d, dp, J->base[1], &rd->argv[1]); + } else { + TValue tv; + tv.u64 = 0; + crec_ct_tv(J, d, dp, lj_ir_kint(J, 0), &tv); + } + } + /* Handle __gc metamethod. */ + fin = lj_ctype_meta(cts, id, MM_gc); + if (fin) + crec_finalizer(J, trcd, fin); + } +} + +/* Record argument conversions. */ +static TRef crec_call_args(jit_State *J, RecordFFData *rd, + CTState *cts, CType *ct) +{ + TRef args[CCI_NARGS_MAX]; + CTypeID fid; + MSize i, n; + TRef tr, *base; + cTValue *o; +#if LJ_TARGET_X86 +#if LJ_ABI_WIN + TRef *arg0 = NULL, *arg1 = NULL; +#endif + int ngpr = 0; + if (ctype_cconv(ct->info) == CTCC_THISCALL) + ngpr = 1; + else if (ctype_cconv(ct->info) == CTCC_FASTCALL) + ngpr = 2; +#endif + + /* Skip initial attributes. */ + fid = ct->sib; + while (fid) { + CType *ctf = ctype_get(cts, fid); + if (!ctype_isattrib(ctf->info)) break; + fid = ctf->sib; + } + args[0] = TREF_NIL; + for (n = 0, base = J->base+1, o = rd->argv+1; *base; n++, base++, o++) { + CTypeID did; + CType *d; + + if (n >= CCI_NARGS_MAX) + lj_trace_err(J, LJ_TRERR_NYICALL); + + if (fid) { /* Get argument type from field. */ + CType *ctf = ctype_get(cts, fid); + fid = ctf->sib; + lua_assert(ctype_isfield(ctf->info)); + did = ctype_cid(ctf->info); + } else { + if (!(ct->info & CTF_VARARG)) + lj_trace_err(J, LJ_TRERR_NYICALL); /* Too many arguments. */ + did = lj_ccall_ctid_vararg(cts, o); /* Infer vararg type. */ + } + d = ctype_raw(cts, did); + if (!(ctype_isnum(d->info) || ctype_isptr(d->info) || + ctype_isenum(d->info))) + lj_trace_err(J, LJ_TRERR_NYICALL); + tr = crec_ct_tv(J, d, 0, *base, o); + if (ctype_isinteger_or_bool(d->info)) { + if (d->size < 4) { + if ((d->info & CTF_UNSIGNED)) + tr = emitconv(tr, IRT_INT, d->size==1 ? IRT_U8 : IRT_U16, 0); + else + tr = emitconv(tr, IRT_INT, d->size==1 ? IRT_I8 : IRT_I16,IRCONV_SEXT); + } + } else if (LJ_SOFTFP && ctype_isfp(d->info) && d->size > 4) { + lj_needsplit(J); + } +#if LJ_TARGET_X86 + /* 64 bit args must not end up in registers for fastcall/thiscall. */ +#if LJ_ABI_WIN + if (!ctype_isfp(d->info)) { + /* Sigh, the Windows/x86 ABI allows reordering across 64 bit args. */ + if (tref_typerange(tr, IRT_I64, IRT_U64)) { + if (ngpr) { + arg0 = &args[n]; args[n++] = TREF_NIL; ngpr--; + if (ngpr) { + arg1 = &args[n]; args[n++] = TREF_NIL; ngpr--; + } + } + } else { + if (arg0) { *arg0 = tr; arg0 = NULL; n--; continue; } + if (arg1) { *arg1 = tr; arg1 = NULL; n--; continue; } + if (ngpr) ngpr--; + } + } +#else + if (!ctype_isfp(d->info) && ngpr) { + if (tref_typerange(tr, IRT_I64, IRT_U64)) { + /* No reordering for other x86 ABIs. Simply add alignment args. */ + do { args[n++] = TREF_NIL; } while (--ngpr); + } else { + ngpr--; + } + } +#endif +#endif + args[n] = tr; + } + tr = args[0]; + for (i = 1; i < n; i++) + tr = emitir(IRT(IR_CARG, IRT_NIL), tr, args[i]); + return tr; +} + +/* Create a snapshot for the caller, simulating a 'false' return value. */ +static void crec_snap_caller(jit_State *J) +{ + lua_State *L = J->L; + TValue *base = L->base, *top = L->top; + const BCIns *pc = J->pc; + TRef ftr = J->base[-1]; + ptrdiff_t delta; + if (!frame_islua(base-1) || J->framedepth <= 0) + lj_trace_err(J, LJ_TRERR_NYICALL); + J->pc = frame_pc(base-1); delta = 1+bc_a(J->pc[-1]); + L->top = base; L->base = base - delta; + J->base[-1] = TREF_FALSE; + J->base -= delta; J->baseslot -= (BCReg)delta; + J->maxslot = (BCReg)delta; J->framedepth--; + lj_snap_add(J); + L->base = base; L->top = top; + J->framedepth++; J->maxslot = 1; + J->base += delta; J->baseslot += (BCReg)delta; + J->base[-1] = ftr; J->pc = pc; +} + +/* Record function call. */ +static int crec_call(jit_State *J, RecordFFData *rd, GCcdata *cd) +{ + CTState *cts = ctype_ctsG(J2G(J)); + CType *ct = ctype_raw(cts, cd->ctypeid); + IRType tp = IRT_PTR; + if (ctype_isptr(ct->info)) { + tp = (LJ_64 && ct->size == 8) ? IRT_P64 : IRT_P32; + ct = ctype_rawchild(cts, ct); + } + if (ctype_isfunc(ct->info)) { + TRef func = emitir(IRT(IR_FLOAD, tp), J->base[0], IRFL_CDATA_PTR); + CType *ctr = ctype_rawchild(cts, ct); + IRType t = crec_ct2irt(cts, ctr); + TRef tr; + TValue tv; + /* Check for blacklisted C functions that might call a callback. */ + setlightudV(&tv, + cdata_getptr(cdataptr(cd), (LJ_64 && tp == IRT_P64) ? 8 : 4)); + if (tvistrue(lj_tab_get(J->L, cts->miscmap, &tv))) + lj_trace_err(J, LJ_TRERR_BLACKL); + if (ctype_isvoid(ctr->info)) { + t = IRT_NIL; + rd->nres = 0; + } else if (!(ctype_isnum(ctr->info) || ctype_isptr(ctr->info) || + ctype_isenum(ctr->info)) || t == IRT_CDATA) { + lj_trace_err(J, LJ_TRERR_NYICALL); + } + if ((ct->info & CTF_VARARG) +#if LJ_TARGET_X86 + || ctype_cconv(ct->info) != CTCC_CDECL +#endif + ) + func = emitir(IRT(IR_CARG, IRT_NIL), func, + lj_ir_kint(J, ctype_typeid(cts, ct))); + tr = emitir(IRT(IR_CALLXS, t), crec_call_args(J, rd, cts, ct), func); + if (ctype_isbool(ctr->info)) { + if (frame_islua(J->L->base-1) && bc_b(frame_pc(J->L->base-1)[-1]) == 1) { + /* Don't check result if ignored. */ + tr = TREF_NIL; + } else { + crec_snap_caller(J); +#if LJ_TARGET_X86ORX64 + /* Note: only the x86/x64 backend supports U8 and only for EQ(tr, 0). */ + lj_ir_set(J, IRTG(IR_NE, IRT_U8), tr, lj_ir_kint(J, 0)); +#else + lj_ir_set(J, IRTGI(IR_NE), tr, lj_ir_kint(J, 0)); +#endif + J->postproc = LJ_POST_FIXGUARDSNAP; + tr = TREF_TRUE; + } + } else if (t == IRT_PTR || (LJ_64 && t == IRT_P32) || + t == IRT_I64 || t == IRT_U64 || ctype_isenum(ctr->info)) { + TRef trid = lj_ir_kint(J, ctype_cid(ct->info)); + tr = emitir(IRTG(IR_CNEWI, IRT_CDATA), trid, tr); + if (t == IRT_I64 || t == IRT_U64) lj_needsplit(J); + } else if (t == IRT_FLOAT || t == IRT_U32) { + tr = emitconv(tr, IRT_NUM, t, 0); + } else if (t == IRT_I8 || t == IRT_I16) { + tr = emitconv(tr, IRT_INT, t, IRCONV_SEXT); + } else if (t == IRT_U8 || t == IRT_U16) { + tr = emitconv(tr, IRT_INT, t, 0); + } + J->base[0] = tr; + J->needsnap = 1; + return 1; + } + return 0; +} + +void LJ_FASTCALL recff_cdata_call(jit_State *J, RecordFFData *rd) +{ + CTState *cts = ctype_ctsG(J2G(J)); + GCcdata *cd = argv2cdata(J, J->base[0], &rd->argv[0]); + CTypeID id = cd->ctypeid; + CType *ct; + cTValue *tv; + MMS mm = MM_call; + if (id == CTID_CTYPEID) { + id = crec_constructor(J, cd, J->base[0]); + mm = MM_new; + } else if (crec_call(J, rd, cd)) { + return; + } + /* Record ctype __call/__new metamethod. */ + ct = ctype_raw(cts, id); + tv = lj_ctype_meta(cts, ctype_isptr(ct->info) ? ctype_cid(ct->info) : id, mm); + if (tv) { + if (tvisfunc(tv)) { + J->base[-1] = lj_ir_kfunc(J, funcV(tv)) | TREF_FRAME; + rd->nres = -1; /* Pending tailcall. */ + return; + } + } else if (mm == MM_new) { + crec_alloc(J, rd, id); + return; + } + /* No metamethod or NYI: non-function metamethods. */ + lj_trace_err(J, LJ_TRERR_BADTYPE); +} + +static TRef crec_arith_int64(jit_State *J, TRef *sp, CType **s, MMS mm) +{ + if (ctype_isnum(s[0]->info) && ctype_isnum(s[1]->info)) { + IRType dt; + CTypeID id; + TRef tr; + MSize i; + IROp op; + lj_needsplit(J); + if (((s[0]->info & CTF_UNSIGNED) && s[0]->size == 8) || + ((s[1]->info & CTF_UNSIGNED) && s[1]->size == 8)) { + dt = IRT_U64; id = CTID_UINT64; + } else { + dt = IRT_I64; id = CTID_INT64; + if (mm < MM_add && + !((s[0]->info | s[1]->info) & CTF_FP) && + s[0]->size == 4 && s[1]->size == 4) { /* Try to narrow comparison. */ + if (!((s[0]->info ^ s[1]->info) & CTF_UNSIGNED) || + (tref_isk(sp[1]) && IR(tref_ref(sp[1]))->i >= 0)) { + dt = (s[0]->info & CTF_UNSIGNED) ? IRT_U32 : IRT_INT; + goto comp; + } else if (tref_isk(sp[0]) && IR(tref_ref(sp[0]))->i >= 0) { + dt = (s[1]->info & CTF_UNSIGNED) ? IRT_U32 : IRT_INT; + goto comp; + } + } + } + for (i = 0; i < 2; i++) { + IRType st = tref_type(sp[i]); + if (st == IRT_NUM || st == IRT_FLOAT) + sp[i] = emitconv(sp[i], dt, st, IRCONV_TRUNC|IRCONV_ANY); + else if (!(st == IRT_I64 || st == IRT_U64)) + sp[i] = emitconv(sp[i], dt, IRT_INT, + (s[i]->info & CTF_UNSIGNED) ? 0 : IRCONV_SEXT); + } + if (mm < MM_add) { + comp: + /* Assume true comparison. Fixup and emit pending guard later. */ + if (mm == MM_eq) { + op = IR_EQ; + } else { + op = mm == MM_lt ? IR_LT : IR_LE; + if (dt == IRT_U32 || dt == IRT_U64) + op += (IR_ULT-IR_LT); + } + lj_ir_set(J, IRTG(op, dt), sp[0], sp[1]); + J->postproc = LJ_POST_FIXGUARD; + return TREF_TRUE; + } else { + tr = emitir(IRT(mm+(int)IR_ADD-(int)MM_add, dt), sp[0], sp[1]); + } + return emitir(IRTG(IR_CNEWI, IRT_CDATA), lj_ir_kint(J, id), tr); + } + return 0; +} + +static TRef crec_arith_ptr(jit_State *J, TRef *sp, CType **s, MMS mm) +{ + CTState *cts = ctype_ctsG(J2G(J)); + CType *ctp = s[0]; + if (ctype_isptr(ctp->info) || ctype_isrefarray(ctp->info)) { + if ((mm == MM_sub || mm == MM_eq || mm == MM_lt || mm == MM_le) && + (ctype_isptr(s[1]->info) || ctype_isrefarray(s[1]->info))) { + if (mm == MM_sub) { /* Pointer difference. */ + TRef tr; + CTSize sz = lj_ctype_size(cts, ctype_cid(ctp->info)); + if (sz == 0 || (sz & (sz-1)) != 0) + return 0; /* NYI: integer division. */ + tr = emitir(IRT(IR_SUB, IRT_INTP), sp[0], sp[1]); + tr = emitir(IRT(IR_BSAR, IRT_INTP), tr, lj_ir_kint(J, lj_fls(sz))); +#if LJ_64 + tr = emitconv(tr, IRT_NUM, IRT_INTP, 0); +#endif + return tr; + } else { /* Pointer comparison (unsigned). */ + /* Assume true comparison. Fixup and emit pending guard later. */ + IROp op = mm == MM_eq ? IR_EQ : mm == MM_lt ? IR_ULT : IR_ULE; + lj_ir_set(J, IRTG(op, IRT_PTR), sp[0], sp[1]); + J->postproc = LJ_POST_FIXGUARD; + return TREF_TRUE; + } + } + if (!((mm == MM_add || mm == MM_sub) && ctype_isnum(s[1]->info))) + return 0; + } else if (mm == MM_add && ctype_isnum(ctp->info) && + (ctype_isptr(s[1]->info) || ctype_isrefarray(s[1]->info))) { + TRef tr = sp[0]; sp[0] = sp[1]; sp[1] = tr; /* Swap pointer and index. */ + ctp = s[1]; + } else { + return 0; + } + { + TRef tr = sp[1]; + IRType t = tref_type(tr); + CTSize sz = lj_ctype_size(cts, ctype_cid(ctp->info)); + CTypeID id; +#if LJ_64 + if (t == IRT_NUM || t == IRT_FLOAT) + tr = emitconv(tr, IRT_INTP, t, IRCONV_TRUNC|IRCONV_ANY); + else if (!(t == IRT_I64 || t == IRT_U64)) + tr = emitconv(tr, IRT_INTP, IRT_INT, + ((t - IRT_I8) & 1) ? 0 : IRCONV_SEXT); +#else + if (!tref_typerange(sp[1], IRT_I8, IRT_U32)) { + tr = emitconv(tr, IRT_INTP, t, + (t == IRT_NUM || t == IRT_FLOAT) ? + IRCONV_TRUNC|IRCONV_ANY : 0); + } +#endif + tr = emitir(IRT(IR_MUL, IRT_INTP), tr, lj_ir_kintp(J, sz)); + tr = emitir(IRT(mm+(int)IR_ADD-(int)MM_add, IRT_PTR), sp[0], tr); + id = lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|ctype_cid(ctp->info)), + CTSIZE_PTR); + return emitir(IRTG(IR_CNEWI, IRT_CDATA), lj_ir_kint(J, id), tr); + } +} + +/* Record ctype arithmetic metamethods. */ +static TRef crec_arith_meta(jit_State *J, TRef *sp, CType **s, CTState *cts, + RecordFFData *rd) +{ + cTValue *tv = NULL; + if (J->base[0]) { + if (tviscdata(&rd->argv[0])) { + CTypeID id = argv2cdata(J, J->base[0], &rd->argv[0])->ctypeid; + CType *ct = ctype_raw(cts, id); + if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); + tv = lj_ctype_meta(cts, id, (MMS)rd->data); + } + if (!tv && J->base[1] && tviscdata(&rd->argv[1])) { + CTypeID id = argv2cdata(J, J->base[1], &rd->argv[1])->ctypeid; + CType *ct = ctype_raw(cts, id); + if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); + tv = lj_ctype_meta(cts, id, (MMS)rd->data); + } + } + if (tv) { + if (tvisfunc(tv)) { + J->base[-1] = lj_ir_kfunc(J, funcV(tv)) | TREF_FRAME; + rd->nres = -1; /* Pending tailcall. */ + return 0; + } /* NYI: non-function metamethods. */ + } else if ((MMS)rd->data == MM_eq) { /* Fallback cdata pointer comparison. */ + if (sp[0] && sp[1] && ctype_isnum(s[0]->info) == ctype_isnum(s[1]->info)) { + /* Assume true comparison. Fixup and emit pending guard later. */ + lj_ir_set(J, IRTG(IR_EQ, IRT_PTR), sp[0], sp[1]); + J->postproc = LJ_POST_FIXGUARD; + return TREF_TRUE; + } else { + return TREF_FALSE; + } + } + lj_trace_err(J, LJ_TRERR_BADTYPE); + return 0; +} + +void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd) +{ + CTState *cts = ctype_ctsG(J2G(J)); + TRef sp[2]; + CType *s[2]; + MSize i; + for (i = 0; i < 2; i++) { + TRef tr = J->base[i]; + CType *ct = ctype_get(cts, CTID_DOUBLE); + if (!tr) { + lj_trace_err(J, LJ_TRERR_BADTYPE); + } else if (tref_iscdata(tr)) { + CTypeID id = argv2cdata(J, tr, &rd->argv[i])->ctypeid; + IRType t; + ct = ctype_raw(cts, id); + t = crec_ct2irt(cts, ct); + if (ctype_isptr(ct->info)) { /* Resolve pointer or reference. */ + tr = emitir(IRT(IR_FLOAD, t), tr, IRFL_CDATA_PTR); + if (ctype_isref(ct->info)) { + ct = ctype_rawchild(cts, ct); + t = crec_ct2irt(cts, ct); + } + } else if (t == IRT_I64 || t == IRT_U64) { + tr = emitir(IRT(IR_FLOAD, t), tr, IRFL_CDATA_INT64); + lj_needsplit(J); + goto ok; + } else if (t == IRT_INT || t == IRT_U32) { + tr = emitir(IRT(IR_FLOAD, t), tr, IRFL_CDATA_INT); + if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); + goto ok; + } else if (ctype_isfunc(ct->info)) { + tr = emitir(IRT(IR_FLOAD, IRT_PTR), tr, IRFL_CDATA_PTR); + ct = ctype_get(cts, + lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|id), CTSIZE_PTR)); + goto ok; + } else { + tr = emitir(IRT(IR_ADD, IRT_PTR), tr, lj_ir_kintp(J, sizeof(GCcdata))); + } + if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); + if (ctype_isnum(ct->info)) { + if (t == IRT_CDATA) { + tr = 0; + } else { + if (t == IRT_I64 || t == IRT_U64) lj_needsplit(J); + tr = emitir(IRT(IR_XLOAD, t), tr, 0); + } + } + } else if (tref_isnil(tr)) { + tr = lj_ir_kptr(J, NULL); + ct = ctype_get(cts, CTID_P_VOID); + } else if (tref_isinteger(tr)) { + ct = ctype_get(cts, CTID_INT32); + } else if (tref_isstr(tr)) { + TRef tr2 = J->base[1-i]; + CTypeID id = argv2cdata(J, tr2, &rd->argv[1-i])->ctypeid; + ct = ctype_raw(cts, id); + if (ctype_isenum(ct->info)) { /* Match string against enum constant. */ + GCstr *str = strV(&rd->argv[i]); + CTSize ofs; + CType *cct = lj_ctype_getfield(cts, ct, str, &ofs); + if (cct && ctype_isconstval(cct->info)) { + /* Specialize to the name of the enum constant. */ + emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, str)); + ct = ctype_child(cts, cct); + tr = lj_ir_kint(J, (int32_t)ofs); + } else { /* Interpreter will throw or return false. */ + ct = ctype_get(cts, CTID_P_VOID); + } + } else if (ctype_isptr(ct->info)) { + tr = emitir(IRT(IR_ADD, IRT_PTR), tr, lj_ir_kintp(J, sizeof(GCstr))); + } else { + ct = ctype_get(cts, CTID_P_VOID); + } + } else if (!tref_isnum(tr)) { + tr = 0; + ct = ctype_get(cts, CTID_P_VOID); + } + ok: + s[i] = ct; + sp[i] = tr; + } + { + TRef tr; + if (!(tr = crec_arith_int64(J, sp, s, (MMS)rd->data)) && + !(tr = crec_arith_ptr(J, sp, s, (MMS)rd->data)) && + !(tr = crec_arith_meta(J, sp, s, cts, rd))) + return; + J->base[0] = tr; + /* Fixup cdata comparisons, too. Avoids some cdata escapes. */ + if (J->postproc == LJ_POST_FIXGUARD && frame_iscont(J->L->base-1) && + !irt_isguard(J->guardemit)) { + const BCIns *pc = frame_contpc(J->L->base-1) - 1; + if (bc_op(*pc) <= BC_ISNEP) { + setframe_pc(&J2G(J)->tmptv, pc); + J2G(J)->tmptv.u32.lo = ((tref_istrue(tr) ^ bc_op(*pc)) & 1); + J->postproc = LJ_POST_FIXCOMP; + } + } + } +} + +/* -- C library namespace metamethods ------------------------------------- */ + +void LJ_FASTCALL recff_clib_index(jit_State *J, RecordFFData *rd) +{ + CTState *cts = ctype_ctsG(J2G(J)); + if (tref_isudata(J->base[0]) && tref_isstr(J->base[1]) && + udataV(&rd->argv[0])->udtype == UDTYPE_FFI_CLIB) { + CLibrary *cl = (CLibrary *)uddata(udataV(&rd->argv[0])); + GCstr *name = strV(&rd->argv[1]); + CType *ct; + CTypeID id = lj_ctype_getname(cts, &ct, name, CLNS_INDEX); + cTValue *tv = lj_tab_getstr(cl->cache, name); + rd->nres = rd->data; + if (id && tv && !tvisnil(tv)) { + /* Specialize to the symbol name and make the result a constant. */ + emitir(IRTG(IR_EQ, IRT_STR), J->base[1], lj_ir_kstr(J, name)); + if (ctype_isconstval(ct->info)) { + if (ct->size >= 0x80000000u && + (ctype_child(cts, ct)->info & CTF_UNSIGNED)) + J->base[0] = lj_ir_knum(J, (lua_Number)(uint32_t)ct->size); + else + J->base[0] = lj_ir_kint(J, (int32_t)ct->size); + } else if (ctype_isextern(ct->info)) { + CTypeID sid = ctype_cid(ct->info); + void *sp = *(void **)cdataptr(cdataV(tv)); + TRef ptr; + ct = ctype_raw(cts, sid); + if (LJ_64 && !checkptr32(sp)) + ptr = lj_ir_kintp(J, (uintptr_t)sp); + else + ptr = lj_ir_kptr(J, sp); + if (rd->data) { + J->base[0] = crec_tv_ct(J, ct, sid, ptr); + } else { + J->needsnap = 1; + crec_ct_tv(J, ct, ptr, J->base[2], &rd->argv[2]); + } + } else { + J->base[0] = lj_ir_kgc(J, obj2gco(cdataV(tv)), IRT_CDATA); + } + } else { + lj_trace_err(J, LJ_TRERR_NOCACHE); + } + } /* else: interpreter will throw. */ +} + +/* -- FFI library functions ----------------------------------------------- */ + +static TRef crec_toint(jit_State *J, CTState *cts, TRef sp, TValue *sval) +{ + return crec_ct_tv(J, ctype_get(cts, CTID_INT32), 0, sp, sval); +} + +void LJ_FASTCALL recff_ffi_new(jit_State *J, RecordFFData *rd) +{ + crec_alloc(J, rd, argv2ctype(J, J->base[0], &rd->argv[0])); +} + +void LJ_FASTCALL recff_ffi_errno(jit_State *J, RecordFFData *rd) +{ + UNUSED(rd); + if (J->base[0]) + lj_trace_err(J, LJ_TRERR_NYICALL); + J->base[0] = lj_ir_call(J, IRCALL_lj_vm_errno); +} + +void LJ_FASTCALL recff_ffi_string(jit_State *J, RecordFFData *rd) +{ + CTState *cts = ctype_ctsG(J2G(J)); + TRef tr = J->base[0]; + if (tr) { + TRef trlen = J->base[1]; + if (!tref_isnil(trlen)) { + trlen = crec_toint(J, cts, trlen, &rd->argv[1]); + tr = crec_ct_tv(J, ctype_get(cts, CTID_P_CVOID), 0, tr, &rd->argv[0]); + } else { + tr = crec_ct_tv(J, ctype_get(cts, CTID_P_CCHAR), 0, tr, &rd->argv[0]); + trlen = lj_ir_call(J, IRCALL_strlen, tr); + } + J->base[0] = emitir(IRT(IR_XSNEW, IRT_STR), tr, trlen); + } /* else: interpreter will throw. */ +} + +void LJ_FASTCALL recff_ffi_copy(jit_State *J, RecordFFData *rd) +{ + CTState *cts = ctype_ctsG(J2G(J)); + TRef trdst = J->base[0], trsrc = J->base[1], trlen = J->base[2]; + if (trdst && trsrc && (trlen || tref_isstr(trsrc))) { + trdst = crec_ct_tv(J, ctype_get(cts, CTID_P_VOID), 0, trdst, &rd->argv[0]); + trsrc = crec_ct_tv(J, ctype_get(cts, CTID_P_CVOID), 0, trsrc, &rd->argv[1]); + if (trlen) { + trlen = crec_toint(J, cts, trlen, &rd->argv[2]); + } else { + trlen = emitir(IRTI(IR_FLOAD), J->base[1], IRFL_STR_LEN); + trlen = emitir(IRTI(IR_ADD), trlen, lj_ir_kint(J, 1)); + } + rd->nres = 0; + crec_copy(J, trdst, trsrc, trlen, NULL); + } /* else: interpreter will throw. */ +} + +void LJ_FASTCALL recff_ffi_fill(jit_State *J, RecordFFData *rd) +{ + CTState *cts = ctype_ctsG(J2G(J)); + TRef trdst = J->base[0], trlen = J->base[1], trfill = J->base[2]; + if (trdst && trlen) { + CTSize step = 1; + if (tviscdata(&rd->argv[0])) { /* Get alignment of original destination. */ + CTSize sz; + CType *ct = ctype_raw(cts, cdataV(&rd->argv[0])->ctypeid); + if (ctype_isptr(ct->info)) + ct = ctype_rawchild(cts, ct); + step = (1u<argv[0]); + trlen = crec_toint(J, cts, trlen, &rd->argv[1]); + if (trfill) + trfill = crec_toint(J, cts, trfill, &rd->argv[2]); + else + trfill = lj_ir_kint(J, 0); + rd->nres = 0; + crec_fill(J, trdst, trlen, trfill, step); + } /* else: interpreter will throw. */ +} + +void LJ_FASTCALL recff_ffi_typeof(jit_State *J, RecordFFData *rd) +{ + if (tref_iscdata(J->base[0])) { + TRef trid = lj_ir_kint(J, argv2ctype(J, J->base[0], &rd->argv[0])); + J->base[0] = emitir(IRTG(IR_CNEWI, IRT_CDATA), + lj_ir_kint(J, CTID_CTYPEID), trid); + } else { + setfuncV(J->L, &J->errinfo, J->fn); + lj_trace_err_info(J, LJ_TRERR_NYIFFU); + } +} + +void LJ_FASTCALL recff_ffi_istype(jit_State *J, RecordFFData *rd) +{ + argv2ctype(J, J->base[0], &rd->argv[0]); + if (tref_iscdata(J->base[1])) { + argv2ctype(J, J->base[1], &rd->argv[1]); + J->postproc = LJ_POST_FIXBOOL; + J->base[0] = TREF_TRUE; + } else { + J->base[0] = TREF_FALSE; + } +} + +void LJ_FASTCALL recff_ffi_abi(jit_State *J, RecordFFData *rd) +{ + if (tref_isstr(J->base[0])) { + /* Specialize to the ABI string to make the boolean result a constant. */ + emitir(IRTG(IR_EQ, IRT_STR), J->base[0], lj_ir_kstr(J, strV(&rd->argv[0]))); + J->postproc = LJ_POST_FIXBOOL; + J->base[0] = TREF_TRUE; + } else { + lj_trace_err(J, LJ_TRERR_BADTYPE); + } +} + +/* Record ffi.sizeof(), ffi.alignof(), ffi.offsetof(). */ +void LJ_FASTCALL recff_ffi_xof(jit_State *J, RecordFFData *rd) +{ + CTypeID id = argv2ctype(J, J->base[0], &rd->argv[0]); + if (rd->data == FF_ffi_sizeof) { + CType *ct = lj_ctype_rawref(ctype_ctsG(J2G(J)), id); + if (ctype_isvltype(ct->info)) + lj_trace_err(J, LJ_TRERR_BADTYPE); + } else if (rd->data == FF_ffi_offsetof) { /* Specialize to the field name. */ + if (!tref_isstr(J->base[1])) + lj_trace_err(J, LJ_TRERR_BADTYPE); + emitir(IRTG(IR_EQ, IRT_STR), J->base[1], lj_ir_kstr(J, strV(&rd->argv[1]))); + rd->nres = 3; /* Just in case. */ + } + J->postproc = LJ_POST_FIXCONST; + J->base[0] = J->base[1] = J->base[2] = TREF_NIL; +} + +void LJ_FASTCALL recff_ffi_gc(jit_State *J, RecordFFData *rd) +{ + argv2cdata(J, J->base[0], &rd->argv[0]); + crec_finalizer(J, J->base[0], &rd->argv[1]); +} + +/* -- Miscellaneous library functions ------------------------------------- */ + +void LJ_FASTCALL lj_crecord_tonumber(jit_State *J, RecordFFData *rd) +{ + CTState *cts = ctype_ctsG(J2G(J)); + CType *d, *ct = lj_ctype_rawref(cts, cdataV(&rd->argv[0])->ctypeid); + if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); + if (ctype_isnum(ct->info) || ctype_iscomplex(ct->info)) { + if (ctype_isinteger_or_bool(ct->info) && ct->size <= 4 && + !(ct->size == 4 && (ct->info & CTF_UNSIGNED))) + d = ctype_get(cts, CTID_INT32); + else + d = ctype_get(cts, CTID_DOUBLE); + J->base[0] = crec_ct_tv(J, d, 0, J->base[0], &rd->argv[0]); + } else { + J->base[0] = TREF_NIL; + } +} + +#undef IR +#undef emitir +#undef emitconv + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_crecord.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_crecord.h new file mode 100644 index 000000000..a4628caca --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_crecord.h @@ -0,0 +1,31 @@ +/* +** Trace recorder for C data operations. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_CRECORD_H +#define _LJ_CRECORD_H + +#include "lj_obj.h" +#include "lj_jit.h" +#include "lj_ffrecord.h" + +#if LJ_HASJIT && LJ_HASFFI +LJ_FUNC void LJ_FASTCALL recff_cdata_index(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_cdata_call(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_clib_index(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_new(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_errno(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_string(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_copy(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_fill(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_typeof(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_istype(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_abi(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_xof(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL recff_ffi_gc(jit_State *J, RecordFFData *rd); +LJ_FUNC void LJ_FASTCALL lj_crecord_tonumber(jit_State *J, RecordFFData *rd); +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_ctype.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ctype.c new file mode 100644 index 000000000..ac3017494 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ctype.c @@ -0,0 +1,634 @@ +/* +** C type management. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include "lj_obj.h" + +#if LJ_HASFFI + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_ctype.h" +#include "lj_ccallback.h" + +/* -- C type definitions -------------------------------------------------- */ + +/* Predefined typedefs. */ +#define CTTDDEF(_) \ + /* Vararg handling. */ \ + _("va_list", P_VOID) \ + _("__builtin_va_list", P_VOID) \ + _("__gnuc_va_list", P_VOID) \ + /* From stddef.h. */ \ + _("ptrdiff_t", INT_PSZ) \ + _("size_t", UINT_PSZ) \ + _("wchar_t", WCHAR) \ + /* Subset of stdint.h. */ \ + _("int8_t", INT8) \ + _("int16_t", INT16) \ + _("int32_t", INT32) \ + _("int64_t", INT64) \ + _("uint8_t", UINT8) \ + _("uint16_t", UINT16) \ + _("uint32_t", UINT32) \ + _("uint64_t", UINT64) \ + _("intptr_t", INT_PSZ) \ + _("uintptr_t", UINT_PSZ) \ + /* End of typedef list. */ + +/* Keywords (only the ones we actually care for). */ +#define CTKWDEF(_) \ + /* Type specifiers. */ \ + _("void", -1, CTOK_VOID) \ + _("_Bool", 0, CTOK_BOOL) \ + _("bool", 1, CTOK_BOOL) \ + _("char", 1, CTOK_CHAR) \ + _("int", 4, CTOK_INT) \ + _("__int8", 1, CTOK_INT) \ + _("__int16", 2, CTOK_INT) \ + _("__int32", 4, CTOK_INT) \ + _("__int64", 8, CTOK_INT) \ + _("float", 4, CTOK_FP) \ + _("double", 8, CTOK_FP) \ + _("long", 0, CTOK_LONG) \ + _("short", 0, CTOK_SHORT) \ + _("_Complex", 0, CTOK_COMPLEX) \ + _("complex", 0, CTOK_COMPLEX) \ + _("__complex", 0, CTOK_COMPLEX) \ + _("__complex__", 0, CTOK_COMPLEX) \ + _("signed", 0, CTOK_SIGNED) \ + _("__signed", 0, CTOK_SIGNED) \ + _("__signed__", 0, CTOK_SIGNED) \ + _("unsigned", 0, CTOK_UNSIGNED) \ + /* Type qualifiers. */ \ + _("const", 0, CTOK_CONST) \ + _("__const", 0, CTOK_CONST) \ + _("__const__", 0, CTOK_CONST) \ + _("volatile", 0, CTOK_VOLATILE) \ + _("__volatile", 0, CTOK_VOLATILE) \ + _("__volatile__", 0, CTOK_VOLATILE) \ + _("restrict", 0, CTOK_RESTRICT) \ + _("__restrict", 0, CTOK_RESTRICT) \ + _("__restrict__", 0, CTOK_RESTRICT) \ + _("inline", 0, CTOK_INLINE) \ + _("__inline", 0, CTOK_INLINE) \ + _("__inline__", 0, CTOK_INLINE) \ + /* Storage class specifiers. */ \ + _("typedef", 0, CTOK_TYPEDEF) \ + _("extern", 0, CTOK_EXTERN) \ + _("static", 0, CTOK_STATIC) \ + _("auto", 0, CTOK_AUTO) \ + _("register", 0, CTOK_REGISTER) \ + /* GCC Attributes. */ \ + _("__extension__", 0, CTOK_EXTENSION) \ + _("__attribute", 0, CTOK_ATTRIBUTE) \ + _("__attribute__", 0, CTOK_ATTRIBUTE) \ + _("asm", 0, CTOK_ASM) \ + _("__asm", 0, CTOK_ASM) \ + _("__asm__", 0, CTOK_ASM) \ + /* MSVC Attributes. */ \ + _("__declspec", 0, CTOK_DECLSPEC) \ + _("__cdecl", CTCC_CDECL, CTOK_CCDECL) \ + _("__thiscall", CTCC_THISCALL, CTOK_CCDECL) \ + _("__fastcall", CTCC_FASTCALL, CTOK_CCDECL) \ + _("__stdcall", CTCC_STDCALL, CTOK_CCDECL) \ + _("__ptr32", 4, CTOK_PTRSZ) \ + _("__ptr64", 8, CTOK_PTRSZ) \ + /* Other type specifiers. */ \ + _("struct", 0, CTOK_STRUCT) \ + _("union", 0, CTOK_UNION) \ + _("enum", 0, CTOK_ENUM) \ + /* Operators. */ \ + _("sizeof", 0, CTOK_SIZEOF) \ + _("__alignof", 0, CTOK_ALIGNOF) \ + _("__alignof__", 0, CTOK_ALIGNOF) \ + /* End of keyword list. */ + +/* Type info for predefined types. Size merged in. */ +static CTInfo lj_ctype_typeinfo[] = { +#define CTTYINFODEF(id, sz, ct, info) CTINFO((ct),(((sz)&0x3fu)<<10)+(info)), +#define CTTDINFODEF(name, id) CTINFO(CT_TYPEDEF, CTID_##id), +#define CTKWINFODEF(name, sz, kw) CTINFO(CT_KW,(((sz)&0x3fu)<<10)+(kw)), +CTTYDEF(CTTYINFODEF) +CTTDDEF(CTTDINFODEF) +CTKWDEF(CTKWINFODEF) +#undef CTTYINFODEF +#undef CTTDINFODEF +#undef CTKWINFODEF + 0 +}; + +/* Predefined type names collected in a single string. */ +static const char * const lj_ctype_typenames = +#define CTTDNAMEDEF(name, id) name "\0" +#define CTKWNAMEDEF(name, sz, cds) name "\0" +CTTDDEF(CTTDNAMEDEF) +CTKWDEF(CTKWNAMEDEF) +#undef CTTDNAMEDEF +#undef CTKWNAMEDEF +; + +#define CTTYPEINFO_NUM (sizeof(lj_ctype_typeinfo)/sizeof(CTInfo)-1) +#ifdef LUAJIT_CTYPE_CHECK_ANCHOR +#define CTTYPETAB_MIN CTTYPEINFO_NUM +#else +#define CTTYPETAB_MIN 128 +#endif + +/* -- C type interning ---------------------------------------------------- */ + +#define ct_hashtype(info, size) (hashrot(info, size) & CTHASH_MASK) +#define ct_hashname(name) \ + (hashrot(u32ptr(name), u32ptr(name) + HASH_BIAS) & CTHASH_MASK) + +/* Create new type element. */ +CTypeID lj_ctype_new(CTState *cts, CType **ctp) +{ + CTypeID id = cts->top; + CType *ct; + lua_assert(cts->L); + if (LJ_UNLIKELY(id >= cts->sizetab)) { + if (id >= CTID_MAX) lj_err_msg(cts->L, LJ_ERR_TABOV); +#ifdef LUAJIT_CTYPE_CHECK_ANCHOR + ct = lj_mem_newvec(cts->L, id+1, CType); + memcpy(ct, cts->tab, id*sizeof(CType)); + memset(cts->tab, 0, id*sizeof(CType)); + lj_mem_freevec(cts->g, cts->tab, cts->sizetab, CType); + cts->tab = ct; + cts->sizetab = id+1; +#else + lj_mem_growvec(cts->L, cts->tab, cts->sizetab, CTID_MAX, CType); +#endif + } + cts->top = id+1; + *ctp = ct = &cts->tab[id]; + ct->info = 0; + ct->size = 0; + ct->sib = 0; + ct->next = 0; + setgcrefnull(ct->name); + return id; +} + +/* Intern a type element. */ +CTypeID lj_ctype_intern(CTState *cts, CTInfo info, CTSize size) +{ + uint32_t h = ct_hashtype(info, size); + CTypeID id = cts->hash[h]; + lua_assert(cts->L); + while (id) { + CType *ct = ctype_get(cts, id); + if (ct->info == info && ct->size == size) + return id; + id = ct->next; + } + id = cts->top; + if (LJ_UNLIKELY(id >= cts->sizetab)) { + if (id >= CTID_MAX) lj_err_msg(cts->L, LJ_ERR_TABOV); + lj_mem_growvec(cts->L, cts->tab, cts->sizetab, CTID_MAX, CType); + } + cts->top = id+1; + cts->tab[id].info = info; + cts->tab[id].size = size; + cts->tab[id].sib = 0; + cts->tab[id].next = cts->hash[h]; + setgcrefnull(cts->tab[id].name); + cts->hash[h] = (CTypeID1)id; + return id; +} + +/* Add type element to hash table. */ +static void ctype_addtype(CTState *cts, CType *ct, CTypeID id) +{ + uint32_t h = ct_hashtype(ct->info, ct->size); + ct->next = cts->hash[h]; + cts->hash[h] = (CTypeID1)id; +} + +/* Add named element to hash table. */ +void lj_ctype_addname(CTState *cts, CType *ct, CTypeID id) +{ + uint32_t h = ct_hashname(gcref(ct->name)); + ct->next = cts->hash[h]; + cts->hash[h] = (CTypeID1)id; +} + +/* Get a C type by name, matching the type mask. */ +CTypeID lj_ctype_getname(CTState *cts, CType **ctp, GCstr *name, uint32_t tmask) +{ + CTypeID id = cts->hash[ct_hashname(name)]; + while (id) { + CType *ct = ctype_get(cts, id); + if (gcref(ct->name) == obj2gco(name) && + ((tmask >> ctype_type(ct->info)) & 1)) { + *ctp = ct; + return id; + } + id = ct->next; + } + *ctp = &cts->tab[0]; /* Simplify caller logic. ctype_get() would assert. */ + return 0; +} + +/* Get a struct/union/enum/function field by name. */ +CType *lj_ctype_getfieldq(CTState *cts, CType *ct, GCstr *name, CTSize *ofs, + CTInfo *qual) +{ + while (ct->sib) { + ct = ctype_get(cts, ct->sib); + if (gcref(ct->name) == obj2gco(name)) { + *ofs = ct->size; + return ct; + } + if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) { + CType *fct, *cct = ctype_child(cts, ct); + CTInfo q = 0; + while (ctype_isattrib(cct->info)) { + if (ctype_attrib(cct->info) == CTA_QUAL) q |= cct->size; + cct = ctype_child(cts, cct); + } + fct = lj_ctype_getfieldq(cts, cct, name, ofs, qual); + if (fct) { + if (qual) *qual |= q; + *ofs += ct->size; + return fct; + } + } + } + return NULL; /* Not found. */ +} + +/* -- C type information -------------------------------------------------- */ + +/* Follow references and get raw type for a C type ID. */ +CType *lj_ctype_rawref(CTState *cts, CTypeID id) +{ + CType *ct = ctype_get(cts, id); + while (ctype_isattrib(ct->info) || ctype_isref(ct->info)) + ct = ctype_child(cts, ct); + return ct; +} + +/* Get size for a C type ID. Does NOT support VLA/VLS. */ +CTSize lj_ctype_size(CTState *cts, CTypeID id) +{ + CType *ct = ctype_raw(cts, id); + return ctype_hassize(ct->info) ? ct->size : CTSIZE_INVALID; +} + +/* Get size for a variable-length C type. Does NOT support other C types. */ +CTSize lj_ctype_vlsize(CTState *cts, CType *ct, CTSize nelem) +{ + uint64_t xsz = 0; + if (ctype_isstruct(ct->info)) { + CTypeID arrid = 0, fid = ct->sib; + xsz = ct->size; /* Add the struct size. */ + while (fid) { + CType *ctf = ctype_get(cts, fid); + if (ctype_type(ctf->info) == CT_FIELD) + arrid = ctype_cid(ctf->info); /* Remember last field of VLS. */ + fid = ctf->sib; + } + ct = ctype_raw(cts, arrid); + } + lua_assert(ctype_isvlarray(ct->info)); /* Must be a VLA. */ + ct = ctype_rawchild(cts, ct); /* Get array element. */ + lua_assert(ctype_hassize(ct->info)); + /* Calculate actual size of VLA and check for overflow. */ + xsz += (uint64_t)ct->size * nelem; + return xsz < 0x80000000u ? (CTSize)xsz : CTSIZE_INVALID; +} + +/* Get type, qualifiers, size and alignment for a C type ID. */ +CTInfo lj_ctype_info(CTState *cts, CTypeID id, CTSize *szp) +{ + CTInfo qual = 0; + CType *ct = ctype_get(cts, id); + for (;;) { + CTInfo info = ct->info; + if (ctype_isenum(info)) { + /* Follow child. Need to look at its attributes, too. */ + } else if (ctype_isattrib(info)) { + if (ctype_isxattrib(info, CTA_QUAL)) + qual |= ct->size; + else if (ctype_isxattrib(info, CTA_ALIGN) && !(qual & CTFP_ALIGNED)) + qual |= CTFP_ALIGNED + CTALIGN(ct->size); + } else { + if (!(qual & CTFP_ALIGNED)) qual |= (info & CTF_ALIGN); + qual |= (info & ~(CTF_ALIGN|CTMASK_CID)); + lua_assert(ctype_hassize(info) || ctype_isfunc(info)); + *szp = ctype_isfunc(info) ? CTSIZE_INVALID : ct->size; + break; + } + ct = ctype_get(cts, ctype_cid(info)); + } + return qual; +} + +/* Get ctype metamethod. */ +cTValue *lj_ctype_meta(CTState *cts, CTypeID id, MMS mm) +{ + CType *ct = ctype_get(cts, id); + cTValue *tv; + while (ctype_isattrib(ct->info) || ctype_isref(ct->info)) { + id = ctype_cid(ct->info); + ct = ctype_get(cts, id); + } + if (ctype_isptr(ct->info) && + ctype_isfunc(ctype_get(cts, ctype_cid(ct->info))->info)) + tv = lj_tab_getstr(cts->miscmap, &cts->g->strempty); + else + tv = lj_tab_getinth(cts->miscmap, -(int32_t)id); + if (tv && tvistab(tv) && + (tv = lj_tab_getstr(tabV(tv), mmname_str(cts->g, mm))) && !tvisnil(tv)) + return tv; + return NULL; +} + +/* -- C type representation ----------------------------------------------- */ + +/* Fixed max. length of a C type representation. */ +#define CTREPR_MAX 512 + +typedef struct CTRepr { + char *pb, *pe; + CTState *cts; + lua_State *L; + int needsp; + int ok; + char buf[CTREPR_MAX]; +} CTRepr; + +/* Prepend string. */ +static void ctype_prepstr(CTRepr *ctr, const char *str, MSize len) +{ + char *p = ctr->pb; + if (ctr->buf + len+1 > p) { ctr->ok = 0; return; } + if (ctr->needsp) *--p = ' '; + ctr->needsp = 1; + p -= len; + while (len-- > 0) p[len] = str[len]; + ctr->pb = p; +} + +#define ctype_preplit(ctr, str) ctype_prepstr((ctr), "" str, sizeof(str)-1) + +/* Prepend char. */ +static void ctype_prepc(CTRepr *ctr, int c) +{ + if (ctr->buf >= ctr->pb) { ctr->ok = 0; return; } + *--ctr->pb = c; +} + +/* Prepend number. */ +static void ctype_prepnum(CTRepr *ctr, uint32_t n) +{ + char *p = ctr->pb; + if (ctr->buf + 10+1 > p) { ctr->ok = 0; return; } + do { *--p = (char)('0' + n % 10); } while (n /= 10); + ctr->pb = p; + ctr->needsp = 0; +} + +/* Append char. */ +static void ctype_appc(CTRepr *ctr, int c) +{ + if (ctr->pe >= ctr->buf + CTREPR_MAX) { ctr->ok = 0; return; } + *ctr->pe++ = c; +} + +/* Append number. */ +static void ctype_appnum(CTRepr *ctr, uint32_t n) +{ + char buf[10]; + char *p = buf+sizeof(buf); + char *q = ctr->pe; + if (q > ctr->buf + CTREPR_MAX - 10) { ctr->ok = 0; return; } + do { *--p = (char)('0' + n % 10); } while (n /= 10); + do { *q++ = *p++; } while (p < buf+sizeof(buf)); + ctr->pe = q; +} + +/* Prepend qualifiers. */ +static void ctype_prepqual(CTRepr *ctr, CTInfo info) +{ + if ((info & CTF_VOLATILE)) ctype_preplit(ctr, "volatile"); + if ((info & CTF_CONST)) ctype_preplit(ctr, "const"); +} + +/* Prepend named type. */ +static void ctype_preptype(CTRepr *ctr, CType *ct, CTInfo qual, const char *t) +{ + if (gcref(ct->name)) { + GCstr *str = gco2str(gcref(ct->name)); + ctype_prepstr(ctr, strdata(str), str->len); + } else { + if (ctr->needsp) ctype_prepc(ctr, ' '); + ctype_prepnum(ctr, ctype_typeid(ctr->cts, ct)); + ctr->needsp = 1; + } + ctype_prepstr(ctr, t, (MSize)strlen(t)); + ctype_prepqual(ctr, qual); +} + +static void ctype_repr(CTRepr *ctr, CTypeID id) +{ + CType *ct = ctype_get(ctr->cts, id); + CTInfo qual = 0; + int ptrto = 0; + for (;;) { + CTInfo info = ct->info; + CTSize size = ct->size; + switch (ctype_type(info)) { + case CT_NUM: + if ((info & CTF_BOOL)) { + ctype_preplit(ctr, "bool"); + } else if ((info & CTF_FP)) { + if (size == sizeof(double)) ctype_preplit(ctr, "double"); + else if (size == sizeof(float)) ctype_preplit(ctr, "float"); + else ctype_preplit(ctr, "long double"); + } else if (size == 1) { + if (!((info ^ CTF_UCHAR) & CTF_UNSIGNED)) ctype_preplit(ctr, "char"); + else if (CTF_UCHAR) ctype_preplit(ctr, "signed char"); + else ctype_preplit(ctr, "unsigned char"); + } else if (size < 8) { + if (size == 4) ctype_preplit(ctr, "int"); + else ctype_preplit(ctr, "short"); + if ((info & CTF_UNSIGNED)) ctype_preplit(ctr, "unsigned"); + } else { + ctype_preplit(ctr, "_t"); + ctype_prepnum(ctr, size*8); + ctype_preplit(ctr, "int"); + if ((info & CTF_UNSIGNED)) ctype_prepc(ctr, 'u'); + } + ctype_prepqual(ctr, (qual|info)); + return; + case CT_VOID: + ctype_preplit(ctr, "void"); + ctype_prepqual(ctr, (qual|info)); + return; + case CT_STRUCT: + ctype_preptype(ctr, ct, qual, (info & CTF_UNION) ? "union" : "struct"); + return; + case CT_ENUM: + if (id == CTID_CTYPEID) { + ctype_preplit(ctr, "ctype"); + return; + } + ctype_preptype(ctr, ct, qual, "enum"); + return; + case CT_ATTRIB: + if (ctype_attrib(info) == CTA_QUAL) qual |= size; + break; + case CT_PTR: + if ((info & CTF_REF)) { + ctype_prepc(ctr, '&'); + } else { + ctype_prepqual(ctr, (qual|info)); + if (LJ_64 && size == 4) ctype_preplit(ctr, "__ptr32"); + ctype_prepc(ctr, '*'); + } + qual = 0; + ptrto = 1; + ctr->needsp = 1; + break; + case CT_ARRAY: + if (ctype_isrefarray(info)) { + ctr->needsp = 1; + if (ptrto) { ptrto = 0; ctype_prepc(ctr, '('); ctype_appc(ctr, ')'); } + ctype_appc(ctr, '['); + if (size != CTSIZE_INVALID) { + CTSize csize = ctype_child(ctr->cts, ct)->size; + ctype_appnum(ctr, csize ? size/csize : 0); + } else if ((info & CTF_VLA)) { + ctype_appc(ctr, '?'); + } + ctype_appc(ctr, ']'); + } else if ((info & CTF_COMPLEX)) { + if (size == 2*sizeof(float)) ctype_preplit(ctr, "float"); + ctype_preplit(ctr, "complex"); + return; + } else { + ctype_preplit(ctr, ")))"); + ctype_prepnum(ctr, size); + ctype_preplit(ctr, "__attribute__((vector_size("); + } + break; + case CT_FUNC: + ctr->needsp = 1; + if (ptrto) { ptrto = 0; ctype_prepc(ctr, '('); ctype_appc(ctr, ')'); } + ctype_appc(ctr, '('); + ctype_appc(ctr, ')'); + break; + default: + lua_assert(0); + break; + } + ct = ctype_get(ctr->cts, ctype_cid(info)); + } +} + +/* Return a printable representation of a C type. */ +GCstr *lj_ctype_repr(lua_State *L, CTypeID id, GCstr *name) +{ + global_State *g = G(L); + CTRepr ctr; + ctr.pb = ctr.pe = &ctr.buf[CTREPR_MAX/2]; + ctr.cts = ctype_ctsG(g); + ctr.L = L; + ctr.ok = 1; + ctr.needsp = 0; + if (name) ctype_prepstr(&ctr, strdata(name), name->len); + ctype_repr(&ctr, id); + if (LJ_UNLIKELY(!ctr.ok)) return lj_str_newlit(L, "?"); + return lj_str_new(L, ctr.pb, ctr.pe - ctr.pb); +} + +/* Convert int64_t/uint64_t to string with 'LL' or 'ULL' suffix. */ +GCstr *lj_ctype_repr_int64(lua_State *L, uint64_t n, int isunsigned) +{ + char buf[1+20+3]; + char *p = buf+sizeof(buf); + int sign = 0; + *--p = 'L'; *--p = 'L'; + if (isunsigned) { + *--p = 'U'; + } else if ((int64_t)n < 0) { + n = (uint64_t)-(int64_t)n; + sign = 1; + } + do { *--p = (char)('0' + n % 10); } while (n /= 10); + if (sign) *--p = '-'; + return lj_str_new(L, p, (size_t)(buf+sizeof(buf)-p)); +} + +/* Convert complex to string with 'i' or 'I' suffix. */ +GCstr *lj_ctype_repr_complex(lua_State *L, void *sp, CTSize size) +{ + char buf[2*LJ_STR_NUMBUF+2+1]; + TValue re, im; + size_t len; + if (size == 2*sizeof(double)) { + re.n = *(double *)sp; im.n = ((double *)sp)[1]; + } else { + re.n = (double)*(float *)sp; im.n = (double)((float *)sp)[1]; + } + len = lj_str_bufnum(buf, &re); + if (!(im.u32.hi & 0x80000000u) || im.n != im.n) buf[len++] = '+'; + len += lj_str_bufnum(buf+len, &im); + buf[len] = buf[len-1] >= 'a' ? 'I' : 'i'; + return lj_str_new(L, buf, len+1); +} + +/* -- C type state -------------------------------------------------------- */ + +/* Initialize C type table and state. */ +CTState *lj_ctype_init(lua_State *L) +{ + CTState *cts = lj_mem_newt(L, sizeof(CTState), CTState); + CType *ct = lj_mem_newvec(L, CTTYPETAB_MIN, CType); + const char *name = lj_ctype_typenames; + CTypeID id; + memset(cts, 0, sizeof(CTState)); + cts->tab = ct; + cts->sizetab = CTTYPETAB_MIN; + cts->top = CTTYPEINFO_NUM; + cts->L = NULL; + cts->g = G(L); + for (id = 0; id < CTTYPEINFO_NUM; id++, ct++) { + CTInfo info = lj_ctype_typeinfo[id]; + ct->size = (CTSize)((int32_t)(info << 16) >> 26); + ct->info = info & 0xffff03ffu; + ct->sib = 0; + if (ctype_type(info) == CT_KW || ctype_istypedef(info)) { + size_t len = strlen(name); + GCstr *str = lj_str_new(L, name, len); + ctype_setname(ct, str); + name += len+1; + lj_ctype_addname(cts, ct, id); + } else { + setgcrefnull(ct->name); + ct->next = 0; + if (!ctype_isenum(info)) ctype_addtype(cts, ct, id); + } + } + setmref(G(L)->ctype_state, cts); + return cts; +} + +/* Free C type table and state. */ +void lj_ctype_freestate(global_State *g) +{ + CTState *cts = ctype_ctsG(g); + if (cts) { + lj_ccallback_mcode_free(cts); + lj_mem_freevec(g, cts->tab, cts->sizetab, CType); + lj_mem_freevec(g, cts->cb.cbid, cts->cb.sizeid, CTypeID1); + lj_mem_freet(g, cts); + } +} + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_ctype.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ctype.h new file mode 100644 index 000000000..3df26f095 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ctype.h @@ -0,0 +1,461 @@ +/* +** C type management. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_CTYPE_H +#define _LJ_CTYPE_H + +#include "lj_obj.h" +#include "lj_gc.h" + +#if LJ_HASFFI + +/* -- C type definitions -------------------------------------------------- */ + +/* C type numbers. Highest 4 bits of C type info. ORDER CT. */ +enum { + /* Externally visible types. */ + CT_NUM, /* Integer or floating-point numbers. */ + CT_STRUCT, /* Struct or union. */ + CT_PTR, /* Pointer or reference. */ + CT_ARRAY, /* Array or complex type. */ + CT_MAYCONVERT = CT_ARRAY, + CT_VOID, /* Void type. */ + CT_ENUM, /* Enumeration. */ + CT_HASSIZE = CT_ENUM, /* Last type where ct->size holds the actual size. */ + CT_FUNC, /* Function. */ + CT_TYPEDEF, /* Typedef. */ + CT_ATTRIB, /* Miscellaneous attributes. */ + /* Internal element types. */ + CT_FIELD, /* Struct/union field or function parameter. */ + CT_BITFIELD, /* Struct/union bitfield. */ + CT_CONSTVAL, /* Constant value. */ + CT_EXTERN, /* External reference. */ + CT_KW /* Keyword. */ +}; + +LJ_STATIC_ASSERT(((int)CT_PTR & (int)CT_ARRAY) == CT_PTR); +LJ_STATIC_ASSERT(((int)CT_STRUCT & (int)CT_ARRAY) == CT_STRUCT); + +/* +** ---------- info ------------ +** |type flags... A cid | size | sib | next | name | +** +----------------------------+--------+-------+-------+-------+-- +** |NUM BFvcUL.. A | size | | type | | +** |STRUCT ..vcU..V A | size | field | name? | name? | +** |PTR ..vcR... A cid | size | | type | | +** |ARRAY VCvc...V A cid | size | | type | | +** |VOID ..vc.... A | size | | type | | +** |ENUM A cid | size | const | name? | name? | +** |FUNC ....VS.. cc cid | nargs | field | name? | name? | +** |TYPEDEF cid | | | name | name | +** |ATTRIB attrnum cid | attr | sib? | type? | | +** |FIELD cid | offset | field | | name? | +** |BITFIELD B.vcU csz bsz pos | offset | field | | name? | +** |CONSTVAL c cid | value | const | name | name | +** |EXTERN cid | | sib? | name | name | +** |KW tok | size | | name | name | +** +----------------------------+--------+-------+-------+-------+-- +** ^^ ^^--- bits used for C type conversion dispatch +*/ + +/* C type info flags. TFFArrrr */ +#define CTF_BOOL 0x08000000u /* Boolean: NUM, BITFIELD. */ +#define CTF_FP 0x04000000u /* Floating-point: NUM. */ +#define CTF_CONST 0x02000000u /* Const qualifier. */ +#define CTF_VOLATILE 0x01000000u /* Volatile qualifier. */ +#define CTF_UNSIGNED 0x00800000u /* Unsigned: NUM, BITFIELD. */ +#define CTF_LONG 0x00400000u /* Long: NUM. */ +#define CTF_VLA 0x00100000u /* Variable-length: ARRAY, STRUCT. */ +#define CTF_REF 0x00800000u /* Reference: PTR. */ +#define CTF_VECTOR 0x08000000u /* Vector: ARRAY. */ +#define CTF_COMPLEX 0x04000000u /* Complex: ARRAY. */ +#define CTF_UNION 0x00800000u /* Union: STRUCT. */ +#define CTF_VARARG 0x00800000u /* Vararg: FUNC. */ +#define CTF_SSEREGPARM 0x00400000u /* SSE register parameters: FUNC. */ + +#define CTF_QUAL (CTF_CONST|CTF_VOLATILE) +#define CTF_ALIGN (CTMASK_ALIGN< 0 ? CTF_UNSIGNED : 0) + +/* Flags used in parser. .F.Ammvf cp->attr */ +#define CTFP_ALIGNED 0x00000001u /* cp->attr + ALIGN */ +#define CTFP_PACKED 0x00000002u /* cp->attr */ +/* ...C...f cp->fattr */ +#define CTFP_CCONV 0x00000001u /* cp->fattr + CCONV/[SSE]REGPARM */ + +/* C type info bitfields. */ +#define CTMASK_CID 0x0000ffffu /* Max. 65536 type IDs. */ +#define CTMASK_NUM 0xf0000000u /* Max. 16 type numbers. */ +#define CTSHIFT_NUM 28 +#define CTMASK_ALIGN 15 /* Max. alignment is 2^15. */ +#define CTSHIFT_ALIGN 16 +#define CTMASK_ATTRIB 255 /* Max. 256 attributes. */ +#define CTSHIFT_ATTRIB 16 +#define CTMASK_CCONV 3 /* Max. 4 calling conventions. */ +#define CTSHIFT_CCONV 16 +#define CTMASK_REGPARM 3 /* Max. 0-3 regparms. */ +#define CTSHIFT_REGPARM 18 +/* Bitfields only used in parser. */ +#define CTMASK_VSIZEP 15 /* Max. vector size is 2^15. */ +#define CTSHIFT_VSIZEP 4 +#define CTMASK_MSIZEP 255 /* Max. type size (via mode) is 128. */ +#define CTSHIFT_MSIZEP 8 + +/* Info bits for BITFIELD. Max. size of bitfield is 64 bits. */ +#define CTBSZ_MAX 32 /* Max. size of bitfield is 32 bit. */ +#define CTBSZ_FIELD 127 /* Temp. marker for regular field. */ +#define CTMASK_BITPOS 127 +#define CTMASK_BITBSZ 127 +#define CTMASK_BITCSZ 127 +#define CTSHIFT_BITPOS 0 +#define CTSHIFT_BITBSZ 8 +#define CTSHIFT_BITCSZ 16 + +#define CTF_INSERT(info, field, val) \ + info = (info & ~(CTMASK_##field<> CTSHIFT_NUM) +#define ctype_cid(info) ((CTypeID)((info) & CTMASK_CID)) +#define ctype_align(info) (((info) >> CTSHIFT_ALIGN) & CTMASK_ALIGN) +#define ctype_attrib(info) (((info) >> CTSHIFT_ATTRIB) & CTMASK_ATTRIB) +#define ctype_bitpos(info) (((info) >> CTSHIFT_BITPOS) & CTMASK_BITPOS) +#define ctype_bitbsz(info) (((info) >> CTSHIFT_BITBSZ) & CTMASK_BITBSZ) +#define ctype_bitcsz(info) (((info) >> CTSHIFT_BITCSZ) & CTMASK_BITCSZ) +#define ctype_vsizeP(info) (((info) >> CTSHIFT_VSIZEP) & CTMASK_VSIZEP) +#define ctype_msizeP(info) (((info) >> CTSHIFT_MSIZEP) & CTMASK_MSIZEP) +#define ctype_cconv(info) (((info) >> CTSHIFT_CCONV) & CTMASK_CCONV) + +/* Simple type checks. */ +#define ctype_isnum(info) (ctype_type((info)) == CT_NUM) +#define ctype_isvoid(info) (ctype_type((info)) == CT_VOID) +#define ctype_isptr(info) (ctype_type((info)) == CT_PTR) +#define ctype_isarray(info) (ctype_type((info)) == CT_ARRAY) +#define ctype_isstruct(info) (ctype_type((info)) == CT_STRUCT) +#define ctype_isfunc(info) (ctype_type((info)) == CT_FUNC) +#define ctype_isenum(info) (ctype_type((info)) == CT_ENUM) +#define ctype_istypedef(info) (ctype_type((info)) == CT_TYPEDEF) +#define ctype_isattrib(info) (ctype_type((info)) == CT_ATTRIB) +#define ctype_isfield(info) (ctype_type((info)) == CT_FIELD) +#define ctype_isbitfield(info) (ctype_type((info)) == CT_BITFIELD) +#define ctype_isconstval(info) (ctype_type((info)) == CT_CONSTVAL) +#define ctype_isextern(info) (ctype_type((info)) == CT_EXTERN) +#define ctype_hassize(info) (ctype_type((info)) <= CT_HASSIZE) + +/* Combined type and flag checks. */ +#define ctype_isinteger(info) \ + (((info) & (CTMASK_NUM|CTF_BOOL|CTF_FP)) == CTINFO(CT_NUM, 0)) +#define ctype_isinteger_or_bool(info) \ + (((info) & (CTMASK_NUM|CTF_FP)) == CTINFO(CT_NUM, 0)) +#define ctype_isbool(info) \ + (((info) & (CTMASK_NUM|CTF_BOOL)) == CTINFO(CT_NUM, CTF_BOOL)) +#define ctype_isfp(info) \ + (((info) & (CTMASK_NUM|CTF_FP)) == CTINFO(CT_NUM, CTF_FP)) + +#define ctype_ispointer(info) \ + ((ctype_type(info) >> 1) == (CT_PTR >> 1)) /* Pointer or array. */ +#define ctype_isref(info) \ + (((info) & (CTMASK_NUM|CTF_REF)) == CTINFO(CT_PTR, CTF_REF)) + +#define ctype_isrefarray(info) \ + (((info) & (CTMASK_NUM|CTF_VECTOR|CTF_COMPLEX)) == CTINFO(CT_ARRAY, 0)) +#define ctype_isvector(info) \ + (((info) & (CTMASK_NUM|CTF_VECTOR)) == CTINFO(CT_ARRAY, CTF_VECTOR)) +#define ctype_iscomplex(info) \ + (((info) & (CTMASK_NUM|CTF_COMPLEX)) == CTINFO(CT_ARRAY, CTF_COMPLEX)) + +#define ctype_isvltype(info) \ + (((info) & ((CTMASK_NUM|CTF_VLA) - (2u<") _(STRING, "") \ + _(INTEGER, "") _(EOF, "") \ + _(OROR, "||") _(ANDAND, "&&") _(EQ, "==") _(NE, "!=") \ + _(LE, "<=") _(GE, ">=") _(SHL, "<<") _(SHR, ">>") _(DEREF, "->") + +/* Simple declaration specifiers. */ +#define CDSDEF(_) \ + _(VOID) _(BOOL) _(CHAR) _(INT) _(FP) \ + _(LONG) _(LONGLONG) _(SHORT) _(COMPLEX) _(SIGNED) _(UNSIGNED) \ + _(CONST) _(VOLATILE) _(RESTRICT) _(INLINE) \ + _(TYPEDEF) _(EXTERN) _(STATIC) _(AUTO) _(REGISTER) + +/* C keywords. */ +#define CKWDEF(_) \ + CDSDEF(_) _(EXTENSION) _(ASM) _(ATTRIBUTE) \ + _(DECLSPEC) _(CCDECL) _(PTRSZ) \ + _(STRUCT) _(UNION) _(ENUM) \ + _(SIZEOF) _(ALIGNOF) + +/* C token numbers. */ +enum { + CTOK_OFS = 255, +#define CTOKNUM(name, sym) CTOK_##name, +#define CKWNUM(name) CTOK_##name, +CTOKDEF(CTOKNUM) +CKWDEF(CKWNUM) +#undef CTOKNUM +#undef CKWNUM + CTOK_FIRSTDECL = CTOK_VOID, + CTOK_FIRSTSCL = CTOK_TYPEDEF, + CTOK_LASTDECLFLAG = CTOK_REGISTER, + CTOK_LASTDECL = CTOK_ENUM +}; + +/* Declaration specifier flags. */ +enum { +#define CDSFLAG(name) CDF_##name = (1u << (CTOK_##name - CTOK_FIRSTDECL)), +CDSDEF(CDSFLAG) +#undef CDSFLAG + CDF__END +}; + +#define CDF_SCL (CDF_TYPEDEF|CDF_EXTERN|CDF_STATIC|CDF_AUTO|CDF_REGISTER) + +/* -- C type management --------------------------------------------------- */ + +#define ctype_ctsG(g) (mref((g)->ctype_state, CTState)) + +/* Get C type state. */ +static LJ_AINLINE CTState *ctype_cts(lua_State *L) +{ + CTState *cts = ctype_ctsG(G(L)); + cts->L = L; /* Save L for errors and allocations. */ + return cts; +} + +/* Save and restore state of C type table. */ +#define LJ_CTYPE_SAVE(cts) CTState savects_ = *(cts) +#define LJ_CTYPE_RESTORE(cts) \ + ((cts)->top = savects_.top, \ + memcpy((cts)->hash, savects_.hash, sizeof(savects_.hash))) + +/* Check C type ID for validity when assertions are enabled. */ +static LJ_AINLINE CTypeID ctype_check(CTState *cts, CTypeID id) +{ + lua_assert(id > 0 && id < cts->top); UNUSED(cts); + return id; +} + +/* Get C type for C type ID. */ +static LJ_AINLINE CType *ctype_get(CTState *cts, CTypeID id) +{ + return &cts->tab[ctype_check(cts, id)]; +} + +/* Get C type ID for a C type. */ +#define ctype_typeid(cts, ct) ((CTypeID)((ct) - (cts)->tab)) + +/* Get child C type. */ +static LJ_AINLINE CType *ctype_child(CTState *cts, CType *ct) +{ + lua_assert(!(ctype_isvoid(ct->info) || ctype_isstruct(ct->info) || + ctype_isbitfield(ct->info))); /* These don't have children. */ + return ctype_get(cts, ctype_cid(ct->info)); +} + +/* Get raw type for a C type ID. */ +static LJ_AINLINE CType *ctype_raw(CTState *cts, CTypeID id) +{ + CType *ct = ctype_get(cts, id); + while (ctype_isattrib(ct->info)) ct = ctype_child(cts, ct); + return ct; +} + +/* Get raw type of the child of a C type. */ +static LJ_AINLINE CType *ctype_rawchild(CTState *cts, CType *ct) +{ + do { ct = ctype_child(cts, ct); } while (ctype_isattrib(ct->info)); + return ct; +} + +/* Set the name of a C type table element. */ +static LJ_AINLINE void ctype_setname(CType *ct, GCstr *s) +{ + /* NOBARRIER: mark string as fixed -- the C type table is never collected. */ + fixstring(s); + setgcref(ct->name, obj2gco(s)); +} + +LJ_FUNC CTypeID lj_ctype_new(CTState *cts, CType **ctp); +LJ_FUNC CTypeID lj_ctype_intern(CTState *cts, CTInfo info, CTSize size); +LJ_FUNC void lj_ctype_addname(CTState *cts, CType *ct, CTypeID id); +LJ_FUNC CTypeID lj_ctype_getname(CTState *cts, CType **ctp, GCstr *name, + uint32_t tmask); +LJ_FUNC CType *lj_ctype_getfieldq(CTState *cts, CType *ct, GCstr *name, + CTSize *ofs, CTInfo *qual); +#define lj_ctype_getfield(cts, ct, name, ofs) \ + lj_ctype_getfieldq((cts), (ct), (name), (ofs), NULL) +LJ_FUNC CType *lj_ctype_rawref(CTState *cts, CTypeID id); +LJ_FUNC CTSize lj_ctype_size(CTState *cts, CTypeID id); +LJ_FUNC CTSize lj_ctype_vlsize(CTState *cts, CType *ct, CTSize nelem); +LJ_FUNC CTInfo lj_ctype_info(CTState *cts, CTypeID id, CTSize *szp); +LJ_FUNC cTValue *lj_ctype_meta(CTState *cts, CTypeID id, MMS mm); +LJ_FUNC GCstr *lj_ctype_repr(lua_State *L, CTypeID id, GCstr *name); +LJ_FUNC GCstr *lj_ctype_repr_int64(lua_State *L, uint64_t n, int isunsigned); +LJ_FUNC GCstr *lj_ctype_repr_complex(lua_State *L, void *sp, CTSize size); +LJ_FUNC CTState *lj_ctype_init(lua_State *L); +LJ_FUNC void lj_ctype_freestate(global_State *g); + +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_debug.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_debug.c new file mode 100644 index 000000000..bd2fa1f56 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_debug.c @@ -0,0 +1,605 @@ +/* +** Debugging and introspection. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_debug_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_err.h" +#include "lj_debug.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_state.h" +#include "lj_frame.h" +#include "lj_bc.h" +#include "lj_vm.h" +#if LJ_HASJIT +#include "lj_jit.h" +#endif + +/* -- Frames -------------------------------------------------------------- */ + +/* Get frame corresponding to a level. */ +cTValue *lj_debug_frame(lua_State *L, int level, int *size) +{ + cTValue *frame, *nextframe, *bot = tvref(L->stack); + /* Traverse frames backwards. */ + for (nextframe = frame = L->base-1; frame > bot; ) { + if (frame_gc(frame) == obj2gco(L)) + level++; /* Skip dummy frames. See lj_meta_call(). */ + if (level-- == 0) { + *size = (int)(nextframe - frame); + return frame; /* Level found. */ + } + nextframe = frame; + if (frame_islua(frame)) { + frame = frame_prevl(frame); + } else { + if (frame_isvarg(frame)) + level++; /* Skip vararg pseudo-frame. */ + frame = frame_prevd(frame); + } + } + *size = level; + return NULL; /* Level not found. */ +} + +/* Invalid bytecode position. */ +#define NO_BCPOS (~(BCPos)0) + +/* Return bytecode position for function/frame or NO_BCPOS. */ +static BCPos debug_framepc(lua_State *L, GCfunc *fn, cTValue *nextframe) +{ + const BCIns *ins; + GCproto *pt; + BCPos pos; + lua_assert(fn->c.gct == ~LJ_TFUNC || fn->c.gct == ~LJ_TTHREAD); + if (!isluafunc(fn)) { /* Cannot derive a PC for non-Lua functions. */ + return NO_BCPOS; + } else if (nextframe == NULL) { /* Lua function on top. */ + void *cf = cframe_raw(L->cframe); + if (cf == NULL || (char *)cframe_pc(cf) == (char *)cframe_L(cf)) + return NO_BCPOS; + ins = cframe_pc(cf); /* Only happens during error/hook handling. */ + } else { + if (frame_islua(nextframe)) { + ins = frame_pc(nextframe); + } else if (frame_iscont(nextframe)) { + ins = frame_contpc(nextframe); + } else { + /* Lua function below errfunc/gc/hook: find cframe to get the PC. */ + void *cf = cframe_raw(L->cframe); + TValue *f = L->base-1; + for (;;) { + if (cf == NULL) + return NO_BCPOS; + while (cframe_nres(cf) < 0) { + if (f >= restorestack(L, -cframe_nres(cf))) + break; + cf = cframe_raw(cframe_prev(cf)); + if (cf == NULL) + return NO_BCPOS; + } + if (f < nextframe) + break; + if (frame_islua(f)) { + f = frame_prevl(f); + } else { + if (frame_isc(f) || (LJ_HASFFI && frame_iscont(f) && + (f-1)->u32.lo == LJ_CONT_FFI_CALLBACK)) + cf = cframe_raw(cframe_prev(cf)); + f = frame_prevd(f); + } + } + ins = cframe_pc(cf); + } + } + pt = funcproto(fn); + pos = proto_bcpos(pt, ins) - 1; +#if LJ_HASJIT + if (pos > pt->sizebc) { /* Undo the effects of lj_trace_exit for JLOOP. */ + GCtrace *T = (GCtrace *)((char *)(ins-1) - offsetof(GCtrace, startins)); + lua_assert(bc_isret(bc_op(ins[-1]))); + pos = proto_bcpos(pt, mref(T->startpc, const BCIns)); + } +#endif + return pos; +} + +/* -- Line numbers -------------------------------------------------------- */ + +/* Get line number for a bytecode position. */ +BCLine LJ_FASTCALL lj_debug_line(GCproto *pt, BCPos pc) +{ + const void *lineinfo = proto_lineinfo(pt); + if (pc <= pt->sizebc && lineinfo) { + BCLine first = pt->firstline; + if (pc == pt->sizebc) return first + pt->numline; + if (pc-- == 0) return first; + if (pt->numline < 256) + return first + (BCLine)((const uint8_t *)lineinfo)[pc]; + else if (pt->numline < 65536) + return first + (BCLine)((const uint16_t *)lineinfo)[pc]; + else + return first + (BCLine)((const uint32_t *)lineinfo)[pc]; + } + return 0; +} + +/* Get line number for function/frame. */ +static BCLine debug_frameline(lua_State *L, GCfunc *fn, cTValue *nextframe) +{ + BCPos pc = debug_framepc(L, fn, nextframe); + if (pc != NO_BCPOS) { + GCproto *pt = funcproto(fn); + lua_assert(pc <= pt->sizebc); + return lj_debug_line(pt, pc); + } + return -1; +} + +/* -- Variable names ------------------------------------------------------ */ + +/* Read ULEB128 value. */ +static uint32_t debug_read_uleb128(const uint8_t **pp) +{ + const uint8_t *p = *pp; + uint32_t v = *p++; + if (LJ_UNLIKELY(v >= 0x80)) { + int sh = 0; + v &= 0x7f; + do { v |= ((*p & 0x7f) << (sh += 7)); } while (*p++ >= 0x80); + } + *pp = p; + return v; +} + +/* Get name of a local variable from slot number and PC. */ +static const char *debug_varname(const GCproto *pt, BCPos pc, BCReg slot) +{ + const uint8_t *p = proto_varinfo(pt); + if (p) { + BCPos lastpc = 0; + for (;;) { + const char *name = (const char *)p; + uint32_t vn = *p++; + BCPos startpc, endpc; + if (vn < VARNAME__MAX) { + if (vn == VARNAME_END) break; /* End of varinfo. */ + } else { + while (*p++) ; /* Skip over variable name string. */ + } + lastpc = startpc = lastpc + debug_read_uleb128(&p); + if (startpc > pc) break; + endpc = startpc + debug_read_uleb128(&p); + if (pc < endpc && slot-- == 0) { + if (vn < VARNAME__MAX) { +#define VARNAMESTR(name, str) str "\0" + name = VARNAMEDEF(VARNAMESTR); +#undef VARNAMESTR + if (--vn) while (*name++ || --vn) ; + } + return name; + } + } + } + return NULL; +} + +/* Get name of local variable from 1-based slot number and function/frame. */ +static TValue *debug_localname(lua_State *L, const lua_Debug *ar, + const char **name, BCReg slot1) +{ + uint32_t offset = (uint32_t)ar->i_ci & 0xffff; + uint32_t size = (uint32_t)ar->i_ci >> 16; + TValue *frame = tvref(L->stack) + offset; + TValue *nextframe = size ? frame + size : NULL; + GCfunc *fn = frame_func(frame); + BCPos pc = debug_framepc(L, fn, nextframe); + if (!nextframe) nextframe = L->top; + if ((int)slot1 < 0) { /* Negative slot number is for varargs. */ + if (pc != NO_BCPOS) { + GCproto *pt = funcproto(fn); + if ((pt->flags & PROTO_VARARG)) { + slot1 = pt->numparams + (BCReg)(-(int)slot1); + if (frame_isvarg(frame)) { /* Vararg frame has been set up? (pc!=0) */ + nextframe = frame; + frame = frame_prevd(frame); + } + if (frame + slot1 < nextframe) { + *name = "(*vararg)"; + return frame+slot1; + } + } + } + return NULL; + } + if (pc != NO_BCPOS && + (*name = debug_varname(funcproto(fn), pc, slot1-1)) != NULL) + ; + else if (slot1 > 0 && frame + slot1 < nextframe) + *name = "(*temporary)"; + return frame+slot1; +} + +/* Get name of upvalue. */ +const char *lj_debug_uvname(GCproto *pt, uint32_t idx) +{ + const uint8_t *p = proto_uvinfo(pt); + lua_assert(idx < pt->sizeuv); + if (!p) return ""; + if (idx) while (*p++ || --idx) ; + return (const char *)p; +} + +/* Get name and value of upvalue. */ +const char *lj_debug_uvnamev(cTValue *o, uint32_t idx, TValue **tvp) +{ + if (tvisfunc(o)) { + GCfunc *fn = funcV(o); + if (isluafunc(fn)) { + GCproto *pt = funcproto(fn); + if (idx < pt->sizeuv) { + *tvp = uvval(&gcref(fn->l.uvptr[idx])->uv); + return lj_debug_uvname(pt, idx); + } + } else { + if (idx < fn->c.nupvalues) { + *tvp = &fn->c.upvalue[idx]; + return ""; + } + } + } + return NULL; +} + +/* Deduce name of an object from slot number and PC. */ +const char *lj_debug_slotname(GCproto *pt, const BCIns *ip, BCReg slot, + const char **name) +{ + const char *lname; +restart: + lname = debug_varname(pt, proto_bcpos(pt, ip), slot); + if (lname != NULL) { *name = lname; return "local"; } + while (--ip > proto_bc(pt)) { + BCIns ins = *ip; + BCOp op = bc_op(ins); + BCReg ra = bc_a(ins); + if (bcmode_a(op) == BCMbase) { + if (slot >= ra && (op != BC_KNIL || slot <= bc_d(ins))) + return NULL; + } else if (bcmode_a(op) == BCMdst && ra == slot) { + switch (bc_op(ins)) { + case BC_MOV: + if (ra == slot) { slot = bc_d(ins); goto restart; } + break; + case BC_GGET: + *name = strdata(gco2str(proto_kgc(pt, ~(ptrdiff_t)bc_d(ins)))); + return "global"; + case BC_TGETS: + *name = strdata(gco2str(proto_kgc(pt, ~(ptrdiff_t)bc_c(ins)))); + if (ip > proto_bc(pt)) { + BCIns insp = ip[-1]; + if (bc_op(insp) == BC_MOV && bc_a(insp) == ra+1 && + bc_d(insp) == bc_b(ins)) + return "method"; + } + return "field"; + case BC_UGET: + *name = lj_debug_uvname(pt, bc_d(ins)); + return "upvalue"; + default: + return NULL; + } + } + } + return NULL; +} + +/* Deduce function name from caller of a frame. */ +const char *lj_debug_funcname(lua_State *L, TValue *frame, const char **name) +{ + TValue *pframe; + GCfunc *fn; + BCPos pc; + if (frame <= tvref(L->stack)) + return NULL; + if (frame_isvarg(frame)) + frame = frame_prevd(frame); + pframe = frame_prev(frame); + fn = frame_func(pframe); + pc = debug_framepc(L, fn, frame); + if (pc != NO_BCPOS) { + GCproto *pt = funcproto(fn); + const BCIns *ip = &proto_bc(pt)[check_exp(pc < pt->sizebc, pc)]; + MMS mm = bcmode_mm(bc_op(*ip)); + if (mm == MM_call) { + BCReg slot = bc_a(*ip); + if (bc_op(*ip) == BC_ITERC) slot -= 3; + return lj_debug_slotname(pt, ip, slot, name); + } else if (mm != MM__MAX) { + *name = strdata(mmname_str(G(L), mm)); + return "metamethod"; + } + } + return NULL; +} + +/* -- Source code locations ----------------------------------------------- */ + +/* Generate shortened source name. */ +void lj_debug_shortname(char *out, GCstr *str) +{ + const char *src = strdata(str); + if (*src == '=') { + strncpy(out, src+1, LUA_IDSIZE); /* Remove first char. */ + out[LUA_IDSIZE-1] = '\0'; /* Ensures null termination. */ + } else if (*src == '@') { /* Output "source", or "...source". */ + size_t len = str->len-1; + src++; /* Skip the `@' */ + if (len >= LUA_IDSIZE) { + src += len-(LUA_IDSIZE-4); /* Get last part of file name. */ + *out++ = '.'; *out++ = '.'; *out++ = '.'; + } + strcpy(out, src); + } else { /* Output [string "string"]. */ + size_t len; /* Length, up to first control char. */ + for (len = 0; len < LUA_IDSIZE-12; len++) + if (((const unsigned char *)src)[len] < ' ') break; + strcpy(out, "[string \""); out += 9; + if (src[len] != '\0') { /* Must truncate? */ + if (len > LUA_IDSIZE-15) len = LUA_IDSIZE-15; + strncpy(out, src, len); out += len; + strcpy(out, "..."); out += 3; + } else { + strcpy(out, src); out += len; + } + strcpy(out, "\"]"); + } +} + +/* Add current location of a frame to error message. */ +void lj_debug_addloc(lua_State *L, const char *msg, + cTValue *frame, cTValue *nextframe) +{ + if (frame) { + GCfunc *fn = frame_func(frame); + if (isluafunc(fn)) { + BCLine line = debug_frameline(L, fn, nextframe); + if (line >= 0) { + char buf[LUA_IDSIZE]; + lj_debug_shortname(buf, proto_chunkname(funcproto(fn))); + lj_str_pushf(L, "%s:%d: %s", buf, line, msg); + return; + } + } + } + lj_str_pushf(L, "%s", msg); +} + +/* Push location string for a bytecode position to Lua stack. */ +void lj_debug_pushloc(lua_State *L, GCproto *pt, BCPos pc) +{ + GCstr *name = proto_chunkname(pt); + const char *s = strdata(name); + MSize i, len = name->len; + BCLine line = lj_debug_line(pt, pc); + if (*s == '@') { + s++; len--; + for (i = len; i > 0; i--) + if (s[i] == '/' || s[i] == '\\') { + s += i+1; + break; + } + lj_str_pushf(L, "%s:%d", s, line); + } else if (len > 40) { + lj_str_pushf(L, "%p:%d", pt, line); + } else if (*s == '=') { + lj_str_pushf(L, "%s:%d", s+1, line); + } else { + lj_str_pushf(L, "\"%s\":%d", s, line); + } +} + +/* -- Public debug API ---------------------------------------------------- */ + +/* lua_getupvalue() and lua_setupvalue() are in lj_api.c. */ + +LUA_API const char *lua_getlocal(lua_State *L, const lua_Debug *ar, int n) +{ + const char *name = NULL; + if (ar) { + TValue *o = debug_localname(L, ar, &name, (BCReg)n); + if (name) { + copyTV(L, L->top, o); + incr_top(L); + } + } else if (tvisfunc(L->top-1) && isluafunc(funcV(L->top-1))) { + name = debug_varname(funcproto(funcV(L->top-1)), 0, (BCReg)n-1); + } + return name; +} + +LUA_API const char *lua_setlocal(lua_State *L, const lua_Debug *ar, int n) +{ + const char *name = NULL; + TValue *o = debug_localname(L, ar, &name, (BCReg)n); + if (name) + copyTV(L, o, L->top-1); + L->top--; + return name; +} + +int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, int ext) +{ + int opt_f = 0, opt_L = 0; + TValue *frame = NULL; + TValue *nextframe = NULL; + GCfunc *fn; + if (*what == '>') { + TValue *func = L->top - 1; + api_check(L, tvisfunc(func)); + fn = funcV(func); + L->top--; + what++; + } else { + uint32_t offset = (uint32_t)ar->i_ci & 0xffff; + uint32_t size = (uint32_t)ar->i_ci >> 16; + lua_assert(offset != 0); + frame = tvref(L->stack) + offset; + if (size) nextframe = frame + size; + lua_assert(frame <= tvref(L->maxstack) && + (!nextframe || nextframe <= tvref(L->maxstack))); + fn = frame_func(frame); + lua_assert(fn->c.gct == ~LJ_TFUNC); + } + for (; *what; what++) { + if (*what == 'S') { + if (isluafunc(fn)) { + GCproto *pt = funcproto(fn); + BCLine firstline = pt->firstline; + GCstr *name = proto_chunkname(pt); + ar->source = strdata(name); + lj_debug_shortname(ar->short_src, name); + ar->linedefined = (int)firstline; + ar->lastlinedefined = (int)(firstline + pt->numline); + ar->what = (firstline || !pt->numline) ? "Lua" : "main"; + } else { + ar->source = "=[C]"; + ar->short_src[0] = '['; + ar->short_src[1] = 'C'; + ar->short_src[2] = ']'; + ar->short_src[3] = '\0'; + ar->linedefined = -1; + ar->lastlinedefined = -1; + ar->what = "C"; + } + } else if (*what == 'l') { + ar->currentline = frame ? debug_frameline(L, fn, nextframe) : -1; + } else if (*what == 'u') { + ar->nups = fn->c.nupvalues; + if (ext) { + if (isluafunc(fn)) { + GCproto *pt = funcproto(fn); + ar->nparams = pt->numparams; + ar->isvararg = !!(pt->flags & PROTO_VARARG); + } else { + ar->nparams = 0; + ar->isvararg = 1; + } + } + } else if (*what == 'n') { + ar->namewhat = frame ? lj_debug_funcname(L, frame, &ar->name) : NULL; + if (ar->namewhat == NULL) { + ar->namewhat = ""; + ar->name = NULL; + } + } else if (*what == 'f') { + opt_f = 1; + } else if (*what == 'L') { + opt_L = 1; + } else { + return 0; /* Bad option. */ + } + } + if (opt_f) { + setfuncV(L, L->top, fn); + incr_top(L); + } + if (opt_L) { + if (isluafunc(fn)) { + GCtab *t = lj_tab_new(L, 0, 0); + GCproto *pt = funcproto(fn); + const void *lineinfo = proto_lineinfo(pt); + if (lineinfo) { + BCLine first = pt->firstline; + int sz = pt->numline < 256 ? 1 : pt->numline < 65536 ? 2 : 4; + MSize i, szl = pt->sizebc-1; + for (i = 0; i < szl; i++) { + BCLine line = first + + (sz == 1 ? (BCLine)((const uint8_t *)lineinfo)[i] : + sz == 2 ? (BCLine)((const uint16_t *)lineinfo)[i] : + (BCLine)((const uint32_t *)lineinfo)[i]); + setboolV(lj_tab_setint(L, t, line), 1); + } + } + settabV(L, L->top, t); + } else { + setnilV(L->top); + } + incr_top(L); + } + return 1; /* Ok. */ +} + +LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar) +{ + return lj_debug_getinfo(L, what, (lj_Debug *)ar, 0); +} + +LUA_API int lua_getstack(lua_State *L, int level, lua_Debug *ar) +{ + int size; + cTValue *frame = lj_debug_frame(L, level, &size); + if (frame) { + ar->i_ci = (size << 16) + (int)(frame - tvref(L->stack)); + return 1; + } else { + ar->i_ci = level - size; + return 0; + } +} + +/* Number of frames for the leading and trailing part of a traceback. */ +#define TRACEBACK_LEVELS1 12 +#define TRACEBACK_LEVELS2 10 + +LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1, const char *msg, + int level) +{ + int top = (int)(L->top - L->base); + int lim = TRACEBACK_LEVELS1; + lua_Debug ar; + if (msg) lua_pushfstring(L, "%s\n", msg); + lua_pushliteral(L, "stack traceback:"); + while (lua_getstack(L1, level++, &ar)) { + GCfunc *fn; + if (level > lim) { + if (!lua_getstack(L1, level + TRACEBACK_LEVELS2, &ar)) { + level--; + } else { + lua_pushliteral(L, "\n\t..."); + lua_getstack(L1, -10, &ar); + level = ar.i_ci - TRACEBACK_LEVELS2; + } + lim = 2147483647; + continue; + } + lua_getinfo(L1, "Snlf", &ar); + fn = funcV(L1->top-1); L1->top--; + if (isffunc(fn) && !*ar.namewhat) + lua_pushfstring(L, "\n\t[builtin#%d]:", fn->c.ffid); + else + lua_pushfstring(L, "\n\t%s:", ar.short_src); + if (ar.currentline > 0) + lua_pushfstring(L, "%d:", ar.currentline); + if (*ar.namewhat) { + lua_pushfstring(L, " in function " LUA_QS, ar.name); + } else { + if (*ar.what == 'm') { + lua_pushliteral(L, " in main chunk"); + } else if (*ar.what == 'C') { + lua_pushfstring(L, " at %p", fn->c.f); + } else { + lua_pushfstring(L, " in function <%s:%d>", + ar.short_src, ar.linedefined); + } + } + if ((int)(L->top - L->base) - top >= 15) + lua_concat(L, (int)(L->top - L->base) - top); + } + lua_concat(L, (int)(L->top - L->base) - top); +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_debug.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_debug.h new file mode 100644 index 000000000..fa8988c3e --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_debug.h @@ -0,0 +1,61 @@ +/* +** Debugging and introspection. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_DEBUG_H +#define _LJ_DEBUG_H + +#include "lj_obj.h" + +typedef struct lj_Debug { + /* Common fields. Must be in the same order as in lua.h. */ + int event; + const char *name; + const char *namewhat; + const char *what; + const char *source; + int currentline; + int nups; + int linedefined; + int lastlinedefined; + char short_src[LUA_IDSIZE]; + int i_ci; + /* Extended fields. Only valid if lj_debug_getinfo() is called with ext = 1.*/ + int nparams; + int isvararg; +} lj_Debug; + +LJ_FUNC cTValue *lj_debug_frame(lua_State *L, int level, int *size); +LJ_FUNC BCLine LJ_FASTCALL lj_debug_line(GCproto *pt, BCPos pc); +LJ_FUNC const char *lj_debug_uvname(GCproto *pt, uint32_t idx); +LJ_FUNC const char *lj_debug_uvnamev(cTValue *o, uint32_t idx, TValue **tvp); +LJ_FUNC const char *lj_debug_slotname(GCproto *pt, const BCIns *pc, + BCReg slot, const char **name); +LJ_FUNC const char *lj_debug_funcname(lua_State *L, TValue *frame, + const char **name); +LJ_FUNC void lj_debug_shortname(char *out, GCstr *str); +LJ_FUNC void lj_debug_addloc(lua_State *L, const char *msg, + cTValue *frame, cTValue *nextframe); +LJ_FUNC void lj_debug_pushloc(lua_State *L, GCproto *pt, BCPos pc); +LJ_FUNC int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, + int ext); + +/* Fixed internal variable names. */ +#define VARNAMEDEF(_) \ + _(FOR_IDX, "(for index)") \ + _(FOR_STOP, "(for limit)") \ + _(FOR_STEP, "(for step)") \ + _(FOR_GEN, "(for generator)") \ + _(FOR_STATE, "(for state)") \ + _(FOR_CTL, "(for control)") + +enum { + VARNAME_END, +#define VARNAMEENUM(name, str) VARNAME_##name, + VARNAMEDEF(VARNAMEENUM) +#undef VARNAMEENUM + VARNAME__MAX +}; + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_def.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_def.h new file mode 100644 index 000000000..213a4e70e --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_def.h @@ -0,0 +1,353 @@ +/* +** LuaJIT common internal definitions. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_DEF_H +#define _LJ_DEF_H + +#include "lua.h" + +#if defined(_MSC_VER) +/* MSVC is stuck in the last century and doesn't have C99's stdint.h. */ +typedef __int8 int8_t; +typedef __int16 int16_t; +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; +#ifdef _WIN64 +typedef __int64 intptr_t; +typedef unsigned __int64 uintptr_t; +#else +typedef __int32 intptr_t; +typedef unsigned __int32 uintptr_t; +#endif +#elif defined(__symbian__) +/* Cough. */ +typedef signed char int8_t; +typedef short int int16_t; +typedef int int32_t; +typedef long long int64_t; +typedef unsigned char uint8_t; +typedef unsigned short int uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; +typedef int intptr_t; +typedef unsigned int uintptr_t; +#else +#include +#endif + +/* Needed everywhere. */ +#include +#include + +/* Various VM limits. */ +#define LJ_MAX_MEM 0x7fffff00 /* Max. total memory allocation. */ +#define LJ_MAX_ALLOC LJ_MAX_MEM /* Max. individual allocation length. */ +#define LJ_MAX_STR LJ_MAX_MEM /* Max. string length. */ +#define LJ_MAX_UDATA LJ_MAX_MEM /* Max. userdata length. */ + +#define LJ_MAX_STRTAB (1<<26) /* Max. string table size. */ +#define LJ_MAX_HBITS 26 /* Max. hash bits. */ +#define LJ_MAX_ABITS 28 /* Max. bits of array key. */ +#define LJ_MAX_ASIZE ((1<<(LJ_MAX_ABITS-1))+1) /* Max. array part size. */ +#define LJ_MAX_COLOSIZE 16 /* Max. elems for colocated array. */ + +#define LJ_MAX_LINE LJ_MAX_MEM /* Max. source code line number. */ +#define LJ_MAX_XLEVEL 200 /* Max. syntactic nesting level. */ +#define LJ_MAX_BCINS (1<<26) /* Max. # of bytecode instructions. */ +#define LJ_MAX_SLOTS 250 /* Max. # of slots in a Lua func. */ +#define LJ_MAX_LOCVAR 200 /* Max. # of local variables. */ +#define LJ_MAX_UPVAL 249 /* Max. # of upvalues. */ + +#define LJ_MAX_IDXCHAIN 100 /* __index/__newindex chain limit. */ +#define LJ_STACK_EXTRA 5 /* Extra stack space (metamethods). */ + +#define LJ_NUM_CBPAGE 1 /* Number of FFI callback pages. */ + +/* Minimum table/buffer sizes. */ +#define LJ_MIN_GLOBAL 6 /* Min. global table size (hbits). */ +#define LJ_MIN_REGISTRY 2 /* Min. registry size (hbits). */ +#define LJ_MIN_STRTAB 256 /* Min. string table size (pow2). */ +#define LJ_MIN_SBUF 32 /* Min. string buffer length. */ +#define LJ_MIN_VECSZ 8 /* Min. size for growable vectors. */ +#define LJ_MIN_IRSZ 32 /* Min. size for growable IR. */ +#define LJ_MIN_K64SZ 16 /* Min. size for chained K64Array. */ + +/* JIT compiler limits. */ +#define LJ_MAX_JSLOTS 250 /* Max. # of stack slots for a trace. */ +#define LJ_MAX_PHI 64 /* Max. # of PHIs for a loop. */ +#define LJ_MAX_EXITSTUBGR 16 /* Max. # of exit stub groups. */ + +/* Various macros. */ +#ifndef UNUSED +#define UNUSED(x) ((void)(x)) /* to avoid warnings */ +#endif + +#define U64x(hi, lo) (((uint64_t)0x##hi << 32) + (uint64_t)0x##lo) +#define i32ptr(p) ((int32_t)(intptr_t)(void *)(p)) +#define u32ptr(p) ((uint32_t)(intptr_t)(void *)(p)) + +#define checki8(x) ((x) == (int32_t)(int8_t)(x)) +#define checku8(x) ((x) == (int32_t)(uint8_t)(x)) +#define checki16(x) ((x) == (int32_t)(int16_t)(x)) +#define checku16(x) ((x) == (int32_t)(uint16_t)(x)) +#define checki32(x) ((x) == (int32_t)(x)) +#define checku32(x) ((x) == (uint32_t)(x)) +#define checkptr32(x) ((uintptr_t)(x) == (uint32_t)(uintptr_t)(x)) + +/* Every half-decent C compiler transforms this into a rotate instruction. */ +#define lj_rol(x, n) (((x)<<(n)) | ((x)>>(-(int)(n)&(8*sizeof(x)-1)))) +#define lj_ror(x, n) (((x)<<(-(int)(n)&(8*sizeof(x)-1))) | ((x)>>(n))) + +/* A really naive Bloom filter. But sufficient for our needs. */ +typedef uintptr_t BloomFilter; +#define BLOOM_MASK (8*sizeof(BloomFilter) - 1) +#define bloombit(x) ((uintptr_t)1 << ((x) & BLOOM_MASK)) +#define bloomset(b, x) ((b) |= bloombit((x))) +#define bloomtest(b, x) ((b) & bloombit((x))) + +#if defined(__GNUC__) || defined(__psp2__) + +#define LJ_NORET __attribute__((noreturn)) +#define LJ_ALIGN(n) __attribute__((aligned(n))) +#define LJ_INLINE inline +#define LJ_AINLINE inline __attribute__((always_inline)) +#define LJ_NOINLINE __attribute__((noinline)) + +#if defined(__ELF__) || defined(__MACH__) || defined(__psp2__) +#if !((defined(__sun__) && defined(__svr4__)) || defined(__CELLOS_LV2__)) +#define LJ_NOAPI extern __attribute__((visibility("hidden"))) +#endif +#endif + +/* Note: it's only beneficial to use fastcall on x86 and then only for up to +** two non-FP args. The amalgamated compile covers all LJ_FUNC cases. Only +** indirect calls and related tail-called C functions are marked as fastcall. +*/ +#if defined(__i386__) +#define LJ_FASTCALL __attribute__((fastcall)) +#endif + +#define LJ_LIKELY(x) __builtin_expect(!!(x), 1) +#define LJ_UNLIKELY(x) __builtin_expect(!!(x), 0) + +#define lj_ffs(x) ((uint32_t)__builtin_ctz(x)) +/* Don't ask ... */ +#if defined(__INTEL_COMPILER) && (defined(__i386__) || defined(__x86_64__)) +static LJ_AINLINE uint32_t lj_fls(uint32_t x) +{ + uint32_t r; __asm__("bsrl %1, %0" : "=r" (r) : "rm" (x) : "cc"); return r; +} +#else +#define lj_fls(x) ((uint32_t)(__builtin_clz(x)^31)) +#endif + +#if defined(__arm__) +static LJ_AINLINE uint32_t lj_bswap(uint32_t x) +{ +#if defined(__psp2__) + return __builtin_rev(x); +#else + uint32_t r; +#if __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6T2__ || __ARM_ARCH_6Z__ ||\ + __ARM_ARCH_6ZK__ || __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ + __asm__("rev %0, %1" : "=r" (r) : "r" (x)); + return r; +#else +#ifdef __thumb__ + r = x ^ lj_ror(x, 16); +#else + __asm__("eor %0, %1, %1, ror #16" : "=r" (r) : "r" (x)); +#endif + return ((r & 0xff00ffffu) >> 8) ^ lj_ror(x, 8); +#endif +#endif +} + +static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) +{ + return ((uint64_t)lj_bswap((uint32_t)x)<<32) | lj_bswap((uint32_t)(x>>32)); +} +#elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +static LJ_AINLINE uint32_t lj_bswap(uint32_t x) +{ + return (uint32_t)__builtin_bswap32((int32_t)x); +} + +static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) +{ + return (uint64_t)__builtin_bswap64((int64_t)x); +} +#elif defined(__i386__) || defined(__x86_64__) +static LJ_AINLINE uint32_t lj_bswap(uint32_t x) +{ + uint32_t r; __asm__("bswap %0" : "=r" (r) : "0" (x)); return r; +} + +#if defined(__i386__) +static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) +{ + return ((uint64_t)lj_bswap((uint32_t)x)<<32) | lj_bswap((uint32_t)(x>>32)); +} +#else +static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) +{ + uint64_t r; __asm__("bswap %0" : "=r" (r) : "0" (x)); return r; +} +#endif +#else +static LJ_AINLINE uint32_t lj_bswap(uint32_t x) +{ + return (x << 24) | ((x & 0xff00) << 8) | ((x >> 8) & 0xff00) | (x >> 24); +} + +static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) +{ + return (uint64_t)lj_bswap((uint32_t)(x >> 32)) | + ((uint64_t)lj_bswap((uint32_t)x) << 32); +} +#endif + +typedef union __attribute__((packed)) Unaligned16 { + uint16_t u; + uint8_t b[2]; +} Unaligned16; + +typedef union __attribute__((packed)) Unaligned32 { + uint32_t u; + uint8_t b[4]; +} Unaligned32; + +/* Unaligned load of uint16_t. */ +static LJ_AINLINE uint16_t lj_getu16(const void *p) +{ + return ((const Unaligned16 *)p)->u; +} + +/* Unaligned load of uint32_t. */ +static LJ_AINLINE uint32_t lj_getu32(const void *p) +{ + return ((const Unaligned32 *)p)->u; +} + +#elif defined(_MSC_VER) + +#define LJ_NORET __declspec(noreturn) +#define LJ_ALIGN(n) __declspec(align(n)) +#define LJ_INLINE __inline +#define LJ_AINLINE __forceinline +#define LJ_NOINLINE __declspec(noinline) +#if defined(_M_IX86) +#define LJ_FASTCALL __fastcall +#endif + +#ifdef _M_PPC +unsigned int _CountLeadingZeros(long); +#pragma intrinsic(_CountLeadingZeros) +static LJ_AINLINE uint32_t lj_fls(uint32_t x) +{ + return _CountLeadingZeros(x) ^ 31; +} +#else +unsigned char _BitScanForward(uint32_t *, unsigned long); +unsigned char _BitScanReverse(uint32_t *, unsigned long); +#pragma intrinsic(_BitScanForward) +#pragma intrinsic(_BitScanReverse) + +static LJ_AINLINE uint32_t lj_ffs(uint32_t x) +{ + uint32_t r; _BitScanForward(&r, x); return r; +} + +static LJ_AINLINE uint32_t lj_fls(uint32_t x) +{ + uint32_t r; _BitScanReverse(&r, x); return r; +} +#endif + +unsigned long _byteswap_ulong(unsigned long); +uint64_t _byteswap_uint64(uint64_t); +#define lj_bswap(x) (_byteswap_ulong((x))) +#define lj_bswap64(x) (_byteswap_uint64((x))) + +#if defined(_M_PPC) && defined(LUAJIT_NO_UNALIGNED) +/* +** Replacement for unaligned loads on Xbox 360. Disabled by default since it's +** usually more costly than the occasional stall when crossing a cache-line. +*/ +static LJ_AINLINE uint16_t lj_getu16(const void *v) +{ + const uint8_t *p = (const uint8_t *)v; + return (uint16_t)((p[0]<<8) | p[1]); +} +static LJ_AINLINE uint32_t lj_getu32(const void *v) +{ + const uint8_t *p = (const uint8_t *)v; + return (uint32_t)((p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]); +} +#else +/* Unaligned loads are generally ok on x86/x64. */ +#define lj_getu16(p) (*(uint16_t *)(p)) +#define lj_getu32(p) (*(uint32_t *)(p)) +#endif + +#else +#error "missing defines for your compiler" +#endif + +/* Optional defines. */ +#ifndef LJ_FASTCALL +#define LJ_FASTCALL +#endif +#ifndef LJ_NORET +#define LJ_NORET +#endif +#ifndef LJ_NOAPI +#define LJ_NOAPI extern +#endif +#ifndef LJ_LIKELY +#define LJ_LIKELY(x) (x) +#define LJ_UNLIKELY(x) (x) +#endif + +/* Attributes for internal functions. */ +#define LJ_DATA LJ_NOAPI +#define LJ_DATADEF +#define LJ_ASMF LJ_NOAPI +#define LJ_FUNCA LJ_NOAPI +#if defined(ljamalg_c) +#define LJ_FUNC static +#else +#define LJ_FUNC LJ_NOAPI +#endif +#define LJ_FUNC_NORET LJ_FUNC LJ_NORET +#define LJ_FUNCA_NORET LJ_FUNCA LJ_NORET +#define LJ_ASMF_NORET LJ_ASMF LJ_NORET + +/* Runtime assertions. */ +#ifdef lua_assert +#define check_exp(c, e) (lua_assert(c), (e)) +#define api_check(l, e) lua_assert(e) +#else +#define lua_assert(c) ((void)0) +#define check_exp(c, e) (e) +#define api_check luai_apicheck +#endif + +/* Static assertions. */ +#define LJ_ASSERT_NAME2(name, line) name ## line +#define LJ_ASSERT_NAME(line) LJ_ASSERT_NAME2(lj_assert_, line) +#ifdef __COUNTER__ +#define LJ_STATIC_ASSERT(cond) \ + extern void LJ_ASSERT_NAME(__COUNTER__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1]) +#else +#define LJ_STATIC_ASSERT(cond) \ + extern void LJ_ASSERT_NAME(__LINE__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1]) +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_dispatch.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_dispatch.c new file mode 100644 index 000000000..37256576e --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_dispatch.c @@ -0,0 +1,494 @@ +/* +** Instruction dispatch handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_dispatch_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_err.h" +#include "lj_func.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_meta.h" +#include "lj_debug.h" +#include "lj_state.h" +#include "lj_frame.h" +#include "lj_bc.h" +#include "lj_ff.h" +#if LJ_HASJIT +#include "lj_jit.h" +#endif +#if LJ_HASFFI +#include "lj_ccallback.h" +#endif +#include "lj_trace.h" +#include "lj_dispatch.h" +#include "lj_vm.h" +#include "luajit.h" + +/* Bump GG_NUM_ASMFF in lj_dispatch.h as needed. Ugly. */ +LJ_STATIC_ASSERT(GG_NUM_ASMFF == FF_NUM_ASMFUNC); + +/* -- Dispatch table management ------------------------------------------- */ + +#if LJ_TARGET_MIPS +#include +LJ_FUNCA_NORET void LJ_FASTCALL lj_ffh_coroutine_wrap_err(lua_State *L, + lua_State *co); + +#define GOTFUNC(name) (ASMFunction)name, +static const ASMFunction dispatch_got[] = { + GOTDEF(GOTFUNC) +}; +#undef GOTFUNC +#endif + +/* Initialize instruction dispatch table and hot counters. */ +void lj_dispatch_init(GG_State *GG) +{ + uint32_t i; + ASMFunction *disp = GG->dispatch; + for (i = 0; i < GG_LEN_SDISP; i++) + disp[GG_LEN_DDISP+i] = disp[i] = makeasmfunc(lj_bc_ofs[i]); + for (i = GG_LEN_SDISP; i < GG_LEN_DDISP; i++) + disp[i] = makeasmfunc(lj_bc_ofs[i]); + /* The JIT engine is off by default. luaopen_jit() turns it on. */ + disp[BC_FORL] = disp[BC_IFORL]; + disp[BC_ITERL] = disp[BC_IITERL]; + disp[BC_LOOP] = disp[BC_ILOOP]; + disp[BC_FUNCF] = disp[BC_IFUNCF]; + disp[BC_FUNCV] = disp[BC_IFUNCV]; + GG->g.bc_cfunc_ext = GG->g.bc_cfunc_int = BCINS_AD(BC_FUNCC, LUA_MINSTACK, 0); + for (i = 0; i < GG_NUM_ASMFF; i++) + GG->bcff[i] = BCINS_AD(BC__MAX+i, 0, 0); +#if LJ_TARGET_MIPS + memcpy(GG->got, dispatch_got, LJ_GOT__MAX*4); +#endif +} + +#if LJ_HASJIT +/* Initialize hotcount table. */ +void lj_dispatch_init_hotcount(global_State *g) +{ + int32_t hotloop = G2J(g)->param[JIT_P_hotloop]; + HotCount start = (HotCount)(hotloop*HOTCOUNT_LOOP - 1); + HotCount *hotcount = G2GG(g)->hotcount; + uint32_t i; + for (i = 0; i < HOTCOUNT_SIZE; i++) + hotcount[i] = start; +} +#endif + +/* Internal dispatch mode bits. */ +#define DISPMODE_JIT 0x01 /* JIT compiler on. */ +#define DISPMODE_REC 0x02 /* Recording active. */ +#define DISPMODE_INS 0x04 /* Override instruction dispatch. */ +#define DISPMODE_CALL 0x08 /* Override call dispatch. */ +#define DISPMODE_RET 0x10 /* Override return dispatch. */ + +/* Update dispatch table depending on various flags. */ +void lj_dispatch_update(global_State *g) +{ + uint8_t oldmode = g->dispatchmode; + uint8_t mode = 0; +#if LJ_HASJIT + mode |= (G2J(g)->flags & JIT_F_ON) ? DISPMODE_JIT : 0; + mode |= G2J(g)->state != LJ_TRACE_IDLE ? + (DISPMODE_REC|DISPMODE_INS|DISPMODE_CALL) : 0; +#endif + mode |= (g->hookmask & (LUA_MASKLINE|LUA_MASKCOUNT)) ? DISPMODE_INS : 0; + mode |= (g->hookmask & LUA_MASKCALL) ? DISPMODE_CALL : 0; + mode |= (g->hookmask & LUA_MASKRET) ? DISPMODE_RET : 0; + if (oldmode != mode) { /* Mode changed? */ + ASMFunction *disp = G2GG(g)->dispatch; + ASMFunction f_forl, f_iterl, f_loop, f_funcf, f_funcv; + g->dispatchmode = mode; + + /* Hotcount if JIT is on, but not while recording. */ + if ((mode & (DISPMODE_JIT|DISPMODE_REC)) == DISPMODE_JIT) { + f_forl = makeasmfunc(lj_bc_ofs[BC_FORL]); + f_iterl = makeasmfunc(lj_bc_ofs[BC_ITERL]); + f_loop = makeasmfunc(lj_bc_ofs[BC_LOOP]); + f_funcf = makeasmfunc(lj_bc_ofs[BC_FUNCF]); + f_funcv = makeasmfunc(lj_bc_ofs[BC_FUNCV]); + } else { /* Otherwise use the non-hotcounting instructions. */ + f_forl = disp[GG_LEN_DDISP+BC_IFORL]; + f_iterl = disp[GG_LEN_DDISP+BC_IITERL]; + f_loop = disp[GG_LEN_DDISP+BC_ILOOP]; + f_funcf = makeasmfunc(lj_bc_ofs[BC_IFUNCF]); + f_funcv = makeasmfunc(lj_bc_ofs[BC_IFUNCV]); + } + /* Init static counting instruction dispatch first (may be copied below). */ + disp[GG_LEN_DDISP+BC_FORL] = f_forl; + disp[GG_LEN_DDISP+BC_ITERL] = f_iterl; + disp[GG_LEN_DDISP+BC_LOOP] = f_loop; + + /* Set dynamic instruction dispatch. */ + if ((oldmode ^ mode) & (DISPMODE_REC|DISPMODE_INS)) { + /* Need to update the whole table. */ + if (!(mode & (DISPMODE_REC|DISPMODE_INS))) { /* No ins dispatch? */ + /* Copy static dispatch table to dynamic dispatch table. */ + memcpy(&disp[0], &disp[GG_LEN_DDISP], GG_LEN_SDISP*sizeof(ASMFunction)); + /* Overwrite with dynamic return dispatch. */ + if ((mode & DISPMODE_RET)) { + disp[BC_RETM] = lj_vm_rethook; + disp[BC_RET] = lj_vm_rethook; + disp[BC_RET0] = lj_vm_rethook; + disp[BC_RET1] = lj_vm_rethook; + } + } else { + /* The recording dispatch also checks for hooks. */ + ASMFunction f = (mode & DISPMODE_REC) ? lj_vm_record : lj_vm_inshook; + uint32_t i; + for (i = 0; i < GG_LEN_SDISP; i++) + disp[i] = f; + } + } else if (!(mode & (DISPMODE_REC|DISPMODE_INS))) { + /* Otherwise set dynamic counting ins. */ + disp[BC_FORL] = f_forl; + disp[BC_ITERL] = f_iterl; + disp[BC_LOOP] = f_loop; + /* Set dynamic return dispatch. */ + if ((mode & DISPMODE_RET)) { + disp[BC_RETM] = lj_vm_rethook; + disp[BC_RET] = lj_vm_rethook; + disp[BC_RET0] = lj_vm_rethook; + disp[BC_RET1] = lj_vm_rethook; + } else { + disp[BC_RETM] = disp[GG_LEN_DDISP+BC_RETM]; + disp[BC_RET] = disp[GG_LEN_DDISP+BC_RET]; + disp[BC_RET0] = disp[GG_LEN_DDISP+BC_RET0]; + disp[BC_RET1] = disp[GG_LEN_DDISP+BC_RET1]; + } + } + + /* Set dynamic call dispatch. */ + if ((oldmode ^ mode) & DISPMODE_CALL) { /* Update the whole table? */ + uint32_t i; + if ((mode & DISPMODE_CALL) == 0) { /* No call hooks? */ + for (i = GG_LEN_SDISP; i < GG_LEN_DDISP; i++) + disp[i] = makeasmfunc(lj_bc_ofs[i]); + } else { + for (i = GG_LEN_SDISP; i < GG_LEN_DDISP; i++) + disp[i] = lj_vm_callhook; + } + } + if (!(mode & DISPMODE_CALL)) { /* Overwrite dynamic counting ins. */ + disp[BC_FUNCF] = f_funcf; + disp[BC_FUNCV] = f_funcv; + } + +#if LJ_HASJIT + /* Reset hotcounts for JIT off to on transition. */ + if ((mode & DISPMODE_JIT) && !(oldmode & DISPMODE_JIT)) + lj_dispatch_init_hotcount(g); +#endif + } +} + +/* -- JIT mode setting ---------------------------------------------------- */ + +#if LJ_HASJIT +/* Set JIT mode for a single prototype. */ +static void setptmode(global_State *g, GCproto *pt, int mode) +{ + if ((mode & LUAJIT_MODE_ON)) { /* (Re-)enable JIT compilation. */ + pt->flags &= ~PROTO_NOJIT; + lj_trace_reenableproto(pt); /* Unpatch all ILOOP etc. bytecodes. */ + } else { /* Flush and/or disable JIT compilation. */ + if (!(mode & LUAJIT_MODE_FLUSH)) + pt->flags |= PROTO_NOJIT; + lj_trace_flushproto(g, pt); /* Flush all traces of prototype. */ + } +} + +/* Recursively set the JIT mode for all children of a prototype. */ +static void setptmode_all(global_State *g, GCproto *pt, int mode) +{ + ptrdiff_t i; + if (!(pt->flags & PROTO_CHILD)) return; + for (i = -(ptrdiff_t)pt->sizekgc; i < 0; i++) { + GCobj *o = proto_kgc(pt, i); + if (o->gch.gct == ~LJ_TPROTO) { + setptmode(g, gco2pt(o), mode); + setptmode_all(g, gco2pt(o), mode); + } + } +} +#endif + +/* Public API function: control the JIT engine. */ +int luaJIT_setmode(lua_State *L, int idx, int mode) +{ + global_State *g = G(L); + int mm = mode & LUAJIT_MODE_MASK; + lj_trace_abort(g); /* Abort recording on any state change. */ + /* Avoid pulling the rug from under our own feet. */ + if ((g->hookmask & HOOK_GC)) + lj_err_caller(L, LJ_ERR_NOGCMM); + switch (mm) { +#if LJ_HASJIT + case LUAJIT_MODE_ENGINE: + if ((mode & LUAJIT_MODE_FLUSH)) { + lj_trace_flushall(L); + } else { + if (!(mode & LUAJIT_MODE_ON)) + G2J(g)->flags &= ~(uint32_t)JIT_F_ON; +#if LJ_TARGET_X86ORX64 + else if ((G2J(g)->flags & JIT_F_SSE2)) + G2J(g)->flags |= (uint32_t)JIT_F_ON; + else + return 0; /* Don't turn on JIT compiler without SSE2 support. */ +#else + else + G2J(g)->flags |= (uint32_t)JIT_F_ON; +#endif + lj_dispatch_update(g); + } + break; + case LUAJIT_MODE_FUNC: + case LUAJIT_MODE_ALLFUNC: + case LUAJIT_MODE_ALLSUBFUNC: { + cTValue *tv = idx == 0 ? frame_prev(L->base-1) : + idx > 0 ? L->base + (idx-1) : L->top + idx; + GCproto *pt; + if ((idx == 0 || tvisfunc(tv)) && isluafunc(&gcval(tv)->fn)) + pt = funcproto(&gcval(tv)->fn); /* Cannot use funcV() for frame slot. */ + else if (tvisproto(tv)) + pt = protoV(tv); + else + return 0; /* Failed. */ + if (mm != LUAJIT_MODE_ALLSUBFUNC) + setptmode(g, pt, mode); + if (mm != LUAJIT_MODE_FUNC) + setptmode_all(g, pt, mode); + break; + } + case LUAJIT_MODE_TRACE: + if (!(mode & LUAJIT_MODE_FLUSH)) + return 0; /* Failed. */ + lj_trace_flush(G2J(g), idx); + break; +#else + case LUAJIT_MODE_ENGINE: + case LUAJIT_MODE_FUNC: + case LUAJIT_MODE_ALLFUNC: + case LUAJIT_MODE_ALLSUBFUNC: + UNUSED(idx); + if ((mode & LUAJIT_MODE_ON)) + return 0; /* Failed. */ + break; +#endif + case LUAJIT_MODE_WRAPCFUNC: + if ((mode & LUAJIT_MODE_ON)) { + if (idx != 0) { + cTValue *tv = idx > 0 ? L->base + (idx-1) : L->top + idx; + if (tvislightud(tv)) + g->wrapf = (lua_CFunction)lightudV(tv); + else + return 0; /* Failed. */ + } else { + return 0; /* Failed. */ + } + g->bc_cfunc_ext = BCINS_AD(BC_FUNCCW, 0, 0); + } else { + g->bc_cfunc_ext = BCINS_AD(BC_FUNCC, 0, 0); + } + break; + default: + return 0; /* Failed. */ + } + return 1; /* OK. */ +} + +/* Enforce (dynamic) linker error for version mismatches. See luajit.c. */ +LUA_API void LUAJIT_VERSION_SYM(void) +{ +} + +/* -- Hooks --------------------------------------------------------------- */ + +/* This function can be called asynchronously (e.g. during a signal). */ +LUA_API int lua_sethook(lua_State *L, lua_Hook func, int mask, int count) +{ + global_State *g = G(L); + mask &= HOOK_EVENTMASK; + if (func == NULL || mask == 0) { mask = 0; func = NULL; } /* Consistency. */ + g->hookf = func; + g->hookcount = g->hookcstart = (int32_t)count; + g->hookmask = (uint8_t)((g->hookmask & ~HOOK_EVENTMASK) | mask); + lj_trace_abort(g); /* Abort recording on any hook change. */ + lj_dispatch_update(g); + return 1; +} + +LUA_API lua_Hook lua_gethook(lua_State *L) +{ + return G(L)->hookf; +} + +LUA_API int lua_gethookmask(lua_State *L) +{ + return G(L)->hookmask & HOOK_EVENTMASK; +} + +LUA_API int lua_gethookcount(lua_State *L) +{ + return (int)G(L)->hookcstart; +} + +/* Call a hook. */ +static void callhook(lua_State *L, int event, BCLine line) +{ + global_State *g = G(L); + lua_Hook hookf = g->hookf; + if (hookf && !hook_active(g)) { + lua_Debug ar; + lj_trace_abort(g); /* Abort recording on any hook call. */ + ar.event = event; + ar.currentline = line; + /* Top frame, nextframe = NULL. */ + ar.i_ci = (int)((L->base-1) - tvref(L->stack)); + lj_state_checkstack(L, 1+LUA_MINSTACK); + hook_enter(g); + hookf(L, &ar); + lua_assert(hook_active(g)); + hook_leave(g); + } +} + +/* -- Dispatch callbacks -------------------------------------------------- */ + +/* Calculate number of used stack slots in the current frame. */ +static BCReg cur_topslot(GCproto *pt, const BCIns *pc, uint32_t nres) +{ + BCIns ins = pc[-1]; + if (bc_op(ins) == BC_UCLO) + ins = pc[bc_j(ins)]; + switch (bc_op(ins)) { + case BC_CALLM: case BC_CALLMT: return bc_a(ins) + bc_c(ins) + nres-1+1; + case BC_RETM: return bc_a(ins) + bc_d(ins) + nres-1; + case BC_TSETM: return bc_a(ins) + nres-1; + default: return pt->framesize; + } +} + +/* Instruction dispatch. Used by instr/line/return hooks or when recording. */ +void LJ_FASTCALL lj_dispatch_ins(lua_State *L, const BCIns *pc) +{ + ERRNO_SAVE + GCfunc *fn = curr_func(L); + GCproto *pt = funcproto(fn); + void *cf = cframe_raw(L->cframe); + const BCIns *oldpc = cframe_pc(cf); + global_State *g = G(L); + BCReg slots; + setcframe_pc(cf, pc); + slots = cur_topslot(pt, pc, cframe_multres_n(cf)); + L->top = L->base + slots; /* Fix top. */ +#if LJ_HASJIT + { + jit_State *J = G2J(g); + if (J->state != LJ_TRACE_IDLE) { +#ifdef LUA_USE_ASSERT + ptrdiff_t delta = L->top - L->base; +#endif + J->L = L; + lj_trace_ins(J, pc-1); /* The interpreter bytecode PC is offset by 1. */ + lua_assert(L->top - L->base == delta); + } + } +#endif + if ((g->hookmask & LUA_MASKCOUNT) && g->hookcount == 0) { + g->hookcount = g->hookcstart; + callhook(L, LUA_HOOKCOUNT, -1); + L->top = L->base + slots; /* Fix top again. */ + } + if ((g->hookmask & LUA_MASKLINE)) { + BCPos npc = proto_bcpos(pt, pc) - 1; + BCPos opc = proto_bcpos(pt, oldpc) - 1; + BCLine line = lj_debug_line(pt, npc); + if (pc <= oldpc || opc >= pt->sizebc || line != lj_debug_line(pt, opc)) { + callhook(L, LUA_HOOKLINE, line); + L->top = L->base + slots; /* Fix top again. */ + } + } + if ((g->hookmask & LUA_MASKRET) && bc_isret(bc_op(pc[-1]))) + callhook(L, LUA_HOOKRET, -1); + ERRNO_RESTORE +} + +/* Initialize call. Ensure stack space and return # of missing parameters. */ +static int call_init(lua_State *L, GCfunc *fn) +{ + if (isluafunc(fn)) { + GCproto *pt = funcproto(fn); + int numparams = pt->numparams; + int gotparams = (int)(L->top - L->base); + int need = pt->framesize; + if ((pt->flags & PROTO_VARARG)) need += 1+gotparams; + lj_state_checkstack(L, (MSize)need); + numparams -= gotparams; + return numparams >= 0 ? numparams : 0; + } else { + lj_state_checkstack(L, LUA_MINSTACK); + return 0; + } +} + +/* Call dispatch. Used by call hooks, hot calls or when recording. */ +ASMFunction LJ_FASTCALL lj_dispatch_call(lua_State *L, const BCIns *pc) +{ + ERRNO_SAVE + GCfunc *fn = curr_func(L); + BCOp op; + global_State *g = G(L); +#if LJ_HASJIT + jit_State *J = G2J(g); +#endif + int missing = call_init(L, fn); +#if LJ_HASJIT + J->L = L; + if ((uintptr_t)pc & 1) { /* Marker for hot call. */ +#ifdef LUA_USE_ASSERT + ptrdiff_t delta = L->top - L->base; +#endif + pc = (const BCIns *)((uintptr_t)pc & ~(uintptr_t)1); + lj_trace_hot(J, pc); + lua_assert(L->top - L->base == delta); + goto out; + } else if (J->state != LJ_TRACE_IDLE && + !(g->hookmask & (HOOK_GC|HOOK_VMEVENT))) { +#ifdef LUA_USE_ASSERT + ptrdiff_t delta = L->top - L->base; +#endif + /* Record the FUNC* bytecodes, too. */ + lj_trace_ins(J, pc-1); /* The interpreter bytecode PC is offset by 1. */ + lua_assert(L->top - L->base == delta); + } +#endif + if ((g->hookmask & LUA_MASKCALL)) { + int i; + for (i = 0; i < missing; i++) /* Add missing parameters. */ + setnilV(L->top++); + callhook(L, LUA_HOOKCALL, -1); + /* Preserve modifications of missing parameters by lua_setlocal(). */ + while (missing-- > 0 && tvisnil(L->top - 1)) + L->top--; + } +#if LJ_HASJIT +out: +#endif + op = bc_op(pc[-1]); /* Get FUNC* op. */ +#if LJ_HASJIT + /* Use the non-hotcounting variants if JIT is off or while recording. */ + if ((!(J->flags & JIT_F_ON) || J->state != LJ_TRACE_IDLE) && + (op == BC_FUNCF || op == BC_FUNCV)) + op = (BCOp)((int)op+(int)BC_IFUNCF-(int)BC_FUNCF); +#endif + ERRNO_RESTORE + return makeasmfunc(lj_bc_ofs[op]); /* Return static dispatch target. */ +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_dispatch.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_dispatch.h new file mode 100644 index 000000000..778affc8c --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_dispatch.h @@ -0,0 +1,131 @@ +/* +** Instruction dispatch handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_DISPATCH_H +#define _LJ_DISPATCH_H + +#include "lj_obj.h" +#include "lj_bc.h" +#if LJ_HASJIT +#include "lj_jit.h" +#endif + +#if LJ_TARGET_MIPS +/* Need our own global offset table for the dreaded MIPS calling conventions. */ +#if LJ_HASJIT +#define JITGOTDEF(_) _(lj_trace_exit) _(lj_trace_hot) +#else +#define JITGOTDEF(_) +#endif +#if LJ_HASFFI +#define FFIGOTDEF(_) \ + _(lj_meta_equal_cd) _(lj_ccallback_enter) _(lj_ccallback_leave) +#else +#define FFIGOTDEF(_) +#endif +#define GOTDEF(_) \ + _(floor) _(ceil) _(trunc) _(log) _(log10) _(exp) _(sin) _(cos) _(tan) \ + _(asin) _(acos) _(atan) _(sinh) _(cosh) _(tanh) _(frexp) _(modf) _(atan2) \ + _(pow) _(fmod) _(ldexp) \ + _(lj_dispatch_call) _(lj_dispatch_ins) _(lj_err_throw) \ + _(lj_ffh_coroutine_wrap_err) _(lj_func_closeuv) _(lj_func_newL_gc) \ + _(lj_gc_barrieruv) _(lj_gc_step) _(lj_gc_step_fixtop) _(lj_meta_arith) \ + _(lj_meta_call) _(lj_meta_cat) _(lj_meta_comp) _(lj_meta_equal) \ + _(lj_meta_for) _(lj_meta_len) _(lj_meta_tget) _(lj_meta_tset) \ + _(lj_state_growstack) _(lj_str_fromnum) _(lj_str_fromnumber) _(lj_str_new) \ + _(lj_tab_dup) _(lj_tab_get) _(lj_tab_getinth) _(lj_tab_len) _(lj_tab_new) \ + _(lj_tab_newkey) _(lj_tab_next) _(lj_tab_reasize) \ + JITGOTDEF(_) FFIGOTDEF(_) + +enum { +#define GOTENUM(name) LJ_GOT_##name, +GOTDEF(GOTENUM) +#undef GOTENUM + LJ_GOT__MAX +}; +#endif + +/* Type of hot counter. Must match the code in the assembler VM. */ +/* 16 bits are sufficient. Only 0.0015% overhead with maximum slot penalty. */ +typedef uint16_t HotCount; + +/* Number of hot counter hash table entries (must be a power of two). */ +#define HOTCOUNT_SIZE 64 +#define HOTCOUNT_PCMASK ((HOTCOUNT_SIZE-1)*sizeof(HotCount)) + +/* Hotcount decrements. */ +#define HOTCOUNT_LOOP 2 +#define HOTCOUNT_CALL 1 + +/* This solves a circular dependency problem -- bump as needed. Sigh. */ +#define GG_NUM_ASMFF 62 + +#define GG_LEN_DDISP (BC__MAX + GG_NUM_ASMFF) +#define GG_LEN_SDISP BC_FUNCF +#define GG_LEN_DISP (GG_LEN_DDISP + GG_LEN_SDISP) + +/* Global state, main thread and extra fields are allocated together. */ +typedef struct GG_State { + lua_State L; /* Main thread. */ + global_State g; /* Global state. */ +#if LJ_TARGET_MIPS + ASMFunction got[LJ_GOT__MAX]; /* Global offset table. */ +#endif +#if LJ_HASJIT + jit_State J; /* JIT state. */ + HotCount hotcount[HOTCOUNT_SIZE]; /* Hot counters. */ +#endif + ASMFunction dispatch[GG_LEN_DISP]; /* Instruction dispatch tables. */ + BCIns bcff[GG_NUM_ASMFF]; /* Bytecode for ASM fast functions. */ +} GG_State; + +#define GG_OFS(field) ((int)offsetof(GG_State, field)) +#define G2GG(gl) ((GG_State *)((char *)(gl) - GG_OFS(g))) +#define J2GG(j) ((GG_State *)((char *)(j) - GG_OFS(J))) +#define L2GG(L) (G2GG(G(L))) +#define J2G(J) (&J2GG(J)->g) +#define G2J(gl) (&G2GG(gl)->J) +#define L2J(L) (&L2GG(L)->J) +#define GG_G2DISP (GG_OFS(dispatch) - GG_OFS(g)) +#define GG_DISP2G (GG_OFS(g) - GG_OFS(dispatch)) +#define GG_DISP2J (GG_OFS(J) - GG_OFS(dispatch)) +#define GG_DISP2HOT (GG_OFS(hotcount) - GG_OFS(dispatch)) +#define GG_DISP2STATIC (GG_LEN_DDISP*(int)sizeof(ASMFunction)) + +#define hotcount_get(gg, pc) \ + (gg)->hotcount[(u32ptr(pc)>>2) & (HOTCOUNT_SIZE-1)] +#define hotcount_set(gg, pc, val) \ + (hotcount_get((gg), (pc)) = (HotCount)(val)) + +/* Dispatch table management. */ +LJ_FUNC void lj_dispatch_init(GG_State *GG); +#if LJ_HASJIT +LJ_FUNC void lj_dispatch_init_hotcount(global_State *g); +#endif +LJ_FUNC void lj_dispatch_update(global_State *g); + +/* Instruction dispatch callback for hooks or when recording. */ +LJ_FUNCA void LJ_FASTCALL lj_dispatch_ins(lua_State *L, const BCIns *pc); +LJ_FUNCA ASMFunction LJ_FASTCALL lj_dispatch_call(lua_State *L, const BCIns*pc); +LJ_FUNCA void LJ_FASTCALL lj_dispatch_return(lua_State *L, const BCIns *pc); + +#if LJ_HASFFI && !defined(_BUILDVM_H) +/* Save/restore errno and GetLastError() around hooks, exits and recording. */ +#include +#if LJ_TARGET_WINDOWS +#define WIN32_LEAN_AND_MEAN +#include +#define ERRNO_SAVE int olderr = errno; DWORD oldwerr = GetLastError(); +#define ERRNO_RESTORE errno = olderr; SetLastError(oldwerr); +#else +#define ERRNO_SAVE int olderr = errno; +#define ERRNO_RESTORE errno = olderr; +#endif +#else +#define ERRNO_SAVE +#define ERRNO_RESTORE +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_arm.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_arm.h new file mode 100644 index 000000000..8c5e5379c --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_arm.h @@ -0,0 +1,356 @@ +/* +** ARM instruction emitter. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* -- Constant encoding --------------------------------------------------- */ + +static uint8_t emit_invai[16] = { + /* AND */ (ARMI_AND^ARMI_BIC) >> 21, + /* EOR */ 0, + /* SUB */ (ARMI_SUB^ARMI_ADD) >> 21, + /* RSB */ 0, + /* ADD */ (ARMI_ADD^ARMI_SUB) >> 21, + /* ADC */ (ARMI_ADC^ARMI_SBC) >> 21, + /* SBC */ (ARMI_SBC^ARMI_ADC) >> 21, + /* RSC */ 0, + /* TST */ 0, + /* TEQ */ 0, + /* CMP */ (ARMI_CMP^ARMI_CMN) >> 21, + /* CMN */ (ARMI_CMN^ARMI_CMP) >> 21, + /* ORR */ 0, + /* MOV */ (ARMI_MOV^ARMI_MVN) >> 21, + /* BIC */ (ARMI_BIC^ARMI_AND) >> 21, + /* MVN */ (ARMI_MVN^ARMI_MOV) >> 21 +}; + +/* Encode constant in K12 format for data processing instructions. */ +static uint32_t emit_isk12(ARMIns ai, int32_t n) +{ + uint32_t invai, i, m = (uint32_t)n; + /* K12: unsigned 8 bit value, rotated in steps of two bits. */ + for (i = 0; i < 4096; i += 256, m = lj_rol(m, 2)) + if (m <= 255) return ARMI_K12|m|i; + /* Otherwise try negation/complement with the inverse instruction. */ + invai = emit_invai[((ai >> 21) & 15)]; + if (!invai) return 0; /* Failed. No inverse instruction. */ + m = ~(uint32_t)n; + if (invai == ((ARMI_SUB^ARMI_ADD) >> 21) || + invai == (ARMI_CMP^ARMI_CMN) >> 21) m++; + for (i = 0; i < 4096; i += 256, m = lj_rol(m, 2)) + if (m <= 255) return ARMI_K12|(invai<<21)|m|i; + return 0; /* Failed. */ +} + +/* -- Emit basic instructions --------------------------------------------- */ + +static void emit_dnm(ASMState *as, ARMIns ai, Reg rd, Reg rn, Reg rm) +{ + *--as->mcp = ai | ARMF_D(rd) | ARMF_N(rn) | ARMF_M(rm); +} + +static void emit_dm(ASMState *as, ARMIns ai, Reg rd, Reg rm) +{ + *--as->mcp = ai | ARMF_D(rd) | ARMF_M(rm); +} + +static void emit_dn(ASMState *as, ARMIns ai, Reg rd, Reg rn) +{ + *--as->mcp = ai | ARMF_D(rd) | ARMF_N(rn); +} + +static void emit_nm(ASMState *as, ARMIns ai, Reg rn, Reg rm) +{ + *--as->mcp = ai | ARMF_N(rn) | ARMF_M(rm); +} + +static void emit_d(ASMState *as, ARMIns ai, Reg rd) +{ + *--as->mcp = ai | ARMF_D(rd); +} + +static void emit_n(ASMState *as, ARMIns ai, Reg rn) +{ + *--as->mcp = ai | ARMF_N(rn); +} + +static void emit_m(ASMState *as, ARMIns ai, Reg rm) +{ + *--as->mcp = ai | ARMF_M(rm); +} + +static void emit_lsox(ASMState *as, ARMIns ai, Reg rd, Reg rn, int32_t ofs) +{ + lua_assert(ofs >= -255 && ofs <= 255); + if (ofs < 0) ofs = -ofs; else ai |= ARMI_LS_U; + *--as->mcp = ai | ARMI_LS_P | ARMI_LSX_I | ARMF_D(rd) | ARMF_N(rn) | + ((ofs & 0xf0) << 4) | (ofs & 0x0f); +} + +static void emit_lso(ASMState *as, ARMIns ai, Reg rd, Reg rn, int32_t ofs) +{ + lua_assert(ofs >= -4095 && ofs <= 4095); + /* Combine LDR/STR pairs to LDRD/STRD. */ + if (*as->mcp == (ai|ARMI_LS_P|ARMI_LS_U|ARMF_D(rd^1)|ARMF_N(rn)|(ofs^4)) && + (ai & ~(ARMI_LDR^ARMI_STR)) == ARMI_STR && rd != rn && + (uint32_t)ofs <= 252 && !(ofs & 3) && !((rd ^ (ofs >>2)) & 1) && + as->mcp != as->mcloop) { + as->mcp++; + emit_lsox(as, ai == ARMI_LDR ? ARMI_LDRD : ARMI_STRD, rd&~1, rn, ofs&~4); + return; + } + if (ofs < 0) ofs = -ofs; else ai |= ARMI_LS_U; + *--as->mcp = ai | ARMI_LS_P | ARMF_D(rd) | ARMF_N(rn) | ofs; +} + +#if !LJ_SOFTFP +static void emit_vlso(ASMState *as, ARMIns ai, Reg rd, Reg rn, int32_t ofs) +{ + lua_assert(ofs >= -1020 && ofs <= 1020 && (ofs&3) == 0); + if (ofs < 0) ofs = -ofs; else ai |= ARMI_LS_U; + *--as->mcp = ai | ARMI_LS_P | ARMF_D(rd & 15) | ARMF_N(rn) | (ofs >> 2); +} +#endif + +/* -- Emit loads/stores --------------------------------------------------- */ + +/* Prefer spills of BASE/L. */ +#define emit_canremat(ref) ((ref) < ASMREF_L) + +/* Try to find a one step delta relative to another constant. */ +static int emit_kdelta1(ASMState *as, Reg d, int32_t i) +{ + RegSet work = ~as->freeset & RSET_GPR; + while (work) { + Reg r = rset_picktop(work); + IRRef ref = regcost_ref(as->cost[r]); + lua_assert(r != d); + if (emit_canremat(ref)) { + int32_t delta = i - (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i); + uint32_t k = emit_isk12(ARMI_ADD, delta); + if (k) { + if (k == ARMI_K12) + emit_dm(as, ARMI_MOV, d, r); + else + emit_dn(as, ARMI_ADD^k, d, r); + return 1; + } + } + rset_clear(work, r); + } + return 0; /* Failed. */ +} + +/* Try to find a two step delta relative to another constant. */ +static int emit_kdelta2(ASMState *as, Reg d, int32_t i) +{ + RegSet work = ~as->freeset & RSET_GPR; + while (work) { + Reg r = rset_picktop(work); + IRRef ref = regcost_ref(as->cost[r]); + lua_assert(r != d); + if (emit_canremat(ref)) { + int32_t other = ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i; + if (other) { + int32_t delta = i - other; + uint32_t sh, inv = 0, k2, k; + if (delta < 0) { delta = -delta; inv = ARMI_ADD^ARMI_SUB; } + sh = lj_ffs(delta) & ~1; + k2 = emit_isk12(0, delta & (255 << sh)); + k = emit_isk12(0, delta & ~(255 << sh)); + if (k) { + emit_dn(as, ARMI_ADD^k2^inv, d, d); + emit_dn(as, ARMI_ADD^k^inv, d, r); + return 1; + } + } + } + rset_clear(work, r); + } + return 0; /* Failed. */ +} + +/* Load a 32 bit constant into a GPR. */ +static void emit_loadi(ASMState *as, Reg r, int32_t i) +{ + uint32_t k = emit_isk12(ARMI_MOV, i); + lua_assert(rset_test(as->freeset, r) || r == RID_TMP); + if (k) { + /* Standard K12 constant. */ + emit_d(as, ARMI_MOV^k, r); + } else if ((as->flags & JIT_F_ARMV6T2) && (uint32_t)i < 0x00010000u) { + /* 16 bit loword constant for ARMv6T2. */ + emit_d(as, ARMI_MOVW|(i & 0x0fff)|((i & 0xf000)<<4), r); + } else if (emit_kdelta1(as, r, i)) { + /* One step delta relative to another constant. */ + } else if ((as->flags & JIT_F_ARMV6T2)) { + /* 32 bit hiword/loword constant for ARMv6T2. */ + emit_d(as, ARMI_MOVT|((i>>16) & 0x0fff)|(((i>>16) & 0xf000)<<4), r); + emit_d(as, ARMI_MOVW|(i & 0x0fff)|((i & 0xf000)<<4), r); + } else if (emit_kdelta2(as, r, i)) { + /* Two step delta relative to another constant. */ + } else { + /* Otherwise construct the constant with up to 4 instructions. */ + /* NYI: use mvn+bic, use pc-relative loads. */ + for (;;) { + uint32_t sh = lj_ffs(i) & ~1; + int32_t m = i & (255 << sh); + i &= ~(255 << sh); + if (i == 0) { + emit_d(as, ARMI_MOV ^ emit_isk12(0, m), r); + break; + } + emit_dn(as, ARMI_ORR ^ emit_isk12(0, m), r, r); + } + } +} + +#define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr))) + +static Reg ra_allock(ASMState *as, int32_t k, RegSet allow); + +/* Get/set from constant pointer. */ +static void emit_lsptr(ASMState *as, ARMIns ai, Reg r, void *p) +{ + int32_t i = i32ptr(p); + emit_lso(as, ai, r, ra_allock(as, (i & ~4095), rset_exclude(RSET_GPR, r)), + (i & 4095)); +} + +#if !LJ_SOFTFP +/* Load a number constant into an FPR. */ +static void emit_loadn(ASMState *as, Reg r, cTValue *tv) +{ + int32_t i; + if ((as->flags & JIT_F_VFPV3) && !tv->u32.lo) { + uint32_t hi = tv->u32.hi; + uint32_t b = ((hi >> 22) & 0x1ff); + if (!(hi & 0xffff) && (b == 0x100 || b == 0x0ff)) { + *--as->mcp = ARMI_VMOVI_D | ARMF_D(r & 15) | + ((tv->u32.hi >> 12) & 0x00080000) | + ((tv->u32.hi >> 4) & 0x00070000) | + ((tv->u32.hi >> 16) & 0x0000000f); + return; + } + } + i = i32ptr(tv); + emit_vlso(as, ARMI_VLDR_D, r, + ra_allock(as, (i & ~1020), RSET_GPR), (i & 1020)); +} +#endif + +/* Get/set global_State fields. */ +#define emit_getgl(as, r, field) \ + emit_lsptr(as, ARMI_LDR, (r), (void *)&J2G(as->J)->field) +#define emit_setgl(as, r, field) \ + emit_lsptr(as, ARMI_STR, (r), (void *)&J2G(as->J)->field) + +/* Trace number is determined from pc of exit instruction. */ +#define emit_setvmstate(as, i) UNUSED(i) + +/* -- Emit control-flow instructions -------------------------------------- */ + +/* Label for internal jumps. */ +typedef MCode *MCLabel; + +/* Return label pointing to current PC. */ +#define emit_label(as) ((as)->mcp) + +static void emit_branch(ASMState *as, ARMIns ai, MCode *target) +{ + MCode *p = as->mcp; + ptrdiff_t delta = (target - p) - 1; + lua_assert(((delta + 0x00800000) >> 24) == 0); + *--p = ai | ((uint32_t)delta & 0x00ffffffu); + as->mcp = p; +} + +#define emit_jmp(as, target) emit_branch(as, ARMI_B, (target)) + +static void emit_call(ASMState *as, void *target) +{ + MCode *p = --as->mcp; + ptrdiff_t delta = ((char *)target - (char *)p) - 8; + if ((((delta>>2) + 0x00800000) >> 24) == 0) { + if ((delta & 1)) + *p = ARMI_BLX | ((uint32_t)(delta>>2) & 0x00ffffffu) | ((delta&2) << 27); + else + *p = ARMI_BL | ((uint32_t)(delta>>2) & 0x00ffffffu); + } else { /* Target out of range: need indirect call. But don't use R0-R3. */ + Reg r = ra_allock(as, i32ptr(target), RSET_RANGE(RID_R4, RID_R12+1)); + *p = ARMI_BLXr | ARMF_M(r); + } +} + +/* -- Emit generic operations --------------------------------------------- */ + +/* Generic move between two regs. */ +static void emit_movrr(ASMState *as, IRIns *ir, Reg dst, Reg src) +{ +#if LJ_SOFTFP + lua_assert(!irt_isnum(ir->t)); UNUSED(ir); +#else + if (dst >= RID_MAX_GPR) { + emit_dm(as, irt_isnum(ir->t) ? ARMI_VMOV_D : ARMI_VMOV_S, + (dst & 15), (src & 15)); + return; + } +#endif + if (as->mcp != as->mcloop) { /* Swap early registers for loads/stores. */ + MCode ins = *as->mcp, swp = (src^dst); + if ((ins & 0x0c000000) == 0x04000000 && (ins & 0x02000010) != 0x02000010) { + if (!((ins ^ (dst << 16)) & 0x000f0000)) + *as->mcp = ins ^ (swp << 16); /* Swap N in load/store. */ + if (!(ins & 0x00100000) && !((ins ^ (dst << 12)) & 0x0000f000)) + *as->mcp = ins ^ (swp << 12); /* Swap D in store. */ + } + } + emit_dm(as, ARMI_MOV, dst, src); +} + +/* Generic load of register from stack slot. */ +static void emit_spload(ASMState *as, IRIns *ir, Reg r, int32_t ofs) +{ +#if LJ_SOFTFP + lua_assert(!irt_isnum(ir->t)); UNUSED(ir); +#else + if (r >= RID_MAX_GPR) + emit_vlso(as, irt_isnum(ir->t) ? ARMI_VLDR_D : ARMI_VLDR_S, r, RID_SP, ofs); + else +#endif + emit_lso(as, ARMI_LDR, r, RID_SP, ofs); +} + +/* Generic store of register to stack slot. */ +static void emit_spstore(ASMState *as, IRIns *ir, Reg r, int32_t ofs) +{ +#if LJ_SOFTFP + lua_assert(!irt_isnum(ir->t)); UNUSED(ir); +#else + if (r >= RID_MAX_GPR) + emit_vlso(as, irt_isnum(ir->t) ? ARMI_VSTR_D : ARMI_VSTR_S, r, RID_SP, ofs); + else +#endif + emit_lso(as, ARMI_STR, r, RID_SP, ofs); +} + +/* Emit an arithmetic/logic operation with a constant operand. */ +static void emit_opk(ASMState *as, ARMIns ai, Reg dest, Reg src, + int32_t i, RegSet allow) +{ + uint32_t k = emit_isk12(ai, i); + if (k) + emit_dn(as, ai^k, dest, src); + else + emit_dnm(as, ai, dest, src, ra_allock(as, i, allow)); +} + +/* Add offset to pointer. */ +static void emit_addptr(ASMState *as, Reg r, int32_t ofs) +{ + if (ofs) + emit_opk(as, ARMI_ADD, r, r, ofs, rset_exclude(RSET_GPR, r)); +} + +#define emit_spsub(as, ofs) emit_addptr(as, RID_SP, -(ofs)) + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_mips.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_mips.h new file mode 100644 index 000000000..0fc07d910 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_mips.h @@ -0,0 +1,211 @@ +/* +** MIPS instruction emitter. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* -- Emit basic instructions --------------------------------------------- */ + +static void emit_dst(ASMState *as, MIPSIns mi, Reg rd, Reg rs, Reg rt) +{ + *--as->mcp = mi | MIPSF_D(rd) | MIPSF_S(rs) | MIPSF_T(rt); +} + +static void emit_dta(ASMState *as, MIPSIns mi, Reg rd, Reg rt, uint32_t a) +{ + *--as->mcp = mi | MIPSF_D(rd) | MIPSF_T(rt) | MIPSF_A(a); +} + +#define emit_ds(as, mi, rd, rs) emit_dst(as, (mi), (rd), (rs), 0) +#define emit_tg(as, mi, rt, rg) emit_dst(as, (mi), (rg)&31, 0, (rt)) + +static void emit_tsi(ASMState *as, MIPSIns mi, Reg rt, Reg rs, int32_t i) +{ + *--as->mcp = mi | MIPSF_T(rt) | MIPSF_S(rs) | (i & 0xffff); +} + +#define emit_ti(as, mi, rt, i) emit_tsi(as, (mi), (rt), 0, (i)) +#define emit_hsi(as, mi, rh, rs, i) emit_tsi(as, (mi), (rh) & 31, (rs), (i)) + +static void emit_fgh(ASMState *as, MIPSIns mi, Reg rf, Reg rg, Reg rh) +{ + *--as->mcp = mi | MIPSF_F(rf&31) | MIPSF_G(rg&31) | MIPSF_H(rh&31); +} + +#define emit_fg(as, mi, rf, rg) emit_fgh(as, (mi), (rf), (rg), 0) + +static void emit_rotr(ASMState *as, Reg dest, Reg src, Reg tmp, uint32_t shift) +{ + if ((as->flags & JIT_F_MIPS32R2)) { + emit_dta(as, MIPSI_ROTR, dest, src, shift); + } else { + emit_dst(as, MIPSI_OR, dest, dest, tmp); + emit_dta(as, MIPSI_SLL, dest, src, (-shift)&31); + emit_dta(as, MIPSI_SRL, tmp, src, shift); + } +} + +/* -- Emit loads/stores --------------------------------------------------- */ + +/* Prefer rematerialization of BASE/L from global_State over spills. */ +#define emit_canremat(ref) ((ref) <= REF_BASE) + +/* Try to find a one step delta relative to another constant. */ +static int emit_kdelta1(ASMState *as, Reg t, int32_t i) +{ + RegSet work = ~as->freeset & RSET_GPR; + while (work) { + Reg r = rset_picktop(work); + IRRef ref = regcost_ref(as->cost[r]); + lua_assert(r != t); + if (ref < ASMREF_L) { + int32_t delta = i - (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i); + if (checki16(delta)) { + emit_tsi(as, MIPSI_ADDIU, t, r, delta); + return 1; + } + } + rset_clear(work, r); + } + return 0; /* Failed. */ +} + +/* Load a 32 bit constant into a GPR. */ +static void emit_loadi(ASMState *as, Reg r, int32_t i) +{ + if (checki16(i)) { + emit_ti(as, MIPSI_LI, r, i); + } else { + if ((i & 0xffff)) { + int32_t jgl = i32ptr(J2G(as->J)); + if ((uint32_t)(i-jgl) < 65536) { + emit_tsi(as, MIPSI_ADDIU, r, RID_JGL, i-jgl-32768); + return; + } else if (emit_kdelta1(as, r, i)) { + return; + } else if ((i >> 16) == 0) { + emit_tsi(as, MIPSI_ORI, r, RID_ZERO, i); + return; + } + emit_tsi(as, MIPSI_ORI, r, r, i); + } + emit_ti(as, MIPSI_LUI, r, (i >> 16)); + } +} + +#define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr))) + +static Reg ra_allock(ASMState *as, int32_t k, RegSet allow); +static void ra_allockreg(ASMState *as, int32_t k, Reg r); + +/* Get/set from constant pointer. */ +static void emit_lsptr(ASMState *as, MIPSIns mi, Reg r, void *p, RegSet allow) +{ + int32_t jgl = i32ptr(J2G(as->J)); + int32_t i = i32ptr(p); + Reg base; + if ((uint32_t)(i-jgl) < 65536) { + i = i-jgl-32768; + base = RID_JGL; + } else { + base = ra_allock(as, i-(int16_t)i, allow); + } + emit_tsi(as, mi, r, base, i); +} + +#define emit_loadn(as, r, tv) \ + emit_lsptr(as, MIPSI_LDC1, ((r) & 31), (void *)(tv), RSET_GPR) + +/* Get/set global_State fields. */ +static void emit_lsglptr(ASMState *as, MIPSIns mi, Reg r, int32_t ofs) +{ + emit_tsi(as, mi, r, RID_JGL, ofs-32768); +} + +#define emit_getgl(as, r, field) \ + emit_lsglptr(as, MIPSI_LW, (r), (int32_t)offsetof(global_State, field)) +#define emit_setgl(as, r, field) \ + emit_lsglptr(as, MIPSI_SW, (r), (int32_t)offsetof(global_State, field)) + +/* Trace number is determined from per-trace exit stubs. */ +#define emit_setvmstate(as, i) UNUSED(i) + +/* -- Emit control-flow instructions -------------------------------------- */ + +/* Label for internal jumps. */ +typedef MCode *MCLabel; + +/* Return label pointing to current PC. */ +#define emit_label(as) ((as)->mcp) + +static void emit_branch(ASMState *as, MIPSIns mi, Reg rs, Reg rt, MCode *target) +{ + MCode *p = as->mcp; + ptrdiff_t delta = target - p; + lua_assert(((delta + 0x8000) >> 16) == 0); + *--p = mi | MIPSF_S(rs) | MIPSF_T(rt) | ((uint32_t)delta & 0xffffu); + as->mcp = p; +} + +static void emit_jmp(ASMState *as, MCode *target) +{ + *--as->mcp = MIPSI_NOP; + emit_branch(as, MIPSI_B, RID_ZERO, RID_ZERO, (target)); +} + +static void emit_call(ASMState *as, void *target) +{ + MCode *p = as->mcp; + *--p = MIPSI_NOP; + if ((((uintptr_t)target ^ (uintptr_t)p) >> 28) == 0) + *--p = MIPSI_JAL | (((uintptr_t)target >>2) & 0x03ffffffu); + else /* Target out of range: need indirect call. */ + *--p = MIPSI_JALR | MIPSF_S(RID_CFUNCADDR); + as->mcp = p; + ra_allockreg(as, i32ptr(target), RID_CFUNCADDR); +} + +/* -- Emit generic operations --------------------------------------------- */ + +#define emit_move(as, dst, src) \ + emit_ds(as, MIPSI_MOVE, (dst), (src)) + +/* Generic move between two regs. */ +static void emit_movrr(ASMState *as, IRIns *ir, Reg dst, Reg src) +{ + if (dst < RID_MAX_GPR) + emit_move(as, dst, src); + else + emit_fg(as, irt_isnum(ir->t) ? MIPSI_MOV_D : MIPSI_MOV_S, dst, src); +} + +/* Generic load of register from stack slot. */ +static void emit_spload(ASMState *as, IRIns *ir, Reg r, int32_t ofs) +{ + if (r < RID_MAX_GPR) + emit_tsi(as, MIPSI_LW, r, RID_SP, ofs); + else + emit_tsi(as, irt_isnum(ir->t) ? MIPSI_LDC1 : MIPSI_LWC1, + (r & 31), RID_SP, ofs); +} + +/* Generic store of register to stack slot. */ +static void emit_spstore(ASMState *as, IRIns *ir, Reg r, int32_t ofs) +{ + if (r < RID_MAX_GPR) + emit_tsi(as, MIPSI_SW, r, RID_SP, ofs); + else + emit_tsi(as, irt_isnum(ir->t) ? MIPSI_SDC1 : MIPSI_SWC1, + (r&31), RID_SP, ofs); +} + +/* Add offset to pointer. */ +static void emit_addptr(ASMState *as, Reg r, int32_t ofs) +{ + if (ofs) { + lua_assert(checki16(ofs)); + emit_tsi(as, MIPSI_ADDIU, r, r, ofs); + } +} + +#define emit_spsub(as, ofs) emit_addptr(as, RID_SP, -(ofs)) + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_ppc.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_ppc.h new file mode 100644 index 000000000..14edf00fd --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_ppc.h @@ -0,0 +1,238 @@ +/* +** PPC instruction emitter. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* -- Emit basic instructions --------------------------------------------- */ + +static void emit_tab(ASMState *as, PPCIns pi, Reg rt, Reg ra, Reg rb) +{ + *--as->mcp = pi | PPCF_T(rt) | PPCF_A(ra) | PPCF_B(rb); +} + +#define emit_asb(as, pi, ra, rs, rb) emit_tab(as, (pi), (rs), (ra), (rb)) +#define emit_as(as, pi, ra, rs) emit_tab(as, (pi), (rs), (ra), 0) +#define emit_ab(as, pi, ra, rb) emit_tab(as, (pi), 0, (ra), (rb)) + +static void emit_tai(ASMState *as, PPCIns pi, Reg rt, Reg ra, int32_t i) +{ + *--as->mcp = pi | PPCF_T(rt) | PPCF_A(ra) | (i & 0xffff); +} + +#define emit_ti(as, pi, rt, i) emit_tai(as, (pi), (rt), 0, (i)) +#define emit_ai(as, pi, ra, i) emit_tai(as, (pi), 0, (ra), (i)) +#define emit_asi(as, pi, ra, rs, i) emit_tai(as, (pi), (rs), (ra), (i)) + +#define emit_fab(as, pi, rf, ra, rb) \ + emit_tab(as, (pi), (rf)&31, (ra)&31, (rb)&31) +#define emit_fb(as, pi, rf, rb) emit_tab(as, (pi), (rf)&31, 0, (rb)&31) +#define emit_fac(as, pi, rf, ra, rc) \ + emit_tab(as, (pi) | PPCF_C((rc) & 31), (rf)&31, (ra)&31, 0) +#define emit_facb(as, pi, rf, ra, rc, rb) \ + emit_tab(as, (pi) | PPCF_C((rc) & 31), (rf)&31, (ra)&31, (rb)&31) +#define emit_fai(as, pi, rf, ra, i) emit_tai(as, (pi), (rf)&31, (ra), (i)) + +static void emit_rot(ASMState *as, PPCIns pi, Reg ra, Reg rs, + int32_t n, int32_t b, int32_t e) +{ + *--as->mcp = pi | PPCF_T(rs) | PPCF_A(ra) | PPCF_B(n) | + PPCF_MB(b) | PPCF_ME(e); +} + +static void emit_slwi(ASMState *as, Reg ra, Reg rs, int32_t n) +{ + lua_assert(n >= 0 && n < 32); + emit_rot(as, PPCI_RLWINM, ra, rs, n, 0, 31-n); +} + +static void emit_rotlwi(ASMState *as, Reg ra, Reg rs, int32_t n) +{ + lua_assert(n >= 0 && n < 32); + emit_rot(as, PPCI_RLWINM, ra, rs, n, 0, 31); +} + +/* -- Emit loads/stores --------------------------------------------------- */ + +/* Prefer rematerialization of BASE/L from global_State over spills. */ +#define emit_canremat(ref) ((ref) <= REF_BASE) + +/* Try to find a one step delta relative to another constant. */ +static int emit_kdelta1(ASMState *as, Reg t, int32_t i) +{ + RegSet work = ~as->freeset & RSET_GPR; + while (work) { + Reg r = rset_picktop(work); + IRRef ref = regcost_ref(as->cost[r]); + lua_assert(r != t); + if (ref < ASMREF_L) { + int32_t delta = i - (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i); + if (checki16(delta)) { + emit_tai(as, PPCI_ADDI, t, r, delta); + return 1; + } + } + rset_clear(work, r); + } + return 0; /* Failed. */ +} + +/* Load a 32 bit constant into a GPR. */ +static void emit_loadi(ASMState *as, Reg r, int32_t i) +{ + if (checki16(i)) { + emit_ti(as, PPCI_LI, r, i); + } else { + if ((i & 0xffff)) { + int32_t jgl = i32ptr(J2G(as->J)); + if ((uint32_t)(i-jgl) < 65536) { + emit_tai(as, PPCI_ADDI, r, RID_JGL, i-jgl-32768); + return; + } else if (emit_kdelta1(as, r, i)) { + return; + } + emit_asi(as, PPCI_ORI, r, r, i); + } + emit_ti(as, PPCI_LIS, r, (i >> 16)); + } +} + +#define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr))) + +static Reg ra_allock(ASMState *as, int32_t k, RegSet allow); + +/* Get/set from constant pointer. */ +static void emit_lsptr(ASMState *as, PPCIns pi, Reg r, void *p, RegSet allow) +{ + int32_t jgl = i32ptr(J2G(as->J)); + int32_t i = i32ptr(p); + Reg base; + if ((uint32_t)(i-jgl) < 65536) { + i = i-jgl-32768; + base = RID_JGL; + } else { + base = ra_allock(as, i-(int16_t)i, allow); + } + emit_tai(as, pi, r, base, i); +} + +#define emit_loadn(as, r, tv) \ + emit_lsptr(as, PPCI_LFD, ((r) & 31), (void *)(tv), RSET_GPR) + +/* Get/set global_State fields. */ +static void emit_lsglptr(ASMState *as, PPCIns pi, Reg r, int32_t ofs) +{ + emit_tai(as, pi, r, RID_JGL, ofs-32768); +} + +#define emit_getgl(as, r, field) \ + emit_lsglptr(as, PPCI_LWZ, (r), (int32_t)offsetof(global_State, field)) +#define emit_setgl(as, r, field) \ + emit_lsglptr(as, PPCI_STW, (r), (int32_t)offsetof(global_State, field)) + +/* Trace number is determined from per-trace exit stubs. */ +#define emit_setvmstate(as, i) UNUSED(i) + +/* -- Emit control-flow instructions -------------------------------------- */ + +/* Label for internal jumps. */ +typedef MCode *MCLabel; + +/* Return label pointing to current PC. */ +#define emit_label(as) ((as)->mcp) + +static void emit_condbranch(ASMState *as, PPCIns pi, PPCCC cc, MCode *target) +{ + MCode *p = --as->mcp; + ptrdiff_t delta = (char *)target - (char *)p; + lua_assert(((delta + 0x8000) >> 16) == 0); + pi ^= (delta & 0x8000) * (PPCF_Y/0x8000); + *p = pi | PPCF_CC(cc) | ((uint32_t)delta & 0xffffu); +} + +static void emit_jmp(ASMState *as, MCode *target) +{ + MCode *p = --as->mcp; + ptrdiff_t delta = (char *)target - (char *)p; + *p = PPCI_B | (delta & 0x03fffffcu); +} + +static void emit_call(ASMState *as, void *target) +{ + MCode *p = --as->mcp; + ptrdiff_t delta = (char *)target - (char *)p; + if ((((delta>>2) + 0x00800000) >> 24) == 0) { + *p = PPCI_BL | (delta & 0x03fffffcu); + } else { /* Target out of range: need indirect call. Don't use arg reg. */ + RegSet allow = RSET_GPR & ~RSET_RANGE(RID_R0, REGARG_LASTGPR+1); + Reg r = ra_allock(as, i32ptr(target), allow); + *p = PPCI_BCTRL; + p[-1] = PPCI_MTCTR | PPCF_T(r); + as->mcp = p-1; + } +} + +/* -- Emit generic operations --------------------------------------------- */ + +#define emit_mr(as, dst, src) \ + emit_asb(as, PPCI_MR, (dst), (src), (src)) + +/* Generic move between two regs. */ +static void emit_movrr(ASMState *as, IRIns *ir, Reg dst, Reg src) +{ + UNUSED(ir); + if (dst < RID_MAX_GPR) + emit_mr(as, dst, src); + else + emit_fb(as, PPCI_FMR, dst, src); +} + +/* Generic load of register from stack slot. */ +static void emit_spload(ASMState *as, IRIns *ir, Reg r, int32_t ofs) +{ + if (r < RID_MAX_GPR) + emit_tai(as, PPCI_LWZ, r, RID_SP, ofs); + else + emit_fai(as, irt_isnum(ir->t) ? PPCI_LFD : PPCI_LFS, r, RID_SP, ofs); +} + +/* Generic store of register to stack slot. */ +static void emit_spstore(ASMState *as, IRIns *ir, Reg r, int32_t ofs) +{ + if (r < RID_MAX_GPR) + emit_tai(as, PPCI_STW, r, RID_SP, ofs); + else + emit_fai(as, irt_isnum(ir->t) ? PPCI_STFD : PPCI_STFS, r, RID_SP, ofs); +} + +/* Emit a compare (for equality) with a constant operand. */ +static void emit_cmpi(ASMState *as, Reg r, int32_t k) +{ + if (checki16(k)) { + emit_ai(as, PPCI_CMPWI, r, k); + } else if (checku16(k)) { + emit_ai(as, PPCI_CMPLWI, r, k); + } else { + emit_ai(as, PPCI_CMPLWI, RID_TMP, k); + emit_asi(as, PPCI_XORIS, RID_TMP, r, (k >> 16)); + } +} + +/* Add offset to pointer. */ +static void emit_addptr(ASMState *as, Reg r, int32_t ofs) +{ + if (ofs) { + emit_tai(as, PPCI_ADDI, r, r, ofs); + if (!checki16(ofs)) + emit_tai(as, PPCI_ADDIS, r, r, (ofs + 32768) >> 16); + } +} + +static void emit_spsub(ASMState *as, int32_t ofs) +{ + if (ofs) { + emit_tai(as, PPCI_STWU, RID_TMP, RID_SP, -ofs); + emit_tai(as, PPCI_ADDI, RID_TMP, RID_SP, + CFRAME_SIZE + (as->parent ? as->parent->spadjust : 0)); + } +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_x86.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_x86.h new file mode 100644 index 000000000..3a2f6510b --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_emit_x86.h @@ -0,0 +1,466 @@ +/* +** x86/x64 instruction emitter. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* -- Emit basic instructions --------------------------------------------- */ + +#define MODRM(mode, r1, r2) ((MCode)((mode)+(((r1)&7)<<3)+((r2)&7))) + +#if LJ_64 +#define REXRB(p, rr, rb) \ + { MCode rex = 0x40 + (((rr)>>1)&4) + (((rb)>>3)&1); \ + if (rex != 0x40) *--(p) = rex; } +#define FORCE_REX 0x200 +#define REX_64 (FORCE_REX|0x080000) +#else +#define REXRB(p, rr, rb) ((void)0) +#define FORCE_REX 0 +#define REX_64 0 +#endif + +#define emit_i8(as, i) (*--as->mcp = (MCode)(i)) +#define emit_i32(as, i) (*(int32_t *)(as->mcp-4) = (i), as->mcp -= 4) +#define emit_u32(as, u) (*(uint32_t *)(as->mcp-4) = (u), as->mcp -= 4) + +#define emit_x87op(as, xo) \ + (*(uint16_t *)(as->mcp-2) = (uint16_t)(xo), as->mcp -= 2) + +/* op */ +static LJ_AINLINE MCode *emit_op(x86Op xo, Reg rr, Reg rb, Reg rx, + MCode *p, int delta) +{ + int n = (int8_t)xo; +#if defined(__GNUC__) + if (__builtin_constant_p(xo) && n == -2) + p[delta-2] = (MCode)(xo >> 24); + else if (__builtin_constant_p(xo) && n == -3) + *(uint16_t *)(p+delta-3) = (uint16_t)(xo >> 16); + else +#endif + *(uint32_t *)(p+delta-5) = (uint32_t)xo; + p += n + delta; +#if LJ_64 + { + uint32_t rex = 0x40 + ((rr>>1)&(4+(FORCE_REX>>1)))+((rx>>2)&2)+((rb>>3)&1); + if (rex != 0x40) { + rex |= (rr >> 16); + if (n == -4) { *p = (MCode)rex; rex = (MCode)(xo >> 8); } + else if ((xo & 0xffffff) == 0x6600fd) { *p = (MCode)rex; rex = 0x66; } + *--p = (MCode)rex; + } + } +#else + UNUSED(rr); UNUSED(rb); UNUSED(rx); +#endif + return p; +} + +/* op + modrm */ +#define emit_opm(xo, mode, rr, rb, p, delta) \ + (p[(delta)-1] = MODRM((mode), (rr), (rb)), \ + emit_op((xo), (rr), (rb), 0, (p), (delta))) + +/* op + modrm + sib */ +#define emit_opmx(xo, mode, scale, rr, rb, rx, p) \ + (p[-1] = MODRM((scale), (rx), (rb)), \ + p[-2] = MODRM((mode), (rr), RID_ESP), \ + emit_op((xo), (rr), (rb), (rx), (p), -1)) + +/* op r1, r2 */ +static void emit_rr(ASMState *as, x86Op xo, Reg r1, Reg r2) +{ + MCode *p = as->mcp; + as->mcp = emit_opm(xo, XM_REG, r1, r2, p, 0); +} + +#if LJ_64 && defined(LUA_USE_ASSERT) +/* [addr] is sign-extended in x64 and must be in lower 2G (not 4G). */ +static int32_t ptr2addr(const void *p) +{ + lua_assert((uintptr_t)p < (uintptr_t)0x80000000); + return i32ptr(p); +} +#else +#define ptr2addr(p) (i32ptr((p))) +#endif + +/* op r, [addr] */ +static void emit_rma(ASMState *as, x86Op xo, Reg rr, const void *addr) +{ + MCode *p = as->mcp; + *(int32_t *)(p-4) = ptr2addr(addr); +#if LJ_64 + p[-5] = MODRM(XM_SCALE1, RID_ESP, RID_EBP); + as->mcp = emit_opm(xo, XM_OFS0, rr, RID_ESP, p, -5); +#else + as->mcp = emit_opm(xo, XM_OFS0, rr, RID_EBP, p, -4); +#endif +} + +/* op r, [base+ofs] */ +static void emit_rmro(ASMState *as, x86Op xo, Reg rr, Reg rb, int32_t ofs) +{ + MCode *p = as->mcp; + x86Mode mode; + if (ra_hasreg(rb)) { + if (ofs == 0 && (rb&7) != RID_EBP) { + mode = XM_OFS0; + } else if (checki8(ofs)) { + *--p = (MCode)ofs; + mode = XM_OFS8; + } else { + p -= 4; + *(int32_t *)p = ofs; + mode = XM_OFS32; + } + if ((rb&7) == RID_ESP) + *--p = MODRM(XM_SCALE1, RID_ESP, RID_ESP); + } else { + *(int32_t *)(p-4) = ofs; +#if LJ_64 + p[-5] = MODRM(XM_SCALE1, RID_ESP, RID_EBP); + p -= 5; + rb = RID_ESP; +#else + p -= 4; + rb = RID_EBP; +#endif + mode = XM_OFS0; + } + as->mcp = emit_opm(xo, mode, rr, rb, p, 0); +} + +/* op r, [base+idx*scale+ofs] */ +static void emit_rmrxo(ASMState *as, x86Op xo, Reg rr, Reg rb, Reg rx, + x86Mode scale, int32_t ofs) +{ + MCode *p = as->mcp; + x86Mode mode; + if (ofs == 0 && (rb&7) != RID_EBP) { + mode = XM_OFS0; + } else if (checki8(ofs)) { + mode = XM_OFS8; + *--p = (MCode)ofs; + } else { + mode = XM_OFS32; + p -= 4; + *(int32_t *)p = ofs; + } + as->mcp = emit_opmx(xo, mode, scale, rr, rb, rx, p); +} + +/* op r, i */ +static void emit_gri(ASMState *as, x86Group xg, Reg rb, int32_t i) +{ + MCode *p = as->mcp; + x86Op xo; + if (checki8(i)) { + *--p = (MCode)i; + xo = XG_TOXOi8(xg); + } else { + p -= 4; + *(int32_t *)p = i; + xo = XG_TOXOi(xg); + } + as->mcp = emit_opm(xo, XM_REG, (Reg)(xg & 7) | (rb & REX_64), rb, p, 0); +} + +/* op [base+ofs], i */ +static void emit_gmroi(ASMState *as, x86Group xg, Reg rb, int32_t ofs, + int32_t i) +{ + x86Op xo; + if (checki8(i)) { + emit_i8(as, i); + xo = XG_TOXOi8(xg); + } else { + emit_i32(as, i); + xo = XG_TOXOi(xg); + } + emit_rmro(as, xo, (Reg)(xg & 7), rb, ofs); +} + +#define emit_shifti(as, xg, r, i) \ + (emit_i8(as, (i)), emit_rr(as, XO_SHIFTi, (Reg)(xg), (r))) + +/* op r, rm/mrm */ +static void emit_mrm(ASMState *as, x86Op xo, Reg rr, Reg rb) +{ + MCode *p = as->mcp; + x86Mode mode = XM_REG; + if (rb == RID_MRM) { + rb = as->mrm.base; + if (rb == RID_NONE) { + rb = RID_EBP; + mode = XM_OFS0; + p -= 4; + *(int32_t *)p = as->mrm.ofs; + if (as->mrm.idx != RID_NONE) + goto mrmidx; +#if LJ_64 + *--p = MODRM(XM_SCALE1, RID_ESP, RID_EBP); + rb = RID_ESP; +#endif + } else { + if (as->mrm.ofs == 0 && (rb&7) != RID_EBP) { + mode = XM_OFS0; + } else if (checki8(as->mrm.ofs)) { + *--p = (MCode)as->mrm.ofs; + mode = XM_OFS8; + } else { + p -= 4; + *(int32_t *)p = as->mrm.ofs; + mode = XM_OFS32; + } + if (as->mrm.idx != RID_NONE) { + mrmidx: + as->mcp = emit_opmx(xo, mode, as->mrm.scale, rr, rb, as->mrm.idx, p); + return; + } + if ((rb&7) == RID_ESP) + *--p = MODRM(XM_SCALE1, RID_ESP, RID_ESP); + } + } + as->mcp = emit_opm(xo, mode, rr, rb, p, 0); +} + +/* op rm/mrm, i */ +static void emit_gmrmi(ASMState *as, x86Group xg, Reg rb, int32_t i) +{ + x86Op xo; + if (checki8(i)) { + emit_i8(as, i); + xo = XG_TOXOi8(xg); + } else { + emit_i32(as, i); + xo = XG_TOXOi(xg); + } + emit_mrm(as, xo, (Reg)(xg & 7) | (rb & REX_64), (rb & ~REX_64)); +} + +/* -- Emit loads/stores --------------------------------------------------- */ + +/* Instruction selection for XMM moves. */ +#define XMM_MOVRR(as) ((as->flags & JIT_F_SPLIT_XMM) ? XO_MOVSD : XO_MOVAPS) +#define XMM_MOVRM(as) ((as->flags & JIT_F_SPLIT_XMM) ? XO_MOVLPD : XO_MOVSD) + +/* mov [base+ofs], i */ +static void emit_movmroi(ASMState *as, Reg base, int32_t ofs, int32_t i) +{ + emit_i32(as, i); + emit_rmro(as, XO_MOVmi, 0, base, ofs); +} + +/* mov [base+ofs], r */ +#define emit_movtomro(as, r, base, ofs) \ + emit_rmro(as, XO_MOVto, (r), (base), (ofs)) + +/* Get/set global_State fields. */ +#define emit_opgl(as, xo, r, field) \ + emit_rma(as, (xo), (r), (void *)&J2G(as->J)->field) +#define emit_getgl(as, r, field) emit_opgl(as, XO_MOV, (r), field) +#define emit_setgl(as, r, field) emit_opgl(as, XO_MOVto, (r), field) + +#define emit_setvmstate(as, i) \ + (emit_i32(as, i), emit_opgl(as, XO_MOVmi, 0, vmstate)) + +/* mov r, i / xor r, r */ +static void emit_loadi(ASMState *as, Reg r, int32_t i) +{ + /* XOR r,r is shorter, but modifies the flags. This is bad for HIOP. */ + if (i == 0 && !(LJ_32 && (IR(as->curins)->o == IR_HIOP || + (as->curins+1 < as->T->nins && + IR(as->curins+1)->o == IR_HIOP)))) { + emit_rr(as, XO_ARITH(XOg_XOR), r, r); + } else { + MCode *p = as->mcp; + *(int32_t *)(p-4) = i; + p[-5] = (MCode)(XI_MOVri+(r&7)); + p -= 5; + REXRB(p, 0, r); + as->mcp = p; + } +} + +/* mov r, addr */ +#define emit_loada(as, r, addr) \ + emit_loadi(as, (r), ptr2addr((addr))) + +#if LJ_64 +/* mov r, imm64 or shorter 32 bit extended load. */ +static void emit_loadu64(ASMState *as, Reg r, uint64_t u64) +{ + if (checku32(u64)) { /* 32 bit load clears upper 32 bits. */ + emit_loadi(as, r, (int32_t)u64); + } else if (checki32((int64_t)u64)) { /* Sign-extended 32 bit load. */ + MCode *p = as->mcp; + *(int32_t *)(p-4) = (int32_t)u64; + as->mcp = emit_opm(XO_MOVmi, XM_REG, REX_64, r, p, -4); + } else { /* Full-size 64 bit load. */ + MCode *p = as->mcp; + *(uint64_t *)(p-8) = u64; + p[-9] = (MCode)(XI_MOVri+(r&7)); + p[-10] = 0x48 + ((r>>3)&1); + p -= 10; + as->mcp = p; + } +} +#endif + +/* movsd r, [&tv->n] / xorps r, r */ +static void emit_loadn(ASMState *as, Reg r, cTValue *tv) +{ + if (tvispzero(tv)) /* Use xor only for +0. */ + emit_rr(as, XO_XORPS, r, r); + else + emit_rma(as, XMM_MOVRM(as), r, &tv->n); +} + +/* -- Emit control-flow instructions -------------------------------------- */ + +/* Label for short jumps. */ +typedef MCode *MCLabel; + +#if LJ_32 && LJ_HASFFI +/* jmp short target */ +static void emit_sjmp(ASMState *as, MCLabel target) +{ + MCode *p = as->mcp; + ptrdiff_t delta = target - p; + lua_assert(delta == (int8_t)delta); + p[-1] = (MCode)(int8_t)delta; + p[-2] = XI_JMPs; + as->mcp = p - 2; +} +#endif + +/* jcc short target */ +static void emit_sjcc(ASMState *as, int cc, MCLabel target) +{ + MCode *p = as->mcp; + ptrdiff_t delta = target - p; + lua_assert(delta == (int8_t)delta); + p[-1] = (MCode)(int8_t)delta; + p[-2] = (MCode)(XI_JCCs+(cc&15)); + as->mcp = p - 2; +} + +/* jcc short (pending target) */ +static MCLabel emit_sjcc_label(ASMState *as, int cc) +{ + MCode *p = as->mcp; + p[-1] = 0; + p[-2] = (MCode)(XI_JCCs+(cc&15)); + as->mcp = p - 2; + return p; +} + +/* Fixup jcc short target. */ +static void emit_sfixup(ASMState *as, MCLabel source) +{ + source[-1] = (MCode)(as->mcp-source); +} + +/* Return label pointing to current PC. */ +#define emit_label(as) ((as)->mcp) + +/* Compute relative 32 bit offset for jump and call instructions. */ +static LJ_AINLINE int32_t jmprel(MCode *p, MCode *target) +{ + ptrdiff_t delta = target - p; + lua_assert(delta == (int32_t)delta); + return (int32_t)delta; +} + +/* jcc target */ +static void emit_jcc(ASMState *as, int cc, MCode *target) +{ + MCode *p = as->mcp; + *(int32_t *)(p-4) = jmprel(p, target); + p[-5] = (MCode)(XI_JCCn+(cc&15)); + p[-6] = 0x0f; + as->mcp = p - 6; +} + +/* jmp target */ +static void emit_jmp(ASMState *as, MCode *target) +{ + MCode *p = as->mcp; + *(int32_t *)(p-4) = jmprel(p, target); + p[-5] = XI_JMP; + as->mcp = p - 5; +} + +/* call target */ +static void emit_call_(ASMState *as, MCode *target) +{ + MCode *p = as->mcp; +#if LJ_64 + if (target-p != (int32_t)(target-p)) { + /* Assumes RID_RET is never an argument to calls and always clobbered. */ + emit_rr(as, XO_GROUP5, XOg_CALL, RID_RET); + emit_loadu64(as, RID_RET, (uint64_t)target); + return; + } +#endif + *(int32_t *)(p-4) = jmprel(p, target); + p[-5] = XI_CALL; + as->mcp = p - 5; +} + +#define emit_call(as, f) emit_call_(as, (MCode *)(void *)(f)) + +/* -- Emit generic operations --------------------------------------------- */ + +/* Use 64 bit operations to handle 64 bit IR types. */ +#if LJ_64 +#define REX_64IR(ir, r) ((r) + (irt_is64((ir)->t) ? REX_64 : 0)) +#else +#define REX_64IR(ir, r) (r) +#endif + +/* Generic move between two regs. */ +static void emit_movrr(ASMState *as, IRIns *ir, Reg dst, Reg src) +{ + UNUSED(ir); + if (dst < RID_MAX_GPR) + emit_rr(as, XO_MOV, REX_64IR(ir, dst), src); + else + emit_rr(as, XMM_MOVRR(as), dst, src); +} + +/* Generic load of register from stack slot. */ +static void emit_spload(ASMState *as, IRIns *ir, Reg r, int32_t ofs) +{ + if (r < RID_MAX_GPR) + emit_rmro(as, XO_MOV, REX_64IR(ir, r), RID_ESP, ofs); + else + emit_rmro(as, irt_isnum(ir->t) ? XMM_MOVRM(as) : XO_MOVSS, r, RID_ESP, ofs); +} + +/* Generic store of register to stack slot. */ +static void emit_spstore(ASMState *as, IRIns *ir, Reg r, int32_t ofs) +{ + if (r < RID_MAX_GPR) + emit_rmro(as, XO_MOVto, REX_64IR(ir, r), RID_ESP, ofs); + else + emit_rmro(as, irt_isnum(ir->t) ? XO_MOVSDto : XO_MOVSSto, r, RID_ESP, ofs); +} + +/* Add offset to pointer. */ +static void emit_addptr(ASMState *as, Reg r, int32_t ofs) +{ + if (ofs) { + if ((as->flags & JIT_F_LEA_AGU)) + emit_rmro(as, XO_LEA, r, r, ofs); + else + emit_gri(as, XG_ARITHi(XOg_ADD), r, ofs); + } +} + +#define emit_spsub(as, ofs) emit_addptr(as, RID_ESP|REX_64, -(ofs)) + +/* Prefer rematerialization of BASE/L from global_State over spills. */ +#define emit_canremat(ref) ((ref) <= REF_BASE) + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_err.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_err.c new file mode 100644 index 000000000..081bfde4a --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_err.c @@ -0,0 +1,800 @@ +/* +** Error handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_err_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_err.h" +#include "lj_debug.h" +#include "lj_str.h" +#include "lj_func.h" +#include "lj_state.h" +#include "lj_frame.h" +#include "lj_ff.h" +#include "lj_trace.h" +#include "lj_vm.h" + +/* +** LuaJIT can either use internal or external frame unwinding: +** +** - Internal frame unwinding (INT) is free-standing and doesn't require +** any OS or library support. +** +** - External frame unwinding (EXT) uses the system-provided unwind handler. +** +** Pros and Cons: +** +** - EXT requires unwind tables for *all* functions on the C stack between +** the pcall/catch and the error/throw. This is the default on x64, +** but needs to be manually enabled on x86/PPC for non-C++ code. +** +** - INT is faster when actually throwing errors (but this happens rarely). +** Setting up error handlers is zero-cost in any case. +** +** - EXT provides full interoperability with C++ exceptions. You can throw +** Lua errors or C++ exceptions through a mix of Lua frames and C++ frames. +** C++ destructors are called as needed. C++ exceptions caught by pcall +** are converted to the string "C++ exception". Lua errors can be caught +** with catch (...) in C++. +** +** - INT has only limited support for automatically catching C++ exceptions +** on POSIX systems using DWARF2 stack unwinding. Other systems may use +** the wrapper function feature. Lua errors thrown through C++ frames +** cannot be caught by C++ code and C++ destructors are not run. +** +** EXT is the default on x64 systems, INT is the default on all other systems. +** +** EXT can be manually enabled on POSIX systems using GCC and DWARF2 stack +** unwinding with -DLUAJIT_UNWIND_EXTERNAL. *All* C code must be compiled +** with -funwind-tables (or -fexceptions). This includes LuaJIT itself (set +** TARGET_CFLAGS), all of your C/Lua binding code, all loadable C modules +** and all C libraries that have callbacks which may be used to call back +** into Lua. C++ code must *not* be compiled with -fno-exceptions. +** +** EXT cannot be enabled on WIN32 since system exceptions use code-driven SEH. +** EXT is mandatory on WIN64 since the calling convention has an abundance +** of callee-saved registers (rbx, rbp, rsi, rdi, r12-r15, xmm6-xmm15). +** EXT is mandatory on POSIX/x64 since the interpreter doesn't save r12/r13. +*/ + +#if defined(__GNUC__) && (LJ_TARGET_X64 || defined(LUAJIT_UNWIND_EXTERNAL)) +#define LJ_UNWIND_EXT 1 +#elif LJ_TARGET_X64 && LJ_TARGET_WINDOWS +#define LJ_UNWIND_EXT 1 +#endif + +/* -- Error messages ------------------------------------------------------ */ + +/* Error message strings. */ +LJ_DATADEF const char *lj_err_allmsg = +#define ERRDEF(name, msg) msg "\0" +#include "lj_errmsg.h" +; + +/* -- Internal frame unwinding -------------------------------------------- */ + +/* Unwind Lua stack and move error message to new top. */ +LJ_NOINLINE static void unwindstack(lua_State *L, TValue *top) +{ + lj_func_closeuv(L, top); + if (top < L->top-1) { + copyTV(L, top, L->top-1); + L->top = top+1; + } + lj_state_relimitstack(L); +} + +/* Unwind until stop frame. Optionally cleanup frames. */ +static void *err_unwind(lua_State *L, void *stopcf, int errcode) +{ + TValue *frame = L->base-1; + void *cf = L->cframe; + while (cf) { + int32_t nres = cframe_nres(cframe_raw(cf)); + if (nres < 0) { /* C frame without Lua frame? */ + TValue *top = restorestack(L, -nres); + if (frame < top) { /* Frame reached? */ + if (errcode) { + L->cframe = cframe_prev(cf); + L->base = frame+1; + unwindstack(L, top); + } + return cf; + } + } + if (frame <= tvref(L->stack)) + break; + switch (frame_typep(frame)) { + case FRAME_LUA: /* Lua frame. */ + case FRAME_LUAP: + frame = frame_prevl(frame); + break; + case FRAME_C: /* C frame. */ +#if LJ_HASFFI + unwind_c: +#endif +#if LJ_UNWIND_EXT + if (errcode) { + L->cframe = cframe_prev(cf); + L->base = frame_prevd(frame) + 1; + unwindstack(L, frame); + } else if (cf != stopcf) { + cf = cframe_prev(cf); + frame = frame_prevd(frame); + break; + } + return NULL; /* Continue unwinding. */ +#else + UNUSED(stopcf); + cf = cframe_prev(cf); + frame = frame_prevd(frame); + break; +#endif + case FRAME_CP: /* Protected C frame. */ + if (cframe_canyield(cf)) { /* Resume? */ + if (errcode) { + hook_leave(G(L)); /* Assumes nobody uses coroutines inside hooks. */ + L->cframe = NULL; + L->status = (uint8_t)errcode; + } + return cf; + } + if (errcode) { + L->cframe = cframe_prev(cf); + L->base = frame_prevd(frame) + 1; + unwindstack(L, frame); + } + return cf; + case FRAME_CONT: /* Continuation frame. */ +#if LJ_HASFFI + if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK) + goto unwind_c; +#endif + case FRAME_VARG: /* Vararg frame. */ + frame = frame_prevd(frame); + break; + case FRAME_PCALL: /* FF pcall() frame. */ + case FRAME_PCALLH: /* FF pcall() frame inside hook. */ + if (errcode) { + if (errcode == LUA_YIELD) { + frame = frame_prevd(frame); + break; + } + if (frame_typep(frame) == FRAME_PCALL) + hook_leave(G(L)); + L->cframe = cf; + L->base = frame_prevd(frame) + 1; + unwindstack(L, L->base); + } + return (void *)((intptr_t)cf | CFRAME_UNWIND_FF); + } + } + /* No C frame. */ + if (errcode) { + L->cframe = NULL; + L->base = tvref(L->stack)+1; + unwindstack(L, L->base); + if (G(L)->panic) + G(L)->panic(L); + exit(EXIT_FAILURE); + } + return L; /* Anything non-NULL will do. */ +} + +/* -- External frame unwinding -------------------------------------------- */ + +#if defined(__GNUC__) && !LJ_NO_UNWIND && !LJ_TARGET_WINDOWS + +/* +** We have to use our own definitions instead of the mandatory (!) unwind.h, +** since various OS, distros and compilers mess up the header installation. +*/ + +typedef struct _Unwind_Exception +{ + uint64_t exclass; + void (*excleanup)(int, struct _Unwind_Exception *); + uintptr_t p1, p2; +} __attribute__((__aligned__)) _Unwind_Exception; + +typedef struct _Unwind_Context _Unwind_Context; + +#define _URC_OK 0 +#define _URC_FATAL_PHASE1_ERROR 3 +#define _URC_HANDLER_FOUND 6 +#define _URC_INSTALL_CONTEXT 7 +#define _URC_CONTINUE_UNWIND 8 +#define _URC_FAILURE 9 + +#if !LJ_TARGET_ARM + +extern uintptr_t _Unwind_GetCFA(_Unwind_Context *); +extern void _Unwind_SetGR(_Unwind_Context *, int, uintptr_t); +extern void _Unwind_SetIP(_Unwind_Context *, uintptr_t); +extern void _Unwind_DeleteException(_Unwind_Exception *); +extern int _Unwind_RaiseException(_Unwind_Exception *); + +#define _UA_SEARCH_PHASE 1 +#define _UA_CLEANUP_PHASE 2 +#define _UA_HANDLER_FRAME 4 +#define _UA_FORCE_UNWIND 8 + +#define LJ_UEXCLASS 0x4c55414a49543200ULL /* LUAJIT2\0 */ +#define LJ_UEXCLASS_MAKE(c) (LJ_UEXCLASS | (uint64_t)(c)) +#define LJ_UEXCLASS_CHECK(cl) (((cl) ^ LJ_UEXCLASS) <= 0xff) +#define LJ_UEXCLASS_ERRCODE(cl) ((int)((cl) & 0xff)) + +/* DWARF2 personality handler referenced from interpreter .eh_frame. */ +LJ_FUNCA int lj_err_unwind_dwarf(int version, int actions, + uint64_t uexclass, _Unwind_Exception *uex, _Unwind_Context *ctx) +{ + void *cf; + lua_State *L; + if (version != 1) + return _URC_FATAL_PHASE1_ERROR; + UNUSED(uexclass); + cf = (void *)_Unwind_GetCFA(ctx); + L = cframe_L(cf); + if ((actions & _UA_SEARCH_PHASE)) { +#if LJ_UNWIND_EXT + if (err_unwind(L, cf, 0) == NULL) + return _URC_CONTINUE_UNWIND; +#endif + if (!LJ_UEXCLASS_CHECK(uexclass)) { + setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP)); + } + return _URC_HANDLER_FOUND; + } + if ((actions & _UA_CLEANUP_PHASE)) { + int errcode; + if (LJ_UEXCLASS_CHECK(uexclass)) { + errcode = LJ_UEXCLASS_ERRCODE(uexclass); + } else { + if ((actions & _UA_HANDLER_FRAME)) + _Unwind_DeleteException(uex); + errcode = LUA_ERRRUN; + } +#if LJ_UNWIND_EXT + cf = err_unwind(L, cf, errcode); + if ((actions & _UA_FORCE_UNWIND)) { + return _URC_CONTINUE_UNWIND; + } else if (cf) { + _Unwind_SetGR(ctx, LJ_TARGET_EHRETREG, errcode); + _Unwind_SetIP(ctx, (uintptr_t)(cframe_unwind_ff(cf) ? + lj_vm_unwind_ff_eh : + lj_vm_unwind_c_eh)); + return _URC_INSTALL_CONTEXT; + } +#if LJ_TARGET_X86ORX64 + else if ((actions & _UA_HANDLER_FRAME)) { + /* Workaround for ancient libgcc bug. Still present in RHEL 5.5. :-/ + ** Real fix: http://gcc.gnu.org/viewcvs/trunk/gcc/unwind-dw2.c?r1=121165&r2=124837&pathrev=153877&diff_format=h + */ + _Unwind_SetGR(ctx, LJ_TARGET_EHRETREG, errcode); + _Unwind_SetIP(ctx, (uintptr_t)lj_vm_unwind_rethrow); + return _URC_INSTALL_CONTEXT; + } +#endif +#else + /* This is not the proper way to escape from the unwinder. We get away with + ** it on non-x64 because the interpreter restores all callee-saved regs. + */ + lj_err_throw(L, errcode); +#endif + } + return _URC_CONTINUE_UNWIND; +} + +#if LJ_UNWIND_EXT +#if LJ_TARGET_OSX || defined(__OpenBSD__) +/* Sorry, no thread safety for OSX. Complain to Apple, not me. */ +static _Unwind_Exception static_uex; +#else +static __thread _Unwind_Exception static_uex; +#endif + +/* Raise DWARF2 exception. */ +static void err_raise_ext(int errcode) +{ + static_uex.exclass = LJ_UEXCLASS_MAKE(errcode); + static_uex.excleanup = NULL; + _Unwind_RaiseException(&static_uex); +} +#endif + +#else + +extern void _Unwind_DeleteException(void *); +extern int __gnu_unwind_frame (void *, _Unwind_Context *); +extern int _Unwind_VRS_Set(_Unwind_Context *, int, uint32_t, int, void *); +extern int _Unwind_VRS_Get(_Unwind_Context *, int, uint32_t, int, void *); + +static inline uint32_t _Unwind_GetGR(_Unwind_Context *ctx, int r) +{ + uint32_t v; + _Unwind_VRS_Get(ctx, 0, r, 0, &v); + return v; +} + +static inline void _Unwind_SetGR(_Unwind_Context *ctx, int r, uint32_t v) +{ + _Unwind_VRS_Set(ctx, 0, r, 0, &v); +} + +#define _US_VIRTUAL_UNWIND_FRAME 0 +#define _US_UNWIND_FRAME_STARTING 1 +#define _US_ACTION_MASK 3 +#define _US_FORCE_UNWIND 8 + +/* ARM unwinder personality handler referenced from interpreter .ARM.extab. */ +LJ_FUNCA int lj_err_unwind_arm(int state, void *ucb, _Unwind_Context *ctx) +{ + void *cf = (void *)_Unwind_GetGR(ctx, 13); + lua_State *L = cframe_L(cf); + if ((state & _US_ACTION_MASK) == _US_VIRTUAL_UNWIND_FRAME) { + setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP)); + return _URC_HANDLER_FOUND; + } + if ((state&(_US_ACTION_MASK|_US_FORCE_UNWIND)) == _US_UNWIND_FRAME_STARTING) { + _Unwind_DeleteException(ucb); + _Unwind_SetGR(ctx, 15, (uint32_t)(void *)lj_err_throw); + _Unwind_SetGR(ctx, 0, (uint32_t)L); + _Unwind_SetGR(ctx, 1, (uint32_t)LUA_ERRRUN); + return _URC_INSTALL_CONTEXT; + } + if (__gnu_unwind_frame(ucb, ctx) != _URC_OK) + return _URC_FAILURE; + return _URC_CONTINUE_UNWIND; +} + +#endif + +#elif LJ_TARGET_X64 && LJ_TARGET_WINDOWS + +/* +** Someone in Redmond owes me several days of my life. A lot of this is +** undocumented or just plain wrong on MSDN. Some of it can be gathered +** from 3rd party docs or must be found by trial-and-error. They really +** don't want you to write your own language-specific exception handler +** or to interact gracefully with MSVC. :-( +** +** Apparently MSVC doesn't call C++ destructors for foreign exceptions +** unless you compile your C++ code with /EHa. Unfortunately this means +** catch (...) also catches things like access violations. The use of +** _set_se_translator doesn't really help, because it requires /EHa, too. +*/ + +#define WIN32_LEAN_AND_MEAN +#include + +/* Taken from: http://www.nynaeve.net/?p=99 */ +typedef struct UndocumentedDispatcherContext { + ULONG64 ControlPc; + ULONG64 ImageBase; + PRUNTIME_FUNCTION FunctionEntry; + ULONG64 EstablisherFrame; + ULONG64 TargetIp; + PCONTEXT ContextRecord; + void (*LanguageHandler)(void); + PVOID HandlerData; + PUNWIND_HISTORY_TABLE HistoryTable; + ULONG ScopeIndex; + ULONG Fill0; +} UndocumentedDispatcherContext; + +/* Another wild guess. */ +extern void __DestructExceptionObject(EXCEPTION_RECORD *rec, int nothrow); + +#ifdef MINGW_SDK_INIT +/* Workaround for broken MinGW64 declaration. */ +VOID RtlUnwindEx_FIXED(PVOID,PVOID,PVOID,PVOID,PVOID,PVOID) asm("RtlUnwindEx"); +#define RtlUnwindEx RtlUnwindEx_FIXED +#endif + +#define LJ_MSVC_EXCODE ((DWORD)0xe06d7363) +#define LJ_GCC_EXCODE ((DWORD)0x20474343) + +#define LJ_EXCODE ((DWORD)0xe24c4a00) +#define LJ_EXCODE_MAKE(c) (LJ_EXCODE | (DWORD)(c)) +#define LJ_EXCODE_CHECK(cl) (((cl) ^ LJ_EXCODE) <= 0xff) +#define LJ_EXCODE_ERRCODE(cl) ((int)((cl) & 0xff)) + +/* Win64 exception handler for interpreter frame. */ +LJ_FUNCA EXCEPTION_DISPOSITION lj_err_unwind_win64(EXCEPTION_RECORD *rec, + void *cf, CONTEXT *ctx, UndocumentedDispatcherContext *dispatch) +{ + lua_State *L = cframe_L(cf); + int errcode = LJ_EXCODE_CHECK(rec->ExceptionCode) ? + LJ_EXCODE_ERRCODE(rec->ExceptionCode) : LUA_ERRRUN; + if ((rec->ExceptionFlags & 6)) { /* EH_UNWINDING|EH_EXIT_UNWIND */ + /* Unwind internal frames. */ + err_unwind(L, cf, errcode); + } else { + void *cf2 = err_unwind(L, cf, 0); + if (cf2) { /* We catch it, so start unwinding the upper frames. */ + if (rec->ExceptionCode == LJ_MSVC_EXCODE || + rec->ExceptionCode == LJ_GCC_EXCODE) { + __DestructExceptionObject(rec, 1); + setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP)); + } else if (!LJ_EXCODE_CHECK(rec->ExceptionCode)) { + /* Don't catch access violations etc. */ + return ExceptionContinueSearch; + } + /* Unwind the stack and call all handlers for all lower C frames + ** (including ourselves) again with EH_UNWINDING set. Then set + ** rsp = cf, rax = errcode and jump to the specified target. + */ + RtlUnwindEx(cf, (void *)((cframe_unwind_ff(cf2) && errcode != LUA_YIELD) ? + lj_vm_unwind_ff_eh : + lj_vm_unwind_c_eh), + rec, (void *)(uintptr_t)errcode, ctx, dispatch->HistoryTable); + /* RtlUnwindEx should never return. */ + } + } + return ExceptionContinueSearch; +} + +/* Raise Windows exception. */ +static void err_raise_ext(int errcode) +{ + RaiseException(LJ_EXCODE_MAKE(errcode), 1 /* EH_NONCONTINUABLE */, 0, NULL); +} + +#endif + +/* -- Error handling ------------------------------------------------------ */ + +/* Throw error. Find catch frame, unwind stack and continue. */ +LJ_NOINLINE void LJ_FASTCALL lj_err_throw(lua_State *L, int errcode) +{ + global_State *g = G(L); + lj_trace_abort(g); + setgcrefnull(g->jit_L); + L->status = 0; +#if LJ_UNWIND_EXT + err_raise_ext(errcode); + /* + ** A return from this function signals a corrupt C stack that cannot be + ** unwound. We have no choice but to call the panic function and exit. + ** + ** Usually this is caused by a C function without unwind information. + ** This should never happen on x64, but may happen if you've manually + ** enabled LUAJIT_UNWIND_EXTERNAL and forgot to recompile *every* + ** non-C++ file with -funwind-tables. + */ + if (G(L)->panic) + G(L)->panic(L); +#else + { + void *cf = err_unwind(L, NULL, errcode); + if (cframe_unwind_ff(cf)) + lj_vm_unwind_ff(cframe_raw(cf)); + else + lj_vm_unwind_c(cframe_raw(cf), errcode); + } +#endif + exit(EXIT_FAILURE); +} + +/* Return string object for error message. */ +LJ_NOINLINE GCstr *lj_err_str(lua_State *L, ErrMsg em) +{ + return lj_str_newz(L, err2msg(em)); +} + +/* Out-of-memory error. */ +LJ_NOINLINE void lj_err_mem(lua_State *L) +{ + if (L->status == LUA_ERRERR+1) /* Don't touch the stack during lua_open. */ + lj_vm_unwind_c(L->cframe, LUA_ERRMEM); + setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRMEM)); + lj_err_throw(L, LUA_ERRMEM); +} + +/* Find error function for runtime errors. Requires an extra stack traversal. */ +static ptrdiff_t finderrfunc(lua_State *L) +{ + cTValue *frame = L->base-1, *bot = tvref(L->stack); + void *cf = L->cframe; + while (frame > bot && cf) { + while (cframe_nres(cframe_raw(cf)) < 0) { /* cframe without frame? */ + if (frame >= restorestack(L, -cframe_nres(cf))) + break; + if (cframe_errfunc(cf) >= 0) /* Error handler not inherited (-1)? */ + return cframe_errfunc(cf); + cf = cframe_prev(cf); /* Else unwind cframe and continue searching. */ + if (cf == NULL) + return 0; + } + switch (frame_typep(frame)) { + case FRAME_LUA: + case FRAME_LUAP: + frame = frame_prevl(frame); + break; + case FRAME_C: + cf = cframe_prev(cf); + /* fallthrough */ + case FRAME_VARG: + frame = frame_prevd(frame); + break; + case FRAME_CONT: +#if LJ_HASFFI + if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK) + cf = cframe_prev(cf); +#endif + frame = frame_prevd(frame); + break; + case FRAME_CP: + if (cframe_canyield(cf)) return 0; + if (cframe_errfunc(cf) >= 0) + return cframe_errfunc(cf); + frame = frame_prevd(frame); + break; + case FRAME_PCALL: + case FRAME_PCALLH: + if (frame_ftsz(frame) >= (ptrdiff_t)(2*sizeof(TValue))) /* xpcall? */ + return savestack(L, frame-1); /* Point to xpcall's errorfunc. */ + return 0; + default: + lua_assert(0); + return 0; + } + } + return 0; +} + +/* Runtime error. */ +LJ_NOINLINE void lj_err_run(lua_State *L) +{ + ptrdiff_t ef = finderrfunc(L); + if (ef) { + TValue *errfunc = restorestack(L, ef); + TValue *top = L->top; + lj_trace_abort(G(L)); + if (!tvisfunc(errfunc) || L->status == LUA_ERRERR) { + setstrV(L, top-1, lj_err_str(L, LJ_ERR_ERRERR)); + lj_err_throw(L, LUA_ERRERR); + } + L->status = LUA_ERRERR; + copyTV(L, top, top-1); + copyTV(L, top-1, errfunc); + L->top = top+1; + lj_vm_call(L, top, 1+1); /* Stack: |errfunc|msg| -> |msg| */ + } + lj_err_throw(L, LUA_ERRRUN); +} + +/* Formatted runtime error message. */ +LJ_NORET LJ_NOINLINE static void err_msgv(lua_State *L, ErrMsg em, ...) +{ + const char *msg; + va_list argp; + va_start(argp, em); + if (curr_funcisL(L)) L->top = curr_topL(L); + msg = lj_str_pushvf(L, err2msg(em), argp); + va_end(argp); + lj_debug_addloc(L, msg, L->base-1, NULL); + lj_err_run(L); +} + +/* Non-vararg variant for better calling conventions. */ +LJ_NOINLINE void lj_err_msg(lua_State *L, ErrMsg em) +{ + err_msgv(L, em); +} + +/* Lexer error. */ +LJ_NOINLINE void lj_err_lex(lua_State *L, GCstr *src, const char *tok, + BCLine line, ErrMsg em, va_list argp) +{ + char buff[LUA_IDSIZE]; + const char *msg; + lj_debug_shortname(buff, src); + msg = lj_str_pushvf(L, err2msg(em), argp); + msg = lj_str_pushf(L, "%s:%d: %s", buff, line, msg); + if (tok) + lj_str_pushf(L, err2msg(LJ_ERR_XNEAR), msg, tok); + lj_err_throw(L, LUA_ERRSYNTAX); +} + +/* Typecheck error for operands. */ +LJ_NOINLINE void lj_err_optype(lua_State *L, cTValue *o, ErrMsg opm) +{ + const char *tname = lj_typename(o); + const char *opname = err2msg(opm); + if (curr_funcisL(L)) { + GCproto *pt = curr_proto(L); + const BCIns *pc = cframe_Lpc(L) - 1; + const char *oname = NULL; + const char *kind = lj_debug_slotname(pt, pc, (BCReg)(o-L->base), &oname); + if (kind) + err_msgv(L, LJ_ERR_BADOPRT, opname, kind, oname, tname); + } + err_msgv(L, LJ_ERR_BADOPRV, opname, tname); +} + +/* Typecheck error for ordered comparisons. */ +LJ_NOINLINE void lj_err_comp(lua_State *L, cTValue *o1, cTValue *o2) +{ + const char *t1 = lj_typename(o1); + const char *t2 = lj_typename(o2); + err_msgv(L, t1 == t2 ? LJ_ERR_BADCMPV : LJ_ERR_BADCMPT, t1, t2); + /* This assumes the two "boolean" entries are commoned by the C compiler. */ +} + +/* Typecheck error for __call. */ +LJ_NOINLINE void lj_err_optype_call(lua_State *L, TValue *o) +{ + /* Gross hack if lua_[p]call or pcall/xpcall fail for a non-callable object: + ** L->base still points to the caller. So add a dummy frame with L instead + ** of a function. See lua_getstack(). + */ + const BCIns *pc = cframe_Lpc(L); + if (((ptrdiff_t)pc & FRAME_TYPE) != FRAME_LUA) { + const char *tname = lj_typename(o); + setframe_pc(o, pc); + setframe_gc(o, obj2gco(L)); + L->top = L->base = o+1; + err_msgv(L, LJ_ERR_BADCALL, tname); + } + lj_err_optype(L, o, LJ_ERR_OPCALL); +} + +/* Error in context of caller. */ +LJ_NOINLINE void lj_err_callermsg(lua_State *L, const char *msg) +{ + TValue *frame = L->base-1; + TValue *pframe = NULL; + if (frame_islua(frame)) { + pframe = frame_prevl(frame); + } else if (frame_iscont(frame)) { +#if LJ_HASFFI + if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK) { + pframe = frame; + frame = NULL; + } else +#endif + { + pframe = frame_prevd(frame); +#if LJ_HASFFI + /* Remove frame for FFI metamethods. */ + if (frame_func(frame)->c.ffid >= FF_ffi_meta___index && + frame_func(frame)->c.ffid <= FF_ffi_meta___tostring) { + L->base = pframe+1; + L->top = frame; + setcframe_pc(cframe_raw(L->cframe), frame_contpc(frame)); + } +#endif + } + } + lj_debug_addloc(L, msg, pframe, frame); + lj_err_run(L); +} + +/* Formatted error in context of caller. */ +LJ_NOINLINE void lj_err_callerv(lua_State *L, ErrMsg em, ...) +{ + const char *msg; + va_list argp; + va_start(argp, em); + msg = lj_str_pushvf(L, err2msg(em), argp); + va_end(argp); + lj_err_callermsg(L, msg); +} + +/* Error in context of caller. */ +LJ_NOINLINE void lj_err_caller(lua_State *L, ErrMsg em) +{ + lj_err_callermsg(L, err2msg(em)); +} + +/* Argument error message. */ +LJ_NORET LJ_NOINLINE static void err_argmsg(lua_State *L, int narg, + const char *msg) +{ + const char *fname = "?"; + const char *ftype = lj_debug_funcname(L, L->base - 1, &fname); + if (narg < 0 && narg > LUA_REGISTRYINDEX) + narg = (int)(L->top - L->base) + narg + 1; + if (ftype && ftype[3] == 'h' && --narg == 0) /* Check for "method". */ + msg = lj_str_pushf(L, err2msg(LJ_ERR_BADSELF), fname, msg); + else + msg = lj_str_pushf(L, err2msg(LJ_ERR_BADARG), narg, fname, msg); + lj_err_callermsg(L, msg); +} + +/* Formatted argument error. */ +LJ_NOINLINE void lj_err_argv(lua_State *L, int narg, ErrMsg em, ...) +{ + const char *msg; + va_list argp; + va_start(argp, em); + msg = lj_str_pushvf(L, err2msg(em), argp); + va_end(argp); + err_argmsg(L, narg, msg); +} + +/* Argument error. */ +LJ_NOINLINE void lj_err_arg(lua_State *L, int narg, ErrMsg em) +{ + err_argmsg(L, narg, err2msg(em)); +} + +/* Typecheck error for arguments. */ +LJ_NOINLINE void lj_err_argtype(lua_State *L, int narg, const char *xname) +{ + const char *tname, *msg; + if (narg <= LUA_REGISTRYINDEX) { + if (narg >= LUA_GLOBALSINDEX) { + tname = lj_obj_itypename[~LJ_TTAB]; + } else { + GCfunc *fn = curr_func(L); + int idx = LUA_GLOBALSINDEX - narg; + if (idx <= fn->c.nupvalues) + tname = lj_typename(&fn->c.upvalue[idx-1]); + else + tname = lj_obj_typename[0]; + } + } else { + TValue *o = narg < 0 ? L->top + narg : L->base + narg-1; + tname = o < L->top ? lj_typename(o) : lj_obj_typename[0]; + } + msg = lj_str_pushf(L, err2msg(LJ_ERR_BADTYPE), xname, tname); + err_argmsg(L, narg, msg); +} + +/* Typecheck error for arguments. */ +LJ_NOINLINE void lj_err_argt(lua_State *L, int narg, int tt) +{ + lj_err_argtype(L, narg, lj_obj_typename[tt+1]); +} + +/* -- Public error handling API ------------------------------------------- */ + +LUA_API lua_CFunction lua_atpanic(lua_State *L, lua_CFunction panicf) +{ + lua_CFunction old = G(L)->panic; + G(L)->panic = panicf; + return old; +} + +/* Forwarders for the public API (C calling convention and no LJ_NORET). */ +LUA_API int lua_error(lua_State *L) +{ + lj_err_run(L); + return 0; /* unreachable */ +} + +LUALIB_API int luaL_argerror(lua_State *L, int narg, const char *msg) +{ + err_argmsg(L, narg, msg); + return 0; /* unreachable */ +} + +LUALIB_API int luaL_typerror(lua_State *L, int narg, const char *xname) +{ + lj_err_argtype(L, narg, xname); + return 0; /* unreachable */ +} + +LUALIB_API void luaL_where(lua_State *L, int level) +{ + int size; + cTValue *frame = lj_debug_frame(L, level, &size); + lj_debug_addloc(L, "", frame, size ? frame+size : NULL); +} + +LUALIB_API int luaL_error(lua_State *L, const char *fmt, ...) +{ + const char *msg; + va_list argp; + va_start(argp, fmt); + msg = lj_str_pushvf(L, fmt, argp); + va_end(argp); + lj_err_callermsg(L, msg); + return 0; /* unreachable */ +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_err.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_err.h new file mode 100644 index 000000000..03a56f036 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_err.h @@ -0,0 +1,41 @@ +/* +** Error handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_ERR_H +#define _LJ_ERR_H + +#include + +#include "lj_obj.h" + +typedef enum { +#define ERRDEF(name, msg) \ + LJ_ERR_##name, LJ_ERR_##name##_ = LJ_ERR_##name + sizeof(msg)-1, +#include "lj_errmsg.h" + LJ_ERR__MAX +} ErrMsg; + +LJ_DATA const char *lj_err_allmsg; +#define err2msg(em) (lj_err_allmsg+(int)(em)) + +LJ_FUNC GCstr *lj_err_str(lua_State *L, ErrMsg em); +LJ_FUNCA_NORET void LJ_FASTCALL lj_err_throw(lua_State *L, int errcode); +LJ_FUNC_NORET void lj_err_mem(lua_State *L); +LJ_FUNC_NORET void lj_err_run(lua_State *L); +LJ_FUNC_NORET void lj_err_msg(lua_State *L, ErrMsg em); +LJ_FUNC_NORET void lj_err_lex(lua_State *L, GCstr *src, const char *tok, + BCLine line, ErrMsg em, va_list argp); +LJ_FUNC_NORET void lj_err_optype(lua_State *L, cTValue *o, ErrMsg opm); +LJ_FUNC_NORET void lj_err_comp(lua_State *L, cTValue *o1, cTValue *o2); +LJ_FUNC_NORET void lj_err_optype_call(lua_State *L, TValue *o); +LJ_FUNC_NORET void lj_err_callermsg(lua_State *L, const char *msg); +LJ_FUNC_NORET void lj_err_callerv(lua_State *L, ErrMsg em, ...); +LJ_FUNC_NORET void lj_err_caller(lua_State *L, ErrMsg em); +LJ_FUNC_NORET void lj_err_arg(lua_State *L, int narg, ErrMsg em); +LJ_FUNC_NORET void lj_err_argv(lua_State *L, int narg, ErrMsg em, ...); +LJ_FUNC_NORET void lj_err_argtype(lua_State *L, int narg, const char *xname); +LJ_FUNC_NORET void lj_err_argt(lua_State *L, int narg, int tt); + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_errmsg.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_errmsg.h new file mode 100644 index 000000000..1c9487607 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_errmsg.h @@ -0,0 +1,193 @@ +/* +** VM error messages. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* This file may be included multiple times with different ERRDEF macros. */ + +/* Basic error handling. */ +ERRDEF(ERRMEM, "not enough memory") +ERRDEF(ERRERR, "error in error handling") +ERRDEF(ERRCPP, "C++ exception") + +/* Allocations. */ +ERRDEF(STROV, "string length overflow") +ERRDEF(UDATAOV, "userdata length overflow") +ERRDEF(STKOV, "stack overflow") +ERRDEF(STKOVM, "stack overflow (%s)") +ERRDEF(TABOV, "table overflow") + +/* Table indexing. */ +ERRDEF(NANIDX, "table index is NaN") +ERRDEF(NILIDX, "table index is nil") +ERRDEF(NEXTIDX, "invalid key to " LUA_QL("next")) + +/* Metamethod resolving. */ +ERRDEF(BADCALL, "attempt to call a %s value") +ERRDEF(BADOPRT, "attempt to %s %s " LUA_QS " (a %s value)") +ERRDEF(BADOPRV, "attempt to %s a %s value") +ERRDEF(BADCMPT, "attempt to compare %s with %s") +ERRDEF(BADCMPV, "attempt to compare two %s values") +ERRDEF(GETLOOP, "loop in gettable") +ERRDEF(SETLOOP, "loop in settable") +ERRDEF(OPCALL, "call") +ERRDEF(OPINDEX, "index") +ERRDEF(OPARITH, "perform arithmetic on") +ERRDEF(OPCAT, "concatenate") +ERRDEF(OPLEN, "get length of") + +/* Type checks. */ +ERRDEF(BADSELF, "calling " LUA_QS " on bad self (%s)") +ERRDEF(BADARG, "bad argument #%d to " LUA_QS " (%s)") +ERRDEF(BADTYPE, "%s expected, got %s") +ERRDEF(BADVAL, "invalid value") +ERRDEF(NOVAL, "value expected") +ERRDEF(NOCORO, "coroutine expected") +ERRDEF(NOTABN, "nil or table expected") +ERRDEF(NOLFUNC, "Lua function expected") +ERRDEF(NOFUNCL, "function or level expected") +ERRDEF(NOSFT, "string/function/table expected") +ERRDEF(NOPROXY, "boolean or proxy expected") +ERRDEF(FORINIT, LUA_QL("for") " initial value must be a number") +ERRDEF(FORLIM, LUA_QL("for") " limit must be a number") +ERRDEF(FORSTEP, LUA_QL("for") " step must be a number") + +/* C API checks. */ +ERRDEF(NOENV, "no calling environment") +ERRDEF(CYIELD, "attempt to yield across C-call boundary") +ERRDEF(BADLU, "bad light userdata pointer") +ERRDEF(NOGCMM, "bad action while in __gc metamethod") +#if LJ_TARGET_WINDOWS +ERRDEF(BADFPU, "bad FPU precision (use D3DCREATE_FPU_PRESERVE with DirectX)") +#endif + +/* Standard library function errors. */ +ERRDEF(ASSERT, "assertion failed!") +ERRDEF(PROTMT, "cannot change a protected metatable") +ERRDEF(UNPACK, "too many results to unpack") +ERRDEF(RDRSTR, "reader function must return a string") +ERRDEF(PRTOSTR, LUA_QL("tostring") " must return a string to " LUA_QL("print")) +ERRDEF(IDXRNG, "index out of range") +ERRDEF(BASERNG, "base out of range") +ERRDEF(LVLRNG, "level out of range") +ERRDEF(INVLVL, "invalid level") +ERRDEF(INVOPT, "invalid option") +ERRDEF(INVOPTM, "invalid option " LUA_QS) +ERRDEF(INVFMT, "invalid format") +ERRDEF(SETFENV, LUA_QL("setfenv") " cannot change environment of given object") +ERRDEF(CORUN, "cannot resume running coroutine") +ERRDEF(CODEAD, "cannot resume dead coroutine") +ERRDEF(COSUSP, "cannot resume non-suspended coroutine") +ERRDEF(TABINS, "wrong number of arguments to " LUA_QL("insert")) +ERRDEF(TABCAT, "invalid value (%s) at index %d in table for " LUA_QL("concat")) +ERRDEF(TABSORT, "invalid order function for sorting") +ERRDEF(IOCLFL, "attempt to use a closed file") +ERRDEF(IOSTDCL, "standard file is closed") +ERRDEF(OSUNIQF, "unable to generate a unique filename") +ERRDEF(OSDATEF, "field " LUA_QS " missing in date table") +ERRDEF(STRDUMP, "unable to dump given function") +ERRDEF(STRSLC, "string slice too long") +ERRDEF(STRPATB, "missing " LUA_QL("[") " after " LUA_QL("%f") " in pattern") +ERRDEF(STRPATC, "invalid pattern capture") +ERRDEF(STRPATE, "malformed pattern (ends with " LUA_QL("%") ")") +ERRDEF(STRPATM, "malformed pattern (missing " LUA_QL("]") ")") +ERRDEF(STRPATU, "unbalanced pattern") +ERRDEF(STRPATX, "pattern too complex") +ERRDEF(STRCAPI, "invalid capture index") +ERRDEF(STRCAPN, "too many captures") +ERRDEF(STRCAPU, "unfinished capture") +ERRDEF(STRFMTO, "invalid option " LUA_QL("%%%c") " to " LUA_QL("format")) +ERRDEF(STRFMTR, "invalid format (repeated flags)") +ERRDEF(STRFMTW, "invalid format (width or precision too long)") +ERRDEF(STRGSRV, "invalid replacement value (a %s)") +ERRDEF(BADMODN, "name conflict for module " LUA_QS) +#if LJ_HASJIT +ERRDEF(JITPROT, "runtime code generation failed, restricted kernel?") +#if LJ_TARGET_X86ORX64 +ERRDEF(NOJIT, "JIT compiler disabled, CPU does not support SSE2") +#else +ERRDEF(NOJIT, "JIT compiler disabled") +#endif +#elif defined(LJ_ARCH_NOJIT) +ERRDEF(NOJIT, "no JIT compiler for this architecture (yet)") +#else +ERRDEF(NOJIT, "JIT compiler permanently disabled by build option") +#endif +ERRDEF(JITOPT, "unknown or malformed optimization flag " LUA_QS) + +/* Lexer/parser errors. */ +ERRDEF(XMODE, "attempt to load chunk with wrong mode") +ERRDEF(XNEAR, "%s near " LUA_QS) +ERRDEF(XELEM, "lexical element too long") +ERRDEF(XLINES, "chunk has too many lines") +ERRDEF(XLEVELS, "chunk has too many syntax levels") +ERRDEF(XNUMBER, "malformed number") +ERRDEF(XLSTR, "unfinished long string") +ERRDEF(XLCOM, "unfinished long comment") +ERRDEF(XSTR, "unfinished string") +ERRDEF(XESC, "invalid escape sequence") +ERRDEF(XLDELIM, "invalid long string delimiter") +ERRDEF(XTOKEN, LUA_QS " expected") +ERRDEF(XJUMP, "control structure too long") +ERRDEF(XSLOTS, "function or expression too complex") +ERRDEF(XLIMC, "chunk has more than %d local variables") +ERRDEF(XLIMM, "main function has more than %d %s") +ERRDEF(XLIMF, "function at line %d has more than %d %s") +ERRDEF(XMATCH, LUA_QS " expected (to close " LUA_QS " at line %d)") +ERRDEF(XFIXUP, "function too long for return fixup") +ERRDEF(XPARAM, " or " LUA_QL("...") " expected") +#if !LJ_52 +ERRDEF(XAMBIG, "ambiguous syntax (function call x new statement)") +#endif +ERRDEF(XFUNARG, "function arguments expected") +ERRDEF(XSYMBOL, "unexpected symbol") +ERRDEF(XDOTS, "cannot use " LUA_QL("...") " outside a vararg function") +ERRDEF(XSYNTAX, "syntax error") +ERRDEF(XFOR, LUA_QL("=") " or " LUA_QL("in") " expected") +ERRDEF(XBREAK, "no loop to break") +ERRDEF(XLUNDEF, "undefined label " LUA_QS) +ERRDEF(XLDUP, "duplicate label " LUA_QS) +ERRDEF(XGSCOPE, " jumps into the scope of local " LUA_QS) + +/* Bytecode reader errors. */ +ERRDEF(BCFMT, "cannot load incompatible bytecode") +ERRDEF(BCBAD, "cannot load malformed bytecode") + +#if LJ_HASFFI +/* FFI errors. */ +ERRDEF(FFI_INVTYPE, "invalid C type") +ERRDEF(FFI_INVSIZE, "size of C type is unknown or too large") +ERRDEF(FFI_BADSCL, "bad storage class") +ERRDEF(FFI_DECLSPEC, "declaration specifier expected") +ERRDEF(FFI_BADTAG, "undeclared or implicit tag " LUA_QS) +ERRDEF(FFI_REDEF, "attempt to redefine " LUA_QS) +ERRDEF(FFI_NUMPARAM, "wrong number of type parameters") +ERRDEF(FFI_INITOV, "too many initializers for " LUA_QS) +ERRDEF(FFI_BADCONV, "cannot convert " LUA_QS " to " LUA_QS) +ERRDEF(FFI_BADLEN, "attempt to get length of " LUA_QS) +ERRDEF(FFI_BADCONCAT, "attempt to concatenate " LUA_QS " and " LUA_QS) +ERRDEF(FFI_BADARITH, "attempt to perform arithmetic on " LUA_QS " and " LUA_QS) +ERRDEF(FFI_BADCOMP, "attempt to compare " LUA_QS " with " LUA_QS) +ERRDEF(FFI_BADCALL, LUA_QS " is not callable") +ERRDEF(FFI_NUMARG, "wrong number of arguments for function call") +ERRDEF(FFI_BADMEMBER, LUA_QS " has no member named " LUA_QS) +ERRDEF(FFI_BADIDX, LUA_QS " cannot be indexed") +ERRDEF(FFI_BADIDXW, LUA_QS " cannot be indexed with " LUA_QS) +ERRDEF(FFI_BADMM, LUA_QS " has no " LUA_QS " metamethod") +ERRDEF(FFI_WRCONST, "attempt to write to constant location") +ERRDEF(FFI_NODECL, "missing declaration for symbol " LUA_QS) +ERRDEF(FFI_BADCBACK, "bad callback") +#if LJ_OS_NOJIT +ERRDEF(FFI_CBACKOV, "no support for callbacks on this OS") +#else +ERRDEF(FFI_CBACKOV, "too many callbacks") +#endif +ERRDEF(FFI_NYIPACKBIT, "NYI: packed bit fields") +ERRDEF(FFI_NYICALL, "NYI: cannot call this C function (yet)") +#endif + +#undef ERRDEF + +/* Detecting unused error messages: + awk -F, '/^ERRDEF/ { gsub(/ERRDEF./, ""); printf "grep -q LJ_ERR_%s *.[ch] || echo %s\n", $1, $1}' lj_errmsg.h | sh +*/ diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_ff.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ff.h new file mode 100644 index 000000000..73dad9695 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ff.h @@ -0,0 +1,18 @@ +/* +** Fast function IDs. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_FF_H +#define _LJ_FF_H + +/* Fast function ID. */ +typedef enum { + FF_LUA_ = FF_LUA, /* Lua function (must be 0). */ + FF_C_ = FF_C, /* Regular C function (must be 1). */ +#define FFDEF(name) FF_##name, +#include "lj_ffdef.h" + FF__MAX +} FastFunc; + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_ffrecord.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ffrecord.c new file mode 100644 index 000000000..69f71ab2e --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ffrecord.c @@ -0,0 +1,888 @@ +/* +** Fast function call recorder. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_ffrecord_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_frame.h" +#include "lj_bc.h" +#include "lj_ff.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_ircall.h" +#include "lj_iropt.h" +#include "lj_trace.h" +#include "lj_record.h" +#include "lj_ffrecord.h" +#include "lj_crecord.h" +#include "lj_dispatch.h" +#include "lj_vm.h" +#include "lj_strscan.h" + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) + +/* Pass IR on to next optimization in chain (FOLD). */ +#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) + +/* -- Fast function recording handlers ------------------------------------ */ + +/* Conventions for fast function call handlers: +** +** The argument slots start at J->base[0]. All of them are guaranteed to be +** valid and type-specialized references. J->base[J->maxslot] is set to 0 +** as a sentinel. The runtime argument values start at rd->argv[0]. +** +** In general fast functions should check for presence of all of their +** arguments and for the correct argument types. Some simplifications +** are allowed if the interpreter throws instead. But even if recording +** is aborted, the generated IR must be consistent (no zero-refs). +** +** The number of results in rd->nres is set to 1. Handlers that return +** a different number of results need to override it. A negative value +** prevents return processing (e.g. for pending calls). +** +** Results need to be stored starting at J->base[0]. Return processing +** moves them to the right slots later. +** +** The per-ffid auxiliary data is the value of the 2nd part of the +** LJLIB_REC() annotation. This allows handling similar functionality +** in a common handler. +*/ + +/* Type of handler to record a fast function. */ +typedef void (LJ_FASTCALL *RecordFunc)(jit_State *J, RecordFFData *rd); + +/* Get runtime value of int argument. */ +static int32_t argv2int(jit_State *J, TValue *o) +{ + if (!lj_strscan_numberobj(o)) + lj_trace_err(J, LJ_TRERR_BADTYPE); + return tvisint(o) ? intV(o) : lj_num2int(numV(o)); +} + +/* Get runtime value of string argument. */ +static GCstr *argv2str(jit_State *J, TValue *o) +{ + if (LJ_LIKELY(tvisstr(o))) { + return strV(o); + } else { + GCstr *s; + if (!tvisnumber(o)) + lj_trace_err(J, LJ_TRERR_BADTYPE); + if (tvisint(o)) + s = lj_str_fromint(J->L, intV(o)); + else + s = lj_str_fromnum(J->L, &o->n); + setstrV(J->L, o, s); + return s; + } +} + +/* Return number of results wanted by caller. */ +static ptrdiff_t results_wanted(jit_State *J) +{ + TValue *frame = J->L->base-1; + if (frame_islua(frame)) + return (ptrdiff_t)bc_b(frame_pc(frame)[-1]) - 1; + else + return -1; +} + +/* Throw error for unsupported variant of fast function. */ +LJ_NORET static void recff_nyiu(jit_State *J) +{ + setfuncV(J->L, &J->errinfo, J->fn); + lj_trace_err_info(J, LJ_TRERR_NYIFFU); +} + +/* Fallback handler for all fast functions that are not recorded (yet). */ +static void LJ_FASTCALL recff_nyi(jit_State *J, RecordFFData *rd) +{ + setfuncV(J->L, &J->errinfo, J->fn); + lj_trace_err_info(J, LJ_TRERR_NYIFF); + UNUSED(rd); +} + +/* C functions can have arbitrary side-effects and are not recorded (yet). */ +static void LJ_FASTCALL recff_c(jit_State *J, RecordFFData *rd) +{ + setfuncV(J->L, &J->errinfo, J->fn); + lj_trace_err_info(J, LJ_TRERR_NYICF); + UNUSED(rd); +} + +/* -- Base library fast functions ----------------------------------------- */ + +static void LJ_FASTCALL recff_assert(jit_State *J, RecordFFData *rd) +{ + /* Arguments already specialized. The interpreter throws for nil/false. */ + rd->nres = J->maxslot; /* Pass through all arguments. */ +} + +static void LJ_FASTCALL recff_type(jit_State *J, RecordFFData *rd) +{ + /* Arguments already specialized. Result is a constant string. Neat, huh? */ + uint32_t t; + if (tvisnumber(&rd->argv[0])) + t = ~LJ_TNUMX; + else if (LJ_64 && tvislightud(&rd->argv[0])) + t = ~LJ_TLIGHTUD; + else + t = ~itype(&rd->argv[0]); + J->base[0] = lj_ir_kstr(J, strV(&J->fn->c.upvalue[t])); + UNUSED(rd); +} + +static void LJ_FASTCALL recff_getmetatable(jit_State *J, RecordFFData *rd) +{ + TRef tr = J->base[0]; + if (tr) { + RecordIndex ix; + ix.tab = tr; + copyTV(J->L, &ix.tabv, &rd->argv[0]); + if (lj_record_mm_lookup(J, &ix, MM_metatable)) + J->base[0] = ix.mobj; + else + J->base[0] = ix.mt; + } /* else: Interpreter will throw. */ +} + +static void LJ_FASTCALL recff_setmetatable(jit_State *J, RecordFFData *rd) +{ + TRef tr = J->base[0]; + TRef mt = J->base[1]; + if (tref_istab(tr) && (tref_istab(mt) || (mt && tref_isnil(mt)))) { + TRef fref, mtref; + RecordIndex ix; + ix.tab = tr; + copyTV(J->L, &ix.tabv, &rd->argv[0]); + lj_record_mm_lookup(J, &ix, MM_metatable); /* Guard for no __metatable. */ + fref = emitir(IRT(IR_FREF, IRT_P32), tr, IRFL_TAB_META); + mtref = tref_isnil(mt) ? lj_ir_knull(J, IRT_TAB) : mt; + emitir(IRT(IR_FSTORE, IRT_TAB), fref, mtref); + if (!tref_isnil(mt)) + emitir(IRT(IR_TBAR, IRT_TAB), tr, 0); + J->base[0] = tr; + J->needsnap = 1; + } /* else: Interpreter will throw. */ +} + +static void LJ_FASTCALL recff_rawget(jit_State *J, RecordFFData *rd) +{ + RecordIndex ix; + ix.tab = J->base[0]; ix.key = J->base[1]; + if (tref_istab(ix.tab) && ix.key) { + ix.val = 0; ix.idxchain = 0; + settabV(J->L, &ix.tabv, tabV(&rd->argv[0])); + copyTV(J->L, &ix.keyv, &rd->argv[1]); + J->base[0] = lj_record_idx(J, &ix); + } /* else: Interpreter will throw. */ +} + +static void LJ_FASTCALL recff_rawset(jit_State *J, RecordFFData *rd) +{ + RecordIndex ix; + ix.tab = J->base[0]; ix.key = J->base[1]; ix.val = J->base[2]; + if (tref_istab(ix.tab) && ix.key && ix.val) { + ix.idxchain = 0; + settabV(J->L, &ix.tabv, tabV(&rd->argv[0])); + copyTV(J->L, &ix.keyv, &rd->argv[1]); + copyTV(J->L, &ix.valv, &rd->argv[2]); + lj_record_idx(J, &ix); + /* Pass through table at J->base[0] as result. */ + } /* else: Interpreter will throw. */ +} + +static void LJ_FASTCALL recff_rawequal(jit_State *J, RecordFFData *rd) +{ + TRef tra = J->base[0]; + TRef trb = J->base[1]; + if (tra && trb) { + int diff = lj_record_objcmp(J, tra, trb, &rd->argv[0], &rd->argv[1]); + J->base[0] = diff ? TREF_FALSE : TREF_TRUE; + } /* else: Interpreter will throw. */ +} + +#if LJ_52 +static void LJ_FASTCALL recff_rawlen(jit_State *J, RecordFFData *rd) +{ + TRef tr = J->base[0]; + if (tref_isstr(tr)) + J->base[0] = emitir(IRTI(IR_FLOAD), tr, IRFL_STR_LEN); + else if (tref_istab(tr)) + J->base[0] = lj_ir_call(J, IRCALL_lj_tab_len, tr); + /* else: Interpreter will throw. */ + UNUSED(rd); +} +#endif + +/* Determine mode of select() call. */ +int32_t lj_ffrecord_select_mode(jit_State *J, TRef tr, TValue *tv) +{ + if (tref_isstr(tr) && *strVdata(tv) == '#') { /* select('#', ...) */ + if (strV(tv)->len == 1) { + emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, strV(tv))); + } else { + TRef trptr = emitir(IRT(IR_STRREF, IRT_P32), tr, lj_ir_kint(J, 0)); + TRef trchar = emitir(IRT(IR_XLOAD, IRT_U8), trptr, IRXLOAD_READONLY); + emitir(IRTG(IR_EQ, IRT_INT), trchar, lj_ir_kint(J, '#')); + } + return 0; + } else { /* select(n, ...) */ + int32_t start = argv2int(J, tv); + if (start == 0) lj_trace_err(J, LJ_TRERR_BADTYPE); /* A bit misleading. */ + return start; + } +} + +static void LJ_FASTCALL recff_select(jit_State *J, RecordFFData *rd) +{ + TRef tr = J->base[0]; + if (tr) { + ptrdiff_t start = lj_ffrecord_select_mode(J, tr, &rd->argv[0]); + if (start == 0) { /* select('#', ...) */ + J->base[0] = lj_ir_kint(J, J->maxslot - 1); + } else if (tref_isk(tr)) { /* select(k, ...) */ + ptrdiff_t n = (ptrdiff_t)J->maxslot; + if (start < 0) start += n; + else if (start > n) start = n; + rd->nres = n - start; + if (start >= 1) { + ptrdiff_t i; + for (i = 0; i < n - start; i++) + J->base[i] = J->base[start+i]; + } /* else: Interpreter will throw. */ + } else { + recff_nyiu(J); + } + } /* else: Interpreter will throw. */ +} + +static void LJ_FASTCALL recff_tonumber(jit_State *J, RecordFFData *rd) +{ + TRef tr = J->base[0]; + TRef base = J->base[1]; + if (tr && !tref_isnil(base)) { + base = lj_opt_narrow_toint(J, base); + if (!tref_isk(base) || IR(tref_ref(base))->i != 10) + recff_nyiu(J); + } + if (tref_isnumber_str(tr)) { + if (tref_isstr(tr)) { + TValue tmp; + if (!lj_strscan_num(strV(&rd->argv[0]), &tmp)) + recff_nyiu(J); /* Would need an inverted STRTO for this case. */ + tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); + } +#if LJ_HASFFI + } else if (tref_iscdata(tr)) { + lj_crecord_tonumber(J, rd); + return; +#endif + } else { + tr = TREF_NIL; + } + J->base[0] = tr; + UNUSED(rd); +} + +static TValue *recff_metacall_cp(lua_State *L, lua_CFunction dummy, void *ud) +{ + jit_State *J = (jit_State *)ud; + lj_record_tailcall(J, 0, 1); + UNUSED(L); UNUSED(dummy); + return NULL; +} + +static int recff_metacall(jit_State *J, RecordFFData *rd, MMS mm) +{ + RecordIndex ix; + ix.tab = J->base[0]; + copyTV(J->L, &ix.tabv, &rd->argv[0]); + if (lj_record_mm_lookup(J, &ix, mm)) { /* Has metamethod? */ + int errcode; + TValue argv0; + /* Temporarily insert metamethod below object. */ + J->base[1] = J->base[0]; + J->base[0] = ix.mobj; + copyTV(J->L, &argv0, &rd->argv[0]); + copyTV(J->L, &rd->argv[1], &rd->argv[0]); + copyTV(J->L, &rd->argv[0], &ix.mobjv); + /* Need to protect lj_record_tailcall because it may throw. */ + errcode = lj_vm_cpcall(J->L, NULL, J, recff_metacall_cp); + /* Always undo Lua stack changes to avoid confusing the interpreter. */ + copyTV(J->L, &rd->argv[0], &argv0); + if (errcode) + lj_err_throw(J->L, errcode); /* Propagate errors. */ + rd->nres = -1; /* Pending call. */ + return 1; /* Tailcalled to metamethod. */ + } + return 0; +} + +static void LJ_FASTCALL recff_tostring(jit_State *J, RecordFFData *rd) +{ + TRef tr = J->base[0]; + if (tref_isstr(tr)) { + /* Ignore __tostring in the string base metatable. */ + /* Pass on result in J->base[0]. */ + } else if (!recff_metacall(J, rd, MM_tostring)) { + if (tref_isnumber(tr)) { + J->base[0] = emitir(IRT(IR_TOSTR, IRT_STR), tr, 0); + } else if (tref_ispri(tr)) { + J->base[0] = lj_ir_kstr(J, strV(&J->fn->c.upvalue[tref_type(tr)])); + } else { + recff_nyiu(J); + } + } +} + +static void LJ_FASTCALL recff_ipairs_aux(jit_State *J, RecordFFData *rd) +{ + RecordIndex ix; + ix.tab = J->base[0]; + if (tref_istab(ix.tab)) { + if (!tvisnumber(&rd->argv[1])) /* No support for string coercion. */ + lj_trace_err(J, LJ_TRERR_BADTYPE); + setintV(&ix.keyv, numberVint(&rd->argv[1])+1); + settabV(J->L, &ix.tabv, tabV(&rd->argv[0])); + ix.val = 0; ix.idxchain = 0; + ix.key = lj_opt_narrow_toint(J, J->base[1]); + J->base[0] = ix.key = emitir(IRTI(IR_ADD), ix.key, lj_ir_kint(J, 1)); + J->base[1] = lj_record_idx(J, &ix); + rd->nres = tref_isnil(J->base[1]) ? 0 : 2; + } /* else: Interpreter will throw. */ +} + +static void LJ_FASTCALL recff_ipairs(jit_State *J, RecordFFData *rd) +{ + if (!(LJ_52 && recff_metacall(J, rd, MM_ipairs))) { + TRef tab = J->base[0]; + if (tref_istab(tab)) { + J->base[0] = lj_ir_kfunc(J, funcV(&J->fn->c.upvalue[0])); + J->base[1] = tab; + J->base[2] = lj_ir_kint(J, 0); + rd->nres = 3; + } /* else: Interpreter will throw. */ + } +} + +static void LJ_FASTCALL recff_pcall(jit_State *J, RecordFFData *rd) +{ + if (J->maxslot >= 1) { + lj_record_call(J, 0, J->maxslot - 1); + rd->nres = -1; /* Pending call. */ + } /* else: Interpreter will throw. */ +} + +static TValue *recff_xpcall_cp(lua_State *L, lua_CFunction dummy, void *ud) +{ + jit_State *J = (jit_State *)ud; + lj_record_call(J, 1, J->maxslot - 2); + UNUSED(L); UNUSED(dummy); + return NULL; +} + +static void LJ_FASTCALL recff_xpcall(jit_State *J, RecordFFData *rd) +{ + if (J->maxslot >= 2) { + TValue argv0, argv1; + TRef tmp; + int errcode; + /* Swap function and traceback. */ + tmp = J->base[0]; J->base[0] = J->base[1]; J->base[1] = tmp; + copyTV(J->L, &argv0, &rd->argv[0]); + copyTV(J->L, &argv1, &rd->argv[1]); + copyTV(J->L, &rd->argv[0], &argv1); + copyTV(J->L, &rd->argv[1], &argv0); + /* Need to protect lj_record_call because it may throw. */ + errcode = lj_vm_cpcall(J->L, NULL, J, recff_xpcall_cp); + /* Always undo Lua stack swap to avoid confusing the interpreter. */ + copyTV(J->L, &rd->argv[0], &argv0); + copyTV(J->L, &rd->argv[1], &argv1); + if (errcode) + lj_err_throw(J->L, errcode); /* Propagate errors. */ + rd->nres = -1; /* Pending call. */ + } /* else: Interpreter will throw. */ +} + +/* -- Math library fast functions ----------------------------------------- */ + +static void LJ_FASTCALL recff_math_abs(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_ir_tonum(J, J->base[0]); + J->base[0] = emitir(IRTN(IR_ABS), tr, lj_ir_knum_abs(J)); + UNUSED(rd); +} + +/* Record rounding functions math.floor and math.ceil. */ +static void LJ_FASTCALL recff_math_round(jit_State *J, RecordFFData *rd) +{ + TRef tr = J->base[0]; + if (!tref_isinteger(tr)) { /* Pass through integers unmodified. */ + tr = emitir(IRTN(IR_FPMATH), lj_ir_tonum(J, tr), rd->data); + /* Result is integral (or NaN/Inf), but may not fit an int32_t. */ + if (LJ_DUALNUM) { /* Try to narrow using a guarded conversion to int. */ + lua_Number n = lj_vm_foldfpm(numberVnum(&rd->argv[0]), rd->data); + if (n == (lua_Number)lj_num2int(n)) + tr = emitir(IRTGI(IR_CONV), tr, IRCONV_INT_NUM|IRCONV_CHECK); + } + J->base[0] = tr; + } +} + +/* Record unary math.* functions, mapped to IR_FPMATH opcode. */ +static void LJ_FASTCALL recff_math_unary(jit_State *J, RecordFFData *rd) +{ + J->base[0] = emitir(IRTN(IR_FPMATH), lj_ir_tonum(J, J->base[0]), rd->data); +} + +/* Record math.log. */ +static void LJ_FASTCALL recff_math_log(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_ir_tonum(J, J->base[0]); + if (J->base[1]) { +#ifdef LUAJIT_NO_LOG2 + uint32_t fpm = IRFPM_LOG; +#else + uint32_t fpm = IRFPM_LOG2; +#endif + TRef trb = lj_ir_tonum(J, J->base[1]); + tr = emitir(IRTN(IR_FPMATH), tr, fpm); + trb = emitir(IRTN(IR_FPMATH), trb, fpm); + trb = emitir(IRTN(IR_DIV), lj_ir_knum_one(J), trb); + tr = emitir(IRTN(IR_MUL), tr, trb); + } else { + tr = emitir(IRTN(IR_FPMATH), tr, IRFPM_LOG); + } + J->base[0] = tr; + UNUSED(rd); +} + +/* Record math.atan2. */ +static void LJ_FASTCALL recff_math_atan2(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_ir_tonum(J, J->base[0]); + TRef tr2 = lj_ir_tonum(J, J->base[1]); + J->base[0] = emitir(IRTN(IR_ATAN2), tr, tr2); + UNUSED(rd); +} + +/* Record math.ldexp. */ +static void LJ_FASTCALL recff_math_ldexp(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_ir_tonum(J, J->base[0]); +#if LJ_TARGET_X86ORX64 + TRef tr2 = lj_ir_tonum(J, J->base[1]); +#else + TRef tr2 = lj_opt_narrow_toint(J, J->base[1]); +#endif + J->base[0] = emitir(IRTN(IR_LDEXP), tr, tr2); + UNUSED(rd); +} + +/* Record math.asin, math.acos, math.atan. */ +static void LJ_FASTCALL recff_math_atrig(jit_State *J, RecordFFData *rd) +{ + TRef y = lj_ir_tonum(J, J->base[0]); + TRef x = lj_ir_knum_one(J); + uint32_t ffid = rd->data; + if (ffid != FF_math_atan) { + TRef tmp = emitir(IRTN(IR_MUL), y, y); + tmp = emitir(IRTN(IR_SUB), x, tmp); + tmp = emitir(IRTN(IR_FPMATH), tmp, IRFPM_SQRT); + if (ffid == FF_math_asin) { x = tmp; } else { x = y; y = tmp; } + } + J->base[0] = emitir(IRTN(IR_ATAN2), y, x); +} + +static void LJ_FASTCALL recff_math_htrig(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_ir_tonum(J, J->base[0]); + J->base[0] = emitir(IRTN(IR_CALLN), tr, rd->data); +} + +static void LJ_FASTCALL recff_math_modf(jit_State *J, RecordFFData *rd) +{ + TRef tr = J->base[0]; + if (tref_isinteger(tr)) { + J->base[0] = tr; + J->base[1] = lj_ir_kint(J, 0); + } else { + TRef trt; + tr = lj_ir_tonum(J, tr); + trt = emitir(IRTN(IR_FPMATH), tr, IRFPM_TRUNC); + J->base[0] = trt; + J->base[1] = emitir(IRTN(IR_SUB), tr, trt); + } + rd->nres = 2; +} + +static void LJ_FASTCALL recff_math_degrad(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_ir_tonum(J, J->base[0]); + TRef trm = lj_ir_knum(J, numV(&J->fn->c.upvalue[0])); + J->base[0] = emitir(IRTN(IR_MUL), tr, trm); + UNUSED(rd); +} + +static void LJ_FASTCALL recff_math_pow(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_ir_tonum(J, J->base[0]); + if (!tref_isnumber_str(J->base[1])) + lj_trace_err(J, LJ_TRERR_BADTYPE); + J->base[0] = lj_opt_narrow_pow(J, tr, J->base[1], &rd->argv[1]); + UNUSED(rd); +} + +static void LJ_FASTCALL recff_math_minmax(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_ir_tonumber(J, J->base[0]); + uint32_t op = rd->data; + BCReg i; + for (i = 1; J->base[i] != 0; i++) { + TRef tr2 = lj_ir_tonumber(J, J->base[i]); + IRType t = IRT_INT; + if (!(tref_isinteger(tr) && tref_isinteger(tr2))) { + if (tref_isinteger(tr)) tr = emitir(IRTN(IR_CONV), tr, IRCONV_NUM_INT); + if (tref_isinteger(tr2)) tr2 = emitir(IRTN(IR_CONV), tr2, IRCONV_NUM_INT); + t = IRT_NUM; + } + tr = emitir(IRT(op, t), tr, tr2); + } + J->base[0] = tr; +} + +static void LJ_FASTCALL recff_math_random(jit_State *J, RecordFFData *rd) +{ + GCudata *ud = udataV(&J->fn->c.upvalue[0]); + TRef tr, one; + lj_ir_kgc(J, obj2gco(ud), IRT_UDATA); /* Prevent collection. */ + tr = lj_ir_call(J, IRCALL_lj_math_random_step, lj_ir_kptr(J, uddata(ud))); + one = lj_ir_knum_one(J); + tr = emitir(IRTN(IR_SUB), tr, one); + if (J->base[0]) { + TRef tr1 = lj_ir_tonum(J, J->base[0]); + if (J->base[1]) { /* d = floor(d*(r2-r1+1.0)) + r1 */ + TRef tr2 = lj_ir_tonum(J, J->base[1]); + tr2 = emitir(IRTN(IR_SUB), tr2, tr1); + tr2 = emitir(IRTN(IR_ADD), tr2, one); + tr = emitir(IRTN(IR_MUL), tr, tr2); + tr = emitir(IRTN(IR_FPMATH), tr, IRFPM_FLOOR); + tr = emitir(IRTN(IR_ADD), tr, tr1); + } else { /* d = floor(d*r1) + 1.0 */ + tr = emitir(IRTN(IR_MUL), tr, tr1); + tr = emitir(IRTN(IR_FPMATH), tr, IRFPM_FLOOR); + tr = emitir(IRTN(IR_ADD), tr, one); + } + } + J->base[0] = tr; + UNUSED(rd); +} + +/* -- Bit library fast functions ------------------------------------------ */ + +/* Record unary bit.tobit, bit.bnot, bit.bswap. */ +static void LJ_FASTCALL recff_bit_unary(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_opt_narrow_tobit(J, J->base[0]); + J->base[0] = (rd->data == IR_TOBIT) ? tr : emitir(IRTI(rd->data), tr, 0); +} + +/* Record N-ary bit.band, bit.bor, bit.bxor. */ +static void LJ_FASTCALL recff_bit_nary(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_opt_narrow_tobit(J, J->base[0]); + uint32_t op = rd->data; + BCReg i; + for (i = 1; J->base[i] != 0; i++) + tr = emitir(IRTI(op), tr, lj_opt_narrow_tobit(J, J->base[i])); + J->base[0] = tr; +} + +/* Record bit shifts. */ +static void LJ_FASTCALL recff_bit_shift(jit_State *J, RecordFFData *rd) +{ + TRef tr = lj_opt_narrow_tobit(J, J->base[0]); + TRef tsh = lj_opt_narrow_tobit(J, J->base[1]); + IROp op = (IROp)rd->data; + if (!(op < IR_BROL ? LJ_TARGET_MASKSHIFT : LJ_TARGET_MASKROT) && + !tref_isk(tsh)) + tsh = emitir(IRTI(IR_BAND), tsh, lj_ir_kint(J, 31)); +#ifdef LJ_TARGET_UNIFYROT + if (op == (LJ_TARGET_UNIFYROT == 1 ? IR_BROR : IR_BROL)) { + op = LJ_TARGET_UNIFYROT == 1 ? IR_BROL : IR_BROR; + tsh = emitir(IRTI(IR_NEG), tsh, tsh); + } +#endif + J->base[0] = emitir(IRTI(op), tr, tsh); +} + +/* -- String library fast functions --------------------------------------- */ + +static void LJ_FASTCALL recff_string_len(jit_State *J, RecordFFData *rd) +{ + J->base[0] = emitir(IRTI(IR_FLOAD), lj_ir_tostr(J, J->base[0]), IRFL_STR_LEN); + UNUSED(rd); +} + +/* Handle string.byte (rd->data = 0) and string.sub (rd->data = 1). */ +static void LJ_FASTCALL recff_string_range(jit_State *J, RecordFFData *rd) +{ + TRef trstr = lj_ir_tostr(J, J->base[0]); + TRef trlen = emitir(IRTI(IR_FLOAD), trstr, IRFL_STR_LEN); + TRef tr0 = lj_ir_kint(J, 0); + TRef trstart, trend; + GCstr *str = argv2str(J, &rd->argv[0]); + int32_t start, end; + if (rd->data) { /* string.sub(str, start [,end]) */ + start = argv2int(J, &rd->argv[1]); + trstart = lj_opt_narrow_toint(J, J->base[1]); + trend = J->base[2]; + if (tref_isnil(trend)) { + trend = lj_ir_kint(J, -1); + end = -1; + } else { + trend = lj_opt_narrow_toint(J, trend); + end = argv2int(J, &rd->argv[2]); + } + } else { /* string.byte(str, [,start [,end]]) */ + if (tref_isnil(J->base[1])) { + start = 1; + trstart = lj_ir_kint(J, 1); + } else { + start = argv2int(J, &rd->argv[1]); + trstart = lj_opt_narrow_toint(J, J->base[1]); + } + if (J->base[1] && !tref_isnil(J->base[2])) { + trend = lj_opt_narrow_toint(J, J->base[2]); + end = argv2int(J, &rd->argv[2]); + } else { + trend = trstart; + end = start; + } + } + if (end < 0) { + emitir(IRTGI(IR_LT), trend, tr0); + trend = emitir(IRTI(IR_ADD), emitir(IRTI(IR_ADD), trlen, trend), + lj_ir_kint(J, 1)); + end = end+(int32_t)str->len+1; + } else if ((MSize)end <= str->len) { + emitir(IRTGI(IR_ULE), trend, trlen); + } else { + emitir(IRTGI(IR_GT), trend, trlen); + end = (int32_t)str->len; + trend = trlen; + } + if (start < 0) { + emitir(IRTGI(IR_LT), trstart, tr0); + trstart = emitir(IRTI(IR_ADD), trlen, trstart); + start = start+(int32_t)str->len; + emitir(start < 0 ? IRTGI(IR_LT) : IRTGI(IR_GE), trstart, tr0); + if (start < 0) { + trstart = tr0; + start = 0; + } + } else { + if (start == 0) { + emitir(IRTGI(IR_EQ), trstart, tr0); + trstart = tr0; + } else { + trstart = emitir(IRTI(IR_ADD), trstart, lj_ir_kint(J, -1)); + emitir(IRTGI(IR_GE), trstart, tr0); + start--; + } + } + if (rd->data) { /* Return string.sub result. */ + if (end - start >= 0) { + /* Also handle empty range here, to avoid extra traces. */ + TRef trptr, trslen = emitir(IRTI(IR_SUB), trend, trstart); + emitir(IRTGI(IR_GE), trslen, tr0); + trptr = emitir(IRT(IR_STRREF, IRT_P32), trstr, trstart); + J->base[0] = emitir(IRT(IR_SNEW, IRT_STR), trptr, trslen); + } else { /* Range underflow: return empty string. */ + emitir(IRTGI(IR_LT), trend, trstart); + J->base[0] = lj_ir_kstr(J, lj_str_new(J->L, strdata(str), 0)); + } + } else { /* Return string.byte result(s). */ + ptrdiff_t i, len = end - start; + if (len > 0) { + TRef trslen = emitir(IRTI(IR_SUB), trend, trstart); + emitir(IRTGI(IR_EQ), trslen, lj_ir_kint(J, (int32_t)len)); + if (J->baseslot + len > LJ_MAX_JSLOTS) + lj_trace_err_info(J, LJ_TRERR_STACKOV); + rd->nres = len; + for (i = 0; i < len; i++) { + TRef tmp = emitir(IRTI(IR_ADD), trstart, lj_ir_kint(J, (int32_t)i)); + tmp = emitir(IRT(IR_STRREF, IRT_P32), trstr, tmp); + J->base[i] = emitir(IRT(IR_XLOAD, IRT_U8), tmp, IRXLOAD_READONLY); + } + } else { /* Empty range or range underflow: return no results. */ + emitir(IRTGI(IR_LE), trend, trstart); + rd->nres = 0; + } + } +} + +/* -- Table library fast functions ---------------------------------------- */ + +static void LJ_FASTCALL recff_table_getn(jit_State *J, RecordFFData *rd) +{ + if (tref_istab(J->base[0])) + J->base[0] = lj_ir_call(J, IRCALL_lj_tab_len, J->base[0]); + /* else: Interpreter will throw. */ + UNUSED(rd); +} + +static void LJ_FASTCALL recff_table_remove(jit_State *J, RecordFFData *rd) +{ + TRef tab = J->base[0]; + rd->nres = 0; + if (tref_istab(tab)) { + if (tref_isnil(J->base[1])) { /* Simple pop: t[#t] = nil */ + TRef trlen = lj_ir_call(J, IRCALL_lj_tab_len, tab); + GCtab *t = tabV(&rd->argv[0]); + MSize len = lj_tab_len(t); + emitir(IRTGI(len ? IR_NE : IR_EQ), trlen, lj_ir_kint(J, 0)); + if (len) { + RecordIndex ix; + ix.tab = tab; + ix.key = trlen; + settabV(J->L, &ix.tabv, t); + setintV(&ix.keyv, len); + ix.idxchain = 0; + if (results_wanted(J) != 0) { /* Specialize load only if needed. */ + ix.val = 0; + J->base[0] = lj_record_idx(J, &ix); /* Load previous value. */ + rd->nres = 1; + /* Assumes ix.key/ix.tab is not modified for raw lj_record_idx(). */ + } + ix.val = TREF_NIL; + lj_record_idx(J, &ix); /* Remove value. */ + } + } else { /* Complex case: remove in the middle. */ + recff_nyiu(J); + } + } /* else: Interpreter will throw. */ +} + +static void LJ_FASTCALL recff_table_insert(jit_State *J, RecordFFData *rd) +{ + RecordIndex ix; + ix.tab = J->base[0]; + ix.val = J->base[1]; + rd->nres = 0; + if (tref_istab(ix.tab) && ix.val) { + if (!J->base[2]) { /* Simple push: t[#t+1] = v */ + TRef trlen = lj_ir_call(J, IRCALL_lj_tab_len, ix.tab); + GCtab *t = tabV(&rd->argv[0]); + ix.key = emitir(IRTI(IR_ADD), trlen, lj_ir_kint(J, 1)); + settabV(J->L, &ix.tabv, t); + setintV(&ix.keyv, lj_tab_len(t) + 1); + ix.idxchain = 0; + lj_record_idx(J, &ix); /* Set new value. */ + } else { /* Complex case: insert in the middle. */ + recff_nyiu(J); + } + } /* else: Interpreter will throw. */ +} + +/* -- I/O library fast functions ------------------------------------------ */ + +/* Get FILE* for I/O function. Any I/O error aborts recording, so there's +** no need to encode the alternate cases for any of the guards. +*/ +static TRef recff_io_fp(jit_State *J, TRef *udp, int32_t id) +{ + TRef tr, ud, fp; + if (id) { /* io.func() */ + tr = lj_ir_kptr(J, &J2G(J)->gcroot[id]); + ud = emitir(IRT(IR_XLOAD, IRT_UDATA), tr, 0); + } else { /* fp:method() */ + ud = J->base[0]; + if (!tref_isudata(ud)) + lj_trace_err(J, LJ_TRERR_BADTYPE); + tr = emitir(IRT(IR_FLOAD, IRT_U8), ud, IRFL_UDATA_UDTYPE); + emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, UDTYPE_IO_FILE)); + } + *udp = ud; + fp = emitir(IRT(IR_FLOAD, IRT_PTR), ud, IRFL_UDATA_FILE); + emitir(IRTG(IR_NE, IRT_PTR), fp, lj_ir_knull(J, IRT_PTR)); + return fp; +} + +static void LJ_FASTCALL recff_io_write(jit_State *J, RecordFFData *rd) +{ + TRef ud, fp = recff_io_fp(J, &ud, rd->data); + TRef zero = lj_ir_kint(J, 0); + TRef one = lj_ir_kint(J, 1); + ptrdiff_t i = rd->data == 0 ? 1 : 0; + for (; J->base[i]; i++) { + TRef str = lj_ir_tostr(J, J->base[i]); + TRef buf = emitir(IRT(IR_STRREF, IRT_P32), str, zero); + TRef len = emitir(IRTI(IR_FLOAD), str, IRFL_STR_LEN); + if (tref_isk(len) && IR(tref_ref(len))->i == 1) { + TRef tr = emitir(IRT(IR_XLOAD, IRT_U8), buf, IRXLOAD_READONLY); + tr = lj_ir_call(J, IRCALL_fputc, tr, fp); + if (results_wanted(J) != 0) /* Check result only if not ignored. */ + emitir(IRTGI(IR_NE), tr, lj_ir_kint(J, -1)); + } else { + TRef tr = lj_ir_call(J, IRCALL_fwrite, buf, one, len, fp); + if (results_wanted(J) != 0) /* Check result only if not ignored. */ + emitir(IRTGI(IR_EQ), tr, len); + } + } + J->base[0] = LJ_52 ? ud : TREF_TRUE; +} + +static void LJ_FASTCALL recff_io_flush(jit_State *J, RecordFFData *rd) +{ + TRef ud, fp = recff_io_fp(J, &ud, rd->data); + TRef tr = lj_ir_call(J, IRCALL_fflush, fp); + if (results_wanted(J) != 0) /* Check result only if not ignored. */ + emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, 0)); + J->base[0] = TREF_TRUE; +} + +/* -- Record calls to fast functions -------------------------------------- */ + +#include "lj_recdef.h" + +static uint32_t recdef_lookup(GCfunc *fn) +{ + if (fn->c.ffid < sizeof(recff_idmap)/sizeof(recff_idmap[0])) + return recff_idmap[fn->c.ffid]; + else + return 0; +} + +/* Record entry to a fast function or C function. */ +void lj_ffrecord_func(jit_State *J) +{ + RecordFFData rd; + uint32_t m = recdef_lookup(J->fn); + rd.data = m & 0xff; + rd.nres = 1; /* Default is one result. */ + rd.argv = J->L->base; + J->base[J->maxslot] = 0; /* Mark end of arguments. */ + (recff_func[m >> 8])(J, &rd); /* Call recff_* handler. */ + if (rd.nres >= 0) { + if (J->postproc == LJ_POST_NONE) J->postproc = LJ_POST_FFRETRY; + lj_record_ret(J, 0, rd.nres); + } +} + +#undef IR +#undef emitir + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_ffrecord.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ffrecord.h new file mode 100644 index 000000000..f858ca29c --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ffrecord.h @@ -0,0 +1,24 @@ +/* +** Fast function call recorder. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_FFRECORD_H +#define _LJ_FFRECORD_H + +#include "lj_obj.h" +#include "lj_jit.h" + +#if LJ_HASJIT +/* Data used by handlers to record a fast function. */ +typedef struct RecordFFData { + TValue *argv; /* Runtime argument values. */ + ptrdiff_t nres; /* Number of returned results (defaults to 1). */ + uint32_t data; /* Per-ffid auxiliary data (opcode, literal etc.). */ +} RecordFFData; + +LJ_FUNC int32_t lj_ffrecord_select_mode(jit_State *J, TRef tr, TValue *tv); +LJ_FUNC void lj_ffrecord_func(jit_State *J); +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_frame.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_frame.h new file mode 100644 index 000000000..cd57be223 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_frame.h @@ -0,0 +1,183 @@ +/* +** Stack frames. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_FRAME_H +#define _LJ_FRAME_H + +#include "lj_obj.h" +#include "lj_bc.h" + +/* -- Lua stack frame ----------------------------------------------------- */ + +/* Frame type markers in callee function slot (callee base-1). */ +enum { + FRAME_LUA, FRAME_C, FRAME_CONT, FRAME_VARG, + FRAME_LUAP, FRAME_CP, FRAME_PCALL, FRAME_PCALLH +}; +#define FRAME_TYPE 3 +#define FRAME_P 4 +#define FRAME_TYPEP (FRAME_TYPE|FRAME_P) + +/* Macros to access and modify Lua frames. */ +#define frame_gc(f) (gcref((f)->fr.func)) +#define frame_func(f) (&frame_gc(f)->fn) +#define frame_ftsz(f) ((f)->fr.tp.ftsz) + +#define frame_type(f) (frame_ftsz(f) & FRAME_TYPE) +#define frame_typep(f) (frame_ftsz(f) & FRAME_TYPEP) +#define frame_islua(f) (frame_type(f) == FRAME_LUA) +#define frame_isc(f) (frame_type(f) == FRAME_C) +#define frame_iscont(f) (frame_typep(f) == FRAME_CONT) +#define frame_isvarg(f) (frame_typep(f) == FRAME_VARG) +#define frame_ispcall(f) ((frame_ftsz(f) & 6) == FRAME_PCALL) + +#define frame_pc(f) (mref((f)->fr.tp.pcr, const BCIns)) +#define frame_contpc(f) (frame_pc((f)-1)) +#if LJ_64 +#define frame_contf(f) \ + ((ASMFunction)(void *)((intptr_t)lj_vm_asm_begin + \ + (intptr_t)(int32_t)((f)-1)->u32.lo)) +#else +#define frame_contf(f) ((ASMFunction)gcrefp(((f)-1)->gcr, void)) +#endif +#define frame_delta(f) (frame_ftsz(f) >> 3) +#define frame_sized(f) (frame_ftsz(f) & ~FRAME_TYPEP) + +#define frame_prevl(f) ((f) - (1+bc_a(frame_pc(f)[-1]))) +#define frame_prevd(f) ((TValue *)((char *)(f) - frame_sized(f))) +#define frame_prev(f) (frame_islua(f)?frame_prevl(f):frame_prevd(f)) +/* Note: this macro does not skip over FRAME_VARG. */ + +#define setframe_pc(f, pc) (setmref((f)->fr.tp.pcr, (pc))) +#define setframe_ftsz(f, sz) ((f)->fr.tp.ftsz = (sz)) +#define setframe_gc(f, p) (setgcref((f)->fr.func, (p))) + +/* -- C stack frame ------------------------------------------------------- */ + +/* Macros to access and modify the C stack frame chain. */ + +/* These definitions must match with the arch-specific *.dasc files. */ +#if LJ_TARGET_X86 +#define CFRAME_OFS_ERRF (15*4) +#define CFRAME_OFS_NRES (14*4) +#define CFRAME_OFS_PREV (13*4) +#define CFRAME_OFS_L (12*4) +#define CFRAME_OFS_PC (6*4) +#define CFRAME_OFS_MULTRES (5*4) +#define CFRAME_SIZE (12*4) +#define CFRAME_SHIFT_MULTRES 0 +#elif LJ_TARGET_X64 +#if LJ_ABI_WIN +#define CFRAME_OFS_PREV (13*8) +#define CFRAME_OFS_PC (25*4) +#define CFRAME_OFS_L (24*4) +#define CFRAME_OFS_ERRF (23*4) +#define CFRAME_OFS_NRES (22*4) +#define CFRAME_OFS_MULTRES (21*4) +#define CFRAME_SIZE (10*8) +#define CFRAME_SIZE_JIT (CFRAME_SIZE + 9*16 + 4*8) +#define CFRAME_SHIFT_MULTRES 0 +#else +#define CFRAME_OFS_PREV (4*8) +#define CFRAME_OFS_PC (7*4) +#define CFRAME_OFS_L (6*4) +#define CFRAME_OFS_ERRF (5*4) +#define CFRAME_OFS_NRES (4*4) +#define CFRAME_OFS_MULTRES (1*4) +#define CFRAME_SIZE (10*8) +#define CFRAME_SIZE_JIT (CFRAME_SIZE + 16) +#define CFRAME_SHIFT_MULTRES 0 +#endif +#elif LJ_TARGET_ARM +#define CFRAME_OFS_ERRF 24 +#define CFRAME_OFS_NRES 20 +#define CFRAME_OFS_PREV 16 +#define CFRAME_OFS_L 12 +#define CFRAME_OFS_PC 8 +#define CFRAME_OFS_MULTRES 4 +#if LJ_ARCH_HASFPU +#define CFRAME_SIZE 128 +#else +#define CFRAME_SIZE 64 +#endif +#define CFRAME_SHIFT_MULTRES 3 +#elif LJ_TARGET_PPC +#if LJ_TARGET_XBOX360 +#define CFRAME_OFS_ERRF 424 +#define CFRAME_OFS_NRES 420 +#define CFRAME_OFS_PREV 400 +#define CFRAME_OFS_L 416 +#define CFRAME_OFS_PC 412 +#define CFRAME_OFS_MULTRES 408 +#define CFRAME_SIZE 384 +#define CFRAME_SHIFT_MULTRES 3 +#elif LJ_ARCH_PPC64 +#define CFRAME_OFS_ERRF 472 +#define CFRAME_OFS_NRES 468 +#define CFRAME_OFS_PREV 448 +#define CFRAME_OFS_L 464 +#define CFRAME_OFS_PC 460 +#define CFRAME_OFS_MULTRES 456 +#define CFRAME_SIZE 400 +#define CFRAME_SHIFT_MULTRES 3 +#else +#define CFRAME_OFS_ERRF 48 +#define CFRAME_OFS_NRES 44 +#define CFRAME_OFS_PREV 40 +#define CFRAME_OFS_L 36 +#define CFRAME_OFS_PC 32 +#define CFRAME_OFS_MULTRES 28 +#define CFRAME_SIZE 272 +#define CFRAME_SHIFT_MULTRES 3 +#endif +#elif LJ_TARGET_PPCSPE +#define CFRAME_OFS_ERRF 28 +#define CFRAME_OFS_NRES 24 +#define CFRAME_OFS_PREV 20 +#define CFRAME_OFS_L 16 +#define CFRAME_OFS_PC 12 +#define CFRAME_OFS_MULTRES 8 +#define CFRAME_SIZE 184 +#define CFRAME_SHIFT_MULTRES 3 +#elif LJ_TARGET_MIPS +#define CFRAME_OFS_ERRF 124 +#define CFRAME_OFS_NRES 120 +#define CFRAME_OFS_PREV 116 +#define CFRAME_OFS_L 112 +#define CFRAME_OFS_PC 20 +#define CFRAME_OFS_MULTRES 16 +#define CFRAME_SIZE 112 +#define CFRAME_SHIFT_MULTRES 3 +#else +#error "Missing CFRAME_* definitions for this architecture" +#endif + +#ifndef CFRAME_SIZE_JIT +#define CFRAME_SIZE_JIT CFRAME_SIZE +#endif + +#define CFRAME_RESUME 1 +#define CFRAME_UNWIND_FF 2 /* Only used in unwinder. */ +#define CFRAME_RAWMASK (~(intptr_t)(CFRAME_RESUME|CFRAME_UNWIND_FF)) + +#define cframe_errfunc(cf) (*(int32_t *)(((char *)(cf))+CFRAME_OFS_ERRF)) +#define cframe_nres(cf) (*(int32_t *)(((char *)(cf))+CFRAME_OFS_NRES)) +#define cframe_prev(cf) (*(void **)(((char *)(cf))+CFRAME_OFS_PREV)) +#define cframe_multres(cf) (*(uint32_t *)(((char *)(cf))+CFRAME_OFS_MULTRES)) +#define cframe_multres_n(cf) (cframe_multres((cf)) >> CFRAME_SHIFT_MULTRES) +#define cframe_L(cf) \ + (&gcref(*(GCRef *)(((char *)(cf))+CFRAME_OFS_L))->th) +#define cframe_pc(cf) \ + (mref(*(MRef *)(((char *)(cf))+CFRAME_OFS_PC), const BCIns)) +#define setcframe_L(cf, L) \ + (setmref(*(MRef *)(((char *)(cf))+CFRAME_OFS_L), (L))) +#define setcframe_pc(cf, pc) \ + (setmref(*(MRef *)(((char *)(cf))+CFRAME_OFS_PC), (pc))) +#define cframe_canyield(cf) ((intptr_t)(cf) & CFRAME_RESUME) +#define cframe_unwind_ff(cf) ((intptr_t)(cf) & CFRAME_UNWIND_FF) +#define cframe_raw(cf) ((void *)((intptr_t)(cf) & CFRAME_RAWMASK)) +#define cframe_Lpc(L) cframe_pc(cframe_raw(L->cframe)) + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_func.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_func.c new file mode 100644 index 000000000..eb8a9dbbf --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_func.c @@ -0,0 +1,185 @@ +/* +** Function handling (prototypes, functions and upvalues). +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lj_func_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_func.h" +#include "lj_trace.h" +#include "lj_vm.h" + +/* -- Prototypes ---------------------------------------------------------- */ + +void LJ_FASTCALL lj_func_freeproto(global_State *g, GCproto *pt) +{ + lj_mem_free(g, pt, pt->sizept); +} + +/* -- Upvalues ------------------------------------------------------------ */ + +static void unlinkuv(GCupval *uv) +{ + lua_assert(uvprev(uvnext(uv)) == uv && uvnext(uvprev(uv)) == uv); + setgcrefr(uvnext(uv)->prev, uv->prev); + setgcrefr(uvprev(uv)->next, uv->next); +} + +/* Find existing open upvalue for a stack slot or create a new one. */ +static GCupval *func_finduv(lua_State *L, TValue *slot) +{ + global_State *g = G(L); + GCRef *pp = &L->openupval; + GCupval *p; + GCupval *uv; + /* Search the sorted list of open upvalues. */ + while (gcref(*pp) != NULL && uvval((p = gco2uv(gcref(*pp)))) >= slot) { + lua_assert(!p->closed && uvval(p) != &p->tv); + if (uvval(p) == slot) { /* Found open upvalue pointing to same slot? */ + if (isdead(g, obj2gco(p))) /* Resurrect it, if it's dead. */ + flipwhite(obj2gco(p)); + return p; + } + pp = &p->nextgc; + } + /* No matching upvalue found. Create a new one. */ + uv = lj_mem_newt(L, sizeof(GCupval), GCupval); + newwhite(g, uv); + uv->gct = ~LJ_TUPVAL; + uv->closed = 0; /* Still open. */ + setmref(uv->v, slot); /* Pointing to the stack slot. */ + /* NOBARRIER: The GCupval is new (marked white) and open. */ + setgcrefr(uv->nextgc, *pp); /* Insert into sorted list of open upvalues. */ + setgcref(*pp, obj2gco(uv)); + setgcref(uv->prev, obj2gco(&g->uvhead)); /* Insert into GC list, too. */ + setgcrefr(uv->next, g->uvhead.next); + setgcref(uvnext(uv)->prev, obj2gco(uv)); + setgcref(g->uvhead.next, obj2gco(uv)); + lua_assert(uvprev(uvnext(uv)) == uv && uvnext(uvprev(uv)) == uv); + return uv; +} + +/* Create an empty and closed upvalue. */ +static GCupval *func_emptyuv(lua_State *L) +{ + GCupval *uv = (GCupval *)lj_mem_newgco(L, sizeof(GCupval)); + uv->gct = ~LJ_TUPVAL; + uv->closed = 1; + setnilV(&uv->tv); + setmref(uv->v, &uv->tv); + return uv; +} + +/* Close all open upvalues pointing to some stack level or above. */ +void LJ_FASTCALL lj_func_closeuv(lua_State *L, TValue *level) +{ + GCupval *uv; + global_State *g = G(L); + while (gcref(L->openupval) != NULL && + uvval((uv = gco2uv(gcref(L->openupval)))) >= level) { + GCobj *o = obj2gco(uv); + lua_assert(!isblack(o) && !uv->closed && uvval(uv) != &uv->tv); + setgcrefr(L->openupval, uv->nextgc); /* No longer in open list. */ + if (isdead(g, o)) { + lj_func_freeuv(g, uv); + } else { + unlinkuv(uv); + lj_gc_closeuv(g, uv); + } + } +} + +void LJ_FASTCALL lj_func_freeuv(global_State *g, GCupval *uv) +{ + if (!uv->closed) + unlinkuv(uv); + lj_mem_freet(g, uv); +} + +/* -- Functions (closures) ------------------------------------------------ */ + +GCfunc *lj_func_newC(lua_State *L, MSize nelems, GCtab *env) +{ + GCfunc *fn = (GCfunc *)lj_mem_newgco(L, sizeCfunc(nelems)); + fn->c.gct = ~LJ_TFUNC; + fn->c.ffid = FF_C; + fn->c.nupvalues = (uint8_t)nelems; + /* NOBARRIER: The GCfunc is new (marked white). */ + setmref(fn->c.pc, &G(L)->bc_cfunc_ext); + setgcref(fn->c.env, obj2gco(env)); + return fn; +} + +static GCfunc *func_newL(lua_State *L, GCproto *pt, GCtab *env) +{ + uint32_t count; + GCfunc *fn = (GCfunc *)lj_mem_newgco(L, sizeLfunc((MSize)pt->sizeuv)); + fn->l.gct = ~LJ_TFUNC; + fn->l.ffid = FF_LUA; + fn->l.nupvalues = 0; /* Set to zero until upvalues are initialized. */ + /* NOBARRIER: Really a setgcref. But the GCfunc is new (marked white). */ + setmref(fn->l.pc, proto_bc(pt)); + setgcref(fn->l.env, obj2gco(env)); + /* Saturating 3 bit counter (0..7) for created closures. */ + count = (uint32_t)pt->flags + PROTO_CLCOUNT; + pt->flags = (uint8_t)(count - ((count >> PROTO_CLC_BITS) & PROTO_CLCOUNT)); + return fn; +} + +/* Create a new Lua function with empty upvalues. */ +GCfunc *lj_func_newL_empty(lua_State *L, GCproto *pt, GCtab *env) +{ + GCfunc *fn = func_newL(L, pt, env); + MSize i, nuv = pt->sizeuv; + /* NOBARRIER: The GCfunc is new (marked white). */ + for (i = 0; i < nuv; i++) { + GCupval *uv = func_emptyuv(L); + uv->dhash = (uint32_t)(uintptr_t)pt ^ ((uint32_t)proto_uv(pt)[i] << 24); + setgcref(fn->l.uvptr[i], obj2gco(uv)); + } + fn->l.nupvalues = (uint8_t)nuv; + return fn; +} + +/* Do a GC check and create a new Lua function with inherited upvalues. */ +GCfunc *lj_func_newL_gc(lua_State *L, GCproto *pt, GCfuncL *parent) +{ + GCfunc *fn; + GCRef *puv; + MSize i, nuv; + TValue *base; + lj_gc_check_fixtop(L); + fn = func_newL(L, pt, tabref(parent->env)); + /* NOBARRIER: The GCfunc is new (marked white). */ + puv = parent->uvptr; + nuv = pt->sizeuv; + base = L->base; + for (i = 0; i < nuv; i++) { + uint32_t v = proto_uv(pt)[i]; + GCupval *uv; + if ((v & PROTO_UV_LOCAL)) { + uv = func_finduv(L, base + (v & 0xff)); + uv->immutable = ((v / PROTO_UV_IMMUTABLE) & 1); + uv->dhash = (uint32_t)(uintptr_t)mref(parent->pc, char) ^ (v << 24); + } else { + uv = &gcref(puv[v])->uv; + } + setgcref(fn->l.uvptr[i], obj2gco(uv)); + } + fn->l.nupvalues = (uint8_t)nuv; + return fn; +} + +void LJ_FASTCALL lj_func_free(global_State *g, GCfunc *fn) +{ + MSize size = isluafunc(fn) ? sizeLfunc((MSize)fn->l.nupvalues) : + sizeCfunc((MSize)fn->c.nupvalues); + lj_mem_free(g, fn, size); +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_func.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_func.h new file mode 100644 index 000000000..a6e534e77 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_func.h @@ -0,0 +1,24 @@ +/* +** Function handling (prototypes, functions and upvalues). +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_FUNC_H +#define _LJ_FUNC_H + +#include "lj_obj.h" + +/* Prototypes. */ +LJ_FUNC void LJ_FASTCALL lj_func_freeproto(global_State *g, GCproto *pt); + +/* Upvalues. */ +LJ_FUNCA void LJ_FASTCALL lj_func_closeuv(lua_State *L, TValue *level); +LJ_FUNC void LJ_FASTCALL lj_func_freeuv(global_State *g, GCupval *uv); + +/* Functions (closures). */ +LJ_FUNC GCfunc *lj_func_newC(lua_State *L, MSize nelems, GCtab *env); +LJ_FUNC GCfunc *lj_func_newL_empty(lua_State *L, GCproto *pt, GCtab *env); +LJ_FUNCA GCfunc *lj_func_newL_gc(lua_State *L, GCproto *pt, GCfuncL *parent); +LJ_FUNC void LJ_FASTCALL lj_func_free(global_State *g, GCfunc *c); + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_gc.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_gc.c new file mode 100644 index 000000000..b498abaa8 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_gc.c @@ -0,0 +1,849 @@ +/* +** Garbage collector. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lj_gc_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_func.h" +#include "lj_udata.h" +#include "lj_meta.h" +#include "lj_state.h" +#include "lj_frame.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#include "lj_cdata.h" +#endif +#include "lj_trace.h" +#include "lj_vm.h" + +#define GCSTEPSIZE 1024u +#define GCSWEEPMAX 40 +#define GCSWEEPCOST 10 +#define GCFINALIZECOST 100 + +/* Macros to set GCobj colors and flags. */ +#define white2gray(x) ((x)->gch.marked &= (uint8_t)~LJ_GC_WHITES) +#define gray2black(x) ((x)->gch.marked |= LJ_GC_BLACK) +#define isfinalized(u) ((u)->marked & LJ_GC_FINALIZED) + +/* -- Mark phase ---------------------------------------------------------- */ + +/* Mark a TValue (if needed). */ +#define gc_marktv(g, tv) \ + { lua_assert(!tvisgcv(tv) || (~itype(tv) == gcval(tv)->gch.gct)); \ + if (tviswhite(tv)) gc_mark(g, gcV(tv)); } + +/* Mark a GCobj (if needed). */ +#define gc_markobj(g, o) \ + { if (iswhite(obj2gco(o))) gc_mark(g, obj2gco(o)); } + +/* Mark a string object. */ +#define gc_mark_str(s) ((s)->marked &= (uint8_t)~LJ_GC_WHITES) + +/* Mark a white GCobj. */ +static void gc_mark(global_State *g, GCobj *o) +{ + int gct = o->gch.gct; + lua_assert(iswhite(o) && !isdead(g, o)); + white2gray(o); + if (LJ_UNLIKELY(gct == ~LJ_TUDATA)) { + GCtab *mt = tabref(gco2ud(o)->metatable); + gray2black(o); /* Userdata are never gray. */ + if (mt) gc_markobj(g, mt); + gc_markobj(g, tabref(gco2ud(o)->env)); + } else if (LJ_UNLIKELY(gct == ~LJ_TUPVAL)) { + GCupval *uv = gco2uv(o); + gc_marktv(g, uvval(uv)); + if (uv->closed) + gray2black(o); /* Closed upvalues are never gray. */ + } else if (gct != ~LJ_TSTR && gct != ~LJ_TCDATA) { + lua_assert(gct == ~LJ_TFUNC || gct == ~LJ_TTAB || + gct == ~LJ_TTHREAD || gct == ~LJ_TPROTO); + setgcrefr(o->gch.gclist, g->gc.gray); + setgcref(g->gc.gray, o); + } +} + +/* Mark GC roots. */ +static void gc_mark_gcroot(global_State *g) +{ + ptrdiff_t i; + for (i = 0; i < GCROOT_MAX; i++) + if (gcref(g->gcroot[i]) != NULL) + gc_markobj(g, gcref(g->gcroot[i])); +} + +/* Start a GC cycle and mark the root set. */ +static void gc_mark_start(global_State *g) +{ + setgcrefnull(g->gc.gray); + setgcrefnull(g->gc.grayagain); + setgcrefnull(g->gc.weak); + gc_markobj(g, mainthread(g)); + gc_markobj(g, tabref(mainthread(g)->env)); + gc_marktv(g, &g->registrytv); + gc_mark_gcroot(g); + g->gc.state = GCSpropagate; +} + +/* Mark open upvalues. */ +static void gc_mark_uv(global_State *g) +{ + GCupval *uv; + for (uv = uvnext(&g->uvhead); uv != &g->uvhead; uv = uvnext(uv)) { + lua_assert(uvprev(uvnext(uv)) == uv && uvnext(uvprev(uv)) == uv); + if (isgray(obj2gco(uv))) + gc_marktv(g, uvval(uv)); + } +} + +/* Mark userdata in mmudata list. */ +static void gc_mark_mmudata(global_State *g) +{ + GCobj *root = gcref(g->gc.mmudata); + GCobj *u = root; + if (u) { + do { + u = gcnext(u); + makewhite(g, u); /* Could be from previous GC. */ + gc_mark(g, u); + } while (u != root); + } +} + +/* Separate userdata objects to be finalized to mmudata list. */ +size_t lj_gc_separateudata(global_State *g, int all) +{ + size_t m = 0; + GCRef *p = &mainthread(g)->nextgc; + GCobj *o; + while ((o = gcref(*p)) != NULL) { + if (!(iswhite(o) || all) || isfinalized(gco2ud(o))) { + p = &o->gch.nextgc; /* Nothing to do. */ + } else if (!lj_meta_fastg(g, tabref(gco2ud(o)->metatable), MM_gc)) { + markfinalized(o); /* Done, as there's no __gc metamethod. */ + p = &o->gch.nextgc; + } else { /* Otherwise move userdata to be finalized to mmudata list. */ + m += sizeudata(gco2ud(o)); + markfinalized(o); + *p = o->gch.nextgc; + if (gcref(g->gc.mmudata)) { /* Link to end of mmudata list. */ + GCobj *root = gcref(g->gc.mmudata); + setgcrefr(o->gch.nextgc, root->gch.nextgc); + setgcref(root->gch.nextgc, o); + setgcref(g->gc.mmudata, o); + } else { /* Create circular list. */ + setgcref(o->gch.nextgc, o); + setgcref(g->gc.mmudata, o); + } + } + } + return m; +} + +/* -- Propagation phase --------------------------------------------------- */ + +/* Traverse a table. */ +static int gc_traverse_tab(global_State *g, GCtab *t) +{ + int weak = 0; + cTValue *mode; + GCtab *mt = tabref(t->metatable); + if (mt) + gc_markobj(g, mt); + mode = lj_meta_fastg(g, mt, MM_mode); + if (mode && tvisstr(mode)) { /* Valid __mode field? */ + const char *modestr = strVdata(mode); + int c; + while ((c = *modestr++)) { + if (c == 'k') weak |= LJ_GC_WEAKKEY; + else if (c == 'v') weak |= LJ_GC_WEAKVAL; + else if (c == 'K') weak = (int)(~0u & ~LJ_GC_WEAKVAL); + } + if (weak > 0) { /* Weak tables are cleared in the atomic phase. */ + t->marked = (uint8_t)((t->marked & ~LJ_GC_WEAK) | weak); + setgcrefr(t->gclist, g->gc.weak); + setgcref(g->gc.weak, obj2gco(t)); + } + } + if (weak == LJ_GC_WEAK) /* Nothing to mark if both keys/values are weak. */ + return 1; + if (!(weak & LJ_GC_WEAKVAL)) { /* Mark array part. */ + MSize i, asize = t->asize; + for (i = 0; i < asize; i++) + gc_marktv(g, arrayslot(t, i)); + } + if (t->hmask > 0) { /* Mark hash part. */ + Node *node = noderef(t->node); + MSize i, hmask = t->hmask; + for (i = 0; i <= hmask; i++) { + Node *n = &node[i]; + if (!tvisnil(&n->val)) { /* Mark non-empty slot. */ + lua_assert(!tvisnil(&n->key)); + if (!(weak & LJ_GC_WEAKKEY)) gc_marktv(g, &n->key); + if (!(weak & LJ_GC_WEAKVAL)) gc_marktv(g, &n->val); + } + } + } + return weak; +} + +/* Traverse a function. */ +static void gc_traverse_func(global_State *g, GCfunc *fn) +{ + gc_markobj(g, tabref(fn->c.env)); + if (isluafunc(fn)) { + uint32_t i; + lua_assert(fn->l.nupvalues <= funcproto(fn)->sizeuv); + gc_markobj(g, funcproto(fn)); + for (i = 0; i < fn->l.nupvalues; i++) /* Mark Lua function upvalues. */ + gc_markobj(g, &gcref(fn->l.uvptr[i])->uv); + } else { + uint32_t i; + for (i = 0; i < fn->c.nupvalues; i++) /* Mark C function upvalues. */ + gc_marktv(g, &fn->c.upvalue[i]); + } +} + +#if LJ_HASJIT +/* Mark a trace. */ +static void gc_marktrace(global_State *g, TraceNo traceno) +{ + GCobj *o = obj2gco(traceref(G2J(g), traceno)); + lua_assert(traceno != G2J(g)->cur.traceno); + if (iswhite(o)) { + white2gray(o); + setgcrefr(o->gch.gclist, g->gc.gray); + setgcref(g->gc.gray, o); + } +} + +/* Traverse a trace. */ +static void gc_traverse_trace(global_State *g, GCtrace *T) +{ + IRRef ref; + if (T->traceno == 0) return; + for (ref = T->nk; ref < REF_TRUE; ref++) { + IRIns *ir = &T->ir[ref]; + if (ir->o == IR_KGC) + gc_markobj(g, ir_kgc(ir)); + } + if (T->link) gc_marktrace(g, T->link); + if (T->nextroot) gc_marktrace(g, T->nextroot); + if (T->nextside) gc_marktrace(g, T->nextside); + gc_markobj(g, gcref(T->startpt)); +} + +/* The current trace is a GC root while not anchored in the prototype (yet). */ +#define gc_traverse_curtrace(g) gc_traverse_trace(g, &G2J(g)->cur) +#else +#define gc_traverse_curtrace(g) UNUSED(g) +#endif + +/* Traverse a prototype. */ +static void gc_traverse_proto(global_State *g, GCproto *pt) +{ + ptrdiff_t i; + gc_mark_str(proto_chunkname(pt)); + for (i = -(ptrdiff_t)pt->sizekgc; i < 0; i++) /* Mark collectable consts. */ + gc_markobj(g, proto_kgc(pt, i)); +#if LJ_HASJIT + if (pt->trace) gc_marktrace(g, pt->trace); +#endif +} + +/* Traverse the frame structure of a stack. */ +static MSize gc_traverse_frames(global_State *g, lua_State *th) +{ + TValue *frame, *top = th->top-1, *bot = tvref(th->stack); + /* Note: extra vararg frame not skipped, marks function twice (harmless). */ + for (frame = th->base-1; frame > bot; frame = frame_prev(frame)) { + GCfunc *fn = frame_func(frame); + TValue *ftop = frame; + if (isluafunc(fn)) ftop += funcproto(fn)->framesize; + if (ftop > top) top = ftop; + gc_markobj(g, fn); /* Need to mark hidden function (or L). */ + } + top++; /* Correct bias of -1 (frame == base-1). */ + if (top > tvref(th->maxstack)) top = tvref(th->maxstack); + return (MSize)(top - bot); /* Return minimum needed stack size. */ +} + +/* Traverse a thread object. */ +static void gc_traverse_thread(global_State *g, lua_State *th) +{ + TValue *o, *top = th->top; + for (o = tvref(th->stack)+1; o < top; o++) + gc_marktv(g, o); + if (g->gc.state == GCSatomic) { + top = tvref(th->stack) + th->stacksize; + for (; o < top; o++) /* Clear unmarked slots. */ + setnilV(o); + } + gc_markobj(g, tabref(th->env)); + lj_state_shrinkstack(th, gc_traverse_frames(g, th)); +} + +/* Propagate one gray object. Traverse it and turn it black. */ +static size_t propagatemark(global_State *g) +{ + GCobj *o = gcref(g->gc.gray); + int gct = o->gch.gct; + lua_assert(isgray(o)); + gray2black(o); + setgcrefr(g->gc.gray, o->gch.gclist); /* Remove from gray list. */ + if (LJ_LIKELY(gct == ~LJ_TTAB)) { + GCtab *t = gco2tab(o); + if (gc_traverse_tab(g, t) > 0) + black2gray(o); /* Keep weak tables gray. */ + return sizeof(GCtab) + sizeof(TValue) * t->asize + + sizeof(Node) * (t->hmask + 1); + } else if (LJ_LIKELY(gct == ~LJ_TFUNC)) { + GCfunc *fn = gco2func(o); + gc_traverse_func(g, fn); + return isluafunc(fn) ? sizeLfunc((MSize)fn->l.nupvalues) : + sizeCfunc((MSize)fn->c.nupvalues); + } else if (LJ_LIKELY(gct == ~LJ_TPROTO)) { + GCproto *pt = gco2pt(o); + gc_traverse_proto(g, pt); + return pt->sizept; + } else if (LJ_LIKELY(gct == ~LJ_TTHREAD)) { + lua_State *th = gco2th(o); + setgcrefr(th->gclist, g->gc.grayagain); + setgcref(g->gc.grayagain, o); + black2gray(o); /* Threads are never black. */ + gc_traverse_thread(g, th); + return sizeof(lua_State) + sizeof(TValue) * th->stacksize; + } else { +#if LJ_HASJIT + GCtrace *T = gco2trace(o); + gc_traverse_trace(g, T); + return ((sizeof(GCtrace)+7)&~7) + (T->nins-T->nk)*sizeof(IRIns) + + T->nsnap*sizeof(SnapShot) + T->nsnapmap*sizeof(SnapEntry); +#else + lua_assert(0); + return 0; +#endif + } +} + +/* Propagate all gray objects. */ +static size_t gc_propagate_gray(global_State *g) +{ + size_t m = 0; + while (gcref(g->gc.gray) != NULL) + m += propagatemark(g); + return m; +} + +/* -- Sweep phase --------------------------------------------------------- */ + +/* Try to shrink some common data structures. */ +static void gc_shrink(global_State *g, lua_State *L) +{ + if (g->strnum <= (g->strmask >> 2) && g->strmask > LJ_MIN_STRTAB*2-1) + lj_str_resize(L, g->strmask >> 1); /* Shrink string table. */ + if (g->tmpbuf.sz > LJ_MIN_SBUF*2) + lj_str_resizebuf(L, &g->tmpbuf, g->tmpbuf.sz >> 1); /* Shrink temp buf. */ +} + +/* Type of GC free functions. */ +typedef void (LJ_FASTCALL *GCFreeFunc)(global_State *g, GCobj *o); + +/* GC free functions for LJ_TSTR .. LJ_TUDATA. ORDER LJ_T */ +static const GCFreeFunc gc_freefunc[] = { + (GCFreeFunc)lj_str_free, + (GCFreeFunc)lj_func_freeuv, + (GCFreeFunc)lj_state_free, + (GCFreeFunc)lj_func_freeproto, + (GCFreeFunc)lj_func_free, +#if LJ_HASJIT + (GCFreeFunc)lj_trace_free, +#else + (GCFreeFunc)0, +#endif +#if LJ_HASFFI + (GCFreeFunc)lj_cdata_free, +#else + (GCFreeFunc)0, +#endif + (GCFreeFunc)lj_tab_free, + (GCFreeFunc)lj_udata_free +}; + +/* Full sweep of a GC list. */ +#define gc_fullsweep(g, p) gc_sweep(g, (p), LJ_MAX_MEM) + +/* Partial sweep of a GC list. */ +static GCRef *gc_sweep(global_State *g, GCRef *p, uint32_t lim) +{ + /* Mask with other white and LJ_GC_FIXED. Or LJ_GC_SFIXED on shutdown. */ + int ow = otherwhite(g); + GCobj *o; + while ((o = gcref(*p)) != NULL && lim-- > 0) { + if (o->gch.gct == ~LJ_TTHREAD) /* Need to sweep open upvalues, too. */ + gc_fullsweep(g, &gco2th(o)->openupval); + if (((o->gch.marked ^ LJ_GC_WHITES) & ow)) { /* Black or current white? */ + lua_assert(!isdead(g, o) || (o->gch.marked & LJ_GC_FIXED)); + makewhite(g, o); /* Value is alive, change to the current white. */ + p = &o->gch.nextgc; + } else { /* Otherwise value is dead, free it. */ + lua_assert(isdead(g, o) || ow == LJ_GC_SFIXED); + setgcrefr(*p, o->gch.nextgc); + if (o == gcref(g->gc.root)) + setgcrefr(g->gc.root, o->gch.nextgc); /* Adjust list anchor. */ + gc_freefunc[o->gch.gct - ~LJ_TSTR](g, o); + } + } + return p; +} + +/* Check whether we can clear a key or a value slot from a table. */ +static int gc_mayclear(cTValue *o, int val) +{ + if (tvisgcv(o)) { /* Only collectable objects can be weak references. */ + if (tvisstr(o)) { /* But strings cannot be used as weak references. */ + gc_mark_str(strV(o)); /* And need to be marked. */ + return 0; + } + if (iswhite(gcV(o))) + return 1; /* Object is about to be collected. */ + if (tvisudata(o) && val && isfinalized(udataV(o))) + return 1; /* Finalized userdata is dropped only from values. */ + } + return 0; /* Cannot clear. */ +} + +/* Clear collected entries from weak tables. */ +static void gc_clearweak(GCobj *o) +{ + while (o) { + GCtab *t = gco2tab(o); + lua_assert((t->marked & LJ_GC_WEAK)); + if ((t->marked & LJ_GC_WEAKVAL)) { + MSize i, asize = t->asize; + for (i = 0; i < asize; i++) { + /* Clear array slot when value is about to be collected. */ + TValue *tv = arrayslot(t, i); + if (gc_mayclear(tv, 1)) + setnilV(tv); + } + } + if (t->hmask > 0) { + Node *node = noderef(t->node); + MSize i, hmask = t->hmask; + for (i = 0; i <= hmask; i++) { + Node *n = &node[i]; + /* Clear hash slot when key or value is about to be collected. */ + if (!tvisnil(&n->val) && (gc_mayclear(&n->key, 0) || + gc_mayclear(&n->val, 1))) + setnilV(&n->val); + } + } + o = gcref(t->gclist); + } +} + +/* Call a userdata or cdata finalizer. */ +static void gc_call_finalizer(global_State *g, lua_State *L, + cTValue *mo, GCobj *o) +{ + /* Save and restore lots of state around the __gc callback. */ + uint8_t oldh = hook_save(g); + MSize oldt = g->gc.threshold; + int errcode; + TValue *top; + lj_trace_abort(g); + top = L->top; + L->top = top+2; + hook_entergc(g); /* Disable hooks and new traces during __gc. */ + g->gc.threshold = LJ_MAX_MEM; /* Prevent GC steps. */ + copyTV(L, top, mo); + setgcV(L, top+1, o, ~o->gch.gct); + errcode = lj_vm_pcall(L, top+1, 1+0, -1); /* Stack: |mo|o| -> | */ + hook_restore(g, oldh); + g->gc.threshold = oldt; /* Restore GC threshold. */ + if (errcode) + lj_err_throw(L, errcode); /* Propagate errors. */ +} + +/* Finalize one userdata or cdata object from the mmudata list. */ +static void gc_finalize(lua_State *L) +{ + global_State *g = G(L); + GCobj *o = gcnext(gcref(g->gc.mmudata)); + cTValue *mo; + lua_assert(gcref(g->jit_L) == NULL); /* Must not be called on trace. */ + /* Unchain from list of userdata to be finalized. */ + if (o == gcref(g->gc.mmudata)) + setgcrefnull(g->gc.mmudata); + else + setgcrefr(gcref(g->gc.mmudata)->gch.nextgc, o->gch.nextgc); +#if LJ_HASFFI + if (o->gch.gct == ~LJ_TCDATA) { + TValue tmp, *tv; + /* Add cdata back to the GC list and make it white. */ + setgcrefr(o->gch.nextgc, g->gc.root); + setgcref(g->gc.root, o); + makewhite(g, o); + o->gch.marked &= (uint8_t)~LJ_GC_CDATA_FIN; + /* Resolve finalizer. */ + setcdataV(L, &tmp, gco2cd(o)); + tv = lj_tab_set(L, ctype_ctsG(g)->finalizer, &tmp); + if (!tvisnil(tv)) { + g->gc.nocdatafin = 0; + copyTV(L, &tmp, tv); + setnilV(tv); /* Clear entry in finalizer table. */ + gc_call_finalizer(g, L, &tmp, o); + } + return; + } +#endif + /* Add userdata back to the main userdata list and make it white. */ + setgcrefr(o->gch.nextgc, mainthread(g)->nextgc); + setgcref(mainthread(g)->nextgc, o); + makewhite(g, o); + /* Resolve the __gc metamethod. */ + mo = lj_meta_fastg(g, tabref(gco2ud(o)->metatable), MM_gc); + if (mo) + gc_call_finalizer(g, L, mo, o); +} + +/* Finalize all userdata objects from mmudata list. */ +void lj_gc_finalize_udata(lua_State *L) +{ + while (gcref(G(L)->gc.mmudata) != NULL) + gc_finalize(L); +} + +#if LJ_HASFFI +/* Finalize all cdata objects from finalizer table. */ +void lj_gc_finalize_cdata(lua_State *L) +{ + global_State *g = G(L); + CTState *cts = ctype_ctsG(g); + if (cts) { + GCtab *t = cts->finalizer; + Node *node = noderef(t->node); + ptrdiff_t i; + setgcrefnull(t->metatable); /* Mark finalizer table as disabled. */ + for (i = (ptrdiff_t)t->hmask; i >= 0; i--) + if (!tvisnil(&node[i].val) && tviscdata(&node[i].key)) { + GCobj *o = gcV(&node[i].key); + TValue tmp; + makewhite(g, o); + o->gch.marked &= (uint8_t)~LJ_GC_CDATA_FIN; + copyTV(L, &tmp, &node[i].val); + setnilV(&node[i].val); + gc_call_finalizer(g, L, &tmp, o); + } + } +} +#endif + +/* Free all remaining GC objects. */ +void lj_gc_freeall(global_State *g) +{ + MSize i, strmask; + /* Free everything, except super-fixed objects (the main thread). */ + g->gc.currentwhite = LJ_GC_WHITES | LJ_GC_SFIXED; + gc_fullsweep(g, &g->gc.root); + strmask = g->strmask; + for (i = 0; i <= strmask; i++) /* Free all string hash chains. */ + gc_fullsweep(g, &g->strhash[i]); +} + +/* -- Collector ----------------------------------------------------------- */ + +/* Atomic part of the GC cycle, transitioning from mark to sweep phase. */ +static void atomic(global_State *g, lua_State *L) +{ + size_t udsize; + + gc_mark_uv(g); /* Need to remark open upvalues (the thread may be dead). */ + gc_propagate_gray(g); /* Propagate any left-overs. */ + + setgcrefr(g->gc.gray, g->gc.weak); /* Empty the list of weak tables. */ + setgcrefnull(g->gc.weak); + lua_assert(!iswhite(obj2gco(mainthread(g)))); + gc_markobj(g, L); /* Mark running thread. */ + gc_traverse_curtrace(g); /* Traverse current trace. */ + gc_mark_gcroot(g); /* Mark GC roots (again). */ + gc_propagate_gray(g); /* Propagate all of the above. */ + + setgcrefr(g->gc.gray, g->gc.grayagain); /* Empty the 2nd chance list. */ + setgcrefnull(g->gc.grayagain); + gc_propagate_gray(g); /* Propagate it. */ + + udsize = lj_gc_separateudata(g, 0); /* Separate userdata to be finalized. */ + gc_mark_mmudata(g); /* Mark them. */ + udsize += gc_propagate_gray(g); /* And propagate the marks. */ + + /* All marking done, clear weak tables. */ + gc_clearweak(gcref(g->gc.weak)); + + /* Prepare for sweep phase. */ + g->gc.currentwhite = (uint8_t)otherwhite(g); /* Flip current white. */ + g->strempty.marked = g->gc.currentwhite; + setmref(g->gc.sweep, &g->gc.root); + g->gc.estimate = g->gc.total - (MSize)udsize; /* Initial estimate. */ +} + +/* GC state machine. Returns a cost estimate for each step performed. */ +static size_t gc_onestep(lua_State *L) +{ + global_State *g = G(L); + switch (g->gc.state) { + case GCSpause: + gc_mark_start(g); /* Start a new GC cycle by marking all GC roots. */ + return 0; + case GCSpropagate: + if (gcref(g->gc.gray) != NULL) + return propagatemark(g); /* Propagate one gray object. */ + g->gc.state = GCSatomic; /* End of mark phase. */ + return 0; + case GCSatomic: + if (gcref(g->jit_L)) /* Don't run atomic phase on trace. */ + return LJ_MAX_MEM; + atomic(g, L); + g->gc.state = GCSsweepstring; /* Start of sweep phase. */ + g->gc.sweepstr = 0; + return 0; + case GCSsweepstring: { + MSize old = g->gc.total; + gc_fullsweep(g, &g->strhash[g->gc.sweepstr++]); /* Sweep one chain. */ + if (g->gc.sweepstr > g->strmask) + g->gc.state = GCSsweep; /* All string hash chains sweeped. */ + lua_assert(old >= g->gc.total); + g->gc.estimate -= old - g->gc.total; + return GCSWEEPCOST; + } + case GCSsweep: { + MSize old = g->gc.total; + setmref(g->gc.sweep, gc_sweep(g, mref(g->gc.sweep, GCRef), GCSWEEPMAX)); + lua_assert(old >= g->gc.total); + g->gc.estimate -= old - g->gc.total; + if (gcref(*mref(g->gc.sweep, GCRef)) == NULL) { + gc_shrink(g, L); + if (gcref(g->gc.mmudata)) { /* Need any finalizations? */ + g->gc.state = GCSfinalize; +#if LJ_HASFFI + g->gc.nocdatafin = 1; +#endif + } else { /* Otherwise skip this phase to help the JIT. */ + g->gc.state = GCSpause; /* End of GC cycle. */ + g->gc.debt = 0; + } + } + return GCSWEEPMAX*GCSWEEPCOST; + } + case GCSfinalize: + if (gcref(g->gc.mmudata) != NULL) { + if (gcref(g->jit_L)) /* Don't call finalizers on trace. */ + return LJ_MAX_MEM; + gc_finalize(L); /* Finalize one userdata object. */ + if (g->gc.estimate > GCFINALIZECOST) + g->gc.estimate -= GCFINALIZECOST; + return GCFINALIZECOST; + } +#if LJ_HASFFI + if (!g->gc.nocdatafin) lj_tab_rehash(L, ctype_ctsG(g)->finalizer); +#endif + g->gc.state = GCSpause; /* End of GC cycle. */ + g->gc.debt = 0; + return 0; + default: + lua_assert(0); + return 0; + } +} + +/* Perform a limited amount of incremental GC steps. */ +int LJ_FASTCALL lj_gc_step(lua_State *L) +{ + global_State *g = G(L); + MSize lim; + int32_t ostate = g->vmstate; + setvmstate(g, GC); + lim = (GCSTEPSIZE/100) * g->gc.stepmul; + if (lim == 0) + lim = LJ_MAX_MEM; + if (g->gc.total > g->gc.threshold) + g->gc.debt += g->gc.total - g->gc.threshold; + do { + lim -= (MSize)gc_onestep(L); + if (g->gc.state == GCSpause) { + g->gc.threshold = (g->gc.estimate/100) * g->gc.pause; + g->vmstate = ostate; + return 1; /* Finished a GC cycle. */ + } + } while ((int32_t)lim > 0); + if (g->gc.debt < GCSTEPSIZE) { + g->gc.threshold = g->gc.total + GCSTEPSIZE; + g->vmstate = ostate; + return -1; + } else { + g->gc.debt -= GCSTEPSIZE; + g->gc.threshold = g->gc.total; + g->vmstate = ostate; + return 0; + } +} + +/* Ditto, but fix the stack top first. */ +void LJ_FASTCALL lj_gc_step_fixtop(lua_State *L) +{ + if (curr_funcisL(L)) L->top = curr_topL(L); + lj_gc_step(L); +} + +#if LJ_HASJIT +/* Perform multiple GC steps. Called from JIT-compiled code. */ +int LJ_FASTCALL lj_gc_step_jit(global_State *g, MSize steps) +{ + lua_State *L = gco2th(gcref(g->jit_L)); + L->base = mref(G(L)->jit_base, TValue); + L->top = curr_topL(L); + while (steps-- > 0 && lj_gc_step(L) == 0) + ; + /* Return 1 to force a trace exit. */ + return (G(L)->gc.state == GCSatomic || G(L)->gc.state == GCSfinalize); +} +#endif + +/* Perform a full GC cycle. */ +void lj_gc_fullgc(lua_State *L) +{ + global_State *g = G(L); + int32_t ostate = g->vmstate; + setvmstate(g, GC); + if (g->gc.state <= GCSatomic) { /* Caught somewhere in the middle. */ + setmref(g->gc.sweep, &g->gc.root); /* Sweep everything (preserving it). */ + setgcrefnull(g->gc.gray); /* Reset lists from partial propagation. */ + setgcrefnull(g->gc.grayagain); + setgcrefnull(g->gc.weak); + g->gc.state = GCSsweepstring; /* Fast forward to the sweep phase. */ + g->gc.sweepstr = 0; + } + while (g->gc.state == GCSsweepstring || g->gc.state == GCSsweep) + gc_onestep(L); /* Finish sweep. */ + lua_assert(g->gc.state == GCSfinalize || g->gc.state == GCSpause); + /* Now perform a full GC. */ + g->gc.state = GCSpause; + do { gc_onestep(L); } while (g->gc.state != GCSpause); + g->gc.threshold = (g->gc.estimate/100) * g->gc.pause; + g->vmstate = ostate; +} + +/* -- Write barriers ------------------------------------------------------ */ + +/* Move the GC propagation frontier forward. */ +void lj_gc_barrierf(global_State *g, GCobj *o, GCobj *v) +{ + lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); + lua_assert(g->gc.state != GCSfinalize && g->gc.state != GCSpause); + lua_assert(o->gch.gct != ~LJ_TTAB); + /* Preserve invariant during propagation. Otherwise it doesn't matter. */ + if (g->gc.state == GCSpropagate || g->gc.state == GCSatomic) + gc_mark(g, v); /* Move frontier forward. */ + else + makewhite(g, o); /* Make it white to avoid the following barrier. */ +} + +/* Specialized barrier for closed upvalue. Pass &uv->tv. */ +void LJ_FASTCALL lj_gc_barrieruv(global_State *g, TValue *tv) +{ +#define TV2MARKED(x) \ + (*((uint8_t *)(x) - offsetof(GCupval, tv) + offsetof(GCupval, marked))) + if (g->gc.state == GCSpropagate || g->gc.state == GCSatomic) + gc_mark(g, gcV(tv)); + else + TV2MARKED(tv) = (TV2MARKED(tv) & (uint8_t)~LJ_GC_COLORS) | curwhite(g); +#undef TV2MARKED +} + +/* Close upvalue. Also needs a write barrier. */ +void lj_gc_closeuv(global_State *g, GCupval *uv) +{ + GCobj *o = obj2gco(uv); + /* Copy stack slot to upvalue itself and point to the copy. */ + copyTV(mainthread(g), &uv->tv, uvval(uv)); + setmref(uv->v, &uv->tv); + uv->closed = 1; + setgcrefr(o->gch.nextgc, g->gc.root); + setgcref(g->gc.root, o); + if (isgray(o)) { /* A closed upvalue is never gray, so fix this. */ + if (g->gc.state == GCSpropagate || g->gc.state == GCSatomic) { + gray2black(o); /* Make it black and preserve invariant. */ + if (tviswhite(&uv->tv)) + lj_gc_barrierf(g, o, gcV(&uv->tv)); + } else { + makewhite(g, o); /* Make it white, i.e. sweep the upvalue. */ + lua_assert(g->gc.state != GCSfinalize && g->gc.state != GCSpause); + } + } +} + +#if LJ_HASJIT +/* Mark a trace if it's saved during the propagation phase. */ +void lj_gc_barriertrace(global_State *g, uint32_t traceno) +{ + if (g->gc.state == GCSpropagate || g->gc.state == GCSatomic) + gc_marktrace(g, traceno); +} +#endif + +/* -- Allocator ----------------------------------------------------------- */ + +/* Call pluggable memory allocator to allocate or resize a fragment. */ +void *lj_mem_realloc(lua_State *L, void *p, MSize osz, MSize nsz) +{ + global_State *g = G(L); + lua_assert((osz == 0) == (p == NULL)); + p = g->allocf(g->allocd, p, osz, nsz); + if (p == NULL && nsz > 0) + lj_err_mem(L); + lua_assert((nsz == 0) == (p == NULL)); + lua_assert(checkptr32(p)); + g->gc.total = (g->gc.total - osz) + nsz; + return p; +} + +/* Allocate new GC object and link it to the root set. */ +void * LJ_FASTCALL lj_mem_newgco(lua_State *L, MSize size) +{ + global_State *g = G(L); + GCobj *o = (GCobj *)g->allocf(g->allocd, NULL, 0, size); + if (o == NULL) + lj_err_mem(L); + lua_assert(checkptr32(o)); + g->gc.total += size; + setgcrefr(o->gch.nextgc, g->gc.root); + setgcref(g->gc.root, o); + newwhite(g, o); + return o; +} + +/* Resize growable vector. */ +void *lj_mem_grow(lua_State *L, void *p, MSize *szp, MSize lim, MSize esz) +{ + MSize sz = (*szp) << 1; + if (sz < LJ_MIN_VECSZ) + sz = LJ_MIN_VECSZ; + if (sz > lim) + sz = lim; + p = lj_mem_realloc(L, p, (*szp)*esz, sz*esz); + *szp = sz; + return p; +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_gc.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_gc.h new file mode 100644 index 000000000..ba061bc5d --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_gc.h @@ -0,0 +1,134 @@ +/* +** Garbage collector. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_GC_H +#define _LJ_GC_H + +#include "lj_obj.h" + +/* Garbage collector states. Order matters. */ +enum { + GCSpause, GCSpropagate, GCSatomic, GCSsweepstring, GCSsweep, GCSfinalize +}; + +/* Bitmasks for marked field of GCobj. */ +#define LJ_GC_WHITE0 0x01 +#define LJ_GC_WHITE1 0x02 +#define LJ_GC_BLACK 0x04 +#define LJ_GC_FINALIZED 0x08 +#define LJ_GC_WEAKKEY 0x08 +#define LJ_GC_WEAKVAL 0x10 +#define LJ_GC_CDATA_FIN 0x10 +#define LJ_GC_FIXED 0x20 +#define LJ_GC_SFIXED 0x40 + +#define LJ_GC_WHITES (LJ_GC_WHITE0 | LJ_GC_WHITE1) +#define LJ_GC_COLORS (LJ_GC_WHITES | LJ_GC_BLACK) +#define LJ_GC_WEAK (LJ_GC_WEAKKEY | LJ_GC_WEAKVAL) + +/* Macros to test and set GCobj colors. */ +#define iswhite(x) ((x)->gch.marked & LJ_GC_WHITES) +#define isblack(x) ((x)->gch.marked & LJ_GC_BLACK) +#define isgray(x) (!((x)->gch.marked & (LJ_GC_BLACK|LJ_GC_WHITES))) +#define tviswhite(x) (tvisgcv(x) && iswhite(gcV(x))) +#define otherwhite(g) (g->gc.currentwhite ^ LJ_GC_WHITES) +#define isdead(g, v) ((v)->gch.marked & otherwhite(g) & LJ_GC_WHITES) + +#define curwhite(g) ((g)->gc.currentwhite & LJ_GC_WHITES) +#define newwhite(g, x) (obj2gco(x)->gch.marked = (uint8_t)curwhite(g)) +#define makewhite(g, x) \ + ((x)->gch.marked = ((x)->gch.marked & (uint8_t)~LJ_GC_COLORS) | curwhite(g)) +#define flipwhite(x) ((x)->gch.marked ^= LJ_GC_WHITES) +#define black2gray(x) ((x)->gch.marked &= (uint8_t)~LJ_GC_BLACK) +#define fixstring(s) ((s)->marked |= LJ_GC_FIXED) +#define markfinalized(x) ((x)->gch.marked |= LJ_GC_FINALIZED) + +/* Collector. */ +LJ_FUNC size_t lj_gc_separateudata(global_State *g, int all); +LJ_FUNC void lj_gc_finalize_udata(lua_State *L); +#if LJ_HASFFI +LJ_FUNC void lj_gc_finalize_cdata(lua_State *L); +#else +#define lj_gc_finalize_cdata(L) UNUSED(L) +#endif +LJ_FUNC void lj_gc_freeall(global_State *g); +LJ_FUNCA int LJ_FASTCALL lj_gc_step(lua_State *L); +LJ_FUNCA void LJ_FASTCALL lj_gc_step_fixtop(lua_State *L); +#if LJ_HASJIT +LJ_FUNC int LJ_FASTCALL lj_gc_step_jit(global_State *g, MSize steps); +#endif +LJ_FUNC void lj_gc_fullgc(lua_State *L); + +/* GC check: drive collector forward if the GC threshold has been reached. */ +#define lj_gc_check(L) \ + { if (LJ_UNLIKELY(G(L)->gc.total >= G(L)->gc.threshold)) \ + lj_gc_step(L); } +#define lj_gc_check_fixtop(L) \ + { if (LJ_UNLIKELY(G(L)->gc.total >= G(L)->gc.threshold)) \ + lj_gc_step_fixtop(L); } + +/* Write barriers. */ +LJ_FUNC void lj_gc_barrierf(global_State *g, GCobj *o, GCobj *v); +LJ_FUNCA void LJ_FASTCALL lj_gc_barrieruv(global_State *g, TValue *tv); +LJ_FUNC void lj_gc_closeuv(global_State *g, GCupval *uv); +#if LJ_HASJIT +LJ_FUNC void lj_gc_barriertrace(global_State *g, uint32_t traceno); +#endif + +/* Move the GC propagation frontier back for tables (make it gray again). */ +static LJ_AINLINE void lj_gc_barrierback(global_State *g, GCtab *t) +{ + GCobj *o = obj2gco(t); + lua_assert(isblack(o) && !isdead(g, o)); + lua_assert(g->gc.state != GCSfinalize && g->gc.state != GCSpause); + black2gray(o); + setgcrefr(t->gclist, g->gc.grayagain); + setgcref(g->gc.grayagain, o); +} + +/* Barrier for stores to table objects. TValue and GCobj variant. */ +#define lj_gc_anybarriert(L, t) \ + { if (LJ_UNLIKELY(isblack(obj2gco(t)))) lj_gc_barrierback(G(L), (t)); } +#define lj_gc_barriert(L, t, tv) \ + { if (tviswhite(tv) && isblack(obj2gco(t))) \ + lj_gc_barrierback(G(L), (t)); } +#define lj_gc_objbarriert(L, t, o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) \ + lj_gc_barrierback(G(L), (t)); } + +/* Barrier for stores to any other object. TValue and GCobj variant. */ +#define lj_gc_barrier(L, p, tv) \ + { if (tviswhite(tv) && isblack(obj2gco(p))) \ + lj_gc_barrierf(G(L), obj2gco(p), gcV(tv)); } +#define lj_gc_objbarrier(L, p, o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ + lj_gc_barrierf(G(L), obj2gco(p), obj2gco(o)); } + +/* Allocator. */ +LJ_FUNC void *lj_mem_realloc(lua_State *L, void *p, MSize osz, MSize nsz); +LJ_FUNC void * LJ_FASTCALL lj_mem_newgco(lua_State *L, MSize size); +LJ_FUNC void *lj_mem_grow(lua_State *L, void *p, + MSize *szp, MSize lim, MSize esz); + +#define lj_mem_new(L, s) lj_mem_realloc(L, NULL, 0, (s)) + +static LJ_AINLINE void lj_mem_free(global_State *g, void *p, size_t osize) +{ + g->gc.total -= (MSize)osize; + g->allocf(g->allocd, p, osize, 0); +} + +#define lj_mem_newvec(L, n, t) ((t *)lj_mem_new(L, (MSize)((n)*sizeof(t)))) +#define lj_mem_reallocvec(L, p, on, n, t) \ + ((p) = (t *)lj_mem_realloc(L, p, (on)*sizeof(t), (MSize)((n)*sizeof(t)))) +#define lj_mem_growvec(L, p, n, m, t) \ + ((p) = (t *)lj_mem_grow(L, (p), &(n), (m), (MSize)sizeof(t))) +#define lj_mem_freevec(g, p, n, t) lj_mem_free(g, (p), (n)*sizeof(t)) + +#define lj_mem_newobj(L, t) ((t *)lj_mem_newgco(L, sizeof(t))) +#define lj_mem_newt(L, s, t) ((t *)lj_mem_new(L, (s))) +#define lj_mem_freet(g, p) lj_mem_free(g, (p), sizeof(*(p))) + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_gdbjit.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_gdbjit.c new file mode 100644 index 000000000..d3f3e6119 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_gdbjit.c @@ -0,0 +1,795 @@ +/* +** Client for the GDB JIT API. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_gdbjit_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_debug.h" +#include "lj_frame.h" +#include "lj_jit.h" +#include "lj_dispatch.h" + +/* This is not compiled in by default. +** Enable with -DLUAJIT_USE_GDBJIT in the Makefile and recompile everything. +*/ +#ifdef LUAJIT_USE_GDBJIT + +/* The GDB JIT API allows JIT compilers to pass debug information about +** JIT-compiled code back to GDB. You need at least GDB 7.0 or higher +** to see it in action. +** +** This is a passive API, so it works even when not running under GDB +** or when attaching to an already running process. Alas, this implies +** enabling it always has a non-negligible overhead -- do not use in +** release mode! +** +** The LuaJIT GDB JIT client is rather minimal at the moment. It gives +** each trace a symbol name and adds a source location and frame unwind +** information. Obviously LuaJIT itself and any embedding C application +** should be compiled with debug symbols, too (see the Makefile). +** +** Traces are named TRACE_1, TRACE_2, ... these correspond to the trace +** numbers from -jv or -jdump. Use "break TRACE_1" or "tbreak TRACE_1" etc. +** to set breakpoints on specific traces (even ahead of their creation). +** +** The source location for each trace allows listing the corresponding +** source lines with the GDB command "list" (but only if the Lua source +** has been loaded from a file). Currently this is always set to the +** location where the trace has been started. +** +** Frame unwind information can be inspected with the GDB command +** "info frame". This also allows proper backtraces across JIT-compiled +** code with the GDB command "bt". +** +** You probably want to add the following settings to a .gdbinit file +** (or add them to ~/.gdbinit): +** set disassembly-flavor intel +** set breakpoint pending on +** +** Here's a sample GDB session: +** ------------------------------------------------------------------------ + +$ cat >x.lua +for outer=1,100 do + for inner=1,100 do end +end +^D + +$ luajit -jv x.lua +[TRACE 1 x.lua:2] +[TRACE 2 (1/3) x.lua:1 -> 1] + +$ gdb --quiet --args luajit x.lua +(gdb) tbreak TRACE_1 +Function "TRACE_1" not defined. +Temporary breakpoint 1 (TRACE_1) pending. +(gdb) run +Starting program: luajit x.lua + +Temporary breakpoint 1, TRACE_1 () at x.lua:2 +2 for inner=1,100 do end +(gdb) list +1 for outer=1,100 do +2 for inner=1,100 do end +3 end +(gdb) bt +#0 TRACE_1 () at x.lua:2 +#1 0x08053690 in lua_pcall [...] +[...] +#7 0x0806ff90 in main [...] +(gdb) disass TRACE_1 +Dump of assembler code for function TRACE_1: +0xf7fd9fba : mov DWORD PTR ds:0xf7e0e2a0,0x1 +0xf7fd9fc4 : movsd xmm7,QWORD PTR [edx+0x20] +[...] +0xf7fd9ff8 : jmp 0xf7fd2014 +End of assembler dump. +(gdb) tbreak TRACE_2 +Function "TRACE_2" not defined. +Temporary breakpoint 2 (TRACE_2) pending. +(gdb) cont +Continuing. + +Temporary breakpoint 2, TRACE_2 () at x.lua:1 +1 for outer=1,100 do +(gdb) info frame +Stack level 0, frame at 0xffffd7c0: + eip = 0xf7fd9f60 in TRACE_2 (x.lua:1); saved eip 0x8053690 + called by frame at 0xffffd7e0 + source language unknown. + Arglist at 0xffffd78c, args: + Locals at 0xffffd78c, Previous frame's sp is 0xffffd7c0 + Saved registers: + ebx at 0xffffd7ac, ebp at 0xffffd7b8, esi at 0xffffd7b0, edi at 0xffffd7b4, + eip at 0xffffd7bc +(gdb) + +** ------------------------------------------------------------------------ +*/ + +/* -- GDB JIT API --------------------------------------------------------- */ + +/* GDB JIT actions. */ +enum { + GDBJIT_NOACTION = 0, + GDBJIT_REGISTER, + GDBJIT_UNREGISTER +}; + +/* GDB JIT entry. */ +typedef struct GDBJITentry { + struct GDBJITentry *next_entry; + struct GDBJITentry *prev_entry; + const char *symfile_addr; + uint64_t symfile_size; +} GDBJITentry; + +/* GDB JIT descriptor. */ +typedef struct GDBJITdesc { + uint32_t version; + uint32_t action_flag; + GDBJITentry *relevant_entry; + GDBJITentry *first_entry; +} GDBJITdesc; + +GDBJITdesc __jit_debug_descriptor = { + 1, GDBJIT_NOACTION, NULL, NULL +}; + +/* GDB sets a breakpoint at this function. */ +void LJ_NOINLINE __jit_debug_register_code() +{ + __asm__ __volatile__(""); +}; + +/* -- In-memory ELF object definitions ------------------------------------ */ + +/* ELF definitions. */ +typedef struct ELFheader { + uint8_t emagic[4]; + uint8_t eclass; + uint8_t eendian; + uint8_t eversion; + uint8_t eosabi; + uint8_t eabiversion; + uint8_t epad[7]; + uint16_t type; + uint16_t machine; + uint32_t version; + uintptr_t entry; + uintptr_t phofs; + uintptr_t shofs; + uint32_t flags; + uint16_t ehsize; + uint16_t phentsize; + uint16_t phnum; + uint16_t shentsize; + uint16_t shnum; + uint16_t shstridx; +} ELFheader; + +typedef struct ELFsectheader { + uint32_t name; + uint32_t type; + uintptr_t flags; + uintptr_t addr; + uintptr_t ofs; + uintptr_t size; + uint32_t link; + uint32_t info; + uintptr_t align; + uintptr_t entsize; +} ELFsectheader; + +#define ELFSECT_IDX_ABS 0xfff1 + +enum { + ELFSECT_TYPE_PROGBITS = 1, + ELFSECT_TYPE_SYMTAB = 2, + ELFSECT_TYPE_STRTAB = 3, + ELFSECT_TYPE_NOBITS = 8 +}; + +#define ELFSECT_FLAGS_WRITE 1 +#define ELFSECT_FLAGS_ALLOC 2 +#define ELFSECT_FLAGS_EXEC 4 + +typedef struct ELFsymbol { +#if LJ_64 + uint32_t name; + uint8_t info; + uint8_t other; + uint16_t sectidx; + uintptr_t value; + uint64_t size; +#else + uint32_t name; + uintptr_t value; + uint32_t size; + uint8_t info; + uint8_t other; + uint16_t sectidx; +#endif +} ELFsymbol; + +enum { + ELFSYM_TYPE_FUNC = 2, + ELFSYM_TYPE_FILE = 4, + ELFSYM_BIND_LOCAL = 0 << 4, + ELFSYM_BIND_GLOBAL = 1 << 4, +}; + +/* DWARF definitions. */ +#define DW_CIE_VERSION 1 + +enum { + DW_CFA_nop = 0x0, + DW_CFA_offset_extended = 0x5, + DW_CFA_def_cfa = 0xc, + DW_CFA_def_cfa_offset = 0xe, + DW_CFA_offset_extended_sf = 0x11, + DW_CFA_advance_loc = 0x40, + DW_CFA_offset = 0x80 +}; + +enum { + DW_EH_PE_udata4 = 3, + DW_EH_PE_textrel = 0x20 +}; + +enum { + DW_TAG_compile_unit = 0x11 +}; + +enum { + DW_children_no = 0, + DW_children_yes = 1 +}; + +enum { + DW_AT_name = 0x03, + DW_AT_stmt_list = 0x10, + DW_AT_low_pc = 0x11, + DW_AT_high_pc = 0x12 +}; + +enum { + DW_FORM_addr = 0x01, + DW_FORM_data4 = 0x06, + DW_FORM_string = 0x08 +}; + +enum { + DW_LNS_extended_op = 0, + DW_LNS_copy = 1, + DW_LNS_advance_pc = 2, + DW_LNS_advance_line = 3 +}; + +enum { + DW_LNE_end_sequence = 1, + DW_LNE_set_address = 2 +}; + +enum { +#if LJ_TARGET_X86 + DW_REG_AX, DW_REG_CX, DW_REG_DX, DW_REG_BX, + DW_REG_SP, DW_REG_BP, DW_REG_SI, DW_REG_DI, + DW_REG_RA, +#elif LJ_TARGET_X64 + /* Yes, the order is strange, but correct. */ + DW_REG_AX, DW_REG_DX, DW_REG_CX, DW_REG_BX, + DW_REG_SI, DW_REG_DI, DW_REG_BP, DW_REG_SP, + DW_REG_8, DW_REG_9, DW_REG_10, DW_REG_11, + DW_REG_12, DW_REG_13, DW_REG_14, DW_REG_15, + DW_REG_RA, +#elif LJ_TARGET_ARM + DW_REG_SP = 13, + DW_REG_RA = 14, +#elif LJ_TARGET_PPC + DW_REG_SP = 1, + DW_REG_RA = 65, + DW_REG_CR = 70, +#elif LJ_TARGET_MIPS + DW_REG_SP = 29, + DW_REG_RA = 31, +#else +#error "Unsupported target architecture" +#endif +}; + +/* Minimal list of sections for the in-memory ELF object. */ +enum { + GDBJIT_SECT_NULL, + GDBJIT_SECT_text, + GDBJIT_SECT_eh_frame, + GDBJIT_SECT_shstrtab, + GDBJIT_SECT_strtab, + GDBJIT_SECT_symtab, + GDBJIT_SECT_debug_info, + GDBJIT_SECT_debug_abbrev, + GDBJIT_SECT_debug_line, + GDBJIT_SECT__MAX +}; + +enum { + GDBJIT_SYM_UNDEF, + GDBJIT_SYM_FILE, + GDBJIT_SYM_FUNC, + GDBJIT_SYM__MAX +}; + +/* In-memory ELF object. */ +typedef struct GDBJITobj { + ELFheader hdr; /* ELF header. */ + ELFsectheader sect[GDBJIT_SECT__MAX]; /* ELF sections. */ + ELFsymbol sym[GDBJIT_SYM__MAX]; /* ELF symbol table. */ + uint8_t space[4096]; /* Space for various section data. */ +} GDBJITobj; + +/* Combined structure for GDB JIT entry and ELF object. */ +typedef struct GDBJITentryobj { + GDBJITentry entry; + size_t sz; + GDBJITobj obj; +} GDBJITentryobj; + +/* Template for in-memory ELF header. */ +static const ELFheader elfhdr_template = { + .emagic = { 0x7f, 'E', 'L', 'F' }, + .eclass = LJ_64 ? 2 : 1, + .eendian = LJ_ENDIAN_SELECT(1, 2), + .eversion = 1, +#if LJ_TARGET_LINUX + .eosabi = 0, /* Nope, it's not 3. */ +#elif defined(__FreeBSD__) + .eosabi = 9, +#elif defined(__NetBSD__) + .eosabi = 2, +#elif defined(__OpenBSD__) + .eosabi = 12, +#elif defined(__DragonFly__) + .eosabi = 0, +#elif (defined(__sun__) && defined(__svr4__)) + .eosabi = 6, +#else + .eosabi = 0, +#endif + .eabiversion = 0, + .epad = { 0, 0, 0, 0, 0, 0, 0 }, + .type = 1, +#if LJ_TARGET_X86 + .machine = 3, +#elif LJ_TARGET_X64 + .machine = 62, +#elif LJ_TARGET_ARM + .machine = 40, +#elif LJ_TARGET_PPC + .machine = 20, +#elif LJ_TARGET_MIPS + .machine = 8, +#else +#error "Unsupported target architecture" +#endif + .version = 1, + .entry = 0, + .phofs = 0, + .shofs = offsetof(GDBJITobj, sect), + .flags = 0, + .ehsize = sizeof(ELFheader), + .phentsize = 0, + .phnum = 0, + .shentsize = sizeof(ELFsectheader), + .shnum = GDBJIT_SECT__MAX, + .shstridx = GDBJIT_SECT_shstrtab +}; + +/* -- In-memory ELF object generation ------------------------------------- */ + +/* Context for generating the ELF object for the GDB JIT API. */ +typedef struct GDBJITctx { + uint8_t *p; /* Pointer to next address in obj.space. */ + uint8_t *startp; /* Pointer to start address in obj.space. */ + GCtrace *T; /* Generate symbols for this trace. */ + uintptr_t mcaddr; /* Machine code address. */ + MSize szmcode; /* Size of machine code. */ + MSize spadjp; /* Stack adjustment for parent trace or interpreter. */ + MSize spadj; /* Stack adjustment for trace itself. */ + BCLine lineno; /* Starting line number. */ + const char *filename; /* Starting file name. */ + size_t objsize; /* Final size of ELF object. */ + GDBJITobj obj; /* In-memory ELF object. */ +} GDBJITctx; + +/* Add a zero-terminated string. */ +static uint32_t gdbjit_strz(GDBJITctx *ctx, const char *str) +{ + uint8_t *p = ctx->p; + uint32_t ofs = (uint32_t)(p - ctx->startp); + do { + *p++ = (uint8_t)*str; + } while (*str++); + ctx->p = p; + return ofs; +} + +/* Append a decimal number. */ +static void gdbjit_catnum(GDBJITctx *ctx, uint32_t n) +{ + if (n >= 10) { uint32_t m = n / 10; n = n % 10; gdbjit_catnum(ctx, m); } + *ctx->p++ = '0' + n; +} + +/* Add a ULEB128 value. */ +static void gdbjit_uleb128(GDBJITctx *ctx, uint32_t v) +{ + uint8_t *p = ctx->p; + for (; v >= 0x80; v >>= 7) + *p++ = (uint8_t)((v & 0x7f) | 0x80); + *p++ = (uint8_t)v; + ctx->p = p; +} + +/* Add a SLEB128 value. */ +static void gdbjit_sleb128(GDBJITctx *ctx, int32_t v) +{ + uint8_t *p = ctx->p; + for (; (uint32_t)(v+0x40) >= 0x80; v >>= 7) + *p++ = (uint8_t)((v & 0x7f) | 0x80); + *p++ = (uint8_t)(v & 0x7f); + ctx->p = p; +} + +/* Shortcuts to generate DWARF structures. */ +#define DB(x) (*p++ = (x)) +#define DI8(x) (*(int8_t *)p = (x), p++) +#define DU16(x) (*(uint16_t *)p = (x), p += 2) +#define DU32(x) (*(uint32_t *)p = (x), p += 4) +#define DADDR(x) (*(uintptr_t *)p = (x), p += sizeof(uintptr_t)) +#define DUV(x) (ctx->p = p, gdbjit_uleb128(ctx, (x)), p = ctx->p) +#define DSV(x) (ctx->p = p, gdbjit_sleb128(ctx, (x)), p = ctx->p) +#define DSTR(str) (ctx->p = p, gdbjit_strz(ctx, (str)), p = ctx->p) +#define DALIGNNOP(s) while ((uintptr_t)p & ((s)-1)) *p++ = DW_CFA_nop +#define DSECT(name, stmt) \ + { uint32_t *szp_##name = (uint32_t *)p; p += 4; stmt \ + *szp_##name = (uint32_t)((p-(uint8_t *)szp_##name)-4); } \ + +/* Initialize ELF section headers. */ +static void LJ_FASTCALL gdbjit_secthdr(GDBJITctx *ctx) +{ + ELFsectheader *sect; + + *ctx->p++ = '\0'; /* Empty string at start of string table. */ + +#define SECTDEF(id, tp, al) \ + sect = &ctx->obj.sect[GDBJIT_SECT_##id]; \ + sect->name = gdbjit_strz(ctx, "." #id); \ + sect->type = ELFSECT_TYPE_##tp; \ + sect->align = (al) + + SECTDEF(text, NOBITS, 16); + sect->flags = ELFSECT_FLAGS_ALLOC|ELFSECT_FLAGS_EXEC; + sect->addr = ctx->mcaddr; + sect->ofs = 0; + sect->size = ctx->szmcode; + + SECTDEF(eh_frame, PROGBITS, sizeof(uintptr_t)); + sect->flags = ELFSECT_FLAGS_ALLOC; + + SECTDEF(shstrtab, STRTAB, 1); + SECTDEF(strtab, STRTAB, 1); + + SECTDEF(symtab, SYMTAB, sizeof(uintptr_t)); + sect->ofs = offsetof(GDBJITobj, sym); + sect->size = sizeof(ctx->obj.sym); + sect->link = GDBJIT_SECT_strtab; + sect->entsize = sizeof(ELFsymbol); + sect->info = GDBJIT_SYM_FUNC; + + SECTDEF(debug_info, PROGBITS, 1); + SECTDEF(debug_abbrev, PROGBITS, 1); + SECTDEF(debug_line, PROGBITS, 1); + +#undef SECTDEF +} + +/* Initialize symbol table. */ +static void LJ_FASTCALL gdbjit_symtab(GDBJITctx *ctx) +{ + ELFsymbol *sym; + + *ctx->p++ = '\0'; /* Empty string at start of string table. */ + + sym = &ctx->obj.sym[GDBJIT_SYM_FILE]; + sym->name = gdbjit_strz(ctx, "JIT mcode"); + sym->sectidx = ELFSECT_IDX_ABS; + sym->info = ELFSYM_TYPE_FILE|ELFSYM_BIND_LOCAL; + + sym = &ctx->obj.sym[GDBJIT_SYM_FUNC]; + sym->name = gdbjit_strz(ctx, "TRACE_"); ctx->p--; + gdbjit_catnum(ctx, ctx->T->traceno); *ctx->p++ = '\0'; + sym->sectidx = GDBJIT_SECT_text; + sym->value = 0; + sym->size = ctx->szmcode; + sym->info = ELFSYM_TYPE_FUNC|ELFSYM_BIND_GLOBAL; +} + +/* Initialize .eh_frame section. */ +static void LJ_FASTCALL gdbjit_ehframe(GDBJITctx *ctx) +{ + uint8_t *p = ctx->p; + uint8_t *framep = p; + + /* Emit DWARF EH CIE. */ + DSECT(CIE, + DU32(0); /* Offset to CIE itself. */ + DB(DW_CIE_VERSION); + DSTR("zR"); /* Augmentation. */ + DUV(1); /* Code alignment factor. */ + DSV(-(int32_t)sizeof(uintptr_t)); /* Data alignment factor. */ + DB(DW_REG_RA); /* Return address register. */ + DB(1); DB(DW_EH_PE_textrel|DW_EH_PE_udata4); /* Augmentation data. */ + DB(DW_CFA_def_cfa); DUV(DW_REG_SP); DUV(sizeof(uintptr_t)); +#if LJ_TARGET_PPC + DB(DW_CFA_offset_extended_sf); DB(DW_REG_RA); DSV(-1); +#else + DB(DW_CFA_offset|DW_REG_RA); DUV(1); +#endif + DALIGNNOP(sizeof(uintptr_t)); + ) + + /* Emit DWARF EH FDE. */ + DSECT(FDE, + DU32((uint32_t)(p-framep)); /* Offset to CIE. */ + DU32(0); /* Machine code offset relative to .text. */ + DU32(ctx->szmcode); /* Machine code length. */ + DB(0); /* Augmentation data. */ + /* Registers saved in CFRAME. */ +#if LJ_TARGET_X86 + DB(DW_CFA_offset|DW_REG_BP); DUV(2); + DB(DW_CFA_offset|DW_REG_DI); DUV(3); + DB(DW_CFA_offset|DW_REG_SI); DUV(4); + DB(DW_CFA_offset|DW_REG_BX); DUV(5); +#elif LJ_TARGET_X64 + DB(DW_CFA_offset|DW_REG_BP); DUV(2); + DB(DW_CFA_offset|DW_REG_BX); DUV(3); + DB(DW_CFA_offset|DW_REG_15); DUV(4); + DB(DW_CFA_offset|DW_REG_14); DUV(5); + /* Extra registers saved for JIT-compiled code. */ + DB(DW_CFA_offset|DW_REG_13); DUV(9); + DB(DW_CFA_offset|DW_REG_12); DUV(10); +#elif LJ_TARGET_ARM + { + int i; + for (i = 11; i >= 4; i--) { DB(DW_CFA_offset|i); DUV(2+(11-i)); } + } +#elif LJ_TARGET_PPC + { + int i; + DB(DW_CFA_offset_extended); DB(DW_REG_CR); DUV(55); + for (i = 14; i <= 31; i++) { + DB(DW_CFA_offset|i); DUV(37+(31-i)); + DB(DW_CFA_offset|32|i); DUV(2+2*(31-i)); + } + } +#elif LJ_TARGET_MIPS + { + int i; + DB(DW_CFA_offset|30); DUV(2); + for (i = 23; i >= 16; i--) { DB(DW_CFA_offset|i); DUV(26-i); } + for (i = 30; i >= 20; i -= 2) { DB(DW_CFA_offset|32|i); DUV(42-i); } + } +#else +#error "Unsupported target architecture" +#endif + if (ctx->spadjp != ctx->spadj) { /* Parent/interpreter stack frame size. */ + DB(DW_CFA_def_cfa_offset); DUV(ctx->spadjp); + DB(DW_CFA_advance_loc|1); /* Only an approximation. */ + } + DB(DW_CFA_def_cfa_offset); DUV(ctx->spadj); /* Trace stack frame size. */ + DALIGNNOP(sizeof(uintptr_t)); + ) + + ctx->p = p; +} + +/* Initialize .debug_info section. */ +static void LJ_FASTCALL gdbjit_debuginfo(GDBJITctx *ctx) +{ + uint8_t *p = ctx->p; + + DSECT(info, + DU16(2); /* DWARF version. */ + DU32(0); /* Abbrev offset. */ + DB(sizeof(uintptr_t)); /* Pointer size. */ + + DUV(1); /* Abbrev #1: DW_TAG_compile_unit. */ + DSTR(ctx->filename); /* DW_AT_name. */ + DADDR(ctx->mcaddr); /* DW_AT_low_pc. */ + DADDR(ctx->mcaddr + ctx->szmcode); /* DW_AT_high_pc. */ + DU32(0); /* DW_AT_stmt_list. */ + ) + + ctx->p = p; +} + +/* Initialize .debug_abbrev section. */ +static void LJ_FASTCALL gdbjit_debugabbrev(GDBJITctx *ctx) +{ + uint8_t *p = ctx->p; + + /* Abbrev #1: DW_TAG_compile_unit. */ + DUV(1); DUV(DW_TAG_compile_unit); + DB(DW_children_no); + DUV(DW_AT_name); DUV(DW_FORM_string); + DUV(DW_AT_low_pc); DUV(DW_FORM_addr); + DUV(DW_AT_high_pc); DUV(DW_FORM_addr); + DUV(DW_AT_stmt_list); DUV(DW_FORM_data4); + DB(0); DB(0); + + ctx->p = p; +} + +#define DLNE(op, s) (DB(DW_LNS_extended_op), DUV(1+(s)), DB((op))) + +/* Initialize .debug_line section. */ +static void LJ_FASTCALL gdbjit_debugline(GDBJITctx *ctx) +{ + uint8_t *p = ctx->p; + + DSECT(line, + DU16(2); /* DWARF version. */ + DSECT(header, + DB(1); /* Minimum instruction length. */ + DB(1); /* is_stmt. */ + DI8(0); /* Line base for special opcodes. */ + DB(2); /* Line range for special opcodes. */ + DB(3+1); /* Opcode base at DW_LNS_advance_line+1. */ + DB(0); DB(1); DB(1); /* Standard opcode lengths. */ + /* Directory table. */ + DB(0); + /* File name table. */ + DSTR(ctx->filename); DUV(0); DUV(0); DUV(0); + DB(0); + ) + + DLNE(DW_LNE_set_address, sizeof(uintptr_t)); DADDR(ctx->mcaddr); + if (ctx->lineno) { + DB(DW_LNS_advance_line); DSV(ctx->lineno-1); + } + DB(DW_LNS_copy); + DB(DW_LNS_advance_pc); DUV(ctx->szmcode); + DLNE(DW_LNE_end_sequence, 0); + ) + + ctx->p = p; +} + +#undef DLNE + +/* Undef shortcuts. */ +#undef DB +#undef DI8 +#undef DU16 +#undef DU32 +#undef DADDR +#undef DUV +#undef DSV +#undef DSTR +#undef DALIGNNOP +#undef DSECT + +/* Type of a section initializer callback. */ +typedef void (LJ_FASTCALL *GDBJITinitf)(GDBJITctx *ctx); + +/* Call section initializer and set the section offset and size. */ +static void gdbjit_initsect(GDBJITctx *ctx, int sect, GDBJITinitf initf) +{ + ctx->startp = ctx->p; + ctx->obj.sect[sect].ofs = (uintptr_t)((char *)ctx->p - (char *)&ctx->obj); + initf(ctx); + ctx->obj.sect[sect].size = (uintptr_t)(ctx->p - ctx->startp); +} + +#define SECTALIGN(p, a) \ + ((p) = (uint8_t *)(((uintptr_t)(p) + ((a)-1)) & ~(uintptr_t)((a)-1))) + +/* Build in-memory ELF object. */ +static void gdbjit_buildobj(GDBJITctx *ctx) +{ + GDBJITobj *obj = &ctx->obj; + /* Fill in ELF header and clear structures. */ + memcpy(&obj->hdr, &elfhdr_template, sizeof(ELFheader)); + memset(&obj->sect, 0, sizeof(ELFsectheader)*GDBJIT_SECT__MAX); + memset(&obj->sym, 0, sizeof(ELFsymbol)*GDBJIT_SYM__MAX); + /* Initialize sections. */ + ctx->p = obj->space; + gdbjit_initsect(ctx, GDBJIT_SECT_shstrtab, gdbjit_secthdr); + gdbjit_initsect(ctx, GDBJIT_SECT_strtab, gdbjit_symtab); + gdbjit_initsect(ctx, GDBJIT_SECT_debug_info, gdbjit_debuginfo); + gdbjit_initsect(ctx, GDBJIT_SECT_debug_abbrev, gdbjit_debugabbrev); + gdbjit_initsect(ctx, GDBJIT_SECT_debug_line, gdbjit_debugline); + SECTALIGN(ctx->p, sizeof(uintptr_t)); + gdbjit_initsect(ctx, GDBJIT_SECT_eh_frame, gdbjit_ehframe); + ctx->objsize = (size_t)((char *)ctx->p - (char *)obj); + lua_assert(ctx->objsize < sizeof(GDBJITobj)); +} + +#undef SECTALIGN + +/* -- Interface to GDB JIT API -------------------------------------------- */ + +/* Add new entry to GDB JIT symbol chain. */ +static void gdbjit_newentry(lua_State *L, GDBJITctx *ctx) +{ + /* Allocate memory for GDB JIT entry and ELF object. */ + MSize sz = (MSize)(sizeof(GDBJITentryobj) - sizeof(GDBJITobj) + ctx->objsize); + GDBJITentryobj *eo = lj_mem_newt(L, sz, GDBJITentryobj); + memcpy(&eo->obj, &ctx->obj, ctx->objsize); /* Copy ELF object. */ + eo->sz = sz; + ctx->T->gdbjit_entry = (void *)eo; + /* Link new entry to chain and register it. */ + eo->entry.prev_entry = NULL; + eo->entry.next_entry = __jit_debug_descriptor.first_entry; + if (eo->entry.next_entry) + eo->entry.next_entry->prev_entry = &eo->entry; + eo->entry.symfile_addr = (const char *)&eo->obj; + eo->entry.symfile_size = ctx->objsize; + __jit_debug_descriptor.first_entry = &eo->entry; + __jit_debug_descriptor.relevant_entry = &eo->entry; + __jit_debug_descriptor.action_flag = GDBJIT_REGISTER; + __jit_debug_register_code(); +} + +/* Add debug info for newly compiled trace and notify GDB. */ +void lj_gdbjit_addtrace(jit_State *J, GCtrace *T) +{ + GDBJITctx ctx; + GCproto *pt = &gcref(T->startpt)->pt; + TraceNo parent = T->ir[REF_BASE].op1; + const BCIns *startpc = mref(T->startpc, const BCIns); + ctx.T = T; + ctx.mcaddr = (uintptr_t)T->mcode; + ctx.szmcode = T->szmcode; + ctx.spadjp = CFRAME_SIZE_JIT + + (MSize)(parent ? traceref(J, parent)->spadjust : 0); + ctx.spadj = CFRAME_SIZE_JIT + T->spadjust; + lua_assert(startpc >= proto_bc(pt) && startpc < proto_bc(pt) + pt->sizebc); + ctx.lineno = lj_debug_line(pt, proto_bcpos(pt, startpc)); + ctx.filename = proto_chunknamestr(pt); + if (*ctx.filename == '@' || *ctx.filename == '=') + ctx.filename++; + else + ctx.filename = "(string)"; + gdbjit_buildobj(&ctx); + gdbjit_newentry(J->L, &ctx); +} + +/* Delete debug info for trace and notify GDB. */ +void lj_gdbjit_deltrace(jit_State *J, GCtrace *T) +{ + GDBJITentryobj *eo = (GDBJITentryobj *)T->gdbjit_entry; + if (eo) { + if (eo->entry.prev_entry) + eo->entry.prev_entry->next_entry = eo->entry.next_entry; + else + __jit_debug_descriptor.first_entry = eo->entry.next_entry; + if (eo->entry.next_entry) + eo->entry.next_entry->prev_entry = eo->entry.prev_entry; + __jit_debug_descriptor.relevant_entry = &eo->entry; + __jit_debug_descriptor.action_flag = GDBJIT_UNREGISTER; + __jit_debug_register_code(); + lj_mem_free(J2G(J), eo, eo->sz); + } +} + +#endif +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_gdbjit.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_gdbjit.h new file mode 100644 index 000000000..49c586301 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_gdbjit.h @@ -0,0 +1,22 @@ +/* +** Client for the GDB JIT API. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_GDBJIT_H +#define _LJ_GDBJIT_H + +#include "lj_obj.h" +#include "lj_jit.h" + +#if LJ_HASJIT && defined(LUAJIT_USE_GDBJIT) + +LJ_FUNC void lj_gdbjit_addtrace(jit_State *J, GCtrace *T); +LJ_FUNC void lj_gdbjit_deltrace(jit_State *J, GCtrace *T); + +#else +#define lj_gdbjit_addtrace(J, T) UNUSED(T) +#define lj_gdbjit_deltrace(J, T) UNUSED(T) +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_ir.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ir.c new file mode 100644 index 000000000..439f3fc34 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ir.c @@ -0,0 +1,501 @@ +/* +** SSA IR (Intermediate Representation) emitter. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_ir_c +#define LUA_CORE + +/* For pointers to libc/libm functions. */ +#include +#include + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_gc.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_ircall.h" +#include "lj_iropt.h" +#include "lj_trace.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#include "lj_cdata.h" +#include "lj_carith.h" +#endif +#include "lj_vm.h" +#include "lj_strscan.h" +#include "lj_lib.h" + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) +#define fins (&J->fold.ins) + +/* Pass IR on to next optimization in chain (FOLD). */ +#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) + +/* -- IR tables ----------------------------------------------------------- */ + +/* IR instruction modes. */ +LJ_DATADEF const uint8_t lj_ir_mode[IR__MAX+1] = { +IRDEF(IRMODE) + 0 +}; + +/* IR type sizes. */ +LJ_DATADEF const uint8_t lj_ir_type_size[IRT__MAX+1] = { +#define IRTSIZE(name, size) size, +IRTDEF(IRTSIZE) +#undef IRTSIZE + 0 +}; + +/* C call info for CALL* instructions. */ +LJ_DATADEF const CCallInfo lj_ir_callinfo[] = { +#define IRCALLCI(cond, name, nargs, kind, type, flags) \ + { (ASMFunction)IRCALLCOND_##cond(name), \ + (nargs)|(CCI_CALL_##kind)|(IRT_##type<irbuf + J->irbotlim; + MSize szins = J->irtoplim - J->irbotlim; + if (szins) { + baseir = (IRIns *)lj_mem_realloc(J->L, baseir, szins*sizeof(IRIns), + 2*szins*sizeof(IRIns)); + J->irtoplim = J->irbotlim + 2*szins; + } else { + baseir = (IRIns *)lj_mem_realloc(J->L, NULL, 0, LJ_MIN_IRSZ*sizeof(IRIns)); + J->irbotlim = REF_BASE - LJ_MIN_IRSZ/4; + J->irtoplim = J->irbotlim + LJ_MIN_IRSZ; + } + J->cur.ir = J->irbuf = baseir - J->irbotlim; +} + +/* Grow IR buffer at the bottom or shift it up. */ +static void lj_ir_growbot(jit_State *J) +{ + IRIns *baseir = J->irbuf + J->irbotlim; + MSize szins = J->irtoplim - J->irbotlim; + lua_assert(szins != 0); + lua_assert(J->cur.nk == J->irbotlim); + if (J->cur.nins + (szins >> 1) < J->irtoplim) { + /* More than half of the buffer is free on top: shift up by a quarter. */ + MSize ofs = szins >> 2; + memmove(baseir + ofs, baseir, (J->cur.nins - J->irbotlim)*sizeof(IRIns)); + J->irbotlim -= ofs; + J->irtoplim -= ofs; + J->cur.ir = J->irbuf = baseir - J->irbotlim; + } else { + /* Double the buffer size, but split the growth amongst top/bottom. */ + IRIns *newbase = lj_mem_newt(J->L, 2*szins*sizeof(IRIns), IRIns); + MSize ofs = szins >= 256 ? 128 : (szins >> 1); /* Limit bottom growth. */ + memcpy(newbase + ofs, baseir, (J->cur.nins - J->irbotlim)*sizeof(IRIns)); + lj_mem_free(G(J->L), baseir, szins*sizeof(IRIns)); + J->irbotlim -= ofs; + J->irtoplim = J->irbotlim + 2*szins; + J->cur.ir = J->irbuf = newbase - J->irbotlim; + } +} + +/* Emit IR without any optimizations. */ +TRef LJ_FASTCALL lj_ir_emit(jit_State *J) +{ + IRRef ref = lj_ir_nextins(J); + IRIns *ir = IR(ref); + IROp op = fins->o; + ir->prev = J->chain[op]; + J->chain[op] = (IRRef1)ref; + ir->o = op; + ir->op1 = fins->op1; + ir->op2 = fins->op2; + J->guardemit.irt |= fins->t.irt; + return TREF(ref, irt_t((ir->t = fins->t))); +} + +/* Emit call to a C function. */ +TRef lj_ir_call(jit_State *J, IRCallID id, ...) +{ + const CCallInfo *ci = &lj_ir_callinfo[id]; + uint32_t n = CCI_NARGS(ci); + TRef tr = TREF_NIL; + va_list argp; + va_start(argp, id); + if ((ci->flags & CCI_L)) n--; + if (n > 0) + tr = va_arg(argp, IRRef); + while (n-- > 1) + tr = emitir(IRT(IR_CARG, IRT_NIL), tr, va_arg(argp, IRRef)); + va_end(argp); + if (CCI_OP(ci) == IR_CALLS) + J->needsnap = 1; /* Need snapshot after call with side effect. */ + return emitir(CCI_OPTYPE(ci), tr, id); +} + +/* -- Interning of constants ---------------------------------------------- */ + +/* +** IR instructions for constants are kept between J->cur.nk >= ref < REF_BIAS. +** They are chained like all other instructions, but grow downwards. +** The are interned (like strings in the VM) to facilitate reference +** comparisons. The same constant must get the same reference. +*/ + +/* Get ref of next IR constant and optionally grow IR. +** Note: this may invalidate all IRIns *! +*/ +static LJ_AINLINE IRRef ir_nextk(jit_State *J) +{ + IRRef ref = J->cur.nk; + if (LJ_UNLIKELY(ref <= J->irbotlim)) lj_ir_growbot(J); + J->cur.nk = --ref; + return ref; +} + +/* Intern int32_t constant. */ +TRef LJ_FASTCALL lj_ir_kint(jit_State *J, int32_t k) +{ + IRIns *ir, *cir = J->cur.ir; + IRRef ref; + for (ref = J->chain[IR_KINT]; ref; ref = cir[ref].prev) + if (cir[ref].i == k) + goto found; + ref = ir_nextk(J); + ir = IR(ref); + ir->i = k; + ir->t.irt = IRT_INT; + ir->o = IR_KINT; + ir->prev = J->chain[IR_KINT]; + J->chain[IR_KINT] = (IRRef1)ref; +found: + return TREF(ref, IRT_INT); +} + +/* The MRef inside the KNUM/KINT64 IR instructions holds the address of the +** 64 bit constant. The constants themselves are stored in a chained array +** and shared across traces. +** +** Rationale for choosing this data structure: +** - The address of the constants is embedded in the generated machine code +** and must never move. A resizable array or hash table wouldn't work. +** - Most apps need very few non-32 bit integer constants (less than a dozen). +** - Linear search is hard to beat in terms of speed and low complexity. +*/ +typedef struct K64Array { + MRef next; /* Pointer to next list. */ + MSize numk; /* Number of used elements in this array. */ + TValue k[LJ_MIN_K64SZ]; /* Array of constants. */ +} K64Array; + +/* Free all chained arrays. */ +void lj_ir_k64_freeall(jit_State *J) +{ + K64Array *k; + for (k = mref(J->k64, K64Array); k; ) { + K64Array *next = mref(k->next, K64Array); + lj_mem_free(J2G(J), k, sizeof(K64Array)); + k = next; + } +} + +/* Find 64 bit constant in chained array or add it. */ +cTValue *lj_ir_k64_find(jit_State *J, uint64_t u64) +{ + K64Array *k, *kp = NULL; + TValue *ntv; + MSize idx; + /* Search for the constant in the whole chain of arrays. */ + for (k = mref(J->k64, K64Array); k; k = mref(k->next, K64Array)) { + kp = k; /* Remember previous element in list. */ + for (idx = 0; idx < k->numk; idx++) { /* Search one array. */ + TValue *tv = &k->k[idx]; + if (tv->u64 == u64) /* Needed for +-0/NaN/absmask. */ + return tv; + } + } + /* Constant was not found, need to add it. */ + if (!(kp && kp->numk < LJ_MIN_K64SZ)) { /* Allocate a new array. */ + K64Array *kn = lj_mem_newt(J->L, sizeof(K64Array), K64Array); + setmref(kn->next, NULL); + kn->numk = 0; + if (kp) + setmref(kp->next, kn); /* Chain to the end of the list. */ + else + setmref(J->k64, kn); /* Link first array. */ + kp = kn; + } + ntv = &kp->k[kp->numk++]; /* Add to current array. */ + ntv->u64 = u64; + return ntv; +} + +/* Intern 64 bit constant, given by its address. */ +TRef lj_ir_k64(jit_State *J, IROp op, cTValue *tv) +{ + IRIns *ir, *cir = J->cur.ir; + IRRef ref; + IRType t = op == IR_KNUM ? IRT_NUM : IRT_I64; + for (ref = J->chain[op]; ref; ref = cir[ref].prev) + if (ir_k64(&cir[ref]) == tv) + goto found; + ref = ir_nextk(J); + ir = IR(ref); + lua_assert(checkptr32(tv)); + setmref(ir->ptr, tv); + ir->t.irt = t; + ir->o = op; + ir->prev = J->chain[op]; + J->chain[op] = (IRRef1)ref; +found: + return TREF(ref, t); +} + +/* Intern FP constant, given by its 64 bit pattern. */ +TRef lj_ir_knum_u64(jit_State *J, uint64_t u64) +{ + return lj_ir_k64(J, IR_KNUM, lj_ir_k64_find(J, u64)); +} + +/* Intern 64 bit integer constant. */ +TRef lj_ir_kint64(jit_State *J, uint64_t u64) +{ + return lj_ir_k64(J, IR_KINT64, lj_ir_k64_find(J, u64)); +} + +/* Check whether a number is int and return it. -0 is NOT considered an int. */ +static int numistrueint(lua_Number n, int32_t *kp) +{ + int32_t k = lj_num2int(n); + if (n == (lua_Number)k) { + if (kp) *kp = k; + if (k == 0) { /* Special check for -0. */ + TValue tv; + setnumV(&tv, n); + if (tv.u32.hi != 0) + return 0; + } + return 1; + } + return 0; +} + +/* Intern number as int32_t constant if possible, otherwise as FP constant. */ +TRef lj_ir_knumint(jit_State *J, lua_Number n) +{ + int32_t k; + if (numistrueint(n, &k)) + return lj_ir_kint(J, k); + else + return lj_ir_knum(J, n); +} + +/* Intern GC object "constant". */ +TRef lj_ir_kgc(jit_State *J, GCobj *o, IRType t) +{ + IRIns *ir, *cir = J->cur.ir; + IRRef ref; + lua_assert(!isdead(J2G(J), o)); + for (ref = J->chain[IR_KGC]; ref; ref = cir[ref].prev) + if (ir_kgc(&cir[ref]) == o) + goto found; + ref = ir_nextk(J); + ir = IR(ref); + /* NOBARRIER: Current trace is a GC root. */ + setgcref(ir->gcr, o); + ir->t.irt = (uint8_t)t; + ir->o = IR_KGC; + ir->prev = J->chain[IR_KGC]; + J->chain[IR_KGC] = (IRRef1)ref; +found: + return TREF(ref, t); +} + +/* Intern 32 bit pointer constant. */ +TRef lj_ir_kptr_(jit_State *J, IROp op, void *ptr) +{ + IRIns *ir, *cir = J->cur.ir; + IRRef ref; + lua_assert((void *)(intptr_t)i32ptr(ptr) == ptr); + for (ref = J->chain[op]; ref; ref = cir[ref].prev) + if (mref(cir[ref].ptr, void) == ptr) + goto found; + ref = ir_nextk(J); + ir = IR(ref); + setmref(ir->ptr, ptr); + ir->t.irt = IRT_P32; + ir->o = op; + ir->prev = J->chain[op]; + J->chain[op] = (IRRef1)ref; +found: + return TREF(ref, IRT_P32); +} + +/* Intern typed NULL constant. */ +TRef lj_ir_knull(jit_State *J, IRType t) +{ + IRIns *ir, *cir = J->cur.ir; + IRRef ref; + for (ref = J->chain[IR_KNULL]; ref; ref = cir[ref].prev) + if (irt_t(cir[ref].t) == t) + goto found; + ref = ir_nextk(J); + ir = IR(ref); + ir->i = 0; + ir->t.irt = (uint8_t)t; + ir->o = IR_KNULL; + ir->prev = J->chain[IR_KNULL]; + J->chain[IR_KNULL] = (IRRef1)ref; +found: + return TREF(ref, t); +} + +/* Intern key slot. */ +TRef lj_ir_kslot(jit_State *J, TRef key, IRRef slot) +{ + IRIns *ir, *cir = J->cur.ir; + IRRef2 op12 = IRREF2((IRRef1)key, (IRRef1)slot); + IRRef ref; + /* Const part is not touched by CSE/DCE, so 0-65535 is ok for IRMlit here. */ + lua_assert(tref_isk(key) && slot == (IRRef)(IRRef1)slot); + for (ref = J->chain[IR_KSLOT]; ref; ref = cir[ref].prev) + if (cir[ref].op12 == op12) + goto found; + ref = ir_nextk(J); + ir = IR(ref); + ir->op12 = op12; + ir->t.irt = IRT_P32; + ir->o = IR_KSLOT; + ir->prev = J->chain[IR_KSLOT]; + J->chain[IR_KSLOT] = (IRRef1)ref; +found: + return TREF(ref, IRT_P32); +} + +/* -- Access to IR constants ---------------------------------------------- */ + +/* Copy value of IR constant. */ +void lj_ir_kvalue(lua_State *L, TValue *tv, const IRIns *ir) +{ + UNUSED(L); + lua_assert(ir->o != IR_KSLOT); /* Common mistake. */ + switch (ir->o) { + case IR_KPRI: setitype(tv, irt_toitype(ir->t)); break; + case IR_KINT: setintV(tv, ir->i); break; + case IR_KGC: setgcV(L, tv, ir_kgc(ir), irt_toitype(ir->t)); break; + case IR_KPTR: case IR_KKPTR: case IR_KNULL: + setlightudV(tv, mref(ir->ptr, void)); + break; + case IR_KNUM: setnumV(tv, ir_knum(ir)->n); break; +#if LJ_HASFFI + case IR_KINT64: { + GCcdata *cd = lj_cdata_new_(L, CTID_INT64, 8); + *(uint64_t *)cdataptr(cd) = ir_kint64(ir)->u64; + setcdataV(L, tv, cd); + break; + } +#endif + default: lua_assert(0); break; + } +} + +/* -- Convert IR operand types -------------------------------------------- */ + +/* Convert from string to number. */ +TRef LJ_FASTCALL lj_ir_tonumber(jit_State *J, TRef tr) +{ + if (!tref_isnumber(tr)) { + if (tref_isstr(tr)) + tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); + else + lj_trace_err(J, LJ_TRERR_BADTYPE); + } + return tr; +} + +/* Convert from integer or string to number. */ +TRef LJ_FASTCALL lj_ir_tonum(jit_State *J, TRef tr) +{ + if (!tref_isnum(tr)) { + if (tref_isinteger(tr)) + tr = emitir(IRTN(IR_CONV), tr, IRCONV_NUM_INT); + else if (tref_isstr(tr)) + tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); + else + lj_trace_err(J, LJ_TRERR_BADTYPE); + } + return tr; +} + +/* Convert from integer or number to string. */ +TRef LJ_FASTCALL lj_ir_tostr(jit_State *J, TRef tr) +{ + if (!tref_isstr(tr)) { + if (!tref_isnumber(tr)) + lj_trace_err(J, LJ_TRERR_BADTYPE); + tr = emitir(IRT(IR_TOSTR, IRT_STR), tr, 0); + } + return tr; +} + +/* -- Miscellaneous IR ops ------------------------------------------------ */ + +/* Evaluate numeric comparison. */ +int lj_ir_numcmp(lua_Number a, lua_Number b, IROp op) +{ + switch (op) { + case IR_EQ: return (a == b); + case IR_NE: return (a != b); + case IR_LT: return (a < b); + case IR_GE: return (a >= b); + case IR_LE: return (a <= b); + case IR_GT: return (a > b); + case IR_ULT: return !(a >= b); + case IR_UGE: return !(a < b); + case IR_ULE: return !(a > b); + case IR_UGT: return !(a <= b); + default: lua_assert(0); return 0; + } +} + +/* Evaluate string comparison. */ +int lj_ir_strcmp(GCstr *a, GCstr *b, IROp op) +{ + int res = lj_str_cmp(a, b); + switch (op) { + case IR_LT: return (res < 0); + case IR_GE: return (res >= 0); + case IR_LE: return (res <= 0); + case IR_GT: return (res > 0); + default: lua_assert(0); return 0; + } +} + +/* Rollback IR to previous state. */ +void lj_ir_rollback(jit_State *J, IRRef ref) +{ + IRRef nins = J->cur.nins; + while (nins > ref) { + IRIns *ir; + nins--; + ir = IR(nins); + J->chain[ir->o] = ir->prev; + } + J->cur.nins = nins; +} + +#undef IR +#undef fins +#undef emitir + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_ir.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ir.h new file mode 100644 index 000000000..8126482e8 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ir.h @@ -0,0 +1,551 @@ +/* +** SSA IR (Intermediate Representation) format. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_IR_H +#define _LJ_IR_H + +#include "lj_obj.h" + +/* -- IR instructions ----------------------------------------------------- */ + +/* IR instruction definition. Order matters, see below. ORDER IR */ +#define IRDEF(_) \ + /* Guarded assertions. */ \ + /* Must be properly aligned to flip opposites (^1) and (un)ordered (^4). */ \ + _(LT, N , ref, ref) \ + _(GE, N , ref, ref) \ + _(LE, N , ref, ref) \ + _(GT, N , ref, ref) \ + \ + _(ULT, N , ref, ref) \ + _(UGE, N , ref, ref) \ + _(ULE, N , ref, ref) \ + _(UGT, N , ref, ref) \ + \ + _(EQ, C , ref, ref) \ + _(NE, C , ref, ref) \ + \ + _(ABC, N , ref, ref) \ + _(RETF, S , ref, ref) \ + \ + /* Miscellaneous ops. */ \ + _(NOP, N , ___, ___) \ + _(BASE, N , lit, lit) \ + _(PVAL, N , lit, ___) \ + _(GCSTEP, S , ___, ___) \ + _(HIOP, S , ref, ref) \ + _(LOOP, S , ___, ___) \ + _(USE, S , ref, ___) \ + _(PHI, S , ref, ref) \ + _(RENAME, S , ref, lit) \ + \ + /* Constants. */ \ + _(KPRI, N , ___, ___) \ + _(KINT, N , cst, ___) \ + _(KGC, N , cst, ___) \ + _(KPTR, N , cst, ___) \ + _(KKPTR, N , cst, ___) \ + _(KNULL, N , cst, ___) \ + _(KNUM, N , cst, ___) \ + _(KINT64, N , cst, ___) \ + _(KSLOT, N , ref, lit) \ + \ + /* Bit ops. */ \ + _(BNOT, N , ref, ___) \ + _(BSWAP, N , ref, ___) \ + _(BAND, C , ref, ref) \ + _(BOR, C , ref, ref) \ + _(BXOR, C , ref, ref) \ + _(BSHL, N , ref, ref) \ + _(BSHR, N , ref, ref) \ + _(BSAR, N , ref, ref) \ + _(BROL, N , ref, ref) \ + _(BROR, N , ref, ref) \ + \ + /* Arithmetic ops. ORDER ARITH */ \ + _(ADD, C , ref, ref) \ + _(SUB, N , ref, ref) \ + _(MUL, C , ref, ref) \ + _(DIV, N , ref, ref) \ + _(MOD, N , ref, ref) \ + _(POW, N , ref, ref) \ + _(NEG, N , ref, ref) \ + \ + _(ABS, N , ref, ref) \ + _(ATAN2, N , ref, ref) \ + _(LDEXP, N , ref, ref) \ + _(MIN, C , ref, ref) \ + _(MAX, C , ref, ref) \ + _(FPMATH, N , ref, lit) \ + \ + /* Overflow-checking arithmetic ops. */ \ + _(ADDOV, CW, ref, ref) \ + _(SUBOV, NW, ref, ref) \ + _(MULOV, CW, ref, ref) \ + \ + /* Memory ops. A = array, H = hash, U = upvalue, F = field, S = stack. */ \ + \ + /* Memory references. */ \ + _(AREF, R , ref, ref) \ + _(HREFK, R , ref, ref) \ + _(HREF, L , ref, ref) \ + _(NEWREF, S , ref, ref) \ + _(UREFO, LW, ref, lit) \ + _(UREFC, LW, ref, lit) \ + _(FREF, R , ref, lit) \ + _(STRREF, N , ref, ref) \ + \ + /* Loads and Stores. These must be in the same order. */ \ + _(ALOAD, L , ref, ___) \ + _(HLOAD, L , ref, ___) \ + _(ULOAD, L , ref, ___) \ + _(FLOAD, L , ref, lit) \ + _(XLOAD, L , ref, lit) \ + _(SLOAD, L , lit, lit) \ + _(VLOAD, L , ref, ___) \ + \ + _(ASTORE, S , ref, ref) \ + _(HSTORE, S , ref, ref) \ + _(USTORE, S , ref, ref) \ + _(FSTORE, S , ref, ref) \ + _(XSTORE, S , ref, ref) \ + \ + /* Allocations. */ \ + _(SNEW, N , ref, ref) /* CSE is ok, not marked as A. */ \ + _(XSNEW, A , ref, ref) \ + _(TNEW, AW, lit, lit) \ + _(TDUP, AW, ref, ___) \ + _(CNEW, AW, ref, ref) \ + _(CNEWI, NW, ref, ref) /* CSE is ok, not marked as A. */ \ + \ + /* Barriers. */ \ + _(TBAR, S , ref, ___) \ + _(OBAR, S , ref, ref) \ + _(XBAR, S , ___, ___) \ + \ + /* Type conversions. */ \ + _(CONV, NW, ref, lit) \ + _(TOBIT, N , ref, ref) \ + _(TOSTR, N , ref, ___) \ + _(STRTO, N , ref, ___) \ + \ + /* Calls. */ \ + _(CALLN, N , ref, lit) \ + _(CALLL, L , ref, lit) \ + _(CALLS, S , ref, lit) \ + _(CALLXS, S , ref, ref) \ + _(CARG, N , ref, ref) \ + \ + /* End of list. */ + +/* IR opcodes (max. 256). */ +typedef enum { +#define IRENUM(name, m, m1, m2) IR_##name, +IRDEF(IRENUM) +#undef IRENUM + IR__MAX +} IROp; + +/* Stored opcode. */ +typedef uint8_t IROp1; + +LJ_STATIC_ASSERT(((int)IR_EQ^1) == (int)IR_NE); +LJ_STATIC_ASSERT(((int)IR_LT^1) == (int)IR_GE); +LJ_STATIC_ASSERT(((int)IR_LE^1) == (int)IR_GT); +LJ_STATIC_ASSERT(((int)IR_LT^3) == (int)IR_GT); +LJ_STATIC_ASSERT(((int)IR_LT^4) == (int)IR_ULT); + +/* Delta between xLOAD and xSTORE. */ +#define IRDELTA_L2S ((int)IR_ASTORE - (int)IR_ALOAD) + +LJ_STATIC_ASSERT((int)IR_HLOAD + IRDELTA_L2S == (int)IR_HSTORE); +LJ_STATIC_ASSERT((int)IR_ULOAD + IRDELTA_L2S == (int)IR_USTORE); +LJ_STATIC_ASSERT((int)IR_FLOAD + IRDELTA_L2S == (int)IR_FSTORE); +LJ_STATIC_ASSERT((int)IR_XLOAD + IRDELTA_L2S == (int)IR_XSTORE); + +/* -- Named IR literals --------------------------------------------------- */ + +/* FPMATH sub-functions. ORDER FPM. */ +#define IRFPMDEF(_) \ + _(FLOOR) _(CEIL) _(TRUNC) /* Must be first and in this order. */ \ + _(SQRT) _(EXP) _(EXP2) _(LOG) _(LOG2) _(LOG10) \ + _(SIN) _(COS) _(TAN) \ + _(OTHER) + +typedef enum { +#define FPMENUM(name) IRFPM_##name, +IRFPMDEF(FPMENUM) +#undef FPMENUM + IRFPM__MAX +} IRFPMathOp; + +/* FLOAD fields. */ +#define IRFLDEF(_) \ + _(STR_LEN, offsetof(GCstr, len)) \ + _(FUNC_ENV, offsetof(GCfunc, l.env)) \ + _(FUNC_PC, offsetof(GCfunc, l.pc)) \ + _(TAB_META, offsetof(GCtab, metatable)) \ + _(TAB_ARRAY, offsetof(GCtab, array)) \ + _(TAB_NODE, offsetof(GCtab, node)) \ + _(TAB_ASIZE, offsetof(GCtab, asize)) \ + _(TAB_HMASK, offsetof(GCtab, hmask)) \ + _(TAB_NOMM, offsetof(GCtab, nomm)) \ + _(UDATA_META, offsetof(GCudata, metatable)) \ + _(UDATA_UDTYPE, offsetof(GCudata, udtype)) \ + _(UDATA_FILE, sizeof(GCudata)) \ + _(CDATA_CTYPEID, offsetof(GCcdata, ctypeid)) \ + _(CDATA_PTR, sizeof(GCcdata)) \ + _(CDATA_INT, sizeof(GCcdata)) \ + _(CDATA_INT64, sizeof(GCcdata)) \ + _(CDATA_INT64_4, sizeof(GCcdata) + 4) + +typedef enum { +#define FLENUM(name, ofs) IRFL_##name, +IRFLDEF(FLENUM) +#undef FLENUM + IRFL__MAX +} IRFieldID; + +/* SLOAD mode bits, stored in op2. */ +#define IRSLOAD_PARENT 0x01 /* Coalesce with parent trace. */ +#define IRSLOAD_FRAME 0x02 /* Load hiword of frame. */ +#define IRSLOAD_TYPECHECK 0x04 /* Needs type check. */ +#define IRSLOAD_CONVERT 0x08 /* Number to integer conversion. */ +#define IRSLOAD_READONLY 0x10 /* Read-only, omit slot store. */ +#define IRSLOAD_INHERIT 0x20 /* Inherited by exits/side traces. */ + +/* XLOAD mode, stored in op2. */ +#define IRXLOAD_READONLY 1 /* Load from read-only data. */ +#define IRXLOAD_VOLATILE 2 /* Load from volatile data. */ +#define IRXLOAD_UNALIGNED 4 /* Unaligned load. */ + +/* CONV mode, stored in op2. */ +#define IRCONV_SRCMASK 0x001f /* Source IRType. */ +#define IRCONV_DSTMASK 0x03e0 /* Dest. IRType (also in ir->t). */ +#define IRCONV_DSH 5 +#define IRCONV_NUM_INT ((IRT_NUM<>2)&3)) +#define irm_iscomm(m) ((m) & IRM_C) +#define irm_kind(m) ((m) & IRM_S) + +#define IRMODE(name, m, m1, m2) (((IRM##m1)|((IRM##m2)<<2)|(IRM_##m))^IRM_W), + +LJ_DATA const uint8_t lj_ir_mode[IR__MAX+1]; + +/* -- IR instruction types ------------------------------------------------ */ + +/* Map of itypes to non-negative numbers. ORDER LJ_T. +** LJ_TUPVAL/LJ_TTRACE never appear in a TValue. Use these itypes for +** IRT_P32 and IRT_P64, which never escape the IR. +** The various integers are only used in the IR and can only escape to +** a TValue after implicit or explicit conversion. Their types must be +** contiguous and next to IRT_NUM (see the typerange macros below). +*/ +#define IRTDEF(_) \ + _(NIL, 4) _(FALSE, 4) _(TRUE, 4) _(LIGHTUD, LJ_64 ? 8 : 4) _(STR, 4) \ + _(P32, 4) _(THREAD, 4) _(PROTO, 4) _(FUNC, 4) _(P64, 8) _(CDATA, 4) \ + _(TAB, 4) _(UDATA, 4) \ + _(FLOAT, 4) _(NUM, 8) _(I8, 1) _(U8, 1) _(I16, 2) _(U16, 2) \ + _(INT, 4) _(U32, 4) _(I64, 8) _(U64, 8) \ + _(SOFTFP, 4) /* There is room for 9 more types. */ + +/* IR result type and flags (8 bit). */ +typedef enum { +#define IRTENUM(name, size) IRT_##name, +IRTDEF(IRTENUM) +#undef IRTENUM + IRT__MAX, + + /* Native pointer type and the corresponding integer type. */ + IRT_PTR = LJ_64 ? IRT_P64 : IRT_P32, + IRT_INTP = LJ_64 ? IRT_I64 : IRT_INT, + IRT_UINTP = LJ_64 ? IRT_U64 : IRT_U32, + + /* Additional flags. */ + IRT_MARK = 0x20, /* Marker for misc. purposes. */ + IRT_ISPHI = 0x40, /* Instruction is left or right PHI operand. */ + IRT_GUARD = 0x80, /* Instruction is a guard. */ + + /* Masks. */ + IRT_TYPE = 0x1f, + IRT_T = 0xff +} IRType; + +#define irtype_ispri(irt) ((uint32_t)(irt) <= IRT_TRUE) + +/* Stored IRType. */ +typedef struct IRType1 { uint8_t irt; } IRType1; + +#define IRT(o, t) ((uint32_t)(((o)<<8) | (t))) +#define IRTI(o) (IRT((o), IRT_INT)) +#define IRTN(o) (IRT((o), IRT_NUM)) +#define IRTG(o, t) (IRT((o), IRT_GUARD|(t))) +#define IRTGI(o) (IRT((o), IRT_GUARD|IRT_INT)) + +#define irt_t(t) ((IRType)(t).irt) +#define irt_type(t) ((IRType)((t).irt & IRT_TYPE)) +#define irt_sametype(t1, t2) ((((t1).irt ^ (t2).irt) & IRT_TYPE) == 0) +#define irt_typerange(t, first, last) \ + ((uint32_t)((t).irt & IRT_TYPE) - (uint32_t)(first) <= (uint32_t)(last-first)) + +#define irt_isnil(t) (irt_type(t) == IRT_NIL) +#define irt_ispri(t) ((uint32_t)irt_type(t) <= IRT_TRUE) +#define irt_islightud(t) (irt_type(t) == IRT_LIGHTUD) +#define irt_isstr(t) (irt_type(t) == IRT_STR) +#define irt_istab(t) (irt_type(t) == IRT_TAB) +#define irt_iscdata(t) (irt_type(t) == IRT_CDATA) +#define irt_isfloat(t) (irt_type(t) == IRT_FLOAT) +#define irt_isnum(t) (irt_type(t) == IRT_NUM) +#define irt_isint(t) (irt_type(t) == IRT_INT) +#define irt_isi8(t) (irt_type(t) == IRT_I8) +#define irt_isu8(t) (irt_type(t) == IRT_U8) +#define irt_isi16(t) (irt_type(t) == IRT_I16) +#define irt_isu16(t) (irt_type(t) == IRT_U16) +#define irt_isu32(t) (irt_type(t) == IRT_U32) +#define irt_isi64(t) (irt_type(t) == IRT_I64) +#define irt_isu64(t) (irt_type(t) == IRT_U64) + +#define irt_isfp(t) (irt_isnum(t) || irt_isfloat(t)) +#define irt_isinteger(t) (irt_typerange((t), IRT_I8, IRT_INT)) +#define irt_isgcv(t) (irt_typerange((t), IRT_STR, IRT_UDATA)) +#define irt_isaddr(t) (irt_typerange((t), IRT_LIGHTUD, IRT_UDATA)) +#define irt_isint64(t) (irt_typerange((t), IRT_I64, IRT_U64)) + +#if LJ_64 +#define IRT_IS64 \ + ((1u<> irt_type(t)) & 1) +#define irt_is64orfp(t) (((IRT_IS64|(1u<>irt_type(t)) & 1) + +#define irt_size(t) (lj_ir_type_size[irt_t((t))]) + +LJ_DATA const uint8_t lj_ir_type_size[]; + +static LJ_AINLINE IRType itype2irt(const TValue *tv) +{ + if (tvisint(tv)) + return IRT_INT; + else if (tvisnum(tv)) + return IRT_NUM; +#if LJ_64 + else if (tvislightud(tv)) + return IRT_LIGHTUD; +#endif + else + return (IRType)~itype(tv); +} + +static LJ_AINLINE uint32_t irt_toitype_(IRType t) +{ + lua_assert(!LJ_64 || t != IRT_LIGHTUD); + if (LJ_DUALNUM && t > IRT_NUM) { + return LJ_TISNUM; + } else { + lua_assert(t <= IRT_NUM); + return ~(uint32_t)t; + } +} + +#define irt_toitype(t) irt_toitype_(irt_type((t))) + +#define irt_isguard(t) ((t).irt & IRT_GUARD) +#define irt_ismarked(t) ((t).irt & IRT_MARK) +#define irt_setmark(t) ((t).irt |= IRT_MARK) +#define irt_clearmark(t) ((t).irt &= ~IRT_MARK) +#define irt_isphi(t) ((t).irt & IRT_ISPHI) +#define irt_setphi(t) ((t).irt |= IRT_ISPHI) +#define irt_clearphi(t) ((t).irt &= ~IRT_ISPHI) + +/* Stored combined IR opcode and type. */ +typedef uint16_t IROpT; + +/* -- IR references ------------------------------------------------------- */ + +/* IR references. */ +typedef uint16_t IRRef1; /* One stored reference. */ +typedef uint32_t IRRef2; /* Two stored references. */ +typedef uint32_t IRRef; /* Used to pass around references. */ + +/* Fixed references. */ +enum { + REF_BIAS = 0x8000, + REF_TRUE = REF_BIAS-3, + REF_FALSE = REF_BIAS-2, + REF_NIL = REF_BIAS-1, /* \--- Constants grow downwards. */ + REF_BASE = REF_BIAS, /* /--- IR grows upwards. */ + REF_FIRST = REF_BIAS+1, + REF_DROP = 0xffff +}; + +/* Note: IRMlit operands must be < REF_BIAS, too! +** This allows for fast and uniform manipulation of all operands +** without looking up the operand mode in lj_ir_mode: +** - CSE calculates the maximum reference of two operands. +** This must work with mixed reference/literal operands, too. +** - DCE marking only checks for operand >= REF_BIAS. +** - LOOP needs to substitute reference operands. +** Constant references and literals must not be modified. +*/ + +#define IRREF2(lo, hi) ((IRRef2)(lo) | ((IRRef2)(hi) << 16)) + +#define irref_isk(ref) ((ref) < REF_BIAS) + +/* Tagged IR references (32 bit). +** +** +-------+-------+---------------+ +** | irt | flags | ref | +** +-------+-------+---------------+ +** +** The tag holds a copy of the IRType and speeds up IR type checks. +*/ +typedef uint32_t TRef; + +#define TREF_REFMASK 0x0000ffff +#define TREF_FRAME 0x00010000 +#define TREF_CONT 0x00020000 + +#define TREF(ref, t) ((TRef)((ref) + ((t)<<24))) + +#define tref_ref(tr) ((IRRef1)(tr)) +#define tref_t(tr) ((IRType)((tr)>>24)) +#define tref_type(tr) ((IRType)(((tr)>>24) & IRT_TYPE)) +#define tref_typerange(tr, first, last) \ + ((((tr)>>24) & IRT_TYPE) - (TRef)(first) <= (TRef)(last-first)) + +#define tref_istype(tr, t) (((tr) & (IRT_TYPE<<24)) == ((t)<<24)) +#define tref_isnil(tr) (tref_istype((tr), IRT_NIL)) +#define tref_isfalse(tr) (tref_istype((tr), IRT_FALSE)) +#define tref_istrue(tr) (tref_istype((tr), IRT_TRUE)) +#define tref_isstr(tr) (tref_istype((tr), IRT_STR)) +#define tref_isfunc(tr) (tref_istype((tr), IRT_FUNC)) +#define tref_iscdata(tr) (tref_istype((tr), IRT_CDATA)) +#define tref_istab(tr) (tref_istype((tr), IRT_TAB)) +#define tref_isudata(tr) (tref_istype((tr), IRT_UDATA)) +#define tref_isnum(tr) (tref_istype((tr), IRT_NUM)) +#define tref_isint(tr) (tref_istype((tr), IRT_INT)) + +#define tref_isbool(tr) (tref_typerange((tr), IRT_FALSE, IRT_TRUE)) +#define tref_ispri(tr) (tref_typerange((tr), IRT_NIL, IRT_TRUE)) +#define tref_istruecond(tr) (!tref_typerange((tr), IRT_NIL, IRT_FALSE)) +#define tref_isinteger(tr) (tref_typerange((tr), IRT_I8, IRT_INT)) +#define tref_isnumber(tr) (tref_typerange((tr), IRT_NUM, IRT_INT)) +#define tref_isnumber_str(tr) (tref_isnumber((tr)) || tref_isstr((tr))) +#define tref_isgcv(tr) (tref_typerange((tr), IRT_STR, IRT_UDATA)) + +#define tref_isk(tr) (irref_isk(tref_ref((tr)))) +#define tref_isk2(tr1, tr2) (irref_isk(tref_ref((tr1) | (tr2)))) + +#define TREF_PRI(t) (TREF(REF_NIL-(t), (t))) +#define TREF_NIL (TREF_PRI(IRT_NIL)) +#define TREF_FALSE (TREF_PRI(IRT_FALSE)) +#define TREF_TRUE (TREF_PRI(IRT_TRUE)) + +/* -- IR format ----------------------------------------------------------- */ + +/* IR instruction format (64 bit). +** +** 16 16 8 8 8 8 +** +-------+-------+---+---+---+---+ +** | op1 | op2 | t | o | r | s | +** +-------+-------+---+---+---+---+ +** | op12/i/gco | ot | prev | (alternative fields in union) +** +---------------+-------+-------+ +** 32 16 16 +** +** prev is only valid prior to register allocation and then reused for r + s. +*/ + +typedef union IRIns { + struct { + LJ_ENDIAN_LOHI( + IRRef1 op1; /* IR operand 1. */ + , IRRef1 op2; /* IR operand 2. */ + ) + IROpT ot; /* IR opcode and type (overlaps t and o). */ + IRRef1 prev; /* Previous ins in same chain (overlaps r and s). */ + }; + struct { + IRRef2 op12; /* IR operand 1 and 2 (overlaps op1 and op2). */ + LJ_ENDIAN_LOHI( + IRType1 t; /* IR type. */ + , IROp1 o; /* IR opcode. */ + ) + LJ_ENDIAN_LOHI( + uint8_t r; /* Register allocation (overlaps prev). */ + , uint8_t s; /* Spill slot allocation (overlaps prev). */ + ) + }; + int32_t i; /* 32 bit signed integer literal (overlaps op12). */ + GCRef gcr; /* GCobj constant (overlaps op12). */ + MRef ptr; /* Pointer constant (overlaps op12). */ +} IRIns; + +#define ir_kgc(ir) check_exp((ir)->o == IR_KGC, gcref((ir)->gcr)) +#define ir_kstr(ir) (gco2str(ir_kgc((ir)))) +#define ir_ktab(ir) (gco2tab(ir_kgc((ir)))) +#define ir_kfunc(ir) (gco2func(ir_kgc((ir)))) +#define ir_kcdata(ir) (gco2cd(ir_kgc((ir)))) +#define ir_knum(ir) check_exp((ir)->o == IR_KNUM, mref((ir)->ptr, cTValue)) +#define ir_kint64(ir) check_exp((ir)->o == IR_KINT64, mref((ir)->ptr,cTValue)) +#define ir_k64(ir) \ + check_exp((ir)->o == IR_KNUM || (ir)->o == IR_KINT64, mref((ir)->ptr,cTValue)) +#define ir_kptr(ir) \ + check_exp((ir)->o == IR_KPTR || (ir)->o == IR_KKPTR, mref((ir)->ptr, void)) + +/* A store or any other op with a non-weak guard has a side-effect. */ +static LJ_AINLINE int ir_sideeff(IRIns *ir) +{ + return (((ir->t.irt | ~IRT_GUARD) & lj_ir_mode[ir->o]) >= IRM_S); +} + +LJ_STATIC_ASSERT((int)IRT_GUARD == (int)IRM_W); + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_ircall.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ircall.h new file mode 100644 index 000000000..893dac2f8 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_ircall.h @@ -0,0 +1,277 @@ +/* +** IR CALL* instruction definitions. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_IRCALL_H +#define _LJ_IRCALL_H + +#include "lj_obj.h" +#include "lj_ir.h" +#include "lj_jit.h" + +/* C call info for CALL* instructions. */ +typedef struct CCallInfo { + ASMFunction func; /* Function pointer. */ + uint32_t flags; /* Number of arguments and flags. */ +} CCallInfo; + +#define CCI_NARGS(ci) ((ci)->flags & 0xff) /* Extract # of args. */ +#define CCI_NARGS_MAX 32 /* Max. # of args. */ + +#define CCI_OTSHIFT 16 +#define CCI_OPTYPE(ci) ((ci)->flags >> CCI_OTSHIFT) /* Get op/type. */ +#define CCI_OPSHIFT 24 +#define CCI_OP(ci) ((ci)->flags >> CCI_OPSHIFT) /* Get op. */ + +#define CCI_CALL_N (IR_CALLN << CCI_OPSHIFT) +#define CCI_CALL_L (IR_CALLL << CCI_OPSHIFT) +#define CCI_CALL_S (IR_CALLS << CCI_OPSHIFT) +#define CCI_CALL_FN (CCI_CALL_N|CCI_CC_FASTCALL) +#define CCI_CALL_FL (CCI_CALL_L|CCI_CC_FASTCALL) +#define CCI_CALL_FS (CCI_CALL_S|CCI_CC_FASTCALL) + +/* C call info flags. */ +#define CCI_L 0x0100 /* Implicit L arg. */ +#define CCI_CASTU64 0x0200 /* Cast u64 result to number. */ +#define CCI_NOFPRCLOBBER 0x0400 /* Does not clobber any FPRs. */ +#define CCI_VARARG 0x0800 /* Vararg function. */ + +#define CCI_CC_MASK 0x3000 /* Calling convention mask. */ +#define CCI_CC_SHIFT 12 +/* ORDER CC */ +#define CCI_CC_CDECL 0x0000 /* Default cdecl calling convention. */ +#define CCI_CC_THISCALL 0x1000 /* Thiscall calling convention. */ +#define CCI_CC_FASTCALL 0x2000 /* Fastcall calling convention. */ +#define CCI_CC_STDCALL 0x3000 /* Stdcall calling convention. */ + +/* Helpers for conditional function definitions. */ +#define IRCALLCOND_ANY(x) x + +#if LJ_TARGET_X86ORX64 +#define IRCALLCOND_FPMATH(x) NULL +#else +#define IRCALLCOND_FPMATH(x) x +#endif + +#if LJ_SOFTFP +#define IRCALLCOND_SOFTFP(x) x +#if LJ_HASFFI +#define IRCALLCOND_SOFTFP_FFI(x) x +#else +#define IRCALLCOND_SOFTFP_FFI(x) NULL +#endif +#else +#define IRCALLCOND_SOFTFP(x) NULL +#define IRCALLCOND_SOFTFP_FFI(x) NULL +#endif + +#define LJ_NEED_FP64 (LJ_TARGET_ARM || LJ_TARGET_PPC || LJ_TARGET_MIPS) + +#if LJ_HASFFI && (LJ_SOFTFP || LJ_NEED_FP64) +#define IRCALLCOND_FP64_FFI(x) x +#else +#define IRCALLCOND_FP64_FFI(x) NULL +#endif + +#if LJ_HASFFI +#define IRCALLCOND_FFI(x) x +#if LJ_32 +#define IRCALLCOND_FFI32(x) x +#else +#define IRCALLCOND_FFI32(x) NULL +#endif +#else +#define IRCALLCOND_FFI(x) NULL +#define IRCALLCOND_FFI32(x) NULL +#endif + +#if LJ_TARGET_X86 +#define CCI_RANDFPR 0 /* Clang on OSX/x86 is overzealous. */ +#else +#define CCI_RANDFPR CCI_NOFPRCLOBBER +#endif + +#if LJ_SOFTFP +#define ARG1_FP 2 /* Treat as 2 32 bit arguments. */ +#else +#define ARG1_FP 1 +#endif + +#if LJ_32 +#define ARG2_64 4 /* Treat as 4 32 bit arguments. */ +#else +#define ARG2_64 2 +#endif + +/* Function definitions for CALL* instructions. */ +#define IRCALLDEF(_) \ + _(ANY, lj_str_cmp, 2, FN, INT, CCI_NOFPRCLOBBER) \ + _(ANY, lj_str_new, 3, S, STR, CCI_L) \ + _(ANY, lj_strscan_num, 2, FN, INT, 0) \ + _(ANY, lj_str_fromint, 2, FN, STR, CCI_L) \ + _(ANY, lj_str_fromnum, 2, FN, STR, CCI_L) \ + _(ANY, lj_tab_new1, 2, FS, TAB, CCI_L) \ + _(ANY, lj_tab_dup, 2, FS, TAB, CCI_L) \ + _(ANY, lj_tab_newkey, 3, S, P32, CCI_L) \ + _(ANY, lj_tab_len, 1, FL, INT, 0) \ + _(ANY, lj_gc_step_jit, 2, FS, NIL, CCI_L) \ + _(ANY, lj_gc_barrieruv, 2, FS, NIL, 0) \ + _(ANY, lj_mem_newgco, 2, FS, P32, CCI_L) \ + _(ANY, lj_math_random_step, 1, FS, NUM, CCI_CASTU64|CCI_RANDFPR)\ + _(ANY, lj_vm_modi, 2, FN, INT, 0) \ + _(ANY, sinh, ARG1_FP, N, NUM, 0) \ + _(ANY, cosh, ARG1_FP, N, NUM, 0) \ + _(ANY, tanh, ARG1_FP, N, NUM, 0) \ + _(ANY, fputc, 2, S, INT, 0) \ + _(ANY, fwrite, 4, S, INT, 0) \ + _(ANY, fflush, 1, S, INT, 0) \ + /* ORDER FPM */ \ + _(FPMATH, lj_vm_floor, ARG1_FP, N, NUM, 0) \ + _(FPMATH, lj_vm_ceil, ARG1_FP, N, NUM, 0) \ + _(FPMATH, lj_vm_trunc, ARG1_FP, N, NUM, 0) \ + _(FPMATH, sqrt, ARG1_FP, N, NUM, 0) \ + _(FPMATH, exp, ARG1_FP, N, NUM, 0) \ + _(FPMATH, lj_vm_exp2, ARG1_FP, N, NUM, 0) \ + _(FPMATH, log, ARG1_FP, N, NUM, 0) \ + _(FPMATH, lj_vm_log2, ARG1_FP, N, NUM, 0) \ + _(FPMATH, log10, ARG1_FP, N, NUM, 0) \ + _(FPMATH, sin, ARG1_FP, N, NUM, 0) \ + _(FPMATH, cos, ARG1_FP, N, NUM, 0) \ + _(FPMATH, tan, ARG1_FP, N, NUM, 0) \ + _(FPMATH, lj_vm_powi, ARG1_FP+1, N, NUM, 0) \ + _(FPMATH, pow, ARG1_FP*2, N, NUM, 0) \ + _(FPMATH, atan2, ARG1_FP*2, N, NUM, 0) \ + _(FPMATH, ldexp, ARG1_FP+1, N, NUM, 0) \ + _(SOFTFP, lj_vm_tobit, 2, N, INT, 0) \ + _(SOFTFP, softfp_add, 4, N, NUM, 0) \ + _(SOFTFP, softfp_sub, 4, N, NUM, 0) \ + _(SOFTFP, softfp_mul, 4, N, NUM, 0) \ + _(SOFTFP, softfp_div, 4, N, NUM, 0) \ + _(SOFTFP, softfp_cmp, 4, N, NIL, 0) \ + _(SOFTFP, softfp_i2d, 1, N, NUM, 0) \ + _(SOFTFP, softfp_d2i, 2, N, INT, 0) \ + _(SOFTFP_FFI, softfp_ui2d, 1, N, NUM, 0) \ + _(SOFTFP_FFI, softfp_f2d, 1, N, NUM, 0) \ + _(SOFTFP_FFI, softfp_d2ui, 2, N, INT, 0) \ + _(SOFTFP_FFI, softfp_d2f, 2, N, FLOAT, 0) \ + _(SOFTFP_FFI, softfp_i2f, 1, N, FLOAT, 0) \ + _(SOFTFP_FFI, softfp_ui2f, 1, N, FLOAT, 0) \ + _(SOFTFP_FFI, softfp_f2i, 1, N, INT, 0) \ + _(SOFTFP_FFI, softfp_f2ui, 1, N, INT, 0) \ + _(FP64_FFI, fp64_l2d, 2, N, NUM, 0) \ + _(FP64_FFI, fp64_ul2d, 2, N, NUM, 0) \ + _(FP64_FFI, fp64_l2f, 2, N, FLOAT, 0) \ + _(FP64_FFI, fp64_ul2f, 2, N, FLOAT, 0) \ + _(FP64_FFI, fp64_d2l, ARG1_FP, N, I64, 0) \ + _(FP64_FFI, fp64_d2ul, ARG1_FP, N, U64, 0) \ + _(FP64_FFI, fp64_f2l, 1, N, I64, 0) \ + _(FP64_FFI, fp64_f2ul, 1, N, U64, 0) \ + _(FFI, lj_carith_divi64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \ + _(FFI, lj_carith_divu64, ARG2_64, N, U64, CCI_NOFPRCLOBBER) \ + _(FFI, lj_carith_modi64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \ + _(FFI, lj_carith_modu64, ARG2_64, N, U64, CCI_NOFPRCLOBBER) \ + _(FFI, lj_carith_powi64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \ + _(FFI, lj_carith_powu64, ARG2_64, N, U64, CCI_NOFPRCLOBBER) \ + _(FFI, lj_cdata_setfin, 2, FN, P32, CCI_L) \ + _(FFI, strlen, 1, L, INTP, 0) \ + _(FFI, memcpy, 3, S, PTR, 0) \ + _(FFI, memset, 3, S, PTR, 0) \ + _(FFI, lj_vm_errno, 0, S, INT, CCI_NOFPRCLOBBER) \ + _(FFI32, lj_carith_mul64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) + \ + /* End of list. */ + +typedef enum { +#define IRCALLENUM(cond, name, nargs, kind, type, flags) IRCALL_##name, +IRCALLDEF(IRCALLENUM) +#undef IRCALLENUM + IRCALL__MAX +} IRCallID; + +LJ_FUNC TRef lj_ir_call(jit_State *J, IRCallID id, ...); + +LJ_DATA const CCallInfo lj_ir_callinfo[IRCALL__MAX+1]; + +/* Soft-float declarations. */ +#if LJ_SOFTFP +#if LJ_TARGET_ARM +#define softfp_add __aeabi_dadd +#define softfp_sub __aeabi_dsub +#define softfp_mul __aeabi_dmul +#define softfp_div __aeabi_ddiv +#define softfp_cmp __aeabi_cdcmple +#define softfp_i2d __aeabi_i2d +#define softfp_d2i __aeabi_d2iz +#define softfp_ui2d __aeabi_ui2d +#define softfp_f2d __aeabi_f2d +#define softfp_d2ui __aeabi_d2uiz +#define softfp_d2f __aeabi_d2f +#define softfp_i2f __aeabi_i2f +#define softfp_ui2f __aeabi_ui2f +#define softfp_f2i __aeabi_f2iz +#define softfp_f2ui __aeabi_f2uiz +#define fp64_l2d __aeabi_l2d +#define fp64_ul2d __aeabi_ul2d +#define fp64_l2f __aeabi_l2f +#define fp64_ul2f __aeabi_ul2f +#if LJ_TARGET_IOS +#define fp64_d2l __fixdfdi +#define fp64_d2ul __fixunsdfdi +#define fp64_f2l __fixsfdi +#define fp64_f2ul __fixunssfdi +#else +#define fp64_d2l __aeabi_d2lz +#define fp64_d2ul __aeabi_d2ulz +#define fp64_f2l __aeabi_f2lz +#define fp64_f2ul __aeabi_f2ulz +#endif +#else +#error "Missing soft-float definitions for target architecture" +#endif +extern double softfp_add(double a, double b); +extern double softfp_sub(double a, double b); +extern double softfp_mul(double a, double b); +extern double softfp_div(double a, double b); +extern void softfp_cmp(double a, double b); +extern double softfp_i2d(int32_t a); +extern int32_t softfp_d2i(double a); +#if LJ_HASFFI +extern double softfp_ui2d(uint32_t a); +extern double softfp_f2d(float a); +extern uint32_t softfp_d2ui(double a); +extern float softfp_d2f(double a); +extern float softfp_i2f(int32_t a); +extern float softfp_ui2f(uint32_t a); +extern int32_t softfp_f2i(float a); +extern uint32_t softfp_f2ui(float a); +#endif +#endif + +#if LJ_HASFFI && LJ_NEED_FP64 && !(LJ_TARGET_ARM && LJ_SOFTFP) +#ifdef __GNUC__ +#define fp64_l2d __floatdidf +#define fp64_ul2d __floatundidf +#define fp64_l2f __floatdisf +#define fp64_ul2f __floatundisf +#define fp64_d2l __fixdfdi +#define fp64_d2ul __fixunsdfdi +#define fp64_f2l __fixsfdi +#define fp64_f2ul __fixunssfdi +#else +#error "Missing fp64 helper definitions for this compiler" +#endif +#endif + +#if LJ_HASFFI && (LJ_SOFTFP || LJ_NEED_FP64) +extern double fp64_l2d(int64_t a); +extern double fp64_ul2d(uint64_t a); +extern float fp64_l2f(int64_t a); +extern float fp64_ul2f(uint64_t a); +extern int64_t fp64_d2l(double a); +extern uint64_t fp64_d2ul(double a); +extern int64_t fp64_f2l(float a); +extern uint64_t fp64_f2ul(float a); +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_iropt.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_iropt.h new file mode 100644 index 000000000..4e424e700 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_iropt.h @@ -0,0 +1,161 @@ +/* +** Common header for IR emitter and optimizations. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_IROPT_H +#define _LJ_IROPT_H + +#include + +#include "lj_obj.h" +#include "lj_jit.h" + +#if LJ_HASJIT +/* IR emitter. */ +LJ_FUNC void LJ_FASTCALL lj_ir_growtop(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_ir_emit(jit_State *J); + +/* Save current IR in J->fold.ins, but do not emit it (yet). */ +static LJ_AINLINE void lj_ir_set_(jit_State *J, uint16_t ot, IRRef1 a, IRRef1 b) +{ + J->fold.ins.ot = ot; J->fold.ins.op1 = a; J->fold.ins.op2 = b; +} + +#define lj_ir_set(J, ot, a, b) \ + lj_ir_set_(J, (uint16_t)(ot), (IRRef1)(a), (IRRef1)(b)) + +/* Get ref of next IR instruction and optionally grow IR. +** Note: this may invalidate all IRIns*! +*/ +static LJ_AINLINE IRRef lj_ir_nextins(jit_State *J) +{ + IRRef ref = J->cur.nins; + if (LJ_UNLIKELY(ref >= J->irtoplim)) lj_ir_growtop(J); + J->cur.nins = ref + 1; + return ref; +} + +/* Interning of constants. */ +LJ_FUNC TRef LJ_FASTCALL lj_ir_kint(jit_State *J, int32_t k); +LJ_FUNC void lj_ir_k64_freeall(jit_State *J); +LJ_FUNC TRef lj_ir_k64(jit_State *J, IROp op, cTValue *tv); +LJ_FUNC cTValue *lj_ir_k64_find(jit_State *J, uint64_t u64); +LJ_FUNC TRef lj_ir_knum_u64(jit_State *J, uint64_t u64); +LJ_FUNC TRef lj_ir_knumint(jit_State *J, lua_Number n); +LJ_FUNC TRef lj_ir_kint64(jit_State *J, uint64_t u64); +LJ_FUNC TRef lj_ir_kgc(jit_State *J, GCobj *o, IRType t); +LJ_FUNC TRef lj_ir_kptr_(jit_State *J, IROp op, void *ptr); +LJ_FUNC TRef lj_ir_knull(jit_State *J, IRType t); +LJ_FUNC TRef lj_ir_kslot(jit_State *J, TRef key, IRRef slot); + +#if LJ_64 +#define lj_ir_kintp(J, k) lj_ir_kint64(J, (uint64_t)(k)) +#else +#define lj_ir_kintp(J, k) lj_ir_kint(J, (int32_t)(k)) +#endif + +static LJ_AINLINE TRef lj_ir_knum(jit_State *J, lua_Number n) +{ + TValue tv; + tv.n = n; + return lj_ir_knum_u64(J, tv.u64); +} + +#define lj_ir_kstr(J, str) lj_ir_kgc(J, obj2gco((str)), IRT_STR) +#define lj_ir_ktab(J, tab) lj_ir_kgc(J, obj2gco((tab)), IRT_TAB) +#define lj_ir_kfunc(J, func) lj_ir_kgc(J, obj2gco((func)), IRT_FUNC) +#define lj_ir_kptr(J, ptr) lj_ir_kptr_(J, IR_KPTR, (ptr)) +#define lj_ir_kkptr(J, ptr) lj_ir_kptr_(J, IR_KKPTR, (ptr)) + +/* Special FP constants. */ +#define lj_ir_knum_zero(J) lj_ir_knum_u64(J, U64x(00000000,00000000)) +#define lj_ir_knum_one(J) lj_ir_knum_u64(J, U64x(3ff00000,00000000)) +#define lj_ir_knum_tobit(J) lj_ir_knum_u64(J, U64x(43380000,00000000)) + +/* Special 128 bit SIMD constants. */ +#define lj_ir_knum_abs(J) lj_ir_k64(J, IR_KNUM, LJ_KSIMD(J, LJ_KSIMD_ABS)) +#define lj_ir_knum_neg(J) lj_ir_k64(J, IR_KNUM, LJ_KSIMD(J, LJ_KSIMD_NEG)) + +/* Access to constants. */ +LJ_FUNC void lj_ir_kvalue(lua_State *L, TValue *tv, const IRIns *ir); + +/* Convert IR operand types. */ +LJ_FUNC TRef LJ_FASTCALL lj_ir_tonumber(jit_State *J, TRef tr); +LJ_FUNC TRef LJ_FASTCALL lj_ir_tonum(jit_State *J, TRef tr); +LJ_FUNC TRef LJ_FASTCALL lj_ir_tostr(jit_State *J, TRef tr); + +/* Miscellaneous IR ops. */ +LJ_FUNC int lj_ir_numcmp(lua_Number a, lua_Number b, IROp op); +LJ_FUNC int lj_ir_strcmp(GCstr *a, GCstr *b, IROp op); +LJ_FUNC void lj_ir_rollback(jit_State *J, IRRef ref); + +/* Emit IR instructions with on-the-fly optimizations. */ +LJ_FUNC TRef LJ_FASTCALL lj_opt_fold(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_cse(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_cselim(jit_State *J, IRRef lim); + +/* Special return values for the fold functions. */ +enum { + NEXTFOLD, /* Couldn't fold, pass on. */ + RETRYFOLD, /* Retry fold with modified fins. */ + KINTFOLD, /* Return ref for int constant in fins->i. */ + FAILFOLD, /* Guard would always fail. */ + DROPFOLD, /* Guard eliminated. */ + MAX_FOLD +}; + +#define INTFOLD(k) ((J->fold.ins.i = (k)), (TRef)KINTFOLD) +#define INT64FOLD(k) (lj_ir_kint64(J, (k))) +#define CONDFOLD(cond) ((TRef)FAILFOLD + (TRef)(cond)) +#define LEFTFOLD (J->fold.ins.op1) +#define RIGHTFOLD (J->fold.ins.op2) +#define CSEFOLD (lj_opt_cse(J)) +#define EMITFOLD (lj_ir_emit(J)) + +/* Load/store forwarding. */ +LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_aload(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_hload(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_uload(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_fload(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_xload(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_tab_len(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_hrefk(jit_State *J); +LJ_FUNC int LJ_FASTCALL lj_opt_fwd_href_nokey(jit_State *J); +LJ_FUNC int LJ_FASTCALL lj_opt_fwd_tptr(jit_State *J, IRRef lim); +LJ_FUNC int lj_opt_fwd_wasnonnil(jit_State *J, IROpT loadop, IRRef xref); + +/* Dead-store elimination. */ +LJ_FUNC TRef LJ_FASTCALL lj_opt_dse_ahstore(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_dse_ustore(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_dse_fstore(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_dse_xstore(jit_State *J); + +/* Narrowing. */ +LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_convert(jit_State *J); +LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_index(jit_State *J, TRef key); +LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_toint(jit_State *J, TRef tr); +LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_tobit(jit_State *J, TRef tr); +#if LJ_HASFFI +LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_cindex(jit_State *J, TRef key); +#endif +LJ_FUNC TRef lj_opt_narrow_arith(jit_State *J, TRef rb, TRef rc, + TValue *vb, TValue *vc, IROp op); +LJ_FUNC TRef lj_opt_narrow_unm(jit_State *J, TRef rc, TValue *vc); +LJ_FUNC TRef lj_opt_narrow_mod(jit_State *J, TRef rb, TRef rc, TValue *vc); +LJ_FUNC TRef lj_opt_narrow_pow(jit_State *J, TRef rb, TRef rc, TValue *vc); +LJ_FUNC IRType lj_opt_narrow_forl(jit_State *J, cTValue *forbase); + +/* Optimization passes. */ +LJ_FUNC void lj_opt_dce(jit_State *J); +LJ_FUNC int lj_opt_loop(jit_State *J); +#if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) +LJ_FUNC void lj_opt_split(jit_State *J); +#else +#define lj_opt_split(J) UNUSED(J) +#endif +LJ_FUNC void lj_opt_sink(jit_State *J); + +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_jit.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_jit.h new file mode 100644 index 000000000..eb7654770 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_jit.h @@ -0,0 +1,417 @@ +/* +** Common definitions for the JIT compiler. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_JIT_H +#define _LJ_JIT_H + +#include "lj_obj.h" +#include "lj_ir.h" + +/* JIT engine flags. */ +#define JIT_F_ON 0x00000001 + +/* CPU-specific JIT engine flags. */ +#if LJ_TARGET_X86ORX64 +#define JIT_F_CMOV 0x00000010 +#define JIT_F_SSE2 0x00000020 +#define JIT_F_SSE3 0x00000040 +#define JIT_F_SSE4_1 0x00000080 +#define JIT_F_P4 0x00000100 +#define JIT_F_PREFER_IMUL 0x00000200 +#define JIT_F_SPLIT_XMM 0x00000400 +#define JIT_F_LEA_AGU 0x00000800 + +/* Names for the CPU-specific flags. Must match the order above. */ +#define JIT_F_CPU_FIRST JIT_F_CMOV +#define JIT_F_CPUSTRING "\4CMOV\4SSE2\4SSE3\6SSE4.1\2P4\3AMD\2K8\4ATOM" +#elif LJ_TARGET_ARM +#define JIT_F_ARMV6_ 0x00000010 +#define JIT_F_ARMV6T2_ 0x00000020 +#define JIT_F_ARMV7 0x00000040 +#define JIT_F_VFPV2 0x00000080 +#define JIT_F_VFPV3 0x00000100 + +#define JIT_F_ARMV6 (JIT_F_ARMV6_|JIT_F_ARMV6T2_|JIT_F_ARMV7) +#define JIT_F_ARMV6T2 (JIT_F_ARMV6T2_|JIT_F_ARMV7) +#define JIT_F_VFP (JIT_F_VFPV2|JIT_F_VFPV3) + +/* Names for the CPU-specific flags. Must match the order above. */ +#define JIT_F_CPU_FIRST JIT_F_ARMV6_ +#define JIT_F_CPUSTRING "\5ARMv6\7ARMv6T2\5ARMv7\5VFPv2\5VFPv3" +#elif LJ_TARGET_PPC +#define JIT_F_SQRT 0x00000010 +#define JIT_F_ROUND 0x00000020 + +/* Names for the CPU-specific flags. Must match the order above. */ +#define JIT_F_CPU_FIRST JIT_F_SQRT +#define JIT_F_CPUSTRING "\4SQRT\5ROUND" +#elif LJ_TARGET_MIPS +#define JIT_F_MIPS32R2 0x00000010 + +/* Names for the CPU-specific flags. Must match the order above. */ +#define JIT_F_CPU_FIRST JIT_F_MIPS32R2 +#define JIT_F_CPUSTRING "\010MIPS32R2" +#else +#define JIT_F_CPU_FIRST 0 +#define JIT_F_CPUSTRING "" +#endif + +/* Optimization flags. */ +#define JIT_F_OPT_MASK 0x0fff0000 + +#define JIT_F_OPT_FOLD 0x00010000 +#define JIT_F_OPT_CSE 0x00020000 +#define JIT_F_OPT_DCE 0x00040000 +#define JIT_F_OPT_FWD 0x00080000 +#define JIT_F_OPT_DSE 0x00100000 +#define JIT_F_OPT_NARROW 0x00200000 +#define JIT_F_OPT_LOOP 0x00400000 +#define JIT_F_OPT_ABC 0x00800000 +#define JIT_F_OPT_SINK 0x01000000 +#define JIT_F_OPT_FUSE 0x02000000 + +/* Optimizations names for -O. Must match the order above. */ +#define JIT_F_OPT_FIRST JIT_F_OPT_FOLD +#define JIT_F_OPTSTRING \ + "\4fold\3cse\3dce\3fwd\3dse\6narrow\4loop\3abc\4sink\4fuse" + +/* Optimization levels set a fixed combination of flags. */ +#define JIT_F_OPT_0 0 +#define JIT_F_OPT_1 (JIT_F_OPT_FOLD|JIT_F_OPT_CSE|JIT_F_OPT_DCE) +#define JIT_F_OPT_2 (JIT_F_OPT_1|JIT_F_OPT_NARROW|JIT_F_OPT_LOOP) +#define JIT_F_OPT_3 (JIT_F_OPT_2|\ + JIT_F_OPT_FWD|JIT_F_OPT_DSE|JIT_F_OPT_ABC|JIT_F_OPT_SINK|JIT_F_OPT_FUSE) +#define JIT_F_OPT_DEFAULT JIT_F_OPT_3 + +#if LJ_TARGET_WINDOWS || LJ_64 +/* See: http://blogs.msdn.com/oldnewthing/archive/2003/10/08/55239.aspx */ +#define JIT_P_sizemcode_DEFAULT 64 +#else +/* Could go as low as 4K, but the mmap() overhead would be rather high. */ +#define JIT_P_sizemcode_DEFAULT 32 +#endif + +/* Optimization parameters and their defaults. Length is a char in octal! */ +#define JIT_PARAMDEF(_) \ + _(\010, maxtrace, 1000) /* Max. # of traces in cache. */ \ + _(\011, maxrecord, 4000) /* Max. # of recorded IR instructions. */ \ + _(\012, maxirconst, 500) /* Max. # of IR constants of a trace. */ \ + _(\007, maxside, 100) /* Max. # of side traces of a root trace. */ \ + _(\007, maxsnap, 500) /* Max. # of snapshots for a trace. */ \ + \ + _(\007, hotloop, 56) /* # of iter. to detect a hot loop/call. */ \ + _(\007, hotexit, 10) /* # of taken exits to start a side trace. */ \ + _(\007, tryside, 4) /* # of attempts to compile a side trace. */ \ + \ + _(\012, instunroll, 4) /* Max. unroll for instable loops. */ \ + _(\012, loopunroll, 15) /* Max. unroll for loop ops in side traces. */ \ + _(\012, callunroll, 3) /* Max. unroll for recursive calls. */ \ + _(\011, recunroll, 2) /* Min. unroll for true recursion. */ \ + \ + /* Size of each machine code area (in KBytes). */ \ + _(\011, sizemcode, JIT_P_sizemcode_DEFAULT) \ + /* Max. total size of all machine code areas (in KBytes). */ \ + _(\010, maxmcode, 512) \ + /* End of list. */ + +enum { +#define JIT_PARAMENUM(len, name, value) JIT_P_##name, +JIT_PARAMDEF(JIT_PARAMENUM) +#undef JIT_PARAMENUM + JIT_P__MAX +}; + +#define JIT_PARAMSTR(len, name, value) #len #name +#define JIT_P_STRING JIT_PARAMDEF(JIT_PARAMSTR) + +/* Trace compiler state. */ +typedef enum { + LJ_TRACE_IDLE, /* Trace compiler idle. */ + LJ_TRACE_ACTIVE = 0x10, + LJ_TRACE_RECORD, /* Bytecode recording active. */ + LJ_TRACE_START, /* New trace started. */ + LJ_TRACE_END, /* End of trace. */ + LJ_TRACE_ASM, /* Assemble trace. */ + LJ_TRACE_ERR /* Trace aborted with error. */ +} TraceState; + +/* Post-processing action. */ +typedef enum { + LJ_POST_NONE, /* No action. */ + LJ_POST_FIXCOMP, /* Fixup comparison and emit pending guard. */ + LJ_POST_FIXGUARD, /* Fixup and emit pending guard. */ + LJ_POST_FIXGUARDSNAP, /* Fixup and emit pending guard and snapshot. */ + LJ_POST_FIXBOOL, /* Fixup boolean result. */ + LJ_POST_FIXCONST, /* Fixup constant results. */ + LJ_POST_FFRETRY /* Suppress recording of retried fast functions. */ +} PostProc; + +/* Machine code type. */ +#if LJ_TARGET_X86ORX64 +typedef uint8_t MCode; +#else +typedef uint32_t MCode; +#endif + +/* Stack snapshot header. */ +typedef struct SnapShot { + uint16_t mapofs; /* Offset into snapshot map. */ + IRRef1 ref; /* First IR ref for this snapshot. */ + uint8_t nslots; /* Number of valid slots. */ + uint8_t topslot; /* Maximum frame extent. */ + uint8_t nent; /* Number of compressed entries. */ + uint8_t count; /* Count of taken exits for this snapshot. */ +} SnapShot; + +#define SNAPCOUNT_DONE 255 /* Already compiled and linked a side trace. */ + +/* Compressed snapshot entry. */ +typedef uint32_t SnapEntry; + +#define SNAP_FRAME 0x010000 /* Frame slot. */ +#define SNAP_CONT 0x020000 /* Continuation slot. */ +#define SNAP_NORESTORE 0x040000 /* No need to restore slot. */ +#define SNAP_SOFTFPNUM 0x080000 /* Soft-float number. */ +LJ_STATIC_ASSERT(SNAP_FRAME == TREF_FRAME); +LJ_STATIC_ASSERT(SNAP_CONT == TREF_CONT); + +#define SNAP(slot, flags, ref) (((SnapEntry)(slot) << 24) + (flags) + (ref)) +#define SNAP_TR(slot, tr) \ + (((SnapEntry)(slot) << 24) + ((tr) & (TREF_CONT|TREF_FRAME|TREF_REFMASK))) +#define SNAP_MKPC(pc) ((SnapEntry)u32ptr(pc)) +#define SNAP_MKFTSZ(ftsz) ((SnapEntry)(ftsz)) +#define snap_ref(sn) ((sn) & 0xffff) +#define snap_slot(sn) ((BCReg)((sn) >> 24)) +#define snap_isframe(sn) ((sn) & SNAP_FRAME) +#define snap_pc(sn) ((const BCIns *)(uintptr_t)(sn)) +#define snap_setref(sn, ref) (((sn) & (0xffff0000&~SNAP_NORESTORE)) | (ref)) + +/* Snapshot and exit numbers. */ +typedef uint32_t SnapNo; +typedef uint32_t ExitNo; + +/* Trace number. */ +typedef uint32_t TraceNo; /* Used to pass around trace numbers. */ +typedef uint16_t TraceNo1; /* Stored trace number. */ + +/* Type of link. ORDER LJ_TRLINK */ +typedef enum { + LJ_TRLINK_NONE, /* Incomplete trace. No link, yet. */ + LJ_TRLINK_ROOT, /* Link to other root trace. */ + LJ_TRLINK_LOOP, /* Loop to same trace. */ + LJ_TRLINK_TAILREC, /* Tail-recursion. */ + LJ_TRLINK_UPREC, /* Up-recursion. */ + LJ_TRLINK_DOWNREC, /* Down-recursion. */ + LJ_TRLINK_INTERP, /* Fallback to interpreter. */ + LJ_TRLINK_RETURN /* Return to interpreter. */ +} TraceLink; + +/* Trace object. */ +typedef struct GCtrace { + GCHeader; + uint8_t topslot; /* Top stack slot already checked to be allocated. */ + uint8_t linktype; /* Type of link. */ + IRRef nins; /* Next IR instruction. Biased with REF_BIAS. */ + GCRef gclist; + IRIns *ir; /* IR instructions/constants. Biased with REF_BIAS. */ + IRRef nk; /* Lowest IR constant. Biased with REF_BIAS. */ + uint16_t nsnap; /* Number of snapshots. */ + uint16_t nsnapmap; /* Number of snapshot map elements. */ + SnapShot *snap; /* Snapshot array. */ + SnapEntry *snapmap; /* Snapshot map. */ + GCRef startpt; /* Starting prototype. */ + MRef startpc; /* Bytecode PC of starting instruction. */ + BCIns startins; /* Original bytecode of starting instruction. */ + MSize szmcode; /* Size of machine code. */ + MCode *mcode; /* Start of machine code. */ + MSize mcloop; /* Offset of loop start in machine code. */ + uint16_t nchild; /* Number of child traces (root trace only). */ + uint16_t spadjust; /* Stack pointer adjustment (offset in bytes). */ + TraceNo1 traceno; /* Trace number. */ + TraceNo1 link; /* Linked trace (or self for loops). */ + TraceNo1 root; /* Root trace of side trace (or 0 for root traces). */ + TraceNo1 nextroot; /* Next root trace for same prototype. */ + TraceNo1 nextside; /* Next side trace of same root trace. */ + uint8_t sinktags; /* Trace has SINK tags. */ + uint8_t unused1; +#ifdef LUAJIT_USE_GDBJIT + void *gdbjit_entry; /* GDB JIT entry. */ +#endif +} GCtrace; + +#define gco2trace(o) check_exp((o)->gch.gct == ~LJ_TTRACE, (GCtrace *)(o)) +#define traceref(J, n) \ + check_exp((n)>0 && (MSize)(n)sizetrace, (GCtrace *)gcref(J->trace[(n)])) + +LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCtrace, gclist)); + +static LJ_AINLINE MSize snap_nextofs(GCtrace *T, SnapShot *snap) +{ + if (snap+1 == &T->snap[T->nsnap]) + return T->nsnapmap; + else + return (snap+1)->mapofs; +} + +/* Round-robin penalty cache for bytecodes leading to aborted traces. */ +typedef struct HotPenalty { + MRef pc; /* Starting bytecode PC. */ + uint16_t val; /* Penalty value, i.e. hotcount start. */ + uint16_t reason; /* Abort reason (really TraceErr). */ +} HotPenalty; + +#define PENALTY_SLOTS 64 /* Penalty cache slot. Must be a power of 2. */ +#define PENALTY_MIN (36*2) /* Minimum penalty value. */ +#define PENALTY_MAX 60000 /* Maximum penalty value. */ +#define PENALTY_RNDBITS 4 /* # of random bits to add to penalty value. */ + +/* Round-robin backpropagation cache for narrowing conversions. */ +typedef struct BPropEntry { + IRRef1 key; /* Key: original reference. */ + IRRef1 val; /* Value: reference after conversion. */ + IRRef mode; /* Mode for this entry (currently IRCONV_*). */ +} BPropEntry; + +/* Number of slots for the backpropagation cache. Must be a power of 2. */ +#define BPROP_SLOTS 16 + +/* Scalar evolution analysis cache. */ +typedef struct ScEvEntry { + MRef pc; /* Bytecode PC of FORI. */ + IRRef1 idx; /* Index reference. */ + IRRef1 start; /* Constant start reference. */ + IRRef1 stop; /* Constant stop reference. */ + IRRef1 step; /* Constant step reference. */ + IRType1 t; /* Scalar type. */ + uint8_t dir; /* Direction. 1: +, 0: -. */ +} ScEvEntry; + +/* 128 bit SIMD constants. */ +enum { + LJ_KSIMD_ABS, + LJ_KSIMD_NEG, + LJ_KSIMD__MAX +}; + +/* Get 16 byte aligned pointer to SIMD constant. */ +#define LJ_KSIMD(J, n) \ + ((TValue *)(((intptr_t)&J->ksimd[2*(n)] + 15) & ~(intptr_t)15)) + +/* Set/reset flag to activate the SPLIT pass for the current trace. */ +#if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) +#define lj_needsplit(J) (J->needsplit = 1) +#define lj_resetsplit(J) (J->needsplit = 0) +#else +#define lj_needsplit(J) UNUSED(J) +#define lj_resetsplit(J) UNUSED(J) +#endif + +/* Fold state is used to fold instructions on-the-fly. */ +typedef struct FoldState { + IRIns ins; /* Currently emitted instruction. */ + IRIns left; /* Instruction referenced by left operand. */ + IRIns right; /* Instruction referenced by right operand. */ +} FoldState; + +/* JIT compiler state. */ +typedef struct jit_State { + GCtrace cur; /* Current trace. */ + + lua_State *L; /* Current Lua state. */ + const BCIns *pc; /* Current PC. */ + GCfunc *fn; /* Current function. */ + GCproto *pt; /* Current prototype. */ + TRef *base; /* Current frame base, points into J->slots. */ + + uint32_t flags; /* JIT engine flags. */ + BCReg maxslot; /* Relative to baseslot. */ + BCReg baseslot; /* Current frame base, offset into J->slots. */ + + uint8_t mergesnap; /* Allowed to merge with next snapshot. */ + uint8_t needsnap; /* Need snapshot before recording next bytecode. */ + IRType1 guardemit; /* Accumulated IRT_GUARD for emitted instructions. */ + uint8_t bcskip; /* Number of bytecode instructions to skip. */ + + FoldState fold; /* Fold state. */ + + const BCIns *bc_min; /* Start of allowed bytecode range for root trace. */ + MSize bc_extent; /* Extent of the range. */ + + TraceState state; /* Trace compiler state. */ + + int32_t instunroll; /* Unroll counter for instable loops. */ + int32_t loopunroll; /* Unroll counter for loop ops in side traces. */ + int32_t tailcalled; /* Number of successive tailcalls. */ + int32_t framedepth; /* Current frame depth. */ + int32_t retdepth; /* Return frame depth (count of RETF). */ + + MRef k64; /* Pointer to chained array of 64 bit constants. */ + TValue ksimd[LJ_KSIMD__MAX*2+1]; /* 16 byte aligned SIMD constants. */ + + IRIns *irbuf; /* Temp. IR instruction buffer. Biased with REF_BIAS. */ + IRRef irtoplim; /* Upper limit of instuction buffer (biased). */ + IRRef irbotlim; /* Lower limit of instuction buffer (biased). */ + IRRef loopref; /* Last loop reference or ref of final LOOP (or 0). */ + + MSize sizesnap; /* Size of temp. snapshot buffer. */ + SnapShot *snapbuf; /* Temp. snapshot buffer. */ + SnapEntry *snapmapbuf; /* Temp. snapshot map buffer. */ + MSize sizesnapmap; /* Size of temp. snapshot map buffer. */ + + PostProc postproc; /* Required post-processing after execution. */ +#if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) + int needsplit; /* Need SPLIT pass. */ +#endif + + GCRef *trace; /* Array of traces. */ + TraceNo freetrace; /* Start of scan for next free trace. */ + MSize sizetrace; /* Size of trace array. */ + + IRRef1 chain[IR__MAX]; /* IR instruction skip-list chain anchors. */ + TRef slot[LJ_MAX_JSLOTS+LJ_STACK_EXTRA]; /* Stack slot map. */ + + int32_t param[JIT_P__MAX]; /* JIT engine parameters. */ + + MCode *exitstubgroup[LJ_MAX_EXITSTUBGR]; /* Exit stub group addresses. */ + + HotPenalty penalty[PENALTY_SLOTS]; /* Penalty slots. */ + uint32_t penaltyslot; /* Round-robin index into penalty slots. */ + uint32_t prngstate; /* PRNG state. */ + + BPropEntry bpropcache[BPROP_SLOTS]; /* Backpropagation cache slots. */ + uint32_t bpropslot; /* Round-robin index into bpropcache slots. */ + + ScEvEntry scev; /* Scalar evolution analysis cache slots. */ + + const BCIns *startpc; /* Bytecode PC of starting instruction. */ + TraceNo parent; /* Parent of current side trace (0 for root traces). */ + ExitNo exitno; /* Exit number in parent of current side trace. */ + + BCIns *patchpc; /* PC for pending re-patch. */ + BCIns patchins; /* Instruction for pending re-patch. */ + + int mcprot; /* Protection of current mcode area. */ + MCode *mcarea; /* Base of current mcode area. */ + MCode *mctop; /* Top of current mcode area. */ + MCode *mcbot; /* Bottom of current mcode area. */ + size_t szmcarea; /* Size of current mcode area. */ + size_t szallmcarea; /* Total size of all allocated mcode areas. */ + + TValue errinfo; /* Additional info element for trace errors. */ +} +#if LJ_TARGET_ARM +LJ_ALIGN(16) /* For DISPATCH-relative addresses in assembler part. */ +#endif +jit_State; + +/* Trivial PRNG e.g. used for penalty randomization. */ +static LJ_AINLINE uint32_t LJ_PRNG_BITS(jit_State *J, int bits) +{ + /* Yes, this LCG is very weak, but that doesn't matter for our use case. */ + J->prngstate = J->prngstate * 1103515245 + 12345; + return J->prngstate >> (32-bits); +} + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_lex.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_lex.c new file mode 100644 index 000000000..e1dc3cdfd --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_lex.c @@ -0,0 +1,482 @@ +/* +** Lexical analyzer. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lj_lex_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#if LJ_HASFFI +#include "lj_tab.h" +#include "lj_ctype.h" +#include "lj_cdata.h" +#include "lualib.h" +#endif +#include "lj_state.h" +#include "lj_lex.h" +#include "lj_parse.h" +#include "lj_char.h" +#include "lj_strscan.h" + +/* Lua lexer token names. */ +static const char *const tokennames[] = { +#define TKSTR1(name) #name, +#define TKSTR2(name, sym) #sym, +TKDEF(TKSTR1, TKSTR2) +#undef TKSTR1 +#undef TKSTR2 + NULL +}; + +/* -- Buffer handling ----------------------------------------------------- */ + +#define char2int(c) ((int)(uint8_t)(c)) +#define next(ls) \ + (ls->current = (ls->n--) > 0 ? char2int(*ls->p++) : fillbuf(ls)) +#define save_and_next(ls) (save(ls, ls->current), next(ls)) +#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r') +#define END_OF_STREAM (-1) + +static int fillbuf(LexState *ls) +{ + size_t sz; + const char *buf = ls->rfunc(ls->L, ls->rdata, &sz); + if (buf == NULL || sz == 0) return END_OF_STREAM; + ls->n = (MSize)sz - 1; + ls->p = buf; + return char2int(*(ls->p++)); +} + +static LJ_NOINLINE void save_grow(LexState *ls, int c) +{ + MSize newsize; + if (ls->sb.sz >= LJ_MAX_STR/2) + lj_lex_error(ls, 0, LJ_ERR_XELEM); + newsize = ls->sb.sz * 2; + lj_str_resizebuf(ls->L, &ls->sb, newsize); + ls->sb.buf[ls->sb.n++] = (char)c; +} + +static LJ_AINLINE void save(LexState *ls, int c) +{ + if (LJ_UNLIKELY(ls->sb.n + 1 > ls->sb.sz)) + save_grow(ls, c); + else + ls->sb.buf[ls->sb.n++] = (char)c; +} + +static void inclinenumber(LexState *ls) +{ + int old = ls->current; + lua_assert(currIsNewline(ls)); + next(ls); /* skip `\n' or `\r' */ + if (currIsNewline(ls) && ls->current != old) + next(ls); /* skip `\n\r' or `\r\n' */ + if (++ls->linenumber >= LJ_MAX_LINE) + lj_lex_error(ls, ls->token, LJ_ERR_XLINES); +} + +/* -- Scanner for terminals ----------------------------------------------- */ + +/* Parse a number literal. */ +static void lex_number(LexState *ls, TValue *tv) +{ + StrScanFmt fmt; + int c, xp = 'e'; + lua_assert(lj_char_isdigit(ls->current)); + if ((c = ls->current) == '0') { + save_and_next(ls); + if ((ls->current | 0x20) == 'x') xp = 'p'; + } + while (lj_char_isident(ls->current) || ls->current == '.' || + ((ls->current == '-' || ls->current == '+') && (c | 0x20) == xp)) { + c = ls->current; + save_and_next(ls); + } + save(ls, '\0'); + fmt = lj_strscan_scan((const uint8_t *)ls->sb.buf, tv, + (LJ_DUALNUM ? STRSCAN_OPT_TOINT : STRSCAN_OPT_TONUM) | + (LJ_HASFFI ? (STRSCAN_OPT_LL|STRSCAN_OPT_IMAG) : 0)); + if (LJ_DUALNUM && fmt == STRSCAN_INT) { + setitype(tv, LJ_TISNUM); + } else if (fmt == STRSCAN_NUM) { + /* Already in correct format. */ +#if LJ_HASFFI + } else if (fmt != STRSCAN_ERROR) { + lua_State *L = ls->L; + GCcdata *cd; + lua_assert(fmt == STRSCAN_I64 || fmt == STRSCAN_U64 || fmt == STRSCAN_IMAG); + if (!ctype_ctsG(G(L))) { + ptrdiff_t oldtop = savestack(L, L->top); + luaopen_ffi(L); /* Load FFI library on-demand. */ + L->top = restorestack(L, oldtop); + } + if (fmt == STRSCAN_IMAG) { + cd = lj_cdata_new_(L, CTID_COMPLEX_DOUBLE, 2*sizeof(double)); + ((double *)cdataptr(cd))[0] = 0; + ((double *)cdataptr(cd))[1] = numV(tv); + } else { + cd = lj_cdata_new_(L, fmt==STRSCAN_I64 ? CTID_INT64 : CTID_UINT64, 8); + *(uint64_t *)cdataptr(cd) = tv->u64; + } + lj_parse_keepcdata(ls, tv, cd); +#endif + } else { + lua_assert(fmt == STRSCAN_ERROR); + lj_lex_error(ls, TK_number, LJ_ERR_XNUMBER); + } +} + +static int skip_sep(LexState *ls) +{ + int count = 0; + int s = ls->current; + lua_assert(s == '[' || s == ']'); + save_and_next(ls); + while (ls->current == '=') { + save_and_next(ls); + count++; + } + return (ls->current == s) ? count : (-count) - 1; +} + +static void read_long_string(LexState *ls, TValue *tv, int sep) +{ + save_and_next(ls); /* skip 2nd `[' */ + if (currIsNewline(ls)) /* string starts with a newline? */ + inclinenumber(ls); /* skip it */ + for (;;) { + switch (ls->current) { + case END_OF_STREAM: + lj_lex_error(ls, TK_eof, tv ? LJ_ERR_XLSTR : LJ_ERR_XLCOM); + break; + case ']': + if (skip_sep(ls) == sep) { + save_and_next(ls); /* skip 2nd `]' */ + goto endloop; + } + break; + case '\n': + case '\r': + save(ls, '\n'); + inclinenumber(ls); + if (!tv) lj_str_resetbuf(&ls->sb); /* avoid wasting space */ + break; + default: + if (tv) save_and_next(ls); + else next(ls); + break; + } + } endloop: + if (tv) { + GCstr *str = lj_parse_keepstr(ls, ls->sb.buf + (2 + (MSize)sep), + ls->sb.n - 2*(2 + (MSize)sep)); + setstrV(ls->L, tv, str); + } +} + +static void read_string(LexState *ls, int delim, TValue *tv) +{ + save_and_next(ls); + while (ls->current != delim) { + switch (ls->current) { + case END_OF_STREAM: + lj_lex_error(ls, TK_eof, LJ_ERR_XSTR); + continue; + case '\n': + case '\r': + lj_lex_error(ls, TK_string, LJ_ERR_XSTR); + continue; + case '\\': { + int c = next(ls); /* Skip the '\\'. */ + switch (c) { + case 'a': c = '\a'; break; + case 'b': c = '\b'; break; + case 'f': c = '\f'; break; + case 'n': c = '\n'; break; + case 'r': c = '\r'; break; + case 't': c = '\t'; break; + case 'v': c = '\v'; break; + case 'x': /* Hexadecimal escape '\xXX'. */ + c = (next(ls) & 15u) << 4; + if (!lj_char_isdigit(ls->current)) { + if (!lj_char_isxdigit(ls->current)) goto err_xesc; + c += 9 << 4; + } + c += (next(ls) & 15u); + if (!lj_char_isdigit(ls->current)) { + if (!lj_char_isxdigit(ls->current)) goto err_xesc; + c += 9; + } + break; + case 'z': /* Skip whitespace. */ + next(ls); + while (lj_char_isspace(ls->current)) + if (currIsNewline(ls)) inclinenumber(ls); else next(ls); + continue; + case '\n': case '\r': save(ls, '\n'); inclinenumber(ls); continue; + case '\\': case '\"': case '\'': break; + case END_OF_STREAM: continue; + default: + if (!lj_char_isdigit(c)) + goto err_xesc; + c -= '0'; /* Decimal escape '\ddd'. */ + if (lj_char_isdigit(next(ls))) { + c = c*10 + (ls->current - '0'); + if (lj_char_isdigit(next(ls))) { + c = c*10 + (ls->current - '0'); + if (c > 255) { + err_xesc: + lj_lex_error(ls, TK_string, LJ_ERR_XESC); + } + next(ls); + } + } + save(ls, c); + continue; + } + save(ls, c); + next(ls); + continue; + } + default: + save_and_next(ls); + break; + } + } + save_and_next(ls); /* skip delimiter */ + setstrV(ls->L, tv, lj_parse_keepstr(ls, ls->sb.buf + 1, ls->sb.n - 2)); +} + +/* -- Main lexical scanner ------------------------------------------------ */ + +static int llex(LexState *ls, TValue *tv) +{ + lj_str_resetbuf(&ls->sb); + for (;;) { + if (lj_char_isident(ls->current)) { + GCstr *s; + if (lj_char_isdigit(ls->current)) { /* Numeric literal. */ + lex_number(ls, tv); + return TK_number; + } + /* Identifier or reserved word. */ + do { + save_and_next(ls); + } while (lj_char_isident(ls->current)); + s = lj_parse_keepstr(ls, ls->sb.buf, ls->sb.n); + setstrV(ls->L, tv, s); + if (s->reserved > 0) /* Reserved word? */ + return TK_OFS + s->reserved; + return TK_name; + } + switch (ls->current) { + case '\n': + case '\r': + inclinenumber(ls); + continue; + case ' ': + case '\t': + case '\v': + case '\f': + next(ls); + continue; + case '-': + next(ls); + if (ls->current != '-') return '-'; + /* else is a comment */ + next(ls); + if (ls->current == '[') { + int sep = skip_sep(ls); + lj_str_resetbuf(&ls->sb); /* `skip_sep' may dirty the buffer */ + if (sep >= 0) { + read_long_string(ls, NULL, sep); /* long comment */ + lj_str_resetbuf(&ls->sb); + continue; + } + } + /* else short comment */ + while (!currIsNewline(ls) && ls->current != END_OF_STREAM) + next(ls); + continue; + case '[': { + int sep = skip_sep(ls); + if (sep >= 0) { + read_long_string(ls, tv, sep); + return TK_string; + } else if (sep == -1) { + return '['; + } else { + lj_lex_error(ls, TK_string, LJ_ERR_XLDELIM); + continue; + } + } + case '=': + next(ls); + if (ls->current != '=') return '='; else { next(ls); return TK_eq; } + case '<': + next(ls); + if (ls->current != '=') return '<'; else { next(ls); return TK_le; } + case '>': + next(ls); + if (ls->current != '=') return '>'; else { next(ls); return TK_ge; } + case '~': + next(ls); + if (ls->current != '=') return '~'; else { next(ls); return TK_ne; } + case ':': + next(ls); + if (ls->current != ':') return ':'; else { next(ls); return TK_label; } + case '"': + case '\'': + read_string(ls, ls->current, tv); + return TK_string; + case '.': + save_and_next(ls); + if (ls->current == '.') { + next(ls); + if (ls->current == '.') { + next(ls); + return TK_dots; /* ... */ + } + return TK_concat; /* .. */ + } else if (!lj_char_isdigit(ls->current)) { + return '.'; + } else { + lex_number(ls, tv); + return TK_number; + } + case END_OF_STREAM: + return TK_eof; + default: { + int c = ls->current; + next(ls); + return c; /* Single-char tokens (+ - / ...). */ + } + } + } +} + +/* -- Lexer API ----------------------------------------------------------- */ + +/* Setup lexer state. */ +int lj_lex_setup(lua_State *L, LexState *ls) +{ + int header = 0; + ls->L = L; + ls->fs = NULL; + ls->n = 0; + ls->p = NULL; + ls->vstack = NULL; + ls->sizevstack = 0; + ls->vtop = 0; + ls->bcstack = NULL; + ls->sizebcstack = 0; + ls->token = 0; + ls->lookahead = TK_eof; /* No look-ahead token. */ + ls->linenumber = 1; + ls->lastline = 1; + lj_str_resizebuf(ls->L, &ls->sb, LJ_MIN_SBUF); + next(ls); /* Read-ahead first char. */ + if (ls->current == 0xef && ls->n >= 2 && char2int(ls->p[0]) == 0xbb && + char2int(ls->p[1]) == 0xbf) { /* Skip UTF-8 BOM (if buffered). */ + ls->n -= 2; + ls->p += 2; + next(ls); + header = 1; + } + if (ls->current == '#') { /* Skip POSIX #! header line. */ + do { + next(ls); + if (ls->current == END_OF_STREAM) return 0; + } while (!currIsNewline(ls)); + inclinenumber(ls); + header = 1; + } + if (ls->current == LUA_SIGNATURE[0]) { /* Bytecode dump. */ + if (header) { + /* + ** Loading bytecode with an extra header is disabled for security + ** reasons. This may circumvent the usual check for bytecode vs. + ** Lua code by looking at the first char. Since this is a potential + ** security violation no attempt is made to echo the chunkname either. + */ + setstrV(L, L->top++, lj_err_str(L, LJ_ERR_BCBAD)); + lj_err_throw(L, LUA_ERRSYNTAX); + } + return 1; + } + return 0; +} + +/* Cleanup lexer state. */ +void lj_lex_cleanup(lua_State *L, LexState *ls) +{ + global_State *g = G(L); + lj_mem_freevec(g, ls->bcstack, ls->sizebcstack, BCInsLine); + lj_mem_freevec(g, ls->vstack, ls->sizevstack, VarInfo); + lj_str_freebuf(g, &ls->sb); +} + +void lj_lex_next(LexState *ls) +{ + ls->lastline = ls->linenumber; + if (LJ_LIKELY(ls->lookahead == TK_eof)) { /* No lookahead token? */ + ls->token = llex(ls, &ls->tokenval); /* Get next token. */ + } else { /* Otherwise return lookahead token. */ + ls->token = ls->lookahead; + ls->lookahead = TK_eof; + ls->tokenval = ls->lookaheadval; + } +} + +LexToken lj_lex_lookahead(LexState *ls) +{ + lua_assert(ls->lookahead == TK_eof); + ls->lookahead = llex(ls, &ls->lookaheadval); + return ls->lookahead; +} + +const char *lj_lex_token2str(LexState *ls, LexToken token) +{ + if (token > TK_OFS) + return tokennames[token-TK_OFS-1]; + else if (!lj_char_iscntrl(token)) + return lj_str_pushf(ls->L, "%c", token); + else + return lj_str_pushf(ls->L, "char(%d)", token); +} + +void lj_lex_error(LexState *ls, LexToken token, ErrMsg em, ...) +{ + const char *tok; + va_list argp; + if (token == 0) { + tok = NULL; + } else if (token == TK_name || token == TK_string || token == TK_number) { + save(ls, '\0'); + tok = ls->sb.buf; + } else { + tok = lj_lex_token2str(ls, token); + } + va_start(argp, em); + lj_err_lex(ls->L, ls->chunkname, tok, ls->linenumber, em, argp); + va_end(argp); +} + +void lj_lex_init(lua_State *L) +{ + uint32_t i; + for (i = 0; i < TK_RESERVED; i++) { + GCstr *s = lj_str_newz(L, tokennames[i]); + fixstring(s); /* Reserved words are never collected. */ + s->reserved = (uint8_t)(i+1); + } +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_lex.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_lex.h new file mode 100644 index 000000000..fe0176864 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_lex.h @@ -0,0 +1,85 @@ +/* +** Lexical analyzer. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_LEX_H +#define _LJ_LEX_H + +#include + +#include "lj_obj.h" +#include "lj_err.h" + +/* Lua lexer tokens. */ +#define TKDEF(_, __) \ + _(and) _(break) _(do) _(else) _(elseif) _(end) _(false) \ + _(for) _(function) _(goto) _(if) _(in) _(local) _(nil) _(not) _(or) \ + _(repeat) _(return) _(then) _(true) _(until) _(while) \ + __(concat, ..) __(dots, ...) __(eq, ==) __(ge, >=) __(le, <=) __(ne, ~=) \ + __(label, ::) __(number, ) __(name, ) __(string, ) \ + __(eof, ) + +enum { + TK_OFS = 256, +#define TKENUM1(name) TK_##name, +#define TKENUM2(name, sym) TK_##name, +TKDEF(TKENUM1, TKENUM2) +#undef TKENUM1 +#undef TKENUM2 + TK_RESERVED = TK_while - TK_OFS +}; + +typedef int LexToken; + +/* Combined bytecode ins/line. Only used during bytecode generation. */ +typedef struct BCInsLine { + BCIns ins; /* Bytecode instruction. */ + BCLine line; /* Line number for this bytecode. */ +} BCInsLine; + +/* Info for local variables. Only used during bytecode generation. */ +typedef struct VarInfo { + GCRef name; /* Local variable name or goto/label name. */ + BCPos startpc; /* First point where the local variable is active. */ + BCPos endpc; /* First point where the local variable is dead. */ + uint8_t slot; /* Variable slot. */ + uint8_t info; /* Variable/goto/label info. */ +} VarInfo; + +/* Lua lexer state. */ +typedef struct LexState { + struct FuncState *fs; /* Current FuncState. Defined in lj_parse.c. */ + struct lua_State *L; /* Lua state. */ + TValue tokenval; /* Current token value. */ + TValue lookaheadval; /* Lookahead token value. */ + int current; /* Current character (charint). */ + LexToken token; /* Current token. */ + LexToken lookahead; /* Lookahead token. */ + MSize n; /* Bytes left in input buffer. */ + const char *p; /* Current position in input buffer. */ + SBuf sb; /* String buffer for tokens. */ + lua_Reader rfunc; /* Reader callback. */ + void *rdata; /* Reader callback data. */ + BCLine linenumber; /* Input line counter. */ + BCLine lastline; /* Line of last token. */ + GCstr *chunkname; /* Current chunk name (interned string). */ + const char *chunkarg; /* Chunk name argument. */ + const char *mode; /* Allow loading bytecode (b) and/or source text (t). */ + VarInfo *vstack; /* Stack for names and extents of local variables. */ + MSize sizevstack; /* Size of variable stack. */ + MSize vtop; /* Top of variable stack. */ + BCInsLine *bcstack; /* Stack for bytecode instructions/line numbers. */ + MSize sizebcstack; /* Size of bytecode stack. */ + uint32_t level; /* Syntactical nesting level. */ +} LexState; + +LJ_FUNC int lj_lex_setup(lua_State *L, LexState *ls); +LJ_FUNC void lj_lex_cleanup(lua_State *L, LexState *ls); +LJ_FUNC void lj_lex_next(LexState *ls); +LJ_FUNC LexToken lj_lex_lookahead(LexState *ls); +LJ_FUNC const char *lj_lex_token2str(LexState *ls, LexToken token); +LJ_FUNC_NORET void lj_lex_error(LexState *ls, LexToken token, ErrMsg em, ...); +LJ_FUNC void lj_lex_init(lua_State *L); + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_lib.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_lib.c new file mode 100644 index 000000000..856685ee3 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_lib.c @@ -0,0 +1,258 @@ +/* +** Library function support. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_lib_c +#define LUA_CORE + +#include "lauxlib.h" + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_func.h" +#include "lj_bc.h" +#include "lj_dispatch.h" +#include "lj_vm.h" +#include "lj_strscan.h" +#include "lj_lib.h" + +/* -- Library initialization ---------------------------------------------- */ + +static GCtab *lib_create_table(lua_State *L, const char *libname, int hsize) +{ + if (libname) { + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 16); + lua_getfield(L, -1, libname); + if (!tvistab(L->top-1)) { + L->top--; + if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, hsize) != NULL) + lj_err_callerv(L, LJ_ERR_BADMODN, libname); + settabV(L, L->top, tabV(L->top-1)); + L->top++; + lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ + } + L->top--; + settabV(L, L->top-1, tabV(L->top)); + } else { + lua_createtable(L, 0, hsize); + } + return tabV(L->top-1); +} + +void lj_lib_register(lua_State *L, const char *libname, + const uint8_t *p, const lua_CFunction *cf) +{ + GCtab *env = tabref(L->env); + GCfunc *ofn = NULL; + int ffid = *p++; + BCIns *bcff = &L2GG(L)->bcff[*p++]; + GCtab *tab = lib_create_table(L, libname, *p++); + ptrdiff_t tpos = L->top - L->base; + + /* Avoid barriers further down. */ + lj_gc_anybarriert(L, tab); + tab->nomm = 0; + + for (;;) { + uint32_t tag = *p++; + MSize len = tag & LIBINIT_LENMASK; + tag &= LIBINIT_TAGMASK; + if (tag != LIBINIT_STRING) { + const char *name; + MSize nuv = (MSize)(L->top - L->base - tpos); + GCfunc *fn = lj_func_newC(L, nuv, env); + if (nuv) { + L->top = L->base + tpos; + memcpy(fn->c.upvalue, L->top, sizeof(TValue)*nuv); + } + fn->c.ffid = (uint8_t)(ffid++); + name = (const char *)p; + p += len; + if (tag == LIBINIT_CF) + setmref(fn->c.pc, &G(L)->bc_cfunc_int); + else + setmref(fn->c.pc, bcff++); + if (tag == LIBINIT_ASM_) + fn->c.f = ofn->c.f; /* Copy handler from previous function. */ + else + fn->c.f = *cf++; /* Get cf or handler from C function table. */ + if (len) { + /* NOBARRIER: See above for common barrier. */ + setfuncV(L, lj_tab_setstr(L, tab, lj_str_new(L, name, len)), fn); + } + ofn = fn; + } else { + switch (tag | len) { + case LIBINIT_SET: + L->top -= 2; + if (tvisstr(L->top+1) && strV(L->top+1)->len == 0) + env = tabV(L->top); + else /* NOBARRIER: See above for common barrier. */ + copyTV(L, lj_tab_set(L, tab, L->top+1), L->top); + break; + case LIBINIT_NUMBER: + memcpy(&L->top->n, p, sizeof(double)); + L->top++; + p += sizeof(double); + break; + case LIBINIT_COPY: + copyTV(L, L->top, L->top - *p++); + L->top++; + break; + case LIBINIT_LASTCL: + setfuncV(L, L->top++, ofn); + break; + case LIBINIT_FFID: + ffid++; + break; + case LIBINIT_END: + return; + default: + setstrV(L, L->top++, lj_str_new(L, (const char *)p, len)); + p += len; + break; + } + } + } +} + +/* -- Type checks --------------------------------------------------------- */ + +TValue *lj_lib_checkany(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (o >= L->top) + lj_err_arg(L, narg, LJ_ERR_NOVAL); + return o; +} + +GCstr *lj_lib_checkstr(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (o < L->top) { + if (LJ_LIKELY(tvisstr(o))) { + return strV(o); + } else if (tvisnumber(o)) { + GCstr *s = lj_str_fromnumber(L, o); + setstrV(L, o, s); + return s; + } + } + lj_err_argt(L, narg, LUA_TSTRING); + return NULL; /* unreachable */ +} + +GCstr *lj_lib_optstr(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + return (o < L->top && !tvisnil(o)) ? lj_lib_checkstr(L, narg) : NULL; +} + +#if LJ_DUALNUM +void lj_lib_checknumber(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (!(o < L->top && lj_strscan_numberobj(o))) + lj_err_argt(L, narg, LUA_TNUMBER); +} +#endif + +lua_Number lj_lib_checknum(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (!(o < L->top && + (tvisnumber(o) || (tvisstr(o) && lj_strscan_num(strV(o), o))))) + lj_err_argt(L, narg, LUA_TNUMBER); + if (LJ_UNLIKELY(tvisint(o))) { + lua_Number n = (lua_Number)intV(o); + setnumV(o, n); + return n; + } else { + return numV(o); + } +} + +int32_t lj_lib_checkint(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (!(o < L->top && lj_strscan_numberobj(o))) + lj_err_argt(L, narg, LUA_TNUMBER); + if (LJ_LIKELY(tvisint(o))) { + return intV(o); + } else { + int32_t i = lj_num2int(numV(o)); + if (LJ_DUALNUM) setintV(o, i); + return i; + } +} + +int32_t lj_lib_optint(lua_State *L, int narg, int32_t def) +{ + TValue *o = L->base + narg-1; + return (o < L->top && !tvisnil(o)) ? lj_lib_checkint(L, narg) : def; +} + +int32_t lj_lib_checkbit(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (!(o < L->top && lj_strscan_numberobj(o))) + lj_err_argt(L, narg, LUA_TNUMBER); + if (LJ_LIKELY(tvisint(o))) { + return intV(o); + } else { + int32_t i = lj_num2bit(numV(o)); + if (LJ_DUALNUM) setintV(o, i); + return i; + } +} + +GCfunc *lj_lib_checkfunc(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (!(o < L->top && tvisfunc(o))) + lj_err_argt(L, narg, LUA_TFUNCTION); + return funcV(o); +} + +GCtab *lj_lib_checktab(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (!(o < L->top && tvistab(o))) + lj_err_argt(L, narg, LUA_TTABLE); + return tabV(o); +} + +GCtab *lj_lib_checktabornil(lua_State *L, int narg) +{ + TValue *o = L->base + narg-1; + if (o < L->top) { + if (tvistab(o)) + return tabV(o); + else if (tvisnil(o)) + return NULL; + } + lj_err_arg(L, narg, LJ_ERR_NOTABN); + return NULL; /* unreachable */ +} + +int lj_lib_checkopt(lua_State *L, int narg, int def, const char *lst) +{ + GCstr *s = def >= 0 ? lj_lib_optstr(L, narg) : lj_lib_checkstr(L, narg); + if (s) { + const char *opt = strdata(s); + MSize len = s->len; + int i; + for (i = 0; *(const uint8_t *)lst; i++) { + if (*(const uint8_t *)lst == len && memcmp(opt, lst+1, len) == 0) + return i; + lst += 1+*(const uint8_t *)lst; + } + lj_err_argv(L, narg, LJ_ERR_INVOPTM, opt); + } + return def; +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_lib.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_lib.h new file mode 100644 index 000000000..9320f34fd --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_lib.h @@ -0,0 +1,112 @@ +/* +** Library function support. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_LIB_H +#define _LJ_LIB_H + +#include "lj_obj.h" + +/* +** A fallback handler is called by the assembler VM if the fast path fails: +** +** - too few arguments: unrecoverable. +** - wrong argument type: recoverable, if coercion succeeds. +** - bad argument value: unrecoverable. +** - stack overflow: recoverable, if stack reallocation succeeds. +** - extra handling: recoverable. +** +** The unrecoverable cases throw an error with lj_err_arg(), lj_err_argtype(), +** lj_err_caller() or lj_err_callermsg(). +** The recoverable cases return 0 or the number of results + 1. +** The assembler VM retries the fast path only if 0 is returned. +** This time the fallback must not be called again or it gets stuck in a loop. +*/ + +/* Return values from fallback handler. */ +#define FFH_RETRY 0 +#define FFH_UNREACHABLE FFH_RETRY +#define FFH_RES(n) ((n)+1) +#define FFH_TAILCALL (-1) + +LJ_FUNC TValue *lj_lib_checkany(lua_State *L, int narg); +LJ_FUNC GCstr *lj_lib_checkstr(lua_State *L, int narg); +LJ_FUNC GCstr *lj_lib_optstr(lua_State *L, int narg); +#if LJ_DUALNUM +LJ_FUNC void lj_lib_checknumber(lua_State *L, int narg); +#else +#define lj_lib_checknumber(L, narg) lj_lib_checknum((L), (narg)) +#endif +LJ_FUNC lua_Number lj_lib_checknum(lua_State *L, int narg); +LJ_FUNC int32_t lj_lib_checkint(lua_State *L, int narg); +LJ_FUNC int32_t lj_lib_optint(lua_State *L, int narg, int32_t def); +LJ_FUNC int32_t lj_lib_checkbit(lua_State *L, int narg); +LJ_FUNC GCfunc *lj_lib_checkfunc(lua_State *L, int narg); +LJ_FUNC GCtab *lj_lib_checktab(lua_State *L, int narg); +LJ_FUNC GCtab *lj_lib_checktabornil(lua_State *L, int narg); +LJ_FUNC int lj_lib_checkopt(lua_State *L, int narg, int def, const char *lst); + +/* Avoid including lj_frame.h. */ +#define lj_lib_upvalue(L, n) \ + (&gcref((L->base-1)->fr.func)->fn.c.upvalue[(n)-1]) + +#if LJ_TARGET_WINDOWS +#define lj_lib_checkfpu(L) \ + do { setnumV(L->top++, (lua_Number)1437217655); \ + if (lua_tointeger(L, -1) != 1437217655) lj_err_caller(L, LJ_ERR_BADFPU); \ + L->top--; } while (0) +#else +#define lj_lib_checkfpu(L) UNUSED(L) +#endif + +/* Push internal function on the stack. */ +static LJ_AINLINE void lj_lib_pushcc(lua_State *L, lua_CFunction f, + int id, int n) +{ + GCfunc *fn; + lua_pushcclosure(L, f, n); + fn = funcV(L->top-1); + fn->c.ffid = (uint8_t)id; + setmref(fn->c.pc, &G(L)->bc_cfunc_int); +} + +#define lj_lib_pushcf(L, fn, id) (lj_lib_pushcc(L, (fn), (id), 0)) + +/* Library function declarations. Scanned by buildvm. */ +#define LJLIB_CF(name) static int lj_cf_##name(lua_State *L) +#define LJLIB_ASM(name) static int lj_ffh_##name(lua_State *L) +#define LJLIB_ASM_(name) +#define LJLIB_SET(name) +#define LJLIB_PUSH(arg) +#define LJLIB_REC(handler) +#define LJLIB_NOREGUV +#define LJLIB_NOREG + +#define LJ_LIB_REG(L, regname, name) \ + lj_lib_register(L, regname, lj_lib_init_##name, lj_lib_cf_##name) + +LJ_FUNC void lj_lib_register(lua_State *L, const char *libname, + const uint8_t *init, const lua_CFunction *cf); + +/* Library init data tags. */ +#define LIBINIT_LENMASK 0x3f +#define LIBINIT_TAGMASK 0xc0 +#define LIBINIT_CF 0x00 +#define LIBINIT_ASM 0x40 +#define LIBINIT_ASM_ 0x80 +#define LIBINIT_STRING 0xc0 +#define LIBINIT_MAXSTR 0x39 +#define LIBINIT_SET 0xfa +#define LIBINIT_NUMBER 0xfb +#define LIBINIT_COPY 0xfc +#define LIBINIT_LASTCL 0xfd +#define LIBINIT_FFID 0xfe +#define LIBINIT_END 0xff + +/* Exported library functions. */ + +typedef struct RandomState RandomState; +LJ_FUNC uint64_t LJ_FASTCALL lj_math_random_step(RandomState *rs); + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_load.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_load.c new file mode 100644 index 000000000..ff7b85117 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_load.c @@ -0,0 +1,168 @@ +/* +** Load and dump code. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include +#include + +#define lj_load_c +#define LUA_CORE + +#include "lua.h" +#include "lauxlib.h" + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_func.h" +#include "lj_frame.h" +#include "lj_vm.h" +#include "lj_lex.h" +#include "lj_bcdump.h" +#include "lj_parse.h" + +/* -- Load Lua source code and bytecode ----------------------------------- */ + +static TValue *cpparser(lua_State *L, lua_CFunction dummy, void *ud) +{ + LexState *ls = (LexState *)ud; + GCproto *pt; + GCfunc *fn; + int bc; + UNUSED(dummy); + cframe_errfunc(L->cframe) = -1; /* Inherit error function. */ + bc = lj_lex_setup(L, ls); + if (ls->mode && !strchr(ls->mode, bc ? 'b' : 't')) { + setstrV(L, L->top++, lj_err_str(L, LJ_ERR_XMODE)); + lj_err_throw(L, LUA_ERRSYNTAX); + } + pt = bc ? lj_bcread(ls) : lj_parse(ls); + fn = lj_func_newL_empty(L, pt, tabref(L->env)); + /* Don't combine above/below into one statement. */ + setfuncV(L, L->top++, fn); + return NULL; +} + +LUA_API int lua_loadx(lua_State *L, lua_Reader reader, void *data, + const char *chunkname, const char *mode) +{ + LexState ls; + int status; + ls.rfunc = reader; + ls.rdata = data; + ls.chunkarg = chunkname ? chunkname : "?"; + ls.mode = mode; + lj_str_initbuf(&ls.sb); + status = lj_vm_cpcall(L, NULL, &ls, cpparser); + lj_lex_cleanup(L, &ls); + lj_gc_check(L); + return status; +} + +LUA_API int lua_load(lua_State *L, lua_Reader reader, void *data, + const char *chunkname) +{ + return lua_loadx(L, reader, data, chunkname, NULL); +} + +typedef struct FileReaderCtx { + FILE *fp; + char buf[LUAL_BUFFERSIZE]; +} FileReaderCtx; + +static const char *reader_file(lua_State *L, void *ud, size_t *size) +{ + FileReaderCtx *ctx = (FileReaderCtx *)ud; + UNUSED(L); + if (feof(ctx->fp)) return NULL; + *size = fread(ctx->buf, 1, sizeof(ctx->buf), ctx->fp); + return *size > 0 ? ctx->buf : NULL; +} + +LUALIB_API int luaL_loadfilex(lua_State *L, const char *filename, + const char *mode) +{ + FileReaderCtx ctx; + int status; + const char *chunkname; + if (filename) { + ctx.fp = fopen(filename, "rb"); + if (ctx.fp == NULL) { + lua_pushfstring(L, "cannot open %s: %s", filename, strerror(errno)); + return LUA_ERRFILE; + } + chunkname = lua_pushfstring(L, "@%s", filename); + } else { + ctx.fp = stdin; + chunkname = "=stdin"; + } + status = lua_loadx(L, reader_file, &ctx, chunkname, mode); + if (ferror(ctx.fp)) { + L->top -= filename ? 2 : 1; + lua_pushfstring(L, "cannot read %s: %s", chunkname+1, strerror(errno)); + if (filename) + fclose(ctx.fp); + return LUA_ERRFILE; + } + if (filename) { + L->top--; + copyTV(L, L->top-1, L->top); + fclose(ctx.fp); + } + return status; +} + +LUALIB_API int luaL_loadfile(lua_State *L, const char *filename) +{ + return luaL_loadfilex(L, filename, NULL); +} + +typedef struct StringReaderCtx { + const char *str; + size_t size; +} StringReaderCtx; + +static const char *reader_string(lua_State *L, void *ud, size_t *size) +{ + StringReaderCtx *ctx = (StringReaderCtx *)ud; + UNUSED(L); + if (ctx->size == 0) return NULL; + *size = ctx->size; + ctx->size = 0; + return ctx->str; +} + +LUALIB_API int luaL_loadbufferx(lua_State *L, const char *buf, size_t size, + const char *name, const char *mode) +{ + StringReaderCtx ctx; + ctx.str = buf; + ctx.size = size; + return lua_loadx(L, reader_string, &ctx, name, mode); +} + +LUALIB_API int luaL_loadbuffer(lua_State *L, const char *buf, size_t size, + const char *name) +{ + return luaL_loadbufferx(L, buf, size, name, NULL); +} + +LUALIB_API int luaL_loadstring(lua_State *L, const char *s) +{ + return luaL_loadbuffer(L, s, strlen(s), s); +} + +/* -- Dump bytecode ------------------------------------------------------- */ + +LUA_API int lua_dump(lua_State *L, lua_Writer writer, void *data) +{ + cTValue *o = L->top-1; + api_check(L, L->top > L->base); + if (tvisfunc(o) && isluafunc(funcV(o))) + return lj_bcwrite(L, funcproto(funcV(o)), writer, data, 0); + else + return 1; +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_mcode.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_mcode.c new file mode 100644 index 000000000..d95ebeb1f --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_mcode.c @@ -0,0 +1,386 @@ +/* +** Machine code management. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_mcode_c +#define LUA_CORE + +#include "lj_obj.h" +#if LJ_HASJIT +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_jit.h" +#include "lj_mcode.h" +#include "lj_trace.h" +#include "lj_dispatch.h" +#endif +#if LJ_HASJIT || LJ_HASFFI +#include "lj_vm.h" +#endif + +/* -- OS-specific functions ----------------------------------------------- */ + +#if LJ_HASJIT || LJ_HASFFI + +/* Define this if you want to run LuaJIT with Valgrind. */ +#ifdef LUAJIT_USE_VALGRIND +#include +#endif + +#if LJ_TARGET_IOS +void sys_icache_invalidate(void *start, size_t len); +#endif + +/* Synchronize data/instruction cache. */ +void lj_mcode_sync(void *start, void *end) +{ +#ifdef LUAJIT_USE_VALGRIND + VALGRIND_DISCARD_TRANSLATIONS(start, (char *)end-(char *)start); +#endif +#if LJ_TARGET_X86ORX64 + UNUSED(start); UNUSED(end); +#elif LJ_TARGET_IOS + sys_icache_invalidate(start, (char *)end-(char *)start); +#elif LJ_TARGET_PPC + lj_vm_cachesync(start, end); +#elif defined(__GNUC__) + __clear_cache(start, end); +#else +#error "Missing builtin to flush instruction cache" +#endif +} + +#endif + +#if LJ_HASJIT + +#if LJ_TARGET_WINDOWS + +#define WIN32_LEAN_AND_MEAN +#include + +#define MCPROT_RW PAGE_READWRITE +#define MCPROT_RX PAGE_EXECUTE_READ +#define MCPROT_RWX PAGE_EXECUTE_READWRITE + +static void *mcode_alloc_at(jit_State *J, uintptr_t hint, size_t sz, DWORD prot) +{ + void *p = VirtualAlloc((void *)hint, sz, + MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, prot); + if (!p && !hint) + lj_trace_err(J, LJ_TRERR_MCODEAL); + return p; +} + +static void mcode_free(jit_State *J, void *p, size_t sz) +{ + UNUSED(J); UNUSED(sz); + VirtualFree(p, 0, MEM_RELEASE); +} + +static int mcode_setprot(void *p, size_t sz, DWORD prot) +{ + DWORD oprot; + return !VirtualProtect(p, sz, prot, &oprot); +} + +#elif LJ_TARGET_POSIX + +#include + +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + +#define MCPROT_RW (PROT_READ|PROT_WRITE) +#define MCPROT_RX (PROT_READ|PROT_EXEC) +#define MCPROT_RWX (PROT_READ|PROT_WRITE|PROT_EXEC) + +static void *mcode_alloc_at(jit_State *J, uintptr_t hint, size_t sz, int prot) +{ + void *p = mmap((void *)hint, sz, prot, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); + if (p == MAP_FAILED) { + if (!hint) lj_trace_err(J, LJ_TRERR_MCODEAL); + p = NULL; + } + return p; +} + +static void mcode_free(jit_State *J, void *p, size_t sz) +{ + UNUSED(J); + munmap(p, sz); +} + +static int mcode_setprot(void *p, size_t sz, int prot) +{ + return mprotect(p, sz, prot); +} + +#elif LJ_64 + +#error "Missing OS support for explicit placement of executable memory" + +#else + +/* Fallback allocator. This will fail if memory is not executable by default. */ +#define LUAJIT_UNPROTECT_MCODE +#define MCPROT_RW 0 +#define MCPROT_RX 0 +#define MCPROT_RWX 0 + +static void *mcode_alloc_at(jit_State *J, uintptr_t hint, size_t sz, int prot) +{ + UNUSED(hint); UNUSED(prot); + return lj_mem_new(J->L, sz); +} + +static void mcode_free(jit_State *J, void *p, size_t sz) +{ + lj_mem_free(J2G(J), p, sz); +} + +#endif + +/* -- MCode area protection ----------------------------------------------- */ + +/* Define this ONLY if page protection twiddling becomes a bottleneck. */ +#ifdef LUAJIT_UNPROTECT_MCODE + +/* It's generally considered to be a potential security risk to have +** pages with simultaneous write *and* execute access in a process. +** +** Do not even think about using this mode for server processes or +** apps handling untrusted external data (such as a browser). +** +** The security risk is not in LuaJIT itself -- but if an adversary finds +** any *other* flaw in your C application logic, then any RWX memory page +** simplifies writing an exploit considerably. +*/ +#define MCPROT_GEN MCPROT_RWX +#define MCPROT_RUN MCPROT_RWX + +static void mcode_protect(jit_State *J, int prot) +{ + UNUSED(J); UNUSED(prot); +} + +#else + +/* This is the default behaviour and much safer: +** +** Most of the time the memory pages holding machine code are executable, +** but NONE of them is writable. +** +** The current memory area is marked read-write (but NOT executable) only +** during the short time window while the assembler generates machine code. +*/ +#define MCPROT_GEN MCPROT_RW +#define MCPROT_RUN MCPROT_RX + +/* Protection twiddling failed. Probably due to kernel security. */ +static LJ_NOINLINE void mcode_protfail(jit_State *J) +{ + lua_CFunction panic = J2G(J)->panic; + if (panic) { + lua_State *L = J->L; + setstrV(L, L->top++, lj_err_str(L, LJ_ERR_JITPROT)); + panic(L); + } +} + +/* Change protection of MCode area. */ +static void mcode_protect(jit_State *J, int prot) +{ + if (J->mcprot != prot) { + if (LJ_UNLIKELY(mcode_setprot(J->mcarea, J->szmcarea, prot))) + mcode_protfail(J); + J->mcprot = prot; + } +} + +#endif + +/* -- MCode area allocation ----------------------------------------------- */ + +#if LJ_TARGET_X64 +#define mcode_validptr(p) ((p) && (uintptr_t)(p) < (uintptr_t)1<<47) +#else +#define mcode_validptr(p) ((p) && (uintptr_t)(p) < 0xffff0000) +#endif + +#ifdef LJ_TARGET_JUMPRANGE + +/* Get memory within relative jump distance of our code in 64 bit mode. */ +static void *mcode_alloc(jit_State *J, size_t sz) +{ + /* Target an address in the static assembler code (64K aligned). + ** Try addresses within a distance of target-range/2+1MB..target+range/2-1MB. + ** Use half the jump range so every address in the range can reach any other. + */ +#if LJ_TARGET_MIPS + /* Use the middle of the 256MB-aligned region. */ + uintptr_t target = ((uintptr_t)(void *)lj_vm_exit_handler & 0xf0000000u) + + 0x08000000u; +#else + uintptr_t target = (uintptr_t)(void *)lj_vm_exit_handler & ~(uintptr_t)0xffff; +#endif + const uintptr_t range = (1u << (LJ_TARGET_JUMPRANGE-1)) - (1u << 21); + /* First try a contiguous area below the last one. */ + uintptr_t hint = J->mcarea ? (uintptr_t)J->mcarea - sz : 0; + int i; + for (i = 0; i < 32; i++) { /* 32 attempts ought to be enough ... */ + if (mcode_validptr(hint)) { + void *p = mcode_alloc_at(J, hint, sz, MCPROT_GEN); + + if (mcode_validptr(p) && + ((uintptr_t)p + sz - target < range || target - (uintptr_t)p < range)) + return p; + if (p) mcode_free(J, p, sz); /* Free badly placed area. */ + } + /* Next try probing pseudo-random addresses. */ + do { + hint = (0x78fb ^ LJ_PRNG_BITS(J, 15)) << 16; /* 64K aligned. */ + } while (!(hint + sz < range)); + hint = target + hint - (range>>1); + } + lj_trace_err(J, LJ_TRERR_MCODEAL); /* Give up. OS probably ignores hints? */ + return NULL; +} + +#else + +/* All memory addresses are reachable by relative jumps. */ +static void *mcode_alloc(jit_State *J, size_t sz) +{ +#ifdef __OpenBSD__ + /* Allow better executable memory allocation for OpenBSD W^X mode. */ + void *p = mcode_alloc_at(J, 0, sz, MCPROT_RUN); + if (p && mcode_setprot(p, sz, MCPROT_GEN)) { + mcode_free(J, p, sz); + return NULL; + } + return p; +#else + return mcode_alloc_at(J, 0, sz, MCPROT_GEN); +#endif +} + +#endif + +/* -- MCode area management ----------------------------------------------- */ + +/* Linked list of MCode areas. */ +typedef struct MCLink { + MCode *next; /* Next area. */ + size_t size; /* Size of current area. */ +} MCLink; + +/* Allocate a new MCode area. */ +static void mcode_allocarea(jit_State *J) +{ + MCode *oldarea = J->mcarea; + size_t sz = (size_t)J->param[JIT_P_sizemcode] << 10; + sz = (sz + LJ_PAGESIZE-1) & ~(size_t)(LJ_PAGESIZE - 1); + J->mcarea = (MCode *)mcode_alloc(J, sz); + J->szmcarea = sz; + J->mcprot = MCPROT_GEN; + J->mctop = (MCode *)((char *)J->mcarea + J->szmcarea); + J->mcbot = (MCode *)((char *)J->mcarea + sizeof(MCLink)); + ((MCLink *)J->mcarea)->next = oldarea; + ((MCLink *)J->mcarea)->size = sz; + J->szallmcarea += sz; +} + +/* Free all MCode areas. */ +void lj_mcode_free(jit_State *J) +{ + MCode *mc = J->mcarea; + J->mcarea = NULL; + J->szallmcarea = 0; + while (mc) { + MCode *next = ((MCLink *)mc)->next; + mcode_free(J, mc, ((MCLink *)mc)->size); + mc = next; + } +} + +/* -- MCode transactions -------------------------------------------------- */ + +/* Reserve the remainder of the current MCode area. */ +MCode *lj_mcode_reserve(jit_State *J, MCode **lim) +{ + if (!J->mcarea) + mcode_allocarea(J); + else + mcode_protect(J, MCPROT_GEN); + *lim = J->mcbot; + return J->mctop; +} + +/* Commit the top part of the current MCode area. */ +void lj_mcode_commit(jit_State *J, MCode *top) +{ + J->mctop = top; + mcode_protect(J, MCPROT_RUN); +} + +/* Abort the reservation. */ +void lj_mcode_abort(jit_State *J) +{ + if (J->mcarea) + mcode_protect(J, MCPROT_RUN); +} + +/* Set/reset protection to allow patching of MCode areas. */ +MCode *lj_mcode_patch(jit_State *J, MCode *ptr, int finish) +{ +#ifdef LUAJIT_UNPROTECT_MCODE + UNUSED(J); UNUSED(ptr); UNUSED(finish); + return NULL; +#else + if (finish) { + if (J->mcarea == ptr) + mcode_protect(J, MCPROT_RUN); + else if (LJ_UNLIKELY(mcode_setprot(ptr, ((MCLink *)ptr)->size, MCPROT_RUN))) + mcode_protfail(J); + return NULL; + } else { + MCode *mc = J->mcarea; + /* Try current area first to use the protection cache. */ + if (ptr >= mc && ptr < (MCode *)((char *)mc + J->szmcarea)) { + mcode_protect(J, MCPROT_GEN); + return mc; + } + /* Otherwise search through the list of MCode areas. */ + for (;;) { + mc = ((MCLink *)mc)->next; + lua_assert(mc != NULL); + if (ptr >= mc && ptr < (MCode *)((char *)mc + ((MCLink *)mc)->size)) { + if (LJ_UNLIKELY(mcode_setprot(mc, ((MCLink *)mc)->size, MCPROT_GEN))) + mcode_protfail(J); + return mc; + } + } + } +#endif +} + +/* Limit of MCode reservation reached. */ +void lj_mcode_limiterr(jit_State *J, size_t need) +{ + size_t sizemcode, maxmcode; + lj_mcode_abort(J); + sizemcode = (size_t)J->param[JIT_P_sizemcode] << 10; + sizemcode = (sizemcode + LJ_PAGESIZE-1) & ~(size_t)(LJ_PAGESIZE - 1); + maxmcode = (size_t)J->param[JIT_P_maxmcode] << 10; + if ((size_t)need > sizemcode) + lj_trace_err(J, LJ_TRERR_MCODEOV); /* Too long for any area. */ + if (J->szallmcarea + sizemcode > maxmcode) + lj_trace_err(J, LJ_TRERR_MCODEAL); + mcode_allocarea(J); + lj_trace_err(J, LJ_TRERR_MCODELM); /* Retry with new area. */ +} + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_mcode.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_mcode.h new file mode 100644 index 000000000..ee6045234 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_mcode.h @@ -0,0 +1,30 @@ +/* +** Machine code management. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_MCODE_H +#define _LJ_MCODE_H + +#include "lj_obj.h" + +#if LJ_HASJIT || LJ_HASFFI +LJ_FUNC void lj_mcode_sync(void *start, void *end); +#endif + +#if LJ_HASJIT + +#include "lj_jit.h" + +LJ_FUNC void lj_mcode_free(jit_State *J); +LJ_FUNC MCode *lj_mcode_reserve(jit_State *J, MCode **lim); +LJ_FUNC void lj_mcode_commit(jit_State *J, MCode *m); +LJ_FUNC void lj_mcode_abort(jit_State *J); +LJ_FUNC MCode *lj_mcode_patch(jit_State *J, MCode *ptr, int finish); +LJ_FUNC_NORET void lj_mcode_limiterr(jit_State *J, size_t need); + +#define lj_mcode_commitbot(J, m) (J->mcbot = (m)) + +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_meta.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_meta.c new file mode 100644 index 000000000..faaaf7026 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_meta.c @@ -0,0 +1,466 @@ +/* +** Metamethod handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lj_meta_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_meta.h" +#include "lj_frame.h" +#include "lj_bc.h" +#include "lj_vm.h" +#include "lj_strscan.h" + +/* -- Metamethod handling ------------------------------------------------- */ + +/* String interning of metamethod names for fast indexing. */ +void lj_meta_init(lua_State *L) +{ +#define MMNAME(name) "__" #name + const char *metanames = MMDEF(MMNAME); +#undef MMNAME + global_State *g = G(L); + const char *p, *q; + uint32_t mm; + for (mm = 0, p = metanames; *p; mm++, p = q) { + GCstr *s; + for (q = p+2; *q && *q != '_'; q++) ; + s = lj_str_new(L, p, (size_t)(q-p)); + /* NOBARRIER: g->gcroot[] is a GC root. */ + setgcref(g->gcroot[GCROOT_MMNAME+mm], obj2gco(s)); + } +} + +/* Negative caching of a few fast metamethods. See the lj_meta_fast() macro. */ +cTValue *lj_meta_cache(GCtab *mt, MMS mm, GCstr *name) +{ + cTValue *mo = lj_tab_getstr(mt, name); + lua_assert(mm <= MM_FAST); + if (!mo || tvisnil(mo)) { /* No metamethod? */ + mt->nomm |= (uint8_t)(1u<metatable); + else if (tvisudata(o)) + mt = tabref(udataV(o)->metatable); + else + mt = tabref(basemt_obj(G(L), o)); + if (mt) { + cTValue *mo = lj_tab_getstr(mt, mmname_str(G(L), mm)); + if (mo) + return mo; + } + return niltv(L); +} + +#if LJ_HASFFI +/* Tailcall from C function. */ +int lj_meta_tailcall(lua_State *L, cTValue *tv) +{ + TValue *base = L->base; + TValue *top = L->top; + const BCIns *pc = frame_pc(base-1); /* Preserve old PC from frame. */ + copyTV(L, base-1, tv); /* Replace frame with new object. */ + top->u32.lo = LJ_CONT_TAILCALL; + setframe_pc(top, pc); + setframe_gc(top+1, obj2gco(L)); /* Dummy frame object. */ + setframe_ftsz(top+1, (int)((char *)(top+2) - (char *)base) + FRAME_CONT); + L->base = L->top = top+2; + /* + ** before: [old_mo|PC] [... ...] + ** ^base ^top + ** after: [new_mo|itype] [... ...] [NULL|PC] [dummy|delta] + ** ^base/top + ** tailcall: [new_mo|PC] [... ...] + ** ^base ^top + */ + return 0; +} +#endif + +/* Setup call to metamethod to be run by Assembler VM. */ +static TValue *mmcall(lua_State *L, ASMFunction cont, cTValue *mo, + cTValue *a, cTValue *b) +{ + /* + ** |-- framesize -> top top+1 top+2 top+3 + ** before: [func slots ...] + ** mm setup: [func slots ...] [cont|?] [mo|tmtype] [a] [b] + ** in asm: [func slots ...] [cont|PC] [mo|delta] [a] [b] + ** ^-- func base ^-- mm base + ** after mm: [func slots ...] [result] + ** ^-- copy to base[PC_RA] --/ for lj_cont_ra + ** istruecond + branch for lj_cont_cond* + ** ignore for lj_cont_nop + ** next PC: [func slots ...] + */ + TValue *top = L->top; + if (curr_funcisL(L)) top = curr_topL(L); + setcont(top, cont); /* Assembler VM stores PC in upper word. */ + copyTV(L, top+1, mo); /* Store metamethod and two arguments. */ + copyTV(L, top+2, a); + copyTV(L, top+3, b); + return top+2; /* Return new base. */ +} + +/* -- C helpers for some instructions, called from assembler VM ----------- */ + +/* Helper for TGET*. __index chain and metamethod. */ +cTValue *lj_meta_tget(lua_State *L, cTValue *o, cTValue *k) +{ + int loop; + for (loop = 0; loop < LJ_MAX_IDXCHAIN; loop++) { + cTValue *mo; + if (LJ_LIKELY(tvistab(o))) { + GCtab *t = tabV(o); + cTValue *tv = lj_tab_get(L, t, k); + if (!tvisnil(tv) || + !(mo = lj_meta_fast(L, tabref(t->metatable), MM_index))) + return tv; + } else if (tvisnil(mo = lj_meta_lookup(L, o, MM_index))) { + lj_err_optype(L, o, LJ_ERR_OPINDEX); + return NULL; /* unreachable */ + } + if (tvisfunc(mo)) { + L->top = mmcall(L, lj_cont_ra, mo, o, k); + return NULL; /* Trigger metamethod call. */ + } + o = mo; + } + lj_err_msg(L, LJ_ERR_GETLOOP); + return NULL; /* unreachable */ +} + +/* Helper for TSET*. __newindex chain and metamethod. */ +TValue *lj_meta_tset(lua_State *L, cTValue *o, cTValue *k) +{ + TValue tmp; + int loop; + for (loop = 0; loop < LJ_MAX_IDXCHAIN; loop++) { + cTValue *mo; + if (LJ_LIKELY(tvistab(o))) { + GCtab *t = tabV(o); + cTValue *tv = lj_tab_get(L, t, k); + if (LJ_LIKELY(!tvisnil(tv))) { + t->nomm = 0; /* Invalidate negative metamethod cache. */ + lj_gc_anybarriert(L, t); + return (TValue *)tv; + } else if (!(mo = lj_meta_fast(L, tabref(t->metatable), MM_newindex))) { + t->nomm = 0; /* Invalidate negative metamethod cache. */ + lj_gc_anybarriert(L, t); + if (tv != niltv(L)) + return (TValue *)tv; + if (tvisnil(k)) lj_err_msg(L, LJ_ERR_NILIDX); + else if (tvisint(k)) { setnumV(&tmp, (lua_Number)intV(k)); k = &tmp; } + else if (tvisnum(k) && tvisnan(k)) lj_err_msg(L, LJ_ERR_NANIDX); + return lj_tab_newkey(L, t, k); + } + } else if (tvisnil(mo = lj_meta_lookup(L, o, MM_newindex))) { + lj_err_optype(L, o, LJ_ERR_OPINDEX); + return NULL; /* unreachable */ + } + if (tvisfunc(mo)) { + L->top = mmcall(L, lj_cont_nop, mo, o, k); + /* L->top+2 = v filled in by caller. */ + return NULL; /* Trigger metamethod call. */ + } + copyTV(L, &tmp, mo); + o = &tmp; + } + lj_err_msg(L, LJ_ERR_SETLOOP); + return NULL; /* unreachable */ +} + +static cTValue *str2num(cTValue *o, TValue *n) +{ + if (tvisnum(o)) + return o; + else if (tvisint(o)) + return (setnumV(n, (lua_Number)intV(o)), n); + else if (tvisstr(o) && lj_strscan_num(strV(o), n)) + return n; + else + return NULL; +} + +/* Helper for arithmetic instructions. Coercion, metamethod. */ +TValue *lj_meta_arith(lua_State *L, TValue *ra, cTValue *rb, cTValue *rc, + BCReg op) +{ + MMS mm = bcmode_mm(op); + TValue tempb, tempc; + cTValue *b, *c; + if ((b = str2num(rb, &tempb)) != NULL && + (c = str2num(rc, &tempc)) != NULL) { /* Try coercion first. */ + setnumV(ra, lj_vm_foldarith(numV(b), numV(c), (int)mm-MM_add)); + return NULL; + } else { + cTValue *mo = lj_meta_lookup(L, rb, mm); + if (tvisnil(mo)) { + mo = lj_meta_lookup(L, rc, mm); + if (tvisnil(mo)) { + if (str2num(rb, &tempb) == NULL) rc = rb; + lj_err_optype(L, rc, LJ_ERR_OPARITH); + return NULL; /* unreachable */ + } + } + return mmcall(L, lj_cont_ra, mo, rb, rc); + } +} + +/* In-place coercion of a number to a string. */ +static LJ_AINLINE int tostring(lua_State *L, TValue *o) +{ + if (tvisstr(o)) { + return 1; + } else if (tvisnumber(o)) { + setstrV(L, o, lj_str_fromnumber(L, o)); + return 1; + } else { + return 0; + } +} + +/* Helper for CAT. Coercion, iterative concat, __concat metamethod. */ +TValue *lj_meta_cat(lua_State *L, TValue *top, int left) +{ + int fromc = 0; + if (left < 0) { left = -left; fromc = 1; } + do { + int n = 1; + if (!(tvisstr(top-1) || tvisnumber(top-1)) || !tostring(L, top)) { + cTValue *mo = lj_meta_lookup(L, top-1, MM_concat); + if (tvisnil(mo)) { + mo = lj_meta_lookup(L, top, MM_concat); + if (tvisnil(mo)) { + if (tvisstr(top-1) || tvisnumber(top-1)) top++; + lj_err_optype(L, top-1, LJ_ERR_OPCAT); + return NULL; /* unreachable */ + } + } + /* One of the top two elements is not a string, call __cat metamethod: + ** + ** before: [...][CAT stack .........................] + ** top-1 top top+1 top+2 + ** pick two: [...][CAT stack ...] [o1] [o2] + ** setup mm: [...][CAT stack ...] [cont|?] [mo|tmtype] [o1] [o2] + ** in asm: [...][CAT stack ...] [cont|PC] [mo|delta] [o1] [o2] + ** ^-- func base ^-- mm base + ** after mm: [...][CAT stack ...] <--push-- [result] + ** next step: [...][CAT stack .............] + */ + copyTV(L, top+2, top); /* Careful with the order of stack copies! */ + copyTV(L, top+1, top-1); + copyTV(L, top, mo); + setcont(top-1, lj_cont_cat); + return top+1; /* Trigger metamethod call. */ + } else if (strV(top)->len == 0) { /* Shortcut. */ + (void)tostring(L, top-1); + } else { + /* Pick as many strings as possible from the top and concatenate them: + ** + ** before: [...][CAT stack ...........................] + ** pick str: [...][CAT stack ...] [...... strings ......] + ** concat: [...][CAT stack ...] [result] + ** next step: [...][CAT stack ............] + */ + MSize tlen = strV(top)->len; + char *buffer; + int i; + for (n = 1; n <= left && tostring(L, top-n); n++) { + MSize len = strV(top-n)->len; + if (len >= LJ_MAX_STR - tlen) + lj_err_msg(L, LJ_ERR_STROV); + tlen += len; + } + buffer = lj_str_needbuf(L, &G(L)->tmpbuf, tlen); + n--; + tlen = 0; + for (i = n; i >= 0; i--) { + MSize len = strV(top-i)->len; + memcpy(buffer + tlen, strVdata(top-i), len); + tlen += len; + } + setstrV(L, top-n, lj_str_new(L, buffer, tlen)); + } + left -= n; + top -= n; + } while (left >= 1); + if (LJ_UNLIKELY(G(L)->gc.total >= G(L)->gc.threshold)) { + if (!fromc) L->top = curr_topL(L); + lj_gc_step(L); + } + return NULL; +} + +/* Helper for LEN. __len metamethod. */ +TValue * LJ_FASTCALL lj_meta_len(lua_State *L, cTValue *o) +{ + cTValue *mo = lj_meta_lookup(L, o, MM_len); + if (tvisnil(mo)) { + if (LJ_52 && tvistab(o)) + tabref(tabV(o)->metatable)->nomm |= (uint8_t)(1u<gch.metatable), MM_eq); + if (mo) { + TValue *top; + uint32_t it; + if (tabref(o1->gch.metatable) != tabref(o2->gch.metatable)) { + cTValue *mo2 = lj_meta_fast(L, tabref(o2->gch.metatable), MM_eq); + if (mo2 == NULL || !lj_obj_equal(mo, mo2)) + return (TValue *)(intptr_t)ne; + } + top = curr_top(L); + setcont(top, ne ? lj_cont_condf : lj_cont_condt); + copyTV(L, top+1, mo); + it = ~(uint32_t)o1->gch.gct; + setgcV(L, top+2, o1, it); + setgcV(L, top+3, o2, it); + return top+2; /* Trigger metamethod call. */ + } + return (TValue *)(intptr_t)ne; +} + +#if LJ_HASFFI +TValue * LJ_FASTCALL lj_meta_equal_cd(lua_State *L, BCIns ins) +{ + ASMFunction cont = (bc_op(ins) & 1) ? lj_cont_condf : lj_cont_condt; + int op = (int)bc_op(ins) & ~1; + TValue tv; + cTValue *mo, *o2, *o1 = &L->base[bc_a(ins)]; + cTValue *o1mm = o1; + if (op == BC_ISEQV) { + o2 = &L->base[bc_d(ins)]; + if (!tviscdata(o1mm)) o1mm = o2; + } else if (op == BC_ISEQS) { + setstrV(L, &tv, gco2str(proto_kgc(curr_proto(L), ~(ptrdiff_t)bc_d(ins)))); + o2 = &tv; + } else if (op == BC_ISEQN) { + o2 = &mref(curr_proto(L)->k, cTValue)[bc_d(ins)]; + } else { + lua_assert(op == BC_ISEQP); + setitype(&tv, ~bc_d(ins)); + o2 = &tv; + } + mo = lj_meta_lookup(L, o1mm, MM_eq); + if (LJ_LIKELY(!tvisnil(mo))) + return mmcall(L, cont, mo, o1, o2); + else + return (TValue *)(intptr_t)(bc_op(ins) & 1); +} +#endif + +/* Helper for ordered comparisons. String compare, __lt/__le metamethods. */ +TValue *lj_meta_comp(lua_State *L, cTValue *o1, cTValue *o2, int op) +{ + if (LJ_HASFFI && (tviscdata(o1) || tviscdata(o2))) { + ASMFunction cont = (op & 1) ? lj_cont_condf : lj_cont_condt; + MMS mm = (op & 2) ? MM_le : MM_lt; + cTValue *mo = lj_meta_lookup(L, tviscdata(o1) ? o1 : o2, mm); + if (LJ_UNLIKELY(tvisnil(mo))) goto err; + return mmcall(L, cont, mo, o1, o2); + } else if (LJ_52 || itype(o1) == itype(o2)) { + /* Never called with two numbers. */ + if (tvisstr(o1) && tvisstr(o2)) { + int32_t res = lj_str_cmp(strV(o1), strV(o2)); + return (TValue *)(intptr_t)(((op&2) ? res <= 0 : res < 0) ^ (op&1)); + } else { + trymt: + while (1) { + ASMFunction cont = (op & 1) ? lj_cont_condf : lj_cont_condt; + MMS mm = (op & 2) ? MM_le : MM_lt; + cTValue *mo = lj_meta_lookup(L, o1, mm); +#if LJ_52 + if (tvisnil(mo) && tvisnil((mo = lj_meta_lookup(L, o2, mm)))) +#else + cTValue *mo2 = lj_meta_lookup(L, o2, mm); + if (tvisnil(mo) || !lj_obj_equal(mo, mo2)) +#endif + { + if (op & 2) { /* MM_le not found: retry with MM_lt. */ + cTValue *ot = o1; o1 = o2; o2 = ot; /* Swap operands. */ + op ^= 3; /* Use LT and flip condition. */ + continue; + } + goto err; + } + return mmcall(L, cont, mo, o1, o2); + } + } + } else if (tvisbool(o1) && tvisbool(o2)) { + goto trymt; + } else { + err: + lj_err_comp(L, o1, o2); + return NULL; + } +} + +/* Helper for calls. __call metamethod. */ +void lj_meta_call(lua_State *L, TValue *func, TValue *top) +{ + cTValue *mo = lj_meta_lookup(L, func, MM_call); + TValue *p; + if (!tvisfunc(mo)) + lj_err_optype_call(L, func); + for (p = top; p > func; p--) copyTV(L, p, p-1); + copyTV(L, func, mo); +} + +/* Helper for FORI. Coercion. */ +void LJ_FASTCALL lj_meta_for(lua_State *L, TValue *o) +{ + if (!lj_strscan_numberobj(o)) lj_err_msg(L, LJ_ERR_FORINIT); + if (!lj_strscan_numberobj(o+1)) lj_err_msg(L, LJ_ERR_FORLIM); + if (!lj_strscan_numberobj(o+2)) lj_err_msg(L, LJ_ERR_FORSTEP); + if (LJ_DUALNUM) { + /* Ensure all slots are integers or all slots are numbers. */ + int32_t k[3]; + int nint = 0; + ptrdiff_t i; + for (i = 0; i <= 2; i++) { + if (tvisint(o+i)) { + k[i] = intV(o+i); nint++; + } else { + k[i] = lj_num2int(numV(o+i)); nint += ((lua_Number)k[i] == numV(o+i)); + } + } + if (nint == 3) { /* Narrow to integers. */ + setintV(o, k[0]); + setintV(o+1, k[1]); + setintV(o+2, k[2]); + } else if (nint != 0) { /* Widen to numbers. */ + if (tvisint(o)) setnumV(o, (lua_Number)intV(o)); + if (tvisint(o+1)) setnumV(o+1, (lua_Number)intV(o+1)); + if (tvisint(o+2)) setnumV(o+2, (lua_Number)intV(o+2)); + } + } +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_meta.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_meta.h new file mode 100644 index 000000000..2c1ad0dd9 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_meta.h @@ -0,0 +1,37 @@ +/* +** Metamethod handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_META_H +#define _LJ_META_H + +#include "lj_obj.h" + +/* Metamethod handling */ +LJ_FUNC void lj_meta_init(lua_State *L); +LJ_FUNC cTValue *lj_meta_cache(GCtab *mt, MMS mm, GCstr *name); +LJ_FUNC cTValue *lj_meta_lookup(lua_State *L, cTValue *o, MMS mm); +#if LJ_HASFFI +LJ_FUNC int lj_meta_tailcall(lua_State *L, cTValue *tv); +#endif + +#define lj_meta_fastg(g, mt, mm) \ + ((mt) == NULL ? NULL : ((mt)->nomm & (1u<<(mm))) ? NULL : \ + lj_meta_cache(mt, mm, mmname_str(g, mm))) +#define lj_meta_fast(L, mt, mm) lj_meta_fastg(G(L), mt, mm) + +/* C helpers for some instructions, called from assembler VM. */ +LJ_FUNCA cTValue *lj_meta_tget(lua_State *L, cTValue *o, cTValue *k); +LJ_FUNCA TValue *lj_meta_tset(lua_State *L, cTValue *o, cTValue *k); +LJ_FUNCA TValue *lj_meta_arith(lua_State *L, TValue *ra, cTValue *rb, + cTValue *rc, BCReg op); +LJ_FUNCA TValue *lj_meta_cat(lua_State *L, TValue *top, int left); +LJ_FUNCA TValue * LJ_FASTCALL lj_meta_len(lua_State *L, cTValue *o); +LJ_FUNCA TValue *lj_meta_equal(lua_State *L, GCobj *o1, GCobj *o2, int ne); +LJ_FUNCA TValue * LJ_FASTCALL lj_meta_equal_cd(lua_State *L, BCIns ins); +LJ_FUNCA TValue *lj_meta_comp(lua_State *L, cTValue *o1, cTValue *o2, int op); +LJ_FUNCA void lj_meta_call(lua_State *L, TValue *func, TValue *top); +LJ_FUNCA void LJ_FASTCALL lj_meta_for(lua_State *L, TValue *o); + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_obj.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_obj.c new file mode 100644 index 000000000..7fab714e5 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_obj.c @@ -0,0 +1,35 @@ +/* +** Miscellaneous object handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_obj_c +#define LUA_CORE + +#include "lj_obj.h" + +/* Object type names. */ +LJ_DATADEF const char *const lj_obj_typename[] = { /* ORDER LUA_T */ + "no value", "nil", "boolean", "userdata", "number", "string", + "table", "function", "userdata", "thread", "proto", "cdata" +}; + +LJ_DATADEF const char *const lj_obj_itypename[] = { /* ORDER LJ_T */ + "nil", "boolean", "boolean", "userdata", "string", "upval", "thread", + "proto", "function", "trace", "cdata", "table", "userdata", "number" +}; + +/* Compare two objects without calling metamethods. */ +int lj_obj_equal(cTValue *o1, cTValue *o2) +{ + if (itype(o1) == itype(o2)) { + if (tvispri(o1)) + return 1; + if (!tvisnum(o1)) + return gcrefeq(o1->gcr, o2->gcr); + } else if (!tvisnumber(o1) || !tvisnumber(o2)) { + return 0; + } + return numberVnum(o1) == numberVnum(o2); +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_obj.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_obj.h new file mode 100644 index 000000000..6e8381cba --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_obj.h @@ -0,0 +1,856 @@ +/* +** LuaJIT VM tags, values and objects. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#ifndef _LJ_OBJ_H +#define _LJ_OBJ_H + +#include "lua.h" +#include "lj_def.h" +#include "lj_arch.h" + +/* -- Memory references (32 bit address space) ---------------------------- */ + +/* Memory size. */ +typedef uint32_t MSize; + +/* Memory reference */ +typedef struct MRef { + uint32_t ptr32; /* Pseudo 32 bit pointer. */ +} MRef; + +#define mref(r, t) ((t *)(void *)(uintptr_t)(r).ptr32) + +#define setmref(r, p) ((r).ptr32 = (uint32_t)(uintptr_t)(void *)(p)) +#define setmrefr(r, v) ((r).ptr32 = (v).ptr32) + +/* -- GC object references (32 bit address space) ------------------------- */ + +/* GCobj reference */ +typedef struct GCRef { + uint32_t gcptr32; /* Pseudo 32 bit pointer. */ +} GCRef; + +/* Common GC header for all collectable objects. */ +#define GCHeader GCRef nextgc; uint8_t marked; uint8_t gct +/* This occupies 6 bytes, so use the next 2 bytes for non-32 bit fields. */ + +#define gcref(r) ((GCobj *)(uintptr_t)(r).gcptr32) +#define gcrefp(r, t) ((t *)(void *)(uintptr_t)(r).gcptr32) +#define gcrefu(r) ((r).gcptr32) +#define gcrefi(r) ((int32_t)(r).gcptr32) +#define gcrefeq(r1, r2) ((r1).gcptr32 == (r2).gcptr32) +#define gcnext(gc) (gcref((gc)->gch.nextgc)) + +#define setgcref(r, gc) ((r).gcptr32 = (uint32_t)(uintptr_t)&(gc)->gch) +#define setgcrefi(r, i) ((r).gcptr32 = (uint32_t)(i)) +#define setgcrefp(r, p) ((r).gcptr32 = (uint32_t)(uintptr_t)(p)) +#define setgcrefnull(r) ((r).gcptr32 = 0) +#define setgcrefr(r, v) ((r).gcptr32 = (v).gcptr32) + +/* IMPORTANT NOTE: +** +** All uses of the setgcref* macros MUST be accompanied with a write barrier. +** +** This is to ensure the integrity of the incremental GC. The invariant +** to preserve is that a black object never points to a white object. +** I.e. never store a white object into a field of a black object. +** +** It's ok to LEAVE OUT the write barrier ONLY in the following cases: +** - The source is not a GC object (NULL). +** - The target is a GC root. I.e. everything in global_State. +** - The target is a lua_State field (threads are never black). +** - The target is a stack slot, see setgcV et al. +** - The target is an open upvalue, i.e. pointing to a stack slot. +** - The target is a newly created object (i.e. marked white). But make +** sure nothing invokes the GC inbetween. +** - The target and the source are the same object (self-reference). +** - The target already contains the object (e.g. moving elements around). +** +** The most common case is a store to a stack slot. All other cases where +** a barrier has been omitted are annotated with a NOBARRIER comment. +** +** The same logic applies for stores to table slots (array part or hash +** part). ALL uses of lj_tab_set* require a barrier for the stored value +** *and* the stored key, based on the above rules. In practice this means +** a barrier is needed if *either* of the key or value are a GC object. +** +** It's ok to LEAVE OUT the write barrier in the following special cases: +** - The stored value is nil. The key doesn't matter because it's either +** not resurrected or lj_tab_newkey() will take care of the key barrier. +** - The key doesn't matter if the *previously* stored value is guaranteed +** to be non-nil (because the key is kept alive in the table). +** - The key doesn't matter if it's guaranteed not to be part of the table, +** since lj_tab_newkey() takes care of the key barrier. This applies +** trivially to new tables, but watch out for resurrected keys. Storing +** a nil value leaves the key in the table! +** +** In case of doubt use lj_gc_anybarriert() as it's rather cheap. It's used +** by the interpreter for all table stores. +** +** Note: In contrast to Lua's GC, LuaJIT's GC does *not* specially mark +** dead keys in tables. The reference is left in, but it's guaranteed to +** be never dereferenced as long as the value is nil. It's ok if the key is +** freed or if any object subsequently gets the same address. +** +** Not destroying dead keys helps to keep key hash slots stable. This avoids +** specialization back-off for HREFK when a value flips between nil and +** non-nil and the GC gets in the way. It also allows safely hoisting +** HREF/HREFK across GC steps. Dead keys are only removed if a table is +** resized (i.e. by NEWREF) and xREF must not be CSEd across a resize. +** +** The trade-off is that a write barrier for tables must take the key into +** account, too. Implicitly resurrecting the key by storing a non-nil value +** may invalidate the incremental GC invariant. +*/ + +/* -- Common type definitions --------------------------------------------- */ + +/* Types for handling bytecodes. Need this here, details in lj_bc.h. */ +typedef uint32_t BCIns; /* Bytecode instruction. */ +typedef uint32_t BCPos; /* Bytecode position. */ +typedef uint32_t BCReg; /* Bytecode register. */ +typedef int32_t BCLine; /* Bytecode line number. */ + +/* Internal assembler functions. Never call these directly from C. */ +typedef void (*ASMFunction)(void); + +/* Resizable string buffer. Need this here, details in lj_str.h. */ +typedef struct SBuf { + char *buf; /* String buffer base. */ + MSize n; /* String buffer length. */ + MSize sz; /* String buffer size. */ +} SBuf; + +/* -- Tags and values ----------------------------------------------------- */ + +/* Frame link. */ +typedef union { + int32_t ftsz; /* Frame type and size of previous frame. */ + MRef pcr; /* Overlaps PC for Lua frames. */ +} FrameLink; + +/* Tagged value. */ +typedef LJ_ALIGN(8) union TValue { + uint64_t u64; /* 64 bit pattern overlaps number. */ + lua_Number n; /* Number object overlaps split tag/value object. */ + struct { + LJ_ENDIAN_LOHI( + union { + GCRef gcr; /* GCobj reference (if any). */ + int32_t i; /* Integer value. */ + }; + , uint32_t it; /* Internal object tag. Must overlap MSW of number. */ + ) + }; + struct { + LJ_ENDIAN_LOHI( + GCRef func; /* Function for next frame (or dummy L). */ + , FrameLink tp; /* Link to previous frame. */ + ) + } fr; + struct { + LJ_ENDIAN_LOHI( + uint32_t lo; /* Lower 32 bits of number. */ + , uint32_t hi; /* Upper 32 bits of number. */ + ) + } u32; +} TValue; + +typedef const TValue cTValue; + +#define tvref(r) (mref(r, TValue)) + +/* More external and GCobj tags for internal objects. */ +#define LAST_TT LUA_TTHREAD +#define LUA_TPROTO (LAST_TT+1) +#define LUA_TCDATA (LAST_TT+2) + +/* Internal object tags. +** +** Internal tags overlap the MSW of a number object (must be a double). +** Interpreted as a double these are special NaNs. The FPU only generates +** one type of NaN (0xfff8_0000_0000_0000). So MSWs > 0xfff80000 are available +** for use as internal tags. Small negative numbers are used to shorten the +** encoding of type comparisons (reg/mem against sign-ext. 8 bit immediate). +** +** ---MSW---.---LSW--- +** primitive types | itype | | +** lightuserdata | itype | void * | (32 bit platforms) +** lightuserdata |ffff| void * | (64 bit platforms, 47 bit pointers) +** GC objects | itype | GCRef | +** int (LJ_DUALNUM)| itype | int | +** number -------double------ +** +** ORDER LJ_T +** Primitive types nil/false/true must be first, lightuserdata next. +** GC objects are at the end, table/userdata must be lowest. +** Also check lj_ir.h for similar ordering constraints. +*/ +#define LJ_TNIL (~0u) +#define LJ_TFALSE (~1u) +#define LJ_TTRUE (~2u) +#define LJ_TLIGHTUD (~3u) +#define LJ_TSTR (~4u) +#define LJ_TUPVAL (~5u) +#define LJ_TTHREAD (~6u) +#define LJ_TPROTO (~7u) +#define LJ_TFUNC (~8u) +#define LJ_TTRACE (~9u) +#define LJ_TCDATA (~10u) +#define LJ_TTAB (~11u) +#define LJ_TUDATA (~12u) +/* This is just the canonical number type used in some places. */ +#define LJ_TNUMX (~13u) + +/* Integers have itype == LJ_TISNUM doubles have itype < LJ_TISNUM */ +#if LJ_64 +#define LJ_TISNUM 0xfffeffffu +#else +#define LJ_TISNUM LJ_TNUMX +#endif +#define LJ_TISTRUECOND LJ_TFALSE +#define LJ_TISPRI LJ_TTRUE +#define LJ_TISGCV (LJ_TSTR+1) +#define LJ_TISTABUD LJ_TTAB + +/* -- String object ------------------------------------------------------- */ + +/* String object header. String payload follows. */ +typedef struct GCstr { + GCHeader; + uint8_t reserved; /* Used by lexer for fast lookup of reserved words. */ + uint8_t unused; + MSize hash; /* Hash of string. */ + MSize len; /* Size of string. */ +} GCstr; + +#define strref(r) (&gcref((r))->str) +#define strdata(s) ((const char *)((s)+1)) +#define strdatawr(s) ((char *)((s)+1)) +#define strVdata(o) strdata(strV(o)) +#define sizestring(s) (sizeof(struct GCstr)+(s)->len+1) + +/* -- Userdata object ----------------------------------------------------- */ + +/* Userdata object. Payload follows. */ +typedef struct GCudata { + GCHeader; + uint8_t udtype; /* Userdata type. */ + uint8_t unused2; + GCRef env; /* Should be at same offset in GCfunc. */ + MSize len; /* Size of payload. */ + GCRef metatable; /* Must be at same offset in GCtab. */ + uint32_t align1; /* To force 8 byte alignment of the payload. */ +} GCudata; + +/* Userdata types. */ +enum { + UDTYPE_USERDATA, /* Regular userdata. */ + UDTYPE_IO_FILE, /* I/O library FILE. */ + UDTYPE_FFI_CLIB, /* FFI C library namespace. */ + UDTYPE__MAX +}; + +#define uddata(u) ((void *)((u)+1)) +#define sizeudata(u) (sizeof(struct GCudata)+(u)->len) + +/* -- C data object ------------------------------------------------------- */ + +/* C data object. Payload follows. */ +typedef struct GCcdata { + GCHeader; + uint16_t ctypeid; /* C type ID. */ +} GCcdata; + +/* Prepended to variable-sized or realigned C data objects. */ +typedef struct GCcdataVar { + uint16_t offset; /* Offset to allocated memory (relative to GCcdata). */ + uint16_t extra; /* Extra space allocated (incl. GCcdata + GCcdatav). */ + MSize len; /* Size of payload. */ +} GCcdataVar; + +#define cdataptr(cd) ((void *)((cd)+1)) +#define cdataisv(cd) ((cd)->marked & 0x80) +#define cdatav(cd) ((GCcdataVar *)((char *)(cd) - sizeof(GCcdataVar))) +#define cdatavlen(cd) check_exp(cdataisv(cd), cdatav(cd)->len) +#define sizecdatav(cd) (cdatavlen(cd) + cdatav(cd)->extra) +#define memcdatav(cd) ((void *)((char *)(cd) - cdatav(cd)->offset)) + +/* -- Prototype object ---------------------------------------------------- */ + +#define SCALE_NUM_GCO ((int32_t)sizeof(lua_Number)/sizeof(GCRef)) +#define round_nkgc(n) (((n) + SCALE_NUM_GCO-1) & ~(SCALE_NUM_GCO-1)) + +typedef struct GCproto { + GCHeader; + uint8_t numparams; /* Number of parameters. */ + uint8_t framesize; /* Fixed frame size. */ + MSize sizebc; /* Number of bytecode instructions. */ + GCRef gclist; + MRef k; /* Split constant array (points to the middle). */ + MRef uv; /* Upvalue list. local slot|0x8000 or parent uv idx. */ + MSize sizekgc; /* Number of collectable constants. */ + MSize sizekn; /* Number of lua_Number constants. */ + MSize sizept; /* Total size including colocated arrays. */ + uint8_t sizeuv; /* Number of upvalues. */ + uint8_t flags; /* Miscellaneous flags (see below). */ + uint16_t trace; /* Anchor for chain of root traces. */ + /* ------ The following fields are for debugging/tracebacks only ------ */ + GCRef chunkname; /* Name of the chunk this function was defined in. */ + BCLine firstline; /* First line of the function definition. */ + BCLine numline; /* Number of lines for the function definition. */ + MRef lineinfo; /* Compressed map from bytecode ins. to source line. */ + MRef uvinfo; /* Upvalue names. */ + MRef varinfo; /* Names and compressed extents of local variables. */ +} GCproto; + +/* Flags for prototype. */ +#define PROTO_CHILD 0x01 /* Has child prototypes. */ +#define PROTO_VARARG 0x02 /* Vararg function. */ +#define PROTO_FFI 0x04 /* Uses BC_KCDATA for FFI datatypes. */ +#define PROTO_NOJIT 0x08 /* JIT disabled for this function. */ +#define PROTO_ILOOP 0x10 /* Patched bytecode with ILOOP etc. */ +/* Only used during parsing. */ +#define PROTO_HAS_RETURN 0x20 /* Already emitted a return. */ +#define PROTO_FIXUP_RETURN 0x40 /* Need to fixup emitted returns. */ +/* Top bits used for counting created closures. */ +#define PROTO_CLCOUNT 0x20 /* Base of saturating 3 bit counter. */ +#define PROTO_CLC_BITS 3 +#define PROTO_CLC_POLY (3*PROTO_CLCOUNT) /* Polymorphic threshold. */ + +#define PROTO_UV_LOCAL 0x8000 /* Upvalue for local slot. */ +#define PROTO_UV_IMMUTABLE 0x4000 /* Immutable upvalue. */ + +#define proto_kgc(pt, idx) \ + check_exp((uintptr_t)(intptr_t)(idx) >= (uintptr_t)-(intptr_t)(pt)->sizekgc, \ + gcref(mref((pt)->k, GCRef)[(idx)])) +#define proto_knumtv(pt, idx) \ + check_exp((uintptr_t)(idx) < (pt)->sizekn, &mref((pt)->k, TValue)[(idx)]) +#define proto_bc(pt) ((BCIns *)((char *)(pt) + sizeof(GCproto))) +#define proto_bcpos(pt, pc) ((BCPos)((pc) - proto_bc(pt))) +#define proto_uv(pt) (mref((pt)->uv, uint16_t)) + +#define proto_chunkname(pt) (strref((pt)->chunkname)) +#define proto_chunknamestr(pt) (strdata(proto_chunkname((pt)))) +#define proto_lineinfo(pt) (mref((pt)->lineinfo, const void)) +#define proto_uvinfo(pt) (mref((pt)->uvinfo, const uint8_t)) +#define proto_varinfo(pt) (mref((pt)->varinfo, const uint8_t)) + +/* -- Upvalue object ------------------------------------------------------ */ + +typedef struct GCupval { + GCHeader; + uint8_t closed; /* Set if closed (i.e. uv->v == &uv->u.value). */ + uint8_t immutable; /* Immutable value. */ + union { + TValue tv; /* If closed: the value itself. */ + struct { /* If open: double linked list, anchored at thread. */ + GCRef prev; + GCRef next; + }; + }; + MRef v; /* Points to stack slot (open) or above (closed). */ + uint32_t dhash; /* Disambiguation hash: dh1 != dh2 => cannot alias. */ +} GCupval; + +#define uvprev(uv_) (&gcref((uv_)->prev)->uv) +#define uvnext(uv_) (&gcref((uv_)->next)->uv) +#define uvval(uv_) (mref((uv_)->v, TValue)) + +/* -- Function object (closures) ------------------------------------------ */ + +/* Common header for functions. env should be at same offset in GCudata. */ +#define GCfuncHeader \ + GCHeader; uint8_t ffid; uint8_t nupvalues; \ + GCRef env; GCRef gclist; MRef pc + +typedef struct GCfuncC { + GCfuncHeader; + lua_CFunction f; /* C function to be called. */ + TValue upvalue[1]; /* Array of upvalues (TValue). */ +} GCfuncC; + +typedef struct GCfuncL { + GCfuncHeader; + GCRef uvptr[1]; /* Array of _pointers_ to upvalue objects (GCupval). */ +} GCfuncL; + +typedef union GCfunc { + GCfuncC c; + GCfuncL l; +} GCfunc; + +#define FF_LUA 0 +#define FF_C 1 +#define isluafunc(fn) ((fn)->c.ffid == FF_LUA) +#define iscfunc(fn) ((fn)->c.ffid == FF_C) +#define isffunc(fn) ((fn)->c.ffid > FF_C) +#define funcproto(fn) \ + check_exp(isluafunc(fn), (GCproto *)(mref((fn)->l.pc, char)-sizeof(GCproto))) +#define sizeCfunc(n) (sizeof(GCfuncC)-sizeof(TValue)+sizeof(TValue)*(n)) +#define sizeLfunc(n) (sizeof(GCfuncL)-sizeof(GCRef)+sizeof(GCRef)*(n)) + +/* -- Table object -------------------------------------------------------- */ + +/* Hash node. */ +typedef struct Node { + TValue val; /* Value object. Must be first field. */ + TValue key; /* Key object. */ + MRef next; /* Hash chain. */ + MRef freetop; /* Top of free elements (stored in t->node[0]). */ +} Node; + +LJ_STATIC_ASSERT(offsetof(Node, val) == 0); + +typedef struct GCtab { + GCHeader; + uint8_t nomm; /* Negative cache for fast metamethods. */ + int8_t colo; /* Array colocation. */ + MRef array; /* Array part. */ + GCRef gclist; + GCRef metatable; /* Must be at same offset in GCudata. */ + MRef node; /* Hash part. */ + uint32_t asize; /* Size of array part (keys [0, asize-1]). */ + uint32_t hmask; /* Hash part mask (size of hash part - 1). */ +} GCtab; + +#define sizetabcolo(n) ((n)*sizeof(TValue) + sizeof(GCtab)) +#define tabref(r) (&gcref((r))->tab) +#define noderef(r) (mref((r), Node)) +#define nextnode(n) (mref((n)->next, Node)) + +/* -- State objects ------------------------------------------------------- */ + +/* VM states. */ +enum { + LJ_VMST_INTERP, /* Interpreter. */ + LJ_VMST_C, /* C function. */ + LJ_VMST_GC, /* Garbage collector. */ + LJ_VMST_EXIT, /* Trace exit handler. */ + LJ_VMST_RECORD, /* Trace recorder. */ + LJ_VMST_OPT, /* Optimizer. */ + LJ_VMST_ASM, /* Assembler. */ + LJ_VMST__MAX +}; + +#define setvmstate(g, st) ((g)->vmstate = ~LJ_VMST_##st) + +/* Metamethods. ORDER MM */ +#ifdef LJ_HASFFI +#define MMDEF_FFI(_) _(new) +#else +#define MMDEF_FFI(_) +#endif + +#if LJ_52 || LJ_HASFFI +#define MMDEF_PAIRS(_) _(pairs) _(ipairs) +#else +#define MMDEF_PAIRS(_) +#define MM_pairs 255 +#define MM_ipairs 255 +#endif + +#define MMDEF(_) \ + _(index) _(newindex) _(gc) _(mode) _(eq) _(len) \ + /* Only the above (fast) metamethods are negative cached (max. 8). */ \ + _(lt) _(le) _(concat) _(call) \ + /* The following must be in ORDER ARITH. */ \ + _(add) _(sub) _(mul) _(div) _(mod) _(pow) _(unm) \ + /* The following are used in the standard libraries. */ \ + _(metatable) _(tostring) MMDEF_FFI(_) MMDEF_PAIRS(_) + +typedef enum { +#define MMENUM(name) MM_##name, +MMDEF(MMENUM) +#undef MMENUM + MM__MAX, + MM____ = MM__MAX, + MM_FAST = MM_len +} MMS; + +/* GC root IDs. */ +typedef enum { + GCROOT_MMNAME, /* Metamethod names. */ + GCROOT_MMNAME_LAST = GCROOT_MMNAME + MM__MAX-1, + GCROOT_BASEMT, /* Metatables for base types. */ + GCROOT_BASEMT_NUM = GCROOT_BASEMT + ~LJ_TNUMX, + GCROOT_IO_INPUT, /* Userdata for default I/O input file. */ + GCROOT_IO_OUTPUT, /* Userdata for default I/O output file. */ + GCROOT_MAX +} GCRootID; + +#define basemt_it(g, it) ((g)->gcroot[GCROOT_BASEMT+~(it)]) +#define basemt_obj(g, o) ((g)->gcroot[GCROOT_BASEMT+itypemap(o)]) +#define mmname_str(g, mm) (strref((g)->gcroot[GCROOT_MMNAME+(mm)])) + +typedef struct GCState { + MSize total; /* Memory currently allocated. */ + MSize threshold; /* Memory threshold. */ + uint8_t currentwhite; /* Current white color. */ + uint8_t state; /* GC state. */ + uint8_t nocdatafin; /* No cdata finalizer called. */ + uint8_t unused2; + MSize sweepstr; /* Sweep position in string table. */ + GCRef root; /* List of all collectable objects. */ + MRef sweep; /* Sweep position in root list. */ + GCRef gray; /* List of gray objects. */ + GCRef grayagain; /* List of objects for atomic traversal. */ + GCRef weak; /* List of weak tables (to be cleared). */ + GCRef mmudata; /* List of userdata (to be finalized). */ + MSize stepmul; /* Incremental GC step granularity. */ + MSize debt; /* Debt (how much GC is behind schedule). */ + MSize estimate; /* Estimate of memory actually in use. */ + MSize pause; /* Pause between successive GC cycles. */ +} GCState; + +/* Global state, shared by all threads of a Lua universe. */ +typedef struct global_State { + GCRef *strhash; /* String hash table (hash chain anchors). */ + MSize strmask; /* String hash mask (size of hash table - 1). */ + MSize strnum; /* Number of strings in hash table. */ + lua_Alloc allocf; /* Memory allocator. */ + void *allocd; /* Memory allocator data. */ + GCState gc; /* Garbage collector. */ + SBuf tmpbuf; /* Temporary buffer for string concatenation. */ + Node nilnode; /* Fallback 1-element hash part (nil key and value). */ + GCstr strempty; /* Empty string. */ + uint8_t stremptyz; /* Zero terminator of empty string. */ + uint8_t hookmask; /* Hook mask. */ + uint8_t dispatchmode; /* Dispatch mode. */ + uint8_t vmevmask; /* VM event mask. */ + GCRef mainthref; /* Link to main thread. */ + TValue registrytv; /* Anchor for registry. */ + TValue tmptv, tmptv2; /* Temporary TValues. */ + GCupval uvhead; /* Head of double-linked list of all open upvalues. */ + int32_t hookcount; /* Instruction hook countdown. */ + int32_t hookcstart; /* Start count for instruction hook counter. */ + lua_Hook hookf; /* Hook function. */ + lua_CFunction wrapf; /* Wrapper for C function calls. */ + lua_CFunction panic; /* Called as a last resort for errors. */ + volatile int32_t vmstate; /* VM state or current JIT code trace number. */ + BCIns bc_cfunc_int; /* Bytecode for internal C function calls. */ + BCIns bc_cfunc_ext; /* Bytecode for external C function calls. */ + GCRef jit_L; /* Current JIT code lua_State or NULL. */ + MRef jit_base; /* Current JIT code L->base. */ + MRef ctype_state; /* Pointer to C type state. */ + GCRef gcroot[GCROOT_MAX]; /* GC roots. */ +} global_State; + +#define mainthread(g) (&gcref(g->mainthref)->th) +#define niltv(L) \ + check_exp(tvisnil(&G(L)->nilnode.val), &G(L)->nilnode.val) +#define niltvg(g) \ + check_exp(tvisnil(&(g)->nilnode.val), &(g)->nilnode.val) + +/* Hook management. Hook event masks are defined in lua.h. */ +#define HOOK_EVENTMASK 0x0f +#define HOOK_ACTIVE 0x10 +#define HOOK_ACTIVE_SHIFT 4 +#define HOOK_VMEVENT 0x20 +#define HOOK_GC 0x40 +#define hook_active(g) ((g)->hookmask & HOOK_ACTIVE) +#define hook_enter(g) ((g)->hookmask |= HOOK_ACTIVE) +#define hook_entergc(g) ((g)->hookmask |= (HOOK_ACTIVE|HOOK_GC)) +#define hook_vmevent(g) ((g)->hookmask |= (HOOK_ACTIVE|HOOK_VMEVENT)) +#define hook_leave(g) ((g)->hookmask &= ~HOOK_ACTIVE) +#define hook_save(g) ((g)->hookmask & ~HOOK_EVENTMASK) +#define hook_restore(g, h) \ + ((g)->hookmask = ((g)->hookmask & HOOK_EVENTMASK) | (h)) + +/* Per-thread state object. */ +struct lua_State { + GCHeader; + uint8_t dummy_ffid; /* Fake FF_C for curr_funcisL() on dummy frames. */ + uint8_t status; /* Thread status. */ + MRef glref; /* Link to global state. */ + GCRef gclist; /* GC chain. */ + TValue *base; /* Base of currently executing function. */ + TValue *top; /* First free slot in the stack. */ + MRef maxstack; /* Last free slot in the stack. */ + MRef stack; /* Stack base. */ + GCRef openupval; /* List of open upvalues in the stack. */ + GCRef env; /* Thread environment (table of globals). */ + void *cframe; /* End of C stack frame chain. */ + MSize stacksize; /* True stack size (incl. LJ_STACK_EXTRA). */ +}; + +#define G(L) (mref(L->glref, global_State)) +#define registry(L) (&G(L)->registrytv) + +/* Macros to access the currently executing (Lua) function. */ +#define curr_func(L) (&gcref((L->base-1)->fr.func)->fn) +#define curr_funcisL(L) (isluafunc(curr_func(L))) +#define curr_proto(L) (funcproto(curr_func(L))) +#define curr_topL(L) (L->base + curr_proto(L)->framesize) +#define curr_top(L) (curr_funcisL(L) ? curr_topL(L) : L->top) + +/* -- GC object definition and conversions -------------------------------- */ + +/* GC header for generic access to common fields of GC objects. */ +typedef struct GChead { + GCHeader; + uint8_t unused1; + uint8_t unused2; + GCRef env; + GCRef gclist; + GCRef metatable; +} GChead; + +/* The env field SHOULD be at the same offset for all GC objects. */ +LJ_STATIC_ASSERT(offsetof(GChead, env) == offsetof(GCfuncL, env)); +LJ_STATIC_ASSERT(offsetof(GChead, env) == offsetof(GCudata, env)); + +/* The metatable field MUST be at the same offset for all GC objects. */ +LJ_STATIC_ASSERT(offsetof(GChead, metatable) == offsetof(GCtab, metatable)); +LJ_STATIC_ASSERT(offsetof(GChead, metatable) == offsetof(GCudata, metatable)); + +/* The gclist field MUST be at the same offset for all GC objects. */ +LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(lua_State, gclist)); +LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCproto, gclist)); +LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCfuncL, gclist)); +LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCtab, gclist)); + +typedef union GCobj { + GChead gch; + GCstr str; + GCupval uv; + lua_State th; + GCproto pt; + GCfunc fn; + GCcdata cd; + GCtab tab; + GCudata ud; +} GCobj; + +/* Macros to convert a GCobj pointer into a specific value. */ +#define gco2str(o) check_exp((o)->gch.gct == ~LJ_TSTR, &(o)->str) +#define gco2uv(o) check_exp((o)->gch.gct == ~LJ_TUPVAL, &(o)->uv) +#define gco2th(o) check_exp((o)->gch.gct == ~LJ_TTHREAD, &(o)->th) +#define gco2pt(o) check_exp((o)->gch.gct == ~LJ_TPROTO, &(o)->pt) +#define gco2func(o) check_exp((o)->gch.gct == ~LJ_TFUNC, &(o)->fn) +#define gco2cd(o) check_exp((o)->gch.gct == ~LJ_TCDATA, &(o)->cd) +#define gco2tab(o) check_exp((o)->gch.gct == ~LJ_TTAB, &(o)->tab) +#define gco2ud(o) check_exp((o)->gch.gct == ~LJ_TUDATA, &(o)->ud) + +/* Macro to convert any collectable object into a GCobj pointer. */ +#define obj2gco(v) ((GCobj *)(v)) + +/* -- TValue getters/setters ---------------------------------------------- */ + +#ifdef LUA_USE_ASSERT +#include "lj_gc.h" +#endif + +/* Macros to test types. */ +#define itype(o) ((o)->it) +#define tvisnil(o) (itype(o) == LJ_TNIL) +#define tvisfalse(o) (itype(o) == LJ_TFALSE) +#define tvistrue(o) (itype(o) == LJ_TTRUE) +#define tvisbool(o) (tvisfalse(o) || tvistrue(o)) +#if LJ_64 +#define tvislightud(o) (((int32_t)itype(o) >> 15) == -2) +#else +#define tvislightud(o) (itype(o) == LJ_TLIGHTUD) +#endif +#define tvisstr(o) (itype(o) == LJ_TSTR) +#define tvisfunc(o) (itype(o) == LJ_TFUNC) +#define tvisthread(o) (itype(o) == LJ_TTHREAD) +#define tvisproto(o) (itype(o) == LJ_TPROTO) +#define tviscdata(o) (itype(o) == LJ_TCDATA) +#define tvistab(o) (itype(o) == LJ_TTAB) +#define tvisudata(o) (itype(o) == LJ_TUDATA) +#define tvisnumber(o) (itype(o) <= LJ_TISNUM) +#define tvisint(o) (LJ_DUALNUM && itype(o) == LJ_TISNUM) +#define tvisnum(o) (itype(o) < LJ_TISNUM) + +#define tvistruecond(o) (itype(o) < LJ_TISTRUECOND) +#define tvispri(o) (itype(o) >= LJ_TISPRI) +#define tvistabud(o) (itype(o) <= LJ_TISTABUD) /* && !tvisnum() */ +#define tvisgcv(o) ((itype(o) - LJ_TISGCV) > (LJ_TNUMX - LJ_TISGCV)) + +/* Special macros to test numbers for NaN, +0, -0, +1 and raw equality. */ +#define tvisnan(o) ((o)->n != (o)->n) +#if LJ_64 +#define tviszero(o) (((o)->u64 << 1) == 0) +#else +#define tviszero(o) (((o)->u32.lo | ((o)->u32.hi << 1)) == 0) +#endif +#define tvispzero(o) ((o)->u64 == 0) +#define tvismzero(o) ((o)->u64 == U64x(80000000,00000000)) +#define tvispone(o) ((o)->u64 == U64x(3ff00000,00000000)) +#define rawnumequal(o1, o2) ((o1)->u64 == (o2)->u64) + +/* Macros to convert type ids. */ +#if LJ_64 +#define itypemap(o) \ + (tvisnumber(o) ? ~LJ_TNUMX : tvislightud(o) ? ~LJ_TLIGHTUD : ~itype(o)) +#else +#define itypemap(o) (tvisnumber(o) ? ~LJ_TNUMX : ~itype(o)) +#endif + +/* Macros to get tagged values. */ +#define gcval(o) (gcref((o)->gcr)) +#define boolV(o) check_exp(tvisbool(o), (LJ_TFALSE - (o)->it)) +#if LJ_64 +#define lightudV(o) \ + check_exp(tvislightud(o), (void *)((o)->u64 & U64x(00007fff,ffffffff))) +#else +#define lightudV(o) check_exp(tvislightud(o), gcrefp((o)->gcr, void)) +#endif +#define gcV(o) check_exp(tvisgcv(o), gcval(o)) +#define strV(o) check_exp(tvisstr(o), &gcval(o)->str) +#define funcV(o) check_exp(tvisfunc(o), &gcval(o)->fn) +#define threadV(o) check_exp(tvisthread(o), &gcval(o)->th) +#define protoV(o) check_exp(tvisproto(o), &gcval(o)->pt) +#define cdataV(o) check_exp(tviscdata(o), &gcval(o)->cd) +#define tabV(o) check_exp(tvistab(o), &gcval(o)->tab) +#define udataV(o) check_exp(tvisudata(o), &gcval(o)->ud) +#define numV(o) check_exp(tvisnum(o), (o)->n) +#define intV(o) check_exp(tvisint(o), (int32_t)(o)->i) + +/* Macros to set tagged values. */ +#define setitype(o, i) ((o)->it = (i)) +#define setnilV(o) ((o)->it = LJ_TNIL) +#define setboolV(o, x) ((o)->it = LJ_TFALSE-(uint32_t)(x)) + +static LJ_AINLINE void setlightudV(TValue *o, void *p) +{ +#if LJ_64 + o->u64 = (uint64_t)p | (((uint64_t)0xffff) << 48); +#else + setgcrefp(o->gcr, p); setitype(o, LJ_TLIGHTUD); +#endif +} + +#if LJ_64 +#define checklightudptr(L, p) \ + (((uint64_t)(p) >> 47) ? (lj_err_msg(L, LJ_ERR_BADLU), NULL) : (p)) +#define setcont(o, f) \ + ((o)->u64 = (uint64_t)(void *)(f) - (uint64_t)lj_vm_asm_begin) +#else +#define checklightudptr(L, p) (p) +#define setcont(o, f) setlightudV((o), (void *)(f)) +#endif + +#define tvchecklive(L, o) \ + UNUSED(L), lua_assert(!tvisgcv(o) || \ + ((~itype(o) == gcval(o)->gch.gct) && !isdead(G(L), gcval(o)))) + +static LJ_AINLINE void setgcV(lua_State *L, TValue *o, GCobj *v, uint32_t itype) +{ + setgcref(o->gcr, v); setitype(o, itype); tvchecklive(L, o); +} + +#define define_setV(name, type, tag) \ +static LJ_AINLINE void name(lua_State *L, TValue *o, type *v) \ +{ \ + setgcV(L, o, obj2gco(v), tag); \ +} +define_setV(setstrV, GCstr, LJ_TSTR) +define_setV(setthreadV, lua_State, LJ_TTHREAD) +define_setV(setprotoV, GCproto, LJ_TPROTO) +define_setV(setfuncV, GCfunc, LJ_TFUNC) +define_setV(setcdataV, GCcdata, LJ_TCDATA) +define_setV(settabV, GCtab, LJ_TTAB) +define_setV(setudataV, GCudata, LJ_TUDATA) + +#define setnumV(o, x) ((o)->n = (x)) +#define setnanV(o) ((o)->u64 = U64x(fff80000,00000000)) +#define setpinfV(o) ((o)->u64 = U64x(7ff00000,00000000)) +#define setminfV(o) ((o)->u64 = U64x(fff00000,00000000)) + +static LJ_AINLINE void setintV(TValue *o, int32_t i) +{ +#if LJ_DUALNUM + o->i = (uint32_t)i; setitype(o, LJ_TISNUM); +#else + o->n = (lua_Number)i; +#endif +} + +static LJ_AINLINE void setint64V(TValue *o, int64_t i) +{ + if (LJ_DUALNUM && LJ_LIKELY(i == (int64_t)(int32_t)i)) + setintV(o, (int32_t)i); + else + setnumV(o, (lua_Number)i); +} + +#if LJ_64 +#define setintptrV(o, i) setint64V((o), (i)) +#else +#define setintptrV(o, i) setintV((o), (i)) +#endif + +/* Copy tagged values. */ +static LJ_AINLINE void copyTV(lua_State *L, TValue *o1, const TValue *o2) +{ + *o1 = *o2; tvchecklive(L, o1); +} + +/* -- Number to integer conversion ---------------------------------------- */ + +#if LJ_SOFTFP +LJ_ASMF int32_t lj_vm_tobit(double x); +#endif + +static LJ_AINLINE int32_t lj_num2bit(lua_Number n) +{ +#if LJ_SOFTFP + return lj_vm_tobit(n); +#else + TValue o; + o.n = n + 6755399441055744.0; /* 2^52 + 2^51 */ + return (int32_t)o.u32.lo; +#endif +} + +#if LJ_TARGET_X86 && !defined(__SSE2__) +#define lj_num2int(n) lj_num2bit((n)) +#else +#define lj_num2int(n) ((int32_t)(n)) +#endif + +static LJ_AINLINE uint64_t lj_num2u64(lua_Number n) +{ +#ifdef _MSC_VER + if (n >= 9223372036854775808.0) /* They think it's a feature. */ + return (uint64_t)(int64_t)(n - 18446744073709551616.0); + else +#endif + return (uint64_t)n; +} + +static LJ_AINLINE int32_t numberVint(cTValue *o) +{ + if (LJ_LIKELY(tvisint(o))) + return intV(o); + else + return lj_num2int(numV(o)); +} + +static LJ_AINLINE lua_Number numberVnum(cTValue *o) +{ + if (LJ_UNLIKELY(tvisint(o))) + return (lua_Number)intV(o); + else + return numV(o); +} + +/* -- Miscellaneous object handling --------------------------------------- */ + +/* Names and maps for internal and external object tags. */ +LJ_DATA const char *const lj_obj_typename[1+LUA_TCDATA+1]; +LJ_DATA const char *const lj_obj_itypename[~LJ_TNUMX+1]; + +#define lj_typename(o) (lj_obj_itypename[itypemap(o)]) + +/* Compare two objects without calling metamethods. */ +LJ_FUNC int lj_obj_equal(cTValue *o1, cTValue *o2); + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_dce.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_dce.c new file mode 100644 index 000000000..7f1faafe6 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_dce.c @@ -0,0 +1,78 @@ +/* +** DCE: Dead Code Elimination. Pre-LOOP only -- ASM already performs DCE. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_opt_dce_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_iropt.h" + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) + +/* Scan through all snapshots and mark all referenced instructions. */ +static void dce_marksnap(jit_State *J) +{ + SnapNo i, nsnap = J->cur.nsnap; + for (i = 0; i < nsnap; i++) { + SnapShot *snap = &J->cur.snap[i]; + SnapEntry *map = &J->cur.snapmap[snap->mapofs]; + MSize n, nent = snap->nent; + for (n = 0; n < nent; n++) { + IRRef ref = snap_ref(map[n]); + if (ref >= REF_FIRST) + irt_setmark(IR(ref)->t); + } + } +} + +/* Backwards propagate marks. Replace unused instructions with NOPs. */ +static void dce_propagate(jit_State *J) +{ + IRRef1 *pchain[IR__MAX]; + IRRef ins; + uint32_t i; + for (i = 0; i < IR__MAX; i++) pchain[i] = &J->chain[i]; + for (ins = J->cur.nins-1; ins >= REF_FIRST; ins--) { + IRIns *ir = IR(ins); + if (irt_ismarked(ir->t)) { + irt_clearmark(ir->t); + pchain[ir->o] = &ir->prev; + } else if (!ir_sideeff(ir)) { + *pchain[ir->o] = ir->prev; /* Reroute original instruction chain. */ + ir->t.irt = IRT_NIL; + ir->o = IR_NOP; /* Replace instruction with NOP. */ + ir->op1 = ir->op2 = 0; + ir->prev = 0; + continue; + } + if (ir->op1 >= REF_FIRST) irt_setmark(IR(ir->op1)->t); + if (ir->op2 >= REF_FIRST) irt_setmark(IR(ir->op2)->t); + } +} + +/* Dead Code Elimination. +** +** First backpropagate marks for all used instructions. Then replace +** the unused ones with a NOP. Note that compressing the IR to eliminate +** the NOPs does not pay off. +*/ +void lj_opt_dce(jit_State *J) +{ + if ((J->flags & JIT_F_OPT_DCE)) { + dce_marksnap(J); + dce_propagate(J); + memset(J->bpropcache, 0, sizeof(J->bpropcache)); /* Invalidate cache. */ + } +} + +#undef IR + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_fold.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_fold.c new file mode 100644 index 000000000..d00fdd56f --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_fold.c @@ -0,0 +1,2304 @@ +/* +** FOLD: Constant Folding, Algebraic Simplifications and Reassociation. +** ABCelim: Array Bounds Check Elimination. +** CSE: Common-Subexpression Elimination. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_opt_fold_c +#define LUA_CORE + +#include + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_iropt.h" +#include "lj_trace.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#endif +#include "lj_carith.h" +#include "lj_vm.h" +#include "lj_strscan.h" + +/* Here's a short description how the FOLD engine processes instructions: +** +** The FOLD engine receives a single instruction stored in fins (J->fold.ins). +** The instruction and its operands are used to select matching fold rules. +** These are applied iteratively until a fixed point is reached. +** +** The 8 bit opcode of the instruction itself plus the opcodes of the +** two instructions referenced by its operands form a 24 bit key +** 'ins left right' (unused operands -> 0, literals -> lowest 8 bits). +** +** This key is used for partial matching against the fold rules. The +** left/right operand fields of the key are successively masked with +** the 'any' wildcard, from most specific to least specific: +** +** ins left right +** ins any right +** ins left any +** ins any any +** +** The masked key is used to lookup a matching fold rule in a semi-perfect +** hash table. If a matching rule is found, the related fold function is run. +** Multiple rules can share the same fold function. A fold rule may return +** one of several special values: +** +** - NEXTFOLD means no folding was applied, because an additional test +** inside the fold function failed. Matching continues against less +** specific fold rules. Finally the instruction is passed on to CSE. +** +** - RETRYFOLD means the instruction was modified in-place. Folding is +** retried as if this instruction had just been received. +** +** All other return values are terminal actions -- no further folding is +** applied: +** +** - INTFOLD(i) returns a reference to the integer constant i. +** +** - LEFTFOLD and RIGHTFOLD return the left/right operand reference +** without emitting an instruction. +** +** - CSEFOLD and EMITFOLD pass the instruction directly to CSE or emit +** it without passing through any further optimizations. +** +** - FAILFOLD, DROPFOLD and CONDFOLD only apply to instructions which have +** no result (e.g. guarded assertions): FAILFOLD means the guard would +** always fail, i.e. the current trace is pointless. DROPFOLD means +** the guard is always true and has been eliminated. CONDFOLD is a +** shortcut for FAILFOLD + cond (i.e. drop if true, otherwise fail). +** +** - Any other return value is interpreted as an IRRef or TRef. This +** can be a reference to an existing or a newly created instruction. +** Only the least-significant 16 bits (IRRef1) are used to form a TRef +** which is finally returned to the caller. +** +** The FOLD engine receives instructions both from the trace recorder and +** substituted instructions from LOOP unrolling. This means all types +** of instructions may end up here, even though the recorder bypasses +** FOLD in some cases. Thus all loads, stores and allocations must have +** an any/any rule to avoid being passed on to CSE. +** +** Carefully read the following requirements before adding or modifying +** any fold rules: +** +** Requirement #1: All fold rules must preserve their destination type. +** +** Consistently use INTFOLD() (KINT result) or lj_ir_knum() (KNUM result). +** Never use lj_ir_knumint() which can have either a KINT or KNUM result. +** +** Requirement #2: Fold rules should not create *new* instructions which +** reference operands *across* PHIs. +** +** E.g. a RETRYFOLD with 'fins->op1 = fleft->op1' is invalid if the +** left operand is a PHI. Then fleft->op1 would point across the PHI +** frontier to an invariant instruction. Adding a PHI for this instruction +** would be counterproductive. The solution is to add a barrier which +** prevents folding across PHIs, i.e. 'PHIBARRIER(fleft)' in this case. +** The only exception is for recurrences with high latencies like +** repeated int->num->int conversions. +** +** One could relax this condition a bit if the referenced instruction is +** a PHI, too. But this often leads to worse code due to excessive +** register shuffling. +** +** Note: returning *existing* instructions (e.g. LEFTFOLD) is ok, though. +** Even returning fleft->op1 would be ok, because a new PHI will added, +** if needed. But again, this leads to excessive register shuffling and +** should be avoided. +** +** Requirement #3: The set of all fold rules must be monotonic to guarantee +** termination. +** +** The goal is optimization, so one primarily wants to add strength-reducing +** rules. This means eliminating an instruction or replacing an instruction +** with one or more simpler instructions. Don't add fold rules which point +** into the other direction. +** +** Some rules (like commutativity) do not directly reduce the strength of +** an instruction, but enable other fold rules (e.g. by moving constants +** to the right operand). These rules must be made unidirectional to avoid +** cycles. +** +** Rule of thumb: the trace recorder expands the IR and FOLD shrinks it. +*/ + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) +#define fins (&J->fold.ins) +#define fleft (&J->fold.left) +#define fright (&J->fold.right) +#define knumleft (ir_knum(fleft)->n) +#define knumright (ir_knum(fright)->n) + +/* Pass IR on to next optimization in chain (FOLD). */ +#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) + +/* Fold function type. Fastcall on x86 significantly reduces their size. */ +typedef IRRef (LJ_FASTCALL *FoldFunc)(jit_State *J); + +/* Macros for the fold specs, so buildvm can recognize them. */ +#define LJFOLD(x) +#define LJFOLDX(x) +#define LJFOLDF(name) static TRef LJ_FASTCALL fold_##name(jit_State *J) +/* Note: They must be at the start of a line or buildvm ignores them! */ + +/* Barrier to prevent using operands across PHIs. */ +#define PHIBARRIER(ir) if (irt_isphi((ir)->t)) return NEXTFOLD + +/* Barrier to prevent folding across a GC step. +** GC steps can only happen at the head of a trace and at LOOP. +** And the GC is only driven forward if there is at least one allocation. +*/ +#define gcstep_barrier(J, ref) \ + ((ref) < J->chain[IR_LOOP] && \ + (J->chain[IR_SNEW] || J->chain[IR_XSNEW] || \ + J->chain[IR_TNEW] || J->chain[IR_TDUP] || \ + J->chain[IR_CNEW] || J->chain[IR_CNEWI] || J->chain[IR_TOSTR])) + +/* -- Constant folding for FP numbers ------------------------------------- */ + +LJFOLD(ADD KNUM KNUM) +LJFOLD(SUB KNUM KNUM) +LJFOLD(MUL KNUM KNUM) +LJFOLD(DIV KNUM KNUM) +LJFOLD(NEG KNUM KNUM) +LJFOLD(ABS KNUM KNUM) +LJFOLD(ATAN2 KNUM KNUM) +LJFOLD(LDEXP KNUM KNUM) +LJFOLD(MIN KNUM KNUM) +LJFOLD(MAX KNUM KNUM) +LJFOLDF(kfold_numarith) +{ + lua_Number a = knumleft; + lua_Number b = knumright; + lua_Number y = lj_vm_foldarith(a, b, fins->o - IR_ADD); + return lj_ir_knum(J, y); +} + +LJFOLD(LDEXP KNUM KINT) +LJFOLDF(kfold_ldexp) +{ +#if LJ_TARGET_X86ORX64 + UNUSED(J); + return NEXTFOLD; +#else + return lj_ir_knum(J, ldexp(knumleft, fright->i)); +#endif +} + +LJFOLD(FPMATH KNUM any) +LJFOLDF(kfold_fpmath) +{ + lua_Number a = knumleft; + lua_Number y = lj_vm_foldfpm(a, fins->op2); + return lj_ir_knum(J, y); +} + +LJFOLD(POW KNUM KINT) +LJFOLDF(kfold_numpow) +{ + lua_Number a = knumleft; + lua_Number b = (lua_Number)fright->i; + lua_Number y = lj_vm_foldarith(a, b, IR_POW - IR_ADD); + return lj_ir_knum(J, y); +} + +/* Must not use kfold_kref for numbers (could be NaN). */ +LJFOLD(EQ KNUM KNUM) +LJFOLD(NE KNUM KNUM) +LJFOLD(LT KNUM KNUM) +LJFOLD(GE KNUM KNUM) +LJFOLD(LE KNUM KNUM) +LJFOLD(GT KNUM KNUM) +LJFOLD(ULT KNUM KNUM) +LJFOLD(UGE KNUM KNUM) +LJFOLD(ULE KNUM KNUM) +LJFOLD(UGT KNUM KNUM) +LJFOLDF(kfold_numcomp) +{ + return CONDFOLD(lj_ir_numcmp(knumleft, knumright, (IROp)fins->o)); +} + +/* -- Constant folding for 32 bit integers -------------------------------- */ + +static int32_t kfold_intop(int32_t k1, int32_t k2, IROp op) +{ + switch (op) { + case IR_ADD: k1 += k2; break; + case IR_SUB: k1 -= k2; break; + case IR_MUL: k1 *= k2; break; + case IR_MOD: k1 = lj_vm_modi(k1, k2); break; + case IR_NEG: k1 = -k1; break; + case IR_BAND: k1 &= k2; break; + case IR_BOR: k1 |= k2; break; + case IR_BXOR: k1 ^= k2; break; + case IR_BSHL: k1 <<= (k2 & 31); break; + case IR_BSHR: k1 = (int32_t)((uint32_t)k1 >> (k2 & 31)); break; + case IR_BSAR: k1 >>= (k2 & 31); break; + case IR_BROL: k1 = (int32_t)lj_rol((uint32_t)k1, (k2 & 31)); break; + case IR_BROR: k1 = (int32_t)lj_ror((uint32_t)k1, (k2 & 31)); break; + case IR_MIN: k1 = k1 < k2 ? k1 : k2; break; + case IR_MAX: k1 = k1 > k2 ? k1 : k2; break; + default: lua_assert(0); break; + } + return k1; +} + +LJFOLD(ADD KINT KINT) +LJFOLD(SUB KINT KINT) +LJFOLD(MUL KINT KINT) +LJFOLD(MOD KINT KINT) +LJFOLD(NEG KINT KINT) +LJFOLD(BAND KINT KINT) +LJFOLD(BOR KINT KINT) +LJFOLD(BXOR KINT KINT) +LJFOLD(BSHL KINT KINT) +LJFOLD(BSHR KINT KINT) +LJFOLD(BSAR KINT KINT) +LJFOLD(BROL KINT KINT) +LJFOLD(BROR KINT KINT) +LJFOLD(MIN KINT KINT) +LJFOLD(MAX KINT KINT) +LJFOLDF(kfold_intarith) +{ + return INTFOLD(kfold_intop(fleft->i, fright->i, (IROp)fins->o)); +} + +LJFOLD(ADDOV KINT KINT) +LJFOLD(SUBOV KINT KINT) +LJFOLD(MULOV KINT KINT) +LJFOLDF(kfold_intovarith) +{ + lua_Number n = lj_vm_foldarith((lua_Number)fleft->i, (lua_Number)fright->i, + fins->o - IR_ADDOV); + int32_t k = lj_num2int(n); + if (n != (lua_Number)k) + return FAILFOLD; + return INTFOLD(k); +} + +LJFOLD(BNOT KINT) +LJFOLDF(kfold_bnot) +{ + return INTFOLD(~fleft->i); +} + +LJFOLD(BSWAP KINT) +LJFOLDF(kfold_bswap) +{ + return INTFOLD((int32_t)lj_bswap((uint32_t)fleft->i)); +} + +LJFOLD(LT KINT KINT) +LJFOLD(GE KINT KINT) +LJFOLD(LE KINT KINT) +LJFOLD(GT KINT KINT) +LJFOLD(ULT KINT KINT) +LJFOLD(UGE KINT KINT) +LJFOLD(ULE KINT KINT) +LJFOLD(UGT KINT KINT) +LJFOLD(ABC KINT KINT) +LJFOLDF(kfold_intcomp) +{ + int32_t a = fleft->i, b = fright->i; + switch ((IROp)fins->o) { + case IR_LT: return CONDFOLD(a < b); + case IR_GE: return CONDFOLD(a >= b); + case IR_LE: return CONDFOLD(a <= b); + case IR_GT: return CONDFOLD(a > b); + case IR_ULT: return CONDFOLD((uint32_t)a < (uint32_t)b); + case IR_UGE: return CONDFOLD((uint32_t)a >= (uint32_t)b); + case IR_ULE: return CONDFOLD((uint32_t)a <= (uint32_t)b); + case IR_ABC: + case IR_UGT: return CONDFOLD((uint32_t)a > (uint32_t)b); + default: lua_assert(0); return FAILFOLD; + } +} + +LJFOLD(UGE any KINT) +LJFOLDF(kfold_intcomp0) +{ + if (fright->i == 0) + return DROPFOLD; + return NEXTFOLD; +} + +/* -- Constant folding for 64 bit integers -------------------------------- */ + +static uint64_t kfold_int64arith(uint64_t k1, uint64_t k2, IROp op) +{ + switch (op) { +#if LJ_64 || LJ_HASFFI + case IR_ADD: k1 += k2; break; + case IR_SUB: k1 -= k2; break; +#endif +#if LJ_HASFFI + case IR_MUL: k1 *= k2; break; + case IR_BAND: k1 &= k2; break; + case IR_BOR: k1 |= k2; break; + case IR_BXOR: k1 ^= k2; break; +#endif + default: UNUSED(k2); lua_assert(0); break; + } + return k1; +} + +LJFOLD(ADD KINT64 KINT64) +LJFOLD(SUB KINT64 KINT64) +LJFOLD(MUL KINT64 KINT64) +LJFOLD(BAND KINT64 KINT64) +LJFOLD(BOR KINT64 KINT64) +LJFOLD(BXOR KINT64 KINT64) +LJFOLDF(kfold_int64arith) +{ + return INT64FOLD(kfold_int64arith(ir_k64(fleft)->u64, + ir_k64(fright)->u64, (IROp)fins->o)); +} + +LJFOLD(DIV KINT64 KINT64) +LJFOLD(MOD KINT64 KINT64) +LJFOLD(POW KINT64 KINT64) +LJFOLDF(kfold_int64arith2) +{ +#if LJ_HASFFI + uint64_t k1 = ir_k64(fleft)->u64, k2 = ir_k64(fright)->u64; + if (irt_isi64(fins->t)) { + k1 = fins->o == IR_DIV ? lj_carith_divi64((int64_t)k1, (int64_t)k2) : + fins->o == IR_MOD ? lj_carith_modi64((int64_t)k1, (int64_t)k2) : + lj_carith_powi64((int64_t)k1, (int64_t)k2); + } else { + k1 = fins->o == IR_DIV ? lj_carith_divu64(k1, k2) : + fins->o == IR_MOD ? lj_carith_modu64(k1, k2) : + lj_carith_powu64(k1, k2); + } + return INT64FOLD(k1); +#else + UNUSED(J); lua_assert(0); return FAILFOLD; +#endif +} + +LJFOLD(BSHL KINT64 KINT) +LJFOLD(BSHR KINT64 KINT) +LJFOLD(BSAR KINT64 KINT) +LJFOLD(BROL KINT64 KINT) +LJFOLD(BROR KINT64 KINT) +LJFOLDF(kfold_int64shift) +{ +#if LJ_HASFFI || LJ_64 + uint64_t k = ir_k64(fleft)->u64; + int32_t sh = (fright->i & 63); + switch ((IROp)fins->o) { + case IR_BSHL: k <<= sh; break; +#if LJ_HASFFI + case IR_BSHR: k >>= sh; break; + case IR_BSAR: k = (uint64_t)((int64_t)k >> sh); break; + case IR_BROL: k = lj_rol(k, sh); break; + case IR_BROR: k = lj_ror(k, sh); break; +#endif + default: lua_assert(0); break; + } + return INT64FOLD(k); +#else + UNUSED(J); lua_assert(0); return FAILFOLD; +#endif +} + +LJFOLD(BNOT KINT64) +LJFOLDF(kfold_bnot64) +{ +#if LJ_HASFFI + return INT64FOLD(~ir_k64(fleft)->u64); +#else + UNUSED(J); lua_assert(0); return FAILFOLD; +#endif +} + +LJFOLD(BSWAP KINT64) +LJFOLDF(kfold_bswap64) +{ +#if LJ_HASFFI + return INT64FOLD(lj_bswap64(ir_k64(fleft)->u64)); +#else + UNUSED(J); lua_assert(0); return FAILFOLD; +#endif +} + +LJFOLD(LT KINT64 KINT64) +LJFOLD(GE KINT64 KINT64) +LJFOLD(LE KINT64 KINT64) +LJFOLD(GT KINT64 KINT64) +LJFOLD(ULT KINT64 KINT64) +LJFOLD(UGE KINT64 KINT64) +LJFOLD(ULE KINT64 KINT64) +LJFOLD(UGT KINT64 KINT64) +LJFOLDF(kfold_int64comp) +{ +#if LJ_HASFFI + uint64_t a = ir_k64(fleft)->u64, b = ir_k64(fright)->u64; + switch ((IROp)fins->o) { + case IR_LT: return CONDFOLD(a < b); + case IR_GE: return CONDFOLD(a >= b); + case IR_LE: return CONDFOLD(a <= b); + case IR_GT: return CONDFOLD(a > b); + case IR_ULT: return CONDFOLD((uint64_t)a < (uint64_t)b); + case IR_UGE: return CONDFOLD((uint64_t)a >= (uint64_t)b); + case IR_ULE: return CONDFOLD((uint64_t)a <= (uint64_t)b); + case IR_UGT: return CONDFOLD((uint64_t)a > (uint64_t)b); + default: lua_assert(0); return FAILFOLD; + } +#else + UNUSED(J); lua_assert(0); return FAILFOLD; +#endif +} + +LJFOLD(UGE any KINT64) +LJFOLDF(kfold_int64comp0) +{ +#if LJ_HASFFI + if (ir_k64(fright)->u64 == 0) + return DROPFOLD; + return NEXTFOLD; +#else + UNUSED(J); lua_assert(0); return FAILFOLD; +#endif +} + +/* -- Constant folding for strings ---------------------------------------- */ + +LJFOLD(SNEW KKPTR KINT) +LJFOLDF(kfold_snew_kptr) +{ + GCstr *s = lj_str_new(J->L, (const char *)ir_kptr(fleft), (size_t)fright->i); + return lj_ir_kstr(J, s); +} + +LJFOLD(SNEW any KINT) +LJFOLDF(kfold_snew_empty) +{ + if (fright->i == 0) + return lj_ir_kstr(J, &J2G(J)->strempty); + return NEXTFOLD; +} + +LJFOLD(STRREF KGC KINT) +LJFOLDF(kfold_strref) +{ + GCstr *str = ir_kstr(fleft); + lua_assert((MSize)fright->i <= str->len); + return lj_ir_kkptr(J, (char *)strdata(str) + fright->i); +} + +LJFOLD(STRREF SNEW any) +LJFOLDF(kfold_strref_snew) +{ + PHIBARRIER(fleft); + if (irref_isk(fins->op2) && fright->i == 0) { + return fleft->op1; /* strref(snew(ptr, len), 0) ==> ptr */ + } else { + /* Reassociate: strref(snew(strref(str, a), len), b) ==> strref(str, a+b) */ + IRIns *ir = IR(fleft->op1); + if (ir->o == IR_STRREF) { + IRRef1 str = ir->op1; /* IRIns * is not valid across emitir. */ + PHIBARRIER(ir); + fins->op2 = emitir(IRTI(IR_ADD), ir->op2, fins->op2); /* Clobbers fins! */ + fins->op1 = str; + fins->ot = IRT(IR_STRREF, IRT_P32); + return RETRYFOLD; + } + } + return NEXTFOLD; +} + +LJFOLD(CALLN CARG IRCALL_lj_str_cmp) +LJFOLDF(kfold_strcmp) +{ + if (irref_isk(fleft->op1) && irref_isk(fleft->op2)) { + GCstr *a = ir_kstr(IR(fleft->op1)); + GCstr *b = ir_kstr(IR(fleft->op2)); + return INTFOLD(lj_str_cmp(a, b)); + } + return NEXTFOLD; +} + +/* -- Constant folding of pointer arithmetic ------------------------------ */ + +LJFOLD(ADD KGC KINT) +LJFOLD(ADD KGC KINT64) +LJFOLDF(kfold_add_kgc) +{ + GCobj *o = ir_kgc(fleft); +#if LJ_64 + ptrdiff_t ofs = (ptrdiff_t)ir_kint64(fright)->u64; +#else + ptrdiff_t ofs = fright->i; +#endif +#if LJ_HASFFI + if (irt_iscdata(fleft->t)) { + CType *ct = ctype_raw(ctype_ctsG(J2G(J)), gco2cd(o)->ctypeid); + if (ctype_isnum(ct->info) || ctype_isenum(ct->info) || + ctype_isptr(ct->info) || ctype_isfunc(ct->info) || + ctype_iscomplex(ct->info) || ctype_isvector(ct->info)) + return lj_ir_kkptr(J, (char *)o + ofs); + } +#endif + return lj_ir_kptr(J, (char *)o + ofs); +} + +LJFOLD(ADD KPTR KINT) +LJFOLD(ADD KPTR KINT64) +LJFOLD(ADD KKPTR KINT) +LJFOLD(ADD KKPTR KINT64) +LJFOLDF(kfold_add_kptr) +{ + void *p = ir_kptr(fleft); +#if LJ_64 + ptrdiff_t ofs = (ptrdiff_t)ir_kint64(fright)->u64; +#else + ptrdiff_t ofs = fright->i; +#endif + return lj_ir_kptr_(J, fleft->o, (char *)p + ofs); +} + +LJFOLD(ADD any KGC) +LJFOLD(ADD any KPTR) +LJFOLD(ADD any KKPTR) +LJFOLDF(kfold_add_kright) +{ + if (fleft->o == IR_KINT || fleft->o == IR_KINT64) { + IRRef1 tmp = fins->op1; fins->op1 = fins->op2; fins->op2 = tmp; + return RETRYFOLD; + } + return NEXTFOLD; +} + +/* -- Constant folding of conversions ------------------------------------- */ + +LJFOLD(TOBIT KNUM KNUM) +LJFOLDF(kfold_tobit) +{ + return INTFOLD(lj_num2bit(knumleft)); +} + +LJFOLD(CONV KINT IRCONV_NUM_INT) +LJFOLDF(kfold_conv_kint_num) +{ + return lj_ir_knum(J, (lua_Number)fleft->i); +} + +LJFOLD(CONV KINT IRCONV_NUM_U32) +LJFOLDF(kfold_conv_kintu32_num) +{ + return lj_ir_knum(J, (lua_Number)(uint32_t)fleft->i); +} + +LJFOLD(CONV KINT IRCONV_INT_I8) +LJFOLD(CONV KINT IRCONV_INT_U8) +LJFOLD(CONV KINT IRCONV_INT_I16) +LJFOLD(CONV KINT IRCONV_INT_U16) +LJFOLDF(kfold_conv_kint_ext) +{ + int32_t k = fleft->i; + if ((fins->op2 & IRCONV_SRCMASK) == IRT_I8) k = (int8_t)k; + else if ((fins->op2 & IRCONV_SRCMASK) == IRT_U8) k = (uint8_t)k; + else if ((fins->op2 & IRCONV_SRCMASK) == IRT_I16) k = (int16_t)k; + else k = (uint16_t)k; + return INTFOLD(k); +} + +LJFOLD(CONV KINT IRCONV_I64_INT) +LJFOLD(CONV KINT IRCONV_U64_INT) +LJFOLD(CONV KINT IRCONV_I64_U32) +LJFOLD(CONV KINT IRCONV_U64_U32) +LJFOLDF(kfold_conv_kint_i64) +{ + if ((fins->op2 & IRCONV_SEXT)) + return INT64FOLD((uint64_t)(int64_t)fleft->i); + else + return INT64FOLD((uint64_t)(int64_t)(uint32_t)fleft->i); +} + +LJFOLD(CONV KINT64 IRCONV_NUM_I64) +LJFOLDF(kfold_conv_kint64_num_i64) +{ + return lj_ir_knum(J, (lua_Number)(int64_t)ir_kint64(fleft)->u64); +} + +LJFOLD(CONV KINT64 IRCONV_NUM_U64) +LJFOLDF(kfold_conv_kint64_num_u64) +{ + return lj_ir_knum(J, (lua_Number)ir_kint64(fleft)->u64); +} + +LJFOLD(CONV KINT64 IRCONV_INT_I64) +LJFOLD(CONV KINT64 IRCONV_U32_I64) +LJFOLDF(kfold_conv_kint64_int_i64) +{ + return INTFOLD((int32_t)ir_kint64(fleft)->u64); +} + +LJFOLD(CONV KNUM IRCONV_INT_NUM) +LJFOLDF(kfold_conv_knum_int_num) +{ + lua_Number n = knumleft; + if (!(fins->op2 & IRCONV_TRUNC)) { + int32_t k = lj_num2int(n); + if (irt_isguard(fins->t) && n != (lua_Number)k) { + /* We're about to create a guard which always fails, like CONV +1.5. + ** Some pathological loops cause this during LICM, e.g.: + ** local x,k,t = 0,1.5,{1,[1.5]=2} + ** for i=1,200 do x = x+ t[k]; k = k == 1 and 1.5 or 1 end + ** assert(x == 300) + */ + return FAILFOLD; + } + return INTFOLD(k); + } else { + return INTFOLD((int32_t)n); + } +} + +LJFOLD(CONV KNUM IRCONV_U32_NUM) +LJFOLDF(kfold_conv_knum_u32_num) +{ + lua_assert((fins->op2 & IRCONV_TRUNC)); +#ifdef _MSC_VER + { /* Workaround for MSVC bug. */ + volatile uint32_t u = (uint32_t)knumleft; + return INTFOLD((int32_t)u); + } +#else + return INTFOLD((int32_t)(uint32_t)knumleft); +#endif +} + +LJFOLD(CONV KNUM IRCONV_I64_NUM) +LJFOLDF(kfold_conv_knum_i64_num) +{ + lua_assert((fins->op2 & IRCONV_TRUNC)); + return INT64FOLD((uint64_t)(int64_t)knumleft); +} + +LJFOLD(CONV KNUM IRCONV_U64_NUM) +LJFOLDF(kfold_conv_knum_u64_num) +{ + lua_assert((fins->op2 & IRCONV_TRUNC)); + return INT64FOLD(lj_num2u64(knumleft)); +} + +LJFOLD(TOSTR KNUM) +LJFOLDF(kfold_tostr_knum) +{ + return lj_ir_kstr(J, lj_str_fromnum(J->L, &knumleft)); +} + +LJFOLD(TOSTR KINT) +LJFOLDF(kfold_tostr_kint) +{ + return lj_ir_kstr(J, lj_str_fromint(J->L, fleft->i)); +} + +LJFOLD(STRTO KGC) +LJFOLDF(kfold_strto) +{ + TValue n; + if (lj_strscan_num(ir_kstr(fleft), &n)) + return lj_ir_knum(J, numV(&n)); + return FAILFOLD; +} + +/* -- Constant folding of equality checks --------------------------------- */ + +/* Don't constant-fold away FLOAD checks against KNULL. */ +LJFOLD(EQ FLOAD KNULL) +LJFOLD(NE FLOAD KNULL) +LJFOLDX(lj_opt_cse) + +/* But fold all other KNULL compares, since only KNULL is equal to KNULL. */ +LJFOLD(EQ any KNULL) +LJFOLD(NE any KNULL) +LJFOLD(EQ KNULL any) +LJFOLD(NE KNULL any) +LJFOLD(EQ KINT KINT) /* Constants are unique, so same refs <==> same value. */ +LJFOLD(NE KINT KINT) +LJFOLD(EQ KINT64 KINT64) +LJFOLD(NE KINT64 KINT64) +LJFOLD(EQ KGC KGC) +LJFOLD(NE KGC KGC) +LJFOLDF(kfold_kref) +{ + return CONDFOLD((fins->op1 == fins->op2) ^ (fins->o == IR_NE)); +} + +/* -- Algebraic shortcuts ------------------------------------------------- */ + +LJFOLD(FPMATH FPMATH IRFPM_FLOOR) +LJFOLD(FPMATH FPMATH IRFPM_CEIL) +LJFOLD(FPMATH FPMATH IRFPM_TRUNC) +LJFOLDF(shortcut_round) +{ + IRFPMathOp op = (IRFPMathOp)fleft->op2; + if (op == IRFPM_FLOOR || op == IRFPM_CEIL || op == IRFPM_TRUNC) + return LEFTFOLD; /* round(round_left(x)) = round_left(x) */ + return NEXTFOLD; +} + +LJFOLD(ABS ABS KNUM) +LJFOLDF(shortcut_left) +{ + return LEFTFOLD; /* f(g(x)) ==> g(x) */ +} + +LJFOLD(ABS NEG KNUM) +LJFOLDF(shortcut_dropleft) +{ + PHIBARRIER(fleft); + fins->op1 = fleft->op1; /* abs(neg(x)) ==> abs(x) */ + return RETRYFOLD; +} + +/* Note: no safe shortcuts with STRTO and TOSTR ("1e2" ==> +100 ==> "100"). */ +LJFOLD(NEG NEG any) +LJFOLD(BNOT BNOT) +LJFOLD(BSWAP BSWAP) +LJFOLDF(shortcut_leftleft) +{ + PHIBARRIER(fleft); /* See above. Fold would be ok, but not beneficial. */ + return fleft->op1; /* f(g(x)) ==> x */ +} + +/* -- FP algebraic simplifications ---------------------------------------- */ + +/* FP arithmetic is tricky -- there's not much to simplify. +** Please note the following common pitfalls before sending "improvements": +** x+0 ==> x is INVALID for x=-0 +** 0-x ==> -x is INVALID for x=+0 +** x*0 ==> 0 is INVALID for x=-0, x=+-Inf or x=NaN +*/ + +LJFOLD(ADD NEG any) +LJFOLDF(simplify_numadd_negx) +{ + PHIBARRIER(fleft); + fins->o = IR_SUB; /* (-a) + b ==> b - a */ + fins->op1 = fins->op2; + fins->op2 = fleft->op1; + return RETRYFOLD; +} + +LJFOLD(ADD any NEG) +LJFOLDF(simplify_numadd_xneg) +{ + PHIBARRIER(fright); + fins->o = IR_SUB; /* a + (-b) ==> a - b */ + fins->op2 = fright->op1; + return RETRYFOLD; +} + +LJFOLD(SUB any KNUM) +LJFOLDF(simplify_numsub_k) +{ + lua_Number n = knumright; + if (n == 0.0) /* x - (+-0) ==> x */ + return LEFTFOLD; + return NEXTFOLD; +} + +LJFOLD(SUB NEG KNUM) +LJFOLDF(simplify_numsub_negk) +{ + PHIBARRIER(fleft); + fins->op2 = fleft->op1; /* (-x) - k ==> (-k) - x */ + fins->op1 = (IRRef1)lj_ir_knum(J, -knumright); + return RETRYFOLD; +} + +LJFOLD(SUB any NEG) +LJFOLDF(simplify_numsub_xneg) +{ + PHIBARRIER(fright); + fins->o = IR_ADD; /* a - (-b) ==> a + b */ + fins->op2 = fright->op1; + return RETRYFOLD; +} + +LJFOLD(MUL any KNUM) +LJFOLD(DIV any KNUM) +LJFOLDF(simplify_nummuldiv_k) +{ + lua_Number n = knumright; + if (n == 1.0) { /* x o 1 ==> x */ + return LEFTFOLD; + } else if (n == -1.0) { /* x o -1 ==> -x */ + fins->o = IR_NEG; + fins->op2 = (IRRef1)lj_ir_knum_neg(J); + return RETRYFOLD; + } else if (fins->o == IR_MUL && n == 2.0) { /* x * 2 ==> x + x */ + fins->o = IR_ADD; + fins->op2 = fins->op1; + return RETRYFOLD; + } else if (fins->o == IR_DIV) { /* x / 2^k ==> x * 2^-k */ + uint64_t u = ir_knum(fright)->u64; + uint32_t ex = ((uint32_t)(u >> 52) & 0x7ff); + if ((u & U64x(000fffff,ffffffff)) == 0 && ex - 1 < 0x7fd) { + u = (u & ((uint64_t)1 << 63)) | ((uint64_t)(0x7fe - ex) << 52); + fins->o = IR_MUL; /* Multiply by exact reciprocal. */ + fins->op2 = lj_ir_knum_u64(J, u); + return RETRYFOLD; + } + } + return NEXTFOLD; +} + +LJFOLD(MUL NEG KNUM) +LJFOLD(DIV NEG KNUM) +LJFOLDF(simplify_nummuldiv_negk) +{ + PHIBARRIER(fleft); + fins->op1 = fleft->op1; /* (-a) o k ==> a o (-k) */ + fins->op2 = (IRRef1)lj_ir_knum(J, -knumright); + return RETRYFOLD; +} + +LJFOLD(MUL NEG NEG) +LJFOLD(DIV NEG NEG) +LJFOLDF(simplify_nummuldiv_negneg) +{ + PHIBARRIER(fleft); + PHIBARRIER(fright); + fins->op1 = fleft->op1; /* (-a) o (-b) ==> a o b */ + fins->op2 = fright->op1; + return RETRYFOLD; +} + +LJFOLD(POW any KINT) +LJFOLDF(simplify_numpow_xk) +{ + int32_t k = fright->i; + TRef ref = fins->op1; + if (k == 0) /* x ^ 0 ==> 1 */ + return lj_ir_knum_one(J); /* Result must be a number, not an int. */ + if (k == 1) /* x ^ 1 ==> x */ + return LEFTFOLD; + if ((uint32_t)(k+65536) > 2*65536u) /* Limit code explosion. */ + return NEXTFOLD; + if (k < 0) { /* x ^ (-k) ==> (1/x) ^ k. */ + ref = emitir(IRTN(IR_DIV), lj_ir_knum_one(J), ref); + k = -k; + } + /* Unroll x^k for 1 <= k <= 65536. */ + for (; (k & 1) == 0; k >>= 1) /* Handle leading zeros. */ + ref = emitir(IRTN(IR_MUL), ref, ref); + if ((k >>= 1) != 0) { /* Handle trailing bits. */ + TRef tmp = emitir(IRTN(IR_MUL), ref, ref); + for (; k != 1; k >>= 1) { + if (k & 1) + ref = emitir(IRTN(IR_MUL), ref, tmp); + tmp = emitir(IRTN(IR_MUL), tmp, tmp); + } + ref = emitir(IRTN(IR_MUL), ref, tmp); + } + return ref; +} + +LJFOLD(POW KNUM any) +LJFOLDF(simplify_numpow_kx) +{ + lua_Number n = knumleft; + if (n == 2.0) { /* 2.0 ^ i ==> ldexp(1.0, tonum(i)) */ + fins->o = IR_CONV; +#if LJ_TARGET_X86ORX64 + fins->op1 = fins->op2; + fins->op2 = IRCONV_NUM_INT; + fins->op2 = (IRRef1)lj_opt_fold(J); +#endif + fins->op1 = (IRRef1)lj_ir_knum_one(J); + fins->o = IR_LDEXP; + return RETRYFOLD; + } + return NEXTFOLD; +} + +/* -- Simplify conversions ------------------------------------------------ */ + +LJFOLD(CONV CONV IRCONV_NUM_INT) /* _NUM */ +LJFOLDF(shortcut_conv_num_int) +{ + PHIBARRIER(fleft); + /* Only safe with a guarded conversion to int. */ + if ((fleft->op2 & IRCONV_SRCMASK) == IRT_NUM && irt_isguard(fleft->t)) + return fleft->op1; /* f(g(x)) ==> x */ + return NEXTFOLD; +} + +LJFOLD(CONV CONV IRCONV_INT_NUM) /* _INT */ +LJFOLD(CONV CONV IRCONV_U32_NUM) /* _U32*/ +LJFOLDF(simplify_conv_int_num) +{ + /* Fold even across PHI to avoid expensive num->int conversions in loop. */ + if ((fleft->op2 & IRCONV_SRCMASK) == + ((fins->op2 & IRCONV_DSTMASK) >> IRCONV_DSH)) + return fleft->op1; + return NEXTFOLD; +} + +LJFOLD(CONV CONV IRCONV_I64_NUM) /* _INT or _U32 */ +LJFOLD(CONV CONV IRCONV_U64_NUM) /* _INT or _U32 */ +LJFOLDF(simplify_conv_i64_num) +{ + PHIBARRIER(fleft); + if ((fleft->op2 & IRCONV_SRCMASK) == IRT_INT) { + /* Reduce to a sign-extension. */ + fins->op1 = fleft->op1; + fins->op2 = ((IRT_I64<<5)|IRT_INT|IRCONV_SEXT); + return RETRYFOLD; + } else if ((fleft->op2 & IRCONV_SRCMASK) == IRT_U32) { +#if LJ_TARGET_X64 + return fleft->op1; +#else + /* Reduce to a zero-extension. */ + fins->op1 = fleft->op1; + fins->op2 = (IRT_I64<<5)|IRT_U32; + return RETRYFOLD; +#endif + } + return NEXTFOLD; +} + +LJFOLD(CONV CONV IRCONV_INT_I64) /* _INT or _U32 */ +LJFOLD(CONV CONV IRCONV_INT_U64) /* _INT or _U32 */ +LJFOLD(CONV CONV IRCONV_U32_I64) /* _INT or _U32 */ +LJFOLD(CONV CONV IRCONV_U32_U64) /* _INT or _U32 */ +LJFOLDF(simplify_conv_int_i64) +{ + int src; + PHIBARRIER(fleft); + src = (fleft->op2 & IRCONV_SRCMASK); + if (src == IRT_INT || src == IRT_U32) { + if (src == ((fins->op2 & IRCONV_DSTMASK) >> IRCONV_DSH)) { + return fleft->op1; + } else { + fins->op2 = ((fins->op2 & IRCONV_DSTMASK) | src); + fins->op1 = fleft->op1; + return RETRYFOLD; + } + } + return NEXTFOLD; +} + +LJFOLD(CONV CONV IRCONV_FLOAT_NUM) /* _FLOAT */ +LJFOLDF(simplify_conv_flt_num) +{ + PHIBARRIER(fleft); + if ((fleft->op2 & IRCONV_SRCMASK) == IRT_FLOAT) + return fleft->op1; + return NEXTFOLD; +} + +/* Shortcut TOBIT + IRT_NUM <- IRT_INT/IRT_U32 conversion. */ +LJFOLD(TOBIT CONV KNUM) +LJFOLDF(simplify_tobit_conv) +{ + /* Fold even across PHI to avoid expensive num->int conversions in loop. */ + if ((fleft->op2 & IRCONV_SRCMASK) == IRT_INT) { + lua_assert(irt_isnum(fleft->t)); + return fleft->op1; + } else if ((fleft->op2 & IRCONV_SRCMASK) == IRT_U32) { + lua_assert(irt_isnum(fleft->t)); + fins->o = IR_CONV; + fins->op1 = fleft->op1; + fins->op2 = (IRT_INT<<5)|IRT_U32; + return RETRYFOLD; + } + return NEXTFOLD; +} + +/* Shortcut floor/ceil/round + IRT_NUM <- IRT_INT/IRT_U32 conversion. */ +LJFOLD(FPMATH CONV IRFPM_FLOOR) +LJFOLD(FPMATH CONV IRFPM_CEIL) +LJFOLD(FPMATH CONV IRFPM_TRUNC) +LJFOLDF(simplify_floor_conv) +{ + if ((fleft->op2 & IRCONV_SRCMASK) == IRT_INT || + (fleft->op2 & IRCONV_SRCMASK) == IRT_U32) + return LEFTFOLD; + return NEXTFOLD; +} + +/* Strength reduction of widening. */ +LJFOLD(CONV any IRCONV_I64_INT) +LJFOLD(CONV any IRCONV_U64_INT) +LJFOLDF(simplify_conv_sext) +{ + IRRef ref = fins->op1; + int64_t ofs = 0; + if (!(fins->op2 & IRCONV_SEXT)) + return NEXTFOLD; + PHIBARRIER(fleft); + if (fleft->o == IR_XLOAD && (irt_isu8(fleft->t) || irt_isu16(fleft->t))) + goto ok_reduce; + if (fleft->o == IR_ADD && irref_isk(fleft->op2)) { + ofs = (int64_t)IR(fleft->op2)->i; + ref = fleft->op1; + } + /* Use scalar evolution analysis results to strength-reduce sign-extension. */ + if (ref == J->scev.idx) { + IRRef lo = J->scev.dir ? J->scev.start : J->scev.stop; + lua_assert(irt_isint(J->scev.t)); + if (lo && IR(lo)->i + ofs >= 0) { + ok_reduce: +#if LJ_TARGET_X64 + /* Eliminate widening. All 32 bit ops do an implicit zero-extension. */ + return LEFTFOLD; +#else + /* Reduce to a (cheaper) zero-extension. */ + fins->op2 &= ~IRCONV_SEXT; + return RETRYFOLD; +#endif + } + } + return NEXTFOLD; +} + +/* Strength reduction of narrowing. */ +LJFOLD(CONV ADD IRCONV_INT_I64) +LJFOLD(CONV SUB IRCONV_INT_I64) +LJFOLD(CONV MUL IRCONV_INT_I64) +LJFOLD(CONV ADD IRCONV_INT_U64) +LJFOLD(CONV SUB IRCONV_INT_U64) +LJFOLD(CONV MUL IRCONV_INT_U64) +LJFOLD(CONV ADD IRCONV_U32_I64) +LJFOLD(CONV SUB IRCONV_U32_I64) +LJFOLD(CONV MUL IRCONV_U32_I64) +LJFOLD(CONV ADD IRCONV_U32_U64) +LJFOLD(CONV SUB IRCONV_U32_U64) +LJFOLD(CONV MUL IRCONV_U32_U64) +LJFOLDF(simplify_conv_narrow) +{ + IROp op = (IROp)fleft->o; + IRType t = irt_type(fins->t); + IRRef op1 = fleft->op1, op2 = fleft->op2, mode = fins->op2; + PHIBARRIER(fleft); + op1 = emitir(IRTI(IR_CONV), op1, mode); + op2 = emitir(IRTI(IR_CONV), op2, mode); + fins->ot = IRT(op, t); + fins->op1 = op1; + fins->op2 = op2; + return RETRYFOLD; +} + +/* Special CSE rule for CONV. */ +LJFOLD(CONV any any) +LJFOLDF(cse_conv) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_CSE)) { + IRRef op1 = fins->op1, op2 = (fins->op2 & IRCONV_MODEMASK); + uint8_t guard = irt_isguard(fins->t); + IRRef ref = J->chain[IR_CONV]; + while (ref > op1) { + IRIns *ir = IR(ref); + /* Commoning with stronger checks is ok. */ + if (ir->op1 == op1 && (ir->op2 & IRCONV_MODEMASK) == op2 && + irt_isguard(ir->t) >= guard) + return ref; + ref = ir->prev; + } + } + return EMITFOLD; /* No fallthrough to regular CSE. */ +} + +/* FP conversion narrowing. */ +LJFOLD(TOBIT ADD KNUM) +LJFOLD(TOBIT SUB KNUM) +LJFOLD(CONV ADD IRCONV_INT_NUM) +LJFOLD(CONV SUB IRCONV_INT_NUM) +LJFOLD(CONV ADD IRCONV_I64_NUM) +LJFOLD(CONV SUB IRCONV_I64_NUM) +LJFOLDF(narrow_convert) +{ + PHIBARRIER(fleft); + /* Narrowing ignores PHIs and repeating it inside the loop is not useful. */ + if (J->chain[IR_LOOP]) + return NEXTFOLD; + lua_assert(fins->o != IR_CONV || (fins->op2&IRCONV_CONVMASK) != IRCONV_TOBIT); + return lj_opt_narrow_convert(J); +} + +/* -- Integer algebraic simplifications ----------------------------------- */ + +LJFOLD(ADD any KINT) +LJFOLD(ADDOV any KINT) +LJFOLD(SUBOV any KINT) +LJFOLDF(simplify_intadd_k) +{ + if (fright->i == 0) /* i o 0 ==> i */ + return LEFTFOLD; + return NEXTFOLD; +} + +LJFOLD(MULOV any KINT) +LJFOLDF(simplify_intmul_k) +{ + if (fright->i == 0) /* i * 0 ==> 0 */ + return RIGHTFOLD; + if (fright->i == 1) /* i * 1 ==> i */ + return LEFTFOLD; + if (fright->i == 2) { /* i * 2 ==> i + i */ + fins->o = IR_ADDOV; + fins->op2 = fins->op1; + return RETRYFOLD; + } + return NEXTFOLD; +} + +LJFOLD(SUB any KINT) +LJFOLDF(simplify_intsub_k) +{ + if (fright->i == 0) /* i - 0 ==> i */ + return LEFTFOLD; + fins->o = IR_ADD; /* i - k ==> i + (-k) */ + fins->op2 = (IRRef1)lj_ir_kint(J, -fright->i); /* Overflow for -2^31 ok. */ + return RETRYFOLD; +} + +LJFOLD(SUB KINT any) +LJFOLD(SUB KINT64 any) +LJFOLDF(simplify_intsub_kleft) +{ + if (fleft->o == IR_KINT ? (fleft->i == 0) : (ir_kint64(fleft)->u64 == 0)) { + fins->o = IR_NEG; /* 0 - i ==> -i */ + fins->op1 = fins->op2; + return RETRYFOLD; + } + return NEXTFOLD; +} + +LJFOLD(ADD any KINT64) +LJFOLDF(simplify_intadd_k64) +{ + if (ir_kint64(fright)->u64 == 0) /* i + 0 ==> i */ + return LEFTFOLD; + return NEXTFOLD; +} + +LJFOLD(SUB any KINT64) +LJFOLDF(simplify_intsub_k64) +{ + uint64_t k = ir_kint64(fright)->u64; + if (k == 0) /* i - 0 ==> i */ + return LEFTFOLD; + fins->o = IR_ADD; /* i - k ==> i + (-k) */ + fins->op2 = (IRRef1)lj_ir_kint64(J, (uint64_t)-(int64_t)k); + return RETRYFOLD; +} + +static TRef simplify_intmul_k(jit_State *J, int32_t k) +{ + /* Note: many more simplifications are possible, e.g. 2^k1 +- 2^k2. + ** But this is mainly intended for simple address arithmetic. + ** Also it's easier for the backend to optimize the original multiplies. + */ + if (k == 1) { /* i * 1 ==> i */ + return LEFTFOLD; + } else if ((k & (k-1)) == 0) { /* i * 2^k ==> i << k */ + fins->o = IR_BSHL; + fins->op2 = lj_ir_kint(J, lj_fls((uint32_t)k)); + return RETRYFOLD; + } + return NEXTFOLD; +} + +LJFOLD(MUL any KINT) +LJFOLDF(simplify_intmul_k32) +{ + if (fright->i == 0) /* i * 0 ==> 0 */ + return INTFOLD(0); + else if (fright->i > 0) + return simplify_intmul_k(J, fright->i); + return NEXTFOLD; +} + +LJFOLD(MUL any KINT64) +LJFOLDF(simplify_intmul_k64) +{ + if (ir_kint64(fright)->u64 == 0) /* i * 0 ==> 0 */ + return INT64FOLD(0); +#if LJ_64 + /* NYI: SPLIT for BSHL and 32 bit backend support. */ + else if (ir_kint64(fright)->u64 < 0x80000000u) + return simplify_intmul_k(J, (int32_t)ir_kint64(fright)->u64); +#endif + return NEXTFOLD; +} + +LJFOLD(MOD any KINT) +LJFOLDF(simplify_intmod_k) +{ + int32_t k = fright->i; + lua_assert(k != 0); + if (k > 0 && (k & (k-1)) == 0) { /* i % (2^k) ==> i & (2^k-1) */ + fins->o = IR_BAND; + fins->op2 = lj_ir_kint(J, k-1); + return RETRYFOLD; + } + return NEXTFOLD; +} + +LJFOLD(MOD KINT any) +LJFOLDF(simplify_intmod_kleft) +{ + if (fleft->i == 0) + return INTFOLD(0); + return NEXTFOLD; +} + +LJFOLD(SUB any any) +LJFOLD(SUBOV any any) +LJFOLDF(simplify_intsub) +{ + if (fins->op1 == fins->op2 && !irt_isnum(fins->t)) /* i - i ==> 0 */ + return irt_is64(fins->t) ? INT64FOLD(0) : INTFOLD(0); + return NEXTFOLD; +} + +LJFOLD(SUB ADD any) +LJFOLDF(simplify_intsubadd_leftcancel) +{ + if (!irt_isnum(fins->t)) { + PHIBARRIER(fleft); + if (fins->op2 == fleft->op1) /* (i + j) - i ==> j */ + return fleft->op2; + if (fins->op2 == fleft->op2) /* (i + j) - j ==> i */ + return fleft->op1; + } + return NEXTFOLD; +} + +LJFOLD(SUB SUB any) +LJFOLDF(simplify_intsubsub_leftcancel) +{ + if (!irt_isnum(fins->t)) { + PHIBARRIER(fleft); + if (fins->op2 == fleft->op1) { /* (i - j) - i ==> 0 - j */ + fins->op1 = (IRRef1)lj_ir_kint(J, 0); + fins->op2 = fleft->op2; + return RETRYFOLD; + } + } + return NEXTFOLD; +} + +LJFOLD(SUB any SUB) +LJFOLDF(simplify_intsubsub_rightcancel) +{ + if (!irt_isnum(fins->t)) { + PHIBARRIER(fright); + if (fins->op1 == fright->op1) /* i - (i - j) ==> j */ + return fright->op2; + } + return NEXTFOLD; +} + +LJFOLD(SUB any ADD) +LJFOLDF(simplify_intsubadd_rightcancel) +{ + if (!irt_isnum(fins->t)) { + PHIBARRIER(fright); + if (fins->op1 == fright->op1) { /* i - (i + j) ==> 0 - j */ + fins->op2 = fright->op2; + fins->op1 = (IRRef1)lj_ir_kint(J, 0); + return RETRYFOLD; + } + if (fins->op1 == fright->op2) { /* i - (j + i) ==> 0 - j */ + fins->op2 = fright->op1; + fins->op1 = (IRRef1)lj_ir_kint(J, 0); + return RETRYFOLD; + } + } + return NEXTFOLD; +} + +LJFOLD(SUB ADD ADD) +LJFOLDF(simplify_intsubaddadd_cancel) +{ + if (!irt_isnum(fins->t)) { + PHIBARRIER(fleft); + PHIBARRIER(fright); + if (fleft->op1 == fright->op1) { /* (i + j1) - (i + j2) ==> j1 - j2 */ + fins->op1 = fleft->op2; + fins->op2 = fright->op2; + return RETRYFOLD; + } + if (fleft->op1 == fright->op2) { /* (i + j1) - (j2 + i) ==> j1 - j2 */ + fins->op1 = fleft->op2; + fins->op2 = fright->op1; + return RETRYFOLD; + } + if (fleft->op2 == fright->op1) { /* (j1 + i) - (i + j2) ==> j1 - j2 */ + fins->op1 = fleft->op1; + fins->op2 = fright->op2; + return RETRYFOLD; + } + if (fleft->op2 == fright->op2) { /* (j1 + i) - (j2 + i) ==> j1 - j2 */ + fins->op1 = fleft->op1; + fins->op2 = fright->op1; + return RETRYFOLD; + } + } + return NEXTFOLD; +} + +LJFOLD(BAND any KINT) +LJFOLD(BAND any KINT64) +LJFOLDF(simplify_band_k) +{ + int64_t k = fright->o == IR_KINT ? (int64_t)fright->i : + (int64_t)ir_k64(fright)->u64; + if (k == 0) /* i & 0 ==> 0 */ + return RIGHTFOLD; + if (k == -1) /* i & -1 ==> i */ + return LEFTFOLD; + return NEXTFOLD; +} + +LJFOLD(BOR any KINT) +LJFOLD(BOR any KINT64) +LJFOLDF(simplify_bor_k) +{ + int64_t k = fright->o == IR_KINT ? (int64_t)fright->i : + (int64_t)ir_k64(fright)->u64; + if (k == 0) /* i | 0 ==> i */ + return LEFTFOLD; + if (k == -1) /* i | -1 ==> -1 */ + return RIGHTFOLD; + return NEXTFOLD; +} + +LJFOLD(BXOR any KINT) +LJFOLD(BXOR any KINT64) +LJFOLDF(simplify_bxor_k) +{ + int64_t k = fright->o == IR_KINT ? (int64_t)fright->i : + (int64_t)ir_k64(fright)->u64; + if (k == 0) /* i xor 0 ==> i */ + return LEFTFOLD; + if (k == -1) { /* i xor -1 ==> ~i */ + fins->o = IR_BNOT; + fins->op2 = 0; + return RETRYFOLD; + } + return NEXTFOLD; +} + +LJFOLD(BSHL any KINT) +LJFOLD(BSHR any KINT) +LJFOLD(BSAR any KINT) +LJFOLD(BROL any KINT) +LJFOLD(BROR any KINT) +LJFOLDF(simplify_shift_ik) +{ + int32_t mask = irt_is64(fins->t) ? 63 : 31; + int32_t k = (fright->i & mask); + if (k == 0) /* i o 0 ==> i */ + return LEFTFOLD; + if (k == 1 && fins->o == IR_BSHL) { /* i << 1 ==> i + i */ + fins->o = IR_ADD; + fins->op2 = fins->op1; + return RETRYFOLD; + } + if (k != fright->i) { /* i o k ==> i o (k & mask) */ + fins->op2 = (IRRef1)lj_ir_kint(J, k); + return RETRYFOLD; + } +#ifndef LJ_TARGET_UNIFYROT + if (fins->o == IR_BROR) { /* bror(i, k) ==> brol(i, (-k)&mask) */ + fins->o = IR_BROL; + fins->op2 = (IRRef1)lj_ir_kint(J, (-k)&mask); + return RETRYFOLD; + } +#endif + return NEXTFOLD; +} + +LJFOLD(BSHL any BAND) +LJFOLD(BSHR any BAND) +LJFOLD(BSAR any BAND) +LJFOLD(BROL any BAND) +LJFOLD(BROR any BAND) +LJFOLDF(simplify_shift_andk) +{ + IRIns *irk = IR(fright->op2); + PHIBARRIER(fright); + if ((fins->o < IR_BROL ? LJ_TARGET_MASKSHIFT : LJ_TARGET_MASKROT) && + irk->o == IR_KINT) { /* i o (j & mask) ==> i o j */ + int32_t mask = irt_is64(fins->t) ? 63 : 31; + int32_t k = irk->i & mask; + if (k == mask) { + fins->op2 = fright->op1; + return RETRYFOLD; + } + } + return NEXTFOLD; +} + +LJFOLD(BSHL KINT any) +LJFOLD(BSHR KINT any) +LJFOLD(BSHL KINT64 any) +LJFOLD(BSHR KINT64 any) +LJFOLDF(simplify_shift1_ki) +{ + int64_t k = fleft->o == IR_KINT ? (int64_t)fleft->i : + (int64_t)ir_k64(fleft)->u64; + if (k == 0) /* 0 o i ==> 0 */ + return LEFTFOLD; + return NEXTFOLD; +} + +LJFOLD(BSAR KINT any) +LJFOLD(BROL KINT any) +LJFOLD(BROR KINT any) +LJFOLD(BSAR KINT64 any) +LJFOLD(BROL KINT64 any) +LJFOLD(BROR KINT64 any) +LJFOLDF(simplify_shift2_ki) +{ + int64_t k = fleft->o == IR_KINT ? (int64_t)fleft->i : + (int64_t)ir_k64(fleft)->u64; + if (k == 0 || k == -1) /* 0 o i ==> 0; -1 o i ==> -1 */ + return LEFTFOLD; + return NEXTFOLD; +} + +LJFOLD(BSHL BAND KINT) +LJFOLD(BSHR BAND KINT) +LJFOLD(BROL BAND KINT) +LJFOLD(BROR BAND KINT) +LJFOLDF(simplify_shiftk_andk) +{ + IRIns *irk = IR(fleft->op2); + PHIBARRIER(fleft); + if (irk->o == IR_KINT) { /* (i & k1) o k2 ==> (i o k2) & (k1 o k2) */ + int32_t k = kfold_intop(irk->i, fright->i, (IROp)fins->o); + fins->op1 = fleft->op1; + fins->op1 = (IRRef1)lj_opt_fold(J); + fins->op2 = (IRRef1)lj_ir_kint(J, k); + fins->ot = IRTI(IR_BAND); + return RETRYFOLD; + } + return NEXTFOLD; +} + +LJFOLD(BAND BSHL KINT) +LJFOLD(BAND BSHR KINT) +LJFOLDF(simplify_andk_shiftk) +{ + IRIns *irk = IR(fleft->op2); + if (irk->o == IR_KINT && + kfold_intop(-1, irk->i, (IROp)fleft->o) == fright->i) + return LEFTFOLD; /* (i o k1) & k2 ==> i, if (-1 o k1) == k2 */ + return NEXTFOLD; +} + +/* -- Reassociation ------------------------------------------------------- */ + +LJFOLD(ADD ADD KINT) +LJFOLD(MUL MUL KINT) +LJFOLD(BAND BAND KINT) +LJFOLD(BOR BOR KINT) +LJFOLD(BXOR BXOR KINT) +LJFOLDF(reassoc_intarith_k) +{ + IRIns *irk = IR(fleft->op2); + if (irk->o == IR_KINT) { + int32_t k = kfold_intop(irk->i, fright->i, (IROp)fins->o); + if (k == irk->i) /* (i o k1) o k2 ==> i o k1, if (k1 o k2) == k1. */ + return LEFTFOLD; + PHIBARRIER(fleft); + fins->op1 = fleft->op1; + fins->op2 = (IRRef1)lj_ir_kint(J, k); + return RETRYFOLD; /* (i o k1) o k2 ==> i o (k1 o k2) */ + } + return NEXTFOLD; +} + +LJFOLD(ADD ADD KINT64) +LJFOLD(MUL MUL KINT64) +LJFOLD(BAND BAND KINT64) +LJFOLD(BOR BOR KINT64) +LJFOLD(BXOR BXOR KINT64) +LJFOLDF(reassoc_intarith_k64) +{ +#if LJ_HASFFI || LJ_64 + IRIns *irk = IR(fleft->op2); + if (irk->o == IR_KINT64) { + uint64_t k = kfold_int64arith(ir_k64(irk)->u64, + ir_k64(fright)->u64, (IROp)fins->o); + PHIBARRIER(fleft); + fins->op1 = fleft->op1; + fins->op2 = (IRRef1)lj_ir_kint64(J, k); + return RETRYFOLD; /* (i o k1) o k2 ==> i o (k1 o k2) */ + } + return NEXTFOLD; +#else + UNUSED(J); lua_assert(0); return FAILFOLD; +#endif +} + +LJFOLD(MIN MIN any) +LJFOLD(MAX MAX any) +LJFOLD(BAND BAND any) +LJFOLD(BOR BOR any) +LJFOLDF(reassoc_dup) +{ + if (fins->op2 == fleft->op1 || fins->op2 == fleft->op2) + return LEFTFOLD; /* (a o b) o a ==> a o b; (a o b) o b ==> a o b */ + return NEXTFOLD; +} + +LJFOLD(BXOR BXOR any) +LJFOLDF(reassoc_bxor) +{ + PHIBARRIER(fleft); + if (fins->op2 == fleft->op1) /* (a xor b) xor a ==> b */ + return fleft->op2; + if (fins->op2 == fleft->op2) /* (a xor b) xor b ==> a */ + return fleft->op1; + return NEXTFOLD; +} + +LJFOLD(BSHL BSHL KINT) +LJFOLD(BSHR BSHR KINT) +LJFOLD(BSAR BSAR KINT) +LJFOLD(BROL BROL KINT) +LJFOLD(BROR BROR KINT) +LJFOLDF(reassoc_shift) +{ + IRIns *irk = IR(fleft->op2); + PHIBARRIER(fleft); /* The (shift any KINT) rule covers k2 == 0 and more. */ + if (irk->o == IR_KINT) { /* (i o k1) o k2 ==> i o (k1 + k2) */ + int32_t mask = irt_is64(fins->t) ? 63 : 31; + int32_t k = (irk->i & mask) + (fright->i & mask); + if (k > mask) { /* Combined shift too wide? */ + if (fins->o == IR_BSHL || fins->o == IR_BSHR) + return mask == 31 ? INTFOLD(0) : INT64FOLD(0); + else if (fins->o == IR_BSAR) + k = mask; + else + k &= mask; + } + fins->op1 = fleft->op1; + fins->op2 = (IRRef1)lj_ir_kint(J, k); + return RETRYFOLD; + } + return NEXTFOLD; +} + +LJFOLD(MIN MIN KNUM) +LJFOLD(MAX MAX KNUM) +LJFOLD(MIN MIN KINT) +LJFOLD(MAX MAX KINT) +LJFOLDF(reassoc_minmax_k) +{ + IRIns *irk = IR(fleft->op2); + if (irk->o == IR_KNUM) { + lua_Number a = ir_knum(irk)->n; + lua_Number y = lj_vm_foldarith(a, knumright, fins->o - IR_ADD); + if (a == y) /* (x o k1) o k2 ==> x o k1, if (k1 o k2) == k1. */ + return LEFTFOLD; + PHIBARRIER(fleft); + fins->op1 = fleft->op1; + fins->op2 = (IRRef1)lj_ir_knum(J, y); + return RETRYFOLD; /* (x o k1) o k2 ==> x o (k1 o k2) */ + } else if (irk->o == IR_KINT) { + int32_t a = irk->i; + int32_t y = kfold_intop(a, fright->i, fins->o); + if (a == y) /* (x o k1) o k2 ==> x o k1, if (k1 o k2) == k1. */ + return LEFTFOLD; + PHIBARRIER(fleft); + fins->op1 = fleft->op1; + fins->op2 = (IRRef1)lj_ir_kint(J, y); + return RETRYFOLD; /* (x o k1) o k2 ==> x o (k1 o k2) */ + } + return NEXTFOLD; +} + +LJFOLD(MIN MAX any) +LJFOLD(MAX MIN any) +LJFOLDF(reassoc_minmax_left) +{ + if (fins->op2 == fleft->op1 || fins->op2 == fleft->op2) + return RIGHTFOLD; /* (b o1 a) o2 b ==> b; (a o1 b) o2 b ==> b */ + return NEXTFOLD; +} + +LJFOLD(MIN any MAX) +LJFOLD(MAX any MIN) +LJFOLDF(reassoc_minmax_right) +{ + if (fins->op1 == fright->op1 || fins->op1 == fright->op2) + return LEFTFOLD; /* a o2 (a o1 b) ==> a; a o2 (b o1 a) ==> a */ + return NEXTFOLD; +} + +/* -- Array bounds check elimination -------------------------------------- */ + +/* Eliminate ABC across PHIs to handle t[i-1] forwarding case. +** ABC(asize, (i+k)+(-k)) ==> ABC(asize, i), but only if it already exists. +** Could be generalized to (i+k1)+k2 ==> i+(k1+k2), but needs better disambig. +*/ +LJFOLD(ABC any ADD) +LJFOLDF(abc_fwd) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_ABC)) { + if (irref_isk(fright->op2)) { + IRIns *add2 = IR(fright->op1); + if (add2->o == IR_ADD && irref_isk(add2->op2) && + IR(fright->op2)->i == -IR(add2->op2)->i) { + IRRef ref = J->chain[IR_ABC]; + IRRef lim = add2->op1; + if (fins->op1 > lim) lim = fins->op1; + while (ref > lim) { + IRIns *ir = IR(ref); + if (ir->op1 == fins->op1 && ir->op2 == add2->op1) + return DROPFOLD; + ref = ir->prev; + } + } + } + } + return NEXTFOLD; +} + +/* Eliminate ABC for constants. +** ABC(asize, k1), ABC(asize k2) ==> ABC(asize, max(k1, k2)) +** Drop second ABC if k2 is lower. Otherwise patch first ABC with k2. +*/ +LJFOLD(ABC any KINT) +LJFOLDF(abc_k) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_ABC)) { + IRRef ref = J->chain[IR_ABC]; + IRRef asize = fins->op1; + while (ref > asize) { + IRIns *ir = IR(ref); + if (ir->op1 == asize && irref_isk(ir->op2)) { + int32_t k = IR(ir->op2)->i; + if (fright->i > k) + ir->op2 = fins->op2; + return DROPFOLD; + } + ref = ir->prev; + } + return EMITFOLD; /* Already performed CSE. */ + } + return NEXTFOLD; +} + +/* Eliminate invariant ABC inside loop. */ +LJFOLD(ABC any any) +LJFOLDF(abc_invar) +{ + /* Invariant ABC marked as PTR. Drop if op1 is invariant, too. */ + if (!irt_isint(fins->t) && fins->op1 < J->chain[IR_LOOP] && + !irt_isphi(IR(fins->op1)->t)) + return DROPFOLD; + return NEXTFOLD; +} + +/* -- Commutativity ------------------------------------------------------- */ + +/* The refs of commutative ops are canonicalized. Lower refs go to the right. +** Rationale behind this: +** - It (also) moves constants to the right. +** - It reduces the number of FOLD rules (e.g. (BOR any KINT) suffices). +** - It helps CSE to find more matches. +** - The assembler generates better code with constants at the right. +*/ + +LJFOLD(ADD any any) +LJFOLD(MUL any any) +LJFOLD(ADDOV any any) +LJFOLD(MULOV any any) +LJFOLDF(comm_swap) +{ + if (fins->op1 < fins->op2) { /* Move lower ref to the right. */ + IRRef1 tmp = fins->op1; + fins->op1 = fins->op2; + fins->op2 = tmp; + return RETRYFOLD; + } + return NEXTFOLD; +} + +LJFOLD(EQ any any) +LJFOLD(NE any any) +LJFOLDF(comm_equal) +{ + /* For non-numbers only: x == x ==> drop; x ~= x ==> fail */ + if (fins->op1 == fins->op2 && !irt_isnum(fins->t)) + return CONDFOLD(fins->o == IR_EQ); + return fold_comm_swap(J); +} + +LJFOLD(LT any any) +LJFOLD(GE any any) +LJFOLD(LE any any) +LJFOLD(GT any any) +LJFOLD(ULT any any) +LJFOLD(UGE any any) +LJFOLD(ULE any any) +LJFOLD(UGT any any) +LJFOLDF(comm_comp) +{ + /* For non-numbers only: x <=> x ==> drop; x <> x ==> fail */ + if (fins->op1 == fins->op2 && !irt_isnum(fins->t)) + return CONDFOLD((fins->o ^ (fins->o >> 1)) & 1); + if (fins->op1 < fins->op2) { /* Move lower ref to the right. */ + IRRef1 tmp = fins->op1; + fins->op1 = fins->op2; + fins->op2 = tmp; + fins->o ^= 3; /* GT <-> LT, GE <-> LE, does not affect U */ + return RETRYFOLD; + } + return NEXTFOLD; +} + +LJFOLD(BAND any any) +LJFOLD(BOR any any) +LJFOLD(MIN any any) +LJFOLD(MAX any any) +LJFOLDF(comm_dup) +{ + if (fins->op1 == fins->op2) /* x o x ==> x */ + return LEFTFOLD; + return fold_comm_swap(J); +} + +LJFOLD(BXOR any any) +LJFOLDF(comm_bxor) +{ + if (fins->op1 == fins->op2) /* i xor i ==> 0 */ + return irt_is64(fins->t) ? INT64FOLD(0) : INTFOLD(0); + return fold_comm_swap(J); +} + +/* -- Simplification of compound expressions ------------------------------ */ + +static TRef kfold_xload(jit_State *J, IRIns *ir, const void *p) +{ + int32_t k; + switch (irt_type(ir->t)) { + case IRT_NUM: return lj_ir_knum_u64(J, *(uint64_t *)p); + case IRT_I8: k = (int32_t)*(int8_t *)p; break; + case IRT_U8: k = (int32_t)*(uint8_t *)p; break; + case IRT_I16: k = (int32_t)(int16_t)lj_getu16(p); break; + case IRT_U16: k = (int32_t)(uint16_t)lj_getu16(p); break; + case IRT_INT: case IRT_U32: k = (int32_t)lj_getu32(p); break; + case IRT_I64: case IRT_U64: return lj_ir_kint64(J, *(uint64_t *)p); + default: return 0; + } + return lj_ir_kint(J, k); +} + +/* Turn: string.sub(str, a, b) == kstr +** into: string.byte(str, a) == string.byte(kstr, 1) etc. +** Note: this creates unaligned XLOADs on x86/x64. +*/ +LJFOLD(EQ SNEW KGC) +LJFOLD(NE SNEW KGC) +LJFOLDF(merge_eqne_snew_kgc) +{ + GCstr *kstr = ir_kstr(fright); + int32_t len = (int32_t)kstr->len; + lua_assert(irt_isstr(fins->t)); + +#if LJ_TARGET_UNALIGNED +#define FOLD_SNEW_MAX_LEN 4 /* Handle string lengths 0, 1, 2, 3, 4. */ +#define FOLD_SNEW_TYPE8 IRT_I8 /* Creates shorter immediates. */ +#else +#define FOLD_SNEW_MAX_LEN 1 /* Handle string lengths 0 or 1. */ +#define FOLD_SNEW_TYPE8 IRT_U8 /* Prefer unsigned loads. */ +#endif + + PHIBARRIER(fleft); + if (len <= FOLD_SNEW_MAX_LEN) { + IROp op = (IROp)fins->o; + IRRef strref = fleft->op1; + if (IR(strref)->o != IR_STRREF) + return NEXTFOLD; + if (op == IR_EQ) { + emitir(IRTGI(IR_EQ), fleft->op2, lj_ir_kint(J, len)); + /* Caveat: fins/fleft/fright is no longer valid after emitir. */ + } else { + /* NE is not expanded since this would need an OR of two conds. */ + if (!irref_isk(fleft->op2)) /* Only handle the constant length case. */ + return NEXTFOLD; + if (IR(fleft->op2)->i != len) + return DROPFOLD; + } + if (len > 0) { + /* A 4 byte load for length 3 is ok -- all strings have an extra NUL. */ + uint16_t ot = (uint16_t)(len == 1 ? IRT(IR_XLOAD, FOLD_SNEW_TYPE8) : + len == 2 ? IRT(IR_XLOAD, IRT_U16) : + IRTI(IR_XLOAD)); + TRef tmp = emitir(ot, strref, + IRXLOAD_READONLY | (len > 1 ? IRXLOAD_UNALIGNED : 0)); + TRef val = kfold_xload(J, IR(tref_ref(tmp)), strdata(kstr)); + if (len == 3) + tmp = emitir(IRTI(IR_BAND), tmp, + lj_ir_kint(J, LJ_ENDIAN_SELECT(0x00ffffff, 0xffffff00))); + fins->op1 = (IRRef1)tmp; + fins->op2 = (IRRef1)val; + fins->ot = (IROpT)IRTGI(op); + return RETRYFOLD; + } else { + return DROPFOLD; + } + } + return NEXTFOLD; +} + +/* -- Loads --------------------------------------------------------------- */ + +/* Loads cannot be folded or passed on to CSE in general. +** Alias analysis is needed to check for forwarding opportunities. +** +** Caveat: *all* loads must be listed here or they end up at CSE! +*/ + +LJFOLD(ALOAD any) +LJFOLDX(lj_opt_fwd_aload) + +/* From HREF fwd (see below). Must eliminate, not supported by fwd/backend. */ +LJFOLD(HLOAD KKPTR) +LJFOLDF(kfold_hload_kkptr) +{ + UNUSED(J); + lua_assert(ir_kptr(fleft) == niltvg(J2G(J))); + return TREF_NIL; +} + +LJFOLD(HLOAD any) +LJFOLDX(lj_opt_fwd_hload) + +LJFOLD(ULOAD any) +LJFOLDX(lj_opt_fwd_uload) + +LJFOLD(CALLL any IRCALL_lj_tab_len) +LJFOLDX(lj_opt_fwd_tab_len) + +/* Upvalue refs are really loads, but there are no corresponding stores. +** So CSE is ok for them, except for UREFO across a GC step (see below). +** If the referenced function is const, its upvalue addresses are const, too. +** This can be used to improve CSE by looking for the same address, +** even if the upvalues originate from a different function. +*/ +LJFOLD(UREFO KGC any) +LJFOLD(UREFC KGC any) +LJFOLDF(cse_uref) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_CSE)) { + IRRef ref = J->chain[fins->o]; + GCfunc *fn = ir_kfunc(fleft); + GCupval *uv = gco2uv(gcref(fn->l.uvptr[(fins->op2 >> 8)])); + while (ref > 0) { + IRIns *ir = IR(ref); + if (irref_isk(ir->op1)) { + GCfunc *fn2 = ir_kfunc(IR(ir->op1)); + if (gco2uv(gcref(fn2->l.uvptr[(ir->op2 >> 8)])) == uv) { + if (fins->o == IR_UREFO && gcstep_barrier(J, ref)) + break; + return ref; + } + } + ref = ir->prev; + } + } + return EMITFOLD; +} + +LJFOLD(HREFK any any) +LJFOLDX(lj_opt_fwd_hrefk) + +LJFOLD(HREF TNEW any) +LJFOLDF(fwd_href_tnew) +{ + if (lj_opt_fwd_href_nokey(J)) + return lj_ir_kkptr(J, niltvg(J2G(J))); + return NEXTFOLD; +} + +LJFOLD(HREF TDUP KPRI) +LJFOLD(HREF TDUP KGC) +LJFOLD(HREF TDUP KNUM) +LJFOLDF(fwd_href_tdup) +{ + TValue keyv; + lj_ir_kvalue(J->L, &keyv, fright); + if (lj_tab_get(J->L, ir_ktab(IR(fleft->op1)), &keyv) == niltvg(J2G(J)) && + lj_opt_fwd_href_nokey(J)) + return lj_ir_kkptr(J, niltvg(J2G(J))); + return NEXTFOLD; +} + +/* We can safely FOLD/CSE array/hash refs and field loads, since there +** are no corresponding stores. But we need to check for any NEWREF with +** an aliased table, as it may invalidate all of the pointers and fields. +** Only HREF needs the NEWREF check -- AREF and HREFK already depend on +** FLOADs. And NEWREF itself is treated like a store (see below). +*/ +LJFOLD(FLOAD TNEW IRFL_TAB_ASIZE) +LJFOLDF(fload_tab_tnew_asize) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && lj_opt_fwd_tptr(J, fins->op1)) + return INTFOLD(fleft->op1); + return NEXTFOLD; +} + +LJFOLD(FLOAD TNEW IRFL_TAB_HMASK) +LJFOLDF(fload_tab_tnew_hmask) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && lj_opt_fwd_tptr(J, fins->op1)) + return INTFOLD((1 << fleft->op2)-1); + return NEXTFOLD; +} + +LJFOLD(FLOAD TDUP IRFL_TAB_ASIZE) +LJFOLDF(fload_tab_tdup_asize) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && lj_opt_fwd_tptr(J, fins->op1)) + return INTFOLD((int32_t)ir_ktab(IR(fleft->op1))->asize); + return NEXTFOLD; +} + +LJFOLD(FLOAD TDUP IRFL_TAB_HMASK) +LJFOLDF(fload_tab_tdup_hmask) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && lj_opt_fwd_tptr(J, fins->op1)) + return INTFOLD((int32_t)ir_ktab(IR(fleft->op1))->hmask); + return NEXTFOLD; +} + +LJFOLD(HREF any any) +LJFOLD(FLOAD any IRFL_TAB_ARRAY) +LJFOLD(FLOAD any IRFL_TAB_NODE) +LJFOLD(FLOAD any IRFL_TAB_ASIZE) +LJFOLD(FLOAD any IRFL_TAB_HMASK) +LJFOLDF(fload_tab_ah) +{ + TRef tr = lj_opt_cse(J); + return lj_opt_fwd_tptr(J, tref_ref(tr)) ? tr : EMITFOLD; +} + +/* Strings are immutable, so we can safely FOLD/CSE the related FLOAD. */ +LJFOLD(FLOAD KGC IRFL_STR_LEN) +LJFOLDF(fload_str_len_kgc) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) + return INTFOLD((int32_t)ir_kstr(fleft)->len); + return NEXTFOLD; +} + +LJFOLD(FLOAD SNEW IRFL_STR_LEN) +LJFOLDF(fload_str_len_snew) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) { + PHIBARRIER(fleft); + return fleft->op2; + } + return NEXTFOLD; +} + +/* The C type ID of cdata objects is immutable. */ +LJFOLD(FLOAD KGC IRFL_CDATA_CTYPEID) +LJFOLDF(fload_cdata_typeid_kgc) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) + return INTFOLD((int32_t)ir_kcdata(fleft)->ctypeid); + return NEXTFOLD; +} + +/* Get the contents of immutable cdata objects. */ +LJFOLD(FLOAD KGC IRFL_CDATA_PTR) +LJFOLD(FLOAD KGC IRFL_CDATA_INT) +LJFOLD(FLOAD KGC IRFL_CDATA_INT64) +LJFOLDF(fload_cdata_int64_kgc) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) { + void *p = cdataptr(ir_kcdata(fleft)); + if (irt_is64(fins->t)) + return INT64FOLD(*(uint64_t *)p); + else + return INTFOLD(*(int32_t *)p); + } + return NEXTFOLD; +} + +LJFOLD(FLOAD CNEW IRFL_CDATA_CTYPEID) +LJFOLD(FLOAD CNEWI IRFL_CDATA_CTYPEID) +LJFOLDF(fload_cdata_typeid_cnew) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) + return fleft->op1; /* No PHI barrier needed. CNEW/CNEWI op1 is const. */ + return NEXTFOLD; +} + +/* Pointer, int and int64 cdata objects are immutable. */ +LJFOLD(FLOAD CNEWI IRFL_CDATA_PTR) +LJFOLD(FLOAD CNEWI IRFL_CDATA_INT) +LJFOLD(FLOAD CNEWI IRFL_CDATA_INT64) +LJFOLDF(fload_cdata_ptr_int64_cnew) +{ + if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) + return fleft->op2; /* Fold even across PHI to avoid allocations. */ + return NEXTFOLD; +} + +LJFOLD(FLOAD any IRFL_STR_LEN) +LJFOLD(FLOAD any IRFL_CDATA_CTYPEID) +LJFOLD(FLOAD any IRFL_CDATA_PTR) +LJFOLD(FLOAD any IRFL_CDATA_INT) +LJFOLD(FLOAD any IRFL_CDATA_INT64) +LJFOLD(VLOAD any any) /* Vararg loads have no corresponding stores. */ +LJFOLDX(lj_opt_cse) + +/* All other field loads need alias analysis. */ +LJFOLD(FLOAD any any) +LJFOLDX(lj_opt_fwd_fload) + +/* This is for LOOP only. Recording handles SLOADs internally. */ +LJFOLD(SLOAD any any) +LJFOLDF(fwd_sload) +{ + if ((fins->op2 & IRSLOAD_FRAME)) { + TRef tr = lj_opt_cse(J); + return tref_ref(tr) < J->chain[IR_RETF] ? EMITFOLD : tr; + } else { + lua_assert(J->slot[fins->op1] != 0); + return J->slot[fins->op1]; + } +} + +/* Only fold for KKPTR. The pointer _and_ the contents must be const. */ +LJFOLD(XLOAD KKPTR any) +LJFOLDF(xload_kptr) +{ + TRef tr = kfold_xload(J, fins, ir_kptr(fleft)); + return tr ? tr : NEXTFOLD; +} + +LJFOLD(XLOAD any any) +LJFOLDX(lj_opt_fwd_xload) + +/* -- Write barriers ------------------------------------------------------ */ + +/* Write barriers are amenable to CSE, but not across any incremental +** GC steps. +** +** The same logic applies to open upvalue references, because a stack +** may be resized during a GC step (not the current stack, but maybe that +** of a coroutine). +*/ +LJFOLD(TBAR any) +LJFOLD(OBAR any any) +LJFOLD(UREFO any any) +LJFOLDF(barrier_tab) +{ + TRef tr = lj_opt_cse(J); + if (gcstep_barrier(J, tref_ref(tr))) /* CSE across GC step? */ + return EMITFOLD; /* Raw emit. Assumes fins is left intact by CSE. */ + return tr; +} + +LJFOLD(TBAR TNEW) +LJFOLD(TBAR TDUP) +LJFOLDF(barrier_tnew_tdup) +{ + /* New tables are always white and never need a barrier. */ + if (fins->op1 < J->chain[IR_LOOP]) /* Except across a GC step. */ + return NEXTFOLD; + return DROPFOLD; +} + +/* -- Stores and allocations ---------------------------------------------- */ + +/* Stores and allocations cannot be folded or passed on to CSE in general. +** But some stores can be eliminated with dead-store elimination (DSE). +** +** Caveat: *all* stores and allocs must be listed here or they end up at CSE! +*/ + +LJFOLD(ASTORE any any) +LJFOLD(HSTORE any any) +LJFOLDX(lj_opt_dse_ahstore) + +LJFOLD(USTORE any any) +LJFOLDX(lj_opt_dse_ustore) + +LJFOLD(FSTORE any any) +LJFOLDX(lj_opt_dse_fstore) + +LJFOLD(XSTORE any any) +LJFOLDX(lj_opt_dse_xstore) + +LJFOLD(NEWREF any any) /* Treated like a store. */ +LJFOLD(CALLS any any) +LJFOLD(CALLL any any) /* Safeguard fallback. */ +LJFOLD(CALLXS any any) +LJFOLD(XBAR) +LJFOLD(RETF any any) /* Modifies BASE. */ +LJFOLD(TNEW any any) +LJFOLD(TDUP any) +LJFOLD(CNEW any any) +LJFOLD(XSNEW any any) +LJFOLDX(lj_ir_emit) + +/* ------------------------------------------------------------------------ */ + +/* Every entry in the generated hash table is a 32 bit pattern: +** +** xxxxxxxx iiiiiii lllllll rrrrrrrrrr +** +** xxxxxxxx = 8 bit index into fold function table +** iiiiiii = 7 bit folded instruction opcode +** lllllll = 7 bit left instruction opcode +** rrrrrrrrrr = 8 bit right instruction opcode or 10 bits from literal field +*/ + +#include "lj_folddef.h" + +/* ------------------------------------------------------------------------ */ + +/* Fold IR instruction. */ +TRef LJ_FASTCALL lj_opt_fold(jit_State *J) +{ + uint32_t key, any; + IRRef ref; + + if (LJ_UNLIKELY((J->flags & JIT_F_OPT_MASK) != JIT_F_OPT_DEFAULT)) { + lua_assert(((JIT_F_OPT_FOLD|JIT_F_OPT_FWD|JIT_F_OPT_CSE|JIT_F_OPT_DSE) | + JIT_F_OPT_DEFAULT) == JIT_F_OPT_DEFAULT); + /* Folding disabled? Chain to CSE, but not for loads/stores/allocs. */ + if (!(J->flags & JIT_F_OPT_FOLD) && irm_kind(lj_ir_mode[fins->o]) == IRM_N) + return lj_opt_cse(J); + + /* No FOLD, forwarding or CSE? Emit raw IR for loads, except for SLOAD. */ + if ((J->flags & (JIT_F_OPT_FOLD|JIT_F_OPT_FWD|JIT_F_OPT_CSE)) != + (JIT_F_OPT_FOLD|JIT_F_OPT_FWD|JIT_F_OPT_CSE) && + irm_kind(lj_ir_mode[fins->o]) == IRM_L && fins->o != IR_SLOAD) + return lj_ir_emit(J); + + /* No FOLD or DSE? Emit raw IR for stores. */ + if ((J->flags & (JIT_F_OPT_FOLD|JIT_F_OPT_DSE)) != + (JIT_F_OPT_FOLD|JIT_F_OPT_DSE) && + irm_kind(lj_ir_mode[fins->o]) == IRM_S) + return lj_ir_emit(J); + } + + /* Fold engine start/retry point. */ +retry: + /* Construct key from opcode and operand opcodes (unless literal/none). */ + key = ((uint32_t)fins->o << 17); + if (fins->op1 >= J->cur.nk) { + key += (uint32_t)IR(fins->op1)->o << 10; + *fleft = *IR(fins->op1); + } + if (fins->op2 >= J->cur.nk) { + key += (uint32_t)IR(fins->op2)->o; + *fright = *IR(fins->op2); + } else { + key += (fins->op2 & 0x3ffu); /* Literal mask. Must include IRCONV_*MASK. */ + } + + /* Check for a match in order from most specific to least specific. */ + any = 0; + for (;;) { + uint32_t k = key | (any & 0x1ffff); + uint32_t h = fold_hashkey(k); + uint32_t fh = fold_hash[h]; /* Lookup key in semi-perfect hash table. */ + if ((fh & 0xffffff) == k || (fh = fold_hash[h+1], (fh & 0xffffff) == k)) { + ref = (IRRef)tref_ref(fold_func[fh >> 24](J)); + if (ref != NEXTFOLD) + break; + } + if (any == 0xfffff) /* Exhausted folding. Pass on to CSE. */ + return lj_opt_cse(J); + any = (any | (any >> 10)) ^ 0xffc00; + } + + /* Return value processing, ordered by frequency. */ + if (LJ_LIKELY(ref >= MAX_FOLD)) + return TREF(ref, irt_t(IR(ref)->t)); + if (ref == RETRYFOLD) + goto retry; + if (ref == KINTFOLD) + return lj_ir_kint(J, fins->i); + if (ref == FAILFOLD) + lj_trace_err(J, LJ_TRERR_GFAIL); + lua_assert(ref == DROPFOLD); + return REF_DROP; +} + +/* -- Common-Subexpression Elimination ------------------------------------ */ + +/* CSE an IR instruction. This is very fast due to the skip-list chains. */ +TRef LJ_FASTCALL lj_opt_cse(jit_State *J) +{ + /* Avoid narrow to wide store-to-load forwarding stall */ + IRRef2 op12 = (IRRef2)fins->op1 + ((IRRef2)fins->op2 << 16); + IROp op = fins->o; + if (LJ_LIKELY(J->flags & JIT_F_OPT_CSE)) { + /* Limited search for same operands in per-opcode chain. */ + IRRef ref = J->chain[op]; + IRRef lim = fins->op1; + if (fins->op2 > lim) lim = fins->op2; /* Relies on lit < REF_BIAS. */ + while (ref > lim) { + if (IR(ref)->op12 == op12) + return TREF(ref, irt_t(IR(ref)->t)); /* Common subexpression found. */ + ref = IR(ref)->prev; + } + } + /* Otherwise emit IR (inlined for speed). */ + { + IRRef ref = lj_ir_nextins(J); + IRIns *ir = IR(ref); + ir->prev = J->chain[op]; + ir->op12 = op12; + J->chain[op] = (IRRef1)ref; + ir->o = fins->o; + J->guardemit.irt |= fins->t.irt; + return TREF(ref, irt_t((ir->t = fins->t))); + } +} + +/* CSE with explicit search limit. */ +TRef LJ_FASTCALL lj_opt_cselim(jit_State *J, IRRef lim) +{ + IRRef ref = J->chain[fins->o]; + IRRef2 op12 = (IRRef2)fins->op1 + ((IRRef2)fins->op2 << 16); + while (ref > lim) { + if (IR(ref)->op12 == op12) + return ref; + ref = IR(ref)->prev; + } + return lj_ir_emit(J); +} + +/* ------------------------------------------------------------------------ */ + +#undef IR +#undef fins +#undef fleft +#undef fright +#undef knumleft +#undef knumright +#undef emitir + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_loop.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_loop.c new file mode 100644 index 000000000..b7d1923ed --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_loop.c @@ -0,0 +1,436 @@ +/* +** LOOP: Loop Optimizations. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_opt_loop_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_err.h" +#include "lj_str.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_iropt.h" +#include "lj_trace.h" +#include "lj_snap.h" +#include "lj_vm.h" + +/* Loop optimization: +** +** Traditional Loop-Invariant Code Motion (LICM) splits the instructions +** of a loop into invariant and variant instructions. The invariant +** instructions are hoisted out of the loop and only the variant +** instructions remain inside the loop body. +** +** Unfortunately LICM is mostly useless for compiling dynamic languages. +** The IR has many guards and most of the subsequent instructions are +** control-dependent on them. The first non-hoistable guard would +** effectively prevent hoisting of all subsequent instructions. +** +** That's why we use a special form of unrolling using copy-substitution, +** combined with redundancy elimination: +** +** The recorded instruction stream is re-emitted to the compiler pipeline +** with substituted operands. The substitution table is filled with the +** refs returned by re-emitting each instruction. This can be done +** on-the-fly, because the IR is in strict SSA form, where every ref is +** defined before its use. +** +** This aproach generates two code sections, separated by the LOOP +** instruction: +** +** 1. The recorded instructions form a kind of pre-roll for the loop. It +** contains a mix of invariant and variant instructions and performs +** exactly one loop iteration (but not necessarily the 1st iteration). +** +** 2. The loop body contains only the variant instructions and performs +** all remaining loop iterations. +** +** On first sight that looks like a waste of space, because the variant +** instructions are present twice. But the key insight is that the +** pre-roll honors the control-dependencies for *both* the pre-roll itself +** *and* the loop body! +** +** It also means one doesn't have to explicitly model control-dependencies +** (which, BTW, wouldn't help LICM much). And it's much easier to +** integrate sparse snapshotting with this approach. +** +** One of the nicest aspects of this approach is that all of the +** optimizations of the compiler pipeline (FOLD, CSE, FWD, etc.) can be +** reused with only minor restrictions (e.g. one should not fold +** instructions across loop-carried dependencies). +** +** But in general all optimizations can be applied which only need to look +** backwards into the generated instruction stream. At any point in time +** during the copy-substitution process this contains both a static loop +** iteration (the pre-roll) and a dynamic one (from the to-be-copied +** instruction up to the end of the partial loop body). +** +** Since control-dependencies are implicitly kept, CSE also applies to all +** kinds of guards. The major advantage is that all invariant guards can +** be hoisted, too. +** +** Load/store forwarding works across loop iterations, too. This is +** important if loop-carried dependencies are kept in upvalues or tables. +** E.g. 'self.idx = self.idx + 1' deep down in some OO-style method may +** become a forwarded loop-recurrence after inlining. +** +** Since the IR is in SSA form, loop-carried dependencies have to be +** modeled with PHI instructions. The potential candidates for PHIs are +** collected on-the-fly during copy-substitution. After eliminating the +** redundant ones, PHI instructions are emitted *below* the loop body. +** +** Note that this departure from traditional SSA form doesn't change the +** semantics of the PHI instructions themselves. But it greatly simplifies +** on-the-fly generation of the IR and the machine code. +*/ + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) + +/* Pass IR on to next optimization in chain (FOLD). */ +#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) + +/* Emit raw IR without passing through optimizations. */ +#define emitir_raw(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_ir_emit(J)) + +/* -- PHI elimination ----------------------------------------------------- */ + +/* Emit or eliminate collected PHIs. */ +static void loop_emit_phi(jit_State *J, IRRef1 *subst, IRRef1 *phi, IRRef nphi, + SnapNo onsnap) +{ + int passx = 0; + IRRef i, j, nslots; + IRRef invar = J->chain[IR_LOOP]; + /* Pass #1: mark redundant and potentially redundant PHIs. */ + for (i = 0, j = 0; i < nphi; i++) { + IRRef lref = phi[i]; + IRRef rref = subst[lref]; + if (lref == rref || rref == REF_DROP) { /* Invariants are redundant. */ + irt_clearphi(IR(lref)->t); + } else { + phi[j++] = (IRRef1)lref; + if (!(IR(rref)->op1 == lref || IR(rref)->op2 == lref)) { + /* Quick check for simple recurrences failed, need pass2. */ + irt_setmark(IR(lref)->t); + passx = 1; + } + } + } + nphi = j; + /* Pass #2: traverse variant part and clear marks of non-redundant PHIs. */ + if (passx) { + SnapNo s; + for (i = J->cur.nins-1; i > invar; i--) { + IRIns *ir = IR(i); + if (!irref_isk(ir->op2)) irt_clearmark(IR(ir->op2)->t); + if (!irref_isk(ir->op1)) { + irt_clearmark(IR(ir->op1)->t); + if (ir->op1 < invar && + ir->o >= IR_CALLN && ir->o <= IR_CARG) { /* ORDER IR */ + ir = IR(ir->op1); + while (ir->o == IR_CARG) { + if (!irref_isk(ir->op2)) irt_clearmark(IR(ir->op2)->t); + if (irref_isk(ir->op1)) break; + ir = IR(ir->op1); + irt_clearmark(ir->t); + } + } + } + } + for (s = J->cur.nsnap-1; s >= onsnap; s--) { + SnapShot *snap = &J->cur.snap[s]; + SnapEntry *map = &J->cur.snapmap[snap->mapofs]; + MSize n, nent = snap->nent; + for (n = 0; n < nent; n++) { + IRRef ref = snap_ref(map[n]); + if (!irref_isk(ref)) irt_clearmark(IR(ref)->t); + } + } + } + /* Pass #3: add PHIs for variant slots without a corresponding SLOAD. */ + nslots = J->baseslot+J->maxslot; + for (i = 1; i < nslots; i++) { + IRRef ref = tref_ref(J->slot[i]); + while (!irref_isk(ref) && ref != subst[ref]) { + IRIns *ir = IR(ref); + irt_clearmark(ir->t); /* Unmark potential uses, too. */ + if (irt_isphi(ir->t) || irt_ispri(ir->t)) + break; + irt_setphi(ir->t); + if (nphi >= LJ_MAX_PHI) + lj_trace_err(J, LJ_TRERR_PHIOV); + phi[nphi++] = (IRRef1)ref; + ref = subst[ref]; + if (ref > invar) + break; + } + } + /* Pass #4: propagate non-redundant PHIs. */ + while (passx) { + passx = 0; + for (i = 0; i < nphi; i++) { + IRRef lref = phi[i]; + IRIns *ir = IR(lref); + if (!irt_ismarked(ir->t)) { /* Propagate only from unmarked PHIs. */ + IRIns *irr = IR(subst[lref]); + if (irt_ismarked(irr->t)) { /* Right ref points to other PHI? */ + irt_clearmark(irr->t); /* Mark that PHI as non-redundant. */ + passx = 1; /* Retry. */ + } + } + } + } + /* Pass #5: emit PHI instructions or eliminate PHIs. */ + for (i = 0; i < nphi; i++) { + IRRef lref = phi[i]; + IRIns *ir = IR(lref); + if (!irt_ismarked(ir->t)) { /* Emit PHI if not marked. */ + IRRef rref = subst[lref]; + if (rref > invar) + irt_setphi(IR(rref)->t); + emitir_raw(IRT(IR_PHI, irt_type(ir->t)), lref, rref); + } else { /* Otherwise eliminate PHI. */ + irt_clearmark(ir->t); + irt_clearphi(ir->t); + } + } +} + +/* -- Loop unrolling using copy-substitution ------------------------------ */ + +/* Copy-substitute snapshot. */ +static void loop_subst_snap(jit_State *J, SnapShot *osnap, + SnapEntry *loopmap, IRRef1 *subst) +{ + SnapEntry *nmap, *omap = &J->cur.snapmap[osnap->mapofs]; + SnapEntry *nextmap = &J->cur.snapmap[snap_nextofs(&J->cur, osnap)]; + MSize nmapofs; + MSize on, ln, nn, onent = osnap->nent; + BCReg nslots = osnap->nslots; + SnapShot *snap = &J->cur.snap[J->cur.nsnap]; + if (irt_isguard(J->guardemit)) { /* Guard inbetween? */ + nmapofs = J->cur.nsnapmap; + J->cur.nsnap++; /* Add new snapshot. */ + } else { /* Otherwise overwrite previous snapshot. */ + snap--; + nmapofs = snap->mapofs; + } + J->guardemit.irt = 0; + /* Setup new snapshot. */ + snap->mapofs = (uint16_t)nmapofs; + snap->ref = (IRRef1)J->cur.nins; + snap->nslots = nslots; + snap->topslot = osnap->topslot; + snap->count = 0; + nmap = &J->cur.snapmap[nmapofs]; + /* Substitute snapshot slots. */ + on = ln = nn = 0; + while (on < onent) { + SnapEntry osn = omap[on], lsn = loopmap[ln]; + if (snap_slot(lsn) < snap_slot(osn)) { /* Copy slot from loop map. */ + nmap[nn++] = lsn; + ln++; + } else { /* Copy substituted slot from snapshot map. */ + if (snap_slot(lsn) == snap_slot(osn)) ln++; /* Shadowed loop slot. */ + if (!irref_isk(snap_ref(osn))) + osn = snap_setref(osn, subst[snap_ref(osn)]); + nmap[nn++] = osn; + on++; + } + } + while (snap_slot(loopmap[ln]) < nslots) /* Copy remaining loop slots. */ + nmap[nn++] = loopmap[ln++]; + snap->nent = (uint8_t)nn; + omap += onent; + nmap += nn; + while (omap < nextmap) /* Copy PC + frame links. */ + *nmap++ = *omap++; + J->cur.nsnapmap = (uint16_t)(nmap - J->cur.snapmap); +} + +/* Unroll loop. */ +static void loop_unroll(jit_State *J) +{ + IRRef1 phi[LJ_MAX_PHI]; + uint32_t nphi = 0; + IRRef1 *subst; + SnapNo onsnap; + SnapShot *osnap, *loopsnap; + SnapEntry *loopmap, *psentinel; + IRRef ins, invar; + + /* Use temp buffer for substitution table. + ** Only non-constant refs in [REF_BIAS,invar) are valid indexes. + ** Caveat: don't call into the VM or run the GC or the buffer may be gone. + */ + invar = J->cur.nins; + subst = (IRRef1 *)lj_str_needbuf(J->L, &G(J->L)->tmpbuf, + (invar-REF_BIAS)*sizeof(IRRef1)) - REF_BIAS; + subst[REF_BASE] = REF_BASE; + + /* LOOP separates the pre-roll from the loop body. */ + emitir_raw(IRTG(IR_LOOP, IRT_NIL), 0, 0); + + /* Grow snapshot buffer and map for copy-substituted snapshots. + ** Need up to twice the number of snapshots minus #0 and loop snapshot. + ** Need up to twice the number of entries plus fallback substitutions + ** from the loop snapshot entries for each new snapshot. + ** Caveat: both calls may reallocate J->cur.snap and J->cur.snapmap! + */ + onsnap = J->cur.nsnap; + lj_snap_grow_buf(J, 2*onsnap-2); + lj_snap_grow_map(J, J->cur.nsnapmap*2+(onsnap-2)*J->cur.snap[onsnap-1].nent); + + /* The loop snapshot is used for fallback substitutions. */ + loopsnap = &J->cur.snap[onsnap-1]; + loopmap = &J->cur.snapmap[loopsnap->mapofs]; + /* The PC of snapshot #0 and the loop snapshot must match. */ + psentinel = &loopmap[loopsnap->nent]; + lua_assert(*psentinel == J->cur.snapmap[J->cur.snap[0].nent]); + *psentinel = SNAP(255, 0, 0); /* Replace PC with temporary sentinel. */ + + /* Start substitution with snapshot #1 (#0 is empty for root traces). */ + osnap = &J->cur.snap[1]; + + /* Copy and substitute all recorded instructions and snapshots. */ + for (ins = REF_FIRST; ins < invar; ins++) { + IRIns *ir; + IRRef op1, op2; + + if (ins >= osnap->ref) /* Instruction belongs to next snapshot? */ + loop_subst_snap(J, osnap++, loopmap, subst); /* Copy-substitute it. */ + + /* Substitute instruction operands. */ + ir = IR(ins); + op1 = ir->op1; + if (!irref_isk(op1)) op1 = subst[op1]; + op2 = ir->op2; + if (!irref_isk(op2)) op2 = subst[op2]; + if (irm_kind(lj_ir_mode[ir->o]) == IRM_N && + op1 == ir->op1 && op2 == ir->op2) { /* Regular invariant ins? */ + subst[ins] = (IRRef1)ins; /* Shortcut. */ + } else { + /* Re-emit substituted instruction to the FOLD/CSE/etc. pipeline. */ + IRType1 t = ir->t; /* Get this first, since emitir may invalidate ir. */ + IRRef ref = tref_ref(emitir(ir->ot & ~IRT_ISPHI, op1, op2)); + subst[ins] = (IRRef1)ref; + if (ref != ins) { + IRIns *irr = IR(ref); + if (ref < invar) { /* Loop-carried dependency? */ + /* Potential PHI? */ + if (!irref_isk(ref) && !irt_isphi(irr->t) && !irt_ispri(irr->t)) { + irt_setphi(irr->t); + if (nphi >= LJ_MAX_PHI) + lj_trace_err(J, LJ_TRERR_PHIOV); + phi[nphi++] = (IRRef1)ref; + } + /* Check all loop-carried dependencies for type instability. */ + if (!irt_sametype(t, irr->t)) { + if (irt_isinteger(t) && irt_isinteger(irr->t)) + continue; + else if (irt_isnum(t) && irt_isinteger(irr->t)) /* Fix int->num. */ + ref = tref_ref(emitir(IRTN(IR_CONV), ref, IRCONV_NUM_INT)); + else if (irt_isnum(irr->t) && irt_isinteger(t)) /* Fix num->int. */ + ref = tref_ref(emitir(IRTGI(IR_CONV), ref, + IRCONV_INT_NUM|IRCONV_CHECK)); + else + lj_trace_err(J, LJ_TRERR_TYPEINS); + subst[ins] = (IRRef1)ref; + irr = IR(ref); + goto phiconv; + } + } else if (ref != REF_DROP && irr->o == IR_CONV && + ref > invar && irr->op1 < invar) { + /* May need an extra PHI for a CONV. */ + ref = irr->op1; + irr = IR(ref); + phiconv: + if (ref < invar && !irref_isk(ref) && !irt_isphi(irr->t)) { + irt_setphi(irr->t); + if (nphi >= LJ_MAX_PHI) + lj_trace_err(J, LJ_TRERR_PHIOV); + phi[nphi++] = (IRRef1)ref; + } + } + } + } + } + if (!irt_isguard(J->guardemit)) /* Drop redundant snapshot. */ + J->cur.nsnapmap = (uint16_t)J->cur.snap[--J->cur.nsnap].mapofs; + lua_assert(J->cur.nsnapmap <= J->sizesnapmap); + *psentinel = J->cur.snapmap[J->cur.snap[0].nent]; /* Restore PC. */ + + loop_emit_phi(J, subst, phi, nphi, onsnap); +} + +/* Undo any partial changes made by the loop optimization. */ +static void loop_undo(jit_State *J, IRRef ins, SnapNo nsnap, MSize nsnapmap) +{ + ptrdiff_t i; + SnapShot *snap = &J->cur.snap[nsnap-1]; + SnapEntry *map = J->cur.snapmap; + map[snap->mapofs + snap->nent] = map[J->cur.snap[0].nent]; /* Restore PC. */ + J->cur.nsnapmap = (uint16_t)nsnapmap; + J->cur.nsnap = nsnap; + J->guardemit.irt = 0; + lj_ir_rollback(J, ins); + for (i = 0; i < BPROP_SLOTS; i++) { /* Remove backprop. cache entries. */ + BPropEntry *bp = &J->bpropcache[i]; + if (bp->val >= ins) + bp->key = 0; + } + for (ins--; ins >= REF_FIRST; ins--) { /* Remove flags. */ + IRIns *ir = IR(ins); + irt_clearphi(ir->t); + irt_clearmark(ir->t); + } +} + +/* Protected callback for loop optimization. */ +static TValue *cploop_opt(lua_State *L, lua_CFunction dummy, void *ud) +{ + UNUSED(L); UNUSED(dummy); + loop_unroll((jit_State *)ud); + return NULL; +} + +/* Loop optimization. */ +int lj_opt_loop(jit_State *J) +{ + IRRef nins = J->cur.nins; + SnapNo nsnap = J->cur.nsnap; + MSize nsnapmap = J->cur.nsnapmap; + int errcode = lj_vm_cpcall(J->L, NULL, J, cploop_opt); + if (LJ_UNLIKELY(errcode)) { + lua_State *L = J->L; + if (errcode == LUA_ERRRUN && tvisnumber(L->top-1)) { /* Trace error? */ + int32_t e = numberVint(L->top-1); + switch ((TraceError)e) { + case LJ_TRERR_TYPEINS: /* Type instability. */ + case LJ_TRERR_GFAIL: /* Guard would always fail. */ + /* Unrolling via recording fixes many cases, e.g. a flipped boolean. */ + if (--J->instunroll < 0) /* But do not unroll forever. */ + break; + L->top--; /* Remove error object. */ + loop_undo(J, nins, nsnap, nsnapmap); + return 1; /* Loop optimization failed, continue recording. */ + default: + break; + } + } + lj_err_throw(L, errcode); /* Propagate all other errors. */ + } + return 0; /* Loop optimization is ok. */ +} + +#undef IR +#undef emitir +#undef emitir_raw + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_mem.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_mem.c new file mode 100644 index 000000000..a4d96fc0f --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_mem.c @@ -0,0 +1,916 @@ +/* +** Memory access optimizations. +** AA: Alias Analysis using high-level semantic disambiguation. +** FWD: Load Forwarding (L2L) + Store Forwarding (S2L). +** DSE: Dead-Store Elimination. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_opt_mem_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_tab.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_iropt.h" + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) +#define fins (&J->fold.ins) +#define fleft (&J->fold.left) +#define fright (&J->fold.right) + +/* +** Caveat #1: return value is not always a TRef -- only use with tref_ref(). +** Caveat #2: FWD relies on active CSE for xREF operands -- see lj_opt_fold(). +*/ + +/* Return values from alias analysis. */ +typedef enum { + ALIAS_NO, /* The two refs CANNOT alias (exact). */ + ALIAS_MAY, /* The two refs MAY alias (inexact). */ + ALIAS_MUST /* The two refs MUST alias (exact). */ +} AliasRet; + +/* -- ALOAD/HLOAD forwarding and ASTORE/HSTORE elimination ---------------- */ + +/* Simplified escape analysis: check for intervening stores. */ +static AliasRet aa_escape(jit_State *J, IRIns *ir, IRIns *stop) +{ + IRRef ref = (IRRef)(ir - J->cur.ir); /* The ref that might be stored. */ + for (ir++; ir < stop; ir++) + if (ir->op2 == ref && + (ir->o == IR_ASTORE || ir->o == IR_HSTORE || + ir->o == IR_USTORE || ir->o == IR_FSTORE)) + return ALIAS_MAY; /* Reference was stored and might alias. */ + return ALIAS_NO; /* Reference was not stored. */ +} + +/* Alias analysis for two different table references. */ +static AliasRet aa_table(jit_State *J, IRRef ta, IRRef tb) +{ + IRIns *taba = IR(ta), *tabb = IR(tb); + int newa, newb; + lua_assert(ta != tb); + lua_assert(irt_istab(taba->t) && irt_istab(tabb->t)); + /* Disambiguate new allocations. */ + newa = (taba->o == IR_TNEW || taba->o == IR_TDUP); + newb = (tabb->o == IR_TNEW || tabb->o == IR_TDUP); + if (newa && newb) + return ALIAS_NO; /* Two different allocations never alias. */ + if (newb) { /* At least one allocation? */ + IRIns *tmp = taba; taba = tabb; tabb = tmp; + } else if (!newa) { + return ALIAS_MAY; /* Anything else: we just don't know. */ + } + return aa_escape(J, taba, tabb); +} + +/* Alias analysis for array and hash access using key-based disambiguation. */ +static AliasRet aa_ahref(jit_State *J, IRIns *refa, IRIns *refb) +{ + IRRef ka = refa->op2; + IRRef kb = refb->op2; + IRIns *keya, *keyb; + IRRef ta, tb; + if (refa == refb) + return ALIAS_MUST; /* Shortcut for same refs. */ + keya = IR(ka); + if (keya->o == IR_KSLOT) { ka = keya->op1; keya = IR(ka); } + keyb = IR(kb); + if (keyb->o == IR_KSLOT) { kb = keyb->op1; keyb = IR(kb); } + ta = (refa->o==IR_HREFK || refa->o==IR_AREF) ? IR(refa->op1)->op1 : refa->op1; + tb = (refb->o==IR_HREFK || refb->o==IR_AREF) ? IR(refb->op1)->op1 : refb->op1; + if (ka == kb) { + /* Same key. Check for same table with different ref (NEWREF vs. HREF). */ + if (ta == tb) + return ALIAS_MUST; /* Same key, same table. */ + else + return aa_table(J, ta, tb); /* Same key, possibly different table. */ + } + if (irref_isk(ka) && irref_isk(kb)) + return ALIAS_NO; /* Different constant keys. */ + if (refa->o == IR_AREF) { + /* Disambiguate array references based on index arithmetic. */ + int32_t ofsa = 0, ofsb = 0; + IRRef basea = ka, baseb = kb; + lua_assert(refb->o == IR_AREF); + /* Gather base and offset from t[base] or t[base+-ofs]. */ + if (keya->o == IR_ADD && irref_isk(keya->op2)) { + basea = keya->op1; + ofsa = IR(keya->op2)->i; + if (basea == kb && ofsa != 0) + return ALIAS_NO; /* t[base+-ofs] vs. t[base]. */ + } + if (keyb->o == IR_ADD && irref_isk(keyb->op2)) { + baseb = keyb->op1; + ofsb = IR(keyb->op2)->i; + if (ka == baseb && ofsb != 0) + return ALIAS_NO; /* t[base] vs. t[base+-ofs]. */ + } + if (basea == baseb && ofsa != ofsb) + return ALIAS_NO; /* t[base+-o1] vs. t[base+-o2] and o1 != o2. */ + } else { + /* Disambiguate hash references based on the type of their keys. */ + lua_assert((refa->o==IR_HREF || refa->o==IR_HREFK || refa->o==IR_NEWREF) && + (refb->o==IR_HREF || refb->o==IR_HREFK || refb->o==IR_NEWREF)); + if (!irt_sametype(keya->t, keyb->t)) + return ALIAS_NO; /* Different key types. */ + } + if (ta == tb) + return ALIAS_MAY; /* Same table, cannot disambiguate keys. */ + else + return aa_table(J, ta, tb); /* Try to disambiguate tables. */ +} + +/* Array and hash load forwarding. */ +static TRef fwd_ahload(jit_State *J, IRRef xref) +{ + IRIns *xr = IR(xref); + IRRef lim = xref; /* Search limit. */ + IRRef ref; + + /* Search for conflicting stores. */ + ref = J->chain[fins->o+IRDELTA_L2S]; + while (ref > xref) { + IRIns *store = IR(ref); + switch (aa_ahref(J, xr, IR(store->op1))) { + case ALIAS_NO: break; /* Continue searching. */ + case ALIAS_MAY: lim = ref; goto cselim; /* Limit search for load. */ + case ALIAS_MUST: return store->op2; /* Store forwarding. */ + } + ref = store->prev; + } + + /* No conflicting store (yet): const-fold loads from allocations. */ + { + IRIns *ir = (xr->o == IR_HREFK || xr->o == IR_AREF) ? IR(xr->op1) : xr; + IRRef tab = ir->op1; + ir = IR(tab); + if (ir->o == IR_TNEW || (ir->o == IR_TDUP && irref_isk(xr->op2))) { + /* A NEWREF with a number key may end up pointing to the array part. + ** But it's referenced from HSTORE and not found in the ASTORE chain. + ** For now simply consider this a conflict without forwarding anything. + */ + if (xr->o == IR_AREF) { + IRRef ref2 = J->chain[IR_NEWREF]; + while (ref2 > tab) { + IRIns *newref = IR(ref2); + if (irt_isnum(IR(newref->op2)->t)) + goto cselim; + ref2 = newref->prev; + } + } + /* NEWREF inhibits CSE for HREF, and dependent FLOADs from HREFK/AREF. + ** But the above search for conflicting stores was limited by xref. + ** So continue searching, limited by the TNEW/TDUP. Store forwarding + ** is ok, too. A conflict does NOT limit the search for a matching load. + */ + while (ref > tab) { + IRIns *store = IR(ref); + switch (aa_ahref(J, xr, IR(store->op1))) { + case ALIAS_NO: break; /* Continue searching. */ + case ALIAS_MAY: goto cselim; /* Conflicting store. */ + case ALIAS_MUST: return store->op2; /* Store forwarding. */ + } + ref = store->prev; + } + lua_assert(ir->o != IR_TNEW || irt_isnil(fins->t)); + if (irt_ispri(fins->t)) { + return TREF_PRI(irt_type(fins->t)); + } else if (irt_isnum(fins->t) || (LJ_DUALNUM && irt_isint(fins->t)) || + irt_isstr(fins->t)) { + TValue keyv; + cTValue *tv; + IRIns *key = IR(xr->op2); + if (key->o == IR_KSLOT) key = IR(key->op1); + lj_ir_kvalue(J->L, &keyv, key); + tv = lj_tab_get(J->L, ir_ktab(IR(ir->op1)), &keyv); + lua_assert(itype2irt(tv) == irt_type(fins->t)); + if (irt_isnum(fins->t)) + return lj_ir_knum_u64(J, tv->u64); + else if (LJ_DUALNUM && irt_isint(fins->t)) + return lj_ir_kint(J, intV(tv)); + else + return lj_ir_kstr(J, strV(tv)); + } + /* Othwerwise: don't intern as a constant. */ + } + } + +cselim: + /* Try to find a matching load. Below the conflicting store, if any. */ + ref = J->chain[fins->o]; + while (ref > lim) { + IRIns *load = IR(ref); + if (load->op1 == xref) + return ref; /* Load forwarding. */ + ref = load->prev; + } + return 0; /* Conflict or no match. */ +} + +/* Reassociate ALOAD across PHIs to handle t[i-1] forwarding case. */ +static TRef fwd_aload_reassoc(jit_State *J) +{ + IRIns *irx = IR(fins->op1); + IRIns *key = IR(irx->op2); + if (key->o == IR_ADD && irref_isk(key->op2)) { + IRIns *add2 = IR(key->op1); + if (add2->o == IR_ADD && irref_isk(add2->op2) && + IR(key->op2)->i == -IR(add2->op2)->i) { + IRRef ref = J->chain[IR_AREF]; + IRRef lim = add2->op1; + if (irx->op1 > lim) lim = irx->op1; + while (ref > lim) { + IRIns *ir = IR(ref); + if (ir->op1 == irx->op1 && ir->op2 == add2->op1) + return fwd_ahload(J, ref); + ref = ir->prev; + } + } + } + return 0; +} + +/* ALOAD forwarding. */ +TRef LJ_FASTCALL lj_opt_fwd_aload(jit_State *J) +{ + IRRef ref; + if ((ref = fwd_ahload(J, fins->op1)) || + (ref = fwd_aload_reassoc(J))) + return ref; + return EMITFOLD; +} + +/* HLOAD forwarding. */ +TRef LJ_FASTCALL lj_opt_fwd_hload(jit_State *J) +{ + IRRef ref = fwd_ahload(J, fins->op1); + if (ref) + return ref; + return EMITFOLD; +} + +/* HREFK forwarding. */ +TRef LJ_FASTCALL lj_opt_fwd_hrefk(jit_State *J) +{ + IRRef tab = fleft->op1; + IRRef ref = J->chain[IR_NEWREF]; + while (ref > tab) { + IRIns *newref = IR(ref); + if (tab == newref->op1) { + if (fright->op1 == newref->op2) + return ref; /* Forward from NEWREF. */ + else + goto docse; + } else if (aa_table(J, tab, newref->op1) != ALIAS_NO) { + goto docse; + } + ref = newref->prev; + } + /* No conflicting NEWREF: key location unchanged for HREFK of TDUP. */ + if (IR(tab)->o == IR_TDUP) + fins->t.irt &= ~IRT_GUARD; /* Drop HREFK guard. */ +docse: + return CSEFOLD; +} + +/* Check whether HREF of TNEW/TDUP can be folded to niltv. */ +int LJ_FASTCALL lj_opt_fwd_href_nokey(jit_State *J) +{ + IRRef lim = fins->op1; /* Search limit. */ + IRRef ref; + + /* The key for an ASTORE may end up in the hash part after a NEWREF. */ + if (irt_isnum(fright->t) && J->chain[IR_NEWREF] > lim) { + ref = J->chain[IR_ASTORE]; + while (ref > lim) { + if (ref < J->chain[IR_NEWREF]) + return 0; /* Conflict. */ + ref = IR(ref)->prev; + } + } + + /* Search for conflicting stores. */ + ref = J->chain[IR_HSTORE]; + while (ref > lim) { + IRIns *store = IR(ref); + if (aa_ahref(J, fins, IR(store->op1)) != ALIAS_NO) + return 0; /* Conflict. */ + ref = store->prev; + } + + return 1; /* No conflict. Can fold to niltv. */ +} + +/* Check whether there's no aliasing NEWREF for the left operand. */ +int LJ_FASTCALL lj_opt_fwd_tptr(jit_State *J, IRRef lim) +{ + IRRef ta = fins->op1; + IRRef ref = J->chain[IR_NEWREF]; + while (ref > lim) { + IRIns *newref = IR(ref); + if (ta == newref->op1 || aa_table(J, ta, newref->op1) != ALIAS_NO) + return 0; /* Conflict. */ + ref = newref->prev; + } + return 1; /* No conflict. Can safely FOLD/CSE. */ +} + +/* ASTORE/HSTORE elimination. */ +TRef LJ_FASTCALL lj_opt_dse_ahstore(jit_State *J) +{ + IRRef xref = fins->op1; /* xREF reference. */ + IRRef val = fins->op2; /* Stored value reference. */ + IRIns *xr = IR(xref); + IRRef1 *refp = &J->chain[fins->o]; + IRRef ref = *refp; + while (ref > xref) { /* Search for redundant or conflicting stores. */ + IRIns *store = IR(ref); + switch (aa_ahref(J, xr, IR(store->op1))) { + case ALIAS_NO: + break; /* Continue searching. */ + case ALIAS_MAY: /* Store to MAYBE the same location. */ + if (store->op2 != val) /* Conflict if the value is different. */ + goto doemit; + break; /* Otherwise continue searching. */ + case ALIAS_MUST: /* Store to the same location. */ + if (store->op2 == val) /* Same value: drop the new store. */ + return DROPFOLD; + /* Different value: try to eliminate the redundant store. */ + if (ref > J->chain[IR_LOOP]) { /* Quick check to avoid crossing LOOP. */ + IRIns *ir; + /* Check for any intervening guards (includes conflicting loads). */ + for (ir = IR(J->cur.nins-1); ir > store; ir--) + if (irt_isguard(ir->t) || ir->o == IR_CALLL) + goto doemit; /* No elimination possible. */ + /* Remove redundant store from chain and replace with NOP. */ + *refp = store->prev; + store->o = IR_NOP; + store->t.irt = IRT_NIL; + store->op1 = store->op2 = 0; + store->prev = 0; + /* Now emit the new store instead. */ + } + goto doemit; + } + ref = *(refp = &store->prev); + } +doemit: + return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ +} + +/* -- ULOAD forwarding ---------------------------------------------------- */ + +/* The current alias analysis for upvalues is very simplistic. It only +** disambiguates between the unique upvalues of the same function. +** This is good enough for now, since most upvalues are read-only. +** +** A more precise analysis would be feasible with the help of the parser: +** generate a unique key for every upvalue, even across all prototypes. +** Lacking a realistic use-case, it's unclear whether this is beneficial. +*/ +static AliasRet aa_uref(IRIns *refa, IRIns *refb) +{ + if (refa->o != refb->o) + return ALIAS_NO; /* Different UREFx type. */ + if (refa->op1 == refb->op1) { /* Same function. */ + if (refa->op2 == refb->op2) + return ALIAS_MUST; /* Same function, same upvalue idx. */ + else + return ALIAS_NO; /* Same function, different upvalue idx. */ + } else { /* Different functions, check disambiguation hash values. */ + if (((refa->op2 ^ refb->op2) & 0xff)) + return ALIAS_NO; /* Upvalues with different hash values cannot alias. */ + else + return ALIAS_MAY; /* No conclusion can be drawn for same hash value. */ + } +} + +/* ULOAD forwarding. */ +TRef LJ_FASTCALL lj_opt_fwd_uload(jit_State *J) +{ + IRRef uref = fins->op1; + IRRef lim = REF_BASE; /* Search limit. */ + IRIns *xr = IR(uref); + IRRef ref; + + /* Search for conflicting stores. */ + ref = J->chain[IR_USTORE]; + while (ref > lim) { + IRIns *store = IR(ref); + switch (aa_uref(xr, IR(store->op1))) { + case ALIAS_NO: break; /* Continue searching. */ + case ALIAS_MAY: lim = ref; goto cselim; /* Limit search for load. */ + case ALIAS_MUST: return store->op2; /* Store forwarding. */ + } + ref = store->prev; + } + +cselim: + /* Try to find a matching load. Below the conflicting store, if any. */ + + ref = J->chain[IR_ULOAD]; + while (ref > lim) { + IRIns *ir = IR(ref); + if (ir->op1 == uref || + (IR(ir->op1)->op12 == IR(uref)->op12 && IR(ir->op1)->o == IR(uref)->o)) + return ref; /* Match for identical or equal UREFx (non-CSEable UREFO). */ + ref = ir->prev; + } + return lj_ir_emit(J); +} + +/* USTORE elimination. */ +TRef LJ_FASTCALL lj_opt_dse_ustore(jit_State *J) +{ + IRRef xref = fins->op1; /* xREF reference. */ + IRRef val = fins->op2; /* Stored value reference. */ + IRIns *xr = IR(xref); + IRRef1 *refp = &J->chain[IR_USTORE]; + IRRef ref = *refp; + while (ref > xref) { /* Search for redundant or conflicting stores. */ + IRIns *store = IR(ref); + switch (aa_uref(xr, IR(store->op1))) { + case ALIAS_NO: + break; /* Continue searching. */ + case ALIAS_MAY: /* Store to MAYBE the same location. */ + if (store->op2 != val) /* Conflict if the value is different. */ + goto doemit; + break; /* Otherwise continue searching. */ + case ALIAS_MUST: /* Store to the same location. */ + if (store->op2 == val) /* Same value: drop the new store. */ + return DROPFOLD; + /* Different value: try to eliminate the redundant store. */ + if (ref > J->chain[IR_LOOP]) { /* Quick check to avoid crossing LOOP. */ + IRIns *ir; + /* Check for any intervening guards (includes conflicting loads). */ + for (ir = IR(J->cur.nins-1); ir > store; ir--) + if (irt_isguard(ir->t)) + goto doemit; /* No elimination possible. */ + /* Remove redundant store from chain and replace with NOP. */ + *refp = store->prev; + store->o = IR_NOP; + store->t.irt = IRT_NIL; + store->op1 = store->op2 = 0; + store->prev = 0; + if (ref+1 < J->cur.nins && + store[1].o == IR_OBAR && store[1].op1 == xref) { + IRRef1 *bp = &J->chain[IR_OBAR]; + IRIns *obar; + for (obar = IR(*bp); *bp > ref+1; obar = IR(*bp)) + bp = &obar->prev; + /* Remove OBAR, too. */ + *bp = obar->prev; + obar->o = IR_NOP; + obar->t.irt = IRT_NIL; + obar->op1 = obar->op2 = 0; + obar->prev = 0; + } + /* Now emit the new store instead. */ + } + goto doemit; + } + ref = *(refp = &store->prev); + } +doemit: + return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ +} + +/* -- FLOAD forwarding and FSTORE elimination ----------------------------- */ + +/* Alias analysis for field access. +** Field loads are cheap and field stores are rare. +** Simple disambiguation based on field types is good enough. +*/ +static AliasRet aa_fref(jit_State *J, IRIns *refa, IRIns *refb) +{ + if (refa->op2 != refb->op2) + return ALIAS_NO; /* Different fields. */ + if (refa->op1 == refb->op1) + return ALIAS_MUST; /* Same field, same object. */ + else if (refa->op2 >= IRFL_TAB_META && refa->op2 <= IRFL_TAB_NOMM) + return aa_table(J, refa->op1, refb->op1); /* Disambiguate tables. */ + else + return ALIAS_MAY; /* Same field, possibly different object. */ +} + +/* Only the loads for mutable fields end up here (see FOLD). */ +TRef LJ_FASTCALL lj_opt_fwd_fload(jit_State *J) +{ + IRRef oref = fins->op1; /* Object reference. */ + IRRef fid = fins->op2; /* Field ID. */ + IRRef lim = oref; /* Search limit. */ + IRRef ref; + + /* Search for conflicting stores. */ + ref = J->chain[IR_FSTORE]; + while (ref > oref) { + IRIns *store = IR(ref); + switch (aa_fref(J, fins, IR(store->op1))) { + case ALIAS_NO: break; /* Continue searching. */ + case ALIAS_MAY: lim = ref; goto cselim; /* Limit search for load. */ + case ALIAS_MUST: return store->op2; /* Store forwarding. */ + } + ref = store->prev; + } + + /* No conflicting store: const-fold field loads from allocations. */ + if (fid == IRFL_TAB_META) { + IRIns *ir = IR(oref); + if (ir->o == IR_TNEW || ir->o == IR_TDUP) + return lj_ir_knull(J, IRT_TAB); + } + +cselim: + /* Try to find a matching load. Below the conflicting store, if any. */ + return lj_opt_cselim(J, lim); +} + +/* FSTORE elimination. */ +TRef LJ_FASTCALL lj_opt_dse_fstore(jit_State *J) +{ + IRRef fref = fins->op1; /* FREF reference. */ + IRRef val = fins->op2; /* Stored value reference. */ + IRIns *xr = IR(fref); + IRRef1 *refp = &J->chain[IR_FSTORE]; + IRRef ref = *refp; + while (ref > fref) { /* Search for redundant or conflicting stores. */ + IRIns *store = IR(ref); + switch (aa_fref(J, xr, IR(store->op1))) { + case ALIAS_NO: + break; /* Continue searching. */ + case ALIAS_MAY: + if (store->op2 != val) /* Conflict if the value is different. */ + goto doemit; + break; /* Otherwise continue searching. */ + case ALIAS_MUST: + if (store->op2 == val) /* Same value: drop the new store. */ + return DROPFOLD; + /* Different value: try to eliminate the redundant store. */ + if (ref > J->chain[IR_LOOP]) { /* Quick check to avoid crossing LOOP. */ + IRIns *ir; + /* Check for any intervening guards or conflicting loads. */ + for (ir = IR(J->cur.nins-1); ir > store; ir--) + if (irt_isguard(ir->t) || (ir->o == IR_FLOAD && ir->op2 == xr->op2)) + goto doemit; /* No elimination possible. */ + /* Remove redundant store from chain and replace with NOP. */ + *refp = store->prev; + store->o = IR_NOP; + store->t.irt = IRT_NIL; + store->op1 = store->op2 = 0; + store->prev = 0; + /* Now emit the new store instead. */ + } + goto doemit; + } + ref = *(refp = &store->prev); + } +doemit: + return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ +} + +/* -- XLOAD forwarding and XSTORE elimination ----------------------------- */ + +/* Find cdata allocation for a reference (if any). */ +static IRIns *aa_findcnew(jit_State *J, IRIns *ir) +{ + while (ir->o == IR_ADD) { + if (!irref_isk(ir->op1)) { + IRIns *ir1 = aa_findcnew(J, IR(ir->op1)); /* Left-recursion. */ + if (ir1) return ir1; + } + if (irref_isk(ir->op2)) return NULL; + ir = IR(ir->op2); /* Flatten right-recursion. */ + } + return ir->o == IR_CNEW ? ir : NULL; +} + +/* Alias analysis for two cdata allocations. */ +static AliasRet aa_cnew(jit_State *J, IRIns *refa, IRIns *refb) +{ + IRIns *cnewa = aa_findcnew(J, refa); + IRIns *cnewb = aa_findcnew(J, refb); + if (cnewa == cnewb) + return ALIAS_MAY; /* Same allocation or neither is an allocation. */ + if (cnewa && cnewb) + return ALIAS_NO; /* Two different allocations never alias. */ + if (cnewb) { cnewa = cnewb; refb = refa; } + return aa_escape(J, cnewa, refb); +} + +/* Alias analysis for XLOAD/XSTORE. */ +static AliasRet aa_xref(jit_State *J, IRIns *refa, IRIns *xa, IRIns *xb) +{ + ptrdiff_t ofsa = 0, ofsb = 0; + IRIns *refb = IR(xb->op1); + IRIns *basea = refa, *baseb = refb; + if (refa == refb && irt_sametype(xa->t, xb->t)) + return ALIAS_MUST; /* Shortcut for same refs with identical type. */ + /* Offset-based disambiguation. */ + if (refa->o == IR_ADD && irref_isk(refa->op2)) { + IRIns *irk = IR(refa->op2); + basea = IR(refa->op1); + ofsa = (LJ_64 && irk->o == IR_KINT64) ? (ptrdiff_t)ir_k64(irk)->u64 : + (ptrdiff_t)irk->i; + } + if (refb->o == IR_ADD && irref_isk(refb->op2)) { + IRIns *irk = IR(refb->op2); + baseb = IR(refb->op1); + ofsb = (LJ_64 && irk->o == IR_KINT64) ? (ptrdiff_t)ir_k64(irk)->u64 : + (ptrdiff_t)irk->i; + } + /* Treat constified pointers like base vs. base+offset. */ + if (basea->o == IR_KPTR && baseb->o == IR_KPTR) { + ofsb += (char *)ir_kptr(baseb) - (char *)ir_kptr(basea); + baseb = basea; + } + /* This implements (very) strict aliasing rules. + ** Different types do NOT alias, except for differences in signedness. + ** Type punning through unions is allowed (but forces a reload). + */ + if (basea == baseb) { + ptrdiff_t sza = irt_size(xa->t), szb = irt_size(xb->t); + if (ofsa == ofsb) { + if (sza == szb && irt_isfp(xa->t) == irt_isfp(xb->t)) + return ALIAS_MUST; /* Same-sized, same-kind. May need to convert. */ + } else if (ofsa + sza <= ofsb || ofsb + szb <= ofsa) { + return ALIAS_NO; /* Non-overlapping base+-o1 vs. base+-o2. */ + } + /* NYI: extract, extend or reinterpret bits (int <-> fp). */ + return ALIAS_MAY; /* Overlapping or type punning: force reload. */ + } + if (!irt_sametype(xa->t, xb->t) && + !(irt_typerange(xa->t, IRT_I8, IRT_U64) && + ((xa->t.irt - IRT_I8) ^ (xb->t.irt - IRT_I8)) == 1)) + return ALIAS_NO; + /* NYI: structural disambiguation. */ + return aa_cnew(J, basea, baseb); /* Try to disambiguate allocations. */ +} + +/* Return CSEd reference or 0. Caveat: swaps lower ref to the right! */ +static IRRef reassoc_trycse(jit_State *J, IROp op, IRRef op1, IRRef op2) +{ + IRRef ref = J->chain[op]; + IRRef lim = op1; + if (op2 > lim) { lim = op2; op2 = op1; op1 = lim; } + while (ref > lim) { + IRIns *ir = IR(ref); + if (ir->op1 == op1 && ir->op2 == op2) + return ref; + ref = ir->prev; + } + return 0; +} + +/* Reassociate index references. */ +static IRRef reassoc_xref(jit_State *J, IRIns *ir) +{ + ptrdiff_t ofs = 0; + if (ir->o == IR_ADD && irref_isk(ir->op2)) { /* Get constant offset. */ + IRIns *irk = IR(ir->op2); + ofs = (LJ_64 && irk->o == IR_KINT64) ? (ptrdiff_t)ir_k64(irk)->u64 : + (ptrdiff_t)irk->i; + ir = IR(ir->op1); + } + if (ir->o == IR_ADD) { /* Add of base + index. */ + /* Index ref > base ref for loop-carried dependences. Only check op1. */ + IRIns *ir2, *ir1 = IR(ir->op1); + int32_t shift = 0; + IRRef idxref; + /* Determine index shifts. Don't bother with IR_MUL here. */ + if (ir1->o == IR_BSHL && irref_isk(ir1->op2)) + shift = IR(ir1->op2)->i; + else if (ir1->o == IR_ADD && ir1->op1 == ir1->op2) + shift = 1; + else + ir1 = ir; + ir2 = IR(ir1->op1); + /* A non-reassociated add. Must be a loop-carried dependence. */ + if (ir2->o == IR_ADD && irt_isint(ir2->t) && irref_isk(ir2->op2)) + ofs += (ptrdiff_t)IR(ir2->op2)->i << shift; + else + return 0; + idxref = ir2->op1; + /* Try to CSE the reassociated chain. Give up if not found. */ + if (ir1 != ir && + !(idxref = reassoc_trycse(J, ir1->o, idxref, + ir1->o == IR_BSHL ? ir1->op2 : idxref))) + return 0; + if (!(idxref = reassoc_trycse(J, IR_ADD, idxref, ir->op2))) + return 0; + if (ofs != 0) { + IRRef refk = tref_ref(lj_ir_kintp(J, ofs)); + if (!(idxref = reassoc_trycse(J, IR_ADD, idxref, refk))) + return 0; + } + return idxref; /* Success, found a reassociated index reference. Phew. */ + } + return 0; /* Failure. */ +} + +/* XLOAD forwarding. */ +TRef LJ_FASTCALL lj_opt_fwd_xload(jit_State *J) +{ + IRRef xref = fins->op1; + IRIns *xr = IR(xref); + IRRef lim = xref; /* Search limit. */ + IRRef ref; + + if ((fins->op2 & IRXLOAD_READONLY)) + goto cselim; + if ((fins->op2 & IRXLOAD_VOLATILE)) + goto doemit; + + /* Search for conflicting stores. */ + ref = J->chain[IR_XSTORE]; +retry: + if (J->chain[IR_CALLXS] > lim) lim = J->chain[IR_CALLXS]; + if (J->chain[IR_XBAR] > lim) lim = J->chain[IR_XBAR]; + while (ref > lim) { + IRIns *store = IR(ref); + switch (aa_xref(J, xr, fins, store)) { + case ALIAS_NO: break; /* Continue searching. */ + case ALIAS_MAY: lim = ref; goto cselim; /* Limit search for load. */ + case ALIAS_MUST: + /* Emit conversion if the loaded type doesn't match the forwarded type. */ + if (!irt_sametype(fins->t, IR(store->op2)->t)) { + IRType dt = irt_type(fins->t), st = irt_type(IR(store->op2)->t); + if (dt == IRT_I8 || dt == IRT_I16) { /* Trunc + sign-extend. */ + st = dt | IRCONV_SEXT; + dt = IRT_INT; + } else if (dt == IRT_U8 || dt == IRT_U16) { /* Trunc + zero-extend. */ + st = dt; + dt = IRT_INT; + } + fins->ot = IRT(IR_CONV, dt); + fins->op1 = store->op2; + fins->op2 = (dt<<5)|st; + return RETRYFOLD; + } + return store->op2; /* Store forwarding. */ + } + ref = store->prev; + } + +cselim: + /* Try to find a matching load. Below the conflicting store, if any. */ + ref = J->chain[IR_XLOAD]; + while (ref > lim) { + /* CSE for XLOAD depends on the type, but not on the IRXLOAD_* flags. */ + if (IR(ref)->op1 == xref && irt_sametype(IR(ref)->t, fins->t)) + return ref; + ref = IR(ref)->prev; + } + + /* Reassociate XLOAD across PHIs to handle a[i-1] forwarding case. */ + if (!(fins->op2 & IRXLOAD_READONLY) && J->chain[IR_LOOP] && + xref == fins->op1 && (xref = reassoc_xref(J, xr)) != 0) { + ref = J->chain[IR_XSTORE]; + while (ref > lim) /* Skip stores that have already been checked. */ + ref = IR(ref)->prev; + lim = xref; + xr = IR(xref); + goto retry; /* Retry with the reassociated reference. */ + } +doemit: + return EMITFOLD; +} + +/* XSTORE elimination. */ +TRef LJ_FASTCALL lj_opt_dse_xstore(jit_State *J) +{ + IRRef xref = fins->op1; + IRIns *xr = IR(xref); + IRRef lim = xref; /* Search limit. */ + IRRef val = fins->op2; /* Stored value reference. */ + IRRef1 *refp = &J->chain[IR_XSTORE]; + IRRef ref = *refp; + if (J->chain[IR_CALLXS] > lim) lim = J->chain[IR_CALLXS]; + if (J->chain[IR_XBAR] > lim) lim = J->chain[IR_XBAR]; + if (J->chain[IR_XSNEW] > lim) lim = J->chain[IR_XSNEW]; + while (ref > lim) { /* Search for redundant or conflicting stores. */ + IRIns *store = IR(ref); + switch (aa_xref(J, xr, fins, store)) { + case ALIAS_NO: + break; /* Continue searching. */ + case ALIAS_MAY: + if (store->op2 != val) /* Conflict if the value is different. */ + goto doemit; + break; /* Otherwise continue searching. */ + case ALIAS_MUST: + if (store->op2 == val) /* Same value: drop the new store. */ + return DROPFOLD; + /* Different value: try to eliminate the redundant store. */ + if (ref > J->chain[IR_LOOP]) { /* Quick check to avoid crossing LOOP. */ + IRIns *ir; + /* Check for any intervening guards or any XLOADs (no AA performed). */ + for (ir = IR(J->cur.nins-1); ir > store; ir--) + if (irt_isguard(ir->t) || ir->o == IR_XLOAD) + goto doemit; /* No elimination possible. */ + /* Remove redundant store from chain and replace with NOP. */ + *refp = store->prev; + store->o = IR_NOP; + store->t.irt = IRT_NIL; + store->op1 = store->op2 = 0; + store->prev = 0; + /* Now emit the new store instead. */ + } + goto doemit; + } + ref = *(refp = &store->prev); + } +doemit: + return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ +} + +/* -- Forwarding of lj_tab_len -------------------------------------------- */ + +/* This is rather simplistic right now, but better than nothing. */ +TRef LJ_FASTCALL lj_opt_fwd_tab_len(jit_State *J) +{ + IRRef tab = fins->op1; /* Table reference. */ + IRRef lim = tab; /* Search limit. */ + IRRef ref; + + /* Any ASTORE is a conflict and limits the search. */ + if (J->chain[IR_ASTORE] > lim) lim = J->chain[IR_ASTORE]; + + /* Search for conflicting HSTORE with numeric key. */ + ref = J->chain[IR_HSTORE]; + while (ref > lim) { + IRIns *store = IR(ref); + IRIns *href = IR(store->op1); + IRIns *key = IR(href->op2); + if (irt_isnum(key->o == IR_KSLOT ? IR(key->op1)->t : key->t)) { + lim = ref; /* Conflicting store found, limits search for TLEN. */ + break; + } + ref = store->prev; + } + + /* Try to find a matching load. Below the conflicting store, if any. */ + return lj_opt_cselim(J, lim); +} + +/* -- ASTORE/HSTORE previous type analysis -------------------------------- */ + +/* Check whether the previous value for a table store is non-nil. +** This can be derived either from a previous store or from a previous +** load (because all loads from tables perform a type check). +** +** The result of the analysis can be used to avoid the metatable check +** and the guard against HREF returning niltv. Both of these are cheap, +** so let's not spend too much effort on the analysis. +** +** A result of 1 is exact: previous value CANNOT be nil. +** A result of 0 is inexact: previous value MAY be nil. +*/ +int lj_opt_fwd_wasnonnil(jit_State *J, IROpT loadop, IRRef xref) +{ + /* First check stores. */ + IRRef ref = J->chain[loadop+IRDELTA_L2S]; + while (ref > xref) { + IRIns *store = IR(ref); + if (store->op1 == xref) { /* Same xREF. */ + /* A nil store MAY alias, but a non-nil store MUST alias. */ + return !irt_isnil(store->t); + } else if (irt_isnil(store->t)) { /* Must check any nil store. */ + IRRef skref = IR(store->op1)->op2; + IRRef xkref = IR(xref)->op2; + /* Same key type MAY alias. Need ALOAD check due to multiple int types. */ + if (loadop == IR_ALOAD || irt_sametype(IR(skref)->t, IR(xkref)->t)) { + if (skref == xkref || !irref_isk(skref) || !irref_isk(xkref)) + return 0; /* A nil store with same const key or var key MAY alias. */ + /* Different const keys CANNOT alias. */ + } /* Different key types CANNOT alias. */ + } /* Other non-nil stores MAY alias. */ + ref = store->prev; + } + + /* Check loads since nothing could be derived from stores. */ + ref = J->chain[loadop]; + while (ref > xref) { + IRIns *load = IR(ref); + if (load->op1 == xref) { /* Same xREF. */ + /* A nil load MAY alias, but a non-nil load MUST alias. */ + return !irt_isnil(load->t); + } /* Other non-nil loads MAY alias. */ + ref = load->prev; + } + return 0; /* Nothing derived at all, previous value MAY be nil. */ +} + +/* ------------------------------------------------------------------------ */ + +#undef IR +#undef fins +#undef fleft +#undef fright + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_narrow.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_narrow.c new file mode 100644 index 000000000..58b3763db --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_narrow.c @@ -0,0 +1,656 @@ +/* +** NARROW: Narrowing of numbers to integers (double to int32_t). +** STRIPOV: Stripping of overflow checks. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_opt_narrow_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_bc.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_iropt.h" +#include "lj_trace.h" +#include "lj_vm.h" +#include "lj_strscan.h" + +/* Rationale for narrowing optimizations: +** +** Lua has only a single number type and this is a FP double by default. +** Narrowing doubles to integers does not pay off for the interpreter on a +** current-generation x86/x64 machine. Most FP operations need the same +** amount of execution resources as their integer counterparts, except +** with slightly longer latencies. Longer latencies are a non-issue for +** the interpreter, since they are usually hidden by other overhead. +** +** The total CPU execution bandwidth is the sum of the bandwidth of the FP +** and the integer units, because they execute in parallel. The FP units +** have an equal or higher bandwidth than the integer units. Not using +** them means losing execution bandwidth. Moving work away from them to +** the already quite busy integer units is a losing proposition. +** +** The situation for JIT-compiled code is a bit different: the higher code +** density makes the extra latencies much more visible. Tight loops expose +** the latencies for updating the induction variables. Array indexing +** requires narrowing conversions with high latencies and additional +** guards (to check that the index is really an integer). And many common +** optimizations only work on integers. +** +** One solution would be speculative, eager narrowing of all number loads. +** This causes many problems, like losing -0 or the need to resolve type +** mismatches between traces. It also effectively forces the integer type +** to have overflow-checking semantics. This impedes many basic +** optimizations and requires adding overflow checks to all integer +** arithmetic operations (whereas FP arithmetics can do without). +** +** Always replacing an FP op with an integer op plus an overflow check is +** counter-productive on a current-generation super-scalar CPU. Although +** the overflow check branches are highly predictable, they will clog the +** execution port for the branch unit and tie up reorder buffers. This is +** turning a pure data-flow dependency into a different data-flow +** dependency (with slightly lower latency) *plus* a control dependency. +** In general, you don't want to do this since latencies due to data-flow +** dependencies can be well hidden by out-of-order execution. +** +** A better solution is to keep all numbers as FP values and only narrow +** when it's beneficial to do so. LuaJIT uses predictive narrowing for +** induction variables and demand-driven narrowing for index expressions, +** integer arguments and bit operations. Additionally it can eliminate or +** hoist most of the resulting overflow checks. Regular arithmetic +** computations are never narrowed to integers. +** +** The integer type in the IR has convenient wrap-around semantics and +** ignores overflow. Extra operations have been added for +** overflow-checking arithmetic (ADDOV/SUBOV) instead of an extra type. +** Apart from reducing overall complexity of the compiler, this also +** nicely solves the problem where you want to apply algebraic +** simplifications to ADD, but not to ADDOV. And the x86/x64 assembler can +** use lea instead of an add for integer ADD, but not for ADDOV (lea does +** not affect the flags, but it helps to avoid register moves). +** +** +** All of the above has to be reconsidered for architectures with slow FP +** operations or without a hardware FPU. The dual-number mode of LuaJIT +** addresses this issue. Arithmetic operations are performed on integers +** as far as possible and overflow checks are added as needed. +** +** This implies that narrowing for integer arguments and bit operations +** should also strip overflow checks, e.g. replace ADDOV with ADD. The +** original overflow guards are weak and can be eliminated by DCE, if +** there's no other use. +** +** A slight twist is that it's usually beneficial to use overflow-checked +** integer arithmetics if all inputs are already integers. This is the only +** change that affects the single-number mode, too. +*/ + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) +#define fins (&J->fold.ins) + +/* Pass IR on to next optimization in chain (FOLD). */ +#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) + +#define emitir_raw(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_ir_emit(J)) + +/* -- Elimination of narrowing type conversions --------------------------- */ + +/* Narrowing of index expressions and bit operations is demand-driven. The +** trace recorder emits a narrowing type conversion (CONV.int.num or TOBIT) +** in all of these cases (e.g. array indexing or string indexing). FOLD +** already takes care of eliminating simple redundant conversions like +** CONV.int.num(CONV.num.int(x)) ==> x. +** +** But the surrounding code is FP-heavy and arithmetic operations are +** performed on FP numbers (for the single-number mode). Consider a common +** example such as 'x=t[i+1]', with 'i' already an integer (due to induction +** variable narrowing). The index expression would be recorded as +** CONV.int.num(ADD(CONV.num.int(i), 1)) +** which is clearly suboptimal. +** +** One can do better by recursively backpropagating the narrowing type +** conversion across FP arithmetic operations. This turns FP ops into +** their corresponding integer counterparts. Depending on the semantics of +** the conversion they also need to check for overflow. Currently only ADD +** and SUB are supported. +** +** The above example can be rewritten as +** ADDOV(CONV.int.num(CONV.num.int(i)), 1) +** and then into ADDOV(i, 1) after folding of the conversions. The original +** FP ops remain in the IR and are eliminated by DCE since all references to +** them are gone. +** +** [In dual-number mode the trace recorder already emits ADDOV etc., but +** this can be further reduced. See below.] +** +** Special care has to be taken to avoid narrowing across an operation +** which is potentially operating on non-integral operands. One obvious +** case is when an expression contains a non-integral constant, but ends +** up as an integer index at runtime (like t[x+1.5] with x=0.5). +** +** Operations with two non-constant operands illustrate a similar problem +** (like t[a+b] with a=1.5 and b=2.5). Backpropagation has to stop there, +** unless it can be proven that either operand is integral (e.g. by CSEing +** a previous conversion). As a not-so-obvious corollary this logic also +** applies for a whole expression tree (e.g. t[(a+1)+(b+1)]). +** +** Correctness of the transformation is guaranteed by avoiding to expand +** the tree by adding more conversions than the one we would need to emit +** if not backpropagating. TOBIT employs a more optimistic rule, because +** the conversion has special semantics, designed to make the life of the +** compiler writer easier. ;-) +** +** Using on-the-fly backpropagation of an expression tree doesn't work +** because it's unknown whether the transform is correct until the end. +** This either requires IR rollback and cache invalidation for every +** subtree or a two-pass algorithm. The former didn't work out too well, +** so the code now combines a recursive collector with a stack-based +** emitter. +** +** [A recursive backpropagation algorithm with backtracking, employing +** skip-list lookup and round-robin caching, emitting stack operations +** on-the-fly for a stack-based interpreter -- and all of that in a meager +** kilobyte? Yep, compilers are a great treasure chest. Throw away your +** textbooks and read the codebase of a compiler today!] +** +** There's another optimization opportunity for array indexing: it's +** always accompanied by an array bounds-check. The outermost overflow +** check may be delegated to the ABC operation. This works because ABC is +** an unsigned comparison and wrap-around due to overflow creates negative +** numbers. +** +** But this optimization is only valid for constants that cannot overflow +** an int32_t into the range of valid array indexes [0..2^27+1). A check +** for +-2^30 is safe since -2^31 - 2^30 wraps to 2^30 and 2^31-1 + 2^30 +** wraps to -2^30-1. +** +** It's also good enough in practice, since e.g. t[i+1] or t[i-10] are +** quite common. So the above example finally ends up as ADD(i, 1)! +** +** Later on, the assembler is able to fuse the whole array reference and +** the ADD into the memory operands of loads and other instructions. This +** is why LuaJIT is able to generate very pretty (and fast) machine code +** for array indexing. And that, my dear, concludes another story about +** one of the hidden secrets of LuaJIT ... +*/ + +/* Maximum backpropagation depth and maximum stack size. */ +#define NARROW_MAX_BACKPROP 100 +#define NARROW_MAX_STACK 256 + +/* The stack machine has a 32 bit instruction format: [IROpT | IRRef1] +** The lower 16 bits hold a reference (or 0). The upper 16 bits hold +** the IR opcode + type or one of the following special opcodes: +*/ +enum { + NARROW_REF, /* Push ref. */ + NARROW_CONV, /* Push conversion of ref. */ + NARROW_SEXT, /* Push sign-extension of ref. */ + NARROW_INT /* Push KINT ref. The next code holds an int32_t. */ +}; + +typedef uint32_t NarrowIns; + +#define NARROWINS(op, ref) (((op) << 16) + (ref)) +#define narrow_op(ins) ((IROpT)((ins) >> 16)) +#define narrow_ref(ins) ((IRRef1)(ins)) + +/* Context used for narrowing of type conversions. */ +typedef struct NarrowConv { + jit_State *J; /* JIT compiler state. */ + NarrowIns *sp; /* Current stack pointer. */ + NarrowIns *maxsp; /* Maximum stack pointer minus redzone. */ + int lim; /* Limit on the number of emitted conversions. */ + IRRef mode; /* Conversion mode (IRCONV_*). */ + IRType t; /* Destination type: IRT_INT or IRT_I64. */ + NarrowIns stack[NARROW_MAX_STACK]; /* Stack holding stack-machine code. */ +} NarrowConv; + +/* Lookup a reference in the backpropagation cache. */ +static BPropEntry *narrow_bpc_get(jit_State *J, IRRef1 key, IRRef mode) +{ + ptrdiff_t i; + for (i = 0; i < BPROP_SLOTS; i++) { + BPropEntry *bp = &J->bpropcache[i]; + /* Stronger checks are ok, too. */ + if (bp->key == key && bp->mode >= mode && + ((bp->mode ^ mode) & IRCONV_MODEMASK) == 0) + return bp; + } + return NULL; +} + +/* Add an entry to the backpropagation cache. */ +static void narrow_bpc_set(jit_State *J, IRRef1 key, IRRef1 val, IRRef mode) +{ + uint32_t slot = J->bpropslot; + BPropEntry *bp = &J->bpropcache[slot]; + J->bpropslot = (slot + 1) & (BPROP_SLOTS-1); + bp->key = key; + bp->val = val; + bp->mode = mode; +} + +/* Backpropagate overflow stripping. */ +static void narrow_stripov_backprop(NarrowConv *nc, IRRef ref, int depth) +{ + jit_State *J = nc->J; + IRIns *ir = IR(ref); + if (ir->o == IR_ADDOV || ir->o == IR_SUBOV || + (ir->o == IR_MULOV && (nc->mode & IRCONV_CONVMASK) == IRCONV_ANY)) { + BPropEntry *bp = narrow_bpc_get(nc->J, ref, IRCONV_TOBIT); + if (bp) { + ref = bp->val; + } else if (++depth < NARROW_MAX_BACKPROP && nc->sp < nc->maxsp) { + NarrowIns *savesp = nc->sp; + narrow_stripov_backprop(nc, ir->op1, depth); + if (nc->sp < nc->maxsp) { + narrow_stripov_backprop(nc, ir->op2, depth); + if (nc->sp < nc->maxsp) { + *nc->sp++ = NARROWINS(IRT(ir->o - IR_ADDOV + IR_ADD, IRT_INT), ref); + return; + } + } + nc->sp = savesp; /* Path too deep, need to backtrack. */ + } + } + *nc->sp++ = NARROWINS(NARROW_REF, ref); +} + +/* Backpropagate narrowing conversion. Return number of needed conversions. */ +static int narrow_conv_backprop(NarrowConv *nc, IRRef ref, int depth) +{ + jit_State *J = nc->J; + IRIns *ir = IR(ref); + IRRef cref; + + if (nc->sp >= nc->maxsp) return 10; /* Path too deep. */ + + /* Check the easy cases first. */ + if (ir->o == IR_CONV && (ir->op2 & IRCONV_SRCMASK) == IRT_INT) { + if ((nc->mode & IRCONV_CONVMASK) <= IRCONV_ANY) + narrow_stripov_backprop(nc, ir->op1, depth+1); + else + *nc->sp++ = NARROWINS(NARROW_REF, ir->op1); /* Undo conversion. */ + if (nc->t == IRT_I64) + *nc->sp++ = NARROWINS(NARROW_SEXT, 0); /* Sign-extend integer. */ + return 0; + } else if (ir->o == IR_KNUM) { /* Narrow FP constant. */ + lua_Number n = ir_knum(ir)->n; + if ((nc->mode & IRCONV_CONVMASK) == IRCONV_TOBIT) { + /* Allows a wider range of constants. */ + int64_t k64 = (int64_t)n; + if (n == (lua_Number)k64) { /* Only if const doesn't lose precision. */ + *nc->sp++ = NARROWINS(NARROW_INT, 0); + *nc->sp++ = (NarrowIns)k64; /* But always truncate to 32 bits. */ + return 0; + } + } else { + int32_t k = lj_num2int(n); + /* Only if constant is a small integer. */ + if (checki16(k) && n == (lua_Number)k) { + *nc->sp++ = NARROWINS(NARROW_INT, 0); + *nc->sp++ = (NarrowIns)k; + return 0; + } + } + return 10; /* Never narrow other FP constants (this is rare). */ + } + + /* Try to CSE the conversion. Stronger checks are ok, too. */ + cref = J->chain[fins->o]; + while (cref > ref) { + IRIns *cr = IR(cref); + if (cr->op1 == ref && + (fins->o == IR_TOBIT || + ((cr->op2 & IRCONV_MODEMASK) == (nc->mode & IRCONV_MODEMASK) && + irt_isguard(cr->t) >= irt_isguard(fins->t)))) { + *nc->sp++ = NARROWINS(NARROW_REF, cref); + return 0; /* Already there, no additional conversion needed. */ + } + cref = cr->prev; + } + + /* Backpropagate across ADD/SUB. */ + if (ir->o == IR_ADD || ir->o == IR_SUB) { + /* Try cache lookup first. */ + IRRef mode = nc->mode; + BPropEntry *bp; + /* Inner conversions need a stronger check. */ + if ((mode & IRCONV_CONVMASK) == IRCONV_INDEX && depth > 0) + mode += IRCONV_CHECK-IRCONV_INDEX; + bp = narrow_bpc_get(nc->J, (IRRef1)ref, mode); + if (bp) { + *nc->sp++ = NARROWINS(NARROW_REF, bp->val); + return 0; + } else if (nc->t == IRT_I64) { + /* Try sign-extending from an existing (checked) conversion to int. */ + mode = (IRT_INT<<5)|IRT_NUM|IRCONV_INDEX; + bp = narrow_bpc_get(nc->J, (IRRef1)ref, mode); + if (bp) { + *nc->sp++ = NARROWINS(NARROW_REF, bp->val); + *nc->sp++ = NARROWINS(NARROW_SEXT, 0); + return 0; + } + } + if (++depth < NARROW_MAX_BACKPROP && nc->sp < nc->maxsp) { + NarrowIns *savesp = nc->sp; + int count = narrow_conv_backprop(nc, ir->op1, depth); + count += narrow_conv_backprop(nc, ir->op2, depth); + if (count <= nc->lim) { /* Limit total number of conversions. */ + *nc->sp++ = NARROWINS(IRT(ir->o, nc->t), ref); + return count; + } + nc->sp = savesp; /* Too many conversions, need to backtrack. */ + } + } + + /* Otherwise add a conversion. */ + *nc->sp++ = NARROWINS(NARROW_CONV, ref); + return 1; +} + +/* Emit the conversions collected during backpropagation. */ +static IRRef narrow_conv_emit(jit_State *J, NarrowConv *nc) +{ + /* The fins fields must be saved now -- emitir() overwrites them. */ + IROpT guardot = irt_isguard(fins->t) ? IRTG(IR_ADDOV-IR_ADD, 0) : 0; + IROpT convot = fins->ot; + IRRef1 convop2 = fins->op2; + NarrowIns *next = nc->stack; /* List of instructions from backpropagation. */ + NarrowIns *last = nc->sp; + NarrowIns *sp = nc->stack; /* Recycle the stack to store operands. */ + while (next < last) { /* Simple stack machine to process the ins. list. */ + NarrowIns ref = *next++; + IROpT op = narrow_op(ref); + if (op == NARROW_REF) { + *sp++ = ref; + } else if (op == NARROW_CONV) { + *sp++ = emitir_raw(convot, ref, convop2); /* Raw emit avoids a loop. */ + } else if (op == NARROW_SEXT) { + lua_assert(sp >= nc->stack+1); + sp[-1] = emitir(IRT(IR_CONV, IRT_I64), sp[-1], + (IRT_I64<<5)|IRT_INT|IRCONV_SEXT); + } else if (op == NARROW_INT) { + lua_assert(next < last); + *sp++ = nc->t == IRT_I64 ? + lj_ir_kint64(J, (int64_t)(int32_t)*next++) : + lj_ir_kint(J, *next++); + } else { /* Regular IROpT. Pops two operands and pushes one result. */ + IRRef mode = nc->mode; + lua_assert(sp >= nc->stack+2); + sp--; + /* Omit some overflow checks for array indexing. See comments above. */ + if ((mode & IRCONV_CONVMASK) == IRCONV_INDEX) { + if (next == last && irref_isk(narrow_ref(sp[0])) && + (uint32_t)IR(narrow_ref(sp[0]))->i + 0x40000000u < 0x80000000u) + guardot = 0; + else /* Otherwise cache a stronger check. */ + mode += IRCONV_CHECK-IRCONV_INDEX; + } + sp[-1] = emitir(op+guardot, sp[-1], sp[0]); + /* Add to cache. */ + if (narrow_ref(ref)) + narrow_bpc_set(J, narrow_ref(ref), narrow_ref(sp[-1]), mode); + } + } + lua_assert(sp == nc->stack+1); + return nc->stack[0]; +} + +/* Narrow a type conversion of an arithmetic operation. */ +TRef LJ_FASTCALL lj_opt_narrow_convert(jit_State *J) +{ + if ((J->flags & JIT_F_OPT_NARROW)) { + NarrowConv nc; + nc.J = J; + nc.sp = nc.stack; + nc.maxsp = &nc.stack[NARROW_MAX_STACK-4]; + nc.t = irt_type(fins->t); + if (fins->o == IR_TOBIT) { + nc.mode = IRCONV_TOBIT; /* Used only in the backpropagation cache. */ + nc.lim = 2; /* TOBIT can use a more optimistic rule. */ + } else { + nc.mode = fins->op2; + nc.lim = 1; + } + if (narrow_conv_backprop(&nc, fins->op1, 0) <= nc.lim) + return narrow_conv_emit(J, &nc); + } + return NEXTFOLD; +} + +/* -- Narrowing of implicit conversions ----------------------------------- */ + +/* Recursively strip overflow checks. */ +static TRef narrow_stripov(jit_State *J, TRef tr, int lastop, IRRef mode) +{ + IRRef ref = tref_ref(tr); + IRIns *ir = IR(ref); + int op = ir->o; + if (op >= IR_ADDOV && op <= lastop) { + BPropEntry *bp = narrow_bpc_get(J, ref, mode); + if (bp) { + return TREF(bp->val, irt_t(IR(bp->val)->t)); + } else { + IRRef op1 = ir->op1, op2 = ir->op2; /* The IR may be reallocated. */ + op1 = narrow_stripov(J, op1, lastop, mode); + op2 = narrow_stripov(J, op2, lastop, mode); + tr = emitir(IRT(op - IR_ADDOV + IR_ADD, + ((mode & IRCONV_DSTMASK) >> IRCONV_DSH)), op1, op2); + narrow_bpc_set(J, ref, tref_ref(tr), mode); + } + } else if (LJ_64 && (mode & IRCONV_SEXT) && !irt_is64(ir->t)) { + tr = emitir(IRT(IR_CONV, IRT_INTP), tr, mode); + } + return tr; +} + +/* Narrow array index. */ +TRef LJ_FASTCALL lj_opt_narrow_index(jit_State *J, TRef tr) +{ + IRIns *ir; + lua_assert(tref_isnumber(tr)); + if (tref_isnum(tr)) /* Conversion may be narrowed, too. See above. */ + return emitir(IRTGI(IR_CONV), tr, IRCONV_INT_NUM|IRCONV_INDEX); + /* Omit some overflow checks for array indexing. See comments above. */ + ir = IR(tref_ref(tr)); + if ((ir->o == IR_ADDOV || ir->o == IR_SUBOV) && irref_isk(ir->op2) && + (uint32_t)IR(ir->op2)->i + 0x40000000u < 0x80000000u) + return emitir(IRTI(ir->o - IR_ADDOV + IR_ADD), ir->op1, ir->op2); + return tr; +} + +/* Narrow conversion to integer operand (overflow undefined). */ +TRef LJ_FASTCALL lj_opt_narrow_toint(jit_State *J, TRef tr) +{ + if (tref_isstr(tr)) + tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); + if (tref_isnum(tr)) /* Conversion may be narrowed, too. See above. */ + return emitir(IRTI(IR_CONV), tr, IRCONV_INT_NUM|IRCONV_ANY); + if (!tref_isinteger(tr)) + lj_trace_err(J, LJ_TRERR_BADTYPE); + /* + ** Undefined overflow semantics allow stripping of ADDOV, SUBOV and MULOV. + ** Use IRCONV_TOBIT for the cache entries, since the semantics are the same. + */ + return narrow_stripov(J, tr, IR_MULOV, (IRT_INT<<5)|IRT_INT|IRCONV_TOBIT); +} + +/* Narrow conversion to bitop operand (overflow wrapped). */ +TRef LJ_FASTCALL lj_opt_narrow_tobit(jit_State *J, TRef tr) +{ + if (tref_isstr(tr)) + tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); + if (tref_isnum(tr)) /* Conversion may be narrowed, too. See above. */ + return emitir(IRTI(IR_TOBIT), tr, lj_ir_knum_tobit(J)); + if (!tref_isinteger(tr)) + lj_trace_err(J, LJ_TRERR_BADTYPE); + /* + ** Wrapped overflow semantics allow stripping of ADDOV and SUBOV. + ** MULOV cannot be stripped due to precision widening. + */ + return narrow_stripov(J, tr, IR_SUBOV, (IRT_INT<<5)|IRT_INT|IRCONV_TOBIT); +} + +#if LJ_HASFFI +/* Narrow C array index (overflow undefined). */ +TRef LJ_FASTCALL lj_opt_narrow_cindex(jit_State *J, TRef tr) +{ + lua_assert(tref_isnumber(tr)); + if (tref_isnum(tr)) + return emitir(IRT(IR_CONV, IRT_INTP), tr, + (IRT_INTP<<5)|IRT_NUM|IRCONV_TRUNC|IRCONV_ANY); + /* Undefined overflow semantics allow stripping of ADDOV, SUBOV and MULOV. */ + return narrow_stripov(J, tr, IR_MULOV, + LJ_64 ? ((IRT_INTP<<5)|IRT_INT|IRCONV_SEXT) : + ((IRT_INTP<<5)|IRT_INT|IRCONV_TOBIT)); +} +#endif + +/* -- Narrowing of arithmetic operators ----------------------------------- */ + +/* Check whether a number fits into an int32_t (-0 is ok, too). */ +static int numisint(lua_Number n) +{ + return (n == (lua_Number)lj_num2int(n)); +} + +/* Narrowing of arithmetic operations. */ +TRef lj_opt_narrow_arith(jit_State *J, TRef rb, TRef rc, + TValue *vb, TValue *vc, IROp op) +{ + if (tref_isstr(rb)) { + rb = emitir(IRTG(IR_STRTO, IRT_NUM), rb, 0); + lj_strscan_num(strV(vb), vb); + } + if (tref_isstr(rc)) { + rc = emitir(IRTG(IR_STRTO, IRT_NUM), rc, 0); + lj_strscan_num(strV(vc), vc); + } + /* Must not narrow MUL in non-DUALNUM variant, because it loses -0. */ + if ((op >= IR_ADD && op <= (LJ_DUALNUM ? IR_MUL : IR_SUB)) && + tref_isinteger(rb) && tref_isinteger(rc) && + numisint(lj_vm_foldarith(numberVnum(vb), numberVnum(vc), + (int)op - (int)IR_ADD))) + return emitir(IRTGI((int)op - (int)IR_ADD + (int)IR_ADDOV), rb, rc); + if (!tref_isnum(rb)) rb = emitir(IRTN(IR_CONV), rb, IRCONV_NUM_INT); + if (!tref_isnum(rc)) rc = emitir(IRTN(IR_CONV), rc, IRCONV_NUM_INT); + return emitir(IRTN(op), rb, rc); +} + +/* Narrowing of unary minus operator. */ +TRef lj_opt_narrow_unm(jit_State *J, TRef rc, TValue *vc) +{ + if (tref_isstr(rc)) { + rc = emitir(IRTG(IR_STRTO, IRT_NUM), rc, 0); + lj_strscan_num(strV(vc), vc); + } + if (tref_isinteger(rc)) { + if ((uint32_t)numberVint(vc) != 0x80000000u) + return emitir(IRTGI(IR_SUBOV), lj_ir_kint(J, 0), rc); + rc = emitir(IRTN(IR_CONV), rc, IRCONV_NUM_INT); + } + return emitir(IRTN(IR_NEG), rc, lj_ir_knum_neg(J)); +} + +/* Narrowing of modulo operator. */ +TRef lj_opt_narrow_mod(jit_State *J, TRef rb, TRef rc, TValue *vc) +{ + TRef tmp; + if (tvisstr(vc) && !lj_strscan_num(strV(vc), vc)) + lj_trace_err(J, LJ_TRERR_BADTYPE); + if ((LJ_DUALNUM || (J->flags & JIT_F_OPT_NARROW)) && + tref_isinteger(rb) && tref_isinteger(rc) && + (tvisint(vc) ? intV(vc) != 0 : !tviszero(vc))) { + emitir(IRTGI(IR_NE), rc, lj_ir_kint(J, 0)); + return emitir(IRTI(IR_MOD), rb, rc); + } + /* b % c ==> b - floor(b/c)*c */ + rb = lj_ir_tonum(J, rb); + rc = lj_ir_tonum(J, rc); + tmp = emitir(IRTN(IR_DIV), rb, rc); + tmp = emitir(IRTN(IR_FPMATH), tmp, IRFPM_FLOOR); + tmp = emitir(IRTN(IR_MUL), tmp, rc); + return emitir(IRTN(IR_SUB), rb, tmp); +} + +/* Narrowing of power operator or math.pow. */ +TRef lj_opt_narrow_pow(jit_State *J, TRef rb, TRef rc, TValue *vc) +{ + if (tvisstr(vc) && !lj_strscan_num(strV(vc), vc)) + lj_trace_err(J, LJ_TRERR_BADTYPE); + /* Narrowing must be unconditional to preserve (-x)^i semantics. */ + if (tvisint(vc) || numisint(numV(vc))) { + int checkrange = 0; + /* Split pow is faster for bigger exponents. But do this only for (+k)^i. */ + if (tref_isk(rb) && (int32_t)ir_knum(IR(tref_ref(rb)))->u32.hi >= 0) { + int32_t k = numberVint(vc); + if (!(k >= -65536 && k <= 65536)) goto split_pow; + checkrange = 1; + } + if (!tref_isinteger(rc)) { + if (tref_isstr(rc)) + rc = emitir(IRTG(IR_STRTO, IRT_NUM), rc, 0); + /* Guarded conversion to integer! */ + rc = emitir(IRTGI(IR_CONV), rc, IRCONV_INT_NUM|IRCONV_CHECK); + } + if (checkrange && !tref_isk(rc)) { /* Range guard: -65536 <= i <= 65536 */ + TRef tmp = emitir(IRTI(IR_ADD), rc, lj_ir_kint(J, 65536)); + emitir(IRTGI(IR_ULE), tmp, lj_ir_kint(J, 2*65536)); + } + return emitir(IRTN(IR_POW), rb, rc); + } +split_pow: + /* FOLD covers most cases, but some are easier to do here. */ + if (tref_isk(rb) && tvispone(ir_knum(IR(tref_ref(rb))))) + return rb; /* 1 ^ x ==> 1 */ + rc = lj_ir_tonum(J, rc); + if (tref_isk(rc) && ir_knum(IR(tref_ref(rc)))->n == 0.5) + return emitir(IRTN(IR_FPMATH), rb, IRFPM_SQRT); /* x ^ 0.5 ==> sqrt(x) */ + /* Split up b^c into exp2(c*log2(b)). Assembler may rejoin later. */ + rb = emitir(IRTN(IR_FPMATH), rb, IRFPM_LOG2); + rc = emitir(IRTN(IR_MUL), rb, rc); + return emitir(IRTN(IR_FPMATH), rc, IRFPM_EXP2); +} + +/* -- Predictive narrowing of induction variables ------------------------- */ + +/* Narrow a single runtime value. */ +static int narrow_forl(jit_State *J, cTValue *o) +{ + if (tvisint(o)) return 1; + if (LJ_DUALNUM || (J->flags & JIT_F_OPT_NARROW)) return numisint(numV(o)); + return 0; +} + +/* Narrow the FORL index type by looking at the runtime values. */ +IRType lj_opt_narrow_forl(jit_State *J, cTValue *tv) +{ + lua_assert(tvisnumber(&tv[FORL_IDX]) && + tvisnumber(&tv[FORL_STOP]) && + tvisnumber(&tv[FORL_STEP])); + /* Narrow only if the runtime values of start/stop/step are all integers. */ + if (narrow_forl(J, &tv[FORL_IDX]) && + narrow_forl(J, &tv[FORL_STOP]) && + narrow_forl(J, &tv[FORL_STEP])) { + /* And if the loop index can't possibly overflow. */ + lua_Number step = numberVnum(&tv[FORL_STEP]); + lua_Number sum = numberVnum(&tv[FORL_STOP]) + step; + if (0 <= step ? (sum <= 2147483647.0) : (sum >= -2147483648.0)) + return IRT_INT; + } + return IRT_NUM; +} + +#undef IR +#undef fins +#undef emitir +#undef emitir_raw + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_sink.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_sink.c new file mode 100644 index 000000000..a98e9dfe3 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_sink.c @@ -0,0 +1,245 @@ +/* +** SINK: Allocation Sinking and Store Sinking. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_opt_sink_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_iropt.h" +#include "lj_target.h" + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) + +/* Check whether the store ref points to an eligible allocation. */ +static IRIns *sink_checkalloc(jit_State *J, IRIns *irs) +{ + IRIns *ir = IR(irs->op1); + if (!irref_isk(ir->op2)) + return NULL; /* Non-constant key. */ + if (ir->o == IR_HREFK || ir->o == IR_AREF) + ir = IR(ir->op1); + else if (!(ir->o == IR_HREF || ir->o == IR_NEWREF || + ir->o == IR_FREF || ir->o == IR_ADD)) + return NULL; /* Unhandled reference type (for XSTORE). */ + ir = IR(ir->op1); + if (!(ir->o == IR_TNEW || ir->o == IR_TDUP || ir->o == IR_CNEW)) + return NULL; /* Not an allocation. */ + return ir; /* Return allocation. */ +} + +/* Recursively check whether a value depends on a PHI. */ +static int sink_phidep(jit_State *J, IRRef ref) +{ + IRIns *ir = IR(ref); + if (irt_isphi(ir->t)) return 1; + if (ir->op1 >= REF_FIRST && sink_phidep(J, ir->op1)) return 1; + if (ir->op2 >= REF_FIRST && sink_phidep(J, ir->op2)) return 1; + return 0; +} + +/* Check whether a value is a sinkable PHI or loop-invariant. */ +static int sink_checkphi(jit_State *J, IRIns *ira, IRRef ref) +{ + if (ref >= REF_FIRST) { + IRIns *ir = IR(ref); + if (irt_isphi(ir->t) || (ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT && + irt_isphi(IR(ir->op1)->t))) { + ira->prev++; + return 1; /* Sinkable PHI. */ + } + /* Otherwise the value must be loop-invariant. */ + return ref < J->loopref && !sink_phidep(J, ref); + } + return 1; /* Constant (non-PHI). */ +} + +/* Mark non-sinkable allocations using single-pass backward propagation. +** +** Roots for the marking process are: +** - Some PHIs or snapshots (see below). +** - Non-PHI, non-constant values stored to PHI allocations. +** - All guards. +** - Any remaining loads not eliminated by store-to-load forwarding. +** - Stores with non-constant keys. +** - All stored values. +*/ +static void sink_mark_ins(jit_State *J) +{ + IRIns *ir, *irlast = IR(J->cur.nins-1); + for (ir = irlast ; ; ir--) { + switch (ir->o) { + case IR_BASE: + return; /* Finished. */ + case IR_CALLL: /* IRCALL_lj_tab_len */ + case IR_ALOAD: case IR_HLOAD: case IR_XLOAD: case IR_TBAR: + irt_setmark(IR(ir->op1)->t); /* Mark ref for remaining loads. */ + break; + case IR_FLOAD: + if (irt_ismarked(ir->t) || ir->op2 == IRFL_TAB_META) + irt_setmark(IR(ir->op1)->t); /* Mark table for remaining loads. */ + break; + case IR_ASTORE: case IR_HSTORE: case IR_FSTORE: case IR_XSTORE: { + IRIns *ira = sink_checkalloc(J, ir); + if (!ira || (irt_isphi(ira->t) && !sink_checkphi(J, ira, ir->op2))) + irt_setmark(IR(ir->op1)->t); /* Mark ineligible ref. */ + irt_setmark(IR(ir->op2)->t); /* Mark stored value. */ + break; + } +#if LJ_HASFFI + case IR_CNEWI: + if (irt_isphi(ir->t) && + (!sink_checkphi(J, ir, ir->op2) || + (LJ_32 && ir+1 < irlast && (ir+1)->o == IR_HIOP && + !sink_checkphi(J, ir, (ir+1)->op2)))) + irt_setmark(ir->t); /* Mark ineligible allocation. */ + /* fallthrough */ +#endif + case IR_USTORE: + irt_setmark(IR(ir->op2)->t); /* Mark stored value. */ + break; +#if LJ_HASFFI + case IR_CALLXS: +#endif + case IR_CALLS: + irt_setmark(IR(ir->op1)->t); /* Mark (potentially) stored values. */ + break; + case IR_PHI: { + IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); + irl->prev = irr->prev = 0; /* Clear PHI value counts. */ + if (irl->o == irr->o && + (irl->o == IR_TNEW || irl->o == IR_TDUP || + (LJ_HASFFI && (irl->o == IR_CNEW || irl->o == IR_CNEWI)))) + break; + irt_setmark(irl->t); + irt_setmark(irr->t); + break; + } + default: + if (irt_ismarked(ir->t) || irt_isguard(ir->t)) { /* Propagate mark. */ + if (ir->op1 >= REF_FIRST) irt_setmark(IR(ir->op1)->t); + if (ir->op2 >= REF_FIRST) irt_setmark(IR(ir->op2)->t); + } + break; + } + } +} + +/* Mark all instructions referenced by a snapshot. */ +static void sink_mark_snap(jit_State *J, SnapShot *snap) +{ + SnapEntry *map = &J->cur.snapmap[snap->mapofs]; + MSize n, nent = snap->nent; + for (n = 0; n < nent; n++) { + IRRef ref = snap_ref(map[n]); + if (!irref_isk(ref)) + irt_setmark(IR(ref)->t); + } +} + +/* Iteratively remark PHI refs with differing marks or PHI value counts. */ +static void sink_remark_phi(jit_State *J) +{ + IRIns *ir; + int remark; + do { + remark = 0; + for (ir = IR(J->cur.nins-1); ir->o == IR_PHI; ir--) { + IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); + if (((irl->t.irt ^ irr->t.irt) & IRT_MARK)) + remark = 1; + else if (irl->prev == irr->prev) + continue; + irt_setmark(IR(ir->op1)->t); + irt_setmark(IR(ir->op2)->t); + } + } while (remark); +} + +/* Sweep instructions and tag sunken allocations and stores. */ +static void sink_sweep_ins(jit_State *J) +{ + IRIns *ir, *irfirst = IR(J->cur.nk); + for (ir = IR(J->cur.nins-1) ; ir >= irfirst; ir--) { + switch (ir->o) { + case IR_ASTORE: case IR_HSTORE: case IR_FSTORE: case IR_XSTORE: { + IRIns *ira = sink_checkalloc(J, ir); + if (ira && !irt_ismarked(ira->t)) { + int delta = (int)(ir - ira); + ir->prev = REGSP(RID_SINK, delta > 255 ? 255 : delta); + } else { + ir->prev = REGSP_INIT; + } + break; + } + case IR_NEWREF: + if (!irt_ismarked(IR(ir->op1)->t)) { + ir->prev = REGSP(RID_SINK, 0); + } else { + irt_clearmark(ir->t); + ir->prev = REGSP_INIT; + } + break; +#if LJ_HASFFI + case IR_CNEW: case IR_CNEWI: +#endif + case IR_TNEW: case IR_TDUP: + if (!irt_ismarked(ir->t)) { + ir->t.irt &= ~IRT_GUARD; + ir->prev = REGSP(RID_SINK, 0); + J->cur.sinktags = 1; /* Signal present SINK tags to assembler. */ + } else { + irt_clearmark(ir->t); + ir->prev = REGSP_INIT; + } + break; + case IR_PHI: { + IRIns *ira = IR(ir->op2); + if (!irt_ismarked(ira->t) && + (ira->o == IR_TNEW || ira->o == IR_TDUP || + (LJ_HASFFI && (ira->o == IR_CNEW || ira->o == IR_CNEWI)))) { + ir->prev = REGSP(RID_SINK, 0); + } else { + ir->prev = REGSP_INIT; + } + break; + } + default: + irt_clearmark(ir->t); + ir->prev = REGSP_INIT; + break; + } + } +} + +/* Allocation sinking and store sinking. +** +** 1. Mark all non-sinkable allocations. +** 2. Then sink all remaining allocations and the related stores. +*/ +void lj_opt_sink(jit_State *J) +{ + const uint32_t need = (JIT_F_OPT_SINK|JIT_F_OPT_FWD| + JIT_F_OPT_DCE|JIT_F_OPT_CSE|JIT_F_OPT_FOLD); + if ((J->flags & need) == need && + (J->chain[IR_TNEW] || J->chain[IR_TDUP] || + (LJ_HASFFI && (J->chain[IR_CNEW] || J->chain[IR_CNEWI])))) { + if (!J->loopref) + sink_mark_snap(J, &J->cur.snap[J->cur.nsnap-1]); + sink_mark_ins(J); + if (J->loopref) + sink_remark_phi(J); + sink_sweep_ins(J); + } +} + +#undef IR + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_split.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_split.c new file mode 100644 index 000000000..1cee5093b --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_opt_split.c @@ -0,0 +1,731 @@ +/* +** SPLIT: Split 64 bit IR instructions into 32 bit IR instructions. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_opt_split_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT && (LJ_SOFTFP || (LJ_32 && LJ_HASFFI)) + +#include "lj_err.h" +#include "lj_str.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_ircall.h" +#include "lj_iropt.h" +#include "lj_vm.h" + +/* SPLIT pass: +** +** This pass splits up 64 bit IR instructions into multiple 32 bit IR +** instructions. It's only active for soft-float targets or for 32 bit CPUs +** which lack native 64 bit integer operations (the FFI is currently the +** only emitter for 64 bit integer instructions). +** +** Splitting the IR in a separate pass keeps each 32 bit IR assembler +** backend simple. Only a small amount of extra functionality needs to be +** implemented. This is much easier than adding support for allocating +** register pairs to each backend (believe me, I tried). A few simple, but +** important optimizations can be performed by the SPLIT pass, which would +** be tedious to do in the backend. +** +** The basic idea is to replace each 64 bit IR instruction with its 32 bit +** equivalent plus an extra HIOP instruction. The splitted IR is not passed +** through FOLD or any other optimizations, so each HIOP is guaranteed to +** immediately follow it's counterpart. The actual functionality of HIOP is +** inferred from the previous instruction. +** +** The operands of HIOP hold the hiword input references. The output of HIOP +** is the hiword output reference, which is also used to hold the hiword +** register or spill slot information. The register allocator treats this +** instruction independently of any other instruction, which improves code +** quality compared to using fixed register pairs. +** +** It's easier to split up some instructions into two regular 32 bit +** instructions. E.g. XLOAD is split up into two XLOADs with two different +** addresses. Obviously 64 bit constants need to be split up into two 32 bit +** constants, too. Some hiword instructions can be entirely omitted, e.g. +** when zero-extending a 32 bit value to 64 bits. 64 bit arguments for calls +** are split up into two 32 bit arguments each. +** +** On soft-float targets, floating-point instructions are directly converted +** to soft-float calls by the SPLIT pass (except for comparisons and MIN/MAX). +** HIOP for number results has the type IRT_SOFTFP ("sfp" in -jdump). +** +** Here's the IR and x64 machine code for 'x.b = x.a + 1' for a struct with +** two int64_t fields: +** +** 0100 p32 ADD base +8 +** 0101 i64 XLOAD 0100 +** 0102 i64 ADD 0101 +1 +** 0103 p32 ADD base +16 +** 0104 i64 XSTORE 0103 0102 +** +** mov rax, [esi+0x8] +** add rax, +0x01 +** mov [esi+0x10], rax +** +** Here's the transformed IR and the x86 machine code after the SPLIT pass: +** +** 0100 p32 ADD base +8 +** 0101 int XLOAD 0100 +** 0102 p32 ADD base +12 +** 0103 int XLOAD 0102 +** 0104 int ADD 0101 +1 +** 0105 int HIOP 0103 +0 +** 0106 p32 ADD base +16 +** 0107 int XSTORE 0106 0104 +** 0108 int HIOP 0106 0105 +** +** mov eax, [esi+0x8] +** mov ecx, [esi+0xc] +** add eax, +0x01 +** adc ecx, +0x00 +** mov [esi+0x10], eax +** mov [esi+0x14], ecx +** +** You may notice the reassociated hiword address computation, which is +** later fused into the mov operands by the assembler. +*/ + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) + +/* Directly emit the transformed IR without updating chains etc. */ +static IRRef split_emit(jit_State *J, uint16_t ot, IRRef1 op1, IRRef1 op2) +{ + IRRef nref = lj_ir_nextins(J); + IRIns *ir = IR(nref); + ir->ot = ot; + ir->op1 = op1; + ir->op2 = op2; + return nref; +} + +#if LJ_SOFTFP +/* Emit a (checked) number to integer conversion. */ +static IRRef split_num2int(jit_State *J, IRRef lo, IRRef hi, int check) +{ + IRRef tmp, res; +#if LJ_LE + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), lo, hi); +#else + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hi, lo); +#endif + res = split_emit(J, IRTI(IR_CALLN), tmp, IRCALL_softfp_d2i); + if (check) { + tmp = split_emit(J, IRTI(IR_CALLN), res, IRCALL_softfp_i2d); + split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), tmp, tmp); + split_emit(J, IRTGI(IR_EQ), tmp, lo); + split_emit(J, IRTG(IR_HIOP, IRT_SOFTFP), tmp+1, hi); + } + return res; +} + +/* Emit a CALLN with one split 64 bit argument. */ +static IRRef split_call_l(jit_State *J, IRRef1 *hisubst, IRIns *oir, + IRIns *ir, IRCallID id) +{ + IRRef tmp, op1 = ir->op1; + J->cur.nins--; +#if LJ_LE + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), oir[op1].prev, hisubst[op1]); +#else + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hisubst[op1], oir[op1].prev); +#endif + ir->prev = tmp = split_emit(J, IRTI(IR_CALLN), tmp, id); + return split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), tmp, tmp); +} + +/* Emit a CALLN with one split 64 bit argument and a 32 bit argument. */ +static IRRef split_call_li(jit_State *J, IRRef1 *hisubst, IRIns *oir, + IRIns *ir, IRCallID id) +{ + IRRef tmp, op1 = ir->op1, op2 = ir->op2; + J->cur.nins--; +#if LJ_LE + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), oir[op1].prev, hisubst[op1]); +#else + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hisubst[op1], oir[op1].prev); +#endif + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, oir[op2].prev); + ir->prev = tmp = split_emit(J, IRTI(IR_CALLN), tmp, id); + return split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), tmp, tmp); +} +#endif + +/* Emit a CALLN with two split 64 bit arguments. */ +static IRRef split_call_ll(jit_State *J, IRRef1 *hisubst, IRIns *oir, + IRIns *ir, IRCallID id) +{ + IRRef tmp, op1 = ir->op1, op2 = ir->op2; + J->cur.nins--; +#if LJ_LE + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), oir[op1].prev, hisubst[op1]); + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, oir[op2].prev); + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, hisubst[op2]); +#else + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hisubst[op1], oir[op1].prev); + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, hisubst[op2]); + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, oir[op2].prev); +#endif + ir->prev = tmp = split_emit(J, IRTI(IR_CALLN), tmp, id); + return split_emit(J, + IRT(IR_HIOP, (LJ_SOFTFP && irt_isnum(ir->t)) ? IRT_SOFTFP : IRT_INT), + tmp, tmp); +} + +/* Get a pointer to the other 32 bit word (LE: hiword, BE: loword). */ +static IRRef split_ptr(jit_State *J, IRIns *oir, IRRef ref) +{ + IRRef nref = oir[ref].prev; + IRIns *ir = IR(nref); + int32_t ofs = 4; + if (ir->o == IR_KPTR) + return lj_ir_kptr(J, (char *)ir_kptr(ir) + ofs); + if (ir->o == IR_ADD && irref_isk(ir->op2) && !irt_isphi(oir[ref].t)) { + /* Reassociate address. */ + ofs += IR(ir->op2)->i; + nref = ir->op1; + if (ofs == 0) return nref; + } + return split_emit(J, IRTI(IR_ADD), nref, lj_ir_kint(J, ofs)); +} + +/* Substitute references of a snapshot. */ +static void split_subst_snap(jit_State *J, SnapShot *snap, IRIns *oir) +{ + SnapEntry *map = &J->cur.snapmap[snap->mapofs]; + MSize n, nent = snap->nent; + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + IRIns *ir = &oir[snap_ref(sn)]; + if (!(LJ_SOFTFP && (sn & SNAP_SOFTFPNUM) && irref_isk(snap_ref(sn)))) + map[n] = ((sn & 0xffff0000) | ir->prev); + } +} + +/* Transform the old IR to the new IR. */ +static void split_ir(jit_State *J) +{ + IRRef nins = J->cur.nins, nk = J->cur.nk; + MSize irlen = nins - nk; + MSize need = (irlen+1)*(sizeof(IRIns) + sizeof(IRRef1)); + IRIns *oir = (IRIns *)lj_str_needbuf(J->L, &G(J->L)->tmpbuf, need); + IRRef1 *hisubst; + IRRef ref, snref; + SnapShot *snap; + + /* Copy old IR to buffer. */ + memcpy(oir, IR(nk), irlen*sizeof(IRIns)); + /* Bias hiword substitution table and old IR. Loword kept in field prev. */ + hisubst = (IRRef1 *)&oir[irlen] - nk; + oir -= nk; + + /* Remove all IR instructions, but retain IR constants. */ + J->cur.nins = REF_FIRST; + J->loopref = 0; + + /* Process constants and fixed references. */ + for (ref = nk; ref <= REF_BASE; ref++) { + IRIns *ir = &oir[ref]; + if ((LJ_SOFTFP && ir->o == IR_KNUM) || ir->o == IR_KINT64) { + /* Split up 64 bit constant. */ + TValue tv = *ir_k64(ir); + ir->prev = lj_ir_kint(J, (int32_t)tv.u32.lo); + hisubst[ref] = lj_ir_kint(J, (int32_t)tv.u32.hi); + } else { + ir->prev = ref; /* Identity substitution for loword. */ + hisubst[ref] = 0; + } + } + + /* Process old IR instructions. */ + snap = J->cur.snap; + snref = snap->ref; + for (ref = REF_FIRST; ref < nins; ref++) { + IRIns *ir = &oir[ref]; + IRRef nref = lj_ir_nextins(J); + IRIns *nir = IR(nref); + IRRef hi = 0; + + if (ref >= snref) { + snap->ref = nref; + split_subst_snap(J, snap++, oir); + snref = snap < &J->cur.snap[J->cur.nsnap] ? snap->ref : ~(IRRef)0; + } + + /* Copy-substitute old instruction to new instruction. */ + nir->op1 = ir->op1 < nk ? ir->op1 : oir[ir->op1].prev; + nir->op2 = ir->op2 < nk ? ir->op2 : oir[ir->op2].prev; + ir->prev = nref; /* Loword substitution. */ + nir->o = ir->o; + nir->t.irt = ir->t.irt & ~(IRT_MARK|IRT_ISPHI); + hisubst[ref] = 0; + + /* Split 64 bit instructions. */ +#if LJ_SOFTFP + if (irt_isnum(ir->t)) { + nir->t.irt = IRT_INT | (nir->t.irt & IRT_GUARD); /* Turn into INT op. */ + /* Note: hi ref = lo ref + 1! Required for SNAP_SOFTFPNUM logic. */ + switch (ir->o) { + case IR_ADD: + hi = split_call_ll(J, hisubst, oir, ir, IRCALL_softfp_add); + break; + case IR_SUB: + hi = split_call_ll(J, hisubst, oir, ir, IRCALL_softfp_sub); + break; + case IR_MUL: + hi = split_call_ll(J, hisubst, oir, ir, IRCALL_softfp_mul); + break; + case IR_DIV: + hi = split_call_ll(J, hisubst, oir, ir, IRCALL_softfp_div); + break; + case IR_POW: + hi = split_call_li(J, hisubst, oir, ir, IRCALL_lj_vm_powi); + break; + case IR_FPMATH: + /* Try to rejoin pow from EXP2, MUL and LOG2. */ + if (nir->op2 == IRFPM_EXP2 && nir->op1 > J->loopref) { + IRIns *irp = IR(nir->op1); + if (irp->o == IR_CALLN && irp->op2 == IRCALL_softfp_mul) { + IRIns *irm4 = IR(irp->op1); + IRIns *irm3 = IR(irm4->op1); + IRIns *irm12 = IR(irm3->op1); + IRIns *irl1 = IR(irm12->op1); + if (irm12->op1 > J->loopref && irl1->o == IR_CALLN && + irl1->op2 == IRCALL_lj_vm_log2) { + IRRef tmp = irl1->op1; /* Recycle first two args from LOG2. */ + IRRef arg3 = irm3->op2, arg4 = irm4->op2; + J->cur.nins--; + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, arg3); + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, arg4); + ir->prev = tmp = split_emit(J, IRTI(IR_CALLN), tmp, IRCALL_pow); + hi = split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), tmp, tmp); + break; + } + } + } + hi = split_call_l(J, hisubst, oir, ir, IRCALL_lj_vm_floor + ir->op2); + break; + case IR_ATAN2: + hi = split_call_ll(J, hisubst, oir, ir, IRCALL_atan2); + break; + case IR_LDEXP: + hi = split_call_li(J, hisubst, oir, ir, IRCALL_ldexp); + break; + case IR_NEG: case IR_ABS: + nir->o = IR_CONV; /* Pass through loword. */ + nir->op2 = (IRT_INT << 5) | IRT_INT; + hi = split_emit(J, IRT(ir->o == IR_NEG ? IR_BXOR : IR_BAND, IRT_SOFTFP), + hisubst[ir->op1], hisubst[ir->op2]); + break; + case IR_SLOAD: + if ((nir->op2 & IRSLOAD_CONVERT)) { /* Convert from int to number. */ + nir->op2 &= ~IRSLOAD_CONVERT; + ir->prev = nref = split_emit(J, IRTI(IR_CALLN), nref, + IRCALL_softfp_i2d); + hi = split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nref, nref); + break; + } + /* fallthrough */ + case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: + case IR_STRTO: + hi = split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nref, nref); + break; + case IR_XLOAD: { + IRIns inslo = *nir; /* Save/undo the emit of the lo XLOAD. */ + J->cur.nins--; + hi = split_ptr(J, oir, ir->op1); /* Insert the hiref ADD. */ + nref = lj_ir_nextins(J); + nir = IR(nref); + *nir = inslo; /* Re-emit lo XLOAD immediately before hi XLOAD. */ + hi = split_emit(J, IRT(IR_XLOAD, IRT_SOFTFP), hi, ir->op2); +#if LJ_LE + ir->prev = nref; +#else + ir->prev = hi; hi = nref; +#endif + break; + } + case IR_ASTORE: case IR_HSTORE: case IR_USTORE: case IR_XSTORE: + split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nir->op1, hisubst[ir->op2]); + break; + case IR_CONV: { /* Conversion to number. Others handled below. */ + IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); + UNUSED(st); +#if LJ_32 && LJ_HASFFI + if (st == IRT_I64 || st == IRT_U64) { + hi = split_call_l(J, hisubst, oir, ir, + st == IRT_I64 ? IRCALL_fp64_l2d : IRCALL_fp64_ul2d); + break; + } +#endif + lua_assert(st == IRT_INT || + (LJ_32 && LJ_HASFFI && (st == IRT_U32 || st == IRT_FLOAT))); + nir->o = IR_CALLN; +#if LJ_32 && LJ_HASFFI + nir->op2 = st == IRT_INT ? IRCALL_softfp_i2d : + st == IRT_FLOAT ? IRCALL_softfp_f2d : + IRCALL_softfp_ui2d; +#else + nir->op2 = IRCALL_softfp_i2d; +#endif + hi = split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nref, nref); + break; + } + case IR_CALLN: + case IR_CALLL: + case IR_CALLS: + case IR_CALLXS: + goto split_call; + case IR_PHI: + if (nir->op1 == nir->op2) + J->cur.nins--; /* Drop useless PHIs. */ + if (hisubst[ir->op1] != hisubst[ir->op2]) + split_emit(J, IRT(IR_PHI, IRT_SOFTFP), + hisubst[ir->op1], hisubst[ir->op2]); + break; + case IR_HIOP: + J->cur.nins--; /* Drop joining HIOP. */ + ir->prev = nir->op1; + hi = nir->op2; + break; + default: + lua_assert(ir->o <= IR_NE || ir->o == IR_MIN || ir->o == IR_MAX); + hi = split_emit(J, IRTG(IR_HIOP, IRT_SOFTFP), + hisubst[ir->op1], hisubst[ir->op2]); + break; + } + } else +#endif +#if LJ_32 && LJ_HASFFI + if (irt_isint64(ir->t)) { + IRRef hiref = hisubst[ir->op1]; + nir->t.irt = IRT_INT | (nir->t.irt & IRT_GUARD); /* Turn into INT op. */ + switch (ir->o) { + case IR_ADD: + case IR_SUB: + /* Use plain op for hiword if loword cannot produce a carry/borrow. */ + if (irref_isk(nir->op2) && IR(nir->op2)->i == 0) { + ir->prev = nir->op1; /* Pass through loword. */ + nir->op1 = hiref; nir->op2 = hisubst[ir->op2]; + hi = nref; + break; + } + /* fallthrough */ + case IR_NEG: + hi = split_emit(J, IRTI(IR_HIOP), hiref, hisubst[ir->op2]); + break; + case IR_MUL: + hi = split_call_ll(J, hisubst, oir, ir, IRCALL_lj_carith_mul64); + break; + case IR_DIV: + hi = split_call_ll(J, hisubst, oir, ir, + irt_isi64(ir->t) ? IRCALL_lj_carith_divi64 : + IRCALL_lj_carith_divu64); + break; + case IR_MOD: + hi = split_call_ll(J, hisubst, oir, ir, + irt_isi64(ir->t) ? IRCALL_lj_carith_modi64 : + IRCALL_lj_carith_modu64); + break; + case IR_POW: + hi = split_call_ll(J, hisubst, oir, ir, + irt_isi64(ir->t) ? IRCALL_lj_carith_powi64 : + IRCALL_lj_carith_powu64); + break; + case IR_FLOAD: + lua_assert(ir->op2 == IRFL_CDATA_INT64); + hi = split_emit(J, IRTI(IR_FLOAD), nir->op1, IRFL_CDATA_INT64_4); +#if LJ_BE + ir->prev = hi; hi = nref; +#endif + break; + case IR_XLOAD: + hi = split_emit(J, IRTI(IR_XLOAD), split_ptr(J, oir, ir->op1), ir->op2); +#if LJ_BE + ir->prev = hi; hi = nref; +#endif + break; + case IR_XSTORE: + split_emit(J, IRTI(IR_HIOP), nir->op1, hisubst[ir->op2]); + break; + case IR_CONV: { /* Conversion to 64 bit integer. Others handled below. */ + IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); +#if LJ_SOFTFP + if (st == IRT_NUM) { /* NUM to 64 bit int conv. */ + hi = split_call_l(J, hisubst, oir, ir, + irt_isi64(ir->t) ? IRCALL_fp64_d2l : IRCALL_fp64_d2ul); + } else if (st == IRT_FLOAT) { /* FLOAT to 64 bit int conv. */ + nir->o = IR_CALLN; + nir->op2 = irt_isi64(ir->t) ? IRCALL_fp64_f2l : IRCALL_fp64_f2ul; + hi = split_emit(J, IRTI(IR_HIOP), nref, nref); + } +#else + if (st == IRT_NUM || st == IRT_FLOAT) { /* FP to 64 bit int conv. */ + hi = split_emit(J, IRTI(IR_HIOP), nir->op1, nref); + } +#endif + else if (st == IRT_I64 || st == IRT_U64) { /* 64/64 bit cast. */ + /* Drop cast, since assembler doesn't care. */ + goto fwdlo; + } else if ((ir->op2 & IRCONV_SEXT)) { /* Sign-extend to 64 bit. */ + IRRef k31 = lj_ir_kint(J, 31); + nir = IR(nref); /* May have been reallocated. */ + ir->prev = nir->op1; /* Pass through loword. */ + nir->o = IR_BSAR; /* hi = bsar(lo, 31). */ + nir->op2 = k31; + hi = nref; + } else { /* Zero-extend to 64 bit. */ + hi = lj_ir_kint(J, 0); + goto fwdlo; + } + break; + } + case IR_CALLXS: + goto split_call; + case IR_PHI: { + IRRef hiref2; + if ((irref_isk(nir->op1) && irref_isk(nir->op2)) || + nir->op1 == nir->op2) + J->cur.nins--; /* Drop useless PHIs. */ + hiref2 = hisubst[ir->op2]; + if (!((irref_isk(hiref) && irref_isk(hiref2)) || hiref == hiref2)) + split_emit(J, IRTI(IR_PHI), hiref, hiref2); + break; + } + case IR_HIOP: + J->cur.nins--; /* Drop joining HIOP. */ + ir->prev = nir->op1; + hi = nir->op2; + break; + default: + lua_assert(ir->o <= IR_NE); /* Comparisons. */ + split_emit(J, IRTGI(IR_HIOP), hiref, hisubst[ir->op2]); + break; + } + } else +#endif +#if LJ_SOFTFP + if (ir->o == IR_SLOAD) { + if ((nir->op2 & IRSLOAD_CONVERT)) { /* Convert from number to int. */ + nir->op2 &= ~IRSLOAD_CONVERT; + if (!(nir->op2 & IRSLOAD_TYPECHECK)) + nir->t.irt = IRT_INT; /* Drop guard. */ + split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nref, nref); + ir->prev = split_num2int(J, nref, nref+1, irt_isguard(ir->t)); + } + } else if (ir->o == IR_TOBIT) { + IRRef tmp, op1 = ir->op1; + J->cur.nins--; +#if LJ_LE + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), oir[op1].prev, hisubst[op1]); +#else + tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hisubst[op1], oir[op1].prev); +#endif + ir->prev = split_emit(J, IRTI(IR_CALLN), tmp, IRCALL_lj_vm_tobit); + } else if (ir->o == IR_TOSTR) { + if (hisubst[ir->op1]) { + if (irref_isk(ir->op1)) + nir->op1 = ir->op1; + else + split_emit(J, IRT(IR_HIOP, IRT_NIL), hisubst[ir->op1], nref); + } + } else if (ir->o == IR_HREF || ir->o == IR_NEWREF) { + if (irref_isk(ir->op2) && hisubst[ir->op2]) + nir->op2 = ir->op2; + } else +#endif + if (ir->o == IR_CONV) { /* See above, too. */ + IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); +#if LJ_32 && LJ_HASFFI + if (st == IRT_I64 || st == IRT_U64) { /* Conversion from 64 bit int. */ +#if LJ_SOFTFP + if (irt_isfloat(ir->t)) { + split_call_l(J, hisubst, oir, ir, + st == IRT_I64 ? IRCALL_fp64_l2f : IRCALL_fp64_ul2f); + J->cur.nins--; /* Drop unused HIOP. */ + } +#else + if (irt_isfp(ir->t)) { /* 64 bit integer to FP conversion. */ + ir->prev = split_emit(J, IRT(IR_HIOP, irt_type(ir->t)), + hisubst[ir->op1], nref); + } +#endif + else { /* Truncate to lower 32 bits. */ + fwdlo: + ir->prev = nir->op1; /* Forward loword. */ + /* Replace with NOP to avoid messing up the snapshot logic. */ + nir->ot = IRT(IR_NOP, IRT_NIL); + nir->op1 = nir->op2 = 0; + } + } +#endif +#if LJ_SOFTFP && LJ_32 && LJ_HASFFI + else if (irt_isfloat(ir->t)) { + if (st == IRT_NUM) { + split_call_l(J, hisubst, oir, ir, IRCALL_softfp_d2f); + J->cur.nins--; /* Drop unused HIOP. */ + } else { + nir->o = IR_CALLN; + nir->op2 = st == IRT_INT ? IRCALL_softfp_i2f : IRCALL_softfp_ui2f; + } + } else if (st == IRT_FLOAT) { + nir->o = IR_CALLN; + nir->op2 = irt_isint(ir->t) ? IRCALL_softfp_f2i : IRCALL_softfp_f2ui; + } else +#endif +#if LJ_SOFTFP + if (st == IRT_NUM || (LJ_32 && LJ_HASFFI && st == IRT_FLOAT)) { + if (irt_isguard(ir->t)) { + lua_assert(st == IRT_NUM && irt_isint(ir->t)); + J->cur.nins--; + ir->prev = split_num2int(J, nir->op1, hisubst[ir->op1], 1); + } else { + split_call_l(J, hisubst, oir, ir, +#if LJ_32 && LJ_HASFFI + st == IRT_NUM ? + (irt_isint(ir->t) ? IRCALL_softfp_d2i : IRCALL_softfp_d2ui) : + (irt_isint(ir->t) ? IRCALL_softfp_f2i : IRCALL_softfp_f2ui) +#else + IRCALL_softfp_d2i +#endif + ); + J->cur.nins--; /* Drop unused HIOP. */ + } + } +#endif + } else if (ir->o == IR_CALLXS) { + IRRef hiref; + split_call: + hiref = hisubst[ir->op1]; + if (hiref) { + IROpT ot = nir->ot; + IRRef op2 = nir->op2; + nir->ot = IRT(IR_CARG, IRT_NIL); +#if LJ_LE + nir->op2 = hiref; +#else + nir->op2 = nir->op1; nir->op1 = hiref; +#endif + ir->prev = nref = split_emit(J, ot, nref, op2); + } + if (LJ_SOFTFP ? irt_is64(ir->t) : irt_isint64(ir->t)) + hi = split_emit(J, + IRT(IR_HIOP, (LJ_SOFTFP && irt_isnum(ir->t)) ? IRT_SOFTFP : IRT_INT), + nref, nref); + } else if (ir->o == IR_CARG) { + IRRef hiref = hisubst[ir->op1]; + if (hiref) { + IRRef op2 = nir->op2; +#if LJ_LE + nir->op2 = hiref; +#else + nir->op2 = nir->op1; nir->op1 = hiref; +#endif + ir->prev = nref = split_emit(J, IRT(IR_CARG, IRT_NIL), nref, op2); + nir = IR(nref); + } + hiref = hisubst[ir->op2]; + if (hiref) { +#if !LJ_TARGET_X86 + int carg = 0; + IRIns *cir; + for (cir = IR(nir->op1); cir->o == IR_CARG; cir = IR(cir->op1)) + carg++; + if ((carg & 1) == 0) { /* Align 64 bit arguments. */ + IRRef op2 = nir->op2; + nir->op2 = REF_NIL; + nref = split_emit(J, IRT(IR_CARG, IRT_NIL), nref, op2); + nir = IR(nref); + } +#endif +#if LJ_BE + { IRRef tmp = nir->op2; nir->op2 = hiref; hiref = tmp; } +#endif + ir->prev = split_emit(J, IRT(IR_CARG, IRT_NIL), nref, hiref); + } + } else if (ir->o == IR_CNEWI) { + if (hisubst[ir->op2]) + split_emit(J, IRT(IR_HIOP, IRT_NIL), nref, hisubst[ir->op2]); + } else if (ir->o == IR_LOOP) { + J->loopref = nref; /* Needed by assembler. */ + } + hisubst[ref] = hi; /* Store hiword substitution. */ + } + if (snref == nins) { /* Substitution for last snapshot. */ + snap->ref = J->cur.nins; + split_subst_snap(J, snap, oir); + } + + /* Add PHI marks. */ + for (ref = J->cur.nins-1; ref >= REF_FIRST; ref--) { + IRIns *ir = IR(ref); + if (ir->o != IR_PHI) break; + if (!irref_isk(ir->op1)) irt_setphi(IR(ir->op1)->t); + if (ir->op2 > J->loopref) irt_setphi(IR(ir->op2)->t); + } +} + +/* Protected callback for split pass. */ +static TValue *cpsplit(lua_State *L, lua_CFunction dummy, void *ud) +{ + jit_State *J = (jit_State *)ud; + split_ir(J); + UNUSED(L); UNUSED(dummy); + return NULL; +} + +#if defined(LUA_USE_ASSERT) || LJ_SOFTFP +/* Slow, but sure way to check whether a SPLIT pass is needed. */ +static int split_needsplit(jit_State *J) +{ + IRIns *ir, *irend; + IRRef ref; + for (ir = IR(REF_FIRST), irend = IR(J->cur.nins); ir < irend; ir++) + if (LJ_SOFTFP ? irt_is64orfp(ir->t) : irt_isint64(ir->t)) + return 1; + if (LJ_SOFTFP) { + for (ref = J->chain[IR_SLOAD]; ref; ref = IR(ref)->prev) + if ((IR(ref)->op2 & IRSLOAD_CONVERT)) + return 1; + if (J->chain[IR_TOBIT]) + return 1; + } + for (ref = J->chain[IR_CONV]; ref; ref = IR(ref)->prev) { + IRType st = (IR(ref)->op2 & IRCONV_SRCMASK); + if ((LJ_SOFTFP && (st == IRT_NUM || st == IRT_FLOAT)) || + st == IRT_I64 || st == IRT_U64) + return 1; + } + return 0; /* Nope. */ +} +#endif + +/* SPLIT pass. */ +void lj_opt_split(jit_State *J) +{ +#if LJ_SOFTFP + if (!J->needsplit) + J->needsplit = split_needsplit(J); +#else + lua_assert(J->needsplit >= split_needsplit(J)); /* Verify flag. */ +#endif + if (J->needsplit) { + int errcode = lj_vm_cpcall(J->L, NULL, J, cpsplit); + if (errcode) { + /* Completely reset the trace to avoid inconsistent dump on abort. */ + J->cur.nins = J->cur.nk = REF_BASE; + J->cur.nsnap = 0; + lj_err_throw(J->L, errcode); /* Propagate errors. */ + } + } +} + +#undef IR + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_parse.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_parse.c new file mode 100644 index 000000000..abfac3c0c --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_parse.c @@ -0,0 +1,2754 @@ +/* +** Lua parser (source code -> bytecode). +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lj_parse_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_debug.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_func.h" +#include "lj_state.h" +#include "lj_bc.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#endif +#include "lj_lex.h" +#include "lj_parse.h" +#include "lj_vm.h" +#include "lj_vmevent.h" + +/* -- Parser structures and definitions ----------------------------------- */ + +/* Expression kinds. */ +typedef enum { + /* Constant expressions must be first and in this order: */ + VKNIL, + VKFALSE, + VKTRUE, + VKSTR, /* sval = string value */ + VKNUM, /* nval = number value */ + VKLAST = VKNUM, + VKCDATA, /* nval = cdata value, not treated as a constant expression */ + /* Non-constant expressions follow: */ + VLOCAL, /* info = local register, aux = vstack index */ + VUPVAL, /* info = upvalue index, aux = vstack index */ + VGLOBAL, /* sval = string value */ + VINDEXED, /* info = table register, aux = index reg/byte/string const */ + VJMP, /* info = instruction PC */ + VRELOCABLE, /* info = instruction PC */ + VNONRELOC, /* info = result register */ + VCALL, /* info = instruction PC, aux = base */ + VVOID +} ExpKind; + +/* Expression descriptor. */ +typedef struct ExpDesc { + union { + struct { + uint32_t info; /* Primary info. */ + uint32_t aux; /* Secondary info. */ + } s; + TValue nval; /* Number value. */ + GCstr *sval; /* String value. */ + } u; + ExpKind k; + BCPos t; /* True condition jump list. */ + BCPos f; /* False condition jump list. */ +} ExpDesc; + +/* Macros for expressions. */ +#define expr_hasjump(e) ((e)->t != (e)->f) + +#define expr_isk(e) ((e)->k <= VKLAST) +#define expr_isk_nojump(e) (expr_isk(e) && !expr_hasjump(e)) +#define expr_isnumk(e) ((e)->k == VKNUM) +#define expr_isnumk_nojump(e) (expr_isnumk(e) && !expr_hasjump(e)) +#define expr_isstrk(e) ((e)->k == VKSTR) + +#define expr_numtv(e) check_exp(expr_isnumk((e)), &(e)->u.nval) +#define expr_numberV(e) numberVnum(expr_numtv((e))) + +/* Initialize expression. */ +static LJ_AINLINE void expr_init(ExpDesc *e, ExpKind k, uint32_t info) +{ + e->k = k; + e->u.s.info = info; + e->f = e->t = NO_JMP; +} + +/* Check number constant for +-0. */ +static int expr_numiszero(ExpDesc *e) +{ + TValue *o = expr_numtv(e); + return tvisint(o) ? (intV(o) == 0) : tviszero(o); +} + +/* Per-function linked list of scope blocks. */ +typedef struct FuncScope { + struct FuncScope *prev; /* Link to outer scope. */ + MSize vstart; /* Start of block-local variables. */ + uint8_t nactvar; /* Number of active vars outside the scope. */ + uint8_t flags; /* Scope flags. */ +} FuncScope; + +#define FSCOPE_LOOP 0x01 /* Scope is a (breakable) loop. */ +#define FSCOPE_BREAK 0x02 /* Break used in scope. */ +#define FSCOPE_GOLA 0x04 /* Goto or label used in scope. */ +#define FSCOPE_UPVAL 0x08 /* Upvalue in scope. */ +#define FSCOPE_NOCLOSE 0x10 /* Do not close upvalues. */ + +#define NAME_BREAK ((GCstr *)(uintptr_t)1) + +/* Index into variable stack. */ +typedef uint16_t VarIndex; +#define LJ_MAX_VSTACK (65536 - LJ_MAX_UPVAL) + +/* Variable/goto/label info. */ +#define VSTACK_VAR_RW 0x01 /* R/W variable. */ +#define VSTACK_GOTO 0x02 /* Pending goto. */ +#define VSTACK_LABEL 0x04 /* Label. */ + +/* Per-function state. */ +typedef struct FuncState { + GCtab *kt; /* Hash table for constants. */ + LexState *ls; /* Lexer state. */ + lua_State *L; /* Lua state. */ + FuncScope *bl; /* Current scope. */ + struct FuncState *prev; /* Enclosing function. */ + BCPos pc; /* Next bytecode position. */ + BCPos lasttarget; /* Bytecode position of last jump target. */ + BCPos jpc; /* Pending jump list to next bytecode. */ + BCReg freereg; /* First free register. */ + BCReg nactvar; /* Number of active local variables. */ + BCReg nkn, nkgc; /* Number of lua_Number/GCobj constants */ + BCLine linedefined; /* First line of the function definition. */ + BCInsLine *bcbase; /* Base of bytecode stack. */ + BCPos bclim; /* Limit of bytecode stack. */ + MSize vbase; /* Base of variable stack for this function. */ + uint8_t flags; /* Prototype flags. */ + uint8_t numparams; /* Number of parameters. */ + uint8_t framesize; /* Fixed frame size. */ + uint8_t nuv; /* Number of upvalues */ + VarIndex varmap[LJ_MAX_LOCVAR]; /* Map from register to variable idx. */ + VarIndex uvmap[LJ_MAX_UPVAL]; /* Map from upvalue to variable idx. */ + VarIndex uvtmp[LJ_MAX_UPVAL]; /* Temporary upvalue map. */ +} FuncState; + +/* Binary and unary operators. ORDER OPR */ +typedef enum BinOpr { + OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, /* ORDER ARITH */ + OPR_CONCAT, + OPR_NE, OPR_EQ, + OPR_LT, OPR_GE, OPR_LE, OPR_GT, + OPR_AND, OPR_OR, + OPR_NOBINOPR +} BinOpr; + +LJ_STATIC_ASSERT((int)BC_ISGE-(int)BC_ISLT == (int)OPR_GE-(int)OPR_LT); +LJ_STATIC_ASSERT((int)BC_ISLE-(int)BC_ISLT == (int)OPR_LE-(int)OPR_LT); +LJ_STATIC_ASSERT((int)BC_ISGT-(int)BC_ISLT == (int)OPR_GT-(int)OPR_LT); +LJ_STATIC_ASSERT((int)BC_SUBVV-(int)BC_ADDVV == (int)OPR_SUB-(int)OPR_ADD); +LJ_STATIC_ASSERT((int)BC_MULVV-(int)BC_ADDVV == (int)OPR_MUL-(int)OPR_ADD); +LJ_STATIC_ASSERT((int)BC_DIVVV-(int)BC_ADDVV == (int)OPR_DIV-(int)OPR_ADD); +LJ_STATIC_ASSERT((int)BC_MODVV-(int)BC_ADDVV == (int)OPR_MOD-(int)OPR_ADD); + +/* -- Error handling ------------------------------------------------------ */ + +LJ_NORET LJ_NOINLINE static void err_syntax(LexState *ls, ErrMsg em) +{ + lj_lex_error(ls, ls->token, em); +} + +LJ_NORET LJ_NOINLINE static void err_token(LexState *ls, LexToken token) +{ + lj_lex_error(ls, ls->token, LJ_ERR_XTOKEN, lj_lex_token2str(ls, token)); +} + +LJ_NORET static void err_limit(FuncState *fs, uint32_t limit, const char *what) +{ + if (fs->linedefined == 0) + lj_lex_error(fs->ls, 0, LJ_ERR_XLIMM, limit, what); + else + lj_lex_error(fs->ls, 0, LJ_ERR_XLIMF, fs->linedefined, limit, what); +} + +#define checklimit(fs, v, l, m) if ((v) >= (l)) err_limit(fs, l, m) +#define checklimitgt(fs, v, l, m) if ((v) > (l)) err_limit(fs, l, m) +#define checkcond(ls, c, em) { if (!(c)) err_syntax(ls, em); } + +/* -- Management of constants --------------------------------------------- */ + +/* Return bytecode encoding for primitive constant. */ +#define const_pri(e) check_exp((e)->k <= VKTRUE, (e)->k) + +#define tvhaskslot(o) ((o)->u32.hi == 0) +#define tvkslot(o) ((o)->u32.lo) + +/* Add a number constant. */ +static BCReg const_num(FuncState *fs, ExpDesc *e) +{ + lua_State *L = fs->L; + TValue *o; + lua_assert(expr_isnumk(e)); + o = lj_tab_set(L, fs->kt, &e->u.nval); + if (tvhaskslot(o)) + return tvkslot(o); + o->u64 = fs->nkn; + return fs->nkn++; +} + +/* Add a GC object constant. */ +static BCReg const_gc(FuncState *fs, GCobj *gc, uint32_t itype) +{ + lua_State *L = fs->L; + TValue key, *o; + setgcV(L, &key, gc, itype); + /* NOBARRIER: the key is new or kept alive. */ + o = lj_tab_set(L, fs->kt, &key); + if (tvhaskslot(o)) + return tvkslot(o); + o->u64 = fs->nkgc; + return fs->nkgc++; +} + +/* Add a string constant. */ +static BCReg const_str(FuncState *fs, ExpDesc *e) +{ + lua_assert(expr_isstrk(e) || e->k == VGLOBAL); + return const_gc(fs, obj2gco(e->u.sval), LJ_TSTR); +} + +/* Anchor string constant to avoid GC. */ +GCstr *lj_parse_keepstr(LexState *ls, const char *str, size_t len) +{ + /* NOBARRIER: the key is new or kept alive. */ + lua_State *L = ls->L; + GCstr *s = lj_str_new(L, str, len); + TValue *tv = lj_tab_setstr(L, ls->fs->kt, s); + if (tvisnil(tv)) setboolV(tv, 1); + lj_gc_check(L); + return s; +} + +#if LJ_HASFFI +/* Anchor cdata to avoid GC. */ +void lj_parse_keepcdata(LexState *ls, TValue *tv, GCcdata *cd) +{ + /* NOBARRIER: the key is new or kept alive. */ + lua_State *L = ls->L; + setcdataV(L, tv, cd); + setboolV(lj_tab_set(L, ls->fs->kt, tv), 1); +} +#endif + +/* -- Jump list handling -------------------------------------------------- */ + +/* Get next element in jump list. */ +static BCPos jmp_next(FuncState *fs, BCPos pc) +{ + ptrdiff_t delta = bc_j(fs->bcbase[pc].ins); + if ((BCPos)delta == NO_JMP) + return NO_JMP; + else + return (BCPos)(((ptrdiff_t)pc+1)+delta); +} + +/* Check if any of the instructions on the jump list produce no value. */ +static int jmp_novalue(FuncState *fs, BCPos list) +{ + for (; list != NO_JMP; list = jmp_next(fs, list)) { + BCIns p = fs->bcbase[list >= 1 ? list-1 : list].ins; + if (!(bc_op(p) == BC_ISTC || bc_op(p) == BC_ISFC || bc_a(p) == NO_REG)) + return 1; + } + return 0; +} + +/* Patch register of test instructions. */ +static int jmp_patchtestreg(FuncState *fs, BCPos pc, BCReg reg) +{ + BCInsLine *ilp = &fs->bcbase[pc >= 1 ? pc-1 : pc]; + BCOp op = bc_op(ilp->ins); + if (op == BC_ISTC || op == BC_ISFC) { + if (reg != NO_REG && reg != bc_d(ilp->ins)) { + setbc_a(&ilp->ins, reg); + } else { /* Nothing to store or already in the right register. */ + setbc_op(&ilp->ins, op+(BC_IST-BC_ISTC)); + setbc_a(&ilp->ins, 0); + } + } else if (bc_a(ilp->ins) == NO_REG) { + if (reg == NO_REG) { + ilp->ins = BCINS_AJ(BC_JMP, bc_a(fs->bcbase[pc].ins), 0); + } else { + setbc_a(&ilp->ins, reg); + if (reg >= bc_a(ilp[1].ins)) + setbc_a(&ilp[1].ins, reg+1); + } + } else { + return 0; /* Cannot patch other instructions. */ + } + return 1; +} + +/* Drop values for all instructions on jump list. */ +static void jmp_dropval(FuncState *fs, BCPos list) +{ + for (; list != NO_JMP; list = jmp_next(fs, list)) + jmp_patchtestreg(fs, list, NO_REG); +} + +/* Patch jump instruction to target. */ +static void jmp_patchins(FuncState *fs, BCPos pc, BCPos dest) +{ + BCIns *jmp = &fs->bcbase[pc].ins; + BCPos offset = dest-(pc+1)+BCBIAS_J; + lua_assert(dest != NO_JMP); + if (offset > BCMAX_D) + err_syntax(fs->ls, LJ_ERR_XJUMP); + setbc_d(jmp, offset); +} + +/* Append to jump list. */ +static void jmp_append(FuncState *fs, BCPos *l1, BCPos l2) +{ + if (l2 == NO_JMP) { + return; + } else if (*l1 == NO_JMP) { + *l1 = l2; + } else { + BCPos list = *l1; + BCPos next; + while ((next = jmp_next(fs, list)) != NO_JMP) /* Find last element. */ + list = next; + jmp_patchins(fs, list, l2); + } +} + +/* Patch jump list and preserve produced values. */ +static void jmp_patchval(FuncState *fs, BCPos list, BCPos vtarget, + BCReg reg, BCPos dtarget) +{ + while (list != NO_JMP) { + BCPos next = jmp_next(fs, list); + if (jmp_patchtestreg(fs, list, reg)) + jmp_patchins(fs, list, vtarget); /* Jump to target with value. */ + else + jmp_patchins(fs, list, dtarget); /* Jump to default target. */ + list = next; + } +} + +/* Jump to following instruction. Append to list of pending jumps. */ +static void jmp_tohere(FuncState *fs, BCPos list) +{ + fs->lasttarget = fs->pc; + jmp_append(fs, &fs->jpc, list); +} + +/* Patch jump list to target. */ +static void jmp_patch(FuncState *fs, BCPos list, BCPos target) +{ + if (target == fs->pc) { + jmp_tohere(fs, list); + } else { + lua_assert(target < fs->pc); + jmp_patchval(fs, list, target, NO_REG, target); + } +} + +/* -- Bytecode register allocator ----------------------------------------- */ + +/* Bump frame size. */ +static void bcreg_bump(FuncState *fs, BCReg n) +{ + BCReg sz = fs->freereg + n; + if (sz > fs->framesize) { + if (sz >= LJ_MAX_SLOTS) + err_syntax(fs->ls, LJ_ERR_XSLOTS); + fs->framesize = (uint8_t)sz; + } +} + +/* Reserve registers. */ +static void bcreg_reserve(FuncState *fs, BCReg n) +{ + bcreg_bump(fs, n); + fs->freereg += n; +} + +/* Free register. */ +static void bcreg_free(FuncState *fs, BCReg reg) +{ + if (reg >= fs->nactvar) { + fs->freereg--; + lua_assert(reg == fs->freereg); + } +} + +/* Free register for expression. */ +static void expr_free(FuncState *fs, ExpDesc *e) +{ + if (e->k == VNONRELOC) + bcreg_free(fs, e->u.s.info); +} + +/* -- Bytecode emitter ---------------------------------------------------- */ + +/* Emit bytecode instruction. */ +static BCPos bcemit_INS(FuncState *fs, BCIns ins) +{ + BCPos pc = fs->pc; + LexState *ls = fs->ls; + jmp_patchval(fs, fs->jpc, pc, NO_REG, pc); + fs->jpc = NO_JMP; + if (LJ_UNLIKELY(pc >= fs->bclim)) { + ptrdiff_t base = fs->bcbase - ls->bcstack; + checklimit(fs, ls->sizebcstack, LJ_MAX_BCINS, "bytecode instructions"); + lj_mem_growvec(fs->L, ls->bcstack, ls->sizebcstack, LJ_MAX_BCINS,BCInsLine); + fs->bclim = (BCPos)(ls->sizebcstack - base); + fs->bcbase = ls->bcstack + base; + } + fs->bcbase[pc].ins = ins; + fs->bcbase[pc].line = ls->lastline; + fs->pc = pc+1; + return pc; +} + +#define bcemit_ABC(fs, o, a, b, c) bcemit_INS(fs, BCINS_ABC(o, a, b, c)) +#define bcemit_AD(fs, o, a, d) bcemit_INS(fs, BCINS_AD(o, a, d)) +#define bcemit_AJ(fs, o, a, j) bcemit_INS(fs, BCINS_AJ(o, a, j)) + +#define bcptr(fs, e) (&(fs)->bcbase[(e)->u.s.info].ins) + +/* -- Bytecode emitter for expressions ------------------------------------ */ + +/* Discharge non-constant expression to any register. */ +static void expr_discharge(FuncState *fs, ExpDesc *e) +{ + BCIns ins; + if (e->k == VUPVAL) { + ins = BCINS_AD(BC_UGET, 0, e->u.s.info); + } else if (e->k == VGLOBAL) { + ins = BCINS_AD(BC_GGET, 0, const_str(fs, e)); + } else if (e->k == VINDEXED) { + BCReg rc = e->u.s.aux; + if ((int32_t)rc < 0) { + ins = BCINS_ABC(BC_TGETS, 0, e->u.s.info, ~rc); + } else if (rc > BCMAX_C) { + ins = BCINS_ABC(BC_TGETB, 0, e->u.s.info, rc-(BCMAX_C+1)); + } else { + bcreg_free(fs, rc); + ins = BCINS_ABC(BC_TGETV, 0, e->u.s.info, rc); + } + bcreg_free(fs, e->u.s.info); + } else if (e->k == VCALL) { + e->u.s.info = e->u.s.aux; + e->k = VNONRELOC; + return; + } else if (e->k == VLOCAL) { + e->k = VNONRELOC; + return; + } else { + return; + } + e->u.s.info = bcemit_INS(fs, ins); + e->k = VRELOCABLE; +} + +/* Emit bytecode to set a range of registers to nil. */ +static void bcemit_nil(FuncState *fs, BCReg from, BCReg n) +{ + if (fs->pc > fs->lasttarget) { /* No jumps to current position? */ + BCIns *ip = &fs->bcbase[fs->pc-1].ins; + BCReg pto, pfrom = bc_a(*ip); + switch (bc_op(*ip)) { /* Try to merge with the previous instruction. */ + case BC_KPRI: + if (bc_d(*ip) != ~LJ_TNIL) break; + if (from == pfrom) { + if (n == 1) return; + } else if (from == pfrom+1) { + from = pfrom; + n++; + } else { + break; + } + *ip = BCINS_AD(BC_KNIL, from, from+n-1); /* Replace KPRI. */ + return; + case BC_KNIL: + pto = bc_d(*ip); + if (pfrom <= from && from <= pto+1) { /* Can we connect both ranges? */ + if (from+n-1 > pto) + setbc_d(ip, from+n-1); /* Patch previous instruction range. */ + return; + } + break; + default: + break; + } + } + /* Emit new instruction or replace old instruction. */ + bcemit_INS(fs, n == 1 ? BCINS_AD(BC_KPRI, from, VKNIL) : + BCINS_AD(BC_KNIL, from, from+n-1)); +} + +/* Discharge an expression to a specific register. Ignore branches. */ +static void expr_toreg_nobranch(FuncState *fs, ExpDesc *e, BCReg reg) +{ + BCIns ins; + expr_discharge(fs, e); + if (e->k == VKSTR) { + ins = BCINS_AD(BC_KSTR, reg, const_str(fs, e)); + } else if (e->k == VKNUM) { +#if LJ_DUALNUM + cTValue *tv = expr_numtv(e); + if (tvisint(tv) && checki16(intV(tv))) + ins = BCINS_AD(BC_KSHORT, reg, (BCReg)(uint16_t)intV(tv)); + else +#else + lua_Number n = expr_numberV(e); + int32_t k = lj_num2int(n); + if (checki16(k) && n == (lua_Number)k) + ins = BCINS_AD(BC_KSHORT, reg, (BCReg)(uint16_t)k); + else +#endif + ins = BCINS_AD(BC_KNUM, reg, const_num(fs, e)); +#if LJ_HASFFI + } else if (e->k == VKCDATA) { + fs->flags |= PROTO_FFI; + ins = BCINS_AD(BC_KCDATA, reg, + const_gc(fs, obj2gco(cdataV(&e->u.nval)), LJ_TCDATA)); +#endif + } else if (e->k == VRELOCABLE) { + setbc_a(bcptr(fs, e), reg); + goto noins; + } else if (e->k == VNONRELOC) { + if (reg == e->u.s.info) + goto noins; + ins = BCINS_AD(BC_MOV, reg, e->u.s.info); + } else if (e->k == VKNIL) { + bcemit_nil(fs, reg, 1); + goto noins; + } else if (e->k <= VKTRUE) { + ins = BCINS_AD(BC_KPRI, reg, const_pri(e)); + } else { + lua_assert(e->k == VVOID || e->k == VJMP); + return; + } + bcemit_INS(fs, ins); +noins: + e->u.s.info = reg; + e->k = VNONRELOC; +} + +/* Forward declaration. */ +static BCPos bcemit_jmp(FuncState *fs); + +/* Discharge an expression to a specific register. */ +static void expr_toreg(FuncState *fs, ExpDesc *e, BCReg reg) +{ + expr_toreg_nobranch(fs, e, reg); + if (e->k == VJMP) + jmp_append(fs, &e->t, e->u.s.info); /* Add it to the true jump list. */ + if (expr_hasjump(e)) { /* Discharge expression with branches. */ + BCPos jend, jfalse = NO_JMP, jtrue = NO_JMP; + if (jmp_novalue(fs, e->t) || jmp_novalue(fs, e->f)) { + BCPos jval = (e->k == VJMP) ? NO_JMP : bcemit_jmp(fs); + jfalse = bcemit_AD(fs, BC_KPRI, reg, VKFALSE); + bcemit_AJ(fs, BC_JMP, fs->freereg, 1); + jtrue = bcemit_AD(fs, BC_KPRI, reg, VKTRUE); + jmp_tohere(fs, jval); + } + jend = fs->pc; + fs->lasttarget = jend; + jmp_patchval(fs, e->f, jend, reg, jfalse); + jmp_patchval(fs, e->t, jend, reg, jtrue); + } + e->f = e->t = NO_JMP; + e->u.s.info = reg; + e->k = VNONRELOC; +} + +/* Discharge an expression to the next free register. */ +static void expr_tonextreg(FuncState *fs, ExpDesc *e) +{ + expr_discharge(fs, e); + expr_free(fs, e); + bcreg_reserve(fs, 1); + expr_toreg(fs, e, fs->freereg - 1); +} + +/* Discharge an expression to any register. */ +static BCReg expr_toanyreg(FuncState *fs, ExpDesc *e) +{ + expr_discharge(fs, e); + if (e->k == VNONRELOC) { + if (!expr_hasjump(e)) return e->u.s.info; /* Already in a register. */ + if (e->u.s.info >= fs->nactvar) { + expr_toreg(fs, e, e->u.s.info); /* Discharge to temp. register. */ + return e->u.s.info; + } + } + expr_tonextreg(fs, e); /* Discharge to next register. */ + return e->u.s.info; +} + +/* Partially discharge expression to a value. */ +static void expr_toval(FuncState *fs, ExpDesc *e) +{ + if (expr_hasjump(e)) + expr_toanyreg(fs, e); + else + expr_discharge(fs, e); +} + +/* Emit store for LHS expression. */ +static void bcemit_store(FuncState *fs, ExpDesc *var, ExpDesc *e) +{ + BCIns ins; + if (var->k == VLOCAL) { + fs->ls->vstack[var->u.s.aux].info |= VSTACK_VAR_RW; + expr_free(fs, e); + expr_toreg(fs, e, var->u.s.info); + return; + } else if (var->k == VUPVAL) { + fs->ls->vstack[var->u.s.aux].info |= VSTACK_VAR_RW; + expr_toval(fs, e); + if (e->k <= VKTRUE) + ins = BCINS_AD(BC_USETP, var->u.s.info, const_pri(e)); + else if (e->k == VKSTR) + ins = BCINS_AD(BC_USETS, var->u.s.info, const_str(fs, e)); + else if (e->k == VKNUM) + ins = BCINS_AD(BC_USETN, var->u.s.info, const_num(fs, e)); + else + ins = BCINS_AD(BC_USETV, var->u.s.info, expr_toanyreg(fs, e)); + } else if (var->k == VGLOBAL) { + BCReg ra = expr_toanyreg(fs, e); + ins = BCINS_AD(BC_GSET, ra, const_str(fs, var)); + } else { + BCReg ra, rc; + lua_assert(var->k == VINDEXED); + ra = expr_toanyreg(fs, e); + rc = var->u.s.aux; + if ((int32_t)rc < 0) { + ins = BCINS_ABC(BC_TSETS, ra, var->u.s.info, ~rc); + } else if (rc > BCMAX_C) { + ins = BCINS_ABC(BC_TSETB, ra, var->u.s.info, rc-(BCMAX_C+1)); + } else { + /* Free late alloced key reg to avoid assert on free of value reg. */ + /* This can only happen when called from expr_table(). */ + lua_assert(e->k != VNONRELOC || ra < fs->nactvar || + rc < ra || (bcreg_free(fs, rc),1)); + ins = BCINS_ABC(BC_TSETV, ra, var->u.s.info, rc); + } + } + bcemit_INS(fs, ins); + expr_free(fs, e); +} + +/* Emit method lookup expression. */ +static void bcemit_method(FuncState *fs, ExpDesc *e, ExpDesc *key) +{ + BCReg idx, func, obj = expr_toanyreg(fs, e); + expr_free(fs, e); + func = fs->freereg; + bcemit_AD(fs, BC_MOV, func+1, obj); /* Copy object to first argument. */ + lua_assert(expr_isstrk(key)); + idx = const_str(fs, key); + if (idx <= BCMAX_C) { + bcreg_reserve(fs, 2); + bcemit_ABC(fs, BC_TGETS, func, obj, idx); + } else { + bcreg_reserve(fs, 3); + bcemit_AD(fs, BC_KSTR, func+2, idx); + bcemit_ABC(fs, BC_TGETV, func, obj, func+2); + fs->freereg--; + } + e->u.s.info = func; + e->k = VNONRELOC; +} + +/* -- Bytecode emitter for branches --------------------------------------- */ + +/* Emit unconditional branch. */ +static BCPos bcemit_jmp(FuncState *fs) +{ + BCPos jpc = fs->jpc; + BCPos j = fs->pc - 1; + BCIns *ip = &fs->bcbase[j].ins; + fs->jpc = NO_JMP; + if ((int32_t)j >= (int32_t)fs->lasttarget && bc_op(*ip) == BC_UCLO) { + setbc_j(ip, NO_JMP); + fs->lasttarget = j+1; + } else { + j = bcemit_AJ(fs, BC_JMP, fs->freereg, NO_JMP); + } + jmp_append(fs, &j, jpc); + return j; +} + +/* Invert branch condition of bytecode instruction. */ +static void invertcond(FuncState *fs, ExpDesc *e) +{ + BCIns *ip = &fs->bcbase[e->u.s.info - 1].ins; + setbc_op(ip, bc_op(*ip)^1); +} + +/* Emit conditional branch. */ +static BCPos bcemit_branch(FuncState *fs, ExpDesc *e, int cond) +{ + BCPos pc; + if (e->k == VRELOCABLE) { + BCIns *ip = bcptr(fs, e); + if (bc_op(*ip) == BC_NOT) { + *ip = BCINS_AD(cond ? BC_ISF : BC_IST, 0, bc_d(*ip)); + return bcemit_jmp(fs); + } + } + if (e->k != VNONRELOC) { + bcreg_reserve(fs, 1); + expr_toreg_nobranch(fs, e, fs->freereg-1); + } + bcemit_AD(fs, cond ? BC_ISTC : BC_ISFC, NO_REG, e->u.s.info); + pc = bcemit_jmp(fs); + expr_free(fs, e); + return pc; +} + +/* Emit branch on true condition. */ +static void bcemit_branch_t(FuncState *fs, ExpDesc *e) +{ + BCPos pc; + expr_discharge(fs, e); + if (e->k == VKSTR || e->k == VKNUM || e->k == VKTRUE) + pc = NO_JMP; /* Never jump. */ + else if (e->k == VJMP) + invertcond(fs, e), pc = e->u.s.info; + else if (e->k == VKFALSE || e->k == VKNIL) + expr_toreg_nobranch(fs, e, NO_REG), pc = bcemit_jmp(fs); + else + pc = bcemit_branch(fs, e, 0); + jmp_append(fs, &e->f, pc); + jmp_tohere(fs, e->t); + e->t = NO_JMP; +} + +/* Emit branch on false condition. */ +static void bcemit_branch_f(FuncState *fs, ExpDesc *e) +{ + BCPos pc; + expr_discharge(fs, e); + if (e->k == VKNIL || e->k == VKFALSE) + pc = NO_JMP; /* Never jump. */ + else if (e->k == VJMP) + pc = e->u.s.info; + else if (e->k == VKSTR || e->k == VKNUM || e->k == VKTRUE) + expr_toreg_nobranch(fs, e, NO_REG), pc = bcemit_jmp(fs); + else + pc = bcemit_branch(fs, e, 1); + jmp_append(fs, &e->t, pc); + jmp_tohere(fs, e->f); + e->f = NO_JMP; +} + +/* -- Bytecode emitter for operators -------------------------------------- */ + +/* Try constant-folding of arithmetic operators. */ +static int foldarith(BinOpr opr, ExpDesc *e1, ExpDesc *e2) +{ + TValue o; + lua_Number n; + if (!expr_isnumk_nojump(e1) || !expr_isnumk_nojump(e2)) return 0; + n = lj_vm_foldarith(expr_numberV(e1), expr_numberV(e2), (int)opr-OPR_ADD); + setnumV(&o, n); + if (tvisnan(&o) || tvismzero(&o)) return 0; /* Avoid NaN and -0 as consts. */ + if (LJ_DUALNUM) { + int32_t k = lj_num2int(n); + if ((lua_Number)k == n) { + setintV(&e1->u.nval, k); + return 1; + } + } + setnumV(&e1->u.nval, n); + return 1; +} + +/* Emit arithmetic operator. */ +static void bcemit_arith(FuncState *fs, BinOpr opr, ExpDesc *e1, ExpDesc *e2) +{ + BCReg rb, rc, t; + uint32_t op; + if (foldarith(opr, e1, e2)) + return; + if (opr == OPR_POW) { + op = BC_POW; + rc = expr_toanyreg(fs, e2); + rb = expr_toanyreg(fs, e1); + } else { + op = opr-OPR_ADD+BC_ADDVV; + /* Must discharge 2nd operand first since VINDEXED might free regs. */ + expr_toval(fs, e2); + if (expr_isnumk(e2) && (rc = const_num(fs, e2)) <= BCMAX_C) + op -= BC_ADDVV-BC_ADDVN; + else + rc = expr_toanyreg(fs, e2); + /* 1st operand discharged by bcemit_binop_left, but need KNUM/KSHORT. */ + lua_assert(expr_isnumk(e1) || e1->k == VNONRELOC); + expr_toval(fs, e1); + /* Avoid two consts to satisfy bytecode constraints. */ + if (expr_isnumk(e1) && !expr_isnumk(e2) && + (t = const_num(fs, e1)) <= BCMAX_B) { + rb = rc; rc = t; op -= BC_ADDVV-BC_ADDNV; + } else { + rb = expr_toanyreg(fs, e1); + } + } + /* Using expr_free might cause asserts if the order is wrong. */ + if (e1->k == VNONRELOC && e1->u.s.info >= fs->nactvar) fs->freereg--; + if (e2->k == VNONRELOC && e2->u.s.info >= fs->nactvar) fs->freereg--; + e1->u.s.info = bcemit_ABC(fs, op, 0, rb, rc); + e1->k = VRELOCABLE; +} + +/* Emit comparison operator. */ +static void bcemit_comp(FuncState *fs, BinOpr opr, ExpDesc *e1, ExpDesc *e2) +{ + ExpDesc *eret = e1; + BCIns ins; + expr_toval(fs, e1); + if (opr == OPR_EQ || opr == OPR_NE) { + BCOp op = opr == OPR_EQ ? BC_ISEQV : BC_ISNEV; + BCReg ra; + if (expr_isk(e1)) { e1 = e2; e2 = eret; } /* Need constant in 2nd arg. */ + ra = expr_toanyreg(fs, e1); /* First arg must be in a reg. */ + expr_toval(fs, e2); + switch (e2->k) { + case VKNIL: case VKFALSE: case VKTRUE: + ins = BCINS_AD(op+(BC_ISEQP-BC_ISEQV), ra, const_pri(e2)); + break; + case VKSTR: + ins = BCINS_AD(op+(BC_ISEQS-BC_ISEQV), ra, const_str(fs, e2)); + break; + case VKNUM: + ins = BCINS_AD(op+(BC_ISEQN-BC_ISEQV), ra, const_num(fs, e2)); + break; + default: + ins = BCINS_AD(op, ra, expr_toanyreg(fs, e2)); + break; + } + } else { + uint32_t op = opr-OPR_LT+BC_ISLT; + BCReg ra, rd; + if ((op-BC_ISLT) & 1) { /* GT -> LT, GE -> LE */ + e1 = e2; e2 = eret; /* Swap operands. */ + op = ((op-BC_ISLT)^3)+BC_ISLT; + expr_toval(fs, e1); + } + rd = expr_toanyreg(fs, e2); + ra = expr_toanyreg(fs, e1); + ins = BCINS_AD(op, ra, rd); + } + /* Using expr_free might cause asserts if the order is wrong. */ + if (e1->k == VNONRELOC && e1->u.s.info >= fs->nactvar) fs->freereg--; + if (e2->k == VNONRELOC && e2->u.s.info >= fs->nactvar) fs->freereg--; + bcemit_INS(fs, ins); + eret->u.s.info = bcemit_jmp(fs); + eret->k = VJMP; +} + +/* Fixup left side of binary operator. */ +static void bcemit_binop_left(FuncState *fs, BinOpr op, ExpDesc *e) +{ + if (op == OPR_AND) { + bcemit_branch_t(fs, e); + } else if (op == OPR_OR) { + bcemit_branch_f(fs, e); + } else if (op == OPR_CONCAT) { + expr_tonextreg(fs, e); + } else if (op == OPR_EQ || op == OPR_NE) { + if (!expr_isk_nojump(e)) expr_toanyreg(fs, e); + } else { + if (!expr_isnumk_nojump(e)) expr_toanyreg(fs, e); + } +} + +/* Emit binary operator. */ +static void bcemit_binop(FuncState *fs, BinOpr op, ExpDesc *e1, ExpDesc *e2) +{ + if (op <= OPR_POW) { + bcemit_arith(fs, op, e1, e2); + } else if (op == OPR_AND) { + lua_assert(e1->t == NO_JMP); /* List must be closed. */ + expr_discharge(fs, e2); + jmp_append(fs, &e2->f, e1->f); + *e1 = *e2; + } else if (op == OPR_OR) { + lua_assert(e1->f == NO_JMP); /* List must be closed. */ + expr_discharge(fs, e2); + jmp_append(fs, &e2->t, e1->t); + *e1 = *e2; + } else if (op == OPR_CONCAT) { + expr_toval(fs, e2); + if (e2->k == VRELOCABLE && bc_op(*bcptr(fs, e2)) == BC_CAT) { + lua_assert(e1->u.s.info == bc_b(*bcptr(fs, e2))-1); + expr_free(fs, e1); + setbc_b(bcptr(fs, e2), e1->u.s.info); + e1->u.s.info = e2->u.s.info; + } else { + expr_tonextreg(fs, e2); + expr_free(fs, e2); + expr_free(fs, e1); + e1->u.s.info = bcemit_ABC(fs, BC_CAT, 0, e1->u.s.info, e2->u.s.info); + } + e1->k = VRELOCABLE; + } else { + lua_assert(op == OPR_NE || op == OPR_EQ || + op == OPR_LT || op == OPR_GE || op == OPR_LE || op == OPR_GT); + bcemit_comp(fs, op, e1, e2); + } +} + +/* Emit unary operator. */ +static void bcemit_unop(FuncState *fs, BCOp op, ExpDesc *e) +{ + if (op == BC_NOT) { + /* Swap true and false lists. */ + { BCPos temp = e->f; e->f = e->t; e->t = temp; } + jmp_dropval(fs, e->f); + jmp_dropval(fs, e->t); + expr_discharge(fs, e); + if (e->k == VKNIL || e->k == VKFALSE) { + e->k = VKTRUE; + return; + } else if (expr_isk(e) || (LJ_HASFFI && e->k == VKCDATA)) { + e->k = VKFALSE; + return; + } else if (e->k == VJMP) { + invertcond(fs, e); + return; + } else if (e->k == VRELOCABLE) { + bcreg_reserve(fs, 1); + setbc_a(bcptr(fs, e), fs->freereg-1); + e->u.s.info = fs->freereg-1; + e->k = VNONRELOC; + } else { + lua_assert(e->k == VNONRELOC); + } + } else { + lua_assert(op == BC_UNM || op == BC_LEN); + if (op == BC_UNM && !expr_hasjump(e)) { /* Constant-fold negations. */ +#if LJ_HASFFI + if (e->k == VKCDATA) { /* Fold in-place since cdata is not interned. */ + GCcdata *cd = cdataV(&e->u.nval); + int64_t *p = (int64_t *)cdataptr(cd); + if (cd->ctypeid == CTID_COMPLEX_DOUBLE) + p[1] ^= (int64_t)U64x(80000000,00000000); + else + *p = -*p; + return; + } else +#endif + if (expr_isnumk(e) && !expr_numiszero(e)) { /* Avoid folding to -0. */ + TValue *o = expr_numtv(e); + if (tvisint(o)) { + int32_t k = intV(o); + if (k == -k) + setnumV(o, -(lua_Number)k); + else + setintV(o, -k); + return; + } else { + o->u64 ^= U64x(80000000,00000000); + return; + } + } + } + expr_toanyreg(fs, e); + } + expr_free(fs, e); + e->u.s.info = bcemit_AD(fs, op, 0, e->u.s.info); + e->k = VRELOCABLE; +} + +/* -- Lexer support ------------------------------------------------------- */ + +/* Check and consume optional token. */ +static int lex_opt(LexState *ls, LexToken tok) +{ + if (ls->token == tok) { + lj_lex_next(ls); + return 1; + } + return 0; +} + +/* Check and consume token. */ +static void lex_check(LexState *ls, LexToken tok) +{ + if (ls->token != tok) + err_token(ls, tok); + lj_lex_next(ls); +} + +/* Check for matching token. */ +static void lex_match(LexState *ls, LexToken what, LexToken who, BCLine line) +{ + if (!lex_opt(ls, what)) { + if (line == ls->linenumber) { + err_token(ls, what); + } else { + const char *swhat = lj_lex_token2str(ls, what); + const char *swho = lj_lex_token2str(ls, who); + lj_lex_error(ls, ls->token, LJ_ERR_XMATCH, swhat, swho, line); + } + } +} + +/* Check for string token. */ +static GCstr *lex_str(LexState *ls) +{ + GCstr *s; + if (ls->token != TK_name && (LJ_52 || ls->token != TK_goto)) + err_token(ls, TK_name); + s = strV(&ls->tokenval); + lj_lex_next(ls); + return s; +} + +/* -- Variable handling --------------------------------------------------- */ + +#define var_get(ls, fs, i) ((ls)->vstack[(fs)->varmap[(i)]]) + +/* Define a new local variable. */ +static void var_new(LexState *ls, BCReg n, GCstr *name) +{ + FuncState *fs = ls->fs; + MSize vtop = ls->vtop; + checklimit(fs, fs->nactvar+n, LJ_MAX_LOCVAR, "local variables"); + if (LJ_UNLIKELY(vtop >= ls->sizevstack)) { + if (ls->sizevstack >= LJ_MAX_VSTACK) + lj_lex_error(ls, 0, LJ_ERR_XLIMC, LJ_MAX_VSTACK); + lj_mem_growvec(ls->L, ls->vstack, ls->sizevstack, LJ_MAX_VSTACK, VarInfo); + } + lua_assert((uintptr_t)name < VARNAME__MAX || + lj_tab_getstr(fs->kt, name) != NULL); + /* NOBARRIER: name is anchored in fs->kt and ls->vstack is not a GCobj. */ + setgcref(ls->vstack[vtop].name, obj2gco(name)); + fs->varmap[fs->nactvar+n] = (uint16_t)vtop; + ls->vtop = vtop+1; +} + +#define var_new_lit(ls, n, v) \ + var_new(ls, (n), lj_parse_keepstr(ls, "" v, sizeof(v)-1)) + +#define var_new_fixed(ls, n, vn) \ + var_new(ls, (n), (GCstr *)(uintptr_t)(vn)) + +/* Add local variables. */ +static void var_add(LexState *ls, BCReg nvars) +{ + FuncState *fs = ls->fs; + BCReg nactvar = fs->nactvar; + while (nvars--) { + VarInfo *v = &var_get(ls, fs, nactvar); + v->startpc = fs->pc; + v->slot = nactvar++; + v->info = 0; + } + fs->nactvar = nactvar; +} + +/* Remove local variables. */ +static void var_remove(LexState *ls, BCReg tolevel) +{ + FuncState *fs = ls->fs; + while (fs->nactvar > tolevel) + var_get(ls, fs, --fs->nactvar).endpc = fs->pc; +} + +/* Lookup local variable name. */ +static BCReg var_lookup_local(FuncState *fs, GCstr *n) +{ + int i; + for (i = fs->nactvar-1; i >= 0; i--) { + if (n == strref(var_get(fs->ls, fs, i).name)) + return (BCReg)i; + } + return (BCReg)-1; /* Not found. */ +} + +/* Lookup or add upvalue index. */ +static MSize var_lookup_uv(FuncState *fs, MSize vidx, ExpDesc *e) +{ + MSize i, n = fs->nuv; + for (i = 0; i < n; i++) + if (fs->uvmap[i] == vidx) + return i; /* Already exists. */ + /* Otherwise create a new one. */ + checklimit(fs, fs->nuv, LJ_MAX_UPVAL, "upvalues"); + lua_assert(e->k == VLOCAL || e->k == VUPVAL); + fs->uvmap[n] = (uint16_t)vidx; + fs->uvtmp[n] = (uint16_t)(e->k == VLOCAL ? vidx : LJ_MAX_VSTACK+e->u.s.info); + fs->nuv = n+1; + return n; +} + +/* Forward declaration. */ +static void fscope_uvmark(FuncState *fs, BCReg level); + +/* Recursively lookup variables in enclosing functions. */ +static MSize var_lookup_(FuncState *fs, GCstr *name, ExpDesc *e, int first) +{ + if (fs) { + BCReg reg = var_lookup_local(fs, name); + if ((int32_t)reg >= 0) { /* Local in this function? */ + expr_init(e, VLOCAL, reg); + if (!first) + fscope_uvmark(fs, reg); /* Scope now has an upvalue. */ + return (MSize)(e->u.s.aux = (uint32_t)fs->varmap[reg]); + } else { + MSize vidx = var_lookup_(fs->prev, name, e, 0); /* Var in outer func? */ + if ((int32_t)vidx >= 0) { /* Yes, make it an upvalue here. */ + e->u.s.info = (uint8_t)var_lookup_uv(fs, vidx, e); + e->k = VUPVAL; + return vidx; + } + } + } else { /* Not found in any function, must be a global. */ + expr_init(e, VGLOBAL, 0); + e->u.sval = name; + } + return (MSize)-1; /* Global. */ +} + +/* Lookup variable name. */ +#define var_lookup(ls, e) \ + var_lookup_((ls)->fs, lex_str(ls), (e), 1) + +/* -- Goto an label handling ---------------------------------------------- */ + +/* Add a new goto or label. */ +static MSize gola_new(LexState *ls, GCstr *name, uint8_t info, BCPos pc) +{ + FuncState *fs = ls->fs; + MSize vtop = ls->vtop; + if (LJ_UNLIKELY(vtop >= ls->sizevstack)) { + if (ls->sizevstack >= LJ_MAX_VSTACK) + lj_lex_error(ls, 0, LJ_ERR_XLIMC, LJ_MAX_VSTACK); + lj_mem_growvec(ls->L, ls->vstack, ls->sizevstack, LJ_MAX_VSTACK, VarInfo); + } + lua_assert(name == NAME_BREAK || lj_tab_getstr(fs->kt, name) != NULL); + /* NOBARRIER: name is anchored in fs->kt and ls->vstack is not a GCobj. */ + setgcref(ls->vstack[vtop].name, obj2gco(name)); + ls->vstack[vtop].startpc = pc; + ls->vstack[vtop].slot = (uint8_t)fs->nactvar; + ls->vstack[vtop].info = info; + ls->vtop = vtop+1; + return vtop; +} + +#define gola_isgoto(v) ((v)->info & VSTACK_GOTO) +#define gola_islabel(v) ((v)->info & VSTACK_LABEL) +#define gola_isgotolabel(v) ((v)->info & (VSTACK_GOTO|VSTACK_LABEL)) + +/* Patch goto to jump to label. */ +static void gola_patch(LexState *ls, VarInfo *vg, VarInfo *vl) +{ + FuncState *fs = ls->fs; + BCPos pc = vg->startpc; + setgcrefnull(vg->name); /* Invalidate pending goto. */ + setbc_a(&fs->bcbase[pc].ins, vl->slot); + jmp_patch(fs, pc, vl->startpc); +} + +/* Patch goto to close upvalues. */ +static void gola_close(LexState *ls, VarInfo *vg) +{ + FuncState *fs = ls->fs; + BCPos pc = vg->startpc; + BCIns *ip = &fs->bcbase[pc].ins; + lua_assert(gola_isgoto(vg)); + lua_assert(bc_op(*ip) == BC_JMP || bc_op(*ip) == BC_UCLO); + setbc_a(ip, vg->slot); + if (bc_op(*ip) == BC_JMP) { + BCPos next = jmp_next(fs, pc); + if (next != NO_JMP) jmp_patch(fs, next, pc); /* Jump to UCLO. */ + setbc_op(ip, BC_UCLO); /* Turn into UCLO. */ + setbc_j(ip, NO_JMP); + } +} + +/* Resolve pending forward gotos for label. */ +static void gola_resolve(LexState *ls, FuncScope *bl, MSize idx) +{ + VarInfo *vg = ls->vstack + bl->vstart; + VarInfo *vl = ls->vstack + idx; + for (; vg < vl; vg++) + if (gcrefeq(vg->name, vl->name) && gola_isgoto(vg)) { + if (vg->slot < vl->slot) { + GCstr *name = strref(var_get(ls, ls->fs, vg->slot).name); + lua_assert((uintptr_t)name >= VARNAME__MAX); + ls->linenumber = ls->fs->bcbase[vg->startpc].line; + lua_assert(strref(vg->name) != NAME_BREAK); + lj_lex_error(ls, 0, LJ_ERR_XGSCOPE, + strdata(strref(vg->name)), strdata(name)); + } + gola_patch(ls, vg, vl); + } +} + +/* Fixup remaining gotos and labels for scope. */ +static void gola_fixup(LexState *ls, FuncScope *bl) +{ + VarInfo *v = ls->vstack + bl->vstart; + VarInfo *ve = ls->vstack + ls->vtop; + for (; v < ve; v++) { + GCstr *name = strref(v->name); + if (name != NULL) { /* Only consider remaining valid gotos/labels. */ + if (gola_islabel(v)) { + VarInfo *vg; + setgcrefnull(v->name); /* Invalidate label that goes out of scope. */ + for (vg = v+1; vg < ve; vg++) /* Resolve pending backward gotos. */ + if (strref(vg->name) == name && gola_isgoto(vg)) { + if ((bl->flags&FSCOPE_UPVAL) && vg->slot > v->slot) + gola_close(ls, vg); + gola_patch(ls, vg, v); + } + } else if (gola_isgoto(v)) { + if (bl->prev) { /* Propagate goto or break to outer scope. */ + bl->prev->flags |= name == NAME_BREAK ? FSCOPE_BREAK : FSCOPE_GOLA; + v->slot = bl->nactvar; + if ((bl->flags & FSCOPE_UPVAL)) + gola_close(ls, v); + } else { /* No outer scope: undefined goto label or no loop. */ + ls->linenumber = ls->fs->bcbase[v->startpc].line; + if (name == NAME_BREAK) + lj_lex_error(ls, 0, LJ_ERR_XBREAK); + else + lj_lex_error(ls, 0, LJ_ERR_XLUNDEF, strdata(name)); + } + } + } + } +} + +/* Find existing label. */ +static VarInfo *gola_findlabel(LexState *ls, GCstr *name) +{ + VarInfo *v = ls->vstack + ls->fs->bl->vstart; + VarInfo *ve = ls->vstack + ls->vtop; + for (; v < ve; v++) + if (strref(v->name) == name && gola_islabel(v)) + return v; + return NULL; +} + +/* -- Scope handling ------------------------------------------------------ */ + +/* Begin a scope. */ +static void fscope_begin(FuncState *fs, FuncScope *bl, int flags) +{ + bl->nactvar = (uint8_t)fs->nactvar; + bl->flags = flags; + bl->vstart = fs->ls->vtop; + bl->prev = fs->bl; + fs->bl = bl; + lua_assert(fs->freereg == fs->nactvar); +} + +/* End a scope. */ +static void fscope_end(FuncState *fs) +{ + FuncScope *bl = fs->bl; + LexState *ls = fs->ls; + fs->bl = bl->prev; + var_remove(ls, bl->nactvar); + fs->freereg = fs->nactvar; + lua_assert(bl->nactvar == fs->nactvar); + if ((bl->flags & (FSCOPE_UPVAL|FSCOPE_NOCLOSE)) == FSCOPE_UPVAL) + bcemit_AJ(fs, BC_UCLO, bl->nactvar, 0); + if ((bl->flags & FSCOPE_BREAK)) { + if ((bl->flags & FSCOPE_LOOP)) { + MSize idx = gola_new(ls, NAME_BREAK, VSTACK_LABEL, fs->pc); + ls->vtop = idx; /* Drop break label immediately. */ + gola_resolve(ls, bl, idx); + return; + } /* else: need the fixup step to propagate the breaks. */ + } else if (!(bl->flags & FSCOPE_GOLA)) { + return; + } + gola_fixup(ls, bl); +} + +/* Mark scope as having an upvalue. */ +static void fscope_uvmark(FuncState *fs, BCReg level) +{ + FuncScope *bl; + for (bl = fs->bl; bl && bl->nactvar > level; bl = bl->prev) + ; + if (bl) + bl->flags |= FSCOPE_UPVAL; +} + +/* -- Function state management ------------------------------------------- */ + +/* Fixup bytecode for prototype. */ +static void fs_fixup_bc(FuncState *fs, GCproto *pt, BCIns *bc, MSize n) +{ + BCInsLine *base = fs->bcbase; + MSize i; + pt->sizebc = n; + bc[0] = BCINS_AD((fs->flags & PROTO_VARARG) ? BC_FUNCV : BC_FUNCF, + fs->framesize, 0); + for (i = 1; i < n; i++) + bc[i] = base[i].ins; +} + +/* Fixup upvalues for child prototype, step #2. */ +static void fs_fixup_uv2(FuncState *fs, GCproto *pt) +{ + VarInfo *vstack = fs->ls->vstack; + uint16_t *uv = proto_uv(pt); + MSize i, n = pt->sizeuv; + for (i = 0; i < n; i++) { + VarIndex vidx = uv[i]; + if (vidx >= LJ_MAX_VSTACK) + uv[i] = vidx - LJ_MAX_VSTACK; + else if ((vstack[vidx].info & VSTACK_VAR_RW)) + uv[i] = vstack[vidx].slot | PROTO_UV_LOCAL; + else + uv[i] = vstack[vidx].slot | PROTO_UV_LOCAL | PROTO_UV_IMMUTABLE; + } +} + +/* Fixup constants for prototype. */ +static void fs_fixup_k(FuncState *fs, GCproto *pt, void *kptr) +{ + GCtab *kt; + TValue *array; + Node *node; + MSize i, hmask; + checklimitgt(fs, fs->nkn, BCMAX_D+1, "constants"); + checklimitgt(fs, fs->nkgc, BCMAX_D+1, "constants"); + setmref(pt->k, kptr); + pt->sizekn = fs->nkn; + pt->sizekgc = fs->nkgc; + kt = fs->kt; + array = tvref(kt->array); + for (i = 0; i < kt->asize; i++) + if (tvhaskslot(&array[i])) { + TValue *tv = &((TValue *)kptr)[tvkslot(&array[i])]; + if (LJ_DUALNUM) + setintV(tv, (int32_t)i); + else + setnumV(tv, (lua_Number)i); + } + node = noderef(kt->node); + hmask = kt->hmask; + for (i = 0; i <= hmask; i++) { + Node *n = &node[i]; + if (tvhaskslot(&n->val)) { + ptrdiff_t kidx = (ptrdiff_t)tvkslot(&n->val); + lua_assert(!tvisint(&n->key)); + if (tvisnum(&n->key)) { + TValue *tv = &((TValue *)kptr)[kidx]; + if (LJ_DUALNUM) { + lua_Number nn = numV(&n->key); + int32_t k = lj_num2int(nn); + lua_assert(!tvismzero(&n->key)); + if ((lua_Number)k == nn) + setintV(tv, k); + else + *tv = n->key; + } else { + *tv = n->key; + } + } else { + GCobj *o = gcV(&n->key); + setgcref(((GCRef *)kptr)[~kidx], o); + lj_gc_objbarrier(fs->L, pt, o); + if (tvisproto(&n->key)) + fs_fixup_uv2(fs, gco2pt(o)); + } + } + } +} + +/* Fixup upvalues for prototype, step #1. */ +static void fs_fixup_uv1(FuncState *fs, GCproto *pt, uint16_t *uv) +{ + setmref(pt->uv, uv); + pt->sizeuv = fs->nuv; + memcpy(uv, fs->uvtmp, fs->nuv*sizeof(VarIndex)); +} + +#ifndef LUAJIT_DISABLE_DEBUGINFO +/* Prepare lineinfo for prototype. */ +static size_t fs_prep_line(FuncState *fs, BCLine numline) +{ + return (fs->pc-1) << (numline < 256 ? 0 : numline < 65536 ? 1 : 2); +} + +/* Fixup lineinfo for prototype. */ +static void fs_fixup_line(FuncState *fs, GCproto *pt, + void *lineinfo, BCLine numline) +{ + BCInsLine *base = fs->bcbase + 1; + BCLine first = fs->linedefined; + MSize i = 0, n = fs->pc-1; + pt->firstline = fs->linedefined; + pt->numline = numline; + setmref(pt->lineinfo, lineinfo); + if (LJ_LIKELY(numline < 256)) { + uint8_t *li = (uint8_t *)lineinfo; + do { + BCLine delta = base[i].line - first; + lua_assert(delta >= 0 && delta < 256); + li[i] = (uint8_t)delta; + } while (++i < n); + } else if (LJ_LIKELY(numline < 65536)) { + uint16_t *li = (uint16_t *)lineinfo; + do { + BCLine delta = base[i].line - first; + lua_assert(delta >= 0 && delta < 65536); + li[i] = (uint16_t)delta; + } while (++i < n); + } else { + uint32_t *li = (uint32_t *)lineinfo; + do { + BCLine delta = base[i].line - first; + lua_assert(delta >= 0); + li[i] = (uint32_t)delta; + } while (++i < n); + } +} + +/* Resize buffer if needed. */ +static LJ_NOINLINE void fs_buf_resize(LexState *ls, MSize len) +{ + MSize sz = ls->sb.sz * 2; + while (ls->sb.n + len > sz) sz = sz * 2; + lj_str_resizebuf(ls->L, &ls->sb, sz); +} + +static LJ_AINLINE void fs_buf_need(LexState *ls, MSize len) +{ + if (LJ_UNLIKELY(ls->sb.n + len > ls->sb.sz)) + fs_buf_resize(ls, len); +} + +/* Add string to buffer. */ +static void fs_buf_str(LexState *ls, const char *str, MSize len) +{ + char *p = ls->sb.buf + ls->sb.n; + MSize i; + ls->sb.n += len; + for (i = 0; i < len; i++) p[i] = str[i]; +} + +/* Add ULEB128 value to buffer. */ +static void fs_buf_uleb128(LexState *ls, uint32_t v) +{ + MSize n = ls->sb.n; + uint8_t *p = (uint8_t *)ls->sb.buf; + for (; v >= 0x80; v >>= 7) + p[n++] = (uint8_t)((v & 0x7f) | 0x80); + p[n++] = (uint8_t)v; + ls->sb.n = n; +} + +/* Prepare variable info for prototype. */ +static size_t fs_prep_var(LexState *ls, FuncState *fs, size_t *ofsvar) +{ + VarInfo *vs =ls->vstack, *ve; + MSize i, n; + BCPos lastpc; + lj_str_resetbuf(&ls->sb); /* Copy to temp. string buffer. */ + /* Store upvalue names. */ + for (i = 0, n = fs->nuv; i < n; i++) { + GCstr *s = strref(vs[fs->uvmap[i]].name); + MSize len = s->len+1; + fs_buf_need(ls, len); + fs_buf_str(ls, strdata(s), len); + } + *ofsvar = ls->sb.n; + lastpc = 0; + /* Store local variable names and compressed ranges. */ + for (ve = vs + ls->vtop, vs += fs->vbase; vs < ve; vs++) { + if (!gola_isgotolabel(vs)) { + GCstr *s = strref(vs->name); + BCPos startpc; + if ((uintptr_t)s < VARNAME__MAX) { + fs_buf_need(ls, 1 + 2*5); + ls->sb.buf[ls->sb.n++] = (uint8_t)(uintptr_t)s; + } else { + MSize len = s->len+1; + fs_buf_need(ls, len + 2*5); + fs_buf_str(ls, strdata(s), len); + } + startpc = vs->startpc; + fs_buf_uleb128(ls, startpc-lastpc); + fs_buf_uleb128(ls, vs->endpc-startpc); + lastpc = startpc; + } + } + fs_buf_need(ls, 1); + ls->sb.buf[ls->sb.n++] = '\0'; /* Terminator for varinfo. */ + return ls->sb.n; +} + +/* Fixup variable info for prototype. */ +static void fs_fixup_var(LexState *ls, GCproto *pt, uint8_t *p, size_t ofsvar) +{ + setmref(pt->uvinfo, p); + setmref(pt->varinfo, (char *)p + ofsvar); + memcpy(p, ls->sb.buf, ls->sb.n); /* Copy from temp. string buffer. */ +} +#else + +/* Initialize with empty debug info, if disabled. */ +#define fs_prep_line(fs, numline) (UNUSED(numline), 0) +#define fs_fixup_line(fs, pt, li, numline) \ + pt->firstline = pt->numline = 0, setmref((pt)->lineinfo, NULL) +#define fs_prep_var(ls, fs, ofsvar) (UNUSED(ofsvar), 0) +#define fs_fixup_var(ls, pt, p, ofsvar) \ + setmref((pt)->uvinfo, NULL), setmref((pt)->varinfo, NULL) + +#endif + +/* Check if bytecode op returns. */ +static int bcopisret(BCOp op) +{ + switch (op) { + case BC_CALLMT: case BC_CALLT: + case BC_RETM: case BC_RET: case BC_RET0: case BC_RET1: + return 1; + default: + return 0; + } +} + +/* Fixup return instruction for prototype. */ +static void fs_fixup_ret(FuncState *fs) +{ + BCPos lastpc = fs->pc; + if (lastpc <= fs->lasttarget || !bcopisret(bc_op(fs->bcbase[lastpc-1].ins))) { + if ((fs->bl->flags & FSCOPE_UPVAL)) + bcemit_AJ(fs, BC_UCLO, 0, 0); + bcemit_AD(fs, BC_RET0, 0, 1); /* Need final return. */ + } + fs->bl->flags |= FSCOPE_NOCLOSE; /* Handled above. */ + fscope_end(fs); + lua_assert(fs->bl == NULL); + /* May need to fixup returns encoded before first function was created. */ + if (fs->flags & PROTO_FIXUP_RETURN) { + BCPos pc; + for (pc = 1; pc < lastpc; pc++) { + BCIns ins = fs->bcbase[pc].ins; + BCPos offset; + switch (bc_op(ins)) { + case BC_CALLMT: case BC_CALLT: + case BC_RETM: case BC_RET: case BC_RET0: case BC_RET1: + offset = bcemit_INS(fs, ins); /* Copy original instruction. */ + fs->bcbase[offset].line = fs->bcbase[pc].line; + offset = offset-(pc+1)+BCBIAS_J; + if (offset > BCMAX_D) + err_syntax(fs->ls, LJ_ERR_XFIXUP); + /* Replace with UCLO plus branch. */ + fs->bcbase[pc].ins = BCINS_AD(BC_UCLO, 0, offset); + break; + case BC_UCLO: + return; /* We're done. */ + default: + break; + } + } + } +} + +/* Finish a FuncState and return the new prototype. */ +static GCproto *fs_finish(LexState *ls, BCLine line) +{ + lua_State *L = ls->L; + FuncState *fs = ls->fs; + BCLine numline = line - fs->linedefined; + size_t sizept, ofsk, ofsuv, ofsli, ofsdbg, ofsvar; + GCproto *pt; + + /* Apply final fixups. */ + fs_fixup_ret(fs); + + /* Calculate total size of prototype including all colocated arrays. */ + sizept = sizeof(GCproto) + fs->pc*sizeof(BCIns) + fs->nkgc*sizeof(GCRef); + sizept = (sizept + sizeof(TValue)-1) & ~(sizeof(TValue)-1); + ofsk = sizept; sizept += fs->nkn*sizeof(TValue); + ofsuv = sizept; sizept += ((fs->nuv+1)&~1)*2; + ofsli = sizept; sizept += fs_prep_line(fs, numline); + ofsdbg = sizept; sizept += fs_prep_var(ls, fs, &ofsvar); + + /* Allocate prototype and initialize its fields. */ + pt = (GCproto *)lj_mem_newgco(L, (MSize)sizept); + pt->gct = ~LJ_TPROTO; + pt->sizept = (MSize)sizept; + pt->trace = 0; + pt->flags = (uint8_t)(fs->flags & ~(PROTO_HAS_RETURN|PROTO_FIXUP_RETURN)); + pt->numparams = fs->numparams; + pt->framesize = fs->framesize; + setgcref(pt->chunkname, obj2gco(ls->chunkname)); + + /* Close potentially uninitialized gap between bc and kgc. */ + *(uint32_t *)((char *)pt + ofsk - sizeof(GCRef)*(fs->nkgc+1)) = 0; + fs_fixup_bc(fs, pt, (BCIns *)((char *)pt + sizeof(GCproto)), fs->pc); + fs_fixup_k(fs, pt, (void *)((char *)pt + ofsk)); + fs_fixup_uv1(fs, pt, (uint16_t *)((char *)pt + ofsuv)); + fs_fixup_line(fs, pt, (void *)((char *)pt + ofsli), numline); + fs_fixup_var(ls, pt, (uint8_t *)((char *)pt + ofsdbg), ofsvar); + + lj_vmevent_send(L, BC, + setprotoV(L, L->top++, pt); + ); + + L->top--; /* Pop table of constants. */ + ls->vtop = fs->vbase; /* Reset variable stack. */ + ls->fs = fs->prev; + lua_assert(ls->fs != NULL || ls->token == TK_eof); + return pt; +} + +/* Initialize a new FuncState. */ +static void fs_init(LexState *ls, FuncState *fs) +{ + lua_State *L = ls->L; + fs->prev = ls->fs; ls->fs = fs; /* Append to list. */ + fs->ls = ls; + fs->vbase = ls->vtop; + fs->L = L; + fs->pc = 0; + fs->lasttarget = 0; + fs->jpc = NO_JMP; + fs->freereg = 0; + fs->nkgc = 0; + fs->nkn = 0; + fs->nactvar = 0; + fs->nuv = 0; + fs->bl = NULL; + fs->flags = 0; + fs->framesize = 1; /* Minimum frame size. */ + fs->kt = lj_tab_new(L, 0, 0); + /* Anchor table of constants in stack to avoid being collected. */ + settabV(L, L->top, fs->kt); + incr_top(L); +} + +/* -- Expressions --------------------------------------------------------- */ + +/* Forward declaration. */ +static void expr(LexState *ls, ExpDesc *v); + +/* Return string expression. */ +static void expr_str(LexState *ls, ExpDesc *e) +{ + expr_init(e, VKSTR, 0); + e->u.sval = lex_str(ls); +} + +/* Return index expression. */ +static void expr_index(FuncState *fs, ExpDesc *t, ExpDesc *e) +{ + /* Already called: expr_toval(fs, e). */ + t->k = VINDEXED; + if (expr_isnumk(e)) { +#if LJ_DUALNUM + if (tvisint(expr_numtv(e))) { + int32_t k = intV(expr_numtv(e)); + if (checku8(k)) { + t->u.s.aux = BCMAX_C+1+(uint32_t)k; /* 256..511: const byte key */ + return; + } + } +#else + lua_Number n = expr_numberV(e); + int32_t k = lj_num2int(n); + if (checku8(k) && n == (lua_Number)k) { + t->u.s.aux = BCMAX_C+1+(uint32_t)k; /* 256..511: const byte key */ + return; + } +#endif + } else if (expr_isstrk(e)) { + BCReg idx = const_str(fs, e); + if (idx <= BCMAX_C) { + t->u.s.aux = ~idx; /* -256..-1: const string key */ + return; + } + } + t->u.s.aux = expr_toanyreg(fs, e); /* 0..255: register */ +} + +/* Parse index expression with named field. */ +static void expr_field(LexState *ls, ExpDesc *v) +{ + FuncState *fs = ls->fs; + ExpDesc key; + expr_toanyreg(fs, v); + lj_lex_next(ls); /* Skip dot or colon. */ + expr_str(ls, &key); + expr_index(fs, v, &key); +} + +/* Parse index expression with brackets. */ +static void expr_bracket(LexState *ls, ExpDesc *v) +{ + lj_lex_next(ls); /* Skip '['. */ + expr(ls, v); + expr_toval(ls->fs, v); + lex_check(ls, ']'); +} + +/* Get value of constant expression. */ +static void expr_kvalue(TValue *v, ExpDesc *e) +{ + if (e->k <= VKTRUE) { + setitype(v, ~(uint32_t)e->k); + } else if (e->k == VKSTR) { + setgcref(v->gcr, obj2gco(e->u.sval)); + setitype(v, LJ_TSTR); + } else { + lua_assert(tvisnumber(expr_numtv(e))); + *v = *expr_numtv(e); + } +} + +/* Parse table constructor expression. */ +static void expr_table(LexState *ls, ExpDesc *e) +{ + FuncState *fs = ls->fs; + BCLine line = ls->linenumber; + GCtab *t = NULL; + int vcall = 0, needarr = 0, fixt = 0; + uint32_t narr = 1; /* First array index. */ + uint32_t nhash = 0; /* Number of hash entries. */ + BCReg freg = fs->freereg; + BCPos pc = bcemit_AD(fs, BC_TNEW, freg, 0); + expr_init(e, VNONRELOC, freg); + bcreg_reserve(fs, 1); + freg++; + lex_check(ls, '{'); + while (ls->token != '}') { + ExpDesc key, val; + vcall = 0; + if (ls->token == '[') { + expr_bracket(ls, &key); /* Already calls expr_toval. */ + if (!expr_isk(&key)) expr_index(fs, e, &key); + if (expr_isnumk(&key) && expr_numiszero(&key)) needarr = 1; else nhash++; + lex_check(ls, '='); + } else if ((ls->token == TK_name || (!LJ_52 && ls->token == TK_goto)) && + lj_lex_lookahead(ls) == '=') { + expr_str(ls, &key); + lex_check(ls, '='); + nhash++; + } else { + expr_init(&key, VKNUM, 0); + setintV(&key.u.nval, (int)narr); + narr++; + needarr = vcall = 1; + } + expr(ls, &val); + if (expr_isk(&key) && key.k != VKNIL && + (key.k == VKSTR || expr_isk_nojump(&val))) { + TValue k, *v; + if (!t) { /* Create template table on demand. */ + BCReg kidx; + t = lj_tab_new(fs->L, needarr ? narr : 0, hsize2hbits(nhash)); + kidx = const_gc(fs, obj2gco(t), LJ_TTAB); + fs->bcbase[pc].ins = BCINS_AD(BC_TDUP, freg-1, kidx); + } + vcall = 0; + expr_kvalue(&k, &key); + v = lj_tab_set(fs->L, t, &k); + lj_gc_anybarriert(fs->L, t); + if (expr_isk_nojump(&val)) { /* Add const key/value to template table. */ + expr_kvalue(v, &val); + } else { /* Otherwise create dummy string key (avoids lj_tab_newkey). */ + settabV(fs->L, v, t); /* Preserve key with table itself as value. */ + fixt = 1; /* Fix this later, after all resizes. */ + goto nonconst; + } + } else { + nonconst: + if (val.k != VCALL) { expr_toanyreg(fs, &val); vcall = 0; } + if (expr_isk(&key)) expr_index(fs, e, &key); + bcemit_store(fs, e, &val); + } + fs->freereg = freg; + if (!lex_opt(ls, ',') && !lex_opt(ls, ';')) break; + } + lex_match(ls, '}', '{', line); + if (vcall) { + BCInsLine *ilp = &fs->bcbase[fs->pc-1]; + ExpDesc en; + lua_assert(bc_a(ilp->ins) == freg && + bc_op(ilp->ins) == (narr > 256 ? BC_TSETV : BC_TSETB)); + expr_init(&en, VKNUM, 0); + en.u.nval.u32.lo = narr-1; + en.u.nval.u32.hi = 0x43300000; /* Biased integer to avoid denormals. */ + if (narr > 256) { fs->pc--; ilp--; } + ilp->ins = BCINS_AD(BC_TSETM, freg, const_num(fs, &en)); + setbc_b(&ilp[-1].ins, 0); + } + if (pc == fs->pc-1) { /* Make expr relocable if possible. */ + e->u.s.info = pc; + fs->freereg--; + e->k = VRELOCABLE; + } else { + e->k = VNONRELOC; /* May have been changed by expr_index. */ + } + if (!t) { /* Construct TNEW RD: hhhhhaaaaaaaaaaa. */ + BCIns *ip = &fs->bcbase[pc].ins; + if (!needarr) narr = 0; + else if (narr < 3) narr = 3; + else if (narr > 0x7ff) narr = 0x7ff; + setbc_d(ip, narr|(hsize2hbits(nhash)<<11)); + } else { + if (needarr && t->asize < narr) + lj_tab_reasize(fs->L, t, narr-1); + if (fixt) { /* Fix value for dummy keys in template table. */ + Node *node = noderef(t->node); + uint32_t i, hmask = t->hmask; + for (i = 0; i <= hmask; i++) { + Node *n = &node[i]; + if (tvistab(&n->val)) { + lua_assert(tabV(&n->val) == t); + setnilV(&n->val); /* Turn value into nil. */ + } + } + } + lj_gc_check(fs->L); + } +} + +/* Parse function parameters. */ +static BCReg parse_params(LexState *ls, int needself) +{ + FuncState *fs = ls->fs; + BCReg nparams = 0; + lex_check(ls, '('); + if (needself) + var_new_lit(ls, nparams++, "self"); + if (ls->token != ')') { + do { + if (ls->token == TK_name || (!LJ_52 && ls->token == TK_goto)) { + var_new(ls, nparams++, lex_str(ls)); + } else if (ls->token == TK_dots) { + lj_lex_next(ls); + fs->flags |= PROTO_VARARG; + break; + } else { + err_syntax(ls, LJ_ERR_XPARAM); + } + } while (lex_opt(ls, ',')); + } + var_add(ls, nparams); + lua_assert(fs->nactvar == nparams); + bcreg_reserve(fs, nparams); + lex_check(ls, ')'); + return nparams; +} + +/* Forward declaration. */ +static void parse_chunk(LexState *ls); + +/* Parse body of a function. */ +static void parse_body(LexState *ls, ExpDesc *e, int needself, BCLine line) +{ + FuncState fs, *pfs = ls->fs; + FuncScope bl; + GCproto *pt; + ptrdiff_t oldbase = pfs->bcbase - ls->bcstack; + fs_init(ls, &fs); + fscope_begin(&fs, &bl, 0); + fs.linedefined = line; + fs.numparams = (uint8_t)parse_params(ls, needself); + fs.bcbase = pfs->bcbase + pfs->pc; + fs.bclim = pfs->bclim - pfs->pc; + bcemit_AD(&fs, BC_FUNCF, 0, 0); /* Placeholder. */ + parse_chunk(ls); + if (ls->token != TK_end) lex_match(ls, TK_end, TK_function, line); + pt = fs_finish(ls, (ls->lastline = ls->linenumber)); + pfs->bcbase = ls->bcstack + oldbase; /* May have been reallocated. */ + pfs->bclim = (BCPos)(ls->sizebcstack - oldbase); + /* Store new prototype in the constant array of the parent. */ + expr_init(e, VRELOCABLE, + bcemit_AD(pfs, BC_FNEW, 0, const_gc(pfs, obj2gco(pt), LJ_TPROTO))); +#if LJ_HASFFI + pfs->flags |= (fs.flags & PROTO_FFI); +#endif + if (!(pfs->flags & PROTO_CHILD)) { + if (pfs->flags & PROTO_HAS_RETURN) + pfs->flags |= PROTO_FIXUP_RETURN; + pfs->flags |= PROTO_CHILD; + } + lj_lex_next(ls); +} + +/* Parse expression list. Last expression is left open. */ +static BCReg expr_list(LexState *ls, ExpDesc *v) +{ + BCReg n = 1; + expr(ls, v); + while (lex_opt(ls, ',')) { + expr_tonextreg(ls->fs, v); + expr(ls, v); + n++; + } + return n; +} + +/* Parse function argument list. */ +static void parse_args(LexState *ls, ExpDesc *e) +{ + FuncState *fs = ls->fs; + ExpDesc args; + BCIns ins; + BCReg base; + BCLine line = ls->linenumber; + if (ls->token == '(') { +#if !LJ_52 + if (line != ls->lastline) + err_syntax(ls, LJ_ERR_XAMBIG); +#endif + lj_lex_next(ls); + if (ls->token == ')') { /* f(). */ + args.k = VVOID; + } else { + expr_list(ls, &args); + if (args.k == VCALL) /* f(a, b, g()) or f(a, b, ...). */ + setbc_b(bcptr(fs, &args), 0); /* Pass on multiple results. */ + } + lex_match(ls, ')', '(', line); + } else if (ls->token == '{') { + expr_table(ls, &args); + } else if (ls->token == TK_string) { + expr_init(&args, VKSTR, 0); + args.u.sval = strV(&ls->tokenval); + lj_lex_next(ls); + } else { + err_syntax(ls, LJ_ERR_XFUNARG); + return; /* Silence compiler. */ + } + lua_assert(e->k == VNONRELOC); + base = e->u.s.info; /* Base register for call. */ + if (args.k == VCALL) { + ins = BCINS_ABC(BC_CALLM, base, 2, args.u.s.aux - base - 1); + } else { + if (args.k != VVOID) + expr_tonextreg(fs, &args); + ins = BCINS_ABC(BC_CALL, base, 2, fs->freereg - base); + } + expr_init(e, VCALL, bcemit_INS(fs, ins)); + e->u.s.aux = base; + fs->bcbase[fs->pc - 1].line = line; + fs->freereg = base+1; /* Leave one result by default. */ +} + +/* Parse primary expression. */ +static void expr_primary(LexState *ls, ExpDesc *v) +{ + FuncState *fs = ls->fs; + /* Parse prefix expression. */ + if (ls->token == '(') { + BCLine line = ls->linenumber; + lj_lex_next(ls); + expr(ls, v); + lex_match(ls, ')', '(', line); + expr_discharge(ls->fs, v); + } else if (ls->token == TK_name || (!LJ_52 && ls->token == TK_goto)) { + var_lookup(ls, v); + } else { + err_syntax(ls, LJ_ERR_XSYMBOL); + } + for (;;) { /* Parse multiple expression suffixes. */ + if (ls->token == '.') { + expr_field(ls, v); + } else if (ls->token == '[') { + ExpDesc key; + expr_toanyreg(fs, v); + expr_bracket(ls, &key); + expr_index(fs, v, &key); + } else if (ls->token == ':') { + ExpDesc key; + lj_lex_next(ls); + expr_str(ls, &key); + bcemit_method(fs, v, &key); + parse_args(ls, v); + } else if (ls->token == '(' || ls->token == TK_string || ls->token == '{') { + expr_tonextreg(fs, v); + parse_args(ls, v); + } else { + break; + } + } +} + +/* Parse simple expression. */ +static void expr_simple(LexState *ls, ExpDesc *v) +{ + switch (ls->token) { + case TK_number: + expr_init(v, (LJ_HASFFI && tviscdata(&ls->tokenval)) ? VKCDATA : VKNUM, 0); + copyTV(ls->L, &v->u.nval, &ls->tokenval); + break; + case TK_string: + expr_init(v, VKSTR, 0); + v->u.sval = strV(&ls->tokenval); + break; + case TK_nil: + expr_init(v, VKNIL, 0); + break; + case TK_true: + expr_init(v, VKTRUE, 0); + break; + case TK_false: + expr_init(v, VKFALSE, 0); + break; + case TK_dots: { /* Vararg. */ + FuncState *fs = ls->fs; + BCReg base; + checkcond(ls, fs->flags & PROTO_VARARG, LJ_ERR_XDOTS); + bcreg_reserve(fs, 1); + base = fs->freereg-1; + expr_init(v, VCALL, bcemit_ABC(fs, BC_VARG, base, 2, fs->numparams)); + v->u.s.aux = base; + break; + } + case '{': /* Table constructor. */ + expr_table(ls, v); + return; + case TK_function: + lj_lex_next(ls); + parse_body(ls, v, 0, ls->linenumber); + return; + default: + expr_primary(ls, v); + return; + } + lj_lex_next(ls); +} + +/* Manage syntactic levels to avoid blowing up the stack. */ +static void synlevel_begin(LexState *ls) +{ + if (++ls->level >= LJ_MAX_XLEVEL) + lj_lex_error(ls, 0, LJ_ERR_XLEVELS); +} + +#define synlevel_end(ls) ((ls)->level--) + +/* Convert token to binary operator. */ +static BinOpr token2binop(LexToken tok) +{ + switch (tok) { + case '+': return OPR_ADD; + case '-': return OPR_SUB; + case '*': return OPR_MUL; + case '/': return OPR_DIV; + case '%': return OPR_MOD; + case '^': return OPR_POW; + case TK_concat: return OPR_CONCAT; + case TK_ne: return OPR_NE; + case TK_eq: return OPR_EQ; + case '<': return OPR_LT; + case TK_le: return OPR_LE; + case '>': return OPR_GT; + case TK_ge: return OPR_GE; + case TK_and: return OPR_AND; + case TK_or: return OPR_OR; + default: return OPR_NOBINOPR; + } +} + +/* Priorities for each binary operator. ORDER OPR. */ +static const struct { + uint8_t left; /* Left priority. */ + uint8_t right; /* Right priority. */ +} priority[] = { + {6,6}, {6,6}, {7,7}, {7,7}, {7,7}, /* ADD SUB MUL DIV MOD */ + {10,9}, {5,4}, /* POW CONCAT (right associative) */ + {3,3}, {3,3}, /* EQ NE */ + {3,3}, {3,3}, {3,3}, {3,3}, /* LT GE GT LE */ + {2,2}, {1,1} /* AND OR */ +}; + +#define UNARY_PRIORITY 8 /* Priority for unary operators. */ + +/* Forward declaration. */ +static BinOpr expr_binop(LexState *ls, ExpDesc *v, uint32_t limit); + +/* Parse unary expression. */ +static void expr_unop(LexState *ls, ExpDesc *v) +{ + BCOp op; + if (ls->token == TK_not) { + op = BC_NOT; + } else if (ls->token == '-') { + op = BC_UNM; + } else if (ls->token == '#') { + op = BC_LEN; + } else { + expr_simple(ls, v); + return; + } + lj_lex_next(ls); + expr_binop(ls, v, UNARY_PRIORITY); + bcemit_unop(ls->fs, op, v); +} + +/* Parse binary expressions with priority higher than the limit. */ +static BinOpr expr_binop(LexState *ls, ExpDesc *v, uint32_t limit) +{ + BinOpr op; + synlevel_begin(ls); + expr_unop(ls, v); + op = token2binop(ls->token); + while (op != OPR_NOBINOPR && priority[op].left > limit) { + ExpDesc v2; + BinOpr nextop; + lj_lex_next(ls); + bcemit_binop_left(ls->fs, op, v); + /* Parse binary expression with higher priority. */ + nextop = expr_binop(ls, &v2, priority[op].right); + bcemit_binop(ls->fs, op, v, &v2); + op = nextop; + } + synlevel_end(ls); + return op; /* Return unconsumed binary operator (if any). */ +} + +/* Parse expression. */ +static void expr(LexState *ls, ExpDesc *v) +{ + expr_binop(ls, v, 0); /* Priority 0: parse whole expression. */ +} + +/* Assign expression to the next register. */ +static void expr_next(LexState *ls) +{ + ExpDesc e; + expr(ls, &e); + expr_tonextreg(ls->fs, &e); +} + +/* Parse conditional expression. */ +static BCPos expr_cond(LexState *ls) +{ + ExpDesc v; + expr(ls, &v); + if (v.k == VKNIL) v.k = VKFALSE; + bcemit_branch_t(ls->fs, &v); + return v.f; +} + +/* -- Assignments --------------------------------------------------------- */ + +/* List of LHS variables. */ +typedef struct LHSVarList { + ExpDesc v; /* LHS variable. */ + struct LHSVarList *prev; /* Link to previous LHS variable. */ +} LHSVarList; + +/* Eliminate write-after-read hazards for local variable assignment. */ +static void assign_hazard(LexState *ls, LHSVarList *lh, const ExpDesc *v) +{ + FuncState *fs = ls->fs; + BCReg reg = v->u.s.info; /* Check against this variable. */ + BCReg tmp = fs->freereg; /* Rename to this temp. register (if needed). */ + int hazard = 0; + for (; lh; lh = lh->prev) { + if (lh->v.k == VINDEXED) { + if (lh->v.u.s.info == reg) { /* t[i], t = 1, 2 */ + hazard = 1; + lh->v.u.s.info = tmp; + } + if (lh->v.u.s.aux == reg) { /* t[i], i = 1, 2 */ + hazard = 1; + lh->v.u.s.aux = tmp; + } + } + } + if (hazard) { + bcemit_AD(fs, BC_MOV, tmp, reg); /* Rename conflicting variable. */ + bcreg_reserve(fs, 1); + } +} + +/* Adjust LHS/RHS of an assignment. */ +static void assign_adjust(LexState *ls, BCReg nvars, BCReg nexps, ExpDesc *e) +{ + FuncState *fs = ls->fs; + int32_t extra = (int32_t)nvars - (int32_t)nexps; + if (e->k == VCALL) { + extra++; /* Compensate for the VCALL itself. */ + if (extra < 0) extra = 0; + setbc_b(bcptr(fs, e), extra+1); /* Fixup call results. */ + if (extra > 1) bcreg_reserve(fs, (BCReg)extra-1); + } else { + if (e->k != VVOID) + expr_tonextreg(fs, e); /* Close last expression. */ + if (extra > 0) { /* Leftover LHS are set to nil. */ + BCReg reg = fs->freereg; + bcreg_reserve(fs, (BCReg)extra); + bcemit_nil(fs, reg, (BCReg)extra); + } + } +} + +/* Recursively parse assignment statement. */ +static void parse_assignment(LexState *ls, LHSVarList *lh, BCReg nvars) +{ + ExpDesc e; + checkcond(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED, LJ_ERR_XSYNTAX); + if (lex_opt(ls, ',')) { /* Collect LHS list and recurse upwards. */ + LHSVarList vl; + vl.prev = lh; + expr_primary(ls, &vl.v); + if (vl.v.k == VLOCAL) + assign_hazard(ls, lh, &vl.v); + checklimit(ls->fs, ls->level + nvars, LJ_MAX_XLEVEL, "variable names"); + parse_assignment(ls, &vl, nvars+1); + } else { /* Parse RHS. */ + BCReg nexps; + lex_check(ls, '='); + nexps = expr_list(ls, &e); + if (nexps == nvars) { + if (e.k == VCALL) { + if (bc_op(*bcptr(ls->fs, &e)) == BC_VARG) { /* Vararg assignment. */ + ls->fs->freereg--; + e.k = VRELOCABLE; + } else { /* Multiple call results. */ + e.u.s.info = e.u.s.aux; /* Base of call is not relocatable. */ + e.k = VNONRELOC; + } + } + bcemit_store(ls->fs, &lh->v, &e); + return; + } + assign_adjust(ls, nvars, nexps, &e); + if (nexps > nvars) + ls->fs->freereg -= nexps - nvars; /* Drop leftover regs. */ + } + /* Assign RHS to LHS and recurse downwards. */ + expr_init(&e, VNONRELOC, ls->fs->freereg-1); + bcemit_store(ls->fs, &lh->v, &e); +} + +/* Parse call statement or assignment. */ +static void parse_call_assign(LexState *ls) +{ + FuncState *fs = ls->fs; + LHSVarList vl; + expr_primary(ls, &vl.v); + if (vl.v.k == VCALL) { /* Function call statement. */ + setbc_b(bcptr(fs, &vl.v), 1); /* No results. */ + } else { /* Start of an assignment. */ + vl.prev = NULL; + parse_assignment(ls, &vl, 1); + } +} + +/* Parse 'local' statement. */ +static void parse_local(LexState *ls) +{ + if (lex_opt(ls, TK_function)) { /* Local function declaration. */ + ExpDesc v, b; + FuncState *fs = ls->fs; + var_new(ls, 0, lex_str(ls)); + expr_init(&v, VLOCAL, fs->freereg); + v.u.s.aux = fs->varmap[fs->freereg]; + bcreg_reserve(fs, 1); + var_add(ls, 1); + parse_body(ls, &b, 0, ls->linenumber); + /* bcemit_store(fs, &v, &b) without setting VSTACK_VAR_RW. */ + expr_free(fs, &b); + expr_toreg(fs, &b, v.u.s.info); + /* The upvalue is in scope, but the local is only valid after the store. */ + var_get(ls, fs, fs->nactvar - 1).startpc = fs->pc; + } else { /* Local variable declaration. */ + ExpDesc e; + BCReg nexps, nvars = 0; + do { /* Collect LHS. */ + var_new(ls, nvars++, lex_str(ls)); + } while (lex_opt(ls, ',')); + if (lex_opt(ls, '=')) { /* Optional RHS. */ + nexps = expr_list(ls, &e); + } else { /* Or implicitly set to nil. */ + e.k = VVOID; + nexps = 0; + } + assign_adjust(ls, nvars, nexps, &e); + var_add(ls, nvars); + } +} + +/* Parse 'function' statement. */ +static void parse_func(LexState *ls, BCLine line) +{ + FuncState *fs; + ExpDesc v, b; + int needself = 0; + lj_lex_next(ls); /* Skip 'function'. */ + /* Parse function name. */ + var_lookup(ls, &v); + while (ls->token == '.') /* Multiple dot-separated fields. */ + expr_field(ls, &v); + if (ls->token == ':') { /* Optional colon to signify method call. */ + needself = 1; + expr_field(ls, &v); + } + parse_body(ls, &b, needself, line); + fs = ls->fs; + bcemit_store(fs, &v, &b); + fs->bcbase[fs->pc - 1].line = line; /* Set line for the store. */ +} + +/* -- Control transfer statements ----------------------------------------- */ + +/* Check for end of block. */ +static int endofblock(LexToken token) +{ + switch (token) { + case TK_else: case TK_elseif: case TK_end: case TK_until: case TK_eof: + return 1; + default: + return 0; + } +} + +/* Parse 'return' statement. */ +static void parse_return(LexState *ls) +{ + BCIns ins; + FuncState *fs = ls->fs; + lj_lex_next(ls); /* Skip 'return'. */ + fs->flags |= PROTO_HAS_RETURN; + if (endofblock(ls->token) || ls->token == ';') { /* Bare return. */ + ins = BCINS_AD(BC_RET0, 0, 1); + } else { /* Return with one or more values. */ + ExpDesc e; /* Receives the _last_ expression in the list. */ + BCReg nret = expr_list(ls, &e); + if (nret == 1) { /* Return one result. */ + if (e.k == VCALL) { /* Check for tail call. */ + BCIns *ip = bcptr(fs, &e); + /* It doesn't pay off to add BC_VARGT just for 'return ...'. */ + if (bc_op(*ip) == BC_VARG) goto notailcall; + fs->pc--; + ins = BCINS_AD(bc_op(*ip)-BC_CALL+BC_CALLT, bc_a(*ip), bc_c(*ip)); + } else { /* Can return the result from any register. */ + ins = BCINS_AD(BC_RET1, expr_toanyreg(fs, &e), 2); + } + } else { + if (e.k == VCALL) { /* Append all results from a call. */ + notailcall: + setbc_b(bcptr(fs, &e), 0); + ins = BCINS_AD(BC_RETM, fs->nactvar, e.u.s.aux - fs->nactvar); + } else { + expr_tonextreg(fs, &e); /* Force contiguous registers. */ + ins = BCINS_AD(BC_RET, fs->nactvar, nret+1); + } + } + } + if (fs->flags & PROTO_CHILD) + bcemit_AJ(fs, BC_UCLO, 0, 0); /* May need to close upvalues first. */ + bcemit_INS(fs, ins); +} + +/* Parse 'break' statement. */ +static void parse_break(LexState *ls) +{ + ls->fs->bl->flags |= FSCOPE_BREAK; + gola_new(ls, NAME_BREAK, VSTACK_GOTO, bcemit_jmp(ls->fs)); +} + +/* Parse 'goto' statement. */ +static void parse_goto(LexState *ls) +{ + FuncState *fs = ls->fs; + GCstr *name = lex_str(ls); + VarInfo *vl = gola_findlabel(ls, name); + if (vl) /* Treat backwards goto within same scope like a loop. */ + bcemit_AJ(fs, BC_LOOP, vl->slot, -1); /* No BC range check. */ + fs->bl->flags |= FSCOPE_GOLA; + gola_new(ls, name, VSTACK_GOTO, bcemit_jmp(fs)); +} + +/* Parse label. */ +static void parse_label(LexState *ls) +{ + FuncState *fs = ls->fs; + GCstr *name; + MSize idx; + fs->lasttarget = fs->pc; + fs->bl->flags |= FSCOPE_GOLA; + lj_lex_next(ls); /* Skip '::'. */ + name = lex_str(ls); + if (gola_findlabel(ls, name)) + lj_lex_error(ls, 0, LJ_ERR_XLDUP, strdata(name)); + idx = gola_new(ls, name, VSTACK_LABEL, fs->pc); + lex_check(ls, TK_label); + /* Recursively parse trailing statements: labels and ';' (Lua 5.2 only). */ + for (;;) { + if (ls->token == TK_label) { + synlevel_begin(ls); + parse_label(ls); + synlevel_end(ls); + } else if (LJ_52 && ls->token == ';') { + lj_lex_next(ls); + } else { + break; + } + } + /* Trailing label is considered to be outside of scope. */ + if (endofblock(ls->token) && ls->token != TK_until) + ls->vstack[idx].slot = fs->bl->nactvar; + gola_resolve(ls, fs->bl, idx); +} + +/* -- Blocks, loops and conditional statements ---------------------------- */ + +/* Parse a block. */ +static void parse_block(LexState *ls) +{ + FuncState *fs = ls->fs; + FuncScope bl; + fscope_begin(fs, &bl, 0); + parse_chunk(ls); + fscope_end(fs); +} + +/* Parse 'while' statement. */ +static void parse_while(LexState *ls, BCLine line) +{ + FuncState *fs = ls->fs; + BCPos start, loop, condexit; + FuncScope bl; + lj_lex_next(ls); /* Skip 'while'. */ + start = fs->lasttarget = fs->pc; + condexit = expr_cond(ls); + fscope_begin(fs, &bl, FSCOPE_LOOP); + lex_check(ls, TK_do); + loop = bcemit_AD(fs, BC_LOOP, fs->nactvar, 0); + parse_block(ls); + jmp_patch(fs, bcemit_jmp(fs), start); + lex_match(ls, TK_end, TK_while, line); + fscope_end(fs); + jmp_tohere(fs, condexit); + jmp_patchins(fs, loop, fs->pc); +} + +/* Parse 'repeat' statement. */ +static void parse_repeat(LexState *ls, BCLine line) +{ + FuncState *fs = ls->fs; + BCPos loop = fs->lasttarget = fs->pc; + BCPos condexit; + FuncScope bl1, bl2; + fscope_begin(fs, &bl1, FSCOPE_LOOP); /* Breakable loop scope. */ + fscope_begin(fs, &bl2, 0); /* Inner scope. */ + lj_lex_next(ls); /* Skip 'repeat'. */ + bcemit_AD(fs, BC_LOOP, fs->nactvar, 0); + parse_chunk(ls); + lex_match(ls, TK_until, TK_repeat, line); + condexit = expr_cond(ls); /* Parse condition (still inside inner scope). */ + if (!(bl2.flags & FSCOPE_UPVAL)) { /* No upvalues? Just end inner scope. */ + fscope_end(fs); + } else { /* Otherwise generate: cond: UCLO+JMP out, !cond: UCLO+JMP loop. */ + parse_break(ls); /* Break from loop and close upvalues. */ + jmp_tohere(fs, condexit); + fscope_end(fs); /* End inner scope and close upvalues. */ + condexit = bcemit_jmp(fs); + } + jmp_patch(fs, condexit, loop); /* Jump backwards if !cond. */ + jmp_patchins(fs, loop, fs->pc); + fscope_end(fs); /* End loop scope. */ +} + +/* Parse numeric 'for'. */ +static void parse_for_num(LexState *ls, GCstr *varname, BCLine line) +{ + FuncState *fs = ls->fs; + BCReg base = fs->freereg; + FuncScope bl; + BCPos loop, loopend; + /* Hidden control variables. */ + var_new_fixed(ls, FORL_IDX, VARNAME_FOR_IDX); + var_new_fixed(ls, FORL_STOP, VARNAME_FOR_STOP); + var_new_fixed(ls, FORL_STEP, VARNAME_FOR_STEP); + /* Visible copy of index variable. */ + var_new(ls, FORL_EXT, varname); + lex_check(ls, '='); + expr_next(ls); + lex_check(ls, ','); + expr_next(ls); + if (lex_opt(ls, ',')) { + expr_next(ls); + } else { + bcemit_AD(fs, BC_KSHORT, fs->freereg, 1); /* Default step is 1. */ + bcreg_reserve(fs, 1); + } + var_add(ls, 3); /* Hidden control variables. */ + lex_check(ls, TK_do); + loop = bcemit_AJ(fs, BC_FORI, base, NO_JMP); + fscope_begin(fs, &bl, 0); /* Scope for visible variables. */ + var_add(ls, 1); + bcreg_reserve(fs, 1); + parse_block(ls); + fscope_end(fs); + /* Perform loop inversion. Loop control instructions are at the end. */ + loopend = bcemit_AJ(fs, BC_FORL, base, NO_JMP); + fs->bcbase[loopend].line = line; /* Fix line for control ins. */ + jmp_patchins(fs, loopend, loop+1); + jmp_patchins(fs, loop, fs->pc); +} + +/* Try to predict whether the iterator is next() and specialize the bytecode. +** Detecting next() and pairs() by name is simplistic, but quite effective. +** The interpreter backs off if the check for the closure fails at runtime. +*/ +static int predict_next(LexState *ls, FuncState *fs, BCPos pc) +{ + BCIns ins = fs->bcbase[pc].ins; + GCstr *name; + cTValue *o; + switch (bc_op(ins)) { + case BC_MOV: + name = gco2str(gcref(var_get(ls, fs, bc_d(ins)).name)); + break; + case BC_UGET: + name = gco2str(gcref(ls->vstack[fs->uvmap[bc_d(ins)]].name)); + break; + case BC_GGET: + /* There's no inverse index (yet), so lookup the strings. */ + o = lj_tab_getstr(fs->kt, lj_str_newlit(ls->L, "pairs")); + if (o && tvhaskslot(o) && tvkslot(o) == bc_d(ins)) + return 1; + o = lj_tab_getstr(fs->kt, lj_str_newlit(ls->L, "next")); + if (o && tvhaskslot(o) && tvkslot(o) == bc_d(ins)) + return 1; + return 0; + default: + return 0; + } + return (name->len == 5 && !strcmp(strdata(name), "pairs")) || + (name->len == 4 && !strcmp(strdata(name), "next")); +} + +/* Parse 'for' iterator. */ +static void parse_for_iter(LexState *ls, GCstr *indexname) +{ + FuncState *fs = ls->fs; + ExpDesc e; + BCReg nvars = 0; + BCLine line; + BCReg base = fs->freereg + 3; + BCPos loop, loopend, exprpc = fs->pc; + FuncScope bl; + int isnext; + /* Hidden control variables. */ + var_new_fixed(ls, nvars++, VARNAME_FOR_GEN); + var_new_fixed(ls, nvars++, VARNAME_FOR_STATE); + var_new_fixed(ls, nvars++, VARNAME_FOR_CTL); + /* Visible variables returned from iterator. */ + var_new(ls, nvars++, indexname); + while (lex_opt(ls, ',')) + var_new(ls, nvars++, lex_str(ls)); + lex_check(ls, TK_in); + line = ls->linenumber; + assign_adjust(ls, 3, expr_list(ls, &e), &e); + bcreg_bump(fs, 3); /* The iterator needs another 3 slots (func + 2 args). */ + isnext = (nvars <= 5 && predict_next(ls, fs, exprpc)); + var_add(ls, 3); /* Hidden control variables. */ + lex_check(ls, TK_do); + loop = bcemit_AJ(fs, isnext ? BC_ISNEXT : BC_JMP, base, NO_JMP); + fscope_begin(fs, &bl, 0); /* Scope for visible variables. */ + var_add(ls, nvars-3); + bcreg_reserve(fs, nvars-3); + parse_block(ls); + fscope_end(fs); + /* Perform loop inversion. Loop control instructions are at the end. */ + jmp_patchins(fs, loop, fs->pc); + bcemit_ABC(fs, isnext ? BC_ITERN : BC_ITERC, base, nvars-3+1, 2+1); + loopend = bcemit_AJ(fs, BC_ITERL, base, NO_JMP); + fs->bcbase[loopend-1].line = line; /* Fix line for control ins. */ + fs->bcbase[loopend].line = line; + jmp_patchins(fs, loopend, loop+1); +} + +/* Parse 'for' statement. */ +static void parse_for(LexState *ls, BCLine line) +{ + FuncState *fs = ls->fs; + GCstr *varname; + FuncScope bl; + fscope_begin(fs, &bl, FSCOPE_LOOP); + lj_lex_next(ls); /* Skip 'for'. */ + varname = lex_str(ls); /* Get first variable name. */ + if (ls->token == '=') + parse_for_num(ls, varname, line); + else if (ls->token == ',' || ls->token == TK_in) + parse_for_iter(ls, varname); + else + err_syntax(ls, LJ_ERR_XFOR); + lex_match(ls, TK_end, TK_for, line); + fscope_end(fs); /* Resolve break list. */ +} + +/* Parse condition and 'then' block. */ +static BCPos parse_then(LexState *ls) +{ + BCPos condexit; + lj_lex_next(ls); /* Skip 'if' or 'elseif'. */ + condexit = expr_cond(ls); + lex_check(ls, TK_then); + parse_block(ls); + return condexit; +} + +/* Parse 'if' statement. */ +static void parse_if(LexState *ls, BCLine line) +{ + FuncState *fs = ls->fs; + BCPos flist; + BCPos escapelist = NO_JMP; + flist = parse_then(ls); + while (ls->token == TK_elseif) { /* Parse multiple 'elseif' blocks. */ + jmp_append(fs, &escapelist, bcemit_jmp(fs)); + jmp_tohere(fs, flist); + flist = parse_then(ls); + } + if (ls->token == TK_else) { /* Parse optional 'else' block. */ + jmp_append(fs, &escapelist, bcemit_jmp(fs)); + jmp_tohere(fs, flist); + lj_lex_next(ls); /* Skip 'else'. */ + parse_block(ls); + } else { + jmp_append(fs, &escapelist, flist); + } + jmp_tohere(fs, escapelist); + lex_match(ls, TK_end, TK_if, line); +} + +/* -- Parse statements ---------------------------------------------------- */ + +/* Parse a statement. Returns 1 if it must be the last one in a chunk. */ +static int parse_stmt(LexState *ls) +{ + BCLine line = ls->linenumber; + switch (ls->token) { + case TK_if: + parse_if(ls, line); + break; + case TK_while: + parse_while(ls, line); + break; + case TK_do: + lj_lex_next(ls); + parse_block(ls); + lex_match(ls, TK_end, TK_do, line); + break; + case TK_for: + parse_for(ls, line); + break; + case TK_repeat: + parse_repeat(ls, line); + break; + case TK_function: + parse_func(ls, line); + break; + case TK_local: + lj_lex_next(ls); + parse_local(ls); + break; + case TK_return: + parse_return(ls); + return 1; /* Must be last. */ + case TK_break: + lj_lex_next(ls); + parse_break(ls); + return !LJ_52; /* Must be last in Lua 5.1. */ +#if LJ_52 + case ';': + lj_lex_next(ls); + break; +#endif + case TK_label: + parse_label(ls); + break; + case TK_goto: + if (LJ_52 || lj_lex_lookahead(ls) == TK_name) { + lj_lex_next(ls); + parse_goto(ls); + break; + } /* else: fallthrough */ + default: + parse_call_assign(ls); + break; + } + return 0; +} + +/* A chunk is a list of statements optionally separated by semicolons. */ +static void parse_chunk(LexState *ls) +{ + int islast = 0; + synlevel_begin(ls); + while (!islast && !endofblock(ls->token)) { + islast = parse_stmt(ls); + lex_opt(ls, ';'); + lua_assert(ls->fs->framesize >= ls->fs->freereg && + ls->fs->freereg >= ls->fs->nactvar); + ls->fs->freereg = ls->fs->nactvar; /* Free registers after each stmt. */ + } + synlevel_end(ls); +} + +/* Entry point of bytecode parser. */ +GCproto *lj_parse(LexState *ls) +{ + FuncState fs; + FuncScope bl; + GCproto *pt; + lua_State *L = ls->L; +#ifdef LUAJIT_DISABLE_DEBUGINFO + ls->chunkname = lj_str_newlit(L, "="); +#else + ls->chunkname = lj_str_newz(L, ls->chunkarg); +#endif + setstrV(L, L->top, ls->chunkname); /* Anchor chunkname string. */ + incr_top(L); + ls->level = 0; + fs_init(ls, &fs); + fs.linedefined = 0; + fs.numparams = 0; + fs.bcbase = NULL; + fs.bclim = 0; + fs.flags |= PROTO_VARARG; /* Main chunk is always a vararg func. */ + fscope_begin(&fs, &bl, 0); + bcemit_AD(&fs, BC_FUNCV, 0, 0); /* Placeholder. */ + lj_lex_next(ls); /* Read-ahead first token. */ + parse_chunk(ls); + if (ls->token != TK_eof) + err_token(ls, TK_eof); + pt = fs_finish(ls, ls->linenumber); + L->top--; /* Drop chunkname. */ + lua_assert(fs.prev == NULL); + lua_assert(ls->fs == NULL); + lua_assert(pt->sizeuv == 0); + return pt; +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_parse.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_parse.h new file mode 100644 index 000000000..dc4fd405d --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_parse.h @@ -0,0 +1,18 @@ +/* +** Lua parser (source code -> bytecode). +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_PARSE_H +#define _LJ_PARSE_H + +#include "lj_obj.h" +#include "lj_lex.h" + +LJ_FUNC GCproto *lj_parse(LexState *ls); +LJ_FUNC GCstr *lj_parse_keepstr(LexState *ls, const char *str, size_t l); +#if LJ_HASFFI +LJ_FUNC void lj_parse_keepcdata(LexState *ls, TValue *tv, GCcdata *cd); +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_record.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_record.c new file mode 100644 index 000000000..843108c85 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_record.c @@ -0,0 +1,2252 @@ +/* +** Trace recorder (bytecode -> SSA IR). +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_record_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_meta.h" +#include "lj_frame.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#endif +#include "lj_bc.h" +#include "lj_ff.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_ircall.h" +#include "lj_iropt.h" +#include "lj_trace.h" +#include "lj_record.h" +#include "lj_ffrecord.h" +#include "lj_snap.h" +#include "lj_dispatch.h" +#include "lj_vm.h" + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) + +/* Pass IR on to next optimization in chain (FOLD). */ +#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) + +/* Emit raw IR without passing through optimizations. */ +#define emitir_raw(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_ir_emit(J)) + +/* -- Sanity checks ------------------------------------------------------- */ + +#ifdef LUA_USE_ASSERT +/* Sanity check the whole IR -- sloooow. */ +static void rec_check_ir(jit_State *J) +{ + IRRef i, nins = J->cur.nins, nk = J->cur.nk; + lua_assert(nk <= REF_BIAS && nins >= REF_BIAS && nins < 65536); + for (i = nins-1; i >= nk; i--) { + IRIns *ir = IR(i); + uint32_t mode = lj_ir_mode[ir->o]; + IRRef op1 = ir->op1; + IRRef op2 = ir->op2; + switch (irm_op1(mode)) { + case IRMnone: lua_assert(op1 == 0); break; + case IRMref: lua_assert(op1 >= nk); + lua_assert(i >= REF_BIAS ? op1 < i : op1 > i); break; + case IRMlit: break; + case IRMcst: lua_assert(i < REF_BIAS); continue; + } + switch (irm_op2(mode)) { + case IRMnone: lua_assert(op2 == 0); break; + case IRMref: lua_assert(op2 >= nk); + lua_assert(i >= REF_BIAS ? op2 < i : op2 > i); break; + case IRMlit: break; + case IRMcst: lua_assert(0); break; + } + if (ir->prev) { + lua_assert(ir->prev >= nk); + lua_assert(i >= REF_BIAS ? ir->prev < i : ir->prev > i); + lua_assert(ir->o == IR_NOP || IR(ir->prev)->o == ir->o); + } + } +} + +/* Compare stack slots and frames of the recorder and the VM. */ +static void rec_check_slots(jit_State *J) +{ + BCReg s, nslots = J->baseslot + J->maxslot; + int32_t depth = 0; + cTValue *base = J->L->base - J->baseslot; + lua_assert(J->baseslot >= 1 && J->baseslot < LJ_MAX_JSLOTS); + lua_assert(J->baseslot == 1 || (J->slot[J->baseslot-1] & TREF_FRAME)); + lua_assert(nslots < LJ_MAX_JSLOTS); + for (s = 0; s < nslots; s++) { + TRef tr = J->slot[s]; + if (tr) { + cTValue *tv = &base[s]; + IRRef ref = tref_ref(tr); + IRIns *ir; + lua_assert(ref >= J->cur.nk && ref < J->cur.nins); + ir = IR(ref); + lua_assert(irt_t(ir->t) == tref_t(tr)); + if (s == 0) { + lua_assert(tref_isfunc(tr)); + } else if ((tr & TREF_FRAME)) { + GCfunc *fn = gco2func(frame_gc(tv)); + BCReg delta = (BCReg)(tv - frame_prev(tv)); + lua_assert(tref_isfunc(tr)); + if (tref_isk(tr)) lua_assert(fn == ir_kfunc(ir)); + lua_assert(s > delta ? (J->slot[s-delta] & TREF_FRAME) : (s == delta)); + depth++; + } else if ((tr & TREF_CONT)) { + lua_assert(ir_kptr(ir) == gcrefp(tv->gcr, void)); + lua_assert((J->slot[s+1] & TREF_FRAME)); + depth++; + } else { + if (tvisnumber(tv)) + lua_assert(tref_isnumber(tr)); /* Could be IRT_INT etc., too. */ + else + lua_assert(itype2irt(tv) == tref_type(tr)); + if (tref_isk(tr)) { /* Compare constants. */ + TValue tvk; + lj_ir_kvalue(J->L, &tvk, ir); + if (!(tvisnum(&tvk) && tvisnan(&tvk))) + lua_assert(lj_obj_equal(tv, &tvk)); + else + lua_assert(tvisnum(tv) && tvisnan(tv)); + } + } + } + } + lua_assert(J->framedepth == depth); +} +#endif + +/* -- Type handling and specialization ------------------------------------ */ + +/* Note: these functions return tagged references (TRef). */ + +/* Specialize a slot to a specific type. Note: slot can be negative! */ +static TRef sloadt(jit_State *J, int32_t slot, IRType t, int mode) +{ + /* Caller may set IRT_GUARD in t. */ + TRef ref = emitir_raw(IRT(IR_SLOAD, t), (int32_t)J->baseslot+slot, mode); + J->base[slot] = ref; + return ref; +} + +/* Specialize a slot to the runtime type. Note: slot can be negative! */ +static TRef sload(jit_State *J, int32_t slot) +{ + IRType t = itype2irt(&J->L->base[slot]); + TRef ref = emitir_raw(IRTG(IR_SLOAD, t), (int32_t)J->baseslot+slot, + IRSLOAD_TYPECHECK); + if (irtype_ispri(t)) ref = TREF_PRI(t); /* Canonicalize primitive refs. */ + J->base[slot] = ref; + return ref; +} + +/* Get TRef from slot. Load slot and specialize if not done already. */ +#define getslot(J, s) (J->base[(s)] ? J->base[(s)] : sload(J, (int32_t)(s))) + +/* Get TRef for current function. */ +static TRef getcurrf(jit_State *J) +{ + if (J->base[-1]) + return J->base[-1]; + lua_assert(J->baseslot == 1); + return sloadt(J, -1, IRT_FUNC, IRSLOAD_READONLY); +} + +/* Compare for raw object equality. +** Returns 0 if the objects are the same. +** Returns 1 if they are different, but the same type. +** Returns 2 for two different types. +** Comparisons between primitives always return 1 -- no caller cares about it. +*/ +int lj_record_objcmp(jit_State *J, TRef a, TRef b, cTValue *av, cTValue *bv) +{ + int diff = !lj_obj_equal(av, bv); + if (!tref_isk2(a, b)) { /* Shortcut, also handles primitives. */ + IRType ta = tref_isinteger(a) ? IRT_INT : tref_type(a); + IRType tb = tref_isinteger(b) ? IRT_INT : tref_type(b); + if (ta != tb) { + /* Widen mixed number/int comparisons to number/number comparison. */ + if (ta == IRT_INT && tb == IRT_NUM) { + a = emitir(IRTN(IR_CONV), a, IRCONV_NUM_INT); + ta = IRT_NUM; + } else if (ta == IRT_NUM && tb == IRT_INT) { + b = emitir(IRTN(IR_CONV), b, IRCONV_NUM_INT); + } else { + return 2; /* Two different types are never equal. */ + } + } + emitir(IRTG(diff ? IR_NE : IR_EQ, ta), a, b); + } + return diff; +} + +/* Constify a value. Returns 0 for non-representable object types. */ +TRef lj_record_constify(jit_State *J, cTValue *o) +{ + if (tvisgcv(o)) + return lj_ir_kgc(J, gcV(o), itype2irt(o)); + else if (tvisint(o)) + return lj_ir_kint(J, intV(o)); + else if (tvisnum(o)) + return lj_ir_knumint(J, numV(o)); + else if (tvisbool(o)) + return TREF_PRI(itype2irt(o)); + else + return 0; /* Can't represent lightuserdata (pointless). */ +} + +/* -- Record loop ops ----------------------------------------------------- */ + +/* Loop event. */ +typedef enum { + LOOPEV_LEAVE, /* Loop is left or not entered. */ + LOOPEV_ENTERLO, /* Loop is entered with a low iteration count left. */ + LOOPEV_ENTER /* Loop is entered. */ +} LoopEvent; + +/* Canonicalize slots: convert integers to numbers. */ +static void canonicalize_slots(jit_State *J) +{ + BCReg s; + if (LJ_DUALNUM) return; + for (s = J->baseslot+J->maxslot-1; s >= 1; s--) { + TRef tr = J->slot[s]; + if (tref_isinteger(tr)) { + IRIns *ir = IR(tref_ref(tr)); + if (!(ir->o == IR_SLOAD && (ir->op2 & IRSLOAD_READONLY))) + J->slot[s] = emitir(IRTN(IR_CONV), tr, IRCONV_NUM_INT); + } + } +} + +/* Stop recording. */ +static void rec_stop(jit_State *J, TraceLink linktype, TraceNo lnk) +{ + lj_trace_end(J); + J->cur.linktype = (uint8_t)linktype; + J->cur.link = (uint16_t)lnk; + /* Looping back at the same stack level? */ + if (lnk == J->cur.traceno && J->framedepth + J->retdepth == 0) { + if ((J->flags & JIT_F_OPT_LOOP)) /* Shall we try to create a loop? */ + goto nocanon; /* Do not canonicalize or we lose the narrowing. */ + if (J->cur.root) /* Otherwise ensure we always link to the root trace. */ + J->cur.link = J->cur.root; + } + canonicalize_slots(J); +nocanon: + /* Note: all loop ops must set J->pc to the following instruction! */ + lj_snap_add(J); /* Add loop snapshot. */ + J->needsnap = 0; + J->mergesnap = 1; /* In case recording continues. */ +} + +/* Search bytecode backwards for a int/num constant slot initializer. */ +static TRef find_kinit(jit_State *J, const BCIns *endpc, BCReg slot, IRType t) +{ + /* This algorithm is rather simplistic and assumes quite a bit about + ** how the bytecode is generated. It works fine for FORI initializers, + ** but it won't necessarily work in other cases (e.g. iterator arguments). + ** It doesn't do anything fancy, either (like backpropagating MOVs). + */ + const BCIns *pc, *startpc = proto_bc(J->pt); + for (pc = endpc-1; pc > startpc; pc--) { + BCIns ins = *pc; + BCOp op = bc_op(ins); + /* First try to find the last instruction that stores to this slot. */ + if (bcmode_a(op) == BCMbase && bc_a(ins) <= slot) { + return 0; /* Multiple results, e.g. from a CALL or KNIL. */ + } else if (bcmode_a(op) == BCMdst && bc_a(ins) == slot) { + if (op == BC_KSHORT || op == BC_KNUM) { /* Found const. initializer. */ + /* Now try to verify there's no forward jump across it. */ + const BCIns *kpc = pc; + for (; pc > startpc; pc--) + if (bc_op(*pc) == BC_JMP) { + const BCIns *target = pc+bc_j(*pc)+1; + if (target > kpc && target <= endpc) + return 0; /* Conditional assignment. */ + } + if (op == BC_KSHORT) { + int32_t k = (int32_t)(int16_t)bc_d(ins); + return t == IRT_INT ? lj_ir_kint(J, k) : lj_ir_knum(J, (lua_Number)k); + } else { + cTValue *tv = proto_knumtv(J->pt, bc_d(ins)); + if (t == IRT_INT) { + int32_t k = numberVint(tv); + if (tvisint(tv) || numV(tv) == (lua_Number)k) /* -0 is ok here. */ + return lj_ir_kint(J, k); + return 0; /* Type mismatch. */ + } else { + return lj_ir_knum(J, numberVnum(tv)); + } + } + } + return 0; /* Non-constant initializer. */ + } + } + return 0; /* No assignment to this slot found? */ +} + +/* Load and optionally convert a FORI argument from a slot. */ +static TRef fori_load(jit_State *J, BCReg slot, IRType t, int mode) +{ + int conv = (tvisint(&J->L->base[slot]) != (t==IRT_INT)) ? IRSLOAD_CONVERT : 0; + return sloadt(J, (int32_t)slot, + t + (((mode & IRSLOAD_TYPECHECK) || + (conv && t == IRT_INT && !(mode >> 16))) ? + IRT_GUARD : 0), + mode + conv); +} + +/* Peek before FORI to find a const initializer. Otherwise load from slot. */ +static TRef fori_arg(jit_State *J, const BCIns *fori, BCReg slot, + IRType t, int mode) +{ + TRef tr = J->base[slot]; + if (!tr) { + tr = find_kinit(J, fori, slot, t); + if (!tr) + tr = fori_load(J, slot, t, mode); + } + return tr; +} + +/* Return the direction of the FOR loop iterator. +** It's important to exactly reproduce the semantics of the interpreter. +*/ +static int rec_for_direction(cTValue *o) +{ + return (tvisint(o) ? intV(o) : (int32_t)o->u32.hi) >= 0; +} + +/* Simulate the runtime behavior of the FOR loop iterator. */ +static LoopEvent rec_for_iter(IROp *op, cTValue *o, int isforl) +{ + lua_Number stopv = numberVnum(&o[FORL_STOP]); + lua_Number idxv = numberVnum(&o[FORL_IDX]); + lua_Number stepv = numberVnum(&o[FORL_STEP]); + if (isforl) + idxv += stepv; + if (rec_for_direction(&o[FORL_STEP])) { + if (idxv <= stopv) { + *op = IR_LE; + return idxv + 2*stepv > stopv ? LOOPEV_ENTERLO : LOOPEV_ENTER; + } + *op = IR_GT; return LOOPEV_LEAVE; + } else { + if (stopv <= idxv) { + *op = IR_GE; + return idxv + 2*stepv < stopv ? LOOPEV_ENTERLO : LOOPEV_ENTER; + } + *op = IR_LT; return LOOPEV_LEAVE; + } +} + +/* Record checks for FOR loop overflow and step direction. */ +static void rec_for_check(jit_State *J, IRType t, int dir, + TRef stop, TRef step, int init) +{ + if (!tref_isk(step)) { + /* Non-constant step: need a guard for the direction. */ + TRef zero = (t == IRT_INT) ? lj_ir_kint(J, 0) : lj_ir_knum_zero(J); + emitir(IRTG(dir ? IR_GE : IR_LT, t), step, zero); + /* Add hoistable overflow checks for a narrowed FORL index. */ + if (init && t == IRT_INT) { + if (tref_isk(stop)) { + /* Constant stop: optimize check away or to a range check for step. */ + int32_t k = IR(tref_ref(stop))->i; + if (dir) { + if (k > 0) + emitir(IRTGI(IR_LE), step, lj_ir_kint(J, (int32_t)0x7fffffff-k)); + } else { + if (k < 0) + emitir(IRTGI(IR_GE), step, lj_ir_kint(J, (int32_t)0x80000000-k)); + } + } else { + /* Stop+step variable: need full overflow check. */ + TRef tr = emitir(IRTGI(IR_ADDOV), step, stop); + emitir(IRTI(IR_USE), tr, 0); /* ADDOV is weak. Avoid dead result. */ + } + } + } else if (init && t == IRT_INT && !tref_isk(stop)) { + /* Constant step: optimize overflow check to a range check for stop. */ + int32_t k = IR(tref_ref(step))->i; + k = (int32_t)(dir ? 0x7fffffff : 0x80000000) - k; + emitir(IRTGI(dir ? IR_LE : IR_GE), stop, lj_ir_kint(J, k)); + } +} + +/* Record a FORL instruction. */ +static void rec_for_loop(jit_State *J, const BCIns *fori, ScEvEntry *scev, + int init) +{ + BCReg ra = bc_a(*fori); + cTValue *tv = &J->L->base[ra]; + TRef idx = J->base[ra+FORL_IDX]; + IRType t = idx ? tref_type(idx) : + (init || LJ_DUALNUM) ? lj_opt_narrow_forl(J, tv) : IRT_NUM; + int mode = IRSLOAD_INHERIT + + ((!LJ_DUALNUM || tvisint(tv) == (t == IRT_INT)) ? IRSLOAD_READONLY : 0); + TRef stop = fori_arg(J, fori, ra+FORL_STOP, t, mode); + TRef step = fori_arg(J, fori, ra+FORL_STEP, t, mode); + int tc, dir = rec_for_direction(&tv[FORL_STEP]); + lua_assert(bc_op(*fori) == BC_FORI || bc_op(*fori) == BC_JFORI); + scev->t.irt = t; + scev->dir = dir; + scev->stop = tref_ref(stop); + scev->step = tref_ref(step); + rec_for_check(J, t, dir, stop, step, init); + scev->start = tref_ref(find_kinit(J, fori, ra+FORL_IDX, IRT_INT)); + tc = (LJ_DUALNUM && + !(scev->start && irref_isk(scev->stop) && irref_isk(scev->step) && + tvisint(&tv[FORL_IDX]) == (t == IRT_INT))) ? + IRSLOAD_TYPECHECK : 0; + if (tc) { + J->base[ra+FORL_STOP] = stop; + J->base[ra+FORL_STEP] = step; + } + if (!idx) + idx = fori_load(J, ra+FORL_IDX, t, + IRSLOAD_INHERIT + tc + (J->scev.start << 16)); + if (!init) + J->base[ra+FORL_IDX] = idx = emitir(IRT(IR_ADD, t), idx, step); + J->base[ra+FORL_EXT] = idx; + scev->idx = tref_ref(idx); + setmref(scev->pc, fori); + J->maxslot = ra+FORL_EXT+1; +} + +/* Record FORL/JFORL or FORI/JFORI. */ +static LoopEvent rec_for(jit_State *J, const BCIns *fori, int isforl) +{ + BCReg ra = bc_a(*fori); + TValue *tv = &J->L->base[ra]; + TRef *tr = &J->base[ra]; + IROp op; + LoopEvent ev; + TRef stop; + IRType t; + if (isforl) { /* Handle FORL/JFORL opcodes. */ + TRef idx = tr[FORL_IDX]; + if (mref(J->scev.pc, const BCIns) == fori && tref_ref(idx) == J->scev.idx) { + t = J->scev.t.irt; + stop = J->scev.stop; + idx = emitir(IRT(IR_ADD, t), idx, J->scev.step); + tr[FORL_EXT] = tr[FORL_IDX] = idx; + } else { + ScEvEntry scev; + rec_for_loop(J, fori, &scev, 0); + t = scev.t.irt; + stop = scev.stop; + } + } else { /* Handle FORI/JFORI opcodes. */ + BCReg i; + lj_meta_for(J->L, tv); + t = (LJ_DUALNUM || tref_isint(tr[FORL_IDX])) ? lj_opt_narrow_forl(J, tv) : + IRT_NUM; + for (i = FORL_IDX; i <= FORL_STEP; i++) { + if (!tr[i]) sload(J, ra+i); + lua_assert(tref_isnumber_str(tr[i])); + if (tref_isstr(tr[i])) + tr[i] = emitir(IRTG(IR_STRTO, IRT_NUM), tr[i], 0); + if (t == IRT_INT) { + if (!tref_isinteger(tr[i])) + tr[i] = emitir(IRTGI(IR_CONV), tr[i], IRCONV_INT_NUM|IRCONV_CHECK); + } else { + if (!tref_isnum(tr[i])) + tr[i] = emitir(IRTN(IR_CONV), tr[i], IRCONV_NUM_INT); + } + } + tr[FORL_EXT] = tr[FORL_IDX]; + stop = tr[FORL_STOP]; + rec_for_check(J, t, rec_for_direction(&tv[FORL_STEP]), + stop, tr[FORL_STEP], 1); + } + + ev = rec_for_iter(&op, tv, isforl); + if (ev == LOOPEV_LEAVE) { + J->maxslot = ra+FORL_EXT+1; + J->pc = fori+1; + } else { + J->maxslot = ra; + J->pc = fori+bc_j(*fori)+1; + } + lj_snap_add(J); + + emitir(IRTG(op, t), tr[FORL_IDX], stop); + + if (ev == LOOPEV_LEAVE) { + J->maxslot = ra; + J->pc = fori+bc_j(*fori)+1; + } else { + J->maxslot = ra+FORL_EXT+1; + J->pc = fori+1; + } + J->needsnap = 1; + return ev; +} + +/* Record ITERL/JITERL. */ +static LoopEvent rec_iterl(jit_State *J, const BCIns iterins) +{ + BCReg ra = bc_a(iterins); + lua_assert(J->base[ra] != 0); + if (!tref_isnil(J->base[ra])) { /* Looping back? */ + J->base[ra-1] = J->base[ra]; /* Copy result of ITERC to control var. */ + J->maxslot = ra-1+bc_b(J->pc[-1]); + J->pc += bc_j(iterins)+1; + return LOOPEV_ENTER; + } else { + J->maxslot = ra-3; + J->pc++; + return LOOPEV_LEAVE; + } +} + +/* Record LOOP/JLOOP. Now, that was easy. */ +static LoopEvent rec_loop(jit_State *J, BCReg ra) +{ + if (ra < J->maxslot) J->maxslot = ra; + J->pc++; + return LOOPEV_ENTER; +} + +/* Check if a loop repeatedly failed to trace because it didn't loop back. */ +static int innerloopleft(jit_State *J, const BCIns *pc) +{ + ptrdiff_t i; + for (i = 0; i < PENALTY_SLOTS; i++) + if (mref(J->penalty[i].pc, const BCIns) == pc) { + if ((J->penalty[i].reason == LJ_TRERR_LLEAVE || + J->penalty[i].reason == LJ_TRERR_LINNER) && + J->penalty[i].val >= 2*PENALTY_MIN) + return 1; + break; + } + return 0; +} + +/* Handle the case when an interpreted loop op is hit. */ +static void rec_loop_interp(jit_State *J, const BCIns *pc, LoopEvent ev) +{ + if (J->parent == 0) { + if (pc == J->startpc && J->framedepth + J->retdepth == 0) { + /* Same loop? */ + if (ev == LOOPEV_LEAVE) /* Must loop back to form a root trace. */ + lj_trace_err(J, LJ_TRERR_LLEAVE); + rec_stop(J, LJ_TRLINK_LOOP, J->cur.traceno); /* Looping root trace. */ + } else if (ev != LOOPEV_LEAVE) { /* Entering inner loop? */ + /* It's usually better to abort here and wait until the inner loop + ** is traced. But if the inner loop repeatedly didn't loop back, + ** this indicates a low trip count. In this case try unrolling + ** an inner loop even in a root trace. But it's better to be a bit + ** more conservative here and only do it for very short loops. + */ + if (bc_j(*pc) != -1 && !innerloopleft(J, pc)) + lj_trace_err(J, LJ_TRERR_LINNER); /* Root trace hit an inner loop. */ + if ((ev != LOOPEV_ENTERLO && + J->loopref && J->cur.nins - J->loopref > 24) || --J->loopunroll < 0) + lj_trace_err(J, LJ_TRERR_LUNROLL); /* Limit loop unrolling. */ + J->loopref = J->cur.nins; + } + } else if (ev != LOOPEV_LEAVE) { /* Side trace enters an inner loop. */ + J->loopref = J->cur.nins; + if (--J->loopunroll < 0) + lj_trace_err(J, LJ_TRERR_LUNROLL); /* Limit loop unrolling. */ + } /* Side trace continues across a loop that's left or not entered. */ +} + +/* Handle the case when an already compiled loop op is hit. */ +static void rec_loop_jit(jit_State *J, TraceNo lnk, LoopEvent ev) +{ + if (J->parent == 0) { /* Root trace hit an inner loop. */ + /* Better let the inner loop spawn a side trace back here. */ + lj_trace_err(J, LJ_TRERR_LINNER); + } else if (ev != LOOPEV_LEAVE) { /* Side trace enters a compiled loop. */ + J->instunroll = 0; /* Cannot continue across a compiled loop op. */ + if (J->pc == J->startpc && J->framedepth + J->retdepth == 0) + rec_stop(J, LJ_TRLINK_LOOP, J->cur.traceno); /* Form an extra loop. */ + else + rec_stop(J, LJ_TRLINK_ROOT, lnk); /* Link to the loop. */ + } /* Side trace continues across a loop that's left or not entered. */ +} + +/* -- Record calls and returns -------------------------------------------- */ + +/* Specialize to the runtime value of the called function or its prototype. */ +static TRef rec_call_specialize(jit_State *J, GCfunc *fn, TRef tr) +{ + TRef kfunc; + if (isluafunc(fn)) { + GCproto *pt = funcproto(fn); + /* Too many closures created? Probably not a monomorphic function. */ + if (pt->flags >= PROTO_CLC_POLY) { /* Specialize to prototype instead. */ + TRef trpt = emitir(IRT(IR_FLOAD, IRT_P32), tr, IRFL_FUNC_PC); + emitir(IRTG(IR_EQ, IRT_P32), trpt, lj_ir_kptr(J, proto_bc(pt))); + (void)lj_ir_kgc(J, obj2gco(pt), IRT_PROTO); /* Prevent GC of proto. */ + return tr; + } + } + /* Otherwise specialize to the function (closure) value itself. */ + kfunc = lj_ir_kfunc(J, fn); + emitir(IRTG(IR_EQ, IRT_FUNC), tr, kfunc); + return kfunc; +} + +/* Record call setup. */ +static void rec_call_setup(jit_State *J, BCReg func, ptrdiff_t nargs) +{ + RecordIndex ix; + TValue *functv = &J->L->base[func]; + TRef *fbase = &J->base[func]; + ptrdiff_t i; + for (i = 0; i <= nargs; i++) + (void)getslot(J, func+i); /* Ensure func and all args have a reference. */ + if (!tref_isfunc(fbase[0])) { /* Resolve __call metamethod. */ + ix.tab = fbase[0]; + copyTV(J->L, &ix.tabv, functv); + if (!lj_record_mm_lookup(J, &ix, MM_call) || !tref_isfunc(ix.mobj)) + lj_trace_err(J, LJ_TRERR_NOMM); + for (i = ++nargs; i > 0; i--) /* Shift arguments up. */ + fbase[i] = fbase[i-1]; + fbase[0] = ix.mobj; /* Replace function. */ + functv = &ix.mobjv; + } + fbase[0] = TREF_FRAME | rec_call_specialize(J, funcV(functv), fbase[0]); + J->maxslot = (BCReg)nargs; +} + +/* Record call. */ +void lj_record_call(jit_State *J, BCReg func, ptrdiff_t nargs) +{ + rec_call_setup(J, func, nargs); + /* Bump frame. */ + J->framedepth++; + J->base += func+1; + J->baseslot += func+1; +} + +/* Record tail call. */ +void lj_record_tailcall(jit_State *J, BCReg func, ptrdiff_t nargs) +{ + rec_call_setup(J, func, nargs); + if (frame_isvarg(J->L->base - 1)) { + BCReg cbase = (BCReg)frame_delta(J->L->base - 1); + if (--J->framedepth < 0) + lj_trace_err(J, LJ_TRERR_NYIRETL); + J->baseslot -= (BCReg)cbase; + J->base -= cbase; + func += cbase; + } + /* Move func + args down. */ + memmove(&J->base[-1], &J->base[func], sizeof(TRef)*(J->maxslot+1)); + /* Note: the new TREF_FRAME is now at J->base[-1] (even for slot #0). */ + /* Tailcalls can form a loop, so count towards the loop unroll limit. */ + if (++J->tailcalled > J->loopunroll) + lj_trace_err(J, LJ_TRERR_LUNROLL); +} + +/* Check unroll limits for down-recursion. */ +static int check_downrec_unroll(jit_State *J, GCproto *pt) +{ + IRRef ptref; + for (ptref = J->chain[IR_KGC]; ptref; ptref = IR(ptref)->prev) + if (ir_kgc(IR(ptref)) == obj2gco(pt)) { + int count = 0; + IRRef ref; + for (ref = J->chain[IR_RETF]; ref; ref = IR(ref)->prev) + if (IR(ref)->op1 == ptref) + count++; + if (count) { + if (J->pc == J->startpc) { + if (count + J->tailcalled > J->param[JIT_P_recunroll]) + return 1; + } else { + lj_trace_err(J, LJ_TRERR_DOWNREC); + } + } + } + return 0; +} + +/* Record return. */ +void lj_record_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults) +{ + TValue *frame = J->L->base - 1; + ptrdiff_t i; + for (i = 0; i < gotresults; i++) + (void)getslot(J, rbase+i); /* Ensure all results have a reference. */ + while (frame_ispcall(frame)) { /* Immediately resolve pcall() returns. */ + BCReg cbase = (BCReg)frame_delta(frame); + if (--J->framedepth < 0) + lj_trace_err(J, LJ_TRERR_NYIRETL); + lua_assert(J->baseslot > 1); + gotresults++; + rbase += cbase; + J->baseslot -= (BCReg)cbase; + J->base -= cbase; + J->base[--rbase] = TREF_TRUE; /* Prepend true to results. */ + frame = frame_prevd(frame); + } + /* Return to lower frame via interpreter for unhandled cases. */ + if (J->framedepth == 0 && J->pt && bc_isret(bc_op(*J->pc)) && + (!frame_islua(frame) || + (J->parent == 0 && !bc_isret(bc_op(J->cur.startins))))) { + /* NYI: specialize to frame type and return directly, not via RET*. */ + for (i = 0; i < (ptrdiff_t)rbase; i++) + J->base[i] = 0; /* Purge dead slots. */ + J->maxslot = rbase + (BCReg)gotresults; + rec_stop(J, LJ_TRLINK_RETURN, 0); /* Return to interpreter. */ + return; + } + if (frame_isvarg(frame)) { + BCReg cbase = (BCReg)frame_delta(frame); + if (--J->framedepth < 0) /* NYI: return of vararg func to lower frame. */ + lj_trace_err(J, LJ_TRERR_NYIRETL); + lua_assert(J->baseslot > 1); + rbase += cbase; + J->baseslot -= (BCReg)cbase; + J->base -= cbase; + frame = frame_prevd(frame); + } + if (frame_islua(frame)) { /* Return to Lua frame. */ + BCIns callins = *(frame_pc(frame)-1); + ptrdiff_t nresults = bc_b(callins) ? (ptrdiff_t)bc_b(callins)-1 :gotresults; + BCReg cbase = bc_a(callins); + GCproto *pt = funcproto(frame_func(frame - (cbase+1))); + if ((pt->flags & PROTO_NOJIT)) + lj_trace_err(J, LJ_TRERR_CJITOFF); + if (J->framedepth == 0 && J->pt && frame == J->L->base - 1) { + if (check_downrec_unroll(J, pt)) { + J->maxslot = (BCReg)(rbase + gotresults); + lj_snap_purge(J); + rec_stop(J, LJ_TRLINK_DOWNREC, J->cur.traceno); /* Down-recursion. */ + return; + } + lj_snap_add(J); + } + for (i = 0; i < nresults; i++) /* Adjust results. */ + J->base[i-1] = i < gotresults ? J->base[rbase+i] : TREF_NIL; + J->maxslot = cbase+(BCReg)nresults; + if (J->framedepth > 0) { /* Return to a frame that is part of the trace. */ + J->framedepth--; + lua_assert(J->baseslot > cbase+1); + J->baseslot -= cbase+1; + J->base -= cbase+1; + } else if (J->parent == 0 && !bc_isret(bc_op(J->cur.startins))) { + /* Return to lower frame would leave the loop in a root trace. */ + lj_trace_err(J, LJ_TRERR_LLEAVE); + } else if (J->needsnap) { /* Tailcalled to ff with side-effects. */ + lj_trace_err(J, LJ_TRERR_NYIRETL); /* No way to insert snapshot here. */ + } else { /* Return to lower frame. Guard for the target we return to. */ + TRef trpt = lj_ir_kgc(J, obj2gco(pt), IRT_PROTO); + TRef trpc = lj_ir_kptr(J, (void *)frame_pc(frame)); + emitir(IRTG(IR_RETF, IRT_P32), trpt, trpc); + J->retdepth++; + J->needsnap = 1; + lua_assert(J->baseslot == 1); + /* Shift result slots up and clear the slots of the new frame below. */ + memmove(J->base + cbase, J->base-1, sizeof(TRef)*nresults); + memset(J->base-1, 0, sizeof(TRef)*(cbase+1)); + } + } else if (frame_iscont(frame)) { /* Return to continuation frame. */ + ASMFunction cont = frame_contf(frame); + BCReg cbase = (BCReg)frame_delta(frame); + if ((J->framedepth -= 2) < 0) + lj_trace_err(J, LJ_TRERR_NYIRETL); + J->baseslot -= (BCReg)cbase; + J->base -= cbase; + J->maxslot = cbase-2; + if (cont == lj_cont_ra) { + /* Copy result to destination slot. */ + BCReg dst = bc_a(*(frame_contpc(frame)-1)); + J->base[dst] = gotresults ? J->base[cbase+rbase] : TREF_NIL; + if (dst >= J->maxslot) J->maxslot = dst+1; + } else if (cont == lj_cont_nop) { + /* Nothing to do here. */ + } else if (cont == lj_cont_cat) { + lua_assert(0); + } else { + /* Result type already specialized. */ + lua_assert(cont == lj_cont_condf || cont == lj_cont_condt); + } + } else { + lj_trace_err(J, LJ_TRERR_NYIRETL); /* NYI: handle return to C frame. */ + } + lua_assert(J->baseslot >= 1); +} + +/* -- Metamethod handling ------------------------------------------------- */ + +/* Prepare to record call to metamethod. */ +static BCReg rec_mm_prep(jit_State *J, ASMFunction cont) +{ + BCReg s, top = curr_proto(J->L)->framesize; + TRef trcont; + setcont(&J->L->base[top], cont); +#if LJ_64 + trcont = lj_ir_kptr(J, (void *)((int64_t)cont - (int64_t)lj_vm_asm_begin)); +#else + trcont = lj_ir_kptr(J, (void *)cont); +#endif + J->base[top] = trcont | TREF_CONT; + J->framedepth++; + for (s = J->maxslot; s < top; s++) + J->base[s] = 0; /* Clear frame gap to avoid resurrecting previous refs. */ + return top+1; +} + +/* Record metamethod lookup. */ +int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm) +{ + RecordIndex mix; + GCtab *mt; + if (tref_istab(ix->tab)) { + mt = tabref(tabV(&ix->tabv)->metatable); + mix.tab = emitir(IRT(IR_FLOAD, IRT_TAB), ix->tab, IRFL_TAB_META); + } else if (tref_isudata(ix->tab)) { + int udtype = udataV(&ix->tabv)->udtype; + mt = tabref(udataV(&ix->tabv)->metatable); + /* The metatables of special userdata objects are treated as immutable. */ + if (udtype != UDTYPE_USERDATA) { + cTValue *mo; + if (LJ_HASFFI && udtype == UDTYPE_FFI_CLIB) { + /* Specialize to the C library namespace object. */ + emitir(IRTG(IR_EQ, IRT_P32), ix->tab, lj_ir_kptr(J, udataV(&ix->tabv))); + } else { + /* Specialize to the type of userdata. */ + TRef tr = emitir(IRT(IR_FLOAD, IRT_U8), ix->tab, IRFL_UDATA_UDTYPE); + emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, udtype)); + } + immutable_mt: + mo = lj_tab_getstr(mt, mmname_str(J2G(J), mm)); + if (!mo || tvisnil(mo)) + return 0; /* No metamethod. */ + /* Treat metamethod or index table as immutable, too. */ + if (!(tvisfunc(mo) || tvistab(mo))) + lj_trace_err(J, LJ_TRERR_BADTYPE); + copyTV(J->L, &ix->mobjv, mo); + ix->mobj = lj_ir_kgc(J, gcV(mo), tvisfunc(mo) ? IRT_FUNC : IRT_TAB); + ix->mtv = mt; + ix->mt = TREF_NIL; /* Dummy value for comparison semantics. */ + return 1; /* Got metamethod or index table. */ + } + mix.tab = emitir(IRT(IR_FLOAD, IRT_TAB), ix->tab, IRFL_UDATA_META); + } else { + /* Specialize to base metatable. Must flush mcode in lua_setmetatable(). */ + mt = tabref(basemt_obj(J2G(J), &ix->tabv)); + if (mt == NULL) { + ix->mt = TREF_NIL; + return 0; /* No metamethod. */ + } + /* The cdata metatable is treated as immutable. */ + if (LJ_HASFFI && tref_iscdata(ix->tab)) goto immutable_mt; + ix->mt = mix.tab = lj_ir_ktab(J, mt); + goto nocheck; + } + ix->mt = mt ? mix.tab : TREF_NIL; + emitir(IRTG(mt ? IR_NE : IR_EQ, IRT_TAB), mix.tab, lj_ir_knull(J, IRT_TAB)); +nocheck: + if (mt) { + GCstr *mmstr = mmname_str(J2G(J), mm); + cTValue *mo = lj_tab_getstr(mt, mmstr); + if (mo && !tvisnil(mo)) + copyTV(J->L, &ix->mobjv, mo); + ix->mtv = mt; + settabV(J->L, &mix.tabv, mt); + setstrV(J->L, &mix.keyv, mmstr); + mix.key = lj_ir_kstr(J, mmstr); + mix.val = 0; + mix.idxchain = 0; + ix->mobj = lj_record_idx(J, &mix); + return !tref_isnil(ix->mobj); /* 1 if metamethod found, 0 if not. */ + } + return 0; /* No metamethod. */ +} + +/* Record call to arithmetic metamethod. */ +static TRef rec_mm_arith(jit_State *J, RecordIndex *ix, MMS mm) +{ + /* Set up metamethod call first to save ix->tab and ix->tabv. */ + BCReg func = rec_mm_prep(J, lj_cont_ra); + TRef *base = J->base + func; + TValue *basev = J->L->base + func; + base[1] = ix->tab; base[2] = ix->key; + copyTV(J->L, basev+1, &ix->tabv); + copyTV(J->L, basev+2, &ix->keyv); + if (!lj_record_mm_lookup(J, ix, mm)) { /* Lookup mm on 1st operand. */ + if (mm != MM_unm) { + ix->tab = ix->key; + copyTV(J->L, &ix->tabv, &ix->keyv); + if (lj_record_mm_lookup(J, ix, mm)) /* Lookup mm on 2nd operand. */ + goto ok; + } + lj_trace_err(J, LJ_TRERR_NOMM); + } +ok: + base[0] = ix->mobj; + copyTV(J->L, basev+0, &ix->mobjv); + lj_record_call(J, func, 2); + return 0; /* No result yet. */ +} + +/* Record call to __len metamethod. */ +static TRef rec_mm_len(jit_State *J, TRef tr, TValue *tv) +{ + RecordIndex ix; + ix.tab = tr; + copyTV(J->L, &ix.tabv, tv); + if (lj_record_mm_lookup(J, &ix, MM_len)) { + BCReg func = rec_mm_prep(J, lj_cont_ra); + TRef *base = J->base + func; + TValue *basev = J->L->base + func; + base[0] = ix.mobj; copyTV(J->L, basev+0, &ix.mobjv); + base[1] = tr; copyTV(J->L, basev+1, tv); +#if LJ_52 + base[2] = tr; copyTV(J->L, basev+2, tv); +#else + base[2] = TREF_NIL; setnilV(basev+2); +#endif + lj_record_call(J, func, 2); + } else { + if (LJ_52 && tref_istab(tr)) + return lj_ir_call(J, IRCALL_lj_tab_len, tr); + lj_trace_err(J, LJ_TRERR_NOMM); + } + return 0; /* No result yet. */ +} + +/* Call a comparison metamethod. */ +static void rec_mm_callcomp(jit_State *J, RecordIndex *ix, int op) +{ + BCReg func = rec_mm_prep(J, (op&1) ? lj_cont_condf : lj_cont_condt); + TRef *base = J->base + func; + TValue *tv = J->L->base + func; + base[0] = ix->mobj; base[1] = ix->val; base[2] = ix->key; + copyTV(J->L, tv+0, &ix->mobjv); + copyTV(J->L, tv+1, &ix->valv); + copyTV(J->L, tv+2, &ix->keyv); + lj_record_call(J, func, 2); +} + +/* Record call to equality comparison metamethod (for tab and udata only). */ +static void rec_mm_equal(jit_State *J, RecordIndex *ix, int op) +{ + ix->tab = ix->val; + copyTV(J->L, &ix->tabv, &ix->valv); + if (lj_record_mm_lookup(J, ix, MM_eq)) { /* Lookup mm on 1st operand. */ + cTValue *bv; + TRef mo1 = ix->mobj; + TValue mo1v; + copyTV(J->L, &mo1v, &ix->mobjv); + /* Avoid the 2nd lookup and the objcmp if the metatables are equal. */ + bv = &ix->keyv; + if (tvistab(bv) && tabref(tabV(bv)->metatable) == ix->mtv) { + TRef mt2 = emitir(IRT(IR_FLOAD, IRT_TAB), ix->key, IRFL_TAB_META); + emitir(IRTG(IR_EQ, IRT_TAB), mt2, ix->mt); + } else if (tvisudata(bv) && tabref(udataV(bv)->metatable) == ix->mtv) { + TRef mt2 = emitir(IRT(IR_FLOAD, IRT_TAB), ix->key, IRFL_UDATA_META); + emitir(IRTG(IR_EQ, IRT_TAB), mt2, ix->mt); + } else { /* Lookup metamethod on 2nd operand and compare both. */ + ix->tab = ix->key; + copyTV(J->L, &ix->tabv, bv); + if (!lj_record_mm_lookup(J, ix, MM_eq) || + lj_record_objcmp(J, mo1, ix->mobj, &mo1v, &ix->mobjv)) + return; + } + rec_mm_callcomp(J, ix, op); + } +} + +/* Record call to ordered comparison metamethods (for arbitrary objects). */ +static void rec_mm_comp(jit_State *J, RecordIndex *ix, int op) +{ + ix->tab = ix->val; + copyTV(J->L, &ix->tabv, &ix->valv); + while (1) { + MMS mm = (op & 2) ? MM_le : MM_lt; /* Try __le + __lt or only __lt. */ +#if LJ_52 + if (!lj_record_mm_lookup(J, ix, mm)) { /* Lookup mm on 1st operand. */ + ix->tab = ix->key; + copyTV(J->L, &ix->tabv, &ix->keyv); + if (!lj_record_mm_lookup(J, ix, mm)) /* Lookup mm on 2nd operand. */ + goto nomatch; + } + rec_mm_callcomp(J, ix, op); + return; +#else + if (lj_record_mm_lookup(J, ix, mm)) { /* Lookup mm on 1st operand. */ + cTValue *bv; + TRef mo1 = ix->mobj; + TValue mo1v; + copyTV(J->L, &mo1v, &ix->mobjv); + /* Avoid the 2nd lookup and the objcmp if the metatables are equal. */ + bv = &ix->keyv; + if (tvistab(bv) && tabref(tabV(bv)->metatable) == ix->mtv) { + TRef mt2 = emitir(IRT(IR_FLOAD, IRT_TAB), ix->key, IRFL_TAB_META); + emitir(IRTG(IR_EQ, IRT_TAB), mt2, ix->mt); + } else if (tvisudata(bv) && tabref(udataV(bv)->metatable) == ix->mtv) { + TRef mt2 = emitir(IRT(IR_FLOAD, IRT_TAB), ix->key, IRFL_UDATA_META); + emitir(IRTG(IR_EQ, IRT_TAB), mt2, ix->mt); + } else { /* Lookup metamethod on 2nd operand and compare both. */ + ix->tab = ix->key; + copyTV(J->L, &ix->tabv, bv); + if (!lj_record_mm_lookup(J, ix, mm) || + lj_record_objcmp(J, mo1, ix->mobj, &mo1v, &ix->mobjv)) + goto nomatch; + } + rec_mm_callcomp(J, ix, op); + return; + } +#endif + nomatch: + /* Lookup failed. Retry with __lt and swapped operands. */ + if (!(op & 2)) break; /* Already at __lt. Interpreter will throw. */ + ix->tab = ix->key; ix->key = ix->val; ix->val = ix->tab; + copyTV(J->L, &ix->tabv, &ix->keyv); + copyTV(J->L, &ix->keyv, &ix->valv); + copyTV(J->L, &ix->valv, &ix->tabv); + op ^= 3; + } +} + +#if LJ_HASFFI +/* Setup call to cdata comparison metamethod. */ +static void rec_mm_comp_cdata(jit_State *J, RecordIndex *ix, int op, MMS mm) +{ + lj_snap_add(J); + if (tref_iscdata(ix->val)) { + ix->tab = ix->val; + copyTV(J->L, &ix->tabv, &ix->valv); + } else { + lua_assert(tref_iscdata(ix->key)); + ix->tab = ix->key; + copyTV(J->L, &ix->tabv, &ix->keyv); + } + lj_record_mm_lookup(J, ix, mm); + rec_mm_callcomp(J, ix, op); +} +#endif + +/* -- Indexed access ------------------------------------------------------ */ + +/* Record bounds-check. */ +static void rec_idx_abc(jit_State *J, TRef asizeref, TRef ikey, uint32_t asize) +{ + /* Try to emit invariant bounds checks. */ + if ((J->flags & (JIT_F_OPT_LOOP|JIT_F_OPT_ABC)) == + (JIT_F_OPT_LOOP|JIT_F_OPT_ABC)) { + IRRef ref = tref_ref(ikey); + IRIns *ir = IR(ref); + int32_t ofs = 0; + IRRef ofsref = 0; + /* Handle constant offsets. */ + if (ir->o == IR_ADD && irref_isk(ir->op2)) { + ofsref = ir->op2; + ofs = IR(ofsref)->i; + ref = ir->op1; + ir = IR(ref); + } + /* Got scalar evolution analysis results for this reference? */ + if (ref == J->scev.idx) { + int32_t stop; + lua_assert(irt_isint(J->scev.t) && ir->o == IR_SLOAD); + stop = numberVint(&(J->L->base - J->baseslot)[ir->op1 + FORL_STOP]); + /* Runtime value for stop of loop is within bounds? */ + if ((uint64_t)stop + ofs < (uint64_t)asize) { + /* Emit invariant bounds check for stop. */ + emitir(IRTG(IR_ABC, IRT_P32), asizeref, ofs == 0 ? J->scev.stop : + emitir(IRTI(IR_ADD), J->scev.stop, ofsref)); + /* Emit invariant bounds check for start, if not const or negative. */ + if (!(J->scev.dir && J->scev.start && + (int64_t)IR(J->scev.start)->i + ofs >= 0)) + emitir(IRTG(IR_ABC, IRT_P32), asizeref, ikey); + return; + } + } + } + emitir(IRTGI(IR_ABC), asizeref, ikey); /* Emit regular bounds check. */ +} + +/* Record indexed key lookup. */ +static TRef rec_idx_key(jit_State *J, RecordIndex *ix) +{ + TRef key; + GCtab *t = tabV(&ix->tabv); + ix->oldv = lj_tab_get(J->L, t, &ix->keyv); /* Lookup previous value. */ + + /* Integer keys are looked up in the array part first. */ + key = ix->key; + if (tref_isnumber(key)) { + int32_t k = numberVint(&ix->keyv); + if (!tvisint(&ix->keyv) && numV(&ix->keyv) != (lua_Number)k) + k = LJ_MAX_ASIZE; + if ((MSize)k < LJ_MAX_ASIZE) { /* Potential array key? */ + TRef ikey = lj_opt_narrow_index(J, key); + TRef asizeref = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_ASIZE); + if ((MSize)k < t->asize) { /* Currently an array key? */ + TRef arrayref; + rec_idx_abc(J, asizeref, ikey, t->asize); + arrayref = emitir(IRT(IR_FLOAD, IRT_P32), ix->tab, IRFL_TAB_ARRAY); + return emitir(IRT(IR_AREF, IRT_P32), arrayref, ikey); + } else { /* Currently not in array (may be an array extension)? */ + emitir(IRTGI(IR_ULE), asizeref, ikey); /* Inv. bounds check. */ + if (k == 0 && tref_isk(key)) + key = lj_ir_knum_zero(J); /* Canonicalize 0 or +-0.0 to +0.0. */ + /* And continue with the hash lookup. */ + } + } else if (!tref_isk(key)) { + /* We can rule out const numbers which failed the integerness test + ** above. But all other numbers are potential array keys. + */ + if (t->asize == 0) { /* True sparse tables have an empty array part. */ + /* Guard that the array part stays empty. */ + TRef tmp = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_ASIZE); + emitir(IRTGI(IR_EQ), tmp, lj_ir_kint(J, 0)); + } else { + lj_trace_err(J, LJ_TRERR_NYITMIX); + } + } + } + + /* Otherwise the key is located in the hash part. */ + if (t->hmask == 0) { /* Shortcut for empty hash part. */ + /* Guard that the hash part stays empty. */ + TRef tmp = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_HMASK); + emitir(IRTGI(IR_EQ), tmp, lj_ir_kint(J, 0)); + return lj_ir_kkptr(J, niltvg(J2G(J))); + } + if (tref_isinteger(key)) /* Hash keys are based on numbers, not ints. */ + key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT); + if (tref_isk(key)) { + /* Optimize lookup of constant hash keys. */ + MSize hslot = (MSize)((char *)ix->oldv - (char *)&noderef(t->node)[0].val); + if (t->hmask > 0 && hslot <= t->hmask*(MSize)sizeof(Node) && + hslot <= 65535*(MSize)sizeof(Node)) { + TRef node, kslot; + TRef hm = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_HMASK); + emitir(IRTGI(IR_EQ), hm, lj_ir_kint(J, (int32_t)t->hmask)); + node = emitir(IRT(IR_FLOAD, IRT_P32), ix->tab, IRFL_TAB_NODE); + kslot = lj_ir_kslot(J, key, hslot / sizeof(Node)); + return emitir(IRTG(IR_HREFK, IRT_P32), node, kslot); + } + } + /* Fall back to a regular hash lookup. */ + return emitir(IRT(IR_HREF, IRT_P32), ix->tab, key); +} + +/* Determine whether a key is NOT one of the fast metamethod names. */ +static int nommstr(jit_State *J, TRef key) +{ + if (tref_isstr(key)) { + if (tref_isk(key)) { + GCstr *str = ir_kstr(IR(tref_ref(key))); + uint32_t mm; + for (mm = 0; mm <= MM_FAST; mm++) + if (mmname_str(J2G(J), mm) == str) + return 0; /* MUST be one the fast metamethod names. */ + } else { + return 0; /* Variable string key MAY be a metamethod name. */ + } + } + return 1; /* CANNOT be a metamethod name. */ +} + +/* Record indexed load/store. */ +TRef lj_record_idx(jit_State *J, RecordIndex *ix) +{ + TRef xref; + IROp xrefop, loadop; + cTValue *oldv; + + while (!tref_istab(ix->tab)) { /* Handle non-table lookup. */ + /* Never call raw lj_record_idx() on non-table. */ + lua_assert(ix->idxchain != 0); + if (!lj_record_mm_lookup(J, ix, ix->val ? MM_newindex : MM_index)) + lj_trace_err(J, LJ_TRERR_NOMM); + handlemm: + if (tref_isfunc(ix->mobj)) { /* Handle metamethod call. */ + BCReg func = rec_mm_prep(J, ix->val ? lj_cont_nop : lj_cont_ra); + TRef *base = J->base + func; + TValue *tv = J->L->base + func; + base[0] = ix->mobj; base[1] = ix->tab; base[2] = ix->key; + setfuncV(J->L, tv+0, funcV(&ix->mobjv)); + copyTV(J->L, tv+1, &ix->tabv); + copyTV(J->L, tv+2, &ix->keyv); + if (ix->val) { + base[3] = ix->val; + copyTV(J->L, tv+3, &ix->valv); + lj_record_call(J, func, 3); /* mobj(tab, key, val) */ + return 0; + } else { + lj_record_call(J, func, 2); /* res = mobj(tab, key) */ + return 0; /* No result yet. */ + } + } + /* Otherwise retry lookup with metaobject. */ + ix->tab = ix->mobj; + copyTV(J->L, &ix->tabv, &ix->mobjv); + if (--ix->idxchain == 0) + lj_trace_err(J, LJ_TRERR_IDXLOOP); + } + + /* First catch nil and NaN keys for tables. */ + if (tvisnil(&ix->keyv) || (tvisnum(&ix->keyv) && tvisnan(&ix->keyv))) { + if (ix->val) /* Better fail early. */ + lj_trace_err(J, LJ_TRERR_STORENN); + if (tref_isk(ix->key)) { + if (ix->idxchain && lj_record_mm_lookup(J, ix, MM_index)) + goto handlemm; + return TREF_NIL; + } + } + + /* Record the key lookup. */ + xref = rec_idx_key(J, ix); + xrefop = IR(tref_ref(xref))->o; + loadop = xrefop == IR_AREF ? IR_ALOAD : IR_HLOAD; + /* The lj_meta_tset() inconsistency is gone, but better play safe. */ + oldv = xrefop == IR_KKPTR ? (cTValue *)ir_kptr(IR(tref_ref(xref))) : ix->oldv; + + if (ix->val == 0) { /* Indexed load */ + IRType t = itype2irt(oldv); + TRef res; + if (oldv == niltvg(J2G(J))) { + emitir(IRTG(IR_EQ, IRT_P32), xref, lj_ir_kkptr(J, niltvg(J2G(J)))); + res = TREF_NIL; + } else { + res = emitir(IRTG(loadop, t), xref, 0); + } + if (t == IRT_NIL && ix->idxchain && lj_record_mm_lookup(J, ix, MM_index)) + goto handlemm; + if (irtype_ispri(t)) res = TREF_PRI(t); /* Canonicalize primitives. */ + return res; + } else { /* Indexed store. */ + GCtab *mt = tabref(tabV(&ix->tabv)->metatable); + int keybarrier = tref_isgcv(ix->key) && !tref_isnil(ix->val); + if (tvisnil(oldv)) { /* Previous value was nil? */ + /* Need to duplicate the hasmm check for the early guards. */ + int hasmm = 0; + if (ix->idxchain && mt) { + cTValue *mo = lj_tab_getstr(mt, mmname_str(J2G(J), MM_newindex)); + hasmm = mo && !tvisnil(mo); + } + if (hasmm) + emitir(IRTG(loadop, IRT_NIL), xref, 0); /* Guard for nil value. */ + else if (xrefop == IR_HREF) + emitir(IRTG(oldv == niltvg(J2G(J)) ? IR_EQ : IR_NE, IRT_P32), + xref, lj_ir_kkptr(J, niltvg(J2G(J)))); + if (ix->idxchain && lj_record_mm_lookup(J, ix, MM_newindex)) { + lua_assert(hasmm); + goto handlemm; + } + lua_assert(!hasmm); + if (oldv == niltvg(J2G(J))) { /* Need to insert a new key. */ + TRef key = ix->key; + if (tref_isinteger(key)) /* NEWREF needs a TValue as a key. */ + key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT); + xref = emitir(IRT(IR_NEWREF, IRT_P32), ix->tab, key); + keybarrier = 0; /* NEWREF already takes care of the key barrier. */ + } + } else if (!lj_opt_fwd_wasnonnil(J, loadop, tref_ref(xref))) { + /* Cannot derive that the previous value was non-nil, must do checks. */ + if (xrefop == IR_HREF) /* Guard against store to niltv. */ + emitir(IRTG(IR_NE, IRT_P32), xref, lj_ir_kkptr(J, niltvg(J2G(J)))); + if (ix->idxchain) { /* Metamethod lookup required? */ + /* A check for NULL metatable is cheaper (hoistable) than a load. */ + if (!mt) { + TRef mtref = emitir(IRT(IR_FLOAD, IRT_TAB), ix->tab, IRFL_TAB_META); + emitir(IRTG(IR_EQ, IRT_TAB), mtref, lj_ir_knull(J, IRT_TAB)); + } else { + IRType t = itype2irt(oldv); + emitir(IRTG(loadop, t), xref, 0); /* Guard for non-nil value. */ + } + } + } else { + keybarrier = 0; /* Previous non-nil value kept the key alive. */ + } + /* Convert int to number before storing. */ + if (!LJ_DUALNUM && tref_isinteger(ix->val)) + ix->val = emitir(IRTN(IR_CONV), ix->val, IRCONV_NUM_INT); + emitir(IRT(loadop+IRDELTA_L2S, tref_type(ix->val)), xref, ix->val); + if (keybarrier || tref_isgcv(ix->val)) + emitir(IRT(IR_TBAR, IRT_NIL), ix->tab, 0); + /* Invalidate neg. metamethod cache for stores with certain string keys. */ + if (!nommstr(J, ix->key)) { + TRef fref = emitir(IRT(IR_FREF, IRT_P32), ix->tab, IRFL_TAB_NOMM); + emitir(IRT(IR_FSTORE, IRT_U8), fref, lj_ir_kint(J, 0)); + } + J->needsnap = 1; + return 0; + } +} + +/* -- Upvalue access ------------------------------------------------------ */ + +/* Check whether upvalue is immutable and ok to constify. */ +static int rec_upvalue_constify(jit_State *J, GCupval *uvp) +{ + if (uvp->immutable) { + cTValue *o = uvval(uvp); + /* Don't constify objects that may retain large amounts of memory. */ +#if LJ_HASFFI + if (tviscdata(o)) { + GCcdata *cd = cdataV(o); + if (!cdataisv(cd) && !(cd->marked & LJ_GC_CDATA_FIN)) { + CType *ct = ctype_raw(ctype_ctsG(J2G(J)), cd->ctypeid); + if (!ctype_hassize(ct->info) || ct->size <= 16) + return 1; + } + return 0; + } +#else + UNUSED(J); +#endif + if (!(tvistab(o) || tvisudata(o) || tvisthread(o))) + return 1; + } + return 0; +} + +/* Record upvalue load/store. */ +static TRef rec_upvalue(jit_State *J, uint32_t uv, TRef val) +{ + GCupval *uvp = &gcref(J->fn->l.uvptr[uv])->uv; + TRef fn = getcurrf(J); + IRRef uref; + int needbarrier = 0; + if (rec_upvalue_constify(J, uvp)) { /* Try to constify immutable upvalue. */ + TRef tr, kfunc; + lua_assert(val == 0); + if (!tref_isk(fn)) { /* Late specialization of current function. */ + if (J->pt->flags >= PROTO_CLC_POLY) + goto noconstify; + kfunc = lj_ir_kfunc(J, J->fn); + emitir(IRTG(IR_EQ, IRT_FUNC), fn, kfunc); + J->base[-1] = TREF_FRAME | kfunc; + fn = kfunc; + } + tr = lj_record_constify(J, uvval(uvp)); + if (tr) + return tr; + } +noconstify: + /* Note: this effectively limits LJ_MAX_UPVAL to 127. */ + uv = (uv << 8) | (hashrot(uvp->dhash, uvp->dhash + HASH_BIAS) & 0xff); + if (!uvp->closed) { + /* In current stack? */ + if (uvval(uvp) >= tvref(J->L->stack) && + uvval(uvp) < tvref(J->L->maxstack)) { + int32_t slot = (int32_t)(uvval(uvp) - (J->L->base - J->baseslot)); + if (slot >= 0) { /* Aliases an SSA slot? */ + slot -= (int32_t)J->baseslot; /* Note: slot number may be negative! */ + /* NYI: add IR to guard that it's still aliasing the same slot. */ + if (val == 0) { + return getslot(J, slot); + } else { + J->base[slot] = val; + if (slot >= (int32_t)J->maxslot) J->maxslot = (BCReg)(slot+1); + return 0; + } + } + } + uref = tref_ref(emitir(IRTG(IR_UREFO, IRT_P32), fn, uv)); + } else { + needbarrier = 1; + uref = tref_ref(emitir(IRTG(IR_UREFC, IRT_P32), fn, uv)); + } + if (val == 0) { /* Upvalue load */ + IRType t = itype2irt(uvval(uvp)); + TRef res = emitir(IRTG(IR_ULOAD, t), uref, 0); + if (irtype_ispri(t)) res = TREF_PRI(t); /* Canonicalize primitive refs. */ + return res; + } else { /* Upvalue store. */ + /* Convert int to number before storing. */ + if (!LJ_DUALNUM && tref_isinteger(val)) + val = emitir(IRTN(IR_CONV), val, IRCONV_NUM_INT); + emitir(IRT(IR_USTORE, tref_type(val)), uref, val); + if (needbarrier && tref_isgcv(val)) + emitir(IRT(IR_OBAR, IRT_NIL), uref, val); + J->needsnap = 1; + return 0; + } +} + +/* -- Record calls to Lua functions --------------------------------------- */ + +/* Check unroll limits for calls. */ +static void check_call_unroll(jit_State *J, TraceNo lnk) +{ + cTValue *frame = J->L->base - 1; + void *pc = mref(frame_func(frame)->l.pc, void); + int32_t depth = J->framedepth; + int32_t count = 0; + if ((J->pt->flags & PROTO_VARARG)) depth--; /* Vararg frame still missing. */ + for (; depth > 0; depth--) { /* Count frames with same prototype. */ + if (frame_iscont(frame)) depth--; + frame = frame_prev(frame); + if (mref(frame_func(frame)->l.pc, void) == pc) + count++; + } + if (J->pc == J->startpc) { + if (count + J->tailcalled > J->param[JIT_P_recunroll]) { + J->pc++; + if (J->framedepth + J->retdepth == 0) + rec_stop(J, LJ_TRLINK_TAILREC, J->cur.traceno); /* Tail-recursion. */ + else + rec_stop(J, LJ_TRLINK_UPREC, J->cur.traceno); /* Up-recursion. */ + } + } else { + if (count > J->param[JIT_P_callunroll]) { + if (lnk) { /* Possible tail- or up-recursion. */ + lj_trace_flush(J, lnk); /* Flush trace that only returns. */ + /* Set a small, pseudo-random hotcount for a quick retry of JFUNC*. */ + hotcount_set(J2GG(J), J->pc+1, LJ_PRNG_BITS(J, 4)); + } + lj_trace_err(J, LJ_TRERR_CUNROLL); + } + } +} + +/* Record Lua function setup. */ +static void rec_func_setup(jit_State *J) +{ + GCproto *pt = J->pt; + BCReg s, numparams = pt->numparams; + if ((pt->flags & PROTO_NOJIT)) + lj_trace_err(J, LJ_TRERR_CJITOFF); + if (J->baseslot + pt->framesize >= LJ_MAX_JSLOTS) + lj_trace_err(J, LJ_TRERR_STACKOV); + /* Fill up missing parameters with nil. */ + for (s = J->maxslot; s < numparams; s++) + J->base[s] = TREF_NIL; + /* The remaining slots should never be read before they are written. */ + J->maxslot = numparams; +} + +/* Record Lua vararg function setup. */ +static void rec_func_vararg(jit_State *J) +{ + GCproto *pt = J->pt; + BCReg s, fixargs, vframe = J->maxslot+1; + lua_assert((pt->flags & PROTO_VARARG)); + if (J->baseslot + vframe + pt->framesize >= LJ_MAX_JSLOTS) + lj_trace_err(J, LJ_TRERR_STACKOV); + J->base[vframe-1] = J->base[-1]; /* Copy function up. */ + /* Copy fixarg slots up and set their original slots to nil. */ + fixargs = pt->numparams < J->maxslot ? pt->numparams : J->maxslot; + for (s = 0; s < fixargs; s++) { + J->base[vframe+s] = J->base[s]; + J->base[s] = TREF_NIL; + } + J->maxslot = fixargs; + J->framedepth++; + J->base += vframe; + J->baseslot += vframe; +} + +/* Record entry to a Lua function. */ +static void rec_func_lua(jit_State *J) +{ + rec_func_setup(J); + check_call_unroll(J, 0); +} + +/* Record entry to an already compiled function. */ +static void rec_func_jit(jit_State *J, TraceNo lnk) +{ + GCtrace *T; + rec_func_setup(J); + T = traceref(J, lnk); + if (T->linktype == LJ_TRLINK_RETURN) { /* Trace returns to interpreter? */ + check_call_unroll(J, lnk); + /* Temporarily unpatch JFUNC* to continue recording across function. */ + J->patchins = *J->pc; + J->patchpc = (BCIns *)J->pc; + *J->patchpc = T->startins; + return; + } + J->instunroll = 0; /* Cannot continue across a compiled function. */ + if (J->pc == J->startpc && J->framedepth + J->retdepth == 0) + rec_stop(J, LJ_TRLINK_TAILREC, J->cur.traceno); /* Extra tail-recursion. */ + else + rec_stop(J, LJ_TRLINK_ROOT, lnk); /* Link to the function. */ +} + +/* -- Vararg handling ----------------------------------------------------- */ + +/* Detect y = select(x, ...) idiom. */ +static int select_detect(jit_State *J) +{ + BCIns ins = J->pc[1]; + if (bc_op(ins) == BC_CALLM && bc_b(ins) == 2 && bc_c(ins) == 1) { + cTValue *func = &J->L->base[bc_a(ins)]; + if (tvisfunc(func) && funcV(func)->c.ffid == FF_select) + return 1; + } + return 0; +} + +/* Record vararg instruction. */ +static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults) +{ + int32_t numparams = J->pt->numparams; + ptrdiff_t nvararg = frame_delta(J->L->base-1) - numparams - 1; + lua_assert(frame_isvarg(J->L->base-1)); + if (J->framedepth > 0) { /* Simple case: varargs defined on-trace. */ + ptrdiff_t i; + if (nvararg < 0) nvararg = 0; + if (nresults == -1) { + nresults = nvararg; + J->maxslot = dst + (BCReg)nvararg; + } else if (dst + nresults > J->maxslot) { + J->maxslot = dst + (BCReg)nresults; + } + for (i = 0; i < nresults; i++) + J->base[dst+i] = i < nvararg ? getslot(J, i - nvararg - 1) : TREF_NIL; + } else { /* Unknown number of varargs passed to trace. */ + TRef fr = emitir(IRTI(IR_SLOAD), 0, IRSLOAD_READONLY|IRSLOAD_FRAME); + int32_t frofs = 8*(1+numparams)+FRAME_VARG; + if (nresults >= 0) { /* Known fixed number of results. */ + ptrdiff_t i; + if (nvararg > 0) { + ptrdiff_t nload = nvararg >= nresults ? nresults : nvararg; + TRef vbase; + if (nvararg >= nresults) + emitir(IRTGI(IR_GE), fr, lj_ir_kint(J, frofs+8*(int32_t)nresults)); + else + emitir(IRTGI(IR_EQ), fr, lj_ir_kint(J, frame_ftsz(J->L->base-1))); + vbase = emitir(IRTI(IR_SUB), REF_BASE, fr); + vbase = emitir(IRT(IR_ADD, IRT_P32), vbase, lj_ir_kint(J, frofs-8)); + for (i = 0; i < nload; i++) { + IRType t = itype2irt(&J->L->base[i-1-nvararg]); + TRef aref = emitir(IRT(IR_AREF, IRT_P32), + vbase, lj_ir_kint(J, (int32_t)i)); + TRef tr = emitir(IRTG(IR_VLOAD, t), aref, 0); + if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */ + J->base[dst+i] = tr; + } + } else { + emitir(IRTGI(IR_LE), fr, lj_ir_kint(J, frofs)); + nvararg = 0; + } + for (i = nvararg; i < nresults; i++) + J->base[dst+i] = TREF_NIL; + if (dst + (BCReg)nresults > J->maxslot) + J->maxslot = dst + (BCReg)nresults; + } else if (select_detect(J)) { /* y = select(x, ...) */ + TRef tridx = J->base[dst-1]; + TRef tr = TREF_NIL; + ptrdiff_t idx = lj_ffrecord_select_mode(J, tridx, &J->L->base[dst-1]); + if (idx < 0) goto nyivarg; + if (idx != 0 && !tref_isinteger(tridx)) + tridx = emitir(IRTGI(IR_CONV), tridx, IRCONV_INT_NUM|IRCONV_INDEX); + if (idx != 0 && tref_isk(tridx)) { + emitir(IRTGI(idx <= nvararg ? IR_GE : IR_LT), + fr, lj_ir_kint(J, frofs+8*(int32_t)idx)); + frofs -= 8; /* Bias for 1-based index. */ + } else if (idx <= nvararg) { /* Compute size. */ + TRef tmp = emitir(IRTI(IR_ADD), fr, lj_ir_kint(J, -frofs)); + if (numparams) + emitir(IRTGI(IR_GE), tmp, lj_ir_kint(J, 0)); + tr = emitir(IRTI(IR_BSHR), tmp, lj_ir_kint(J, 3)); + if (idx != 0) { + tridx = emitir(IRTI(IR_ADD), tridx, lj_ir_kint(J, -1)); + rec_idx_abc(J, tr, tridx, (uint32_t)nvararg); + } + } else { + TRef tmp = lj_ir_kint(J, frofs); + if (idx != 0) { + TRef tmp2 = emitir(IRTI(IR_BSHL), tridx, lj_ir_kint(J, 3)); + tmp = emitir(IRTI(IR_ADD), tmp2, tmp); + } else { + tr = lj_ir_kint(J, 0); + } + emitir(IRTGI(IR_LT), fr, tmp); + } + if (idx != 0 && idx <= nvararg) { + IRType t; + TRef aref, vbase = emitir(IRTI(IR_SUB), REF_BASE, fr); + vbase = emitir(IRT(IR_ADD, IRT_P32), vbase, lj_ir_kint(J, frofs-8)); + t = itype2irt(&J->L->base[idx-2-nvararg]); + aref = emitir(IRT(IR_AREF, IRT_P32), vbase, tridx); + tr = emitir(IRTG(IR_VLOAD, t), aref, 0); + if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */ + } + J->base[dst-2] = tr; + J->maxslot = dst-1; + J->bcskip = 2; /* Skip CALLM + select. */ + } else { + nyivarg: + setintV(&J->errinfo, BC_VARG); + lj_trace_err_info(J, LJ_TRERR_NYIBC); + } + } +} + +/* -- Record allocations -------------------------------------------------- */ + +static TRef rec_tnew(jit_State *J, uint32_t ah) +{ + uint32_t asize = ah & 0x7ff; + uint32_t hbits = ah >> 11; + if (asize == 0x7ff) asize = 0x801; + return emitir(IRTG(IR_TNEW, IRT_TAB), asize, hbits); +} + +/* -- Record bytecode ops ------------------------------------------------- */ + +/* Prepare for comparison. */ +static void rec_comp_prep(jit_State *J) +{ + /* Prevent merging with snapshot #0 (GC exit) since we fixup the PC. */ + if (J->cur.nsnap == 1 && J->cur.snap[0].ref == J->cur.nins) + emitir_raw(IRT(IR_NOP, IRT_NIL), 0, 0); + lj_snap_add(J); +} + +/* Fixup comparison. */ +static void rec_comp_fixup(jit_State *J, const BCIns *pc, int cond) +{ + BCIns jmpins = pc[1]; + const BCIns *npc = pc + 2 + (cond ? bc_j(jmpins) : 0); + SnapShot *snap = &J->cur.snap[J->cur.nsnap-1]; + /* Set PC to opposite target to avoid re-recording the comp. in side trace. */ + J->cur.snapmap[snap->mapofs + snap->nent] = SNAP_MKPC(npc); + J->needsnap = 1; + if (bc_a(jmpins) < J->maxslot) J->maxslot = bc_a(jmpins); + lj_snap_shrink(J); /* Shrink last snapshot if possible. */ +} + +/* Record the next bytecode instruction (_before_ it's executed). */ +void lj_record_ins(jit_State *J) +{ + cTValue *lbase; + RecordIndex ix; + const BCIns *pc; + BCIns ins; + BCOp op; + TRef ra, rb, rc; + + /* Perform post-processing action before recording the next instruction. */ + if (LJ_UNLIKELY(J->postproc != LJ_POST_NONE)) { + switch (J->postproc) { + case LJ_POST_FIXCOMP: /* Fixup comparison. */ + pc = frame_pc(&J2G(J)->tmptv); + rec_comp_fixup(J, pc, (!tvistruecond(&J2G(J)->tmptv2) ^ (bc_op(*pc)&1))); + /* fallthrough */ + case LJ_POST_FIXGUARD: /* Fixup and emit pending guard. */ + case LJ_POST_FIXGUARDSNAP: /* Fixup and emit pending guard and snapshot. */ + if (!tvistruecond(&J2G(J)->tmptv2)) { + J->fold.ins.o ^= 1; /* Flip guard to opposite. */ + if (J->postproc == LJ_POST_FIXGUARDSNAP) { + SnapShot *snap = &J->cur.snap[J->cur.nsnap-1]; + J->cur.snapmap[snap->mapofs+snap->nent-1]--; /* False -> true. */ + } + } + lj_opt_fold(J); /* Emit pending guard. */ + /* fallthrough */ + case LJ_POST_FIXBOOL: + if (!tvistruecond(&J2G(J)->tmptv2)) { + BCReg s; + TValue *tv = J->L->base; + for (s = 0; s < J->maxslot; s++) /* Fixup stack slot (if any). */ + if (J->base[s] == TREF_TRUE && tvisfalse(&tv[s])) { + J->base[s] = TREF_FALSE; + break; + } + } + break; + case LJ_POST_FIXCONST: + { + BCReg s; + TValue *tv = J->L->base; + for (s = 0; s < J->maxslot; s++) /* Constify stack slots (if any). */ + if (J->base[s] == TREF_NIL && !tvisnil(&tv[s])) + J->base[s] = lj_record_constify(J, &tv[s]); + } + break; + case LJ_POST_FFRETRY: /* Suppress recording of retried fast function. */ + if (bc_op(*J->pc) >= BC__MAX) + return; + break; + default: lua_assert(0); break; + } + J->postproc = LJ_POST_NONE; + } + + /* Need snapshot before recording next bytecode (e.g. after a store). */ + if (J->needsnap) { + J->needsnap = 0; + lj_snap_purge(J); + lj_snap_add(J); + J->mergesnap = 1; + } + + /* Skip some bytecodes. */ + if (LJ_UNLIKELY(J->bcskip > 0)) { + J->bcskip--; + return; + } + + /* Record only closed loops for root traces. */ + pc = J->pc; + if (J->framedepth == 0 && + (MSize)((char *)pc - (char *)J->bc_min) >= J->bc_extent) + lj_trace_err(J, LJ_TRERR_LLEAVE); + +#ifdef LUA_USE_ASSERT + rec_check_slots(J); + rec_check_ir(J); +#endif + + /* Keep a copy of the runtime values of var/num/str operands. */ +#define rav (&ix.valv) +#define rbv (&ix.tabv) +#define rcv (&ix.keyv) + + lbase = J->L->base; + ins = *pc; + op = bc_op(ins); + ra = bc_a(ins); + ix.val = 0; + switch (bcmode_a(op)) { + case BCMvar: + copyTV(J->L, rav, &lbase[ra]); ix.val = ra = getslot(J, ra); break; + default: break; /* Handled later. */ + } + rb = bc_b(ins); + rc = bc_c(ins); + switch (bcmode_b(op)) { + case BCMnone: rb = 0; rc = bc_d(ins); break; /* Upgrade rc to 'rd'. */ + case BCMvar: + copyTV(J->L, rbv, &lbase[rb]); ix.tab = rb = getslot(J, rb); break; + default: break; /* Handled later. */ + } + switch (bcmode_c(op)) { + case BCMvar: + copyTV(J->L, rcv, &lbase[rc]); ix.key = rc = getslot(J, rc); break; + case BCMpri: setitype(rcv, ~rc); ix.key = rc = TREF_PRI(IRT_NIL+rc); break; + case BCMnum: { cTValue *tv = proto_knumtv(J->pt, rc); + copyTV(J->L, rcv, tv); ix.key = rc = tvisint(tv) ? lj_ir_kint(J, intV(tv)) : + lj_ir_knumint(J, numV(tv)); } break; + case BCMstr: { GCstr *s = gco2str(proto_kgc(J->pt, ~(ptrdiff_t)rc)); + setstrV(J->L, rcv, s); ix.key = rc = lj_ir_kstr(J, s); } break; + default: break; /* Handled later. */ + } + + switch (op) { + + /* -- Comparison ops ---------------------------------------------------- */ + + case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: +#if LJ_HASFFI + if (tref_iscdata(ra) || tref_iscdata(rc)) { + rec_mm_comp_cdata(J, &ix, op, ((int)op & 2) ? MM_le : MM_lt); + break; + } +#endif + /* Emit nothing for two numeric or string consts. */ + if (!(tref_isk2(ra,rc) && tref_isnumber_str(ra) && tref_isnumber_str(rc))) { + IRType ta = tref_isinteger(ra) ? IRT_INT : tref_type(ra); + IRType tc = tref_isinteger(rc) ? IRT_INT : tref_type(rc); + int irop; + if (ta != tc) { + /* Widen mixed number/int comparisons to number/number comparison. */ + if (ta == IRT_INT && tc == IRT_NUM) { + ra = emitir(IRTN(IR_CONV), ra, IRCONV_NUM_INT); + ta = IRT_NUM; + } else if (ta == IRT_NUM && tc == IRT_INT) { + rc = emitir(IRTN(IR_CONV), rc, IRCONV_NUM_INT); + } else if (LJ_52) { + ta = IRT_NIL; /* Force metamethod for different types. */ + } else if (!((ta == IRT_FALSE || ta == IRT_TRUE) && + (tc == IRT_FALSE || tc == IRT_TRUE))) { + break; /* Interpreter will throw for two different types. */ + } + } + rec_comp_prep(J); + irop = (int)op - (int)BC_ISLT + (int)IR_LT; + if (ta == IRT_NUM) { + if ((irop & 1)) irop ^= 4; /* ISGE/ISGT are unordered. */ + if (!lj_ir_numcmp(numberVnum(rav), numberVnum(rcv), (IROp)irop)) + irop ^= 5; + } else if (ta == IRT_INT) { + if (!lj_ir_numcmp(numberVnum(rav), numberVnum(rcv), (IROp)irop)) + irop ^= 1; + } else if (ta == IRT_STR) { + if (!lj_ir_strcmp(strV(rav), strV(rcv), (IROp)irop)) irop ^= 1; + ra = lj_ir_call(J, IRCALL_lj_str_cmp, ra, rc); + rc = lj_ir_kint(J, 0); + ta = IRT_INT; + } else { + rec_mm_comp(J, &ix, (int)op); + break; + } + emitir(IRTG(irop, ta), ra, rc); + rec_comp_fixup(J, J->pc, ((int)op ^ irop) & 1); + } + break; + + case BC_ISEQV: case BC_ISNEV: + case BC_ISEQS: case BC_ISNES: + case BC_ISEQN: case BC_ISNEN: + case BC_ISEQP: case BC_ISNEP: +#if LJ_HASFFI + if (tref_iscdata(ra) || tref_iscdata(rc)) { + rec_mm_comp_cdata(J, &ix, op, MM_eq); + break; + } +#endif + /* Emit nothing for two non-table, non-udata consts. */ + if (!(tref_isk2(ra, rc) && !(tref_istab(ra) || tref_isudata(ra)))) { + int diff; + rec_comp_prep(J); + diff = lj_record_objcmp(J, ra, rc, rav, rcv); + if (diff == 2 || !(tref_istab(ra) || tref_isudata(ra))) + rec_comp_fixup(J, J->pc, ((int)op & 1) == !diff); + else if (diff == 1) /* Only check __eq if different, but same type. */ + rec_mm_equal(J, &ix, (int)op); + } + break; + + /* -- Unary test and copy ops ------------------------------------------- */ + + case BC_ISTC: case BC_ISFC: + if ((op & 1) == tref_istruecond(rc)) + rc = 0; /* Don't store if condition is not true. */ + /* fallthrough */ + case BC_IST: case BC_ISF: /* Type specialization suffices. */ + if (bc_a(pc[1]) < J->maxslot) + J->maxslot = bc_a(pc[1]); /* Shrink used slots. */ + break; + + /* -- Unary ops --------------------------------------------------------- */ + + case BC_NOT: + /* Type specialization already forces const result. */ + rc = tref_istruecond(rc) ? TREF_FALSE : TREF_TRUE; + break; + + case BC_LEN: + if (tref_isstr(rc)) + rc = emitir(IRTI(IR_FLOAD), rc, IRFL_STR_LEN); + else if (!LJ_52 && tref_istab(rc)) + rc = lj_ir_call(J, IRCALL_lj_tab_len, rc); + else + rc = rec_mm_len(J, rc, rcv); + break; + + /* -- Arithmetic ops ---------------------------------------------------- */ + + case BC_UNM: + if (tref_isnumber_str(rc)) { + rc = lj_opt_narrow_unm(J, rc, rcv); + } else { + ix.tab = rc; + copyTV(J->L, &ix.tabv, rcv); + rc = rec_mm_arith(J, &ix, MM_unm); + } + break; + + case BC_ADDNV: case BC_SUBNV: case BC_MULNV: case BC_DIVNV: case BC_MODNV: + /* Swap rb/rc and rbv/rcv. rav is temp. */ + ix.tab = rc; ix.key = rc = rb; rb = ix.tab; + copyTV(J->L, rav, rbv); + copyTV(J->L, rbv, rcv); + copyTV(J->L, rcv, rav); + if (op == BC_MODNV) + goto recmod; + /* fallthrough */ + case BC_ADDVN: case BC_SUBVN: case BC_MULVN: case BC_DIVVN: + case BC_ADDVV: case BC_SUBVV: case BC_MULVV: case BC_DIVVV: { + MMS mm = bcmode_mm(op); + if (tref_isnumber_str(rb) && tref_isnumber_str(rc)) + rc = lj_opt_narrow_arith(J, rb, rc, rbv, rcv, + (int)mm - (int)MM_add + (int)IR_ADD); + else + rc = rec_mm_arith(J, &ix, mm); + break; + } + + case BC_MODVN: case BC_MODVV: + recmod: + if (tref_isnumber_str(rb) && tref_isnumber_str(rc)) + rc = lj_opt_narrow_mod(J, rb, rc, rcv); + else + rc = rec_mm_arith(J, &ix, MM_mod); + break; + + case BC_POW: + if (tref_isnumber_str(rb) && tref_isnumber_str(rc)) + rc = lj_opt_narrow_pow(J, lj_ir_tonum(J, rb), rc, rcv); + else + rc = rec_mm_arith(J, &ix, MM_pow); + break; + + /* -- Constant and move ops --------------------------------------------- */ + + case BC_MOV: + /* Clear gap of method call to avoid resurrecting previous refs. */ + if (ra > J->maxslot) J->base[ra-1] = 0; + break; + case BC_KSTR: case BC_KNUM: case BC_KPRI: + break; + case BC_KSHORT: + rc = lj_ir_kint(J, (int32_t)(int16_t)rc); + break; + case BC_KNIL: + while (ra <= rc) + J->base[ra++] = TREF_NIL; + if (rc >= J->maxslot) J->maxslot = rc+1; + break; +#if LJ_HASFFI + case BC_KCDATA: + rc = lj_ir_kgc(J, proto_kgc(J->pt, ~(ptrdiff_t)rc), IRT_CDATA); + break; +#endif + + /* -- Upvalue and function ops ------------------------------------------ */ + + case BC_UGET: + rc = rec_upvalue(J, rc, 0); + break; + case BC_USETV: case BC_USETS: case BC_USETN: case BC_USETP: + rec_upvalue(J, ra, rc); + break; + + /* -- Table ops --------------------------------------------------------- */ + + case BC_GGET: case BC_GSET: + settabV(J->L, &ix.tabv, tabref(J->fn->l.env)); + ix.tab = emitir(IRT(IR_FLOAD, IRT_TAB), getcurrf(J), IRFL_FUNC_ENV); + ix.idxchain = LJ_MAX_IDXCHAIN; + rc = lj_record_idx(J, &ix); + break; + + case BC_TGETB: case BC_TSETB: + setintV(&ix.keyv, (int32_t)rc); + ix.key = lj_ir_kint(J, (int32_t)rc); + /* fallthrough */ + case BC_TGETV: case BC_TGETS: case BC_TSETV: case BC_TSETS: + ix.idxchain = LJ_MAX_IDXCHAIN; + rc = lj_record_idx(J, &ix); + break; + + case BC_TNEW: + rc = rec_tnew(J, rc); + break; + case BC_TDUP: + rc = emitir(IRTG(IR_TDUP, IRT_TAB), + lj_ir_ktab(J, gco2tab(proto_kgc(J->pt, ~(ptrdiff_t)rc))), 0); + break; + + /* -- Calls and vararg handling ----------------------------------------- */ + + case BC_ITERC: + J->base[ra] = getslot(J, ra-3); + J->base[ra+1] = getslot(J, ra-2); + J->base[ra+2] = getslot(J, ra-1); + { /* Do the actual copy now because lj_record_call needs the values. */ + TValue *b = &J->L->base[ra]; + copyTV(J->L, b, b-3); + copyTV(J->L, b+1, b-2); + copyTV(J->L, b+2, b-1); + } + lj_record_call(J, ra, (ptrdiff_t)rc-1); + break; + + /* L->top is set to L->base+ra+rc+NARGS-1+1. See lj_dispatch_ins(). */ + case BC_CALLM: + rc = (BCReg)(J->L->top - J->L->base) - ra; + /* fallthrough */ + case BC_CALL: + lj_record_call(J, ra, (ptrdiff_t)rc-1); + break; + + case BC_CALLMT: + rc = (BCReg)(J->L->top - J->L->base) - ra; + /* fallthrough */ + case BC_CALLT: + lj_record_tailcall(J, ra, (ptrdiff_t)rc-1); + break; + + case BC_VARG: + rec_varg(J, ra, (ptrdiff_t)rb-1); + break; + + /* -- Returns ----------------------------------------------------------- */ + + case BC_RETM: + /* L->top is set to L->base+ra+rc+NRESULTS-1, see lj_dispatch_ins(). */ + rc = (BCReg)(J->L->top - J->L->base) - ra + 1; + /* fallthrough */ + case BC_RET: case BC_RET0: case BC_RET1: + lj_record_ret(J, ra, (ptrdiff_t)rc-1); + break; + + /* -- Loops and branches ------------------------------------------------ */ + + case BC_FORI: + if (rec_for(J, pc, 0) != LOOPEV_LEAVE) + J->loopref = J->cur.nins; + break; + case BC_JFORI: + lua_assert(bc_op(pc[(ptrdiff_t)rc-BCBIAS_J]) == BC_JFORL); + if (rec_for(J, pc, 0) != LOOPEV_LEAVE) /* Link to existing loop. */ + rec_stop(J, LJ_TRLINK_ROOT, bc_d(pc[(ptrdiff_t)rc-BCBIAS_J])); + /* Continue tracing if the loop is not entered. */ + break; + + case BC_FORL: + rec_loop_interp(J, pc, rec_for(J, pc+((ptrdiff_t)rc-BCBIAS_J), 1)); + break; + case BC_ITERL: + rec_loop_interp(J, pc, rec_iterl(J, *pc)); + break; + case BC_LOOP: + rec_loop_interp(J, pc, rec_loop(J, ra)); + break; + + case BC_JFORL: + rec_loop_jit(J, rc, rec_for(J, pc+bc_j(traceref(J, rc)->startins), 1)); + break; + case BC_JITERL: + rec_loop_jit(J, rc, rec_iterl(J, traceref(J, rc)->startins)); + break; + case BC_JLOOP: + rec_loop_jit(J, rc, rec_loop(J, ra)); + break; + + case BC_IFORL: + case BC_IITERL: + case BC_ILOOP: + case BC_IFUNCF: + case BC_IFUNCV: + lj_trace_err(J, LJ_TRERR_BLACKL); + break; + + case BC_JMP: + if (ra < J->maxslot) + J->maxslot = ra; /* Shrink used slots. */ + break; + + /* -- Function headers -------------------------------------------------- */ + + case BC_FUNCF: + rec_func_lua(J); + break; + case BC_JFUNCF: + rec_func_jit(J, rc); + break; + + case BC_FUNCV: + rec_func_vararg(J); + rec_func_lua(J); + break; + case BC_JFUNCV: + lua_assert(0); /* Cannot happen. No hotcall counting for varag funcs. */ + break; + + case BC_FUNCC: + case BC_FUNCCW: + lj_ffrecord_func(J); + break; + + default: + if (op >= BC__MAX) { + lj_ffrecord_func(J); + break; + } + /* fallthrough */ + case BC_ITERN: + case BC_ISNEXT: + case BC_CAT: + case BC_UCLO: + case BC_FNEW: + case BC_TSETM: + setintV(&J->errinfo, (int32_t)op); + lj_trace_err_info(J, LJ_TRERR_NYIBC); + break; + } + + /* rc == 0 if we have no result yet, e.g. pending __index metamethod call. */ + if (bcmode_a(op) == BCMdst && rc) { + J->base[ra] = rc; + if (ra >= J->maxslot) J->maxslot = ra+1; + } + +#undef rav +#undef rbv +#undef rcv + + /* Limit the number of recorded IR instructions. */ + if (J->cur.nins > REF_FIRST+(IRRef)J->param[JIT_P_maxrecord]) + lj_trace_err(J, LJ_TRERR_TRACEOV); +} + +/* -- Recording setup ----------------------------------------------------- */ + +/* Setup recording for a root trace started by a hot loop. */ +static const BCIns *rec_setup_root(jit_State *J) +{ + /* Determine the next PC and the bytecode range for the loop. */ + const BCIns *pcj, *pc = J->pc; + BCIns ins = *pc; + BCReg ra = bc_a(ins); + switch (bc_op(ins)) { + case BC_FORL: + J->bc_extent = (MSize)(-bc_j(ins))*sizeof(BCIns); + pc += 1+bc_j(ins); + J->bc_min = pc; + break; + case BC_ITERL: + lua_assert(bc_op(pc[-1]) == BC_ITERC); + J->maxslot = ra + bc_b(pc[-1]) - 1; + J->bc_extent = (MSize)(-bc_j(ins))*sizeof(BCIns); + pc += 1+bc_j(ins); + lua_assert(bc_op(pc[-1]) == BC_JMP); + J->bc_min = pc; + break; + case BC_LOOP: + /* Only check BC range for real loops, but not for "repeat until true". */ + pcj = pc + bc_j(ins); + ins = *pcj; + if (bc_op(ins) == BC_JMP && bc_j(ins) < 0) { + J->bc_min = pcj+1 + bc_j(ins); + J->bc_extent = (MSize)(-bc_j(ins))*sizeof(BCIns); + } + J->maxslot = ra; + pc++; + break; + case BC_RET: + case BC_RET0: + case BC_RET1: + /* No bytecode range check for down-recursive root traces. */ + J->maxslot = ra + bc_d(ins) - 1; + break; + case BC_FUNCF: + /* No bytecode range check for root traces started by a hot call. */ + J->maxslot = J->pt->numparams; + pc++; + break; + default: + lua_assert(0); + break; + } + return pc; +} + +/* Setup for recording a new trace. */ +void lj_record_setup(jit_State *J) +{ + uint32_t i; + + /* Initialize state related to current trace. */ + memset(J->slot, 0, sizeof(J->slot)); + memset(J->chain, 0, sizeof(J->chain)); + memset(J->bpropcache, 0, sizeof(J->bpropcache)); + J->scev.idx = REF_NIL; + setmref(J->scev.pc, NULL); + + J->baseslot = 1; /* Invoking function is at base[-1]. */ + J->base = J->slot + J->baseslot; + J->maxslot = 0; + J->framedepth = 0; + J->retdepth = 0; + + J->instunroll = J->param[JIT_P_instunroll]; + J->loopunroll = J->param[JIT_P_loopunroll]; + J->tailcalled = 0; + J->loopref = 0; + + J->bc_min = NULL; /* Means no limit. */ + J->bc_extent = ~(MSize)0; + + /* Emit instructions for fixed references. Also triggers initial IR alloc. */ + emitir_raw(IRT(IR_BASE, IRT_P32), J->parent, J->exitno); + for (i = 0; i <= 2; i++) { + IRIns *ir = IR(REF_NIL-i); + ir->i = 0; + ir->t.irt = (uint8_t)(IRT_NIL+i); + ir->o = IR_KPRI; + ir->prev = 0; + } + J->cur.nk = REF_TRUE; + + J->startpc = J->pc; + setmref(J->cur.startpc, J->pc); + if (J->parent) { /* Side trace. */ + GCtrace *T = traceref(J, J->parent); + TraceNo root = T->root ? T->root : J->parent; + J->cur.root = (uint16_t)root; + J->cur.startins = BCINS_AD(BC_JMP, 0, 0); + /* Check whether we could at least potentially form an extra loop. */ + if (J->exitno == 0 && T->snap[0].nent == 0) { + /* We can narrow a FORL for some side traces, too. */ + if (J->pc > proto_bc(J->pt) && bc_op(J->pc[-1]) == BC_JFORI && + bc_d(J->pc[bc_j(J->pc[-1])-1]) == root) { + lj_snap_add(J); + rec_for_loop(J, J->pc-1, &J->scev, 1); + goto sidecheck; + } + } else { + J->startpc = NULL; /* Prevent forming an extra loop. */ + } + lj_snap_replay(J, T); + sidecheck: + if (traceref(J, J->cur.root)->nchild >= J->param[JIT_P_maxside] || + T->snap[J->exitno].count >= J->param[JIT_P_hotexit] + + J->param[JIT_P_tryside]) { + rec_stop(J, LJ_TRLINK_INTERP, 0); + } + } else { /* Root trace. */ + J->cur.root = 0; + J->cur.startins = *J->pc; + J->pc = rec_setup_root(J); + /* Note: the loop instruction itself is recorded at the end and not + ** at the start! So snapshot #0 needs to point to the *next* instruction. + */ + lj_snap_add(J); + if (bc_op(J->cur.startins) == BC_FORL) + rec_for_loop(J, J->pc-1, &J->scev, 1); + if (1 + J->pt->framesize >= LJ_MAX_JSLOTS) + lj_trace_err(J, LJ_TRERR_STACKOV); + } +#ifdef LUAJIT_ENABLE_CHECKHOOK + /* Regularly check for instruction/line hooks from compiled code and + ** exit to the interpreter if the hooks are set. + ** + ** This is a compile-time option and disabled by default, since the + ** hook checks may be quite expensive in tight loops. + ** + ** Note this is only useful if hooks are *not* set most of the time. + ** Use this only if you want to *asynchronously* interrupt the execution. + ** + ** You can set the instruction hook via lua_sethook() with a count of 1 + ** from a signal handler or another native thread. Please have a look + ** at the first few functions in luajit.c for an example (Ctrl-C handler). + */ + { + TRef tr = emitir(IRT(IR_XLOAD, IRT_U8), + lj_ir_kptr(J, &J2G(J)->hookmask), IRXLOAD_VOLATILE); + tr = emitir(IRTI(IR_BAND), tr, lj_ir_kint(J, (LUA_MASKLINE|LUA_MASKCOUNT))); + emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, 0)); + } +#endif +} + +#undef IR +#undef emitir_raw +#undef emitir + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_record.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_record.h new file mode 100644 index 000000000..c9f4882a9 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_record.h @@ -0,0 +1,44 @@ +/* +** Trace recorder (bytecode -> SSA IR). +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_RECORD_H +#define _LJ_RECORD_H + +#include "lj_obj.h" +#include "lj_jit.h" + +#if LJ_HASJIT +/* Context for recording an indexed load/store. */ +typedef struct RecordIndex { + TValue tabv; /* Runtime value of table (or indexed object). */ + TValue keyv; /* Runtime value of key. */ + TValue valv; /* Runtime value of stored value. */ + TValue mobjv; /* Runtime value of metamethod object. */ + GCtab *mtv; /* Runtime value of metatable object. */ + cTValue *oldv; /* Runtime value of previously stored value. */ + TRef tab; /* Table (or indexed object) reference. */ + TRef key; /* Key reference. */ + TRef val; /* Value reference for a store or 0 for a load. */ + TRef mt; /* Metatable reference. */ + TRef mobj; /* Metamethod object reference. */ + int idxchain; /* Index indirections left or 0 for raw lookup. */ +} RecordIndex; + +LJ_FUNC int lj_record_objcmp(jit_State *J, TRef a, TRef b, + cTValue *av, cTValue *bv); +LJ_FUNC TRef lj_record_constify(jit_State *J, cTValue *o); + +LJ_FUNC void lj_record_call(jit_State *J, BCReg func, ptrdiff_t nargs); +LJ_FUNC void lj_record_tailcall(jit_State *J, BCReg func, ptrdiff_t nargs); +LJ_FUNC void lj_record_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults); + +LJ_FUNC int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm); +LJ_FUNC TRef lj_record_idx(jit_State *J, RecordIndex *ix); + +LJ_FUNC void lj_record_ins(jit_State *J); +LJ_FUNC void lj_record_setup(jit_State *J); +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_snap.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_snap.c new file mode 100644 index 000000000..5c870bafd --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_snap.c @@ -0,0 +1,866 @@ +/* +** Snapshot handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_snap_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_gc.h" +#include "lj_tab.h" +#include "lj_state.h" +#include "lj_frame.h" +#include "lj_bc.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_iropt.h" +#include "lj_trace.h" +#include "lj_snap.h" +#include "lj_target.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#include "lj_cdata.h" +#endif + +/* Some local macros to save typing. Undef'd at the end. */ +#define IR(ref) (&J->cur.ir[(ref)]) + +/* Pass IR on to next optimization in chain (FOLD). */ +#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) + +/* Emit raw IR without passing through optimizations. */ +#define emitir_raw(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_ir_emit(J)) + +/* -- Snapshot buffer allocation ------------------------------------------ */ + +/* Grow snapshot buffer. */ +void lj_snap_grow_buf_(jit_State *J, MSize need) +{ + MSize maxsnap = (MSize)J->param[JIT_P_maxsnap]; + if (need > maxsnap) + lj_trace_err(J, LJ_TRERR_SNAPOV); + lj_mem_growvec(J->L, J->snapbuf, J->sizesnap, maxsnap, SnapShot); + J->cur.snap = J->snapbuf; +} + +/* Grow snapshot map buffer. */ +void lj_snap_grow_map_(jit_State *J, MSize need) +{ + if (need < 2*J->sizesnapmap) + need = 2*J->sizesnapmap; + else if (need < 64) + need = 64; + J->snapmapbuf = (SnapEntry *)lj_mem_realloc(J->L, J->snapmapbuf, + J->sizesnapmap*sizeof(SnapEntry), need*sizeof(SnapEntry)); + J->cur.snapmap = J->snapmapbuf; + J->sizesnapmap = need; +} + +/* -- Snapshot generation ------------------------------------------------- */ + +/* Add all modified slots to the snapshot. */ +static MSize snapshot_slots(jit_State *J, SnapEntry *map, BCReg nslots) +{ + IRRef retf = J->chain[IR_RETF]; /* Limits SLOAD restore elimination. */ + BCReg s; + MSize n = 0; + for (s = 0; s < nslots; s++) { + TRef tr = J->slot[s]; + IRRef ref = tref_ref(tr); + if (ref) { + SnapEntry sn = SNAP_TR(s, tr); + IRIns *ir = IR(ref); + if (!(sn & (SNAP_CONT|SNAP_FRAME)) && + ir->o == IR_SLOAD && ir->op1 == s && ref > retf) { + /* No need to snapshot unmodified non-inherited slots. */ + if (!(ir->op2 & IRSLOAD_INHERIT)) + continue; + /* No need to restore readonly slots and unmodified non-parent slots. */ + if (!(LJ_DUALNUM && (ir->op2 & IRSLOAD_CONVERT)) && + (ir->op2 & (IRSLOAD_READONLY|IRSLOAD_PARENT)) != IRSLOAD_PARENT) + sn |= SNAP_NORESTORE; + } + if (LJ_SOFTFP && irt_isnum(ir->t)) + sn |= SNAP_SOFTFPNUM; + map[n++] = sn; + } + } + return n; +} + +/* Add frame links at the end of the snapshot. */ +static BCReg snapshot_framelinks(jit_State *J, SnapEntry *map) +{ + cTValue *frame = J->L->base - 1; + cTValue *lim = J->L->base - J->baseslot; + cTValue *ftop = frame + funcproto(frame_func(frame))->framesize; + MSize f = 0; + map[f++] = SNAP_MKPC(J->pc); /* The current PC is always the first entry. */ + while (frame > lim) { /* Backwards traversal of all frames above base. */ + if (frame_islua(frame)) { + map[f++] = SNAP_MKPC(frame_pc(frame)); + frame = frame_prevl(frame); + } else if (frame_iscont(frame)) { + map[f++] = SNAP_MKFTSZ(frame_ftsz(frame)); + map[f++] = SNAP_MKPC(frame_contpc(frame)); + frame = frame_prevd(frame); + } else { + lua_assert(!frame_isc(frame)); + map[f++] = SNAP_MKFTSZ(frame_ftsz(frame)); + frame = frame_prevd(frame); + continue; + } + if (frame + funcproto(frame_func(frame))->framesize > ftop) + ftop = frame + funcproto(frame_func(frame))->framesize; + } + lua_assert(f == (MSize)(1 + J->framedepth)); + return (BCReg)(ftop - lim); +} + +/* Take a snapshot of the current stack. */ +static void snapshot_stack(jit_State *J, SnapShot *snap, MSize nsnapmap) +{ + BCReg nslots = J->baseslot + J->maxslot; + MSize nent; + SnapEntry *p; + /* Conservative estimate. */ + lj_snap_grow_map(J, nsnapmap + nslots + (MSize)J->framedepth+1); + p = &J->cur.snapmap[nsnapmap]; + nent = snapshot_slots(J, p, nslots); + snap->topslot = (uint8_t)snapshot_framelinks(J, p + nent); + snap->mapofs = (uint16_t)nsnapmap; + snap->ref = (IRRef1)J->cur.nins; + snap->nent = (uint8_t)nent; + snap->nslots = (uint8_t)nslots; + snap->count = 0; + J->cur.nsnapmap = (uint16_t)(nsnapmap + nent + 1 + J->framedepth); +} + +/* Add or merge a snapshot. */ +void lj_snap_add(jit_State *J) +{ + MSize nsnap = J->cur.nsnap; + MSize nsnapmap = J->cur.nsnapmap; + /* Merge if no ins. inbetween or if requested and no guard inbetween. */ + if (J->mergesnap ? !irt_isguard(J->guardemit) : + (nsnap > 0 && J->cur.snap[nsnap-1].ref == J->cur.nins)) { + if (nsnap == 1) { /* But preserve snap #0 PC. */ + emitir_raw(IRT(IR_NOP, IRT_NIL), 0, 0); + goto nomerge; + } + nsnapmap = J->cur.snap[--nsnap].mapofs; + } else { + nomerge: + lj_snap_grow_buf(J, nsnap+1); + J->cur.nsnap = (uint16_t)(nsnap+1); + } + J->mergesnap = 0; + J->guardemit.irt = 0; + snapshot_stack(J, &J->cur.snap[nsnap], nsnapmap); +} + +/* -- Snapshot modification ----------------------------------------------- */ + +#define SNAP_USEDEF_SLOTS (LJ_MAX_JSLOTS+LJ_STACK_EXTRA) + +/* Find unused slots with reaching-definitions bytecode data-flow analysis. */ +static BCReg snap_usedef(jit_State *J, uint8_t *udf, + const BCIns *pc, BCReg maxslot) +{ + BCReg s; + GCobj *o; + + if (maxslot == 0) return 0; +#ifdef LUAJIT_USE_VALGRIND + /* Avoid errors for harmless reads beyond maxslot. */ + memset(udf, 1, SNAP_USEDEF_SLOTS); +#else + memset(udf, 1, maxslot); +#endif + + /* Treat open upvalues as used. */ + o = gcref(J->L->openupval); + while (o) { + if (uvval(gco2uv(o)) < J->L->base) break; + udf[uvval(gco2uv(o)) - J->L->base] = 0; + o = gcref(o->gch.nextgc); + } + +#define USE_SLOT(s) udf[(s)] &= ~1 +#define DEF_SLOT(s) udf[(s)] *= 3 + + /* Scan through following bytecode and check for uses/defs. */ + lua_assert(pc >= proto_bc(J->pt) && pc < proto_bc(J->pt) + J->pt->sizebc); + for (;;) { + BCIns ins = *pc++; + BCOp op = bc_op(ins); + switch (bcmode_b(op)) { + case BCMvar: USE_SLOT(bc_b(ins)); break; + default: break; + } + switch (bcmode_c(op)) { + case BCMvar: USE_SLOT(bc_c(ins)); break; + case BCMrbase: + lua_assert(op == BC_CAT); + for (s = bc_b(ins); s <= bc_c(ins); s++) USE_SLOT(s); + for (; s < maxslot; s++) DEF_SLOT(s); + break; + case BCMjump: + handle_jump: { + BCReg minslot = bc_a(ins); + if (op >= BC_FORI && op <= BC_JFORL) minslot += FORL_EXT; + else if (op >= BC_ITERL && op <= BC_JITERL) minslot += bc_b(pc[-2])-1; + else if (op == BC_UCLO) { pc += bc_j(ins); break; } + for (s = minslot; s < maxslot; s++) DEF_SLOT(s); + return minslot < maxslot ? minslot : maxslot; + } + case BCMlit: + if (op == BC_JFORL || op == BC_JITERL || op == BC_JLOOP) { + goto handle_jump; + } else if (bc_isret(op)) { + BCReg top = op == BC_RETM ? maxslot : (bc_a(ins) + bc_d(ins)-1); + for (s = 0; s < bc_a(ins); s++) DEF_SLOT(s); + for (; s < top; s++) USE_SLOT(s); + for (; s < maxslot; s++) DEF_SLOT(s); + return 0; + } + break; + case BCMfunc: return maxslot; /* NYI: will abort, anyway. */ + default: break; + } + switch (bcmode_a(op)) { + case BCMvar: USE_SLOT(bc_a(ins)); break; + case BCMdst: + if (!(op == BC_ISTC || op == BC_ISFC)) DEF_SLOT(bc_a(ins)); + break; + case BCMbase: + if (op >= BC_CALLM && op <= BC_VARG) { + BCReg top = (op == BC_CALLM || op == BC_CALLMT || bc_c(ins) == 0) ? + maxslot : (bc_a(ins) + bc_c(ins)); + s = bc_a(ins) - ((op == BC_ITERC || op == BC_ITERN) ? 3 : 0); + for (; s < top; s++) USE_SLOT(s); + for (; s < maxslot; s++) DEF_SLOT(s); + if (op == BC_CALLT || op == BC_CALLMT) { + for (s = 0; s < bc_a(ins); s++) DEF_SLOT(s); + return 0; + } + } else if (op == BC_KNIL) { + for (s = bc_a(ins); s <= bc_d(ins); s++) DEF_SLOT(s); + } else if (op == BC_TSETM) { + for (s = bc_a(ins)-1; s < maxslot; s++) USE_SLOT(s); + } + break; + default: break; + } + lua_assert(pc >= proto_bc(J->pt) && pc < proto_bc(J->pt) + J->pt->sizebc); + } + +#undef USE_SLOT +#undef DEF_SLOT + + return 0; /* unreachable */ +} + +/* Purge dead slots before the next snapshot. */ +void lj_snap_purge(jit_State *J) +{ + uint8_t udf[SNAP_USEDEF_SLOTS]; + BCReg maxslot = J->maxslot; + BCReg s = snap_usedef(J, udf, J->pc, maxslot); + for (; s < maxslot; s++) + if (udf[s] != 0) + J->base[s] = 0; /* Purge dead slots. */ +} + +/* Shrink last snapshot. */ +void lj_snap_shrink(jit_State *J) +{ + SnapShot *snap = &J->cur.snap[J->cur.nsnap-1]; + SnapEntry *map = &J->cur.snapmap[snap->mapofs]; + MSize n, m, nlim, nent = snap->nent; + uint8_t udf[SNAP_USEDEF_SLOTS]; + BCReg maxslot = J->maxslot; + BCReg minslot = snap_usedef(J, udf, snap_pc(map[nent]), maxslot); + BCReg baseslot = J->baseslot; + maxslot += baseslot; + minslot += baseslot; + snap->nslots = (uint8_t)maxslot; + for (n = m = 0; n < nent; n++) { /* Remove unused slots from snapshot. */ + BCReg s = snap_slot(map[n]); + if (s < minslot || (s < maxslot && udf[s-baseslot] == 0)) + map[m++] = map[n]; /* Only copy used slots. */ + } + snap->nent = (uint8_t)m; + nlim = J->cur.nsnapmap - snap->mapofs - 1; + while (n <= nlim) map[m++] = map[n++]; /* Move PC + frame links down. */ + J->cur.nsnapmap = (uint16_t)(snap->mapofs + m); /* Free up space in map. */ +} + +/* -- Snapshot access ----------------------------------------------------- */ + +/* Initialize a Bloom Filter with all renamed refs. +** There are very few renames (often none), so the filter has +** very few bits set. This makes it suitable for negative filtering. +*/ +static BloomFilter snap_renamefilter(GCtrace *T, SnapNo lim) +{ + BloomFilter rfilt = 0; + IRIns *ir; + for (ir = &T->ir[T->nins-1]; ir->o == IR_RENAME; ir--) + if (ir->op2 <= lim) + bloomset(rfilt, ir->op1); + return rfilt; +} + +/* Process matching renames to find the original RegSP. */ +static RegSP snap_renameref(GCtrace *T, SnapNo lim, IRRef ref, RegSP rs) +{ + IRIns *ir; + for (ir = &T->ir[T->nins-1]; ir->o == IR_RENAME; ir--) + if (ir->op1 == ref && ir->op2 <= lim) + rs = ir->prev; + return rs; +} + +/* Copy RegSP from parent snapshot to the parent links of the IR. */ +IRIns *lj_snap_regspmap(GCtrace *T, SnapNo snapno, IRIns *ir) +{ + SnapShot *snap = &T->snap[snapno]; + SnapEntry *map = &T->snapmap[snap->mapofs]; + BloomFilter rfilt = snap_renamefilter(T, snapno); + MSize n = 0; + IRRef ref = 0; + for ( ; ; ir++) { + uint32_t rs; + if (ir->o == IR_SLOAD) { + if (!(ir->op2 & IRSLOAD_PARENT)) break; + for ( ; ; n++) { + lua_assert(n < snap->nent); + if (snap_slot(map[n]) == ir->op1) { + ref = snap_ref(map[n++]); + break; + } + } + } else if (LJ_SOFTFP && ir->o == IR_HIOP) { + ref++; + } else if (ir->o == IR_PVAL) { + ref = ir->op1 + REF_BIAS; + } else { + break; + } + rs = T->ir[ref].prev; + if (bloomtest(rfilt, ref)) + rs = snap_renameref(T, snapno, ref, rs); + ir->prev = (uint16_t)rs; + lua_assert(regsp_used(rs)); + } + return ir; +} + +/* -- Snapshot replay ----------------------------------------------------- */ + +/* Replay constant from parent trace. */ +static TRef snap_replay_const(jit_State *J, IRIns *ir) +{ + /* Only have to deal with constants that can occur in stack slots. */ + switch ((IROp)ir->o) { + case IR_KPRI: return TREF_PRI(irt_type(ir->t)); + case IR_KINT: return lj_ir_kint(J, ir->i); + case IR_KGC: return lj_ir_kgc(J, ir_kgc(ir), irt_t(ir->t)); + case IR_KNUM: return lj_ir_k64(J, IR_KNUM, ir_knum(ir)); + case IR_KINT64: return lj_ir_k64(J, IR_KINT64, ir_kint64(ir)); + case IR_KPTR: return lj_ir_kptr(J, ir_kptr(ir)); /* Continuation. */ + default: lua_assert(0); return TREF_NIL; break; + } +} + +/* De-duplicate parent reference. */ +static TRef snap_dedup(jit_State *J, SnapEntry *map, MSize nmax, IRRef ref) +{ + MSize j; + for (j = 0; j < nmax; j++) + if (snap_ref(map[j]) == ref) + return J->slot[snap_slot(map[j])] & ~(SNAP_CONT|SNAP_FRAME); + return 0; +} + +/* Emit parent reference with de-duplication. */ +static TRef snap_pref(jit_State *J, GCtrace *T, SnapEntry *map, MSize nmax, + BloomFilter seen, IRRef ref) +{ + IRIns *ir = &T->ir[ref]; + TRef tr; + if (irref_isk(ref)) + tr = snap_replay_const(J, ir); + else if (!regsp_used(ir->prev)) + tr = 0; + else if (!bloomtest(seen, ref) || (tr = snap_dedup(J, map, nmax, ref)) == 0) + tr = emitir(IRT(IR_PVAL, irt_type(ir->t)), ref - REF_BIAS, 0); + return tr; +} + +/* Check whether a sunk store corresponds to an allocation. Slow path. */ +static int snap_sunk_store2(jit_State *J, IRIns *ira, IRIns *irs) +{ + if (irs->o == IR_ASTORE || irs->o == IR_HSTORE || + irs->o == IR_FSTORE || irs->o == IR_XSTORE) { + IRIns *irk = IR(irs->op1); + if (irk->o == IR_AREF || irk->o == IR_HREFK) + irk = IR(irk->op1); + return (IR(irk->op1) == ira); + } + return 0; +} + +/* Check whether a sunk store corresponds to an allocation. Fast path. */ +static LJ_AINLINE int snap_sunk_store(jit_State *J, IRIns *ira, IRIns *irs) +{ + if (irs->s != 255) + return (ira + irs->s == irs); /* Fast check. */ + return snap_sunk_store2(J, ira, irs); +} + +/* Replay snapshot state to setup side trace. */ +void lj_snap_replay(jit_State *J, GCtrace *T) +{ + SnapShot *snap = &T->snap[J->exitno]; + SnapEntry *map = &T->snapmap[snap->mapofs]; + MSize n, nent = snap->nent; + BloomFilter seen = 0; + int pass23 = 0; + J->framedepth = 0; + /* Emit IR for slots inherited from parent snapshot. */ + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + BCReg s = snap_slot(sn); + IRRef ref = snap_ref(sn); + IRIns *ir = &T->ir[ref]; + TRef tr; + /* The bloom filter avoids O(nent^2) overhead for de-duping slots. */ + if (bloomtest(seen, ref) && (tr = snap_dedup(J, map, n, ref)) != 0) + goto setslot; + bloomset(seen, ref); + if (irref_isk(ref)) { + tr = snap_replay_const(J, ir); + } else if (!regsp_used(ir->prev)) { + pass23 = 1; + lua_assert(s != 0); + tr = s; + } else { + IRType t = irt_type(ir->t); + uint32_t mode = IRSLOAD_INHERIT|IRSLOAD_PARENT; + if (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM)) t = IRT_NUM; + if (ir->o == IR_SLOAD) mode |= (ir->op2 & IRSLOAD_READONLY); + tr = emitir_raw(IRT(IR_SLOAD, t), s, mode); + } + setslot: + J->slot[s] = tr | (sn&(SNAP_CONT|SNAP_FRAME)); /* Same as TREF_* flags. */ + J->framedepth += ((sn & (SNAP_CONT|SNAP_FRAME)) && s); + if ((sn & SNAP_FRAME)) + J->baseslot = s+1; + } + if (pass23) { + IRIns *irlast = &T->ir[snap->ref]; + pass23 = 0; + /* Emit dependent PVALs. */ + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + IRRef refp = snap_ref(sn); + IRIns *ir = &T->ir[refp]; + if (regsp_reg(ir->r) == RID_SUNK) { + if (J->slot[snap_slot(sn)] != snap_slot(sn)) continue; + pass23 = 1; + lua_assert(ir->o == IR_TNEW || ir->o == IR_TDUP || + ir->o == IR_CNEW || ir->o == IR_CNEWI); + if (ir->op1 >= T->nk) snap_pref(J, T, map, nent, seen, ir->op1); + if (ir->op2 >= T->nk) snap_pref(J, T, map, nent, seen, ir->op2); + if (LJ_HASFFI && ir->o == IR_CNEWI) { + if (LJ_32 && refp+1 < T->nins && (ir+1)->o == IR_HIOP) + snap_pref(J, T, map, nent, seen, (ir+1)->op2); + } else { + IRIns *irs; + for (irs = ir+1; irs < irlast; irs++) + if (irs->r == RID_SINK && snap_sunk_store(J, ir, irs)) { + if (snap_pref(J, T, map, nent, seen, irs->op2) == 0) + snap_pref(J, T, map, nent, seen, T->ir[irs->op2].op1); + else if ((LJ_SOFTFP || (LJ_32 && LJ_HASFFI)) && + irs+1 < irlast && (irs+1)->o == IR_HIOP) + snap_pref(J, T, map, nent, seen, (irs+1)->op2); + } + } + } else if (!irref_isk(refp) && !regsp_used(ir->prev)) { + lua_assert(ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT); + J->slot[snap_slot(sn)] = snap_pref(J, T, map, nent, seen, ir->op1); + } + } + /* Replay sunk instructions. */ + for (n = 0; pass23 && n < nent; n++) { + SnapEntry sn = map[n]; + IRRef refp = snap_ref(sn); + IRIns *ir = &T->ir[refp]; + if (regsp_reg(ir->r) == RID_SUNK) { + TRef op1, op2; + if (J->slot[snap_slot(sn)] != snap_slot(sn)) { /* De-dup allocs. */ + J->slot[snap_slot(sn)] = J->slot[J->slot[snap_slot(sn)]]; + continue; + } + op1 = ir->op1; + if (op1 >= T->nk) op1 = snap_pref(J, T, map, nent, seen, op1); + op2 = ir->op2; + if (op2 >= T->nk) op2 = snap_pref(J, T, map, nent, seen, op2); + if (LJ_HASFFI && ir->o == IR_CNEWI) { + if (LJ_32 && refp+1 < T->nins && (ir+1)->o == IR_HIOP) { + lj_needsplit(J); /* Emit joining HIOP. */ + op2 = emitir_raw(IRT(IR_HIOP, IRT_I64), op2, + snap_pref(J, T, map, nent, seen, (ir+1)->op2)); + } + J->slot[snap_slot(sn)] = emitir(ir->ot, op1, op2); + } else { + IRIns *irs; + TRef tr = emitir(ir->ot, op1, op2); + J->slot[snap_slot(sn)] = tr; + for (irs = ir+1; irs < irlast; irs++) + if (irs->r == RID_SINK && snap_sunk_store(J, ir, irs)) { + IRIns *irr = &T->ir[irs->op1]; + TRef val, key = irr->op2, tmp = tr; + if (irr->o != IR_FREF) { + IRIns *irk = &T->ir[key]; + if (irr->o == IR_HREFK) + key = lj_ir_kslot(J, snap_replay_const(J, &T->ir[irk->op1]), + irk->op2); + else + key = snap_replay_const(J, irk); + if (irr->o == IR_HREFK || irr->o == IR_AREF) { + IRIns *irf = &T->ir[irr->op1]; + tmp = emitir(irf->ot, tmp, irf->op2); + } + } + tmp = emitir(irr->ot, tmp, key); + val = snap_pref(J, T, map, nent, seen, irs->op2); + if (val == 0) { + IRIns *irc = &T->ir[irs->op2]; + lua_assert(irc->o == IR_CONV && irc->op2 == IRCONV_NUM_INT); + val = snap_pref(J, T, map, nent, seen, irc->op1); + val = emitir(IRTN(IR_CONV), val, IRCONV_NUM_INT); + } else if ((LJ_SOFTFP || (LJ_32 && LJ_HASFFI)) && + irs+1 < irlast && (irs+1)->o == IR_HIOP) { + IRType t = IRT_I64; + if (LJ_SOFTFP && irt_type((irs+1)->t) == IRT_SOFTFP) + t = IRT_NUM; + lj_needsplit(J); + if (irref_isk(irs->op2) && irref_isk((irs+1)->op2)) { + uint64_t k = (uint32_t)T->ir[irs->op2].i + + ((uint64_t)T->ir[(irs+1)->op2].i << 32); + val = lj_ir_k64(J, t == IRT_I64 ? IR_KINT64 : IR_KNUM, + lj_ir_k64_find(J, k)); + } else { + val = emitir_raw(IRT(IR_HIOP, t), val, + snap_pref(J, T, map, nent, seen, (irs+1)->op2)); + } + tmp = emitir(IRT(irs->o, t), tmp, val); + continue; + } + tmp = emitir(irs->ot, tmp, val); + } else if (LJ_HASFFI && irs->o == IR_XBAR && ir->o == IR_CNEW) { + emitir(IRT(IR_XBAR, IRT_NIL), 0, 0); + } + } + } + } + } + J->base = J->slot + J->baseslot; + J->maxslot = snap->nslots - J->baseslot; + lj_snap_add(J); + if (pass23) /* Need explicit GC step _after_ initial snapshot. */ + emitir_raw(IRTG(IR_GCSTEP, IRT_NIL), 0, 0); +} + +/* -- Snapshot restore ---------------------------------------------------- */ + +static void snap_unsink(jit_State *J, GCtrace *T, ExitState *ex, + SnapNo snapno, BloomFilter rfilt, + IRIns *ir, TValue *o); + +/* Restore a value from the trace exit state. */ +static void snap_restoreval(jit_State *J, GCtrace *T, ExitState *ex, + SnapNo snapno, BloomFilter rfilt, + IRRef ref, TValue *o) +{ + IRIns *ir = &T->ir[ref]; + IRType1 t = ir->t; + RegSP rs = ir->prev; + if (irref_isk(ref)) { /* Restore constant slot. */ + lj_ir_kvalue(J->L, o, ir); + return; + } + if (LJ_UNLIKELY(bloomtest(rfilt, ref))) + rs = snap_renameref(T, snapno, ref, rs); + if (ra_hasspill(regsp_spill(rs))) { /* Restore from spill slot. */ + int32_t *sps = &ex->spill[regsp_spill(rs)]; + if (irt_isinteger(t)) { + setintV(o, *sps); +#if !LJ_SOFTFP + } else if (irt_isnum(t)) { + o->u64 = *(uint64_t *)sps; +#endif + } else if (LJ_64 && irt_islightud(t)) { + /* 64 bit lightuserdata which may escape already has the tag bits. */ + o->u64 = *(uint64_t *)sps; + } else { + lua_assert(!irt_ispri(t)); /* PRI refs never have a spill slot. */ + setgcrefi(o->gcr, *sps); + setitype(o, irt_toitype(t)); + } + } else { /* Restore from register. */ + Reg r = regsp_reg(rs); + if (ra_noreg(r)) { + lua_assert(ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT); + snap_restoreval(J, T, ex, snapno, rfilt, ir->op1, o); + if (LJ_DUALNUM) setnumV(o, (lua_Number)intV(o)); + return; + } else if (irt_isinteger(t)) { + setintV(o, (int32_t)ex->gpr[r-RID_MIN_GPR]); +#if !LJ_SOFTFP + } else if (irt_isnum(t)) { + setnumV(o, ex->fpr[r-RID_MIN_FPR]); +#endif + } else if (LJ_64 && irt_islightud(t)) { + /* 64 bit lightuserdata which may escape already has the tag bits. */ + o->u64 = ex->gpr[r-RID_MIN_GPR]; + } else { + if (!irt_ispri(t)) + setgcrefi(o->gcr, ex->gpr[r-RID_MIN_GPR]); + setitype(o, irt_toitype(t)); + } + } +} + +#if LJ_HASFFI +/* Restore raw data from the trace exit state. */ +static void snap_restoredata(GCtrace *T, ExitState *ex, + SnapNo snapno, BloomFilter rfilt, + IRRef ref, void *dst, CTSize sz) +{ + IRIns *ir = &T->ir[ref]; + RegSP rs = ir->prev; + int32_t *src; + uint64_t tmp; + if (irref_isk(ref)) { + if (ir->o == IR_KNUM || ir->o == IR_KINT64) { + src = mref(ir->ptr, int32_t); + } else if (sz == 8) { + tmp = (uint64_t)(uint32_t)ir->i; + src = (int32_t *)&tmp; + } else { + src = &ir->i; + } + } else { + if (LJ_UNLIKELY(bloomtest(rfilt, ref))) + rs = snap_renameref(T, snapno, ref, rs); + if (ra_hasspill(regsp_spill(rs))) { + src = &ex->spill[regsp_spill(rs)]; + if (sz == 8 && !irt_is64(ir->t)) { + tmp = (uint64_t)(uint32_t)*src; + src = (int32_t *)&tmp; + } + } else { + Reg r = regsp_reg(rs); + if (ra_noreg(r)) { + /* Note: this assumes CNEWI is never used for SOFTFP split numbers. */ + lua_assert(sz == 8 && ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT); + snap_restoredata(T, ex, snapno, rfilt, ir->op1, dst, 4); + *(lua_Number *)dst = (lua_Number)*(int32_t *)dst; + return; + } + src = (int32_t *)&ex->gpr[r-RID_MIN_GPR]; +#if !LJ_SOFTFP + if (r >= RID_MAX_GPR) { + src = (int32_t *)&ex->fpr[r-RID_MIN_FPR]; +#if LJ_TARGET_PPC + if (sz == 4) { /* PPC FPRs are always doubles. */ + *(float *)dst = (float)*(double *)src; + return; + } +#else + if (LJ_BE && sz == 4) src++; +#endif + } +#endif + } + } + lua_assert(sz == 1 || sz == 2 || sz == 4 || sz == 8); + if (sz == 4) *(int32_t *)dst = *src; + else if (sz == 8) *(int64_t *)dst = *(int64_t *)src; + else if (sz == 1) *(int8_t *)dst = (int8_t)*src; + else *(int16_t *)dst = (int16_t)*src; +} +#endif + +/* Unsink allocation from the trace exit state. Unsink sunk stores. */ +static void snap_unsink(jit_State *J, GCtrace *T, ExitState *ex, + SnapNo snapno, BloomFilter rfilt, + IRIns *ir, TValue *o) +{ + lua_assert(ir->o == IR_TNEW || ir->o == IR_TDUP || + ir->o == IR_CNEW || ir->o == IR_CNEWI); +#if LJ_HASFFI + if (ir->o == IR_CNEW || ir->o == IR_CNEWI) { + CTState *cts = ctype_cts(J->L); + CTypeID id = (CTypeID)T->ir[ir->op1].i; + CTSize sz = lj_ctype_size(cts, id); + GCcdata *cd = lj_cdata_new(cts, id, sz); + setcdataV(J->L, o, cd); + if (ir->o == IR_CNEWI) { + uint8_t *p = (uint8_t *)cdataptr(cd); + lua_assert(sz == 4 || sz == 8); + if (LJ_32 && sz == 8 && ir+1 < T->ir + T->nins && (ir+1)->o == IR_HIOP) { + snap_restoredata(T, ex, snapno, rfilt, (ir+1)->op2, LJ_LE?p+4:p, 4); + if (LJ_BE) p += 4; + sz = 4; + } + snap_restoredata(T, ex, snapno, rfilt, ir->op2, p, sz); + } else { + IRIns *irs, *irlast = &T->ir[T->snap[snapno].ref]; + for (irs = ir+1; irs < irlast; irs++) + if (irs->r == RID_SINK && snap_sunk_store(J, ir, irs)) { + IRIns *iro = &T->ir[T->ir[irs->op1].op2]; + uint8_t *p = (uint8_t *)cd; + CTSize szs; + lua_assert(irs->o == IR_XSTORE && T->ir[irs->op1].o == IR_ADD); + lua_assert(iro->o == IR_KINT || iro->o == IR_KINT64); + if (irt_is64(irs->t)) szs = 8; + else if (irt_isi8(irs->t) || irt_isu8(irs->t)) szs = 1; + else if (irt_isi16(irs->t) || irt_isu16(irs->t)) szs = 2; + else szs = 4; + if (LJ_64 && iro->o == IR_KINT64) + p += (int64_t)ir_k64(iro)->u64; + else + p += iro->i; + lua_assert(p >= (uint8_t *)cdataptr(cd) && + p + szs <= (uint8_t *)cdataptr(cd) + sz); + if (LJ_32 && irs+1 < T->ir + T->nins && (irs+1)->o == IR_HIOP) { + lua_assert(szs == 4); + snap_restoredata(T, ex, snapno, rfilt, (irs+1)->op2, LJ_LE?p+4:p,4); + if (LJ_BE) p += 4; + } + snap_restoredata(T, ex, snapno, rfilt, irs->op2, p, szs); + } + } + } else +#endif + { + IRIns *irs, *irlast; + GCtab *t = ir->o == IR_TNEW ? lj_tab_new(J->L, ir->op1, ir->op2) : + lj_tab_dup(J->L, ir_ktab(&T->ir[ir->op1])); + settabV(J->L, o, t); + irlast = &T->ir[T->snap[snapno].ref]; + for (irs = ir+1; irs < irlast; irs++) + if (irs->r == RID_SINK && snap_sunk_store(J, ir, irs)) { + IRIns *irk = &T->ir[irs->op1]; + TValue tmp, *val; + lua_assert(irs->o == IR_ASTORE || irs->o == IR_HSTORE || + irs->o == IR_FSTORE); + if (irk->o == IR_FREF) { + lua_assert(irk->op2 == IRFL_TAB_META); + snap_restoreval(J, T, ex, snapno, rfilt, irs->op2, &tmp); + /* NOBARRIER: The table is new (marked white). */ + setgcref(t->metatable, obj2gco(tabV(&tmp))); + } else { + irk = &T->ir[irk->op2]; + if (irk->o == IR_KSLOT) irk = &T->ir[irk->op1]; + lj_ir_kvalue(J->L, &tmp, irk); + val = lj_tab_set(J->L, t, &tmp); + /* NOBARRIER: The table is new (marked white). */ + snap_restoreval(J, T, ex, snapno, rfilt, irs->op2, val); + if (LJ_SOFTFP && irs+1 < T->ir + T->nins && (irs+1)->o == IR_HIOP) { + snap_restoreval(J, T, ex, snapno, rfilt, (irs+1)->op2, &tmp); + val->u32.hi = tmp.u32.lo; + } + } + } + } +} + +/* Restore interpreter state from exit state with the help of a snapshot. */ +const BCIns *lj_snap_restore(jit_State *J, void *exptr) +{ + ExitState *ex = (ExitState *)exptr; + SnapNo snapno = J->exitno; /* For now, snapno == exitno. */ + GCtrace *T = traceref(J, J->parent); + SnapShot *snap = &T->snap[snapno]; + MSize n, nent = snap->nent; + SnapEntry *map = &T->snapmap[snap->mapofs]; + SnapEntry *flinks = &T->snapmap[snap_nextofs(T, snap)-1]; + int32_t ftsz0; + TValue *frame; + BloomFilter rfilt = snap_renamefilter(T, snapno); + const BCIns *pc = snap_pc(map[nent]); + lua_State *L = J->L; + + /* Set interpreter PC to the next PC to get correct error messages. */ + setcframe_pc(cframe_raw(L->cframe), pc+1); + + /* Make sure the stack is big enough for the slots from the snapshot. */ + if (LJ_UNLIKELY(L->base + snap->topslot >= tvref(L->maxstack))) { + L->top = curr_topL(L); + lj_state_growstack(L, snap->topslot - curr_proto(L)->framesize); + } + + /* Fill stack slots with data from the registers and spill slots. */ + frame = L->base-1; + ftsz0 = frame_ftsz(frame); /* Preserve link to previous frame in slot #0. */ + for (n = 0; n < nent; n++) { + SnapEntry sn = map[n]; + if (!(sn & SNAP_NORESTORE)) { + TValue *o = &frame[snap_slot(sn)]; + IRRef ref = snap_ref(sn); + IRIns *ir = &T->ir[ref]; + if (ir->r == RID_SUNK) { + MSize j; + for (j = 0; j < n; j++) + if (snap_ref(map[j]) == ref) { /* De-duplicate sunk allocations. */ + copyTV(L, o, &frame[snap_slot(map[j])]); + goto dupslot; + } + snap_unsink(J, T, ex, snapno, rfilt, ir, o); + dupslot: + continue; + } + snap_restoreval(J, T, ex, snapno, rfilt, ref, o); + if (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM) && tvisint(o)) { + TValue tmp; + snap_restoreval(J, T, ex, snapno, rfilt, ref+1, &tmp); + o->u32.hi = tmp.u32.lo; + } else if ((sn & (SNAP_CONT|SNAP_FRAME))) { + /* Overwrite tag with frame link. */ + o->fr.tp.ftsz = snap_slot(sn) != 0 ? (int32_t)*flinks-- : ftsz0; + L->base = o+1; + } + } + } + lua_assert(map + nent == flinks); + + /* Compute current stack top. */ + switch (bc_op(*pc)) { + default: + if (bc_op(*pc) < BC_FUNCF) { + L->top = curr_topL(L); + break; + } + /* fallthrough */ + case BC_CALLM: case BC_CALLMT: case BC_RETM: case BC_TSETM: + L->top = frame + snap->nslots; + break; + } + return pc; +} + +#undef IR +#undef emitir_raw +#undef emitir + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_snap.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_snap.h new file mode 100644 index 000000000..9a125be7f --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_snap.h @@ -0,0 +1,34 @@ +/* +** Snapshot handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_SNAP_H +#define _LJ_SNAP_H + +#include "lj_obj.h" +#include "lj_jit.h" + +#if LJ_HASJIT +LJ_FUNC void lj_snap_add(jit_State *J); +LJ_FUNC void lj_snap_purge(jit_State *J); +LJ_FUNC void lj_snap_shrink(jit_State *J); +LJ_FUNC IRIns *lj_snap_regspmap(GCtrace *T, SnapNo snapno, IRIns *ir); +LJ_FUNC void lj_snap_replay(jit_State *J, GCtrace *T); +LJ_FUNC const BCIns *lj_snap_restore(jit_State *J, void *exptr); +LJ_FUNC void lj_snap_grow_buf_(jit_State *J, MSize need); +LJ_FUNC void lj_snap_grow_map_(jit_State *J, MSize need); + +static LJ_AINLINE void lj_snap_grow_buf(jit_State *J, MSize need) +{ + if (LJ_UNLIKELY(need > J->sizesnap)) lj_snap_grow_buf_(J, need); +} + +static LJ_AINLINE void lj_snap_grow_map(jit_State *J, MSize need) +{ + if (LJ_UNLIKELY(need > J->sizesnapmap)) lj_snap_grow_map_(J, need); +} + +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_state.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_state.c new file mode 100644 index 000000000..e654afaeb --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_state.c @@ -0,0 +1,287 @@ +/* +** State and stack handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lj_state_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_func.h" +#include "lj_meta.h" +#include "lj_state.h" +#include "lj_frame.h" +#if LJ_HASFFI +#include "lj_ctype.h" +#endif +#include "lj_trace.h" +#include "lj_dispatch.h" +#include "lj_vm.h" +#include "lj_lex.h" +#include "lj_alloc.h" + +/* -- Stack handling ------------------------------------------------------ */ + +/* Stack sizes. */ +#define LJ_STACK_MIN LUA_MINSTACK /* Min. stack size. */ +#define LJ_STACK_MAX LUAI_MAXSTACK /* Max. stack size. */ +#define LJ_STACK_START (2*LJ_STACK_MIN) /* Starting stack size. */ +#define LJ_STACK_MAXEX (LJ_STACK_MAX + 1 + LJ_STACK_EXTRA) + +/* Explanation of LJ_STACK_EXTRA: +** +** Calls to metamethods store their arguments beyond the current top +** without checking for the stack limit. This avoids stack resizes which +** would invalidate passed TValue pointers. The stack check is performed +** later by the function header. This can safely resize the stack or raise +** an error. Thus we need some extra slots beyond the current stack limit. +** +** Most metamethods need 4 slots above top (cont, mobj, arg1, arg2) plus +** one extra slot if mobj is not a function. Only lj_meta_tset needs 5 +** slots above top, but then mobj is always a function. So we can get by +** with 5 extra slots. +*/ + +/* Resize stack slots and adjust pointers in state. */ +static void resizestack(lua_State *L, MSize n) +{ + TValue *st, *oldst = tvref(L->stack); + ptrdiff_t delta; + MSize oldsize = L->stacksize; + MSize realsize = n + 1 + LJ_STACK_EXTRA; + GCobj *up; + lua_assert((MSize)(tvref(L->maxstack)-oldst)==L->stacksize-LJ_STACK_EXTRA-1); + st = (TValue *)lj_mem_realloc(L, tvref(L->stack), + (MSize)(L->stacksize*sizeof(TValue)), + (MSize)(realsize*sizeof(TValue))); + setmref(L->stack, st); + delta = (char *)st - (char *)oldst; + setmref(L->maxstack, st + n); + while (oldsize < realsize) /* Clear new slots. */ + setnilV(st + oldsize++); + L->stacksize = realsize; + L->base = (TValue *)((char *)L->base + delta); + L->top = (TValue *)((char *)L->top + delta); + for (up = gcref(L->openupval); up != NULL; up = gcnext(up)) + setmref(gco2uv(up)->v, (TValue *)((char *)uvval(gco2uv(up)) + delta)); + if (obj2gco(L) == gcref(G(L)->jit_L)) + setmref(G(L)->jit_base, mref(G(L)->jit_base, char) + delta); +} + +/* Relimit stack after error, in case the limit was overdrawn. */ +void lj_state_relimitstack(lua_State *L) +{ + if (L->stacksize > LJ_STACK_MAXEX && L->top-tvref(L->stack) < LJ_STACK_MAX-1) + resizestack(L, LJ_STACK_MAX); +} + +/* Try to shrink the stack (called from GC). */ +void lj_state_shrinkstack(lua_State *L, MSize used) +{ + if (L->stacksize > LJ_STACK_MAXEX) + return; /* Avoid stack shrinking while handling stack overflow. */ + if (4*used < L->stacksize && + 2*(LJ_STACK_START+LJ_STACK_EXTRA) < L->stacksize && + obj2gco(L) != gcref(G(L)->jit_L)) /* Don't shrink stack of live trace. */ + resizestack(L, L->stacksize >> 1); +} + +/* Try to grow stack. */ +void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need) +{ + MSize n; + if (L->stacksize > LJ_STACK_MAXEX) /* Overflow while handling overflow? */ + lj_err_throw(L, LUA_ERRERR); + n = L->stacksize + need; + if (n > LJ_STACK_MAX) { + n += 2*LUA_MINSTACK; + } else if (n < 2*L->stacksize) { + n = 2*L->stacksize; + if (n >= LJ_STACK_MAX) + n = LJ_STACK_MAX; + } + resizestack(L, n); + if (L->stacksize > LJ_STACK_MAXEX) + lj_err_msg(L, LJ_ERR_STKOV); +} + +void LJ_FASTCALL lj_state_growstack1(lua_State *L) +{ + lj_state_growstack(L, 1); +} + +/* Allocate basic stack for new state. */ +static void stack_init(lua_State *L1, lua_State *L) +{ + TValue *stend, *st = lj_mem_newvec(L, LJ_STACK_START+LJ_STACK_EXTRA, TValue); + setmref(L1->stack, st); + L1->stacksize = LJ_STACK_START + LJ_STACK_EXTRA; + stend = st + L1->stacksize; + setmref(L1->maxstack, stend - LJ_STACK_EXTRA - 1); + L1->base = L1->top = st+1; + setthreadV(L1, st, L1); /* Needed for curr_funcisL() on empty stack. */ + while (st < stend) /* Clear new slots. */ + setnilV(st++); +} + +/* -- State handling ------------------------------------------------------ */ + +/* Open parts that may cause memory-allocation errors. */ +static TValue *cpluaopen(lua_State *L, lua_CFunction dummy, void *ud) +{ + global_State *g = G(L); + UNUSED(dummy); + UNUSED(ud); + stack_init(L, L); + /* NOBARRIER: State initialization, all objects are white. */ + setgcref(L->env, obj2gco(lj_tab_new(L, 0, LJ_MIN_GLOBAL))); + settabV(L, registry(L), lj_tab_new(L, 0, LJ_MIN_REGISTRY)); + lj_str_resize(L, LJ_MIN_STRTAB-1); + lj_meta_init(L); + lj_lex_init(L); + fixstring(lj_err_str(L, LJ_ERR_ERRMEM)); /* Preallocate memory error msg. */ + g->gc.threshold = 4*g->gc.total; + lj_trace_initstate(g); + return NULL; +} + +static void close_state(lua_State *L) +{ + global_State *g = G(L); + lj_func_closeuv(L, tvref(L->stack)); + lj_gc_freeall(g); + lua_assert(gcref(g->gc.root) == obj2gco(L)); + lua_assert(g->strnum == 0); + lj_trace_freestate(g); +#if LJ_HASFFI + lj_ctype_freestate(g); +#endif + lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef); + lj_str_freebuf(g, &g->tmpbuf); + lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue); + lua_assert(g->gc.total == sizeof(GG_State)); +#ifndef LUAJIT_USE_SYSMALLOC + if (g->allocf == lj_alloc_f) + lj_alloc_destroy(g->allocd); + else +#endif + g->allocf(g->allocd, G2GG(g), sizeof(GG_State), 0); +} + +#if LJ_64 && !(defined(LUAJIT_USE_VALGRIND) && defined(LUAJIT_USE_SYSMALLOC)) +lua_State *lj_state_newstate(lua_Alloc f, void *ud) +#else +LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) +#endif +{ + GG_State *GG = (GG_State *)f(ud, NULL, 0, sizeof(GG_State)); + lua_State *L = &GG->L; + global_State *g = &GG->g; + if (GG == NULL || !checkptr32(GG)) return NULL; + memset(GG, 0, sizeof(GG_State)); + L->gct = ~LJ_TTHREAD; + L->marked = LJ_GC_WHITE0 | LJ_GC_FIXED | LJ_GC_SFIXED; /* Prevent free. */ + L->dummy_ffid = FF_C; + setmref(L->glref, g); + g->gc.currentwhite = LJ_GC_WHITE0 | LJ_GC_FIXED; + g->strempty.marked = LJ_GC_WHITE0; + g->strempty.gct = ~LJ_TSTR; + g->allocf = f; + g->allocd = ud; + setgcref(g->mainthref, obj2gco(L)); + setgcref(g->uvhead.prev, obj2gco(&g->uvhead)); + setgcref(g->uvhead.next, obj2gco(&g->uvhead)); + g->strmask = ~(MSize)0; + setnilV(registry(L)); + setnilV(&g->nilnode.val); + setnilV(&g->nilnode.key); + setmref(g->nilnode.freetop, &g->nilnode); + lj_str_initbuf(&g->tmpbuf); + g->gc.state = GCSpause; + setgcref(g->gc.root, obj2gco(L)); + setmref(g->gc.sweep, &g->gc.root); + g->gc.total = sizeof(GG_State); + g->gc.pause = LUAI_GCPAUSE; + g->gc.stepmul = LUAI_GCMUL; + lj_dispatch_init((GG_State *)L); + L->status = LUA_ERRERR+1; /* Avoid touching the stack upon memory error. */ + if (lj_vm_cpcall(L, NULL, NULL, cpluaopen) != 0) { + /* Memory allocation error: free partial state. */ + close_state(L); + return NULL; + } + L->status = 0; + return L; +} + +static TValue *cpfinalize(lua_State *L, lua_CFunction dummy, void *ud) +{ + UNUSED(dummy); + UNUSED(ud); + lj_gc_finalize_cdata(L); + lj_gc_finalize_udata(L); + /* Frame pop omitted. */ + return NULL; +} + +LUA_API void lua_close(lua_State *L) +{ + global_State *g = G(L); + int i; + L = mainthread(g); /* Only the main thread can be closed. */ + lj_func_closeuv(L, tvref(L->stack)); + lj_gc_separateudata(g, 1); /* Separate udata which have GC metamethods. */ +#if LJ_HASJIT + G2J(g)->flags &= ~JIT_F_ON; + G2J(g)->state = LJ_TRACE_IDLE; + lj_dispatch_update(g); +#endif + for (i = 0;;) { + hook_enter(g); + L->status = 0; + L->cframe = NULL; + L->base = L->top = tvref(L->stack) + 1; + if (lj_vm_cpcall(L, NULL, NULL, cpfinalize) == 0) { + if (++i >= 10) break; + lj_gc_separateudata(g, 1); /* Separate udata again. */ + if (gcref(g->gc.mmudata) == NULL) /* Until nothing is left to do. */ + break; + } + } + close_state(L); +} + +lua_State *lj_state_new(lua_State *L) +{ + lua_State *L1 = lj_mem_newobj(L, lua_State); + L1->gct = ~LJ_TTHREAD; + L1->dummy_ffid = FF_C; + L1->status = 0; + L1->stacksize = 0; + setmref(L1->stack, NULL); + L1->cframe = NULL; + /* NOBARRIER: The lua_State is new (marked white). */ + setgcrefnull(L1->openupval); + setmrefr(L1->glref, L->glref); + setgcrefr(L1->env, L->env); + stack_init(L1, L); /* init stack */ + lua_assert(iswhite(obj2gco(L1))); + return L1; +} + +void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L) +{ + lua_assert(L != mainthread(g)); + lj_func_closeuv(L, tvref(L->stack)); + lua_assert(gcref(L->openupval) == NULL); + lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue); + lj_mem_freet(g, L); +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_state.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_state.h new file mode 100644 index 000000000..687889a26 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_state.h @@ -0,0 +1,35 @@ +/* +** State and stack handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_STATE_H +#define _LJ_STATE_H + +#include "lj_obj.h" + +#define incr_top(L) \ + (++L->top >= tvref(L->maxstack) && (lj_state_growstack1(L), 0)) + +#define savestack(L, p) ((char *)(p) - mref(L->stack, char)) +#define restorestack(L, n) ((TValue *)(mref(L->stack, char) + (n))) + +LJ_FUNC void lj_state_relimitstack(lua_State *L); +LJ_FUNC void lj_state_shrinkstack(lua_State *L, MSize used); +LJ_FUNCA void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need); +LJ_FUNC void LJ_FASTCALL lj_state_growstack1(lua_State *L); + +static LJ_AINLINE void lj_state_checkstack(lua_State *L, MSize need) +{ + if ((mref(L->maxstack, char) - (char *)L->top) <= + (ptrdiff_t)need*(ptrdiff_t)sizeof(TValue)) + lj_state_growstack(L, need); +} + +LJ_FUNC lua_State *lj_state_new(lua_State *L); +LJ_FUNC void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L); +#if LJ_64 +LJ_FUNC lua_State *lj_state_newstate(lua_Alloc f, void *ud); +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_str.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_str.c new file mode 100644 index 000000000..3239bfc95 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_str.c @@ -0,0 +1,366 @@ +/* +** String handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#include + +#define lj_str_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_str.h" +#include "lj_state.h" +#include "lj_char.h" + +/* -- String interning ---------------------------------------------------- */ + +/* Ordered compare of strings. Assumes string data is 4-byte aligned. */ +int32_t LJ_FASTCALL lj_str_cmp(GCstr *a, GCstr *b) +{ + MSize i, n = a->len > b->len ? b->len : a->len; + for (i = 0; i < n; i += 4) { + /* Note: innocuous access up to end of string + 3. */ + uint32_t va = *(const uint32_t *)(strdata(a)+i); + uint32_t vb = *(const uint32_t *)(strdata(b)+i); + if (va != vb) { +#if LJ_LE + va = lj_bswap(va); vb = lj_bswap(vb); +#endif + i -= n; + if ((int32_t)i >= -3) { + va >>= 32+(i<<3); vb >>= 32+(i<<3); + if (va == vb) break; + } + return va < vb ? -1 : 1; + } + } + return (int32_t)(a->len - b->len); +} + +/* Fast string data comparison. Caveat: unaligned access to 1st string! */ +static LJ_AINLINE int str_fastcmp(const char *a, const char *b, MSize len) +{ + MSize i = 0; + lua_assert(len > 0); + lua_assert((((uintptr_t)a+len-1) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4); + do { /* Note: innocuous access up to end of string + 3. */ + uint32_t v = lj_getu32(a+i) ^ *(const uint32_t *)(b+i); + if (v) { + i -= len; +#if LJ_LE + return (int32_t)i >= -3 ? (v << (32+(i<<3))) : 1; +#else + return (int32_t)i >= -3 ? (v >> (32+(i<<3))) : 1; +#endif + } + i += 4; + } while (i < len); + return 0; +} + +/* Resize the string hash table (grow and shrink). */ +void lj_str_resize(lua_State *L, MSize newmask) +{ + global_State *g = G(L); + GCRef *newhash; + MSize i; + if (g->gc.state == GCSsweepstring || newmask >= LJ_MAX_STRTAB-1) + return; /* No resizing during GC traversal or if already too big. */ + newhash = lj_mem_newvec(L, newmask+1, GCRef); + memset(newhash, 0, (newmask+1)*sizeof(GCRef)); + for (i = g->strmask; i != ~(MSize)0; i--) { /* Rehash old table. */ + GCobj *p = gcref(g->strhash[i]); + while (p) { /* Follow each hash chain and reinsert all strings. */ + MSize h = gco2str(p)->hash & newmask; + GCobj *next = gcnext(p); + /* NOBARRIER: The string table is a GC root. */ + setgcrefr(p->gch.nextgc, newhash[h]); + setgcref(newhash[h], p); + p = next; + } + } + lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef); + g->strmask = newmask; + g->strhash = newhash; +} + +/* +** Lua will use at most ~(2^LUAI_HASHLIMIT) bytes from a string to +** compute its hash +*/ +#if !defined(LUAI_HASHLIMIT) +#define LUAI_HASHLIMIT 5 +#endif + +#define cast(t, exp) ((t)(exp)) +int luajittex_choose_hash_function = 0 ; +/* Intern a string and return string object. */ +GCstr *lj_str_new(lua_State *L, const char *str, size_t lenx) +{ + global_State *g; + GCstr *s; + GCobj *o; + MSize len = (MSize)lenx; + MSize a, b, h = len; + size_t step ; + size_t l1 ; + if (lenx >= LJ_MAX_STR) + lj_err_msg(L, LJ_ERR_STROV); + g = G(L); + + if (len==0) + return &g->strempty; + if (luajittex_choose_hash_function==0) { + /* Lua 5.1.5 hash function */ + /* for 5.2 max methods we also need to patch the vm eq */ + step = (len>>LUAI_HASHLIMIT)+1; /* if string is too long, don't hash all its chars */ + for (l1=len; l1>=step; l1-=step) /* compute hash */ + h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); + } else { + /* LuaJIT 2.0.2 hash function */ + /* Compute string hash. Constants taken from lookup3 hash by Bob Jenkins. */ + if (len >= 4) { /* Caveat: unaligned access! */ + a = lj_getu32(str); + h ^= lj_getu32(str+len-4); + b = lj_getu32(str+(len>>1)-2); + h ^= b; h -= lj_rol(b, 14); + b += lj_getu32(str+(len>>2)-1); + } else if (len > 0) { + a = *(const uint8_t *)str; + h ^= *(const uint8_t *)(str+len-1); + b = *(const uint8_t *)(str+(len>>1)); + h ^= b; h -= lj_rol(b, 14); + } else { + /* Already done, kept for reference */ + return &g->strempty; + } + a ^= h; a -= lj_rol(h, 11); + b ^= a; b -= lj_rol(a, 25); + h ^= b; h -= lj_rol(b, 16); + } + + + /* Check if the string has already been interned. */ + o = gcref(g->strhash[h & g->strmask]); + if (LJ_LIKELY((((uintptr_t)str+len-1) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4)) { + while (o != NULL) { + GCstr *sx = gco2str(o); + if (sx->len == len && str_fastcmp(str, strdata(sx), len) == 0) { + /* Resurrect if dead. Can only happen with fixstring() (keywords). */ + if (isdead(g, o)) flipwhite(o); + return sx; /* Return existing string. */ + } + o = gcnext(o); + } + } else { /* Slow path: end of string is too close to a page boundary. */ + while (o != NULL) { + GCstr *sx = gco2str(o); + if (sx->len == len && memcmp(str, strdata(sx), len) == 0) { + /* Resurrect if dead. Can only happen with fixstring() (keywords). */ + if (isdead(g, o)) flipwhite(o); + return sx; /* Return existing string. */ + } + o = gcnext(o); + } + } + /* Nope, create a new string. */ + s = lj_mem_newt(L, sizeof(GCstr)+len+1, GCstr); + newwhite(g, s); + s->gct = ~LJ_TSTR; + s->len = len; + s->hash = h; + s->reserved = 0; + memcpy(strdatawr(s), str, len); + strdatawr(s)[len] = '\0'; /* Zero-terminate string. */ + /* Add it to string hash table. */ + h &= g->strmask; + s->nextgc = g->strhash[h]; + /* NOBARRIER: The string table is a GC root. */ + setgcref(g->strhash[h], obj2gco(s)); + if (g->strnum++ > g->strmask) /* Allow a 100% load factor. */ + lj_str_resize(L, (g->strmask<<1)+1); /* Grow string table. */ + return s; /* Return newly interned string. */ +} + +void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s) +{ + g->strnum--; + lj_mem_free(g, s, sizestring(s)); +} + +/* -- Type conversions ---------------------------------------------------- */ + +/* Print number to buffer. Canonicalizes non-finite values. */ +size_t LJ_FASTCALL lj_str_bufnum(char *s, cTValue *o) +{ + if (LJ_LIKELY((o->u32.hi << 1) < 0xffe00000)) { /* Finite? */ + lua_Number n = o->n; +#if __BIONIC__ + if (tvismzero(o)) { s[0] = '-'; s[1] = '0'; return 2; } +#endif + return (size_t)lua_number2str(s, n); + } else if (((o->u32.hi & 0x000fffff) | o->u32.lo) != 0) { + s[0] = 'n'; s[1] = 'a'; s[2] = 'n'; return 3; + } else if ((o->u32.hi & 0x80000000) == 0) { + s[0] = 'i'; s[1] = 'n'; s[2] = 'f'; return 3; + } else { + s[0] = '-'; s[1] = 'i'; s[2] = 'n'; s[3] = 'f'; return 4; + } +} + +/* Print integer to buffer. Returns pointer to start. */ +char * LJ_FASTCALL lj_str_bufint(char *p, int32_t k) +{ + uint32_t u = (uint32_t)(k < 0 ? -k : k); + p += 1+10; + do { *--p = (char)('0' + u % 10); } while (u /= 10); + if (k < 0) *--p = '-'; + return p; +} + +/* Convert number to string. */ +GCstr * LJ_FASTCALL lj_str_fromnum(lua_State *L, const lua_Number *np) +{ + char buf[LJ_STR_NUMBUF]; + size_t len = lj_str_bufnum(buf, (TValue *)np); + return lj_str_new(L, buf, len); +} + +/* Convert integer to string. */ +GCstr * LJ_FASTCALL lj_str_fromint(lua_State *L, int32_t k) +{ + char s[1+10]; + char *p = lj_str_bufint(s, k); + return lj_str_new(L, p, (size_t)(s+sizeof(s)-p)); +} + +GCstr * LJ_FASTCALL lj_str_fromnumber(lua_State *L, cTValue *o) +{ + return tvisint(o) ? lj_str_fromint(L, intV(o)) : lj_str_fromnum(L, &o->n); +} + +/* -- String formatting --------------------------------------------------- */ + +static void addstr(lua_State *L, SBuf *sb, const char *str, MSize len) +{ + char *p; + MSize i; + if (sb->n + len > sb->sz) { + MSize sz = sb->sz * 2; + while (sb->n + len > sz) sz = sz * 2; + lj_str_resizebuf(L, sb, sz); + } + p = sb->buf + sb->n; + sb->n += len; + for (i = 0; i < len; i++) p[i] = str[i]; +} + +static void addchar(lua_State *L, SBuf *sb, int c) +{ + if (sb->n + 1 > sb->sz) { + MSize sz = sb->sz * 2; + lj_str_resizebuf(L, sb, sz); + } + sb->buf[sb->n++] = (char)c; +} + +/* Push formatted message as a string object to Lua stack. va_list variant. */ +const char *lj_str_pushvf(lua_State *L, const char *fmt, va_list argp) +{ + SBuf *sb = &G(L)->tmpbuf; + lj_str_needbuf(L, sb, (MSize)strlen(fmt)); + lj_str_resetbuf(sb); + for (;;) { + const char *e = strchr(fmt, '%'); + if (e == NULL) break; + addstr(L, sb, fmt, (MSize)(e-fmt)); + /* This function only handles %s, %c, %d, %f and %p formats. */ + switch (e[1]) { + case 's': { + const char *s = va_arg(argp, char *); + if (s == NULL) s = "(null)"; + addstr(L, sb, s, (MSize)strlen(s)); + break; + } + case 'c': + addchar(L, sb, va_arg(argp, int)); + break; + case 'd': { + char buf[LJ_STR_INTBUF]; + char *p = lj_str_bufint(buf, va_arg(argp, int32_t)); + addstr(L, sb, p, (MSize)(buf+LJ_STR_INTBUF-p)); + break; + } + case 'f': { + char buf[LJ_STR_NUMBUF]; + TValue tv; + MSize len; + tv.n = (lua_Number)(va_arg(argp, LUAI_UACNUMBER)); + len = (MSize)lj_str_bufnum(buf, &tv); + addstr(L, sb, buf, len); + break; + } + case 'p': { +#define FMTP_CHARS (2*sizeof(ptrdiff_t)) + char buf[2+FMTP_CHARS]; + ptrdiff_t p = (ptrdiff_t)(va_arg(argp, void *)); + ptrdiff_t i, lasti = 2+FMTP_CHARS; + if (p == 0) { + addstr(L, sb, "NULL", 4); + break; + } +#if LJ_64 + /* Shorten output for 64 bit pointers. */ + lasti = 2+2*4+((p >> 32) ? 2+2*(lj_fls((uint32_t)(p >> 32))>>3) : 0); +#endif + buf[0] = '0'; + buf[1] = 'x'; + for (i = lasti-1; i >= 2; i--, p >>= 4) + buf[i] = "0123456789abcdef"[(p & 15)]; + addstr(L, sb, buf, (MSize)lasti); + break; + } + case '%': + addchar(L, sb, '%'); + break; + default: + addchar(L, sb, '%'); + addchar(L, sb, e[1]); + break; + } + fmt = e+2; + } + addstr(L, sb, fmt, (MSize)strlen(fmt)); + setstrV(L, L->top, lj_str_new(L, sb->buf, sb->n)); + incr_top(L); + return strVdata(L->top - 1); +} + +/* Push formatted message as a string object to Lua stack. Vararg variant. */ +const char *lj_str_pushf(lua_State *L, const char *fmt, ...) +{ + const char *msg; + va_list argp; + va_start(argp, fmt); + msg = lj_str_pushvf(L, fmt, argp); + va_end(argp); + return msg; +} + +/* -- Buffer handling ----------------------------------------------------- */ + +char *lj_str_needbuf(lua_State *L, SBuf *sb, MSize sz) +{ + if (sz > sb->sz) { + if (sz < LJ_MIN_SBUF) sz = LJ_MIN_SBUF; + lj_str_resizebuf(L, sb, sz); + } + return sb->buf; +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_str.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_str.h new file mode 100644 index 000000000..99697051d --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_str.h @@ -0,0 +1,50 @@ +/* +** String handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_STR_H +#define _LJ_STR_H + +#include + +#include "lj_obj.h" + +/* String interning. */ +LJ_FUNC int32_t LJ_FASTCALL lj_str_cmp(GCstr *a, GCstr *b); +LJ_FUNC void lj_str_resize(lua_State *L, MSize newmask); +LJ_FUNCA GCstr *lj_str_new(lua_State *L, const char *str, size_t len); +LJ_FUNC void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s); + +#define lj_str_newz(L, s) (lj_str_new(L, s, strlen(s))) +#define lj_str_newlit(L, s) (lj_str_new(L, "" s, sizeof(s)-1)) + +/* Type conversions. */ +LJ_FUNC size_t LJ_FASTCALL lj_str_bufnum(char *s, cTValue *o); +LJ_FUNC char * LJ_FASTCALL lj_str_bufint(char *p, int32_t k); +LJ_FUNCA GCstr * LJ_FASTCALL lj_str_fromnum(lua_State *L, const lua_Number *np); +LJ_FUNC GCstr * LJ_FASTCALL lj_str_fromint(lua_State *L, int32_t k); +LJ_FUNCA GCstr * LJ_FASTCALL lj_str_fromnumber(lua_State *L, cTValue *o); + +#define LJ_STR_INTBUF (1+10) +#define LJ_STR_NUMBUF LUAI_MAXNUMBER2STR + +/* String formatting. */ +LJ_FUNC const char *lj_str_pushvf(lua_State *L, const char *fmt, va_list argp); +LJ_FUNC const char *lj_str_pushf(lua_State *L, const char *fmt, ...) +#if defined(__GNUC__) + __attribute__ ((format (printf, 2, 3))) +#endif + ; + +/* Resizable string buffers. Struct definition in lj_obj.h. */ +LJ_FUNC char *lj_str_needbuf(lua_State *L, SBuf *sb, MSize sz); + +#define lj_str_initbuf(sb) ((sb)->buf = NULL, (sb)->sz = 0) +#define lj_str_resetbuf(sb) ((sb)->n = 0) +#define lj_str_resizebuf(L, sb, size) \ + ((sb)->buf = (char *)lj_mem_realloc(L, (sb)->buf, (sb)->sz, (size)), \ + (sb)->sz = (size)) +#define lj_str_freebuf(g, sb) lj_mem_free(g, (void *)(sb)->buf, (sb)->sz) + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_strscan.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_strscan.c new file mode 100644 index 000000000..568f647d6 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_strscan.c @@ -0,0 +1,498 @@ +/* +** String scanning. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include + +#define lj_strscan_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_char.h" +#include "lj_strscan.h" + +/* -- Scanning numbers ---------------------------------------------------- */ + +/* +** Rationale for the builtin string to number conversion library: +** +** It removes a dependency on libc's strtod(), which is a true portability +** nightmare. Mainly due to the plethora of supported OS and toolchain +** combinations. Sadly, the various implementations +** a) are often buggy, incomplete (no hex floats) and/or imprecise, +** b) sometimes crash or hang on certain inputs, +** c) return non-standard NaNs that need to be filtered out, and +** d) fail if the locale-specific decimal separator is not a dot, +** which can only be fixed with atrocious workarounds. +** +** Also, most of the strtod() implementations are hopelessly bloated, +** which is not just an I-cache hog, but a problem for static linkage +** on embedded systems, too. +** +** OTOH the builtin conversion function is very compact. Even though it +** does a lot more, like parsing long longs, octal or imaginary numbers +** and returning the result in different formats: +** a) It needs less than 3 KB (!) of machine code (on x64 with -Os), +** b) it doesn't perform any dynamic allocation and, +** c) it needs only around 600 bytes of stack space. +** +** The builtin function is faster than strtod() for typical inputs, e.g. +** "123", "1.5" or "1e6". Arguably, it's slower for very large exponents, +** which are not very common (this could be fixed, if needed). +** +** And most importantly, the builtin function is equally precise on all +** platforms. It correctly converts and rounds any input to a double. +** If this is not the case, please send a bug report -- but PLEASE verify +** that the implementation you're comparing to is not the culprit! +** +** The implementation quickly pre-scans the entire string first and +** handles simple integers on-the-fly. Otherwise, it dispatches to the +** base-specific parser. Hex and octal is straightforward. +** +** Decimal to binary conversion uses a fixed-length circular buffer in +** base 100. Some simple cases are handled directly. For other cases, the +** number in the buffer is up-scaled or down-scaled until the integer part +** is in the proper range. Then the integer part is rounded and converted +** to a double which is finally rescaled to the result. Denormals need +** special treatment to prevent incorrect 'double rounding'. +*/ + +/* Definitions for circular decimal digit buffer (base 100 = 2 digits/byte). */ +#define STRSCAN_DIG 1024 +#define STRSCAN_MAXDIG 800 /* 772 + extra are sufficient. */ +#define STRSCAN_DDIG (STRSCAN_DIG/2) +#define STRSCAN_DMASK (STRSCAN_DDIG-1) + +/* Helpers for circular buffer. */ +#define DNEXT(a) (((a)+1) & STRSCAN_DMASK) +#define DPREV(a) (((a)-1) & STRSCAN_DMASK) +#define DLEN(lo, hi) ((int32_t)(((lo)-(hi)) & STRSCAN_DMASK)) + +#define casecmp(c, k) (((c) | 0x20) == k) + +/* Final conversion to double. */ +static void strscan_double(uint64_t x, TValue *o, int32_t ex2, int32_t neg) +{ + double n; + + /* Avoid double rounding for denormals. */ + if (LJ_UNLIKELY(ex2 <= -1075 && x != 0)) { + /* NYI: all of this generates way too much code on 32 bit CPUs. */ +#if defined(__GNUC__) && LJ_64 + int32_t b = (int32_t)(__builtin_clzll(x)^63); +#else + int32_t b = (x>>32) ? 32+(int32_t)lj_fls((uint32_t)(x>>32)) : + (int32_t)lj_fls((uint32_t)x); +#endif + if ((int32_t)b + ex2 <= -1023 && (int32_t)b + ex2 >= -1075) { + uint64_t rb = (uint64_t)1 << (-1075-ex2); + if ((x & rb) && ((x & (rb+rb+rb-1)))) x += rb+rb; + x = (x & ~(rb+rb-1)); + } + } + + /* Convert to double using a signed int64_t conversion, then rescale. */ + lua_assert((int64_t)x >= 0); + n = (double)(int64_t)x; + if (neg) n = -n; + if (ex2) n = ldexp(n, ex2); + o->n = n; +} + +/* Parse hexadecimal number. */ +static StrScanFmt strscan_hex(const uint8_t *p, TValue *o, + StrScanFmt fmt, uint32_t opt, + int32_t ex2, int32_t neg, uint32_t dig) +{ + uint64_t x = 0; + uint32_t i; + + /* Scan hex digits. */ + for (i = dig > 16 ? 16 : dig ; i; i--, p++) { + uint32_t d = (*p != '.' ? *p : *++p); if (d > '9') d += 9; + x = (x << 4) + (d & 15); + } + + /* Summarize rounding-effect of excess digits. */ + for (i = 16; i < dig; i++, p++) + x |= ((*p != '.' ? *p : *++p) != '0'), ex2 += 4; + + /* Format-specific handling. */ + switch (fmt) { + case STRSCAN_INT: + if (!(opt & STRSCAN_OPT_TONUM) && x < 0x80000000u+neg) { + o->i = neg ? -(int32_t)x : (int32_t)x; + return STRSCAN_INT; /* Fast path for 32 bit integers. */ + } + if (!(opt & STRSCAN_OPT_C)) { fmt = STRSCAN_NUM; break; } + /* fallthrough */ + case STRSCAN_U32: + if (dig > 8) return STRSCAN_ERROR; + o->i = neg ? -(int32_t)x : (int32_t)x; + return STRSCAN_U32; + case STRSCAN_I64: + case STRSCAN_U64: + if (dig > 16) return STRSCAN_ERROR; + o->u64 = neg ? (uint64_t)-(int64_t)x : x; + return fmt; + default: + break; + } + + /* Reduce range then convert to double. */ + if ((x & U64x(c0000000,0000000))) { x = (x >> 2) | (x & 3); ex2 += 2; } + strscan_double(x, o, ex2, neg); + return fmt; +} + +/* Parse octal number. */ +static StrScanFmt strscan_oct(const uint8_t *p, TValue *o, + StrScanFmt fmt, int32_t neg, uint32_t dig) +{ + uint64_t x = 0; + + /* Scan octal digits. */ + if (dig > 22 || (dig == 22 && *p > '1')) return STRSCAN_ERROR; + while (dig-- > 0) { + if (!(*p >= '0' && *p <= '7')) return STRSCAN_ERROR; + x = (x << 3) + (*p++ & 7); + } + + /* Format-specific handling. */ + switch (fmt) { + case STRSCAN_INT: + if (x >= 0x80000000u+neg) fmt = STRSCAN_U32; + /* fallthrough */ + case STRSCAN_U32: + if ((x >> 32)) return STRSCAN_ERROR; + o->i = neg ? -(int32_t)x : (int32_t)x; + break; + default: + case STRSCAN_I64: + case STRSCAN_U64: + o->u64 = neg ? (uint64_t)-(int64_t)x : x; + break; + } + return fmt; +} + +/* Parse decimal number. */ +static StrScanFmt strscan_dec(const uint8_t *p, TValue *o, + StrScanFmt fmt, uint32_t opt, + int32_t ex10, int32_t neg, uint32_t dig) +{ + uint8_t xi[STRSCAN_DDIG], *xip = xi; + + if (dig) { + uint32_t i = dig; + if (i > STRSCAN_MAXDIG) { + ex10 += (int32_t)(i - STRSCAN_MAXDIG); + i = STRSCAN_MAXDIG; + } + /* Scan unaligned leading digit. */ + if (((ex10^i) & 1)) + *xip++ = ((*p != '.' ? *p : *++p) & 15), i--, p++; + /* Scan aligned double-digits. */ + for ( ; i > 1; i -= 2) { + uint32_t d = 10 * ((*p != '.' ? *p : *++p) & 15); p++; + *xip++ = d + ((*p != '.' ? *p : *++p) & 15); p++; + } + /* Scan and realign trailing digit. */ + if (i) *xip++ = 10 * ((*p != '.' ? *p : *++p) & 15), ex10--, dig++, p++; + + /* Summarize rounding-effect of excess digits. */ + if (dig > STRSCAN_MAXDIG) { + do { + if ((*p != '.' ? *p : *++p) != '0') { xip[-1] |= 1; break; } + p++; + } while (--dig > STRSCAN_MAXDIG); + dig = STRSCAN_MAXDIG; + } else { /* Simplify exponent. */ + while (ex10 > 0 && dig <= 18) *xip++ = 0, ex10 -= 2, dig += 2; + } + } else { /* Only got zeros. */ + ex10 = 0; + xi[0] = 0; + } + + /* Fast path for numbers in integer format (but handles e.g. 1e6, too). */ + if (dig <= 20 && ex10 == 0) { + uint8_t *xis; + uint64_t x = xi[0]; + double n; + for (xis = xi+1; xis < xip; xis++) x = x * 100 + *xis; + if (!(dig == 20 && (xi[0] > 18 || (int64_t)x >= 0))) { /* No overflow? */ + /* Format-specific handling. */ + switch (fmt) { + case STRSCAN_INT: + if (!(opt & STRSCAN_OPT_TONUM) && x < 0x80000000u+neg) { + o->i = neg ? -(int32_t)x : (int32_t)x; + return STRSCAN_INT; /* Fast path for 32 bit integers. */ + } + if (!(opt & STRSCAN_OPT_C)) { fmt = STRSCAN_NUM; goto plainnumber; } + /* fallthrough */ + case STRSCAN_U32: + if ((x >> 32) != 0) return STRSCAN_ERROR; + o->i = neg ? -(int32_t)x : (int32_t)x; + return STRSCAN_U32; + case STRSCAN_I64: + case STRSCAN_U64: + o->u64 = neg ? (uint64_t)-(int64_t)x : x; + return fmt; + default: + plainnumber: /* Fast path for plain numbers < 2^63. */ + if ((int64_t)x < 0) break; + n = (double)(int64_t)x; + if (neg) n = -n; + o->n = n; + return fmt; + } + } + } + + /* Slow non-integer path. */ + if (fmt == STRSCAN_INT) { + if ((opt & STRSCAN_OPT_C)) return STRSCAN_ERROR; + fmt = STRSCAN_NUM; + } else if (fmt > STRSCAN_INT) { + return STRSCAN_ERROR; + } + { + uint32_t hi = 0, lo = (uint32_t)(xip-xi); + int32_t ex2 = 0, idig = (int32_t)lo + (ex10 >> 1); + + lua_assert(lo > 0 && (ex10 & 1) == 0); + + /* Handle simple overflow/underflow. */ + if (idig > 310/2) { if (neg) setminfV(o); else setpinfV(o); return fmt; } + else if (idig < -326/2) { o->n = neg ? -0.0 : 0.0; return fmt; } + + /* Scale up until we have at least 17 or 18 integer part digits. */ + while (idig < 9 && idig < DLEN(lo, hi)) { + uint32_t i, cy = 0; + ex2 -= 6; + for (i = DPREV(lo); ; i = DPREV(i)) { + uint32_t d = (xi[i] << 6) + cy; + cy = (((d >> 2) * 5243) >> 17); d = d - cy * 100; /* Div/mod 100. */ + xi[i] = (uint8_t)d; + if (i == hi) break; + if (d == 0 && i == DPREV(lo)) lo = i; + } + if (cy) { + hi = DPREV(hi); + if (xi[DPREV(lo)] == 0) lo = DPREV(lo); + else if (hi == lo) { lo = DPREV(lo); xi[DPREV(lo)] |= xi[lo]; } + xi[hi] = (uint8_t)cy; idig++; + } + } + + /* Scale down until no more than 17 or 18 integer part digits remain. */ + while (idig > 9) { + uint32_t i = hi, cy = 0; + ex2 += 6; + do { + cy += xi[i]; + xi[i] = (cy >> 6); + cy = 100 * (cy & 0x3f); + if (xi[i] == 0 && i == hi) hi = DNEXT(hi), idig--; + i = DNEXT(i); + } while (i != lo); + while (cy) { + if (hi == lo) { xi[DPREV(lo)] |= 1; break; } + xi[lo] = (cy >> 6); lo = DNEXT(lo); + cy = 100 * (cy & 0x3f); + } + } + + /* Collect integer part digits and convert to rescaled double. */ + { + uint64_t x = xi[hi]; + uint32_t i; + for (i = DNEXT(hi); --idig > 0 && i != lo; i = DNEXT(i)) + x = x * 100 + xi[i]; + if (i == lo) { + while (--idig >= 0) x = x * 100; + } else { /* Gather round bit from remaining digits. */ + x <<= 1; ex2--; + do { + if (xi[i]) { x |= 1; break; } + i = DNEXT(i); + } while (i != lo); + } + strscan_double(x, o, ex2, neg); + } + } + return fmt; +} + +/* Scan string containing a number. Returns format. Returns value in o. */ +StrScanFmt lj_strscan_scan(const uint8_t *p, TValue *o, uint32_t opt) +{ + int32_t neg = 0; + + /* Remove leading space, parse sign and non-numbers. */ + if (LJ_UNLIKELY(!lj_char_isdigit(*p))) { + while (lj_char_isspace(*p)) p++; + if (*p == '+' || *p == '-') neg = (*p++ == '-'); + if (LJ_UNLIKELY(*p >= 'A')) { /* Parse "inf", "infinity" or "nan". */ + TValue tmp; + setnanV(&tmp); + if (casecmp(p[0],'i') && casecmp(p[1],'n') && casecmp(p[2],'f')) { + if (neg) setminfV(&tmp); else setpinfV(&tmp); + p += 3; + if (casecmp(p[0],'i') && casecmp(p[1],'n') && casecmp(p[2],'i') && + casecmp(p[3],'t') && casecmp(p[4],'y')) p += 5; + } else if (casecmp(p[0],'n') && casecmp(p[1],'a') && casecmp(p[2],'n')) { + p += 3; + } + while (lj_char_isspace(*p)) p++; + if (*p) return STRSCAN_ERROR; + o->u64 = tmp.u64; + return STRSCAN_NUM; + } + } + + /* Parse regular number. */ + { + StrScanFmt fmt = STRSCAN_INT; + int cmask = LJ_CHAR_DIGIT; + int base = (opt & STRSCAN_OPT_C) && *p == '0' ? 0 : 10; + const uint8_t *sp, *dp = NULL; + uint32_t dig = 0, hasdig = 0, x = 0; + int32_t ex = 0; + + /* Determine base and skip leading zeros. */ + if (LJ_UNLIKELY(*p <= '0')) { + if (*p == '0' && casecmp(p[1], 'x')) + base = 16, cmask = LJ_CHAR_XDIGIT, p += 2; + for ( ; ; p++) { + if (*p == '0') { + hasdig = 1; + } else if (*p == '.') { + if (dp) return STRSCAN_ERROR; + dp = p; + } else { + break; + } + } + } + + /* Preliminary digit and decimal point scan. */ + for (sp = p; ; p++) { + if (LJ_LIKELY(lj_char_isa(*p, cmask))) { + x = x * 10 + (*p & 15); /* For fast path below. */ + dig++; + } else if (*p == '.') { + if (dp) return STRSCAN_ERROR; + dp = p; + } else { + break; + } + } + if (!(hasdig | dig)) return STRSCAN_ERROR; + + /* Handle decimal point. */ + if (dp) { + fmt = STRSCAN_NUM; + if (dig) { + ex = (int32_t)(dp-(p-1)); dp = p-1; + while (ex < 0 && *dp-- == '0') ex++, dig--; /* Skip trailing zeros. */ + if (base == 16) ex *= 4; + } + } + + /* Parse exponent. */ + if (casecmp(*p, (uint32_t)(base == 16 ? 'p' : 'e'))) { + uint32_t xx; + int negx = 0; + fmt = STRSCAN_NUM; p++; + if (*p == '+' || *p == '-') negx = (*p++ == '-'); + if (!lj_char_isdigit(*p)) return STRSCAN_ERROR; + xx = (*p++ & 15); + while (lj_char_isdigit(*p)) { + if (xx < 65536) xx = xx * 10 + (*p & 15); + p++; + } + ex += negx ? -(int32_t)xx : (int32_t)xx; + } + + /* Parse suffix. */ + if (*p) { + /* I (IMAG), U (U32), LL (I64), ULL/LLU (U64), L (long), UL/LU (ulong). */ + /* NYI: f (float). Not needed until cp_number() handles non-integers. */ + if (casecmp(*p, 'i')) { + if (!(opt & STRSCAN_OPT_IMAG)) return STRSCAN_ERROR; + p++; fmt = STRSCAN_IMAG; + } else if (fmt == STRSCAN_INT) { + if (casecmp(*p, 'u')) p++, fmt = STRSCAN_U32; + if (casecmp(*p, 'l')) { + p++; + if (casecmp(*p, 'l')) p++, fmt += STRSCAN_I64 - STRSCAN_INT; + else if (!(opt & STRSCAN_OPT_C)) return STRSCAN_ERROR; + else if (sizeof(long) == 8) fmt += STRSCAN_I64 - STRSCAN_INT; + } + if (casecmp(*p, 'u') && (fmt == STRSCAN_INT || fmt == STRSCAN_I64)) + p++, fmt += STRSCAN_U32 - STRSCAN_INT; + if ((fmt == STRSCAN_U32 && !(opt & STRSCAN_OPT_C)) || + (fmt >= STRSCAN_I64 && !(opt & STRSCAN_OPT_LL))) + return STRSCAN_ERROR; + } + while (lj_char_isspace(*p)) p++; + if (*p) return STRSCAN_ERROR; + } + + /* Fast path for decimal 32 bit integers. */ + if (fmt == STRSCAN_INT && base == 10 && + (dig < 10 || (dig == 10 && *sp <= '2' && x < 0x80000000u+neg))) { + int32_t y = neg ? -(int32_t)x : (int32_t)x; + if ((opt & STRSCAN_OPT_TONUM)) { + o->n = (double)y; + return STRSCAN_NUM; + } else { + o->i = y; + return STRSCAN_INT; + } + } + + /* Dispatch to base-specific parser. */ + if (base == 0 && !(fmt == STRSCAN_NUM || fmt == STRSCAN_IMAG)) + return strscan_oct(sp, o, fmt, neg, dig); + if (base == 16) + fmt = strscan_hex(sp, o, fmt, opt, ex, neg, dig); + else + fmt = strscan_dec(sp, o, fmt, opt, ex, neg, dig); + + /* Try to convert number to integer, if requested. */ + if (fmt == STRSCAN_NUM && (opt & STRSCAN_OPT_TOINT)) { + double n = o->n; + int32_t i = lj_num2int(n); + if (n == (lua_Number)i) { o->i = i; return STRSCAN_INT; } + } + return fmt; + } +} + +int LJ_FASTCALL lj_strscan_num(GCstr *str, TValue *o) +{ + StrScanFmt fmt = lj_strscan_scan((const uint8_t *)strdata(str), o, + STRSCAN_OPT_TONUM); + lua_assert(fmt == STRSCAN_ERROR || fmt == STRSCAN_NUM); + return (fmt != STRSCAN_ERROR); +} + +#if LJ_DUALNUM +int LJ_FASTCALL lj_strscan_number(GCstr *str, TValue *o) +{ + StrScanFmt fmt = lj_strscan_scan((const uint8_t *)strdata(str), o, + STRSCAN_OPT_TOINT); + lua_assert(fmt == STRSCAN_ERROR || fmt == STRSCAN_NUM || fmt == STRSCAN_INT); + if (fmt == STRSCAN_INT) setitype(o, LJ_TISNUM); + return (fmt != STRSCAN_ERROR); +} +#endif + +#undef DNEXT +#undef DPREV +#undef DLEN + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_strscan.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_strscan.h new file mode 100644 index 000000000..776068936 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_strscan.h @@ -0,0 +1,39 @@ +/* +** String scanning. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_STRSCAN_H +#define _LJ_STRSCAN_H + +#include "lj_obj.h" + +/* Options for accepted/returned formats. */ +#define STRSCAN_OPT_TOINT 0x01 /* Convert to int32_t, if possible. */ +#define STRSCAN_OPT_TONUM 0x02 /* Always convert to double. */ +#define STRSCAN_OPT_IMAG 0x04 +#define STRSCAN_OPT_LL 0x08 +#define STRSCAN_OPT_C 0x10 + +/* Returned format. */ +typedef enum { + STRSCAN_ERROR, + STRSCAN_NUM, STRSCAN_IMAG, + STRSCAN_INT, STRSCAN_U32, STRSCAN_I64, STRSCAN_U64, +} StrScanFmt; + +LJ_FUNC StrScanFmt lj_strscan_scan(const uint8_t *p, TValue *o, uint32_t opt); +LJ_FUNC int LJ_FASTCALL lj_strscan_num(GCstr *str, TValue *o); +#if LJ_DUALNUM +LJ_FUNC int LJ_FASTCALL lj_strscan_number(GCstr *str, TValue *o); +#else +#define lj_strscan_number(s, o) lj_strscan_num((s), (o)) +#endif + +/* Check for number or convert string to number/int in-place (!). */ +static LJ_AINLINE int lj_strscan_numberobj(TValue *o) +{ + return tvisnumber(o) || (tvisstr(o) && lj_strscan_number(strV(o), o)); +} + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_tab.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_tab.c new file mode 100644 index 000000000..a8062db7c --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_tab.c @@ -0,0 +1,631 @@ +/* +** Table handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#define lj_tab_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_tab.h" + +/* -- Object hashing ------------------------------------------------------ */ + +/* Hash values are masked with the table hash mask and used as an index. */ +static LJ_AINLINE Node *hashmask(const GCtab *t, uint32_t hash) +{ + Node *n = noderef(t->node); + return &n[hash & t->hmask]; +} + +/* String hashes are precomputed when they are interned. */ +#define hashstr(t, s) hashmask(t, (s)->hash) + +#define hashlohi(t, lo, hi) hashmask((t), hashrot((lo), (hi))) +#define hashnum(t, o) hashlohi((t), (o)->u32.lo, ((o)->u32.hi << 1)) +#define hashptr(t, p) hashlohi((t), u32ptr(p), u32ptr(p) + HASH_BIAS) +#define hashgcref(t, r) hashlohi((t), gcrefu(r), gcrefu(r) + HASH_BIAS) + +/* Hash an arbitrary key and return its anchor position in the hash table. */ +static Node *hashkey(const GCtab *t, cTValue *key) +{ + lua_assert(!tvisint(key)); + if (tvisstr(key)) + return hashstr(t, strV(key)); + else if (tvisnum(key)) + return hashnum(t, key); + else if (tvisbool(key)) + return hashmask(t, boolV(key)); + else + return hashgcref(t, key->gcr); + /* Only hash 32 bits of lightuserdata on a 64 bit CPU. Good enough? */ +} + +/* -- Table creation and destruction -------------------------------------- */ + +/* Create new hash part for table. */ +static LJ_AINLINE void newhpart(lua_State *L, GCtab *t, uint32_t hbits) +{ + uint32_t hsize; + Node *node; + lua_assert(hbits != 0); + if (hbits > LJ_MAX_HBITS) + lj_err_msg(L, LJ_ERR_TABOV); + hsize = 1u << hbits; + node = lj_mem_newvec(L, hsize, Node); + setmref(node->freetop, &node[hsize]); + setmref(t->node, node); + t->hmask = hsize-1; +} + +/* +** Q: Why all of these copies of t->hmask, t->node etc. to local variables? +** A: Because alias analysis for C is _really_ tough. +** Even state-of-the-art C compilers won't produce good code without this. +*/ + +/* Clear hash part of table. */ +static LJ_AINLINE void clearhpart(GCtab *t) +{ + uint32_t i, hmask = t->hmask; + Node *node = noderef(t->node); + lua_assert(t->hmask != 0); + for (i = 0; i <= hmask; i++) { + Node *n = &node[i]; + setmref(n->next, NULL); + setnilV(&n->key); + setnilV(&n->val); + } +} + +/* Clear array part of table. */ +static LJ_AINLINE void clearapart(GCtab *t) +{ + uint32_t i, asize = t->asize; + TValue *array = tvref(t->array); + for (i = 0; i < asize; i++) + setnilV(&array[i]); +} + +/* Create a new table. Note: the slots are not initialized (yet). */ +static GCtab *newtab(lua_State *L, uint32_t asize, uint32_t hbits) +{ + GCtab *t; + /* First try to colocate the array part. */ + if (LJ_MAX_COLOSIZE != 0 && asize > 0 && asize <= LJ_MAX_COLOSIZE) { + lua_assert((sizeof(GCtab) & 7) == 0); + t = (GCtab *)lj_mem_newgco(L, sizetabcolo(asize)); + t->gct = ~LJ_TTAB; + t->nomm = (uint8_t)~0; + t->colo = (int8_t)asize; + setmref(t->array, (TValue *)((char *)t + sizeof(GCtab))); + setgcrefnull(t->metatable); + t->asize = asize; + t->hmask = 0; + setmref(t->node, &G(L)->nilnode); + } else { /* Otherwise separately allocate the array part. */ + t = lj_mem_newobj(L, GCtab); + t->gct = ~LJ_TTAB; + t->nomm = (uint8_t)~0; + t->colo = 0; + setmref(t->array, NULL); + setgcrefnull(t->metatable); + t->asize = 0; /* In case the array allocation fails. */ + t->hmask = 0; + setmref(t->node, &G(L)->nilnode); + if (asize > 0) { + if (asize > LJ_MAX_ASIZE) + lj_err_msg(L, LJ_ERR_TABOV); + setmref(t->array, lj_mem_newvec(L, asize, TValue)); + t->asize = asize; + } + } + if (hbits) + newhpart(L, t, hbits); + return t; +} + +/* Create a new table. +** +** IMPORTANT NOTE: The API differs from lua_createtable()! +** +** The array size is non-inclusive. E.g. asize=128 creates array slots +** for 0..127, but not for 128. If you need slots 1..128, pass asize=129 +** (slot 0 is wasted in this case). +** +** The hash size is given in hash bits. hbits=0 means no hash part. +** hbits=1 creates 2 hash slots, hbits=2 creates 4 hash slots and so on. +*/ +GCtab *lj_tab_new(lua_State *L, uint32_t asize, uint32_t hbits) +{ + GCtab *t = newtab(L, asize, hbits); + clearapart(t); + if (t->hmask > 0) clearhpart(t); + return t; +} + +#if LJ_HASJIT +GCtab * LJ_FASTCALL lj_tab_new1(lua_State *L, uint32_t ahsize) +{ + GCtab *t = newtab(L, ahsize & 0xffffff, ahsize >> 24); + clearapart(t); + if (t->hmask > 0) clearhpart(t); + return t; +} +#endif + +/* Duplicate a table. */ +GCtab * LJ_FASTCALL lj_tab_dup(lua_State *L, const GCtab *kt) +{ + GCtab *t; + uint32_t asize, hmask; + t = newtab(L, kt->asize, kt->hmask > 0 ? lj_fls(kt->hmask)+1 : 0); + lua_assert(kt->asize == t->asize && kt->hmask == t->hmask); + t->nomm = 0; /* Keys with metamethod names may be present. */ + asize = kt->asize; + if (asize > 0) { + TValue *array = tvref(t->array); + TValue *karray = tvref(kt->array); + if (asize < 64) { /* An inlined loop beats memcpy for < 512 bytes. */ + uint32_t i; + for (i = 0; i < asize; i++) + copyTV(L, &array[i], &karray[i]); + } else { + memcpy(array, karray, asize*sizeof(TValue)); + } + } + hmask = kt->hmask; + if (hmask > 0) { + uint32_t i; + Node *node = noderef(t->node); + Node *knode = noderef(kt->node); + ptrdiff_t d = (char *)node - (char *)knode; + setmref(node->freetop, (Node *)((char *)noderef(knode->freetop) + d)); + for (i = 0; i <= hmask; i++) { + Node *kn = &knode[i]; + Node *n = &node[i]; + Node *next = nextnode(kn); + /* Don't use copyTV here, since it asserts on a copy of a dead key. */ + n->val = kn->val; n->key = kn->key; + setmref(n->next, next == NULL? next : (Node *)((char *)next + d)); + } + } + return t; +} + +/* Free a table. */ +void LJ_FASTCALL lj_tab_free(global_State *g, GCtab *t) +{ + if (t->hmask > 0) + lj_mem_freevec(g, noderef(t->node), t->hmask+1, Node); + if (t->asize > 0 && LJ_MAX_COLOSIZE != 0 && t->colo <= 0) + lj_mem_freevec(g, tvref(t->array), t->asize, TValue); + if (LJ_MAX_COLOSIZE != 0 && t->colo) + lj_mem_free(g, t, sizetabcolo((uint32_t)t->colo & 0x7f)); + else + lj_mem_freet(g, t); +} + +/* -- Table resizing ------------------------------------------------------ */ + +/* Resize a table to fit the new array/hash part sizes. */ +static void resizetab(lua_State *L, GCtab *t, uint32_t asize, uint32_t hbits) +{ + Node *oldnode = noderef(t->node); + uint32_t oldasize = t->asize; + uint32_t oldhmask = t->hmask; + if (asize > oldasize) { /* Array part grows? */ + TValue *array; + uint32_t i; + if (asize > LJ_MAX_ASIZE) + lj_err_msg(L, LJ_ERR_TABOV); + if (LJ_MAX_COLOSIZE != 0 && t->colo > 0) { + /* A colocated array must be separated and copied. */ + TValue *oarray = tvref(t->array); + array = lj_mem_newvec(L, asize, TValue); + t->colo = (int8_t)(t->colo | 0x80); /* Mark as separated (colo < 0). */ + for (i = 0; i < oldasize; i++) + copyTV(L, &array[i], &oarray[i]); + } else { + array = (TValue *)lj_mem_realloc(L, tvref(t->array), + oldasize*sizeof(TValue), asize*sizeof(TValue)); + } + setmref(t->array, array); + t->asize = asize; + for (i = oldasize; i < asize; i++) /* Clear newly allocated slots. */ + setnilV(&array[i]); + } + /* Create new (empty) hash part. */ + if (hbits) { + newhpart(L, t, hbits); + clearhpart(t); + } else { + global_State *g = G(L); + setmref(t->node, &g->nilnode); + t->hmask = 0; + } + if (asize < oldasize) { /* Array part shrinks? */ + TValue *array = tvref(t->array); + uint32_t i; + t->asize = asize; /* Note: This 'shrinks' even colocated arrays. */ + for (i = asize; i < oldasize; i++) /* Reinsert old array values. */ + if (!tvisnil(&array[i])) + copyTV(L, lj_tab_setinth(L, t, (int32_t)i), &array[i]); + /* Physically shrink only separated arrays. */ + if (LJ_MAX_COLOSIZE != 0 && t->colo <= 0) + setmref(t->array, lj_mem_realloc(L, array, + oldasize*sizeof(TValue), asize*sizeof(TValue))); + } + if (oldhmask > 0) { /* Reinsert pairs from old hash part. */ + global_State *g; + uint32_t i; + for (i = 0; i <= oldhmask; i++) { + Node *n = &oldnode[i]; + if (!tvisnil(&n->val)) + copyTV(L, lj_tab_set(L, t, &n->key), &n->val); + } + g = G(L); + lj_mem_freevec(g, oldnode, oldhmask+1, Node); + } +} + +static uint32_t countint(cTValue *key, uint32_t *bins) +{ + lua_assert(!tvisint(key)); + if (tvisnum(key)) { + lua_Number nk = numV(key); + int32_t k = lj_num2int(nk); + if ((uint32_t)k < LJ_MAX_ASIZE && nk == (lua_Number)k) { + bins[(k > 2 ? lj_fls((uint32_t)(k-1)) : 0)]++; + return 1; + } + } + return 0; +} + +static uint32_t countarray(const GCtab *t, uint32_t *bins) +{ + uint32_t na, b, i; + if (t->asize == 0) return 0; + for (na = i = b = 0; b < LJ_MAX_ABITS; b++) { + uint32_t n, top = 2u << b; + TValue *array; + if (top >= t->asize) { + top = t->asize-1; + if (i > top) + break; + } + array = tvref(t->array); + for (n = 0; i <= top; i++) + if (!tvisnil(&array[i])) + n++; + bins[b] += n; + na += n; + } + return na; +} + +static uint32_t counthash(const GCtab *t, uint32_t *bins, uint32_t *narray) +{ + uint32_t total, na, i, hmask = t->hmask; + Node *node = noderef(t->node); + for (total = na = 0, i = 0; i <= hmask; i++) { + Node *n = &node[i]; + if (!tvisnil(&n->val)) { + na += countint(&n->key, bins); + total++; + } + } + *narray += na; + return total; +} + +static uint32_t bestasize(uint32_t bins[], uint32_t *narray) +{ + uint32_t b, sum, na = 0, sz = 0, nn = *narray; + for (b = 0, sum = 0; 2*nn > (1u< 0 && 2*(sum += bins[b]) > (1u<hmask > 0 ? lj_fls(t->hmask)+1 : 0); +} + +/* -- Table getters ------------------------------------------------------- */ + +cTValue * LJ_FASTCALL lj_tab_getinth(GCtab *t, int32_t key) +{ + TValue k; + Node *n; + k.n = (lua_Number)key; + n = hashnum(t, &k); + do { + if (tvisnum(&n->key) && n->key.n == k.n) + return &n->val; + } while ((n = nextnode(n))); + return NULL; +} + +cTValue *lj_tab_getstr(GCtab *t, GCstr *key) +{ + Node *n = hashstr(t, key); + do { + if (tvisstr(&n->key) && strV(&n->key) == key) + return &n->val; + } while ((n = nextnode(n))); + return NULL; +} + +cTValue *lj_tab_get(lua_State *L, GCtab *t, cTValue *key) +{ + if (tvisstr(key)) { + cTValue *tv = lj_tab_getstr(t, strV(key)); + if (tv) + return tv; + } else if (tvisint(key)) { + cTValue *tv = lj_tab_getint(t, intV(key)); + if (tv) + return tv; + } else if (tvisnum(key)) { + lua_Number nk = numV(key); + int32_t k = lj_num2int(nk); + if (nk == (lua_Number)k) { + cTValue *tv = lj_tab_getint(t, k); + if (tv) + return tv; + } else { + goto genlookup; /* Else use the generic lookup. */ + } + } else if (!tvisnil(key)) { + Node *n; + genlookup: + n = hashkey(t, key); + do { + if (lj_obj_equal(&n->key, key)) + return &n->val; + } while ((n = nextnode(n))); + } + return niltv(L); +} + +/* -- Table setters ------------------------------------------------------- */ + +/* Insert new key. Use Brent's variation to optimize the chain length. */ +TValue *lj_tab_newkey(lua_State *L, GCtab *t, cTValue *key) +{ + Node *n = hashkey(t, key); + if (!tvisnil(&n->val) || t->hmask == 0) { + Node *nodebase = noderef(t->node); + Node *collide, *freenode = noderef(nodebase->freetop); + lua_assert(freenode >= nodebase && freenode <= nodebase+t->hmask+1); + do { + if (freenode == nodebase) { /* No free node found? */ + rehashtab(L, t, key); /* Rehash table. */ + return lj_tab_set(L, t, key); /* Retry key insertion. */ + } + } while (!tvisnil(&(--freenode)->key)); + setmref(nodebase->freetop, freenode); + lua_assert(freenode != &G(L)->nilnode); + collide = hashkey(t, &n->key); + if (collide != n) { /* Colliding node not the main node? */ + while (noderef(collide->next) != n) /* Find predecessor. */ + collide = nextnode(collide); + setmref(collide->next, freenode); /* Relink chain. */ + /* Copy colliding node into free node and free main node. */ + freenode->val = n->val; + freenode->key = n->key; + freenode->next = n->next; + setmref(n->next, NULL); + setnilV(&n->val); + /* Rechain pseudo-resurrected string keys with colliding hashes. */ + while (nextnode(freenode)) { + Node *nn = nextnode(freenode); + if (tvisstr(&nn->key) && !tvisnil(&nn->val) && + hashstr(t, strV(&nn->key)) == n) { + freenode->next = nn->next; + nn->next = n->next; + setmref(n->next, nn); + } else { + freenode = nn; + } + } + } else { /* Otherwise use free node. */ + setmrefr(freenode->next, n->next); /* Insert into chain. */ + setmref(n->next, freenode); + n = freenode; + } + } + n->key.u64 = key->u64; + if (LJ_UNLIKELY(tvismzero(&n->key))) + n->key.u64 = 0; + lj_gc_anybarriert(L, t); + lua_assert(tvisnil(&n->val)); + return &n->val; +} + +TValue *lj_tab_setinth(lua_State *L, GCtab *t, int32_t key) +{ + TValue k; + Node *n; + k.n = (lua_Number)key; + n = hashnum(t, &k); + do { + if (tvisnum(&n->key) && n->key.n == k.n) + return &n->val; + } while ((n = nextnode(n))); + return lj_tab_newkey(L, t, &k); +} + +TValue *lj_tab_setstr(lua_State *L, GCtab *t, GCstr *key) +{ + TValue k; + Node *n = hashstr(t, key); + do { + if (tvisstr(&n->key) && strV(&n->key) == key) + return &n->val; + } while ((n = nextnode(n))); + setstrV(L, &k, key); + return lj_tab_newkey(L, t, &k); +} + +TValue *lj_tab_set(lua_State *L, GCtab *t, cTValue *key) +{ + Node *n; + t->nomm = 0; /* Invalidate negative metamethod cache. */ + if (tvisstr(key)) { + return lj_tab_setstr(L, t, strV(key)); + } else if (tvisint(key)) { + return lj_tab_setint(L, t, intV(key)); + } else if (tvisnum(key)) { + lua_Number nk = numV(key); + int32_t k = lj_num2int(nk); + if (nk == (lua_Number)k) + return lj_tab_setint(L, t, k); + if (tvisnan(key)) + lj_err_msg(L, LJ_ERR_NANIDX); + /* Else use the generic lookup. */ + } else if (tvisnil(key)) { + lj_err_msg(L, LJ_ERR_NILIDX); + } + n = hashkey(t, key); + do { + if (lj_obj_equal(&n->key, key)) + return &n->val; + } while ((n = nextnode(n))); + return lj_tab_newkey(L, t, key); +} + +/* -- Table traversal ----------------------------------------------------- */ + +/* Get the traversal index of a key. */ +static uint32_t keyindex(lua_State *L, GCtab *t, cTValue *key) +{ + TValue tmp; + if (tvisint(key)) { + int32_t k = intV(key); + if ((uint32_t)k < t->asize) + return (uint32_t)k; /* Array key indexes: [0..t->asize-1] */ + setnumV(&tmp, (lua_Number)k); + key = &tmp; + } else if (tvisnum(key)) { + lua_Number nk = numV(key); + int32_t k = lj_num2int(nk); + if ((uint32_t)k < t->asize && nk == (lua_Number)k) + return (uint32_t)k; /* Array key indexes: [0..t->asize-1] */ + } + if (!tvisnil(key)) { + Node *n = hashkey(t, key); + do { + if (lj_obj_equal(&n->key, key)) + return t->asize + (uint32_t)(n - noderef(t->node)); + /* Hash key indexes: [t->asize..t->asize+t->nmask] */ + } while ((n = nextnode(n))); + if (key->u32.hi == 0xfffe7fff) /* ITERN was despecialized while running. */ + return key->u32.lo - 1; + lj_err_msg(L, LJ_ERR_NEXTIDX); + return 0; /* unreachable */ + } + return ~0u; /* A nil key starts the traversal. */ +} + +/* Advance to the next step in a table traversal. */ +int lj_tab_next(lua_State *L, GCtab *t, TValue *key) +{ + uint32_t i = keyindex(L, t, key); /* Find predecessor key index. */ + for (i++; i < t->asize; i++) /* First traverse the array keys. */ + if (!tvisnil(arrayslot(t, i))) { + setintV(key, i); + copyTV(L, key+1, arrayslot(t, i)); + return 1; + } + for (i -= t->asize; i <= t->hmask; i++) { /* Then traverse the hash keys. */ + Node *n = &noderef(t->node)[i]; + if (!tvisnil(&n->val)) { + copyTV(L, key, &n->key); + copyTV(L, key+1, &n->val); + return 1; + } + } + return 0; /* End of traversal. */ +} + +/* -- Table length calculation -------------------------------------------- */ + +static MSize unbound_search(GCtab *t, MSize j) +{ + cTValue *tv; + MSize i = j; /* i is zero or a present index */ + j++; + /* find `i' and `j' such that i is present and j is not */ + while ((tv = lj_tab_getint(t, (int32_t)j)) && !tvisnil(tv)) { + i = j; + j *= 2; + if (j > (MSize)(INT_MAX-2)) { /* overflow? */ + /* table was built with bad purposes: resort to linear search */ + i = 1; + while ((tv = lj_tab_getint(t, (int32_t)i)) && !tvisnil(tv)) i++; + return i - 1; + } + } + /* now do a binary search between them */ + while (j - i > 1) { + MSize m = (i+j)/2; + cTValue *tvb = lj_tab_getint(t, (int32_t)m); + if (tvb && !tvisnil(tvb)) i = m; else j = m; + } + return i; +} + +/* +** Try to find a boundary in table `t'. A `boundary' is an integer index +** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). +*/ +MSize LJ_FASTCALL lj_tab_len(GCtab *t) +{ + MSize j = (MSize)t->asize; + if (j > 1 && tvisnil(arrayslot(t, j-1))) { + MSize i = 1; + while (j - i > 1) { + MSize m = (i+j)/2; + if (tvisnil(arrayslot(t, m-1))) j = m; else i = m; + } + return i-1; + } + if (j) j--; + if (t->hmask <= 0) + return j; + return unbound_search(t, j); +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_tab.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_tab.h new file mode 100644 index 000000000..f0d228eb2 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_tab.h @@ -0,0 +1,70 @@ +/* +** Table handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_TAB_H +#define _LJ_TAB_H + +#include "lj_obj.h" + +/* Hash constants. Tuned using a brute force search. */ +#define HASH_BIAS (-0x04c11db7) +#define HASH_ROT1 14 +#define HASH_ROT2 5 +#define HASH_ROT3 13 + +/* Scramble the bits of numbers and pointers. */ +static LJ_AINLINE uint32_t hashrot(uint32_t lo, uint32_t hi) +{ +#if LJ_TARGET_X86ORX64 + /* Prefer variant that compiles well for a 2-operand CPU. */ + lo ^= hi; hi = lj_rol(hi, HASH_ROT1); + lo -= hi; hi = lj_rol(hi, HASH_ROT2); + hi ^= lo; hi -= lj_rol(lo, HASH_ROT3); +#else + lo ^= hi; + lo = lo - lj_rol(hi, HASH_ROT1); + hi = lo ^ lj_rol(hi, HASH_ROT1 + HASH_ROT2); + hi = hi - lj_rol(lo, HASH_ROT3); +#endif + return hi; +} + +#define hsize2hbits(s) ((s) ? ((s)==1 ? 1 : 1+lj_fls((uint32_t)((s)-1))) : 0) + +LJ_FUNCA GCtab *lj_tab_new(lua_State *L, uint32_t asize, uint32_t hbits); +#if LJ_HASJIT +LJ_FUNC GCtab * LJ_FASTCALL lj_tab_new1(lua_State *L, uint32_t ahsize); +#endif +LJ_FUNCA GCtab * LJ_FASTCALL lj_tab_dup(lua_State *L, const GCtab *kt); +LJ_FUNC void LJ_FASTCALL lj_tab_free(global_State *g, GCtab *t); +#if LJ_HASFFI +LJ_FUNC void lj_tab_rehash(lua_State *L, GCtab *t); +#endif +LJ_FUNCA void lj_tab_reasize(lua_State *L, GCtab *t, uint32_t nasize); + +/* Caveat: all getters except lj_tab_get() can return NULL! */ + +LJ_FUNCA cTValue * LJ_FASTCALL lj_tab_getinth(GCtab *t, int32_t key); +LJ_FUNC cTValue *lj_tab_getstr(GCtab *t, GCstr *key); +LJ_FUNCA cTValue *lj_tab_get(lua_State *L, GCtab *t, cTValue *key); + +/* Caveat: all setters require a write barrier for the stored value. */ + +LJ_FUNCA TValue *lj_tab_newkey(lua_State *L, GCtab *t, cTValue *key); +LJ_FUNC TValue *lj_tab_setinth(lua_State *L, GCtab *t, int32_t key); +LJ_FUNC TValue *lj_tab_setstr(lua_State *L, GCtab *t, GCstr *key); +LJ_FUNC TValue *lj_tab_set(lua_State *L, GCtab *t, cTValue *key); + +#define inarray(t, key) ((MSize)(key) < (MSize)(t)->asize) +#define arrayslot(t, i) (&tvref((t)->array)[(i)]) +#define lj_tab_getint(t, key) \ + (inarray((t), (key)) ? arrayslot((t), (key)) : lj_tab_getinth((t), (key))) +#define lj_tab_setint(L, t, key) \ + (inarray((t), (key)) ? arrayslot((t), (key)) : lj_tab_setinth(L, (t), (key))) + +LJ_FUNCA int lj_tab_next(lua_State *L, GCtab *t, TValue *key); +LJ_FUNCA MSize LJ_FASTCALL lj_tab_len(GCtab *t); + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_target.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_target.h new file mode 100644 index 000000000..1a242325f --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_target.h @@ -0,0 +1,162 @@ +/* +** Definitions for target CPU. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_TARGET_H +#define _LJ_TARGET_H + +#include "lj_def.h" +#include "lj_arch.h" + +/* -- Registers and spill slots ------------------------------------------- */ + +/* Register type (uint8_t in ir->r). */ +typedef uint32_t Reg; + +/* The hi-bit is NOT set for an allocated register. This means the value +** can be directly used without masking. The hi-bit is set for a register +** allocation hint or for RID_INIT, RID_SINK or RID_SUNK. +*/ +#define RID_NONE 0x80 +#define RID_MASK 0x7f +#define RID_INIT (RID_NONE|RID_MASK) +#define RID_SINK (RID_INIT-1) +#define RID_SUNK (RID_INIT-2) + +#define ra_noreg(r) ((r) & RID_NONE) +#define ra_hasreg(r) (!((r) & RID_NONE)) + +/* The ra_hashint() macro assumes a previous test for ra_noreg(). */ +#define ra_hashint(r) ((r) < RID_SUNK) +#define ra_gethint(r) ((Reg)((r) & RID_MASK)) +#define ra_sethint(rr, r) rr = (uint8_t)((r)|RID_NONE) +#define ra_samehint(r1, r2) (ra_gethint((r1)^(r2)) == 0) + +/* Spill slot 0 means no spill slot has been allocated. */ +#define SPS_NONE 0 + +#define ra_hasspill(s) ((s) != SPS_NONE) + +/* Combined register and spill slot (uint16_t in ir->prev). */ +typedef uint32_t RegSP; + +#define REGSP(r, s) ((r) + ((s) << 8)) +#define REGSP_HINT(r) ((r)|RID_NONE) +#define REGSP_INIT REGSP(RID_INIT, 0) + +#define regsp_reg(rs) ((rs) & 255) +#define regsp_spill(rs) ((rs) >> 8) +#define regsp_used(rs) \ + (((rs) & ~REGSP(RID_MASK, 0)) != REGSP(RID_NONE, 0)) + +/* -- Register sets ------------------------------------------------------- */ + +/* Bitset for registers. 32 registers suffice for most architectures. +** Note that one set holds bits for both GPRs and FPRs. +*/ +#if LJ_TARGET_PPC || LJ_TARGET_MIPS +typedef uint64_t RegSet; +#else +typedef uint32_t RegSet; +#endif + +#define RID2RSET(r) (((RegSet)1) << (r)) +#define RSET_EMPTY ((RegSet)0) +#define RSET_RANGE(lo, hi) ((RID2RSET((hi)-(lo))-1) << (lo)) + +#define rset_test(rs, r) ((int)((rs) >> (r)) & 1) +#define rset_set(rs, r) (rs |= RID2RSET(r)) +#define rset_clear(rs, r) (rs &= ~RID2RSET(r)) +#define rset_exclude(rs, r) (rs & ~RID2RSET(r)) +#if LJ_TARGET_PPC || LJ_TARGET_MIPS +#define rset_picktop(rs) ((Reg)(__builtin_clzll(rs)^63)) +#define rset_pickbot(rs) ((Reg)__builtin_ctzll(rs)) +#else +#define rset_picktop(rs) ((Reg)lj_fls(rs)) +#define rset_pickbot(rs) ((Reg)lj_ffs(rs)) +#endif + +/* -- Register allocation cost -------------------------------------------- */ + +/* The register allocation heuristic keeps track of the cost for allocating +** a specific register: +** +** A free register (obviously) has a cost of 0 and a 1-bit in the free mask. +** +** An already allocated register has the (non-zero) IR reference in the lowest +** bits and the result of a blended cost-model in the higher bits. +** +** The allocator first checks the free mask for a hit. Otherwise an (unrolled) +** linear search for the minimum cost is used. The search doesn't need to +** keep track of the position of the minimum, which makes it very fast. +** The lowest bits of the minimum cost show the desired IR reference whose +** register is the one to evict. +** +** Without the cost-model this degenerates to the standard heuristics for +** (reverse) linear-scan register allocation. Since code generation is done +** in reverse, a live interval extends from the last use to the first def. +** For an SSA IR the IR reference is the first (and only) def and thus +** trivially marks the end of the interval. The LSRA heuristics says to pick +** the register whose live interval has the furthest extent, i.e. the lowest +** IR reference in our case. +** +** A cost-model should take into account other factors, like spill-cost and +** restore- or rematerialization-cost, which depend on the kind of instruction. +** E.g. constants have zero spill costs, variant instructions have higher +** costs than invariants and PHIs should preferably never be spilled. +** +** Here's a first cut at simple, but effective blended cost-model for R-LSRA: +** - Due to careful design of the IR, constants already have lower IR +** references than invariants and invariants have lower IR references +** than variants. +** - The cost in the upper 16 bits is the sum of the IR reference and a +** weighted score. The score currently only takes into account whether +** the IRT_ISPHI bit is set in the instruction type. +** - The PHI weight is the minimum distance (in IR instructions) a PHI +** reference has to be further apart from a non-PHI reference to be spilled. +** - It should be a power of two (for speed) and must be between 2 and 32768. +** Good values for the PHI weight seem to be between 40 and 150. +** - Further study is required. +*/ +#define REGCOST_PHI_WEIGHT 64 + +/* Cost for allocating a specific register. */ +typedef uint32_t RegCost; + +/* Note: assumes 16 bit IRRef1. */ +#define REGCOST(cost, ref) ((RegCost)(ref) + ((RegCost)(cost) << 16)) +#define regcost_ref(rc) ((IRRef1)(rc)) + +#define REGCOST_T(t) \ + ((RegCost)((t)&IRT_ISPHI) * (((RegCost)(REGCOST_PHI_WEIGHT)<<16)/IRT_ISPHI)) +#define REGCOST_REF_T(ref, t) (REGCOST((ref), (ref)) + REGCOST_T((t))) + +/* -- Target-specific definitions ----------------------------------------- */ + +#if LJ_TARGET_X86ORX64 +#include "lj_target_x86.h" +#elif LJ_TARGET_ARM +#include "lj_target_arm.h" +#elif LJ_TARGET_PPC +#include "lj_target_ppc.h" +#elif LJ_TARGET_MIPS +#include "lj_target_mips.h" +#else +#error "Missing include for target CPU" +#endif + +#ifdef EXITSTUBS_PER_GROUP +/* Return the address of an exit stub. */ +static LJ_AINLINE char *exitstub_addr_(char **group, uint32_t exitno) +{ + lua_assert(group[exitno / EXITSTUBS_PER_GROUP] != NULL); + return (char *)group[exitno / EXITSTUBS_PER_GROUP] + + EXITSTUB_SPACING*(exitno % EXITSTUBS_PER_GROUP); +} +/* Avoid dependence on lj_jit.h if only including lj_target.h. */ +#define exitstub_addr(J, exitno) \ + ((MCode *)exitstub_addr_((char **)((J)->exitstubgroup), (exitno))) +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_target_arm.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_target_arm.h new file mode 100644 index 000000000..6d4d0aed0 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_target_arm.h @@ -0,0 +1,274 @@ +/* +** Definitions for ARM CPUs. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_TARGET_ARM_H +#define _LJ_TARGET_ARM_H + +/* -- Registers IDs ------------------------------------------------------- */ + +#define GPRDEF(_) \ + _(R0) _(R1) _(R2) _(R3) _(R4) _(R5) _(R6) _(R7) \ + _(R8) _(R9) _(R10) _(R11) _(R12) _(SP) _(LR) _(PC) +#if LJ_SOFTFP +#define FPRDEF(_) +#else +#define FPRDEF(_) \ + _(D0) _(D1) _(D2) _(D3) _(D4) _(D5) _(D6) _(D7) \ + _(D8) _(D9) _(D10) _(D11) _(D12) _(D13) _(D14) _(D15) +#endif +#define VRIDDEF(_) + +#define RIDENUM(name) RID_##name, + +enum { + GPRDEF(RIDENUM) /* General-purpose registers (GPRs). */ + FPRDEF(RIDENUM) /* Floating-point registers (FPRs). */ + RID_MAX, + RID_TMP = RID_LR, + + /* Calling conventions. */ + RID_RET = RID_R0, + RID_RETLO = RID_R0, + RID_RETHI = RID_R1, +#if LJ_SOFTFP + RID_FPRET = RID_R0, +#else + RID_FPRET = RID_D0, +#endif + + /* These definitions must match with the *.dasc file(s): */ + RID_BASE = RID_R9, /* Interpreter BASE. */ + RID_LPC = RID_R6, /* Interpreter PC. */ + RID_DISPATCH = RID_R7, /* Interpreter DISPATCH table. */ + RID_LREG = RID_R8, /* Interpreter L. */ + + /* Register ranges [min, max) and number of registers. */ + RID_MIN_GPR = RID_R0, + RID_MAX_GPR = RID_PC+1, + RID_MIN_FPR = RID_MAX_GPR, +#if LJ_SOFTFP + RID_MAX_FPR = RID_MIN_FPR, +#else + RID_MAX_FPR = RID_D15+1, +#endif + RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR, + RID_NUM_FPR = RID_MAX_FPR - RID_MIN_FPR +}; + +#define RID_NUM_KREF RID_NUM_GPR +#define RID_MIN_KREF RID_R0 + +/* -- Register sets ------------------------------------------------------- */ + +/* Make use of all registers, except sp, lr and pc. */ +#define RSET_GPR (RSET_RANGE(RID_MIN_GPR, RID_R12+1)) +#define RSET_GPREVEN \ + (RID2RSET(RID_R0)|RID2RSET(RID_R2)|RID2RSET(RID_R4)|RID2RSET(RID_R6)| \ + RID2RSET(RID_R8)|RID2RSET(RID_R10)) +#define RSET_GPRODD \ + (RID2RSET(RID_R1)|RID2RSET(RID_R3)|RID2RSET(RID_R5)|RID2RSET(RID_R7)| \ + RID2RSET(RID_R9)|RID2RSET(RID_R11)) +#if LJ_SOFTFP +#define RSET_FPR 0 +#else +#define RSET_FPR (RSET_RANGE(RID_MIN_FPR, RID_MAX_FPR)) +#endif +#define RSET_ALL (RSET_GPR|RSET_FPR) +#define RSET_INIT RSET_ALL + +/* ABI-specific register sets. lr is an implicit scratch register. */ +#define RSET_SCRATCH_GPR_ (RSET_RANGE(RID_R0, RID_R3+1)|RID2RSET(RID_R12)) +#ifdef __APPLE__ +#define RSET_SCRATCH_GPR (RSET_SCRATCH_GPR_|RID2RSET(RID_R9)) +#else +#define RSET_SCRATCH_GPR RSET_SCRATCH_GPR_ +#endif +#if LJ_SOFTFP +#define RSET_SCRATCH_FPR 0 +#else +#define RSET_SCRATCH_FPR (RSET_RANGE(RID_D0, RID_D7+1)) +#endif +#define RSET_SCRATCH (RSET_SCRATCH_GPR|RSET_SCRATCH_FPR) +#define REGARG_FIRSTGPR RID_R0 +#define REGARG_LASTGPR RID_R3 +#define REGARG_NUMGPR 4 +#if LJ_ABI_SOFTFP +#define REGARG_FIRSTFPR 0 +#define REGARG_LASTFPR 0 +#define REGARG_NUMFPR 0 +#else +#define REGARG_FIRSTFPR RID_D0 +#define REGARG_LASTFPR RID_D7 +#define REGARG_NUMFPR 8 +#endif + +/* -- Spill slots --------------------------------------------------------- */ + +/* Spill slots are 32 bit wide. An even/odd pair is used for FPRs. +** +** SPS_FIXED: Available fixed spill slots in interpreter frame. +** This definition must match with the *.dasc file(s). +** +** SPS_FIRST: First spill slot for general use. Reserve min. two 32 bit slots. +*/ +#define SPS_FIXED 2 +#define SPS_FIRST 2 + +#define SPOFS_TMP 0 + +#define sps_scale(slot) (4 * (int32_t)(slot)) +#define sps_align(slot) (((slot) - SPS_FIXED + 1) & ~1) + +/* -- Exit state ---------------------------------------------------------- */ + +/* This definition must match with the *.dasc file(s). */ +typedef struct { +#if !LJ_SOFTFP + lua_Number fpr[RID_NUM_FPR]; /* Floating-point registers. */ +#endif + int32_t gpr[RID_NUM_GPR]; /* General-purpose registers. */ + int32_t spill[256]; /* Spill slots. */ +} ExitState; + +/* PC after instruction that caused an exit. Used to find the trace number. */ +#define EXITSTATE_PCREG RID_PC +/* Highest exit + 1 indicates stack check. */ +#define EXITSTATE_CHECKEXIT 1 + +#define EXITSTUB_SPACING 4 +#define EXITSTUBS_PER_GROUP 32 + +/* -- Instructions -------------------------------------------------------- */ + +/* Instruction fields. */ +#define ARMF_CC(ai, cc) (((ai) ^ ARMI_CCAL) | ((cc) << 28)) +#define ARMF_N(r) ((r) << 16) +#define ARMF_D(r) ((r) << 12) +#define ARMF_S(r) ((r) << 8) +#define ARMF_M(r) (r) +#define ARMF_SH(sh, n) (((sh) << 5) | ((n) << 7)) +#define ARMF_RSH(sh, r) (0x10 | ((sh) << 5) | ARMF_S(r)) + +typedef enum ARMIns { + ARMI_CCAL = 0xe0000000, + ARMI_S = 0x000100000, + ARMI_K12 = 0x02000000, + ARMI_KNEG = 0x00200000, + ARMI_LS_W = 0x00200000, + ARMI_LS_U = 0x00800000, + ARMI_LS_P = 0x01000000, + ARMI_LS_R = 0x02000000, + ARMI_LSX_I = 0x00400000, + + ARMI_AND = 0xe0000000, + ARMI_EOR = 0xe0200000, + ARMI_SUB = 0xe0400000, + ARMI_RSB = 0xe0600000, + ARMI_ADD = 0xe0800000, + ARMI_ADC = 0xe0a00000, + ARMI_SBC = 0xe0c00000, + ARMI_RSC = 0xe0e00000, + ARMI_TST = 0xe1100000, + ARMI_TEQ = 0xe1300000, + ARMI_CMP = 0xe1500000, + ARMI_CMN = 0xe1700000, + ARMI_ORR = 0xe1800000, + ARMI_MOV = 0xe1a00000, + ARMI_BIC = 0xe1c00000, + ARMI_MVN = 0xe1e00000, + + ARMI_NOP = 0xe1a00000, + + ARMI_MUL = 0xe0000090, + ARMI_SMULL = 0xe0c00090, + + ARMI_LDR = 0xe4100000, + ARMI_LDRB = 0xe4500000, + ARMI_LDRH = 0xe01000b0, + ARMI_LDRSB = 0xe01000d0, + ARMI_LDRSH = 0xe01000f0, + ARMI_LDRD = 0xe00000d0, + ARMI_STR = 0xe4000000, + ARMI_STRB = 0xe4400000, + ARMI_STRH = 0xe00000b0, + ARMI_STRD = 0xe00000f0, + ARMI_PUSH = 0xe92d0000, + + ARMI_B = 0xea000000, + ARMI_BL = 0xeb000000, + ARMI_BLX = 0xfa000000, + ARMI_BLXr = 0xe12fff30, + + /* ARMv6 */ + ARMI_REV = 0xe6bf0f30, + ARMI_SXTB = 0xe6af0070, + ARMI_SXTH = 0xe6bf0070, + ARMI_UXTB = 0xe6ef0070, + ARMI_UXTH = 0xe6ff0070, + + /* ARMv6T2 */ + ARMI_MOVW = 0xe3000000, + ARMI_MOVT = 0xe3400000, + + /* VFP */ + ARMI_VMOV_D = 0xeeb00b40, + ARMI_VMOV_S = 0xeeb00a40, + ARMI_VMOVI_D = 0xeeb00b00, + + ARMI_VMOV_R_S = 0xee100a10, + ARMI_VMOV_S_R = 0xee000a10, + ARMI_VMOV_RR_D = 0xec500b10, + ARMI_VMOV_D_RR = 0xec400b10, + + ARMI_VADD_D = 0xee300b00, + ARMI_VSUB_D = 0xee300b40, + ARMI_VMUL_D = 0xee200b00, + ARMI_VMLA_D = 0xee000b00, + ARMI_VMLS_D = 0xee000b40, + ARMI_VNMLS_D = 0xee100b00, + ARMI_VDIV_D = 0xee800b00, + + ARMI_VABS_D = 0xeeb00bc0, + ARMI_VNEG_D = 0xeeb10b40, + ARMI_VSQRT_D = 0xeeb10bc0, + + ARMI_VCMP_D = 0xeeb40b40, + ARMI_VCMPZ_D = 0xeeb50b40, + + ARMI_VMRS = 0xeef1fa10, + + ARMI_VCVT_S32_F32 = 0xeebd0ac0, + ARMI_VCVT_S32_F64 = 0xeebd0bc0, + ARMI_VCVT_U32_F32 = 0xeebc0ac0, + ARMI_VCVT_U32_F64 = 0xeebc0bc0, + ARMI_VCVTR_S32_F32 = 0xeebd0a40, + ARMI_VCVTR_S32_F64 = 0xeebd0b40, + ARMI_VCVTR_U32_F32 = 0xeebc0a40, + ARMI_VCVTR_U32_F64 = 0xeebc0b40, + ARMI_VCVT_F32_S32 = 0xeeb80ac0, + ARMI_VCVT_F64_S32 = 0xeeb80bc0, + ARMI_VCVT_F32_U32 = 0xeeb80a40, + ARMI_VCVT_F64_U32 = 0xeeb80b40, + ARMI_VCVT_F32_F64 = 0xeeb70bc0, + ARMI_VCVT_F64_F32 = 0xeeb70ac0, + + ARMI_VLDR_S = 0xed100a00, + ARMI_VLDR_D = 0xed100b00, + ARMI_VSTR_S = 0xed000a00, + ARMI_VSTR_D = 0xed000b00, +} ARMIns; + +typedef enum ARMShift { + ARMSH_LSL, ARMSH_LSR, ARMSH_ASR, ARMSH_ROR +} ARMShift; + +/* ARM condition codes. */ +typedef enum ARMCC { + CC_EQ, CC_NE, CC_CS, CC_CC, CC_MI, CC_PL, CC_VS, CC_VC, + CC_HI, CC_LS, CC_GE, CC_LT, CC_GT, CC_LE, CC_AL, + CC_HS = CC_CS, CC_LO = CC_CC +} ARMCC; + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_target_mips.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_target_mips.h new file mode 100644 index 000000000..0ab140bf3 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_target_mips.h @@ -0,0 +1,257 @@ +/* +** Definitions for MIPS CPUs. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_TARGET_MIPS_H +#define _LJ_TARGET_MIPS_H + +/* -- Registers IDs ------------------------------------------------------- */ + +#define GPRDEF(_) \ + _(R0) _(R1) _(R2) _(R3) _(R4) _(R5) _(R6) _(R7) \ + _(R8) _(R9) _(R10) _(R11) _(R12) _(R13) _(R14) _(R15) \ + _(R16) _(R17) _(R18) _(R19) _(R20) _(R21) _(R22) _(R23) \ + _(R24) _(R25) _(SYS1) _(SYS2) _(R28) _(SP) _(R30) _(RA) +#define FPRDEF(_) \ + _(F0) _(F1) _(F2) _(F3) _(F4) _(F5) _(F6) _(F7) \ + _(F8) _(F9) _(F10) _(F11) _(F12) _(F13) _(F14) _(F15) \ + _(F16) _(F17) _(F18) _(F19) _(F20) _(F21) _(F22) _(F23) \ + _(F24) _(F25) _(F26) _(F27) _(F28) _(F29) _(F30) _(F31) +#define VRIDDEF(_) + +#define RIDENUM(name) RID_##name, + +enum { + GPRDEF(RIDENUM) /* General-purpose registers (GPRs). */ + FPRDEF(RIDENUM) /* Floating-point registers (FPRs). */ + RID_MAX, + RID_ZERO = RID_R0, + RID_TMP = RID_RA, + + /* Calling conventions. */ + RID_RET = RID_R2, +#if LJ_LE + RID_RETHI = RID_R3, + RID_RETLO = RID_R2, +#else + RID_RETHI = RID_R2, + RID_RETLO = RID_R3, +#endif + RID_FPRET = RID_F0, + RID_CFUNCADDR = RID_R25, + + /* These definitions must match with the *.dasc file(s): */ + RID_BASE = RID_R16, /* Interpreter BASE. */ + RID_LPC = RID_R18, /* Interpreter PC. */ + RID_DISPATCH = RID_R19, /* Interpreter DISPATCH table. */ + RID_LREG = RID_R20, /* Interpreter L. */ + RID_JGL = RID_R30, /* On-trace: global_State + 32768. */ + + /* Register ranges [min, max) and number of registers. */ + RID_MIN_GPR = RID_R0, + RID_MAX_GPR = RID_RA+1, + RID_MIN_FPR = RID_F0, + RID_MAX_FPR = RID_F31+1, + RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR, + RID_NUM_FPR = RID_MAX_FPR - RID_MIN_FPR /* Only even regs are used. */ +}; + +#define RID_NUM_KREF RID_NUM_GPR +#define RID_MIN_KREF RID_R0 + +/* -- Register sets ------------------------------------------------------- */ + +/* Make use of all registers, except ZERO, TMP, SP, SYS1, SYS2 and JGL. */ +#define RSET_FIXED \ + (RID2RSET(RID_ZERO)|RID2RSET(RID_TMP)|RID2RSET(RID_SP)|\ + RID2RSET(RID_SYS1)|RID2RSET(RID_SYS2)|RID2RSET(RID_JGL)) +#define RSET_GPR (RSET_RANGE(RID_MIN_GPR, RID_MAX_GPR) - RSET_FIXED) +#define RSET_FPR \ + (RID2RSET(RID_F0)|RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(RID_F6)|\ + RID2RSET(RID_F8)|RID2RSET(RID_F10)|RID2RSET(RID_F12)|RID2RSET(RID_F14)|\ + RID2RSET(RID_F16)|RID2RSET(RID_F18)|RID2RSET(RID_F20)|RID2RSET(RID_F22)|\ + RID2RSET(RID_F24)|RID2RSET(RID_F26)|RID2RSET(RID_F28)|RID2RSET(RID_F30)) +#define RSET_ALL (RSET_GPR|RSET_FPR) +#define RSET_INIT RSET_ALL + +#define RSET_SCRATCH_GPR \ + (RSET_RANGE(RID_R1, RID_R15+1)|\ + RID2RSET(RID_R24)|RID2RSET(RID_R25)|RID2RSET(RID_R28)) +#define RSET_SCRATCH_FPR \ + (RID2RSET(RID_F0)|RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(RID_F6)|\ + RID2RSET(RID_F8)|RID2RSET(RID_F10)|RID2RSET(RID_F12)|RID2RSET(RID_F14)|\ + RID2RSET(RID_F16)|RID2RSET(RID_F18)) +#define RSET_SCRATCH (RSET_SCRATCH_GPR|RSET_SCRATCH_FPR) +#define REGARG_FIRSTGPR RID_R4 +#define REGARG_LASTGPR RID_R7 +#define REGARG_NUMGPR 4 +#define REGARG_FIRSTFPR RID_F12 +#define REGARG_LASTFPR RID_F14 +#define REGARG_NUMFPR 2 + +/* -- Spill slots --------------------------------------------------------- */ + +/* Spill slots are 32 bit wide. An even/odd pair is used for FPRs. +** +** SPS_FIXED: Available fixed spill slots in interpreter frame. +** This definition must match with the *.dasc file(s). +** +** SPS_FIRST: First spill slot for general use. +*/ +#define SPS_FIXED 5 +#define SPS_FIRST 4 + +#define SPOFS_TMP 0 + +#define sps_scale(slot) (4 * (int32_t)(slot)) +#define sps_align(slot) (((slot) - SPS_FIXED + 1) & ~1) + +/* -- Exit state ---------------------------------------------------------- */ + +/* This definition must match with the *.dasc file(s). */ +typedef struct { + lua_Number fpr[RID_NUM_FPR]; /* Floating-point registers. */ + int32_t gpr[RID_NUM_GPR]; /* General-purpose registers. */ + int32_t spill[256]; /* Spill slots. */ +} ExitState; + +/* Highest exit + 1 indicates stack check. */ +#define EXITSTATE_CHECKEXIT 1 + +/* Return the address of a per-trace exit stub. */ +static LJ_AINLINE uint32_t *exitstub_trace_addr_(uint32_t *p) +{ + while (*p == 0x00000000) p++; /* Skip MIPSI_NOP. */ + return p; +} +/* Avoid dependence on lj_jit.h if only including lj_target.h. */ +#define exitstub_trace_addr(T, exitno) \ + exitstub_trace_addr_((MCode *)((char *)(T)->mcode + (T)->szmcode)) + +/* -- Instructions -------------------------------------------------------- */ + +/* Instruction fields. */ +#define MIPSF_S(r) ((r) << 21) +#define MIPSF_T(r) ((r) << 16) +#define MIPSF_D(r) ((r) << 11) +#define MIPSF_R(r) ((r) << 21) +#define MIPSF_H(r) ((r) << 16) +#define MIPSF_G(r) ((r) << 11) +#define MIPSF_F(r) ((r) << 6) +#define MIPSF_A(n) ((n) << 6) +#define MIPSF_M(n) ((n) << 11) + +typedef enum MIPSIns { + /* Integer instructions. */ + MIPSI_MOVE = 0x00000021, + MIPSI_NOP = 0x00000000, + + MIPSI_LI = 0x24000000, + MIPSI_LU = 0x34000000, + MIPSI_LUI = 0x3c000000, + + MIPSI_ADDIU = 0x24000000, + MIPSI_ANDI = 0x30000000, + MIPSI_ORI = 0x34000000, + MIPSI_XORI = 0x38000000, + MIPSI_SLTI = 0x28000000, + MIPSI_SLTIU = 0x2c000000, + + MIPSI_ADDU = 0x00000021, + MIPSI_SUBU = 0x00000023, + MIPSI_MUL = 0x70000002, + MIPSI_AND = 0x00000024, + MIPSI_OR = 0x00000025, + MIPSI_XOR = 0x00000026, + MIPSI_NOR = 0x00000027, + MIPSI_SLT = 0x0000002a, + MIPSI_SLTU = 0x0000002b, + MIPSI_MOVZ = 0x0000000a, + MIPSI_MOVN = 0x0000000b, + + MIPSI_SLL = 0x00000000, + MIPSI_SRL = 0x00000002, + MIPSI_SRA = 0x00000003, + MIPSI_ROTR = 0x00200002, /* MIPS32R2 */ + MIPSI_SLLV = 0x00000004, + MIPSI_SRLV = 0x00000006, + MIPSI_SRAV = 0x00000007, + MIPSI_ROTRV = 0x00000046, /* MIPS32R2 */ + + MIPSI_SEB = 0x7c000420, /* MIPS32R2 */ + MIPSI_SEH = 0x7c000620, /* MIPS32R2 */ + MIPSI_WSBH = 0x7c0000a0, /* MIPS32R2 */ + + MIPSI_B = 0x10000000, + MIPSI_J = 0x08000000, + MIPSI_JAL = 0x0c000000, + MIPSI_JR = 0x00000008, + MIPSI_JALR = 0x0000f809, + + MIPSI_BEQ = 0x10000000, + MIPSI_BNE = 0x14000000, + MIPSI_BLEZ = 0x18000000, + MIPSI_BGTZ = 0x1c000000, + MIPSI_BLTZ = 0x04000000, + MIPSI_BGEZ = 0x04010000, + + /* Load/store instructions. */ + MIPSI_LW = 0x8c000000, + MIPSI_SW = 0xac000000, + MIPSI_LB = 0x80000000, + MIPSI_SB = 0xa0000000, + MIPSI_LH = 0x84000000, + MIPSI_SH = 0xa4000000, + MIPSI_LBU = 0x90000000, + MIPSI_LHU = 0x94000000, + MIPSI_LWC1 = 0xc4000000, + MIPSI_SWC1 = 0xe4000000, + MIPSI_LDC1 = 0xd4000000, + MIPSI_SDC1 = 0xf4000000, + + /* FP instructions. */ + MIPSI_MOV_S = 0x46000006, + MIPSI_MOV_D = 0x46200006, + MIPSI_MOVT_D = 0x46210011, + MIPSI_MOVF_D = 0x46200011, + + MIPSI_ABS_D = 0x46200005, + MIPSI_NEG_D = 0x46200007, + + MIPSI_ADD_D = 0x46200000, + MIPSI_SUB_D = 0x46200001, + MIPSI_MUL_D = 0x46200002, + MIPSI_DIV_D = 0x46200003, + MIPSI_SQRT_D = 0x46200004, + + MIPSI_ADD_S = 0x46000000, + MIPSI_SUB_S = 0x46000001, + + MIPSI_CVT_D_S = 0x46000021, + MIPSI_CVT_W_S = 0x46000024, + MIPSI_CVT_S_D = 0x46200020, + MIPSI_CVT_W_D = 0x46200024, + MIPSI_CVT_S_W = 0x46800020, + MIPSI_CVT_D_W = 0x46800021, + + MIPSI_TRUNC_W_S = 0x4600000d, + MIPSI_TRUNC_W_D = 0x4620000d, + MIPSI_FLOOR_W_S = 0x4600000f, + MIPSI_FLOOR_W_D = 0x4620000f, + + MIPSI_MFC1 = 0x44000000, + MIPSI_MTC1 = 0x44800000, + + MIPSI_BC1F = 0x45000000, + MIPSI_BC1T = 0x45010000, + + MIPSI_C_EQ_D = 0x46200032, + MIPSI_C_OLT_D = 0x46200034, + MIPSI_C_ULT_D = 0x46200035, + MIPSI_C_OLE_D = 0x46200036, + MIPSI_C_ULE_D = 0x46200037, + +} MIPSIns; + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_target_ppc.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_target_ppc.h new file mode 100644 index 000000000..2caeeb044 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_target_ppc.h @@ -0,0 +1,280 @@ +/* +** Definitions for PPC CPUs. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_TARGET_PPC_H +#define _LJ_TARGET_PPC_H + +/* -- Registers IDs ------------------------------------------------------- */ + +#define GPRDEF(_) \ + _(R0) _(SP) _(SYS1) _(R3) _(R4) _(R5) _(R6) _(R7) \ + _(R8) _(R9) _(R10) _(R11) _(R12) _(SYS2) _(R14) _(R15) \ + _(R16) _(R17) _(R18) _(R19) _(R20) _(R21) _(R22) _(R23) \ + _(R24) _(R25) _(R26) _(R27) _(R28) _(R29) _(R30) _(R31) +#define FPRDEF(_) \ + _(F0) _(F1) _(F2) _(F3) _(F4) _(F5) _(F6) _(F7) \ + _(F8) _(F9) _(F10) _(F11) _(F12) _(F13) _(F14) _(F15) \ + _(F16) _(F17) _(F18) _(F19) _(F20) _(F21) _(F22) _(F23) \ + _(F24) _(F25) _(F26) _(F27) _(F28) _(F29) _(F30) _(F31) +#define VRIDDEF(_) + +#define RIDENUM(name) RID_##name, + +enum { + GPRDEF(RIDENUM) /* General-purpose registers (GPRs). */ + FPRDEF(RIDENUM) /* Floating-point registers (FPRs). */ + RID_MAX, + RID_TMP = RID_R0, + + /* Calling conventions. */ + RID_RET = RID_R3, + RID_RETHI = RID_R3, + RID_RETLO = RID_R4, + RID_FPRET = RID_F1, + + /* These definitions must match with the *.dasc file(s): */ + RID_BASE = RID_R14, /* Interpreter BASE. */ + RID_LPC = RID_R16, /* Interpreter PC. */ + RID_DISPATCH = RID_R17, /* Interpreter DISPATCH table. */ + RID_LREG = RID_R18, /* Interpreter L. */ + RID_JGL = RID_R31, /* On-trace: global_State + 32768. */ + + /* Register ranges [min, max) and number of registers. */ + RID_MIN_GPR = RID_R0, + RID_MAX_GPR = RID_R31+1, + RID_MIN_FPR = RID_F0, + RID_MAX_FPR = RID_F31+1, + RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR, + RID_NUM_FPR = RID_MAX_FPR - RID_MIN_FPR +}; + +#define RID_NUM_KREF RID_NUM_GPR +#define RID_MIN_KREF RID_R0 + +/* -- Register sets ------------------------------------------------------- */ + +/* Make use of all registers, except TMP, SP, SYS1, SYS2 and JGL. */ +#define RSET_FIXED \ + (RID2RSET(RID_TMP)|RID2RSET(RID_SP)|RID2RSET(RID_SYS1)|\ + RID2RSET(RID_SYS2)|RID2RSET(RID_JGL)) +#define RSET_GPR (RSET_RANGE(RID_MIN_GPR, RID_MAX_GPR) - RSET_FIXED) +#define RSET_FPR RSET_RANGE(RID_MIN_FPR, RID_MAX_FPR) +#define RSET_ALL (RSET_GPR|RSET_FPR) +#define RSET_INIT RSET_ALL + +#define RSET_SCRATCH_GPR (RSET_RANGE(RID_R3, RID_R12+1)) +#define RSET_SCRATCH_FPR (RSET_RANGE(RID_F0, RID_F13+1)) +#define RSET_SCRATCH (RSET_SCRATCH_GPR|RSET_SCRATCH_FPR) +#define REGARG_FIRSTGPR RID_R3 +#define REGARG_LASTGPR RID_R10 +#define REGARG_NUMGPR 8 +#define REGARG_FIRSTFPR RID_F1 +#define REGARG_LASTFPR RID_F8 +#define REGARG_NUMFPR 8 + +/* -- Spill slots --------------------------------------------------------- */ + +/* Spill slots are 32 bit wide. An even/odd pair is used for FPRs. +** +** SPS_FIXED: Available fixed spill slots in interpreter frame. +** This definition must match with the *.dasc file(s). +** +** SPS_FIRST: First spill slot for general use. +** [sp+12] tmplo word \ +** [sp+ 8] tmphi word / tmp dword, parameter area for callee +** [sp+ 4] tmpw, LR of callee +** [sp+ 0] stack chain +*/ +#define SPS_FIXED 7 +#define SPS_FIRST 4 + +/* Stack offsets for temporary slots. Used for FP<->int conversions etc. */ +#define SPOFS_TMPW 4 +#define SPOFS_TMP 8 +#define SPOFS_TMPHI 8 +#define SPOFS_TMPLO 12 + +#define sps_scale(slot) (4 * (int32_t)(slot)) +#define sps_align(slot) (((slot) - SPS_FIXED + 3) & ~3) + +/* -- Exit state ---------------------------------------------------------- */ + +/* This definition must match with the *.dasc file(s). */ +typedef struct { + lua_Number fpr[RID_NUM_FPR]; /* Floating-point registers. */ + int32_t gpr[RID_NUM_GPR]; /* General-purpose registers. */ + int32_t spill[256]; /* Spill slots. */ +} ExitState; + +/* Highest exit + 1 indicates stack check. */ +#define EXITSTATE_CHECKEXIT 1 + +/* Return the address of a per-trace exit stub. */ +static LJ_AINLINE uint32_t *exitstub_trace_addr_(uint32_t *p, uint32_t exitno) +{ + while (*p == 0x60000000) p++; /* Skip PPCI_NOP. */ + return p + 3 + exitno; +} +/* Avoid dependence on lj_jit.h if only including lj_target.h. */ +#define exitstub_trace_addr(T, exitno) \ + exitstub_trace_addr_((MCode *)((char *)(T)->mcode + (T)->szmcode), (exitno)) + +/* -- Instructions -------------------------------------------------------- */ + +/* Instruction fields. */ +#define PPCF_CC(cc) ((((cc) & 3) << 16) | (((cc) & 4) << 22)) +#define PPCF_T(r) ((r) << 21) +#define PPCF_A(r) ((r) << 16) +#define PPCF_B(r) ((r) << 11) +#define PPCF_C(r) ((r) << 6) +#define PPCF_MB(n) ((n) << 6) +#define PPCF_ME(n) ((n) << 1) +#define PPCF_Y 0x00200000 +#define PPCF_DOT 0x00000001 + +typedef enum PPCIns { + /* Integer instructions. */ + PPCI_MR = 0x7c000378, + PPCI_NOP = 0x60000000, + + PPCI_LI = 0x38000000, + PPCI_LIS = 0x3c000000, + + PPCI_ADD = 0x7c000214, + PPCI_ADDC = 0x7c000014, + PPCI_ADDO = 0x7c000614, + PPCI_ADDE = 0x7c000114, + PPCI_ADDZE = 0x7c000194, + PPCI_ADDME = 0x7c0001d4, + PPCI_ADDI = 0x38000000, + PPCI_ADDIS = 0x3c000000, + PPCI_ADDIC = 0x30000000, + PPCI_ADDICDOT = 0x34000000, + + PPCI_SUBF = 0x7c000050, + PPCI_SUBFC = 0x7c000010, + PPCI_SUBFO = 0x7c000450, + PPCI_SUBFE = 0x7c000110, + PPCI_SUBFZE = 0x7c000190, + PPCI_SUBFME = 0x7c0001d0, + PPCI_SUBFIC = 0x20000000, + + PPCI_NEG = 0x7c0000d0, + + PPCI_AND = 0x7c000038, + PPCI_ANDC = 0x7c000078, + PPCI_NAND = 0x7c0003b8, + PPCI_ANDIDOT = 0x70000000, + PPCI_ANDISDOT = 0x74000000, + + PPCI_OR = 0x7c000378, + PPCI_NOR = 0x7c0000f8, + PPCI_ORI = 0x60000000, + PPCI_ORIS = 0x64000000, + + PPCI_XOR = 0x7c000278, + PPCI_EQV = 0x7c000238, + PPCI_XORI = 0x68000000, + PPCI_XORIS = 0x6c000000, + + PPCI_CMPW = 0x7c000000, + PPCI_CMPLW = 0x7c000040, + PPCI_CMPWI = 0x2c000000, + PPCI_CMPLWI = 0x28000000, + + PPCI_MULLW = 0x7c0001d6, + PPCI_MULLI = 0x1c000000, + PPCI_MULLWO = 0x7c0005d6, + + PPCI_EXTSB = 0x7c000774, + PPCI_EXTSH = 0x7c000734, + + PPCI_SLW = 0x7c000030, + PPCI_SRW = 0x7c000430, + PPCI_SRAW = 0x7c000630, + PPCI_SRAWI = 0x7c000670, + + PPCI_RLWNM = 0x5c000000, + PPCI_RLWINM = 0x54000000, + PPCI_RLWIMI = 0x50000000, + + PPCI_B = 0x48000000, + PPCI_BL = 0x48000001, + PPCI_BC = 0x40800000, + PPCI_BCL = 0x40800001, + PPCI_BCTR = 0x4e800420, + PPCI_BCTRL = 0x4e800421, + + PPCI_CRANDC = 0x4c000102, + PPCI_CRXOR = 0x4c000182, + PPCI_CRAND = 0x4c000202, + PPCI_CREQV = 0x4c000242, + PPCI_CRORC = 0x4c000342, + PPCI_CROR = 0x4c000382, + + PPCI_MFLR = 0x7c0802a6, + PPCI_MTCTR = 0x7c0903a6, + + PPCI_MCRXR = 0x7c000400, + + /* Load/store instructions. */ + PPCI_LWZ = 0x80000000, + PPCI_LBZ = 0x88000000, + PPCI_STW = 0x90000000, + PPCI_STB = 0x98000000, + PPCI_LHZ = 0xa0000000, + PPCI_LHA = 0xa8000000, + PPCI_STH = 0xb0000000, + + PPCI_STWU = 0x94000000, + + PPCI_LFS = 0xc0000000, + PPCI_LFD = 0xc8000000, + PPCI_STFS = 0xd0000000, + PPCI_STFD = 0xd8000000, + + PPCI_LWZX = 0x7c00002e, + PPCI_LBZX = 0x7c0000ae, + PPCI_STWX = 0x7c00012e, + PPCI_STBX = 0x7c0001ae, + PPCI_LHZX = 0x7c00022e, + PPCI_LHAX = 0x7c0002ae, + PPCI_STHX = 0x7c00032e, + + PPCI_LWBRX = 0x7c00042c, + PPCI_STWBRX = 0x7c00052c, + + PPCI_LFSX = 0x7c00042e, + PPCI_LFDX = 0x7c0004ae, + PPCI_STFSX = 0x7c00052e, + PPCI_STFDX = 0x7c0005ae, + + /* FP instructions. */ + PPCI_FMR = 0xfc000090, + PPCI_FNEG = 0xfc000050, + PPCI_FABS = 0xfc000210, + + PPCI_FRSP = 0xfc000018, + PPCI_FCTIWZ = 0xfc00001e, + + PPCI_FADD = 0xfc00002a, + PPCI_FSUB = 0xfc000028, + PPCI_FMUL = 0xfc000032, + PPCI_FDIV = 0xfc000024, + PPCI_FSQRT = 0xfc00002c, + + PPCI_FMADD = 0xfc00003a, + PPCI_FMSUB = 0xfc000038, + PPCI_FNMSUB = 0xfc00003c, + + PPCI_FCMPU = 0xfc000000, + PPCI_FSEL = 0xfc00002e, +} PPCIns; + +typedef enum PPCCC { + CC_GE, CC_LE, CC_NE, CC_NS, CC_LT, CC_GT, CC_EQ, CC_SO +} PPCCC; + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_target_x86.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_target_x86.h new file mode 100644 index 000000000..d12a1b87c --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_target_x86.h @@ -0,0 +1,342 @@ +/* +** Definitions for x86 and x64 CPUs. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_TARGET_X86_H +#define _LJ_TARGET_X86_H + +/* -- Registers IDs ------------------------------------------------------- */ + +#if LJ_64 +#define GPRDEF(_) \ + _(EAX) _(ECX) _(EDX) _(EBX) _(ESP) _(EBP) _(ESI) _(EDI) \ + _(R8D) _(R9D) _(R10D) _(R11D) _(R12D) _(R13D) _(R14D) _(R15D) +#define FPRDEF(_) \ + _(XMM0) _(XMM1) _(XMM2) _(XMM3) _(XMM4) _(XMM5) _(XMM6) _(XMM7) \ + _(XMM8) _(XMM9) _(XMM10) _(XMM11) _(XMM12) _(XMM13) _(XMM14) _(XMM15) +#else +#define GPRDEF(_) \ + _(EAX) _(ECX) _(EDX) _(EBX) _(ESP) _(EBP) _(ESI) _(EDI) +#define FPRDEF(_) \ + _(XMM0) _(XMM1) _(XMM2) _(XMM3) _(XMM4) _(XMM5) _(XMM6) _(XMM7) +#endif +#define VRIDDEF(_) \ + _(MRM) + +#define RIDENUM(name) RID_##name, + +enum { + GPRDEF(RIDENUM) /* General-purpose registers (GPRs). */ + FPRDEF(RIDENUM) /* Floating-point registers (FPRs). */ + RID_MAX, + RID_MRM = RID_MAX, /* Pseudo-id for ModRM operand. */ + + /* Calling conventions. */ + RID_RET = RID_EAX, +#if LJ_64 + RID_FPRET = RID_XMM0, +#else + RID_RETLO = RID_EAX, + RID_RETHI = RID_EDX, +#endif + + /* These definitions must match with the *.dasc file(s): */ + RID_BASE = RID_EDX, /* Interpreter BASE. */ +#if LJ_64 && !LJ_ABI_WIN + RID_LPC = RID_EBX, /* Interpreter PC. */ + RID_DISPATCH = RID_R14D, /* Interpreter DISPATCH table. */ +#else + RID_LPC = RID_ESI, /* Interpreter PC. */ + RID_DISPATCH = RID_EBX, /* Interpreter DISPATCH table. */ +#endif + + /* Register ranges [min, max) and number of registers. */ + RID_MIN_GPR = RID_EAX, + RID_MIN_FPR = RID_XMM0, + RID_MAX_GPR = RID_MIN_FPR, + RID_MAX_FPR = RID_MAX, + RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR, + RID_NUM_FPR = RID_MAX_FPR - RID_MIN_FPR, +}; + +/* -- Register sets ------------------------------------------------------- */ + +/* Make use of all registers, except the stack pointer. */ +#define RSET_GPR (RSET_RANGE(RID_MIN_GPR, RID_MAX_GPR)-RID2RSET(RID_ESP)) +#define RSET_FPR (RSET_RANGE(RID_MIN_FPR, RID_MAX_FPR)) +#define RSET_ALL (RSET_GPR|RSET_FPR) +#define RSET_INIT RSET_ALL + +#if LJ_64 +/* Note: this requires the use of FORCE_REX! */ +#define RSET_GPR8 RSET_GPR +#else +#define RSET_GPR8 (RSET_RANGE(RID_EAX, RID_EBX+1)) +#endif + +/* ABI-specific register sets. */ +#define RSET_ACD (RID2RSET(RID_EAX)|RID2RSET(RID_ECX)|RID2RSET(RID_EDX)) +#if LJ_64 +#if LJ_ABI_WIN +/* Windows x64 ABI. */ +#define RSET_SCRATCH \ + (RSET_ACD|RSET_RANGE(RID_R8D, RID_R11D+1)|RSET_RANGE(RID_XMM0, RID_XMM5+1)) +#define REGARG_GPRS \ + (RID_ECX|((RID_EDX|((RID_R8D|(RID_R9D<<5))<<5))<<5)) +#define REGARG_NUMGPR 4 +#define REGARG_NUMFPR 4 +#define REGARG_FIRSTFPR RID_XMM0 +#define REGARG_LASTFPR RID_XMM3 +#define STACKARG_OFS (4*8) +#else +/* The rest of the civilized x64 world has a common ABI. */ +#define RSET_SCRATCH \ + (RSET_ACD|RSET_RANGE(RID_ESI, RID_R11D+1)|RSET_FPR) +#define REGARG_GPRS \ + (RID_EDI|((RID_ESI|((RID_EDX|((RID_ECX|((RID_R8D|(RID_R9D \ + <<5))<<5))<<5))<<5))<<5)) +#define REGARG_NUMGPR 6 +#define REGARG_NUMFPR 8 +#define REGARG_FIRSTFPR RID_XMM0 +#define REGARG_LASTFPR RID_XMM7 +#define STACKARG_OFS 0 +#endif +#else +/* Common x86 ABI. */ +#define RSET_SCRATCH (RSET_ACD|RSET_FPR) +#define REGARG_GPRS (RID_ECX|(RID_EDX<<5)) /* Fastcall only. */ +#define REGARG_NUMGPR 2 /* Fastcall only. */ +#define REGARG_NUMFPR 0 +#define STACKARG_OFS 0 +#endif + +#if LJ_64 +/* Prefer the low 8 regs of each type to reduce REX prefixes. */ +#undef rset_picktop +#define rset_picktop(rs) (lj_fls(lj_bswap(rs)) ^ 0x18) +#endif + +/* -- Spill slots --------------------------------------------------------- */ + +/* Spill slots are 32 bit wide. An even/odd pair is used for FPRs. +** +** SPS_FIXED: Available fixed spill slots in interpreter frame. +** This definition must match with the *.dasc file(s). +** +** SPS_FIRST: First spill slot for general use. Reserve min. two 32 bit slots. +*/ +#if LJ_64 +#if LJ_ABI_WIN +#define SPS_FIXED (4*2) +#define SPS_FIRST (4*2) /* Don't use callee register save area. */ +#else +#define SPS_FIXED 4 +#define SPS_FIRST 2 +#endif +#else +#define SPS_FIXED 6 +#define SPS_FIRST 2 +#endif + +#define SPOFS_TMP 0 + +#define sps_scale(slot) (4 * (int32_t)(slot)) +#define sps_align(slot) (((slot) - SPS_FIXED + 3) & ~3) + +/* -- Exit state ---------------------------------------------------------- */ + +/* This definition must match with the *.dasc file(s). */ +typedef struct { + lua_Number fpr[RID_NUM_FPR]; /* Floating-point registers. */ + intptr_t gpr[RID_NUM_GPR]; /* General-purpose registers. */ + int32_t spill[256]; /* Spill slots. */ +} ExitState; + +/* Limited by the range of a short fwd jump (127): (2+2)*(32-1)-2 = 122. */ +#define EXITSTUB_SPACING (2+2) +#define EXITSTUBS_PER_GROUP 32 + +/* -- x86 ModRM operand encoding ------------------------------------------ */ + +typedef enum { + XM_OFS0 = 0x00, XM_OFS8 = 0x40, XM_OFS32 = 0x80, XM_REG = 0xc0, + XM_SCALE1 = 0x00, XM_SCALE2 = 0x40, XM_SCALE4 = 0x80, XM_SCALE8 = 0xc0, + XM_MASK = 0xc0 +} x86Mode; + +/* Structure to hold variable ModRM operand. */ +typedef struct { + int32_t ofs; /* Offset. */ + uint8_t base; /* Base register or RID_NONE. */ + uint8_t idx; /* Index register or RID_NONE. */ + uint8_t scale; /* Index scale (XM_SCALE1 .. XM_SCALE8). */ +} x86ModRM; + +/* -- Opcodes ------------------------------------------------------------- */ + +/* Macros to construct variable-length x86 opcodes. -(len+1) is in LSB. */ +#define XO_(o) ((uint32_t)(0x0000fe + (0x##o<<24))) +#define XO_FPU(a,b) ((uint32_t)(0x00fd + (0x##a<<16)+(0x##b<<24))) +#define XO_0f(o) ((uint32_t)(0x0f00fd + (0x##o<<24))) +#define XO_66(o) ((uint32_t)(0x6600fd + (0x##o<<24))) +#define XO_660f(o) ((uint32_t)(0x0f66fc + (0x##o<<24))) +#define XO_f20f(o) ((uint32_t)(0x0ff2fc + (0x##o<<24))) +#define XO_f30f(o) ((uint32_t)(0x0ff3fc + (0x##o<<24))) + +/* This list of x86 opcodes is not intended to be complete. Opcodes are only +** included when needed. Take a look at DynASM or jit.dis_x86 to see the +** whole mess. +*/ +typedef enum { + /* Fixed length opcodes. XI_* prefix. */ + XI_NOP = 0x90, + XI_XCHGa = 0x90, + XI_CALL = 0xe8, + XI_JMP = 0xe9, + XI_JMPs = 0xeb, + XI_PUSH = 0x50, /* Really 50+r. */ + XI_JCCs = 0x70, /* Really 7x. */ + XI_JCCn = 0x80, /* Really 0f8x. */ + XI_LEA = 0x8d, + XI_MOVrib = 0xb0, /* Really b0+r. */ + XI_MOVri = 0xb8, /* Really b8+r. */ + XI_ARITHib = 0x80, + XI_ARITHi = 0x81, + XI_ARITHi8 = 0x83, + XI_PUSHi8 = 0x6a, + XI_TESTb = 0x84, + XI_TEST = 0x85, + XI_MOVmi = 0xc7, + XI_GROUP5 = 0xff, + + /* Note: little-endian byte-order! */ + XI_FLDZ = 0xeed9, + XI_FLD1 = 0xe8d9, + XI_FLDLG2 = 0xecd9, + XI_FLDLN2 = 0xedd9, + XI_FDUP = 0xc0d9, /* Really fld st0. */ + XI_FPOP = 0xd8dd, /* Really fstp st0. */ + XI_FPOP1 = 0xd9dd, /* Really fstp st1. */ + XI_FRNDINT = 0xfcd9, + XI_FSIN = 0xfed9, + XI_FCOS = 0xffd9, + XI_FPTAN = 0xf2d9, + XI_FPATAN = 0xf3d9, + XI_FSCALE = 0xfdd9, + XI_FYL2X = 0xf1d9, + + /* Variable-length opcodes. XO_* prefix. */ + XO_MOV = XO_(8b), + XO_MOVto = XO_(89), + XO_MOVtow = XO_66(89), + XO_MOVtob = XO_(88), + XO_MOVmi = XO_(c7), + XO_MOVmib = XO_(c6), + XO_LEA = XO_(8d), + XO_ARITHib = XO_(80), + XO_ARITHi = XO_(81), + XO_ARITHi8 = XO_(83), + XO_ARITHiw8 = XO_66(83), + XO_SHIFTi = XO_(c1), + XO_SHIFT1 = XO_(d1), + XO_SHIFTcl = XO_(d3), + XO_IMUL = XO_0f(af), + XO_IMULi = XO_(69), + XO_IMULi8 = XO_(6b), + XO_CMP = XO_(3b), + XO_TESTb = XO_(84), + XO_TEST = XO_(85), + XO_GROUP3b = XO_(f6), + XO_GROUP3 = XO_(f7), + XO_GROUP5b = XO_(fe), + XO_GROUP5 = XO_(ff), + XO_MOVZXb = XO_0f(b6), + XO_MOVZXw = XO_0f(b7), + XO_MOVSXb = XO_0f(be), + XO_MOVSXw = XO_0f(bf), + XO_MOVSXd = XO_(63), + XO_BSWAP = XO_0f(c8), + XO_CMOV = XO_0f(40), + + XO_MOVSD = XO_f20f(10), + XO_MOVSDto = XO_f20f(11), + XO_MOVSS = XO_f30f(10), + XO_MOVSSto = XO_f30f(11), + XO_MOVLPD = XO_660f(12), + XO_MOVAPS = XO_0f(28), + XO_XORPS = XO_0f(57), + XO_ANDPS = XO_0f(54), + XO_ADDSD = XO_f20f(58), + XO_SUBSD = XO_f20f(5c), + XO_MULSD = XO_f20f(59), + XO_DIVSD = XO_f20f(5e), + XO_SQRTSD = XO_f20f(51), + XO_MINSD = XO_f20f(5d), + XO_MAXSD = XO_f20f(5f), + XO_ROUNDSD = 0x0b3a0ffc, /* Really 66 0f 3a 0b. See asm_fpmath. */ + XO_UCOMISD = XO_660f(2e), + XO_CVTSI2SD = XO_f20f(2a), + XO_CVTSD2SI = XO_f20f(2d), + XO_CVTTSD2SI= XO_f20f(2c), + XO_CVTSI2SS = XO_f30f(2a), + XO_CVTSS2SI = XO_f30f(2d), + XO_CVTTSS2SI= XO_f30f(2c), + XO_CVTSS2SD = XO_f30f(5a), + XO_CVTSD2SS = XO_f20f(5a), + XO_ADDSS = XO_f30f(58), + XO_MOVD = XO_660f(6e), + XO_MOVDto = XO_660f(7e), + + XO_FLDd = XO_(d9), XOg_FLDd = 0, + XO_FLDq = XO_(dd), XOg_FLDq = 0, + XO_FILDd = XO_(db), XOg_FILDd = 0, + XO_FILDq = XO_(df), XOg_FILDq = 5, + XO_FSTPd = XO_(d9), XOg_FSTPd = 3, + XO_FSTPq = XO_(dd), XOg_FSTPq = 3, + XO_FISTPq = XO_(df), XOg_FISTPq = 7, + XO_FISTTPq = XO_(dd), XOg_FISTTPq = 1, + XO_FADDq = XO_(dc), XOg_FADDq = 0, + XO_FLDCW = XO_(d9), XOg_FLDCW = 5, + XO_FNSTCW = XO_(d9), XOg_FNSTCW = 7 +} x86Op; + +/* x86 opcode groups. */ +typedef uint32_t x86Group; + +#define XG_(i8, i, g) ((x86Group)(((i8) << 16) + ((i) << 8) + (g))) +#define XG_ARITHi(g) XG_(XI_ARITHi8, XI_ARITHi, g) +#define XG_TOXOi(xg) ((x86Op)(0x000000fe + (((xg)<<16) & 0xff000000))) +#define XG_TOXOi8(xg) ((x86Op)(0x000000fe + (((xg)<<8) & 0xff000000))) + +#define XO_ARITH(a) ((x86Op)(0x030000fe + ((a)<<27))) +#define XO_ARITHw(a) ((x86Op)(0x036600fd + ((a)<<27))) + +typedef enum { + XOg_ADD, XOg_OR, XOg_ADC, XOg_SBB, XOg_AND, XOg_SUB, XOg_XOR, XOg_CMP, + XOg_X_IMUL +} x86Arith; + +typedef enum { + XOg_ROL, XOg_ROR, XOg_RCL, XOg_RCR, XOg_SHL, XOg_SHR, XOg_SAL, XOg_SAR +} x86Shift; + +typedef enum { + XOg_TEST, XOg_TEST_, XOg_NOT, XOg_NEG, XOg_MUL, XOg_IMUL, XOg_DIV, XOg_IDIV +} x86Group3; + +typedef enum { + XOg_INC, XOg_DEC, XOg_CALL, XOg_CALLfar, XOg_JMP, XOg_JMPfar, XOg_PUSH +} x86Group5; + +/* x86 condition codes. */ +typedef enum { + CC_O, CC_NO, CC_B, CC_NB, CC_E, CC_NE, CC_BE, CC_NBE, + CC_S, CC_NS, CC_P, CC_NP, CC_L, CC_NL, CC_LE, CC_NLE, + CC_C = CC_B, CC_NAE = CC_C, CC_NC = CC_NB, CC_AE = CC_NB, + CC_Z = CC_E, CC_NZ = CC_NE, CC_NA = CC_BE, CC_A = CC_NBE, + CC_PE = CC_P, CC_PO = CC_NP, CC_NGE = CC_L, CC_GE = CC_NL, + CC_NG = CC_LE, CC_G = CC_NLE +} x86CC; + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_trace.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_trace.c new file mode 100644 index 000000000..e51ec5467 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_trace.c @@ -0,0 +1,816 @@ +/* +** Trace management. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_trace_c +#define LUA_CORE + +#include "lj_obj.h" + +#if LJ_HASJIT + +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_debug.h" +#include "lj_str.h" +#include "lj_frame.h" +#include "lj_state.h" +#include "lj_bc.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_iropt.h" +#include "lj_mcode.h" +#include "lj_trace.h" +#include "lj_snap.h" +#include "lj_gdbjit.h" +#include "lj_record.h" +#include "lj_asm.h" +#include "lj_dispatch.h" +#include "lj_vm.h" +#include "lj_vmevent.h" +#include "lj_target.h" + +/* -- Error handling ------------------------------------------------------ */ + +/* Synchronous abort with error message. */ +void lj_trace_err(jit_State *J, TraceError e) +{ + setnilV(&J->errinfo); /* No error info. */ + setintV(J->L->top++, (int32_t)e); + lj_err_throw(J->L, LUA_ERRRUN); +} + +/* Synchronous abort with error message and error info. */ +void lj_trace_err_info(jit_State *J, TraceError e) +{ + setintV(J->L->top++, (int32_t)e); + lj_err_throw(J->L, LUA_ERRRUN); +} + +/* -- Trace management ---------------------------------------------------- */ + +/* The current trace is first assembled in J->cur. The variable length +** arrays point to shared, growable buffers (J->irbuf etc.). When trace +** recording ends successfully, the current trace and its data structures +** are copied to a new (compact) GCtrace object. +*/ + +/* Find a free trace number. */ +static TraceNo trace_findfree(jit_State *J) +{ + MSize osz, lim; + if (J->freetrace == 0) + J->freetrace = 1; + for (; J->freetrace < J->sizetrace; J->freetrace++) + if (traceref(J, J->freetrace) == NULL) + return J->freetrace++; + /* Need to grow trace array. */ + lim = (MSize)J->param[JIT_P_maxtrace] + 1; + if (lim < 2) lim = 2; else if (lim > 65535) lim = 65535; + osz = J->sizetrace; + if (osz >= lim) + return 0; /* Too many traces. */ + lj_mem_growvec(J->L, J->trace, J->sizetrace, lim, GCRef); + for (; osz < J->sizetrace; osz++) + setgcrefnull(J->trace[osz]); + return J->freetrace; +} + +#define TRACE_APPENDVEC(field, szfield, tp) \ + T->field = (tp *)p; \ + memcpy(p, J->cur.field, J->cur.szfield*sizeof(tp)); \ + p += J->cur.szfield*sizeof(tp); + +#ifdef LUAJIT_USE_PERFTOOLS +/* +** Create symbol table of JIT-compiled code. For use with Linux perf tools. +** Example usage: +** perf record -f -e cycles luajit test.lua +** perf report -s symbol +** rm perf.data /tmp/perf-*.map +*/ +#include +#include + +static void perftools_addtrace(GCtrace *T) +{ + static FILE *fp; + GCproto *pt = &gcref(T->startpt)->pt; + const BCIns *startpc = mref(T->startpc, const BCIns); + const char *name = proto_chunknamestr(pt); + BCLine lineno; + if (name[0] == '@' || name[0] == '=') + name++; + else + name = "(string)"; + lua_assert(startpc >= proto_bc(pt) && startpc < proto_bc(pt) + pt->sizebc); + lineno = lj_debug_line(pt, proto_bcpos(pt, startpc)); + if (!fp) { + char fname[40]; + sprintf(fname, "/tmp/perf-%d.map", getpid()); + if (!(fp = fopen(fname, "w"))) return; + setlinebuf(fp); + } + fprintf(fp, "%lx %x TRACE_%d::%s:%u\n", + (long)T->mcode, T->szmcode, T->traceno, name, lineno); +} +#endif + +/* Save current trace by copying and compacting it. */ +static void trace_save(jit_State *J) +{ + size_t sztr = ((sizeof(GCtrace)+7)&~7); + size_t szins = (J->cur.nins-J->cur.nk)*sizeof(IRIns); + size_t sz = sztr + szins + + J->cur.nsnap*sizeof(SnapShot) + + J->cur.nsnapmap*sizeof(SnapEntry); + GCtrace *T = lj_mem_newt(J->L, (MSize)sz, GCtrace); + char *p = (char *)T + sztr; + memcpy(T, &J->cur, sizeof(GCtrace)); + setgcrefr(T->nextgc, J2G(J)->gc.root); + setgcrefp(J2G(J)->gc.root, T); + newwhite(J2G(J), T); + T->gct = ~LJ_TTRACE; + T->ir = (IRIns *)p - J->cur.nk; + memcpy(p, J->cur.ir+J->cur.nk, szins); + p += szins; + TRACE_APPENDVEC(snap, nsnap, SnapShot) + TRACE_APPENDVEC(snapmap, nsnapmap, SnapEntry) + J->cur.traceno = 0; + setgcrefp(J->trace[T->traceno], T); + lj_gc_barriertrace(J2G(J), T->traceno); + lj_gdbjit_addtrace(J, T); +#ifdef LUAJIT_USE_PERFTOOLS + perftools_addtrace(T); +#endif +} + +void LJ_FASTCALL lj_trace_free(global_State *g, GCtrace *T) +{ + jit_State *J = G2J(g); + if (T->traceno) { + lj_gdbjit_deltrace(J, T); + if (T->traceno < J->freetrace) + J->freetrace = T->traceno; + setgcrefnull(J->trace[T->traceno]); + } + lj_mem_free(g, T, + ((sizeof(GCtrace)+7)&~7) + (T->nins-T->nk)*sizeof(IRIns) + + T->nsnap*sizeof(SnapShot) + T->nsnapmap*sizeof(SnapEntry)); +} + +/* Re-enable compiling a prototype by unpatching any modified bytecode. */ +void lj_trace_reenableproto(GCproto *pt) +{ + if ((pt->flags & PROTO_ILOOP)) { + BCIns *bc = proto_bc(pt); + BCPos i, sizebc = pt->sizebc;; + pt->flags &= ~PROTO_ILOOP; + if (bc_op(bc[0]) == BC_IFUNCF) + setbc_op(&bc[0], BC_FUNCF); + for (i = 1; i < sizebc; i++) { + BCOp op = bc_op(bc[i]); + if (op == BC_IFORL || op == BC_IITERL || op == BC_ILOOP) + setbc_op(&bc[i], (int)op+(int)BC_LOOP-(int)BC_ILOOP); + } + } +} + +/* Unpatch the bytecode modified by a root trace. */ +static void trace_unpatch(jit_State *J, GCtrace *T) +{ + BCOp op = bc_op(T->startins); + BCIns *pc = mref(T->startpc, BCIns); + UNUSED(J); + if (op == BC_JMP) + return; /* No need to unpatch branches in parent traces (yet). */ + switch (bc_op(*pc)) { + case BC_JFORL: + lua_assert(traceref(J, bc_d(*pc)) == T); + *pc = T->startins; + pc += bc_j(T->startins); + lua_assert(bc_op(*pc) == BC_JFORI); + setbc_op(pc, BC_FORI); + break; + case BC_JITERL: + case BC_JLOOP: + lua_assert(op == BC_ITERL || op == BC_LOOP || bc_isret(op)); + *pc = T->startins; + break; + case BC_JMP: + lua_assert(op == BC_ITERL); + pc += bc_j(*pc)+2; + if (bc_op(*pc) == BC_JITERL) { + lua_assert(traceref(J, bc_d(*pc)) == T); + *pc = T->startins; + } + break; + case BC_JFUNCF: + lua_assert(op == BC_FUNCF); + *pc = T->startins; + break; + default: /* Already unpatched. */ + break; + } +} + +/* Flush a root trace. */ +static void trace_flushroot(jit_State *J, GCtrace *T) +{ + GCproto *pt = &gcref(T->startpt)->pt; + lua_assert(T->root == 0 && pt != NULL); + /* First unpatch any modified bytecode. */ + trace_unpatch(J, T); + /* Unlink root trace from chain anchored in prototype. */ + if (pt->trace == T->traceno) { /* Trace is first in chain. Easy. */ + pt->trace = T->nextroot; + } else if (pt->trace) { /* Otherwise search in chain of root traces. */ + GCtrace *T2 = traceref(J, pt->trace); + if (T2) { + for (; T2->nextroot; T2 = traceref(J, T2->nextroot)) + if (T2->nextroot == T->traceno) { + T2->nextroot = T->nextroot; /* Unlink from chain. */ + break; + } + } + } +} + +/* Flush a trace. Only root traces are considered. */ +void lj_trace_flush(jit_State *J, TraceNo traceno) +{ + if (traceno > 0 && traceno < J->sizetrace) { + GCtrace *T = traceref(J, traceno); + if (T && T->root == 0) + trace_flushroot(J, T); + } +} + +/* Flush all traces associated with a prototype. */ +void lj_trace_flushproto(global_State *g, GCproto *pt) +{ + while (pt->trace != 0) + trace_flushroot(G2J(g), traceref(G2J(g), pt->trace)); +} + +/* Flush all traces. */ +int lj_trace_flushall(lua_State *L) +{ + jit_State *J = L2J(L); + ptrdiff_t i; + if ((J2G(J)->hookmask & HOOK_GC)) + return 1; + for (i = (ptrdiff_t)J->sizetrace-1; i > 0; i--) { + GCtrace *T = traceref(J, i); + if (T) { + if (T->root == 0) + trace_flushroot(J, T); + lj_gdbjit_deltrace(J, T); + T->traceno = 0; + setgcrefnull(J->trace[i]); + } + } + J->cur.traceno = 0; + J->freetrace = 0; + /* Clear penalty cache. */ + memset(J->penalty, 0, sizeof(J->penalty)); + /* Free the whole machine code and invalidate all exit stub groups. */ + lj_mcode_free(J); + memset(J->exitstubgroup, 0, sizeof(J->exitstubgroup)); + lj_vmevent_send(L, TRACE, + setstrV(L, L->top++, lj_str_newlit(L, "flush")); + ); + return 0; +} + +/* Initialize JIT compiler state. */ +void lj_trace_initstate(global_State *g) +{ + jit_State *J = G2J(g); + TValue *tv; + /* Initialize SIMD constants. */ + tv = LJ_KSIMD(J, LJ_KSIMD_ABS); + tv[0].u64 = U64x(7fffffff,ffffffff); + tv[1].u64 = U64x(7fffffff,ffffffff); + tv = LJ_KSIMD(J, LJ_KSIMD_NEG); + tv[0].u64 = U64x(80000000,00000000); + tv[1].u64 = U64x(80000000,00000000); +} + +/* Free everything associated with the JIT compiler state. */ +void lj_trace_freestate(global_State *g) +{ + jit_State *J = G2J(g); +#ifdef LUA_USE_ASSERT + { /* This assumes all traces have already been freed. */ + ptrdiff_t i; + for (i = 1; i < (ptrdiff_t)J->sizetrace; i++) + lua_assert(i == (ptrdiff_t)J->cur.traceno || traceref(J, i) == NULL); + } +#endif + lj_mcode_free(J); + lj_ir_k64_freeall(J); + lj_mem_freevec(g, J->snapmapbuf, J->sizesnapmap, SnapEntry); + lj_mem_freevec(g, J->snapbuf, J->sizesnap, SnapShot); + lj_mem_freevec(g, J->irbuf + J->irbotlim, J->irtoplim - J->irbotlim, IRIns); + lj_mem_freevec(g, J->trace, J->sizetrace, GCRef); +} + +/* -- Penalties and blacklisting ------------------------------------------ */ + +/* Blacklist a bytecode instruction. */ +static void blacklist_pc(GCproto *pt, BCIns *pc) +{ + setbc_op(pc, (int)bc_op(*pc)+(int)BC_ILOOP-(int)BC_LOOP); + pt->flags |= PROTO_ILOOP; +} + +/* Penalize a bytecode instruction. */ +static void penalty_pc(jit_State *J, GCproto *pt, BCIns *pc, TraceError e) +{ + uint32_t i, val = PENALTY_MIN; + for (i = 0; i < PENALTY_SLOTS; i++) + if (mref(J->penalty[i].pc, const BCIns) == pc) { /* Cache slot found? */ + /* First try to bump its hotcount several times. */ + val = ((uint32_t)J->penalty[i].val << 1) + + LJ_PRNG_BITS(J, PENALTY_RNDBITS); + if (val > PENALTY_MAX) { + blacklist_pc(pt, pc); /* Blacklist it, if that didn't help. */ + return; + } + goto setpenalty; + } + /* Assign a new penalty cache slot. */ + i = J->penaltyslot; + J->penaltyslot = (J->penaltyslot + 1) & (PENALTY_SLOTS-1); + setmref(J->penalty[i].pc, pc); +setpenalty: + J->penalty[i].val = (uint16_t)val; + J->penalty[i].reason = e; + hotcount_set(J2GG(J), pc+1, val); +} + +/* -- Trace compiler state machine ---------------------------------------- */ + +/* Start tracing. */ +static void trace_start(jit_State *J) +{ + lua_State *L; + TraceNo traceno; + + if ((J->pt->flags & PROTO_NOJIT)) { /* JIT disabled for this proto? */ + if (J->parent == 0) { + /* Lazy bytecode patching to disable hotcount events. */ + lua_assert(bc_op(*J->pc) == BC_FORL || bc_op(*J->pc) == BC_ITERL || + bc_op(*J->pc) == BC_LOOP || bc_op(*J->pc) == BC_FUNCF); + setbc_op(J->pc, (int)bc_op(*J->pc)+(int)BC_ILOOP-(int)BC_LOOP); + J->pt->flags |= PROTO_ILOOP; + } + J->state = LJ_TRACE_IDLE; /* Silently ignored. */ + return; + } + + /* Get a new trace number. */ + traceno = trace_findfree(J); + if (LJ_UNLIKELY(traceno == 0)) { /* No free trace? */ + lua_assert((J2G(J)->hookmask & HOOK_GC) == 0); + lj_trace_flushall(J->L); + J->state = LJ_TRACE_IDLE; /* Silently ignored. */ + return; + } + setgcrefp(J->trace[traceno], &J->cur); + + /* Setup enough of the current trace to be able to send the vmevent. */ + memset(&J->cur, 0, sizeof(GCtrace)); + J->cur.traceno = traceno; + J->cur.nins = J->cur.nk = REF_BASE; + J->cur.ir = J->irbuf; + J->cur.snap = J->snapbuf; + J->cur.snapmap = J->snapmapbuf; + J->mergesnap = 0; + J->needsnap = 0; + J->bcskip = 0; + J->guardemit.irt = 0; + J->postproc = LJ_POST_NONE; + lj_resetsplit(J); + setgcref(J->cur.startpt, obj2gco(J->pt)); + + L = J->L; + lj_vmevent_send(L, TRACE, + setstrV(L, L->top++, lj_str_newlit(L, "start")); + setintV(L->top++, traceno); + setfuncV(L, L->top++, J->fn); + setintV(L->top++, proto_bcpos(J->pt, J->pc)); + if (J->parent) { + setintV(L->top++, J->parent); + setintV(L->top++, J->exitno); + } + ); + lj_record_setup(J); +} + +/* Stop tracing. */ +static void trace_stop(jit_State *J) +{ + BCIns *pc = mref(J->cur.startpc, BCIns); + BCOp op = bc_op(J->cur.startins); + GCproto *pt = &gcref(J->cur.startpt)->pt; + TraceNo traceno = J->cur.traceno; + lua_State *L; + + switch (op) { + case BC_FORL: + setbc_op(pc+bc_j(J->cur.startins), BC_JFORI); /* Patch FORI, too. */ + /* fallthrough */ + case BC_LOOP: + case BC_ITERL: + case BC_FUNCF: + /* Patch bytecode of starting instruction in root trace. */ + setbc_op(pc, (int)op+(int)BC_JLOOP-(int)BC_LOOP); + setbc_d(pc, traceno); + addroot: + /* Add to root trace chain in prototype. */ + J->cur.nextroot = pt->trace; + pt->trace = (TraceNo1)traceno; + break; + case BC_RET: + case BC_RET0: + case BC_RET1: + *pc = BCINS_AD(BC_JLOOP, J->cur.snap[0].nslots, traceno); + goto addroot; + case BC_JMP: + /* Patch exit branch in parent to side trace entry. */ + lua_assert(J->parent != 0 && J->cur.root != 0); + lj_asm_patchexit(J, traceref(J, J->parent), J->exitno, J->cur.mcode); + /* Avoid compiling a side trace twice (stack resizing uses parent exit). */ + traceref(J, J->parent)->snap[J->exitno].count = SNAPCOUNT_DONE; + /* Add to side trace chain in root trace. */ + { + GCtrace *root = traceref(J, J->cur.root); + root->nchild++; + J->cur.nextside = root->nextside; + root->nextside = (TraceNo1)traceno; + } + break; + default: + lua_assert(0); + break; + } + + /* Commit new mcode only after all patching is done. */ + lj_mcode_commit(J, J->cur.mcode); + J->postproc = LJ_POST_NONE; + trace_save(J); + + L = J->L; + lj_vmevent_send(L, TRACE, + setstrV(L, L->top++, lj_str_newlit(L, "stop")); + setintV(L->top++, traceno); + ); +} + +/* Start a new root trace for down-recursion. */ +static int trace_downrec(jit_State *J) +{ + /* Restart recording at the return instruction. */ + lua_assert(J->pt != NULL); + lua_assert(bc_isret(bc_op(*J->pc))); + if (bc_op(*J->pc) == BC_RETM) + return 0; /* NYI: down-recursion with RETM. */ + J->parent = 0; + J->exitno = 0; + J->state = LJ_TRACE_RECORD; + trace_start(J); + return 1; +} + +/* Abort tracing. */ +static int trace_abort(jit_State *J) +{ + lua_State *L = J->L; + TraceError e = LJ_TRERR_RECERR; + TraceNo traceno; + + J->postproc = LJ_POST_NONE; + lj_mcode_abort(J); + if (tvisnumber(L->top-1)) + e = (TraceError)numberVint(L->top-1); + if (e == LJ_TRERR_MCODELM) { + L->top--; /* Remove error object */ + J->state = LJ_TRACE_ASM; + return 1; /* Retry ASM with new MCode area. */ + } + /* Penalize or blacklist starting bytecode instruction. */ + if (J->parent == 0 && !bc_isret(bc_op(J->cur.startins))) + penalty_pc(J, &gcref(J->cur.startpt)->pt, mref(J->cur.startpc, BCIns), e); + + /* Is there anything to abort? */ + traceno = J->cur.traceno; + if (traceno) { + ptrdiff_t errobj = savestack(L, L->top-1); /* Stack may be resized. */ + J->cur.link = 0; + J->cur.linktype = LJ_TRLINK_NONE; + lj_vmevent_send(L, TRACE, + TValue *frame; + const BCIns *pc; + GCfunc *fn; + setstrV(L, L->top++, lj_str_newlit(L, "abort")); + setintV(L->top++, traceno); + /* Find original Lua function call to generate a better error message. */ + frame = J->L->base-1; + pc = J->pc; + while (!isluafunc(frame_func(frame))) { + pc = (frame_iscont(frame) ? frame_contpc(frame) : frame_pc(frame)) - 1; + frame = frame_prev(frame); + } + fn = frame_func(frame); + setfuncV(L, L->top++, fn); + setintV(L->top++, proto_bcpos(funcproto(fn), pc)); + copyTV(L, L->top++, restorestack(L, errobj)); + copyTV(L, L->top++, &J->errinfo); + ); + /* Drop aborted trace after the vmevent (which may still access it). */ + setgcrefnull(J->trace[traceno]); + if (traceno < J->freetrace) + J->freetrace = traceno; + J->cur.traceno = 0; + } + L->top--; /* Remove error object */ + if (e == LJ_TRERR_DOWNREC) + return trace_downrec(J); + else if (e == LJ_TRERR_MCODEAL) + lj_trace_flushall(L); + return 0; +} + +/* Perform pending re-patch of a bytecode instruction. */ +static LJ_AINLINE void trace_pendpatch(jit_State *J, int force) +{ + if (LJ_UNLIKELY(J->patchpc)) { + if (force || J->bcskip == 0) { + *J->patchpc = J->patchins; + J->patchpc = NULL; + } else { + J->bcskip = 0; + } + } +} + +/* State machine for the trace compiler. Protected callback. */ +static TValue *trace_state(lua_State *L, lua_CFunction dummy, void *ud) +{ + jit_State *J = (jit_State *)ud; + UNUSED(dummy); + do { + retry: + switch (J->state) { + case LJ_TRACE_START: + J->state = LJ_TRACE_RECORD; /* trace_start() may change state. */ + trace_start(J); + lj_dispatch_update(J2G(J)); + break; + + case LJ_TRACE_RECORD: + trace_pendpatch(J, 0); + setvmstate(J2G(J), RECORD); + lj_vmevent_send_(L, RECORD, + /* Save/restore tmptv state for trace recorder. */ + TValue savetv = J2G(J)->tmptv; + TValue savetv2 = J2G(J)->tmptv2; + setintV(L->top++, J->cur.traceno); + setfuncV(L, L->top++, J->fn); + setintV(L->top++, J->pt ? (int32_t)proto_bcpos(J->pt, J->pc) : -1); + setintV(L->top++, J->framedepth); + , + J2G(J)->tmptv = savetv; + J2G(J)->tmptv2 = savetv2; + ); + lj_record_ins(J); + break; + + case LJ_TRACE_END: + trace_pendpatch(J, 1); + J->loopref = 0; + if ((J->flags & JIT_F_OPT_LOOP) && + J->cur.link == J->cur.traceno && J->framedepth + J->retdepth == 0) { + setvmstate(J2G(J), OPT); + lj_opt_dce(J); + if (lj_opt_loop(J)) { /* Loop optimization failed? */ + J->cur.link = 0; + J->cur.linktype = LJ_TRLINK_NONE; + J->loopref = J->cur.nins; + J->state = LJ_TRACE_RECORD; /* Try to continue recording. */ + break; + } + J->loopref = J->chain[IR_LOOP]; /* Needed by assembler. */ + } + lj_opt_split(J); + lj_opt_sink(J); + if (!J->loopref) J->cur.snap[J->cur.nsnap-1].count = SNAPCOUNT_DONE; + J->state = LJ_TRACE_ASM; + break; + + case LJ_TRACE_ASM: + setvmstate(J2G(J), ASM); + lj_asm_trace(J, &J->cur); + trace_stop(J); + setvmstate(J2G(J), INTERP); + J->state = LJ_TRACE_IDLE; + lj_dispatch_update(J2G(J)); + return NULL; + + default: /* Trace aborted asynchronously. */ + setintV(L->top++, (int32_t)LJ_TRERR_RECERR); + /* fallthrough */ + case LJ_TRACE_ERR: + trace_pendpatch(J, 1); + if (trace_abort(J)) + goto retry; + setvmstate(J2G(J), INTERP); + J->state = LJ_TRACE_IDLE; + lj_dispatch_update(J2G(J)); + return NULL; + } + } while (J->state > LJ_TRACE_RECORD); + return NULL; +} + +/* -- Event handling ------------------------------------------------------ */ + +/* A bytecode instruction is about to be executed. Record it. */ +void lj_trace_ins(jit_State *J, const BCIns *pc) +{ + /* Note: J->L must already be set. pc is the true bytecode PC here. */ + J->pc = pc; + J->fn = curr_func(J->L); + J->pt = isluafunc(J->fn) ? funcproto(J->fn) : NULL; + while (lj_vm_cpcall(J->L, NULL, (void *)J, trace_state) != 0) + J->state = LJ_TRACE_ERR; +} + +/* A hotcount triggered. Start recording a root trace. */ +void LJ_FASTCALL lj_trace_hot(jit_State *J, const BCIns *pc) +{ + /* Note: pc is the interpreter bytecode PC here. It's offset by 1. */ + ERRNO_SAVE + /* Reset hotcount. */ + hotcount_set(J2GG(J), pc, J->param[JIT_P_hotloop]*HOTCOUNT_LOOP); + /* Only start a new trace if not recording or inside __gc call or vmevent. */ + if (J->state == LJ_TRACE_IDLE && + !(J2G(J)->hookmask & (HOOK_GC|HOOK_VMEVENT))) { + J->parent = 0; /* Root trace. */ + J->exitno = 0; + J->state = LJ_TRACE_START; + lj_trace_ins(J, pc-1); + } + ERRNO_RESTORE +} + +/* Check for a hot side exit. If yes, start recording a side trace. */ +static void trace_hotside(jit_State *J, const BCIns *pc) +{ + SnapShot *snap = &traceref(J, J->parent)->snap[J->exitno]; + if (!(J2G(J)->hookmask & (HOOK_GC|HOOK_VMEVENT)) && + snap->count != SNAPCOUNT_DONE && + ++snap->count >= J->param[JIT_P_hotexit]) { + lua_assert(J->state == LJ_TRACE_IDLE); + /* J->parent is non-zero for a side trace. */ + J->state = LJ_TRACE_START; + lj_trace_ins(J, pc); + } +} + +/* Tiny struct to pass data to protected call. */ +typedef struct ExitDataCP { + jit_State *J; + void *exptr; /* Pointer to exit state. */ + const BCIns *pc; /* Restart interpreter at this PC. */ +} ExitDataCP; + +/* Need to protect lj_snap_restore because it may throw. */ +static TValue *trace_exit_cp(lua_State *L, lua_CFunction dummy, void *ud) +{ + ExitDataCP *exd = (ExitDataCP *)ud; + cframe_errfunc(L->cframe) = -1; /* Inherit error function. */ + exd->pc = lj_snap_restore(exd->J, exd->exptr); + UNUSED(dummy); + return NULL; +} + +#ifndef LUAJIT_DISABLE_VMEVENT +/* Push all registers from exit state. */ +static void trace_exit_regs(lua_State *L, ExitState *ex) +{ + int32_t i; + setintV(L->top++, RID_NUM_GPR); + setintV(L->top++, RID_NUM_FPR); + for (i = 0; i < RID_NUM_GPR; i++) { + if (sizeof(ex->gpr[i]) == sizeof(int32_t)) + setintV(L->top++, (int32_t)ex->gpr[i]); + else + setnumV(L->top++, (lua_Number)ex->gpr[i]); + } +#if !LJ_SOFTFP + for (i = 0; i < RID_NUM_FPR; i++) { + setnumV(L->top, ex->fpr[i]); + if (LJ_UNLIKELY(tvisnan(L->top))) + setnanV(L->top); + L->top++; + } +#endif +} +#endif + +#ifdef EXITSTATE_PCREG +/* Determine trace number from pc of exit instruction. */ +static TraceNo trace_exit_find(jit_State *J, MCode *pc) +{ + TraceNo traceno; + for (traceno = 1; traceno < J->sizetrace; traceno++) { + GCtrace *T = traceref(J, traceno); + if (T && pc >= T->mcode && pc < (MCode *)((char *)T->mcode + T->szmcode)) + return traceno; + } + lua_assert(0); + return 0; +} +#endif + +/* A trace exited. Restore interpreter state. */ +int LJ_FASTCALL lj_trace_exit(jit_State *J, void *exptr) +{ + ERRNO_SAVE + lua_State *L = J->L; + ExitState *ex = (ExitState *)exptr; + ExitDataCP exd; + int errcode; + const BCIns *pc; + void *cf; + GCtrace *T; +#ifdef EXITSTATE_PCREG + J->parent = trace_exit_find(J, (MCode *)(intptr_t)ex->gpr[EXITSTATE_PCREG]); +#endif + T = traceref(J, J->parent); UNUSED(T); +#ifdef EXITSTATE_CHECKEXIT + if (J->exitno == T->nsnap) { /* Treat stack check like a parent exit. */ + lua_assert(T->root != 0); + J->exitno = T->ir[REF_BASE].op2; + J->parent = T->ir[REF_BASE].op1; + T = traceref(J, J->parent); + } +#endif + lua_assert(T != NULL && J->exitno < T->nsnap); + exd.J = J; + exd.exptr = exptr; + errcode = lj_vm_cpcall(L, NULL, &exd, trace_exit_cp); + if (errcode) + return -errcode; /* Return negated error code. */ + + lj_vmevent_send(L, TEXIT, + lj_state_checkstack(L, 4+RID_NUM_GPR+RID_NUM_FPR+LUA_MINSTACK); + setintV(L->top++, J->parent); + setintV(L->top++, J->exitno); + trace_exit_regs(L, ex); + ); + + pc = exd.pc; + cf = cframe_raw(L->cframe); + setcframe_pc(cf, pc); + if (G(L)->gc.state == GCSatomic || G(L)->gc.state == GCSfinalize) { + if (!(G(L)->hookmask & HOOK_GC)) + lj_gc_step(L); /* Exited because of GC: drive GC forward. */ + } else { + trace_hotside(J, pc); + } + if (bc_op(*pc) == BC_JLOOP) { + BCIns *retpc = &traceref(J, bc_d(*pc))->startins; + if (bc_isret(bc_op(*retpc))) { + if (J->state == LJ_TRACE_RECORD) { + J->patchins = *pc; + J->patchpc = (BCIns *)pc; + *J->patchpc = *retpc; + J->bcskip = 1; + } else { + pc = retpc; + setcframe_pc(cf, pc); + } + } + } + /* Return MULTRES or 0. */ + ERRNO_RESTORE + switch (bc_op(*pc)) { + case BC_CALLM: case BC_CALLMT: + return (int)((BCReg)(L->top - L->base) - bc_a(*pc) - bc_c(*pc)); + case BC_RETM: + return (int)((BCReg)(L->top - L->base) + 1 - bc_a(*pc) - bc_d(*pc)); + case BC_TSETM: + return (int)((BCReg)(L->top - L->base) + 1 - bc_a(*pc)); + default: + if (bc_op(*pc) >= BC_FUNCF) + return (int)((BCReg)(L->top - L->base) + 1); + return 0; + } +} + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_trace.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_trace.h new file mode 100644 index 000000000..4fbe5cf25 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_trace.h @@ -0,0 +1,53 @@ +/* +** Trace management. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_TRACE_H +#define _LJ_TRACE_H + +#include "lj_obj.h" + +#if LJ_HASJIT +#include "lj_jit.h" +#include "lj_dispatch.h" + +/* Trace errors. */ +typedef enum { +#define TREDEF(name, msg) LJ_TRERR_##name, +#include "lj_traceerr.h" + LJ_TRERR__MAX +} TraceError; + +LJ_FUNC_NORET void lj_trace_err(jit_State *J, TraceError e); +LJ_FUNC_NORET void lj_trace_err_info(jit_State *J, TraceError e); + +/* Trace management. */ +LJ_FUNC void LJ_FASTCALL lj_trace_free(global_State *g, GCtrace *T); +LJ_FUNC void lj_trace_reenableproto(GCproto *pt); +LJ_FUNC void lj_trace_flushproto(global_State *g, GCproto *pt); +LJ_FUNC void lj_trace_flush(jit_State *J, TraceNo traceno); +LJ_FUNC int lj_trace_flushall(lua_State *L); +LJ_FUNC void lj_trace_initstate(global_State *g); +LJ_FUNC void lj_trace_freestate(global_State *g); + +/* Event handling. */ +LJ_FUNC void lj_trace_ins(jit_State *J, const BCIns *pc); +LJ_FUNCA void LJ_FASTCALL lj_trace_hot(jit_State *J, const BCIns *pc); +LJ_FUNCA int LJ_FASTCALL lj_trace_exit(jit_State *J, void *exptr); + +/* Signal asynchronous abort of trace or end of trace. */ +#define lj_trace_abort(g) (G2J(g)->state &= ~LJ_TRACE_ACTIVE) +#define lj_trace_end(J) (J->state = LJ_TRACE_END) + +#else + +#define lj_trace_flushall(L) (UNUSED(L), 0) +#define lj_trace_initstate(g) UNUSED(g) +#define lj_trace_freestate(g) UNUSED(g) +#define lj_trace_abort(g) UNUSED(g) +#define lj_trace_end(J) UNUSED(J) + +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_traceerr.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_traceerr.h new file mode 100644 index 000000000..9bef117ab --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_traceerr.h @@ -0,0 +1,61 @@ +/* +** Trace compiler error messages. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* This file may be included multiple times with different TREDEF macros. */ + +/* Recording. */ +TREDEF(RECERR, "error thrown or hook called during recording") +TREDEF(TRACEOV, "trace too long") +TREDEF(STACKOV, "trace too deep") +TREDEF(SNAPOV, "too many snapshots") +TREDEF(BLACKL, "blacklisted") +TREDEF(NYIBC, "NYI: bytecode %d") + +/* Recording loop ops. */ +TREDEF(LLEAVE, "leaving loop in root trace") +TREDEF(LINNER, "inner loop in root trace") +TREDEF(LUNROLL, "loop unroll limit reached") + +/* Recording calls/returns. */ +TREDEF(BADTYPE, "bad argument type") +TREDEF(CJITOFF, "JIT compilation disabled for function") +TREDEF(CUNROLL, "call unroll limit reached") +TREDEF(DOWNREC, "down-recursion, restarting") +TREDEF(NYICF, "NYI: C function %p") +TREDEF(NYIFF, "NYI: FastFunc %s") +TREDEF(NYIFFU, "NYI: unsupported variant of FastFunc %s") +TREDEF(NYIRETL, "NYI: return to lower frame") + +/* Recording indexed load/store. */ +TREDEF(STORENN, "store with nil or NaN key") +TREDEF(NOMM, "missing metamethod") +TREDEF(IDXLOOP, "looping index lookup") +TREDEF(NYITMIX, "NYI: mixed sparse/dense table") + +/* Recording C data operations. */ +TREDEF(NOCACHE, "symbol not in cache") +TREDEF(NYICONV, "NYI: unsupported C type conversion") +TREDEF(NYICALL, "NYI: unsupported C function type") + +/* Optimizations. */ +TREDEF(GFAIL, "guard would always fail") +TREDEF(PHIOV, "too many PHIs") +TREDEF(TYPEINS, "persistent type instability") + +/* Assembler. */ +TREDEF(MCODEAL, "failed to allocate mcode memory") +TREDEF(MCODEOV, "machine code too long") +TREDEF(MCODELM, "hit mcode limit (retrying)") +TREDEF(SPILLOV, "too many spill slots") +TREDEF(BADRA, "inconsistent register allocation") +TREDEF(NYIIR, "NYI: cannot assemble IR instruction %d") +TREDEF(NYIPHI, "NYI: PHI shuffling too complex") +TREDEF(NYICOAL, "NYI: register coalescing too complex") + +#undef TREDEF + +/* Detecting unused error messages: + awk -F, '/^TREDEF/ { gsub(/TREDEF./, ""); printf "grep -q LJ_TRERR_%s *.[ch] || echo %s\n", $1, $1}' lj_traceerr.h | sh +*/ diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_udata.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_udata.c new file mode 100644 index 000000000..d401a3d8e --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_udata.c @@ -0,0 +1,34 @@ +/* +** Userdata handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_udata_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_udata.h" + +GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env) +{ + GCudata *ud = lj_mem_newt(L, sizeof(GCudata) + sz, GCudata); + global_State *g = G(L); + newwhite(g, ud); /* Not finalized. */ + ud->gct = ~LJ_TUDATA; + ud->udtype = UDTYPE_USERDATA; + ud->len = sz; + /* NOBARRIER: The GCudata is new (marked white). */ + setgcrefnull(ud->metatable); + setgcref(ud->env, obj2gco(env)); + /* Chain to userdata list (after main thread). */ + setgcrefr(ud->nextgc, mainthread(g)->nextgc); + setgcref(mainthread(g)->nextgc, obj2gco(ud)); + return ud; +} + +void LJ_FASTCALL lj_udata_free(global_State *g, GCudata *ud) +{ + lj_mem_free(g, ud, sizeudata(ud)); +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_udata.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_udata.h new file mode 100644 index 000000000..676e970f4 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_udata.h @@ -0,0 +1,14 @@ +/* +** Userdata handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_UDATA_H +#define _LJ_UDATA_H + +#include "lj_obj.h" + +LJ_FUNC GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env); +LJ_FUNC void LJ_FASTCALL lj_udata_free(global_State *g, GCudata *ud); + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_vm.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_vm.h new file mode 100644 index 000000000..036cabc57 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_vm.h @@ -0,0 +1,116 @@ +/* +** Assembler VM interface definitions. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_VM_H +#define _LJ_VM_H + +#include "lj_obj.h" + +/* Entry points for ASM parts of VM. */ +LJ_ASMF void lj_vm_call(lua_State *L, TValue *base, int nres1); +LJ_ASMF int lj_vm_pcall(lua_State *L, TValue *base, int nres1, ptrdiff_t ef); +typedef TValue *(*lua_CPFunction)(lua_State *L, lua_CFunction func, void *ud); +LJ_ASMF int lj_vm_cpcall(lua_State *L, lua_CFunction func, void *ud, + lua_CPFunction cp); +LJ_ASMF int lj_vm_resume(lua_State *L, TValue *base, int nres1, ptrdiff_t ef); +LJ_ASMF_NORET void LJ_FASTCALL lj_vm_unwind_c(void *cframe, int errcode); +LJ_ASMF_NORET void LJ_FASTCALL lj_vm_unwind_ff(void *cframe); +LJ_ASMF void lj_vm_unwind_c_eh(void); +LJ_ASMF void lj_vm_unwind_ff_eh(void); +#if LJ_TARGET_X86ORX64 +LJ_ASMF void lj_vm_unwind_rethrow(void); +#endif + +/* Miscellaneous functions. */ +#if LJ_TARGET_X86ORX64 +LJ_ASMF int lj_vm_cpuid(uint32_t f, uint32_t res[4]); +#endif +#if LJ_TARGET_PPC +void lj_vm_cachesync(void *start, void *end); +#endif +LJ_ASMF double lj_vm_foldarith(double x, double y, int op); +#if LJ_HASJIT +LJ_ASMF double lj_vm_foldfpm(double x, int op); +#endif +#if !LJ_ARCH_HASFPU +/* Declared in lj_obj.h: LJ_ASMF int32_t lj_vm_tobit(double x); */ +#endif + +/* Dispatch targets for recording and hooks. */ +LJ_ASMF void lj_vm_record(void); +LJ_ASMF void lj_vm_inshook(void); +LJ_ASMF void lj_vm_rethook(void); +LJ_ASMF void lj_vm_callhook(void); + +/* Trace exit handling. */ +LJ_ASMF void lj_vm_exit_handler(void); +LJ_ASMF void lj_vm_exit_interp(void); + +/* Internal math helper functions. */ +#if LJ_TARGET_X86ORX64 || LJ_TARGET_PPC +#define lj_vm_floor floor +#define lj_vm_ceil ceil +#else +LJ_ASMF double lj_vm_floor(double); +LJ_ASMF double lj_vm_ceil(double); +#if LJ_TARGET_ARM +LJ_ASMF double lj_vm_floor_sf(double); +LJ_ASMF double lj_vm_ceil_sf(double); +#endif +#endif +#if defined(LUAJIT_NO_LOG2) || LJ_TARGET_X86ORX64 +LJ_ASMF double lj_vm_log2(double); +#else +#define lj_vm_log2 log2 +#endif + +#if LJ_HASJIT +#if LJ_TARGET_X86ORX64 +LJ_ASMF void lj_vm_floor_sse(void); +LJ_ASMF void lj_vm_ceil_sse(void); +LJ_ASMF void lj_vm_trunc_sse(void); +LJ_ASMF void lj_vm_exp_x87(void); +LJ_ASMF void lj_vm_exp2_x87(void); +LJ_ASMF void lj_vm_pow_sse(void); +LJ_ASMF void lj_vm_powi_sse(void); +#else +#if LJ_TARGET_PPC +#define lj_vm_trunc trunc +#else +LJ_ASMF double lj_vm_trunc(double); +#if LJ_TARGET_ARM +LJ_ASMF double lj_vm_trunc_sf(double); +#endif +#endif +LJ_ASMF double lj_vm_powi(double, int32_t); +#ifdef LUAJIT_NO_EXP2 +LJ_ASMF double lj_vm_exp2(double); +#else +#define lj_vm_exp2 exp2 +#endif +#endif +LJ_ASMF int32_t LJ_FASTCALL lj_vm_modi(int32_t, int32_t); +#if LJ_HASFFI +LJ_ASMF int lj_vm_errno(void); +#endif +#endif + +/* Continuations for metamethods. */ +LJ_ASMF void lj_cont_cat(void); /* Continue with concatenation. */ +LJ_ASMF void lj_cont_ra(void); /* Store result in RA from instruction. */ +LJ_ASMF void lj_cont_nop(void); /* Do nothing, just continue execution. */ +LJ_ASMF void lj_cont_condt(void); /* Branch if result is true. */ +LJ_ASMF void lj_cont_condf(void); /* Branch if result is false. */ +LJ_ASMF void lj_cont_hook(void); /* Continue from hook yield. */ + +enum { LJ_CONT_TAILCALL, LJ_CONT_FFI_CALLBACK }; /* Special continuations. */ + +/* Start of the ASM code. */ +LJ_ASMF char lj_vm_asm_begin[]; + +/* Bytecode offsets are relative to lj_vm_asm_begin. */ +#define makeasmfunc(ofs) ((ASMFunction)(lj_vm_asm_begin + (ofs))) + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_vmevent.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_vmevent.c new file mode 100644 index 000000000..81fe47d4d --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_vmevent.c @@ -0,0 +1,57 @@ +/* +** VM event handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#include + +#define lj_vmevent_c +#define LUA_CORE + +#include "lj_obj.h" +#include "lj_str.h" +#include "lj_tab.h" +#include "lj_state.h" +#include "lj_dispatch.h" +#include "lj_vm.h" +#include "lj_vmevent.h" + +ptrdiff_t lj_vmevent_prepare(lua_State *L, VMEvent ev) +{ + global_State *g = G(L); + GCstr *s = lj_str_newlit(L, LJ_VMEVENTS_REGKEY); + cTValue *tv = lj_tab_getstr(tabV(registry(L)), s); + if (tvistab(tv)) { + int hash = VMEVENT_HASH(ev); + tv = lj_tab_getint(tabV(tv), hash); + if (tv && tvisfunc(tv)) { + lj_state_checkstack(L, LUA_MINSTACK); + setfuncV(L, L->top++, funcV(tv)); + return savestack(L, L->top); + } + } + g->vmevmask &= ~VMEVENT_MASK(ev); /* No handler: cache this fact. */ + return 0; +} + +void lj_vmevent_call(lua_State *L, ptrdiff_t argbase) +{ + global_State *g = G(L); + uint8_t oldmask = g->vmevmask; + uint8_t oldh = hook_save(g); + int status; + g->vmevmask = 0; /* Disable all events. */ + hook_vmevent(g); + status = lj_vm_pcall(L, restorestack(L, argbase), 0+1, 0); + if (LJ_UNLIKELY(status)) { + /* Really shouldn't use stderr here, but where else to complain? */ + L->top--; + fputs("VM handler failed: ", stderr); + fputs(tvisstr(L->top) ? strVdata(L->top) : "?", stderr); + fputc('\n', stderr); + } + hook_restore(g, oldh); + if (g->vmevmask != VMEVENT_NOCACHE) + g->vmevmask = oldmask; /* Restore event mask, but not if not modified. */ +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_vmevent.h b/source/libs/luajit/LuaJIT-2.0.4/src/lj_vmevent.h new file mode 100644 index 000000000..231e00ecd --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_vmevent.h @@ -0,0 +1,59 @@ +/* +** VM event handling. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LJ_VMEVENT_H +#define _LJ_VMEVENT_H + +#include "lj_obj.h" + +/* Registry key for VM event handler table. */ +#define LJ_VMEVENTS_REGKEY "_VMEVENTS" +#define LJ_VMEVENTS_HSIZE 4 + +#define VMEVENT_MASK(ev) ((uint8_t)1 << ((int)(ev) & 7)) +#define VMEVENT_HASH(ev) ((int)(ev) & ~7) +#define VMEVENT_HASHIDX(h) ((int)(h) << 3) +#define VMEVENT_NOCACHE 255 + +#define VMEVENT_DEF(name, hash) \ + LJ_VMEVENT_##name##_, \ + LJ_VMEVENT_##name = ((LJ_VMEVENT_##name##_) & 7)|((hash) << 3) + +/* VM event IDs. */ +typedef enum { + VMEVENT_DEF(BC, 0x00003883), + VMEVENT_DEF(TRACE, 0xb2d91467), + VMEVENT_DEF(RECORD, 0x9284bf4f), + VMEVENT_DEF(TEXIT, 0xb29df2b0), + LJ_VMEVENT__MAX +} VMEvent; + +#ifdef LUAJIT_DISABLE_VMEVENT +#define lj_vmevent_send(L, ev, args) UNUSED(L) +#define lj_vmevent_send_(L, ev, args, post) UNUSED(L) +#else +#define lj_vmevent_send(L, ev, args) \ + if (G(L)->vmevmask & VMEVENT_MASK(LJ_VMEVENT_##ev)) { \ + ptrdiff_t argbase = lj_vmevent_prepare(L, LJ_VMEVENT_##ev); \ + if (argbase) { \ + args \ + lj_vmevent_call(L, argbase); \ + } \ + } +#define lj_vmevent_send_(L, ev, args, post) \ + if (G(L)->vmevmask & VMEVENT_MASK(LJ_VMEVENT_##ev)) { \ + ptrdiff_t argbase = lj_vmevent_prepare(L, LJ_VMEVENT_##ev); \ + if (argbase) { \ + args \ + lj_vmevent_call(L, argbase); \ + post \ + } \ + } + +LJ_FUNC ptrdiff_t lj_vmevent_prepare(lua_State *L, VMEvent ev); +LJ_FUNC void lj_vmevent_call(lua_State *L, ptrdiff_t argbase); +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lj_vmmath.c b/source/libs/luajit/LuaJIT-2.0.4/src/lj_vmmath.c new file mode 100644 index 000000000..31c6029fc --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lj_vmmath.c @@ -0,0 +1,140 @@ +/* +** Math helper functions for assembler VM. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#define lj_vmmath_c +#define LUA_CORE + +#include +#include + +#include "lj_obj.h" +#include "lj_ir.h" +#include "lj_vm.h" + +/* -- Helper functions for generated machine code ------------------------- */ + +#if LJ_TARGET_X86ORX64 +/* Wrapper functions to avoid linker issues on OSX. */ +LJ_FUNCA double lj_vm_sinh(double x) { return sinh(x); } +LJ_FUNCA double lj_vm_cosh(double x) { return cosh(x); } +LJ_FUNCA double lj_vm_tanh(double x) { return tanh(x); } +#endif + +#if !LJ_TARGET_X86ORX64 +double lj_vm_foldarith(double x, double y, int op) +{ + switch (op) { + case IR_ADD - IR_ADD: return x+y; break; + case IR_SUB - IR_ADD: return x-y; break; + case IR_MUL - IR_ADD: return x*y; break; + case IR_DIV - IR_ADD: return x/y; break; + case IR_MOD - IR_ADD: return x-lj_vm_floor(x/y)*y; break; + case IR_POW - IR_ADD: return pow(x, y); break; + case IR_NEG - IR_ADD: return -x; break; + case IR_ABS - IR_ADD: return fabs(x); break; +#if LJ_HASJIT + case IR_ATAN2 - IR_ADD: return atan2(x, y); break; + case IR_LDEXP - IR_ADD: return ldexp(x, (int)y); break; + case IR_MIN - IR_ADD: return x > y ? y : x; break; + case IR_MAX - IR_ADD: return x < y ? y : x; break; +#endif + default: return x; + } +} +#endif + +#if LJ_HASJIT + +#ifdef LUAJIT_NO_LOG2 +double lj_vm_log2(double a) +{ + return log(a) * 1.4426950408889634074; +} +#endif + +#ifdef LUAJIT_NO_EXP2 +double lj_vm_exp2(double a) +{ + return exp(a * 0.6931471805599453); +} +#endif + +#if !(LJ_TARGET_ARM || LJ_TARGET_PPC) +int32_t LJ_FASTCALL lj_vm_modi(int32_t a, int32_t b) +{ + uint32_t y, ua, ub; + lua_assert(b != 0); /* This must be checked before using this function. */ + ua = a < 0 ? (uint32_t)-a : (uint32_t)a; + ub = b < 0 ? (uint32_t)-b : (uint32_t)b; + y = ua % ub; + if (y != 0 && (a^b) < 0) y = y - ub; + if (((int32_t)y^b) < 0) y = (uint32_t)-(int32_t)y; + return (int32_t)y; +} +#endif + +#if !LJ_TARGET_X86ORX64 +/* Unsigned x^k. */ +static double lj_vm_powui(double x, uint32_t k) +{ + double y; + lua_assert(k != 0); + for (; (k & 1) == 0; k >>= 1) x *= x; + y = x; + if ((k >>= 1) != 0) { + for (;;) { + x *= x; + if (k == 1) break; + if (k & 1) y *= x; + k >>= 1; + } + y *= x; + } + return y; +} + +/* Signed x^k. */ +double lj_vm_powi(double x, int32_t k) +{ + if (k > 1) + return lj_vm_powui(x, (uint32_t)k); + else if (k == 1) + return x; + else if (k == 0) + return 1.0; + else + return 1.0 / lj_vm_powui(x, (uint32_t)-k); +} + +/* Computes fpm(x) for extended math functions. */ +double lj_vm_foldfpm(double x, int fpm) +{ + switch (fpm) { + case IRFPM_FLOOR: return lj_vm_floor(x); + case IRFPM_CEIL: return lj_vm_ceil(x); + case IRFPM_TRUNC: return lj_vm_trunc(x); + case IRFPM_SQRT: return sqrt(x); + case IRFPM_EXP: return exp(x); + case IRFPM_EXP2: return lj_vm_exp2(x); + case IRFPM_LOG: return log(x); + case IRFPM_LOG2: return lj_vm_log2(x); + case IRFPM_LOG10: return log10(x); + case IRFPM_SIN: return sin(x); + case IRFPM_COS: return cos(x); + case IRFPM_TAN: return tan(x); + default: lua_assert(0); + } + return 0; +} +#endif + +#if LJ_HASFFI +int lj_vm_errno(void) +{ + return errno; +} +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/ljamalg.c b/source/libs/luajit/LuaJIT-2.0.4/src/ljamalg.c new file mode 100644 index 000000000..9b237b7e9 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/ljamalg.c @@ -0,0 +1,93 @@ +/* +** LuaJIT core and libraries amalgamation. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +/* ++--------------------------------------------------------------------------+ +| WARNING: Compiling the amalgamation needs a lot of virtual memory | +| (around 300 MB with GCC 4.x)! If you don't have enough physical memory | +| your machine will start swapping to disk and the compile will not finish | +| within a reasonable amount of time. | +| So either compile on a bigger machine or use the non-amalgamated build. | ++--------------------------------------------------------------------------+ +*/ + +#define ljamalg_c +#define LUA_CORE + +/* To get the mremap prototype. Must be defined before any system includes. */ +#if defined(__linux__) && !defined(_GNU_SOURCE) +#define _GNU_SOURCE +#endif + +#ifndef WINVER +#define WINVER 0x0501 +#endif + +#include "lua.h" +#include "lauxlib.h" + +#include "lj_gc.c" +#include "lj_err.c" +#include "lj_char.c" +#include "lj_bc.c" +#include "lj_obj.c" +#include "lj_str.c" +#include "lj_tab.c" +#include "lj_func.c" +#include "lj_udata.c" +#include "lj_meta.c" +#include "lj_debug.c" +#include "lj_state.c" +#include "lj_dispatch.c" +#include "lj_vmevent.c" +#include "lj_vmmath.c" +#include "lj_strscan.c" +#include "lj_api.c" +#include "lj_lex.c" +#include "lj_parse.c" +#include "lj_bcread.c" +#include "lj_bcwrite.c" +#include "lj_load.c" +#include "lj_ctype.c" +#include "lj_cdata.c" +#include "lj_cconv.c" +#include "lj_ccall.c" +#include "lj_ccallback.c" +#include "lj_carith.c" +#include "lj_clib.c" +#include "lj_cparse.c" +#include "lj_lib.c" +#include "lj_ir.c" +#include "lj_opt_mem.c" +#include "lj_opt_fold.c" +#include "lj_opt_narrow.c" +#include "lj_opt_dce.c" +#include "lj_opt_loop.c" +#include "lj_opt_split.c" +#include "lj_opt_sink.c" +#include "lj_mcode.c" +#include "lj_snap.c" +#include "lj_record.c" +#include "lj_crecord.c" +#include "lj_ffrecord.c" +#include "lj_asm.c" +#include "lj_trace.c" +#include "lj_gdbjit.c" +#include "lj_alloc.c" + +#include "lib_aux.c" +#include "lib_base.c" +#include "lib_math.c" +#include "lib_string.c" +#include "lib_table.c" +#include "lib_io.c" +#include "lib_os.c" +#include "lib_package.c" +#include "lib_debug.c" +#include "lib_bit.c" +#include "lib_jit.c" +#include "lib_ffi.c" +#include "lib_init.c" + diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lua.h b/source/libs/luajit/LuaJIT-2.0.4/src/lua.h similarity index 100% rename from source/libs/luajit/LuaJIT-2.0.3/src/lua.h rename to source/libs/luajit/LuaJIT-2.0.4/src/lua.h diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/lua.hpp b/source/libs/luajit/LuaJIT-2.0.4/src/lua.hpp similarity index 100% rename from source/libs/luajit/LuaJIT-2.0.3/src/lua.hpp rename to source/libs/luajit/LuaJIT-2.0.4/src/lua.hpp diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/luaconf.h b/source/libs/luajit/LuaJIT-2.0.4/src/luaconf.h new file mode 100644 index 000000000..84fa64187 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/luaconf.h @@ -0,0 +1,156 @@ +/* +** Configuration header. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef luaconf_h +#define luaconf_h + +#ifndef WINVER +#define WINVER 0x0501 +#endif +#include +#include + +/* Default path for loading Lua and C modules with require(). */ +#if defined(_WIN32) +/* +** In Windows, any exclamation mark ('!') in the path is replaced by the +** path of the directory of the executable file of the current process. +*/ +#define LUA_LDIR "!\\lua\\" +#define LUA_CDIR "!\\" +#define LUA_PATH_DEFAULT \ + ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" +#define LUA_CPATH_DEFAULT \ + ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" +#else +/* +** Note to distribution maintainers: do NOT patch the following lines! +** Please read ../doc/install.html#distro and pass PREFIX=/usr instead. +*/ +#ifndef LUA_MULTILIB +#define LUA_MULTILIB "lib" +#endif +#ifndef LUA_LMULTILIB +#define LUA_LMULTILIB "lib" +#endif +#define LUA_LROOT "/usr/local" +#define LUA_LUADIR "/lua/5.1/" +#define LUA_LJDIR "/luajit-2.0.4/" + +#ifdef LUA_ROOT +#define LUA_JROOT LUA_ROOT +#define LUA_RLDIR LUA_ROOT "/share" LUA_LUADIR +#define LUA_RCDIR LUA_ROOT "/" LUA_MULTILIB LUA_LUADIR +#define LUA_RLPATH ";" LUA_RLDIR "?.lua;" LUA_RLDIR "?/init.lua" +#define LUA_RCPATH ";" LUA_RCDIR "?.so" +#else +#define LUA_JROOT LUA_LROOT +#define LUA_RLPATH +#define LUA_RCPATH +#endif + +#define LUA_JPATH ";" LUA_JROOT "/share" LUA_LJDIR "?.lua" +#define LUA_LLDIR LUA_LROOT "/share" LUA_LUADIR +#define LUA_LCDIR LUA_LROOT "/" LUA_LMULTILIB LUA_LUADIR +#define LUA_LLPATH ";" LUA_LLDIR "?.lua;" LUA_LLDIR "?/init.lua" +#define LUA_LCPATH1 ";" LUA_LCDIR "?.so" +#define LUA_LCPATH2 ";" LUA_LCDIR "loadall.so" + +#define LUA_PATH_DEFAULT "./?.lua" LUA_JPATH LUA_LLPATH LUA_RLPATH +#define LUA_CPATH_DEFAULT "./?.so" LUA_LCPATH1 LUA_RCPATH LUA_LCPATH2 +#endif + +/* Environment variable names for path overrides and initialization code. */ +#define LUA_PATH "LUA_PATH" +#define LUA_CPATH "LUA_CPATH" +#define LUA_INIT "LUA_INIT" + +/* Special file system characters. */ +#if defined(_WIN32) +#define LUA_DIRSEP "\\" +#else +#define LUA_DIRSEP "/" +#endif +#define LUA_PATHSEP ";" +#define LUA_PATH_MARK "?" +#define LUA_EXECDIR "!" +#define LUA_IGMARK "-" +#define LUA_PATH_CONFIG \ + LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" \ + LUA_EXECDIR "\n" LUA_IGMARK + +/* Quoting in error messages. */ +#define LUA_QL(x) "'" x "'" +#define LUA_QS LUA_QL("%s") + +/* Various tunables. */ +#define LUAI_MAXSTACK 65500 /* Max. # of stack slots for a thread (<64K). */ +#define LUAI_MAXCSTACK 8000 /* Max. # of stack slots for a C func (<10K). */ +#define LUAI_GCPAUSE 200 /* Pause GC until memory is at 200%. */ +#define LUAI_GCMUL 200 /* Run GC at 200% of allocation speed. */ +#define LUA_MAXCAPTURES 32 /* Max. pattern captures. */ + +/* Compatibility with older library function names. */ +#define LUA_COMPAT_MOD /* OLD: math.mod, NEW: math.fmod */ +#define LUA_COMPAT_GFIND /* OLD: string.gfind, NEW: string.gmatch */ + +/* Configuration for the frontend (the luajit executable). */ +#if defined(luajit_c) +#define LUA_PROGNAME "luajit" /* Fallback frontend name. */ +#define LUA_PROMPT "> " /* Interactive prompt. */ +#define LUA_PROMPT2 ">> " /* Continuation prompt. */ +#define LUA_MAXINPUT 512 /* Max. input line length. */ +#endif + +/* Note: changing the following defines breaks the Lua 5.1 ABI. */ +#define LUA_INTEGER ptrdiff_t +#define LUA_IDSIZE 60 /* Size of lua_Debug.short_src. */ +/* +** Size of lauxlib and io.* on-stack buffers. Weird workaround to avoid using +** unreasonable amounts of stack space, but still retain ABI compatibility. +** Blame Lua for depending on BUFSIZ in the ABI, blame **** for wrecking it. +*/ +#define LUAL_BUFFERSIZE (BUFSIZ > 16384 ? 8192 : BUFSIZ) + +/* The following defines are here only for compatibility with luaconf.h +** from the standard Lua distribution. They must not be changed for LuaJIT. +*/ +#define LUA_NUMBER_DOUBLE +#define LUA_NUMBER double +#define LUAI_UACNUMBER double +#define LUA_NUMBER_SCAN "%lf" +#define LUA_NUMBER_FMT "%.14g" +#define lua_number2str(s, n) sprintf((s), LUA_NUMBER_FMT, (n)) +#define LUAI_MAXNUMBER2STR 32 +#define LUA_INTFRMLEN "l" +#define LUA_INTFRM_T long + +/* Linkage of public API functions. */ +#if defined(LUA_BUILD_AS_DLL) +#if defined(LUA_CORE) || defined(LUA_LIB) +#define LUA_API __declspec(dllexport) +#else +#define LUA_API __declspec(dllimport) +#endif +#else +#define LUA_API extern +#endif + +#define LUALIB_API LUA_API + +/* Support for internal assertions. */ +#if defined(LUA_USE_ASSERT) || defined(LUA_USE_APICHECK) +#include +#endif +#ifdef LUA_USE_ASSERT +#define lua_assert(x) assert(x) +#endif +#ifdef LUA_USE_APICHECK +#define luai_apicheck(L, o) { (void)L; assert(o); } +#else +#define luai_apicheck(L, o) { (void)L; } +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/luajit.c b/source/libs/luajit/LuaJIT-2.0.4/src/luajit.c new file mode 100644 index 000000000..85d713fb4 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/luajit.c @@ -0,0 +1,571 @@ +/* +** LuaJIT frontend. Runs commands, scripts, read-eval-print (REPL) etc. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +** +** Major portions taken verbatim or adapted from the Lua interpreter. +** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h +*/ + +#include +#include +#include + +#define luajit_c + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "luajit.h" + +#include "lj_arch.h" + +#if LJ_TARGET_POSIX +#include +#define lua_stdin_is_tty() isatty(0) +#elif LJ_TARGET_WINDOWS +#include +#ifdef __BORLANDC__ +#define lua_stdin_is_tty() isatty(_fileno(stdin)) +#else +#define lua_stdin_is_tty() _isatty(_fileno(stdin)) +#endif +#else +#define lua_stdin_is_tty() 1 +#endif + +#if !LJ_TARGET_CONSOLE +#include +#endif + +static lua_State *globalL = NULL; +static const char *progname = LUA_PROGNAME; + +#if !LJ_TARGET_CONSOLE +static void lstop(lua_State *L, lua_Debug *ar) +{ + (void)ar; /* unused arg. */ + lua_sethook(L, NULL, 0, 0); + /* Avoid luaL_error -- a C hook doesn't add an extra frame. */ + luaL_where(L, 0); + lua_pushfstring(L, "%sinterrupted!", lua_tostring(L, -1)); + lua_error(L); +} + +static void laction(int i) +{ + signal(i, SIG_DFL); /* if another SIGINT happens before lstop, + terminate process (default action) */ + lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1); +} +#endif + +static void print_usage(void) +{ + fprintf(stderr, + "usage: %s [options]... [script [args]...].\n" + "Available options are:\n" + " -e chunk Execute string " LUA_QL("chunk") ".\n" + " -l name Require library " LUA_QL("name") ".\n" + " -b ... Save or list bytecode.\n" + " -j cmd Perform LuaJIT control command.\n" + " -O[opt] Control LuaJIT optimizations.\n" + " -i Enter interactive mode after executing " LUA_QL("script") ".\n" + " -v Show version information.\n" + " -E Ignore environment variables.\n" + " -- Stop handling options.\n" + " - Execute stdin and stop handling options.\n" + , + progname); + fflush(stderr); +} + +static void l_message(const char *pname, const char *msg) +{ + if (pname) fprintf(stderr, "%s: ", pname); + fprintf(stderr, "%s\n", msg); + fflush(stderr); +} + +static int report(lua_State *L, int status) +{ + if (status && !lua_isnil(L, -1)) { + const char *msg = lua_tostring(L, -1); + if (msg == NULL) msg = "(error object is not a string)"; + l_message(progname, msg); + lua_pop(L, 1); + } + return status; +} + +static int traceback(lua_State *L) +{ + if (!lua_isstring(L, 1)) { /* Non-string error object? Try metamethod. */ + if (lua_isnoneornil(L, 1) || + !luaL_callmeta(L, 1, "__tostring") || + !lua_isstring(L, -1)) + return 1; /* Return non-string error object. */ + lua_remove(L, 1); /* Replace object by result of __tostring metamethod. */ + } + luaL_traceback(L, L, lua_tostring(L, 1), 1); + return 1; +} + +static int docall(lua_State *L, int narg, int clear) +{ + int status; + int base = lua_gettop(L) - narg; /* function index */ + lua_pushcfunction(L, traceback); /* push traceback function */ + lua_insert(L, base); /* put it under chunk and args */ +#if !LJ_TARGET_CONSOLE + signal(SIGINT, laction); +#endif + status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base); +#if !LJ_TARGET_CONSOLE + signal(SIGINT, SIG_DFL); +#endif + lua_remove(L, base); /* remove traceback function */ + /* force a complete garbage collection in case of errors */ + if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0); + return status; +} + +static void print_version(void) +{ + fputs(LUAJIT_VERSION " -- " LUAJIT_COPYRIGHT ". " LUAJIT_URL "\n", stdout); +} + +static void print_jit_status(lua_State *L) +{ + int n; + const char *s; + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, -1, "jit"); /* Get jit.* module table. */ + lua_remove(L, -2); + lua_getfield(L, -1, "status"); + lua_remove(L, -2); + n = lua_gettop(L); + lua_call(L, 0, LUA_MULTRET); + fputs(lua_toboolean(L, n) ? "JIT: ON" : "JIT: OFF", stdout); + for (n++; (s = lua_tostring(L, n)); n++) { + putc(' ', stdout); + fputs(s, stdout); + } + putc('\n', stdout); +} + +static int getargs(lua_State *L, char **argv, int n) +{ + int narg; + int i; + int argc = 0; + while (argv[argc]) argc++; /* count total number of arguments */ + narg = argc - (n + 1); /* number of arguments to the script */ + luaL_checkstack(L, narg + 3, "too many arguments to script"); + for (i = n+1; i < argc; i++) + lua_pushstring(L, argv[i]); + lua_createtable(L, narg, n + 1); + for (i = 0; i < argc; i++) { + lua_pushstring(L, argv[i]); + lua_rawseti(L, -2, i - n); + } + return narg; +} + +static int dofile(lua_State *L, const char *name) +{ + int status = luaL_loadfile(L, name) || docall(L, 0, 1); + return report(L, status); +} + +static int dostring(lua_State *L, const char *s, const char *name) +{ + int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1); + return report(L, status); +} + +static int dolibrary(lua_State *L, const char *name) +{ + lua_getglobal(L, "require"); + lua_pushstring(L, name); + return report(L, docall(L, 1, 1)); +} + +static void write_prompt(lua_State *L, int firstline) +{ + const char *p; + lua_getfield(L, LUA_GLOBALSINDEX, firstline ? "_PROMPT" : "_PROMPT2"); + p = lua_tostring(L, -1); + if (p == NULL) p = firstline ? LUA_PROMPT : LUA_PROMPT2; + fputs(p, stdout); + fflush(stdout); + lua_pop(L, 1); /* remove global */ +} + +static int incomplete(lua_State *L, int status) +{ + if (status == LUA_ERRSYNTAX) { + size_t lmsg; + const char *msg = lua_tolstring(L, -1, &lmsg); + const char *tp = msg + lmsg - (sizeof(LUA_QL("")) - 1); + if (strstr(msg, LUA_QL("")) == tp) { + lua_pop(L, 1); + return 1; + } + } + return 0; /* else... */ +} + +static int pushline(lua_State *L, int firstline) +{ + char buf[LUA_MAXINPUT]; + write_prompt(L, firstline); + if (fgets(buf, LUA_MAXINPUT, stdin)) { + size_t len = strlen(buf); + if (len > 0 && buf[len-1] == '\n') + buf[len-1] = '\0'; + if (firstline && buf[0] == '=') + lua_pushfstring(L, "return %s", buf+1); + else + lua_pushstring(L, buf); + return 1; + } + return 0; +} + +static int loadline(lua_State *L) +{ + int status; + lua_settop(L, 0); + if (!pushline(L, 1)) + return -1; /* no input */ + for (;;) { /* repeat until gets a complete line */ + status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin"); + if (!incomplete(L, status)) break; /* cannot try to add lines? */ + if (!pushline(L, 0)) /* no more input? */ + return -1; + lua_pushliteral(L, "\n"); /* add a new line... */ + lua_insert(L, -2); /* ...between the two lines */ + lua_concat(L, 3); /* join them */ + } + lua_remove(L, 1); /* remove line */ + return status; +} + +static void dotty(lua_State *L) +{ + int status; + const char *oldprogname = progname; + progname = NULL; + while ((status = loadline(L)) != -1) { + if (status == 0) status = docall(L, 0, 0); + report(L, status); + if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */ + lua_getglobal(L, "print"); + lua_insert(L, 1); + if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0) + l_message(progname, + lua_pushfstring(L, "error calling " LUA_QL("print") " (%s)", + lua_tostring(L, -1))); + } + } + lua_settop(L, 0); /* clear stack */ + fputs("\n", stdout); + fflush(stdout); + progname = oldprogname; +} + +static int handle_script(lua_State *L, char **argv, int n) +{ + int status; + const char *fname; + int narg = getargs(L, argv, n); /* collect arguments */ + lua_setglobal(L, "arg"); + fname = argv[n]; + if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0) + fname = NULL; /* stdin */ + status = luaL_loadfile(L, fname); + lua_insert(L, -(narg+1)); + if (status == 0) + status = docall(L, narg, 0); + else + lua_pop(L, narg); + return report(L, status); +} + +/* Load add-on module. */ +static int loadjitmodule(lua_State *L) +{ + lua_getglobal(L, "require"); + lua_pushliteral(L, "jit."); + lua_pushvalue(L, -3); + lua_concat(L, 2); + if (lua_pcall(L, 1, 1, 0)) { + const char *msg = lua_tostring(L, -1); + if (msg && !strncmp(msg, "module ", 7)) + goto nomodule; + return report(L, 1); + } + lua_getfield(L, -1, "start"); + if (lua_isnil(L, -1)) { + nomodule: + l_message(progname, + "unknown luaJIT command or jit.* modules not installed"); + return 1; + } + lua_remove(L, -2); /* Drop module table. */ + return 0; +} + +/* Run command with options. */ +static int runcmdopt(lua_State *L, const char *opt) +{ + int narg = 0; + if (opt && *opt) { + for (;;) { /* Split arguments. */ + const char *p = strchr(opt, ','); + narg++; + if (!p) break; + if (p == opt) + lua_pushnil(L); + else + lua_pushlstring(L, opt, (size_t)(p - opt)); + opt = p + 1; + } + if (*opt) + lua_pushstring(L, opt); + else + lua_pushnil(L); + } + return report(L, lua_pcall(L, narg, 0, 0)); +} + +/* JIT engine control command: try jit library first or load add-on module. */ +static int dojitcmd(lua_State *L, const char *cmd) +{ + const char *opt = strchr(cmd, '='); + lua_pushlstring(L, cmd, opt ? (size_t)(opt - cmd) : strlen(cmd)); + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, -1, "jit"); /* Get jit.* module table. */ + lua_remove(L, -2); + lua_pushvalue(L, -2); + lua_gettable(L, -2); /* Lookup library function. */ + if (!lua_isfunction(L, -1)) { + lua_pop(L, 2); /* Drop non-function and jit.* table, keep module name. */ + if (loadjitmodule(L)) + return 1; + } else { + lua_remove(L, -2); /* Drop jit.* table. */ + } + lua_remove(L, -2); /* Drop module name. */ + return runcmdopt(L, opt ? opt+1 : opt); +} + +/* Optimization flags. */ +static int dojitopt(lua_State *L, const char *opt) +{ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, -1, "jit.opt"); /* Get jit.opt.* module table. */ + lua_remove(L, -2); + lua_getfield(L, -1, "start"); + lua_remove(L, -2); + return runcmdopt(L, opt); +} + +/* Save or list bytecode. */ +static int dobytecode(lua_State *L, char **argv) +{ + int narg = 0; + lua_pushliteral(L, "bcsave"); + if (loadjitmodule(L)) + return 1; + if (argv[0][2]) { + narg++; + argv[0][1] = '-'; + lua_pushstring(L, argv[0]+1); + } + for (argv++; *argv != NULL; narg++, argv++) + lua_pushstring(L, *argv); + return report(L, lua_pcall(L, narg, 0, 0)); +} + +/* check that argument has no extra characters at the end */ +#define notail(x) {if ((x)[2] != '\0') return -1;} + +#define FLAGS_INTERACTIVE 1 +#define FLAGS_VERSION 2 +#define FLAGS_EXEC 4 +#define FLAGS_OPTION 8 +#define FLAGS_NOENV 16 + +static int collectargs(char **argv, int *flags) +{ + int i; + for (i = 1; argv[i] != NULL; i++) { + if (argv[i][0] != '-') /* Not an option? */ + return i; + switch (argv[i][1]) { /* Check option. */ + case '-': + notail(argv[i]); + return (argv[i+1] != NULL ? i+1 : 0); + case '\0': + return i; + case 'i': + notail(argv[i]); + *flags |= FLAGS_INTERACTIVE; + /* fallthrough */ + case 'v': + notail(argv[i]); + *flags |= FLAGS_VERSION; + break; + case 'e': + *flags |= FLAGS_EXEC; + case 'j': /* LuaJIT extension */ + case 'l': + *flags |= FLAGS_OPTION; + if (argv[i][2] == '\0') { + i++; + if (argv[i] == NULL) return -1; + } + break; + case 'O': break; /* LuaJIT extension */ + case 'b': /* LuaJIT extension */ + if (*flags) return -1; + *flags |= FLAGS_EXEC; + return 0; + case 'E': + *flags |= FLAGS_NOENV; + break; + default: return -1; /* invalid option */ + } + } + return 0; +} + +static int runargs(lua_State *L, char **argv, int n) +{ + int i; + for (i = 1; i < n; i++) { + if (argv[i] == NULL) continue; + lua_assert(argv[i][0] == '-'); + switch (argv[i][1]) { /* option */ + case 'e': { + const char *chunk = argv[i] + 2; + if (*chunk == '\0') chunk = argv[++i]; + lua_assert(chunk != NULL); + if (dostring(L, chunk, "=(command line)") != 0) + return 1; + break; + } + case 'l': { + const char *filename = argv[i] + 2; + if (*filename == '\0') filename = argv[++i]; + lua_assert(filename != NULL); + if (dolibrary(L, filename)) + return 1; /* stop if file fails */ + break; + } + case 'j': { /* LuaJIT extension */ + const char *cmd = argv[i] + 2; + if (*cmd == '\0') cmd = argv[++i]; + lua_assert(cmd != NULL); + if (dojitcmd(L, cmd)) + return 1; + break; + } + case 'O': /* LuaJIT extension */ + if (dojitopt(L, argv[i] + 2)) + return 1; + break; + case 'b': /* LuaJIT extension */ + return dobytecode(L, argv+i); + default: break; + } + } + return 0; +} + +static int handle_luainit(lua_State *L) +{ +#if LJ_TARGET_CONSOLE + const char *init = NULL; +#else + const char *init = getenv(LUA_INIT); +#endif + if (init == NULL) + return 0; /* status OK */ + else if (init[0] == '@') + return dofile(L, init+1); + else + return dostring(L, init, "=" LUA_INIT); +} + +static struct Smain { + char **argv; + int argc; + int status; +} smain; + +static int pmain(lua_State *L) +{ + struct Smain *s = &smain; + char **argv = s->argv; + int script; + int flags = 0; + globalL = L; + if (argv[0] && argv[0][0]) progname = argv[0]; + LUAJIT_VERSION_SYM(); /* linker-enforced version check */ + script = collectargs(argv, &flags); + if (script < 0) { /* invalid args? */ + print_usage(); + s->status = 1; + return 0; + } + if ((flags & FLAGS_NOENV)) { + lua_pushboolean(L, 1); + lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV"); + } + lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ + luaL_openlibs(L); /* open libraries */ + lua_gc(L, LUA_GCRESTART, -1); + if (!(flags & FLAGS_NOENV)) { + s->status = handle_luainit(L); + if (s->status != 0) return 0; + } + if ((flags & FLAGS_VERSION)) print_version(); + s->status = runargs(L, argv, (script > 0) ? script : s->argc); + if (s->status != 0) return 0; + if (script) { + s->status = handle_script(L, argv, script); + if (s->status != 0) return 0; + } + if ((flags & FLAGS_INTERACTIVE)) { + print_jit_status(L); + dotty(L); + } else if (script == 0 && !(flags & (FLAGS_EXEC|FLAGS_VERSION))) { + if (lua_stdin_is_tty()) { + print_version(); + print_jit_status(L); + dotty(L); + } else { + dofile(L, NULL); /* executes stdin as a file */ + } + } + return 0; +} + +int main(int argc, char **argv) +{ + int status; + lua_State *L = lua_open(); /* create state */ + if (L == NULL) { + l_message(argv[0], "cannot create state: not enough memory"); + return EXIT_FAILURE; + } + smain.argc = argc; + smain.argv = argv; + status = lua_cpcall(L, pmain, NULL); + report(L, status); + lua_close(L); + return (status || smain.status) ? EXIT_FAILURE : EXIT_SUCCESS; +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/luajit.h b/source/libs/luajit/LuaJIT-2.0.4/src/luajit.h new file mode 100644 index 000000000..9ced18eb8 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/luajit.h @@ -0,0 +1,70 @@ +/* +** LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/ +** +** Copyright (C) 2005-2015 Mike Pall. All rights reserved. +** +** Permission is hereby granted, free of charge, to any person obtaining +** a copy of this software and associated documentation files (the +** "Software"), to deal in the Software without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Software, and to +** permit persons to whom the Software is furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be +** included in all copies or substantial portions of the Software. +** +** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +** +** [ MIT license: http://www.opensource.org/licenses/mit-license.php ] +*/ + +#ifndef _LUAJIT_H +#define _LUAJIT_H + +#include "lua.h" + +#define LUAJIT_VERSION "LuaJIT 2.0.4" +#define LUAJIT_VERSION_NUM 20004 /* Version 2.0.4 = 02.00.04. */ +#define LUAJIT_VERSION_SYM luaJIT_version_2_0_4 +#define LUAJIT_COPYRIGHT "Copyright (C) 2005-2015 Mike Pall" +#define LUAJIT_URL "http://luajit.org/" + +/* Modes for luaJIT_setmode. */ +#define LUAJIT_MODE_MASK 0x00ff + +enum { + LUAJIT_MODE_ENGINE, /* Set mode for whole JIT engine. */ + LUAJIT_MODE_DEBUG, /* Set debug mode (idx = level). */ + + LUAJIT_MODE_FUNC, /* Change mode for a function. */ + LUAJIT_MODE_ALLFUNC, /* Recurse into subroutine protos. */ + LUAJIT_MODE_ALLSUBFUNC, /* Change only the subroutines. */ + + LUAJIT_MODE_TRACE, /* Flush a compiled trace. */ + + LUAJIT_MODE_WRAPCFUNC = 0x10, /* Set wrapper mode for C function calls. */ + + LUAJIT_MODE_MAX +}; + +/* Flags or'ed in to the mode. */ +#define LUAJIT_MODE_OFF 0x0000 /* Turn feature off. */ +#define LUAJIT_MODE_ON 0x0100 /* Turn feature on. */ +#define LUAJIT_MODE_FLUSH 0x0200 /* Flush JIT-compiled code. */ + +/* LuaJIT public C API. */ + +/* Control the JIT engine. */ +LUA_API int luaJIT_setmode(lua_State *L, int idx, int mode); + +/* Enforce (dynamic) linker error for version mismatches. Call from main. */ +LUA_API void LUAJIT_VERSION_SYM(void); + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/lualib.h b/source/libs/luajit/LuaJIT-2.0.4/src/lualib.h new file mode 100644 index 000000000..58dd3349a --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/lualib.h @@ -0,0 +1,47 @@ +/* +** Standard library header. +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +*/ + +#ifndef _LUALIB_H +#define _LUALIB_H + +#include "lua.h" + +#define LUA_FILEHANDLE "FILE*" + +#define LUA_COLIBNAME "coroutine" +#define LUA_MATHLIBNAME "math" +#define LUA_STRLIBNAME "string" +#define LUA_TABLIBNAME "table" +#define LUA_IOLIBNAME "io" +#define LUA_OSLIBNAME "os" +#define LUA_LOADLIBNAME "package" +#define LUA_DBLIBNAME "debug" +#define LUA_BITLIBNAME "bit" +#define LUA_JITLIBNAME "jit" +#define LUA_FFILIBNAME "ffi" + +#define LUA_BITLIBNAME_32 "bit32" + +LUALIB_API int luaopen_base(lua_State *L); +LUALIB_API int luaopen_math(lua_State *L); +LUALIB_API int luaopen_string(lua_State *L); +LUALIB_API int luaopen_table(lua_State *L); +LUALIB_API int luaopen_io(lua_State *L); +LUALIB_API int luaopen_os(lua_State *L); +LUALIB_API int luaopen_package(lua_State *L); +LUALIB_API int luaopen_debug(lua_State *L); +LUALIB_API int luaopen_bit(lua_State *L); +LUALIB_API int luaopen_jit(lua_State *L); +LUALIB_API int luaopen_ffi(lua_State *L); + +LUALIB_API int luaopen_bit32(lua_State *L); + +LUALIB_API void luaL_openlibs(lua_State *L); + +#ifndef lua_assert +#define lua_assert(x) ((void)0) +#endif + +#endif diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/msvcbuild.bat b/source/libs/luajit/LuaJIT-2.0.4/src/msvcbuild.bat new file mode 100644 index 000000000..4b501855a --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/msvcbuild.bat @@ -0,0 +1,113 @@ +@rem Script to build LuaJIT with MSVC. +@rem Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +@rem +@rem Either open a "Visual Studio .NET Command Prompt" +@rem (Note that the Express Edition does not contain an x64 compiler) +@rem -or- +@rem Open a "Windows SDK Command Shell" and set the compiler environment: +@rem setenv /release /x86 +@rem -or- +@rem setenv /release /x64 +@rem +@rem Then cd to this directory and run this script. + +@if not defined INCLUDE goto :FAIL + +@setlocal +@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE +@set LJLINK=link /nologo +@set LJMT=mt /nologo +@set LJLIB=lib /nologo /nodefaultlib +@set DASMDIR=..\dynasm +@set DASM=%DASMDIR%\dynasm.lua +@set LJDLLNAME=lua51.dll +@set LJLIBNAME=lua51.lib +@set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c + +%LJCOMPILE% host\minilua.c +@if errorlevel 1 goto :BAD +%LJLINK% /out:minilua.exe minilua.obj +@if errorlevel 1 goto :BAD +if exist minilua.exe.manifest^ + %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe + +@set DASMFLAGS=-D WIN -D JIT -D FFI -D P64 +@set LJARCH=x64 +@minilua +@if errorlevel 8 goto :X64 +@set DASMFLAGS=-D WIN -D JIT -D FFI +@set LJARCH=x86 +:X64 +minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x86.dasc +@if errorlevel 1 goto :BAD + +%LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c +@if errorlevel 1 goto :BAD +%LJLINK% /out:buildvm.exe buildvm*.obj +@if errorlevel 1 goto :BAD +if exist buildvm.exe.manifest^ + %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe + +buildvm -m peobj -o lj_vm.obj +@if errorlevel 1 goto :BAD +buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m libdef -o lj_libdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m recdef -o lj_recdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m folddef -o lj_folddef.h lj_opt_fold.c +@if errorlevel 1 goto :BAD + +@if "%1" neq "debug" goto :NODEBUG +@shift +@set LJCOMPILE=%LJCOMPILE% /Zi +@set LJLINK=%LJLINK% /debug +:NODEBUG +@if "%1"=="amalg" goto :AMALGDLL +@if "%1"=="static" goto :STATIC +%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL lj_*.c lib_*.c +@if errorlevel 1 goto :BAD +%LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj +@if errorlevel 1 goto :BAD +@goto :MTDLL +:STATIC +%LJCOMPILE% lj_*.c lib_*.c +@if errorlevel 1 goto :BAD +%LJLIB% /OUT:%LJLIBNAME% lj_*.obj lib_*.obj +@if errorlevel 1 goto :BAD +@goto :MTDLL +:AMALGDLL +%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL ljamalg.c +@if errorlevel 1 goto :BAD +%LJLINK% /DLL /out:%LJDLLNAME% ljamalg.obj lj_vm.obj +@if errorlevel 1 goto :BAD +:MTDLL +if exist %LJDLLNAME%.manifest^ + %LJMT% -manifest %LJDLLNAME%.manifest -outputresource:%LJDLLNAME%;2 + +%LJCOMPILE% luajit.c +@if errorlevel 1 goto :BAD +%LJLINK% /out:luajit.exe luajit.obj %LJLIBNAME% +@if errorlevel 1 goto :BAD +if exist luajit.exe.manifest^ + %LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe + +@del *.obj *.manifest minilua.exe buildvm.exe +@echo. +@echo === Successfully built LuaJIT for Windows/%LJARCH% === + +@goto :END +:BAD +@echo. +@echo ******************************************************* +@echo *** Build FAILED -- Please check the error messages *** +@echo ******************************************************* +@goto :END +:FAIL +@echo You must open a "Visual Studio .NET Command Prompt" to run this script +:END diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/ps4build.bat b/source/libs/luajit/LuaJIT-2.0.4/src/ps4build.bat similarity index 100% rename from source/libs/luajit/LuaJIT-2.0.3/src/ps4build.bat rename to source/libs/luajit/LuaJIT-2.0.4/src/ps4build.bat diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/psvitabuild.bat b/source/libs/luajit/LuaJIT-2.0.4/src/psvitabuild.bat new file mode 100644 index 000000000..3991dc653 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/psvitabuild.bat @@ -0,0 +1,93 @@ +@rem Script to build LuaJIT with the PS Vita SDK. +@rem Donated to the public domain. +@rem +@rem Open a "Visual Studio .NET Command Prompt" (32 bit host compiler) +@rem Then cd to this directory and run this script. + +@if not defined INCLUDE goto :FAIL +@if not defined SCE_PSP2_SDK_DIR goto :FAIL + +@setlocal +@rem ---- Host compiler ---- +@set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE +@set LJLINK=link /nologo +@set LJMT=mt /nologo +@set DASMDIR=..\dynasm +@set DASM=%DASMDIR%\dynasm.lua +@set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c + +%LJCOMPILE% host\minilua.c +@if errorlevel 1 goto :BAD +%LJLINK% /out:minilua.exe minilua.obj +@if errorlevel 1 goto :BAD +if exist minilua.exe.manifest^ + %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe + +@rem Check for 32 bit host compiler. +@minilua +@if errorlevel 8 goto :FAIL + +@set DASMFLAGS=-D FPU -D HFABI +minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_arm.dasc +@if errorlevel 1 goto :BAD + +%LJCOMPILE% /I "." /I %DASMDIR% -DLUAJIT_TARGET=LUAJIT_ARCH_ARM -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLJ_TARGET_PSVITA=1 host\buildvm*.c +@if errorlevel 1 goto :BAD +%LJLINK% /out:buildvm.exe buildvm*.obj +@if errorlevel 1 goto :BAD +if exist buildvm.exe.manifest^ + %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe + +buildvm -m elfasm -o lj_vm.s +@if errorlevel 1 goto :BAD +buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m libdef -o lj_libdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m recdef -o lj_recdef.h %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% +@if errorlevel 1 goto :BAD +buildvm -m folddef -o lj_folddef.h lj_opt_fold.c +@if errorlevel 1 goto :BAD + +@rem ---- Cross compiler ---- +@set LJCOMPILE="%SCE_PSP2_SDK_DIR%\host_tools\build\bin\psp2snc" -c -w -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC +@set LJLIB="%SCE_PSP2_SDK_DIR%\host_tools\build\bin\psp2ld32" -r --output= +@set INCLUDE="" + +"%SCE_PSP2_SDK_DIR%\host_tools\build\bin\psp2as" -o lj_vm.o lj_vm.s + +@if "%1" neq "debug" goto :NODEBUG +@shift +@set LJCOMPILE=%LJCOMPILE% -g -O0 +@set TARGETLIB=libluajitD.a +goto :BUILD +:NODEBUG +@set LJCOMPILE=%LJCOMPILE% -O2 +@set TARGETLIB=libluajit.a +:BUILD +del %TARGETLIB% + +%LJCOMPILE% ljamalg.c +@if errorlevel 1 goto :BAD +%LJLIB%%TARGETLIB% ljamalg.o lj_vm.o +@if errorlevel 1 goto :BAD + +@del *.o *.obj *.manifest minilua.exe buildvm.exe +@echo. +@echo === Successfully built LuaJIT for PS Vita === + +@goto :END +:BAD +@echo. +@echo ******************************************************* +@echo *** Build FAILED -- Please check the error messages *** +@echo ******************************************************* +@goto :END +:FAIL +@echo To run this script you must open a "Visual Studio .NET Command Prompt" +@echo (32 bit host compiler). The PS Vita SDK must be installed, too. +:END diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/vm_arm.dasc b/source/libs/luajit/LuaJIT-2.0.4/src/vm_arm.dasc new file mode 100644 index 000000000..457efa63c --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/vm_arm.dasc @@ -0,0 +1,4486 @@ +|// Low-level VM code for ARM CPUs. +|// Bytecode interpreter, fast functions and helper functions. +|// Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +| +|.arch arm +|.section code_op, code_sub +| +|.actionlist build_actionlist +|.globals GLOB_ +|.globalnames globnames +|.externnames extnames +| +|// Note: The ragged indentation of the instructions is intentional. +|// The starting columns indicate data dependencies. +| +|//----------------------------------------------------------------------- +| +|// Fixed register assignments for the interpreter. +| +|// The following must be C callee-save. +|.define MASKR8, r4 // 255*8 constant for fast bytecode decoding. +|.define KBASE, r5 // Constants of current Lua function. +|.define PC, r6 // Next PC. +|.define DISPATCH, r7 // Opcode dispatch table. +|.define LREG, r8 // Register holding lua_State (also in SAVE_L). +| +|// C callee-save in EABI, but often refetched. Temporary in iOS 3.0+. +|.define BASE, r9 // Base of current Lua stack frame. +| +|// The following temporaries are not saved across C calls, except for RA/RC. +|.define RA, r10 // Callee-save. +|.define RC, r11 // Callee-save. +|.define RB, r12 +|.define OP, r12 // Overlaps RB, must not be lr. +|.define INS, lr +| +|// Calling conventions. Also used as temporaries. +|.define CARG1, r0 +|.define CARG2, r1 +|.define CARG3, r2 +|.define CARG4, r3 +|.define CARG12, r0 // For 1st soft-fp double. +|.define CARG34, r2 // For 2nd soft-fp double. +| +|.define CRET1, r0 +|.define CRET2, r1 +| +|// Stack layout while in interpreter. Must match with lj_frame.h. +|.define SAVE_R4, [sp, #28] +|.define CFRAME_SPACE, #28 +|.define SAVE_ERRF, [sp, #24] +|.define SAVE_NRES, [sp, #20] +|.define SAVE_CFRAME, [sp, #16] +|.define SAVE_L, [sp, #12] +|.define SAVE_PC, [sp, #8] +|.define SAVE_MULTRES, [sp, #4] +|.define ARG5, [sp] +| +|.define TMPDhi, [sp, #4] +|.define TMPDlo, [sp] +|.define TMPD, [sp] +|.define TMPDp, sp +| +|.if FPU +|.macro saveregs +| push {r5, r6, r7, r8, r9, r10, r11, lr} +| vpush {d8-d15} +| sub sp, sp, CFRAME_SPACE+4 +| str r4, SAVE_R4 +|.endmacro +|.macro restoreregs_ret +| ldr r4, SAVE_R4 +| add sp, sp, CFRAME_SPACE+4 +| vpop {d8-d15} +| pop {r5, r6, r7, r8, r9, r10, r11, pc} +|.endmacro +|.else +|.macro saveregs +| push {r4, r5, r6, r7, r8, r9, r10, r11, lr} +| sub sp, sp, CFRAME_SPACE +|.endmacro +|.macro restoreregs_ret +| add sp, sp, CFRAME_SPACE +| pop {r4, r5, r6, r7, r8, r9, r10, r11, pc} +|.endmacro +|.endif +| +|// Type definitions. Some of these are only used for documentation. +|.type L, lua_State, LREG +|.type GL, global_State +|.type TVALUE, TValue +|.type GCOBJ, GCobj +|.type STR, GCstr +|.type TAB, GCtab +|.type LFUNC, GCfuncL +|.type CFUNC, GCfuncC +|.type PROTO, GCproto +|.type UPVAL, GCupval +|.type NODE, Node +|.type NARGS8, int +|.type TRACE, GCtrace +| +|//----------------------------------------------------------------------- +| +|// Trap for not-yet-implemented parts. +|.macro NYI; ud; .endmacro +| +|//----------------------------------------------------------------------- +| +|// Access to frame relative to BASE. +|.define FRAME_FUNC, #-8 +|.define FRAME_PC, #-4 +| +|.macro decode_RA8, dst, ins; and dst, MASKR8, ins, lsr #5; .endmacro +|.macro decode_RB8, dst, ins; and dst, MASKR8, ins, lsr #21; .endmacro +|.macro decode_RC8, dst, ins; and dst, MASKR8, ins, lsr #13; .endmacro +|.macro decode_RD, dst, ins; lsr dst, ins, #16; .endmacro +|.macro decode_OP, dst, ins; and dst, ins, #255; .endmacro +| +|// Instruction fetch. +|.macro ins_NEXT1 +| ldrb OP, [PC] +|.endmacro +|.macro ins_NEXT2 +| ldr INS, [PC], #4 +|.endmacro +|// Instruction decode+dispatch. +|.macro ins_NEXT3 +| ldr OP, [DISPATCH, OP, lsl #2] +| decode_RA8 RA, INS +| decode_RD RC, INS +| bx OP +|.endmacro +|.macro ins_NEXT +| ins_NEXT1 +| ins_NEXT2 +| ins_NEXT3 +|.endmacro +| +|// Instruction footer. +|.if 1 +| // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. +| .define ins_next, ins_NEXT +| .define ins_next_, ins_NEXT +| .define ins_next1, ins_NEXT1 +| .define ins_next2, ins_NEXT2 +| .define ins_next3, ins_NEXT3 +|.else +| // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. +| // Affects only certain kinds of benchmarks (and only with -j off). +| .macro ins_next +| b ->ins_next +| .endmacro +| .macro ins_next1 +| .endmacro +| .macro ins_next2 +| .endmacro +| .macro ins_next3 +| b ->ins_next +| .endmacro +| .macro ins_next_ +| ->ins_next: +| ins_NEXT +| .endmacro +|.endif +| +|// Avoid register name substitution for field name. +#define field_pc pc +| +|// Call decode and dispatch. +|.macro ins_callt +| // BASE = new base, CARG3 = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC +| ldr PC, LFUNC:CARG3->field_pc +| ldrb OP, [PC] // STALL: load PC. early PC. +| ldr INS, [PC], #4 +| ldr OP, [DISPATCH, OP, lsl #2] // STALL: load OP. early OP. +| decode_RA8 RA, INS +| add RA, RA, BASE +| bx OP +|.endmacro +| +|.macro ins_call +| // BASE = new base, CARG3 = LFUNC/CFUNC, RC = nargs*8, PC = caller PC +| str PC, [BASE, FRAME_PC] +| ins_callt // STALL: locked PC. +|.endmacro +| +|//----------------------------------------------------------------------- +| +|// Macros to test operand types. +|.macro checktp, reg, tp; cmn reg, #-tp; .endmacro +|.macro checktpeq, reg, tp; cmneq reg, #-tp; .endmacro +|.macro checktpne, reg, tp; cmnne reg, #-tp; .endmacro +|.macro checkstr, reg, target; checktp reg, LJ_TSTR; bne target; .endmacro +|.macro checktab, reg, target; checktp reg, LJ_TTAB; bne target; .endmacro +|.macro checkfunc, reg, target; checktp reg, LJ_TFUNC; bne target; .endmacro +| +|// Assumes DISPATCH is relative to GL. +#define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) +#define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) +| +#define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) +| +|.macro hotcheck, delta +| lsr CARG1, PC, #1 +| and CARG1, CARG1, #126 +| sub CARG1, CARG1, #-GG_DISP2HOT +| ldrh CARG2, [DISPATCH, CARG1] +| subs CARG2, CARG2, #delta +| strh CARG2, [DISPATCH, CARG1] +|.endmacro +| +|.macro hotloop +| hotcheck HOTCOUNT_LOOP +| blo ->vm_hotloop +|.endmacro +| +|.macro hotcall +| hotcheck HOTCOUNT_CALL +| blo ->vm_hotcall +|.endmacro +| +|// Set current VM state. +|.macro mv_vmstate, reg, st; mvn reg, #LJ_VMST_..st; .endmacro +|.macro st_vmstate, reg; str reg, [DISPATCH, #DISPATCH_GL(vmstate)]; .endmacro +| +|// Move table write barrier back. Overwrites mark and tmp. +|.macro barrierback, tab, mark, tmp +| ldr tmp, [DISPATCH, #DISPATCH_GL(gc.grayagain)] +| bic mark, mark, #LJ_GC_BLACK // black2gray(tab) +| str tab, [DISPATCH, #DISPATCH_GL(gc.grayagain)] +| strb mark, tab->marked +| str tmp, tab->gclist +|.endmacro +| +|.macro .IOS, a, b +|.if IOS +| a, b +|.endif +|.endmacro +| +|//----------------------------------------------------------------------- + +#if !LJ_DUALNUM +#error "Only dual-number mode supported for ARM target" +#endif + +/* Generate subroutines used by opcodes and other parts of the VM. */ +/* The .code_sub section should be last to help static branch prediction. */ +static void build_subroutines(BuildCtx *ctx) +{ + |.code_sub + | + |//----------------------------------------------------------------------- + |//-- Return handling ---------------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_returnp: + | // See vm_return. Also: RB = previous base. + | tst PC, #FRAME_P + | beq ->cont_dispatch + | + | // Return from pcall or xpcall fast func. + | ldr PC, [RB, FRAME_PC] // Fetch PC of previous frame. + | mvn CARG2, #~LJ_TTRUE + | mov BASE, RB + | // Prepending may overwrite the pcall frame, so do it at the end. + | str CARG2, [RA, FRAME_PC] // Prepend true to results. + | sub RA, RA, #8 + | + |->vm_returnc: + | adds RC, RC, #8 // RC = (nresults+1)*8. + | mov CRET1, #LUA_YIELD + | beq ->vm_unwind_c_eh + | str RC, SAVE_MULTRES + | ands CARG1, PC, #FRAME_TYPE + | beq ->BC_RET_Z // Handle regular return to Lua. + | + |->vm_return: + | // BASE = base, RA = resultptr, RC/MULTRES = (nresults+1)*8, PC = return + | // CARG1 = PC & FRAME_TYPE + | bic RB, PC, #FRAME_TYPEP + | cmp CARG1, #FRAME_C + | sub RB, BASE, RB // RB = previous base. + | bne ->vm_returnp + | + | str RB, L->base + | ldr KBASE, SAVE_NRES + | mv_vmstate CARG4, C + | sub BASE, BASE, #8 + | subs CARG3, RC, #8 + | lsl KBASE, KBASE, #3 // KBASE = (nresults_wanted+1)*8 + | st_vmstate CARG4 + | beq >2 + |1: + | subs CARG3, CARG3, #8 + | ldrd CARG12, [RA], #8 + | strd CARG12, [BASE], #8 + | bne <1 + |2: + | cmp KBASE, RC // More/less results wanted? + | bne >6 + |3: + | str BASE, L->top // Store new top. + | + |->vm_leave_cp: + | ldr RC, SAVE_CFRAME // Restore previous C frame. + | mov CRET1, #0 // Ok return status for vm_pcall. + | str RC, L->cframe + | + |->vm_leave_unw: + | restoreregs_ret + | + |6: + | blt >7 // Less results wanted? + | // More results wanted. Check stack size and fill up results with nil. + | ldr CARG3, L->maxstack + | mvn CARG2, #~LJ_TNIL + | cmp BASE, CARG3 + | bhs >8 + | str CARG2, [BASE, #4] + | add RC, RC, #8 + | add BASE, BASE, #8 + | b <2 + | + |7: // Less results wanted. + | sub CARG1, RC, KBASE + | cmp KBASE, #0 // LUA_MULTRET+1 case? + | subne BASE, BASE, CARG1 // Either keep top or shrink it. + | b <3 + | + |8: // Corner case: need to grow stack for filling up results. + | // This can happen if: + | // - A C function grows the stack (a lot). + | // - The GC shrinks the stack in between. + | // - A return back from a lua_call() with (high) nresults adjustment. + | str BASE, L->top // Save current top held in BASE (yes). + | lsr CARG2, KBASE, #3 + | mov CARG1, L + | bl extern lj_state_growstack // (lua_State *L, int n) + | ldr BASE, L->top // Need the (realloced) L->top in BASE. + | b <2 + | + |->vm_unwind_c: // Unwind C stack, return from vm_pcall. + | // (void *cframe, int errcode) + | mov sp, CARG1 + | mov CRET1, CARG2 + |->vm_unwind_c_eh: // Landing pad for external unwinder. + | ldr L, SAVE_L + | mv_vmstate CARG4, C + | ldr GL:CARG3, L->glref + | str CARG4, GL:CARG3->vmstate + | b ->vm_leave_unw + | + |->vm_unwind_ff: // Unwind C stack, return from ff pcall. + | // (void *cframe) + | bic CARG1, CARG1, #~CFRAME_RAWMASK // Use two steps: bic sp is deprecated. + | mov sp, CARG1 + |->vm_unwind_ff_eh: // Landing pad for external unwinder. + | ldr L, SAVE_L + | mov MASKR8, #255 + | mov RC, #16 // 2 results: false + error message. + | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. + | ldr BASE, L->base + | ldr DISPATCH, L->glref // Setup pointer to dispatch table. + | mvn CARG1, #~LJ_TFALSE + | sub RA, BASE, #8 // Results start at BASE-8. + | ldr PC, [BASE, FRAME_PC] // Fetch PC of previous frame. + | add DISPATCH, DISPATCH, #GG_G2DISP + | mv_vmstate CARG2, INTERP + | str CARG1, [BASE, #-4] // Prepend false to error message. + | st_vmstate CARG2 + | b ->vm_returnc + | + |//----------------------------------------------------------------------- + |//-- Grow stack for calls ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_growstack_c: // Grow stack for C function. + | // CARG1 = L + | mov CARG2, #LUA_MINSTACK + | b >2 + | + |->vm_growstack_l: // Grow stack for Lua function. + | // BASE = new base, RA = BASE+framesize*8, RC = nargs*8, PC = first PC + | add RC, BASE, RC + | sub RA, RA, BASE + | mov CARG1, L + | str BASE, L->base + | add PC, PC, #4 // Must point after first instruction. + | str RC, L->top + | lsr CARG2, RA, #3 + |2: + | // L->base = new base, L->top = top + | str PC, SAVE_PC + | bl extern lj_state_growstack // (lua_State *L, int n) + | ldr BASE, L->base + | ldr RC, L->top + | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] + | sub NARGS8:RC, RC, BASE + | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC + | ins_callt // Just retry the call. + | + |//----------------------------------------------------------------------- + |//-- Entry points into the assembler VM --------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_resume: // Setup C frame and resume thread. + | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) + | saveregs + | mov L, CARG1 + | ldr DISPATCH, L:CARG1->glref // Setup pointer to dispatch table. + | mov BASE, CARG2 + | add DISPATCH, DISPATCH, #GG_G2DISP + | str L, SAVE_L + | mov PC, #FRAME_CP + | str CARG3, SAVE_NRES + | add CARG2, sp, #CFRAME_RESUME + | ldrb CARG1, L->status + | str CARG3, SAVE_ERRF + | str CARG2, L->cframe + | str CARG3, SAVE_CFRAME + | cmp CARG1, #0 + | str L, SAVE_PC // Any value outside of bytecode is ok. + | beq >3 + | + | // Resume after yield (like a return). + | mov RA, BASE + | ldr BASE, L->base + | ldr CARG1, L->top + | mov MASKR8, #255 + | strb CARG3, L->status + | sub RC, CARG1, BASE + | ldr PC, [BASE, FRAME_PC] + | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. + | mv_vmstate CARG2, INTERP + | add RC, RC, #8 + | ands CARG1, PC, #FRAME_TYPE + | st_vmstate CARG2 + | str RC, SAVE_MULTRES + | beq ->BC_RET_Z + | b ->vm_return + | + |->vm_pcall: // Setup protected C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) + | saveregs + | mov PC, #FRAME_CP + | str CARG4, SAVE_ERRF + | b >1 + | + |->vm_call: // Setup C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1) + | saveregs + | mov PC, #FRAME_C + | + |1: // Entry point for vm_pcall above (PC = ftype). + | ldr RC, L:CARG1->cframe + | str CARG3, SAVE_NRES + | mov L, CARG1 + | str CARG1, SAVE_L + | mov BASE, CARG2 + | str sp, L->cframe // Add our C frame to cframe chain. + | ldr DISPATCH, L->glref // Setup pointer to dispatch table. + | str CARG1, SAVE_PC // Any value outside of bytecode is ok. + | str RC, SAVE_CFRAME + | add DISPATCH, DISPATCH, #GG_G2DISP + | + |3: // Entry point for vm_cpcall/vm_resume (BASE = base, PC = ftype). + | ldr RB, L->base // RB = old base (for vmeta_call). + | ldr CARG1, L->top + | mov MASKR8, #255 + | add PC, PC, BASE + | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. + | sub PC, PC, RB // PC = frame delta + frame type + | mv_vmstate CARG2, INTERP + | sub NARGS8:RC, CARG1, BASE + | st_vmstate CARG2 + | + |->vm_call_dispatch: + | // RB = old base, BASE = new base, RC = nargs*8, PC = caller PC + | ldrd CARG34, [BASE, FRAME_FUNC] + | checkfunc CARG4, ->vmeta_call + | + |->vm_call_dispatch_f: + | ins_call + | // BASE = new base, CARG3 = func, RC = nargs*8, PC = caller PC + | + |->vm_cpcall: // Setup protected C frame, call C. + | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) + | saveregs + | mov L, CARG1 + | ldr RA, L:CARG1->stack + | str CARG1, SAVE_L + | ldr RB, L->top + | str CARG1, SAVE_PC // Any value outside of bytecode is ok. + | ldr RC, L->cframe + | sub RA, RA, RB // Compute -savestack(L, L->top). + | str sp, L->cframe // Add our C frame to cframe chain. + | mov RB, #0 + | str RA, SAVE_NRES // Neg. delta means cframe w/o frame. + | str RB, SAVE_ERRF // No error function. + | str RC, SAVE_CFRAME + | blx CARG4 // (lua_State *L, lua_CFunction func, void *ud) + | ldr DISPATCH, L->glref // Setup pointer to dispatch table. + | movs BASE, CRET1 + | mov PC, #FRAME_CP + | add DISPATCH, DISPATCH, #GG_G2DISP + | bne <3 // Else continue with the call. + | b ->vm_leave_cp // No base? Just remove C frame. + | + |//----------------------------------------------------------------------- + |//-- Metamethod handling ------------------------------------------------ + |//----------------------------------------------------------------------- + | + |//-- Continuation dispatch ---------------------------------------------- + | + |->cont_dispatch: + | // BASE = meta base, RA = resultptr, RC = (nresults+1)*8 + | ldr LFUNC:CARG3, [RB, FRAME_FUNC] + | ldr CARG1, [BASE, #-16] // Get continuation. + | mov CARG4, BASE + | mov BASE, RB // Restore caller BASE. + |.if FFI + | cmp CARG1, #1 + |.endif + | ldr PC, [CARG4, #-12] // Restore PC from [cont|PC]. + | ldr CARG3, LFUNC:CARG3->field_pc + | mvn INS, #~LJ_TNIL + | add CARG2, RA, RC + | str INS, [CARG2, #-4] // Ensure one valid arg. + |.if FFI + | bls >1 + |.endif + | ldr KBASE, [CARG3, #PC2PROTO(k)] + | // BASE = base, RA = resultptr, CARG4 = meta base + | bx CARG1 + | + |.if FFI + |1: + | beq ->cont_ffi_callback // cont = 1: return from FFI callback. + | // cont = 0: tailcall from C function. + | sub CARG4, CARG4, #16 + | sub RC, CARG4, BASE + | b ->vm_call_tail + |.endif + | + |->cont_cat: // RA = resultptr, CARG4 = meta base + | ldr INS, [PC, #-4] + | sub CARG2, CARG4, #16 + | ldrd CARG34, [RA] + | str BASE, L->base + | decode_RB8 RC, INS + | decode_RA8 RA, INS + | add CARG1, BASE, RC + | subs CARG1, CARG2, CARG1 + | strdne CARG34, [CARG2] + | movne CARG3, CARG1 + | bne ->BC_CAT_Z + | strd CARG34, [BASE, RA] + | b ->cont_nop + | + |//-- Table indexing metamethods ----------------------------------------- + | + |->vmeta_tgets1: + | add CARG2, BASE, RB + | b >2 + | + |->vmeta_tgets: + | sub CARG2, DISPATCH, #-DISPATCH_GL(tmptv) + | mvn CARG4, #~LJ_TTAB + | str TAB:RB, [CARG2] + | str CARG4, [CARG2, #4] + |2: + | mvn CARG4, #~LJ_TSTR + | str STR:RC, TMPDlo + | str CARG4, TMPDhi + | mov CARG3, TMPDp + | b >1 + | + |->vmeta_tgetb: // RC = index + | decode_RB8 RB, INS + | str RC, TMPDlo + | mvn CARG4, #~LJ_TISNUM + | add CARG2, BASE, RB + | str CARG4, TMPDhi + | mov CARG3, TMPDp + | b >1 + | + |->vmeta_tgetv: + | add CARG2, BASE, RB + | add CARG3, BASE, RC + |1: + | str BASE, L->base + | mov CARG1, L + | str PC, SAVE_PC + | bl extern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) + | // Returns TValue * (finished) or NULL (metamethod). + | .IOS ldr BASE, L->base + | cmp CRET1, #0 + | beq >3 + | ldrd CARG34, [CRET1] + | ins_next1 + | ins_next2 + | strd CARG34, [BASE, RA] + | ins_next3 + | + |3: // Call __index metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k + | rsb CARG1, BASE, #FRAME_CONT + | ldr BASE, L->top + | mov NARGS8:RC, #16 // 2 args for func(t, k). + | str PC, [BASE, #-12] // [cont|PC] + | add PC, CARG1, BASE + | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Guaranteed to be a function here. + | b ->vm_call_dispatch_f + | + |//----------------------------------------------------------------------- + | + |->vmeta_tsets1: + | add CARG2, BASE, RB + | b >2 + | + |->vmeta_tsets: + | sub CARG2, DISPATCH, #-DISPATCH_GL(tmptv) + | mvn CARG4, #~LJ_TTAB + | str TAB:RB, [CARG2] + | str CARG4, [CARG2, #4] + |2: + | mvn CARG4, #~LJ_TSTR + | str STR:RC, TMPDlo + | str CARG4, TMPDhi + | mov CARG3, TMPDp + | b >1 + | + |->vmeta_tsetb: // RC = index + | decode_RB8 RB, INS + | str RC, TMPDlo + | mvn CARG4, #~LJ_TISNUM + | add CARG2, BASE, RB + | str CARG4, TMPDhi + | mov CARG3, TMPDp + | b >1 + | + |->vmeta_tsetv: + | add CARG2, BASE, RB + | add CARG3, BASE, RC + |1: + | str BASE, L->base + | mov CARG1, L + | str PC, SAVE_PC + | bl extern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) + | // Returns TValue * (finished) or NULL (metamethod). + | .IOS ldr BASE, L->base + | cmp CRET1, #0 + | ldrd CARG34, [BASE, RA] + | beq >3 + | ins_next1 + | // NOBARRIER: lj_meta_tset ensures the table is not black. + | strd CARG34, [CRET1] + | ins_next2 + | ins_next3 + | + |3: // Call __newindex metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) + | rsb CARG1, BASE, #FRAME_CONT + | ldr BASE, L->top + | mov NARGS8:RC, #24 // 3 args for func(t, k, v). + | strd CARG34, [BASE, #16] // Copy value to third argument. + | str PC, [BASE, #-12] // [cont|PC] + | add PC, CARG1, BASE + | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Guaranteed to be a function here. + | b ->vm_call_dispatch_f + | + |//-- Comparison metamethods --------------------------------------------- + | + |->vmeta_comp: + | mov CARG1, L + | sub PC, PC, #4 + | mov CARG2, RA + | str BASE, L->base + | mov CARG3, RC + | str PC, SAVE_PC + | decode_OP CARG4, INS + | bl extern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) + | // Returns 0/1 or TValue * (metamethod). + |3: + | .IOS ldr BASE, L->base + | cmp CRET1, #1 + | bhi ->vmeta_binop + |4: + | ldrh RB, [PC, #2] + | add PC, PC, #4 + | add RB, PC, RB, lsl #2 + | subhs PC, RB, #0x20000 + |->cont_nop: + | ins_next + | + |->cont_ra: // RA = resultptr + | ldr INS, [PC, #-4] + | ldrd CARG12, [RA] + | decode_RA8 CARG3, INS + | strd CARG12, [BASE, CARG3] + | b ->cont_nop + | + |->cont_condt: // RA = resultptr + | ldr CARG2, [RA, #4] + | mvn CARG1, #~LJ_TTRUE + | cmp CARG1, CARG2 // Branch if result is true. + | b <4 + | + |->cont_condf: // RA = resultptr + | ldr CARG2, [RA, #4] + | checktp CARG2, LJ_TFALSE // Branch if result is false. + | b <4 + | + |->vmeta_equal: + | // CARG2, CARG3, CARG4 are already set by BC_ISEQV/BC_ISNEV. + | sub PC, PC, #4 + | str BASE, L->base + | mov CARG1, L + | str PC, SAVE_PC + | bl extern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) + | // Returns 0/1 or TValue * (metamethod). + | b <3 + | + |->vmeta_equal_cd: + |.if FFI + | sub PC, PC, #4 + | str BASE, L->base + | mov CARG1, L + | mov CARG2, INS + | str PC, SAVE_PC + | bl extern lj_meta_equal_cd // (lua_State *L, BCIns op) + | // Returns 0/1 or TValue * (metamethod). + | b <3 + |.endif + | + |//-- Arithmetic metamethods --------------------------------------------- + | + |->vmeta_arith_vn: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | add CARG3, BASE, RB + | add CARG4, KBASE, RC + | b >1 + | + |->vmeta_arith_nv: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | add CARG4, BASE, RB + | add CARG3, KBASE, RC + | b >1 + | + |->vmeta_unm: + | ldr INS, [PC, #-8] + | sub PC, PC, #4 + | add CARG3, BASE, RC + | add CARG4, BASE, RC + | b >1 + | + |->vmeta_arith_vv: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | add CARG3, BASE, RB + | add CARG4, BASE, RC + |1: + | decode_OP OP, INS + | add CARG2, BASE, RA + | str BASE, L->base + | mov CARG1, L + | str PC, SAVE_PC + | str OP, ARG5 + | bl extern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) + | // Returns NULL (finished) or TValue * (metamethod). + | .IOS ldr BASE, L->base + | cmp CRET1, #0 + | beq ->cont_nop + | + | // Call metamethod for binary op. + |->vmeta_binop: + | // BASE = old base, CRET1 = new base, stack = cont/func/o1/o2 + | sub CARG2, CRET1, BASE + | str PC, [CRET1, #-12] // [cont|PC] + | add PC, CARG2, #FRAME_CONT + | mov BASE, CRET1 + | mov NARGS8:RC, #16 // 2 args for func(o1, o2). + | b ->vm_call_dispatch + | + |->vmeta_len: + | add CARG2, BASE, RC + | str BASE, L->base + | mov CARG1, L + | str PC, SAVE_PC + | bl extern lj_meta_len // (lua_State *L, TValue *o) + | // Returns NULL (retry) or TValue * (metamethod base). + | .IOS ldr BASE, L->base +#if LJ_52 + | cmp CRET1, #0 + | bne ->vmeta_binop // Binop call for compatibility. + | ldr TAB:CARG1, [BASE, RC] + | b ->BC_LEN_Z +#else + | b ->vmeta_binop // Binop call for compatibility. +#endif + | + |//-- Call metamethod ---------------------------------------------------- + | + |->vmeta_call: // Resolve and call __call metamethod. + | // RB = old base, BASE = new base, RC = nargs*8 + | mov CARG1, L + | str RB, L->base // This is the callers base! + | sub CARG2, BASE, #8 + | str PC, SAVE_PC + | add CARG3, BASE, NARGS8:RC + | .IOS mov RA, BASE + | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) + | .IOS mov BASE, RA + | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Guaranteed to be a function here. + | add NARGS8:RC, NARGS8:RC, #8 // Got one more argument now. + | ins_call + | + |->vmeta_callt: // Resolve __call for BC_CALLT. + | // BASE = old base, RA = new base, RC = nargs*8 + | mov CARG1, L + | str BASE, L->base + | sub CARG2, RA, #8 + | str PC, SAVE_PC + | add CARG3, RA, NARGS8:RC + | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) + | .IOS ldr BASE, L->base + | ldr LFUNC:CARG3, [RA, FRAME_FUNC] // Guaranteed to be a function here. + | ldr PC, [BASE, FRAME_PC] + | add NARGS8:RC, NARGS8:RC, #8 // Got one more argument now. + | b ->BC_CALLT2_Z + | + |//-- Argument coercion for 'for' statement ------------------------------ + | + |->vmeta_for: + | mov CARG1, L + | str BASE, L->base + | mov CARG2, RA + | str PC, SAVE_PC + | bl extern lj_meta_for // (lua_State *L, TValue *base) + | .IOS ldr BASE, L->base + |.if JIT + | ldrb OP, [PC, #-4] + |.endif + | ldr INS, [PC, #-4] + |.if JIT + | cmp OP, #BC_JFORI + |.endif + | decode_RA8 RA, INS + | decode_RD RC, INS + |.if JIT + | beq =>BC_JFORI + |.endif + | b =>BC_FORI + | + |//----------------------------------------------------------------------- + |//-- Fast functions ----------------------------------------------------- + |//----------------------------------------------------------------------- + | + |.macro .ffunc, name + |->ff_ .. name: + |.endmacro + | + |.macro .ffunc_1, name + |->ff_ .. name: + | ldrd CARG12, [BASE] + | cmp NARGS8:RC, #8 + | blo ->fff_fallback + |.endmacro + | + |.macro .ffunc_2, name + |->ff_ .. name: + | ldrd CARG12, [BASE] + | ldrd CARG34, [BASE, #8] + | cmp NARGS8:RC, #16 + | blo ->fff_fallback + |.endmacro + | + |.macro .ffunc_n, name + | .ffunc_1 name + | checktp CARG2, LJ_TISNUM + | bhs ->fff_fallback + |.endmacro + | + |.macro .ffunc_nn, name + | .ffunc_2 name + | checktp CARG2, LJ_TISNUM + | cmnlo CARG4, #-LJ_TISNUM + | bhs ->fff_fallback + |.endmacro + | + |.macro .ffunc_d, name + | .ffunc name + | ldr CARG2, [BASE, #4] + | cmp NARGS8:RC, #8 + | vldr d0, [BASE] + | blo ->fff_fallback + | checktp CARG2, LJ_TISNUM + | bhs ->fff_fallback + |.endmacro + | + |.macro .ffunc_dd, name + | .ffunc name + | ldr CARG2, [BASE, #4] + | ldr CARG4, [BASE, #12] + | cmp NARGS8:RC, #16 + | vldr d0, [BASE] + | vldr d1, [BASE, #8] + | blo ->fff_fallback + | checktp CARG2, LJ_TISNUM + | cmnlo CARG4, #-LJ_TISNUM + | bhs ->fff_fallback + |.endmacro + | + |// Inlined GC threshold check. Caveat: uses CARG1 and CARG2. + |.macro ffgccheck + | ldr CARG1, [DISPATCH, #DISPATCH_GL(gc.total)] + | ldr CARG2, [DISPATCH, #DISPATCH_GL(gc.threshold)] + | cmp CARG1, CARG2 + | blge ->fff_gcstep + |.endmacro + | + |//-- Base library: checks ----------------------------------------------- + | + |.ffunc_1 assert + | checktp CARG2, LJ_TTRUE + | bhi ->fff_fallback + | ldr PC, [BASE, FRAME_PC] + | strd CARG12, [BASE, #-8] + | mov RB, BASE + | subs RA, NARGS8:RC, #8 + | add RC, NARGS8:RC, #8 // Compute (nresults+1)*8. + | beq ->fff_res // Done if exactly 1 argument. + |1: + | ldrd CARG12, [RB, #8] + | subs RA, RA, #8 + | strd CARG12, [RB], #8 + | bne <1 + | b ->fff_res + | + |.ffunc type + | ldr CARG2, [BASE, #4] + | cmp NARGS8:RC, #8 + | blo ->fff_fallback + | checktp CARG2, LJ_TISNUM + | mvnlo CARG2, #~LJ_TISNUM + | rsb CARG4, CARG2, #(int)(offsetof(GCfuncC, upvalue)>>3)-1 + | lsl CARG4, CARG4, #3 + | ldrd CARG12, [CFUNC:CARG3, CARG4] + | b ->fff_restv + | + |//-- Base library: getters and setters --------------------------------- + | + |.ffunc_1 getmetatable + | checktp CARG2, LJ_TTAB + | cmnne CARG2, #-LJ_TUDATA + | bne >6 + |1: // Field metatable must be at same offset for GCtab and GCudata! + | ldr TAB:RB, TAB:CARG1->metatable + |2: + | mvn CARG2, #~LJ_TNIL + | ldr STR:RC, [DISPATCH, #DISPATCH_GL(gcroot[GCROOT_MMNAME+MM_metatable])] + | cmp TAB:RB, #0 + | beq ->fff_restv + | ldr CARG3, TAB:RB->hmask + | ldr CARG4, STR:RC->hash + | ldr NODE:INS, TAB:RB->node + | and CARG3, CARG3, CARG4 // idx = str->hash & tab->hmask + | add CARG3, CARG3, CARG3, lsl #1 + | add NODE:INS, NODE:INS, CARG3, lsl #3 // node = tab->node + idx*3*8 + |3: // Rearranged logic, because we expect _not_ to find the key. + | ldrd CARG34, NODE:INS->key // STALL: early NODE:INS. + | ldrd CARG12, NODE:INS->val + | ldr NODE:INS, NODE:INS->next + | checktp CARG4, LJ_TSTR + | cmpeq CARG3, STR:RC + | beq >5 + | cmp NODE:INS, #0 + | bne <3 + |4: + | mov CARG1, RB // Use metatable as default result. + | mvn CARG2, #~LJ_TTAB + | b ->fff_restv + |5: + | checktp CARG2, LJ_TNIL + | bne ->fff_restv + | b <4 + | + |6: + | checktp CARG2, LJ_TISNUM + | mvnhs CARG2, CARG2 + | movlo CARG2, #~LJ_TISNUM + | add CARG4, DISPATCH, CARG2, lsl #2 + | ldr TAB:RB, [CARG4, #DISPATCH_GL(gcroot[GCROOT_BASEMT])] + | b <2 + | + |.ffunc_2 setmetatable + | // Fast path: no mt for table yet and not clearing the mt. + | checktp CARG2, LJ_TTAB + | ldreq TAB:RB, TAB:CARG1->metatable + | checktpeq CARG4, LJ_TTAB + | ldrbeq CARG4, TAB:CARG1->marked + | cmpeq TAB:RB, #0 + | bne ->fff_fallback + | tst CARG4, #LJ_GC_BLACK // isblack(table) + | str TAB:CARG3, TAB:CARG1->metatable + | beq ->fff_restv + | barrierback TAB:CARG1, CARG4, CARG3 + | b ->fff_restv + | + |.ffunc rawget + | ldrd CARG34, [BASE] + | cmp NARGS8:RC, #16 + | blo ->fff_fallback + | mov CARG2, CARG3 + | checktab CARG4, ->fff_fallback + | mov CARG1, L + | add CARG3, BASE, #8 + | .IOS mov RA, BASE + | bl extern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) + | // Returns cTValue *. + | .IOS mov BASE, RA + | ldrd CARG12, [CRET1] + | b ->fff_restv + | + |//-- Base library: conversions ------------------------------------------ + | + |.ffunc tonumber + | // Only handles the number case inline (without a base argument). + | ldrd CARG12, [BASE] + | cmp NARGS8:RC, #8 + | bne ->fff_fallback + | checktp CARG2, LJ_TISNUM + | bls ->fff_restv + | b ->fff_fallback + | + |.ffunc_1 tostring + | // Only handles the string or number case inline. + | checktp CARG2, LJ_TSTR + | // A __tostring method in the string base metatable is ignored. + | beq ->fff_restv + | // Handle numbers inline, unless a number base metatable is present. + | ldr CARG4, [DISPATCH, #DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])] + | str BASE, L->base + | checktp CARG2, LJ_TISNUM + | cmpls CARG4, #0 + | str PC, SAVE_PC // Redundant (but a defined value). + | bhi ->fff_fallback + | ffgccheck + | mov CARG1, L + | mov CARG2, BASE + | bl extern lj_str_fromnumber // (lua_State *L, cTValue *o) + | // Returns GCstr *. + | ldr BASE, L->base + | mvn CARG2, #~LJ_TSTR + | b ->fff_restv + | + |//-- Base library: iterators ------------------------------------------- + | + |.ffunc_1 next + | mvn CARG4, #~LJ_TNIL + | checktab CARG2, ->fff_fallback + | strd CARG34, [BASE, NARGS8:RC] // Set missing 2nd arg to nil. + | ldr PC, [BASE, FRAME_PC] + | mov CARG2, CARG1 + | str BASE, L->base // Add frame since C call can throw. + | mov CARG1, L + | str BASE, L->top // Dummy frame length is ok. + | add CARG3, BASE, #8 + | str PC, SAVE_PC + | bl extern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) + | // Returns 0 at end of traversal. + | .IOS ldr BASE, L->base + | cmp CRET1, #0 + | mvneq CRET2, #~LJ_TNIL + | beq ->fff_restv // End of traversal: return nil. + | ldrd CARG12, [BASE, #8] // Copy key and value to results. + | ldrd CARG34, [BASE, #16] + | mov RC, #(2+1)*8 + | strd CARG12, [BASE, #-8] + | strd CARG34, [BASE] + | b ->fff_res + | + |.ffunc_1 pairs + | checktab CARG2, ->fff_fallback +#if LJ_52 + | ldr TAB:RB, TAB:CARG1->metatable +#endif + | ldrd CFUNC:CARG34, CFUNC:CARG3->upvalue[0] + | ldr PC, [BASE, FRAME_PC] +#if LJ_52 + | cmp TAB:RB, #0 + | bne ->fff_fallback +#endif + | mvn CARG2, #~LJ_TNIL + | mov RC, #(3+1)*8 + | strd CFUNC:CARG34, [BASE, #-8] + | str CARG2, [BASE, #12] + | b ->fff_res + | + |.ffunc_2 ipairs_aux + | checktp CARG2, LJ_TTAB + | checktpeq CARG4, LJ_TISNUM + | bne ->fff_fallback + | ldr RB, TAB:CARG1->asize + | ldr RC, TAB:CARG1->array + | add CARG3, CARG3, #1 + | ldr PC, [BASE, FRAME_PC] + | cmp CARG3, RB + | add RC, RC, CARG3, lsl #3 + | strd CARG34, [BASE, #-8] + | ldrdlo CARG12, [RC] + | mov RC, #(0+1)*8 + | bhs >2 // Not in array part? + |1: + | checktp CARG2, LJ_TNIL + | movne RC, #(2+1)*8 + | strdne CARG12, [BASE] + | b ->fff_res + |2: // Check for empty hash part first. Otherwise call C function. + | ldr RB, TAB:CARG1->hmask + | mov CARG2, CARG3 + | cmp RB, #0 + | beq ->fff_res + | .IOS mov RA, BASE + | bl extern lj_tab_getinth // (GCtab *t, int32_t key) + | // Returns cTValue * or NULL. + | .IOS mov BASE, RA + | cmp CRET1, #0 + | beq ->fff_res + | ldrd CARG12, [CRET1] + | b <1 + | + |.ffunc_1 ipairs + | checktab CARG2, ->fff_fallback +#if LJ_52 + | ldr TAB:RB, TAB:CARG1->metatable +#endif + | ldrd CFUNC:CARG34, CFUNC:CARG3->upvalue[0] + | ldr PC, [BASE, FRAME_PC] +#if LJ_52 + | cmp TAB:RB, #0 + | bne ->fff_fallback +#endif + | mov CARG1, #0 + | mvn CARG2, #~LJ_TISNUM + | mov RC, #(3+1)*8 + | strd CFUNC:CARG34, [BASE, #-8] + | strd CARG12, [BASE, #8] + | b ->fff_res + | + |//-- Base library: catch errors ---------------------------------------- + | + |.ffunc pcall + | ldrb RA, [DISPATCH, #DISPATCH_GL(hookmask)] + | cmp NARGS8:RC, #8 + | blo ->fff_fallback + | tst RA, #HOOK_ACTIVE // Remember active hook before pcall. + | mov RB, BASE + | add BASE, BASE, #8 + | moveq PC, #8+FRAME_PCALL + | movne PC, #8+FRAME_PCALLH + | sub NARGS8:RC, NARGS8:RC, #8 + | b ->vm_call_dispatch + | + |.ffunc_2 xpcall + | ldrb RA, [DISPATCH, #DISPATCH_GL(hookmask)] + | checkfunc CARG4, ->fff_fallback // Traceback must be a function. + | mov RB, BASE + | strd CARG12, [BASE, #8] // Swap function and traceback. + | strd CARG34, [BASE] + | tst RA, #HOOK_ACTIVE // Remember active hook before pcall. + | add BASE, BASE, #16 + | moveq PC, #16+FRAME_PCALL + | movne PC, #16+FRAME_PCALLH + | sub NARGS8:RC, NARGS8:RC, #16 + | b ->vm_call_dispatch + | + |//-- Coroutine library -------------------------------------------------- + | + |.macro coroutine_resume_wrap, resume + |.if resume + |.ffunc_1 coroutine_resume + | checktp CARG2, LJ_TTHREAD + | bne ->fff_fallback + |.else + |.ffunc coroutine_wrap_aux + | ldr L:CARG1, CFUNC:CARG3->upvalue[0].gcr + |.endif + | ldr PC, [BASE, FRAME_PC] + | str BASE, L->base + | ldr CARG2, L:CARG1->top + | ldrb RA, L:CARG1->status + | ldr RB, L:CARG1->base + | add CARG3, CARG2, NARGS8:RC + | add CARG4, CARG2, RA + | str PC, SAVE_PC + | cmp CARG4, RB + | beq ->fff_fallback + | ldr CARG4, L:CARG1->maxstack + | ldr RB, L:CARG1->cframe + | cmp RA, #LUA_YIELD + | cmpls CARG3, CARG4 + | cmpls RB, #0 + | bhi ->fff_fallback + |1: + |.if resume + | sub CARG3, CARG3, #8 // Keep resumed thread in stack for GC. + | add BASE, BASE, #8 + | sub NARGS8:RC, NARGS8:RC, #8 + |.endif + | str CARG3, L:CARG1->top + | str BASE, L->top + |2: // Move args to coroutine. + | ldrd CARG34, [BASE, RB] + | cmp RB, NARGS8:RC + | strdne CARG34, [CARG2, RB] + | add RB, RB, #8 + | bne <2 + | + | mov CARG3, #0 + | mov L:RA, L:CARG1 + | mov CARG4, #0 + | bl ->vm_resume // (lua_State *L, TValue *base, 0, 0) + | // Returns thread status. + |4: + | ldr CARG3, L:RA->base + | mv_vmstate CARG2, INTERP + | ldr CARG4, L:RA->top + | st_vmstate CARG2 + | cmp CRET1, #LUA_YIELD + | ldr BASE, L->base + | bhi >8 + | subs RC, CARG4, CARG3 + | ldr CARG1, L->maxstack + | add CARG2, BASE, RC + | beq >6 // No results? + | cmp CARG2, CARG1 + | mov RB, #0 + | bhi >9 // Need to grow stack? + | + | sub CARG4, RC, #8 + | str CARG3, L:RA->top // Clear coroutine stack. + |5: // Move results from coroutine. + | ldrd CARG12, [CARG3, RB] + | cmp RB, CARG4 + | strd CARG12, [BASE, RB] + | add RB, RB, #8 + | bne <5 + |6: + |.if resume + | mvn CARG3, #~LJ_TTRUE + | add RC, RC, #16 + |7: + | str CARG3, [BASE, #-4] // Prepend true/false to results. + | sub RA, BASE, #8 + |.else + | mov RA, BASE + | add RC, RC, #8 + |.endif + | ands CARG1, PC, #FRAME_TYPE + | str PC, SAVE_PC + | str RC, SAVE_MULTRES + | beq ->BC_RET_Z + | b ->vm_return + | + |8: // Coroutine returned with error (at co->top-1). + |.if resume + | ldrd CARG12, [CARG4, #-8]! + | mvn CARG3, #~LJ_TFALSE + | mov RC, #(2+1)*8 + | str CARG4, L:RA->top // Remove error from coroutine stack. + | strd CARG12, [BASE] // Copy error message. + | b <7 + |.else + | mov CARG1, L + | mov CARG2, L:RA + | bl extern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co) + | // Never returns. + |.endif + | + |9: // Handle stack expansion on return from yield. + | mov CARG1, L + | lsr CARG2, RC, #3 + | bl extern lj_state_growstack // (lua_State *L, int n) + | mov CRET1, #0 + | b <4 + |.endmacro + | + | coroutine_resume_wrap 1 // coroutine.resume + | coroutine_resume_wrap 0 // coroutine.wrap + | + |.ffunc coroutine_yield + | ldr CARG1, L->cframe + | add CARG2, BASE, NARGS8:RC + | str BASE, L->base + | tst CARG1, #CFRAME_RESUME + | str CARG2, L->top + | mov CRET1, #LUA_YIELD + | mov CARG3, #0 + | beq ->fff_fallback + | str CARG3, L->cframe + | strb CRET1, L->status + | b ->vm_leave_unw + | + |//-- Math library ------------------------------------------------------- + | + |.macro math_round, func + | .ffunc_1 math_ .. func + | checktp CARG2, LJ_TISNUM + | beq ->fff_restv + | bhi ->fff_fallback + | // Round FP value and normalize result. + | lsl CARG3, CARG2, #1 + | adds RB, CARG3, #0x00200000 + | bpl >2 // |x| < 1? + | mvn CARG4, #0x3e0 + | subs RB, CARG4, RB, asr #21 + | lsl CARG4, CARG2, #11 + | lsl CARG3, CARG1, #11 + | orr CARG4, CARG4, #0x80000000 + | rsb INS, RB, #32 + | orr CARG4, CARG4, CARG1, lsr #21 + | bls >3 // |x| >= 2^31? + | orr CARG3, CARG3, CARG4, lsl INS + | lsr CARG1, CARG4, RB + |.if "func" == "floor" + | tst CARG3, CARG2, asr #31 + | addne CARG1, CARG1, #1 + |.else + | bics CARG3, CARG3, CARG2, asr #31 + | addsne CARG1, CARG1, #1 + | ldrdvs CARG12, >9 + | bvs ->fff_restv + |.endif + | cmp CARG2, #0 + | rsblt CARG1, CARG1, #0 + |1: + | mvn CARG2, #~LJ_TISNUM + | b ->fff_restv + | + |2: // |x| < 1 + | bcs ->fff_restv // |x| is not finite. + | orr CARG3, CARG3, CARG1 // ztest = abs(hi) | lo + |.if "func" == "floor" + | tst CARG3, CARG2, asr #31 // return (ztest & sign) == 0 ? 0 : -1 + | moveq CARG1, #0 + | mvnne CARG1, #0 + |.else + | bics CARG3, CARG3, CARG2, asr #31 // return (ztest & ~sign) == 0 ? 0 : 1 + | moveq CARG1, #0 + | movne CARG1, #1 + |.endif + | mvn CARG2, #~LJ_TISNUM + | b ->fff_restv + | + |3: // |x| >= 2^31. Check for x == -(2^31). + | cmpeq CARG4, #0x80000000 + |.if "func" == "floor" + | cmpeq CARG3, #0 + |.endif + | bne >4 + | cmp CARG2, #0 + | movmi CARG1, #0x80000000 + | bmi <1 + |4: + | bl ->vm_..func.._sf + | b ->fff_restv + |.endmacro + | + | math_round floor + | math_round ceil + | + |.align 8 + |9: + | .long 0x00000000, 0x41e00000 // 2^31. + | + |.ffunc_1 math_abs + | checktp CARG2, LJ_TISNUM + | bhi ->fff_fallback + | bicne CARG2, CARG2, #0x80000000 + | bne ->fff_restv + | cmp CARG1, #0 + | rsbslt CARG1, CARG1, #0 + | ldrdvs CARG12, <9 + | // Fallthrough. + | + |->fff_restv: + | // CARG12 = TValue result. + | ldr PC, [BASE, FRAME_PC] + | strd CARG12, [BASE, #-8] + |->fff_res1: + | // PC = return. + | mov RC, #(1+1)*8 + |->fff_res: + | // RC = (nresults+1)*8, PC = return. + | ands CARG1, PC, #FRAME_TYPE + | ldreq INS, [PC, #-4] + | str RC, SAVE_MULTRES + | sub RA, BASE, #8 + | bne ->vm_return + | decode_RB8 RB, INS + |5: + | cmp RB, RC // More results expected? + | bhi >6 + | decode_RA8 CARG1, INS + | ins_next1 + | ins_next2 + | // Adjust BASE. KBASE is assumed to be set for the calling frame. + | sub BASE, RA, CARG1 + | ins_next3 + | + |6: // Fill up results with nil. + | add CARG2, RA, RC + | mvn CARG1, #~LJ_TNIL + | add RC, RC, #8 + | str CARG1, [CARG2, #-4] + | b <5 + | + |.macro math_extern, func + |.if HFABI + | .ffunc_d math_ .. func + |.else + | .ffunc_n math_ .. func + |.endif + | .IOS mov RA, BASE + | bl extern func + | .IOS mov BASE, RA + |.if HFABI + | b ->fff_resd + |.else + | b ->fff_restv + |.endif + |.endmacro + | + |.macro math_extern2, func + |.if HFABI + | .ffunc_dd math_ .. func + |.else + | .ffunc_nn math_ .. func + |.endif + | .IOS mov RA, BASE + | bl extern func + | .IOS mov BASE, RA + |.if HFABI + | b ->fff_resd + |.else + | b ->fff_restv + |.endif + |.endmacro + | + |.if FPU + | .ffunc_d math_sqrt + | vsqrt.f64 d0, d0 + |->fff_resd: + | ldr PC, [BASE, FRAME_PC] + | vstr d0, [BASE, #-8] + | b ->fff_res1 + |.else + | math_extern sqrt + |.endif + | + |.ffunc math_log + |.if HFABI + | ldr CARG2, [BASE, #4] + | cmp NARGS8:RC, #8 // Need exactly 1 argument. + | vldr d0, [BASE] + | bne ->fff_fallback + |.else + | ldrd CARG12, [BASE] + | cmp NARGS8:RC, #8 // Need exactly 1 argument. + | bne ->fff_fallback + |.endif + | checktp CARG2, LJ_TISNUM + | bhs ->fff_fallback + | .IOS mov RA, BASE + | bl extern log + | .IOS mov BASE, RA + |.if HFABI + | b ->fff_resd + |.else + | b ->fff_restv + |.endif + | + | math_extern log10 + | math_extern exp + | math_extern sin + | math_extern cos + | math_extern tan + | math_extern asin + | math_extern acos + | math_extern atan + | math_extern sinh + | math_extern cosh + | math_extern tanh + | math_extern2 pow + | math_extern2 atan2 + | math_extern2 fmod + | + |->ff_math_deg: + |.if FPU + | .ffunc_d math_rad + | vldr d1, CFUNC:CARG3->upvalue[0] + | vmul.f64 d0, d0, d1 + | b ->fff_resd + |.else + | .ffunc_n math_rad + | ldrd CARG34, CFUNC:CARG3->upvalue[0] + | bl extern __aeabi_dmul + | b ->fff_restv + |.endif + | + |.if HFABI + | .ffunc math_ldexp + | ldr CARG4, [BASE, #4] + | ldrd CARG12, [BASE, #8] + | cmp NARGS8:RC, #16 + | blo ->fff_fallback + | vldr d0, [BASE] + | checktp CARG4, LJ_TISNUM + | bhs ->fff_fallback + | checktp CARG2, LJ_TISNUM + | bne ->fff_fallback + | .IOS mov RA, BASE + | bl extern ldexp // (double x, int exp) + | .IOS mov BASE, RA + | b ->fff_resd + |.else + |.ffunc_2 math_ldexp + | checktp CARG2, LJ_TISNUM + | bhs ->fff_fallback + | checktp CARG4, LJ_TISNUM + | bne ->fff_fallback + | .IOS mov RA, BASE + | bl extern ldexp // (double x, int exp) + | .IOS mov BASE, RA + | b ->fff_restv + |.endif + | + |.if HFABI + |.ffunc_d math_frexp + | mov CARG1, sp + | .IOS mov RA, BASE + | bl extern frexp + | .IOS mov BASE, RA + | ldr CARG3, [sp] + | mvn CARG4, #~LJ_TISNUM + | ldr PC, [BASE, FRAME_PC] + | vstr d0, [BASE, #-8] + | mov RC, #(2+1)*8 + | strd CARG34, [BASE] + | b ->fff_res + |.else + |.ffunc_n math_frexp + | mov CARG3, sp + | .IOS mov RA, BASE + | bl extern frexp + | .IOS mov BASE, RA + | ldr CARG3, [sp] + | mvn CARG4, #~LJ_TISNUM + | ldr PC, [BASE, FRAME_PC] + | strd CARG12, [BASE, #-8] + | mov RC, #(2+1)*8 + | strd CARG34, [BASE] + | b ->fff_res + |.endif + | + |.if HFABI + |.ffunc_d math_modf + | sub CARG1, BASE, #8 + | ldr PC, [BASE, FRAME_PC] + | .IOS mov RA, BASE + | bl extern modf + | .IOS mov BASE, RA + | mov RC, #(2+1)*8 + | vstr d0, [BASE] + | b ->fff_res + |.else + |.ffunc_n math_modf + | sub CARG3, BASE, #8 + | ldr PC, [BASE, FRAME_PC] + | .IOS mov RA, BASE + | bl extern modf + | .IOS mov BASE, RA + | mov RC, #(2+1)*8 + | strd CARG12, [BASE] + | b ->fff_res + |.endif + | + |.macro math_minmax, name, cond, fcond + |.if FPU + | .ffunc_1 name + | add RB, BASE, RC + | checktp CARG2, LJ_TISNUM + | add RA, BASE, #8 + | bne >4 + |1: // Handle integers. + | ldrd CARG34, [RA] + | cmp RA, RB + | bhs ->fff_restv + | checktp CARG4, LJ_TISNUM + | bne >3 + | cmp CARG1, CARG3 + | add RA, RA, #8 + | mov..cond CARG1, CARG3 + | b <1 + |3: // Convert intermediate result to number and continue below. + | vmov s4, CARG1 + | bhi ->fff_fallback + | vldr d1, [RA] + | vcvt.f64.s32 d0, s4 + | b >6 + | + |4: + | vldr d0, [BASE] + | bhi ->fff_fallback + |5: // Handle numbers. + | ldrd CARG34, [RA] + | vldr d1, [RA] + | cmp RA, RB + | bhs ->fff_resd + | checktp CARG4, LJ_TISNUM + | bhs >7 + |6: + | vcmp.f64 d0, d1 + | vmrs + | add RA, RA, #8 + | vmov..fcond.f64 d0, d1 + | b <5 + |7: // Convert integer to number and continue above. + | vmov s4, CARG3 + | bhi ->fff_fallback + | vcvt.f64.s32 d1, s4 + | b <6 + | + |.else + | + | .ffunc_1 name + | checktp CARG2, LJ_TISNUM + | mov RA, #8 + | bne >4 + |1: // Handle integers. + | ldrd CARG34, [BASE, RA] + | cmp RA, RC + | bhs ->fff_restv + | checktp CARG4, LJ_TISNUM + | bne >3 + | cmp CARG1, CARG3 + | add RA, RA, #8 + | mov..cond CARG1, CARG3 + | b <1 + |3: // Convert intermediate result to number and continue below. + | bhi ->fff_fallback + | bl extern __aeabi_i2d + | ldrd CARG34, [BASE, RA] + | b >6 + | + |4: + | bhi ->fff_fallback + |5: // Handle numbers. + | ldrd CARG34, [BASE, RA] + | cmp RA, RC + | bhs ->fff_restv + | checktp CARG4, LJ_TISNUM + | bhs >7 + |6: + | bl extern __aeabi_cdcmple + | add RA, RA, #8 + | mov..fcond CARG1, CARG3 + | mov..fcond CARG2, CARG4 + | b <5 + |7: // Convert integer to number and continue above. + | bhi ->fff_fallback + | strd CARG12, TMPD + | mov CARG1, CARG3 + | bl extern __aeabi_i2d + | ldrd CARG34, TMPD + | b <6 + |.endif + |.endmacro + | + | math_minmax math_min, gt, hi + | math_minmax math_max, lt, lo + | + |//-- String library ----------------------------------------------------- + | + |.ffunc_1 string_len + | checkstr CARG2, ->fff_fallback + | ldr CARG1, STR:CARG1->len + | mvn CARG2, #~LJ_TISNUM + | b ->fff_restv + | + |.ffunc string_byte // Only handle the 1-arg case here. + | ldrd CARG12, [BASE] + | ldr PC, [BASE, FRAME_PC] + | cmp NARGS8:RC, #8 + | checktpeq CARG2, LJ_TSTR // Need exactly 1 argument. + | bne ->fff_fallback + | ldr CARG3, STR:CARG1->len + | ldrb CARG1, STR:CARG1[1] // Access is always ok (NUL at end). + | mvn CARG2, #~LJ_TISNUM + | cmp CARG3, #0 + | moveq RC, #(0+1)*8 + | movne RC, #(1+1)*8 + | strd CARG12, [BASE, #-8] + | b ->fff_res + | + |.ffunc string_char // Only handle the 1-arg case here. + | ffgccheck + | ldrd CARG12, [BASE] + | ldr PC, [BASE, FRAME_PC] + | cmp NARGS8:RC, #8 // Need exactly 1 argument. + | checktpeq CARG2, LJ_TISNUM + | bicseq CARG4, CARG1, #255 + | mov CARG3, #1 + | bne ->fff_fallback + | str CARG1, TMPD + | mov CARG2, TMPDp // Points to stack. Little-endian. + |->fff_newstr: + | // CARG2 = str, CARG3 = len. + | str BASE, L->base + | mov CARG1, L + | str PC, SAVE_PC + | bl extern lj_str_new // (lua_State *L, char *str, size_t l) + | // Returns GCstr *. + | ldr BASE, L->base + | mvn CARG2, #~LJ_TSTR + | b ->fff_restv + | + |.ffunc string_sub + | ffgccheck + | ldrd CARG12, [BASE] + | ldrd CARG34, [BASE, #16] + | cmp NARGS8:RC, #16 + | mvn RB, #0 + | beq >1 + | blo ->fff_fallback + | checktp CARG4, LJ_TISNUM + | mov RB, CARG3 + | bne ->fff_fallback + |1: + | ldrd CARG34, [BASE, #8] + | checktp CARG2, LJ_TSTR + | ldreq CARG2, STR:CARG1->len + | checktpeq CARG4, LJ_TISNUM + | bne ->fff_fallback + | // CARG1 = str, CARG2 = str->len, CARG3 = start, RB = end + | add CARG4, CARG2, #1 + | cmp CARG3, #0 // if (start < 0) start += len+1 + | addlt CARG3, CARG3, CARG4 + | cmp CARG3, #1 // if (start < 1) start = 1 + | movlt CARG3, #1 + | cmp RB, #0 // if (end < 0) end += len+1 + | addlt RB, RB, CARG4 + | bic RB, RB, RB, asr #31 // if (end < 0) end = 0 + | cmp RB, CARG2 // if (end > len) end = len + | add CARG1, STR:CARG1, #sizeof(GCstr)-1 + | movgt RB, CARG2 + | add CARG2, CARG1, CARG3 + | subs CARG3, RB, CARG3 // len = end - start + | add CARG3, CARG3, #1 // len += 1 + | bge ->fff_newstr + |->fff_emptystr: + | sub STR:CARG1, DISPATCH, #-DISPATCH_GL(strempty) + | mvn CARG2, #~LJ_TSTR + | b ->fff_restv + | + |.ffunc string_rep // Only handle the 1-char case inline. + | ffgccheck + | ldrd CARG12, [BASE] + | ldrd CARG34, [BASE, #8] + | cmp NARGS8:RC, #16 + | bne ->fff_fallback // Exactly 2 arguments + | checktp CARG2, LJ_TSTR + | checktpeq CARG4, LJ_TISNUM + | bne ->fff_fallback + | subs CARG4, CARG3, #1 + | ldr CARG2, STR:CARG1->len + | blt ->fff_emptystr // Count <= 0? + | cmp CARG2, #1 + | blo ->fff_emptystr // Zero-length string? + | bne ->fff_fallback // Fallback for > 1-char strings. + | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.sz)] + | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.buf)] + | ldr CARG1, STR:CARG1[1] + | cmp RB, CARG3 + | blo ->fff_fallback + |1: // Fill buffer with char. + | strb CARG1, [CARG2, CARG4] + | subs CARG4, CARG4, #1 + | bge <1 + | b ->fff_newstr + | + |.ffunc string_reverse + | ffgccheck + | ldrd CARG12, [BASE] + | cmp NARGS8:RC, #8 + | blo ->fff_fallback + | checkstr CARG2, ->fff_fallback + | ldr CARG3, STR:CARG1->len + | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.sz)] + | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.buf)] + | mov CARG4, CARG3 + | add CARG1, STR:CARG1, #sizeof(GCstr) + | cmp RB, CARG3 + | blo ->fff_fallback + |1: // Reverse string copy. + | ldrb RB, [CARG1], #1 + | subs CARG4, CARG4, #1 + | blt ->fff_newstr + | strb RB, [CARG2, CARG4] + | b <1 + | + |.macro ffstring_case, name, lo + | .ffunc name + | ffgccheck + | ldrd CARG12, [BASE] + | cmp NARGS8:RC, #8 + | blo ->fff_fallback + | checkstr CARG2, ->fff_fallback + | ldr CARG3, STR:CARG1->len + | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.sz)] + | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.buf)] + | mov CARG4, #0 + | add CARG1, STR:CARG1, #sizeof(GCstr) + | cmp RB, CARG3 + | blo ->fff_fallback + |1: // ASCII case conversion. + | ldrb RB, [CARG1, CARG4] + | cmp CARG4, CARG3 + | bhs ->fff_newstr + | sub RC, RB, #lo + | cmp RC, #26 + | eorlo RB, RB, #0x20 + | strb RB, [CARG2, CARG4] + | add CARG4, CARG4, #1 + | b <1 + |.endmacro + | + |ffstring_case string_lower, 65 + |ffstring_case string_upper, 97 + | + |//-- Table library ------------------------------------------------------ + | + |.ffunc_1 table_getn + | checktab CARG2, ->fff_fallback + | .IOS mov RA, BASE + | bl extern lj_tab_len // (GCtab *t) + | // Returns uint32_t (but less than 2^31). + | .IOS mov BASE, RA + | mvn CARG2, #~LJ_TISNUM + | b ->fff_restv + | + |//-- Bit library -------------------------------------------------------- + | + |// FP number to bit conversion for soft-float. Clobbers r0-r3. + |->vm_tobit_fb: + | bhi ->fff_fallback + |->vm_tobit: + | lsl RB, CARG2, #1 + | adds RB, RB, #0x00200000 + | movpl CARG1, #0 // |x| < 1? + | bxpl lr + | mvn CARG4, #0x3e0 + | subs RB, CARG4, RB, asr #21 + | bmi >1 // |x| >= 2^32? + | lsl CARG4, CARG2, #11 + | orr CARG4, CARG4, #0x80000000 + | orr CARG4, CARG4, CARG1, lsr #21 + | cmp CARG2, #0 + | lsr CARG1, CARG4, RB + | rsblt CARG1, CARG1, #0 + | bx lr + |1: + | add RB, RB, #21 + | lsr CARG4, CARG1, RB + | rsb RB, RB, #20 + | lsl CARG1, CARG2, #12 + | cmp CARG2, #0 + | orr CARG1, CARG4, CARG1, lsl RB + | rsblt CARG1, CARG1, #0 + | bx lr + | + |.macro .ffunc_bit, name + | .ffunc_1 bit_..name + | checktp CARG2, LJ_TISNUM + | blne ->vm_tobit_fb + |.endmacro + | + |.ffunc_bit tobit + | mvn CARG2, #~LJ_TISNUM + | b ->fff_restv + | + |.macro .ffunc_bit_op, name, ins + | .ffunc_bit name + | mov CARG3, CARG1 + | mov RA, #8 + |1: + | ldrd CARG12, [BASE, RA] + | cmp RA, NARGS8:RC + | add RA, RA, #8 + | bge >2 + | checktp CARG2, LJ_TISNUM + | blne ->vm_tobit_fb + | ins CARG3, CARG3, CARG1 + | b <1 + |.endmacro + | + |.ffunc_bit_op band, and + |.ffunc_bit_op bor, orr + |.ffunc_bit_op bxor, eor + | + |2: + | mvn CARG4, #~LJ_TISNUM + | ldr PC, [BASE, FRAME_PC] + | strd CARG34, [BASE, #-8] + | b ->fff_res1 + | + |.ffunc_bit bswap + | eor CARG3, CARG1, CARG1, ror #16 + | bic CARG3, CARG3, #0x00ff0000 + | ror CARG1, CARG1, #8 + | mvn CARG2, #~LJ_TISNUM + | eor CARG1, CARG1, CARG3, lsr #8 + | b ->fff_restv + | + |.ffunc_bit bnot + | mvn CARG1, CARG1 + | mvn CARG2, #~LJ_TISNUM + | b ->fff_restv + | + |.macro .ffunc_bit_sh, name, ins, shmod + | .ffunc bit_..name + | ldrd CARG12, [BASE, #8] + | cmp NARGS8:RC, #16 + | blo ->fff_fallback + | checktp CARG2, LJ_TISNUM + | blne ->vm_tobit_fb + |.if shmod == 0 + | and RA, CARG1, #31 + |.else + | rsb RA, CARG1, #0 + |.endif + | ldrd CARG12, [BASE] + | checktp CARG2, LJ_TISNUM + | blne ->vm_tobit_fb + | ins CARG1, CARG1, RA + | mvn CARG2, #~LJ_TISNUM + | b ->fff_restv + |.endmacro + | + |.ffunc_bit_sh lshift, lsl, 0 + |.ffunc_bit_sh rshift, lsr, 0 + |.ffunc_bit_sh arshift, asr, 0 + |.ffunc_bit_sh rol, ror, 1 + |.ffunc_bit_sh ror, ror, 0 + | + |//----------------------------------------------------------------------- + | + |->fff_fallback: // Call fast function fallback handler. + | // BASE = new base, RC = nargs*8 + | ldr CARG3, [BASE, FRAME_FUNC] + | ldr CARG2, L->maxstack + | add CARG1, BASE, NARGS8:RC + | ldr PC, [BASE, FRAME_PC] // Fallback may overwrite PC. + | str CARG1, L->top + | ldr CARG3, CFUNC:CARG3->f + | str BASE, L->base + | add CARG1, CARG1, #8*LUA_MINSTACK + | str PC, SAVE_PC // Redundant (but a defined value). + | cmp CARG1, CARG2 + | mov CARG1, L + | bhi >5 // Need to grow stack. + | blx CARG3 // (lua_State *L) + | // Either throws an error, or recovers and returns -1, 0 or nresults+1. + | ldr BASE, L->base + | cmp CRET1, #0 + | lsl RC, CRET1, #3 + | sub RA, BASE, #8 + | bgt ->fff_res // Returned nresults+1? + |1: // Returned 0 or -1: retry fast path. + | ldr CARG1, L->top + | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] + | sub NARGS8:RC, CARG1, BASE + | bne ->vm_call_tail // Returned -1? + | ins_callt // Returned 0: retry fast path. + | + |// Reconstruct previous base for vmeta_call during tailcall. + |->vm_call_tail: + | ands CARG1, PC, #FRAME_TYPE + | bic CARG2, PC, #FRAME_TYPEP + | ldreq INS, [PC, #-4] + | andeq CARG2, MASKR8, INS, lsr #5 // Conditional decode_RA8. + | addeq CARG2, CARG2, #8 + | sub RB, BASE, CARG2 + | b ->vm_call_dispatch // Resolve again for tailcall. + | + |5: // Grow stack for fallback handler. + | mov CARG2, #LUA_MINSTACK + | bl extern lj_state_growstack // (lua_State *L, int n) + | ldr BASE, L->base + | cmp CARG1, CARG1 // Set zero-flag to force retry. + | b <1 + | + |->fff_gcstep: // Call GC step function. + | // BASE = new base, RC = nargs*8 + | mov RA, lr + | str BASE, L->base + | add CARG2, BASE, NARGS8:RC + | str PC, SAVE_PC // Redundant (but a defined value). + | str CARG2, L->top + | mov CARG1, L + | bl extern lj_gc_step // (lua_State *L) + | ldr BASE, L->base + | mov lr, RA // Help return address predictor. + | ldr CFUNC:CARG3, [BASE, FRAME_FUNC] + | bx lr + | + |//----------------------------------------------------------------------- + |//-- Special dispatch targets ------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_record: // Dispatch target for recording phase. + |.if JIT + | ldrb CARG1, [DISPATCH, #DISPATCH_GL(hookmask)] + | tst CARG1, #HOOK_VMEVENT // No recording while in vmevent. + | bne >5 + | // Decrement the hookcount for consistency, but always do the call. + | ldr CARG2, [DISPATCH, #DISPATCH_GL(hookcount)] + | tst CARG1, #HOOK_ACTIVE + | bne >1 + | sub CARG2, CARG2, #1 + | tst CARG1, #LUA_MASKLINE|LUA_MASKCOUNT + | strne CARG2, [DISPATCH, #DISPATCH_GL(hookcount)] + | b >1 + |.endif + | + |->vm_rethook: // Dispatch target for return hooks. + | ldrb CARG1, [DISPATCH, #DISPATCH_GL(hookmask)] + | tst CARG1, #HOOK_ACTIVE // Hook already active? + | beq >1 + |5: // Re-dispatch to static ins. + | decode_OP OP, INS + | add OP, DISPATCH, OP, lsl #2 + | ldr pc, [OP, #GG_DISP2STATIC] + | + |->vm_inshook: // Dispatch target for instr/line hooks. + | ldrb CARG1, [DISPATCH, #DISPATCH_GL(hookmask)] + | ldr CARG2, [DISPATCH, #DISPATCH_GL(hookcount)] + | tst CARG1, #HOOK_ACTIVE // Hook already active? + | bne <5 + | tst CARG1, #LUA_MASKLINE|LUA_MASKCOUNT + | beq <5 + | subs CARG2, CARG2, #1 + | str CARG2, [DISPATCH, #DISPATCH_GL(hookcount)] + | beq >1 + | tst CARG1, #LUA_MASKLINE + | beq <5 + |1: + | mov CARG1, L + | str BASE, L->base + | mov CARG2, PC + | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. + | bl extern lj_dispatch_ins // (lua_State *L, const BCIns *pc) + |3: + | ldr BASE, L->base + |4: // Re-dispatch to static ins. + | ldrb OP, [PC, #-4] + | ldr INS, [PC, #-4] + | add OP, DISPATCH, OP, lsl #2 + | ldr OP, [OP, #GG_DISP2STATIC] + | decode_RA8 RA, INS + | decode_RD RC, INS + | bx OP + | + |->cont_hook: // Continue from hook yield. + | ldr CARG1, [CARG4, #-24] + | add PC, PC, #4 + | str CARG1, SAVE_MULTRES // Restore MULTRES for *M ins. + | b <4 + | + |->vm_hotloop: // Hot loop counter underflow. + |.if JIT + | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Same as curr_topL(L). + | sub CARG1, DISPATCH, #-GG_DISP2J + | str PC, SAVE_PC + | ldr CARG3, LFUNC:CARG3->field_pc + | mov CARG2, PC + | str L, [DISPATCH, #DISPATCH_J(L)] + | ldrb CARG3, [CARG3, #PC2PROTO(framesize)] + | str BASE, L->base + | add CARG3, BASE, CARG3, lsl #3 + | str CARG3, L->top + | bl extern lj_trace_hot // (jit_State *J, const BCIns *pc) + | b <3 + |.endif + | + |->vm_callhook: // Dispatch target for call hooks. + | mov CARG2, PC + |.if JIT + | b >1 + |.endif + | + |->vm_hotcall: // Hot call counter underflow. + |.if JIT + | orr CARG2, PC, #1 + |1: + |.endif + | add CARG4, BASE, RC + | str PC, SAVE_PC + | mov CARG1, L + | str BASE, L->base + | sub RA, RA, BASE + | str CARG4, L->top + | bl extern lj_dispatch_call // (lua_State *L, const BCIns *pc) + | // Returns ASMFunction. + | ldr BASE, L->base + | ldr CARG4, L->top + | mov CARG2, #0 + | add RA, BASE, RA + | sub NARGS8:RC, CARG4, BASE + | str CARG2, SAVE_PC // Invalidate for subsequent line hook. + | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] + | ldr INS, [PC, #-4] + | bx CRET1 + | + |//----------------------------------------------------------------------- + |//-- Trace exit handler ------------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_exit_handler: + |.if JIT + | sub sp, sp, #12 + | push {r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12} + | ldr CARG1, [sp, #64] // Load original value of lr. + | ldr DISPATCH, [lr] // Load DISPATCH. + | add CARG3, sp, #64 // Recompute original value of sp. + | mv_vmstate CARG4, EXIT + | str CARG3, [sp, #52] // Store sp in RID_SP + | st_vmstate CARG4 + | ldr CARG2, [CARG1, #-4]! // Get exit instruction. + | str CARG1, [sp, #56] // Store exit pc in RID_LR and RID_PC. + | str CARG1, [sp, #60] + |.if FPU + | vpush {d0-d15} + |.endif + | lsl CARG2, CARG2, #8 + | add CARG1, CARG1, CARG2, asr #6 + | ldr CARG2, [lr, #4] // Load exit stub group offset. + | sub CARG1, CARG1, lr + | ldr L, [DISPATCH, #DISPATCH_GL(jit_L)] + | add CARG1, CARG2, CARG1, lsr #2 // Compute exit number. + | ldr BASE, [DISPATCH, #DISPATCH_GL(jit_base)] + | str CARG1, [DISPATCH, #DISPATCH_J(exitno)] + | mov CARG4, #0 + | str L, [DISPATCH, #DISPATCH_J(L)] + | str BASE, L->base + | str CARG4, [DISPATCH, #DISPATCH_GL(jit_L)] + | sub CARG1, DISPATCH, #-GG_DISP2J + | mov CARG2, sp + | bl extern lj_trace_exit // (jit_State *J, ExitState *ex) + | // Returns MULTRES (unscaled) or negated error code. + | ldr CARG2, L->cframe + | ldr BASE, L->base + | bic CARG2, CARG2, #~CFRAME_RAWMASK // Use two steps: bic sp is deprecated. + | mov sp, CARG2 + | ldr PC, SAVE_PC // Get SAVE_PC. + | str L, SAVE_L // Set SAVE_L (on-trace resume/yield). + | b >1 + |.endif + |->vm_exit_interp: + | // CARG1 = MULTRES or negated error code, BASE, PC and DISPATCH set. + |.if JIT + | ldr L, SAVE_L + |1: + | cmp CARG1, #0 + | blt >3 // Check for error from exit. + | lsl RC, CARG1, #3 + | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] + | str RC, SAVE_MULTRES + | mov CARG3, #0 + | ldr CARG2, LFUNC:CARG2->field_pc + | str CARG3, [DISPATCH, #DISPATCH_GL(jit_L)] + | mv_vmstate CARG4, INTERP + | ldr KBASE, [CARG2, #PC2PROTO(k)] + | // Modified copy of ins_next which handles function header dispatch, too. + | ldrb OP, [PC] + | mov MASKR8, #255 + | ldr INS, [PC], #4 + | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. + | st_vmstate CARG4 + | cmp OP, #BC_FUNCF // Function header? + | ldr OP, [DISPATCH, OP, lsl #2] + | decode_RA8 RA, INS + | lsrlo RC, INS, #16 // No: Decode operands A*8 and D. + | subhs RC, RC, #8 + | addhs RA, RA, BASE // Yes: RA = BASE+framesize*8, RC = nargs*8 + | bx OP + | + |3: // Rethrow error from the right C frame. + | rsb CARG2, CARG1, #0 + | mov CARG1, L + | bl extern lj_err_throw // (lua_State *L, int errcode) + |.endif + | + |//----------------------------------------------------------------------- + |//-- Math helper functions ---------------------------------------------- + |//----------------------------------------------------------------------- + | + |// FP value rounding. Called from JIT code. + |// + |// double lj_vm_floor/ceil/trunc(double x); + |.macro vm_round, func, hf + |.if hf == 1 + | vmov CARG1, CARG2, d0 + |.endif + | lsl CARG3, CARG2, #1 + | adds RB, CARG3, #0x00200000 + | bpl >2 // |x| < 1? + | mvn CARG4, #0x3cc + | subs RB, CARG4, RB, asr #21 // 2^0: RB = 51, 2^51: RB = 0. + | bxlo lr // |x| >= 2^52: done. + | mvn CARG4, #1 + | bic CARG3, CARG1, CARG4, lsl RB // ztest = lo & ~lomask + | and CARG1, CARG1, CARG4, lsl RB // lo &= lomask + | subs RB, RB, #32 + | bicpl CARG4, CARG2, CARG4, lsl RB // |x| <= 2^20: ztest |= hi & ~himask + | orrpl CARG3, CARG3, CARG4 + | mvnpl CARG4, #1 + | andpl CARG2, CARG2, CARG4, lsl RB // |x| <= 2^20: hi &= himask + |.if "func" == "floor" + | tst CARG3, CARG2, asr #31 // iszero = ((ztest & signmask) == 0) + |.else + | bics CARG3, CARG3, CARG2, asr #31 // iszero = ((ztest & ~signmask) == 0) + |.endif + |.if hf == 1 + | vmoveq d0, CARG1, CARG2 + |.endif + | bxeq lr // iszero: done. + | mvn CARG4, #1 + | cmp RB, #0 + | lslpl CARG3, CARG4, RB + | mvnmi CARG3, #0 + | add RB, RB, #32 + | subs CARG1, CARG1, CARG4, lsl RB // lo = lo-lomask + | sbc CARG2, CARG2, CARG3 // hi = hi-himask+carry + |.if hf == 1 + | vmov d0, CARG1, CARG2 + |.endif + | bx lr + | + |2: // |x| < 1: + | bxcs lr // |x| is not finite. + | orr CARG3, CARG3, CARG1 // ztest = (2*hi) | lo + |.if "func" == "floor" + | tst CARG3, CARG2, asr #31 // iszero = ((ztest & signmask) == 0) + |.else + | bics CARG3, CARG3, CARG2, asr #31 // iszero = ((ztest & ~signmask) == 0) + |.endif + | mov CARG1, #0 // lo = 0 + | and CARG2, CARG2, #0x80000000 + | ldrne CARG4, <9 // hi = sign(x) | (iszero ? 0.0 : 1.0) + | orrne CARG2, CARG2, CARG4 + |.if hf == 1 + | vmov d0, CARG1, CARG2 + |.endif + | bx lr + |.endmacro + | + |9: + | .long 0x3ff00000 // hiword(+1.0) + | + |->vm_floor: + |.if HFABI + | vm_round floor, 1 + |.endif + |->vm_floor_sf: + | vm_round floor, 0 + | + |->vm_ceil: + |.if HFABI + | vm_round ceil, 1 + |.endif + |->vm_ceil_sf: + | vm_round ceil, 0 + | + |.macro vm_trunc, hf + |.if JIT + |.if hf == 1 + | vmov CARG1, CARG2, d0 + |.endif + | lsl CARG3, CARG2, #1 + | adds RB, CARG3, #0x00200000 + | andpl CARG2, CARG2, #0x80000000 // |x| < 1? hi = sign(x), lo = 0. + | movpl CARG1, #0 + |.if hf == 1 + | vmovpl d0, CARG1, CARG2 + |.endif + | bxpl lr + | mvn CARG4, #0x3cc + | subs RB, CARG4, RB, asr #21 // 2^0: RB = 51, 2^51: RB = 0. + | bxlo lr // |x| >= 2^52: already done. + | mvn CARG4, #1 + | and CARG1, CARG1, CARG4, lsl RB // lo &= lomask + | subs RB, RB, #32 + | andpl CARG2, CARG2, CARG4, lsl RB // |x| <= 2^20: hi &= himask + |.if hf == 1 + | vmov d0, CARG1, CARG2 + |.endif + | bx lr + |.endif + |.endmacro + | + |->vm_trunc: + |.if HFABI + | vm_trunc 1 + |.endif + |->vm_trunc_sf: + | vm_trunc 0 + | + | // double lj_vm_mod(double dividend, double divisor); + |->vm_mod: + |.if FPU + | // Special calling convention. Also, RC (r11) is not preserved. + | vdiv.f64 d0, d6, d7 + | mov RC, lr + | vmov CARG1, CARG2, d0 + | bl ->vm_floor_sf + | vmov d0, CARG1, CARG2 + | vmul.f64 d0, d0, d7 + | mov lr, RC + | vsub.f64 d6, d6, d0 + | bx lr + |.else + | push {r0, r1, r2, r3, r4, lr} + | bl extern __aeabi_ddiv + | bl ->vm_floor_sf + | ldrd CARG34, [sp, #8] + | bl extern __aeabi_dmul + | ldrd CARG34, [sp] + | eor CARG2, CARG2, #0x80000000 + | bl extern __aeabi_dadd + | add sp, sp, #20 + | pop {pc} + |.endif + | + | // int lj_vm_modi(int dividend, int divisor); + |->vm_modi: + | ands RB, CARG1, #0x80000000 + | rsbmi CARG1, CARG1, #0 // a = |dividend| + | eor RB, RB, CARG2, asr #1 // Keep signdiff and sign(divisor). + | cmp CARG2, #0 + | rsbmi CARG2, CARG2, #0 // b = |divisor| + | subs CARG4, CARG2, #1 + | cmpne CARG1, CARG2 + | moveq CARG1, #0 // if (b == 1 || a == b) a = 0 + | tsthi CARG2, CARG4 + | andeq CARG1, CARG1, CARG4 // else if ((b & (b-1)) == 0) a &= b-1 + | bls >1 + | // Use repeated subtraction to get the remainder. + | clz CARG3, CARG1 + | clz CARG4, CARG2 + | sub CARG4, CARG4, CARG3 + | rsbs CARG3, CARG4, #31 // entry = (31-(clz(b)-clz(a)))*8 + | addne pc, pc, CARG3, lsl #3 // Duff's device. + | nop + { + int i; + for (i = 31; i >= 0; i--) { + | cmp CARG1, CARG2, lsl #i + | subhs CARG1, CARG1, CARG2, lsl #i + } + } + |1: + | cmp CARG1, #0 + | cmpne RB, #0 + | submi CARG1, CARG1, CARG2 // if (y != 0 && signdiff) y = y - b + | eors CARG2, CARG1, RB, lsl #1 + | rsbmi CARG1, CARG1, #0 // if (sign(divisor) != sign(y)) y = -y + | bx lr + | + |//----------------------------------------------------------------------- + |//-- Miscellaneous functions -------------------------------------------- + |//----------------------------------------------------------------------- + | + |//----------------------------------------------------------------------- + |//-- FFI helper functions ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |// Handler for callback functions. + |// Saveregs already performed. Callback slot number in [sp], g in r12. + |->vm_ffi_callback: + |.if FFI + |.type CTSTATE, CTState, PC + | ldr CTSTATE, GL:r12->ctype_state + | add DISPATCH, r12, #GG_G2DISP + |.if FPU + | str r4, SAVE_R4 + | add r4, sp, CFRAME_SPACE+4+8*8 + | vstmdb r4!, {d8-d15} + |.endif + |.if HFABI + | add r12, CTSTATE, #offsetof(CTState, cb.fpr[8]) + |.endif + | strd CARG34, CTSTATE->cb.gpr[2] + | strd CARG12, CTSTATE->cb.gpr[0] + |.if HFABI + | vstmdb r12!, {d0-d7} + |.endif + | ldr CARG4, [sp] + | add CARG3, sp, #CFRAME_SIZE + | mov CARG1, CTSTATE + | lsr CARG4, CARG4, #3 + | str CARG3, CTSTATE->cb.stack + | mov CARG2, sp + | str CARG4, CTSTATE->cb.slot + | str CTSTATE, SAVE_PC // Any value outside of bytecode is ok. + | bl extern lj_ccallback_enter // (CTState *cts, void *cf) + | // Returns lua_State *. + | ldr BASE, L:CRET1->base + | mv_vmstate CARG2, INTERP + | ldr RC, L:CRET1->top + | mov MASKR8, #255 + | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] + | mov L, CRET1 + | sub RC, RC, BASE + | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. + | st_vmstate CARG2 + | ins_callt + |.endif + | + |->cont_ffi_callback: // Return from FFI callback. + |.if FFI + | ldr CTSTATE, [DISPATCH, #DISPATCH_GL(ctype_state)] + | str BASE, L->base + | str CARG4, L->top + | str L, CTSTATE->L + | mov CARG1, CTSTATE + | mov CARG2, RA + | bl extern lj_ccallback_leave // (CTState *cts, TValue *o) + | ldrd CARG12, CTSTATE->cb.gpr[0] + |.if HFABI + | vldr d0, CTSTATE->cb.fpr[0] + |.endif + | b ->vm_leave_unw + |.endif + | + |->vm_ffi_call: // Call C function via FFI. + | // Caveat: needs special frame unwinding, see below. + |.if FFI + | .type CCSTATE, CCallState, r4 + | push {CCSTATE, r5, r11, lr} + | mov CCSTATE, CARG1 + | ldr CARG1, CCSTATE:CARG1->spadj + | ldrb CARG2, CCSTATE->nsp + | add CARG3, CCSTATE, #offsetof(CCallState, stack) + |.if HFABI + | add RB, CCSTATE, #offsetof(CCallState, fpr[0]) + |.endif + | mov r11, sp + | sub sp, sp, CARG1 // Readjust stack. + | subs CARG2, CARG2, #1 + |.if HFABI + | vldm RB, {d0-d7} + |.endif + | ldr RB, CCSTATE->func + | bmi >2 + |1: // Copy stack slots. + | ldr CARG4, [CARG3, CARG2, lsl #2] + | str CARG4, [sp, CARG2, lsl #2] + | subs CARG2, CARG2, #1 + | bpl <1 + |2: + | ldrd CARG12, CCSTATE->gpr[0] + | ldrd CARG34, CCSTATE->gpr[2] + | blx RB + | mov sp, r11 + |.if HFABI + | add r12, CCSTATE, #offsetof(CCallState, fpr[4]) + |.endif + | strd CRET1, CCSTATE->gpr[0] + |.if HFABI + | vstmdb r12!, {d0-d3} + |.endif + | pop {CCSTATE, r5, r11, pc} + |.endif + |// Note: vm_ffi_call must be the last function in this object file! + | + |//----------------------------------------------------------------------- +} + +/* Generate the code for a single instruction. */ +static void build_ins(BuildCtx *ctx, BCOp op, int defop) +{ + int vk = 0; + |=>defop: + + switch (op) { + + /* -- Comparison ops ---------------------------------------------------- */ + + /* Remember: all ops branch for a true comparison, fall through otherwise. */ + + case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: + | // RA = src1*8, RC = src2, JMP with RC = target + | lsl RC, RC, #3 + | ldrd CARG12, [RA, BASE]! + | ldrh RB, [PC, #2] + | ldrd CARG34, [RC, BASE]! + | add PC, PC, #4 + | add RB, PC, RB, lsl #2 + | checktp CARG2, LJ_TISNUM + | bne >3 + | checktp CARG4, LJ_TISNUM + | bne >4 + | cmp CARG1, CARG3 + if (op == BC_ISLT) { + | sublt PC, RB, #0x20000 + } else if (op == BC_ISGE) { + | subge PC, RB, #0x20000 + } else if (op == BC_ISLE) { + | suble PC, RB, #0x20000 + } else { + | subgt PC, RB, #0x20000 + } + |1: + | ins_next + | + |3: // CARG12 is not an integer. + |.if FPU + | vldr d0, [RA] + | bhi ->vmeta_comp + | // d0 is a number. + | checktp CARG4, LJ_TISNUM + | vldr d1, [RC] + | blo >5 + | bhi ->vmeta_comp + | // d0 is a number, CARG3 is an integer. + | vmov s4, CARG3 + | vcvt.f64.s32 d1, s4 + | b >5 + |4: // CARG1 is an integer, CARG34 is not an integer. + | vldr d1, [RC] + | bhi ->vmeta_comp + | // CARG1 is an integer, d1 is a number. + | vmov s4, CARG1 + | vcvt.f64.s32 d0, s4 + |5: // d0 and d1 are numbers. + | vcmp.f64 d0, d1 + | vmrs + | // To preserve NaN semantics GE/GT branch on unordered, but LT/LE don't. + if (op == BC_ISLT) { + | sublo PC, RB, #0x20000 + } else if (op == BC_ISGE) { + | subhs PC, RB, #0x20000 + } else if (op == BC_ISLE) { + | subls PC, RB, #0x20000 + } else { + | subhi PC, RB, #0x20000 + } + | b <1 + |.else + | bhi ->vmeta_comp + | // CARG12 is a number. + | checktp CARG4, LJ_TISNUM + | movlo RA, RB // Save RB. + | blo >5 + | bhi ->vmeta_comp + | // CARG12 is a number, CARG3 is an integer. + | mov CARG1, CARG3 + | mov RC, RA + | mov RA, RB // Save RB. + | bl extern __aeabi_i2d + | mov CARG3, CARG1 + | mov CARG4, CARG2 + | ldrd CARG12, [RC] // Restore first operand. + | b >5 + |4: // CARG1 is an integer, CARG34 is not an integer. + | bhi ->vmeta_comp + | // CARG1 is an integer, CARG34 is a number. + | mov RA, RB // Save RB. + | bl extern __aeabi_i2d + | ldrd CARG34, [RC] // Restore second operand. + |5: // CARG12 and CARG34 are numbers. + | bl extern __aeabi_cdcmple + | // To preserve NaN semantics GE/GT branch on unordered, but LT/LE don't. + if (op == BC_ISLT) { + | sublo PC, RA, #0x20000 + } else if (op == BC_ISGE) { + | subhs PC, RA, #0x20000 + } else if (op == BC_ISLE) { + | subls PC, RA, #0x20000 + } else { + | subhi PC, RA, #0x20000 + } + | b <1 + |.endif + break; + + case BC_ISEQV: case BC_ISNEV: + vk = op == BC_ISEQV; + | // RA = src1*8, RC = src2, JMP with RC = target + | lsl RC, RC, #3 + | ldrd CARG12, [RA, BASE]! + | ldrh RB, [PC, #2] + | ldrd CARG34, [RC, BASE]! + | add PC, PC, #4 + | add RB, PC, RB, lsl #2 + | checktp CARG2, LJ_TISNUM + | cmnls CARG4, #-LJ_TISNUM + if (vk) { + | bls ->BC_ISEQN_Z + } else { + | bls ->BC_ISNEN_Z + } + | // Either or both types are not numbers. + |.if FFI + | checktp CARG2, LJ_TCDATA + | checktpne CARG4, LJ_TCDATA + | beq ->vmeta_equal_cd + |.endif + | cmp CARG2, CARG4 // Compare types. + | bne >2 // Not the same type? + | checktp CARG2, LJ_TISPRI + | bhs >1 // Same type and primitive type? + | + | // Same types and not a primitive type. Compare GCobj or pvalue. + | cmp CARG1, CARG3 + if (vk) { + | bne >3 // Different GCobjs or pvalues? + |1: // Branch if same. + | sub PC, RB, #0x20000 + |2: // Different. + | ins_next + |3: + | checktp CARG2, LJ_TISTABUD + | bhi <2 // Different objects and not table/ud? + } else { + | beq >1 // Same GCobjs or pvalues? + | checktp CARG2, LJ_TISTABUD + | bhi >2 // Different objects and not table/ud? + } + | // Different tables or userdatas. Need to check __eq metamethod. + | // Field metatable must be at same offset for GCtab and GCudata! + | ldr TAB:RA, TAB:CARG1->metatable + | cmp TAB:RA, #0 + if (vk) { + | beq <2 // No metatable? + } else { + | beq >2 // No metatable? + } + | ldrb RA, TAB:RA->nomm + | mov CARG4, #1-vk // ne = 0 or 1. + | mov CARG2, CARG1 + | tst RA, #1<vmeta_equal // 'no __eq' flag not set? + if (vk) { + | b <2 + } else { + |2: // Branch if different. + | sub PC, RB, #0x20000 + |1: // Same. + | ins_next + } + break; + + case BC_ISEQS: case BC_ISNES: + vk = op == BC_ISEQS; + | // RA = src*8, RC = str_const (~), JMP with RC = target + | mvn RC, RC + | ldrd CARG12, [BASE, RA] + | ldrh RB, [PC, #2] + | ldr STR:CARG3, [KBASE, RC, lsl #2] + | add PC, PC, #4 + | add RB, PC, RB, lsl #2 + | checktp CARG2, LJ_TSTR + |.if FFI + | bne >7 + | cmp CARG1, CARG3 + |.else + | cmpeq CARG1, CARG3 + |.endif + if (vk) { + | subeq PC, RB, #0x20000 + |1: + } else { + |1: + | subne PC, RB, #0x20000 + } + | ins_next + | + |.if FFI + |7: + | checktp CARG2, LJ_TCDATA + | bne <1 + | b ->vmeta_equal_cd + |.endif + break; + + case BC_ISEQN: case BC_ISNEN: + vk = op == BC_ISEQN; + | // RA = src*8, RC = num_const (~), JMP with RC = target + | lsl RC, RC, #3 + | ldrd CARG12, [RA, BASE]! + | ldrh RB, [PC, #2] + | ldrd CARG34, [RC, KBASE]! + | add PC, PC, #4 + | add RB, PC, RB, lsl #2 + if (vk) { + |->BC_ISEQN_Z: + } else { + |->BC_ISNEN_Z: + } + | checktp CARG2, LJ_TISNUM + | bne >3 + | checktp CARG4, LJ_TISNUM + | bne >4 + | cmp CARG1, CARG3 + if (vk) { + | subeq PC, RB, #0x20000 + |1: + } else { + |1: + | subne PC, RB, #0x20000 + } + |2: + | ins_next + | + |3: // CARG12 is not an integer. + |.if FFI + | bhi >7 + |.else + if (!vk) { + | subhi PC, RB, #0x20000 + } + | bhi <2 + |.endif + |.if FPU + | checktp CARG4, LJ_TISNUM + | vmov s4, CARG3 + | vldr d0, [RA] + | vldrlo d1, [RC] + | vcvths.f64.s32 d1, s4 + | b >5 + |4: // CARG1 is an integer, d1 is a number. + | vmov s4, CARG1 + | vldr d1, [RC] + | vcvt.f64.s32 d0, s4 + |5: // d0 and d1 are numbers. + | vcmp.f64 d0, d1 + | vmrs + if (vk) { + | subeq PC, RB, #0x20000 + } else { + | subne PC, RB, #0x20000 + } + | b <2 + |.else + | // CARG12 is a number. + | checktp CARG4, LJ_TISNUM + | movlo RA, RB // Save RB. + | blo >5 + | // CARG12 is a number, CARG3 is an integer. + | mov CARG1, CARG3 + | mov RC, RA + |4: // CARG1 is an integer, CARG34 is a number. + | mov RA, RB // Save RB. + | bl extern __aeabi_i2d + | ldrd CARG34, [RC] // Restore other operand. + |5: // CARG12 and CARG34 are numbers. + | bl extern __aeabi_cdcmpeq + if (vk) { + | subeq PC, RA, #0x20000 + } else { + | subne PC, RA, #0x20000 + } + | b <2 + |.endif + | + |.if FFI + |7: + | checktp CARG2, LJ_TCDATA + | bne <1 + | b ->vmeta_equal_cd + |.endif + break; + + case BC_ISEQP: case BC_ISNEP: + vk = op == BC_ISEQP; + | // RA = src*8, RC = primitive_type (~), JMP with RC = target + | ldrd CARG12, [BASE, RA] + | ldrh RB, [PC, #2] + | add PC, PC, #4 + | mvn RC, RC + | add RB, PC, RB, lsl #2 + |.if FFI + | checktp CARG2, LJ_TCDATA + | beq ->vmeta_equal_cd + |.endif + | cmp CARG2, RC + if (vk) { + | subeq PC, RB, #0x20000 + } else { + | subne PC, RB, #0x20000 + } + | ins_next + break; + + /* -- Unary test and copy ops ------------------------------------------- */ + + case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: + | // RA = dst*8 or unused, RC = src, JMP with RC = target + | add RC, BASE, RC, lsl #3 + | ldrh RB, [PC, #2] + | ldrd CARG12, [RC] + | add PC, PC, #4 + | add RB, PC, RB, lsl #2 + | checktp CARG2, LJ_TTRUE + if (op == BC_ISTC || op == BC_IST) { + | subls PC, RB, #0x20000 + if (op == BC_ISTC) { + | strdls CARG12, [BASE, RA] + } + } else { + | subhi PC, RB, #0x20000 + if (op == BC_ISFC) { + | strdhi CARG12, [BASE, RA] + } + } + | ins_next + break; + + /* -- Unary ops --------------------------------------------------------- */ + + case BC_MOV: + | // RA = dst*8, RC = src + | lsl RC, RC, #3 + | ins_next1 + | ldrd CARG12, [BASE, RC] + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + break; + case BC_NOT: + | // RA = dst*8, RC = src + | add RC, BASE, RC, lsl #3 + | ins_next1 + | ldr CARG1, [RC, #4] + | add RA, BASE, RA + | ins_next2 + | checktp CARG1, LJ_TTRUE + | mvnls CARG2, #~LJ_TFALSE + | mvnhi CARG2, #~LJ_TTRUE + | str CARG2, [RA, #4] + | ins_next3 + break; + case BC_UNM: + | // RA = dst*8, RC = src + | lsl RC, RC, #3 + | ldrd CARG12, [BASE, RC] + | ins_next1 + | ins_next2 + | checktp CARG2, LJ_TISNUM + | bhi ->vmeta_unm + | eorne CARG2, CARG2, #0x80000000 + | bne >5 + | rsbseq CARG1, CARG1, #0 + | ldrdvs CARG12, >9 + |5: + | strd CARG12, [BASE, RA] + | ins_next3 + | + |.align 8 + |9: + | .long 0x00000000, 0x41e00000 // 2^31. + break; + case BC_LEN: + | // RA = dst*8, RC = src + | lsl RC, RC, #3 + | ldrd CARG12, [BASE, RC] + | checkstr CARG2, >2 + | ldr CARG1, STR:CARG1->len + |1: + | mvn CARG2, #~LJ_TISNUM + | ins_next1 + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + |2: + | checktab CARG2, ->vmeta_len +#if LJ_52 + | ldr TAB:CARG3, TAB:CARG1->metatable + | cmp TAB:CARG3, #0 + | bne >9 + |3: +#endif + |->BC_LEN_Z: + | .IOS mov RC, BASE + | bl extern lj_tab_len // (GCtab *t) + | // Returns uint32_t (but less than 2^31). + | .IOS mov BASE, RC + | b <1 +#if LJ_52 + |9: + | ldrb CARG4, TAB:CARG3->nomm + | tst CARG4, #1<vmeta_len +#endif + break; + + /* -- Binary ops -------------------------------------------------------- */ + + |.macro ins_arithcheck, cond, ncond, target + ||if (vk == 1) { + | cmn CARG4, #-LJ_TISNUM + | cmn..cond CARG2, #-LJ_TISNUM + ||} else { + | cmn CARG2, #-LJ_TISNUM + | cmn..cond CARG4, #-LJ_TISNUM + ||} + | b..ncond target + |.endmacro + |.macro ins_arithcheck_int, target + | ins_arithcheck eq, ne, target + |.endmacro + |.macro ins_arithcheck_num, target + | ins_arithcheck lo, hs, target + |.endmacro + | + |.macro ins_arithpre + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 + ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); + ||switch (vk) { + ||case 0: + | .if FPU + | ldrd CARG12, [RB, BASE]! + | ldrd CARG34, [RC, KBASE]! + | .else + | ldrd CARG12, [BASE, RB] + | ldrd CARG34, [KBASE, RC] + | .endif + || break; + ||case 1: + | .if FPU + | ldrd CARG34, [RB, BASE]! + | ldrd CARG12, [RC, KBASE]! + | .else + | ldrd CARG34, [BASE, RB] + | ldrd CARG12, [KBASE, RC] + | .endif + || break; + ||default: + | .if FPU + | ldrd CARG12, [RB, BASE]! + | ldrd CARG34, [RC, BASE]! + | .else + | ldrd CARG12, [BASE, RB] + | ldrd CARG34, [BASE, RC] + | .endif + || break; + ||} + |.endmacro + | + |.macro ins_arithpre_fpu, reg1, reg2 + |.if FPU + ||if (vk == 1) { + | vldr reg2, [RB] + | vldr reg1, [RC] + ||} else { + | vldr reg1, [RB] + | vldr reg2, [RC] + ||} + |.endif + |.endmacro + | + |.macro ins_arithpost_fpu, reg + | ins_next1 + | add RA, BASE, RA + | ins_next2 + | vstr reg, [RA] + | ins_next3 + |.endmacro + | + |.macro ins_arithfallback, ins + ||switch (vk) { + ||case 0: + | ins ->vmeta_arith_vn + || break; + ||case 1: + | ins ->vmeta_arith_nv + || break; + ||default: + | ins ->vmeta_arith_vv + || break; + ||} + |.endmacro + | + |.macro ins_arithdn, intins, fpins, fpcall + | ins_arithpre + |.if "intins" ~= "vm_modi" and not FPU + | ins_next1 + |.endif + | ins_arithcheck_int >5 + |.if "intins" == "smull" + | smull CARG1, RC, CARG3, CARG1 + | cmp RC, CARG1, asr #31 + | ins_arithfallback bne + |.elif "intins" == "vm_modi" + | movs CARG2, CARG3 + | ins_arithfallback beq + | bl ->vm_modi + | mvn CARG2, #~LJ_TISNUM + |.else + | intins CARG1, CARG1, CARG3 + | ins_arithfallback bvs + |.endif + |4: + |.if "intins" == "vm_modi" or FPU + | ins_next1 + |.endif + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + |5: // FP variant. + | ins_arithpre_fpu d6, d7 + | ins_arithfallback ins_arithcheck_num + |.if FPU + |.if "intins" == "vm_modi" + | bl fpcall + |.else + | fpins d6, d6, d7 + |.endif + | ins_arithpost_fpu d6 + |.else + | bl fpcall + |.if "intins" ~= "vm_modi" + | ins_next1 + |.endif + | b <4 + |.endif + |.endmacro + | + |.macro ins_arithfp, fpins, fpcall + | ins_arithpre + |.if "fpins" ~= "extern" or HFABI + | ins_arithpre_fpu d0, d1 + |.endif + | ins_arithfallback ins_arithcheck_num + |.if "fpins" == "extern" + | .IOS mov RC, BASE + | bl fpcall + | .IOS mov BASE, RC + |.elif FPU + | fpins d0, d0, d1 + |.else + | bl fpcall + |.endif + |.if ("fpins" ~= "extern" or HFABI) and FPU + | ins_arithpost_fpu d0 + |.else + | ins_next1 + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + |.endif + |.endmacro + + case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: + | ins_arithdn adds, vadd.f64, extern __aeabi_dadd + break; + case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: + | ins_arithdn subs, vsub.f64, extern __aeabi_dsub + break; + case BC_MULVN: case BC_MULNV: case BC_MULVV: + | ins_arithdn smull, vmul.f64, extern __aeabi_dmul + break; + case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: + | ins_arithfp vdiv.f64, extern __aeabi_ddiv + break; + case BC_MODVN: case BC_MODNV: case BC_MODVV: + | ins_arithdn vm_modi, vm_mod, ->vm_mod + break; + case BC_POW: + | // NYI: (partial) integer arithmetic. + | ins_arithfp extern, extern pow + break; + + case BC_CAT: + | decode_RB8 RC, INS + | decode_RC8 RB, INS + | // RA = dst*8, RC = src_start*8, RB = src_end*8 (note: RB/RC swapped!) + | sub CARG3, RB, RC + | str BASE, L->base + | add CARG2, BASE, RB + |->BC_CAT_Z: + | // RA = dst*8, RC = src_start*8, CARG2 = top-1 + | mov CARG1, L + | str PC, SAVE_PC + | lsr CARG3, CARG3, #3 + | bl extern lj_meta_cat // (lua_State *L, TValue *top, int left) + | // Returns NULL (finished) or TValue * (metamethod). + | ldr BASE, L->base + | cmp CRET1, #0 + | bne ->vmeta_binop + | ldrd CARG34, [BASE, RC] + | ins_next1 + | ins_next2 + | strd CARG34, [BASE, RA] // Copy result to RA. + | ins_next3 + break; + + /* -- Constant ops ------------------------------------------------------ */ + + case BC_KSTR: + | // RA = dst*8, RC = str_const (~) + | mvn RC, RC + | ins_next1 + | ldr CARG1, [KBASE, RC, lsl #2] + | mvn CARG2, #~LJ_TSTR + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + break; + case BC_KCDATA: + |.if FFI + | // RA = dst*8, RC = cdata_const (~) + | mvn RC, RC + | ins_next1 + | ldr CARG1, [KBASE, RC, lsl #2] + | mvn CARG2, #~LJ_TCDATA + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + |.endif + break; + case BC_KSHORT: + | // RA = dst*8, (RC = int16_literal) + | mov CARG1, INS, asr #16 // Refetch sign-extended reg. + | mvn CARG2, #~LJ_TISNUM + | ins_next1 + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + break; + case BC_KNUM: + | // RA = dst*8, RC = num_const + | lsl RC, RC, #3 + | ins_next1 + | ldrd CARG12, [KBASE, RC] + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + break; + case BC_KPRI: + | // RA = dst*8, RC = primitive_type (~) + | add RA, BASE, RA + | mvn RC, RC + | ins_next1 + | ins_next2 + | str RC, [RA, #4] + | ins_next3 + break; + case BC_KNIL: + | // RA = base*8, RC = end + | add RA, BASE, RA + | add RC, BASE, RC, lsl #3 + | mvn CARG1, #~LJ_TNIL + | str CARG1, [RA, #4] + | add RA, RA, #8 + |1: + | str CARG1, [RA, #4] + | cmp RA, RC + | add RA, RA, #8 + | blt <1 + | ins_next_ + break; + + /* -- Upvalue and function ops ------------------------------------------ */ + + case BC_UGET: + | // RA = dst*8, RC = uvnum + | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] + | lsl RC, RC, #2 + | add RC, RC, #offsetof(GCfuncL, uvptr) + | ldr UPVAL:CARG2, [LFUNC:CARG2, RC] + | ldr CARG2, UPVAL:CARG2->v + | ldrd CARG34, [CARG2] + | ins_next1 + | ins_next2 + | strd CARG34, [BASE, RA] + | ins_next3 + break; + case BC_USETV: + | // RA = uvnum*8, RC = src + | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] + | lsr RA, RA, #1 + | add RA, RA, #offsetof(GCfuncL, uvptr) + | lsl RC, RC, #3 + | ldr UPVAL:CARG2, [LFUNC:CARG2, RA] + | ldrd CARG34, [BASE, RC] + | ldrb RB, UPVAL:CARG2->marked + | ldrb RC, UPVAL:CARG2->closed + | ldr CARG2, UPVAL:CARG2->v + | tst RB, #LJ_GC_BLACK // isblack(uv) + | add RB, CARG4, #-LJ_TISGCV + | cmpne RC, #0 + | strd CARG34, [CARG2] + | bne >2 // Upvalue is closed and black? + |1: + | ins_next + | + |2: // Check if new value is collectable. + | cmn RB, #-(LJ_TNUMX - LJ_TISGCV) + | ldrbhi RC, GCOBJ:CARG3->gch.marked + | bls <1 // tvisgcv(v) + | sub CARG1, DISPATCH, #-GG_DISP2G + | tst RC, #LJ_GC_WHITES + | // Crossed a write barrier. Move the barrier forward. + |.if IOS + | beq <1 + | mov RC, BASE + | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) + | mov BASE, RC + |.else + | blne extern lj_gc_barrieruv // (global_State *g, TValue *tv) + |.endif + | b <1 + break; + case BC_USETS: + | // RA = uvnum*8, RC = str_const (~) + | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] + | lsr RA, RA, #1 + | add RA, RA, #offsetof(GCfuncL, uvptr) + | mvn RC, RC + | ldr UPVAL:CARG2, [LFUNC:CARG2, RA] + | ldr STR:CARG3, [KBASE, RC, lsl #2] + | ldrb RB, UPVAL:CARG2->marked + | ldrb RC, UPVAL:CARG2->closed + | ldr CARG2, UPVAL:CARG2->v + | mvn CARG4, #~LJ_TSTR + | tst RB, #LJ_GC_BLACK // isblack(uv) + | ldrb RB, STR:CARG3->marked + | strd CARG34, [CARG2] + | bne >2 + |1: + | ins_next + | + |2: // Check if string is white and ensure upvalue is closed. + | tst RB, #LJ_GC_WHITES // iswhite(str) + | cmpne RC, #0 + | sub CARG1, DISPATCH, #-GG_DISP2G + | // Crossed a write barrier. Move the barrier forward. + |.if IOS + | beq <1 + | mov RC, BASE + | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) + | mov BASE, RC + |.else + | blne extern lj_gc_barrieruv // (global_State *g, TValue *tv) + |.endif + | b <1 + break; + case BC_USETN: + | // RA = uvnum*8, RC = num_const + | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] + | lsr RA, RA, #1 + | add RA, RA, #offsetof(GCfuncL, uvptr) + | lsl RC, RC, #3 + | ldr UPVAL:CARG2, [LFUNC:CARG2, RA] + | ldrd CARG34, [KBASE, RC] + | ldr CARG2, UPVAL:CARG2->v + | ins_next1 + | ins_next2 + | strd CARG34, [CARG2] + | ins_next3 + break; + case BC_USETP: + | // RA = uvnum*8, RC = primitive_type (~) + | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] + | lsr RA, RA, #1 + | add RA, RA, #offsetof(GCfuncL, uvptr) + | ldr UPVAL:CARG2, [LFUNC:CARG2, RA] + | mvn RC, RC + | ldr CARG2, UPVAL:CARG2->v + | ins_next1 + | ins_next2 + | str RC, [CARG2, #4] + | ins_next3 + break; + + case BC_UCLO: + | // RA = level*8, RC = target + | ldr CARG3, L->openupval + | add RC, PC, RC, lsl #2 + | str BASE, L->base + | cmp CARG3, #0 + | sub PC, RC, #0x20000 + | beq >1 + | mov CARG1, L + | add CARG2, BASE, RA + | bl extern lj_func_closeuv // (lua_State *L, TValue *level) + | ldr BASE, L->base + |1: + | ins_next + break; + + case BC_FNEW: + | // RA = dst*8, RC = proto_const (~) (holding function prototype) + | mvn RC, RC + | str BASE, L->base + | ldr CARG2, [KBASE, RC, lsl #2] + | str PC, SAVE_PC + | ldr CARG3, [BASE, FRAME_FUNC] + | mov CARG1, L + | // (lua_State *L, GCproto *pt, GCfuncL *parent) + | bl extern lj_func_newL_gc + | // Returns GCfuncL *. + | ldr BASE, L->base + | mvn CARG2, #~LJ_TFUNC + | ins_next1 + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + break; + + /* -- Table ops --------------------------------------------------------- */ + + case BC_TNEW: + case BC_TDUP: + | // RA = dst*8, RC = (hbits|asize) | tab_const (~) + if (op == BC_TDUP) { + | mvn RC, RC + } + | ldr CARG3, [DISPATCH, #DISPATCH_GL(gc.total)] + | ldr CARG4, [DISPATCH, #DISPATCH_GL(gc.threshold)] + | str BASE, L->base + | str PC, SAVE_PC + | cmp CARG3, CARG4 + | mov CARG1, L + | bhs >5 + |1: + if (op == BC_TNEW) { + | lsl CARG2, RC, #21 + | lsr CARG3, RC, #11 + | asr RC, CARG2, #21 + | lsr CARG2, CARG2, #21 + | cmn RC, #1 + | addeq CARG2, CARG2, #2 + | bl extern lj_tab_new // (lua_State *L, int32_t asize, uint32_t hbits) + | // Returns GCtab *. + } else { + | ldr CARG2, [KBASE, RC, lsl #2] + | bl extern lj_tab_dup // (lua_State *L, Table *kt) + | // Returns GCtab *. + } + | ldr BASE, L->base + | mvn CARG2, #~LJ_TTAB + | ins_next1 + | ins_next2 + | strd CARG12, [BASE, RA] + | ins_next3 + |5: + | bl extern lj_gc_step_fixtop // (lua_State *L) + | mov CARG1, L + | b <1 + break; + + case BC_GGET: + | // RA = dst*8, RC = str_const (~) + case BC_GSET: + | // RA = dst*8, RC = str_const (~) + | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] + | mvn RC, RC + | ldr TAB:CARG1, LFUNC:CARG2->env + | ldr STR:RC, [KBASE, RC, lsl #2] + if (op == BC_GGET) { + | b ->BC_TGETS_Z + } else { + | b ->BC_TSETS_Z + } + break; + + case BC_TGETV: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | // RA = dst*8, RB = table*8, RC = key*8 + | ldrd TAB:CARG12, [BASE, RB] + | ldrd CARG34, [BASE, RC] + | checktab CARG2, ->vmeta_tgetv // STALL: load CARG12. + | checktp CARG4, LJ_TISNUM // Integer key? + | ldreq CARG4, TAB:CARG1->array + | ldreq CARG2, TAB:CARG1->asize + | bne >9 + | + | add CARG4, CARG4, CARG3, lsl #3 + | cmp CARG3, CARG2 // In array part? + | ldrdlo CARG34, [CARG4] + | bhs ->vmeta_tgetv + | ins_next1 // Overwrites RB! + | checktp CARG4, LJ_TNIL + | beq >5 + |1: + | ins_next2 + | strd CARG34, [BASE, RA] + | ins_next3 + | + |5: // Check for __index if table value is nil. + | ldr TAB:CARG2, TAB:CARG1->metatable + | cmp TAB:CARG2, #0 + | beq <1 // No metatable: done. + | ldrb CARG2, TAB:CARG2->nomm + | tst CARG2, #1<vmeta_tgetv + | + |9: + | checktp CARG4, LJ_TSTR // String key? + | moveq STR:RC, CARG3 + | beq ->BC_TGETS_Z + | b ->vmeta_tgetv + break; + case BC_TGETS: + | decode_RB8 RB, INS + | and RC, RC, #255 + | // RA = dst*8, RB = table*8, RC = str_const (~) + | ldrd CARG12, [BASE, RB] + | mvn RC, RC + | ldr STR:RC, [KBASE, RC, lsl #2] // STALL: early RC. + | checktab CARG2, ->vmeta_tgets1 + |->BC_TGETS_Z: + | // (TAB:RB =) TAB:CARG1 = GCtab *, STR:RC = GCstr *, RA = dst*8 + | ldr CARG3, TAB:CARG1->hmask + | ldr CARG4, STR:RC->hash + | ldr NODE:INS, TAB:CARG1->node + | mov TAB:RB, TAB:CARG1 + | and CARG3, CARG3, CARG4 // idx = str->hash & tab->hmask + | add CARG3, CARG3, CARG3, lsl #1 + | add NODE:INS, NODE:INS, CARG3, lsl #3 // node = tab->node + idx*3*8 + |1: + | ldrd CARG12, NODE:INS->key // STALL: early NODE:INS. + | ldrd CARG34, NODE:INS->val + | ldr NODE:INS, NODE:INS->next + | checktp CARG2, LJ_TSTR + | cmpeq CARG1, STR:RC + | bne >4 + | checktp CARG4, LJ_TNIL + | beq >5 + |3: + | ins_next1 + | ins_next2 + | strd CARG34, [BASE, RA] + | ins_next3 + | + |4: // Follow hash chain. + | cmp NODE:INS, #0 + | bne <1 + | // End of hash chain: key not found, nil result. + | + |5: // Check for __index if table value is nil. + | ldr TAB:CARG1, TAB:RB->metatable + | mov CARG3, #0 // Optional clear of undef. value (during load stall). + | mvn CARG4, #~LJ_TNIL + | cmp TAB:CARG1, #0 + | beq <3 // No metatable: done. + | ldrb CARG2, TAB:CARG1->nomm + | tst CARG2, #1<vmeta_tgets + break; + case BC_TGETB: + | decode_RB8 RB, INS + | and RC, RC, #255 + | // RA = dst*8, RB = table*8, RC = index + | ldrd CARG12, [BASE, RB] + | checktab CARG2, ->vmeta_tgetb // STALL: load CARG12. + | ldr CARG3, TAB:CARG1->asize + | ldr CARG4, TAB:CARG1->array + | lsl CARG2, RC, #3 + | cmp RC, CARG3 + | ldrdlo CARG34, [CARG4, CARG2] + | bhs ->vmeta_tgetb + | ins_next1 // Overwrites RB! + | checktp CARG4, LJ_TNIL + | beq >5 + |1: + | ins_next2 + | strd CARG34, [BASE, RA] + | ins_next3 + | + |5: // Check for __index if table value is nil. + | ldr TAB:CARG2, TAB:CARG1->metatable + | cmp TAB:CARG2, #0 + | beq <1 // No metatable: done. + | ldrb CARG2, TAB:CARG2->nomm + | tst CARG2, #1<vmeta_tgetb + break; + + case BC_TSETV: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | // RA = src*8, RB = table*8, RC = key*8 + | ldrd TAB:CARG12, [BASE, RB] + | ldrd CARG34, [BASE, RC] + | checktab CARG2, ->vmeta_tsetv // STALL: load CARG12. + | checktp CARG4, LJ_TISNUM // Integer key? + | ldreq CARG2, TAB:CARG1->array + | ldreq CARG4, TAB:CARG1->asize + | bne >9 + | + | add CARG2, CARG2, CARG3, lsl #3 + | cmp CARG3, CARG4 // In array part? + | ldrlo INS, [CARG2, #4] + | bhs ->vmeta_tsetv + | ins_next1 // Overwrites RB! + | checktp INS, LJ_TNIL + | ldrb INS, TAB:CARG1->marked + | ldrd CARG34, [BASE, RA] + | beq >5 + |1: + | tst INS, #LJ_GC_BLACK // isblack(table) + | strd CARG34, [CARG2] + | bne >7 + |2: + | ins_next2 + | ins_next3 + | + |5: // Check for __newindex if previous value is nil. + | ldr TAB:RA, TAB:CARG1->metatable + | cmp TAB:RA, #0 + | beq <1 // No metatable: done. + | ldrb RA, TAB:RA->nomm + | tst RA, #1<vmeta_tsetv + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:CARG1, INS, CARG3 + | b <2 + | + |9: + | checktp CARG4, LJ_TSTR // String key? + | moveq STR:RC, CARG3 + | beq ->BC_TSETS_Z + | b ->vmeta_tsetv + break; + case BC_TSETS: + | decode_RB8 RB, INS + | and RC, RC, #255 + | // RA = src*8, RB = table*8, RC = str_const (~) + | ldrd CARG12, [BASE, RB] + | mvn RC, RC + | ldr STR:RC, [KBASE, RC, lsl #2] // STALL: early RC. + | checktab CARG2, ->vmeta_tsets1 + |->BC_TSETS_Z: + | // (TAB:RB =) TAB:CARG1 = GCtab *, STR:RC = GCstr *, RA = dst*8 + | ldr CARG3, TAB:CARG1->hmask + | ldr CARG4, STR:RC->hash + | ldr NODE:INS, TAB:CARG1->node + | mov TAB:RB, TAB:CARG1 + | and CARG3, CARG3, CARG4 // idx = str->hash & tab->hmask + | add CARG3, CARG3, CARG3, lsl #1 + | mov CARG4, #0 + | add NODE:INS, NODE:INS, CARG3, lsl #3 // node = tab->node + idx*3*8 + | strb CARG4, TAB:RB->nomm // Clear metamethod cache. + |1: + | ldrd CARG12, NODE:INS->key + | ldr CARG4, NODE:INS->val.it + | ldr NODE:CARG3, NODE:INS->next + | checktp CARG2, LJ_TSTR + | cmpeq CARG1, STR:RC + | bne >5 + | ldrb CARG2, TAB:RB->marked + | checktp CARG4, LJ_TNIL // Key found, but nil value? + | ldrd CARG34, [BASE, RA] + | beq >4 + |2: + | tst CARG2, #LJ_GC_BLACK // isblack(table) + | strd CARG34, NODE:INS->val + | bne >7 + |3: + | ins_next + | + |4: // Check for __newindex if previous value is nil. + | ldr TAB:CARG1, TAB:RB->metatable + | cmp TAB:CARG1, #0 + | beq <2 // No metatable: done. + | ldrb CARG1, TAB:CARG1->nomm + | tst CARG1, #1<vmeta_tsets + | + |5: // Follow hash chain. + | movs NODE:INS, NODE:CARG3 + | bne <1 + | // End of hash chain: key not found, add a new one. + | + | // But check for __newindex first. + | ldr TAB:CARG1, TAB:RB->metatable + | mov CARG3, TMPDp + | str PC, SAVE_PC + | cmp TAB:CARG1, #0 // No metatable: continue. + | str BASE, L->base + | ldrbne CARG2, TAB:CARG1->nomm + | mov CARG1, L + | beq >6 + | tst CARG2, #1<vmeta_tsets // 'no __newindex' flag NOT set: check. + |6: + | mvn CARG4, #~LJ_TSTR + | str STR:RC, TMPDlo + | mov CARG2, TAB:RB + | str CARG4, TMPDhi + | bl extern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k) + | // Returns TValue *. + | ldr BASE, L->base + | ldrd CARG34, [BASE, RA] + | strd CARG34, [CRET1] + | b <3 // No 2nd write barrier needed. + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, CARG2, CARG3 + | b <3 + break; + case BC_TSETB: + | decode_RB8 RB, INS + | and RC, RC, #255 + | // RA = src*8, RB = table*8, RC = index + | ldrd CARG12, [BASE, RB] + | checktab CARG2, ->vmeta_tsetb // STALL: load CARG12. + | ldr CARG3, TAB:CARG1->asize + | ldr RB, TAB:CARG1->array + | lsl CARG2, RC, #3 + | cmp RC, CARG3 + | ldrdlo CARG34, [CARG2, RB]! + | bhs ->vmeta_tsetb + | ins_next1 // Overwrites RB! + | checktp CARG4, LJ_TNIL + | ldrb INS, TAB:CARG1->marked + | ldrd CARG34, [BASE, RA] + | beq >5 + |1: + | tst INS, #LJ_GC_BLACK // isblack(table) + | strd CARG34, [CARG2] + | bne >7 + |2: + | ins_next2 + | ins_next3 + | + |5: // Check for __newindex if previous value is nil. + | ldr TAB:RA, TAB:CARG1->metatable + | cmp TAB:RA, #0 + | beq <1 // No metatable: done. + | ldrb RA, TAB:RA->nomm + | tst RA, #1<vmeta_tsetb + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:CARG1, INS, CARG3 + | b <2 + break; + + case BC_TSETM: + | // RA = base*8 (table at base-1), RC = num_const (start index) + | add RA, BASE, RA + |1: + | ldr RB, SAVE_MULTRES + | ldr TAB:CARG2, [RA, #-8] // Guaranteed to be a table. + | ldr CARG1, [KBASE, RC, lsl #3] // Integer constant is in lo-word. + | subs RB, RB, #8 + | ldr CARG4, TAB:CARG2->asize + | beq >4 // Nothing to copy? + | add CARG3, CARG1, RB, lsr #3 + | cmp CARG3, CARG4 + | ldr CARG4, TAB:CARG2->array + | add RB, RA, RB + | bhi >5 + | add INS, CARG4, CARG1, lsl #3 + | ldrb CARG1, TAB:CARG2->marked + |3: // Copy result slots to table. + | ldrd CARG34, [RA], #8 + | strd CARG34, [INS], #8 + | cmp RA, RB + | blo <3 + | tst CARG1, #LJ_GC_BLACK // isblack(table) + | bne >7 + |4: + | ins_next + | + |5: // Need to resize array part. + | str BASE, L->base + | mov CARG1, L + | str PC, SAVE_PC + | bl extern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) + | // Must not reallocate the stack. + | .IOS ldr BASE, L->base + | b <1 + | + |7: // Possible table write barrier for any value. Skip valiswhite check. + | barrierback TAB:CARG2, CARG1, CARG3 + | b <4 + break; + + /* -- Calls and vararg handling ----------------------------------------- */ + + case BC_CALLM: + | // RA = base*8, (RB = nresults+1,) RC = extra_nargs + | ldr CARG1, SAVE_MULTRES + | decode_RC8 NARGS8:RC, INS + | add NARGS8:RC, NARGS8:RC, CARG1 + | b ->BC_CALL_Z + break; + case BC_CALL: + | decode_RC8 NARGS8:RC, INS + | // RA = base*8, (RB = nresults+1,) RC = (nargs+1)*8 + |->BC_CALL_Z: + | mov RB, BASE // Save old BASE for vmeta_call. + | ldrd CARG34, [BASE, RA]! + | sub NARGS8:RC, NARGS8:RC, #8 + | add BASE, BASE, #8 + | checkfunc CARG4, ->vmeta_call + | ins_call + break; + + case BC_CALLMT: + | // RA = base*8, (RB = 0,) RC = extra_nargs + | ldr CARG1, SAVE_MULTRES + | add NARGS8:RC, CARG1, RC, lsl #3 + | b ->BC_CALLT1_Z + break; + case BC_CALLT: + | lsl NARGS8:RC, RC, #3 + | // RA = base*8, (RB = 0,) RC = (nargs+1)*8 + |->BC_CALLT1_Z: + | ldrd LFUNC:CARG34, [RA, BASE]! + | sub NARGS8:RC, NARGS8:RC, #8 + | add RA, RA, #8 + | checkfunc CARG4, ->vmeta_callt + | ldr PC, [BASE, FRAME_PC] + |->BC_CALLT2_Z: + | mov RB, #0 + | ldrb CARG4, LFUNC:CARG3->ffid + | tst PC, #FRAME_TYPE + | bne >7 + |1: + | str LFUNC:CARG3, [BASE, FRAME_FUNC] // Copy function down, but keep PC. + | cmp NARGS8:RC, #0 + | beq >3 + |2: + | ldrd CARG12, [RA, RB] + | add INS, RB, #8 + | cmp INS, NARGS8:RC + | strd CARG12, [BASE, RB] + | mov RB, INS + | bne <2 + |3: + | cmp CARG4, #1 // (> FF_C) Calling a fast function? + | bhi >5 + |4: + | ins_callt + | + |5: // Tailcall to a fast function with a Lua frame below. + | ldr INS, [PC, #-4] + | decode_RA8 RA, INS + | sub CARG1, BASE, RA + | ldr LFUNC:CARG1, [CARG1, #-16] + | ldr CARG1, LFUNC:CARG1->field_pc + | ldr KBASE, [CARG1, #PC2PROTO(k)] + | b <4 + | + |7: // Tailcall from a vararg function. + | eor PC, PC, #FRAME_VARG + | tst PC, #FRAME_TYPEP // Vararg frame below? + | movne CARG4, #0 // Clear ffid if no Lua function below. + | bne <1 + | sub BASE, BASE, PC + | ldr PC, [BASE, FRAME_PC] + | tst PC, #FRAME_TYPE + | movne CARG4, #0 // Clear ffid if no Lua function below. + | b <1 + break; + + case BC_ITERC: + | // RA = base*8, (RB = nresults+1, RC = nargs+1 (2+1)) + | add RA, BASE, RA + | mov RB, BASE // Save old BASE for vmeta_call. + | ldrd CARG34, [RA, #-16] + | ldrd CARG12, [RA, #-8] + | add BASE, RA, #8 + | strd CARG34, [RA, #8] // Copy state. + | strd CARG12, [RA, #16] // Copy control var. + | // STALL: locked CARG34. + | ldrd LFUNC:CARG34, [RA, #-24] + | mov NARGS8:RC, #16 // Iterators get 2 arguments. + | // STALL: load CARG34. + | strd LFUNC:CARG34, [RA] // Copy callable. + | checkfunc CARG4, ->vmeta_call + | ins_call + break; + + case BC_ITERN: + | // RA = base*8, (RB = nresults+1, RC = nargs+1 (2+1)) + |.if JIT + | // NYI: add hotloop, record BC_ITERN. + |.endif + | add RA, BASE, RA + | ldr TAB:RB, [RA, #-16] + | ldr CARG1, [RA, #-8] // Get index from control var. + | ldr INS, TAB:RB->asize + | ldr CARG2, TAB:RB->array + | add PC, PC, #4 + |1: // Traverse array part. + | subs RC, CARG1, INS + | add CARG3, CARG2, CARG1, lsl #3 + | bhs >5 // Index points after array part? + | ldrd CARG34, [CARG3] + | checktp CARG4, LJ_TNIL + | addeq CARG1, CARG1, #1 // Skip holes in array part. + | beq <1 + | ldrh RC, [PC, #-2] + | mvn CARG2, #~LJ_TISNUM + | strd CARG34, [RA, #8] + | add RC, PC, RC, lsl #2 + | add RB, CARG1, #1 + | strd CARG12, [RA] + | sub PC, RC, #0x20000 + | str RB, [RA, #-8] // Update control var. + |3: + | ins_next + | + |5: // Traverse hash part. + | ldr CARG4, TAB:RB->hmask + | ldr NODE:RB, TAB:RB->node + |6: + | add CARG1, RC, RC, lsl #1 + | cmp RC, CARG4 // End of iteration? Branch to ITERL+1. + | add NODE:CARG3, NODE:RB, CARG1, lsl #3 // node = tab->node + idx*3*8 + | bhi <3 + | ldrd CARG12, NODE:CARG3->val + | checktp CARG2, LJ_TNIL + | add RC, RC, #1 + | beq <6 // Skip holes in hash part. + | ldrh RB, [PC, #-2] + | add RC, RC, INS + | ldrd CARG34, NODE:CARG3->key + | str RC, [RA, #-8] // Update control var. + | strd CARG12, [RA, #8] + | add RC, PC, RB, lsl #2 + | sub PC, RC, #0x20000 + | strd CARG34, [RA] + | b <3 + break; + + case BC_ISNEXT: + | // RA = base*8, RC = target (points to ITERN) + | add RA, BASE, RA + | add RC, PC, RC, lsl #2 + | ldrd CFUNC:CARG12, [RA, #-24] + | ldr CARG3, [RA, #-12] + | ldr CARG4, [RA, #-4] + | checktp CARG2, LJ_TFUNC + | ldrbeq CARG1, CFUNC:CARG1->ffid + | checktpeq CARG3, LJ_TTAB + | checktpeq CARG4, LJ_TNIL + | cmpeq CARG1, #FF_next_N + | subeq PC, RC, #0x20000 + | bne >5 + | ins_next1 + | ins_next2 + | mov CARG1, #0 + | mvn CARG2, #0x00018000 + | strd CARG1, [RA, #-8] // Initialize control var. + |1: + | ins_next3 + |5: // Despecialize bytecode if any of the checks fail. + | mov CARG1, #BC_JMP + | mov OP, #BC_ITERC + | strb CARG1, [PC, #-4] + | sub PC, RC, #0x20000 + | strb OP, [PC] // Subsumes ins_next1. + | ins_next2 + | b <1 + break; + + case BC_VARG: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | // RA = base*8, RB = (nresults+1)*8, RC = numparams*8 + | ldr CARG1, [BASE, FRAME_PC] + | add RC, BASE, RC + | add RA, BASE, RA + | add RC, RC, #FRAME_VARG + | add CARG4, RA, RB + | sub CARG3, BASE, #8 // CARG3 = vtop + | sub RC, RC, CARG1 // RC = vbase + | // Note: RC may now be even _above_ BASE if nargs was < numparams. + | cmp RB, #0 + | sub CARG1, CARG3, RC + | beq >5 // Copy all varargs? + | sub CARG4, CARG4, #16 + |1: // Copy vararg slots to destination slots. + | cmp RC, CARG3 + | ldrdlo CARG12, [RC], #8 + | mvnhs CARG2, #~LJ_TNIL + | cmp RA, CARG4 + | strd CARG12, [RA], #8 + | blo <1 + |2: + | ins_next + | + |5: // Copy all varargs. + | ldr CARG4, L->maxstack + | cmp CARG1, #0 + | movle RB, #8 // MULTRES = (0+1)*8 + | addgt RB, CARG1, #8 + | add CARG2, RA, CARG1 + | str RB, SAVE_MULTRES + | ble <2 + | cmp CARG2, CARG4 + | bhi >7 + |6: + | ldrd CARG12, [RC], #8 + | strd CARG12, [RA], #8 + | cmp RC, CARG3 + | blo <6 + | b <2 + | + |7: // Grow stack for varargs. + | lsr CARG2, CARG1, #3 + | str RA, L->top + | mov CARG1, L + | str BASE, L->base + | sub RC, RC, BASE // Need delta, because BASE may change. + | str PC, SAVE_PC + | sub RA, RA, BASE + | bl extern lj_state_growstack // (lua_State *L, int n) + | ldr BASE, L->base + | add RA, BASE, RA + | add RC, BASE, RC + | sub CARG3, BASE, #8 + | b <6 + break; + + /* -- Returns ----------------------------------------------------------- */ + + case BC_RETM: + | // RA = results*8, RC = extra results + | ldr CARG1, SAVE_MULTRES + | ldr PC, [BASE, FRAME_PC] + | add RA, BASE, RA + | add RC, CARG1, RC, lsl #3 + | b ->BC_RETM_Z + break; + + case BC_RET: + | // RA = results*8, RC = nresults+1 + | ldr PC, [BASE, FRAME_PC] + | lsl RC, RC, #3 + | add RA, BASE, RA + |->BC_RETM_Z: + | str RC, SAVE_MULTRES + |1: + | ands CARG1, PC, #FRAME_TYPE + | eor CARG2, PC, #FRAME_VARG + | bne ->BC_RETV2_Z + | + |->BC_RET_Z: + | // BASE = base, RA = resultptr, RC = (nresults+1)*8, PC = return + | ldr INS, [PC, #-4] + | subs CARG4, RC, #8 + | sub CARG3, BASE, #8 + | beq >3 + |2: + | ldrd CARG12, [RA], #8 + | add BASE, BASE, #8 + | subs CARG4, CARG4, #8 + | strd CARG12, [BASE, #-16] + | bne <2 + |3: + | decode_RA8 RA, INS + | sub CARG4, CARG3, RA + | decode_RB8 RB, INS + | ldr LFUNC:CARG1, [CARG4, FRAME_FUNC] + |5: + | cmp RB, RC // More results expected? + | bhi >6 + | mov BASE, CARG4 + | ldr CARG2, LFUNC:CARG1->field_pc + | ins_next1 + | ins_next2 + | ldr KBASE, [CARG2, #PC2PROTO(k)] + | ins_next3 + | + |6: // Fill up results with nil. + | mvn CARG2, #~LJ_TNIL + | add BASE, BASE, #8 + | add RC, RC, #8 + | str CARG2, [BASE, #-12] + | b <5 + | + |->BC_RETV1_Z: // Non-standard return case. + | add RA, BASE, RA + |->BC_RETV2_Z: + | tst CARG2, #FRAME_TYPEP + | bne ->vm_return + | // Return from vararg function: relocate BASE down. + | sub BASE, BASE, CARG2 + | ldr PC, [BASE, FRAME_PC] + | b <1 + break; + + case BC_RET0: case BC_RET1: + | // RA = results*8, RC = nresults+1 + | ldr PC, [BASE, FRAME_PC] + | lsl RC, RC, #3 + | str RC, SAVE_MULTRES + | ands CARG1, PC, #FRAME_TYPE + | eor CARG2, PC, #FRAME_VARG + | ldreq INS, [PC, #-4] + | bne ->BC_RETV1_Z + if (op == BC_RET1) { + | ldrd CARG12, [BASE, RA] + } + | sub CARG4, BASE, #8 + | decode_RA8 RA, INS + if (op == BC_RET1) { + | strd CARG12, [CARG4] + } + | sub BASE, CARG4, RA + | decode_RB8 RB, INS + | ldr LFUNC:CARG1, [BASE, FRAME_FUNC] + |5: + | cmp RB, RC + | bhi >6 + | ldr CARG2, LFUNC:CARG1->field_pc + | ins_next1 + | ins_next2 + | ldr KBASE, [CARG2, #PC2PROTO(k)] + | ins_next3 + | + |6: // Fill up results with nil. + | sub CARG2, CARG4, #4 + | mvn CARG3, #~LJ_TNIL + | str CARG3, [CARG2, RC] + | add RC, RC, #8 + | b <5 + break; + + /* -- Loops and branches ------------------------------------------------ */ + + |.define FOR_IDX, [RA]; .define FOR_TIDX, [RA, #4] + |.define FOR_STOP, [RA, #8]; .define FOR_TSTOP, [RA, #12] + |.define FOR_STEP, [RA, #16]; .define FOR_TSTEP, [RA, #20] + |.define FOR_EXT, [RA, #24]; .define FOR_TEXT, [RA, #28] + + case BC_FORL: + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_IFORL follows. + break; + + case BC_JFORI: + case BC_JFORL: +#if !LJ_HASJIT + break; +#endif + case BC_FORI: + case BC_IFORL: + | // RA = base*8, RC = target (after end of loop or start of loop) + vk = (op == BC_IFORL || op == BC_JFORL); + | ldrd CARG12, [RA, BASE]! + if (op != BC_JFORL) { + | add RC, PC, RC, lsl #2 + } + if (!vk) { + | ldrd CARG34, FOR_STOP + | checktp CARG2, LJ_TISNUM + | ldr RB, FOR_TSTEP + | bne >5 + | checktp CARG4, LJ_TISNUM + | ldr CARG4, FOR_STEP + | checktpeq RB, LJ_TISNUM + | bne ->vmeta_for + | cmp CARG4, #0 + | blt >4 + | cmp CARG1, CARG3 + } else { + | ldrd CARG34, FOR_STEP + | checktp CARG2, LJ_TISNUM + | bne >5 + | adds CARG1, CARG1, CARG3 + | ldr CARG4, FOR_STOP + if (op == BC_IFORL) { + | addvs RC, PC, #0x20000 // Overflow: prevent branch. + } else { + | bvs >2 // Overflow: do not enter mcode. + } + | cmp CARG3, #0 + | blt >4 + | cmp CARG1, CARG4 + } + |1: + if (op == BC_FORI) { + | subgt PC, RC, #0x20000 + } else if (op == BC_JFORI) { + | sub PC, RC, #0x20000 + | ldrhle RC, [PC, #-2] + } else if (op == BC_IFORL) { + | suble PC, RC, #0x20000 + } + if (vk) { + | strd CARG12, FOR_IDX + } + |2: + | ins_next1 + | ins_next2 + | strd CARG12, FOR_EXT + if (op == BC_JFORI || op == BC_JFORL) { + | ble =>BC_JLOOP + } + |3: + | ins_next3 + | + |4: // Invert check for negative step. + if (!vk) { + | cmp CARG3, CARG1 + } else { + | cmp CARG4, CARG1 + } + | b <1 + | + |5: // FP loop. + if (!vk) { + | cmnlo CARG4, #-LJ_TISNUM + | cmnlo RB, #-LJ_TISNUM + | bhs ->vmeta_for + |.if FPU + | vldr d0, FOR_IDX + | vldr d1, FOR_STOP + | cmp RB, #0 + | vstr d0, FOR_EXT + |.else + | cmp RB, #0 + | strd CARG12, FOR_EXT + | blt >8 + |.endif + } else { + |.if FPU + | vldr d0, FOR_IDX + | vldr d2, FOR_STEP + | vldr d1, FOR_STOP + | cmp CARG4, #0 + | vadd.f64 d0, d0, d2 + |.else + | cmp CARG4, #0 + | blt >8 + | bl extern __aeabi_dadd + | strd CARG12, FOR_IDX + | ldrd CARG34, FOR_STOP + | strd CARG12, FOR_EXT + |.endif + } + |6: + |.if FPU + | vcmpge.f64 d0, d1 + | vcmplt.f64 d1, d0 + | vmrs + |.else + | bl extern __aeabi_cdcmple + |.endif + if (vk) { + |.if FPU + | vstr d0, FOR_IDX + | vstr d0, FOR_EXT + |.endif + } + if (op == BC_FORI) { + | subhi PC, RC, #0x20000 + } else if (op == BC_JFORI) { + | sub PC, RC, #0x20000 + | ldrhls RC, [PC, #-2] + | bls =>BC_JLOOP + } else if (op == BC_IFORL) { + | subls PC, RC, #0x20000 + } else { + | bls =>BC_JLOOP + } + | ins_next1 + | ins_next2 + | b <3 + | + |.if not FPU + |8: // Invert check for negative step. + if (vk) { + | bl extern __aeabi_dadd + | strd CARG12, FOR_IDX + | strd CARG12, FOR_EXT + } + | mov CARG3, CARG1 + | mov CARG4, CARG2 + | ldrd CARG12, FOR_STOP + | b <6 + |.endif + break; + + case BC_ITERL: + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_IITERL follows. + break; + + case BC_JITERL: +#if !LJ_HASJIT + break; +#endif + case BC_IITERL: + | // RA = base*8, RC = target + | ldrd CARG12, [RA, BASE]! + if (op == BC_JITERL) { + | cmn CARG2, #-LJ_TNIL // Stop if iterator returned nil. + | strdne CARG12, [RA, #-8] + | bne =>BC_JLOOP + } else { + | add RC, PC, RC, lsl #2 + | // STALL: load CARG12. + | cmn CARG2, #-LJ_TNIL // Stop if iterator returned nil. + | subne PC, RC, #0x20000 // Otherwise save control var + branch. + | strdne CARG12, [RA, #-8] + } + | ins_next + break; + + case BC_LOOP: + | // RA = base*8, RC = target (loop extent) + | // Note: RA/RC is only used by trace recorder to determine scope/extent + | // This opcode does NOT jump, it's only purpose is to detect a hot loop. + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_ILOOP follows. + break; + + case BC_ILOOP: + | // RA = base*8, RC = target (loop extent) + | ins_next + break; + + case BC_JLOOP: + |.if JIT + | // RA = base (ignored), RC = traceno + | ldr CARG1, [DISPATCH, #DISPATCH_J(trace)] + | mov CARG2, #0 // Traces on ARM don't store the trace number, so use 0. + | ldr TRACE:RC, [CARG1, RC, lsl #2] + | st_vmstate CARG2 + | ldr RA, TRACE:RC->mcode + | str BASE, [DISPATCH, #DISPATCH_GL(jit_base)] + | str L, [DISPATCH, #DISPATCH_GL(jit_L)] + | bx RA + |.endif + break; + + case BC_JMP: + | // RA = base*8 (only used by trace recorder), RC = target + | add RC, PC, RC, lsl #2 + | sub PC, RC, #0x20000 + | ins_next + break; + + /* -- Function headers -------------------------------------------------- */ + + case BC_FUNCF: + |.if JIT + | hotcall + |.endif + case BC_FUNCV: /* NYI: compiled vararg functions. */ + | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow. + break; + + case BC_JFUNCF: +#if !LJ_HASJIT + break; +#endif + case BC_IFUNCF: + | // BASE = new base, RA = BASE+framesize*8, CARG3 = LFUNC, RC = nargs*8 + | ldr CARG1, L->maxstack + | ldrb CARG2, [PC, #-4+PC2PROTO(numparams)] + | ldr KBASE, [PC, #-4+PC2PROTO(k)] + | cmp RA, CARG1 + | bhi ->vm_growstack_l + if (op != BC_JFUNCF) { + | ins_next1 + | ins_next2 + } + |2: + | cmp NARGS8:RC, CARG2, lsl #3 // Check for missing parameters. + | mvn CARG4, #~LJ_TNIL + | blo >3 + if (op == BC_JFUNCF) { + | decode_RD RC, INS + | b =>BC_JLOOP + } else { + | ins_next3 + } + | + |3: // Clear missing parameters. + | strd CARG34, [BASE, NARGS8:RC] + | add NARGS8:RC, NARGS8:RC, #8 + | b <2 + break; + + case BC_JFUNCV: +#if !LJ_HASJIT + break; +#endif + | NYI // NYI: compiled vararg functions + break; /* NYI: compiled vararg functions. */ + + case BC_IFUNCV: + | // BASE = new base, RA = BASE+framesize*8, CARG3 = LFUNC, RC = nargs*8 + | ldr CARG1, L->maxstack + | add CARG4, BASE, RC + | add RA, RA, RC + | str LFUNC:CARG3, [CARG4] // Store copy of LFUNC. + | add CARG2, RC, #8+FRAME_VARG + | ldr KBASE, [PC, #-4+PC2PROTO(k)] + | cmp RA, CARG1 + | str CARG2, [CARG4, #4] // Store delta + FRAME_VARG. + | bhs ->vm_growstack_l + | ldrb RB, [PC, #-4+PC2PROTO(numparams)] + | mov RA, BASE + | mov RC, CARG4 + | cmp RB, #0 + | add BASE, CARG4, #8 + | beq >3 + | mvn CARG3, #~LJ_TNIL + |1: + | cmp RA, RC // Less args than parameters? + | ldrdlo CARG12, [RA], #8 + | movhs CARG2, CARG3 + | strlo CARG3, [RA, #-4] // Clear old fixarg slot (help the GC). + |2: + | subs RB, RB, #1 + | strd CARG12, [CARG4, #8]! + | bne <1 + |3: + | ins_next + break; + + case BC_FUNCC: + case BC_FUNCCW: + | // BASE = new base, RA = BASE+framesize*8, CARG3 = CFUNC, RC = nargs*8 + if (op == BC_FUNCC) { + | ldr CARG4, CFUNC:CARG3->f + } else { + | ldr CARG4, [DISPATCH, #DISPATCH_GL(wrapf)] + } + | add CARG2, RA, NARGS8:RC + | ldr CARG1, L->maxstack + | add RC, BASE, NARGS8:RC + | str BASE, L->base + | cmp CARG2, CARG1 + | str RC, L->top + if (op == BC_FUNCCW) { + | ldr CARG2, CFUNC:CARG3->f + } + | mv_vmstate CARG3, C + | mov CARG1, L + | bhi ->vm_growstack_c // Need to grow stack. + | st_vmstate CARG3 + | blx CARG4 // (lua_State *L [, lua_CFunction f]) + | // Returns nresults. + | ldr BASE, L->base + | mv_vmstate CARG3, INTERP + | ldr CRET2, L->top + | lsl RC, CRET1, #3 + | st_vmstate CARG3 + | ldr PC, [BASE, FRAME_PC] + | sub RA, CRET2, RC // RA = L->top - nresults*8 + | b ->vm_returnc + break; + + /* ---------------------------------------------------------------------- */ + + default: + fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); + exit(2); + break; + } +} + +static int build_backend(BuildCtx *ctx) +{ + int op; + + dasm_growpc(Dst, BC__MAX); + + build_subroutines(ctx); + + |.code_op + for (op = 0; op < BC__MAX; op++) + build_ins(ctx, (BCOp)op, op); + + return BC__MAX; +} + +/* Emit pseudo frame-info for all assembler functions. */ +static void emit_asm_debug(BuildCtx *ctx) +{ + int fcofs = (int)((uint8_t *)ctx->glob[GLOB_vm_ffi_call] - ctx->code); + int i; + switch (ctx->mode) { + case BUILD_elfasm: + fprintf(ctx->fp, "\t.section .debug_frame,\"\",%%progbits\n"); + fprintf(ctx->fp, + ".Lframe0:\n" + "\t.long .LECIE0-.LSCIE0\n" + ".LSCIE0:\n" + "\t.long 0xffffffff\n" + "\t.byte 0x1\n" + "\t.string \"\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -4\n" + "\t.byte 0xe\n" /* Return address is in lr. */ + "\t.byte 0xc\n\t.uleb128 0xd\n\t.uleb128 0\n" /* def_cfa sp */ + "\t.align 2\n" + ".LECIE0:\n\n"); + fprintf(ctx->fp, + ".LSFDE0:\n" + "\t.long .LEFDE0-.LASFDE0\n" + ".LASFDE0:\n" + "\t.long .Lframe0\n" + "\t.long .Lbegin\n" + "\t.long %d\n" + "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ + "\t.byte 0x8e\n\t.uleb128 1\n", /* offset lr */ + fcofs, CFRAME_SIZE); + for (i = 11; i >= (LJ_ARCH_HASFPU ? 5 : 4); i--) /* offset r4-r11 */ + fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+i, 2+(11-i)); +#if LJ_ARCH_HASFPU + for (i = 15; i >= 8; i--) /* offset d8-d15 */ + fprintf(ctx->fp, "\t.byte 5\n\t.uleb128 %d, %d\n", + 64+2*i, 10+2*(15-i)); + fprintf(ctx->fp, "\t.byte 0x84\n\t.uleb128 %d\n", 25); /* offset r4 */ +#endif + fprintf(ctx->fp, + "\t.align 2\n" + ".LEFDE0:\n\n"); +#if LJ_HASFFI + fprintf(ctx->fp, + ".LSFDE1:\n" + "\t.long .LEFDE1-.LASFDE1\n" + ".LASFDE1:\n" + "\t.long .Lframe0\n" + "\t.long lj_vm_ffi_call\n" + "\t.long %d\n" + "\t.byte 0xe\n\t.uleb128 16\n" /* def_cfa_offset */ + "\t.byte 0x8e\n\t.uleb128 1\n" /* offset lr */ + "\t.byte 0x8b\n\t.uleb128 2\n" /* offset r11 */ + "\t.byte 0x85\n\t.uleb128 3\n" /* offset r5 */ + "\t.byte 0x84\n\t.uleb128 4\n" /* offset r4 */ + "\t.byte 0xd\n\t.uleb128 0xb\n" /* def_cfa_register r11 */ + "\t.align 2\n" + ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); +#endif + break; + default: + break; + } +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/vm_mips.dasc b/source/libs/luajit/LuaJIT-2.0.4/src/vm_mips.dasc new file mode 100644 index 000000000..ac8346bbd --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/vm_mips.dasc @@ -0,0 +1,4241 @@ +|// Low-level VM code for MIPS CPUs. +|// Bytecode interpreter, fast functions and helper functions. +|// Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +| +|.arch mips +|.section code_op, code_sub +| +|.actionlist build_actionlist +|.globals GLOB_ +|.globalnames globnames +|.externnames extnames +| +|// Note: The ragged indentation of the instructions is intentional. +|// The starting columns indicate data dependencies. +| +|//----------------------------------------------------------------------- +| +|// Fixed register assignments for the interpreter. +|// Don't use: r0 = 0, r26/r27 = reserved, r28 = gp, r29 = sp, r31 = ra +| +|// The following must be C callee-save (but BASE is often refetched). +|.define BASE, r16 // Base of current Lua stack frame. +|.define KBASE, r17 // Constants of current Lua function. +|.define PC, r18 // Next PC. +|.define DISPATCH, r19 // Opcode dispatch table. +|.define LREG, r20 // Register holding lua_State (also in SAVE_L). +|.define MULTRES, r21 // Size of multi-result: (nresults+1)*8. +|// NYI: r22 currently unused. +| +|.define JGL, r30 // On-trace: global_State + 32768. +| +|// Constants for type-comparisons, stores and conversions. C callee-save. +|.define TISNIL, r30 +|.define TOBIT, f30 // 2^52 + 2^51. +| +|// The following temporaries are not saved across C calls, except for RA. +|.define RA, r23 // Callee-save. +|.define RB, r8 +|.define RC, r9 +|.define RD, r10 +|.define INS, r11 +| +|.define AT, r1 // Assembler temporary. +|.define TMP0, r12 +|.define TMP1, r13 +|.define TMP2, r14 +|.define TMP3, r15 +| +|// Calling conventions. +|.define CFUNCADDR, r25 +|.define CARG1, r4 +|.define CARG2, r5 +|.define CARG3, r6 +|.define CARG4, r7 +| +|.define CRET1, r2 +|.define CRET2, r3 +| +|.define FARG1, f12 +|.define FARG2, f14 +| +|.define FRET1, f0 +|.define FRET2, f2 +| +|// Stack layout while in interpreter. Must match with lj_frame.h. +|.define CFRAME_SPACE, 112 // Delta for sp. +| +|.define SAVE_ERRF, 124(sp) // 32 bit C frame info. +|.define SAVE_NRES, 120(sp) +|.define SAVE_CFRAME, 116(sp) +|.define SAVE_L, 112(sp) +|//----- 8 byte aligned, ^^^^ 16 byte register save area, owned by interpreter. +|.define SAVE_GPR_, 72 // .. 72+10*4: 32 bit GPR saves. +|.define SAVE_FPR_, 24 // .. 24+6*8: 64 bit FPR saves. +|.define SAVE_PC, 20(sp) +|.define ARG5, 16(sp) +|.define CSAVE_4, 12(sp) +|.define CSAVE_3, 8(sp) +|.define CSAVE_2, 4(sp) +|.define CSAVE_1, 0(sp) +|//----- 8 byte aligned, ^^^^ 16 byte register save area, owned by callee. +| +|.define ARG5_OFS, 16 +|.define SAVE_MULTRES, ARG5 +| +|.macro saveregs +| addiu sp, sp, -CFRAME_SPACE +| sw ra, SAVE_GPR_+9*4(sp) +| sw r30, SAVE_GPR_+8*4(sp) +| sdc1 f30, SAVE_FPR_+5*8(sp) +| sw r23, SAVE_GPR_+7*4(sp) +| sw r22, SAVE_GPR_+6*4(sp) +| sdc1 f28, SAVE_FPR_+4*8(sp) +| sw r21, SAVE_GPR_+5*4(sp) +| sw r20, SAVE_GPR_+4*4(sp) +| sdc1 f26, SAVE_FPR_+3*8(sp) +| sw r19, SAVE_GPR_+3*4(sp) +| sw r18, SAVE_GPR_+2*4(sp) +| sdc1 f24, SAVE_FPR_+2*8(sp) +| sw r17, SAVE_GPR_+1*4(sp) +| sw r16, SAVE_GPR_+0*4(sp) +| sdc1 f22, SAVE_FPR_+1*8(sp) +| sdc1 f20, SAVE_FPR_+0*8(sp) +|.endmacro +| +|.macro restoreregs_ret +| lw ra, SAVE_GPR_+9*4(sp) +| lw r30, SAVE_GPR_+8*4(sp) +| ldc1 f30, SAVE_FPR_+5*8(sp) +| lw r23, SAVE_GPR_+7*4(sp) +| lw r22, SAVE_GPR_+6*4(sp) +| ldc1 f28, SAVE_FPR_+4*8(sp) +| lw r21, SAVE_GPR_+5*4(sp) +| lw r20, SAVE_GPR_+4*4(sp) +| ldc1 f26, SAVE_FPR_+3*8(sp) +| lw r19, SAVE_GPR_+3*4(sp) +| lw r18, SAVE_GPR_+2*4(sp) +| ldc1 f24, SAVE_FPR_+2*8(sp) +| lw r17, SAVE_GPR_+1*4(sp) +| lw r16, SAVE_GPR_+0*4(sp) +| ldc1 f22, SAVE_FPR_+1*8(sp) +| ldc1 f20, SAVE_FPR_+0*8(sp) +| jr ra +| addiu sp, sp, CFRAME_SPACE +|.endmacro +| +|// Type definitions. Some of these are only used for documentation. +|.type L, lua_State, LREG +|.type GL, global_State +|.type TVALUE, TValue +|.type GCOBJ, GCobj +|.type STR, GCstr +|.type TAB, GCtab +|.type LFUNC, GCfuncL +|.type CFUNC, GCfuncC +|.type PROTO, GCproto +|.type UPVAL, GCupval +|.type NODE, Node +|.type NARGS8, int +|.type TRACE, GCtrace +| +|//----------------------------------------------------------------------- +| +|// Trap for not-yet-implemented parts. +|.macro NYI; .long 0xf0f0f0f0; .endmacro +| +|// Macros to mark delay slots. +|.macro ., a; a; .endmacro +|.macro ., a,b; a,b; .endmacro +|.macro ., a,b,c; a,b,c; .endmacro +| +|//----------------------------------------------------------------------- +| +|// Endian-specific defines. +|.define FRAME_PC, LJ_ENDIAN_SELECT(-4,-8) +|.define FRAME_FUNC, LJ_ENDIAN_SELECT(-8,-4) +|.define HI, LJ_ENDIAN_SELECT(4,0) +|.define LO, LJ_ENDIAN_SELECT(0,4) +|.define OFS_RD, LJ_ENDIAN_SELECT(2,0) +|.define OFS_RA, LJ_ENDIAN_SELECT(1,2) +|.define OFS_OP, LJ_ENDIAN_SELECT(0,3) +| +|// Instruction decode. +|.macro decode_OP1, dst, ins; andi dst, ins, 0xff; .endmacro +|.macro decode_OP4a, dst, ins; andi dst, ins, 0xff; .endmacro +|.macro decode_OP4b, dst; sll dst, dst, 2; .endmacro +|.macro decode_RC4a, dst, ins; srl dst, ins, 14; .endmacro +|.macro decode_RC4b, dst; andi dst, dst, 0x3fc; .endmacro +|.macro decode_RD4b, dst; sll dst, dst, 2; .endmacro +|.macro decode_RA8a, dst, ins; srl dst, ins, 5; .endmacro +|.macro decode_RA8b, dst; andi dst, dst, 0x7f8; .endmacro +|.macro decode_RB8a, dst, ins; srl dst, ins, 21; .endmacro +|.macro decode_RB8b, dst; andi dst, dst, 0x7f8; .endmacro +|.macro decode_RD8a, dst, ins; srl dst, ins, 16; .endmacro +|.macro decode_RD8b, dst; sll dst, dst, 3; .endmacro +|.macro decode_RDtoRC8, dst, src; andi dst, src, 0x7f8; .endmacro +| +|// Instruction fetch. +|.macro ins_NEXT1 +| lw INS, 0(PC) +| addiu PC, PC, 4 +|.endmacro +|// Instruction decode+dispatch. +|.macro ins_NEXT2 +| decode_OP4a TMP1, INS +| decode_OP4b TMP1 +| addu TMP0, DISPATCH, TMP1 +| decode_RD8a RD, INS +| lw AT, 0(TMP0) +| decode_RA8a RA, INS +| decode_RD8b RD +| jr AT +| decode_RA8b RA +|.endmacro +|.macro ins_NEXT +| ins_NEXT1 +| ins_NEXT2 +|.endmacro +| +|// Instruction footer. +|.if 1 +| // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. +| .define ins_next, ins_NEXT +| .define ins_next_, ins_NEXT +| .define ins_next1, ins_NEXT1 +| .define ins_next2, ins_NEXT2 +|.else +| // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. +| // Affects only certain kinds of benchmarks (and only with -j off). +| .macro ins_next +| b ->ins_next +| .endmacro +| .macro ins_next1 +| .endmacro +| .macro ins_next2 +| b ->ins_next +| .endmacro +| .macro ins_next_ +| ->ins_next: +| ins_NEXT +| .endmacro +|.endif +| +|// Call decode and dispatch. +|.macro ins_callt +| // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC +| lw PC, LFUNC:RB->pc +| lw INS, 0(PC) +| addiu PC, PC, 4 +| decode_OP4a TMP1, INS +| decode_RA8a RA, INS +| decode_OP4b TMP1 +| decode_RA8b RA +| addu TMP0, DISPATCH, TMP1 +| lw TMP0, 0(TMP0) +| jr TMP0 +| addu RA, RA, BASE +|.endmacro +| +|.macro ins_call +| // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, PC = caller PC +| sw PC, FRAME_PC(BASE) +| ins_callt +|.endmacro +| +|//----------------------------------------------------------------------- +| +|.macro branch_RD +| srl TMP0, RD, 1 +| lui AT, (-(BCBIAS_J*4 >> 16) & 65535) +| addu TMP0, TMP0, AT +| addu PC, PC, TMP0 +|.endmacro +| +|// Assumes DISPATCH is relative to GL. +#define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) +#define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) +#define GG_DISP2GOT (GG_OFS(got) - GG_OFS(dispatch)) +#define DISPATCH_GOT(name) (GG_DISP2GOT + 4*LJ_GOT_##name) +| +#define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) +| +|.macro load_got, func +| lw CFUNCADDR, DISPATCH_GOT(func)(DISPATCH) +|.endmacro +|// Much faster. Sadly, there's no easy way to force the required code layout. +|// .macro call_intern, func; bal extern func; .endmacro +|.macro call_intern, func; jalr CFUNCADDR; .endmacro +|.macro call_extern; jalr CFUNCADDR; .endmacro +|.macro jmp_extern; jr CFUNCADDR; .endmacro +| +|.macro hotcheck, delta, target +| srl TMP1, PC, 1 +| andi TMP1, TMP1, 126 +| addu TMP1, TMP1, DISPATCH +| lhu TMP2, GG_DISP2HOT(TMP1) +| addiu TMP2, TMP2, -delta +| bltz TMP2, target +|. sh TMP2, GG_DISP2HOT(TMP1) +|.endmacro +| +|.macro hotloop +| hotcheck HOTCOUNT_LOOP, ->vm_hotloop +|.endmacro +| +|.macro hotcall +| hotcheck HOTCOUNT_CALL, ->vm_hotcall +|.endmacro +| +|// Set current VM state. Uses TMP0. +|.macro li_vmstate, st; li TMP0, ~LJ_VMST_..st; .endmacro +|.macro st_vmstate; sw TMP0, DISPATCH_GL(vmstate)(DISPATCH); .endmacro +| +|// Move table write barrier back. Overwrites mark and tmp. +|.macro barrierback, tab, mark, tmp, target +| lw tmp, DISPATCH_GL(gc.grayagain)(DISPATCH) +| andi mark, mark, ~LJ_GC_BLACK & 255 // black2gray(tab) +| sw tab, DISPATCH_GL(gc.grayagain)(DISPATCH) +| sb mark, tab->marked +| b target +|. sw tmp, tab->gclist +|.endmacro +| +|//----------------------------------------------------------------------- + +/* Generate subroutines used by opcodes and other parts of the VM. */ +/* The .code_sub section should be last to help static branch prediction. */ +static void build_subroutines(BuildCtx *ctx) +{ + |.code_sub + | + |//----------------------------------------------------------------------- + |//-- Return handling ---------------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_returnp: + | // See vm_return. Also: TMP2 = previous base. + | andi AT, PC, FRAME_P + | beqz AT, ->cont_dispatch + |. li TMP1, LJ_TTRUE + | + | // Return from pcall or xpcall fast func. + | lw PC, FRAME_PC(TMP2) // Fetch PC of previous frame. + | move BASE, TMP2 // Restore caller base. + | // Prepending may overwrite the pcall frame, so do it at the end. + | sw TMP1, FRAME_PC(RA) // Prepend true to results. + | addiu RA, RA, -8 + | + |->vm_returnc: + | addiu RD, RD, 8 // RD = (nresults+1)*8. + | andi TMP0, PC, FRAME_TYPE + | beqz RD, ->vm_unwind_c_eh + |. li CRET1, LUA_YIELD + | beqz TMP0, ->BC_RET_Z // Handle regular return to Lua. + |. move MULTRES, RD + | + |->vm_return: + | // BASE = base, RA = resultptr, RD/MULTRES = (nresults+1)*8, PC = return + | // TMP0 = PC & FRAME_TYPE + | li TMP2, -8 + | xori AT, TMP0, FRAME_C + | and TMP2, PC, TMP2 + | bnez AT, ->vm_returnp + | subu TMP2, BASE, TMP2 // TMP2 = previous base. + | + | addiu TMP1, RD, -8 + | sw TMP2, L->base + | li_vmstate C + | lw TMP2, SAVE_NRES + | addiu BASE, BASE, -8 + | st_vmstate + | beqz TMP1, >2 + |. sll TMP2, TMP2, 3 + |1: + | addiu TMP1, TMP1, -8 + | ldc1 f0, 0(RA) + | addiu RA, RA, 8 + | sdc1 f0, 0(BASE) + | bnez TMP1, <1 + |. addiu BASE, BASE, 8 + | + |2: + | bne TMP2, RD, >6 + |3: + |. sw BASE, L->top // Store new top. + | + |->vm_leave_cp: + | lw TMP0, SAVE_CFRAME // Restore previous C frame. + | move CRET1, r0 // Ok return status for vm_pcall. + | sw TMP0, L->cframe + | + |->vm_leave_unw: + | restoreregs_ret + | + |6: + | lw TMP1, L->maxstack + | slt AT, TMP2, RD + | bnez AT, >7 // Less results wanted? + | // More results wanted. Check stack size and fill up results with nil. + |. slt AT, BASE, TMP1 + | beqz AT, >8 + |. nop + | sw TISNIL, HI(BASE) + | addiu RD, RD, 8 + | b <2 + |. addiu BASE, BASE, 8 + | + |7: // Less results wanted. + | subu TMP0, RD, TMP2 + | subu TMP0, BASE, TMP0 // Either keep top or shrink it. + | b <3 + |. movn BASE, TMP0, TMP2 // LUA_MULTRET+1 case? + | + |8: // Corner case: need to grow stack for filling up results. + | // This can happen if: + | // - A C function grows the stack (a lot). + | // - The GC shrinks the stack in between. + | // - A return back from a lua_call() with (high) nresults adjustment. + | load_got lj_state_growstack + | move MULTRES, RD + | srl CARG2, TMP2, 3 + | call_intern lj_state_growstack // (lua_State *L, int n) + |. move CARG1, L + | lw TMP2, SAVE_NRES + | lw BASE, L->top // Need the (realloced) L->top in BASE. + | move RD, MULTRES + | b <2 + |. sll TMP2, TMP2, 3 + | + |->vm_unwind_c: // Unwind C stack, return from vm_pcall. + | // (void *cframe, int errcode) + | move sp, CARG1 + | move CRET1, CARG2 + |->vm_unwind_c_eh: // Landing pad for external unwinder. + | lw L, SAVE_L + | li TMP0, ~LJ_VMST_C + | lw GL:TMP1, L->glref + | b ->vm_leave_unw + |. sw TMP0, GL:TMP1->vmstate + | + |->vm_unwind_ff: // Unwind C stack, return from ff pcall. + | // (void *cframe) + | li AT, -4 + | and sp, CARG1, AT + |->vm_unwind_ff_eh: // Landing pad for external unwinder. + | lw L, SAVE_L + | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | li TISNIL, LJ_TNIL + | lw BASE, L->base + | lw DISPATCH, L->glref // Setup pointer to dispatch table. + | mtc1 TMP3, TOBIT + | li TMP1, LJ_TFALSE + | li_vmstate INTERP + | lw PC, FRAME_PC(BASE) // Fetch PC of previous frame. + | cvt.d.s TOBIT, TOBIT + | addiu RA, BASE, -8 // Results start at BASE-8. + | addiu DISPATCH, DISPATCH, GG_G2DISP + | sw TMP1, HI(RA) // Prepend false to error message. + | st_vmstate + | b ->vm_returnc + |. li RD, 16 // 2 results: false + error message. + | + |//----------------------------------------------------------------------- + |//-- Grow stack for calls ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_growstack_c: // Grow stack for C function. + | b >2 + |. li CARG2, LUA_MINSTACK + | + |->vm_growstack_l: // Grow stack for Lua function. + | // BASE = new base, RA = BASE+framesize*8, RC = nargs*8, PC = first PC + | addu RC, BASE, RC + | subu RA, RA, BASE + | sw BASE, L->base + | addiu PC, PC, 4 // Must point after first instruction. + | sw RC, L->top + | srl CARG2, RA, 3 + |2: + | // L->base = new base, L->top = top + | load_got lj_state_growstack + | sw PC, SAVE_PC + | call_intern lj_state_growstack // (lua_State *L, int n) + |. move CARG1, L + | lw BASE, L->base + | lw RC, L->top + | lw LFUNC:RB, FRAME_FUNC(BASE) + | subu RC, RC, BASE + | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC + | ins_callt // Just retry the call. + | + |//----------------------------------------------------------------------- + |//-- Entry points into the assembler VM --------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_resume: // Setup C frame and resume thread. + | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) + | saveregs + | move L, CARG1 + | lw DISPATCH, L->glref // Setup pointer to dispatch table. + | move BASE, CARG2 + | lbu TMP1, L->status + | sw L, SAVE_L + | li PC, FRAME_CP + | addiu TMP0, sp, CFRAME_RESUME + | addiu DISPATCH, DISPATCH, GG_G2DISP + | sw r0, SAVE_NRES + | sw r0, SAVE_ERRF + | sw TMP0, L->cframe + | sw r0, SAVE_CFRAME + | beqz TMP1, >3 + |. sw CARG1, SAVE_PC // Any value outside of bytecode is ok. + | + | // Resume after yield (like a return). + | move RA, BASE + | lw BASE, L->base + | lw TMP1, L->top + | lw PC, FRAME_PC(BASE) + | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | subu RD, TMP1, BASE + | mtc1 TMP3, TOBIT + | sb r0, L->status + | cvt.d.s TOBIT, TOBIT + | li_vmstate INTERP + | addiu RD, RD, 8 + | st_vmstate + | move MULTRES, RD + | andi TMP0, PC, FRAME_TYPE + | beqz TMP0, ->BC_RET_Z + |. li TISNIL, LJ_TNIL + | b ->vm_return + |. nop + | + |->vm_pcall: // Setup protected C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) + | saveregs + | sw CARG4, SAVE_ERRF + | b >1 + |. li PC, FRAME_CP + | + |->vm_call: // Setup C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1) + | saveregs + | li PC, FRAME_C + | + |1: // Entry point for vm_pcall above (PC = ftype). + | lw TMP1, L:CARG1->cframe + | sw CARG3, SAVE_NRES + | move L, CARG1 + | sw CARG1, SAVE_L + | move BASE, CARG2 + | sw sp, L->cframe // Add our C frame to cframe chain. + | lw DISPATCH, L->glref // Setup pointer to dispatch table. + | sw CARG1, SAVE_PC // Any value outside of bytecode is ok. + | sw TMP1, SAVE_CFRAME + | addiu DISPATCH, DISPATCH, GG_G2DISP + | + |3: // Entry point for vm_cpcall/vm_resume (BASE = base, PC = ftype). + | lw TMP2, L->base // TMP2 = old base (used in vmeta_call). + | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | lw TMP1, L->top + | mtc1 TMP3, TOBIT + | addu PC, PC, BASE + | subu NARGS8:RC, TMP1, BASE + | subu PC, PC, TMP2 // PC = frame delta + frame type + | cvt.d.s TOBIT, TOBIT + | li_vmstate INTERP + | li TISNIL, LJ_TNIL + | st_vmstate + | + |->vm_call_dispatch: + | // TMP2 = old base, BASE = new base, RC = nargs*8, PC = caller PC + | lw TMP0, FRAME_PC(BASE) + | li AT, LJ_TFUNC + | bne TMP0, AT, ->vmeta_call + |. lw LFUNC:RB, FRAME_FUNC(BASE) + | + |->vm_call_dispatch_f: + | ins_call + | // BASE = new base, RB = func, RC = nargs*8, PC = caller PC + | + |->vm_cpcall: // Setup protected C frame, call C. + | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) + | saveregs + | move L, CARG1 + | lw TMP0, L:CARG1->stack + | sw CARG1, SAVE_L + | lw TMP1, L->top + | sw CARG1, SAVE_PC // Any value outside of bytecode is ok. + | subu TMP0, TMP0, TMP1 // Compute -savestack(L, L->top). + | lw TMP1, L->cframe + | sw sp, L->cframe // Add our C frame to cframe chain. + | sw TMP0, SAVE_NRES // Neg. delta means cframe w/o frame. + | sw r0, SAVE_ERRF // No error function. + | move CFUNCADDR, CARG4 + | jalr CARG4 // (lua_State *L, lua_CFunction func, void *ud) + |. sw TMP1, SAVE_CFRAME + | move BASE, CRET1 + | lw DISPATCH, L->glref // Setup pointer to dispatch table. + | li PC, FRAME_CP + | bnez CRET1, <3 // Else continue with the call. + |. addiu DISPATCH, DISPATCH, GG_G2DISP + | b ->vm_leave_cp // No base? Just remove C frame. + |. nop + | + |//----------------------------------------------------------------------- + |//-- Metamethod handling ------------------------------------------------ + |//----------------------------------------------------------------------- + | + |// The lj_meta_* functions (except for lj_meta_cat) don't reallocate the + |// stack, so BASE doesn't need to be reloaded across these calls. + | + |//-- Continuation dispatch ---------------------------------------------- + | + |->cont_dispatch: + | // BASE = meta base, RA = resultptr, RD = (nresults+1)*8 + | lw TMP0, -16+LO(BASE) // Continuation. + | move RB, BASE + | move BASE, TMP2 // Restore caller BASE. + | lw LFUNC:TMP1, FRAME_FUNC(TMP2) + |.if FFI + | sltiu AT, TMP0, 2 + |.endif + | lw PC, -16+HI(RB) // Restore PC from [cont|PC]. + | addu TMP2, RA, RD + | lw TMP1, LFUNC:TMP1->pc + |.if FFI + | bnez AT, >1 + |.endif + |. sw TISNIL, -8+HI(TMP2) // Ensure one valid arg. + | // BASE = base, RA = resultptr, RB = meta base + | jr TMP0 // Jump to continuation. + |. lw KBASE, PC2PROTO(k)(TMP1) + | + |.if FFI + |1: + | bnez TMP0, ->cont_ffi_callback // cont = 1: return from FFI callback. + | // cont = 0: tailcall from C function. + |. addiu TMP1, RB, -16 + | b ->vm_call_tail + |. subu RC, TMP1, BASE + |.endif + | + |->cont_cat: // RA = resultptr, RB = meta base + | lw INS, -4(PC) + | addiu CARG2, RB, -16 + | ldc1 f0, 0(RA) + | decode_RB8a MULTRES, INS + | decode_RA8a RA, INS + | decode_RB8b MULTRES + | decode_RA8b RA + | addu TMP1, BASE, MULTRES + | sw BASE, L->base + | subu CARG3, CARG2, TMP1 + | bne TMP1, CARG2, ->BC_CAT_Z + |. sdc1 f0, 0(CARG2) + | addu RA, BASE, RA + | b ->cont_nop + |. sdc1 f0, 0(RA) + | + |//-- Table indexing metamethods ----------------------------------------- + | + |->vmeta_tgets1: + | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) + | li TMP0, LJ_TSTR + | sw STR:RC, LO(CARG3) + | b >1 + |. sw TMP0, HI(CARG3) + | + |->vmeta_tgets: + | addiu CARG2, DISPATCH, DISPATCH_GL(tmptv) + | li TMP0, LJ_TTAB + | sw TAB:RB, LO(CARG2) + | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv2) + | sw TMP0, HI(CARG2) + | li TMP1, LJ_TSTR + | sw STR:RC, LO(CARG3) + | b >1 + |. sw TMP1, HI(CARG3) + | + |->vmeta_tgetb: // TMP0 = index + | mtc1 TMP0, f0 + | cvt.d.w f0, f0 + | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) + | sdc1 f0, 0(CARG3) + | + |->vmeta_tgetv: + |1: + | load_got lj_meta_tget + | sw BASE, L->base + | sw PC, SAVE_PC + | call_intern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) + |. move CARG1, L + | // Returns TValue * (finished) or NULL (metamethod). + | beqz CRET1, >3 + |. addiu TMP1, BASE, -FRAME_CONT + | ldc1 f0, 0(CRET1) + | ins_next1 + | sdc1 f0, 0(RA) + | ins_next2 + | + |3: // Call __index metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k + | lw BASE, L->top + | sw PC, -16+HI(BASE) // [cont|PC] + | subu PC, BASE, TMP1 + | lw LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. + | b ->vm_call_dispatch_f + |. li NARGS8:RC, 16 // 2 args for func(t, k). + | + |//----------------------------------------------------------------------- + | + |->vmeta_tsets1: + | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) + | li TMP0, LJ_TSTR + | sw STR:RC, LO(CARG3) + | b >1 + |. sw TMP0, HI(CARG3) + | + |->vmeta_tsets: + | addiu CARG2, DISPATCH, DISPATCH_GL(tmptv) + | li TMP0, LJ_TTAB + | sw TAB:RB, LO(CARG2) + | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv2) + | sw TMP0, HI(CARG2) + | li TMP1, LJ_TSTR + | sw STR:RC, LO(CARG3) + | b >1 + |. sw TMP1, HI(CARG3) + | + |->vmeta_tsetb: // TMP0 = index + | mtc1 TMP0, f0 + | cvt.d.w f0, f0 + | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) + | sdc1 f0, 0(CARG3) + | + |->vmeta_tsetv: + |1: + | load_got lj_meta_tset + | sw BASE, L->base + | sw PC, SAVE_PC + | call_intern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) + |. move CARG1, L + | // Returns TValue * (finished) or NULL (metamethod). + | beqz CRET1, >3 + |. ldc1 f0, 0(RA) + | // NOBARRIER: lj_meta_tset ensures the table is not black. + | ins_next1 + | sdc1 f0, 0(CRET1) + | ins_next2 + | + |3: // Call __newindex metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) + | addiu TMP1, BASE, -FRAME_CONT + | lw BASE, L->top + | sw PC, -16+HI(BASE) // [cont|PC] + | subu PC, BASE, TMP1 + | lw LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. + | sdc1 f0, 16(BASE) // Copy value to third argument. + | b ->vm_call_dispatch_f + |. li NARGS8:RC, 24 // 3 args for func(t, k, v) + | + |//-- Comparison metamethods --------------------------------------------- + | + |->vmeta_comp: + | // CARG2, CARG3 are already set by BC_ISLT/BC_ISGE/BC_ISLE/BC_ISGT. + | load_got lj_meta_comp + | addiu PC, PC, -4 + | sw BASE, L->base + | sw PC, SAVE_PC + | decode_OP1 CARG4, INS + | call_intern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) + |. move CARG1, L + | // Returns 0/1 or TValue * (metamethod). + |3: + | sltiu AT, CRET1, 2 + | beqz AT, ->vmeta_binop + | negu TMP2, CRET1 + |4: + | lhu RD, OFS_RD(PC) + | addiu PC, PC, 4 + | lui TMP1, (-(BCBIAS_J*4 >> 16) & 65535) + | sll RD, RD, 2 + | addu RD, RD, TMP1 + | and RD, RD, TMP2 + | addu PC, PC, RD + |->cont_nop: + | ins_next + | + |->cont_ra: // RA = resultptr + | lbu TMP1, -4+OFS_RA(PC) + | ldc1 f0, 0(RA) + | sll TMP1, TMP1, 3 + | addu TMP1, BASE, TMP1 + | b ->cont_nop + |. sdc1 f0, 0(TMP1) + | + |->cont_condt: // RA = resultptr + | lw TMP0, HI(RA) + | sltiu AT, TMP0, LJ_TISTRUECOND + | b <4 + |. negu TMP2, AT // Branch if result is true. + | + |->cont_condf: // RA = resultptr + | lw TMP0, HI(RA) + | sltiu AT, TMP0, LJ_TISTRUECOND + | b <4 + |. addiu TMP2, AT, -1 // Branch if result is false. + | + |->vmeta_equal: + | // CARG2, CARG3, CARG4 are already set by BC_ISEQV/BC_ISNEV. + | load_got lj_meta_equal + | addiu PC, PC, -4 + | sw BASE, L->base + | sw PC, SAVE_PC + | call_intern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) + |. move CARG1, L + | // Returns 0/1 or TValue * (metamethod). + | b <3 + |. nop + | + |->vmeta_equal_cd: + |.if FFI + | load_got lj_meta_equal_cd + | move CARG2, INS + | addiu PC, PC, -4 + | sw BASE, L->base + | sw PC, SAVE_PC + | call_intern lj_meta_equal_cd // (lua_State *L, BCIns op) + |. move CARG1, L + | // Returns 0/1 or TValue * (metamethod). + | b <3 + |. nop + |.endif + | + |//-- Arithmetic metamethods --------------------------------------------- + | + |->vmeta_unm: + | move CARG4, CARG3 + | + |->vmeta_arith: + | load_got lj_meta_arith + | decode_OP1 TMP0, INS + | sw BASE, L->base + | sw PC, SAVE_PC + | move CARG2, RA + | sw TMP0, ARG5 + | call_intern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) + |. move CARG1, L + | // Returns NULL (finished) or TValue * (metamethod). + | beqz CRET1, ->cont_nop + |. nop + | + | // Call metamethod for binary op. + |->vmeta_binop: + | // BASE = old base, CRET1 = new base, stack = cont/func/o1/o2 + | subu TMP1, CRET1, BASE + | sw PC, -16+HI(CRET1) // [cont|PC] + | move TMP2, BASE + | addiu PC, TMP1, FRAME_CONT + | move BASE, CRET1 + | b ->vm_call_dispatch + |. li NARGS8:RC, 16 // 2 args for func(o1, o2). + | + |->vmeta_len: + | // CARG2 already set by BC_LEN. +#if LJ_52 + | move MULTRES, CARG1 +#endif + | load_got lj_meta_len + | sw BASE, L->base + | sw PC, SAVE_PC + | call_intern lj_meta_len // (lua_State *L, TValue *o) + |. move CARG1, L + | // Returns NULL (retry) or TValue * (metamethod base). +#if LJ_52 + | bnez CRET1, ->vmeta_binop // Binop call for compatibility. + |. nop + | b ->BC_LEN_Z + |. move CARG1, MULTRES +#else + | b ->vmeta_binop // Binop call for compatibility. + |. nop +#endif + | + |//-- Call metamethod ---------------------------------------------------- + | + |->vmeta_call: // Resolve and call __call metamethod. + | // TMP2 = old base, BASE = new base, RC = nargs*8 + | load_got lj_meta_call + | sw TMP2, L->base // This is the callers base! + | addiu CARG2, BASE, -8 + | sw PC, SAVE_PC + | addu CARG3, BASE, RC + | move MULTRES, NARGS8:RC + | call_intern lj_meta_call // (lua_State *L, TValue *func, TValue *top) + |. move CARG1, L + | lw LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. + | addiu NARGS8:RC, MULTRES, 8 // Got one more argument now. + | ins_call + | + |->vmeta_callt: // Resolve __call for BC_CALLT. + | // BASE = old base, RA = new base, RC = nargs*8 + | load_got lj_meta_call + | sw BASE, L->base + | addiu CARG2, RA, -8 + | sw PC, SAVE_PC + | addu CARG3, RA, RC + | move MULTRES, NARGS8:RC + | call_intern lj_meta_call // (lua_State *L, TValue *func, TValue *top) + |. move CARG1, L + | lw TMP1, FRAME_PC(BASE) + | lw LFUNC:RB, FRAME_FUNC(RA) // Guaranteed to be a function here. + | b ->BC_CALLT_Z + |. addiu NARGS8:RC, MULTRES, 8 // Got one more argument now. + | + |//-- Argument coercion for 'for' statement ------------------------------ + | + |->vmeta_for: + | load_got lj_meta_for + | sw BASE, L->base + | move CARG2, RA + | sw PC, SAVE_PC + | move MULTRES, INS + | call_intern lj_meta_for // (lua_State *L, TValue *base) + |. move CARG1, L + |.if JIT + | decode_OP1 TMP0, MULTRES + | li AT, BC_JFORI + |.endif + | decode_RA8a RA, MULTRES + | decode_RD8a RD, MULTRES + | decode_RA8b RA + |.if JIT + | beq TMP0, AT, =>BC_JFORI + |. decode_RD8b RD + | b =>BC_FORI + |. nop + |.else + | b =>BC_FORI + |. decode_RD8b RD + |.endif + | + |//----------------------------------------------------------------------- + |//-- Fast functions ----------------------------------------------------- + |//----------------------------------------------------------------------- + | + |.macro .ffunc, name + |->ff_ .. name: + |.endmacro + | + |.macro .ffunc_1, name + |->ff_ .. name: + | beqz NARGS8:RC, ->fff_fallback + |. lw CARG3, HI(BASE) + | lw CARG1, LO(BASE) + |.endmacro + | + |.macro .ffunc_2, name + |->ff_ .. name: + | sltiu AT, NARGS8:RC, 16 + | lw CARG3, HI(BASE) + | bnez AT, ->fff_fallback + |. lw CARG4, 8+HI(BASE) + | lw CARG1, LO(BASE) + | lw CARG2, 8+LO(BASE) + |.endmacro + | + |.macro .ffunc_n, name // Caveat: has delay slot! + |->ff_ .. name: + | lw CARG3, HI(BASE) + | beqz NARGS8:RC, ->fff_fallback + |. ldc1 FARG1, 0(BASE) + | sltiu AT, CARG3, LJ_TISNUM + | beqz AT, ->fff_fallback + |.endmacro + | + |.macro .ffunc_nn, name // Caveat: has delay slot! + |->ff_ .. name: + | sltiu AT, NARGS8:RC, 16 + | lw CARG3, HI(BASE) + | bnez AT, ->fff_fallback + |. lw CARG4, 8+HI(BASE) + | ldc1 FARG1, 0(BASE) + | ldc1 FARG2, 8(BASE) + | sltiu TMP0, CARG3, LJ_TISNUM + | sltiu TMP1, CARG4, LJ_TISNUM + | and TMP0, TMP0, TMP1 + | beqz TMP0, ->fff_fallback + |.endmacro + | + |// Inlined GC threshold check. Caveat: uses TMP0 and TMP1 and has delay slot! + |.macro ffgccheck + | lw TMP0, DISPATCH_GL(gc.total)(DISPATCH) + | lw TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) + | subu AT, TMP0, TMP1 + | bgezal AT, ->fff_gcstep + |.endmacro + | + |//-- Base library: checks ----------------------------------------------- + | + |.ffunc_1 assert + | sltiu AT, CARG3, LJ_TISTRUECOND + | beqz AT, ->fff_fallback + |. addiu RA, BASE, -8 + | lw PC, FRAME_PC(BASE) + | addiu RD, NARGS8:RC, 8 // Compute (nresults+1)*8. + | addu TMP2, RA, NARGS8:RC + | sw CARG3, HI(RA) + | addiu TMP1, BASE, 8 + | beq BASE, TMP2, ->fff_res // Done if exactly 1 argument. + |. sw CARG1, LO(RA) + |1: + | ldc1 f0, 0(TMP1) + | sdc1 f0, -8(TMP1) + | bne TMP1, TMP2, <1 + |. addiu TMP1, TMP1, 8 + | b ->fff_res + |. nop + | + |.ffunc type + | lw CARG3, HI(BASE) + | li TMP1, LJ_TISNUM + | beqz NARGS8:RC, ->fff_fallback + |. sltiu TMP0, CARG3, LJ_TISNUM + | movz TMP1, CARG3, TMP0 + | not TMP1, TMP1 + | sll TMP1, TMP1, 3 + | addu TMP1, CFUNC:RB, TMP1 + | b ->fff_resn + |. ldc1 FRET1, CFUNC:TMP1->upvalue + | + |//-- Base library: getters and setters --------------------------------- + | + |.ffunc_1 getmetatable + | li AT, LJ_TTAB + | bne CARG3, AT, >6 + |. li AT, LJ_TUDATA + |1: // Field metatable must be at same offset for GCtab and GCudata! + | lw TAB:CARG1, TAB:CARG1->metatable + |2: + | lw STR:RC, DISPATCH_GL(gcroot[GCROOT_MMNAME+MM_metatable])(DISPATCH) + | beqz TAB:CARG1, ->fff_restv + |. li CARG3, LJ_TNIL + | lw TMP0, TAB:CARG1->hmask + | li CARG3, LJ_TTAB // Use metatable as default result. + | lw TMP1, STR:RC->hash + | lw NODE:TMP2, TAB:CARG1->node + | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask + | sll TMP0, TMP1, 5 + | sll TMP1, TMP1, 3 + | subu TMP1, TMP0, TMP1 + | addu NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) + | li AT, LJ_TSTR + |3: // Rearranged logic, because we expect _not_ to find the key. + | lw CARG4, offsetof(Node, key)+HI(NODE:TMP2) + | lw TMP0, offsetof(Node, key)+LO(NODE:TMP2) + | lw NODE:TMP3, NODE:TMP2->next + | bne CARG4, AT, >4 + |. lw CARG2, offsetof(Node, val)+HI(NODE:TMP2) + | beq TMP0, STR:RC, >5 + |. lw TMP1, offsetof(Node, val)+LO(NODE:TMP2) + |4: + | beqz NODE:TMP3, ->fff_restv // Not found, keep default result. + |. move NODE:TMP2, NODE:TMP3 + | b <3 + |. nop + |5: + | beq CARG2, TISNIL, ->fff_restv // Ditto for nil value. + |. nop + | move CARG3, CARG2 // Return value of mt.__metatable. + | b ->fff_restv + |. move CARG1, TMP1 + | + |6: + | beq CARG3, AT, <1 + |. sltiu TMP0, CARG3, LJ_TISNUM + | li TMP1, LJ_TISNUM + | movz TMP1, CARG3, TMP0 + | not TMP1, TMP1 + | sll TMP1, TMP1, 2 + | addu TMP1, DISPATCH, TMP1 + | b <2 + |. lw TAB:CARG1, DISPATCH_GL(gcroot[GCROOT_BASEMT])(TMP1) + | + |.ffunc_2 setmetatable + | // Fast path: no mt for table yet and not clearing the mt. + | li AT, LJ_TTAB + | bne CARG3, AT, ->fff_fallback + |. addiu CARG4, CARG4, -LJ_TTAB + | lw TAB:TMP1, TAB:CARG1->metatable + | lbu TMP3, TAB:CARG1->marked + | or AT, CARG4, TAB:TMP1 + | bnez AT, ->fff_fallback + |. andi AT, TMP3, LJ_GC_BLACK // isblack(table) + | beqz AT, ->fff_restv + |. sw TAB:CARG2, TAB:CARG1->metatable + | barrierback TAB:CARG1, TMP3, TMP0, ->fff_restv + | + |.ffunc rawget + | lw CARG4, HI(BASE) + | sltiu AT, NARGS8:RC, 16 + | lw TAB:CARG2, LO(BASE) + | load_got lj_tab_get + | addiu CARG4, CARG4, -LJ_TTAB + | or AT, AT, CARG4 + | bnez AT, ->fff_fallback + | addiu CARG3, BASE, 8 + | call_intern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) + |. move CARG1, L + | // Returns cTValue *. + | b ->fff_resn + |. ldc1 FRET1, 0(CRET1) + | + |//-- Base library: conversions ------------------------------------------ + | + |.ffunc tonumber + | // Only handles the number case inline (without a base argument). + | lw CARG1, HI(BASE) + | xori AT, NARGS8:RC, 8 + | sltiu CARG1, CARG1, LJ_TISNUM + | movn CARG1, r0, AT + | beqz CARG1, ->fff_fallback // Exactly one number argument. + |. ldc1 FRET1, 0(BASE) + | b ->fff_resn + |. nop + | + |.ffunc_1 tostring + | // Only handles the string or number case inline. + | li AT, LJ_TSTR + | // A __tostring method in the string base metatable is ignored. + | beq CARG3, AT, ->fff_restv // String key? + | // Handle numbers inline, unless a number base metatable is present. + |. lw TMP1, DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])(DISPATCH) + | sltiu TMP0, CARG3, LJ_TISNUM + | sltiu TMP1, TMP1, 1 + | and TMP0, TMP0, TMP1 + | beqz TMP0, ->fff_fallback + |. sw BASE, L->base // Add frame since C call can throw. + | ffgccheck + |. sw PC, SAVE_PC // Redundant (but a defined value). + | load_got lj_str_fromnum + | move CARG1, L + | call_intern lj_str_fromnum // (lua_State *L, lua_Number *np) + |. move CARG2, BASE + | // Returns GCstr *. + | li CARG3, LJ_TSTR + | b ->fff_restv + |. move CARG1, CRET1 + | + |//-- Base library: iterators ------------------------------------------- + | + |.ffunc next + | lw CARG1, HI(BASE) + | lw TAB:CARG2, LO(BASE) + | beqz NARGS8:RC, ->fff_fallback + |. addu TMP2, BASE, NARGS8:RC + | li AT, LJ_TTAB + | sw TISNIL, HI(TMP2) // Set missing 2nd arg to nil. + | bne CARG1, AT, ->fff_fallback + |. lw PC, FRAME_PC(BASE) + | load_got lj_tab_next + | sw BASE, L->base // Add frame since C call can throw. + | sw BASE, L->top // Dummy frame length is ok. + | addiu CARG3, BASE, 8 + | sw PC, SAVE_PC + | call_intern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) + |. move CARG1, L + | // Returns 0 at end of traversal. + | beqz CRET1, ->fff_restv // End of traversal: return nil. + |. li CARG3, LJ_TNIL + | ldc1 f0, 8(BASE) // Copy key and value to results. + | addiu RA, BASE, -8 + | ldc1 f2, 16(BASE) + | li RD, (2+1)*8 + | sdc1 f0, 0(RA) + | b ->fff_res + |. sdc1 f2, 8(RA) + | + |.ffunc_1 pairs + | li AT, LJ_TTAB + | bne CARG3, AT, ->fff_fallback + |. lw PC, FRAME_PC(BASE) +#if LJ_52 + | lw TAB:TMP2, TAB:CARG1->metatable + | ldc1 f0, CFUNC:RB->upvalue[0] + | bnez TAB:TMP2, ->fff_fallback +#else + | ldc1 f0, CFUNC:RB->upvalue[0] +#endif + |. addiu RA, BASE, -8 + | sw TISNIL, 8+HI(BASE) + | li RD, (3+1)*8 + | b ->fff_res + |. sdc1 f0, 0(RA) + | + |.ffunc ipairs_aux + | sltiu AT, NARGS8:RC, 16 + | lw CARG3, HI(BASE) + | lw TAB:CARG1, LO(BASE) + | lw CARG4, 8+HI(BASE) + | bnez AT, ->fff_fallback + |. ldc1 FARG2, 8(BASE) + | addiu CARG3, CARG3, -LJ_TTAB + | sltiu AT, CARG4, LJ_TISNUM + | li TMP0, 1 + | movn AT, r0, CARG3 + | mtc1 TMP0, FARG1 + | beqz AT, ->fff_fallback + |. lw PC, FRAME_PC(BASE) + | cvt.w.d FRET1, FARG2 + | cvt.d.w FARG1, FARG1 + | lw TMP0, TAB:CARG1->asize + | lw TMP1, TAB:CARG1->array + | mfc1 TMP2, FRET1 + | addiu RA, BASE, -8 + | add.d FARG2, FARG2, FARG1 + | addiu TMP2, TMP2, 1 + | sltu AT, TMP2, TMP0 + | sll TMP3, TMP2, 3 + | addu TMP3, TMP1, TMP3 + | beqz AT, >2 // Not in array part? + |. sdc1 FARG2, 0(RA) + | lw TMP2, HI(TMP3) + | ldc1 f0, 0(TMP3) + |1: + | beq TMP2, TISNIL, ->fff_res // End of iteration, return 0 results. + |. li RD, (0+1)*8 + | li RD, (2+1)*8 + | b ->fff_res + |. sdc1 f0, 8(RA) + |2: // Check for empty hash part first. Otherwise call C function. + | lw TMP0, TAB:CARG1->hmask + | load_got lj_tab_getinth + | beqz TMP0, ->fff_res + |. li RD, (0+1)*8 + | call_intern lj_tab_getinth // (GCtab *t, int32_t key) + |. move CARG2, TMP2 + | // Returns cTValue * or NULL. + | beqz CRET1, ->fff_res + |. li RD, (0+1)*8 + | lw TMP2, HI(CRET1) + | b <1 + |. ldc1 f0, 0(CRET1) + | + |.ffunc_1 ipairs + | li AT, LJ_TTAB + | bne CARG3, AT, ->fff_fallback + |. lw PC, FRAME_PC(BASE) +#if LJ_52 + | lw TAB:TMP2, TAB:CARG1->metatable + | ldc1 f0, CFUNC:RB->upvalue[0] + | bnez TAB:TMP2, ->fff_fallback +#else + | ldc1 f0, CFUNC:RB->upvalue[0] +#endif + |. addiu RA, BASE, -8 + | sw r0, 8+HI(BASE) + | sw r0, 8+LO(BASE) + | li RD, (3+1)*8 + | b ->fff_res + |. sdc1 f0, 0(RA) + | + |//-- Base library: catch errors ---------------------------------------- + | + |.ffunc pcall + | lbu TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | beqz NARGS8:RC, ->fff_fallback + | move TMP2, BASE + | addiu BASE, BASE, 8 + | // Remember active hook before pcall. + | srl TMP3, TMP3, HOOK_ACTIVE_SHIFT + | andi TMP3, TMP3, 1 + | addiu PC, TMP3, 8+FRAME_PCALL + | b ->vm_call_dispatch + |. addiu NARGS8:RC, NARGS8:RC, -8 + | + |.ffunc xpcall + | sltiu AT, NARGS8:RC, 16 + | lw CARG4, 8+HI(BASE) + | bnez AT, ->fff_fallback + |. ldc1 FARG2, 8(BASE) + | ldc1 FARG1, 0(BASE) + | lbu TMP1, DISPATCH_GL(hookmask)(DISPATCH) + | li AT, LJ_TFUNC + | move TMP2, BASE + | bne CARG4, AT, ->fff_fallback // Traceback must be a function. + | addiu BASE, BASE, 16 + | // Remember active hook before pcall. + | srl TMP3, TMP3, HOOK_ACTIVE_SHIFT + | sdc1 FARG2, 0(TMP2) // Swap function and traceback. + | andi TMP3, TMP3, 1 + | sdc1 FARG1, 8(TMP2) + | addiu PC, TMP3, 16+FRAME_PCALL + | b ->vm_call_dispatch + |. addiu NARGS8:RC, NARGS8:RC, -16 + | + |//-- Coroutine library -------------------------------------------------- + | + |.macro coroutine_resume_wrap, resume + |.if resume + |.ffunc_1 coroutine_resume + | li AT, LJ_TTHREAD + | bne CARG3, AT, ->fff_fallback + |.else + |.ffunc coroutine_wrap_aux + | lw L:CARG1, CFUNC:RB->upvalue[0].gcr + |.endif + | lbu TMP0, L:CARG1->status + | lw TMP1, L:CARG1->cframe + | lw CARG2, L:CARG1->top + | lw TMP2, L:CARG1->base + | addiu TMP3, TMP0, -LUA_YIELD + | bgtz TMP3, ->fff_fallback // st > LUA_YIELD? + |. xor TMP2, TMP2, CARG2 + | bnez TMP1, ->fff_fallback // cframe != 0? + |. or AT, TMP2, TMP0 + | lw TMP0, L:CARG1->maxstack + | beqz AT, ->fff_fallback // base == top && st == 0? + |. lw PC, FRAME_PC(BASE) + | addu TMP2, CARG2, NARGS8:RC + | sltu AT, TMP0, TMP2 + | bnez AT, ->fff_fallback // Stack overflow? + |. sw PC, SAVE_PC + | sw BASE, L->base + |1: + |.if resume + | addiu BASE, BASE, 8 // Keep resumed thread in stack for GC. + | addiu NARGS8:RC, NARGS8:RC, -8 + | addiu TMP2, TMP2, -8 + |.endif + | sw TMP2, L:CARG1->top + | addu TMP1, BASE, NARGS8:RC + | move CARG3, CARG2 + | sw BASE, L->top + |2: // Move args to coroutine. + | ldc1 f0, 0(BASE) + | sltu AT, BASE, TMP1 + | beqz AT, >3 + |. addiu BASE, BASE, 8 + | sdc1 f0, 0(CARG3) + | b <2 + |. addiu CARG3, CARG3, 8 + |3: + | bal ->vm_resume // (lua_State *L, TValue *base, 0, 0) + |. move L:RA, L:CARG1 + | // Returns thread status. + |4: + | lw TMP2, L:RA->base + | sltiu AT, CRET1, LUA_YIELD+1 + | lw TMP3, L:RA->top + | li_vmstate INTERP + | lw BASE, L->base + | st_vmstate + | beqz AT, >8 + |. subu RD, TMP3, TMP2 + | lw TMP0, L->maxstack + | beqz RD, >6 // No results? + |. addu TMP1, BASE, RD + | sltu AT, TMP0, TMP1 + | bnez AT, >9 // Need to grow stack? + |. addu TMP3, TMP2, RD + | sw TMP2, L:RA->top // Clear coroutine stack. + | move TMP1, BASE + |5: // Move results from coroutine. + | ldc1 f0, 0(TMP2) + | addiu TMP2, TMP2, 8 + | sltu AT, TMP2, TMP3 + | sdc1 f0, 0(TMP1) + | bnez AT, <5 + |. addiu TMP1, TMP1, 8 + |6: + | andi TMP0, PC, FRAME_TYPE + |.if resume + | li TMP1, LJ_TTRUE + | addiu RA, BASE, -8 + | sw TMP1, -8+HI(BASE) // Prepend true to results. + | addiu RD, RD, 16 + |.else + | move RA, BASE + | addiu RD, RD, 8 + |.endif + |7: + | sw PC, SAVE_PC + | beqz TMP0, ->BC_RET_Z + |. move MULTRES, RD + | b ->vm_return + |. nop + | + |8: // Coroutine returned with error (at co->top-1). + |.if resume + | addiu TMP3, TMP3, -8 + | li TMP1, LJ_TFALSE + | ldc1 f0, 0(TMP3) + | sw TMP3, L:RA->top // Remove error from coroutine stack. + | li RD, (2+1)*8 + | sw TMP1, -8+HI(BASE) // Prepend false to results. + | addiu RA, BASE, -8 + | sdc1 f0, 0(BASE) // Copy error message. + | b <7 + |. andi TMP0, PC, FRAME_TYPE + |.else + | load_got lj_ffh_coroutine_wrap_err + | move CARG2, L:RA + | call_intern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co) + |. move CARG1, L + |.endif + | + |9: // Handle stack expansion on return from yield. + | load_got lj_state_growstack + | srl CARG2, RD, 3 + | call_intern lj_state_growstack // (lua_State *L, int n) + |. move CARG1, L + | b <4 + |. li CRET1, 0 + |.endmacro + | + | coroutine_resume_wrap 1 // coroutine.resume + | coroutine_resume_wrap 0 // coroutine.wrap + | + |.ffunc coroutine_yield + | lw TMP0, L->cframe + | addu TMP1, BASE, NARGS8:RC + | sw BASE, L->base + | andi TMP0, TMP0, CFRAME_RESUME + | sw TMP1, L->top + | beqz TMP0, ->fff_fallback + |. li CRET1, LUA_YIELD + | sw r0, L->cframe + | b ->vm_leave_unw + |. sb CRET1, L->status + | + |//-- Math library ------------------------------------------------------- + | + |.ffunc_n math_abs + |. abs.d FRET1, FARG1 + |->fff_resn: + | lw PC, FRAME_PC(BASE) + | addiu RA, BASE, -8 + | b ->fff_res1 + |. sdc1 FRET1, -8(BASE) + | + |->fff_restv: + | // CARG3/CARG1 = TValue result. + | lw PC, FRAME_PC(BASE) + | sw CARG3, -8+HI(BASE) + | addiu RA, BASE, -8 + | sw CARG1, -8+LO(BASE) + |->fff_res1: + | // RA = results, PC = return. + | li RD, (1+1)*8 + |->fff_res: + | // RA = results, RD = (nresults+1)*8, PC = return. + | andi TMP0, PC, FRAME_TYPE + | bnez TMP0, ->vm_return + |. move MULTRES, RD + | lw INS, -4(PC) + | decode_RB8a RB, INS + | decode_RB8b RB + |5: + | sltu AT, RD, RB + | bnez AT, >6 // More results expected? + |. decode_RA8a TMP0, INS + | decode_RA8b TMP0 + | ins_next1 + | // Adjust BASE. KBASE is assumed to be set for the calling frame. + | subu BASE, RA, TMP0 + | ins_next2 + | + |6: // Fill up results with nil. + | addu TMP1, RA, RD + | addiu RD, RD, 8 + | b <5 + |. sw TISNIL, -8+HI(TMP1) + | + |.macro math_extern, func + |->ff_math_ .. func: + | lw CARG3, HI(BASE) + | beqz NARGS8:RC, ->fff_fallback + |. load_got func + | sltiu AT, CARG3, LJ_TISNUM + | beqz AT, ->fff_fallback + |. nop + | call_extern + |. ldc1 FARG1, 0(BASE) + | b ->fff_resn + |. nop + |.endmacro + | + |.macro math_extern2, func + | .ffunc_nn math_ .. func + |. load_got func + | call_extern + |. nop + | b ->fff_resn + |. nop + |.endmacro + | + |.macro math_round, func + | .ffunc_n math_ .. func + |. nop + | bal ->vm_ .. func + |. nop + | b ->fff_resn + |. nop + |.endmacro + | + | math_round floor + | math_round ceil + | + |.ffunc math_log + | lw CARG3, HI(BASE) + | li AT, 8 + | bne NARGS8:RC, AT, ->fff_fallback // Exactly 1 argument. + |. load_got log + | sltiu AT, CARG3, LJ_TISNUM + | beqz AT, ->fff_fallback + |. nop + | call_extern + |. ldc1 FARG1, 0(BASE) + | b ->fff_resn + |. nop + | + | math_extern log10 + | math_extern exp + | math_extern sin + | math_extern cos + | math_extern tan + | math_extern asin + | math_extern acos + | math_extern atan + | math_extern sinh + | math_extern cosh + | math_extern tanh + | math_extern2 pow + | math_extern2 atan2 + | math_extern2 fmod + | + |.ffunc_n math_sqrt + |. sqrt.d FRET1, FARG1 + | b ->fff_resn + |. nop + | + |->ff_math_deg: + |.ffunc_n math_rad + |. ldc1 FARG2, CFUNC:RB->upvalue[0] + | b ->fff_resn + |. mul.d FRET1, FARG1, FARG2 + | + |.ffunc_nn math_ldexp + | cvt.w.d FARG2, FARG2 + | load_got ldexp + | mfc1 CARG3, FARG2 + | call_extern + |. nop + | b ->fff_resn + |. nop + | + |.ffunc_n math_frexp + | load_got frexp + | lw PC, FRAME_PC(BASE) + | call_extern + |. addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) + | lw TMP1, DISPATCH_GL(tmptv)(DISPATCH) + | addiu RA, BASE, -8 + | mtc1 TMP1, FARG2 + | sdc1 FRET1, 0(RA) + | cvt.d.w FARG2, FARG2 + | sdc1 FARG2, 8(RA) + | b ->fff_res + |. li RD, (2+1)*8 + | + |.ffunc_n math_modf + | load_got modf + | lw PC, FRAME_PC(BASE) + | call_extern + |. addiu CARG3, BASE, -8 + | addiu RA, BASE, -8 + | sdc1 FRET1, 0(BASE) + | b ->fff_res + |. li RD, (2+1)*8 + | + |.macro math_minmax, name, ismax + |->ff_ .. name: + | lw CARG3, HI(BASE) + | beqz NARGS8:RC, ->fff_fallback + |. ldc1 FRET1, 0(BASE) + | sltiu AT, CARG3, LJ_TISNUM + | beqz AT, ->fff_fallback + |. addu TMP2, BASE, NARGS8:RC + | addiu TMP1, BASE, 8 + | beq TMP1, TMP2, ->fff_resn + |1: + |. lw CARG3, HI(TMP1) + | ldc1 FARG1, 0(TMP1) + | addiu TMP1, TMP1, 8 + | sltiu AT, CARG3, LJ_TISNUM + | beqz AT, ->fff_fallback + |.if ismax + |. c.olt.d FARG1, FRET1 + |.else + |. c.olt.d FRET1, FARG1 + |.endif + | bne TMP1, TMP2, <1 + |. movf.d FRET1, FARG1 + | b ->fff_resn + |. nop + |.endmacro + | + | math_minmax math_min, 0 + | math_minmax math_max, 1 + | + |//-- String library ----------------------------------------------------- + | + |.ffunc_1 string_len + | li AT, LJ_TSTR + | bne CARG3, AT, ->fff_fallback + |. nop + | b ->fff_resi + |. lw CRET1, STR:CARG1->len + | + |.ffunc string_byte // Only handle the 1-arg case here. + | lw CARG3, HI(BASE) + | lw STR:CARG1, LO(BASE) + | xori AT, NARGS8:RC, 8 + | addiu CARG3, CARG3, -LJ_TSTR + | or AT, AT, CARG3 + | bnez AT, ->fff_fallback // Need exactly 1 string argument. + |. nop + | lw TMP0, STR:CARG1->len + | lbu TMP1, STR:CARG1[1] // Access is always ok (NUL at end). + | addiu RA, BASE, -8 + | sltu RD, r0, TMP0 + | mtc1 TMP1, f0 + | addiu RD, RD, 1 + | cvt.d.w f0, f0 + | lw PC, FRAME_PC(BASE) + | sll RD, RD, 3 // RD = ((str->len != 0)+1)*8 + | b ->fff_res + |. sdc1 f0, 0(RA) + | + |.ffunc string_char // Only handle the 1-arg case here. + | ffgccheck + | lw CARG3, HI(BASE) + | ldc1 FARG1, 0(BASE) + | li AT, 8 + | bne NARGS8:RC, AT, ->fff_fallback // Exactly 1 argument. + |. sltiu AT, CARG3, LJ_TISNUM + | beqz AT, ->fff_fallback + |. li CARG3, 1 + | cvt.w.d FARG1, FARG1 + | addiu CARG2, sp, ARG5_OFS + | sltiu AT, TMP0, 256 + | mfc1 TMP0, FARG1 + | beqz AT, ->fff_fallback + |. sw TMP0, ARG5 + |->fff_newstr: + | load_got lj_str_new + | sw BASE, L->base + | sw PC, SAVE_PC + | call_intern lj_str_new // (lua_State *L, char *str, size_t l) + |. move CARG1, L + | // Returns GCstr *. + | lw BASE, L->base + | move CARG1, CRET1 + | b ->fff_restv + |. li CARG3, LJ_TSTR + | + |.ffunc string_sub + | ffgccheck + | addiu AT, NARGS8:RC, -16 + | lw CARG3, 16+HI(BASE) + | ldc1 f0, 16(BASE) + | lw TMP0, HI(BASE) + | lw STR:CARG1, LO(BASE) + | bltz AT, ->fff_fallback + | lw CARG2, 8+HI(BASE) + | ldc1 f2, 8(BASE) + | beqz AT, >1 + |. li CARG4, -1 + | cvt.w.d f0, f0 + | sltiu AT, CARG3, LJ_TISNUM + | beqz AT, ->fff_fallback + |. mfc1 CARG4, f0 + |1: + | sltiu AT, CARG2, LJ_TISNUM + | beqz AT, ->fff_fallback + |. li AT, LJ_TSTR + | cvt.w.d f2, f2 + | bne TMP0, AT, ->fff_fallback + |. lw CARG2, STR:CARG1->len + | mfc1 CARG3, f2 + | // STR:CARG1 = str, CARG2 = str->len, CARG3 = start, CARG4 = end + | slt AT, CARG4, r0 + | addiu TMP0, CARG2, 1 + | addu TMP1, CARG4, TMP0 + | slt TMP3, CARG3, r0 + | movn CARG4, TMP1, AT // if (end < 0) end += len+1 + | addu TMP1, CARG3, TMP0 + | movn CARG3, TMP1, TMP3 // if (start < 0) start += len+1 + | li TMP2, 1 + | slt AT, CARG4, r0 + | slt TMP3, r0, CARG3 + | movn CARG4, r0, AT // if (end < 0) end = 0 + | movz CARG3, TMP2, TMP3 // if (start < 1) start = 1 + | slt AT, CARG2, CARG4 + | movn CARG4, CARG2, AT // if (end > len) end = len + | addu CARG2, STR:CARG1, CARG3 + | subu CARG3, CARG4, CARG3 // len = end - start + | addiu CARG2, CARG2, sizeof(GCstr)-1 + | bgez CARG3, ->fff_newstr + |. addiu CARG3, CARG3, 1 // len++ + |->fff_emptystr: // Return empty string. + | addiu STR:CARG1, DISPATCH, DISPATCH_GL(strempty) + | b ->fff_restv + |. li CARG3, LJ_TSTR + | + |.ffunc string_rep // Only handle the 1-char case inline. + | ffgccheck + | lw TMP0, HI(BASE) + | addiu AT, NARGS8:RC, -16 // Exactly 2 arguments. + | lw CARG4, 8+HI(BASE) + | lw STR:CARG1, LO(BASE) + | addiu TMP0, TMP0, -LJ_TSTR + | ldc1 f0, 8(BASE) + | or AT, AT, TMP0 + | bnez AT, ->fff_fallback + |. sltiu AT, CARG4, LJ_TISNUM + | cvt.w.d f0, f0 + | beqz AT, ->fff_fallback + |. lw TMP0, STR:CARG1->len + | mfc1 CARG3, f0 + | lw TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) + | li AT, 1 + | blez CARG3, ->fff_emptystr // Count <= 0? + |. sltu AT, AT, TMP0 + | beqz TMP0, ->fff_emptystr // Zero length string? + |. sltu TMP0, TMP1, CARG3 + | or AT, AT, TMP0 + | lw CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) + | bnez AT, ->fff_fallback // Fallback for > 1-char strings. + |. lbu TMP0, STR:CARG1[1] + | addu TMP2, CARG2, CARG3 + |1: // Fill buffer with char. Yes, this is suboptimal code (do you care?). + | addiu TMP2, TMP2, -1 + | sltu AT, CARG2, TMP2 + | bnez AT, <1 + |. sb TMP0, 0(TMP2) + | b ->fff_newstr + |. nop + | + |.ffunc string_reverse + | ffgccheck + | lw CARG3, HI(BASE) + | lw STR:CARG1, LO(BASE) + | beqz NARGS8:RC, ->fff_fallback + |. li AT, LJ_TSTR + | bne CARG3, AT, ->fff_fallback + |. lw TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) + | lw CARG3, STR:CARG1->len + | addiu CARG1, STR:CARG1, #STR + | lw CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) + | sltu AT, TMP1, CARG3 + | bnez AT, ->fff_fallback + |. addu TMP3, CARG1, CARG3 + | addu CARG4, CARG2, CARG3 + |1: // Reverse string copy. + | lbu TMP1, 0(CARG1) + | sltu AT, CARG1, TMP3 + | beqz AT, ->fff_newstr + |. addiu CARG1, CARG1, 1 + | addiu CARG4, CARG4, -1 + | b <1 + | sb TMP1, 0(CARG4) + | + |.macro ffstring_case, name, lo + | .ffunc name + | ffgccheck + | lw CARG3, HI(BASE) + | lw STR:CARG1, LO(BASE) + | beqz NARGS8:RC, ->fff_fallback + |. li AT, LJ_TSTR + | bne CARG3, AT, ->fff_fallback + |. lw TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) + | lw CARG3, STR:CARG1->len + | addiu CARG1, STR:CARG1, #STR + | lw CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) + | sltu AT, TMP1, CARG3 + | bnez AT, ->fff_fallback + |. addu TMP3, CARG1, CARG3 + | move CARG4, CARG2 + |1: // ASCII case conversion. + | lbu TMP1, 0(CARG1) + | sltu AT, CARG1, TMP3 + | beqz AT, ->fff_newstr + |. addiu TMP0, TMP1, -lo + | xori TMP2, TMP1, 0x20 + | sltiu AT, TMP0, 26 + | movn TMP1, TMP2, AT + | addiu CARG1, CARG1, 1 + | sb TMP1, 0(CARG4) + | b <1 + |. addiu CARG4, CARG4, 1 + |.endmacro + | + |ffstring_case string_lower, 65 + |ffstring_case string_upper, 97 + | + |//-- Table library ------------------------------------------------------ + | + |.ffunc_1 table_getn + | li AT, LJ_TTAB + | bne CARG3, AT, ->fff_fallback + |. load_got lj_tab_len + | call_intern lj_tab_len // (GCtab *t) + |. nop + | // Returns uint32_t (but less than 2^31). + | b ->fff_resi + |. nop + | + |//-- Bit library -------------------------------------------------------- + | + |.macro .ffunc_bit, name + | .ffunc_n bit_..name + |. add.d FARG1, FARG1, TOBIT + | mfc1 CRET1, FARG1 + |.endmacro + | + |.macro .ffunc_bit_op, name, ins + | .ffunc_bit name + | addiu TMP1, BASE, 8 + | addu TMP2, BASE, NARGS8:RC + |1: + | lw CARG4, HI(TMP1) + | beq TMP1, TMP2, ->fff_resi + |. ldc1 FARG1, 0(TMP1) + | sltiu AT, CARG4, LJ_TISNUM + | beqz AT, ->fff_fallback + | add.d FARG1, FARG1, TOBIT + | mfc1 CARG2, FARG1 + | ins CRET1, CRET1, CARG2 + | b <1 + |. addiu TMP1, TMP1, 8 + |.endmacro + | + |.ffunc_bit_op band, and + |.ffunc_bit_op bor, or + |.ffunc_bit_op bxor, xor + | + |.ffunc_bit bswap + | srl TMP0, CRET1, 24 + | srl TMP2, CRET1, 8 + | sll TMP1, CRET1, 24 + | andi TMP2, TMP2, 0xff00 + | or TMP0, TMP0, TMP1 + | andi CRET1, CRET1, 0xff00 + | or TMP0, TMP0, TMP2 + | sll CRET1, CRET1, 8 + | b ->fff_resi + |. or CRET1, TMP0, CRET1 + | + |.ffunc_bit bnot + | b ->fff_resi + |. not CRET1, CRET1 + | + |.macro .ffunc_bit_sh, name, ins, shmod + | .ffunc_nn bit_..name + |. add.d FARG1, FARG1, TOBIT + | add.d FARG2, FARG2, TOBIT + | mfc1 CARG1, FARG1 + | mfc1 CARG2, FARG2 + |.if shmod == 1 + | li AT, 32 + | subu TMP0, AT, CARG2 + | sllv CARG2, CARG1, CARG2 + | srlv CARG1, CARG1, TMP0 + |.elif shmod == 2 + | li AT, 32 + | subu TMP0, AT, CARG2 + | srlv CARG2, CARG1, CARG2 + | sllv CARG1, CARG1, TMP0 + |.endif + | b ->fff_resi + |. ins CRET1, CARG1, CARG2 + |.endmacro + | + |.ffunc_bit_sh lshift, sllv, 0 + |.ffunc_bit_sh rshift, srlv, 0 + |.ffunc_bit_sh arshift, srav, 0 + |// Can't use rotrv, since it's only in MIPS32R2. + |.ffunc_bit_sh rol, or, 1 + |.ffunc_bit_sh ror, or, 2 + | + |.ffunc_bit tobit + |->fff_resi: + | mtc1 CRET1, FRET1 + | b ->fff_resn + |. cvt.d.w FRET1, FRET1 + | + |//----------------------------------------------------------------------- + | + |->fff_fallback: // Call fast function fallback handler. + | // BASE = new base, RB = CFUNC, RC = nargs*8 + | lw TMP3, CFUNC:RB->f + | addu TMP1, BASE, NARGS8:RC + | lw PC, FRAME_PC(BASE) // Fallback may overwrite PC. + | addiu TMP0, TMP1, 8*LUA_MINSTACK + | lw TMP2, L->maxstack + | sw PC, SAVE_PC // Redundant (but a defined value). + | sltu AT, TMP2, TMP0 + | sw BASE, L->base + | sw TMP1, L->top + | bnez AT, >5 // Need to grow stack. + |. move CFUNCADDR, TMP3 + | jalr TMP3 // (lua_State *L) + |. move CARG1, L + | // Either throws an error, or recovers and returns -1, 0 or nresults+1. + | lw BASE, L->base + | sll RD, CRET1, 3 + | bgtz CRET1, ->fff_res // Returned nresults+1? + |. addiu RA, BASE, -8 + |1: // Returned 0 or -1: retry fast path. + | lw TMP0, L->top + | lw LFUNC:RB, FRAME_FUNC(BASE) + | bnez CRET1, ->vm_call_tail // Returned -1? + |. subu NARGS8:RC, TMP0, BASE + | ins_callt // Returned 0: retry fast path. + | + |// Reconstruct previous base for vmeta_call during tailcall. + |->vm_call_tail: + | andi TMP0, PC, FRAME_TYPE + | li AT, -4 + | bnez TMP0, >3 + |. and TMP1, PC, AT + | lbu TMP1, OFS_RA(PC) + | sll TMP1, TMP1, 3 + | addiu TMP1, TMP1, 8 + |3: + | b ->vm_call_dispatch // Resolve again for tailcall. + |. subu TMP2, BASE, TMP1 + | + |5: // Grow stack for fallback handler. + | load_got lj_state_growstack + | li CARG2, LUA_MINSTACK + | call_intern lj_state_growstack // (lua_State *L, int n) + |. move CARG1, L + | lw BASE, L->base + | b <1 + |. li CRET1, 0 // Force retry. + | + |->fff_gcstep: // Call GC step function. + | // BASE = new base, RC = nargs*8 + | move MULTRES, ra + | load_got lj_gc_step + | sw BASE, L->base + | addu TMP0, BASE, NARGS8:RC + | sw PC, SAVE_PC // Redundant (but a defined value). + | sw TMP0, L->top + | call_intern lj_gc_step // (lua_State *L) + |. move CARG1, L + | lw BASE, L->base + | move ra, MULTRES + | lw TMP0, L->top + | lw CFUNC:RB, FRAME_FUNC(BASE) + | jr ra + |. subu NARGS8:RC, TMP0, BASE + | + |//----------------------------------------------------------------------- + |//-- Special dispatch targets ------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_record: // Dispatch target for recording phase. + |.if JIT + | lbu TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | andi AT, TMP3, HOOK_VMEVENT // No recording while in vmevent. + | bnez AT, >5 + | // Decrement the hookcount for consistency, but always do the call. + |. lw TMP2, DISPATCH_GL(hookcount)(DISPATCH) + | andi AT, TMP3, HOOK_ACTIVE + | bnez AT, >1 + |. addiu TMP2, TMP2, -1 + | andi AT, TMP3, LUA_MASKLINE|LUA_MASKCOUNT + | beqz AT, >1 + |. nop + | b >1 + |. sw TMP2, DISPATCH_GL(hookcount)(DISPATCH) + |.endif + | + |->vm_rethook: // Dispatch target for return hooks. + | lbu TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | andi AT, TMP3, HOOK_ACTIVE // Hook already active? + | beqz AT, >1 + |5: // Re-dispatch to static ins. + |. lw AT, GG_DISP2STATIC(TMP0) // Assumes TMP0 holds DISPATCH+OP*4. + | jr AT + |. nop + | + |->vm_inshook: // Dispatch target for instr/line hooks. + | lbu TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | lw TMP2, DISPATCH_GL(hookcount)(DISPATCH) + | andi AT, TMP3, HOOK_ACTIVE // Hook already active? + | bnez AT, <5 + |. andi AT, TMP3, LUA_MASKLINE|LUA_MASKCOUNT + | beqz AT, <5 + |. addiu TMP2, TMP2, -1 + | beqz TMP2, >1 + |. sw TMP2, DISPATCH_GL(hookcount)(DISPATCH) + | andi AT, TMP3, LUA_MASKLINE + | beqz AT, <5 + |1: + |. load_got lj_dispatch_ins + | sw MULTRES, SAVE_MULTRES + | move CARG2, PC + | sw BASE, L->base + | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. + | call_intern lj_dispatch_ins // (lua_State *L, const BCIns *pc) + |. move CARG1, L + |3: + | lw BASE, L->base + |4: // Re-dispatch to static ins. + | lw INS, -4(PC) + | decode_OP4a TMP1, INS + | decode_OP4b TMP1 + | addu TMP0, DISPATCH, TMP1 + | decode_RD8a RD, INS + | lw AT, GG_DISP2STATIC(TMP0) + | decode_RA8a RA, INS + | decode_RD8b RD + | jr AT + | decode_RA8b RA + | + |->cont_hook: // Continue from hook yield. + | addiu PC, PC, 4 + | b <4 + |. lw MULTRES, -24+LO(RB) // Restore MULTRES for *M ins. + | + |->vm_hotloop: // Hot loop counter underflow. + |.if JIT + | lw LFUNC:TMP1, FRAME_FUNC(BASE) + | addiu CARG1, DISPATCH, GG_DISP2J + | sw PC, SAVE_PC + | lw TMP1, LFUNC:TMP1->pc + | move CARG2, PC + | sw L, DISPATCH_J(L)(DISPATCH) + | lbu TMP1, PC2PROTO(framesize)(TMP1) + | load_got lj_trace_hot + | sw BASE, L->base + | sll TMP1, TMP1, 3 + | addu TMP1, BASE, TMP1 + | call_intern lj_trace_hot // (jit_State *J, const BCIns *pc) + |. sw TMP1, L->top + | b <3 + |. nop + |.endif + | + |->vm_callhook: // Dispatch target for call hooks. + |.if JIT + | b >1 + |.endif + |. move CARG2, PC + | + |->vm_hotcall: // Hot call counter underflow. + |.if JIT + | ori CARG2, PC, 1 + |1: + |.endif + | load_got lj_dispatch_call + | addu TMP0, BASE, RC + | sw PC, SAVE_PC + | sw BASE, L->base + | subu RA, RA, BASE + | sw TMP0, L->top + | call_intern lj_dispatch_call // (lua_State *L, const BCIns *pc) + |. move CARG1, L + | // Returns ASMFunction. + | lw BASE, L->base + | lw TMP0, L->top + | sw r0, SAVE_PC // Invalidate for subsequent line hook. + | subu NARGS8:RC, TMP0, BASE + | addu RA, BASE, RA + | lw LFUNC:RB, FRAME_FUNC(BASE) + | jr CRET1 + |. lw INS, -4(PC) + | + |//----------------------------------------------------------------------- + |//-- Trace exit handler ------------------------------------------------- + |//----------------------------------------------------------------------- + | + |.macro savex_, a, b + | sdc1 f..a, 16+a*8(sp) + | sw r..a, 16+32*8+a*4(sp) + | sw r..b, 16+32*8+b*4(sp) + |.endmacro + | + |->vm_exit_handler: + |.if JIT + | addiu sp, sp, -(16+32*8+32*4) + | savex_ 0, 1 + | savex_ 2, 3 + | savex_ 4, 5 + | savex_ 6, 7 + | savex_ 8, 9 + | savex_ 10, 11 + | savex_ 12, 13 + | savex_ 14, 15 + | savex_ 16, 17 + | savex_ 18, 19 + | savex_ 20, 21 + | savex_ 22, 23 + | savex_ 24, 25 + | savex_ 26, 27 + | sdc1 f28, 16+28*8(sp) + | sw r28, 16+32*8+28*4(sp) + | sdc1 f30, 16+30*8(sp) + | sw r30, 16+32*8+30*4(sp) + | sw r0, 16+32*8+31*4(sp) // Clear RID_TMP. + | li_vmstate EXIT + | addiu TMP2, sp, 16+32*8+32*4 // Recompute original value of sp. + | addiu DISPATCH, JGL, -GG_DISP2G-32768 + | lw TMP1, 0(TMP2) // Load exit number. + | st_vmstate + | sw TMP2, 16+32*8+29*4(sp) // Store sp in RID_SP. + | lw L, DISPATCH_GL(jit_L)(DISPATCH) + | lw BASE, DISPATCH_GL(jit_base)(DISPATCH) + | load_got lj_trace_exit + | sw L, DISPATCH_J(L)(DISPATCH) + | sw ra, DISPATCH_J(parent)(DISPATCH) // Store trace number. + | sw TMP1, DISPATCH_J(exitno)(DISPATCH) // Store exit number. + | addiu CARG1, DISPATCH, GG_DISP2J + | sw BASE, L->base + | call_intern lj_trace_exit // (jit_State *J, ExitState *ex) + |. addiu CARG2, sp, 16 + | // Returns MULTRES (unscaled) or negated error code. + | lw TMP1, L->cframe + | li AT, -4 + | lw BASE, L->base + | and sp, TMP1, AT + | lw PC, SAVE_PC // Get SAVE_PC. + | b >1 + |. sw L, SAVE_L // Set SAVE_L (on-trace resume/yield). + |.endif + |->vm_exit_interp: + |.if JIT + | // CRET1 = MULTRES or negated error code, BASE, PC and JGL set. + | lw L, SAVE_L + | addiu DISPATCH, JGL, -GG_DISP2G-32768 + |1: + | bltz CRET1, >3 // Check for error from exit. + |. lw LFUNC:TMP1, FRAME_FUNC(BASE) + | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | sll MULTRES, CRET1, 3 + | li TISNIL, LJ_TNIL + | sw MULTRES, SAVE_MULTRES + | mtc1 TMP3, TOBIT + | lw TMP1, LFUNC:TMP1->pc + | sw r0, DISPATCH_GL(jit_L)(DISPATCH) + | lw KBASE, PC2PROTO(k)(TMP1) + | cvt.d.s TOBIT, TOBIT + | // Modified copy of ins_next which handles function header dispatch, too. + | lw INS, 0(PC) + | addiu PC, PC, 4 + | // Assumes TISNIL == ~LJ_VMST_INTERP == -1 + | sw TISNIL, DISPATCH_GL(vmstate)(DISPATCH) + | decode_OP4a TMP1, INS + | decode_OP4b TMP1 + | sltiu TMP2, TMP1, BC_FUNCF*4 // Function header? + | addu TMP0, DISPATCH, TMP1 + | decode_RD8a RD, INS + | lw AT, 0(TMP0) + | decode_RA8a RA, INS + | beqz TMP2, >2 + |. decode_RA8b RA + | jr AT + |. decode_RD8b RD + |2: + | addiu RC, MULTRES, -8 + | jr AT + |. addu RA, RA, BASE + | + |3: // Rethrow error from the right C frame. + | load_got lj_err_throw + | negu CARG2, CRET1 + | call_intern lj_err_throw // (lua_State *L, int errcode) + |. move CARG1, L + |.endif + | + |//----------------------------------------------------------------------- + |//-- Math helper functions ---------------------------------------------- + |//----------------------------------------------------------------------- + | + |// Modifies AT, TMP0, FRET1, FRET2, f4. Keeps all others incl. FARG1. + |.macro vm_round, func + | lui TMP0, 0x4330 // Hiword of 2^52 (double). + | mtc1 r0, f4 + | mtc1 TMP0, f5 + | abs.d FRET2, FARG1 // |x| + | mfc1 AT, f13 + | c.olt.d 0, FRET2, f4 + | add.d FRET1, FRET2, f4 // (|x| + 2^52) - 2^52 + | bc1f 0, >1 // Truncate only if |x| < 2^52. + |. sub.d FRET1, FRET1, f4 + | slt AT, AT, r0 + |.if "func" == "ceil" + | lui TMP0, 0xbff0 // Hiword of -1 (double). Preserves -0. + |.else + | lui TMP0, 0x3ff0 // Hiword of +1 (double). + |.endif + |.if "func" == "trunc" + | mtc1 TMP0, f5 + | c.olt.d 0, FRET2, FRET1 // |x| < result? + | sub.d FRET2, FRET1, f4 + | movt.d FRET1, FRET2, 0 // If yes, subtract +1. + | neg.d FRET2, FRET1 + | jr ra + |. movn.d FRET1, FRET2, AT // Merge sign bit back in. + |.else + | neg.d FRET2, FRET1 + | mtc1 TMP0, f5 + | movn.d FRET1, FRET2, AT // Merge sign bit back in. + |.if "func" == "ceil" + | c.olt.d 0, FRET1, FARG1 // x > result? + |.else + | c.olt.d 0, FARG1, FRET1 // x < result? + |.endif + | sub.d FRET2, FRET1, f4 // If yes, subtract +-1. + | jr ra + |. movt.d FRET1, FRET2, 0 + |.endif + |1: + | jr ra + |. mov.d FRET1, FARG1 + |.endmacro + | + |->vm_floor: + | vm_round floor + |->vm_ceil: + | vm_round ceil + |->vm_trunc: + |.if JIT + | vm_round trunc + |.endif + | + |//----------------------------------------------------------------------- + |//-- Miscellaneous functions -------------------------------------------- + |//----------------------------------------------------------------------- + | + |//----------------------------------------------------------------------- + |//-- FFI helper functions ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |// Handler for callback functions. Callback slot number in r1, g in r2. + |->vm_ffi_callback: + |.if FFI + |.type CTSTATE, CTState, PC + | saveregs + | lw CTSTATE, GL:r2->ctype_state + | addiu DISPATCH, r2, GG_G2DISP + | load_got lj_ccallback_enter + | sw r1, CTSTATE->cb.slot + | sw CARG1, CTSTATE->cb.gpr[0] + | sw CARG2, CTSTATE->cb.gpr[1] + | sdc1 FARG1, CTSTATE->cb.fpr[0] + | sw CARG3, CTSTATE->cb.gpr[2] + | sw CARG4, CTSTATE->cb.gpr[3] + | sdc1 FARG2, CTSTATE->cb.fpr[1] + | addiu TMP0, sp, CFRAME_SPACE+16 + | sw TMP0, CTSTATE->cb.stack + | sw r0, SAVE_PC // Any value outside of bytecode is ok. + | move CARG2, sp + | call_intern lj_ccallback_enter // (CTState *cts, void *cf) + |. move CARG1, CTSTATE + | // Returns lua_State *. + | lw BASE, L:CRET1->base + | lw RC, L:CRET1->top + | move L, CRET1 + | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | lw LFUNC:RB, FRAME_FUNC(BASE) + | mtc1 TMP3, TOBIT + | li_vmstate INTERP + | li TISNIL, LJ_TNIL + | subu RC, RC, BASE + | st_vmstate + | cvt.d.s TOBIT, TOBIT + | ins_callt + |.endif + | + |->cont_ffi_callback: // Return from FFI callback. + |.if FFI + | load_got lj_ccallback_leave + | lw CTSTATE, DISPATCH_GL(ctype_state)(DISPATCH) + | sw BASE, L->base + | sw RB, L->top + | sw L, CTSTATE->L + | move CARG2, RA + | call_intern lj_ccallback_leave // (CTState *cts, TValue *o) + |. move CARG1, CTSTATE + | lw CRET1, CTSTATE->cb.gpr[0] + | ldc1 FRET1, CTSTATE->cb.fpr[0] + | lw CRET2, CTSTATE->cb.gpr[1] + | b ->vm_leave_unw + |. ldc1 FRET2, CTSTATE->cb.fpr[1] + |.endif + | + |->vm_ffi_call: // Call C function via FFI. + | // Caveat: needs special frame unwinding, see below. + |.if FFI + | .type CCSTATE, CCallState, CARG1 + | lw TMP1, CCSTATE->spadj + | lbu CARG2, CCSTATE->nsp + | move TMP2, sp + | subu sp, sp, TMP1 + | sw ra, -4(TMP2) + | sll CARG2, CARG2, 2 + | sw r16, -8(TMP2) + | sw CCSTATE, -12(TMP2) + | move r16, TMP2 + | addiu TMP1, CCSTATE, offsetof(CCallState, stack) + | addiu TMP2, sp, 16 + | beqz CARG2, >2 + |. addu TMP3, TMP1, CARG2 + |1: + | lw TMP0, 0(TMP1) + | addiu TMP1, TMP1, 4 + | sltu AT, TMP1, TMP3 + | sw TMP0, 0(TMP2) + | bnez AT, <1 + |. addiu TMP2, TMP2, 4 + |2: + | lw CFUNCADDR, CCSTATE->func + | lw CARG2, CCSTATE->gpr[1] + | lw CARG3, CCSTATE->gpr[2] + | lw CARG4, CCSTATE->gpr[3] + | ldc1 FARG1, CCSTATE->fpr[0] + | ldc1 FARG2, CCSTATE->fpr[1] + | jalr CFUNCADDR + |. lw CARG1, CCSTATE->gpr[0] // Do this last, since CCSTATE is CARG1. + | lw CCSTATE:TMP1, -12(r16) + | lw TMP2, -8(r16) + | lw ra, -4(r16) + | sw CRET1, CCSTATE:TMP1->gpr[0] + | sw CRET2, CCSTATE:TMP1->gpr[1] + | sdc1 FRET1, CCSTATE:TMP1->fpr[0] + | sdc1 FRET2, CCSTATE:TMP1->fpr[1] + | move sp, r16 + | jr ra + |. move r16, TMP2 + |.endif + |// Note: vm_ffi_call must be the last function in this object file! + | + |//----------------------------------------------------------------------- +} + +/* Generate the code for a single instruction. */ +static void build_ins(BuildCtx *ctx, BCOp op, int defop) +{ + int vk = 0; + |=>defop: + + switch (op) { + + /* -- Comparison ops ---------------------------------------------------- */ + + /* Remember: all ops branch for a true comparison, fall through otherwise. */ + + case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: + | // RA = src1*8, RD = src2*8, JMP with RD = target + | addu CARG2, BASE, RA + | addu CARG3, BASE, RD + | lw TMP0, HI(CARG2) + | lw TMP1, HI(CARG3) + | ldc1 f0, 0(CARG2) + | ldc1 f2, 0(CARG3) + | sltiu TMP0, TMP0, LJ_TISNUM + | sltiu TMP1, TMP1, LJ_TISNUM + | lhu TMP2, OFS_RD(PC) + | and TMP0, TMP0, TMP1 + | addiu PC, PC, 4 + | beqz TMP0, ->vmeta_comp + |. lui TMP1, (-(BCBIAS_J*4 >> 16) & 65535) + | decode_RD4b TMP2 + | addu TMP2, TMP2, TMP1 + if (op == BC_ISLT || op == BC_ISGE) { + | c.olt.d f0, f2 + } else { + | c.ole.d f0, f2 + } + if (op == BC_ISLT || op == BC_ISLE) { + | movf TMP2, r0 + } else { + | movt TMP2, r0 + } + | addu PC, PC, TMP2 + |1: + | ins_next + break; + + case BC_ISEQV: case BC_ISNEV: + vk = op == BC_ISEQV; + | // RA = src1*8, RD = src2*8, JMP with RD = target + | addu RA, BASE, RA + | addiu PC, PC, 4 + | lw TMP0, HI(RA) + | ldc1 f0, 0(RA) + | addu RD, BASE, RD + | lhu TMP2, -4+OFS_RD(PC) + | lw TMP1, HI(RD) + | ldc1 f2, 0(RD) + | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) + | sltiu AT, TMP0, LJ_TISNUM + | sltiu CARG1, TMP1, LJ_TISNUM + | decode_RD4b TMP2 + | and AT, AT, CARG1 + | beqz AT, >5 + |. addu TMP2, TMP2, TMP3 + | c.eq.d f0, f2 + if (vk) { + | movf TMP2, r0 + } else { + | movt TMP2, r0 + } + |1: + | addu PC, PC, TMP2 + | ins_next + |5: // Either or both types are not numbers. + | lw CARG2, LO(RA) + | lw CARG3, LO(RD) + |.if FFI + | li TMP3, LJ_TCDATA + | beq TMP0, TMP3, ->vmeta_equal_cd + |.endif + |. sltiu AT, TMP0, LJ_TISPRI // Not a primitive? + |.if FFI + | beq TMP1, TMP3, ->vmeta_equal_cd + |.endif + |. xor TMP3, CARG2, CARG3 // Same tv? + | xor TMP1, TMP1, TMP0 // Same type? + | sltiu CARG1, TMP0, LJ_TISTABUD+1 // Table or userdata? + | movz TMP3, r0, AT // Ignore tv if primitive. + | movn CARG1, r0, TMP1 // Tab/ud and same type? + | or AT, TMP1, TMP3 // Same type && (pri||same tv). + | movz CARG1, r0, AT + | beqz CARG1, <1 // Done if not tab/ud or not same type or same tv. + if (vk) { + |. movn TMP2, r0, AT + } else { + |. movz TMP2, r0, AT + } + | // Different tables or userdatas. Need to check __eq metamethod. + | // Field metatable must be at same offset for GCtab and GCudata! + | lw TAB:TMP1, TAB:CARG2->metatable + | beqz TAB:TMP1, <1 // No metatable? + |. nop + | lbu TMP1, TAB:TMP1->nomm + | andi TMP1, TMP1, 1<vmeta_equal // Handle __eq metamethod. + |. li CARG4, 1-vk // ne = 0 or 1. + break; + + case BC_ISEQS: case BC_ISNES: + vk = op == BC_ISEQS; + | // RA = src*8, RD = str_const*8 (~), JMP with RD = target + | addu RA, BASE, RA + | addiu PC, PC, 4 + | lw TMP0, HI(RA) + | srl RD, RD, 1 + | lw STR:TMP3, LO(RA) + | subu RD, KBASE, RD + | lhu TMP2, -4+OFS_RD(PC) + |.if FFI + | li AT, LJ_TCDATA + | beq TMP0, AT, ->vmeta_equal_cd + |.endif + |. lw STR:TMP1, -4(RD) // KBASE-4-str_const*4 + | addiu TMP0, TMP0, -LJ_TSTR + | decode_RD4b TMP2 + | xor TMP1, STR:TMP1, STR:TMP3 + | or TMP0, TMP0, TMP1 + | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) + | addu TMP2, TMP2, TMP3 + if (vk) { + | movn TMP2, r0, TMP0 + } else { + | movz TMP2, r0, TMP0 + } + | addu PC, PC, TMP2 + | ins_next + break; + + case BC_ISEQN: case BC_ISNEN: + vk = op == BC_ISEQN; + | // RA = src*8, RD = num_const*8, JMP with RD = target + | addu RA, BASE, RA + | addiu PC, PC, 4 + | lw TMP0, HI(RA) + | ldc1 f0, 0(RA) + | addu RD, KBASE, RD + | lhu TMP2, -4+OFS_RD(PC) + | ldc1 f2, 0(RD) + | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) + | sltiu AT, TMP0, LJ_TISNUM + | decode_RD4b TMP2 + |.if FFI + | beqz AT, >5 + |.else + | beqz AT, >1 + |.endif + |. addu TMP2, TMP2, TMP3 + | c.eq.d f0, f2 + if (vk) { + | movf TMP2, r0 + | addu PC, PC, TMP2 + |1: + } else { + | movt TMP2, r0 + |1: + | addu PC, PC, TMP2 + } + | ins_next + |.if FFI + |5: + | li AT, LJ_TCDATA + | beq TMP0, AT, ->vmeta_equal_cd + |. nop + | b <1 + |. nop + |.endif + break; + + case BC_ISEQP: case BC_ISNEP: + vk = op == BC_ISEQP; + | // RA = src*8, RD = primitive_type*8 (~), JMP with RD = target + | addu RA, BASE, RA + | srl TMP1, RD, 3 + | lw TMP0, HI(RA) + | lhu TMP2, OFS_RD(PC) + | not TMP1, TMP1 + | addiu PC, PC, 4 + |.if FFI + | li AT, LJ_TCDATA + | beq TMP0, AT, ->vmeta_equal_cd + |.endif + |. xor TMP0, TMP0, TMP1 + | decode_RD4b TMP2 + | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) + | addu TMP2, TMP2, TMP3 + if (vk) { + | movn TMP2, r0, TMP0 + } else { + | movz TMP2, r0, TMP0 + } + | addu PC, PC, TMP2 + | ins_next + break; + + /* -- Unary test and copy ops ------------------------------------------- */ + + case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: + | // RA = dst*8 or unused, RD = src*8, JMP with RD = target + | addu RD, BASE, RD + | lhu TMP2, OFS_RD(PC) + | lw TMP0, HI(RD) + | addiu PC, PC, 4 + if (op == BC_IST || op == BC_ISF) { + | sltiu TMP0, TMP0, LJ_TISTRUECOND + | decode_RD4b TMP2 + | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) + | addu TMP2, TMP2, TMP3 + if (op == BC_IST) { + | movz TMP2, r0, TMP0 + } else { + | movn TMP2, r0, TMP0 + } + | addu PC, PC, TMP2 + } else { + | sltiu TMP0, TMP0, LJ_TISTRUECOND + | ldc1 f0, 0(RD) + if (op == BC_ISTC) { + | beqz TMP0, >1 + } else { + | bnez TMP0, >1 + } + |. addu RA, BASE, RA + | decode_RD4b TMP2 + | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) + | addu TMP2, TMP2, TMP3 + | sdc1 f0, 0(RA) + | addu PC, PC, TMP2 + |1: + } + | ins_next + break; + + /* -- Unary ops --------------------------------------------------------- */ + + case BC_MOV: + | // RA = dst*8, RD = src*8 + | addu RD, BASE, RD + | addu RA, BASE, RA + | ldc1 f0, 0(RD) + | ins_next1 + | sdc1 f0, 0(RA) + | ins_next2 + break; + case BC_NOT: + | // RA = dst*8, RD = src*8 + | addu RD, BASE, RD + | addu RA, BASE, RA + | lw TMP0, HI(RD) + | li TMP1, LJ_TFALSE + | sltiu TMP0, TMP0, LJ_TISTRUECOND + | addiu TMP1, TMP0, LJ_TTRUE + | ins_next1 + | sw TMP1, HI(RA) + | ins_next2 + break; + case BC_UNM: + | // RA = dst*8, RD = src*8 + | addu CARG3, BASE, RD + | addu RA, BASE, RA + | lw TMP0, HI(CARG3) + | ldc1 f0, 0(CARG3) + | sltiu AT, TMP0, LJ_TISNUM + | beqz AT, ->vmeta_unm + |. neg.d f0, f0 + | ins_next1 + | sdc1 f0, 0(RA) + | ins_next2 + break; + case BC_LEN: + | // RA = dst*8, RD = src*8 + | addu CARG2, BASE, RD + | addu RA, BASE, RA + | lw TMP0, HI(CARG2) + | lw CARG1, LO(CARG2) + | li AT, LJ_TSTR + | bne TMP0, AT, >2 + |. li AT, LJ_TTAB + | lw CRET1, STR:CARG1->len + |1: + | mtc1 CRET1, f0 + | cvt.d.w f0, f0 + | ins_next1 + | sdc1 f0, 0(RA) + | ins_next2 + |2: + | bne TMP0, AT, ->vmeta_len + |. nop +#if LJ_52 + | lw TAB:TMP2, TAB:CARG1->metatable + | bnez TAB:TMP2, >9 + |. nop + |3: +#endif + |->BC_LEN_Z: + | load_got lj_tab_len + | call_intern lj_tab_len // (GCtab *t) + |. nop + | // Returns uint32_t (but less than 2^31). + | b <1 + |. nop +#if LJ_52 + |9: + | lbu TMP0, TAB:TMP2->nomm + | andi TMP0, TMP0, 1<vmeta_len + |. nop +#endif + break; + + /* -- Binary ops -------------------------------------------------------- */ + + |.macro ins_arithpre + ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); + | decode_RB8a RB, INS + | decode_RB8b RB + | decode_RDtoRC8 RC, RD + | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 + ||switch (vk) { + ||case 0: + | addu CARG3, BASE, RB + | addu CARG4, KBASE, RC + | lw TMP1, HI(CARG3) + | ldc1 f20, 0(CARG3) + | ldc1 f22, 0(CARG4) + | sltiu AT, TMP1, LJ_TISNUM + || break; + ||case 1: + | addu CARG4, BASE, RB + | addu CARG3, KBASE, RC + | lw TMP1, HI(CARG4) + | ldc1 f22, 0(CARG4) + | ldc1 f20, 0(CARG3) + | sltiu AT, TMP1, LJ_TISNUM + || break; + ||default: + | addu CARG3, BASE, RB + | addu CARG4, BASE, RC + | lw TMP1, HI(CARG3) + | lw TMP2, HI(CARG4) + | ldc1 f20, 0(CARG3) + | ldc1 f22, 0(CARG4) + | sltiu AT, TMP1, LJ_TISNUM + | sltiu TMP0, TMP2, LJ_TISNUM + | and AT, AT, TMP0 + || break; + ||} + | beqz AT, ->vmeta_arith + |. addu RA, BASE, RA + |.endmacro + | + |.macro fpmod, a, b, c + |->BC_MODVN_Z: + | bal ->vm_floor // floor(b/c) + |. div.d FARG1, b, c + | mul.d a, FRET1, c + | sub.d a, b, a // b - floor(b/c)*c + |.endmacro + | + |.macro ins_arith, ins + | ins_arithpre + |.if "ins" == "fpmod_" + | b ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. + |. nop + |.else + | ins f0, f20, f22 + | ins_next1 + | sdc1 f0, 0(RA) + | ins_next2 + |.endif + |.endmacro + + case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: + | ins_arith add.d + break; + case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: + | ins_arith sub.d + break; + case BC_MULVN: case BC_MULNV: case BC_MULVV: + | ins_arith mul.d + break; + case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: + | ins_arith div.d + break; + case BC_MODVN: + | ins_arith fpmod + break; + case BC_MODNV: case BC_MODVV: + | ins_arith fpmod_ + break; + case BC_POW: + | decode_RB8a RB, INS + | decode_RB8b RB + | decode_RDtoRC8 RC, RD + | addu CARG3, BASE, RB + | addu CARG4, BASE, RC + | lw TMP1, HI(CARG3) + | lw TMP2, HI(CARG4) + | ldc1 FARG1, 0(CARG3) + | ldc1 FARG2, 0(CARG4) + | sltiu AT, TMP1, LJ_TISNUM + | sltiu TMP0, TMP2, LJ_TISNUM + | and AT, AT, TMP0 + | load_got pow + | beqz AT, ->vmeta_arith + |. addu RA, BASE, RA + | call_extern + |. nop + | ins_next1 + | sdc1 FRET1, 0(RA) + | ins_next2 + break; + + case BC_CAT: + | // RA = dst*8, RB = src_start*8, RC = src_end*8 + | decode_RB8a RB, INS + | decode_RB8b RB + | decode_RDtoRC8 RC, RD + | subu CARG3, RC, RB + | sw BASE, L->base + | addu CARG2, BASE, RC + | move MULTRES, RB + |->BC_CAT_Z: + | load_got lj_meta_cat + | srl CARG3, CARG3, 3 + | sw PC, SAVE_PC + | call_intern lj_meta_cat // (lua_State *L, TValue *top, int left) + |. move CARG1, L + | // Returns NULL (finished) or TValue * (metamethod). + | bnez CRET1, ->vmeta_binop + |. lw BASE, L->base + | addu RB, BASE, MULTRES + | ldc1 f0, 0(RB) + | addu RA, BASE, RA + | ins_next1 + | sdc1 f0, 0(RA) // Copy result from RB to RA. + | ins_next2 + break; + + /* -- Constant ops ------------------------------------------------------ */ + + case BC_KSTR: + | // RA = dst*8, RD = str_const*8 (~) + | srl TMP1, RD, 1 + | subu TMP1, KBASE, TMP1 + | ins_next1 + | lw TMP0, -4(TMP1) // KBASE-4-str_const*4 + | addu RA, BASE, RA + | li TMP2, LJ_TSTR + | sw TMP0, LO(RA) + | sw TMP2, HI(RA) + | ins_next2 + break; + case BC_KCDATA: + |.if FFI + | // RA = dst*8, RD = cdata_const*8 (~) + | srl TMP1, RD, 1 + | subu TMP1, KBASE, TMP1 + | ins_next1 + | lw TMP0, -4(TMP1) // KBASE-4-cdata_const*4 + | addu RA, BASE, RA + | li TMP2, LJ_TCDATA + | sw TMP0, LO(RA) + | sw TMP2, HI(RA) + | ins_next2 + |.endif + break; + case BC_KSHORT: + | // RA = dst*8, RD = int16_literal*8 + | sra RD, INS, 16 + | mtc1 RD, f0 + | addu RA, BASE, RA + | cvt.d.w f0, f0 + | ins_next1 + | sdc1 f0, 0(RA) + | ins_next2 + break; + case BC_KNUM: + | // RA = dst*8, RD = num_const*8 + | addu RD, KBASE, RD + | addu RA, BASE, RA + | ldc1 f0, 0(RD) + | ins_next1 + | sdc1 f0, 0(RA) + | ins_next2 + break; + case BC_KPRI: + | // RA = dst*8, RD = primitive_type*8 (~) + | srl TMP1, RD, 3 + | addu RA, BASE, RA + | not TMP0, TMP1 + | ins_next1 + | sw TMP0, HI(RA) + | ins_next2 + break; + case BC_KNIL: + | // RA = base*8, RD = end*8 + | addu RA, BASE, RA + | sw TISNIL, HI(RA) + | addiu RA, RA, 8 + | addu RD, BASE, RD + |1: + | sw TISNIL, HI(RA) + | slt AT, RA, RD + | bnez AT, <1 + |. addiu RA, RA, 8 + | ins_next_ + break; + + /* -- Upvalue and function ops ------------------------------------------ */ + + case BC_UGET: + | // RA = dst*8, RD = uvnum*8 + | lw LFUNC:RB, FRAME_FUNC(BASE) + | srl RD, RD, 1 + | addu RD, RD, LFUNC:RB + | lw UPVAL:RB, LFUNC:RD->uvptr + | ins_next1 + | lw TMP1, UPVAL:RB->v + | ldc1 f0, 0(TMP1) + | addu RA, BASE, RA + | sdc1 f0, 0(RA) + | ins_next2 + break; + case BC_USETV: + | // RA = uvnum*8, RD = src*8 + | lw LFUNC:RB, FRAME_FUNC(BASE) + | srl RA, RA, 1 + | addu RD, BASE, RD + | addu RA, RA, LFUNC:RB + | ldc1 f0, 0(RD) + | lw UPVAL:RB, LFUNC:RA->uvptr + | lbu TMP3, UPVAL:RB->marked + | lw CARG2, UPVAL:RB->v + | andi TMP3, TMP3, LJ_GC_BLACK // isblack(uv) + | lbu TMP0, UPVAL:RB->closed + | lw TMP2, HI(RD) + | sdc1 f0, 0(CARG2) + | li AT, LJ_GC_BLACK|1 + | or TMP3, TMP3, TMP0 + | beq TMP3, AT, >2 // Upvalue is closed and black? + |. addiu TMP2, TMP2, -(LJ_TNUMX+1) + |1: + | ins_next + | + |2: // Check if new value is collectable. + | sltiu AT, TMP2, LJ_TISGCV - (LJ_TNUMX+1) + | beqz AT, <1 // tvisgcv(v) + |. lw TMP1, LO(RD) + | lbu TMP3, GCOBJ:TMP1->gch.marked + | andi TMP3, TMP3, LJ_GC_WHITES // iswhite(v) + | beqz TMP3, <1 + |. load_got lj_gc_barrieruv + | // Crossed a write barrier. Move the barrier forward. + | call_intern lj_gc_barrieruv // (global_State *g, TValue *tv) + |. addiu CARG1, DISPATCH, GG_DISP2G + | b <1 + |. nop + break; + case BC_USETS: + | // RA = uvnum*8, RD = str_const*8 (~) + | lw LFUNC:RB, FRAME_FUNC(BASE) + | srl RA, RA, 1 + | srl TMP1, RD, 1 + | addu RA, RA, LFUNC:RB + | subu TMP1, KBASE, TMP1 + | lw UPVAL:RB, LFUNC:RA->uvptr + | lw STR:TMP1, -4(TMP1) // KBASE-4-str_const*4 + | lbu TMP2, UPVAL:RB->marked + | lw CARG2, UPVAL:RB->v + | lbu TMP3, STR:TMP1->marked + | andi AT, TMP2, LJ_GC_BLACK // isblack(uv) + | lbu TMP2, UPVAL:RB->closed + | li TMP0, LJ_TSTR + | sw STR:TMP1, LO(CARG2) + | bnez AT, >2 + |. sw TMP0, HI(CARG2) + |1: + | ins_next + | + |2: // Check if string is white and ensure upvalue is closed. + | beqz TMP2, <1 + |. andi AT, TMP3, LJ_GC_WHITES // iswhite(str) + | beqz AT, <1 + |. load_got lj_gc_barrieruv + | // Crossed a write barrier. Move the barrier forward. + | call_intern lj_gc_barrieruv // (global_State *g, TValue *tv) + |. addiu CARG1, DISPATCH, GG_DISP2G + | b <1 + |. nop + break; + case BC_USETN: + | // RA = uvnum*8, RD = num_const*8 + | lw LFUNC:RB, FRAME_FUNC(BASE) + | srl RA, RA, 1 + | addu RD, KBASE, RD + | addu RA, RA, LFUNC:RB + | ldc1 f0, 0(RD) + | lw UPVAL:RB, LFUNC:RA->uvptr + | ins_next1 + | lw TMP1, UPVAL:RB->v + | sdc1 f0, 0(TMP1) + | ins_next2 + break; + case BC_USETP: + | // RA = uvnum*8, RD = primitive_type*8 (~) + | lw LFUNC:RB, FRAME_FUNC(BASE) + | srl RA, RA, 1 + | srl TMP0, RD, 3 + | addu RA, RA, LFUNC:RB + | not TMP0, TMP0 + | lw UPVAL:RB, LFUNC:RA->uvptr + | ins_next1 + | lw TMP1, UPVAL:RB->v + | sw TMP0, HI(TMP1) + | ins_next2 + break; + + case BC_UCLO: + | // RA = level*8, RD = target + | lw TMP2, L->openupval + | branch_RD // Do this first since RD is not saved. + | load_got lj_func_closeuv + | sw BASE, L->base + | beqz TMP2, >1 + |. move CARG1, L + | call_intern lj_func_closeuv // (lua_State *L, TValue *level) + |. addu CARG2, BASE, RA + | lw BASE, L->base + |1: + | ins_next + break; + + case BC_FNEW: + | // RA = dst*8, RD = proto_const*8 (~) (holding function prototype) + | srl TMP1, RD, 1 + | load_got lj_func_newL_gc + | subu TMP1, KBASE, TMP1 + | lw CARG3, FRAME_FUNC(BASE) + | lw CARG2, -4(TMP1) // KBASE-4-tab_const*4 + | sw BASE, L->base + | sw PC, SAVE_PC + | // (lua_State *L, GCproto *pt, GCfuncL *parent) + | call_intern lj_func_newL_gc + |. move CARG1, L + | // Returns GCfuncL *. + | lw BASE, L->base + | li TMP0, LJ_TFUNC + | ins_next1 + | addu RA, BASE, RA + | sw TMP0, HI(RA) + | sw LFUNC:CRET1, LO(RA) + | ins_next2 + break; + + /* -- Table ops --------------------------------------------------------- */ + + case BC_TNEW: + case BC_TDUP: + | // RA = dst*8, RD = (hbits|asize)*8 | tab_const*8 (~) + | lw TMP0, DISPATCH_GL(gc.total)(DISPATCH) + | lw TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) + | sw BASE, L->base + | sw PC, SAVE_PC + | sltu AT, TMP0, TMP1 + | beqz AT, >5 + |1: + if (op == BC_TNEW) { + | load_got lj_tab_new + | srl CARG2, RD, 3 + | andi CARG2, CARG2, 0x7ff + | li TMP0, 0x801 + | addiu AT, CARG2, -0x7ff + | srl CARG3, RD, 14 + | movz CARG2, TMP0, AT + | // (lua_State *L, int32_t asize, uint32_t hbits) + | call_intern lj_tab_new + |. move CARG1, L + | // Returns Table *. + } else { + | load_got lj_tab_dup + | srl TMP1, RD, 1 + | subu TMP1, KBASE, TMP1 + | move CARG1, L + | call_intern lj_tab_dup // (lua_State *L, Table *kt) + |. lw CARG2, -4(TMP1) // KBASE-4-str_const*4 + | // Returns Table *. + } + | lw BASE, L->base + | ins_next1 + | addu RA, BASE, RA + | li TMP0, LJ_TTAB + | sw TAB:CRET1, LO(RA) + | sw TMP0, HI(RA) + | ins_next2 + |5: + | load_got lj_gc_step_fixtop + | move MULTRES, RD + | call_intern lj_gc_step_fixtop // (lua_State *L) + |. move CARG1, L + | b <1 + |. move RD, MULTRES + break; + + case BC_GGET: + | // RA = dst*8, RD = str_const*8 (~) + case BC_GSET: + | // RA = src*8, RD = str_const*8 (~) + | lw LFUNC:TMP2, FRAME_FUNC(BASE) + | srl TMP1, RD, 1 + | subu TMP1, KBASE, TMP1 + | lw TAB:RB, LFUNC:TMP2->env + | lw STR:RC, -4(TMP1) // KBASE-4-str_const*4 + if (op == BC_GGET) { + | b ->BC_TGETS_Z + } else { + | b ->BC_TSETS_Z + } + |. addu RA, BASE, RA + break; + + case BC_TGETV: + | // RA = dst*8, RB = table*8, RC = key*8 + | decode_RB8a RB, INS + | decode_RB8b RB + | decode_RDtoRC8 RC, RD + | addu CARG2, BASE, RB + | addu CARG3, BASE, RC + | lw TMP1, HI(CARG2) + | lw TMP2, HI(CARG3) + | lw TAB:RB, LO(CARG2) + | li AT, LJ_TTAB + | ldc1 f0, 0(CARG3) + | bne TMP1, AT, ->vmeta_tgetv + |. addu RA, BASE, RA + | sltiu AT, TMP2, LJ_TISNUM + | beqz AT, >5 + |. li AT, LJ_TSTR + | + | // Convert number key to integer, check for integerness and range. + | cvt.w.d f2, f0 + | lw TMP0, TAB:RB->asize + | mfc1 TMP2, f2 + | cvt.d.w f4, f2 + | lw TMP1, TAB:RB->array + | c.eq.d f0, f4 + | sltu AT, TMP2, TMP0 + | movf AT, r0 + | sll TMP2, TMP2, 3 + | beqz AT, ->vmeta_tgetv // Integer key and in array part? + |. addu TMP2, TMP1, TMP2 + | lw TMP0, HI(TMP2) + | beq TMP0, TISNIL, >2 + |. ldc1 f0, 0(TMP2) + |1: + | ins_next1 + | sdc1 f0, 0(RA) + | ins_next2 + | + |2: // Check for __index if table value is nil. + | lw TAB:TMP2, TAB:RB->metatable + | beqz TAB:TMP2, <1 // No metatable: done. + |. nop + | lbu TMP0, TAB:TMP2->nomm + | andi TMP0, TMP0, 1<vmeta_tgetv + |. nop + | + |5: + | bne TMP2, AT, ->vmeta_tgetv + |. lw STR:RC, LO(CARG3) + | b ->BC_TGETS_Z // String key? + |. nop + break; + case BC_TGETS: + | // RA = dst*8, RB = table*8, RC = str_const*4 (~) + | decode_RB8a RB, INS + | decode_RB8b RB + | addu CARG2, BASE, RB + | decode_RC4a RC, INS + | lw TMP0, HI(CARG2) + | decode_RC4b RC + | li AT, LJ_TTAB + | lw TAB:RB, LO(CARG2) + | subu CARG3, KBASE, RC + | lw STR:RC, -4(CARG3) // KBASE-4-str_const*4 + | bne TMP0, AT, ->vmeta_tgets1 + |. addu RA, BASE, RA + |->BC_TGETS_Z: + | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = dst*8 + | lw TMP0, TAB:RB->hmask + | lw TMP1, STR:RC->hash + | lw NODE:TMP2, TAB:RB->node + | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask + | sll TMP0, TMP1, 5 + | sll TMP1, TMP1, 3 + | subu TMP1, TMP0, TMP1 + | addu NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) + |1: + | lw CARG1, offsetof(Node, key)+HI(NODE:TMP2) + | lw TMP0, offsetof(Node, key)+LO(NODE:TMP2) + | lw NODE:TMP1, NODE:TMP2->next + | lw CARG2, offsetof(Node, val)+HI(NODE:TMP2) + | addiu CARG1, CARG1, -LJ_TSTR + | xor TMP0, TMP0, STR:RC + | or AT, CARG1, TMP0 + | bnez AT, >4 + |. lw TAB:TMP3, TAB:RB->metatable + | beq CARG2, TISNIL, >5 // Key found, but nil value? + |. lw CARG1, offsetof(Node, val)+LO(NODE:TMP2) + |3: + | ins_next1 + | sw CARG2, HI(RA) + | sw CARG1, LO(RA) + | ins_next2 + | + |4: // Follow hash chain. + | bnez NODE:TMP1, <1 + |. move NODE:TMP2, NODE:TMP1 + | // End of hash chain: key not found, nil result. + | + |5: // Check for __index if table value is nil. + | beqz TAB:TMP3, <3 // No metatable: done. + |. li CARG2, LJ_TNIL + | lbu TMP0, TAB:TMP3->nomm + | andi TMP0, TMP0, 1<vmeta_tgets + |. nop + break; + case BC_TGETB: + | // RA = dst*8, RB = table*8, RC = index*8 + | decode_RB8a RB, INS + | decode_RB8b RB + | addu CARG2, BASE, RB + | decode_RDtoRC8 RC, RD + | lw CARG1, HI(CARG2) + | li AT, LJ_TTAB + | lw TAB:RB, LO(CARG2) + | addu RA, BASE, RA + | bne CARG1, AT, ->vmeta_tgetb + |. srl TMP0, RC, 3 + | lw TMP1, TAB:RB->asize + | lw TMP2, TAB:RB->array + | sltu AT, TMP0, TMP1 + | beqz AT, ->vmeta_tgetb + |. addu RC, TMP2, RC + | lw TMP1, HI(RC) + | beq TMP1, TISNIL, >5 + |. ldc1 f0, 0(RC) + |1: + | ins_next1 + | sdc1 f0, 0(RA) + | ins_next2 + | + |5: // Check for __index if table value is nil. + | lw TAB:TMP2, TAB:RB->metatable + | beqz TAB:TMP2, <1 // No metatable: done. + |. nop + | lbu TMP1, TAB:TMP2->nomm + | andi TMP1, TMP1, 1<vmeta_tgetb // Caveat: preserve TMP0! + |. nop + break; + + case BC_TSETV: + | // RA = src*8, RB = table*8, RC = key*8 + | decode_RB8a RB, INS + | decode_RB8b RB + | decode_RDtoRC8 RC, RD + | addu CARG2, BASE, RB + | addu CARG3, BASE, RC + | lw TMP1, HI(CARG2) + | lw TMP2, HI(CARG3) + | lw TAB:RB, LO(CARG2) + | li AT, LJ_TTAB + | ldc1 f0, 0(CARG3) + | bne TMP1, AT, ->vmeta_tsetv + |. addu RA, BASE, RA + | sltiu AT, TMP2, LJ_TISNUM + | beqz AT, >5 + |. li AT, LJ_TSTR + | + | // Convert number key to integer, check for integerness and range. + | cvt.w.d f2, f0 + | lw TMP0, TAB:RB->asize + | mfc1 TMP2, f2 + | cvt.d.w f4, f2 + | lw TMP1, TAB:RB->array + | c.eq.d f0, f4 + | sltu AT, TMP2, TMP0 + | movf AT, r0 + | sll TMP2, TMP2, 3 + | beqz AT, ->vmeta_tsetv // Integer key and in array part? + |. addu TMP1, TMP1, TMP2 + | lbu TMP3, TAB:RB->marked + | lw TMP0, HI(TMP1) + | beq TMP0, TISNIL, >3 + |. ldc1 f0, 0(RA) + |1: + | andi AT, TMP3, LJ_GC_BLACK // isblack(table) + | bnez AT, >7 + |. sdc1 f0, 0(TMP1) + |2: + | ins_next + | + |3: // Check for __newindex if previous value is nil. + | lw TAB:TMP2, TAB:RB->metatable + | beqz TAB:TMP2, <1 // No metatable: done. + |. nop + | lbu TMP2, TAB:TMP2->nomm + | andi TMP2, TMP2, 1<vmeta_tsetv + |. nop + | + |5: + | bne TMP2, AT, ->vmeta_tsetv + |. lw STR:RC, LO(CARG3) + | b ->BC_TSETS_Z // String key? + |. nop + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, TMP3, TMP0, <2 + break; + case BC_TSETS: + | // RA = src*8, RB = table*8, RC = str_const*8 (~) + | decode_RB8a RB, INS + | decode_RB8b RB + | addu CARG2, BASE, RB + | decode_RC4a RC, INS + | lw TMP0, HI(CARG2) + | decode_RC4b RC + | li AT, LJ_TTAB + | subu CARG3, KBASE, RC + | lw TAB:RB, LO(CARG2) + | lw STR:RC, -4(CARG3) // KBASE-4-str_const*4 + | bne TMP0, AT, ->vmeta_tsets1 + |. addu RA, BASE, RA + |->BC_TSETS_Z: + | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = BASE+src*8 + | lw TMP0, TAB:RB->hmask + | lw TMP1, STR:RC->hash + | lw NODE:TMP2, TAB:RB->node + | sb r0, TAB:RB->nomm // Clear metamethod cache. + | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask + | sll TMP0, TMP1, 5 + | sll TMP1, TMP1, 3 + | subu TMP1, TMP0, TMP1 + | addu NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) + | ldc1 f20, 0(RA) + |1: + | lw CARG1, offsetof(Node, key)+HI(NODE:TMP2) + | lw TMP0, offsetof(Node, key)+LO(NODE:TMP2) + | li AT, LJ_TSTR + | lw NODE:TMP1, NODE:TMP2->next + | bne CARG1, AT, >5 + |. lw CARG2, offsetof(Node, val)+HI(NODE:TMP2) + | bne TMP0, STR:RC, >5 + |. lbu TMP3, TAB:RB->marked + | beq CARG2, TISNIL, >4 // Key found, but nil value? + |. lw TAB:TMP0, TAB:RB->metatable + |2: + | andi AT, TMP3, LJ_GC_BLACK // isblack(table) + | bnez AT, >7 + |. sdc1 f20, NODE:TMP2->val + |3: + | ins_next + | + |4: // Check for __newindex if previous value is nil. + | beqz TAB:TMP0, <2 // No metatable: done. + |. nop + | lbu TMP0, TAB:TMP0->nomm + | andi TMP0, TMP0, 1<vmeta_tsets + |. nop + | + |5: // Follow hash chain. + | bnez NODE:TMP1, <1 + |. move NODE:TMP2, NODE:TMP1 + | // End of hash chain: key not found, add a new one + | + | // But check for __newindex first. + | lw TAB:TMP2, TAB:RB->metatable + | beqz TAB:TMP2, >6 // No metatable: continue. + |. addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) + | lbu TMP0, TAB:TMP2->nomm + | andi TMP0, TMP0, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. + |. li AT, LJ_TSTR + |6: + | load_got lj_tab_newkey + | sw STR:RC, LO(CARG3) + | sw AT, HI(CARG3) + | sw BASE, L->base + | move CARG2, TAB:RB + | sw PC, SAVE_PC + | call_intern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k + |. move CARG1, L + | // Returns TValue *. + | lw BASE, L->base + | b <3 // No 2nd write barrier needed. + |. sdc1 f20, 0(CRET1) + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, TMP3, TMP0, <3 + break; + case BC_TSETB: + | // RA = src*8, RB = table*8, RC = index*8 + | decode_RB8a RB, INS + | decode_RB8b RB + | addu CARG2, BASE, RB + | decode_RDtoRC8 RC, RD + | lw CARG1, HI(CARG2) + | li AT, LJ_TTAB + | lw TAB:RB, LO(CARG2) + | addu RA, BASE, RA + | bne CARG1, AT, ->vmeta_tsetb + |. srl TMP0, RC, 3 + | lw TMP1, TAB:RB->asize + | lw TMP2, TAB:RB->array + | sltu AT, TMP0, TMP1 + | beqz AT, ->vmeta_tsetb + |. addu RC, TMP2, RC + | lw TMP1, HI(RC) + | lbu TMP3, TAB:RB->marked + | beq TMP1, TISNIL, >5 + |. ldc1 f0, 0(RA) + |1: + | andi AT, TMP3, LJ_GC_BLACK // isblack(table) + | bnez AT, >7 + |. sdc1 f0, 0(RC) + |2: + | ins_next + | + |5: // Check for __newindex if previous value is nil. + | lw TAB:TMP2, TAB:RB->metatable + | beqz TAB:TMP2, <1 // No metatable: done. + |. nop + | lbu TMP1, TAB:TMP2->nomm + | andi TMP1, TMP1, 1<vmeta_tsetb // Caveat: preserve TMP0! + |. nop + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, TMP3, TMP0, <2 + break; + + case BC_TSETM: + | // RA = base*8 (table at base-1), RD = num_const*8 (start index) + | addu RA, BASE, RA + |1: + | addu TMP3, KBASE, RD + | lw TAB:CARG2, -8+LO(RA) // Guaranteed to be a table. + | addiu TMP0, MULTRES, -8 + | lw TMP3, LO(TMP3) // Integer constant is in lo-word. + | beqz TMP0, >4 // Nothing to copy? + |. srl CARG3, TMP0, 3 + | addu CARG3, CARG3, TMP3 + | lw TMP2, TAB:CARG2->asize + | sll TMP1, TMP3, 3 + | lbu TMP3, TAB:CARG2->marked + | lw CARG1, TAB:CARG2->array + | sltu AT, TMP2, CARG3 + | bnez AT, >5 + |. addu TMP2, RA, TMP0 + | addu TMP1, TMP1, CARG1 + | andi TMP0, TMP3, LJ_GC_BLACK // isblack(table) + |3: // Copy result slots to table. + | ldc1 f0, 0(RA) + | addiu RA, RA, 8 + | sltu AT, RA, TMP2 + | sdc1 f0, 0(TMP1) + | bnez AT, <3 + |. addiu TMP1, TMP1, 8 + | bnez TMP0, >7 + |. nop + |4: + | ins_next + | + |5: // Need to resize array part. + | load_got lj_tab_reasize + | sw BASE, L->base + | sw PC, SAVE_PC + | move BASE, RD + | call_intern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) + |. move CARG1, L + | // Must not reallocate the stack. + | move RD, BASE + | b <1 + |. lw BASE, L->base // Reload BASE for lack of a saved register. + | + |7: // Possible table write barrier for any value. Skip valiswhite check. + | barrierback TAB:CARG2, TMP3, TMP0, <4 + break; + + /* -- Calls and vararg handling ----------------------------------------- */ + + case BC_CALLM: + | // RA = base*8, (RB = (nresults+1)*8,) RC = extra_nargs*8 + | decode_RDtoRC8 NARGS8:RC, RD + | b ->BC_CALL_Z + |. addu NARGS8:RC, NARGS8:RC, MULTRES + break; + case BC_CALL: + | // RA = base*8, (RB = (nresults+1)*8,) RC = (nargs+1)*8 + | decode_RDtoRC8 NARGS8:RC, RD + |->BC_CALL_Z: + | move TMP2, BASE + | addu BASE, BASE, RA + | li AT, LJ_TFUNC + | lw TMP0, HI(BASE) + | lw LFUNC:RB, LO(BASE) + | addiu BASE, BASE, 8 + | bne TMP0, AT, ->vmeta_call + |. addiu NARGS8:RC, NARGS8:RC, -8 + | ins_call + break; + + case BC_CALLMT: + | // RA = base*8, (RB = 0,) RC = extra_nargs*8 + | addu NARGS8:RD, NARGS8:RD, MULTRES // BC_CALLT gets RC from RD. + | // Fall through. Assumes BC_CALLT follows. + break; + case BC_CALLT: + | // RA = base*8, (RB = 0,) RC = (nargs+1)*8 + | addu RA, BASE, RA + | li AT, LJ_TFUNC + | lw TMP0, HI(RA) + | lw LFUNC:RB, LO(RA) + | move NARGS8:RC, RD + | lw TMP1, FRAME_PC(BASE) + | addiu RA, RA, 8 + | bne TMP0, AT, ->vmeta_callt + |. addiu NARGS8:RC, NARGS8:RC, -8 + |->BC_CALLT_Z: + | andi TMP0, TMP1, FRAME_TYPE // Caveat: preserve TMP0 until the 'or'. + | lbu TMP3, LFUNC:RB->ffid + | bnez TMP0, >7 + |. xori TMP2, TMP1, FRAME_VARG + |1: + | sw LFUNC:RB, FRAME_FUNC(BASE) // Copy function down, but keep PC. + | sltiu AT, TMP3, 2 // (> FF_C) Calling a fast function? + | move TMP2, BASE + | beqz NARGS8:RC, >3 + |. move TMP3, NARGS8:RC + |2: + | ldc1 f0, 0(RA) + | addiu RA, RA, 8 + | addiu TMP3, TMP3, -8 + | sdc1 f0, 0(TMP2) + | bnez TMP3, <2 + |. addiu TMP2, TMP2, 8 + |3: + | or TMP0, TMP0, AT + | beqz TMP0, >5 + |. nop + |4: + | ins_callt + | + |5: // Tailcall to a fast function with a Lua frame below. + | lw INS, -4(TMP1) + | decode_RA8a RA, INS + | decode_RA8b RA + | subu TMP1, BASE, RA + | lw LFUNC:TMP1, -8+FRAME_FUNC(TMP1) + | lw TMP1, LFUNC:TMP1->pc + | b <4 + |. lw KBASE, PC2PROTO(k)(TMP1) // Need to prepare KBASE. + | + |7: // Tailcall from a vararg function. + | andi AT, TMP2, FRAME_TYPEP + | bnez AT, <1 // Vararg frame below? + |. subu TMP2, BASE, TMP2 // Relocate BASE down. + | move BASE, TMP2 + | lw TMP1, FRAME_PC(TMP2) + | b <1 + |. andi TMP0, TMP1, FRAME_TYPE + break; + + case BC_ITERC: + | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 ((2+1)*8)) + | move TMP2, BASE + | addu BASE, BASE, RA + | li AT, LJ_TFUNC + | lw TMP1, -24+HI(BASE) + | lw LFUNC:RB, -24+LO(BASE) + | ldc1 f2, -8(BASE) + | ldc1 f0, -16(BASE) + | sw TMP1, HI(BASE) // Copy callable. + | sw LFUNC:RB, LO(BASE) + | sdc1 f2, 16(BASE) // Copy control var. + | sdc1 f0, 8(BASE) // Copy state. + | addiu BASE, BASE, 8 + | bne TMP1, AT, ->vmeta_call + |. li NARGS8:RC, 16 // Iterators get 2 arguments. + | ins_call + break; + + case BC_ITERN: + | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 (2+1)*8) + |.if JIT + | // NYI: add hotloop, record BC_ITERN. + |.endif + | addu RA, BASE, RA + | lw TAB:RB, -16+LO(RA) + | lw RC, -8+LO(RA) // Get index from control var. + | lw TMP0, TAB:RB->asize + | lw TMP1, TAB:RB->array + | addiu PC, PC, 4 + |1: // Traverse array part. + | sltu AT, RC, TMP0 + | beqz AT, >5 // Index points after array part? + |. sll TMP3, RC, 3 + | addu TMP3, TMP1, TMP3 + | lw TMP2, HI(TMP3) + | ldc1 f0, 0(TMP3) + | mtc1 RC, f2 + | lhu RD, -4+OFS_RD(PC) + | beq TMP2, TISNIL, <1 // Skip holes in array part. + |. addiu RC, RC, 1 + | cvt.d.w f2, f2 + | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) + | sdc1 f0, 8(RA) + | decode_RD4b RD + | addu RD, RD, TMP3 + | sw RC, -8+LO(RA) // Update control var. + | addu PC, PC, RD + | sdc1 f2, 0(RA) + |3: + | ins_next + | + |5: // Traverse hash part. + | lw TMP1, TAB:RB->hmask + | subu RC, RC, TMP0 + | lw TMP2, TAB:RB->node + |6: + | sltu AT, TMP1, RC // End of iteration? Branch to ITERL+1. + | bnez AT, <3 + |. sll TMP3, RC, 5 + | sll RB, RC, 3 + | subu TMP3, TMP3, RB + | addu NODE:TMP3, TMP3, TMP2 + | lw RB, HI(NODE:TMP3) + | ldc1 f0, 0(NODE:TMP3) + | lhu RD, -4+OFS_RD(PC) + | beq RB, TISNIL, <6 // Skip holes in hash part. + |. addiu RC, RC, 1 + | ldc1 f2, NODE:TMP3->key + | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) + | sdc1 f0, 8(RA) + | addu RC, RC, TMP0 + | decode_RD4b RD + | addu RD, RD, TMP3 + | sdc1 f2, 0(RA) + | addu PC, PC, RD + | b <3 + |. sw RC, -8+LO(RA) // Update control var. + break; + + case BC_ISNEXT: + | // RA = base*8, RD = target (points to ITERN) + | addu RA, BASE, RA + | lw TMP0, -24+HI(RA) + | lw CFUNC:TMP1, -24+LO(RA) + | lw TMP2, -16+HI(RA) + | lw TMP3, -8+HI(RA) + | li AT, LJ_TFUNC + | bne TMP0, AT, >5 + |. addiu TMP2, TMP2, -LJ_TTAB + | lbu TMP1, CFUNC:TMP1->ffid + | addiu TMP3, TMP3, -LJ_TNIL + | srl TMP0, RD, 1 + | or TMP2, TMP2, TMP3 + | addiu TMP1, TMP1, -FF_next_N + | addu TMP0, PC, TMP0 + | or TMP1, TMP1, TMP2 + | bnez TMP1, >5 + |. lui TMP2, (-(BCBIAS_J*4 >> 16) & 65535) + | addu PC, TMP0, TMP2 + | lui TMP1, 0xfffe + | ori TMP1, TMP1, 0x7fff + | sw r0, -8+LO(RA) // Initialize control var. + | sw TMP1, -8+HI(RA) + |1: + | ins_next + |5: // Despecialize bytecode if any of the checks fail. + | li TMP3, BC_JMP + | li TMP1, BC_ITERC + | sb TMP3, -4+OFS_OP(PC) + | addu PC, TMP0, TMP2 + | b <1 + |. sb TMP1, OFS_OP(PC) + break; + + case BC_VARG: + | // RA = base*8, RB = (nresults+1)*8, RC = numparams*8 + | lw TMP0, FRAME_PC(BASE) + | decode_RDtoRC8 RC, RD + | decode_RB8a RB, INS + | addu RC, BASE, RC + | decode_RB8b RB + | addu RA, BASE, RA + | addiu RC, RC, FRAME_VARG + | addu TMP2, RA, RB + | addiu TMP3, BASE, -8 // TMP3 = vtop + | subu RC, RC, TMP0 // RC = vbase + | // Note: RC may now be even _above_ BASE if nargs was < numparams. + | beqz RB, >5 // Copy all varargs? + |. subu TMP1, TMP3, RC + | addiu TMP2, TMP2, -16 + |1: // Copy vararg slots to destination slots. + | lw CARG1, HI(RC) + | sltu AT, RC, TMP3 + | lw CARG2, LO(RC) + | addiu RC, RC, 8 + | movz CARG1, TISNIL, AT + | sw CARG1, HI(RA) + | sw CARG2, LO(RA) + | sltu AT, RA, TMP2 + | bnez AT, <1 + |. addiu RA, RA, 8 + |3: + | ins_next + | + |5: // Copy all varargs. + | lw TMP0, L->maxstack + | blez TMP1, <3 // No vararg slots? + |. li MULTRES, 8 // MULTRES = (0+1)*8 + | addu TMP2, RA, TMP1 + | sltu AT, TMP0, TMP2 + | bnez AT, >7 + |. addiu MULTRES, TMP1, 8 + |6: + | ldc1 f0, 0(RC) + | addiu RC, RC, 8 + | sdc1 f0, 0(RA) + | sltu AT, RC, TMP3 + | bnez AT, <6 // More vararg slots? + |. addiu RA, RA, 8 + | b <3 + |. nop + | + |7: // Grow stack for varargs. + | load_got lj_state_growstack + | sw RA, L->top + | subu RA, RA, BASE + | sw BASE, L->base + | subu BASE, RC, BASE // Need delta, because BASE may change. + | sw PC, SAVE_PC + | srl CARG2, TMP1, 3 + | call_intern lj_state_growstack // (lua_State *L, int n) + |. move CARG1, L + | move RC, BASE + | lw BASE, L->base + | addu RA, BASE, RA + | addu RC, BASE, RC + | b <6 + |. addiu TMP3, BASE, -8 + break; + + /* -- Returns ----------------------------------------------------------- */ + + case BC_RETM: + | // RA = results*8, RD = extra_nresults*8 + | addu RD, RD, MULTRES // MULTRES >= 8, so RD >= 8. + | // Fall through. Assumes BC_RET follows. + break; + + case BC_RET: + | // RA = results*8, RD = (nresults+1)*8 + | lw PC, FRAME_PC(BASE) + | addu RA, BASE, RA + | move MULTRES, RD + |1: + | andi TMP0, PC, FRAME_TYPE + | bnez TMP0, ->BC_RETV_Z + |. xori TMP1, PC, FRAME_VARG + | + |->BC_RET_Z: + | // BASE = base, RA = resultptr, RD = (nresults+1)*8, PC = return + | lw INS, -4(PC) + | addiu TMP2, BASE, -8 + | addiu RC, RD, -8 + | decode_RA8a TMP0, INS + | decode_RB8a RB, INS + | decode_RA8b TMP0 + | decode_RB8b RB + | addu TMP3, TMP2, RB + | beqz RC, >3 + |. subu BASE, TMP2, TMP0 + |2: + | ldc1 f0, 0(RA) + | addiu RA, RA, 8 + | addiu RC, RC, -8 + | sdc1 f0, 0(TMP2) + | bnez RC, <2 + |. addiu TMP2, TMP2, 8 + |3: + | addiu TMP3, TMP3, -8 + |5: + | sltu AT, TMP2, TMP3 + | bnez AT, >6 + |. lw LFUNC:TMP1, FRAME_FUNC(BASE) + | ins_next1 + | lw TMP1, LFUNC:TMP1->pc + | lw KBASE, PC2PROTO(k)(TMP1) + | ins_next2 + | + |6: // Fill up results with nil. + | sw TISNIL, HI(TMP2) + | b <5 + |. addiu TMP2, TMP2, 8 + | + |->BC_RETV_Z: // Non-standard return case. + | andi TMP2, TMP1, FRAME_TYPEP + | bnez TMP2, ->vm_return + |. nop + | // Return from vararg function: relocate BASE down. + | subu BASE, BASE, TMP1 + | b <1 + |. lw PC, FRAME_PC(BASE) + break; + + case BC_RET0: case BC_RET1: + | // RA = results*8, RD = (nresults+1)*8 + | lw PC, FRAME_PC(BASE) + | addu RA, BASE, RA + | move MULTRES, RD + | andi TMP0, PC, FRAME_TYPE + | bnez TMP0, ->BC_RETV_Z + |. xori TMP1, PC, FRAME_VARG + | + | lw INS, -4(PC) + | addiu TMP2, BASE, -8 + if (op == BC_RET1) { + | ldc1 f0, 0(RA) + } + | decode_RB8a RB, INS + | decode_RA8a RA, INS + | decode_RB8b RB + | decode_RA8b RA + if (op == BC_RET1) { + | sdc1 f0, 0(TMP2) + } + | subu BASE, TMP2, RA + |5: + | sltu AT, RD, RB + | bnez AT, >6 + |. lw LFUNC:TMP1, FRAME_FUNC(BASE) + | ins_next1 + | lw TMP1, LFUNC:TMP1->pc + | lw KBASE, PC2PROTO(k)(TMP1) + | ins_next2 + | + |6: // Fill up results with nil. + | addiu TMP2, TMP2, 8 + | addiu RD, RD, 8 + | b <5 + if (op == BC_RET1) { + |. sw TISNIL, HI(TMP2) + } else { + |. sw TISNIL, -8+HI(TMP2) + } + break; + + /* -- Loops and branches ------------------------------------------------ */ + + case BC_FORL: + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_IFORL follows. + break; + + case BC_JFORI: + case BC_JFORL: +#if !LJ_HASJIT + break; +#endif + case BC_FORI: + case BC_IFORL: + | // RA = base*8, RD = target (after end of loop or start of loop) + vk = (op == BC_IFORL || op == BC_JFORL); + | addu RA, BASE, RA + if (vk) { + | ldc1 f0, FORL_IDX*8(RA) + | ldc1 f4, FORL_STEP*8(RA) + | ldc1 f2, FORL_STOP*8(RA) + | lw TMP3, FORL_STEP*8+HI(RA) + | add.d f0, f0, f4 + | sdc1 f0, FORL_IDX*8(RA) + } else { + | lw TMP1, FORL_IDX*8+HI(RA) + | lw TMP3, FORL_STEP*8+HI(RA) + | lw TMP2, FORL_STOP*8+HI(RA) + | sltiu TMP1, TMP1, LJ_TISNUM + | sltiu TMP0, TMP3, LJ_TISNUM + | sltiu TMP2, TMP2, LJ_TISNUM + | and TMP1, TMP1, TMP0 + | and TMP1, TMP1, TMP2 + | ldc1 f0, FORL_IDX*8(RA) + | beqz TMP1, ->vmeta_for + |. ldc1 f2, FORL_STOP*8(RA) + } + if (op != BC_JFORL) { + | srl RD, RD, 1 + | lui TMP0, (-(BCBIAS_J*4 >> 16) & 65535) + } + | c.le.d 0, f0, f2 + | c.le.d 1, f2, f0 + | sdc1 f0, FORL_EXT*8(RA) + if (op == BC_JFORI) { + | li TMP1, 1 + | li TMP2, 1 + | addu TMP0, RD, TMP0 + | slt TMP3, TMP3, r0 + | movf TMP1, r0, 0 + | addu PC, PC, TMP0 + | movf TMP2, r0, 1 + | lhu RD, -4+OFS_RD(PC) + | movn TMP1, TMP2, TMP3 + | bnez TMP1, =>BC_JLOOP + |. decode_RD8b RD + } else if (op == BC_JFORL) { + | li TMP1, 1 + | li TMP2, 1 + | slt TMP3, TMP3, r0 + | movf TMP1, r0, 0 + | movf TMP2, r0, 1 + | movn TMP1, TMP2, TMP3 + | bnez TMP1, =>BC_JLOOP + |. nop + } else { + | addu TMP1, RD, TMP0 + | slt TMP3, TMP3, r0 + | move TMP2, TMP1 + if (op == BC_FORI) { + | movt TMP1, r0, 0 + | movt TMP2, r0, 1 + } else { + | movf TMP1, r0, 0 + | movf TMP2, r0, 1 + } + | movn TMP1, TMP2, TMP3 + | addu PC, PC, TMP1 + } + | ins_next + break; + + case BC_ITERL: + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_IITERL follows. + break; + + case BC_JITERL: +#if !LJ_HASJIT + break; +#endif + case BC_IITERL: + | // RA = base*8, RD = target + | addu RA, BASE, RA + | lw TMP1, HI(RA) + | beq TMP1, TISNIL, >1 // Stop if iterator returned nil. + |. lw TMP2, LO(RA) + if (op == BC_JITERL) { + | sw TMP1, -8+HI(RA) + | b =>BC_JLOOP + |. sw TMP2, -8+LO(RA) + } else { + | branch_RD // Otherwise save control var + branch. + | sw TMP1, -8+HI(RA) + | sw TMP2, -8+LO(RA) + } + |1: + | ins_next + break; + + case BC_LOOP: + | // RA = base*8, RD = target (loop extent) + | // Note: RA/RD is only used by trace recorder to determine scope/extent + | // This opcode does NOT jump, it's only purpose is to detect a hot loop. + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_ILOOP follows. + break; + + case BC_ILOOP: + | // RA = base*8, RD = target (loop extent) + | ins_next + break; + + case BC_JLOOP: + |.if JIT + | // RA = base*8 (ignored), RD = traceno*8 + | lw TMP1, DISPATCH_J(trace)(DISPATCH) + | srl RD, RD, 1 + | li AT, 0 + | addu TMP1, TMP1, RD + | // Traces on MIPS don't store the trace number, so use 0. + | sw AT, DISPATCH_GL(vmstate)(DISPATCH) + | lw TRACE:TMP2, 0(TMP1) + | sw BASE, DISPATCH_GL(jit_base)(DISPATCH) + | sw L, DISPATCH_GL(jit_L)(DISPATCH) + | lw TMP2, TRACE:TMP2->mcode + | jr TMP2 + |. addiu JGL, DISPATCH, GG_DISP2G+32768 + |.endif + break; + + case BC_JMP: + | // RA = base*8 (only used by trace recorder), RD = target + | branch_RD + | ins_next + break; + + /* -- Function headers -------------------------------------------------- */ + + case BC_FUNCF: + |.if JIT + | hotcall + |.endif + case BC_FUNCV: /* NYI: compiled vararg functions. */ + | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow. + break; + + case BC_JFUNCF: +#if !LJ_HASJIT + break; +#endif + case BC_IFUNCF: + | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 + | lw TMP2, L->maxstack + | lbu TMP1, -4+PC2PROTO(numparams)(PC) + | lw KBASE, -4+PC2PROTO(k)(PC) + | sltu AT, TMP2, RA + | bnez AT, ->vm_growstack_l + |. sll TMP1, TMP1, 3 + if (op != BC_JFUNCF) { + | ins_next1 + } + |2: + | sltu AT, NARGS8:RC, TMP1 // Check for missing parameters. + | bnez AT, >3 + |. addu AT, BASE, NARGS8:RC + if (op == BC_JFUNCF) { + | decode_RD8a RD, INS + | b =>BC_JLOOP + |. decode_RD8b RD + } else { + | ins_next2 + } + | + |3: // Clear missing parameters. + | sw TISNIL, HI(AT) + | b <2 + |. addiu NARGS8:RC, NARGS8:RC, 8 + break; + + case BC_JFUNCV: +#if !LJ_HASJIT + break; +#endif + | NYI // NYI: compiled vararg functions + break; /* NYI: compiled vararg functions. */ + + case BC_IFUNCV: + | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 + | addu TMP1, BASE, RC + | lw TMP2, L->maxstack + | addu TMP0, RA, RC + | sw LFUNC:RB, LO(TMP1) // Store copy of LFUNC. + | addiu TMP3, RC, 8+FRAME_VARG + | sltu AT, TMP0, TMP2 + | lw KBASE, -4+PC2PROTO(k)(PC) + | beqz AT, ->vm_growstack_l + |. sw TMP3, HI(TMP1) // Store delta + FRAME_VARG. + | lbu TMP2, -4+PC2PROTO(numparams)(PC) + | move RA, BASE + | move RC, TMP1 + | ins_next1 + | beqz TMP2, >3 + |. addiu BASE, TMP1, 8 + |1: + | lw TMP0, HI(RA) + | lw TMP3, LO(RA) + | sltu AT, RA, RC // Less args than parameters? + | move CARG1, TMP0 + | movz TMP0, TISNIL, AT // Clear missing parameters. + | movn CARG1, TISNIL, AT // Clear old fixarg slot (help the GC). + | sw TMP3, 8+LO(TMP1) + | addiu TMP2, TMP2, -1 + | sw TMP0, 8+HI(TMP1) + | addiu TMP1, TMP1, 8 + | sw CARG1, HI(RA) + | bnez TMP2, <1 + |. addiu RA, RA, 8 + |3: + | ins_next2 + break; + + case BC_FUNCC: + case BC_FUNCCW: + | // BASE = new base, RA = BASE+framesize*8, RB = CFUNC, RC = nargs*8 + if (op == BC_FUNCC) { + | lw CFUNCADDR, CFUNC:RB->f + } else { + | lw CFUNCADDR, DISPATCH_GL(wrapf)(DISPATCH) + } + | addu TMP1, RA, NARGS8:RC + | lw TMP2, L->maxstack + | addu RC, BASE, NARGS8:RC + | sw BASE, L->base + | sltu AT, TMP2, TMP1 + | sw RC, L->top + | li_vmstate C + if (op == BC_FUNCCW) { + | lw CARG2, CFUNC:RB->f + } + | bnez AT, ->vm_growstack_c // Need to grow stack. + |. move CARG1, L + | jalr CFUNCADDR // (lua_State *L [, lua_CFunction f]) + |. st_vmstate + | // Returns nresults. + | lw BASE, L->base + | sll RD, CRET1, 3 + | lw TMP1, L->top + | li_vmstate INTERP + | lw PC, FRAME_PC(BASE) // Fetch PC of caller. + | subu RA, TMP1, RD // RA = L->top - nresults*8 + | b ->vm_returnc + |. st_vmstate + break; + + /* ---------------------------------------------------------------------- */ + + default: + fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); + exit(2); + break; + } +} + +static int build_backend(BuildCtx *ctx) +{ + int op; + + dasm_growpc(Dst, BC__MAX); + + build_subroutines(ctx); + + |.code_op + for (op = 0; op < BC__MAX; op++) + build_ins(ctx, (BCOp)op, op); + + return BC__MAX; +} + +/* Emit pseudo frame-info for all assembler functions. */ +static void emit_asm_debug(BuildCtx *ctx) +{ + int fcofs = (int)((uint8_t *)ctx->glob[GLOB_vm_ffi_call] - ctx->code); + int i; + switch (ctx->mode) { + case BUILD_elfasm: + fprintf(ctx->fp, "\t.section .debug_frame,\"\",@progbits\n"); + fprintf(ctx->fp, + ".Lframe0:\n" + "\t.4byte .LECIE0-.LSCIE0\n" + ".LSCIE0:\n" + "\t.4byte 0xffffffff\n" + "\t.byte 0x1\n" + "\t.string \"\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -4\n" + "\t.byte 31\n" + "\t.byte 0xc\n\t.uleb128 29\n\t.uleb128 0\n" + "\t.align 2\n" + ".LECIE0:\n\n"); + fprintf(ctx->fp, + ".LSFDE0:\n" + "\t.4byte .LEFDE0-.LASFDE0\n" + ".LASFDE0:\n" + "\t.4byte .Lframe0\n" + "\t.4byte .Lbegin\n" + "\t.4byte %d\n" + "\t.byte 0xe\n\t.uleb128 %d\n" + "\t.byte 0x9f\n\t.sleb128 1\n" + "\t.byte 0x9e\n\t.sleb128 2\n", + fcofs, CFRAME_SIZE); + for (i = 23; i >= 16; i--) + fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+i, 26-i); + for (i = 30; i >= 20; i -= 2) + fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+32+i, 42-i); + fprintf(ctx->fp, + "\t.align 2\n" + ".LEFDE0:\n\n"); +#if LJ_HASFFI + fprintf(ctx->fp, + ".LSFDE1:\n" + "\t.4byte .LEFDE1-.LASFDE1\n" + ".LASFDE1:\n" + "\t.4byte .Lframe0\n" + "\t.4byte lj_vm_ffi_call\n" + "\t.4byte %d\n" + "\t.byte 0x9f\n\t.uleb128 1\n" + "\t.byte 0x90\n\t.uleb128 2\n" + "\t.byte 0xd\n\t.uleb128 0x10\n" + "\t.align 2\n" + ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); +#endif + fprintf(ctx->fp, "\t.section .eh_frame,\"aw\",@progbits\n"); + fprintf(ctx->fp, + "\t.globl lj_err_unwind_dwarf\n" + ".Lframe1:\n" + "\t.4byte .LECIE1-.LSCIE1\n" + ".LSCIE1:\n" + "\t.4byte 0\n" + "\t.byte 0x1\n" + "\t.string \"zPR\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -4\n" + "\t.byte 31\n" + "\t.uleb128 6\n" /* augmentation length */ + "\t.byte 0\n" + "\t.4byte lj_err_unwind_dwarf\n" + "\t.byte 0\n" + "\t.byte 0xc\n\t.uleb128 29\n\t.uleb128 0\n" + "\t.align 2\n" + ".LECIE1:\n\n"); + fprintf(ctx->fp, + ".LSFDE2:\n" + "\t.4byte .LEFDE2-.LASFDE2\n" + ".LASFDE2:\n" + "\t.4byte .LASFDE2-.Lframe1\n" + "\t.4byte .Lbegin\n" + "\t.4byte %d\n" + "\t.uleb128 0\n" /* augmentation length */ + "\t.byte 0xe\n\t.uleb128 %d\n" + "\t.byte 0x9f\n\t.sleb128 1\n" + "\t.byte 0x9e\n\t.sleb128 2\n", + fcofs, CFRAME_SIZE); + for (i = 23; i >= 16; i--) + fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+i, 26-i); + for (i = 30; i >= 20; i -= 2) + fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+32+i, 42-i); + fprintf(ctx->fp, + "\t.align 2\n" + ".LEFDE2:\n\n"); +#if LJ_HASFFI + fprintf(ctx->fp, + ".Lframe2:\n" + "\t.4byte .LECIE2-.LSCIE2\n" + ".LSCIE2:\n" + "\t.4byte 0\n" + "\t.byte 0x1\n" + "\t.string \"zR\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -4\n" + "\t.byte 31\n" + "\t.uleb128 1\n" /* augmentation length */ + "\t.byte 0\n" + "\t.byte 0xc\n\t.uleb128 29\n\t.uleb128 0\n" + "\t.align 2\n" + ".LECIE2:\n\n"); + fprintf(ctx->fp, + ".LSFDE3:\n" + "\t.4byte .LEFDE3-.LASFDE3\n" + ".LASFDE3:\n" + "\t.4byte .LASFDE3-.Lframe2\n" + "\t.4byte lj_vm_ffi_call\n" + "\t.4byte %d\n" + "\t.uleb128 0\n" /* augmentation length */ + "\t.byte 0x9f\n\t.uleb128 1\n" + "\t.byte 0x90\n\t.uleb128 2\n" + "\t.byte 0xd\n\t.uleb128 0x10\n" + "\t.align 2\n" + ".LEFDE3:\n\n", (int)ctx->codesz - fcofs); +#endif + break; + default: + break; + } +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/vm_ppc.dasc b/source/libs/luajit/LuaJIT-2.0.4/src/vm_ppc.dasc new file mode 100644 index 000000000..ad8a023e4 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/vm_ppc.dasc @@ -0,0 +1,5160 @@ +|// Low-level VM code for PowerPC CPUs. +|// Bytecode interpreter, fast functions and helper functions. +|// Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +| +|.arch ppc +|.section code_op, code_sub +| +|.actionlist build_actionlist +|.globals GLOB_ +|.globalnames globnames +|.externnames extnames +| +|// Note: The ragged indentation of the instructions is intentional. +|// The starting columns indicate data dependencies. +| +|//----------------------------------------------------------------------- +| +|// DynASM defines used by the PPC port: +|// +|// P64 64 bit pointers (only for GPR64 testing). +|// Note: a full PPC64 _LP64 port is not planned. +|// GPR64 64 bit registers (but possibly 32 bit pointers, e.g. PS3). +|// Affects reg saves, stack layout, carry/overflow/dot flags etc. +|// FRAME32 Use 32 bit frame layout, even with GPR64 (Xbox 360). +|// TOC Need table of contents (64 bit or 32 bit variant, e.g. PS3). +|// Function pointers are really a struct: code, TOC, env (optional). +|// TOCENV Function pointers have an environment pointer, too (not on PS3). +|// PPE Power Processor Element of Cell (PS3) or Xenon (Xbox 360). +|// Must avoid (slow) micro-coded instructions. +| +|.if P64 +|.define TOC, 1 +|.define TOCENV, 1 +|.macro lpx, a, b, c; ldx a, b, c; .endmacro +|.macro lp, a, b; ld a, b; .endmacro +|.macro stp, a, b; std a, b; .endmacro +|.define decode_OPP, decode_OP8 +|.if FFI +|// Missing: Calling conventions, 64 bit regs, TOC. +|.error lib_ffi not yet implemented for PPC64 +|.endif +|.else +|.macro lpx, a, b, c; lwzx a, b, c; .endmacro +|.macro lp, a, b; lwz a, b; .endmacro +|.macro stp, a, b; stw a, b; .endmacro +|.define decode_OPP, decode_OP4 +|.endif +| +|// Convenience macros for TOC handling. +|.if TOC +|// Linker needs a TOC patch area for every external call relocation. +|.macro blex, target; bl extern target@plt; nop; .endmacro +|.macro .toc, a, b; a, b; .endmacro +|.if P64 +|.define TOC_OFS, 8 +|.define ENV_OFS, 16 +|.else +|.define TOC_OFS, 4 +|.define ENV_OFS, 8 +|.endif +|.else // No TOC. +|.macro blex, target; bl extern target@plt; .endmacro +|.macro .toc, a, b; .endmacro +|.endif +|.macro .tocenv, a, b; .if TOCENV; a, b; .endif; .endmacro +| +|.macro .gpr64, a, b; .if GPR64; a, b; .endif; .endmacro +| +|.macro andix., y, a, i +|.if PPE +| rlwinm y, a, 0, 31-lj_fls(i), 31-lj_ffs(i) +| cmpwi y, 0 +|.else +| andi. y, a, i +|.endif +|.endmacro +| +|.macro clrso, reg +|.if PPE +| li reg, 0 +| mtxer reg +|.else +| mcrxr cr0 +|.endif +|.endmacro +| +|.macro checkov, reg, noov +|.if PPE +| mfxer reg +| add reg, reg, reg +| cmpwi reg, 0 +| li reg, 0 +| mtxer reg +| bgey noov +|.else +| mcrxr cr0 +| bley noov +|.endif +|.endmacro +| +|//----------------------------------------------------------------------- +| +|// Fixed register assignments for the interpreter. +|// Don't use: r1 = sp, r2 and r13 = reserved (TOC, TLS or SDATA) +| +|// The following must be C callee-save (but BASE is often refetched). +|.define BASE, r14 // Base of current Lua stack frame. +|.define KBASE, r15 // Constants of current Lua function. +|.define PC, r16 // Next PC. +|.define DISPATCH, r17 // Opcode dispatch table. +|.define LREG, r18 // Register holding lua_State (also in SAVE_L). +|.define MULTRES, r19 // Size of multi-result: (nresults+1)*8. +|.define JGL, r31 // On-trace: global_State + 32768. +| +|// Constants for type-comparisons, stores and conversions. C callee-save. +|.define TISNUM, r22 +|.define TISNIL, r23 +|.define ZERO, r24 +|.define TOBIT, f30 // 2^52 + 2^51. +|.define TONUM, f31 // 2^52 + 2^51 + 2^31. +| +|// The following temporaries are not saved across C calls, except for RA. +|.define RA, r20 // Callee-save. +|.define RB, r10 +|.define RC, r11 +|.define RD, r12 +|.define INS, r7 // Overlaps CARG5. +| +|.define TMP0, r0 +|.define TMP1, r8 +|.define TMP2, r9 +|.define TMP3, r6 // Overlaps CARG4. +| +|// Saved temporaries. +|.define SAVE0, r21 +| +|// Calling conventions. +|.define CARG1, r3 +|.define CARG2, r4 +|.define CARG3, r5 +|.define CARG4, r6 // Overlaps TMP3. +|.define CARG5, r7 // Overlaps INS. +| +|.define FARG1, f1 +|.define FARG2, f2 +| +|.define CRET1, r3 +|.define CRET2, r4 +| +|.define TOCREG, r2 // TOC register (only used by C code). +|.define ENVREG, r11 // Environment pointer (nested C functions). +| +|// Stack layout while in interpreter. Must match with lj_frame.h. +|.if GPR64 +|.if FRAME32 +| +|// 456(sp) // \ 32/64 bit C frame info +|.define TONUM_LO, 452(sp) // | +|.define TONUM_HI, 448(sp) // | +|.define TMPD_LO, 444(sp) // | +|.define TMPD_HI, 440(sp) // | +|.define SAVE_CR, 432(sp) // | 64 bit CR save. +|.define SAVE_ERRF, 424(sp) // > Parameter save area. +|.define SAVE_NRES, 420(sp) // | +|.define SAVE_L, 416(sp) // | +|.define SAVE_PC, 412(sp) // | +|.define SAVE_MULTRES, 408(sp) // | +|.define SAVE_CFRAME, 400(sp) // / 64 bit C frame chain. +|// 392(sp) // Reserved. +|.define CFRAME_SPACE, 384 // Delta for sp. +|// Back chain for sp: 384(sp) <-- sp entering interpreter +|.define SAVE_LR, 376(sp) // 32 bit LR stored in hi-part. +|.define SAVE_GPR_, 232 // .. 232+18*8: 64 bit GPR saves. +|.define SAVE_FPR_, 88 // .. 88+18*8: 64 bit FPR saves. +|// 80(sp) // Needed for 16 byte stack frame alignment. +|// 16(sp) // Callee parameter save area (ABI mandated). +|// 8(sp) // Reserved +|// Back chain for sp: 0(sp) <-- sp while in interpreter +|// 32 bit sp stored in hi-part of 0(sp). +| +|.define TMPD_BLO, 447(sp) +|.define TMPD, TMPD_HI +|.define TONUM_D, TONUM_HI +| +|.else +| +|// 508(sp) // \ 32 bit C frame info. +|.define SAVE_ERRF, 472(sp) // | +|.define SAVE_NRES, 468(sp) // | +|.define SAVE_L, 464(sp) // > Parameter save area. +|.define SAVE_PC, 460(sp) // | +|.define SAVE_MULTRES, 456(sp) // | +|.define SAVE_CFRAME, 448(sp) // / 64 bit C frame chain. +|.define SAVE_LR, 416(sp) +|.define CFRAME_SPACE, 400 // Delta for sp. +|// Back chain for sp: 400(sp) <-- sp entering interpreter +|.define SAVE_FPR_, 256 // .. 256+18*8: 64 bit FPR saves. +|.define SAVE_GPR_, 112 // .. 112+18*8: 64 bit GPR saves. +|// 48(sp) // Callee parameter save area (ABI mandated). +|.define SAVE_TOC, 40(sp) // TOC save area. +|.define TMPD_LO, 36(sp) // \ Link editor temp (ABI mandated). +|.define TMPD_HI, 32(sp) // / +|.define TONUM_LO, 28(sp) // \ Compiler temp (ABI mandated). +|.define TONUM_HI, 24(sp) // / +|// Next frame lr: 16(sp) +|.define SAVE_CR, 8(sp) // 64 bit CR save. +|// Back chain for sp: 0(sp) <-- sp while in interpreter +| +|.define TMPD_BLO, 39(sp) +|.define TMPD, TMPD_HI +|.define TONUM_D, TONUM_HI +| +|.endif +|.else +| +|.define SAVE_LR, 276(sp) +|.define CFRAME_SPACE, 272 // Delta for sp. +|// Back chain for sp: 272(sp) <-- sp entering interpreter +|.define SAVE_FPR_, 128 // .. 128+18*8: 64 bit FPR saves. +|.define SAVE_GPR_, 56 // .. 56+18*4: 32 bit GPR saves. +|.define SAVE_CR, 52(sp) // 32 bit CR save. +|.define SAVE_ERRF, 48(sp) // 32 bit C frame info. +|.define SAVE_NRES, 44(sp) +|.define SAVE_CFRAME, 40(sp) +|.define SAVE_L, 36(sp) +|.define SAVE_PC, 32(sp) +|.define SAVE_MULTRES, 28(sp) +|.define UNUSED1, 24(sp) +|.define TMPD_LO, 20(sp) +|.define TMPD_HI, 16(sp) +|.define TONUM_LO, 12(sp) +|.define TONUM_HI, 8(sp) +|// Next frame lr: 4(sp) +|// Back chain for sp: 0(sp) <-- sp while in interpreter +| +|.define TMPD_BLO, 23(sp) +|.define TMPD, TMPD_HI +|.define TONUM_D, TONUM_HI +| +|.endif +| +|.macro save_, reg +|.if GPR64 +| std r..reg, SAVE_GPR_+(reg-14)*8(sp) +|.else +| stw r..reg, SAVE_GPR_+(reg-14)*4(sp) +|.endif +| stfd f..reg, SAVE_FPR_+(reg-14)*8(sp) +|.endmacro +|.macro rest_, reg +|.if GPR64 +| ld r..reg, SAVE_GPR_+(reg-14)*8(sp) +|.else +| lwz r..reg, SAVE_GPR_+(reg-14)*4(sp) +|.endif +| lfd f..reg, SAVE_FPR_+(reg-14)*8(sp) +|.endmacro +| +|.macro saveregs +|.if GPR64 and not FRAME32 +| stdu sp, -CFRAME_SPACE(sp) +|.else +| stwu sp, -CFRAME_SPACE(sp) +|.endif +| save_ 14; save_ 15; save_ 16 +| mflr r0 +| save_ 17; save_ 18; save_ 19; save_ 20; save_ 21; save_ 22 +|.if GPR64 and not FRAME32 +| std r0, SAVE_LR +|.else +| stw r0, SAVE_LR +|.endif +| save_ 23; save_ 24; save_ 25 +| mfcr r0 +| save_ 26; save_ 27; save_ 28; save_ 29; save_ 30; save_ 31 +|.if GPR64 +| std r0, SAVE_CR +|.else +| stw r0, SAVE_CR +|.endif +| .toc std TOCREG, SAVE_TOC +|.endmacro +| +|.macro restoreregs +|.if GPR64 and not FRAME32 +| ld r0, SAVE_LR +|.else +| lwz r0, SAVE_LR +|.endif +|.if GPR64 +| ld r12, SAVE_CR +|.else +| lwz r12, SAVE_CR +|.endif +| rest_ 14; rest_ 15; rest_ 16; rest_ 17; rest_ 18; rest_ 19 +| mtlr r0; +|.if PPE; mtocrf 0x20, r12; .else; mtcrf 0x38, r12; .endif +| rest_ 20; rest_ 21; rest_ 22; rest_ 23; rest_ 24; rest_ 25 +|.if PPE; mtocrf 0x10, r12; .endif +| rest_ 26; rest_ 27; rest_ 28; rest_ 29; rest_ 30; rest_ 31 +|.if PPE; mtocrf 0x08, r12; .endif +| addi sp, sp, CFRAME_SPACE +|.endmacro +| +|// Type definitions. Some of these are only used for documentation. +|.type L, lua_State, LREG +|.type GL, global_State +|.type TVALUE, TValue +|.type GCOBJ, GCobj +|.type STR, GCstr +|.type TAB, GCtab +|.type LFUNC, GCfuncL +|.type CFUNC, GCfuncC +|.type PROTO, GCproto +|.type UPVAL, GCupval +|.type NODE, Node +|.type NARGS8, int +|.type TRACE, GCtrace +| +|//----------------------------------------------------------------------- +| +|// These basic macros should really be part of DynASM. +|.macro srwi, rx, ry, n; rlwinm rx, ry, 32-n, n, 31; .endmacro +|.macro slwi, rx, ry, n; rlwinm rx, ry, n, 0, 31-n; .endmacro +|.macro rotlwi, rx, ry, n; rlwinm rx, ry, n, 0, 31; .endmacro +|.macro rotlw, rx, ry, rn; rlwnm rx, ry, rn, 0, 31; .endmacro +|.macro subi, rx, ry, i; addi rx, ry, -i; .endmacro +| +|// Trap for not-yet-implemented parts. +|.macro NYI; tw 4, sp, sp; .endmacro +| +|// int/FP conversions. +|.macro tonum_i, freg, reg +| xoris reg, reg, 0x8000 +| stw reg, TONUM_LO +| lfd freg, TONUM_D +| fsub freg, freg, TONUM +|.endmacro +| +|.macro tonum_u, freg, reg +| stw reg, TONUM_LO +| lfd freg, TONUM_D +| fsub freg, freg, TOBIT +|.endmacro +| +|.macro toint, reg, freg, tmpfreg +| fctiwz tmpfreg, freg +| stfd tmpfreg, TMPD +| lwz reg, TMPD_LO +|.endmacro +| +|.macro toint, reg, freg +| toint reg, freg, freg +|.endmacro +| +|//----------------------------------------------------------------------- +| +|// Access to frame relative to BASE. +|.define FRAME_PC, -8 +|.define FRAME_FUNC, -4 +| +|// Instruction decode. +|.macro decode_OP4, dst, ins; rlwinm dst, ins, 2, 22, 29; .endmacro +|.macro decode_OP8, dst, ins; rlwinm dst, ins, 3, 21, 28; .endmacro +|.macro decode_RA8, dst, ins; rlwinm dst, ins, 27, 21, 28; .endmacro +|.macro decode_RB8, dst, ins; rlwinm dst, ins, 11, 21, 28; .endmacro +|.macro decode_RC8, dst, ins; rlwinm dst, ins, 19, 21, 28; .endmacro +|.macro decode_RD8, dst, ins; rlwinm dst, ins, 19, 13, 28; .endmacro +| +|.macro decode_OP1, dst, ins; rlwinm dst, ins, 0, 24, 31; .endmacro +|.macro decode_RD4, dst, ins; rlwinm dst, ins, 18, 14, 29; .endmacro +| +|// Instruction fetch. +|.macro ins_NEXT1 +| lwz INS, 0(PC) +| addi PC, PC, 4 +|.endmacro +|// Instruction decode+dispatch. Note: optimized for e300! +|.macro ins_NEXT2 +| decode_OPP TMP1, INS +| lpx TMP0, DISPATCH, TMP1 +| mtctr TMP0 +| decode_RB8 RB, INS +| decode_RD8 RD, INS +| decode_RA8 RA, INS +| decode_RC8 RC, INS +| bctr +|.endmacro +|.macro ins_NEXT +| ins_NEXT1 +| ins_NEXT2 +|.endmacro +| +|// Instruction footer. +|.if 1 +| // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. +| .define ins_next, ins_NEXT +| .define ins_next_, ins_NEXT +| .define ins_next1, ins_NEXT1 +| .define ins_next2, ins_NEXT2 +|.else +| // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. +| // Affects only certain kinds of benchmarks (and only with -j off). +| .macro ins_next +| b ->ins_next +| .endmacro +| .macro ins_next1 +| .endmacro +| .macro ins_next2 +| b ->ins_next +| .endmacro +| .macro ins_next_ +| ->ins_next: +| ins_NEXT +| .endmacro +|.endif +| +|// Call decode and dispatch. +|.macro ins_callt +| // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC +| lwz PC, LFUNC:RB->pc +| lwz INS, 0(PC) +| addi PC, PC, 4 +| decode_OPP TMP1, INS +| decode_RA8 RA, INS +| lpx TMP0, DISPATCH, TMP1 +| add RA, RA, BASE +| mtctr TMP0 +| bctr +|.endmacro +| +|.macro ins_call +| // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, PC = caller PC +| stw PC, FRAME_PC(BASE) +| ins_callt +|.endmacro +| +|//----------------------------------------------------------------------- +| +|// Macros to test operand types. +|.macro checknum, reg; cmplw reg, TISNUM; .endmacro +|.macro checknum, cr, reg; cmplw cr, reg, TISNUM; .endmacro +|.macro checkstr, reg; cmpwi reg, LJ_TSTR; .endmacro +|.macro checktab, reg; cmpwi reg, LJ_TTAB; .endmacro +|.macro checkfunc, reg; cmpwi reg, LJ_TFUNC; .endmacro +|.macro checknil, reg; cmpwi reg, LJ_TNIL; .endmacro +| +|.macro branch_RD +| srwi TMP0, RD, 1 +| addis PC, PC, -(BCBIAS_J*4 >> 16) +| add PC, PC, TMP0 +|.endmacro +| +|// Assumes DISPATCH is relative to GL. +#define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) +#define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) +| +#define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) +| +|.macro hotcheck, delta, target +| rlwinm TMP1, PC, 31, 25, 30 +| addi TMP1, TMP1, GG_DISP2HOT +| lhzx TMP2, DISPATCH, TMP1 +| addic. TMP2, TMP2, -delta +| sthx TMP2, DISPATCH, TMP1 +| blt target +|.endmacro +| +|.macro hotloop +| hotcheck HOTCOUNT_LOOP, ->vm_hotloop +|.endmacro +| +|.macro hotcall +| hotcheck HOTCOUNT_CALL, ->vm_hotcall +|.endmacro +| +|// Set current VM state. Uses TMP0. +|.macro li_vmstate, st; li TMP0, ~LJ_VMST_..st; .endmacro +|.macro st_vmstate; stw TMP0, DISPATCH_GL(vmstate)(DISPATCH); .endmacro +| +|// Move table write barrier back. Overwrites mark and tmp. +|.macro barrierback, tab, mark, tmp +| lwz tmp, DISPATCH_GL(gc.grayagain)(DISPATCH) +| // Assumes LJ_GC_BLACK is 0x04. +| rlwinm mark, mark, 0, 30, 28 // black2gray(tab) +| stw tab, DISPATCH_GL(gc.grayagain)(DISPATCH) +| stb mark, tab->marked +| stw tmp, tab->gclist +|.endmacro +| +|//----------------------------------------------------------------------- + +/* Generate subroutines used by opcodes and other parts of the VM. */ +/* The .code_sub section should be last to help static branch prediction. */ +static void build_subroutines(BuildCtx *ctx) +{ + |.code_sub + | + |//----------------------------------------------------------------------- + |//-- Return handling ---------------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_returnp: + | // See vm_return. Also: TMP2 = previous base. + | andix. TMP0, PC, FRAME_P + | li TMP1, LJ_TTRUE + | beq ->cont_dispatch + | + | // Return from pcall or xpcall fast func. + | lwz PC, FRAME_PC(TMP2) // Fetch PC of previous frame. + | mr BASE, TMP2 // Restore caller base. + | // Prepending may overwrite the pcall frame, so do it at the end. + | stwu TMP1, FRAME_PC(RA) // Prepend true to results. + | + |->vm_returnc: + | addi RD, RD, 8 // RD = (nresults+1)*8. + | andix. TMP0, PC, FRAME_TYPE + | cmpwi cr1, RD, 0 + | li CRET1, LUA_YIELD + | beq cr1, ->vm_unwind_c_eh + | mr MULTRES, RD + | beq ->BC_RET_Z // Handle regular return to Lua. + | + |->vm_return: + | // BASE = base, RA = resultptr, RD/MULTRES = (nresults+1)*8, PC = return + | // TMP0 = PC & FRAME_TYPE + | cmpwi TMP0, FRAME_C + | rlwinm TMP2, PC, 0, 0, 28 + | li_vmstate C + | sub TMP2, BASE, TMP2 // TMP2 = previous base. + | bney ->vm_returnp + | + | addic. TMP1, RD, -8 + | stp TMP2, L->base + | lwz TMP2, SAVE_NRES + | subi BASE, BASE, 8 + | st_vmstate + | slwi TMP2, TMP2, 3 + | beq >2 + |1: + | addic. TMP1, TMP1, -8 + | lfd f0, 0(RA) + | addi RA, RA, 8 + | stfd f0, 0(BASE) + | addi BASE, BASE, 8 + | bney <1 + | + |2: + | cmpw TMP2, RD // More/less results wanted? + | bne >6 + |3: + | stp BASE, L->top // Store new top. + | + |->vm_leave_cp: + | lp TMP0, SAVE_CFRAME // Restore previous C frame. + | li CRET1, 0 // Ok return status for vm_pcall. + | stp TMP0, L->cframe + | + |->vm_leave_unw: + | restoreregs + | blr + | + |6: + | ble >7 // Less results wanted? + | // More results wanted. Check stack size and fill up results with nil. + | lwz TMP1, L->maxstack + | cmplw BASE, TMP1 + | bge >8 + | stw TISNIL, 0(BASE) + | addi RD, RD, 8 + | addi BASE, BASE, 8 + | b <2 + | + |7: // Less results wanted. + | subfic TMP3, TMP2, 0 // LUA_MULTRET+1 case? + | sub TMP0, RD, TMP2 + | subfe TMP1, TMP1, TMP1 // TMP1 = TMP2 == 0 ? 0 : -1 + | and TMP0, TMP0, TMP1 + | sub BASE, BASE, TMP0 // Either keep top or shrink it. + | b <3 + | + |8: // Corner case: need to grow stack for filling up results. + | // This can happen if: + | // - A C function grows the stack (a lot). + | // - The GC shrinks the stack in between. + | // - A return back from a lua_call() with (high) nresults adjustment. + | stp BASE, L->top // Save current top held in BASE (yes). + | mr SAVE0, RD + | srwi CARG2, TMP2, 3 + | mr CARG1, L + | bl extern lj_state_growstack // (lua_State *L, int n) + | lwz TMP2, SAVE_NRES + | mr RD, SAVE0 + | slwi TMP2, TMP2, 3 + | lp BASE, L->top // Need the (realloced) L->top in BASE. + | b <2 + | + |->vm_unwind_c: // Unwind C stack, return from vm_pcall. + | // (void *cframe, int errcode) + | mr sp, CARG1 + | mr CRET1, CARG2 + |->vm_unwind_c_eh: // Landing pad for external unwinder. + | lwz L, SAVE_L + | .toc ld TOCREG, SAVE_TOC + | li TMP0, ~LJ_VMST_C + | lwz GL:TMP1, L->glref + | stw TMP0, GL:TMP1->vmstate + | b ->vm_leave_unw + | + |->vm_unwind_ff: // Unwind C stack, return from ff pcall. + | // (void *cframe) + |.if GPR64 + | rldicr sp, CARG1, 0, 61 + |.else + | rlwinm sp, CARG1, 0, 0, 29 + |.endif + |->vm_unwind_ff_eh: // Landing pad for external unwinder. + | lwz L, SAVE_L + | .toc ld TOCREG, SAVE_TOC + | li TISNUM, LJ_TISNUM // Setup type comparison constants. + | lp BASE, L->base + | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | lwz DISPATCH, L->glref // Setup pointer to dispatch table. + | li ZERO, 0 + | stw TMP3, TMPD + | li TMP1, LJ_TFALSE + | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). + | li TISNIL, LJ_TNIL + | li_vmstate INTERP + | lfs TOBIT, TMPD + | lwz PC, FRAME_PC(BASE) // Fetch PC of previous frame. + | la RA, -8(BASE) // Results start at BASE-8. + | stw TMP3, TMPD + | addi DISPATCH, DISPATCH, GG_G2DISP + | stw TMP1, 0(RA) // Prepend false to error message. + | li RD, 16 // 2 results: false + error message. + | st_vmstate + | lfs TONUM, TMPD + | b ->vm_returnc + | + |//----------------------------------------------------------------------- + |//-- Grow stack for calls ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_growstack_c: // Grow stack for C function. + | li CARG2, LUA_MINSTACK + | b >2 + | + |->vm_growstack_l: // Grow stack for Lua function. + | // BASE = new base, RA = BASE+framesize*8, RC = nargs*8, PC = first PC + | add RC, BASE, RC + | sub RA, RA, BASE + | stp BASE, L->base + | addi PC, PC, 4 // Must point after first instruction. + | stp RC, L->top + | srwi CARG2, RA, 3 + |2: + | // L->base = new base, L->top = top + | stw PC, SAVE_PC + | mr CARG1, L + | bl extern lj_state_growstack // (lua_State *L, int n) + | lp BASE, L->base + | lp RC, L->top + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | sub RC, RC, BASE + | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC + | ins_callt // Just retry the call. + | + |//----------------------------------------------------------------------- + |//-- Entry points into the assembler VM --------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_resume: // Setup C frame and resume thread. + | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) + | saveregs + | mr L, CARG1 + | lwz DISPATCH, L->glref // Setup pointer to dispatch table. + | mr BASE, CARG2 + | lbz TMP1, L->status + | stw L, SAVE_L + | li PC, FRAME_CP + | addi TMP0, sp, CFRAME_RESUME + | addi DISPATCH, DISPATCH, GG_G2DISP + | stw CARG3, SAVE_NRES + | cmplwi TMP1, 0 + | stw CARG3, SAVE_ERRF + | stp TMP0, L->cframe + | stp CARG3, SAVE_CFRAME + | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. + | beq >3 + | + | // Resume after yield (like a return). + | mr RA, BASE + | lp BASE, L->base + | li TISNUM, LJ_TISNUM // Setup type comparison constants. + | lp TMP1, L->top + | lwz PC, FRAME_PC(BASE) + | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | stb CARG3, L->status + | stw TMP3, TMPD + | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). + | lfs TOBIT, TMPD + | sub RD, TMP1, BASE + | stw TMP3, TMPD + | lus TMP0, 0x4338 // Hiword of 2^52 + 2^51 (double) + | addi RD, RD, 8 + | stw TMP0, TONUM_HI + | li_vmstate INTERP + | li ZERO, 0 + | st_vmstate + | andix. TMP0, PC, FRAME_TYPE + | mr MULTRES, RD + | lfs TONUM, TMPD + | li TISNIL, LJ_TNIL + | beq ->BC_RET_Z + | b ->vm_return + | + |->vm_pcall: // Setup protected C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) + | saveregs + | li PC, FRAME_CP + | stw CARG4, SAVE_ERRF + | b >1 + | + |->vm_call: // Setup C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1) + | saveregs + | li PC, FRAME_C + | + |1: // Entry point for vm_pcall above (PC = ftype). + | lp TMP1, L:CARG1->cframe + | stw CARG3, SAVE_NRES + | mr L, CARG1 + | stw CARG1, SAVE_L + | mr BASE, CARG2 + | stp sp, L->cframe // Add our C frame to cframe chain. + | lwz DISPATCH, L->glref // Setup pointer to dispatch table. + | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. + | stp TMP1, SAVE_CFRAME + | addi DISPATCH, DISPATCH, GG_G2DISP + | + |3: // Entry point for vm_cpcall/vm_resume (BASE = base, PC = ftype). + | lp TMP2, L->base // TMP2 = old base (used in vmeta_call). + | li TISNUM, LJ_TISNUM // Setup type comparison constants. + | lp TMP1, L->top + | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | add PC, PC, BASE + | stw TMP3, TMPD + | li ZERO, 0 + | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). + | lfs TOBIT, TMPD + | sub PC, PC, TMP2 // PC = frame delta + frame type + | stw TMP3, TMPD + | lus TMP0, 0x4338 // Hiword of 2^52 + 2^51 (double) + | sub NARGS8:RC, TMP1, BASE + | stw TMP0, TONUM_HI + | li_vmstate INTERP + | lfs TONUM, TMPD + | li TISNIL, LJ_TNIL + | st_vmstate + | + |->vm_call_dispatch: + | // TMP2 = old base, BASE = new base, RC = nargs*8, PC = caller PC + | lwz TMP0, FRAME_PC(BASE) + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | checkfunc TMP0; bne ->vmeta_call + | + |->vm_call_dispatch_f: + | ins_call + | // BASE = new base, RB = func, RC = nargs*8, PC = caller PC + | + |->vm_cpcall: // Setup protected C frame, call C. + | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) + | saveregs + | mr L, CARG1 + | lwz TMP0, L:CARG1->stack + | stw CARG1, SAVE_L + | lp TMP1, L->top + | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. + | sub TMP0, TMP0, TMP1 // Compute -savestack(L, L->top). + | lp TMP1, L->cframe + | stp sp, L->cframe // Add our C frame to cframe chain. + | .toc lp CARG4, 0(CARG4) + | li TMP2, 0 + | stw TMP0, SAVE_NRES // Neg. delta means cframe w/o frame. + | stw TMP2, SAVE_ERRF // No error function. + | stp TMP1, SAVE_CFRAME + | mtctr CARG4 + | bctrl // (lua_State *L, lua_CFunction func, void *ud) + |.if PPE + | mr BASE, CRET1 + | cmpwi CRET1, 0 + |.else + | mr. BASE, CRET1 + |.endif + | lwz DISPATCH, L->glref // Setup pointer to dispatch table. + | li PC, FRAME_CP + | addi DISPATCH, DISPATCH, GG_G2DISP + | bne <3 // Else continue with the call. + | b ->vm_leave_cp // No base? Just remove C frame. + | + |//----------------------------------------------------------------------- + |//-- Metamethod handling ------------------------------------------------ + |//----------------------------------------------------------------------- + | + |// The lj_meta_* functions (except for lj_meta_cat) don't reallocate the + |// stack, so BASE doesn't need to be reloaded across these calls. + | + |//-- Continuation dispatch ---------------------------------------------- + | + |->cont_dispatch: + | // BASE = meta base, RA = resultptr, RD = (nresults+1)*8 + | lwz TMP0, -12(BASE) // Continuation. + | mr RB, BASE + | mr BASE, TMP2 // Restore caller BASE. + | lwz LFUNC:TMP1, FRAME_FUNC(TMP2) + |.if FFI + | cmplwi TMP0, 1 + |.endif + | lwz PC, -16(RB) // Restore PC from [cont|PC]. + | subi TMP2, RD, 8 + | lwz TMP1, LFUNC:TMP1->pc + | stwx TISNIL, RA, TMP2 // Ensure one valid arg. + |.if FFI + | ble >1 + |.endif + | lwz KBASE, PC2PROTO(k)(TMP1) + | // BASE = base, RA = resultptr, RB = meta base + | mtctr TMP0 + | bctr // Jump to continuation. + | + |.if FFI + |1: + | beq ->cont_ffi_callback // cont = 1: return from FFI callback. + | // cont = 0: tailcall from C function. + | subi TMP1, RB, 16 + | sub RC, TMP1, BASE + | b ->vm_call_tail + |.endif + | + |->cont_cat: // RA = resultptr, RB = meta base + | lwz INS, -4(PC) + | subi CARG2, RB, 16 + | decode_RB8 SAVE0, INS + | lfd f0, 0(RA) + | add TMP1, BASE, SAVE0 + | stp BASE, L->base + | cmplw TMP1, CARG2 + | sub CARG3, CARG2, TMP1 + | decode_RA8 RA, INS + | stfd f0, 0(CARG2) + | bney ->BC_CAT_Z + | stfdx f0, BASE, RA + | b ->cont_nop + | + |//-- Table indexing metamethods ----------------------------------------- + | + |->vmeta_tgets1: + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | li TMP0, LJ_TSTR + | decode_RB8 RB, INS + | stw STR:RC, 4(CARG3) + | add CARG2, BASE, RB + | stw TMP0, 0(CARG3) + | b >1 + | + |->vmeta_tgets: + | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) + | li TMP0, LJ_TTAB + | stw TAB:RB, 4(CARG2) + | la CARG3, DISPATCH_GL(tmptv2)(DISPATCH) + | stw TMP0, 0(CARG2) + | li TMP1, LJ_TSTR + | stw STR:RC, 4(CARG3) + | stw TMP1, 0(CARG3) + | b >1 + | + |->vmeta_tgetb: // TMP0 = index + |.if not DUALNUM + | tonum_u f0, TMP0 + |.endif + | decode_RB8 RB, INS + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | add CARG2, BASE, RB + |.if DUALNUM + | stw TISNUM, 0(CARG3) + | stw TMP0, 4(CARG3) + |.else + | stfd f0, 0(CARG3) + |.endif + | b >1 + | + |->vmeta_tgetv: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | add CARG2, BASE, RB + | add CARG3, BASE, RC + |1: + | stp BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | bl extern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) + | // Returns TValue * (finished) or NULL (metamethod). + | cmplwi CRET1, 0 + | beq >3 + | lfd f0, 0(CRET1) + | ins_next1 + | stfdx f0, BASE, RA + | ins_next2 + | + |3: // Call __index metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k + | subfic TMP1, BASE, FRAME_CONT + | lp BASE, L->top + | stw PC, -16(BASE) // [cont|PC] + | add PC, TMP1, BASE + | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. + | li NARGS8:RC, 16 // 2 args for func(t, k). + | b ->vm_call_dispatch_f + | + |//----------------------------------------------------------------------- + | + |->vmeta_tsets1: + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | li TMP0, LJ_TSTR + | decode_RB8 RB, INS + | stw STR:RC, 4(CARG3) + | add CARG2, BASE, RB + | stw TMP0, 0(CARG3) + | b >1 + | + |->vmeta_tsets: + | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) + | li TMP0, LJ_TTAB + | stw TAB:RB, 4(CARG2) + | la CARG3, DISPATCH_GL(tmptv2)(DISPATCH) + | stw TMP0, 0(CARG2) + | li TMP1, LJ_TSTR + | stw STR:RC, 4(CARG3) + | stw TMP1, 0(CARG3) + | b >1 + | + |->vmeta_tsetb: // TMP0 = index + |.if not DUALNUM + | tonum_u f0, TMP0 + |.endif + | decode_RB8 RB, INS + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | add CARG2, BASE, RB + |.if DUALNUM + | stw TISNUM, 0(CARG3) + | stw TMP0, 4(CARG3) + |.else + | stfd f0, 0(CARG3) + |.endif + | b >1 + | + |->vmeta_tsetv: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | add CARG2, BASE, RB + | add CARG3, BASE, RC + |1: + | stp BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | bl extern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) + | // Returns TValue * (finished) or NULL (metamethod). + | cmplwi CRET1, 0 + | lfdx f0, BASE, RA + | beq >3 + | // NOBARRIER: lj_meta_tset ensures the table is not black. + | ins_next1 + | stfd f0, 0(CRET1) + | ins_next2 + | + |3: // Call __newindex metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) + | subfic TMP1, BASE, FRAME_CONT + | lp BASE, L->top + | stw PC, -16(BASE) // [cont|PC] + | add PC, TMP1, BASE + | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. + | li NARGS8:RC, 24 // 3 args for func(t, k, v) + | stfd f0, 16(BASE) // Copy value to third argument. + | b ->vm_call_dispatch_f + | + |//-- Comparison metamethods --------------------------------------------- + | + |->vmeta_comp: + | mr CARG1, L + | subi PC, PC, 4 + |.if DUALNUM + | mr CARG2, RA + |.else + | add CARG2, BASE, RA + |.endif + | stw PC, SAVE_PC + |.if DUALNUM + | mr CARG3, RD + |.else + | add CARG3, BASE, RD + |.endif + | stp BASE, L->base + | decode_OP1 CARG4, INS + | bl extern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) + | // Returns 0/1 or TValue * (metamethod). + |3: + | cmplwi CRET1, 1 + | bgt ->vmeta_binop + | subfic CRET1, CRET1, 0 + |4: + | lwz INS, 0(PC) + | addi PC, PC, 4 + | decode_RD4 TMP2, INS + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + | and TMP2, TMP2, CRET1 + | add PC, PC, TMP2 + |->cont_nop: + | ins_next + | + |->cont_ra: // RA = resultptr + | lwz INS, -4(PC) + | lfd f0, 0(RA) + | decode_RA8 TMP1, INS + | stfdx f0, BASE, TMP1 + | b ->cont_nop + | + |->cont_condt: // RA = resultptr + | lwz TMP0, 0(RA) + | .gpr64 extsw TMP0, TMP0 + | subfic TMP0, TMP0, LJ_TTRUE // Branch if result is true. + | subfe CRET1, CRET1, CRET1 + | not CRET1, CRET1 + | b <4 + | + |->cont_condf: // RA = resultptr + | lwz TMP0, 0(RA) + | .gpr64 extsw TMP0, TMP0 + | subfic TMP0, TMP0, LJ_TTRUE // Branch if result is false. + | subfe CRET1, CRET1, CRET1 + | b <4 + | + |->vmeta_equal: + | // CARG2, CARG3, CARG4 are already set by BC_ISEQV/BC_ISNEV. + | subi PC, PC, 4 + | stp BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | bl extern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) + | // Returns 0/1 or TValue * (metamethod). + | b <3 + | + |->vmeta_equal_cd: + |.if FFI + | mr CARG2, INS + | subi PC, PC, 4 + | stp BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | bl extern lj_meta_equal_cd // (lua_State *L, BCIns op) + | // Returns 0/1 or TValue * (metamethod). + | b <3 + |.endif + | + |//-- Arithmetic metamethods --------------------------------------------- + | + |->vmeta_arith_nv: + | add CARG3, KBASE, RC + | add CARG4, BASE, RB + | b >1 + |->vmeta_arith_nv2: + |.if DUALNUM + | mr CARG3, RC + | mr CARG4, RB + | b >1 + |.endif + | + |->vmeta_unm: + | mr CARG3, RD + | mr CARG4, RD + | b >1 + | + |->vmeta_arith_vn: + | add CARG3, BASE, RB + | add CARG4, KBASE, RC + | b >1 + | + |->vmeta_arith_vv: + | add CARG3, BASE, RB + | add CARG4, BASE, RC + |.if DUALNUM + | b >1 + |.endif + |->vmeta_arith_vn2: + |->vmeta_arith_vv2: + |.if DUALNUM + | mr CARG3, RB + | mr CARG4, RC + |.endif + |1: + | add CARG2, BASE, RA + | stp BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | decode_OP1 CARG5, INS // Caveat: CARG5 overlaps INS. + | bl extern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) + | // Returns NULL (finished) or TValue * (metamethod). + | cmplwi CRET1, 0 + | beq ->cont_nop + | + | // Call metamethod for binary op. + |->vmeta_binop: + | // BASE = old base, CRET1 = new base, stack = cont/func/o1/o2 + | sub TMP1, CRET1, BASE + | stw PC, -16(CRET1) // [cont|PC] + | mr TMP2, BASE + | addi PC, TMP1, FRAME_CONT + | mr BASE, CRET1 + | li NARGS8:RC, 16 // 2 args for func(o1, o2). + | b ->vm_call_dispatch + | + |->vmeta_len: +#if LJ_52 + | mr SAVE0, CARG1 +#endif + | mr CARG2, RD + | stp BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | bl extern lj_meta_len // (lua_State *L, TValue *o) + | // Returns NULL (retry) or TValue * (metamethod base). +#if LJ_52 + | cmplwi CRET1, 0 + | bne ->vmeta_binop // Binop call for compatibility. + | mr CARG1, SAVE0 + | b ->BC_LEN_Z +#else + | b ->vmeta_binop // Binop call for compatibility. +#endif + | + |//-- Call metamethod ---------------------------------------------------- + | + |->vmeta_call: // Resolve and call __call metamethod. + | // TMP2 = old base, BASE = new base, RC = nargs*8 + | mr CARG1, L + | stp TMP2, L->base // This is the callers base! + | subi CARG2, BASE, 8 + | stw PC, SAVE_PC + | add CARG3, BASE, RC + | mr SAVE0, NARGS8:RC + | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) + | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. + | addi NARGS8:RC, SAVE0, 8 // Got one more argument now. + | ins_call + | + |->vmeta_callt: // Resolve __call for BC_CALLT. + | // BASE = old base, RA = new base, RC = nargs*8 + | mr CARG1, L + | stp BASE, L->base + | subi CARG2, RA, 8 + | stw PC, SAVE_PC + | add CARG3, RA, RC + | mr SAVE0, NARGS8:RC + | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) + | lwz TMP1, FRAME_PC(BASE) + | addi NARGS8:RC, SAVE0, 8 // Got one more argument now. + | lwz LFUNC:RB, FRAME_FUNC(RA) // Guaranteed to be a function here. + | b ->BC_CALLT_Z + | + |//-- Argument coercion for 'for' statement ------------------------------ + | + |->vmeta_for: + | mr CARG1, L + | stp BASE, L->base + | mr CARG2, RA + | stw PC, SAVE_PC + | mr SAVE0, INS + | bl extern lj_meta_for // (lua_State *L, TValue *base) + |.if JIT + | decode_OP1 TMP0, SAVE0 + |.endif + | decode_RA8 RA, SAVE0 + |.if JIT + | cmpwi TMP0, BC_JFORI + |.endif + | decode_RD8 RD, SAVE0 + |.if JIT + | beqy =>BC_JFORI + |.endif + | b =>BC_FORI + | + |//----------------------------------------------------------------------- + |//-- Fast functions ----------------------------------------------------- + |//----------------------------------------------------------------------- + | + |.macro .ffunc, name + |->ff_ .. name: + |.endmacro + | + |.macro .ffunc_1, name + |->ff_ .. name: + | cmplwi NARGS8:RC, 8 + | lwz CARG3, 0(BASE) + | lwz CARG1, 4(BASE) + | blt ->fff_fallback + |.endmacro + | + |.macro .ffunc_2, name + |->ff_ .. name: + | cmplwi NARGS8:RC, 16 + | lwz CARG3, 0(BASE) + | lwz CARG4, 8(BASE) + | lwz CARG1, 4(BASE) + | lwz CARG2, 12(BASE) + | blt ->fff_fallback + |.endmacro + | + |.macro .ffunc_n, name + |->ff_ .. name: + | cmplwi NARGS8:RC, 8 + | lwz CARG3, 0(BASE) + | lfd FARG1, 0(BASE) + | blt ->fff_fallback + | checknum CARG3; bge ->fff_fallback + |.endmacro + | + |.macro .ffunc_nn, name + |->ff_ .. name: + | cmplwi NARGS8:RC, 16 + | lwz CARG3, 0(BASE) + | lfd FARG1, 0(BASE) + | lwz CARG4, 8(BASE) + | lfd FARG2, 8(BASE) + | blt ->fff_fallback + | checknum CARG3; bge ->fff_fallback + | checknum CARG4; bge ->fff_fallback + |.endmacro + | + |// Inlined GC threshold check. Caveat: uses TMP0 and TMP1. + |.macro ffgccheck + | lwz TMP0, DISPATCH_GL(gc.total)(DISPATCH) + | lwz TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) + | cmplw TMP0, TMP1 + | bgel ->fff_gcstep + |.endmacro + | + |//-- Base library: checks ----------------------------------------------- + | + |.ffunc_1 assert + | li TMP1, LJ_TFALSE + | la RA, -8(BASE) + | cmplw cr1, CARG3, TMP1 + | lwz PC, FRAME_PC(BASE) + | bge cr1, ->fff_fallback + | stw CARG3, 0(RA) + | addi RD, NARGS8:RC, 8 // Compute (nresults+1)*8. + | stw CARG1, 4(RA) + | beq ->fff_res // Done if exactly 1 argument. + | li TMP1, 8 + | subi RC, RC, 8 + |1: + | cmplw TMP1, RC + | lfdx f0, BASE, TMP1 + | stfdx f0, RA, TMP1 + | addi TMP1, TMP1, 8 + | bney <1 + | b ->fff_res + | + |.ffunc type + | cmplwi NARGS8:RC, 8 + | lwz CARG1, 0(BASE) + | blt ->fff_fallback + | .gpr64 extsw CARG1, CARG1 + | subfc TMP0, TISNUM, CARG1 + | subfe TMP2, CARG1, CARG1 + | orc TMP1, TMP2, TMP0 + | addi TMP1, TMP1, ~LJ_TISNUM+1 + | slwi TMP1, TMP1, 3 + | la TMP2, CFUNC:RB->upvalue + | lfdx FARG1, TMP2, TMP1 + | b ->fff_resn + | + |//-- Base library: getters and setters --------------------------------- + | + |.ffunc_1 getmetatable + | checktab CARG3; bne >6 + |1: // Field metatable must be at same offset for GCtab and GCudata! + | lwz TAB:CARG1, TAB:CARG1->metatable + |2: + | li CARG3, LJ_TNIL + | cmplwi TAB:CARG1, 0 + | lwz STR:RC, DISPATCH_GL(gcroot[GCROOT_MMNAME+MM_metatable])(DISPATCH) + | beq ->fff_restv + | lwz TMP0, TAB:CARG1->hmask + | li CARG3, LJ_TTAB // Use metatable as default result. + | lwz TMP1, STR:RC->hash + | lwz NODE:TMP2, TAB:CARG1->node + | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask + | slwi TMP0, TMP1, 5 + | slwi TMP1, TMP1, 3 + | sub TMP1, TMP0, TMP1 + | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) + |3: // Rearranged logic, because we expect _not_ to find the key. + | lwz CARG4, NODE:TMP2->key + | lwz TMP0, 4+offsetof(Node, key)(NODE:TMP2) + | lwz CARG2, NODE:TMP2->val + | lwz TMP1, 4+offsetof(Node, val)(NODE:TMP2) + | checkstr CARG4; bne >4 + | cmpw TMP0, STR:RC; beq >5 + |4: + | lwz NODE:TMP2, NODE:TMP2->next + | cmplwi NODE:TMP2, 0 + | beq ->fff_restv // Not found, keep default result. + | b <3 + |5: + | checknil CARG2 + | beq ->fff_restv // Ditto for nil value. + | mr CARG3, CARG2 // Return value of mt.__metatable. + | mr CARG1, TMP1 + | b ->fff_restv + | + |6: + | cmpwi CARG3, LJ_TUDATA; beq <1 + | .gpr64 extsw CARG3, CARG3 + | subfc TMP0, TISNUM, CARG3 + | subfe TMP2, CARG3, CARG3 + | orc TMP1, TMP2, TMP0 + | addi TMP1, TMP1, ~LJ_TISNUM+1 + | slwi TMP1, TMP1, 2 + | la TMP2, DISPATCH_GL(gcroot[GCROOT_BASEMT])(DISPATCH) + | lwzx TAB:CARG1, TMP2, TMP1 + | b <2 + | + |.ffunc_2 setmetatable + | // Fast path: no mt for table yet and not clearing the mt. + | checktab CARG3; bne ->fff_fallback + | lwz TAB:TMP1, TAB:CARG1->metatable + | checktab CARG4; bne ->fff_fallback + | cmplwi TAB:TMP1, 0 + | lbz TMP3, TAB:CARG1->marked + | bne ->fff_fallback + | andix. TMP0, TMP3, LJ_GC_BLACK // isblack(table) + | stw TAB:CARG2, TAB:CARG1->metatable + | beq ->fff_restv + | barrierback TAB:CARG1, TMP3, TMP0 + | b ->fff_restv + | + |.ffunc rawget + | cmplwi NARGS8:RC, 16 + | lwz CARG4, 0(BASE) + | lwz TAB:CARG2, 4(BASE) + | blt ->fff_fallback + | checktab CARG4; bne ->fff_fallback + | la CARG3, 8(BASE) + | mr CARG1, L + | bl extern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) + | // Returns cTValue *. + | lfd FARG1, 0(CRET1) + | b ->fff_resn + | + |//-- Base library: conversions ------------------------------------------ + | + |.ffunc tonumber + | // Only handles the number case inline (without a base argument). + | cmplwi NARGS8:RC, 8 + | lwz CARG1, 0(BASE) + | lfd FARG1, 0(BASE) + | bne ->fff_fallback // Exactly one argument. + | checknum CARG1; bgt ->fff_fallback + | b ->fff_resn + | + |.ffunc_1 tostring + | // Only handles the string or number case inline. + | checkstr CARG3 + | // A __tostring method in the string base metatable is ignored. + | beq ->fff_restv // String key? + | // Handle numbers inline, unless a number base metatable is present. + | lwz TMP0, DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])(DISPATCH) + | checknum CARG3 + | cmplwi cr1, TMP0, 0 + | stp BASE, L->base // Add frame since C call can throw. + | crorc 4*cr0+eq, 4*cr0+gt, 4*cr1+eq + | stw PC, SAVE_PC // Redundant (but a defined value). + | beq ->fff_fallback + | ffgccheck + | mr CARG1, L + | mr CARG2, BASE + |.if DUALNUM + | bl extern lj_str_fromnumber // (lua_State *L, cTValue *o) + |.else + | bl extern lj_str_fromnum // (lua_State *L, lua_Number *np) + |.endif + | // Returns GCstr *. + | li CARG3, LJ_TSTR + | b ->fff_restv + | + |//-- Base library: iterators ------------------------------------------- + | + |.ffunc next + | cmplwi NARGS8:RC, 8 + | lwz CARG1, 0(BASE) + | lwz TAB:CARG2, 4(BASE) + | blt ->fff_fallback + | stwx TISNIL, BASE, NARGS8:RC // Set missing 2nd arg to nil. + | checktab CARG1 + | lwz PC, FRAME_PC(BASE) + | bne ->fff_fallback + | stp BASE, L->base // Add frame since C call can throw. + | mr CARG1, L + | stp BASE, L->top // Dummy frame length is ok. + | la CARG3, 8(BASE) + | stw PC, SAVE_PC + | bl extern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) + | // Returns 0 at end of traversal. + | cmplwi CRET1, 0 + | li CARG3, LJ_TNIL + | beq ->fff_restv // End of traversal: return nil. + | lfd f0, 8(BASE) // Copy key and value to results. + | la RA, -8(BASE) + | lfd f1, 16(BASE) + | stfd f0, 0(RA) + | li RD, (2+1)*8 + | stfd f1, 8(RA) + | b ->fff_res + | + |.ffunc_1 pairs + | checktab CARG3 + | lwz PC, FRAME_PC(BASE) + | bne ->fff_fallback +#if LJ_52 + | lwz TAB:TMP2, TAB:CARG1->metatable + | lfd f0, CFUNC:RB->upvalue[0] + | cmplwi TAB:TMP2, 0 + | la RA, -8(BASE) + | bne ->fff_fallback +#else + | lfd f0, CFUNC:RB->upvalue[0] + | la RA, -8(BASE) +#endif + | stw TISNIL, 8(BASE) + | li RD, (3+1)*8 + | stfd f0, 0(RA) + | b ->fff_res + | + |.ffunc ipairs_aux + | cmplwi NARGS8:RC, 16 + | lwz CARG3, 0(BASE) + | lwz TAB:CARG1, 4(BASE) + | lwz CARG4, 8(BASE) + |.if DUALNUM + | lwz TMP2, 12(BASE) + |.else + | lfd FARG2, 8(BASE) + |.endif + | blt ->fff_fallback + | checktab CARG3 + | checknum cr1, CARG4 + | lwz PC, FRAME_PC(BASE) + |.if DUALNUM + | bne ->fff_fallback + | bne cr1, ->fff_fallback + |.else + | lus TMP0, 0x3ff0 + | stw ZERO, TMPD_LO + | bne ->fff_fallback + | stw TMP0, TMPD_HI + | bge cr1, ->fff_fallback + | lfd FARG1, TMPD + | toint TMP2, FARG2, f0 + |.endif + | lwz TMP0, TAB:CARG1->asize + | lwz TMP1, TAB:CARG1->array + |.if not DUALNUM + | fadd FARG2, FARG2, FARG1 + |.endif + | addi TMP2, TMP2, 1 + | la RA, -8(BASE) + | cmplw TMP0, TMP2 + |.if DUALNUM + | stw TISNUM, 0(RA) + | slwi TMP3, TMP2, 3 + | stw TMP2, 4(RA) + |.else + | slwi TMP3, TMP2, 3 + | stfd FARG2, 0(RA) + |.endif + | ble >2 // Not in array part? + | lwzx TMP2, TMP1, TMP3 + | lfdx f0, TMP1, TMP3 + |1: + | checknil TMP2 + | li RD, (0+1)*8 + | beq ->fff_res // End of iteration, return 0 results. + | li RD, (2+1)*8 + | stfd f0, 8(RA) + | b ->fff_res + |2: // Check for empty hash part first. Otherwise call C function. + | lwz TMP0, TAB:CARG1->hmask + | cmplwi TMP0, 0 + | li RD, (0+1)*8 + | beq ->fff_res + | mr CARG2, TMP2 + | bl extern lj_tab_getinth // (GCtab *t, int32_t key) + | // Returns cTValue * or NULL. + | cmplwi CRET1, 0 + | li RD, (0+1)*8 + | beq ->fff_res + | lwz TMP2, 0(CRET1) + | lfd f0, 0(CRET1) + | b <1 + | + |.ffunc_1 ipairs + | checktab CARG3 + | lwz PC, FRAME_PC(BASE) + | bne ->fff_fallback +#if LJ_52 + | lwz TAB:TMP2, TAB:CARG1->metatable + | lfd f0, CFUNC:RB->upvalue[0] + | cmplwi TAB:TMP2, 0 + | la RA, -8(BASE) + | bne ->fff_fallback +#else + | lfd f0, CFUNC:RB->upvalue[0] + | la RA, -8(BASE) +#endif + |.if DUALNUM + | stw TISNUM, 8(BASE) + |.else + | stw ZERO, 8(BASE) + |.endif + | stw ZERO, 12(BASE) + | li RD, (3+1)*8 + | stfd f0, 0(RA) + | b ->fff_res + | + |//-- Base library: catch errors ---------------------------------------- + | + |.ffunc pcall + | cmplwi NARGS8:RC, 8 + | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | blt ->fff_fallback + | mr TMP2, BASE + | la BASE, 8(BASE) + | // Remember active hook before pcall. + | rlwinm TMP3, TMP3, 32-HOOK_ACTIVE_SHIFT, 31, 31 + | subi NARGS8:RC, NARGS8:RC, 8 + | addi PC, TMP3, 8+FRAME_PCALL + | b ->vm_call_dispatch + | + |.ffunc xpcall + | cmplwi NARGS8:RC, 16 + | lwz CARG4, 8(BASE) + | lfd FARG2, 8(BASE) + | lfd FARG1, 0(BASE) + | blt ->fff_fallback + | lbz TMP1, DISPATCH_GL(hookmask)(DISPATCH) + | mr TMP2, BASE + | checkfunc CARG4; bne ->fff_fallback // Traceback must be a function. + | la BASE, 16(BASE) + | // Remember active hook before pcall. + | rlwinm TMP1, TMP1, 32-HOOK_ACTIVE_SHIFT, 31, 31 + | stfd FARG2, 0(TMP2) // Swap function and traceback. + | subi NARGS8:RC, NARGS8:RC, 16 + | stfd FARG1, 8(TMP2) + | addi PC, TMP1, 16+FRAME_PCALL + | b ->vm_call_dispatch + | + |//-- Coroutine library -------------------------------------------------- + | + |.macro coroutine_resume_wrap, resume + |.if resume + |.ffunc_1 coroutine_resume + | cmpwi CARG3, LJ_TTHREAD; bne ->fff_fallback + |.else + |.ffunc coroutine_wrap_aux + | lwz L:CARG1, CFUNC:RB->upvalue[0].gcr + |.endif + | lbz TMP0, L:CARG1->status + | lp TMP1, L:CARG1->cframe + | lp CARG2, L:CARG1->top + | cmplwi cr0, TMP0, LUA_YIELD + | lp TMP2, L:CARG1->base + | cmplwi cr1, TMP1, 0 + | lwz TMP0, L:CARG1->maxstack + | cmplw cr7, CARG2, TMP2 + | lwz PC, FRAME_PC(BASE) + | crorc 4*cr6+lt, 4*cr0+gt, 4*cr1+eq // st>LUA_YIELD || cframe!=0 + | add TMP2, CARG2, NARGS8:RC + | crandc 4*cr6+gt, 4*cr7+eq, 4*cr0+eq // base==top && st!=LUA_YIELD + | cmplw cr1, TMP2, TMP0 + | cror 4*cr6+lt, 4*cr6+lt, 4*cr6+gt + | stw PC, SAVE_PC + | cror 4*cr6+lt, 4*cr6+lt, 4*cr1+gt // cond1 || cond2 || stackov + | stp BASE, L->base + | blt cr6, ->fff_fallback + |1: + |.if resume + | addi BASE, BASE, 8 // Keep resumed thread in stack for GC. + | subi NARGS8:RC, NARGS8:RC, 8 + | subi TMP2, TMP2, 8 + |.endif + | stp TMP2, L:CARG1->top + | li TMP1, 0 + | stp BASE, L->top + |2: // Move args to coroutine. + | cmpw TMP1, NARGS8:RC + | lfdx f0, BASE, TMP1 + | beq >3 + | stfdx f0, CARG2, TMP1 + | addi TMP1, TMP1, 8 + | b <2 + |3: + | li CARG3, 0 + | mr L:SAVE0, L:CARG1 + | li CARG4, 0 + | bl ->vm_resume // (lua_State *L, TValue *base, 0, 0) + | // Returns thread status. + |4: + | lp TMP2, L:SAVE0->base + | cmplwi CRET1, LUA_YIELD + | lp TMP3, L:SAVE0->top + | li_vmstate INTERP + | lp BASE, L->base + | st_vmstate + | bgt >8 + | sub RD, TMP3, TMP2 + | lwz TMP0, L->maxstack + | cmplwi RD, 0 + | add TMP1, BASE, RD + | beq >6 // No results? + | cmplw TMP1, TMP0 + | li TMP1, 0 + | bgt >9 // Need to grow stack? + | + | subi TMP3, RD, 8 + | stp TMP2, L:SAVE0->top // Clear coroutine stack. + |5: // Move results from coroutine. + | cmplw TMP1, TMP3 + | lfdx f0, TMP2, TMP1 + | stfdx f0, BASE, TMP1 + | addi TMP1, TMP1, 8 + | bne <5 + |6: + | andix. TMP0, PC, FRAME_TYPE + |.if resume + | li TMP1, LJ_TTRUE + | la RA, -8(BASE) + | stw TMP1, -8(BASE) // Prepend true to results. + | addi RD, RD, 16 + |.else + | mr RA, BASE + | addi RD, RD, 8 + |.endif + |7: + | stw PC, SAVE_PC + | mr MULTRES, RD + | beq ->BC_RET_Z + | b ->vm_return + | + |8: // Coroutine returned with error (at co->top-1). + |.if resume + | andix. TMP0, PC, FRAME_TYPE + | la TMP3, -8(TMP3) + | li TMP1, LJ_TFALSE + | lfd f0, 0(TMP3) + | stp TMP3, L:SAVE0->top // Remove error from coroutine stack. + | li RD, (2+1)*8 + | stw TMP1, -8(BASE) // Prepend false to results. + | la RA, -8(BASE) + | stfd f0, 0(BASE) // Copy error message. + | b <7 + |.else + | mr CARG1, L + | mr CARG2, L:SAVE0 + | bl extern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co) + |.endif + | + |9: // Handle stack expansion on return from yield. + | mr CARG1, L + | srwi CARG2, RD, 3 + | bl extern lj_state_growstack // (lua_State *L, int n) + | li CRET1, 0 + | b <4 + |.endmacro + | + | coroutine_resume_wrap 1 // coroutine.resume + | coroutine_resume_wrap 0 // coroutine.wrap + | + |.ffunc coroutine_yield + | lp TMP0, L->cframe + | add TMP1, BASE, NARGS8:RC + | stp BASE, L->base + | andix. TMP0, TMP0, CFRAME_RESUME + | stp TMP1, L->top + | li CRET1, LUA_YIELD + | beq ->fff_fallback + | stp ZERO, L->cframe + | stb CRET1, L->status + | b ->vm_leave_unw + | + |//-- Math library ------------------------------------------------------- + | + |.ffunc_1 math_abs + | checknum CARG3 + |.if DUALNUM + | bne >2 + | srawi TMP1, CARG1, 31 + | xor TMP2, TMP1, CARG1 + |.if GPR64 + | lus TMP0, 0x8000 + | sub CARG1, TMP2, TMP1 + | cmplw CARG1, TMP0 + | beq >1 + |.else + | sub. CARG1, TMP2, TMP1 + | blt >1 + |.endif + |->fff_resi: + | lwz PC, FRAME_PC(BASE) + | la RA, -8(BASE) + | stw TISNUM, -8(BASE) + | stw CRET1, -4(BASE) + | b ->fff_res1 + |1: + | lus CARG3, 0x41e0 // 2^31. + | li CARG1, 0 + | b ->fff_restv + |2: + |.endif + | bge ->fff_fallback + | rlwinm CARG3, CARG3, 0, 1, 31 + | // Fallthrough. + | + |->fff_restv: + | // CARG3/CARG1 = TValue result. + | lwz PC, FRAME_PC(BASE) + | stw CARG3, -8(BASE) + | la RA, -8(BASE) + | stw CARG1, -4(BASE) + |->fff_res1: + | // RA = results, PC = return. + | li RD, (1+1)*8 + |->fff_res: + | // RA = results, RD = (nresults+1)*8, PC = return. + | andix. TMP0, PC, FRAME_TYPE + | mr MULTRES, RD + | bney ->vm_return + | lwz INS, -4(PC) + | decode_RB8 RB, INS + |5: + | cmplw RB, RD // More results expected? + | decode_RA8 TMP0, INS + | bgt >6 + | ins_next1 + | // Adjust BASE. KBASE is assumed to be set for the calling frame. + | sub BASE, RA, TMP0 + | ins_next2 + | + |6: // Fill up results with nil. + | subi TMP1, RD, 8 + | addi RD, RD, 8 + | stwx TISNIL, RA, TMP1 + | b <5 + | + |.macro math_extern, func + | .ffunc_n math_ .. func + | blex func + | b ->fff_resn + |.endmacro + | + |.macro math_extern2, func + | .ffunc_nn math_ .. func + | blex func + | b ->fff_resn + |.endmacro + | + |.macro math_round, func + | .ffunc_1 math_ .. func + | checknum CARG3; beqy ->fff_restv + | rlwinm TMP2, CARG3, 12, 21, 31 + | bge ->fff_fallback + | addic. TMP2, TMP2, -1023 // exp = exponent(x) - 1023 + | cmplwi cr1, TMP2, 31 // 0 <= exp < 31? + | subfic TMP0, TMP2, 31 + | blt >3 + | slwi TMP1, CARG3, 11 + | srwi TMP3, CARG1, 21 + | oris TMP1, TMP1, 0x8000 + | addi TMP2, TMP2, 1 + | or TMP1, TMP1, TMP3 + | slwi CARG2, CARG1, 11 + | bge cr1, >4 + | slw TMP3, TMP1, TMP2 + | srw RD, TMP1, TMP0 + | or TMP3, TMP3, CARG2 + | srawi TMP2, CARG3, 31 + |.if "func" == "floor" + | and TMP1, TMP3, TMP2 + | addic TMP0, TMP1, -1 + | subfe TMP1, TMP0, TMP1 + | add CARG1, RD, TMP1 + | xor CARG1, CARG1, TMP2 + | sub CARG1, CARG1, TMP2 + | b ->fff_resi + |.else + | andc TMP1, TMP3, TMP2 + | addic TMP0, TMP1, -1 + | subfe TMP1, TMP0, TMP1 + | add CARG1, RD, TMP1 + | cmpw CARG1, RD + | xor CARG1, CARG1, TMP2 + | sub CARG1, CARG1, TMP2 + | bge ->fff_resi + | // Overflow to 2^31. + | lus CARG3, 0x41e0 // 2^31. + | li CARG1, 0 + | b ->fff_restv + |.endif + |3: // |x| < 1 + | slwi TMP2, CARG3, 1 + | srawi TMP1, CARG3, 31 + | or TMP2, CARG1, TMP2 // ztest = (hi+hi) | lo + |.if "func" == "floor" + | and TMP1, TMP2, TMP1 // (ztest & sign) == 0 ? 0 : -1 + | subfic TMP2, TMP1, 0 + | subfe CARG1, CARG1, CARG1 + |.else + | andc TMP1, TMP2, TMP1 // (ztest & ~sign) == 0 ? 0 : 1 + | addic TMP2, TMP1, -1 + | subfe CARG1, TMP2, TMP1 + |.endif + | b ->fff_resi + |4: // exp >= 31. Check for -(2^31). + | xoris TMP1, TMP1, 0x8000 + | srawi TMP2, CARG3, 31 + |.if "func" == "floor" + | or TMP1, TMP1, CARG2 + |.endif + |.if PPE + | orc TMP1, TMP1, TMP2 + | cmpwi TMP1, 0 + |.else + | orc. TMP1, TMP1, TMP2 + |.endif + | crand 4*cr0+eq, 4*cr0+eq, 4*cr1+eq + | lus CARG1, 0x8000 // -(2^31). + | beqy ->fff_resi + |5: + | lfd FARG1, 0(BASE) + | blex func + | b ->fff_resn + |.endmacro + | + |.if DUALNUM + | math_round floor + | math_round ceil + |.else + | // NYI: use internal implementation. + | math_extern floor + | math_extern ceil + |.endif + | + |.if SQRT + |.ffunc_n math_sqrt + | fsqrt FARG1, FARG1 + | b ->fff_resn + |.else + | math_extern sqrt + |.endif + | + |.ffunc math_log + | cmplwi NARGS8:RC, 8 + | lwz CARG3, 0(BASE) + | lfd FARG1, 0(BASE) + | bne ->fff_fallback // Need exactly 1 argument. + | checknum CARG3; bge ->fff_fallback + | blex log + | b ->fff_resn + | + | math_extern log10 + | math_extern exp + | math_extern sin + | math_extern cos + | math_extern tan + | math_extern asin + | math_extern acos + | math_extern atan + | math_extern sinh + | math_extern cosh + | math_extern tanh + | math_extern2 pow + | math_extern2 atan2 + | math_extern2 fmod + | + |->ff_math_deg: + |.ffunc_n math_rad + | lfd FARG2, CFUNC:RB->upvalue[0] + | fmul FARG1, FARG1, FARG2 + | b ->fff_resn + | + |.if DUALNUM + |.ffunc math_ldexp + | cmplwi NARGS8:RC, 16 + | lwz CARG3, 0(BASE) + | lfd FARG1, 0(BASE) + | lwz CARG4, 8(BASE) + |.if GPR64 + | lwz CARG2, 12(BASE) + |.else + | lwz CARG1, 12(BASE) + |.endif + | blt ->fff_fallback + | checknum CARG3; bge ->fff_fallback + | checknum CARG4; bne ->fff_fallback + |.else + |.ffunc_nn math_ldexp + |.if GPR64 + | toint CARG2, FARG2 + |.else + | toint CARG1, FARG2 + |.endif + |.endif + | blex ldexp + | b ->fff_resn + | + |.ffunc_n math_frexp + |.if GPR64 + | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) + |.else + | la CARG1, DISPATCH_GL(tmptv)(DISPATCH) + |.endif + | lwz PC, FRAME_PC(BASE) + | blex frexp + | lwz TMP1, DISPATCH_GL(tmptv)(DISPATCH) + | la RA, -8(BASE) + |.if not DUALNUM + | tonum_i FARG2, TMP1 + |.endif + | stfd FARG1, 0(RA) + | li RD, (2+1)*8 + |.if DUALNUM + | stw TISNUM, 8(RA) + | stw TMP1, 12(RA) + |.else + | stfd FARG2, 8(RA) + |.endif + | b ->fff_res + | + |.ffunc_n math_modf + |.if GPR64 + | la CARG2, -8(BASE) + |.else + | la CARG1, -8(BASE) + |.endif + | lwz PC, FRAME_PC(BASE) + | blex modf + | la RA, -8(BASE) + | stfd FARG1, 0(BASE) + | li RD, (2+1)*8 + | b ->fff_res + | + |.macro math_minmax, name, ismax + |.if DUALNUM + | .ffunc_1 name + | checknum CARG3 + | addi TMP1, BASE, 8 + | add TMP2, BASE, NARGS8:RC + | bne >4 + |1: // Handle integers. + | lwz CARG4, 0(TMP1) + | cmplw cr1, TMP1, TMP2 + | lwz CARG2, 4(TMP1) + | bge cr1, ->fff_resi + | checknum CARG4 + | xoris TMP0, CARG1, 0x8000 + | xoris TMP3, CARG2, 0x8000 + | bne >3 + | subfc TMP3, TMP3, TMP0 + | subfe TMP0, TMP0, TMP0 + |.if ismax + | andc TMP3, TMP3, TMP0 + |.else + | and TMP3, TMP3, TMP0 + |.endif + | add CARG1, TMP3, CARG2 + |.if GPR64 + | rldicl CARG1, CARG1, 0, 32 + |.endif + | addi TMP1, TMP1, 8 + | b <1 + |3: + | bge ->fff_fallback + | // Convert intermediate result to number and continue below. + | tonum_i FARG1, CARG1 + | lfd FARG2, 0(TMP1) + | b >6 + |4: + | lfd FARG1, 0(BASE) + | bge ->fff_fallback + |5: // Handle numbers. + | lwz CARG4, 0(TMP1) + | cmplw cr1, TMP1, TMP2 + | lfd FARG2, 0(TMP1) + | bge cr1, ->fff_resn + | checknum CARG4; bge >7 + |6: + | fsub f0, FARG1, FARG2 + | addi TMP1, TMP1, 8 + |.if ismax + | fsel FARG1, f0, FARG1, FARG2 + |.else + | fsel FARG1, f0, FARG2, FARG1 + |.endif + | b <5 + |7: // Convert integer to number and continue above. + | lwz CARG2, 4(TMP1) + | bne ->fff_fallback + | tonum_i FARG2, CARG2 + | b <6 + |.else + | .ffunc_n name + | li TMP1, 8 + |1: + | lwzx CARG2, BASE, TMP1 + | lfdx FARG2, BASE, TMP1 + | cmplw cr1, TMP1, NARGS8:RC + | checknum CARG2 + | bge cr1, ->fff_resn + | bge ->fff_fallback + | fsub f0, FARG1, FARG2 + | addi TMP1, TMP1, 8 + |.if ismax + | fsel FARG1, f0, FARG1, FARG2 + |.else + | fsel FARG1, f0, FARG2, FARG1 + |.endif + | b <1 + |.endif + |.endmacro + | + | math_minmax math_min, 0 + | math_minmax math_max, 1 + | + |//-- String library ----------------------------------------------------- + | + |.ffunc_1 string_len + | checkstr CARG3; bne ->fff_fallback + | lwz CRET1, STR:CARG1->len + | b ->fff_resi + | + |.ffunc string_byte // Only handle the 1-arg case here. + | cmplwi NARGS8:RC, 8 + | lwz CARG3, 0(BASE) + | lwz STR:CARG1, 4(BASE) + | bne ->fff_fallback // Need exactly 1 argument. + | checkstr CARG3 + | bne ->fff_fallback + | lwz TMP0, STR:CARG1->len + |.if DUALNUM + | lbz CARG1, STR:CARG1[1] // Access is always ok (NUL at end). + | li RD, (0+1)*8 + | lwz PC, FRAME_PC(BASE) + | cmplwi TMP0, 0 + | la RA, -8(BASE) + | beqy ->fff_res + | b ->fff_resi + |.else + | lbz TMP1, STR:CARG1[1] // Access is always ok (NUL at end). + | addic TMP3, TMP0, -1 // RD = ((str->len != 0)+1)*8 + | subfe RD, TMP3, TMP0 + | stw TMP1, TONUM_LO // Inlined tonum_u f0, TMP1. + | addi RD, RD, 1 + | lfd f0, TONUM_D + | la RA, -8(BASE) + | lwz PC, FRAME_PC(BASE) + | fsub f0, f0, TOBIT + | slwi RD, RD, 3 + | stfd f0, 0(RA) + | b ->fff_res + |.endif + | + |.ffunc string_char // Only handle the 1-arg case here. + | ffgccheck + | cmplwi NARGS8:RC, 8 + | lwz CARG3, 0(BASE) + |.if DUALNUM + | lwz TMP0, 4(BASE) + | bne ->fff_fallback // Exactly 1 argument. + | checknum CARG3; bne ->fff_fallback + | la CARG2, 7(BASE) + |.else + | lfd FARG1, 0(BASE) + | bne ->fff_fallback // Exactly 1 argument. + | checknum CARG3; bge ->fff_fallback + | toint TMP0, FARG1 + | la CARG2, TMPD_BLO + |.endif + | li CARG3, 1 + | cmplwi TMP0, 255; bgt ->fff_fallback + |->fff_newstr: + | mr CARG1, L + | stp BASE, L->base + | stw PC, SAVE_PC + | bl extern lj_str_new // (lua_State *L, char *str, size_t l) + | // Returns GCstr *. + | lp BASE, L->base + | li CARG3, LJ_TSTR + | b ->fff_restv + | + |.ffunc string_sub + | ffgccheck + | cmplwi NARGS8:RC, 16 + | lwz CARG3, 16(BASE) + |.if not DUALNUM + | lfd f0, 16(BASE) + |.endif + | lwz TMP0, 0(BASE) + | lwz STR:CARG1, 4(BASE) + | blt ->fff_fallback + | lwz CARG2, 8(BASE) + |.if DUALNUM + | lwz TMP1, 12(BASE) + |.else + | lfd f1, 8(BASE) + |.endif + | li TMP2, -1 + | beq >1 + |.if DUALNUM + | checknum CARG3 + | lwz TMP2, 20(BASE) + | bne ->fff_fallback + |1: + | checknum CARG2; bne ->fff_fallback + |.else + | checknum CARG3; bge ->fff_fallback + | toint TMP2, f0 + |1: + | checknum CARG2; bge ->fff_fallback + |.endif + | checkstr TMP0; bne ->fff_fallback + |.if not DUALNUM + | toint TMP1, f1 + |.endif + | lwz TMP0, STR:CARG1->len + | cmplw TMP0, TMP2 // len < end? (unsigned compare) + | addi TMP3, TMP2, 1 + | blt >5 + |2: + | cmpwi TMP1, 0 // start <= 0? + | add TMP3, TMP1, TMP0 + | ble >7 + |3: + | sub CARG3, TMP2, TMP1 + | addi CARG2, STR:CARG1, #STR-1 + | srawi TMP0, CARG3, 31 + | addi CARG3, CARG3, 1 + | add CARG2, CARG2, TMP1 + | andc CARG3, CARG3, TMP0 + |.if GPR64 + | rldicl CARG2, CARG2, 0, 32 + | rldicl CARG3, CARG3, 0, 32 + |.endif + | b ->fff_newstr + | + |5: // Negative end or overflow. + | cmpw TMP0, TMP2 // len >= end? (signed compare) + | add TMP2, TMP0, TMP3 // Negative end: end = end+len+1. + | bge <2 + | mr TMP2, TMP0 // Overflow: end = len. + | b <2 + | + |7: // Negative start or underflow. + | .gpr64 extsw TMP1, TMP1 + | addic CARG3, TMP1, -1 + | subfe CARG3, CARG3, CARG3 + | srawi CARG2, TMP3, 31 // Note: modifies carry. + | andc TMP3, TMP3, CARG3 + | andc TMP1, TMP3, CARG2 + | addi TMP1, TMP1, 1 // start = 1 + (start ? start+len : 0) + | b <3 + | + |.ffunc string_rep // Only handle the 1-char case inline. + | ffgccheck + | cmplwi NARGS8:RC, 16 + | lwz TMP0, 0(BASE) + | lwz STR:CARG1, 4(BASE) + | lwz CARG4, 8(BASE) + |.if DUALNUM + | lwz CARG3, 12(BASE) + |.else + | lfd FARG2, 8(BASE) + |.endif + | bne ->fff_fallback // Exactly 2 arguments. + | checkstr TMP0; bne ->fff_fallback + |.if DUALNUM + | checknum CARG4; bne ->fff_fallback + |.else + | checknum CARG4; bge ->fff_fallback + | toint CARG3, FARG2 + |.endif + | lwz TMP0, STR:CARG1->len + | cmpwi CARG3, 0 + | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) + | ble >2 // Count <= 0? (or non-int) + | cmplwi TMP0, 1 + | subi TMP2, CARG3, 1 + | blt >2 // Zero length string? + | cmplw cr1, TMP1, CARG3 + | bne ->fff_fallback // Fallback for > 1-char strings. + | lbz TMP0, STR:CARG1[1] + | lp CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) + | blt cr1, ->fff_fallback + |1: // Fill buffer with char. Yes, this is suboptimal code (do you care?). + | cmplwi TMP2, 0 + | stbx TMP0, CARG2, TMP2 + | subi TMP2, TMP2, 1 + | bne <1 + | b ->fff_newstr + |2: // Return empty string. + | la STR:CARG1, DISPATCH_GL(strempty)(DISPATCH) + | li CARG3, LJ_TSTR + | b ->fff_restv + | + |.ffunc string_reverse + | ffgccheck + | cmplwi NARGS8:RC, 8 + | lwz CARG3, 0(BASE) + | lwz STR:CARG1, 4(BASE) + | blt ->fff_fallback + | checkstr CARG3 + | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) + | bne ->fff_fallback + | lwz CARG3, STR:CARG1->len + | la CARG1, #STR(STR:CARG1) + | lp CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) + | li TMP2, 0 + | cmplw TMP1, CARG3 + | subi TMP3, CARG3, 1 + | blt ->fff_fallback + |1: // Reverse string copy. + | cmpwi TMP3, 0 + | lbzx TMP1, CARG1, TMP2 + | blty ->fff_newstr + | stbx TMP1, CARG2, TMP3 + | subi TMP3, TMP3, 1 + | addi TMP2, TMP2, 1 + | b <1 + | + |.macro ffstring_case, name, lo + | .ffunc name + | ffgccheck + | cmplwi NARGS8:RC, 8 + | lwz CARG3, 0(BASE) + | lwz STR:CARG1, 4(BASE) + | blt ->fff_fallback + | checkstr CARG3 + | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) + | bne ->fff_fallback + | lwz CARG3, STR:CARG1->len + | la CARG1, #STR(STR:CARG1) + | lp CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) + | cmplw TMP1, CARG3 + | li TMP2, 0 + | blt ->fff_fallback + |1: // ASCII case conversion. + | cmplw TMP2, CARG3 + | lbzx TMP1, CARG1, TMP2 + | bgey ->fff_newstr + | subi TMP0, TMP1, lo + | xori TMP3, TMP1, 0x20 + | addic TMP0, TMP0, -26 + | subfe TMP3, TMP3, TMP3 + | rlwinm TMP3, TMP3, 0, 26, 26 // x &= 0x20. + | xor TMP1, TMP1, TMP3 + | stbx TMP1, CARG2, TMP2 + | addi TMP2, TMP2, 1 + | b <1 + |.endmacro + | + |ffstring_case string_lower, 65 + |ffstring_case string_upper, 97 + | + |//-- Table library ------------------------------------------------------ + | + |.ffunc_1 table_getn + | checktab CARG3; bne ->fff_fallback + | bl extern lj_tab_len // (GCtab *t) + | // Returns uint32_t (but less than 2^31). + | b ->fff_resi + | + |//-- Bit library -------------------------------------------------------- + | + |.macro .ffunc_bit, name + |.if DUALNUM + | .ffunc_1 bit_..name + | checknum CARG3; bnel ->fff_tobit_fb + |.else + | .ffunc_n bit_..name + | fadd FARG1, FARG1, TOBIT + | stfd FARG1, TMPD + | lwz CARG1, TMPD_LO + |.endif + |.endmacro + | + |.macro .ffunc_bit_op, name, ins + | .ffunc_bit name + | addi TMP1, BASE, 8 + | add TMP2, BASE, NARGS8:RC + |1: + | lwz CARG4, 0(TMP1) + | cmplw cr1, TMP1, TMP2 + |.if DUALNUM + | lwz CARG2, 4(TMP1) + |.else + | lfd FARG1, 0(TMP1) + |.endif + | bgey cr1, ->fff_resi + | checknum CARG4 + |.if DUALNUM + | bnel ->fff_bitop_fb + |.else + | fadd FARG1, FARG1, TOBIT + | bge ->fff_fallback + | stfd FARG1, TMPD + | lwz CARG2, TMPD_LO + |.endif + | ins CARG1, CARG1, CARG2 + | addi TMP1, TMP1, 8 + | b <1 + |.endmacro + | + |.ffunc_bit_op band, and + |.ffunc_bit_op bor, or + |.ffunc_bit_op bxor, xor + | + |.ffunc_bit bswap + | rotlwi TMP0, CARG1, 8 + | rlwimi TMP0, CARG1, 24, 0, 7 + | rlwimi TMP0, CARG1, 24, 16, 23 + | mr CRET1, TMP0 + | b ->fff_resi + | + |.ffunc_bit bnot + | not CRET1, CARG1 + | b ->fff_resi + | + |.macro .ffunc_bit_sh, name, ins, shmod + |.if DUALNUM + | .ffunc_2 bit_..name + | checknum CARG3; bnel ->fff_tobit_fb + | // Note: no inline conversion from number for 2nd argument! + | checknum CARG4; bne ->fff_fallback + |.else + | .ffunc_nn bit_..name + | fadd FARG1, FARG1, TOBIT + | fadd FARG2, FARG2, TOBIT + | stfd FARG1, TMPD + | lwz CARG1, TMPD_LO + | stfd FARG2, TMPD + | lwz CARG2, TMPD_LO + |.endif + |.if shmod == 1 + | rlwinm CARG2, CARG2, 0, 27, 31 + |.elif shmod == 2 + | neg CARG2, CARG2 + |.endif + | ins CRET1, CARG1, CARG2 + | b ->fff_resi + |.endmacro + | + |.ffunc_bit_sh lshift, slw, 1 + |.ffunc_bit_sh rshift, srw, 1 + |.ffunc_bit_sh arshift, sraw, 1 + |.ffunc_bit_sh rol, rotlw, 0 + |.ffunc_bit_sh ror, rotlw, 2 + | + |.ffunc_bit tobit + |.if DUALNUM + | b ->fff_resi + |.else + |->fff_resi: + | tonum_i FARG1, CRET1 + |.endif + |->fff_resn: + | lwz PC, FRAME_PC(BASE) + | la RA, -8(BASE) + | stfd FARG1, -8(BASE) + | b ->fff_res1 + | + |// Fallback FP number to bit conversion. + |->fff_tobit_fb: + |.if DUALNUM + | lfd FARG1, 0(BASE) + | bgt ->fff_fallback + | fadd FARG1, FARG1, TOBIT + | stfd FARG1, TMPD + | lwz CARG1, TMPD_LO + | blr + |.endif + |->fff_bitop_fb: + |.if DUALNUM + | lfd FARG1, 0(TMP1) + | bgt ->fff_fallback + | fadd FARG1, FARG1, TOBIT + | stfd FARG1, TMPD + | lwz CARG2, TMPD_LO + | blr + |.endif + | + |//----------------------------------------------------------------------- + | + |->fff_fallback: // Call fast function fallback handler. + | // BASE = new base, RB = CFUNC, RC = nargs*8 + | lp TMP3, CFUNC:RB->f + | add TMP1, BASE, NARGS8:RC + | lwz PC, FRAME_PC(BASE) // Fallback may overwrite PC. + | addi TMP0, TMP1, 8*LUA_MINSTACK + | lwz TMP2, L->maxstack + | stw PC, SAVE_PC // Redundant (but a defined value). + | .toc lp TMP3, 0(TMP3) + | cmplw TMP0, TMP2 + | stp BASE, L->base + | stp TMP1, L->top + | mr CARG1, L + | bgt >5 // Need to grow stack. + | mtctr TMP3 + | bctrl // (lua_State *L) + | // Either throws an error, or recovers and returns -1, 0 or nresults+1. + | lp BASE, L->base + | cmpwi CRET1, 0 + | slwi RD, CRET1, 3 + | la RA, -8(BASE) + | bgt ->fff_res // Returned nresults+1? + |1: // Returned 0 or -1: retry fast path. + | lp TMP0, L->top + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | sub NARGS8:RC, TMP0, BASE + | bne ->vm_call_tail // Returned -1? + | ins_callt // Returned 0: retry fast path. + | + |// Reconstruct previous base for vmeta_call during tailcall. + |->vm_call_tail: + | andix. TMP0, PC, FRAME_TYPE + | rlwinm TMP1, PC, 0, 0, 28 + | bne >3 + | lwz INS, -4(PC) + | decode_RA8 TMP1, INS + | addi TMP1, TMP1, 8 + |3: + | sub TMP2, BASE, TMP1 + | b ->vm_call_dispatch // Resolve again for tailcall. + | + |5: // Grow stack for fallback handler. + | li CARG2, LUA_MINSTACK + | bl extern lj_state_growstack // (lua_State *L, int n) + | lp BASE, L->base + | cmpw TMP0, TMP0 // Set 4*cr0+eq to force retry. + | b <1 + | + |->fff_gcstep: // Call GC step function. + | // BASE = new base, RC = nargs*8 + | mflr SAVE0 + | stp BASE, L->base + | add TMP0, BASE, NARGS8:RC + | stw PC, SAVE_PC // Redundant (but a defined value). + | stp TMP0, L->top + | mr CARG1, L + | bl extern lj_gc_step // (lua_State *L) + | lp BASE, L->base + | mtlr SAVE0 + | lp TMP0, L->top + | sub NARGS8:RC, TMP0, BASE + | lwz CFUNC:RB, FRAME_FUNC(BASE) + | blr + | + |//----------------------------------------------------------------------- + |//-- Special dispatch targets ------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_record: // Dispatch target for recording phase. + |.if JIT + | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | andix. TMP0, TMP3, HOOK_VMEVENT // No recording while in vmevent. + | bne >5 + | // Decrement the hookcount for consistency, but always do the call. + | lwz TMP2, DISPATCH_GL(hookcount)(DISPATCH) + | andix. TMP0, TMP3, HOOK_ACTIVE + | bne >1 + | subi TMP2, TMP2, 1 + | andi. TMP0, TMP3, LUA_MASKLINE|LUA_MASKCOUNT + | beqy >1 + | stw TMP2, DISPATCH_GL(hookcount)(DISPATCH) + | b >1 + |.endif + | + |->vm_rethook: // Dispatch target for return hooks. + | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | andix. TMP0, TMP3, HOOK_ACTIVE // Hook already active? + | beq >1 + |5: // Re-dispatch to static ins. + | addi TMP1, TMP1, GG_DISP2STATIC // Assumes decode_OPP TMP1, INS. + | lpx TMP0, DISPATCH, TMP1 + | mtctr TMP0 + | bctr + | + |->vm_inshook: // Dispatch target for instr/line hooks. + | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | lwz TMP2, DISPATCH_GL(hookcount)(DISPATCH) + | andix. TMP0, TMP3, HOOK_ACTIVE // Hook already active? + | rlwinm TMP0, TMP3, 31-LUA_HOOKLINE, 31, 0 + | bne <5 + | + | cmpwi cr1, TMP0, 0 + | addic. TMP2, TMP2, -1 + | beq cr1, <5 + | stw TMP2, DISPATCH_GL(hookcount)(DISPATCH) + | beq >1 + | bge cr1, <5 + |1: + | mr CARG1, L + | stw MULTRES, SAVE_MULTRES + | mr CARG2, PC + | stp BASE, L->base + | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. + | bl extern lj_dispatch_ins // (lua_State *L, const BCIns *pc) + |3: + | lp BASE, L->base + |4: // Re-dispatch to static ins. + | lwz INS, -4(PC) + | decode_OPP TMP1, INS + | decode_RB8 RB, INS + | addi TMP1, TMP1, GG_DISP2STATIC + | decode_RD8 RD, INS + | lpx TMP0, DISPATCH, TMP1 + | decode_RA8 RA, INS + | decode_RC8 RC, INS + | mtctr TMP0 + | bctr + | + |->cont_hook: // Continue from hook yield. + | addi PC, PC, 4 + | lwz MULTRES, -20(RB) // Restore MULTRES for *M ins. + | b <4 + | + |->vm_hotloop: // Hot loop counter underflow. + |.if JIT + | lwz LFUNC:TMP1, FRAME_FUNC(BASE) + | addi CARG1, DISPATCH, GG_DISP2J + | stw PC, SAVE_PC + | lwz TMP1, LFUNC:TMP1->pc + | mr CARG2, PC + | stw L, DISPATCH_J(L)(DISPATCH) + | lbz TMP1, PC2PROTO(framesize)(TMP1) + | stp BASE, L->base + | slwi TMP1, TMP1, 3 + | add TMP1, BASE, TMP1 + | stp TMP1, L->top + | bl extern lj_trace_hot // (jit_State *J, const BCIns *pc) + | b <3 + |.endif + | + |->vm_callhook: // Dispatch target for call hooks. + | mr CARG2, PC + |.if JIT + | b >1 + |.endif + | + |->vm_hotcall: // Hot call counter underflow. + |.if JIT + | ori CARG2, PC, 1 + |1: + |.endif + | add TMP0, BASE, RC + | stw PC, SAVE_PC + | mr CARG1, L + | stp BASE, L->base + | sub RA, RA, BASE + | stp TMP0, L->top + | bl extern lj_dispatch_call // (lua_State *L, const BCIns *pc) + | // Returns ASMFunction. + | lp BASE, L->base + | lp TMP0, L->top + | stw ZERO, SAVE_PC // Invalidate for subsequent line hook. + | sub NARGS8:RC, TMP0, BASE + | add RA, BASE, RA + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | lwz INS, -4(PC) + | mtctr CRET1 + | bctr + | + |//----------------------------------------------------------------------- + |//-- Trace exit handler ------------------------------------------------- + |//----------------------------------------------------------------------- + | + |.macro savex_, a, b, c, d + | stfd f..a, 16+a*8(sp) + | stfd f..b, 16+b*8(sp) + | stfd f..c, 16+c*8(sp) + | stfd f..d, 16+d*8(sp) + |.endmacro + | + |->vm_exit_handler: + |.if JIT + | addi sp, sp, -(16+32*8+32*4) + | stmw r2, 16+32*8+2*4(sp) + | addi DISPATCH, JGL, -GG_DISP2G-32768 + | li CARG2, ~LJ_VMST_EXIT + | lwz CARG1, 16+32*8+32*4(sp) // Get stack chain. + | stw CARG2, DISPATCH_GL(vmstate)(DISPATCH) + | savex_ 0,1,2,3 + | stw CARG1, 0(sp) // Store extended stack chain. + | clrso TMP1 + | savex_ 4,5,6,7 + | addi CARG2, sp, 16+32*8+32*4 // Recompute original value of sp. + | savex_ 8,9,10,11 + | stw CARG2, 16+32*8+1*4(sp) // Store sp in RID_SP. + | savex_ 12,13,14,15 + | mflr CARG3 + | li TMP1, 0 + | savex_ 16,17,18,19 + | stw TMP1, 16+32*8+0*4(sp) // Clear RID_TMP. + | savex_ 20,21,22,23 + | lhz CARG4, 2(CARG3) // Load trace number. + | savex_ 24,25,26,27 + | lwz L, DISPATCH_GL(jit_L)(DISPATCH) + | savex_ 28,29,30,31 + | sub CARG3, TMP0, CARG3 // Compute exit number. + | lp BASE, DISPATCH_GL(jit_base)(DISPATCH) + | srwi CARG3, CARG3, 2 + | stw L, DISPATCH_J(L)(DISPATCH) + | subi CARG3, CARG3, 2 + | stw TMP1, DISPATCH_GL(jit_L)(DISPATCH) + | stw CARG4, DISPATCH_J(parent)(DISPATCH) + | stp BASE, L->base + | addi CARG1, DISPATCH, GG_DISP2J + | stw CARG3, DISPATCH_J(exitno)(DISPATCH) + | addi CARG2, sp, 16 + | bl extern lj_trace_exit // (jit_State *J, ExitState *ex) + | // Returns MULTRES (unscaled) or negated error code. + | lp TMP1, L->cframe + | lwz TMP2, 0(sp) + | lp BASE, L->base + |.if GPR64 + | rldicr sp, TMP1, 0, 61 + |.else + | rlwinm sp, TMP1, 0, 0, 29 + |.endif + | lwz PC, SAVE_PC // Get SAVE_PC. + | stw TMP2, 0(sp) + | stw L, SAVE_L // Set SAVE_L (on-trace resume/yield). + | b >1 + |.endif + |->vm_exit_interp: + |.if JIT + | // CARG1 = MULTRES or negated error code, BASE, PC and JGL set. + | lwz L, SAVE_L + | addi DISPATCH, JGL, -GG_DISP2G-32768 + |1: + | cmpwi CARG1, 0 + | blt >3 // Check for error from exit. + | lwz LFUNC:TMP1, FRAME_FUNC(BASE) + | slwi MULTRES, CARG1, 3 + | li TMP2, 0 + | stw MULTRES, SAVE_MULTRES + | lwz TMP1, LFUNC:TMP1->pc + | stw TMP2, DISPATCH_GL(jit_L)(DISPATCH) + | lwz KBASE, PC2PROTO(k)(TMP1) + | // Setup type comparison constants. + | li TISNUM, LJ_TISNUM + | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | stw TMP3, TMPD + | li ZERO, 0 + | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). + | lfs TOBIT, TMPD + | stw TMP3, TMPD + | lus TMP0, 0x4338 // Hiword of 2^52 + 2^51 (double) + | li TISNIL, LJ_TNIL + | stw TMP0, TONUM_HI + | lfs TONUM, TMPD + | // Modified copy of ins_next which handles function header dispatch, too. + | lwz INS, 0(PC) + | addi PC, PC, 4 + | // Assumes TISNIL == ~LJ_VMST_INTERP == -1. + | stw TISNIL, DISPATCH_GL(vmstate)(DISPATCH) + | decode_OPP TMP1, INS + | decode_RA8 RA, INS + | lpx TMP0, DISPATCH, TMP1 + | mtctr TMP0 + | cmplwi TMP1, BC_FUNCF*4 // Function header? + | bge >2 + | decode_RB8 RB, INS + | decode_RD8 RD, INS + | decode_RC8 RC, INS + | bctr + |2: + | subi RC, MULTRES, 8 + | add RA, RA, BASE + | bctr + | + |3: // Rethrow error from the right C frame. + | neg CARG2, CARG1 + | mr CARG1, L + | bl extern lj_err_throw // (lua_State *L, int errcode) + |.endif + | + |//----------------------------------------------------------------------- + |//-- Math helper functions ---------------------------------------------- + |//----------------------------------------------------------------------- + | + |// NYI: Use internal implementations of floor, ceil, trunc. + | + |->vm_modi: + | divwo. TMP0, CARG1, CARG2 + | bso >1 + |.if GPR64 + | xor CARG3, CARG1, CARG2 + | cmpwi CARG3, 0 + |.else + | xor. CARG3, CARG1, CARG2 + |.endif + | mullw TMP0, TMP0, CARG2 + | sub CARG1, CARG1, TMP0 + | bgelr + | cmpwi CARG1, 0; beqlr + | add CARG1, CARG1, CARG2 + | blr + |1: + | cmpwi CARG2, 0 + | li CARG1, 0 + | beqlr + | clrso TMP0 // Clear SO for -2147483648 % -1 and return 0. + | blr + | + |//----------------------------------------------------------------------- + |//-- Miscellaneous functions -------------------------------------------- + |//----------------------------------------------------------------------- + | + |// void lj_vm_cachesync(void *start, void *end) + |// Flush D-Cache and invalidate I-Cache. Assumes 32 byte cache line size. + |// This is a good lower bound, except for very ancient PPC models. + |->vm_cachesync: + |.if JIT or FFI + | // Compute start of first cache line and number of cache lines. + | rlwinm CARG1, CARG1, 0, 0, 26 + | sub CARG2, CARG2, CARG1 + | addi CARG2, CARG2, 31 + | rlwinm. CARG2, CARG2, 27, 5, 31 + | beqlr + | mtctr CARG2 + | mr CARG3, CARG1 + |1: // Flush D-Cache. + | dcbst r0, CARG1 + | addi CARG1, CARG1, 32 + | bdnz <1 + | sync + | mtctr CARG2 + |1: // Invalidate I-Cache. + | icbi r0, CARG3 + | addi CARG3, CARG3, 32 + | bdnz <1 + | isync + | blr + |.endif + | + |//----------------------------------------------------------------------- + |//-- FFI helper functions ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |// Handler for callback functions. Callback slot number in r11, g in r12. + |->vm_ffi_callback: + |.if FFI + |.type CTSTATE, CTState, PC + | saveregs + | lwz CTSTATE, GL:r12->ctype_state + | addi DISPATCH, r12, GG_G2DISP + | stw r11, CTSTATE->cb.slot + | stw r3, CTSTATE->cb.gpr[0] + | stfd f1, CTSTATE->cb.fpr[0] + | stw r4, CTSTATE->cb.gpr[1] + | stfd f2, CTSTATE->cb.fpr[1] + | stw r5, CTSTATE->cb.gpr[2] + | stfd f3, CTSTATE->cb.fpr[2] + | stw r6, CTSTATE->cb.gpr[3] + | stfd f4, CTSTATE->cb.fpr[3] + | stw r7, CTSTATE->cb.gpr[4] + | stfd f5, CTSTATE->cb.fpr[4] + | stw r8, CTSTATE->cb.gpr[5] + | stfd f6, CTSTATE->cb.fpr[5] + | stw r9, CTSTATE->cb.gpr[6] + | stfd f7, CTSTATE->cb.fpr[6] + | stw r10, CTSTATE->cb.gpr[7] + | stfd f8, CTSTATE->cb.fpr[7] + | addi TMP0, sp, CFRAME_SPACE+8 + | stw TMP0, CTSTATE->cb.stack + | mr CARG1, CTSTATE + | stw CTSTATE, SAVE_PC // Any value outside of bytecode is ok. + | mr CARG2, sp + | bl extern lj_ccallback_enter // (CTState *cts, void *cf) + | // Returns lua_State *. + | lp BASE, L:CRET1->base + | li TISNUM, LJ_TISNUM // Setup type comparison constants. + | lp RC, L:CRET1->top + | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). + | li ZERO, 0 + | mr L, CRET1 + | stw TMP3, TMPD + | lus TMP0, 0x4338 // Hiword of 2^52 + 2^51 (double) + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). + | stw TMP0, TONUM_HI + | li TISNIL, LJ_TNIL + | li_vmstate INTERP + | lfs TOBIT, TMPD + | stw TMP3, TMPD + | sub RC, RC, BASE + | st_vmstate + | lfs TONUM, TMPD + | ins_callt + |.endif + | + |->cont_ffi_callback: // Return from FFI callback. + |.if FFI + | lwz CTSTATE, DISPATCH_GL(ctype_state)(DISPATCH) + | stp BASE, L->base + | stp RB, L->top + | stp L, CTSTATE->L + | mr CARG1, CTSTATE + | mr CARG2, RA + | bl extern lj_ccallback_leave // (CTState *cts, TValue *o) + | lwz CRET1, CTSTATE->cb.gpr[0] + | lfd FARG1, CTSTATE->cb.fpr[0] + | lwz CRET2, CTSTATE->cb.gpr[1] + | b ->vm_leave_unw + |.endif + | + |->vm_ffi_call: // Call C function via FFI. + | // Caveat: needs special frame unwinding, see below. + |.if FFI + | .type CCSTATE, CCallState, CARG1 + | lwz TMP1, CCSTATE->spadj + | mflr TMP0 + | lbz CARG2, CCSTATE->nsp + | lbz CARG3, CCSTATE->nfpr + | neg TMP1, TMP1 + | stw TMP0, 4(sp) + | cmpwi cr1, CARG3, 0 + | mr TMP2, sp + | addic. CARG2, CARG2, -1 + | stwux sp, sp, TMP1 + | crnot 4*cr1+eq, 4*cr1+eq // For vararg calls. + | stw r14, -4(TMP2) + | stw CCSTATE, -8(TMP2) + | mr r14, TMP2 + | la TMP1, CCSTATE->stack + | slwi CARG2, CARG2, 2 + | blty >2 + | la TMP2, 8(sp) + |1: + | lwzx TMP0, TMP1, CARG2 + | stwx TMP0, TMP2, CARG2 + | addic. CARG2, CARG2, -4 + | bge <1 + |2: + | bney cr1, >3 + | lfd f1, CCSTATE->fpr[0] + | lfd f2, CCSTATE->fpr[1] + | lfd f3, CCSTATE->fpr[2] + | lfd f4, CCSTATE->fpr[3] + | lfd f5, CCSTATE->fpr[4] + | lfd f6, CCSTATE->fpr[5] + | lfd f7, CCSTATE->fpr[6] + | lfd f8, CCSTATE->fpr[7] + |3: + | lp TMP0, CCSTATE->func + | lwz CARG2, CCSTATE->gpr[1] + | lwz CARG3, CCSTATE->gpr[2] + | lwz CARG4, CCSTATE->gpr[3] + | lwz CARG5, CCSTATE->gpr[4] + | mtctr TMP0 + | lwz r8, CCSTATE->gpr[5] + | lwz r9, CCSTATE->gpr[6] + | lwz r10, CCSTATE->gpr[7] + | lwz CARG1, CCSTATE->gpr[0] // Do this last, since CCSTATE is CARG1. + | bctrl + | lwz CCSTATE:TMP1, -8(r14) + | lwz TMP2, -4(r14) + | lwz TMP0, 4(r14) + | stw CARG1, CCSTATE:TMP1->gpr[0] + | stfd FARG1, CCSTATE:TMP1->fpr[0] + | stw CARG2, CCSTATE:TMP1->gpr[1] + | mtlr TMP0 + | stw CARG3, CCSTATE:TMP1->gpr[2] + | mr sp, r14 + | stw CARG4, CCSTATE:TMP1->gpr[3] + | mr r14, TMP2 + | blr + |.endif + |// Note: vm_ffi_call must be the last function in this object file! + | + |//----------------------------------------------------------------------- +} + +/* Generate the code for a single instruction. */ +static void build_ins(BuildCtx *ctx, BCOp op, int defop) +{ + int vk = 0; + |=>defop: + + switch (op) { + + /* -- Comparison ops ---------------------------------------------------- */ + + /* Remember: all ops branch for a true comparison, fall through otherwise. */ + + case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: + | // RA = src1*8, RD = src2*8, JMP with RD = target + |.if DUALNUM + | lwzux TMP0, RA, BASE + | addi PC, PC, 4 + | lwz CARG2, 4(RA) + | lwzux TMP1, RD, BASE + | lwz TMP2, -4(PC) + | checknum cr0, TMP0 + | lwz CARG3, 4(RD) + | decode_RD4 TMP2, TMP2 + | checknum cr1, TMP1 + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + | bne cr0, >7 + | bne cr1, >8 + | cmpw CARG2, CARG3 + if (op == BC_ISLT) { + | bge >2 + } else if (op == BC_ISGE) { + | blt >2 + } else if (op == BC_ISLE) { + | bgt >2 + } else { + | ble >2 + } + |1: + | add PC, PC, TMP2 + |2: + | ins_next + | + |7: // RA is not an integer. + | bgt cr0, ->vmeta_comp + | // RA is a number. + | lfd f0, 0(RA) + | bgt cr1, ->vmeta_comp + | blt cr1, >4 + | // RA is a number, RD is an integer. + | tonum_i f1, CARG3 + | b >5 + | + |8: // RA is an integer, RD is not an integer. + | bgt cr1, ->vmeta_comp + | // RA is an integer, RD is a number. + | tonum_i f0, CARG2 + |4: + | lfd f1, 0(RD) + |5: + | fcmpu cr0, f0, f1 + if (op == BC_ISLT) { + | bge <2 + } else if (op == BC_ISGE) { + | blt <2 + } else if (op == BC_ISLE) { + | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+eq + | bge <2 + } else { + | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+eq + | blt <2 + } + | b <1 + |.else + | lwzx TMP0, BASE, RA + | addi PC, PC, 4 + | lfdx f0, BASE, RA + | lwzx TMP1, BASE, RD + | checknum cr0, TMP0 + | lwz TMP2, -4(PC) + | lfdx f1, BASE, RD + | checknum cr1, TMP1 + | decode_RD4 TMP2, TMP2 + | bge cr0, ->vmeta_comp + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + | bge cr1, ->vmeta_comp + | fcmpu cr0, f0, f1 + if (op == BC_ISLT) { + | bge >1 + } else if (op == BC_ISGE) { + | blt >1 + } else if (op == BC_ISLE) { + | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+eq + | bge >1 + } else { + | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+eq + | blt >1 + } + | add PC, PC, TMP2 + |1: + | ins_next + |.endif + break; + + case BC_ISEQV: case BC_ISNEV: + vk = op == BC_ISEQV; + | // RA = src1*8, RD = src2*8, JMP with RD = target + |.if DUALNUM + | lwzux TMP0, RA, BASE + | addi PC, PC, 4 + | lwz CARG2, 4(RA) + | lwzux TMP1, RD, BASE + | checknum cr0, TMP0 + | lwz TMP2, -4(PC) + | checknum cr1, TMP1 + | decode_RD4 TMP2, TMP2 + | lwz CARG3, 4(RD) + | cror 4*cr7+gt, 4*cr0+gt, 4*cr1+gt + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + if (vk) { + | ble cr7, ->BC_ISEQN_Z + } else { + | ble cr7, ->BC_ISNEN_Z + } + |.else + | lwzux TMP0, RA, BASE + | lwz TMP2, 0(PC) + | lfd f0, 0(RA) + | addi PC, PC, 4 + | lwzux TMP1, RD, BASE + | checknum cr0, TMP0 + | decode_RD4 TMP2, TMP2 + | lfd f1, 0(RD) + | checknum cr1, TMP1 + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + | bge cr0, >5 + | bge cr1, >5 + | fcmpu cr0, f0, f1 + if (vk) { + | bne >1 + | add PC, PC, TMP2 + } else { + | beq >1 + | add PC, PC, TMP2 + } + |1: + | ins_next + |.endif + |5: // Either or both types are not numbers. + |.if not DUALNUM + | lwz CARG2, 4(RA) + | lwz CARG3, 4(RD) + |.endif + |.if FFI + | cmpwi cr7, TMP0, LJ_TCDATA + | cmpwi cr5, TMP1, LJ_TCDATA + |.endif + | not TMP3, TMP0 + | cmplw TMP0, TMP1 + | cmplwi cr1, TMP3, ~LJ_TISPRI // Primitive? + |.if FFI + | cror 4*cr7+eq, 4*cr7+eq, 4*cr5+eq + |.endif + | cmplwi cr6, TMP3, ~LJ_TISTABUD // Table or userdata? + |.if FFI + | beq cr7, ->vmeta_equal_cd + |.endif + | cmplw cr5, CARG2, CARG3 + | crandc 4*cr0+gt, 4*cr0+eq, 4*cr1+gt // 2: Same type and primitive. + | crorc 4*cr0+lt, 4*cr5+eq, 4*cr0+eq // 1: Same tv or different type. + | crand 4*cr0+eq, 4*cr0+eq, 4*cr5+eq // 0: Same type and same tv. + | mr SAVE0, PC + | cror 4*cr0+eq, 4*cr0+eq, 4*cr0+gt // 0 or 2. + | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+gt // 1 or 2. + if (vk) { + | bne cr0, >6 + | add PC, PC, TMP2 + |6: + } else { + | beq cr0, >6 + | add PC, PC, TMP2 + |6: + } + |.if DUALNUM + | bge cr0, >2 // Done if 1 or 2. + |1: + | ins_next + |2: + |.else + | blt cr0, <1 // Done if 1 or 2. + |.endif + | blt cr6, <1 // Done if not tab/ud. + | + | // Different tables or userdatas. Need to check __eq metamethod. + | // Field metatable must be at same offset for GCtab and GCudata! + | lwz TAB:TMP2, TAB:CARG2->metatable + | li CARG4, 1-vk // ne = 0 or 1. + | cmplwi TAB:TMP2, 0 + | beq <1 // No metatable? + | lbz TMP2, TAB:TMP2->nomm + | andix. TMP2, TMP2, 1<vmeta_equal // Handle __eq metamethod. + break; + + case BC_ISEQS: case BC_ISNES: + vk = op == BC_ISEQS; + | // RA = src*8, RD = str_const*8 (~), JMP with RD = target + | lwzux TMP0, RA, BASE + | srwi RD, RD, 1 + | lwz STR:TMP3, 4(RA) + | lwz TMP2, 0(PC) + | subfic RD, RD, -4 + | addi PC, PC, 4 + |.if FFI + | cmpwi TMP0, LJ_TCDATA + |.endif + | lwzx STR:TMP1, KBASE, RD // KBASE-4-str_const*4 + | .gpr64 extsw TMP0, TMP0 + | subfic TMP0, TMP0, LJ_TSTR + |.if FFI + | beq ->vmeta_equal_cd + |.endif + | sub TMP1, STR:TMP1, STR:TMP3 + | or TMP0, TMP0, TMP1 + | decode_RD4 TMP2, TMP2 + | subfic TMP0, TMP0, 0 + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + | subfe TMP1, TMP1, TMP1 + if (vk) { + | andc TMP2, TMP2, TMP1 + } else { + | and TMP2, TMP2, TMP1 + } + | add PC, PC, TMP2 + | ins_next + break; + + case BC_ISEQN: case BC_ISNEN: + vk = op == BC_ISEQN; + | // RA = src*8, RD = num_const*8, JMP with RD = target + |.if DUALNUM + | lwzux TMP0, RA, BASE + | addi PC, PC, 4 + | lwz CARG2, 4(RA) + | lwzux TMP1, RD, KBASE + | checknum cr0, TMP0 + | lwz TMP2, -4(PC) + | checknum cr1, TMP1 + | decode_RD4 TMP2, TMP2 + | lwz CARG3, 4(RD) + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + if (vk) { + |->BC_ISEQN_Z: + } else { + |->BC_ISNEN_Z: + } + | bne cr0, >7 + | bne cr1, >8 + | cmpw CARG2, CARG3 + |4: + |.else + if (vk) { + |->BC_ISEQN_Z: // Dummy label. + } else { + |->BC_ISNEN_Z: // Dummy label. + } + | lwzx TMP0, BASE, RA + | addi PC, PC, 4 + | lfdx f0, BASE, RA + | lwz TMP2, -4(PC) + | lfdx f1, KBASE, RD + | decode_RD4 TMP2, TMP2 + | checknum TMP0 + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + | bge >3 + | fcmpu cr0, f0, f1 + |.endif + if (vk) { + | bne >1 + | add PC, PC, TMP2 + |1: + |.if not FFI + |3: + |.endif + } else { + | beq >2 + |1: + |.if not FFI + |3: + |.endif + | add PC, PC, TMP2 + |2: + } + | ins_next + |.if FFI + |3: + | cmpwi TMP0, LJ_TCDATA + | beq ->vmeta_equal_cd + | b <1 + |.endif + |.if DUALNUM + |7: // RA is not an integer. + | bge cr0, <3 + | // RA is a number. + | lfd f0, 0(RA) + | blt cr1, >1 + | // RA is a number, RD is an integer. + | tonum_i f1, CARG3 + | b >2 + | + |8: // RA is an integer, RD is a number. + | tonum_i f0, CARG2 + |1: + | lfd f1, 0(RD) + |2: + | fcmpu cr0, f0, f1 + | b <4 + |.endif + break; + + case BC_ISEQP: case BC_ISNEP: + vk = op == BC_ISEQP; + | // RA = src*8, RD = primitive_type*8 (~), JMP with RD = target + | lwzx TMP0, BASE, RA + | srwi TMP1, RD, 3 + | lwz TMP2, 0(PC) + | not TMP1, TMP1 + | addi PC, PC, 4 + |.if FFI + | cmpwi TMP0, LJ_TCDATA + |.endif + | sub TMP0, TMP0, TMP1 + |.if FFI + | beq ->vmeta_equal_cd + |.endif + | decode_RD4 TMP2, TMP2 + | .gpr64 extsw TMP0, TMP0 + | addic TMP0, TMP0, -1 + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + | subfe TMP1, TMP1, TMP1 + if (vk) { + | and TMP2, TMP2, TMP1 + } else { + | andc TMP2, TMP2, TMP1 + } + | add PC, PC, TMP2 + | ins_next + break; + + /* -- Unary test and copy ops ------------------------------------------- */ + + case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: + | // RA = dst*8 or unused, RD = src*8, JMP with RD = target + | lwzx TMP0, BASE, RD + | lwz INS, 0(PC) + | addi PC, PC, 4 + if (op == BC_IST || op == BC_ISF) { + | .gpr64 extsw TMP0, TMP0 + | subfic TMP0, TMP0, LJ_TTRUE + | decode_RD4 TMP2, INS + | subfe TMP1, TMP1, TMP1 + | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) + if (op == BC_IST) { + | andc TMP2, TMP2, TMP1 + } else { + | and TMP2, TMP2, TMP1 + } + | add PC, PC, TMP2 + } else { + | li TMP1, LJ_TFALSE + | lfdx f0, BASE, RD + | cmplw TMP0, TMP1 + if (op == BC_ISTC) { + | bge >1 + } else { + | blt >1 + } + | addis PC, PC, -(BCBIAS_J*4 >> 16) + | decode_RD4 TMP2, INS + | stfdx f0, BASE, RA + | add PC, PC, TMP2 + |1: + } + | ins_next + break; + + /* -- Unary ops --------------------------------------------------------- */ + + case BC_MOV: + | // RA = dst*8, RD = src*8 + | ins_next1 + | lfdx f0, BASE, RD + | stfdx f0, BASE, RA + | ins_next2 + break; + case BC_NOT: + | // RA = dst*8, RD = src*8 + | ins_next1 + | lwzx TMP0, BASE, RD + | .gpr64 extsw TMP0, TMP0 + | subfic TMP1, TMP0, LJ_TTRUE + | adde TMP0, TMP0, TMP1 + | stwx TMP0, BASE, RA + | ins_next2 + break; + case BC_UNM: + | // RA = dst*8, RD = src*8 + | lwzux TMP1, RD, BASE + | lwz TMP0, 4(RD) + | checknum TMP1 + |.if DUALNUM + | bne >5 + |.if GPR64 + | lus TMP2, 0x8000 + | neg TMP0, TMP0 + | cmplw TMP0, TMP2 + | beq >4 + |.else + | nego. TMP0, TMP0 + | bso >4 + |1: + |.endif + | ins_next1 + | stwux TISNUM, RA, BASE + | stw TMP0, 4(RA) + |3: + | ins_next2 + |4: + |.if not GPR64 + | // Potential overflow. + | checkov TMP1, <1 // Ignore unrelated overflow. + |.endif + | lus TMP1, 0x41e0 // 2^31. + | li TMP0, 0 + | b >7 + |.endif + |5: + | bge ->vmeta_unm + | xoris TMP1, TMP1, 0x8000 + |7: + | ins_next1 + | stwux TMP1, RA, BASE + | stw TMP0, 4(RA) + |.if DUALNUM + | b <3 + |.else + | ins_next2 + |.endif + break; + case BC_LEN: + | // RA = dst*8, RD = src*8 + | lwzux TMP0, RD, BASE + | lwz CARG1, 4(RD) + | checkstr TMP0; bne >2 + | lwz CRET1, STR:CARG1->len + |1: + |.if DUALNUM + | ins_next1 + | stwux TISNUM, RA, BASE + | stw CRET1, 4(RA) + |.else + | tonum_u f0, CRET1 // Result is a non-negative integer. + | ins_next1 + | stfdx f0, BASE, RA + |.endif + | ins_next2 + |2: + | checktab TMP0; bne ->vmeta_len +#if LJ_52 + | lwz TAB:TMP2, TAB:CARG1->metatable + | cmplwi TAB:TMP2, 0 + | bne >9 + |3: +#endif + |->BC_LEN_Z: + | bl extern lj_tab_len // (GCtab *t) + | // Returns uint32_t (but less than 2^31). + | b <1 +#if LJ_52 + |9: + | lbz TMP0, TAB:TMP2->nomm + | andix. TMP0, TMP0, 1<vmeta_len +#endif + break; + + /* -- Binary ops -------------------------------------------------------- */ + + |.macro ins_arithpre + | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 + ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); + ||switch (vk) { + ||case 0: + | lwzx TMP1, BASE, RB + | .if DUALNUM + | lwzx TMP2, KBASE, RC + | .endif + | lfdx f14, BASE, RB + | lfdx f15, KBASE, RC + | .if DUALNUM + | checknum cr0, TMP1 + | checknum cr1, TMP2 + | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt + | bge ->vmeta_arith_vn + | .else + | checknum TMP1; bge ->vmeta_arith_vn + | .endif + || break; + ||case 1: + | lwzx TMP1, BASE, RB + | .if DUALNUM + | lwzx TMP2, KBASE, RC + | .endif + | lfdx f15, BASE, RB + | lfdx f14, KBASE, RC + | .if DUALNUM + | checknum cr0, TMP1 + | checknum cr1, TMP2 + | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt + | bge ->vmeta_arith_nv + | .else + | checknum TMP1; bge ->vmeta_arith_nv + | .endif + || break; + ||default: + | lwzx TMP1, BASE, RB + | lwzx TMP2, BASE, RC + | lfdx f14, BASE, RB + | lfdx f15, BASE, RC + | checknum cr0, TMP1 + | checknum cr1, TMP2 + | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt + | bge ->vmeta_arith_vv + || break; + ||} + |.endmacro + | + |.macro ins_arithfallback, ins + ||switch (vk) { + ||case 0: + | ins ->vmeta_arith_vn2 + || break; + ||case 1: + | ins ->vmeta_arith_nv2 + || break; + ||default: + | ins ->vmeta_arith_vv2 + || break; + ||} + |.endmacro + | + |.macro intmod, a, b, c + | bl ->vm_modi + |.endmacro + | + |.macro fpmod, a, b, c + |->BC_MODVN_Z: + | fdiv FARG1, b, c + | // NYI: Use internal implementation of floor. + | blex floor // floor(b/c) + | fmul a, FARG1, c + | fsub a, b, a // b - floor(b/c)*c + |.endmacro + | + |.macro ins_arithfp, fpins + | ins_arithpre + |.if "fpins" == "fpmod_" + | b ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. + |.else + | fpins f0, f14, f15 + | ins_next1 + | stfdx f0, BASE, RA + | ins_next2 + |.endif + |.endmacro + | + |.macro ins_arithdn, intins, fpins + | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 + ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); + ||switch (vk) { + ||case 0: + | lwzux TMP1, RB, BASE + | lwzux TMP2, RC, KBASE + | lwz CARG1, 4(RB) + | checknum cr0, TMP1 + | lwz CARG2, 4(RC) + || break; + ||case 1: + | lwzux TMP1, RB, BASE + | lwzux TMP2, RC, KBASE + | lwz CARG2, 4(RB) + | checknum cr0, TMP1 + | lwz CARG1, 4(RC) + || break; + ||default: + | lwzux TMP1, RB, BASE + | lwzux TMP2, RC, BASE + | lwz CARG1, 4(RB) + | checknum cr0, TMP1 + | lwz CARG2, 4(RC) + || break; + ||} + | checknum cr1, TMP2 + | bne >5 + | bne cr1, >5 + | intins CARG1, CARG1, CARG2 + | bso >4 + |1: + | ins_next1 + | stwux TISNUM, RA, BASE + | stw CARG1, 4(RA) + |2: + | ins_next2 + |4: // Overflow. + | checkov TMP0, <1 // Ignore unrelated overflow. + | ins_arithfallback b + |5: // FP variant. + ||if (vk == 1) { + | lfd f15, 0(RB) + | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt + | lfd f14, 0(RC) + ||} else { + | lfd f14, 0(RB) + | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt + | lfd f15, 0(RC) + ||} + | ins_arithfallback bge + |.if "fpins" == "fpmod_" + | b ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. + |.else + | fpins f0, f14, f15 + | ins_next1 + | stfdx f0, BASE, RA + | b <2 + |.endif + |.endmacro + | + |.macro ins_arith, intins, fpins + |.if DUALNUM + | ins_arithdn intins, fpins + |.else + | ins_arithfp fpins + |.endif + |.endmacro + + case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: + |.if GPR64 + |.macro addo32., y, a, b + | // Need to check overflow for (a<<32) + (b<<32). + | rldicr TMP0, a, 32, 31 + | rldicr TMP3, b, 32, 31 + | addo. TMP0, TMP0, TMP3 + | add y, a, b + |.endmacro + | ins_arith addo32., fadd + |.else + | ins_arith addo., fadd + |.endif + break; + case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: + |.if GPR64 + |.macro subo32., y, a, b + | // Need to check overflow for (a<<32) - (b<<32). + | rldicr TMP0, a, 32, 31 + | rldicr TMP3, b, 32, 31 + | subo. TMP0, TMP0, TMP3 + | sub y, a, b + |.endmacro + | ins_arith subo32., fsub + |.else + | ins_arith subo., fsub + |.endif + break; + case BC_MULVN: case BC_MULNV: case BC_MULVV: + | ins_arith mullwo., fmul + break; + case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: + | ins_arithfp fdiv + break; + case BC_MODVN: + | ins_arith intmod, fpmod + break; + case BC_MODNV: case BC_MODVV: + | ins_arith intmod, fpmod_ + break; + case BC_POW: + | // NYI: (partial) integer arithmetic. + | lwzx TMP1, BASE, RB + | lfdx FARG1, BASE, RB + | lwzx TMP2, BASE, RC + | lfdx FARG2, BASE, RC + | checknum cr0, TMP1 + | checknum cr1, TMP2 + | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt + | bge ->vmeta_arith_vv + | blex pow + | ins_next1 + | stfdx FARG1, BASE, RA + | ins_next2 + break; + + case BC_CAT: + | // RA = dst*8, RB = src_start*8, RC = src_end*8 + | sub CARG3, RC, RB + | stp BASE, L->base + | add CARG2, BASE, RC + | mr SAVE0, RB + |->BC_CAT_Z: + | stw PC, SAVE_PC + | mr CARG1, L + | srwi CARG3, CARG3, 3 + | bl extern lj_meta_cat // (lua_State *L, TValue *top, int left) + | // Returns NULL (finished) or TValue * (metamethod). + | cmplwi CRET1, 0 + | lp BASE, L->base + | bne ->vmeta_binop + | ins_next1 + | lfdx f0, BASE, SAVE0 // Copy result from RB to RA. + | stfdx f0, BASE, RA + | ins_next2 + break; + + /* -- Constant ops ------------------------------------------------------ */ + + case BC_KSTR: + | // RA = dst*8, RD = str_const*8 (~) + | srwi TMP1, RD, 1 + | subfic TMP1, TMP1, -4 + | ins_next1 + | lwzx TMP0, KBASE, TMP1 // KBASE-4-str_const*4 + | li TMP2, LJ_TSTR + | stwux TMP2, RA, BASE + | stw TMP0, 4(RA) + | ins_next2 + break; + case BC_KCDATA: + |.if FFI + | // RA = dst*8, RD = cdata_const*8 (~) + | srwi TMP1, RD, 1 + | subfic TMP1, TMP1, -4 + | ins_next1 + | lwzx TMP0, KBASE, TMP1 // KBASE-4-cdata_const*4 + | li TMP2, LJ_TCDATA + | stwux TMP2, RA, BASE + | stw TMP0, 4(RA) + | ins_next2 + |.endif + break; + case BC_KSHORT: + | // RA = dst*8, RD = int16_literal*8 + |.if DUALNUM + | slwi RD, RD, 13 + | srawi RD, RD, 16 + | ins_next1 + | stwux TISNUM, RA, BASE + | stw RD, 4(RA) + | ins_next2 + |.else + | // The soft-float approach is faster. + | slwi RD, RD, 13 + | srawi TMP1, RD, 31 + | xor TMP2, TMP1, RD + | sub TMP2, TMP2, TMP1 // TMP2 = abs(x) + | cntlzw TMP3, TMP2 + | subfic TMP1, TMP3, 0x40d // TMP1 = exponent-1 + | slw TMP2, TMP2, TMP3 // TMP2 = left aligned mantissa + | subfic TMP3, RD, 0 + | slwi TMP1, TMP1, 20 + | rlwimi RD, TMP2, 21, 1, 31 // hi = sign(x) | (mantissa>>11) + | subfe TMP0, TMP0, TMP0 + | add RD, RD, TMP1 // hi = hi + exponent-1 + | and RD, RD, TMP0 // hi = x == 0 ? 0 : hi + | ins_next1 + | stwux RD, RA, BASE + | stw ZERO, 4(RA) + | ins_next2 + |.endif + break; + case BC_KNUM: + | // RA = dst*8, RD = num_const*8 + | ins_next1 + | lfdx f0, KBASE, RD + | stfdx f0, BASE, RA + | ins_next2 + break; + case BC_KPRI: + | // RA = dst*8, RD = primitive_type*8 (~) + | srwi TMP1, RD, 3 + | not TMP0, TMP1 + | ins_next1 + | stwx TMP0, BASE, RA + | ins_next2 + break; + case BC_KNIL: + | // RA = base*8, RD = end*8 + | stwx TISNIL, BASE, RA + | addi RA, RA, 8 + |1: + | stwx TISNIL, BASE, RA + | cmpw RA, RD + | addi RA, RA, 8 + | blt <1 + | ins_next_ + break; + + /* -- Upvalue and function ops ------------------------------------------ */ + + case BC_UGET: + | // RA = dst*8, RD = uvnum*8 + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi RD, RD, 1 + | addi RD, RD, offsetof(GCfuncL, uvptr) + | lwzx UPVAL:RB, LFUNC:RB, RD + | ins_next1 + | lwz TMP1, UPVAL:RB->v + | lfd f0, 0(TMP1) + | stfdx f0, BASE, RA + | ins_next2 + break; + case BC_USETV: + | // RA = uvnum*8, RD = src*8 + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi RA, RA, 1 + | addi RA, RA, offsetof(GCfuncL, uvptr) + | lfdux f0, RD, BASE + | lwzx UPVAL:RB, LFUNC:RB, RA + | lbz TMP3, UPVAL:RB->marked + | lwz CARG2, UPVAL:RB->v + | andix. TMP3, TMP3, LJ_GC_BLACK // isblack(uv) + | lbz TMP0, UPVAL:RB->closed + | lwz TMP2, 0(RD) + | stfd f0, 0(CARG2) + | cmplwi cr1, TMP0, 0 + | lwz TMP1, 4(RD) + | cror 4*cr0+eq, 4*cr0+eq, 4*cr1+eq + | subi TMP2, TMP2, (LJ_TNUMX+1) + | bne >2 // Upvalue is closed and black? + |1: + | ins_next + | + |2: // Check if new value is collectable. + | cmplwi TMP2, LJ_TISGCV - (LJ_TNUMX+1) + | bge <1 // tvisgcv(v) + | lbz TMP3, GCOBJ:TMP1->gch.marked + | andix. TMP3, TMP3, LJ_GC_WHITES // iswhite(v) + | la CARG1, GG_DISP2G(DISPATCH) + | // Crossed a write barrier. Move the barrier forward. + | beq <1 + | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) + | b <1 + break; + case BC_USETS: + | // RA = uvnum*8, RD = str_const*8 (~) + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi TMP1, RD, 1 + | srwi RA, RA, 1 + | subfic TMP1, TMP1, -4 + | addi RA, RA, offsetof(GCfuncL, uvptr) + | lwzx STR:TMP1, KBASE, TMP1 // KBASE-4-str_const*4 + | lwzx UPVAL:RB, LFUNC:RB, RA + | lbz TMP3, UPVAL:RB->marked + | lwz CARG2, UPVAL:RB->v + | andix. TMP3, TMP3, LJ_GC_BLACK // isblack(uv) + | lbz TMP3, STR:TMP1->marked + | lbz TMP2, UPVAL:RB->closed + | li TMP0, LJ_TSTR + | stw STR:TMP1, 4(CARG2) + | stw TMP0, 0(CARG2) + | bne >2 + |1: + | ins_next + | + |2: // Check if string is white and ensure upvalue is closed. + | andix. TMP3, TMP3, LJ_GC_WHITES // iswhite(str) + | cmplwi cr1, TMP2, 0 + | cror 4*cr0+eq, 4*cr0+eq, 4*cr1+eq + | la CARG1, GG_DISP2G(DISPATCH) + | // Crossed a write barrier. Move the barrier forward. + | beq <1 + | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) + | b <1 + break; + case BC_USETN: + | // RA = uvnum*8, RD = num_const*8 + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi RA, RA, 1 + | addi RA, RA, offsetof(GCfuncL, uvptr) + | lfdx f0, KBASE, RD + | lwzx UPVAL:RB, LFUNC:RB, RA + | ins_next1 + | lwz TMP1, UPVAL:RB->v + | stfd f0, 0(TMP1) + | ins_next2 + break; + case BC_USETP: + | // RA = uvnum*8, RD = primitive_type*8 (~) + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi RA, RA, 1 + | srwi TMP0, RD, 3 + | addi RA, RA, offsetof(GCfuncL, uvptr) + | not TMP0, TMP0 + | lwzx UPVAL:RB, LFUNC:RB, RA + | ins_next1 + | lwz TMP1, UPVAL:RB->v + | stw TMP0, 0(TMP1) + | ins_next2 + break; + + case BC_UCLO: + | // RA = level*8, RD = target + | lwz TMP1, L->openupval + | branch_RD // Do this first since RD is not saved. + | stp BASE, L->base + | cmplwi TMP1, 0 + | mr CARG1, L + | beq >1 + | add CARG2, BASE, RA + | bl extern lj_func_closeuv // (lua_State *L, TValue *level) + | lp BASE, L->base + |1: + | ins_next + break; + + case BC_FNEW: + | // RA = dst*8, RD = proto_const*8 (~) (holding function prototype) + | srwi TMP1, RD, 1 + | stp BASE, L->base + | subfic TMP1, TMP1, -4 + | stw PC, SAVE_PC + | lwzx CARG2, KBASE, TMP1 // KBASE-4-tab_const*4 + | mr CARG1, L + | lwz CARG3, FRAME_FUNC(BASE) + | // (lua_State *L, GCproto *pt, GCfuncL *parent) + | bl extern lj_func_newL_gc + | // Returns GCfuncL *. + | lp BASE, L->base + | li TMP0, LJ_TFUNC + | stwux TMP0, RA, BASE + | stw LFUNC:CRET1, 4(RA) + | ins_next + break; + + /* -- Table ops --------------------------------------------------------- */ + + case BC_TNEW: + case BC_TDUP: + | // RA = dst*8, RD = (hbits|asize)*8 | tab_const*8 (~) + | lwz TMP0, DISPATCH_GL(gc.total)(DISPATCH) + | mr CARG1, L + | lwz TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) + | stp BASE, L->base + | cmplw TMP0, TMP1 + | stw PC, SAVE_PC + | bge >5 + |1: + if (op == BC_TNEW) { + | rlwinm CARG2, RD, 29, 21, 31 + | rlwinm CARG3, RD, 18, 27, 31 + | cmpwi CARG2, 0x7ff; beq >3 + |2: + | bl extern lj_tab_new // (lua_State *L, int32_t asize, uint32_t hbits) + | // Returns Table *. + } else { + | srwi TMP1, RD, 1 + | subfic TMP1, TMP1, -4 + | lwzx CARG2, KBASE, TMP1 // KBASE-4-tab_const*4 + | bl extern lj_tab_dup // (lua_State *L, Table *kt) + | // Returns Table *. + } + | lp BASE, L->base + | li TMP0, LJ_TTAB + | stwux TMP0, RA, BASE + | stw TAB:CRET1, 4(RA) + | ins_next + if (op == BC_TNEW) { + |3: + | li CARG2, 0x801 + | b <2 + } + |5: + | mr SAVE0, RD + | bl extern lj_gc_step_fixtop // (lua_State *L) + | mr RD, SAVE0 + | mr CARG1, L + | b <1 + break; + + case BC_GGET: + | // RA = dst*8, RD = str_const*8 (~) + case BC_GSET: + | // RA = src*8, RD = str_const*8 (~) + | lwz LFUNC:TMP2, FRAME_FUNC(BASE) + | srwi TMP1, RD, 1 + | lwz TAB:RB, LFUNC:TMP2->env + | subfic TMP1, TMP1, -4 + | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 + if (op == BC_GGET) { + | b ->BC_TGETS_Z + } else { + | b ->BC_TSETS_Z + } + break; + + case BC_TGETV: + | // RA = dst*8, RB = table*8, RC = key*8 + | lwzux CARG1, RB, BASE + | lwzux CARG2, RC, BASE + | lwz TAB:RB, 4(RB) + |.if DUALNUM + | lwz RC, 4(RC) + |.else + | lfd f0, 0(RC) + |.endif + | checktab CARG1 + | checknum cr1, CARG2 + | bne ->vmeta_tgetv + |.if DUALNUM + | lwz TMP0, TAB:RB->asize + | bne cr1, >5 + | lwz TMP1, TAB:RB->array + | cmplw TMP0, RC + | slwi TMP2, RC, 3 + |.else + | bge cr1, >5 + | // Convert number key to integer, check for integerness and range. + | fctiwz f1, f0 + | fadd f2, f0, TOBIT + | stfd f1, TMPD + | lwz TMP0, TAB:RB->asize + | fsub f2, f2, TOBIT + | lwz TMP2, TMPD_LO + | lwz TMP1, TAB:RB->array + | fcmpu cr1, f0, f2 + | cmplw cr0, TMP0, TMP2 + | crand 4*cr0+gt, 4*cr0+gt, 4*cr1+eq + | slwi TMP2, TMP2, 3 + |.endif + | ble ->vmeta_tgetv // Integer key and in array part? + | lwzx TMP0, TMP1, TMP2 + | lfdx f14, TMP1, TMP2 + | checknil TMP0; beq >2 + |1: + | ins_next1 + | stfdx f14, BASE, RA + | ins_next2 + | + |2: // Check for __index if table value is nil. + | lwz TAB:TMP2, TAB:RB->metatable + | cmplwi TAB:TMP2, 0 + | beq <1 // No metatable: done. + | lbz TMP0, TAB:TMP2->nomm + | andix. TMP0, TMP0, 1<vmeta_tgetv + | + |5: + | checkstr CARG2; bne ->vmeta_tgetv + |.if not DUALNUM + | lwz STR:RC, 4(RC) + |.endif + | b ->BC_TGETS_Z // String key? + break; + case BC_TGETS: + | // RA = dst*8, RB = table*8, RC = str_const*8 (~) + | lwzux CARG1, RB, BASE + | srwi TMP1, RC, 1 + | lwz TAB:RB, 4(RB) + | subfic TMP1, TMP1, -4 + | checktab CARG1 + | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 + | bne ->vmeta_tgets1 + |->BC_TGETS_Z: + | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = dst*8 + | lwz TMP0, TAB:RB->hmask + | lwz TMP1, STR:RC->hash + | lwz NODE:TMP2, TAB:RB->node + | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask + | slwi TMP0, TMP1, 5 + | slwi TMP1, TMP1, 3 + | sub TMP1, TMP0, TMP1 + | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) + |1: + | lwz CARG1, NODE:TMP2->key + | lwz TMP0, 4+offsetof(Node, key)(NODE:TMP2) + | lwz CARG2, NODE:TMP2->val + | lwz TMP1, 4+offsetof(Node, val)(NODE:TMP2) + | checkstr CARG1; bne >4 + | cmpw TMP0, STR:RC; bne >4 + | checknil CARG2; beq >5 // Key found, but nil value? + |3: + | stwux CARG2, RA, BASE + | stw TMP1, 4(RA) + | ins_next + | + |4: // Follow hash chain. + | lwz NODE:TMP2, NODE:TMP2->next + | cmplwi NODE:TMP2, 0 + | bne <1 + | // End of hash chain: key not found, nil result. + | li CARG2, LJ_TNIL + | + |5: // Check for __index if table value is nil. + | lwz TAB:TMP2, TAB:RB->metatable + | cmplwi TAB:TMP2, 0 + | beq <3 // No metatable: done. + | lbz TMP0, TAB:TMP2->nomm + | andix. TMP0, TMP0, 1<vmeta_tgets + break; + case BC_TGETB: + | // RA = dst*8, RB = table*8, RC = index*8 + | lwzux CARG1, RB, BASE + | srwi TMP0, RC, 3 + | lwz TAB:RB, 4(RB) + | checktab CARG1; bne ->vmeta_tgetb + | lwz TMP1, TAB:RB->asize + | lwz TMP2, TAB:RB->array + | cmplw TMP0, TMP1; bge ->vmeta_tgetb + | lwzx TMP1, TMP2, RC + | lfdx f0, TMP2, RC + | checknil TMP1; beq >5 + |1: + | ins_next1 + | stfdx f0, BASE, RA + | ins_next2 + | + |5: // Check for __index if table value is nil. + | lwz TAB:TMP2, TAB:RB->metatable + | cmplwi TAB:TMP2, 0 + | beq <1 // No metatable: done. + | lbz TMP2, TAB:TMP2->nomm + | andix. TMP2, TMP2, 1<vmeta_tgetb // Caveat: preserve TMP0! + break; + + case BC_TSETV: + | // RA = src*8, RB = table*8, RC = key*8 + | lwzux CARG1, RB, BASE + | lwzux CARG2, RC, BASE + | lwz TAB:RB, 4(RB) + |.if DUALNUM + | lwz RC, 4(RC) + |.else + | lfd f0, 0(RC) + |.endif + | checktab CARG1 + | checknum cr1, CARG2 + | bne ->vmeta_tsetv + |.if DUALNUM + | lwz TMP0, TAB:RB->asize + | bne cr1, >5 + | lwz TMP1, TAB:RB->array + | cmplw TMP0, RC + | slwi TMP0, RC, 3 + |.else + | bge cr1, >5 + | // Convert number key to integer, check for integerness and range. + | fctiwz f1, f0 + | fadd f2, f0, TOBIT + | stfd f1, TMPD + | lwz TMP0, TAB:RB->asize + | fsub f2, f2, TOBIT + | lwz TMP2, TMPD_LO + | lwz TMP1, TAB:RB->array + | fcmpu cr1, f0, f2 + | cmplw cr0, TMP0, TMP2 + | crand 4*cr0+gt, 4*cr0+gt, 4*cr1+eq + | slwi TMP0, TMP2, 3 + |.endif + | ble ->vmeta_tsetv // Integer key and in array part? + | lwzx TMP2, TMP1, TMP0 + | lbz TMP3, TAB:RB->marked + | lfdx f14, BASE, RA + | checknil TMP2; beq >3 + |1: + | andix. TMP2, TMP3, LJ_GC_BLACK // isblack(table) + | stfdx f14, TMP1, TMP0 + | bne >7 + |2: + | ins_next + | + |3: // Check for __newindex if previous value is nil. + | lwz TAB:TMP2, TAB:RB->metatable + | cmplwi TAB:TMP2, 0 + | beq <1 // No metatable: done. + | lbz TMP2, TAB:TMP2->nomm + | andix. TMP2, TMP2, 1<vmeta_tsetv + | + |5: + | checkstr CARG2; bne ->vmeta_tsetv + |.if not DUALNUM + | lwz STR:RC, 4(RC) + |.endif + | b ->BC_TSETS_Z // String key? + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, TMP3, TMP0 + | b <2 + break; + case BC_TSETS: + | // RA = src*8, RB = table*8, RC = str_const*8 (~) + | lwzux CARG1, RB, BASE + | srwi TMP1, RC, 1 + | lwz TAB:RB, 4(RB) + | subfic TMP1, TMP1, -4 + | checktab CARG1 + | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 + | bne ->vmeta_tsets1 + |->BC_TSETS_Z: + | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = src*8 + | lwz TMP0, TAB:RB->hmask + | lwz TMP1, STR:RC->hash + | lwz NODE:TMP2, TAB:RB->node + | stb ZERO, TAB:RB->nomm // Clear metamethod cache. + | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask + | lfdx f14, BASE, RA + | slwi TMP0, TMP1, 5 + | slwi TMP1, TMP1, 3 + | sub TMP1, TMP0, TMP1 + | lbz TMP3, TAB:RB->marked + | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) + |1: + | lwz CARG1, NODE:TMP2->key + | lwz TMP0, 4+offsetof(Node, key)(NODE:TMP2) + | lwz CARG2, NODE:TMP2->val + | lwz NODE:TMP1, NODE:TMP2->next + | checkstr CARG1; bne >5 + | cmpw TMP0, STR:RC; bne >5 + | checknil CARG2; beq >4 // Key found, but nil value? + |2: + | andix. TMP0, TMP3, LJ_GC_BLACK // isblack(table) + | stfd f14, NODE:TMP2->val + | bne >7 + |3: + | ins_next + | + |4: // Check for __newindex if previous value is nil. + | lwz TAB:TMP1, TAB:RB->metatable + | cmplwi TAB:TMP1, 0 + | beq <2 // No metatable: done. + | lbz TMP0, TAB:TMP1->nomm + | andix. TMP0, TMP0, 1<vmeta_tsets + | + |5: // Follow hash chain. + | cmplwi NODE:TMP1, 0 + | mr NODE:TMP2, NODE:TMP1 + | bne <1 + | // End of hash chain: key not found, add a new one. + | + | // But check for __newindex first. + | lwz TAB:TMP1, TAB:RB->metatable + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | stw PC, SAVE_PC + | mr CARG1, L + | cmplwi TAB:TMP1, 0 + | stp BASE, L->base + | beq >6 // No metatable: continue. + | lbz TMP0, TAB:TMP1->nomm + | andix. TMP0, TMP0, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. + |6: + | li TMP0, LJ_TSTR + | stw STR:RC, 4(CARG3) + | mr CARG2, TAB:RB + | stw TMP0, 0(CARG3) + | bl extern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k) + | // Returns TValue *. + | lp BASE, L->base + | stfd f14, 0(CRET1) + | b <3 // No 2nd write barrier needed. + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, TMP3, TMP0 + | b <3 + break; + case BC_TSETB: + | // RA = src*8, RB = table*8, RC = index*8 + | lwzux CARG1, RB, BASE + | srwi TMP0, RC, 3 + | lwz TAB:RB, 4(RB) + | checktab CARG1; bne ->vmeta_tsetb + | lwz TMP1, TAB:RB->asize + | lwz TMP2, TAB:RB->array + | lbz TMP3, TAB:RB->marked + | cmplw TMP0, TMP1 + | lfdx f14, BASE, RA + | bge ->vmeta_tsetb + | lwzx TMP1, TMP2, RC + | checknil TMP1; beq >5 + |1: + | andix. TMP0, TMP3, LJ_GC_BLACK // isblack(table) + | stfdx f14, TMP2, RC + | bne >7 + |2: + | ins_next + | + |5: // Check for __newindex if previous value is nil. + | lwz TAB:TMP1, TAB:RB->metatable + | cmplwi TAB:TMP1, 0 + | beq <1 // No metatable: done. + | lbz TMP1, TAB:TMP1->nomm + | andix. TMP1, TMP1, 1<vmeta_tsetb // Caveat: preserve TMP0! + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, TMP3, TMP0 + | b <2 + break; + + case BC_TSETM: + | // RA = base*8 (table at base-1), RD = num_const*8 (start index) + | add RA, BASE, RA + |1: + | add TMP3, KBASE, RD + | lwz TAB:CARG2, -4(RA) // Guaranteed to be a table. + | addic. TMP0, MULTRES, -8 + | lwz TMP3, 4(TMP3) // Integer constant is in lo-word. + | srwi CARG3, TMP0, 3 + | beq >4 // Nothing to copy? + | add CARG3, CARG3, TMP3 + | lwz TMP2, TAB:CARG2->asize + | slwi TMP1, TMP3, 3 + | lbz TMP3, TAB:CARG2->marked + | cmplw CARG3, TMP2 + | add TMP2, RA, TMP0 + | lwz TMP0, TAB:CARG2->array + | bgt >5 + | add TMP1, TMP1, TMP0 + | andix. TMP0, TMP3, LJ_GC_BLACK // isblack(table) + |3: // Copy result slots to table. + | lfd f0, 0(RA) + | addi RA, RA, 8 + | cmpw cr1, RA, TMP2 + | stfd f0, 0(TMP1) + | addi TMP1, TMP1, 8 + | blt cr1, <3 + | bne >7 + |4: + | ins_next + | + |5: // Need to resize array part. + | stp BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | mr SAVE0, RD + | bl extern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) + | // Must not reallocate the stack. + | mr RD, SAVE0 + | b <1 + | + |7: // Possible table write barrier for any value. Skip valiswhite check. + | barrierback TAB:CARG2, TMP3, TMP0 + | b <4 + break; + + /* -- Calls and vararg handling ----------------------------------------- */ + + case BC_CALLM: + | // RA = base*8, (RB = (nresults+1)*8,) RC = extra_nargs*8 + | add NARGS8:RC, NARGS8:RC, MULTRES + | // Fall through. Assumes BC_CALL follows. + break; + case BC_CALL: + | // RA = base*8, (RB = (nresults+1)*8,) RC = (nargs+1)*8 + | mr TMP2, BASE + | lwzux TMP0, BASE, RA + | lwz LFUNC:RB, 4(BASE) + | subi NARGS8:RC, NARGS8:RC, 8 + | addi BASE, BASE, 8 + | checkfunc TMP0; bne ->vmeta_call + | ins_call + break; + + case BC_CALLMT: + | // RA = base*8, (RB = 0,) RC = extra_nargs*8 + | add NARGS8:RC, NARGS8:RC, MULTRES + | // Fall through. Assumes BC_CALLT follows. + break; + case BC_CALLT: + | // RA = base*8, (RB = 0,) RC = (nargs+1)*8 + | lwzux TMP0, RA, BASE + | lwz LFUNC:RB, 4(RA) + | subi NARGS8:RC, NARGS8:RC, 8 + | lwz TMP1, FRAME_PC(BASE) + | checkfunc TMP0 + | addi RA, RA, 8 + | bne ->vmeta_callt + |->BC_CALLT_Z: + | andix. TMP0, TMP1, FRAME_TYPE // Caveat: preserve cr0 until the crand. + | lbz TMP3, LFUNC:RB->ffid + | xori TMP2, TMP1, FRAME_VARG + | cmplwi cr1, NARGS8:RC, 0 + | bne >7 + |1: + | stw LFUNC:RB, FRAME_FUNC(BASE) // Copy function down, but keep PC. + | li TMP2, 0 + | cmplwi cr7, TMP3, 1 // (> FF_C) Calling a fast function? + | beq cr1, >3 + |2: + | addi TMP3, TMP2, 8 + | lfdx f0, RA, TMP2 + | cmplw cr1, TMP3, NARGS8:RC + | stfdx f0, BASE, TMP2 + | mr TMP2, TMP3 + | bne cr1, <2 + |3: + | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+gt + | beq >5 + |4: + | ins_callt + | + |5: // Tailcall to a fast function with a Lua frame below. + | lwz INS, -4(TMP1) + | decode_RA8 RA, INS + | sub TMP1, BASE, RA + | lwz LFUNC:TMP1, FRAME_FUNC-8(TMP1) + | lwz TMP1, LFUNC:TMP1->pc + | lwz KBASE, PC2PROTO(k)(TMP1) // Need to prepare KBASE. + | b <4 + | + |7: // Tailcall from a vararg function. + | andix. TMP0, TMP2, FRAME_TYPEP + | bne <1 // Vararg frame below? + | sub BASE, BASE, TMP2 // Relocate BASE down. + | lwz TMP1, FRAME_PC(BASE) + | andix. TMP0, TMP1, FRAME_TYPE + | b <1 + break; + + case BC_ITERC: + | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 ((2+1)*8)) + | mr TMP2, BASE + | add BASE, BASE, RA + | lwz TMP1, -24(BASE) + | lwz LFUNC:RB, -20(BASE) + | lfd f1, -8(BASE) + | lfd f0, -16(BASE) + | stw TMP1, 0(BASE) // Copy callable. + | stw LFUNC:RB, 4(BASE) + | checkfunc TMP1 + | stfd f1, 16(BASE) // Copy control var. + | li NARGS8:RC, 16 // Iterators get 2 arguments. + | stfdu f0, 8(BASE) // Copy state. + | bne ->vmeta_call + | ins_call + break; + + case BC_ITERN: + | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 (2+1)*8) + |.if JIT + | // NYI: add hotloop, record BC_ITERN. + |.endif + | add RA, BASE, RA + | lwz TAB:RB, -12(RA) + | lwz RC, -4(RA) // Get index from control var. + | lwz TMP0, TAB:RB->asize + | lwz TMP1, TAB:RB->array + | addi PC, PC, 4 + |1: // Traverse array part. + | cmplw RC, TMP0 + | slwi TMP3, RC, 3 + | bge >5 // Index points after array part? + | lwzx TMP2, TMP1, TMP3 + | lfdx f0, TMP1, TMP3 + | checknil TMP2 + | lwz INS, -4(PC) + | beq >4 + |.if DUALNUM + | stw RC, 4(RA) + | stw TISNUM, 0(RA) + |.else + | tonum_u f1, RC + |.endif + | addi RC, RC, 1 + | addis TMP3, PC, -(BCBIAS_J*4 >> 16) + | stfd f0, 8(RA) + | decode_RD4 TMP1, INS + | stw RC, -4(RA) // Update control var. + | add PC, TMP1, TMP3 + |.if not DUALNUM + | stfd f1, 0(RA) + |.endif + |3: + | ins_next + | + |4: // Skip holes in array part. + | addi RC, RC, 1 + | b <1 + | + |5: // Traverse hash part. + | lwz TMP1, TAB:RB->hmask + | sub RC, RC, TMP0 + | lwz TMP2, TAB:RB->node + |6: + | cmplw RC, TMP1 // End of iteration? Branch to ITERL+1. + | slwi TMP3, RC, 5 + | bgty <3 + | slwi RB, RC, 3 + | sub TMP3, TMP3, RB + | lwzx RB, TMP2, TMP3 + | lfdx f0, TMP2, TMP3 + | add NODE:TMP3, TMP2, TMP3 + | checknil RB + | lwz INS, -4(PC) + | beq >7 + | lfd f1, NODE:TMP3->key + | addis TMP2, PC, -(BCBIAS_J*4 >> 16) + | stfd f0, 8(RA) + | add RC, RC, TMP0 + | decode_RD4 TMP1, INS + | stfd f1, 0(RA) + | addi RC, RC, 1 + | add PC, TMP1, TMP2 + | stw RC, -4(RA) // Update control var. + | b <3 + | + |7: // Skip holes in hash part. + | addi RC, RC, 1 + | b <6 + break; + + case BC_ISNEXT: + | // RA = base*8, RD = target (points to ITERN) + | add RA, BASE, RA + | lwz TMP0, -24(RA) + | lwz CFUNC:TMP1, -20(RA) + | lwz TMP2, -16(RA) + | lwz TMP3, -8(RA) + | cmpwi cr0, TMP2, LJ_TTAB + | cmpwi cr1, TMP0, LJ_TFUNC + | cmpwi cr6, TMP3, LJ_TNIL + | bne cr1, >5 + | lbz TMP1, CFUNC:TMP1->ffid + | crand 4*cr0+eq, 4*cr0+eq, 4*cr6+eq + | cmpwi cr7, TMP1, FF_next_N + | srwi TMP0, RD, 1 + | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+eq + | add TMP3, PC, TMP0 + | bne cr0, >5 + | lus TMP1, 0xfffe + | ori TMP1, TMP1, 0x7fff + | stw ZERO, -4(RA) // Initialize control var. + | stw TMP1, -8(RA) + | addis PC, TMP3, -(BCBIAS_J*4 >> 16) + |1: + | ins_next + |5: // Despecialize bytecode if any of the checks fail. + | li TMP0, BC_JMP + | li TMP1, BC_ITERC + | stb TMP0, -1(PC) + | addis PC, TMP3, -(BCBIAS_J*4 >> 16) + | stb TMP1, 3(PC) + | b <1 + break; + + case BC_VARG: + | // RA = base*8, RB = (nresults+1)*8, RC = numparams*8 + | lwz TMP0, FRAME_PC(BASE) + | add RC, BASE, RC + | add RA, BASE, RA + | addi RC, RC, FRAME_VARG + | add TMP2, RA, RB + | subi TMP3, BASE, 8 // TMP3 = vtop + | sub RC, RC, TMP0 // RC = vbase + | // Note: RC may now be even _above_ BASE if nargs was < numparams. + | cmplwi cr1, RB, 0 + |.if PPE + | sub TMP1, TMP3, RC + | cmpwi TMP1, 0 + |.else + | sub. TMP1, TMP3, RC + |.endif + | beq cr1, >5 // Copy all varargs? + | subi TMP2, TMP2, 16 + | ble >2 // No vararg slots? + |1: // Copy vararg slots to destination slots. + | lfd f0, 0(RC) + | addi RC, RC, 8 + | stfd f0, 0(RA) + | cmplw RA, TMP2 + | cmplw cr1, RC, TMP3 + | bge >3 // All destination slots filled? + | addi RA, RA, 8 + | blt cr1, <1 // More vararg slots? + |2: // Fill up remainder with nil. + | stw TISNIL, 0(RA) + | cmplw RA, TMP2 + | addi RA, RA, 8 + | blt <2 + |3: + | ins_next + | + |5: // Copy all varargs. + | lwz TMP0, L->maxstack + | li MULTRES, 8 // MULTRES = (0+1)*8 + | bley <3 // No vararg slots? + | add TMP2, RA, TMP1 + | cmplw TMP2, TMP0 + | addi MULTRES, TMP1, 8 + | bgt >7 + |6: + | lfd f0, 0(RC) + | addi RC, RC, 8 + | stfd f0, 0(RA) + | cmplw RC, TMP3 + | addi RA, RA, 8 + | blt <6 // More vararg slots? + | b <3 + | + |7: // Grow stack for varargs. + | mr CARG1, L + | stp RA, L->top + | sub SAVE0, RC, BASE // Need delta, because BASE may change. + | stp BASE, L->base + | sub RA, RA, BASE + | stw PC, SAVE_PC + | srwi CARG2, TMP1, 3 + | bl extern lj_state_growstack // (lua_State *L, int n) + | lp BASE, L->base + | add RA, BASE, RA + | add RC, BASE, SAVE0 + | subi TMP3, BASE, 8 + | b <6 + break; + + /* -- Returns ----------------------------------------------------------- */ + + case BC_RETM: + | // RA = results*8, RD = extra_nresults*8 + | add RD, RD, MULTRES // MULTRES >= 8, so RD >= 8. + | // Fall through. Assumes BC_RET follows. + break; + + case BC_RET: + | // RA = results*8, RD = (nresults+1)*8 + | lwz PC, FRAME_PC(BASE) + | add RA, BASE, RA + | mr MULTRES, RD + |1: + | andix. TMP0, PC, FRAME_TYPE + | xori TMP1, PC, FRAME_VARG + | bne ->BC_RETV_Z + | + |->BC_RET_Z: + | // BASE = base, RA = resultptr, RD = (nresults+1)*8, PC = return + | lwz INS, -4(PC) + | cmpwi RD, 8 + | subi TMP2, BASE, 8 + | subi RC, RD, 8 + | decode_RB8 RB, INS + | beq >3 + | li TMP1, 0 + |2: + | addi TMP3, TMP1, 8 + | lfdx f0, RA, TMP1 + | cmpw TMP3, RC + | stfdx f0, TMP2, TMP1 + | beq >3 + | addi TMP1, TMP3, 8 + | lfdx f1, RA, TMP3 + | cmpw TMP1, RC + | stfdx f1, TMP2, TMP3 + | bne <2 + |3: + |5: + | cmplw RB, RD + | decode_RA8 RA, INS + | bgt >6 + | sub BASE, TMP2, RA + | lwz LFUNC:TMP1, FRAME_FUNC(BASE) + | ins_next1 + | lwz TMP1, LFUNC:TMP1->pc + | lwz KBASE, PC2PROTO(k)(TMP1) + | ins_next2 + | + |6: // Fill up results with nil. + | subi TMP1, RD, 8 + | addi RD, RD, 8 + | stwx TISNIL, TMP2, TMP1 + | b <5 + | + |->BC_RETV_Z: // Non-standard return case. + | andix. TMP2, TMP1, FRAME_TYPEP + | bne ->vm_return + | // Return from vararg function: relocate BASE down. + | sub BASE, BASE, TMP1 + | lwz PC, FRAME_PC(BASE) + | b <1 + break; + + case BC_RET0: case BC_RET1: + | // RA = results*8, RD = (nresults+1)*8 + | lwz PC, FRAME_PC(BASE) + | add RA, BASE, RA + | mr MULTRES, RD + | andix. TMP0, PC, FRAME_TYPE + | xori TMP1, PC, FRAME_VARG + | bney ->BC_RETV_Z + | + | lwz INS, -4(PC) + | subi TMP2, BASE, 8 + | decode_RB8 RB, INS + if (op == BC_RET1) { + | lfd f0, 0(RA) + | stfd f0, 0(TMP2) + } + |5: + | cmplw RB, RD + | decode_RA8 RA, INS + | bgt >6 + | sub BASE, TMP2, RA + | lwz LFUNC:TMP1, FRAME_FUNC(BASE) + | ins_next1 + | lwz TMP1, LFUNC:TMP1->pc + | lwz KBASE, PC2PROTO(k)(TMP1) + | ins_next2 + | + |6: // Fill up results with nil. + | subi TMP1, RD, 8 + | addi RD, RD, 8 + | stwx TISNIL, TMP2, TMP1 + | b <5 + break; + + /* -- Loops and branches ------------------------------------------------ */ + + case BC_FORL: + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_IFORL follows. + break; + + case BC_JFORI: + case BC_JFORL: +#if !LJ_HASJIT + break; +#endif + case BC_FORI: + case BC_IFORL: + | // RA = base*8, RD = target (after end of loop or start of loop) + vk = (op == BC_IFORL || op == BC_JFORL); + |.if DUALNUM + | // Integer loop. + | lwzux TMP1, RA, BASE + | lwz CARG1, FORL_IDX*8+4(RA) + | cmplw cr0, TMP1, TISNUM + if (vk) { + | lwz CARG3, FORL_STEP*8+4(RA) + | bne >9 + |.if GPR64 + | // Need to check overflow for (a<<32) + (b<<32). + | rldicr TMP0, CARG1, 32, 31 + | rldicr TMP2, CARG3, 32, 31 + | add CARG1, CARG1, CARG3 + | addo. TMP0, TMP0, TMP2 + |.else + | addo. CARG1, CARG1, CARG3 + |.endif + | cmpwi cr6, CARG3, 0 + | lwz CARG2, FORL_STOP*8+4(RA) + | bso >6 + |4: + | stw CARG1, FORL_IDX*8+4(RA) + } else { + | lwz TMP3, FORL_STEP*8(RA) + | lwz CARG3, FORL_STEP*8+4(RA) + | lwz TMP2, FORL_STOP*8(RA) + | lwz CARG2, FORL_STOP*8+4(RA) + | cmplw cr7, TMP3, TISNUM + | cmplw cr1, TMP2, TISNUM + | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+eq + | crand 4*cr0+eq, 4*cr0+eq, 4*cr1+eq + | cmpwi cr6, CARG3, 0 + | bne >9 + } + | blt cr6, >5 + | cmpw CARG1, CARG2 + |1: + | stw TISNUM, FORL_EXT*8(RA) + if (op != BC_JFORL) { + | srwi RD, RD, 1 + } + | stw CARG1, FORL_EXT*8+4(RA) + if (op != BC_JFORL) { + | add RD, PC, RD + } + if (op == BC_FORI) { + | bgt >3 // See FP loop below. + } else if (op == BC_JFORI) { + | addis PC, RD, -(BCBIAS_J*4 >> 16) + | bley >7 + } else if (op == BC_IFORL) { + | bgt >2 + | addis PC, RD, -(BCBIAS_J*4 >> 16) + } else { + | bley =>BC_JLOOP + } + |2: + | ins_next + |5: // Invert check for negative step. + | cmpw CARG2, CARG1 + | b <1 + if (vk) { + |6: // Potential overflow. + | checkov TMP0, <4 // Ignore unrelated overflow. + | b <2 + } + |.endif + if (vk) { + |.if DUALNUM + |9: // FP loop. + | lfd f1, FORL_IDX*8(RA) + |.else + | lfdux f1, RA, BASE + |.endif + | lfd f3, FORL_STEP*8(RA) + | lfd f2, FORL_STOP*8(RA) + | lwz TMP3, FORL_STEP*8(RA) + | fadd f1, f1, f3 + | stfd f1, FORL_IDX*8(RA) + } else { + |.if DUALNUM + |9: // FP loop. + |.else + | lwzux TMP1, RA, BASE + | lwz TMP3, FORL_STEP*8(RA) + | lwz TMP2, FORL_STOP*8(RA) + | cmplw cr0, TMP1, TISNUM + | cmplw cr7, TMP3, TISNUM + | cmplw cr1, TMP2, TISNUM + |.endif + | lfd f1, FORL_IDX*8(RA) + | crand 4*cr0+lt, 4*cr0+lt, 4*cr7+lt + | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt + | lfd f2, FORL_STOP*8(RA) + | bge ->vmeta_for + } + | cmpwi cr6, TMP3, 0 + if (op != BC_JFORL) { + | srwi RD, RD, 1 + } + | stfd f1, FORL_EXT*8(RA) + if (op != BC_JFORL) { + | add RD, PC, RD + } + | fcmpu cr0, f1, f2 + if (op == BC_JFORI) { + | addis PC, RD, -(BCBIAS_J*4 >> 16) + } + | blt cr6, >5 + if (op == BC_FORI) { + | bgt >3 + } else if (op == BC_IFORL) { + |.if DUALNUM + | bgty <2 + |.else + | bgt >2 + |.endif + |1: + | addis PC, RD, -(BCBIAS_J*4 >> 16) + } else if (op == BC_JFORI) { + | bley >7 + } else { + | bley =>BC_JLOOP + } + |.if DUALNUM + | b <2 + |.else + |2: + | ins_next + |.endif + |5: // Negative step. + if (op == BC_FORI) { + | bge <2 + |3: // Used by integer loop, too. + | addis PC, RD, -(BCBIAS_J*4 >> 16) + } else if (op == BC_IFORL) { + | bgey <1 + } else if (op == BC_JFORI) { + | bgey >7 + } else { + | bgey =>BC_JLOOP + } + | b <2 + if (op == BC_JFORI) { + |7: + | lwz INS, -4(PC) + | decode_RD8 RD, INS + | b =>BC_JLOOP + } + break; + + case BC_ITERL: + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_IITERL follows. + break; + + case BC_JITERL: +#if !LJ_HASJIT + break; +#endif + case BC_IITERL: + | // RA = base*8, RD = target + | lwzux TMP1, RA, BASE + | lwz TMP2, 4(RA) + | checknil TMP1; beq >1 // Stop if iterator returned nil. + if (op == BC_JITERL) { + | stw TMP1, -8(RA) + | stw TMP2, -4(RA) + | b =>BC_JLOOP + } else { + | branch_RD // Otherwise save control var + branch. + | stw TMP1, -8(RA) + | stw TMP2, -4(RA) + } + |1: + | ins_next + break; + + case BC_LOOP: + | // RA = base*8, RD = target (loop extent) + | // Note: RA/RD is only used by trace recorder to determine scope/extent + | // This opcode does NOT jump, it's only purpose is to detect a hot loop. + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_ILOOP follows. + break; + + case BC_ILOOP: + | // RA = base*8, RD = target (loop extent) + | ins_next + break; + + case BC_JLOOP: + |.if JIT + | // RA = base*8 (ignored), RD = traceno*8 + | lwz TMP1, DISPATCH_J(trace)(DISPATCH) + | srwi RD, RD, 1 + | // Traces on PPC don't store the trace number, so use 0. + | stw ZERO, DISPATCH_GL(vmstate)(DISPATCH) + | lwzx TRACE:TMP2, TMP1, RD + | clrso TMP1 + | lp TMP2, TRACE:TMP2->mcode + | stw BASE, DISPATCH_GL(jit_base)(DISPATCH) + | mtctr TMP2 + | stw L, DISPATCH_GL(jit_L)(DISPATCH) + | addi JGL, DISPATCH, GG_DISP2G+32768 + | bctr + |.endif + break; + + case BC_JMP: + | // RA = base*8 (only used by trace recorder), RD = target + | branch_RD + | ins_next + break; + + /* -- Function headers -------------------------------------------------- */ + + case BC_FUNCF: + |.if JIT + | hotcall + |.endif + case BC_FUNCV: /* NYI: compiled vararg functions. */ + | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow. + break; + + case BC_JFUNCF: +#if !LJ_HASJIT + break; +#endif + case BC_IFUNCF: + | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 + | lwz TMP2, L->maxstack + | lbz TMP1, -4+PC2PROTO(numparams)(PC) + | lwz KBASE, -4+PC2PROTO(k)(PC) + | cmplw RA, TMP2 + | slwi TMP1, TMP1, 3 + | bgt ->vm_growstack_l + if (op != BC_JFUNCF) { + | ins_next1 + } + |2: + | cmplw NARGS8:RC, TMP1 // Check for missing parameters. + | blt >3 + if (op == BC_JFUNCF) { + | decode_RD8 RD, INS + | b =>BC_JLOOP + } else { + | ins_next2 + } + | + |3: // Clear missing parameters. + | stwx TISNIL, BASE, NARGS8:RC + | addi NARGS8:RC, NARGS8:RC, 8 + | b <2 + break; + + case BC_JFUNCV: +#if !LJ_HASJIT + break; +#endif + | NYI // NYI: compiled vararg functions + break; /* NYI: compiled vararg functions. */ + + case BC_IFUNCV: + | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 + | lwz TMP2, L->maxstack + | add TMP1, BASE, RC + | add TMP0, RA, RC + | stw LFUNC:RB, 4(TMP1) // Store copy of LFUNC. + | addi TMP3, RC, 8+FRAME_VARG + | lwz KBASE, -4+PC2PROTO(k)(PC) + | cmplw TMP0, TMP2 + | stw TMP3, 0(TMP1) // Store delta + FRAME_VARG. + | bge ->vm_growstack_l + | lbz TMP2, -4+PC2PROTO(numparams)(PC) + | mr RA, BASE + | mr RC, TMP1 + | ins_next1 + | cmpwi TMP2, 0 + | addi BASE, TMP1, 8 + | beq >3 + |1: + | cmplw RA, RC // Less args than parameters? + | lwz TMP0, 0(RA) + | lwz TMP3, 4(RA) + | bge >4 + | stw TISNIL, 0(RA) // Clear old fixarg slot (help the GC). + | addi RA, RA, 8 + |2: + | addic. TMP2, TMP2, -1 + | stw TMP0, 8(TMP1) + | stw TMP3, 12(TMP1) + | addi TMP1, TMP1, 8 + | bne <1 + |3: + | ins_next2 + | + |4: // Clear missing parameters. + | li TMP0, LJ_TNIL + | b <2 + break; + + case BC_FUNCC: + case BC_FUNCCW: + | // BASE = new base, RA = BASE+framesize*8, RB = CFUNC, RC = nargs*8 + if (op == BC_FUNCC) { + | lp RD, CFUNC:RB->f + } else { + | lp RD, DISPATCH_GL(wrapf)(DISPATCH) + } + | add TMP1, RA, NARGS8:RC + | lwz TMP2, L->maxstack + | .toc lp TMP3, 0(RD) + | add RC, BASE, NARGS8:RC + | stp BASE, L->base + | cmplw TMP1, TMP2 + | stp RC, L->top + | li_vmstate C + |.if TOC + | mtctr TMP3 + |.else + | mtctr RD + |.endif + if (op == BC_FUNCCW) { + | lp CARG2, CFUNC:RB->f + } + | mr CARG1, L + | bgt ->vm_growstack_c // Need to grow stack. + | .toc lp TOCREG, TOC_OFS(RD) + | .tocenv lp ENVREG, ENV_OFS(RD) + | st_vmstate + | bctrl // (lua_State *L [, lua_CFunction f]) + | // Returns nresults. + | lp BASE, L->base + | .toc ld TOCREG, SAVE_TOC + | slwi RD, CRET1, 3 + | lp TMP1, L->top + | li_vmstate INTERP + | lwz PC, FRAME_PC(BASE) // Fetch PC of caller. + | sub RA, TMP1, RD // RA = L->top - nresults*8 + | st_vmstate + | b ->vm_returnc + break; + + /* ---------------------------------------------------------------------- */ + + default: + fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); + exit(2); + break; + } +} + +static int build_backend(BuildCtx *ctx) +{ + int op; + + dasm_growpc(Dst, BC__MAX); + + build_subroutines(ctx); + + |.code_op + for (op = 0; op < BC__MAX; op++) + build_ins(ctx, (BCOp)op, op); + + return BC__MAX; +} + +/* Emit pseudo frame-info for all assembler functions. */ +static void emit_asm_debug(BuildCtx *ctx) +{ + int fcofs = (int)((uint8_t *)ctx->glob[GLOB_vm_ffi_call] - ctx->code); + int i; + switch (ctx->mode) { + case BUILD_elfasm: + fprintf(ctx->fp, "\t.section .debug_frame,\"\",@progbits\n"); + fprintf(ctx->fp, + ".Lframe0:\n" + "\t.long .LECIE0-.LSCIE0\n" + ".LSCIE0:\n" + "\t.long 0xffffffff\n" + "\t.byte 0x1\n" + "\t.string \"\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -4\n" + "\t.byte 65\n" + "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" + "\t.align 2\n" + ".LECIE0:\n\n"); + fprintf(ctx->fp, + ".LSFDE0:\n" + "\t.long .LEFDE0-.LASFDE0\n" + ".LASFDE0:\n" + "\t.long .Lframe0\n" + "\t.long .Lbegin\n" + "\t.long %d\n" + "\t.byte 0xe\n\t.uleb128 %d\n" + "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" + "\t.byte 0x5\n\t.uleb128 70\n\t.uleb128 55\n", + fcofs, CFRAME_SIZE); + for (i = 14; i <= 31; i++) + fprintf(ctx->fp, + "\t.byte %d\n\t.uleb128 %d\n" + "\t.byte %d\n\t.uleb128 %d\n", + 0x80+i, 37+(31-i), 0x80+32+i, 2+2*(31-i)); + fprintf(ctx->fp, + "\t.align 2\n" + ".LEFDE0:\n\n"); +#if LJ_HASFFI + fprintf(ctx->fp, + ".LSFDE1:\n" + "\t.long .LEFDE1-.LASFDE1\n" + ".LASFDE1:\n" + "\t.long .Lframe0\n" +#if LJ_TARGET_PS3 + "\t.long .lj_vm_ffi_call\n" +#else + "\t.long lj_vm_ffi_call\n" +#endif + "\t.long %d\n" + "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" + "\t.byte 0x8e\n\t.uleb128 2\n" + "\t.byte 0xd\n\t.uleb128 0xe\n" + "\t.align 2\n" + ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); +#endif +#if !LJ_NO_UNWIND + fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n"); + fprintf(ctx->fp, + ".Lframe1:\n" + "\t.long .LECIE1-.LSCIE1\n" + ".LSCIE1:\n" + "\t.long 0\n" + "\t.byte 0x1\n" + "\t.string \"zPR\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -4\n" + "\t.byte 65\n" + "\t.uleb128 6\n" /* augmentation length */ + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.long lj_err_unwind_dwarf-.\n" + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" + "\t.align 2\n" + ".LECIE1:\n\n"); + fprintf(ctx->fp, + ".LSFDE2:\n" + "\t.long .LEFDE2-.LASFDE2\n" + ".LASFDE2:\n" + "\t.long .LASFDE2-.Lframe1\n" + "\t.long .Lbegin-.\n" + "\t.long %d\n" + "\t.uleb128 0\n" /* augmentation length */ + "\t.byte 0xe\n\t.uleb128 %d\n" + "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" + "\t.byte 0x5\n\t.uleb128 70\n\t.uleb128 55\n", + fcofs, CFRAME_SIZE); + for (i = 14; i <= 31; i++) + fprintf(ctx->fp, + "\t.byte %d\n\t.uleb128 %d\n" + "\t.byte %d\n\t.uleb128 %d\n", + 0x80+i, 37+(31-i), 0x80+32+i, 2+2*(31-i)); + fprintf(ctx->fp, + "\t.align 2\n" + ".LEFDE2:\n\n"); +#if LJ_HASFFI + fprintf(ctx->fp, + ".Lframe2:\n" + "\t.long .LECIE2-.LSCIE2\n" + ".LSCIE2:\n" + "\t.long 0\n" + "\t.byte 0x1\n" + "\t.string \"zR\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -4\n" + "\t.byte 65\n" + "\t.uleb128 1\n" /* augmentation length */ + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" + "\t.align 2\n" + ".LECIE2:\n\n"); + fprintf(ctx->fp, + ".LSFDE3:\n" + "\t.long .LEFDE3-.LASFDE3\n" + ".LASFDE3:\n" + "\t.long .LASFDE3-.Lframe2\n" + "\t.long lj_vm_ffi_call-.\n" + "\t.long %d\n" + "\t.uleb128 0\n" /* augmentation length */ + "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" + "\t.byte 0x8e\n\t.uleb128 2\n" + "\t.byte 0xd\n\t.uleb128 0xe\n" + "\t.align 2\n" + ".LEFDE3:\n\n", (int)ctx->codesz - fcofs); +#endif +#endif + break; + default: + break; + } +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/vm_ppcspe.dasc b/source/libs/luajit/LuaJIT-2.0.4/src/vm_ppcspe.dasc new file mode 100644 index 000000000..53ea2d965 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/vm_ppcspe.dasc @@ -0,0 +1,3691 @@ +|// Low-level VM code for PowerPC/e500 CPUs. +|// Bytecode interpreter, fast functions and helper functions. +|// Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +| +|.arch ppc +|.section code_op, code_sub +| +|.actionlist build_actionlist +|.globals GLOB_ +|.globalnames globnames +|.externnames extnames +| +|// Note: The ragged indentation of the instructions is intentional. +|// The starting columns indicate data dependencies. +| +|//----------------------------------------------------------------------- +| +|// Fixed register assignments for the interpreter. +|// Don't use: r1 = sp, r2 and r13 = reserved and/or small data area ptr +| +|// The following must be C callee-save (but BASE is often refetched). +|.define BASE, r14 // Base of current Lua stack frame. +|.define KBASE, r15 // Constants of current Lua function. +|.define PC, r16 // Next PC. +|.define DISPATCH, r17 // Opcode dispatch table. +|.define LREG, r18 // Register holding lua_State (also in SAVE_L). +|.define MULTRES, r19 // Size of multi-result: (nresults+1)*8. +| +|// Constants for vectorized type-comparisons (hi+low GPR). C callee-save. +|.define TISNUM, r22 +|.define TISSTR, r23 +|.define TISTAB, r24 +|.define TISFUNC, r25 +|.define TISNIL, r26 +|.define TOBIT, r27 +|.define ZERO, TOBIT // Zero in lo word. +| +|// The following temporaries are not saved across C calls, except for RA. +|.define RA, r20 // Callee-save. +|.define RB, r10 +|.define RC, r11 +|.define RD, r12 +|.define INS, r7 // Overlaps CARG5. +| +|.define TMP0, r0 +|.define TMP1, r8 +|.define TMP2, r9 +|.define TMP3, r6 // Overlaps CARG4. +| +|// Saved temporaries. +|.define SAVE0, r21 +| +|// Calling conventions. +|.define CARG1, r3 +|.define CARG2, r4 +|.define CARG3, r5 +|.define CARG4, r6 // Overlaps TMP3. +|.define CARG5, r7 // Overlaps INS. +| +|.define CRET1, r3 +|.define CRET2, r4 +| +|// Stack layout while in interpreter. Must match with lj_frame.h. +|.define SAVE_LR, 188(sp) +|.define CFRAME_SPACE, 184 // Delta for sp. +|// Back chain for sp: 184(sp) <-- sp entering interpreter +|.define SAVE_r31, 176(sp) // 64 bit register saves. +|.define SAVE_r30, 168(sp) +|.define SAVE_r29, 160(sp) +|.define SAVE_r28, 152(sp) +|.define SAVE_r27, 144(sp) +|.define SAVE_r26, 136(sp) +|.define SAVE_r25, 128(sp) +|.define SAVE_r24, 120(sp) +|.define SAVE_r23, 112(sp) +|.define SAVE_r22, 104(sp) +|.define SAVE_r21, 96(sp) +|.define SAVE_r20, 88(sp) +|.define SAVE_r19, 80(sp) +|.define SAVE_r18, 72(sp) +|.define SAVE_r17, 64(sp) +|.define SAVE_r16, 56(sp) +|.define SAVE_r15, 48(sp) +|.define SAVE_r14, 40(sp) +|.define SAVE_CR, 36(sp) +|.define UNUSED1, 32(sp) +|.define SAVE_ERRF, 28(sp) // 32 bit C frame info. +|.define SAVE_NRES, 24(sp) +|.define SAVE_CFRAME, 20(sp) +|.define SAVE_L, 16(sp) +|.define SAVE_PC, 12(sp) +|.define SAVE_MULTRES, 8(sp) +|// Next frame lr: 4(sp) +|// Back chain for sp: 0(sp) <-- sp while in interpreter +| +|.macro save_, reg; evstdd reg, SAVE_..reg; .endmacro +|.macro rest_, reg; evldd reg, SAVE_..reg; .endmacro +| +|.macro saveregs +| stwu sp, -CFRAME_SPACE(sp) +| save_ r14; save_ r15; save_ r16; save_ r17; save_ r18; save_ r19 +| mflr r0; mfcr r12 +| save_ r20; save_ r21; save_ r22; save_ r23; save_ r24; save_ r25 +| stw r0, SAVE_LR; stw r12, SAVE_CR +| save_ r26; save_ r27; save_ r28; save_ r29; save_ r30; save_ r31 +|.endmacro +| +|.macro restoreregs +| lwz r0, SAVE_LR; lwz r12, SAVE_CR +| rest_ r14; rest_ r15; rest_ r16; rest_ r17; rest_ r18; rest_ r19 +| mtlr r0; mtcrf 0x38, r12 +| rest_ r20; rest_ r21; rest_ r22; rest_ r23; rest_ r24; rest_ r25 +| rest_ r26; rest_ r27; rest_ r28; rest_ r29; rest_ r30; rest_ r31 +| addi sp, sp, CFRAME_SPACE +|.endmacro +| +|// Type definitions. Some of these are only used for documentation. +|.type L, lua_State, LREG +|.type GL, global_State +|.type TVALUE, TValue +|.type GCOBJ, GCobj +|.type STR, GCstr +|.type TAB, GCtab +|.type LFUNC, GCfuncL +|.type CFUNC, GCfuncC +|.type PROTO, GCproto +|.type UPVAL, GCupval +|.type NODE, Node +|.type NARGS8, int +|.type TRACE, GCtrace +| +|//----------------------------------------------------------------------- +| +|// These basic macros should really be part of DynASM. +|.macro srwi, rx, ry, n; rlwinm rx, ry, 32-n, n, 31; .endmacro +|.macro slwi, rx, ry, n; rlwinm rx, ry, n, 0, 31-n; .endmacro +|.macro rotlwi, rx, ry, n; rlwinm rx, ry, n, 0, 31; .endmacro +|.macro rotlw, rx, ry, rn; rlwnm rx, ry, rn, 0, 31; .endmacro +|.macro subi, rx, ry, i; addi rx, ry, -i; .endmacro +| +|// Trap for not-yet-implemented parts. +|.macro NYI; tw 4, sp, sp; .endmacro +| +|//----------------------------------------------------------------------- +| +|// Access to frame relative to BASE. +|.define FRAME_PC, -8 +|.define FRAME_FUNC, -4 +| +|// Instruction decode. +|.macro decode_OP4, dst, ins; rlwinm dst, ins, 2, 22, 29; .endmacro +|.macro decode_RA8, dst, ins; rlwinm dst, ins, 27, 21, 28; .endmacro +|.macro decode_RB8, dst, ins; rlwinm dst, ins, 11, 21, 28; .endmacro +|.macro decode_RC8, dst, ins; rlwinm dst, ins, 19, 21, 28; .endmacro +|.macro decode_RD8, dst, ins; rlwinm dst, ins, 19, 13, 28; .endmacro +| +|.macro decode_OP1, dst, ins; rlwinm dst, ins, 0, 24, 31; .endmacro +|.macro decode_RD4, dst, ins; rlwinm dst, ins, 18, 14, 29; .endmacro +| +|// Instruction fetch. +|.macro ins_NEXT1 +| lwz INS, 0(PC) +| addi PC, PC, 4 +|.endmacro +|// Instruction decode+dispatch. +|.macro ins_NEXT2 +| decode_OP4 TMP1, INS +| decode_RB8 RB, INS +| decode_RD8 RD, INS +| lwzx TMP0, DISPATCH, TMP1 +| decode_RA8 RA, INS +| decode_RC8 RC, INS +| mtctr TMP0 +| bctr +|.endmacro +|.macro ins_NEXT +| ins_NEXT1 +| ins_NEXT2 +|.endmacro +| +|// Instruction footer. +|.if 1 +| // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. +| .define ins_next, ins_NEXT +| .define ins_next_, ins_NEXT +| .define ins_next1, ins_NEXT1 +| .define ins_next2, ins_NEXT2 +|.else +| // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. +| // Affects only certain kinds of benchmarks (and only with -j off). +| .macro ins_next +| b ->ins_next +| .endmacro +| .macro ins_next1 +| .endmacro +| .macro ins_next2 +| b ->ins_next +| .endmacro +| .macro ins_next_ +| ->ins_next: +| ins_NEXT +| .endmacro +|.endif +| +|// Call decode and dispatch. +|.macro ins_callt +| // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC +| lwz PC, LFUNC:RB->pc +| lwz INS, 0(PC) +| addi PC, PC, 4 +| decode_OP4 TMP1, INS +| decode_RA8 RA, INS +| lwzx TMP0, DISPATCH, TMP1 +| add RA, RA, BASE +| mtctr TMP0 +| bctr +|.endmacro +| +|.macro ins_call +| // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, PC = caller PC +| stw PC, FRAME_PC(BASE) +| ins_callt +|.endmacro +| +|//----------------------------------------------------------------------- +| +|// Macros to test operand types. +|.macro checknum, reg; evcmpltu reg, TISNUM; .endmacro +|.macro checkstr, reg; evcmpeq reg, TISSTR; .endmacro +|.macro checktab, reg; evcmpeq reg, TISTAB; .endmacro +|.macro checkfunc, reg; evcmpeq reg, TISFUNC; .endmacro +|.macro checknil, reg; evcmpeq reg, TISNIL; .endmacro +|.macro checkok, label; blt label; .endmacro +|.macro checkfail, label; bge label; .endmacro +|.macro checkanyfail, label; bns label; .endmacro +|.macro checkallok, label; bso label; .endmacro +| +|.macro branch_RD +| srwi TMP0, RD, 1 +| add PC, PC, TMP0 +| addis PC, PC, -(BCBIAS_J*4 >> 16) +|.endmacro +| +|// Assumes DISPATCH is relative to GL. +#define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) +#define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) +| +#define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) +| +|.macro hotloop +| NYI +|.endmacro +| +|.macro hotcall +| NYI +|.endmacro +| +|// Set current VM state. Uses TMP0. +|.macro li_vmstate, st; li TMP0, ~LJ_VMST_..st; .endmacro +|.macro st_vmstate; stw TMP0, DISPATCH_GL(vmstate)(DISPATCH); .endmacro +| +|// Move table write barrier back. Overwrites mark and tmp. +|.macro barrierback, tab, mark, tmp +| lwz tmp, DISPATCH_GL(gc.grayagain)(DISPATCH) +| // Assumes LJ_GC_BLACK is 0x04. +| rlwinm mark, mark, 0, 30, 28 // black2gray(tab) +| stw tab, DISPATCH_GL(gc.grayagain)(DISPATCH) +| stb mark, tab->marked +| stw tmp, tab->gclist +|.endmacro +| +|//----------------------------------------------------------------------- + +/* Generate subroutines used by opcodes and other parts of the VM. */ +/* The .code_sub section should be last to help static branch prediction. */ +static void build_subroutines(BuildCtx *ctx) +{ + |.code_sub + | + |//----------------------------------------------------------------------- + |//-- Return handling ---------------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_returnp: + | // See vm_return. Also: TMP2 = previous base. + | andi. TMP0, PC, FRAME_P + | evsplati TMP1, LJ_TTRUE + | beq ->cont_dispatch + | + | // Return from pcall or xpcall fast func. + | lwz PC, FRAME_PC(TMP2) // Fetch PC of previous frame. + | mr BASE, TMP2 // Restore caller base. + | // Prepending may overwrite the pcall frame, so do it at the end. + | stwu TMP1, FRAME_PC(RA) // Prepend true to results. + | + |->vm_returnc: + | addi RD, RD, 8 // RD = (nresults+1)*8. + | andi. TMP0, PC, FRAME_TYPE + | cmpwi cr1, RD, 0 + | li CRET1, LUA_YIELD + | beq cr1, ->vm_unwind_c_eh + | mr MULTRES, RD + | beq ->BC_RET_Z // Handle regular return to Lua. + | + |->vm_return: + | // BASE = base, RA = resultptr, RD/MULTRES = (nresults+1)*8, PC = return + | // TMP0 = PC & FRAME_TYPE + | cmpwi TMP0, FRAME_C + | rlwinm TMP2, PC, 0, 0, 28 + | li_vmstate C + | sub TMP2, BASE, TMP2 // TMP2 = previous base. + | bne ->vm_returnp + | + | addic. TMP1, RD, -8 + | stw TMP2, L->base + | lwz TMP2, SAVE_NRES + | subi BASE, BASE, 8 + | st_vmstate + | slwi TMP2, TMP2, 3 + | beq >2 + |1: + | addic. TMP1, TMP1, -8 + | evldd TMP0, 0(RA) + | addi RA, RA, 8 + | evstdd TMP0, 0(BASE) + | addi BASE, BASE, 8 + | bne <1 + | + |2: + | cmpw TMP2, RD // More/less results wanted? + | bne >6 + |3: + | stw BASE, L->top // Store new top. + | + |->vm_leave_cp: + | lwz TMP0, SAVE_CFRAME // Restore previous C frame. + | li CRET1, 0 // Ok return status for vm_pcall. + | stw TMP0, L->cframe + | + |->vm_leave_unw: + | restoreregs + | blr + | + |6: + | ble >7 // Less results wanted? + | // More results wanted. Check stack size and fill up results with nil. + | lwz TMP1, L->maxstack + | cmplw BASE, TMP1 + | bge >8 + | evstdd TISNIL, 0(BASE) + | addi RD, RD, 8 + | addi BASE, BASE, 8 + | b <2 + | + |7: // Less results wanted. + | sub TMP0, RD, TMP2 + | cmpwi TMP2, 0 // LUA_MULTRET+1 case? + | sub TMP0, BASE, TMP0 // Subtract the difference. + | iseleq BASE, BASE, TMP0 // Either keep top or shrink it. + | b <3 + | + |8: // Corner case: need to grow stack for filling up results. + | // This can happen if: + | // - A C function grows the stack (a lot). + | // - The GC shrinks the stack in between. + | // - A return back from a lua_call() with (high) nresults adjustment. + | stw BASE, L->top // Save current top held in BASE (yes). + | mr SAVE0, RD + | mr CARG2, TMP2 + | mr CARG1, L + | bl extern lj_state_growstack // (lua_State *L, int n) + | lwz TMP2, SAVE_NRES + | mr RD, SAVE0 + | slwi TMP2, TMP2, 3 + | lwz BASE, L->top // Need the (realloced) L->top in BASE. + | b <2 + | + |->vm_unwind_c: // Unwind C stack, return from vm_pcall. + | // (void *cframe, int errcode) + | mr sp, CARG1 + | mr CRET1, CARG2 + |->vm_unwind_c_eh: // Landing pad for external unwinder. + | lwz L, SAVE_L + | li TMP0, ~LJ_VMST_C + | lwz GL:TMP1, L->glref + | stw TMP0, GL:TMP1->vmstate + | b ->vm_leave_unw + | + |->vm_unwind_ff: // Unwind C stack, return from ff pcall. + | // (void *cframe) + | rlwinm sp, CARG1, 0, 0, 29 + |->vm_unwind_ff_eh: // Landing pad for external unwinder. + | lwz L, SAVE_L + | evsplati TISNUM, LJ_TISNUM+1 // Setup type comparison constants. + | evsplati TISFUNC, LJ_TFUNC + | lus TOBIT, 0x4338 + | evsplati TISTAB, LJ_TTAB + | li TMP0, 0 + | lwz BASE, L->base + | evmergelo TOBIT, TOBIT, TMP0 + | lwz DISPATCH, L->glref // Setup pointer to dispatch table. + | evsplati TISSTR, LJ_TSTR + | li TMP1, LJ_TFALSE + | evsplati TISNIL, LJ_TNIL + | li_vmstate INTERP + | lwz PC, FRAME_PC(BASE) // Fetch PC of previous frame. + | la RA, -8(BASE) // Results start at BASE-8. + | addi DISPATCH, DISPATCH, GG_G2DISP + | stw TMP1, 0(RA) // Prepend false to error message. + | li RD, 16 // 2 results: false + error message. + | st_vmstate + | b ->vm_returnc + | + |//----------------------------------------------------------------------- + |//-- Grow stack for calls ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_growstack_c: // Grow stack for C function. + | li CARG2, LUA_MINSTACK + | b >2 + | + |->vm_growstack_l: // Grow stack for Lua function. + | // BASE = new base, RA = BASE+framesize*8, RC = nargs*8, PC = first PC + | add RC, BASE, RC + | sub RA, RA, BASE + | stw BASE, L->base + | addi PC, PC, 4 // Must point after first instruction. + | stw RC, L->top + | srwi CARG2, RA, 3 + |2: + | // L->base = new base, L->top = top + | stw PC, SAVE_PC + | mr CARG1, L + | bl extern lj_state_growstack // (lua_State *L, int n) + | lwz BASE, L->base + | lwz RC, L->top + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | sub RC, RC, BASE + | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC + | ins_callt // Just retry the call. + | + |//----------------------------------------------------------------------- + |//-- Entry points into the assembler VM --------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_resume: // Setup C frame and resume thread. + | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) + | saveregs + | mr L, CARG1 + | lwz DISPATCH, L->glref // Setup pointer to dispatch table. + | mr BASE, CARG2 + | lbz TMP1, L->status + | stw L, SAVE_L + | li PC, FRAME_CP + | addi TMP0, sp, CFRAME_RESUME + | addi DISPATCH, DISPATCH, GG_G2DISP + | stw CARG3, SAVE_NRES + | cmplwi TMP1, 0 + | stw CARG3, SAVE_ERRF + | stw TMP0, L->cframe + | stw CARG3, SAVE_CFRAME + | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. + | beq >3 + | + | // Resume after yield (like a return). + | mr RA, BASE + | lwz BASE, L->base + | evsplati TISNUM, LJ_TISNUM+1 // Setup type comparison constants. + | lwz TMP1, L->top + | evsplati TISFUNC, LJ_TFUNC + | lus TOBIT, 0x4338 + | evsplati TISTAB, LJ_TTAB + | lwz PC, FRAME_PC(BASE) + | li TMP2, 0 + | evsplati TISSTR, LJ_TSTR + | sub RD, TMP1, BASE + | evmergelo TOBIT, TOBIT, TMP2 + | stb CARG3, L->status + | andi. TMP0, PC, FRAME_TYPE + | li_vmstate INTERP + | addi RD, RD, 8 + | evsplati TISNIL, LJ_TNIL + | mr MULTRES, RD + | st_vmstate + | beq ->BC_RET_Z + | b ->vm_return + | + |->vm_pcall: // Setup protected C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) + | saveregs + | li PC, FRAME_CP + | stw CARG4, SAVE_ERRF + | b >1 + | + |->vm_call: // Setup C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1) + | saveregs + | li PC, FRAME_C + | + |1: // Entry point for vm_pcall above (PC = ftype). + | lwz TMP1, L:CARG1->cframe + | stw CARG3, SAVE_NRES + | mr L, CARG1 + | stw CARG1, SAVE_L + | mr BASE, CARG2 + | stw sp, L->cframe // Add our C frame to cframe chain. + | lwz DISPATCH, L->glref // Setup pointer to dispatch table. + | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. + | stw TMP1, SAVE_CFRAME + | addi DISPATCH, DISPATCH, GG_G2DISP + | + |3: // Entry point for vm_cpcall/vm_resume (BASE = base, PC = ftype). + | lwz TMP2, L->base // TMP2 = old base (used in vmeta_call). + | evsplati TISNUM, LJ_TISNUM+1 // Setup type comparison constants. + | lwz TMP1, L->top + | evsplati TISFUNC, LJ_TFUNC + | add PC, PC, BASE + | evsplati TISTAB, LJ_TTAB + | lus TOBIT, 0x4338 + | li TMP0, 0 + | sub PC, PC, TMP2 // PC = frame delta + frame type + | evsplati TISSTR, LJ_TSTR + | sub NARGS8:RC, TMP1, BASE + | evmergelo TOBIT, TOBIT, TMP0 + | li_vmstate INTERP + | evsplati TISNIL, LJ_TNIL + | st_vmstate + | + |->vm_call_dispatch: + | // TMP2 = old base, BASE = new base, RC = nargs*8, PC = caller PC + | li TMP0, -8 + | evlddx LFUNC:RB, BASE, TMP0 + | checkfunc LFUNC:RB + | checkfail ->vmeta_call + | + |->vm_call_dispatch_f: + | ins_call + | // BASE = new base, RB = func, RC = nargs*8, PC = caller PC + | + |->vm_cpcall: // Setup protected C frame, call C. + | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) + | saveregs + | mr L, CARG1 + | lwz TMP0, L:CARG1->stack + | stw CARG1, SAVE_L + | lwz TMP1, L->top + | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. + | sub TMP0, TMP0, TMP1 // Compute -savestack(L, L->top). + | lwz TMP1, L->cframe + | stw sp, L->cframe // Add our C frame to cframe chain. + | li TMP2, 0 + | stw TMP0, SAVE_NRES // Neg. delta means cframe w/o frame. + | stw TMP2, SAVE_ERRF // No error function. + | stw TMP1, SAVE_CFRAME + | mtctr CARG4 + | bctrl // (lua_State *L, lua_CFunction func, void *ud) + | mr. BASE, CRET1 + | lwz DISPATCH, L->glref // Setup pointer to dispatch table. + | li PC, FRAME_CP + | addi DISPATCH, DISPATCH, GG_G2DISP + | bne <3 // Else continue with the call. + | b ->vm_leave_cp // No base? Just remove C frame. + | + |//----------------------------------------------------------------------- + |//-- Metamethod handling ------------------------------------------------ + |//----------------------------------------------------------------------- + | + |// The lj_meta_* functions (except for lj_meta_cat) don't reallocate the + |// stack, so BASE doesn't need to be reloaded across these calls. + | + |//-- Continuation dispatch ---------------------------------------------- + | + |->cont_dispatch: + | // BASE = meta base, RA = resultptr, RD = (nresults+1)*8 + | lwz TMP0, -12(BASE) // Continuation. + | mr RB, BASE + | mr BASE, TMP2 // Restore caller BASE. + | lwz LFUNC:TMP1, FRAME_FUNC(TMP2) + | cmplwi TMP0, 0 + | lwz PC, -16(RB) // Restore PC from [cont|PC]. + | beq >1 + | subi TMP2, RD, 8 + | lwz TMP1, LFUNC:TMP1->pc + | evstddx TISNIL, RA, TMP2 // Ensure one valid arg. + | lwz KBASE, PC2PROTO(k)(TMP1) + | // BASE = base, RA = resultptr, RB = meta base + | mtctr TMP0 + | bctr // Jump to continuation. + | + |1: // Tail call from C function. + | subi TMP1, RB, 16 + | sub RC, TMP1, BASE + | b ->vm_call_tail + | + |->cont_cat: // RA = resultptr, RB = meta base + | lwz INS, -4(PC) + | subi CARG2, RB, 16 + | decode_RB8 SAVE0, INS + | evldd TMP0, 0(RA) + | add TMP1, BASE, SAVE0 + | stw BASE, L->base + | cmplw TMP1, CARG2 + | sub CARG3, CARG2, TMP1 + | decode_RA8 RA, INS + | evstdd TMP0, 0(CARG2) + | bne ->BC_CAT_Z + | evstddx TMP0, BASE, RA + | b ->cont_nop + | + |//-- Table indexing metamethods ----------------------------------------- + | + |->vmeta_tgets1: + | evmergelo STR:RC, TISSTR, STR:RC + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | decode_RB8 RB, INS + | evstdd STR:RC, 0(CARG3) + | add CARG2, BASE, RB + | b >1 + | + |->vmeta_tgets: + | evmergelo TAB:RB, TISTAB, TAB:RB + | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) + | evmergelo STR:RC, TISSTR, STR:RC + | evstdd TAB:RB, 0(CARG2) + | la CARG3, DISPATCH_GL(tmptv2)(DISPATCH) + | evstdd STR:RC, 0(CARG3) + | b >1 + | + |->vmeta_tgetb: // TMP0 = index + | efdcfsi TMP0, TMP0 + | decode_RB8 RB, INS + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | add CARG2, BASE, RB + | evstdd TMP0, 0(CARG3) + | b >1 + | + |->vmeta_tgetv: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | add CARG2, BASE, RB + | add CARG3, BASE, RC + |1: + | stw BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | bl extern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) + | // Returns TValue * (finished) or NULL (metamethod). + | cmplwi CRET1, 0 + | beq >3 + | evldd TMP0, 0(CRET1) + | evstddx TMP0, BASE, RA + | ins_next + | + |3: // Call __index metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k + | subfic TMP1, BASE, FRAME_CONT + | lwz BASE, L->top + | stw PC, -16(BASE) // [cont|PC] + | add PC, TMP1, BASE + | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. + | li NARGS8:RC, 16 // 2 args for func(t, k). + | b ->vm_call_dispatch_f + | + |//----------------------------------------------------------------------- + | + |->vmeta_tsets1: + | evmergelo STR:RC, TISSTR, STR:RC + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | decode_RB8 RB, INS + | evstdd STR:RC, 0(CARG3) + | add CARG2, BASE, RB + | b >1 + | + |->vmeta_tsets: + | evmergelo TAB:RB, TISTAB, TAB:RB + | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) + | evmergelo STR:RC, TISSTR, STR:RC + | evstdd TAB:RB, 0(CARG2) + | la CARG3, DISPATCH_GL(tmptv2)(DISPATCH) + | evstdd STR:RC, 0(CARG3) + | b >1 + | + |->vmeta_tsetb: // TMP0 = index + | efdcfsi TMP0, TMP0 + | decode_RB8 RB, INS + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | add CARG2, BASE, RB + | evstdd TMP0, 0(CARG3) + | b >1 + | + |->vmeta_tsetv: + | decode_RB8 RB, INS + | decode_RC8 RC, INS + | add CARG2, BASE, RB + | add CARG3, BASE, RC + |1: + | stw BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | bl extern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) + | // Returns TValue * (finished) or NULL (metamethod). + | cmplwi CRET1, 0 + | evlddx TMP0, BASE, RA + | beq >3 + | // NOBARRIER: lj_meta_tset ensures the table is not black. + | evstdd TMP0, 0(CRET1) + | ins_next + | + |3: // Call __newindex metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) + | subfic TMP1, BASE, FRAME_CONT + | lwz BASE, L->top + | stw PC, -16(BASE) // [cont|PC] + | add PC, TMP1, BASE + | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. + | li NARGS8:RC, 24 // 3 args for func(t, k, v) + | evstdd TMP0, 16(BASE) // Copy value to third argument. + | b ->vm_call_dispatch_f + | + |//-- Comparison metamethods --------------------------------------------- + | + |->vmeta_comp: + | mr CARG1, L + | subi PC, PC, 4 + | add CARG2, BASE, RA + | stw PC, SAVE_PC + | add CARG3, BASE, RD + | stw BASE, L->base + | decode_OP1 CARG4, INS + | bl extern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) + | // Returns 0/1 or TValue * (metamethod). + |3: + | cmplwi CRET1, 1 + | bgt ->vmeta_binop + |4: + | lwz INS, 0(PC) + | addi PC, PC, 4 + | decode_RD4 TMP2, INS + | addis TMP3, PC, -(BCBIAS_J*4 >> 16) + | add TMP2, TMP2, TMP3 + | isellt PC, PC, TMP2 + |->cont_nop: + | ins_next + | + |->cont_ra: // RA = resultptr + | lwz INS, -4(PC) + | evldd TMP0, 0(RA) + | decode_RA8 TMP1, INS + | evstddx TMP0, BASE, TMP1 + | b ->cont_nop + | + |->cont_condt: // RA = resultptr + | lwz TMP0, 0(RA) + | li TMP1, LJ_TTRUE + | cmplw TMP1, TMP0 // Branch if result is true. + | b <4 + | + |->cont_condf: // RA = resultptr + | lwz TMP0, 0(RA) + | li TMP1, LJ_TFALSE + | cmplw TMP0, TMP1 // Branch if result is false. + | b <4 + | + |->vmeta_equal: + | // CARG2, CARG3, CARG4 are already set by BC_ISEQV/BC_ISNEV. + | subi PC, PC, 4 + | stw BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | bl extern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) + | // Returns 0/1 or TValue * (metamethod). + | b <3 + | + |//-- Arithmetic metamethods --------------------------------------------- + | + |->vmeta_arith_vn: + | add CARG3, BASE, RB + | add CARG4, KBASE, RC + | b >1 + | + |->vmeta_arith_nv: + | add CARG3, KBASE, RC + | add CARG4, BASE, RB + | b >1 + | + |->vmeta_unm: + | add CARG3, BASE, RD + | mr CARG4, CARG3 + | b >1 + | + |->vmeta_arith_vv: + | add CARG3, BASE, RB + | add CARG4, BASE, RC + |1: + | add CARG2, BASE, RA + | stw BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | decode_OP1 CARG5, INS // Caveat: CARG5 overlaps INS. + | bl extern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) + | // Returns NULL (finished) or TValue * (metamethod). + | cmplwi CRET1, 0 + | beq ->cont_nop + | + | // Call metamethod for binary op. + |->vmeta_binop: + | // BASE = old base, CRET1 = new base, stack = cont/func/o1/o2 + | sub TMP1, CRET1, BASE + | stw PC, -16(CRET1) // [cont|PC] + | mr TMP2, BASE + | addi PC, TMP1, FRAME_CONT + | mr BASE, CRET1 + | li NARGS8:RC, 16 // 2 args for func(o1, o2). + | b ->vm_call_dispatch + | + |->vmeta_len: +#if LJ_52 + | mr SAVE0, CARG1 +#endif + | add CARG2, BASE, RD + | stw BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | bl extern lj_meta_len // (lua_State *L, TValue *o) + | // Returns NULL (retry) or TValue * (metamethod base). +#if LJ_52 + | cmplwi CRET1, 0 + | bne ->vmeta_binop // Binop call for compatibility. + | mr CARG1, SAVE0 + | b ->BC_LEN_Z +#else + | b ->vmeta_binop // Binop call for compatibility. +#endif + | + |//-- Call metamethod ---------------------------------------------------- + | + |->vmeta_call: // Resolve and call __call metamethod. + | // TMP2 = old base, BASE = new base, RC = nargs*8 + | mr CARG1, L + | stw TMP2, L->base // This is the callers base! + | subi CARG2, BASE, 8 + | stw PC, SAVE_PC + | add CARG3, BASE, RC + | mr SAVE0, NARGS8:RC + | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) + | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. + | addi NARGS8:RC, SAVE0, 8 // Got one more argument now. + | ins_call + | + |->vmeta_callt: // Resolve __call for BC_CALLT. + | // BASE = old base, RA = new base, RC = nargs*8 + | mr CARG1, L + | stw BASE, L->base + | subi CARG2, RA, 8 + | stw PC, SAVE_PC + | add CARG3, RA, RC + | mr SAVE0, NARGS8:RC + | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) + | lwz TMP1, FRAME_PC(BASE) + | addi NARGS8:RC, SAVE0, 8 // Got one more argument now. + | lwz LFUNC:RB, FRAME_FUNC(RA) // Guaranteed to be a function here. + | b ->BC_CALLT_Z + | + |//-- Argument coercion for 'for' statement ------------------------------ + | + |->vmeta_for: + | mr CARG1, L + | stw BASE, L->base + | mr CARG2, RA + | stw PC, SAVE_PC + | mr SAVE0, INS + | bl extern lj_meta_for // (lua_State *L, TValue *base) + |.if JIT + | decode_OP1 TMP0, SAVE0 + |.endif + | decode_RA8 RA, SAVE0 + |.if JIT + | cmpwi TMP0, BC_JFORI + |.endif + | decode_RD8 RD, SAVE0 + |.if JIT + | beq =>BC_JFORI + |.endif + | b =>BC_FORI + | + |//----------------------------------------------------------------------- + |//-- Fast functions ----------------------------------------------------- + |//----------------------------------------------------------------------- + | + |.macro .ffunc, name + |->ff_ .. name: + |.endmacro + | + |.macro .ffunc_1, name + |->ff_ .. name: + | cmplwi NARGS8:RC, 8 + | evldd CARG1, 0(BASE) + | blt ->fff_fallback + |.endmacro + | + |.macro .ffunc_2, name + |->ff_ .. name: + | cmplwi NARGS8:RC, 16 + | evldd CARG1, 0(BASE) + | evldd CARG2, 8(BASE) + | blt ->fff_fallback + |.endmacro + | + |.macro .ffunc_n, name + | .ffunc_1 name + | checknum CARG1 + | checkfail ->fff_fallback + |.endmacro + | + |.macro .ffunc_nn, name + | .ffunc_2 name + | evmergehi TMP0, CARG1, CARG2 + | checknum TMP0 + | checkanyfail ->fff_fallback + |.endmacro + | + |// Inlined GC threshold check. Caveat: uses TMP0 and TMP1. + |.macro ffgccheck + | lwz TMP0, DISPATCH_GL(gc.total)(DISPATCH) + | lwz TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) + | cmplw TMP0, TMP1 + | bgel ->fff_gcstep + |.endmacro + | + |//-- Base library: checks ----------------------------------------------- + | + |.ffunc assert + | cmplwi NARGS8:RC, 8 + | evldd TMP0, 0(BASE) + | blt ->fff_fallback + | evaddw TMP1, TISNIL, TISNIL // Synthesize LJ_TFALSE. + | la RA, -8(BASE) + | evcmpltu cr1, TMP0, TMP1 + | lwz PC, FRAME_PC(BASE) + | bge cr1, ->fff_fallback + | evstdd TMP0, 0(RA) + | addi RD, NARGS8:RC, 8 // Compute (nresults+1)*8. + | beq ->fff_res // Done if exactly 1 argument. + | li TMP1, 8 + | subi RC, RC, 8 + |1: + | cmplw TMP1, RC + | evlddx TMP0, BASE, TMP1 + | evstddx TMP0, RA, TMP1 + | addi TMP1, TMP1, 8 + | bne <1 + | b ->fff_res + | + |.ffunc type + | cmplwi NARGS8:RC, 8 + | lwz CARG1, 0(BASE) + | blt ->fff_fallback + | li TMP2, ~LJ_TNUMX + | cmplw CARG1, TISNUM + | not TMP1, CARG1 + | isellt TMP1, TMP2, TMP1 + | slwi TMP1, TMP1, 3 + | la TMP2, CFUNC:RB->upvalue + | evlddx STR:CRET1, TMP2, TMP1 + | b ->fff_restv + | + |//-- Base library: getters and setters --------------------------------- + | + |.ffunc_1 getmetatable + | checktab CARG1 + | evmergehi TMP1, CARG1, CARG1 + | checkfail >6 + |1: // Field metatable must be at same offset for GCtab and GCudata! + | lwz TAB:RB, TAB:CARG1->metatable + |2: + | evmr CRET1, TISNIL + | cmplwi TAB:RB, 0 + | lwz STR:RC, DISPATCH_GL(gcroot[GCROOT_MMNAME+MM_metatable])(DISPATCH) + | beq ->fff_restv + | lwz TMP0, TAB:RB->hmask + | evmergelo CRET1, TISTAB, TAB:RB // Use metatable as default result. + | lwz TMP1, STR:RC->hash + | lwz NODE:TMP2, TAB:RB->node + | evmergelo STR:RC, TISSTR, STR:RC + | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask + | slwi TMP0, TMP1, 5 + | slwi TMP1, TMP1, 3 + | sub TMP1, TMP0, TMP1 + | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) + |3: // Rearranged logic, because we expect _not_ to find the key. + | evldd TMP0, NODE:TMP2->key + | evldd TMP1, NODE:TMP2->val + | evcmpeq TMP0, STR:RC + | lwz NODE:TMP2, NODE:TMP2->next + | checkallok >5 + | cmplwi NODE:TMP2, 0 + | beq ->fff_restv // Not found, keep default result. + | b <3 + |5: + | checknil TMP1 + | checkok ->fff_restv // Ditto for nil value. + | evmr CRET1, TMP1 // Return value of mt.__metatable. + | b ->fff_restv + | + |6: + | cmpwi TMP1, LJ_TUDATA + | not TMP1, TMP1 + | beq <1 + | checknum CARG1 + | slwi TMP1, TMP1, 2 + | li TMP2, 4*~LJ_TNUMX + | isellt TMP1, TMP2, TMP1 + | la TMP2, DISPATCH_GL(gcroot[GCROOT_BASEMT])(DISPATCH) + | lwzx TAB:RB, TMP2, TMP1 + | b <2 + | + |.ffunc_2 setmetatable + | // Fast path: no mt for table yet and not clearing the mt. + | evmergehi TMP0, TAB:CARG1, TAB:CARG2 + | checktab TMP0 + | checkanyfail ->fff_fallback + | lwz TAB:TMP1, TAB:CARG1->metatable + | cmplwi TAB:TMP1, 0 + | lbz TMP3, TAB:CARG1->marked + | bne ->fff_fallback + | andi. TMP0, TMP3, LJ_GC_BLACK // isblack(table) + | stw TAB:CARG2, TAB:CARG1->metatable + | beq ->fff_restv + | barrierback TAB:CARG1, TMP3, TMP0 + | b ->fff_restv + | + |.ffunc rawget + | cmplwi NARGS8:RC, 16 + | evldd CARG2, 0(BASE) + | blt ->fff_fallback + | checktab CARG2 + | la CARG3, 8(BASE) + | checkfail ->fff_fallback + | mr CARG1, L + | bl extern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) + | // Returns cTValue *. + | evldd CRET1, 0(CRET1) + | b ->fff_restv + | + |//-- Base library: conversions ------------------------------------------ + | + |.ffunc tonumber + | // Only handles the number case inline (without a base argument). + | cmplwi NARGS8:RC, 8 + | evldd CARG1, 0(BASE) + | bne ->fff_fallback // Exactly one argument. + | checknum CARG1 + | checkok ->fff_restv + | b ->fff_fallback + | + |.ffunc_1 tostring + | // Only handles the string or number case inline. + | checkstr CARG1 + | // A __tostring method in the string base metatable is ignored. + | checkok ->fff_restv // String key? + | // Handle numbers inline, unless a number base metatable is present. + | lwz TMP0, DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])(DISPATCH) + | checknum CARG1 + | cmplwi cr1, TMP0, 0 + | stw BASE, L->base // Add frame since C call can throw. + | crand 4*cr0+eq, 4*cr0+lt, 4*cr1+eq + | stw PC, SAVE_PC // Redundant (but a defined value). + | bne ->fff_fallback + | ffgccheck + | mr CARG1, L + | mr CARG2, BASE + | bl extern lj_str_fromnum // (lua_State *L, lua_Number *np) + | // Returns GCstr *. + | evmergelo STR:CRET1, TISSTR, STR:CRET1 + | b ->fff_restv + | + |//-- Base library: iterators ------------------------------------------- + | + |.ffunc next + | cmplwi NARGS8:RC, 8 + | evldd CARG2, 0(BASE) + | blt ->fff_fallback + | evstddx TISNIL, BASE, NARGS8:RC // Set missing 2nd arg to nil. + | checktab TAB:CARG2 + | lwz PC, FRAME_PC(BASE) + | checkfail ->fff_fallback + | stw BASE, L->base // Add frame since C call can throw. + | mr CARG1, L + | stw BASE, L->top // Dummy frame length is ok. + | la CARG3, 8(BASE) + | stw PC, SAVE_PC + | bl extern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) + | // Returns 0 at end of traversal. + | cmplwi CRET1, 0 + | evmr CRET1, TISNIL + | beq ->fff_restv // End of traversal: return nil. + | evldd TMP0, 8(BASE) // Copy key and value to results. + | la RA, -8(BASE) + | evldd TMP1, 16(BASE) + | evstdd TMP0, 0(RA) + | li RD, (2+1)*8 + | evstdd TMP1, 8(RA) + | b ->fff_res + | + |.ffunc_1 pairs + | checktab TAB:CARG1 + | lwz PC, FRAME_PC(BASE) + | checkfail ->fff_fallback +#if LJ_52 + | lwz TAB:TMP2, TAB:CARG1->metatable + | evldd CFUNC:TMP0, CFUNC:RB->upvalue[0] + | cmplwi TAB:TMP2, 0 + | la RA, -8(BASE) + | bne ->fff_fallback +#else + | evldd CFUNC:TMP0, CFUNC:RB->upvalue[0] + | la RA, -8(BASE) +#endif + | evstdd TISNIL, 8(BASE) + | li RD, (3+1)*8 + | evstdd CFUNC:TMP0, 0(RA) + | b ->fff_res + | + |.ffunc_2 ipairs_aux + | checktab TAB:CARG1 + | lwz PC, FRAME_PC(BASE) + | checkfail ->fff_fallback + | checknum CARG2 + | lus TMP3, 0x3ff0 + | checkfail ->fff_fallback + | efdctsi TMP2, CARG2 + | lwz TMP0, TAB:CARG1->asize + | evmergelo TMP3, TMP3, ZERO + | lwz TMP1, TAB:CARG1->array + | efdadd CARG2, CARG2, TMP3 + | addi TMP2, TMP2, 1 + | la RA, -8(BASE) + | cmplw TMP0, TMP2 + | slwi TMP3, TMP2, 3 + | evstdd CARG2, 0(RA) + | ble >2 // Not in array part? + | evlddx TMP1, TMP1, TMP3 + |1: + | checknil TMP1 + | li RD, (0+1)*8 + | checkok ->fff_res // End of iteration, return 0 results. + | li RD, (2+1)*8 + | evstdd TMP1, 8(RA) + | b ->fff_res + |2: // Check for empty hash part first. Otherwise call C function. + | lwz TMP0, TAB:CARG1->hmask + | cmplwi TMP0, 0 + | li RD, (0+1)*8 + | beq ->fff_res + | mr CARG2, TMP2 + | bl extern lj_tab_getinth // (GCtab *t, int32_t key) + | // Returns cTValue * or NULL. + | cmplwi CRET1, 0 + | li RD, (0+1)*8 + | beq ->fff_res + | evldd TMP1, 0(CRET1) + | b <1 + | + |.ffunc_1 ipairs + | checktab TAB:CARG1 + | lwz PC, FRAME_PC(BASE) + | checkfail ->fff_fallback +#if LJ_52 + | lwz TAB:TMP2, TAB:CARG1->metatable + | evldd CFUNC:TMP0, CFUNC:RB->upvalue[0] + | cmplwi TAB:TMP2, 0 + | la RA, -8(BASE) + | bne ->fff_fallback +#else + | evldd CFUNC:TMP0, CFUNC:RB->upvalue[0] + | la RA, -8(BASE) +#endif + | evsplati TMP1, 0 + | li RD, (3+1)*8 + | evstdd TMP1, 8(BASE) + | evstdd CFUNC:TMP0, 0(RA) + | b ->fff_res + | + |//-- Base library: catch errors ---------------------------------------- + | + |.ffunc pcall + | cmplwi NARGS8:RC, 8 + | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | blt ->fff_fallback + | mr TMP2, BASE + | la BASE, 8(BASE) + | // Remember active hook before pcall. + | rlwinm TMP3, TMP3, 32-HOOK_ACTIVE_SHIFT, 31, 31 + | subi NARGS8:RC, NARGS8:RC, 8 + | addi PC, TMP3, 8+FRAME_PCALL + | b ->vm_call_dispatch + | + |.ffunc_2 xpcall + | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | mr TMP2, BASE + | checkfunc CARG2 // Traceback must be a function. + | checkfail ->fff_fallback + | la BASE, 16(BASE) + | // Remember active hook before pcall. + | rlwinm TMP3, TMP3, 32-HOOK_ACTIVE_SHIFT, 31, 31 + | evstdd CARG2, 0(TMP2) // Swap function and traceback. + | subi NARGS8:RC, NARGS8:RC, 16 + | evstdd CARG1, 8(TMP2) + | addi PC, TMP3, 16+FRAME_PCALL + | b ->vm_call_dispatch + | + |//-- Coroutine library -------------------------------------------------- + | + |.macro coroutine_resume_wrap, resume + |.if resume + |.ffunc_1 coroutine_resume + | evmergehi TMP0, L:CARG1, L:CARG1 + |.else + |.ffunc coroutine_wrap_aux + | lwz L:CARG1, CFUNC:RB->upvalue[0].gcr + |.endif + |.if resume + | cmpwi TMP0, LJ_TTHREAD + | bne ->fff_fallback + |.endif + | lbz TMP0, L:CARG1->status + | lwz TMP1, L:CARG1->cframe + | lwz CARG2, L:CARG1->top + | cmplwi cr0, TMP0, LUA_YIELD + | lwz TMP2, L:CARG1->base + | cmplwi cr1, TMP1, 0 + | lwz TMP0, L:CARG1->maxstack + | cmplw cr7, CARG2, TMP2 + | lwz PC, FRAME_PC(BASE) + | crorc 4*cr6+lt, 4*cr0+gt, 4*cr1+eq // st>LUA_YIELD || cframe!=0 + | add TMP2, CARG2, NARGS8:RC + | crandc 4*cr6+gt, 4*cr7+eq, 4*cr0+eq // base==top && st!=LUA_YIELD + | cmplw cr1, TMP2, TMP0 + | cror 4*cr6+lt, 4*cr6+lt, 4*cr6+gt + | stw PC, SAVE_PC + | cror 4*cr6+lt, 4*cr6+lt, 4*cr1+gt // cond1 || cond2 || stackov + | stw BASE, L->base + | blt cr6, ->fff_fallback + |1: + |.if resume + | addi BASE, BASE, 8 // Keep resumed thread in stack for GC. + | subi NARGS8:RC, NARGS8:RC, 8 + | subi TMP2, TMP2, 8 + |.endif + | stw TMP2, L:CARG1->top + | li TMP1, 0 + | stw BASE, L->top + |2: // Move args to coroutine. + | cmpw TMP1, NARGS8:RC + | evlddx TMP0, BASE, TMP1 + | beq >3 + | evstddx TMP0, CARG2, TMP1 + | addi TMP1, TMP1, 8 + | b <2 + |3: + | li CARG3, 0 + | mr L:SAVE0, L:CARG1 + | li CARG4, 0 + | bl ->vm_resume // (lua_State *L, TValue *base, 0, 0) + | // Returns thread status. + |4: + | lwz TMP2, L:SAVE0->base + | cmplwi CRET1, LUA_YIELD + | lwz TMP3, L:SAVE0->top + | li_vmstate INTERP + | lwz BASE, L->base + | st_vmstate + | bgt >8 + | sub RD, TMP3, TMP2 + | lwz TMP0, L->maxstack + | cmplwi RD, 0 + | add TMP1, BASE, RD + | beq >6 // No results? + | cmplw TMP1, TMP0 + | li TMP1, 0 + | bgt >9 // Need to grow stack? + | + | subi TMP3, RD, 8 + | stw TMP2, L:SAVE0->top // Clear coroutine stack. + |5: // Move results from coroutine. + | cmplw TMP1, TMP3 + | evlddx TMP0, TMP2, TMP1 + | evstddx TMP0, BASE, TMP1 + | addi TMP1, TMP1, 8 + | bne <5 + |6: + | andi. TMP0, PC, FRAME_TYPE + |.if resume + | li TMP1, LJ_TTRUE + | la RA, -8(BASE) + | stw TMP1, -8(BASE) // Prepend true to results. + | addi RD, RD, 16 + |.else + | mr RA, BASE + | addi RD, RD, 8 + |.endif + |7: + | stw PC, SAVE_PC + | mr MULTRES, RD + | beq ->BC_RET_Z + | b ->vm_return + | + |8: // Coroutine returned with error (at co->top-1). + |.if resume + | andi. TMP0, PC, FRAME_TYPE + | la TMP3, -8(TMP3) + | li TMP1, LJ_TFALSE + | evldd TMP0, 0(TMP3) + | stw TMP3, L:SAVE0->top // Remove error from coroutine stack. + | li RD, (2+1)*8 + | stw TMP1, -8(BASE) // Prepend false to results. + | la RA, -8(BASE) + | evstdd TMP0, 0(BASE) // Copy error message. + | b <7 + |.else + | mr CARG1, L + | mr CARG2, L:SAVE0 + | bl extern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co) + |.endif + | + |9: // Handle stack expansion on return from yield. + | mr CARG1, L + | srwi CARG2, RD, 3 + | bl extern lj_state_growstack // (lua_State *L, int n) + | li CRET1, 0 + | b <4 + |.endmacro + | + | coroutine_resume_wrap 1 // coroutine.resume + | coroutine_resume_wrap 0 // coroutine.wrap + | + |.ffunc coroutine_yield + | lwz TMP0, L->cframe + | add TMP1, BASE, NARGS8:RC + | stw BASE, L->base + | andi. TMP0, TMP0, CFRAME_RESUME + | stw TMP1, L->top + | li CRET1, LUA_YIELD + | beq ->fff_fallback + | stw ZERO, L->cframe + | stb CRET1, L->status + | b ->vm_leave_unw + | + |//-- Math library ------------------------------------------------------- + | + |.ffunc_n math_abs + | efdabs CRET1, CARG1 + | // Fallthrough. + | + |->fff_restv: + | // CRET1 = TValue result. + | lwz PC, FRAME_PC(BASE) + | la RA, -8(BASE) + | evstdd CRET1, 0(RA) + |->fff_res1: + | // RA = results, PC = return. + | li RD, (1+1)*8 + |->fff_res: + | // RA = results, RD = (nresults+1)*8, PC = return. + | andi. TMP0, PC, FRAME_TYPE + | mr MULTRES, RD + | bne ->vm_return + | lwz INS, -4(PC) + | decode_RB8 RB, INS + |5: + | cmplw RB, RD // More results expected? + | decode_RA8 TMP0, INS + | bgt >6 + | ins_next1 + | // Adjust BASE. KBASE is assumed to be set for the calling frame. + | sub BASE, RA, TMP0 + | ins_next2 + | + |6: // Fill up results with nil. + | subi TMP1, RD, 8 + | addi RD, RD, 8 + | evstddx TISNIL, RA, TMP1 + | b <5 + | + |.macro math_extern, func + | .ffunc math_ .. func + | cmplwi NARGS8:RC, 8 + | evldd CARG2, 0(BASE) + | blt ->fff_fallback + | checknum CARG2 + | evmergehi CARG1, CARG2, CARG2 + | checkfail ->fff_fallback + | bl extern func@plt + | evmergelo CRET1, CRET1, CRET2 + | b ->fff_restv + |.endmacro + | + |.macro math_extern2, func + | .ffunc math_ .. func + | cmplwi NARGS8:RC, 16 + | evldd CARG2, 0(BASE) + | evldd CARG4, 8(BASE) + | blt ->fff_fallback + | evmergehi CARG1, CARG4, CARG2 + | checknum CARG1 + | evmergehi CARG3, CARG4, CARG4 + | checkanyfail ->fff_fallback + | bl extern func@plt + | evmergelo CRET1, CRET1, CRET2 + | b ->fff_restv + |.endmacro + | + |.macro math_round, func + | .ffunc math_ .. func + | cmplwi NARGS8:RC, 8 + | evldd CARG2, 0(BASE) + | blt ->fff_fallback + | checknum CARG2 + | evmergehi CARG1, CARG2, CARG2 + | checkfail ->fff_fallback + | lwz PC, FRAME_PC(BASE) + | bl ->vm_..func.._hilo; + | la RA, -8(BASE) + | evstdd CRET2, 0(RA) + | b ->fff_res1 + |.endmacro + | + | math_round floor + | math_round ceil + | + | math_extern sqrt + | + |.ffunc math_log + | cmplwi NARGS8:RC, 8 + | evldd CARG2, 0(BASE) + | bne ->fff_fallback // Need exactly 1 argument. + | checknum CARG2 + | evmergehi CARG1, CARG2, CARG2 + | checkfail ->fff_fallback + | bl extern log@plt + | evmergelo CRET1, CRET1, CRET2 + | b ->fff_restv + | + | math_extern log10 + | math_extern exp + | math_extern sin + | math_extern cos + | math_extern tan + | math_extern asin + | math_extern acos + | math_extern atan + | math_extern sinh + | math_extern cosh + | math_extern tanh + | math_extern2 pow + | math_extern2 atan2 + | math_extern2 fmod + | + |->ff_math_deg: + |.ffunc_n math_rad + | evldd CARG2, CFUNC:RB->upvalue[0] + | efdmul CRET1, CARG1, CARG2 + | b ->fff_restv + | + |.ffunc math_ldexp + | cmplwi NARGS8:RC, 16 + | evldd CARG2, 0(BASE) + | evldd CARG4, 8(BASE) + | blt ->fff_fallback + | evmergehi CARG1, CARG4, CARG2 + | checknum CARG1 + | checkanyfail ->fff_fallback + | efdctsi CARG3, CARG4 + | bl extern ldexp@plt + | evmergelo CRET1, CRET1, CRET2 + | b ->fff_restv + | + |.ffunc math_frexp + | cmplwi NARGS8:RC, 8 + | evldd CARG2, 0(BASE) + | blt ->fff_fallback + | checknum CARG2 + | evmergehi CARG1, CARG2, CARG2 + | checkfail ->fff_fallback + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | lwz PC, FRAME_PC(BASE) + | bl extern frexp@plt + | lwz TMP1, DISPATCH_GL(tmptv)(DISPATCH) + | evmergelo CRET1, CRET1, CRET2 + | efdcfsi CRET2, TMP1 + | la RA, -8(BASE) + | evstdd CRET1, 0(RA) + | li RD, (2+1)*8 + | evstdd CRET2, 8(RA) + | b ->fff_res + | + |.ffunc math_modf + | cmplwi NARGS8:RC, 8 + | evldd CARG2, 0(BASE) + | blt ->fff_fallback + | checknum CARG2 + | evmergehi CARG1, CARG2, CARG2 + | checkfail ->fff_fallback + | la CARG3, -8(BASE) + | lwz PC, FRAME_PC(BASE) + | bl extern modf@plt + | evmergelo CRET1, CRET1, CRET2 + | la RA, -8(BASE) + | evstdd CRET1, 0(BASE) + | li RD, (2+1)*8 + | b ->fff_res + | + |.macro math_minmax, name, cmpop + | .ffunc_1 name + | checknum CARG1 + | li TMP1, 8 + | checkfail ->fff_fallback + |1: + | evlddx CARG2, BASE, TMP1 + | cmplw cr1, TMP1, NARGS8:RC + | checknum CARG2 + | bge cr1, ->fff_restv // Ok, since CRET1 = CARG1. + | checkfail ->fff_fallback + | cmpop CARG2, CARG1 + | addi TMP1, TMP1, 8 + | crmove 4*cr0+lt, 4*cr0+gt + | evsel CARG1, CARG2, CARG1 + | b <1 + |.endmacro + | + | math_minmax math_min, efdtstlt + | math_minmax math_max, efdtstgt + | + |//-- String library ----------------------------------------------------- + | + |.ffunc_1 string_len + | checkstr STR:CARG1 + | checkfail ->fff_fallback + | lwz TMP0, STR:CARG1->len + | efdcfsi CRET1, TMP0 + | b ->fff_restv + | + |.ffunc string_byte // Only handle the 1-arg case here. + | cmplwi NARGS8:RC, 8 + | evldd STR:CARG1, 0(BASE) + | bne ->fff_fallback // Need exactly 1 argument. + | checkstr STR:CARG1 + | la RA, -8(BASE) + | checkfail ->fff_fallback + | lwz TMP0, STR:CARG1->len + | li RD, (0+1)*8 + | lbz TMP1, STR:CARG1[1] // Access is always ok (NUL at end). + | li TMP2, (1+1)*8 + | cmplwi TMP0, 0 + | lwz PC, FRAME_PC(BASE) + | efdcfsi CRET1, TMP1 + | iseleq RD, RD, TMP2 + | evstdd CRET1, 0(RA) + | b ->fff_res + | + |.ffunc string_char // Only handle the 1-arg case here. + | ffgccheck + | cmplwi NARGS8:RC, 8 + | evldd CARG1, 0(BASE) + | bne ->fff_fallback // Exactly 1 argument. + | checknum CARG1 + | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) + | checkfail ->fff_fallback + | efdctsiz TMP0, CARG1 + | li CARG3, 1 + | cmplwi TMP0, 255 + | stb TMP0, 0(CARG2) + | bgt ->fff_fallback + |->fff_newstr: + | mr CARG1, L + | stw BASE, L->base + | stw PC, SAVE_PC + | bl extern lj_str_new // (lua_State *L, char *str, size_t l) + | // Returns GCstr *. + | lwz BASE, L->base + | evmergelo STR:CRET1, TISSTR, STR:CRET1 + | b ->fff_restv + | + |.ffunc string_sub + | ffgccheck + | cmplwi NARGS8:RC, 16 + | evldd CARG3, 16(BASE) + | evldd STR:CARG1, 0(BASE) + | blt ->fff_fallback + | evldd CARG2, 8(BASE) + | li TMP2, -1 + | beq >1 + | checknum CARG3 + | checkfail ->fff_fallback + | efdctsiz TMP2, CARG3 + |1: + | checknum CARG2 + | checkfail ->fff_fallback + | checkstr STR:CARG1 + | efdctsiz TMP1, CARG2 + | checkfail ->fff_fallback + | lwz TMP0, STR:CARG1->len + | cmplw TMP0, TMP2 // len < end? (unsigned compare) + | add TMP3, TMP2, TMP0 + | blt >5 + |2: + | cmpwi TMP1, 0 // start <= 0? + | add TMP3, TMP1, TMP0 + | ble >7 + |3: + | sub. CARG3, TMP2, TMP1 + | addi CARG2, STR:CARG1, #STR-1 + | addi CARG3, CARG3, 1 + | add CARG2, CARG2, TMP1 + | isellt CARG3, r0, CARG3 + | b ->fff_newstr + | + |5: // Negative end or overflow. + | cmpw TMP0, TMP2 + | addi TMP3, TMP3, 1 + | iselgt TMP2, TMP3, TMP0 // end = end > len ? len : end+len+1 + | b <2 + | + |7: // Negative start or underflow. + | cmpwi cr1, TMP3, 0 + | iseleq TMP1, r0, TMP3 + | isel TMP1, r0, TMP1, 4*cr1+lt + | addi TMP1, TMP1, 1 // start = 1 + (start ? start+len : 0) + | b <3 + | + |.ffunc string_rep // Only handle the 1-char case inline. + | ffgccheck + | cmplwi NARGS8:RC, 16 + | evldd CARG1, 0(BASE) + | evldd CARG2, 8(BASE) + | bne ->fff_fallback // Exactly 2 arguments. + | checknum CARG2 + | checkfail ->fff_fallback + | checkstr STR:CARG1 + | efdctsiz CARG3, CARG2 + | checkfail ->fff_fallback + | lwz TMP0, STR:CARG1->len + | cmpwi CARG3, 0 + | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) + | ble >2 // Count <= 0? (or non-int) + | cmplwi TMP0, 1 + | subi TMP2, CARG3, 1 + | blt >2 // Zero length string? + | cmplw cr1, TMP1, CARG3 + | bne ->fff_fallback // Fallback for > 1-char strings. + | lbz TMP0, STR:CARG1[1] + | lwz CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) + | blt cr1, ->fff_fallback + |1: // Fill buffer with char. Yes, this is suboptimal code (do you care?). + | cmplwi TMP2, 0 + | stbx TMP0, CARG2, TMP2 + | subi TMP2, TMP2, 1 + | bne <1 + | b ->fff_newstr + |2: // Return empty string. + | la STR:CRET1, DISPATCH_GL(strempty)(DISPATCH) + | evmergelo CRET1, TISSTR, STR:CRET1 + | b ->fff_restv + | + |.ffunc string_reverse + | ffgccheck + | cmplwi NARGS8:RC, 8 + | evldd CARG1, 0(BASE) + | blt ->fff_fallback + | checkstr STR:CARG1 + | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) + | checkfail ->fff_fallback + | lwz CARG3, STR:CARG1->len + | la CARG1, #STR(STR:CARG1) + | lwz CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) + | li TMP2, 0 + | cmplw TMP1, CARG3 + | subi TMP3, CARG3, 1 + | blt ->fff_fallback + |1: // Reverse string copy. + | cmpwi TMP3, 0 + | lbzx TMP1, CARG1, TMP2 + | blt ->fff_newstr + | stbx TMP1, CARG2, TMP3 + | subi TMP3, TMP3, 1 + | addi TMP2, TMP2, 1 + | b <1 + | + |.macro ffstring_case, name, lo + | .ffunc name + | ffgccheck + | cmplwi NARGS8:RC, 8 + | evldd CARG1, 0(BASE) + | blt ->fff_fallback + | checkstr STR:CARG1 + | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) + | checkfail ->fff_fallback + | lwz CARG3, STR:CARG1->len + | la CARG1, #STR(STR:CARG1) + | lwz CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) + | cmplw TMP1, CARG3 + | li TMP2, 0 + | blt ->fff_fallback + |1: // ASCII case conversion. + | cmplw TMP2, CARG3 + | lbzx TMP1, CARG1, TMP2 + | bge ->fff_newstr + | subi TMP0, TMP1, lo + | xori TMP3, TMP1, 0x20 + | cmplwi TMP0, 26 + | isellt TMP1, TMP3, TMP1 + | stbx TMP1, CARG2, TMP2 + | addi TMP2, TMP2, 1 + | b <1 + |.endmacro + | + |ffstring_case string_lower, 65 + |ffstring_case string_upper, 97 + | + |//-- Table library ------------------------------------------------------ + | + |.ffunc_1 table_getn + | checktab CARG1 + | checkfail ->fff_fallback + | bl extern lj_tab_len // (GCtab *t) + | // Returns uint32_t (but less than 2^31). + | efdcfsi CRET1, CRET1 + | b ->fff_restv + | + |//-- Bit library -------------------------------------------------------- + | + |.macro .ffunc_bit, name + | .ffunc_n bit_..name + | efdadd CARG1, CARG1, TOBIT + |.endmacro + | + |.ffunc_bit tobit + |->fff_resbit: + | efdcfsi CRET1, CARG1 + | b ->fff_restv + | + |.macro .ffunc_bit_op, name, ins + | .ffunc_bit name + | li TMP1, 8 + |1: + | evlddx CARG2, BASE, TMP1 + | cmplw cr1, TMP1, NARGS8:RC + | checknum CARG2 + | bge cr1, ->fff_resbit + | checkfail ->fff_fallback + | efdadd CARG2, CARG2, TOBIT + | ins CARG1, CARG1, CARG2 + | addi TMP1, TMP1, 8 + | b <1 + |.endmacro + | + |.ffunc_bit_op band, and + |.ffunc_bit_op bor, or + |.ffunc_bit_op bxor, xor + | + |.ffunc_bit bswap + | rotlwi TMP0, CARG1, 8 + | rlwimi TMP0, CARG1, 24, 0, 7 + | rlwimi TMP0, CARG1, 24, 16, 23 + | efdcfsi CRET1, TMP0 + | b ->fff_restv + | + |.ffunc_bit bnot + | not TMP0, CARG1 + | efdcfsi CRET1, TMP0 + | b ->fff_restv + | + |.macro .ffunc_bit_sh, name, ins, shmod + | .ffunc_nn bit_..name + | efdadd CARG2, CARG2, TOBIT + | efdadd CARG1, CARG1, TOBIT + |.if shmod == 1 + | rlwinm CARG2, CARG2, 0, 27, 31 + |.elif shmod == 2 + | neg CARG2, CARG2 + |.endif + | ins TMP0, CARG1, CARG2 + | efdcfsi CRET1, TMP0 + | b ->fff_restv + |.endmacro + | + |.ffunc_bit_sh lshift, slw, 1 + |.ffunc_bit_sh rshift, srw, 1 + |.ffunc_bit_sh arshift, sraw, 1 + |.ffunc_bit_sh rol, rotlw, 0 + |.ffunc_bit_sh ror, rotlw, 2 + | + |//----------------------------------------------------------------------- + | + |->fff_fallback: // Call fast function fallback handler. + | // BASE = new base, RB = CFUNC, RC = nargs*8 + | lwz TMP3, CFUNC:RB->f + | add TMP1, BASE, NARGS8:RC + | lwz PC, FRAME_PC(BASE) // Fallback may overwrite PC. + | addi TMP0, TMP1, 8*LUA_MINSTACK + | lwz TMP2, L->maxstack + | stw PC, SAVE_PC // Redundant (but a defined value). + | cmplw TMP0, TMP2 + | stw BASE, L->base + | stw TMP1, L->top + | mr CARG1, L + | bgt >5 // Need to grow stack. + | mtctr TMP3 + | bctrl // (lua_State *L) + | // Either throws an error, or recovers and returns -1, 0 or nresults+1. + | lwz BASE, L->base + | cmpwi CRET1, 0 + | slwi RD, CRET1, 3 + | la RA, -8(BASE) + | bgt ->fff_res // Returned nresults+1? + |1: // Returned 0 or -1: retry fast path. + | lwz TMP0, L->top + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | sub NARGS8:RC, TMP0, BASE + | bne ->vm_call_tail // Returned -1? + | ins_callt // Returned 0: retry fast path. + | + |// Reconstruct previous base for vmeta_call during tailcall. + |->vm_call_tail: + | andi. TMP0, PC, FRAME_TYPE + | rlwinm TMP1, PC, 0, 0, 28 + | bne >3 + | lwz INS, -4(PC) + | decode_RA8 TMP1, INS + | addi TMP1, TMP1, 8 + |3: + | sub TMP2, BASE, TMP1 + | b ->vm_call_dispatch // Resolve again for tailcall. + | + |5: // Grow stack for fallback handler. + | li CARG2, LUA_MINSTACK + | bl extern lj_state_growstack // (lua_State *L, int n) + | lwz BASE, L->base + | cmpw TMP0, TMP0 // Set 4*cr0+eq to force retry. + | b <1 + | + |->fff_gcstep: // Call GC step function. + | // BASE = new base, RC = nargs*8 + | mflr SAVE0 + | stw BASE, L->base + | add TMP0, BASE, NARGS8:RC + | stw PC, SAVE_PC // Redundant (but a defined value). + | stw TMP0, L->top + | mr CARG1, L + | bl extern lj_gc_step // (lua_State *L) + | lwz BASE, L->base + | mtlr SAVE0 + | lwz TMP0, L->top + | sub NARGS8:RC, TMP0, BASE + | lwz CFUNC:RB, FRAME_FUNC(BASE) + | blr + | + |//----------------------------------------------------------------------- + |//-- Special dispatch targets ------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_record: // Dispatch target for recording phase. + |.if JIT + | NYI + |.endif + | + |->vm_rethook: // Dispatch target for return hooks. + | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | andi. TMP0, TMP3, HOOK_ACTIVE // Hook already active? + | beq >1 + |5: // Re-dispatch to static ins. + | addi TMP1, TMP1, GG_DISP2STATIC // Assumes decode_OP4 TMP1, INS. + | lwzx TMP0, DISPATCH, TMP1 + | mtctr TMP0 + | bctr + | + |->vm_inshook: // Dispatch target for instr/line hooks. + | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) + | lwz TMP2, DISPATCH_GL(hookcount)(DISPATCH) + | andi. TMP0, TMP3, HOOK_ACTIVE // Hook already active? + | rlwinm TMP0, TMP3, 31-LUA_HOOKLINE, 31, 0 + | bne <5 + | + | cmpwi cr1, TMP0, 0 + | addic. TMP2, TMP2, -1 + | beq cr1, <5 + | stw TMP2, DISPATCH_GL(hookcount)(DISPATCH) + | beq >1 + | bge cr1, <5 + |1: + | mr CARG1, L + | stw MULTRES, SAVE_MULTRES + | mr CARG2, PC + | stw BASE, L->base + | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. + | bl extern lj_dispatch_ins // (lua_State *L, const BCIns *pc) + |3: + | lwz BASE, L->base + |4: // Re-dispatch to static ins. + | lwz INS, -4(PC) + | decode_OP4 TMP1, INS + | decode_RB8 RB, INS + | addi TMP1, TMP1, GG_DISP2STATIC + | decode_RD8 RD, INS + | lwzx TMP0, DISPATCH, TMP1 + | decode_RA8 RA, INS + | decode_RC8 RC, INS + | mtctr TMP0 + | bctr + | + |->cont_hook: // Continue from hook yield. + | addi PC, PC, 4 + | lwz MULTRES, -20(RB) // Restore MULTRES for *M ins. + | b <4 + | + |->vm_hotloop: // Hot loop counter underflow. + |.if JIT + | NYI + |.endif + | + |->vm_callhook: // Dispatch target for call hooks. + | mr CARG2, PC + |.if JIT + | b >1 + |.endif + | + |->vm_hotcall: // Hot call counter underflow. + |.if JIT + | ori CARG2, PC, 1 + |1: + |.endif + | add TMP0, BASE, RC + | stw PC, SAVE_PC + | mr CARG1, L + | stw BASE, L->base + | sub RA, RA, BASE + | stw TMP0, L->top + | bl extern lj_dispatch_call // (lua_State *L, const BCIns *pc) + | // Returns ASMFunction. + | lwz BASE, L->base + | lwz TMP0, L->top + | stw ZERO, SAVE_PC // Invalidate for subsequent line hook. + | sub NARGS8:RC, TMP0, BASE + | add RA, BASE, RA + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | mtctr CRET1 + | bctr + | + |//----------------------------------------------------------------------- + |//-- Trace exit handler ------------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_exit_handler: + |.if JIT + | NYI + |.endif + |->vm_exit_interp: + |.if JIT + | NYI + |.endif + | + |//----------------------------------------------------------------------- + |//-- Math helper functions ---------------------------------------------- + |//----------------------------------------------------------------------- + | + |// FP value rounding. Called by math.floor/math.ceil fast functions + |// and from JIT code. + |// + |// This can be inlined if the CPU has the frin/friz/frip/frim instructions. + |// The alternative hard-float approaches have a deep dependency chain. + |// The resulting latency is at least 3x-7x the double-precision FP latency + |// (e500v2: 6cy, e600: 5cy, Cell: 10cy) or around 20-70 cycles. + |// + |// The soft-float approach is tedious, but much faster (e500v2: ~11cy/~6cy). + |// However it relies on a fast way to transfer the FP value to GPRs + |// (e500v2: 0cy for lo-word, 1cy for hi-word). + |// + |.macro vm_round, name, mode + | // Used temporaries: TMP0, TMP1, TMP2, TMP3. + |->name.._efd: // Input: CARG2, output: CRET2 + | evmergehi CARG1, CARG2, CARG2 + |->name.._hilo: + | // Input: CARG1 (hi), CARG2 (hi, lo), output: CRET2 + | rlwinm TMP2, CARG1, 12, 21, 31 + | addic. TMP2, TMP2, -1023 // exp = exponent(x) - 1023 + | li TMP1, -1 + | cmplwi cr1, TMP2, 51 // 0 <= exp <= 51? + | subfic TMP0, TMP2, 52 + | bgt cr1, >1 + | lus TMP3, 0xfff0 + | slw TMP0, TMP1, TMP0 // lomask = -1 << (52-exp) + | sraw TMP1, TMP3, TMP2 // himask = (int32_t)0xfff00000 >> exp + |.if mode == 2 // trunc(x): + | evmergelo TMP0, TMP1, TMP0 + | evand CRET2, CARG2, TMP0 // hi &= himask, lo &= lomask + |.else + | andc TMP2, CARG2, TMP0 + | andc TMP3, CARG1, TMP1 + | or TMP2, TMP2, TMP3 // ztest = (hi&~himask) | (lo&~lomask) + | srawi TMP3, CARG1, 31 // signmask = (int32_t)hi >> 31 + |.if mode == 0 // floor(x): + | and. TMP2, TMP2, TMP3 // iszero = ((ztest & signmask) == 0) + |.else // ceil(x): + | andc. TMP2, TMP2, TMP3 // iszero = ((ztest & ~signmask) == 0) + |.endif + | and CARG2, CARG2, TMP0 // lo &= lomask + | and CARG1, CARG1, TMP1 // hi &= himask + | subc TMP0, CARG2, TMP0 + | iseleq TMP0, CARG2, TMP0 // lo = iszero ? lo : lo-lomask + | sube TMP1, CARG1, TMP1 + | iseleq TMP1, CARG1, TMP1 // hi = iszero ? hi : hi-himask+carry + | evmergelo CRET2, TMP1, TMP0 + |.endif + | blr + |1: + | bgtlr // Already done if >=2^52, +-inf or nan. + |.if mode == 2 // trunc(x): + | rlwinm TMP1, CARG1, 0, 0, 0 // hi = sign(x) + | li TMP0, 0 + | evmergelo CRET2, TMP1, TMP0 + |.else + | rlwinm TMP2, CARG1, 0, 1, 31 + | srawi TMP0, CARG1, 31 // signmask = (int32_t)hi >> 31 + | or TMP2, TMP2, CARG2 // ztest = abs(hi) | lo + | lus TMP1, 0x3ff0 + |.if mode == 0 // floor(x): + | and. TMP2, TMP2, TMP0 // iszero = ((ztest & signmask) == 0) + |.else // ceil(x): + | andc. TMP2, TMP2, TMP0 // iszero = ((ztest & ~signmask) == 0) + |.endif + | li TMP0, 0 + | iseleq TMP1, r0, TMP1 + | rlwimi CARG1, TMP1, 0, 1, 31 // hi = sign(x) | (iszero ? 0.0 : 1.0) + | evmergelo CRET2, CARG1, TMP0 + |.endif + | blr + |.endmacro + | + |->vm_floor: + | mflr CARG3 + | evmergelo CARG2, CARG1, CARG2 + | bl ->vm_floor_hilo + | mtlr CARG3 + | evmergehi CRET1, CRET2, CRET2 + | blr + | + | vm_round vm_floor, 0 + | vm_round vm_ceil, 1 + |.if JIT + | vm_round vm_trunc, 2 + |.else + |->vm_trunc_efd: + |->vm_trunc_hilo: + |.endif + | + |//----------------------------------------------------------------------- + |//-- Miscellaneous functions -------------------------------------------- + |//----------------------------------------------------------------------- + | + |//----------------------------------------------------------------------- + |//-- FFI helper functions ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_ffi_call: + |.if FFI + | NYI + |.endif + | + |//----------------------------------------------------------------------- +} + +/* Generate the code for a single instruction. */ +static void build_ins(BuildCtx *ctx, BCOp op, int defop) +{ + int vk = 0; + |=>defop: + + switch (op) { + + /* -- Comparison ops ---------------------------------------------------- */ + + /* Remember: all ops branch for a true comparison, fall through otherwise. */ + + case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: + | // RA = src1*8, RD = src2*8, JMP with RD = target + | evlddx TMP0, BASE, RA + | addi PC, PC, 4 + | evlddx TMP1, BASE, RD + | addis TMP3, PC, -(BCBIAS_J*4 >> 16) + | lwz TMP2, -4(PC) + | evmergehi RB, TMP0, TMP1 + | decode_RD4 TMP2, TMP2 + | checknum RB + | add TMP2, TMP2, TMP3 + | checkanyfail ->vmeta_comp + | efdcmplt TMP0, TMP1 + if (op == BC_ISLE || op == BC_ISGT) { + | efdcmpeq cr1, TMP0, TMP1 + | cror 4*cr0+gt, 4*cr0+gt, 4*cr1+gt + } + if (op == BC_ISLT || op == BC_ISLE) { + | iselgt PC, TMP2, PC + } else { + | iselgt PC, PC, TMP2 + } + | ins_next + break; + + case BC_ISEQV: case BC_ISNEV: + vk = op == BC_ISEQV; + | // RA = src1*8, RD = src2*8, JMP with RD = target + | evlddx CARG2, BASE, RA + | addi PC, PC, 4 + | evlddx CARG3, BASE, RD + | addis TMP3, PC, -(BCBIAS_J*4 >> 16) + | lwz TMP2, -4(PC) + | evmergehi RB, CARG2, CARG3 + | decode_RD4 TMP2, TMP2 + | checknum RB + | add TMP2, TMP2, TMP3 + | checkanyfail >5 + | efdcmpeq CARG2, CARG3 + if (vk) { + | iselgt PC, TMP2, PC + } else { + | iselgt PC, PC, TMP2 + } + |1: + | ins_next + | + |5: // Either or both types are not numbers. + | evcmpeq CARG2, CARG3 + | not TMP3, RB + | cmplwi cr1, TMP3, ~LJ_TISPRI // Primitive? + | crorc 4*cr7+lt, 4*cr0+so, 4*cr0+lt // 1: Same tv or different type. + | cmplwi cr6, TMP3, ~LJ_TISTABUD // Table or userdata? + | crandc 4*cr7+gt, 4*cr0+lt, 4*cr1+gt // 2: Same type and primitive. + | mr SAVE0, PC + if (vk) { + | isel PC, TMP2, PC, 4*cr7+gt + } else { + | isel TMP2, PC, TMP2, 4*cr7+gt + } + | cror 4*cr7+lt, 4*cr7+lt, 4*cr7+gt // 1 or 2. + if (vk) { + | isel PC, TMP2, PC, 4*cr0+so + } else { + | isel PC, PC, TMP2, 4*cr0+so + } + | blt cr7, <1 // Done if 1 or 2. + | blt cr6, <1 // Done if not tab/ud. + | + | // Different tables or userdatas. Need to check __eq metamethod. + | // Field metatable must be at same offset for GCtab and GCudata! + | lwz TAB:TMP2, TAB:CARG2->metatable + | li CARG4, 1-vk // ne = 0 or 1. + | cmplwi TAB:TMP2, 0 + | beq <1 // No metatable? + | lbz TMP2, TAB:TMP2->nomm + | andi. TMP2, TMP2, 1<vmeta_equal // Handle __eq metamethod. + break; + + case BC_ISEQS: case BC_ISNES: + vk = op == BC_ISEQS; + | // RA = src*8, RD = str_const*8 (~), JMP with RD = target + | evlddx TMP0, BASE, RA + | srwi RD, RD, 1 + | lwz INS, 0(PC) + | subfic RD, RD, -4 + | addi PC, PC, 4 + | lwzx STR:TMP1, KBASE, RD // KBASE-4-str_const*4 + | addis TMP3, PC, -(BCBIAS_J*4 >> 16) + | decode_RD4 TMP2, INS + | evmergelo STR:TMP1, TISSTR, STR:TMP1 + | add TMP2, TMP2, TMP3 + | evcmpeq TMP0, STR:TMP1 + if (vk) { + | isel PC, TMP2, PC, 4*cr0+so + } else { + | isel PC, PC, TMP2, 4*cr0+so + } + | ins_next + break; + + case BC_ISEQN: case BC_ISNEN: + vk = op == BC_ISEQN; + | // RA = src*8, RD = num_const*8, JMP with RD = target + | evlddx TMP0, BASE, RA + | addi PC, PC, 4 + | evlddx TMP1, KBASE, RD + | addis TMP3, PC, -(BCBIAS_J*4 >> 16) + | lwz INS, -4(PC) + | checknum TMP0 + | checkfail >5 + | efdcmpeq TMP0, TMP1 + |1: + | decode_RD4 TMP2, INS + | add TMP2, TMP2, TMP3 + if (vk) { + | iselgt PC, TMP2, PC + |5: + } else { + | iselgt PC, PC, TMP2 + } + |3: + | ins_next + if (!vk) { + |5: + | decode_RD4 TMP2, INS + | add PC, TMP2, TMP3 + | b <3 + } + break; + + case BC_ISEQP: case BC_ISNEP: + vk = op == BC_ISEQP; + | // RA = src*8, RD = primitive_type*8 (~), JMP with RD = target + | lwzx TMP0, BASE, RA + | srwi TMP1, RD, 3 + | lwz INS, 0(PC) + | addi PC, PC, 4 + | not TMP1, TMP1 + | addis TMP3, PC, -(BCBIAS_J*4 >> 16) + | cmplw TMP0, TMP1 + | decode_RD4 TMP2, INS + | add TMP2, TMP2, TMP3 + if (vk) { + | iseleq PC, TMP2, PC + } else { + | iseleq PC, PC, TMP2 + } + | ins_next + break; + + /* -- Unary test and copy ops ------------------------------------------- */ + + case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: + | // RA = dst*8 or unused, RD = src*8, JMP with RD = target + | evlddx TMP0, BASE, RD + | evaddw TMP1, TISNIL, TISNIL // Synthesize LJ_TFALSE. + | lwz INS, 0(PC) + | evcmpltu TMP0, TMP1 + | addi PC, PC, 4 + if (op == BC_IST || op == BC_ISF) { + | addis TMP3, PC, -(BCBIAS_J*4 >> 16) + | decode_RD4 TMP2, INS + | add TMP2, TMP2, TMP3 + if (op == BC_IST) { + | isellt PC, TMP2, PC + } else { + | isellt PC, PC, TMP2 + } + } else { + if (op == BC_ISTC) { + | checkfail >1 + } else { + | checkok >1 + } + | addis PC, PC, -(BCBIAS_J*4 >> 16) + | decode_RD4 TMP2, INS + | evstddx TMP0, BASE, RA + | add PC, PC, TMP2 + |1: + } + | ins_next + break; + + /* -- Unary ops --------------------------------------------------------- */ + + case BC_MOV: + | // RA = dst*8, RD = src*8 + | ins_next1 + | evlddx TMP0, BASE, RD + | evstddx TMP0, BASE, RA + | ins_next2 + break; + case BC_NOT: + | // RA = dst*8, RD = src*8 + | ins_next1 + | lwzx TMP0, BASE, RD + | subfic TMP1, TMP0, LJ_TTRUE + | adde TMP0, TMP0, TMP1 + | stwx TMP0, BASE, RA + | ins_next2 + break; + case BC_UNM: + | // RA = dst*8, RD = src*8 + | evlddx TMP0, BASE, RD + | checknum TMP0 + | checkfail ->vmeta_unm + | efdneg TMP0, TMP0 + | ins_next1 + | evstddx TMP0, BASE, RA + | ins_next2 + break; + case BC_LEN: + | // RA = dst*8, RD = src*8 + | evlddx CARG1, BASE, RD + | checkstr CARG1 + | checkfail >2 + | lwz CRET1, STR:CARG1->len + |1: + | ins_next1 + | efdcfsi TMP0, CRET1 + | evstddx TMP0, BASE, RA + | ins_next2 + |2: + | checktab CARG1 + | checkfail ->vmeta_len +#if LJ_52 + | lwz TAB:TMP2, TAB:CARG1->metatable + | cmplwi TAB:TMP2, 0 + | bne >9 + |3: +#endif + |->BC_LEN_Z: + | bl extern lj_tab_len // (GCtab *t) + | // Returns uint32_t (but less than 2^31). + | b <1 +#if LJ_52 + |9: + | lbz TMP0, TAB:TMP2->nomm + | andi. TMP0, TMP0, 1<vmeta_len +#endif + break; + + /* -- Binary ops -------------------------------------------------------- */ + + |.macro ins_arithpre, t0, t1 + | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 + ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); + ||switch (vk) { + ||case 0: + | evlddx t0, BASE, RB + | checknum t0 + | evlddx t1, KBASE, RC + | checkfail ->vmeta_arith_vn + || break; + ||case 1: + | evlddx t1, BASE, RB + | checknum t1 + | evlddx t0, KBASE, RC + | checkfail ->vmeta_arith_nv + || break; + ||default: + | evlddx t0, BASE, RB + | evlddx t1, BASE, RC + | evmergehi TMP2, t0, t1 + | checknum TMP2 + | checkanyfail ->vmeta_arith_vv + || break; + ||} + |.endmacro + | + |.macro ins_arith, ins + | ins_arithpre TMP0, TMP1 + | ins_next1 + | ins TMP0, TMP0, TMP1 + | evstddx TMP0, BASE, RA + | ins_next2 + |.endmacro + + case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: + | ins_arith efdadd + break; + case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: + | ins_arith efdsub + break; + case BC_MULVN: case BC_MULNV: case BC_MULVV: + | ins_arith efdmul + break; + case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: + | ins_arith efddiv + break; + case BC_MODVN: + | ins_arithpre RD, SAVE0 + |->BC_MODVN_Z: + | efddiv CARG2, RD, SAVE0 + | bl ->vm_floor_efd // floor(b/c) + | efdmul TMP0, CRET2, SAVE0 + | ins_next1 + | efdsub TMP0, RD, TMP0 // b - floor(b/c)*c + | evstddx TMP0, BASE, RA + | ins_next2 + break; + case BC_MODNV: case BC_MODVV: + | ins_arithpre RD, SAVE0 + | b ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. + break; + case BC_POW: + | evlddx CARG2, BASE, RB + | evlddx CARG4, BASE, RC + | evmergehi CARG1, CARG4, CARG2 + | checknum CARG1 + | evmergehi CARG3, CARG4, CARG4 + | checkanyfail ->vmeta_arith_vv + | bl extern pow@plt + | evmergelo CRET2, CRET1, CRET2 + | evstddx CRET2, BASE, RA + | ins_next + break; + + case BC_CAT: + | // RA = dst*8, RB = src_start*8, RC = src_end*8 + | sub CARG3, RC, RB + | stw BASE, L->base + | add CARG2, BASE, RC + | mr SAVE0, RB + |->BC_CAT_Z: + | stw PC, SAVE_PC + | mr CARG1, L + | srwi CARG3, CARG3, 3 + | bl extern lj_meta_cat // (lua_State *L, TValue *top, int left) + | // Returns NULL (finished) or TValue * (metamethod). + | cmplwi CRET1, 0 + | lwz BASE, L->base + | bne ->vmeta_binop + | evlddx TMP0, BASE, SAVE0 // Copy result from RB to RA. + | evstddx TMP0, BASE, RA + | ins_next + break; + + /* -- Constant ops ------------------------------------------------------ */ + + case BC_KSTR: + | // RA = dst*8, RD = str_const*8 (~) + | ins_next1 + | srwi TMP1, RD, 1 + | subfic TMP1, TMP1, -4 + | lwzx TMP0, KBASE, TMP1 // KBASE-4-str_const*4 + | evmergelo TMP0, TISSTR, TMP0 + | evstddx TMP0, BASE, RA + | ins_next2 + break; + case BC_KCDATA: + |.if FFI + | // RA = dst*8, RD = cdata_const*8 (~) + | ins_next1 + | srwi TMP1, RD, 1 + | subfic TMP1, TMP1, -4 + | lwzx TMP0, KBASE, TMP1 // KBASE-4-cdata_const*4 + | li TMP2, LJ_TCDATA + | evmergelo TMP0, TMP2, TMP0 + | evstddx TMP0, BASE, RA + | ins_next2 + |.endif + break; + case BC_KSHORT: + | // RA = dst*8, RD = int16_literal*8 + | srwi TMP1, RD, 3 + | extsh TMP1, TMP1 + | ins_next1 + | efdcfsi TMP0, TMP1 + | evstddx TMP0, BASE, RA + | ins_next2 + break; + case BC_KNUM: + | // RA = dst*8, RD = num_const*8 + | evlddx TMP0, KBASE, RD + | ins_next1 + | evstddx TMP0, BASE, RA + | ins_next2 + break; + case BC_KPRI: + | // RA = dst*8, RD = primitive_type*8 (~) + | srwi TMP1, RD, 3 + | not TMP0, TMP1 + | ins_next1 + | stwx TMP0, BASE, RA + | ins_next2 + break; + case BC_KNIL: + | // RA = base*8, RD = end*8 + | evstddx TISNIL, BASE, RA + | addi RA, RA, 8 + |1: + | evstddx TISNIL, BASE, RA + | cmpw RA, RD + | addi RA, RA, 8 + | blt <1 + | ins_next_ + break; + + /* -- Upvalue and function ops ------------------------------------------ */ + + case BC_UGET: + | // RA = dst*8, RD = uvnum*8 + | ins_next1 + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi RD, RD, 1 + | addi RD, RD, offsetof(GCfuncL, uvptr) + | lwzx UPVAL:RB, LFUNC:RB, RD + | lwz TMP1, UPVAL:RB->v + | evldd TMP0, 0(TMP1) + | evstddx TMP0, BASE, RA + | ins_next2 + break; + case BC_USETV: + | // RA = uvnum*8, RD = src*8 + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi RA, RA, 1 + | addi RA, RA, offsetof(GCfuncL, uvptr) + | evlddx TMP1, BASE, RD + | lwzx UPVAL:RB, LFUNC:RB, RA + | lbz TMP3, UPVAL:RB->marked + | lwz CARG2, UPVAL:RB->v + | andi. TMP3, TMP3, LJ_GC_BLACK // isblack(uv) + | lbz TMP0, UPVAL:RB->closed + | evmergehi TMP2, TMP1, TMP1 + | evstdd TMP1, 0(CARG2) + | cmplwi cr1, TMP0, 0 + | cror 4*cr0+eq, 4*cr0+eq, 4*cr1+eq + | subi TMP2, TMP2, (LJ_TISNUM+1) + | bne >2 // Upvalue is closed and black? + |1: + | ins_next + | + |2: // Check if new value is collectable. + | cmplwi TMP2, LJ_TISGCV - (LJ_TISNUM+1) + | bge <1 // tvisgcv(v) + | lbz TMP3, GCOBJ:TMP1->gch.marked + | andi. TMP3, TMP3, LJ_GC_WHITES // iswhite(v) + | la CARG1, GG_DISP2G(DISPATCH) + | // Crossed a write barrier. Move the barrier forward. + | beq <1 + | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) + | b <1 + break; + case BC_USETS: + | // RA = uvnum*8, RD = str_const*8 (~) + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi TMP1, RD, 1 + | srwi RA, RA, 1 + | subfic TMP1, TMP1, -4 + | addi RA, RA, offsetof(GCfuncL, uvptr) + | lwzx STR:TMP1, KBASE, TMP1 // KBASE-4-str_const*4 + | lwzx UPVAL:RB, LFUNC:RB, RA + | evmergelo STR:TMP1, TISSTR, STR:TMP1 + | lbz TMP3, UPVAL:RB->marked + | lwz CARG2, UPVAL:RB->v + | andi. TMP3, TMP3, LJ_GC_BLACK // isblack(uv) + | lbz TMP3, STR:TMP1->marked + | lbz TMP2, UPVAL:RB->closed + | evstdd STR:TMP1, 0(CARG2) + | bne >2 + |1: + | ins_next + | + |2: // Check if string is white and ensure upvalue is closed. + | andi. TMP3, TMP3, LJ_GC_WHITES // iswhite(str) + | cmplwi cr1, TMP2, 0 + | cror 4*cr0+eq, 4*cr0+eq, 4*cr1+eq + | la CARG1, GG_DISP2G(DISPATCH) + | // Crossed a write barrier. Move the barrier forward. + | beq <1 + | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) + | b <1 + break; + case BC_USETN: + | // RA = uvnum*8, RD = num_const*8 + | ins_next1 + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi RA, RA, 1 + | addi RA, RA, offsetof(GCfuncL, uvptr) + | evlddx TMP0, KBASE, RD + | lwzx UPVAL:RB, LFUNC:RB, RA + | lwz TMP1, UPVAL:RB->v + | evstdd TMP0, 0(TMP1) + | ins_next2 + break; + case BC_USETP: + | // RA = uvnum*8, RD = primitive_type*8 (~) + | ins_next1 + | lwz LFUNC:RB, FRAME_FUNC(BASE) + | srwi RA, RA, 1 + | addi RA, RA, offsetof(GCfuncL, uvptr) + | srwi TMP0, RD, 3 + | lwzx UPVAL:RB, LFUNC:RB, RA + | not TMP0, TMP0 + | lwz TMP1, UPVAL:RB->v + | stw TMP0, 0(TMP1) + | ins_next2 + break; + + case BC_UCLO: + | // RA = level*8, RD = target + | lwz TMP1, L->openupval + | branch_RD // Do this first since RD is not saved. + | stw BASE, L->base + | cmplwi TMP1, 0 + | mr CARG1, L + | beq >1 + | add CARG2, BASE, RA + | bl extern lj_func_closeuv // (lua_State *L, TValue *level) + | lwz BASE, L->base + |1: + | ins_next + break; + + case BC_FNEW: + | // RA = dst*8, RD = proto_const*8 (~) (holding function prototype) + | srwi TMP1, RD, 1 + | stw BASE, L->base + | subfic TMP1, TMP1, -4 + | stw PC, SAVE_PC + | lwzx CARG2, KBASE, TMP1 // KBASE-4-tab_const*4 + | mr CARG1, L + | lwz CARG3, FRAME_FUNC(BASE) + | // (lua_State *L, GCproto *pt, GCfuncL *parent) + | bl extern lj_func_newL_gc + | // Returns GCfuncL *. + | lwz BASE, L->base + | evmergelo LFUNC:CRET1, TISFUNC, LFUNC:CRET1 + | evstddx LFUNC:CRET1, BASE, RA + | ins_next + break; + + /* -- Table ops --------------------------------------------------------- */ + + case BC_TNEW: + case BC_TDUP: + | // RA = dst*8, RD = (hbits|asize)*8 | tab_const*8 (~) + | lwz TMP0, DISPATCH_GL(gc.total)(DISPATCH) + | mr CARG1, L + | lwz TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) + | stw BASE, L->base + | cmplw TMP0, TMP1 + | stw PC, SAVE_PC + | bge >5 + |1: + if (op == BC_TNEW) { + | rlwinm CARG2, RD, 29, 21, 31 + | rlwinm CARG3, RD, 18, 27, 31 + | cmpwi CARG2, 0x7ff + | li TMP1, 0x801 + | iseleq CARG2, TMP1, CARG2 + | bl extern lj_tab_new // (lua_State *L, int32_t asize, uint32_t hbits) + | // Returns Table *. + } else { + | srwi TMP1, RD, 1 + | subfic TMP1, TMP1, -4 + | lwzx CARG2, KBASE, TMP1 // KBASE-4-tab_const*4 + | bl extern lj_tab_dup // (lua_State *L, Table *kt) + | // Returns Table *. + } + | lwz BASE, L->base + | evmergelo TAB:CRET1, TISTAB, TAB:CRET1 + | evstddx TAB:CRET1, BASE, RA + | ins_next + |5: + | mr SAVE0, RD + | bl extern lj_gc_step_fixtop // (lua_State *L) + | mr RD, SAVE0 + | mr CARG1, L + | b <1 + break; + + case BC_GGET: + | // RA = dst*8, RD = str_const*8 (~) + case BC_GSET: + | // RA = src*8, RD = str_const*8 (~) + | lwz LFUNC:TMP2, FRAME_FUNC(BASE) + | srwi TMP1, RD, 1 + | lwz TAB:RB, LFUNC:TMP2->env + | subfic TMP1, TMP1, -4 + | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 + if (op == BC_GGET) { + | b ->BC_TGETS_Z + } else { + | b ->BC_TSETS_Z + } + break; + + case BC_TGETV: + | // RA = dst*8, RB = table*8, RC = key*8 + | evlddx TAB:RB, BASE, RB + | evlddx RC, BASE, RC + | checktab TAB:RB + | checkfail ->vmeta_tgetv + | checknum RC + | checkfail >5 + | // Convert number key to integer + | efdctsi TMP2, RC + | lwz TMP0, TAB:RB->asize + | efdcfsi TMP1, TMP2 + | cmplw cr0, TMP0, TMP2 + | efdcmpeq cr1, RC, TMP1 + | lwz TMP1, TAB:RB->array + | crand 4*cr0+gt, 4*cr0+gt, 4*cr1+gt + | slwi TMP2, TMP2, 3 + | ble ->vmeta_tgetv // Integer key and in array part? + | evlddx TMP1, TMP1, TMP2 + | checknil TMP1 + | checkok >2 + |1: + | evstddx TMP1, BASE, RA + | ins_next + | + |2: // Check for __index if table value is nil. + | lwz TAB:TMP2, TAB:RB->metatable + | cmplwi TAB:TMP2, 0 + | beq <1 // No metatable: done. + | lbz TMP0, TAB:TMP2->nomm + | andi. TMP0, TMP0, 1<vmeta_tgetv + | + |5: + | checkstr STR:RC // String key? + | checkok ->BC_TGETS_Z + | b ->vmeta_tgetv + break; + case BC_TGETS: + | // RA = dst*8, RB = table*8, RC = str_const*8 (~) + | evlddx TAB:RB, BASE, RB + | srwi TMP1, RC, 1 + | checktab TAB:RB + | subfic TMP1, TMP1, -4 + | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 + | checkfail ->vmeta_tgets1 + |->BC_TGETS_Z: + | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = dst*8 + | lwz TMP0, TAB:RB->hmask + | lwz TMP1, STR:RC->hash + | lwz NODE:TMP2, TAB:RB->node + | evmergelo STR:RC, TISSTR, STR:RC + | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask + | slwi TMP0, TMP1, 5 + | slwi TMP1, TMP1, 3 + | sub TMP1, TMP0, TMP1 + | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) + |1: + | evldd TMP0, NODE:TMP2->key + | evldd TMP1, NODE:TMP2->val + | evcmpeq TMP0, STR:RC + | checkanyfail >4 + | checknil TMP1 + | checkok >5 // Key found, but nil value? + |3: + | evstddx TMP1, BASE, RA + | ins_next + | + |4: // Follow hash chain. + | lwz NODE:TMP2, NODE:TMP2->next + | cmplwi NODE:TMP2, 0 + | bne <1 + | // End of hash chain: key not found, nil result. + | evmr TMP1, TISNIL + | + |5: // Check for __index if table value is nil. + | lwz TAB:TMP2, TAB:RB->metatable + | cmplwi TAB:TMP2, 0 + | beq <3 // No metatable: done. + | lbz TMP0, TAB:TMP2->nomm + | andi. TMP0, TMP0, 1<vmeta_tgets + break; + case BC_TGETB: + | // RA = dst*8, RB = table*8, RC = index*8 + | evlddx TAB:RB, BASE, RB + | srwi TMP0, RC, 3 + | checktab TAB:RB + | checkfail ->vmeta_tgetb + | lwz TMP1, TAB:RB->asize + | lwz TMP2, TAB:RB->array + | cmplw TMP0, TMP1 + | bge ->vmeta_tgetb + | evlddx TMP1, TMP2, RC + | checknil TMP1 + | checkok >5 + |1: + | ins_next1 + | evstddx TMP1, BASE, RA + | ins_next2 + | + |5: // Check for __index if table value is nil. + | lwz TAB:TMP2, TAB:RB->metatable + | cmplwi TAB:TMP2, 0 + | beq <1 // No metatable: done. + | lbz TMP2, TAB:TMP2->nomm + | andi. TMP2, TMP2, 1<vmeta_tgetb // Caveat: preserve TMP0! + break; + + case BC_TSETV: + | // RA = src*8, RB = table*8, RC = key*8 + | evlddx TAB:RB, BASE, RB + | evlddx RC, BASE, RC + | checktab TAB:RB + | checkfail ->vmeta_tsetv + | checknum RC + | checkfail >5 + | // Convert number key to integer + | efdctsi TMP2, RC + | evlddx SAVE0, BASE, RA + | lwz TMP0, TAB:RB->asize + | efdcfsi TMP1, TMP2 + | cmplw cr0, TMP0, TMP2 + | efdcmpeq cr1, RC, TMP1 + | lwz TMP1, TAB:RB->array + | crand 4*cr0+gt, 4*cr0+gt, 4*cr1+gt + | slwi TMP0, TMP2, 3 + | ble ->vmeta_tsetv // Integer key and in array part? + | lbz TMP3, TAB:RB->marked + | evlddx TMP2, TMP1, TMP0 + | checknil TMP2 + | checkok >3 + |1: + | andi. TMP2, TMP3, LJ_GC_BLACK // isblack(table) + | evstddx SAVE0, TMP1, TMP0 + | bne >7 + |2: + | ins_next + | + |3: // Check for __newindex if previous value is nil. + | lwz TAB:TMP2, TAB:RB->metatable + | cmplwi TAB:TMP2, 0 + | beq <1 // No metatable: done. + | lbz TMP2, TAB:TMP2->nomm + | andi. TMP2, TMP2, 1<vmeta_tsetv + | + |5: + | checkstr STR:RC // String key? + | checkok ->BC_TSETS_Z + | b ->vmeta_tsetv + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, TMP3, TMP0 + | b <2 + break; + case BC_TSETS: + | // RA = src*8, RB = table*8, RC = str_const*8 (~) + | evlddx TAB:RB, BASE, RB + | srwi TMP1, RC, 1 + | checktab TAB:RB + | subfic TMP1, TMP1, -4 + | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 + | checkfail ->vmeta_tsets1 + |->BC_TSETS_Z: + | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = src*8 + | lwz TMP0, TAB:RB->hmask + | lwz TMP1, STR:RC->hash + | lwz NODE:TMP2, TAB:RB->node + | evmergelo STR:RC, TISSTR, STR:RC + | stb ZERO, TAB:RB->nomm // Clear metamethod cache. + | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask + | evlddx SAVE0, BASE, RA + | slwi TMP0, TMP1, 5 + | slwi TMP1, TMP1, 3 + | sub TMP1, TMP0, TMP1 + | lbz TMP3, TAB:RB->marked + | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) + |1: + | evldd TMP0, NODE:TMP2->key + | evldd TMP1, NODE:TMP2->val + | evcmpeq TMP0, STR:RC + | checkanyfail >5 + | checknil TMP1 + | checkok >4 // Key found, but nil value? + |2: + | andi. TMP0, TMP3, LJ_GC_BLACK // isblack(table) + | evstdd SAVE0, NODE:TMP2->val + | bne >7 + |3: + | ins_next + | + |4: // Check for __newindex if previous value is nil. + | lwz TAB:TMP1, TAB:RB->metatable + | cmplwi TAB:TMP1, 0 + | beq <2 // No metatable: done. + | lbz TMP0, TAB:TMP1->nomm + | andi. TMP0, TMP0, 1<vmeta_tsets + | + |5: // Follow hash chain. + | lwz NODE:TMP2, NODE:TMP2->next + | cmplwi NODE:TMP2, 0 + | bne <1 + | // End of hash chain: key not found, add a new one. + | + | // But check for __newindex first. + | lwz TAB:TMP1, TAB:RB->metatable + | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) + | stw PC, SAVE_PC + | mr CARG1, L + | cmplwi TAB:TMP1, 0 + | stw BASE, L->base + | beq >6 // No metatable: continue. + | lbz TMP0, TAB:TMP1->nomm + | andi. TMP0, TMP0, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. + |6: + | mr CARG2, TAB:RB + | evstdd STR:RC, 0(CARG3) + | bl extern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k) + | // Returns TValue *. + | lwz BASE, L->base + | evstdd SAVE0, 0(CRET1) + | b <3 // No 2nd write barrier needed. + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, TMP3, TMP0 + | b <3 + break; + case BC_TSETB: + | // RA = src*8, RB = table*8, RC = index*8 + | evlddx TAB:RB, BASE, RB + | srwi TMP0, RC, 3 + | checktab TAB:RB + | checkfail ->vmeta_tsetb + | lwz TMP1, TAB:RB->asize + | lwz TMP2, TAB:RB->array + | lbz TMP3, TAB:RB->marked + | cmplw TMP0, TMP1 + | evlddx SAVE0, BASE, RA + | bge ->vmeta_tsetb + | evlddx TMP1, TMP2, RC + | checknil TMP1 + | checkok >5 + |1: + | andi. TMP0, TMP3, LJ_GC_BLACK // isblack(table) + | evstddx SAVE0, TMP2, RC + | bne >7 + |2: + | ins_next + | + |5: // Check for __newindex if previous value is nil. + | lwz TAB:TMP1, TAB:RB->metatable + | cmplwi TAB:TMP1, 0 + | beq <1 // No metatable: done. + | lbz TMP1, TAB:TMP1->nomm + | andi. TMP1, TMP1, 1<vmeta_tsetb // Caveat: preserve TMP0! + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, TMP3, TMP0 + | b <2 + break; + + case BC_TSETM: + | // RA = base*8 (table at base-1), RD = num_const*8 (start index) + | add RA, BASE, RA + |1: + | add TMP3, KBASE, RD + | lwz TAB:CARG2, -4(RA) // Guaranteed to be a table. + | addic. TMP0, MULTRES, -8 + | lwz TMP3, 4(TMP3) // Integer constant is in lo-word. + | srwi CARG3, TMP0, 3 + | beq >4 // Nothing to copy? + | add CARG3, CARG3, TMP3 + | lwz TMP2, TAB:CARG2->asize + | slwi TMP1, TMP3, 3 + | lbz TMP3, TAB:CARG2->marked + | cmplw CARG3, TMP2 + | add TMP2, RA, TMP0 + | lwz TMP0, TAB:CARG2->array + | bgt >5 + | add TMP1, TMP1, TMP0 + | andi. TMP0, TMP3, LJ_GC_BLACK // isblack(table) + |3: // Copy result slots to table. + | evldd TMP0, 0(RA) + | addi RA, RA, 8 + | cmpw cr1, RA, TMP2 + | evstdd TMP0, 0(TMP1) + | addi TMP1, TMP1, 8 + | blt cr1, <3 + | bne >7 + |4: + | ins_next + | + |5: // Need to resize array part. + | stw BASE, L->base + | mr CARG1, L + | stw PC, SAVE_PC + | mr SAVE0, RD + | bl extern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) + | // Must not reallocate the stack. + | mr RD, SAVE0 + | b <1 + | + |7: // Possible table write barrier for any value. Skip valiswhite check. + | barrierback TAB:CARG2, TMP3, TMP0 + | b <4 + break; + + /* -- Calls and vararg handling ----------------------------------------- */ + + case BC_CALLM: + | // RA = base*8, (RB = (nresults+1)*8,) RC = extra_nargs*8 + | add NARGS8:RC, NARGS8:RC, MULTRES + | // Fall through. Assumes BC_CALL follows. + break; + case BC_CALL: + | // RA = base*8, (RB = (nresults+1)*8,) RC = (nargs+1)*8 + | evlddx LFUNC:RB, BASE, RA + | mr TMP2, BASE + | add BASE, BASE, RA + | subi NARGS8:RC, NARGS8:RC, 8 + | checkfunc LFUNC:RB + | addi BASE, BASE, 8 + | checkfail ->vmeta_call + | ins_call + break; + + case BC_CALLMT: + | // RA = base*8, (RB = 0,) RC = extra_nargs*8 + | add NARGS8:RC, NARGS8:RC, MULTRES + | // Fall through. Assumes BC_CALLT follows. + break; + case BC_CALLT: + | // RA = base*8, (RB = 0,) RC = (nargs+1)*8 + | evlddx LFUNC:RB, BASE, RA + | add RA, BASE, RA + | lwz TMP1, FRAME_PC(BASE) + | subi NARGS8:RC, NARGS8:RC, 8 + | checkfunc LFUNC:RB + | addi RA, RA, 8 + | checkfail ->vmeta_callt + |->BC_CALLT_Z: + | andi. TMP0, TMP1, FRAME_TYPE // Caveat: preserve cr0 until the crand. + | lbz TMP3, LFUNC:RB->ffid + | xori TMP2, TMP1, FRAME_VARG + | cmplwi cr1, NARGS8:RC, 0 + | bne >7 + |1: + | stw LFUNC:RB, FRAME_FUNC(BASE) // Copy function down, but keep PC. + | li TMP2, 0 + | cmplwi cr7, TMP3, 1 // (> FF_C) Calling a fast function? + | beq cr1, >3 + |2: + | addi TMP3, TMP2, 8 + | evlddx TMP0, RA, TMP2 + | cmplw cr1, TMP3, NARGS8:RC + | evstddx TMP0, BASE, TMP2 + | mr TMP2, TMP3 + | bne cr1, <2 + |3: + | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+gt + | beq >5 + |4: + | ins_callt + | + |5: // Tailcall to a fast function with a Lua frame below. + | lwz INS, -4(TMP1) + | decode_RA8 RA, INS + | sub TMP1, BASE, RA + | lwz LFUNC:TMP1, FRAME_FUNC-8(TMP1) + | lwz TMP1, LFUNC:TMP1->pc + | lwz KBASE, PC2PROTO(k)(TMP1) // Need to prepare KBASE. + | b <4 + | + |7: // Tailcall from a vararg function. + | andi. TMP0, TMP2, FRAME_TYPEP + | bne <1 // Vararg frame below? + | sub BASE, BASE, TMP2 // Relocate BASE down. + | lwz TMP1, FRAME_PC(BASE) + | andi. TMP0, TMP1, FRAME_TYPE + | b <1 + break; + + case BC_ITERC: + | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 ((2+1)*8)) + | subi RA, RA, 24 // evldd doesn't support neg. offsets. + | mr TMP2, BASE + | evlddx LFUNC:RB, BASE, RA + | add BASE, BASE, RA + | evldd TMP0, 8(BASE) + | evldd TMP1, 16(BASE) + | evstdd LFUNC:RB, 24(BASE) // Copy callable. + | checkfunc LFUNC:RB + | evstdd TMP0, 32(BASE) // Copy state. + | li NARGS8:RC, 16 // Iterators get 2 arguments. + | evstdd TMP1, 40(BASE) // Copy control var. + | addi BASE, BASE, 32 + | checkfail ->vmeta_call + | ins_call + break; + + case BC_ITERN: + | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 (2+1)*8) + |.if JIT + | // NYI: add hotloop, record BC_ITERN. + |.endif + | add RA, BASE, RA + | lwz TAB:RB, -12(RA) + | lwz RC, -4(RA) // Get index from control var. + | lwz TMP0, TAB:RB->asize + | lwz TMP1, TAB:RB->array + | addi PC, PC, 4 + |1: // Traverse array part. + | cmplw RC, TMP0 + | slwi TMP3, RC, 3 + | bge >5 // Index points after array part? + | evlddx TMP2, TMP1, TMP3 + | checknil TMP2 + | lwz INS, -4(PC) + | checkok >4 + | efdcfsi TMP0, RC + | addi RC, RC, 1 + | addis TMP3, PC, -(BCBIAS_J*4 >> 16) + | evstdd TMP2, 8(RA) + | decode_RD4 TMP1, INS + | stw RC, -4(RA) // Update control var. + | add PC, TMP1, TMP3 + | evstdd TMP0, 0(RA) + |3: + | ins_next + | + |4: // Skip holes in array part. + | addi RC, RC, 1 + | b <1 + | + |5: // Traverse hash part. + | lwz TMP1, TAB:RB->hmask + | sub RC, RC, TMP0 + | lwz TMP2, TAB:RB->node + |6: + | cmplw RC, TMP1 // End of iteration? Branch to ITERL+1. + | slwi TMP3, RC, 5 + | bgt <3 + | slwi RB, RC, 3 + | sub TMP3, TMP3, RB + | evlddx RB, TMP2, TMP3 + | add NODE:TMP3, TMP2, TMP3 + | checknil RB + | lwz INS, -4(PC) + | checkok >7 + | evldd TMP3, NODE:TMP3->key + | addis TMP2, PC, -(BCBIAS_J*4 >> 16) + | evstdd RB, 8(RA) + | add RC, RC, TMP0 + | decode_RD4 TMP1, INS + | evstdd TMP3, 0(RA) + | addi RC, RC, 1 + | add PC, TMP1, TMP2 + | stw RC, -4(RA) // Update control var. + | b <3 + | + |7: // Skip holes in hash part. + | addi RC, RC, 1 + | b <6 + break; + + case BC_ISNEXT: + | // RA = base*8, RD = target (points to ITERN) + | add RA, BASE, RA + | li TMP2, -24 + | evlddx CFUNC:TMP1, RA, TMP2 + | lwz TMP2, -16(RA) + | lwz TMP3, -8(RA) + | evmergehi TMP0, CFUNC:TMP1, CFUNC:TMP1 + | cmpwi cr0, TMP2, LJ_TTAB + | cmpwi cr1, TMP0, LJ_TFUNC + | cmpwi cr6, TMP3, LJ_TNIL + | bne cr1, >5 + | lbz TMP1, CFUNC:TMP1->ffid + | crand 4*cr0+eq, 4*cr0+eq, 4*cr6+eq + | cmpwi cr7, TMP1, FF_next_N + | srwi TMP0, RD, 1 + | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+eq + | add TMP3, PC, TMP0 + | bne cr0, >5 + | lus TMP1, 0xfffe + | ori TMP1, TMP1, 0x7fff + | stw ZERO, -4(RA) // Initialize control var. + | stw TMP1, -8(RA) + | addis PC, TMP3, -(BCBIAS_J*4 >> 16) + |1: + | ins_next + |5: // Despecialize bytecode if any of the checks fail. + | li TMP0, BC_JMP + | li TMP1, BC_ITERC + | stb TMP0, -1(PC) + | addis PC, TMP3, -(BCBIAS_J*4 >> 16) + | stb TMP1, 3(PC) + | b <1 + break; + + case BC_VARG: + | // RA = base*8, RB = (nresults+1)*8, RC = numparams*8 + | lwz TMP0, FRAME_PC(BASE) + | add RC, BASE, RC + | add RA, BASE, RA + | addi RC, RC, FRAME_VARG + | add TMP2, RA, RB + | subi TMP3, BASE, 8 // TMP3 = vtop + | sub RC, RC, TMP0 // RC = vbase + | // Note: RC may now be even _above_ BASE if nargs was < numparams. + | cmplwi cr1, RB, 0 + | sub. TMP1, TMP3, RC + | beq cr1, >5 // Copy all varargs? + | subi TMP2, TMP2, 16 + | ble >2 // No vararg slots? + |1: // Copy vararg slots to destination slots. + | evldd TMP0, 0(RC) + | addi RC, RC, 8 + | evstdd TMP0, 0(RA) + | cmplw RA, TMP2 + | cmplw cr1, RC, TMP3 + | bge >3 // All destination slots filled? + | addi RA, RA, 8 + | blt cr1, <1 // More vararg slots? + |2: // Fill up remainder with nil. + | evstdd TISNIL, 0(RA) + | cmplw RA, TMP2 + | addi RA, RA, 8 + | blt <2 + |3: + | ins_next + | + |5: // Copy all varargs. + | lwz TMP0, L->maxstack + | li MULTRES, 8 // MULTRES = (0+1)*8 + | ble <3 // No vararg slots? + | add TMP2, RA, TMP1 + | cmplw TMP2, TMP0 + | addi MULTRES, TMP1, 8 + | bgt >7 + |6: + | evldd TMP0, 0(RC) + | addi RC, RC, 8 + | evstdd TMP0, 0(RA) + | cmplw RC, TMP3 + | addi RA, RA, 8 + | blt <6 // More vararg slots? + | b <3 + | + |7: // Grow stack for varargs. + | mr CARG1, L + | stw RA, L->top + | sub SAVE0, RC, BASE // Need delta, because BASE may change. + | stw BASE, L->base + | sub RA, RA, BASE + | stw PC, SAVE_PC + | srwi CARG2, TMP1, 3 + | bl extern lj_state_growstack // (lua_State *L, int n) + | lwz BASE, L->base + | add RA, BASE, RA + | add RC, BASE, SAVE0 + | subi TMP3, BASE, 8 + | b <6 + break; + + /* -- Returns ----------------------------------------------------------- */ + + case BC_RETM: + | // RA = results*8, RD = extra_nresults*8 + | add RD, RD, MULTRES // MULTRES >= 8, so RD >= 8. + | // Fall through. Assumes BC_RET follows. + break; + + case BC_RET: + | // RA = results*8, RD = (nresults+1)*8 + | lwz PC, FRAME_PC(BASE) + | add RA, BASE, RA + | mr MULTRES, RD + |1: + | andi. TMP0, PC, FRAME_TYPE + | xori TMP1, PC, FRAME_VARG + | bne ->BC_RETV_Z + | + |->BC_RET_Z: + | // BASE = base, RA = resultptr, RD = (nresults+1)*8, PC = return + | lwz INS, -4(PC) + | cmpwi RD, 8 + | subi TMP2, BASE, 8 + | subi RC, RD, 8 + | decode_RB8 RB, INS + | beq >3 + | li TMP1, 0 + |2: + | addi TMP3, TMP1, 8 + | evlddx TMP0, RA, TMP1 + | cmpw TMP3, RC + | evstddx TMP0, TMP2, TMP1 + | beq >3 + | addi TMP1, TMP3, 8 + | evlddx TMP0, RA, TMP3 + | cmpw TMP1, RC + | evstddx TMP0, TMP2, TMP3 + | bne <2 + |3: + |5: + | cmplw RB, RD + | decode_RA8 RA, INS + | bgt >6 + | sub BASE, TMP2, RA + | lwz LFUNC:TMP1, FRAME_FUNC(BASE) + | ins_next1 + | lwz TMP1, LFUNC:TMP1->pc + | lwz KBASE, PC2PROTO(k)(TMP1) + | ins_next2 + | + |6: // Fill up results with nil. + | subi TMP1, RD, 8 + | addi RD, RD, 8 + | evstddx TISNIL, TMP2, TMP1 + | b <5 + | + |->BC_RETV_Z: // Non-standard return case. + | andi. TMP2, TMP1, FRAME_TYPEP + | bne ->vm_return + | // Return from vararg function: relocate BASE down. + | sub BASE, BASE, TMP1 + | lwz PC, FRAME_PC(BASE) + | b <1 + break; + + case BC_RET0: case BC_RET1: + | // RA = results*8, RD = (nresults+1)*8 + | lwz PC, FRAME_PC(BASE) + | add RA, BASE, RA + | mr MULTRES, RD + | andi. TMP0, PC, FRAME_TYPE + | xori TMP1, PC, FRAME_VARG + | bne ->BC_RETV_Z + | + | lwz INS, -4(PC) + | subi TMP2, BASE, 8 + | decode_RB8 RB, INS + if (op == BC_RET1) { + | evldd TMP0, 0(RA) + | evstdd TMP0, 0(TMP2) + } + |5: + | cmplw RB, RD + | decode_RA8 RA, INS + | bgt >6 + | sub BASE, TMP2, RA + | lwz LFUNC:TMP1, FRAME_FUNC(BASE) + | ins_next1 + | lwz TMP1, LFUNC:TMP1->pc + | lwz KBASE, PC2PROTO(k)(TMP1) + | ins_next2 + | + |6: // Fill up results with nil. + | subi TMP1, RD, 8 + | addi RD, RD, 8 + | evstddx TISNIL, TMP2, TMP1 + | b <5 + break; + + /* -- Loops and branches ------------------------------------------------ */ + + case BC_FORL: + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_IFORL follows. + break; + + case BC_JFORI: + case BC_JFORL: +#if !LJ_HASJIT + break; +#endif + case BC_FORI: + case BC_IFORL: + | // RA = base*8, RD = target (after end of loop or start of loop) + vk = (op == BC_IFORL || op == BC_JFORL); + | add RA, BASE, RA + | evldd TMP1, FORL_IDX*8(RA) + | evldd TMP3, FORL_STEP*8(RA) + | evldd TMP2, FORL_STOP*8(RA) + if (!vk) { + | evcmpgtu cr0, TMP1, TISNUM + | evcmpgtu cr7, TMP3, TISNUM + | evcmpgtu cr1, TMP2, TISNUM + | cror 4*cr0+lt, 4*cr0+lt, 4*cr7+lt + | cror 4*cr0+lt, 4*cr0+lt, 4*cr1+lt + | blt ->vmeta_for + } + if (vk) { + | efdadd TMP1, TMP1, TMP3 + | evstdd TMP1, FORL_IDX*8(RA) + } + | evcmpgts TMP3, TISNIL + | evstdd TMP1, FORL_EXT*8(RA) + | bge >2 + | efdcmpgt TMP1, TMP2 + |1: + if (op != BC_JFORL) { + | srwi RD, RD, 1 + | add RD, PC, RD + if (op == BC_JFORI) { + | addis PC, RD, -(BCBIAS_J*4 >> 16) + } else { + | addis RD, RD, -(BCBIAS_J*4 >> 16) + } + } + if (op == BC_FORI) { + | iselgt PC, RD, PC + } else if (op == BC_IFORL) { + | iselgt PC, PC, RD + } else { + | ble =>BC_JLOOP + } + | ins_next + |2: + | efdcmpgt TMP2, TMP1 + | b <1 + break; + + case BC_ITERL: + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_IITERL follows. + break; + + case BC_JITERL: +#if !LJ_HASJIT + break; +#endif + case BC_IITERL: + | // RA = base*8, RD = target + | evlddx TMP1, BASE, RA + | subi RA, RA, 8 + | checknil TMP1 + | checkok >1 // Stop if iterator returned nil. + if (op == BC_JITERL) { + | NYI + } else { + | branch_RD // Otherwise save control var + branch. + | evstddx TMP1, BASE, RA + } + |1: + | ins_next + break; + + case BC_LOOP: + | // RA = base*8, RD = target (loop extent) + | // Note: RA/RD is only used by trace recorder to determine scope/extent + | // This opcode does NOT jump, it's only purpose is to detect a hot loop. + |.if JIT + | hotloop + |.endif + | // Fall through. Assumes BC_ILOOP follows. + break; + + case BC_ILOOP: + | // RA = base*8, RD = target (loop extent) + | ins_next + break; + + case BC_JLOOP: + |.if JIT + | NYI + |.endif + break; + + case BC_JMP: + | // RA = base*8 (only used by trace recorder), RD = target + | branch_RD + | ins_next + break; + + /* -- Function headers -------------------------------------------------- */ + + case BC_FUNCF: + |.if JIT + | hotcall + |.endif + case BC_FUNCV: /* NYI: compiled vararg functions. */ + | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow. + break; + + case BC_JFUNCF: +#if !LJ_HASJIT + break; +#endif + case BC_IFUNCF: + | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 + | lwz TMP2, L->maxstack + | lbz TMP1, -4+PC2PROTO(numparams)(PC) + | lwz KBASE, -4+PC2PROTO(k)(PC) + | cmplw RA, TMP2 + | slwi TMP1, TMP1, 3 + | bgt ->vm_growstack_l + | ins_next1 + |2: + | cmplw NARGS8:RC, TMP1 // Check for missing parameters. + | ble >3 + if (op == BC_JFUNCF) { + | NYI + } else { + | ins_next2 + } + | + |3: // Clear missing parameters. + | evstddx TISNIL, BASE, NARGS8:RC + | addi NARGS8:RC, NARGS8:RC, 8 + | b <2 + break; + + case BC_JFUNCV: +#if !LJ_HASJIT + break; +#endif + | NYI // NYI: compiled vararg functions + break; /* NYI: compiled vararg functions. */ + + case BC_IFUNCV: + | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 + | lwz TMP2, L->maxstack + | add TMP1, BASE, RC + | add TMP0, RA, RC + | stw LFUNC:RB, 4(TMP1) // Store copy of LFUNC. + | addi TMP3, RC, 8+FRAME_VARG + | lwz KBASE, -4+PC2PROTO(k)(PC) + | cmplw TMP0, TMP2 + | stw TMP3, 0(TMP1) // Store delta + FRAME_VARG. + | bge ->vm_growstack_l + | lbz TMP2, -4+PC2PROTO(numparams)(PC) + | mr RA, BASE + | mr RC, TMP1 + | ins_next1 + | cmpwi TMP2, 0 + | addi BASE, TMP1, 8 + | beq >3 + |1: + | cmplw RA, RC // Less args than parameters? + | evldd TMP0, 0(RA) + | bge >4 + | evstdd TISNIL, 0(RA) // Clear old fixarg slot (help the GC). + | addi RA, RA, 8 + |2: + | addic. TMP2, TMP2, -1 + | evstdd TMP0, 8(TMP1) + | addi TMP1, TMP1, 8 + | bne <1 + |3: + | ins_next2 + | + |4: // Clear missing parameters. + | evmr TMP0, TISNIL + | b <2 + break; + + case BC_FUNCC: + case BC_FUNCCW: + | // BASE = new base, RA = BASE+framesize*8, RB = CFUNC, RC = nargs*8 + if (op == BC_FUNCC) { + | lwz TMP3, CFUNC:RB->f + } else { + | lwz TMP3, DISPATCH_GL(wrapf)(DISPATCH) + } + | add TMP1, RA, NARGS8:RC + | lwz TMP2, L->maxstack + | add RC, BASE, NARGS8:RC + | stw BASE, L->base + | cmplw TMP1, TMP2 + | stw RC, L->top + | li_vmstate C + | mtctr TMP3 + if (op == BC_FUNCCW) { + | lwz CARG2, CFUNC:RB->f + } + | mr CARG1, L + | bgt ->vm_growstack_c // Need to grow stack. + | st_vmstate + | bctrl // (lua_State *L [, lua_CFunction f]) + | // Returns nresults. + | lwz TMP1, L->top + | slwi RD, CRET1, 3 + | lwz BASE, L->base + | li_vmstate INTERP + | lwz PC, FRAME_PC(BASE) // Fetch PC of caller. + | sub RA, TMP1, RD // RA = L->top - nresults*8 + | st_vmstate + | b ->vm_returnc + break; + + /* ---------------------------------------------------------------------- */ + + default: + fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); + exit(2); + break; + } +} + +static int build_backend(BuildCtx *ctx) +{ + int op; + + dasm_growpc(Dst, BC__MAX); + + build_subroutines(ctx); + + |.code_op + for (op = 0; op < BC__MAX; op++) + build_ins(ctx, (BCOp)op, op); + + return BC__MAX; +} + +/* Emit pseudo frame-info for all assembler functions. */ +static void emit_asm_debug(BuildCtx *ctx) +{ + int i; + switch (ctx->mode) { + case BUILD_elfasm: + fprintf(ctx->fp, "\t.section .debug_frame,\"\",@progbits\n"); + fprintf(ctx->fp, + ".Lframe0:\n" + "\t.long .LECIE0-.LSCIE0\n" + ".LSCIE0:\n" + "\t.long 0xffffffff\n" + "\t.byte 0x1\n" + "\t.string \"\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -4\n" + "\t.byte 65\n" + "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" + "\t.align 2\n" + ".LECIE0:\n\n"); + fprintf(ctx->fp, + ".LSFDE0:\n" + "\t.long .LEFDE0-.LASFDE0\n" + ".LASFDE0:\n" + "\t.long .Lframe0\n" + "\t.long .Lbegin\n" + "\t.long %d\n" + "\t.byte 0xe\n\t.uleb128 %d\n" + "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" + "\t.byte 0x5\n\t.uleb128 70\n\t.sleb128 37\n", + (int)ctx->codesz, CFRAME_SIZE); + for (i = 14; i <= 31; i++) + fprintf(ctx->fp, + "\t.byte %d\n\t.uleb128 %d\n" + "\t.byte 5\n\t.uleb128 %d\n\t.uleb128 %d\n", + 0x80+i, 1+2*(31-i), 1200+i, 2+2*(31-i)); + fprintf(ctx->fp, + "\t.align 2\n" + ".LEFDE0:\n\n"); + fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n"); + fprintf(ctx->fp, + ".Lframe1:\n" + "\t.long .LECIE1-.LSCIE1\n" + ".LSCIE1:\n" + "\t.long 0\n" + "\t.byte 0x1\n" + "\t.string \"zPR\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -4\n" + "\t.byte 65\n" + "\t.uleb128 6\n" /* augmentation length */ + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.long lj_err_unwind_dwarf-.\n" + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" + "\t.align 2\n" + ".LECIE1:\n\n"); + fprintf(ctx->fp, + ".LSFDE1:\n" + "\t.long .LEFDE1-.LASFDE1\n" + ".LASFDE1:\n" + "\t.long .LASFDE1-.Lframe1\n" + "\t.long .Lbegin-.\n" + "\t.long %d\n" + "\t.uleb128 0\n" /* augmentation length */ + "\t.byte 0xe\n\t.uleb128 %d\n" + "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" + "\t.byte 0x5\n\t.uleb128 70\n\t.sleb128 37\n", + (int)ctx->codesz, CFRAME_SIZE); + for (i = 14; i <= 31; i++) + fprintf(ctx->fp, + "\t.byte %d\n\t.uleb128 %d\n" + "\t.byte 5\n\t.uleb128 %d\n\t.uleb128 %d\n", + 0x80+i, 1+2*(31-i), 1200+i, 2+2*(31-i)); + fprintf(ctx->fp, + "\t.align 2\n" + ".LEFDE1:\n\n"); + break; + default: + break; + } +} + diff --git a/source/libs/luajit/LuaJIT-2.0.4/src/vm_x86.dasc b/source/libs/luajit/LuaJIT-2.0.4/src/vm_x86.dasc new file mode 100644 index 000000000..6cdb8cbd2 --- /dev/null +++ b/source/libs/luajit/LuaJIT-2.0.4/src/vm_x86.dasc @@ -0,0 +1,6377 @@ +|// Low-level VM code for x86 CPUs. +|// Bytecode interpreter, fast functions and helper functions. +|// Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h +| +|.if P64 +|.arch x64 +|.else +|.arch x86 +|.endif +|.section code_op, code_sub +| +|.actionlist build_actionlist +|.globals GLOB_ +|.globalnames globnames +|.externnames extnames +| +|//----------------------------------------------------------------------- +| +|.if P64 +|.define X64, 1 +|.define SSE, 1 +|.if WIN +|.define X64WIN, 1 +|.endif +|.endif +| +|// Fixed register assignments for the interpreter. +|// This is very fragile and has many dependencies. Caveat emptor. +|.define BASE, edx // Not C callee-save, refetched anyway. +|.if not X64 +|.define KBASE, edi // Must be C callee-save. +|.define KBASEa, KBASE +|.define PC, esi // Must be C callee-save. +|.define PCa, PC +|.define DISPATCH, ebx // Must be C callee-save. +|.elif X64WIN +|.define KBASE, edi // Must be C callee-save. +|.define KBASEa, rdi +|.define PC, esi // Must be C callee-save. +|.define PCa, rsi +|.define DISPATCH, ebx // Must be C callee-save. +|.else +|.define KBASE, r15d // Must be C callee-save. +|.define KBASEa, r15 +|.define PC, ebx // Must be C callee-save. +|.define PCa, rbx +|.define DISPATCH, r14d // Must be C callee-save. +|.endif +| +|.define RA, ecx +|.define RAH, ch +|.define RAL, cl +|.define RB, ebp // Must be ebp (C callee-save). +|.define RC, eax // Must be eax. +|.define RCW, ax +|.define RCH, ah +|.define RCL, al +|.define OP, RB +|.define RD, RC +|.define RDW, RCW +|.define RDL, RCL +|.if X64 +|.define RAa, rcx +|.define RBa, rbp +|.define RCa, rax +|.define RDa, rax +|.else +|.define RAa, RA +|.define RBa, RB +|.define RCa, RC +|.define RDa, RD +|.endif +| +|.if not X64 +|.define FCARG1, ecx // x86 fastcall arguments. +|.define FCARG2, edx +|.elif X64WIN +|.define CARG1, rcx // x64/WIN64 C call arguments. +|.define CARG2, rdx +|.define CARG3, r8 +|.define CARG4, r9 +|.define CARG1d, ecx +|.define CARG2d, edx +|.define CARG3d, r8d +|.define CARG4d, r9d +|.define FCARG1, CARG1d // Upwards compatible to x86 fastcall. +|.define FCARG2, CARG2d +|.else +|.define CARG1, rdi // x64/POSIX C call arguments. +|.define CARG2, rsi +|.define CARG3, rdx +|.define CARG4, rcx +|.define CARG5, r8 +|.define CARG6, r9 +|.define CARG1d, edi +|.define CARG2d, esi +|.define CARG3d, edx +|.define CARG4d, ecx +|.define CARG5d, r8d +|.define CARG6d, r9d +|.define FCARG1, CARG1d // Simulate x86 fastcall. +|.define FCARG2, CARG2d +|.endif +| +|// Type definitions. Some of these are only used for documentation. +|.type L, lua_State +|.type GL, global_State +|.type TVALUE, TValue +|.type GCOBJ, GCobj +|.type STR, GCstr +|.type TAB, GCtab +|.type LFUNC, GCfuncL +|.type CFUNC, GCfuncC +|.type PROTO, GCproto +|.type UPVAL, GCupval +|.type NODE, Node +|.type NARGS, int +|.type TRACE, GCtrace +| +|// Stack layout while in interpreter. Must match with lj_frame.h. +|//----------------------------------------------------------------------- +|.if not X64 // x86 stack layout. +| +|.define CFRAME_SPACE, aword*7 // Delta for esp (see <--). +|.macro saveregs_ +| push edi; push esi; push ebx +| sub esp, CFRAME_SPACE +|.endmacro +|.macro saveregs +| push ebp; saveregs_ +|.endmacro +|.macro restoreregs +| add esp, CFRAME_SPACE +| pop ebx; pop esi; pop edi; pop ebp +|.endmacro +| +|.define SAVE_ERRF, aword [esp+aword*15] // vm_pcall/vm_cpcall only. +|.define SAVE_NRES, aword [esp+aword*14] +|.define SAVE_CFRAME, aword [esp+aword*13] +|.define SAVE_L, aword [esp+aword*12] +|//----- 16 byte aligned, ^^^ arguments from C caller +|.define SAVE_RET, aword [esp+aword*11] //<-- esp entering interpreter. +|.define SAVE_R4, aword [esp+aword*10] +|.define SAVE_R3, aword [esp+aword*9] +|.define SAVE_R2, aword [esp+aword*8] +|//----- 16 byte aligned +|.define SAVE_R1, aword [esp+aword*7] //<-- esp after register saves. +|.define SAVE_PC, aword [esp+aword*6] +|.define TMP2, aword [esp+aword*5] +|.define TMP1, aword [esp+aword*4] +|//----- 16 byte aligned +|.define ARG4, aword [esp+aword*3] +|.define ARG3, aword [esp+aword*2] +|.define ARG2, aword [esp+aword*1] +|.define ARG1, aword [esp] //<-- esp while in interpreter. +|//----- 16 byte aligned, ^^^ arguments for C callee +| +|// FPARGx overlaps ARGx and ARG(x+1) on x86. +|.define FPARG3, qword [esp+qword*1] +|.define FPARG1, qword [esp] +|// TMPQ overlaps TMP1/TMP2. ARG5/MULTRES overlap TMP1/TMP2 (and TMPQ). +|.define TMPQ, qword [esp+aword*4] +|.define TMP3, ARG4 +|.define ARG5, TMP1 +|.define TMPa, TMP1 +|.define MULTRES, TMP2 +| +|// Arguments for vm_call and vm_pcall. +|.define INARG_BASE, SAVE_CFRAME // Overwritten by SAVE_CFRAME! +| +|// Arguments for vm_cpcall. +|.define INARG_CP_CALL, SAVE_ERRF +|.define INARG_CP_UD, SAVE_NRES +|.define INARG_CP_FUNC, SAVE_CFRAME +| +|//----------------------------------------------------------------------- +|.elif X64WIN // x64/Windows stack layout +| +|.define CFRAME_SPACE, aword*5 // Delta for rsp (see <--). +|.macro saveregs_ +| push rdi; push rsi; push rbx +| sub rsp, CFRAME_SPACE +|.endmacro +|.macro saveregs +| push rbp; saveregs_ +|.endmacro +|.macro restoreregs +| add rsp, CFRAME_SPACE +| pop rbx; pop rsi; pop rdi; pop rbp +|.endmacro +| +|.define SAVE_CFRAME, aword [rsp+aword*13] +|.define SAVE_PC, dword [rsp+dword*25] +|.define SAVE_L, dword [rsp+dword*24] +|.define SAVE_ERRF, dword [rsp+dword*23] +|.define SAVE_NRES, dword [rsp+dword*22] +|.define TMP2, dword [rsp+dword*21] +|.define TMP1, dword [rsp+dword*20] +|//----- 16 byte aligned, ^^^ 32 byte register save area, owned by interpreter +|.define SAVE_RET, aword [rsp+aword*9] //<-- rsp entering interpreter. +|.define SAVE_R4, aword [rsp+aword*8] +|.define SAVE_R3, aword [rsp+aword*7] +|.define SAVE_R2, aword [rsp+aword*6] +|.define SAVE_R1, aword [rsp+aword*5] //<-- rsp after register saves. +|.define ARG5, aword [rsp+aword*4] +|.define CSAVE_4, aword [rsp+aword*3] +|.define CSAVE_3, aword [rsp+aword*2] +|.define CSAVE_2, aword [rsp+aword*1] +|.define CSAVE_1, aword [rsp] //<-- rsp while in interpreter. +|//----- 16 byte aligned, ^^^ 32 byte register save area, owned by callee +| +|// TMPQ overlaps TMP1/TMP2. MULTRES overlaps TMP2 (and TMPQ). +|.define TMPQ, qword [rsp+aword*10] +|.define MULTRES, TMP2 +|.define TMPa, ARG5 +|.define ARG5d, dword [rsp+aword*4] +|.define TMP3, ARG5d +| +|//----------------------------------------------------------------------- +|.else // x64/POSIX stack layout +| +|.define CFRAME_SPACE, aword*5 // Delta for rsp (see <--). +|.macro saveregs_ +| push rbx; push r15; push r14 +| sub rsp, CFRAME_SPACE +|.endmacro +|.macro saveregs +| push rbp; saveregs_ +|.endmacro +|.macro restoreregs +| add rsp, CFRAME_SPACE +| pop r14; pop r15; pop rbx; pop rbp +|.endmacro +| +|//----- 16 byte aligned, +|.define SAVE_RET, aword [rsp+aword*9] //<-- rsp entering interpreter. +|.define SAVE_R4, aword [rsp+aword*8] +|.define SAVE_R3, aword [rsp+aword*7] +|.define SAVE_R2, aword [rsp+aword*6] +|.define SAVE_R1, aword [rsp+aword*5] //<-- rsp after register saves. +|.define SAVE_CFRAME, aword [rsp+aword*4] +|.define SAVE_PC, dword [rsp+dword*7] +|.define SAVE_L, dword [rsp+dword*6] +|.define SAVE_ERRF, dword [rsp+dword*5] +|.define SAVE_NRES, dword [rsp+dword*4] +|.define TMPa, aword [rsp+aword*1] +|.define TMP2, dword [rsp+dword*1] +|.define TMP1, dword [rsp] //<-- rsp while in interpreter. +|//----- 16 byte aligned +| +|// TMPQ overlaps TMP1/TMP2. MULTRES overlaps TMP2 (and TMPQ). +|.define TMPQ, qword [rsp] +|.define TMP3, dword [rsp+aword*1] +|.define MULTRES, TMP2 +| +|.endif +| +|//----------------------------------------------------------------------- +| +|// Instruction headers. +|.macro ins_A; .endmacro +|.macro ins_AD; .endmacro +|.macro ins_AJ; .endmacro +|.macro ins_ABC; movzx RB, RCH; movzx RC, RCL; .endmacro +|.macro ins_AB_; movzx RB, RCH; .endmacro +|.macro ins_A_C; movzx RC, RCL; .endmacro +|.macro ins_AND; not RDa; .endmacro +| +|// Instruction decode+dispatch. Carefully tuned (nope, lodsd is not faster). +|.macro ins_NEXT +| mov RC, [PC] +| movzx RA, RCH +| movzx OP, RCL +| add PC, 4 +| shr RC, 16 +|.if X64 +| jmp aword [DISPATCH+OP*8] +|.else +| jmp aword [DISPATCH+OP*4] +|.endif +|.endmacro +| +|// Instruction footer. +|.if 1 +| // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. +| .define ins_next, ins_NEXT +| .define ins_next_, ins_NEXT +|.else +| // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. +| // Affects only certain kinds of benchmarks (and only with -j off). +| // Around 10%-30% slower on Core2, a lot more slower on P4. +| .macro ins_next +| jmp ->ins_next +| .endmacro +| .macro ins_next_ +| ->ins_next: +| ins_NEXT +| .endmacro +|.endif +| +|// Call decode and dispatch. +|.macro ins_callt +| // BASE = new base, RB = LFUNC, RD = nargs+1, [BASE-4] = PC +| mov PC, LFUNC:RB->pc +| mov RA, [PC] +| movzx OP, RAL +| movzx RA, RAH +| add PC, 4 +|.if X64 +| jmp aword [DISPATCH+OP*8] +|.else +| jmp aword [DISPATCH+OP*4] +|.endif +|.endmacro +| +|.macro ins_call +| // BASE = new base, RB = LFUNC, RD = nargs+1 +| mov [BASE-4], PC +| ins_callt +|.endmacro +| +|//----------------------------------------------------------------------- +| +|// Macros to test operand types. +|.macro checktp, reg, tp; cmp dword [BASE+reg*8+4], tp; .endmacro +|.macro checknum, reg, target; checktp reg, LJ_TISNUM; jae target; .endmacro +|.macro checkint, reg, target; checktp reg, LJ_TISNUM; jne target; .endmacro +|.macro checkstr, reg, target; checktp reg, LJ_TSTR; jne target; .endmacro +|.macro checktab, reg, target; checktp reg, LJ_TTAB; jne target; .endmacro +| +|// These operands must be used with movzx. +|.define PC_OP, byte [PC-4] +|.define PC_RA, byte [PC-3] +|.define PC_RB, byte [PC-1] +|.define PC_RC, byte [PC-2] +|.define PC_RD, word [PC-2] +| +|.macro branchPC, reg +| lea PC, [PC+reg*4-BCBIAS_J*4] +|.endmacro +| +|// Assumes DISPATCH is relative to GL. +#define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) +#define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) +| +#define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) +| +|// Decrement hashed hotcount and trigger trace recorder if zero. +|.macro hotloop, reg +| mov reg, PC +| shr reg, 1 +| and reg, HOTCOUNT_PCMASK +| sub word [DISPATCH+reg+GG_DISP2HOT], HOTCOUNT_LOOP +| jb ->vm_hotloop +|.endmacro +| +|.macro hotcall, reg +| mov reg, PC +| shr reg, 1 +| and reg, HOTCOUNT_PCMASK +| sub word [DISPATCH+reg+GG_DISP2HOT], HOTCOUNT_CALL +| jb ->vm_hotcall +|.endmacro +| +|// Set current VM state. +|.macro set_vmstate, st +| mov dword [DISPATCH+DISPATCH_GL(vmstate)], ~LJ_VMST_..st +|.endmacro +| +|// x87 compares. +|.macro fcomparepp // Compare and pop st0 >< st1. +| fucomip st1 +| fpop +|.endmacro +| +|.macro fdup; fld st0; .endmacro +|.macro fpop1; fstp st1; .endmacro +| +|// Synthesize SSE FP constants. +|.macro sseconst_abs, reg, tmp // Synthesize abs mask. +|.if X64 +| mov64 tmp, U64x(7fffffff,ffffffff); movd reg, tmp +|.else +| pxor reg, reg; pcmpeqd reg, reg; psrlq reg, 1 +|.endif +|.endmacro +| +|.macro sseconst_hi, reg, tmp, val // Synthesize hi-32 bit const. +|.if X64 +| mov64 tmp, U64x(val,00000000); movd reg, tmp +|.else +| mov tmp, 0x .. val; movd reg, tmp; pshufd reg, reg, 0x51 +|.endif +|.endmacro +| +|.macro sseconst_sign, reg, tmp // Synthesize sign mask. +| sseconst_hi reg, tmp, 80000000 +|.endmacro +|.macro sseconst_1, reg, tmp // Synthesize 1.0. +| sseconst_hi reg, tmp, 3ff00000 +|.endmacro +|.macro sseconst_m1, reg, tmp // Synthesize -1.0. +| sseconst_hi reg, tmp, bff00000 +|.endmacro +|.macro sseconst_2p52, reg, tmp // Synthesize 2^52. +| sseconst_hi reg, tmp, 43300000 +|.endmacro +|.macro sseconst_tobit, reg, tmp // Synthesize 2^52 + 2^51. +| sseconst_hi reg, tmp, 43380000 +|.endmacro +| +|// Move table write barrier back. Overwrites reg. +|.macro barrierback, tab, reg +| and byte tab->marked, (uint8_t)~LJ_GC_BLACK // black2gray(tab) +| mov reg, [DISPATCH+DISPATCH_GL(gc.grayagain)] +| mov [DISPATCH+DISPATCH_GL(gc.grayagain)], tab +| mov tab->gclist, reg +|.endmacro +| +|//----------------------------------------------------------------------- + +/* Generate subroutines used by opcodes and other parts of the VM. */ +/* The .code_sub section should be last to help static branch prediction. */ +static void build_subroutines(BuildCtx *ctx) +{ + |.code_sub + | + |//----------------------------------------------------------------------- + |//-- Return handling ---------------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_returnp: + | test PC, FRAME_P + | jz ->cont_dispatch + | + | // Return from pcall or xpcall fast func. + | and PC, -8 + | sub BASE, PC // Restore caller base. + | lea RAa, [RA+PC-8] // Rebase RA and prepend one result. + | mov PC, [BASE-4] // Fetch PC of previous frame. + | // Prepending may overwrite the pcall frame, so do it at the end. + | mov dword [BASE+RA+4], LJ_TTRUE // Prepend true to results. + | + |->vm_returnc: + | add RD, 1 // RD = nresults+1 + | jz ->vm_unwind_yield + | mov MULTRES, RD + | test PC, FRAME_TYPE + | jz ->BC_RET_Z // Handle regular return to Lua. + | + |->vm_return: + | // BASE = base, RA = resultofs, RD = nresults+1 (= MULTRES), PC = return + | xor PC, FRAME_C + | test PC, FRAME_TYPE + | jnz ->vm_returnp + | + | // Return to C. + | set_vmstate C + | and PC, -8 + | sub PC, BASE + | neg PC // Previous base = BASE - delta. + | + | sub RD, 1 + | jz >2 + |1: // Move results down. + |.if X64 + | mov RBa, [BASE+RA] + | mov [BASE-8], RBa + |.else + | mov RB, [BASE+RA] + | mov [BASE-8], RB + | mov RB, [BASE+RA+4] + | mov [BASE-4], RB + |.endif + | add BASE, 8 + | sub RD, 1 + | jnz <1 + |2: + | mov L:RB, SAVE_L + | mov L:RB->base, PC + |3: + | mov RD, MULTRES + | mov RA, SAVE_NRES // RA = wanted nresults+1 + |4: + | cmp RA, RD + | jne >6 // More/less results wanted? + |5: + | sub BASE, 8 + | mov L:RB->top, BASE + | + |->vm_leave_cp: + | mov RAa, SAVE_CFRAME // Restore previous C frame. + | mov L:RB->cframe, RAa + | xor eax, eax // Ok return status for vm_pcall. + | + |->vm_leave_unw: + | restoreregs + | ret + | + |6: + | jb >7 // Less results wanted? + | // More results wanted. Check stack size and fill up results with nil. + | cmp BASE, L:RB->maxstack + | ja >8 + | mov dword [BASE-4], LJ_TNIL + | add BASE, 8 + | add RD, 1 + | jmp <4 + | + |7: // Less results wanted. + | test RA, RA + | jz <5 // But check for LUA_MULTRET+1. + | sub RA, RD // Negative result! + | lea BASE, [BASE+RA*8] // Correct top. + | jmp <5 + | + |8: // Corner case: need to grow stack for filling up results. + | // This can happen if: + | // - A C function grows the stack (a lot). + | // - The GC shrinks the stack in between. + | // - A return back from a lua_call() with (high) nresults adjustment. + | mov L:RB->top, BASE // Save current top held in BASE (yes). + | mov MULTRES, RD // Need to fill only remainder with nil. + | mov FCARG2, RA + | mov FCARG1, L:RB + | call extern lj_state_growstack@8 // (lua_State *L, int n) + | mov BASE, L:RB->top // Need the (realloced) L->top in BASE. + | jmp <3 + | + |->vm_unwind_yield: + | mov al, LUA_YIELD + | jmp ->vm_unwind_c_eh + | + |->vm_unwind_c@8: // Unwind C stack, return from vm_pcall. + | // (void *cframe, int errcode) + |.if X64 + | mov eax, CARG2d // Error return status for vm_pcall. + | mov rsp, CARG1 + |.else + | mov eax, FCARG2 // Error return status for vm_pcall. + | mov esp, FCARG1 + |.endif + |->vm_unwind_c_eh: // Landing pad for external unwinder. + | mov L:RB, SAVE_L + | mov GL:RB, L:RB->glref + | mov dword GL:RB->vmstate, ~LJ_VMST_C + | jmp ->vm_leave_unw + | + |->vm_unwind_rethrow: + |.if X64 and not X64WIN + | mov FCARG1, SAVE_L + | mov FCARG2, eax + | restoreregs + | jmp extern lj_err_throw@8 // (lua_State *L, int errcode) + |.endif + | + |->vm_unwind_ff@4: // Unwind C stack, return from ff pcall. + | // (void *cframe) + |.if X64 + | and CARG1, CFRAME_RAWMASK + | mov rsp, CARG1 + |.else + | and FCARG1, CFRAME_RAWMASK + | mov esp, FCARG1 + |.endif + |->vm_unwind_ff_eh: // Landing pad for external unwinder. + | mov L:RB, SAVE_L + | mov RAa, -8 // Results start at BASE+RA = BASE-8. + | mov RD, 1+1 // Really 1+2 results, incr. later. + | mov BASE, L:RB->base + | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table. + | add DISPATCH, GG_G2DISP + | mov PC, [BASE-4] // Fetch PC of previous frame. + | mov dword [BASE-4], LJ_TFALSE // Prepend false to error message. + | set_vmstate INTERP + | jmp ->vm_returnc // Increments RD/MULTRES and returns. + | + |//----------------------------------------------------------------------- + |//-- Grow stack for calls ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_growstack_c: // Grow stack for C function. + | mov FCARG2, LUA_MINSTACK + | jmp >2 + | + |->vm_growstack_v: // Grow stack for vararg Lua function. + | sub RD, 8 + | jmp >1 + | + |->vm_growstack_f: // Grow stack for fixarg Lua function. + | // BASE = new base, RD = nargs+1, RB = L, PC = first PC + | lea RD, [BASE+NARGS:RD*8-8] + |1: + | movzx RA, byte [PC-4+PC2PROTO(framesize)] + | add PC, 4 // Must point after first instruction. + | mov L:RB->base, BASE + | mov L:RB->top, RD + | mov SAVE_PC, PC + | mov FCARG2, RA + |2: + | // RB = L, L->base = new base, L->top = top + | mov FCARG1, L:RB + | call extern lj_state_growstack@8 // (lua_State *L, int n) + | mov BASE, L:RB->base + | mov RD, L:RB->top + | mov LFUNC:RB, [BASE-8] + | sub RD, BASE + | shr RD, 3 + | add NARGS:RD, 1 + | // BASE = new base, RB = LFUNC, RD = nargs+1 + | ins_callt // Just retry the call. + | + |//----------------------------------------------------------------------- + |//-- Entry points into the assembler VM --------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_resume: // Setup C frame and resume thread. + | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) + | saveregs + |.if X64 + | mov L:RB, CARG1d // Caveat: CARG1d may be RA. + | mov SAVE_L, CARG1d + | mov RA, CARG2d + |.else + | mov L:RB, SAVE_L + | mov RA, INARG_BASE // Caveat: overlaps SAVE_CFRAME! + |.endif + | mov PC, FRAME_CP + | xor RD, RD + | lea KBASEa, [esp+CFRAME_RESUME] + | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table. + | add DISPATCH, GG_G2DISP + | mov L:RB->cframe, KBASEa + | mov SAVE_PC, RD // Any value outside of bytecode is ok. + | mov SAVE_CFRAME, RDa + |.if X64 + | mov SAVE_NRES, RD + | mov SAVE_ERRF, RD + |.endif + | cmp byte L:RB->status, RDL + | je >3 // Initial resume (like a call). + | + | // Resume after yield (like a return). + | set_vmstate INTERP + | mov byte L:RB->status, RDL + | mov BASE, L:RB->base + | mov RD, L:RB->top + | sub RD, RA + | shr RD, 3 + | add RD, 1 // RD = nresults+1 + | sub RA, BASE // RA = resultofs + | mov PC, [BASE-4] + | mov MULTRES, RD + | test PC, FRAME_TYPE + | jz ->BC_RET_Z + | jmp ->vm_return + | + |->vm_pcall: // Setup protected C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) + | saveregs + | mov PC, FRAME_CP + |.if X64 + | mov SAVE_ERRF, CARG4d + |.endif + | jmp >1 + | + |->vm_call: // Setup C frame and enter VM. + | // (lua_State *L, TValue *base, int nres1) + | saveregs + | mov PC, FRAME_C + | + |1: // Entry point for vm_pcall above (PC = ftype). + |.if X64 + | mov SAVE_NRES, CARG3d + | mov L:RB, CARG1d // Caveat: CARG1d may be RA. + | mov SAVE_L, CARG1d + | mov RA, CARG2d + |.else + | mov L:RB, SAVE_L + | mov RA, INARG_BASE // Caveat: overlaps SAVE_CFRAME! + |.endif + | + | mov KBASEa, L:RB->cframe // Add our C frame to cframe chain. + | mov SAVE_CFRAME, KBASEa + | mov SAVE_PC, L:RB // Any value outside of bytecode is ok. + |.if X64 + | mov L:RB->cframe, rsp + |.else + | mov L:RB->cframe, esp + |.endif + | + |2: // Entry point for vm_cpcall below (RA = base, RB = L, PC = ftype). + | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table. + | add DISPATCH, GG_G2DISP + | + |3: // Entry point for vm_resume above (RA = base, RB = L, PC = ftype). + | set_vmstate INTERP + | mov BASE, L:RB->base // BASE = old base (used in vmeta_call). + | add PC, RA + | sub PC, BASE // PC = frame delta + frame type + | + | mov RD, L:RB->top + | sub RD, RA + | shr NARGS:RD, 3 + | add NARGS:RD, 1 // RD = nargs+1 + | + |->vm_call_dispatch: + | mov LFUNC:RB, [RA-8] + | cmp dword [RA-4], LJ_TFUNC + | jne ->vmeta_call // Ensure KBASE defined and != BASE. + | + |->vm_call_dispatch_f: + | mov BASE, RA + | ins_call + | // BASE = new base, RB = func, RD = nargs+1, PC = caller PC + | + |->vm_cpcall: // Setup protected C frame, call C. + | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) + | saveregs + |.if X64 + | mov L:RB, CARG1d // Caveat: CARG1d may be RA. + | mov SAVE_L, CARG1d + |.else + | mov L:RB, SAVE_L + | // Caveat: INARG_CP_* and SAVE_CFRAME/SAVE_NRES/SAVE_ERRF overlap! + | mov RC, INARG_CP_UD // Get args before they are overwritten. + | mov RA, INARG_CP_FUNC + | mov BASE, INARG_CP_CALL + |.endif + | mov SAVE_PC, L:RB // Any value outside of bytecode is ok. + | + | mov KBASE, L:RB->stack // Compute -savestack(L, L->top). + | sub KBASE, L:RB->top + | mov SAVE_ERRF, 0 // No error function. + | mov SAVE_NRES, KBASE // Neg. delta means cframe w/o frame. + | // Handler may change cframe_nres(L->cframe) or cframe_errfunc(L->cframe). + | + |.if X64 + | mov KBASEa, L:RB->cframe // Add our C frame to cframe chain. + | mov SAVE_CFRAME, KBASEa + | mov L:RB->cframe, rsp + | + | call CARG4 // (lua_State *L, lua_CFunction func, void *ud) + |.else + | mov ARG3, RC // Have to copy args downwards. + | mov ARG2, RA + | mov ARG1, L:RB + | + | mov KBASE, L:RB->cframe // Add our C frame to cframe chain. + | mov SAVE_CFRAME, KBASE + | mov L:RB->cframe, esp + | + | call BASE // (lua_State *L, lua_CFunction func, void *ud) + |.endif + | // TValue * (new base) or NULL returned in eax (RC). + | test RC, RC + | jz ->vm_leave_cp // No base? Just remove C frame. + | mov RA, RC + | mov PC, FRAME_CP + | jmp <2 // Else continue with the call. + | + |//----------------------------------------------------------------------- + |//-- Metamethod handling ------------------------------------------------ + |//----------------------------------------------------------------------- + | + |//-- Continuation dispatch ---------------------------------------------- + | + |->cont_dispatch: + | // BASE = meta base, RA = resultofs, RD = nresults+1 (also in MULTRES) + | add RA, BASE + | and PC, -8 + | mov RB, BASE + | sub BASE, PC // Restore caller BASE. + | mov dword [RA+RD*8-4], LJ_TNIL // Ensure one valid arg. + | mov RC, RA // ... in [RC] + | mov PC, [RB-12] // Restore PC from [cont|PC]. + |.if X64 + | movsxd RAa, dword [RB-16] // May be negative on WIN64 with debug. + |.if FFI + | cmp RA, 1 + | jbe >1 + |.endif + | lea KBASEa, qword [=>0] + | add RAa, KBASEa + |.else + | mov RA, dword [RB-16] + |.if FFI + | cmp RA, 1 + | jbe >1 + |.endif + |.endif + | mov LFUNC:KBASE, [BASE-8] + | mov KBASE, LFUNC:KBASE->pc + | mov KBASE, [KBASE+PC2PROTO(k)] + | // BASE = base, RC = result, RB = meta base + | jmp RAa // Jump to continuation. + | + |.if FFI + |1: + | je ->cont_ffi_callback // cont = 1: return from FFI callback. + | // cont = 0: Tail call from C function. + | sub RB, BASE + | shr RB, 3 + | lea RD, [RB-1] + | jmp ->vm_call_tail + |.endif + | + |->cont_cat: // BASE = base, RC = result, RB = mbase + | movzx RA, PC_RB + | sub RB, 16 + | lea RA, [BASE+RA*8] + | sub RA, RB + | je ->cont_ra + | neg RA + | shr RA, 3 + |.if X64WIN + | mov CARG3d, RA + | mov L:CARG1d, SAVE_L + | mov L:CARG1d->base, BASE + | mov RCa, [RC] + | mov [RB], RCa + | mov CARG2d, RB + |.elif X64 + | mov L:CARG1d, SAVE_L + | mov L:CARG1d->base, BASE + | mov CARG3d, RA + | mov RAa, [RC] + | mov [RB], RAa + | mov CARG2d, RB + |.else + | mov ARG3, RA + | mov RA, [RC+4] + | mov RC, [RC] + | mov [RB+4], RA + | mov [RB], RC + | mov ARG2, RB + |.endif + | jmp ->BC_CAT_Z + | + |//-- Table indexing metamethods ----------------------------------------- + | + |->vmeta_tgets: + | mov TMP1, RC // RC = GCstr * + | mov TMP2, LJ_TSTR + | lea RCa, TMP1 // Store temp. TValue in TMP1/TMP2. + | cmp PC_OP, BC_GGET + | jne >1 + | lea RA, [DISPATCH+DISPATCH_GL(tmptv)] // Store fn->l.env in g->tmptv. + | mov [RA], TAB:RB // RB = GCtab * + | mov dword [RA+4], LJ_TTAB + | mov RB, RA + | jmp >2 + | + |->vmeta_tgetb: + | movzx RC, PC_RC + |.if DUALNUM + | mov TMP2, LJ_TISNUM + | mov TMP1, RC + |.elif SSE + | cvtsi2sd xmm0, RC + | movsd TMPQ, xmm0 + |.else + | mov ARG4, RC + | fild ARG4 + | fstp TMPQ + |.endif + | lea RCa, TMPQ // Store temp. TValue in TMPQ. + | jmp >1 + | + |->vmeta_tgetv: + | movzx RC, PC_RC // Reload TValue *k from RC. + | lea RC, [BASE+RC*8] + |1: + | movzx RB, PC_RB // Reload TValue *t from RB. + | lea RB, [BASE+RB*8] + |2: + |.if X64 + | mov L:CARG1d, SAVE_L + | mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE. + | mov CARG2d, RB + | mov CARG3, RCa // May be 64 bit ptr to stack. + | mov L:RB, L:CARG1d + |.else + | mov ARG2, RB + | mov L:RB, SAVE_L + | mov ARG3, RC + | mov ARG1, L:RB + | mov L:RB->base, BASE + |.endif + | mov SAVE_PC, PC + | call extern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) + | // TValue * (finished) or NULL (metamethod) returned in eax (RC). + | mov BASE, L:RB->base + | test RC, RC + | jz >3 + |->cont_ra: // BASE = base, RC = result + | movzx RA, PC_RA + |.if X64 + | mov RBa, [RC] + | mov [BASE+RA*8], RBa + |.else + | mov RB, [RC+4] + | mov RC, [RC] + | mov [BASE+RA*8+4], RB + | mov [BASE+RA*8], RC + |.endif + | ins_next + | + |3: // Call __index metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k + | mov RA, L:RB->top + | mov [RA-12], PC // [cont|PC] + | lea PC, [RA+FRAME_CONT] + | sub PC, BASE + | mov LFUNC:RB, [RA-8] // Guaranteed to be a function here. + | mov NARGS:RD, 2+1 // 2 args for func(t, k). + | jmp ->vm_call_dispatch_f + | + |//----------------------------------------------------------------------- + | + |->vmeta_tsets: + | mov TMP1, RC // RC = GCstr * + | mov TMP2, LJ_TSTR + | lea RCa, TMP1 // Store temp. TValue in TMP1/TMP2. + | cmp PC_OP, BC_GSET + | jne >1 + | lea RA, [DISPATCH+DISPATCH_GL(tmptv)] // Store fn->l.env in g->tmptv. + | mov [RA], TAB:RB // RB = GCtab * + | mov dword [RA+4], LJ_TTAB + | mov RB, RA + | jmp >2 + | + |->vmeta_tsetb: + | movzx RC, PC_RC + |.if DUALNUM + | mov TMP2, LJ_TISNUM + | mov TMP1, RC + |.elif SSE + | cvtsi2sd xmm0, RC + | movsd TMPQ, xmm0 + |.else + | mov ARG4, RC + | fild ARG4 + | fstp TMPQ + |.endif + | lea RCa, TMPQ // Store temp. TValue in TMPQ. + | jmp >1 + | + |->vmeta_tsetv: + | movzx RC, PC_RC // Reload TValue *k from RC. + | lea RC, [BASE+RC*8] + |1: + | movzx RB, PC_RB // Reload TValue *t from RB. + | lea RB, [BASE+RB*8] + |2: + |.if X64 + | mov L:CARG1d, SAVE_L + | mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE. + | mov CARG2d, RB + | mov CARG3, RCa // May be 64 bit ptr to stack. + | mov L:RB, L:CARG1d + |.else + | mov ARG2, RB + | mov L:RB, SAVE_L + | mov ARG3, RC + | mov ARG1, L:RB + | mov L:RB->base, BASE + |.endif + | mov SAVE_PC, PC + | call extern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) + | // TValue * (finished) or NULL (metamethod) returned in eax (RC). + | mov BASE, L:RB->base + | test RC, RC + | jz >3 + | // NOBARRIER: lj_meta_tset ensures the table is not black. + | movzx RA, PC_RA + |.if X64 + | mov RBa, [BASE+RA*8] + | mov [RC], RBa + |.else + | mov RB, [BASE+RA*8+4] + | mov RA, [BASE+RA*8] + | mov [RC+4], RB + | mov [RC], RA + |.endif + |->cont_nop: // BASE = base, (RC = result) + | ins_next + | + |3: // Call __newindex metamethod. + | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) + | mov RA, L:RB->top + | mov [RA-12], PC // [cont|PC] + | movzx RC, PC_RA + | // Copy value to third argument. + |.if X64 + | mov RBa, [BASE+RC*8] + | mov [RA+16], RBa + |.else + | mov RB, [BASE+RC*8+4] + | mov RC, [BASE+RC*8] + | mov [RA+20], RB + | mov [RA+16], RC + |.endif + | lea PC, [RA+FRAME_CONT] + | sub PC, BASE + | mov LFUNC:RB, [RA-8] // Guaranteed to be a function here. + | mov NARGS:RD, 3+1 // 3 args for func(t, k, v). + | jmp ->vm_call_dispatch_f + | + |//-- Comparison metamethods --------------------------------------------- + | + |->vmeta_comp: + |.if X64 + | mov L:RB, SAVE_L + | mov L:RB->base, BASE // Caveat: CARG2d/CARG3d == BASE. + |.if X64WIN + | lea CARG3d, [BASE+RD*8] + | lea CARG2d, [BASE+RA*8] + |.else + | lea CARG2d, [BASE+RA*8] + | lea CARG3d, [BASE+RD*8] + |.endif + | mov CARG1d, L:RB // Caveat: CARG1d/CARG4d == RA. + | movzx CARG4d, PC_OP + |.else + | movzx RB, PC_OP + | lea RD, [BASE+RD*8] + | lea RA, [BASE+RA*8] + | mov ARG4, RB + | mov L:RB, SAVE_L + | mov ARG3, RD + | mov ARG2, RA + | mov ARG1, L:RB + | mov L:RB->base, BASE + |.endif + | mov SAVE_PC, PC + | call extern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) + | // 0/1 or TValue * (metamethod) returned in eax (RC). + |3: + | mov BASE, L:RB->base + | cmp RC, 1 + | ja ->vmeta_binop + |4: + | lea PC, [PC+4] + | jb >6 + |5: + | movzx RD, PC_RD + | branchPC RD + |6: + | ins_next + | + |->cont_condt: // BASE = base, RC = result + | add PC, 4 + | cmp dword [RC+4], LJ_TISTRUECOND // Branch if result is true. + | jb <5 + | jmp <6 + | + |->cont_condf: // BASE = base, RC = result + | cmp dword [RC+4], LJ_TISTRUECOND // Branch if result is false. + | jmp <4 + | + |->vmeta_equal: + | sub PC, 4 + |.if X64WIN + | mov CARG3d, RD + | mov CARG4d, RB + | mov L:RB, SAVE_L + | mov L:RB->base, BASE // Caveat: CARG2d == BASE. + | mov CARG2d, RA + | mov CARG1d, L:RB // Caveat: CARG1d == RA. + |.elif X64 + | mov CARG2d, RA + | mov CARG4d, RB // Caveat: CARG4d == RA. + | mov L:RB, SAVE_L + | mov L:RB->base, BASE // Caveat: CARG3d == BASE. + | mov CARG3d, RD + | mov CARG1d, L:RB + |.else + | mov ARG4, RB + | mov L:RB, SAVE_L + | mov ARG3, RD + | mov ARG2, RA + | mov ARG1, L:RB + | mov L:RB->base, BASE + |.endif + | mov SAVE_PC, PC + | call extern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) + | // 0/1 or TValue * (metamethod) returned in eax (RC). + | jmp <3 + | + |->vmeta_equal_cd: + |.if FFI + | sub PC, 4 + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + | mov FCARG1, L:RB + | mov FCARG2, dword [PC-4] + | mov SAVE_PC, PC + | call extern lj_meta_equal_cd@8 // (lua_State *L, BCIns ins) + | // 0/1 or TValue * (metamethod) returned in eax (RC). + | jmp <3 + |.endif + | + |//-- Arithmetic metamethods --------------------------------------------- + | + |->vmeta_arith_vno: + |.if DUALNUM + | movzx RB, PC_RB + |.endif + |->vmeta_arith_vn: + | lea RC, [KBASE+RC*8] + | jmp >1 + | + |->vmeta_arith_nvo: + |.if DUALNUM + | movzx RC, PC_RC + |.endif + |->vmeta_arith_nv: + | lea RC, [KBASE+RC*8] + | lea RB, [BASE+RB*8] + | xchg RB, RC + | jmp >2 + | + |->vmeta_unm: + | lea RC, [BASE+RD*8] + | mov RB, RC + | jmp >2 + | + |->vmeta_arith_vvo: + |.if DUALNUM + | movzx RB, PC_RB + |.endif + |->vmeta_arith_vv: + | lea RC, [BASE+RC*8] + |1: + | lea RB, [BASE+RB*8] + |2: + | lea RA, [BASE+RA*8] + |.if X64WIN + | mov CARG3d, RB + | mov CARG4d, RC + | movzx RC, PC_OP + | mov ARG5d, RC + | mov L:RB, SAVE_L + | mov L:RB->base, BASE // Caveat: CARG2d == BASE. + | mov CARG2d, RA + | mov CARG1d, L:RB // Caveat: CARG1d == RA. + |.elif X64 + | movzx CARG5d, PC_OP + | mov CARG2d, RA + | mov CARG4d, RC // Caveat: CARG4d == RA. + | mov L:CARG1d, SAVE_L + | mov L:CARG1d->base, BASE // Caveat: CARG3d == BASE. + | mov CARG3d, RB + | mov L:RB, L:CARG1d + |.else + | mov ARG3, RB + | mov L:RB, SAVE_L + | mov ARG4, RC + | movzx RC, PC_OP + | mov ARG2, RA + | mov ARG5, RC + | mov ARG1, L:RB + | mov L:RB->base, BASE + |.endif + | mov SAVE_PC, PC + | call extern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) + | // NULL (finished) or TValue * (metamethod) returned in eax (RC). + | mov BASE, L:RB->base + | test RC, RC + | jz ->cont_nop + | + | // Call metamethod for binary op. + |->vmeta_binop: + | // BASE = base, RC = new base, stack = cont/func/o1/o2 + | mov RA, RC + | sub RC, BASE + | mov [RA-12], PC // [cont|PC] + | lea PC, [RC+FRAME_CONT] + | mov NARGS:RD, 2+1 // 2 args for func(o1, o2). + | jmp ->vm_call_dispatch + | + |->vmeta_len: + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + | lea FCARG2, [BASE+RD*8] // Caveat: FCARG2 == BASE + | mov L:FCARG1, L:RB + | mov SAVE_PC, PC + | call extern lj_meta_len@8 // (lua_State *L, TValue *o) + | // NULL (retry) or TValue * (metamethod) returned in eax (RC). + | mov BASE, L:RB->base +#if LJ_52 + | test RC, RC + | jne ->vmeta_binop // Binop call for compatibility. + | movzx RD, PC_RD + | mov TAB:FCARG1, [BASE+RD*8] + | jmp ->BC_LEN_Z +#else + | jmp ->vmeta_binop // Binop call for compatibility. +#endif + | + |//-- Call metamethod ---------------------------------------------------- + | + |->vmeta_call_ra: + | lea RA, [BASE+RA*8+8] + |->vmeta_call: // Resolve and call __call metamethod. + | // BASE = old base, RA = new base, RC = nargs+1, PC = return + | mov TMP2, RA // Save RA, RC for us. + | mov TMP1, NARGS:RD + | sub RA, 8 + |.if X64 + | mov L:RB, SAVE_L + | mov L:RB->base, BASE // Caveat: CARG2d/CARG3d may be BASE. + | mov CARG2d, RA + | lea CARG3d, [RA+NARGS:RD*8] + | mov CARG1d, L:RB // Caveat: CARG1d may be RA. + |.else + | lea RC, [RA+NARGS:RD*8] + | mov L:RB, SAVE_L + | mov ARG2, RA + | mov ARG3, RC + | mov ARG1, L:RB + | mov L:RB->base, BASE // This is the callers base! + |.endif + | mov SAVE_PC, PC + | call extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) + | mov BASE, L:RB->base + | mov RA, TMP2 + | mov NARGS:RD, TMP1 + | mov LFUNC:RB, [RA-8] + | add NARGS:RD, 1 + | // This is fragile. L->base must not move, KBASE must always be defined. + | cmp KBASE, BASE // Continue with CALLT if flag set. + | je ->BC_CALLT_Z + | mov BASE, RA + | ins_call // Otherwise call resolved metamethod. + | + |//-- Argument coercion for 'for' statement ------------------------------ + | + |->vmeta_for: + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + | mov FCARG2, RA // Caveat: FCARG2 == BASE + | mov L:FCARG1, L:RB // Caveat: FCARG1 == RA + | mov SAVE_PC, PC + | call extern lj_meta_for@8 // (lua_State *L, TValue *base) + | mov BASE, L:RB->base + | mov RC, [PC-4] + | movzx RA, RCH + | movzx OP, RCL + | shr RC, 16 + |.if X64 + | jmp aword [DISPATCH+OP*8+GG_DISP2STATIC] // Retry FORI or JFORI. + |.else + | jmp aword [DISPATCH+OP*4+GG_DISP2STATIC] // Retry FORI or JFORI. + |.endif + | + |//----------------------------------------------------------------------- + |//-- Fast functions ----------------------------------------------------- + |//----------------------------------------------------------------------- + | + |.macro .ffunc, name + |->ff_ .. name: + |.endmacro + | + |.macro .ffunc_1, name + |->ff_ .. name: + | cmp NARGS:RD, 1+1; jb ->fff_fallback + |.endmacro + | + |.macro .ffunc_2, name + |->ff_ .. name: + | cmp NARGS:RD, 2+1; jb ->fff_fallback + |.endmacro + | + |.macro .ffunc_n, name + | .ffunc_1 name + | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback + | fld qword [BASE] + |.endmacro + | + |.macro .ffunc_n, name, op + | .ffunc_1 name + | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback + | op + | fld qword [BASE] + |.endmacro + | + |.macro .ffunc_nsse, name, op + | .ffunc_1 name + | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback + | op xmm0, qword [BASE] + |.endmacro + | + |.macro .ffunc_nsse, name + | .ffunc_nsse name, movsd + |.endmacro + | + |.macro .ffunc_nn, name + | .ffunc_2 name + | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback + | cmp dword [BASE+12], LJ_TISNUM; jae ->fff_fallback + | fld qword [BASE] + | fld qword [BASE+8] + |.endmacro + | + |.macro .ffunc_nnsse, name + | .ffunc_2 name + | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback + | cmp dword [BASE+12], LJ_TISNUM; jae ->fff_fallback + | movsd xmm0, qword [BASE] + | movsd xmm1, qword [BASE+8] + |.endmacro + | + |.macro .ffunc_nnr, name + | .ffunc_2 name + | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback + | cmp dword [BASE+12], LJ_TISNUM; jae ->fff_fallback + | fld qword [BASE+8] + | fld qword [BASE] + |.endmacro + | + |// Inlined GC threshold check. Caveat: uses label 1. + |.macro ffgccheck + | mov RB, [DISPATCH+DISPATCH_GL(gc.total)] + | cmp RB, [DISPATCH+DISPATCH_GL(gc.threshold)] + | jb >1 + | call ->fff_gcstep + |1: + |.endmacro + | + |//-- Base library: checks ----------------------------------------------- + | + |.ffunc_1 assert + | mov RB, [BASE+4] + | cmp RB, LJ_TISTRUECOND; jae ->fff_fallback + | mov PC, [BASE-4] + | mov MULTRES, RD + | mov [BASE-4], RB + | mov RB, [BASE] + | mov [BASE-8], RB + | sub RD, 2 + | jz >2 + | mov RA, BASE + |1: + | add RA, 8 + |.if X64 + | mov RBa, [RA] + | mov [RA-8], RBa + |.else + | mov RB, [RA+4] + | mov [RA-4], RB + | mov RB, [RA] + | mov [RA-8], RB + |.endif + | sub RD, 1 + | jnz <1 + |2: + | mov RD, MULTRES + | jmp ->fff_res_ + | + |.ffunc_1 type + | mov RB, [BASE+4] + |.if X64 + | mov RA, RB + | sar RA, 15 + | cmp RA, -2 + | je >3 + |.endif + | mov RC, ~LJ_TNUMX + | not RB + | cmp RC, RB + | cmova RC, RB + |2: + | mov CFUNC:RB, [BASE-8] + | mov STR:RC, [CFUNC:RB+RC*8+((char *)(&((GCfuncC *)0)->upvalue))] + | mov PC, [BASE-4] + | mov dword [BASE-4], LJ_TSTR + | mov [BASE-8], STR:RC + | jmp ->fff_res1 + |.if X64 + |3: + | mov RC, ~LJ_TLIGHTUD + | jmp <2 + |.endif + | + |//-- Base library: getters and setters --------------------------------- + | + |.ffunc_1 getmetatable + | mov RB, [BASE+4] + | mov PC, [BASE-4] + | cmp RB, LJ_TTAB; jne >6 + |1: // Field metatable must be at same offset for GCtab and GCudata! + | mov TAB:RB, [BASE] + | mov TAB:RB, TAB:RB->metatable + |2: + | test TAB:RB, TAB:RB + | mov dword [BASE-4], LJ_TNIL + | jz ->fff_res1 + | mov STR:RC, [DISPATCH+DISPATCH_GL(gcroot)+4*(GCROOT_MMNAME+MM_metatable)] + | mov dword [BASE-4], LJ_TTAB // Store metatable as default result. + | mov [BASE-8], TAB:RB + | mov RA, TAB:RB->hmask + | and RA, STR:RC->hash + | imul RA, #NODE + | add NODE:RA, TAB:RB->node + |3: // Rearranged logic, because we expect _not_ to find the key. + | cmp dword NODE:RA->key.it, LJ_TSTR + | jne >4 + | cmp dword NODE:RA->key.gcr, STR:RC + | je >5 + |4: + | mov NODE:RA, NODE:RA->next + | test NODE:RA, NODE:RA + | jnz <3 + | jmp ->fff_res1 // Not found, keep default result. + |5: + | mov RB, [RA+4] + | cmp RB, LJ_TNIL; je ->fff_res1 // Ditto for nil value. + | mov RC, [RA] + | mov [BASE-4], RB // Return value of mt.__metatable. + | mov [BASE-8], RC + | jmp ->fff_res1 + | + |6: + | cmp RB, LJ_TUDATA; je <1 + |.if X64 + | cmp RB, LJ_TNUMX; ja >8 + | cmp RB, LJ_TISNUM; jbe >7 + | mov RB, LJ_TLIGHTUD + | jmp >8 + |7: + |.else + | cmp RB, LJ_TISNUM; ja >8 + |.endif + | mov RB, LJ_TNUMX + |8: + | not RB + | mov TAB:RB, [DISPATCH+RB*4+DISPATCH_GL(gcroot[GCROOT_BASEMT])] + | jmp <2 + | + |.ffunc_2 setmetatable + | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback + | // Fast path: no mt for table yet and not clearing the mt. + | mov TAB:RB, [BASE] + | cmp dword TAB:RB->metatable, 0; jne ->fff_fallback + | cmp dword [BASE+12], LJ_TTAB; jne ->fff_fallback + | mov TAB:RC, [BASE+8] + | mov TAB:RB->metatable, TAB:RC + | mov PC, [BASE-4] + | mov dword [BASE-4], LJ_TTAB // Return original table. + | mov [BASE-8], TAB:RB + | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) + | jz >1 + | // Possible write barrier. Table is black, but skip iswhite(mt) check. + | barrierback TAB:RB, RC + |1: + | jmp ->fff_res1 + | + |.ffunc_2 rawget + | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback + |.if X64WIN + | mov RB, BASE // Save BASE. + | lea CARG3d, [BASE+8] + | mov CARG2d, [BASE] // Caveat: CARG2d == BASE. + | mov CARG1d, SAVE_L + |.elif X64 + | mov RB, BASE // Save BASE. + | mov CARG2d, [BASE] + | lea CARG3d, [BASE+8] // Caveat: CARG3d == BASE. + | mov CARG1d, SAVE_L + |.else + | mov TAB:RD, [BASE] + | mov L:RB, SAVE_L + | mov ARG2, TAB:RD + | mov ARG1, L:RB + | mov RB, BASE // Save BASE. + | add BASE, 8 + | mov ARG3, BASE + |.endif + | call extern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) + | // cTValue * returned in eax (RD). + | mov BASE, RB // Restore BASE. + | // Copy table slot. + |.if X64 + | mov RBa, [RD] + | mov PC, [BASE-4] + | mov [BASE-8], RBa + |.else + | mov RB, [RD] + | mov RD, [RD+4] + | mov PC, [BASE-4] + | mov [BASE-8], RB + | mov [BASE-4], RD + |.endif + | jmp ->fff_res1 + | + |//-- Base library: conversions ------------------------------------------ + | + |.ffunc tonumber + | // Only handles the number case inline (without a base argument). + | cmp NARGS:RD, 1+1; jne ->fff_fallback // Exactly one argument. + | cmp dword [BASE+4], LJ_TISNUM + |.if DUALNUM + | jne >1 + | mov RB, dword [BASE]; jmp ->fff_resi + |1: + | ja ->fff_fallback + |.else + | jae ->fff_fallback + |.endif + |.if SSE + | movsd xmm0, qword [BASE]; jmp ->fff_resxmm0 + |.else + | fld qword [BASE]; jmp ->fff_resn + |.endif + | + |.ffunc_1 tostring + | // Only handles the string or number case inline. + | mov PC, [BASE-4] + | cmp dword [BASE+4], LJ_TSTR; jne >3 + | // A __tostring method in the string base metatable is ignored. + | mov STR:RD, [BASE] + |2: + | mov dword [BASE-4], LJ_TSTR + | mov [BASE-8], STR:RD + | jmp ->fff_res1 + |3: // Handle numbers inline, unless a number base metatable is present. + | cmp dword [BASE+4], LJ_TISNUM; ja ->fff_fallback + | cmp dword [DISPATCH+DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])], 0 + | jne ->fff_fallback + | ffgccheck // Caveat: uses label 1. + | mov L:RB, SAVE_L + | mov L:RB->base, BASE // Add frame since C call can throw. + | mov SAVE_PC, PC // Redundant (but a defined value). + |.if X64 and not X64WIN + | mov FCARG2, BASE // Otherwise: FCARG2 == BASE + |.endif + | mov L:FCARG1, L:RB + |.if DUALNUM + | call extern lj_str_fromnumber@8 // (lua_State *L, cTValue *o) + |.else + | call extern lj_str_fromnum@8 // (lua_State *L, lua_Number *np) + |.endif + | // GCstr returned in eax (RD). + | mov BASE, L:RB->base + | jmp <2 + | + |//-- Base library: iterators ------------------------------------------- + | + |.ffunc_1 next + | je >2 // Missing 2nd arg? + |1: + | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback + | mov L:RB, SAVE_L + | mov L:RB->base, BASE // Add frame since C call can throw. + | mov L:RB->top, BASE // Dummy frame length is ok. + | mov PC, [BASE-4] + |.if X64WIN + | lea CARG3d, [BASE+8] + | mov CARG2d, [BASE] // Caveat: CARG2d == BASE. + | mov CARG1d, L:RB + |.elif X64 + | mov CARG2d, [BASE] + | lea CARG3d, [BASE+8] // Caveat: CARG3d == BASE. + | mov CARG1d, L:RB + |.else + | mov TAB:RD, [BASE] + | mov ARG2, TAB:RD + | mov ARG1, L:RB + | add BASE, 8 + | mov ARG3, BASE + |.endif + | mov SAVE_PC, PC // Needed for ITERN fallback. + | call extern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) + | // Flag returned in eax (RD). + | mov BASE, L:RB->base + | test RD, RD; jz >3 // End of traversal? + | // Copy key and value to results. + |.if X64 + | mov RBa, [BASE+8] + | mov RDa, [BASE+16] + | mov [BASE-8], RBa + | mov [BASE], RDa + |.else + | mov RB, [BASE+8] + | mov RD, [BASE+12] + | mov [BASE-8], RB + | mov [BASE-4], RD + | mov RB, [BASE+16] + | mov RD, [BASE+20] + | mov [BASE], RB + | mov [BASE+4], RD + |.endif + |->fff_res2: + | mov RD, 1+2 + | jmp ->fff_res + |2: // Set missing 2nd arg to nil. + | mov dword [BASE+12], LJ_TNIL + | jmp <1 + |3: // End of traversal: return nil. + | mov dword [BASE-4], LJ_TNIL + | jmp ->fff_res1 + | + |.ffunc_1 pairs + | mov TAB:RB, [BASE] + | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback +#if LJ_52 + | cmp dword TAB:RB->metatable, 0; jne ->fff_fallback +#endif + | mov CFUNC:RB, [BASE-8] + | mov CFUNC:RD, CFUNC:RB->upvalue[0] + | mov PC, [BASE-4] + | mov dword [BASE-4], LJ_TFUNC + | mov [BASE-8], CFUNC:RD + | mov dword [BASE+12], LJ_TNIL + | mov RD, 1+3 + | jmp ->fff_res + | + |.ffunc_2 ipairs_aux + | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback + | cmp dword [BASE+12], LJ_TISNUM + |.if DUALNUM + | jne ->fff_fallback + |.else + | jae ->fff_fallback + |.endif + | mov PC, [BASE-4] + |.if DUALNUM + | mov RD, dword [BASE+8] + | add RD, 1 + | mov dword [BASE-4], LJ_TISNUM + | mov dword [BASE-8], RD + |.elif SSE + | movsd xmm0, qword [BASE+8] + | sseconst_1 xmm1, RBa + | addsd xmm0, xmm1 + | cvtsd2si RD, xmm0 + | movsd qword [BASE-8], xmm0 + |.else + | fld qword [BASE+8] + | fld1 + | faddp st1 + | fist ARG1 + | fstp qword [BASE-8] + | mov RD, ARG1 + |.endif + | mov TAB:RB, [BASE] + | cmp RD, TAB:RB->asize; jae >2 // Not in array part? + | shl RD, 3 + | add RD, TAB:RB->array + |1: + | cmp dword [RD+4], LJ_TNIL; je ->fff_res0 + | // Copy array slot. + |.if X64 + | mov RBa, [RD] + | mov [BASE], RBa + |.else + | mov RB, [RD] + | mov RD, [RD+4] + | mov [BASE], RB + | mov [BASE+4], RD + |.endif + | jmp ->fff_res2 + |2: // Check for empty hash part first. Otherwise call C function. + | cmp dword TAB:RB->hmask, 0; je ->fff_res0 + | mov FCARG1, TAB:RB + | mov RB, BASE // Save BASE. + | mov FCARG2, RD // Caveat: FCARG2 == BASE + | call extern lj_tab_getinth@8 // (GCtab *t, int32_t key) + | // cTValue * or NULL returned in eax (RD). + | mov BASE, RB + | test RD, RD + | jnz <1 + |->fff_res0: + | mov RD, 1+0 + | jmp ->fff_res + | + |.ffunc_1 ipairs + | mov TAB:RB, [BASE] + | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback +#if LJ_52 + | cmp dword TAB:RB->metatable, 0; jne ->fff_fallback +#endif + | mov CFUNC:RB, [BASE-8] + | mov CFUNC:RD, CFUNC:RB->upvalue[0] + | mov PC, [BASE-4] + | mov dword [BASE-4], LJ_TFUNC + | mov [BASE-8], CFUNC:RD + |.if DUALNUM + | mov dword [BASE+12], LJ_TISNUM + | mov dword [BASE+8], 0 + |.elif SSE + | xorps xmm0, xmm0 + | movsd qword [BASE+8], xmm0 + |.else + | fldz + | fstp qword [BASE+8] + |.endif + | mov RD, 1+3 + | jmp ->fff_res + | + |//-- Base library: catch errors ---------------------------------------- + | + |.ffunc_1 pcall + | lea RA, [BASE+8] + | sub NARGS:RD, 1 + | mov PC, 8+FRAME_PCALL + |1: + | movzx RB, byte [DISPATCH+DISPATCH_GL(hookmask)] + | shr RB, HOOK_ACTIVE_SHIFT + | and RB, 1 + | add PC, RB // Remember active hook before pcall. + | jmp ->vm_call_dispatch + | + |.ffunc_2 xpcall + | cmp dword [BASE+12], LJ_TFUNC; jne ->fff_fallback + | mov RB, [BASE+4] // Swap function and traceback. + | mov [BASE+12], RB + | mov dword [BASE+4], LJ_TFUNC + | mov LFUNC:RB, [BASE] + | mov PC, [BASE+8] + | mov [BASE+8], LFUNC:RB + | mov [BASE], PC + | lea RA, [BASE+16] + | sub NARGS:RD, 2 + | mov PC, 16+FRAME_PCALL + | jmp <1 + | + |//-- Coroutine library -------------------------------------------------- + | + |.macro coroutine_resume_wrap, resume + |.if resume + |.ffunc_1 coroutine_resume + | mov L:RB, [BASE] + |.else + |.ffunc coroutine_wrap_aux + | mov CFUNC:RB, [BASE-8] + | mov L:RB, CFUNC:RB->upvalue[0].gcr + |.endif + | mov PC, [BASE-4] + | mov SAVE_PC, PC + |.if X64 + | mov TMP1, L:RB + |.else + | mov ARG1, L:RB + |.endif + |.if resume + | cmp dword [BASE+4], LJ_TTHREAD; jne ->fff_fallback + |.endif + | cmp aword L:RB->cframe, 0; jne ->fff_fallback + | cmp byte L:RB->status, LUA_YIELD; ja ->fff_fallback + | mov RA, L:RB->top + | je >1 // Status != LUA_YIELD (i.e. 0)? + | cmp RA, L:RB->base // Check for presence of initial func. + | je ->fff_fallback + |1: + |.if resume + | lea PC, [RA+NARGS:RD*8-16] // Check stack space (-1-thread). + |.else + | lea PC, [RA+NARGS:RD*8-8] // Check stack space (-1). + |.endif + | cmp PC, L:RB->maxstack; ja ->fff_fallback + | mov L:RB->top, PC + | + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + |.if resume + | add BASE, 8 // Keep resumed thread in stack for GC. + |.endif + | mov L:RB->top, BASE + |.if resume + | lea RB, [BASE+NARGS:RD*8-24] // RB = end of source for stack move. + |.else + | lea RB, [BASE+NARGS:RD*8-16] // RB = end of source for stack move. + |.endif + | sub RBa, PCa // Relative to PC. + | + | cmp PC, RA + | je >3 + |2: // Move args to coroutine. + |.if X64 + | mov RCa, [PC+RB] + | mov [PC-8], RCa + |.else + | mov RC, [PC+RB+4] + | mov [PC-4], RC + | mov RC, [PC+RB] + | mov [PC-8], RC + |.endif + | sub PC, 8 + | cmp PC, RA + | jne <2 + |3: + |.if X64 + | mov CARG2d, RA + | mov CARG1d, TMP1 + |.else + | mov ARG2, RA + | xor RA, RA + | mov ARG4, RA + | mov ARG3, RA + |.endif + | call ->vm_resume // (lua_State *L, TValue *base, 0, 0) + | set_vmstate INTERP + | + | mov L:RB, SAVE_L + |.if X64 + | mov L:PC, TMP1 + |.else + | mov L:PC, ARG1 // The callee doesn't modify SAVE_L. + |.endif + | mov BASE, L:RB->base + | cmp eax, LUA_YIELD + | ja >8 + |4: + | mov RA, L:PC->base + | mov KBASE, L:PC->top + | mov L:PC->top, RA // Clear coroutine stack. + | mov PC, KBASE + | sub PC, RA + | je >6 // No results? + | lea RD, [BASE+PC] + | shr PC, 3 + | cmp RD, L:RB->maxstack + | ja >9 // Need to grow stack? + | + | mov RB, BASE + | sub RBa, RAa + |5: // Move results from coroutine. + |.if X64 + | mov RDa, [RA] + | mov [RA+RB], RDa + |.else + | mov RD, [RA] + | mov [RA+RB], RD + | mov RD, [RA+4] + | mov [RA+RB+4], RD + |.endif + | add RA, 8 + | cmp RA, KBASE + | jne <5 + |6: + |.if resume + | lea RD, [PC+2] // nresults+1 = 1 + true + results. + | mov dword [BASE-4], LJ_TTRUE // Prepend true to results. + |.else + | lea RD, [PC+1] // nresults+1 = 1 + results. + |.endif + |7: + | mov PC, SAVE_PC + | mov MULTRES, RD + |.if resume + | mov RAa, -8 + |.else + | xor RA, RA + |.endif + | test PC, FRAME_TYPE + | jz ->BC_RET_Z + | jmp ->vm_return + | + |8: // Coroutine returned with error (at co->top-1). + |.if resume + | mov dword [BASE-4], LJ_TFALSE // Prepend false to results. + | mov RA, L:PC->top + | sub RA, 8 + | mov L:PC->top, RA // Clear error from coroutine stack. + | // Copy error message. + |.if X64 + | mov RDa, [RA] + | mov [BASE], RDa + |.else + | mov RD, [RA] + | mov [BASE], RD + | mov RD, [RA+4] + | mov [BASE+4], RD + |.endif + | mov RD, 1+2 // nresults+1 = 1 + false + error. + | jmp <7 + |.else + | mov FCARG2, L:PC + | mov FCARG1, L:RB + | call extern lj_ffh_coroutine_wrap_err@8 // (lua_State *L, lua_State *co) + | // Error function does not return. + |.endif + | + |9: // Handle stack expansion on return from yield. + |.if X64 + | mov L:RA, TMP1 + |.else + | mov L:RA, ARG1 // The callee doesn't modify SAVE_L. + |.endif + | mov L:RA->top, KBASE // Undo coroutine stack clearing. + | mov FCARG2, PC + | mov FCARG1, L:RB + | call extern lj_state_growstack@8 // (lua_State *L, int n) + |.if X64 + | mov L:PC, TMP1 + |.else + | mov L:PC, ARG1 + |.endif + | mov BASE, L:RB->base + | jmp <4 // Retry the stack move. + |.endmacro + | + | coroutine_resume_wrap 1 // coroutine.resume + | coroutine_resume_wrap 0 // coroutine.wrap + | + |.ffunc coroutine_yield + | mov L:RB, SAVE_L + | test aword L:RB->cframe, CFRAME_RESUME + | jz ->fff_fallback + | mov L:RB->base, BASE + | lea RD, [BASE+NARGS:RD*8-8] + | mov L:RB->top, RD + | xor RD, RD + | mov aword L:RB->cframe, RDa + | mov al, LUA_YIELD + | mov byte L:RB->status, al + | jmp ->vm_leave_unw + | + |//-- Math library ------------------------------------------------------- + | + |.if not DUALNUM + |->fff_resi: // Dummy. + |.endif + | + |.if SSE + |->fff_resn: + | mov PC, [BASE-4] + | fstp qword [BASE-8] + | jmp ->fff_res1 + |.endif + | + | .ffunc_1 math_abs + |.if DUALNUM + | cmp dword [BASE+4], LJ_TISNUM; jne >2 + | mov RB, dword [BASE] + | cmp RB, 0; jns ->fff_resi + | neg RB; js >1 + |->fff_resbit: + |->fff_resi: + | mov PC, [BASE-4] + | mov dword [BASE-4], LJ_TISNUM + | mov dword [BASE-8], RB + | jmp ->fff_res1 + |1: + | mov PC, [BASE-4] + | mov dword [BASE-4], 0x41e00000 // 2^31. + | mov dword [BASE-8], 0 + | jmp ->fff_res1 + |2: + | ja ->fff_fallback + |.else + | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback + |.endif + | + |.if SSE + | movsd xmm0, qword [BASE] + | sseconst_abs xmm1, RDa + | andps xmm0, xmm1 + |->fff_resxmm0: + | mov PC, [BASE-4] + | movsd qword [BASE-8], xmm0 + | // fallthrough + |.else + | fld qword [BASE] + | fabs + | // fallthrough + |->fff_resxmm0: // Dummy. + |->fff_resn: + | mov PC, [BASE-4] + | fstp qword [BASE-8] + |.endif + | + |->fff_res1: + | mov RD, 1+1 + |->fff_res: + | mov MULTRES, RD + |->fff_res_: + | test PC, FRAME_TYPE + | jnz >7 + |5: + | cmp PC_RB, RDL // More results expected? + | ja >6 + | // Adjust BASE. KBASE is assumed to be set for the calling frame. + | movzx RA, PC_RA + | not RAa // Note: ~RA = -(RA+1) + | lea BASE, [BASE+RA*8] // base = base - (RA+1)*8 + | ins_next + | + |6: // Fill up results with nil. + | mov dword [BASE+RD*8-12], LJ_TNIL + | add RD, 1 + | jmp <5 + | + |7: // Non-standard return case. + | mov RAa, -8 // Results start at BASE+RA = BASE-8. + | jmp ->vm_return + | + |.macro math_round, func + | .ffunc math_ .. func + |.if DUALNUM + | cmp dword [BASE+4], LJ_TISNUM; jne >1 + | mov RB, dword [BASE]; jmp ->fff_resi + |1: + | ja ->fff_fallback + |.else + | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback + |.endif + |.if SSE + | movsd xmm0, qword [BASE] + | call ->vm_ .. func + | .if DUALNUM + | cvtsd2si RB, xmm0 + | cmp RB, 0x80000000 + | jne ->fff_resi + | cvtsi2sd xmm1, RB + | ucomisd xmm0, xmm1 + | jp ->fff_resxmm0 + | je ->fff_resi + | .endif + | jmp ->fff_resxmm0 + |.else + | fld qword [BASE] + | call ->vm_ .. func + | .if DUALNUM + | fist ARG1 + | mov RB, ARG1 + | cmp RB, 0x80000000; jne >2 + | fdup + | fild ARG1 + | fcomparepp + | jp ->fff_resn + | jne ->fff_resn + |2: + | fpop + | jmp ->fff_resi + | .else + | jmp ->fff_resn + | .endif + |.endif + |.endmacro + | + | math_round floor + | math_round ceil + | + |.if SSE + |.ffunc_nsse math_sqrt, sqrtsd; jmp ->fff_resxmm0 + |.else + |.ffunc_n math_sqrt; fsqrt; jmp ->fff_resn + |.endif + | + |.ffunc math_log + | cmp NARGS:RD, 1+1; jne ->fff_fallback // Exactly one argument. + | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback + | fldln2; fld qword [BASE]; fyl2x; jmp ->fff_resn + | + |.ffunc_n math_log10, fldlg2; fyl2x; jmp ->fff_resn + |.ffunc_n math_exp; call ->vm_exp_x87; jmp ->fff_resn + | + |.ffunc_n math_sin; fsin; jmp ->fff_resn + |.ffunc_n math_cos; fcos; jmp ->fff_resn + |.ffunc_n math_tan; fptan; fpop; jmp ->fff_resn + | + |.ffunc_n math_asin + | fdup; fmul st0; fld1; fsubrp st1; fsqrt; fpatan + | jmp ->fff_resn + |.ffunc_n math_acos + | fdup; fmul st0; fld1; fsubrp st1; fsqrt; fxch; fpatan + | jmp ->fff_resn + |.ffunc_n math_atan; fld1; fpatan; jmp ->fff_resn + | + |.macro math_extern, func + |.if SSE + | .ffunc_nsse math_ .. func + | .if not X64 + | movsd FPARG1, xmm0 + | .endif + |.else + | .ffunc_n math_ .. func + | fstp FPARG1 + |.endif + | mov RB, BASE + | call extern lj_vm_ .. func + | mov BASE, RB + | .if X64 + | jmp ->fff_resxmm0 + | .else + | jmp ->fff_resn + | .endif + |.endmacro + | + | math_extern sinh + | math_extern cosh + | math_extern tanh + | + |->ff_math_deg: + |.if SSE + |.ffunc_nsse math_rad + | mov CFUNC:RB, [BASE-8] + | mulsd xmm0, qword CFUNC:RB->upvalue[0] + | jmp ->fff_resxmm0 + |.else + |.ffunc_n math_rad + | mov CFUNC:RB, [BASE-8] + | fmul qword CFUNC:RB->upvalue[0] + | jmp ->fff_resn + |.endif + | + |.ffunc_nn math_atan2; fpatan; jmp ->fff_resn + |.ffunc_nnr math_ldexp; fscale; fpop1; jmp ->fff_resn + | + |.ffunc_1 math_frexp + | mov RB, [BASE+4] + | cmp RB, LJ_TISNUM; jae ->fff_fallback + | mov PC, [BASE-4] + | mov RC, [BASE] + | mov [BASE-4], RB; mov [BASE-8], RC + | shl RB, 1; cmp RB, 0xffe00000; jae >3 + | or RC, RB; jz >3 + | mov RC, 1022 + | cmp RB, 0x00200000; jb >4 + |1: + | shr RB, 21; sub RB, RC // Extract and unbias exponent. + |.if SSE + | cvtsi2sd xmm0, RB + |.else + | mov TMP1, RB; fild TMP1 + |.endif + | mov RB, [BASE-4] + | and RB, 0x800fffff // Mask off exponent. + | or RB, 0x3fe00000 // Put mantissa in range [0.5,1) or 0. + | mov [BASE-4], RB + |2: + |.if SSE + | movsd qword [BASE], xmm0 + |.else + | fstp qword [BASE] + |.endif + | mov RD, 1+2 + | jmp ->fff_res + |3: // Return +-0, +-Inf, NaN unmodified and an exponent of 0. + |.if SSE + | xorps xmm0, xmm0; jmp <2 + |.else + | fldz; jmp <2 + |.endif + |4: // Handle denormals by multiplying with 2^54 and adjusting the bias. + |.if SSE + | movsd xmm0, qword [BASE] + | sseconst_hi xmm1, RBa, 43500000 // 2^54. + | mulsd xmm0, xmm1 + | movsd qword [BASE-8], xmm0 + |.else + | fld qword [BASE] + | mov TMP1, 0x5a800000; fmul TMP1 // x = x*2^54 + | fstp qword [BASE-8] + |.endif + | mov RB, [BASE-4]; mov RC, 1076; shl RB, 1; jmp <1 + | + |.if SSE + |.ffunc_nsse math_modf + |.else + |.ffunc_n math_modf + |.endif + | mov RB, [BASE+4] + | mov PC, [BASE-4] + | shl RB, 1; cmp RB, 0xffe00000; je >4 // +-Inf? + |.if SSE + | movaps xmm4, xmm0 + | call ->vm_trunc + | subsd xmm4, xmm0 + |1: + | movsd qword [BASE-8], xmm0 + | movsd qword [BASE], xmm4 + |.else + | fdup + | call ->vm_trunc + | fsub st1, st0 + |1: + | fstp qword [BASE-8] + | fstp qword [BASE] + |.endif + | mov RC, [BASE-4]; mov RB, [BASE+4] + | xor RC, RB; js >3 // Need to adjust sign? + |2: + | mov RD, 1+2 + | jmp ->fff_res + |3: + | xor RB, 0x80000000; mov [BASE+4], RB // Flip sign of fraction. + | jmp <2 + |4: + |.if SSE + | xorps xmm4, xmm4; jmp <1 // Return +-Inf and +-0. + |.else + | fldz; fxch; jmp <1 // Return +-Inf and +-0. + |.endif + | + |.ffunc_nnr math_fmod + |1: ; fprem; fnstsw ax; and ax, 0x400; jnz <1 + | fpop1 + | jmp ->fff_resn + | + |.if SSE + |.ffunc_nnsse math_pow; call ->vm_pow; jmp ->fff_resxmm0 + |.else + |.ffunc_nn math_pow; call ->vm_pow; jmp ->fff_resn + |.endif + | + |.macro math_minmax, name, cmovop, fcmovop, sseop + | .ffunc name + | mov RA, 2 + | cmp dword [BASE+4], LJ_TISNUM + |.if DUALNUM + | jne >4 + | mov RB, dword [BASE] + |1: // Handle integers. + | cmp RA, RD; jae ->fff_resi + | cmp dword [BASE+RA*8-4], LJ_TISNUM; jne >3 + | cmp RB, dword [BASE+RA*8-8] + | cmovop RB, dword [BASE+RA*8-8] + | add RA, 1 + | jmp <1 + |3: + | ja ->fff_fallback + | // Convert intermediate result to number and continue below. + |.if SSE + | cvtsi2sd xmm0, RB + |.else + | mov TMP1, RB + | fild TMP1 + |.endif + | jmp >6 + |4: + | ja ->fff_fallback + |.else + | jae ->fff_fallback + |.endif + | + |.if SSE + | movsd xmm0, qword [BASE] + |5: // Handle numbers or integers. + | cmp RA, RD; jae ->fff_resxmm0 + | cmp dword [BASE+RA*8-4], LJ_TISNUM + |.if DUALNUM + | jb >6 + | ja ->fff_fallback + | cvtsi2sd xmm1, dword [BASE+RA*8-8] + | jmp >7 + |.else + | jae ->fff_fallback + |.endif + |6: + | movsd xmm1, qword [BASE+RA*8-8] + |7: + | sseop xmm0, xmm1 + | add RA, 1 + | jmp <5 + |.else + | fld qword [BASE] + |5: // Handle numbers or integers. + | cmp RA, RD; jae ->fff_resn + | cmp dword [BASE+RA*8-4], LJ_TISNUM + |.if DUALNUM + | jb >6 + | ja >9 + | fild dword [BASE+RA*8-8] + | jmp >7 + |.else + | jae >9 + |.endif + |6: + | fld qword [BASE+RA*8-8] + |7: + | fucomi st1; fcmovop st1; fpop1 + | add RA, 1 + | jmp <5 + |.endif + |.endmacro + | + | math_minmax math_min, cmovg, fcmovnbe, minsd + | math_minmax math_max, cmovl, fcmovbe, maxsd + |.if not SSE + |9: + | fpop; jmp ->fff_fallback + |.endif + | + |//-- String library ----------------------------------------------------- + | + |.ffunc_1 string_len + | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback + | mov STR:RB, [BASE] + |.if DUALNUM + | mov RB, dword STR:RB->len; jmp ->fff_resi + |.elif SSE + | cvtsi2sd xmm0, dword STR:RB->len; jmp ->fff_resxmm0 + |.else + | fild dword STR:RB->len; jmp ->fff_resn + |.endif + | + |.ffunc string_byte // Only handle the 1-arg case here. + | cmp NARGS:RD, 1+1; jne ->fff_fallback + | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback + | mov STR:RB, [BASE] + | mov PC, [BASE-4] + | cmp dword STR:RB->len, 1 + | jb ->fff_res0 // Return no results for empty string. + | movzx RB, byte STR:RB[1] + |.if DUALNUM + | jmp ->fff_resi + |.elif SSE + | cvtsi2sd xmm0, RB; jmp ->fff_resxmm0 + |.else + | mov TMP1, RB; fild TMP1; jmp ->fff_resn + |.endif + | + |.ffunc string_char // Only handle the 1-arg case here. + | ffgccheck + | cmp NARGS:RD, 1+1; jne ->fff_fallback // *Exactly* 1 arg. + | cmp dword [BASE+4], LJ_TISNUM + |.if DUALNUM + | jne ->fff_fallback + | mov RB, dword [BASE] + | cmp RB, 255; ja ->fff_fallback + | mov TMP2, RB + |.elif SSE + | jae ->fff_fallback + | cvttsd2si RB, qword [BASE] + | cmp RB, 255; ja ->fff_fallback + | mov TMP2, RB + |.else + | jae ->fff_fallback + | fld qword [BASE] + | fistp TMP2 + | cmp TMP2, 255; ja ->fff_fallback + |.endif + |.if X64 + | mov TMP3, 1 + |.else + | mov ARG3, 1 + |.endif + | lea RDa, TMP2 // Points to stack. Little-endian. + |->fff_newstr: + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + |.if X64 + | mov CARG3d, TMP3 // Zero-extended to size_t. + | mov CARG2, RDa // May be 64 bit ptr to stack. + | mov CARG1d, L:RB + |.else + | mov ARG2, RD + | mov ARG1, L:RB + |.endif + | mov SAVE_PC, PC + | call extern lj_str_new // (lua_State *L, char *str, size_t l) + | // GCstr * returned in eax (RD). + | mov BASE, L:RB->base + | mov PC, [BASE-4] + | mov dword [BASE-4], LJ_TSTR + | mov [BASE-8], STR:RD + | jmp ->fff_res1 + | + |.ffunc string_sub + | ffgccheck + | mov TMP2, -1 + | cmp NARGS:RD, 1+2; jb ->fff_fallback + | jna >1 + | cmp dword [BASE+20], LJ_TISNUM + |.if DUALNUM + | jne ->fff_fallback + | mov RB, dword [BASE+16] + | mov TMP2, RB + |.elif SSE + | jae ->fff_fallback + | cvttsd2si RB, qword [BASE+16] + | mov TMP2, RB + |.else + | jae ->fff_fallback + | fld qword [BASE+16] + | fistp TMP2 + |.endif + |1: + | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback + | cmp dword [BASE+12], LJ_TISNUM + |.if DUALNUM + | jne ->fff_fallback + |.else + | jae ->fff_fallback + |.endif + | mov STR:RB, [BASE] + | mov TMP3, STR:RB + | mov RB, STR:RB->len + |.if DUALNUM + | mov RA, dword [BASE+8] + |.elif SSE + | cvttsd2si RA, qword [BASE+8] + |.else + | fld qword [BASE+8] + | fistp ARG3 + | mov RA, ARG3 + |.endif + | mov RC, TMP2 + | cmp RB, RC // len < end? (unsigned compare) + | jb >5 + |2: + | test RA, RA // start <= 0? + | jle >7 + |3: + | mov STR:RB, TMP3 + | sub RC, RA // start > end? + | jl ->fff_emptystr + | lea RB, [STR:RB+RA+#STR-1] + | add RC, 1 + |4: + |.if X64 + | mov TMP3, RC + |.else + | mov ARG3, RC + |.endif + | mov RD, RB + | jmp ->fff_newstr + | + |5: // Negative end or overflow. + | jl >6 + | lea RC, [RC+RB+1] // end = end+(len+1) + | jmp <2 + |6: // Overflow. + | mov RC, RB // end = len + | jmp <2 + | + |7: // Negative start or underflow. + | je >8 + | add RA, RB // start = start+(len+1) + | add RA, 1 + | jg <3 // start > 0? + |8: // Underflow. + | mov RA, 1 // start = 1 + | jmp <3 + | + |->fff_emptystr: // Range underflow. + | xor RC, RC // Zero length. Any ptr in RB is ok. + | jmp <4 + | + |.ffunc string_rep // Only handle the 1-char case inline. + | ffgccheck + | cmp NARGS:RD, 2+1; jne ->fff_fallback // Exactly 2 arguments. + | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback + | cmp dword [BASE+12], LJ_TISNUM + | mov STR:RB, [BASE] + |.if DUALNUM + | jne ->fff_fallback + | mov RC, dword [BASE+8] + |.elif SSE + | jae ->fff_fallback + | cvttsd2si RC, qword [BASE+8] + |.else + | jae ->fff_fallback + | fld qword [BASE+8] + | fistp TMP2 + | mov RC, TMP2 + |.endif + | test RC, RC + | jle ->fff_emptystr // Count <= 0? (or non-int) + | cmp dword STR:RB->len, 1 + | jb ->fff_emptystr // Zero length string? + | jne ->fff_fallback_2 // Fallback for > 1-char strings. + | cmp [DISPATCH+DISPATCH_GL(tmpbuf.sz)], RC; jb ->fff_fallback_2 + | movzx RA, byte STR:RB[1] + | mov RB, [DISPATCH+DISPATCH_GL(tmpbuf.buf)] + |.if X64 + | mov TMP3, RC + |.else + | mov ARG3, RC + |.endif + |1: // Fill buffer with char. Yes, this is suboptimal code (do you care?). + | mov [RB], RAL + | add RB, 1 + | sub RC, 1 + | jnz <1 + | mov RD, [DISPATCH+DISPATCH_GL(tmpbuf.buf)] + | jmp ->fff_newstr + | + |.ffunc_1 string_reverse + | ffgccheck + | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback + | mov STR:RB, [BASE] + | mov RC, STR:RB->len + | test RC, RC + | jz ->fff_emptystr // Zero length string? + | cmp [DISPATCH+DISPATCH_GL(tmpbuf.sz)], RC; jb ->fff_fallback_1 + | add RB, #STR + | mov TMP2, PC // Need another temp register. + |.if X64 + | mov TMP3, RC + |.else + | mov ARG3, RC + |.endif + | mov PC, [DISPATCH+DISPATCH_GL(tmpbuf.buf)] + |1: + | movzx RA, byte [RB] + | add RB, 1 + | sub RC, 1 + | mov [PC+RC], RAL + | jnz <1 + | mov RD, PC + | mov PC, TMP2 + | jmp ->fff_newstr + | + |.macro ffstring_case, name, lo, hi + | .ffunc_1 name + | ffgccheck + | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback + | mov STR:RB, [BASE] + | mov RC, STR:RB->len + | cmp [DISPATCH+DISPATCH_GL(tmpbuf.sz)], RC; jb ->fff_fallback_1 + | add RB, #STR + | mov TMP2, PC // Need another temp register. + |.if X64 + | mov TMP3, RC + |.else + | mov ARG3, RC + |.endif + | mov PC, [DISPATCH+DISPATCH_GL(tmpbuf.buf)] + | jmp >3 + |1: // ASCII case conversion. Yes, this is suboptimal code (do you care?). + | movzx RA, byte [RB+RC] + | cmp RA, lo + | jb >2 + | cmp RA, hi + | ja >2 + | xor RA, 0x20 + |2: + | mov [PC+RC], RAL + |3: + | sub RC, 1 + | jns <1 + | mov RD, PC + | mov PC, TMP2 + | jmp ->fff_newstr + |.endmacro + | + |ffstring_case string_lower, 0x41, 0x5a + |ffstring_case string_upper, 0x61, 0x7a + | + |//-- Table library ------------------------------------------------------ + | + |.ffunc_1 table_getn + | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback + | mov RB, BASE // Save BASE. + | mov TAB:FCARG1, [BASE] + | call extern lj_tab_len@4 // LJ_FASTCALL (GCtab *t) + | // Length of table returned in eax (RD). + | mov BASE, RB // Restore BASE. + |.if DUALNUM + | mov RB, RD; jmp ->fff_resi + |.elif SSE + | cvtsi2sd xmm0, RD; jmp ->fff_resxmm0 + |.else + | mov ARG1, RD; fild ARG1; jmp ->fff_resn + |.endif + | + |//-- Bit library -------------------------------------------------------- + | + |.define TOBIT_BIAS, 0x59c00000 // 2^52 + 2^51 (float, not double!). + | + |.macro .ffunc_bit, name, kind, fdef + | fdef name + |.if kind == 2 + |.if SSE + | sseconst_tobit xmm1, RBa + |.else + | mov TMP1, TOBIT_BIAS + |.endif + |.endif + | cmp dword [BASE+4], LJ_TISNUM + |.if DUALNUM + | jne >1 + | mov RB, dword [BASE] + |.if kind > 0 + | jmp >2 + |.else + | jmp ->fff_resbit + |.endif + |1: + | ja ->fff_fallback + |.else + | jae ->fff_fallback + |.endif + |.if SSE + | movsd xmm0, qword [BASE] + |.if kind < 2 + | sseconst_tobit xmm1, RBa + |.endif + | addsd xmm0, xmm1 + | movd RB, xmm0 + |.else + | fld qword [BASE] + |.if kind < 2 + | mov TMP1, TOBIT_BIAS + |.endif + | fadd TMP1 + | fstp FPARG1 + |.if kind > 0 + | mov RB, ARG1 + |.endif + |.endif + |2: + |.endmacro + | + |.macro .ffunc_bit, name, kind + | .ffunc_bit name, kind, .ffunc_1 + |.endmacro + | + |.ffunc_bit bit_tobit, 0 + |.if DUALNUM or SSE + |.if not SSE + | mov RB, ARG1 + |.endif + | jmp ->fff_resbit + |.else + | fild ARG1 + | jmp ->fff_resn + |.endif + | + |.macro .ffunc_bit_op, name, ins + | .ffunc_bit name, 2 + | mov TMP2, NARGS:RD // Save for fallback. + | lea RD, [BASE+NARGS:RD*8-16] + |1: + | cmp RD, BASE + | jbe ->fff_resbit + | cmp dword [RD+4], LJ_TISNUM + |.if DUALNUM + | jne >2 + | ins RB, dword [RD] + | sub RD, 8 + | jmp <1 + |2: + | ja ->fff_fallback_bit_op + |.else + | jae ->fff_fallback_bit_op + |.endif + |.if SSE + | movsd xmm0, qword [RD] + | addsd xmm0, xmm1 + | movd RA, xmm0 + | ins RB, RA + |.else + | fld qword [RD] + | fadd TMP1 + | fstp FPARG1 + | ins RB, ARG1 + |.endif + | sub RD, 8 + | jmp <1 + |.endmacro + | + |.ffunc_bit_op bit_band, and + |.ffunc_bit_op bit_bor, or + |.ffunc_bit_op bit_bxor, xor + | + |.ffunc_bit bit_bswap, 1 + | bswap RB + | jmp ->fff_resbit + | + |.ffunc_bit bit_bnot, 1 + | not RB + |.if DUALNUM + | jmp ->fff_resbit + |.elif SSE + |->fff_resbit: + | cvtsi2sd xmm0, RB + | jmp ->fff_resxmm0 + |.else + |->fff_resbit: + | mov ARG1, RB + | fild ARG1 + | jmp ->fff_resn + |.endif + | + |->fff_fallback_bit_op: + | mov NARGS:RD, TMP2 // Restore for fallback + | jmp ->fff_fallback + | + |.macro .ffunc_bit_sh, name, ins + |.if DUALNUM + | .ffunc_bit name, 1, .ffunc_2 + | // Note: no inline conversion from number for 2nd argument! + | cmp dword [BASE+12], LJ_TISNUM; jne ->fff_fallback + | mov RA, dword [BASE+8] + |.elif SSE + | .ffunc_nnsse name + | sseconst_tobit xmm2, RBa + | addsd xmm0, xmm2 + | addsd xmm1, xmm2 + | movd RB, xmm0 + | movd RA, xmm1 + |.else + | .ffunc_nn name + | mov TMP1, TOBIT_BIAS + | fadd TMP1 + | fstp FPARG3 + | fadd TMP1 + | fstp FPARG1 + | mov RA, ARG3 + | mov RB, ARG1 + |.endif + | ins RB, cl // Assumes RA is ecx. + | jmp ->fff_resbit + |.endmacro + | + |.ffunc_bit_sh bit_lshift, shl + |.ffunc_bit_sh bit_rshift, shr + |.ffunc_bit_sh bit_arshift, sar + |.ffunc_bit_sh bit_rol, rol + |.ffunc_bit_sh bit_ror, ror + | + |//----------------------------------------------------------------------- + | + |->fff_fallback_2: + | mov NARGS:RD, 1+2 // Other args are ignored, anyway. + | jmp ->fff_fallback + |->fff_fallback_1: + | mov NARGS:RD, 1+1 // Other args are ignored, anyway. + |->fff_fallback: // Call fast function fallback handler. + | // BASE = new base, RD = nargs+1 + | mov L:RB, SAVE_L + | mov PC, [BASE-4] // Fallback may overwrite PC. + | mov SAVE_PC, PC // Redundant (but a defined value). + | mov L:RB->base, BASE + | lea RD, [BASE+NARGS:RD*8-8] + | lea RA, [RD+8*LUA_MINSTACK] // Ensure enough space for handler. + | mov L:RB->top, RD + | mov CFUNC:RD, [BASE-8] + | cmp RA, L:RB->maxstack + | ja >5 // Need to grow stack. + |.if X64 + | mov CARG1d, L:RB + |.else + | mov ARG1, L:RB + |.endif + | call aword CFUNC:RD->f // (lua_State *L) + | mov BASE, L:RB->base + | // Either throws an error, or recovers and returns -1, 0 or nresults+1. + | test RD, RD; jg ->fff_res // Returned nresults+1? + |1: + | mov RA, L:RB->top + | sub RA, BASE + | shr RA, 3 + | test RD, RD + | lea NARGS:RD, [RA+1] + | mov LFUNC:RB, [BASE-8] + | jne ->vm_call_tail // Returned -1? + | ins_callt // Returned 0: retry fast path. + | + |// Reconstruct previous base for vmeta_call during tailcall. + |->vm_call_tail: + | mov RA, BASE + | test PC, FRAME_TYPE + | jnz >3 + | movzx RB, PC_RA + | not RBa // Note: ~RB = -(RB+1) + | lea BASE, [BASE+RB*8] // base = base - (RB+1)*8 + | jmp ->vm_call_dispatch // Resolve again for tailcall. + |3: + | mov RB, PC + | and RB, -8 + | sub BASE, RB + | jmp ->vm_call_dispatch // Resolve again for tailcall. + | + |5: // Grow stack for fallback handler. + | mov FCARG2, LUA_MINSTACK + | mov FCARG1, L:RB + | call extern lj_state_growstack@8 // (lua_State *L, int n) + | mov BASE, L:RB->base + | xor RD, RD // Simulate a return 0. + | jmp <1 // Dumb retry (goes through ff first). + | + |->fff_gcstep: // Call GC step function. + | // BASE = new base, RD = nargs+1 + | pop RBa // Must keep stack at same level. + | mov TMPa, RBa // Save return address + | mov L:RB, SAVE_L + | mov SAVE_PC, PC // Redundant (but a defined value). + | mov L:RB->base, BASE + | lea RD, [BASE+NARGS:RD*8-8] + | mov FCARG1, L:RB + | mov L:RB->top, RD + | call extern lj_gc_step@4 // (lua_State *L) + | mov BASE, L:RB->base + | mov RD, L:RB->top + | sub RD, BASE + | shr RD, 3 + | add NARGS:RD, 1 + | mov RBa, TMPa + | push RBa // Restore return address. + | ret + | + |//----------------------------------------------------------------------- + |//-- Special dispatch targets ------------------------------------------- + |//----------------------------------------------------------------------- + | + |->vm_record: // Dispatch target for recording phase. + |.if JIT + | movzx RD, byte [DISPATCH+DISPATCH_GL(hookmask)] + | test RDL, HOOK_VMEVENT // No recording while in vmevent. + | jnz >5 + | // Decrement the hookcount for consistency, but always do the call. + | test RDL, HOOK_ACTIVE + | jnz >1 + | test RDL, LUA_MASKLINE|LUA_MASKCOUNT + | jz >1 + | dec dword [DISPATCH+DISPATCH_GL(hookcount)] + | jmp >1 + |.endif + | + |->vm_rethook: // Dispatch target for return hooks. + | movzx RD, byte [DISPATCH+DISPATCH_GL(hookmask)] + | test RDL, HOOK_ACTIVE // Hook already active? + | jnz >5 + | jmp >1 + | + |->vm_inshook: // Dispatch target for instr/line hooks. + | movzx RD, byte [DISPATCH+DISPATCH_GL(hookmask)] + | test RDL, HOOK_ACTIVE // Hook already active? + | jnz >5 + | + | test RDL, LUA_MASKLINE|LUA_MASKCOUNT + | jz >5 + | dec dword [DISPATCH+DISPATCH_GL(hookcount)] + | jz >1 + | test RDL, LUA_MASKLINE + | jz >5 + |1: + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + | mov FCARG2, PC // Caveat: FCARG2 == BASE + | mov FCARG1, L:RB + | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. + | call extern lj_dispatch_ins@8 // (lua_State *L, BCIns *pc) + |3: + | mov BASE, L:RB->base + |4: + | movzx RA, PC_RA + |5: + | movzx OP, PC_OP + | movzx RD, PC_RD + |.if X64 + | jmp aword [DISPATCH+OP*8+GG_DISP2STATIC] // Re-dispatch to static ins. + |.else + | jmp aword [DISPATCH+OP*4+GG_DISP2STATIC] // Re-dispatch to static ins. + |.endif + | + |->cont_hook: // Continue from hook yield. + | add PC, 4 + | mov RA, [RB-24] + | mov MULTRES, RA // Restore MULTRES for *M ins. + | jmp <4 + | + |->vm_hotloop: // Hot loop counter underflow. + |.if JIT + | mov LFUNC:RB, [BASE-8] // Same as curr_topL(L). + | mov RB, LFUNC:RB->pc + | movzx RD, byte [RB+PC2PROTO(framesize)] + | lea RD, [BASE+RD*8] + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + | mov L:RB->top, RD + | mov FCARG2, PC + | lea FCARG1, [DISPATCH+GG_DISP2J] + | mov aword [DISPATCH+DISPATCH_J(L)], L:RBa + | mov SAVE_PC, PC + | call extern lj_trace_hot@8 // (jit_State *J, const BCIns *pc) + | jmp <3 + |.endif + | + |->vm_callhook: // Dispatch target for call hooks. + | mov SAVE_PC, PC + |.if JIT + | jmp >1 + |.endif + | + |->vm_hotcall: // Hot call counter underflow. + |.if JIT + | mov SAVE_PC, PC + | or PC, 1 // Marker for hot call. + |1: + |.endif + | lea RD, [BASE+NARGS:RD*8-8] + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + | mov L:RB->top, RD + | mov FCARG2, PC + | mov FCARG1, L:RB + | call extern lj_dispatch_call@8 // (lua_State *L, const BCIns *pc) + | // ASMFunction returned in eax/rax (RDa). + | mov SAVE_PC, 0 // Invalidate for subsequent line hook. + |.if JIT + | and PC, -2 + |.endif + | mov BASE, L:RB->base + | mov RAa, RDa + | mov RD, L:RB->top + | sub RD, BASE + | mov RBa, RAa + | movzx RA, PC_RA + | shr RD, 3 + | add NARGS:RD, 1 + | jmp RBa + | + |//----------------------------------------------------------------------- + |//-- Trace exit handler ------------------------------------------------- + |//----------------------------------------------------------------------- + | + |// Called from an exit stub with the exit number on the stack. + |// The 16 bit exit number is stored with two (sign-extended) push imm8. + |->vm_exit_handler: + |.if JIT + |.if X64 + | push r13; push r12 + | push r11; push r10; push r9; push r8 + | push rdi; push rsi; push rbp; lea rbp, [rsp+88]; push rbp + | push rbx; push rdx; push rcx; push rax + | movzx RC, byte [rbp-8] // Reconstruct exit number. + | mov RCH, byte [rbp-16] + | mov [rbp-8], r15; mov [rbp-16], r14 + |.else + | push ebp; lea ebp, [esp+12]; push ebp + | push ebx; push edx; push ecx; push eax + | movzx RC, byte [ebp-4] // Reconstruct exit number. + | mov RCH, byte [ebp-8] + | mov [ebp-4], edi; mov [ebp-8], esi + |.endif + | // Caveat: DISPATCH is ebx. + | mov DISPATCH, [ebp] + | mov RA, [DISPATCH+DISPATCH_GL(vmstate)] // Get trace number. + | set_vmstate EXIT + | mov [DISPATCH+DISPATCH_J(exitno)], RC + | mov [DISPATCH+DISPATCH_J(parent)], RA + |.if X64 + |.if X64WIN + | sub rsp, 16*8+4*8 // Room for SSE regs + save area. + |.else + | sub rsp, 16*8 // Room for SSE regs. + |.endif + | add rbp, -128 + | movsd qword [rbp-8], xmm15; movsd qword [rbp-16], xmm14 + | movsd qword [rbp-24], xmm13; movsd qword [rbp-32], xmm12 + | movsd qword [rbp-40], xmm11; movsd qword [rbp-48], xmm10 + | movsd qword [rbp-56], xmm9; movsd qword [rbp-64], xmm8 + | movsd qword [rbp-72], xmm7; movsd qword [rbp-80], xmm6 + | movsd qword [rbp-88], xmm5; movsd qword [rbp-96], xmm4 + | movsd qword [rbp-104], xmm3; movsd qword [rbp-112], xmm2 + | movsd qword [rbp-120], xmm1; movsd qword [rbp-128], xmm0 + |.else + | sub esp, 8*8+16 // Room for SSE regs + args. + | movsd qword [ebp-40], xmm7; movsd qword [ebp-48], xmm6 + | movsd qword [ebp-56], xmm5; movsd qword [ebp-64], xmm4 + | movsd qword [ebp-72], xmm3; movsd qword [ebp-80], xmm2 + | movsd qword [ebp-88], xmm1; movsd qword [ebp-96], xmm0 + |.endif + | // Caveat: RB is ebp. + | mov L:RB, [DISPATCH+DISPATCH_GL(jit_L)] + | mov BASE, [DISPATCH+DISPATCH_GL(jit_base)] + | mov aword [DISPATCH+DISPATCH_J(L)], L:RBa + | mov dword [DISPATCH+DISPATCH_GL(jit_L)], 0 + | mov L:RB->base, BASE + |.if X64WIN + | lea CARG2, [rsp+4*8] + |.elif X64 + | mov CARG2, rsp + |.else + | lea FCARG2, [esp+16] + |.endif + | lea FCARG1, [DISPATCH+GG_DISP2J] + | call extern lj_trace_exit@8 // (jit_State *J, ExitState *ex) + | // MULTRES or negated error code returned in eax (RD). + | mov RAa, L:RB->cframe + | and RAa, CFRAME_RAWMASK + |.if X64WIN + | // Reposition stack later. + |.elif X64 + | mov rsp, RAa // Reposition stack to C frame. + |.else + | mov esp, RAa // Reposition stack to C frame. + |.endif + | mov [RAa+CFRAME_OFS_L], L:RB // Set SAVE_L (on-trace resume/yield). + | mov BASE, L:RB->base + | mov PC, [RAa+CFRAME_OFS_PC] // Get SAVE_PC. + |.if X64 + | jmp >1 + |.endif + |.endif + |->vm_exit_interp: + | // RD = MULTRES or negated error code, BASE, PC and DISPATCH set. + |.if JIT + |.if X64 + | // Restore additional callee-save registers only used in compiled code. + |.if X64WIN + | lea RAa, [rsp+9*16+4*8] + |1: + | movdqa xmm15, [RAa-9*16] + | movdqa xmm14, [RAa-8*16] + | movdqa xmm13, [RAa-7*16] + | movdqa xmm12, [RAa-6*16] + | movdqa xmm11, [RAa-5*16] + | movdqa xmm10, [RAa-4*16] + | movdqa xmm9, [RAa-3*16] + | movdqa xmm8, [RAa-2*16] + | movdqa xmm7, [RAa-1*16] + | mov rsp, RAa // Reposition stack to C frame. + | movdqa xmm6, [RAa] + | mov r15, CSAVE_3 + | mov r14, CSAVE_4 + |.else + | add rsp, 16 // Reposition stack to C frame. + |1: + |.endif + | mov r13, TMPa + | mov r12, TMPQ + |.endif + | test RD, RD; js >3 // Check for error from exit. + | mov MULTRES, RD + | mov LFUNC:KBASE, [BASE-8] + | mov KBASE, LFUNC:KBASE->pc + | mov KBASE, [KBASE+PC2PROTO(k)] + | mov dword [DISPATCH+DISPATCH_GL(jit_L)], 0 + | set_vmstate INTERP + | // Modified copy of ins_next which handles function header dispatch, too. + | mov RC, [PC] + | movzx RA, RCH + | movzx OP, RCL + | add PC, 4 + | shr RC, 16 + | cmp OP, BC_FUNCF // Function header? + | jb >2 + | mov RC, MULTRES // RC/RD holds nres+1. + |2: + |.if X64 + | jmp aword [DISPATCH+OP*8] + |.else + | jmp aword [DISPATCH+OP*4] + |.endif + | + |3: // Rethrow error from the right C frame. + | neg RD + | mov FCARG1, L:RB + | mov FCARG2, RD + | call extern lj_err_throw@8 // (lua_State *L, int errcode) + |.endif + | + |//----------------------------------------------------------------------- + |//-- Math helper functions ---------------------------------------------- + |//----------------------------------------------------------------------- + | + |// FP value rounding. Called by math.floor/math.ceil fast functions + |// and from JIT code. + | + |// x87 variant: Arg/ret on x87 stack. No int/xmm registers modified. + |.macro vm_round_x87, mode1, mode2 + | fnstcw word [esp+4] // Caveat: overwrites ARG1 and ARG2. + | mov [esp+8], eax + | mov ax, mode1 + | or ax, [esp+4] + |.if mode2 ~= 0xffff + | and ax, mode2 + |.endif + | mov [esp+6], ax + | fldcw word [esp+6] + | frndint + | fldcw word [esp+4] + | mov eax, [esp+8] + | ret + |.endmacro + | + |// SSE variant: arg/ret is xmm0. xmm0-xmm3 and RD (eax) modified. + |.macro vm_round_sse, mode + | sseconst_abs xmm2, RDa + | sseconst_2p52 xmm3, RDa + | movaps xmm1, xmm0 + | andpd xmm1, xmm2 // |x| + | ucomisd xmm3, xmm1 // No truncation if 2^52 <= |x|. + | jbe >1 + | andnpd xmm2, xmm0 // Isolate sign bit. + |.if mode == 2 // trunc(x)? + | movaps xmm0, xmm1 + | addsd xmm1, xmm3 // (|x| + 2^52) - 2^52 + | subsd xmm1, xmm3 + | sseconst_1 xmm3, RDa + | cmpsd xmm0, xmm1, 1 // |x| < result? + | andpd xmm0, xmm3 + | subsd xmm1, xmm0 // If yes, subtract -1. + | orpd xmm1, xmm2 // Merge sign bit back in. + |.else + | addsd xmm1, xmm3 // (|x| + 2^52) - 2^52 + | subsd xmm1, xmm3 + | orpd xmm1, xmm2 // Merge sign bit back in. + | .if mode == 1 // ceil(x)? + | sseconst_m1 xmm2, RDa // Must subtract -1 to preserve -0. + | cmpsd xmm0, xmm1, 6 // x > result? + | .else // floor(x)? + | sseconst_1 xmm2, RDa + | cmpsd xmm0, xmm1, 1 // x < result? + | .endif + | andpd xmm0, xmm2 + | subsd xmm1, xmm0 // If yes, subtract +-1. + |.endif + | movaps xmm0, xmm1 + |1: + | ret + |.endmacro + | + |.macro vm_round, name, ssemode, mode1, mode2 + |->name: + |.if not SSE + | vm_round_x87 mode1, mode2 + |.endif + |->name .. _sse: + | vm_round_sse ssemode + |.endmacro + | + | vm_round vm_floor, 0, 0x0400, 0xf7ff + | vm_round vm_ceil, 1, 0x0800, 0xfbff + | vm_round vm_trunc, 2, 0x0c00, 0xffff + | + |// FP modulo x%y. Called by BC_MOD* and vm_arith. + |->vm_mod: + |.if SSE + |// Args in xmm0/xmm1, return value in xmm0. + |// Caveat: xmm0-xmm5 and RC (eax) modified! + | movaps xmm5, xmm0 + | divsd xmm0, xmm1 + | sseconst_abs xmm2, RDa + | sseconst_2p52 xmm3, RDa + | movaps xmm4, xmm0 + | andpd xmm4, xmm2 // |x/y| + | ucomisd xmm3, xmm4 // No truncation if 2^52 <= |x/y|. + | jbe >1 + | andnpd xmm2, xmm0 // Isolate sign bit. + | addsd xmm4, xmm3 // (|x/y| + 2^52) - 2^52 + | subsd xmm4, xmm3 + | orpd xmm4, xmm2 // Merge sign bit back in. + | sseconst_1 xmm2, RDa + | cmpsd xmm0, xmm4, 1 // x/y < result? + | andpd xmm0, xmm2 + | subsd xmm4, xmm0 // If yes, subtract 1.0. + | movaps xmm0, xmm5 + | mulsd xmm1, xmm4 + | subsd xmm0, xmm1 + | ret + |1: + | mulsd xmm1, xmm0 + | movaps xmm0, xmm5 + | subsd xmm0, xmm1 + | ret + |.else + |// Args/ret on x87 stack (y on top). No xmm registers modified. + |// Caveat: needs 3 slots on x87 stack! RC (eax) modified! + | fld st1 + | fdiv st1 + | fnstcw word [esp+4] + | mov ax, 0x0400 + | or ax, [esp+4] + | and ax, 0xf7ff + | mov [esp+6], ax + | fldcw word [esp+6] + | frndint + | fldcw word [esp+4] + | fmulp st1 + | fsubp st1 + | ret + |.endif + | + |// FP log2(x). Called by math.log(x, base). + |->vm_log2: + |.if X64WIN + | movsd qword [rsp+8], xmm0 // Use scratch area. + | fld1 + | fld qword [rsp+8] + | fyl2x + | fstp qword [rsp+8] + | movsd xmm0, qword [rsp+8] + |.elif X64 + | movsd qword [rsp-8], xmm0 // Use red zone. + | fld1 + | fld qword [rsp-8] + | fyl2x + | fstp qword [rsp-8] + | movsd xmm0, qword [rsp-8] + |.else + | fld1 + | fld qword [esp+4] + | fyl2x + |.endif + | ret + | + |// FP exponentiation e^x and 2^x. Called by math.exp fast function and + |// from JIT code. Arg/ret on x87 stack. No int/xmm regs modified. + |// Caveat: needs 3 slots on x87 stack! + |->vm_exp_x87: + | fldl2e; fmulp st1 // e^x ==> 2^(x*log2(e)) + |->vm_exp2_x87: + | .if X64WIN + | .define expscratch, dword [rsp+8] // Use scratch area. + | .elif X64 + | .define expscratch, dword [rsp-8] // Use red zone. + | .else + | .define expscratch, dword [esp+4] // Needs 4 byte scratch area. + | .endif + | fst expscratch // Caveat: overwrites ARG1. + | cmp expscratch, 0x7f800000; je >1 // Special case: e^+Inf = +Inf + | cmp expscratch, 0xff800000; je >2 // Special case: e^-Inf = 0 + |->vm_exp2raw: // Entry point for vm_pow. Without +-Inf check. + | fdup; frndint; fsub st1, st0; fxch // Split into frac/int part. + | f2xm1; fld1; faddp st1; fscale; fpop1 // ==> (2^frac-1 +1) << int + |1: + | ret + |2: + | fpop; fldz; ret + | + |// Generic power function x^y. Called by BC_POW, math.pow fast function, + |// and vm_arith. + |// Args/ret on x87 stack (y on top). RC (eax) modified. + |// Caveat: needs 3 slots on x87 stack! + |->vm_pow: + |.if not SSE + | fist dword [esp+4] // Store/reload int before comparison. + | fild dword [esp+4] // Integral exponent used in vm_powi. + | fucomip st1 + | jnz >8 // Branch for FP exponents. + | jp >9 // Branch for NaN exponent. + | fpop // Pop y and fallthrough to vm_powi. + | + |// FP/int power function x^i. Arg1/ret on x87 stack. + |// Arg2 (int) on C stack. RC (eax) modified. + |// Caveat: needs 2 slots on x87 stack! + | mov eax, [esp+4] + | cmp eax, 1; jle >6 // i<=1? + | // Now 1 < (unsigned)i <= 0x80000000. + |1: // Handle leading zeros. + | test eax, 1; jnz >2 + | fmul st0 + | shr eax, 1 + | jmp <1 + |2: + | shr eax, 1; jz >5 + | fdup + |3: // Handle trailing bits. + | fmul st0 + | shr eax, 1; jz >4 + | jnc <3 + | fmul st1, st0 + | jmp <3 + |4: + | fmulp st1 + |5: + | ret + |6: + | je <5 // x^1 ==> x + | jb >7 + | fld1; fdivrp st1 + | neg eax + | cmp eax, 1; je <5 // x^-1 ==> 1/x + | jmp <1 // x^-i ==> (1/x)^i + |7: + | fpop; fld1 // x^0 ==> 1 + | ret + | + |8: // FP/FP power function x^y. + | fst dword [esp+4] + | fxch + | fst dword [esp+8] + | mov eax, [esp+4]; shl eax, 1 + | cmp eax, 0xff000000; je >2 // x^+-Inf? + | mov eax, [esp+8]; shl eax, 1; je >4 // +-0^y? + | cmp eax, 0xff000000; je >4 // +-Inf^y? + | fyl2x + | jmp ->vm_exp2raw + | + |9: // Handle x^NaN. + | fld1 + | fucomip st2 + | je >1 // 1^NaN ==> 1 + | fxch // x^NaN ==> NaN + |1: + | fpop + | ret + | + |2: // Handle x^+-Inf. + | fabs + | fld1 + | fucomip st1 + | je >3 // +-1^+-Inf ==> 1 + | fpop; fabs; fldz; mov eax, 0; setc al + | ror eax, 1; xor eax, [esp+4]; jns >3 // |x|<>1, x^+-Inf ==> +Inf/0 + | fxch + |3: + | fpop1; fabs + | ret + | + |4: // Handle +-0^y or +-Inf^y. + | cmp dword [esp+4], 0; jge <3 // y >= 0, x^y ==> |x| + | fpop; fpop + | test eax, eax; jz >5 // y < 0, +-0^y ==> +Inf + | fldz // y < 0, +-Inf^y ==> 0 + | ret + |5: + | mov dword [esp+4], 0x7f800000 // Return +Inf. + | fld dword [esp+4] + | ret + |.endif + | + |// Args in xmm0/xmm1. Ret in xmm0. xmm0-xmm2 and RC (eax) modified. + |// Needs 16 byte scratch area for x86. Also called from JIT code. + |->vm_pow_sse: + | cvtsd2si eax, xmm1 + | cvtsi2sd xmm2, eax + | ucomisd xmm1, xmm2 + | jnz >8 // Branch for FP exponents. + | jp >9 // Branch for NaN exponent. + | // Fallthrough to vm_powi_sse. + | + |// Args in xmm0/eax. Ret in xmm0. xmm0-xmm1 and eax modified. + |->vm_powi_sse: + | cmp eax, 1; jle >6 // i<=1? + | // Now 1 < (unsigned)i <= 0x80000000. + |1: // Handle leading zeros. + | test eax, 1; jnz >2 + | mulsd xmm0, xmm0 + | shr eax, 1 + | jmp <1 + |2: + | shr eax, 1; jz >5 + | movaps xmm1, xmm0 + |3: // Handle trailing bits. + | mulsd xmm0, xmm0 + | shr eax, 1; jz >4 + | jnc <3 + | mulsd xmm1, xmm0 + | jmp <3 + |4: + | mulsd xmm0, xmm1 + |5: + | ret + |6: + | je <5 // x^1 ==> x + | jb >7 // x^0 ==> 1 + | neg eax + | call <1 + | sseconst_1 xmm1, RDa + | divsd xmm1, xmm0 + | movaps xmm0, xmm1 + | ret + |7: + | sseconst_1 xmm0, RDa + | ret + | + |8: // FP/FP power function x^y. + |.if X64 + | movd rax, xmm1; shl rax, 1 + | rol rax, 12; cmp rax, 0xffe; je >2 // x^+-Inf? + | movd rax, xmm0; shl rax, 1; je >4 // +-0^y? + | rol rax, 12; cmp rax, 0xffe; je >5 // +-Inf^y? + | .if X64WIN + | movsd qword [rsp+16], xmm1 // Use scratch area. + | movsd qword [rsp+8], xmm0 + | fld qword [rsp+16] + | fld qword [rsp+8] + | .else + | movsd qword [rsp-16], xmm1 // Use red zone. + | movsd qword [rsp-8], xmm0 + | fld qword [rsp-16] + | fld qword [rsp-8] + | .endif + |.else + | movsd qword [esp+12], xmm1 // Needs 16 byte scratch area. + | movsd qword [esp+4], xmm0 + | cmp dword [esp+12], 0; jne >1 + | mov eax, [esp+16]; shl eax, 1 + | cmp eax, 0xffe00000; je >2 // x^+-Inf? + |1: + | cmp dword [esp+4], 0; jne >1 + | mov eax, [esp+8]; shl eax, 1; je >4 // +-0^y? + | cmp eax, 0xffe00000; je >5 // +-Inf^y? + |1: + | fld qword [esp+12] + | fld qword [esp+4] + |.endif + | fyl2x // y*log2(x) + | fdup; frndint; fsub st1, st0; fxch // Split into frac/int part. + | f2xm1; fld1; faddp st1; fscale; fpop1 // ==> (2^frac-1 +1) << int + |.if X64WIN + | fstp qword [rsp+8] // Use scratch area. + | movsd xmm0, qword [rsp+8] + |.elif X64 + | fstp qword [rsp-8] // Use red zone. + | movsd xmm0, qword [rsp-8] + |.else + | fstp qword [esp+4] // Needs 8 byte scratch area. + | movsd xmm0, qword [esp+4] + |.endif + | ret + | + |9: // Handle x^NaN. + | sseconst_1 xmm2, RDa + | ucomisd xmm0, xmm2; je >1 // 1^NaN ==> 1 + | movaps xmm0, xmm1 // x^NaN ==> NaN + |1: + | ret + | + |2: // Handle x^+-Inf. + | sseconst_abs xmm2, RDa + | andpd xmm0, xmm2 // |x| + | sseconst_1 xmm2, RDa + | ucomisd xmm0, xmm2; je <1 // +-1^+-Inf ==> 1 + | movmskpd eax, xmm1 + | xorps xmm0, xmm0 + | mov ah, al; setc al; xor al, ah; jne <1 // |x|<>1, x^+-Inf ==> +Inf/0 + |3: + | sseconst_hi xmm0, RDa, 7ff00000 // +Inf + | ret + | + |4: // Handle +-0^y. + | movmskpd eax, xmm1; test eax, eax; jnz <3 // y < 0, +-0^y ==> +Inf + | xorps xmm0, xmm0 // y >= 0, +-0^y ==> 0 + | ret + | + |5: // Handle +-Inf^y. + | movmskpd eax, xmm1; test eax, eax; jz <3 // y >= 0, +-Inf^y ==> +Inf + | xorps xmm0, xmm0 // y < 0, +-Inf^y ==> 0 + | ret + | + |// Callable from C: double lj_vm_foldfpm(double x, int fpm) + |// Computes fpm(x) for extended math functions. ORDER FPM. + |->vm_foldfpm: + |.if JIT + |.if X64 + | .if X64WIN + | .define fpmop, CARG2d + | .else + | .define fpmop, CARG1d + | .endif + | cmp fpmop, 1; jb ->vm_floor; je ->vm_ceil + | cmp fpmop, 3; jb ->vm_trunc; ja >2 + | sqrtsd xmm0, xmm0; ret + |2: + | .if X64WIN + | movsd qword [rsp+8], xmm0 // Use scratch area. + | fld qword [rsp+8] + | .else + | movsd qword [rsp-8], xmm0 // Use red zone. + | fld qword [rsp-8] + | .endif + | cmp fpmop, 5; ja >2 + | .if X64WIN; pop rax; .endif + | je >1 + | call ->vm_exp_x87 + | .if X64WIN; push rax; .endif + | jmp >7 + |1: + | call ->vm_exp2_x87 + | .if X64WIN; push rax; .endif + | jmp >7 + |2: ; cmp fpmop, 7; je >1; ja >2 + | fldln2; fxch; fyl2x; jmp >7 + |1: ; fld1; fxch; fyl2x; jmp >7 + |2: ; cmp fpmop, 9; je >1; ja >2 + | fldlg2; fxch; fyl2x; jmp >7 + |1: ; fsin; jmp >7 + |2: ; cmp fpmop, 11; je >1; ja >9 + | fcos; jmp >7 + |1: ; fptan; fpop + |7: + | .if X64WIN + | fstp qword [rsp+8] // Use scratch area. + | movsd xmm0, qword [rsp+8] + | .else + | fstp qword [rsp-8] // Use red zone. + | movsd xmm0, qword [rsp-8] + | .endif + | ret + |.else // x86 calling convention. + | .define fpmop, eax + |.if SSE + | mov fpmop, [esp+12] + | movsd xmm0, qword [esp+4] + | cmp fpmop, 1; je >1; ja >2 + | call ->vm_floor; jmp >7 + |1: ; call ->vm_ceil; jmp >7 + |2: ; cmp fpmop, 3; je >1; ja >2 + | call ->vm_trunc; jmp >7 + |1: + | sqrtsd xmm0, xmm0 + |7: + | movsd qword [esp+4], xmm0 // Overwrite callee-owned args. + | fld qword [esp+4] + | ret + |2: ; fld qword [esp+4] + | cmp fpmop, 5; jb ->vm_exp_x87; je ->vm_exp2_x87 + |2: ; cmp fpmop, 7; je >1; ja >2 + | fldln2; fxch; fyl2x; ret + |1: ; fld1; fxch; fyl2x; ret + |2: ; cmp fpmop, 9; je >1; ja >2 + | fldlg2; fxch; fyl2x; ret + |1: ; fsin; ret + |2: ; cmp fpmop, 11; je >1; ja >9 + | fcos; ret + |1: ; fptan; fpop; ret + |.else + | mov fpmop, [esp+12] + | fld qword [esp+4] + | cmp fpmop, 1; jb ->vm_floor; je ->vm_ceil + | cmp fpmop, 3; jb ->vm_trunc; ja >2 + | fsqrt; ret + |2: ; cmp fpmop, 5; jb ->vm_exp_x87; je ->vm_exp2_x87 + | cmp fpmop, 7; je >1; ja >2 + | fldln2; fxch; fyl2x; ret + |1: ; fld1; fxch; fyl2x; ret + |2: ; cmp fpmop, 9; je >1; ja >2 + | fldlg2; fxch; fyl2x; ret + |1: ; fsin; ret + |2: ; cmp fpmop, 11; je >1; ja >9 + | fcos; ret + |1: ; fptan; fpop; ret + |.endif + |.endif + |9: ; int3 // Bad fpm. + |.endif + | + |// Callable from C: double lj_vm_foldarith(double x, double y, int op) + |// Compute x op y for basic arithmetic operators (+ - * / % ^ and unary -) + |// and basic math functions. ORDER ARITH + |->vm_foldarith: + |.if X64 + | + | .if X64WIN + | .define foldop, CARG3d + | .else + | .define foldop, CARG1d + | .endif + | cmp foldop, 1; je >1; ja >2 + | addsd xmm0, xmm1; ret + |1: ; subsd xmm0, xmm1; ret + |2: ; cmp foldop, 3; je >1; ja >2 + | mulsd xmm0, xmm1; ret + |1: ; divsd xmm0, xmm1; ret + |2: ; cmp foldop, 5; jb ->vm_mod; je ->vm_pow + | cmp foldop, 7; je >1; ja >2 + | sseconst_sign xmm1, RDa; xorps xmm0, xmm1; ret + |1: ; sseconst_abs xmm1, RDa; andps xmm0, xmm1; ret + |2: ; cmp foldop, 9; ja >2 + |.if X64WIN + | movsd qword [rsp+8], xmm0 // Use scratch area. + | movsd qword [rsp+16], xmm1 + | fld qword [rsp+8] + | fld qword [rsp+16] + |.else + | movsd qword [rsp-8], xmm0 // Use red zone. + | movsd qword [rsp-16], xmm1 + | fld qword [rsp-8] + | fld qword [rsp-16] + |.endif + | je >1 + | fpatan + |7: + |.if X64WIN + | fstp qword [rsp+8] // Use scratch area. + | movsd xmm0, qword [rsp+8] + |.else + | fstp qword [rsp-8] // Use red zone. + | movsd xmm0, qword [rsp-8] + |.endif + | ret + |1: ; fxch; fscale; fpop1; jmp <7 + |2: ; cmp foldop, 11; je >1; ja >9 + | minsd xmm0, xmm1; ret + |1: ; maxsd xmm0, xmm1; ret + |9: ; int3 // Bad op. + | + |.elif SSE // x86 calling convention with SSE ops. + | + | .define foldop, eax + | mov foldop, [esp+20] + | movsd xmm0, qword [esp+4] + | movsd xmm1, qword [esp+12] + | cmp foldop, 1; je >1; ja >2 + | addsd xmm0, xmm1 + |7: + | movsd qword [esp+4], xmm0 // Overwrite callee-owned args. + | fld qword [esp+4] + | ret + |1: ; subsd xmm0, xmm1; jmp <7 + |2: ; cmp foldop, 3; je >1; ja >2 + | mulsd xmm0, xmm1; jmp <7 + |1: ; divsd xmm0, xmm1; jmp <7 + |2: ; cmp foldop, 5 + | je >1; ja >2 + | call ->vm_mod; jmp <7 + |1: ; pop edx; call ->vm_pow; push edx; jmp <7 // Writes to scratch area. + |2: ; cmp foldop, 7; je >1; ja >2 + | sseconst_sign xmm1, RDa; xorps xmm0, xmm1; jmp <7 + |1: ; sseconst_abs xmm1, RDa; andps xmm0, xmm1; jmp <7 + |2: ; cmp foldop, 9; ja >2 + | fld qword [esp+4] // Reload from stack + | fld qword [esp+12] + | je >1 + | fpatan; ret + |1: ; fxch; fscale; fpop1; ret + |2: ; cmp foldop, 11; je >1; ja >9 + | minsd xmm0, xmm1; jmp <7 + |1: ; maxsd xmm0, xmm1; jmp <7 + |9: ; int3 // Bad op. + | + |.else // x86 calling convention with x87 ops. + | + | mov eax, [esp+20] + | fld qword [esp+4] + | fld qword [esp+12] + | cmp eax, 1; je >1; ja >2 + | faddp st1; ret + |1: ; fsubp st1; ret + |2: ; cmp eax, 3; je >1; ja >2 + | fmulp st1; ret + |1: ; fdivp st1; ret + |2: ; cmp eax, 5; jb ->vm_mod; je ->vm_pow + | cmp eax, 7; je >1; ja >2 + | fpop; fchs; ret + |1: ; fpop; fabs; ret + |2: ; cmp eax, 9; je >1; ja >2 + | fpatan; ret + |1: ; fxch; fscale; fpop1; ret + |2: ; cmp eax, 11; je >1; ja >9 + | fucomi st1; fcmovnbe st1; fpop1; ret + |1: ; fucomi st1; fcmovbe st1; fpop1; ret + |9: ; int3 // Bad op. + | + |.endif + | + |//----------------------------------------------------------------------- + |//-- Miscellaneous functions -------------------------------------------- + |//----------------------------------------------------------------------- + | + |// int lj_vm_cpuid(uint32_t f, uint32_t res[4]) + |->vm_cpuid: + |.if X64 + | mov eax, CARG1d + | .if X64WIN; push rsi; mov rsi, CARG2; .endif + | push rbx + | cpuid + | mov [rsi], eax + | mov [rsi+4], ebx + | mov [rsi+8], ecx + | mov [rsi+12], edx + | pop rbx + | .if X64WIN; pop rsi; .endif + | ret + |.else + | pushfd + | pop edx + | mov ecx, edx + | xor edx, 0x00200000 // Toggle ID bit in flags. + | push edx + | popfd + | pushfd + | pop edx + | xor eax, eax // Zero means no features supported. + | cmp ecx, edx + | jz >1 // No ID toggle means no CPUID support. + | mov eax, [esp+4] // Argument 1 is function number. + | push edi + | push ebx + | cpuid + | mov edi, [esp+16] // Argument 2 is result area. + | mov [edi], eax + | mov [edi+4], ebx + | mov [edi+8], ecx + | mov [edi+12], edx + | pop ebx + | pop edi + |1: + | ret + |.endif + | + |//----------------------------------------------------------------------- + |//-- Assertions --------------------------------------------------------- + |//----------------------------------------------------------------------- + | + |->assert_bad_for_arg_type: +#ifdef LUA_USE_ASSERT + | int3 +#endif + | int3 + | + |//----------------------------------------------------------------------- + |//-- FFI helper functions ----------------------------------------------- + |//----------------------------------------------------------------------- + | + |// Handler for callback functions. Callback slot number in ah/al. + |->vm_ffi_callback: + |.if FFI + |.type CTSTATE, CTState, PC + |.if not X64 + | sub esp, 16 // Leave room for SAVE_ERRF etc. + |.endif + | saveregs_ // ebp/rbp already saved. ebp now holds global_State *. + | lea DISPATCH, [ebp+GG_G2DISP] + | mov CTSTATE, GL:ebp->ctype_state + | movzx eax, ax + | mov CTSTATE->cb.slot, eax + |.if X64 + | mov CTSTATE->cb.gpr[0], CARG1 + | mov CTSTATE->cb.gpr[1], CARG2 + | mov CTSTATE->cb.gpr[2], CARG3 + | mov CTSTATE->cb.gpr[3], CARG4 + | movsd qword CTSTATE->cb.fpr[0], xmm0 + | movsd qword CTSTATE->cb.fpr[1], xmm1 + | movsd qword CTSTATE->cb.fpr[2], xmm2 + | movsd qword CTSTATE->cb.fpr[3], xmm3 + |.if X64WIN + | lea rax, [rsp+CFRAME_SIZE+4*8] + |.else + | lea rax, [rsp+CFRAME_SIZE] + | mov CTSTATE->cb.gpr[4], CARG5 + | mov CTSTATE->cb.gpr[5], CARG6 + | movsd qword CTSTATE->cb.fpr[4], xmm4 + | movsd qword CTSTATE->cb.fpr[5], xmm5 + | movsd qword CTSTATE->cb.fpr[6], xmm6 + | movsd qword CTSTATE->cb.fpr[7], xmm7 + |.endif + | mov CTSTATE->cb.stack, rax + | mov CARG2, rsp + |.else + | lea eax, [esp+CFRAME_SIZE+16] + | mov CTSTATE->cb.gpr[0], FCARG1 + | mov CTSTATE->cb.gpr[1], FCARG2 + | mov CTSTATE->cb.stack, eax + | mov FCARG1, [esp+CFRAME_SIZE+12] // Move around misplaced retaddr/ebp. + | mov FCARG2, [esp+CFRAME_SIZE+8] + | mov SAVE_RET, FCARG1 + | mov SAVE_R4, FCARG2 + | mov FCARG2, esp + |.endif + | mov SAVE_PC, CTSTATE // Any value outside of bytecode is ok. + | mov FCARG1, CTSTATE + | call extern lj_ccallback_enter@8 // (CTState *cts, void *cf) + | // lua_State * returned in eax (RD). + | set_vmstate INTERP + | mov BASE, L:RD->base + | mov RD, L:RD->top + | sub RD, BASE + | mov LFUNC:RB, [BASE-8] + | shr RD, 3 + | add RD, 1 + | ins_callt + |.endif + | + |->cont_ffi_callback: // Return from FFI callback. + |.if FFI + | mov L:RA, SAVE_L + | mov CTSTATE, [DISPATCH+DISPATCH_GL(ctype_state)] + | mov aword CTSTATE->L, L:RAa + | mov L:RA->base, BASE + | mov L:RA->top, RB + | mov FCARG1, CTSTATE + | mov FCARG2, RC + | call extern lj_ccallback_leave@8 // (CTState *cts, TValue *o) + |.if X64 + | mov rax, CTSTATE->cb.gpr[0] + | movsd xmm0, qword CTSTATE->cb.fpr[0] + | jmp ->vm_leave_unw + |.else + | mov L:RB, SAVE_L + | mov eax, CTSTATE->cb.gpr[0] + | mov edx, CTSTATE->cb.gpr[1] + | cmp dword CTSTATE->cb.gpr[2], 1 + | jb >7 + | je >6 + | fld qword CTSTATE->cb.fpr[0].d + | jmp >7 + |6: + | fld dword CTSTATE->cb.fpr[0].f + |7: + | mov ecx, L:RB->top + | movzx ecx, word [ecx+6] // Get stack adjustment and copy up. + | mov SAVE_L, ecx // Must be one slot above SAVE_RET + | restoreregs + | pop ecx // Move return addr from SAVE_RET. + | add esp, [esp] // Adjust stack. + | add esp, 16 + | push ecx + | ret + |.endif + |.endif + | + |->vm_ffi_call@4: // Call C function via FFI. + | // Caveat: needs special frame unwinding, see below. + |.if FFI + |.if X64 + | .type CCSTATE, CCallState, rbx + | push rbp; mov rbp, rsp; push rbx; mov CCSTATE, CARG1 + |.else + | .type CCSTATE, CCallState, ebx + | push ebp; mov ebp, esp; push ebx; mov CCSTATE, FCARG1 + |.endif + | + | // Readjust stack. + |.if X64 + | mov eax, CCSTATE->spadj + | sub rsp, rax + |.else + | sub esp, CCSTATE->spadj + |.if WIN + | mov CCSTATE->spadj, esp + |.endif + |.endif + | + | // Copy stack slots. + | movzx ecx, byte CCSTATE->nsp + | sub ecx, 1 + | js >2 + |1: + |.if X64 + | mov rax, [CCSTATE+rcx*8+offsetof(CCallState, stack)] + | mov [rsp+rcx*8+CCALL_SPS_EXTRA*8], rax + |.else + | mov eax, [CCSTATE+ecx*4+offsetof(CCallState, stack)] + | mov [esp+ecx*4], eax + |.endif + | sub ecx, 1 + | jns <1 + |2: + | + |.if X64 + | movzx eax, byte CCSTATE->nfpr + | mov CARG1, CCSTATE->gpr[0] + | mov CARG2, CCSTATE->gpr[1] + | mov CARG3, CCSTATE->gpr[2] + | mov CARG4, CCSTATE->gpr[3] + |.if not X64WIN + | mov CARG5, CCSTATE->gpr[4] + | mov CARG6, CCSTATE->gpr[5] + |.endif + | test eax, eax; jz >5 + | movaps xmm0, CCSTATE->fpr[0] + | movaps xmm1, CCSTATE->fpr[1] + | movaps xmm2, CCSTATE->fpr[2] + | movaps xmm3, CCSTATE->fpr[3] + |.if not X64WIN + | cmp eax, 4; jbe >5 + | movaps xmm4, CCSTATE->fpr[4] + | movaps xmm5, CCSTATE->fpr[5] + | movaps xmm6, CCSTATE->fpr[6] + | movaps xmm7, CCSTATE->fpr[7] + |.endif + |5: + |.else + | mov FCARG1, CCSTATE->gpr[0] + | mov FCARG2, CCSTATE->gpr[1] + |.endif + | + | call aword CCSTATE->func + | + |.if X64 + | mov CCSTATE->gpr[0], rax + | movaps CCSTATE->fpr[0], xmm0 + |.if not X64WIN + | mov CCSTATE->gpr[1], rdx + | movaps CCSTATE->fpr[1], xmm1 + |.endif + |.else + | mov CCSTATE->gpr[0], eax + | mov CCSTATE->gpr[1], edx + | cmp byte CCSTATE->resx87, 1 + | jb >7 + | je >6 + | fstp qword CCSTATE->fpr[0].d[0] + | jmp >7 + |6: + | fstp dword CCSTATE->fpr[0].f[0] + |7: + |.if WIN + | sub CCSTATE->spadj, esp + |.endif + |.endif + | + |.if X64 + | mov rbx, [rbp-8]; leave; ret + |.else + | mov ebx, [ebp-4]; leave; ret + |.endif + |.endif + |// Note: vm_ffi_call must be the last function in this object file! + | + |//----------------------------------------------------------------------- +} + +/* Generate the code for a single instruction. */ +static void build_ins(BuildCtx *ctx, BCOp op, int defop) +{ + int vk = 0; + |// Note: aligning all instructions does not pay off. + |=>defop: + + switch (op) { + + /* -- Comparison ops ---------------------------------------------------- */ + + /* Remember: all ops branch for a true comparison, fall through otherwise. */ + + |.macro jmp_comp, lt, ge, le, gt, target + ||switch (op) { + ||case BC_ISLT: + | lt target + ||break; + ||case BC_ISGE: + | ge target + ||break; + ||case BC_ISLE: + | le target + ||break; + ||case BC_ISGT: + | gt target + ||break; + ||default: break; /* Shut up GCC. */ + ||} + |.endmacro + + case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: + | // RA = src1, RD = src2, JMP with RD = target + | ins_AD + |.if DUALNUM + | checkint RA, >7 + | checkint RD, >8 + | mov RB, dword [BASE+RA*8] + | add PC, 4 + | cmp RB, dword [BASE+RD*8] + | jmp_comp jge, jl, jg, jle, >9 + |6: + | movzx RD, PC_RD + | branchPC RD + |9: + | ins_next + | + |7: // RA is not an integer. + | ja ->vmeta_comp + | // RA is a number. + | cmp dword [BASE+RD*8+4], LJ_TISNUM; jb >1; jne ->vmeta_comp + | // RA is a number, RD is an integer. + |.if SSE + | cvtsi2sd xmm0, dword [BASE+RD*8] + | jmp >2 + |.else + | fld qword [BASE+RA*8] + | fild dword [BASE+RD*8] + | jmp >3 + |.endif + | + |8: // RA is an integer, RD is not an integer. + | ja ->vmeta_comp + | // RA is an integer, RD is a number. + |.if SSE + | cvtsi2sd xmm1, dword [BASE+RA*8] + | movsd xmm0, qword [BASE+RD*8] + | add PC, 4 + | ucomisd xmm0, xmm1 + | jmp_comp jbe, ja, jb, jae, <9 + | jmp <6 + |.else + | fild dword [BASE+RA*8] + | jmp >2 + |.endif + |.else + | checknum RA, ->vmeta_comp + | checknum RD, ->vmeta_comp + |.endif + |.if SSE + |1: + | movsd xmm0, qword [BASE+RD*8] + |2: + | add PC, 4 + | ucomisd xmm0, qword [BASE+RA*8] + |3: + |.else + |1: + | fld qword [BASE+RA*8] // Reverse order, i.e like cmp D, A. + |2: + | fld qword [BASE+RD*8] + |3: + | add PC, 4 + | fcomparepp + |.endif + | // Unordered: all of ZF CF PF set, ordered: PF clear. + | // To preserve NaN semantics GE/GT branch on unordered, but LT/LE don't. + |.if DUALNUM + | jmp_comp jbe, ja, jb, jae, <9 + | jmp <6 + |.else + | jmp_comp jbe, ja, jb, jae, >1 + | movzx RD, PC_RD + | branchPC RD + |1: + | ins_next + |.endif + break; + + case BC_ISEQV: case BC_ISNEV: + vk = op == BC_ISEQV; + | ins_AD // RA = src1, RD = src2, JMP with RD = target + | mov RB, [BASE+RD*8+4] + | add PC, 4 + |.if DUALNUM + | cmp RB, LJ_TISNUM; jne >7 + | checkint RA, >8 + | mov RB, dword [BASE+RD*8] + | cmp RB, dword [BASE+RA*8] + if (vk) { + | jne >9 + } else { + | je >9 + } + | movzx RD, PC_RD + | branchPC RD + |9: + | ins_next + | + |7: // RD is not an integer. + | ja >5 + | // RD is a number. + | cmp dword [BASE+RA*8+4], LJ_TISNUM; jb >1; jne >5 + | // RD is a number, RA is an integer. + |.if SSE + | cvtsi2sd xmm0, dword [BASE+RA*8] + |.else + | fild dword [BASE+RA*8] + |.endif + | jmp >2 + | + |8: // RD is an integer, RA is not an integer. + | ja >5 + | // RD is an integer, RA is a number. + |.if SSE + | cvtsi2sd xmm0, dword [BASE+RD*8] + | ucomisd xmm0, qword [BASE+RA*8] + |.else + | fild dword [BASE+RD*8] + | fld qword [BASE+RA*8] + |.endif + | jmp >4 + | + |.else + | cmp RB, LJ_TISNUM; jae >5 + | checknum RA, >5 + |.endif + |.if SSE + |1: + | movsd xmm0, qword [BASE+RA*8] + |2: + | ucomisd xmm0, qword [BASE+RD*8] + |4: + |.else + |1: + | fld qword [BASE+RA*8] + |2: + | fld qword [BASE+RD*8] + |4: + | fcomparepp + |.endif + iseqne_fp: + if (vk) { + | jp >2 // Unordered means not equal. + | jne >2 + } else { + | jp >2 // Unordered means not equal. + | je >1 + } + iseqne_end: + if (vk) { + |1: // EQ: Branch to the target. + | movzx RD, PC_RD + | branchPC RD + |2: // NE: Fallthrough to next instruction. + |.if not FFI + |3: + |.endif + } else { + |.if not FFI + |3: + |.endif + |2: // NE: Branch to the target. + | movzx RD, PC_RD + | branchPC RD + |1: // EQ: Fallthrough to next instruction. + } + if (LJ_DUALNUM && (op == BC_ISEQV || op == BC_ISNEV || + op == BC_ISEQN || op == BC_ISNEN)) { + | jmp <9 + } else { + | ins_next + } + | + if (op == BC_ISEQV || op == BC_ISNEV) { + |5: // Either or both types are not numbers. + |.if FFI + | cmp RB, LJ_TCDATA; je ->vmeta_equal_cd + | checktp RA, LJ_TCDATA; je ->vmeta_equal_cd + |.endif + | checktp RA, RB // Compare types. + | jne <2 // Not the same type? + | cmp RB, LJ_TISPRI + | jae <1 // Same type and primitive type? + | + | // Same types and not a primitive type. Compare GCobj or pvalue. + | mov RA, [BASE+RA*8] + | mov RD, [BASE+RD*8] + | cmp RA, RD + | je <1 // Same GCobjs or pvalues? + | cmp RB, LJ_TISTABUD + | ja <2 // Different objects and not table/ud? + |.if X64 + | cmp RB, LJ_TUDATA // And not 64 bit lightuserdata. + | jb <2 + |.endif + | + | // Different tables or userdatas. Need to check __eq metamethod. + | // Field metatable must be at same offset for GCtab and GCudata! + | mov TAB:RB, TAB:RA->metatable + | test TAB:RB, TAB:RB + | jz <2 // No metatable? + | test byte TAB:RB->nomm, 1<vmeta_equal // Handle __eq metamethod. + } else { + |.if FFI + |3: + | cmp RB, LJ_TCDATA + if (LJ_DUALNUM && vk) { + | jne <9 + } else { + | jne <2 + } + | jmp ->vmeta_equal_cd + |.endif + } + break; + case BC_ISEQS: case BC_ISNES: + vk = op == BC_ISEQS; + | ins_AND // RA = src, RD = str const, JMP with RD = target + | mov RB, [BASE+RA*8+4] + | add PC, 4 + | cmp RB, LJ_TSTR; jne >3 + | mov RA, [BASE+RA*8] + | cmp RA, [KBASE+RD*4] + iseqne_test: + if (vk) { + | jne >2 + } else { + | je >1 + } + goto iseqne_end; + case BC_ISEQN: case BC_ISNEN: + vk = op == BC_ISEQN; + | ins_AD // RA = src, RD = num const, JMP with RD = target + | mov RB, [BASE+RA*8+4] + | add PC, 4 + |.if DUALNUM + | cmp RB, LJ_TISNUM; jne >7 + | cmp dword [KBASE+RD*8+4], LJ_TISNUM; jne >8 + | mov RB, dword [KBASE+RD*8] + | cmp RB, dword [BASE+RA*8] + if (vk) { + | jne >9 + } else { + | je >9 + } + | movzx RD, PC_RD + | branchPC RD + |9: + | ins_next + | + |7: // RA is not an integer. + | ja >3 + | // RA is a number. + | cmp dword [KBASE+RD*8+4], LJ_TISNUM; jb >1 + | // RA is a number, RD is an integer. + |.if SSE + | cvtsi2sd xmm0, dword [KBASE+RD*8] + |.else + | fild dword [KBASE+RD*8] + |.endif + | jmp >2 + | + |8: // RA is an integer, RD is a number. + |.if SSE + | cvtsi2sd xmm0, dword [BASE+RA*8] + | ucomisd xmm0, qword [KBASE+RD*8] + |.else + | fild dword [BASE+RA*8] + | fld qword [KBASE+RD*8] + |.endif + | jmp >4 + |.else + | cmp RB, LJ_TISNUM; jae >3 + |.endif + |.if SSE + |1: + | movsd xmm0, qword [KBASE+RD*8] + |2: + | ucomisd xmm0, qword [BASE+RA*8] + |4: + |.else + |1: + | fld qword [KBASE+RD*8] + |2: + | fld qword [BASE+RA*8] + |4: + | fcomparepp + |.endif + goto iseqne_fp; + case BC_ISEQP: case BC_ISNEP: + vk = op == BC_ISEQP; + | ins_AND // RA = src, RD = primitive type (~), JMP with RD = target + | mov RB, [BASE+RA*8+4] + | add PC, 4 + | cmp RB, RD + if (!LJ_HASFFI) goto iseqne_test; + if (vk) { + | jne >3 + | movzx RD, PC_RD + | branchPC RD + |2: + | ins_next + |3: + | cmp RB, LJ_TCDATA; jne <2 + | jmp ->vmeta_equal_cd + } else { + | je >2 + | cmp RB, LJ_TCDATA; je ->vmeta_equal_cd + | movzx RD, PC_RD + | branchPC RD + |2: + | ins_next + } + break; + + /* -- Unary test and copy ops ------------------------------------------- */ + + case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: + | ins_AD // RA = dst or unused, RD = src, JMP with RD = target + | mov RB, [BASE+RD*8+4] + | add PC, 4 + | cmp RB, LJ_TISTRUECOND + if (op == BC_IST || op == BC_ISTC) { + | jae >1 + } else { + | jb >1 + } + if (op == BC_ISTC || op == BC_ISFC) { + | mov [BASE+RA*8+4], RB + | mov RB, [BASE+RD*8] + | mov [BASE+RA*8], RB + } + | movzx RD, PC_RD + | branchPC RD + |1: // Fallthrough to the next instruction. + | ins_next + break; + + /* -- Unary ops --------------------------------------------------------- */ + + case BC_MOV: + | ins_AD // RA = dst, RD = src + |.if X64 + | mov RBa, [BASE+RD*8] + | mov [BASE+RA*8], RBa + |.else + | mov RB, [BASE+RD*8+4] + | mov RD, [BASE+RD*8] + | mov [BASE+RA*8+4], RB + | mov [BASE+RA*8], RD + |.endif + | ins_next_ + break; + case BC_NOT: + | ins_AD // RA = dst, RD = src + | xor RB, RB + | checktp RD, LJ_TISTRUECOND + | adc RB, LJ_TTRUE + | mov [BASE+RA*8+4], RB + | ins_next + break; + case BC_UNM: + | ins_AD // RA = dst, RD = src + |.if DUALNUM + | checkint RD, >5 + | mov RB, [BASE+RD*8] + | neg RB + | jo >4 + | mov dword [BASE+RA*8+4], LJ_TISNUM + | mov dword [BASE+RA*8], RB + |9: + | ins_next + |4: + | mov dword [BASE+RA*8+4], 0x41e00000 // 2^31. + | mov dword [BASE+RA*8], 0 + | jmp <9 + |5: + | ja ->vmeta_unm + |.else + | checknum RD, ->vmeta_unm + |.endif + |.if SSE + | movsd xmm0, qword [BASE+RD*8] + | sseconst_sign xmm1, RDa + | xorps xmm0, xmm1 + | movsd qword [BASE+RA*8], xmm0 + |.else + | fld qword [BASE+RD*8] + | fchs + | fstp qword [BASE+RA*8] + |.endif + |.if DUALNUM + | jmp <9 + |.else + | ins_next + |.endif + break; + case BC_LEN: + | ins_AD // RA = dst, RD = src + | checkstr RD, >2 + | mov STR:RD, [BASE+RD*8] + |.if DUALNUM + | mov RD, dword STR:RD->len + |1: + | mov dword [BASE+RA*8+4], LJ_TISNUM + | mov dword [BASE+RA*8], RD + |.elif SSE + | xorps xmm0, xmm0 + | cvtsi2sd xmm0, dword STR:RD->len + |1: + | movsd qword [BASE+RA*8], xmm0 + |.else + | fild dword STR:RD->len + |1: + | fstp qword [BASE+RA*8] + |.endif + | ins_next + |2: + | checktab RD, ->vmeta_len + | mov TAB:FCARG1, [BASE+RD*8] +#if LJ_52 + | mov TAB:RB, TAB:FCARG1->metatable + | cmp TAB:RB, 0 + | jnz >9 + |3: +#endif + |->BC_LEN_Z: + | mov RB, BASE // Save BASE. + | call extern lj_tab_len@4 // (GCtab *t) + | // Length of table returned in eax (RD). + |.if DUALNUM + | // Nothing to do. + |.elif SSE + | cvtsi2sd xmm0, RD + |.else + | mov ARG1, RD + | fild ARG1 + |.endif + | mov BASE, RB // Restore BASE. + | movzx RA, PC_RA + | jmp <1 +#if LJ_52 + |9: // Check for __len. + | test byte TAB:RB->nomm, 1<vmeta_len // 'no __len' flag NOT set: check. +#endif + break; + + /* -- Binary ops -------------------------------------------------------- */ + + |.macro ins_arithpre, x87ins, sseins, ssereg + | ins_ABC + ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); + ||switch (vk) { + ||case 0: + | checknum RB, ->vmeta_arith_vn + | .if DUALNUM + | cmp dword [KBASE+RC*8+4], LJ_TISNUM; jae ->vmeta_arith_vn + | .endif + | .if SSE + | movsd xmm0, qword [BASE+RB*8] + | sseins ssereg, qword [KBASE+RC*8] + | .else + | fld qword [BASE+RB*8] + | x87ins qword [KBASE+RC*8] + | .endif + || break; + ||case 1: + | checknum RB, ->vmeta_arith_nv + | .if DUALNUM + | cmp dword [KBASE+RC*8+4], LJ_TISNUM; jae ->vmeta_arith_nv + | .endif + | .if SSE + | movsd xmm0, qword [KBASE+RC*8] + | sseins ssereg, qword [BASE+RB*8] + | .else + | fld qword [KBASE+RC*8] + | x87ins qword [BASE+RB*8] + | .endif + || break; + ||default: + | checknum RB, ->vmeta_arith_vv + | checknum RC, ->vmeta_arith_vv + | .if SSE + | movsd xmm0, qword [BASE+RB*8] + | sseins ssereg, qword [BASE+RC*8] + | .else + | fld qword [BASE+RB*8] + | x87ins qword [BASE+RC*8] + | .endif + || break; + ||} + |.endmacro + | + |.macro ins_arithdn, intins + | ins_ABC + ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); + ||switch (vk) { + ||case 0: + | checkint RB, ->vmeta_arith_vn + | cmp dword [KBASE+RC*8+4], LJ_TISNUM; jne ->vmeta_arith_vn + | mov RB, [BASE+RB*8] + | intins RB, [KBASE+RC*8]; jo ->vmeta_arith_vno + || break; + ||case 1: + | checkint RB, ->vmeta_arith_nv + | cmp dword [KBASE+RC*8+4], LJ_TISNUM; jne ->vmeta_arith_nv + | mov RC, [KBASE+RC*8] + | intins RC, [BASE+RB*8]; jo ->vmeta_arith_nvo + || break; + ||default: + | checkint RB, ->vmeta_arith_vv + | checkint RC, ->vmeta_arith_vv + | mov RB, [BASE+RB*8] + | intins RB, [BASE+RC*8]; jo ->vmeta_arith_vvo + || break; + ||} + | mov dword [BASE+RA*8+4], LJ_TISNUM + ||if (vk == 1) { + | mov dword [BASE+RA*8], RC + ||} else { + | mov dword [BASE+RA*8], RB + ||} + | ins_next + |.endmacro + | + |.macro ins_arithpost + |.if SSE + | movsd qword [BASE+RA*8], xmm0 + |.else + | fstp qword [BASE+RA*8] + |.endif + |.endmacro + | + |.macro ins_arith, x87ins, sseins + | ins_arithpre x87ins, sseins, xmm0 + | ins_arithpost + | ins_next + |.endmacro + | + |.macro ins_arith, intins, x87ins, sseins + |.if DUALNUM + | ins_arithdn intins + |.else + | ins_arith, x87ins, sseins + |.endif + |.endmacro + + | // RA = dst, RB = src1 or num const, RC = src2 or num const + case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: + | ins_arith add, fadd, addsd + break; + case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: + | ins_arith sub, fsub, subsd + break; + case BC_MULVN: case BC_MULNV: case BC_MULVV: + | ins_arith imul, fmul, mulsd + break; + case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: + | ins_arith fdiv, divsd + break; + case BC_MODVN: + | ins_arithpre fld, movsd, xmm1 + |->BC_MODVN_Z: + | call ->vm_mod + | ins_arithpost + | ins_next + break; + case BC_MODNV: case BC_MODVV: + | ins_arithpre fld, movsd, xmm1 + | jmp ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. + break; + case BC_POW: + | ins_arithpre fld, movsd, xmm1 + | call ->vm_pow + | ins_arithpost + | ins_next + break; + + case BC_CAT: + | ins_ABC // RA = dst, RB = src_start, RC = src_end + |.if X64 + | mov L:CARG1d, SAVE_L + | mov L:CARG1d->base, BASE + | lea CARG2d, [BASE+RC*8] + | mov CARG3d, RC + | sub CARG3d, RB + |->BC_CAT_Z: + | mov L:RB, L:CARG1d + |.else + | lea RA, [BASE+RC*8] + | sub RC, RB + | mov ARG2, RA + | mov ARG3, RC + |->BC_CAT_Z: + | mov L:RB, SAVE_L + | mov ARG1, L:RB + | mov L:RB->base, BASE + |.endif + | mov SAVE_PC, PC + | call extern lj_meta_cat // (lua_State *L, TValue *top, int left) + | // NULL (finished) or TValue * (metamethod) returned in eax (RC). + | mov BASE, L:RB->base + | test RC, RC + | jnz ->vmeta_binop + | movzx RB, PC_RB // Copy result to Stk[RA] from Stk[RB]. + | movzx RA, PC_RA + |.if X64 + | mov RCa, [BASE+RB*8] + | mov [BASE+RA*8], RCa + |.else + | mov RC, [BASE+RB*8+4] + | mov RB, [BASE+RB*8] + | mov [BASE+RA*8+4], RC + | mov [BASE+RA*8], RB + |.endif + | ins_next + break; + + /* -- Constant ops ------------------------------------------------------ */ + + case BC_KSTR: + | ins_AND // RA = dst, RD = str const (~) + | mov RD, [KBASE+RD*4] + | mov dword [BASE+RA*8+4], LJ_TSTR + | mov [BASE+RA*8], RD + | ins_next + break; + case BC_KCDATA: + |.if FFI + | ins_AND // RA = dst, RD = cdata const (~) + | mov RD, [KBASE+RD*4] + | mov dword [BASE+RA*8+4], LJ_TCDATA + | mov [BASE+RA*8], RD + | ins_next + |.endif + break; + case BC_KSHORT: + | ins_AD // RA = dst, RD = signed int16 literal + |.if DUALNUM + | movsx RD, RDW + | mov dword [BASE+RA*8+4], LJ_TISNUM + | mov dword [BASE+RA*8], RD + |.elif SSE + | movsx RD, RDW // Sign-extend literal. + | cvtsi2sd xmm0, RD + | movsd qword [BASE+RA*8], xmm0 + |.else + | fild PC_RD // Refetch signed RD from instruction. + | fstp qword [BASE+RA*8] + |.endif + | ins_next + break; + case BC_KNUM: + | ins_AD // RA = dst, RD = num const + |.if SSE + | movsd xmm0, qword [KBASE+RD*8] + | movsd qword [BASE+RA*8], xmm0 + |.else + | fld qword [KBASE+RD*8] + | fstp qword [BASE+RA*8] + |.endif + | ins_next + break; + case BC_KPRI: + | ins_AND // RA = dst, RD = primitive type (~) + | mov [BASE+RA*8+4], RD + | ins_next + break; + case BC_KNIL: + | ins_AD // RA = dst_start, RD = dst_end + | lea RA, [BASE+RA*8+12] + | lea RD, [BASE+RD*8+4] + | mov RB, LJ_TNIL + | mov [RA-8], RB // Sets minimum 2 slots. + |1: + | mov [RA], RB + | add RA, 8 + | cmp RA, RD + | jbe <1 + | ins_next + break; + + /* -- Upvalue and function ops ------------------------------------------ */ + + case BC_UGET: + | ins_AD // RA = dst, RD = upvalue # + | mov LFUNC:RB, [BASE-8] + | mov UPVAL:RB, [LFUNC:RB+RD*4+offsetof(GCfuncL, uvptr)] + | mov RB, UPVAL:RB->v + |.if X64 + | mov RDa, [RB] + | mov [BASE+RA*8], RDa + |.else + | mov RD, [RB+4] + | mov RB, [RB] + | mov [BASE+RA*8+4], RD + | mov [BASE+RA*8], RB + |.endif + | ins_next + break; + case BC_USETV: +#define TV2MARKOFS \ + ((int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)) + | ins_AD // RA = upvalue #, RD = src + | mov LFUNC:RB, [BASE-8] + | mov UPVAL:RB, [LFUNC:RB+RA*4+offsetof(GCfuncL, uvptr)] + | cmp byte UPVAL:RB->closed, 0 + | mov RB, UPVAL:RB->v + | mov RA, [BASE+RD*8] + | mov RD, [BASE+RD*8+4] + | mov [RB], RA + | mov [RB+4], RD + | jz >1 + | // Check barrier for closed upvalue. + | test byte [RB+TV2MARKOFS], LJ_GC_BLACK // isblack(uv) + | jnz >2 + |1: + | ins_next + | + |2: // Upvalue is black. Check if new value is collectable and white. + | sub RD, LJ_TISGCV + | cmp RD, LJ_TNUMX - LJ_TISGCV // tvisgcv(v) + | jbe <1 + | test byte GCOBJ:RA->gch.marked, LJ_GC_WHITES // iswhite(v) + | jz <1 + | // Crossed a write barrier. Move the barrier forward. + |.if X64 and not X64WIN + | mov FCARG2, RB + | mov RB, BASE // Save BASE. + |.else + | xchg FCARG2, RB // Save BASE (FCARG2 == BASE). + |.endif + | lea GL:FCARG1, [DISPATCH+GG_DISP2G] + | call extern lj_gc_barrieruv@8 // (global_State *g, TValue *tv) + | mov BASE, RB // Restore BASE. + | jmp <1 + break; +#undef TV2MARKOFS + case BC_USETS: + | ins_AND // RA = upvalue #, RD = str const (~) + | mov LFUNC:RB, [BASE-8] + | mov UPVAL:RB, [LFUNC:RB+RA*4+offsetof(GCfuncL, uvptr)] + | mov GCOBJ:RA, [KBASE+RD*4] + | mov RD, UPVAL:RB->v + | mov [RD], GCOBJ:RA + | mov dword [RD+4], LJ_TSTR + | test byte UPVAL:RB->marked, LJ_GC_BLACK // isblack(uv) + | jnz >2 + |1: + | ins_next + | + |2: // Check if string is white and ensure upvalue is closed. + | test byte GCOBJ:RA->gch.marked, LJ_GC_WHITES // iswhite(str) + | jz <1 + | cmp byte UPVAL:RB->closed, 0 + | jz <1 + | // Crossed a write barrier. Move the barrier forward. + | mov RB, BASE // Save BASE (FCARG2 == BASE). + | mov FCARG2, RD + | lea GL:FCARG1, [DISPATCH+GG_DISP2G] + | call extern lj_gc_barrieruv@8 // (global_State *g, TValue *tv) + | mov BASE, RB // Restore BASE. + | jmp <1 + break; + case BC_USETN: + | ins_AD // RA = upvalue #, RD = num const + | mov LFUNC:RB, [BASE-8] + |.if SSE + | movsd xmm0, qword [KBASE+RD*8] + |.else + | fld qword [KBASE+RD*8] + |.endif + | mov UPVAL:RB, [LFUNC:RB+RA*4+offsetof(GCfuncL, uvptr)] + | mov RA, UPVAL:RB->v + |.if SSE + | movsd qword [RA], xmm0 + |.else + | fstp qword [RA] + |.endif + | ins_next + break; + case BC_USETP: + | ins_AND // RA = upvalue #, RD = primitive type (~) + | mov LFUNC:RB, [BASE-8] + | mov UPVAL:RB, [LFUNC:RB+RA*4+offsetof(GCfuncL, uvptr)] + | mov RA, UPVAL:RB->v + | mov [RA+4], RD + | ins_next + break; + case BC_UCLO: + | ins_AD // RA = level, RD = target + | branchPC RD // Do this first to free RD. + | mov L:RB, SAVE_L + | cmp dword L:RB->openupval, 0 + | je >1 + | mov L:RB->base, BASE + | lea FCARG2, [BASE+RA*8] // Caveat: FCARG2 == BASE + | mov L:FCARG1, L:RB // Caveat: FCARG1 == RA + | call extern lj_func_closeuv@8 // (lua_State *L, TValue *level) + | mov BASE, L:RB->base + |1: + | ins_next + break; + + case BC_FNEW: + | ins_AND // RA = dst, RD = proto const (~) (holding function prototype) + |.if X64 + | mov L:RB, SAVE_L + | mov L:RB->base, BASE // Caveat: CARG2d/CARG3d may be BASE. + | mov CARG3d, [BASE-8] + | mov CARG2d, [KBASE+RD*4] // Fetch GCproto *. + | mov CARG1d, L:RB + |.else + | mov LFUNC:RA, [BASE-8] + | mov PROTO:RD, [KBASE+RD*4] // Fetch GCproto *. + | mov L:RB, SAVE_L + | mov ARG3, LFUNC:RA + | mov ARG2, PROTO:RD + | mov ARG1, L:RB + | mov L:RB->base, BASE + |.endif + | mov SAVE_PC, PC + | // (lua_State *L, GCproto *pt, GCfuncL *parent) + | call extern lj_func_newL_gc + | // GCfuncL * returned in eax (RC). + | mov BASE, L:RB->base + | movzx RA, PC_RA + | mov [BASE+RA*8], LFUNC:RC + | mov dword [BASE+RA*8+4], LJ_TFUNC + | ins_next + break; + + /* -- Table ops --------------------------------------------------------- */ + + case BC_TNEW: + | ins_AD // RA = dst, RD = hbits|asize + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + | mov RA, [DISPATCH+DISPATCH_GL(gc.total)] + | cmp RA, [DISPATCH+DISPATCH_GL(gc.threshold)] + | mov SAVE_PC, PC + | jae >5 + |1: + |.if X64 + | mov CARG3d, RD + | and RD, 0x7ff + | shr CARG3d, 11 + |.else + | mov RA, RD + | and RD, 0x7ff + | shr RA, 11 + | mov ARG3, RA + |.endif + | cmp RD, 0x7ff + | je >3 + |2: + |.if X64 + | mov L:CARG1d, L:RB + | mov CARG2d, RD + |.else + | mov ARG1, L:RB + | mov ARG2, RD + |.endif + | call extern lj_tab_new // (lua_State *L, int32_t asize, uint32_t hbits) + | // Table * returned in eax (RC). + | mov BASE, L:RB->base + | movzx RA, PC_RA + | mov [BASE+RA*8], TAB:RC + | mov dword [BASE+RA*8+4], LJ_TTAB + | ins_next + |3: // Turn 0x7ff into 0x801. + | mov RD, 0x801 + | jmp <2 + |5: + | mov L:FCARG1, L:RB + | call extern lj_gc_step_fixtop@4 // (lua_State *L) + | movzx RD, PC_RD + | jmp <1 + break; + case BC_TDUP: + | ins_AND // RA = dst, RD = table const (~) (holding template table) + | mov L:RB, SAVE_L + | mov RA, [DISPATCH+DISPATCH_GL(gc.total)] + | mov SAVE_PC, PC + | cmp RA, [DISPATCH+DISPATCH_GL(gc.threshold)] + | mov L:RB->base, BASE + | jae >3 + |2: + | mov TAB:FCARG2, [KBASE+RD*4] // Caveat: FCARG2 == BASE + | mov L:FCARG1, L:RB // Caveat: FCARG1 == RA + | call extern lj_tab_dup@8 // (lua_State *L, Table *kt) + | // Table * returned in eax (RC). + | mov BASE, L:RB->base + | movzx RA, PC_RA + | mov [BASE+RA*8], TAB:RC + | mov dword [BASE+RA*8+4], LJ_TTAB + | ins_next + |3: + | mov L:FCARG1, L:RB + | call extern lj_gc_step_fixtop@4 // (lua_State *L) + | movzx RD, PC_RD // Need to reload RD. + | not RDa + | jmp <2 + break; + + case BC_GGET: + | ins_AND // RA = dst, RD = str const (~) + | mov LFUNC:RB, [BASE-8] + | mov TAB:RB, LFUNC:RB->env + | mov STR:RC, [KBASE+RD*4] + | jmp ->BC_TGETS_Z + break; + case BC_GSET: + | ins_AND // RA = src, RD = str const (~) + | mov LFUNC:RB, [BASE-8] + | mov TAB:RB, LFUNC:RB->env + | mov STR:RC, [KBASE+RD*4] + | jmp ->BC_TSETS_Z + break; + + case BC_TGETV: + | ins_ABC // RA = dst, RB = table, RC = key + | checktab RB, ->vmeta_tgetv + | mov TAB:RB, [BASE+RB*8] + | + | // Integer key? + |.if DUALNUM + | checkint RC, >5 + | mov RC, dword [BASE+RC*8] + |.else + | // Convert number to int and back and compare. + | checknum RC, >5 + |.if SSE + | movsd xmm0, qword [BASE+RC*8] + | cvtsd2si RC, xmm0 + | cvtsi2sd xmm1, RC + | ucomisd xmm0, xmm1 + |.else + | fld qword [BASE+RC*8] + | fist ARG1 + | fild ARG1 + | fcomparepp + | mov RC, ARG1 + |.endif + | jne ->vmeta_tgetv // Generic numeric key? Use fallback. + |.endif + | cmp RC, TAB:RB->asize // Takes care of unordered, too. + | jae ->vmeta_tgetv // Not in array part? Use fallback. + | shl RC, 3 + | add RC, TAB:RB->array + | cmp dword [RC+4], LJ_TNIL // Avoid overwriting RB in fastpath. + | je >2 + | // Get array slot. + |.if X64 + | mov RBa, [RC] + | mov [BASE+RA*8], RBa + |.else + | mov RB, [RC] + | mov RC, [RC+4] + | mov [BASE+RA*8], RB + | mov [BASE+RA*8+4], RC + |.endif + |1: + | ins_next + | + |2: // Check for __index if table value is nil. + | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. + | jz >3 + | mov TAB:RA, TAB:RB->metatable + | test byte TAB:RA->nomm, 1<vmeta_tgetv // 'no __index' flag NOT set: check. + | movzx RA, PC_RA // Restore RA. + |3: + | mov dword [BASE+RA*8+4], LJ_TNIL + | jmp <1 + | + |5: // String key? + | checkstr RC, ->vmeta_tgetv + | mov STR:RC, [BASE+RC*8] + | jmp ->BC_TGETS_Z + break; + case BC_TGETS: + | ins_ABC // RA = dst, RB = table, RC = str const (~) + | not RCa + | mov STR:RC, [KBASE+RC*4] + | checktab RB, ->vmeta_tgets + | mov TAB:RB, [BASE+RB*8] + |->BC_TGETS_Z: // RB = GCtab *, RC = GCstr *, refetches PC_RA. + | mov RA, TAB:RB->hmask + | and RA, STR:RC->hash + | imul RA, #NODE + | add NODE:RA, TAB:RB->node + |1: + | cmp dword NODE:RA->key.it, LJ_TSTR + | jne >4 + | cmp dword NODE:RA->key.gcr, STR:RC + | jne >4 + | // Ok, key found. Assumes: offsetof(Node, val) == 0 + | cmp dword [RA+4], LJ_TNIL // Avoid overwriting RB in fastpath. + | je >5 // Key found, but nil value? + | movzx RC, PC_RA + | // Get node value. + |.if X64 + | mov RBa, [RA] + | mov [BASE+RC*8], RBa + |.else + | mov RB, [RA] + | mov RA, [RA+4] + | mov [BASE+RC*8], RB + | mov [BASE+RC*8+4], RA + |.endif + |2: + | ins_next + | + |3: + | movzx RC, PC_RA + | mov dword [BASE+RC*8+4], LJ_TNIL + | jmp <2 + | + |4: // Follow hash chain. + | mov NODE:RA, NODE:RA->next + | test NODE:RA, NODE:RA + | jnz <1 + | // End of hash chain: key not found, nil result. + | + |5: // Check for __index if table value is nil. + | mov TAB:RA, TAB:RB->metatable + | test TAB:RA, TAB:RA + | jz <3 // No metatable: done. + | test byte TAB:RA->nomm, 1<vmeta_tgets // Caveat: preserve STR:RC. + break; + case BC_TGETB: + | ins_ABC // RA = dst, RB = table, RC = byte literal + | checktab RB, ->vmeta_tgetb + | mov TAB:RB, [BASE+RB*8] + | cmp RC, TAB:RB->asize + | jae ->vmeta_tgetb + | shl RC, 3 + | add RC, TAB:RB->array + | cmp dword [RC+4], LJ_TNIL // Avoid overwriting RB in fastpath. + | je >2 + | // Get array slot. + |.if X64 + | mov RBa, [RC] + | mov [BASE+RA*8], RBa + |.else + | mov RB, [RC] + | mov RC, [RC+4] + | mov [BASE+RA*8], RB + | mov [BASE+RA*8+4], RC + |.endif + |1: + | ins_next + | + |2: // Check for __index if table value is nil. + | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. + | jz >3 + | mov TAB:RA, TAB:RB->metatable + | test byte TAB:RA->nomm, 1<vmeta_tgetb // 'no __index' flag NOT set: check. + | movzx RA, PC_RA // Restore RA. + |3: + | mov dword [BASE+RA*8+4], LJ_TNIL + | jmp <1 + break; + + case BC_TSETV: + | ins_ABC // RA = src, RB = table, RC = key + | checktab RB, ->vmeta_tsetv + | mov TAB:RB, [BASE+RB*8] + | + | // Integer key? + |.if DUALNUM + | checkint RC, >5 + | mov RC, dword [BASE+RC*8] + |.else + | // Convert number to int and back and compare. + | checknum RC, >5 + |.if SSE + | movsd xmm0, qword [BASE+RC*8] + | cvtsd2si RC, xmm0 + | cvtsi2sd xmm1, RC + | ucomisd xmm0, xmm1 + |.else + | fld qword [BASE+RC*8] + | fist ARG1 + | fild ARG1 + | fcomparepp + | mov RC, ARG1 + |.endif + | jne ->vmeta_tsetv // Generic numeric key? Use fallback. + |.endif + | cmp RC, TAB:RB->asize // Takes care of unordered, too. + | jae ->vmeta_tsetv + | shl RC, 3 + | add RC, TAB:RB->array + | cmp dword [RC+4], LJ_TNIL + | je >3 // Previous value is nil? + |1: + | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) + | jnz >7 + |2: // Set array slot. + |.if X64 + | mov RBa, [BASE+RA*8] + | mov [RC], RBa + |.else + | mov RB, [BASE+RA*8+4] + | mov RA, [BASE+RA*8] + | mov [RC+4], RB + | mov [RC], RA + |.endif + | ins_next + | + |3: // Check for __newindex if previous value is nil. + | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. + | jz <1 + | mov TAB:RA, TAB:RB->metatable + | test byte TAB:RA->nomm, 1<vmeta_tsetv // 'no __newindex' flag NOT set: check. + | movzx RA, PC_RA // Restore RA. + | jmp <1 + | + |5: // String key? + | checkstr RC, ->vmeta_tsetv + | mov STR:RC, [BASE+RC*8] + | jmp ->BC_TSETS_Z + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, RA + | movzx RA, PC_RA // Restore RA. + | jmp <2 + break; + case BC_TSETS: + | ins_ABC // RA = src, RB = table, RC = str const (~) + | not RCa + | mov STR:RC, [KBASE+RC*4] + | checktab RB, ->vmeta_tsets + | mov TAB:RB, [BASE+RB*8] + |->BC_TSETS_Z: // RB = GCtab *, RC = GCstr *, refetches PC_RA. + | mov RA, TAB:RB->hmask + | and RA, STR:RC->hash + | imul RA, #NODE + | mov byte TAB:RB->nomm, 0 // Clear metamethod cache. + | add NODE:RA, TAB:RB->node + |1: + | cmp dword NODE:RA->key.it, LJ_TSTR + | jne >5 + | cmp dword NODE:RA->key.gcr, STR:RC + | jne >5 + | // Ok, key found. Assumes: offsetof(Node, val) == 0 + | cmp dword [RA+4], LJ_TNIL + | je >4 // Previous value is nil? + |2: + | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) + | jnz >7 + |3: // Set node value. + | movzx RC, PC_RA + |.if X64 + | mov RBa, [BASE+RC*8] + | mov [RA], RBa + |.else + | mov RB, [BASE+RC*8+4] + | mov RC, [BASE+RC*8] + | mov [RA+4], RB + | mov [RA], RC + |.endif + | ins_next + | + |4: // Check for __newindex if previous value is nil. + | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. + | jz <2 + | mov TMP1, RA // Save RA. + | mov TAB:RA, TAB:RB->metatable + | test byte TAB:RA->nomm, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. + | mov RA, TMP1 // Restore RA. + | jmp <2 + | + |5: // Follow hash chain. + | mov NODE:RA, NODE:RA->next + | test NODE:RA, NODE:RA + | jnz <1 + | // End of hash chain: key not found, add a new one. + | + | // But check for __newindex first. + | mov TAB:RA, TAB:RB->metatable + | test TAB:RA, TAB:RA + | jz >6 // No metatable: continue. + | test byte TAB:RA->nomm, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. + |6: + | mov TMP1, STR:RC + | mov TMP2, LJ_TSTR + | mov TMP3, TAB:RB // Save TAB:RB for us. + |.if X64 + | mov L:CARG1d, SAVE_L + | mov L:CARG1d->base, BASE + | lea CARG3, TMP1 + | mov CARG2d, TAB:RB + | mov L:RB, L:CARG1d + |.else + | lea RC, TMP1 // Store temp. TValue in TMP1/TMP2. + | mov ARG2, TAB:RB + | mov L:RB, SAVE_L + | mov ARG3, RC + | mov ARG1, L:RB + | mov L:RB->base, BASE + |.endif + | mov SAVE_PC, PC + | call extern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k) + | // Handles write barrier for the new key. TValue * returned in eax (RC). + | mov BASE, L:RB->base + | mov TAB:RB, TMP3 // Need TAB:RB for barrier. + | mov RA, eax + | jmp <2 // Must check write barrier for value. + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, RC // Destroys STR:RC. + | jmp <3 + break; + case BC_TSETB: + | ins_ABC // RA = src, RB = table, RC = byte literal + | checktab RB, ->vmeta_tsetb + | mov TAB:RB, [BASE+RB*8] + | cmp RC, TAB:RB->asize + | jae ->vmeta_tsetb + | shl RC, 3 + | add RC, TAB:RB->array + | cmp dword [RC+4], LJ_TNIL + | je >3 // Previous value is nil? + |1: + | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) + | jnz >7 + |2: // Set array slot. + |.if X64 + | mov RAa, [BASE+RA*8] + | mov [RC], RAa + |.else + | mov RB, [BASE+RA*8+4] + | mov RA, [BASE+RA*8] + | mov [RC+4], RB + | mov [RC], RA + |.endif + | ins_next + | + |3: // Check for __newindex if previous value is nil. + | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. + | jz <1 + | mov TAB:RA, TAB:RB->metatable + | test byte TAB:RA->nomm, 1<vmeta_tsetb // 'no __newindex' flag NOT set: check. + | movzx RA, PC_RA // Restore RA. + | jmp <1 + | + |7: // Possible table write barrier for the value. Skip valiswhite check. + | barrierback TAB:RB, RA + | movzx RA, PC_RA // Restore RA. + | jmp <2 + break; + + case BC_TSETM: + | ins_AD // RA = base (table at base-1), RD = num const (start index) + | mov TMP1, KBASE // Need one more free register. + | mov KBASE, dword [KBASE+RD*8] // Integer constant is in lo-word. + |1: + | lea RA, [BASE+RA*8] + | mov TAB:RB, [RA-8] // Guaranteed to be a table. + | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) + | jnz >7 + |2: + | mov RD, MULTRES + | sub RD, 1 + | jz >4 // Nothing to copy? + | add RD, KBASE // Compute needed size. + | cmp RD, TAB:RB->asize + | ja >5 // Doesn't fit into array part? + | sub RD, KBASE + | shl KBASE, 3 + | add KBASE, TAB:RB->array + |3: // Copy result slots to table. + |.if X64 + | mov RBa, [RA] + | add RA, 8 + | mov [KBASE], RBa + |.else + | mov RB, [RA] + | mov [KBASE], RB + | mov RB, [RA+4] + | add RA, 8 + | mov [KBASE+4], RB + |.endif + | add KBASE, 8 + | sub RD, 1 + | jnz <3 + |4: + | mov KBASE, TMP1 + | ins_next + | + |5: // Need to resize array part. + |.if X64 + | mov L:CARG1d, SAVE_L + | mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE. + | mov CARG2d, TAB:RB + | mov CARG3d, RD + | mov L:RB, L:CARG1d + |.else + | mov ARG2, TAB:RB + | mov L:RB, SAVE_L + | mov L:RB->base, BASE + | mov ARG3, RD + | mov ARG1, L:RB + |.endif + | mov SAVE_PC, PC + | call extern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) + | mov BASE, L:RB->base + | movzx RA, PC_RA // Restore RA. + | jmp <1 // Retry. + | + |7: // Possible table write barrier for any value. Skip valiswhite check. + | barrierback TAB:RB, RD + | jmp <2 + break; + + /* -- Calls and vararg handling ----------------------------------------- */ + + case BC_CALL: case BC_CALLM: + | ins_A_C // RA = base, (RB = nresults+1,) RC = nargs+1 | extra_nargs + if (op == BC_CALLM) { + | add NARGS:RD, MULTRES + } + | cmp dword [BASE+RA*8+4], LJ_TFUNC + | mov LFUNC:RB, [BASE+RA*8] + | jne ->vmeta_call_ra + | lea BASE, [BASE+RA*8+8] + | ins_call + break; + + case BC_CALLMT: + | ins_AD // RA = base, RD = extra_nargs + | add NARGS:RD, MULTRES + | // Fall through. Assumes BC_CALLT follows and ins_AD is a no-op. + break; + case BC_CALLT: + | ins_AD // RA = base, RD = nargs+1 + | lea RA, [BASE+RA*8+8] + | mov KBASE, BASE // Use KBASE for move + vmeta_call hint. + | mov LFUNC:RB, [RA-8] + | cmp dword [RA-4], LJ_TFUNC + | jne ->vmeta_call + |->BC_CALLT_Z: + | mov PC, [BASE-4] + | test PC, FRAME_TYPE + | jnz >7 + |1: + | mov [BASE-8], LFUNC:RB // Copy function down, reloaded below. + | mov MULTRES, NARGS:RD + | sub NARGS:RD, 1 + | jz >3 + |2: // Move args down. + |.if X64 + | mov RBa, [RA] + | add RA, 8 + | mov [KBASE], RBa + |.else + | mov RB, [RA] + | mov [KBASE], RB + | mov RB, [RA+4] + | add RA, 8 + | mov [KBASE+4], RB + |.endif + | add KBASE, 8 + | sub NARGS:RD, 1 + | jnz <2 + | + | mov LFUNC:RB, [BASE-8] + |3: + | mov NARGS:RD, MULTRES + | cmp byte LFUNC:RB->ffid, 1 // (> FF_C) Calling a fast function? + | ja >5 + |4: + | ins_callt + | + |5: // Tailcall to a fast function. + | test PC, FRAME_TYPE // Lua frame below? + | jnz <4 + | movzx RA, PC_RA + | not RAa + | mov LFUNC:KBASE, [BASE+RA*8-8] // Need to prepare KBASE. + | mov KBASE, LFUNC:KBASE->pc + | mov KBASE, [KBASE+PC2PROTO(k)] + | jmp <4 + | + |7: // Tailcall from a vararg function. + | sub PC, FRAME_VARG + | test PC, FRAME_TYPEP + | jnz >8 // Vararg frame below? + | sub BASE, PC // Need to relocate BASE/KBASE down. + | mov KBASE, BASE + | mov PC, [BASE-4] + | jmp <1 + |8: + | add PC, FRAME_VARG + | jmp <1 + break; + + case BC_ITERC: + | ins_A // RA = base, (RB = nresults+1,) RC = nargs+1 (2+1) + | lea RA, [BASE+RA*8+8] // fb = base+1 + |.if X64 + | mov RBa, [RA-24] // Copy state. fb[0] = fb[-3]. + | mov RCa, [RA-16] // Copy control var. fb[1] = fb[-2]. + | mov [RA], RBa + | mov [RA+8], RCa + |.else + | mov RB, [RA-24] // Copy state. fb[0] = fb[-3]. + | mov RC, [RA-20] + | mov [RA], RB + | mov [RA+4], RC + | mov RB, [RA-16] // Copy control var. fb[1] = fb[-2]. + | mov RC, [RA-12] + | mov [RA+8], RB + | mov [RA+12], RC + |.endif + | mov LFUNC:RB, [RA-32] // Copy callable. fb[-1] = fb[-4] + | mov RC, [RA-28] + | mov [RA-8], LFUNC:RB + | mov [RA-4], RC + | cmp RC, LJ_TFUNC // Handle like a regular 2-arg call. + | mov NARGS:RD, 2+1 + | jne ->vmeta_call + | mov BASE, RA + | ins_call + break; + + case BC_ITERN: + | ins_A // RA = base, (RB = nresults+1, RC = nargs+1 (2+1)) + |.if JIT + | // NYI: add hotloop, record BC_ITERN. + |.endif + | mov TMP1, KBASE // Need two more free registers. + | mov TMP2, DISPATCH + | mov TAB:RB, [BASE+RA*8-16] + | mov RC, [BASE+RA*8-8] // Get index from control var. + | mov DISPATCH, TAB:RB->asize + | add PC, 4 + | mov KBASE, TAB:RB->array + |1: // Traverse array part. + | cmp RC, DISPATCH; jae >5 // Index points after array part? + | cmp dword [KBASE+RC*8+4], LJ_TNIL; je >4 + |.if DUALNUM + | mov dword [BASE+RA*8+4], LJ_TISNUM + | mov dword [BASE+RA*8], RC + |.elif SSE + | cvtsi2sd xmm0, RC + |.else + | fild dword [BASE+RA*8-8] + |.endif + | // Copy array slot to returned value. + |.if X64 + | mov RBa, [KBASE+RC*8] + | mov [BASE+RA*8+8], RBa + |.else + | mov RB, [KBASE+RC*8+4] + | mov [BASE+RA*8+12], RB + | mov RB, [KBASE+RC*8] + | mov [BASE+RA*8+8], RB + |.endif + | add RC, 1 + | // Return array index as a numeric key. + |.if DUALNUM + | // See above. + |.elif SSE + | movsd qword [BASE+RA*8], xmm0 + |.else + | fstp qword [BASE+RA*8] + |.endif + | mov [BASE+RA*8-8], RC // Update control var. + |2: + | movzx RD, PC_RD // Get target from ITERL. + | branchPC RD + |3: + | mov DISPATCH, TMP2 + | mov KBASE, TMP1 + | ins_next + | + |4: // Skip holes in array part. + | add RC, 1 + |.if not (DUALNUM or SSE) + | mov [BASE+RA*8-8], RC + |.endif + | jmp <1 + | + |5: // Traverse hash part. + | sub RC, DISPATCH + |6: + | cmp RC, TAB:RB->hmask; ja <3 // End of iteration? Branch to ITERL+1. + | imul KBASE, RC, #NODE + | add NODE:KBASE, TAB:RB->node + | cmp dword NODE:KBASE->val.it, LJ_TNIL; je >7 + | lea DISPATCH, [RC+DISPATCH+1] + | // Copy key and value from hash slot. + |.if X64 + | mov RBa, NODE:KBASE->key + | mov RCa, NODE:KBASE->val + | mov [BASE+RA*8], RBa + | mov [BASE+RA*8+8], RCa + |.else + | mov RB, NODE:KBASE->key.gcr + | mov RC, NODE:KBASE->key.it + | mov [BASE+RA*8], RB + | mov [BASE+RA*8+4], RC + | mov RB, NODE:KBASE->val.gcr + | mov RC, NODE:KBASE->val.it + | mov [BASE+RA*8+8], RB + | mov [BASE+RA*8+12], RC + |.endif + | mov [BASE+RA*8-8], DISPATCH + | jmp <2 + | + |7: // Skip holes in hash part. + | add RC, 1 + | jmp <6 + break; + + case BC_ISNEXT: + | ins_AD // RA = base, RD = target (points to ITERN) + | cmp dword [BASE+RA*8-20], LJ_TFUNC; jne >5 + | mov CFUNC:RB, [BASE+RA*8-24] + | cmp dword [BASE+RA*8-12], LJ_TTAB; jne >5 + | cmp dword [BASE+RA*8-4], LJ_TNIL; jne >5 + | cmp byte CFUNC:RB->ffid, FF_next_N; jne >5 + | branchPC RD + | mov dword [BASE+RA*8-8], 0 // Initialize control var. + | mov dword [BASE+RA*8-4], 0xfffe7fff + |1: + | ins_next + |5: // Despecialize bytecode if any of the checks fail. + | mov PC_OP, BC_JMP + | branchPC RD + | mov byte [PC], BC_ITERC + | jmp <1 + break; + + case BC_VARG: + | ins_ABC // RA = base, RB = nresults+1, RC = numparams + | mov TMP1, KBASE // Need one more free register. + | lea KBASE, [BASE+RC*8+(8+FRAME_VARG)] + | lea RA, [BASE+RA*8] + | sub KBASE, [BASE-4] + | // Note: KBASE may now be even _above_ BASE if nargs was < numparams. + | test RB, RB + | jz >5 // Copy all varargs? + | lea RB, [RA+RB*8-8] + | cmp KBASE, BASE // No vararg slots? + | jnb >2 + |1: // Copy vararg slots to destination slots. + |.if X64 + | mov RCa, [KBASE-8] + | add KBASE, 8 + | mov [RA], RCa + |.else + | mov RC, [KBASE-8] + | mov [RA], RC + | mov RC, [KBASE-4] + | add KBASE, 8 + | mov [RA+4], RC + |.endif + | add RA, 8 + | cmp RA, RB // All destination slots filled? + | jnb >3 + | cmp KBASE, BASE // No more vararg slots? + | jb <1 + |2: // Fill up remainder with nil. + | mov dword [RA+4], LJ_TNIL + | add RA, 8 + | cmp RA, RB + | jb <2 + |3: + | mov KBASE, TMP1 + | ins_next + | + |5: // Copy all varargs. + | mov MULTRES, 1 // MULTRES = 0+1 + | mov RC, BASE + | sub RC, KBASE + | jbe <3 // No vararg slots? + | mov RB, RC + | shr RB, 3 + | add RB, 1 + | mov MULTRES, RB // MULTRES = #varargs+1 + | mov L:RB, SAVE_L + | add RC, RA + | cmp RC, L:RB->maxstack + | ja >7 // Need to grow stack? + |6: // Copy all vararg slots. + |.if X64 + | mov RCa, [KBASE-8] + | add KBASE, 8 + | mov [RA], RCa + |.else + | mov RC, [KBASE-8] + | mov [RA], RC + | mov RC, [KBASE-4] + | add KBASE, 8 + | mov [RA+4], RC + |.endif + | add RA, 8 + | cmp KBASE, BASE // No more vararg slots? + | jb <6 + | jmp <3 + | + |7: // Grow stack for varargs. + | mov L:RB->base, BASE + | mov L:RB->top, RA + | mov SAVE_PC, PC + | sub KBASE, BASE // Need delta, because BASE may change. + | mov FCARG2, MULTRES + | sub FCARG2, 1 + | mov FCARG1, L:RB + | call extern lj_state_growstack@8 // (lua_State *L, int n) + | mov BASE, L:RB->base + | mov RA, L:RB->top + | add KBASE, BASE + | jmp <6 + break; + + /* -- Returns ----------------------------------------------------------- */ + + case BC_RETM: + | ins_AD // RA = results, RD = extra_nresults + | add RD, MULTRES // MULTRES >=1, so RD >=1. + | // Fall through. Assumes BC_RET follows and ins_AD is a no-op. + break; + + case BC_RET: case BC_RET0: case BC_RET1: + | ins_AD // RA = results, RD = nresults+1 + if (op != BC_RET0) { + | shl RA, 3 + } + |1: + | mov PC, [BASE-4] + | mov MULTRES, RD // Save nresults+1. + | test PC, FRAME_TYPE // Check frame type marker. + | jnz >7 // Not returning to a fixarg Lua func? + switch (op) { + case BC_RET: + |->BC_RET_Z: + | mov KBASE, BASE // Use KBASE for result move. + | sub RD, 1 + | jz >3 + |2: // Move results down. + |.if X64 + | mov RBa, [KBASE+RA] + | mov [KBASE-8], RBa + |.else + | mov RB, [KBASE+RA] + | mov [KBASE-8], RB + | mov RB, [KBASE+RA+4] + | mov [KBASE-4], RB + |.endif + | add KBASE, 8 + | sub RD, 1 + | jnz <2 + |3: + | mov RD, MULTRES // Note: MULTRES may be >255. + | movzx RB, PC_RB // So cannot compare with RDL! + |5: + | cmp RB, RD // More results expected? + | ja >6 + break; + case BC_RET1: + |.if X64 + | mov RBa, [BASE+RA] + | mov [BASE-8], RBa + |.else + | mov RB, [BASE+RA+4] + | mov [BASE-4], RB + | mov RB, [BASE+RA] + | mov [BASE-8], RB + |.endif + /* fallthrough */ + case BC_RET0: + |5: + | cmp PC_RB, RDL // More results expected? + | ja >6 + default: + break; + } + | movzx RA, PC_RA + | not RAa // Note: ~RA = -(RA+1) + | lea BASE, [BASE+RA*8] // base = base - (RA+1)*8 + | mov LFUNC:KBASE, [BASE-8] + | mov KBASE, LFUNC:KBASE->pc + | mov KBASE, [KBASE+PC2PROTO(k)] + | ins_next + | + |6: // Fill up results with nil. + if (op == BC_RET) { + | mov dword [KBASE-4], LJ_TNIL // Note: relies on shifted base. + | add KBASE, 8 + } else { + | mov dword [BASE+RD*8-12], LJ_TNIL + } + | add RD, 1 + | jmp <5 + | + |7: // Non-standard return case. + | lea RB, [PC-FRAME_VARG] + | test RB, FRAME_TYPEP + | jnz ->vm_return + | // Return from vararg function: relocate BASE down and RA up. + | sub BASE, RB + if (op != BC_RET0) { + | add RA, RB + } + | jmp <1 + break; + + /* -- Loops and branches ------------------------------------------------ */ + + |.define FOR_IDX, [RA]; .define FOR_TIDX, dword [RA+4] + |.define FOR_STOP, [RA+8]; .define FOR_TSTOP, dword [RA+12] + |.define FOR_STEP, [RA+16]; .define FOR_TSTEP, dword [RA+20] + |.define FOR_EXT, [RA+24]; .define FOR_TEXT, dword [RA+28] + + case BC_FORL: + |.if JIT + | hotloop RB + |.endif + | // Fall through. Assumes BC_IFORL follows and ins_AJ is a no-op. + break; + + case BC_JFORI: + case BC_JFORL: +#if !LJ_HASJIT + break; +#endif + case BC_FORI: + case BC_IFORL: + vk = (op == BC_IFORL || op == BC_JFORL); + | ins_AJ // RA = base, RD = target (after end of loop or start of loop) + | lea RA, [BASE+RA*8] + if (LJ_DUALNUM) { + | cmp FOR_TIDX, LJ_TISNUM; jne >9 + if (!vk) { + | cmp FOR_TSTOP, LJ_TISNUM; jne ->vmeta_for + | cmp FOR_TSTEP, LJ_TISNUM; jne ->vmeta_for + | mov RB, dword FOR_IDX + | cmp dword FOR_STEP, 0; jl >5 + } else { +#ifdef LUA_USE_ASSERT + | cmp FOR_TSTOP, LJ_TISNUM; jne ->assert_bad_for_arg_type + | cmp FOR_TSTEP, LJ_TISNUM; jne ->assert_bad_for_arg_type +#endif + | mov RB, dword FOR_STEP + | test RB, RB; js >5 + | add RB, dword FOR_IDX; jo >1 + | mov dword FOR_IDX, RB + } + | cmp RB, dword FOR_STOP + | mov FOR_TEXT, LJ_TISNUM + | mov dword FOR_EXT, RB + if (op == BC_FORI) { + | jle >7 + |1: + |6: + | branchPC RD + } else if (op == BC_JFORI) { + | branchPC RD + | movzx RD, PC_RD + | jle =>BC_JLOOP + |1: + |6: + } else if (op == BC_IFORL) { + | jg >7 + |6: + | branchPC RD + |1: + } else { + | jle =>BC_JLOOP + |1: + |6: + } + |7: + | ins_next + | + |5: // Invert check for negative step. + if (vk) { + | add RB, dword FOR_IDX; jo <1 + | mov dword FOR_IDX, RB + } + | cmp RB, dword FOR_STOP + | mov FOR_TEXT, LJ_TISNUM + | mov dword FOR_EXT, RB + if (op == BC_FORI) { + | jge <7 + } else if (op == BC_JFORI) { + | branchPC RD + | movzx RD, PC_RD + | jge =>BC_JLOOP + } else if (op == BC_IFORL) { + | jl <7 + } else { + | jge =>BC_JLOOP + } + | jmp <6 + |9: // Fallback to FP variant. + } else if (!vk) { + | cmp FOR_TIDX, LJ_TISNUM + } + if (!vk) { + | jae ->vmeta_for + | cmp FOR_TSTOP, LJ_TISNUM; jae ->vmeta_for + } else { +#ifdef LUA_USE_ASSERT + | cmp FOR_TSTOP, LJ_TISNUM; jae ->assert_bad_for_arg_type + | cmp FOR_TSTEP, LJ_TISNUM; jae ->assert_bad_for_arg_type +#endif + } + | mov RB, FOR_TSTEP // Load type/hiword of for step. + if (!vk) { + | cmp RB, LJ_TISNUM; jae ->vmeta_for + } + |.if SSE + | movsd xmm0, qword FOR_IDX + | movsd xmm1, qword FOR_STOP + if (vk) { + | addsd xmm0, qword FOR_STEP + | movsd qword FOR_IDX, xmm0 + | test RB, RB; js >3 + } else { + | jl >3 + } + | ucomisd xmm1, xmm0 + |1: + | movsd qword FOR_EXT, xmm0 + |.else + | fld qword FOR_STOP + | fld qword FOR_IDX + if (vk) { + | fadd qword FOR_STEP // nidx = idx + step + | fst qword FOR_IDX + | fst qword FOR_EXT + | test RB, RB; js >1 + } else { + | fst qword FOR_EXT + | jl >1 + } + | fxch // Swap lim/(n)idx if step non-negative. + |1: + | fcomparepp + |.endif + if (op == BC_FORI) { + |.if DUALNUM + | jnb <7 + |.else + | jnb >2 + | branchPC RD + |.endif + } else if (op == BC_JFORI) { + | branchPC RD + | movzx RD, PC_RD + | jnb =>BC_JLOOP + } else if (op == BC_IFORL) { + |.if DUALNUM + | jb <7 + |.else + | jb >2 + | branchPC RD + |.endif + } else { + | jnb =>BC_JLOOP + } + |.if DUALNUM + | jmp <6 + |.else + |2: + | ins_next + |.endif + |.if SSE + |3: // Invert comparison if step is negative. + | ucomisd xmm0, xmm1 + | jmp <1 + |.endif + break; + + case BC_ITERL: + |.if JIT + | hotloop RB + |.endif + | // Fall through. Assumes BC_IITERL follows and ins_AJ is a no-op. + break; + + case BC_JITERL: +#if !LJ_HASJIT + break; +#endif + case BC_IITERL: + | ins_AJ // RA = base, RD = target + | lea RA, [BASE+RA*8] + | mov RB, [RA+4] + | cmp RB, LJ_TNIL; je >1 // Stop if iterator returned nil. + if (op == BC_JITERL) { + | mov [RA-4], RB + | mov RB, [RA] + | mov [RA-8], RB + | jmp =>BC_JLOOP + } else { + | branchPC RD // Otherwise save control var + branch. + | mov RD, [RA] + | mov [RA-4], RB + | mov [RA-8], RD + } + |1: + | ins_next + break; + + case BC_LOOP: + | ins_A // RA = base, RD = target (loop extent) + | // Note: RA/RD is only used by trace recorder to determine scope/extent + | // This opcode does NOT jump, it's only purpose is to detect a hot loop. + |.if JIT + | hotloop RB + |.endif + | // Fall through. Assumes BC_ILOOP follows and ins_A is a no-op. + break; + + case BC_ILOOP: + | ins_A // RA = base, RD = target (loop extent) + | ins_next + break; + + case BC_JLOOP: + |.if JIT + | ins_AD // RA = base (ignored), RD = traceno + | mov RA, [DISPATCH+DISPATCH_J(trace)] + | mov TRACE:RD, [RA+RD*4] + | mov RDa, TRACE:RD->mcode + | mov L:RB, SAVE_L + | mov [DISPATCH+DISPATCH_GL(jit_base)], BASE + | mov [DISPATCH+DISPATCH_GL(jit_L)], L:RB + | // Save additional callee-save registers only used in compiled code. + |.if X64WIN + | mov TMPQ, r12 + | mov TMPa, r13 + | mov CSAVE_4, r14 + | mov CSAVE_3, r15 + | mov RAa, rsp + | sub rsp, 9*16+4*8 + | movdqa [RAa], xmm6 + | movdqa [RAa-1*16], xmm7 + | movdqa [RAa-2*16], xmm8 + | movdqa [RAa-3*16], xmm9 + | movdqa [RAa-4*16], xmm10 + | movdqa [RAa-5*16], xmm11 + | movdqa [RAa-6*16], xmm12 + | movdqa [RAa-7*16], xmm13 + | movdqa [RAa-8*16], xmm14 + | movdqa [RAa-9*16], xmm15 + |.elif X64 + | mov TMPQ, r12 + | mov TMPa, r13 + | sub rsp, 16 + |.endif + | jmp RDa + |.endif + break; + + case BC_JMP: + | ins_AJ // RA = unused, RD = target + | branchPC RD + | ins_next + break; + + /* -- Function headers -------------------------------------------------- */ + + /* + ** Reminder: A function may be called with func/args above L->maxstack, + ** i.e. occupying EXTRA_STACK slots. And vmeta_call may add one extra slot, + ** too. This means all FUNC* ops (including fast functions) must check + ** for stack overflow _before_ adding more slots! + */ + + case BC_FUNCF: + |.if JIT + | hotcall RB + |.endif + case BC_FUNCV: /* NYI: compiled vararg functions. */ + | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow and ins_AD is a no-op. + break; + + case BC_JFUNCF: +#if !LJ_HASJIT + break; +#endif + case BC_IFUNCF: + | ins_AD // BASE = new base, RA = framesize, RD = nargs+1 + | mov KBASE, [PC-4+PC2PROTO(k)] + | mov L:RB, SAVE_L + | lea RA, [BASE+RA*8] // Top of frame. + | cmp RA, L:RB->maxstack + | ja ->vm_growstack_f + | movzx RA, byte [PC-4+PC2PROTO(numparams)] + | cmp NARGS:RD, RA // Check for missing parameters. + | jbe >3 + |2: + if (op == BC_JFUNCF) { + | movzx RD, PC_RD + | jmp =>BC_JLOOP + } else { + | ins_next + } + | + |3: // Clear missing parameters. + | mov dword [BASE+NARGS:RD*8-4], LJ_TNIL + | add NARGS:RD, 1 + | cmp NARGS:RD, RA + | jbe <3 + | jmp <2 + break; + + case BC_JFUNCV: +#if !LJ_HASJIT + break; +#endif + | int3 // NYI: compiled vararg functions + break; /* NYI: compiled vararg functions. */ + + case BC_IFUNCV: + | ins_AD // BASE = new base, RA = framesize, RD = nargs+1 + | lea RB, [NARGS:RD*8+FRAME_VARG] + | lea RD, [BASE+NARGS:RD*8] + | mov LFUNC:KBASE, [BASE-8] + | mov [RD-4], RB // Store delta + FRAME_VARG. + | mov [RD-8], LFUNC:KBASE // Store copy of LFUNC. + | mov L:RB, SAVE_L + | lea RA, [RD+RA*8] + | cmp RA, L:RB->maxstack + | ja ->vm_growstack_v // Need to grow stack. + | mov RA, BASE + | mov BASE, RD + | movzx RB, byte [PC-4+PC2PROTO(numparams)] + | test RB, RB + | jz >2 + |1: // Copy fixarg slots up to new frame. + | add RA, 8 + | cmp RA, BASE + | jnb >3 // Less args than parameters? + | mov KBASE, [RA-8] + | mov [RD], KBASE + | mov KBASE, [RA-4] + | mov [RD+4], KBASE + | add RD, 8 + | mov dword [RA-4], LJ_TNIL // Clear old fixarg slot (help the GC). + | sub RB, 1 + | jnz <1 + |2: + if (op == BC_JFUNCV) { + | movzx RD, PC_RD + | jmp =>BC_JLOOP + } else { + | mov KBASE, [PC-4+PC2PROTO(k)] + | ins_next + } + | + |3: // Clear missing parameters. + | mov dword [RD+4], LJ_TNIL + | add RD, 8 + | sub RB, 1 + | jnz <3 + | jmp <2 + break; + + case BC_FUNCC: + case BC_FUNCCW: + | ins_AD // BASE = new base, RA = ins RA|RD (unused), RD = nargs+1 + | mov CFUNC:RB, [BASE-8] + | mov KBASEa, CFUNC:RB->f + | mov L:RB, SAVE_L + | lea RD, [BASE+NARGS:RD*8-8] + | mov L:RB->base, BASE + | lea RA, [RD+8*LUA_MINSTACK] + | cmp RA, L:RB->maxstack + | mov L:RB->top, RD + if (op == BC_FUNCC) { + |.if X64 + | mov CARG1d, L:RB // Caveat: CARG1d may be RA. + |.else + | mov ARG1, L:RB + |.endif + } else { + |.if X64 + | mov CARG2, KBASEa + | mov CARG1d, L:RB // Caveat: CARG1d may be RA. + |.else + | mov ARG2, KBASEa + | mov ARG1, L:RB + |.endif + } + | ja ->vm_growstack_c // Need to grow stack. + | set_vmstate C + if (op == BC_FUNCC) { + | call KBASEa // (lua_State *L) + } else { + | // (lua_State *L, lua_CFunction f) + | call aword [DISPATCH+DISPATCH_GL(wrapf)] + } + | set_vmstate INTERP + | // nresults returned in eax (RD). + | mov BASE, L:RB->base + | lea RA, [BASE+RD*8] + | neg RA + | add RA, L:RB->top // RA = (L->top-(L->base+nresults))*8 + | mov PC, [BASE-4] // Fetch PC of caller. + | jmp ->vm_returnc + break; + + /* ---------------------------------------------------------------------- */ + + default: + fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); + exit(2); + break; + } +} + +static int build_backend(BuildCtx *ctx) +{ + int op; + dasm_growpc(Dst, BC__MAX); + build_subroutines(ctx); + |.code_op + for (op = 0; op < BC__MAX; op++) + build_ins(ctx, (BCOp)op, op); + return BC__MAX; +} + +/* Emit pseudo frame-info for all assembler functions. */ +static void emit_asm_debug(BuildCtx *ctx) +{ + int fcofs = (int)((uint8_t *)ctx->glob[GLOB_vm_ffi_call] - ctx->code); +#if LJ_64 +#define SZPTR "8" +#define BSZPTR "3" +#define REG_SP "0x7" +#define REG_RA "0x10" +#else +#define SZPTR "4" +#define BSZPTR "2" +#define REG_SP "0x4" +#define REG_RA "0x8" +#endif + switch (ctx->mode) { + case BUILD_elfasm: + fprintf(ctx->fp, "\t.section .debug_frame,\"\",@progbits\n"); + fprintf(ctx->fp, + ".Lframe0:\n" + "\t.long .LECIE0-.LSCIE0\n" + ".LSCIE0:\n" + "\t.long 0xffffffff\n" + "\t.byte 0x1\n" + "\t.string \"\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -" SZPTR "\n" + "\t.byte " REG_RA "\n" + "\t.byte 0xc\n\t.uleb128 " REG_SP "\n\t.uleb128 " SZPTR "\n" + "\t.byte 0x80+" REG_RA "\n\t.uleb128 0x1\n" + "\t.align " SZPTR "\n" + ".LECIE0:\n\n"); + fprintf(ctx->fp, + ".LSFDE0:\n" + "\t.long .LEFDE0-.LASFDE0\n" + ".LASFDE0:\n" + "\t.long .Lframe0\n" +#if LJ_64 + "\t.quad .Lbegin\n" + "\t.quad %d\n" + "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ + "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ + "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ + "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */ + "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */ +#else + "\t.long .Lbegin\n" + "\t.long %d\n" + "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ + "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ + "\t.byte 0x87\n\t.uleb128 0x3\n" /* offset edi */ + "\t.byte 0x86\n\t.uleb128 0x4\n" /* offset esi */ + "\t.byte 0x83\n\t.uleb128 0x5\n" /* offset ebx */ +#endif + "\t.align " SZPTR "\n" + ".LEFDE0:\n\n", fcofs, CFRAME_SIZE); +#if LJ_HASFFI + fprintf(ctx->fp, + ".LSFDE1:\n" + "\t.long .LEFDE1-.LASFDE1\n" + ".LASFDE1:\n" + "\t.long .Lframe0\n" +#if LJ_64 + "\t.quad lj_vm_ffi_call\n" + "\t.quad %d\n" + "\t.byte 0xe\n\t.uleb128 16\n" /* def_cfa_offset */ + "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ + "\t.byte 0xd\n\t.uleb128 0x6\n" /* def_cfa_register rbp */ + "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ +#else + "\t.long lj_vm_ffi_call\n" + "\t.long %d\n" + "\t.byte 0xe\n\t.uleb128 8\n" /* def_cfa_offset */ + "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ + "\t.byte 0xd\n\t.uleb128 0x5\n" /* def_cfa_register ebp */ + "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset ebx */ +#endif + "\t.align " SZPTR "\n" + ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); +#endif +#if (defined(__sun__) && defined(__svr4__)) +#if LJ_64 + fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@unwind\n"); +#else + fprintf(ctx->fp, "\t.section .eh_frame,\"aw\",@progbits\n"); +#endif +#else + fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n"); +#endif + fprintf(ctx->fp, + ".Lframe1:\n" + "\t.long .LECIE1-.LSCIE1\n" + ".LSCIE1:\n" + "\t.long 0\n" + "\t.byte 0x1\n" + "\t.string \"zPR\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -" SZPTR "\n" + "\t.byte " REG_RA "\n" + "\t.uleb128 6\n" /* augmentation length */ + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.long lj_err_unwind_dwarf-.\n" + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.byte 0xc\n\t.uleb128 " REG_SP "\n\t.uleb128 " SZPTR "\n" + "\t.byte 0x80+" REG_RA "\n\t.uleb128 0x1\n" + "\t.align " SZPTR "\n" + ".LECIE1:\n\n"); + fprintf(ctx->fp, + ".LSFDE2:\n" + "\t.long .LEFDE2-.LASFDE2\n" + ".LASFDE2:\n" + "\t.long .LASFDE2-.Lframe1\n" + "\t.long .Lbegin-.\n" + "\t.long %d\n" + "\t.uleb128 0\n" /* augmentation length */ + "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ +#if LJ_64 + "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ + "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ + "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */ + "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */ +#else + "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ + "\t.byte 0x87\n\t.uleb128 0x3\n" /* offset edi */ + "\t.byte 0x86\n\t.uleb128 0x4\n" /* offset esi */ + "\t.byte 0x83\n\t.uleb128 0x5\n" /* offset ebx */ +#endif + "\t.align " SZPTR "\n" + ".LEFDE2:\n\n", fcofs, CFRAME_SIZE); +#if LJ_HASFFI + fprintf(ctx->fp, + ".Lframe2:\n" + "\t.long .LECIE2-.LSCIE2\n" + ".LSCIE2:\n" + "\t.long 0\n" + "\t.byte 0x1\n" + "\t.string \"zR\"\n" + "\t.uleb128 0x1\n" + "\t.sleb128 -" SZPTR "\n" + "\t.byte " REG_RA "\n" + "\t.uleb128 1\n" /* augmentation length */ + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.byte 0xc\n\t.uleb128 " REG_SP "\n\t.uleb128 " SZPTR "\n" + "\t.byte 0x80+" REG_RA "\n\t.uleb128 0x1\n" + "\t.align " SZPTR "\n" + ".LECIE2:\n\n"); + fprintf(ctx->fp, + ".LSFDE3:\n" + "\t.long .LEFDE3-.LASFDE3\n" + ".LASFDE3:\n" + "\t.long .LASFDE3-.Lframe2\n" + "\t.long lj_vm_ffi_call-.\n" + "\t.long %d\n" + "\t.uleb128 0\n" /* augmentation length */ +#if LJ_64 + "\t.byte 0xe\n\t.uleb128 16\n" /* def_cfa_offset */ + "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ + "\t.byte 0xd\n\t.uleb128 0x6\n" /* def_cfa_register rbp */ + "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ +#else + "\t.byte 0xe\n\t.uleb128 8\n" /* def_cfa_offset */ + "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ + "\t.byte 0xd\n\t.uleb128 0x5\n" /* def_cfa_register ebp */ + "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset ebx */ +#endif + "\t.align " SZPTR "\n" + ".LEFDE3:\n\n", (int)ctx->codesz - fcofs); +#endif + break; + /* Mental note: never let Apple design an assembler. + ** Or a linker. Or a plastic case. But I digress. + */ + case BUILD_machasm: { +#if LJ_HASFFI + int fcsize = 0; +#endif + int i; + fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n"); + fprintf(ctx->fp, + "EH_frame1:\n" + "\t.set L$set$x,LECIEX-LSCIEX\n" + "\t.long L$set$x\n" + "LSCIEX:\n" + "\t.long 0\n" + "\t.byte 0x1\n" + "\t.ascii \"zPR\\0\"\n" + "\t.byte 0x1\n" + "\t.byte 128-" SZPTR "\n" + "\t.byte " REG_RA "\n" + "\t.byte 6\n" /* augmentation length */ + "\t.byte 0x9b\n" /* indirect|pcrel|sdata4 */ +#if LJ_64 + "\t.long _lj_err_unwind_dwarf+4@GOTPCREL\n" + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.byte 0xc\n\t.byte " REG_SP "\n\t.byte " SZPTR "\n" +#else + "\t.long L_lj_err_unwind_dwarf$non_lazy_ptr-.\n" + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.byte 0xc\n\t.byte 0x5\n\t.byte 0x4\n" /* esp=5 on 32 bit MACH-O. */ +#endif + "\t.byte 0x80+" REG_RA "\n\t.byte 0x1\n" + "\t.align " BSZPTR "\n" + "LECIEX:\n\n"); + for (i = 0; i < ctx->nsym; i++) { + const char *name = ctx->sym[i].name; + int32_t size = ctx->sym[i+1].ofs - ctx->sym[i].ofs; + if (size == 0) continue; +#if LJ_HASFFI + if (!strcmp(name, "_lj_vm_ffi_call")) { fcsize = size; continue; } +#endif + fprintf(ctx->fp, + "%s.eh:\n" + "LSFDE%d:\n" + "\t.set L$set$%d,LEFDE%d-LASFDE%d\n" + "\t.long L$set$%d\n" + "LASFDE%d:\n" + "\t.long LASFDE%d-EH_frame1\n" + "\t.long %s-.\n" + "\t.long %d\n" + "\t.byte 0\n" /* augmentation length */ + "\t.byte 0xe\n\t.byte %d\n" /* def_cfa_offset */ +#if LJ_64 + "\t.byte 0x86\n\t.byte 0x2\n" /* offset rbp */ + "\t.byte 0x83\n\t.byte 0x3\n" /* offset rbx */ + "\t.byte 0x8f\n\t.byte 0x4\n" /* offset r15 */ + "\t.byte 0x8e\n\t.byte 0x5\n" /* offset r14 */ +#else + "\t.byte 0x84\n\t.byte 0x2\n" /* offset ebp (4 for MACH-O)*/ + "\t.byte 0x87\n\t.byte 0x3\n" /* offset edi */ + "\t.byte 0x86\n\t.byte 0x4\n" /* offset esi */ + "\t.byte 0x83\n\t.byte 0x5\n" /* offset ebx */ +#endif + "\t.align " BSZPTR "\n" + "LEFDE%d:\n\n", + name, i, i, i, i, i, i, i, name, size, CFRAME_SIZE, i); + } +#if LJ_HASFFI + if (fcsize) { + fprintf(ctx->fp, + "EH_frame2:\n" + "\t.set L$set$y,LECIEY-LSCIEY\n" + "\t.long L$set$y\n" + "LSCIEY:\n" + "\t.long 0\n" + "\t.byte 0x1\n" + "\t.ascii \"zR\\0\"\n" + "\t.byte 0x1\n" + "\t.byte 128-" SZPTR "\n" + "\t.byte " REG_RA "\n" + "\t.byte 1\n" /* augmentation length */ +#if LJ_64 + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.byte 0xc\n\t.byte " REG_SP "\n\t.byte " SZPTR "\n" +#else + "\t.byte 0x1b\n" /* pcrel|sdata4 */ + "\t.byte 0xc\n\t.byte 0x5\n\t.byte 0x4\n" /* esp=5 on 32 bit MACH. */ +#endif + "\t.byte 0x80+" REG_RA "\n\t.byte 0x1\n" + "\t.align " BSZPTR "\n" + "LECIEY:\n\n"); + fprintf(ctx->fp, + "_lj_vm_ffi_call.eh:\n" + "LSFDEY:\n" + "\t.set L$set$yy,LEFDEY-LASFDEY\n" + "\t.long L$set$yy\n" + "LASFDEY:\n" + "\t.long LASFDEY-EH_frame2\n" + "\t.long _lj_vm_ffi_call-.\n" + "\t.long %d\n" + "\t.byte 0\n" /* augmentation length */ +#if LJ_64 + "\t.byte 0xe\n\t.byte 16\n" /* def_cfa_offset */ + "\t.byte 0x86\n\t.byte 0x2\n" /* offset rbp */ + "\t.byte 0xd\n\t.byte 0x6\n" /* def_cfa_register rbp */ + "\t.byte 0x83\n\t.byte 0x3\n" /* offset rbx */ +#else + "\t.byte 0xe\n\t.byte 8\n" /* def_cfa_offset */ + "\t.byte 0x84\n\t.byte 0x2\n" /* offset ebp (4 for MACH-O)*/ + "\t.byte 0xd\n\t.byte 0x4\n" /* def_cfa_register ebp */ + "\t.byte 0x83\n\t.byte 0x3\n" /* offset ebx */ +#endif + "\t.align " BSZPTR "\n" + "LEFDEY:\n\n", fcsize); + } +#endif +#if LJ_64 + fprintf(ctx->fp, "\t.subsections_via_symbols\n"); +#else + fprintf(ctx->fp, + "\t.non_lazy_symbol_pointer\n" + "L_lj_err_unwind_dwarf$non_lazy_ptr:\n" + ".indirect_symbol _lj_err_unwind_dwarf\n" + ".long 0\n"); +#endif + } + break; + default: /* Difficult for other modes. */ + break; + } +} + diff --git a/source/libs/luajit/LuaJIT-2.0.3/src/xedkbuild.bat b/source/libs/luajit/LuaJIT-2.0.4/src/xedkbuild.bat similarity index 100% rename from source/libs/luajit/LuaJIT-2.0.3/src/xedkbuild.bat rename to source/libs/luajit/LuaJIT-2.0.4/src/xedkbuild.bat diff --git a/source/libs/luajit/configure b/source/libs/luajit/configure index e6cd0c830..039ddf2e8 100755 --- a/source/libs/luajit/configure +++ b/source/libs/luajit/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for luajit for TeX Live 2.0.3. +# Generated by GNU Autoconf 2.69 for luajit for TeX Live 2.0.4. # # Report bugs to . # @@ -590,12 +590,12 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='luajit for TeX Live' PACKAGE_TARNAME='luajit-for-tex-live' -PACKAGE_VERSION='2.0.3' -PACKAGE_STRING='luajit for TeX Live 2.0.3' +PACKAGE_VERSION='2.0.4' +PACKAGE_STRING='luajit for TeX Live 2.0.4' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' -ac_unique_file="LuaJIT-2.0.3/src/luajit.h" +ac_unique_file="LuaJIT-2.0.4/src/luajit.h" # Factoring default headers for most tests. ac_includes_default="\ #include @@ -1343,7 +1343,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures luajit for TeX Live 2.0.3 to adapt to many kinds of systems. +\`configure' configures luajit for TeX Live 2.0.4 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1414,7 +1414,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of luajit for TeX Live 2.0.3:";; + short | recursive ) echo "Configuration of luajit for TeX Live 2.0.4:";; esac cat <<\_ACEOF @@ -1533,7 +1533,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -luajit for TeX Live configure 2.0.3 +luajit for TeX Live configure 2.0.4 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1994,7 +1994,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by luajit for TeX Live $as_me 2.0.3, which was +It was created by luajit for TeX Live $as_me 2.0.4, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3917,7 +3917,7 @@ fi # Define the identity of the package. PACKAGE='luajit-for-tex-live' - VERSION='2.0.3' + VERSION='2.0.4' cat >>confdefs.h <<_ACEOF @@ -4072,13 +4072,13 @@ else if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_cflags="-Wimplicit -Wreturn-type" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement" ;; #( *) : ;; esac case `$CC -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -4090,7 +4090,7 @@ esac kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition" ;; #( *) : ;; @@ -5158,10 +5158,10 @@ $as_echo "no, using $LN_S" >&6; } fi -LUAJITVERSION=2.0.3 +LUAJITVERSION=2.0.4 -LUAJIT_LT_VERSINFO=2:3:0 +LUAJIT_LT_VERSINFO=2:4:0 case `pwd` in @@ -13955,7 +13955,7 @@ case $host_os in #( LJHOST='Other' ;; esac lj_save_CPPFLAGS=$CPPFLAGS -CPPFLAGS="$CPPFLAGS -I$srcdir/LuaJIT-2.0.3/src $LUAJIT_DEFINES -dM" +CPPFLAGS="$CPPFLAGS -I$srcdir/LuaJIT-2.0.4/src $LUAJIT_DEFINES -dM" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -14113,7 +14113,7 @@ fi echo timestamp >config.force fi -LUAJIT_TREE=LuaJIT-2.0.3 +LUAJIT_TREE=LuaJIT-2.0.4 ac_config_headers="$ac_config_headers config.h" @@ -14680,7 +14680,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by luajit for TeX Live $as_me 2.0.3, which was +This file was extended by luajit for TeX Live $as_me 2.0.4, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14746,7 +14746,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -luajit for TeX Live config.status 2.0.3 +luajit for TeX Live config.status 2.0.4 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/source/libs/luajit/native/configure b/source/libs/luajit/native/configure index f63d59fe3..794770bc8 100755 --- a/source/libs/luajit/native/configure +++ b/source/libs/luajit/native/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for luajit native 2.0.3. +# Generated by GNU Autoconf 2.69 for luajit native 2.0.4. # # Report bugs to . # @@ -580,12 +580,12 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='luajit native' PACKAGE_TARNAME='luajit-native' -PACKAGE_VERSION='2.0.3' -PACKAGE_STRING='luajit native 2.0.3' +PACKAGE_VERSION='2.0.4' +PACKAGE_STRING='luajit native 2.0.4' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' -ac_unique_file="../LuaJIT-2.0.3/src/luajit.h" +ac_unique_file="../LuaJIT-2.0.4/src/luajit.h" # Factoring default headers for most tests. ac_includes_default="\ #include @@ -1286,7 +1286,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures luajit native 2.0.3 to adapt to many kinds of systems. +\`configure' configures luajit native 2.0.4 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1356,7 +1356,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of luajit native 2.0.3:";; + short | recursive ) echo "Configuration of luajit native 2.0.4:";; esac cat <<\_ACEOF @@ -1453,7 +1453,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -luajit native configure 2.0.3 +luajit native configure 2.0.4 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1847,7 +1847,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by luajit native $as_me 2.0.3, which was +It was created by luajit native $as_me 2.0.4, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3770,7 +3770,7 @@ fi # Define the identity of the package. PACKAGE='luajit-native' - VERSION='2.0.3' + VERSION='2.0.4' cat >>confdefs.h <<_ACEOF @@ -3925,13 +3925,13 @@ else if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_cflags="-Wimplicit -Wreturn-type" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement" ;; #( *) : ;; esac case `$CC -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -3943,7 +3943,7 @@ esac kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition" ;; #( *) : ;; @@ -5304,7 +5304,7 @@ esac -LUAJIT_TREE=../LuaJIT-2.0.3 +LUAJIT_TREE=../LuaJIT-2.0.4 ac_config_headers="$ac_config_headers config.h" @@ -5851,7 +5851,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by luajit native $as_me 2.0.3, which was +This file was extended by luajit native $as_me 2.0.4, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5917,7 +5917,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -luajit native config.status 2.0.3 +luajit native config.status 2.0.4 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/source/libs/luajit/version.ac b/source/libs/luajit/version.ac index 754170bc4..562fb72ce 100644 --- a/source/libs/luajit/version.ac +++ b/source/libs/luajit/version.ac @@ -1,5 +1,5 @@ dnl -dnl Copyright (C) 2014 Peter Breitenlohner +dnl Copyright (C) 2014, 2015 Peter Breitenlohner dnl dnl This file is free software; the copyright holder dnl gives unlimited permission to copy and/or distribute it, @@ -8,4 +8,4 @@ dnl dnl -------------------------------------------------------- dnl dnl m4-include this file to define the current luajit version -m4_define([luajit_version], [2.0.3]) +m4_define([luajit_version], [2.0.4]) diff --git a/source/libs/mpfr/configure b/source/libs/mpfr/configure index 57483f995..f50b1fcc4 100755 --- a/source/libs/mpfr/configure +++ b/source/libs/mpfr/configure @@ -4016,13 +4016,13 @@ else if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_cflags="-Wimplicit -Wreturn-type" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement" ;; #( *) : ;; esac case `$CC -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -4034,7 +4034,7 @@ esac kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition" ;; #( *) : ;; diff --git a/source/libs/pixman/configure b/source/libs/pixman/configure index 68f3b9aa1..85eac9cc4 100755 --- a/source/libs/pixman/configure +++ b/source/libs/pixman/configure @@ -4030,13 +4030,13 @@ else if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_cflags="-Wimplicit -Wreturn-type" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement" ;; #( *) : ;; esac case `$CC -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -4048,7 +4048,7 @@ esac kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition" ;; #( *) : ;; diff --git a/source/libs/poppler/ChangeLog b/source/libs/poppler/ChangeLog index 87452a232..13ddda135 100644 --- a/source/libs/poppler/ChangeLog +++ b/source/libs/poppler/ChangeLog @@ -1,3 +1,8 @@ +2015-06-12 Peter Breitenlohner + + Import poppler-0.33.0. + * version.ac: Adjust. + 2015-03-08 Peter Breitenlohner Import poppler-0.32.0. diff --git a/source/libs/poppler/Makefile.in b/source/libs/poppler/Makefile.in index 167d0fad5..ebc4a6bdc 100644 --- a/source/libs/poppler/Makefile.in +++ b/source/libs/poppler/Makefile.in @@ -276,7 +276,7 @@ am__DIST_COMMON = $(srcdir)/../../am/dist_hook.am \ $(top_srcdir)/../../build-aux/depcomp \ $(top_srcdir)/../../build-aux/install-sh \ $(top_srcdir)/../../build-aux/missing \ - $(top_srcdir)/poppler-0.32.0/poppler/poppler-config.h.in \ + $(top_srcdir)/poppler-0.33.0/poppler/poppler-config.h.in \ ../../build-aux/compile ../../build-aux/config.guess \ ../../build-aux/config.sub ../../build-aux/depcomp \ ../../build-aux/install-sh ../../build-aux/ltmain.sh \ @@ -597,7 +597,7 @@ poppler-config.h: stamp-h2 @test -f $@ || rm -f stamp-h2 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h2 -stamp-h2: $(top_srcdir)/poppler-0.32.0/poppler/poppler-config.h.in $(top_builddir)/config.status +stamp-h2: $(top_srcdir)/poppler-0.33.0/poppler/poppler-config.h.in $(top_builddir)/config.status @rm -f stamp-h2 cd $(top_builddir) && $(SHELL) ./config.status poppler-config.h diff --git a/source/libs/poppler/configure b/source/libs/poppler/configure index c9ec0cfea..362916290 100755 --- a/source/libs/poppler/configure +++ b/source/libs/poppler/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for poppler (TeX Live) 0.32.0. +# Generated by GNU Autoconf 2.69 for poppler (TeX Live) 0.33.0. # # Report bugs to . # @@ -580,12 +580,12 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='poppler (TeX Live)' PACKAGE_TARNAME='poppler--tex-live-' -PACKAGE_VERSION='0.32.0' -PACKAGE_STRING='poppler (TeX Live) 0.32.0' +PACKAGE_VERSION='0.33.0' +PACKAGE_STRING='poppler (TeX Live) 0.33.0' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' -ac_unique_file="poppler-0.32.0/poppler/Array.cc" +ac_unique_file="poppler-0.33.0/poppler/Array.cc" # Factoring default headers for most tests. ac_includes_default="\ #include @@ -1306,7 +1306,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures poppler (TeX Live) 0.32.0 to adapt to many kinds of systems. +\`configure' configures poppler (TeX Live) 0.33.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1373,7 +1373,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of poppler (TeX Live) 0.32.0:";; + short | recursive ) echo "Configuration of poppler (TeX Live) 0.33.0:";; esac cat <<\_ACEOF @@ -1486,7 +1486,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -poppler (TeX Live) configure 0.32.0 +poppler (TeX Live) configure 0.33.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2076,7 +2076,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by poppler (TeX Live) $as_me 0.32.0, which was +It was created by poppler (TeX Live) $as_me 0.33.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3999,7 +3999,7 @@ fi # Define the identity of the package. PACKAGE='poppler--tex-live-' - VERSION='0.32.0' + VERSION='0.33.0' # Some tools Automake needs. @@ -4145,13 +4145,13 @@ else if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_cflags="-Wimplicit -Wreturn-type" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement" ;; #( *) : ;; esac case `$CC -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -4163,7 +4163,7 @@ esac kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition" ;; #( *) : ;; @@ -5318,7 +5318,7 @@ if test "x$enable_compiler_warnings" != xno; then ;; esac case `$CXX -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cxxflags="$kpse_cv_warning_cxxflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -6573,12 +6573,12 @@ fi ac_config_headers="$ac_config_headers config.h" -ac_config_headers="$ac_config_headers poppler-config.h:poppler-0.32.0/poppler/poppler-config.h.in" +ac_config_headers="$ac_config_headers poppler-config.h:poppler-0.33.0/poppler/poppler-config.h.in" cat >>confdefs.h <<_ACEOF -#define POPPLER_VERSION "0.32.0" +#define POPPLER_VERSION "0.33.0" _ACEOF @@ -6712,7 +6712,7 @@ fi $as_echo "#define ENABLE_ZLIB 1" >>confdefs.h -POPPLER_TREE=poppler-0.32.0 +POPPLER_TREE=poppler-0.33.0 ac_config_files="$ac_config_files Makefile include/Makefile include/goo/Makefile include/fofi/Makefile" @@ -7272,7 +7272,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by poppler (TeX Live) $as_me 0.32.0, which was +This file was extended by poppler (TeX Live) $as_me 0.33.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -7338,7 +7338,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -poppler (TeX Live) config.status 0.32.0 +poppler (TeX Live) config.status 0.33.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -7469,7 +7469,7 @@ do case $ac_config_target in "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; - "poppler-config.h") CONFIG_HEADERS="$CONFIG_HEADERS poppler-config.h:poppler-0.32.0/poppler/poppler-config.h.in" ;; + "poppler-config.h") CONFIG_HEADERS="$CONFIG_HEADERS poppler-config.h:poppler-0.33.0/poppler/poppler-config.h.in" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;; "include/goo/Makefile") CONFIG_FILES="$CONFIG_FILES include/goo/Makefile" ;; diff --git a/source/libs/poppler/poppler-0.32.0-PATCHES/ChangeLog b/source/libs/poppler/poppler-0.32.0-PATCHES/ChangeLog deleted file mode 100755 index 3c45002c3..000000000 --- a/source/libs/poppler/poppler-0.32.0-PATCHES/ChangeLog +++ /dev/null @@ -1,256 +0,0 @@ -2015-03-08 Peter Breitenlohner - - Imported poppler-0.32.0 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - -2015-02-06 Peter Breitenlohner - - Imported poppler-0.31.0 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - -2015-01-07 Peter Breitenlohner - - Imported poppler-0.30.0 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - -2014-12-05 Peter Breitenlohner - - Imported poppler-0.29.0 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - -2014-11-04 Peter Breitenlohner - - Imported poppler-0.28.0 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - * patch-10-UTF-16BE (removed): Included upstream. - -2014-10-08 Peter Breitenlohner - - * patch-10-UTF-16BE (new): Backport from poppler git - (submitted by Luigi Scarso ). - -2014-09-29 Peter Breitenlohner - - Imported poppler-0.26.5 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - -2014-08-22 Peter Breitenlohner - - Imported poppler-0.26.4 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - -2014-07-21 Peter Breitenlohner - - Imported poppler-0.26.3 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - -2014-06-20 Peter Breitenlohner - - Imported poppler-0.26.2 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - -2014-05-24 Peter Breitenlohner - - Imported poppler-0.26.1 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - -2014-05-19 Peter Breitenlohner - - Imported poppler-0.26.0 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - - * patch-03-NOMINMAX (removed): Now included upstream. - -2014-03-27 Peter Breitenlohner - - Imported poppler-0.25.2 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - - * patch-03-NOMINMAX (new): Avoid to redefine NOMINMAX. - -2014-01-03 Peter Breitenlohner - - Imported poppler-0.25.1 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - -2013-12-12 Peter Breitenlohner - - Imported poppler-0.25.0 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - -2013-12-02 Peter Breitenlohner - - Imported poppler-0.24.4 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - -2013-10-28 Peter Breitenlohner - - Imported poppler-0.24.3 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - -2013-09-30 Peter Breitenlohner - - Imported poppler-0.24.2 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - -2013-09-10 Peter Breitenlohner - - Imported poppler-0.24.1 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - -2013-07-30 Peter Breitenlohner - - Imported poppler-0.24.0 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - -2013-07-19 Peter Breitenlohner - - Imported poppler-0.23.4 source tree from: - http://poppler.freedesktop.org/ - - * patch-02-LLONG_MAX: Adapted. - -2013-07-02 Peter Breitenlohner - - Imported poppler-0.23.3 source tree from: - http://poppler.freedesktop.org/ - - * patch-01-MINGW_PRINTF_FORMAT (removed): Now included upstream. - * patch-02-LLONG_MAX: Adapted. - -2013-06-18 Peter Breitenlohner - - Imported poppler-0.23.2 source tree from: - http://poppler.freedesktop.org/ - - * patch-01-disable-jpeg (removed): Now included upstream. - * patch-02-warnings (removed): Obsoleted by gcc-4.6. - - * patch-01-MINGW_PRINTF_FORMAT (new): MinGW32 may not define - __MINGW_PRINTF_FORMAT (and __USE_MINGW_ANSI_STDIO could be 0). - * patch-02-LLONG_MAX (new): If necessary define LLONG_MAX etc. - -2013-03-12 Peter Breitenlohner - - Imported poppler-0.22.2 source tree from: - http://poppler.freedesktop.org/ - * patch-02-warnings: Adapted. - - * patch-01-disable-jpeg (new): We build without libjpeg. - -2012-12-31 Peter Breitenlohner - - Imported poppler-0.22.0 source tree from: - http://poppler.freedesktop.org/ - * patch-02-warnings: Adapted. - -2012-10-15 Peter Breitenlohner - - Imported poppler-0.21.0 source tree from: - http://poppler.freedesktop.org/ - * patch-02-warnings: Adapted. - -2012-07-11 Peter Breitenlohner - - Imported poppler-0.20.2 source tree from: - http://poppler.freedesktop.org/ - * patch-02-warnings: Adapted. - -2012-05-11 Peter Breitenlohner - - Imported poppler-0.20.0 source tree from: - http://poppler.freedesktop.org/ - * patch-01-missing-param (removed): Obsolete. - * patch-02-warnings: Adapted. - -2012-05-09 Peter Breitenlohner - - Imported poppler-0.19.4 source tree from: - http://poppler.freedesktop.org/ - * patch-03-POPPLER_VERSION (removed): Obsolete. - * patch-01-missing-param (new): Bug fix, missing new func param. - * patch-02-warnings: Adapted. - -2012-02-23 Peter Breitenlohner - - Imported poppler-0.18.4 source tree from: - http://poppler.freedesktop.org/ - * patch-01-PDF_PARSER_ONLY (removed): Obsolete. - * patch-0[23]-*: Adapted. - -2011-10-18 Peter Breitenlohner - - * patch-04-mingw (removed): Instead add `-lgdi32'. - -2011-10-11 Peter Breitenlohner - - * patch-04-mingw (new): Split off ... - * patch-01-PDF_PARSER_ONLY: ... from here. - -2011-10-10 Peter Breitenlohner - - * patch-03-POPPLER_VERSION: Reorg definition of POPPLER_VERSION. - -2011-10-08 Peter Breitenlohner - - Imported poppler-0.18.0 source tree from: - http://poppler.freedesktop.org/ - * patch-0[123]-*: Adapted. - -2011-04-14 Peter Breitenlohner - - * patch-01-PDF_PARSER_ONLY: Fix PDF_PARSER_ONLY for MinGW. - - * patch-03-POPPLER_VERSION (new): #define POPPLER_VERSION. - -2011-04-12 Peter Breitenlohner - - * patch-02-warnings (new): - poppler/Movie.cc: Cast -1 to Gulong. - goo/PNGWriter.h: Add newline at end of file. - -2011-04-12 Taco Hoekwater - - Imported poppler-0.12.4 source tree from: - http://poppler.freedesktop.org/ - - * patch-01-PDF_PARSER_ONLY (new): Implement PDF_PARSER_ONLY. - diff --git a/source/libs/poppler/poppler-0.32.0-PATCHES/TL-Changes b/source/libs/poppler/poppler-0.32.0-PATCHES/TL-Changes deleted file mode 100755 index d1de678e4..000000000 --- a/source/libs/poppler/poppler-0.32.0-PATCHES/TL-Changes +++ /dev/null @@ -1,30 +0,0 @@ -Changes applied to the poppler-0.32.0 tree as obtained from: - http://poppler.freedesktop.org/ - -Removed: - Makefile.in - aclocal.m4 - compile - config.guess - config.sub - configure - depcomp - install-sh - ltmain.sh - missing - test-driver - fofi/Makefile.in - goo/Makefile.in - poppler/Makefile.in - splash/Makefile.in - -Removed unused dirs: - cmake - cpp - glib - m4 - qt4 - qt5 - test - utils - diff --git a/source/libs/poppler/poppler-0.32.0-PATCHES/patch-02-LLONG_MAX b/source/libs/poppler/poppler-0.32.0-PATCHES/patch-02-LLONG_MAX deleted file mode 100755 index 8885d6711..000000000 --- a/source/libs/poppler/poppler-0.32.0-PATCHES/patch-02-LLONG_MAX +++ /dev/null @@ -1,25 +0,0 @@ -diff -ur poppler-0.32.0.orig/goo/GooString.h poppler-0.32.0/goo/GooString.h ---- poppler-0.32.0.orig/goo/GooString.h 2014-10-07 22:41:15.000000000 +0200 -+++ poppler-0.32.0/goo/GooString.h 2014-11-04 10:20:40.567904859 +0100 -@@ -34,6 +34,21 @@ - #endif - - #include // for LLONG_MAX and ULLONG_MAX -+ -+/* and/or the compiler may or may not define these. */ -+/* Minimum and maximum values a `signed long long int' can hold. */ -+#ifndef LLONG_MAX -+# define LLONG_MAX 9223372036854775807LL -+#endif -+#ifndef LLONG_MIN -+# define LLONG_MIN (-LLONG_MAX - 1LL) -+#endif -+ -+/* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */ -+#ifndef ULLONG_MAX -+# define ULLONG_MAX 18446744073709551615ULL -+#endif -+ - #include - #include // for NULL - #include "gtypes.h" diff --git a/source/libs/poppler/poppler-0.32.0/CMakeLists.txt b/source/libs/poppler/poppler-0.32.0/CMakeLists.txt deleted file mode 100755 index 301760cfd..000000000 --- a/source/libs/poppler/poppler-0.32.0/CMakeLists.txt +++ /dev/null @@ -1,735 +0,0 @@ -project(poppler) - -cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR) - -set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) - -include(PopplerDefaults) -include(PopplerMacros) -include(MacroOptionalFindPackage) -find_package(PkgConfig) -include(MacroEnsureVersion) -include(MacroBoolTo01) -find_package(Threads) -include(TestBigEndian) -test_big_endian(WORDS_BIGENDIAN) -include(CheckFileOffsetBits) -CHECK_FILE_OFFSET_BITS() - -find_package (ECM 1.6.0 QUIET NO_MODULE) -if (ECM_FOUND) - include("${ECM_MODULE_DIR}/ECMEnableSanitizers.cmake") -endif() - -set(POPPLER_MAJOR_VERSION "0") -set(POPPLER_MINOR_VERSION "32") -set(POPPLER_MICRO_VERSION "0") -set(POPPLER_VERSION "${POPPLER_MAJOR_VERSION}.${POPPLER_MINOR_VERSION}.${POPPLER_MICRO_VERSION}") - -# command line switches -option(ENABLE_XPDF_HEADERS "Install unsupported xpdf headers." OFF) -option(BUILD_GTK_TESTS "Whether compile the GTK+ test programs." ON) -option(BUILD_QT4_TESTS "Whether compile the Qt4 test programs." ON) -option(BUILD_QT5_TESTS "Whether compile the Qt5 test programs." ON) -option(BUILD_CPP_TESTS "Whether compile the CPP test programs." ON) -option(ENABLE_SPLASH "Build the Splash graphics backend." ON) -option(ENABLE_UTILS "Compile poppler command line utils." ON) -option(ENABLE_CPP "Compile poppler cpp wrapper." ON) -set(ENABLE_LIBOPENJPEG "auto" CACHE STRING "Use libopenjpeg for JPX streams. Possible values: auto, openjpeg1, openjpeg2. 'auto' prefers openjpeg1 over openjpeg2 if both are available. Unset to not use openjpeg.") -set(ENABLE_CMS "auto" CACHE STRING "Use color management system. Possible values: auto, lcms1, lcms2. 'auto' prefers lcms2 over lcms1 if both are available. Unset to disable color management system.") -option(ENABLE_LIBCURL "Build libcurl based HTTP support." OFF) -option(ENABLE_ZLIB "Build with zlib (not totally safe)." OFF) -option(USE_FIXEDPOINT "Use fixed point arithmetic in the Splash backend" OFF) -option(USE_FLOAT "Use single precision arithmetic in the Splash backend" OFF) -if(WIN32) - option(ENABLE_RELOCATABLE "Do not hardcode the poppler library location (on Windows)." ON) -else(WIN32) - set(ENABLE_RELOCATABLE OFF) -endif(WIN32) - -set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)") - -set(TESTDATADIR "${CMAKE_SOURCE_DIR}/../test" CACHE STRING "Specify test data dir.") -if(NOT (EXISTS ${TESTDATADIR} AND EXISTS ${TESTDATADIR}/test-poppler.c)) - message(WARNING " - No test data found in $testdatadir. - You will not be able to run 'make test' successfully. - - The test data is not included in the source packages - and is also not part of the main git repository. Instead, - you can checkout the test data from its own git - repository with: - - git clone git://git.freedesktop.org/git/poppler/test - - You should checkout the test data as a sibling of your - poppler source folder or specify the location of your - checkout with -DTESTDATADIR=/path/to/checkoutdir/test. - ") -endif() - -if(WIN32) - set(_default_fontconfiguration "win32") -else(WIN32) - set(_default_fontconfiguration "fontconfig") -endif(WIN32) -set(FONT_CONFIGURATION "${_default_fontconfiguration}" CACHE STRING "The font configuration backend (win32|fontconfig).") -string(TOLOWER "${FONT_CONFIGURATION}" font_configuration) -set(WITH_FONTCONFIGURATION_WIN32 OFF) -set(WITH_FONTCONFIGURATION_FONTCONFIG OFF) -if(font_configuration STREQUAL "win32") - set(WITH_FONTCONFIGURATION_WIN32 ON) -elseif(font_configuration STREQUAL "fontconfig") - set(WITH_FONTCONFIGURATION_FONTCONFIG ON) -else(font_configuration STREQUAL "win32") - message(FATAL_ERROR "Invalid font configuration setting: ${FONT_CONFIGURATION}") -endif(font_configuration STREQUAL "win32") - -# Enable these unconditionally. -set(MULTITHREADED ON) -set(OPI_SUPPORT ON) -set(TEXTOUT_WORD_LIST ON) - -# setting the minimum required versions for some components -set(QT4_MIN_VERSION "4.7.0") -set(CAIRO_VERSION "1.10.0") -set(GLIB_REQUIRED "2.18") - -macro_bool_to_01(ENABLE_SPLASH HAVE_SPLASH) -find_package(Freetype REQUIRED) -if(WITH_FONTCONFIGURATION_FONTCONFIG) - find_package(Fontconfig REQUIRED) -endif(WITH_FONTCONFIGURATION_FONTCONFIG) -macro_optional_find_package(JPEG) -macro_optional_find_package(PNG) -macro_optional_find_package(TIFF) -if(JPEG_FOUND) - set(ENABLE_LIBJPEG ${JPEG_FOUND}) -endif(JPEG_FOUND) -macro_optional_find_package(Qt4) -if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.8.7) - find_package(Qt5Core) - find_package(Qt5Gui) - find_package(Qt5Xml) - find_package(Qt5Widgets) - find_package(Qt5Test) - if (Qt5Core_FOUND AND Qt5Gui_FOUND AND Qt5Xml_FOUND AND Qt5Widgets_FOUND AND Qt5Test_FOUND) - set(QT5_FOUND true) - else () - message("-- Package Qt5Core or Qt5Gui or Qt5Xml or Qt5Widgets or Qt5Test not found") - set(QT5_FOUND false) - endif() -else(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.8.7) - set(QT5_FOUND false) - message("-- CMake >= 2.8.8 is needed to enable Qt5") -endif(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.8.7) - -macro_optional_find_package(Cairo ${CAIRO_VERSION}) -if(CAIRO_FOUND) - set(HAVE_CAIRO ${CAIRO_FOUND}) - set(CAIRO_FEATURE "#define POPPLER_HAS_CAIRO 1") - set(CAIRO_REQ "cairo") - set(POPPLER_GLIB_DISABLE_DEPRECATED "") - set(POPPLER_GLIB_DISABLE_SINGLE_INCLUDES "") - macro_optional_find_package(GLIB) - if(GLIB_FOUND) - set(ENABLE_GLIB ON) - # Check for introspection - macro_optional_find_package(GObjectIntrospection 0.9.12) - set(HAVE_INTROSPECTION ${INTROSPECTION_FOUND}) - set(POPPLER_GLIB_DISABLE_DEPRECATED "${POPPLER_GLIB_DISABLE_DEPRECATED} -DG_DISABLE_DEPRECATED") - set(POPPLER_GLIB_DISABLE_SINGLE_INCLUDES "${POPPLER_GLIB_DISABLE_SINGLE_INCLUDES} -DG_DISABLE_SINGLE_INCLUDES") - macro_optional_find_package(GTK) - endif(GLIB_FOUND) -else(CAIRO_FOUND) - set(CAIRO_FEATURE "#undef POPPLER_HAS_CAIRO") -endif(CAIRO_FOUND) -if(ENABLE_CPP) - macro_optional_find_package(Iconv) - set(ENABLE_CPP ${ICONV_FOUND}) - set(HAVE_ICONV ${ICONV_FOUND}) -endif(ENABLE_CPP) -if(ENABLE_ZLIB) - find_package(ZLIB) - if(ZLIB_FOUND) - set(HAVE_LIBZ ${ZLIB_FOUND}) - endif(ZLIB_FOUND) - set(ENABLE_ZLIB ${ZLIB_FOUND}) -endif(ENABLE_ZLIB) -set(USE_OPENJPEG1 FALSE) -set(USE_OPENJPEG2 FALSE) -if(ENABLE_LIBOPENJPEG STREQUAL "auto") - find_package(LIBOPENJPEG) - set(USE_OPENJPEG1 ${LIBOPENJPEG_FOUND}) - set(WITH_OPENJPEG ${LIBOPENJPEG_FOUND}) - if(NOT LIBOPENJPEG_FOUND) - find_package(LIBOPENJPEG2) - set(USE_OPENJPEG2 ${LIBOPENJPEG2_FOUND}) - set(WITH_OPENJPEG ${LIBOPENJPEG2_FOUND}) - endif() -elseif(ENABLE_LIBOPENJPEG STREQUAL "openjpeg1") - find_package(LIBOPENJPEG) - set(USE_OPENJPEG1 ${LIBOPENJPEG_FOUND}) - set(WITH_OPENJPEG ${LIBOPENJPEG_FOUND}) -elseif(ENABLE_LIBOPENJPEG STREQUAL "openjpeg2") - find_package(LIBOPENJPEG2) - set(USE_OPENJPEG2 ${LIBOPENJPEG2_FOUND}) - set(WITH_OPENJPEG ${LIBOPENJPEG2_FOUND}) -endif() -if(ENABLE_CMS STREQUAL "auto") - find_package(LCMS2) - set(USE_CMS ${LCMS2_FOUND}) - if(NOT LCMS2_FOUND) - find_package(LCMS) - set(USE_CMS ${LCMS_FOUND}) - set(USE_LCMS1 ${LCMS_FOUND}) - endif(NOT LCMS2_FOUND) -elseif(ENABLE_CMS STREQUAL "lcms1") - find_package(LCMS) - set(USE_CMS ${LCMS_FOUND}) - set(USE_LCMS1 ${LCMS_FOUND}) -elseif(ENABLE_CMS STREQUAL "lcms2") - find_package(LCMS2) - set(USE_CMS ${LCMS2_FOUND}) -endif() -if(ENABLE_LIBCURL) - find_package(CURL) - include_directories(${CURL_INCLUDE_DIR}) - set(POPPLER_HAS_CURL_SUPPORT ON) -endif(ENABLE_LIBCURL) - -add_definitions(-DHAVE_CONFIG_H=1) -if(MINGW) - # Use mingw's ansi stdio extensions - add_definitions(-D__USE_MINGW_ANSI_STDIO=1) -endif(MINGW) -if(FONTCONFIG_FOUND) - add_definitions(${FONTCONFIG_DEFINITIONS}) - include_directories(${FONTCONFIG_INCLUDE_DIR}) -endif(FONTCONFIG_FOUND) -if(WITH_FONTCONFIGURATION_WIN32) - if(MINGW) - # Set the minimum required Internet Explorer version to 5.0 - add_definitions(-D_WIN32_IE=0x0500) - endif(MINGW) -endif(WITH_FONTCONFIGURATION_WIN32) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/fofi - ${CMAKE_CURRENT_SOURCE_DIR}/goo - ${CMAKE_CURRENT_SOURCE_DIR}/poppler - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/poppler - ${FREETYPE_INCLUDE_DIRS} -) -set(HAVE_FREETYPE_H ON) -if(CMAKE_USE_PTHREADS_INIT) - set(HAVE_PTHREAD ON) -endif(CMAKE_USE_PTHREADS_INIT) - -if(ENABLE_ZLIB) - include_directories(${ZLIB_INCLUDE_DIR}) -endif(ENABLE_ZLIB) -if(JPEG_FOUND) - include_directories(${JPEG_INCLUDE_DIR}) - set(ENABLE_LIBJPEG ON) -endif(JPEG_FOUND) -if(PNG_FOUND) - include_directories(${PNG_INCLUDE_DIR}) - set(ENABLE_LIBPNG ON) -endif(PNG_FOUND) -if(TIFF_FOUND) - include_directories(${TIFF_INCLUDE_DIR}) - set(ENABLE_LIBTIFF ON) -endif(TIFF_FOUND) -if(LIBOPENJPEG_FOUND) - include_directories(${LIBOPENJPEG_INCLUDE_DIR}) -endif(LIBOPENJPEG_FOUND) -if(LIBOPENJPEG2_FOUND) - include_directories(${LIBOPENJPEG2_INCLUDE_DIRS}) -endif() -if(LCMS_FOUND) - include_directories(${LCMS_INCLUDE_DIR}) -endif(LCMS_FOUND) -if(LCMS2_FOUND) - include_directories(${LCMS2_INCLUDE_DIR}) -endif(LCMS2_FOUND) - -# Recent versions of poppler-data install a .pc file. -# Use it to determine the encoding data path, if available. -# Default to the same prefix otherwise. -pkg_check_modules(POPPLER_DATA poppler-data) -if(POPPLER_DATA_FOUND) - execute_process(COMMAND "${PKG_CONFIG_EXECUTABLE}" --variable=poppler_datadir poppler-data - RESULT_VARIABLE _result_var - OUTPUT_VARIABLE _output_var OUTPUT_STRIP_TRAILING_WHITESPACE) - if(_result_var STREQUAL "0" AND NOT _output_var STREQUAL "") - set(POPPLER_DATADIR "${_output_var}") - endif(_result_var STREQUAL "0" AND NOT _output_var STREQUAL "") -endif(POPPLER_DATA_FOUND) -if(NOT DEFINED POPPLER_DATADIR) - set(POPPLER_DATADIR "${CMAKE_INSTALL_PREFIX}/share/poppler") -endif(NOT DEFINED POPPLER_DATADIR) - -if(DEFINED COMPILE_WARNINGS) -else(DEFINED COMPILE_WARNINGS) - set(COMPILE_WARNINGS "yes") -endif(DEFINED COMPILE_WARNINGS) -string(TOLOWER "${COMPILE_WARNINGS}" _comp_warnings) -if(_comp_warnings STREQUAL "no") - set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS_NO} ${CMAKE_CXX_FLAGS}") -endif(_comp_warnings STREQUAL "no") -if(_comp_warnings STREQUAL "yes") - set(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS_YES} ${CMAKE_CXX_FLAGS}") -endif(_comp_warnings STREQUAL "yes") -if(_comp_warnings STREQUAL "kde") - set(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS_KDE} ${CMAKE_CXX_FLAGS}") -endif(_comp_warnings STREQUAL "kde") - - -include(ConfigureChecks.cmake) -configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) -configure_file(poppler/poppler-config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/poppler/poppler-config.h) - - -set(poppler_SRCS - goo/gfile.cc - goo/gmempp.cc - goo/GooHash.cc - goo/GooList.cc - goo/GooTimer.cc - goo/GooString.cc - goo/gmem.cc - goo/FixedPoint.cc - goo/NetPBMWriter.cc - goo/PNGWriter.cc - goo/TiffWriter.cc - goo/JpegWriter.cc - goo/ImgWriter.cc - goo/gstrtod.cc - goo/grandom.cc - fofi/FoFiBase.cc - fofi/FoFiEncodings.cc - fofi/FoFiTrueType.cc - fofi/FoFiType1.cc - fofi/FoFiType1C.cc - fofi/FoFiIdentifier.cc - poppler/Annot.cc - poppler/Array.cc - poppler/BuiltinFont.cc - poppler/BuiltinFontTables.cc - poppler/CachedFile.cc - poppler/Catalog.cc - poppler/CharCodeToUnicode.cc - poppler/CMap.cc - poppler/DateInfo.cc - poppler/Decrypt.cc - poppler/Dict.cc - poppler/Error.cc - poppler/FileSpec.cc - poppler/FontEncodingTables.cc - poppler/Form.cc - poppler/FontInfo.cc - poppler/Function.cc - poppler/Gfx.cc - poppler/GfxFont.cc - poppler/GfxState.cc - poppler/GlobalParams.cc - poppler/Hints.cc - poppler/JArithmeticDecoder.cc - poppler/JBIG2Stream.cc - poppler/Lexer.cc - poppler/Link.cc - poppler/Linearization.cc - poppler/LocalPDFDocBuilder.cc - poppler/MarkedContentOutputDev.cc - poppler/NameToCharCode.cc - poppler/Object.cc - poppler/OptionalContent.cc - poppler/Outline.cc - poppler/OutputDev.cc - poppler/Page.cc - poppler/PageTransition.cc - poppler/Parser.cc - poppler/PDFDoc.cc - poppler/PDFDocEncoding.cc - poppler/PDFDocFactory.cc - poppler/PopplerCache.cc - poppler/ProfileData.cc - poppler/PreScanOutputDev.cc - poppler/PSTokenizer.cc - poppler/Stream.cc - poppler/StructTreeRoot.cc - poppler/StructElement.cc - poppler/strtok_r.cpp - poppler/UnicodeMap.cc - poppler/UnicodeTypeTable.cc - poppler/UTF.cc - poppler/XRef.cc - poppler/PSOutputDev.cc - poppler/TextOutputDev.cc - poppler/PageLabelInfo.cc - poppler/SecurityHandler.cc - poppler/StdinCachedFile.cc - poppler/StdinPDFDocBuilder.cc - poppler/Sound.cc - poppler/ViewerPreferences.cc - poppler/XpdfPluginAPI.cc - poppler/Movie.cc - poppler/Rendition.cc -) -set(poppler_LIBS ${FREETYPE_LIBRARIES}) -if(ENABLE_SPLASH) - set(poppler_SRCS ${poppler_SRCS} - poppler/SplashOutputDev.cc - splash/Splash.cc - splash/SplashBitmap.cc - splash/SplashClip.cc - splash/SplashFTFont.cc - splash/SplashFTFontEngine.cc - splash/SplashFTFontFile.cc - splash/SplashFont.cc - splash/SplashFontEngine.cc - splash/SplashFontFile.cc - splash/SplashFontFileID.cc - splash/SplashPath.cc - splash/SplashPattern.cc - splash/SplashScreen.cc - splash/SplashState.cc - splash/SplashT1Font.cc - splash/SplashT1FontEngine.cc - splash/SplashT1FontFile.cc - splash/SplashXPath.cc - splash/SplashXPathScanner.cc - ) -endif(ENABLE_SPLASH) -if(FONTCONFIG_FOUND) - set(poppler_LIBS ${poppler_LIBS} ${FONTCONFIG_LIBRARIES}) -endif(FONTCONFIG_FOUND) -if(JPEG_FOUND) - set(poppler_SRCS ${poppler_SRCS} - poppler/DCTStream.cc - ) - set(poppler_LIBS ${poppler_LIBS} ${JPEG_LIBRARIES}) -endif(JPEG_FOUND) -if(ENABLE_ZLIB) - set(poppler_SRCS ${poppler_SRCS} - poppler/FlateStream.cc - ) - set(poppler_LIBS ${poppler_LIBS} ${ZLIB_LIBRARIES}) -endif(ENABLE_ZLIB) -if(ENABLE_LIBCURL) - set(poppler_SRCS ${poppler_SRCS} - poppler/CurlCachedFile.cc - poppler/CurlPDFDocBuilder.cc - ) - set(poppler_LIBS ${poppler_LIBS} ${CURL_LIBRARIES}) -endif(ENABLE_LIBCURL) -if(LIBOPENJPEG_FOUND) - set(poppler_SRCS ${poppler_SRCS} - poppler/JPEG2000Stream.cc - ) - set(poppler_LIBS ${poppler_LIBS} ${LIBOPENJPEG_LIBRARIES}) - add_definitions(-DUSE_OPENJPEG1) -elseif (LIBOPENJPEG2_FOUND) - set(poppler_SRCS ${poppler_SRCS} - poppler/JPEG2000Stream.cc - ) - add_definitions(-DUSE_OPENJPEG2) -MESSAGE(${LIBOPENJPEG2_LIBRARIES}) - set(poppler_LIBS ${poppler_LIBS} ${LIBOPENJPEG2_LIBRARIES}) -else () - set(poppler_SRCS ${poppler_SRCS} - poppler/JPXStream.cc - ) -endif() -if(USE_CMS) - if(LCMS_FOUND) - set(poppler_LIBS ${poppler_LIBS} ${LCMS_LIBRARIES}) - endif(LCMS_FOUND) - if(LCMS2_FOUND) - set(poppler_LIBS ${poppler_LIBS} ${LCMS2_LIBRARIES}) - endif(LCMS2_FOUND) -endif(USE_CMS) -if(WIN32) - # gdi32 is needed under win32 - set(poppler_LIBS ${poppler_LIBS} gdi32) -endif(WIN32) -if(PNG_FOUND) - set(poppler_LIBS ${poppler_LIBS} ${PNG_LIBRARIES}) -endif(PNG_FOUND) -if(TIFF_FOUND) - set(poppler_LIBS ${poppler_LIBS} ${TIFF_LIBRARIES}) -endif(TIFF_FOUND) -if(HAVE_PTHREAD) - set(poppler_LIBS ${poppler_LIBS} ${CMAKE_THREAD_LIBS_INIT}) -endif() - -if(MSVC) -add_definitions(-D_CRT_SECURE_NO_WARNINGS) -set(CMAKE_CXX_FLAGS "/Zc:wchar_t- ${CMAKE_CXX_FLAGS}") -add_library(poppler STATIC ${poppler_SRCS}) -else(MSVC) -add_library(poppler SHARED ${poppler_SRCS}) -endif(MSVC) -set_target_properties(poppler PROPERTIES VERSION 51.0.0 SOVERSION 51) -target_link_libraries(poppler ${poppler_LIBS}) -target_link_libraries(poppler LINK_INTERFACE_LIBRARIES "") -install(TARGETS poppler RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) - -if(ENABLE_XPDF_HEADERS) - install(FILES - poppler/Annot.h - poppler/Array.h - poppler/BuiltinFont.h - poppler/BuiltinFontTables.h - poppler/CachedFile.h - poppler/Catalog.h - poppler/CharCodeToUnicode.h - poppler/CMap.h - poppler/DateInfo.h - poppler/Decrypt.h - poppler/Dict.h - poppler/Error.h - poppler/FileSpec.h - poppler/FontEncodingTables.h - poppler/FontInfo.h - poppler/Form.h - poppler/Function.cc - poppler/Function.h - poppler/Gfx.h - poppler/GfxFont.h - poppler/GfxState.h - poppler/GfxState_helpers.h - poppler/GlobalParams.h - poppler/Hints.h - poppler/JArithmeticDecoder.h - poppler/JBIG2Stream.h - poppler/Lexer.h - poppler/Link.h - poppler/Linearization.h - poppler/LocalPDFDocBuilder.h - poppler/MarkedContentOutputDev.h - poppler/Movie.h - poppler/NameToCharCode.h - poppler/Object.h - poppler/OptionalContent.h - poppler/Outline.h - poppler/OutputDev.h - poppler/Page.h - poppler/PageTransition.h - poppler/Parser.h - poppler/PDFDoc.h - poppler/PDFDocBuilder.h - poppler/PDFDocEncoding.h - poppler/PDFDocFactory.h - poppler/PopplerCache.h - poppler/ProfileData.h - poppler/PreScanOutputDev.h - poppler/PSTokenizer.h - poppler/Rendition.h - poppler/Stream-CCITT.h - poppler/Stream.h - poppler/StructElement.h - poppler/StructTreeRoot.h - poppler/UnicodeMap.h - poppler/UnicodeMapTables.h - poppler/UnicodeTypeTable.h - poppler/UnicodeCClassTables.h - poppler/UnicodeCompTables.h - poppler/UnicodeDecompTables.h - poppler/ViewerPreferences.h - poppler/XRef.h - poppler/CharTypes.h - poppler/CompactFontTables.h - poppler/ErrorCodes.h - poppler/NameToUnicodeTable.h - poppler/PSOutputDev.h - poppler/TextOutputDev.h - poppler/SecurityHandler.h - poppler/StdinCachedFile.h - poppler/StdinPDFDocBuilder.h - poppler/UTF.h - poppler/UTF8.h - poppler/XpdfPluginAPI.h - poppler/Sound.h - ${CMAKE_CURRENT_BINARY_DIR}/poppler/poppler-config.h - DESTINATION include/poppler) - install(FILES - goo/GooHash.h - goo/GooList.h - goo/GooTimer.h - goo/GooMutex.h - goo/GooString.h - goo/gtypes.h - goo/gmem.h - goo/gfile.h - goo/FixedPoint.h - goo/ImgWriter.h - goo/GooLikely.h - goo/gstrtod.h - goo/grandom.h - DESTINATION include/poppler/goo) - if(PNG_FOUND) - install(FILES - goo/PNGWriter.h - DESTINATION include/poppler/goo) - endif(PNG_FOUND) - if(TIFF_FOUND) - install(FILES - goo/TiffWriter.h - DESTINATION include/poppler/goo) - endif(TIFF_FOUND) - if(JPEG_FOUND) - install(FILES - goo/JpegWriter.h - DESTINATION include/poppler/goo) - endif(JPEG_FOUND) - install(FILES - fofi/FoFiBase.h - fofi/FoFiEncodings.h - fofi/FoFiTrueType.h - fofi/FoFiType1.h - fofi/FoFiType1C.h - fofi/FoFiIdentifier.h - DESTINATION include/poppler/fofi) - if(ENABLE_LIBCURL) - install(FILES - poppler/CurlCachedFile.h - poppler/CurlPDFDocBuilder.h - DESTINATION include/poppler) - endif(ENABLE_LIBCURL) - if(LIBOPENJPEG_FOUND) - install(FILES - poppler/JPEG2000Stream.h - DESTINATION include/poppler) - elseif(LIBOPENJPEG2_FOUND) - install(FILES - poppler/JPEG2000Stream.h - DESTINATION include/poppler) - else() - install(FILES - poppler/JPXStream.h - DESTINATION include/poppler) - endif() - if(ENABLE_SPLASH) - install(FILES - poppler/SplashOutputDev.h - DESTINATION include/poppler) - install(FILES - splash/Splash.h - splash/SplashBitmap.h - splash/SplashClip.h - splash/SplashErrorCodes.h - splash/SplashFTFont.h - splash/SplashFTFontEngine.h - splash/SplashFTFontFile.h - splash/SplashFont.h - splash/SplashFontEngine.h - splash/SplashFontFile.h - splash/SplashFontFileID.h - splash/SplashGlyphBitmap.h - splash/SplashMath.h - splash/SplashPath.h - splash/SplashPattern.h - splash/SplashScreen.h - splash/SplashState.h - splash/SplashT1Font.h - splash/SplashT1FontEngine.h - splash/SplashT1FontFile.h - splash/SplashTypes.h - splash/SplashXPath.h - splash/SplashXPathScanner.h - DESTINATION include/poppler/splash) - endif(ENABLE_SPLASH) -endif(ENABLE_XPDF_HEADERS) - - -if(ENABLE_UTILS) - add_subdirectory(utils) -endif(ENABLE_UTILS) -if(ENABLE_GLIB) - add_subdirectory(glib) -endif(ENABLE_GLIB) -add_subdirectory(test) -if(QT4_FOUND) - add_subdirectory(qt4) -endif(QT4_FOUND) -if(QT5_FOUND) - add_subdirectory(qt5) -endif(QT5_FOUND) -if(ENABLE_CPP) - add_subdirectory(cpp) -endif(ENABLE_CPP) - -set(PKG_CONFIG_VERSION_0_18 TRUE) -if(PKG_CONFIG_EXECUTABLE) - exec_program(${PKG_CONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _output_VAR) - macro_ensure_version("0.18" "${_output_VAR}" PKG_CONFIG_VERSION_0_18) -endif(PKG_CONFIG_EXECUTABLE) -if(PKG_CONFIG_VERSION_0_18) - set(PC_REQUIRES "") - set(PC_REQUIRES_PRIVATE "Requires.private: poppler = ${POPPLER_VERSION}") -else(PKG_CONFIG_VERSION_0_18) - set(PC_REQUIRES "poppler = ${POPPLER_VERSION}") - set(PC_REQUIRES_PRIVATE "") -endif(PKG_CONFIG_VERSION_0_18) - -poppler_create_install_pkgconfig(poppler.pc lib${LIB_SUFFIX}/pkgconfig) -if(ENABLE_SPLASH) - poppler_create_install_pkgconfig(poppler-splash.pc lib${LIB_SUFFIX}/pkgconfig) -endif(ENABLE_SPLASH) -if(QT4_FOUND) - poppler_create_install_pkgconfig(poppler-qt4.pc lib${LIB_SUFFIX}/pkgconfig) -endif(QT4_FOUND) -if(QT5_FOUND) - poppler_create_install_pkgconfig(poppler-qt5.pc lib${LIB_SUFFIX}/pkgconfig) -endif(QT5_FOUND) -if(ENABLE_GLIB) - poppler_create_install_pkgconfig(poppler-glib.pc lib${LIB_SUFFIX}/pkgconfig) -endif(ENABLE_GLIB) -if(CAIRO_FOUND) - poppler_create_install_pkgconfig(poppler-cairo.pc lib${LIB_SUFFIX}/pkgconfig) -endif(CAIRO_FOUND) -if(ENABLE_CPP) - poppler_create_install_pkgconfig(poppler-cpp.pc lib${LIB_SUFFIX}/pkgconfig) -endif(ENABLE_CPP) - - -message("Building Poppler with support for:") -show_end_message("font configuration" ${font_configuration}) -show_end_message_yesno("splash output" ENABLE_SPLASH) -show_end_message_yesno("cairo output" CAIRO_FOUND) -show_end_message_yesno("qt4 wrapper" QT4_FOUND) -show_end_message_yesno("qt5 wrapper" QT5_FOUND) -show_end_message_yesno("glib wrapper" ENABLE_GLIB) -show_end_message_yesno(" introspection" INTROSPECTION_FOUND) -show_end_message_yesno("cpp wrapper" ENABLE_CPP) -show_end_message("use gtk-doc" "not supported with this CMake build system") -show_end_message_yesno("use libjpeg" ENABLE_LIBJPEG) -show_end_message_yesno("use libpng" ENABLE_LIBPNG) -show_end_message_yesno("use libtiff" ENABLE_LIBTIFF) -show_end_message_yesno("use zlib" ENABLE_ZLIB) -show_end_message_yesno("use curl" ENABLE_LIBCURL) -show_end_message_yesno("use libopenjpeg" WITH_OPENJPEG) -if(USE_OPENJPEG1) - message(" with openjpeg1") -endif() -if(USE_OPENJPEG2) - message(" with openjpeg2") -endif() -show_end_message_yesno("use cms" USE_CMS) -if(LCMS_FOUND) - message(" with lcms1") -endif(LCMS_FOUND) -if(LCMS2_FOUND) - message(" with lcms2") -endif(LCMS2_FOUND) -show_end_message_yesno("command line utils" ENABLE_UTILS) -show_end_message("test data dir" ${TESTDATADIR}) - -if(USE_FIXEDPOINT AND USE_FLOAT) - message("Warning: Single precision and fixed point options should not be enabled at the same time") -endif(USE_FIXEDPOINT AND USE_FLOAT) diff --git a/source/libs/poppler/poppler-0.32.0/ChangeLog b/source/libs/poppler/poppler-0.32.0/ChangeLog deleted file mode 100755 index 1aa109489..000000000 --- a/source/libs/poppler/poppler-0.32.0/ChangeLog +++ /dev/null @@ -1,57375 +0,0 @@ -commit d7cc90a8b60d7e353db6e0acdd0b789485e32972 -Author: Albert Astals Cid -Date: Sat Mar 7 15:04:52 2015 +0100 - - 0.32.0 - - CMakeLists.txt | 4 ++-- - NEWS | 16 ++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - qt5/src/Doxyfile | 2 +- - 7 files changed, 23 insertions(+), 7 deletions(-) - -commit c13297d154ded11721fe7d3abdba459ca628cef8 -Author: Albert Astals Cid -Date: Sat Mar 7 14:58:10 2015 +0100 - - Update (C) - - poppler/SecurityHandler.cc | 2 +- - poppler/SplashOutputDev.cc | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit c909964bff671d5ff0d8eee5f613ded4562f8afd -Author: Albert Astals Cid -Date: Sat Mar 7 14:54:43 2015 +0100 - - Do not assert on broken document - - Bug #89422 - - poppler/SecurityHandler.cc | 14 +++++++++----- - 1 file changed, 9 insertions(+), 5 deletions(-) - -commit 3705fcee0309c50b5fecd563e8e466cbe2c5972b -Author: Thomas Freitag -Date: Fri Mar 6 15:19:58 2015 +0100 - - Fix Wrong colour shown when GouraudTriangleShFill uses a DeviceN - colorspace - - Bug #89182 - - poppler/SplashOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit b7fde1ec83a5fff9bec73becc22e581583a30d43 -Author: Albert Astals Cid -Date: Wed Feb 25 21:51:34 2015 +0100 - - Fix last commit regression - - It seems it actually needs to be pipe->shape and not pipe->usesShape - (i.e. it seems at some point we use pipe->shape with useShape - being false) - Otherwise we had a regression on - eci_altona-test-suite-v2_technical2_x4.pdf - - splash/Splash.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 7980fe868a8ef2ee3315f0bcb606c448d6604039 -Author: William Bader -Date: Wed Feb 25 15:00:33 2015 +0100 - - Fix uninitialized variable in Splash::pipeRun - - Use useShape is actually the guard for shape, so use it in the if - - splash/Splash.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 57b6b78a0831fb31c06fd1bc6e9803de524f9d2d -Author: Thomas Freitag -Date: Tue Feb 24 23:34:57 2015 +0100 - - pdfseparate: use always an unique instance for PDFDoc for savePageAs - - utils/pdfseparate.cc | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -commit 8a30d219df71ead323649ff0dfd4a724b5e7bd18 -Author: William Bader -Date: Sat Feb 21 23:55:10 2015 +0100 - - Fix memcpy introduced in ec956ab8552dbe10fac4e649951042bddc424b7d - - goo/GooString.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ec956ab8552dbe10fac4e649951042bddc424b7d -Author: William Bader -Date: Tue Feb 17 22:55:14 2015 +0100 - - Reduce use of gmalloc() in GooString::appendfv() - - Bug #89096 - - goo/GooString.cc | 18 ++++++++++++++---- - 1 file changed, 14 insertions(+), 4 deletions(-) - -commit 132ef18324f62c1f2a08dcd794b379fadaa4daf5 -Author: Petr Gajdos -Date: Wed Feb 11 19:37:21 2015 +0100 - - Annot BG/BC: Empty Array means no color - - poppler/Annot.cc | 15 +++++++++++++-- - 1 file changed, 13 insertions(+), 2 deletions(-) - -commit bf4aae25a244b1033a2479b9a8f633224f7d5de5 -Author: William Bader -Date: Wed Feb 11 17:35:40 2015 +0100 - - Off by one fix to the previous crash fix - - fofi/FoFiTrueType.cc | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - -commit 97dd46bae5424818ca808c20506d7d96f7b85fb5 -Author: William Bader -Date: Mon Feb 9 22:30:51 2015 +0100 - - pdftops: Add aaRaster and overprint to man file - - utils/pdftops.1 | 9 +++++++++ - 1 file changed, 9 insertions(+) - -commit c114a90063d755639d2b0dbf816690a66b54bee0 -Author: Albert Astals Cid -Date: Sun Feb 8 00:24:11 2015 +0100 - - Fix crash in fuzzed file from Bug #84988 - - poppler/TextOutputDev.cc | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -commit 22895623e6cd2a5923f552421d44cc80cab77dd8 -Author: Albert Astals Cid -Date: Sat Feb 7 22:28:21 2015 +0100 - - Fix malformed file crash from bug #86854 - - poppler/PSOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit cdb7ad95f7c8fbf63ade040d8a07ec96467042fc -Author: Albert Astals Cid -Date: Sat Feb 7 22:21:16 2015 +0100 - - Fix malformed file crash in bug #85243 - - fofi/FoFiTrueType.cc | 15 +++++++++++++-- - 1 file changed, 13 insertions(+), 2 deletions(-) - -commit 6641b935e1fc0c4151a723b6b476d987b8324ed2 -Author: Albert Astals Cid -Date: Sat Feb 7 21:58:23 2015 +0100 - - If ECM is around include the sanitizers module - - This way you can run - cmake -DECM_ENABLE_SANITIZERS='address' - and get an ASAN built poppler - - CMakeLists.txt | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 92e41685dcef538a7fc669ca357ce9f448a8078e -Author: Albert Astals Cid -Date: Sat Feb 7 21:54:39 2015 +0100 - - Fix crash in malformed file from bug #85275 - - poppler/SplashOutputDev.cc | 4 ++-- - splash/Splash.cc | 10 +++++++++- - splash/SplashBitmap.cc | 4 ++-- - 3 files changed, 13 insertions(+), 5 deletions(-) - -commit 9842b3b00492eda21297d5d65f769f77a565f6ac -Author: Aleksei Volkov -Date: Sat Feb 7 20:46:26 2015 +0100 - - No need to check for hmtx, freetype does for us - - Bug #88939 - - fofi/FoFiTrueType.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 4849eb43892640062c485e48ba7a29b5a0cc9587 -Author: William Bader -Date: Sat Feb 7 16:41:53 2015 +0100 - - Make the colorpsace optimization and option and not the default - - Bug #88971 - - poppler/PSOutputDev.cc | 25 ++++++++++++++++--------- - poppler/PSOutputDev.h | 4 ++++ - utils/pdftops.1 | 10 +++++++++- - utils/pdftops.cc | 4 ++++ - 4 files changed, 33 insertions(+), 10 deletions(-) - -commit 8e16e423a718b92514885e771e31048f1ae2a766 -Author: Albert Astals Cid -Date: Thu Feb 5 20:18:13 2015 +0100 - - 0.31.0 - - And copyright updating - - CMakeLists.txt | 4 ++-- - NEWS | 17 +++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/CairoOutputDev.cc | 1 + - poppler/CairoOutputDev.h | 1 + - poppler/JBIG2Stream.cc | 1 + - poppler/JBIG2Stream.h | 1 + - poppler/Makefile.am | 2 +- - poppler/Stream.cc | 1 + - qt4/src/CMakeLists.txt | 2 +- - qt4/src/Doxyfile | 2 +- - qt4/src/Makefile.am | 2 +- - qt5/src/CMakeLists.txt | 2 +- - qt5/src/Doxyfile | 2 +- - qt5/src/Makefile.am | 2 +- - 16 files changed, 33 insertions(+), 11 deletions(-) - -commit f932315e559a7857d9c5642eb04efc0d2b717789 -Author: suzuki toshiya -Date: Tue Jan 20 22:05:29 2015 +1030 - - cairo: support embedding JBIG2 image data - - http://lists.freedesktop.org/archives/poppler/2014-December/011183.html - - poppler/CairoOutputDev.cc | 117 - ++++++++++++++++++++++++++++++++++++++-------- - poppler/CairoOutputDev.h | 3 ++ - poppler/JBIG2Stream.cc | 9 +++- - poppler/JBIG2Stream.h | 4 +- - poppler/Stream.cc | 13 +++++- - 5 files changed, 121 insertions(+), 25 deletions(-) - -commit 78abf540057181b708c546aee421f81a1dd58331 -Author: Adam Reichold -Date: Wed Jan 21 22:30:45 2015 +0100 - - Worlds -> Words - - qt4/src/poppler-page.cc | 4 ++-- - qt4/src/poppler-qt4.h | 2 +- - qt4/tests/check_search.cpp | 4 ++-- - qt5/src/poppler-page.cc | 4 ++-- - qt5/src/poppler-qt5.h | 2 +- - qt5/tests/check_search.cpp | 4 ++-- - 6 files changed, 10 insertions(+), 10 deletions(-) - -commit 027eac4e565576ca2e7042e21426e28abd775d98 -Author: Adam Reichold -Date: Tue Jan 20 00:09:09 2015 +0100 - - Expose whole-words search option in Qt frontends - - qt4/src/poppler-page-private.h | 5 +- - qt4/src/poppler-page.cc | 114 - +++++++++++++++++++++++++------------ - qt4/src/poppler-qt4.h | 44 +++++++++++++- - qt4/tests/check_search.cpp | 112 +++++++++++++++++++++++++++++++----- - qt5/src/poppler-page-private.h | 5 +- - qt5/src/poppler-page.cc | 116 - +++++++++++++++++++++++++------------ - qt5/src/poppler-qt5.h | 46 +++++++++++++-- - qt5/tests/check_search.cpp | 126 - +++++++++++++++++++++++++++++++++-------- - 8 files changed, 447 insertions(+), 121 deletions(-) - -commit 30a0baa353c374165e5f411efc4203746f14a74d -Author: Albert Astals Cid -Date: Sun Jan 18 15:39:53 2015 +0100 - - Move more variables from GlobalParams to PSOutputDev - - poppler/CairoFontEngine.cc | 4 +- - poppler/GfxFont.cc | 15 ++--- - poppler/GfxFont.h | 7 ++- - poppler/GlobalParams.cc | 144 - --------------------------------------------- - poppler/GlobalParams.h | 28 --------- - poppler/PSOutputDev.cc | 121 +++++++++++++++++++------------------ - poppler/PSOutputDev.h | 30 +++++++++- - poppler/SplashOutputDev.cc | 2 +- - qt4/src/ArthurOutputDev.cc | 4 +- - qt5/src/ArthurOutputDev.cc | 4 +- - utils/pdftops.cc | 36 ++++-------- - 11 files changed, 116 insertions(+), 279 deletions(-) - -commit 8fed995c3457d64669ae12901450b7c811599dba -Author: Albert Astals Cid -Date: Sun Jan 18 14:52:53 2015 +0100 - - Forgot to delete this in the previous commit - - poppler/GlobalParams.h | 1 - - 1 file changed, 1 deletion(-) - -commit 4992ff7fa062462507733494827fdad7eaaa95b3 -Author: Albert Astals Cid -Date: Sun Jan 18 13:57:36 2015 +0100 - - Move raster mono and resolution from GlobalParams to PSOutputDev - - poppler/GlobalParams.cc | 32 -------------------------------- - poppler/GlobalParams.h | 7 ------- - poppler/PSOutputDev.cc | 18 +++++++----------- - poppler/PSOutputDev.h | 6 ++++++ - utils/pdftops.cc | 7 ++++--- - 5 files changed, 17 insertions(+), 53 deletions(-) - -commit 54908f675eda96c363528198e8c530921df2f45a -Author: Albert Astals Cid -Date: Sun Jan 18 13:34:45 2015 +0100 - - Move psUncompressPreloadedImages from GlobalParams to PSOutputDev - - It belongs there and PSOutputDev is always created by the external - user - so in case someone wants to set it, it is the same amount of work - to set it in GlobalParams than in PSOutputDev - - poppler/GlobalParams.cc | 16 ---------------- - poppler/GlobalParams.h | 3 --- - poppler/PSOutputDev.cc | 9 +++++---- - poppler/PSOutputDev.h | 2 ++ - 4 files changed, 7 insertions(+), 23 deletions(-) - -commit 136d7aa5e79f153dfcb216c58598e33a8ff16630 -Author: Albert Astals Cid -Date: Sun Jan 18 13:28:26 2015 +0100 - - Remove declared but not defined function - - poppler/GlobalParams.h | 1 - - 1 file changed, 1 deletion(-) - -commit fdba9154d9a176759c765180805e608d4959c34e -Author: Adam Reichold -Date: Fri Jan 16 19:57:59 2015 +0100 - - pdftoppm: parse the flags earlier and only once - - utils/pdftoppm.cc | 42 +++++++++++++++--------------------------- - 1 file changed, 15 insertions(+), 27 deletions(-) - -commit 6b072500b5ac936631be6b29b7d5a591848a18f3 -Author: William Bader -Date: Wed Jan 14 23:28:03 2015 +0100 - - Add rasterization option to pdftops - - Also removes GlobalParams stuff \o/ - - Coded in conjuntion with Albert - - Bug #85934 - - cpp/poppler-page-renderer.cpp | 5 ++-- - poppler/GlobalParams.cc | 58 - ++----------------------------------------- - poppler/GlobalParams.h | 16 +++--------- - poppler/PSOutputDev.cc | 14 +++++------ - poppler/PSOutputDev.h | 5 +++- - poppler/SplashOutputDev.cc | 19 ++++++-------- - poppler/SplashOutputDev.h | 11 +++++--- - qt4/src/poppler-page.cc | 7 +++--- - qt5/src/poppler-page.cc | 7 +++--- - utils/pdftohtml.cc | 9 +++---- - utils/pdftoppm.cc | 49 ++++++++++++++++++++++++++---------- - utils/pdftops.cc | 14 ++++++++++- - 12 files changed, 96 insertions(+), 118 deletions(-) - -commit dc9751e6ac47a708ba6e7a68560bdce6a2e4a010 -Author: Albert Astals Cid -Date: Fri Jan 9 15:50:02 2015 +0100 - - Compile++ - - poppler/GfxState.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit d91876a0c7a936b1f6f461d80131d7586a6c1a5e -Author: Albert Astals Cid -Date: Thu Jan 8 20:13:06 2015 +0100 - - Accept malformed documents whose root is a Page instead of a Pages - - gs and Adobe Reader do it so it's "common" enough - - Bug #88172 - - poppler/Catalog.cc | 37 ++++++++++++++++++++++++++++++++----- - 1 file changed, 32 insertions(+), 5 deletions(-) - -commit 7ce86b9be058408eb567d8d0b9747853a66c116f -Author: Albert Astals Cid -Date: Thu Jan 8 17:35:28 2015 +0100 - - Remove assert in gouraudFillTriangle - - We don't *need* the assert, an error() is fine and the malformed - document - will just get rendered wrongly instead of "crashing" - - Bugs #85274 - - poppler/Gfx.cc | 28 +++++++++++++++++----------- - 1 file changed, 17 insertions(+), 11 deletions(-) - -commit 9e9df4b20d17478996780008bc9802a857d173fc -Author: Albert Astals Cid -Date: Thu Jan 8 17:01:52 2015 +0100 - - Fix crash on broken document - - Bug #85281 - - poppler/GfxState.cc | 10 +++++++--- - 1 file changed, 7 insertions(+), 3 deletions(-) - -commit 636faafcb84b856580398f7883b6406d645c85d1 -Author: Adam Reichold -Date: Tue Jan 6 22:57:20 2015 +0100 - - JPEG2000Stream: Inline doGetChar and doLookChar - - poppler/JPEG2000Stream.cc | 49 - +++++++++++++++++++++++++---------------------- - poppler/JPEG2000Stream.h | 7 ++----- - 2 files changed, 28 insertions(+), 28 deletions(-) - -commit c13bffe92963c4969037695992f4c2776bbe973f -Author: Albert Astals Cid -Date: Sun Jan 4 23:17:42 2015 +0100 - - 0.30 - - CMakeLists.txt | 4 ++-- - NEWS | 18 ++++++++++++++++++ - configure.ac | 2 +- - cpp/CMakeLists.txt | 2 +- - cpp/Doxyfile | 2 +- - cpp/Makefile.am | 2 +- - poppler/Makefile.am | 2 +- - poppler/PDFDoc.cc | 1 + - poppler/TextOutputDev.cc | 2 +- - poppler/poppler-config.h.cmake | 2 +- - poppler/poppler-config.h.in | 2 +- - qt4/src/Doxyfile | 2 +- - qt5/src/Doxyfile | 2 +- - 13 files changed, 31 insertions(+), 12 deletions(-) - -commit e499fdab2e96cb3069db7ac8ffa0df20ccccddc9 -Author: Thomas Freitag -Date: Sun Jan 4 20:23:39 2015 +0100 - - extended openjpeg2 support - - poppler/JPEG2000Stream.cc | 101 - +++++++++++++++++++++++++++++++++++----------- - 1 file changed, 78 insertions(+), 23 deletions(-) - -commit 2841f3c34dd6366a70e4d6d307a08b3fbc3e9897 -Author: Adrian Johnson -Date: Sun Jan 4 20:22:47 2015 +0100 - - Cmake support for openjpeg2 - - With some tweaks from Albert - - CMakeLists.txt | 56 - +++++++++++++++++++++++++++++------- - cmake/modules/FindLIBOPENJPEG2.cmake | 30 +++++++++++++++++++ - 2 files changed, 76 insertions(+), 10 deletions(-) - -commit 117af9c6bbd923954ef7de63adec8c22d51da1e4 -Author: Adrian Johnson -Date: Sun Jan 4 19:42:34 2015 +0100 - - Initial attempt at libopenjpeg2 support - - OpenJPEG 2 has a new pkg-config name and API. - - - Update configure.ac to find openjpeg 2 and provide V1/v2 macros - - Update JPEG2000Stream to use new API depending on openjpeg v1/v2 - macros - - OpenJPEG 2.1 changed the API so provide a version macro to make - it easier - to handle the the 2.1 change and any future changes. - - Move openjpeg.h into the .cc file - - configure.ac | 80 ++++++++---- - poppler/JPEG2000Stream.cc | 313 - +++++++++++++++++++++++++++++++++++++--------- - poppler/JPEG2000Stream.h | 41 ++---- - 3 files changed, 323 insertions(+), 111 deletions(-) - -commit 9caf7525409d699c16896653528486451123b485 -Author: Albert Astals Cid -Date: Sun Jan 4 18:48:02 2015 +0100 - - Make PSOutputDev accept a list of pages indeces - - Instead of first, last - - Bug #84833 - - Reviewed in the mailing list, see "Can anyone have a look at my - patch?" - - glib/poppler-page.cc | 10 ++++++--- - poppler/PSOutputDev.cc | 50 - ++++++++++++++++++++++++----------------- - poppler/PSOutputDev.h | 14 +++++++----- - qt4/src/poppler-ps-converter.cc | 11 ++++++--- - qt5/src/poppler-ps-converter.cc | 11 ++++++--- - utils/pdftops.cc | 15 +++++++++---- - 6 files changed, 71 insertions(+), 40 deletions(-) - -commit 173f182fb568843f97e7d45d1b16bebbd2aa7413 -Author: Li Junling -Date: Fri Jan 2 17:23:24 2015 +0100 - - Find last 'startxref' in the last 24K instead of the last 1K - - Bug #85919 - - poppler/PDFDoc.cc | 38 ++++++++++++++++++++++---------------- - 1 file changed, 22 insertions(+), 16 deletions(-) - -commit 0b1cd9403b8a240e58ec4f1832588d25f8295278 -Author: Jason Crain -Date: Sat Dec 20 03:22:23 2014 -0600 - - Free BBox object on error - - poppler/Gfx.cc | 1 + - 1 file changed, 1 insertion(+) - -commit acc33a6950031ac4a5c759d043d24df0cfa7e8b6 -Author: Jason Crain -Date: Sat Dec 20 02:24:49 2014 -0600 - - Check for invalid matrix in annotation - - Bug #84990 - - poppler/Gfx.cc | 12 ++++++++++-- - 1 file changed, 10 insertions(+), 2 deletions(-) - -commit 56aff7d78658f586e3c4cd41685f189dafb3098a -Author: Thomas Freitag -Date: Tue Dec 23 15:49:15 2014 +0100 - - pdfunite: Support output intents, optional content and acroform - - utils/pdfunite.cc | 116 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 116 insertions(+) - -commit 9e734063e6a6a4b9743c9aa27d3d3127b5a960d7 -Author: Jason Crain -Date: Fri Dec 19 01:56:45 2014 -0600 - - Move array reallocation from visitLine to startLine - - Fixes potential memory corruption from writing after end of lines - array. - - https://bugs.freedesktop.org/show_bug.cgi?id=84555 - - poppler/TextOutputDev.cc | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -commit 0c47b769a77795bd866b6686b79fd20ad6f554bf -Author: Daniel Macks -Date: Sun Dec 14 18:52:48 2014 +0100 - - Only consider adding -fno-check-new if compiler supports it - - Helps compiling on old clang's - - Bug #76963 - - configure.ac | 18 ++++++++++++++++-- - 1 file changed, 16 insertions(+), 2 deletions(-) - -commit c9c90d50e3708f6fac313aa8b458aef6dba5dcfb -Author: Hans-Peter Deifel -Date: Fri Dec 12 13:09:51 2014 +0100 - - cpp: New API to set debug output function - - Adds the global function set_debug_error_function, that allows users - to install their own function to print internal poppler errors. - - cpp/poppler-global.cpp | 29 +++++++++++++++++++++++++++++ - cpp/poppler-global.h | 5 +++++ - cpp/poppler-private.cpp | 15 ++++++++++++--- - cpp/poppler-private.h | 3 +++ - 4 files changed, 49 insertions(+), 3 deletions(-) - -commit fa8f276a10911c97d2777fff3270771802bc3892 -Author: Albert Astals Cid -Date: Thu Dec 4 23:11:12 2014 +0100 - - 0.29.0 - - CMakeLists.txt | 4 ++-- - NEWS | 15 +++++++++++++++ - configure.ac | 4 ++-- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - qt5/src/Doxyfile | 2 +- - 7 files changed, 23 insertions(+), 8 deletions(-) - -commit fee700cfecb9d7d5fa938704a5f457f15aaa4676 -Author: Albert Astals Cid -Date: Mon Dec 1 20:52:42 2014 +0100 - - Run dos2unix as suggested by Volker Grabsch - - splash/SplashState.h | 278 ++++++++++---------- - test/perf-test-preview-dummy.cc | 44 ++-- - test/perf-test-preview-win.cc | 544 - ++++++++++++++++++++-------------------- - 3 files changed, 433 insertions(+), 433 deletions(-) - -commit d3fe0661c6dc6050e14cd5cb4afa089b7d7d66b0 -Author: Richard PALO -Date: Sun Nov 30 22:46:22 2014 +0100 - - warning: "_FILE_OFFSET_BITS" redefined - - Bug #86870 - - test/perf-test.cc | 2559 - +++++++++++++++++++++++++++-------------------------- - 1 file changed, 1280 insertions(+), 1279 deletions(-) - -commit 18884065e11fee82506915095619107a43172ecb -Author: Richard PALO -Date: Sun Nov 30 22:36:29 2014 +0100 - - The isfinite macro is defined on SunOS under c99 - - Bug #86869 - - poppler/SplashOutputDev.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit bcb470064dd9f75ab0b0a0d9b7319fe8f1e558ae -Author: Adrian Johnson -Date: Tue Nov 25 05:53:38 2014 +1030 - - cofigure: print "no" instead of "auto" if lcms not found - - configure.ac | 2 ++ - 1 file changed, 2 insertions(+) - -commit 832046c57ab2909d329340f1c941b29e8246ff73 -Author: Thomas Freitag -Date: Fri Nov 28 11:08:34 2014 +0100 - - Use correct LAB byte array for lcms input - - Bug #86388 - - poppler/GfxState.cc | 51 - ++++++++++++++++++++++++++++++++++++++------------- - poppler/GfxState.h | 4 +++- - 2 files changed, 41 insertions(+), 14 deletions(-) - -commit a604bc3a2ed9f9181aa3b12d795608fcf5e08220 -Author: Thomas Freitag -Date: Fri Nov 14 11:56:50 2014 +0100 - - Solve blend mode problem in CYMK and DeviceN for separable blend modes - - Fixes part of #68986 - - poppler/SplashOutputDev.cc | 277 - +++++++++++++++++++++++++-------------------- - 1 file changed, 155 insertions(+), 122 deletions(-) - -commit b7802ff39db270dda2aa20f005fb87c22ed34137 -Author: Thomas Freitag -Date: Fri Nov 14 11:47:38 2014 +0100 - - Use Default colorspaces if present instead of Device colorspaces - - Fixes part of #68986 - - poppler/CairoOutputDev.cc | 4 +- - poppler/Gfx.cc | 40 +++++----- - poppler/GfxState.cc | 197 - ++++++++++++++++++++++++++++++++++------------ - poppler/GfxState.h | 31 ++++---- - poppler/Page.cc | 4 +- - 5 files changed, 188 insertions(+), 88 deletions(-) - -commit 07aa6f4030418883d8d45a8dfa3d80d2dadca4e7 -Author: Thomas Freitag -Date: Thu Nov 13 12:26:25 2014 +0100 - - write correct size in trailer dict - - Bug #86063 - - poppler/PDFDoc.cc | 7 ++----- - 1 file changed, 2 insertions(+), 5 deletions(-) - -commit 51e7c29cabedc72e097023e6d8d6d68ed43fa20c -Author: Carlos Garcia Campos -Date: Fri Nov 7 18:30:36 2014 +0100 - - regtest: Update references also for tests that no longer crash - - We are currently updating the refs only when we have checksums to - compare, but if a test used to crash there's no md5 file in refs. - - regtest/TestRun.py | 2 ++ - regtest/backends/__init__.py | 24 ++++++++++++++++++++++++ - 2 files changed, 26 insertions(+) - -commit d205908930d5dc4ec3a1a1a2c2b93fbb92c2c867 -Author: William Bader -Date: Wed Nov 5 20:23:49 2014 +0100 - - Make it proper C - - glib/demo/annots.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit fa1d636b00210b9c52787ab3c833fe9aa2e293fa -Author: Albert Astals Cid -Date: Tue Nov 4 20:00:08 2014 +0100 - - 0.28.1 - - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - qt5/src/Doxyfile | 2 +- - 4 files changed, 4 insertions(+), 4 deletions(-) - -commit 7debbb05df18afc86df8a4fd37980728ec2e5788 -Author: Albert Astals Cid -Date: Tue Nov 4 19:29:58 2014 +0100 - - Fix typo - - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit d5489ef37742227176e800390a990f2b882d9710 -Author: Albert Astals Cid -Date: Tue Nov 4 01:27:05 2014 +0100 - - 0.28.0 - - CMakeLists.txt | 6 +++--- - NEWS | 43 +++++++++++++++++++++++++++++++++++++++++++ - configure.ac | 4 ++-- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/CMakeLists.txt | 2 +- - qt4/src/Doxyfile | 2 +- - qt4/src/Makefile.am | 2 +- - qt5/src/CMakeLists.txt | 2 +- - qt5/src/Doxyfile | 2 +- - qt5/src/Makefile.am | 2 +- - 11 files changed, 56 insertions(+), 13 deletions(-) - -commit f87115a1129e4e03802769181a3392c8dce3192a -Author: Hib Eris -Date: Tue Nov 4 01:25:18 2014 +0100 - - Don't ship the moc files - - qt4/demos/Makefile.am | 1 - - qt5/demos/Makefile.am | 1 - - 2 files changed, 2 deletions(-) - -commit 0a9c38076f1555196029372b7e08714b43c7a58d -Author: Albert Astals Cid -Date: Mon Nov 3 21:43:28 2014 +0100 - - Update (C) - - fofi/FoFiType1.cc | 1 + - poppler/PDFDoc.cc | 4 ++-- - poppler/PDFDoc.h | 2 +- - poppler/XRef.cc | 2 +- - qt4/src/poppler-annotation-private.h | 2 +- - qt4/src/poppler-annotation.cc | 2 +- - qt4/src/poppler-page.cc | 2 +- - qt4/src/poppler-qt4.h | 2 +- - qt5/src/poppler-annotation-private.h | 2 +- - qt5/src/poppler-annotation.cc | 2 +- - qt5/src/poppler-page.cc | 2 +- - qt5/src/poppler-qt5.h | 2 +- - utils/pdfdetach.cc | 1 + - utils/pdftocairo-win32.cc | 12 ++++++++++++ - utils/pdftocairo-win32.h | 12 ++++++++++++ - utils/pdftocairo.cc | 3 ++- - 16 files changed, 40 insertions(+), 13 deletions(-) - -commit 73cf1e87c9803bbe4271be297b486d9932677d46 -Author: Albert Astals Cid -Date: Mon Nov 3 21:37:13 2014 +0100 - - Need to dist this file - - utils/Makefile.am | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 2fd0cd652cfc03c9af35a59192729e4ed26e8146 -Author: Albert Astals Cid -Date: Mon Nov 3 19:20:23 2014 +0100 - - Fix memory leaks when running pdfseparate - - Bug #84768 - - poppler/PDFDoc.cc | 102 - +++++++++++++++++++++------------------------------ - poppler/PDFDoc.h | 2 +- - utils/pdfseparate.cc | 8 +++- - utils/pdfunite.cc | 4 +- - 4 files changed, 50 insertions(+), 66 deletions(-) - -commit d6ea8acbb348fdb43601a963ba5407e933565003 -Author: Adrian Johnson -Date: Mon Nov 3 19:11:25 2014 +0100 - - fix crash in Xref::getEntry - - Bug 85234 - - poppler/XRef.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit bd142810b9f66b017a58b3e1840d4d72794f1ef4 -Author: Jason Crain -Date: Thu May 15 02:22:44 2014 -0500 - - cairo: Use matrix to determine pattern size - - https://bugs.freedesktop.org/show_bug.cgi?id=33364 - - poppler/CairoOutputDev.cc | 22 ++++++++++++++++++---- - 1 file changed, 18 insertions(+), 4 deletions(-) - -commit 06dd7dc337c7db6122329e98783a126d59035aff -Author: Hib Eris -Date: Thu May 29 12:45:33 2014 +0200 - - Include windows.h, not Windows.h - - Fixes building on file systems that are case sensitive, e.g. when - cross compiling on Linux for win32. - - https://bugs.freedesktop.org/show_bug.cgi?id=79407 - - qt4/tests/stress-threads-qt4.cpp | 2 +- - qt5/tests/stress-threads-qt5.cpp | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 76a350b11160ac203a41b27fbc85a3264bfe4735 -Author: Carlos Garcia Campos -Date: Thu Oct 30 18:25:06 2014 +0100 - - regtest: Try to fix again the paths of the resources in the generated - HTML report - - Use always relatives paths for the resources under the out directory, - and absolute paths for all other resources when no-absolute-path - command - line option is used. - - regtest/HTMLReport.py | 47 - +++++++++++++++++++++++------------------------ - 1 file changed, 23 insertions(+), 24 deletions(-) - -commit c93d6b264dc77c46c72281d966bf826274a43d15 -Author: Carlos Garcia Campos -Date: Wed Oct 29 17:37:06 2014 +0100 - - regtest: respect --no-absolute-paths when creating the pretty - diff links - - regtest/HTMLReport.py | 16 ++++++++++------ - 1 file changed, 10 insertions(+), 6 deletions(-) - -commit 9f953e47a6ea92d806aeea61e227af54c889c6be -Author: Carlos Garcia Campos -Date: Mon Oct 27 19:53:28 2014 +0100 - - regtest: Add an option to create the HTML report without absolute - paths - - It uses the paths as received from the command line attributes. - - regtest/HTMLReport.py | 15 +++++++++++---- - regtest/commands/create-report.py | 4 ++++ - 2 files changed, 15 insertions(+), 4 deletions(-) - -commit 3d840231bc6f0714da361493ef32913af2eb78d7 -Author: Carlos Garcia Campos -Date: Sun Oct 26 12:09:28 2014 +0100 - - regtest: Fix png diff generation with python-pil pillow fork - - Use from PIL import Image instead of just import Image, since pillow - only doesn't support import Image without using PIL.Image. - - regtest/backends/__init__.py | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 68e58ec5465efc289d85ae104941db92450a3168 -Author: Carlos Garcia Campos -Date: Sun Oct 26 11:21:23 2014 +0100 - - regtest: Limit the number of worker threads to the number of documents - to test - - We are always spawning all the threads even if the documents to - test is - less than the worker threads. Also optimize the case of running - only one - test to not spwn any thread. - - regtest/TestRun.py | 27 ++++++++++++++++++--------- - 1 file changed, 18 insertions(+), 9 deletions(-) - -commit 7c21b95852e891060cd2e276949acf0945306ab7 -Author: Carlos Garcia Campos -Date: Sun Oct 26 11:08:45 2014 +0100 - - regtest: Allow to run groups of tests individually - - Now it's possible to pass more than one argument to run-tests - command and - optionally the docs directory. When more than one test is passed - and the - docs directory is not provided, the common base path of all passed - tests - is used as docs directory. The tests passed can be documents or - directories, using absolute paths or paths relative to the docs - directory. - This also allows us to update the refs for a group of tests. - - regtest/TestRun.py | 26 ++++++++++++++++++++++++-- - regtest/Utils.py | 7 +++++-- - regtest/commands/run-tests.py | 29 ++++++++++++++++++++--------- - 3 files changed, 49 insertions(+), 13 deletions(-) - -commit 53be607edc18a861aeb0b6663bac3c05de46c84c -Author: Hib Eris -Date: Fri Oct 24 11:35:17 2014 +0200 - - Fix warning on unused variable in pdftocairo.cc - - Fixes warning: - - CXX pdftocairo-pdftocairo.o - pdftocairo.cc:130:14: warning: ‘setupdlg’ defined but not used - [-Wunused-variable] - static GBool setupdlg = gFalse; - ^ - - https://bugs.freedesktop.org/show_bug.cgi?id=85400 - - utils/pdftocairo.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit f966b8766d40b2c912e69a1e17ef8cc4bd52be95 -Author: Carlos Garcia Campos -Date: Tue Oct 21 16:42:27 2014 +0200 - - fofi: Fix a crash when parsing an invalid font due to a integer - overflow - - This fixes a crash rendering trust_metrics.f2495.f0.pdf. - - fofi/FoFiType1.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 4963332ca4db13d8a9186b06d2aa0d59abbc10ee -Author: Adrian Johnson -Date: Sun Oct 5 21:58:37 2014 +1030 - - pdftocairo: add -printdlg output option for win32 - - when set the win32 print dialog is displayed before printing - - configure.ac | 2 +- - utils/pdftocairo-win32.cc | 303 - ++++++++++++++++++++++++++++++++++++++++++++-- - utils/pdftocairo-win32.h | 14 +-- - utils/pdftocairo.1 | 14 ++- - utils/pdftocairo.cc | 31 ++++- - 5 files changed, 337 insertions(+), 27 deletions(-) - -commit d8fe025c36f555a5438677e20df803eee216bb13 -Author: Adrian Johnson -Date: Sun Oct 5 18:11:09 2014 +1030 - - pdftocairo: add a -setupdlg option that will the show printer - properties - - dialog when printing to a win32 printer. - - utils/pdftocairo-win32.cc | 22 +++++++++++++++++++--- - utils/pdftocairo-win32.h | 3 ++- - utils/pdftocairo.1 | 5 +++++ - utils/pdftocairo.cc | 24 ++++++++++++++++-------- - 4 files changed, 42 insertions(+), 12 deletions(-) - -commit c091aa14513859ab76223f5e4e6055d92082433c -Author: Adrian Johnson -Date: Sun Sep 14 20:43:47 2014 +0930 - - pdftocairo: fix a number of bugs in win32 printing - - - make origPageSizes work - - make landscape pages work - - make -noshrink option work - - return actual page size in use back to main() so fit page transform - works - - hdc should be destroyed after cairo surface - - improve option parsing and rename duplex values - - Add third call to DocumentProperties as discussed in bug 79936 - - fix error messages - - utils/pdftocairo-win32.cc | 181 - ++++++++++++++++++++++++++-------------------- - utils/pdftocairo-win32.h | 2 +- - utils/pdftocairo.1 | 5 +- - utils/pdftocairo.cc | 49 ++++++------- - 4 files changed, 132 insertions(+), 105 deletions(-) - -commit cc3b39d49c656e912a7461212f3bb4e58c6444e7 -Author: Adrian Johnson -Date: Fri Sep 12 18:17:49 2014 +0930 - - make pdftocairo-win32.cc a standalone .cc file - - instead of #including it in pdftocairo.cc - - utils/CMakeLists.txt | 1 + - utils/Makefile.am | 3 +- - utils/pdftocairo-win32.cc | 74 - +++++++++++++++++++++++------------------------ - utils/pdftocairo-win32.h | 22 ++++++++++++++ - utils/pdftocairo.cc | 24 +++++++++------ - 5 files changed, 77 insertions(+), 47 deletions(-) - -commit 700205af19ef1ae5f2c713d118ebd5dd4a0afba3 -Author: Adrian Johnson -Date: Sun Sep 7 20:18:36 2014 +0930 - - pdftocairo: Allow an output file for win32 printing to be specified - - Can be used for testing win32 print output without wasting paper. - - utils/pdftocairo-win32.cc | 12 ++++++++---- - utils/pdftocairo.1 | 4 ++++ - utils/pdftocairo.cc | 13 +++++++------ - 3 files changed, 19 insertions(+), 10 deletions(-) - -commit 40d3ae87befad489fd8c0b38ff2561a0782cae0b -Author: Rodrigo Rivas Costa -Date: Sat Sep 6 21:04:10 2014 +0930 - - Add support for printing to a Windows printer from pdftocairo - - Bug 79936 - - configure.ac | 2 +- - utils/pdftocairo-win32.cc | 219 - ++++++++++++++++++++++++++++++++++++++++++++++ - utils/pdftocairo.1 | 23 ++++- - utils/pdftocairo.cc | 61 ++++++++++--- - 4 files changed, 292 insertions(+), 13 deletions(-) - -commit ee4a389872d86b619c677888da8f13f1f6c54472 -Author: Adrian Johnson -Date: Mon Oct 20 22:32:30 2014 +1030 - - PDFDoc: fix crash when getPage() returns NULL - - Bug 85235 - - poppler/PDFDoc.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 0c3f53e34ec287dab2784e1f3411ad06b62dffc7 -Author: Adrian Johnson -Date: Mon Oct 20 22:17:20 2014 +1030 - - PDFDOC: Check for EOF when reading raw stream - - Bug 85233 - - poppler/PDFDoc.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 88dbd4df0998233939b4a51cedbfc65c58a315f9 -Author: Adrian Johnson -Date: Sun Oct 19 22:47:15 2014 +1030 - - pdfdetach: fix crash when getPage() returns null - - Bug 85145 - - utils/pdfdetach.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit e0179304cdef615fcf639046410d214fd5b5f276 -Author: Adrian Johnson -Date: Sun Oct 19 21:36:39 2014 +1030 - - cairo: fix crash when no group color space - - Bug 85137 - - poppler/CairoOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 745f1241bf903969e50f0e1139641e389a9c331f -Author: Scott West -Date: Tue Oct 7 23:54:52 2014 +0200 - - Fix memory leak in Dict.remove. - - The entry was previously just overwritten now it is freed - - Small fixes by Albert oo - - Bug #84607 - - poppler/Dict.cc | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -commit b8810703ca76f0bbc8185ab87679cf18eb006d52 -Author: Luigi Scarso -Date: Tue Oct 7 22:45:05 2014 +0200 - - Make Attribute::getName() work when UTF-16BE is used - - Contains some ideas by me - Bug #84722 - - goo/GooString.h | 9 +++++---- - poppler/StructElement.cc | 17 +++++++++++------ - poppler/StructElement.h | 7 +++++-- - 3 files changed, 21 insertions(+), 12 deletions(-) - -commit 96a04336c7a6331727724125686a0d6f42f19f46 -Author: Adrian Johnson -Date: Mon Oct 6 10:21:51 2014 +1030 - - cairo: only embed mime data if image decode map is identity - - https://bugs.launchpad.net/ubuntu/+source/cairo/+bug/1317517 - - poppler/CairoOutputDev.cc | 19 ++++++++++++++++--- - poppler/CairoOutputDev.h | 3 ++- - 2 files changed, 18 insertions(+), 4 deletions(-) - -commit 18541054bebce3f9d4729629785bf140d67d2da0 -Author: Adrian Johnson -Date: Wed Sep 24 21:20:42 2014 +0930 - - cairo: Only embed mime data for gray/rgb/cmyk colorspaces - - Bug 80719 - - poppler/CairoOutputDev.cc | 39 +++++++++++++++++++++++++++++++-------- - poppler/CairoOutputDev.h | 2 +- - 2 files changed, 32 insertions(+), 9 deletions(-) - -commit cbf2652c483d7010fc36191c8b209a57eeec93d8 -Author: Adrian Johnson -Date: Thu Jan 26 00:37:17 2012 +1030 - - cairo: don't render text when text matrix is not invertable - - Emulates acroread behavior. - - Bug 78042 - - poppler/CairoOutputDev.cc | 14 +++++++++----- - poppler/CairoOutputDev.h | 1 + - 2 files changed, 10 insertions(+), 5 deletions(-) - -commit 4fe17e97a4bd7873caad771c446199b282039697 -Author: Carlos Garcia Campos -Date: Sun Oct 5 11:30:43 2014 +0200 - - glib: Build introspection linking to the uninstalled libraries - - https://bugs.freedesktop.org/show_bug.cgi?id=84526 - - glib/Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit a2477da56a4d1c534175940d7c01a9d3db6c72d4 -Author: Albert Astals Cid -Date: Wed Oct 1 22:33:11 2014 +0200 - - Fix 303287ebdad0de9fb2655c4d7eab627c0045ea04 - - It may happen that j is bigger than macGlyphNames size, so don't - try to access it - - fofi/FoFiTrueType.cc | 12 ++++++++---- - 1 file changed, 8 insertions(+), 4 deletions(-) - -commit ce95ecda450361496aedd5d5cd0bf47fd2c66703 -Author: Albert Astals Cid -Date: Tue Sep 30 19:50:20 2014 +0200 - - Fix assert in 5068.asan.0.6052.pdf - - poppler/Gfx.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 01723aa17e836e818158dbdc56df642a290be300 -Author: Adrian Johnson -Date: Tue Sep 30 18:48:47 2014 +0200 - - Map Standard/Expert encoding ligatures to AGLFN names - - for use with substitute fonts that are not compatible with the - Standard 14 fonts. - - Bug 80093 - - poppler/CairoFontEngine.cc | 12 +++++++++--- - poppler/GfxFont.cc | 29 ++++++++++++++++++++++++++++- - poppler/GfxFont.h | 7 ++++++- - splash/SplashFTFontFile.cc | 8 ++++++++ - 4 files changed, 51 insertions(+), 5 deletions(-) - -commit 529db4a94607c1ad909764d26f740c601bbe896f -Author: Hib Eris -Date: Mon Sep 29 22:59:15 2014 +0200 - - Fix build with --disable-utils - - Since 21b5fd655ce45b90668d1416d21c526ab7eb3ad6, building Poppler - fails when configured - with '--disable-utils'. - - Bug #84448 - - Makefile.am | 6 +----- - utils/Makefile.am | 4 ++++ - 2 files changed, 5 insertions(+), 5 deletions(-) - -commit c54f6aceed983a221d88ce5c21becbf8aab2931b -Author: Thomas Freitag -Date: Mon Sep 29 21:42:46 2014 +0200 - - use alt colorspace to get CMYK values for an ICC based CMYK colorspace - - The reason for the pale image is that GfxICCBasedColorSpace::getCMYK() - uses the cms transformation to get RGB values and the convert it - back to CMYK even for a ICC based CMYK colorspace instead of just - returning the CMYK values itself. - - Bug #79019 - - poppler/GfxState.cc | 10 ++++++---- - 1 file changed, 6 insertions(+), 4 deletions(-) - -commit 21b5fd655ce45b90668d1416d21c526ab7eb3ad6 -Author: Hib Eris -Date: Sun Sep 14 11:20:23 2014 +0200 - - Refactor Makefiles to build a noinst library for parsing args - - Prevents this automake warning about possible forward-incompatibility: - - $ ./autogen.sh - ... - cpp/tests/Makefile.am:16: warning: source file - '$(top_srcdir)/utils/parseargs.cc' is in a subdirectory, - cpp/tests/Makefile.am:16: but option 'subdir-objects' is disabled - automake: warning: possible forward-incompatibility. - automake: At least a source file is in a subdirectory, but the - 'subdir-objects' - automake: automake option hasn't been enabled. For now, the - corresponding output - automake: object file(s) will be placed in the top-level directory. - However, - automake: this behaviour will change in future Automake versions: - they will - automake: unconditionally cause object files to be placed in the - same subdirectory - automake: of the corresponding sources. - automake: You are advised to start using 'subdir-objects' option - throughout your - automake: project, to avoid future incompatibilities. - cpp/tests/Makefile.am:20: warning: source file - '$(top_srcdir)/utils/parseargs.cc' is in a subdirectory, - cpp/tests/Makefile.am:20: but option 'subdir-objects' is disabled - parallel-tests: installing './test-driver' - test/Makefile.am:58: warning: source file '../utils/parseargs.cc' - is in a subdirectory, - test/Makefile.am:58: but option 'subdir-objects' is disabled - - $ automake --version - automake (GNU automake) 1.14.1 - ... - - https://bugs.freedesktop.org/show_bug.cgi?id=83839 - - cpp/tests/Makefile.am | 3 +-- - test/Makefile.am | 8 ++++---- - utils/.gitignore | 2 ++ - utils/Makefile.am | 42 ++++++++++++++++++------------------------ - 4 files changed, 25 insertions(+), 30 deletions(-) - -commit 70a851b0cc58241d1f2f6bc48af2614595326c8f -Author: Adrian Johnson -Date: Sat Sep 6 21:16:04 2014 +0930 - - Update .gitignore - - .gitignore | 2 ++ - 1 file changed, 2 insertions(+) - -commit d44e7e3560bdc79253df98db05385dce3e8ccbb4 -Author: Adrian Johnson -Date: Sat Sep 6 21:53:21 2014 +0930 - - Don't use -fPIC on mingw - - it emits a warning for every file stating that -fPIC is ignored - - configure.ac | 12 +++++++++++- - 1 file changed, 11 insertions(+), 1 deletion(-) - -commit 2723371b2e2f7684301ea1c5272ab49851f28c03 -Author: Adrian Johnson -Date: Sat Sep 6 21:19:46 2014 +0930 - - make autogen.sh work with variables with spaces - - eg ./autogen.sh CXXFLAGS="-O0 -g3" - - autogen.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ebc814a7e31511308bbcd8856d0356f4d7cc74be -Author: Hib Eris -Date: Sun Sep 14 11:45:12 2014 +0200 - - Add compile to .gitignore - - Automake automatically creates a wrapper script called 'compile' for - compilers which do not understand '-c -o'. - - $ automake --version - automake (GNU automake) 1.14.1 - - https://bugs.freedesktop.org/show_bug.cgi?id=83840 - - .gitignore | 1 + - 1 file changed, 1 insertion(+) - -commit 8ce31485faa26994c52f4d032cc5a8355aba23d1 -Merge: 4589ce1 303287e -Author: Albert Astals Cid -Date: Fri Sep 26 00:40:43 2014 +0200 - - Merge remote-tracking branch 'origin/poppler-0.26' - -commit 303287ebdad0de9fb2655c4d7eab627c0045ea04 -Author: Thomas Freitag -Date: Fri Sep 26 00:25:38 2014 +0200 - - Fix rendering of file with a wrong embedded font - - Bug #84270 - - fofi/FoFiTrueType.cc | 22 ++++++++++++++-------- - 1 file changed, 14 insertions(+), 8 deletions(-) - -commit f94ba85a736b4c90c05e7782939f32506472658e -Author: Carlos Garcia Campos -Date: Fri Sep 12 19:22:20 2014 +0200 - - glib: Fix use of uninitialized members in PopplerInputStream - - https://bugs.freedesktop.org/show_bug.cgi?id=82630 - - glib/poppler-input-stream.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 4589ce17caf94e7c5fa856906d3a8cc08e999d73 -Author: Carlos Garcia Campos -Date: Fri Sep 12 19:22:20 2014 +0200 - - glib: Fix use of uninitialized members in PopplerInputStream - - https://bugs.freedesktop.org/show_bug.cgi?id=82630 - - glib/poppler-input-stream.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit fe67324d450c356b7c876cf50da705156112513a -Merge: e62e18e f74a596 -Author: Albert Astals Cid -Date: Thu Aug 21 21:39:52 2014 +0200 - - Merge remote-tracking branch 'origin/poppler-0.26' - -commit f74a5964078224c01bd5642aabc928d185bb0b69 -Author: Albert Astals Cid -Date: Thu Aug 21 20:07:54 2014 +0200 - - 0.26.4 - - CMakeLists.txt | 2 +- - NEWS | 12 ++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - qt5/src/Doxyfile | 2 +- - 6 files changed, 17 insertions(+), 5 deletions(-) - -commit ce92e4ccefc7dad79db7f0af7a792ffa47824849 -Author: Albert Astals Cid -Date: Thu Aug 21 20:03:42 2014 +0200 - - Update (C) years - - poppler/Annot.cc | 1 + - poppler/CairoOutputDev.cc | 2 +- - 2 files changed, 2 insertions(+), 1 deletion(-) - -commit 42315c28809e62da7872add917e82853cf8c7e33 -Author: Albert Astals Cid -Date: Thu Aug 21 19:58:35 2014 +0200 - - Make sure e is always initialized - - goo/gfile.cc | 6 +----- - 1 file changed, 1 insertion(+), 5 deletions(-) - -commit e62e18e1b318d6fa664d236723de3c06ae43e86b -Author: Jehan Pagès -Date: Tue Aug 12 21:05:03 2014 +0200 - - poppler: use poppler-data pkg-config for both cmake and autotools - builds - - CMakeLists.txt | 16 ++++++++++++++++ - config.h.cmake | 2 +- - configure.ac | 7 ++++++- - 3 files changed, 23 insertions(+), 2 deletions(-) - -commit 572c60764bbbd2080bfd7a926c646ad20b467aea -Author: Hib Eris -Date: Tue Aug 12 18:12:45 2014 +0200 - - Makefile.am cleanups - - Bug #79411 - - configure.ac | 13 +++-- - cpp/Makefile.am | 66 +++++++++++++------------ - cpp/tests/Makefile.am | 13 ++--- - fofi/Makefile.am | 6 +-- - glib/Makefile.am | 29 ++++++----- - glib/demo/Makefile.am | 18 +++---- - glib/reference/Makefile.am | 3 +- - goo/Makefile.am | 38 +++++++-------- - poppler/Makefile.am | 118 - ++++++++++++++++++++++----------------------- - qt4/demos/Makefile.am | 59 +++++++++++------------ - qt4/src/Makefile.am | 31 ++++++------ - qt4/tests/Makefile.am | 97 +++++++++++++------------------------ - qt5/demos/Makefile.am | 59 +++++++++++------------ - qt5/src/Makefile.am | 27 ++++++----- - qt5/tests/Makefile.am | 98 ++++++++++++++----------------------- - splash/Makefile.am | 42 ++++++++-------- - test/Makefile.am | 68 +++++++++----------------- - utils/Makefile.am | 97 ++++++++++++++++++------------------- - 18 files changed, 405 insertions(+), 477 deletions(-) - -commit 4a4fe80d85a31b10822c7cd8eb5a0698bf306a52 -Author: Hib Eris -Date: Fri Aug 1 07:16:36 2014 +0200 - - glib-demo: Replace use of deprecated gtk stock items - - https://bugs.freedesktop.org/show_bug.cgi?id=82384 - - glib/demo/annots.c | 8 ++++---- - glib/demo/attachments.c | 4 ++-- - glib/demo/main.c | 6 +++--- - glib/demo/page.c | 6 +++--- - glib/demo/utils.c | 4 ++-- - 5 files changed, 14 insertions(+), 14 deletions(-) - -commit ec6bad36cf5e9521f35285a3295976c05a69f76a -Author: Hib Eris -Date: Fri Aug 1 07:51:10 2014 +0200 - - glib-demo: Remove use of deprecated gtk_dialog_get_action_area() - - https://bugs.freedesktop.org/show_bug.cgi?id=82385 - - glib/demo/main.c | 5 +---- - 1 file changed, 1 insertion(+), 4 deletions(-) - -commit b72a534d6c7d8bc026812b68f9d9ac6bf9a2200a -Merge: f2e4154 ef3f758 -Author: Albert Astals Cid -Date: Sun Aug 3 01:06:57 2014 +0200 - - Merge remote-tracking branch 'origin/poppler-0.26' - -commit ef3f7585fac086de0919aa0bb0ef91a5070ac23e -Author: Jiri Slaby -Date: Sun Aug 3 01:05:00 2014 +0200 - - Improve non-latin characters in inline notes - - Preview commit had by mistake changes in these two files that - belong here - - Bug #65956 - - poppler/Annot.cc | 1 + - poppler/CharCodeToUnicode.cc | 1 + - 2 files changed, 2 insertions(+) - -commit 1b9c54286a4cdfaa284795933c20acf3c7e13bfc -Author: Ed Porras -Date: Sun Aug 3 01:01:35 2014 +0200 - - Don't check for inlineImg twice - - Bug #82059 - - poppler/Annot.cc | 2 +- - poppler/CharCodeToUnicode.cc | 2 +- - poppler/SplashOutputDev.cc | 9 ++++----- - 3 files changed, 6 insertions(+), 7 deletions(-) - -commit f2e4154eff52b86e62490a3ccba470824c9cf436 -Author: Thomas Freitag -Date: Sat Jul 26 00:12:37 2014 +0200 - - pdfseparate: additonal handling for annotations - - Bug #77549 - - poppler/PDFDoc.cc | 46 ++++++++++++++++++++++++++++------------------ - poppler/PDFDoc.h | 6 +++--- - utils/pdfunite.cc | 2 +- - 3 files changed, 32 insertions(+), 22 deletions(-) - -commit e7825f7cbbe7cc9c324fcb34c2e0dcae75f4172a -Author: Carlos Garcia Campos -Date: Fri Jul 25 15:45:55 2014 +0200 - - glib: Fix a memory leak when getting text layout and attributes - - glib/poppler-page.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit b729bf92ea1522a1eed9579e53e7580215cb9555 -Author: Carlos Garcia Campos -Date: Fri Jul 25 15:45:55 2014 +0200 - - glib: Fix a memory leak when getting text layout and attributes - - glib/poppler-page.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit a1ecff0f0ab81fe76f63244250d96e7ef275f402 -Author: Carlos Garcia Campos -Date: Fri Jul 25 11:25:42 2014 +0200 - - glib: Return NULL in poppler_annot_get_contents also for empty strings - - glib/poppler-annot.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ab1113d10ef712c7c44cd4b4bb6bc79f9ca3702c -Author: Anuj Khare -Date: Thu Jul 24 19:47:22 2014 +0200 - - annots: Fix a crash when adding annot without contents - - Having no content in an annotation results in a crash when generating - its appearance, since the contents pointer is dereferenced. - For consistency, the same has been done in Annot::initialize. - - poppler/Annot.cc | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit f302864ed354b313ec39433f65ca3b107b55789d -Author: Carlos Garcia Campos -Date: Fri Jul 25 11:25:42 2014 +0200 - - glib: Return NULL in poppler_annot_get_contents also for empty strings - - glib/poppler-annot.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 13a5c5f4b61d05f2d18f94ad15e210a47021a576 -Author: Anuj Khare -Date: Thu Jul 24 19:47:22 2014 +0200 - - annots: Fix a crash when adding annot without contents - - Having no content in an annotation results in a crash when generating - its appearance, since the contents pointer is dereferenced. - For consistency, the same has been done in Annot::initialize. - - poppler/Annot.cc | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit 94ea9d8e1631abfbb8cc078100942d46b1356970 -Author: Carlos Garcia Campos -Date: Thu Jul 24 10:46:17 2014 +0200 - - cairo: Make sure we always push a transparency group in - setSoftMaskFromImageMask() - - Because that's what unsetSoftMaskFromImageMask() assumes. - - https://bugs.freedesktop.org/show_bug.cgi?id=81624 - - poppler/CairoOutputDev.cc | 64 - +++++++++++++++++++++++------------------------ - 1 file changed, 31 insertions(+), 33 deletions(-) - -commit 02c127b355bb8a98684a5d0af063c60b8bfd09dd -Author: Carlos Garcia Campos -Date: Thu Jul 24 10:46:17 2014 +0200 - - cairo: Make sure we always push a transparency group in - setSoftMaskFromImageMask() - - Because that's what unsetSoftMaskFromImageMask() assumes. - - https://bugs.freedesktop.org/show_bug.cgi?id=81624 - - poppler/CairoOutputDev.cc | 64 - +++++++++++++++++++++++------------------------ - 1 file changed, 31 insertions(+), 33 deletions(-) - -commit c841a703c4c1750fd7ac0d04c6c3e7d4af80b8fa -Author: Albert Astals Cid -Date: Mon Jul 21 00:29:28 2014 +0200 - - Improve Overprintmode and shadings - - Bug #80998 - - poppler/SplashOutputDev.cc | 6 ++++-- - poppler/SplashOutputDev.h | 8 +++++++- - splash/Splash.cc | 24 ++++++++++++++++++++++-- - splash/SplashPattern.h | 6 +++++- - 4 files changed, 38 insertions(+), 6 deletions(-) - -commit ce782112746f629a8e7be6f2daf6ece6ab19917d -Merge: 2c0cb68 26372cf -Author: Albert Astals Cid -Date: Sun Jul 20 20:35:13 2014 +0200 - - Merge remote-tracking branch 'origin/poppler-0.26' - -commit 26372cfae029a1124e042855c58bf5b70f281c76 -Author: Ed Porras -Date: Sun Jul 20 20:33:48 2014 +0200 - - printf -> error - - Bug #81513 - - poppler/Catalog.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 87d12c09281e3d12cda0fadcd65ab78928dff283 -Author: Albert Astals Cid -Date: Sun Jul 20 18:20:57 2014 +0200 - - 0.26.3 - - CMakeLists.txt | 2 +- - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - qt5/src/Doxyfile | 2 +- - 5 files changed, 5 insertions(+), 5 deletions(-) - -commit 69e5b81640c9bb31f0876fa8eb7ba28dbf38923f -Author: Albert Astals Cid -Date: Sun Jul 20 18:18:29 2014 +0200 - - News for 0.26.3 - - NEWS | 21 +++++++++++++++++++++ - 1 file changed, 21 insertions(+) - -commit c368c0714d57c089057d974908295d850a1b5108 -Author: Albert Astals Cid -Date: Sun Jul 20 18:15:22 2014 +0200 - - Update Thomas' (C) - - splash/SplashXPathScanner.cc | 2 +- - splash/SplashXPathScanner.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 639179318c43a907a27e86778b720d33d481a9f9 -Author: Pino Toscano -Date: Thu Jul 17 07:33:10 2014 +0200 - - glib: use C90-style comments in public headers - - glib/poppler-media.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 2c0cb689910e8579bf428b3999bcac0cb27b0e51 -Merge: 0b639cd 1161e72 -Author: Albert Astals Cid -Date: Sat Jul 12 17:21:07 2014 +0200 - - Merge remote-tracking branch 'origin/poppler-0.26' - -commit 1161e728de9ca7c9a5fb0e24c4a5e4a79c65a849 -Author: Thomas Freitag -Date: Sat Jul 12 17:04:42 2014 +0200 - - Error out instead of exiting if allInter grows too much - - Bug #78714 - - splash/SplashXPathScanner.cc | 25 +++++++++++++++++-------- - splash/SplashXPathScanner.h | 2 +- - 2 files changed, 18 insertions(+), 9 deletions(-) - -commit e82a24a585d251f767725f61700dc1f8fe169a52 -Author: Pino Toscano -Date: Sat Jul 12 08:35:45 2014 +0200 - - cmake: sync poppler-config.h.cmake with poppler-config.h.in - - poppler/poppler-config.h.cmake | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -commit 0b639cd2ac1071f5b741031a78d8e2bc18d2b7d7 -Merge: bb16c71 a5ad55b -Author: Albert Astals Cid -Date: Fri Jul 11 00:32:46 2014 +0200 - - Merge remote-tracking branch 'origin/poppler-0.26' - -commit a5ad55b7cb9dc4e62754954291e4ecb8e05b5d67 -Author: Albert Astals Cid -Date: Fri Jul 11 00:32:07 2014 +0200 - - Add Hib's (C) - - poppler/poppler-config.h.in | 1 + - 1 file changed, 1 insertion(+) - -commit 4f4ee736075d5b1d1bf4911a26c2f80a7122fe04 -Author: Aki Koskinen -Date: Fri Jul 11 00:30:52 2014 +0200 - - Fix compilation of Qt5 frontend with MinGW - - qt5/src/poppler-private.h | 7 ++----- - 1 file changed, 2 insertions(+), 5 deletions(-) - -commit ddd91675792d9d496b06223867e05d2a190b878b -Author: Hib Eris -Date: Thu May 29 16:58:55 2014 +0200 - - Include stdio.h from poppler-config.h - - In poppler-config.h there is a check for __MINGW_PRINTF_FORMAT, - which is set by stdio.h. - - This fixes this warning when compling with the mingw-w64-compiler: - - XRef.cc: In member function 'virtual void - XRef::XRefTableWriter::writeEntry(Goffset, int, XRefEntryType)': - XRef.cc:1460:94: warning: unknown conversion type character 'l' - in format [-Wformat=] - outStr->printf("%010lli %05i %c\r\n", (long long)offset, gen, - (type==xrefEntryFree)?'f':'n'); - ^ - XRef.cc:1460:94: warning: format '%i' expects argument of type 'int', - but argument 3 has type 'Goffset {aka long long int}' [-Wformat=] - XRef.cc:1460:94: warning: too many arguments for format - [-Wformat-extra-args] - - https://bugs.freedesktop.org/show_bug.cgi?id=79762 - - poppler/poppler-config.h.in | 2 ++ - 1 file changed, 2 insertions(+) - -commit bb16c7162c73b871e26f508823c0ee259b7e5420 -Author: Hib Eris -Date: Sat Jun 7 12:00:52 2014 +0200 - - Move automake version check from autogen.sh to configure.ac - - https://bugs.freedesktop.org/show_bug.cgi?id=79797 - - autogen.sh | 18 ------------------ - configure.ac | 2 +- - 2 files changed, 1 insertion(+), 19 deletions(-) - -commit 74c72223cf609e7c24594f95cab6f9865ad562ac -Merge: f8f7b3a 47a947f -Author: Albert Astals Cid -Date: Fri Jul 11 00:23:04 2014 +0200 - - Merge remote-tracking branch 'origin/poppler-0.26' - -commit 47a947f1dc664793a7037888a46a297a46c79d6c -Author: Hib Eris -Date: Thu Jun 19 10:11:21 2014 +0200 - - Fix moc-qt5 detection - - https://bugs.freedesktop.org/show_bug.cgi?id=80250 - - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit f8f7b3a61bc7eb1e569c25a630b5e127b5dcae62 -Merge: 805ff76 aa6205d -Author: Albert Astals Cid -Date: Wed Jul 9 00:23:22 2014 +0200 - - Merge remote-tracking branch 'origin/poppler-0.26' - -commit aa6205d195c56a77e897bad125bf213aba138422 -Author: Jason Crain -Date: Mon Jul 7 23:52:39 2014 -0500 - - Increase required Qt4 version to 4.7.0 - - We use Qt::LayoutDirectionAuto, introduced in 4.7.0. - - bug #81005 - - CMakeLists.txt | 2 +- - configure.ac | 8 ++++---- - 2 files changed, 5 insertions(+), 5 deletions(-) - -commit 805ff76112ebfd57276ea78f1f0891abc61a6c03 -Author: Yaakov Selkowitz -Date: Mon Apr 11 16:26:11 2011 -0500 - - Do not dist gir_DATA - - See https://bugzilla.gnome.org/show_bug.cgi?id=621611 for rationale. - - glib/Makefile.am | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit e5862155b1c549b6774bb4f25c09c45857ff1734 -Author: Hib Eris -Date: Wed Jun 4 20:58:56 2014 +0200 - - Add Changelog to .gitignore - - https://bugs.freedesktop.org/show_bug.cgi?id=79744 - - .gitignore | 1 + - 1 file changed, 1 insertion(+) - -commit 5f22649694d64c4170db82847b599576d5377176 -Author: Hib Eris -Date: Wed Jun 4 20:56:23 2014 +0200 - - Add *.gir, *.typelib to glib/.gitignore - - https://bugs.freedesktop.org/show_bug.cgi?id=79744 - - glib/.gitignore | 2 ++ - 1 file changed, 2 insertions(+) - -commit b63f57985719c7884b67f46fc4afd4954c44c5ab -Author: Hib Eris -Date: Wed Jun 4 20:54:30 2014 +0200 - - Add poppler-undeclared.txt to .gitignore - - https://bugs.freedesktop.org/show_bug.cgi?id=79744 - - glib/reference/.gitignore | 1 + - 1 file changed, 1 insertion(+) - -commit 5e0f4e2516d5a3997ea9c9a9927e24d4f3abe136 -Author: Hib Eris -Date: Wed Jun 4 20:52:15 2014 +0200 - - Add poppler-forms, stress-threads-qt, test-render-to-file to - .gitignore - - https://bugs.freedesktop.org/show_bug.cgi?id=79744 - - qt4/tests/.gitignore | 3 +++ - qt5/tests/.gitignore | 3 +++ - 2 files changed, 6 insertions(+) - -commit 4d2400e7bb8ae9208030b9615dda7c53e571be8b -Author: Hib Eris -Date: Wed Jun 4 10:09:16 2014 +0200 - - Add test-driver to .gitignore - - https://bugs.freedesktop.org/show_bug.cgi?id=79744 - - .gitignore | 1 + - 1 file changed, 1 insertion(+) - -commit 4c35e0213be26f21b628ff8d9f170252bb0106c9 -Author: Hib Eris -Date: Wed Jun 4 10:06:20 2014 +0200 - - Add poppler-qt5.pc to .gitignore - - https://bugs.freedesktop.org/show_bug.cgi?id=79744 - - .gitignore | 2 ++ - 1 file changed, 2 insertions(+) - -commit 2b455b85168d5c9d8641d9a91bfde81ccab18e54 -Author: Pino Toscano -Date: Sun Jul 6 11:13:54 2014 +0200 - - glib: fix typo in apidox - - glib/poppler.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 266a61ab1c9f536a4fb7d68c8f285c854eb2d6e9 -Author: Albert Astals Cid -Date: Thu Jun 19 20:16:19 2014 +0200 - - 0.26.2 - - CMakeLists.txt | 2 +- - NEWS | 10 ++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - qt5/src/Doxyfile | 2 +- - 6 files changed, 15 insertions(+), 5 deletions(-) - -commit 3381ee20efca2ce27733182d0d6720c1e6936a7f -Author: Albert Astals Cid -Date: Thu Jun 19 19:57:31 2014 +0200 - - Update (C) - - poppler/Lexer.cc | 2 +- - utils/pdftohtml.cc | 1 + - 2 files changed, 2 insertions(+), 1 deletion(-) - -commit 8a5e59c6ea7ccd0ecbdb4b37bf3fe4e74e1c0e8e -Merge: 1b70533 310fbee -Author: Albert Astals Cid -Date: Wed Jun 18 00:37:03 2014 +0200 - - Merge remote-tracking branch 'origin/poppler-0.26' - -commit 310fbeec692b02d555e3e8dd6c851be11b25e26a -Author: Albert Astals Cid -Date: Wed Jun 18 00:31:48 2014 +0200 - - Make sure we have an xref before using - - KDE bug #335413 had this backtrace - XRef::getNumEntry (this=0x0, offset=-1) at XRef.cc:1300 - 0x00007f29aec1681e in Lexer::getObj (this=0x1648760, - obj=obj@entry=0x1bdf978, cmdA=cmdA@entry=0x7f29aeca66c8 "endstream", - objNum=objNum@entry=0) at Lexer.cc:594 - 0x00007f29aec20dfd in Parser::shift (this=this@entry=0x1bdf950, - cmdA=cmdA@entry=0x7f29aeca66c8 "endstream", objNum=objNum@entry=0) - at Parser.cc:323 - 0x00007f29aec20fde in Parser::makeStream (this=this@entry=0x1bdf950, - dict=dict@entry=0x7fff2541cad0, fileKey=fileKey@entry=0x0, - encAlgorithm=encAlgorithm@entry=cryptRC4, keyLength=keyLength@entry=0, - objNum=objNum@entry=0, objGen=objGen@entry=0, - recursion=recursion@entry=1, strict=strict@entry=false) at - Parser.cc:245 - 0x00007f29aec216b8 in Parser::getObj (this=this@entry=0x1bdf950, - obj=obj@entry=0x7fff2541cad0, simpleOnly=simpleOnly@entry=false, - fileKey=fileKey@entry=0x0, encAlgorithm=encAlgorithm@entry=cryptRC4, - keyLength=keyLength@entry=0, objNum=objNum@entry=0, - objGen=objGen@entry=0, recursion=recursion@entry=0, - strict=strict@entry=false) at Parser.cc:131 - 0x00007f29aec350fc in XRef::readXRef - (this=this@entry=0xfe43a0, pos=pos@entry=0xfe4438, - followedXRefStm=followedXRefStm@entry=0x7fff2541cb30, - xrefStreamObjsNum=xrefStreamObjsNum@entry=0x0) at XRef.cc:551 - 0x00007f29aec35319 in XRef::XRef (this=0xfe43a0, - strA=0x1c54ff0, pos=, mainXRefEntriesOffsetA=0, - wasReconstructed=0x7fff2541cbaf, reconstruct=) - at XRef.cc:342 - 0x00007f29aec2534f in PDFDoc::setup (this=this@entry=0x311e1b0, - ownerPassword=ownerPassword@entry=0x1165830, - userPassword=userPassword@entry=0x447f550) at PDFDoc.cc:262 - - poppler/Lexer.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 1b705331019b155f2138d4b9f5a5bd03ec59193d -Author: Hib Eris -Date: Sun Jun 8 17:07:15 2014 +0200 - - [glib] doc: Move poppler_date_parse to utility functions section - - https://bugs.freedesktop.org/show_bug.cgi?id=79798 - - glib/reference/poppler-docs.sgml | 1 + - glib/reference/poppler-sections.txt | 7 ++++++- - 2 files changed, 7 insertions(+), 1 deletion(-) - -commit d661553b0a13855aa5a1240e9c04a0e49dafd910 -Author: Hib Eris -Date: Sun Jun 8 16:11:26 2014 +0200 - - [glib] doc: Document PopplerFindFlags:POPPLER_FIND_DEFAULT - - Fixes warning: - DOC Building XML - ../../glib/poppler.h:157: warning: Value description for - PopplerFindFlags::POPPLER_FIND_DEFAULT is missing in source code - comment - block. - - https://bugs.freedesktop.org/show_bug.cgi?id=79798 - - glib/poppler.h | 1 + - 1 file changed, 1 insertion(+) - -commit 237a1402ab836d10eb5fdc1aa6ceccabea10a316 -Author: Hib Eris -Date: Sun Jun 8 16:07:14 2014 +0200 - - [glib] doc: Use instead of - - Fixes: - DOC Building HTML - Element em in namespace '' encountered in para, but no template - matches. - - https://bugs.freedesktop.org/show_bug.cgi?id=79798 - - glib/poppler-structure-element.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 66abf3992228be2559542e9d2753f45f06ae7728 -Author: Hib Eris -Date: Sun Jun 8 16:02:01 2014 +0200 - - [glib] doc: Add PopplerBackend documentation - - https://bugs.freedesktop.org/show_bug.cgi?id=79798 - - glib/poppler.h | 8 ++++++++ - 1 file changed, 8 insertions(+) - -commit a30ec8e4abe3875aad068c83265b47f9beea33d1 -Author: Hib Eris -Date: Sun Jun 8 15:05:52 2014 +0200 - - [glib] doc: Add missing POPPLER_TYPE_POINT - - And while we are here, also move poppler_point_get_type() and - poppler_quadrilateral_get_type() to private subsection. - - https://bugs.freedesktop.org/show_bug.cgi?id=79798 - - glib/reference/poppler-sections.txt | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - -commit 6eb0537ac5163356c8e8f689d2408fa695e99423 -Author: Hib Eris -Date: Sun Jun 8 14:59:15 2014 +0200 - - [glib] doc: Fix typo - - https://bugs.freedesktop.org/show_bug.cgi?id=79798 - - glib/reference/poppler-sections.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 96adcad85d76409cb8ed4266a08ae776b42661e4 -Author: Hib Eris -Date: Sun Jun 8 14:53:42 2014 +0200 - - [glib] doc: Add poppler_annot_set_flags() to documentation - - https://bugs.freedesktop.org/show_bug.cgi?id=79798 - - glib/reference/poppler-sections.txt | 1 + - 1 file changed, 1 insertion(+) - -commit f3519352c70537009cc6bd660c0bd3e727db8b8a -Author: Hib Eris -Date: Sun Jun 8 14:38:13 2014 +0200 - - [glib] doc: Move PopplerFindFlags to PopplerPage section - - And also add the missing POPPLER_TYPE_FIND_FLAGS and - poppler_find_flags_get_type. - - https://bugs.freedesktop.org/show_bug.cgi?id=79798 - - glib/reference/poppler-sections.txt | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit 45b0d49330d9d089b2480b91e418924a490c82ce -Author: Hib Eris -Date: Sun Jun 8 14:22:28 2014 +0200 - - [glib] doc: Move PopplerPrintFlags to PopplerPage section - - https://bugs.freedesktop.org/show_bug.cgi?id=79798 - - glib/reference/poppler-sections.txt | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit ce357147d17004a2772ca3b32d106da511bba360 -Author: Hib Eris -Date: Sun Jun 8 13:22:51 2014 +0200 - - [glib] doc: Move poppler_get_{version, backend} documentation to - features section - - https://bugs.freedesktop.org/show_bug.cgi?id=79798 - - glib/reference/poppler-sections.txt | 15 +++++++++------ - 1 file changed, 9 insertions(+), 6 deletions(-) - -commit 1bfd6b69e7e98d4b3e6e891a46b58c9109b8c14c -Author: Hib Eris -Date: Sun Jun 8 12:57:25 2014 +0200 - - [glib] doc: Move PopplerColor documentation to it's own section - - https://bugs.freedesktop.org/show_bug.cgi?id=79798 - - glib/poppler-page.cc | 6 ++++++ - glib/reference/poppler-docs.sgml | 1 + - glib/reference/poppler-sections.txt | 21 +++++++++++++++------ - 3 files changed, 22 insertions(+), 6 deletions(-) - -commit 2dd9b95fd910023a7d9d23f2c2e41dcab91d3c31 -Merge: fed71eb b36d27b -Author: Albert Astals Cid -Date: Fri Jun 6 21:43:49 2014 +0200 - - Merge remote-tracking branch 'origin/poppler-0.26' - -commit b36d27b42417d15866a5729409e39d6f7c2b0289 -Author: Hib Eris -Date: Fri Jun 6 21:42:10 2014 +0200 - - Fix typo in configure.ac - - Bug #79742 - - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit fed71ebd8e43e24eace9dcebe24bd318ff3d04a6 -Author: Hib Eris -Date: Thu May 29 13:22:05 2014 +0200 - - Change pagenum arguments in PDFDoc::markAnnotations from Guint to int - - Bug #79410 - Fixes compile warning: - - CXX PDFDoc.lo - PDFDoc.cc: In member function 'GBool PDFDoc::markAnnotations(Object*, - XRef*, XRef*, Guint, Guint, Guint)': - PDFDoc.cc:1607:40: warning: comparison between signed and unsigned - integer expressions [-Wsign-compare] - if (obj2.getRef().num == oldPageNum) { - ^ - PDFDoc.cc:1617:47: warning: comparison between signed and unsigned - integer expressions [-Wsign-compare] - } else if (obj2.getRef().num == newPageNum) { - - https://bugs.freedesktop.org/show_bug.cgi?id=79410 - - poppler/PDFDoc.cc | 4 ++-- - poppler/PDFDoc.h | 4 ++-- - 2 files changed, 4 insertions(+), 4 deletions(-) - -commit f5e702060a84362bfdf75260531920d4ba8b7333 -Author: Pino Toscano -Date: Sat May 24 15:59:42 2014 +0200 - - pdftohtml: exit with 0 with -v and -h - - utils/pdftohtml.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 700bf398ef7b20306f5035e423becfaa3d28fb10 -Author: Albert Astals Cid -Date: Fri May 23 20:05:41 2014 +0200 - - 0.26.1 - - CMakeLists.txt | 2 +- - NEWS | 12 ++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - qt5/src/Doxyfile | 2 +- - 6 files changed, 17 insertions(+), 5 deletions(-) - -commit 93373cd113d046b65538fe983b46842d689a2112 -Author: Albert Astals Cid -Date: Sun May 11 18:31:10 2014 +0200 - - Qt: Add a new page->annotations() call that let's you specify subtypes - - This way we don't return annotations you may not be interested in - - qt4/src/poppler-annotation-private.h | 4 +-- - qt4/src/poppler-annotation.cc | 48 - ++++++++++++++++++++++++++++++++++-- - qt4/src/poppler-page.cc | 7 +++++- - qt4/src/poppler-qt4.h | 14 +++++++++++ - qt5/src/poppler-annotation-private.h | 4 +-- - qt5/src/poppler-annotation.cc | 48 - ++++++++++++++++++++++++++++++++++-- - qt5/src/poppler-page.cc | 7 +++++- - qt5/src/poppler-qt5.h | 15 +++++++++++ - 8 files changed, 137 insertions(+), 10 deletions(-) - -commit d2892cd893e4379914a08e66682ed5c423743a41 -Merge: 0844220 7e9fc61 -Author: Albert Astals Cid -Date: Wed May 7 22:27:41 2014 +0200 - - Merge remote-tracking branch 'origin/poppler-0.26' - -commit 7e9fc61e287889eefd6b08ef5991d31fed79cafd -Author: Albert Astals Cid -Date: Wed May 7 22:25:59 2014 +0200 - - Fix libopenjpeg 1.5 detection on some systems - - Someone somewhere decided the pc file will be called libopenjpeg1 - instead of libopenjpeg - - Bug #78389 - - configure.ac | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 0844220347f984c3d9b04fe53e690ee0e8c74afe -Merge: 84278d8 0a6c1ff -Author: Albert Astals Cid -Date: Wed May 7 21:56:07 2014 +0200 - - Merge remote-tracking branch 'origin/poppler-0.26' - -commit 0a6c1ff777aa23c7a5654b313b639e66600883b9 -Author: Thomas Freitag -Date: Wed May 7 21:54:46 2014 +0200 - - Only add annotations of the current page when splitting - - Bug #77549 - - poppler/PDFDoc.cc | 153 - +++++++++++++++++++++++++++++++++++++++++++++++++++++- - poppler/PDFDoc.h | 4 +- - utils/pdfunite.cc | 9 +++- - 3 files changed, 162 insertions(+), 4 deletions(-) - -commit 84278d8adbb1f6e9a28588fcb4db30c9ef70adde -Merge: 7b94b11 5b2cdef -Author: Albert Astals Cid -Date: Sun May 4 22:21:25 2014 +0200 - - Merge remote-tracking branch 'origin/poppler-0.26' - -commit 5b2cdef49a8a0a92fd323fbe45841a5098a42ece -Author: Olly Betts -Date: Sun May 4 22:20:30 2014 +0200 - - Fix extraction of text in some files - - Bug #78145 - - poppler/GfxFont.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 7b94b119f07713af7b8b9f1ac3ea3f1d35c1e240 -Merge: c859d2b bae836c -Author: Albert Astals Cid -Date: Sun May 4 16:21:24 2014 +0200 - - Merge remote-tracking branch 'origin/poppler-0.26' - -commit bae836cd3dd3511ca9cf4745626142334bafd1a6 -Author: Marek Kasik -Date: Sun May 4 16:20:33 2014 +0200 - - Use field value V for radio buttons - - Turn on radio button only if its appearance state is equal to - the value - of name object "V" of the field. - - Bug #75979 - - poppler/Annot.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit a748b3a059938e6ae98b51eb82bab7c33a5e23c7 -Author: Carlos Garcia Campos -Date: Wed Apr 30 09:25:31 2014 +0200 - - glib: Fix multiple definition of PopplerTextSpan - - https://bugs.freedesktop.org/show_bug.cgi?id=78103 - - glib/poppler-structure-element.h | 3 --- - 1 file changed, 3 deletions(-) - -commit c859d2b891a115c79d04db14463791dfb1c46a20 -Author: Carlos Garcia Campos -Date: Wed Apr 30 09:25:31 2014 +0200 - - glib: Fix multiple definition of PopplerTextSpan - - https://bugs.freedesktop.org/show_bug.cgi?id=78103 - - glib/poppler-structure-element.h | 3 --- - 1 file changed, 3 deletions(-) - -commit 9a68daee2b3c7f8a992ee47c0e9ac78b346d4348 -Author: Albert Astals Cid -Date: Fri Apr 25 01:01:08 2014 +0200 - - 0.26.0 - - CMakeLists.txt | 4 ++-- - NEWS | 13 +++++++++++++ - configure.ac | 4 ++-- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - qt5/src/Doxyfile | 2 +- - 6 files changed, 20 insertions(+), 7 deletions(-) - -commit 8073852c84b71257d487aa8a46e441aa82f4b42c -Author: Fabio D'Urso -Date: Mon Apr 14 23:35:50 2014 +0200 - - qt: Fix missing ! in TextAnnotation::setInplaceIntent - - CID #16814 - - qt4/src/poppler-annotation.cc | 2 +- - qt5/src/poppler-annotation.cc | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 1fbf98664c0879ac035a63602242a910c0c1d316 -Author: Albert Astals Cid -Date: Mon Apr 14 11:53:59 2014 +0200 - - Initialize tmpBufLen - - CID #16957 - - It isn't really needed since locateFont always returns a fontLoc - with a non null - path if fontLoc itself is not null, but it doesn't hurt either - - qt4/src/ArthurOutputDev.cc | 4 ++-- - qt5/src/ArthurOutputDev.cc | 4 ++-- - 2 files changed, 4 insertions(+), 4 deletions(-) - -commit b3e5c582a279b1b8d8309322ac3f4d0e51831f77 -Author: Albert Astals Cid -Date: Thu Apr 10 23:38:09 2014 +0200 - - Remove unused member - - cpp/poppler-font.cpp | 2 -- - 1 file changed, 2 deletions(-) - -commit b86f471c43e387cf873358cf3cbcd27470646713 -Author: Albert Astals Cid -Date: Thu Apr 10 22:50:56 2014 +0200 - - 0.25.3 - - CMakeLists.txt | 2 +- - NEWS | 19 +++++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/CairoOutputDev.cc | 2 +- - poppler/GfxFont.cc | 2 +- - qt4/src/Doxyfile | 2 +- - qt4/src/poppler-optcontent.cc | 2 +- - qt5/src/Doxyfile | 2 +- - qt5/src/poppler-optcontent.cc | 2 +- - qt5/src/poppler-private.cc | 2 +- - qt5/src/poppler-private.h | 2 +- - 12 files changed, 30 insertions(+), 11 deletions(-) - -commit 80107c72ac03bf4d00b2d71d6f947c139ea84ab5 -Author: Pino Toscano -Date: Sun Apr 6 20:17:31 2014 +0200 - - qt5: remove m_fontInfoIterator from Document - - it was used by the deprecated scanForFonts API, which was not provided - in poppler-qt5 - - qt5/src/poppler-private.cc | 2 -- - qt5/src/poppler-private.h | 2 -- - 2 files changed, 4 deletions(-) - -commit b8325316e41fb03eb5fac5c80d6a550fe9ce9695 -Author: Albert Astals Cid -Date: Sun Apr 6 16:05:51 2014 +0200 - - Fix memory leak - - CID #16943 - - utils/pdfseparate.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit ca9713118d6ce3fdd245f9ca4f595229a5be19c3 -Author: Albert Astals Cid -Date: Sun Apr 6 15:59:43 2014 +0200 - - Don't check twice for the same variable ^_^ - - CID #16804 - - splash/Splash.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 0ef290a7c5a8fa54d3fe0f646abdf098443a7a67 -Author: Albert Astals Cid -Date: Sun Apr 6 15:57:38 2014 +0200 - - Fix memory leak - - CID #16852 - - splash/Splash.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 8810b8917fded340b784873a91ca025b0bb49f3d -Author: Albert Astals Cid -Date: Sun Apr 6 15:49:18 2014 +0200 - - Fix Out-of-bounds read - - CID #16844 - - poppler/PageLabelInfo_p.h | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -commit 9309907673e8557a25021dce79d9b4354640e2d0 -Author: Albert Astals Cid -Date: Sun Apr 6 15:35:00 2014 +0200 - - Fix memory leak - - Don't pass new'ed GooStrings as parameters to error() - - CID #16915 - - poppler/GfxFont.cc | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit a511005584a38217fed582ced6ce2c937526cf96 -Author: Albert Astals Cid -Date: Sun Apr 6 15:28:50 2014 +0200 - - Fix Uninitialized pointer read when nFucnsA is 0 - - CID #16965 - - poppler/GfxState.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 26b961a64030d91c5db2769dcd0ab8dff7b9b6a6 -Author: Albert Astals Cid -Date: Sun Apr 6 15:23:35 2014 +0200 - - gfree -> delete since it was new'ed - - CID #16786 - - poppler/JBIG2Stream.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 814ac2230b594cce3b871588804dd92f4a187e7e -Author: Albert Astals Cid -Date: Sun Apr 6 15:22:13 2014 +0200 - - delete -> gfree since it was gmaloced - - CID #16785 - - poppler/JBIG2Stream.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit b496b6665803247b10b018ae939a2a452fa4a48f -Author: Albert Astals Cid -Date: Sun Apr 6 15:17:50 2014 +0200 - - Fix memory leak - - CID #16864 - - poppler/SplashOutputDev.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 1b612f355e9f29fa93c15a9de1188049a8e086b6 -Author: Albert Astals Cid -Date: Sun Apr 6 15:14:50 2014 +0200 - - Fix memory leak - - CID #16853 - - poppler/XRef.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 07621ebbda8ab85cf4cd76a6092efc67aa14454d -Merge: 8d3a2c9 9fcd46a -Author: Pino Toscano -Date: Sat Apr 5 15:49:31 2014 +0200 - - Merge remote-tracking branch 'origin/poppler-0.24' - -commit 9fcd46ac4a94f138981ec5afaab3875918c6a175 -Author: Pino Toscano -Date: Sat Apr 5 15:48:27 2014 +0200 - - qt4/qt5: remove extra qDebug - - qt4/src/poppler-optcontent.cc | 1 - - qt5/src/poppler-optcontent.cc | 1 - - 2 files changed, 2 deletions(-) - -commit 37286ee2923de060ae463ac6b178ffd0e6096b90 -Author: Pino Toscano -Date: Sat Apr 5 15:46:44 2014 +0200 - - qt4/qt5: fix some kinds of OCG models - - properly pass parent and child when building the tree - - qt4/src/poppler-optcontent.cc | 2 +- - qt5/src/poppler-optcontent.cc | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 8d3a2c9d007052bcb8719200760a1abb6314f804 -Author: Peter Breitenlohner -Date: Sun Mar 30 23:34:23 2014 +0200 - - Avoid MinGW/Cygwin warnings due to redefinition of NOMINMAX - - goo/GooMutex.h | 3 +++ - goo/GooTimer.h | 5 ++++- - goo/gfile.h | 5 ++++- - poppler/XpdfPluginAPI.h | 3 +++ - 4 files changed, 14 insertions(+), 2 deletions(-) - -commit 38dcaf96f308265ff6958e4683bcec2be0c254b9 -Author: Adrian Johnson -Date: Fri Mar 28 20:49:17 2014 +1030 - - cairo: fix segv cause by bad image stream - - bug 76445 - - poppler/CairoOutputDev.cc | 10 +++++++++- - 1 file changed, 9 insertions(+), 1 deletion(-) - -commit 07b0a038b194eb0392a1e9a4236064d37247d687 -Author: Jakub Wilk -Date: Sun Mar 30 16:12:28 2014 +0200 - - pdftohtml: Fix typo in manpage - - utils/pdftohtml.1 | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ac3c8303396a0b8de5e4ad32f480b8da5f3b396e -Author: Thomas Liebetraut -Date: Sun Mar 30 12:25:26 2014 +0200 - - glib: Fix the first coord of the qudrilateral in - create_poppler_quads_from_annot_quads() - - https://bugs.freedesktop.org/show_bug.cgi?id=76504 - - glib/poppler-annot.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 82d69da7c2f67e774c51fb7b146fdf639a6b9616 -Author: Albert Astals Cid -Date: Fri Mar 28 15:53:22 2014 +0100 - - Fix error reported by ASAN in 3628.asan.0.3910.pdf - - ==20743== ERROR: AddressSanitizer: heap-buffer-overflow on - address 0x60040005c6ef at pc 0x7f8912ca0c90 bp 0x7fff8509ee20 sp - 0x7fff8509ee18 - READ of size 1 at 0x60040005c6ef thread T0 - #0 0x7f8912ca0c8f in expandRow(unsigned char*, unsigned char*, - int, int, int) /home/tsdgeos/devel/poppler/splash/Splash.cc:4855 - #1 0x7f8912ca1097 in Splash::scaleImageYuXuBilinear(bool - (*)(void*, unsigned char*, unsigned char*), void*, - SplashColorMode, int, bool, int, int, int, int, SplashBitmap*) - /home/tsdgeos/devel/poppler/splash/Splash.cc:4897 - #2 0x7f8912c9d2b7 in Splash::scaleImage(bool - (*)(void*, unsigned char*, unsigned char*), void*, - SplashColorMode, int, bool, int, int, int, int, bool, bool) - /home/tsdgeos/devel/poppler/splash/Splash.cc:4127 - #3 0x7f8912c98101 in Splash::drawImage(bool - (*)(void*, unsigned char*, unsigned char*), void*, - SplashColorMode, bool, int, int, double*, bool, bool) - /home/tsdgeos/devel/poppler/splash/Splash.cc:3726 - #4 0x7f8912c7056a in - SplashOutputDev::drawSoftMaskedImage(GfxState*, - Object*, Stream*, int, int, GfxImageColorMap*, - bool, Stream*, int, int, GfxImageColorMap*, bool) - /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:3630 - #5 0x7f8912ac7aa7 in Gfx::doImage(Object*, Stream*, bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4646 - #6 0x7f8912ac4de0 in Gfx::opXObject(Object*, int) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4179 - #7 0x7f8912a9f33a in Gfx::execOp(Object*, Object*, int) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:903 - #8 0x7f8912a9e50f in Gfx::go(bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:762 - #9 0x7f8912a9e163 in Gfx::display(Object*, bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:728 - #10 0x7f8912b80e13 in Page::displaySlice(OutputDev*, double, - double, int, bool, bool, int, int, int, int, bool, bool - (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/Page.cc:585 - #11 0x7f8912b8833f in PDFDoc::displayPageSlice(OutputDev*, - int, double, double, int, bool, bool, bool, int, int, int, int, - bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 - #12 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, - int, int, int, int, int, double, double, char*) - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 - #13 0x404416 in main - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 - #14 0x7f89121a8ec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) - #15 0x401d58 in _start - (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) - - splash/Splash.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 38ec8cbeeaf69d96b9d7bcd662187c8916cf7903 -Author: Albert Astals Cid -Date: Fri Mar 28 11:18:02 2014 +0100 - - Fix error reported by ASAN in 5782.asan.0.7113.pdf - - ==32161== ERROR: AddressSanitizer: heap-buffer-overflow on - address 0x6008000e3bcf at pc 0x7f66bae0e117 bp 0x7fffcb54ea70 sp - 0x7fffcb54ea68 - READ of size 1 at 0x6008000e3bcf thread T0 - #0 0x7f66bae0e116 in GooString::getChar(int) - /home/tsdgeos/devel/poppler/goo/GooString.h:119 - #1 0x7f66bafb5dca in LinkURI::LinkURI(Object*, GooString*) - /home/tsdgeos/devel/poppler/poppler/Link.cc:562 - #2 0x7f66bafb2a05 in LinkAction::parseAction(Object*, GooString*) - /home/tsdgeos/devel/poppler/poppler/Link.cc:98 - #3 0x7f66bae69c0e in AnnotLink::initialize(PDFDoc*, Dict*) - /home/tsdgeos/devel/poppler/poppler/Annot.cc:2621 - #4 0x7f66bae698d9 in AnnotLink::AnnotLink(PDFDoc*, Dict*, Object*) - /home/tsdgeos/devel/poppler/poppler/Annot.cc:2596 - #5 0x7f66bae8d998 in Annots::createAnnot(Dict*, Object*) - /home/tsdgeos/devel/poppler/poppler/Annot.cc:6737 - #6 0x7f66bae8d269 in Annots::Annots(PDFDoc*, int, Object*) - /home/tsdgeos/devel/poppler/poppler/Annot.cc:6683 - #7 0x7f66bafc750d in Page::getAnnots(XRef*) - /home/tsdgeos/devel/poppler/poppler/Page.cc:402 - #8 0x7f66bafc8e66 in Page::displaySlice(OutputDev*, double, - double, int, bool, bool, int, int, int, int, bool, bool - (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/Page.cc:595 - #9 0x7f66bafd02fd in PDFDoc::displayPageSlice(OutputDev*, int, - double, double, int, bool, bool, bool, int, int, int, int, - bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 - #10 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, - int, int, int, int, int, double, double, char*) - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 - #11 0x404416 in main - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 - #12 0x7f66ba5f0ec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) - #13 0x401d58 in _start - (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) - - poppler/Link.cc | 10 ++++++---- - 1 file changed, 6 insertions(+), 4 deletions(-) - -commit 49b4eb68ee646aefe49b70f9e2831ebf93576053 -Author: Albert Astals Cid -Date: Fri Mar 28 11:08:18 2014 +0100 - - Fix error reported by ASAN in 590.asan.0.7288.pdf - - ==31898== ERROR: AddressSanitizer: heap-use-after-free on - address 0x60ae0007432c at pc 0x7f03483026aa bp 0x7fff6ec0c820 sp - 0x7fff6ec0c818 - READ of size 4 at 0x60ae0007432c thread T0 - #0 0x7f03483026a9 in SplashFTFont::getGlyphPath(int) - /home/tsdgeos/devel/poppler/splash/SplashFTFont.cc:414 - #1 0x7f034829f681 in SplashOutputDev::drawChar(GfxState*, - double, double, double, double, double, - double, unsigned int, int, unsigned int*, int) - /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:2239 - #2 0x7f0348100599 in Gfx::doShowText(GooString*) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4054 - #3 0x7f03480fddb0 in Gfx::opShowSpaceText(Object*, int) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:3886 - #4 0x7f03480dc33a in Gfx::execOp(Object*, Object*, int) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:903 - #5 0x7f03480db50f in Gfx::go(bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:762 - #6 0x7f03480db163 in Gfx::display(Object*, bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:728 - #7 0x7f03481bddd1 in Page::displaySlice(OutputDev*, double, - double, int, bool, bool, int, int, int, int, bool, bool - (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/Page.cc:585 - #8 0x7f03481c52fd in PDFDoc::displayPageSlice(OutputDev*, int, - double, double, int, bool, bool, bool, int, int, int, int, - bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 - #9 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, - int, int, int, int, int, double, double, char*) - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 - #10 0x404416 in main - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 - #11 0x7f03477e5ec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) - #12 0x401d58 in _start - (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) - - splash/SplashFTFont.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 89a64b508e5f8445798c95fcec6c87180f6c9b73 -Author: Albert Astals Cid -Date: Fri Mar 28 00:35:17 2014 +0100 - - Fix error reported by ASAN in 2279.asan.0.1904.pdf - - ==20507== ERROR: AddressSanitizer: heap-buffer-overflow on - address 0x60420000ff04 at pc 0x7fa1492e8012 bp 0x7fff8406d900 sp - 0x7fff8406d8f8 - READ of size 4 at 0x60420000ff04 thread T0 - #0 0x7fa1492e8011 in SplashFTFont::makeGlyph(int, int, int, - SplashGlyphBitmap*, int, int, SplashClip*, SplashClipResult*) - /home/tsdgeos/devel/poppler/splash/SplashFTFont.cc:284 - #1 0x7fa1492eda32 in SplashFont::getGlyph(int, int, int, - SplashGlyphBitmap*, int, int, SplashClip*, SplashClipResult*) - /home/tsdgeos/devel/poppler/splash/SplashFont.cc:168 - #2 0x7fa1492e7c69 in SplashFTFont::getGlyph(int, int, int, - SplashGlyphBitmap*, int, int, SplashClip*, SplashClipResult*) - /home/tsdgeos/devel/poppler/splash/SplashFTFont.cc:233 - #3 0x7fa1492b3368 in Splash::fillChar(double, double, int, - SplashFont*) /home/tsdgeos/devel/poppler/splash/Splash.cc:2714 - #4 0x7fa149286a20 in SplashOutputDev::drawChar(GfxState*, - double, double, double, double, double, - double, unsigned int, int, unsigned int*, int) - /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:2270 - #5 0x7fa1490e7599 in Gfx::doShowText(GooString*) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4054 - #6 0x7fa1490e4db0 in Gfx::opShowSpaceText(Object*, int) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:3886 - #7 0x7fa1490c333a in Gfx::execOp(Object*, Object*, int) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:903 - #8 0x7fa1490c250f in Gfx::go(bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:762 - #9 0x7fa1490c2163 in Gfx::display(Object*, bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:728 - #10 0x7fa1491a4dd1 in Page::displaySlice(OutputDev*, double, - double, int, bool, bool, int, int, int, int, bool, bool - (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/Page.cc:585 - #11 0x7fa1491ac2fd in PDFDoc::displayPageSlice(OutputDev*, - int, double, double, int, bool, bool, bool, int, int, int, int, - bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 - #12 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, - int, int, int, int, int, double, double, char*) - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 - #13 0x404416 in main - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 - #14 0x7fa1487ccec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) - #15 0x401d58 in _start - (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) - - splash/SplashFTFont.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 5055479634dc8d0cd5afb3373de600fb121357fe -Author: Albert Astals Cid -Date: Thu Mar 27 23:54:20 2014 +0100 - - Fix error reported by ASAN in 2010.asan.0.1506.pdf - - ==18859== ERROR: AddressSanitizer: unknown-crash on address - 0x7f1e4a6beb50 at pc 0x7f1e5557444d bp 0x7fff6af3c340 sp - 0x7fff6af3bb00 - WRITE of size 442216446 at 0x7f1e4a6beb50 thread T0 - #0 0x7f1e5557444c (/usr/lib/x86_64-linux-gnu/libasan.so.0+0xe44c) - #1 0x7f1e550e04ff in SplashFont::getGlyph(int, int, int, - SplashGlyphBitmap*, int, int, SplashClip*, SplashClipResult*) - /home/tsdgeos/devel/poppler/splash/SplashFont.cc:206 - #2 0x7f1e550d9c69 in SplashFTFont::getGlyph(int, int, int, - SplashGlyphBitmap*, int, int, SplashClip*, SplashClipResult*) - /home/tsdgeos/devel/poppler/splash/SplashFTFont.cc:233 - #3 0x7f1e550a5368 in Splash::fillChar(double, double, int, - SplashFont*) /home/tsdgeos/devel/poppler/splash/Splash.cc:2714 - #4 0x7f1e55078a20 in SplashOutputDev::drawChar(GfxState*, - double, double, double, double, double, - double, unsigned int, int, unsigned int*, int) - /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:2270 - #5 0x7f1e54ed9599 in Gfx::doShowText(GooString*) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4054 - #6 0x7f1e54ed6db0 in Gfx::opShowSpaceText(Object*, int) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:3886 - #7 0x7f1e54eb533a in Gfx::execOp(Object*, Object*, int) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:903 - #8 0x7f1e54eb450f in Gfx::go(bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:762 - #9 0x7f1e54eb4163 in Gfx::display(Object*, bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:728 - #10 0x7f1e54f96dd1 in Page::displaySlice(OutputDev*, double, - double, int, bool, bool, int, int, int, int, bool, bool - (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/Page.cc:585 - #11 0x7f1e54f9e2fd in PDFDoc::displayPageSlice(OutputDev*, - int, double, double, int, bool, bool, bool, int, int, int, int, - bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 - #12 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, - int, int, int, int, int, double, double, char*) - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 - #13 0x404416 in main - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 - #14 0x7f1e545beec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) - #15 0x401d58 in _start - (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) - - splash/SplashFont.cc | 13 +++++++++---- - 1 file changed, 9 insertions(+), 4 deletions(-) - -commit 3e7779935ec2610410bc4a42e9b0174e41ca9672 -Author: Albert Astals Cid -Date: Thu Mar 27 16:49:57 2014 +0100 - - Fix error reported by ASAN in 139.asan.0.581.pdf - - ==15244== ERROR: AddressSanitizer: SEGV on unknown address - 0x605df000f3ee (pc 0x7f1087b3a22e sp 0x7fffec30ff20 bp 0x7fffec30ff80 - T0) - AddressSanitizer can not provide additional info. - #0 0x7f1087b3a22d - (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x48f22d) - #1 0x7f1087b19d92 - (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x46ed92) - #2 0x7f1087ae570b - (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x43a70b) - #3 0x7f1087ae4061 - (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x439061) - #4 0x7f1087ab9b38 - (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x40eb38) - #5 0x7f1087900989 - (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x255989) - #6 0x7f10878f733a - (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x24c33a) - #7 0x7f10878f650f - (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x24b50f) - #8 0x7f10878f6163 - (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x24b163) - #9 0x7f10879d8dd1 - (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x32ddd1) - #10 0x7f10879e02fd - (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x3352fd) - #11 0x40311e - (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x40311e) - #12 0x404416 - (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x404416) - #13 0x7f1087000ec4 (/lib/x86_64-linux-gnu/libc-2.19.so+0x21ec4) - #14 0x401d58 - (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) - - splash/SplashXPathScanner.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 23ad7fa5253a4fec6543d1435827aa1b59b62ced -Author: Albert Astals Cid -Date: Thu Mar 27 01:14:05 2014 +0100 - - 0.25.2 - - CMakeLists.txt | 4 ++-- - NEWS | 48 - +++++++++++++++++++++++++++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - gtk-doc.make | 33 +++++++++++++++++++--------- - m4/gtk-doc.m4 | 47 - +++++++++++++++++++++++++++------------- - poppler/CairoOutputDev.h | 2 +- - poppler/Hints.cc | 2 +- - poppler/Makefile.am | 2 +- - poppler/PSOutputDev.cc | 3 ++- - poppler/PSOutputDev.h | 2 +- - poppler/StructElement.cc | 2 +- - poppler/StructElement.h | 2 +- - poppler/StructTreeRoot.cc | 2 +- - poppler/StructTreeRoot.h | 2 +- - qt4/src/CMakeLists.txt | 2 +- - qt4/src/Doxyfile | 2 +- - qt4/src/Makefile.am | 2 +- - qt4/src/poppler-ps-converter.cc | 1 + - qt5/src/CMakeLists.txt | 2 +- - qt5/src/Doxyfile | 2 +- - qt5/src/Makefile.am | 2 +- - qt5/src/poppler-ps-converter.cc | 1 + - utils/pdftocairo.cc | 2 +- - utils/pdftops.cc | 1 + - 25 files changed, 127 insertions(+), 45 deletions(-) - -commit ec2f8bca9f48935d3180dab65ef2ca455a893afd -Author: Albert Astals Cid -Date: Wed Mar 26 18:38:13 2014 +0100 - - Fix overflow malloc - - poppler/Stream.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 322e416451b7b33cba8fb3d4702207693c3c7921 -Author: Albert Astals Cid -Date: Wed Mar 26 17:58:48 2014 +0100 - - Fix error reported by ASAN in 1195.asan.0.293.pdf - - ==31060== ERROR: AddressSanitizer: heap-buffer-overflow on - address 0x60040002a215 at pc 0x7f5614cd96c4 bp 0x7fff54a44050 sp - 0x7fff54a44048 - READ of size 1 at 0x60040002a215 thread T0 - #0 0x7f5614cd96c3 in JBIG2Stream::readGenericBitmap(bool, - int, int, int, bool, bool, JBIG2Bitmap*, int*, int*, int) - /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:3389 - #1 0x7f5614cce0e7 in JBIG2Stream::readSymbolDictSeg(unsigned - int, unsigned int, unsigned int*, unsigned int) - /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:1867 - #2 0x7f5614ccb8fe in JBIG2Stream::readSegments() - /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:1408 - #3 0x7f5614cca72e in JBIG2Stream::reset() - /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:1248 - #4 0x7f5614d1648b in ImageStream::reset() - /home/tsdgeos/devel/poppler/poppler/Stream.cc:484 - #5 0x7f5614de6578 in SplashOutputDev::drawImage(GfxState*, - Object*, Stream*, int, int, GfxImageColorMap*, bool, int*, bool) - /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:3158 - #6 0x7f5614c41d64 in Gfx::doImage(Object*, Stream*, bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4653 - #7 0x7f5614c3ede0 in Gfx::opXObject(Object*, int) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4179 - #8 0x7f5614c1933a in Gfx::execOp(Object*, Object*, int) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:903 - #9 0x7f5614c1850f in Gfx::go(bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:762 - #10 0x7f5614c18163 in Gfx::display(Object*, bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:728 - #11 0x7f5614cfae27 in Page::displaySlice(OutputDev*, double, - double, int, bool, bool, int, int, int, int, bool, bool - (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/Page.cc:585 - #12 0x7f5614d02353 in PDFDoc::displayPageSlice(OutputDev*, - int, double, double, int, bool, bool, bool, int, int, int, int, - bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 - #13 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, - int, int, int, int, int, double, double, char*) - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 - #14 0x404416 in main - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 - #15 0x7f5614322ec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) - #16 0x401d58 in _start - (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) - - poppler/JBIG2Stream.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 225232f6f070d17d8570108ffe39ffd4350fc6e8 -Author: Albert Astals Cid -Date: Wed Mar 26 15:00:09 2014 +0100 - - Fix error reported by ASAN in 6609.asan.0.8343.pdf - - ==8470== ERROR: AddressSanitizer: heap-buffer-overflow on - address 0x7f3b12f7b5e1 at pc 0x7f3b0f915f5e bp 0x7fff47842de0 sp - 0x7fff47842dd8 - READ of size 1 at 0x7f3b12f7b5e1 thread T0 - #0 0x7f3b0f915f5d in JBIG2Stream::readGenericBitmap(bool, - int, int, int, bool, bool, JBIG2Bitmap*, int*, int*, int) - /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:3628 - #1 0x7f3b0f910558 in JBIG2Stream::readGenericRegionSeg(unsigned - int, bool, bool, unsigned int) - /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:2849 - #2 0x7f3b0f906b33 in JBIG2Stream::readSegments() - /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:1443 - #3 0x7f3b0f90572e in JBIG2Stream::reset() - /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:1248 - #4 0x7f3b0f951459 in ImageStream::reset() - /home/tsdgeos/devel/poppler/poppler/Stream.cc:484 - #5 0x7f3b0fa21546 in SplashOutputDev::drawImage(GfxState*, - Object*, Stream*, int, int, GfxImageColorMap*, bool, int*, bool) - /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:3158 - #6 0x7f3b0f87cd64 in Gfx::doImage(Object*, Stream*, bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4653 - #7 0x7f3b0f879de0 in Gfx::opXObject(Object*, int) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4179 - #8 0x7f3b0f85433a in Gfx::execOp(Object*, Object*, int) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:903 - #9 0x7f3b0f85350f in Gfx::go(bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:762 - #10 0x7f3b0f853163 in Gfx::display(Object*, bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:728 - #11 0x7f3b0f935df5 in Page::displaySlice(OutputDev*, double, - double, int, bool, bool, int, int, int, int, bool, bool - (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/Page.cc:585 - #12 0x7f3b0f93d321 in PDFDoc::displayPageSlice(OutputDev*, - int, double, double, int, bool, bool, bool, int, int, int, int, - bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 - #13 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, - int, int, int, int, int, double, double, char*) - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 - #14 0x404416 in main - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 - #15 0x7f3b0ef5dec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) - #16 0x401d58 in _start - (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) - - poppler/JBIG2Stream.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 216890f1f147b25643e0d6e18e361d4d34b6c332 -Author: Albert Astals Cid -Date: Wed Mar 26 12:19:42 2014 +0100 - - Fix error reported by ASAN in 6760.asan.0.8568.pdf - - ==26566== ERROR: AddressSanitizer: SEGV on unknown address - 0x7fffbc3e5ea8 (pc 0x7fe1fa858db1 sp 0x7fffc788eb30 bp 0x7fffc788eb40 - T0) - AddressSanitizer can not provide additional info. - #0 0x7fe1fa858db0 in PSStack::index(int) - /home/tsdgeos/devel/poppler/poppler/Function.cc:1067 - #1 0x7fe1fa856fd6 in PostScriptFunction::exec(PSStack*, int) - /home/tsdgeos/devel/poppler/poppler/Function.cc:1621 - #2 0x7fe1fa854c10 in PostScriptFunction::transform(double*, - double*) /home/tsdgeos/devel/poppler/poppler/Function.cc:1266 - #3 0x7fe1fa854097 in - PostScriptFunction::PostScriptFunction(Object*, Dict*) - /home/tsdgeos/devel/poppler/poppler/Function.cc:1216 - #4 0x7fe1fa84a0c2 in Function::parse(Object*, - std::set, std::allocator >*) - /home/tsdgeos/devel/poppler/poppler/Function.cc:98 - #5 0x7fe1fa849e3c in Function::parse(Object*) - /home/tsdgeos/devel/poppler/poppler/Function.cc:63 - #6 0x7fe1fa8c1d8c in GfxDeviceNColorSpace::parse(Array*, - OutputDev*, GfxState*, int) - /home/tsdgeos/devel/poppler/poppler/GfxState.cc:2978 - #7 0x7fe1fa8a6fb7 in GfxColorSpace::parse(Object*, - OutputDev*, GfxState*, int) - /home/tsdgeos/devel/poppler/poppler/GfxState.cc:328 - #8 0x7fe1fa88440f in Gfx::doImage(Object*, Stream*, bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4403 - #9 0x7fe1fa882d6c in Gfx::opXObject(Object*, int) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4179 - #10 0x7fe1fa85d2c6 in Gfx::execOp(Object*, Object*, int) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:903 - #11 0x7fe1fa85c49b in Gfx::go(bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:762 - #12 0x7fe1fa85c0ef in Gfx::display(Object*, bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:728 - #13 0x7fe1fa93ed81 in Page::displaySlice(OutputDev*, double, - double, int, bool, bool, int, int, int, int, bool, bool - (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/Page.cc:585 - #14 0x7fe1fa9462ad in PDFDoc::displayPageSlice(OutputDev*, - int, double, double, int, bool, bool, bool, int, int, int, int, - bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 - #15 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, - int, int, int, int, int, double, double, char*) - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 - #16 0x404416 in main - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 - #17 0x7fe1f9f66ec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) - #18 0x401d58 in _start - (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) - - poppler/Function.cc | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -commit fb7d91435c71603697b652c70cfa76dd595ee200 -Author: Albert Astals Cid -Date: Wed Mar 26 12:08:52 2014 +0100 - - Fix ASAN in 750.asan.0.9621.pdf - - ==25876== ERROR: AddressSanitizer: heap-buffer-overflow on - address 0x60040002a10f at pc 0x7fc396c3c23e bp 0x7ffff1123d20 sp - 0x7ffff1123d18 - READ of size 1 at 0x60040002a10f thread T0 - #0 0x7fc396c3c23d in JBIG2Stream::readGenericBitmap(bool, - int, int, int, bool, bool, JBIG2Bitmap*, int*, int*, int) - /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:3504 - #1 0x7fc396c30073 in JBIG2Stream::readSymbolDictSeg(unsigned - int, unsigned int, unsigned int*, unsigned int) - /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:1867 - #2 0x7fc396c2d88a in JBIG2Stream::readSegments() - /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:1408 - #3 0x7fc396c2c6ba in JBIG2Stream::reset() - /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:1248 - #4 0x7fc396c783f7 in ImageStream::reset() - /home/tsdgeos/devel/poppler/poppler/Stream.cc:484 - #5 0x7fc396d484e4 in SplashOutputDev::drawImage(GfxState*, - Object*, Stream*, int, int, GfxImageColorMap*, bool, int*, bool) - /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:3158 - #6 0x7fc396ba3cf0 in Gfx::doImage(Object*, Stream*, bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4653 - #7 0x7fc396ba0d6c in Gfx::opXObject(Object*, int) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4179 - #8 0x7fc396b7b2c6 in Gfx::execOp(Object*, Object*, int) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:903 - #9 0x7fc396b7a49b in Gfx::go(bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:762 - #10 0x7fc396b7a0ef in Gfx::display(Object*, bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:728 - #11 0x7fc396c5cd93 in Page::displaySlice(OutputDev*, double, - double, int, bool, bool, int, int, int, int, bool, bool - (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/Page.cc:585 - #12 0x7fc396c642bf in PDFDoc::displayPageSlice(OutputDev*, - int, double, double, int, bool, bool, bool, int, int, int, int, - bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 - #13 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, - int, int, int, int, int, double, double, char*) - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 - #14 0x404416 in main - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 - #15 0x7fc396284ec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) - #16 0x401d58 in _start - (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) - - poppler/JBIG2Stream.cc | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -commit 9002b3b7cbbbc5802abfa8383ded2093a29d1746 -Author: Albert Astals Cid -Date: Wed Mar 26 00:48:15 2014 +0100 - - Fix ASAN in 784.asan.0.9671.pdf - - ================================================================= - ==24856== ERROR: AddressSanitizer: SEGV on unknown address - 0x603bfffe5804 (pc 0x7f7aa3310c6b sp 0x7fff0e656bd0 bp 0x7fff0e656e90 - T0) - AddressSanitizer can not provide additional info. - #0 0x7f7aa3310c6a in - GfxIndexedColorSpace::mapColorToBase(GfxColor*, GfxColor*) - /home/tsdgeos/devel/poppler/poppler/GfxState.cc:2509 - #1 0x7f7aa33110d2 in GfxIndexedColorSpace::getRGB(GfxColor*, - GfxRGB*) /home/tsdgeos/devel/poppler/poppler/GfxState.cc:2529 - #2 0x7f7aa3466712 in convertGfxColor(unsigned - char*, SplashColorMode, GfxColorSpace*, GfxColor*) - /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:117 - #3 0x7f7aa34675a9 in SplashUnivariatePattern::getColor(int, - int, unsigned char*) - /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:215 - #4 0x7f7aa348d2a2 in Splash::pipeRun(SplashPipe*) - /home/tsdgeos/devel/poppler/splash/Splash.cc:363 - #5 0x7f7aa34c9c29 in Splash::drawAALine(SplashPipe*, - int, int, int, bool, unsigned char) - /home/tsdgeos/devel/poppler/splash/Splash.cc:1537 - #6 0x7f7aa34c4787 in Splash::shadedFill(SplashPath*, bool, - SplashPattern*) /home/tsdgeos/devel/poppler/splash/Splash.cc:6388 - #7 0x7f7aa348b65c in - SplashOutputDev::univariateShadedFill(GfxState*, - SplashUnivariatePattern*, double, double) - /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:4408 - #8 0x7f7aa348b93d in SplashOutputDev::radialShadedFill(GfxState*, - GfxRadialShading*, double, double) - /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:4427 - #9 0x7f7aa32c7574 in Gfx::doRadialShFill(GfxRadialShading*) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:3058 - #10 0x7f7aa32c188f in Gfx::opShFill(Object*, int) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:2476 - #11 0x7f7aa32b12c6 in Gfx::execOp(Object*, Object*, int) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:903 - #12 0x7f7aa32b049b in Gfx::go(bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:762 - #13 0x7f7aa32b00ef in Gfx::display(Object*, bool) - /home/tsdgeos/devel/poppler/poppler/Gfx.cc:728 - #14 0x7f7aa3392dc9 in Page::displaySlice(OutputDev*, double, - double, int, bool, bool, int, int, int, int, bool, bool - (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/Page.cc:585 - #15 0x7f7aa339a2f5 in PDFDoc::displayPageSlice(OutputDev*, - int, double, double, int, bool, bool, bool, int, int, int, int, - bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) - /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 - #16 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, - int, int, int, int, int, double, double, char*) - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 - #17 0x404416 in main - /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 - #18 0x7f7aa29baec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) - #19 0x401d58 in _start - (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) - SUMMARY: AddressSanitizer: SEGV - /home/tsdgeos/devel/poppler/poppler/GfxState.cc:2509 - GfxIndexedColorSpace::mapColorToBase(GfxColor*, GfxColor*) - - poppler/GfxState.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 8947c6bc1dcb768b9d9c03a7a5db1573abdc2e87 -Author: Albert Astals Cid -Date: Wed Mar 26 00:47:59 2014 +0100 - - Forgot my (C) in the last commit - - poppler/TextOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 1d7095ab7bdf0f14c3bfe99d6d5985bce98abe16 -Author: Albert Astals Cid -Date: Tue Mar 25 22:29:07 2014 +0100 - - Fix Heap-buffer-overflow in TextPage::updateFont - - Bug #76442 - - poppler/TextOutputDev.cc | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit 37ad83d69bd1d10da6ea1eb559c4bd320917ae25 -Author: Albert Astals Cid -Date: Sat Mar 22 17:33:55 2014 +0100 - - Reorder the if check condition - - I think the previous condition was correct anyway because of the - extra -1 in the i check - but it really makes more sense to have the i check first - - Bug #76478 - - goo/gfile.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 3535d658095ffa49ef8615d69843afa9c5ada061 -Author: Albert Astals Cid -Date: Sat Mar 22 17:29:46 2014 +0100 - - Make the test rect go to xMax, yMax not xMax-1,yMax-1 - - I don't understand why the -1 is there and removing - it actually fixes bug #76387 - - splash/Splash.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 1e93c3f2d1c86edd40ca283ed422089f64886d04 -Author: William Bader -Date: Sat Mar 15 17:14:21 2014 +0100 - - Fix regression when creating level1 PS - - Bug #75241 - - poppler/PreScanOutputDev.cc | 16 ++++++++++++++-- - poppler/PreScanOutputDev.h | 3 ++- - 2 files changed, 16 insertions(+), 3 deletions(-) - -commit 1ea2eb412d12d97eaf49d1e51d7fda7abd8fbf9d -Author: Jason Crain -Date: Wed Mar 12 00:34:13 2014 +0100 - - Limit numeric parsing of character names - - Bug #38456 - - poppler/GfxFont.cc | 139 - ++++++++++++++++++++++++++++++++++-------------- - poppler/GlobalParams.cc | 4 +- - 2 files changed, 102 insertions(+), 41 deletions(-) - -commit e24cbeae22d6c8630e292897bd982a87e6290ca6 -Author: Steven Lee -Date: Tue Mar 11 21:24:59 2014 +0100 - - Fix TIFF writting in Windows - - Bug #75969 - - goo/TiffWriter.cc | 11 +++++++++++ - 1 file changed, 11 insertions(+) - -commit b984a3b5946ebcd736e0583a10eb614cede3388a -Author: Adrian Perez de Castro -Date: Wed Mar 5 11:19:48 2014 +0200 - - glib: Use flags argument in poppler_structure_element_get_text() - - Instead of accepting a boolean argument to enable recursive text - extraction, - use a flags value. Text extraction may add features in the future (for - example, allowing using alternate text as replacement for inline - figures), - and this will allow to extend the method without introducing ABI - or API - breakage. - - https://bugs.freedesktop.org/show_bug.cgi?id=75796 - - glib/poppler-structure-element.cc | 12 +++++++----- - glib/poppler-structure-element.h | 14 +++++++++++++- - glib/reference/poppler-sections.txt | 3 +++ - 3 files changed, 23 insertions(+), 6 deletions(-) - -commit 94df09de1e07d442895ec1fb5cc23cacd9826552 -Author: Adrian Perez de Castro -Date: Thu Mar 6 10:44:51 2014 +0200 - - glib: Add missing underscore in method name - - The correct name is poppler_structure_element_get_form_state(). - - https://bugs.freedesktop.org/show_bug.cgi?id=75827 - - glib/poppler-structure-element.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 7ddd03f9a00dcf505921821c55bebe6817aa3605 -Author: Carlos Garcia Campos -Date: Wed Mar 5 17:48:39 2014 +0100 - - Rename getNumElements, getElement and appendElement as getNumChildren, - getChild and appendChild - - It's more consistent with other internal API and less confusing. - - glib/poppler-structure-element.cc | 16 ++++++++-------- - poppler/StructElement.cc | 6 +++--- - poppler/StructElement.h | 8 ++++---- - poppler/StructTreeRoot.cc | 4 ++-- - poppler/StructTreeRoot.h | 8 ++++---- - 5 files changed, 21 insertions(+), 21 deletions(-) - -commit 7d6a5b65f8497537248d405177ae141f3765a419 -Author: Carlos Garcia Campos -Date: Wed Mar 5 17:40:14 2014 +0100 - - glib: Update the documentation symbols after the PopplerStructureScope - rename - - glib/reference/poppler-sections.txt | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 9282b5a26e9ce81d81d42c0cbe449543c8366b7c -Author: Carlos Garcia Campos -Date: Wed Mar 5 17:37:38 2014 +0100 - - glib: Rename PopplerStructureScope as PopplerStructureTableScope - - It's a table specific attribute - - glib/poppler-structure-element.cc | 14 +++++++------- - glib/poppler-structure-element.h | 12 ++++++------ - 2 files changed, 13 insertions(+), 13 deletions(-) - -commit 9888eb65c6fad0eabcf525a7e88941dec2a27e92 -Author: Adrian Perez de Castro -Date: Thu Sep 26 19:36:12 2013 +0300 - - glib: Implement accessors for element attributes - - Implement inspecting the standard attributes of - PopplerStructureElement - objects. - - https://bugs.freedesktop.org/show_bug.cgi?id=64821 - - glib/poppler-structure-element.cc | 1279 - ++++++++++++++++++++++++++++++++++- - glib/poppler-structure-element.h | 252 ++++++- - glib/reference/poppler-sections.txt | 84 +++ - 3 files changed, 1597 insertions(+), 18 deletions(-) - -commit b346df59ef0775f5bd74a9f7379b5f430ccd7b79 -Author: Adam Reichold -Date: Tue Mar 4 23:40:59 2014 +0100 - - Qt: Expose document-supplied text direction - - qt4/src/poppler-document.cc | 17 +++++++++++++++++ - qt4/src/poppler-qt4.h | 10 +++++++++- - qt5/src/poppler-document.cc | 17 +++++++++++++++++ - qt5/src/poppler-qt5.h | 10 +++++++++- - 4 files changed, 52 insertions(+), 2 deletions(-) - -commit 2fc38c1866243598e22be07f0177e7d9385542d5 -Author: Adrian Perez de Castro -Date: Fri Feb 28 19:14:36 2014 +0200 - - glib: Fixes in the API reference documentation - - - Remove the references to non-existent methods for - PopplerStructureElement, - and point to PopplerStructureElementIter instead to point out how to - obtain the structure tree. - - Remove a non-existent include in poppler-docs.sgml - - Add POPPLER_TYPE_TEXT_SPAN to the list of private symbols. - - https://bugs.freedesktop.org/show_bug.cgi?id=75615 - - glib/poppler-structure-element.cc | 6 +++--- - glib/reference/poppler-docs.sgml | 1 - - glib/reference/poppler-sections.txt | 1 + - 3 files changed, 4 insertions(+), 4 deletions(-) - -commit cfe47a655ec5e280168e000da85bbf13f5f5f8b8 -Author: Adrian Perez de Castro -Date: Fri Feb 28 19:17:45 2014 +0200 - - glib: Remove poppler_text_span_is_link() in header - - The method poppler_text_span_is_link() does not exist, and must - be removed from the API header. - - https://bugs.freedesktop.org/show_bug.cgi?id=75613 - - glib/poppler-structure-element.h | 1 - - 1 file changed, 1 deletion(-) - -commit 7a2db63b5f7cae4bc215baa0859c4d4f8a660951 -Author: Adrian Perez de Castro -Date: Wed Feb 26 20:16:29 2014 +0200 - - glib: Remove unneeded POPPLER_STRUCTURE_ELEMENT_UNKNOWN - - The enum value POPPLER_STRUCTURE_ELEMENT_UNKNOWN because Poppler does - not add invalid StructElements ("invalid" being nodes of type - StructElement::Unknown) to the Tagged-PDF structure tree. That means - that poppler-glib does not need to expose it in the API. An assertion - is left to aid in finding issues when using debug builds. - - https://bugs.freedesktop.org/show_bug.cgi?id=75541 - - glib/poppler-structure-element.cc | 12 +++++++----- - glib/poppler-structure-element.h | 1 - - 2 files changed, 7 insertions(+), 6 deletions(-) - -commit db909c2a14f962234a813ba9853535b9692cfd5a -Author: Albert Astals Cid -Date: Wed Feb 26 22:09:44 2014 +0100 - - Try harder to open broken files - - Bug #75232 - - poppler/PDFDoc.cc | 33 ++++++++++++++++++++++----------- - poppler/PDFDoc.h | 8 ++++---- - 2 files changed, 26 insertions(+), 15 deletions(-) - -commit b2394eee5384edf4128d598030989e66d64714ef -Author: Adrian Perez de Castro -Date: Mon Feb 10 20:29:35 2014 +0200 - - Tagged-PDF: Fix parsing of attached element attributes - - The wrong object was used as attribute dictionary, which caused - a segmentation fault when parsing PDF files in which the structure - elements included attributes attached to them. This patch fixes the - issue. - - Thanks to Joanmarie Diggs for helping in - debugging the problem. - - https://bugs.freedesktop.org/show_bug.cgi?id=74805 - - poppler/StructElement.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit c549b5e9ce2dcc8beb2511ee315bfff2fdfdf6e8 -Author: Adrian Perez de Castro -Date: Sun Feb 9 18:31:22 2014 +0200 - - glib: Add poppler_structure_element_is_grouping() - - Implement a method to check whether a structure element is a grouping - element, wrapping the StructElement::isGrouping() method. - - https://bugs.freedesktop.org/show_bug.cgi?id=74753 - - glib/poppler-structure-element.cc | 20 ++++++++++++++++++++ - glib/poppler-structure-element.h | 1 + - glib/reference/poppler-sections.txt | 1 + - 3 files changed, 22 insertions(+) - -commit 6fbd6cb85bdd32dc5a3d4c3c719556269a4488ac -Author: Adrian Perez de Castro -Date: Fri Feb 21 15:02:44 2014 +0200 - - glib: Handle missing structure element types - - Element Art (article); RB, RP, RB (Ruby text inner elements); and - WT, WP (Warichu inner elements) were not being handled. This adds - the corresponding handling in poppler-glib. Also, the "default" case - in the switch in poppler_structure_element_get_type() is removed, so - the compiler can emit warnings when enum values are not handled. - - https://bugs.freedesktop.org/show_bug.cgi?id=75323 - - glib/poppler-structure-element.cc | 25 +++++++++++++++++++------ - glib/poppler-structure-element.h | 9 +++++++-- - 2 files changed, 26 insertions(+), 8 deletions(-) - -commit 63e9c0b67fa2e64ca20258d873a849386c7eb295 -Author: Fabio D'Urso -Date: Mon Feb 17 23:58:09 2014 +0100 - - Some error() usage fixes - - poppler/Hints.cc | 3 ++- - poppler/JBIG2Stream.cc | 4 ++-- - poppler/PSOutputDev.cc | 4 ++-- - poppler/SecurityHandler.cc | 3 ++- - poppler/StructTreeRoot.cc | 3 ++- - qt4/src/poppler-annotation.cc | 6 +++--- - qt5/src/poppler-annotation.cc | 6 +++--- - utils/HtmlOutputDev.cc | 11 ++++++----- - 8 files changed, 22 insertions(+), 18 deletions(-) - -commit 8f2d847f1d0224a297e642944f8da9c1409732b6 -Author: Fabio D'Urso -Date: Mon Feb 17 23:56:49 2014 +0100 - - Clang++ plugin that checks for usage errors in GooString::format-style - calls - - goo/GooString.h | 12 +- - poppler/Error.h | 4 +- - test/goostring-format-checker/README | 16 + - .../goostring-format-checker.cc | 369 - +++++++++++++++++++++ - 4 files changed, 397 insertions(+), 4 deletions(-) - -commit d7d61dcda91910f7eb2548b19e8380d7c3232dd3 -Author: Thomas Freitag -Date: Wed Feb 12 21:50:38 2014 +0100 - - blend usage in PDF with spot colors casue random output - - The reason for the random colors is the uninitialized local variable - cBlend. The blend functions only fills offset 0 to 3, so offset 4 - up to 4 + SPOT_NCOMPS are left uninitialized, but all offsets are - stored in the bitmap. - So we need to initialize these offsets with 0! - - Bug #74883 - - splash/Splash.cc | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - -commit b2905a0d299cc09fcd219afe49cb370f6db61c5a -Author: Albert Astals Cid -Date: Mon Feb 10 20:19:07 2014 +0100 - - increase gtk3 dependency - - gtk_tree_view_set_activate_on_single_click was introduced in 3.8 - - cmake/modules/FindGTK.cmake | 2 +- - configure.ac | 4 ++-- - 2 files changed, 3 insertions(+), 3 deletions(-) - -commit 71d4041b061c109a965e72230640cf8ee616dac3 -Author: Albert Astals Cid -Date: Mon Feb 10 20:16:46 2014 +0100 - - Make sure number of least objects in hints table is valid - - Bug #74741 - - poppler/Hints.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit a865f13def88153fdbe8a0a054d2005e3e2bb737 -Author: Albert Astals Cid -Date: Sun Feb 9 23:22:07 2014 +0100 - - Fix cmake build - - glib/CMakeLists.txt | 2 ++ - glib/demo/CMakeLists.txt | 1 + - 2 files changed, 3 insertions(+) - -commit d6fde0fac0120b1622942d8344d5153d9abf3e1e -Author: Adrian Perez de Castro -Date: Wed May 29 23:44:03 2013 +0300 - - glib-demo: Pane showing the document structure - - Adds a new pane in poppler-glib-demo showing the structure for - Tagged-PDF - documents. It also serves as an example on how to to use the API for - PopplerStructure and PopplerStructureElement. - - glib/demo/Makefile.am | 2 + - glib/demo/main.c | 2 + - glib/demo/taggedstruct.c | 232 - +++++++++++++++++++++++++++++++++++++++++++++++ - glib/demo/taggedstruct.h | 31 +++++++ - 4 files changed, 267 insertions(+) - -commit 0f9fa775c469c03d1613b955ee7b06b823e6e080 -Author: Adrian Perez de Castro -Date: Thu Sep 26 17:50:51 2013 +0300 - - glib: Expose inline attributes of structure elements - - Allows obtaining inline text attributes from structure elements. The - text - is divived into "spans", which are groups of consecutive glyphs - that share - their attributes. Each one of those is represented by a - PopplerTextSpan, - which gives information about the text font and color, and the - link target - for links. The list of PopplerTextSpans is created lazily when - first used. - - https://bugs.freedesktop.org/show_bug.cgi?id=64821 - - glib/poppler-structure-element.cc | 269 - ++++++++++++++++++++++++++++++++++++ - glib/poppler-structure-element.h | 16 ++- - glib/poppler.h | 1 + - glib/reference/poppler-sections.txt | 12 ++ - 4 files changed, 297 insertions(+), 1 deletion(-) - -commit 8072d4b0e3ea10b4308f8172891f769f30466133 -Author: Adrian Perez de Castro -Date: Thu May 9 12:01:59 2013 +0300 - - glib: Expose the document structure tree - - Implements a new PopplerStructureElement classe, which builds upon - StructTreeRoot and StructElement to expose the document structure of - tagged PDFs in the GLib binding. - - Navigation of the structure tree is done by an iterator-based - interface, - using PopplerStructureElementIter. - - https://bugs.freedesktop.org/show_bug.cgi?id=64821 - - glib/Makefile.am | 2 + - glib/poppler-private.h | 10 + - glib/poppler-structure-element.cc | 663 - ++++++++++++++++++++++++++++++++++++ - glib/poppler-structure-element.h | 112 ++++++ - glib/poppler.h | 3 + - glib/reference/poppler-docs.sgml | 2 + - glib/reference/poppler-sections.txt | 37 ++ - glib/reference/poppler.types | 2 + - 8 files changed, 831 insertions(+) - -commit 46b7470ae9846d7e6dbb72bbb3ff831acd954168 -Author: Germán Poo-Caamaño -Date: Thu Jan 30 14:42:51 2014 -0800 - - glib-demo: Fix performance in text markup annotations - - Fix https://bugs.freedesktop.org/show_bug.cgi?id=51487#c45 - - glib/demo/annots.c | 19 +++++++++++++------ - 1 file changed, 13 insertions(+), 6 deletions(-) - -commit 8a84b45674aed8c27a1d172b07eb0531c0ec14f1 -Author: Carlos Garcia Campos -Date: Sat Feb 8 09:17:02 2014 +0100 - - glib: Fix gobject-introspection warnings - - glib/poppler-page.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 899799df78c00fc2ca6d2d0e612536b87a871817 -Author: Adrian Perez de Castro -Date: Tue Feb 4 19:26:53 2014 +0200 - - Allow properly identifying grouping elements - - Grouping elements in the Tagged-PDF structure should be identifiable - as - such (see section 14.8.4.2 "Grouping Elements" of the PDF - standard). Those - were previously reported as inline elements, which is quite not - correct. - This patch introduces a new StructElement::isGrouping() method which - correctly reports grouping elements as such. - - https://bugs.freedesktop.org/show_bug.cgi?id=74520 - - poppler/StructElement.cc | 31 +++++++++++++++++++------------ - poppler/StructElement.h | 1 + - 2 files changed, 20 insertions(+), 12 deletions(-) - -commit 27cd9a00bfebf0602e7ed29a8ee8e16ffff67bde -Author: Adrian Perez de Castro -Date: Tue Feb 4 19:35:58 2014 +0200 - - Report LBody elements in Tagged-PDF structure as block elements - - According to section 14.8.4.3 "Block-Level Structure Elements" - (in particular subsection 14.8.4.3.3 "List Elements"), structure - elements of type LBody must be reported as block elements. This - patch changes the reported type from elementTypeUndefined to - elementTypeBlock accordingly. - - https://bugs.freedesktop.org/show_bug.cgi?id=74522 - - poppler/StructElement.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 4cda839cb489fe5cd4726109cb9ab8b0ba2fa563 -Author: Adrian Johnson -Date: Tue Jan 28 06:06:09 2014 +1030 - - pdftops: ensure there is always a page size in the output - - even if the PDF file as badly broken. - - poppler/PSOutputDev.cc | 7 +++++++ - 1 file changed, 7 insertions(+) - -commit 45a87afdf1372911aa1ba840557e61627cdc7b4f -Author: Adrian Johnson -Date: Sun Dec 29 15:16:37 2013 +1030 - - cairo: clip to crop box - - when printing the cairo surface may larger than the crop box - - fixes https://bugzilla.gnome.org/show_bug.cgi?id=649886 - - poppler/CairoOutputDev.h | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 6d39a1d7b348329dd057a8e7c77bfd47921fc495 -Author: Adrian Johnson -Date: Mon Dec 30 17:59:09 2013 +1030 - - pdftocairo: ensure page size and crop box works the same as pdftops - - Bug 72312 - - utils/pdftocairo.1 | 26 +++++++++----------------- - utils/pdftocairo.cc | 20 +++++++++++++++----- - 2 files changed, 24 insertions(+), 22 deletions(-) - -commit b1da7e20dcef78ef6036418b37a47ba3f8818453 -Author: Adrian Johnson -Date: Thu Dec 19 22:18:26 2013 +1030 - - pdftops: Only change paper size when different to previous size - - Previously this check was done in the code (removed in previous - commit). - Moving this check into the pdfSetupPaper macro preserves page - independence. - - Bug 72312 - - poppler/PSOutputDev.cc | 30 +++++++++++++++++++++++++----- - 1 file changed, 25 insertions(+), 5 deletions(-) - -commit 7ac7d3bad4b868950ee96fd9c5ece88632f8827c -Author: Adrian Johnson -Date: Fri Dec 20 07:19:21 2013 +1030 - - pdftops: Remove origpagesizes mode and make -origpagesizes an alias - for -paper match - - Bug 72312 - - poppler/PSOutputDev.cc | 9 ++------- - poppler/PSOutputDev.h | 4 ++-- - utils/pdftops.1 | 30 ++++++++++-------------------- - utils/pdftops.cc | 23 ++++++++++++++--------- - 4 files changed, 28 insertions(+), 38 deletions(-) - -commit 31fc5181bc491ff2e4aee0ae05c0f611a36e585c -Author: Adrian Johnson -Date: Fri Dec 20 07:16:37 2013 +1030 - - pdftops: Use crop box as page size - - unless -nocrop is used. The fontends use the crop box as the page - size and - acroread uses the cropbox as the page size for display and printing. - - Bug 72312 - - poppler/PSOutputDev.cc | 28 +++++++--------------------- - 1 file changed, 7 insertions(+), 21 deletions(-) - -commit bf2049b17ac4706f472c59e50266f4eaf0ffaa32 -Author: Adrian Johnson -Date: Sun Dec 15 18:00:41 2013 +1030 - - pdftps: fix DocumentMedia/Page/Media/PageBBox DSC comments - - Bug 72312 - - poppler/PSOutputDev.cc | 167 - ++++++++++++++++++++++++++-------------- - poppler/PSOutputDev.h | 6 +- - qt4/src/poppler-ps-converter.cc | 1 + - qt5/src/poppler-ps-converter.cc | 1 + - utils/pdftops.cc | 1 + - 5 files changed, 119 insertions(+), 57 deletions(-) - -commit fe49033c9bd2103c13d4eb59983e06fdcdd33a8d -Author: Till Kamppeter -Date: Sat Dec 14 16:05:09 2013 +1030 - - pdftops: ensure paper size takes into account rotation - - Bug 72312 - - poppler/PSOutputDev.cc | 48 - ++++++++++++++++++++---------------------------- - 1 file changed, 20 insertions(+), 28 deletions(-) - -commit 31edf585e62f4e91b7b64295cc8b978ac466ce58 -Author: Bogdan Cristea -Date: Mon Jan 27 20:06:11 2014 +0100 - - [qt] Improve compilation under Win 8 with Visual Studio 2012 - - Bug #73111 - - goo/GooMutex.h | 3 ++- - goo/GooTimer.h | 2 ++ - goo/gfile.h | 2 ++ - poppler/PDFDoc.cc | 4 +--- - poppler/XpdfPluginAPI.h | 2 ++ - poppler/poppler-config.h.cmake | 18 ++++++++++++++++-- - poppler/poppler-config.h.in | 18 ++++++++++++++++-- - qt4/tests/stress-threads-qt4.cpp | 5 +++++ - qt5/src/poppler-private.h | 6 ++++-- - qt5/tests/stress-threads-qt5.cpp | 5 +++++ - test/perf-test.cc | 1 - - 11 files changed, 55 insertions(+), 11 deletions(-) - -commit 834cd18e3ddfda44a11316290f7eee98cd871305 -Author: Albert Astals Cid -Date: Sun Jan 26 16:10:20 2014 +0100 - - Use c99 for the c compiler - - cmake/modules/PopplerMacros.cmake | 1 + - 1 file changed, 1 insertion(+) - -commit 03674a141a96806e5e1a134dc3dec2ee61b68713 -Author: Pino Toscano -Date: Sun Jan 26 12:43:13 2014 +0100 - - qt4/qt5: add GCC visibility export attributes - - this does no actual changes to the exported symbols, but can help in - hiding symbols if the right GCC flags for symbols visibility are - specified - - qt4/src/poppler-export.h | 3 +++ - qt5/src/poppler-export.h | 3 +++ - 2 files changed, 6 insertions(+) - -commit 52b46d05219cf9898ee4adae7c8c2702adb1ba23 -Author: Pino Toscano -Date: Sun Jan 26 12:38:03 2014 +0100 - - qt4/qt5: improve naming of internal export/import macros - - use something less generic than LIB_EXPORT/LIB_IMPORT - - qt4/src/poppler-export.h | 12 ++++++------ - qt5/src/poppler-export.h | 12 ++++++------ - 2 files changed, 12 insertions(+), 12 deletions(-) - -commit 7a8bcea11ad71fccbbba2787fc442f6ba4bf7100 -Author: Pino Toscano -Date: Thu Jan 23 22:34:07 2014 +0100 - - cmake: install JpegWriter.h depending on libjpeg - - ... and not libopenjpeg - - CMakeLists.txt | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -commit 57f34f525fa2c2e62ebc7383ceba48ebc80ebba6 -Author: Andres Gomez -Date: Wed Jan 8 12:26:14 2014 +0200 - - glib-demo: Fix conding style issue in render.c - - glib/demo/render.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 3fac919eeb1ca1abfdbb4f9923a454e532256f5c -Author: Andres Gomez -Date: Wed Jan 8 12:25:52 2014 +0200 - - glib-demo: Fix trailing whitespaces in render.c - - glib/demo/render.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 92ea15642a6d3fe65d66d5c59fb6bed54e060e5d -Author: Christian Persch -Date: Fri Jan 3 23:31:56 2014 +0100 - - glib: Install error callback - - Install an error callback so that poppler error messages can be - redirected - to the GLib logging API. - - https://bugs.freedesktop.org/show_bug.cgi?id=73269 - - glib/poppler.cc | 47 +++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 47 insertions(+) - -commit f99128e38bbff43623d5cd1c1bc27fd789d0bc0c -Author: Carlos Garcia Campos -Date: Sun Jan 19 16:03:35 2014 +0100 - - glib: Make vertices a constructor parameter of line annotations - - It's a required field in the line annotation. - - glib/demo/annots.c | 4 +--- - glib/poppler-annot.cc | 12 ++++++++++-- - glib/poppler-annot.h | 4 +++- - 3 files changed, 14 insertions(+), 6 deletions(-) - -commit 587a40f90e4ac5a1b6ab9044495a1ae403bc8c58 -Author: Carlos Garcia Campos -Date: Sun Jan 19 15:58:43 2014 +0100 - - annots: Fix memory leak when setting AnnotTextMarkup quads twice - - poppler/Annot.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 69e73da1fbab9bf3365b40dced1008b0283ac931 -Author: Germán Poo-Caamaño -Date: Wed Nov 20 11:53:30 2013 -0800 - - glib-demo: Add support for PopplerTextAnnotMarkup - - * The subtypes are: Highlihght, Squiggly, StrikeOut and Underline. - * Use ScrolledWindow for annotation properties to make room to - show the Quadrilaterals of TextMarkup annotations. - - https://bugs.freedesktop.org/show_bug.cgi?id=51487 - - glib/demo/annots.c | 232 - +++++++++++++++++++++++++++++++++++++++++++++++------ - 1 file changed, 206 insertions(+), 26 deletions(-) - -commit 9a7699ebe3e644ba845ef75d9295c88d321cb934 -Author: Germán Poo-Caamaño -Date: Mon Nov 18 16:42:08 2013 -0800 - - glib: Add PopplerAnnotTextMarkup class and subtypes - - The subtypes are: Highlihght, Squiggly, StrikeOut and Underline. - It adds convenient methods to set/get/free quadrilaterals - necessaries for TextMarkup annotations. - - https://bugs.freedesktop.org/show_bug.cgi?id=51487 - - glib/poppler-annot.cc | 264 - ++++++++++++++++++++++++++++++++++++ - glib/poppler-annot.h | 23 ++++ - glib/poppler-page.cc | 6 + - glib/poppler-private.h | 1 + - glib/poppler.h | 1 + - glib/reference/poppler-sections.txt | 11 ++ - 6 files changed, 306 insertions(+) - -commit 40040b41216a3dcc833fc224f1c6f15517a88aed -Author: Germán Poo-Caamaño -Date: Mon Nov 18 16:26:27 2013 -0800 - - glib: Add PopplerQuadrilateral boxed type - - https://bugs.freedesktop.org/show_bug.cgi?id=51487 - - glib/poppler-page.cc | 53 - +++++++++++++++++++++++++++++++++++++ - glib/poppler-page.h | 33 +++++++++++++++++++++++ - glib/poppler.h | 1 + - glib/reference/poppler-sections.txt | 6 +++++ - 4 files changed, 93 insertions(+) - -commit c8a845cf7c7752d3b7dad06013d3154812c66c92 -Author: Albert Astals Cid -Date: Tue Jan 14 20:26:59 2014 +0100 - - Do not define -ansi - - We are using long long that is not defined in ansi, so forcing ansi - strictness does - not make any sense. Bug #72499 - - cmake/modules/PopplerMacros.cmake | 5 ----- - configure.ac | 15 --------------- - 2 files changed, 20 deletions(-) - -commit f0c13ee72e8a7df17bdf847f5e922c01acee1f0d -Author: Albert Astals Cid -Date: Mon Jan 6 21:55:07 2014 +0100 - - C for last commit - - poppler/Parser.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 1e1b9991a911fb610e74119979b20b179f3f2a67 -Author: Albert Astals Cid -Date: Mon Jan 6 21:51:25 2014 +0100 - - Fix rendering of pdf file from KDE bug 329600 - - It used to work and regressed with large file support (used to work - because stuff just overflowed) - - lexer->getPos needs lexer to be a stream, if it is not, just resort - to the +5000 kludge - - poppler/Parser.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 4cd5c349cfbc745688c0c38fc50d364092bc3718 -Author: Albert Astals Cid -Date: Mon Jan 6 21:48:25 2014 +0100 - - Update popplers (C) - - poppler/poppler-config.h.cmake | 2 +- - poppler/poppler-config.h.in | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 7ca2f42b06757587dfd9521fb1c6c7d657545553 -Author: Albert Astals Cid -Date: Mon Jan 6 15:48:22 2014 +0100 - - Learn about automake 1.14 - - autogen.sh | 19 ++++++++++--------- - 1 file changed, 10 insertions(+), 9 deletions(-) - -commit de9643b6f76774ebe131c4787df82dd213181c71 -Author: Albert Astals Cid -Date: Fri Jan 3 00:53:37 2014 +0100 - - 0.25.1 - - CMakeLists.txt | 2 +- - NEWS | 19 +++++++++++++++++++ - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - qt5/src/Doxyfile | 2 +- - 5 files changed, 23 insertions(+), 4 deletions(-) - -commit e238c1f83fd5f667336bfbb0e9a59569ff638ecc -Author: Albert Astals Cid -Date: Fri Jan 3 00:29:28 2014 +0100 - - Fix qt5 moc detection fix - - configure.ac | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit 381ae2877acace4e8908b07ee5fb442bc19bf814 -Merge: 64100e7 a2f0e4b -Author: Albert Astals Cid -Date: Fri Jan 3 00:04:29 2014 +0100 - - Merge remote-tracking branch 'origin/poppler-0.24' - - Conflicts: - CMakeLists.txt - NEWS - configure.ac - cpp/Doxyfile - qt4/src/Doxyfile - qt5/src/Doxyfile - -commit a2f0e4b1fd8b3d9675cc00a561094bd78a63d048 -Author: Albert Astals Cid -Date: Thu Jan 2 23:48:29 2014 +0100 - - 0.24.5 - - CMakeLists.txt | 2 +- - NEWS | 4 ++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - qt5/src/Doxyfile | 2 +- - 6 files changed, 9 insertions(+), 5 deletions(-) - -commit 523b2731e0489bab58e66b21016bd6f010e616ea -Author: Albert Astals Cid -Date: Thu Jan 2 22:54:42 2014 +0100 - - Update copyrights - - poppler/JBIG2Stream.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 64100e7f1f6b550e952838fce38615ec3788e17c -Author: Fabio D'Urso -Date: Sat Dec 28 12:11:47 2013 +0100 - - Simplify some calls to GooString::format-family functions - - poppler/Object.h | 4 ++-- - utils/pdftocairo.cc | 2 +- - 2 files changed, 3 insertions(+), 3 deletions(-) - -commit 0abde34d0f7ba0fc04a30dbfd78373ec9d9d0695 -Author: Fabio D'Urso -Date: Sat Dec 28 12:11:05 2013 +0100 - - Fixed some GooString format markers - - poppler/CMap.cc | 3 ++- - poppler/Function.cc | 3 ++- - poppler/StructElement.cc | 2 +- - 3 files changed, 5 insertions(+), 3 deletions(-) - -commit a7da4c6ac2b13308803806009c3437332b140586 -Author: Fabio D'Urso -Date: Fri Dec 27 17:09:39 2013 +0100 - - GooString format: fixed bug with printing LLONG_MIN - - ( -LLONG_MIN doesn't fit in a signed long long ) - - goo/GooString.cc | 19 +++++++++++++------ - 1 file changed, 13 insertions(+), 6 deletions(-) - -commit fe88f20cc565b4cf4765fed56c821989148ef454 -Author: Fabio D'Urso -Date: Fri Dec 27 17:08:50 2013 +0100 - - GooString format: Added some tests + improved documentation - - goo/GooString.h | 10 +++++-- - qt4/tests/check_goostring.cpp | 66 - +++++++++++++++++++++++++++++++++++++++++++ - qt5/tests/check_goostring.cpp | 66 - +++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 139 insertions(+), 3 deletions(-) - -commit 5234a349adb678d267a3d8ca13176ac8abb7afd2 -Author: Thomas Freitag -Date: Fri Dec 20 20:25:26 2013 +0100 - - pdfunite: do not lose fonts when merging some files - - utils/pdfunite.cc | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -commit 8e24fcc0d296e07327e9cbe297f627bfc6471ee3 -Merge: 85efba3 b02f873 -Author: Albert Astals Cid -Date: Wed Dec 18 21:51:57 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.24' - - Conflicts: - poppler/GfxState.cc - -commit b02f873174865837fed3a9544b70b8b21747a3dd -Author: Fabio D'Urso -Date: Wed Dec 18 21:46:12 2013 +0100 - - Fixed some GooString format markers - - poppler/GfxState.cc | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - -commit 85efba38c02b5daf7d3fc46bc85850e6842a085d -Author: Thomas Freitag -Date: Wed Dec 18 00:46:00 2013 +0100 - - Make pdfunite work even if there's a single file given - - Bug #72720 - - utils/pdfunite.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit a766c55f68db38feed91cf003a0d5710e2f925a8 -Author: Tuomas Jormola -Date: Mon Dec 16 20:43:28 2013 +0100 - - Fix detection of moc for Qt5 - - Bug #72744 - - On my Mac OS X 10.9 Mavericks system with Qt 5.2.0 installed using - Homebrew, the output of the moc command doesn't include the string - "Qt 5" which is expected by the moc version detection logic in - configure.ac of poppler 0.24.4. This patch updates the grep pattern so - that the current expected moc version output and the version output of - this installation of Qt5 are both detected as a valid moc for - Qt5. With - this patch applied, I was able to build and test poppler with Qt5 - support successfully. - - (09:26:05)(tj@gauri)(~)$ uname -a - Darwin gauri.ad.local.domain 13.0.0 Darwin Kernel Version 13.0.0: - Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 - x86_64 i386 MacBookPro3,1 Darwin - (09:26:08)(tj@gauri)(~)$ /usr/local/opt/qt5/bin/moc -v - moc 5.2.0 - (09:26:24)(tj@gauri)(~)$ - - configure.ac | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit a43b4bf84fe4bde6649049685bf4ed6a682e8286 -Author: Carlos Garcia Campos -Date: Sun Dec 15 11:59:57 2013 +0100 - - regtest: Add a command line option to create-report command to not - launch the browser - - regtest/HTMLReport.py | 5 +++-- - regtest/commands/create-report.py | 5 ++++- - 2 files changed, 7 insertions(+), 3 deletions(-) - -commit 113958276b96d7f1aab7042e1807a9970425d234 -Author: Carlos Garcia Campos -Date: Sun Dec 15 11:48:51 2013 +0100 - - regtest: Return an exist status code depending on whether the - command succeeded - - regtest/TestRun.py | 2 ++ - regtest/commands/__init__.py | 4 ++-- - regtest/commands/create-refs.py | 2 ++ - regtest/commands/create-report.py | 2 ++ - regtest/commands/find-regression.py | 4 +++- - regtest/commands/run-tests.py | 6 ++++-- - regtest/main.py | 8 ++++---- - regtest/poppler-regtest | 2 +- - 8 files changed, 20 insertions(+), 10 deletions(-) - -commit 44cf2de0df351d5948893f6a4e2bca1168d16b70 -Author: Dominik Haumann -Date: Thu Dec 12 23:12:35 2013 +0100 - - Arthur font rendering improvements - - The patch does does the following: - - use NoPen to fill the glyphs - - since SplashPath seems to bitwise OR stop and start of path, - closing a subpath needs to happen before starting a path. - - Arthur needs serious work but this is a definite improvement in all - the files i've tried it on - - qt4/src/ArthurOutputDev.cc | 18 +++++++++--------- - qt5/src/ArthurOutputDev.cc | 18 +++++++++--------- - 2 files changed, 18 insertions(+), 18 deletions(-) - -commit 02863f683be4543a2af6c26d53be93785d2b836a -Author: Albert Astals Cid -Date: Thu Dec 12 23:09:43 2013 +0100 - - qt: Simple silly test program to save to file - - Allows us to do some quick arthur testing - - qt4/tests/CMakeLists.txt | 1 + - qt4/tests/Makefile.am | 8 ++++- - qt4/tests/test-render-to-file.cpp | 69 - +++++++++++++++++++++++++++++++++++++++ - qt5/tests/CMakeLists.txt | 1 + - qt5/tests/Makefile.am | 8 ++++- - qt5/tests/test-render-to-file.cpp | 69 - +++++++++++++++++++++++++++++++++++++++ - 6 files changed, 154 insertions(+), 2 deletions(-) - -commit 018892d4ceccd5e2994cdb74cd2d401293fc929d -Author: Albert Astals Cid -Date: Wed Dec 11 23:05:53 2013 +0100 - - 0.25.0 - - CMakeLists.txt | 6 +++--- - configure.ac | 4 ++-- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - qt5/src/Doxyfile | 2 +- - 6 files changed, 9 insertions(+), 9 deletions(-) - -commit a1b99b26da9124fa55f773af55ae7382bd911d47 -Author: Albert Astals Cid -Date: Wed Dec 11 23:00:00 2013 +0100 - - NEWS - - NEWS | 23 +++++++++++++++++++++++ - 1 file changed, 23 insertions(+) - -commit 10a0c45676ef56bee5924e889a7e7c21244b4339 -Author: Albert Astals Cid -Date: Tue Dec 10 20:48:36 2013 +0100 - - Update copyrights - - cpp/poppler-image.cpp | 1 + - goo/PNGWriter.cc | 2 +- - poppler/MarkedContentOutputDev.cc | 2 ++ - poppler/MarkedContentOutputDev.h | 2 ++ - poppler/Object.h | 1 + - poppler/PDFDoc.h | 1 + - utils/ImageOutputDev.h | 2 +- - 7 files changed, 9 insertions(+), 2 deletions(-) - -commit 6c0e7d35f273583acc2aa818860e3120b0cab64f -Author: Thomas Freitag -Date: Tue Dec 10 20:14:39 2013 +0100 - - correction for knockout transparency groups - - Fixes test "G" in eci_altona-test-suite-v2_technical2_x4.pdf - - poppler/SplashOutputDev.cc | 18 ++++++++++--- - splash/Splash.cc | 63 - +++++++++++++++++++++++++++++++++------------ - splash/SplashFTFontEngine.h | 3 +++ - splash/SplashFontEngine.cc | 13 ++++++++++ - splash/SplashFontEngine.h | 5 ++++ - 5 files changed, 82 insertions(+), 20 deletions(-) - -commit f77bc21813ae7234ec4ce94ce4e92230fe5c174a -Merge: 06e9dc9 58e04a0 -Author: Albert Astals Cid -Date: Sat Dec 7 16:56:11 2013 +0000 - - Merge remote-tracking branch 'origin/poppler-0.24' - - Conflicts: - utils/pdfimages.cc - utils/pdfinfo.cc - utils/pdfseparate.cc - -commit 06e9dc917650f562cd6f6666190a8c25756514a3 -Author: Albert Astals Cid -Date: Sat Dec 7 16:39:02 2013 +0000 - - Compile++ - - CMakeLists.txt | 2 ++ - 1 file changed, 2 insertions(+) - -commit 58e04a08afee39370283c494ee2e4e392fd3b684 -Author: Fabio D'Urso -Date: Sat Dec 7 16:33:09 2013 +0000 - - segExtraBytes is a goffset not an int so use lld - - Fixes KDE bug #328511 - - poppler/JBIG2Stream.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 3335d5e52fd7527bba7368ad6e87f1188808582f -Author: Carlos Garcia Campos -Date: Fri Dec 6 17:28:13 2013 +0100 - - regtest: Limit the stderr files to ~1MB - - Some tests send a lot of information to stderr, usually due to parsing - errors in buggy documents. More than 1MB of stderr output is - diffcult to - hanlde and in most cases it's redundant with a lot of duplicated - messages. - This patch reduced the size of the refs dir for the complete test - suite - by 1GB. - - regtest/backends/__init__.py | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -commit 24107ac47625438837d7c29053bff795f986a6bb -Author: Carlos Garcia Campos -Date: Fri Dec 6 13:24:47 2013 +0100 - - regtest: Save checksum results sorted in md5 files - - We are using os.listdir() to get the list of test results that returns - files in arbitrary order. - - regtest/backends/__init__.py | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit f1c9993d58fb9d191a7b3e26bfcaf7b5eec5323d -Author: Carlos Garcia Campos -Date: Fri Dec 6 13:03:24 2013 +0100 - - regtest: Show also the tests expected to crash/fail to run but - don't fail - - regtest/TestRun.py | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -commit 64d1e79c863d12b12b87ed0e3139d364f503e026 -Author: Carlos Garcia Campos -Date: Fri Dec 6 12:51:48 2013 +0100 - - regtest: Improve readability of test results - - Show a summary of tests failed per backend with the percentages and - use a - new line for every test in the result instead of using a comma - separated - line. - - regtest/TestRun.py | 67 - ++++++++++++++++++++++++++++++++++++++---------------- - 1 file changed, 47 insertions(+), 20 deletions(-) - -commit c35bc1da9402896c88999f9cffed6962a265f32e -Author: Carlos Garcia Campos -Date: Fri Dec 6 10:04:48 2013 +0100 - - glib-demo: Increase the default size of the main window - - Some demos like annots that show a document view use more space than - they used to, requiring to manually resize the window everytime. - - glib/demo/main.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ab7da0bf62bb5032c4683d9cd841075d26045aae -Author: Germán Poo-Caamaño -Date: Mon Oct 28 22:52:22 2013 -0700 - - glib-demo: Add Square and Circle annotations demo - - https://bugs.freedesktop.org/show_bug.cgi?id=70983 - - glib/demo/annots.c | 19 +++++++++++++++++++ - 1 file changed, 19 insertions(+) - -commit 2ec450567f27bba3ee4a08b5e69b7c9605bea4bb -Author: Germán Poo-Caamaño -Date: Mon Oct 28 22:48:39 2013 -0700 - - glib: Add implementation of Square and Circle annotations - - Square and Circle only differ in the constructor which defines - the subtype. Therefore, it uses the same name than Poppler's - Geometry class. - - https://bugs.freedesktop.org/show_bug.cgi?id=70983 - - glib/poppler-annot.cc | 263 - ++++++++++++++++++++++++++++++++---- - glib/poppler-annot.h | 23 ++++ - glib/poppler-page.cc | 6 + - glib/poppler-private.h | 2 + - glib/poppler.h | 2 + - glib/reference/poppler-sections.txt | 16 +++ - 6 files changed, 286 insertions(+), 26 deletions(-) - -commit e109cf2461d5be93d004593123d875a28fd79b61 -Author: Carlos Garcia Campos -Date: Tue Nov 26 20:12:22 2013 +0100 - - annots: Make Annot::setBorder receive an AnnotBorder object - - Instead of receiving AnnotBorderArray. Also implement writeToObject in - both AnnotBorderArray and AnnotBorderBS to make sure that - Annot::setBorder will work for both cases. - - poppler/Annot.cc | 51 +++++++++++++++++++++++++++++++++++++++++++++------ - poppler/Annot.h | 10 +++++++--- - 2 files changed, 52 insertions(+), 9 deletions(-) - -commit 3979b82982e84107d93fbbe95350bf25ce47398d -Author: Carlos Garcia Campos -Date: Tue Nov 26 14:44:57 2013 +0100 - - annots: Use a default border for annots that can have a BS entry - - According to the spec if neither the Border nor the BS entry is - present, - the border shall be drawn as a solid line with a width of 1 point. - However, acroread seems to ignore the Border entry for annots - that can't - have a BS entry. - - poppler/Annot.cc | 223 - ++++++++++++++++++++++++++++++++----------------------- - 1 file changed, 132 insertions(+), 91 deletions(-) - -commit 36c07c82bdff010695c5d615b67506922522d0e8 -Author: Carlos Garcia Campos -Date: Tue Nov 26 14:07:21 2013 +0100 - - annots: Add helper function Annot::setLineStyleForBorder - - It sets the line dash and width based on the given AnnotBorder. Use it - only when the border width is greater than 0 for FreeText annotations - and always for annotations that use the border to set the line - width and - dash, but don't draw a border. - - poppler/Annot.cc | 110 - ++++++++++++++++--------------------------------------- - poppler/Annot.h | 1 + - 2 files changed, 32 insertions(+), 79 deletions(-) - -commit e7b1ff97318fd6c3a8fed3a33d45f1cb55208b28 -Author: Carlos Garcia Campos -Date: Tue Nov 26 11:40:57 2013 +0100 - - annots: Remove unused typeUnknown AnnotBorderType from AnnotBorder - - Also make the AnnotBorder constructor protected to make sure it's not - possible to create AnnotBorder instances. - - poppler/Annot.cc | 3 --- - poppler/Annot.h | 12 ++++++++---- - 2 files changed, 8 insertions(+), 7 deletions(-) - -commit 17b2623360ed8917e94a8e5b880e92e6db70335e -Author: Adrian Perez de Castro -Date: Tue Jun 18 00:35:51 2013 +0300 - - Tagged-PDF: Text content extraction from structure elements - - Implement StructElement::getText(), by using MCOutputDev. This - output device - captures pieces of text (aka "spans") which have the same attributes - into - a list of TextSpan objects. - - https://bugs.freedesktop.org/show_bug.cgi?id=64815 - - poppler/Makefile.am | 2 + - poppler/MarkedContentOutputDev.cc | 210 - ++++++++++++++++++++++++++++++++++++++ - poppler/MarkedContentOutputDev.h | 128 +++++++++++++++++++++++ - poppler/StructElement.cc | 50 +++++++++ - poppler/StructElement.h | 28 +++++ - 5 files changed, 418 insertions(+) - -commit 2c4320c26744ea28be10eac7cc54980c9eb4fc27 -Author: Carlos Garcia Campos -Date: Tue Dec 3 19:07:09 2013 +0100 - - glib-demo: Show number of charcters and text layout units in text demo - - It helps to easily detect the cases where these values mismatch. - - glib/demo/text.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 98d75dcdb9b73feb6f35d8ad76f5d0c428289f91 -Author: Jason Crain -Date: Sat Nov 30 17:29:50 2013 +0100 - - Limit use of ZapfDingbats character names - - Some PDFs use names from ZapfDingbats (a1-a206) without intending for - them to be used for text extraction. Only use these character names - to locate glyphs or for text extraction with ZapfDingbats fonts. - - Bug #60243 - - goo/GooString.cc | 10 ++ - goo/GooString.h | 4 + - poppler/GfxFont.cc | 15 +- - poppler/GlobalParams.cc | 33 +++- - poppler/GlobalParams.h | 16 +- - poppler/NameToUnicodeTable.h | 415 - ++++++++++++++++++++++--------------------- - 6 files changed, 274 insertions(+), 219 deletions(-) - -commit 817cc333ca8009998f2099583fd0a2fc703f3db3 -Author: Carlos Garcia Campos -Date: Fri Nov 29 10:07:16 2013 +0100 - - regtest: Do not buffer stderr output - - Some buggy documents can produce a huge stderr output because - of parsing - errors or whatever. We could give a file directly to Popen to - write the - stderr file, but we only want to create the file when there's output, - because it's what we use to know whether the command produced - output or - not. So, instead of buffering the whole output and then write it - to the - file, now we read from the pipe while the command is running, writing - the output in chunks to the file. This improves a lot the memory - consumption when running some tests. - - regtest/backends/__init__.py | 40 - ++++++++++++++++++++++++++++++---------- - 1 file changed, 30 insertions(+), 10 deletions(-) - -commit f8f82f1cc3a948239a05d7762210a3f244299db6 -Author: Carlos Garcia Campos -Date: Fri Nov 29 10:03:24 2013 +0100 - - regtest: Read test results in chunks to get the md5 digest - - Some backends can generate huge results, like huge postscript - files that - we don't want to load in memory to get the md5. So, instead of - creating - thr md5 object with the entire file, we feed it with chunks of data - using the update method. This improves a lot the memory consumption - and - performance as well. - - regtest/backends/__init__.py | 19 ++++++++++++------- - 1 file changed, 12 insertions(+), 7 deletions(-) - -commit 3444a44397a890dbeb1bd10357dbc8246fd21ad0 -Author: Carlos Garcia Campos -Date: Fri Nov 29 10:01:20 2013 +0100 - - regtest: Remove unused method _check_exit_status2 - - It was used when the backends ran in parallel odd and even pages, but - it's no longer used since threads support was added. - - regtest/backends/__init__.py | 20 -------------------- - 1 file changed, 20 deletions(-) - -commit 5f825df417947c51943f1db327e1aa6c3faa15b0 -Author: Carlos Garcia Campos -Date: Fri Nov 29 09:57:57 2013 +0100 - - regtest: Do not store the current line in Printer but only its length - - We are not using the line text anymore, but only the length. - - regtest/Printer.py | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -commit 1486d93f0f6418b37ccc57568717d9349a79935b -Author: Carlos Garcia Campos -Date: Wed Nov 27 18:29:36 2013 +0100 - - regtest: Do not consider docs with no refs as skipped - - Handle them differently as new docs, and show them in the summary - suggesting to use create-refs command to include them in the test - suite. - - regtest/TestRun.py | 40 +++++++++++++++++++++++----------------- - 1 file changed, 23 insertions(+), 17 deletions(-) - -commit 5241c0cc730c380dc44c3a081e1de675e1915861 -Author: Carlos Garcia Campos -Date: Wed Nov 27 17:18:37 2013 +0100 - - regtest: Use number of tests run to show the progress - - Instead of using the number of document tested. We don't really - need to - set a number to a particular document, we only want to know the - progress - of the whole process. This ensures that the progress is shown in the - correct order. It also simplifies the code a bit. - Also improved the output formatting to make it easier to read. - - regtest/Printer.py | 44 ++++----------- - regtest/TestReferences.py | 50 +++++++++++------ - regtest/TestRun.py | 136 - +++++++++++++++++++++++++--------------------- - 3 files changed, 118 insertions(+), 112 deletions(-) - -commit 0af3e009a702d0c6ca716565ab87b386baa0a1ed -Author: Albert Astals Cid -Date: Wed Nov 27 00:53:16 2013 +0100 - - 0.24.4 - - CMakeLists.txt | 4 ++-- - NEWS | 18 ++++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - qt5/src/Doxyfile | 2 +- - 7 files changed, 25 insertions(+), 7 deletions(-) - -commit a42a13be0a0cda71dc230a73f7b16eb4eb066251 -Author: suzuki toshiya -Date: Wed Nov 27 00:05:57 2013 +0100 - - Warn the user if he provides a wrong range - - utils/pdffonts.cc | 7 +++++++ - utils/pdfimages.cc | 7 +++++++ - utils/pdfinfo.cc | 7 +++++++ - utils/pdfseparate.cc | 7 +++++++ - utils/pdftocairo.cc | 7 +++++++ - utils/pdftohtml.cc | 8 +++++++- - utils/pdftoppm.cc | 7 +++++++ - utils/pdftops.cc | 7 +++++++ - utils/pdftotext.cc | 6 ++++++ - 9 files changed, 62 insertions(+), 1 deletion(-) - -commit 45552cafaeef6b883078db269437586add1dc32c -Author: Albert Astals Cid -Date: Tue Nov 26 23:36:12 2013 +0100 - - Update copyrights - - utils/pdftotext.cc | 1 + - 1 file changed, 1 insertion(+) - -commit f20fe89d4f5a8f768e2019f25cecf40cd0e4f5f8 -Author: Carlos Garcia Campos -Date: Mon Nov 25 09:05:41 2013 +0100 - - glib-demo: Add an area selector to text demo - - And use the for_area variants of the API to get the text, text layout - and text attributes. - - glib/demo/text.c | 114 - +++++++++++++++++++++++++++++++++++++++++++++++++++++-- - 1 file changed, 110 insertions(+), 4 deletions(-) - -commit bb2b7fb491fb72f0ea024d80df89680ede3457b4 -Author: Carlos Garcia Campos -Date: Mon Nov 25 09:04:30 2013 +0100 - - glib: Add API to get text, text layout and text attributes for a - given area - - glib/poppler-page.cc | 107 - ++++++++++++++++++++++++++++++++++-- - glib/poppler-page.h | 8 +++ - glib/reference/poppler-sections.txt | 3 + - 3 files changed, 113 insertions(+), 5 deletions(-) - -commit f662973b0da52da84acc3668a0e037ee72498193 -Author: Carlos Garcia Campos -Date: Sat Nov 2 14:07:07 2013 +0100 - - TextOutputDev: Honor the selection rectangle passed to - TextPage::getSelectionWords() - - Make TextPage::getSelectionWords() return a list of TextWordSelection - instead of a list of TextWord so that it's possible to know which - characters of the word are inside the given selection rectangle. - Adapt the glib frontend to the new API and use the selection bounds - instead of the whole word to build the list of characters in - poppler_page_get_text_layout() and poppler_page_get_text_attributes(), - which ensures the number of glyphs returned is in sync with the number - of characters returned by poppler_page_get_text(). - - https://bugs.freedesktop.org/show_bug.cgi?id=71160 - - glib/poppler-page.cc | 22 ++++++++++++++-------- - poppler/TextOutputDev.cc | 40 ++++++++-------------------------------- - poppler/TextOutputDev.h | 20 ++++++++++++++++++++ - 3 files changed, 42 insertions(+), 40 deletions(-) - -commit 18fab454c59b1c77c691617aaef99245eacd83b5 -Author: Germán Poo-Caamaño -Date: Mon Oct 28 22:41:41 2013 -0700 - - glib-demo: Simplify annotations list and its properties - - * Move the annotation's rectangle to properties to make the - list view of annotations cleaner. - * Remove duplicated information: flags and page are already - present in the UI. - - https://bugs.freedesktop.org/show_bug.cgi?id=70982 - - glib/demo/annots.c | 70 - ++++++++++++------------------------------------------ - 1 file changed, 15 insertions(+), 55 deletions(-) - -commit 770a7ac9833a3c4f4f0399093272d4d0bdc7923b -Merge: e7a0f2b 9ae29c7 -Author: Albert Astals Cid -Date: Thu Nov 21 23:58:29 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.24' - -commit 9ae29c7a07d0f372dbfc4aca17bbb646126aedb5 -Author: Thomas Freitag -Date: Thu Nov 21 23:53:53 2013 +0100 - - Don't end loop if reading from GooFile fails - - Bug #71835 - - poppler/Stream.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit e7a0f2b942fe621304275175324f7809d1c83d80 -Author: Hib Eris -Date: Wed Nov 20 00:43:27 2013 +0100 - - Fix warning on signed/unsigned comparison in GfxState.cc - - Bug #71641 - - poppler/GfxState.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit c784c4c3a582aaa4e10c223665cb876e12b7c16f -Author: Germán Poo-Caamaño -Date: Mon Nov 18 00:57:53 2013 -0800 - - glib-demo: Add support for simple line annotations - - https://bugs.freedesktop.org/show_bug.cgi?id=70981 - - glib/demo/annots.c | 99 - +++++++++++++++++++++++++++++++++++++++++++++++++----- - 1 file changed, 91 insertions(+), 8 deletions(-) - -commit 2d164e06b8a84ade6689d85bba2d606c66bf62a9 -Author: Germán Poo-Caamaño -Date: Mon Nov 18 00:48:13 2013 -0800 - - glib-demo: add color selection for new annotations - - https://bugs.freedesktop.org/show_bug.cgi?id=71727 - - glib/demo/annots.c | 34 ++++++++++++++++++++++++++++++++++ - 1 file changed, 34 insertions(+) - -commit 7127a2c705787f6f44b0852efeabe9fdeae7e2c0 -Author: Germán Poo-Caamaño -Date: Sun Nov 17 23:38:32 2013 -0800 - - glib: Add support for simple line annotations - - https://bugs.freedesktop.org/show_bug.cgi?id=70981 - - glib/poppler-annot.cc | 79 - +++++++++++++++++++++++++++++++++++++ - glib/poppler-annot.h | 12 ++++++ - glib/poppler-page.cc | 3 ++ - glib/poppler-private.h | 1 + - glib/poppler.h | 1 + - glib/reference/poppler-sections.txt | 7 ++++ - 6 files changed, 103 insertions(+) - -commit 451bac9f05bab18f3aa0392ddf6eb6b569004cb8 -Author: Germán Poo-Caamaño -Date: Sun Nov 17 23:30:14 2013 -0800 - - glib: Add PopplerPoint boxed type - - https://bugs.freedesktop.org/show_bug.cgi?id=70981 - - glib/poppler-page.cc | 54 - +++++++++++++++++++++++++++++++++++++ - glib/poppler-page.h | 20 ++++++++++++++ - glib/poppler.h | 1 + - glib/reference/poppler-sections.txt | 5 ++++ - 4 files changed, 80 insertions(+) - -commit c01cee165392ba8297e4168111a66d2acb272a99 -Merge: 07c2554 47605a8 -Author: Albert Astals Cid -Date: Mon Nov 18 22:58:28 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.24' - - Conflicts: - poppler/Catalog.cc - poppler/Catalog.h - -commit 47605a8aaf85bee21601219b04c0c8e6cf982507 -Author: José Aliste -Date: Mon Nov 18 22:52:08 2013 +0100 - - Catalog: sort entries of NameTrees to make sure lookup works - - Bug #26049 - - poppler/Catalog.cc | 12 ++++++++++++ - poppler/Catalog.h | 2 ++ - 2 files changed, 14 insertions(+) - -commit 07c255482f7ec8a8cfd4eaeaf7b07de317bbcc7a -Author: Germán Poo-Caamaño -Date: Sun Oct 27 13:30:22 2013 -0700 - - glib-demo: Add annotations interactively - - * Prepare UI to add multiple annotations type. - * Remove dialog and button add annotations. - - https://bugs.freedesktop.org/show_bug.cgi?id=69978 - - glib/demo/annots.c | 348 - ++++++++++++++++++++++++++++++++--------------------- - 1 file changed, 213 insertions(+), 135 deletions(-) - -commit 4b7c91ea697359751f9abe9ec5e63021c90a60ed -Author: Germán Poo-Caamaño -Date: Sat Sep 28 23:18:07 2013 -0700 - - glib: Add getter and setter for annotation's rectangle - - Annotation objects contain at least two keys, Rect and Subtype. - The former has the coordinates where the annotation is placed. - The getter and setter allows to obtain and modify the position - of a given annotation. - - https://bugs.freedesktop.org/show_bug.cgi?id=70901 - - glib/poppler-annot.cc | 48 - +++++++++++++++++++++++++++++++++++++ - glib/poppler-annot.h | 4 ++++ - glib/reference/poppler-sections.txt | 2 ++ - 3 files changed, 54 insertions(+) - -commit 491f0a170c72271a7a9ce049fbcfe81f08cff162 -Author: suzuki toshiya -Date: Fri Nov 15 20:35:12 2013 +0100 - - pdftotext: Escape the text of the xml headers - - utils/pdftotext.cc | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit 4da94680d4d2d6b1bd3351d476a20f9c7ae565bc -Merge: 3ea3d7c 78c407a -Author: Albert Astals Cid -Date: Fri Nov 15 20:27:00 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.24' - -commit 3ea3d7c6c7a0ede76428204ec11aec3a844117fc -Author: Hib Eris -Date: Fri Nov 15 19:59:52 2013 +0100 - - pdftotext: Silence warning for may be used uninitialized variable - - Bug #71640 - - utils/pdftotext.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 97910b9eb92df49757915bde02e0d54de04552d4 -Author: Hib Eris -Date: Fri Nov 15 19:55:19 2013 +0100 - - Do not close stdout in pdftotext - - Bug #71639 - - utils/pdftotext.cc | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit 78c407ac7e8f48ae2d2c75ad0f5960390190d2e3 -Author: Albert Astals Cid -Date: Fri Nov 15 20:25:52 2013 +0100 - - destionation -> destination - - And this is why the xml based api has to die - - Bug #71643 - Found by Hib - - qt4/src/poppler-annotation.cc | 5 +++-- - qt5/src/poppler-annotation.cc | 3 ++- - 2 files changed, 5 insertions(+), 3 deletions(-) - -commit a23c9ad4c0536d680bedc563444ce3adf6e1ee9e -Author: Hib Eris -Date: Fri Nov 15 11:38:45 2013 +0100 - - Silence warning for may be used uninitialized variable in - ImageOutputDec.cc - - Fixes warning: - - CXX ImageOutputDev.lo - ImageOutputDev.cc: In member function 'void - ImageOutputDev::writeImageFile(ImgWriter*, - ImageOutputDev::ImageFormat, const char*, Stream*, int, int, - GfxImageColorMap*)': - ImageOutputDev.cc:409:28: warning: 'imgStr' may be used uninitialized - in this function [-Wmaybe-uninitialized] - - Bug #71642 - - utils/ImageOutputDev.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit c43a80e65fc570a8017892ba111a8c48ac33d9ad -Author: Hib Eris -Date: Fri Nov 15 19:59:52 2013 +0100 - - pdftotext: Silence warning for may be used uninitialized variable - - Bug #71640 - - utils/pdftotext.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit f905d804c0d1c715d8423938f41b5a002c0ef15d -Author: Hib Eris -Date: Fri Nov 15 19:55:19 2013 +0100 - - Do not close stdout in pdftotext - - Bug #71639 - - utils/pdftotext.cc | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit 33e703ac9bb6cf69664d6c6fddd3bebd56336074 -Merge: 8294d18 7c74bcc -Author: Albert Astals Cid -Date: Fri Nov 15 19:50:10 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.24' - -commit 7c74bccdf514cce05987dde7fb1cce4ac65ff025 -Author: Albert Astals Cid -Date: Fri Nov 15 19:48:07 2013 +0100 - - Forgot to update the copyrights - - poppler/Lexer.cc | 2 +- - poppler/Lexer.h | 2 +- - poppler/Parser.cc | 2 +- - poppler/Parser.h | 2 +- - 4 files changed, 4 insertions(+), 4 deletions(-) - -commit ebe49d597a62aa94601c2e4595dbad1895ea7ef0 -Author: Albert Astals Cid -Date: Fri Nov 15 19:33:00 2013 +0100 - - Fix regression in broken endstream detection - - Rregression was caused by e1ffa9100cf6b4a444be7ed76b11698a5c5bb441 - Fixes bug #70854 - - poppler/Lexer.cc | 4 ++-- - poppler/Lexer.h | 2 +- - poppler/Parser.cc | 11 ++++------- - poppler/Parser.h | 2 +- - 4 files changed, 8 insertions(+), 11 deletions(-) - -commit 8294d18ea96bd18be076bccbdbdaa015fc48aa12 -Author: Adrian Perez de Castro -Date: Thu Sep 26 20:46:34 2013 +0300 - - Tagged-PDF: Parsing of StructElem standard types and attributes - - Parse attributes and standard types of StructElem nodes of the - document structure tree. Type name aliases are resolved via the - RoleMap (and cycles detected). Both standard attributes and user - properties are mapped to instances of the Attribute class. - Attributes are parsed both via ClassMap references and directly - referenced from the StructElem objects. - - https://bugs.freedesktop.org/show_bug.cgi?id=64815 - - poppler/StructElement.cc | 1018 - +++++++++++++++++++++++++++++++++++++++++++++- - poppler/StructElement.h | 113 ++++- - 2 files changed, 1126 insertions(+), 5 deletions(-) - -commit 4e0cbd37b964107c0fb531d48876a33ae843bf27 -Author: suzuki toshiya -Date: Mon Nov 11 22:46:07 2013 +0100 - - pdftohtml: Add -? and --help - - utils/pdftohtml.cc | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -commit 4dbd36f5b35dd0964e59d942242aecdc6b474c89 -Author: Andres Gomez -Date: Tue Nov 5 09:52:23 2013 +0200 - - glib-demo: Fix conding style issue in main.c - - https://bugs.freedesktop.org/show_bug.cgi?id=71245 - - glib/demo/main.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 02f3c235eaf60350c98e88dbe266378fccef59d7 -Author: Andres Gomez -Date: Tue Nov 5 09:52:23 2013 +0200 - - glib-demo: Fix a typo in function name - - https://bugs.freedesktop.org/show_bug.cgi?id=71245 - - glib/demo/main.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 5620b82e69335b7f12d877a24f1a463604f0e515 -Author: Andres Gomez -Date: Tue Nov 5 09:52:23 2013 +0200 - - glib-demo: Fix trailing whitespaces in main.c - - https://bugs.freedesktop.org/show_bug.cgi?id=71245 - - glib/demo/main.c | 14 +++++++------- - 1 file changed, 7 insertions(+), 7 deletions(-) - -commit 43309d92d327b4ae8e89edb15482247045d726a4 -Author: Germán Poo-Caamaño -Date: Sat Sep 28 20:45:32 2013 -0700 - - glib-demo: Make the Remove annotation button prominent in demo - - Move out from Annotation properties to the top. This make better - use of the space. - Make the remove button active only if there is an annotation - selected. - - https://bugs.freedesktop.org/show_bug.cgi?id=69978 - - glib/demo/annots.c | 22 +++++++++++++--------- - 1 file changed, 13 insertions(+), 9 deletions(-) - -commit f4a72fd3c61091d6b455af9a881c2390da19b506 -Author: Albert Astals Cid -Date: Sat Oct 26 19:06:34 2013 +0200 - - 0.24.3 - - CMakeLists.txt | 2 +- - NEWS | 14 ++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - qt5/src/Doxyfile | 2 +- - 6 files changed, 19 insertions(+), 5 deletions(-) - -commit 33a5af32cd5769cf1b6c6344077ac4a3f407ba21 -Author: Albert Astals Cid -Date: Sat Oct 26 18:48:50 2013 +0200 - - Update copyrights - - qt4/src/poppler-document.cc | 2 +- - utils/pdfseparate.cc | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 9f09b9596f1fc52481914019d68c8f9b85b5c438 -Merge: bd893d4 61f79b8 -Author: Albert Astals Cid -Date: Thu Oct 24 01:03:02 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.24' - -commit 61f79b8447c3ac8ab5a26e79e0c28053ffdccf75 -Author: Albert Astals Cid -Date: Thu Oct 24 00:54:56 2013 +0200 - - Allow only one %d in the filename - - Fixes crashes if you had %s and similar in the filename - - Inspired from patch by Pedro Ribeiro - - Bug #69434 - - utils/pdfseparate.cc | 31 ++++++++++++++++++++++++++++++- - 1 file changed, 30 insertions(+), 1 deletion(-) - -commit bd893d4a543a6cc3a525655f37def38440944f28 -Merge: 93e8b05 daa0990 -Author: Albert Astals Cid -Date: Thu Oct 10 02:19:34 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.24' - -commit daa0990a7baf17d00d12574a4de815e070727a86 -Author: Albert Astals Cid -Date: Thu Oct 10 02:16:25 2013 +0200 - - Return empty if getXRef()->copy() fails - - Seems this can happen by looking at the backtrace in - https://bugs.kde.org/show_bug.cgi?id=325810 - - qt4/src/poppler-document.cc | 6 ++++++ - qt5/src/poppler-document.cc | 6 ++++++ - 2 files changed, 12 insertions(+) - -commit f4bfa940aa40a82a1080cdaf765da1d1615ccfb1 -Author: Carlos Garcia Campos -Date: Sat Oct 5 11:20:04 2013 +0200 - - cairo: Do not set an invalid matrix in drawImage() - - https://bugs.freedesktop.org/show_bug.cgi?id=70085 - - poppler/CairoOutputDev.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 93e8b05fb2a6d225f048db6a3a735717433a5a13 -Author: Carlos Garcia Campos -Date: Sat Oct 5 11:20:04 2013 +0200 - - cairo: Do not set an invalid matrix in drawImage() - - https://bugs.freedesktop.org/show_bug.cgi?id=70085 - - poppler/CairoOutputDev.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 3084f8f4a5ad55937094b14e30169dccf1fa4ec9 -Author: Germán Poo-Caamaño -Date: Sat Sep 21 11:59:32 2013 -0700 - - glib-demo: Expand short names for annotations used in demo - - https://bugs.freedesktop.org/show_bug.cgi?id=69978 - - glib/demo/annots.c | 10 +++++----- - glib/demo/main.c | 2 +- - 2 files changed, 6 insertions(+), 6 deletions(-) - -commit ff674f57a3587142165fd56aec089d9840ceda36 -Author: Germán Poo-Caamaño -Date: Fri Sep 27 22:33:42 2013 -0700 - - glib-demo: Merge columns Type and Color in annotations demo - - Reduce the space used by both columns, makes the color - pixbuf smaller enough to give a clue of the annotation - color. - - https://bugs.freedesktop.org/show_bug.cgi?id=69978 - - glib/demo/annots.c | 28 ++++++++++++++++------------ - 1 file changed, 16 insertions(+), 12 deletions(-) - -commit 76d6e2d385e2cbad7f44bc8aee05147efd3970a4 -Author: Germán Poo-Caamaño -Date: Fri Sep 20 23:27:20 2013 -0700 - - glib-demo: Rearrange layout for annotations in demo - - Add render area to visualize the annotations per page. - - https://bugs.freedesktop.org/show_bug.cgi?id=69978 - - glib/demo/annots.c | 130 - ++++++++++++++++++++++++++++++++++++++++++++++++----- - 1 file changed, 118 insertions(+), 12 deletions(-) - -commit a6b1fc1a2ca83b3e4c52bcaa95b99d0289354f4b -Author: Germán Poo-Caamaño -Date: Sun Sep 29 22:50:42 2013 -0700 - - glib-demo: Fix rectangle calculation for new annotations in demo - - https://bugs.freedesktop.org/show_bug.cgi?id=69978 - - glib/demo/annots.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit bd49b3c0c6f2adccc5bda561edbaf9f00ed2917a -Author: Thomas Freitag -Date: Wed Oct 2 23:32:09 2013 +0200 - - Use icc profile in OutputIntents - - Bug #34053 - - poppler/Gfx.cc | 114 +++++++++++--- - poppler/Gfx.h | 8 +- - poppler/GfxState.cc | 429 - +++++++++++++++++++++++++++++++++++++++++----------- - poppler/GfxState.h | 72 ++++++--- - poppler/Page.cc | 2 +- - 5 files changed, 490 insertions(+), 135 deletions(-) - -commit df947a0641082f530200880d46e20cd3e1fd962f -Author: Albert Astals Cid -Date: Wed Oct 2 20:53:32 2013 +0200 - - Compile++ - - CMakeLists.txt | 4 ++++ - 1 file changed, 4 insertions(+) - -commit fa83d7e4f36cfc11c7b4f81f5f5e8ed69eb6dbbe -Author: Daniel Kahn Gillmor -Date: Wed Oct 2 20:35:58 2013 +0200 - - pdfseparate: allow zero-padded pagespecs - - Bug #50914 - - utils/pdfseparate.cc | 22 +++++++++++++++++++--- - 1 file changed, 19 insertions(+), 3 deletions(-) - -commit e04cabd878a0fd84faa5178f423fd828d010b664 -Author: Adrian Perez de Castro -Date: Mon Jun 17 17:00:27 2013 +0300 - - Tagged-PDF: Implement parsing of StructTreeRoot - - Implement parsing of the StructTreeRoot entry of the Catalog. Also, - the - Catalog::getStructTreeRoot() and PDFDoc::getStructTreeRoot() - methods are - modified to return an instance of StructTreeRoot instead of an Object. - - All elements from the StructTreeRoot are parsed except for: - - - IDTree: it is a lookup tree to locate items by their ID, which would - be barely useful because the whole structure tree is to be kept in - memory, which should be fast enough to traverse. - - ParentTreeNextKey: This is needed only when the ParentTree object is - to be modified. For the moment the implementation deals only with - reading, so this has been deliberately left out. - - StructElem tree nodes from the document structure tree are parsed as a - StructElement instance. Attributes and extraction of content out from - elements are not yet handled. - - https://bugs.freedesktop.org/show_bug.cgi?id=64815 - - poppler/Catalog.cc | 36 +++--- - poppler/Catalog.h | 5 +- - poppler/Makefile.am | 4 + - poppler/PDFDoc.h | 3 +- - poppler/StructElement.cc | 322 - ++++++++++++++++++++++++++++++++++++++++++++++ - poppler/StructElement.h | 167 ++++++++++++++++++++++++ - poppler/StructTreeRoot.cc | 174 +++++++++++++++++++++++++ - poppler/StructTreeRoot.h | 83 ++++++++++++ - 8 files changed, 776 insertions(+), 18 deletions(-) - -commit 45e0fe56985f34e695c99a2f6ec1ffe14e239b9e -Author: Adrian Perez de Castro -Date: Thu Sep 26 20:56:52 2013 +0300 - - Implement Object::takeString() method - - Object::takeString() behaves like Object::getString(), but transfers - ownership of the returned string to the caller. Also, it makes - sure that - calling Object::free() afterwards won't free the string that the - Object - is holding. - - poppler/Object.h | 4 ++++ - 1 file changed, 4 insertions(+) - -commit d80eb4a34c218de34633ee2f1b9dfd65504a0ad9 -Author: Thomas Freitag -Date: Tue Oct 1 22:57:55 2013 +0200 - - cache cms values in getGray(), getRGB() and getCMYK() - - Bug #68420 - - poppler/GfxState.cc | 111 - ++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/GfxState.h | 2 + - 2 files changed, 113 insertions(+) - -commit 9bc8f3240698d5a8ae4c0129e768840664d28c22 -Merge: a2742c8 e2fe851 -Author: Albert Astals Cid -Date: Tue Oct 1 19:19:32 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.24' - -commit e2fe85137ecb59eb0d177682c552febc64cda643 -Author: Adrian Johnson -Date: Tue Oct 1 19:15:08 2013 +0200 - - Fix PFB font embedding - - Bug #69717 - - poppler/PSOutputDev.cc | 52 - ++++++++++++++++++++++++++++++++++++++++++++------ - 1 file changed, 46 insertions(+), 6 deletions(-) - -commit a2742c8fce0594ccbdb036dd0c29c6e15d2229f3 -Merge: 6b30a52 06dabe1 -Author: Albert Astals Cid -Date: Mon Sep 30 19:32:41 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.24' - -commit 06dabe1eed912e5f5c96fe9f371ab459516e5a99 -Author: Albert Astals Cid -Date: Fri Sep 27 12:41:23 2013 +0200 - - 0.24.2 - - CMakeLists.txt | 2 +- - NEWS | 8 ++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - qt5/src/Doxyfile | 2 +- - 6 files changed, 13 insertions(+), 5 deletions(-) - -commit 78141da189c42a04b6a303767284de755a4a2d4d -Author: Albert Astals Cid -Date: Fri Sep 27 12:39:00 2013 +0200 - - Update copyrights - - utils/pdfseparate.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 6b30a5214e39993025cf2fb9f221e1360de7fa9c -Merge: 4966b6f dc344b4 -Author: Albert Astals Cid -Date: Sat Sep 21 10:38:45 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.24' - -commit dc344b410f49410174ee902b7649ebd8c2cb0fa2 -Author: Lu Wang -Date: Sat Sep 21 10:37:30 2013 +0200 - - pdftocairo: check file opening failure in beginDocument() - - utils/pdftocairo.cc | 7 +++++++ - 1 file changed, 7 insertions(+) - -commit 4966b6f4193cc9d13f63e92bdc2aac0c8b78298d -Merge: 0f074b1 1e612d3 -Author: Albert Astals Cid -Date: Sat Sep 21 10:15:28 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.24' - -commit 1e612d331b79dabec66ad241d7ffe66674a10bc4 -Author: Thomas Freitag -Date: Sat Sep 21 10:10:16 2013 +0200 - - Windows: Fix CreateFile fails with ERROR_SHARING_VIOLATION - - Bug #69597 - - goo/gfile.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 0f074b16317d874fe58d7042f8434282786ca757 -Merge: d277432 b8682d8 -Author: Pino Toscano -Date: Mon Sep 16 19:53:10 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.24' - - Conflicts: - utils/pdfimages.1 - -commit b8682d868ddf7f741e93b791588af0932893f95c -Author: Pino Toscano -Date: Mon Sep 16 19:46:55 2013 +0200 - - pdfseparate: improve the path building - - Make use of snprintf to limit the output to the pathName buffer; - while I'm there, expand its size to 4096 (might help longer paths), - although a better fix would be dynamically allocate its length - (and/or using GooString, maybe). - - utils/pdfseparate.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit d2774325f5248018977d3ab8f8dd7155ed972668 -Author: Adrian Johnson -Date: Sat Sep 14 14:08:11 2013 +0930 - - pdfimages.1: fix typo - - utils/pdfimages.1 | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 9b5957278c7f249fa1010e61a0ed79f0eb20e26d -Author: Adrian Johnson -Date: Sat Aug 31 17:33:25 2013 +0930 - - pdfimages: ensure dump* variables are intialized - - utils/ImageOutputDev.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit e116ef32504b589001814f0f579309ecf7ec89d9 -Author: Adrian Johnson -Date: Wed Aug 28 08:05:23 2013 +0930 - - Make cpp/poppler-image.cc use goo/NetPBMWriter - - cpp/CMakeLists.txt | 1 - - cpp/Makefile.am | 2 - - cpp/PNMWriter.cc | 119 - -------------------------------------------------- - cpp/PNMWriter.h | 43 ------------------ - cpp/poppler-image.cpp | 14 +++--- - 5 files changed, 6 insertions(+), 173 deletions(-) - -commit a87a11ee6bbd0f5707a3ac34ac2b9cc79f4e92d0 -Author: Adrian Johnson -Date: Thu Aug 29 22:42:34 2013 +0930 - - pdfimages: support cmyk tiff output - - If -tiff is specified, CMYK images will be written as CMYK TIFF files - instead of converting to RGB. If both -png and -tiff are specified (as - is the case with the -all option), CMYK images are written as TIFF and - all other types as PNG. - - utils/ImageOutputDev.cc | 32 +++++++++++++++++++++++++++++++- - utils/ImageOutputDev.h | 3 ++- - utils/pdfimages.1 | 13 ++++++++----- - utils/pdfimages.cc | 3 ++- - 4 files changed, 43 insertions(+), 8 deletions(-) - -commit 63da26f8fb0b2b5ffaa127762d4e36d995c482ee -Author: Thomas Freitag -Date: Tue Aug 27 20:40:29 2013 +0200 - - resolve copy&paste error - - poppler/GfxState.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 563da2d375c003478d398897796ecbf45ce03482 -Author: Albert Astals Cid -Date: Mon Aug 26 22:33:10 2013 +0200 - - 0.24.1 - - CMakeLists.txt | 2 +- - NEWS | 23 +++++++++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - qt5/src/Doxyfile | 2 +- - 6 files changed, 28 insertions(+), 5 deletions(-) - -commit 2c73f1ea9116172692d8350cb7adf1b5376f795c -Author: Albert Astals Cid -Date: Mon Aug 26 21:50:51 2013 +0200 - - Fix typo - - qt5/src/poppler-qt5.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit f58e9b64d5cf62906876c5c0f8da0f3c2c6c2bac -Author: Albert Astals Cid -Date: Mon Aug 26 00:27:59 2013 +0200 - - Some more files Adrian has changed - - goo/PNGWriter.h | 2 +- - utils/HtmlOutputDev.cc | 2 +- - utils/pdftocairo.cc | 2 +- - 3 files changed, 3 insertions(+), 3 deletions(-) - -commit 16da389c61c495111a5a49f62539a423a0655c28 -Author: Adrian Johnson -Date: Mon Aug 26 07:50:51 2013 +0930 - - fix typo in pdfimages.1 - - utils/pdfimages.1 | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 56c0d4f3a231dca141c06493b50ab25959b5b15c -Author: Adrian Johnson -Date: Mon Aug 26 07:47:46 2013 +0930 - - fix typo in pdfimages.1 - - utils/pdfimages.1 | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit af4f2b775946815b572622bf4c4d42ad3aea1141 -Author: Adrian Johnson -Date: Sat Aug 24 21:25:51 2013 +0930 - - pdfimages: Add -all option to write all image in their native format - - utils/pdfimages.1 | 4 ++++ - utils/pdfimages.cc | 23 +++++++++++++++++------ - 2 files changed, 21 insertions(+), 6 deletions(-) - -commit 25e96b6ddbbe54a75ddb97d2e235c1bd6033fe79 -Author: Adrian Johnson -Date: Wed Aug 21 22:22:28 2013 +0930 - - pdfimages: support ccitt output - - poppler/Stream.h | 5 +++++ - utils/ImageOutputDev.cc | 35 +++++++++++++++++++++++++++++++++++ - utils/ImageOutputDev.h | 4 ++++ - utils/pdfimages.1 | 39 ++++++++++++++++++++++++++++++++++++++- - utils/pdfimages.cc | 4 ++++ - 5 files changed, 86 insertions(+), 1 deletion(-) - -commit 086413263cb63a24d9492fbe534fdcc34b45951a -Author: Adrian Johnson -Date: Sun Aug 18 20:37:01 2013 +0930 - - pdfimages: support JBIG2 output - - poppler/JBIG2Stream.h | 1 + - utils/ImageOutputDev.cc | 25 +++++++++++++++++++++++++ - utils/ImageOutputDev.h | 4 ++++ - utils/pdfimages.1 | 13 ++++++++----- - utils/pdfimages.cc | 4 ++++ - 5 files changed, 42 insertions(+), 5 deletions(-) - -commit 2845ebabd00a2755549b8db436e78a3e0e0c0713 -Author: Adrian Johnson -Date: Sun Aug 18 20:07:31 2013 +0930 - - pdfimages: add support for writing JPEG2000 files - - utils/ImageOutputDev.cc | 4 ++++ - utils/ImageOutputDev.h | 4 ++++ - utils/pdfimages.1 | 12 ++++++++---- - utils/pdfimages.cc | 4 ++++ - 4 files changed, 20 insertions(+), 4 deletions(-) - -commit 2021c8ffcb36432049c4305e85ced2ae139086f3 -Author: Adrian Johnson -Date: Sun Aug 18 17:29:00 2013 +0930 - - pdfimages: add support for png and tiff output - - utils/ImageOutputDev.cc | 67 - ++++++++++++++++++++++++++++++++++++++++++++++--- - utils/ImageOutputDev.h | 17 +++++++++++-- - utils/pdfimages.1 | 22 ++++++++++------ - utils/pdfimages.cc | 19 +++++++++++--- - 4 files changed, 110 insertions(+), 15 deletions(-) - -commit 8f466775c77b09a7114c688004317e6db05bcd3f -Author: Adrian Johnson -Date: Sun Aug 18 16:08:02 2013 +0930 - - Change PNGWriter monochrome format to be 8 pixels/byte - - to be consistent with TiffWriter and NetPBMWriter - - goo/PNGWriter.cc | 4 ---- - goo/PNGWriter.h | 2 +- - utils/HtmlOutputDev.cc | 31 +++++++++++++++++++------------ - utils/ImageOutputDev.cc | 9 ++++++--- - utils/pdftocairo.cc | 2 +- - 5 files changed, 27 insertions(+), 21 deletions(-) - -commit e53aec2c61ba42cf0635dc05f8e27e3503c1eaac -Author: Adrian Johnson -Date: Sun Aug 18 15:50:39 2013 +0930 - - Refactor ImageOutputDev to facilitate adding more output formats - - - Move PPM/PBM code into a NetPBMWriter class so PNGWriter and - TiffWritersupport be added. - - - Create generic WriteRawIMage function for writing jpeg files so - support for jpeg2000/jbig2 can be added. - - CMakeLists.txt | 1 + - goo/Makefile.am | 2 + - goo/NetPBMWriter.cc | 84 ++++++++++++++++ - goo/NetPBMWriter.h | 52 ++++++++++ - utils/ImageOutputDev.cc | 261 - +++++++++++++++++++++--------------------------- - utils/ImageOutputDev.h | 15 +-- - 6 files changed, 262 insertions(+), 153 deletions(-) - -commit 0ca0fcc9f536a57365048914cd8a8cc3eb5ed4fd -Author: Adrian Johnson -Date: Sat Aug 17 15:24:43 2013 +0930 - - pdfimages: fix bug in -list output - - Images of type /ImageMask should have type 'stencil'. - - utils/ImageOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit f8ee5a931c795013d17f73f083b6e6f9a683d061 -Author: Adrian Johnson -Date: Sat Aug 17 15:17:11 2013 +0930 - - pdfimages: print size, ratio, and ppi - - utils/ImageOutputDev.cc | 100 - ++++++++++++++++++++++++++++++++++++++++++++---- - utils/pdfimages.1 | 12 ++++++ - utils/pdfimages.cc | 2 +- - 3 files changed, 106 insertions(+), 8 deletions(-) - -commit b5321c4f40fb56b10f75c14c5c955c5775cf2ef9 -Author: Thomas Freitag -Date: Sun Aug 25 20:13:12 2013 +0200 - - use getCMYK/DeviceNLine in CMYK mode if available - - Second part of bug 66928 - - poppler/GfxState.cc | 310 - ++++++++++++++++++++++++++++++++++++++++++++- - poppler/GfxState.h | 32 ++++- - poppler/SplashOutputDev.cc | 28 ++-- - splash/SplashTypes.h | 2 - - 4 files changed, 355 insertions(+), 17 deletions(-) - -commit d006ac567e59e82c4c6cb42c5e429a4aa516ac0b -Merge: d391af7 ed3585e -Author: Albert Astals Cid -Date: Sun Aug 25 19:36:33 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.24' - -commit ed3585efc8b259cb065eac361a6a499f9f26851f -Author: William Bader -Date: Sun Aug 25 19:31:11 2013 +0200 - - Fix pdftops -eps -level1sep rendering of a file - - Since 8fb243bf11a979af8bfa36427436940706c9f71d we have - case splashModeXBGR8: - + cSrcNonIso[3] = 255; - and that means splashModeDeviceN8 and splashModeCMYK8 can't - skip their breaks anymore otherwise the cSrcNonIso[3] gets - overwritten - - Bug #68321 - - splash/Splash.cc | 11 +++++++---- - 1 file changed, 7 insertions(+), 4 deletions(-) - -commit d391af7ea63c4bc884bb81895aea0cdd8f8b282a -Author: Albert Astals Cid -Date: Sat Aug 24 14:03:49 2013 +0200 - - Update copyrights - - poppler/Annot.cc | 1 + - poppler/Annot.h | 1 + - poppler/Catalog.cc | 2 ++ - poppler/Catalog.h | 2 ++ - poppler/Form.cc | 2 +- - poppler/Form.h | 1 + - poppler/Page.cc | 1 + - poppler/Page.h | 1 + - utils/pdfinfo.cc | 1 + - 9 files changed, 11 insertions(+), 1 deletion(-) - -commit a47b7f853174d6101f2b882a2db1a7dc95b33293 -Author: Adrian Johnson -Date: Sat Aug 3 10:28:20 2013 +0930 - - Add pdfinfo option to print out javascript - - poppler/Catalog.h | 1 + - utils/JSInfo.cc | 164 - +++++++++++++++++++++++++++++++++++++++++------------- - utils/JSInfo.h | 12 +++- - utils/pdfinfo.1 | 3 + - utils/pdfinfo.cc | 10 ++++ - 5 files changed, 151 insertions(+), 39 deletions(-) - -commit 8f7155e7e3180bb1966a5e7df6af6acdd479939b -Author: Adrian Johnson -Date: Sat Aug 3 09:05:21 2013 +0930 - - pdfinfo: indicate if pdf contains javascript - - poppler/Annot.cc | 27 ++++++++++ - poppler/Annot.h | 8 +++ - poppler/Catalog.cc | 26 +++++++++ - poppler/Catalog.h | 12 +++++ - poppler/Form.cc | 4 ++ - poppler/Form.h | 2 + - poppler/Page.cc | 20 +++++++ - poppler/Page.h | 10 +++- - utils/CMakeLists.txt | 4 ++ - utils/JSInfo.cc | 145 - +++++++++++++++++++++++++++++++++++++++++++++++++++ - utils/JSInfo.h | 50 ++++++++++++++++++ - utils/Makefile.am | 4 ++ - utils/pdfinfo.1 | 3 ++ - utils/pdfinfo.cc | 8 +++ - 14 files changed, 322 insertions(+), 1 deletion(-) - -commit c2453fc1307ebb222747f976e1311ecc5e99abfa -Merge: 3bb8c2e 70298a0 -Author: Albert Astals Cid -Date: Tue Aug 20 19:53:17 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.24' - -commit 70298a021657a72ae80389687a86247144e6d6b6 -Author: Thomas Freitag -Date: Tue Aug 20 19:46:01 2013 +0200 - - Don't copy not needed bitmap - - Speeds up rendering of fixes from bug 67105 - As example one file is down from 130s to 6.5s - - poppler/SplashOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 3bb8c2e34039cf473bf72ed9dab55664deab3ab7 -Merge: 71c1d16 fc78330 -Author: Albert Astals Cid -Date: Tue Aug 20 00:41:13 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.24' - -commit fc78330072b9771fa39d21896703adb4836e5398 -Author: Albert Astals Cid -Date: Tue Aug 20 00:37:56 2013 +0200 - - use getRGBLine images if available - - Speeds up greatly files from bug #66928 - - E.g. some file went from 21s to 2s in my computer - - poppler/SplashOutputDev.cc | 30 +++++++++++++++++++----------- - 1 file changed, 19 insertions(+), 11 deletions(-) - -commit 71c1d162477a243db07b62ef3c056a2946f8986e -Merge: 7d1de78 678c767 -Author: Albert Astals Cid -Date: Sun Aug 18 16:41:20 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.24' - -commit 7d1de78ad79162217ee0ca6c2e99ce51017a327d -Merge: 7e0d969 fbea224 -Author: Albert Astals Cid -Date: Sun Aug 18 16:40:34 2013 +0200 - - Merge commit 'origin/poppler-0.24~1' - - This is merging the revert commits with the "ours" strategy, so - it's virtually - doing nothing other than making the stable branch mergeable again - to master - -commit 678c767584fa80620cc58a1d8a913cb3473209d4 -Author: Albert Astals Cid -Date: Sun Aug 18 16:19:27 2013 +0200 - - Fix crash in 1026.asan.0.42.pdf - - We were not checking that bitmapOff was in bounds - - splash/Splash.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit fbea2241cccdde0106d2c34592b6ddda28a8d848 -Author: Albert Astals Cid -Date: Sat Aug 17 01:32:51 2013 +0200 - - Revert "Tagged-PDF: Accessors in Catalog for the MarkInfo dictionary" - - This reverts commit 402ee8b4e31630a42a0a38db1d39164cc5789f3c. - - No clue how this ended up in the stable branch - - poppler/Catalog.cc | 45 --------------------------------------------- - poppler/Catalog.h | 10 ---------- - 2 files changed, 55 deletions(-) - -commit 6d2771b8a8c0cb0f2288d0900fea3c9edc3dd172 -Author: Albert Astals Cid -Date: Sat Aug 17 01:32:38 2013 +0200 - - Revert "pdfinfo: Use Catalog::getMarkInfo() to show mark info - properties" - - This reverts commit 73cca518c479594e26605196d54b429fbf42dcdc. - - No clue how this ended up in the stable branch - - utils/pdfinfo.cc | 8 ++------ - 1 file changed, 2 insertions(+), 6 deletions(-) - -commit 7e0d969dc2439637ab16e609df8223504316f87d -Merge: 6efc0c7 ef64206 -Author: Albert Astals Cid -Date: Sat Aug 17 01:13:30 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.24' - -commit ef6420656c7b88eb22a63ec2cb3e504e0bda0384 -Author: Albert Astals Cid -Date: Sat Aug 17 01:11:37 2013 +0200 - - Fix jpeg image export - - Use same logic than the one used in ImageOutputDev - Bug #48270 - - utils/HtmlOutputDev.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit 681f52a572b08c068cb376e5b2dc8a31676aad07 -Author: Albert Astals Cid -Date: Fri Aug 16 23:58:44 2013 +0200 - - Fix exit(1) in 1026.asan.0.42.pdf - - The main crash in discussion with Thomas - - splash/Splash.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit 9f4d7796589e4c9c1645fbbcf0cfabd79a71bde9 -Author: Thomas Freitag -Date: Thu Aug 8 20:33:54 2013 +0200 - - use copyString where memory is freed with gfree - - Bug #67666 - - poppler/Annot.cc | 2 +- - poppler/Dict.cc | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 73cca518c479594e26605196d54b429fbf42dcdc -Author: Adrian Perez de Castro -Date: Thu Apr 25 09:52:56 2013 +0300 - - pdfinfo: Use Catalog::getMarkInfo() to show mark info properties - - utils/pdfinfo.cc | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -commit 402ee8b4e31630a42a0a38db1d39164cc5789f3c -Author: Adrian Perez de Castro -Date: Thu Apr 25 09:52:56 2013 +0300 - - Tagged-PDF: Accessors in Catalog for the MarkInfo dictionary - - poppler/Catalog.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++ - poppler/Catalog.h | 10 ++++++++++ - 2 files changed, 55 insertions(+) - -commit 6efc0c7ad97a82064a1e2c47e0b063b606e56bb7 -Author: Albert Astals Cid -Date: Fri Aug 16 23:31:54 2013 +0200 - - Remove unused xref member - - poppler/OptionalContent.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit cb5160aa74f64b78a20aaed4b89fead850b42e9b -Author: Albert Astals Cid -Date: Fri Aug 16 23:31:17 2013 +0200 - - Remove usnused objectNumberFirst member - - poppler/Hints.h | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit a642aad68733c25f4055c268d691eedcf4e14a22 -Author: Albert Astals Cid -Date: Fri Aug 16 23:30:50 2013 +0200 - - PNGWriterPrivate is actually a struct not a class - - goo/PNGWriter.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 31947d413eae115acc147c33fc55b8ab4adccd91 -Author: Thomas Freitag -Date: Tue Aug 13 19:39:30 2013 +0200 - - pdftoppm: Add thinlinemode option setting - - utils/pdftoppm.1 | 12 ++++++++++++ - utils/pdftoppm.cc | 17 +++++++++++++++-- - 2 files changed, 27 insertions(+), 2 deletions(-) - -commit 8a1740b0b6ee4b217ecbe9d0046e4afa491e9f17 -Merge: b27588c c3f953d -Author: Albert Astals Cid -Date: Mon Aug 12 22:47:44 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.24' - -commit c3f953dc87f83ac726f99cb8f1f959c486098391 -Author: Yury G. Kudryashov -Date: Sat Aug 10 21:43:57 2013 +0300 - - Fix a typo - - qt4/src/poppler-qt4.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit b27588c4c946ef4f9a62248fbead4dffcb60b4d1 -Author: Yury G. Kudryashov -Date: Mon Aug 12 22:42:13 2013 +0200 - - Fix indentation - - utils/pdftotext.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit b8b5773386ee4f57e72c2b867421cdff8a2eab5a -Merge: 5f9d385 62d079b -Author: Albert Astals Cid -Date: Thu Aug 8 20:47:05 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.24' - -commit 62d079b40a2f816f59cc533b1624ea57458331f3 -Author: Yury G. Kudryashov -Date: Thu Aug 8 20:45:08 2013 +0200 - - Fix `pdftotext -bbox in.pdf -` - - Print body text to stdout if invoked as above. - - Bug #45163 - - utils/pdftotext.cc | 15 ++++++--------- - 1 file changed, 6 insertions(+), 9 deletions(-) - -commit 5f9d385dbec3148614b84ae24cae47177e18dbfc -Merge: af450a8 86dbc5f -Author: Albert Astals Cid -Date: Thu Aug 8 20:41:25 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.24' - -commit 86dbc5f6f850ba3919bed9979386e5a4d0e7dba3 -Author: Yury G. Kudryashov -Date: Thu Aug 8 20:39:30 2013 +0200 - - pdfdetach: don't mention xpdfrc - - - drop -cfg command line argument; the old code passed its value to - GlobalParams constructor which is the data dir, not a cfg file - - remove corresponding lines from pdfdetach.1 - - fix '-enc' documentation in pdfdetach.1 - - utils/pdfdetach.1 | 23 +++-------------------- - utils/pdfdetach.cc | 6 ++---- - 2 files changed, 5 insertions(+), 24 deletions(-) - -commit af450a885ede5a3eac1a12734310722963764d83 -Author: Thomas Freitag -Date: Thu Aug 8 20:33:54 2013 +0200 - - use copyString where memory is freed with gfree - - Bug #67666 - - poppler/Annot.cc | 2 +- - poppler/Dict.cc | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 030ee12875a562f5976c5569d5c76783aadf89bd -Author: Adrian Perez de Castro -Date: Thu Apr 25 09:52:56 2013 +0300 - - pdfinfo: Use Catalog::getMarkInfo() to show mark info properties - - utils/pdfinfo.cc | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -commit 9a232273988c0d2fd752dc2016e5111227ae6646 -Author: Adrian Perez de Castro -Date: Thu Apr 25 09:52:56 2013 +0300 - - Tagged-PDF: Accessors in Catalog for the MarkInfo dictionary - - poppler/Catalog.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++ - poppler/Catalog.h | 10 ++++++++++ - 2 files changed, 55 insertions(+) - -commit 2724a7b9f723789491b4991ce7fe0cfa3e5488c3 -Author: Carlos Garcia Campos -Date: Tue Jul 30 09:36:44 2013 +0200 - - glib-demo: Remove GTK_DISABLE_DEPRECATED compilation flag - - Deprecations are now compile warnings, there's no reason to make them - fatal. - - glib/demo/Makefile.am | 1 - - 1 file changed, 1 deletion(-) - -commit ef9d861486d54fb3dcf7b8bca01bd44c3b3361a9 -Author: Carlos Garcia Campos -Date: Tue Jul 30 09:36:44 2013 +0200 - - glib-demo: Remove GTK_DISABLE_DEPRECATED compilation flag - - Deprecations are now compile warnings, there's no reason to make them - fatal. - - glib/demo/Makefile.am | 1 - - 1 file changed, 1 deletion(-) - -commit eac752dc25942439de3e1c7a4ff815500a41dd2a -Author: Albert Astals Cid -Date: Mon Jul 29 19:11:55 2013 +0200 - - 0.24.0 - - CMakeLists.txt | 6 +++--- - NEWS | 7 +++++++ - configure.ac | 4 ++-- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - qt5/src/Doxyfile | 2 +- - 7 files changed, 16 insertions(+), 9 deletions(-) - -commit 892433a068a8a11c09a7c4f57c5fc941747c4453 -Author: Albert Astals Cid -Date: Mon Jul 29 19:08:10 2013 +0200 - - Update Ed's copyright - - poppler/TextOutputDev.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 4637b1581286381c3d1c6963828d9cd8afc5b9e0 -Author: Albert Astals Cid -Date: Mon Jul 29 01:08:06 2013 +0200 - - Make some pdftops conversions *much* faster - - For example: http://ev.kde.org/resources/expense_report.pdf - - Without this patch it seems "infinite", which this patch it's a - few seconds - - The change: Instead of just remembering in xobjStack the set of - XObjects (and Patterns, - the variable name was 'wrong') we are currently setting up (i.e. the - current chain), we - remember all of them. - - This has passed the pdf->ps regression test without a single issue - - poppler/PSOutputDev.cc | 42 ++++++++++-------------------------------- - poppler/PSOutputDev.h | 6 +++--- - 2 files changed, 13 insertions(+), 35 deletions(-) - -commit e04287f2682e46831c04e0ef8d60411f521a2572 -Author: Albert Astals Cid -Date: Mon Jul 29 00:55:43 2013 +0200 - - Fallback to 1x1 bitmap If we fail to create the corrent one - - poppler/SplashOutputDev.cc | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -commit fe5ff20cb93a70fa1650ef5e00b67e35de20f0ca -Author: Albert Astals Cid -Date: Mon Jul 29 00:54:07 2013 +0200 - - Initialize t3FillColorOnly - - poppler/PSOutputDev.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 19930d9f104b63070dcd7636758eb8b90a86fc0d -Author: Ed Catmur -Date: Sun Jul 21 11:07:00 2013 +0200 - - TextOutputDev: Do not draw ligatures more than once when selected - - When the selection covers a ligature presentation form where a single - character code corresponds to multiple Unicode codepoints, the - glyph for - the ligature is drawn multiple times, once for each Unicode character. - - https://bugs.freedesktop.org/show_bug.cgi?id=9001 - - poppler/TextOutputDev.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 6b451b2d3f785c28d98907ae338d58380db518d2 -Author: Albert Astals Cid -Date: Fri Jul 19 02:55:29 2013 +0200 - - 0.23.4 - - CMakeLists.txt | 4 +-- - NEWS | 8 ++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - gtk-doc.make | 70 - +++++++++++++++++++++++++++++++----------------- - m4/gtk-doc.m4 | 6 ++++- - poppler/CairoOutputDev.h | 2 +- - poppler/Makefile.am | 2 +- - poppler/TextOutputDev.cc | 2 +- - qt4/src/Doxyfile | 2 +- - qt5/src/Doxyfile | 2 +- - 11 files changed, 67 insertions(+), 35 deletions(-) - -commit 6cf43442e38c501b49293a28f38e06ab143852c6 -Author: Ed Catmur -Date: Thu Jul 18 10:34:29 2013 +0200 - - TextOutputDev: clip the selected text rendering to the selection box - - Sometimes with italic text or text containing ligatures, part of the - glyph falls outside the selection box. By clipping to the selection - box - we avoid drawing the whole glyph with the selection color. - - https://bugs.freedesktop.org/show_bug.cgi?id=66983 - - poppler/TextOutputDev.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 269b3f3d572a15f1007f8cc84f758b1a293ef8af -Author: Carlos Garcia Campos -Date: Mon Jul 8 20:19:30 2013 +0200 - - build: Make -lpthread take preference over -pthread - - This makes libpoppler link to pthreads and fixes runtime error due to - unresolved pthread symbols when running some of the utils and tests. - - m4/ax_pthread.m4 | 2 +- - test/Makefile.am | 6 ++++-- - utils/Makefile.am | 4 +++- - 3 files changed, 8 insertions(+), 4 deletions(-) - -commit 40f857d27930aa002a99c96f3892c5e240e7ecb5 -Author: Carlos Garcia Campos -Date: Mon Jul 8 19:55:10 2013 +0200 - - m4: Replace old acx_pthread.m4 with new one ax_pthread.m4 - - configure.ac | 2 +- - m4/acx_pthread.m4 | 280 ----------------------------------------------- - m4/ax_pthread.m4 | 317 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 318 insertions(+), 281 deletions(-) - -commit 44b7070aa713b2e20eb97b868000d432e2f8504e -Author: Pino Toscano -Date: Mon Jul 8 19:42:15 2013 +0200 - - cmake: improve linking with pthreads - - Use the CMake-provided variable instead of hardcoding -lpthread. - - CMakeLists.txt | 6 +++--- - utils/CMakeLists.txt | 2 +- - 2 files changed, 4 insertions(+), 4 deletions(-) - -commit 69c281fdcf23520151c0eb5471a4259c73fa1273 -Author: Carlos Garcia Campos -Date: Sun Jul 7 11:51:27 2013 +0200 - - cairo: Fix the bounding box of images saved in CairoImageOutputDev - - We were using the size of the original image instead of the rendered - size and asuming the scales were always positive. - - poppler/CairoOutputDev.cc | 145 - ++++++++++++++++++---------------------------- - poppler/CairoOutputDev.h | 5 +- - 2 files changed, 59 insertions(+), 91 deletions(-) - -commit 759e0266b36c4ea9f66912f1e53ed6392dbfd6da -Author: Albert Astals Cid -Date: Tue Jul 2 00:47:13 2013 +0200 - - News for 0.23.3 - - forgot to add them to the tarball, oh well - - NEWS | 18 ++++++++++++++++++ - 1 file changed, 18 insertions(+) - -commit df1fe9dc7ade5228e37c16c6f0c9a2d4890fdc90 -Author: Albert Astals Cid -Date: Tue Jul 2 00:33:04 2013 +0200 - - 0.23.3 - - CMakeLists.txt | 4 ++-- - Makefile.am | 2 +- - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - qt5/src/Doxyfile | 2 +- - 7 files changed, 8 insertions(+), 8 deletions(-) - -commit df9d4fee17adfe003c822175b6921a3cd93675f6 -Author: Albert Astals Cid -Date: Mon Jul 1 21:04:10 2013 +0200 - - Update copyrights - - poppler/Annot.cc | 2 +- - poppler/Annot.h | 2 +- - poppler/Page.cc | 2 +- - poppler/TextOutputDev.cc | 2 +- - poppler/TextOutputDev.h | 2 +- - qt5/src/poppler-annotation.cc | 2 +- - qt5/src/poppler-annotation.h | 2 +- - qt5/src/poppler-document.cc | 2 +- - qt5/src/poppler-link.cc | 2 +- - qt5/src/poppler-qt5.h | 2 +- - 10 files changed, 10 insertions(+), 10 deletions(-) - -commit 67129e9db88e8332907407f14d3e09ee5c49e274 -Author: Jason Crain -Date: Mon Jul 1 02:24:47 2013 -0500 - - Check for NULL in Page::getResourceDictCopy - - poppler/Page.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit c376559bc412e90204162bb4b2d20cd586db70c1 -Author: Carlos Garcia Campos -Date: Sun Jun 30 13:14:07 2013 +0200 - - annots: Invalidate the appearance stream when annot properties change - - Make invalidateAppearance() protected and only call it when properties - that affect the appearance stream are updated. Remove all calls to - invalidateAppearance() from qt frontend, this is now handled by - the core - and fixes the appearance stream regeneration in the glib frontend too. - - poppler/Annot.cc | 36 ++++++++++++++++++++++++++++++++++++ - poppler/Annot.h | 10 ++++++---- - qt4/src/poppler-annotation.cc | 34 ---------------------------------- - qt5/src/poppler-annotation.cc | 34 ---------------------------------- - 4 files changed, 42 insertions(+), 72 deletions(-) - -commit c746e8b38e821d1ebeaf52c4c816515bc3ddaaf6 -Author: Carlos Garcia Campos -Date: Sun Jun 30 11:44:59 2013 +0200 - - annots: Remove unused variable - - poppler/Annot.cc | 1 - - 1 file changed, 1 deletion(-) - -commit 7d9d5d2518f7760e6a4317a358040ddd9164fdef -Author: Carlos Garcia Campos -Date: Sun Jun 30 11:40:15 2013 +0200 - - annots: Do not update AP and AS entries if they are not present when - invaliding the appaearance stream - - poppler/Annot.cc | 17 ++++++++++++++--- - 1 file changed, 14 insertions(+), 3 deletions(-) - -commit 347b53f7fca644564724c230fe6c0dcbffa0d6f9 -Author: Carlos Garcia Campos -Date: Sun Jun 30 11:23:54 2013 +0200 - - annots: do not set the default appearance state when invalidating - appearances - - We are setting the default appareance state to Off and then we are - updating AS dictionary to NULL in the XRef. The appearance state - is only - required when there's more than once appearance stream, but when - invalidating the apperance we remove all streams. - - poppler/Annot.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit b5e9941c145fc99e03a28d92a50840638895908d -Author: Albert Astals Cid -Date: Mon Jul 1 00:32:51 2013 +0200 - - Fix crash on malformed doc - - Where the Colorants dictionary values are not arrays - Document can be found on KDE bug #319925 - - poppler/GfxState.cc | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - -commit 19f8a88bba6022b8172477e6f52dfd36b2fc5e92 -Author: Fabio D'Urso -Date: Thu Mar 7 00:20:15 2013 +0100 - - qt5: Free some temporary memory in - TextAnnotationPrivate::createNativeAnnot - - There's no need to keep this buffer around after it has been flushed - - qt5/src/poppler-annotation.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 8bac4d1e43ce9a4c66fddc8430d7bed2d9aabba1 -Author: Fabio D'Urso -Date: Tue Jun 25 20:09:00 2013 +0200 - - qt5: Some documentation about annotations - - * Removed incorrect hint "Use uniqueName to test for Annotation - equality": uniqueNames are optional and we don't actually guarantee - uniqueness - * Added "How to add annotations" and "FixedRotation flag specifics" - sections in the Annotation class page - * Added links from enum Annotation::SubType items to actual subclasses - * Added documentation for annotation flags that are known to work - * Added "see also" links between annotation flag and boundary - setters/getters - * Added warning on Annotation::setPopup to tell that it's currently - not - implemented - - qt5/src/poppler-annotation.h | 143 - ++++++++++++++++++++++++++++++++++++++++--- - 1 file changed, 135 insertions(+), 8 deletions(-) - -commit 1d5fe3f20189fd3928121e954bcc8fa7278b39fb -Author: Fabio D'Urso -Date: Sat Mar 2 19:06:49 2013 +0100 - - qt5: FixedRotation annotations' coordinate conversion - - FixedRotation(=flagNoRotate) annotations use a different coordinate - system than regular annotations. This patch implements transparent - conversion so that qt5 clients don't notice the difference. - - Important! When dealing with FixedRotation annotations, poppler-qt5 - clients will need to set geometry-related annotation properties in - the following order: - 1) flags (because we need to know if this is a FixedRotation - annotation or not) - 2) boundary (because we need to know what the topleft corner is, - so that we can construct the conversion matrix) - 3) anything else - - This requirement will be documented in the next patch - - qt5/src/poppler-annotation-private.h | 7 ++- - qt5/src/poppler-annotation.cc | 111 - +++++++++++++++++++++++++++-------- - 2 files changed, 92 insertions(+), 26 deletions(-) - -commit ab130c91492765f8be29ed112dd2e2e6f665641b -Author: Fabio D'Urso -Date: Sat Mar 2 00:55:58 2013 +0100 - - core: Remove geometry-related arguments from annotation constructors - - Removed arguments from annotation constructors related to the geometry - of the annotation. This change will make it easier to support creating - annotations with flag NoRotate in the next patch (because no special - cases will be needed: coordinate conversion code will be able - to always - assume that the underlying annotation object already exists). - - Data that used to be taken from these arguments is now replaced - by dummy - values, which can be modified using appropriate setter methods after - the annotation object is created. - - Affected annotation types: - - AnnotLine - - AnnotTextMarkup - - AnnotPolygon - - AnnotInk - - qt5/src/poppler-annotation.cc | 34 ++++++++++++++++++---------------- - 1 file changed, 18 insertions(+), 16 deletions(-) - -commit 35cfb6914e1be4c5eda2f355900b1a0a1fa69d19 -Author: Fabio D'Urso -Date: Fri Feb 15 12:24:18 2013 +0100 - - poppler_qt5viewer: Add combobox to select rotation - - qt5/demos/navigationtoolbar.cpp | 15 +++++++++++++++ - qt5/demos/navigationtoolbar.h | 4 ++++ - qt5/demos/pageview.cpp | 24 +++++++++++++++++++++++- - qt5/demos/pageview.h | 3 +++ - qt5/demos/viewer.cpp | 2 ++ - 5 files changed, 47 insertions(+), 1 deletion(-) - -commit de2a93c0bc6e92a95c687796f59780c998b90ca4 -Author: Fabio D'Urso -Date: Thu Mar 7 00:20:15 2013 +0100 - - qt4: Free some temporary memory in - TextAnnotationPrivate::createNativeAnnot - - There's no need to keep this buffer around after it has been flushed - - qt4/src/poppler-annotation.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 738b0b4fedaa2b2b28ea1c11622dfd880180d1c9 -Author: Fabio D'Urso -Date: Thu Mar 7 20:50:52 2013 +0100 - - qt4: Some documentation about annotations - - * Removed incorrect hint "Use uniqueName to test for Annotation - equality": uniqueNames are optional and we don't actually guarantee - uniqueness - * Added "How to add annotations" and "FixedRotation flag specifics" - sections in the Annotation class page - * Added links from enum Annotation::SubType items to actual subclasses - * Added documentation for annotation flags that are known to work - * Added "see also" links between annotation flag and boundary - setters/getters - * Added warning on Annotation::setPopup to tell that it's currently - not - implemented - - qt4/src/poppler-annotation.h | 143 - ++++++++++++++++++++++++++++++++++++++++--- - 1 file changed, 135 insertions(+), 8 deletions(-) - -commit cf950a2b7e8278e70719c67b441b0d324ffd0399 -Author: Fabio D'Urso -Date: Sat Mar 2 19:06:49 2013 +0100 - - qt4: FixedRotation annotations' coordinate conversion - - FixedRotation(=flagNoRotate) annotations use a different coordinate - system than regular annotations. This patch implements transparent - conversion so that qt4 clients don't notice the difference. - - Important! When dealing with FixedRotation annotations, poppler-qt4 - clients will need to set geometry-related annotation properties in - the following order: - 1) flags (because we need to know if this is a FixedRotation - annotation or not) - 2) boundary (because we need to know what the topleft corner is, - so that we can construct the conversion matrix) - 3) anything else - - This requirement will be documented in the next patch - - poppler/Annot.cc | 8 +++ - poppler/Annot.h | 2 + - qt4/src/poppler-annotation-private.h | 7 ++- - qt4/src/poppler-annotation.cc | 111 - +++++++++++++++++++++++++++-------- - 4 files changed, 102 insertions(+), 26 deletions(-) - -commit 4b13085568df09d8b75099f6a5438f025a028fd5 -Author: Fabio D'Urso -Date: Sat Mar 2 00:55:58 2013 +0100 - - core: Remove geometry-related arguments from annotation constructors - - Removed arguments from annotation constructors related to the geometry - of the annotation. This change will make it easier to support creating - annotations with flag NoRotate in the next patch (because no special - cases will be needed: coordinate conversion code will be able - to always - assume that the underlying annotation object already exists). - - Data that used to be taken from these arguments is now replaced - by dummy - values, which can be modified using appropriate setter methods after - the annotation object is created. - - Affected annotation types: - - AnnotLine - - AnnotTextMarkup - - AnnotPolygon - - AnnotInk - - poppler/Annot.cc | 56 - +++++++++++++------------------------------ - poppler/Annot.h | 9 ++++--- - qt4/src/poppler-annotation.cc | 34 +++++++++++++------------- - 3 files changed, 39 insertions(+), 60 deletions(-) - -commit 5923cfb5f7e3a0703de17e21f4952f92a44f3c14 -Author: Fabio D'Urso -Date: Fri Feb 15 12:24:18 2013 +0100 - - poppler_qt4viewer: Add combobox to select rotation - - qt4/demos/navigationtoolbar.cpp | 15 +++++++++++++++ - qt4/demos/navigationtoolbar.h | 4 ++++ - qt4/demos/pageview.cpp | 24 +++++++++++++++++++++++- - qt4/demos/pageview.h | 3 +++ - qt4/demos/viewer.cpp | 2 ++ - 5 files changed, 47 insertions(+), 1 deletion(-) - -commit 74ea15cc454f31b772e71b3525b71045dbfa5527 -Author: Fabio D'Urso -Date: Tue Jun 25 19:56:20 2013 +0200 - - core: Support for rendering annotations with flagNoRotate - - Gfx::drawAnnot now makes a counter-rotation if flagNoRotate is set - - poppler/Annot.cc | 55 - ++++++++++++++++++++++++++++++++++++------------------- - poppler/Annot.h | 3 ++- - poppler/Gfx.cc | 41 +++++++++++++++++++++++++++++++++++++---- - poppler/Gfx.h | 3 ++- - 4 files changed, 77 insertions(+), 25 deletions(-) - -commit 2639957ba78defd2ab6282679375fb7969bad21f -Author: Fabio D'Urso -Date: Wed Jun 26 23:12:40 2013 +0200 - - Do not crash in page::removeAnnot if there are non-Ref entries - in /Annots - - poppler/Page.cc | 10 ++++++---- - 1 file changed, 6 insertions(+), 4 deletions(-) - -commit ae016aa263c218fbfbd607cc92feac1013348c7e -Author: Albert Astals Cid -Date: Wed Jun 26 11:33:55 2013 +0200 - - Fix qt5 found/not found logic - - CMakeLists.txt | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit e27c1057caf4d878a0dc43c92c9e0b565db8fe40 -Merge: c55b577 ee8cfbc -Author: Albert Astals Cid -Date: Tue Jun 25 19:17:13 2013 +0200 - - Merge remote-tracking branch 'origin/qt5' - -commit c55b577ce69ad4bb69f5261b3e120e92c9fdb3d0 -Author: Carlos Garcia Campos -Date: Tue Jun 25 10:01:38 2013 +0200 - - glib: Use TextPage::getSelectionWords to build text layout and - attributes - - This way we can make sure that the list of words used in - poppler_page_get_text_layout and poppler_page_get_text_attributes - is the - same that the one used in poppler_page_get_text. This fixes the - mismatch - between the number of characters in the text returned by - poppler_page_get_text and the number of characters returned by - poppler_page_get_text_layout in some documents. - - glib/poppler-page.cc | 168 - +++++++++++++++++++++++++++------------------------ - 1 file changed, 90 insertions(+), 78 deletions(-) - -commit fc534f571315c064005515c19d7d70ad3af1563e -Author: Carlos Garcia Campos -Date: Tue Jun 25 10:05:01 2013 +0200 - - TextOutputDev: add a method to TextPage to get the selection as a - list of words - - Returns a list of lines of words. - - poppler/TextOutputDev.cc | 36 ++++++++++++++++++++++++++++++++++++ - poppler/TextOutputDev.h | 4 ++++ - 2 files changed, 40 insertions(+) - -commit a924246b7534e86165f8e9ab6c60d56b73a17b94 -Author: Carlos Garcia Campos -Date: Tue Jun 25 09:57:48 2013 +0200 - - TextOutputDev: simplify the text selection dumper - - Build a list of lines of words and don't try to format the text when - detecting tables, simply add the words and lines in the right order. - - poppler/TextOutputDev.cc | 200 - ++++++++++++++++++++++------------------------- - 1 file changed, 92 insertions(+), 108 deletions(-) - -commit c849094a2daf896d085937adff1f7659a09da062 -Author: Carlos Garcia Campos -Date: Mon Jun 24 18:29:11 2013 +0200 - - TextOutputDev: Move TextSelection class from TextSelectionPainter - to TextSelectionVisitor - - So that it can be used by other TextSelectionVisitor implementations. - Also renamed it as TextWordSelection since it contains a word - selection. - - poppler/TextOutputDev.cc | 35 ++++++++++++++++++----------------- - 1 file changed, 18 insertions(+), 17 deletions(-) - -commit b3ff3f2c3e131556d2b27cbe52f0ddbbb4820c19 -Author: Jason Crain -Date: Thu Jun 20 21:47:13 2013 -0500 - - Draw glyphs after selection background - - When multiple lines of text are selected, TextSelectionPainter will - draw selections over each other, hiding the previous line with the - selection background of the current line. This patch changes - TextSelectionPainter so that glyphs are drawn only after the entire - background is drawn. - - https://bugs.freedesktop.org/show_bug.cgi?id=65989 - - poppler/TextOutputDev.cc | 109 - ++++++++++++++++++++++++++++++----------------- - 1 file changed, 69 insertions(+), 40 deletions(-) - -commit ee8cfbc78fe9de109abbe0727a738870f6027a73 -Author: Albert Astals Cid -Date: Tue Jun 18 23:20:01 2013 +0200 - - Fix indent - - qt5/src/poppler-optcontent.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 9d0a5b6afb25a1273504383e108bdb95ca82f099 -Author: Albert Astals Cid -Date: Tue Jun 18 23:19:30 2013 +0200 - - Bring changes from the qt4 dir - - qt5/src/Doxyfile | 2 +- - qt5/src/poppler-private.h | 2 +- - qt5/tests/CMakeLists.txt | 1 + - qt5/tests/Makefile.am | 13 +- - qt5/tests/stress-threads-qt5.cpp | 304 - +++++++++++++++++++++++++++++++++++++++ - qt5/tests/test-poppler-qt5.cpp | 2 +- - 6 files changed, 320 insertions(+), 4 deletions(-) - -commit 1adb1ab7aee026e227d25716a4b7be22b19b5b84 -Author: Albert Astals Cid -Date: Tue Jun 18 20:50:49 2013 +0200 - - Make it build with autotools - - poppler/ArthurOutputDev.cc | 816 - ------------------------------------------ - poppler/ArthurOutputDev.h | 170 --------- - poppler/Makefile.am | 23 +- - qt4/src/ArthurOutputDev.cc | 816 - ++++++++++++++++++++++++++++++++++++++++++ - qt4/src/ArthurOutputDev.h | 170 +++++++++ - qt4/src/CMakeLists.txt | 2 +- - qt4/src/Makefile.am | 5 +- - qt5/src/ArthurOutputDev.cc | 816 - ++++++++++++++++++++++++++++++++++++++++++ - qt5/src/ArthurOutputDev.h | 170 +++++++++ - qt5/src/CMakeLists.txt | 2 +- - qt5/src/Makefile.am | 5 +- - qt5/src/poppler-optcontent.cc | 2 + - 12 files changed, 1983 insertions(+), 1014 deletions(-) - -commit 93a1c2b768cc419c5bf9b3033bf85fb21326a65a -Author: Albert Astals Cid -Date: Tue Jun 18 00:33:38 2013 +0200 - - If qmake gives us a Qt5 qmake try with qmake4 and qmake-qt4 - - cmake/modules/FindQt4.cmake | 62 - ++++++++++++++++++++++++++++----------------- - 1 file changed, 39 insertions(+), 23 deletions(-) - -commit 7cc33a752ef864b595748ce7724ba553a8e3ba8e -Author: Albert Astals Cid -Date: Mon Jun 17 22:57:56 2013 +0200 - - We are not compiling an executable - - qt5/src/CMakeLists.txt | 1 - - 1 file changed, 1 deletion(-) - -commit 87cfcd41e8e970186c6ce753aa660ef86aca8878 -Author: Granger Anthony -Date: Mon Jun 17 09:17:51 2013 +0200 - - Allow to enable Qt5 support only with CMake >= 2.8.8 - - CMakeLists.txt | 26 ++++++++++++++++---------- - qt5/tests/CMakeLists.txt | 1 - - 2 files changed, 16 insertions(+), 11 deletions(-) - -commit b44c70f04758000cf0e049b06cc7864287570f7b -Author: Albert Astals Cid -Date: Mon Jun 17 22:10:05 2013 +0200 - - Bring PIC back to the toplevel, still have linking errors tohugh :-/ - - configure.ac | 1 + - 1 file changed, 1 insertion(+) - -commit be49073f5ce79f56b38197758a5cf1253b972306 -Author: Albert Astals Cid -Date: Mon Jun 17 21:50:31 2013 +0200 - - Use qtchooser if available - - configure.ac | 15 ++++++++++++--- - 1 file changed, 12 insertions(+), 3 deletions(-) - -commit b1958228d4bc6793a3606b5e31c61a57b9fac9f5 -Author: Albert Astals Cid -Date: Mon Jun 17 20:21:08 2013 +0200 - - No distro ships moc-qt5 but make it work in case someone would - - configure.ac | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit 06f45c7177afc67e02985be1a97cd976c530c4ae -Author: Albert Astals Cid -Date: Mon Jun 17 20:04:49 2013 +0200 - - Build fixes - - Fix moc when moc-qt4 is qt4 moc but moc is qt5 one - Do not add -fPIE everywhere, just -fPIC to qt5 - - configure.ac | 10 ++++++---- - qt5/src/Makefile.am | 2 +- - 2 files changed, 7 insertions(+), 5 deletions(-) - -commit cb617c21fba727781f46278f5475b91d528a488b -Author: Albert Astals Cid -Date: Mon Jun 17 18:12:18 2013 +0200 - - Files i forgot - - poppler-qt5-uninstalled.pc.in | 7 +++++++ - poppler-qt5.pc.cmake | 13 +++++++++++++ - poppler-qt5.pc.in | 13 +++++++++++++ - 3 files changed, 33 insertions(+) - -commit 5c521bba427eb163e4b77d936865fbdd0e07faf3 -Author: Albert Astals Cid -Date: Mon Jun 17 18:12:07 2013 +0200 - - soversion 1 - - qt5/src/CMakeLists.txt | 2 +- - qt5/src/Makefile.am | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 43786964946b4f4c005a0526e16fead3ffa6ba4a -Author: Albert Astals Cid -Date: Mon Jun 17 00:23:31 2013 +0200 - - harmonize spaces - - CMakeLists.txt | 7 +++---- - 1 file changed, 3 insertions(+), 4 deletions(-) - -commit 2e2ea27fe3dc688c87003d170b82451a6a872b0d -Author: Albert Astals Cid -Date: Mon Jun 17 00:22:18 2013 +0200 - - Remove qt4 mentions - - qt5/src/poppler-converter-private.h | 6 +++--- - qt5/src/poppler-embeddedfile-private.h | 2 +- - qt5/src/poppler-form.cc | 2 +- - qt5/src/poppler-form.h | 6 +++--- - qt5/src/poppler-pdf-converter.cc | 2 +- - qt5/src/poppler-private.cc | 4 ++-- - qt5/src/poppler-private.h | 2 +- - qt5/src/poppler-qt5.h | 2 +- - 8 files changed, 13 insertions(+), 13 deletions(-) - -commit e2264ce82af3e971e34930f5307b7c9b43a1e346 -Author: Albert Astals Cid -Date: Mon Jun 17 00:19:27 2013 +0200 - - remove deprecated stuff - - qt5/src/poppler-annotation.cc | 19 ++------ - qt5/src/poppler-annotation.h | 18 ------- - qt5/src/poppler-document.cc | 19 -------- - qt5/src/poppler-link.cc | 5 -- - qt5/src/poppler-link.h | 10 ---- - qt5/src/poppler-page.cc | 18 ------- - qt5/src/poppler-qt5.h | 41 ---------------- - qt5/tests/check_fonts.cpp | 21 ++------- - qt5/tests/check_metadata.cpp | 1 - - qt5/tests/check_search.cpp | 107 - ++++++++++++++++++++++-------------------- - 10 files changed, 65 insertions(+), 194 deletions(-) - -commit 21808e203eed46e379954b58b7014998b3836573 -Author: Albert Astals Cid -Date: Mon Jun 17 00:03:45 2013 +0200 - - remove commented stuff - - qt5/src/CMakeLists.txt | 1 - - 1 file changed, 1 deletion(-) - -commit 16e7033f18a8da8e27aaed6f63cce156abf8837a -Author: Albert Astals Cid -Date: Mon Jun 17 00:01:27 2013 +0200 - - Initial Qt5 port - - CMakeLists.txt | 20 + - Makefile.am | 18 +- - configure.ac | 66 +- - qt5/.gitignore | 4 + - qt5/CMakeLists.txt | 3 + - qt5/Makefile.am | 1 + - qt5/demos/.gitignore | 4 + - qt5/demos/CMakeLists.txt | 38 + - qt5/demos/Makefile.am | 67 + - qt5/demos/abstractinfodock.cpp | 57 + - qt5/demos/abstractinfodock.h | 48 + - qt5/demos/documentobserver.cpp | 50 + - qt5/demos/documentobserver.h | 50 + - qt5/demos/embeddedfiles.cpp | 82 + - qt5/demos/embeddedfiles.h | 44 + - qt5/demos/fonts.cpp | 72 + - qt5/demos/fonts.h | 43 + - qt5/demos/info.cpp | 72 + - qt5/demos/info.h | 43 + - qt5/demos/main_viewer.cpp | 33 + - qt5/demos/metadata.cpp | 50 + - qt5/demos/metadata.h | 43 + - qt5/demos/navigationtoolbar.cpp | 129 + - qt5/demos/navigationtoolbar.h | 61 + - qt5/demos/optcontent.cpp | 69 + - qt5/demos/optcontent.h | 47 + - qt5/demos/pageview.cpp | 79 + - qt5/demos/pageview.h | 50 + - qt5/demos/permissions.cpp | 66 + - qt5/demos/permissions.h | 43 + - qt5/demos/thumbnails.cpp | 84 + - qt5/demos/thumbnails.h | 48 + - qt5/demos/toc.cpp | 88 + - qt5/demos/toc.h | 43 + - qt5/demos/viewer.cpp | 317 ++ - qt5/demos/viewer.h | 73 + - qt5/src/.gitignore | 9 + - qt5/src/CMakeLists.txt | 54 + - qt5/src/Doxyfile | 1637 ++++++++++ - qt5/src/Mainpage.dox | 85 + - qt5/src/Makefile.am | 73 + - qt5/src/poppler-annotation-helper.h | 198 ++ - qt5/src/poppler-annotation-private.h | 111 + - qt5/src/poppler-annotation.cc | 4394 - ++++++++++++++++++++++++++ - qt5/src/poppler-annotation.h | 921 ++++++ - qt5/src/poppler-base-converter.cc | 105 + - qt5/src/poppler-converter-private.h | 49 + - qt5/src/poppler-document.cc | 679 ++++ - qt5/src/poppler-embeddedfile-private.h | 42 + - qt5/src/poppler-embeddedfile.cc | 135 + - qt5/src/poppler-export.h | 17 + - qt5/src/poppler-fontinfo.cc | 149 + - qt5/src/poppler-form.cc | 416 +++ - qt5/src/poppler-form.h | 343 ++ - qt5/src/poppler-link-extractor-private.h | 57 + - qt5/src/poppler-link-extractor.cc | 84 + - qt5/src/poppler-link.cc | 711 +++++ - qt5/src/poppler-link.h | 612 ++++ - qt5/src/poppler-media.cc | 168 + - qt5/src/poppler-media.h | 100 + - qt5/src/poppler-movie.cc | 110 + - qt5/src/poppler-optcontent-private.h | 121 + - qt5/src/poppler-optcontent.cc | 427 +++ - qt5/src/poppler-optcontent.h | 77 + - qt5/src/poppler-page-private.h | 54 + - qt5/src/poppler-page-transition-private.h | 28 + - qt5/src/poppler-page-transition.cc | 95 + - qt5/src/poppler-page-transition.h | 148 + - qt5/src/poppler-page.cc | 744 +++++ - qt5/src/poppler-pdf-converter.cc | 115 + - qt5/src/poppler-private.cc | 292 ++ - qt5/src/poppler-private.h | 240 ++ - qt5/src/poppler-ps-converter.cc | 273 ++ - qt5/src/poppler-qiodeviceoutstream-private.h | 47 + - qt5/src/poppler-qiodeviceoutstream.cc | 64 + - qt5/src/poppler-qt5.h | 1812 +++++++++++ - qt5/src/poppler-sound.cc | 132 + - qt5/src/poppler-textbox.cc | 63 + - qt5/tests/.gitignore | 30 + - qt5/tests/CMakeLists.txt | 75 + - qt5/tests/Makefile.am | 152 + - qt5/tests/README.unittest | 23 + - qt5/tests/check_actualtext.cpp | 33 + - qt5/tests/check_attachments.cpp | 157 + - qt5/tests/check_dateConversion.cpp | 142 + - qt5/tests/check_fonts.cpp | 248 ++ - qt5/tests/check_goostring.cpp | 61 + - qt5/tests/check_lexer.cpp | 128 + - qt5/tests/check_links.cpp | 96 + - qt5/tests/check_metadata.cpp | 275 ++ - qt5/tests/check_optcontent.cpp | 484 +++ - qt5/tests/check_pagelabelinfo.cpp | 43 + - qt5/tests/check_pagelayout.cpp | 49 + - qt5/tests/check_pagemode.cpp | 73 + - qt5/tests/check_password.cpp | 88 + - qt5/tests/check_permissions.cpp | 44 + - qt5/tests/check_search.cpp | 91 + - qt5/tests/check_strings.cpp | 250 ++ - qt5/tests/poppler-attachments.cpp | 39 + - qt5/tests/poppler-fonts.cpp | 89 + - qt5/tests/poppler-forms.cpp | 166 + - qt5/tests/poppler-texts.cpp | 40 + - qt5/tests/stress-poppler-dir.cpp | 67 + - qt5/tests/stress-poppler-qt5.cpp | 74 + - qt5/tests/test-password-qt5.cpp | 136 + - qt5/tests/test-poppler-qt5.cpp | 235 ++ - 106 files changed, 21480 insertions(+), 4 deletions(-) - -commit 714ee1e61d853394818dca7155b1b882408ffc6a -Author: Albert Astals Cid -Date: Sun Jun 16 19:00:01 2013 +0200 - - Pass down the recursion param - - Fixes heap smashing in 168.pdf.SIGSEGV.598.462 - - poppler/Stream.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 1f3e3828b9a57e044b86640b9bf9ad2437cc5656 -Author: Albert Astals Cid -Date: Sat Jun 15 17:21:36 2013 +0200 - - Add quotes since use_cairo can have spaces - - BUG #65709 - - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit fe3ffab19d54326052fd0ff8ee3ee1feb9fa928c -Author: Adam Reichold -Date: Tue Jun 11 23:08:07 2013 +0200 - - Windows compile fixes - - qt4/tests/stress-threads-qt4.cpp | 13 +++++++++---- - 1 file changed, 9 insertions(+), 4 deletions(-) - -commit 99908cb0c8a784791ffa0682c8f105acdef0d5ab -Author: Peter Breitenlohner -Date: Tue Jun 11 10:02:01 2013 +0200 - - MinGW32 may or may not define __MINGW_PRINTF_FORMAT - - Moreover __USE_MINGW_ANSI_STDIO might be defined as 0 - - poppler/poppler-config.h.cmake | 2 +- - poppler/poppler-config.h.in | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 0673f3d8024554c414f578e0770086f475e6a605 -Author: Albert Astals Cid -Date: Tue Jun 11 00:19:19 2013 +0200 - - 0.23.2 - - CMakeLists.txt | 4 ++-- - NEWS | 12 ++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 6 files changed, 18 insertions(+), 6 deletions(-) - -commit 7f1bf8d94302c15a2ff68debfb6fba49df526d16 -Author: Christoph Duelli -Date: Thu May 16 16:16:32 2013 +0200 - - Do not pollute global namespace with internal classes - - Bug #64680 - - fofi/FoFiIdentifier.cc | 18 ++++++++++++++++++ - 1 file changed, 18 insertions(+) - -commit 07992075a6d1d29db57f997f67d5a4a6deacbbb4 -Merge: 4a0bd6f 25f453e -Author: Albert Astals Cid -Date: Sun Jun 9 12:17:53 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.22' - - Conflicts: - poppler/Catalog.cc - qt4/src/poppler-private.h - utils/HtmlOutputDev.cc - -commit 25f453ef49004452ac4c201d59d9ce2ef52ffeee -Author: Julien Nabet -Date: Sun Jun 9 12:12:06 2013 +0200 - - Prefer prefix ++/-- operators for non-primitive types - - Part of bug #80537 - - poppler/CachedFile.cc | 3 ++- - poppler/Catalog.cc | 5 +++-- - utils/HtmlFonts.cc | 3 ++- - utils/HtmlLinks.cc | 3 ++- - 4 files changed, 9 insertions(+), 5 deletions(-) - -commit ed01688a899c5e7560a93ca2424ca302ff3452f1 -Author: Julien Nabet -Date: Sun Jun 9 12:10:01 2013 +0200 - - Fix mismatched allocation and deallocation - - Part of bug #65551 - - qt4/src/poppler-private.h | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit a27890ac441fbd613ddfe6fcf404b92be371e554 -Author: Julien Nabet -Date: Sun Jun 9 12:08:06 2013 +0200 - - Fix memory leak - - utils/HtmlOutputDev.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 4a0bd6fdb2e9e3c589e1bdb282e7c2bfca8567b1 -Merge: bbd27c9 17a16a2 -Author: Albert Astals Cid -Date: Sun Jun 9 12:06:10 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit 17a16a2731b1110a12c7163c139d85bccee04492 -Author: Albert Astals Cid -Date: Sun Jun 9 12:04:40 2013 +0200 - - Fix mismatched free/delete - - Bug #65553 - - poppler/UTF.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit bbd27c92b5e5034dc2899ea26b47fcb983209f82 -Author: Thomas Freitag -Date: Thu Jun 6 23:52:36 2013 +0200 - - Speed-up some tiling on a 10x factor - - Bug #64892 - - poppler/SplashOutputDev.cc | 15 ++++++++++++++- - splash/Splash.cc | 15 +++++++++++---- - splash/Splash.h | 3 ++- - 3 files changed, 27 insertions(+), 6 deletions(-) - -commit 7847769a24bd3ccf863f653bc2215e84157ccfb6 -Author: Peter Breitenlohner -Date: Tue Jun 4 15:31:06 2013 +0200 - - Use fseeko64/ftello64 for MinGW32 - - goo/gfile.cc | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -commit 0c3548087b379dd6ffa2291d03f0ea1c7e6a69d1 -Author: Peter Breitenlohner -Date: Tue Jun 4 15:31:05 2013 +0200 - - Allow to build without multithreading - - poppler/Annot.cc | 7 +++++++ - poppler/XRef.cc | 4 ++++ - 2 files changed, 11 insertions(+) - -commit 1e74ac4589daf80dcac54b094145d32c90069738 -Author: Adam Reichold -Date: Thu Jun 6 01:03:48 2013 +0200 - - [qt4] fix autotools - - qt4/tests/Makefile.am | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 342cc0d8a101e99199d447d632a1cd5ba7beb5b2 -Author: Li Junling -Date: Tue Jun 4 22:39:35 2013 +0200 - - Fix memory leak - - poppler/SplashOutputDev.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 52945a072b6f864e80485cc4321a27530a76c452 -Author: Albert Astals Cid -Date: Tue Jun 4 22:35:32 2013 +0200 - - Move the iccColorSpaceCache from Gfx to OutputDev - - This way it's shared when doing tiling. Page 35 of - bug-poppler64963.pdf - goes down from 150 to 133 seconds - - poppler/Gfx.cc | 61 ++++++++++++++-------------------- - poppler/Gfx.h | 12 ++----- - poppler/GfxState.cc | 93 - ++++++++++++++++++++++++++-------------------------- - poppler/GfxState.h | 33 ++++++++++--------- - poppler/OutputDev.cc | 8 ++++- - poppler/OutputDev.h | 19 +++++++++-- - 6 files changed, 114 insertions(+), 112 deletions(-) - -commit 7d4bda198b8ac767bdf4e0a4fdcaae5541113f92 -Author: Albert Astals Cid -Date: Mon Jun 3 23:34:11 2013 +0200 - - Compile - - qt4/tests/stress-threads-qt4.cpp | 1 + - 1 file changed, 1 insertion(+) - -commit 395b3fa021850225e1fea66736f3a3f00571571f -Author: Albert Astals Cid -Date: Mon Jun 3 23:31:52 2013 +0200 - - Fix #end -> #endif - - poppler/poppler-config.h.cmake | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 425d1b4835389e2031631ce54cee157af39f1cb6 -Author: Adam Reichold -Date: Mon Jun 3 20:04:21 2013 +0200 - - Check for the correct number of arguments - - qt4/tests/stress-threads-qt4.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 9d3eb07a1ea01b98aabe4f32481dd4a83bc8f2a5 -Author: Hib Eris -Date: Mon Jun 3 08:49:37 2013 +0200 - - Fix cmake build to use ansi stdio extensions when using a mingw - compiler - - https://bugs.freedesktop.org/show_bug.cgi?id=65238 - - poppler/poppler-config.h.cmake | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 287afe2290d64ca63cdb75fef8f3fbdc20997970 -Author: Adam Reichold -Date: Sun Jun 2 23:29:00 2013 +0200 - - Add a thread stresser in qt4 - - qt4/tests/CMakeLists.txt | 1 + - qt4/tests/Makefile.am | 9 +- - qt4/tests/stress-threads-qt4.cpp | 298 - +++++++++++++++++++++++++++++++++++++++ - 3 files changed, 307 insertions(+), 1 deletion(-) - -commit 77ecb3823c2db4a6cca5af5889c07c73f90de7f0 -Author: Adam Reichold -Date: Sat Jun 1 19:04:10 2013 +0200 - - Add a pthread option to pdftoppm - - It's mostly a developer tool only to test thread support - Not end user oriented (hence no buildsystem) - - Parts also by Thomas - - utils/pdftoppm.cc | 130 - ++++++++++++++++++++++++++++++++++++++++++++++++++++-- - 1 file changed, 126 insertions(+), 4 deletions(-) - -commit caa19f4961146915f51be6c72f60c3aa43037235 -Author: Albert Astals Cid -Date: Sat Jun 1 17:22:54 2013 +0200 - - qt4: Fix test binary name in help - - qt4/tests/test-poppler-qt4.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit a0b48b1d05f08605bca5e1a2e2518e16578f6055 -Author: Hib Eris -Date: Sat Jun 1 14:42:42 2013 +0200 - - Fix printf format warning for size_t - - Fixes: - - CXX pdfunite.o - pdfunite.cc: In function ‘int main(int, char**)’: - pdfunite.cc:142:59: warning: format ‘%d’ expects argument of type - ‘int’, but argument 3 has type ‘std::vector::size_type - {aka long unsigned int}’ [-Wformat] - - https://bugs.freedesktop.org/show_bug.cgi?id=65242 - - utils/pdfunite.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 860737c2a19c734a0c5b65ad506ba229ba439985 -Author: Hib Eris -Date: Sat Jun 1 12:05:17 2013 +0200 - - Use ansi stdio extensions when using a mingw compiler - - In the C runtime used by mingw compilers (msvcrt.dll) the printf - function does not support the C99 format-width specifier "%ll". - - Defining __USE_MINGW_ANSI_STDIO enables mingw's ansi stdio extensions - that implement a C99 compliant printf function. - - https://bugs.freedesktop.org/show_bug.cgi?id=65238 - - CMakeLists.txt | 4 ++++ - configure.ac | 3 +++ - poppler/poppler-config.h.in | 5 +++++ - 3 files changed, 12 insertions(+) - -commit dd30ce39252a3820254b43f90699849ab5a1ca58 -Author: Hib Eris -Date: Fri May 31 12:24:55 2013 +0200 - - Fix warning on narrowing conversion from int to DWORD - - Fixes warning when compiling for Windows: - - gfile.cc: In member function 'Goffset GooFile::size() const': - gfile.cc:609:30: warning: narrowing conversion of '-1' from 'int' - to 'DWORD {aka long unsigned int}' inside { } is ill-formed in C++11 - [-Wnarrowing] - LARGE_INTEGER size = {-1,-1}; - - https://bugs.freedesktop.org/show_bug.cgi?id=65239 - - goo/gfile.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 01a825f3f9f5dcf686fc123d2cf80b9c525d0d89 -Merge: a57f937 b4b1310 -Author: Albert Astals Cid -Date: Sat Jun 1 13:47:29 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit b4b13102716cd33636a94fd99c49487924761670 -Author: Albert Astals Cid -Date: Sat Jun 1 13:45:53 2013 +0200 - - Fix crash on malformed file - - Also remove outdated comment - - Bug #65221 - - poppler/Stream.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit a57f93780de12732875e0195127a92bff835ff61 -Author: Albert Astals Cid -Date: Tue May 28 00:11:10 2013 +0200 - - 0.23.1 - - CMakeLists.txt | 4 ++-- - NEWS | 11 +++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 6 files changed, 17 insertions(+), 6 deletions(-) - -commit 299a1447e3d9a845b5e964f29e698046abdb63f2 -Author: Albert Astals Cid -Date: Tue May 28 00:10:43 2013 +0200 - - Build poppler-forms in the autotools buildsystem - - qt4/tests/Makefile.am | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -commit dcfaf20503868d0956ee81208265a975b480fb52 -Author: Albert Astals Cid -Date: Mon May 27 23:40:49 2013 +0200 - - Dist these two files too - - Makefile.am | 2 ++ - 1 file changed, 2 insertions(+) - -commit de7a3fb715811be6be9ed51b1c5ab1a63c523403 -Author: Albert Astals Cid -Date: Mon May 27 23:40:07 2013 +0200 - - Add missing copyright - - poppler/Hints.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 30282d3fdbbb3029d9a0f838b2cd979bb962235c -Merge: 61f6658 56044ef -Author: Albert Astals Cid -Date: Mon May 27 00:20:12 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit 56044ef482c26f10a8a1371dace049c144659dc7 -Author: Albert Astals Cid -Date: Mon May 27 00:18:22 2013 +0200 - - Fix infinite loop while feeding wrong data in stdin - - Take into account that CachedFile::read might not always return - the number of elems we asked it to read - - Bug #64967 - - poppler/Stream.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 61f665885daeb0009ecac2cc85188f23d6addb60 -Author: Albert Astals Cid -Date: Mon May 27 00:01:24 2013 +0200 - - Fix big file support in cmake - - Tested by Fabio - - CMakeLists.txt | 2 ++ - cmake/modules/CheckFileOffsetBits.c | 14 +++++++++++ - cmake/modules/CheckFileOffsetBits.cmake | 44 - +++++++++++++++++++++++++++++++++ - config.h.cmake | 6 ++--- - 4 files changed, 63 insertions(+), 3 deletions(-) - -commit f536a4ec37246e10f03fe4de309bd31deb6a4727 -Author: Hib Eris -Date: Thu May 16 21:06:56 2013 +0200 - - Do not use deprecated gtk_scrolled_window_add_with_viewport() - - https://bugs.freedesktop.org/show_bug.cgi?id=64683 - - glib/demo/find.c | 4 ++++ - glib/demo/images.c | 4 ++++ - glib/demo/layers.c | 4 ++++ - glib/demo/render.c | 4 ++++ - glib/demo/selections.c | 4 ++++ - test/gtk-test.cc | 4 ++++ - 6 files changed, 24 insertions(+) - -commit c10f2f8777927d8cfe547941ea2f70fcce14da7a -Author: Pino Toscano -Date: Mon May 20 00:09:45 2013 +0200 - - fix typo in error message - - poppler/Hints.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 71d327194293cb3d1a0e274eaf4451c7afe81e8a -Merge: 7b2df1f 6a98b56 -Author: Albert Astals Cid -Date: Fri May 17 23:04:12 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit 6a98b56f6ded957477ddcccd4ff849a870020395 -Author: Albert Astals Cid -Date: Fri May 17 23:01:20 2013 +0200 - - Make an invalid nSharedGroupsFirst a real error - - Instead trying to recover - Fixes bug #46703 - - poppler/Hints.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 7b2df1f935192c89eacddd98c4bf92f38013c8e0 -Author: Albert Astals Cid -Date: Fri May 17 20:56:51 2013 +0200 - - A simple form dumper - - qt4/tests/CMakeLists.txt | 1 + - qt4/tests/poppler-forms.cpp | 166 - ++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 167 insertions(+) - -commit 54f539b4436a1a3e0eab2ef0904c302865082982 -Merge: b3d8f51 3a6e2de -Author: Albert Astals Cid -Date: Thu May 16 21:27:47 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit 3a6e2de1d35e3ee4fd86f71713c49bec8e09e41d -Author: Albert Astals Cid -Date: Thu May 16 21:27:02 2013 +0200 - - Make sure that Title: doesn't contain \n or \n - - Bug #63862 - - poppler/PSOutputDev.cc | 11 +++++++++-- - 1 file changed, 9 insertions(+), 2 deletions(-) - -commit b3d8f510e30fb4d8da9069390d5e9bd8a283fbd6 -Author: Thomas Freitag -Date: Thu May 16 20:52:09 2013 +0200 - - Fix splashModeBGR8 rendering - - Also make SplashBitmap able to write splashModeBGR8 images - - Bug #64381 - - splash/Splash.cc | 4 ++-- - splash/SplashBitmap.cc | 24 ++++++++++++++++++++++-- - 2 files changed, 24 insertions(+), 4 deletions(-) - -commit 8640933a3aa7dbafa21765d029e97b4bba76716c -Author: Fabio D'Urso -Date: Thu Apr 25 19:18:30 2013 +0200 - - Fix printf format specifiers (Goffset is a long long, not a int) - - poppler/PDFDoc.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit f8e8805bbce3e94b16b77fece0072645c66f6a31 -Author: Fabio D'Urso -Date: Thu Apr 25 19:06:09 2013 +0200 - - Re-enable commented-out printf-format attribute on OutStream::printf - - The answer to the question "2,3 because the first arg is class - instance ?" is yes. It's documented behavior: - Since non-static C++ methods have an implicit this argument, the - arguments of such methods should be counted from two, not one. - from - http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Function-Attributes.html - - poppler/Stream.h | 6 ++---- - 1 file changed, 2 insertions(+), 4 deletions(-) - -commit 013b2b247268f9b8dcd8e0461580e0bbcf7554c1 -Author: Fabio D'Urso -Date: Thu Apr 25 17:58:25 2013 +0200 - - XRef stream writing: Write 32-bit offsets when possible - - For compatibility reasons: some pdf readers don't support 64-bit - offsets - yet (for example, poppler 0.22 doesn't) - - poppler/XRef.cc | 38 ++++++++++++++++++++++++++++---------- - poppler/XRef.h | 17 +++++++++++++++-- - 2 files changed, 43 insertions(+), 12 deletions(-) - -commit ea61a9dc012fbffd9bc9fe8a09264ba8744635fc -Author: Albert Astals Cid -Date: Mon May 13 23:15:55 2013 +0200 - - 0.23.0 - - Includes news, soversions, updated copyrights, etc - - CMakeLists.txt | 6 +++--- - NEWS | 12 ++++++++++++ - configure.ac | 4 ++-- - cpp/Doxyfile | 2 +- - goo/gfile.cc | 1 + - goo/gfile.h | 1 + - poppler/CairoOutputDev.h | 2 +- - poppler/Makefile.am | 2 +- - poppler/Stream.cc | 1 + - poppler/Stream.h | 1 + - poppler/XRef.cc | 1 + - qt4/src/CMakeLists.txt | 2 +- - qt4/src/Doxyfile | 2 +- - qt4/src/Makefile.am | 2 +- - 14 files changed, 28 insertions(+), 11 deletions(-) - -commit 7a5eee1cbebe241b8bd44027fc07682944686910 -Author: Albert Astals Cid -Date: Mon May 13 23:00:40 2013 +0200 - - Add check_pagelabelinfo test - - qt4/tests/Makefile.am | 1 + - 1 file changed, 1 insertion(+) - -commit 30a519f21dd5df8d41a43a58b2cbd95fe657df73 -Merge: 998a9e7 0c0aef2 -Author: Albert Astals Cid -Date: Mon May 13 20:40:04 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit 0c0aef20d9cecaee1de0badc6cd56dd6e5b5bf12 -Author: Albert Astals Cid -Date: Mon May 13 19:57:02 2013 +0200 - - 0.22.4 version - - Also increase soversion since Gfx.h got a new member - - CMakeLists.txt | 4 ++-- - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 5 files changed, 6 insertions(+), 6 deletions(-) - -commit 4d6662d05f6b652af97ac6e0eb1f1c1dca8e9550 -Author: Albert Astals Cid -Date: Mon May 13 19:55:21 2013 +0200 - - 0.22.4 NEWS - - NEWS | 15 +++++++++++++++ - 1 file changed, 15 insertions(+) - -commit 93e08d96867d636a70ab04ee4ad22c2214ae4b6a -Author: Albert Astals Cid -Date: Mon May 13 19:51:52 2013 +0200 - - Update copyright years - - poppler/CairoOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 998a9e7c982a72b0e931304b719de40f30094d12 -Merge: 5e73cb0 73d09cd -Author: Albert Astals Cid -Date: Mon May 13 19:30:26 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.22' - - Conflicts: - splash/Splash.cc - -commit 73d09cd55f3bd307450c2dd095e039ea39c69cea -Author: Albert Astals Cid -Date: Mon May 13 19:28:40 2013 +0200 - - Fix compilation with fixed point mode enabled - - Thanks to Andreas Müller for the tip - - splash/Splash.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 5e73cb059e27f68b329513de609d52e84d73f8af -Merge: 5e9654a b3e44fc -Author: Albert Astals Cid -Date: Tue May 7 22:00:02 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit b3e44fc59a9258ad701bc67132dea0646fd8b61a -Author: Albert Astals Cid -Date: Tue May 7 21:53:31 2013 +0200 - - We need UnicodeParsedString here too - - Fixes KDE bug #307786 - - qt4/src/poppler-embeddedfile.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 5e9654a3eb28b2c8b0985545778dd0e45829f8e1 -Merge: eeecd97 a107428 -Author: Albert Astals Cid -Date: Thu Apr 25 20:45:34 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.22' - - Conflicts: - poppler/Gfx.h - -commit a107428e7db0c420b60418a33b9f815909ac9a33 -Author: Albert Astals Cid -Date: Thu Apr 25 20:44:36 2013 +0200 - - Update my C of the last two previous commits - - poppler/Gfx.cc | 2 +- - poppler/Gfx.h | 2 +- - utils/HtmlOutputDev.cc | 2 +- - 3 files changed, 3 insertions(+), 3 deletions(-) - -commit eeecd9718f201dc795b2cb8469c43860aec6e07d -Author: Albert Astals Cid -Date: Thu Apr 25 20:29:24 2013 +0200 - - Do not start drawing a form we are already drawing - - Bug #63190 - - poppler/Gfx.cc | 23 +++++++++++++++++++---- - poppler/Gfx.h | 2 ++ - 2 files changed, 21 insertions(+), 4 deletions(-) - -commit 43d66e11aa9e692c1c6b3a237e7e972d317e5c4d -Author: Albert Astals Cid -Date: Thu Apr 25 20:27:43 2013 +0200 - - Make sure getKids returns != 0 before using it - - Fixes crash in bug #63909 - - utils/HtmlOutputDev.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit ec298b3b780f885464aa00880150eaa2b9b50b08 -Author: Albert Astals Cid -Date: Thu Apr 25 20:29:24 2013 +0200 - - Do not start drawing a form we are already drawing - - Bug #63190 - - poppler/Gfx.cc | 23 +++++++++++++++++++---- - poppler/Gfx.h | 2 ++ - 2 files changed, 21 insertions(+), 4 deletions(-) - -commit 11ab42e7e90099d0cebf8f02197413fd5dee044b -Author: Albert Astals Cid -Date: Thu Apr 25 20:27:43 2013 +0200 - - Make sure getKids returns != 0 before using it - - Fixes crash in bug #63909 - - utils/HtmlOutputDev.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 4ee78e77f7d6cadc8e150ceff96b546ddca329d4 -Author: Carlos Garcia Campos -Date: Sat Apr 20 16:41:56 2013 +0200 - - cairo: Always use the trasnfer function if present in setSoftMask - - "If the subtype is Alpha, the transparency group XObject G shall be - evaluated to compute a group alpha only. The colours of the - constituent - objects shall be ignored and the colour compositing computations shall - not be performed. The transfer function TR shall then be applied - to the - computed group alpha to produce the mask values." - - We were using the transfer function only for luminosity soft masks. - - https://bugs.freedesktop.org/show_bug.cgi?id=63587 - - poppler/CairoOutputDev.cc | 37 +++++++++++++++++++------------------ - 1 file changed, 19 insertions(+), 18 deletions(-) - -commit 3c2a92b06a6541071bd1e555606bb2096de17ef6 -Author: Carlos Garcia Campos -Date: Sat Apr 20 16:41:56 2013 +0200 - - cairo: Always use the trasnfer function if present in setSoftMask - - "If the subtype is Alpha, the transparency group XObject G shall be - evaluated to compute a group alpha only. The colours of the - constituent - objects shall be ignored and the colour compositing computations shall - not be performed. The transfer function TR shall then be applied - to the - computed group alpha to produce the mask values." - - We were using the transfer function only for luminosity soft masks. - - https://bugs.freedesktop.org/show_bug.cgi?id=63587 - - poppler/CairoOutputDev.cc | 37 +++++++++++++++++++------------------ - 1 file changed, 19 insertions(+), 18 deletions(-) - -commit fd648e83e60db7157b7273ffddc02308b0c5813b -Merge: 970e9f6 53b9cec -Author: Albert Astals Cid -Date: Sun Apr 21 23:30:16 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit 53b9cec6c1334020f90b885cff6fc30293437e5f -Author: Thomas Freitag -Date: Sun Apr 21 23:28:40 2013 +0200 - - Splash: Always consider a softmask transfer function - - Fixes bug 63587 in splash - - poppler/SplashOutputDev.cc | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -commit 970e9f6304c3b59ac3e44495b90a5cfe7c7ceb8b -Author: Hib Eris -Date: Fri Apr 12 13:26:55 2013 +0200 - - Remove unused variables from Lexer::getObj() - - https://bugs.freedesktop.org/show_bug.cgi?id=63467 - - poppler/Lexer.cc | 8 +++----- - 1 file changed, 3 insertions(+), 5 deletions(-) - -commit f8bf602620b3c7570f483ac66fc4d6a76a81a882 -Merge: bbd27dc 62a5b4d -Author: Albert Astals Cid -Date: Sun Apr 14 16:40:51 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit 62a5b4d5c6d5c368d190b86eab63ccb07d642c01 -Author: Hib Eris -Date: Sun Apr 14 16:37:14 2013 +0200 - - Check for strcpy_s() and strcat_s() at configure time - - It is better to test for functions than to hardcode exceptions for - specific compilers. - - This fixes compiling poppler with the latest mingw-w64 compiler which - has strcpy_s() and strcat_s() build in. - - Bug #63459 - - ConfigureChecks.cmake | 2 ++ - configure.ac | 1 + - test/perf-test.cc | 6 ++++-- - 3 files changed, 7 insertions(+), 2 deletions(-) - -commit bbd27dc4ce7b24af890d80f597f74e5d7ee0215a -Merge: ea3698c 5bc0080 -Author: Albert Astals Cid -Date: Fri Apr 12 00:10:27 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.22' - - Conflicts: - poppler/TextOutputDev.h - -commit 5bc00809ebe560a180d5df93eb50bdf0ff0e97e6 -Author: Albert Astals Cid -Date: Thu Apr 11 23:29:00 2013 +0200 - - Increase poppler core soname - - CMakeLists.txt | 2 +- - poppler/Makefile.am | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 115d4c1465291adde86c3c905f265ac03374441f -Author: Albert Astals Cid -Date: Thu Apr 11 23:28:17 2013 +0200 - - Increase version number to 0.22.3 - - CMakeLists.txt | 2 +- - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - 4 files changed, 4 insertions(+), 4 deletions(-) - -commit ae1a3553b85e2616a339aacb6efecd15db373858 -Author: Albert Astals Cid -Date: Thu Apr 11 23:26:44 2013 +0200 - - News file - - NEWS | 20 ++++++++++++++++++++ - 1 file changed, 20 insertions(+) - -commit 1fefe98fc86cf8449346bdc230dff5758b1bb7a3 -Author: Albert Astals Cid -Date: Thu Apr 11 23:22:20 2013 +0200 - - Update copyrgihts - - poppler/CairoOutputDev.cc | 2 +- - poppler/PDFDoc.cc | 2 +- - poppler/TextOutputDev.cc | 2 +- - poppler/TextOutputDev.h | 2 +- - 4 files changed, 4 insertions(+), 4 deletions(-) - -commit ea3698cfffc9c132081f5691287ef1fd17911b2a -Merge: fcc1468 aaaea5d -Author: Albert Astals Cid -Date: Wed Apr 10 20:42:01 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit aaaea5d0f2f427e82625a04f90c178e24892e539 -Author: Marek Kasik -Date: Wed Apr 10 16:41:48 2013 +0200 - - man pages: Fix typos - - Fix several typos in manual pages of pdftops and pdfseparate. - - utils/pdfseparate.1 | 2 +- - utils/pdftops.1 | 6 +++--- - 2 files changed, 4 insertions(+), 4 deletions(-) - -commit fcc14682899ff4981bfece74dbc8c290a625b05c -Merge: f11e216 e6559a0 -Author: Albert Astals Cid -Date: Sun Apr 7 17:44:12 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit e6559a0d836df127ed5061794dc737d435ef534c -Author: Albert Astals Cid -Date: Sun Apr 7 17:42:23 2013 +0200 - - Fix crash in KDE bug #317710 - - It is not guaranteed that the ::LinkAction passed to - PageData::convertLinkActionToLink - will be always around (e.g. Page::action deletes it) so make a copy - of the ::MediaRendition object - - qt4/src/poppler-link.h | 6 +++--- - qt4/src/poppler-media.cc | 6 ++++++ - qt4/src/poppler-media.h | 5 ++++- - qt4/src/poppler-page.cc | 4 ++-- - 4 files changed, 15 insertions(+), 6 deletions(-) - -commit f11e21627121c3ff81c0ec7f4d71936a2dd590c3 -Merge: e1ffa91 b9fdb0c -Author: Albert Astals Cid -Date: Sat Apr 6 23:26:54 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit e1ffa9100cf6b4a444be7ed76b11698a5c5bb441 -Author: Thomas Freitag -Date: Sat Apr 6 23:21:58 2013 +0200 - - Fix endstream detection - - Part 1 of bug #62985 - - the endstream search, and at least with bug-poppler16579.pdf this - doesn't work correctly: the shift(-1) with the used token mechanism - in Lexer isn't correct for a binary data stream. If there is i.e. a - "(" without corresponding ")" in the binary data, which of course can - happen and happens in that pdf, shift(-1) skips the searched endstream - and can therefore in worst case reach the end-of-file. Therefore I - implemented a shift("endstream") in Java, which I now port back to - C++, or in other words "There and Back Again" :-) - - You can test it with bug-poppler16579.pdf if You just change temporary - - if (longNumber <= INT_MAX && longNumber >= INT_MIN && - *end_ptr == '\0') { - - in XRef.cc to - - if (gFalse && longNumber <= INT_MAX && longNumber >= - INT_MIN && *end_ptr == '\0') { - - poppler/Lexer.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++ - poppler/Lexer.h | 2 ++ - poppler/Parser.cc | 28 ++++++++++++++++++++++++++-- - poppler/Parser.h | 2 ++ - 4 files changed, 75 insertions(+), 2 deletions(-) - -commit b9fdb0cb767a228c56f3f0635a7f78e3e0a8c7b6 -Author: Albert Astals Cid -Date: Sat Apr 6 23:20:48 2013 +0200 - - Last commit was Thomas' forgot his (C) - - poppler/XRef.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 94bee4601cbbda0e7c6205a04650e0510f198aee -Merge: 42368fb b312210 -Author: Albert Astals Cid -Date: Sat Apr 6 23:19:25 2013 +0200 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit b312210b630f96baeb8b2f3b49b0b79779609d98 -Author: Albert Astals Cid -Date: Sat Apr 6 23:18:18 2013 +0200 - - Fix for complete rewrites in repaired files - - Part 2 of bug #62985 - if You save a PDF with defect xref offsets, the - - readXRefUntil(-1 /* read all xref sections */, &xrefStreamObjNums) - - in XRef::scanSpecialFlags() will destroy the already reconstructed - entries table, but this means that any modification which the user did - in the meantime get lost. This can be tested i.e. with bug168518.pdf. - - poppler/XRef.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit 42368fb9452c3719a7bbd159f1c1421068f40653 -Author: Albert Astals Cid -Date: Sat Apr 6 18:28:35 2013 +0200 - - Add missing free() - - poppler/PDFDoc.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 2264e7a95e5dc252de1b5736a1edd6bf5de3ad1f -Author: Thomas Freitag -Date: Sat Apr 6 18:27:57 2013 +0200 - - implement Crypt filter - - Bug #62800 - - poppler/Decrypt.h | 3 ++- - poppler/PDFDoc.cc | 37 ++++++++++++++++++++++++++++++++++--- - poppler/Stream.cc | 6 ++++++ - poppler/Stream.h | 3 ++- - 4 files changed, 44 insertions(+), 5 deletions(-) - -commit a65a4e6f878ff033b780b2f1e3362f2918c93b6b -Author: Adam Reichold -Date: Sat Apr 6 18:25:21 2013 +0200 - - No need to keep the mutex attributes around all the time - - goo/GooMutex.h | 27 ++++++++++----------------- - 1 file changed, 10 insertions(+), 17 deletions(-) - -commit 73ff5ad58cfe7ec9415cc1459b6ca083fee608f4 -Author: Albert Astals Cid -Date: Sat Apr 6 18:19:28 2013 +0200 - - Pass the recursion flag - - poppler/DCTStream.cc | 6 +++--- - poppler/DCTStream.h | 2 +- - poppler/Stream.cc | 4 ++-- - poppler/Stream.h | 2 +- - 4 files changed, 7 insertions(+), 7 deletions(-) - -commit 837e3704e76ea857b3de45503840e9b855096fef -Author: Albert Astals Cid -Date: Sat Apr 6 17:01:08 2013 +0200 - - Make our mutexes recursive - - Fixes a deadlock problem found with a pdf i can't share - (411klaralv.pdf) - Reviewed by Thomas and Adam on the mailing list - - CMakeLists.txt | 3 +++ - glib/CMakeLists.txt | 3 +++ - goo/GooMutex.h | 36 ++++++++++++++++++++++-------------- - poppler/Annot.cc | 34 +++++++++++++++++----------------- - poppler/Annot.h | 4 ++-- - poppler/Catalog.cc | 24 +++++++++++------------- - poppler/Catalog.h | 8 ++++---- - poppler/XRef.cc | 2 +- - utils/CMakeLists.txt | 3 +++ - 9 files changed, 66 insertions(+), 51 deletions(-) - -commit 0a243c8c14d09a40f25338999c3ca06273277b45 -Author: Adam Reichold -Date: Fri Apr 5 00:00:07 2013 +0200 - - Add a GooFile class to encapsulate file read access using offsets - - Bug #62735 - - ConfigureChecks.cmake | 2 ++ - config.h.cmake | 6 ++++ - configure.ac | 1 + - goo/gfile.cc | 80 - ++++++++++++++++++++++++++++++++++++++++++++++ - goo/gfile.h | 30 +++++++++++++++++ - poppler/GlobalParamsWin.cc | 19 ++++------- - poppler/PDFDoc.cc | 37 ++++++--------------- - poppler/PDFDoc.h | 4 ++- - poppler/Stream.cc | 46 +++++++++----------------- - poppler/Stream.h | 17 +++------- - 10 files changed, 158 insertions(+), 84 deletions(-) - -commit 70e6af4739d2eea58e6f3200a8c9467597a12ae5 -Author: Rodrigo Rivas Costa -Date: Thu Apr 4 23:10:09 2013 +0200 - - Be pedantic about setjmp use - - Bug #63067 - - poppler/DCTStream.cc | 57 - +++++++++++++++++++++++++++------------------------- - 1 file changed, 30 insertions(+), 27 deletions(-) - -commit c7e28e3d672654f31f1a0f95245a1fba3bc9c28f -Author: Albert Astals Cid -Date: Mon Mar 25 22:55:58 2013 +0100 - - Only write the file once when saving - - Bug #62739 - - poppler/PDFDoc.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 09ddb34f202be2111c70901724d64d3b61483c7a -Author: Albert Astals Cid -Date: Mon Mar 25 22:55:58 2013 +0100 - - Only write the file once when saving - - Bug #62739 - - poppler/PDFDoc.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 75378557f409a5a2305ea0fb42c56184c74ba887 -Author: Carlos Garcia Campos -Date: Sun Mar 24 12:53:29 2013 +0100 - - glib: Always start from the beginning when starting a new search on - a page - - And start from previous match when searching the next one on the same - page. This allows to search for the same string multiple times on the - same page. - - https://bugs.freedesktop.org/show_bug.cgi?id=59972 - - glib/poppler-page.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 4ee6757dd7de9211faf8601531342a199225a06d -Author: Carlos Garcia Campos -Date: Sun Mar 24 12:53:29 2013 +0100 - - glib: Always start from the beginning when starting a new search on - a page - - And start from previous match when searching the next one on the same - page. This allows to search for the same string multiple times on the - same page. - - https://bugs.freedesktop.org/show_bug.cgi?id=59972 - - glib/poppler-page.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 83cf2d3d3ecce6340d858a2ee037cd5120ac1db5 -Author: Jason Crain -Date: Sat Mar 9 08:44:36 2013 -0600 - - TextOutputDev: Set text matrix when painting selection - - https://bugs.freedesktop.org/show_bug.cgi?id=61042 - - poppler/TextOutputDev.cc | 30 +++++++++++++++++++++++------- - poppler/TextOutputDev.h | 3 ++- - 2 files changed, 25 insertions(+), 8 deletions(-) - -commit a3bc584fdd7f74a7dab701c743df0bb0bf74a03e -Author: Jason Crain -Date: Sat Mar 9 08:44:36 2013 -0600 - - TextOutputDev: Set text matrix when painting selection - - https://bugs.freedesktop.org/show_bug.cgi?id=61042 - - poppler/TextOutputDev.cc | 30 +++++++++++++++++++++++------- - poppler/TextOutputDev.h | 3 ++- - 2 files changed, 25 insertions(+), 8 deletions(-) - -commit 8cbdbc64897a34beb226d4dc4c58095f10013f29 -Merge: 2bce2cf a01e2d4 -Author: Albert Astals Cid -Date: Wed Mar 20 22:37:06 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit a01e2d41fcb638fe340bd3d4d22bd13db245e0fd -Author: Thomas Freitag -Date: Wed Mar 20 22:35:08 2013 +0100 - - check order bounding box values in tiling pattern - - Bug #62369 - - poppler/Gfx.cc | 20 +++++++++++++++----- - 1 file changed, 15 insertions(+), 5 deletions(-) - -commit 2bce2cf2a523f9b8db7f5e255384044b8dfe1a24 -Author: Albert Astals Cid -Date: Tue Mar 19 22:53:47 2013 +0100 - - Avoid blackboxes on weird files using the thin line mode - - Bug #61719 - - splash/Splash.cc | 35 +++++++++++++++++++++++++++++++++++ - splash/Splash.h | 1 + - 2 files changed, 36 insertions(+) - -commit b2d07cbf0c2f94bd25e1422e366ff78031815867 -Merge: 80cf78f 3206950 -Author: Albert Astals Cid -Date: Mon Mar 18 21:06:59 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit 3206950658521009b52f638cc5e712e0cef42706 -Author: Albert Astals Cid -Date: Mon Mar 18 21:06:09 2013 +0100 - - Spec says Zoom -> 0 means no zoom change - - poppler/Link.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 13ee9f8b7d42ed7d7bc0f9dbf190ff66e6ab5a81 -Author: Pino Toscano -Date: Mon Mar 18 18:15:57 2013 +0100 - - cmake: drop search of gthread-2.0 and gio-2.0 from GTK - - this matches what is done in the autoconf counterpart - - cmake/modules/FindGTK.cmake | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 47e869e60fb147caca825380eeaa2a0851d502b9 -Author: Michael Weiser -Date: Mon Mar 18 18:15:14 2013 +0100 - - cmake: search also for gio-2.0 as GLIB library - - cmake/modules/FindGLIB.cmake | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 80cf78f2020e2f4cf33ed49fe522c6861d710588 -Merge: b21780e 72c8312 -Author: Adrian Johnson -Date: Mon Mar 18 20:02:08 2013 +1030 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit 72c8312d77704211f55c8de35b47bd811c792878 -Author: Adrian Johnson -Date: Sun Mar 17 19:39:14 2013 +1030 - - cairo: Don't change image interpolation when printing - - Bug 62418 - - poppler/CairoOutputDev.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit b21780e69dd92f3f2bcb7851608d3e0557dc81f8 -Author: Thomas Freitag -Date: Sat Mar 16 23:20:35 2013 +0100 - - Fix typo - - poppler/XRef.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 75849a0d7c205c048714b90883695b6bebd2298c -Merge: ec7140b 5a51812 -Author: Albert Astals Cid -Date: Tue Mar 12 20:27:59 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.22' - - Conflicts: - poppler/Stream.h - -commit 5a51812b7c1457feb8acaa106f43d7d5252b3980 -Author: Peter Breitenlohner -Date: Tue Mar 12 20:25:50 2013 +0100 - - Fix compile when not using libjpeg - - poppler/Stream.h | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 341e863d65fdd5619a071e4fd903fa82bf33c757 -Author: Albert Astals Cid -Date: Mon Mar 11 19:20:06 2013 +0100 - - 0.22.2 - - CMakeLists.txt | 4 ++-- - NEWS | 16 ++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 6 files changed, 22 insertions(+), 6 deletions(-) - -commit ec7140b3f56b034fbbc53cb8066ba01fe9f60f47 -Merge: c86062f 5db6585 -Author: Albert Astals Cid -Date: Fri Mar 8 16:41:21 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.22' - - Conflicts: - poppler/Stream.cc - poppler/Stream.h - -commit 5db6585c2b02dd4071f1adabd53509506333dcf8 -Author: Albert Astals Cid -Date: Fri Mar 8 16:38:49 2013 +0100 - - Make the non jpeglib based DCTStream compile - - poppler/Stream.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 6402e291e1f9374fbaf4de3b97b21f43d38d6ab8 -Author: Thomas Freitag -Date: Fri Mar 8 16:37:11 2013 +0100 - - Workaround broken jpeg stream definitions - - Bug #61994 - - poppler/DCTStream.cc | 22 +++++++++++++++++++--- - poppler/DCTStream.h | 6 +++++- - poppler/Stream.cc | 8 ++++---- - poppler/Stream.h | 4 ++-- - 4 files changed, 30 insertions(+), 10 deletions(-) - -commit c86062f982d6eb08cb27b654b6317c71ab77c692 -Merge: 677e5b2 4e142b6 -Author: Albert Astals Cid -Date: Mon Mar 4 20:13:36 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit 4e142b60790638e4495b4fd6551702470cf4c38f -Author: Albert Astals Cid -Date: Mon Mar 4 20:12:01 2013 +0100 - - Make sure we don't try to paint in x < 0 - - Fixes crash in KDE bug #315432 - - splash/Splash.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 677e5b265a0d39a988f65d642a4f964a279fad28 -Author: Albert Astals Cid -Date: Sun Mar 3 19:07:32 2013 +0100 - - Small improvements over locker class - - * Remove the namespace (we don't use much/any namespaces in - poppler core) - * Rename the class and defines from lock to locker since lock and be - either the action "to lock" or the "thing that locks", with locker - it is more clear (i think) that is "the thing" than "the action" - * Make Annot::decRefCnt use gLockMutex since we the object itself - is being deleted in the if and not sure the locker would be happy - with that - * change the getNumPages() param to be DoNotLockMutex since - previously it was a gFalse (i guess Thomas made a c&p typo here) - * Have only one constructor like Adam suggested. - - goo/GooMutex.h | 33 +++++++++-------- - poppler/Annot.cc | 92 - +++++++++++++++++++++++----------------------- - poppler/Annot.h | 6 +-- - poppler/Array.cc | 15 ++++---- - poppler/CairoFontEngine.cc | 8 ++-- - poppler/Catalog.cc | 52 +++++++++++++------------- - poppler/Catalog.h | 10 ++--- - poppler/Dict.cc | 20 +++++----- - poppler/PDFDoc.cc | 12 +++--- - poppler/Page.cc | 16 ++++---- - poppler/Stream.cc | 8 ++-- - poppler/XRef.cc | 18 ++++----- - 12 files changed, 147 insertions(+), 143 deletions(-) - -commit d5c929fc253c2748bb8fa3642d9b5383c5fe96f8 -Author: Thomas Freitag -Date: Sun Mar 3 18:00:11 2013 +0100 - - Add a locker helper and a bool -> enum changes - - Bug #59933 - - goo/GooMutex.h | 16 +++++++ - poppler/Annot.cc | 114 - +++++++++++++++++---------------------------- - poppler/Annot.h | 4 +- - poppler/Array.cc | 22 +++------ - poppler/CairoFontEngine.cc | 10 ++-- - poppler/Catalog.cc | 79 ++++++++++--------------------- - poppler/Catalog.h | 9 ++-- - poppler/Dict.cc | 29 ++++-------- - poppler/FontInfo.cc | 2 +- - poppler/PDFDoc.cc | 21 ++------- - poppler/Page.cc | 32 ++++++------- - poppler/Page.h | 3 +- - poppler/Stream.cc | 12 ++--- - poppler/XRef.cc | 29 ++++-------- - 14 files changed, 145 insertions(+), 237 deletions(-) - -commit 1f4a012f7570ffd2120e3e8c2236de5408f3dda3 -Merge: 15d4039 a766740 -Author: Albert Astals Cid -Date: Fri Mar 1 19:16:52 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit a766740cf5a5a7580935a026bf15fbd668aa0fdf -Author: Thomas Freitag -Date: Fri Mar 1 19:12:22 2013 +0100 - - Restore CTM on early exits - - Bug #61413 - - poppler/SplashOutputDev.cc | 14 ++++++++++---- - 1 file changed, 10 insertions(+), 4 deletions(-) - -commit 15d40392a29dded8a29c2dc9d7c15b402515e033 -Merge: be5d9af 39882df -Author: Albert Astals Cid -Date: Thu Feb 28 19:46:59 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit 39882dfecdccc00db353946a31d395582ee37022 -Author: José Aliste -Date: Wed Feb 27 01:33:38 2013 +0100 - - Correct rendering of underline and strike out annotations - - Current code assumes that the text to underline or strike out is - horizontal. - Fixes bug #61518 - - poppler/Annot.cc | 27 ++++++++++++++++----------- - 1 file changed, 16 insertions(+), 11 deletions(-) - -commit be5d9af38655496a2eaa4eb12cea84461c5aeb3f -Author: Thomas Freitag -Date: Sat Feb 23 23:41:46 2013 +0100 - - expose thin line modes in qt frontend - - qt4/src/poppler-page.cc | 5 ++++- - qt4/src/poppler-qt4.h | 6 ++++-- - 2 files changed, 8 insertions(+), 3 deletions(-) - -commit f96cbacfdbc97ace35f843854992f06e9322f485 -Author: Thomas Freitag -Date: Sat Feb 23 23:39:52 2013 +0100 - - Refine splashThinLineShape support - - splash/Splash.cc | 14 +++++++++++--- - 1 file changed, 11 insertions(+), 3 deletions(-) - -commit 47453a78e52aa43edd148aef53b67306603161f5 -Author: Thomas Freitag -Date: Wed Feb 20 23:12:17 2013 +0100 - - More threading safety - - poppler/Annot.cc | 97 - +++++++++++++++++++++++++++++++++++------ - poppler/Annot.h | 8 +++- - poppler/FontInfo.cc | 29 ++++++------ - poppler/FontInfo.h | 5 ++- - poppler/Page.cc | 11 ++++- - poppler/Page.h | 6 +-- - poppler/SplashOutputDev.cc | 7 ++- - poppler/SplashOutputDev.h | 5 ++- - poppler/XRef.cc | 4 +- - qt4/src/poppler-page.cc | 9 ++-- - qt4/src/poppler-ps-converter.cc | 3 +- - 11 files changed, 139 insertions(+), 45 deletions(-) - -commit 60c5e072d4b930507469e6e8c234971725a4aa26 -Merge: 0d42a6d 8d62625 -Author: Albert Astals Cid -Date: Wed Feb 20 21:08:53 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit 8d62625610746ad70ffb88d845791fa03f5e35cc -Author: Thomas Fischer -Date: Wed Feb 20 21:07:10 2013 +0100 - - height -> maskHeight - - Bug #61168 - - utils/ImageOutputDev.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 0d42a6dab479d27de1ecb2b47ad3f7568b1ee638 -Merge: 7eb7880 8fb243b -Author: Albert Astals Cid -Date: Wed Feb 20 00:00:09 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit 8fb243bf11a979af8bfa36427436940706c9f71d -Author: Albert Astals Cid -Date: Tue Feb 19 23:59:17 2013 +0100 - - Initialize cSrcNonIso[3] in splashModeXBGR8 - - Fixes valgrind warning - - splash/Splash.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 8a0199a0247c1a03a4d64375ca8bc900570d1817 -Author: Albert Astals Cid -Date: Tue Feb 19 23:11:46 2013 +0100 - - Fix indent - - splash/Splash.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 7eb7880907cb7b6bd1032013d6ce4c49aa3525c4 -Merge: 2c84acb 1389aa4 -Author: Albert Astals Cid -Date: Tue Feb 19 22:26:37 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit 1389aa41b2984de9da7bb66c11485f6c6aeaea41 -Author: Albert Astals Cid -Date: Tue Feb 19 22:25:56 2013 +0100 - - fix indent - - splash/Splash.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 2c84acbfd02eeeaf0d20542798e907cb011c1e57 -Merge: 401c35b ffd33e7 -Author: Albert Astals Cid -Date: Tue Feb 19 11:32:11 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit ffd33e7b5aea44bc54a74f433f6bfff859b913dd -Author: Albert Astals Cid -Date: Tue Feb 19 11:31:22 2013 +0100 - - Fix missing ) here too - - README.contributors | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 14466ecc320387c9b6568280614a96e6f56309b4 -Author: Albert Astals Cid -Date: Tue Feb 19 11:31:02 2013 +0100 - - Forgot my C here - - poppler/PageLabelInfo.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 401c35b797d3c25c734fbfb5b95be16a666a6012 -Author: Albert Astals Cid -Date: Mon Feb 18 22:33:07 2013 +0100 - - Fix closing ) as suggested by William Bader - - README.contributors | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 94364adade4dc27e5d80bc14511d4f2b7ea4ab0d -Merge: 164805b 47f30fa -Author: Albert Astals Cid -Date: Mon Feb 18 20:34:34 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit 47f30fa96e62fc215c0e80f42517908760ef8065 -Author: Brad Hards -Date: Mon Feb 18 20:38:10 2013 +1100 - - Minor rewording of contributor README - - README.contributors | 13 +++++++------ - 1 file changed, 7 insertions(+), 6 deletions(-) - -commit 164805b4471256d3915c5e49fff28c9cdcbf89e6 -Author: Albert Astals Cid -Date: Mon Feb 18 20:05:12 2013 +0100 - - Move the commented test to a proper one - - poppler/Makefile.am | 3 +- - poppler/PageLabelInfo.cc | 160 - +------------------------------------- - poppler/PageLabelInfo_p.h | 147 - ++++++++++++++++++++++++++++++++++ - qt4/tests/CMakeLists.txt | 1 + - qt4/tests/Makefile.am | 4 + - qt4/tests/check_pagelabelinfo.cpp | 43 ++++++++++ - 6 files changed, 198 insertions(+), 160 deletions(-) - -commit 527b91a0ef97906041ffe57e88f0d26e1c407af0 -Merge: df35562 95609be -Author: Albert Astals Cid -Date: Mon Feb 18 19:49:14 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit 95609be551fc4413874b8980010be70fbbab112a -Author: Albert Astals Cid -Date: Mon Feb 18 19:47:19 2013 +0100 - - Use the toLatin function in PageLabelInfo::indexToLabel - - Wonder why Kristian never enabled it? - Fixes bug #61034 - - poppler/PageLabelInfo.cc | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit df3556240d5e4b4546b3c42b29be6d2be83a2802 -Merge: 4dacd7c 5c7057c -Author: Albert Astals Cid -Date: Tue Feb 12 23:55:24 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit 5c7057c61ed6e270e001c1f86632f265bebb6890 -Author: Nuno Araujo -Date: Tue Feb 12 23:54:47 2013 +0100 - - Fix the build with automake-1.13 - - autogen.sh | 17 +++++++++-------- - configure.ac | 3 +-- - 2 files changed, 10 insertions(+), 10 deletions(-) - -commit 4dacd7cdeb19d16fe7737c71e34904c7363c6b63 -Merge: 7f2c255 9fc4b9f -Author: Albert Astals Cid -Date: Tue Feb 12 22:59:56 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.22' - -commit 9fc4b9f7a7e6105a6fd85aed9c21b78742e89ddd -Author: Peter Breitenlohner -Date: Tue Feb 12 22:58:17 2013 +0100 - - true->TRUE - - Fixes compilation with jpeglib9 - - goo/JpegWriter.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 7f2c255ff28386ba992717f729f25a979f240375 -Author: Thomas Freitag -Date: Tue Feb 12 22:48:40 2013 +0100 - - Introduce option SplashThinLineMode - - More info at bug #37347 - - poppler/SplashOutputDev.cc | 9 ++++++++- - poppler/SplashOutputDev.h | 3 ++- - splash/Splash.cc | 37 ++++++++++++++++++++++++++++++------- - splash/Splash.h | 9 +++++++-- - splash/SplashClip.cc | 7 ++++--- - splash/SplashClip.h | 4 +++- - splash/SplashTypes.h | 8 +++++++- - splash/SplashXPath.cc | 14 ++++++++++++-- - splash/SplashXPath.h | 17 ++++++++++++++++- - splash/SplashXPathScanner.cc | 9 +++++---- - splash/SplashXPathScanner.h | 17 ++++++++++++++++- - 11 files changed, 110 insertions(+), 24 deletions(-) - -commit c2ebcbea2267f861c491c0cd6c1fbf2dc2aff7d2 -Merge: 48ed05d dca21f8 -Author: Albert Astals Cid -Date: Sun Feb 10 12:01:13 2013 +0100 - - Merge remote-tracking branch 'origin/poppler-0.22' - - Conflicts: - poppler/Parser.cc - -commit dca21f86359b6b2a925f7b05a2f36ab854cefbce -Author: Albert Astals Cid -Date: Sun Feb 10 11:47:21 2013 +0100 - - 0.22.1 - - CMakeLists.txt | 2 +- - NEWS | 9 +++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - 5 files changed, 13 insertions(+), 4 deletions(-) - -commit e8e9245f6a4884da3940fc281b7ff1a42d7f5964 -Author: Albert Astals Cid -Date: Sun Feb 10 11:43:14 2013 +0100 - - Update C year here too - - poppler/poppler-config.h.cmake | 2 +- - poppler/poppler-config.h.in | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit ebbacd897e2b529d1c3637b6af438b8dcc1d7ce8 -Author: Albert Astals Cid -Date: Sun Feb 10 11:42:21 2013 +0100 - - Update C - - poppler/Parser.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 48ed05d95598b642a57456a843baf9f246502bb6 -Author: Adrian Johnson -Date: Wed Feb 6 21:56:01 2013 +1030 - - Make Goffset long long and factor out all fseek/ftell into gfile.cc - - This fixes build problems on 32-bit machines due to off_t being - defined differently depending on whether source files included - condig.h. - - Bug 60095 - - goo/gfile.cc | 38 ++++++++++++++++++++++++ - goo/gfile.h | 7 +++++ - goo/gtypes.h | 19 +----------- - poppler/Stream.cc | 67 - ++++++------------------------------------ - poppler/XRef.cc | 4 +-- - poppler/poppler-config.h.cmake | 6 ---- - poppler/poppler-config.h.in | 6 ---- - utils/pdfinfo.cc | 16 ++-------- - 8 files changed, 60 insertions(+), 103 deletions(-) - -commit fbcd64386c1b189db6e06234577261973bdc88cc -Author: Adrian Johnson -Date: Fri Jan 25 22:24:50 2013 +1030 - - cairo: support uncolored tiling patterns - - Bug 59179 - - poppler/CairoOutputDev.cc | 20 ++++++++++++++++++++ - poppler/CairoOutputDev.h | 1 + - 2 files changed, 21 insertions(+) - -commit c60ad119363c65d097dff56a68c1ab3fb2933f0b -Author: Adrian Johnson -Date: Sun Jan 27 15:50:26 2013 +1030 - - A few more missing Goffsets - - glib/poppler-input-stream.h | 2 +- - poppler/PDFDoc.cc | 16 ++++++++-------- - poppler/PDFDoc.h | 6 +++--- - poppler/Stream.cc | 4 ++-- - poppler/Stream.h | 4 ++-- - 5 files changed, 16 insertions(+), 16 deletions(-) - -commit 9b113dc86a27085693ac4bcad061780c881ea7f9 -Author: Adrian Johnson -Date: Sun Jan 27 11:32:34 2013 +1030 - - Use sys/types.h instead of stdio.h for the off_t type - - Bug 44085 - - goo/gtypes.h | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit f3aa5236361dca3db64f110520ebe721ba1c9464 -Author: Pino Toscano -Date: Sun Jan 27 18:50:10 2013 +0100 - - use Goffset also for length in MemStream ctor - - poppler/Stream.cc | 2 +- - poppler/Stream.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit eb5ce6990522bac91d8f5d0d3636c46178386d25 -Author: Pino Toscano -Date: Sun Jan 27 15:20:42 2013 +0100 - - avoid max() macro expansion - - protect against compilers defining max as macro - - poppler/XRef.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 6b716b1ab60b573b5770d8636992247387bc3513 -Author: Pino Toscano -Date: Sun Jan 27 15:18:04 2013 +0100 - - cmake: provide HAVE_FSEEK64 and HAVE_FSEEKO in poppler-config - - followup of a3cee0e7e9dd292c70fe1fa19a92e70bbc1e1b41 also for the - cmake-generated poppler-config.h - - poppler/poppler-config.h.cmake | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit fe59ac914230b80aa82b314398a8a038ef083e06 -Author: Adrian Johnson -Date: Sat Jan 26 16:44:49 2013 +1030 - - Read 8 byte xref offsets when sizeof(Goffset) < 8 - - and print an error if the offset read is too large for Goffset. - - Bug 56318 - - poppler/XRef.cc | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -commit 098d98dfc3846150098f5b20f3f5a07cb565c465 -Author: Lu Wang -Date: Sat Jan 26 19:31:20 2013 +0100 - - Rename function - - Makes it say more what it does - - poppler/GfxState.cc | 3 ++- - poppler/GfxState.h | 3 ++- - poppler/SplashOutputDev.cc | 5 +++-- - 3 files changed, 7 insertions(+), 4 deletions(-) - -commit 97e93d7583f2a6a5b1c8b51474744ca05277dc28 -Author: Lu Wang -Date: Sat Jan 26 16:56:00 2013 +0100 - - Remove unused deviceHasTextClip - - poppler/CairoOutputDev.h | 1 - - poppler/OutputDev.h | 1 - - poppler/PSOutputDev.h | 1 - - poppler/SplashOutputDev.h | 1 - - utils/pdftohtml.cc | 1 - - 5 files changed, 5 deletions(-) - -commit 1bb3ddc2264cb65dffd553a952ee4518344df0de -Author: Albert Astals Cid -Date: Fri Jan 25 19:37:24 2013 +0100 - - A few Goffsets we missed - - charactersRead is returned in BaseCryptStream::getPos thus should - be a Goffset - Gfx::getPos returns Parser::getPos and thus should be a Goffset too - - poppler/Decrypt.h | 3 ++- - poppler/Gfx.cc | 4 ++-- - poppler/Gfx.h | 4 ++-- - 3 files changed, 6 insertions(+), 5 deletions(-) - -commit 5f8b1275a19b2036c6e9323a744d8bc64af31c36 -Author: Albert Astals Cid -Date: Fri Jan 25 19:32:58 2013 +0100 - - New year! - - poppler/poppler-config.h.cmake | 2 +- - poppler/poppler-config.h.in | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 574907e6a74e62a5ee6d7f17c43fdd9bcb07e069 -Author: Albert Astals Cid -Date: Fri Jan 25 19:31:59 2013 +0100 - - Adrian C for 2013 because of the big files support - - cpp/poppler-private.cpp | 1 + - cpp/poppler-private.h | 1 + - goo/gtypes.h | 1 + - poppler/Decrypt.cc | 1 + - poppler/Decrypt.h | 1 + - poppler/Error.cc | 1 + - poppler/Error.h | 1 + - poppler/Hints.cc | 1 + - poppler/Hints.h | 1 + - poppler/JBIG2Stream.cc | 1 + - poppler/JBIG2Stream.h | 1 + - poppler/JPEG2000Stream.cc | 1 + - poppler/JPEG2000Stream.h | 1 + - poppler/Lexer.cc | 2 +- - poppler/Lexer.h | 1 + - poppler/Object.cc | 1 + - poppler/Object.h | 1 + - poppler/PDFDoc.cc | 1 + - poppler/PDFDoc.h | 1 + - poppler/PageTransition.cc | 1 + - poppler/Parser.cc | 1 + - poppler/Parser.h | 1 + - poppler/SecurityHandler.cc | 1 + - poppler/Stream.cc | 1 + - poppler/Stream.h | 1 + - poppler/XRef.cc | 1 + - poppler/XRef.h | 1 + - qt4/src/poppler-private.cc | 1 + - qt4/src/poppler-qiodeviceoutstream-private.h | 1 + - qt4/src/poppler-qiodeviceoutstream.cc | 1 + - utils/pdfinfo.cc | 2 +- - utils/pdfunite.cc | 1 + - 32 files changed, 32 insertions(+), 2 deletions(-) - -commit 95b81ae9b5a345c9caa3d658b9b543d1937c6c02 -Author: Adrian Johnson -Date: Fri Jan 25 21:37:51 2013 +1030 - - gitignore - - qt4/tests/.gitignore | 2 ++ - 1 file changed, 2 insertions(+) - -commit 576dc53c857d99bb5d81fe7c9c52fe314a6e58ee -Author: Thomas Freitag -Date: Fri Jan 25 21:27:13 2013 +1030 - - splash: fix uninitialized memory - - Bug 44085 - - poppler/SplashOutputDev.cc | 13 +++++++------ - 1 file changed, 7 insertions(+), 6 deletions(-) - -commit a9768588cd6086f4ca4e6906db038cfdbfd551d5 -Author: Adrian Johnson -Date: Fri Jan 25 21:24:29 2013 +1030 - - win32 large file support - - Bug 44085 - - goo/gtypes.h | 2 ++ - poppler/Stream.cc | 13 +++++++++++++ - utils/pdfinfo.cc | 3 +++ - 3 files changed, 18 insertions(+) - -commit a3cee0e7e9dd292c70fe1fa19a92e70bbc1e1b41 -Author: Adrian Johnson -Date: Fri Jan 25 21:23:43 2013 +1030 - - Large file support - - Create a Goffset type and use this type for all file offsets and file - sizes. - - Bug 44085 - - cpp/poppler-private.cpp | 2 +- - cpp/poppler-private.h | 2 +- - glib/poppler-input-stream.cc | 10 +- - glib/poppler-input-stream.h | 16 +-- - goo/gtypes.h | 15 +++ - poppler/Decrypt.cc | 2 +- - poppler/Decrypt.h | 2 +- - poppler/Error.cc | 10 +- - poppler/Error.h | 5 +- - poppler/Hints.cc | 4 +- - poppler/Hints.h | 6 +- - poppler/JBIG2Stream.cc | 8 +- - poppler/JBIG2Stream.h | 2 +- - poppler/JPEG2000Stream.cc | 2 +- - poppler/JPEG2000Stream.h | 2 +- - poppler/Lexer.h | 8 +- - poppler/Object.h | 8 +- - poppler/PDFDoc.cc | 54 +++++----- - poppler/PDFDoc.h | 14 +-- - poppler/Parser.cc | 10 +- - poppler/Parser.h | 2 +- - poppler/Stream.cc | 88 ++++++++--------- - poppler/Stream.h | 102 +++++++++---------- - poppler/XRef.cc | 141 - +++++++++++++++++---------- - poppler/XRef.h | 34 +++---- - poppler/poppler-config.h.in | 6 ++ - qt4/src/poppler-private.cc | 2 +- - qt4/src/poppler-qiodeviceoutstream-private.h | 2 +- - qt4/src/poppler-qiodeviceoutstream.cc | 4 +- - test/perf-test.cc | 6 +- - utils/pdfinfo.cc | 6 +- - utils/pdfunite.cc | 2 +- - 32 files changed, 320 insertions(+), 257 deletions(-) - -commit 6eebbb9c015f98b713205e56ab2f1d4d430e9206 -Author: Adrian Johnson -Date: Fri Jan 25 21:22:51 2013 +1030 - - Add Int64 object type - - Bug 44085 - - poppler/Lexer.cc | 46 - ++++++++++++++++++++-------------------------- - poppler/Object.cc | 6 +++--- - poppler/Object.h | 26 +++++++++++++++----------- - poppler/PDFDoc.cc | 4 ++-- - poppler/SecurityHandler.cc | 4 ++-- - qt4/tests/check_lexer.cpp | 24 +++++++++++++++++------- - test/pdf-fullrewrite.cc | 9 +-------- - 7 files changed, 60 insertions(+), 59 deletions(-) - -commit be495d73ce7324963a979cffc149330f5512288b -Author: Adrian Johnson -Date: Fri Jan 25 21:14:21 2013 +1030 - - use getNum instead of getReal - - poppler/PageTransition.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit a5adb6738e1e191c64457e0c07ee2e3422a042dd -Author: Albert Astals Cid -Date: Sat Jan 19 18:13:33 2013 +0100 - - Don't use config.h but poppler-config.h - - That was already included but i forgot to kill the other one - - poppler/XRef.h | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit 8eb489c355d734a72e140ce7e32470d048362499 -Author: Thomas Freitag -Date: Sat Jan 19 17:43:08 2013 +0100 - - Make rendering thread-safe - - Bug #50992 - - glib/poppler-input-stream.cc | 4 ++ - glib/poppler-input-stream.h | 1 + - poppler/Annot.cc | 52 +++++++++---------- - poppler/Array.cc | 48 +++++++++++++++++- - poppler/Array.h | 15 ++++-- - poppler/ArthurOutputDev.cc | 3 +- - poppler/ArthurOutputDev.h | 3 +- - poppler/CairoFontEngine.cc | 33 +++++++++--- - poppler/CairoFontEngine.h | 11 ++-- - poppler/CairoOutputDev.cc | 15 ++++-- - poppler/CairoOutputDev.h | 5 +- - poppler/Catalog.cc | 84 +++++++++++++++++++++++++++---- - poppler/Catalog.h | 15 ++++-- - poppler/Dict.cc | 67 ++++++++++++++++++++++++- - poppler/Dict.h | 11 +++- - poppler/Gfx.cc | 18 ++++--- - poppler/Gfx.h | 8 +-- - poppler/GlobalParamsWin.cc | 4 +- - poppler/Object.h | 7 +-- - poppler/OutputDev.h | 4 +- - poppler/PDFDoc.cc | 66 ++++++++++++++++++------ - poppler/PDFDoc.h | 11 ++-- - poppler/PSOutputDev.cc | 12 ++--- - poppler/PSOutputDev.h | 4 +- - poppler/Page.cc | 75 ++++++++++++++++++++++++--- - poppler/Page.h | 18 +++++-- - poppler/Parser.cc | 3 +- - poppler/PreScanOutputDev.cc | 4 +- - poppler/PreScanOutputDev.h | 4 +- - poppler/SplashOutputDev.cc | 16 +++--- - poppler/SplashOutputDev.h | 5 +- - poppler/Stream.cc | 117 - ++++++++++++++++++++++++++++++++----------- - poppler/Stream.h | 35 +++++++++---- - poppler/TextOutputDev.cc | 5 +- - poppler/TextOutputDev.h | 3 +- - poppler/XRef.cc | 99 +++++++++++++++++++++++++++++++++--- - poppler/XRef.h | 16 +++++- - qt4/src/poppler-document.cc | 23 ++++----- - qt4/src/poppler-page.cc | 64 ++++++++++++++++++++--- - qt4/src/poppler-private.cc | 3 +- - qt4/src/poppler-private.h | 74 +-------------------------- - test/gtk-test.cc | 2 +- - utils/HtmlOutputDev.cc | 3 +- - utils/HtmlOutputDev.h | 3 +- - utils/ImageOutputDev.h | 3 +- - 45 files changed, 793 insertions(+), 283 deletions(-) - -commit 3db9472e2b016f1b411174273f27848193ab18e5 -Author: José Aliste -Date: Fri Jan 18 15:22:03 2013 +0100 - - Add a null check for gfxFont - - Bug #59561 - - poppler/TextOutputDev.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 4b69217f72f3fd313f73df059eb1e6294878a95e -Author: Peter Dyballa -Date: Fri Jan 11 00:32:46 2013 +0100 - - Use CPPFLAGS for CPPFLAGS not CFLAGS - - Bug #59186 - - m4/libjpeg.m4 | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 8b6dc55e530b2f5ede6b9dfb64aafdd1d5836492 -Author: Albert Astals Cid -Date: Thu Jan 10 22:31:52 2013 +0100 - - Fix invalid memory access in 1150.pdf.asan.8.69 - - splash/Splash.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit e14b6e9c13d35c9bd1e0c50906ace8e707816888 -Author: Albert Astals Cid -Date: Thu Jan 10 20:52:02 2013 +0100 - - Fix invalid memory access in 2030.pdf.asan.69.463 - - poppler/Function.cc | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -commit 0388837f01bc467045164f9ddaff787000a8caaa -Author: Albert Astals Cid -Date: Thu Jan 10 20:29:06 2013 +0100 - - Fix another invalid memory access in 1091.pdf.asan.72.42 - - poppler/Stream.cc | 10 ++++++++-- - 1 file changed, 8 insertions(+), 2 deletions(-) - -commit 957aa252912cde85d76c41e9710b33425a82b696 -Author: Albert Astals Cid -Date: Thu Jan 10 19:16:19 2013 +0100 - - Fix invalid memory accesses in 1091.pdf.asan.72.42 - - splash/Splash.cc | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -commit bbc2d8918fe234b7ef2c480eb148943922cc0959 -Author: Albert Astals Cid -Date: Thu Jan 10 19:07:48 2013 +0100 - - Fix invalid memory accesses in 1036.pdf.asan.23.17 - - splash/Splash.cc | 14 ++++++++++++-- - 1 file changed, 12 insertions(+), 2 deletions(-) - -commit a9b8ab4657dec65b8b86c225d12c533ad7e984e2 -Author: Albert Astals Cid -Date: Wed Jan 9 22:56:45 2013 +0100 - - Fix crash in broken file 1031.pdf.asan.48.15 - - splash/Splash.cc | 9 ++++++--- - 1 file changed, 6 insertions(+), 3 deletions(-) - -commit 7266a634e01e20648cc877371edc95651d30d4fc -Author: Albert Astals Cid -Date: Wed Jan 9 22:52:45 2013 +0100 - - Forgot the C of the last commit - - splash/Splash.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit a205e71a2dbe0c8d4f4905a76a3f79ec522eacec -Author: Albert Astals Cid -Date: Wed Jan 9 22:47:28 2013 +0100 - - Do not crash in broken documents like 1007.pdf.asan.48.4 - - splash/Splash.cc | 12 +++++++++++- - 1 file changed, 11 insertions(+), 1 deletion(-) - -commit b1026b5978c385328f2a15a2185c599a563edf91 -Author: Albert Astals Cid -Date: Wed Jan 9 22:17:09 2013 +0100 - - Initialize refLine totally - - Fixes uninitialized memory read in 1004.pdf.asan.7.3 - - poppler/Stream.cc | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -commit bef2c42f381c74fdb8bbb43babe1a93a0e229fb0 -Author: Adrian Johnson -Date: Thu Jan 3 15:27:36 2013 +1030 - - Parser: return error if stream encountered when allowStreams = false - - Opening a PDF file where the first object is a stream prints a - "Command token too long" error message. This is caused by the - Linearization check in Linearization::Linearization reading objects - with allowStreams = false. The Parser ignores the "stream" token and - tries reading the next token which is usually binary data. Setting - allowStreams to true will not work since the stream length is often an - indirect object and at this point the XRef has not been created. - - Fix this by making Parser return an error object if the "stream" token - is encountered when allowStreams is false. - - Bug 58966 - - poppler/Parser.cc | 14 +++++++------- - 1 file changed, 7 insertions(+), 7 deletions(-) - -commit 801f7feea79e5bc3b5417566552e4df1e6b8a51c -Author: Albert Astals Cid -Date: Sat Dec 29 19:22:54 2012 +0100 - - 0.22.0 - - CMakeLists.txt | 6 +++--- - NEWS | 14 ++++++++++++++ - configure.ac | 4 ++-- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 6 files changed, 22 insertions(+), 8 deletions(-) - -commit bf5ef68c89d4189b18458b764f807cfc6599bad7 -Author: Carlos Garcia Campos -Date: Sat Dec 29 19:43:11 2012 +0100 - - regtest: Print test results when the test has finished - - To make sure the result corresponds to the test now that we are using - multiple threads. - - regtest/Printer.py | 25 +++++++++++++++++++------ - regtest/TestRun.py | 18 +++++++++--------- - 2 files changed, 28 insertions(+), 15 deletions(-) - -commit 80c7f6aa3fa83175fafc71fa8c834350d513a48f -Author: Jason Crain -Date: Fri Nov 23 23:31:01 2012 -0600 - - TextOutputDev: Use page size for max value in TextPage::visitSelection - - https://bugs.freedesktop.org/show_bug.cgi?id=50138 - - poppler/TextOutputDev.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 0d31edfa5617f4fecb04d5476de54a63b6146686 -Author: Ross Lagerwall -Date: Fri Nov 30 09:23:55 2012 +0000 - - pdf-inspector Change from the deprecated GtkTable to GtkGrid - - This fixes the problem of the description_label height changing after - its text changes which was introduced since the port to Gtk3. - - https://bugs.freedesktop.org/show_bug.cgi?id=57727 - - test/pdf-inspector.ui | 39 +++++++++++++++------------------------ - 1 file changed, 15 insertions(+), 24 deletions(-) - -commit 9977a4f26b5698b0b85ca911e7392013941944e0 -Author: Ross Lagerwall -Date: Tue Nov 13 15:49:44 2012 +0000 - - pdf-inspector: Remove deprectated has-separator property - - https://bugs.freedesktop.org/show_bug.cgi?id=57727 - - test/pdf-inspector.ui | 1 - - 1 file changed, 1 deletion(-) - -commit 806d116a38c2a6552c9bcee2c6f753d7059c17aa -Author: Ross Lagerwall -Date: Tue Nov 13 15:44:15 2012 +0000 - - pdf-inspector: Add correct title and copyright - - https://bugs.freedesktop.org/show_bug.cgi?id=57727 - - test/pdf-inspector.cc | 5 ++--- - 1 file changed, 2 insertions(+), 3 deletions(-) - -commit 7d5bf74c19768fa3447819a4debff06d5d83900a -Author: Ross Lagerwall -Date: Tue Nov 13 15:23:36 2012 +0000 - - pdf-inspector: Fix crash by not freeing filename_g - - It is not necessary because PDFDoc takes over filename_g and destroys - it in its deconstructor. - - https://bugs.freedesktop.org/show_bug.cgi?id=57727 - - test/pdf-inspector.cc | 1 - - 1 file changed, 1 deletion(-) - -commit d61c6d4944d6f7c9e8b517dd28958124f4923d08 -Author: Thomas Freitag -Date: Fri Dec 28 01:18:48 2012 +0100 - - Repair pdfunite - - Sorry, when I implemented the support encrypted pdf files in - pdfseparate I - missed that writePageObjects of course is also used in pdfunite - for combining - pages, and even more that encrypted files are still not supported - by pdfunite, - I removed the numoffset from writing the objects itself. Therefore - there are - still all objects in the combined pdf file, but the references - missing the - numoffset and therefore were no more reachable. - The patch repairs it. - - Bug #58569 - - poppler/PDFDoc.cc | 6 ++++-- - poppler/PDFDoc.h | 4 ++-- - utils/pdfunite.cc | 4 ++-- - 3 files changed, 8 insertions(+), 6 deletions(-) - -commit be4804bff2b722ceac180da52ad436fee548f9ee -Author: Albert Astals Cid -Date: Fri Dec 28 01:17:14 2012 +0100 - - dos2unix - - poppler/PDFDoc.cc | 36 ++++++++++++++++++------------------ - 1 file changed, 18 insertions(+), 18 deletions(-) - -commit 703c77eb59aa22ab6372d56a20ee81dc7dfa6e4a -Author: Even Rouault -Date: Fri Dec 28 00:57:17 2012 +0100 - - Fix very long loop in JPXStream::getImageParams() - - poppler/JPXStream.cc | 14 ++++++++++---- - 1 file changed, 10 insertions(+), 4 deletions(-) - -commit 7e0be7854adc49e4e00c0badb0dc470fbdf6d612 -Author: Even Rouault -Date: Fri Dec 28 00:44:29 2012 +0100 - - Avoid DoS due to huge number of JPX tiles in a stream - - poppler/JPXStream.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 2017dbebd9afd4f172242ff8462fce739d911e64 -Author: Even Rouault -Date: Fri Dec 28 00:30:13 2012 +0100 - - Do not crash on 0 or negative nBits values - - poppler/Stream.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 858df0dc04e2f306e806fe0fc4fb5c8ec804e263 -Author: Albert Astals Cid -Date: Thu Dec 27 23:30:27 2012 +0100 - - Fix arg typo - - poppler/PDFDoc.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 1dd6280d79ad22461208702b3c929377887c99ff -Author: Albert Astals Cid -Date: Sat Dec 15 16:39:23 2012 +0100 - - 0.21.4 soversion increases - - CMakeLists.txt | 2 +- - glib/CMakeLists.txt | 2 +- - glib/Makefile.am | 2 +- - poppler/Makefile.am | 2 +- - 4 files changed, 4 insertions(+), 4 deletions(-) - -commit 99d0288bb0b6879ae5414d174939bbd9c1e90bd3 -Author: Albert Astals Cid -Date: Sat Dec 15 16:37:19 2012 +0100 - - 0.21.4 version increase - - CMakeLists.txt | 2 +- - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - 4 files changed, 4 insertions(+), 4 deletions(-) - -commit 2bc48d5369f1dbecfc4db2878f33bdeb80d8d90f -Author: Albert Astals Cid -Date: Sat Dec 15 16:36:38 2012 +0100 - - 0.21.4 NEWS - - NEWS | 18 ++++++++++++++++++ - 1 file changed, 18 insertions(+) - -commit b3423d54b1254597d7ca953872211fa3aa83e29c -Author: Albert Astals Cid -Date: Sat Dec 15 16:29:54 2012 +0100 - - Updated copyrights - - goo/JpegWriter.h | 2 +- - goo/PNGWriter.cc | 1 + - goo/PNGWriter.h | 1 + - goo/TiffWriter.cc | 1 + - goo/TiffWriter.h | 1 + - poppler/GlobalParams.cc | 2 +- - poppler/TextOutputDev.cc | 1 + - splash/Splash.cc | 1 + - utils/HtmlOutputDev.cc | 1 + - 9 files changed, 9 insertions(+), 2 deletions(-) - -commit 487f20d24830a97cad4773ae27f0c2cc58df2ed0 -Author: Albert Astals Cid -Date: Thu Dec 13 20:40:39 2012 +0100 - - Check obj1 is a dict before using it - - Fixes bug #58257 - - poppler/Gfx.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 03045469206adbd797e3a38fee3a16cdd1716812 -Author: Albert Astals Cid -Date: Thu Dec 13 19:24:54 2012 +0100 - - Fix crop on EPS conversion - - Bug #30692 - Patch is half William Bader's and half mine - - poppler/OutputDev.h | 5 +++++ - poppler/PSOutputDev.h | 4 +++- - poppler/Page.cc | 3 +++ - poppler/Page.h | 2 ++ - 4 files changed, 13 insertions(+), 1 deletion(-) - -commit 5d50b2765428e5a417967be2f41452ab05917db7 -Author: Peter Breitenlohner -Date: Tue Dec 11 18:54:30 2012 +0100 - - Correct bad semantics - - Negation has higher precedence than comparison - Confirmed by Marek Kasik that wrote the code originally - - poppler/TextOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit e306bad391a3ff49593f1f3bac0717d62599bd13 -Author: Pino Toscano -Date: Sun Dec 9 22:40:27 2012 +0100 - - pngwriter: move #include into .cc file - - Move all the private data (including the libpng types) to a private - class. - - This requires HtmlOutputDev.cc to include on its own (which - is correct, since it uses the libpng API directly). - - goo/PNGWriter.cc | 98 - +++++++++++++++++++++++++++++--------------------- - goo/PNGWriter.h | 12 ++----- - utils/HtmlOutputDev.cc | 4 +++ - 3 files changed, 64 insertions(+), 50 deletions(-) - -commit cf338551e9d031cc00d56cea0d258ec5fd96e79a -Author: Pino Toscano -Date: Sun Dec 9 22:22:03 2012 +0100 - - tiffwriter: move #include into .cc file - - Move all the private data (including the libtiff types) to a private - class. - - goo/TiffWriter.cc | 94 - ++++++++++++++++++++++++++++++++----------------------- - goo/TiffWriter.h | 12 ++----- - 2 files changed, 56 insertions(+), 50 deletions(-) - -commit 0dfa51f0bfa787ee9c865fd4f05e4bd964c260fc -Author: Albert Astals Cid -Date: Sun Dec 9 22:31:50 2012 +0100 - - Having a look at the log Marek has (C) in this file - - poppler/TextOutputDev.cc | 1 + - 1 file changed, 1 insertion(+) - -commit f1b2e29e1d5f420903085318f06c4dc83ebb24f3 -Author: Thomas Freitag -Date: Sun Dec 9 20:59:26 2012 +0100 - - Fix crash when rendering on mono1 - - poppler/SplashOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 71bad47ed6a36d825b0d08992c8db56845c71e40 -Author: Marek Kasik -Date: Sun Dec 9 20:20:00 2012 +0100 - - Filter stuff that might end up in the shell - - Since it seems shells don't know how to filter stuff and might - causing bad things to happen - - poppler/Error.cc | 21 +++++++++++++++++---- - 1 file changed, 17 insertions(+), 4 deletions(-) - -commit c35d030472e6cb140c3dff30b91541772c992eb0 -Author: Albert Astals Cid -Date: Sat Dec 8 23:51:59 2012 +0100 - - Add private copy constructor and operator= to make sure we don't - use the default ones - - Since using them would results in bad things happening - - goo/GooHash.h | 16 ++++++++++++++++ - goo/GooList.h | 16 ++++++++++++++++ - goo/PNGWriter.h | 5 ++++- - goo/TiffWriter.h | 5 ++++- - goo/gfile.h | 4 ++++ - 5 files changed, 44 insertions(+), 2 deletions(-) - -commit f6741d9242bf2d9c13c8d534c50c8e4d404afc7f -Author: Adrian Johnson -Date: Sun Dec 2 09:34:35 2012 +1030 - - jpegwriter: move #include "jpeglib.h" into .cc file - - On cygwin pdftocairo -v shows the wrong version due to - jpeglib.h defining PACKAGE_VERSION. - - Avoid polluting our header files by moving libjpeg.h and - libjpeg types into JpegWriter.cc - - Bug 57687 - - goo/JpegWriter.cc | 120 - ++++++++++++++++++++++++++++++++----------------- - goo/JpegWriter.h | 25 ++++++----- - splash/SplashBitmap.cc | 2 +- - utils/pdftocairo.cc | 4 +- - 4 files changed, 95 insertions(+), 56 deletions(-) - -commit e78dbb1b7dbd20c3ae547b02270ab0648c1bfc61 -Author: Adrian Johnson -Date: Sun Dec 2 09:10:32 2012 +1030 - - Reformat goo/*Writer files to poppler style - - goo/ImgWriter.h | 20 ++--- - goo/JpegWriter.cc | 184 ++++++++++++++++++++++---------------------- - goo/JpegWriter.h | 38 ++++----- - goo/PNGWriter.cc | 224 - +++++++++++++++++++++++++++--------------------------- - goo/PNGWriter.h | 62 +++++++-------- - goo/TiffWriter.cc | 40 +++++----- - goo/TiffWriter.h | 58 +++++++------- - 7 files changed, 313 insertions(+), 313 deletions(-) - -commit 1bfe4b22cf893dd498d6f306ee9cf942c72fe3ed -Author: Matthias Kramm -Date: Mon Nov 19 12:39:56 2012 -0800 - - Fix linewidths in monochrome mode. - - For zoom levels that scale the page below sqrt(2) of the original - resolution, monochrome line widths were wrong (snapped back to 1 pixel - wide.) This patch fixes that issue. - - splash/Splash.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit e5008bdb26df0135edfbd30a811df2332f4e036c -Author: José Aliste -Date: Sat Dec 8 10:33:21 2012 -0300 - - glib-demo: Update the demo to modify flags of annotations - - https://bugs.freedesktop.org/show_bug.cgi?id=58015 - - glib/demo/annots.c | 65 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 65 insertions(+) - -commit 8cd5cae953de374276c11711dc106de15c8dcad0 -Author: Carlos Garcia Campos -Date: Sat Dec 8 18:57:07 2012 +0100 - - regtest: Use the number of cpus as default number of worker threads - - regtest/main.py | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -commit 605c363b04ba3853883010c0a413054fe246d9aa -Author: Carlos Garcia Campos -Date: Sat Dec 8 18:45:22 2012 +0100 - - regtest: Remove trailing whitespaces - - regtest/TestReferences.py | 10 +++++----- - regtest/TestRun.py | 10 +++++----- - regtest/main.py | 6 +++--- - 3 files changed, 13 insertions(+), 13 deletions(-) - -commit 787a8438708397f0a1bf26e93726f544c91533e6 -Author: Hib Eris -Date: Sun Dec 2 08:03:10 2012 +0100 - - Fix compile warning on deprecated conversion from string constant - - Fixes (for win32): - - CXX GlobalParams.lo - GlobalParams.cc: In function 'char* get_poppler_datadir()': - GlobalParams.cc:181:12: warning: deprecated conversion from string - constant to 'char*' [-Wwrite-strings] - - poppler/GlobalParams.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit cb3a10417ae659fdb7b77132c569c93ec00bc95e -Author: Fabio D'Urso -Date: Sun Dec 2 01:41:05 2012 +0100 - - Fixed check_lexer on 32-bit systems - - qt4/tests/check_lexer.cpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 8550576bdf74180b62f54f9fd59213fbcd0a1be1 -Author: José Aliste -Date: Sat Dec 8 10:33:04 2012 -0300 - - glib: Add poppler_annot_set_flags - - https://bugs.freedesktop.org/show_bug.cgi?id=58015 - - glib/poppler-annot.cc | 22 ++++++++++++++++++++++ - glib/poppler-annot.h | 2 ++ - 2 files changed, 24 insertions(+) - -commit 15dcc5426ce319429e1a2c518902effb2ddf06cf -Author: Adam Reichold -Date: Thu Dec 6 18:45:46 2012 +0100 - - implement parallel testing using Python's Queue class - - regtest/Printer.py | 36 +++++++++++++++++----------- - regtest/TestReferences.py | 23 +++++++++++++++++- - regtest/TestRun.py | 58 - ++++++++++++++++++++++++++++++++++++---------- - regtest/backends/cairo.py | 5 ++-- - regtest/backends/splash.py | 5 ++-- - regtest/main.py | 11 ++++++++- - 6 files changed, 104 insertions(+), 34 deletions(-) - -commit c46646020826136b403e9aae8e2ded24c7165522 -Author: Hib Eris -Date: Sun Dec 2 10:04:28 2012 +0100 - - glib-demo: Do not use deprecated gtk_color_button_{get,set}_rgba() - - Since Gtk 3.4, gtk_color_button_get_rgba() and - gtk_color_button_set_rgba() have been deprecated. - - https://bugs.freedesktop.org/show_bug.cgi?id=57798 - - glib/demo/selections.c | 16 ++++++++++++++++ - 1 file changed, 16 insertions(+) - -commit f8c1b55e764a6e79b0530fb1be9ee11917f4237e -Author: Albert Astals Cid -Date: Sat Dec 1 22:19:17 2012 +0100 - - 0.21.3 - - CMakeLists.txt | 4 ++-- - NEWS | 17 +++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 6 files changed, 23 insertions(+), 6 deletions(-) - -commit e3716d9d735a1093399a3c5c33ea5471a6adc405 -Author: Albert Astals Cid -Date: Sat Dec 1 22:34:00 2012 +0100 - - Build on make check correctly - - qt4/tests/check_goostring.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit c7ae96b162e8a05269a54c31f8e7c411edc84553 -Merge: 1f279c3 b1dacd1 -Author: Albert Astals Cid -Date: Sat Dec 1 21:26:24 2012 +0100 - - Merge commit 'b1dacd1e6ab00eb1976491eb2b45c76671011b38' - -commit 1f279c32dcdc899b509fc00aaa57382bc8af90f3 -Author: Albert Astals Cid -Date: Sat Dec 1 20:37:52 2012 +0100 - - Update copyrights - - poppler/CairoOutputDev.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 5daa17c013be8ebe180ff48207e189bd9bd50a84 -Author: Albert Astals Cid -Date: Sat Dec 1 20:06:17 2012 +0100 - - Initialize to NULL, fixes crash - - Since the TextStringToUCS4 not always assigns to second param, - initialize uni to NULL - - poppler/TextOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit f673be852e6564e039b5ec24e5bf583149b1d5a4 -Author: Jason Crain -Date: Sat Dec 1 20:03:00 2012 +0100 - - Allow large chars in TextPage - - poppler/TextOutputDev.cc | 1 - - 1 file changed, 1 deletion(-) - -commit aca122432951c4c0a2a5dbaba046d848f2153b84 -Author: Hib Eris -Date: Sat Jun 23 18:27:55 2012 +0200 - - Fix compile warning on unused variable filename_g - - glib/poppler-document.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit c702066961b1cc2a9c0fb16546e9db93c312813b -Author: Hib Eris -Date: Sat Jun 23 18:23:59 2012 +0200 - - Do not use 'size' uninitialized - - poppler/PDFDoc.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 14bdeacb0eb8e4a1d3995f310a1b526e4dcc96dc -Author: Hib Eris -Date: Sat Jun 23 18:09:01 2012 +0200 - - Fix compile warnings on deprecated conversion from string constant to - 'char*' - - poppler/FileSpec.cc | 3 ++- - poppler/GlobalParamsWin.cc | 4 ++-- - 2 files changed, 4 insertions(+), 3 deletions(-) - -commit 72d4a1ba998218de876e2a0e939bbec4b7795299 -Author: Hib Eris -Date: Sat Jun 23 17:52:13 2012 +0200 - - Fix compile warning on signed/unsigned comparison - - goo/gfile.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 1262111e70ff161e495505bd6a262cc0357a943c -Author: Hib Eris -Date: Sat Jun 23 17:46:54 2012 +0200 - - Remove unused variable - - goo/gfile.cc | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit 85572b85950ed4e4421f1e61e704e5c250ca27d9 -Author: Albert Astals Cid -Date: Sat Dec 1 01:50:25 2012 +0100 - - Silence gcc warning - - Bug #57572 - - goo/TiffWriter.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit a97aead193a927b91a4e33d7b5d2ba7179e664df -Author: Adrian Johnson -Date: Fri Nov 30 21:30:19 2012 +0100 - - Splash: Implement bilinear image scaling - - Bug #22138 - - poppler/SplashOutputDev.cc | 10 +-- - splash/Splash.cc | 183 - ++++++++++++++++++++++++++++++++++++++++++--- - splash/Splash.h | 13 +++- - 3 files changed, 188 insertions(+), 18 deletions(-) - -commit e6806d893a9a104e3f23d69d0245ad0e4948a409 -Author: Pino Toscano -Date: Wed Nov 28 17:59:36 2012 +0100 - - cmake: Enable compiler warnings for C code - - Compilation of glib/demo uses a C compiler, thus compiler warnings - should be enabled in the CFLAGS variable. - - followup of 5c5945d163fe406960ccc2e3a71882722b9e69d1 - - CMakeLists.txt | 2 ++ - 1 file changed, 2 insertions(+) - -commit bdb17da35de49b9fd1a549c3afd5e36004552080 -Author: Hib Eris -Date: Mon Nov 26 20:38:03 2012 +0100 - - cairo: Fix uninitaliazed warning in CairoOutputDev - - Fix warning: - - CXX CairoOutputDev.lo - ../../poppler/poppler/CairoOutputDev.cc: In member function 'virtual - void RescaleDrawImage::getRow(int, uint32_t*)': - ../../poppler/poppler/CairoOutputDev.cc:2813:25: warning: 'pix' - may be used uninitialized in this function [-Wuninitialized] - - https://bugs.freedesktop.org/show_bug.cgi?id=57571 - - poppler/CairoOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit beff044e4fdf44e80ad7c75255cb71a83e70a293 -Author: Hib Eris -Date: Tue Nov 27 22:19:01 2012 +0100 - - glib-demo: Fix warning on signedness - - Fixes: - - CC attachments.o - ../../../poppler/glib/demo/attachments.c: In function - ‘attachment_save_callback’: - ../../../poppler/glib/demo/attachments.c:190:2: warning: pointer - targets in passing argument 2 of ‘g_checksum_update’ differ in - signedness [-Wpointer-sign] - /usr/include/glib-2.0/glib/gchecksum.h:69:23: note: expected ‘const - guchar *’ but argument is of type ‘const gchar *’ - - https://bugs.freedesktop.org/show_bug.cgi?id=57620 - - glib/demo/attachments.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit b484749ffa58315e4b61738d652347d7a77da982 -Author: Hib Eris -Date: Tue Nov 27 19:38:59 2012 +0100 - - glib-demo: Fix set but unused warning - - Fixes: - - CC print.o - ../../../poppler/glib/demo/print.c: In function - ‘pgd_print_draw_page’: - ../../../poppler/glib/demo/print.c:68:27: warning: variable - ‘settings’ set but not used [-Wunused-but-set-variable] - - https://bugs.freedesktop.org/show_bug.cgi?id=57620 - - glib/demo/print.c | 9 ++++++--- - 1 file changed, 6 insertions(+), 3 deletions(-) - -commit 8438daf7bf7ab1b96c6899baab7e47d9c634cb3d -Author: Hib Eris -Date: Sun Jun 24 14:54:31 2012 +0200 - - glib-demo: pgd_text_view_query_tooltip(): return a gboolean - - https://bugs.freedesktop.org/show_bug.cgi?id=57620 - - glib/demo/text.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit ff9e211cfb60eb820b9b046da546352fa59d7df9 -Author: Hib Eris -Date: Sat Jun 23 22:56:02 2012 +0200 - - glib-demo: Remove set but unused variable textinfo - - https://bugs.freedesktop.org/show_bug.cgi?id=57620 - - glib/demo/text.c | 2 -- - 1 file changed, 2 deletions(-) - -commit 8e5ae33bc63eca5297dea12fc281ba223f5be09a -Author: Hib Eris -Date: Sat Jun 23 22:44:22 2012 +0200 - - glib-demo: Fix warning "operation on 'page' may be undefined - [-Wsequence-point]" - - https://bugs.freedesktop.org/show_bug.cgi?id=57620 - - glib/demo/text.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit c6f98d62b885e1d7f6ce1f265d4a87dca36494de -Author: Hib Eris -Date: Sat Jun 23 22:38:35 2012 +0200 - - glib-demo: Remove unused variable slice_selector - - https://bugs.freedesktop.org/show_bug.cgi?id=57620 - - glib/demo/render.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit da56d280e2a51229c93117d8b537897ba63296cf -Author: Hib Eris -Date: Sat Jun 23 22:36:29 2012 +0200 - - glib-demo: Remove unused variable region - - https://bugs.freedesktop.org/show_bug.cgi?id=57620 - - glib/demo/selections.c | 1 - - 1 file changed, 1 deletion(-) - -commit c792e59064018e0fd899f32080489419517f2bbe -Author: Hib Eris -Date: Sat Jun 23 22:34:44 2012 +0200 - - glib-demo: Do not use 'text' uninitialized - - https://bugs.freedesktop.org/show_bug.cgi?id=57620 - - glib/demo/utils.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit c5a8f7eda14030436e6905dd826e72cabbcf0e5f -Author: Hib Eris -Date: Sat Jun 23 22:26:53 2012 +0200 - - glib-demo: Fix warning on unused variable selection - - https://bugs.freedesktop.org/show_bug.cgi?id=57620 - - glib/demo/layers.c | 1 - - 1 file changed, 1 deletion(-) - -commit 4ceb3f4f4ca0092e79bb36723a7332b071491666 -Author: Hib Eris -Date: Sat Jun 23 18:36:12 2012 +0200 - - glib-demo: Fix warnings on unused variables - - https://bugs.freedesktop.org/show_bug.cgi?id=57620 - - glib/demo/annots.c | 4 +--- - 1 file changed, 1 insertion(+), 3 deletions(-) - -commit 5c5945d163fe406960ccc2e3a71882722b9e69d1 -Author: Hib Eris -Date: Tue Nov 27 19:21:34 2012 +0100 - - Enable compiler warnings for C code - - Compilation of glib/demo uses a C compiler, thus compiler warnings - should be enabled in the CFLAGS variable. - - configure.ac | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 55940e989701eb9118015e30f4f48eb654fa34c4 -Author: Pino Toscano -Date: Tue Nov 27 16:05:15 2012 +0100 - - fix my previous GooString::insert fix - - we need only to move the characters after the specified position, - not all of them - - extend qt4's check_goostring with few more checks covering this - (and the previous) fix - - goo/GooString.cc | 2 +- - qt4/tests/check_goostring.cpp | 39 - +++++++++++++++++++++++++++++++++++++++ - 2 files changed, 40 insertions(+), 1 deletion(-) - -commit dcbc9686d97f4f6596c43d1f701207278c25f8eb -Author: Pino Toscano -Date: Mon Nov 26 14:44:21 2012 +0100 - - glib/cmake: Include Gio-2.0 for introspection - - Fixes g-ir-scanner warnings: - poppler-document.cc:257: Warning: Poppler: - poppler_document_new_from_stream: argument stream: Unresolved type: - 'GInputStream*' - poppler-document.cc:257: Warning: Poppler: - poppler_document_new_from_stream: argument cancellable: Unresolved - type: 'GCancellable*' - poppler-document.cc:315: Warning: Poppler: - poppler_document_new_from_gfile: argument file: Unresolved type: - 'GFile*' - poppler-document.cc:315: Warning: Poppler: - poppler_document_new_from_gfile: argument cancellable: Unresolved - type: 'GCancellable*' - - https://bugs.freedesktop.org/show_bug.cgi?id=56218 - - folloup of c84753e12029fcc6113f80dedc9a943ce1deb214 - - glib/CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 169e4cb001fa235ca608d3d0b42ea4214161fc2d -Author: Pino Toscano -Date: Mon Nov 26 14:42:59 2012 +0100 - - glib/cmake: Show all suppressed introspection scanner warnings - - https://bugs.freedesktop.org/show_bug.cgi?id=56218 - - followup of 11a1f6f512a7d7b86defeb5963fa16bc08e3ba1c - - glib/CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 62c0dbbe9f1987c78eeb87f248d35e7fd73e968a -Author: Albert Astals Cid -Date: Mon Nov 26 00:40:57 2012 +0100 - - Check GooString::insert - - Checks we don't break what we just fixed with Pino's patch - - qt4/tests/CMakeLists.txt | 1 + - qt4/tests/Makefile.am | 7 ++++++- - qt4/tests/check_goostring.cpp | 22 ++++++++++++++++++++++ - 3 files changed, 29 insertions(+), 1 deletion(-) - -commit 01e438ca47776075c8171bda090e7d859fd9f620 -Author: Adam Reichold -Date: Mon Nov 26 00:39:05 2012 +0100 - - Don't use memcpy to copy classes - - poppler/Function.cc | 63 - +++++++++++++++++++++++++++++++++++++++++++---------- - poppler/Function.h | 11 ++++++---- - 2 files changed, 59 insertions(+), 15 deletions(-) - -commit 7ba15d11e56175601104d125d5e4a47619c224bf -Author: Pino Toscano -Date: Mon Nov 26 00:29:35 2012 +0100 - - fix GooString::insert() - - Hi, - - as reported in a Debian bug [1], it seems GooString::insert could lead - to using uninitialized memory. - The case is a simple: - GooString goo; - goo.insert(0, "."); - goo.insert(0, "This is a very long long test string"); - i.e. basically first insert a single character at position 0, and - then a - string longer than STR_STATIC_SIZE always at position 0. - - [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=693817 - - goo/GooString.cc | 5 ++--- - 1 file changed, 2 insertions(+), 3 deletions(-) - -commit 703f85a10cf7ad61d2f2d3a5faf347fdddcb4738 -Author: Carlos Garcia Campos -Date: Sun Nov 25 12:36:33 2012 +0100 - - glib: Fix returns tag in PopplerAttachmentSaveFunc api doc - - glib/poppler-attachment.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 52896031783b28cee350ea92c8736e2c2e4e9d33 -Author: José Aliste -Date: Mon Nov 19 23:47:19 2012 +0100 - - glib: Add missing ":" at the end of some functions documentation - - New versions of gir-scanner emit a warning when the : at - the end of the function documentation is not found. - - https://bugs.freedesktop.org/show_bug.cgi?id=56218 - - glib/poppler-annot.cc | 2 +- - glib/poppler-form-field.cc | 10 +++++----- - glib/poppler-layer.cc | 12 ++++++------ - 3 files changed, 12 insertions(+), 12 deletions(-) - -commit 60dfc1a3471f824f40b0bef5b97a7b04bd78e72b -Author: Hib Eris -Date: Sat Oct 20 10:17:01 2012 +0200 - - glib: Exclude poppler-input-stream.h from introspection files - - Fixes warning: - - poppler-input-stream.h:28: Warning: Poppler: - symbol='inputStreamBufSize': Unknown namespace for symbol - 'inputStreamBufSize' - - https://bugs.freedesktop.org/show_bug.cgi?id=56218 - - glib/Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit c84753e12029fcc6113f80dedc9a943ce1deb214 -Author: Hib Eris -Date: Sat Oct 20 09:40:09 2012 +0200 - - glib: Include Gio-2.0 for introspection - - Fixes g-ir-scanner warnings: - poppler-document.cc:257: Warning: Poppler: - poppler_document_new_from_stream: argument stream: Unresolved type: - 'GInputStream*' - poppler-document.cc:257: Warning: Poppler: - poppler_document_new_from_stream: argument cancellable: Unresolved - type: 'GCancellable*' - poppler-document.cc:315: Warning: Poppler: - poppler_document_new_from_gfile: argument file: Unresolved type: - 'GFile*' - poppler-document.cc:315: Warning: Poppler: - poppler_document_new_from_gfile: argument cancellable: Unresolved - type: 'GCancellable*' - - https://bugs.freedesktop.org/show_bug.cgi?id=56218 - - glib/Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 11a1f6f512a7d7b86defeb5963fa16bc08e3ba1c -Author: Hib Eris -Date: Sat Oct 20 09:30:05 2012 +0200 - - glib: Show all suppressed introspection scanner warnings - - https://bugs.freedesktop.org/show_bug.cgi?id=56218 - - glib/Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 16812829a7d4816717731318b1aa1bc3ab5e3935 -Author: Jason Crain -Date: Mon Aug 27 22:42:11 2012 -0500 - - Update fill and stroke color in CairoOutputDev::startPage - - Keep fill_color and stroke_color from falling out of sync with - fill_pattern and stroke_pattern. - - https://bugs.freedesktop.org/show_bug.cgi?id=54526 - - glib/poppler-page.cc | 2 +- - poppler/CairoOutputDev.cc | 2 ++ - 2 files changed, 3 insertions(+), 1 deletion(-) - -commit c93702bea0718d67660f2255344dcf9b0f502d57 -Author: José Aliste -Date: Tue Nov 20 11:25:41 2012 +0100 - - glib: Ensure text is only computed on first render - - Getting the text on a page could be quite slow on - complex pages without structured text. Before this patch, - poppler_page_render would reprocess the text each time - is called. - - glib/poppler-page.cc | 9 ++++----- - 1 file changed, 4 insertions(+), 5 deletions(-) - -commit b0297110c455eb18096268b59d6095d428380de5 -Author: Jason Crain -Date: Wed Nov 21 14:15:59 2012 -0600 - - glib: check if words end with spaces - - poppler_page_get_text_layout and poppler_page_get_text_attributes - assume that each word ends with a space or newline, causing them to - become mismatched from the text. This adds a check to - TextWord::getSpaceAfter. - - https://bugs.freedesktop.org/show_bug.cgi?id=54504 - - glib/poppler-page.cc | 62 - +++++++++++++++++++++++++++++----------------------- - 1 file changed, 35 insertions(+), 27 deletions(-) - -commit b1dacd1e6ab00eb1976491eb2b45c76671011b38 -Author: Albert Astals Cid -Date: Fri Nov 23 00:12:24 2012 +0100 - - 0.21.2 - - CMakeLists.txt | 4 ++-- - NEWS | 13 +++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 6 files changed, 19 insertions(+), 6 deletions(-) - -commit 2d2a3af7159945c3fd54f22878e2eb09e019bbc6 -Author: Albert Astals Cid -Date: Fri Nov 23 00:06:39 2012 +0100 - - Update copyrights - - goo/TiffWriter.cc | 1 + - goo/TiffWriter.h | 1 + - poppler/CairoRescaleBox.cc | 1 + - poppler/CairoRescaleBox.h | 38 ++++++++++++++++++++++++++++++++++++++ - splash/SplashBitmap.cc | 2 +- - 5 files changed, 42 insertions(+), 1 deletion(-) - -commit e0d0177562ff546b59b3bc8eb68a08dc740d6f6c -Author: Adrian Johnson -Date: Wed Nov 14 22:44:20 2012 +1030 - - cairo: Fix crash in CairoImageOutputDev with setSoftMaskFromImageMask - - Bug 57067 - - poppler/CairoOutputDev.cc | 46 - ++++++++++++++++++++++++++++++++++++++++++++++ - poppler/CairoOutputDev.h | 5 +++++ - 2 files changed, 51 insertions(+) - -commit f050717f986a6c2833876d14083363a540fa849a -Author: Adrian Johnson -Date: Wed Nov 14 23:50:10 2012 +1030 - - cairo: fix soft mask when image resolution != smask resolution - - Both image and mask are drawn the same size (unit square) regardless - of the size of the image data. - - Bug 57070 - - poppler/CairoOutputDev.cc | 12 +++--------- - 1 file changed, 3 insertions(+), 9 deletions(-) - -commit 87fd5275514b63f13622b79a8fcfe443ccc4f45d -Author: Adrian Johnson -Date: Sun Nov 11 18:53:12 2012 +1030 - - cairo: make drawImage work with images > 32767 in width/height - - Cairo images are limited to 32767 in width and height due to the - 16.16 format used by pixman. Make drawImage work with large images - by scaling down the image before a cairo image is created. - - CairoRescaleBox.cc has been turned into a class with a virtual - function to get the next row of the source image. This allows the - rescale code to access the source data one row at a time to avoid - needing to allocate an image the size of the source image. - - A RescaleDrawImage class derived from CairoRescaleBox has been - written to create the cairo source image to be used by drawImage. The - code from drawImage that created the cairo source image has been moved - into RescaleDrawImage::getSourceImage and RescaleDrawImage::getRow. - - Bug 56858 - - poppler/CairoOutputDev.cc | 278 - ++++++++++++++++++++++++--------------------- - poppler/CairoRescaleBox.cc | 177 +++++++++++++++-------------- - poppler/CairoRescaleBox.h | 21 +++- - 3 files changed, 258 insertions(+), 218 deletions(-) - -commit d1c509c48fc422649d0c2c2d70af5e13e3472874 -Author: Adrian Johnson -Date: Sat Nov 17 10:04:55 2012 +1030 - - pdftocairo: add tiff support - - Bug 57006 - - utils/pdftocairo.1 | 23 ++++++++------ - utils/pdftocairo.cc | 88 - +++++++++++++++++++++++++++++++++++++++++------------ - 2 files changed, 83 insertions(+), 28 deletions(-) - -commit 6d3fe48cf30b298b4436462904d781ea441c1f3d -Author: Adrian Johnson -Date: Sat Nov 17 10:03:22 2012 +1030 - - tiff: remove splash dependency and add RGBA support - - Bug 57006 - - goo/TiffWriter.cc | 47 - +++++++++++++++++++---------------------------- - goo/TiffWriter.h | 13 ++++++++++--- - splash/SplashBitmap.cc | 23 +++++++++++++++++++++-- - 3 files changed, 50 insertions(+), 33 deletions(-) - -commit 15f600a5702788f7e5b91cd67bc2438179921939 -Author: Albert Astals Cid -Date: Thu Nov 15 22:17:27 2012 +0100 - - Don't do a check for sanity that then we don't use - - Fixes bugs 56753 and 51684 - - fofi/FoFiTrueType.cc | 26 -------------------------- - 1 file changed, 26 deletions(-) - -commit c7e3c2d7087e4fc36564ba7bd55e27e100e0a5e5 -Author: Albert Astals Cid -Date: Wed Nov 14 14:58:45 2012 +0100 - - Remove unused code - - fofi/FoFiTrueType.cc | 658 - ------------------------------------------- - fofi/FoFiTrueType.h | 11 +- - splash/SplashFTFontEngine.cc | 42 +-- - 3 files changed, 2 insertions(+), 709 deletions(-) - -commit 06951f529e6514a0c26d6d821ab5fab0920a7cf3 -Author: Albert Astals Cid -Date: Tue Nov 13 23:37:22 2012 +0100 - - Simplify >= 0 ifs for unsigned - - cpp/poppler-global.cpp | 8 ++------ - 1 file changed, 2 insertions(+), 6 deletions(-) - -commit fa813adc3f7b7ee3cc819f1e0cb85e01f13c2c01 -Author: Albert Astals Cid -Date: Tue Nov 13 23:37:01 2012 +0100 - - Remove < 0 ifs for unsigned - - splash/SplashFTFont.cc | 8 -------- - 1 file changed, 8 deletions(-) - -commit 1969bcd693289eba1138fcaa74a684cb3ff2aefc -Author: Albert Astals Cid -Date: Tue Nov 13 23:36:40 2012 +0100 - - Remove unused members - - poppler/Gfx.cc | 3 --- - poppler/Gfx.h | 5 +---- - 2 files changed, 1 insertion(+), 7 deletions(-) - -commit 3a6e5ed5e28b6113696a7ae60b0b85d7097eb731 -Author: Albert Astals Cid -Date: Tue Nov 13 23:35:53 2012 +0100 - - Remove >= 0 checks for unsigned variables - - utils/HtmlFonts.cc | 6 +++--- - utils/HtmlFonts.h | 4 ++-- - 2 files changed, 5 insertions(+), 5 deletions(-) - -commit 0dcc2d711810dd64aa8d8721ce53a6b72e12c47c -Author: Albert Astals Cid -Date: Tue Nov 13 23:35:10 2012 +0100 - - Remove unused var - - utils/pdfinfo.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 1fc97862d30bf723135310bfc8701e6788bfd284 -Author: Albert Astals Cid -Date: Tue Nov 13 23:24:19 2012 +0100 - - size can't be smaller than 0 because it's a size_t - - goo/gmem.cc | 22 +--------------------- - 1 file changed, 1 insertion(+), 21 deletions(-) - -commit bb801a9b889bc0e62cf8b853c26cc6636b4af9a1 -Author: Albert Astals Cid -Date: Tue Nov 13 22:51:17 2012 +0100 - - Removed unused var - - utils/pdfinfo.cc | 1 - - 1 file changed, 1 deletion(-) - -commit fd651fb49653e89d96b032e010a7d8e891536bb0 -Author: Albert Astals Cid -Date: Mon Nov 12 00:42:49 2012 +0100 - - Parse the args (so that -v says vesion only) - - Fixes bug #56817 - - utils/pdfunite.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit 7e2e9567f51d01be9a88848e1141c6d4f0f768a1 -Author: Albert Astals Cid -Date: Fri Nov 9 20:02:25 2012 +0100 - - 0.21.1 - - CMakeLists.txt | 4 ++-- - NEWS | 14 ++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/CMakeLists.txt | 2 +- - qt4/src/Doxyfile | 2 +- - qt4/src/Makefile.am | 2 +- - 8 files changed, 22 insertions(+), 8 deletions(-) - -commit 98b7cfd289abb53a745a88d6ec99e95df477fc8f -Merge: 40efa72 d254174 -Author: Albert Astals Cid -Date: Fri Nov 9 00:38:19 2012 +0100 - - Merge remote-tracking branch 'origin/poppler-0.20' - - Conflicts: - poppler/Form.cc - -commit 40efa72987ebf62cbf2c761c10a209e2e6be612e -Author: Fabio D'Urso -Date: Sun Nov 4 11:20:29 2012 +0100 - - Replaced forward declaration of enum CryptAlgorithm with a proper - #include - - Forward-declaring enums is illegal. It hasn't caused problems so far - because XRef.h includes Object.h, which in turn includes Stream.h, - where - the enum is defined. - Therefore, enum is alreadly defined when the compiler reaches - that line. - - To avoid future issues, I've replaced it with a proper #include - "Stream.h" - (which expands to nothing as Stream.h has already been included - at that - point). - - I've also added a #include in XRef.h because it references enum - CryptAlgorithm too. Also in this case, it expands to nothing. - - poppler/PDFDoc.h | 2 +- - poppler/XRef.h | 1 + - 2 files changed, 2 insertions(+), 1 deletion(-) - -commit 0f7c17d7f92d4cdfbd8816dba666aeed924d8bc2 -Author: Fabio D'Urso -Date: Fri Nov 2 10:54:17 2012 +0100 - - qt4: Export information about the document form type - - This patch also wraps the code that checks the form type and moves it - from pdfinfo to the Catalog class. - - poppler/Catalog.cc | 19 +++++++++++++++++++ - poppler/Catalog.h | 9 +++++++++ - qt4/src/poppler-document.cc | 16 ++++++++++++++++ - qt4/src/poppler-qt4.h | 18 ++++++++++++++++++ - utils/pdfinfo.cc | 19 ++++++++++--------- - 5 files changed, 72 insertions(+), 9 deletions(-) - -commit f3f5a166bcd16b6f2cb516cceb2b3f41b6faf0b4 -Author: Fabio D'Urso -Date: Fri Nov 2 01:53:24 2012 +0100 - - Editable FormFieldChoice: Clear editedChoice when one of the - predefined option is selected - - This patch clears the user-entered text when the user interacts with - predefined options. - - poppler/Form.cc | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -commit ddcd5dc0ceecc02f0d4f740cb6c9b557dfd33c74 -Author: Fabio D'Urso -Date: Thu Nov 1 00:58:51 2012 +0100 - - FormFieldChoice ctor: Added support to recognize user strings as - /V value - - Fixes - http://lists.freedesktop.org/archives/poppler/2012-October/009688.html - - poppler/Form.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 1302bf52bba7e6446f01358240a4b5b583e196a9 -Author: Fabio D'Urso -Date: Wed Oct 31 19:56:37 2012 +0100 - - FormFieldChoice ctor: Stop scanning if /V is a string and the - corresponding option has been identified - - poppler/Form.cc | 11 +++++++++-- - 1 file changed, 9 insertions(+), 2 deletions(-) - -commit d254174e08146115ad04ac1f1bf82bb26e56c684 -Author: Fabio D'Urso -Date: Wed Oct 31 16:57:56 2012 +0100 - - FormFieldChoice::updateSelection: Fixed wrong loop condition - - poppler/Form.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 401de95f5ab42ab0f5d8fd92d76b5def50f84a2b -Author: Fabio D'Urso -Date: Wed Oct 31 19:43:51 2012 +0100 - - FormFieldChoice ctor: Look for selected options in /I instead of /V - if /I is available - - Since /I stores the indices of the selected options, it can - distinguish - duplicate option (i.e. options with the same name/export value). - - poppler/Form.cc | 71 - ++++++++++++++++++++++++++++++++++----------------------- - 1 file changed, 42 insertions(+), 29 deletions(-) - -commit cfd3a46a857100cb634e18192b762e7342165348 -Author: Fabio D'Urso -Date: Wed Oct 31 15:44:32 2012 +0100 - - FormFieldChoice: Handle /V values containing the export value instead - of the option name - - According to the PDF spec, /V should always contain an "option - name" and - never an "export value" if /Opt is an array of couples. However, it - seems that acroread works the other way round: it is able to identify - selected options only if they are referred by their export value - instead of the option name. - With this patch, we mimic this behavior. - - poppler/Form.cc | 49 ++++++++++++++++++++++++++++++++++--------------- - 1 file changed, 34 insertions(+), 15 deletions(-) - -commit ce99940bcac0447f32ee2ad46efb09af93989c12 -Author: Fabio D'Urso -Date: Sat Oct 13 00:13:33 2012 +0200 - - FormFieldChoice::updateSelection: Write /I too - - This improves handling of choice fields containing two or more entries - with the same name, and also makes sure that the previous value of /I - gets updated (failing to update it results in acroread still showing - the old selection). - - poppler/Form.cc | 50 ++++++++++++++++++++++++++++++++++++-------------- - 1 file changed, 36 insertions(+), 14 deletions(-) - -commit 102553e2104a1b223c8ac924aa6702829adebbdb -Author: Fabio D'Urso -Date: Wed Oct 31 16:57:56 2012 +0100 - - FormFieldChoice::updateSelection: Fixed wrong loop condition - - poppler/Form.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit d7522ea1d2e66beef64f705e8986142f15fcf613 -Author: Fabio D'Urso -Date: Wed Oct 31 15:26:37 2012 +0100 - - FormFieldChoice ctor: Don't convert "human-readable" option names - to unicode - - Despite that comment, they're not meant to be read by humans only, - but they - are also used as option identifiers. - - This patch stops poppler from forcing them to be unicode. Instead, - they now stay the same encoding as their corresponding /Opt entry. - - This fixes poppler not being able to recognize selected entries - in documents produced by poppler itself: previously, the /V value was - always written in Unicode encoding, and therefore it was very - often not - binary-equal to the corresponding /Opt entry. - Now the /V value is always binary-equal to the corresponding /Opt - entry. - - poppler/Form.cc | 16 +--------------- - 1 file changed, 1 insertion(+), 15 deletions(-) - -commit da08ebeee241198907378c6461721fddb5106875 -Author: Adrian Johnson -Date: Sun Oct 28 12:13:22 2012 +1030 - - Don't allow invalid unicode to be passed to backends - - poppler/CharCodeToUnicode.cc | 11 +++++++++-- - poppler/UTF.cc | 11 +++++++++++ - poppler/UTF.h | 4 ++++ - 3 files changed, 24 insertions(+), 2 deletions(-) - -commit 9f92feda5eff9b2542c64349f33ae3cf250e7f4b -Author: Thomas Freitag -Date: Fri Nov 2 23:05:55 2012 +0100 - - Memory leak in CharCodeToUnicode - - Bug #54702 - - poppler/CharCodeToUnicode.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit ef11b4f0e642dff0be02bf3327eb56bf0b364847 -Author: Thomas Freitag -Date: Fri Nov 2 22:44:27 2012 +0100 - - Implement overprint in qt interface - - With minor api fixes by me (Albert Astals Cid) - - qt4/src/poppler-document.cc | 23 ++++++++++++--- - qt4/src/poppler-page.cc | 38 +++++++++++++----------- - qt4/src/poppler-private.h | 69 - ++++++++++++++++++++++++++++---------------- - qt4/src/poppler-qt4.h | 11 ++++++- - splash/SplashBitmap.cc | 70 - +++++++++++++++++++++++++++++++++++++++++++++ - splash/SplashBitmap.h | 5 +++- - 6 files changed, 169 insertions(+), 47 deletions(-) - -commit ae8fc0cbfc6123189e17b3cf1286e0540f181646 -Author: Adrian Johnson -Date: Tue Oct 30 21:22:04 2012 +1030 - - cairo: support parameterized Gouraud shading - - Bug 56463 - - poppler/CairoOutputDev.cc | 19 +++++++++++++++---- - 1 file changed, 15 insertions(+), 4 deletions(-) - -commit 3be4e835d765f2f060e2a2e07dd23905c3212cdd -Author: Pino Toscano -Date: Wed Oct 24 18:37:06 2012 +0200 - - dos2unix - - utils/pdftoppm.cc | 876 - +++++++++++++++++++++++++++--------------------------- - 1 file changed, 438 insertions(+), 438 deletions(-) - -commit 77a980472e76b568346a49057b0217111a14a4cd -Merge: 74d6217 46fb365 -Author: Albert Astals Cid -Date: Tue Oct 23 00:23:53 2012 +0200 - - Merge remote-tracking branch 'origin/poppler-0.20' - -commit 46fb3653c7ae44c34d12d799df8f70d649eaa995 -Author: Albert Astals Cid -Date: Tue Oct 23 00:22:55 2012 +0200 - - Fix the or-ing of flags - - qt4/src/poppler-document.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 74d6217ba164fdfe263b4edac8047b60506e39a6 -Author: Carlos Garcia Campos -Date: Sun Oct 21 17:48:57 2012 +0200 - - regstest: Add print_test_result_ln() and use it for failed test - results - - To make sure they are always shown. - - regtest/Printer.py | 3 +++ - regtest/TestRun.py | 10 +++++----- - 2 files changed, 8 insertions(+), 5 deletions(-) - -commit 4e9b8d2cca44241a501bb8095b3980d17fcda6c5 -Author: Carlos Garcia Campos -Date: Sun Oct 21 17:48:22 2012 +0200 - - regtest: Do not rewrite lines in verbose mode - - regtest/Printer.py | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 2a25264afe3c59931f6a3638e2d6c6c2e0e5dfba -Author: Albert Astals Cid -Date: Fri Oct 19 17:22:56 2012 +0200 - - make static - - because i can - - qt4/tests/check_fonts.cpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit bc4a54c0a4430216c9aeaf2c3bddbaeef5a004e4 -Author: Albert Astals Cid -Date: Fri Oct 19 17:22:13 2012 +0200 - - Compile with clang - - qt4/tests/check_fonts.cpp | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit f38194cfae8f8690bc3767cbdcf140519564366c -Merge: 80cf434 5312984 -Author: Albert Astals Cid -Date: Fri Oct 19 00:02:02 2012 +0200 - - Merge remote-tracking branch 'origin/poppler-0.20' - -commit 5312984b40355b067001704e9c688ea0a72b1159 -Author: Albert Astals Cid -Date: Fri Oct 19 00:00:53 2012 +0200 - - Define the numbers a bit better so gcc in i386 understands them better - - qt4/tests/check_lexer.cpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 80cf43472e5913f5f64bf73cb4a8ac5a53063f2e -Author: Adam Reichold -Date: Wed Oct 17 08:27:13 2012 +0200 - - added accessors for FormWidgetChoice::editChoice property to qt4 - frontend - - qt4/src/poppler-form.cc | 23 +++++++++++++++++++++++ - qt4/src/poppler-form.h | 15 +++++++++++++++ - 2 files changed, 38 insertions(+) - -commit 0b3ff2dc4e1ba37dd66f5913b10a9d69e31c40ce -Merge: fb5cb0f 528b64b -Author: Albert Astals Cid -Date: Wed Oct 17 00:28:40 2012 +0200 - - Merge remote-tracking branch 'origin/poppler-0.20' - - Conflicts: - CMakeLists.txt - NEWS - configure.ac - cpp/Doxyfile - poppler/Annot.cc - poppler/Form.h - qt4/src/Doxyfile - -commit 528b64bb077ed37c0d8fc7ae2ef3dc2c0dbb26ca -Author: Fabio D'Urso -Date: Tue Sep 4 23:10:17 2012 +0200 - - Free entries in the xref form a linked list: terminate it properly - when writing the XRef - - The last entry must point back to object 0. Previously it was left - unitialized and resulted in "-000000001 00000 f" being written in the - XRef table. - - poppler/XRef.cc | 1 + - 1 file changed, 1 insertion(+) - -commit fb5cb0fbdfcd06556661b38b0c598922fff2d759 -Author: Fabio D'Urso -Date: Thu Oct 4 11:20:42 2012 +0200 - - Create the 24x24 rectangle for text annotation icons from the top-left - corner instead of bottom-left - - poppler/Annot.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 35c07fe40d7b18e19f6ef0f5615f9f5ac8195cf7 -Author: Fabio D'Urso -Date: Tue Oct 9 15:24:02 2012 +0200 - - AnnotWidget: Avoid repeatedly deleting and creating xref entries - for appearance streams - - Previously updating the appearance stream always involved deleting - the old - stream's xref entry and creating a new one. - Since xref entry deletion causes the generation number to be - incremented, this - behavior caused the generation number to quickly rise during user - input. - - This patch stops it by reusing the same entry as the old appearance - stream in - case of repeated modifications. - - poppler/Annot.cc | 40 ++++++++++++++++++++++++++++------------ - poppler/Annot.h | 1 + - 2 files changed, 29 insertions(+), 12 deletions(-) - -commit 2127a977bbe9985aa58561116508ad4f08430a2c -Author: Fabio D'Urso -Date: Tue Oct 9 12:49:26 2012 +0200 - - Generate and write the appearance stream in - AnnotWidget::updateWidgetApperance() - - Note: At the moment the old appearance is deleted and a *new* xref - entry is - created every time AnnotWidget::updateWidgetApperance() is called. - - poppler/Annot.cc | 30 +++++++++++++++++++++++++----- - 1 file changed, 25 insertions(+), 5 deletions(-) - -commit 0446e2cc1073f4579a90284d28bc5872e46e0536 -Author: Fabio D'Urso -Date: Tue Oct 9 10:47:40 2012 +0200 - - Killed FormField::isModified() in favor of a new AnnotWidget callback - - Instead of having to ask FormField from AnnotWidget::draw if the - widget's appearance needs to be rebuilt, now AnnotWidget gets notified - of changes via the new AnnotWidget::updateAppearanceStream() callback. - - poppler/Annot.cc | 16 ++++++++++------ - poppler/Annot.h | 1 + - poppler/Form.cc | 52 - ++++++++++++++++++++++++++++++++++++++-------------- - poppler/Form.h | 12 +++++++++--- - 4 files changed, 58 insertions(+), 23 deletions(-) - -commit 68d732ab2d55ae15e194ececfffa753977fae84c -Author: Fabio D'Urso -Date: Tue Oct 9 15:24:02 2012 +0200 - - AnnotWidget: Avoid repeatedly deleting and creating xref entries - for appearance streams - - Previously updating the appearance stream always involved deleting - the old - stream's xref entry and creating a new one. - Since xref entry deletion causes the generation number to be - incremented, this - behavior caused the generation number to quickly rise during user - input. - - This patch stops it by reusing the same entry as the old appearance - stream in - case of repeated modifications. - - poppler/Annot.cc | 40 ++++++++++++++++++++++++++++------------ - poppler/Annot.h | 1 + - 2 files changed, 29 insertions(+), 12 deletions(-) - -commit e2993cc9551dc7521528904646f941c9747473f7 -Author: Fabio D'Urso -Date: Tue Oct 9 12:49:26 2012 +0200 - - Generate and write the appearance stream in - AnnotWidget::updateWidgetApperance() - - Note: At the moment the old appearance is deleted and a *new* xref - entry is - created every time AnnotWidget::updateWidgetApperance() is called. - - poppler/Annot.cc | 30 +++++++++++++++++++++++++----- - 1 file changed, 25 insertions(+), 5 deletions(-) - -commit df924493922e8c0f7b1e19c2847d33b28a098913 -Author: Fabio D'Urso -Date: Tue Oct 9 10:47:40 2012 +0200 - - Killed FormField::isModified() in favor of a new AnnotWidget callback - - Instead of having to ask FormField from AnnotWidget::draw if the - widget's appearance needs to be rebuilt, now AnnotWidget gets notified - of changes via the new AnnotWidget::updateAppearanceStream() callback. - - poppler/Annot.cc | 16 ++++++++++------ - poppler/Annot.h | 1 + - poppler/Form.cc | 52 - ++++++++++++++++++++++++++++++++++++++-------------- - poppler/Form.h | 12 +++++++++--- - 4 files changed, 58 insertions(+), 23 deletions(-) - -commit 0a5bda01ace9f8576d687c5a28feb5cf09b48a92 -Author: Albert Astals Cid -Date: Sun Oct 14 23:05:27 2012 +0200 - - New/old header for cmake buildsystem - - CMakeLists.txt | 1 + - 1 file changed, 1 insertion(+) - -commit 6d46f0b477143eb0df09f718e96dd2ff2a7dd61b -Author: Hib Eris -Date: Sat Sep 22 20:50:07 2012 +0200 - - Split our UTF.h into xpdf based UTF8.h and a poppler specific UTF.h - - poppler/GlobalParams.cc | 2 +- - poppler/Makefile.am | 1 + - poppler/UTF.h | 79 - +--------------------------------------------- - poppler/UTF8.h | 84 - +++++++++++++++++++++++++++++++++++++++++++++++++ - 4 files changed, 87 insertions(+), 79 deletions(-) - -commit 03cbba935c90ce9a6d9ad44f7cda4901c2f81f2e -Author: Hib Eris -Date: Sat Sep 22 19:58:40 2012 +0200 - - Do not use mapUTF8() directly in CairoOutputDev - - poppler/CairoOutputDev.cc | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -commit f219bdbcadcb0334d595bbd9afd01f00c37d1978 -Author: Hib Eris -Date: Sun Oct 14 22:59:55 2012 +0200 - - Make sure array index is >= 0 - - Fixes this warning on array subscript type: - UTF.cc: In function 'int TextStringToUCS4(GooString*, Unicode**)': - UTF.cc:99:33: warning: array subscript has type 'char' - [-Wchar-subscripts] - - poppler/UTF.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 65a2555607e03c94d77ae9ebdb34ab6d4f8844b6 -Author: Fabio D'Urso -Date: Fri Oct 12 23:54:57 2012 +0200 - - FormFieldChoice ctor: Fixed wrong index variable - - It caused a crash if multiple items are initially selected. - - poppler/Form.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 710bb3383306a9aa6debbfe1364029ee12a15576 -Author: Fabio D'Urso -Date: Fri Oct 12 23:54:57 2012 +0200 - - FormFieldChoice ctor: Fixed wrong index variable - - It caused a crash if multiple items are initially selected. - - poppler/Form.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ce18c9b3d5251305eb76d294fdf4b4de9382b3a4 -Author: Albert Astals Cid -Date: Wed Oct 10 19:54:57 2012 +0200 - - 0.20.5 - - CMakeLists.txt | 2 +- - NEWS | 15 +++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - 5 files changed, 19 insertions(+), 4 deletions(-) - -commit b112602334a5de84ae30c2e90d9bc6d4609f7f96 -Author: Tobias Koening -Date: Mon Oct 8 22:32:34 2012 +0200 - - [qt4] make LinkRendition properties available - - Bug #55378 - - poppler/Link.cc | 34 +++++++++++++++++++----- - poppler/Link.h | 17 +++++++++--- - qt4/src/poppler-annotation.cc | 2 -- - qt4/src/poppler-annotation.h | 1 + - qt4/src/poppler-link.cc | 60 - ++++++++++++++++++++++++++++++++++++++++--- - qt4/src/poppler-link.h | 57 - +++++++++++++++++++++++++++++++++++++--- - qt4/src/poppler-page.cc | 8 +++++- - 7 files changed, 158 insertions(+), 21 deletions(-) - -commit 6d6bd660dbb652f2f3e87c81c55a87d1fc11ec70 -Author: Carlos Garcia Campos -Date: Sat Oct 6 10:26:55 2012 +0200 - - glib: chain up finalize to the parent class - - This was missing in some of the classes. - - https://bugs.freedesktop.org/show_bug.cgi?id=55521 - - glib/poppler-document.cc | 6 ++++++ - glib/poppler-page.cc | 2 ++ - 2 files changed, 8 insertions(+) - -commit ac3875a9e7f2f4f31881d3d1b3081f2adaef65a1 -Author: Carlos Garcia Campos -Date: Sat Oct 6 10:26:55 2012 +0200 - - glib: chain up finalize to the parent class - - This was missing in some of the classes. - - https://bugs.freedesktop.org/show_bug.cgi?id=55521 - - glib/poppler-document.cc | 6 ++++++ - glib/poppler-page.cc | 2 ++ - 2 files changed, 8 insertions(+) - -commit 042d332c1c9f628e3bfaabf3da9e04436a8677b5 -Merge: 7b9a9f8 e044814 -Author: Albert Astals Cid -Date: Thu Oct 4 00:53:01 2012 +0200 - - Merge remote-tracking branch 'origin/poppler-0.20' - -commit e044814c0657a6c5b44939a01dcbdc8d83396d43 -Author: Thomas Freitag -Date: Thu Oct 4 00:51:04 2012 +0200 - - Do not render invalid outlines - - Bug #55573 - - splash/SplashFTFont.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 7b9a9f809d07303fe5adff9210731613df8b2adf -Merge: 3b0962c 9451b7a -Author: Albert Astals Cid -Date: Wed Oct 3 01:24:04 2012 +0200 - - Merge remote-tracking branch 'origin/poppler-0.20' - -commit 9451b7a61b6dcaa6c4a76f3efda82f1ebd408654 -Author: Albert Astals Cid -Date: Wed Oct 3 01:21:45 2012 +0200 - - Fix crash when parsing some unknown colorspaces - - Can't do csObj->getName if csObj is a dict - - poppler/GfxState.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 3b0962cd14b15ce92c0916f58ed5ba00aebe80b0 -Merge: a9d7ea2 42908e6 -Author: Albert Astals Cid -Date: Tue Oct 2 19:51:48 2012 +0200 - - Merge remote-tracking branch 'origin/poppler-0.20' - -commit 42908e6e72d95cec0f70b202c4b1c23f7e47c2a4 -Author: Lu Wang -Date: Tue Oct 2 19:31:04 2012 +0200 - - support automake-1.12 in autogen.sh - - Bug #55541 - - autogen.sh | 15 ++++++++------- - 1 file changed, 8 insertions(+), 7 deletions(-) - -commit a9d7ea2eb549acbf6ca7e2a299ffed46ff3d8758 -Merge: 397d7b4 9bb6845 -Author: Albert Astals Cid -Date: Wed Sep 26 15:31:29 2012 +0200 - - Merge remote-tracking branch 'origin/poppler-0.20' - - Conflicts: - poppler/XRef.cc - -commit 9bb68456de41d24db7acf61204bc3f4e36e98505 -Author: Albert Astals Cid -Date: Wed Sep 26 15:13:47 2012 +0200 - - Initilize rootNum - - Fixes valgrind warnings about uninitialized uses - - poppler/XRef.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 397d7b4597ad4bc8ab41fd7a99078473a3c93eb0 -Merge: 6013d49 2c0f70a -Author: Albert Astals Cid -Date: Wed Sep 26 15:00:04 2012 +0200 - - Merge remote-tracking branch 'origin/poppler-0.20' - -commit 2c0f70afff03798165c2b609e115dc7e9c034c57 -Author: Thomas Freitag -Date: Wed Sep 26 14:58:05 2012 +0200 - - More crash fixes for broken documents - - poppler/JPXStream.cc | 97 - ++++++++++++++++++++++++++++++++++++++++++++-------- - 1 file changed, 82 insertions(+), 15 deletions(-) - -commit 78558d24692c68212da35a88deb68069c5a06d81 -Author: Thomas Freitag -Date: Wed Sep 26 14:32:05 2012 +0200 - - Fix more crashes in broken files - - solves 1258.pdf.SIGSEGV.dee.288 and 1255.pdf.asan.38.285, extends - 1043.pdf.asan.47.50 and 557.pdf.asan.47.894 - - poppler/GfxState.cc | 26 +++++++++++++++++++++++--- - 1 file changed, 23 insertions(+), 3 deletions(-) - -commit e8822c0f3a46195ec7c6e55c556dd0c5716be742 -Author: Albert Astals Cid -Date: Wed Sep 26 14:21:46 2012 +0200 - - Add unlikelys - - poppler/Stream.cc | 32 ++++++++++++++++---------------- - 1 file changed, 16 insertions(+), 16 deletions(-) - -commit 31874f2e065b0d68f726ef404de98f42489c80c7 -Author: Thomas Freitag -Date: Wed Sep 26 14:17:00 2012 +0200 - - Less crashes in broken files - - rebased patch for 1001.pdf.asan.2a.4, extends patch for - 100.pdf.asan.38.2 - - poppler/Stream.cc | 100 - ++++++++++++++++++++++++++++++++++++++++++++++++++++-- - 1 file changed, 98 insertions(+), 2 deletions(-) - -commit 81b1d9207840ec1e66eef469b29a36a8556b7265 -Author: Albert Astals Cid -Date: Wed Sep 26 13:38:54 2012 +0200 - - Add some unlikelys - - poppler/JBIG2Stream.cc | 28 ++++++++++++++-------------- - 1 file changed, 14 insertions(+), 14 deletions(-) - -commit 9ae1184e3049cabc695c8645a10eaef748b6e641 -Author: Thomas Freitag -Date: Wed Sep 26 12:32:26 2012 +0200 - - More fixes against broken files - - solves 121.pdf.asan.6f.235, extends 682.pdf.SIGFPE.f3.1033 and - 569.pdf.SIGSEGV.c1.907, extends Patch for 829. and 839. asan and - sigsegv series - - poppler/JBIG2Stream.cc | 105 - +++++++++++++++++++++++++++++++++++++++++++------ - 1 file changed, 93 insertions(+), 12 deletions(-) - -commit 1d72c14b3877ae730ac0aa92f36923269e8a2004 -Author: Thomas Freitag -Date: Wed Sep 26 11:48:14 2012 +0200 - - Fix crash in 158.pdf.asan.d.451 - - poppler/SplashOutputDev.cc | 8 ++++++++ - 1 file changed, 8 insertions(+) - -commit 6013d49d852c58c4c23f787fd7dd64731c0918f1 -Merge: b97c28c 671df5d -Author: Albert Astals Cid -Date: Wed Sep 26 00:53:28 2012 +0200 - - Merge remote-tracking branch 'origin/poppler-0.20' - -commit 671df5dad0732882ceb9e053c3f947dfe0597f3d -Author: Lu Wang -Date: Wed Sep 26 00:52:32 2012 +0200 - - Don't close the stream if it's not a stream - - poppler/PSOutputDev.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit b97c28c42a18d1c2a8fabea52c092d948811d582 -Merge: 32bb874 f8c116f -Author: Albert Astals Cid -Date: Tue Sep 25 23:22:23 2012 +0200 - - Merge remote-tracking branch 'origin/poppler-0.20' - - Conflicts: - qt4/src/Makefile.am - -commit f8c116f1e0fbf3516ce228fbb34c33d6b618bed0 -Author: Albert Astals Cid -Date: Tue Sep 25 23:07:55 2012 +0200 - - Add LCMS_FLAGS - - Fixes compilation when lcms is on non standard locations - Bug #55326 - - qt4/src/Makefile.am | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 32bb87419c360a3b14c717c0f385198b70a1b2e7 -Author: Carlos Garcia Campos -Date: Sun Sep 23 18:15:13 2012 +0200 - - regtest: Reduce the noise of the default output when running tests - - Show permanent information only about failed tests, without the - details - about the failing pages. Previous verbose output is available passing - --verbose command line output. - - regtest/Printer.py | 96 - +++++++++++++++++++++++++++++++++++++ - regtest/TestReferences.py | 8 ++-- - regtest/TestRun.py | 35 +++++++------- - regtest/backends/__init__.py | 13 +++-- - regtest/commands/create-refs.py | 3 +- - regtest/commands/find-regression.py | 5 +- - regtest/commands/run-tests.py | 3 +- - regtest/main.py | 3 ++ - 8 files changed, 137 insertions(+), 29 deletions(-) - -commit ca6afce24aac2ef9d88e215177b11760f7468a6d -Author: Lu Wang -Date: Fri Sep 21 21:33:05 2012 +0200 - - Do not call drawing routines if we don't need non text - - Bug #54617 - - poppler/Gfx.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 70030b91ce2280f23c3e5adf863f1d336c9c5faf -Author: Albert Astals Cid -Date: Fri Sep 21 08:18:29 2012 +0200 - - Increase sonames - - CMakeLists.txt | 2 +- - glib/CMakeLists.txt | 2 +- - glib/Makefile.am | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/CMakeLists.txt | 2 +- - qt4/src/Makefile.am | 2 +- - 6 files changed, 6 insertions(+), 6 deletions(-) - -commit 2323e38f1a54cb58ec31b4cf15e6c2b1db742ca5 -Author: Albert Astals Cid -Date: Fri Sep 21 08:12:52 2012 +0200 - - Version increase - - CMakeLists.txt | 4 ++-- - configure.ac | 4 ++-- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - 4 files changed, 6 insertions(+), 6 deletions(-) - -commit 11a9a620276d199701be5811eb63687ace85ace1 -Author: Albert Astals Cid -Date: Fri Sep 21 08:10:15 2012 +0200 - - Drop the s from AdditionalActionsType - - qt4/src/poppler-annotation-private.h | 5 +++-- - qt4/src/poppler-annotation.cc | 6 +++--- - qt4/src/poppler-annotation.h | 6 +++--- - 3 files changed, 9 insertions(+), 8 deletions(-) - -commit 028e0e7ddf8c30d311feb937385ef21acd34a52d -Author: Albert Astals Cid -Date: Thu Sep 20 18:13:08 2012 +0200 - - 0.21.0 news - - NEWS | 39 +++++++++++++++++++++++++++++++++++++++ - 1 file changed, 39 insertions(+) - -commit 2f2d053352e04e434d83dd93dfdbd08ab5b23f2e -Author: Albert Astals Cid -Date: Thu Sep 20 18:12:57 2012 +0200 - - Update copyrights - - poppler/Annot.cc | 3 ++- - poppler/Annot.h | 1 + - poppler/TextOutputDev.cc | 2 +- - poppler/UTF.h | 1 + - 4 files changed, 5 insertions(+), 2 deletions(-) - -commit 9fad83913791478b63fc76360f1a13e955cdcf4a -Author: Albert Astals Cid -Date: Mon Sep 17 23:15:10 2012 +0200 - - Move to init - - poppler/XRef.cc | 11 +++-------- - 1 file changed, 3 insertions(+), 8 deletions(-) - -commit c470a3929c0a02b8a543fcada22138ab1fc18176 -Author: Thomas Freitag -Date: Mon Sep 17 23:13:48 2012 +0200 - - Support encrypted pdf files in pdfseparate - - poppler/PDFDoc.cc | 35 ++++++++++++++++++++++++++++++++--- - poppler/XRef.cc | 15 +++++++++++++++ - poppler/XRef.h | 2 ++ - utils/pdfseparate.cc | 4 ---- - 4 files changed, 49 insertions(+), 7 deletions(-) - -commit 9b613dcf3c77bc2801d1125dc9bbc5a4dd04e16b -Author: Albert Astals Cid -Date: Mon Sep 17 23:12:43 2012 +0200 - - Compile - - goo/TiffWriter.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit fb5c383bd5be7090fc78380b4bb3244c3316c0cd -Author: William Bader -Date: Mon Sep 17 00:03:49 2012 +0200 - - Make pdftoppm -tiff -overprint work - - Bug #54896 - - goo/TiffWriter.cc | 13 ++++++++++++- - goo/TiffWriter.h | 4 +++- - 2 files changed, 15 insertions(+), 2 deletions(-) - -commit 3794916572a0531b10ee57c9f189497489b90bc8 -Author: Albert Astals Cid -Date: Sun Sep 16 17:53:47 2012 +0200 - - Fix the siblings field correctly - - Fixes KDE bug #302334 - - poppler/Form.cc | 45 - +++++++++++++++++++++++++-------------------- - poppler/Form.h | 24 +++++++++++++----------- - qt4/src/poppler-form.cc | 13 ++++++++++--- - 3 files changed, 48 insertions(+), 34 deletions(-) - -commit e8b6d2ac3a874dd5de166b52625fa628004ea5fe -Merge: 7cb4072 9f51baa -Author: Albert Astals Cid -Date: Sun Sep 16 14:08:34 2012 +0200 - - Merge remote-tracking branch 'origin/poppler-0.20' - -commit 9f51baaf7a86680f2195ecdb978f1eb59a8aa734 -Author: Albert Astals Cid -Date: Sun Sep 16 14:07:45 2012 +0200 - - Rework the #ifdef so that i don't get a gcc warning - - poppler/strtok_r.cpp | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit b63049f97629a93ec346033e0ec56fc11f34c4fe -Author: Albert Astals Cid -Date: Sun Sep 16 14:05:01 2012 +0200 - - Forgot to add the new test to autotools - - qt4/tests/Makefile.am | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -commit 7cb40726f9e80ee2b2f27ca6ce151b46c6ec091d -Merge: e980d11 c6d7084 -Author: Albert Astals Cid -Date: Sun Sep 16 13:50:19 2012 +0200 - - Merge remote-tracking branch 'origin/poppler-0.20' - -commit c6d7084d316e94b5b042b086f5440f8543ff5947 -Author: Albert Astals Cid -Date: Sun Sep 16 13:48:51 2012 +0200 - - Fix parsing of numbers - - -2147483648 is an integer - -2147483649 is a real - - poppler/Lexer.cc | 14 +++++- - qt4/tests/CMakeLists.txt | 1 + - qt4/tests/check_lexer.cpp | 118 - ++++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 131 insertions(+), 2 deletions(-) - -commit e980d11061c19f13c75f93506e07903b4d1c7f97 -Merge: b72c02d 3658088 -Author: Albert Astals Cid -Date: Sat Sep 15 20:41:50 2012 +0200 - - Merge remote-tracking branch 'origin/poppler-0.20' - -commit 365808837080574080b4f8da079124c172fb2123 -Author: Alexey Pavlov -Date: Sat Sep 15 20:38:10 2012 +0200 - - Fix build using mingw64 with winpthread - - strtok_r in winpthread is declared as a macro, that is why - the error happens. Therefore, it is necessary to check whether - the macro - __WINPTHREADS_VERSION is declared. - - Bug #54851 - - poppler/poppler-config.h.cmake | 2 +- - poppler/poppler-config.h.in | 2 +- - poppler/strtok_r.cpp | 16 +++++++++++++++- - 3 files changed, 17 insertions(+), 3 deletions(-) - -commit b72c02d1a2ec8180b3ddfd2bb2b462c0189377d5 -Author: Albert Astals Cid -Date: Thu Sep 13 19:56:45 2012 +0200 - - Remove the fonts loop - - sometimes it's very slow and doesn't really add much - - qt4/tests/test-poppler-qt4.cpp | 4 ---- - 1 file changed, 4 deletions(-) - -commit cb93d51ccb6b1f6938946ae5d38fb9817005fd7a -Author: Albert Astals Cid -Date: Wed Sep 12 00:12:07 2012 +0200 - - Make gcc happy - - It is stupid and can't see that we only use them when we init them - and complains - they might be used un-initialized - - poppler/TextOutputDev.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 3349a8dd7e0469cc5b5aaa8dd929c6078183ef86 -Author: Thomas Freitag -Date: Wed Sep 12 00:04:45 2012 +0200 - - Splash: Avoid bogus memory error for tilingPattern - - just return gFalse if the resulting - tiling pattern bitmap reaches a memory limit and so the Gfx - implemention of - tiling patterns will be used. I think that this is an acceptable - approach also - concerning performance, because it would take also a while to paint - such a huge - bitmap and then draw it to splash. - - poppler/SplashOutputDev.cc | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -commit 2e77799a1668f949612f551425d0665c59ff1d93 -Author: Thomas Freitag -Date: Tue Sep 11 23:33:25 2012 +0200 - - Splash: Implement DeviceN support - - Bug #53140 - - Some copying from the bug tracker - - To explain - it a little bit more I copy a few lines from "Patch 8.01 — DeviceN - Support (6 - colors)" of the Ghent PDF workgroup: - "This patch tests the DeviceN capabilities of a workflow. If DeviceN - is not - handled correctly the colors are converted to CMYK. Instead of the - check marks - an X will appear in the lower left corner of each image and in - the gradient. - In addition you could inspect the color separations. The objects - should appear - only in the Black, Pantone 265C and GWG Green separations as indicated - in the - captions." - Without the patch all DeviceN colors are immediately converted to CMYK - (with - SPLASH_CMYK). This leads especially to problems, if overprint is - used: in - overprint mode a CMYK color will knockout the underlying CMYK - components, BUT - neither any spot colors. But if underlying spot colors are immediately - converted to CMYK colors, they will be kocked out then, too! - The patch now spends up to four (or up to SPOT_NCOMPS) additional - spot colors - in the splash bitmap, so the order in the bitmap will be - CMYKSTUVCMYKSTUVCMYKSTUV... where S, T, U, V are spot colors (I - would use - S1,S2, S3, S4 if it's possible to use indexes), and all painting - operations are - done now in this new device. Only at the end, when we want to store - the bitmap - in a CMYK or RGB color, the spot colors are converted and their - alternate CMYK - components are added to the normal CMYK components. - According to the PDF spec are PDF writer should use different spot - color names - if they have a different appearance in their alternate CMYK - colorspace. - "hasDifferntResultSet" (sorry for the typo) proofs that: if the same - spot color - name is reused BUT has a different appearance in the alternate - colorspace, it - will be converted immediately to its alternate colorspace. - "createMapping" is used so that getDeviceN (color) returns the - components in - the correct order according their appearance in the splash bitmap, - i.e. the - fourth detected spot color must be placed in index 7 of the color - array. - updateFill- and updateStrokeColorspace are needed to create this - mapping at the - appropriate place. And they are not called once but everytime the - colorspace - changed in the PDF (but of course only once in Gfx). - The GooList *getSeparationList() is used to store the functions - for converting - the spot colors to their alternate colorspace in order of their - appearance in - the splash bitmap. The functions are needed to compare if a spot - color with the - same name has really the same appearance and at the end when the - splash bitmap - has to be converted to a CMYK or RGB bitmap (s. ahead). - deviceNTransfer is needed simular to rgbTransferX or cmykTransferX - if a - transfer function is specified in the ExtGState and splash uses - the DeviceN8. - "Do we really need splashModeDeviceN8?": Do we really need - splashModeXBGR8? But - kidding aside: splashModeDeviceN8 needs four more components than - splashModeCMYK8, so the bitmap size in memory doubles the size of - a pure CMYK - bitmap, and it is only needed if the PDF uses spot colors. So I - think it's a - good idea to spend an additional mode and let it up to the calling - application - and the cirumstances if it wants to use this new mode or not. - - poppler/Function.cc | 14 + - poppler/Function.h | 4 + - poppler/GfxState.cc | 341 +++++++++++++++++- - poppler/GfxState.h | 41 ++- - poppler/SplashOutputDev.cc | 173 ++++++++- - poppler/SplashOutputDev.h | 3 + - splash/Splash.cc | 255 ++++++++++++- - splash/Splash.h | 7 +- - splash/SplashBitmap.cc | 115 +++++- - splash/SplashBitmap.h | 8 +- - splash/SplashState.cc | 30 +- - splash/SplashState.h | 3 + - splash/SplashTypes.h | 30 +- - utils/pdftoppm.cc | 878 - ++++++++++++++++++++++----------------------- - 14 files changed, 1415 insertions(+), 487 deletions(-) - -commit cb2ed646c4ef4161e443ee0a377d1111b3be28ff -Merge: f3a1b76 3ce4d21 -Author: Albert Astals Cid -Date: Tue Sep 11 19:29:19 2012 +0200 - - Merge remote-tracking branch 'origin/poppler-0.20' - -commit f3a1b765bd6a58d327a80feedbe30e1c0792076e -Author: Jason Crain -Date: Tue Sep 11 19:28:28 2012 +0200 - - Allow multiple fonts in a TextWord - - Bug #6923 - - glib/poppler-page.cc | 49 ++++++----- - poppler/TextOutputDev.cc | 224 - ++++++++++++++++++++++------------------------- - poppler/TextOutputDev.h | 21 ++--- - 3 files changed, 145 insertions(+), 149 deletions(-) - -commit 3ce4d213480471dfd8e307c24c99bf3c6308cd6f -Author: Albert Astals Cid -Date: Tue Sep 11 19:24:58 2012 +0200 - - Do not use isnan as it is C99 - - poppler/TextOutputDev.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 4d7a64a23fd4b4b5ee0d47ead8677f374aaaf6c9 -Author: Jason Crain -Date: Tue Sep 11 19:24:11 2012 +0200 - - Check for NaN in TextPage::addChar - - poppler/TextOutputDev.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit e79b70ec13ab4d2cce8f245d150fa9329b436658 -Author: Tobias Koenig -Date: Tue Sep 11 16:39:55 2012 +0200 - - Make 'additional actions' available in Annotation API of Qt4 frontend - - Bug #53589 - - qt4/src/poppler-annotation-private.h | 3 ++ - qt4/src/poppler-annotation.cc | 99 - +++++++++++++++++++++++++++++++++++- - qt4/src/poppler-annotation.h | 68 ++++++++++++++++++++++++- - 3 files changed, 168 insertions(+), 2 deletions(-) - -commit 5f338ea7d01cabc0f8c50690d0bc262d85baa0ed -Author: Albert Astals Cid -Date: Mon Sep 10 19:47:20 2012 +0200 - - Fix typo - - NEWS | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 5fd691dc58aac817bca81c87c4820afcf53989d1 -Author: Albert Astals Cid -Date: Mon Sep 10 19:29:01 2012 +0200 - - 0.20.40.20.40.20.40.20.4 - - CMakeLists.txt | 4 ++-- - NEWS | 13 +++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 6 files changed, 19 insertions(+), 6 deletions(-) - -commit 1b40cdd9f863cd3868db85b5ccfa77a8350c56d6 -Merge: 6c40a55 b3e86db -Author: Albert Astals Cid -Date: Mon Sep 10 18:49:52 2012 +0200 - - Merge remote-tracking branch 'origin/poppler-0.20' - -commit b3e86dbdba82956f125e37f69176072e2d0127f2 -Author: Thomas Freitag -Date: Sun Sep 9 23:35:45 2012 +0200 - - Try to find another rootNum if actual rootNum doesn't point to a dict - - Bug #14303 - - poppler/XRef.cc | 14 ++++++++++++-- - poppler/XRef.h | 4 ++-- - 2 files changed, 14 insertions(+), 4 deletions(-) - -commit 6c40a553a3c8825931c59797059392fd110531cc -Merge: 17fc1bf 558a7d9 -Author: Albert Astals Cid -Date: Sun Sep 9 23:27:40 2012 +0200 - - Merge remote-tracking branch 'origin/poppler-0.20' - -commit 558a7d9b046bbbe185dea263b48a3cb2664378fc -Author: Thomas Freitag -Date: Sun Sep 9 23:25:47 2012 +0200 - - Fix invalid memory access in solves 1066.pdf.asan.38.75 - - splash/SplashClip.cc | 23 +++++++++++++++++++++++ - splash/SplashXPathScanner.cc | 3 +++ - 2 files changed, 26 insertions(+) - -commit d0df8e54512f584ca2b3edbae1c19e167948e5c3 -Author: Thomas Freitag -Date: Sun Sep 9 23:21:38 2012 +0200 - - Fix invalid memory access in 1106.pdf.asan.30.120.patch - - poppler/Function.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 86b89864396a1dcf027e5793e6ac75411977bcf9 -Author: Thomas Freitag -Date: Sun Sep 9 23:08:49 2012 +0200 - - Fix crash in 1255.pdf.SIGSEGV.56f.285 - - poppler/XRef.cc | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit 96931732f343d2bbda9af9488b485da031866c3b -Author: Thomas Freitag -Date: Sun Sep 9 22:47:57 2012 +0200 - - Fix invalid memory access in 61.pdf.asan.13.95 - - fofi/FoFiType1C.cc | 25 +++++++++++++++++-------- - fofi/FoFiType1C.h | 2 ++ - 2 files changed, 19 insertions(+), 8 deletions(-) - -commit 26917d69c4da6a110db02b120133c36579fbb17c -Author: Albert Astals Cid -Date: Sun Sep 9 22:23:36 2012 +0200 - - Add unlikely - - poppler/Gfx.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit e6a3c797c01aa343f640f2e6f45de5bf379aa8ad -Author: Thomas Freitag -Date: Sun Sep 9 22:22:59 2012 +0200 - - Fix wrong memory access in 68.pdf.asan.7.1030 - - poppler/Gfx.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 48fe18cf277cd2a4e665c74b3a594482f762f4b6 -Author: Albert Astals Cid -Date: Sun Sep 9 22:09:44 2012 +0200 - - Fix memory leak - - poppler/Gfx.cc | 1 + - 1 file changed, 1 insertion(+) - -commit b87aafc0cdb36c3555053f2684c45f1a9d7b2f94 -Author: Albert Astals Cid -Date: Sun Sep 9 21:42:48 2012 +0200 - - Add unlikelys to the ifs - - poppler/DCTStream.cc | 4 ++-- - poppler/JBIG2Stream.cc | 2 +- - 2 files changed, 3 insertions(+), 3 deletions(-) - -commit a019eef2f8ca53addd7ccab7f9c47657f4e52286 -Author: Thomas Freitag -Date: Sun Sep 9 21:41:09 2012 +0200 - - Fix crash in 1162.pdf.SIGSEGV.28e.182 - - poppler/DCTStream.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit ad7c6ac88f2315c9ce003308d1b4988592d4434b -Author: William Bader -Date: Sun Sep 9 21:31:58 2012 +0200 - - Fix crash in 1028.pdf.SIGSEGV.ae6.33 - - poppler/JBIG2Stream.cc | 8 ++++++++ - 1 file changed, 8 insertions(+) - -commit b861af714daee4125e54b250dddf82106f5a8ce8 -Author: Albert Astals Cid -Date: Sun Sep 9 21:15:06 2012 +0200 - - Fix memory leak - - poppler/Form.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 17fc1bfa8013cafe3b348f0cc07ef08bf9c7dd9a -Merge: e0118be a4f5911 -Author: Albert Astals Cid -Date: Sun Sep 9 12:52:49 2012 +0200 - - Merge remote-tracking branch 'origin/poppler-0.20' - -commit a4f59113574a8d7460c6ce5000cb09d20fe52b74 -Author: Albert Astals Cid -Date: Sun Sep 9 12:49:43 2012 +0200 - - Fix memory leak - - poppler/Annot.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 28240046f8fe37ca96f9a80cb1ea3a59af9c66f3 -Author: Thomas Freitag -Date: Sun Sep 9 12:48:26 2012 +0200 - - Fix crash in 589.pdf.SIGSEGV.8b1.929 - - poppler/Annot.cc | 8 ++++++++ - 1 file changed, 8 insertions(+) - -commit e0118be3ba38bd00fa2a9c20c5b4cd82e820ba0b -Merge: 2c41430 ccd3db5 -Author: Albert Astals Cid -Date: Sat Sep 8 18:15:43 2012 +0200 - - Merge remote-tracking branch 'origin/poppler-0.20' - - Conflicts: - glib/poppler-document.cc - poppler/PDFDoc.cc - poppler/XRef.h - utils/HtmlFonts.cc - -commit ccd3db5a7723ddb692f6dc85ed9d0f5e3dde189f -Author: Albert Astals Cid -Date: Sat Sep 8 18:10:14 2012 +0200 - - Only complain when the malloc really failed - - poppler/JBIG2Stream.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 2c41430732f517d4d57e914a315ba315a2545541 -Author: Albert Astals Cid -Date: Thu Sep 6 22:12:38 2012 +0200 - - Add missing licenses - - goo/grandom.cc | 2 ++ - goo/grandom.h | 2 ++ - splash/SplashScreen.cc | 1 + - utils/pdfinfo.cc | 1 + - 4 files changed, 6 insertions(+) - -commit be88963a5955ac033e7a7d224bdcc4049085a9dc -Author: Fabio D'Urso -Date: Thu Aug 9 13:18:22 2012 +0200 - - pdf-fullrewrite: Added support for encrypted documents, checks on - output documents, incremental update mode - - test/CMakeLists.txt | 1 + - test/Makefile.am | 3 +- - test/pdf-fullrewrite.cc | 354 - ++++++++++++++++++++++++++++++++++++++++++++++-- - 3 files changed, 342 insertions(+), 16 deletions(-) - -commit 381be58e9e0d0e323acbd975a2334eca6d9018fd -Author: Fabio D'Urso -Date: Sat Aug 4 13:00:06 2012 +0200 - - pdfinfo: Show info about the encryption algorithm - - utils/pdfinfo.cc | 24 ++++++++++++++++++++++-- - 1 file changed, 22 insertions(+), 2 deletions(-) - -commit 273e8c896e95b548093159dc8bb14d48ce447053 -Author: Fabio D'Urso -Date: Wed Aug 15 18:09:02 2012 +0200 - - Mark object streams as DontRewrite - - So that they don't get copied in full rewrite mode, because they're - not referenced from the XRef table we build, and we already - individually write each object they contain. - - poppler/XRef.cc | 13 +++++++++++++ - 1 file changed, 13 insertions(+) - -commit 59db8deaa7b1907831b526de3011dc22d0ffb333 -Author: Fabio D'Urso -Date: Thu Aug 9 20:08:44 2012 +0200 - - Mark XRef streams as Unencrypted and DontRewrite - - - Unencrypted because they are stored in unencrypted form - - DontRewrite because they must not be copied in full rewrite mode, - because we always build a new XRef table, and existing XRef streams - are not referenced any more (ie they become "leaked" objects). - Furthermore, since readers know that XRef streams' objects are - unencrypted from the fact that they are XRef streams, but these - leaked objects are no longer referred as XRef streams, readers would - think that they are regularly encrypted objects, resulting in - currupt objects. - - poppler/PDFDoc.cc | 5 +++ - poppler/XRef.cc | 126 - +++++++++++++++++++++++++++++++++++------------------- - poppler/XRef.h | 9 ++-- - 3 files changed, 94 insertions(+), 46 deletions(-) - -commit 116722cc74e267ac44dd5a70924557cdf6f25d02 -Author: Fabio D'Urso -Date: Sat Aug 4 12:47:22 2012 +0200 - - Encrypt strWeird streams before writing them in PDFDoc::writeObject - - poppler/Decrypt.cc | 9 ++++++++- - poppler/Decrypt.h | 2 ++ - poppler/PDFDoc.cc | 10 ++++++++++ - 3 files changed, 20 insertions(+), 1 deletion(-) - -commit 695889c1330ca5b37338b8363dbf233fce936bc6 -Author: Fabio D'Urso -Date: Sat Aug 4 12:24:25 2012 +0200 - - Encrypt strings before writing them in PDFDoc::writeString - - poppler/PDFDoc.cc | 20 ++++++++++++++++++++ - 1 file changed, 20 insertions(+) - -commit 4ab8e7be536db40db8a1a4af50dad3ba59c49f14 -Author: Fabio D'Urso -Date: Sat Aug 4 02:06:11 2012 +0200 - - Propagate encryption parameters to PDFDoc's write functions - - poppler/PDFDoc.cc | 54 - ++++++++++++++++++++++++++++++++++++------------------ - poppler/PDFDoc.h | 20 +++++++++++++------- - poppler/XRef.cc | 14 ++++++++++++++ - poppler/XRef.h | 2 ++ - utils/pdfunite.cc | 2 +- - 5 files changed, 66 insertions(+), 26 deletions(-) - -commit 9e43f9a8bcbee9060309b9679dbcc6b501a79cfb -Author: Fabio D'Urso -Date: Wed Aug 1 16:14:22 2012 +0200 - - Separated header and footer write commands from the rest of - PDFDoc::writeObject - - Because in next patch I'll need to pass the object's num and gen - always, - not only if the object's header and footer need to be written. - - poppler/PDFDoc.cc | 51 - +++++++++++++++++++++++++++++++++------------------ - poppler/PDFDoc.h | 11 +++++++---- - utils/pdfunite.cc | 2 +- - 3 files changed, 41 insertions(+), 23 deletions(-) - -commit 4d19a002801531b07f11382daaf9880e4691a10e -Author: Fabio D'Urso -Date: Sat Aug 4 01:36:06 2012 +0200 - - Do not change encrypted documents' ID, not even in case of full - rewrite - - Because we will raw-copy encrypted streams, and the ID is part of the - decryption key. - - poppler/PDFDoc.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 800b2e37d3c4c73147bf9e11d9f38afe2183ab9d -Author: Fabio D'Urso -Date: Wed Aug 1 14:07:10 2012 +0200 - - Initial support for saving encrypted documents - - - Do not refuse to save encrypted documents - - Copy the /Encrypt value in the new document's trailer dictionary - - Mark indirect objects referred from /Encrypt as not encrypted - in XRef::scanSpecialFlags - - poppler/PDFDoc.cc | 49 ++++++++++++++++++------------------------- - poppler/XRef.cc | 62 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++- - poppler/XRef.h | 16 +++++++++++++- - 3 files changed, 96 insertions(+), 31 deletions(-) - -commit 6647153d47b1d67d2a4d6b90dce2184ab6c7dda6 -Author: Fabio D'Urso -Date: Thu Aug 9 12:26:53 2012 +0200 - - Added field XRefEntry::flags, and turned XRefEntry::updated into - a flag - - In next patches I'll add other flags - - poppler/PDFDoc.cc | 4 ++-- - poppler/XRef.cc | 18 +++++++++--------- - poppler/XRef.h | 20 +++++++++++++++++++- - 3 files changed, 30 insertions(+), 12 deletions(-) - -commit a284c6c6623587abb7da7e4c171c42e006ea477b -Author: Fabio D'Urso -Date: Sat Aug 4 01:57:41 2012 +0200 - - Be able to output overflown integers back - - Because Lexer.cc:241 can read them, and we must be able to write them - back (especially in full rewrite mode). - - poppler/PDFDoc.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 53baea19658a27f15c7ed870a24be82b8219ddfe -Author: Fabio D'Urso -Date: Sat Aug 4 01:32:08 2012 +0200 - - FlateStream::unfilteredReset should call str->unfilteredReset() - - Just like any other FilterStream-derived class does - - poppler/Stream.cc | 14 +++++++++++--- - poppler/Stream.h | 2 ++ - 2 files changed, 13 insertions(+), 3 deletions(-) - -commit 4e5fee4e9156480173f05e7b3d0bdf604127d481 -Author: Fabio D'Urso -Date: Mon Aug 6 02:08:27 2012 +0200 - - Initialize AES encryption with random CBC IV data - - poppler/Decrypt.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 1b008f273359b8df6b64ffa94bb2828e42ffa63e -Author: Fabio D'Urso -Date: Mon Aug 6 02:08:40 2012 +0200 - - Replaced srand/rand calls in SplashScreen with grandom calls - - splash/SplashScreen.cc | 7 ++----- - 1 file changed, 2 insertions(+), 5 deletions(-) - -commit faff947d8106048b19ba74dd483b90b8cebb16c7 -Author: Fabio D'Urso -Date: Mon Aug 6 02:06:47 2012 +0200 - - Added goo/grandom.[cc|h] with POSIX implementation - - CMakeLists.txt | 2 ++ - ConfigureChecks.cmake | 1 + - config.h.cmake | 3 +++ - configure.ac | 1 + - goo/Makefile.am | 6 +++-- - goo/grandom.cc | 68 - +++++++++++++++++++++++++++++++++++++++++++++++++++ - goo/grandom.h | 32 ++++++++++++++++++++++++ - 7 files changed, 111 insertions(+), 2 deletions(-) - -commit af8d05d1ab89b74e307e90aaf19c750528f5f561 -Author: Fabio D'Urso -Date: Fri Aug 3 12:46:06 2012 +0200 - - Added encryption support in Decrypt.cc/.h - - poppler/Decrypt.cc | 222 - +++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Decrypt.h | 21 ++++- - 2 files changed, 242 insertions(+), 1 deletion(-) - -commit ba6ff179aa78a42a384166ace2df80101cfbe7b9 -Author: Fabio D'Urso -Date: Thu Aug 2 18:56:29 2012 +0200 - - Refactoring of Decrypt.cc/.h in preparation for encryption support - - poppler/Decrypt.cc | 219 - +++++++++++++++++++++++++++-------------------------- - poppler/Decrypt.h | 35 ++++++--- - 2 files changed, 133 insertions(+), 121 deletions(-) - -commit cd1ab1e34032d5620140bd0b6b6ec4b74f89ae19 -Author: Albert Astals Cid -Date: Thu Aug 30 22:36:14 2012 +0200 - - Update Adrian's copyrights - - goo/GooString.cc | 1 + - poppler/CharCodeToUnicode.cc | 1 + - poppler/TextOutputDev.cc | 2 +- - poppler/UTF.cc | 23 +++++++++++++++++++++++ - utils/HtmlOutputDev.cc | 2 +- - 5 files changed, 27 insertions(+), 2 deletions(-) - -commit ce8a579f339507da3fd7802e1531fbf6849c0c98 -Author: Adrian Johnson -Date: Tue Aug 28 22:16:34 2012 +0930 - - Move text to unicode conversion into a separate function - - This also ensures UTF-16 ActualText strings are converted to UCS-4 - before calling addChar. - - goo/GooString.cc | 2 +- - poppler/TextOutputDev.cc | 32 ++++---------------------------- - poppler/UTF.cc | 34 ++++++++++++++++++++++++++++++++++ - poppler/UTF.h | 8 ++++++++ - utils/pdfinfo.cc | 37 ++++++------------------------------- - 5 files changed, 53 insertions(+), 60 deletions(-) - -commit cac13e782cf4413703cfd1fa23e76133dfbe5ef9 -Author: Adrian Johnson -Date: Tue Aug 28 21:48:16 2012 +0930 - - text: increase the tolerance for overlapping glyphs - - TextOutputDev will start a new line when encountering consecutive - glyphs with overlapping bounding boxes. This can occur when drawing - diacritics with a separate glyph. In this case, due to the diacritic - having a different baseline, the lines may be output in the wrong - order. - - This patch increases the tolerance for overlapping bounding boxes to - prevent diacritics from splitting lines. - - poppler/TextOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 6f6386219449e70c2c3bc3559fdde3df4a57a809 -Author: Adrian Johnson -Date: Thu Mar 8 20:52:28 2012 +1030 - - Convert UTF-16 to UCS-4 when reading toUnicode cmap - - to ensure only UCS-4 values are used with the "Unicode" type. - - CMakeLists.txt | 3 +- - poppler/CairoOutputDev.cc | 2 +- - poppler/CharCodeToUnicode.cc | 12 ++--- - poppler/GlobalParams.cc | 2 +- - poppler/Makefile.am | 3 +- - poppler/TextOutputDev.cc | 19 +------- - poppler/UTF.cc | 47 ++++++++++++++++++++ - poppler/UTF.h | 103 - +++++++++++++++++++++++++++++++++++++++++++ - poppler/UTF8.h | 84 ----------------------------------- - utils/HtmlOutputDev.cc | 14 +----- - 10 files changed, 165 insertions(+), 124 deletions(-) - -commit b3b0f5abe4fdcc39d884670e4a998d39324659f6 -Author: Albert Astals Cid -Date: Thu Aug 30 00:57:51 2012 +0200 - - qt4: unbreak spacing - - qt4/src/poppler-embeddedfile.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 6356c0bbae47db291a3585d31c7727bc3f8d97a4 -Author: Albert Astals Cid -Date: Thu Aug 30 00:57:51 2012 +0200 - - qt4: unbreak spacing - - qt4/src/poppler-embeddedfile.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 46948868dee6d4e68b658c68d7df482590e34da3 -Author: Albert Astals Cid -Date: Thu Aug 30 00:43:45 2012 +0200 - - Accept FileSpec as Dict too and not only as Ref - - File to try in KDE bug #306008 - - poppler/Catalog.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit debc8fb497bc22c0f9f34d785852981a87475c30 -Author: Albert Astals Cid -Date: Thu Aug 30 00:35:40 2012 +0200 - - Take into account the embFile returned by the core may be NULL - - qt4/src/poppler-embeddedfile-private.h | 4 +++- - qt4/src/poppler-embeddedfile.cc | 19 ++++++++++++------- - 2 files changed, 15 insertions(+), 8 deletions(-) - -commit 3ca67a59fc15782abb1e479eb2b8916de5b1b6ed -Author: Albert Astals Cid -Date: Thu Aug 30 00:34:06 2012 +0200 - - Return NULL EmbFile if the FileSpec is not ok - - Otherwise we might end up asserting - - poppler/FileSpec.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 9264b375eec19e639c524b677f770ad750b1cb43 -Author: Albert Astals Cid -Date: Thu Aug 30 00:43:45 2012 +0200 - - Accept FileSpec as Dict too and not only as Ref - - File to try in KDE bug #306008 - - poppler/Catalog.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit 01528eaedc77d5559f6dc4229b66f1a819678fb7 -Author: Albert Astals Cid -Date: Thu Aug 30 00:35:40 2012 +0200 - - Take into account the embFile returned by the core may be NULL - - qt4/src/poppler-embeddedfile-private.h | 4 +++- - qt4/src/poppler-embeddedfile.cc | 19 ++++++++++++------- - 2 files changed, 15 insertions(+), 8 deletions(-) - -commit c1fba45be106dc30a5136efe41493b1cf6d2a1b5 -Author: Albert Astals Cid -Date: Thu Aug 30 00:34:06 2012 +0200 - - Return NULL EmbFile if the FileSpec is not ok - - Otherwise we might end up asserting - - poppler/FileSpec.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 1881486e9817304d0817ce24b177c1bc79587138 -Author: Tobias Koenig -Date: Fri Aug 24 19:12:20 2012 +0200 - - annots: Unify parsing of additional actions entries - - https://bugs.freedesktop.org/show_bug.cgi?id=53586 - - poppler/Annot.cc | 58 - ++++++++++++++++++++++++++++++++++++++++++++------------ - poppler/Annot.h | 24 +++++++++++++++++++---- - 2 files changed, 66 insertions(+), 16 deletions(-) - -commit 686ec0cc92e25f74eaa9e09a328724cbdf939bca -Author: Albert Astals Cid -Date: Wed Aug 15 20:02:05 2012 +0200 - - Remove declared but not implemented function - - poppler/XRef.h | 1 - - 1 file changed, 1 deletion(-) - -commit 0b3259c1d5679cb8d59d770e5fbe7e1bc141a025 -Author: Albert Astals Cid -Date: Wed Aug 15 20:02:05 2012 +0200 - - Remove declared but not implemented function - - poppler/XRef.h | 1 - - 1 file changed, 1 deletion(-) - -commit 5fd2a35227c22dbddedfb397eff0e0a09c3d1b03 -Author: Pino Toscano -Date: Wed Aug 15 19:51:43 2012 +0200 - - poppler-config.h: remove WITH_FONTCONFIGURATION_* macros - - no public header uses them anymore, so need to expose them - - poppler/poppler-config.h.cmake | 10 ---------- - poppler/poppler-config.h.in | 10 ---------- - 2 files changed, 20 deletions(-) - -commit edd0ea4847c143adb1d15a57b42b0ce2b2c80b0e -Author: Pino Toscano -Date: Wed Aug 15 19:31:50 2012 +0200 - - ignore more qt4 tests - - qt4/tests/.gitignore | 3 +++ - 1 file changed, 3 insertions(+) - -commit 2df57857000c5adbee6b029ff7a79acc707786a0 -Author: Pino Toscano -Date: Wed Aug 15 18:59:15 2012 +0200 - - build: remove extra fontconfig CFLAGS and LIBS - - fontconfig is used only in .cpp sources inside the 'poppler' - subdirectory, so there is no need to add the include paths for it - in other directories; - likewise, do not to link to it if not needed - - glib/Makefile.am | 4 +--- - qt4/demos/Makefile.am | 2 -- - qt4/src/Makefile.am | 2 -- - qt4/tests/Makefile.am | 2 -- - test/Makefile.am | 6 ++---- - utils/CMakeLists.txt | 3 --- - utils/Makefile.am | 4 +--- - 7 files changed, 4 insertions(+), 19 deletions(-) - -commit 3e802949264d9310df057daff891a3fccb2eb8d3 -Author: Albert Astals Cid -Date: Wed Aug 15 00:02:23 2012 +0200 - - PSOutputDev: Always write HiResBoundingBox - - Makes some people happier and it doesn't hurt us much - Bug #53159 - - poppler/PSOutputDev.cc | 7 ++----- - 1 file changed, 2 insertions(+), 5 deletions(-) - -commit e83568065f77ba722b147b3b10faed1ff66f22dc -Author: Pino Toscano -Date: Sat Aug 11 01:38:08 2012 +0200 - - remove extra execution permissions - - (cherry picked from commit 9a5a19ee2f9cd536c3527b30c0256ca9dce3638c) - - goo/GooTimer.h | 0 - 1 file changed, 0 insertions(+), 0 deletions(-) - -commit 9a5a19ee2f9cd536c3527b30c0256ca9dce3638c -Author: Pino Toscano -Date: Sat Aug 11 01:38:08 2012 +0200 - - remove extra execution permissions - - goo/GooTimer.h | 0 - 1 file changed, 0 insertions(+), 0 deletions(-) - -commit 1b2903c104012fdd3c982d57898910945dff9a15 -Author: Albert Astals Cid -Date: Sat Aug 11 00:05:10 2012 +0200 - - 0.20.3 - - CMakeLists.txt | 4 ++-- - NEWS | 16 ++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 6 files changed, 22 insertions(+), 6 deletions(-) - -commit 40e7b744d32152ab4c6201b8bda7fb7caf6bfd4e -Author: Albert Astals Cid -Date: Sun Aug 5 15:07:16 2012 +0200 - - If NULL, NULL fails as password try EMPTY, EMPTY before failing - - Reviewed by Jose Aliste - Bug #3498 - - poppler/SecurityHandler.cc | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -commit a53e0641365608f832b455404f1ee584d278e0c4 -Author: Albert Astals Cid -Date: Sun Aug 5 15:07:16 2012 +0200 - - If NULL, NULL fails as password try EMPTY, EMPTY before failing - - Reviewed by Jose Aliste - Bug #3498 - - poppler/SecurityHandler.cc | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -commit 3ca2bc0d3abdf92741b7921ea402c9de09e531f6 -Author: Markus Trippelsdorf -Date: Fri Aug 3 00:48:12 2012 +0200 - - Fix segfault when scaleImage returns NULL - - Bug 52488 - - splash/Splash.cc | 7 +++++++ - 1 file changed, 7 insertions(+) - -commit 31fe12c63f0133d124e2115aba607857aaff0978 -Author: Markus Trippelsdorf -Date: Fri Aug 3 00:48:12 2012 +0200 - - Fix segfault when scaleImage returns NULL - - Bug 52488 - - splash/Splash.cc | 7 +++++++ - 1 file changed, 7 insertions(+) - -commit d3c339017857cd762d8419260e33e1cc4e197743 -Author: Thomas Freitag -Date: Thu Aug 2 00:22:19 2012 +0200 - - PSOutputDev: Fix Bitmaps in level2sep or level3sep - - Bug #52384 - - poppler/PSOutputDev.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 768cf5877f48f8cee80fe96e2ee52f42f230dfdf -Author: Thomas Freitag -Date: Thu Aug 2 00:22:19 2012 +0200 - - PSOutputDev: Fix Bitmaps in level2sep or level3sep - - Bug #52384 - - poppler/PSOutputDev.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit d0e55aa49484263882345fa648e1e907d2b172f2 -Author: Thomas Freitag -Date: Wed Aug 1 22:56:49 2012 +0200 - - Splash: Blend mode enhancements for CMYK - - poppler/SplashOutputDev.cc | 76 - ++++++++++++++++++++++++++++++++-------------- - splash/Splash.cc | 22 -------------- - 2 files changed, 54 insertions(+), 44 deletions(-) - -commit 315447843a368556a8536bc30e579c9bf338682e -Author: Thomas Freitag -Date: Wed Aug 1 22:56:49 2012 +0200 - - Splash: Blend mode enhancements for CMYK - - poppler/SplashOutputDev.cc | 76 - ++++++++++++++++++++++++++++++++-------------- - splash/Splash.cc | 22 -------------- - 2 files changed, 54 insertions(+), 44 deletions(-) - -commit 78c6a5615013d26b8a2babb13b3c4f7d6a1d70a4 -Author: Albert Astals Cid -Date: Tue Jul 31 23:32:19 2012 +0200 - - Replace c++ style includes with c style ones - - Fixes build in Solaris 10 - Bug #52426 - - goo/gstrtod.cc | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -commit c0c88b3707fc7337e814ae4252d80002641a19ee -Author: Albert Astals Cid -Date: Tue Jul 31 23:32:19 2012 +0200 - - Replace c++ style includes with c style ones - - Fixes build in Solaris 10 - Bug #52426 - - goo/gstrtod.cc | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -commit dcbc923bd3592a81876f84005fbaddcea18641cc -Author: Thomas Freitag -Date: Sun Jul 22 18:40:46 2012 +0200 - - Make sure xScale and yScale are always initialized - - Bug #52215 - - poppler/PSOutputDev.cc | 5 +---- - 1 file changed, 1 insertion(+), 4 deletions(-) - -commit 36481939e3064de920e49d9d1742a85473a50963 -Author: Thomas Freitag -Date: Sun Jul 22 18:40:46 2012 +0200 - - Make sure xScale and yScale are always initialized - - Bug #52215 - - poppler/PSOutputDev.cc | 5 +---- - 1 file changed, 1 insertion(+), 4 deletions(-) - -commit ef7c2418e12d3e6a79f1d89a0051b005fadbc344 -Author: Thomas Freitag -Date: Sat Jul 21 00:01:49 2012 +0200 - - Fix conversion to ps when having multiple strips - - Bug 51982 - - poppler/PSOutputDev.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit 6b567565b7b9d591fbd7441592096960a303bd39 -Author: Thomas Freitag -Date: Sat Jul 21 00:01:49 2012 +0200 - - Fix conversion to ps when having multiple strips - - Bug 51982 - - poppler/PSOutputDev.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit 349b21acc249c130fb053bc4a0c75019f75bd35b -Author: Torsten Kasch -Date: Thu Jul 19 00:18:14 2012 +0200 - - Unify poppler-config.h includes in core "installed" headers - - Bug 52193 - - goo/FixedPoint.h | 2 +- - goo/GooTimer.h | 2 +- - goo/JpegWriter.h | 2 +- - goo/PNGWriter.h | 2 +- - goo/TiffWriter.h | 2 +- - goo/gfile.h | 2 +- - goo/gmem.h | 2 +- - splash/SplashFTFont.h | 2 +- - splash/SplashMath.h | 2 +- - 9 files changed, 9 insertions(+), 9 deletions(-) - -commit 34327b2c201392f96e3449941411b7ad4b3e8bcb -Author: Torsten Kasch -Date: Thu Jul 19 00:18:14 2012 +0200 - - Unify poppler-config.h includes in core "installed" headers - - Bug 52193 - - goo/FixedPoint.h | 2 +- - goo/GooTimer.h | 2 +- - goo/JpegWriter.h | 2 +- - goo/PNGWriter.h | 2 +- - goo/TiffWriter.h | 2 +- - goo/gfile.h | 2 +- - goo/gmem.h | 2 +- - splash/SplashFTFont.h | 2 +- - splash/SplashMath.h | 2 +- - 9 files changed, 9 insertions(+), 9 deletions(-) - -commit 8fe700217ab6ce786a8272f2c338e3dab434c56e -Author: Torsten Kasch -Date: Thu Jul 19 00:06:45 2012 +0200 - - autoconf: Do not assume the shell is bash compatible - - Bug 52197 - - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 15c6ae699f083ea6c9716c1098ae9833a56eeb3e -Author: Torsten Kasch -Date: Thu Jul 19 00:06:45 2012 +0200 - - autoconf: Do not assume the shell is bash compatible - - Bug 52197 - - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit f5311da76ec7cd7c1e6cdfc4e18df6dd56e8398b -Author: Albert Astals Cid -Date: Thu Jul 19 00:01:49 2012 +0200 - - pdfseparate: Return 0 on success - - utils/pdfseparate.cc | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -commit dc8833a36b514c13cfd6b1fd4665d2fddd71f357 -Author: Albert Astals Cid -Date: Thu Jul 19 00:01:49 2012 +0200 - - pdfseparate: Return 0 on success - - utils/pdfseparate.cc | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -commit 51f22ca0badfc41c19cba66cabd63184244f81c7 -Author: Thomas Freitag -Date: Mon Jul 16 23:32:23 2012 +0200 - - PSOutputDev: Fix DeviceN images with alternate Lab colorspace in - level 3 PostScript - - Bug #51822 - - poppler/PSOutputDev.cc | 54 - +++++++++++++++++++++++++++++++++++++++++++------- - poppler/PSOutputDev.h | 2 +- - 2 files changed, 48 insertions(+), 8 deletions(-) - -commit 31ef967033407de91109ff46db9c60cb8748bc55 -Author: Thomas Freitag -Date: Mon Jul 16 23:32:23 2012 +0200 - - PSOutputDev: Fix DeviceN images with alternate Lab colorspace in - level 3 PostScript - - Bug #51822 - - poppler/PSOutputDev.cc | 54 - +++++++++++++++++++++++++++++++++++++++++++------- - poppler/PSOutputDev.h | 2 +- - 2 files changed, 48 insertions(+), 8 deletions(-) - -commit f9f5238d32615f93d07afa3aa7384a8b30737203 -Author: Thomas Freitag -Date: Fri Jul 13 00:56:48 2012 +0200 - - Fix Splash::arbitraryTransformImage causes bogus memory allocation - size - - Bug #49523 - - poppler/SplashOutputDev.cc | 2 +- - splash/Splash.cc | 79 - ++++++++++++++++++++++++++-------------------- - splash/Splash.h | 4 +-- - 3 files changed, 48 insertions(+), 37 deletions(-) - -commit 950d5f3dec4bff5d3c523d55689d7b70215dc110 -Author: Thomas Freitag -Date: Fri Jul 13 00:56:48 2012 +0200 - - Fix Splash::arbitraryTransformImage causes bogus memory allocation - size - - Bug #49523 - - poppler/SplashOutputDev.cc | 2 +- - splash/Splash.cc | 79 - ++++++++++++++++++++++++++-------------------- - splash/Splash.h | 4 +-- - 3 files changed, 48 insertions(+), 37 deletions(-) - -commit e09be3bc6ba1290fd31bde0c3d19c4ffcbadbf00 -Author: Albert Astals Cid -Date: Tue Jul 10 23:06:53 2012 +0200 - - 0.20.2 - - CMakeLists.txt | 2 +- - NEWS | 11 +++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - 5 files changed, 15 insertions(+), 4 deletions(-) - -commit e15fe0e1e6accf779caeb1179a8d62161c0aa650 -Author: Thomas Freitag -Date: Thu Jul 5 17:44:02 2012 +0200 - - Fix handling of DeviceN images in level 3 PostScript - - bug #51548 - - poppler/PSOutputDev.cc | 14 -------------- - 1 file changed, 14 deletions(-) - -commit 31837201cf5b3db735c89ef4969105b7a6ab465d -Author: Thomas Freitag -Date: Thu Jul 5 17:44:02 2012 +0200 - - Fix handling of DeviceN images in level 3 PostScript - - bug #51548 - - poppler/PSOutputDev.cc | 14 -------------- - 1 file changed, 14 deletions(-) - -commit 262203bd86403e43034fbfbbeef5a5894a62ecb2 -Author: Albert Astals Cid -Date: Sat Jun 30 14:36:28 2012 +0200 - - [qt4] Refactor part of ::search() functions - - qt4/src/poppler-page-private.h | 7 ++++- - qt4/src/poppler-page.cc | 61 - +++++++++++++++++++----------------------- - 2 files changed, 34 insertions(+), 34 deletions(-) - -commit bd71f80c409dbb47231088c3c6661946ccde6e67 -Author: Adam Reichold -Date: Thu Jun 28 17:42:17 2012 +0200 - - [qt4] add whole-page search method to Poppler::Page - - qt4/src/poppler-page.cc | 39 +++++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-qt4.h | 14 ++++++++++++++ - 2 files changed, 53 insertions(+) - -commit 46ebe7dc84b14ce8dda7b3b1da516b9d99ac3344 -Author: Albert Astals Cid -Date: Fri Jun 29 01:56:55 2012 +0200 - - PSOutputDev: Correct %%DocumentCustomColors - - Bug 51479 - - poppler/PSOutputDev.cc | 20 ++++++++++++++++++++ - 1 file changed, 20 insertions(+) - -commit 02c4e6bf4cc0f5535946fe31815081a40b1de986 -Author: Albert Astals Cid -Date: Fri Jun 29 01:56:55 2012 +0200 - - PSOutputDev: Correct %%DocumentCustomColors - - Bug 51479 - - poppler/PSOutputDev.cc | 20 ++++++++++++++++++++ - 1 file changed, 20 insertions(+) - -commit 2b8d95aeede56c75699bb83ca3b23ea199b81c2c -Author: Albert Astals Cid -Date: Thu Jun 28 00:18:07 2012 +0200 - - Add some security checks to JPXStream decoding - - Fixes crash in broken/fuzzed pdf sent by Mateusz "j00ru" Jurczyk - and Gynvael Coldwind - - poppler/JPXStream.cc | 14 ++++++++++++-- - 1 file changed, 12 insertions(+), 2 deletions(-) - -commit f7990386d268a444c297958e9c50ed27a0825a00 -Author: Albert Astals Cid -Date: Thu Jun 28 00:18:07 2012 +0200 - - Add some security checks to JPXStream decoding - - Fixes crash in broken/fuzzed pdf sent by Mateusz "j00ru" Jurczyk - and Gynvael Coldwind - - poppler/JPXStream.cc | 14 ++++++++++++-- - 1 file changed, 12 insertions(+), 2 deletions(-) - -commit c5c6eed1623506e1206e89cee0b7c887d815ba62 -Author: Albert Astals Cid -Date: Sun Jun 24 23:43:03 2012 +0200 - - Change SplashBitmap gmallocn to gmallocn_checkoverflow - - Fixes abort in KDE bug #302372 - - splash/Splash.cc | 37 +++++++++++++++++++++++-------------- - splash/SplashBitmap.cc | 18 +++++++++++------- - 2 files changed, 34 insertions(+), 21 deletions(-) - -commit f48eb669ae5c729c026554802e666e64399c0900 -Author: Albert Astals Cid -Date: Sun Jun 24 23:43:03 2012 +0200 - - Change SplashBitmap gmallocn to gmallocn_checkoverflow - - Fixes abort in KDE bug #302372 - - splash/Splash.cc | 37 +++++++++++++++++++++++-------------- - splash/SplashBitmap.cc | 18 +++++++++++------- - 2 files changed, 34 insertions(+), 21 deletions(-) - -commit c87738ee234aafc6eda5a263ad789205037020e1 -Author: Thomas Freitag -Date: Sun Jun 24 20:20:38 2012 +0200 - - copy resources content defined in the pages dict - - Fixes bug #51369 - - poppler/PDFDoc.cc | 16 ++++++++++++++-- - 1 file changed, 14 insertions(+), 2 deletions(-) - -commit ff48a5d67a130211fbbb98aa0011bca0c1185114 -Author: Thomas Freitag -Date: Sun Jun 24 20:20:38 2012 +0200 - - copy resources content defined in the pages dict - - Fixes bug #51369 - - poppler/PDFDoc.cc | 16 ++++++++++++++-- - 1 file changed, 14 insertions(+), 2 deletions(-) - -commit 6cdf879e389f05abba30b3fad8083b7fff23056e -Author: Fabio D'Urso -Date: Sun Jun 24 11:48:04 2012 +0200 - - qt4: Do not hang on malformed /Annots objects - - Don't recurse infinitely if the /Annots object contains annotation - dictionaries (according to specs, /Annots must contain *references* - to annotation dictionaries). - - Fixes bug #51361 - - qt4/src/poppler-annotation.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit bd1dab39a857b852c09d21f64254ffc1f24c2df0 -Author: Fabio D'Urso -Date: Sun Jun 24 11:48:04 2012 +0200 - - qt4: Do not hang on malformed /Annots objects - - Don't recurse infinitely if the /Annots object contains annotation - dictionaries (according to specs, /Annots must contain *references* - to annotation dictionaries). - - Fixes bug #51361 - - qt4/src/poppler-annotation.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 31db47d077825045edd1a2d229e873a6f8e09fb1 -Author: Carlos Garcia Campos -Date: Sun Jun 17 12:00:43 2012 +0200 - - Simplify AnnotAppearance::getAppearanceStream() - - - Use a switch instead of if to get the stream object - - Use the return value of dictLookupNF to check whether the object is - null - - Don't fetch the stream to check the reference is valid, this is - already done when used - - poppler/Annot.cc | 50 ++++++++++++++++++-------------------------------- - 1 file changed, 18 insertions(+), 32 deletions(-) - -commit b15d02b92aca1348564e70d0245064bc27eefce8 -Author: Maciej Mrozowski -Date: Fri May 18 01:47:55 2012 +0200 - - Add the possibility of using lcms1 even if lcms2 is installed - - CMakeLists.txt | 20 +++++++++++++------- - configure.ac | 31 +++++++++++++++---------------- - 2 files changed, 28 insertions(+), 23 deletions(-) - -commit 0cc2738737ed411159c8c8045eff5d1a4463ed16 -Author: Mark Brand -Date: Thu Jun 14 20:31:26 2012 +0200 - - fix typo to compile in Windows - - poppler/GlobalParamsWin.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 3575becd60585324bcefc0631b1bac47c1db3c5c -Author: Mark Brand -Date: Thu Jun 14 20:31:26 2012 +0200 - - fix typo to compile in Windows - - poppler/GlobalParamsWin.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 2e1410ea62fe99e52c94f878d02181f0b59f1cd5 -Author: Albert Astals Cid -Date: Mon Jun 11 15:17:59 2012 +0200 - - Add some security checks to JBIG2Stream decoding - - Fixes crash in broken/fuzzed pdf sent by Mateusz "j00ru" Jurczyk - and Gynvael Coldwind - - poppler/JBIG2Stream.cc | 58 - ++++++++++++++++++++++++++++++++++++++------------ - 1 file changed, 44 insertions(+), 14 deletions(-) - -commit 06618065c8a97a5bec125560546b98edfc1210f3 -Author: Albert Astals Cid -Date: Mon Jun 11 15:17:59 2012 +0200 - - Add some security checks to JBIG2Stream decoding - - Fixes crash in broken/fuzzed pdf sent by Mateusz "j00ru" Jurczyk - and Gynvael Coldwind - - poppler/JBIG2Stream.cc | 58 - ++++++++++++++++++++++++++++++++++++++------------ - 1 file changed, 44 insertions(+), 14 deletions(-) - -commit 6a76d21661add4f84ee0859c4e7a4c23e7a63bc4 -Author: Hib Eris -Date: Sun Jun 10 19:44:18 2012 +0200 - - Check value of first page in linearization table - - Fixes crash in broken/fuzzed pdf sent by Mateusz "j00ru" Jurczyk - and Gynvael Coldwind - - poppler/Linearization.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit e3fe88df3646a80945210ba426eb4681a98b55e9 -Author: Hib Eris -Date: Sun Jun 10 19:44:18 2012 +0200 - - Check value of first page in linearization table - - Fixes crash in broken/fuzzed pdf sent by Mateusz "j00ru" Jurczyk - and Gynvael Coldwind - - poppler/Linearization.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 1240eee8c0d0d01113443e0fda87721775a76da9 -Author: Albert Astals Cid -Date: Sun Jun 10 20:42:55 2012 +0200 - - 0.20.1 - - CMakeLists.txt | 4 ++-- - NEWS | 25 +++++++++++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 6 files changed, 31 insertions(+), 6 deletions(-) - -commit d483436517c5d9679fd6f4ec5544128ffcc2188e -Author: Albert Astals Cid -Date: Sun Jun 10 20:15:01 2012 +0200 - - Update copyrights - - poppler/GlobalParamsWin.cc | 1 + - 1 file changed, 1 insertion(+) - -commit c783037619e2b4c101e8ecd7e61c94ee077b4be2 -Author: Albert Astals Cid -Date: Sun Jun 10 20:15:01 2012 +0200 - - Update copyrights - - poppler/GlobalParamsWin.cc | 1 + - 1 file changed, 1 insertion(+) - -commit d791101fbdebf7a3b3f333939f9bbff6bbecf45f -Author: Albert Astals Cid -Date: Sun Jun 10 19:09:17 2012 +0200 - - Do use NULL function - - Fixes crash in broken/fuzzed pdf sent by Mateusz "j00ru" Jurczyk - and Gynvael Coldwind - - poppler/Gfx.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit f3f9d8f28a97338da92c842d5668b0ef3495ef13 -Author: Albert Astals Cid -Date: Sun Jun 10 19:09:17 2012 +0200 - - Do use NULL function - - Fixes crash in broken/fuzzed pdf sent by Mateusz "j00ru" Jurczyk - and Gynvael Coldwind - - poppler/Gfx.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 8b3fa65f293804dab7ae2fd069132d0d6f44bbb2 -Author: Tobias Koenig -Date: Sun Jun 10 17:48:08 2012 +0200 - - [qt4] Add accessor methods for poster information - - qt4/src/poppler-movie.cc | 15 +++++++++++++++ - qt4/src/poppler-qt4.h | 15 +++++++++++++++ - 2 files changed, 30 insertions(+) - -commit e8aa8266254bfd2189d5b5105e3d76caa4cc6713 -Author: Thomas Freitag -Date: Sun Jun 10 16:58:54 2012 +0200 - - use setoverprintmode only if rip knows it - - poppler/PSOutputDev.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 92ef16e3699da949c80716c3fd4b438fe79c134d -Author: Thomas Freitag -Date: Sun Jun 10 16:58:54 2012 +0200 - - use setoverprintmode only if rip knows it - - poppler/PSOutputDev.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 6e3503b5591b105fa92e6cc6568b8819f6acd625 -Author: Fabio D'Urso -Date: Thu May 24 23:17:27 2012 +0200 - - qt4: Keep page rotation into account when normalizing annotation - coords - - If the page is rotated by 90 or 270 degrees, width and height need - to be swapped - - qt4/src/poppler-annotation.cc | 16 ++++++++++++++-- - 1 file changed, 14 insertions(+), 2 deletions(-) - -commit 99aa734ae2d3ba51f840d4c8ef450488fb702a31 -Author: Fabio D'Urso -Date: Thu May 24 23:17:27 2012 +0200 - - qt4: Keep page rotation into account when normalizing annotation - coords - - If the page is rotated by 90 or 270 degrees, width and height need - to be swapped - - qt4/src/poppler-annotation.cc | 16 ++++++++++++++-- - 1 file changed, 14 insertions(+), 2 deletions(-) - -commit 4f2ac544f36aa11747c3e13ff69fc19bdd0136dc -Author: Fabio D'Urso -Date: Sat Jun 9 01:31:29 2012 +0200 - - Fix saving to xml - - The default icon is Note not comment - - qt4/src/poppler-annotation.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit bde31ce7b223abc86d25e06f3d73668b792c70df -Author: Fabio D'Urso -Date: Sat Jun 9 01:31:29 2012 +0200 - - Fix saving to xml - - The default icon is Note not comment - - qt4/src/poppler-annotation.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 0df0aa439eed1d9838a80942e00af08e9acabb8d -Author: Carlos Garcia Campos -Date: Sat Jun 2 17:33:23 2012 +0200 - - glib-demo: Add find options to find demo - - glib/demo/find.c | 61 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++- - 1 file changed, 60 insertions(+), 1 deletion(-) - -commit 52b3ede4bfd1e2288a0efca34da5d6239d3563e9 -Author: Carlos Garcia Campos -Date: Sat Jun 2 16:25:06 2012 +0200 - - glib-demo: Show search matches in a document view - - glib/demo/find.c | 253 - +++++++++++++++++++++++++++++++++++++++++++++++-------- - 1 file changed, 218 insertions(+), 35 deletions(-) - -commit ed0c761c2190a3c1959a60ae9b7961f58a43c939 -Author: Thomas Schenker -Date: Sat Jun 2 11:54:21 2012 +0200 - - glib: Add poppler_page_find_text_with_options - - To be able to search text with options like case sensitive, search - backwards and whole words only. - - https://bugs.freedesktop.org/show_bug.cgi?id=2951 - - glib/poppler-page.cc | 52 - +++++++++++++++++++++++++++---------- - glib/poppler-page.h | 3 +++ - glib/poppler.h | 18 +++++++++++++ - glib/reference/poppler-sections.txt | 2 ++ - 4 files changed, 62 insertions(+), 13 deletions(-) - -commit 126b55c9a44ccb0dba55e758843e9ee4aa43ee2b -Author: Carlos Garcia Campos -Date: Sat Jun 2 17:19:30 2012 +0200 - - Implement whole words only option to search text - - It seems we missed it in the xpdf303 merge. - - poppler/TextOutputDev.cc | 144 - ++++++++++++++++++++++++----------------------- - 1 file changed, 74 insertions(+), 70 deletions(-) - -commit 20210fbb6117649b20f6930031f24b8fc97b773d -Author: Luis Parravicini -Date: Mon May 28 23:44:17 2012 +0200 - - pdftohtml: Add -fontfullname - - Outputs the font name without any substitutions. Bug #49872 - - utils/HtmlFonts.cc | 4 +++- - utils/pdftohtml.1 | 3 +++ - utils/pdftohtml.cc | 4 ++++ - 3 files changed, 10 insertions(+), 1 deletion(-) - -commit 03f979a7e59c4eb5ecb8acc324c7faf700144589 -Author: Gerald Schmidt -Date: Sat May 26 17:46:59 2012 +0200 - - Make the output more xhtml compliant - - utils/HtmlOutputDev.cc | 105 - +++++++++++++++++++++++++------------------------ - 1 file changed, 53 insertions(+), 52 deletions(-) - -commit ba6406222f828e354323223fc4bdb01c1726fb49 -Author: Fabio D'Urso -Date: Mon May 21 18:16:06 2012 +0200 - - Added Annot::removeReferencedObjects + Always set annotations' - page field - - - Now Page::removeAnnot calls Annot::removeReferencedObjects, which - takes care of - removing referenced objects (such as the annot popup and the - appearance streams). - - Previously, Annot's page field was set only if the annotation - dictionary - contained /P - - poppler/Annot.cc | 40 - ++++++++++++++++++++++++++++++++++------ - poppler/Annot.h | 13 +++++++++---- - poppler/Page.cc | 7 ++++--- - poppler/Page.h | 2 +- - qt4/src/poppler-annotation.cc | 8 -------- - 5 files changed, 48 insertions(+), 22 deletions(-) - -commit 9904b8f10abf068a7816bd90976ccbb320387645 -Author: Adrian Johnson -Date: Thu May 24 18:24:48 2012 +0930 - - glib docs: fix typo - - glib/poppler-document.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 028f580056f99719cfb8af7bbe8184ceac02cb16 -Author: Adrian Johnson -Date: Sun May 13 21:36:36 2012 +0930 - - add sustitute font name to GlobalParamsWin32 to fix compilation - - poppler/GlobalParamsWin.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 1916d000a86336213ffd6e9bd44ce873e8955895 -Author: Adrian Johnson -Date: Sat May 12 16:31:38 2012 +0930 - - Include substitute font name in system font cache - - Bug 49826 - - poppler/FontInfo.cc | 1 + - poppler/GlobalParams.cc | 58 - +++++++++++++++++++++++++++---------------------- - 2 files changed, 33 insertions(+), 26 deletions(-) - -commit b47d38e2ccd8563394df89765e277bde95730052 -Author: Adrian Johnson -Date: Thu May 24 18:24:48 2012 +0930 - - glib docs: fix typo - - glib/poppler-document.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 14a29dbff585cbe55247431a346c2ac3e12473fe -Author: Adrian Johnson -Date: Sun May 13 21:36:36 2012 +0930 - - add sustitute font name to GlobalParamsWin32 to fix compilation - - poppler/GlobalParamsWin.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 7436b2c8a853f5121eb7dd13168ab997f1cf7d80 -Author: Adrian Johnson -Date: Sat May 12 16:31:38 2012 +0930 - - Include substitute font name in system font cache - - Bug 49826 - - poppler/FontInfo.cc | 1 + - poppler/GlobalParams.cc | 58 - +++++++++++++++++++++++++++---------------------- - 2 files changed, 33 insertions(+), 26 deletions(-) - -commit 1c6e84555572a6bf3a2e3fbe9a54b40f11c122ad -Author: Fabio D'Urso -Date: Fri May 18 16:22:46 2012 +0200 - - qt4: Make TextAnnotation ctor public - - qt4/src/poppler-annotation.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit fe28614e7aab6e029f4b420353b67a7eea24de36 -Author: Fabio D'Urso -Date: Fri May 18 16:22:46 2012 +0200 - - qt4: Make TextAnnotation ctor public - - qt4/src/poppler-annotation.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 8e504bf2543621973fdaddbd29055ce435540146 -Author: Ville Skyttä -Date: Wed May 16 23:49:01 2012 +0300 - - pdfseparate.1: Syntax fixes. - - utils/pdfseparate.1 | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 918456372548810c9efbf0533fa155034dd081f2 -Author: Ville Skyttä -Date: Wed May 16 23:49:01 2012 +0300 - - pdfseparate.1: Syntax fixes. - - utils/pdfseparate.1 | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 892e486addcbcad619613c7be1ca692a0d36d6e5 -Author: Albert Astals Cid -Date: Mon May 21 20:28:42 2012 +0200 - - Compile++ - - cmake/modules/FindGTK.cmake | 8 ++++---- - glib/demo/CMakeLists.txt | 6 +++--- - test/CMakeLists.txt | 6 +++--- - 3 files changed, 10 insertions(+), 10 deletions(-) - -commit 794e89ed41d03997778fc4c59b7f1ba557b5e6b7 -Author: Albert Astals Cid -Date: Mon May 21 20:18:42 2012 +0200 - - Compile - - glib/CMakeLists.txt | 2 ++ - 1 file changed, 2 insertions(+) - -commit 78e6c9905a52c0cd4bfc1e56874f50689f04a1c6 -Author: Carlos Garcia Campos -Date: Sun May 20 12:11:27 2012 +0200 - - glib-demo: Make text characters list fill and expand in text demo - - glib/demo/text.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 610eb24426d9b36ac7da40a2fceb3dbeeec19a5c -Author: Carlos Garcia Campos -Date: Sun May 20 12:08:09 2012 +0200 - - glib-demo: Add a button to remove annots from the annot view - - glib/demo/annots.c | 48 +++++++++++++++++++++++++++++++++++++++++------- - 1 file changed, 41 insertions(+), 7 deletions(-) - -commit 11a3093e093319e88f14af0ab6c15009104d17ee -Author: Carlos Garcia Campos -Date: Sun May 20 11:22:49 2012 +0200 - - glib: Add poppler_page_remove_annot() - - https://bugs.freedesktop.org/show_bug.cgi?id=40473 - - glib/poppler-page.cc | 19 +++++++++++++++++++ - glib/poppler-page.h | 2 ++ - glib/reference/poppler-sections.txt | 1 + - 3 files changed, 22 insertions(+) - -commit 0dd157ae7f19cd91ea425a607b968f08addc3a40 -Author: Carlos Garcia Campos -Date: Sun May 20 10:37:47 2012 +0200 - - glib: Take a reference of the core annotation when creating a - PopplerAnnot - - This way if the annotation is removed from the page, the core - annotation - object is not destroyed. Also, a new PopplerAnnot that is never - added to - a page doesn't leak the core annotation anymore. - - glib/poppler-annot.cc | 53 - +++++++++++++++++++++------------------------------ - 1 file changed, 22 insertions(+), 31 deletions(-) - -commit f818b842f54d6860920b39778228e8b247b4e761 -Author: Carlos Garcia Campos -Date: Sat May 19 12:32:33 2012 +0200 - - glib-demo: Fix runtime warning - - glib/demo/selections.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit a24e326425e198eeb70c4d9205bb7a0a3a9db297 -Author: Carlos Garcia Campos -Date: Sat May 19 12:09:45 2012 +0200 - - gtk-tests: Port to GTK+ 3.0 - - configure.ac | 4 +- - glib/demo/annots.c | 74 +++++++------- - glib/demo/attachments.c | 4 +- - glib/demo/find.c | 4 +- - glib/demo/fonts.c | 4 +- - glib/demo/forms.c | 64 ++++++------ - glib/demo/images.c | 21 ++-- - glib/demo/info.cc | 67 ++++++------ - glib/demo/layers.c | 22 ++-- - glib/demo/links.c | 6 +- - glib/demo/main.c | 31 ++---- - glib/demo/outline.c | 2 +- - glib/demo/page.c | 23 ++--- - glib/demo/print.c | 14 +-- - glib/demo/render.c | 263 - ++++++++++++++---------------------------------- - glib/demo/selections.c | 77 ++++++-------- - glib/demo/text.c | 22 ++-- - glib/demo/transitions.c | 4 +- - glib/demo/utils.c | 101 +++++++++---------- - glib/demo/utils.h | 6 +- - test/gtk-test.cc | 48 +++++---- - 21 files changed, 350 insertions(+), 511 deletions(-) - -commit 9f7d919e68a26bb7dd809986d8394fe20b750bd0 -Author: Anthony Wesley -Date: Thu May 17 19:54:47 2012 +0200 - - Fix logic on SplashBitmap::writeImgFile - - splash/SplashBitmap.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 87093d1250807f660042295747a012032f84c034 -Author: Anthony Wesley -Date: Thu May 17 19:54:47 2012 +0200 - - Fix logic on SplashBitmap::writeImgFile - - splash/SplashBitmap.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 7e7997e12faccf4c0513811b324a2fd0fa960a96 -Author: Igor Slepchin -Date: Tue May 15 23:16:27 2012 +0200 - - Determine if font is bold or italic based on FontDescriptor. - - Bug #49758 - - utils/HtmlFonts.cc | 24 ++++++++++++++++++------ - utils/HtmlFonts.h | 3 ++- - utils/HtmlOutputDev.cc | 4 +--- - 3 files changed, 21 insertions(+), 10 deletions(-) - -commit 3a249aa8ad5e9f7511bcafd0416ce51c7efe5f4d -Author: Igor Slepchin -Date: Tue May 15 23:16:27 2012 +0200 - - Determine if font is bold or italic based on FontDescriptor. - - Bug #49758 - - utils/HtmlFonts.cc | 24 ++++++++++++++++++------ - utils/HtmlFonts.h | 3 ++- - utils/HtmlOutputDev.cc | 4 +--- - 3 files changed, 21 insertions(+), 10 deletions(-) - -commit ff2c251dbaef9b964af48f51ebb517626ac3145c -Author: Carlos Garcia Campos -Date: Sun May 13 20:13:32 2012 +0200 - - glib-demo: Use poppler_document_new_from_gfile to load the given uri - - glib/demo/main.c | 9 ++------- - 1 file changed, 2 insertions(+), 7 deletions(-) - -commit a7629331ab4ba5b256213af1f1b2954a49953c34 -Author: Carlos Garcia Campos -Date: Sun May 13 20:13:03 2012 +0200 - - glib: Add poppler_document_new_from_gfile - - glib/poppler-document.cc | 46 - +++++++++++++++++++++++++++++++++++++ - glib/poppler-document.h | 4 ++++ - glib/reference/poppler-sections.txt | 1 + - 3 files changed, 51 insertions(+) - -commit 95277b1f481e274ab0ce22ffb44b40437bffa3c8 -Author: Carlos Garcia Campos -Date: Sun May 13 20:11:12 2012 +0200 - - glib Add missing cancellable param in poppler_document_new_from_stream - doc - - glib/poppler-document.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 329bb1e2b4f4b58832847bcf805d19ac0fd5ef02 -Author: Carlos Garcia Campos -Date: Sun May 13 19:45:55 2012 +0200 - - glib: Make sure password is always converted to latin1 - - Remove the utf8 validation since glib API is supposed to always - receive - utf8 strings. - - glib/poppler-document.cc | 38 +++++++++++++++++++------------------- - 1 file changed, 19 insertions(+), 19 deletions(-) - -commit c4bf7b162028a2f9ffcd2baba2759bdb14fae51f -Author: Carlos Garcia Campos -Date: Sun May 13 19:45:55 2012 +0200 - - glib: Make sure password is always converted to latin1 - - Remove the utf8 validation since glib API is supposed to always - receive - utf8 strings. - - glib/poppler-document.cc | 43 ++++++++++++++++++++----------------------- - 1 file changed, 20 insertions(+), 23 deletions(-) - -commit 7714b4e319c48ee915061a172208245ae7c4141b -Author: Carlos Garcia Campos -Date: Sun May 13 19:30:17 2012 +0200 - - glib: Fix memory leak when document fails to load - - glib/poppler-document.cc | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit 4d0786a97e061a752686968bd7976bdda01b1f84 -Author: Carlos Garcia Campos -Date: Sun May 13 19:30:17 2012 +0200 - - glib: Fix memory leak when document fails to load - - glib/poppler-document.cc | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit 1d1c8175c57ebe6518f4252ab92a20286b7d4c6f -Author: Carlos Garcia Campos -Date: Sun May 13 18:41:25 2012 +0200 - - glib: Add poppler_document_new_from_stream - - A PopplerInputStream has been added to handle GMemoryInputStream and - GLocalFileInputStream, since we don't want to cache the contents in - those cases. A PopplerCachedFileLoader has been added to handle all - other cases. - - configure.ac | 10 +-- - glib/Makefile.am | 4 + - glib/poppler-cached-file-loader.cc | 108 +++++++++++++++++++++++++++ - glib/poppler-cached-file-loader.h | 44 +++++++++++ - glib/poppler-document.cc | 69 ++++++++++++++++++ - glib/poppler-document.h | 6 ++ - glib/poppler-input-stream.cc | 141 - ++++++++++++++++++++++++++++++++++++ - glib/poppler-input-stream.h | 74 +++++++++++++++++++ - glib/reference/poppler-docs.sgml | 4 + - glib/reference/poppler-sections.txt | 1 + - poppler-glib-uninstalled.pc.in | 2 +- - poppler-glib.pc.in | 2 +- - 12 files changed, 458 insertions(+), 7 deletions(-) - -commit 13d2aa303eb1fd900f1045efec14af8002477b02 -Author: Thomas Freitag -Date: Sun May 13 17:25:15 2012 +0200 - - remove unnecesary transparency group handling in splash - - Bug #13487 - - poppler/Gfx.cc | 64 - +++++++++++++++++++++++++++++++++++++++++++++- - poppler/Gfx.h | 4 ++- - poppler/GfxState.cc | 4 ++- - poppler/OutputDev.h | 1 + - poppler/SplashOutputDev.cc | 11 ++++++++ - poppler/SplashOutputDev.h | 1 + - 6 files changed, 82 insertions(+), 3 deletions(-) - -commit b477443e8a4c52500529aaf3be76f01a61e85f28 -Author: Thomas Freitag -Date: Sun May 13 17:25:15 2012 +0200 - - remove unnecesary transparency group handling in splash - - Bug #13487 - - poppler/Gfx.cc | 64 - +++++++++++++++++++++++++++++++++++++++++++++- - poppler/Gfx.h | 4 ++- - poppler/GfxState.cc | 4 ++- - poppler/OutputDev.h | 1 + - poppler/SplashOutputDev.cc | 11 ++++++++ - poppler/SplashOutputDev.h | 1 + - 6 files changed, 82 insertions(+), 3 deletions(-) - -commit a76867003a7bff5ab03016156c75b4c928788d50 -Author: Albert Astals Cid -Date: Sun May 13 13:10:40 2012 +0200 - - Distribute cmake/modules/FindLCMS2.cmake - - Bug #49818 - - Makefile.am | 1 + - 1 file changed, 1 insertion(+) - -commit 8f040dec2ce2eae24dd1eb15900d4d284e4b3848 -Author: Albert Astals Cid -Date: Sun May 13 13:10:40 2012 +0200 - - Distribute cmake/modules/FindLCMS2.cmake - - Bug #49818 - - Makefile.am | 1 + - 1 file changed, 1 insertion(+) - -commit 7f47630a7fc19214cd48dbd164ecf577ba35cc46 -Author: Albert Astals Cid -Date: Thu May 10 23:12:04 2012 +0200 - - Compile with the unsupported ENABLE_PLUGINS defined - - poppler/GlobalParams.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 22264cb230fc5902aea14ab43fa013a8ebdbf812 -Author: Albert Astals Cid -Date: Thu May 10 23:04:33 2012 +0200 - - Make it compile - - Sorry :-/ - - goo/gfile.cc | 82 - -------------------------------------------------- - goo/gfile.h | 4 --- - poppler/GlobalParams.h | 2 +- - 3 files changed, 1 insertion(+), 87 deletions(-) - -commit 44bf99a7b8683a077f2a5db50541099c109aa069 -Author: Albert Astals Cid -Date: Thu May 10 22:59:18 2012 +0200 - - Kill the concept of "base dir" - - We are a library so having a "common configuration folder" does - not really - make much sense at a library level, and even less if it's called - .xpdf :D - - Fixes bug 49448 - - goo/gfile.cc | 46 - ---------------------------------------------- - goo/gfile.h | 3 --- - poppler/GfxState.cc | 16 ++-------------- - poppler/GlobalParams.cc | 21 --------------------- - poppler/GlobalParams.h | 3 --- - test/perf-test.cc | 1 - - 6 files changed, 2 insertions(+), 88 deletions(-) - -commit bb091e38a1c0248ba24b0711b4afc0b0524cce10 -Author: Albert Astals Cid -Date: Thu May 10 22:38:41 2012 +0200 - - Make it be something closer to real english - - utils/pdftohtml.1 | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 67f3c3e0d03ec63df7c6028cbd626e384d231c2b -Author: Fabio D'Urso -Date: Wed May 9 16:48:15 2012 +0200 - - GooString formatting: add support for uppercase hexadecimal + Use - it in Annot::layoutText - - goo/GooString.cc | 61 - ++++++++++++++++++++++++++++++++++++++++++++++---------- - goo/GooString.h | 17 ++++++++-------- - poppler/Annot.cc | 2 +- - 3 files changed, 61 insertions(+), 19 deletions(-) - -commit 1f7f8a78409e6bcc90bd32ea2aaa75ed3a7b6218 -Author: Fabio D'Urso -Date: Wed May 9 16:18:05 2012 +0200 - - Use error() instead of fprintf(stderr, ...) in Annot::layoutText - - poppler/Annot.cc | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit a7a2e72f9ba43816a81278e0565d31807ac5ceb5 -Author: Albert Astals Cid -Date: Thu May 10 22:31:24 2012 +0200 - - More gs cleanup and forgot the (C) on modification - - goo/gfile.cc | 2 +- - goo/gfile.h | 2 +- - utils/pdftohtml.cc | 4 ---- - 3 files changed, 2 insertions(+), 6 deletions(-) - -commit ad36d22d1f11339be90403534b921cce120fdbad -Author: Albert Astals Cid -Date: Thu May 10 22:24:40 2012 +0200 - - pdftohtml: Remove the option to invoke gs - - goo/gfile.cc | 8 --- - goo/gfile.h | 3 -- - utils/pdftohtml.1 | 8 +-- - utils/pdftohtml.cc | 149 - ++++++++++++----------------------------------------- - 4 files changed, 36 insertions(+), 132 deletions(-) - -commit 4114c928fa2560937e02319f57937f1c267a9817 -Author: Albert Astals Cid -Date: Thu May 10 21:09:14 2012 +0200 - - 0.20.0 - - CMakeLists.txt | 6 +++--- - NEWS | 16 ++++++++++++++++ - configure.ac | 4 ++-- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 6 files changed, 24 insertions(+), 8 deletions(-) - -commit df05d084cb26807c39695280cd8ea52d13aa1255 -Author: Albert Astals Cid -Date: Thu May 10 20:54:13 2012 +0200 - - Bring back the begin/endMarkedContent virtuals - - For those evil people that keep using poppler internals - - poppler/Gfx.cc | 8 ++++++++ - poppler/OutputDev.cc | 8 +++++++- - poppler/OutputDev.h | 4 +++- - 3 files changed, 18 insertions(+), 2 deletions(-) - -commit b6159fea4a13ecfd1c38b3a666a797c5147dd952 -Author: William Bader -Date: Thu May 10 20:02:19 2012 +0200 - - splash uses cmykTransferC for M, Y and K in two places - - splash/Splash.cc | 14 +++++++------- - 1 file changed, 7 insertions(+), 7 deletions(-) - -commit c2146219d555cab277906daefd2589f9056f536c -Author: Peter Breitenlohner -Date: Thu May 10 13:26:18 2012 +0200 - - Add missing function parameter - - poppler/GlobalParams.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit 753f6ab9347f972223ec21b7ed4b4f7ebed3d420 -Author: Albert Astals Cid -Date: Thu May 3 15:29:57 2012 -0700 - - Compile with ENABLE_PLUGINS defined - - poppler/SecurityHandler.cc | 4 ++-- - poppler/SecurityHandler.h | 16 ++++++++++++++++ - poppler/XpdfPluginAPI.cc | 35 +---------------------------------- - poppler/XpdfPluginAPI.h | 34 +++++++++++++++------------------- - 4 files changed, 34 insertions(+), 55 deletions(-) - -commit 23df93aaf495428b580bafd0fd1f41515828b08d -Author: Albert Astals Cid -Date: Thu May 3 14:50:09 2012 -0700 - - We don't support the keyBinding concept - - remove wrong merge - - poppler/GlobalParams.cc | 1 - - 1 file changed, 1 deletion(-) - -commit e55838b41959acc311e9b00dc390c9816a9afac2 -Author: Jason -Date: Wed May 2 19:35:26 2012 +0200 - - glib: Use delete[] to free array allocated with new[] - - https://bugs.freedesktop.org/show_bug.cgi?id=48447 - - glib/poppler-document.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit dec873463b06bfe76ff48e36282877e6ac11b59d -Author: Albert Astals Cid -Date: Sun Apr 29 23:36:57 2012 +0200 - - Add the objUint type - - poppler/Object.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 50c0b294d08114920a5db711876e20d991f474a6 -Author: Albert Astals Cid -Date: Sun Apr 29 22:33:09 2012 +0200 - - Make sure the index to dcHuffTables and acHuffTables is in bounds - - Found in a fuzzed pdf sent by Mateusz "j00ru" Jurczyk and Gynvael - Coldwind - - poppler/Stream.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 9e36206465289c96cb189c648a6f5121714c647b -Author: Albert Astals Cid -Date: Sun Apr 29 22:18:12 2012 +0200 - - include for memcpy - - splash/SplashBitmap.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 931051fe0bb445545355027d999515bc3d4b32ef -Author: Albert Astals Cid -Date: Sun Apr 29 22:07:34 2012 +0200 - - Make sure the index for refLine is in bounds - - Found in a fuzzed pdf sent by Mateusz "j00ru" Jurczyk and Gynvael - Coldwind - - poppler/Stream.cc | 10 ++++++---- - 1 file changed, 6 insertions(+), 4 deletions(-) - -commit 53b9c2e2806320d0d0e35134b75da5da72514742 -Author: Albert Astals Cid -Date: Sun Apr 29 22:00:18 2012 +0200 - - Just call getNum if isNum is true - - Found in a fuzzed pdf sent by Mateusz "j00ru" Jurczyk and Gynvael - Coldwind - - poppler/Link.cc | 17 ++++++++++------- - 1 file changed, 10 insertions(+), 7 deletions(-) - -commit da8d858c4fc610718a5f14b14dc3a4a11564a73d -Author: Albert Astals Cid -Date: Sun Apr 29 20:28:37 2012 +0200 - - Do not access args[-1] - - Found in a fuzzed pdf sent by Mateusz "j00ru" Jurczyk and Gynvael - Coldwind - - poppler/Gfx.cc | 10 ++++++---- - 1 file changed, 6 insertions(+), 4 deletions(-) - -commit 934b1a7cd502fe5537a350cdfc650989992693f7 -Author: Albert Astals Cid -Date: Sun Apr 29 19:59:15 2012 +0200 - - Do not access invalid lookup indexes - - Found by Mateusz "j00ru" Jurczyk and Gynvael Coldwind - - poppler/GfxState.cc | 13 ++++++++++--- - 1 file changed, 10 insertions(+), 3 deletions(-) - -commit e80fd082914fe29fad7e60c321a747eb8634e413 -Author: Albert Astals Cid -Date: Sun Apr 29 18:27:41 2012 +0200 - - [qt4] the qualified name may be unicode encoded - - qt4/src/poppler-form.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 251be1787a2a003862691f5a825eb3468eceb6a2 -Author: Albert Astals Cid -Date: Sun Apr 29 18:26:42 2012 +0200 - - Fix getFullyQualifiedName with unicode field names - - Based on a patch from Mark Riedesel. - Bug #49256 - - poppler/Form.cc | 71 - +++++++++++++++++++++++++++++++++++++++++++++++++-------- - 1 file changed, 61 insertions(+), 10 deletions(-) - -commit be41f1c7905d695d17e19ced83a1018531d00199 -Author: Albert Astals Cid -Date: Sun Apr 29 16:02:45 2012 +0200 - - SplashOutputDev: Fix rendering of knockout groups - - Bug #12185 - - poppler/SplashOutputDev.cc | 31 ++++++++++++++++++++++++++++--- - splash/Splash.cc | 21 ++++++++++++++++++--- - splash/Splash.h | 6 ++++-- - splash/SplashBitmap.cc | 22 +++++++++++++++++++++- - splash/SplashBitmap.h | 2 ++ - 5 files changed, 73 insertions(+), 9 deletions(-) - -commit 800cb9ec7189a539d64b99fa181cd4126496c1ec -Author: Thomas Freitag -Date: Sat Apr 28 17:15:30 2012 +0200 - - Reconstruct xref table if xref needed but missing - - Bug #40719 - - poppler/XRef.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 410822d7013ce1f61325afdb61d75ea64666755e -Author: Albert Astals Cid -Date: Fri Apr 27 01:10:22 2012 +0200 - - 0.19.4 - - CMakeLists.txt | 4 ++-- - NEWS | 17 +++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 6 files changed, 23 insertions(+), 6 deletions(-) - -commit b1d5c6c0a20a4a24b42de66db23e0f63d10ca52d -Author: Fabio D'Urso -Date: Tue Apr 24 21:00:11 2012 +0200 - - Output XRef stream when incrementally updating if there's already - a XRef stream - - poppler/PDFDoc.cc | 45 ++++++++++++++++++++++++++++++-- - poppler/XRef.cc | 76 - +++++++++++++++++++++++++++++++++++++++++++++++-------- - poppler/XRef.h | 34 +++++++++++++++++++++++++ - 3 files changed, 142 insertions(+), 13 deletions(-) - -commit 2ecf3b2e49a4c35e995d25016b810592260edfeb -Author: Fabio D'Urso -Date: Tue Apr 24 18:10:15 2012 +0200 - - Refactoring of XRef table write support (in preparation for XRef - stream write support) - - - Trailer dictionary creation now lives in its own function - "createTrailerDict" - (that will be used by XRef stream creation too) - - writeXRefTableTrailer (WAS writeTrailer) now takes care of writing - the XRef - table too (previously it was demanded to the caller) - - poppler/PDFDoc.cc | 61 - +++++++++++++++++++++++++++---------------------------- - poppler/PDFDoc.h | 14 ++++++++++--- - poppler/XRef.cc | 2 +- - poppler/XRef.h | 2 +- - utils/pdfunite.cc | 10 +++++---- - 5 files changed, 49 insertions(+), 40 deletions(-) - -commit cf7a20adbd15f901d414ce06825459c33eeef3f5 -Author: Thomas Freitag -Date: Wed Apr 25 18:51:23 2012 +0200 - - Fix slow rendering of pdf with a lot of image masks in pattern - colorspace - - Makes it around 8 times faster - - poppler/CairoOutputDev.cc | 6 +++--- - poppler/CairoOutputDev.h | 6 +++--- - poppler/Gfx.cc | 4 ++-- - poppler/OutputDev.cc | 5 +++-- - poppler/OutputDev.h | 6 +++--- - poppler/PSOutputDev.cc | 4 ++-- - poppler/PSOutputDev.h | 4 ++-- - poppler/SplashOutputDev.cc | 35 +++++++++++------------------------ - poppler/SplashOutputDev.h | 4 ++-- - 9 files changed, 31 insertions(+), 43 deletions(-) - -commit 26fd142a3608283fd41e07b54067a51a9db76e93 -Author: Fabio D'Urso -Date: Sat Apr 21 18:16:46 2012 +0200 - - Preserve z-index after annotation removal - - poppler/Annot.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 7b10014c1fe9ef1cba57fd6b01c63129ac31386a -Author: Fabio D'Urso -Date: Sat Apr 21 17:53:22 2012 +0200 - - Do not remove appearance stream if it's shared with other annotations - - poppler/Annot.cc | 78 - +++++++++++++++++++++++++++++++++++++++++++++++++++++--- - poppler/Annot.h | 6 +++++ - 2 files changed, 80 insertions(+), 4 deletions(-) - -commit 7684c325929493ad9de01a891de0aef197e176dd -Author: Fabio D'Urso -Date: Sat Apr 21 20:26:49 2012 +0200 - - AnnotText: Always force 24x24 size with custom stamps, not only on - first rendering - - poppler/Annot.cc | 21 ++++++++++++--------- - 1 file changed, 12 insertions(+), 9 deletions(-) - -commit 44cd46a6e04a87bd702dab4a662042f69f16c4ad -Author: Albert Astals Cid -Date: Mon Apr 23 20:02:55 2012 +0200 - - Do not try to access nPatches - 1 if nPatches is 0 - - Found by Mateusz "j00ru" Jurczyk and Gynvael Coldwind - - poppler/GfxState.cc | 20 +++++++++++++++++++- - 1 file changed, 19 insertions(+), 1 deletion(-) - -commit a92f87b83e3c6c9078508c644aa09f4f2b14e9cc -Author: Albert Astals Cid -Date: Mon Apr 23 00:06:18 2012 +0200 - - Do not complain if the entry is missing - - Since we are actually looking for non existing entries :D - - poppler/XRef.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 114e113e3278d02baaffd6c0da7fda266283c176 -Author: Fabio D'Urso -Date: Sat Apr 21 21:08:55 2012 +0200 - - Do not allocate XRef entries whose generation number is 65535 - - poppler/XRef.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit ad8785b053aa115b593b2f20073e2989d59a77c9 -Author: Albert Astals Cid -Date: Wed Apr 18 22:51:33 2012 +0200 - - Remove duplicate call - - utils/pdftohtml.cc | 1 - - 1 file changed, 1 deletion(-) - -commit 80d4e1843c56801508f476fed64ecb3201ba18c8 -Author: Fabio D'Urso -Date: Tue Apr 17 20:25:57 2012 +0200 - - Do not draw border in AnnotText::draw - - poppler/Annot.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit a1e3d868ccd7fb84d52d94754d8681c97119fb6e -Author: Fabio D'Urso -Date: Fri Mar 30 21:52:04 2012 +0200 - - Save/restore gfx state when drawing annot border - - poppler/Gfx.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 7fbeaac5c0d0240564add6c252c1ba7c14639d98 -Author: Albert Astals Cid -Date: Tue Apr 17 20:36:51 2012 +0200 - - Be sure we are checking a non free entry - - poppler/XRef.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit d1254c7e8e995302542093968a0c2967f3c0b5ff -Author: Thomas Freitag -Date: Tue Apr 17 20:36:03 2012 +0200 - - Do not complain if the entry does not exist - - XRef::getNumEntry is only trying to find which entry a given stream - pos belongs so no need to cry if the entry is not there - Bug 48679 - - poppler/XRef.cc | 10 ++++++---- - poppler/XRef.h | 2 +- - 2 files changed, 7 insertions(+), 5 deletions(-) - -commit bcbe9497a4fa50b41852abd538ad139c7b6693e5 -Author: suzuki toshiya -Date: Tue Apr 17 20:21:58 2012 +0200 - - Copying graphics library CFLAGS to cpp frontend Makefile.am. - - Because poppler-image.cpp includes PNGWriter.h, JpegWriter.h, - TiffWriter.h, - CFLAGS to include libpng, libjpeg and libtiff headers are expected. - - cpp/Makefile.am | 22 +++++++++++++++++++++- - 1 file changed, 21 insertions(+), 1 deletion(-) - -commit 44c9df8277877ee1021317a3b6c253f80310f826 -Author: suzuki toshiya -Date: Tue Apr 17 20:21:00 2012 +0200 - - Do not clear FREETYPE_CFLAGS, FREETYPE_LIBS before PKG_CHECK_MODULES() - - Although configure --help says as if environmental variables - FREETYPE_CFLAGS and FREETYPE_LIBS will overwrite the values obtained - by pkg-config. But it is not. These help messages are automatically - given - by pkg-config macro (so I guess no poppler developer designed so - intentionally). - - In current configure, FREETYPE_CFLAGS, FREETYPE_LIBS are cleared - before - PKG_CONFIG_MODULES(), like: - - dnl Check for freetype headers - FREETYPE_LIBS= - FREETYPE_CFLAGS= - - PKG_CHECK_MODULES(FREETYPE, freetype2, - [freetype_pkgconfig=yes], - [freetype_pkgconfig=no]) - - if test "x$freetype_pkgconfig" = "xyes"; then - - AC_DEFINE(HAVE_FREETYPE_H, 1, [Have FreeType2 include - files]) - - else - - AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, no) - [...] - - Checking the history why these values are cleared, it seems that - the initial revision of poppler did not use pkg-config to detect - FREETYPE_CFLAGS, _LIBS. At that time, only freetype-config is used. - In later, when PKG_CHECK_MODULES is introduced, it was accidentally - introduced AFTER the clearning of FREETYPE_CFLAGS,_LIBS. As a result, - the inconsistency between "configure --help" and what configure does - really. I propose to move the clearance of FREETYPE_CFLAGS,_LIBS - just before AC_PATH_PROG, to make PKG_CHECK_MODULES catch the - environmental - values. - - configure.ac | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 9e0f0368e543df46b40cbd7bed6fdc1abf846e7d -Author: suzuki toshiya -Date: Tue Apr 17 20:19:41 2012 +0200 - - Do not append "-ansi" to CXXFLAG, if "-std=XXX" is already specified. - - SplashOutputDev.cc uses isfinite() function (defined by math.h). - isfinite() was standardized in C99, and imported to C++0x in later. - - In QNX header file system, isfinite() is disabled by default, - the definition of __STDC_VERSION__ > 199901 is required to enable it. - In the case of GCC, "-std=c99" (for C) or "-std=gnu++0x" (for C++) - is expected. - - But, current configure of poppler appends "-ansi" flag for CXXFLAGS, - if the compiler is known to be GNU. "-ansi" is C89 or C++98, - so isfinite() - is unavailable. I propose a patch NOT to "-ansi" flag, if CXXFLAGS - includes "-std=XXX" already. - - configure.ac | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -commit 2f1e7ef252b8d1f7ee6004825c2926f0f5e181a5 -Author: Albert Astals Cid -Date: Thu Apr 12 23:11:41 2012 +0200 - - Do not crash in broken documents - - They might trigger an xref reconstruct and then i could not be in - bounds anymore - Crash found by Joel Voss of Leviathan Security Group - - poppler/XRef.cc | 11 +++++++++++ - 1 file changed, 11 insertions(+) - -commit 19fb9caecb1b265a8b8651e9bcf4b779f593fefd -Author: Albert Astals Cid -Date: Thu Apr 12 22:24:50 2012 +0200 - - Fix crash when the destination file does not exist - - Issue found by Joel Voss of Leviathan Security Group - - utils/HtmlOutputDev.cc | 18 ++++++++++-------- - 1 file changed, 10 insertions(+), 8 deletions(-) - -commit fa4848eae370437ab1b9863124e9a340830f66c7 -Author: Adrian Johnson -Date: Fri Apr 13 22:11:01 2012 +0930 - - man pages: add missing section heading - - utils/pdftotext.1 | 1 + - 1 file changed, 1 insertion(+) - -commit 08a14aa37b177bb4586869857ae678cb4bcd4039 -Author: Albert Astals Cid -Date: Thu Apr 12 21:52:30 2012 +0200 - - 0.19.3 - - CMakeLists.txt | 4 ++-- - NEWS | 26 +++++++++++++++++++++++++- - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/CMakeLists.txt | 2 +- - qt4/src/Doxyfile | 2 +- - qt4/src/Makefile.am | 2 +- - 8 files changed, 33 insertions(+), 9 deletions(-) - -commit 52227b59d1fa2a2029bfff2f8a167efd81faebbb -Author: Albert Astals Cid -Date: Thu Apr 12 20:52:55 2012 +0200 - - Update (C) - - poppler/CairoFontEngine.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 40cb3f27f4dcad4fe8c48f0b638eac7913fc3722 -Author: Albert Astals Cid -Date: Thu Apr 12 20:50:38 2012 +0200 - - Do not pass those params to createGfx since they aren't used - - glib/poppler-page.cc | 4 ++-- - poppler/Page.cc | 9 +++------ - poppler/Page.h | 5 ++--- - 3 files changed, 7 insertions(+), 11 deletions(-) - -commit 9a10d31fca7f060f24bae9efe15662f02a9684ca -Author: Fabio D'Urso -Date: Thu Apr 12 20:31:23 2012 +0200 - - qt4: Remove unimplemented revision setters from public API - - qt4/src/poppler-annotation-private.h | 2 ++ - qt4/src/poppler-annotation.cc | 62 - ++++++++---------------------------- - qt4/src/poppler-annotation.h | 13 -------- - 3 files changed, 16 insertions(+), 61 deletions(-) - -commit 0531329aeb8783c48f056929e6e81cebda33500f -Author: Albert Astals Cid -Date: Thu Apr 12 20:07:13 2012 +0200 - - [qt4] Mark the dummy stuff as deprecated - - qt4/src/poppler-annotation.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 67b7b2bdd0943680437d96349c3415aa40082cbb -Author: Albert Astals Cid -Date: Thu Apr 12 20:06:52 2012 +0200 - - [qt4] initialize the dummy members here too - - qt4/src/poppler-annotation.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit bf171382afb6b50284c3855e3a1815a15ec34366 -Author: Albert Astals Cid -Date: Thu Apr 12 19:24:42 2012 +0200 - - Add since markers - - qt4/src/poppler-annotation.h | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -commit e36fd775394ee752c0f62f789359c72b52094975 -Author: Albert Astals Cid -Date: Thu Apr 12 18:58:29 2012 +0200 - - Remove unneeded forward declaration - - qt4/src/poppler-qt4.h | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit c1aa4a8c0aa9d46757e3849776acac42731e02d1 -Author: Fabio D'Urso -Date: Thu Apr 12 00:39:33 2012 +0200 - - qt4: Annotation appearance invalidation - - Call Annot::invalidateAppearance every time the visual aspect - is changed - - qt4/src/poppler-annotation.cc | 34 ++++++++++++++++++++++++++++++++++ - 1 file changed, 34 insertions(+) - -commit 4338ae354c66e4df8d7d70a156517e27b3b80539 -Author: Fabio D'Urso -Date: Sun Mar 25 22:58:33 2012 +0200 - - qt4: Added HideAnnotations option to PSConverter - - qt4/src/poppler-ps-converter.cc | 23 ++++++++++++++++++++++- - qt4/src/poppler-qt4.h | 3 ++- - 2 files changed, 24 insertions(+), 2 deletions(-) - -commit e50993b3b47a759c93ccdeeaef289d6985b05bb1 -Author: Fabio D'Urso -Date: Thu Mar 22 19:58:12 2012 +0100 - - qt4: DOM annotation store - Black color is different than invalid - color - - qt4/src/poppler-annotation.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 4739a6a02097f110c37defdfa616351459902806 -Author: Fabio D'Urso -Date: Mon Mar 19 19:17:33 2012 +0100 - - qt4: Annotation removal - - qt4/src/poppler-annotation-private.h | 3 +++ - qt4/src/poppler-annotation.cc | 29 +++++++++++++++++++++++++++++ - qt4/src/poppler-page.cc | 5 +++++ - qt4/src/poppler-qt4.h | 8 ++++++++ - 4 files changed, 45 insertions(+) - -commit 25a64d69aaab61c8cf944107e649e19920244a2b -Author: Fabio D'Urso -Date: Tue Mar 20 01:46:07 2012 +0100 - - qt4: TextAnnotation write support + basic textFont getter - - Also makes inplaceText a synoym for contents - - qt4/src/poppler-annotation.cc | 159 - ++++++++++++++++++++++++++++++++---------- - 1 file changed, 124 insertions(+), 35 deletions(-) - -commit a31a8118ba07aa7f90c69130476fb7d86f8614ad -Author: Fabio D'Urso -Date: Sun Mar 11 23:57:51 2012 +0100 - - qt4: GeomAnnotation, InkAnnotation and CaretAnnotation write support - - qt4/src/poppler-annotation.cc | 103 - ++++++++++++++++++++++++++++++++++++++---- - qt4/src/poppler-annotation.h | 6 +-- - 2 files changed, 96 insertions(+), 13 deletions(-) - -commit e4052b52002447772e24571fd13f0f22fd2bfb16 -Author: Fabio D'Urso -Date: Sat Mar 10 17:48:56 2012 +0100 - - qt4: HighlightAnnotation and StampAnnotation write support - - qt4/src/poppler-annotation.cc | 96 - +++++++++++++++++++++++++++++++++++++++---- - qt4/src/poppler-annotation.h | 4 +- - 2 files changed, 91 insertions(+), 9 deletions(-) - -commit b5e948b6130cdb04387a8244179337c7904dcd03 -Author: Fabio D'Urso -Date: Wed Mar 14 17:44:50 2012 +0100 - - qt4: Annotation insertion and LineAnnotation support - - This patch adds Page::addAnnotation to insert new annotations in - a page. - The only annotation type that can be added is LineAnnotation. Support - for other - types will be added in the next patches. - - qt4/src/poppler-annotation-private.h | 12 ++ - qt4/src/poppler-annotation.cc | 297 - +++++++++++++++++++++++++++++++++-- - qt4/src/poppler-annotation.h | 4 +- - qt4/src/poppler-page.cc | 5 + - qt4/src/poppler-qt4.h | 9 ++ - 5 files changed, 316 insertions(+), 11 deletions(-) - -commit 20b4feec612448be8a800173ddadbf257657477e -Author: Fabio D'Urso -Date: Fri Mar 9 19:31:16 2012 +0100 - - qt4: Basic setters to edit annotations - - qt4/src/poppler-annotation-helper.h | 15 ++++ - qt4/src/poppler-annotation-private.h | 1 + - qt4/src/poppler-annotation.cc | 128 - ++++++++++++++++++++++++++++++++--- - 3 files changed, 135 insertions(+), 9 deletions(-) - -commit 0e8c35b59f0fba926b30c9a87823c92ae03bf116 -Author: Fabio D'Urso -Date: Fri Mar 9 01:04:28 2012 +0100 - - qt4: Changes to Annotation API (part 2/2) - - 1) Moved annotation data retrieval logic to getters for types of - annotations - that will be made editable in next patches. - Others (Link, FileAttachment, Sound, Movie and Screen) are still - entirely filled - at creation time. - - 2) TextAnnotation's callout points setter now takes an array, not just - individual points. - - 3) AnnotationPrivate::pdfObjectReference replaced with a getter - method that - directly queries the tied Annot object (if any) - - qt4/src/poppler-annotation-helper.h | 31 +- - qt4/src/poppler-annotation-private.h | 23 +- - qt4/src/poppler-annotation.cc | 1254 - +++++++++++++++++++++++++++++++--- - qt4/src/poppler-annotation.h | 58 +- - qt4/src/poppler-link.cc | 2 +- - qt4/src/poppler-page.cc | 778 +-------------------- - qt4/src/poppler-qt4.h | 4 +- - 7 files changed, 1217 insertions(+), 933 deletions(-) - -commit 73b91207649a81740183e2288809d3b84b52f595 -Author: Fabio D'Urso -Date: Wed Mar 7 17:05:50 2012 +0100 - - qt4: Changes to Annotation API (part 1/2) - - This is part 1/2 of a change in annotation API. It breaks both source - and binary - compatibility. - - Note that, even though DOM methods are partially modified by this - patch, their - output is 100% backward compatible. Therefore code relying only on - DOM methods - (i.e. AnnotationUtils methods) will keep working. - - 1) Style and Popup container classes - - Style and Popup (previously known as Window) properties are now - wrapped in - container classes. In both of them, private data is implicitly shared. - The old Window structure is removed, but an undocumented window - field is still - exported to make Okular 4.8.0 compile. It must not be used. - - 2) Revisions - - The Annotation::Revision structure was removed, because it added an - extra layer - of indirection that can be avoided. Now revision scope and type - are stored - directly in the target Annotation, and Annotation::revisions() - returns a list - of pointers to child annotations. - - 3) All constructors are temporarily made private - - This patch hides all constructors from user code. Subsequent - patches will - restore them in the same patch as their type-specific creation - support. - - 4) Minor fixes - - Popup size was incorrectly stored as an integer value, now - it's part of - a QRectF. - - Typo: LinkAnnotation::linkDestionation() --> linkDestination - - Dash array is now exported as QVector instead of - a marks/spaces - integer pair - - GeomAnnotation's geometricalPointWidth removed, because it - was never - referenced and it doesn't exist in PDF specs - - 5) AnnotationPrivate data is now explicitly shared - Annotation private data has been rearranged so that it's now - possible to - uniformly give ownership of all Annotation objects to the caller. - Previously Page::annotations() did leave ownership to user, but - Annotation::revisions() didn't. Now both of them give ownership - to user. - - qt4/src/poppler-annotation-private.h | 19 +- - qt4/src/poppler-annotation.cc | 1022 - ++++++++++++++++++++++++---------- - qt4/src/poppler-annotation.h | 292 +++++++--- - qt4/src/poppler-page.cc | 92 ++- - qt4/src/poppler-qt4.h | 6 + - 5 files changed, 997 insertions(+), 434 deletions(-) - -commit 7f0f080277d35f6f2e426ca2a3ff76c2856daeaf -Author: Adrian Johnson -Date: Tue Apr 10 00:08:49 2012 +0930 - - cairo: fix stroke pattern with transparency group - - Cairo copy path/append path with device offsets is broken. Use GfxPath - instead. - - Bug 48468 - - poppler/CairoOutputDev.cc | 15 ++++++--------- - poppler/CairoOutputDev.h | 4 ++-- - 2 files changed, 8 insertions(+), 11 deletions(-) - -commit 5ea305c3924cead302092378ab67300c3099afd9 -Author: Adrian Johnson -Date: Sun Apr 8 23:11:30 2012 +0930 - - cairo: only align stroke coords for horizontal and vertical lines - - Bug 48318 - - poppler/CairoOutputDev.cc | 80 - ++++++++++++++++++++++++++++++++++++----------- - poppler/CairoOutputDev.h | 2 +- - 2 files changed, 62 insertions(+), 20 deletions(-) - -commit 8414d8f621b8abb018e80f2255cfb511a1e558d4 -Author: Adrian Johnson -Date: Mon Apr 9 12:08:20 2012 +0930 - - cairo: ensure 0 width lines with stroke_adjust are aligned - - Previously the code path for 0 width lines ignored the stroke_adjust - setting. Rearrange the code so the code path for stroke_adjust == TRUE - is performed first (this will also set 0 width lines to 1 pixel wide). - - poppler/CairoOutputDev.cc | 42 +++++++++++++++++++++--------------------- - 1 file changed, 21 insertions(+), 21 deletions(-) - -commit af1a84eb90656de68bb14f2c4ae4f813c51bc3a3 -Author: Adrian Johnson -Date: Mon Apr 9 17:17:29 2012 +0930 - - cairo: fix paintTransparencyGroup when both mask and fill opacity - are required - - Bug 48453 - - poppler/CairoOutputDev.cc | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -commit 46b3a70cae3b37cb4270a83afaddd6734442b752 -Author: Fabio D'Urso -Date: Mon Apr 9 19:32:24 2012 +0200 - - Caption text rendering in AnnotLine - - poppler/Annot.cc | 262 - ++++++++++++++++++++++++++++++++++++++----------------- - poppler/Annot.h | 2 + - 2 files changed, 183 insertions(+), 81 deletions(-) - -commit 855607828447ecec2c8444650d015e21bd17d2e2 -Author: Fabio D'Urso -Date: Mon Apr 9 16:45:50 2012 +0200 - - AnnotFreeText rendering improvements (auto word-wrap, quadding, - border style, font/border color) - - poppler/Annot.cc | 146 - +++++++++++++++++++++++++++++++++++++++++++------------ - poppler/Annot.h | 1 + - 2 files changed, 115 insertions(+), 32 deletions(-) - -commit 80f662162698c1ec27771d9cf5e2e6bc3d21c4df -Author: Ihar Filipau -Date: Thu Apr 12 00:19:26 2012 +0200 - - Fix the mask inversion - - utils/HtmlOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 06591d848e53598973f7d5fddac50785a46e8027 -Author: Thomas Freitag -Date: Wed Apr 11 23:49:29 2012 +0200 - - Fix Splash CMYK merge error - - Mail says - ****** - Hi, - - playing around with the attached PDF to get a better CMYK support for - the blend mode soft light, I encountered that I made a big mistake - during merge in the CMYK part of splash. I fixed that. The attached - patch also includes the small enhancement I made in soft light - routine. - ****** - - poppler/SplashOutputDev.cc | 9 +++++++++ - splash/Splash.cc | 2 +- - 2 files changed, 10 insertions(+), 1 deletion(-) - -commit 1f45afde6410f03c79fcf4b66d5834079879d38f -Author: Ihar Filipau -Date: Mon Apr 9 19:17:41 2012 +0200 - - Add producer and version to xml output - - utils/HtmlOutputDev.cc | 2 +- - utils/pdf2xml.dtd | 4 ++++ - 2 files changed, 5 insertions(+), 1 deletion(-) - -commit cef6ac0ebbf8451beaadb3ddb6c991bbb7239432 -Author: Fabio D'Urso -Date: Sun Apr 8 23:15:15 2012 +0200 - - FIX: Do not append a NUL character to Unicode page labels - - poppler/PageLabelInfo.cc | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit 3d4985f14e54ddcc64ea654b23e931b7e6acfbdc -Author: Fabio D'Urso -Date: Sat Apr 7 11:28:36 2012 +0200 - - Do not trust the rect of AnnotTextMarkup when drawing - - poppler/Annot.cc | 43 +++++++++++++++++++++++++++++-------------- - 1 file changed, 29 insertions(+), 14 deletions(-) - -commit c6296cd8c1ca398beac20f1e88c87b9082386247 -Author: Fabio D'Urso -Date: Sat Apr 7 00:30:54 2012 +0200 - - Do not trust the rect of AnnotLine, AnnotPolygon and AnnotInk - when drawing - - poppler/Annot.cc | 126 - ++++++++++++++++++++++++++++++++++++++++++++----------- - poppler/Annot.h | 27 ++++++++++++ - 2 files changed, 128 insertions(+), 25 deletions(-) - -commit 503620ae74d719da52e3374725e490c62f7be7a3 -Author: Fabio D'Urso -Date: Thu Mar 29 19:07:05 2012 +0200 - - Do not recreate Annots when writing to PS, Export poppler-generated - Annot appearance resource dict - - 1) With previous code each Annot object was reconstructed from the - pdf object when - writing to PS, leading to the fact that writeDocSetup couldn't see the - generated appearance. - This patch makes writeDocSetup use the same Annots object returned by - Page::getAnnots. - - 2) This patch also enables each Annot subtype to control the exported - resources. AnnotFreeText uses this new method to export font - information. - - 3) Comment fixed in Page.h: Page::getAnnots does *not* give away - ownership, in - fact the returned object is destroyed by ~Page. - - poppler/Annot.cc | 28 ++++++++++++++++++++++++++++ - poppler/Annot.h | 5 +++-- - poppler/FontInfo.cc | 11 ++++------- - poppler/PSOutputDev.cc | 12 +++--------- - poppler/Page.h | 2 +- - 5 files changed, 39 insertions(+), 19 deletions(-) - -commit 2733504890333b0925d95e01310726d11fed44d8 -Author: Fabio D'Urso -Date: Fri Mar 23 20:54:58 2012 +0100 - - Basic AnnotFreeText rendering (hardcoded font, WinAnsi characters - only) - - This patch also moves layoutText and writeString from AnnotWidget - to Annot - - poppler/Annot.cc | 137 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++- - poppler/Annot.h | 11 +++-- - 2 files changed, 142 insertions(+), 6 deletions(-) - -commit 3023a59c0a1a5974b232f6f8cb629eabb6797616 -Author: Fabio D'Urso -Date: Sun Mar 25 22:04:11 2012 +0200 - - AnnotTextMarkup rendering improvements - - 1) FIX: Wrong coords in typeUnderline and typeStrikeout - 2) Implementation of typeSquiggly - 3) FIX: Form creation is common to all markup types - - poppler/Annot.cc | 92 - ++++++++++++++++++++++++++++++++++---------------------- - 1 file changed, 56 insertions(+), 36 deletions(-) - -commit 8927ddc448edc016043107e88e3bc3b2b8b03269 -Author: Fabio D'Urso -Date: Thu Mar 22 17:33:01 2012 +0100 - - Improvements to AnnotLine::draw - - poppler/Annot.cc | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- - 1 file changed, 46 insertions(+), 4 deletions(-) - -commit bd7a40fd0312c753d1871558b566376304f1ff35 -Author: Fabio D'Urso -Date: Wed Mar 21 22:48:05 2012 +0100 - - AnnotInk rendering - - poppler/Annot.cc | 62 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Annot.h | 2 ++ - 2 files changed, 64 insertions(+) - -commit 6a8794abe639db8284db079e028cbcd66e138884 -Author: Fabio D'Urso -Date: Wed Mar 21 22:33:13 2012 +0100 - - AnnotPolygon rendering - - poppler/Annot.cc | 87 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Annot.h | 2 ++ - 2 files changed, 89 insertions(+) - -commit f389c50458079f24164b1c12b1151c8617485acb -Author: Fabio D'Urso -Date: Wed Mar 21 21:12:59 2012 +0100 - - Do not fill AnnotGeometry with transparent color - - Previously it was filled with black. - - poppler/Annot.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit c63cc22dd82f827305ad57f241ad49998f2a1c23 -Author: Albert Astals Cid -Date: Sun Apr 8 12:28:17 2012 +0200 - - Remove extra copy() (memleak) - - poppler/GlobalParams.cc | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit ed0c9640abcbea459e3a276ee0b27631b01c32c4 -Author: Albert Astals Cid -Date: Sun Apr 8 12:24:20 2012 +0200 - - Do not crash if mallocing too much memory - - Fixes crash in - https://ritdml.rit.edu/bitstream/handle/1850/11220/TYehThesis1992.pdf?sequence=1 - even though the page is still unrendered - - poppler/JBIG2Stream.cc | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -commit f1e621adbbb74ec709022b2a31195331651c83fa -Author: Adrian Johnson -Date: Sun Apr 8 19:42:05 2012 +0930 - - cairo: use correct userfont font bbox - - cairo 1.12 started clipping text to the font bbox - - Bug 48399 - - poppler/CairoFontEngine.cc | 24 ++++++++++++++++++++++++ - 1 file changed, 24 insertions(+) - -commit f5b708c3e04ba50756cd9f9530cf82f547443ce9 -Author: Suzuki Toshiya -Date: Fri Apr 6 15:22:36 2012 +0200 - - ttc<->ttf fallback is expected for CJK font list in GlobalParamsWin.cc - - Bug 48046 - - poppler/GlobalParamsWin.cc | 224 - ++++++++++++++++++++++++++------------------- - 1 file changed, 128 insertions(+), 96 deletions(-) - -commit 4e940b14a6fddde9a1714976ff8045e26cbf7d40 -Author: Adrian Johnson -Date: Mon Apr 2 20:03:11 2012 +0930 - - cairo: fix regression caused by mesh gradients - - poppler/CairoOutputDev.cc | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit 74a7d963de75c0097eedcf4224d13cf275a64757 -Author: Carlos Garcia Campos -Date: Sun Apr 1 19:35:48 2012 +0200 - - regtest: remove debug print to show bisect exit status in Bisect.py - - regtest/Bisect.py | 1 - - 1 file changed, 1 deletion(-) - -commit 2749db77eb8ccdbc4b0771163c8942f882f259f4 -Author: Carlos Garcia Campos -Date: Sun Apr 1 19:20:37 2012 +0200 - - regtest: Fix crash when creating HTML report for a single test - - regtest/commands/create-report.py | 5 +---- - 1 file changed, 1 insertion(+), 4 deletions(-) - -commit 1c8e1bb637347d0d31945f9d265b29e7b49396e2 -Author: Carlos Garcia Campos -Date: Sun Apr 1 19:11:57 2012 +0200 - - regtest: Don't show results for crashed or failed to run tests in - HTML report - - regtest/HTMLReport.py | 2 ++ - 1 file changed, 2 insertions(+) - -commit a5f4936dfb3e60ca37f932cc066aa10765f3cbc9 -Author: Fabio D'Urso -Date: Sat Mar 24 23:13:48 2012 +0100 - - Fix: annotDisplayDecideCbk was not propagated - - poppler/OutputDev.h | 6 +++++- - poppler/PSOutputDev.cc | 11 ++++++++--- - poppler/PSOutputDev.h | 5 ++++- - poppler/Page.cc | 3 ++- - utils/HtmlOutputDev.h | 5 ++++- - 5 files changed, 23 insertions(+), 7 deletions(-) - -commit aab8c9a026f781da47ecedd453e225f906361444 -Author: Albert Astals Cid -Date: Thu Mar 29 21:49:38 2012 +0200 - - Increase version - - CMakeLists.txt | 4 ++-- - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 5 files changed, 6 insertions(+), 6 deletions(-) - -commit f7e65b62480631d0485167a81a588a176630dd8d -Author: Albert Astals Cid -Date: Thu Mar 29 21:48:11 2012 +0200 - - 0.19.2 news - - NEWS | 23 ++++++++++++++++++++++- - 1 file changed, 22 insertions(+), 1 deletion(-) - -commit 627e072eb1edbfabf549656e9abf10100ed7340c -Author: Albert Astals Cid -Date: Thu Mar 29 21:40:13 2012 +0200 - - Update copyrights - - poppler/TextOutputDev.cc | 1 + - 1 file changed, 1 insertion(+) - -commit e9ad888b003d343d8ca60f044c7cf10a8df81cf4 -Author: Albert Astals Cid -Date: Thu Mar 29 19:49:34 2012 +0200 - - Add quotes to the poppler version define - - poppler/poppler-config.h.cmake | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 8172bb03b6e8f1c16e1a152fb251b10446f54129 -Author: Peter Breitenlohner -Date: Mon Mar 26 11:13:34 2012 +0200 - - define POPPLER_VERSION as C string - - Signed-off-by: Peter Breitenlohner - - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 4a38d933d06d189317b1b9028c3fa4ae2a1551af -Author: Suzuki Toshiya -Date: Thu Mar 29 19:34:25 2012 +0200 - - per-collection fallback for missing CID-keyed fonts on Win32 - - poppler/GlobalParamsWin.cc | 38 ++++++++++++++++++++++++++++++++++---- - 1 file changed, 34 insertions(+), 4 deletions(-) - -commit a0b3e0938e08847d10c5d7b7528c7c5d43a7a3b8 -Author: Hib Eris -Date: Thu Mar 29 07:52:30 2012 +0200 - - Fix help message - - Partial credit goes to suzuki toshiya - - configure.ac | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 631224dc0c721119c91984f1940c9e51edf17eca -Author: Fabio D'Urso -Date: Tue Mar 20 00:56:50 2012 +0100 - - Annotation removal - - poppler/Annot.cc | 17 +++++++++++++++++ - poppler/Annot.h | 1 + - poppler/Page.cc | 36 ++++++++++++++++++++++++++++++++++++ - poppler/Page.h | 3 +++ - 4 files changed, 57 insertions(+) - -commit 20476370a445a26f1fae9db6ad58727ee3c63550 -Author: Fabio D'Urso -Date: Wed Mar 28 23:16:37 2012 +0200 - - Basic support for Annot appearance stream removal and invalidation - - poppler/Annot.cc | 190 - +++++++++++++++++++++++++++++++++++++++++-------------- - poppler/Annot.h | 29 +++++++-- - 2 files changed, 168 insertions(+), 51 deletions(-) - -commit e9a066c3a53cc1cb73dd43a243390ae4e3c76ca3 -Author: Albert Astals Cid -Date: Wed Mar 28 23:33:37 2012 +0200 - - Fix another typo in macGlyphNames - - fofi/FoFiTrueType.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 3d277b230e806a648fcc6d9e7af39370aa89c2ae -Author: Adrian Johnson -Date: Sat Feb 18 09:19:51 2012 +1030 - - Fix typo in "mu" glyph name in truetype 'post' table standard mac - ordering - - The standard mac ordering table is at: - - https://developer.apple.com/fonts/ttrefman/rm06/Chap6post.html - - fofi/FoFiTrueType.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 47b910d35b2cf5914ed4c07f751c5e8c304be7fc -Author: suzuki toshiya -Date: Wed Mar 28 20:21:44 2012 +0200 - - Add quotes - - this is quite small fix. In poppler's configure, basically the shell - variables are not enclosed, and not quoted, aslike - if test x$use_glib = x; then - This syntax make the test command confused when use_glib is multi-word - value, as, "no (required cairo output)". In such case, test cannot - know - how to evaluate the token "no" "(required" "cairo", so some "syntax - error" - messages are given. Thus, quoting of the variable would be safer. - - configure.ac | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 78224609f6c1d87deee72b60a8f8f9f6c36ac75f -Author: Albert Astals Cid -Date: Wed Mar 28 20:21:11 2012 +0200 - - Workaround Windows problem with libjpeg - - In libjpeg6b, there is a type definition conflict issue in jmorecfg.h. - jmorecfg.h typedefs INT16 as short, INT32 as long. The latter conflict - with basetsd.h of Microsoft Windows SDK or MinGW that typedefs INT32 - as int. basetsd.h is included by windows.h, so, if the users work with - ANSI C features only, the conflict does not appear, it would be the - background why such fundamental error has been preserved. - Anyway, jmorecfg.h designer was aware about the conflict with - X11 headers - (Xmd.h defines INT16, INT32, etc), so if we pretend as if Xmd.h were - included (by defining XMD_H), this issue can be bypassed. Attached - patch - checks the conflict, then, if there is a conflict, tries XMD_H - trick, and - uses it if it works. If jmorecfg.h or basetsd.h was manually fixed to - prevent this issue, this trick is not used. - - configure.ac | 42 ++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 42 insertions(+) - -commit d8cf31f8c7e190939525ad68cd4617fb48fea60e -Author: suzuki toshiya -Date: Wed Mar 28 20:20:43 2012 +0200 - - update Makefile.am to reflect LIBJPEG_CFLAGS, LIBTIFF_CFLAGS, - LIBPNG_CFLAGS for related sources. - - goo/Makefile.am | 15 +++++++++++++++ - poppler/Makefile.am | 6 ++++++ - splash/Makefile.am | 16 ++++++++++++++++ - utils/Makefile.am | 6 ++++++ - 4 files changed, 43 insertions(+) - -commit f0c13f5efc641c63627b8f0b0815b6b511d8d196 -Author: suzuki toshiya -Date: Wed Mar 28 20:20:06 2012 +0200 - - Configure improvements for libs in non default paths - - evaluate pkg-config-like environmental variables like LIBJPEG_CFLAGS, - LIBJPEG_LIBS, LIBTIFF_CFLAGS and LIBTIFF_LIBS in configuration. - - configure.ac | 50 ++++++++++++++++++++++++++++++++++++++++++++------ - 1 file changed, 44 insertions(+), 6 deletions(-) - -commit e55f485d803cb1f82e0d8a53d1998e1887c7920f -Author: suzuki toshiya -Date: Wed Mar 28 20:19:08 2012 +0200 - - Improve m4/libjpeg.m4 - - m4/libjpeg.m4 uses USER_INCLUDES and USER_LDFLAGS in it, but - USER_INCLUDES is not reflected when jpeglib.h is searched. - this patch modifies m4/libjpeg.m4 to reflect USER_INCLUDES - when jpeglib.h is searched. - - m4/libjpeg.m4 | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit e88c17d45220eea60a3dd7fab26a067616388c5f -Author: Albert Astals Cid -Date: Wed Mar 28 20:05:45 2012 +0200 - - Fix compile in windows - - poppler/GlobalParamsWin.cc | 35 ++++++++++++++++++++++++++++++----- - 1 file changed, 30 insertions(+), 5 deletions(-) - -commit ee0eaabe24019d2af226ef03e3f456787525e040 -Author: Fabio D'Urso -Date: Mon Mar 19 00:05:49 2012 +0100 - - Added Array::remove (and Object::arrayRemove) - - poppler/Array.cc | 13 +++++++++++++ - poppler/Array.h | 4 ++++ - poppler/Object.h | 5 +++++ - 3 files changed, 22 insertions(+) - -commit d6a1b7dcaeac1e49533519b9f8a279fd64d04c67 -Author: Thomas Freitag -Date: Tue Mar 27 00:00:05 2012 +0200 - - Some regression fixes/improvements - - I just finished the patch for these regressions, they had differents - reasons - 1. In CharCodeToUnicode::mapToUnicode the identity support was missing - 2. The new algorithms for axial and radial shading caused problems in - cairo. I revert these changes but removed the examination of hidden - content (this is already done in the calling function) - 3. The examination of optional hidden content in showing text - was wrong: - of course hidden text should not be shown, but text parameters - like text - position in the state must be changed! - 4. Searching and finding fonts especially with base14 fonts should be - more exact than just looking at the base14 name (i.e. fixed width - and so - on) when using fontconfig. I implement that to find the best font - fitting to the needs. - - poppler/CharCodeToUnicode.cc | 5 + - poppler/Gfx.cc | 329 - ++++++++++++++++++++----------------------- - poppler/GfxFont.cc | 3 +- - poppler/GlobalParams.cc | 78 +++++++--- - poppler/GlobalParams.h | 6 +- - 5 files changed, 218 insertions(+), 203 deletions(-) - -commit a5257efe00d0fe850b1abe5c552f7581027ac64c -Author: Fabio D'Urso -Date: Mon Mar 26 19:28:55 2012 +0200 - - Re-added forceRasterize to PSOutputDev (and qt4 fix too)‏ - - The patch restores the forceRasterize argument in PSOutputDev ctors. - Commit 6ee907f291427b8751a872b31210bf32e8d2b722 had removed it, - turning it - into a global param. - As a side effect, this patch also fixes qt4/poppler-ps-converter, - which had - not been updated to the new signature, and thus produced corrupted - output if - forceRasterization was set. - - glib/poppler-page.cc | 2 +- - poppler/GlobalParams.cc | 16 ---------------- - poppler/GlobalParams.h | 3 --- - poppler/PSOutputDev.cc | 6 +++++- - poppler/PSOutputDev.h | 3 +++ - 5 files changed, 9 insertions(+), 21 deletions(-) - -commit 55d039ada063a9427de6dd59846ce1570ab26e9f -Author: Suzuki Toshiya -Date: Mon Mar 26 22:31:29 2012 +0200 - - CJK improvements - - More info in the mailing list threads - * script names for vertical writing mode should be differentiated - for CJK - * 2 workarounds for a Korean font on Microsoft Windows - - fofi/FoFiTrueType.cc | 47 ++++++++++++++++++++++++++++++++++++----------- - fofi/FoFiTrueType.h | 8 +++++++- - poppler/GfxFont.cc | 14 ++++++++------ - 3 files changed, 51 insertions(+), 18 deletions(-) - -commit a8b0fa4d07480242afba7751995e38eaf3147ac5 -Author: Horst Prote -Date: Mon Mar 26 21:04:32 2012 +1030 - - don't add newline to last line extracted by TextSelectionDumper - - Bug 45955 - - poppler/TextOutputDev.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit c40e2315cd796ba928969d13a761f5f19d8438fc -Author: Adrian Johnson -Date: Fri Mar 23 21:49:42 2012 +1030 - - cairo: use a transparency group with - setSoftMaskFromImageMask/unsetSoftMaskFromImageMask - - Drawing a tiling pattern between setSoftMaskFromImageMask and - unsetSoftMaskFromImageMask clears the softmask. - - Similar to Splash, create a transparency group in - setSoftMaskFromImageMask. Pop and paint the group in - unsetSoftMaskFromImageMask. The saveState/restoreState is to ensure - the softmask is restored before painting the group. - - Bug 47739 - - poppler/CairoOutputDev.cc | 16 ++++++++++++++++ - 1 file changed, 16 insertions(+) - -commit 7b57afea2e433fc7b6f359a62b1289f0e1da3267 -Author: Adrian Johnson -Date: Sat Mar 24 08:27:34 2012 +1030 - - cairo: update cairo mesh pattern to 1.12 api - - Now that a stable version of cairo with mesh gradient support is - released update poppler to use this api. - - poppler/CairoOutputDev.cc | 40 ++++++++++++++++++++-------------------- - poppler/CairoOutputDev.h | 4 ++-- - 2 files changed, 22 insertions(+), 22 deletions(-) - -commit 2f156b34fc8755ddd2a32cac830f3073d6b2c481 -Author: Suzuki Toshiya -Date: Fri Mar 23 20:00:18 2012 +0100 - - Fix compile in mingw-gcc - - poppler/GlobalParamsWin.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 06b6db92dd1ec32f9a55347073f8b533aa074ee1 -Author: Fabio D'Urso -Date: Sun Mar 18 23:58:05 2012 +0100 - - Added XRef::removeIndirectObject - - poppler/PDFDoc.cc | 15 ++++++++++----- - poppler/XRef.cc | 15 +++++++++++++++ - poppler/XRef.h | 2 ++ - 3 files changed, 27 insertions(+), 5 deletions(-) - -commit a2e9b7c02ffa0e5edc4da18cc726993bc92fc684 -Author: Fabio D'Urso -Date: Mon Mar 19 19:17:09 2012 +0100 - - Fix in AnnotMarkup's popup window handling - - AnnotPopup's ref was previously set to the *parent* annot, now - it's correctly - set to the *popup* annot's own. - - poppler/Annot.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 05641304df67beae546a2fe18071f3be52707aa8 -Author: Fabio D'Urso -Date: Mon Mar 19 20:56:45 2012 +0100 - - Basic Annot border editing support - - poppler/Annot.cc | 23 +++++++++++++++++++++++ - poppler/Annot.h | 9 +++++++++ - 2 files changed, 32 insertions(+) - -commit 3e6275a05066c152b265cc27275d9e4107c089e9 -Author: Fabio D'Urso -Date: Fri Mar 16 21:47:02 2012 +0100 - - Yet new setters to AnnotFreeText - - poppler/Annot.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++ - poppler/Annot.h | 2 ++ - 2 files changed, 47 insertions(+) - -commit f69f41056fc8cd8a70b38024f255e9074af20bdc -Author: Pino Toscano -Date: Tue Mar 20 15:18:33 2012 +0100 - - cmake: reset CMAKE_REQUIRED_INCLUDES/CMAKE_REQUIRED_LIBRARIES - - cmake/modules/FindLIBOPENJPEG.cmake | 3 +++ - 1 file changed, 3 insertions(+) - -commit 4a9238441a5317c3304296e4e6430cccefe8322c -Author: Ihar Filipau -Date: Fri Mar 16 00:07:45 2012 +0100 - - Flip images if they need to - - Bug 32340 - - utils/HtmlOutputDev.cc | 50 - ++++++++++++++++++++++++++++++++++++++++++++++++-- - 1 file changed, 48 insertions(+), 2 deletions(-) - -commit 6d68d0d3acc8c8e0d9d310b2e1ba2b07d6bfe942 -Author: Ihar Filipau -Date: Thu Mar 15 22:56:10 2012 +0100 - - pdftohtml: extract mask images even if they are not JPEG - - Bug #47186 - - utils/HtmlOutputDev.cc | 203 - +++++++++++++++++++++++++++++++------------------ - utils/HtmlOutputDev.h | 3 + - 2 files changed, 131 insertions(+), 75 deletions(-) - -commit 60155e0fc7224a6b479bf62133f72c460fe48078 -Author: Albert Astals Cid -Date: Thu Mar 15 20:46:53 2012 +0100 - - Install poppler-media.h - - qt4/src/Makefile.am | 1 + - 1 file changed, 1 insertion(+) - -commit 6a173844d5ca6f32e188406ab14cae6a7548fc1d -Author: Albert Astals Cid -Date: Thu Mar 15 20:44:12 2012 +0100 - - Add the export - - qt4/src/poppler-media.h | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit e401f8e6ba3e18d5a3a4920cd111b2174c75f415 -Author: Albert Astals Cid -Date: Thu Mar 15 20:32:12 2012 +0100 - - Increase version and sonames - - CMakeLists.txt | 4 ++-- - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - glib/CMakeLists.txt | 2 +- - glib/Makefile.am | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/CMakeLists.txt | 2 +- - qt4/src/Doxyfile | 2 +- - qt4/src/Makefile.am | 2 +- - 9 files changed, 10 insertions(+), 10 deletions(-) - -commit ce059698e8c5097f75e7a0f828af0936aa104af0 -Author: Albert Astals Cid -Date: Thu Mar 15 20:27:45 2012 +0100 - - 0.19.1 news - - Also inclusing 0.18.x ones - - NEWS | 110 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 110 insertions(+) - -commit 2041d5721871adb2a23999c16ecbdc60abb7b1c4 -Author: Albert Astals Cid -Date: Thu Mar 15 20:20:31 2012 +0100 - - Update C years - - poppler/CMap.h | 1 + - poppler/GfxFont.h | 2 +- - poppler/Rendition.cc | 1 + - 3 files changed, 3 insertions(+), 1 deletion(-) - -commit 95d684aa2a87d01296f5e93516f2ac3f54adbec8 -Author: Guillermo Amaral -Date: Thu Mar 15 20:13:20 2012 +0100 - - Remove the QIODevice and go with a not so good but more safer - QByteArray - - Bug #47336 - - qt4/src/CMakeLists.txt | 1 - - qt4/src/Makefile.am | 1 - - qt4/src/poppler-media.cc | 35 ++++++++++----- - qt4/src/poppler-media.h | 4 +- - qt4/src/poppler-page.cc | 1 - - qt4/src/poppler-streamsequentialdevice-private.h | 51 - --------------------- - qt4/src/poppler-streamsequentialdevice.cc | 56 - ------------------------ - 7 files changed, 26 insertions(+), 123 deletions(-) - -commit 9fee12f9bee7252db0974ef69870b69ff1452053 -Author: Albert Astals Cid -Date: Thu Mar 15 19:23:47 2012 +0100 - - Compile++ - - qt4/src/Makefile.am | 2 ++ - 1 file changed, 2 insertions(+) - -commit aa1e6d12d063a64a22841f7996101b45aa680ec7 -Author: Guillermo Amaral -Date: Thu Mar 15 00:35:31 2012 +0100 - - Added media rendition support for Qt4 - - qt4/src/CMakeLists.txt | 3 + - qt4/src/poppler-annotation.cc | 66 ++++++++++ - qt4/src/poppler-annotation.h | 47 ++++++- - qt4/src/poppler-link.cc | 44 +++++++ - qt4/src/poppler-link.h | 38 +++++- - qt4/src/poppler-media.cc | 149 - +++++++++++++++++++++++ - qt4/src/poppler-media.h | 94 ++++++++++++++ - qt4/src/poppler-page.cc | 32 ++++- - qt4/src/poppler-qt4.h | 2 + - qt4/src/poppler-streamsequentialdevice-private.h | 51 ++++++++ - qt4/src/poppler-streamsequentialdevice.cc | 56 +++++++++ - 11 files changed, 579 insertions(+), 3 deletions(-) - -commit 258e2197afa49e60b0b13a05408fc8d484dd8147 -Author: Fabio D'Urso -Date: Wed Mar 14 23:25:00 2012 +0100 - - Added some new setters to AnnotFreeText - - poppler/Annot.cc | 39 +++++++++++++++++++++++++++++++++++++++ - poppler/Annot.h | 4 ++++ - 2 files changed, 43 insertions(+) - -commit 84a62ac157e03880c1c1eda60c3927bd4414640e -Author: Fabio D'Urso -Date: Wed Mar 14 23:24:28 2012 +0100 - - Added some new setters to AnnotGeometry, AnnotInk and AnnotCaret - - poppler/Annot.cc | 116 - +++++++++++++++++++++++++++++++++++++++++-------------- - poppler/Annot.h | 10 +++++ - 2 files changed, 96 insertions(+), 30 deletions(-) - -commit 233c9a097bdc382f6a2eb6319ee15528c72e9632 -Author: Fabio D'Urso -Date: Wed Mar 14 23:23:59 2012 +0100 - - Added some new setters to AnnotTextMarkup and AnnotStamp - - poppler/Annot.cc | 61 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Annot.h | 11 ++++++++-- - 2 files changed, 70 insertions(+), 2 deletions(-) - -commit 8fb3ac6cf66233b80959ba99a2c706111050f5f1 -Author: Fabio D'Urso -Date: Wed Mar 14 23:23:23 2012 +0100 - - Added Page::getDoc() - - poppler/Page.h | 2 ++ - 1 file changed, 2 insertions(+) - -commit dc4cb07c1e735006d5168e0e65f5143d7fc53e12 -Author: Fabio D'Urso -Date: Wed Mar 14 23:22:10 2012 +0100 - - Added some new setters to AnnotLine and AnnotPolygon - - poppler/Annot.cc | 201 - +++++++++++++++++++++++++++++++++++++++++++++++++++++-- - poppler/Annot.h | 16 +++++ - 2 files changed, 211 insertions(+), 6 deletions(-) - -commit 4931018eecc37dbbe0df1a456347ab200f1b057a -Author: Fabio D'Urso -Date: Wed Mar 14 23:21:07 2012 +0100 - - Make Dict::set remove the entry if object is Null - - poppler/Dict.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 13ac2c0bed3fa5515a3c068488cb6a0b17410a97 -Author: Fabio D'Urso -Date: Wed Mar 14 23:20:13 2012 +0100 - - Added some new setters to Annot and AnnotMarkup - - poppler/Annot.cc | 94 - ++++++++++++++++++++++++++++++++++++++++++++++++++++---- - poppler/Annot.h | 8 +++++ - 2 files changed, 96 insertions(+), 6 deletions(-) - -commit aa2b5ffa7961aac0aea33ae9a42bf1f38a756b1b -Author: Pino Toscano -Date: Wed Mar 14 16:25:35 2012 +0100 - - qt4: replace ObjectReference with simplier Ref - - instead of roll out a new (still private) version of Ref, just use - it for private annotation and link data; - this needed a couple of explicit initializations of Ref (since it's - a simple struct with no methods) and a private operator== for it - - qt4/src/CMakeLists.txt | 1 - - qt4/src/poppler-annotation-private.h | 4 +- - qt4/src/poppler-annotation.cc | 1 + - qt4/src/poppler-link.cc | 16 ++++--- - qt4/src/poppler-link.h | 5 +- - qt4/src/poppler-objectreference.cc | 89 - ------------------------------------ - qt4/src/poppler-objectreference_p.h | 77 ------------------------------- - qt4/src/poppler-page.cc | 7 ++- - 8 files changed, 21 insertions(+), 179 deletions(-) - -commit e5b914b2bfbb5e95ecde5f1ce148374b1d58dadd -Author: Ihar Filipau -Date: Tue Mar 13 23:54:26 2012 +0100 - - Add possibilty of controlling word breaks percentage - - Bug #47022 - - utils/HtmlOutputDev.cc | 7 +++++-- - utils/pdftohtml.1 | 5 +++++ - utils/pdftohtml.cc | 7 +++++++ - 3 files changed, 17 insertions(+), 2 deletions(-) - -commit 4388cb69114e406ec29e8b6976d1a900e4ab1b7d -Author: Albert Astals Cid -Date: Sun Mar 11 23:37:39 2012 +0100 - - Make doUpdateFont protected - - So that people inheriting from SplashOutputDev *yuck* can use it - more easily - Bug 46622 - - poppler/SplashOutputDev.h | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 448cfc431b7067af38da51e725ac0f1b2a0bc8f8 -Author: Tobias Koenig -Date: Sun Mar 11 23:22:18 2012 +0100 - - support for LinkMovie object in Qt4 frontend - - Bug #40561 - - qt4/src/CMakeLists.txt | 1 + - qt4/src/poppler-annotation-private.h | 4 ++ - qt4/src/poppler-annotation.h | 4 ++ - qt4/src/poppler-link.cc | 42 +++++++++++++---- - qt4/src/poppler-link.h | 43 +++++++++++++++-- - qt4/src/poppler-objectreference.cc | 89 - ++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-objectreference_p.h | 77 +++++++++++++++++++++++++++++++ - qt4/src/poppler-page.cc | 39 ++++++++++++---- - 8 files changed, 276 insertions(+), 23 deletions(-) - -commit a0d151deabf8243c98ff9953f8a43bb56fbf95a9 -Author: Carlos Garcia Campos -Date: Sun Mar 11 16:05:15 2012 +0100 - - regtest: Add find-regression command to run git bisect automatically - - regtest/Bisect.py | 113 - ++++++++++++++++++++++++++++++++++++ - regtest/builder/__init__.py | 86 +++++++++++++++++++++++++++ - regtest/builder/autotools.py | 63 ++++++++++++++++++++ - regtest/commands/find-regression.py | 77 ++++++++++++++++++++++++ - 4 files changed, 339 insertions(+) - -commit 856768c380ecea30ce9727b81c4c44b4f9489626 -Author: Carlos Garcia Campos -Date: Sat Mar 10 18:15:58 2012 +0100 - - regtest: Add information about skipped tests in the summary - - regtest/TestRun.py | 12 +++++++++--- - 1 file changed, 9 insertions(+), 3 deletions(-) - -commit 508c7c3ef1f22459daa822f8287cab382119e753 -Author: Tobias Koenig -Date: Wed Mar 7 18:35:05 2012 +0100 - - Fix logic error in Rendition parsing code - - Make the rendition object invalid when both P an C entries are not - present or are invalid in Media Rendition dictionary. - - https://bugs.freedesktop.org/show_bug.cgi?id=47063 - - poppler/Rendition.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 68625258ab3cfc3e8e10a727e397f80bed0d1f5c -Author: Adrian Johnson -Date: Sun Mar 4 18:37:53 2012 +1030 - - glib demo: make ctrl-q quit the demo - - glib/demo/main.c | 9 +++++++++ - 1 file changed, 9 insertions(+) - -commit 684b47727ba810ad6bf239e2838aa65b6f6cec36 -Author: Adrian Johnson -Date: Sun Mar 4 18:10:49 2012 +1030 - - glib demo: show font encoding in font demo - - glib/demo/fonts.c | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -commit 48c08d28645d82ab9d67433a0150f6e1ba24b7c6 -Author: Adrian Johnson -Date: Sun Mar 4 17:49:56 2012 +1030 - - glib: add poppler_fonts_iter_get_encoding - - glib/poppler-document.cc | 26 ++++++++++++++++++++++++++ - glib/poppler-document.h | 1 + - glib/reference/poppler-sections.txt | 1 + - 3 files changed, 28 insertions(+) - -commit 8d935569a977675afac35cf1bd5f2611b6a771b6 -Author: Albert Astals Cid -Date: Mon Mar 5 21:59:09 2012 +0100 - - Fix regression in some PSOutputDev array sizing - - poppler/PSOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 2484bc0f29aef74c45ea39ef1e24804ed736154c -Author: Albert Astals Cid -Date: Sun Mar 4 23:47:24 2012 +0100 - - Fix mismatch in some functions declarations - - goo/GooString.h | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 35c960d198d2efa97d15e962662114c5c31b8d20 -Author: Even Rouault -Date: Sun Mar 4 20:32:42 2012 +0100 - - Do not crash on malformed files with 0 bits in the color map of - an image - - poppler/Gfx.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit dae29c6c201cd69cbf4f008de865cc19a36f29b3 -Author: Thomas Freitag -Date: Sun Mar 4 15:22:02 2012 +0100 - - CJK substitute implementation on WIndows platforms. - - When You install ghostscript on WIndows You're able to switch on CJK - support. This will create a cidfmap file in the gs-lib directory. The - ps file which creates it (mkcidfm.ps) runs over the windows font - directory and tries to create a suitable substitution table for - missing - CJK fonts. The cidfmap file is more or less PDF like, so it's - quite easy - to parse it with our parser and create a substitution table in - GlobalParamsWin and use that table. But I expect it in the poppler - data - dir instead of searching for ghostscript installation. If it is not - there, it always returns the default CID font of point 2. - You can either copy it from the gs lib directory or create it with the - ghostscript tool calling - - gswin32c -q -dBATCH -sFONTDIR= - -sCIDFMAP=/cidfmap mkcidfm.ps - - poppler/GlobalParams.cc | 5 +++ - poppler/GlobalParams.h | 2 + - poppler/GlobalParamsWin.cc | 106 - ++++++++++++++++++++++++++++++++++++++++----- - 3 files changed, 103 insertions(+), 10 deletions(-) - -commit 32e47ee03840cc8f21c00497025864d77edb75f5 -Author: Thomas Freitag -Date: Sun Mar 4 15:21:13 2012 +0100 - - Improve CJK suport in PSOutputDev - - 1. Adapt bug fix for bug 11413 to the postscript device - 2. A small bug fix when locateFont doesn't find a suitable font and - returns a null pointer - - to 1.: - Adapting the implementation of the bug fix for splash and cairo to the - postscript device was quite easy. But my first proofs of the - output with - ghostscript 8.71 shows some regressions where the CJK chars have a - smaller height than the default square of the font. But the "48" - in the - output of bug-poppler11413.pdf which is set in a "normal" font but - rotated was at the right position. Then I stepped to ghostscript 9.04, - and now the CJK chars were shown correctly, but the 48 was positioned - wrong. But because of these different tests I think that it is still a - problem in ghostscript when using a mix of CJK fonts and "normal" - fonts. - BTW, also Acrobat X distiller has problems with the position of the - "48"! - - to 2.: - On my first tests with PDF which uses non embedded CJK fonts on - Windows - I got crashes. Reason for it was that GlobalParamWin returns - Helvetica, - which is not a CID font, but locateFont accepts here only CID - fonts and - therefore returns a NULL pointer. I first fixed that and then - decided to - return as default MS Mincho if a CID font is expected. - - poppler/PSOutputDev.cc | 203 - ++++++++++++++++++++++--------------------------- - 1 file changed, 92 insertions(+), 111 deletions(-) - -commit 61037a6de157e39331ae7a8b12ee5a115fd7e936 -Author: Adrian Johnson -Date: Sun Mar 4 17:40:40 2012 +1030 - - glib demo: fix typo - - glib/demo/selections.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit aff5b0a4f04c12ad7733aedbc9997367f5873aa1 -Author: Carlos Garcia Campos -Date: Sat Mar 3 20:10:17 2012 +0100 - - regtest: Ignore backends with no results when creating html report - - regtest/HTMLReport.py | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 9d28b8db3561845f4ca94c29479a259ceaf78bc5 -Author: Carlos Garcia Campos -Date: Sat Mar 3 14:42:51 2012 +0100 - - regtest: Add --pretty-diff option to create-report command - - It includes a pretty-diff link to make a bit easier to check - differences - in test results. For images it creates a html with javascript that - toggles actual and expected image, using the same code than WebKit - layout test results. For text files it uses HtmlDiff class from python - difflib. It's an option disabled by default because pretty diff - for text - files is very slow. - - regtest/HTMLReport.py | 128 - +++++++++++++++++++++++++++++++++++++- - regtest/commands/create-report.py | 4 ++ - 2 files changed, 129 insertions(+), 3 deletions(-) - -commit 670ea176495b8b580daba061840c914714bf422d -Author: Adrian Johnson -Date: Fri Mar 2 22:22:16 2012 +1030 - - pdffonts: list the encoding of each font - - Bug 46888 - - poppler/CMap.h | 2 ++ - poppler/FontInfo.cc | 3 +++ - poppler/FontInfo.h | 2 ++ - poppler/GfxFont.cc | 26 ++++++++++++++++++++++++++ - poppler/GfxFont.h | 4 ++++ - utils/pdffonts.1 | 3 +++ - utils/pdffonts.cc | 7 ++++--- - 7 files changed, 44 insertions(+), 3 deletions(-) - -commit 3ab6b5ebf3b6c0d59bcb2ec68eae1aa95cab1d0e -Author: William Bader -Date: Fri Mar 2 19:40:44 2012 +0100 - - Fix pdftops -passfonts regression - - This patch fixes pdftops -passfonts by using the new psFontPassthrough - variable - consistently and removing the old psSubstFonts and its setter and - getter in - GlobalParams. - - Bug 46744 - - poppler/GlobalParams.cc | 9 +-------- - poppler/GlobalParams.h | 4 +--- - utils/pdftops.cc | 10 +++++----- - 3 files changed, 7 insertions(+), 16 deletions(-) - -commit 6c1ee34424b1122c0a2222b776d8d475f7c555cd -Author: Adrian Johnson -Date: Fri Mar 2 18:41:58 2012 +1030 - - Update poppler copyright - - poppler/poppler-config.h.cmake | 2 +- - poppler/poppler-config.h.in | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit cdb1350d1e28cf3bceda75736ca91e13d193de84 -Author: Albert Astals Cid -Date: Thu Mar 1 18:58:02 2012 +0100 - - Increase versions - - CMakeLists.txt | 4 ++-- - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - glib/CMakeLists.txt | 2 +- - glib/Makefile.am | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/CMakeLists.txt | 2 +- - qt4/src/Doxyfile | 2 +- - qt4/src/Makefile.am | 2 +- - 9 files changed, 10 insertions(+), 10 deletions(-) - -commit 2c9e6fa5b3bc6cd01618c3fb4f46533bfce97466 -Author: Albert Astals Cid -Date: Thu Mar 1 18:48:17 2012 +0100 - - 0.19.0 news file - - NEWS | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 48 insertions(+) - -commit 14f6abfcb83f91755e6de05cd33870934bba3cfb -Author: Albert Astals Cid -Date: Thu Mar 1 17:53:25 2012 +0100 - - Update copyrights - - goo/JpegWriter.cc | 2 +- - poppler/CairoFontEngine.cc | 1 + - poppler/CairoOutputDev.cc | 3 ++- - poppler/CairoOutputDev.h | 2 +- - poppler/CairoRescaleBox.cc | 15 +++++++++++++++ - poppler/FontInfo.cc | 2 +- - poppler/FontInfo.h | 1 + - poppler/Gfx.cc | 2 +- - poppler/GfxFont.cc | 1 + - poppler/GlobalParams.cc | 2 ++ - poppler/GlobalParams.h | 1 + - poppler/Lexer.cc | 1 + - poppler/NameToUnicodeTable.h | 2 +- - utils/ImageOutputDev.cc | 1 + - utils/ImageOutputDev.h | 1 + - utils/parseargs.cc | 1 + - utils/parseargs.h | 1 + - utils/pdffonts.cc | 1 + - utils/pdfimages.cc | 1 + - utils/pdftocairo.cc | 2 +- - utils/pdftoppm.cc | 2 +- - 21 files changed, 37 insertions(+), 8 deletions(-) - -commit e63ca8184168f824575be9bbb64e9b1eac1eff94 -Author: Adrian Johnson -Date: Thu Mar 1 21:46:12 2012 +1030 - - pdftocairo: document that -scale-to will preserve aspect ratio - - based on pdftpppm patch 7ec31b8dc40ec8a3534fbb89964aa011aeb81f5e - - utils/pdftocairo.1 | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit fa82a7ce1372e5976ad95624115fcd7a4d9bd22c -Author: Adrian Johnson -Date: Thu Mar 1 21:43:32 2012 +1030 - - pdftocairo: allow one of -scale-to-[xy] = -1 to mean the aspect - ratio is to be preserved - - based on pdftoppm patch 38ace7db5de0b2b247fd520e48a8f26e5d28c9d7 - - utils/pdftocairo.1 | 8 ++++++-- - utils/pdftocairo.cc | 8 ++++++-- - 2 files changed, 12 insertions(+), 4 deletions(-) - -commit a2b008223ad6887f00d76c535f2b0b0f13f52b76 -Author: Adrian Johnson -Date: Tue Feb 28 21:38:19 2012 +1030 - - glib: add copy button to selections demo - - glib/demo/selections.c | 20 ++++++++++++++++++++ - 1 file changed, 20 insertions(+) - -commit b666d19308a043206e405c7e9d4ad709d68d331b -Author: Adrian Johnson -Date: Tue Feb 28 21:07:06 2012 +1030 - - glib: show substitute font name in demo - - glib/demo/fonts.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit 18bc59fcf5a59b1fd51a631c02e900790c3a6dc0 -Author: Adrian Johnson -Date: Tue Feb 28 21:06:38 2012 +1030 - - glib: add poppler_fonts_iter_get_substitute_name - - glib/poppler-document.cc | 27 +++++++++++++++++++++++++++ - glib/poppler-document.h | 1 + - glib/reference/poppler-docs.sgml | 4 ++++ - glib/reference/poppler-sections.txt | 1 + - 4 files changed, 33 insertions(+) - -commit 4eaafe67de79fb63ebf61f031a97bbc0ed6a8891 -Author: Albert Astals Cid -Date: Wed Feb 29 23:22:34 2012 +0100 - - Change nnnnnn to number - - This way people won't expect it to be six fixed digits - Bug #46708 - - utils/pdftoppm.1 | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit aec6cb67951e56e4557a11c4fdf301e585268fe4 -Author: William Bader -Date: Wed Feb 29 23:18:16 2012 +0100 - - Fix stuff lost when merging xpdf303 - - restore the implementation of -binary - restore the fix that level2sep and level3sep must write cmyk instead - of rgb - restore the conversion of bitmaps with all gray to mono8 - fixed the CMYK misspelling in Stream. - - poppler/PSOutputDev.cc | 284 - +++++++++++++++++++++++++++++++++++++++++-------- - poppler/Stream.cc | 55 ++++++++-- - poppler/Stream.h | 39 ++++++- - 3 files changed, 320 insertions(+), 58 deletions(-) - -commit e977925a1eb15083e6b020b31da77ddef9d5df02 -Author: William Bader -Date: Wed Feb 29 23:12:24 2012 +0100 - - Fix double alloc - - xpdf303 merge glitch - - poppler/PSOutputDev.cc | 1 - - 1 file changed, 1 deletion(-) - -commit e13efe04facdc10f3acffece3b057544f018f40c -Author: William Bader -Date: Wed Feb 29 23:10:43 2012 +0100 - - Fix memory leak - - Wrong merge from xpdf303 - - poppler/GfxState.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit adfc03e441b2a86dab5216dc560fd79343dfbe4f -Author: Hib Eris -Date: Wed Feb 29 21:10:56 2012 +0100 - - Only use Hints table when there are no parse errors - - Fixes bug #46459. - - poppler/Hints.cc | 6 ++++-- - poppler/Parser.cc | 30 ++++++++++++++++++++++++------ - poppler/Parser.h | 7 +++++-- - 3 files changed, 33 insertions(+), 10 deletions(-) - -commit 7ec31b8dc40ec8a3534fbb89964aa011aeb81f5e -Author: Adrian Johnson -Date: Mon Feb 27 21:15:39 2012 +1030 - - pdftoppm: document that -scale-to will preserve aspect ratio - - utils/pdftoppm.1 | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit 38ace7db5de0b2b247fd520e48a8f26e5d28c9d7 -Author: Adrian Johnson -Date: Sat Feb 25 20:02:22 2012 +1030 - - pdftoppm: allow one of -scale-to-[xy] = -1 to mean the aspect ratio - is to be preserved - - bug 43393 - - utils/pdftoppm.1 | 8 ++++++-- - utils/pdftoppm.cc | 8 ++++++-- - 2 files changed, 12 insertions(+), 4 deletions(-) - -commit 738b879ebb536cc84d7ec96543d484023b69e6d3 -Author: Carlos Garcia Campos -Date: Sat Feb 25 20:53:58 2012 +0100 - - regtest: Add create-report command to generate html report of - test results - - regtest/HTMLReport.py | 197 - ++++++++++++++++++++++++++++++++++++++ - regtest/backends/__init__.py | 20 +++- - regtest/commands/create-report.py | 57 +++++++++++ - 3 files changed, 273 insertions(+), 1 deletion(-) - -commit d5faabd509c2860ab199ee89b8ef9d4c14fa5118 -Author: Carlos Garcia Campos -Date: Sat Feb 25 20:50:53 2012 +0100 - - regtest: Use diff.png extension for image diff files - - So that they are recognized as images - - regtest/backends/__init__.py | 16 ++++++++++++++-- - regtest/backends/cairo.py | 2 +- - regtest/backends/splash.py | 2 +- - regtest/backends/text.py | 2 +- - 4 files changed, 17 insertions(+), 5 deletions(-) - -commit 2a5f1594a23cf521497f904b502fbadf56a9e780 -Author: William Bader -Date: Sat Feb 25 16:32:33 2012 +0100 - - Fix PSOutputDev regression with -level1 - - poppler/PSOutputDev.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 6a5deb0a86ad227cce3f85b1f58a9b86755cd812 -Author: Adrian Johnson -Date: Sat Feb 25 19:39:02 2012 +1030 - - autoconf: PKG_CHECK_EXISTS should not have the variable prefix in - the first argument - - configure.ac | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 8f4566c14a727fb75c4c353989cf5eb96516c2e3 -Author: Adrian Johnson -Date: Wed Feb 22 21:21:52 2012 +1030 - - autoconf: replace openjpeg compile test with a version test - - Now that openjpeg 1.5 is released and supports pkg-config the compile - test can be replaced with a pkg-config version check. - - configure.ac | 11 +++-------- - 1 file changed, 3 insertions(+), 8 deletions(-) - -commit 30f38bf425e2f76b3f6cc4c080137ac7219a9dbe -Author: Adrian Johnson -Date: Wed Feb 22 21:01:59 2012 +1030 - - autoconf: Use pkgconfig to check for libopenjpeg - - and if not found fallback to using AC_CHECK_LIB/AC_CHECK_HEADERS - - openjpeg >= 1.4 installs a pkgconfig file - - Bug 21789 - - configure.ac | 28 +++++++++++++++++----------- - 1 file changed, 17 insertions(+), 11 deletions(-) - -commit 466340d257ff0fe7e3a88a4e013e3feec3f7b70a -Author: Albert Astals Cid -Date: Thu Feb 23 23:47:15 2012 +0100 - - Combine UTF16 surrogate pairs - - Bug 46521 - - utils/HtmlOutputDev.cc | 14 +++++++++++++- - 1 file changed, 13 insertions(+), 1 deletion(-) - -commit 675ef2bda3c4e06b39e2ba09b3b19d99cfb001b6 -Author: Oliver Sander -Date: Thu Feb 23 23:22:50 2012 +0100 - - Compile - - poppler/Stream.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 7705e65c231cc3af296bf19f5cba110cabb72e7d -Author: Albert Astals Cid -Date: Thu Feb 23 23:09:23 2012 +0100 - - Generate outlines in pdftohtml in -xml mode. - - Bug 56993 - - utils/HtmlOutputDev.cc | 130 - ++++++++++++++++++++++++++++++++++++------------- - utils/HtmlOutputDev.h | 7 ++- - utils/pdf2xml.dtd | 7 ++- - utils/pdftohtml.cc | 5 +- - 4 files changed, 108 insertions(+), 41 deletions(-) - -commit 30446bdd7e202eed88d131e04477c76861fd145c -Author: Albert Astals Cid -Date: Thu Feb 23 22:56:17 2012 +0100 - - Use an Identity CharCodeToUnicode for Adobe-Identity and Adobe-UCS - collections - - Also fix Identity CharCodeToUnicode code - - Bug #35468 - - poppler/CharCodeToUnicode.cc | 18 +++++++++++++----- - poppler/CharCodeToUnicode.h | 7 +++++-- - poppler/GfxFont.cc | 13 +++++++------ - 3 files changed, 25 insertions(+), 13 deletions(-) - -commit 71104f1ec55d3be999afaa1b62405454b31066a9 -Author: Albert Astals Cid -Date: Thu Feb 23 19:34:57 2012 +0100 - - Remove unneded CharCodeToUnicode includes - - poppler/ArthurOutputDev.cc | 3 +-- - poppler/CairoFontEngine.cc | 3 +-- - poppler/CairoOutputDev.cc | 3 +-- - poppler/SplashOutputDev.cc | 3 +-- - 4 files changed, 4 insertions(+), 8 deletions(-) - -commit c0c8cc1592ee6aa13157e34f8083b951d487a413 -Author: Adrian Johnson -Date: Thu Feb 23 21:13:23 2012 +1030 - - glib docs: fix typo - - glib/poppler.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit fde3bed0f400a50f31f1f6bcee44ac1b2c17ddc6 -Author: Albert Astals Cid -Date: Wed Feb 22 00:03:37 2012 +0100 - - pdfinfo: decode utf-16 surrogate pairs - - Based on a patch by Adrian Johnson - Bug 23075 - - utils/pdfinfo.cc | 14 ++++++++++++-- - 1 file changed, 12 insertions(+), 2 deletions(-) - -commit 3361564364a1799fc3d6c6df9f208c5531c407dc -Author: Adrian Johnson -Date: Tue Feb 21 22:20:02 2012 +0100 - - Expand glyph name ligatures such as "ff", "ffi" etc to normal form - - Bug 7002 - - poppler/GfxFont.cc | 14 +++++++++++++- - poppler/UnicodeTypeTable.cc | 9 +++++++++ - poppler/UnicodeTypeTable.h | 3 +++ - 3 files changed, 25 insertions(+), 1 deletion(-) - -commit d0186c558f4a84a9317687ad50b460d34fb5fdf0 -Author: Pino Toscano -Date: Mon Feb 20 22:18:00 2012 +0100 - - cmake: support for lcms2 - - followup of e48c22d3b70412015b9cc07a9a6ce07845274e13 also for the - CMake build system, - importing the FindLCMS2.cmake from kdelibs - - CMakeLists.txt | 26 +++++++++++++-- - cmake/modules/FindLCMS2.cmake | 73 - +++++++++++++++++++++++++++++++++++++++++++ - config.h.cmake | 3 ++ - utils/CMakeLists.txt | 3 ++ - 4 files changed, 102 insertions(+), 3 deletions(-) - -commit e48c22d3b70412015b9cc07a9a6ce07845274e13 -Author: Koji Otani -Date: Mon Feb 20 22:04:01 2012 +0100 - - Add support for lcms2 - - configure.ac | 24 ++++++- - poppler/GfxState.cc | 159 - +++++++++++++++++++++++++++----------------- - qt4/src/poppler-document.cc | 5 ++ - utils/pdftocairo.cc | 17 +++++ - 4 files changed, 143 insertions(+), 62 deletions(-) - -commit 1bcae7aa8f87cc85ee6b477bf0abb49452e46505 -Author: Igor Slepchin -Date: Sun Feb 19 23:40:50 2012 +0100 - - Consistently check if pdftohtml needs to generate outlines. - - utils/pdftohtml.cc | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - -commit 126bf08105e319f9216654782e5a63f99f1d1825 -Author: Albert Astals Cid -Date: Sun Feb 19 23:18:25 2012 +0100 - - Update glyph names to Unicode values mapping - - Added Zapf Dingbat names and fixed copyrightsans, copyrightserif, - registersans, registerserif, trademarksans, trademarkserif - Kudos to Adrian Johnson for find what was missing :-) - Bug #13131 - - poppler/NameToUnicodeTable.h | 213 - +++++++++++++++++++++++++++++++++++++++++-- - 1 file changed, 207 insertions(+), 6 deletions(-) - -commit c0fec84312a37f62bdbfdee7c8e9b520af28330a -Author: Pino Toscano -Date: Sun Feb 19 14:47:24 2012 +0100 - - fix typo, GString -> GooString - - goo/GooString.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit aaae8996766f259dcc329755c7cccde7c916c1fb -Author: Adrian Johnson -Date: Thu Feb 16 22:22:15 2012 +1030 - - cairo: set mask matrix before drawing an image with a mask - - Bug 40828 - - poppler/CairoOutputDev.cc | 1 + - 1 file changed, 1 insertion(+) - -commit fff439f25d9bbd199db5646deccd80733138898e -Author: Adrian Johnson -Date: Sun Feb 19 15:45:31 2012 +1030 - - update .gitignore - - utils/.gitignore | 1 + - 1 file changed, 1 insertion(+) - -commit 1cc3e152d6e879eb13fbdf2964ede3e01d13d097 -Author: Adrian Johnson -Date: Sun Feb 19 15:43:09 2012 +1030 - - glib docs: fix typo - - glib/poppler-page.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 4f4db591276ec156c55b3a3c2020a1cf82f1519b -Author: Adrian Johnson -Date: Sun Feb 19 15:37:04 2012 +1030 - - cairo: fix pdftocairo crash when pdf document uses actualText - - poppler/CairoOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 9b72ee4e4c8658b2f7cd542d601a5c3be621d3fc -Author: Thomas Freitag -Date: Sat Feb 18 17:34:12 2012 +0100 - - Make some of the unfilteredResets be really unfiltered - - poppler/Stream.cc | 26 ++++++++++++++++++++------ - poppler/Stream.h | 3 +++ - 2 files changed, 23 insertions(+), 6 deletions(-) - -commit 33aded82fbd98832eaab7cb7487fe6a1c7ef15f5 -Author: Albert Astals Cid -Date: Sat Feb 18 17:21:10 2012 +0100 - - Rework XRef getNumObjects and getSize - - Kill XRef::last since we do not maintain it correctly, now - getNumObjects returns size as it did - Kill getSize as it just returns the same as getNumObjects - - poppler/PDFDoc.cc | 10 +++++----- - poppler/XRef.cc | 12 +----------- - poppler/XRef.h | 6 ++---- - 3 files changed, 8 insertions(+), 20 deletions(-) - -commit 521d3740e9b7d2cfacf29f089a4a8f6c962de807 -Author: Adrian Johnson -Date: Mon Feb 13 22:05:18 2012 +1030 - - pdfimages: add -list option to list all images - - Bug 46066 - - utils/ImageOutputDev.cc | 204 - ++++++++++++++++++++++++++++++++++++++++++------ - utils/ImageOutputDev.h | 20 ++++- - utils/pdfimages.1 | 101 ++++++++++++++++++++++++ - utils/pdfimages.cc | 12 ++- - 4 files changed, 307 insertions(+), 30 deletions(-) - -commit 119b6b752314c9b13440eddf5bd1d5cef2966e80 -Author: Adrian Johnson -Date: Mon Feb 6 16:50:11 2012 +1030 - - cairo: don't read inline image streams twice - - Bug 45668 - - poppler/CairoOutputDev.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit a76135391555145ec740d49a7141e60da0ea5dee -Author: Hib Eris -Date: Tue Feb 14 20:11:19 2012 +0100 - - Add a configuration option for the test data dir - - This makes 'make distcheck' run succesfully. - - CMakeLists.txt | 20 ++++++++++++++++++++ - Makefile.am | 2 +- - configure.ac | 42 - +++++++++++++++++++++++++++++++++++++++++ - qt4/tests/CMakeLists.txt | 1 + - qt4/tests/Makefile.am | 1 + - qt4/tests/check_actualtext.cpp | 2 +- - qt4/tests/check_attachments.cpp | 14 +++++++------- - qt4/tests/check_fonts.cpp | 18 +++++++++--------- - qt4/tests/check_links.cpp | 6 +++--- - qt4/tests/check_metadata.cpp | 32 +++++++++++++++---------------- - qt4/tests/check_optcontent.cpp | 12 ++++++------ - qt4/tests/check_pagelayout.cpp | 6 +++--- - qt4/tests/check_pagemode.cpp | 10 +++++----- - qt4/tests/check_password.cpp | 12 ++++++------ - qt4/tests/check_permissions.cpp | 2 +- - qt4/tests/check_search.cpp | 4 ++-- - 16 files changed, 124 insertions(+), 60 deletions(-) - -commit 59946e0c34e762eb5f5a13b4ae8c9ec7fb21379a -Author: Thomas Freitag -Date: Tue Feb 14 19:37:21 2012 +0100 - - Overprint implementation in postscript and splash device - - It is an enhancement patch, a - merge fix and a bug fix in one: an enhancement, because it now - completes - the implementation overprint mode and devicen in postscript, a merge - fix, because it fixes some bugs in the overprint implementation in - splash of xpdf 3.0.3 and has now the complete functionality (and - more!) - of my implementation back again and a bug fix, because it fixes - the use - of splash cmyk in postscript which never had worked. - - 1. Overprint implementation in postscript - To have a complete overprint implementation in the (pure) postscript - device there were just two things missing: overprint mode and the - implementation of the DeviceN colorspace in PostScript. I double - checked - my implementation with the Ghent Test Suite with GhostScript (device - pdfwrite) and Acrobat X distiller, and all the tests now succeeds, - either in Acrobat X distiller or in GhostScript. As overprint is a - device dependent feature, it is up to the output device if it supports - overprint and what features of overprint are supported, and often You - have various configuration possibilities there. Nearly all PostScript - output of the Ghent tests show now the desired results if converting - it - back to PDF with ghostscript pdfwrite, the implementation in - ghostscript - is complete. On the other hand a few tests failed when using Acrobat X - distiller, all of them with the overprint mode switch. Funny, because - overprint mode 1 is often also called the illustrator overprint mode - because it was introduced by illustrator, but probably the destiller - only handles EPS correctly which comes from illustrator - - 2. Overprint implementation in postscript if using splash - rasterization - Of course the postscript overprint implementation will only work if - pdftops doesn't decide to use splash to rasterize it because of - the use - of transparencies in the PDF. But because overprint is device - dependent - I decided to spend an additional parameter "overprint" to pdftops - (simular to pdftoppm). Switching it on (only available if compiled - with - SPLASH_CMYK, because overprint is only in CMYK colorspace showable) - will - use the overprint implementation in splash also if rasterizing - the PDF. - - 3. Overprint implementation in splash - The overprint implementation in splash now uses the better designed - interface of xpdf and therefore now also works in transparency groups. - Thanks to the developper team of xpdf. I just fixed a small bug in it, - where it defies the technical specification. Of course it is still in - the nature of the splash implementation that it fails if CMYK values - should overprint spot colors, because spot colors are converted - immediately in their CMYK alternates. And in the implementation of - overprinting spot colors over CMYK colors I made a small assumption to - get it running which causes undesired results if this assumption - fails, - but I didn't want to implement more and more configuration switches. I - still plan to implement a DeviceN output in splash and make a complete - implementation there, but this is of course a bigger task (but - doable). - The overprint switch in pdftoppm is still only available if compiled - with the SPLASH_CMYK directive. - - poppler/PSOutputDev.cc | 67 ++++++++++-- - poppler/PSOutputDev.h | 3 +- - poppler/SplashOutputDev.cc | 62 ++++++++++-- - poppler/SplashOutputDev.h | 4 +- - splash/Splash.cc | 70 +++++++++---- - splash/Splash.h | 4 +- - splash/SplashState.cc | 5 +- - splash/SplashState.h | 247 - +++++++++++++++++++++++---------------------- - utils/pdftops.cc | 13 +++ - 9 files changed, 308 insertions(+), 167 deletions(-) - -commit b505920db6d3dac58c7e9f4f8917f4c4449b08a0 -Merge: 9250449 a631281 -Author: Albert Astals Cid -Date: Tue Feb 14 19:18:54 2012 +0100 - - Merge remote-tracking branch 'origin/xpdf303merge' - - Conflicts: - utils/HtmlOutputDev.cc - utils/HtmlOutputDev.h - -commit 9250449aaa279840d789b3a7cef75d06a0fd88e7 -Author: Hib Eris -Date: Sun Feb 12 23:16:41 2012 +0100 - - Improve moc detection when cross compiling - - configure.ac | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit 66cf1fdb3ba6894f61d9078f5c30046b464347ae -Author: Pino Toscano -Date: Sun Feb 12 22:27:58 2012 +0100 - - qt4: remove non-existing 'qt' include dirs - - qt4/demos/Makefile.am | 1 - - qt4/src/Makefile.am | 1 - - qt4/tests/Makefile.am | 1 - - 3 files changed, 3 deletions(-) - -commit 53d8fc4d2978b70e8926e3df71facd1f39de9348 -Author: Pino Toscano -Date: Sun Feb 12 17:36:55 2012 +0100 - - man pages: fix minor issues with hypens and % - - utils/pdfseparate.1 | 6 +++--- - utils/pdftocairo.1 | 4 ++-- - 2 files changed, 5 insertions(+), 5 deletions(-) - -commit a63128179c65b5d9d6d9d41fa601a593b0a05d94 -Author: Thomas Freitag -Date: Thu Feb 9 22:02:52 2012 +0100 - - [xpdf303] Fix merge issue - - utils/pdftoppm.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit cd5a6a4d02e579e543067d1847164aff90363f16 -Author: Thomas Freitag -Date: Thu Feb 9 22:01:42 2012 +0100 - - [xpdf303] Fix merge bug - - poppler/GfxState.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 597fa37cacec928c40d0491174ce843fe01f26d9 -Author: Igor Slepchin -Date: Wed Feb 8 19:22:13 2012 -0500 - - Close li tags in generated outlines. - - Also, add newlines after ul tags for better readability. - Bug #45807 - (cherry picked from commit bf81250ff7d0968852fc7559fafb6389cd695b91) - - utils/HtmlOutputDev.cc | 9 ++++++--- - 1 file changed, 6 insertions(+), 3 deletions(-) - -commit 2fc36dba5f63703896722adb5127896e4c2840e7 -Author: Igor Slepchin -Date: Thu Feb 9 00:15:13 2012 +0100 - - Get rid of static data members; merge duplicated jpeg dumping code. - - HtmlPage::pgNum is never used; - imgNum is always equal to imgList->getLength()+1 - imgList is now maintained in HtmlPage. - - utils/HtmlOutputDev.cc | 143 - +++++++++++++++++++------------------------------ - utils/HtmlOutputDev.h | 15 ++++-- - 2 files changed, 65 insertions(+), 93 deletions(-) - -commit f655efe327ddd3b6a68353a62589d4e4f8a318a8 -Author: Albert Astals Cid -Date: Wed Feb 8 23:58:27 2012 +0100 - - Fix memory leak when using HtmlOutputDev::mapEncodingToHtml - - Bug #45805 - (cherry picked from commit 53a0c2043dfd56f6da7780f1a049f75af368b84b) - - utils/HtmlOutputDev.cc | 47 - ++++++++++++++++++++++++----------------------- - utils/HtmlOutputDev.h | 7 ++++--- - 2 files changed, 28 insertions(+), 26 deletions(-) - -commit 68f02d19c571fce956c7f4af6ccd0ff9ba8b1b03 -Author: Albert Astals Cid -Date: Wed Feb 8 23:47:46 2012 +0100 - - Fix leak in pdftohtml getInfoString - - Bug #45805 - (cherry picked from commit 4afe4d827a342a847e8b89aba5b4164ed3b4cc32) - - utils/pdftohtml.cc | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit 2b7ba166c28e32653db4ae7acf90e06e0dd5975b -Author: Albert Astals Cid -Date: Wed Feb 8 19:12:52 2012 +0100 - - [xpdf303] Compile fixes - - poppler/GlobalParamsWin.cc | 2 +- - poppler/SplashOutputDev.cc | 10 ---------- - 2 files changed, 1 insertion(+), 11 deletions(-) - -commit b8c9b179c9491cf6755b07bfdec4174e78b7d241 -Author: Albert Astals Cid -Date: Mon Feb 6 19:55:07 2012 +0100 - - [xpdf303] Adapt better to what we did and what xpdf303 does - - poppler/ArthurOutputDev.cc | 1 - - poppler/GlobalParams.cc | 10 ---------- - poppler/GlobalParams.h | 1 - - poppler/SplashOutputDev.cc | 3 --- - poppler/SplashOutputDev.h | 1 - - splash/SplashFTFont.cc | 40 - +++++++++++++++++++--------------------- - splash/SplashFTFont.h | 1 - - splash/SplashFTFontEngine.cc | 7 +++---- - splash/SplashFTFontEngine.h | 5 ++--- - splash/SplashFontEngine.cc | 3 +-- - splash/SplashFontEngine.h | 1 - - utils/pdftoppm.cc | 2 +- - 12 files changed, 26 insertions(+), 49 deletions(-) - -commit ea6bc19564865e04431d9154802ae7fba975a716 -Merge: e17f095 92ce79f -Author: Albert Astals Cid -Date: Mon Feb 6 01:18:25 2012 +0100 - - Merge branch 'master' into xpdf303merge - - Conflicts: - poppler/CairoOutputDev.cc - poppler/CairoOutputDev.h - poppler/FontInfo.cc - poppler/GfxFont.cc - poppler/GfxState.cc - poppler/GlobalParams.cc - poppler/GlobalParams.h - poppler/Lexer.cc - -commit e17f09563276ee25b6acfc127b6ea360da650030 -Author: Albert Astals Cid -Date: Mon Feb 6 00:25:53 2012 +0100 - - [xpdf303] TextOutputDev and associated changes - - cpp/poppler-page.cpp | 10 +- - glib/poppler-page.cc | 5 +- - poppler/ArthurOutputDev.cc | 1 + - poppler/CairoOutputDev.cc | 2 +- - poppler/Gfx.cc | 6 +- - poppler/PSOutputDev.cc | 6 +- - poppler/TextOutputDev.cc | 360 - ++++++++++++++++++++++++++++----------------- - poppler/TextOutputDev.h | 18 ++- - qt4/src/poppler-page.cc | 12 +- - test/perf-test.cc | 2 +- - utils/pdftotext.1 | 4 + - utils/pdftotext.cc | 10 +- - 12 files changed, 270 insertions(+), 166 deletions(-) - -commit 548648bf29dc1551443eb1925814342e7aadee46 -Author: Albert Astals Cid -Date: Sun Feb 5 23:08:44 2012 +0100 - - [xpdf303] Merge PDFDoc encryption related code - - poppler/PDFDoc.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 6ee907f291427b8751a872b31210bf32e8d2b722 -Author: Albert Astals Cid -Date: Sun Feb 5 22:57:25 2012 +0100 - - [xpdf303] More merges from Thomas, basically PSOutputDev and some - other small stuff - - poppler/GfxFont.cc | 4 +- - poppler/GlobalParams.cc | 95 ++- - poppler/GlobalParams.h | 18 +- - poppler/GlobalParamsWin.cc | 16 +- - poppler/Hints.cc | 2 +- - poppler/PSOutputDev.cc | 1814 - ++++++++++++++++++++++--------------------- - poppler/PSOutputDev.h | 51 +- - poppler/Parser.cc | 13 +- - poppler/Parser.h | 7 +- - poppler/PreScanOutputDev.cc | 70 +- - poppler/PreScanOutputDev.h | 16 +- - poppler/XRef.cc | 91 ++- - poppler/XRef.h | 3 +- - utils/pdftops.cc | 2 +- - 14 files changed, 1231 insertions(+), 971 deletions(-) - -commit 92ce79f47f929392f48737612a9690088573f63d -Author: Igor Slepchin -Date: Sun Feb 5 15:55:39 2012 +0100 - - Proper unicode support when dumping PDF outline. - - Also use of already existing Outline class rather than parsing the - outline anew. - - Bug 45572 - (cherry picked from commit 40f7289ab04787734b856c53d5c0139445b52635) - - Conflicts: - - utils/HtmlOutputDev.cc - - utils/HtmlOutputDev.cc | 197 - ++++++++++++++++++++++++++----------------------- - utils/HtmlOutputDev.h | 6 +- - utils/pdftohtml.cc | 3 +- - 3 files changed, 112 insertions(+), 94 deletions(-) - -commit 38ec58ed1cb54722aece875287b847643aa2c4b8 -Author: Adrian Johnson -Date: Sat Feb 4 17:13:30 2012 +1030 - - Lexer: convert integer to real when overflow occurs - - Bug 45605 - - poppler/Lexer.cc | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit df89de61b7d01f0f816e773cdb809faa3053e962 -Author: Hib Eris -Date: Tue Jan 31 20:01:30 2012 +0100 - - glib: Exclude poppler-private.h from introspection files - - Fixes bug #45455. - - glib/CMakeLists.txt | 2 +- - glib/Makefile.am | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 88cb6d9360bc943fc2cdda262dc46bf831641541 -Author: Carlos Garcia Campos -Date: Sat Feb 4 12:04:03 2012 +0100 - - glib: Update gtk-doc makefile and m4 file - - gtk-doc.make | 112 - +++++++++++++++++++++++++++++++++------------------------- - m4/gtk-doc.m4 | 6 ++++ - 2 files changed, 70 insertions(+), 48 deletions(-) - -commit 3f4164f84bbf748a2f919741669ef20db0fbda9f -Author: Hib Eris -Date: Wed Feb 1 10:44:17 2012 +0100 - - gtk-doc: Fix build when builddir != srcdir - - Bug #45549. - - glib/reference/Makefile.am | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -commit 8daeb82f982eba25fe8c7d07358f0a6593ddc89a -Author: Hib Eris -Date: Thu Feb 2 13:01:45 2012 +0100 - - gtk-doc: Fix API documentation for poppler_page_free_annot_mapping() - - Remove reference to non existent method poppler_annot_free() and use - ref/unref instead of copy/free. - - Bug #45549. - - glib/poppler-page.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit f8ce9966e4f480949799a26c01bd861f4011b587 -Author: Carlos Garcia Campos -Date: Sat Feb 4 11:51:34 2012 +0100 - - gtk-doc: Remove reference to non existent method poppler_layer_free() - - Bug #45549. - - glib/poppler-document.cc | 7 +++---- - 1 file changed, 3 insertions(+), 4 deletions(-) - -commit f58f3525f135bc47e89c23c33e96e43db10d4853 -Author: Hib Eris -Date: Thu Feb 2 15:59:47 2012 +0100 - - gtk-doc: Add more glib API documentation for poppler-document - - Fixes several gtk-doc warnings. - - Bug #45549. - - glib/poppler-document.h | 26 +++++++++++++------------- - 1 file changed, 13 insertions(+), 13 deletions(-) - -commit 080247f6a47bc929b25f6e000f4474801af74b1f -Author: Hib Eris -Date: Thu Feb 2 15:45:37 2012 +0100 - - gtk-doc: remove references to removed pixbuf functions - - Bug #45549. - - glib/poppler-page.cc | 6 ++---- - glib/reference/poppler-sections.txt | 4 ---- - 2 files changed, 2 insertions(+), 8 deletions(-) - -commit 47780d9ed1fd69068fdb9b9782e2cb37e2a5b217 -Author: Hib Eris -Date: Thu Feb 2 15:43:30 2012 +0100 - - gtk-doc: do not build doc for glib-demo - - Fixes glib-demo symbols in poppler-unused.txt - - Bug #45549. - - glib/reference/Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit e320f335cc6e54c60bd2436799dd1f05beb060ba -Author: Hib Eris -Date: Sat Feb 4 11:32:50 2012 +0100 - - gtk-doc: Fix typo's - - Bug #45549. - - glib/poppler-annot.cc | 6 +++--- - glib/poppler-annot.h | 2 +- - glib/poppler-document.cc | 2 +- - glib/poppler-media.cc | 2 +- - glib/poppler-page.cc | 3 +-- - glib/poppler-page.h | 4 ++-- - glib/reference/poppler-sections.txt | 4 +++- - 7 files changed, 12 insertions(+), 11 deletions(-) - -commit 1fe27b07975e9a9455708563118fb73cce696f81 -Author: Hib Eris -Date: Tue Jan 31 12:49:01 2012 +0100 - - cairo: Remove unused variable in CairoFontEngine.cc - - Fixes bug #45442. - - poppler/CairoFontEngine.cc | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit e3d80c79815ce46daf3c3f2b944f49eaf19bfea5 -Author: Hib Eris -Date: Tue Jan 31 14:42:04 2012 +0100 - - Fix return value of downscale_box_filter() - - Fixes bug #45441. - - poppler/CairoRescaleBox.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit e074e526fa206403b84da5ce0f27d7357223c7ac -Author: Hib Eris -Date: Tue Jan 31 13:02:16 2012 +0100 - - Fix return value of poppler_attachment_save - - Fixes bug #45440. - - glib/poppler-attachment.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit bc389cff91c350d7da186d4cf707c389c77bbc29 -Author: Hib Eris -Date: Tue Jan 31 14:03:08 2012 +0100 - - glib-demo: Do not use deprecated gtk_dialog_set_has_separator() - - Bug #45439 - - glib/demo/main.c | 2 ++ - 1 file changed, 2 insertions(+) - -commit e52e3c24663edaa630d9187e832223b474b74089 -Author: Hib Eris -Date: Tue Jan 31 13:39:05 2012 +0100 - - glib-demo: Do not use deprecated GtkComboBox API - - Bug #45439. - - glib/demo/annots.c | 6 ++++++ - glib/demo/print.c | 9 ++++++++- - glib/demo/render.c | 16 ++++++++++++++++ - glib/demo/selections.c | 8 ++++++++ - 4 files changed, 38 insertions(+), 1 deletion(-) - -commit 165ab4ec122d0e1a6f30dcfba80aefc422cd83b7 -Author: Hib Eris -Date: Tue Jan 31 12:15:51 2012 +0100 - - Fix build for builddir != srcdir - - Fixes bug #45434. - - glib/Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit e424a13bb516464d59ad76fd0933e92f3307b21b -Author: Thomas Freitag -Date: Fri Feb 3 00:12:10 2012 +0100 - - pdfseparate fixes by Thomas after his last commit - - poppler/PDFDoc.cc | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -commit 4fcd42cfa4424992cd4b36af38bc6230ce0706c9 -Author: Albert Astals Cid -Date: Wed Feb 1 22:53:03 2012 +0100 - - [xpdf303] More merges from Thomas (with minor fixes from me) - - Basically fonts related and some other small stuff - - poppler/Annot.cc | 6 +- - poppler/ArthurOutputDev.cc | 47 +-- - poppler/CMap.cc | 153 ++++++++ - poppler/CMap.h | 16 + - poppler/CairoFontEngine.cc | 43 +-- - poppler/CharCodeToUnicode.h | 1 + - poppler/FontInfo.cc | 8 +- - poppler/Gfx.cc | 363 +++++++++++-------- - poppler/GfxFont.cc | 831 - +++++++++++++++++++++++++++++--------------- - poppler/GfxFont.h | 34 +- - poppler/GfxState.cc | 81 +++-- - poppler/GfxState.h | 2 + - poppler/GlobalParams.cc | 738 ++++++++++++++++++++++----------------- - poppler/GlobalParams.h | 112 +++--- - poppler/GlobalParamsWin.cc | 180 ++++++++-- - poppler/PSOutputDev.cc | 591 +++++++++++++++---------------- - poppler/PSOutputDev.h | 12 +- - poppler/PreScanOutputDev.cc | 10 +- - poppler/SplashOutputDev.cc | 59 ++-- - poppler/XRef.cc | 16 +- - 20 files changed, 2008 insertions(+), 1295 deletions(-) - -commit 0089357de8ea96f3e394ea9cb37e8182ccf15ae2 -Author: Thomas Freitag -Date: Wed Feb 1 19:17:38 2012 +0100 - - pdfseparate: Produce PDF/X conformant pdf pages if the original PDF - was PDF/X conformant. - - poppler/PDFDoc.cc | 63 - ++++++++++++++++++++++++++++++++++--------------------- - poppler/XRef.cc | 9 +++++++- - poppler/XRef.h | 5 ++++- - 3 files changed, 51 insertions(+), 26 deletions(-) - -commit be62a4f2e7d5db3b6d85d1b3026979f9561e6e15 -Author: Hib Eris -Date: Mon Jan 30 17:07:28 2012 +0100 - - Fix build with latest mingw-w64 headers - - Fixes bug #45407. - (cherry picked from commit 58c17c3a61f18a6808ec9ba37e82734a655090ac) - - glib/poppler-annot.cc | 1 + - glib/poppler-document.cc | 1 + - 2 files changed, 2 insertions(+) - -commit acbc63348ce5e279e4d66ed4f240dc8d61df4e57 -Author: Suzuki Toshiya -Date: Mon Jan 30 20:46:04 2012 +1030 - - pdftocairo/automake: link with lcms - - utils/Makefile.am | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 9548573a16629fecdbd44c9aac8b626ec6f53b81 -Author: Pino Toscano -Date: Mon Jan 30 00:32:52 2012 +0100 - - glib/cmake: various minor introspection improvements - - "port" to CMake of the automake equivalents of - 4765c3289635fe4fb006e7df4f83d7056eb42855 - - glib/CMakeLists.txt | 3 +++ - 1 file changed, 3 insertions(+) - -commit bf2ffb1cc76bcf569419ac495f524c41bb6f1650 -Author: Pino Toscano -Date: Mon Jan 30 00:21:31 2012 +0100 - - cmake: support $(gir_name)_EXPORT_PACKAGES for g-ir-scanner - - cmake/modules/GObjectIntrospectionMacros.cmake | 2 ++ - 1 file changed, 2 insertions(+) - -commit cbe7131e63c5896010e7e1ad5c0c3aa91611704d -Author: Albert Astals Cid -Date: Fri Jan 27 00:36:18 2012 +0100 - - Set OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG if you have it - - Fixes/workarounds bug 43414 with openjpeg 1.5 (unreleased) - (cherry picked from commit de6415af1a39ec7dfa4f149c6c5e311b86352cec) - - cmake/modules/FindLIBOPENJPEG.cmake | 13 +++++++++++++ - config.h.cmake | 3 +++ - configure.ac | 8 ++++++++ - poppler/JPEG2000Stream.cc | 7 ++++++- - 4 files changed, 30 insertions(+), 1 deletion(-) - -commit 641526d1a7e8032ea8f7b8ac42c5ad8c20448d9b -Author: Adrian Johnson -Date: Wed Jan 25 22:44:27 2012 +1030 - - jpeg: set image parameters after jpeg_set_defaults() - - so the resolution does not get overwritten by the defaults. - - The libjpeg documentation for jpeg_set_defaults() states: "This - routine sets all JPEG parameters to reasonable defaults, using only - the input image's color space (field in_color_space, which must - already be set in cinfo)" - - Bug 45224 - - goo/JpegWriter.cc | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit f7356a88fe983c2ddd7d5a50400768310a26c4d2 -Author: Adrian Johnson -Date: Thu Jan 26 11:33:28 2012 +1030 - - glib: add section in docs for new symbols in 0.18 - - glib/reference/poppler-docs.sgml | 4 ++++ - 1 file changed, 4 insertions(+) - -commit b42c171de93dba56859beb21cfe5312d825fedd6 -Author: Alexander Saprykin -Date: Mon Jan 23 22:07:15 2012 +0100 - - Do not use 50Kb of stack in SplashXPath::addCurve - - Bug 44905 - - splash/SplashXPath.cc | 69 - ++++++++++++++++++++++++++++++++++++--------------- - 1 file changed, 49 insertions(+), 20 deletions(-) - -commit a04fca6266bda6d04068f38f16fe492cb6b8677b -Author: Adrian Johnson -Date: Sat Jan 21 09:41:12 2012 +1030 - - cairo: use fabs when comparing the transformed line width - - as the transform may cause a negative width. - - Bug 43441 - - poppler/CairoOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ce1b6c7ca16847f07eeafc29c6503be6fa5a9a3d -Author: Patrick Pfeifer -Date: Thu Jan 19 14:54:48 2012 +0100 - - cairo: Fix test for rotation - - Fixes bug #14619. - - poppler/CairoOutputDev.cc | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -commit 4765c3289635fe4fb006e7df4f83d7056eb42855 -Author: Evan Nemerson -Date: Sun Jan 15 11:02:50 2012 -0800 - - glib: various minor introspection and documentation improvements - - Bug 44790 - - glib/Makefile.am | 4 +++- - glib/poppler-annot.cc | 8 ++++---- - glib/poppler-attachment.h | 7 ++++--- - glib/poppler-document.cc | 6 ++++-- - glib/poppler-media.h | 7 ++++--- - glib/poppler-page.cc | 23 +++++++++++++++-------- - 6 files changed, 34 insertions(+), 21 deletions(-) - -commit e8e42988c5cebab2ffa5fe020f30a3a645e90b5f -Author: Adrian Johnson -Date: Mon Jan 16 21:25:19 2012 +1030 - - cairo: ensure paintTransparencyGroup uses same ctm as - beginTransparencyGroup - - Bug 29968 - - poppler/CairoOutputDev.cc | 8 ++++++-- - poppler/CairoOutputDev.h | 1 + - 2 files changed, 7 insertions(+), 2 deletions(-) - -commit f6c7aa752f9455bba1aa3c72e0998e7911c1d43e -Author: Adrian Johnson -Date: Wed Jan 18 21:19:43 2012 +1030 - - configure.ac: print the glib version required if not found - - configure.ac | 10 ++++++++-- - 1 file changed, 8 insertions(+), 2 deletions(-) - -commit 100488ec7db2d1f3e25bfda42c1603ca86696195 -Author: Adrian Johnson -Date: Sun Jan 15 23:52:28 2012 +1030 - - cairo: restore temporary clip used in CairoOutputDev::fill when - painting a mask - - The clip is only used to clip the paint to the fill path so it should - be moved inside the save/restore. - - poppler/CairoOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 9c092e17e8f0cf0335b431a223e6e44bddc27e64 -Author: Albert Astals Cid -Date: Sun Jan 15 23:28:51 2012 +0100 - - [xpdf] More Splash and Gfx changes from Thomas - - 1. merge of blend changes - Here I had not only merged the changed in blend modes, I made also - a few - changes in the SPLASH_CMYK area, so that the already sent PDF now also - be rendered correctly with the -jpegcmyk option - 2. merge of font handling in SplashOutputDev.cc - There were a few changes left in font handling, I took them over - 3. merge of getcolor-changes - The getcolor changes win a price for well defined C++ code. I wouldn't - have merged them, if there were not a lot of other things to merge. - 4. merge of image handling in SplashOutputDev.cc - I merged the left changes in image handling including colorizing masks - in pattern colorspace - 5. cleanup of overprint - I tested the overprint implementation of Derek. They succeed only - in 70 - % percent of the PDF where my solution had success, but Derek's - solution - is much cleaner, and I'm sure that I could also fix the rest in - it. BUT: - as I already considered, when I implemented overprint, there are some - overprint situations, which can not be solved in a CMYK colorspace, we - have to implement a DeviceN colorpace when also overprint from CMYK - colors over spot colors should work. Therefore I decided to remove my - overprint implementation completely from the code and let Derek's - solution in, even if there could be done some enhancements in it. - 6. colorizing text in pattern colorspace - When I saw Derek's implementation with a clean interface only at one - place in Gfx.cc, I first was very surprised. My solution had a lot of - places in Gfx.cc, where I looked if the current colorspace is - a pattern - colorspace. Therefore I first had a look into the PDF specification - again, and really, it can be done in the way of Derek. Therefore I - merged it and removed the fragments of my code. - - On this step I started a regtest against the version after the fourth - patch. There were a lot of enhancements, especially in texts with - symbolic chars like mathematical and so on, but there was one - (and ONLY - one) regression, shown in bug-poppler27482.pdf - I examined that (that is also the reason for the delay) and - encountered - that on merging I removed my solution for this bug, therefore - - 7. insert enhancements for colorizing masks in pattern colorspace - I adapt the bug fix from bug 27482 to the merge. - - poppler/CairoOutputDev.cc | 101 ++-- - poppler/CairoOutputDev.h | 21 +- - poppler/Gfx.cc | 705 +++++++++++++++----------- - poppler/Gfx.h | 22 +- - poppler/GfxState.cc | 208 +++++--- - poppler/GfxState.h | 37 +- - poppler/GlobalParams.cc | 17 + - poppler/GlobalParams.h | 3 + - poppler/OutputDev.cc | 13 +- - poppler/OutputDev.h | 25 +- - poppler/PSOutputDev.cc | 87 ++-- - poppler/PSOutputDev.h | 21 +- - poppler/PreScanOutputDev.cc | 2 +- - poppler/SplashOutputDev.cc | 1179 - +++++++++++++++++++++---------------------- - poppler/SplashOutputDev.h | 80 +-- - poppler/TextOutputDev.cc | 8 + - poppler/TextOutputDev.h | 8 + - splash/Splash.cc | 11 +- - splash/Splash.h | 122 ++--- - splash/SplashPattern.cc | 14 - - splash/SplashPattern.h | 7 - - utils/pdftoppm.cc | 1 + - 22 files changed, 1390 insertions(+), 1302 deletions(-) - -commit 69df13c49cea2390f2c5036f3d450f134f7a2656 -Author: Thomas Freitag -Date: Sun Jan 15 15:07:18 2012 +0100 - - Fix stack overflow in PDFDoc::markObject() - - Bug 44660 - - poppler/PDFDoc.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit cdb56567c60b492ad08befff54f2ff70620b86fe -Author: Thomas Freitag -Date: Sun Jan 15 15:04:51 2012 +0100 - - Correctly initialize globalParams - - utils/pdfseparate.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 4e205a6625431dcf95375de009b4354746a4f0b7 -Author: Adrian Johnson -Date: Sun Jan 15 22:18:30 2012 +1030 - - parseargs: don't use arg->size with GooString argument - - 40b56994 added GooString arguments but incorrectly used arg->size as - the string length. arg->size is always 0 for GooString arguments. This - worked because the arg->size - 1 string length passed to - GooString::Set() just happened to be the the same value as the - CALC_STRING_LEN default argument indicating the string length is to be - calculated with strlen. - - utils/parseargs.cc | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit a7210a7ebc3d3ca88643bfbc2f0d660a5553a668 -Author: Arseny Solokha -Date: Fri Jan 13 18:52:17 2012 +0100 - - Properly initialize globalParams - - Bug 44659 - - utils/pdfunite.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit baaf93f0e47a1978f9ea80e9394543a25b763d77 -Author: Adrian Johnson -Date: Thu Jan 12 01:05:07 2012 +1030 - - configure.ac: print the cairo version required if not found - - Bug 44619 - - configure.ac | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -commit 9b8b4232587831fdada37de033c272a3c5049c34 -Author: Adrian Johnson -Date: Thu Jan 12 00:26:03 2012 +1030 - - cairo: avoid setting huge clip area when printing - - Bug 44002 - - poppler/CairoOutputDev.cc | 21 ++++++++++++--------- - 1 file changed, 12 insertions(+), 9 deletions(-) - -commit efe115f22f8f00a2863ef265ad6f4e7cc2e0336c -Author: Albert Astals Cid -Date: Tue Jan 10 23:41:54 2012 +0100 - - compile - - poppler/ArthurOutputDev.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 52d190d8ff962a57a59218f6871c3a63a443ea53 -Author: Albert Astals Cid -Date: Tue Jan 10 23:33:40 2012 +0100 - - [xpdf303] tiling "merges" from Thomas, using mostly our "old" code - instead of xpdf's - - poppler/CairoOutputDev.cc | 2 +- - poppler/CairoOutputDev.h | 4 ++-- - poppler/Gfx.cc | 45 - +++++++++++++++++++++++++++++++++------------ - poppler/Gfx.h | 15 +++++++++------ - poppler/GfxState.cc | 5 ++++- - poppler/GfxState.h | 7 ++++--- - poppler/OutputDev.h | 3 ++- - poppler/PSOutputDev.cc | 2 +- - poppler/PSOutputDev.h | 2 +- - poppler/PreScanOutputDev.cc | 15 +++++++-------- - poppler/PreScanOutputDev.h | 2 +- - poppler/SplashOutputDev.cc | 8 ++++++-- - poppler/SplashOutputDev.h | 3 ++- - splash/Splash.cc | 32 ++++++++++++++++++++++++-------- - utils/ImageOutputDev.cc | 2 +- - utils/ImageOutputDev.h | 2 +- - 16 files changed, 99 insertions(+), 50 deletions(-) - -commit bf75a957650dd5208ecf1f6db1555a3d00b7949c -Author: Albert Astals Cid -Date: Tue Jan 10 23:31:27 2012 +0100 - - [xpdf303] Splash::blitTransparent merges from Thomas - - splash/Splash.cc | 10 +++++++--- - 1 file changed, 7 insertions(+), 3 deletions(-) - -commit 296244ab74e56b2781daae0a664617d1da30527c -Author: Albert Astals Cid -Date: Tue Jan 10 23:30:34 2012 +0100 - - [xpdf303] Merge xpath Splash stuff from Thomas - - splash/SplashXPath.cc | 22 +++++++++++++--------- - 1 file changed, 13 insertions(+), 9 deletions(-) - -commit e1ae7b900b01db7c7703da68ad94aa9bda1938f6 -Author: Albert Astals Cid -Date: Tue Jan 10 23:29:38 2012 +0100 - - [xpdf303] Merge splash font stuff from Thomas - - poppler/GlobalParams.cc | 17 +++++++++++++++++ - poppler/GlobalParams.h | 3 +++ - poppler/SplashOutputDev.cc | 3 +++ - poppler/SplashOutputDev.h | 1 + - splash/SplashFTFont.cc | 34 ++++++++++++++++++++++++++++------ - splash/SplashFTFont.h | 1 + - splash/SplashFTFontEngine.cc | 7 ++++--- - splash/SplashFTFontEngine.h | 5 +++-- - splash/SplashFontEngine.cc | 3 ++- - splash/SplashFontEngine.h | 1 + - 10 files changed, 63 insertions(+), 12 deletions(-) - -commit d46b673c46a72132fb3918b64733be552e35952f -Author: Albert Astals Cid -Date: Tue Jan 10 23:28:43 2012 +0100 - - [xpdf303] More merges from Thomas - - splash/Splash.cc | 2800 - ++++++++++++++++++++++++++++++++++++------------------ - splash/Splash.h | 60 ++ - 2 files changed, 1943 insertions(+), 917 deletions(-) - -commit 2cb40bab3b8c49d54c2a49554b30268ccb32899b -Author: Adrian Johnson -Date: Sun Jan 8 21:35:41 2012 +1030 - - Fix typo in pdffonts man page - - utils/pdffonts.1 | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 34ae382915d9d9b2b3c015fee3c24907a6b52b8b -Author: Albert Astals Cid -Date: Sat Jan 7 17:14:05 2012 +0100 - - xpdf303: Merge some stuff in Splash [Thomas Freitag] - - 1. merge the complete pipe changes - a) including the overprint implementation from Derek used by pipe - b) including the transfer function implementation - 2. Two changes (not really a merge) to get it compiled under windows - (in - GlobalParams.cc & PDFDoc.cc) - 3. merge fill and stroke changes - a) including merge of SplashClip.cc - b) including merge of SplashXPathScanner.cc - - poppler/GfxState.cc | 94 ++- - poppler/GfxState.h | 17 +- - poppler/GlobalParams.cc | 7 + - poppler/GlobalParams.h | 3 + - poppler/GlobalParamsWin.cc | 2 +- - poppler/PDFDoc.cc | 2 +- - poppler/SplashOutputDev.cc | 134 +++- - poppler/SplashOutputDev.h | 8 +- - splash/Splash.cc | 1658 - ++++++++++++++++++++++++++++++------------ - splash/Splash.h | 42 +- - splash/SplashClip.cc | 57 +- - splash/SplashState.cc | 49 ++ - splash/SplashState.h | 12 + - splash/SplashXPathScanner.cc | 474 +++++++----- - splash/SplashXPathScanner.h | 24 +- - 15 files changed, 1845 insertions(+), 738 deletions(-) - -commit c2378609ae52523beb64e0f040fc79dce4877e03 -Author: Thomas Freitag -Date: Sat Jan 7 11:47:19 2012 +0100 - - regtest: read stderr output before calling wait to fix a possible - deadlock - - In the way the scripts starts it subprocesses, stderr becomes buffered - for the subprocesses. And unforunately, when the buffer limit is - reached, the subprocess suspends it work until it can print again on - stderr. That's why the python script runs into a deadlock when the - subprocess produces a lot of error messages. A small rearrange of the - commands, first read the stderr output and then wait that the - subprocess - ends, will remove this deadlock. - - regtest/backends/__init__.py | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit da6bfacb0f858f27bd47f247a25d6bc9ab778411 -Author: Adrian Johnson -Date: Sat Jan 7 10:35:17 2012 +1030 - - Add -subst option to pdffonts to list the substitute font name - and filename - - Bug 44416 - - poppler/FontInfo.cc | 8 ++++-- - poppler/FontInfo.h | 2 ++ - poppler/GlobalParams.cc | 29 +++++++++++++++++++-- - poppler/GlobalParams.h | 3 ++- - utils/pdffonts.1 | 3 +++ - utils/pdffonts.cc | 67 - +++++++++++++++++++++++++++++++++++-------------- - 6 files changed, 88 insertions(+), 24 deletions(-) - -commit 9979b1b3e36dc8085d8c684692fece463fa474b1 -Author: Yi Yang -Date: Sat Jan 7 09:44:42 2012 +1030 - - Include .otf fonts when finding substitute fonts - - Bug 44412 - - poppler/GfxFont.cc | 2 +- - poppler/GlobalParams.cc | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit ebfab832ab4f2642b9ab2ededd25de670a3c7147 -Author: Adrian Johnson -Date: Fri Dec 23 09:55:20 2011 +1030 - - autoconf: Check for cairo-ft and other cairo backends - - so that CAIRO_LIBS includes the freetype dependency and pdftocairo - includes the dependencies for optional cairo backends. - - Bug 43969 - - configure.ac | 14 ++++++++++++-- - utils/Makefile.am | 4 ++-- - 2 files changed, 14 insertions(+), 4 deletions(-) - -commit 51ca2b7c7dec5430d29860fd887ad5c5d9b3f574 -Author: Albert Astals Cid -Date: Thu Dec 15 00:26:09 2011 +0100 - - [xpdf303] Some more changes in TextOutputDev - - poppler/TextOutputDev.cc | 23 ++++++++++++++++------- - 1 file changed, 16 insertions(+), 7 deletions(-) - -commit c5ce12993a4d2bcd3b3e95b1f08d00dc8960678c -Author: Albert Astals Cid -Date: Wed Dec 14 22:49:33 2011 +0100 - - [xpdf303] Merge some stuff from TextOutputDev - - Yes, this is the best commit log i could think of - - poppler/TextOutputDev.cc | 268 - ++++++++++++++++++++++++++++++----------------- - poppler/TextOutputDev.h | 19 ++-- - 2 files changed, 180 insertions(+), 107 deletions(-) - -commit 388d72ac27ae98fe3a1ebd21760f2b0fa0249a9b -Author: Albert Astals Cid -Date: Tue Dec 6 23:21:15 2011 +0100 - - include strings.h as we use memcpy - - Fixes bug 43558 - - goo/PNGWriter.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 743f70f594bf3c9a58d1ff0738b9a2bc3ea03382 -Author: Albert Astals Cid -Date: Tue Dec 6 20:27:03 2011 +0100 - - xpdf303: Use xpdf method against recursion while parsing - - Ours detected loops correctly, but not "valid" files containing lots - of arrays one inside the other [[[[[[[[[[[[[[[[[[[ - So go to this more crude "fix" used in xpdf - - poppler/Dict.cc | 4 ++-- - poppler/Dict.h | 2 +- - poppler/Object.cc | 4 ++-- - poppler/Object.h | 8 ++++---- - poppler/Parser.cc | 32 +++++++++++++++----------------- - poppler/Parser.h | 10 +++------- - poppler/XRef.cc | 33 +++++++-------------------------- - poppler/XRef.h | 2 +- - 8 files changed, 35 insertions(+), 60 deletions(-) - -commit 63c942a45227ef28fb94ef4765171d9812fffafa -Author: Albert Astals Cid -Date: Sun Dec 4 17:29:45 2011 +0100 - - Do not fail if we are trying to save a file with Encrypt but that - we have not modified at all - - Fixes KDE bug #288045 - - poppler/PDFDoc.cc | 49 +++++++++++++++++++++++++++++-------------------- - 1 file changed, 29 insertions(+), 20 deletions(-) - -commit 0937d775e59a963b72fa7924e0f7be484f8345fc -Author: Albert Astals Cid -Date: Sun Dec 4 15:37:20 2011 +0100 - - update name and copyright - (cherry picked from commit 22601c2a64f094ede8085a3ccca3de9daaa556e7) - - utils/pdftocairo.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit bdb439ac5a751d6146204ae0d61fdbf7828c89c3 -Author: Axel Strübing -Date: Thu Nov 24 22:32:57 2011 +0100 - - Fix typo/regression introduced in - f6d026bfa18624ccd321e102bb39ba744998de1e - - poppler/Gfx.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 74e11d8c912dd95d235e44e7b34b8ea1be082b9f -Author: Albert Astals Cid -Date: Thu Nov 24 18:54:27 2011 +0100 - - Fix typo - - qt4/src/poppler-qt4.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit ec2a1c3fca92a28c56911729927838f7aacf1078 -Author: Albert Astals Cid -Date: Wed Nov 16 23:13:52 2011 +0100 - - xpdf303: Use the correct sizeof() for the greallocn - - poppler/XRef.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 544440b9d19ce99f3a7fcacdea70999b1efc217f -Author: Albert Astals Cid -Date: Wed Nov 16 23:09:23 2011 +0100 - - xpdf303: Add XRef::getPermFlags - - poppler/XRef.h | 1 + - 1 file changed, 1 insertion(+) - -commit b2e43e531edcecaeacf02a627c98cf7ef57f3e3c -Author: Albert Astals Cid -Date: Wed Nov 16 23:04:04 2011 +0100 - - xpdf303: make strToUnsigned "safer" - - poppler/PDFDoc.cc | 11 +++++++---- - 1 file changed, 7 insertions(+), 4 deletions(-) - -commit bd1513742182ed4c80d21401dd30180981879f24 -Author: Albert Astals Cid -Date: Wed Nov 16 22:59:12 2011 +0100 - - xpdf303: Check xrefEntryCompressed entries to be of correct type - and in bounds - - poppler/XRef.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 3bf3e82d1f3eb19a454239d8c7641fc68ff4e462 -Author: Albert Astals Cid -Date: Wed Nov 16 22:54:17 2011 +0100 - - xpdf303: Adobe apparently ignores the generation number on compressed - objects - - poppler/XRef.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 73e6f19c4e76762eb5131b168e3b24167ba126cb -Author: Albert Astals Cid -Date: Wed Nov 16 22:29:11 2011 +0100 - - xpdf303: Add PDFDoc::fileNameU to windows builds - - poppler/PDFDoc.cc | 43 +++++++++++++++++++++++++++++++++++-------- - poppler/PDFDoc.h | 6 ++++++ - 2 files changed, 41 insertions(+), 8 deletions(-) - -commit 65388b1aaf9a78efcf9486d5e2d4bdce76f11194 -Author: Igor Slepchin -Date: Tue Nov 15 21:53:40 2011 +0100 - - Output images in pdftohtml -xml mode if no -i option is specified. - - Comes with an attached update to pdf2xml.dtd - - utils/HtmlOutputDev.cc | 48 - ++++++++++++++++++++++++++++++++++++++++-------- - utils/pdf2xml.dtd | 22 +++++++++++++++++----- - 2 files changed, 57 insertions(+), 13 deletions(-) - -commit a4c78946bc1fc3d52152af2e319051050ab05e28 -Author: Albert Astals Cid -Date: Mon Nov 14 13:22:53 2011 +0100 - - Make GfxColorSpace::parse accept dicts too - - poppler/GfxState.cc | 14 +++++++++++++- - 1 file changed, 13 insertions(+), 1 deletion(-) - -commit f6d026bfa18624ccd321e102bb39ba744998de1e -Author: Albert Astals Cid -Date: Fri Nov 11 16:37:27 2011 +0100 - - Do not crash if failing to parse the colorspace - - Fixes bug 42793 - - poppler/Gfx.cc | 52 +++++++++++++++++++++++++++++----------------------- - 1 file changed, 29 insertions(+), 23 deletions(-) - -commit c9da140bb476dcbb3928950ae9b506de82695cd2 -Author: David King -Date: Thu Oct 20 11:31:10 2011 +0200 - - glib-demo: Conditionally initialise threading - - In GLib 2.24.0 and above, threading is enabled by default, and the - thread initialization functions are deprecated since GLib 2.31.0. - - Fixes bug #42036. - - glib/demo/main.c | 3 +++ - 1 file changed, 3 insertions(+) - -commit a0db250bbdefff6361551cf9db344bd5268fea11 -Author: Vittal Aithal -Date: Wed Nov 9 20:07:58 2011 +0100 - - pdfinfo: report page rotation - - utils/pdfinfo.cc | 8 ++++++++ - 1 file changed, 8 insertions(+) - -commit e7dbd17ff07afa465636a90f526cd7ac8c731862 -Author: Kenji Uno -Date: Wed Nov 9 12:39:41 2011 +0100 - - Fix leak in GooString when resizing - - If resizing from "long" to shorter - - goo/GooString.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 6a4f0c32b6723b127034d59a34bf076942e9935f -Author: Carlos Garcia Campos -Date: Sun Nov 6 15:44:06 2011 +0100 - - regtest: Skip tests with results when creating refs - - Not only tests that have md5, but also crashed or failed tests. - - regtest/TestReferences.py | 4 ++-- - regtest/backends/__init__.py | 3 +++ - 2 files changed, 5 insertions(+), 2 deletions(-) - -commit eab952d121c7ab88a0d41587cfa449c0978bea04 -Author: Pino Toscano -Date: Thu Nov 3 21:58:11 2011 +0100 - - qt4: remove unused variable - - qt4/src/poppler-embeddedfile.cc | 1 - - 1 file changed, 1 deletion(-) - -commit 85615f04e040dd38792533a4522e437644e97548 -Author: Pino Toscano -Date: Thu Nov 3 16:15:40 2011 +0100 - - qt4: get rid of the own F and Ff flags reading - - no more useful now, as they are available either directly or as - parsed values in both Annot and FormField - - qt4/src/poppler-form.cc | 16 ---------------- - qt4/src/poppler-private.h | 4 +--- - 2 files changed, 1 insertion(+), 19 deletions(-) - -commit 43347b43eeb66b5c8dc9637c36436baacc626bc4 -Author: Pino Toscano -Date: Thu Nov 3 16:10:57 2011 +0100 - - qt4: use the flags of the associated Annot object - - qt4/src/poppler-form.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 6c9492202de9b3b43da9eac3e40dc7fe218f21da -Author: Pino Toscano -Date: Thu Nov 3 16:03:11 2011 +0100 - - qt4: remove old commented code - - qt4/src/poppler-form.cc | 1 - - 1 file changed, 1 deletion(-) - -commit f0eca54131f7cdf6c1e0e78a18be0bf642567af4 -Author: Pino Toscano -Date: Thu Nov 3 15:46:33 2011 +0100 - - qt4: use the quadding read already in FormField - - ... instead of reading it again - - qt4/src/poppler-form.cc | 24 ++++++++---------------- - 1 file changed, 8 insertions(+), 16 deletions(-) - -commit d92bce1ae87d2f351bb1b972c64466502fb212aa -Author: Pino Toscano -Date: Thu Nov 3 15:30:45 2011 +0100 - - qt4: include - - qt4/src/poppler-private.h | 1 + - 1 file changed, 1 insertion(+) - -commit 955cd0c7bd3a72340deba098f4242a4904adc60f -Author: Albert Astals Cid -Date: Wed Nov 2 20:20:41 2011 +0100 - - Compile with MSVC needed for last change in the qt4 frontend - - CMakeLists.txt | 1 + - 1 file changed, 1 insertion(+) - -commit e0f5bc1deebaa9861baffd7c9ba31ea31585cd1d -Author: Hib Eris -Date: Tue Nov 1 14:15:09 2011 +0100 - - qt4: Use PDFDoc(wchar_t *, ...) on Windows - - Bug 35378 - - qt4/src/poppler-document.cc | 6 +++--- - qt4/src/poppler-private.h | 17 +++++++++++++++-- - 2 files changed, 18 insertions(+), 5 deletions(-) - -commit 52c1e9c5109299255d13b5b1e7d3eedaab512084 -Author: Carlos Garcia Campos -Date: Tue Nov 1 14:13:10 2011 +0100 - - regtest: Add --update-refs command line option to run-tests command - - It allows to update the references of failing tests. - - regtest/TestRun.py | 2 +- - regtest/backends/__init__.py | 34 ++++++++++++++++++++++++++++++++-- - regtest/commands/run-tests.py | 4 ++++ - 3 files changed, 37 insertions(+), 3 deletions(-) - -commit b4896a416b1df14a81b944b3c577fec85c9c7f7d -Author: Rex Dieter -Date: Tue Nov 1 09:40:53 2011 +0100 - - Fix pkg-config files - - We were using $FOO_REQUIRED instead of @FOO_REQUIRED@ - - configure.ac | 1 + - poppler-glib-uninstalled.pc.in | 2 +- - poppler-glib.pc.cmake | 2 +- - poppler-glib.pc.in | 2 +- - 4 files changed, 4 insertions(+), 3 deletions(-) - -commit 53f1b0c5edfdbef817bff31566893ac4e111516a -Author: Carlos Garcia Campos -Date: Sun Oct 30 16:02:19 2011 +0100 - - pdftocairo: Make sure beginDocument() is always called - - This fixes a crash when rendering only odd/even pages in a printing - format. - - utils/pdftocairo.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 8b0dfe9537082eaccd982530f1eddc2fcfc92f8e -Author: Albert Astals Cid -Date: Thu Oct 27 19:58:31 2011 +0200 - - xpdf303: Use splashDist instead of splashSqrt and USE_FIXEDPOINT - enhacements - - splash/SplashFTFont.cc | 70 - +++++++++++++++++++++++++++++++++++++++++++++----- - splash/SplashFTFont.h | 2 +- - 2 files changed, 65 insertions(+), 7 deletions(-) - -commit b021bce2583c8e1e3a4c129106d80e7a4e223600 -Author: Albert Astals Cid -Date: Thu Oct 27 19:54:22 2011 +0200 - - xpdf303: wops, make it compile - - poppler/Lexer.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 76295f4d401c36bdef3b2a20d18ac57a3b976410 -Author: Albert Astals Cid -Date: Thu Oct 27 19:42:42 2011 +0200 - - xpdf303: Adopt xpdf solution for the name too long problem - - poppler/Lexer.cc | 37 +++++++++++++++++-------------------- - 1 file changed, 17 insertions(+), 20 deletions(-) - -commit be6d4c19b8ce1515ce995eee408dc5752012c649 -Author: Albert Astals Cid -Date: Thu Oct 27 19:34:38 2011 +0200 - - xpdf303: Add brackets - - poppler/Lexer.cc | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit 904ae1385e93155a55008977c89aa664b7c8cb9b -Author: Albert Astals Cid -Date: Wed Oct 26 14:22:28 2011 +0200 - - Expose POPPLER_VERSION in poppler-config.h - - configure.ac | 3 +++ - poppler/poppler-config.h.cmake | 5 +++++ - poppler/poppler-config.h.in | 5 +++++ - 3 files changed, 13 insertions(+) - -commit aa83d4fe942ef0685c5990ddf3eccc2fbdf82292 -Author: Albert Astals Cid -Date: Thu Oct 20 00:59:57 2011 +0200 - - xpdf303: Add readFromStream - - poppler/GfxFont.cc | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit 74d771d58a4d1868669117709eb6811ec28bf840 -Author: Albert Astals Cid -Date: Thu Oct 20 00:56:58 2011 +0200 - - xpdf303: Add base14SubstFonts - - poppler/GfxFont.cc | 24 ++++++++++++++++++++++++ - 1 file changed, 24 insertions(+) - -commit 71260f987161d5b122caced6af14e9d64be46e4d -Author: Albert Astals Cid -Date: Thu Oct 20 00:55:42 2011 +0200 - - xpdf303: GfxFontLoc implementation - - poppler/GfxFont.cc | 20 ++++++++++++++++++++ - 1 file changed, 20 insertions(+) - -commit 586430137985fd303ce87bdb9b902ee9a01341e8 -Author: Albert Astals Cid -Date: Thu Oct 20 00:54:09 2011 +0200 - - xpdf303: More stuff into base14FontMap - - poppler/GfxFont.cc | 16 +++++++++++++++- - 1 file changed, 15 insertions(+), 1 deletion(-) - -commit c0affb1845c339f89ca67608cb9fd9134ff902f5 -Author: Albert Astals Cid -Date: Thu Oct 20 00:51:31 2011 +0200 - - xpdf303: GfxFont::getOrignName/getName rework - - poppler/FontInfo.cc | 4 ++-- - poppler/GfxFont.cc | 4 ---- - poppler/GfxFont.h | 6 +----- - poppler/PSOutputDev.cc | 8 ++++---- - poppler/TextOutputDev.cc | 5 ++--- - 5 files changed, 9 insertions(+), 18 deletions(-) - -commit c5c513b5b72e03f6f0a94d04f7d8a22fe9bdaa80 -Author: Albert Astals Cid -Date: Thu Oct 20 00:45:30 2011 +0200 - - xpdf303: GfxFontLoc - - poppler/GfxFont.h | 35 +++++++++++++++++++++++++++++++++++ - 1 file changed, 35 insertions(+) - -commit 4ec5e5e6d4785eb7a60744ae7e33c7ba3f603e8e -Author: Albert Astals Cid -Date: Thu Oct 20 00:34:10 2011 +0200 - - xpdf303: StdFontMapEntry renaming - - poppler/GfxFont.cc | 26 +++++++++++--------------- - poppler/GfxFont.h | 2 ++ - 2 files changed, 13 insertions(+), 15 deletions(-) - -commit e71088dc5087303b1ae5f3e72af287ec4e0a1342 -Author: Albert Astals Cid -Date: Mon Oct 17 13:42:06 2011 +0200 - - remove useless #if - - poppler/Page.cc | 4 +--- - 1 file changed, 1 insertion(+), 3 deletions(-) - -commit 40b56994dda79653c902977423f349efa55cf21e -Author: Adrian Johnson -Date: Mon Oct 17 20:33:03 2011 +1030 - - utils: Add GooString arg to parseargs and use for paths in pdftocairo - - and MAXPATHLEN is not available on windows. Avoid the - need to know the max path length by using GooString for the path. - - utils/parseargs.cc | 12 ++++++++++++ - utils/parseargs.h | 2 ++ - utils/pdftocairo.cc | 17 ++++++++--------- - 3 files changed, 22 insertions(+), 9 deletions(-) - -commit 4bb34757dbbff780baba053371274c05b29771e1 -Author: Adrian Johnson -Date: Mon Sep 19 21:11:44 2011 +0930 - - cairo: fix setSoftMask bugs - - - Getting the clip extents in device space requires transforming all - four corners of the clip extents and translating by the group device - offset other wise the device extents will not be correct for rotated - ctm. - - - Adjust matrix to include translation of the clip extents origin - since the mask surface does not start at (0,0). - - - the ctm when called cairo_mask() needs to be the same as the - ctm when - the mask was created. - - - implement transfer function in setSoftMask - - Bug 41005 - - poppler/CairoOutputDev.cc | 97 - +++++++++++++++++++++++++++++------------------ - poppler/CairoOutputDev.h | 6 ++- - 2 files changed, 65 insertions(+), 38 deletions(-) - -commit 50adbed183e9bf70eb4c41e8858cf464c3042e45 -Author: Carlos Garcia Campos -Date: Sun Oct 16 12:40:27 2011 +0200 - - Remove poppler-cairo dependency from poppler-glib pkg-config file - - poppler-glib links to poppler-cairo statically, so it doesn'tm - depend on - the dynamic library. - - CMakeLists.txt | 1 - - configure.ac | 2 -- - poppler-glib-uninstalled.pc.in | 2 +- - poppler-glib.pc.cmake | 2 +- - poppler-glib.pc.in | 2 +- - 5 files changed, 3 insertions(+), 6 deletions(-) - -commit acd8ecc9121db58851f73764f046a4f54bd80581 -Author: Adrian Johnson -Date: Sat Oct 8 15:03:24 2011 +1030 - - ps: fix uncolored tiling patterns - - Uncolored patterns and type 3 chars must not use color setting - operators. When emitting an uncolored pattern: - - disable the update color space functions - - disable the update color functions - - set pdfLastFill and pdfLastStroke to true to ensure the the sCol - and fCol procedures that is used by some of the PS procedures that - emulate PDF operators do not update the color. - - Bug 41462 - - poppler/PSOutputDev.cc | 41 +++++++++++++++++++++++++++++++++++++++++ - poppler/PSOutputDev.h | 1 + - 2 files changed, 42 insertions(+) - -commit 6e1326b11f98f2b277e53a6cdbcb373ce6c29958 -Author: Adrian Johnson -Date: Fri Oct 7 20:29:36 2011 +1030 - - ps: emit non repeating patterns in PSOutput with inType3Char = true - - instead of falling back to Gfx. This avoids emitting the image data - twice. - - poppler/PSOutputDev.cc | 23 +++++++++++++++++++++++ - 1 file changed, 23 insertions(+) - -commit ed05fcb8c442b716c5e382c98f2625701926c86a -Author: Adrian Johnson -Date: Sat Oct 1 20:19:19 2011 +0930 - - ps: fix tiling pattern fill matrix - - In PS the pattern matrix maps the pattern space to user space. In PDF - the pattern matrix maps the pattern space to the default ctm of the - content stream (baseMatrix in Gfx). The matrix mat already contains - the - correct pattern->baseMatrix so use it instead of pmat. - - Bug 41374 - - poppler/PSOutputDev.cc | 9 ++------- - 1 file changed, 2 insertions(+), 7 deletions(-) - -commit 087757866de13b6164967a1d241d3c0e47065f1a -Author: Albert Astals Cid -Date: Thu Oct 13 12:18:52 2011 +0200 - - xpdf303: Merge SplashT1Font::getGlyphPath changes - - splash/SplashT1Font.cc | 39 +++++++++++++++++++++------------------ - 1 file changed, 21 insertions(+), 18 deletions(-) - -commit c84f46ee16a8dcc6e2cad2359df621cc6cdb8fa5 -Author: Albert Astals Cid -Date: Thu Oct 13 12:16:14 2011 +0200 - - xpdf303: Add GBool type1 to SplashFTFontFile - - splash/SplashFTFontFile.cc | 9 +++++---- - splash/SplashFTFontFile.h | 3 ++- - 2 files changed, 7 insertions(+), 5 deletions(-) - -commit d845da2c3c1acbeaa4b9bb3125f9143e785210ff -Author: Yury G. Kudryashov -Date: Thu Oct 6 14:49:19 2011 +0200 - - Okular moved to git, fix docs - - Fix URLs in poppler-qt4 documentation - - qt4/src/Mainpage.dox | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit bb40c980f7ab7a6eb9735af17103f87bc65893d6 -Author: Yury G. Kudryashov -Date: Thu Oct 6 14:49:08 2011 +0200 - - Explicitly include fontconfig include dir - - This fixes cmake-driven build on systems where fontconfig is - installed in - non-standard location. - - CMakeLists.txt | 1 + - 1 file changed, 1 insertion(+) - -commit 776ca137984556530ba938265714934bdc3d6443 -Author: Yury G. Kudryashov -Date: Thu Oct 6 14:48:46 2011 +0200 - - Fix typo in cmake option documentation - - Relocatable build does *not* (was missing in docs) hardcode library - location. - - CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ab8616dcb637ac1aeb4d5f142c3c4bff9aecd041 -Author: Adrian Johnson -Date: Thu Oct 6 14:21:10 2011 +0200 - - close the file or flush stdout - - utils/pdftocairo.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 72c2d563684ab6937a98a0c1c79be3639d29c9ce -Author: Albert Astals Cid -Date: Tue Oct 4 17:46:11 2011 +0200 - - xpdf303: Make sure array length is > 0 - - This is not scritcly necessary since Array::get already returns a - null object in case - the index is out of range but let's merge it for the sake of being - more closer to xpdf - - poppler/GfxState.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit c814c2452c7f60623fdd0fee6f915adeaf5b49e3 -Author: Albert Astals Cid -Date: Tue Oct 4 17:40:27 2011 +0200 - - xpdf303: Limit recursion in GfxColorSpace parsing - - I think we could do it better, but it'd take more time and it's not - what we are doing in this branch anyway - - poppler/GfxState.cc | 43 +++++++++++++++++++++++++++---------------- - poppler/GfxState.h | 14 +++++++------- - 2 files changed, 34 insertions(+), 23 deletions(-) - -commit 0e53ba5709296dc2ba1399f885af200d2041f0cd -Author: Glad Deschrijver -Date: Sat Oct 1 15:41:51 2011 +0200 - - qt4: Add the option of PSConverter creating EPS - - qt4/src/poppler-ps-converter.cc | 3 ++- - qt4/src/poppler-qt4.h | 6 ++++-- - 2 files changed, 6 insertions(+), 3 deletions(-) - -commit 04e271a0c10807c9c3967daa1f656e87b97b9901 -Author: Albert Astals Cid -Date: Sat Oct 1 14:34:50 2011 +0200 - - Fix typo in documentation - - Reported by Glad Deschrijver - (cherry picked from commit 1346caac6c564035d368617a329b361d0253fbf6) - - qt4/src/poppler-qt4.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 9855529e8e1a83c6d77a9e4221ea2132d44e9fb1 -Author: Albert Astals Cid -Date: Sat Oct 1 14:27:44 2011 +0200 - - Remove space after % as it confuses libspectre - - Discussed with Adrian Johnson - Problem found by Glad Deschrijver - - poppler/PSOutputDev.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 8e8cde6f374b59222d834e2e7f08fb4a6a4d55a5 -Author: Albert Astals Cid -Date: Wed Sep 28 23:32:24 2011 +0200 - - xpdf303: More manpage merging - - utils/pdftotext.1 | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - -commit f798f00c9ec55bff2eb93938424c436ba2663e7a -Author: Albert Astals Cid -Date: Wed Sep 28 23:30:55 2011 +0200 - - xpdf303: mention pdfdetach in non xpdf tools - - utils/pdftocairo.1 | 1 + - utils/pdftohtml.1 | 1 + - 2 files changed, 2 insertions(+) - -commit 3fc46ac1c046460ccf46ba4b8a92f728e775694a -Author: Albert Astals Cid -Date: Wed Sep 28 23:30:00 2011 +0200 - - xpdf303: Fix pdfdetach man page references - - utils/pdfdetach.1 | 14 ++++++-------- - 1 file changed, 6 insertions(+), 8 deletions(-) - -commit 79e1d77fb00a7c7f0bda4ae76328c4211c7f16e6 -Author: Albert Astals Cid -Date: Wed Sep 28 23:27:53 2011 +0200 - - xpdf303: Merge some more manpages - - utils/pdfinfo.1 | 15 +++++++++++---- - utils/pdftoppm.1 | 9 +++++---- - 2 files changed, 16 insertions(+), 8 deletions(-) - -commit 841c96be59ddad32f51d4d114ba1dcc42285ab55 -Author: Albert Astals Cid -Date: Wed Sep 28 23:23:25 2011 +0200 - - xpdf303: Merge some man pages - - utils/pdffonts.1 | 9 +++++---- - utils/pdfimages.1 | 9 +++++---- - utils/pdftops.1 | 9 +++++---- - 3 files changed, 15 insertions(+), 12 deletions(-) - -commit d2706a05513134f961e2500e0e596f2769707ce5 -Author: Adrian Johnson -Date: Wed Sep 28 21:20:23 2011 +0930 - - cairo: fix crash when using poppler_page_get_image() - - poppler/CairoOutputDev.h | 1 + - 1 file changed, 1 insertion(+) - -commit 0c0591fa23441c54c9443072615273ea65482d76 -Author: Albert Astals Cid -Date: Tue Sep 27 00:45:59 2011 +0200 - - 0.18.0 - - CMakeLists.txt | 6 ++-- - NEWS | 14 ++++++++ - configure.ac | 4 +-- - cpp/Doxyfile | 2 +- - gtk-doc.make | 102 - ++++++++++++++++++++++------------------------------ - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 7 files changed, 64 insertions(+), 68 deletions(-) - -commit 19f5db7acd64330d198f18695175df02141794d7 -Author: Albert Astals Cid -Date: Tue Sep 27 00:15:15 2011 +0200 - - Update Carlos (C) year - - poppler/Gfx.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 6d34d4af90b8b41360de4dabb000bbcc894775d0 -Author: Albert Astals Cid -Date: Tue Sep 27 00:09:54 2011 +0200 - - Rename pdfmerge and pdfextract - - To pdfunite and pdfseparate, the old names were taken - - utils/.gitignore | 4 +- - utils/CMakeLists.txt | 28 ++++---- - utils/Makefile.am | 16 ++--- - utils/pdfextract.1 | 49 -------------- - utils/pdfextract.cc | 115 --------------------------------- - utils/pdfmerge.1 | 33 ---------- - utils/pdfmerge.cc | 176 - --------------------------------------------------- - utils/pdfseparate.1 | 49 ++++++++++++++ - utils/pdfseparate.cc | 115 +++++++++++++++++++++++++++++++++ - utils/pdfunite.1 | 33 ++++++++++ - utils/pdfunite.cc | 176 - +++++++++++++++++++++++++++++++++++++++++++++++++++ - 11 files changed, 397 insertions(+), 397 deletions(-) - -commit baf54c2876edd476ffc68da6518598847bb7ec8a -Author: Albert Astals Cid -Date: Mon Sep 26 15:54:46 2011 +0200 - - Remove getRawStream - - Since it does exactly the same as getNextStream - - poppler/DCTStream.h | 1 - - poppler/Stream.h | 1 - - utils/HtmlOutputDev.cc | 7 ++----- - utils/ImageOutputDev.cc | 9 +++------ - 4 files changed, 5 insertions(+), 13 deletions(-) - -commit bba57e588fd1ee3a61f18405d1d1bf89fceb5b96 -Author: Carlos Garcia Campos -Date: Sun Sep 25 12:21:02 2011 +0200 - - xpdf303: Added the pdfdetach tool - - I haven't merged xpdf code for embedded files, I think our - implementation is better and more complete. I've adapated pdfdetach - code to use our code and return also embedded files of file attachment - annotations to match what xpdf does. - - poppler/FileSpec.cc | 22 ++++ - poppler/FileSpec.h | 3 + - utils/CMakeLists.txt | 9 ++ - utils/Makefile.am | 6 + - utils/pdfdetach.1 | 105 +++++++++++++++++ - utils/pdfdetach.cc | 318 - +++++++++++++++++++++++++++++++++++++++++++++++++++ - 6 files changed, 463 insertions(+) - -commit f62c2f002c782d3a7887525f031d266aca6eb582 -Author: Carlos Garcia Campos -Date: Sat Sep 24 11:20:13 2011 +0200 - - xpdf303: Parse ActualText in Gfx instead of output devices - - Remove beginMarkedContent and endMarkedcontent and add beginActualText - and endActualText. ActualText is parsed in Gfx, that already - handles the - marked content stack, so that text output dev doesn't need to - handle it - too. The text string is passed to beginActualText(). This change - is not - an exact merge of xpdf code, I've tried to keep our implementation. - - poppler/CairoOutputDev.cc | 8 +-- - poppler/CairoOutputDev.h | 6 +- - poppler/Gfx.cc | 40 +++++++++---- - poppler/OutputDev.cc | 6 -- - poppler/OutputDev.h | 4 +- - poppler/TextOutputDev.cc | 145 - +++++++++++++++++++--------------------------- - poppler/TextOutputDev.h | 21 ++++--- - 7 files changed, 108 insertions(+), 122 deletions(-) - -commit a097447ed13cb021003425f85597e2628935feb2 -Author: Carlos Garcia Campos -Date: Sat Sep 24 09:43:05 2011 +0200 - - Use new error syntax in pdfextract - - utils/pdfextract.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 718c735aed540aa49b8dde250ca886c6ad93f5b6 -Merge: 6721916 69707f0 -Author: Carlos Garcia Campos -Date: Sat Sep 24 09:38:52 2011 +0200 - - Merge branch 'master' into xpdf303merge - -commit 69707f0a9b5a94c80817039db943fb4f26e743e3 -Author: Adrian Johnson -Date: Mon Sep 19 22:00:34 2011 +0930 - - Update .gitignore - - regtest/.gitignore | 1 + - utils/.gitignore | 2 ++ - 2 files changed, 3 insertions(+) - -commit 0de477817e424078cfcfcae114e7745809f0848d -Author: Adrian Johnson -Date: Mon Sep 19 21:57:07 2011 +0930 - - utils: Add Glyph & Cog copyright to pdfmerge and pdfextract man pages - - utils/pdfextract.1 | 3 ++- - utils/pdfmerge.1 | 3 ++- - 2 files changed, 4 insertions(+), 2 deletions(-) - -commit ce7372db64ee807dc2b491e121fbe557dbf697e8 -Author: Adrian Johnson -Date: Mon Sep 19 22:04:27 2011 +0930 - - regtest: render cairo at 72ppi - - For consistency with splash. It is faster and easier to compare with - splash results. - - regtest/backends/cairo.py | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 6cf7330089c4dcc1099906d9c37c3607a2a1eeba -Author: Carlos Garcia Campos -Date: Mon Sep 19 18:42:35 2011 +0200 - - regtest: Ignore checksums of crashed, failed and stderr files - - They shouldn't have a checksum, but it might happen with md5 files - generated with previous versions. - - regtest/backends/__init__.py | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 6512bf1c5dab37058460882fec3407b396830981 -Author: Albert Astals Cid -Date: Sun Sep 18 18:38:32 2011 +0200 - - Render at 72 instead of 150, it's faster :D - - regtest/backends/splash.py | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit b828f63ed3896a22f3fe7ddbe2ec2f549d7a2c62 -Author: Albert Astals Cid -Date: Sun Sep 18 18:20:47 2011 +0200 - - install pdfextract and pdfmerge manpages - - utils/CMakeLists.txt | 2 ++ - 1 file changed, 2 insertions(+) - -commit 986759dfbe85998c85ee9b0825c7522395567531 -Author: Thomas Freitag -Date: Sun Sep 18 18:19:30 2011 +0200 - - pdfextract and pdfmerge man pages - - utils/Makefile.am | 2 ++ - utils/pdfextract.1 | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ - utils/pdfmerge.1 | 32 ++++++++++++++++++++++++++++++++ - 3 files changed, 82 insertions(+) - -commit 90da1af542fd7f3cecef31b15da6971345b38209 -Author: Thomas Freitag -Date: Sun Sep 18 18:19:04 2011 +0200 - - Complain if %d is not present and it should - - utils/pdfextract.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 40e066a84ddb3a5c41805c095659af5f5704d6d8 -Author: suzuki toshiya -Date: Sun Sep 18 18:16:14 2011 +0200 - - qt_subdir is unneeded - - Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 6721916c92d720947b3285c85fdbe6610c6bf013 -Merge: 8456a6e e23f6b9 -Author: Carlos Garcia Campos -Date: Sun Sep 18 16:31:10 2011 +0200 - - Merge branch 'master' into xpdf303merge - - Conflicts: - poppler/Gfx.cc - -commit e23f6b9cade804136bd4bb58182f4fe0b072fbf2 -Author: Carlos Garcia Campos -Date: Sun Sep 18 16:27:50 2011 +0200 - - regtest: Do not create checksums for crashed, failed and stderr files - - regtest/backends/__init__.py | 12 +++++++++++- - 1 file changed, 11 insertions(+), 1 deletion(-) - -commit 110b8be1d9f2694b42bd12dcb6af02bfca9866dd -Author: Carlos Garcia Campos -Date: Sun Sep 18 16:26:58 2011 +0200 - - Fix memory leak - - poppler/Gfx.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 8456a6e1354126dc98357fb806595bd3bc198522 -Author: Carlos Garcia Campos -Date: Sun Sep 18 16:07:54 2011 +0200 - - xpdf303: Add OCDisplayNode - - It's not used by poppler yet, but we might want to use it from the - frontends after the merge. - - poppler/OptionalContent.cc | 127 - +++++++++++++++++++++++++++++++++++++++++++++ - poppler/OptionalContent.h | 36 ++++++++++++- - 2 files changed, 162 insertions(+), 1 deletion(-) - -commit 06c6660dc9fe326f185ff323e643af6714b32ec8 -Author: Carlos Garcia Campos -Date: Sun Sep 18 15:08:44 2011 +0200 - - xpdf303: Parse usage dictionary of optional content groups - - poppler/OptionalContent.cc | 28 ++++++++++++++++++++++++++++ - poppler/OptionalContent.h | 14 +++++++++++++- - 2 files changed, 41 insertions(+), 1 deletion(-) - -commit 528d5b0d40302b3fee3aec69b85bdd1daa4db568 -Author: Carlos Garcia Campos -Date: Sun Sep 18 14:03:36 2011 +0200 - - xpdf303: Image XObjects can have a OC entry too - - poppler/Gfx.cc | 11 ++++++++++- - 1 file changed, 10 insertions(+), 1 deletion(-) - -commit c40353d3bb761f5be8ddbd2bf5341e83901fb132 -Author: Carlos Garcia Campos -Date: Sun Sep 18 13:32:07 2011 +0200 - - xpdf303: OC entry is specific to form XObjects - - poppler/Gfx.cc | 17 +++++++++-------- - 1 file changed, 9 insertions(+), 8 deletions(-) - -commit 6ddb51d81b064346dc85d2ae72570a956a184d74 -Author: Carlos Garcia Campos -Date: Sun Sep 18 12:59:28 2011 +0200 - - xpdf303: The spec doesn't say OC must be null or ref - - poppler/Annot.cc | 5 +---- - poppler/Gfx.cc | 22 +++++++--------------- - 2 files changed, 8 insertions(+), 19 deletions(-) - -commit 434bb9b38319edc7282be22044bd7761403a38a6 -Author: Carlos Garcia Campos -Date: Sun Sep 18 12:45:12 2011 +0200 - - xpdf303: OC entry can be an optional content group too - - Not only an optional content membership dictionary. - - poppler/OptionalContent.cc | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -commit 56410b80fdabb99e2de0c6589de6ee745936c523 -Author: Carlos Garcia Campos -Date: Sun Sep 18 12:44:02 2011 +0200 - - xpdf303: Not finding an oc group is not necessarily a syntax error - - poppler/OptionalContent.cc | 2 -- - 1 file changed, 2 deletions(-) - -commit 4bb4439450e342479375cb56d10561457475bd13 -Author: Carlos Garcia Campos -Date: Sun Sep 18 12:42:15 2011 +0200 - - xpdf303: Fix check of OptionalContentGroup::getState() - - We use an enum, not a boolean. - - poppler/OptionalContent.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit d737e3098e02e46525c0edf2165462e03ac7a0e6 -Author: Carlos Garcia Campos -Date: Sun Sep 18 11:36:11 2011 +0200 - - xpdf303: Add support for visibility expressions in OptContent - - poppler/OptionalContent.cc | 113 - +++++++++++++++++++++++++++++++++++---------- - poppler/OptionalContent.h | 3 +- - 2 files changed, 91 insertions(+), 25 deletions(-) - -commit 258d56ba85902a8ab50eec3fe66dd6425226fa59 -Merge: 72a7736 12c6239 -Author: Carlos Garcia Campos -Date: Sun Sep 18 11:12:38 2011 +0200 - - Merge branch 'master' into xpdf303merge - -commit 12c6239ca4f1f6a5de72aebd755f9d1354ea5837 -Author: Carlos Garcia Campos -Date: Sun Sep 18 11:08:06 2011 +0200 - - regtest: Fix checksum check for tests containing spaces in filename - - regtest/backends/__init__.py | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 72a7736389cbe36c1f8a526f1a659cae1a3f85a3 -Author: Carlos Garcia Campos -Date: Sun Sep 18 10:47:51 2011 +0200 - - xpdf303: No need to cache optContentConfig object in Annot - - poppler/Annot.cc | 2 +- - poppler/Annot.h | 2 -- - 2 files changed, 1 insertion(+), 3 deletions(-) - -commit 93ba92db0a3af35f197a4faa5a528af98ea0f624 -Author: Albert Astals Cid -Date: Wed Sep 14 00:58:44 2011 +0200 - - Make it work with Python3 - - regtest/Config.py | 4 ++-- - regtest/TestReferences.py | 8 ++++---- - regtest/TestRun.py | 32 ++++++++++++++++---------------- - regtest/Timer.py | 8 ++++---- - regtest/backends/__init__.py | 12 ++++++------ - regtest/commands/__init__.py | 6 +++--- - regtest/commands/create-refs.py | 2 +- - regtest/commands/run-tests.py | 2 +- - regtest/main.py | 2 +- - 9 files changed, 38 insertions(+), 38 deletions(-) - -commit da1b5437148e1e6317246b16f7235c8bc280be97 -Author: Carlos Garcia Campos -Date: Tue Sep 13 20:09:56 2011 +0200 - - regtest: Add a way to skip files - - A new command line option --skip has been added to give a file - with the - list of test to skip. When --skip is not used, it look for a file - named - Skipped in the tests dir. Lines starting with '#' are considered - comments and are ignored. - - regtest/TestReferences.py | 9 +++++++-- - regtest/TestRun.py | 9 +++++++-- - regtest/Utils.py | 20 ++++++++++++++++++++ - regtest/main.py | 6 +++++- - 4 files changed, 39 insertions(+), 5 deletions(-) - -commit b730b2c1d9666f62f940762663c8318e64049d61 -Author: Carlos Garcia Campos -Date: Tue Sep 13 19:04:04 2011 +0200 - - regtest: Limit the number of arguments to 1 - - It's easier to run poppler-regtest more than once if you need to run - different tests. - - regtest/commands/create-refs.py | 24 ++++++++++++------------ - regtest/commands/run-tests.py | 26 +++++++++++++------------- - regtest/main.py | 2 +- - 3 files changed, 26 insertions(+), 26 deletions(-) - -commit 5ce045d0358318859c844340c639483485b69c58 -Author: Carlos Garcia Campos -Date: Tue Sep 13 18:18:21 2011 +0200 - - regtest: Sort tests before create-refs/run-tests and show progress - - regtest/TestReferences.py | 20 ++++++++------------ - regtest/TestRun.py | 21 ++++++++++----------- - regtest/Utils.py | 35 +++++++++++++++++++++++++++++++++++ - 3 files changed, 53 insertions(+), 23 deletions(-) - -commit 10801b6faee9037af054fe74cc4a03620ea41d45 -Author: Carlos Garcia Campos -Date: Mon Sep 12 20:13:17 2011 +0200 - - Add initial poppler regressions test program - - regtest/Config.py | 32 ++++++ - regtest/TestReferences.py | 73 +++++++++++++ - regtest/TestRun.py | 156 ++++++++++++++++++++++++++++ - regtest/Timer.py | 73 +++++++++++++ - regtest/backends/__init__.py | 220 - ++++++++++++++++++++++++++++++++++++++++ - regtest/backends/cairo.py | 39 +++++++ - regtest/backends/postscript.py | 35 +++++++ - regtest/backends/splash.py | 39 +++++++ - regtest/backends/text.py | 48 +++++++++ - regtest/commands/__init__.py | 93 +++++++++++++++++ - regtest/commands/create-refs.py | 65 ++++++++++++ - regtest/commands/run-tests.py | 69 +++++++++++++ - regtest/main.py | 77 ++++++++++++++ - regtest/poppler-regtest | 6 ++ - 14 files changed, 1025 insertions(+) - -commit 245e331a14e11a615bf47abbeb34a3561e393b41 -Author: Albert Astals Cid -Date: Mon Sep 12 13:43:49 2011 +0200 - - 0.17.4 - - CMakeLists.txt | 2 +- - NEWS | 5 +++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - 5 files changed, 9 insertions(+), 4 deletions(-) - -commit 194b2413eb2c6a1641508aec63336aaf89ec3b51 -Author: Albert Astals Cid -Date: Mon Sep 12 13:43:35 2011 +0200 - - gir 0.18 - - glib/CMakeLists.txt | 12 ++++++------ - glib/Makefile.am | 12 ++++++------ - 2 files changed, 12 insertions(+), 12 deletions(-) - -commit 61c06d2efad20880e1e0b399cf797dd55f6c8dab -Author: Albert Astals Cid -Date: Mon Sep 12 00:32:38 2011 +0200 - - xpdf303: Useless NULL assignments - - poppler/SplashOutputDev.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 4fbcbf1ffb8a98fe8c12643fdab2cbd90b4e60f9 -Author: Albert Astals Cid -Date: Mon Sep 12 00:30:52 2011 +0200 - - xpdf303: Set size to 64 instead of 100 - - poppler/SplashOutputDev.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 1c7203e57e9c7c264f5cada6362a6b449dd8689c -Author: Albert Astals Cid -Date: Mon Sep 12 00:21:03 2011 +0200 - - xpdf303: Avoid calling a "slow" function - - poppler/PSOutputDev.cc | 9 ++++++--- - 1 file changed, 6 insertions(+), 3 deletions(-) - -commit db4c5789bf95af9f45a7911153acc20a26a447f1 -Author: Albert Astals Cid -Date: Mon Sep 12 00:19:49 2011 +0200 - - xpdf303: fix spacing - - poppler/PSOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 10c3d15f841865929d2f66353cb01d0d321e8b82 -Author: Albert Astals Cid -Date: Mon Sep 12 00:03:13 2011 +0200 - - xpdf303: make limit smaller - - poppler/PSOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 1d4e6e739701ba817576752ced169b24c5e95156 -Author: Albert Astals Cid -Date: Sun Sep 11 23:57:22 2011 +0200 - - xpdf303: Remove 512 limit in pdftoppm - - utils/pdftoppm.cc | 13 ++++++------- - 1 file changed, 6 insertions(+), 7 deletions(-) - -commit e4e843f1115d95c54967f0386bfb28f685d6c88d -Author: Albert Astals Cid -Date: Sun Sep 11 22:49:34 2011 +0200 - - xpdf303: Rework nComps != colorSpace->getNComps() handling - - poppler/GfxState.cc | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -commit dda45b6a67f3f97705e5d806eaf7d37171789e66 -Author: Albert Astals Cid -Date: Sun Sep 11 22:46:51 2011 +0200 - - xpdf303: NULL GfxICCBasedColorSpace if array does not have 2 elements - - poppler/GfxState.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 760e814a6d26db8eba567520aad771002e11357a -Author: Albert Astals Cid -Date: Sun Sep 11 22:21:40 2011 +0200 - - xpdf303: increase formDepth limit - - poppler/Gfx.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 59442e5994f3b94d5221cbc90f79fad235fe2611 -Author: Albert Astals Cid -Date: Sun Sep 11 22:10:41 2011 +0200 - - xpdf303: Remove flags that were never used - - splash/Splash.cc | 6 +----- - splash/SplashXPath.cc | 34 ++++------------------------------ - splash/SplashXPath.h | 13 ++++--------- - 3 files changed, 9 insertions(+), 44 deletions(-) - -commit 41a620ef60507ceda42a14d06d6587ed10016468 -Author: Albert Astals Cid -Date: Thu Sep 8 16:18:01 2011 +0200 - - xpdf303: Adapt use of getBlock to our use of getChars - - poppler/Stream.cc | 58 - +++++++++++++++++++++++++++++++++---------------------- - poppler/Stream.h | 2 ++ - 2 files changed, 37 insertions(+), 23 deletions(-) - -commit 2f7701fe730a648d0a1d181c5b20e4802640dc52 -Author: Albert Astals Cid -Date: Thu Sep 8 15:59:27 2011 +0200 - - xpdf303: Adapt xpdf getBlock to our getChars - - poppler/JBIG2Stream.cc | 17 ++++++++ - poppler/JBIG2Stream.h | 2 + - poppler/Stream.cc | 113 - ++++++++++++++++++++++++++++++++++++++++++++----- - poppler/Stream.h | 55 +++++++++++++----------- - 4 files changed, 152 insertions(+), 35 deletions(-) - -commit 3a1988db40def1655ec638cd521ed40eadc0acca -Author: Carlos Garcia Campos -Date: Thu Sep 8 15:40:12 2011 +0200 - - xpdf303: empty pages need to call dump to do any setup required by - the OutputDev - - poppler/Page.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 4cddaed21592ac491519a81a003035bc4e618705 -Author: Carlos Garcia Campos -Date: Thu Sep 8 15:35:33 2011 +0200 - - xpdf303: Don't clip the other page boxes to the MediaBox at the - intermediate nodes - - only do it at the leaf (Page) nodes - the other boxes can be specified - before the MediaBox is specified. - I think we already had that change, we checked isPage before clipping, - I've merged this way just to make future merges a bit easier. - - poppler/Page.cc | 16 ++++++++-------- - poppler/Page.h | 3 +++ - 2 files changed, 11 insertions(+), 8 deletions(-) - -commit 3538ac89bfea750de8907847d1d5e3515d0b8be7 -Author: Albert Astals Cid -Date: Thu Sep 8 15:07:21 2011 +0200 - - xpdf303: compile - - poppler/ArthurOutputDev.cc | 12 +++++++++++- - 1 file changed, 11 insertions(+), 1 deletion(-) - -commit 89d95d0f254a828d28d943b698eeaec51f03686f -Author: Carlos Garcia Campos -Date: Thu Sep 8 12:38:36 2011 +0200 - - xpdf303: Add codeToGID and codeToGIDLen params to - loadOpenTypeCFFFont() - - poppler/SplashOutputDev.cc | 12 +++++++++++- - splash/SplashFTFontEngine.cc | 29 +++++++++++++++++------------ - splash/SplashFTFontEngine.h | 3 ++- - splash/SplashFontEngine.cc | 6 ++++-- - splash/SplashFontEngine.h | 3 ++- - 5 files changed, 36 insertions(+), 17 deletions(-) - -commit d768204e51e6bdbcac4d6b43537297616cbedbf3 -Author: Albert Astals Cid -Date: Tue Sep 6 21:56:43 2011 +0200 - - xpdf303: Revert b36d150931cd555b84ee996d505e8b91e2afde19 - - Breaks bug164568-2.pdf so our fix was better :-) - - poppler/JBIG2Stream.cc | 91 - ++++++++++++++++++++++---------------------------- - poppler/JBIG2Stream.h | 1 - - 2 files changed, 40 insertions(+), 52 deletions(-) - -commit 2230b8f2128edf4994d8a742f562e1b5acf96b74 -Author: Albert Astals Cid -Date: Tue Sep 6 00:05:53 2011 +0200 - - xpdf303: Merge JPXStream changes - - poppler/JPXStream.cc | 1000 - +++++++++++++++++++++++++++++++------------------- - poppler/JPXStream.h | 43 +-- - 2 files changed, 632 insertions(+), 411 deletions(-) - -commit 35bb53feaa2e469253368f03a9835d73aeb1a240 -Author: Albert Astals Cid -Date: Mon Sep 5 23:20:09 2011 +0200 - - xpdf303: Add BufStream - - poppler/Stream.cc | 46 ++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Stream.h | 25 +++++++++++++++++++++++++ - 2 files changed, 71 insertions(+) - -commit 8a9d92fcf05285c1f06bc153aa79d0200d05bbd9 -Author: Albert Astals Cid -Date: Mon Sep 5 22:57:02 2011 +0200 - - xpdf303: CCITTFaxStream header misc fixes - - poppler/Stream.h | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 22d370c0a1f8c016ebc5a6d8320fe55bfd31c8a7 -Author: Albert Astals Cid -Date: Mon Sep 5 22:53:45 2011 +0200 - - xpdf303: DCTStream misc fixes - - poppler/Stream.cc | 32 ++++++++++++++++++++++++++------ - 1 file changed, 26 insertions(+), 6 deletions(-) - -commit 36d3057546b5a1d717c71b8dcb9773f91e3b5960 -Author: Albert Astals Cid -Date: Mon Sep 5 22:46:59 2011 +0200 - - xpdf303: Add some {} - - poppler/Stream.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 308654eb5dfbb783f29bd645f60c79d5b5fe42c9 -Author: Albert Astals Cid -Date: Mon Sep 5 22:45:50 2011 +0200 - - xpdf303: code1 changed to int in CCITTFaxStream::reset - - poppler/Stream.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit f097dc1f9d580eb1cdc8180d3920fe795493cf89 -Author: Albert Astals Cid -Date: Mon Sep 5 22:43:16 2011 +0200 - - xpdf303: Use 32 bits in CCITTFaxStream::lookBits - - poppler/Stream.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit b5417659042c95891aa549cae396ba4cc6604030 -Author: Albert Astals Cid -Date: Mon Sep 5 22:40:02 2011 +0200 - - xpdf303: Check against lookBits returning EOF - - poppler/Stream.cc | 17 ++++++++++------- - 1 file changed, 10 insertions(+), 7 deletions(-) - -commit eaf9d31c97a3cc06f4ce94d9190ae1a337634749 -Author: Albert Astals Cid -Date: Mon Sep 5 22:38:05 2011 +0200 - - xpdf303: Set endOfLine to true if code1 is 1 - - poppler/Stream.cc | 1 + - 1 file changed, 1 insertion(+) - -commit a654a77e26a6c7d76c318636303f8c636a3d2495 -Author: Albert Astals Cid -Date: Mon Sep 5 22:36:58 2011 +0200 - - xpdf303: Tweaks to CCITTFaxStream::lookChar - - poppler/Stream.cc | 55 - +++++++++++++++++++++++++++++++++++++++++++------------ - 1 file changed, 43 insertions(+), 12 deletions(-) - -commit abdf828449cd543e66f326ba862efcb3ca6d342d -Author: Albert Astals Cid -Date: Mon Sep 5 22:19:30 2011 +0200 - - xpdf303: Remove cygwin workaround - - poppler/Stream.cc | 4 ---- - 1 file changed, 4 deletions(-) - -commit 05ef4227d09381e3a9e8050e447770f44d532386 -Author: Albert Astals Cid -Date: Mon Sep 5 22:18:33 2011 +0200 - - xpdf303: Return false if getLine fails - - poppler/Stream.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit c2d6158bd56328754d77ab8f1bf84d46e6ede773 -Author: Albert Astals Cid -Date: Mon Sep 5 22:14:39 2011 +0200 - - xpdf303: Return NULL if size < 0 - - poppler/Stream.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 04947e1dca858b890302a5a1005b84b34255d670 -Author: Albert Astals Cid -Date: Mon Sep 5 22:11:24 2011 +0200 - - xpdf303: Add -rawdates and print Form information - - utils/pdfinfo.cc | 30 +++++++++++++++++++++++++++--- - 1 file changed, 27 insertions(+), 3 deletions(-) - -commit 9529e776e53e71069ba4215cdb8b84592d37b555 -Author: Carlos Garcia Campos -Date: Mon Sep 5 21:19:58 2011 +0200 - - xpdf303: Other fixes in PostScriptFunction - - poppler/Function.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 071f983f461ba0b872dd93d7f1a24d325312799d -Author: Carlos Garcia Campos -Date: Mon Sep 5 21:19:13 2011 +0200 - - xpdf303: Fixed a bug in the PostScript-type function parser - - Real numbers that start with a decimal point weren't being handled - correctly. - - poppler/Function.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit da0eff1aaa31c2bf357a64b6275645100c9629d4 -Author: Carlos Garcia Campos -Date: Mon Sep 5 21:12:02 2011 +0200 - - xpdf303: Fixes in StitchingFunction - - poppler/Function.cc | 6 ++---- - 1 file changed, 2 insertions(+), 4 deletions(-) - -commit b655316706ec394fa6c8ad076d9d9d96ac8ed563 -Author: Albert Astals Cid -Date: Mon Sep 5 21:05:55 2011 +0200 - - xpdf303: Rework LinkURI decoding - - poppler/Link.cc | 35 +++++++++++++++++++---------------- - 1 file changed, 19 insertions(+), 16 deletions(-) - -commit abad9b4e44d81a206bccff8a109ceb9a7effa2ad -Author: Carlos Garcia Campos -Date: Mon Sep 5 21:00:31 2011 +0200 - - xpdf303: Cache the last transform for PostScript-type functions - - poppler/Function.cc | 37 ++++++++++++++++++++++++++++++++++--- - poppler/Function.h | 2 ++ - 2 files changed, 36 insertions(+), 3 deletions(-) - -commit e1c6b4c6e6df0854b040c9af9ef2d3f6789e24b2 -Author: Albert Astals Cid -Date: Mon Sep 5 21:02:31 2011 +0200 - - xpdf303: Only call getNum if isNum - - poppler/Link.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit e5661e1a08c38d4c8d69976a8c1c02c1102bc88c -Author: Carlos Garcia Campos -Date: Mon Sep 5 20:49:13 2011 +0200 - - Optimize SampledFunction - - Pull index computation code out of the transform function; cache the - last transform. - - poppler/Function.cc | 87 - ++++++++++++++++++++++++++++++++++++++++++++--------- - poppler/Function.h | 4 ++- - 2 files changed, 75 insertions(+), 16 deletions(-) - -commit b36d150931cd555b84ee996d505e8b91e2afde19 -Author: Albert Astals Cid -Date: Mon Sep 5 20:52:05 2011 +0200 - - xpdf303: Take xpdf way of handling bug 6500 - - poppler/JBIG2Stream.cc | 91 - ++++++++++++++++++++++++++++---------------------- - poppler/JBIG2Stream.h | 1 + - 2 files changed, 52 insertions(+), 40 deletions(-) - -commit 065565a67c7826b64d89fac9719049d0a57da721 -Author: Albert Astals Cid -Date: Mon Sep 5 20:39:50 2011 +0200 - - xpdf303: Merge ¿speed? improvements in JBIG2Stream::readGenericBitmap - - poppler/JBIG2Stream.cc | 586 - +++++++++++++++++++++++++++++++++++++++---------- - 1 file changed, 471 insertions(+), 115 deletions(-) - -commit 28adb3884dafcf1d36aae1ec05855b10b22aa4ae -Author: Albert Astals Cid -Date: Mon Sep 5 20:26:57 2011 +0200 - - xpdf303: Change bpp calculation - - poppler/JBIG2Stream.cc | 16 +++++++++++----- - 1 file changed, 11 insertions(+), 5 deletions(-) - -commit c163a82f45d869b7c35a1a7141ab237507671f82 -Author: Albert Astals Cid -Date: Mon Sep 5 20:25:04 2011 +0200 - - xpdf303: Change symCodeLen calculation - - poppler/JBIG2Stream.cc | 16 +++++++++++----- - 1 file changed, 11 insertions(+), 5 deletions(-) - -commit 1d1a985101c26f90bde8340dcfae3d6a1e0a08ba -Author: Albert Astals Cid -Date: Mon Sep 5 20:20:03 2011 +0200 - - xpdf303: symCodeLen calculation fix - - poppler/JBIG2Stream.cc | 12 ++++++++---- - 1 file changed, 8 insertions(+), 4 deletions(-) - -commit 5c0274572c65972434293a30f3ba5afd3905005f -Author: Albert Astals Cid -Date: Mon Sep 5 20:07:54 2011 +0200 - - xpdf303: add line accessor - - poppler/JBIG2Stream.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 7b77a264b5c21ba693677b1249a2122743e4e395 -Author: Albert Astals Cid -Date: Mon Sep 5 19:46:16 2011 +0200 - - xpdf303: segments with unspecified length - - poppler/JBIG2Stream.cc | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -commit 23066e8e8309babd61ade9f50ef7d82c9e275055 -Author: Albert Astals Cid -Date: Mon Sep 5 19:41:16 2011 +0200 - - xpdf303: More EOF detection - - poppler/JBIG2Stream.cc | 12 +++++++++--- - 1 file changed, 9 insertions(+), 3 deletions(-) - -commit bc6eded798d6e5dc7a58f88afbe4ab2904698db5 -Author: Albert Astals Cid -Date: Mon Sep 5 19:38:29 2011 +0200 - - xpdf303: Comment++ - - poppler/JBIG2Stream.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit adb98856a745340b4ffb34ffd2ed701600cfc82f -Author: Albert Astals Cid -Date: Mon Sep 5 19:38:02 2011 +0200 - - xpdf303: Exit loop in case of EOF - - poppler/JBIG2Stream.cc | 11 ++++++++--- - 1 file changed, 8 insertions(+), 3 deletions(-) - -commit 112154567ebcab63959294533b00075d6ca6ea65 -Author: Albert Astals Cid -Date: Mon Sep 5 19:33:27 2011 +0200 - - xpdf303: Initialize to NULL - - poppler/JBIG2Stream.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit b9ecfdf4cb27a19e65817af51c048e8030825035 -Author: Albert Astals Cid -Date: Mon Sep 5 19:27:36 2011 +0200 - - xpdf303: Delay memory allocation up to when it is really needed - - poppler/CMap.cc | 58 - ++++++++------------------------------------------------- - poppler/CMap.h | 2 -- - 2 files changed, 8 insertions(+), 52 deletions(-) - -commit 7af7b4b2d1941ee9dcd575535d4fc31f29026d8d -Author: Carlos Garcia Campos -Date: Mon Sep 5 19:05:31 2011 +0200 - - xpdf303: Rework initialization of appearance state - - Merged a slightly different patch, adding an error when the AS - entry is - missing and the AP contains one or more subdictionaries. - - poppler/Annot.cc | 62 - +++++++++++++++++++++++++++++++------------------------- - 1 file changed, 34 insertions(+), 28 deletions(-) - -commit f7d307b818bca9553a05b5d43deb429abbf04824 -Author: Carlos Garcia Campos -Date: Sun Sep 4 13:56:35 2011 +0200 - - xpdf303: Rewrote the code that handles annotation transforms - - It was not handling non-rectangular transforms correctly. - - poppler/Gfx.cc | 143 - ++++++++++++++++++++++++++++++--------------------------- - 1 file changed, 75 insertions(+), 68 deletions(-) - -commit 4609f9feeca22620c6e143962a3717784a843a68 -Author: Carlos Garcia Campos -Date: Sun Sep 4 13:09:50 2011 +0200 - - xpdf303: Implement rotation in the form field appearance regeneration - - poppler/Annot.cc | 51 ++++++++++++++++++++++++++++++++++++++------------- - 1 file changed, 38 insertions(+), 13 deletions(-) - -commit ca7d77a27e2f3a692842968f08dcb9fa5379bf0f -Author: Carlos Garcia Campos -Date: Sun Sep 4 11:53:40 2011 +0200 - - Create forms with a PDFDoc instead of XRef too - - poppler/Form.cc | 79 - +++++++++++++++++++++++++++++---------------------------- - poppler/Form.h | 28 ++++++++++---------- - 2 files changed, 55 insertions(+), 52 deletions(-) - -commit ec52e46e309a0307fdf12113a1b7d41a760f9d6c -Author: Carlos Garcia Campos -Date: Sun Sep 4 11:32:38 2011 +0200 - - xpdf303: Create annots with a doc instead of xref + catalog - - glib/poppler-action.cc | 2 +- - glib/poppler-annot.cc | 4 +- - poppler/Annot.cc | 364 - +++++++++++++++++++++++++------------------------ - poppler/Annot.h | 128 ++++++++--------- - poppler/Catalog.cc | 9 +- - poppler/Form.cc | 22 +-- - poppler/Form.h | 11 +- - poppler/PSOutputDev.cc | 2 +- - poppler/Page.cc | 2 +- - 9 files changed, 274 insertions(+), 270 deletions(-) - -commit ce5e620f07e984927610866467705bb526f9ad8d -Author: Carlos Garcia Campos -Date: Sat Sep 3 11:05:42 2011 +0200 - - xpdf303: Handle the case where sid < 0 - - fofi/FoFiType1C.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit 9d77f999de973f3c547245bca0568f8984faa5d7 -Author: Carlos Garcia Campos -Date: Sat Sep 3 11:02:55 2011 +0200 - - xpdf303: Initialize nFDs in FoFiType1C::parse() - - fofi/FoFiType1C.cc | 1 + - 1 file changed, 1 insertion(+) - -commit d9594c95713ac79b46e313ecf2875196ea076ef4 -Author: Carlos Garcia Campos -Date: Sat Sep 3 11:01:28 2011 +0200 - - xpdf303: Check whether fdSelect is NULL before using it - - fofi/FoFiType1C.cc | 10 ++++++---- - 1 file changed, 6 insertions(+), 4 deletions(-) - -commit 4e4a8ec52c5662e21036f219636a39fc97a32353 -Author: Carlos Garcia Campos -Date: Sat Sep 3 10:52:14 2011 +0200 - - xpdf303: Add writePSString() helper function to FoFiType1C - - fofi/FoFiType1C.cc | 68 - +++++++++++++++++++++++++++++++++++++++--------------- - fofi/FoFiType1C.h | 1 + - 2 files changed, 51 insertions(+), 18 deletions(-) - -commit ff03811db1ef833df4bab12fe3bf3a8c1534c174 -Author: Carlos Garcia Campos -Date: Sat Sep 3 10:40:15 2011 +0200 - - xpdf303: More checks in GooString - - goo/GooString.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 0029efbe2a8a97ff34353f8028ac649b2fd07013 -Author: Carlos Garcia Campos -Date: Sat Sep 3 10:32:14 2011 +0200 - - xpdf303: Use a double instead of an int with a cast - - goo/GooString.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 419ee8c30ba0df02e9f0281b321fbe38387e5a21 -Author: Carlos Garcia Campos -Date: Fri Sep 2 18:44:04 2011 +0200 - - xpdf303: Add more formats to GooString - - goo/GooString.cc | 102 - ++++++++++++++++++++++++++++++++++++++++++++++++++----- - goo/GooString.h | 21 ++++++++++-- - 2 files changed, 111 insertions(+), 12 deletions(-) - -commit 738a6954da01fd3fc8c1cd5baa49fc7b8c959169 -Author: Carlos Garcia Campos -Date: Fri Sep 2 18:24:04 2011 +0200 - - xpdf303: Add getGlyphName() to FoFiType1C - - fofi/FoFiType1C.cc | 12 ++++++++++++ - fofi/FoFiType1C.h | 4 ++++ - 2 files changed, 16 insertions(+) - -commit 39b77a193996b0916690a246f4a9874dad596b2f -Author: Carlos Garcia Campos -Date: Fri Sep 2 18:17:51 2011 +0200 - - xpdf303: Improvements in FoFiType1 parser - - fofi/FoFiType1.cc | 75 - ++++++++++++++++++++++++++----------------------------- - 1 file changed, 35 insertions(+), 40 deletions(-) - -commit 44dbb28a07125f92a0835aea7ad3403310bc451d -Author: Carlos Garcia Campos -Date: Fri Sep 2 18:08:39 2011 +0200 - - xpdf303: Handle PFB headers in Type 1 font files - - fofi/FoFiType1.cc | 36 ++++++++++++++++++++++++++++++++++++ - fofi/FoFiType1.h | 1 + - 2 files changed, 37 insertions(+) - -commit 9531a52b227a994ab8e0d66aeaff2b21358ca73e -Author: Carlos Garcia Campos -Date: Fri Sep 2 18:01:35 2011 +0200 - - xpdf303: New signature of methods convertToCIDType0() and - convertToType0() - - fofi/FoFiTrueType.cc | 8 ++--- - fofi/FoFiTrueType.h | 4 +-- - fofi/FoFiType1C.cc | 84 - +++++++++++++++++++++++++++++++++++--------------- - fofi/FoFiType1C.h | 19 +++++++++--- - poppler/PSOutputDev.cc | 13 ++++++-- - 5 files changed, 91 insertions(+), 37 deletions(-) - -commit 830d2b40770333489a08f23a3b16a372770a8d19 -Author: Albert Astals Cid -Date: Thu Sep 1 23:23:57 2011 +0200 - - xpdf303: Use openFile - - poppler/CharCodeToUnicode.cc | 4 ++-- - poppler/GlobalParams.cc | 10 +++++----- - 2 files changed, 7 insertions(+), 7 deletions(-) - -commit ddf9d6e35b40b902519cbaa8cb664ba6dfdfd510 -Author: Albert Astals Cid -Date: Thu Sep 1 23:21:26 2011 +0200 - - xpdf303: openFile + minor fixes for openTempFile in Windows - - goo/gfile.cc | 108 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- - goo/gfile.h | 13 +++++++ - 2 files changed, 118 insertions(+), 3 deletions(-) - -commit 68e8fa9ff4f13b6703148b3eb6ea628418211243 -Author: Albert Astals Cid -Date: Thu Sep 1 23:17:59 2011 +0200 - - xpdf303: make gcc happy - - fofi/FoFiType1C.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 876021b1aa16ad38767a91e1be31c392f368fde2 -Author: Carlos Garcia Campos -Date: Thu Sep 1 19:07:01 2011 +0200 - - xpdf303: Add getFontMatrix() - - fofi/FoFiTrueType.cc | 76 - +++++++++++++++++++++++++++++++--------------------- - fofi/FoFiTrueType.h | 9 +++++++ - fofi/FoFiType1.cc | 37 +++++++++++++++++++++++++ - fofi/FoFiType1.h | 4 +++ - fofi/FoFiType1C.cc | 29 ++++++++++++++++++++ - fofi/FoFiType1C.h | 3 +++ - 6 files changed, 127 insertions(+), 31 deletions(-) - -commit 1369862ed61ef8b0f81c52fce36f6c1602d82ddb -Author: Carlos Garcia Campos -Date: Thu Sep 1 18:27:51 2011 +0200 - - xpdf303: Ignore entries that have an invalid tag too - - fofi/FoFiTrueType.cc | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -commit 0fe7cc82e84dc2a3b79248b111656e5e7df9fdc2 -Author: Carlos Garcia Campos -Date: Thu Sep 1 18:21:33 2011 +0200 - - xpdf303: Update cmap, name, post and os2 tables in FoFiTrueType - - fofi/FoFiTrueType.cc | 29 ++++++++++++++++------------- - 1 file changed, 16 insertions(+), 13 deletions(-) - -commit 0feebf5f3c9da8d7a1154456a00492a623340cec -Author: Carlos Garcia Campos -Date: Thu Sep 1 18:16:59 2011 +0200 - - xpdf303: Ignore any bogus entries in the table directory - - It's a different approach to fix the same issue we had already fixed, - added just to make future merge easier. We were also reallocating the - tables array, I've kept that but doing it only when the size actually - changes. - - fofi/FoFiTrueType.cc | 25 +++++++++++++------------ - 1 file changed, 13 insertions(+), 12 deletions(-) - -commit 68c6ebc78b89eec94a9c3538fe6e27561a21b680 -Author: Carlos Garcia Campos -Date: Thu Sep 1 17:49:46 2011 +0200 - - xpdf303: codeToGID items can be < 0 now - - fofi/FoFiTrueType.cc | 12 ++++++++++-- - poppler/PSOutputDev.cc | 2 +- - splash/SplashFTFont.cc | 2 +- - 3 files changed, 12 insertions(+), 4 deletions(-) - -commit 19204ed5cd5cb64809f1a1f51dd5ffdef2b9417a -Author: Albert Astals Cid -Date: Thu Sep 1 17:28:39 2011 +0200 - - xpdf303: CMap::getCID signature change - - poppler/CMap.cc | 47 +++++++++++++++++++++++++++++++---------------- - poppler/CMap.h | 8 +++++--- - poppler/GfxFont.cc | 6 ++++-- - 3 files changed, 40 insertions(+), 21 deletions(-) - -commit 9c74bef77e7e1d7a8464dff43cae16bb1206665e -Author: Albert Astals Cid -Date: Thu Sep 1 17:04:04 2011 +0200 - - xpdf303: Use splashDist instead of splashSqrt - - splash/SplashT1Font.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 0568d0dc3c42b68b715226e5ce0ff98d73a94ac7 -Author: Albert Astals Cid -Date: Thu Sep 1 17:01:30 2011 +0200 - - xpdf303: Do the multiplication the other way around - - No idea why :-D - - splash/SplashFTFont.cc | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit 3c0da502aa1d5b1acae01cf1e43fb96f5ecc11da -Author: Albert Astals Cid -Date: Thu Sep 1 17:00:31 2011 +0200 - - xpdf303: Use splashCheckDet isntead of splashAbs - - splash/SplashFontEngine.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 2b4303c66f8de9a267413465898897fd6b0ebb17 -Author: Albert Astals Cid -Date: Thu Sep 1 16:51:53 2011 +0200 - - xpdf303: Bigger fileKey - - poppler/XRef.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 53060857e31a01413936fbe33b7032a0a325b384 -Author: Albert Astals Cid -Date: Thu Sep 1 16:50:08 2011 +0200 - - xpdf303: Merge JArithmeticDecoder.* - - poppler/JArithmeticDecoder.cc | 47 - ++++++++++++++++++++++++++++++++++++------- - poppler/JArithmeticDecoder.h | 4 ++++ - 2 files changed, 44 insertions(+), 7 deletions(-) - -commit 0722960b4cf4ce40b6bd278ac7287d64a1d70bf2 -Author: Albert Astals Cid -Date: Thu Sep 1 16:48:31 2011 +0200 - - xpdf303: Do not crash if imgStr->getLine() is NULL - - utils/ImageOutputDev.cc | 21 ++++++++++++++------- - 1 file changed, 14 insertions(+), 7 deletions(-) - -commit f848edab849910b8291c7974e484ef5d02b2234c -Author: Albert Astals Cid -Date: Thu Sep 1 16:42:30 2011 +0200 - - xpdf303: Do not extract the million tiles of a pattern - - utils/ImageOutputDev.cc | 9 +++++++++ - utils/ImageOutputDev.h | 12 ++++++++++++ - 2 files changed, 21 insertions(+) - -commit 01adb7ef6a524d7313a45e7c5f441da4fd0250bd -Author: Albert Astals Cid -Date: Thu Sep 1 16:31:50 2011 +0200 - - xpdf303: Assembler for some functions - - splash/SplashMath.h | 110 - ++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 110 insertions(+) - -commit 4f87a3163f133565e8774ef416e67d05f906723d -Author: Albert Astals Cid -Date: Thu Sep 1 16:25:19 2011 +0200 - - xpdf303: Add splashAvg - - splash/SplashMath.h | 8 ++++++++ - 1 file changed, 8 insertions(+) - -commit 64cf42f89939763d105be4948a20e9ecb81a64c1 -Author: Albert Astals Cid -Date: Thu Sep 1 16:23:08 2011 +0200 - - xpdf303: Add getters to SplashClip - - splash/SplashClip.h | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit 28c6a55742f55a719ef63b8e0eff7c242653cf36 -Author: Albert Astals Cid -Date: Thu Sep 1 16:17:56 2011 +0200 - - xpdf303: unneeded forward declare - - poppler/Page.h | 1 - - 1 file changed, 1 deletion(-) - -commit 38ebe8c568aafbe5f248f9e0a654f46829e0b659 -Author: Albert Astals Cid -Date: Thu Sep 1 16:13:53 2011 +0200 - - xpdf303: Page functions do not need Catalog * anymore - - glib/poppler-document.cc | 2 +- - glib/poppler-page.cc | 11 ++++------ - poppler/FontInfo.cc | 2 +- - poppler/OutputDev.h | 4 ++-- - poppler/PDFDoc.cc | 8 +++---- - poppler/PSOutputDev.cc | 6 +++--- - poppler/PSOutputDev.h | 2 +- - poppler/Page.cc | 36 - ++++++++++++++++---------------- - poppler/Page.h | 16 +++++++------- - poppler/TextOutputDev.cc | 2 +- - poppler/TextOutputDev.h | 2 +- - qt4/src/poppler-link-extractor-private.h | 2 +- - qt4/src/poppler-link-extractor.cc | 4 ++-- - qt4/src/poppler-page.cc | 4 ++-- - utils/HtmlOutputDev.cc | 9 ++++---- - utils/HtmlOutputDev.h | 7 +++---- - utils/pdftohtml.cc | 2 +- - 17 files changed, 58 insertions(+), 61 deletions(-) - -commit 7d794f6411499fb8f26778bf2b54cb9734d004af -Author: Albert Astals Cid -Date: Thu Sep 1 15:47:32 2011 +0200 - - xpdf303: API rework, Gfx wants a PDFDoc instead of an XRef - - cpp/poppler-page-renderer.cpp | 2 +- - glib/poppler-document.cc | 2 +- - glib/poppler-page.cc | 2 -- - poppler/CairoFontEngine.cc | 28 ++++++++++++---------------- - poppler/CairoFontEngine.h | 13 ++++++------- - poppler/CairoOutputDev.cc | 12 +++++------- - poppler/CairoOutputDev.h | 6 +++--- - poppler/Catalog.cc | 8 +++++--- - poppler/Catalog.h | 4 +++- - poppler/Gfx.cc | 15 +++++++++------ - poppler/Gfx.h | 6 ++++-- - poppler/PDFDoc.cc | 6 +++--- - poppler/PSOutputDev.cc | 29 +++++++++++++++-------------- - poppler/PSOutputDev.h | 9 ++++----- - poppler/Page.cc | 8 +++++--- - poppler/Page.h | 4 +++- - poppler/PreScanOutputDev.cc | 6 +++--- - poppler/PreScanOutputDev.h | 4 ++-- - poppler/SplashOutputDev.cc | 13 +++++++------ - poppler/SplashOutputDev.h | 5 +++-- - qt4/src/poppler-private.h | 2 +- - qt4/src/poppler-ps-converter.cc | 2 -- - test/gtk-test.cc | 2 +- - test/pdf-inspector.cc | 2 +- - test/perf-test.cc | 2 +- - utils/pdftocairo.cc | 2 +- - utils/pdftohtml.cc | 6 +++--- - utils/pdftoppm.cc | 2 +- - utils/pdftops.cc | 4 ++-- - 29 files changed, 105 insertions(+), 101 deletions(-) - -commit 52fb80a7b3f98eb8322a7ba84e2900f044b3a18a -Author: Albert Astals Cid -Date: Thu Sep 1 13:27:01 2011 +0200 - - xpdf303: compile++ - - poppler/ArthurOutputDev.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 37ca8dc4215693ec657d165ebdb6c315a0ae92c9 -Author: Carlos Garcia Campos -Date: Thu Sep 1 12:34:32 2011 +0200 - - xpdf303: Use int instead of Gushort for gid/cid maps - - fofi/FoFiTrueType.cc | 18 +++++++++--------- - fofi/FoFiTrueType.h | 14 +++++++------- - fofi/FoFiType1C.cc | 8 ++++---- - fofi/FoFiType1C.h | 2 +- - poppler/CairoFontEngine.cc | 22 +++++++++++----------- - poppler/CairoFontEngine.h | 8 ++++---- - poppler/GfxFont.cc | 22 +++++++++++----------- - poppler/GfxFont.h | 10 +++++----- - poppler/PSOutputDev.cc | 14 +++++++------- - poppler/SplashOutputDev.cc | 6 +++--- - splash/SplashFTFontEngine.cc | 6 +++--- - splash/SplashFTFontEngine.h | 2 +- - splash/SplashFTFontFile.cc | 12 ++++++------ - splash/SplashFTFontFile.h | 8 ++++---- - splash/SplashFontEngine.cc | 2 +- - splash/SplashFontEngine.h | 2 +- - 16 files changed, 78 insertions(+), 78 deletions(-) - -commit df942e25bff9b014bde0ff69c8a01fa3c1963015 -Author: Albert Astals Cid -Date: Thu Sep 1 01:08:10 2011 +0200 - - xpdf303: More parsing flexibility - - poppler/CharCodeToUnicode.cc | 18 ++++++------------ - 1 file changed, 6 insertions(+), 12 deletions(-) - -commit 5305dfc5702e8004e5ae35697c6aebd0b1a5c96e -Author: Albert Astals Cid -Date: Thu Sep 1 01:05:02 2011 +0200 - - xpdf303: Make sure codes are inside the range - - poppler/CharCodeToUnicode.cc | 17 ++++++++++++++++- - 1 file changed, 16 insertions(+), 1 deletion(-) - -commit 45212483572c68abd612b5c62b21cbb545e10143 -Author: Albert Astals Cid -Date: Thu Sep 1 01:01:13 2011 +0200 - - xpdf303: change mapLen growing stragegy - - poppler/CharCodeToUnicode.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 75d70f190e97f69047cdbe97a872a936788392d9 -Author: Albert Astals Cid -Date: Thu Sep 1 01:00:23 2011 +0200 - - xpdf303: Limit code to 0xffffff - - poppler/CharCodeToUnicode.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit b4180a187f9246b6390df112e5536ead9ef9bcbe -Author: Albert Astals Cid -Date: Thu Sep 1 00:59:09 2011 +0200 - - xpdf303: Use parseHex instead of sscanf - - poppler/CharCodeToUnicode.cc | 18 ++++++++---------- - 1 file changed, 8 insertions(+), 10 deletions(-) - -commit 121f648f233adcdc631c7e29d67b60baa922e29a -Author: Albert Astals Cid -Date: Thu Sep 1 00:28:40 2011 +0200 - - Add helper parseHex function - - poppler/CharCodeToUnicode.cc | 35 +++++++++++++++++++++++++++++++++++ - 1 file changed, 35 insertions(+) - -commit be0436ace671070bab4304efee607f40c959bc55 -Author: Albert Astals Cid -Date: Thu Sep 1 00:26:57 2011 +0200 - - xpdf303: CharCodeToUnicode::makeIdentityMapping & friends - - poppler/CharCodeToUnicode.cc | 25 +++++++++++++++++++++++++ - poppler/CharCodeToUnicode.h | 4 ++++ - 2 files changed, 29 insertions(+) - -commit 5dd94447b14db1894f06ad0590187dae7575e33a -Author: Albert Astals Cid -Date: Thu Sep 1 00:15:59 2011 +0200 - - xpdf303: Remove unused constructor - - splash/SplashXPath.cc | 5 ----- - splash/SplashXPath.h | 1 - - 2 files changed, 6 deletions(-) - -commit d00d56e4a46e8534378534de0d94ce0551d75d84 -Author: Albert Astals Cid -Date: Thu Sep 1 00:11:49 2011 +0200 - - xpdf303: Speedup SplashScreen - - By using << instead of * and by putting some functions on the header - so they can be inlined - - splash/SplashScreen.cc | 89 - +++++++++++++++++--------------------------------- - splash/SplashScreen.h | 14 ++++++-- - 2 files changed, 42 insertions(+), 61 deletions(-) - -commit 5e8debf96ab1bb9db31a0332a482d08c181d52ea -Author: Albert Astals Cid -Date: Wed Aug 31 23:56:52 2011 +0200 - - xpdf303: Add splashCheckDet helper - - splash/SplashMath.h | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -commit 4cef5a52b33b1afba28d890bbe48000b734ac357 -Author: Albert Astals Cid -Date: Wed Aug 31 21:09:50 2011 +0200 - - xpdf303: Protect against NULL from lexer->getStream() - - poppler/Parser.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 2547ec60db6d954e5c8318e30fcc54f70bcfa95c -Author: Albert Astals Cid -Date: Wed Aug 31 21:05:11 2011 +0200 - - xpdf303: Add GBool force = gFalse to SplashPath::close - - splash/SplashPath.cc | 5 +++-- - splash/SplashPath.h | 6 ++++-- - 2 files changed, 7 insertions(+), 4 deletions(-) - -commit 9370f9640a24c7b944f3da7c10e070a960bdd8f9 -Author: Albert Astals Cid -Date: Wed Aug 31 21:01:32 2011 +0200 - - xpdf303: Add guards to the header - - poppler/Stream-CCITT.h | 5 +++++ - 1 file changed, 5 insertions(+) - -commit ab9dea663a4df5af8f54c1ff5149254adfd72ce9 -Author: Albert Astals Cid -Date: Wed Aug 31 20:34:17 2011 +0200 - - xpdf303: Add SplashBitmap::writeAlphaPGMFile and - SplashBitmap::takeData - - splash/SplashBitmap.cc | 22 ++++++++++++++++++++++ - splash/SplashBitmap.h | 6 ++++++ - 2 files changed, 28 insertions(+) - -commit 6558d735c65a3dca9b9e16de5588c8b8c482f04f -Author: Albert Astals Cid -Date: Wed Aug 31 20:30:27 2011 +0200 - - xpdf303: Write faster - - splash/SplashBitmap.cc | 14 ++------------ - 1 file changed, 2 insertions(+), 12 deletions(-) - -commit a9b26d9c35fccc7b46a96acdb2064a9976bd49bd -Author: Albert Astals Cid -Date: Wed Aug 31 20:29:58 2011 +0200 - - xpdf303: Only free data if there is data to free - - splash/SplashBitmap.cc | 11 ++++++----- - 1 file changed, 6 insertions(+), 5 deletions(-) - -commit 8f6e0285d7e80d8c1a8defaad9d0f87a2e054151 -Author: Albert Astals Cid -Date: Wed Aug 31 20:20:47 2011 +0200 - - xpdf303: PDFDocEncoding changes - - This overwrites Michael Vrable's changes of using U+FFFD to actually - using the order, i'm taking Derek's change here - - poppler/PDFDocEncoding.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 9c8f30fb4a2a0dd2cf359610e33749e1682921c7 -Author: Albert Astals Cid -Date: Wed Aug 31 20:17:38 2011 +0200 - - xpdf303: comment changes - - poppler/Link.h | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit b78046057657b44c5cc9353d9e3dde356eb7fcbd -Author: Albert Astals Cid -Date: Wed Aug 31 19:32:03 2011 +0200 - - xpdf303: Introduce unicodeTypeNum and unicodeTypeAlphaNum - - poppler/UnicodeTypeTable.cc | 11 +++++++++++ - poppler/UnicodeTypeTable.h | 4 ++++ - 2 files changed, 15 insertions(+) - -commit 0ec4b390ddb7fa7d028b8f0515ecd3e61c488c9f -Author: Albert Astals Cid -Date: Wed Aug 31 19:30:55 2011 +0200 - - xpdf303: UnicodeTypeTable tables changes - - poppler/UnicodeTypeTable.cc | 28 ++++++++++++++-------------- - 1 file changed, 14 insertions(+), 14 deletions(-) - -commit f331c009f94703d6007fce9570ee19c6e4822339 -Author: Albert Astals Cid -Date: Wed Aug 31 19:20:12 2011 +0200 - - xpdf303: Remove warning() from Error.h - - poppler/CairoOutputDev.cc | 6 +++--- - poppler/Error.cc | 7 ------- - poppler/Error.h | 1 - - 3 files changed, 3 insertions(+), 11 deletions(-) - -commit 53f94df2ce21793914ccc153ba6b2fe5cbeb8371 -Author: Albert Astals Cid -Date: Wed Aug 31 19:17:13 2011 +0200 - - Port to setErrorCallback - - cpp/poppler-document.cpp | 2 +- - cpp/poppler-private.cpp | 6 ++---- - cpp/poppler-private.h | 3 ++- - qt4/src/poppler-private.cc | 8 +++----- - test/perf-test.cc | 4 ++-- - 5 files changed, 10 insertions(+), 13 deletions(-) - -commit 95a52f06a98f49f7c8f2b92634b75af96b4eee1d -Author: Albert Astals Cid -Date: Wed Aug 31 19:07:22 2011 +0200 - - xpdf303: Forgot this when doing the char * -> const char * - - poppler/JPXStream.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 00549400f155d8e36b4ac718603fc945858fe50d -Author: Albert Astals Cid -Date: Wed Aug 31 19:04:14 2011 +0200 - - xpdf303: error() changes, new param and formatting - - fofi/FoFiBase.cc | 8 +-- - fofi/FoFiTrueType.cc | 2 +- - fofi/FoFiType1.cc | 4 +- - goo/JpegWriter.cc | 2 +- - goo/PNGWriter.cc | 16 ++--- - poppler/Annot.cc | 40 +++++------ - poppler/ArthurOutputDev.cc | 16 ++--- - poppler/CMap.cc | 26 +++---- - poppler/CachedFile.cc | 2 +- - poppler/CairoFontEngine.cc | 10 +-- - poppler/Catalog.cc | 50 ++++++------- - poppler/CharCodeToUnicode.cc | 54 +++++++------- - poppler/CurlCachedFile.cc | 2 +- - poppler/DCTStream.cc | 2 +- - poppler/Decrypt.cc | 2 +- - poppler/Error.cc | 55 ++++++++++----- - poppler/Error.h | 23 +++++- - poppler/FileSpec.cc | 8 +-- - poppler/Form.cc | 44 ++++++------ - poppler/Function.cc | 107 ++++++++++++++-------------- - poppler/Gfx.cc | 161 - +++++++++++++++++++++--------------------- - poppler/GfxFont.cc | 102 ++++++++++++++------------- - poppler/GfxState.cc | 128 ++++++++++++++++----------------- - poppler/GfxState.h | 8 +-- - poppler/GlobalParams.cc | 38 +++++----- - poppler/GlobalParamsWin.cc | 4 +- - poppler/Hints.cc | 22 +++--- - poppler/JBIG2Stream.cc | 88 +++++++++++------------ - poppler/JPEG2000Stream.cc | 10 +-- - poppler/JPXStream.cc | 164 - ++++++++++++++++++++++--------------------- - poppler/Lexer.cc | 24 +++---- - poppler/Linearization.cc | 20 +++--- - poppler/Link.cc | 77 ++++++++++---------- - poppler/Movie.cc | 2 +- - poppler/Object.h | 8 +-- - poppler/OptionalContent.cc | 14 ++-- - poppler/PDFDoc.cc | 43 ++++++------ - poppler/PDFDocFactory.cc | 2 +- - poppler/PSOutputDev.cc | 45 ++++++------ - poppler/Page.cc | 12 ++-- - poppler/Parser.cc | 10 +-- - poppler/Rendition.cc | 6 +- - poppler/SecurityHandler.cc | 12 ++-- - poppler/SplashOutputDev.cc | 28 ++++---- - poppler/Stream.cc | 116 ++++++++++++++++-------------- - poppler/TextOutputDev.cc | 2 +- - poppler/UnicodeMap.cc | 15 ++-- - poppler/XRef.cc | 32 ++++----- - splash/Splash.cc | 2 +- - splash/SplashBitmap.cc | 6 +- - test/perf-test.cc | 4 +- - utils/HtmlOutputDev.cc | 18 ++--- - utils/ImageOutputDev.cc | 10 +-- - utils/pdfextract.cc | 4 +- - utils/pdfimages.cc | 2 +- - utils/pdfinfo.cc | 6 +- - utils/pdfmerge.cc | 6 +- - utils/pdftocairo.cc | 6 +- - utils/pdftohtml.cc | 6 +- - utils/pdftops.cc | 6 +- - utils/pdftotext.cc | 12 ++-- - 61 files changed, 912 insertions(+), 842 deletions(-) - -commit cd0764921064bfd455e9df52dc9bda6fbd2c2db2 -Author: Carlos Garcia Campos -Date: Wed Aug 31 17:23:28 2011 +0200 - - xpdf303: Always define at least 256 glyphs for Type 0 fonts - - fofi/FoFiTrueType.cc | 41 ++++++++++++++++++++++++++++++++++------- - fofi/FoFiTrueType.h | 3 ++- - 2 files changed, 36 insertions(+), 8 deletions(-) - -commit 4d4318e258fb68704b1a51a14fa89134606e2aa7 -Author: Carlos Garcia Campos -Date: Wed Aug 31 17:07:25 2011 +0200 - - xpdf303: Different growing strategy for vmtxTab in FoFiTrueType - - fofi/FoFiTrueType.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit c8c7fcef9bc8f802be2d376c9d2099971f159317 -Author: Carlos Garcia Campos -Date: Wed Aug 31 17:05:16 2011 +0200 - - xpdf303: Fix memory leak in FoFiTrueType - - fofi/FoFiTrueType.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit 655b1a97db5449c009e5b63fc7c12233e6fae450 -Author: Carlos Garcia Campos -Date: Wed Aug 31 16:54:05 2011 +0200 - - xpdf303: Check for an invalid loca format field in the head table - in FoFiTrueType - - fofi/FoFiTrueType.cc | 7 +++++++ - 1 file changed, 7 insertions(+) - -commit 9710ab96f1cf26394cc473952a3331d60c149451 -Author: Carlos Garcia Campos -Date: Wed Aug 31 16:49:54 2011 +0200 - - Fix the build - - fofi/FoFiIdentifier.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 36b733a3165fd26aa8c25ba57faa5d2277aa31ec -Author: Carlos Garcia Campos -Date: Tue Aug 30 16:31:52 2011 +0200 - - xpdf303: Handle bogus loca table entries in FoFiTrueType - - where the offset is past the end of the glyf table. This part was - missing in previous commit. - - fofi/FoFiTrueType.cc | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -commit a288bdb417582f07a5a0cb13d5218946a1d0ccc8 -Author: Albert Astals Cid -Date: Tue Aug 30 21:55:43 2011 +0200 - - xpdf303: Increase max keyLength to 32 - - poppler/XRef.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 12e0acd9d393df76e297bb3fde323092c428be21 -Author: Albert Astals Cid -Date: Tue Aug 30 21:03:05 2011 +0200 - - xpdf303: GfxXXXpath different growing strategy - - poppler/GfxState.cc | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -commit 7c5e496715f56498fb1aa08371d2b8d4d0e73d25 -Author: Albert Astals Cid -Date: Tue Aug 30 20:59:36 2011 +0200 - - xpdf303: No need for 4 Guint when 1 is enough - - poppler/GfxState.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit e7e8082901e108130d5c98cc7648f143978c9562 -Author: Albert Astals Cid -Date: Tue Aug 30 20:50:17 2011 +0200 - - xpdf303: GooList::copy, GooList::reverse and GooList::put - - goo/GooList.cc | 22 ++++++++++++++++++++++ - goo/GooList.h | 10 ++++++++++ - 2 files changed, 32 insertions(+) - -commit 8a119cf205467c20269e7beffde9497ffd277c15 -Author: Albert Astals Cid -Date: Tue Aug 30 20:48:40 2011 +0200 - - xpdf303: Inserting with a negative i means prepending - - goo/GooList.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 95142a8e63e476324e368785001a23d4f1d462b9 -Author: Albert Astals Cid -Date: Tue Aug 30 20:47:12 2011 +0200 - - xpdf303: If size is 0 reserve 8 anyway - - goo/GooList.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit bd1076da03f76fb62998a9409d366412f4aa5d13 -Author: Albert Astals Cid -Date: Tue Aug 30 20:45:36 2011 +0200 - - xpdf303: Complain for gmalloc and grealloc < 0 - - goo/gmem.cc | 28 ++++++++++++++++++++++++---- - 1 file changed, 24 insertions(+), 4 deletions(-) - -commit 5a42b3693a9e501a27d790d4aeafcb68f63cb950 -Author: Albert Astals Cid -Date: Tue Aug 30 20:38:39 2011 +0200 - - xpdf303: Honor the deleteKeys setting - - goo/GooHash.cc | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -commit d584b54eff52c47f983947b2aff0967dfed0ccf9 -Author: Albert Astals Cid -Date: Tue Aug 30 20:36:03 2011 +0200 - - xpdf303: set to NULL on failure - - goo/gfile.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit bf2cb5c9c47b4a61192101f0a48771657228e383 -Author: Adrian Johnson -Date: Tue Aug 30 19:08:40 2011 +0930 - - Fix compile error with libpng >= 1.5.0 - - libpng 1.5.0 changed one of the types in the png_set_iCCP() function - prototype. - - goo/PNGWriter.cc | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - -commit 6364c50ffb4053cc30cecbefff7a3142cab8c50b -Author: Albert Astals Cid -Date: Tue Aug 30 18:27:09 2011 +0200 - - xpdf303: Support for aes256 et all in Decrypt/SecurityHandler - - poppler/Decrypt.cc | 488 - +++++++++++++++++++++++++++++++++++++++------ - poppler/Decrypt.h | 19 +- - poppler/PDFDoc.cc | 2 +- - poppler/SecurityHandler.cc | 238 ++++++++++++---------- - poppler/SecurityHandler.h | 7 +- - poppler/Stream.h | 3 +- - 6 files changed, 595 insertions(+), 162 deletions(-) - -commit 39ce4575f96953b499d09074e847d492d18379fa -Author: Albert Astals Cid -Date: Tue Aug 30 17:39:30 2011 +0200 - - xpdf303: Add FoFiIdentifier - - CMakeLists.txt | 2 + - fofi/FoFiIdentifier.cc | 630 - +++++++++++++++++++++++++++++++++++++++++++++++++ - fofi/FoFiIdentifier.h | 42 ++++ - fofi/Makefile.am | 2 + - 4 files changed, 676 insertions(+) - -commit 33e7d54b4a29d297108ef3dc6008190625125ec8 -Author: Albert Astals Cid -Date: Tue Aug 30 17:36:22 2011 +0200 - - xpdf303: Also check against INT_MAX in FoFiBase - - fofi/FoFiBase.cc | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -commit fb1f56f091e5329b30279916b182f64134f3b2e6 -Author: Albert Astals Cid -Date: Tue Aug 30 17:34:50 2011 +0200 - - xpdf303: Introduce FoFiBase::getU32LE - - fofi/FoFiBase.cc | 15 +++++++++++++++ - fofi/FoFiBase.h | 1 + - 2 files changed, 16 insertions(+) - -commit a79bc3359586cbc2c235d20dfa934dab1f475561 -Author: Carlos Garcia Campos -Date: Tue Aug 30 16:59:08 2011 +0200 - - xpdf303: Check for a zero-entry cmap table in FoFiTrueType - - fofi/FoFiTrueType.cc | 28 +++++++++++++++++----------- - 1 file changed, 17 insertions(+), 11 deletions(-) - -commit efce014e39d0d13157b21a10ff8d483b5cfc561a -Author: Albert Astals Cid -Date: Tue Aug 30 17:02:16 2011 +0200 - - xpdf303: upddate xpdfCopyright - - poppler/poppler-config.h.cmake | 4 ++-- - poppler/poppler-config.h.in | 4 ++-- - 2 files changed, 4 insertions(+), 4 deletions(-) - -commit 2eb388ccc6c7526e66da804d9d800cf29a027914 -Author: Albert Astals Cid -Date: Tue Aug 30 16:50:39 2011 +0200 - - xpdf303: Merge README - - README | 2 +- - README-XPDF | 153 - +++++++++++++++++++++++++++++++++++++++--------------------- - 2 files changed, 101 insertions(+), 54 deletions(-) - -commit 331b0f1c16c4f636fc616569bab030969aa848f2 -Author: Carlos Garcia Campos -Date: Tue Aug 30 16:42:33 2011 +0200 - - xpdf303: Check for entries in the table directory with bogus tags - in FoFiTrueType - - This handles the case where the number of tables given in the - header is - too high. - - fofi/FoFiTrueType.cc | 30 +++++++++++++++++++++++++----- - 1 file changed, 25 insertions(+), 5 deletions(-) - -commit faaba717046ba87ef5ded614e2bcab6260a9f7c2 -Author: Albert Astals Cid -Date: Tue Aug 30 16:36:24 2011 +0200 - - xpdf303: FixedPoint improvements - - goo/FixedPoint.cc | 51 - ++++++++++++++++++++++++++++++++------------------ - goo/FixedPoint.h | 15 +++++++++++++-- - splash/Splash.cc | 12 ++++++++++++ - splash/SplashFTFont.cc | 16 ++++++++-------- - splash/SplashMath.h | 8 +++++--- - splash/SplashXPath.cc | 9 +++++++++ - 6 files changed, 80 insertions(+), 31 deletions(-) - -commit 73efc96eef6bd32a7c058b7dda8101f4f23c454f -Author: Carlos Garcia Campos -Date: Tue Aug 30 16:31:52 2011 +0200 - - xpdf303: Handle bogus loca table entries in FoFiTrueType - - where the offset is past the end of the glyf table. - - fofi/FoFiTrueType.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 1df3489392a77e2b75adbafcc2fa10de829c172e -Author: Carlos Garcia Campos -Date: Tue Aug 30 16:21:40 2011 +0200 - - xpdf303: Use std::sort (with functors) in place of qsort - - It can be significantly faster. Not included changes in - SplashXPathScanner.cc since they depend on other changes not yet - merged. - - fofi/FoFiTrueType.cc | 55 - +++++++++++++++++++++++--------------------------- - poppler/GfxFont.cc | 24 ++++++++++++++-------- - splash/SplashScreen.cc | 12 +++++++---- - splash/SplashXPath.cc | 44 ++++++++++++++++++---------------------- - 4 files changed, 69 insertions(+), 66 deletions(-) - -commit f298e7f844105f2d9a36144e59be86c341e37507 -Merge: 2a6bd7a 0ca5453 -Author: Albert Astals Cid -Date: Tue Aug 30 16:21:58 2011 +0200 - - Merge branch 'master' into xpdf303merge - -commit 0ca5453fea9e5342188f772acd6f31af1778f236 -Author: Albert Astals Cid -Date: Tue Aug 30 16:20:17 2011 +0200 - - Compile when defining USE_FIXEDPOINT - - splash/Splash.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit bd7a53bc2f27fc3979f8de306e2dcaca53d4570a -Author: Albert Astals Cid -Date: Tue Aug 30 16:20:08 2011 +0200 - - match function definition - - poppler/SplashOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 2a6bd7aae37f73a94bf1a84f699f310177661611 -Author: Albert Astals Cid -Date: Tue Aug 30 15:13:17 2011 +0200 - - xpdf303: Expand latin1UnicodeMapRanges and ascii7UnicodeMapRanges - - poppler/UnicodeMapTables.h | 10 +++++++--- - 1 file changed, 7 insertions(+), 3 deletions(-) - -commit 4d31785409e464d0e96dcf11167ecdffd64026d1 -Author: Albert Astals Cid -Date: Tue Aug 30 15:09:01 2011 +0200 - - xpdf303: More entries for nameToUnicodeTab - - poppler/NameToUnicodeTable.h | 3159 - ++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 3159 insertions(+) - -commit 2658030836f3a15dadadd7f1989dfaa858bf876f -Author: Albert Astals Cid -Date: Tue Aug 30 14:49:23 2011 +0200 - - xpdf303: char * -> const char * - - cmake/modules/PopplerMacros.cmake | 2 +- - configure.ac | 2 +- - cpp/poppler-private.cpp | 2 +- - cpp/poppler-private.h | 2 +- - fofi/FoFiBase.h | 2 +- - fofi/FoFiEncodings.cc | 6 ++--- - fofi/FoFiEncodings.h | 6 ++--- - fofi/FoFiTrueType.cc | 10 ++++----- - fofi/FoFiTrueType.h | 4 ++-- - fofi/FoFiType1.cc | 4 ++-- - fofi/FoFiType1.h | 2 +- - fofi/FoFiType1C.cc | 14 ++++++------ - fofi/FoFiType1C.h | 6 ++--- - goo/GooHash.cc | 16 +++++++------- - goo/GooHash.h | 12 +++++----- - goo/GooString.cc | 22 +++++++++---------- - goo/GooString.h | 16 +++++++------- - goo/gfile.cc | 4 ++-- - goo/gfile.h | 4 ++-- - goo/gmem.cc | 2 +- - goo/gmem.h | 2 +- - poppler/Annot.cc | 8 +++---- - poppler/Annot.h | 6 ++--- - poppler/ArthurOutputDev.cc | 6 ++--- - poppler/BuiltinFont.cc | 6 ++--- - poppler/BuiltinFont.h | 10 ++++----- - poppler/DCTStream.cc | 2 +- - poppler/DCTStream.h | 2 +- - poppler/Dict.cc | 14 ++++++------ - poppler/Dict.h | 14 ++++++------ - poppler/Error.cc | 10 ++++----- - poppler/Error.h | 6 ++--- - poppler/FileSpec.cc | 2 +- - poppler/FlateStream.cc | 2 +- - poppler/FlateStream.h | 2 +- - poppler/FontEncodingTables.cc | 14 ++++++------ - poppler/FontEncodingTables.h | 14 ++++++------ - poppler/FontInfo.cc | 2 +- - poppler/Form.cc | 6 ++--- - poppler/Form.h | 4 ++-- - poppler/Gfx.cc | 2 +- - poppler/Gfx.h | 2 +- - poppler/GfxFont.cc | 46 - +++++++++++++++++++-------------------- - poppler/GfxFont.h | 8 +++---- - poppler/GfxState.cc | 6 ++--- - poppler/GfxState.h | 2 +- - poppler/GlobalParams.cc | 21 +++++++++--------- - poppler/GlobalParams.h | 8 +++---- - poppler/GlobalParamsWin.cc | 6 ++--- - poppler/JBIG2Stream.cc | 2 +- - poppler/JBIG2Stream.h | 2 +- - poppler/JPEG2000Stream.cc | 2 +- - poppler/JPEG2000Stream.h | 2 +- - poppler/JPXStream.h | 2 +- - poppler/NameToCharCode.cc | 8 +++---- - poppler/NameToCharCode.h | 6 ++--- - poppler/NameToUnicodeTable.h | 2 +- - poppler/Object.cc | 4 ++-- - poppler/Object.h | 28 ++++++++++++------------ - poppler/PDFDoc.cc | 2 +- - poppler/PSOutputDev.cc | 24 ++++++++++---------- - poppler/PSOutputDev.h | 8 +++---- - poppler/Page.cc | 2 +- - poppler/Page.h | 2 +- - poppler/SplashOutputDev.cc | 6 ++--- - poppler/Stream.cc | 16 +++++++------- - poppler/Stream.h | 28 ++++++++++++------------ - poppler/TextOutputDev.cc | 2 +- - poppler/TextOutputDev.h | 2 +- - poppler/UnicodeMap.cc | 4 ++-- - poppler/UnicodeMap.h | 4 ++-- - poppler/UnicodeTypeTable.cc | 4 ++-- - qt4/src/poppler-private.cc | 2 +- - qt4/src/poppler-ps-converter.cc | 2 +- - splash/SplashFTFontEngine.cc | 8 +++---- - splash/SplashFTFontEngine.h | 6 ++--- - splash/SplashFTFontFile.cc | 6 ++--- - splash/SplashFTFontFile.h | 2 +- - splash/SplashFontEngine.cc | 6 ++--- - splash/SplashFontEngine.h | 6 ++--- - splash/SplashT1FontEngine.cc | 6 ++--- - splash/SplashT1FontEngine.h | 4 ++-- - splash/SplashT1FontFile.cc | 10 ++++----- - splash/SplashT1FontFile.h | 6 ++--- - test/pdf-operators.c | 4 ++-- - test/perf-test.cc | 4 ++-- - utils/HtmlFonts.cc | 4 ++-- - utils/HtmlOutputDev.cc | 12 +++++----- - utils/HtmlOutputDev.h | 4 ++-- - utils/parseargs.cc | 4 ++-- - utils/parseargs.h | 6 ++--- - utils/pdffonts.cc | 2 +- - utils/pdfinfo.cc | 12 +++++----- - utils/pdftocairo.cc | 4 ++-- - utils/pdftohtml.cc | 10 ++++----- - utils/pdftotext.cc | 12 +++++----- - 96 files changed, 337 insertions(+), 338 deletions(-) - -commit c899d26e0f7a61db99925179330c28df015a676b -Author: Albert Astals Cid -Date: Tue Aug 30 00:31:00 2011 +0200 - - Add COPYING3 from xpdf3.03 - - COPYING3 | 674 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 674 insertions(+) - -commit 508517a35cb3bc5195682a9cd89fb50a801eddc2 -Author: Albert Astals Cid -Date: Mon Aug 29 23:55:42 2011 +0200 - - 0.17.3 - - CMakeLists.txt | 4 ++-- - NEWS | 32 ++++++++++++++++++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - glib/CMakeLists.txt | 2 +- - glib/Makefile.am | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/CMakeLists.txt | 2 +- - qt4/src/Doxyfile | 2 +- - qt4/src/Makefile.am | 2 +- - 10 files changed, 42 insertions(+), 10 deletions(-) - -commit 1431564f3363a63a8669c8dd15970db814f4969f -Author: Thomas Freitag -Date: Mon Aug 29 22:22:02 2011 +0200 - - Add pdfextract and pdfmerge - - See "Creating PDF with poppler ?" thread for more info - - utils/CMakeLists.txt | 15 +++++ - utils/Makefile.am | 10 +++ - utils/pdfextract.cc | 111 ++++++++++++++++++++++++++++++++ - utils/pdfmerge.cc | 176 - +++++++++++++++++++++++++++++++++++++++++++++++++++ - 4 files changed, 312 insertions(+) - -commit 8ca2f41089bc6402baf9b24428af04314c037b54 -Author: Thomas Freitag -Date: Mon Aug 29 22:20:52 2011 +0200 - - Rework writing of PDF files - - Makes it more compatible with other PDF readers - See "Creating PDF with poppler ?" thread in the mailing list for - more info - - poppler/PDFDoc.cc | 389 - ++++++++++++++++++++++++++++++++++++++++++++++++------ - poppler/PDFDoc.h | 30 ++++- - 2 files changed, 375 insertions(+), 44 deletions(-) - -commit 33da7e270431e8e4c500e7573b3ca0dddd9f237e -Author: suzuki toshiya -Date: Sun Aug 28 22:07:38 2011 +0200 - - Fix building static-linked pdftocairo - - utils/Makefile.am | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 91fafce028ca6620c0eb22e370fb4c6fd3404e3c -Author: Adrian Johnson -Date: Tue Aug 23 21:02:02 2011 +0930 - - cairo: align strokes when Stroke Adjust is true and line width <= 1 - - If the stroke coordinates are not aligned, lines in cairo may be up to - 1 pixel wider than the requested width. This is most obvious when the - line width is 1 and the rendered line is 2 pixels. - - When Stroke Adjust is true, the PDF standard requires that stroke - coordinates be adjusted to ensure the stroke width is within half a - pixel of the requested width. - - If Stroke Adjust is enabled and the width is <= 1 pixel (the previous - commit adjusts the width to be at least 1 pixel), use the method - documented at http://www.cairographics.org/FAQ/#sharp_lines to align - the coordinates to ensure the rendered width is 1 pixel. - - Fixes bug #4536. - - poppler/CairoOutputDev.cc | 40 +++++++++++++++++++++++++++++++++++----- - poppler/CairoOutputDev.h | 3 +++ - 2 files changed, 38 insertions(+), 5 deletions(-) - -commit cfc67afe80b963ba662018674cadf3085466bb9f -Author: Adrian Johnson -Date: Tue Aug 23 20:46:24 2011 +0930 - - cairo: fix stroking of very thin lines - - Lines with a width less than 1.0 are almost invisible in cairo output - due to antialising. The PDF standard states that when the Stroke - Adjust graphics parameter is true, all lines must be at least one - pixel wide. - - Add a stroke_adjust flag to the CairoOuputDev. Like splash, use the - globalParam strokeAdjust setting (which defaults to true) to - initialize the flag and ignore the Stroke Adjust settng in PDF - files. This emulates Acrobat behavior. - - When stroke_adjust is true, find the line width in device pixels and - if less than 0.5 set the line width to 0.5 device pixels. The value - 0.5 pixels seems to make horizontal and vertical lines look better - because integer aligned 1.0 wide lines in cairo are rendered two - pixels wide which looks too fat. - - poppler/CairoOutputDev.cc | 20 +++++++++++++++++++- - poppler/CairoOutputDev.h | 1 + - 2 files changed, 20 insertions(+), 1 deletion(-) - -commit 7a7c932e09796b944dda69df1b339c889ee1d63a -Author: Albert Astals Cid -Date: Thu Aug 25 00:23:40 2011 +0200 - - Add a way to get the fully qualified name - - qt4/src/poppler-form.cc | 12 +++++++++++- - qt4/src/poppler-form.h | 8 +++++++- - 2 files changed, 18 insertions(+), 2 deletions(-) - -commit e001871d927f9cc86b4327d64e4c66ad00172ad0 -Author: Albert Astals Cid -Date: Wed Aug 24 23:44:18 2011 +0200 - - Clarify ownership - - qt4/src/poppler-qt4.h | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 87c48fdc175be4d852b953778f915ea93cd50194 -Author: Adrian Johnson -Date: Wed Aug 24 19:53:48 2011 +0930 - - cairo: fix unique id mime data - - The unique id string was copied before the object number was appended - resulting in all images in pdf output being the same. - - poppler/CairoOutputDev.cc | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit 08a2ba6f1603246651f0d5e697b88d38363d7df2 -Author: Pino Toscano -Date: Tue Aug 23 20:20:32 2011 +0200 - - pdftocairo/cmake: need to link to freetype - - utils/CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 82496b18dc4aff66cc29f2b6607c8f894afe8b49 -Author: Albert Astals Cid -Date: Mon Aug 22 16:42:28 2011 +0200 - - Update Adrian (C) - - poppler/GfxFont.h | 1 + - 1 file changed, 1 insertion(+) - -commit 2576e3a6d9746e2272c620a775e11295932eb5f2 -Author: Adrian Johnson -Date: Mon Aug 22 21:41:36 2011 +0930 - - update SEE ALSO section of man pages - - - ensure each man page references all other utils - - sort list of utils in alphabetical order - - utils/pdffonts.1 | 8 +++++--- - utils/pdfimages.1 | 8 +++++--- - utils/pdfinfo.1 | 8 +++++--- - utils/pdftocairo.1 | 2 +- - utils/pdftohtml.1 | 8 ++++++++ - utils/pdftoppm.1 | 8 +++++--- - utils/pdftops.1 | 8 +++++--- - utils/pdftotext.1 | 9 +++++---- - 8 files changed, 39 insertions(+), 20 deletions(-) - -commit 23ec5c8d394beb632ee45f6308215646cd1a0195 -Author: Adrian Johnson -Date: Mon Aug 22 21:26:24 2011 +0930 - - cairo: only use show_text_glyphs if the surface supports it and the - font has toUnicode - - When generating pdf output, fonts that do not have toUnicode cause an - excessive number of empty text ActualText entries to be written due to - glyphs that do not have have a mapping. - - poppler/CairoOutputDev.cc | 12 ++++++++---- - poppler/CairoOutputDev.h | 1 + - poppler/GfxFont.h | 3 +++ - 3 files changed, 12 insertions(+), 4 deletions(-) - -commit 3a574f13fa22b7c31eda0d0437f4094a5a39ff34 -Author: Adrian Johnson -Date: Fri Aug 19 23:23:24 2011 +0930 - - cairo: fix stroke patterns - - Since cairo still does not yet have cairo_stroke_to_path(), this - implements a workaround for stroke patterns. In clipToStrokePath, the - stroke path and stroke parameters are saved. In tilingPatternFill and - fill (used to draw shading patterns) if a stroke path clip has been - saved, the current pattern is stroked instead of filled using the - saved stroke. - Fixes bug #11719. - - poppler/CairoOutputDev.cc | 52 - ++++++++++++++++++++++++++++++++++++++++++++++- - poppler/CairoOutputDev.h | 17 ++++++++++++++-- - 2 files changed, 66 insertions(+), 3 deletions(-) - -commit eb740dac838d2a1e32899327ca6d25c3dca641df -Author: Carlos Garcia Campos -Date: Mon Aug 22 13:41:56 2011 +0200 - - glib-demo: Add text attributes information to text demo - - glib/demo/text.c | 103 - +++++++++++++++++++++++++++++++++++++++++++++++++++---- - 1 file changed, 97 insertions(+), 6 deletions(-) - -commit cda4aefaa136ae07778de3b1593808a5aaa2db5b -Author: Carlos Garcia Campos -Date: Mon Aug 22 13:40:49 2011 +0200 - - glib-demo: Add pgd_pixbuf_new_for_color() to utils - - To get a pixbuf for a given poppler color. - - glib/demo/annots.c | 22 +--------------------- - glib/demo/utils.c | 27 +++++++++++++++++++++++++++ - glib/demo/utils.h | 1 + - 3 files changed, 29 insertions(+), 21 deletions(-) - -commit 2a11b2963a548186654722a393db1e19d57828f1 -Author: danigm -Date: Mon Aug 22 12:51:50 2011 +0200 - - glib: Add poppler_page_get_text_attributes() - - It returns a list of text attributes that apply to a range of text as - returned by poppler_page_get_text(). Text attributes are represented - by - a PopplerTextAttributes struct that contains font name, font size, - whether text is undrlined and foreground color for a range of text. - Fixes bug #33269. - - glib/poppler-page.cc | 202 - ++++++++++++++++++++++++++++++++++++ - glib/poppler-page.h | 33 ++++++ - glib/poppler.h | 1 + - glib/reference/poppler-sections.txt | 7 ++ - 4 files changed, 243 insertions(+) - -commit 15f99157cf3900bf20cf619e204ae53085af497d -Author: Carlos Garcia Campos -Date: Mon Aug 22 12:43:12 2011 +0200 - - textoutputdev: Add TextFontInfo::matches() - - It checks whether two TextFontInfo objects contain the same font. - - poppler/TextOutputDev.cc | 4 ++++ - poppler/TextOutputDev.h | 1 + - 2 files changed, 5 insertions(+) - -commit 5b554b39fca634c8ba58915c14522cb2920fe280 -Author: Pino Toscano -Date: Mon Aug 22 13:16:23 2011 +0200 - - pdftocairo/cmake: link to lcms library if available - - utils/CMakeLists.txt | 3 +++ - 1 file changed, 3 insertions(+) - -commit f7cd236fea8740ef05635d1fd7917a778cc373f0 -Author: Albert Astals Cid -Date: Mon Aug 22 00:00:32 2011 +0200 - - Ship HtmlUtils.h - - utils/Makefile.am | 1 + - 1 file changed, 1 insertion(+) - -commit a128a858c50287cfba74c69996276ea44370dc26 -Author: Albert Astals Cid -Date: Sun Aug 21 23:52:06 2011 +0200 - - Update Adrian's (C) - - goo/PNGWriter.cc | 2 +- - goo/PNGWriter.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit b78134314107d8344360c3313478115ed291630d -Author: Albert Astals Cid -Date: Sun Aug 21 23:46:09 2011 +0200 - - Fix copyright - - c&p is evil - - goo/gtypes_p.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ade53277546cef4ba19d982518c0cd83a4bb9c12 -Author: Albert Astals Cid -Date: Sun Aug 21 23:42:53 2011 +0200 - - Move HAVE_STDINT_H use to a private header - - This way we do not need to expose it in poppler-config.h since - gtypes.h is a half public header - - goo/Makefile.am | 1 + - goo/gtypes.h | 18 ------------------ - goo/gtypes_p.h | 30 ++++++++++++++++++++++++++++++ - poppler/CairoOutputDev.cc | 1 + - poppler/CairoRescaleBox.cc | 1 + - utils/pdftocairo.cc | 1 + - 6 files changed, 34 insertions(+), 18 deletions(-) - -commit 6166c3a37a4d6307d4f23ee272ea07c95bbba74a -Author: Albert Astals Cid -Date: Sun Aug 21 23:31:30 2011 +0200 - - Silence silly gcc - - goo/PNGWriter.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit eb5b228c4c24152e632c931b63c64ffb1e10d45d -Author: Adrian Johnson -Date: Sat Aug 20 21:13:18 2011 +0930 - - pdftocairo: fix writing to stdout for ps/pdf/svg - - utils/pdftocairo.cc | 23 ++++++++++++++++++++--- - 1 file changed, 20 insertions(+), 3 deletions(-) - -commit 1beac5896a301be68de22240017fef11e7d27d40 -Author: Adrian Johnson -Date: Sat Aug 13 00:23:23 2011 +0930 - - Add poppler version to PSOutputDev ouput - - poppler/PSOutputDev.cc | 1 + - 1 file changed, 1 insertion(+) - -commit b35fd3651fd3dbaa876fc64b8c5cfe77ae67335f -Author: Adrian Johnson -Date: Fri Aug 5 23:01:51 2011 +0930 - - cairo: use cairo_show_text_glyphs() when printing - - This will allow cairo to setup the correct toUnicode or glyph names to - ensure text can be extracted. - - poppler/CairoOutputDev.cc | 41 ++++++++++++++++++++++++++++++++++++++--- - poppler/CairoOutputDev.h | 5 +++++ - 2 files changed, 43 insertions(+), 3 deletions(-) - -commit 51ade078bc1fa737e20120ae4cb3bf693a219823 -Author: Stefan Thomas -Date: Thu Jul 15 16:24:55 2010 +0100 - - pdftocairo: Added to CMake build system. - - utils/CMakeLists.txt | 20 ++++++++++++++++++++ - 1 file changed, 20 insertions(+) - -commit 5a8745cdf428e22641937977eedfc1d605f6ff07 -Author: Adrian Johnson -Date: Fri Aug 12 23:57:01 2011 +0930 - - Add pdftocairo man page - - utils/Makefile.am | 5 +- - utils/pdftocairo.1 | 254 - +++++++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 258 insertions(+), 1 deletion(-) - -commit b67a12b2b26692e2ccec7ff2e6df18fee05be535 -Author: Adrian Johnson -Date: Thu Aug 11 21:34:11 2011 +0930 - - pdftocairo - utility for creating png/jpeg/ps/eps/pdf/svg using - CairoOutputDev - - utils/.gitignore | 2 +- - utils/Makefile.am | 20 +- - utils/pdftocairo.cc | 970 - ++++++++++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 989 insertions(+), 3 deletions(-) - -commit 4f2d774826bf7bb7b3825e02c5ca4c2928643950 -Author: Adrian Johnson -Date: Thu Aug 11 21:32:53 2011 +0930 - - png: add support for embedding ICC profile - - goo/PNGWriter.cc | 28 ++++++++++++++++++++++++++++ - goo/PNGWriter.h | 8 ++++++++ - 2 files changed, 36 insertions(+) - -commit 1091f47310bf0fc71bac5dd4ec81dad50b2f2537 -Author: Adrian Johnson -Date: Wed Aug 10 18:48:15 2011 +0930 - - png: Add additional pixel formats - - RGBA is required for images with transparency. GRAY and MONOCHROME - allow PNGWriter write more compact PNG files when the images is known - to be all gray or monochrome. - - goo/PNGWriter.cc | 30 ++++++++++++++++++++++++++---- - goo/PNGWriter.h | 11 ++++++++++- - 2 files changed, 36 insertions(+), 5 deletions(-) - -commit c6f26915db568f12892d48005746ad2922c19000 -Author: Adrian Johnson -Date: Wed Aug 10 18:45:24 2011 +0930 - - png: use PNG_RESOLUTION_METER instead of PNG_RESOLUTION_UNKNOWN to - set resolution - - gimp does not show the correct resolution unless PNG_RESOLUTION_METER - is used - - goo/PNGWriter.cc | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit 2667d2a5b34e1bbf322aea42876e7e81aa06dc29 -Author: Adrian Johnson -Date: Tue Aug 9 22:05:53 2011 +0930 - - Use stdint.h instead of assuming the size of types - - configure.ac | 1 + - goo/gtypes.h | 18 ++++++++++++++++++ - poppler/CairoOutputDev.cc | 2 -- - poppler/CairoRescaleBox.cc | 2 -- - 4 files changed, 19 insertions(+), 4 deletions(-) - -commit c043f298e68bdfffcb7505ec354ec7487b5bd7b2 -Author: Adrian Johnson -Date: Fri Jul 8 21:13:36 2011 +0930 - - cairo: assume printer pixel size is 1/600" when stroking 0 width lines - - Fixes bug #39067. - - poppler/CairoOutputDev.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 961adf0b767be78d3556b7315de3761d3d46b107 -Author: Adrian Johnson -Date: Thu Aug 18 17:44:35 2011 +0930 - - cairo: set mime data for soft masked images - - Fixes bug #40192. - - poppler/CairoOutputDev.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 86271e4810f714d4ba7a2a6651a9b1d04f653262 -Author: Joshua Richardson -Date: Thu Aug 18 18:48:40 2011 +0200 - - pdftohtml: Support text rotation - - Includes a few other fixlets. - See bug 38586 for more info - - utils/HtmlFonts.cc | 64 ++++++++++--------- - utils/HtmlFonts.h | 10 ++- - utils/HtmlOutputDev.cc | 170 - ++++++++++++++++++++++++++++++++++--------------- - utils/HtmlOutputDev.h | 8 ++- - utils/HtmlUtils.h | 51 +++++++++++++++ - 5 files changed, 218 insertions(+), 85 deletions(-) - -commit 56248b84e2185483dd54704c13838e8f78029d49 -Author: Albert Astals Cid -Date: Thu Aug 18 12:40:51 2011 +0200 - - Only declare overprint if we are going to use it - - utils/pdftoppm.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit a1093aae9f64cb6768164551d50cafaef52876c1 -Author: Albert Astals Cid -Date: Thu Aug 18 12:30:29 2011 +0200 - - Fix Adrian's (C) - - poppler/PSOutputDev.cc | 2 +- - poppler/PSOutputDev.h | 3 ++- - poppler/PreScanOutputDev.cc | 1 + - poppler/PreScanOutputDev.h | 1 + - poppler/SplashOutputDev.cc | 1 + - poppler/SplashOutputDev.h | 1 + - 6 files changed, 7 insertions(+), 2 deletions(-) - -commit 7741b24d05f50c134cf15361d52f5df7ae3c3115 -Author: Adrian Johnson -Date: Sun Aug 14 22:06:22 2011 +0930 - - ps: Avoid using /PatternType if only one instance of the pattern - is used - - this optimization makes pages print faster on my LaserJet - - poppler/PSOutputDev.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit a60e61ac64634dc59c80d8e6b0288c1269fc0154 -Author: Adrian Johnson -Date: Sun Aug 14 21:55:24 2011 +0930 - - ps: use PS Patterns for tiling fill when PS level >= 2 - - poppler/CairoOutputDev.cc | 2 +- - poppler/CairoOutputDev.h | 4 +-- - poppler/Gfx.cc | 4 +-- - poppler/OutputDev.h | 2 +- - poppler/PSOutputDev.cc | 59 - +++++++++++++++++++++++++++++++++++++++++---- - poppler/PSOutputDev.h | 13 +++++++++- - poppler/PreScanOutputDev.cc | 2 +- - poppler/PreScanOutputDev.h | 2 +- - poppler/SplashOutputDev.cc | 2 +- - poppler/SplashOutputDev.h | 2 +- - 10 files changed, 76 insertions(+), 16 deletions(-) - -commit 9938770e737b2fcec8269147e70663517f848925 -Author: Albert Astals Cid -Date: Mon Aug 15 13:17:24 2011 +0200 - - 0.17.2 - - CMakeLists.txt | 4 ++-- - NEWS | 37 +++++++++++++++++++++++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - glib/CMakeLists.txt | 2 +- - glib/Makefile.am | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/CMakeLists.txt | 2 +- - qt4/src/Doxyfile | 2 +- - qt4/src/Makefile.am | 5 +++-- - 10 files changed, 49 insertions(+), 11 deletions(-) - -commit 378fc06c574b85b5c003ca842aa743f0ffe5587e -Author: Albert Astals Cid -Date: Mon Aug 1 22:14:12 2011 +0200 - - Only assume the OC is not visible if it exists and is set to no - - Similar to commit e2def20a45c1d8307fd62fabb9769121af975abf - but in the other branch of the if, fixes bug 39637 - - poppler/OptionalContent.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 861a7bfb9431609e1e148240447f23c8e83b9d0f -Author: Thomas Freitag -Date: Fri Jul 29 00:30:58 2011 +0200 - - Implement overprint in Splash - - See the "Implementing overprint in Splash" thread in the mailing - list for more info - - goo/ImgWriter.h | 2 + - goo/JpegWriter.cc | 54 ++++++-- - goo/JpegWriter.h | 7 +- - poppler/Gfx.cc | 98 +++++++++++++-- - poppler/GfxState.cc | 1 + - poppler/GfxState.h | 4 + - poppler/OutputDev.h | 1 + - poppler/SplashOutputDev.cc | 307 - +++++++++++++++++++++++++++++++++++++++------ - poppler/SplashOutputDev.h | 51 +++++++- - splash/Splash.cc | 86 +++++++++---- - splash/Splash.h | 9 +- - splash/SplashBitmap.cc | 64 +++++++++- - splash/SplashBitmap.h | 1 + - splash/SplashPattern.cc | 16 ++- - splash/SplashPattern.h | 7 ++ - splash/SplashState.cc | 11 +- - splash/SplashState.h | 22 ++++ - splash/SplashTypes.h | 5 +- - utils/pdftoppm.cc | 36 +++++- - 19 files changed, 686 insertions(+), 96 deletions(-) - -commit e2fa8a2ca8459d19c0f9dca445a2399b9a3d483d -Author: Koji Otani -Date: Thu Jul 28 12:43:57 2011 +0200 - - Parse the "Medium" modifier when asking fontconfig for a font - - poppler/GlobalParams.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 0a677dd8dc9c55936530ea1fee901cab831c52af -Author: Koji Otani -Date: Thu Jul 28 12:42:16 2011 +0200 - - Improve selection of CJK fonts - - Seems we need to do some more fontconfig magic for some special - fontconfig configurations - More info at bug 36474 - - poppler/GlobalParams.cc | 137 - +++++++++++++++++++++++++++++++----------------- - 1 file changed, 89 insertions(+), 48 deletions(-) - -commit e78aff6796a5d5a0a4f2fe8c7ceb33c506e2c8f5 -Author: William Bader -Date: Tue Jul 26 00:10:34 2011 +0200 - - make -level1sep write gray instead of cmyk - - If it is a gray only image - Bug 39012 - - poppler/PSOutputDev.cc | 63 - +++++++++++++++++++++++++++++++++++++++++++++++--- - 1 file changed, 60 insertions(+), 3 deletions(-) - -commit ea31309487aab6ed407a086dff1f350b6e4bdbc9 -Author: Albert Astals Cid -Date: Tue Jul 26 00:09:27 2011 +0200 - - Update (C) - - poppler/PDFDoc.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit a945641497946a825dc880f94200ea1d5409332b -Author: Hib Eris -Date: Sat Jul 23 08:44:06 2011 +0200 - - Handle missing startxref properly - - Bug 38209 - - poppler/PDFDoc.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 2c1b25ef2592367f4c18e204ab5d102f15cf272f -Author: William Bader -Date: Mon Jul 25 23:43:27 2011 +0200 - - Fix a bad memory access - - When not using antialias and the character starts to the left/top - of the image - Bug 37189 - - splash/Splash.cc | 14 ++++++++++---- - 1 file changed, 10 insertions(+), 4 deletions(-) - -commit 300900afa2140141748a7571270be5d850274072 -Author: Daniel Glöckner -Date: Sat Jul 23 19:49:15 2011 +0200 - - Fix numerical overflow in libopenjpeg JPXStream::doLookChar() - - It also includes a speed optimization. Bug 39361 - - poppler/JPEG2000Stream.cc | 37 ++++++++++++++++++++++++++++++++++++- - poppler/JPEG2000Stream.h | 36 +++++++++++------------------------- - 2 files changed, 47 insertions(+), 26 deletions(-) - -commit ec6ea621b066a3b332a8099341664889d2ff3743 -Author: Axel Struebing -Date: Thu Jul 21 23:12:36 2011 +0200 - - Fix calculation of startXRefPos - - Reviewed by Hib Eris - See "another problem with saving linearized files" in the mailing - list for more info - - poppler/PDFDoc.cc | 9 ++++++--- - 1 file changed, 6 insertions(+), 3 deletions(-) - -commit ce97cfcd6373c98fb8c63e9b3ef6c51738f22a50 -Author: Albert Astals Cid -Date: Wed Jul 20 00:24:52 2011 +0200 - - Render dots for 0 length dashed lines - - Bug 34150 - - splash/Splash.cc | 13 +++++++++++++ - 1 file changed, 13 insertions(+) - -commit 42c1b1c4af6b07f488d1b2b02a4700f19b0ab0ef -Author: Tomas Hoger -Date: Wed Jul 20 00:23:15 2011 +0200 - - Fix crash on truncated JPEG/DCT stream - - Bug 36693 - - poppler/DCTStream.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 091b570c63694e475c24bb8805638ac70c654892 -Author: Albert Astals Cid -Date: Wed Jul 20 00:19:43 2011 +0200 - - Make sure the dict is a page dict - - Fixes second part of 35925 and 39072 - - poppler/PDFDoc.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ac566c887ffae9d384587f7587609642aef7a016 -Author: Albert Astals Cid -Date: Wed Jul 20 00:17:49 2011 +0200 - - Do not crash if can not get page 0 for some reason - - qt4/tests/test-poppler-qt4.cpp | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -commit 6ad95e7b8b9766aa19f01f06f02eb430e4a4a899 -Author: Albert Astals Cid -Date: Mon Jul 11 15:04:49 2011 +0100 - - Complete the list of preprocessor defines that we never define - - When using any of the two sanctioned build systems - - poppler/poppler-config.h.cmake | 6 ++++-- - poppler/poppler-config.h.in | 6 ++++-- - 2 files changed, 8 insertions(+), 4 deletions(-) - -commit edcc84ef0137a733cf3fab79b919af309d87325c -Author: Albert Astals Cid -Date: Mon Jul 11 15:00:39 2011 +0100 - - Harmonize all SPLASH_CMYK to use #if - - poppler/SplashOutputDev.cc | 24 ++++++++++++------------ - 1 file changed, 12 insertions(+), 12 deletions(-) - -commit a8fca630d592941c033ca6a380bf46b6e733a748 -Author: Albert Astals Cid -Date: Mon Jul 11 14:57:33 2011 +0100 - - Sanitize headers a big - - * Remove includes to config.h as that file does not exist - * Add to poppler-config.h all the defines we define in the - configure/cmake process and are used in headers - * Include poppker-config.h where needed - - goo/GooTimer.h | 2 ++ - goo/ImgWriter.h | 3 +- - goo/JpegWriter.h | 3 +- - goo/PNGWriter.h | 4 +-- - goo/TiffWriter.h | 3 +- - goo/gfile.h | 3 +- - poppler/DCTStream.h | 5 ++-- - poppler/FlateStream.h | 5 ++-- - poppler/Gfx.h | 3 +- - poppler/GfxState.h | 2 ++ - poppler/Stream.h | 3 +- - poppler/poppler-config.h.cmake | 63 - ++++++++++++++++++++++++++++++++++++++++++ - poppler/poppler-config.h.in | 63 - ++++++++++++++++++++++++++++++++++++++++++ - splash/SplashFTFont.h | 4 ++- - splash/SplashMath.h | 4 ++- - 15 files changed, 153 insertions(+), 17 deletions(-) - -commit 214322f3c66a9aad4e2a46f6e305a3dacaa4f8b1 -Author: Albert Astals Cid -Date: Sun Jul 10 01:20:21 2011 +0100 - - And 3 years later, Ed has answered :-) - - Now all our changes are GPLv2+ - - poppler/GfxFont.cc | 3 +++ - poppler/GlobalParams.cc | 3 +++ - poppler/TextOutputDev.cc | 3 +++ - poppler/TextOutputDev.h | 3 +++ - poppler/UnicodeTypeTable.cc | 3 +++ - poppler/UnicodeTypeTable.h | 3 +++ - 6 files changed, 18 insertions(+) - -commit 37cc1344672f480d4062aafbd2f3245ca1392279 -Author: Albert Astals Cid -Date: Sun Jul 10 01:15:44 2011 +0100 - - Fix header - - The file was modified in 2009 and README.contributors stating - everything is GPLv2+ is from 2008 - - poppler/XpdfPluginAPI.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 230ab66f52a992557464e325d18f88573ec52423 -Author: Albert Astals Cid -Date: Sun Jul 10 01:06:41 2011 +0100 - - make files easier to include by themselves - - fofi/FoFiTrueType.h | 2 ++ - splash/Splash.h | 3 ++- - splash/SplashFontEngine.h | 3 ++- - 3 files changed, 6 insertions(+), 2 deletions(-) - -commit 866c6d1b0daa8b28f259e1faba075026cf9007e0 -Author: Albert Astals Cid -Date: Sun Jul 10 00:55:25 2011 +0100 - - Name most of the classes in poppler/ includable by themselves - - poppler/Annot.h | 4 +++- - poppler/Catalog.h | 2 ++ - poppler/CharCodeToUnicode.h | 4 +++- - poppler/CompactFontTables.h | 16 ++++++++++++++++ - poppler/FontInfo.h | 6 +++++- - poppler/GfxState_helpers.h | 4 +++- - poppler/NameToUnicodeTable.h | 18 ++++++++++++++++++ - 7 files changed, 50 insertions(+), 4 deletions(-) - -commit 6b62fb7e9bd7de7f79b9b9a6fe36a5f5da099133 -Author: William Bader -Date: Mon Jun 27 19:38:52 2011 +0100 - - Remove unused variable - - poppler/PSOutputDev.cc | 5 +---- - 1 file changed, 1 insertion(+), 4 deletions(-) - -commit 4bc6c5bd3a001bb4eb9f61488e3d4f356638e391 -Author: Adrian Bunk -Date: Tue Jul 5 15:21:06 2011 +0300 - - .gitignore tests additions - - The following files were missing in .gitignore: - - cpp/tests/poppler-render - - qt4/tests/poppler-texts - - test/gtk-test - - cpp/tests/.gitignore | 1 + - qt4/tests/.gitignore | 1 + - test/.gitignore | 1 + - 3 files changed, 3 insertions(+) - -commit 00076bc308ae320244c47777fe351c1c2bef2da8 -Author: Albert Astals Cid -Date: Fri Jun 24 22:51:55 2011 +0100 - - Forgot William's (C) here - - poppler/Stream.cc | 1 + - poppler/Stream.h | 1 + - 2 files changed, 2 insertions(+) - -commit 7e244fde4ec03da08d81af3402b21646c803bd31 -Author: William Bader -Date: Fri Jun 24 22:39:13 2011 +0100 - - patch to make -level2sep and -level3sep write gray instead of cmyk - - If they are only gray of course :D - - poppler/PSOutputDev.cc | 34 ++++++++++++++++++++++++++++++---- - poppler/Stream.cc | 43 +++++++++++++++++++++++++++++++++++++++++++ - poppler/Stream.h | 29 +++++++++++++++++++++++++++++ - 3 files changed, 102 insertions(+), 4 deletions(-) - -commit abba8140a9972197faaca96ec590af7dc9408fb0 -Author: William Bader -Date: Fri Jun 24 22:38:33 2011 +0100 - - patch to make -level2sep and -level3sep write cmyk instead of rgb - - poppler/PSOutputDev.cc | 59 - +++++++++++++++++++++++++++++++++++++++++++++----- - 1 file changed, 54 insertions(+), 5 deletions(-) - -commit 706007431325b1e8c9bf4cba35c89511b10ebf0c -Author: Albert Astals Cid -Date: Mon Jun 20 23:30:50 2011 +0100 - - (C) for Jim - - fofi/FoFiBase.cc | 1 + - 1 file changed, 1 insertion(+) - -commit e23384fbb3542941d2cf59ce6560913255ca2b01 -Author: Jim Meyering -Date: Mon Jun 20 11:09:01 2011 +0200 - - don't gmalloc(-1) upon ftell failure - - * fofi/FoFiBase.cc: Diagnose ftell failure. - - fofi/FoFiBase.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit c5601bde9d8f3f56e558a6f63e563c9d337810eb -Author: Steven Murdoch -Date: Mon Jun 20 23:25:43 2011 +0100 - - Fix encoding of PDF document metadata in output of pdftohtml - - pdftohtml simply copies the PDF document title into the HTML - tag, which fails when the title is UCS-2 encoded, or if it contains - characters which are in pdfDocEncoding (a ISO 8859-1 superset), - but not - in ISO 8859-1. This patch fixes the problem by decoding UCS-2 or - pdfDocEncoding into Unicode, then encoding this in the desired output - encoding. HTML escaping wasn't being done either, so I have used the - existing function HtmlFont::HtmlFilter to perform both HTML escaping - and character set encoding. This static method had to be made public - to call it from pdftohtml. See bug #37900. - - utils/HtmlFonts.h | 3 ++- - utils/pdftohtml.cc | 41 ++++++++++++++++++++++++++++++++++++++--- - 2 files changed, 40 insertions(+), 4 deletions(-) - -commit d4af1c4ef46abf1f11b7215c7b144ce7bb7912eb -Author: Joshua Richardson <joshuarbox-junk1@yahoo.com> -Date: Sat Jun 18 13:39:54 2011 +0100 - - Fix vertical spacing issues in pdftohtml output. - - Bug 38019 - - utils/HtmlFonts.cc | 3 ++- - utils/HtmlOutputDev.cc | 21 +++++++++++++++++++-- - 2 files changed, 21 insertions(+), 3 deletions(-) - -commit 589933ef105b60e8d48854cce15a7548c2850116 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Jun 13 21:24:39 2011 +0100 - - Forgot my (C) - - poppler/PreScanOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit f5d2ddd13d27078355dee63207671885bf9b0926 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Jun 13 18:57:29 2011 +0100 - - We need to include config.h here - - Fixes crash after patch to fix bug 13518 - - poppler/PreScanOutputDev.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 147ae4bf76a85768c9ed729ca10ee3dae93b8876 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jun 8 23:36:14 2011 +0100 - - Do not crash if link does not have an action - - utils/HtmlOutputDev.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 5d9489bf566b700ef38e5e33665a2648b535e1e7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Jun 4 21:46:10 2011 +0100 - - forgot to update the C - - utils/pdftotext.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 7b123bf2b11ac81f24a966186a06de739d3c8f02 -Author: Steven Murdoch <Steven.Murdoch@cl.cam.ac.uk> -Date: Sat Jun 4 20:22:52 2011 +0100 - - Fix pdftotext -htmlmeta to correctly output U+2019 in PDF metadata - - In PDF documents, right single quotation mark (U+2019) may be - encoded as - 0x90 because PDFDocEncoding uses some of the reserved characters in - ISO 8859-1. However, pdftotext -htmlmeta assumes that characters - are either - UCS-2 or ISO 8859-1. Thus when a right single quotation mark is - encoded as - 0x90, it is output as unicode 0x90 (which is a control - character). pdfinfo - does the right thing by first converting from PDFDocEncoding to - Unicode - with pdfDocEncoding[], before encoding it in the desired character - set. - This patch applies the same logic to pdftotext. pdftohtml is broken - in the - same way, but this patch does not attempt to fix it. - - Bug 37900 - - utils/pdftotext.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit db2ae1bdbb7fcb64ba4c91dfc574d9f970bebdf6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Jun 4 13:23:11 2011 +0100 - - Make sure catDict is a dict - - poppler/Catalog.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 58915affbdf1b5780f25d172a582c69fb2413230 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Jun 4 13:20:02 2011 +0100 - - Make sure catDict is a dict before using it - - KDE Bug 274888 shows it's possible to get aborts because of that - - poppler/Catalog.cc | 26 ++++++++++++++++---------- - 1 file changed, 16 insertions(+), 10 deletions(-) - -commit 4ebc7e364409fe303e7a5729b568913e3c92e7d4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Jun 4 13:19:34 2011 +0100 - - We need to free catDict on failure - - poppler/Catalog.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 335a7fc6d98f5facc1ff098a91ac968387473cb3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue May 31 23:18:26 2011 +0100 - - Make parse() private - - poppler/Catalog.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 311d69ef2222409859817737c44b8e741289d897 -Author: Axel Strübing <axel.struebing@freenet.de> -Date: Sun May 29 16:12:29 2011 +0100 - - Needs to be freed - - As i said in my last commit comment :D - - poppler/PDFDoc.cc | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit 66c7d0199b45bc7c81c88a9989c9515398d30d43 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat May 28 17:32:02 2011 +0100 - - No need to check for NULL - - We probably need to free obj4 but i don't have the stamina to properly - test it - - poppler/PDFDoc.cc | 21 ++++++++++----------- - 1 file changed, 10 insertions(+), 11 deletions(-) - -commit 450934619a1c5b2a58f65649f567274af8d24ea7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat May 28 12:37:08 2011 +0100 - - Parse that as unicode - - Fixes KDE Bug #274055 - - qt4/src/poppler-page.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 04dfb2c984b3c9949466e2b70e26b58029c5a7d3 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat May 7 12:55:34 2011 +0200 - - Make FileSpec a class and move EmbFile from Catalog to FileSpec - - Qt and cpp frontends adapted by Pino Toscano - - cpp/poppler-document.cpp | 4 +- - cpp/poppler-embedded-file-private.h | 10 +-- - cpp/poppler-embedded-file.cpp | 42 +++++++---- - glib/poppler-annot.cc | 6 +- - glib/poppler-attachment.cc | 33 +++++---- - glib/poppler-document.cc | 5 +- - glib/poppler-private.h | 3 +- - poppler/Catalog.cc | 118 - +++--------------------------- - poppler/Catalog.h | 55 +------------- - poppler/FileSpec.cc | 128 - +++++++++++++++++++++++++++++++++ - poppler/FileSpec.h | 51 ++++++++++++- - qt4/src/poppler-embeddedfile-private.h | 6 +- - qt4/src/poppler-embeddedfile.cc | 34 +++++---- - qt4/src/poppler-page.cc | 5 +- - qt4/src/poppler-private.h | 4 +- - qt4/tests/check_attachments.cpp | 12 ++-- - 16 files changed, 284 insertions(+), 232 deletions(-) - -commit 74f9befddd4b5848c4af0c1b2848a1322f8cd0a2 -Author: Pino Toscano <pino@kde.org> -Date: Wed May 25 16:46:15 2011 +0200 - - [qt4] Page needs to be a friend of EmbeddedFile, too - - qt4/src/poppler-qt4.h | 1 + - 1 file changed, 1 insertion(+) - -commit 74853614d617486b7b62e9c08be39a6e58bc7d9b -Author: Pino Toscano <pino@kde.org> -Date: Wed May 25 16:40:49 2011 +0200 - - update copyrights - - qt4/src/poppler-embeddedfile-private.h | 2 +- - qt4/src/poppler-embeddedfile.cc | 2 +- - qt4/src/poppler-qt4.h | 2 +- - 3 files changed, 3 insertions(+), 3 deletions(-) - -commit e6b2dec502c02f9fbaed480f227cf7145249a98e -Author: Pino Toscano <pino@kde.org> -Date: Wed May 25 16:39:09 2011 +0200 - - [qt4] one more usage of the new EmbeddedFile ctor - - followup of a264e5385b2d0fee5126b3d0e57d42d34cafa45d - - qt4/src/poppler-page.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit a264e5385b2d0fee5126b3d0e57d42d34cafa45d -Author: Pino Toscano <pino@kde.org> -Date: Wed May 25 16:12:02 2011 +0200 - - [qt4] create EmbeddedFile by EmbeddedFileData only - - - create the private class and pass it to the EmbeddedFile ctor, - reducing the amount of poppler code API exposed to the outside - - turn the old private EmbeddedFile(EmbFile*) ctor in a death machine - - qt4/src/poppler-embeddedfile-private.h | 3 +++ - qt4/src/poppler-embeddedfile.cc | 21 ++++++++++++++++++--- - qt4/src/poppler-private.h | 3 ++- - qt4/src/poppler-qt4.h | 2 ++ - 4 files changed, 25 insertions(+), 4 deletions(-) - -commit 232bfa1c59013637fd7e858e22194becb636ad21 -Author: Pino Toscano <pino@kde.org> -Date: Wed May 25 15:55:48 2011 +0200 - - [Qt4] split EmbeddedFileData in an own file - - qt4/src/poppler-embeddedfile-private.h | 37 - ++++++++++++++++++++++++++++++++++ - qt4/src/poppler-embeddedfile.cc | 7 +------ - 2 files changed, 38 insertions(+), 6 deletions(-) - -commit a7242b78b3c9a64cf38ac150e6a914d7abce3355 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat May 7 11:10:11 2011 +0100 - - Do not free a shallow copy of an object we'll free later - - Make sure we have our own copy we can free - Fixes KDE BUG #268816 - (cherry picked from commit dab9cdf795d6caead555326958e86e844ace067b) - - poppler/Catalog.cc | 12 +++++------- - poppler/Catalog.h | 2 +- - 2 files changed, 6 insertions(+), 8 deletions(-) - -commit 4db2452b3d345d9531987998e6b5532a59137e1d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri May 6 14:57:51 2011 +0200 - - glib: Add poppler_document_get_n_attachments() - - glib/poppler-document.cc | 34 - ++++++++++++++++++++++++---------- - glib/poppler-document.h | 1 + - glib/reference/poppler-sections.txt | 1 + - 3 files changed, 26 insertions(+), 10 deletions(-) - -commit 3e3284de3fe1916d7f8161ede7bf49c76d01f303 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri May 6 14:49:05 2011 +0200 - - glib: Update gtk-doc.make - - gtk-doc.make | 151 - ++++++++++++++++++++++++++++++++++++++--------------------- - 1 file changed, 98 insertions(+), 53 deletions(-) - -commit 9a77bd7706a08d9aeabe600e3500c14493ac8519 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri May 6 14:48:38 2011 +0200 - - glib-demo: Add missing permission flags to info demo - - glib/demo/info.cc | 39 ++++++++++++++++++++++++++++++++++++--- - 1 file changed, 36 insertions(+), 3 deletions(-) - -commit 091c155f8a7bc79da84cd21877be389de1f2b1a3 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri May 6 14:47:36 2011 +0200 - - glib: Add missing permissions flags to PopplerPermissions - - glib/poppler-document.cc | 6 ++++++ - glib/poppler-document.h | 10 +++++++++- - 2 files changed, 15 insertions(+), 1 deletion(-) - -commit 632d6a40ce3a5d3d8e10bf7e93e8eb578beae907 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue May 3 21:54:59 2011 +0100 - - 0.17.1 - - CMakeLists.txt | 4 ++-- - NEWS | 12 ++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 6 files changed, 18 insertions(+), 6 deletions(-) - -commit ecb136b9927a454df9360a307ccd741eaea3ca93 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue May 3 21:42:45 2011 +0100 - - remove unused vars - - poppler/Annot.cc | 9 ++------- - poppler/ArthurOutputDev.cc | 12 ++---------- - 2 files changed, 4 insertions(+), 17 deletions(-) - -commit ad131763640b2e27dde75c42b514386284b6a60d -Author: Pino Toscano <pino@kde.org> -Date: Wed Apr 27 22:36:13 2011 +0200 - - [qt4/tests] turn some assignments to bool into QVERIFY checks - - qt4/tests/check_optcontent.cpp | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit be08dd69d9dd4fcb22400f2f0aea331222e88e4a -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Apr 27 20:45:36 2011 +0100 - - update copyright years - (cherry picked from commit 2fbd493197309de5700f71f09967c9d23add88d3) - - poppler/Annot.cc | 1 + - utils/pdftotext.cc | 1 + - 2 files changed, 2 insertions(+) - -commit 39bcce0c8ed378aafb1019ffd1ae40330f6bb63f -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Apr 27 19:39:01 2011 +0100 - - Remove more variables that are set but then unused - - poppler/SplashOutputDev.cc | 11 +------ - utils/HtmlOutputDev.cc | 75 - +--------------------------------------------- - 2 files changed, 2 insertions(+), 84 deletions(-) - -commit 6656cf657b62d626910a02dfae9b6a1eb77772dd -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Apr 27 08:46:37 2011 +0100 - - Remove unused vars - - poppler/TextOutputDev.cc | 6 +----- - 1 file changed, 1 insertion(+), 5 deletions(-) - -commit ce55510f4dd10dfec2fc5b1c211c4a546c6ebc98 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Apr 27 08:42:34 2011 +0100 - - Remove unused vars - - splash/Splash.cc | 5 ++--- - splash/SplashFTFontEngine.cc | 4 +--- - splash/SplashXPath.cc | 6 ++---- - 3 files changed, 5 insertions(+), 10 deletions(-) - -commit 49d199fd1ea14383638739d95d019adb33b17768 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Apr 27 08:38:17 2011 +0100 - - Fix page_transition::operator= - - cpp/poppler-page-transition.cpp | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 807c1df2bf79c7c6378390b41dc230d80533ae3f -Author: Tom Gleason <tom@buildadam.com> -Date: Tue Apr 26 17:06:07 2011 +0100 - - bbox coordinates are relative to MediaBox size, not CropBox size - - utils/pdftotext.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 813f41367a681702ae7a155d5c2f3195124a9096 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Apr 3 20:40:15 2011 +0200 - - forms: fix mem leak in case of error - - poppler/Form.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 722baf8baf42e2c7a49e1560aae5235677d1ddee -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Apr 3 20:17:57 2011 +0200 - - forms: check form field is actually terminal before creating the - widget - - poppler/Form.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 5f6f7fc569d1c891956a3c37b3e328504635ab33 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Apr 3 15:06:45 2011 +0100 - - Properly initialize pageObjectNum to 0 - - Bug 35925 - - poppler/Hints.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit d6786edc2549164214342a50782b72c2fd904b63 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Apr 3 13:11:18 2011 +0200 - - forms: Remove unused parameter - - poppler/Form.cc | 2 +- - poppler/Form.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 62692ff381f3b7907b330bfc2019416ed058ea46 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Apr 3 13:01:42 2011 +0200 - - forms: rework the way form fields tree is built - - Now we build the tree as described by the doc, without ignoring - container fields and always creating a child widget for composed - (field - + annot) dictionaries. The way check and radio buttons are set - has been - reworked too, since now it's possible to have a set of buttons where - children are not widgets, but form fields with a child widget. - - poppler/Annot.cc | 4 +- - poppler/Form.cc | 237 - +++++++++++++++++++++++++++++-------------------------- - poppler/Form.h | 17 ++-- - 3 files changed, 137 insertions(+), 121 deletions(-) - -commit a6802301d9c3ab8bf68bd8821f562f8ecced8491 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 28 17:42:37 2011 +0200 - - forms: Add debug methods to print the forms tree - - poppler/Form.cc | 78 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Form.h | 25 ++++++++++++++++++ - 2 files changed, 103 insertions(+) - -commit 46f87da04700cdd1afa634f9c554e376f6f6f752 -Author: José Aliste <jaliste@src.gnome.org> -Date: Thu Mar 31 08:09:41 2011 -0400 - - Fix a memleak in AnnotScreen::initialize - - poppler/Annot.cc | 1 + - 1 file changed, 1 insertion(+) - -commit b64178eaa5dd01f914649d6faa870fa140ddaf9b -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Mar 30 15:17:54 2011 +0200 - - glib: docs: Add PopplerActionJavascript to poppler-sections.txt - - glib/reference/poppler-sections.txt | 1 + - 1 file changed, 1 insertion(+) - -commit 3d777181ddee8f7ab2cc9e4684879cb5b52b065c -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Mar 30 15:16:04 2011 +0200 - - glib: Use Javascript instead of JavaScript for consistency - - glib/poppler-action.h | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit c4774fecfe3d523f32d5980f50e31daa798c9692 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Mar 30 15:08:59 2011 +0200 - - glib-demo: show javascript actions in actions view - - glib/demo/utils.c | 25 +++++++++++++++++++++++++ - 1 file changed, 25 insertions(+) - -commit 68bbbe1a3f68d242b35027ae41f5751b02a2a700 -Author: José Aliste <jaliste@src.gnome.org> -Date: Tue Mar 29 04:56:37 2011 -0400 - - glib: add JavaScript actions - - glib/poppler-action.cc | 24 ++++++++++++++++++++++++ - glib/poppler-action.h | 14 +++++++++++++- - 2 files changed, 37 insertions(+), 1 deletion(-) - -commit 3dd934088a06f246718382601030c9b093d04160 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Mar 30 00:03:58 2011 +0100 - - Need to create the globalParams - - qt4/tests/check_optcontent.cpp | 5 +++++ - 1 file changed, 5 insertions(+) - -commit ce0d4278a32b3ba19c2002ed0c481c58b1854d59 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Mar 29 23:47:33 2011 +0100 - - Long gone - - Makefile.am | 2 -- - 1 file changed, 2 deletions(-) - -commit 12337026533aa59bb66022ce8a119f37aafd4fad -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Mar 29 23:40:57 2011 +0100 - - increase sonames - - CMakeLists.txt | 2 +- - glib/CMakeLists.txt | 2 +- - glib/Makefile.am | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/CMakeLists.txt | 2 +- - qt4/src/Makefile.am | 2 +- - 6 files changed, 6 insertions(+), 6 deletions(-) - -commit a6e613b01698c6b38deff5248fcf7c0b17d041c3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Mar 29 23:40:38 2011 +0100 - - more typos - - NEWS | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit e3ee037ede67212836be158b935deb7ea974b7f7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Mar 29 23:38:24 2011 +0100 - - typo - - NEWS | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 8bcd94964f0af17a3f5b6edf71127df3daa00b1a -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Mar 29 23:30:30 2011 +0100 - - typo - - NEWS | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit a05b9dacbe5dbd4337fdbb3e7d7d364ad5fbaeab -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Mar 29 23:28:49 2011 +0100 - - 0.17.0 version number - - CMakeLists.txt | 2 +- - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - 4 files changed, 4 insertions(+), 4 deletions(-) - -commit 4637b737b4735c70017b46a3ed6c0ee069c02c9b -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Mar 29 23:28:41 2011 +0100 - - 0.17.0 news - - NEWS | 108 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 108 insertions(+) - -commit a55cc5d9c67ede1d96f6e5a58179ddd9f563c53f -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Mar 29 22:51:40 2011 +0100 - - Update years - - poppler/Catalog.cc | 2 +- - poppler/Catalog.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit d96efb6c1af621be78e998ba1a228022c3c076fc -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 29 11:13:03 2011 +0200 - - fix comment - - poppler/ViewerPreferences.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 74ec81d66d4d5bc45cccc4aa8794df1c517f2d74 -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 29 11:07:36 2011 +0200 - - viewer preferences: read PrintScaling and Duplex - - poppler/ViewerPreferences.cc | 24 ++++++++++++++++++++++++ - poppler/ViewerPreferences.h | 14 ++++++++++++++ - 2 files changed, 38 insertions(+) - -commit b41bcd484dd7a93a339270926c57caa524059d8f -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 29 10:58:46 2011 +0200 - - free the viewerPreferences Object - - poppler/Catalog.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 1dd88d0b6b7cbfda76e81902a351c89457a061a8 -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 29 09:58:10 2011 +0200 - - read the ViewerPreferences dict once, and construct ViewerPreferences - on demand - - this way it is possible to know whether the ViewerPreferences - dictionary is present in the Catalog - - poppler/Catalog.cc | 24 +++++++++--------------- - poppler/Catalog.h | 3 ++- - 2 files changed, 11 insertions(+), 16 deletions(-) - -commit f10b0b8c88a7df83ada09f32b6cb6fd930fcb748 -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 29 09:57:46 2011 +0200 - - assume the prefDict is not null - - poppler/ViewerPreferences.cc | 4 ---- - 1 file changed, 4 deletions(-) - -commit d4a5ea45057cad531a8979cf9861ac05cdd56613 -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 29 09:54:22 2011 +0200 - - fix variable name for DisplayDocTitle - - poppler/ViewerPreferences.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit cf84a05ae524aa9b266463cc23cccc3860ff1ba3 -Author: Pino Toscano <pino@kde.org> -Date: Mon Mar 28 23:18:02 2011 +0200 - - viewer preferences: read NonFullScreenPageMode and Direction - - poppler/ViewerPreferences.cc | 26 ++++++++++++++++++++++++++ - poppler/ViewerPreferences.h | 15 +++++++++++++++ - 2 files changed, 41 insertions(+) - -commit 460253a6705a227ff7c36e9c31cceb93cce4d78b -Author: Pino Toscano <pino@kde.org> -Date: Mon Mar 28 22:37:54 2011 +0200 - - read some boolean viewer preferences - - - HideToolbar - - HideMenubar - - HideWindowUI - - FitWindow - - CenterWindow - - DisplayDocTitle - - poppler/ViewerPreferences.cc | 41 - +++++++++++++++++++++++++++++++++++++++++ - poppler/ViewerPreferences.h | 13 +++++++++++++ - 2 files changed, 54 insertions(+) - -commit 9fa9ac3546674120532bb512b82af6471cbebf01 -Author: Pino Toscano <pino@kde.org> -Date: Mon Mar 28 19:58:16 2011 +0200 - - add skeleton for ViewerPreferences - - a small class for handling the ViewerPreferences dictionary of - a Catalog, - created on demand and in any occasion (so defaults are in one - place only) - - CMakeLists.txt | 2 ++ - poppler/Catalog.cc | 23 +++++++++++++++++++++++ - poppler/Catalog.h | 4 ++++ - poppler/Makefile.am | 2 ++ - poppler/ViewerPreferences.cc | 30 ++++++++++++++++++++++++++++++ - poppler/ViewerPreferences.h | 34 ++++++++++++++++++++++++++++++++++ - 6 files changed, 95 insertions(+) - -commit c6081f0bf00d7dcdfa1d09e91e4c9a1fe5a54ad6 -Author: Pino Toscano <pino@kde.org> -Date: Mon Mar 28 19:55:00 2011 +0200 - - delete the temporary buffers created by pdfDocEncodingToUTF16() - - poppler/Form.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit d94d5056d5570e2f5cb578736eba12317ea63fa4 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 28 18:20:31 2011 +0200 - - glib-demo: show the activation action of form fields if there's one - - glib/demo/forms.c | 21 ++++++++++++++++----- - 1 file changed, 16 insertions(+), 5 deletions(-) - -commit ba0f36b76d0c2fd4ef39f3013fc125a53747c03f -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 28 18:17:52 2011 +0200 - - glib: Add poppler_form_field_get_action() - - Fixes bug #33174. - - glib/poppler-form-field.cc | 34 - ++++++++++++++++++++++++++++++++++ - glib/poppler-form-field.h | 1 + - glib/poppler-private.h | 1 + - glib/reference/poppler-sections.txt | 1 + - 4 files changed, 37 insertions(+) - -commit ae5b9cf884ce38dde409c3e5b0f6c46f7d6327d2 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 28 17:43:53 2011 +0200 - - Revert "Patch for embedding videos in to the pdf" - - This reverts commit 66575c990f379871e4b796befc899de178332670. - - It introduces new API to glib frontend that is wrong and will be - changed soon. - - glib/poppler-annot.cc | 33 ----- - glib/poppler-annot.h | 5 - - poppler/Annot.cc | 377 - -------------------------------------------------- - poppler/Annot.h | 2 - - 4 files changed, 417 deletions(-) - -commit b7edd4c93539585652961ecf2db9c4462415c8bc -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Mar 27 12:31:19 2011 +0200 - - annot: Always create appearance streams when NeedAppearances is true - - Fixes regression in document example_054.pdf - - poppler/Annot.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit e9350899e77c28452c48b56349ad7758b3fd47ba -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Mar 24 20:09:18 2011 +0000 - - Introduce splash-friendly getRGBLine functions - - So it does not need to pack and unpack the color again and again - - poppler/GfxState.cc | 248 - ++++++++++++++++++++++++++++++++++++++++++--- - poppler/GfxState.h | 22 +++- - poppler/SplashOutputDev.cc | 43 ++------ - 3 files changed, 265 insertions(+), 48 deletions(-) - -commit 7b08795a9541e9fa01836b4c7fd63f6fe295ad80 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Mar 24 12:16:07 2011 +0100 - - glib: Add g_return macros to make sure index is correct in form - field choice methods - - glib/poppler-form-field.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit f1102fccd2899bc7f97414b1e2a295c59f03da22 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Mar 24 12:15:30 2011 +0100 - - glib-demo: Fix a crash when a choice form field has no items selected - - glib/demo/forms.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit b3971ee6bca6b14b75f046c831a31ac1e5e3241e -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Mar 22 22:08:27 2011 +0000 - - kill this TODO, n is too small - - poppler/SplashOutputDev.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 1064d75817401fe24f728c189b450e9e906beb56 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Mar 22 20:43:05 2011 +0000 - - kill unmaintained abiword backend - - CMakeLists.txt | 16 - - configure.ac | 16 - - poppler/ABWOutputDev.cc | 1179 - ----------------------------------------------- - poppler/ABWOutputDev.h | 141 ------ - poppler/Makefile.am | 17 - - utils/CMakeLists.txt | 10 - - utils/Makefile.am | 18 +- - utils/pdftoabw.cc | 201 -------- - 8 files changed, 2 insertions(+), 1596 deletions(-) - -commit abf167af8b15e5f3b510275ce619e6fdb42edd40 -Author: Thomas Freitag <Thomas.Freitag@alfa.de> -Date: Mon Mar 21 21:34:46 2011 +0000 - - Implement tiling/patterns in SplashOutputDev - - Fixes bug 13518 - - poppler/CairoOutputDev.cc | 5 +- - poppler/CairoOutputDev.h | 10 +- - poppler/Gfx.cc | 6 +- - poppler/OutputDev.h | 6 +- - poppler/PSOutputDev.cc | 8 +- - poppler/PSOutputDev.h | 6 +- - poppler/PreScanOutputDev.cc | 22 +++- - poppler/PreScanOutputDev.h | 16 ++- - poppler/SplashOutputDev.cc | 265 - ++++++++++++++++++++++++++++++++++++++++++++ - poppler/SplashOutputDev.h | 12 ++ - 10 files changed, 334 insertions(+), 22 deletions(-) - -commit 66575c990f379871e4b796befc899de178332670 -Author: Srinivas Adicherla <srinivas.adicherla@gmail.com> -Date: Thu Mar 17 20:14:05 2011 +0000 - - Patch for embedding videos in to the pdf - - glib/poppler-annot.cc | 33 +++++ - glib/poppler-annot.h | 5 + - poppler/Annot.cc | 377 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Annot.h | 2 + - 4 files changed, 417 insertions(+) - -commit ec1917968d2f1c7a00772a0829b3fcc6957d8f3c -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Mar 14 00:13:26 2011 +0000 - - Only build gtk-test if we have to build gtk-test - - test/Makefile.am | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 1acbb01e72a22f70f00dc058ff206e3bc05bc0ab -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Mar 13 14:49:48 2011 +0000 - - (C) years - - poppler/CachedFile.cc | 2 +- - poppler/CurlCachedFile.cc | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit bc8aeb269aa92406081f749064ceff75bb3145e7 -Author: Hib Eris <hib@hiberis.nl> -Date: Sat Mar 12 23:17:59 2011 +0100 - - Check response code of libcurl call - - poppler/CachedFile.cc | 8 +++++++- - poppler/CurlCachedFile.cc | 12 +++++++++--- - 2 files changed, 16 insertions(+), 4 deletions(-) - -commit 0268cedee5b460835a4747d0ea41bbe12269310d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Mar 12 15:24:30 2011 +0100 - - cairo: Fix typo - - poppler/CairoFontEngine.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 5aa369e68e5c9f14efc888c7b26da06aa8bd2a78 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Mar 12 13:47:34 2011 +0000 - - Remove unused variable - - poppler/CurlCachedFile.cc | 2 -- - 1 file changed, 2 deletions(-) - -commit c0dffbe28f91b30b36310ab0b9a9b948610550ae -Author: Pino Toscano <pino@kde.org> -Date: Sat Mar 12 12:15:58 2011 +0100 - - update copyright years - - cpp/poppler-document-private.h | 2 +- - cpp/poppler-document.cpp | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit b8fab173ffdd1e62a34b530228d08bc5ec6725ac -Author: Pino Toscano <pino@kde.org> -Date: Sat Mar 12 12:13:05 2011 +0100 - - [cpp] init the globalParams early in the document loading - - introduce a small RAII class to init/deinit the globalParams, and - make document_private inherit from it - - cpp/poppler-document-private.h | 17 +++++++++----- - cpp/poppler-document.cpp | 52 - +++++++++++++++++++++++------------------- - 2 files changed, 39 insertions(+), 30 deletions(-) - -commit a97a54cb22def2a9fc381fb81842dad9e5c3931f -Author: Pino Toscano <pino@kde.org> -Date: Sat Mar 12 12:12:11 2011 +0100 - - forms: delete tmp_str after being converted to GooString - - poppler/Form.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 9671fe07f8c9ade956742cb141b99518c3b12bad -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Mar 11 00:05:52 2011 +0000 - - getForm can return NULL, do not crash if that happens - - poppler/Annot.cc | 10 ++++++---- - 1 file changed, 6 insertions(+), 4 deletions(-) - -commit bd32672899f5ca4509ec9311de8092d14bec8ab1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Mar 10 23:33:15 2011 +0000 - - update copyright years - - poppler/Catalog.cc | 2 +- - qt4/src/poppler-form.cc | 1 + - 2 files changed, 2 insertions(+), 1 deletion(-) - -commit 841f3bbca37015ec2c58d7b85a73cef5681294f8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Mar 10 23:30:51 2011 +0000 - - Do not infinite loop - - poppler/Form.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit f2fcafdc2b982d9bbed3c01bc7d45c8bd0603f19 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Mar 10 23:27:41 2011 +0000 - - Create the globalParams before the pdfdoc - - qt4/src/poppler-private.cc | 5 +---- - qt4/src/poppler-private.h | 12 ++++++++---- - 2 files changed, 9 insertions(+), 8 deletions(-) - -commit f956b03604b195623ab034a06942a39547adf905 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Mar 10 00:01:18 2011 +0000 - - compile - - qt4/src/poppler-form.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit f0ec3bedc5490aa35e54563019fcf2c3f8b7647d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Mar 9 20:54:15 2011 +0100 - - forms: Remove unused method FormWidget::updateField() - - poppler/Form.cc | 22 ---------------------- - poppler/Form.h | 2 -- - 2 files changed, 24 deletions(-) - -commit 93c25e100ae2564b9a866b95bed16d2fac619bd7 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Mar 9 20:49:32 2011 +0100 - - forms: Rename FormField::createActivationAction() to - FormField::getActivationAction() - - And use the existing action from the AnnotWidget instead of creating a - new one. - - poppler/Form.cc | 11 ++--------- - poppler/Form.h | 2 +- - qt4/src/poppler-form.cc | 3 +-- - 3 files changed, 4 insertions(+), 12 deletions(-) - -commit 59fb0489bfabfd8acccafdcd0361ce005664962a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Mar 9 20:19:24 2011 +0100 - - annots: Check whether we need to create an appearance stream in - AnnotWidget::draw() - - And never modify the AP entry since it breaks check and radio buttons - that doesn't have an appearance for the Off state. - - poppler/Annot.cc | 79 - ++++++++++---------------------------------------------- - poppler/Annot.h | 1 - - 2 files changed, 13 insertions(+), 67 deletions(-) - -commit f3b00ef51ceef6d9b7a1aa7e0f19249abf8ca6f3 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Mar 9 18:19:12 2011 +0100 - - annots: Add Annot::setAppearanceState() and use it from FormWidget - - This method not only updates the current appearance state, but - also the - appearance stream corresponding to the new state. - - poppler/Annot.cc | 43 ++++++++++++++++++++++++++++++++++++------- - poppler/Annot.h | 2 ++ - poppler/Form.cc | 7 +++---- - 3 files changed, 41 insertions(+), 11 deletions(-) - -commit d59561212253302d4dcb23392bb8306b8e5c68d1 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Mar 9 17:35:28 2011 +0100 - - forms: Make FormWidget use a real widget annotation instead of - duplicating code - - When creating annotations, if it's a widget annotation, look first - whether it has already been created by a FormWidget and reuse - it instead - of duplicating it. - - poppler/Annot.cc | 42 +++++++++++++-------- - poppler/Annot.h | 2 +- - poppler/Catalog.cc | 2 +- - poppler/Form.cc | 107 - +++++++++++++++++++++++++---------------------------- - poppler/Form.h | 23 ++++++------ - 5 files changed, 89 insertions(+), 87 deletions(-) - -commit 2dd7e1ba09d4501adf9d10ab4cb8ee003cace74a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Mar 9 10:25:00 2011 +0100 - - forms: Move modified flag from FormWidget to FormField - - poppler/Form.cc | 16 ++++++++-------- - poppler/Form.h | 6 ++++-- - 2 files changed, 12 insertions(+), 10 deletions(-) - -commit b04f03be7e43e309af5f164ef71788e7b8915841 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Mar 9 10:17:57 2011 +0100 - - forms: Move field names handling from FormWidget to FormField - - poppler/Form.cc | 149 - +++++++++++++++++++++++++++++++------------------------- - poppler/Form.h | 20 +++++--- - 2 files changed, 95 insertions(+), 74 deletions(-) - -commit abe1e0d5a37bcdb4376901306d3adccfb33ff3b4 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Mar 8 21:39:00 2011 +0100 - - annots: Make sure no border is drawn for invalid border arrays - - Fixes regression on ClassSchedule_2091_ENGL.pdf - - poppler/Annot.cc | 8 ++++++-- - poppler/Annot.h | 2 +- - 2 files changed, 7 insertions(+), 3 deletions(-) - -commit 14d145371e86ccb92f09b1ca750ced52171b2885 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Mar 8 20:14:57 2011 +0100 - - forms: Remove loadDefaults method - - Moving the code to initialize form field stuff to form field - constructors and widget stuff to form widget constructors. Clean up an - simplify the code. - - poppler/Form.cc | 227 - +++++++++++++++++++++----------------------------------- - poppler/Form.h | 21 ++---- - 2 files changed, 91 insertions(+), 157 deletions(-) - -commit 0585d7820455c93fe5b732b7a9a20d423df47075 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Mar 8 15:36:45 2011 +0100 - - forms: Handle field values (V entry) by field objects - - Rather than AnnotWidget or FormWidget, and use the form field object - from AnnotWidget to get the values. - - poppler/Annot.cc | 52 ++++---- - poppler/Form.cc | 400 - +++++++++++++++++++++++++++---------------------------- - poppler/Form.h | 21 +-- - 3 files changed, 230 insertions(+), 243 deletions(-) - -commit dc100eb9080fb58164fc94c86bfb1728cecd21c3 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 7 20:14:27 2011 +0100 - - annots: Use the field object to get MaxLen instead of parsing the - field dict - - poppler/Annot.cc | 10 ++++------ - 1 file changed, 4 insertions(+), 6 deletions(-) - -commit 7149634f184dc3f07f2a70c296aac207ef24952c -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 7 19:55:45 2011 +0100 - - forms: Parse the default resources dictionary in Form - - And use it in AnnotWidget instead of parsing the dictionary again. - - poppler/Annot.cc | 65 - ++++++++++++++++++++++---------------------------------- - poppler/Annot.h | 12 +++++------ - poppler/Form.cc | 16 ++++++++++++++ - poppler/Form.h | 5 +++++ - 4 files changed, 52 insertions(+), 46 deletions(-) - -commit 2e73f17975811177c0b3c16b8bd97c7eb912bc44 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 7 18:41:48 2011 +0100 - - forms: Parse field variable text entries (DA, Q) in FormField() - - And use them from AnnotWidget instead of parsing the field dictionary - again. - - poppler/Annot.cc | 28 +++++----------------------- - poppler/Form.cc | 17 +++++++++++++++++ - poppler/Form.h | 9 +++++++++ - 3 files changed, 31 insertions(+), 23 deletions(-) - -commit 8677a34911563a712b2dcf0b6e411cee0bad9c44 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 7 18:24:07 2011 +0100 - - forms: Parse default variable text entries (DA, Q) on Form - construction - - And use them from AnnotWidget instead of parsing the acroForm - dictionary - again. - - poppler/Annot.cc | 99 - +++++++++++++++++++++++++++----------------------------- - poppler/Form.cc | 11 +++++++ - poppler/Form.h | 12 +++++++ - 3 files changed, 70 insertions(+), 52 deletions(-) - -commit 41420bfd88685d9b1ac44dc7444ea3abee92097c -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 7 09:18:25 2011 +0100 - - annots: Only parse the dash array for dashed borders - - poppler/Annot.cc | 16 +++++++++------- - 1 file changed, 9 insertions(+), 7 deletions(-) - -commit c198a3f83d8508ddaf84564871d9202ffba8096c -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Mar 6 17:52:01 2011 +0100 - - annots: Use the field object to get the top index of a form field - choice - - Instead of parsing the field dictionary again. - - poppler/Annot.cc | 14 ++------------ - poppler/Annot.h | 1 - - 2 files changed, 2 insertions(+), 13 deletions(-) - -commit 5cf803ec181dbf1112f67b4f4a9c77b88d102e3b -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Mar 6 17:47:18 2011 +0100 - - forms: Add FormFieldChoice::getTopIndex() - - poppler/Form.cc | 5 +++++ - poppler/Form.h | 5 ++++- - 2 files changed, 9 insertions(+), 1 deletion(-) - -commit 1248f59e2045749ece1f5a5e579b866b8330a752 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Mar 6 17:41:33 2011 +0100 - - annots: Draw widget background using the existing appearance - characteristics - - Instead of parsing the appearance characteristics dictionary again - - poppler/Annot.cc | 23 +++++++---------------- - 1 file changed, 7 insertions(+), 16 deletions(-) - -commit dc249ad4529997001ae1f96dcfd7351766ca8e8d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Mar 6 17:34:33 2011 +0100 - - annots: Factor out generateFieldAppearance() - - Adding methods to render every form field type and using the field - object when possible instead of parsing the field dictionary again. - - poppler/Annot.cc | 312 - +++++++++++++++++++++++-------------------------------- - poppler/Annot.h | 8 +- - 2 files changed, 138 insertions(+), 182 deletions(-) - -commit f98b3540db731026e0febf1f010548f0f0ef9142 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Mar 6 15:57:22 2011 +0100 - - annots: Move code to draw the border of an AnnotWidget to a new method - - And use the field object instead of parsing the field dictionary - again. - - poppler/Annot.cc | 242 - +++++++++++++++++++++++++++---------------------------- - poppler/Annot.h | 3 + - 2 files changed, 124 insertions(+), 121 deletions(-) - -commit 9854f3173f994bbe3f57d33bd1d0e045833859c2 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Mar 6 15:56:06 2011 +0100 - - annots: Add AnnotColor::adjustColor() to be able to adjust an - existing AnnotColor - - poppler/Annot.cc | 7 +++++++ - poppler/Annot.h | 2 ++ - 2 files changed, 9 insertions(+) - -commit 2bf82f27bd9c8f97e5484ea97be661f65221163d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Mar 5 15:30:01 2011 +0100 - - annots: Remove unused class AnnotBorderStyle - - poppler/Annot.cc | 22 ---------------------- - poppler/Annot.h | 36 ------------------------------------ - 2 files changed, 58 deletions(-) - -commit 128dcaf282f418d8c45cea4df6ad4d3167b3e39c -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Mar 5 13:12:49 2011 +0100 - - annots: Add AnnotBorder::parseDashArray() to parse dash arrays - - The code was duplicated in AnnotBorderArray and AnnotBorderBS - - poppler/Annot.cc | 91 - +++++++++++++++++++------------------------------------- - poppler/Annot.h | 4 ++- - 2 files changed, 34 insertions(+), 61 deletions(-) - -commit ec2643d311e0ce55f0ff5309c0c420140d053a50 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Mar 1 19:50:55 2011 +0000 - - fix copyright years - - poppler/Annot.cc | 2 +- - poppler/Annot.h | 2 +- - poppler/ArthurOutputDev.cc | 2 +- - poppler/ArthurOutputDev.h | 2 +- - poppler/FontInfo.cc | 1 + - poppler/Form.cc | 4 ++-- - poppler/Form.h | 3 ++- - poppler/GlobalParams.cc | 1 + - poppler/GlobalParams.h | 1 + - poppler/Link.cc | 2 +- - poppler/Link.h | 2 +- - poppler/OutputDev.h | 2 +- - poppler/PDFDoc.cc | 2 +- - poppler/Page.cc | 2 +- - poppler/Page.h | 2 +- - poppler/TextOutputDev.cc | 2 +- - poppler/TextOutputDev.h | 2 +- - qt4/src/poppler-form.cc | 2 +- - qt4/src/poppler-link-extractor-private.h | 2 +- - qt4/src/poppler-link-extractor.cc | 2 +- - qt4/src/poppler-page.cc | 2 +- - qt4/src/poppler-private.h | 2 +- - utils/HtmlOutputDev.cc | 2 +- - utils/HtmlOutputDev.h | 4 ++-- - 24 files changed, 27 insertions(+), 23 deletions(-) - -commit 900974ebfbe6ab7ae21ed151ff79f9578d2bdae2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Mar 1 19:42:22 2011 +0000 - - Fix years - - poppler/poppler-config.h.cmake | 2 +- - poppler/poppler-config.h.in | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit c804db4d8261274b013f8c340abfc921c77bb3cf -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 1 19:22:31 2011 +0100 - - move the fontconfig.h inclusion from GlobalParams.h to GlobalParams.cc - - this avoids a dependency on the fontconfig headers to the users of - the core - - poppler/GlobalParams.cc | 4 ++++ - poppler/GlobalParams.h | 3 --- - 2 files changed, 4 insertions(+), 3 deletions(-) - -commit 2d77c7f9c41f1121354413bcdc3beded35a247f9 -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 1 16:51:04 2011 +0100 - - create the GooString on stack, not in heap - - poppler/Annot.cc | 5 ++--- - poppler/Form.cc | 5 ++--- - 2 files changed, 4 insertions(+), 6 deletions(-) - -commit 5dc2ef0e27ac48c81739cdfe8e8070ebbc410c87 -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 1 16:39:36 2011 +0100 - - annots: avoid temporary GooString's just for comparisons, just - use strcmp - - other than reducing few GooString allocations, strcmp should be much - faster than GooString::cmp - - poppler/Annot.cc | 128 - ++++++++++++++++++++++++------------------------------- - 1 file changed, 56 insertions(+), 72 deletions(-) - -commit 535e48ab764ee4e377451ddd032044b51b842c4a -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 1 16:07:34 2011 +0100 - - [qt4] ignore "Widget" annotations - - they usually are forms or something else we do not support, so do - not complain about them for now - - qt4/src/poppler-page.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit f0e5c36e7f1c5d0f0f51e3a6a6acd6c423f86df7 -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 1 16:02:54 2011 +0100 - - annots: avoid a temporary GooString just for comparisons, just - use strcmp - - other than reducing few GooString allocations, strcmp should be much - faster than GooString::cmp - - poppler/Annot.cc | 54 - ++++++++++++++++++++++++++---------------------------- - 1 file changed, 26 insertions(+), 28 deletions(-) - -commit 58a3b83a8fbd8b13eb98c4f677f4ed19b6ae44cd -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 1 15:35:45 2011 +0100 - - fix appendAnnot() invocation on annotations reading - - 1) check that the annot is actually a non-NULL pointer (otherwise - doing anything else is pointless) - 2) call appendAnnot() only if the annotation isOk() (that will - increase the annot refcount), but always decrement the refcount - (so valid annotation will have it at 1, while invalid will be deleted) - - poppler/Annot.cc | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -commit 664865a2ddca9c20ac36a41aef52ebf12eab838d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Mar 1 10:56:40 2011 +0100 - - Merge Link and AnnotLink code - - Annotations now belong to the Page and are created only once on - demand. - Annots are now ref counted and Links is a list of AnnotLink objects, - Link object has been removed. The AnnotLink API is mostly the - same than - Link and frontends APIs are not affected. - Qt4 changes made by Pino Toscano. - - glib/poppler-document.cc | 2 +- - glib/poppler-page.cc | 29 ++++---- - glib/poppler-private.h | 1 - - poppler/Annot.cc | 79 +++++++++++++------- - poppler/Annot.h | 24 ++++-- - poppler/ArthurOutputDev.cc | 4 - - poppler/ArthurOutputDev.h | 3 - - poppler/CairoOutputDev.cc | 3 - - poppler/CairoOutputDev.h | 6 -- - poppler/FontInfo.cc | 4 +- - poppler/Form.cc | 36 ++++----- - poppler/Form.h | 5 +- - poppler/Link.cc | 124 - +++++-------------------------- - poppler/Link.h | 43 ++--------- - poppler/OutputDev.h | 4 +- - poppler/PDFDoc.cc | 4 +- - poppler/Page.cc | 63 ++++++++-------- - poppler/Page.h | 11 +-- - poppler/TextOutputDev.cc | 9 ++- - poppler/TextOutputDev.h | 10 +-- - qt4/src/poppler-link-extractor-private.h | 2 +- - qt4/src/poppler-link-extractor.cc | 3 +- - qt4/src/poppler-page.cc | 12 ++- - utils/HtmlOutputDev.cc | 7 +- - utils/HtmlOutputDev.h | 4 +- - 25 files changed, 188 insertions(+), 304 deletions(-) - -commit 1f6573e949aaba0eb0a4c2f9cd73d7ad45ba67be -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 27 21:53:32 2011 +0100 - - small fixes to the pdftohtml manpage - - - capitalize HTML, PDF, XML, PNG - - dont -> do not - - fix UTF-8 character - - fix hypens used as minus - - utils/pdftohtml.1 | 18 +++++++++--------- - 1 file changed, 9 insertions(+), 9 deletions(-) - -commit e927384897595f1bda5f7e41b552602f9cc8ed95 -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 27 16:39:59 2011 +0100 - - [qt4] fix caption of push button fields - - instead of asking the 'onStr' of the underlying form widget, - take (if available) the 'MK' entry, i.e. the appearance - characteristics dictionary, - and use the normal caption of that - - qt4/src/poppler-form.cc | 25 +++++++++++++++++++++++-- - 1 file changed, 23 insertions(+), 2 deletions(-) - -commit 5b24ee2c934feea1b7d46c8ec423d1c547258be2 -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 27 16:24:22 2011 +0100 - - annots: 'CA', 'RC' and 'AC' are strings, not names - - poppler/Annot.cc | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - -commit e64f6cb23e9a564b3f80daea9abcfe8bb29189eb -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 27 15:22:32 2011 +0100 - - make getOnStr() return the GooString* instead of its char* - - ... and modify its use accordingly - this way it is easier to check for a numm onStr, without the risk - of dereferencing a NULL pointer - - poppler/Form.cc | 6 +++--- - poppler/Form.h | 2 +- - qt4/src/poppler-form.cc | 7 ++----- - 3 files changed, 6 insertions(+), 9 deletions(-) - -commit f9c978fc2ab8a1f901f2136ae95deb9d41076155 -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 27 14:39:52 2011 +0100 - - [qt4] directly use the dict - - qt4/src/poppler-form.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 071966e48577c515b17a424baeae85ae4fc80a20 -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 27 14:21:11 2011 +0100 - - [qt4] move textAlignment() as a private function - - qt4/src/poppler-form.cc | 33 +++++++++++++++++++++++++++++++-- - qt4/src/poppler-private.h | 25 ------------------------- - 2 files changed, 31 insertions(+), 27 deletions(-) - -commit adc236771f11eeb4197064747836e8ed3fbfeba9 -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 27 14:13:50 2011 +0100 - - [qt4] use FormWidget::getAlternateUiName() - - ... instead of read the value on our own - - qt4/src/poppler-form.cc | 9 ++------- - 1 file changed, 2 insertions(+), 7 deletions(-) - -commit 9f111483cf6196dedf3cee380c3e5224776203ea -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 27 14:12:16 2011 +0100 - - forms: read the TU field as alternateUiName - - poppler/Form.cc | 8 ++++++++ - poppler/Form.h | 2 ++ - 2 files changed, 10 insertions(+) - -commit cfaadaa9e4a857fcea3b5a2cadacd352de6c469d -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 27 14:07:35 2011 +0100 - - [qt4] use FormWidget::getPartialName() - - ... instead of read the value on our own - - qt4/src/poppler-form.cc | 9 ++------- - 1 file changed, 2 insertions(+), 7 deletions(-) - -commit 2478896a0c1f6e5842f3d8b172e4cc7e6bd58cd8 -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 27 13:24:09 2011 +0100 - - [qt4] use the new FormWidget::createActivationAction() - - qt4/src/poppler-form.cc | 13 +++---------- - 1 file changed, 3 insertions(+), 10 deletions(-) - -commit 1dcb683a5c2dd6a1de654e90a4394f65d63dc296 -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 27 13:22:48 2011 +0100 - - add FormWidget::createActivationAction() - - used to get and create a new activation action object of a form widget - - poppler/Form.cc | 12 ++++++++++++ - poppler/Form.h | 3 +++ - 2 files changed, 15 insertions(+) - -commit bd4cc73e438a7d4d4a10c50c69e65b5bdc63ddf2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Feb 27 11:04:45 2011 +0000 - - Some more missing copyrights - - poppler/CairoOutputDev.cc | 2 +- - poppler/CairoOutputDev.h | 2 +- - poppler/Gfx.cc | 2 +- - poppler/OutputDev.h | 2 +- - poppler/TextOutputDev.cc | 1 + - 5 files changed, 5 insertions(+), 4 deletions(-) - -commit 6c2ed4781d8ecfffdf24e1459aafd554b3527686 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Feb 27 10:55:22 2011 +0000 - - Add 2011 years - - poppler/Annot.cc | 2 +- - poppler/CairoFontEngine.cc | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit b297fb9de0779ac84d5b7ef68c792afefe598320 -Author: William Bader <williambader@hotmail.com> -Date: Sun Feb 27 01:48:55 2011 +0000 - - access the pixels directly - - Faster, bug 34005 - - splash/Splash.cc | 21 +++++++++++---------- - 1 file changed, 11 insertions(+), 10 deletions(-) - -commit de77e26759f1c33698abe248ad29b75c329a043c -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Feb 27 01:39:23 2011 +0000 - - Fix crash in some pdf - - Has to be 3 and not nComps since it's a output buffer, a the input one - Bug 34357 - - poppler/GfxState.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 4f82a2e08cb2c930956c6b38030fa7b015a0de5a -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Feb 27 01:38:33 2011 +0000 - - Implement GfxDeviceCMYKColorSpace::getRGBLine - - poppler/GfxState.cc | 22 +++++++++++++++++++++- - poppler/GfxState.h | 12 +++++++++++- - 2 files changed, 32 insertions(+), 2 deletions(-) - -commit 4980b99214281dcab8f82b5b618aadc24de371f4 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Feb 26 14:00:33 2011 +0100 - - annots: Don't assume y1 > y3 for quad points of a highlight annotation - - Fixes https://bugzilla.gnome.org/show_bug.cgi?id=643028 - - poppler/Annot.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit e6ae0f8609cd66e9e124af59adefdff9d610dcd4 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Feb 26 13:23:47 2011 +0100 - - cairo: Handle font type fontCIDType2OT when creating freetype font - - Fixes https://bugzilla.gnome.org/show_bug.cgi?id=643273 - - poppler/CairoFontEngine.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 22eb01d305ea2560d26417ca8df9c0465d4e9a82 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Feb 26 12:17:49 2011 +0100 - - cairo: Fix a crash when rendering a document with inline images - - poppler/CairoOutputDev.cc | 28 ++++++++++++++++------------ - poppler/CairoOutputDev.h | 2 +- - 2 files changed, 17 insertions(+), 13 deletions(-) - -commit a6599dd1fda37186b876b5b2de80be1731dd5946 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Feb 26 11:59:03 2011 +0100 - - glib: Add some more introspection annotations - - glib/poppler-attachment.cc | 2 +- - glib/poppler-document.cc | 4 ++-- - glib/poppler-media.cc | 2 +- - glib/poppler-page.cc | 6 +++--- - 4 files changed, 7 insertions(+), 7 deletions(-) - -commit 89c66f236c85ac5a53ae12b01cdebc30e27b78d3 -Author: Peter Ward <peteraward@gmail.com> -Date: Sat Feb 26 11:39:58 2011 +0100 - - glib: Add missing "out" annotation to poppler_page_get_size() - - glib/poppler-page.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 7a68199b342eb3f33733f7d7446ede8f94130fba -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Feb 26 11:09:27 2011 +0100 - - cairo: Check if cairo version is == 1.11.2 to use mesh gradients api - - Cairo API has changed in 1.11.3. - - poppler/CairoOutputDev.cc | 4 ++-- - poppler/CairoOutputDev.h | 4 ++-- - 2 files changed, 4 insertions(+), 4 deletions(-) - -commit 97e7ab1a4eea2160f3f0847d10f6c16f2d66ef11 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Feb 25 20:33:39 2011 +0000 - - Do not ask freetype for a font of size 0x0 - - Fixes rendering bug at 34602 - - splash/SplashFTFont.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 3590a2d38082fc705040cdb31bf0b22ff12dd3e4 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Thu Feb 24 18:47:35 2011 +0000 - - Fix rendering of some substituted fonts - - More info in bug 34522 - - poppler/GfxFont.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 384753f1f9f780687bdead99a6548ef8598b898a -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Feb 21 19:19:48 2011 +0000 - - Use gfree since we allocate with gmalloc - - Bug 34512 - - goo/GooString.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit d775420c3c6cb5a29ff74712d3fc210fcb4b4627 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Feb 19 11:19:57 2011 +0000 - - Do not delete textOut twice when using -bbox - - utils/pdftotext.cc | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit e1a56d73b066e7152ccf6ccf36206def7956cb00 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Feb 16 00:06:45 2011 +0000 - - Lots of rendering improvements by Thomas and Andrea - - Function.cc: Stitching functions incorrectly reported 0 as output - size. - Function.cc: Remove cache from PostScriptFunction - Function.cc: Make PSStack stack allocated - GfxState.cc & GfxState.h: Abstract GfxSimpleShading, add Matrix::norm - method, add simple caching, parameter range computation - SplashOutputDev.cc & SplashOutputDev..h & Splash.cc & SplashPattern.h: - Improve splash rendering, implement radial and abstract simple - shadings - in splash - - And maybe something more, look at the - Followup Bug 32349 & Poppler: More shading fun ;-) - thread for more info - - poppler/Function.cc | 122 +-------- - poppler/Function.h | 3 +- - poppler/GfxState.cc | 634 - +++++++++++++++++++++++++++++++++++++++------ - poppler/GfxState.h | 90 +++++-- - poppler/SplashOutputDev.cc | 253 +++++++++++++++--- - poppler/SplashOutputDev.h | 67 ++++- - splash/Splash.cc | 126 ++++++--- - splash/SplashPattern.h | 7 +- - 8 files changed, 1006 insertions(+), 296 deletions(-) - -commit 675b3505f963a0110dac7f865654232cbb865ef5 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Feb 13 16:21:52 2011 +0100 - - tests: Merge splash and cairo tests into a single gtk-test tool - - With a command line option to use cairo or splash backends. - - test/CMakeLists.txt | 20 +-- - test/Makefile.am | 29 ++-- - test/gtk-cairo-test.cc | 190 ----------------------- - test/gtk-splash-test.cc | 311 ------------------------------------- - test/gtk-test.cc | 397 - ++++++++++++++++++++++++++++++++++++++++++++++++ - 5 files changed, 412 insertions(+), 535 deletions(-) - -commit 728c022cdc1ea12aa54077d44276f9d7714930d4 -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 13 13:25:51 2011 +0100 - - remove more references to the qt3 frontend - - followup of d82f98a274bfa008c218e265a080c4af7ce95131 - - Makefile.am | 3 --- - 1 file changed, 3 deletions(-) - -commit 15e5b3f16015361754fdc14da4a0dde5af887568 -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 13 13:23:06 2011 +0100 - - remove more GDK-related stuff - - followup of 149b7fec472beda9d1538e0f26607c9498d504c2 - - Makefile.am | 1 - - cmake/modules/FindGDK.cmake | 22 ---------------------- - config.h.cmake | 3 --- - glib/reference/Makefile.am | 1 - - glib/reference/poppler-sections.txt | 1 - - 5 files changed, 28 deletions(-) - -commit 50aa15a0bd7100fc9b9243de1d6e6f4b59df1488 -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 13 13:07:19 2011 +0100 - - remove GDK API here too - - followup of 149b7fec472beda9d1538e0f26607c9498d504c2 - - glib/poppler-features.h.cmake | 1 - - 1 file changed, 1 deletion(-) - -commit f410cd11268254b9d0422201c9860d775f73fdd8 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Feb 13 12:55:37 2011 +0100 - - gtk-splash-test: Don't use GDK deprecated API - - test/gtk-splash-test.cc | 28 +++++++++++++++------------- - 1 file changed, 15 insertions(+), 13 deletions(-) - -commit a0568e449061d6b6af5485e340cd6f9d3e54ef7c -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Feb 13 12:27:22 2011 +0100 - - glib: remove gdk referenes from pkg-config files - - poppler-glib-uninstalled.pc.in | 2 +- - poppler-glib.pc.cmake | 2 +- - poppler-glib.pc.in | 2 +- - 3 files changed, 3 insertions(+), 3 deletions(-) - -commit 149b7fec472beda9d1538e0f26607c9498d504c2 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Feb 13 11:51:57 2011 +0100 - - glib: Remove deprecated GDK API - - It removes the GDK dependency so that poppler-glib now only depends on - glib and cairo. - - CMakeLists.txt | 9 -- - configure.ac | 44 +------ - glib/CMakeLists.txt | 14 +-- - glib/Makefile.am | 8 +- - glib/poppler-features.h.in | 6 - - glib/poppler-page.cc | 296 - --------------------------------------------- - glib/poppler-page.h | 34 ------ - 7 files changed, 4 insertions(+), 407 deletions(-) - -commit a5482d64472a81206dd8d0c5bb80007f6d5bb893 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Feb 13 11:40:23 2011 +0100 - - glib: Remove test-poppler-glib, poppler-glib-demo does the same - and more - - glib/CMakeLists.txt | 8 - - glib/Makefile.am | 14 - - glib/test-poppler-glib.cc | 657 - ---------------------------------------------- - 3 files changed, 679 deletions(-) - -commit cab0cf028a192772dcb5c3f4aefa0a421e73e9e7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Feb 11 19:42:34 2011 +0000 - - Do not infinite loop in some broken files - - poppler/JBIG2Stream.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 1125cc8ccf386d8e0a0679aa73614bc2cb8037b0 -Author: William Bader <williambader@hotmail.com> -Date: Tue Feb 8 20:27:16 2011 +0000 - - Allow setting the rasterization resolution - - More info at bug 34001 - - poppler/GlobalParams.cc | 15 +++++++++++++++ - poppler/GlobalParams.h | 3 +++ - poppler/PSOutputDev.cc | 7 ++++++- - utils/pdftops.1 | 6 ++++++ - utils/pdftops.cc | 6 ++++++ - 5 files changed, 36 insertions(+), 1 deletion(-) - -commit 96e169b0eca31891f3cd564365d4a2a5c6e2a2c0 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Feb 8 19:58:31 2011 +0000 - - Make really sure the uMap static pointer is valid - - It might happen you are extremely unlucky and get the same - globalParams after a new delete/creation - - qt4/src/poppler-private.cc | 51 - +++++++++++++++++++++++++++++++++++++++------- - qt4/src/poppler-private.h | 34 +++---------------------------- - 2 files changed, 47 insertions(+), 38 deletions(-) - -commit c3470145f95791167c19a438934a923eab8a93cf -Author: William Bader <williambader@hotmail.com> -Date: Tue Feb 8 19:54:48 2011 +0000 - - Add PS level1 non standard binary output option - - More info at bug 34003 - - poppler/GlobalParams.cc | 18 +++- - poppler/GlobalParams.h | 5 +- - poppler/PSOutputDev.cc | 227 - ++++++++++++++++++++++++++++++++++-------------- - utils/pdftops.1 | 7 ++ - utils/pdftops.cc | 8 +- - 5 files changed, 198 insertions(+), 67 deletions(-) - -commit 37077aa475d2dee81f87daa05297b201eeb99c87 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Feb 7 19:48:28 2011 +0000 - - Make sure tx is inside the bitmap - - Seems to be what the code tried to do, fixes crash in bug 33948 - depending on - the resolution you render it - - poppler/SplashOutputDev.cc | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -commit 5aa854f70c8f563efe56dafa8bd6b3cdd5c95451 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Feb 6 13:24:35 2011 +0100 - - cairo: Use the new cairo unique id to set the surface id when printing - - Set the unique surface id when attaching jpeg images to the surface so - that cairo can reuse the mime data even when a new surface is created - with the same mime data. This reduces the size of the output file when - printing. - - poppler/CairoOutputDev.cc | 18 ++++++++++++++++-- - poppler/CairoOutputDev.h | 2 +- - 2 files changed, 17 insertions(+), 3 deletions(-) - -commit fe7b8aa4fc78aacf3226d019db74146ceaebd63c -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Feb 2 22:35:40 2011 +0000 - - Workaround bug when converting pdf to ps with level1 - - See bug 31926 for more info - - poppler/PSOutputDev.cc | 2 +- - poppler/PreScanOutputDev.cc | 7 +++++++ - poppler/PreScanOutputDev.h | 7 +++++++ - 3 files changed, 15 insertions(+), 1 deletion(-) - -commit 5984ad081cd609f3146e0da5e22097ef073eb519 -Author: William Bader <williambader@hotmail.com> -Date: Sun Jan 30 17:02:02 2011 +0000 - - Increase precision - - Fixes some issues with pdf from bug 27482 - - poppler/PSOutputDev.cc | 200 - ++++++++++++++++++++++++------------------------- - 1 file changed, 100 insertions(+), 100 deletions(-) - -commit c60d5afbeb986c1b335357202c5f551a3c146a76 -Author: Jim Meyering <meyering@redhat.com> -Date: Mon Jan 24 15:51:20 2011 +0100 - - demo: don't use an uninitialized local variable - - * text.c (pgd_text_get_text): Before this change, when - poppler_page_get_text returned NULL, we'd use "n_recs" uninitialized. - - glib/demo/text.c | 1 + - 1 file changed, 1 insertion(+) - -commit a3bdc56e2f086444419eddfcda5d2010a9a6b5c0 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Jan 29 11:23:33 2011 +0100 - - glib-demo: Add a tooltip with current selected character in text demo - - To make sure that the offset of the text returned by - poppler_page_get_text() matches - the list of rectangles returned by poppler_page_get_text_layout(). - - glib/demo/text.c | 60 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 60 insertions(+) - -commit bf2d86c8db430595fb3c55edd3f6c8d289bdaeb5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jan 28 20:34:08 2011 +0000 - - Make sure uMap is still valid before using it - - Fixes KDE bug 264667 - - qt4/src/poppler-private.cc | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit e6fb20d7b3bf8ea8aedc1bcd910e035059835b5f -Author: Axel Strübing <axel.struebing@freenet.de> -Date: Fri Jan 28 19:20:15 2011 +0000 - - Extract text of a pdf correctly - - See "[poppler] text extraction does not work" in the mailing list - for more info - - poppler/GfxFont.cc | 14 +++++++++++++- - poppler/GfxFont.h | 2 ++ - 2 files changed, 15 insertions(+), 1 deletion(-) - -commit 4829d36a3b005585db8c8115f7ee81a4e2384780 -Author: Simon Kellner <kellner@kit.edu> -Date: Wed Jan 26 22:59:49 2011 +0000 - - fix labelToIndex on multiple prefixes - - A PDF document can use page label prefixes, for example, to label - only inside a chapter ("A-1" .. "A-<n>", "B-1" .. "B-<m>" et cetera). - When calculating a page index for a given label, poppler would - disregard the page range for all preceding prefixes that do not - match the given prefix. - - poppler/PageLabelInfo.cc | 7 +++---- - 1 file changed, 3 insertions(+), 4 deletions(-) - -commit e57c75fbd95ef8399b0785500f6893465bc808c3 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Mon Jan 24 19:48:09 2011 +1030 - - cairo: Implement Type 4,5,6,7 shadings using cairo mesh gradients - - Fixes bugs #19076 and #32791. - - poppler/CairoOutputDev.cc | 139 - ++++++++++++++++++++++++++++++++++++++++++++++ - poppler/CairoOutputDev.h | 12 ++++ - poppler/Gfx.cc | 10 +++- - poppler/OutputDev.h | 2 + - 4 files changed, 161 insertions(+), 2 deletions(-) - -commit 5081356fcc69012e9df95dbf1e3c36e7c1e751c4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jan 25 20:26:25 2011 +0000 - - Fix leak in SplashOutputDev::axialShadedFill - - poppler/SplashOutputDev.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 19dc283c3af597deab297341a37495c06988948b -Author: Thomas Klausner <wiz@danbala.tuwien.ac.at> -Date: Mon Jan 24 19:05:08 2011 +0000 - - Include zlib header since we use things defined there - - goo/PNGWriter.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 5056e33e01ce0f7db1a5401b7b38d30e84eedf69 -Author: Sam Liao <phyomh@gmail.com> -Date: Mon Jan 17 13:07:22 2011 +0800 - - Poppler: Fix line selection, dont check y for Line selection - - When a line is selected while the Y values of selection is - not in the y range of words, the render will render the - line with reverse color while the words does not show up. - - This fix neglect the Y vaules to make sure that the words - also displayed when line is selected. - - poppler/TextOutputDev.cc | 16 ++++++++-------- - 1 file changed, 8 insertions(+), 8 deletions(-) - -commit 88812e716c1a0c87a504118d47eb4cc6f52962fa -Author: Andreas Hartmetz <ahartmetz@gmail.com> -Date: Fri Jan 21 23:33:47 2011 +0000 - - Add Hinting API to ArthurOutputDev - - poppler/ArthurOutputDev.cc | 11 +++++++++-- - poppler/ArthurOutputDev.h | 15 ++++++++++++++- - 2 files changed, 23 insertions(+), 3 deletions(-) - -commit dc5ec4668bdfe3b6ba41f0a2e551bbc07f8839ba -Author: Andreas Hartmetz <ahartmetz@gmail.com> -Date: Fri Jan 21 23:32:50 2011 +0000 - - support slight hinting in Splash backend - - cpp/poppler-page-renderer.cpp | 2 +- - poppler/SplashOutputDev.cc | 6 +++++- - poppler/SplashOutputDev.h | 4 +++- - qt4/src/poppler-private.h | 3 ++- - qt4/src/poppler-qt4.h | 4 +++- - splash/SplashFTFont.cc | 27 ++++++++++++++++++--------- - splash/SplashFTFont.h | 2 ++ - splash/SplashFTFontEngine.cc | 10 +++++++--- - splash/SplashFTFontEngine.h | 6 ++++-- - splash/SplashFontEngine.cc | 4 +++- - splash/SplashFontEngine.h | 2 ++ - 11 files changed, 50 insertions(+), 20 deletions(-) - -commit 0c5b1bef9f3f98001cee20061b1eaf20b965c5a9 -Author: William Bader <williambader@hotmail.com> -Date: Fri Jan 21 19:01:45 2011 +0000 - - Fix rendering for some pdf with -level1sep - - Also some speed improvemensts. Bug #32365 - - poppler/PSOutputDev.cc | 207 - ++++++++++++++++++++++++++++++++++++++----------- - poppler/PSOutputDev.h | 13 +++- - 2 files changed, 170 insertions(+), 50 deletions(-) - -commit 6cb8965fb8bce6da2a4460e86f592c1ea3a84a5c -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jan 21 18:43:21 2011 +0000 - - fix (C) years - - poppler/CairoOutputDev.cc | 2 +- - poppler/CairoOutputDev.h | 2 +- - qt4/src/poppler-private.cc | 2 +- - qt4/tests/check_strings.cpp | 2 +- - 4 files changed, 4 insertions(+), 4 deletions(-) - -commit 24f9c8924b2135da616386d0fa691fe790b4e7a4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jan 21 08:43:34 2011 +0000 - - Access the correct variable - - Fixes asert on bug 33063 - - poppler/Annot.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 07a8808c22445c421f3064da7e5227dcbf40358b -Author: Pino Toscano <pino@kde.org> -Date: Mon Jan 17 21:34:23 2011 +0100 - - fix unicodeToQString() to correctly decode the Unicode sequence - - Use a UnicodeMap to convert the sequence to UTF-8, and convert from - that to QString. - Also, ignore the last character of the Unicode sequence if it is 0x0. - - Add a couple of testcases for it. - - qt4/src/poppler-private.cc | 30 ++++++++++++++++++++++++------ - qt4/tests/check_strings.cpp | 21 +++++++++++++++++++++ - 2 files changed, 45 insertions(+), 6 deletions(-) - -commit ed367c08d788c88c49de770019bf826cfebb3e2c -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 16 17:25:02 2011 +0000 - - Don't need this either - - configure.ac | 1 - - 1 file changed, 1 deletion(-) - -commit 76ab657dc81ed0af7d9f2efaca2e68d570063001 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 16 17:22:56 2011 +0000 - - And this is the last bit of qt3 cleaning? - - configure.ac | 1 - - 1 file changed, 1 deletion(-) - -commit 9a02856c2762e65b8f03e443e728e05e5a86f65b -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 16 17:21:00 2011 +0000 - - Another qt3 unused file - - m4/qt.m4 | 16 ---------------- - 1 file changed, 16 deletions(-) - -commit 26da7a52d31eb677ab6399de2c07140aa272b35e -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 16 17:17:59 2011 +0000 - - Yet more qt3 cleaning - - configure.ac | 2 -- - 1 file changed, 2 deletions(-) - -commit 8dc9c693abb0033247a338d0f7d1f3f7a57c1a55 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 16 17:14:34 2011 +0000 - - Some more qt3 thigs i forgot to kill - - CMakeLists.txt | 5 - - Makefile.am | 1 - - cmake/modules/FindQt3.cmake | 319 - -------------------------------------------- - 3 files changed, 325 deletions(-) - -commit d82f98a274bfa008c218e265a080c4af7ce95131 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 16 17:13:06 2011 +0000 - - Kill qt3 frontend - - CMakeLists.txt | 5 - - Makefile.am | 5 - - configure.ac | 18 -- - poppler-qt-uninstalled.pc.in | 7 - - poppler-qt.pc.cmake | 13 -- - poppler-qt.pc.in | 13 -- - qt/.gitignore | 7 - - qt/CMakeLists.txt | 34 ---- - qt/Makefile.am | 48 ----- - qt/poppler-document.cc | 344 - --------------------------------- - qt/poppler-fontinfo.cc | 83 -------- - qt/poppler-link-qt3.h | 188 ------------------ - qt/poppler-link.cc | 267 -------------------------- - qt/poppler-page-transition-private.h | 28 --- - qt/poppler-page-transition.cc | 95 ---------- - qt/poppler-page-transition.h | 146 -------------- - qt/poppler-page.cc | 357 - ----------------------------------- - qt/poppler-private.cc | 147 --------------- - qt/poppler-private.h | 102 ---------- - qt/poppler-qt.h | 311 ------------------------------ - qt/test-poppler-qt.cpp | 122 ------------ - 21 files changed, 2340 deletions(-) - -commit 301352e5585d4ab6e7b609b4ab79b4d8b8656092 -Author: Daiki Ueno <ueno@unixuser.org> -Date: Sun Jan 9 18:48:50 2011 +0000 - - Do not crash in case jpeg_create_decompress fails - - Bug 32890 - - poppler/DCTStream.cc | 21 ++++++++++++--------- - poppler/DCTStream.h | 8 ++++++-- - 2 files changed, 18 insertions(+), 11 deletions(-) - -commit 17baf0498485720b4ea5952bb46287f533139d0a -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Jan 8 13:03:31 2011 +0000 - - Remove declaration of function without implementation - - poppler/XRef.h | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit a9e280508f5d669c8b6e1a6bb888b9369d868ab3 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Jan 8 10:39:41 2011 +0100 - - glib: Fix memory leak when calling poppler_page_get_text_layout() - for pages with no text - - glib/poppler-page.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 5d62d18941810ef7d668eafa8b001085133fb169 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Jan 8 10:33:32 2011 +0100 - - glib: Use NULL instead of FALSE in g_return_val_if_fail() for - functions returning a pointer - - glib/poppler-page.cc | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - -commit 1324ae13f1fc2fa28951c2c7f7d63d4756537229 -Author: Pino Toscano <pino@kde.org> -Date: Thu Jan 6 01:15:30 2011 +0100 - - [cpp/apidox] advertize the 'pnm' image format - - cpp/poppler-image.cpp | 1 + - 1 file changed, 1 insertion(+) - -commit b192363960c26111167b1b08db9910e5f39dcf8b -Author: Pino Toscano <pino@kde.org> -Date: Thu Jan 6 01:09:09 2011 +0100 - - [cpp] Add PNM (PBM/PGM/PPM) exporting to 'image'. - - Introduce a custom ImgWriter (PNMWriter) for exporting in the PNM - variants, - and use it choosing the output format matching as close as possible - the format of the image. - - cpp/CMakeLists.txt | 1 + - cpp/Makefile.am | 2 + - cpp/PNMWriter.cc | 119 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - cpp/PNMWriter.h | 43 ++++++++++++++++++ - cpp/poppler-image.cpp | 22 +++++++++- - 5 files changed, 186 insertions(+), 1 deletion(-) - -commit bebc530cbde7898759e1bd3629d2836ce0fb1d08 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Fri Dec 31 12:11:40 2010 +1030 - - cairo: Don't set JPX mime data if the stream specifies a colorspace - - The stream colorspace overides, and may be different to, the - colorspace in the JPX data. - - https://bugs.freedesktop.org/show_bug.cgi?id=32746 - - poppler/CairoOutputDev.cc | 46 - +++++++++++++++++++++++++++++++--------------- - poppler/CairoOutputDev.h | 1 + - 2 files changed, 32 insertions(+), 15 deletions(-) - -commit 1399b9ab14b19f25583c75af2b36f63a6a01129a -Author: Pino Toscano <pino@kde.org> -Date: Wed Dec 29 15:56:45 2010 +0100 - - [cpp] add TIFF output to 'image' - - cpp/poppler-image.cpp | 12 ++++++++++++ - 1 file changed, 12 insertions(+) - -commit 1c7937dbc3c577ffc12cacc8de33d320e2f30ce9 -Author: William Bader <williambader@hotmail.com> -Date: Wed Dec 29 14:47:06 2010 +0000 - - Make pdftoppm be able of writing tif files - - BUG 32027 - - CMakeLists.txt | 15 ++++ - config.h.cmake | 3 + - configure.ac | 32 ++++++++ - goo/Makefile.am | 2 + - goo/TiffWriter.cc | 202 - +++++++++++++++++++++++++++++++++++++++++++++++++ - goo/TiffWriter.h | 53 +++++++++++++ - poppler/Makefile.am | 11 +++ - splash/SplashBitmap.cc | 18 ++++- - splash/SplashBitmap.h | 5 +- - splash/SplashTypes.h | 4 +- - utils/pdftoppm.1 | 6 ++ - utils/pdftoppm.cc | 14 +++- - 12 files changed, 358 insertions(+), 7 deletions(-) - -commit bae91ecb638fcfee001e5c9a86a754610da796e4 -Author: William Bader <williambader@hotmail.com> -Date: Tue Dec 28 11:53:54 2010 +0000 - - Add -singlefile option to pdftoppm - - Bug 32025 - - utils/pdftoppm.1 | 3 +++ - utils/pdftoppm.cc | 26 +++++++++++++++++++++++--- - 2 files changed, 26 insertions(+), 3 deletions(-) - -commit ff58ee66c27da09a370a3000ab55eb1a24921852 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Dec 27 20:07:21 2010 +0000 - - bump soname just in case the getPage change is not BC - - qt/CMakeLists.txt | 2 +- - qt/Makefile.am | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 453df02e195a96d0210f297c21c8ffba646659da -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Dec 27 19:51:13 2010 +0000 - - Make distcheck work - - glib/Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 6a34cec72c1a1b6576858a7836aae4a902fb5ed7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Dec 27 19:29:52 2010 +0000 - - increase core soname - - CMakeLists.txt | 2 +- - poppler/Makefile.am | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 8c11e9d68dceb609d04b3b383d22c307b5981d86 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Dec 27 19:23:29 2010 +0000 - - 0.16.0 project version increase - - CMakeLists.txt | 4 ++-- - configure.ac | 4 ++-- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - 4 files changed, 6 insertions(+), 6 deletions(-) - -commit 8c1fd83c6061279af00c1172fe41cee61f19d917 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Dec 27 19:22:22 2010 +0000 - - 0.16.0 NEWS - - NEWS | 24 ++++++++++++++++++++++++ - 1 file changed, 24 insertions(+) - -commit 0294d6e50691a3e40fad0d6e4fa9056944a91efd -Author: Thomas Freitag <Thomas.Freitag@alfa.de> -Date: Thu Dec 23 15:56:32 2010 +0000 - - Be more correct when drawing radial shadings - - Fixes 32349 - - poppler/Gfx.cc | 25 ++++++++++++++++--------- - 1 file changed, 16 insertions(+), 9 deletions(-) - -commit 3aa08e378927889b35b6fa858d6da568250ba6ec -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Dec 19 22:36:47 2010 +0000 - - Seems to work with this version, so enable it - - CMakeLists.txt | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 93cf184b7573980bf2e56342e64f9b99c5d0b415 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Dec 19 14:16:25 2010 +0000 - - Fix last commit - - Applying patches by hand is bad - - poppler/PDFDoc.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit ebb580d756a8321de87814f05ab572564732c15e -Author: Philip Lorenz <lorenzph+freedesktop@gmail.com> -Date: Sun Dec 19 14:08:31 2010 +0000 - - Windows fixes - - poppler/PDFDoc.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 88a4154420e016d93c5ce05b5b8e09b6bddcadc9 -Author: Philip Lorenz <lorenzph+freedesktop@gmail.com> -Date: Sun Dec 19 13:03:01 2010 +0000 - - build on newer MSVC - - qt4/src/poppler-annotation.h | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -commit 18cd9f6aeb48266c551952c395eb9cd662bc27f5 -Author: Thomas Freitag <Thomas.Freitag@alfa.de> -Date: Sat Dec 18 17:59:54 2010 +0000 - - compile in windows - - poppler/FontInfo.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 471102ef68b439dfa13e20e3b0f2e143f8d0dc85 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Dec 17 00:36:36 2010 +0000 - - Remove -resolution - - Actually use -zoom that is there for a reason - - utils/pdftohtml.1 | 3 --- - utils/pdftohtml.cc | 15 ++++++--------- - 2 files changed, 6 insertions(+), 12 deletions(-) - -commit edf6c47feb5b7658e585bcce196e465245e1dc98 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Dec 16 22:56:40 2010 +0000 - - kill useless code - - utils/pdftohtml.cc | 8 -------- - 1 file changed, 8 deletions(-) - -commit 185a2f81485e19f96393a431be5523a277747b94 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Dec 16 22:56:15 2010 +0000 - - static-ify some vars - - utils/HtmlOutputDev.cc | 9 --------- - utils/pdftohtml.cc | 8 ++++---- - 2 files changed, 4 insertions(+), 13 deletions(-) - -commit e4dfc548c57b690db9122d1db3342ed0a785c8bb -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Dec 14 19:45:46 2010 +0000 - - We need this to make the define really be defined - - config.h.cmake | 3 +++ - 1 file changed, 3 insertions(+) - -commit 06da4b46c442778c67b788b747f04b386b5247ac -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Tue Dec 14 09:06:57 2010 +1030 - - cairo: Use A1 instead of A8 for imagemask - - The cairo PDF surface now optimizes the case of cairo_mask() with - solid source and A1 mask to use a PDF stencil mask. - - Fixes https://bugs.launchpad.net/ubuntu/+source/libcairo/+bug/680628 - where a 65K PDF printed to PDF using poppler-cairo turns into an 8MB - PDF. - - CMakeLists.txt | 2 ++ - configure.ac | 1 + - poppler/CairoOutputDev.cc | 25 ++++++++++++++++++------- - 3 files changed, 21 insertions(+), 7 deletions(-) - -commit 6ef457dc818e7e241e5d2e264bc2d78b132ae638 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Dec 13 14:08:29 2010 +0000 - - Move -fno-exceptions -fno-check-new to default flags - - Makes sense since we decided not to support the exception path in - gmem a - while ago - - cmake/modules/PopplerMacros.cmake | 2 +- - configure.ac | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 86e469600b58ae05cb6ede1b4017fbdac99cc556 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Dec 13 14:04:00 2010 +0000 - - More gcc flags movement - - -Wchar-subscripts is part of -Wall so remove it - Move -fno-common to default options since it makes sense to use it - - cmake/modules/PopplerMacros.cmake | 4 ++-- - configure.ac | 4 ++-- - 2 files changed, 4 insertions(+), 4 deletions(-) - -commit 2b74241d8b1fd1ec9fab4f6f673bbaaa1cb3d949 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Dec 13 13:56:52 2010 +0000 - - Promote -Wcast-align to the general warnings we ask gcc to give - - cmake/modules/PopplerMacros.cmake | 2 +- - configure.ac | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 7313e0a4de6f2146c1dcb3d235f18a3c844d12d5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Dec 12 23:28:18 2010 +0000 - - Do not return 99 (or 1) with -h, -v and -printenc - - Bug 32149 - - utils/pdffonts.cc | 2 ++ - utils/pdfimages.cc | 2 ++ - utils/pdfinfo.cc | 3 +++ - utils/pdftoppm.cc | 2 ++ - utils/pdftops.cc | 5 ++++- - utils/pdftotext.cc | 3 +++ - 6 files changed, 16 insertions(+), 1 deletion(-) - -commit 669cbfc9fd78a22d4f14b0af43143e1f5dc28cd5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Dec 11 19:04:22 2010 +0000 - - Fix the preliminary bbox/clip calculation - - Code based in code posted by Suzuki Toshiya in the freetype mailing - list - - splash/SplashFTFont.cc | 15 +++++++++------ - 1 file changed, 9 insertions(+), 6 deletions(-) - -commit 2984002a64acca7014edeadd900dd52cdf7d9eac -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Dec 11 18:57:52 2010 +0000 - - Remove the * we just need to increase the pointer - - Gives a warning with newer gcc's - - splash/Splash.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 9b45fa072198da4a5032004ac943cf2227aa97ea -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Dec 10 12:05:58 2010 +0000 - - Make PreScanOutputDev be less agressive when deciding to rasterize - - BUG 30107 - - poppler/PreScanOutputDev.cc | 14 +++++++++++++- - poppler/PreScanOutputDev.h | 4 ++++ - 2 files changed, 17 insertions(+), 1 deletion(-) - -commit f96f6a06cdc33b4654669ac74d5abd0d546a127d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Dec 5 12:06:21 2010 +0000 - - Adapt the zlib-base FlateStream code to API changes - - Bug 32065 - - poppler/FlateStream.cc | 9 ++++++--- - poppler/FlateStream.h | 9 +++++++++ - 2 files changed, 15 insertions(+), 3 deletions(-) - -commit 7b1f83990a1f68306daf5f7dbeabcd38f4382e3b -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Nov 29 22:27:46 2010 +0000 - - 0.15.3 - - CMakeLists.txt | 4 ++-- - NEWS | 18 ++++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 6 files changed, 24 insertions(+), 6 deletions(-) - -commit 7c23a993193aaaa4d4b5b6d1161a0455d1e2a8c0 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Nov 29 21:33:31 2010 +0000 - - Add some more isNum before calling getNum - - poppler/GfxState.cc | 48 ++++++++++++++++++++++++++++++++---------------- - 1 file changed, 32 insertions(+), 16 deletions(-) - -commit 62ec4f591c258e702ee79b519919a931517220bf -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Nov 29 20:50:43 2010 +0000 - - pass fetchOriginatorNums in some more calls - - Fixes some more crashes in broken files - - poppler/Parser.cc | 7 ++++++- - poppler/Parser.h | 1 + - poppler/XRef.cc | 6 +++--- - 3 files changed, 10 insertions(+), 4 deletions(-) - -commit d2a0e2ca723142478858f7edfb7c98807d554578 -Author: Hib Eris <hib@hiberis.nl> -Date: Thu Nov 25 10:36:38 2010 +0000 - - Skip over loops in Pages tree - - poppler/Catalog.cc | 15 ++++++++++----- - 1 file changed, 10 insertions(+), 5 deletions(-) - -commit 7abd371364e6e4aaef932f26b0664f7f9d760c42 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Nov 28 13:57:50 2010 +0000 - - this var is not about xobjects only anymroe - - poppler/FontInfo.cc | 6 +++--- - poppler/FontInfo.h | 2 +- - 2 files changed, 4 insertions(+), 4 deletions(-) - -commit 1ac14df61d711097837e44d80a9332f0a854b95e -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Sun Nov 28 13:49:41 2010 +0000 - - find fonts inside patterns - - Bug 31948 - - poppler/FontInfo.cc | 50 - +++++++++++++++++++++++++++----------------------- - 1 file changed, 27 insertions(+), 23 deletions(-) - -commit d30dd8c6f6491beac9750447126930168394cd9f -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Nov 28 13:25:39 2010 +0000 - - Use sets instead of arrays - - poppler/FontInfo.cc | 46 ++++++++-------------------------------------- - poppler/FontInfo.h | 11 +++-------- - 2 files changed, 11 insertions(+), 46 deletions(-) - -commit 4c20bf14c0b1d7f1d5e530ded890186487da32b5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Nov 28 12:50:24 2010 +0000 - - Use FontInfoScanner - - No idea why we didn't do this before, duplicate code is evil and now - pdffonts doesn't crash on pdf from bug 20486 - - utils/pdffonts.cc | 185 - ++++++++---------------------------------------------- - 1 file changed, 26 insertions(+), 159 deletions(-) - -commit d915f3d5a9e9e2e5dcd6be4cf8fac1b5849a13e9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 24 21:51:46 2010 +0000 - - protect against null ref here - - poppler/Catalog.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit cf32faaa16d763561fb9dfc4469345e4b3ba2369 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 24 21:48:54 2010 +0000 - - Protect against NULL values here - - poppler/JPEG2000Stream.h | 2 ++ - 1 file changed, 2 insertions(+) - -commit 46a6cc5952c59504863baed3ad2870093c462f12 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 24 19:42:59 2010 +0000 - - Check the objects are numbers before using them - - Bug 31895 - - poppler/GfxState.cc | 26 ++++++++++++++++++-------- - 1 file changed, 18 insertions(+), 8 deletions(-) - -commit 52e25cca7e75a8b8eac95a3cec258f1cd9f8ecaa -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Nov 23 20:31:14 2010 +0000 - - If it is not a Page but has no Kids either let's just pretend it's - a page - - Fixes broken PDF at bug 31861 - - poppler/Catalog.cc | 2 +- - poppler/Dict.cc | 4 ++++ - poppler/Dict.h | 2 ++ - 3 files changed, 7 insertions(+), 1 deletion(-) - -commit c6127898b13311197971b1c6b1b306b91e28cf0e -Author: Hib Eris <hib@hiberis.nl> -Date: Mon Nov 22 13:08:48 2010 +0000 - - Use gmallocn_checkoverflow when parsing Hints table - - Prevents running out of memory with malicious documents. - - poppler/Hints.cc | 26 +++++++++++++------------- - 1 file changed, 13 insertions(+), 13 deletions(-) - -commit 6a17cc89eda52f08cbacbf9bfaaeda22cf041e82 -Author: Thomas Freitag <Thomas.Freitag@alfa.de> -Date: Mon Nov 22 19:20:56 2010 +0000 - - Improve rendering of radial shadings - - Improves the duck rendering in bug 22098 - - poppler/Gfx.cc | 71 - ++++++++++++++++++++++++++++------------------------------ - 1 file changed, 34 insertions(+), 37 deletions(-) - -commit 9093adede4f9ad6fb2962dcefcb09c1d8c357715 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Nov 21 23:49:12 2010 +0000 - - pedantic ; - - poppler/CurlPDFDocBuilder.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 61445f5af749510fb647059af01abf1faf664195 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Nov 20 22:19:35 2010 +0000 - - forgot to upadte year here - - poppler/Parser.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 3628837febb21bcd1b54f3fb737628ea59e5d95d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Nov 20 22:15:08 2010 +0000 - - And now generalize the previous fix - - Works for loops of more than one item as in bug 28784 - - poppler/Dict.cc | 4 ++-- - poppler/Dict.h | 2 +- - poppler/Object.cc | 4 ++-- - poppler/Object.h | 9 +++++---- - poppler/Parser.cc | 19 +++++++++++++------ - poppler/Parser.h | 7 ++++++- - poppler/XRef.cc | 30 +++++++++++++++++++++++++----- - poppler/XRef.h | 2 +- - 8 files changed, 55 insertions(+), 22 deletions(-) - -commit b0555189a7fbd7f6a899e582783b9e0df44d5d6a -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Nov 20 21:32:24 2010 +0000 - - Protect against more loops when parsing - - poppler/Dict.cc | 4 ++-- - poppler/Dict.h | 2 +- - poppler/Object.cc | 4 ++-- - poppler/Object.h | 8 ++++---- - poppler/Parser.cc | 2 +- - poppler/XRef.cc | 4 ++-- - poppler/XRef.h | 2 +- - 7 files changed, 13 insertions(+), 13 deletions(-) - -commit 555fa897b275ca7195f22a727b049c8c4f2d74cd -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Nov 20 19:14:38 2010 +0000 - - Detect loops in FormField creation - - poppler/Form.cc | 88 - ++++++++++++++++++++++++++++++++------------------------- - poppler/Form.h | 14 +++++---- - 2 files changed, 58 insertions(+), 44 deletions(-) - -commit 1802ddef374cb1451975480b2427e5d23ee2c737 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Nov 20 18:58:17 2010 +0000 - - Forgot to port this away from GooVector :-S - - poppler/CurlCachedFile.cc | 3 +-- - poppler/CurlCachedFile.h | 2 +- - 2 files changed, 2 insertions(+), 3 deletions(-) - -commit 32e53c5436b8c3654e7043f1d86596a79511a4cf -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Nov 20 18:54:59 2010 +0000 - - fix spacing - - poppler/Form.cc | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit 1cb3d5d94a1d89ccded96d977bcabfbe438fb81f -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Nov 20 18:08:45 2010 +0000 - - fix the memset - - Fixes crash in broken pdf - - poppler/Hints.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 22e8cebaa15adb4b19c9556cdca43cc3e77832b7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Nov 20 17:20:34 2010 +0000 - - Ensure the obj are num before reading them - - poppler/GfxState.cc | 32 ++++++++++++++++++++++---------- - 1 file changed, 22 insertions(+), 10 deletions(-) - -commit 08b2db36db4e011ebe36d2d945cb1a0498f1c5fb -Author: Pino Toscano <pino@kde.org> -Date: Sat Nov 20 14:00:36 2010 +0100 - - add my copyright here - - poppler/Hints.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 91aa4b02aa93ffe3828479194067de42d52be465 -Author: Pino Toscano <pino@kde.org> -Date: Sat Nov 20 13:13:46 2010 +0100 - - [cpp] include <ios> for std::hex() and std::left() - - cpp/poppler-global.cpp | 1 + - cpp/tests/poppler-dump.cpp | 1 + - 2 files changed, 2 insertions(+) - -commit 1c924412923cb01f2cb95b0943cb7bbaf7e8cfb6 -Author: Pino Toscano <pino@kde.org> -Date: Sat Nov 20 13:02:36 2010 +0100 - - [cpp] include <iterator> for std::back_inserter() - - cpp/poppler-document.cpp | 1 + - 1 file changed, 1 insertion(+) - -commit 95b551025a34f3a7bcff2852eac6d186bc8a7cb0 -Author: Pino Toscano <pino@kde.org> -Date: Sat Nov 20 12:54:21 2010 +0100 - - use a std::vector<char> instead of a var-length-array of char's - - poppler/Hints.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 4faaff893515c80cb69b02e431a0f8483274a497 -Author: Hib Eris <hib@hiberis.nl> -Date: Fri Nov 19 23:53:35 2010 +0000 - - [win32] Simplify strtok_r implementation - - The previous implementation did not compile with mingw64. - - poppler/strtok_r.cpp | 137 - +-------------------------------------------------- - 1 file changed, 1 insertion(+), 136 deletions(-) - -commit 255f84927a649d980f047fe755c9c308535a3779 -Author: Hib Eris <hib@hiberis.nl> -Date: Fri Nov 19 23:45:33 2010 +0000 - - Correct parsing of linearization table - - Fixes bug #31627 - - poppler/Linearization.cc | 4 +--- - 1 file changed, 1 insertion(+), 3 deletions(-) - -commit 9d05138f0b7d15945f546564036bc67815593db0 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Nov 14 16:05:28 2010 +0000 - - 0.15.2 - - CMakeLists.txt | 4 ++-- - NEWS | 22 ++++++++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 6 files changed, 28 insertions(+), 6 deletions(-) - -commit 2d18543bd6b3a5a9ff2dfab63339d5bfcccd0b2f -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Nov 14 15:41:56 2010 +0000 - - This does actually work now :D - - qt4/tests/check_metadata.cpp | 1 - - 1 file changed, 1 deletion(-) - -commit d772364b8a5858cbd98e256547d319260fa9d084 -Author: Pino Toscano <pino@kde.org> -Date: Thu Nov 11 21:52:25 2010 +0100 - - [Qt4] New function setDebugErrorFunction(). - - This new function + typedef can be useful to direct the ebug/error - messages - to a different place than the default qDebug()'s one. - - Base on an idea of Albert, added closure and polish by me. - - qt4/src/poppler-private.cc | 20 +++++++++++++++++++- - qt4/src/poppler-qt4.h | 24 ++++++++++++++++++++++++ - 2 files changed, 43 insertions(+), 1 deletion(-) - -commit ce929cf33f4b6b6421f9d327b4bb792816d47aac -Author: Jakob Voss <jakob.voss@gbv.de> -Date: Wed Nov 10 23:41:44 2010 +0000 - - Add -p flag to pdfimages - - Adds the page the image is in to the image filename - - utils/ImageOutputDev.cc | 25 ++++++++++++++++++------- - utils/ImageOutputDev.h | 19 +++++++++++++++---- - utils/pdfimages.1 | 3 +++ - utils/pdfimages.cc | 6 +++++- - 4 files changed, 41 insertions(+), 12 deletions(-) - -commit 6296c28968613aadb7ea084092945a54005eca9b -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 10 23:28:45 2010 +0000 - - Kill GooVector - - std::vector does the same and GooVector is not part of xpdf so - we don't - need to maintain it in case we ever get a new xpdf release we want to - merge with - - CMakeLists.txt | 1 - - goo/GooVector.h | 159 - --------------------------------------------- - goo/Makefile.am | 1 - - poppler/CachedFile.cc | 19 +++--- - poppler/CachedFile.h | 15 +++-- - poppler/Catalog.cc | 12 ++-- - poppler/Catalog.h | 10 +-- - poppler/Form.h | 3 +- - poppler/Gfx.h | 7 +- - poppler/Hints.cc | 5 +- - poppler/Hints.h | 6 +- - poppler/StdinCachedFile.cc | 2 +- - poppler/StdinCachedFile.h | 2 +- - poppler/Stream.h | 1 - - poppler/XRef.cc | 10 +-- - poppler/XRef.h | 7 +- - utils/HtmlFonts.cc | 8 +-- - utils/HtmlFonts.h | 12 ++-- - utils/HtmlLinks.cc | 8 +-- - utils/HtmlLinks.h | 4 +- - 20 files changed, 66 insertions(+), 226 deletions(-) - -commit 5934c320aa136c1a6e97fb9bf54bdfdccfcab521 -Author: Hib Eris <hib@hiberis.nl> -Date: Wed Nov 10 22:50:36 2010 +0000 - - Linearization improvements - - Read - http://lists.freedesktop.org/archives/poppler/2010-November/006642.html - for the detailed patch description - - CMakeLists.txt | 4 + - glib/poppler-action.cc | 4 +- - glib/poppler-document.cc | 17 +- - glib/poppler-page.cc | 1 + - poppler/CachedFile.h | 2 +- - poppler/Catalog.cc | 352 +++++++++++++++++++++----------- - poppler/Catalog.h | 14 +- - poppler/FontInfo.cc | 5 +- - poppler/Hints.cc | 439 - ++++++++++++++++++++++++++++++++++++++++ - poppler/Hints.h | 95 +++++++++ - poppler/Linearization.cc | 224 ++++++++++++++++++++ - poppler/Linearization.h | 45 ++++ - poppler/Makefile.am | 4 + - poppler/PDFDoc.cc | 284 ++++++++++++++++++++++---- - poppler/PDFDoc.h | 38 +++- - poppler/PSOutputDev.cc | 39 ++-- - poppler/PSOutputDev.h | 14 +- - poppler/Stream.cc | 13 +- - poppler/Stream.h | 11 +- - poppler/XRef.cc | 351 +++++++++++++++++++------------- - poppler/XRef.h | 25 ++- - qt/poppler-document.cc | 14 +- - qt/poppler-page.cc | 19 +- - qt/poppler-private.h | 14 +- - qt/poppler-qt.h | 3 +- - qt4/src/poppler-document.cc | 12 +- - qt4/src/poppler-link.cc | 7 +- - qt4/src/poppler-page.cc | 3 +- - qt4/src/poppler-ps-converter.cc | 2 + - utils/HtmlOutputDev.cc | 2 +- - utils/HtmlOutputDev.h | 3 + - utils/pdffonts.cc | 6 +- - utils/pdfinfo.cc | 22 +- - utils/pdftohtml.cc | 2 +- - utils/pdftops.cc | 3 +- - 35 files changed, 1690 insertions(+), 403 deletions(-) - -commit abb1313ae40ab7efb073406f47fa53bf7afe0b88 -Author: Pino Toscano <pino@kde.org> -Date: Mon Nov 8 01:54:03 2010 +0100 - - [cpp/apidox] add the minimum version of 'image' - - cpp/poppler-image.cpp | 2 ++ - 1 file changed, 2 insertions(+) - -commit f559e77cb7d76c5fe6a79be9086667a29613c912 -Author: Pino Toscano <pino@kde.org> -Date: Mon Nov 8 01:52:48 2010 +0100 - - [cpp] add image::bytes_per_row() - - cpp/poppler-image.cpp | 8 ++++++++ - cpp/poppler-image.h | 1 + - 2 files changed, 9 insertions(+) - -commit 14dea4d74698d5d7d994e687f8176652d790dba7 -Author: Pino Toscano <pino@kde.org> -Date: Sun Nov 7 22:57:31 2010 +0100 - - [arthur] use the untransformed line width, not the transformed one - - ... as the painter will do the transformation itself already; - seems to product better results - - poppler/ArthurOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit f077e82af0724be88d28c896a3c208f1d50ccff9 -Author: Pino Toscano <pino@kde.org> -Date: Sun Nov 7 21:50:48 2010 +0100 - - [qt4] New Page::renderToPainter() - - This new painter-based painting function ican be used for painting - (with Arthur only for now) without getting an image first. - Also add a new flag type for it, with a single item telling whether - do not save+restore the provided painter. - - Mostly based on a patch by Matthias Fauconneau - (matthias.fauconneau@gmail.com), thanks! - - qt4/src/poppler-page.cc | 62 - +++++++++++++++++++++++++++++++--------------- - qt4/src/poppler-qt4.h | 65 - ++++++++++++++++++++++++++++++++++++++++++++++++- - 2 files changed, 107 insertions(+), 20 deletions(-) - -commit df02d1fc9e65422121e5e8f493c13229552ec0e7 -Author: Pino Toscano <pino@kde.org> -Date: Sun Nov 7 19:47:56 2010 +0100 - - [arthur] remove unused 'm_image' attribute - - poppler/ArthurOutputDev.cc | 1 - - poppler/ArthurOutputDev.h | 2 +- - 2 files changed, 1 insertion(+), 2 deletions(-) - -commit b29582cd0d542a3e70dbca3fb75770daa4cc91ca -Author: Matthias Fauconneau <matthias.fauconneau@gmail.com> -Date: Sun Nov 7 19:44:11 2010 +0100 - - [arthur] small fixes and memory leaks - - - fix font rendering (transforming the glyph path and not only the - glyph origin) - - fix image rendering (alpha was set to zero) - - poppler/ArthurOutputDev.cc | 122 - ++++++++++++++++++++------------------------- - 1 file changed, 54 insertions(+), 68 deletions(-) - -commit 970f075569bf9be5e5ddc3a9ad1fabec5435dfaf -Author: Pino Toscano <pino@kde.org> -Date: Sun Nov 7 16:31:02 2010 +0100 - - [cpp/tests] add a simple poppler-render test - - ... to ease testing the render capabilities of poppler-cpp. - quite minimal at the moment. - - cpp/tests/CMakeLists.txt | 3 ++ - cpp/tests/Makefile.am | 9 +++- - cpp/tests/poppler-render.cpp | 113 - +++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 124 insertions(+), 1 deletion(-) - -commit bfe4139c742cb0a669f5504df7e22e3e57243d9a -Author: Pino Toscano <pino@kde.org> -Date: Sun Nov 7 16:23:26 2010 +0100 - - [cpp] Add page_renderer, to render pages over images. - - This new class introduces a very simple way to render a page, using - the Splash backend, - giving an 'image' as result. - It can hold a color for the "paper" of the pages, and some hints - for the actual rendering. - - cpp/CMakeLists.txt | 2 + - cpp/Makefile.am | 2 + - cpp/poppler-page-renderer.cpp | 212 - ++++++++++++++++++++++++++++++++++++++++++ - cpp/poppler-page-renderer.h | 66 +++++++++++++ - 4 files changed, 282 insertions(+) - -commit 91e3f7b4ea42a5821fd78e1edf55e95250c9bc68 -Author: Pino Toscano <pino@kde.org> -Date: Sun Nov 7 16:19:34 2010 +0100 - - [cpp] add an internal way to get a 'page_private' of a 'page' - - useful for getting a 'page_private' in the implementation of other - cpp classes - without the need to add friends to 'page' - - cpp/poppler-page-private.h | 5 +++++ - 1 file changed, 5 insertions(+) - -commit fa7c41cb9c52ecd3d7c574455b1258a3021b8c75 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Nov 4 20:55:34 2010 +0000 - - Improvements to the splash backend - - Antialias and shadings. - Code by Thomas Freitag <Thomas.Freitag@alfa.de> and Christian - Feuersänger <cfeuersaenger@googlemail.com> - More info at bug 30436 - - poppler/CairoOutputDev.h | 5 +- - poppler/Function.cc | 4 +- - poppler/Function.h | 2 + - poppler/Gfx.cc | 12 +- - poppler/OutputDev.h | 16 +- - poppler/PSOutputDev.h | 4 +- - poppler/SplashOutputDev.cc | 182 ++++++++++++++++++++- - poppler/SplashOutputDev.h | 68 +++++++- - splash/Splash.cc | 395 - ++++++++++++++++++++++++++++++++++++++++++++- - splash/Splash.h | 11 +- - splash/SplashBitmap.cc | 4 +- - splash/SplashBitmap.h | 3 + - splash/SplashPattern.cc | 17 +- - splash/SplashPattern.h | 36 ++++- - 14 files changed, 735 insertions(+), 24 deletions(-) - -commit 0aa040163741ab8ba093a742e556bba2a5ab7edf -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 3 20:40:24 2010 +0000 - - Do not add sibling children as parents - - Fixes c2ff94b1600b8a5841a5e4627f014560ac460f1a - - poppler/Function.cc | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -commit c2ff94b1600b8a5841a5e4627f014560ac460f1a -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 3 00:02:02 2010 +0000 - - Do not loop forever in broken documents - - StitchingFunctions that have themselves up in the parent chain - are wrong - - poppler/Function.cc | 22 +++++++++++++++++++--- - poppler/Function.h | 6 ++++-- - 2 files changed, 23 insertions(+), 5 deletions(-) - -commit cad66a7d25abdb6aa15f3aa94a35737b119b2659 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Nov 2 19:14:34 2010 +0000 - - Fix crash in broken documents - - mapLen = (code + 256) & ~255; can wrap and you end up with mapLen - < code - that is not what you wanted - - poppler/CharCodeToUnicode.cc | 16 +++++++++++----- - 1 file changed, 11 insertions(+), 5 deletions(-) - -commit 7e5f31c1c41193c6e49355970e6d027b91d45825 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Nov 2 00:32:01 2010 +0000 - - make some more fields private - - splash/SplashFontFile.h | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 6751eb48dc49890f7ad8b732b3fc29a2db746ec4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Nov 2 00:26:08 2010 +0000 - - Make the destructor private - - You are not supposed to call it, you should call unref - - splash/SplashFontFile.h | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit b718e821d5f21ea5b0c44c6c2b59769c9b94892a -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Oct 28 08:46:09 2010 +0100 - - Revert fdfffc9c68314d3f64dee7e0ef8617105e3198dd - - It is not a leak and makes things crash :D - - poppler/SplashOutputDev.cc | 1 - - 1 file changed, 1 deletion(-) - -commit 15b9aeac5a20c544db1aebe00113ebc2f7ba52c7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Oct 28 00:37:29 2010 +0100 - - if reallocn fails, free p - - goo/gmem.cc | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -commit 561c0567a5741d7c49903c51c8020187dccaa0d9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Oct 27 22:43:51 2010 +0100 - - fix comment - - poppler/SplashOutputDev.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 4ef38cc99a879202e717447a422272cf85eeccfc -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Oct 27 22:36:07 2010 +0100 - - Fix memory leaks that can happen with broken documents - - poppler/SplashOutputDev.cc | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -commit fdfffc9c68314d3f64dee7e0ef8617105e3198dd -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Oct 27 20:40:19 2010 +0100 - - Fix memory leak - - poppler/SplashOutputDev.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 90d479d9d5c947175e60ab689f440ae9c24f0b2b -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Oct 27 20:39:48 2010 +0100 - - Do not crash if bitmap->alpha == NULL - - Happens in broken files - - splash/Splash.cc | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit 6ad36277971ec46d4a4ef0c45625e60f8c5f1247 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Oct 25 18:59:49 2010 +0100 - - Initialze movie to NULL on broken pdf files - - poppler/Annot.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 2d0b6e2956a81164bca6adc9aacad0e620480957 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Oct 24 00:23:21 2010 +0100 - - Here the chars to read is the increment size not the initialSize - - Fixes crash in file provided by Robert Święcki - - poppler/Stream.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit dcb02d2100136b6035485be3be214ce3d9f1c102 -Author: Vincent Torri <vtorri@univ-evry.fr> -Date: Sat Oct 23 23:45:05 2010 +0100 - - remove -ansi flag for cywin and mingw - - configure.ac | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -commit 17cdc81224c72f7b58de61734c9ead337ff7b42b -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 23 23:37:59 2010 +0100 - - update my C year - - poppler/SplashOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit e09ddce7e21bbd62b384d9d59fbd1e0f14f7d05f -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 23 23:33:00 2010 +0100 - - Fix crash in malformed documents - - poppler/SplashOutputDev.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 906e4e15421d8f3f0a825ca767e5eac3169853d6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 23 23:12:44 2010 +0100 - - Do not leak attrs1 - - poppler/Catalog.cc | 1 + - 1 file changed, 1 insertion(+) - -commit ec32bb45a57a8a839156c946fcde1270aa6019d9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 23 23:00:03 2010 +0100 - - Do not crash if n is 0 - - poppler/Function.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 9edf7e4fefb37989af9a2558aaa83d7cd4694ec6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 23 22:59:50 2010 +0100 - - add unlikely marker - - poppler/Decrypt.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit c46e863b7b94dc2f83a7d89f4afb8fe3bc8ec35c -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 23 22:55:49 2010 +0100 - - Do not divide by 0 in rc4InitKey - - poppler/Decrypt.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit bcb13ed5828e2a855efd5e38b2acd15ca37a9991 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 23 22:40:17 2010 +0100 - - Check obj2 is a num before reading it - - poppler/Gfx.cc | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -commit c64a49307782299cb7a950a66419f9d59707f38b -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Oct 20 22:29:29 2010 +0100 - - 0.15.1 - - CMakeLists.txt | 4 ++-- - NEWS | 46 ++++++++++++++++++++++++++++++++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 6 files changed, 52 insertions(+), 6 deletions(-) - -commit 3b45c66de91243d7419657512cf726c9e1c26dfb -Author: Kenneth Berland <ken@hero.com> -Date: Sun Oct 17 14:24:16 2010 +0100 - - Add -bbox option to pdftotext - - utils/pdftotext.1 | 4 ++ - utils/pdftotext.cc | 125 - ++++++++++++++++++++++++++++++++++++++++++----------- - 2 files changed, 103 insertions(+), 26 deletions(-) - -commit 71ec4c7a6715a40d536d1e4b911dae48d1bba7b9 -Author: Pino Toscano <pino@kde.org> -Date: Sun Oct 17 14:57:43 2010 +0200 - - [CMake] update MacroOptionalFindPackage.cmake from KDE SVN - - no radical changes, just a minor improvement for the "explicitly - disabled" case - - cmake/modules/MacroOptionalFindPackage.cmake | 40 - +++++++++++++++++++++------- - 1 file changed, 30 insertions(+), 10 deletions(-) - -commit ab0049d8be5dfe1989c4aa33c2732915c62fecb2 -Author: Pino Toscano <pino@kde.org> -Date: Sun Oct 17 14:29:22 2010 +0200 - - [CMake] Cairo package: make the version check really working - - cmake/modules/FindCairo.cmake | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit 1cea33717c92631ee9c417d9f89e32b03695c75a -Author: Pino Toscano <pino@kde.org> -Date: Sun Oct 17 13:55:58 2010 +0200 - - [CMake] Bump cairo dependency to 1.10 - - followup of fc9b85894754d175af916eaf6cb127efd601df7e - - CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit d6f49aa2da15cd2e9cf775d6b1d2d04a005c8cdd -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Oct 17 14:22:57 2010 +0200 - - [cairo] Fix a crash when redering documents with invalid type 3 fonts - - poppler/CairoFontEngine.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit e2fad550c3cbf86541730582151e1bb6470ed9c1 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Oct 17 13:47:33 2010 +0200 - - [glib-demo] Use poppler_page_get_selected_region() in selections demo - - glib/demo/selections.c | 73 - +++++++++++++++----------------------------------- - 1 file changed, 22 insertions(+), 51 deletions(-) - -commit 88013458e141de58ed801480707ae0dfe92b9aa2 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Oct 17 13:46:26 2010 +0200 - - [glib] Add poppler_page_get_selected_region() - - that returns a cairo_region_t, and deprecate - poppler_page_get_selection_region(). - - glib/poppler-page.cc | 81 - +++++++++++++++++++++++++++++++++++++ - glib/poppler-page.h | 4 ++ - glib/reference/poppler-sections.txt | 1 + - 3 files changed, 86 insertions(+) - -commit fc9b85894754d175af916eaf6cb127efd601df7e -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Oct 17 12:54:18 2010 +0200 - - [configure] Bump cairo dependency to 1.10 - - configure.ac | 2 +- - poppler/CairoOutputDev.cc | 4 ---- - 2 files changed, 1 insertion(+), 5 deletions(-) - -commit dd14ef6b211ac1c8a4f16bb6094dbfd6a09cbef9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Oct 17 12:46:55 2010 +0100 - - Improve dict lookup speed for big dicts - - Based on a patch by Paweł Wiejacha <pawel.wiejacha@gmail.com> - - poppler/Dict.cc | 98 - +++++++++++++++++++++++++++++++++++++++++++++------------ - poppler/Dict.h | 2 ++ - 2 files changed, 80 insertions(+), 20 deletions(-) - -commit bb38a0c71434413f2728109c73278de1b8a58571 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Oct 17 12:52:01 2010 +0200 - - [glib-demo] Make glib demo program installable - - It's a useful tool for testing and debugging not only for people who - install from sources. - - glib/demo/Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit d26d0fab2ddfff853f6681a3518813a2d65a4112 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Oct 17 12:36:46 2010 +0200 - - [glib-demo] Use printing options in print demo - - glib/demo/print.c | 96 - +++++++++++++++++++++++++++++++++++++++++++++++++++++-- - 1 file changed, 93 insertions(+), 3 deletions(-) - -commit 4a71dcdd350d0c0515ca349f0b875b33289d25ee -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Oct 17 12:31:41 2010 +0200 - - [glib] Add poppler_page_render_for_printing_with_options() - - It allows to print with the same options acroread has: - - - Print document - - Print document and markup - - Print document and stamps - - glib/poppler-page.cc | 77 - ++++++++++++++++++++++++++++++++----- - glib/poppler-page.h | 3 ++ - glib/poppler.h | 19 +++++++++ - glib/reference/poppler-sections.txt | 4 ++ - 4 files changed, 94 insertions(+), 9 deletions(-) - -commit 0b3b2ebc3930bd46fb13fb2158fc695b0962f7c5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 16 15:09:05 2010 +0100 - - Add a callback to know which page has been printed - - qt4/src/poppler-ps-converter.cc | 16 ++++++++++++++-- - qt4/src/poppler-qt4.h | 10 ++++++++++ - 2 files changed, 24 insertions(+), 2 deletions(-) - -commit 4bd25223c4d15dfa91965a6e86eaa444a5a81f71 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 16 15:08:05 2010 +0100 - - Do not omit this character - - Mimics Cairo backend and Adode Reader behaviour - - splash/SplashFTFont.cc | 4 ---- - 1 file changed, 4 deletions(-) - -commit b604a008a2a379a21e5fdfa0799886f80d893a08 -Author: Christian Feuersänger <cfeuersaenger@googlemail.com> -Date: Thu Oct 14 23:56:36 2010 +0100 - - Improve rendering of Shading Type 6 and 7 - - poppler/Gfx.cc | 214 - +++++++++++++++++++++++++++++++++++++++++----------- - poppler/Gfx.h | 9 ++- - poppler/GfxState.cc | 96 ++++++++++++++++++++++- - poppler/GfxState.h | 127 ++++++++++++++++++++++++++++++- - 4 files changed, 398 insertions(+), 48 deletions(-) - -commit c6bb63b31c268e4e842532e6839b15edb31cf25c -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Oct 14 23:33:13 2010 +0100 - - Only clip boxes to mediabox if we are at the page level - - Fixes bug 30784 - - poppler/Page.cc | 19 +++++++++++-------- - 1 file changed, 11 insertions(+), 8 deletions(-) - -commit 4a248b3f523209ec16ace587229412653b2276d0 -Author: Pino Toscano <pino@kde.org> -Date: Thu Oct 14 18:32:05 2010 +0200 - - [cpp] make it compile also when there are no image formats available - - including the ImgWirter.h is enough to get the definition of ImgWriter - - cpp/poppler-image.cpp | 1 + - 1 file changed, 1 insertion(+) - -commit de1501d87549269f9214c9e3fba4cbf39960826e -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Oct 13 19:18:36 2010 +0100 - - remove windows eol - - poppler/Gfx.cc | 38 +++++++++++++++++++------------------- - 1 file changed, 19 insertions(+), 19 deletions(-) - -commit 12e68b49feef10b654944dd71eab0852cfeceb89 -Author: Pino Toscano <pino@kde.org> -Date: Sun Oct 10 23:04:57 2010 +0200 - - [cpp] Add a new 'image' class. - - This implicitely shared class represents the data buffer of an - "image", - with direct access to the data. - It also has a function to save to file (png/jpeg). - - Still a FIXME in the copy() method and in the save() (for mono - images only). - - cpp/CMakeLists.txt | 2 + - cpp/Makefile.am | 3 + - cpp/poppler-image-private.h | 48 +++++ - cpp/poppler-image.cpp | 431 - ++++++++++++++++++++++++++++++++++++++++++++ - cpp/poppler-image.h | 70 +++++++ - 5 files changed, 554 insertions(+) - -commit db31687ba476e272b72625a8a78b50780522ee7d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Oct 9 10:33:06 2010 +0200 - - [glib] docs: Document poppler_annot_markup_get_date() - - glib/poppler-annot.cc | 9 +++++++++ - 1 file changed, 9 insertions(+) - -commit a7cf8d322a4a687c9810a577cc92ff6b9725ecdc -Author: Fernando Herrera <fherrera@onirica.com> -Date: Thu Oct 7 17:28:31 2010 +0200 - - [glib] Fix introspection annotations for poppler_document_get_page*() - - Return value should be transfer full since the caller owns the only - reference. - - glib/poppler-document.cc | 6 ++---- - 1 file changed, 2 insertions(+), 4 deletions(-) - -commit d690bea929553d1a4392d42d949843e9467ba8cb -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Oct 5 22:18:22 2010 +0100 - - Make sure obj is a num before reading it - - Not sure if using a 0 is correct otherwise, but if your matrix is - broken you're probably going to get a wrong rendering anyway, so who - cares. Bug #30590 - - poppler/Gfx.cc | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit b17be2bc32cf71bac0473bf4ac16359e3027b4fc -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Oct 3 12:14:11 2010 +0200 - - [annots] Fix a crash when drawing square/circle annots without - a border - - Fixes bug #30580 - - poppler/Annot.cc | 121 - ++++++++++++++++++++++++++++--------------------------- - 1 file changed, 61 insertions(+), 60 deletions(-) - -commit e3d3944c1988343704e3ba3a5d60609719466afb -Author: Tomas Hoger <thoger@redhat.com> -Date: Wed Sep 29 20:03:45 2010 +0100 - - Fix uninitialized uses on DCTScanInfo - - poppler/Stream.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit f380647f09d88339c936184bbe86c70c0d47de4b -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 29 20:02:10 2010 +0100 - - Free names - - poppler/Catalog.cc | 1 + - 1 file changed, 1 insertion(+) - -commit aa0fd32a8501473832bce1b8b804dd3f9a45735b -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 27 22:39:09 2010 +0100 - - Consider render value when colorizing text - - Fixes bug 2807 - - poppler/CairoOutputDev.cc | 18 +++--------------- - poppler/CairoOutputDev.h | 2 -- - poppler/Gfx.cc | 21 +++++++++++++++++---- - poppler/PSOutputDev.cc | 26 ++++++++++---------------- - poppler/PSOutputDev.h | 3 +-- - poppler/SplashOutputDev.cc | 18 +++--------------- - poppler/SplashOutputDev.h | 4 +--- - 7 files changed, 35 insertions(+), 57 deletions(-) - -commit cf710b999b510203e9348ea9f04360be1fe957b8 -Author: Pino Toscano <pino@kde.org> -Date: Fri Sep 24 00:50:37 2010 +0200 - - [Qt4] enable the generation of the QCH file - - ... usable in Qt Assistant - - qt4/src/Doxyfile | 14 +++++++------- - 1 file changed, 7 insertions(+), 7 deletions(-) - -commit be6d933071c9ab043f01f374a884472c4ce3007e -Author: Pino Toscano <pino@kde.org> -Date: Thu Sep 23 15:55:45 2010 +0200 - - update Doxyfile's for qt4 and cpp - - no changes in the actual configuration values - - cpp/Doxyfile | 155 ++++-- - qt4/src/Doxyfile | 1469 - +++++++++++++++++++++++++++++++++--------------------- - 2 files changed, 1018 insertions(+), 606 deletions(-) - -commit 721da3d542ab9b234b058f3c14ea9303d748107e -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Sep 23 14:09:11 2010 +0200 - - [glib] Use g_memdup instead of g_strdup in poppler_document_get_id() - - Ids are not null-terminated strings, but fixed size byte arrays. - - glib/demo/info.cc | 8 ++++++-- - glib/poppler-document.cc | 33 ++++++++++++++------------------- - 2 files changed, 20 insertions(+), 21 deletions(-) - -commit 4ffc0ed73397e4e58f04c3577b093a3fd39c22bd -Author: Pino Toscano <pino@kde.org> -Date: Thu Sep 23 02:21:12 2010 +0200 - - [cpp] small clarification in document::load_from_data() apidox - - cpp/poppler-document.cpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 9491dc4a10706109d0f2b4d15f21b9a1db51d8c9 -Author: Pino Toscano <pino@kde.org> -Date: Thu Sep 23 02:18:07 2010 +0200 - - [cpp] add document::load_from_raw_data() - - ... to be able to load a document from an external data buffer, - with no need to copy the data. - - add as well a new document_private constructor to handle the new - situation, - and make sure to properly use the raw data when unlocking the document - - cpp/poppler-document-private.h | 5 ++++ - cpp/poppler-document.cpp | 53 - ++++++++++++++++++++++++++++++++++++++++++ - cpp/poppler-document.h | 4 ++++ - 3 files changed, 62 insertions(+) - -commit a3c1f2d5ea1de969e9aaaa84ee38866938b4ce0c -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 22 20:14:27 2010 +0100 - - fix copyright - - poppler/Form.cc | 1 + - poppler/Form.h | 1 + - 2 files changed, 2 insertions(+) - -commit 1aad013e353a9e59bdab8a1b4ce93f2ad7aaf4f2 -Author: Pino Toscano <pino@kde.org> -Date: Wed Sep 22 17:07:38 2010 +0200 - - update copyrights - - cpp/poppler-document.h | 2 +- - cpp/poppler-page-transition.cpp | 2 +- - cpp/poppler-private.cpp | 2 +- - cpp/poppler-rectangle.cpp | 2 +- - 4 files changed, 4 insertions(+), 4 deletions(-) - -commit 2d6d66ebe0215df66e33cb5974c58c324fab50b6 -Author: Pino Toscano <pino@kde.org> -Date: Wed Sep 22 17:07:13 2010 +0200 - - [cpp/tests] poppler-dump: show the PDF IDs, if available - - cpp/tests/poppler-dump.cpp | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit e39fde1b62544b90e73a2fc3609a260991db3a47 -Author: Pino Toscano <pino@kde.org> -Date: Wed Sep 22 16:52:08 2010 +0200 - - [cpp] add document::get_pdf_id() - - ... to get the IDs of a PDF document, if present. - - cpp/poppler-document.cpp | 29 +++++++++++++++++++++++++++++ - cpp/poppler-document.h | 1 + - 2 files changed, 30 insertions(+) - -commit 299a1849a148fa0a7b3171c45ec68b9901aa93bb -Author: Pino Toscano <pino@kde.org> -Date: Wed Sep 22 16:36:30 2010 +0200 - - [Qt4] add Document::getPdfId() - - ... to get the IDs of a PDF document, if present. - - also, add two test cases for it in the metadata unit test - - qt4/src/poppler-document.cc | 16 ++++++++++++++ - qt4/src/poppler-qt4.h | 14 +++++++++++++ - qt4/tests/check_metadata.cpp | 50 - ++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 80 insertions(+) - -commit dd9bcdb720ac1bf8a022635bcbb3b56e4b75bb15 -Author: Pino Toscano <pino@kde.org> -Date: Wed Sep 22 16:29:46 2010 +0200 - - Make the internal get_id() not fail because of null bytes in the ID. - - Passing the const char* of the byte string to convert is not enough - if its length must be checked, - as it might fail when the string of the ID contains null bytes. - Instead, pass the original GooString so its size is properly checked. - - Also, remove an hardcoded 16 and make it dependent on pdfIdLength, - as used elsewhere in get_id() function. - - poppler/PDFDoc.cc | 11 ++++++----- - 1 file changed, 6 insertions(+), 5 deletions(-) - -commit 9554cbc3cb4fc0cd7ad2295f5d27a18e030c6aee -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Sep 22 12:54:25 2010 +0200 - - [glib-demo] Show form field names in forms demo - - glib/demo/forms.c | 26 ++++++++++++++++++++------ - 1 file changed, 20 insertions(+), 6 deletions(-) - -commit 257634b26b682628dba5ee5f94cb0bad030bcb4f -Author: Mark Riedesel <mark@klowner.com> -Date: Wed Sep 22 12:52:49 2010 +0200 - - [glib] Add methods to get mapping, partial an fully qualified form - field names - - See bug #28780. - - glib/poppler-form-field.cc | 68 - +++++++++++++++++++++++++++++++++++++ - glib/poppler-form-field.h | 3 ++ - glib/reference/poppler-sections.txt | 3 ++ - 3 files changed, 74 insertions(+) - -commit 6db98abc59c154dcb18d69fc37e44ce804c3ccc9 -Author: Mark Riedesel <mark@klowner.com> -Date: Wed Sep 22 12:41:16 2010 +0200 - - Add getLabel method to FormWidget - - See bug #28780. - - poppler/Form.cc | 64 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Form.h | 8 ++++++++ - 2 files changed, 72 insertions(+) - -commit bcdca66fd57439735e0b9aa182ab7cfce29e9ed0 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Sep 21 11:49:37 2010 +0200 - - [glib] Fix minimum value of creation and modification date properties - - It should be -1 which means there's no date specified - - glib/poppler-document.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit d2578bd66129466b2dd114b6407c147598e09d2b -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 21 19:19:27 2010 +0100 - - Avoid loops in Form::fieldLookup - - Fixes crash in broken pdf provided by Joel Voss of Leviathan - Security Group - - poppler/Dict.h | 3 +++ - poppler/Form.cc | 27 ++++++++++++++++++++++++--- - 2 files changed, 27 insertions(+), 3 deletions(-) - -commit 2fe825deac055be82b220d0127169cb3d61387a8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 21 19:15:25 2010 +0100 - - Make sure obj1 is a num before reading it - - Fixes crash in broken pdf provided by Joel Voss of Leviathan - Security Group - - poppler/Gfx.cc | 20 ++++++++++++++++---- - 1 file changed, 16 insertions(+), 4 deletions(-) - -commit 473de6f88a055bb03470b4af5fa584be8cb5fda4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 21 19:11:42 2010 +0100 - - Fix memory leak if obj2 is not a dict - - Found thanks to PDF provided by Joel Voss of Leviathan Security Group - - poppler/Form.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 9706e28657ff7ea52aa69d9efb3f91d0cfaee70b -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 21 19:09:37 2010 +0100 - - Fix crash when idx is out of range - - Found thanks to PDF provided by Joel Voss of Leviathan Security Group - - poppler/Function.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 26a5817ffec9f05ac63db6c5cd5b1f0871d271c7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 21 19:08:54 2010 +0100 - - Fix crash when idx is out of range - - Fixes crash in broken pdf provided by Joel Voss of Leviathan - Security Group - - poppler/Function.cc | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -commit dfdf3602bde47d1be7788a44722c258bfa0c6d6e -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 21 19:07:12 2010 +0100 - - Give a value to color.c[i] - - Might not be the better solution but it's better than having a random - value there - - Found thanks to PDF provided by Joel Voss of Leviathan Security Group - - poppler/Gfx.cc | 8 ++++++++ - 1 file changed, 8 insertions(+) - -commit 01c85c08305bae16242f5979ab107fa5bb5f5100 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 21 19:04:37 2010 +0100 - - Forgot my (C) here - - poppler/Decrypt.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit bf2055088a3a2d3bb3d3c37d464954ec1a25771f -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 21 19:03:19 2010 +0100 - - Properly initialize stack - - Fixes crash in broken pdf provided by Joel Voss of Leviathan - Security Group - - poppler/Function.cc | 1 + - 1 file changed, 1 insertion(+) - -commit e853106b58d6b4b0467dbd6436c9bb1cfbd372cf -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 21 19:01:36 2010 +0100 - - Properly initialize parser - - Fixes crash in broken pdf provided by Joel Voss of Leviathan - Security Group - - poppler/Gfx.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 3422638b2a39cbdd33a114a7d7debc0a5f688501 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 21 18:58:43 2010 +0100 - - Fix crash in broken pdf (parser->getStream() is 0) - - Found thanks to PDF provided by Joel Voss of Leviathan Security Group - - poppler/Gfx.cc | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -commit a2dab0238a69240dad08eca2083110b52ce488b7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 21 18:55:51 2010 +0100 - - Initialize properly charactersRead - - It is possible that there are calls to getPos before reset - Found thanks to PDF provided by Joel Voss of Leviathan Security Group - - poppler/Decrypt.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 39d140bfc0b8239bdd96d6a55842034ae5c05473 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 21 18:54:31 2010 +0100 - - Fix crash in broken pdf (code < 0) - - Found thanks to PDF provided by Joel Voss of Leviathan Security Group - - fofi/FoFiType1.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit c6a091512745771894b54a71613fd6b5ca1adcb3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 21 18:50:25 2010 +0100 - - Fix memory leak - - Found thanks to PDF provided by Joel Voss of Leviathan Security Group - - poppler/Stream.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 9b6ddb68b80ef19cd2615900bd24da76374003d9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 20 19:47:47 2010 +0100 - - Fix copyright - - poppler/PDFDoc.cc | 1 + - poppler/PDFDoc.h | 1 + - 2 files changed, 2 insertions(+) - -commit fa3abc23656204eedd022ee1c73d9e5af758cdac -Author: Pino Toscano <pino@kde.org> -Date: Fri Sep 17 22:20:09 2010 +0200 - - [cpp] More bits of API documentation. - - cpp/poppler-global.cpp | 124 - ++++++++++++++++++++++++++++++++++++++++ - cpp/poppler-page-transition.cpp | 32 +++++++++++ - cpp/poppler-rectangle.cpp | 19 ++++++ - 3 files changed, 175 insertions(+) - -commit c5f7b5becc9993c05b67a470d5a1e431806b98d6 -Author: Pino Toscano <pino@kde.org> -Date: Fri Sep 17 20:26:37 2010 +0200 - - update copyrights - - qt4/src/poppler-private.cc | 2 +- - qt4/tests/check_strings.cpp | 18 ++++++++++++++++++ - 2 files changed, 19 insertions(+), 1 deletion(-) - -commit ae517042570327b860c1db6b68f9697d5c104657 -Author: Pino Toscano <pino@kde.org> -Date: Fri Sep 17 19:39:10 2010 +0200 - - [cpp] improve a bit the Unicode* -> ustring conversion - - (although IMHO not yet solved) - - cpp/poppler-private.cpp | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit f4c6ef88f01f6763943a3e6e006e52dbea0b149c -Author: Pino Toscano <pino@kde.org> -Date: Fri Sep 17 16:07:05 2010 +0200 - - [Qt4/tests] check_strings: add a new test case for - QStringToUnicodeGooString - - not much test data at the moment though - - qt4/tests/check_strings.cpp | 37 +++++++++++++++++++++++++++++++++++++ - 1 file changed, 37 insertions(+) - -commit ffd227b7669895325d752009d5185973cf86ce5b -Author: Pino Toscano <pino@kde.org> -Date: Fri Sep 17 14:25:57 2010 +0200 - - [Qt4] optimize UnicodeParsedString using less memory from QString - - - reserve() the right number of chars in the result string, so there - is less possibility to make it gr - ow its buffer - - do not call unicodeToQString() just to create a 1 character string, - but directly append a QChar crea - ted with the resulting unicode value (always belonging to the BMP) - - this should reduce of a very little bit the memory usage, while give - a sensible speedup of UnicodeParsedString invocations - - qt4/src/poppler-private.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit 6180890008f2b1814f092f50b8f75376399905ba -Author: Pino Toscano <pino@kde.org> -Date: Fri Sep 17 13:23:25 2010 +0200 - - [Qt4/tests] check_strings: add a test case for UnicodeParsedString - - very simple test data for it, at the moment - - qt4/tests/check_strings.cpp | 48 - +++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 48 insertions(+) - -commit c5f78d7d3953d62a746c6f5a90085ea020fe5ec7 -Author: Pino Toscano <pino@kde.org> -Date: Fri Sep 17 12:54:32 2010 +0200 - - [Qt4/tests] check_string: use a pool of GooString - - this way we can reuse the GooString in a data set even after a test - run (eg in benchmarks), - making sure they all are properly freed - - qt4/tests/check_strings.cpp | 35 ++++++++++++++++++++++++++++++----- - 1 file changed, 30 insertions(+), 5 deletions(-) - -commit 0cd5a256bdf7778c0c720941a611ad8ab56fa2e9 -Author: Pino Toscano <pino@kde.org> -Date: Fri Sep 17 00:27:53 2010 +0200 - - [Qt4/tests] first version of a unit test for strings - - this is used for testing the various string conversions: - - unicodeToQString - - UnicodeParsedString - - QStringToUnicodeGooString - - QStringToGooString - the 1st and the 4th have basic tests - - given private symbols are used, this unit test is not compiled on - windows (at least, it supposed to be so) - - qt4/tests/CMakeLists.txt | 3 ++ - qt4/tests/Makefile.am | 7 ++- - qt4/tests/check_strings.cpp | 101 - ++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 110 insertions(+), 1 deletion(-) - -commit c6e8b21c9829672e6ca42e6cdc0ca631a06af73f -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Sep 17 13:44:38 2010 +0200 - - [glib] docs: Document PopplerDocument properties - - glib/poppler-document.cc | 380 - +++++++++++++++++++++++++++-------------------- - 1 file changed, 223 insertions(+), 157 deletions(-) - -commit d4a6c17255821925906c17b79b88eebed9edfee1 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Sep 17 13:04:33 2010 +0200 - - [glib] Add accessor for all PopplerDocument properties - - PopplerDocument:linearized is now a boolean value rather than string, - so this commit breaks the API again. - - glib/demo/info.cc | 8 +- - glib/poppler-document.cc | 532 - +++++++++++++++++++++++++++++------- - glib/poppler-document.h | 74 +++-- - glib/reference/poppler-sections.txt | 16 ++ - 4 files changed, 498 insertions(+), 132 deletions(-) - -commit a5fec843dbb40fdd2007b926405b96789b21496d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Sep 17 10:38:14 2010 +0200 - - [glib-demo] Show permanent/update ID in document info demo - - glib/demo/info.cc | 9 +++++++++ - 1 file changed, 9 insertions(+) - -commit bfaf8f3cc62f28c6255d42680b9464ab9973737e -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Sep 17 10:37:32 2010 +0200 - - [glib] Add poppler_document_get_id() to get the PDF file identifier - - glib/poppler-document.cc | 52 - +++++++++++++++++++++++++++++++++++++ - glib/poppler-document.h | 3 +++ - glib/reference/poppler-sections.txt | 1 + - 3 files changed, 56 insertions(+) - -commit b15641677447b2e89853a667fc34bcca1383a97a -Author: srinivas adicherla <srinivas.adicherla@gmail.com> -Date: Fri Sep 17 10:36:22 2010 +0200 - - Add a method to get the PDF file identifier - - poppler/PDFDoc.cc | 65 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/PDFDoc.h | 3 +++ - 2 files changed, 68 insertions(+) - -commit 3b4a901a4431814590449b6cd5ea418f4d6c1172 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Sep 16 23:23:03 2010 +0100 - - Add -s option - - Writes a single html file - Since git does not allow multiple authors i'm adding them here - OSSD CDAC Mumbai by Leena Chourey (leenac@cdacmumbai.in) and Onkar - Potdar (onkar@cdacmumbai.in) - - utils/HtmlFonts.cc | 11 +++++-- - utils/HtmlFonts.h | 18 +++++++++-- - utils/HtmlOutputDev.cc | 84 - +++++++++++++++++++++++++++++++------------------- - utils/pdftohtml.1 | 3 ++ - utils/pdftohtml.cc | 15 +++++++-- - 5 files changed, 93 insertions(+), 38 deletions(-) - -commit 2792330f6caeeb42e2996271456b562489215c4c -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 15 22:42:09 2010 +0100 - - new soversions - - CMakeLists.txt | 2 +- - cpp/CMakeLists.txt | 2 +- - cpp/Makefile.am | 2 +- - glib/CMakeLists.txt | 2 +- - glib/Makefile.am | 4 ++-- - poppler/Makefile.am | 2 +- - qt4/src/CMakeLists.txt | 2 +- - qt4/src/Makefile.am | 2 +- - 8 files changed, 9 insertions(+), 9 deletions(-) - -commit 1cf56c732b63d0a310bc45b8e4b3f3f357a42cb1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 15 20:56:42 2010 +0100 - - 0.15.0 in the versions - - CMakeLists.txt | 2 +- - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - 4 files changed, 4 insertions(+), 4 deletions(-) - -commit 4ec0be498b557c3cf631e43823c6d7004304dff3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 15 20:56:34 2010 +0100 - - 0.15.0 NEWS - - NEWS | 90 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 90 insertions(+) - -commit c01a17745c04aef3e6f2225679c867a03e731e83 -Author: Pino Toscano <pino@kde.org> -Date: Thu Sep 16 20:55:56 2010 +0200 - - [CMake] disable the GObject introspection system - - it cannot complete the scanning propecure correctly without libtool - it seems - - CMakeLists.txt | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 9be7d3143b12f291409f88f3d725a239934b205e -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 15 19:19:30 2010 +0100 - - update copyright - - poppler/OptionalContent.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit b9333529bba43a71655fdbf1919ba515f7df9ca3 -Author: Pino Toscano <pino@kde.org> -Date: Wed Sep 15 17:23:54 2010 +0200 - - [cpp/tests] poppler-dump: convert out_ustring() to an - operator<<(std::ostream&) - - so we have a chance to better output the bytearray of a string to - the stream - - cpp/tests/poppler-dump.cpp | 26 ++++++++++++++++++-------- - 1 file changed, 18 insertions(+), 8 deletions(-) - -commit a44f711b4412332875337e9fb7509f18db806ddc -Author: Pino Toscano <pino@kde.org> -Date: Wed Sep 15 16:44:30 2010 +0200 - - [cpp/tests] poppler-dump: add a "--show-text <physical|raw>" option - - ... to show the text of a page in the specified layout - - cpp/tests/poppler-dump.cpp | 29 +++++++++++++++++++++++++++++ - 1 file changed, 29 insertions(+) - -commit 0094c9372b5b439af2564d83d6fb7439f4bdba88 -Author: Pino Toscano <pino@kde.org> -Date: Wed Sep 15 13:19:13 2010 +0200 - - [cpp] add a new page::text() for specifying a layout mode - - add a new text_layout_enum enum for the layout mode, used by the - new text() - make the old text() implementation call the new one with the old value - (= physical) - add & adapt the apidox accordingly - - cpp/poppler-page.cpp | 27 +++++++++++++++++++++++++-- - cpp/poppler-page.h | 5 +++++ - 2 files changed, 30 insertions(+), 2 deletions(-) - -commit 4ec3e7784cdba5c0720b1992ba500e97a7e0ed2b -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Sep 15 11:24:07 2010 +0200 - - Set initial state of optional content groups based on BaseState field - - There's a test case using BaseState attached to bug #30106 - - poppler/OptionalContent.cc | 14 +++++++++----- - 1 file changed, 9 insertions(+), 5 deletions(-) - -commit f49aa86812ed8ad91d41c675bc670b3d88d3444a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Sep 13 14:37:10 2010 +0200 - - [glib] doc: Document PopplerPage:label property - - glib/poppler-page.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit f41fe7ae6e374100574c49d1bb7a3ddc646786c8 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Sep 13 14:36:43 2010 +0200 - - [glib] doc: Add poppler_page_get_label to poppler-sections.txt - - glib/reference/poppler-sections.txt | 1 + - 1 file changed, 1 insertion(+) - -commit 91b8246766a8e5d9cca385b5854667d7967a9d71 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Sep 13 14:22:56 2010 +0200 - - [glib-demo] Use poppler_page_get_label() instead of g_object_get() - - glib/demo/page.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit b82412ef86091f4d249c818cebf00e4c59bae311 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Sep 13 14:22:03 2010 +0200 - - [glib] Add poppler_page_get_label() - - It's just an accessor for the property label - - glib/poppler-page.cc | 47 ++++++++++++++++++++++++++++++++++------------- - glib/poppler-page.h | 1 + - 2 files changed, 35 insertions(+), 13 deletions(-) - -commit ff88abf61f4bf90ad276a8593be1818d39c8ecac -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Sep 13 10:05:45 2010 +0200 - - [glib] Avoid core headers to be parsed by the g-i scanner - - glib/poppler-document.cc | 2 ++ - glib/poppler-page.cc | 2 ++ - glib/poppler-private.h | 3 +++ - 3 files changed, 7 insertions(+) - -commit 53324502898ae5fbbb21a4fb819e4a84acdc1a64 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Sep 12 11:42:03 2010 +0200 - - [glib] Fix a crash when building layer actions - - Some layers are just the parent of others, but not actually a layer so - they don't have an optional content object. Fixes bug #30106. - - glib/poppler-action.cc | 15 +++++++++------ - 1 file changed, 9 insertions(+), 6 deletions(-) - -commit dfc6ea7877635212aa7c5f7ade07af4aa9467e96 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Sep 12 11:36:58 2010 +0200 - - [glib] Fix layers array generation when it contains multiple arrays - - Fixes layers for document attached to bug #30106. - - glib/poppler-document.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 7574912b6c0ff0421c69b6e8c6835957d5126d7d -Author: Jonathan Liu <net147@gmail.com> -Date: Thu Sep 9 20:34:03 2010 +0100 - - Fix checking whether _WIN32 is defined - - Bug 29329 - - poppler/StdinCachedFile.cc | 2 +- - utils/pdftoppm.cc | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 2fc83068c32e09fa3de03a157a420490431ea706 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Sep 5 14:26:27 2010 +0100 - - Increase the number of cached glyphs for small sizes - - Should not increase memory usage much and gives me a 17% speed - increase - in the firefox nytimes advertisment pdf - - splash/SplashFont.cc | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -commit 0d96f74f31171c58a55e4ac36d492ce36dd5e7c5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Sep 5 12:31:57 2010 +0100 - - Use std::sort instead of qsort - - Gives a nice speed improvement without any real code change - Passes regression tests - Based on Paweł Wiejacha patches - - poppler/GfxFont.cc | 17 +++++++--------- - splash/SplashXPath.cc | 48 - ++++++++++++++++++++++++++++---------------- - splash/SplashXPathScanner.cc | 10 +++++---- - 3 files changed, 44 insertions(+), 31 deletions(-) - -commit 3b4816b2b8caa0e2baafbe4c0eb1e45e452d01ce -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 1 20:43:35 2010 +0100 - - forgot the file - - qt4/tests/poppler-texts.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 40 insertions(+) - -commit b0db93c71a83946aa3e02bae6b396223dcca19d1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 1 20:43:14 2010 +0100 - - add since and rename enum - - qt4/src/poppler-page.cc | 2 +- - qt4/src/poppler-qt4.h | 5 ++++- - 2 files changed, 5 insertions(+), 2 deletions(-) - -commit a86f9d90be99a36c41c6932fb4d9a202c4ff6d05 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 1 20:20:48 2010 +0100 - - Clarify the ownership - - qt4/src/poppler-qt4.h | 2 ++ - 1 file changed, 2 insertions(+) - -commit 33ad3a17ac26879fcd6a7fad2023dd219bc5919f -Author: Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> -Date: Wed Sep 1 20:19:54 2010 +0100 - - Add a way to access the raw text - - poppler/TextOutputDev.cc | 23 ++++++++++++++++++++--- - qt4/src/poppler-page.cc | 11 +++++++++-- - qt4/src/poppler-qt4.h | 19 +++++++++++++++++++ - qt4/tests/CMakeLists.txt | 1 + - qt4/tests/Makefile.am | 7 ++++++- - 5 files changed, 55 insertions(+), 6 deletions(-) - -commit 46e89248b3c5b1789baa3bd9bfa012570720ddb5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 1 19:54:02 2010 +0100 - - quadding is not a GBool but an int - - poppler/Annot.cc | 2 +- - poppler/Annot.h | 4 ++-- - 2 files changed, 3 insertions(+), 3 deletions(-) - -commit ae79fc504c5424be2fa21dbc5498ced4db6e5dd3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Aug 31 22:14:57 2010 +0100 - - Make GBool a bool instead of an int - - Passes the regression tests and might make things faster and use a bit - less memory - - cpp/tests/CMakeLists.txt | 2 +- - cpp/tests/Makefile.am | 2 +- - goo/gtypes.h | 7 +- - utils/CMakeLists.txt | 2 +- - utils/Makefile.am | 2 +- - utils/parseargs.c | 208 - ----------------------------------------------- - utils/parseargs.cc | 208 - +++++++++++++++++++++++++++++++++++++++++++++++ - 7 files changed, 216 insertions(+), 215 deletions(-) - -commit d3f32f2c4f9f46620c0287c44bef686f340461f3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Aug 31 18:51:17 2010 +0100 - - Read from the correct variable - - Fixes crash on KDE bug 249586 - - poppler/Movie.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 681bb38eafc720b309172ed7c650439c559663a0 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Aug 26 23:55:58 2010 +0100 - - Make declaration match what there is in the .cc file - - poppler/TextOutputDev.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit c91e869304fc263c52f21ee484a57a6f1900f6b2 -Author: Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> -Date: Thu Aug 26 19:40:46 2010 +0100 - - Add -r option to pdftohtml - - Fixes bug 29551 - - utils/pdftohtml.1 | 3 +++ - utils/pdftohtml.cc | 18 +++++++++++++----- - 2 files changed, 16 insertions(+), 5 deletions(-) - -commit 9b4be586640b4ad344b1b3ed4c9cda8351257f0c -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Aug 25 19:26:30 2010 +0100 - - Use 3 not nComps - - poppler/GfxState.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 218f67c527fb41babf2703ba068d072f8326e37b -Author: Paweł Wiejacha <pawel.wiejacha@gmail.com> -Date: Tue Aug 24 23:47:06 2010 +0100 - - Make SplashOutputDev::imageSrc faster - - By using getRGBLine when possible - - poppler/SplashOutputDev.cc | 39 ++++++++++++++++++++++++++++++--------- - 1 file changed, 30 insertions(+), 9 deletions(-) - -commit 868f4a1f22051b7978f47a0614f23fd66dbb7ca8 -Author: Paweł Wiejacha <pawel.wiejacha@gmail.com> -Date: Tue Aug 24 23:35:21 2010 +0100 - - Make GfxICCBasedColorSpace::getRGBLine faster - - By calling doTransform less - - poppler/GfxState.cc | 15 +++++++-------- - poppler/GfxState.h | 4 +++- - 2 files changed, 10 insertions(+), 9 deletions(-) - -commit 46e37c54c6365cf37dc1e223a3c146e7b96a56af -Author: Paweł Wiejacha <pawel.wiejacha@gmail.com> -Date: Tue Aug 24 21:23:34 2010 +0100 - - Do not call pow three times when one is enough - - poppler/GfxState.cc | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - -commit 8591c804598576556c6d24a66b6648de8ed1c4eb -Author: Mike Slegeir <tehpola@yahoo.com> -Date: Sun Aug 22 22:01:03 2010 +0100 - - Use splash instead of external gs invocation to render the background - - Patch in bug 19404, should fix 9746 too - - utils/pdftohtml.1 | 8 +- - utils/pdftohtml.cc | 210 - ++++++++++++++++++++++++++++++++++++++--------------- - 2 files changed, 158 insertions(+), 60 deletions(-) - -commit 7fc3c21a8c5d6cf8517100427b182887a9569ed0 -Author: Ilya Gorenbein <igorenbein@finjan.com> -Date: Fri Aug 20 20:24:31 2010 +0100 - - Fix failure to parse PDF with damaged internal structure - - Patch in bug 29189, fixes bug 3870 - - poppler/PDFDoc.cc | 24 +++++++++++++---- - poppler/XRef.cc | 80 - ++++++++++++++++++++++++++++++++----------------------- - poppler/XRef.h | 5 ++-- - 3 files changed, 68 insertions(+), 41 deletions(-) - -commit bedf48d4397ae412a6d28fc8fea16cc23a29f07c -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Aug 17 22:02:59 2010 +0100 - - use memset instead of a for - - splash/Splash.cc | 4 +--- - 1 file changed, 1 insertion(+), 3 deletions(-) - -commit 03ca5b4a5c9964d9c0e9913eb2061692848c4b95 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Aug 10 19:55:31 2010 +0100 - - Update copyrights - - goo/GooTimer.cc | 1 + - goo/GooTimer.h | 1 + - goo/gfile.cc | 2 +- - poppler/DCTStream.cc | 1 + - poppler/DCTStream.h | 1 + - poppler/GfxState.cc | 2 +- - poppler/Page.cc | 2 +- - qt4/src/poppler-annotation.cc | 2 +- - 8 files changed, 8 insertions(+), 4 deletions(-) - -commit 3bca8ddc10bf4291bf0c0e39c67341a05953e949 -Author: Jonathan Liu <net147@gmail.com> -Date: Tue Aug 10 19:42:40 2010 +0100 - - Tell windows we are writing/reading binary data - - Bug #29329 - - poppler/StdinCachedFile.cc | 9 +++++++++ - utils/pdftoppm.cc | 9 +++++++++ - 2 files changed, 18 insertions(+) - -commit bdd617f2177a7836f6b6686fde892664513a32a7 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Aug 3 13:05:26 2010 +0200 - - [glib] Fix a crash when a layer doesn't have a name - - Fixes bug #28842. - - glib/poppler-layer.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit e9f0646ca664cc27825f7e084f8419fe0de1fcfc -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Aug 3 13:02:52 2010 +0200 - - Catalog page array might contain NULL for some pages in invalid - documents - - Fixes a crash reproducible with gtk-splash-test when opening document - attached to bug #28842. - - poppler/PDFDoc.cc | 27 +++++++++++++++------------ - 1 file changed, 15 insertions(+), 12 deletions(-) - -commit 842209782ca3ba8c1c783cccf565372a18b3fda5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 30 19:29:12 2010 +0100 - - Do not crash when using pdftops in some files - - Fixes crash in file in kde bug 246269. The output is still wrong - though - - fofi/FoFiType1C.cc | 12 +++++++----- - 1 file changed, 7 insertions(+), 5 deletions(-) - -commit 0dd7c80b7baf2622eb4780a867c4dc6291773f3b -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Jul 26 23:58:26 2010 +0100 - - Do not overwrite the rgb values - - Recommended by Koji Otani in Re: [poppler] Question about code - Passed the regression testing in my files - - poppler/GfxState.cc | 1 - - 1 file changed, 1 deletion(-) - -commit 627edf88c8f5c073a68bd05990df56e1af547292 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Jul 25 13:56:03 2010 +0200 - - [annots] Fix a crash when adding a new annotation and annots object - is an array - - When annots object is an array instead of a ref, the modified - object is - actually de page object. - - poppler/Page.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 5d86f9b600b1e10de93bcaf1b925fadbc2a47522 -Author: mpsuzuki <mpsuzuki@hiroshima-u.ac.jp> -Date: Sat Jul 24 15:12:05 2010 +0100 - - reindent correctly - - poppler/TextOutputDev.cc | 34 +++++++++++++++++----------------- - 1 file changed, 17 insertions(+), 17 deletions(-) - -commit d0a6f9abdab88ec43004b6766337db304cbf6a25 -Author: Pino Toscano <pino@kde.org> -Date: Thu Jul 22 21:28:55 2010 +0200 - - [CMake] improve the way include dirs and cflags for gdk and gtk - are set - - correctly include_directories() for the include dirs, while add the - cflags which are not include dirs as definitions - - glib/CMakeLists.txt | 5 +++-- - glib/demo/CMakeLists.txt | 5 ++++- - 2 files changed, 7 insertions(+), 3 deletions(-) - -commit 02d85dd2cc154dbb6caa04a349532033d833edd1 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jul 20 13:53:56 2010 +0200 - - [glib-demo] Add support for adding annots in annot demo - - glib/demo/annots.c | 114 - +++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 114 insertions(+) - -commit 969cb850f5c2bc31de82c591b2b3210b5cfabf5f -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jul 20 13:53:29 2010 +0200 - - [glib] docs: Add new symbols to poppler-sections.txt - - glib/reference/poppler-sections.txt | 18 ++++++++++++++++++ - 1 file changed, 18 insertions(+) - -commit 251959438b6257fe71ed58e79eec60cda68a66cf -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jul 20 13:53:00 2010 +0200 - - [glib] Add poppler_page_add_annot() - - glib/poppler-document.cc | 7 ++++--- - glib/poppler-page.cc | 19 +++++++++++++++++++ - glib/poppler-page.h | 2 ++ - 3 files changed, 25 insertions(+), 3 deletions(-) - -commit 78a4f6976e708f2cc23aac49fbff0faf00e74bc3 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jul 20 13:51:16 2010 +0200 - - [glib] annots: Add several setter methods - - glib/poppler-annot.cc | 278 - ++++++++++++++++++++++++++++++++++++++++++++----- - glib/poppler-annot.h | 26 +++++ - glib/poppler-private.h | 6 ++ - 3 files changed, 285 insertions(+), 25 deletions(-) - -commit fee488c9db60ab691ce9ff5eef284be2af897aee -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Jul 18 11:26:59 2010 +0200 - - [annots] Add AnnotMarkup::setOpacity - - poppler/Annot.cc | 8 ++++++++ - poppler/Annot.h | 1 + - 2 files changed, 9 insertions(+) - -commit d15a355ede2d8510c4df847ea0b92b5357b29914 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Jul 18 09:57:35 2010 +0200 - - Set the page reference (P in annot dict) when adding a new annot to - a page - - poppler/Annot.cc | 9 +++++++++ - poppler/Annot.h | 3 +++ - poppler/Page.cc | 2 ++ - 3 files changed, 14 insertions(+) - -commit 49ffb46db3118db874d2d9830bb034762d625c61 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Jul 19 16:31:54 2010 +0100 - - Remove exception support - - We don't use it and don't even support it properly - - CMakeLists.txt | 1 - - config.h.cmake | 3 --- - configure.ac | 4 --- - goo/gmem.cc | 56 - ++++++++++++------------------------------ - goo/gmem.h | 38 +++++++++------------------- - poppler/poppler-config.h.cmake | 5 ---- - poppler/poppler-config.h.in | 5 ---- - 7 files changed, 27 insertions(+), 85 deletions(-) - -commit dd2e9399868e3dbf2fa4ede050f8d74d29ebbbb4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Jul 19 16:31:43 2010 +0100 - - add uninstalled.pc to ignore - - .gitignore | 7 +++++++ - 1 file changed, 7 insertions(+) - -commit d1033006aae381a0f075e02d54638a1af997caf3 -Author: Pino Toscano <pino@kde.org> -Date: Sat Jul 17 21:46:14 2010 +0200 - - add FindGObjectIntrospection.cmake and - GObjectIntrospectionMacros.cmake to the dist - - Makefile.am | 2 ++ - 1 file changed, 2 insertions(+) - -commit ce8d03950736cc35d035a44a7d88e5f2a9defa74 -Author: Pino Toscano <pino@kde.org> -Date: Sat Jul 17 21:39:08 2010 +0200 - - [CMake/glib] add support for gobject-introspection - - other than a module to find (using pkg-config) gobject-introspection, - this adds a macro (gir_add_introspections) to add new introspections - in a directory. - its working is much similar (even the variable names used) to - the Makefile version provided by gobject-repository itself, with - the notable difference of a disabled libtool in the g-ir-scanner - invocation. - the only additional step needed is adding two custom targets, compiled - by ALL, which have the gir and the typelib files as dependencies, - to make them build with the usual `make all'. - - CMakeLists.txt | 5 +- - cmake/modules/FindGObjectIntrospection.cmake | 61 +++++++++++++++++ - cmake/modules/GObjectIntrospectionMacros.cmake | 94 - ++++++++++++++++++++++++++ - glib/CMakeLists.txt | 36 ++++++++++ - 4 files changed, 194 insertions(+), 2 deletions(-) - -commit 78bf43d8e11aa52db9862af118c597e117d31083 -Author: Pino Toscano <pino@kde.org> -Date: Sat Jul 17 20:28:58 2010 +0200 - - [CMake] properly use the glib2 include dirs - - properly use GLIB2_INCLUDE_DIRS (pkg-config result) for the glib - include dirs, - while turn GLIB2_CFLAGS into GLIB2_CFLAGS_OTHERS to add the remaining - CFLAGS as definitions - - glib/CMakeLists.txt | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 6f3082d677bc62aa3f8124132e3e337c01be2629 -Author: Pino Toscano <pino@kde.org> -Date: Sat Jul 17 19:28:09 2010 +0200 - - [CMake] split the generated sources of poppler_glib_SRCS in an own - poppler_glib_generated_SRCS - - glib/CMakeLists.txt | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit 2a252dd9b05857bbd10dee235e873886fc74ec17 -Author: Pino Toscano <pino@kde.org> -Date: Sat Jul 17 14:57:38 2010 +0200 - - [CMake] add stub message and TODO for the gobject-introspection - support - - CMakeLists.txt | 3 +++ - 1 file changed, 3 insertions(+) - -commit 8a3d1794a8ef5d525bb454755fec018e3fcb3816 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 16 14:00:32 2010 +0100 - - update - - TODO | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 31ac578942b82cbd16b064abca586ccb89dfa7ce -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 15 15:05:10 2010 +0200 - - Rework ChangeLog generation to fix make distcheck - - Makefile.am | 22 +++++++++++++++++++--- - 1 file changed, 19 insertions(+), 3 deletions(-) - -commit 5da5825ecab63089a19aac694826271019a94e6d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 15 15:03:20 2010 +0200 - - [glib] docs: Add version.xml to content_files var - - glib/reference/Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit fe69b474ae63c9d5d2538db9e51e666dd6ea9fb3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jul 15 10:51:21 2010 +0100 - - Fix padding of names - - The previous method returned 2 for documents with 100 pages, which - is wrong as 100 needs 3 - characters, not 2 - - utils/pdftoppm.cc | 14 +++++++++++++- - 1 file changed, 13 insertions(+), 1 deletion(-) - -commit e265ae2d8a46df00ab1bbd863f01f652068d265f -Author: Brian Cameron <brian.cameron@oracle.com> -Date: Wed Jul 14 20:26:25 2010 +0100 - - Add uninstalled .pc file for poppler when using autoconf - - Makefile.am | 9 ++++++++- - configure.ac | 9 ++++++++- - poppler-cairo-uninstalled.pc.in | 6 ++++++ - poppler-cpp-uninstalled.pc.in | 7 +++++++ - poppler-glib-uninstalled.pc.in | 7 +++++++ - poppler-qt-uninstalled.pc.in | 7 +++++++ - poppler-qt4-uninstalled.pc.in | 7 +++++++ - poppler-splash-uninstalled.pc.in | 7 +++++++ - poppler-uninstalled.pc.in | 6 ++++++ - 9 files changed, 63 insertions(+), 2 deletions(-) - -commit 552ab99e60fe4068be8e4e415924e4be289e47cd -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jul 13 10:18:01 2010 +0200 - - Handle ColorTransform in DCT streams when using libjpeg - - Fixes bug #28873. - - poppler/DCTStream.cc | 30 ++++++++++++++++++++++++++++++ - poppler/DCTStream.h | 1 + - 2 files changed, 31 insertions(+) - -commit 8a6697f89625106f3c373dbc7b4dc521e22502f7 -Author: Hib Eris <hib@hiberis.nl> -Date: Sat Jul 3 16:42:04 2010 +0200 - - Only define findModifier() when used - - Prevents a warning when building with win32 font backend. - - poppler/GlobalParams.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit b1fdb87a4ebb5079c731256cce1870de8c54c65d -Author: Hib Eris <hib@hiberis.nl> -Date: Fri Jul 2 10:53:20 2010 +0200 - - Fix compile warnings on auto imports for mingw compiler - - cpp/Makefile.am | 2 +- - cpp/tests/Makefile.am | 2 ++ - glib/Makefile.am | 2 ++ - poppler/Makefile.am | 2 +- - qt4/demos/Makefile.am | 2 ++ - qt4/src/Makefile.am | 2 +- - qt4/tests/Makefile.am | 2 ++ - 7 files changed, 11 insertions(+), 3 deletions(-) - -commit 9e577110134eb1e093e697b7504efca759000086 -Author: Hib Eris <hib@hiberis.nl> -Date: Fri Jul 2 10:51:24 2010 +0200 - - Check for declaration of gettimeofday() - - The function gettimeofday() is not declared in ansi mode with the - mingw compiler, even though the function exists. Therefore, - configure must - not only check with AC_CHECK_FUNC, but also with AC_CHECK_DECL. - - Also, the checks must run in a C++ context because that is where - gettimeofday() is used. - - configure.ac | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -commit 58c8430ac584f3ba5e97aceb148e6287bfc45f95 -Author: Hib Eris <hib@hiberis.nl> -Date: Wed Jun 30 15:06:44 2010 +0200 - - Set -ansi compiler flag early in configure.ac - - The -ansi compiler flag does not enable warnings, but turns of certain - features of GCC. To force feature tests to use this flag, it should be - set early in configure.ac - - This is important for the mingw compiler where header files refrain - from declaring certain function (e.g. gettimeofday()) when the -ansi - flag is set. - - configure.ac | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -commit e3663a855a9c86f0a3988a7a50fa40d37d0ea069 -Author: Hib Eris <hib@hiberis.nl> -Date: Fri Jul 2 14:45:15 2010 +0200 - - Use MAX_PATH instead of _MAX_PATH everywhere - - _MAX_PATH is compiler specific and not availble with the mingw - compiler - in ansi mode. MAX_PATH is in the Windows api and thus always available - when windows.h is included. - - goo/gfile.cc | 4 ++-- - poppler/GlobalParams.cc | 2 +- - poppler/PDFDoc.cc | 4 ++-- - 3 files changed, 5 insertions(+), 5 deletions(-) - -commit 7227c407d23a37f5d95e6c01cb7411be2f82ca85 -Author: Hib Eris <hib@hiberis.nl> -Date: Wed Jun 30 16:15:06 2010 +0200 - - Check for _WIN32 instead of _MSC_VER - - goo/GooTimer.cc | 6 +++--- - goo/GooTimer.h | 4 ++-- - 2 files changed, 5 insertions(+), 5 deletions(-) - -commit 34e727e011529be312313a1f4d4fa1ba9c545888 -Author: Hib Eris <hib@hiberis.nl> -Date: Tue Jun 29 16:43:31 2010 +0200 - - Fix cross compiling for Windows with autotools - - When cross compiling for Windows with autotools, libtool creates - libpoppler_qt4_la-poppler-optcontent.lo instead of - poppler-optcontent.lo. Thus, explicitly using poppler-optcontent.lo to - create poppler-optcontent.moc does not work well. - - qt4/src/Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 1bc2f4501ea4e56ca99ae4d94d6cf34cf33c2c7a -Author: Hib Eris <hib@hiberis.nl> -Date: Tue Jun 29 15:34:22 2010 +0200 - - define poppler_qt4_EXPORTS when building with autotools - - Lets you build the qt4 bindings for Windows with automake/autoconf. - - qt4/src/Makefile.am | 3 +++ - 1 file changed, 3 insertions(+) - -commit 5825114a26cc6eece2e556063f640dda53ea1e11 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jul 11 12:24:20 2010 +0100 - - Compile++ - - glib/demo/CMakeLists.txt | 1 + - 1 file changed, 1 insertion(+) - -commit 5e4d8eeea0b9dba68420c164975418c76a53be85 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Jul 10 15:54:28 2010 +0200 - - [pdf-inspector] Do not render for printing - - test/pdf-inspector.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit e6824972a213a888ca0185b7ae0a75fc23f75797 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Jul 10 15:52:15 2010 +0200 - - [annots] Use a transparency group for markup annots without AP and - opacity != 1 - - Fixes bug #623616. - - poppler/Annot.cc | 346 - +++++++++++++++++++++++++------------------------------ - poppler/Annot.h | 3 + - poppler/Gfx.cc | 9 +- - poppler/Gfx.h | 2 +- - 4 files changed, 165 insertions(+), 195 deletions(-) - -commit 70ce0b6ea1a0d61f5048d2ae49c639d74a643b29 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Jul 9 17:04:00 2010 +0200 - - [annots] Clamp QuadPoints coords to annot rectangle instead of - ignore points - - Fixes appearance stream generation for document attached to bug - #623616. - - poppler/Annot.cc | 38 +++++++++++++++++++++----------------- - 1 file changed, 21 insertions(+), 17 deletions(-) - -commit 8a9e561bfe64f71e9f38c43e5c6be7e5069b2349 -Author: Hib Eris <hib@hiberis.nl> -Date: Fri Jul 2 21:07:53 2010 +0200 - - Nicer autogen.sh output - - autogen.sh | 1 + - 1 file changed, 1 insertion(+) - -commit ce4d328294cea73f4b7368691dc1fed6bd45d569 -Author: Hib Eris <hib@hiberis.nl> -Date: Fri Jul 2 20:51:47 2010 +0200 - - Add option for autogen.sh to skip configure - - If you do not want to automatically run configure when calling - autogen.sh, run it with: - - $ NOCONFIGURE=1 ./autogen.sh - - This feature is modeled after gnome-autogen.sh behaviour. - - autogen.sh | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -commit d7ee87c5d0a35c8d4fcc88bde4b8496c49f397c6 -Author: Hib Eris <hib@hiberis.nl> -Date: Tue Jul 6 15:16:08 2010 +0100 - - warnings-=2 - - poppler/GfxFont.cc | 3 ++- - utils/HtmlOutputDev.cc | 3 ++- - 2 files changed, 4 insertions(+), 2 deletions(-) - -commit 1e7f457ca1617fd8c958feef8dd7e694476dedd9 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Jul 9 12:29:14 2010 +0200 - - [cairo] Use ceil to convert double to int in tilingPatternFill() - - Fixes rendering of page 2 of document attached to bug #28954. - - poppler/CairoOutputDev.cc | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -commit 91a7605eb51144f2e7dea69aa9454fff47c49bd2 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Jul 9 11:42:56 2010 +0200 - - [glib] Fix build when GDK is enabled - - glib/test-poppler-glib.cc | 8 +------- - 1 file changed, 1 insertion(+), 7 deletions(-) - -commit 09e3e0e9c5134688c4ed2af5cd3a12aa2986474c -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 8 18:56:38 2010 +0200 - - [glib] Fix poppler_page_find_tex() when called more than once - - Fixes bug #27927 - - glib/poppler-page.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 25427bdecb219ffe6f0592d2ac36de60c247bfd9 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 8 17:46:22 2010 +0200 - - Fix build when compiling without glib frontend - - configure.ac | 1 + - 1 file changed, 1 insertion(+) - -commit 550684731356a66753ec19f5a8ca4b572db6d2d5 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 8 17:16:02 2010 +0200 - - [glib-demo] Add selections demo - - glib/demo/Makefile.am | 2 + - glib/demo/main.c | 4 +- - glib/demo/selections.c | 687 - +++++++++++++++++++++++++++++++++++++++++++++++++ - glib/demo/selections.h | 31 +++ - 4 files changed, 723 insertions(+), 1 deletion(-) - -commit b257428150e2c13dcc24fd8f75e4ee2c679ab414 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 8 14:45:29 2010 +0200 - - [glib] Add poppler_page_get_selected_text() - - And change poppler_page_get_text() to return the text of the whole - page. For consistency with poppler_page_get_selection_region() - get_seletect_text() doesn't invert the y coords as get_text() - did. This - change breaks the API. Users of poppler_page_get_text should: - - - Use the new poppler_page_get_text() if they want the text of the - whole page - - - Use poppler_page_get_selected_text() if they want the text of the - selected area. In this case they shouldn't invert the y coords - anymore - before calling the method. - - glib/demo/text.c | 9 +------- - glib/poppler-page.cc | 43 - +++++++++++++++++++++++++++---------- - glib/poppler-page.h | 3 ++- - glib/reference/poppler-sections.txt | 1 + - 4 files changed, 36 insertions(+), 20 deletions(-) - -commit bedc88225c948ad1288b69c6c106adce36233442 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jul 7 11:55:47 2010 +0200 - - [cairo] Fix warning on signed/unsigned comparison - - poppler/CairoFontEngine.cc | 12 ++++++------ - poppler/CairoFontEngine.h | 8 ++++---- - 2 files changed, 10 insertions(+), 10 deletions(-) - -commit 092aa901b9ec35a48bc1fb229ad16a3b00eef5f2 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Jul 5 11:16:49 2010 +0200 - - [glib] docs: add some more introspection annotations - - glib/poppler-attachment.cc | 4 ++-- - glib/poppler-document.cc | 12 ++++++------ - glib/poppler-media.cc | 4 ++-- - glib/poppler-page.cc | 4 ++-- - 4 files changed, 12 insertions(+), 12 deletions(-) - -commit 6c4e14fd90d5ef2d6670a980ab2476b6fab58df7 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Jul 5 10:49:59 2010 +0200 - - [glib] docs: fix POPPLER_CHECK_VERSION() docs - - glib/poppler-features.h.in | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit ed324a867ecf1f616c4b2dc575f01d5cf1b67c38 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Jul 2 18:28:45 2010 +0200 - - [glib] Rename instrospection files as 0.16 instead of 0.14 - - glib/Makefile.am | 14 +++++++------- - 1 file changed, 7 insertions(+), 7 deletions(-) - -commit a55f567ff1ea0858eda13a024ed765a016f3bff0 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Jul 2 18:23:03 2010 +0200 - - [glib] docs: Remove unneeded empty line in doc comment - - glib/poppler-features.h.in | 1 - - 1 file changed, 1 deletion(-) - -commit f16015303422280eaa21c3144eca0f1a330dce8a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Jul 2 18:19:13 2010 +0200 - - [glib] docs: Add GObject introspection annotations - - glib/poppler-annot.cc | 45 - ++++++++++++++++++++-------------------- - glib/poppler-document.cc | 8 +++---- - glib/poppler-page.cc | 23 +++++++++++++------- - glib/reference/poppler-docs.sgml | 2 ++ - 4 files changed, 43 insertions(+), 35 deletions(-) - -commit 60242038e4dce7f0c90f2bfa0e771120247dbc9d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jun 30 09:35:29 2010 +0200 - - [glib] Add GObject introspection support - - configure.ac | 5 +++ - glib/Makefile.am | 29 +++++++++++++++++ - m4/introspection.m4 | 94 - +++++++++++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 128 insertions(+) - -commit 3160950a7d7161457405c9084c31af230329b3f0 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Jul 2 12:47:04 2010 +0200 - - [glib] docs: Add index of deprecated symbols - - glib/reference/poppler-docs.sgml | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 593db7acf6edce1267f69d12310bf4098ff24c97 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Jul 2 12:44:39 2010 +0200 - - [glib] docs: deprecate GDK API - - glib/poppler-page.cc | 8 ++++++++ - 1 file changed, 8 insertions(+) - -commit 6facefb3fa8f97a9d330545308fb2d89c7f57fa0 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 1 18:01:45 2010 +0200 - - [glib] docs: Add index of new symbols for versions 0.12, 0.14 and 0.16 - - glib/poppler-action.h | 10 +++++++--- - glib/poppler-annot.cc | 17 +++++++++++++++++ - glib/poppler-date.cc | 2 ++ - glib/poppler-document.cc | 16 +++++++++++++++- - glib/poppler-layer.cc | 12 ++++++++++++ - glib/poppler-media.cc | 14 ++++++++++++-- - glib/poppler-media.h | 3 +++ - glib/poppler-movie.cc | 6 ++++++ - glib/poppler-page.cc | 2 ++ - glib/reference/poppler-docs.sgml | 12 ++++++++++++ - 10 files changed, 88 insertions(+), 6 deletions(-) - -commit 166b78c0ce8a4536873c4f60b392c24c8a68e7aa -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 1 17:25:03 2010 +0200 - - [glib] docs: document PopplerMediaSaveFunc - - glib/poppler-media.h | 18 +++++++++++++++++- - 1 file changed, 17 insertions(+), 1 deletion(-) - -commit 5cc0a51f88580c65ac2d5c6ff02b8cf14697b70c -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 1 17:20:13 2010 +0200 - - [glib] Use the same name for parameter in function prototype - - glib/poppler-media.h | 10 +++++----- - glib/poppler-movie.h | 6 +++--- - 2 files changed, 8 insertions(+), 8 deletions(-) - -commit 6793fd8fd2d33d3d58c6556b5dbe6d0497e56646 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 1 15:49:49 2010 +0200 - - [glib] docs: document some enums in poppler-action - - glib/poppler-action.h | 92 - +++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 92 insertions(+) - -commit 8e139696dbe19f54ad54364a711b929146f11080 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 1 15:02:58 2010 +0200 - - [glib] docs: mark structures in poppler-private.h as private - - glib/poppler-private.h | 7 +++++++ - 1 file changed, 7 insertions(+) - -commit ccae7e574047d66c638003cc36fa1edeef4d35ed -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 1 14:59:50 2010 +0200 - - [glib] docs: document PopplerDocument enums - - glib/poppler-document.h | 65 - +++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 65 insertions(+) - -commit 4fbff172693c38cdc4ae8070a55ceb706aa213cd -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 1 14:26:53 2010 +0200 - - [glib] docs: document PopplerFontInfo - - glib/poppler-document.cc | 106 - +++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 106 insertions(+) - -commit 465dd4897ff603a6fd96503cf4746fc808b0f827 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 1 12:59:39 2010 +0200 - - [glib] docs: document some enums - - glib/poppler.h | 55 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 55 insertions(+) - -commit de3d599ea9e948867cfe395f42ed659670110c4c -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 1 12:31:10 2010 +0200 - - [glib] docs: document boxed types defined in poppler-page - - glib/poppler-page.cc | 147 - +++++++++++++++++++++++++++++++++++++++++++++++++++ - glib/poppler-page.h | 79 +++++++++++++++++++++++++++ - 2 files changed, 226 insertions(+) - -commit 34c52190e1dbf4d3effa44b4408faa1fbae0d12d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 1 09:33:08 2010 +0200 - - [glib] Remove splash header file - - glib/poppler-page.cc | 1 - - 1 file changed, 1 deletion(-) - -commit 6910545a487f206ccd059bb295d2312228dbf2ba -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jun 30 19:03:04 2010 +0200 - - [glib] docs: Remove invalid symbol from poppler-sections.txt - - glib/reference/poppler-sections.txt | 1 - - 1 file changed, 1 deletion(-) - -commit 65ea3b636cb5a38660e526a483a4d95f5acdf8db -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jun 30 19:02:32 2010 +0200 - - [glib] docs: fix typo - - glib/poppler-form-field.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 689bfec40b5b3030c2819cb4aac42c3ab6279278 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jun 30 19:01:47 2010 +0200 - - [glib] docs: Add missing doc for parameter - - glib/poppler-document.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 0b3d77627f255a4bf3da6ee875ad8d9eb931c96e -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jun 30 19:00:59 2010 +0200 - - [glib] Use the same name for parameter in function prototype - - glib/poppler-page.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 19e1944c00ac2da6b18b015721fc3a8d1898a23a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jun 30 18:01:52 2010 +0200 - - [glib] docs: Add media and movie to docs - - glib/poppler-media.cc | 6 ++++++ - glib/poppler-movie.cc | 6 ++++++ - glib/reference/poppler-docs.sgml | 3 ++- - 3 files changed, 14 insertions(+), 1 deletion(-) - -commit ca48bee07e6b4a20ea7b40b472a335e75feb4739 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jun 30 17:56:50 2010 +0200 - - [glib] docs: Add missing types to poppler.types - - glib/reference/poppler.types | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 613ccf81317a007ed5017ee788466613a6699bb5 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jun 30 17:54:22 2010 +0200 - - [glib] docs: rework poppler-sections.txt - - - Better organization of sections and contents - - Use of Standard and Private subsections - - Add missing sections - - Remove enums section - - glib/reference/poppler-sections.txt | 424 - +++++++++++++++++++++++++----------- - 1 file changed, 295 insertions(+), 129 deletions(-) - -commit b37556a32b79f8711ed7eca24abf19511872a70a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jun 30 12:01:44 2010 +0200 - - [glib] docs: Add index of symbols - - glib/reference/poppler-docs.sgml | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 7f5fa4e19b4e324a396d64261b9125c1a557ac84 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jun 30 12:00:35 2010 +0200 - - [glib] docs: Add version information - - configure.ac | 1 + - glib/reference/Makefile.am | 2 +- - glib/reference/poppler-docs.sgml | 7 ++++++- - glib/reference/version.xml.in | 1 + - 4 files changed, 9 insertions(+), 2 deletions(-) - -commit 848d5e158fa9eadd19a658db314ba3fff9d026e8 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jun 30 11:30:41 2010 +0200 - - [glib] docs: do not use gtk-doc templates - - configure.ac | 2 +- - glib/poppler-action.cc | 6 + - glib/poppler-annot.cc | 6 + - glib/poppler-attachment.cc | 6 + - glib/poppler-attachment.h | 16 + - glib/poppler-document.cc | 8 + - glib/poppler-features.h.in | 59 ++++ - glib/poppler-form-field.cc | 6 + - glib/poppler-layer.cc | 6 + - glib/poppler-page.cc | 6 + - glib/reference/tmpl/poppler-action.sgml | 216 ------------ - glib/reference/tmpl/poppler-annot.sgml | 377 --------------------- - glib/reference/tmpl/poppler-attachment.sgml | 68 ---- - glib/reference/tmpl/poppler-document.sgml | 410 - ----------------------- - glib/reference/tmpl/poppler-enums.sgml | 246 -------------- - glib/reference/tmpl/poppler-features.sgml | 83 ----- - glib/reference/tmpl/poppler-form-field.sgml | 318 ------------------ - glib/reference/tmpl/poppler-layer.sgml | 83 ----- - glib/reference/tmpl/poppler-page.sgml | 483 - --------------------------- - glib/reference/tmpl/poppler-private.sgml | 148 -------- - glib/reference/tmpl/poppler-unused.sgml | 8 - - glib/reference/tmpl/poppler.sgml | 285 ---------------- - glib/reference/tmpl/stamp-poppler-enums.sgml | 22 -- - gtk-doc.make | 78 +++-- - m4/gtk-doc.m4 | 2 +- - 25 files changed, 171 insertions(+), 2777 deletions(-) - -commit 16e15ac845206217086e2adac9f220e75c0c630d -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 29 21:44:02 2010 +0100 - - bitmap can be null at this stage, check it isn't - - poppler/JBIG2Stream.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 38e5d28a184d0ca8df71a7ea910ce85d7a225e4e -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Jun 21 20:38:00 2010 +0100 - - more pow 0.5 -> sqrt - - poppler/GfxState.cc | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - -commit 58a53ca0a4e8434e8478f8fe121067dcf05c017d -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Jun 21 19:24:20 2010 +0100 - - sqrt is much faster than pow 0.5 - - poppler/GfxState.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit bf86a9fc464aca57ebec207a213dcc2cc6031940 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Jun 21 19:20:47 2010 +0100 - - introduce getChars to save some method calls - - Can give us a decent speedup when we go a lot though this methods - - poppler/Catalog.cc | 12 +---- - poppler/DCTStream.cc | 51 ++++++++++++++------ - poppler/DCTStream.h | 3 ++ - poppler/GfxFont.cc | 22 ++------- - poppler/GfxState.cc | 30 ++++-------- - poppler/JPEG2000Stream.cc | 67 +++++++------------------- - poppler/JPEG2000Stream.h | 38 ++++++++++++++- - poppler/Link.cc | 14 ++---- - poppler/Object.h | 4 ++ - poppler/Stream.cc | 90 +++++++++++++++++++---------------- - poppler/Stream.h | 118 - +++++++++++++++++++++++++++++++++++++++++++++- - 11 files changed, 279 insertions(+), 170 deletions(-) - -commit 65c14073a3b1035ca5fe3bd6667abd315272841e -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Jun 21 17:19:22 2010 +0200 - - Reduce pow operations in GfxCalRGBColorSpace::getXYZ() - - We were doing the same pow operation 3 times!. It makes document - attached to bug #28591 render a little faster. - - poppler/GfxState.cc | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - -commit 9365c05c1f66b3000febf32c45cef2ffe79e041a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Jun 19 10:36:39 2010 +0200 - - [glib] Fix links/annots area for rotated documents with page CropBox - not starting at 0,0 - - Fixes bug #28588. - - glib/poppler-page.cc | 25 ++++++++++--------------- - 1 file changed, 10 insertions(+), 15 deletions(-) - -commit d9504c0a288c84b68a516f715505d6bc94b911f5 -Author: Pino Toscano <pino@kde.org> -Date: Fri Jun 18 23:59:04 2010 +0200 - - [autotools] link the 'cpp' tests against libpoppler as well - - ... this way gatof() can be found correctly - should fix bug #28605 - - cpp/tests/Makefile.am | 1 + - 1 file changed, 1 insertion(+) - -commit 62975737bcaa6e0a2ecab981aa3e0c8f2ff10571 -Author: Brian Cameron <brian.cameron@oracle.com> -Date: Fri Jun 18 19:22:17 2010 +0100 - - Compile with Sun Studio - - goo/ImgWriter.h | 3 ++- - goo/JpegWriter.h | 3 ++- - poppler/SplashOutputDev.cc | 6 ++++++ - 3 files changed, 10 insertions(+), 2 deletions(-) - -commit 7cbe3d1521aea8b484efb8663e75684e05b6fb61 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jun 17 23:01:21 2010 +0100 - - Optimize Splash::compositeBackground - - Optimization takes into account the two most common cases, the - pixel not - being painted at all (alpha == 0) meaning we just copy the paperColor - and the pixel being opage meaning we have to do nothing - - splash/Splash.cc | 34 ++++++++++++++++++++++++++-------- - 1 file changed, 26 insertions(+), 8 deletions(-) - -commit f323e5e4cdcc20075ee7c722f7adc088c0772249 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jun 17 22:59:37 2010 +0100 - - Check the objects are num before reading them - - Might have caused the kde bug #241995 - - poppler/GfxState.cc | 11 +++++++---- - 1 file changed, 7 insertions(+), 4 deletions(-) - -commit 35e87d2062b1d82db0d765de5a6187122a0fa99c -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jun 16 11:52:25 2010 +0200 - - [gib-demo] Add demo for poppler_page_get_text_layout() - - glib/demo/text.c | 182 - +++++++++++++++++++++++++++++++++++++++++++++++++------ - 1 file changed, 164 insertions(+), 18 deletions(-) - -commit ddcea568b3a7334e062d6214f43d0a2c2ec95be4 -Author: Daniel Garcia <danigm@yaco.es> -Date: Tue Jun 15 16:57:32 2010 +0200 - - [glib] Add poppler_page_get_text_layout() - - Returns an array of PopplerRectangle items and each Rectangle is a - text character position. - - The position in this array represent the offset in text returned by - poppler_page_get_text - - glib/poppler-page.cc | 91 - ++++++++++++++++++++++++++++++++++++++++++++++++++++ - glib/poppler-page.h | 4 ++- - 2 files changed, 94 insertions(+), 1 deletion(-) - -commit 6e9fe8832c37b560ac4d0b0e32d618bde70ee117 -Author: Pino Toscano <pino@kde.org> -Date: Wed Jun 16 00:22:59 2010 +0200 - - [Qt4] and support 'Print' named action here too... - - qt4/src/poppler-annotation.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 53c003f36af5d77f50fe238eaec4c5f7c3a485c7 -Author: Pino Toscano <pino@kde.org> -Date: Wed Jun 16 00:18:13 2010 +0200 - - [CMake] install the new goo/GooLikely.h - - CMakeLists.txt | 1 + - 1 file changed, 1 insertion(+) - -commit 2ba752aabc8dad4bb35a351697b1590795c54ca4 -Author: Pino Toscano <pino@kde.org> -Date: Wed Jun 16 00:06:30 2010 +0200 - - update copyrights - - qt4/src/poppler-link.h | 3 ++- - qt4/src/poppler-page.cc | 1 + - 2 files changed, 3 insertions(+), 1 deletion(-) - -commit 38bf54bbad40288be763c6a1a89d90477c9ef89d -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 15 23:05:43 2010 +0100 - - move the declaration of likely/unlikely to an own file in goo/ - - goo/GooLikely.h | 22 ++++++++++++++++++++++ - goo/Makefile.am | 1 + - poppler/Object.h | 9 +-------- - splash/Splash.cc | 4 +--- - 4 files changed, 25 insertions(+), 11 deletions(-) - -commit 9838edf8c7497858e3bac2743784a3259f61cfdd -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 15 22:54:34 2010 +0100 - - Protect us against negative y coordinates - - Happens very rarely, like in bug 28480 - - splash/Splash.cc | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit 8b32c3e9826d4462fd9d16fab4200ebb23251046 -Author: Pino Toscano <pino@kde.org> -Date: Tue Jun 15 23:55:01 2010 +0200 - - [Qt4/apidox] ok, now the *proper* version for 'Print'... - - qt4/src/poppler-link.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit b54e5ac49f69bd1c906e517edcb436e042199cd5 -Author: Pino Toscano <pino@kde.org> -Date: Tue Jun 15 23:53:50 2010 +0200 - - [Qt4/apidox] add the proper version for the new 'Print' - - qt4/src/poppler-link.h | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 71ad18c3b6b73e23d71600d07ce00bdfaf0bef60 -Author: Pino Toscano <pino@kde.org> -Date: Tue Jun 15 23:51:01 2010 +0200 - - [Qt4] recognize the 'Print' named action here too - - qt4/src/poppler-annotation.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 96f60f2748ba76de0d296a9838dbd7181f506e36 -Author: Guillermo Amaral <gamaral@kdab.com> -Date: Tue Jun 15 23:47:46 2010 +0200 - - [Qt4] recognize 'Print' as name in named actions - - qt4/src/poppler-link.h | 3 ++- - qt4/src/poppler-page.cc | 2 ++ - 2 files changed, 4 insertions(+), 1 deletion(-) - -commit 25494311c5b8eb88d43df420ec91a1aedad20d05 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jun 15 17:44:23 2010 +0200 - - [glib] Add some G_UNLIKELY() - - glib/poppler-document.cc | 12 ++++++------ - glib/poppler-page.cc | 17 ++++++++++------- - 2 files changed, 16 insertions(+), 13 deletions(-) - -commit 52f133fb962256edb577b7f639c5c13221c6365d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jun 15 14:20:49 2010 +0200 - - [glib] Use g_slice for actions and destinations - - glib/poppler-action.cc | 21 +++++++++------------ - 1 file changed, 9 insertions(+), 12 deletions(-) - -commit f035c94d8b5b34c0c3bb47b8cfc2f9c720a4fc71 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jun 15 14:01:07 2010 +0200 - - [glib] Use g_slice_dup in _copy() function for iterators - - glib/poppler-document.cc | 9 +++------ - 1 file changed, 3 insertions(+), 6 deletions(-) - -commit c84f69681828c7e3b969f666f9b84f1531976c6f -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jun 15 13:57:18 2010 +0200 - - [glib] Use g_slice for mappings and PopplerRectangle - - glib/poppler-page.cc | 50 - ++++++++++++++++++-------------------------------- - 1 file changed, 18 insertions(+), 32 deletions(-) - -commit e12b9ab105f3b56b47ded871693b939ed421c853 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jun 15 13:49:27 2010 +0200 - - [glib] Use poppler_image_mapping_free() instead of g_free() - - glib/poppler-page.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit fb791a15f7472042fb2174e6f5df6924dd4eeb9b -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jun 15 13:37:52 2010 +0200 - - [glib] Remove poppler_mapping_free and use poppler_link_mapping_free - instead - - glib/poppler-page.cc | 9 +-------- - 1 file changed, 1 insertion(+), 8 deletions(-) - -commit 6186d7220e545eb89597626933a10acd0cd25173 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jun 15 13:16:59 2010 +0200 - - [glib] Use _new() methods instead of g_new() to create boxed structs - - glib/poppler-page.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 44639cb7b10ab6d66122ae2b6b7f3e5745f933bd -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jun 15 10:39:00 2010 +0200 - - [glib-demo] Use poppler_rectangle_free() instead of g_free() - - glib/demo/find.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 3ca304f3837af27ae49541a5f441d8729264a945 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Jun 14 19:16:41 2010 +0100 - - Add more caching to ObjectStreams - - Makes opening of file from bug 26759 ten times faster - - poppler/XRef.cc | 62 - ++++++++++++++++++++++++++++++++++++++++++++++++--------- - poppler/XRef.h | 4 ++-- - 2 files changed, 55 insertions(+), 11 deletions(-) - -commit cc2e5f190e19ee8169f67df2541302a2816873d3 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Jun 14 18:17:01 2010 +0200 - - [glib-demo] Support password protected documents - - glib/demo/main.c | 175 - +++++++++++++++++++++++++++++++++++++++++++++++++++++-- - 1 file changed, 170 insertions(+), 5 deletions(-) - -commit 34b2dbb6bbaf0189c92eea6b7924999ab2b6ad11 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Jun 14 17:41:51 2010 +0200 - - [glib-demo] Remove GLIB_CHECK_VERSION(), we already depend on - glib 2.18 - - glib/demo/attachments.c | 5 ----- - glib/demo/main.c | 32 +------------------------------- - 2 files changed, 1 insertion(+), 36 deletions(-) - -commit a52670a46c0561025d8b86cd2865603f0720c695 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jun 13 15:31:15 2010 +0100 - - do not distribute these two files - - they are generated on configure/cmake time and depend on the machine - - glib/Makefile.am | 7 +++---- - poppler/Makefile.am | 4 ++-- - 2 files changed, 5 insertions(+), 6 deletions(-) - -commit eb0206ba8458f1dba004ac7bef856dcbb2ccbba5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jun 9 18:56:16 2010 +0100 - - we need to ship these two files - - Bug 28458 - - Makefile.am | 2 ++ - 1 file changed, 2 insertions(+) - -commit 7dfdf1ee293b7d36a049a90d8a17462ed0e50f2c -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 8 21:54:52 2010 +0100 - - Typo-- - - utils/pdftoppm.1 | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 57cc04ee1a122794b338c0d9818dbdaea46a42d6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 8 21:49:40 2010 +0100 - - Add cropbox to the manpage - - utils/pdftoppm.1 | 3 +++ - 1 file changed, 3 insertions(+) - -commit f9e6cb9647981f7afbb20261b3ccedaf003657d2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 8 20:43:11 2010 +0100 - - 0.14.0 - - CMakeLists.txt | 4 ++-- - NEWS | 18 ++++++++++++++++++ - configure.ac | 4 ++-- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - 5 files changed, 24 insertions(+), 6 deletions(-) - -commit 963afdc39153fee69ecb939c98deeef4f64638de -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 8 20:29:58 2010 +0100 - - libpoppler-qt4.so.3.2.0 -> libpoppler-qt4.so.3.3.0 - - qt4/src/CMakeLists.txt | 2 +- - qt4/src/Makefile.am | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit c1629be8011f3bddbf619246090640d62136d521 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 8 20:23:00 2010 +0100 - - Increase soname as _PopplerActionMovie struct grew - - glib/CMakeLists.txt | 2 +- - glib/Makefile.am | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 5ef45b1e72aed88ece0905b1204edee641f3c8fc -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 8 19:35:20 2010 +0100 - - Do not exit when trying to allocate memory for the XRef fails - - See bug 28406 - - poppler/XRef.cc | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -commit e7a5e9f70ee1283a2ca6734552d905279c97989b -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jun 4 08:46:33 2010 +0100 - - a bit of docu - - poppler/Object.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 9ff4dab2558f7c2700fd7fcaccacdad9619dbdda -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jun 4 08:44:34 2010 +0100 - - Add support for unsigned integer numbers - - So files store their P as a 32 bit unsigned instead of as a 32 bit - signed, making us to overflow our objInt parsing and rejecting to open - the file, this patch introduces objUint that only happens when the - number is not real, does not fit in a 32 bit integer but still fits - in a - 32 bit unsigned integer - - poppler/Lexer.cc | 32 +++++++++++++++++++++++++------- - poppler/Object.cc | 5 ++++- - poppler/Object.h | 14 +++++++++++--- - poppler/SecurityHandler.cc | 22 ++++++++++++++++++++++ - 4 files changed, 62 insertions(+), 11 deletions(-) - -commit 41e9af7f505dbfbda36f6ac97df90f2a42ab3160 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 1 21:40:07 2010 +0100 - - If the document is not encrypted it is ok to print - - poppler/XRef.cc | 16 ++++++++++------ - 1 file changed, 10 insertions(+), 6 deletions(-) - -commit b15c793a8a58b17a7fe7b32c1037726e1e0e1bf0 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 1 20:57:16 2010 +0100 - - Check it is a stream, not that it is not none - - People is reporting aborts, e.g. KDE bug 240208 - but can not check if this really fixes it since he can not share the - document - - poppler/Lexer.h | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit a72c68117ba05f3934e2df227cdcaf53a375f0ce -Author: Pino Toscano <pino@kde.org> -Date: Fri May 28 18:11:02 2010 +0200 - - [cpp apidox] add a start of API documentation for the 'page' class - - cpp/poppler-page.cpp | 68 - ++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 68 insertions(+) - -commit acf7729e8e270e1b4b2a552272dc280ae6d7b352 -Author: Pino Toscano <pino@kde.org> -Date: Fri May 28 17:38:35 2010 +0200 - - [cpp] fix the font_iterator current page status - - cpp/poppler-font.cpp | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -commit 4e017ff24a01cbbf1b39eedc3d7697f8b180fdd9 -Author: Pino Toscano <pino@kde.org> -Date: Fri May 28 17:15:28 2010 +0200 - - [cpp apidox] add API documentation for the 'font_info' and - 'font_iterator' classes - - cpp/poppler-font.cpp | 71 - ++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 71 insertions(+) - -commit 2ff840b62e41e2fc98e9fcff7330f40216de58a5 -Author: Pino Toscano <pino@kde.org> -Date: Fri May 28 14:34:37 2010 +0200 - - [cpp] move the actual convert_date(const char*) implementation in - the detail - - this way it is possible to call it from inside poppler-cpp without - an implicit conversion to std::string - - cpp/poppler-document.cpp | 2 +- - cpp/poppler-embedded-file.cpp | 4 ++-- - cpp/poppler-global.cpp | 23 ++--------------------- - cpp/poppler-private.cpp | 25 +++++++++++++++++++++++++ - cpp/poppler-private.h | 2 ++ - 5 files changed, 32 insertions(+), 24 deletions(-) - -commit 8112e9111313eaded4cd2e89d0e67efb0f3e29db -Author: Pino Toscano <pino@kde.org> -Date: Fri May 28 13:13:50 2010 +0200 - - [cpp] add a time_type typedef - - ... defined as unsigned int, and use it all around - (it changes nothing for client code) - - cpp/poppler-document.cpp | 8 ++++---- - cpp/poppler-document.h | 2 +- - cpp/poppler-embedded-file.cpp | 4 ++-- - cpp/poppler-embedded-file.h | 4 ++-- - cpp/poppler-global.cpp | 4 ++-- - cpp/poppler-global.h | 4 +++- - 6 files changed, 14 insertions(+), 12 deletions(-) - -commit bc5bdb43b12437e00aaddc27a74b9ac4b6498446 -Author: Pino Toscano <pino@kde.org> -Date: Fri May 28 13:01:53 2010 +0200 - - use the proper type for iterating on a GooVector - - poppler/XRef.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 87128ab0dfec6be1a034361512ee41301b078831 -Author: Maciej Mrozowski <reavertm@gmail.com> -Date: Thu May 27 17:31:00 2010 +0200 - - [CMake] Do not force -O2, preserve compiler flags instead. - - cmake/modules/PopplerMacros.cmake | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 241c338facb45641ef1a271c904355a014bbf28d -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu May 27 20:37:55 2010 +0100 - - Allow quality & progressive mode to be utilised in JpegWriter - - goo/JpegWriter.cc | 15 +++++++++++++-- - goo/JpegWriter.h | 4 ++++ - splash/SplashBitmap.cc | 18 +++++++++--------- - splash/SplashBitmap.h | 4 ++++ - 4 files changed, 30 insertions(+), 11 deletions(-) - -commit 9eda6e8aaae412a9882141d1b5b8c7bf0c823c68 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue May 25 23:44:30 2010 +0100 - - Do not follow loops blindly - - Fixes crash in pdf in bug 28172 - - poppler/XRef.cc | 21 +++++++++++++++------ - poppler/XRef.h | 7 ++++--- - 2 files changed, 19 insertions(+), 9 deletions(-) - -commit bbee6e0c8c9b181f8d19c167c867d74a765685fb -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue May 25 23:13:38 2010 +0100 - - update copyright - - poppler/JBIG2Stream.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 80b72b9f2fd70395580205b8b176e0576e132cf5 -Author: Hib Eris <hib@hiberis.nl> -Date: Wed May 26 13:07:57 2010 +0200 - - [autotools] sync autotool build with cmake build - - In addition to commit 69c2cf76cef9c190ac07726f60f1dccd3df5cb6d - - poppler/poppler-config.h.in | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 30ea3ab8a1eecafb3366aef193910098fdb7ccc8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue May 25 23:07:56 2010 +0100 - - Fix crash when parsing pdf in bug 28170 - - This code is a can of crashing worms :-7 - - poppler/JBIG2Stream.cc | 23 ++++++++++++++++------- - 1 file changed, 16 insertions(+), 7 deletions(-) - -commit b5a9021037c4e6cbbfd622433f3de693d1f47671 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue May 25 20:00:57 2010 +0100 - - 0.13.4 - - CMakeLists.txt | 2 +- - NEWS | 16 ++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - glib/reference/tmpl/poppler-action.sgml | 5 +++++ - glib/reference/tmpl/poppler-annot.sgml | 18 ++++++++++++++++++ - glib/reference/tmpl/poppler-attachment.sgml | 3 +++ - glib/reference/tmpl/poppler-document.sgml | 5 +++++ - glib/reference/tmpl/poppler-enums.sgml | 17 +++++++++++++++++ - glib/reference/tmpl/poppler-features.sgml | 3 +++ - glib/reference/tmpl/poppler-form-field.sgml | 3 +++ - glib/reference/tmpl/poppler-layer.sgml | 4 ++++ - glib/reference/tmpl/poppler-page.sgml | 13 +++++++++++++ - glib/reference/tmpl/poppler-private.sgml | 3 +++ - glib/reference/tmpl/poppler.sgml | 6 ++++++ - glib/reference/tmpl/stamp-poppler-enums.sgml | 3 +++ - qt4/src/Doxyfile | 2 +- - 17 files changed, 103 insertions(+), 4 deletions(-) - -commit 57ab0ebe993d79fe551bba58e0a70d55d32828f8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed May 12 20:49:31 2010 +0100 - - better copyright - - poppler/strtok_r.cpp | 23 +++++++++++++++++++++++ - 1 file changed, 23 insertions(+) - -commit 69c2cf76cef9c190ac07726f60f1dccd3df5cb6d -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed May 12 20:47:25 2010 +0100 - - mingw does not provide strtok_r - - Copy the glibc implementation - - CMakeLists.txt | 1 + - poppler/Makefile.am | 1 + - poppler/poppler-config.h.cmake | 4 + - poppler/strtok_r.cpp | 189 - +++++++++++++++++++++++++++++++++++++++++ - 4 files changed, 195 insertions(+) - -commit 9e9b5e0d87a7450bd2223538673321ecec720c36 -Author: Marek Kasik <mkasik@redhat.com> -Date: Tue May 11 12:06:17 2010 +0200 - - Better check of overlapping of table cells when selecting text - - Add check for overlapping of upper right cell with lower left cell - of assumed table (related to #3188). - - poppler/TextOutputDev.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit a3e40b460b7690ef73ccf143b10da07e91d9ee7f -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon May 10 17:41:04 2010 +0200 - - [annots] Adjust bbox for line annots when y1 = y2 - - Some documents like pdf_commenting_new.pdf, have y1 = y2 but - line_width > 0, acroread renders the lines in such cases even - though the - annot bbox is empty. - - poppler/Annot.cc | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -commit e30d24c506a9ff742f8af5d6c71273abeddaa265 -Author: Pino Toscano <pino@kde.org> -Date: Tue May 4 15:19:26 2010 +0200 - - [cpp] ustring::{from,to}_utf8(): fix in/out buffer sizes - - cpp/poppler-global.cpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit aaa19a673020e12dbfceb4d25ade0ece7875fd83 -Author: Pino Toscano <pino@kde.org> -Date: Tue May 4 12:07:43 2010 +0200 - - [cpp] make the pkg-config files really working - - poppler-cpp.pc.cmake | 6 +++++- - poppler-cpp.pc.in | 6 +++++- - 2 files changed, 10 insertions(+), 2 deletions(-) - -commit 8f963ccde41ef1faa719254fccc5bdfe75e9fa87 -Author: Patrick Spendrin <ps_ml@gmx.de> -Date: Sun May 2 18:42:10 2010 +0200 - - Windows: define strtok_r as strtok_s - - poppler/poppler-config.h.cmake | 4 ++++ - poppler/poppler-config.h.in | 4 ++++ - 2 files changed, 8 insertions(+) - -commit c9d8df51c96e50ad72f7954baba2254259fc894c -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat May 1 19:52:51 2010 +0100 - - 2010 in these copyrights - - poppler/poppler-config.h.cmake | 2 +- - poppler/poppler-config.h.in | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 9ce71fb35fdd66c55872956432160a5c76a62080 -Author: Jakub Wilk <ubanus@users.sf.net> -Date: Sat May 1 19:50:54 2010 +0100 - - Use strtok_r instead strtok - - strtok is not thread safe - - fofi/FoFiType1.cc | 8 +++++--- - poppler/CharCodeToUnicode.cc | 6 ++++-- - poppler/GlobalParams.cc | 6 ++++-- - poppler/PDFDoc.cc | 4 +++- - poppler/UnicodeMap.cc | 21 ++++++++++++++++++--- - 5 files changed, 34 insertions(+), 11 deletions(-) - -commit 6b2983f89e87792a393880dab6dc1fedb748db2c -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Apr 30 14:48:50 2010 +0200 - - [cairo] Set device offset and matrix to smask depending on the - group target - - It seems to fix all of my test cases. Fixes bug #27208. - - poppler/CairoOutputDev.cc | 21 +++++++++++++++------ - 1 file changed, 15 insertions(+), 6 deletions(-) - -commit ac32021704178721ee007a6b6831283e323e500f -Author: Pino Toscano <pino@kde.org> -Date: Fri Apr 30 01:14:14 2010 +0200 - - demote the #warning to a simple FIXME comment - - poppler/ArthurOutputDev.cc | 4 +--- - 1 file changed, 1 insertion(+), 3 deletions(-) - -commit 8c1bc17552c989c15f318d9d109607a9a594ca6b -Author: Pino Toscano <pino@kde.org> -Date: Fri Apr 30 01:12:19 2010 +0200 - - MSVC: define fmax() and fmin() - - MSVC does not provide those functions, so we need to define them to - the existing max()/mix() macros. - Thanks to Patrick Spendrin for the hint! - - poppler/poppler-config.h.cmake | 5 +++++ - poppler/poppler-config.h.in | 5 +++++ - 2 files changed, 10 insertions(+) - -commit 71063d51a45835b0267a7e3f823ef49689cfd06f -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Apr 29 20:28:07 2010 +0200 - - Make sure we are drawing text before calling endTextObject() - - This is actually the right fix for the previous commit. - - poppler/Gfx.cc | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -commit e909219d8e92994bd52976f9676015fa6ca9fc91 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Apr 29 18:34:22 2010 +0200 - - Set textHaveCSPattern=false again before filling the pattern in - opEndText() - - Fixes cairo backend regressions caused by commit - ccf238b32e236f69c0507a5421ac2649dfa8d865. - - poppler/Gfx.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 29572d6ac7829b60efce2d8e489473c55e370f26 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 27 23:39:23 2010 +0100 - - fabs for doubles - - poppler/TextOutputDev.cc | 24 ++++++++++++------------ - 1 file changed, 12 insertions(+), 12 deletions(-) - -commit 4905e2bd764ea601e3bf9c5195c740e5bf186af5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 27 23:34:34 2010 +0100 - - fix include - - splash/SplashBitmap.cc | 1 + - 1 file changed, 1 insertion(+) - -commit f9f0e4b747a1527bd6354897cdba7954d58651de -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Apr 27 14:26:23 2010 +0200 - - Fix first color stop offset of linear gradients - - Fixes bug #27837. - - poppler/Gfx.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 5b822011029f3721fbafd4a7bf01b9d6fee35d25 -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 24 18:18:08 2010 +0200 - - include standard float.h instead of unportable values.h - - poppler/TextOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit dee7cb8691528293bb5b8f266970cdb6771e301b -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 24 15:39:23 2010 +0100 - - 0.13.3 - - CMakeLists.txt | 2 +- - NEWS | 31 +++++++++++++++++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - 5 files changed, 35 insertions(+), 4 deletions(-) - -commit 07864c9e2a7a32b48bdbab92c8b2f79bce1d9f5b -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 24 13:07:02 2010 +0100 - - minor cleanups - - utils/HtmlLinks.cc | 15 ++------------- - utils/HtmlLinks.h | 16 ++++++++++++++-- - 2 files changed, 16 insertions(+), 15 deletions(-) - -commit e501eabb2f0775444a2bf64005a3a3f1ffa281b4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 24 13:06:12 2010 +0100 - - Do not assume the parameter will have more than 5 chars - - utils/pdftohtml.cc | 30 ++++++++++++++++++------------ - 1 file changed, 18 insertions(+), 12 deletions(-) - -commit 6cc4d571339214e9eeeb682ba48fb220cef905f9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 24 13:04:05 2010 +0100 - - Fix end() to return the correct last valid value - - goo/GooVector.h | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 4ed53e30e735b79c46eab9d54883531c6e187b17 -Author: William Bader <williambader@hotmail.com> -Date: Fri Apr 23 22:52:24 2010 +0100 - - Silence some Illegal entry in bfrange block in ToUnicode CMap - - Fixes #27728 - - poppler/CharCodeToUnicode.cc | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -commit 16a004784043e2a8587c0c3c6d23889df8a80470 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Apr 22 19:39:01 2010 +0100 - - Avoid the usage of std:: - - poppler/TextOutputDev.cc | 25 +++++++++++-------------- - 1 file changed, 11 insertions(+), 14 deletions(-) - -commit a7dcb2b4ffee57b7f78529cbaeaab647ab93de86 -Author: Pino Toscano <pino@kde.org> -Date: Thu Apr 22 13:31:41 2010 +0200 - - Windows: include config.h in GlobalParamsWin.cc only if not included - already - - GlobalParamsWin.cc is not compiled standalone but only #include'd by - GlobalParams.cc (on Windows only), so config.h has already included - already - as safety check, check for PACKAGE_NAME (#define'd in config.h) - before #include'ing it again - - poppler/GlobalParamsWin.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit fba076e17af24a9c9883504282316bba119a908c -Author: Pino Toscano <pino@kde.org> -Date: Thu Apr 22 13:24:04 2010 +0200 - - avoid accidental max() macro replacement with some compilers (eg MSVC) - - defining an empty macro and using it between "max" and "(", such - compilers won't try to replace their macro max(a, b) there; in any - case, empty spaces are just fine - - poppler/TextOutputDev.cc | 11 +++++++---- - 1 file changed, 7 insertions(+), 4 deletions(-) - -commit ccf238b32e236f69c0507a5421ac2649dfa8d865 -Author: Thomas Freitag <Thomas.Freitag@alfa.de> -Date: Wed Apr 21 19:21:37 2010 +0100 - - Improve colorizing text and masks in pattern colorspace - - Bug #27482 - - poppler/Gfx.cc | 137 - ++++++++++++++++++++++----------------------- - poppler/Gfx.h | 4 +- - poppler/SplashOutputDev.cc | 41 ++++++++++++-- - poppler/SplashOutputDev.h | 3 +- - 4 files changed, 106 insertions(+), 79 deletions(-) - -commit 8e86dfb328d94939ecf390d34af533b831b2837b -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Apr 21 19:19:53 2010 +0100 - - Add copyright - - poppler/TextOutputDev.cc | 1 + - poppler/TextOutputDev.h | 1 + - 2 files changed, 2 insertions(+) - -commit 6f9f3d33ff8058e28243ba45b8547e21ad0d088a -Author: Andre Klapper <a9016009@gmx.de> -Date: Wed Apr 21 19:57:15 2010 +0200 - - [glib-demo] Compile with -DGSEAL_ENABLE - - Fixes bug #27579. - - glib/demo/images.c | 2 +- - glib/demo/layers.c | 4 ++-- - glib/demo/render.c | 8 ++++---- - 3 files changed, 7 insertions(+), 7 deletions(-) - -commit 6b14c18d60cae130869f9a5c7688dfe880602224 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Apr 21 19:56:49 2010 +0200 - - [cairo] Make sure we always use a new path in doPath() - - Fixes document - http://acroeng.adobe.com/Test_Files/images/transparency/Untitled-2.pdf - when rendering with cairo backend. - - poppler/CairoOutputDev.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 4f71d64c69500ed78daf4d797c8af6cfbd3d970e -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Apr 21 11:44:49 2010 +0200 - - [cairo] Fix pattern size when bbox is not at 0,0 - - poppler/CairoOutputDev.cc | 11 +++++++++-- - 1 file changed, 9 insertions(+), 2 deletions(-) - -commit 9c5612f6e013a8698eff6531ec388a7e6c1fb89a -Author: Marek Kasik <mkasik@redhat.com> -Date: Fri Feb 12 14:31:01 2010 +0100 - - Distinguish between columns and tables when selecting text - - This commit add ability to detect tables in text by checking borders - of 4 neighbouring text blocks for arrangement (to the left, to - the right, - center, ...). Detected border of whole table is then stored in - ExMin, ExMax, - EyMin and EyMax of each block together with id of detected - table. Sorting - of blocks is then performed on the these borders to be able to - distinguish - tables from columns. - Pasting of selected text was modified so that tables are pasted - correctly - (even with multi line cells). - - poppler/TextOutputDev.cc | 490 - +++++++++++++++++++++++++++++++++++++++++------ - poppler/TextOutputDev.h | 5 + - 2 files changed, 437 insertions(+), 58 deletions(-) - -commit db014ffb357e760d9397544c5a8fe747cdb497ab -Author: Brian Ewins <brian.ewins@gmail.com> -Date: Mon Nov 23 08:58:19 2009 +0000 - - Select top right to bottom left in RTL mode - - This makes pure RTL selection work. Bidi is not handled at all. - Rendering of the selection is poor and the dumped text appears - to still be in reverse order to me. - - poppler/TextOutputDev.cc | 57 - ++++++++++++++++++++++++++++++++++++------------ - 1 file changed, 43 insertions(+), 14 deletions(-) - -commit b1d43fa052d9160c4f319a67415ecf3ebf2cf9b3 -Author: Brian Ewins <brian.ewins@gmail.com> -Date: Sun Nov 22 09:47:40 2009 +0000 - - Make pdftotext newlines match copy and paste - - The output of pdftotext didn't insert line breaks, - resulting in jumbled text. Change the rules to - emit a newline at the end of each line unless - a hyphenation is being supressed, and an extra - newline at the end of each flow. - - poppler/TextOutputDev.cc | 17 +++-------------- - 1 file changed, 3 insertions(+), 14 deletions(-) - -commit f83b677a8eb44d65698b77edb13a5c7de3a72c0f -Author: Brian Ewins <brian.ewins@gmail.com> -Date: Thu Nov 12 02:50:29 2009 +0000 - - Use a reading-order sort to order blocks - - This switches the block sort from XY to reading order, - using the rules from T. Breuel's "High Performance - Document Layout Analysis". - - Signed-off-by: Brian Ewins <brian.ewins@gmail.com> - - poppler/TextOutputDev.cc | 164 - +++++++++++++++++++++++++++++++++++++++++++++-- - poppler/TextOutputDev.h | 8 +++ - 2 files changed, 167 insertions(+), 5 deletions(-) - -commit a2191a4d45e0abaec97c19aacae37c4c5824bd36 -Author: Brian Ewins <brian.ewins@gmail.com> -Date: Mon Nov 9 06:24:51 2009 +0000 - - Separate flow construction from reading order - - If the blocks were already in reading order, then - constructing flows is simplified, since blocks - cannot be picked out-of-order. Make this change - first in preparation for adding a reading-order - sort. - - Signed-off-by: Brian Ewins <brian.ewins@gmail.com> - - poppler/TextOutputDev.cc | 96 - +++++++++--------------------------------------- - 1 file changed, 17 insertions(+), 79 deletions(-) - -commit 345ed51af9b9e7ea53af42727b91ed68dcc52370 -Author: Brian Ewins <brian.ewins@gmail.com> -Date: Thu Oct 29 01:46:29 2009 +0000 - - Fix bug 3188, text selection across table cells - - Bug 3188. When selecting text, poppler goes across the whole - page then down, rather than across each cell, down that cell, - then across to the next cell. This leads to illegible paste - results. - - Teach TextPage to visit the selection in flow order rather than - block order. - - Signed-off-by: Brian Ewins <brian.ewins@gmail.com> - - poppler/TextOutputDev.cc | 334 - +++++++++++++++++++++++++---------------------- - 1 file changed, 178 insertions(+), 156 deletions(-) - -commit 12d83931ae1b899b70c7ea5c01f03f123b1bb9a8 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Apr 18 17:53:48 2010 +0200 - - [cairo] Check pattern status after setting matrix when rendering - images - - Fixes rendering of document attached to kde bug - http://bugs.kde.org/show_bug.cgi?id=135417. - - poppler/CairoOutputDev.cc | 34 ++++++++++++++++++++++++++++++++++ - 1 file changed, 34 insertions(+) - -commit ff6d501a2fc887fd49a985161f756d6d6b8e6c0d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Apr 18 17:51:42 2010 +0200 - - [cairo] Fix a crash when rendering 0x0 images - - See kde bug http://bugs.kde.org/show_bug.cgi?id=135417 - - poppler/CairoOutputDev.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 84cd2186861436fbaa7c29aa691e69fcd543a1c2 -Author: Hib Eris <hib@hiberis.nl> -Date: Tue Apr 13 23:42:28 2010 +0200 - - Properly initialize variable - - poppler/CachedFile.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 24f244f486f332b0bd76c6525c5d9d03168a76e6 -Author: Hib Eris <hib@hiberis.nl> -Date: Tue Apr 13 23:54:28 2010 +0200 - - pdftops: require output filename when reading from stdin - - utils/pdftops.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 955f9f53ff225f6794a494fdd0f0fe5ee1a41d88 -Author: Hib Eris <hib@hiberis.nl> -Date: Tue Apr 13 23:47:40 2010 +0200 - - pdftotext: require output filename when reading from stdin - - utils/pdftotext.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 31388aa8b5117619878431b7fed2d033000af541 -Author: Hib Eris <hib@hiberis.nl> -Date: Tue Apr 13 23:27:20 2010 +0200 - - pdftohtml: require output filename when reading from stdin - - utils/pdftohtml.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit a8d43ec1c7f5448a7f63d9bbd9062d56ee1c7c58 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Apr 14 19:21:33 2010 +0100 - - update XOPEN_SOURCE to 600 in non standard compile options - - it seems helps compiling on some BSD - - cmake/modules/PopplerMacros.cmake | 2 +- - configure.ac | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 4cce1f14e964edf1bf2d9fb8286ee002a67dc212 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 13 21:57:16 2010 +0100 - - include strings.h on non windows platforms - - poppler/GlobalParams.cc | 2 ++ - test/perf-test.cc | 2 ++ - 2 files changed, 4 insertions(+) - -commit 55c76069c52f9f51c6b8c60fe1aa8de499012ea8 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Apr 12 19:32:46 2010 +0200 - - [glib] Use existing cairo api when rendering to a pixbuf - - I should fix bug #5589 for the GDK api too. - - glib/poppler-page.cc | 227 - +++++++++++++++++++++------------------------------ - 1 file changed, 93 insertions(+), 134 deletions(-) - -commit 51aefe1423a068e8c119c21a8791d265aecbeaf5 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Apr 9 12:50:00 2010 +0200 - - [cairo] Implement colorizing image masks with pattern colorspace - - poppler/CairoOutputDev.cc | 9 +++++++++ - 1 file changed, 9 insertions(+) - -commit bd8f44289770175a17ac45e4788b0d374cc93d5a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Apr 9 12:02:38 2010 +0200 - - Partially revert "[cairo] Do not change device offset of mask surface" - - This partially reverts commit - a32f6f9ebaed3e4827b9dc6cb37e307c2798f521. - It fixed bug #27208, but it's causing regressions on other documents. - - poppler/CairoOutputDev.cc | 11 ++++++++++- - 1 file changed, 10 insertions(+), 1 deletion(-) - -commit bcb405c43fb7140f5d601d00de4d30913a0050ef -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Apr 8 12:02:48 2010 +0200 - - Pages were always created without forms by Catalog - - Use getForm() instead of form when creating a page object. - - poppler/Catalog.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit d46581c574b3088a82555cbc3b76e95e2571b9c0 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Apr 7 20:25:23 2010 +0100 - - Fix destructor - - poppler/Catalog.cc | 19 +++++++------------ - poppler/Catalog.h | 3 +-- - 2 files changed, 8 insertions(+), 14 deletions(-) - -commit ab14433f8b3d7c67f279cece65dfdd40c6675ac0 -Author: Hib Eris <hib@hiberis.nl> -Date: Thu Mar 25 15:33:33 2010 +0100 - - Parse Form on demand - - poppler/Catalog.cc | 21 +++++++++++++-------- - poppler/Catalog.h | 2 +- - 2 files changed, 14 insertions(+), 9 deletions(-) - -commit c72a2c7f70b13a7b7b531b3c983d9a9bc104bac7 -Author: Hib Eris <hib@hiberis.nl> -Date: Thu Mar 25 17:33:11 2010 +0100 - - Parse Names on demand - - poppler/Catalog.cc | 112 - +++++++++++++++++++++++++++++++++++++++++++---------- - poppler/Catalog.h | 18 ++++++--- - 2 files changed, 104 insertions(+), 26 deletions(-) - -commit 32053360c93607cf9bdc092257cefad5d4df9ec5 -Author: Hib Eris <hib@hiberis.nl> -Date: Thu Mar 25 16:32:22 2010 +0100 - - Parse Dests on demand - - poppler/Catalog.cc | 27 +++++++++++++++++++++------ - poppler/Catalog.h | 2 +- - 2 files changed, 22 insertions(+), 7 deletions(-) - -commit da0f8e69eecb944e128474f62829f729eeabd189 -Author: Hib Eris <hib@hiberis.nl> -Date: Thu Mar 25 16:48:07 2010 +0100 - - Parse Outline on demand in PDFDoc - - poppler/PDFDoc.cc | 17 ++++++++++++----- - poppler/PDFDoc.h | 2 +- - 2 files changed, 13 insertions(+), 6 deletions(-) - -commit d7a69c8cad112cb6616d0192d8a4028fdaee2f73 -Author: Hib Eris <hib@hiberis.nl> -Date: Thu Mar 25 16:05:02 2010 +0100 - - Parse Outline on demand - - poppler/Catalog.cc | 23 ++++++++++++++++++++--- - poppler/Catalog.h | 2 +- - 2 files changed, 21 insertions(+), 4 deletions(-) - -commit c149e027fa76824221a78fe6d3bf9bfe953491d4 -Author: Hib Eris <hib@hiberis.nl> -Date: Thu Mar 25 15:51:51 2010 +0100 - - Parse StructTreeRoot on demand - - poppler/Catalog.cc | 22 +++++++++++++++++++--- - poppler/Catalog.h | 2 +- - 2 files changed, 20 insertions(+), 4 deletions(-) - -commit 3c6effe44d6d97f175c2ee7f3913d8c4ba34d612 -Author: Hib Eris <hib@hiberis.nl> -Date: Thu Mar 25 14:55:22 2010 +0100 - - Parse Metadata on demand - - poppler/Catalog.cc | 16 +++++++++++++--- - 1 file changed, 13 insertions(+), 3 deletions(-) - -commit 749d67ea2346a3453ef41dc37ba59d419ad900b0 -Author: Hib Eris <hib@hiberis.nl> -Date: Thu Mar 25 15:09:58 2010 +0100 - - Parse PageLabelInfo on demand - - poppler/Catalog.cc | 37 +++++++++++++++++++++++++++++-------- - poppler/Catalog.h | 3 +++ - 2 files changed, 32 insertions(+), 8 deletions(-) - -commit 78f7d106714fa489a66c39410163a6902ba24856 -Author: Hib Eris <hib@hiberis.nl> -Date: Sat Mar 27 14:43:57 2010 +0100 - - Parse PageMode and PageLayout on demand - - poppler/Catalog.cc | 109 - ++++++++++++++++++++++++++++++++++++----------------- - poppler/Catalog.h | 11 ++++-- - 2 files changed, 81 insertions(+), 39 deletions(-) - -commit f5dd5be64d09186ee289632c1a61979d15edd605 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Apr 7 19:48:39 2010 +0200 - - Fix saving update docs that have a compressed xref table - - - Use the original xref table size as Size field in the trailer - dictionary to make sure size = maxObjId + 1 - - - Use the right generation number for compressed objects that which - must be 0. gen field in xref entry for compressed objects is the - index of the object in the stream, not the generation number. - - Fixes bug #27450. - - poppler/PDFDoc.cc | 9 ++++----- - 1 file changed, 4 insertions(+), 5 deletions(-) - -commit 3f302fdd78cd78873bf5376af84e83741a8daadb -Author: Pino Toscano <pino@kde.org> -Date: Tue Apr 6 23:58:46 2010 +0200 - - use a GooVector<bool> instead of a non-standard variable-length-array - - poppler/CachedFile.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 425a62b5fa8e4e69bfc1c64ed126b5baac06d78a -Author: Hib Eris <hib@hiberis.nl> -Date: Tue Apr 6 10:57:30 2010 +0200 - - pdfutils: fix deleting fileName - - utils/pdfinfo.cc | 2 +- - utils/pdftoabw.cc | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 198c9d61ba93ba62ea2da44a23cd948d43556c3e -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 6 22:00:14 2010 +0100 - - Use the topleft of the Rect of text annots to draw - - Not use the full rect when we are drawing "our" notes - - poppler/Annot.cc | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -commit 1422802f029483ad3e62a3a13e66b2d3990ac58f -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Apr 6 12:32:12 2010 +0200 - - [cairo] Use current fill_opacity when drawing soft masked images - - Fixes GNOME Bug https://bugzilla.gnome.org/show_bug.cgi?id=614915 - - poppler/CairoOutputDev.cc | 27 ++++++++++++++++++++------- - 1 file changed, 20 insertions(+), 7 deletions(-) - -commit c152d30f879e6cde45de58bb9249035e127e84e7 -Author: Hib Eris <hib@hiberis.nl> -Date: Mon Apr 5 18:55:29 2010 +0200 - - delete fileName in utils - - utils/pdftohtml.cc | 1 + - utils/pdftops.cc | 1 + - utils/pdftotext.cc | 1 + - 3 files changed, 3 insertions(+) - -commit f091c83414ab32a4ecf1fa2bd15f13a3cf113a86 -Author: Hib Eris <hib@hiberis.nl> -Date: Mon Apr 5 20:12:01 2010 +0100 - - add some docu - - poppler/CachedFile.h | 30 ++++++++++++++++++++++++++++++ - poppler/CurlPDFDocBuilder.h | 2 ++ - poppler/LocalPDFDocBuilder.h | 2 ++ - poppler/PDFDocBuilder.h | 9 +++++++++ - poppler/PDFDocFactory.h | 12 ++++++++++++ - poppler/StdinPDFDocBuilder.h | 2 ++ - 6 files changed, 57 insertions(+) - -commit fc071d800cb4329a3ccf898d7bf16b4db7323ad8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Apr 5 19:11:26 2010 +0100 - - Rework DCTStream error handling, should work better now - - Fixes bug 26280 - - poppler/DCTStream.cc | 35 ++++++++++++++--------------------- - poppler/DCTStream.h | 5 +++-- - utils/HtmlOutputDev.cc | 4 ++-- - 3 files changed, 19 insertions(+), 25 deletions(-) - -commit a9d801b2db20ecb08734ee5cdb703abf11994b6e -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Apr 5 16:55:02 2010 +0100 - - Make some paremeters const & to clearly show we just read them - - poppler/CachedFile.cc | 18 ++++++++++-------- - poppler/CachedFile.h | 8 +++++--- - poppler/CurlCachedFile.cc | 9 +++++---- - poppler/CurlCachedFile.h | 3 ++- - poppler/CurlPDFDocBuilder.cc | 9 +++++---- - poppler/CurlPDFDocBuilder.h | 5 +++-- - poppler/LocalPDFDocBuilder.cc | 15 ++++++++------- - poppler/LocalPDFDocBuilder.h | 5 +++-- - poppler/PDFDocBuilder.h | 5 +++-- - poppler/PDFDocFactory.cc | 7 ++++--- - poppler/PDFDocFactory.h | 3 ++- - poppler/StdinCachedFile.cc | 3 ++- - poppler/StdinCachedFile.h | 3 ++- - poppler/StdinPDFDocBuilder.cc | 7 ++++--- - poppler/StdinPDFDocBuilder.h | 5 +++-- - utils/pdffonts.cc | 4 ++-- - utils/pdfimages.cc | 4 ++-- - utils/pdfinfo.cc | 4 ++-- - utils/pdftoabw.cc | 4 ++-- - utils/pdftohtml.cc | 4 ++-- - utils/pdftoppm.cc | 2 +- - utils/pdftops.cc | 4 ++-- - utils/pdftotext.cc | 4 ++-- - 23 files changed, 76 insertions(+), 59 deletions(-) - -commit a04ee3ea6066c97d41fc40d5d97c600a1870855a -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Apr 5 16:50:58 2010 +0100 - - forgot my (C) - - poppler/Form.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ed723c8ac4a21a50d7d236cdcf7a635defd8dffb -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Apr 5 16:50:15 2010 +0100 - - The copy constructor of GooString never worked, so do not use it - - poppler/Form.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit a28be8e4009b86fdfd92da928def194225a736c6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Apr 5 16:49:06 2010 +0100 - - Add some const correctnes to GooString - - goo/GooString.cc | 12 ++++++------ - goo/GooString.h | 21 ++++++++++++--------- - 2 files changed, 18 insertions(+), 15 deletions(-) - -commit 46aee9e4d225b88a3dfd4afbe57259f337bb15d3 -Author: Hib Eris <hib@hiberis.nl> -Date: Mon Apr 5 14:36:09 2010 +0200 - - Use PDFDocFactory in utils - - utils/pdffonts.cc | 16 ++++++++-------- - utils/pdfimages.cc | 11 ++++++++++- - utils/pdfinfo.cc | 31 +++++++------------------------ - utils/pdftoabw.cc | 10 +++++++++- - utils/pdftohtml.cc | 10 +++++++++- - utils/pdftoppm.cc | 17 +++++++++++------ - utils/pdftops.cc | 9 ++++++++- - utils/pdftotext.cc | 14 +++++++------- - 8 files changed, 69 insertions(+), 49 deletions(-) - -commit d487a90688c4431075c9e4db040b3b02625e208f -Author: Hib Eris <hib@hiberis.nl> -Date: Mon Apr 5 14:35:52 2010 +0200 - - Add PDFDocFactory - - CMakeLists.txt | 2 ++ - poppler/Makefile.am | 2 ++ - poppler/PDFDocFactory.cc | 71 - ++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/PDFDocFactory.h | 42 ++++++++++++++++++++++++++++ - 4 files changed, 117 insertions(+) - -commit 869135920831fb0d15db734f3dcd7a67146cc241 -Author: Hib Eris <hib@hiberis.nl> -Date: Wed Feb 24 15:24:26 2010 +0100 - - Add CurlPDFDocBuilder - - CMakeLists.txt | 2 ++ - poppler/CurlPDFDocBuilder.cc | 46 - ++++++++++++++++++++++++++++++++++++++++++++ - poppler/CurlPDFDocBuilder.h | 30 +++++++++++++++++++++++++++++ - poppler/Makefile.am | 6 ++++-- - 4 files changed, 82 insertions(+), 2 deletions(-) - -commit ec5c6117a64f9cb03560091c4d7948d4287b6975 -Author: Hib Eris <hib@hiberis.nl> -Date: Thu Feb 25 11:23:28 2010 +0100 - - Add LocalPDFDocBuilder and StdinPDFDocBuilder - - CMakeLists.txt | 4 ++++ - poppler/LocalPDFDocBuilder.cc | 45 - +++++++++++++++++++++++++++++++++++++++++++ - poppler/LocalPDFDocBuilder.h | 30 +++++++++++++++++++++++++++++ - poppler/Makefile.am | 4 ++++ - poppler/StdinPDFDocBuilder.cc | 42 - ++++++++++++++++++++++++++++++++++++++++ - poppler/StdinPDFDocBuilder.h | 30 +++++++++++++++++++++++++++++ - 6 files changed, 155 insertions(+) - -commit 919b735d1c0b99bf72280aff8db87ba503954498 -Author: Hib Eris <hib@hiberis.nl> -Date: Sun Apr 4 11:05:35 2010 +0200 - - Add PDFDocBuilder - - CMakeLists.txt | 1 + - poppler/Makefile.am | 1 + - poppler/PDFDocBuilder.h | 32 ++++++++++++++++++++++++++++++++ - 3 files changed, 34 insertions(+) - -commit 1ab07faf05661d6d92186974c4b1c279b6178747 -Author: Hib Eris <hib@hiberis.nl> -Date: Sun Apr 4 11:29:53 2010 +0200 - - Add PDFDoc::ErrorPDFDoc - - poppler/PDFDoc.cc | 14 ++++++++++++++ - poppler/PDFDoc.h | 3 +++ - 2 files changed, 17 insertions(+) - -commit efc7e5efeddd8f70b7c74573d3194aba0a7d4631 -Author: Hib Eris <hib@hiberis.nl> -Date: Sun Apr 4 11:17:37 2010 +0200 - - Cleanup PDFDoc - - poppler/PDFDoc.cc | 40 +++++++++++++++------------------------- - poppler/PDFDoc.h | 3 ++- - 2 files changed, 17 insertions(+), 26 deletions(-) - -commit 08a3435e67ebf21beac2fefcbd21ad65f9293fd1 -Author: Hib Eris <hib@hiberis.nl> -Date: Tue Feb 23 02:29:26 2010 +0100 - - Add HTTP support using libcurl - - With libcurl, poppler can handle documents over http. - - CMakeLists.txt | 18 ++++++++ - config.h.cmake | 6 +++ - configure.ac | 16 +++++++ - poppler/CurlCachedFile.cc | 95 - ++++++++++++++++++++++++++++++++++++++++++ - poppler/CurlCachedFile.h | 39 +++++++++++++++++ - poppler/Makefile.am | 20 +++++++++ - poppler/poppler-config.h.cmake | 5 +++ - poppler/poppler-config.h.in | 5 +++ - utils/pdfinfo.cc | 16 ++++++- - 9 files changed, 219 insertions(+), 1 deletion(-) - -commit a87abf6ad9fb66d35a70c9412adc5d8ba2889b96 -Author: Hib Eris <hib@hiberis.nl> -Date: Wed Feb 24 14:46:59 2010 +0100 - - Use cached files to read from stdin in pdfinfo - - This fixes reading from stdin. - - utils/pdfinfo.cc | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -commit 958b04b14baf03c07492fa1cbd225d9968b9efc1 -Author: Hib Eris <hib@hiberis.nl> -Date: Tue Feb 23 02:02:10 2010 +0100 - - Add support for reading a cached file from stdin - - CMakeLists.txt | 2 ++ - poppler/Makefile.am | 2 ++ - poppler/StdinCachedFile.cc | 37 +++++++++++++++++++++++++++++++++++++ - poppler/StdinCachedFile.h | 26 ++++++++++++++++++++++++++ - 4 files changed, 67 insertions(+) - -commit 9539f75bd06150a3868209c5b04a75f5253722cc -Author: Hib Eris <hib@hiberis.nl> -Date: Sat Apr 3 15:08:20 2010 +0200 - - Add support for cached files - - CMakeLists.txt | 2 + - poppler/CachedFile.cc | 246 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/CachedFile.h | 113 +++++++++++++++++++++++ - poppler/Makefile.am | 2 + - poppler/Stream.cc | 102 +++++++++++++++++++++ - poppler/Stream.h | 58 ++++++++++++ - 6 files changed, 523 insertions(+) - -commit 8c6aefb8aa8929b9c47791d3062ed3ac8512626f -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Apr 4 16:08:12 2010 +0200 - - [lexer] Correctly parse numbers with '+' sign - - See GNOME Bug: https://bugzilla.gnome.org/show_bug.cgi?id=614549 - - poppler/Lexer.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit ab5044e451e3714d385295f0b4ce9a15c8f2562c -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Apr 4 12:32:42 2010 +0100 - - Add the -o[dd] and -e[ven] options to pdftoppm - - I've been using this patch forever and it's a pain to apply and - unapply - it each time - - utils/pdftoppm.1 | 6 ++++++ - utils/pdftoppm.cc | 8 ++++++++ - 2 files changed, 14 insertions(+) - -commit 0e371fb628a7e7d0cc1656e6405af4c97dbebf5d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Apr 4 12:30:34 2010 +0100 - - Fix my roll optimization - - Thanks Carlos for noticing - - poppler/Function.cc | 12 +++++++----- - 1 file changed, 7 insertions(+), 5 deletions(-) - -commit a32f6f9ebaed3e4827b9dc6cb37e307c2798f521 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Mar 28 18:43:14 2010 +0200 - - [cairo] Do not change device offset of mask surface - - Also call cairo_paint() after set_source_rgb() to paint the - background. - Fixes bug #27208. - - poppler/CairoOutputDev.cc | 13 ++----------- - 1 file changed, 2 insertions(+), 11 deletions(-) - -commit efa5d9544d29252e3df36cc4e65c3d880b3c5172 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Mar 27 22:11:49 2010 +0000 - - remove empty section - - NEWS | 2 -- - 1 file changed, 2 deletions(-) - -commit 5722df7a5387e43ec73f659ca58d2d07b9c4be3b -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Mar 27 22:04:43 2010 +0000 - - poppler 0.13.2 - - CMakeLists.txt | 2 +- - NEWS | 39 +++++++++++++++++++++++++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - 5 files changed, 43 insertions(+), 4 deletions(-) - -commit b82fd707747b9d87ebf3c8f7ce5ab70ccdf82809 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Mar 27 22:00:58 2010 +0000 - - gtk-doc changes - - glib/reference/tmpl/poppler-action.sgml | 7 +++---- - glib/reference/tmpl/poppler-annot.sgml | 9 --------- - glib/reference/tmpl/poppler-private.sgml | 10 ++++++++++ - glib/reference/tmpl/poppler-unused.sgml | 8 ++++++++ - glib/reference/tmpl/poppler.sgml | 10 ++++++++++ - 5 files changed, 31 insertions(+), 13 deletions(-) - -commit ed0354be4eac615b80e7a868984cc527853788b4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Mar 27 21:44:59 2010 +0000 - - some forgotten copyrights - - qt/poppler-page.cc | 2 +- - qt4/src/poppler-document.cc | 2 +- - qt4/src/poppler-movie.cc | 3 ++- - qt4/src/poppler-page.cc | 2 +- - 4 files changed, 5 insertions(+), 4 deletions(-) - -commit 2aedeedf9ef2e2d3eb17bc36d728e68c2f7af762 -Author: Hib Eris <hib@hiberis.nl> -Date: Sat Mar 27 14:38:27 2010 +0000 - - Correctly initialize actualText - - poppler/TextOutputDev.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit b53f9b203598555d6d706c3804aba013b8566921 -Author: Jan Engelhardt <jengelh@medozas.de> -Date: Sat Mar 27 13:23:42 2010 +0000 - - make qt3 detection use pkgconfig - - m4/qt.m4 | 101 - +++++---------------------------------------------------- - qt/Makefile.am | 4 +-- - 2 files changed, 10 insertions(+), 95 deletions(-) - -commit 320d4cee46e108498440179d8f9eab22cd5383d9 -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 24 21:51:58 2010 +0100 - - Revert "no more needed" - - This reverts commit 24d6bc8c78cb3148db2098ae4d69bd744340cf52. - It is actually needed. - - cpp/tests/CMakeLists.txt | 1 + - 1 file changed, 1 insertion(+) - -commit af21b5ab366bfdda203c26a77f4ae6ed0e70f64e -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 23 00:13:21 2010 +0100 - - [CMake] remove the (now) unneeded stuff from Find{GLIB,GDK,GTK}.cmake, - and search for them - - this way each bit (GLIB, GDK, and GTK) can be enabled/disabled - independently from the others - - CMakeLists.txt | 4 +++- - cmake/modules/FindGDK.cmake | 14 +------------- - cmake/modules/FindGLIB.cmake | 14 +------------- - cmake/modules/FindGTK.cmake | 14 +------------- - 4 files changed, 6 insertions(+), 40 deletions(-) - -commit 9b93ed5ce6712ec4cdf58148628e95685c289ef5 -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 23 00:02:27 2010 +0100 - - [CMake] copy FindGTK.cmake as FindGLIB.cmake and FindGDK.cmake - - this way FindGTK.cmake can be split in the various parts - - cmake/modules/FindGDK.cmake | 34 ++++++++++++++++++++++++++++++++++ - cmake/modules/FindGLIB.cmake | 34 ++++++++++++++++++++++++++++++++++ - 2 files changed, 68 insertions(+) - -commit 0ec21cae0b4623644c3efca1d2836a9f38f25737 -Author: Pino Toscano <pino@kde.org> -Date: Mon Mar 22 22:11:04 2010 +0100 - - [Qt] add the unhandled cases for 'actionOCGState' - - qt/poppler-page.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 5211e09595135b8e6c68efd1b8b689b518092b84 -Author: Pino Toscano <pino@kde.org> -Date: Mon Mar 22 22:07:44 2010 +0100 - - [CMake/cpp] move the BUILD_CPP_TESTS option to the main CMakeLists.txt - - CMakeLists.txt | 1 + - cpp/tests/CMakeLists.txt | 3 --- - 2 files changed, 1 insertion(+), 3 deletions(-) - -commit 24d6bc8c78cb3148db2098ae4d69bd744340cf52 -Author: Pino Toscano <pino@kde.org> -Date: Mon Mar 22 22:00:55 2010 +0100 - - no more needed - - cpp/tests/CMakeLists.txt | 1 - - 1 file changed, 1 deletion(-) - -commit a07ef8f703ab896f89ed211a5780e4a669b04fc7 -Author: Pino Toscano <pino@kde.org> -Date: Mon Mar 22 22:00:15 2010 +0100 - - [CMake] revert addition of "-Wl,--no-add-needed" to the link flags, - if available - - for now it is safer without it - - cmake/modules/PopplerMacros.cmake | 6 ------ - 1 file changed, 6 deletions(-) - -commit 86debcc9bba28a7c86f01ca9e63bde5fcd541846 -Author: Pino Toscano <pino@kde.org> -Date: Mon Mar 22 21:49:22 2010 +0100 - - [CMake] add "-ansi" to the CXXFLAGS only on Linux - - cmake/modules/PopplerMacros.cmake | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -commit 0819acd52a2ce74f0e176626d7b2233e10232d53 -Merge: c4ddbe8 92738eb -Author: Pino Toscano <pino@kde.org> -Date: Mon Mar 22 21:43:01 2010 +0100 - - Merge branch 'master' of ssh://git.freedesktop.org/git/poppler/poppler - -commit 92738ebb8a9c7cfc879aae59c2cbdf3159f03cd3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Mar 22 20:28:15 2010 +0000 - - Add a search overload that takes doubles - - QRectF is evil and is float in some arch and causes search to loop - infinitely because of double->float conversion - - qt4/src/poppler-page.cc | 22 +++++++++++++++------- - qt4/src/poppler-qt4.h | 16 ++++++++++++++-- - 2 files changed, 29 insertions(+), 9 deletions(-) - -commit 0a895f14c8125c5de7b97e8e799459c431eb51cb -Author: Thomas Freitag <Thomas.Freitag@alfa.de> -Date: Mon Mar 22 19:03:54 2010 +0000 - - correctly initialize the grayscale softmask color - - Fixes file with sha1sum e6e1576803a1bd74ad822eebbd750ee7b8357d25 - - poppler/SplashOutputDev.cc | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -commit c4ddbe89df9e48343a9606728b7c182080d87ece -Author: Patrick Spendrin <ps_ml@gmx.de> -Date: Sat Mar 20 21:55:17 2010 +0100 - - [CMake] when the conf configuration backend is "win32", set the - required Internet Explorer version to 5.0 - - ... as done with autotools as well - - CMakeLists.txt | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit 97da1f9d060493d9fb54a20e980c3f6e2b82c97e -Author: Pino Toscano <pino@kde.org> -Date: Sat Mar 20 17:51:07 2010 +0100 - - [CMake] check whether a link flag is supported before adding it to - the link flags - - this way we can add -Wl,--as-needed and -Wl,--no-add-needed only if - the current GCC/LD supports them - - cmake/modules/PopplerMacros.cmake | 23 ++++++++++++++++++++--- - 1 file changed, 20 insertions(+), 3 deletions(-) - -commit 223bce6d14e632f457a81b2ec091fe16369d2eb6 -Author: Pino Toscano <pino@kde.org> -Date: Sat Mar 20 14:08:58 2010 +0100 - - [CMake] with GCC, pass --as-needed and --no-add-needed to the linker - - --as-needed allows to avoid overlinking, linking only to the libraries - whose symbols are actually used - --no-add-needed makes the linker not use the NEEDED libraries - automatically, so we have to always make sure we specify all the - libraries actually used in a exe/lib - - cmake/modules/PopplerMacros.cmake | 4 ++++ - 1 file changed, 4 insertions(+) - -commit fc761f0d385708daaef1b95968532795b04f11b0 -Author: Pino Toscano <pino@kde.org> -Date: Sat Mar 20 14:05:59 2010 +0100 - - [CMake] poppler-dump uses parseargs.c which uses the poppler core API, - so it must link to it - - cpp/tests/CMakeLists.txt | 1 + - 1 file changed, 1 insertion(+) - -commit a210440b05d14efc53224a10e8b3ac7d508043b5 -Author: Pino Toscano <pino@kde.org> -Date: Sat Mar 20 14:04:02 2010 +0100 - - [CMake] poppler-glib uses the freetype API, so it must explicitly - link to it - - glib/CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit f5d352666b92cee0390470d7b892ec8dcbf046a5 -Author: Pino Toscano <pino@kde.org> -Date: Sat Mar 20 14:03:19 2010 +0100 - - [CMake] pdftoabw uses the libxml2 API, so it must explicitly link - to it - - utils/CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 3fc2c4affe825f4aabcee161ec794338bd359403 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Mar 18 13:52:52 2010 +0100 - - [glib] Use g_slice_new/free instead of g_new/free to alloc/free - iterators - - glib/poppler-document.cc | 27 +++++++++++++-------------- - 1 file changed, 13 insertions(+), 14 deletions(-) - -commit 7bd6a8558646983669ce699f83d5ed42d7fce476 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Mar 18 13:34:03 2010 +0100 - - [glib] Move find_annot_movie_for_action() from page to action - - And remove _poppler_action_movie_set_movie(). - - glib/poppler-action.cc | 93 - ++++++++++++++++++++++++++++++++++++++++++++------ - glib/poppler-page.cc | 79 ------------------------------------------ - glib/poppler-private.h | 2 -- - 3 files changed, 82 insertions(+), 92 deletions(-) - -commit e5e3d310aa488638431dd85ac3383a12056674bf -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Mar 18 12:20:26 2010 +0100 - - Update copyright header - - poppler/Link.cc | 2 +- - poppler/Link.h | 1 + - 2 files changed, 2 insertions(+), 1 deletion(-) - -commit c76870178a031e437de3f9ed7baa64efb96955d6 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Mar 18 12:13:36 2010 +0100 - - [glib-demo] OCG State Actions demo - - glib/demo/utils.c | 64 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 64 insertions(+) - -commit 456e42f91dfbf73b71a5dbdde13d7ccdb5637d79 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Mar 18 12:12:51 2010 +0100 - - [glib] Add support for OCG State actions - - glib/poppler-action.cc | 125 - +++++++++++++++++++++++++++++++++++++++++++++++++ - glib/poppler-action.h | 25 +++++++++- - glib/poppler.h | 1 + - 3 files changed, 150 insertions(+), 1 deletion(-) - -commit 4b109899e0732bbf65cacd875829e869e61eda48 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Mar 18 12:10:19 2010 +0100 - - [glib] Make get_layer_rbgroup() and get_layers() doc funcs public - for internal use - - glib/poppler-document.cc | 12 ++++++------ - glib/poppler-private.h | 3 +++ - 2 files changed, 9 insertions(+), 6 deletions(-) - -commit 38a55f6118debf994ce1fc41e987b0e3766047ba -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Mar 18 12:08:30 2010 +0100 - - Add support for Set-OCG-State actions - - Fixes bug #23522. - - poppler/Link.cc | 80 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Link.h | 31 ++++++++++++++++++++++ - 2 files changed, 111 insertions(+) - -commit bf398e53b0823d0a6272679858b67c5ffd704425 -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 17 23:06:44 2010 +0100 - - [CMake] fix pkg-config executable variable name - - CMakeLists.txt | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit ab1a37666704d6b15c19b694ee191327847c23da -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 17 23:04:01 2010 +0100 - - [CMake] proper way of looking for pkg-config - - cmake/modules/FindGTK.cmake | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 7f07a7dcea031f99a9a6d7c424184a2e69ee0062 -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 17 22:58:08 2010 +0100 - - [CMake] update FindFontconfig.cmake with a more recent version - - ... present in KDE (as before) - - cmake/modules/FindFontconfig.cmake | 15 +++++++++------ - 1 file changed, 9 insertions(+), 6 deletions(-) - -commit beee143ffbdc699ab19f10a01e5747200ea1927a -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 17 18:36:32 2010 +0100 - - [CMake] set the LINK_INTERFACE_LIBRARIES for the poppler and - poppler-cpp libraries - - this should reduce the libraries linked by frontends and utility - applications - - CMakeLists.txt | 1 + - cpp/CMakeLists.txt | 1 + - 2 files changed, 2 insertions(+) - -commit 5ab791cb2a029edcde84b00a47165adfe4d98a98 -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 17 16:39:38 2010 +0100 - - [CMake] small cleanups in FindGTK.cmake - - - update the header will all the stuff found and the variables set - - add my copyright for this year - - remove no more useful UsePkgConfig inclusion - - cmake/modules/FindGTK.cmake | 17 ++++++++++++----- - 1 file changed, 12 insertions(+), 5 deletions(-) - -commit fcbc76d82e3059c8288fbdc8da117ac9b38a70f2 -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 17 16:36:41 2010 +0100 - - [CMake] switch gtk2 (gtk+, gdk-pixbuf, gthread, gio) search to use - the new pkg_check_modules() way - - cmake/modules/FindGTK.cmake | 27 ++------------------------- - 1 file changed, 2 insertions(+), 25 deletions(-) - -commit 5b8135e0899aa3578045eca40940a3495c48d895 -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 17 16:27:40 2010 +0100 - - [CMake] link poppler-glib to the gdk2 libraries, if gdk2 was found - - glib/CMakeLists.txt | 3 +++ - 1 file changed, 3 insertions(+) - -commit 3dc4979d72048e81ae3b2d60dab11e791ac95696 -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 17 16:26:04 2010 +0100 - - [CMake] switch gdk2 search to use the new pkg_check_modules() way - - cmake/modules/FindGTK.cmake | 13 +------------ - 1 file changed, 1 insertion(+), 12 deletions(-) - -commit 0ef3d899cb8dea75c97ae1038cac5006f97bc0d2 -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 17 16:05:07 2010 +0100 - - [CMake] switch glib2 search to use the new pkg_check_modules() way - - cmake/modules/FindGTK.cmake | 18 ++---------------- - 1 file changed, 2 insertions(+), 16 deletions(-) - -commit d2dc83cb8de481e44ea584eee77881978af920fa -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 17 15:56:16 2010 +0100 - - [CMake] rename GLIB_VERSION to GLIB_REQUIRED - - this way it matches autotools, and it is going to not conflict with - my next changes - - CMakeLists.txt | 4 ++-- - cmake/modules/FindGTK.cmake | 2 +- - 2 files changed, 3 insertions(+), 3 deletions(-) - -commit 34accfe27305cae18e09243ab2a607287b86fa47 -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 17 13:55:09 2010 +0100 - - [CMake] set all the definitions for poppler-glib in a single place - - glib/CMakeLists.txt | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 3d93daf50c61019ca70f42e7ccf33897800b262a -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 17 13:49:22 2010 +0100 - - [CMake] no need to check for BUILD_GTK_TESTS for single tests - - poppler_add_test(... BUILD_GTK_TESTS ...) takes care of that already - - glib/CMakeLists.txt | 4 ++-- - test/CMakeLists.txt | 4 ++-- - 2 files changed, 4 insertions(+), 4 deletions(-) - -commit 946a11345d01d39538d22114e50aa3e179059883 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 15 20:24:25 2010 +0100 - - [build] Update cmake files - - CMakeLists.txt | 2 ++ - glib/CMakeLists.txt | 4 ++++ - 2 files changed, 6 insertions(+) - -commit 922c0fe392ba439453edb5b2e88b74f0caa586b3 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 15 20:08:23 2010 +0100 - - [glib-demo] Rendition actions demo - - glib/demo/utils.c | 112 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 112 insertions(+) - -commit 163b3f79d67543bc37b64875e30dcc9b7053e1d5 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 15 20:08:00 2010 +0100 - - [glib] Add support for rendition actions - - glib/poppler-action.cc | 22 ++++++++++++++++++++++ - glib/poppler-action.h | 14 +++++++++++++- - 2 files changed, 35 insertions(+), 1 deletion(-) - -commit d9b1e40751beddf48a8694b20bfcc4b4cb41060a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 15 20:06:45 2010 +0100 - - [glib] Add PopplerMedia representing a Rendition Media Clip - - glib/Makefile.am | 2 + - glib/poppler-media.cc | 302 - +++++++++++++++++++++++++++++++++++++++++++++++++ - glib/poppler-media.h | 53 +++++++++ - glib/poppler-private.h | 2 + - glib/poppler.h | 2 + - 5 files changed, 361 insertions(+) - -commit 0224b81c4729a98a56b7a68054422ea655018d6a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 15 17:54:03 2010 +0100 - - [glib-demo] Add page number to annots demo - - glib/demo/annots.c | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 0153b892c63e4fccd0819150cf7b4213857a11c5 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 15 17:49:51 2010 +0100 - - [glib] Add poppler_annot_get_page_index() to get the page associated - to annot - - glib/poppler-annot.cc | 19 +++++++++++++++++++ - glib/poppler-annot.h | 1 + - 2 files changed, 20 insertions(+) - -commit b47337ea91696fea8f42a68a6fa160681ab284b2 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 15 17:49:17 2010 +0100 - - [annots] Checks screen annots associated with a rendition action - have a valid page ref - - poppler/Annot.cc | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit 9417fd793ec8d806822669aa614193073e7dfe50 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 15 16:52:30 2010 +0100 - - [annots] Save page index of the page associated with the annot - - poppler/Annot.cc | 14 +++++--------- - poppler/Annot.h | 4 ++-- - 2 files changed, 7 insertions(+), 11 deletions(-) - -commit 36b76a5d01b74c6381433b6f6f7ffb9f02696a60 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 15 14:12:11 2010 +0100 - - Rework LinkRendition to follow the spec - - poppler/Link.cc | 68 - +++++++++++++++++++++++++++++++++++---------------------- - poppler/Link.h | 12 ++++++---- - 2 files changed, 50 insertions(+), 30 deletions(-) - -commit 7b5885ee7d2026df9a6e87327b6d02f37d79b8b2 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 15 12:25:12 2010 +0100 - - [glib-demo] Annot screen demo - - glib/demo/annots.c | 17 +++++++++++++++++ - 1 file changed, 17 insertions(+) - -commit bdb76c7cb89bcb6fb139b0ef348d96b7780d57ed -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 15 12:24:19 2010 +0100 - - [glib] Add support for screen annotation - - Based on patch by Sam Kaplan. - - glib/poppler-annot.cc | 75 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - glib/poppler-annot.h | 8 ++++++ - glib/poppler-page.cc | 3 ++ - glib/poppler-private.h | 1 + - glib/poppler.h | 1 + - 5 files changed, 88 insertions(+) - -commit 54892b1375e360113432b07c6ba058f861d21fe8 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 15 12:21:30 2010 +0100 - - [annots] Save the action already parsed in AnnotScreen - - poppler/Annot.cc | 9 +++++++-- - poppler/Annot.h | 5 +++-- - 2 files changed, 10 insertions(+), 4 deletions(-) - -commit 5a84a2d749478f19631dbfad2be06ec4ea85038c -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 15 11:16:17 2010 +0100 - - [glib-demo] Annot and links movie demo - - glib/demo/annots.c | 20 ++++++++++ - glib/demo/utils.c | 115 - ++++++++++++++++++++++++++++++++++++++++++++++++++++- - glib/demo/utils.h | 3 ++ - 3 files changed, 137 insertions(+), 1 deletion(-) - -commit 2cf5ee4f62089df099f78cd4d39a4eb7589d1b47 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 15 11:04:17 2010 +0100 - - [glib] Add support for movie actions - - Based on patch by Hugo Mercier. - - glib/poppler-action.cc | 35 ++++++++++++++++++---- - glib/poppler-action.h | 15 ++++++++-- - glib/poppler-page.cc | 81 - +++++++++++++++++++++++++++++++++++++++++++++++++- - glib/poppler-private.h | 2 ++ - 4 files changed, 125 insertions(+), 8 deletions(-) - -commit 132b6f072fefd231d42f31626f1b5009c4e8319e -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 15 10:56:23 2010 +0100 - - [glib] Add support for movie annotations - - Based on patch by Hugo Mercier. - - glib/poppler-annot.cc | 97 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - glib/poppler-annot.h | 10 ++++++ - glib/poppler-page.cc | 3 ++ - glib/poppler-private.h | 1 + - glib/poppler.h | 1 + - 5 files changed, 112 insertions(+) - -commit aecad2bb12be44825d273e364ec6a0444dac5605 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 15 10:48:03 2010 +0100 - - [glib] Add PopplerMovie class - - glib/Makefile.am | 2 + - glib/poppler-movie.cc | 140 - +++++++++++++++++++++++++++++++++++++++++++++++++ - glib/poppler-movie.h | 42 +++++++++++++++ - glib/poppler-private.h | 2 + - glib/poppler.h | 2 + - 5 files changed, 188 insertions(+) - -commit 5b3234a16e0d465bff2b5e277cb64b4f4b0a8dbd -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Mar 14 16:10:26 2010 +0100 - - Split Movie class into Rendition and Movie classes to follow the spec - - poppler/Annot.cc | 16 +- - poppler/Link.cc | 10 +- - poppler/Link.h | 6 +- - poppler/Makefile.am | 2 + - poppler/Movie.cc | 438 - +++++------------------------------------------ - poppler/Movie.h | 138 +++------------ - poppler/Rendition.cc | 400 - +++++++++++++++++++++++++++++++++++++++++++ - poppler/Rendition.h | 157 +++++++++++++++++ - qt4/src/poppler-movie.cc | 9 +- - 9 files changed, 657 insertions(+), 519 deletions(-) - -commit f9c163730478e3b6d8a1e73dbae6c52c28ae1e84 -Author: Pino Toscano <pino@kde.org> -Date: Mon Mar 8 14:49:12 2010 +0100 - - [Qt4] include Object.h and Annot.h, now needed - - qt4/src/poppler-movie.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit a00532f509c19c5455e0db5068db95dd4583e8dd -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 8 14:22:53 2010 +0100 - - Check for Null instead of None to know whether a dict entry is present - - Dict::lookup returns obj->initNull() when the key is not found. - - poppler/Movie.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit b51e66c9a7e2f7f39ae1edf8bda02a7bc1ad4ebd -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 8 14:15:22 2010 +0100 - - [annots] Create appearance stream for Movie Annotations when not - defined - - See bug #23108 - - poppler/Annot.cc | 103 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++- - poppler/Annot.h | 4 ++- - 2 files changed, 105 insertions(+), 2 deletions(-) - -commit fae59411852e5c2c45825c5ea963318f1ed5dc6a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 8 14:07:09 2010 +0100 - - Fix handling of poster in Movie - - Poster is not always a stream, it can be a boolean too. Also, get the - reference when available instead of fetching the stream. - - poppler/Movie.cc | 25 ++++++++++++------------- - poppler/Movie.h | 6 ++++-- - 2 files changed, 16 insertions(+), 15 deletions(-) - -commit a451f83d101bf265a1e7e2a17c0b320895e70f4e -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Mar 7 12:22:57 2010 +0100 - - Save width, height (aspect) in Movie object and provide getAspect() - method - - poppler/Movie.cc | 3 ++- - poppler/Movie.h | 4 ++++ - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit f88d469f860da17055fc4b98b64aef241fcf0185 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Mar 6 12:33:40 2010 +0100 - - Move Movie objects parsing code from Annot to Movie - - poppler/Annot.cc | 244 - ++------------------------------------------- - poppler/Annot.h | 73 +------------- - poppler/Link.cc | 4 +- - poppler/Movie.cc | 255 - +++++++++++++++++++++++++++++++++++++++-------- - poppler/Movie.h | 25 +++-- - qt4/src/poppler-movie.cc | 11 +- - 6 files changed, 246 insertions(+), 366 deletions(-) - -commit ec9138b574c7226ad733880d3d43b86bb72073f4 -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 23:17:50 2010 +0100 - - [autotools] add also cpp/tests/CMakeLists.txt to the "dist files" - - Makefile.am | 1 + - 1 file changed, 1 insertion(+) - -commit ef3258d6fc57e7a62d951cc826804e50e8e1b526 -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 23:14:12 2010 +0100 - - [autotools] fix location of poppler-config.h.cmake - - Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit fd1d9c882997ff35acd5a458e9dfeba3ad6c8b25 -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 22:42:06 2010 +0100 - - [CMake] just enable what needed each time - - CMakeLists.txt | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 476bde472a7e694afde96a04ea335fe9582d6fad -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 22:39:45 2010 +0100 - - [CMake] add small description for the zlib option - - taken from two bits in configure.ac - - CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 1267d7e0c36e262984070a3b55fea46e7289a4b4 -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 19:34:03 2010 +0100 - - [CMake] add a note about gtk-doc not supported yet - - CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 201b18ad0837e84d874b56e1b0469d1b2d45378b -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 19:30:36 2010 +0100 - - [CMake] sync with poppler-config.h.in: add - WITH_FONTCONFIGURATION_{FONTCONFIG,WIN32} - - poppler/poppler-config.h.cmake | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -commit 0d0044e8cc2d406f066338102ec73e1b56214cc3 -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 19:25:27 2010 +0100 - - [CMake] move poppler-config.h.cmake in the poppler subdirectory, - where poppler-config.h.in is - - CMakeLists.txt | 2 +- - poppler-config.h.cmake | 90 - ------------------------------------------ - poppler/poppler-config.h.cmake | 90 - ++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 91 insertions(+), 91 deletions(-) - -commit f785e29a901d2c76204dd26e9585446fdd817ebd -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 18:35:34 2010 +0100 - - [CMake] remove the generated poppler-enums.{c,h} in the clean target - - ie usually when doing `make clean' - - glib/CMakeLists.txt | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 369604603375dbe3516136b6f8f9d0c26e0b744f -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 18:26:45 2010 +0100 - - [CMake] use the --template option of glib-mkenums (like done with - autotools) - - glib/CMakeLists.txt | 24 ++++-------------------- - 1 file changed, 4 insertions(+), 20 deletions(-) - -commit bbcbb34fec10c90edd5960bdbcc6849bc8f39526 -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 17:34:40 2010 +0100 - - [CMake] set POPPLER_GLIB_DISABLE_DEPRECATED and - POPPLER_GLIB_DISABLE_SINGLE_INCLUDES as done with autotools - - CMakeLists.txt | 6 ++++++ - glib/CMakeLists.txt | 6 +++++- - 2 files changed, 11 insertions(+), 1 deletion(-) - -commit 190fa971c12ca1b3007f6ba349a77a7c15c47490 -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 17:24:25 2010 +0100 - - reorder to match what's in the correspondent .in - - glib/poppler-features.h.cmake | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ff46def8b178420a86a974ec2ce767a538bba8be -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 17:23:16 2010 +0100 - - [CMake] GDK_FEATURE is no more needed here - - glib/CMakeLists.txt | 1 - - 1 file changed, 1 deletion(-) - -commit 1eb8026a3060ef61a88c535177510f7ac7e7fc25 -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 17:19:58 2010 +0100 - - [CMake] set in one place whether to build the glib frontend - - CMakeLists.txt | 11 ++++++----- - 1 file changed, 6 insertions(+), 5 deletions(-) - -commit a1a6f23e2345814e147a72211ce9139555385223 -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 17:09:58 2010 +0100 - - [CMake] correctly set the GLIB_REQ stuff - - CMakeLists.txt | 1 + - poppler-glib.pc.cmake | 2 +- - 2 files changed, 2 insertions(+), 1 deletion(-) - -commit 0f2e5d6925c5938281d9bafc297a43867c4a915b -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 17:03:21 2010 +0100 - - [CMake] move the minimum GLib version to the main CMakeLists.txt - - CMakeLists.txt | 1 + - cmake/modules/FindGTK.cmake | 2 +- - 2 files changed, 2 insertions(+), 1 deletion(-) - -commit efdffba45d15b538dbfb294403e99f3a6470b4d9 -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 16:58:27 2010 +0100 - - [CMake] align the GDK stuff (GDK_{FEATURE,REQ}) to what done with - autotools - - CMakeLists.txt | 6 +++++- - poppler-glib.pc.cmake | 2 +- - 2 files changed, 6 insertions(+), 2 deletions(-) - -commit cfecc69b7f05920f543ee7e9aafeafaa4c3506fb -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 16:49:14 2010 +0100 - - [CMake] apparently there's not a minimum version requirement for GDK, - so drop the check - - cmake/modules/FindGTK.cmake | 5 +---- - 1 file changed, 1 insertion(+), 4 deletions(-) - -commit 8ff1cf03d2607b0f13bbbbf272f2b03d8927bd24 -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 16:47:21 2010 +0100 - - [CMake] first look for Cairo, then for GLib/GDK/GTK - - this starts to align to the searches done with autotools - also, move the CAIRO_FEATURE to the main CMakeLists.txt - - CMakeLists.txt | 19 +++++++++++-------- - glib/CMakeLists.txt | 1 - - 2 files changed, 11 insertions(+), 9 deletions(-) - -commit bcaf62b8e252594530d3050761ba563cf3b1fb6e -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 16:00:03 2010 +0100 - - [CMake] enhance/rewrite a bit the FindCairo module - - make use of some features of CMake 2.6 (as we require it): - - newer pkg-config handling (aka pkg_check_modules()) - - version checking for modules (PACKAGE_FIND_VERSION*) - - find_package_handle_standard_args() - also, after the pkg-config search to win32, search for cairo again - (double-check plus real search for win32) - furthermore, introduce CAIRO_INCLUDE_DIRS with the include paths - requires (kind of "obsoletes" CAIRO_CFLAGS, left there in case it - is used again) - - apply the changes to the rest of the build system (specify the - version needed, use the correct variable for includes) - - CMakeLists.txt | 2 +- - cmake/modules/FindCairo.cmake | 64 - +++++++++++++++++++++++++++---------------- - glib/CMakeLists.txt | 2 +- - 3 files changed, 43 insertions(+), 25 deletions(-) - -commit c96aa0f5fc74ae04f483485b787aaf65f1791991 -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 02:01:13 2010 +0100 - - add Patrick's copyright notices - - cpp/poppler-global.h | 1 + - goo/gtypes.h | 14 ++++++++++++++ - poppler/GlobalParams.cc | 1 + - poppler/SplashOutputDev.cc | 1 + - 4 files changed, 17 insertions(+) - -commit 3311bedd2eb831ef1fd553f3f50960331cf6885f -Author: Patrick Spendrin <ps_ml@gmx.de> -Date: Sun Mar 7 01:56:15 2010 +0100 - - MSVC: disable for the 'ustring' class the warning C4251 (which does - not apply) - - cpp/poppler-global.h | 8 ++++++++ - 1 file changed, 8 insertions(+) - -commit 9efa18397bd05fbd27c7811fa6e0f34ce94012e0 -Author: Patrick Spendrin <ps_ml@gmx.de> -Date: Sun Mar 7 01:48:03 2010 +0100 - - MSVC: disable warning C4800, which is of no use for now - - goo/gtypes.h | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 3a88d1bf8d2c5a9e8014e0d46e24c9ec06556469 -Author: Patrick Spendrin <ps_ml@gmx.de> -Date: Sun Mar 7 01:26:10 2010 +0100 - - MSVC: no isfinite(), so provide it using _finite() - - poppler/SplashOutputDev.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 7774912c46f832f25c51b4cfc0e9430b1cd7fa1f -Author: Patrick Spendrin <ps_ml@gmx.de> -Date: Sun Mar 7 01:22:31 2010 +0100 - - MSVC: do not force constness here, so the right overload will - be chosen - - poppler/GlobalParams.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit cf07a5d85b402b6956c9605fbdc88bddcb94a3cf -Author: Pino Toscano <pino@kde.org> -Date: Sun Mar 7 00:49:07 2010 +0100 - - [CMake] show end yes/no message about the GDK usage - - just like done with autotools - - CMakeLists.txt | 1 + - 1 file changed, 1 insertion(+) - -commit 42c98f8eabe304d5e3dc8c1ebdd5b0b6c221e696 -Author: Pino Toscano <pino@kde.org> -Date: Sat Mar 6 17:18:08 2010 +0100 - - [CMake] make the font configuration backend selection take a string - (like with autotools) - - this way it is possible to set the cmake variable FONT_CONFIGURATION - to either "win32" (default on windows) or "fontconfig" (default - elsewhere) to the font backend to use - as a consequence, make fontconfig a requirement only if the font - backend chosen is "fontconfig" - - CMakeLists.txt | 39 +++++++++++++++++++++++++++++---------- - 1 file changed, 29 insertions(+), 10 deletions(-) - -commit bda6e7cd089f2970af2e9540b4415633ffcf0ebb -Author: Pino Toscano <pino@kde.org> -Date: Sat Mar 6 17:13:30 2010 +0100 - - [CMake] add a show_end_message() macro to show a generic string - as value - - make show_end_message_yesno() call it with the proper "yes" or - "no" string - - cmake/modules/PopplerMacros.cmake | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -commit d313c0f508711b3b7166b84608c43ebf1f07194b -Author: Pino Toscano <pino@kde.org> -Date: Sat Mar 6 17:08:59 2010 +0100 - - [CMake] rename the show_end_message() macro to - show_end_message_yesno() - - CMakeLists.txt | 26 +++++++++++++------------- - cmake/modules/PopplerMacros.cmake | 4 ++-- - 2 files changed, 15 insertions(+), 15 deletions(-) - -commit 0425ff835fa26df5e25e628a6c56f3a180713905 -Author: Pino Toscano <pino@kde.org> -Date: Fri Mar 5 22:21:56 2010 +0100 - - update copyright - - poppler/ArthurOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit c5ea135ca58e112110be3ae10d887f3188172765 -Author: Pino Toscano <pino@kde.org> -Date: Fri Mar 5 22:14:57 2010 +0100 - - [arthur] update the miter limit - - poppler/ArthurOutputDev.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 552f344b3e3df7c796afa6946149b0a5590cc4f7 -Author: Pino Toscano <pino@kde.org> -Date: Fri Mar 5 22:04:39 2010 +0100 - - [arthur] update the line dash style - - poppler/ArthurOutputDev.cc | 12 +++++++++++- - 1 file changed, 11 insertions(+), 1 deletion(-) - -commit bc42ee05fceef0d0dd2ab0587c184dfc37cf29bf -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Mar 5 18:54:32 2010 +0000 - - fix copyright year - - poppler/CairoOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit b21461e91ed671ef29fd3cf4780fda44f82a0679 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Fri Mar 5 15:14:08 2010 +0100 - - [cairo] Close image stream before resetting it again - - poppler/CairoOutputDev.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 866bcc7edb47fe11355081045e2d316a4d530649 -Author: Pino Toscano <pino@kde.org> -Date: Thu Mar 4 14:19:50 2010 +0100 - - [Qt4] no need to save&restore on a newly created painter - - qt4/src/poppler-page.cc | 2 -- - 1 file changed, 2 deletions(-) - -commit 654698b556eb53eab7c2d55fc6b3fdd9e35173bb -Author: Pino Toscano <pino@kde.org> -Date: Thu Mar 4 13:16:11 2010 +0100 - - [Qt4] use Arthur unconditionally - - arthur is no more tied to splash, so can be used in an occasion - - qt4/src/poppler-document.cc | 2 +- - qt4/src/poppler-page.cc | 4 +--- - 2 files changed, 2 insertions(+), 4 deletions(-) - -commit 41931b6310d2ae81e622db904246f019ceb8410d -Author: Pino Toscano <pino@kde.org> -Date: Thu Mar 4 13:13:11 2010 +0100 - - [Qt4] compile Arthur unconditionally - - as the arthur output dev does not require splash anymore, we can - always compile it with poppler-qt4 - - poppler/Makefile.am | 4 ++-- - qt4/src/CMakeLists.txt | 6 +----- - qt4/src/Makefile.am | 6 +----- - 3 files changed, 4 insertions(+), 12 deletions(-) - -commit 48a29e2bbc9aa9bd0cb2775a2365c0ffdeb6ce87 -Author: Pino Toscano <pino@kde.org> -Date: Thu Mar 4 13:11:43 2010 +0100 - - [Arthur] make ArthurOutputDev compile even with Splash disabled - - text rendering is disabled in that case for now - - poppler/ArthurOutputDev.cc | 11 ++++++++++- - 1 file changed, 10 insertions(+), 1 deletion(-) - -commit 2013a19b6457753890affad8c4049f2ce4627df7 -Author: Pino Toscano <pino@kde.org> -Date: Thu Mar 4 13:02:43 2010 +0100 - - [CMake/tests] compile gtk-splash-test only if splash is enabled - - test/CMakeLists.txt | 14 +++++++++----- - 1 file changed, 9 insertions(+), 5 deletions(-) - -commit ae740c5cfefbae13f82b750e39fa3dbbdc94858b -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 2 23:22:06 2010 +0100 - - [cpp] update the copyrights - - cpp/poppler-document-private.h | 2 +- - cpp/poppler-document.cpp | 2 +- - cpp/poppler-embedded-file.cpp | 2 +- - cpp/poppler-embedded-file.h | 2 +- - cpp/poppler-global.cpp | 3 ++- - cpp/poppler-global.h | 2 +- - cpp/poppler-page.cpp | 2 +- - cpp/poppler-page.h | 2 +- - cpp/poppler-rectangle.h | 2 +- - cpp/poppler-toc.cpp | 2 +- - cpp/poppler-version.cpp | 2 +- - cpp/tests/poppler-dump.cpp | 2 +- - 12 files changed, 13 insertions(+), 12 deletions(-) - -commit 24b1d8d0b4ae7cea9fbc331f19cd5ce3917b8b4d -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 2 23:15:56 2010 +0100 - - [cpp] {from,to}_utf_8() -> {from,to}_utf8() - - cpp/poppler-global.cpp | 4 ++-- - cpp/poppler-global.h | 4 ++-- - cpp/poppler-page.cpp | 2 +- - 3 files changed, 5 insertions(+), 5 deletions(-) - -commit 690af1bc58de1ebe710c5e599f1cb635e4838fc8 -Author: Hib Eris <hib@hiberis.nl> -Date: Tue Mar 2 16:33:04 2010 +0100 - - [cpp] define poppler_cpp_EXPORTS when building with autotools as well - - fixes building on Windows - - cpp/Makefile.am | 3 +++ - 1 file changed, 3 insertions(+) - -commit 7492a376e7e5ec35534276ac15485123645617b0 -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 2 22:16:07 2010 +0100 - - [cpp/tests] use gmtime() when gmtime_r() is not available - - cpp/tests/poppler-dump.cpp | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - -commit de013cc14a0621782c53f481ed7e559f241855a3 -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 2 22:05:25 2010 +0100 - - [cpp] include config.h _after_ the other includes - - cpp/poppler-global.cpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 388e5d6aebcabbfc90894c86248159c63701cb0a -Author: Hib Eris <hib@hiberis.nl> -Date: Tue Mar 2 15:51:23 2010 +0100 - - Use ICONV_CONST when necessary - - cpp/poppler-global.cpp | 10 ++++++---- - 1 file changed, 6 insertions(+), 4 deletions(-) - -commit aaa58b26733a2f7c778632da4942b588050cf33f -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 2 21:53:55 2010 +0100 - - [CMake] properly define ICONV_CONST - - CMakeLists.txt | 1 - - cmake/modules/FindIconv.cmake | 3 +++ - config.h.cmake | 2 +- - 3 files changed, 4 insertions(+), 2 deletions(-) - -commit 6304b0d8959fccf96b030c757d78e845d04757e4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Feb 28 15:33:53 2010 +0100 - - poppler 0.13.1 - - CMakeLists.txt | 2 +- - NEWS | 33 +++++++++++++++++++++++++++++++++ - configure.ac | 2 +- - cpp/Doxyfile | 2 +- - qt4/src/Doxyfile | 2 +- - 5 files changed, 37 insertions(+), 4 deletions(-) - -commit 9eac71862915c851c07075e3ca3af82eb9e4e775 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Feb 28 15:33:19 2010 +0100 - - Make sure the private headers end up in the tarball on make dist - - cpp/Makefile.am | 5 +++++ - 1 file changed, 5 insertions(+) - -commit b488172311c2921ab4c365d71ad8b1ab7f596c71 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Feb 28 14:25:36 2010 +0100 - - Add copyright notices - - poppler/CairoFontEngine.cc | 3 ++- - poppler/CairoFontEngine.h | 2 +- - 2 files changed, 3 insertions(+), 2 deletions(-) - -commit 5453cff5b7cb47cadfdae585a58409117af8c1f1 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Feb 28 13:51:22 2010 +0100 - - [cairo] Select filter for images based on scale factor - - When rendering images and interpolate flag is disabled or missing, we - always interpolate unless scale factor is >= 400% - - See bugs #25268, #9860 - - poppler/CairoOutputDev.cc | 64 - ++++++++++++++++++++++++++++++++++------------- - poppler/CairoOutputDev.h | 2 ++ - 2 files changed, 49 insertions(+), 17 deletions(-) - -commit e65456cbd5cae2750426aabeb2d66a10537616f0 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Feb 28 13:13:13 2010 +0100 - - [cairo] Refactor scaled size computation into a new method - - poppler/CairoOutputDev.cc | 52 - +++++++++++++++++++++++------------------------ - poppler/CairoOutputDev.h | 2 ++ - 2 files changed, 28 insertions(+), 26 deletions(-) - -commit 32aa9ae7d0087298661829265de00e93398272b3 -Author: Jan Kümmel <jan+freedesktop@snorc.org> -Date: Sat Feb 27 17:58:46 2010 +0100 - - [cairo] Omit writing of embedded fonts into tempary files - - Fixes bug #26694. - - poppler/CairoFontEngine.cc | 146 - +++++++++++++++++++++++++-------------------- - 1 file changed, 80 insertions(+), 66 deletions(-) - -commit 7ba52a32343ca73730a80b64c136e3f03348e7d9 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Feb 27 17:42:46 2010 +0100 - - [cairo] Remove unused 'face' from CairoFreeTypeFont class - - poppler/CairoFontEngine.cc | 6 ++---- - poppler/CairoFontEngine.h | 3 +-- - 2 files changed, 3 insertions(+), 6 deletions(-) - -commit 7c3140c88c00282e10888143fffe3c402d48fb05 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Sat Feb 27 13:13:47 2010 +0100 - - Don't use '\' character in PostScript names - - poppler/PSOutputDev.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 8e354a15a1861719c00799937ad9f9bb1bb71e9f -Author: Thomas Freitag <Thomas.Freitag@alfa.de> -Date: Wed Feb 24 18:58:11 2010 +0000 - - Fix remaining part of 26243 - - Thomas says: The "gn" is colored with a shading pattern, but the - shading has a bbox, - so it is clipped to this bbox, too. But when coloring text or masks in - pattern colorspace, this is definely wrong. - - poppler/Gfx.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit fcbc571a98775b1daa8f562fc8674fb2d15b6626 -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 23 17:02:47 2010 +0100 - - [cpp] make checksum() return an array of data, instead of a string - - a checksum is a sequence of values after all, so just return it as - such instead of pretending it is a string - accordingly adapt the mini dump application - - cpp/poppler-embedded-file.cpp | 10 ++++++++-- - cpp/poppler-embedded-file.h | 2 +- - cpp/tests/poppler-dump.cpp | 4 ++-- - 3 files changed, 11 insertions(+), 5 deletions(-) - -commit fbefb9bef9f7a099d51919255a98f412d1e1d696 -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 23 16:56:47 2010 +0100 - - [cpp apidox] add API documentation for the 'embedded_file' class - - cpp/poppler-embedded-file.cpp | 43 - +++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 43 insertions(+) - -commit 6d39cca0a035fc656d3b86ba66dedaccee532fcb -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 23 16:41:56 2010 +0100 - - [cpp apidox] add API documentation for the 'toc' and 'toc_item' - classes - - cpp/poppler-toc.cpp | 57 - +++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 57 insertions(+) - -commit 857e4ceb26d959c48c7af6bff53ca1bfe5307236 -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 23 15:39:58 2010 +0100 - - [cpp] when the loading of the document fails, put back the data - where it was before - - cpp/poppler-document-private.h | 2 +- - cpp/poppler-document.cpp | 10 +++++++--- - 2 files changed, 8 insertions(+), 4 deletions(-) - -commit 7838b182143086192ac8dcf571da0ce1743619e2 -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 23 00:04:09 2010 +0100 - - [cpp] add the directory of the generated html apidox to the ignore - list - - cpp/.gitignore | 1 + - 1 file changed, 1 insertion(+) - -commit 71a38a23a9db5cac872c666283b7abcb1462210c -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 22 23:43:34 2010 +0100 - - [cpp] add page::text() to get the text inside a page region - - cpp/poppler-page.cpp | 16 ++++++++++++++++ - cpp/poppler-page.h | 1 + - 2 files changed, 17 insertions(+) - -commit 4c75360233bc67f097551980a46ecce976927220 -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 22 23:05:53 2010 +0100 - - [cpp] add page::search() - - cpp/poppler-page.cpp | 51 - +++++++++++++++++++++++++++++++++++++++++++++++++++ - cpp/poppler-page.h | 8 ++++++++ - 2 files changed, 59 insertions(+) - -commit 8932c53a084083eb42d109dd17bac3ad41ce65b5 -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 22 22:39:36 2010 +0100 - - [cpp] add getters and setters for left/top/right/bottom - - cpp/poppler-rectangle.h | 18 ++++++++++++++++++ - 1 file changed, 18 insertions(+) - -commit 8e1ea57f558fa3a1702a17d79b5aaffc486c6a56 -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 22 22:19:51 2010 +0100 - - [cpp] add a global enum for case sensitivity - - cpp/poppler-global.h | 2 ++ - 1 file changed, 2 insertions(+) - -commit ae41b087de8f0a7d525320dcf1d64ff22fe982b6 -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 22 19:06:21 2010 +0100 - - [cpp apidox] doxygen configuration for poppler-cpp - - cpp/Doxyfile | 1551 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 1551 insertions(+) - -commit 1a36a7bcc684065478a3ade2c2938f0e3672140a -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 22 19:05:49 2010 +0100 - - [cpp apidox] very small start of intro page - - cpp/Mainpage.dox | 9 +++++++++ - 1 file changed, 9 insertions(+) - -commit 85e052ab7a4c462143325ecf60eebba35411b790 -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 22 18:53:20 2010 +0100 - - [cpp apidox] start adding API documentation for the global 'poppler' - namespace - - ... including the 'convert_date' function and faking the 'noncopyable' - class - - cpp/poppler-global.cpp | 16 ++++++++++++++++ - 1 file changed, 16 insertions(+) - -commit b01608f91fb6cf6e9c4fb6e6ee3cb57517a766bf -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 22 18:52:24 2010 +0100 - - [cpp apidox] exclude the 'detail' namespace from apidox extraction - - this includes also the 'noncopyable' typedef, but that will be - handled differently - - cpp/poppler-global.h | 2 ++ - 1 file changed, 2 insertions(+) - -commit f17a7a8cfdeabb3ced3ba8d42c869d892c528e13 -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 22 18:51:30 2010 +0100 - - [cpp apidox] add API documentation for the version functions - - cpp/poppler-version.cpp | 12 ++++++++++++ - 1 file changed, 12 insertions(+) - -commit f6c4bbddc7d04c0b1a6b25c41cbf6d81ae40cc0c -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 22 18:50:54 2010 +0100 - - [cpp apidox] start adding API documentation for 'document' - - cpp/poppler-document.cpp | 182 - +++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 182 insertions(+) - -commit cbb7519904d9b6395d0128e16a79324e4b8bfcc0 -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 22 13:15:11 2010 +0100 - - [CMake] no more need to build system check for the Cairo blend modes - - followup of 880890c14e99a954b365a3a6b59deeffa5304d30 for the cmake - build system - - cmake/modules/FindCairo.cmake | 18 ------------------ - config.h.cmake | 3 --- - 2 files changed, 21 deletions(-) - -commit 80f47bbf45faf751c661c1d0931e8e1da622b8ca -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Feb 22 12:43:06 2010 +0100 - - [cairo] Use cairo_surface_set_mime_data() when printing - - When rendering a jpeg image for printing, using - cairo_surface_set_mime_data() to attach the jpeg stream to the - surface reduces drastically the size of the output file. - - poppler/CairoOutputDev.cc | 42 ++++++++++++++++++++++++++++++++++++++++++ - poppler/CairoOutputDev.h | 1 + - 2 files changed, 43 insertions(+) - -commit d63293af6dbff65f160be0118b1580c03a1aab56 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Nov 27 09:52:23 2009 +0100 - - [cairo] Turn EXTEND_PAD off when printing - - poppler/CairoOutputDev.cc | 98 - ++++++++++++++++++++++++++++++++--------------- - 1 file changed, 67 insertions(+), 31 deletions(-) - -commit 880890c14e99a954b365a3a6b59deeffa5304d30 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Feb 22 11:01:05 2010 +0100 - - [cairo] Use CAIRO_VERSION macros to check whether blend modes are - available - - configure.ac | 24 ------------------------ - poppler/CairoOutputDev.cc | 4 ++-- - 2 files changed, 2 insertions(+), 26 deletions(-) - -commit 5c300ce00b5c59da767ca1ffec12f96f0ebbe701 -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 21 21:20:10 2010 +0100 - - [Qt4/apidox] fix typo - - qt4/src/poppler-qt4.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 3f89ccf871e2f4a14129ad3e986b8cd19cdf129c -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 21 21:06:31 2010 +0100 - - [CMake] set the CXXFLAGS in a better way - - CMakeLists.txt | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit a18dab9e53a20a76eb46fa3a868fffdd3c754ce2 -Merge: fa09892 f3862f7 -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 21 19:56:38 2010 +0100 - - Merge remote branch 'origin/cpp-frontend' - - * origin/cpp-frontend: (34 commits) - [cpp/tests] poppler-dump: show a string for the font type - [cpp/tests] poppler-dump: show the orientation of the pages - [cpp/tests] poppler-dump: a bit less output in permissions lines - [cpp/tests] poppler-dump: add --show-all to show all the information - [cpp] use iconv for the utf8 <-> utf16 conversions - [cpp] add the build system stuff for iconv, mandatory for cpp - [cpp] fixup unicode GooString <-> ustring conversions - [cpp] fix installation of poppler-version.h with autotools and - builddir != srcdir - simplify - [cpp/tests] add a simple poppler-dump test - [cpp] use the correct index (instead of an uninitialized variable) - [cpp] properly delete the children of a toc item - [cpp] actually implement toc::root() - [cpp] fix the reference to the vector data - [cpp] fix the reference to the vector data - [cpp] add destructor for 'rectangle' - [cpp] add out stream operators for rect and rectf - [cpp] add namespace to namespace functiond to link properly - [cpp] add default empty parameters for the passwords of the document - loading functions - [cpp] add "human friendly" output representation for byte_array - ... - - Conflicts: - config.h.cmake - -commit fa0989297e95b6adebed71336ea206d1b279ab24 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Feb 21 16:59:57 2010 +0000 - - Detect the need for nanosleep in solaris - - Fixes bug 26650 - - ConfigureChecks.cmake | 5 +++++ - test/CMakeLists.txt | 17 +++++++++++------ - 2 files changed, 16 insertions(+), 6 deletions(-) - -commit d074485aa9d9fac6b715382002f53e3303bbc519 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Feb 20 10:08:33 2010 +0000 - - Do not call getPixel if we know how to access the data - - Gives a 20% speed increase in some pdf - - splash/Splash.cc | 19 ++++++++++--------- - 1 file changed, 10 insertions(+), 9 deletions(-) - -commit d4cafe357bd86feb4b56e5dfbf5b7822e237a2ee -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Feb 20 10:07:20 2010 +0000 - - Only call getPixel when really needed - - Gives a 8% speed increase in some pdf - - splash/Splash.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit c3122cfbe090f3a4045269222f941cd5ce77c171 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Feb 20 10:04:37 2010 +0000 - - Move test code to the header to it can be inlined - - Gives a 10% speed increase in some documents - - splash/SplashClip.cc | 40 ++++++++++++++-------------------------- - splash/SplashClip.h | 43 +++++++++++++++++++++++++++++++++++++++++-- - 2 files changed, 55 insertions(+), 28 deletions(-) - -commit d987fb9b77e6da454eb898cc6c8baaf747b7ac4f -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Feb 19 23:59:03 2010 +0000 - - implement writeImgFile for splashModeXBGR8 - - splash/SplashBitmap.cc | 25 +++++++++++++++++++++++-- - 1 file changed, 23 insertions(+), 2 deletions(-) - -commit f9425c0b5b112ac673d0499f79a743afce719593 -Author: Hib Eris <hib@hiberis.nl> -Date: Fri Feb 19 20:18:13 2010 +0000 - - use pkgconfig to detect libpng on autotools too - - configure.ac | 12 ++++--- - goo/Makefile.am | 7 +++- - m4/libpng.m4 | 99 - ----------------------------------------------------- - poppler/Makefile.am | 3 ++ - 4 files changed, 17 insertions(+), 104 deletions(-) - -commit 0cb07d645527f25997f5e1b104a6be92441d8ffa -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Feb 18 23:27:20 2010 +0000 - - Only swap w with h if rotation is 90 or 270 - - utils/pdftoppm.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 35015ed11090d67cab69443e607d4d80ca03c619 -Author: Nils Höglund <nils.hoglund@gmail.com> -Date: Thu Feb 18 23:14:51 2010 +0000 - - Match the number of calls to beginMarkedContent and endMarkedContent - - poppler/Gfx.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit ee265760e6ecec93fe26fb8e02848872555daefd -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Feb 18 23:13:48 2010 +0000 - - make sure properties exists before using it - - poppler/TextOutputDev.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit eab7a55815c06525c7aeba254b66498ab147a958 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Feb 17 21:54:31 2010 +0000 - - if malloc failed return false - - splash/SplashFTFont.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit e2def20a45c1d8307fd62fabb9769121af975abf -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Feb 16 23:31:05 2010 +0000 - - Only assume the OC is not visible if it exists and is set to no - - Fixes bug 26532 and a small line that was not drawn in 15899 - - poppler/OptionalContent.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 5edd175bdd0f7c2fc3aecb72384de4cb0788fc4e -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Feb 16 20:57:22 2010 +0000 - - Add and fix copyright years - - poppler/CairoOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 0f0fba1b04589061449f98b9dcd8a0c4e7ad2d74 -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 16 22:00:51 2010 +0100 - - make the descriptions specify they refer to the Splash backend - - config.h.cmake | 4 ++-- - configure.ac | 4 ++-- - 2 files changed, 4 insertions(+), 4 deletions(-) - -commit 39b4699020b5cfa1a10e5ef00f0e355e27b21c9f -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 16 21:56:30 2010 +0100 - - [CMake] reflect that poppler-glib needs cairo now - - poppler-glib.pc.cmake | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 5c66c775bcd686c61ea136bcd8f261fb631c5e71 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Feb 16 20:52:15 2010 +0000 - - We don't need to pass anything to FontConfig - - Makes it much easier to manage and also fixes bug 26544 - - poppler/GlobalParams.cc | 11 +++-------- - poppler/GlobalParams.h | 6 +----- - 2 files changed, 4 insertions(+), 13 deletions(-) - -commit 582b5259b3c65ee1bef99dbdfccf00f37269b76f -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 16 16:36:24 2010 +0100 - - [CMake] find the system threads, and define in the config.h if we - have pthreads - - CMakeLists.txt | 4 ++++ - config.h.cmake | 3 +++ - 2 files changed, 7 insertions(+) - -commit 1dff9d440556a155fb5ca7bed15fc6a1f77a1c97 -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 16 16:10:44 2010 +0100 - - [CMake] add the HAVE_LIBOPENJPEG and HAVE_OPENJPEG_H defines, to - match autotools' ones - - CMakeLists.txt | 1 + - config.h.cmake | 6 ++++++ - 2 files changed, 7 insertions(+) - -commit 4a0bcaa83e6e6533cd48c63449a08467d51c13ea -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 16 16:01:53 2010 +0100 - - [CMake] config.h.cmake: change some comments to match autotools' ones - - config.h.cmake | 10 ++++++---- - 1 file changed, 6 insertions(+), 4 deletions(-) - -commit 9e38082c3e571d035f0152d65661e5dd97fdd5d8 -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 16 15:58:30 2010 +0100 - - [CMake] add the Win32-specific ENABLE_RELOCATABLE option, matching - autotools' one - - CMakeLists.txt | 5 +++++ - config.h.cmake | 3 +++ - 2 files changed, 8 insertions(+) - -commit eb03020893ed591c18817d75d427a1296cb1f233 -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 16 15:49:50 2010 +0100 - - [CMake] config.h.cmake: move POPPLER_WITH_GDK in the same place of - autotools' generated one, and with the same comment - - config.h.cmake | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit ba65b3af047b758094b999b2939065c5127508dd -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Feb 10 23:08:04 2010 +0000 - - Wrap #include <jpeglib.h> in extern "C" to fix build - - Fixes bug 26351 - - goo/JpegWriter.h | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -commit d3d2a3ee0a3505f44d1196823716b768d434ba73 -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 10 23:16:27 2010 +0100 - - [CMake] fix typo: "MULTITHREAD" -> "MULTITHREADED" - - CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 0dae2294cf8a2f312d8e6504be4e1be516b34b1b -Author: Thomas Freitag <Thomas.Freitag@alfa.de> -Date: Tue Feb 9 21:44:07 2010 +0000 - - Fix regression in painting. Fixes bug 26243 - - poppler/Gfx.cc | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - -commit aa9c3acbc73bafb33c8a797701ed0488a4a74263 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jan 28 17:23:18 2010 +0100 - - [cairo] Add clipToStrokePath() method - - It's unimplemented, it just contains a log message to help when - debugging. - - poppler/CairoOutputDev.cc | 4 ++++ - poppler/CairoOutputDev.h | 1 + - 2 files changed, 5 insertions(+) - -commit 41a450c8db45fd064798d15c3d8fe5ab536a7b30 -Author: David Benjamin <davidben@mit.edu> -Date: Fri Jan 22 00:26:59 2010 -0500 - - [cairo] Avoid leaving pointers to free'd memory - - Fixes potential free'd memory access introduced by - 3a94e8ce90c0a4d11c5c5aa8805c167c8a0434e5. I don't think this is - actually - possible in the current code; we push/pop before and after rendering a - PDF, so the bottom state should never have a mask. - - Still, better to clean this up. - - poppler/CairoOutputDev.cc | 5 ++--- - 1 file changed, 2 insertions(+), 3 deletions(-) - -commit 309228404710debee4337cc53c641dfef64ad86c -Author: David Benjamin <davidben@mit.edu> -Date: Wed Jan 27 22:41:16 2010 +0000 - - Allow commands to abort the current stream - - In many instances, the sensible response (and what acroread does) in - case of an error is abort the PDF stream. To avoid changing the return - value of every function and using C++ exceptions, we communicate via a - commandAborted variable. - - This patch, matching acroread's behavior aborts the current stream - when - there are too few arguments or we pop too many times. Implementation - note 39 in Appendix H of the PDF reference contradicts the former, but - hand-crafted test PDFs as well as the file in #24575 suggest - otherwise. - - Unlike all the other attempts, this patch actually fixes the PDF in - bug #24575. - - poppler/Gfx.cc | 11 +++++++++++ - poppler/Gfx.h | 1 + - 2 files changed, 12 insertions(+) - -commit 8284008aa8230a92ba08d547864353d3290e9bf9 -Author: David Benjamin <davidben@mit.edu> -Date: Wed Jan 27 22:40:33 2010 +0000 - - Add a stack of stateGuards to Gfx - - While a stack of states is a good way to maintain graphics contexts, - if - the command stream you are interpreting is untrusted, we must place - appropriate guards to be sure that, not only do we not pop past - the end - of the stack, but we do not pop past the stack as it was when we began - rendering. - - poppler/Gfx.cc | 30 +++++++++++++++++++++++++++++- - poppler/Gfx.h | 11 +++++++++++ - 2 files changed, 40 insertions(+), 1 deletion(-) - -commit 4ae84c830f842d100cbb702b32970951a5a5769f -Author: David Benjamin <davidben@mit.edu> -Date: Wed Jan 27 22:39:20 2010 +0000 - - Maintain the height of the stack in Gfx - - Introduces a new variable Gfx::stackHeight that maintains up-to-date - information about the current height of the stack. - - poppler/Gfx.cc | 4 ++++ - poppler/Gfx.h | 1 + - 2 files changed, 5 insertions(+) - -commit 120fe6ef673c648ae7b19ad2a7e9aef22ee25810 -Author: David Benjamin <davidben@mit.edu> -Date: Wed Jan 27 22:38:43 2010 +0000 - - Do not use objects just after deleting them - - The error condition in GfxCIDFont::GfxCIDFont references cMapName and - collection, so they should not be deleted yet. - - poppler/GfxFont.cc | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -commit 3375fa96c7a7dbbb98f5a7b3df9e840a5f30bc80 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jan 27 22:32:29 2010 +0000 - - GooVector rewrite, old version had "unknown" origins/license - - goo/GooVector.h | 237 - +++++++++++++++++++++++++++++++++----------------------- - 1 file changed, 141 insertions(+), 96 deletions(-) - -commit a945fe64e16ac9aa2577c5db05fc7f3fd4955b7b -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jan 27 16:15:40 2010 +0100 - - [cairo] Fix downscaling images when document is rotated - - Fixes bug #26264. - - poppler/CairoOutputDev.cc | 37 +++++++++++++++++++++++++++++++++++-- - 1 file changed, 35 insertions(+), 2 deletions(-) - -commit 428cc965c17f167ea00540beeaeaac5c3e426686 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jan 26 21:01:32 2010 +0000 - - Add POPPLER_WITH_GDK in cmake build system - - Bug 26247 - - glib/CMakeLists.txt | 1 + - glib/poppler-features.h.cmake | 1 + - 2 files changed, 2 insertions(+) - -commit 0af1ae75fd4c8031343f668bed5d8ca6588ee652 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jan 26 20:49:17 2010 +0100 - - [cairo] Use the right matrix for the mask in drawMaskedImage() - - Fixes bug #16906. - - poppler/CairoOutputDev.cc | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -commit d8ceaff39f5b80624b6bdc703c2a180dfc3d73ee -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jan 26 11:57:06 2010 +0100 - - [cairo] Add some more LOG messages - - poppler/CairoOutputDev.cc | 18 +++++++++++++++--- - 1 file changed, 15 insertions(+), 3 deletions(-) - -commit 778e764b3cb77526260c3c8b46acf19ad06fc61d -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Jan 25 22:40:20 2010 +0000 - - poppler 0.13.0 - - CMakeLists.txt | 4 +-- - NEWS | 99 - +++++++++++++++++++++++++++++++++++++++++++++++++++++ - configure.ac | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 5 files changed, 104 insertions(+), 5 deletions(-) - -commit 1b5333f2685b8ab85bb1f5b899332c5a0ac99a3d -Author: Pino Toscano <pino@kde.org> -Date: Mon Jan 25 02:19:00 2010 +0100 - - [CMake] allow multiple targets with the same name - - this is needed for building the unit tests later without explicitly - having - enabling them at configure time (thus compile them on-demand) - for this, set the cmake policy 0003 as OLD (allow), and consecuently - 0011 for - setting the former from an include()d script - - cmake/modules/PopplerDefaults.cmake | 7 +++++++ - 1 file changed, 7 insertions(+) - -commit 92e1f46866c063c370ef1d6324f6a6c01aed6680 -Author: Pino Toscano <pino@kde.org> -Date: Mon Jan 25 02:15:27 2010 +0100 - - [CMake] do not add the fake buildtests target for the MSVC IDE - - cmake/modules/PopplerMacros.cmake | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit dea5aa37de079196fa916b1db9af782cf25045f9 -Author: Maciej Mrozowski <reavertm@gmail.com> -Date: Mon Jan 25 00:51:20 2010 +0000 - - Install some more goo files - - CMakeLists.txt | 9 +++++++++ - 1 file changed, 9 insertions(+) - -commit 671a971c45a1e8ce8f6daade82117a9a137034d6 -Author: Maciej Mrozowski <reavertm@gmail.com> -Date: Mon Jan 25 00:48:31 2010 +0000 - - do not install a private header - - qt4/src/Makefile.am | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 54c86e53a143a8f9d196e4bef2a733c6f00f6026 -Author: Maciej Mrozowski <reavertm@gmail.com> -Date: Mon Jan 25 00:33:07 2010 +0000 - - Only build tests if told to - - test/CMakeLists.txt | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit eb082274694aadb80dd16caea65d7f0a1adf8b46 -Author: Maciej Mrozowski <reavertm@gmail.com> -Date: Mon Jan 25 00:29:55 2010 +0000 - - Only build demos and test if told so. Install poppler-layer.h - - glib/CMakeLists.txt | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - -commit 73fcc310cd7d6ef435b453485c1c99a33f77212a -Author: Maciej Mrozowski <reavertm@gmail.com> -Date: Mon Jan 25 00:29:09 2010 +0000 - - install man pages - - utils/CMakeLists.txt | 7 +++++++ - 1 file changed, 7 insertions(+) - -commit 8672217af4cf88d5506572c2b40fbb0d1d0dbd87 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Jan 25 00:11:50 2010 +0000 - - Make the poppler object cache params be a ref - - And make sure what we was is a ref, otherwise we abort - - poppler/Gfx.cc | 14 ++++++++------ - poppler/PopplerCache.cc | 12 ++++++------ - poppler/PopplerCache.h | 6 +++--- - 3 files changed, 17 insertions(+), 15 deletions(-) - -commit 9567fd8d3d905897d0abacd77885102ae86ba8a9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 24 20:15:49 2010 +0000 - - ImgWriter is a header too - - goo/Makefile.am | 1 + - 1 file changed, 1 insertion(+) - -commit 735e8a690d0bd3ab4bec90bdad975d19ac3d4689 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 24 19:51:19 2010 +0000 - - noone maintains this either - - msvc/config.h | 62 ---------------------------------- - msvc/poppler/poppler-config.h | 77 - ------------------------------------------- - 2 files changed, 139 deletions(-) - -commit d485564f0dc86f62b996380bfbd570cf3f543e4f -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 24 19:22:33 2010 +0000 - - remove files noone maintains - - README.windows | 63 ------------------------ - makefile.vc | 150 - --------------------------------------------------------- - 2 files changed, 213 deletions(-) - -commit 38467f2738c88f060ae1d30332e34da743a888a5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 24 19:18:44 2010 +0000 - - only compile glib frontend if cairo is found - - CMakeLists.txt | 4 ++-- - glib/CMakeLists.txt | 25 +++++++------------------ - 2 files changed, 9 insertions(+), 20 deletions(-) - -commit cf045acf46307d51fb6d9959451b53681e6cac03 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 24 19:01:52 2010 +0000 - - compile - - glib/CMakeLists.txt | 1 + - 1 file changed, 1 insertion(+) - -commit 0397cf4f193015286464ae70ab202ed400110e30 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 24 19:00:09 2010 +0000 - - Add and fix copyright years - - poppler/CairoFontEngine.cc | 1 + - poppler/CairoOutputDev.cc | 2 +- - poppler/CairoOutputDev.h | 2 +- - poppler/Gfx.cc | 2 +- - poppler/Gfx.h | 2 +- - poppler/PopplerCache.cc | 1 + - poppler/PopplerCache.h | 1 + - 7 files changed, 7 insertions(+), 4 deletions(-) - -commit 9c9f18b6ceea546dfb21ef0aab29ba99733dcb52 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Jan 24 19:27:29 2010 +0100 - - [glib-demo] Remove #ifdef HAVE_CAIRO macros from several demos - - glib/demo/images.c | 2 -- - glib/demo/layers.c | 71 - +++--------------------------------------------------- - glib/demo/render.c | 29 ++++------------------ - 3 files changed, 9 insertions(+), 93 deletions(-) - -commit 4e938c1f81add2162ced0e97b24fe588f15f178d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Jan 24 19:15:06 2010 +0100 - - [glib] Make glib frontend unconditionally use cairo output device - - Splash support has been removed. - - configure.ac | 74 ++++++++------- - glib/Makefile.am | 20 +--- - glib/poppler-document.cc | 9 -- - glib/poppler-page.cc | 237 - +--------------------------------------------- - glib/poppler-page.h | 7 -- - glib/poppler-private.h | 14 --- - glib/poppler.cc | 6 -- - glib/test-poppler-glib.cc | 6 +- - poppler-glib.pc.in | 2 +- - 9 files changed, 51 insertions(+), 324 deletions(-) - -commit 59ff9d66fc3b0c9612b1c12fc1ae4dbb8dc85b39 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Jan 24 17:57:48 2010 +0100 - - Use a small object cache in GfxResources to cache GState objects - - It drastically improves performance with some documents like page - 742 of - PDF32000_2008.pdf - - poppler/Gfx.cc | 19 +++++++++++++++++-- - poppler/Gfx.h | 2 ++ - 2 files changed, 19 insertions(+), 2 deletions(-) - -commit 880a4a9a60a10f7aa7d3dc7c2802b31b7ef01e06 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Jan 24 17:56:35 2010 +0100 - - Add a generic cache to store objects by its reference - - poppler/PopplerCache.cc | 60 - +++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/PopplerCache.h | 16 +++++++++++++ - 2 files changed, 76 insertions(+) - -commit 5ad492df75c0c2394719e85db4c8b43f15b52110 -Author: mpsuzuki <mpsuzuki@hiroshima-u.ac.jp> -Date: Sun Jan 24 13:34:41 2010 +0100 - - [cairo] Fix memory leak - - poppler/CairoFontEngine.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 3160464b4b70c714c36234320878acab81b866cc -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Nov 26 13:17:19 2009 +0100 - - [cairo] Use our own implementation to scale down images instead - of cairo - - This is a workaround for the low quality downscaling of pixman. - Rescaler implementation is a box filter that supports non-integer box - sizes written by Jeff Muizelaar. - Fixes bug #5589. - - poppler/CairoOutputDev.cc | 89 ++++++++++++ - poppler/CairoOutputDev.h | 1 + - poppler/CairoRescaleBox.cc | 352 - +++++++++++++++++++++++++++++++++++++++++++++ - poppler/CairoRescaleBox.h | 12 ++ - poppler/Makefile.am | 4 +- - 5 files changed, 457 insertions(+), 1 deletion(-) - -commit 6825a219f0bc0ac6fd469fb8a6ebb86df774375f -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Jan 23 11:24:15 2010 +0100 - - [glib] Use TextOutputDev to get TextPage when we haven't rendered - the page - - glib/poppler-page.cc | 27 ++++++++++++++++++--------- - 1 file changed, 18 insertions(+), 9 deletions(-) - -commit 6c61a457e9a8ec10945bc1e0700c8e4d121faa58 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jan 20 21:59:05 2010 +0000 - - Fix GfxRadialShading::GfxRadialShading - - Fixes crash in KDE bug 223359 - - poppler/GfxState.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 442894d371879a6bf2adb5a39b9dd0a49e76e4ac -Author: Pino Toscano <pino@kde.org> -Date: Fri Jan 15 21:28:42 2010 +0100 - - [glib-demo/cmake] compile print.c - - followup of b64d4bd46b052feb0b143f1348773afbd93e5e33 - - glib/demo/CMakeLists.txt | 1 + - 1 file changed, 1 insertion(+) - -commit b64d4bd46b052feb0b143f1348773afbd93e5e33 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Nov 27 11:47:22 2009 +0100 - - [glib-demo] Add print demo - - glib/demo/Makefile.am | 2 + - glib/demo/main.c | 4 +- - glib/demo/print.c | 135 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - glib/demo/print.h | 31 ++++++++++++ - 4 files changed, 171 insertions(+), 1 deletion(-) - -commit ba2c746f358a5785d8cbaaf03d8628ee3754c388 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Nov 27 09:52:50 2009 +0100 - - [glib-demo] Add render for printing option to render demo - - glib/demo/render.c | 47 ++++++++++++++++++++++++++++++++++++++--------- - 1 file changed, 38 insertions(+), 9 deletions(-) - -commit 9a478008ccb61641f09bd77eaa55033cca266c43 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Jan 15 12:03:11 2010 +0100 - - Add FONTCONFIGURATION macros to poppler-config.h - - They are used in a header file (GlobalParams.h). It fixes a crash - when opening any document. - - poppler/poppler-config.h.in | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -commit 1f80f874d8e132411816302465f04bc59d404d89 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jan 14 08:43:11 2010 +0000 - - Fix Uncover and Fade to return correct values - - Bug 26034 - - poppler/PageTransition.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 350ff407e06a961f2a5b9d203cb8e78ce09313a0 -Author: Hib Eris <hib@hiberis.nl> -Date: Wed Jan 13 22:20:41 2010 +0000 - - Make poppler (optionally) relocatable on Windows - - configure.ac | 26 ++++++++++++++++++++++ - poppler/GlobalParams.cc | 57 - +++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 83 insertions(+) - -commit 36b67b002db802bfad553720e2114b76b07bb614 -Author: Hib Eris <hib@hiberis.nl> -Date: Wed Jan 13 22:17:03 2010 +0000 - - Make fontconfig optional with mingw compiler - - CMakeLists.txt | 8 +++++++- - config.h.cmake | 6 ++++++ - configure.ac | 39 ++++++++++++++++++++++++++++++++++++++- - makefile.vc | 2 +- - poppler/GlobalParams.cc | 10 +++++++--- - poppler/GlobalParams.h | 7 ++++--- - poppler/GlobalParamsWin.cc | 5 +++++ - 7 files changed, 68 insertions(+), 9 deletions(-) - -commit 9c0b20ab8c104c2f5398a5a3b8409ca554f5fa39 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jan 12 22:55:06 2010 +0000 - - Add the possibility of using float for splash variables instead - of double - - Based on a patch by Marius Vollmer marius.vollmer@nokia.com - See bug 25578 for more info - - CMakeLists.txt | 7 ++++++- - config.h.cmake | 5 ++++- - configure.ac | 10 +++++++++- - splash/SplashMath.h | 14 ++++++++++++-- - splash/SplashTypes.h | 4 +++- - 5 files changed, 34 insertions(+), 6 deletions(-) - -commit 30e5f76e372114339fa1d37c335e6bbade8b6d8a -Author: Pino Toscano <pino@kde.org> -Date: Thu Jan 7 11:18:36 2010 +0100 - - [CMake] followup recent glib/gtk+ version requirements - - - glib to 2.18, see ce9404b1999f81b3f9e5a89bcd6e715463f89024 - - gtk+ to 2.14, see e338643f2cebb1203f7ff0646f87b3dea8318757 - - cmake/modules/FindGTK.cmake | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit e338643f2cebb1203f7ff0646f87b3dea8318757 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jan 7 11:08:31 2010 +0100 - - [tests] Bump GTK+ requirements to 2.14 - - Fixes bug #22090. - - configure.ac | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit ce9404b1999f81b3f9e5a89bcd6e715463f89024 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jan 7 11:06:19 2010 +0100 - - Bump glib requirements to 2.18 - - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 526c8871cbdfbc119e013ee96887a79f65403790 -Author: Hib Eris <hib@hiberis.nl> -Date: Thu Dec 31 17:52:33 2009 +0100 - - [glib] Use PDFDoc(wchar_t *, ...) on Windows - - Fixes bug #25032 - - glib/poppler-document.cc | 22 +++++++++++++++++++--- - 1 file changed, 19 insertions(+), 3 deletions(-) - -commit e0c8188136958b853269179079efefdd3488dc22 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Jan 4 18:36:01 2010 +0000 - - Require Qt 4.4 - - This updates the requirement to real requirement - - CMakeLists.txt | 2 +- - configure.ac | 8 ++++---- - 2 files changed, 5 insertions(+), 5 deletions(-) - -commit f9accdb878b23ebd2152dd05d61cfcc71d46cd03 -Author: Pino Toscano <pino@kde.org> -Date: Mon Jan 4 14:13:13 2010 +0100 - - [Qt4/tests] use getPdfVersion() instead of the deprecated pdfVersion() - - qt4/tests/stress-poppler-dir.cpp | 3 ++- - qt4/tests/stress-poppler-qt4.cpp | 3 ++- - qt4/tests/test-password-qt4.cpp | 4 +++- - qt4/tests/test-poppler-qt4.cpp | 4 +++- - 4 files changed, 10 insertions(+), 4 deletions(-) - -commit 898e939d8c0ac74cc7ee3f5d42d83083ed31036e -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Sat Jan 2 02:33:58 2010 +0100 - - Make pdftoppm embed correct resolution in PNG and JPEG files - - goo/ImgWriter.h | 3 ++- - goo/JpegWriter.cc | 6 +++++- - goo/JpegWriter.h | 3 ++- - goo/PNGWriter.cc | 6 +++++- - goo/PNGWriter.h | 3 ++- - splash/SplashBitmap.cc | 9 +++++---- - splash/SplashBitmap.h | 5 +++-- - utils/HtmlOutputDev.cc | 4 +++- - utils/pdftoppm.cc | 9 +++++---- - 9 files changed, 32 insertions(+), 16 deletions(-) - -commit df569dc2fb89d7e0780bbf7a687ce2464ff5cb43 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Sat Jan 2 01:19:50 2010 +0100 - - enable AM_SILENT_RULES by default - - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit f3862f7d987aae52a1fd2bb0af27d1cd803a5b84 -Author: Pino Toscano <pino@kde.org> -Date: Thu Dec 31 00:20:11 2009 +0100 - - [cpp/tests] poppler-dump: show a string for the font type - - cpp/tests/poppler-dump.cpp | 23 ++++++++++++++++++++++- - 1 file changed, 22 insertions(+), 1 deletion(-) - -commit 9c343c821593ebae51ac47b58ad007a82f198652 -Author: Pino Toscano <pino@kde.org> -Date: Thu Dec 31 00:13:09 2009 +0100 - - [cpp/tests] poppler-dump: show the orientation of the pages - - cpp/tests/poppler-dump.cpp | 16 ++++++++++++++++ - 1 file changed, 16 insertions(+) - -commit bc91fe3824f37cd17a38aac85c817e8ada1b2f43 -Author: Pino Toscano <pino@kde.org> -Date: Wed Dec 30 23:53:31 2009 +0100 - - [cpp/tests] poppler-dump: a bit less output in permissions lines - - cpp/tests/poppler-dump.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 1199de8f097a78edb831313841ac0ed3f9ec9905 -Author: Pino Toscano <pino@kde.org> -Date: Wed Dec 30 23:50:36 2009 +0100 - - [cpp/tests] poppler-dump: add --show-all to show all the information - - cpp/tests/poppler-dump.cpp | 13 +++++++++++++ - 1 file changed, 13 insertions(+) - -commit 9522f830b59942adfc91d5f03c274415a4737ccc -Author: Pino Toscano <pino@kde.org> -Date: Wed Dec 30 23:38:40 2009 +0100 - - [cpp] use iconv for the utf8 <-> utf16 conversions - - cpp/poppler-global.cpp | 92 - +++++++++++++++++++++++++++++++++++--------------- - 1 file changed, 64 insertions(+), 28 deletions(-) - -commit b156b4031f5daf658f40db8efa2a3016d95b98b5 -Author: Pino Toscano <pino@kde.org> -Date: Wed Dec 30 23:24:23 2009 +0100 - - [cpp] add the build system stuff for iconv, mandatory for cpp - - CMakeLists.txt | 6 ++ - Makefile.am | 1 + - cmake/modules/FindIconv.cmake | 57 +++++++++++++ - config.h.cmake | 6 ++ - configure.ac | 6 ++ - cpp/CMakeLists.txt | 2 +- - cpp/Makefile.am | 3 +- - m4/iconv.m4 | 180 - ++++++++++++++++++++++++++++++++++++++++++ - 8 files changed, 259 insertions(+), 2 deletions(-) - -commit a0cffb8b69e0595a2afe15ecc4928e0df1eeb063 -Author: Pino Toscano <pino@kde.org> -Date: Wed Dec 30 18:57:09 2009 +0100 - - [cpp] fixup unicode GooString <-> ustring conversions - - better make them use the "hand-made" code, it is more correct for them - - cpp/poppler-private.cpp | 44 +++++++++++++++++++++++++++++++++++++++++--- - 1 file changed, 41 insertions(+), 3 deletions(-) - -commit 3b6e3605209d5db453725b9ce4e6e54679d9c5da -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Dec 27 15:30:22 2009 +0100 - - Do not crop the transformation matrix at an arbitrary value - - Fixes bug 25763 and gave no regression on my test suite - - poppler/GfxState.cc | 21 --------------------- - poppler/SplashOutputDev.cc | 15 +++++++++++++++ - 2 files changed, 15 insertions(+), 21 deletions(-) - -commit ea44c60645001ffea7d297f8549aaa4f5ce5e16c -Author: Ilya Gorenbein <igorenbein@finjan.com> -Date: Sun Dec 27 15:27:00 2009 +0100 - - Try to work on streams without Length - - We have code that finds the Length if it's wrong so let that code - do its job - instead of returning a NULL stream - - poppler/Parser.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 283dd326a00c804b6332ee3ca1aaa0d86377b3f3 -Author: Pino Toscano <pino@kde.org> -Date: Sat Dec 19 12:50:10 2009 +0100 - - [cpp] fix installation of poppler-version.h with autotools and - builddir != srcdir - - cpp/Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit df0ccddb7f784b4a8564beda51b3047cb9e3611a -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Dec 18 20:23:48 2009 +0000 - - move the retrieval of the bitmap after rendering the page as it can - change on render time - - utils/pdftoppm.cc | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit ab88a02f7efefc950a316d7a5edf88dad8f3e4d0 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Dec 17 18:24:20 2009 +0100 - - [annots] QuadPoints is required in Text Markup annotations - - Show an error message and mark annotation as invalid when it's - missing. - - poppler/Annot.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 39dc99431b3ea9e00f6f645dd7169c0319571dc9 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Dec 17 18:17:20 2009 +0100 - - [annots] Create appearance stream for Sound Annotations when not - defined - - See bug #23108. - - poppler/Annot.cc | 112 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Annot.h | 2 + - 2 files changed, 114 insertions(+) - -commit e4f5a78a853b88b1586ef59fc8893a321ea23736 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Dec 17 17:39:39 2009 +0100 - - [annots] Add Tag and Graph icons for File Attachment annotations - - See bug #23108. - - poppler/Annot.cc | 70 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 70 insertions(+) - -commit 752b14857cfb0669fd6d7dfef2ea73c13a2369fc -Author: Pino Toscano <pino@kde.org> -Date: Thu Dec 17 17:16:01 2009 +0100 - - simplify - - cpp/poppler-toc.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit a26e4b7903fabc667d7d16c23ca2c7a535dd05fa -Author: Pino Toscano <pino@kde.org> -Date: Thu Dec 17 17:09:35 2009 +0100 - - [cpp/tests] add a simple poppler-dump test - - this small test executable can dump various features of the document, - like the general info, permissions, metadata, toc, fonts, - embedded files, pages, etc - - also add the necessary autotools+cmake machinery to compile it - - configure.ac | 1 + - cpp/CMakeLists.txt | 2 + - cpp/Makefile.am | 1 + - cpp/tests/.gitignore | 1 + - cpp/tests/CMakeLists.txt | 24 ++++ - cpp/tests/Makefile.am | 17 +++ - cpp/tests/poppler-dump.cpp | 293 - +++++++++++++++++++++++++++++++++++++++++++++ - 7 files changed, 339 insertions(+) - -commit 86c871cc625d00b8ee7f93dc8c0f9ef8462bba5a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Dec 17 17:05:45 2009 +0100 - - [annots] Create appearance stream for Text Markup Annotations when - not defined - - Highlight annotations are an exception, we always ignore the - appearance stream to use our own, since for most of the documents the - appearance stream provided by the annotation is not enough. That's why - it's currently broken. This is what acroread does indeed and Leonard - Rosenthol recommended us to do the same. - See bug #23108. - - poppler/Annot.cc | 199 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Annot.h | 2 + - 2 files changed, 201 insertions(+) - -commit 904ecd929c6acbbad6d782b950c53c0a80e1f39c -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Dec 17 12:49:20 2009 +0100 - - [annots] Fix memory leaks - - poppler/Annot.cc | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -commit ef7954b86f9b1a762c4f77a48d5f42f8db4bbed7 -Author: Pino Toscano <pino@kde.org> -Date: Tue Dec 15 02:20:18 2009 +0100 - - [cpp] use the correct index (instead of an uninitialized variable) - - cpp/poppler-page.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 2547b5e53e7799cf7299838ae9bd882c21a228ae -Author: Pino Toscano <pino@kde.org> -Date: Tue Dec 15 02:14:57 2009 +0100 - - [cpp] properly delete the children of a toc item - - cpp/poppler-toc.cpp | 1 + - 1 file changed, 1 insertion(+) - -commit 771bd3594740fe16bd030dbe73928a8b1d4d113f -Author: Pino Toscano <pino@kde.org> -Date: Tue Dec 15 02:04:24 2009 +0100 - - [cpp] actually implement toc::root() - - cpp/poppler-toc.cpp | 5 +++++ - 1 file changed, 5 insertions(+) - -commit ca1d2ec4588b2437b58b4448ae2fc5ebd0f130d3 -Author: Pino Toscano <pino@kde.org> -Date: Tue Dec 15 00:54:29 2009 +0100 - - [cpp] fix the reference to the vector data - - cpp/poppler-global.cpp | 2 +- - cpp/poppler-private.cpp | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 16c946e7658b0e9cff701ce1d6bbf7d3828cbe08 -Author: Pino Toscano <pino@kde.org> -Date: Tue Dec 15 00:35:25 2009 +0100 - - [cpp] fix the reference to the vector data - - cpp/poppler-document.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 9bb90c99b65e0e9d9b65c7dbeb5b4d66377ceb21 -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 23:43:12 2009 +0100 - - [cpp] add destructor for 'rectangle' - - cpp/poppler-rectangle.h | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 61ccdc9ab3b816174896fcae0899ff34f11eee80 -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 23:40:51 2009 +0100 - - [cpp] add out stream operators for rect and rectf - - cpp/CMakeLists.txt | 1 + - cpp/Makefile.am | 1 + - cpp/poppler-rectangle.cpp | 35 +++++++++++++++++++++++++++++++++++ - cpp/poppler-rectangle.h | 5 +++++ - 4 files changed, 42 insertions(+) - -commit 69dd51fed3de41f8b799b811ae5ee59c0d5f59c2 -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 22:24:07 2009 +0100 - - [cpp] add namespace to namespace functiond to link properly - - cpp/poppler-global.cpp | 4 ++-- - cpp/poppler-version.cpp | 8 ++++---- - 2 files changed, 6 insertions(+), 6 deletions(-) - -commit 3923fa4890984d8616d86016f4f4a94e8ef3e992 -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 22:23:15 2009 +0100 - - [cpp] add default empty parameters for the passwords of the document - loading functions - - cpp/poppler-document.h | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit 1d23cc677e9b0a9f61c53e0ea365537f33abe5bf -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 21:44:56 2009 +0100 - - [cpp] add "human friendly" output representation for byte_array - - cpp/poppler-global.cpp | 23 +++++++++++++++++++++++ - cpp/poppler-global.h | 3 +++ - 2 files changed, 26 insertions(+) - -commit 82954ea5f8ba880276328765f104690a05adbd9e -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Dec 7 12:05:54 2009 +0100 - - [annot] Create appearance stream for Attachment Annotations when - not defined - - See bug #23108. - - poppler/Annot.cc | 94 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Annot.h | 2 ++ - 2 files changed, 96 insertions(+) - -commit c6195472326c183fcfd8a3e9da1ee7f6fa8b7c3d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Dec 6 17:09:23 2009 +0100 - - [annots] Use opacity when drawing Markup Annotations - - According to the spec: - - "The constant opacity value that shall be used in painting the - annotation. This value shall apply to all visible elements of the - annotation in its closed state (including its background and border) - but - not to the pop-up window that appears when the annotation is opened. - - The specified value shall not used if the annotation has an appearance - stream in that case, the appearance stream shall specify any - transparency. - - If no explicit appearance stream is defined for the annotation, it may - be painted by implementation-dependent means that do not necessarily - conform to the PDF imaging model; in this case, the effect of - this entry - is implementation-dependent as well." - - poppler/Annot.cc | 21 +++++++++++++++------ - poppler/Gfx.cc | 9 ++++++++- - poppler/Gfx.h | 2 +- - 3 files changed, 24 insertions(+), 8 deletions(-) - -commit a337c1d757d52c1c238229d2f0cd3a41694b0e08 -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 16:18:22 2009 +0100 - - [cpp] add document metadata reading - - cpp/poppler-document.cpp | 9 +++++++++ - cpp/poppler-document.h | 1 + - 2 files changed, 10 insertions(+) - -commit 6c4fa513e60dbdd5ab693434f239d82d95756994 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Dec 6 16:56:22 2009 +0100 - - [annot] Create appearance stream for Geometry Annotations when - not defined - - See bug #23108. - - poppler/Annot.cc | 120 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Annot.h | 2 + - 2 files changed, 122 insertions(+) - -commit eed94b8bd2855dce1fd39b835e3280cbd0ccd1cf -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Dec 6 16:51:37 2009 +0100 - - [annot] Create appearance stream for Line Annotations when not defined - - See bug #23108. - - poppler/Annot.cc | 62 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Annot.h | 2 ++ - 2 files changed, 64 insertions(+) - -commit 1c7a5f5e89c4c51e31b6de345d4862ef8dcc2bc0 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Dec 6 16:40:14 2009 +0100 - - [annot] Create appearance stream for Text Annotations when not defined - - Streams have been created by using the svg icons created by mac_v and - ulisse. See bug #23108. - - poppler/Annot.cc | 305 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Annot.h | 2 + - 2 files changed, 307 insertions(+) - -commit c9cb6353ad5279d09615eb2c944b2b053cdf5ccc -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 15:52:25 2009 +0100 - - [cpp] add function to query for document "permissions" - - cpp/poppler-document.cpp | 23 +++++++++++++++++++++++ - cpp/poppler-document.h | 1 + - cpp/poppler-global.h | 4 ++++ - 3 files changed, 28 insertions(+) - -commit 30e90c7c1b41c62ddc21905e7ccdea4c95547e80 -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 15:33:36 2009 +0100 - - [cpp] add is_encrypted and is_linearized for document - - cpp/poppler-document.cpp | 10 ++++++++++ - cpp/poppler-document.h | 2 ++ - 2 files changed, 12 insertions(+) - -commit 93fd588c519958a1f66231c111ea8a6b0a759be1 -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 13:19:24 2009 +0100 - - [cpp] add the possibility to load a document from raw data - - cpp/poppler-document-private.h | 5 +++++ - cpp/poppler-document.cpp | 35 ++++++++++++++++++++++++++++++++++- - cpp/poppler-document.h | 3 +++ - 3 files changed, 42 insertions(+), 1 deletion(-) - -commit 53996365b159cf84adf2cac56c76b8bda8dfb12e -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 12:57:41 2009 +0100 - - [cpp] use the byte_array typedef - - cpp/poppler-embedded-file.cpp | 6 +++--- - cpp/poppler-embedded-file.h | 2 +- - 2 files changed, 4 insertions(+), 4 deletions(-) - -commit e4969c1aaed4a8eb770d8b54920f2476129bbcb7 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Dec 6 16:19:36 2009 +0100 - - [annots] Refactor Annot::setColor to receive an AnnotColor - - Removes duplicated code since color arrays are already parsed in - AnnotColor - - poppler/Annot.cc | 136 - +++++++++++++++++++++++++++++-------------------------- - poppler/Annot.h | 4 +- - 2 files changed, 73 insertions(+), 67 deletions(-) - -commit cfb4f5dfabf31de22d68aa0d5796cb7a33d8b462 -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 11:06:36 2009 +0100 - - [cpp] add a byte_array typedef, and use it for utf8 string data - - cpp/poppler-global.cpp | 12 +++--------- - cpp/poppler-global.h | 5 ++++- - cpp/poppler-private.cpp | 5 ++--- - 3 files changed, 9 insertions(+), 13 deletions(-) - -commit 2d13ac31671b2007e44a90f45a82cb3adfa9c80c -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 02:30:06 2009 +0100 - - update ignore files - - .gitignore | 1 + - cpp/.gitignore | 1 + - 2 files changed, 2 insertions(+) - -commit 01e902e40ca15acf0319e37d39a271d6875bfce9 -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 02:02:47 2009 +0100 - - [cpp] add a version header+functions - - this way, it is possible to get (either at build time and at runtime) - the version of the current poppler-cpp library - - poppler-config.h is generated by the build system (autotools or cmake) - with the correct version information - - configure.ac | 2 ++ - cpp/CMakeLists.txt | 5 +++++ - cpp/Makefile.am | 6 ++++-- - cpp/poppler-version.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ - cpp/poppler-version.h.in | 39 +++++++++++++++++++++++++++++++++++++++ - 5 files changed, 91 insertions(+), 2 deletions(-) - -commit b3f5e5d60bc9109da961940f6216722f9db4a87b -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 00:56:15 2009 +0100 - - [CMake] add the configure check for the Cairo blend modes support - (as in autotools) - - cmake/modules/FindCairo.cmake | 18 ++++++++++++++++++ - config.h.cmake | 3 +++ - 2 files changed, 21 insertions(+) - -commit f6ba877e0c22538cfe34d32d69814f660de59d2c -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 00:44:55 2009 +0100 - - [CMake] add configure check for sys/mman.h (as in autotools) - - ConfigureChecks.cmake | 1 + - config.h.cmake | 3 +++ - 2 files changed, 4 insertions(+) - -commit e12801320ae030628fc62c073983c06b39ee13d7 -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 00:42:20 2009 +0100 - - minor spello - - config.h.cmake | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 6428907ebcf33d4391673aadcfa71c3061f6d352 -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 00:41:49 2009 +0100 - - [CMake] add configure check for fcntl.h (as in autotools) - - ConfigureChecks.cmake | 1 + - config.h.cmake | 3 +++ - 2 files changed, 4 insertions(+) - -commit 916ab7163249e23bd5ba00922fdcad9caaf92c75 -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 00:34:59 2009 +0100 - - [CMake] oops, those should have been '#cmakedefine' and not '#define' - - config.h.cmake | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit ea655d8c7e24e97ee710110a783ed9c209cf76e3 -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 00:33:51 2009 +0100 - - [CMake] move and rename to match more the autotools output - - config.h.cmake | 21 ++++++++++++++------- - 1 file changed, 14 insertions(+), 7 deletions(-) - -commit 9f0146c5b2f9326e834104b89791f66b18f85adc -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 14 00:28:04 2009 +0100 - - [CMake] add checks for gmtime_r and localtime_r - - ConfigureChecks.cmake | 2 ++ - config.h.cmake | 6 ++++++ - 2 files changed, 8 insertions(+) - -commit 9d0cf201e96044dd679c26bea6255d986a6cd246 -Author: Pino Toscano <pino@kde.org> -Date: Sun Dec 13 23:45:39 2009 +0100 - - [cpp] add ignore file - - cpp/.gitignore | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit d783e92b863d8b22de6ca326328115fec63193ed -Author: Pino Toscano <pino@kde.org> -Date: Sun Dec 13 23:42:33 2009 +0100 - - [cpp] don't forget the cmake stuff when packing with the autotools - - Makefile.am | 2 ++ - 1 file changed, 2 insertions(+) - -commit 0105caefe860e7a45fc7d3a1bd1162fe56bcfe6a -Author: Pino Toscano <pino@kde.org> -Date: Sun Dec 13 23:40:55 2009 +0100 - - [cpp] add the pkg-config stuff - - CMakeLists.txt | 3 +++ - Makefile.am | 7 +++++-- - configure.ac | 3 ++- - poppler-cpp.pc.cmake | 9 +++++++++ - poppler-cpp.pc.in | 9 +++++++++ - 5 files changed, 28 insertions(+), 3 deletions(-) - -commit d5a74f78df0dca24fd537b30424fd2ebb3efe3e2 -Author: Pino Toscano <pino@kde.org> -Date: Sun Dec 13 23:35:06 2009 +0100 - - [cpp] add the (rest of the) CMake build system for it - - CMakeLists.txt | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 0e41f937946e4e4c1b660406bd74e4afe8825b5f -Author: Pino Toscano <pino@kde.org> -Date: Sun Dec 13 23:31:46 2009 +0100 - - [cpp] add the autotools buildsystem for it - - Makefile.am | 6 +++++- - configure.ac | 15 +++++++++++++++ - cpp/Makefile.am | 32 ++++++++++++++++++++++++++++++++ - 3 files changed, 52 insertions(+), 1 deletion(-) - -commit 9727fdc0c682742335e44ddc2f32d60e4c59983a -Author: Pino Toscano <pino@kde.org> -Date: Sun Dec 13 22:55:28 2009 +0100 - - Start of a pure C++ frontend for Poppler. - - This initial version (called 'poppler-cpp') includes preliminary - support for: - - document (loading from file name, some query methods, unlocking, - font listing, embedded files) - - page (some query methods) with page transitions - - TOC - - Modelled a bit on the Qt4 API, it provides also an own "ustring" - typedef representing UTF-16 strings, - with methods to convert back/to UTF-8 and Latin 1. - - Most probably it has bugs, but nevertheless worth testing and - developing. - - cpp/CMakeLists.txt | 34 ++++ - cpp/poppler-document-private.h | 55 +++++++ - cpp/poppler-document.cpp | 316 - ++++++++++++++++++++++++++++++++++++ - cpp/poppler-document.h | 92 +++++++++++ - cpp/poppler-embedded-file-private.h | 40 +++++ - cpp/poppler-embedded-file.cpp | 116 +++++++++++++ - cpp/poppler-embedded-file.h | 55 +++++++ - cpp/poppler-font.cpp | 166 +++++++++++++++++++ - cpp/poppler-font.h | 91 +++++++++++ - cpp/poppler-global.cpp | 162 ++++++++++++++++++ - cpp/poppler-global.h | 86 ++++++++++ - cpp/poppler-page-private.h | 44 +++++ - cpp/poppler-page-transition.cpp | 95 +++++++++++ - cpp/poppler-page-transition.h | 82 ++++++++++ - cpp/poppler-page.cpp | 121 ++++++++++++++ - cpp/poppler-page.h | 62 +++++++ - cpp/poppler-private.cpp | 70 ++++++++ - cpp/poppler-private.h | 66 ++++++++ - cpp/poppler-rectangle.h | 60 +++++++ - cpp/poppler-toc-private.h | 62 +++++++ - cpp/poppler-toc.cpp | 136 ++++++++++++++++ - cpp/poppler-toc.h | 74 +++++++++ - 22 files changed, 2085 insertions(+) - -commit 62854051f4e47028147cc93a5faac39e2fa2c9fd -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Dec 12 17:22:08 2009 +0100 - - Initialize profileCommands in Gfx constructor - - poppler/Gfx.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 4e6af25a028d16608111634c5467420e31fa399b -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Dec 9 19:45:40 2009 +0100 - - [cairo] Update font of TextPage in CairoOutputDev::updateAll() - - Fixes a crash with some documents, see Evince bug - https://bugzilla.gnome.org/show_bug.cgi?id=603934 - - poppler/CairoOutputDev.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 6798d3e52e36e91bceff3a1a96372e9d9c6f3813 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Dec 6 15:34:36 2009 +0100 - - Use fixed size array in AnnotColor - - glib/poppler-annot.cc | 2 +- - poppler/Annot.cc | 24 +++++------------------- - poppler/Annot.h | 5 ++--- - poppler/Gfx.cc | 2 +- - qt4/src/poppler-annotation.cc | 2 +- - 5 files changed, 10 insertions(+), 25 deletions(-) - -commit 92fab93bee3748a73c09429cc8a105c16f21fed0 -Author: Axel Struebing <axel.struebing@freenet.de> -Date: Sat Dec 5 22:31:29 2009 +0000 - - Add a empty space after null - - Fixes bug 25465 - - poppler/PDFDoc.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 32103f45d0193b31e95269ea9123b8011d93e994 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Dec 5 10:14:18 2009 +0100 - - [annots] Add isVisible() to check whether annot is visible before - drawing it - - It takes into account annot flags and optional content. - - poppler/Annot.cc | 29 ++++++++++++++--------------- - poppler/Annot.h | 1 + - 2 files changed, 15 insertions(+), 15 deletions(-) - -commit c14dfc7102341f5e1ed67a05c0738d55befab1ec -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Dec 5 10:07:46 2009 +0100 - - [annots] Do not check if annot is a link in Annot::draw() - - AnnotLink already implements draw() - - poppler/Annot.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ddf85d4a51f605eed998c633857b8bb5c74ab590 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Dec 4 14:59:41 2009 +0100 - - Make the code a bit more resilient - - By checking the GooString we are going to use really exists - - poppler/PSOutputDev.cc | 24 ++++++++++++++++-------- - 1 file changed, 16 insertions(+), 8 deletions(-) - -commit 78b4afa0a44048b8d40438d400652dbae4cb99b1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Dec 4 14:57:10 2009 +0100 - - Accept Fontname if FontName is not present - - Fixes KDE bug 217013 - - poppler/GfxFont.cc | 9 +++++++++ - 1 file changed, 9 insertions(+) - -commit fee5cb0eec2ddb8d596289e9a6285cf04d97632e -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Dec 4 13:26:42 2009 +0100 - - [annots] Remove redundant flags definition - - poppler/Annot.cc | 22 +++++++++------------- - 1 file changed, 9 insertions(+), 13 deletions(-) - -commit 3a94e8ce90c0a4d11c5c5aa8805c167c8a0434e5 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Nov 27 15:23:11 2009 +0100 - - [cairo] Revert commit 77c2e154c2cb57300116ecd4295f1e67b06b411f - - And fix bug #24575 jut by checking pointer is not null before - using it. - - poppler/CairoOutputDev.cc | 12 +++++------- - 1 file changed, 5 insertions(+), 7 deletions(-) - -commit a093b768e64d477ebdd5f6b519d80a6c45706e7e -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Nov 22 20:23:49 2009 +0100 - - Add copyrights - - poppler/CairoFontEngine.cc | 2 +- - poppler/CairoOutputDev.cc | 4 ++-- - poppler/CairoOutputDev.h | 2 +- - 3 files changed, 4 insertions(+), 4 deletions(-) - -commit 77c2e154c2cb57300116ecd4295f1e67b06b411f -Author: David Benjamin <davidben@mit.edu> -Date: Sun Nov 22 20:19:29 2009 +0100 - - Do not crash on malformed files - - bug 24575 - - poppler/CairoOutputDev.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 1d0cb9b2cfd4d4d9aa9b0ad83ad6408544263a09 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Nov 22 19:59:34 2009 +0100 - - [cairo] Initialize fill_color and stroke_color - - poppler/CairoOutputDev.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 32de2ac62fb87570e1a59152f37b86e571a01180 -Author: Ilya Gorenbein <igorenbein@finjan.com> -Date: Sun Nov 22 19:51:54 2009 +0100 - - Improve the reconstruction of the XRef - - Makes load a file Ilya can't share - - poppler/XRef.cc | 165 - ++++++++++++++++++++++++++++++++------------------------ - 1 file changed, 95 insertions(+), 70 deletions(-) - -commit 039c6dffbfbed46a11e207048a3247d6921d6b02 -Author: Ilya Gorenbein <igorenbein@finjan.com> -Date: Sun Nov 22 15:14:20 2009 +0100 - - Correctly initialize fileName - - poppler/Link.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit b905caf1785ee207cc0480953da69be302d3d4e9 -Author: David Benjamin <davidben@mit.edu> -Date: Sat Nov 21 02:43:21 2009 +0100 - - Be more lenient with /Decode key on images - - The spec requires the field be [1 0] or [0 1]. Adobe accepts - floating point - values as well. This fixes bug #17439. - - poppler/Gfx.cc | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -commit d99e7a88845a5f4b35e2c538c597316b2ad541ca -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Nov 20 22:09:44 2009 +0100 - - Check for openjpeg in the C++ part as it uses bool in the header - - Bug 25103 - - configure.ac | 61 - ++++++++++++++++++++++++++++++------------------------------ - 1 file changed, 30 insertions(+), 31 deletions(-) - -commit 55261a2dc86241c8d132e590e76e7398b3ca5090 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 18 22:26:01 2009 +0100 - - replace floor with a cast to int for numbers > 0 - - bug-poppler13487.pdf gets a 15% faster rendering - - splash/SplashMath.h | 19 +++++++++++++++++-- - 1 file changed, 17 insertions(+), 2 deletions(-) - -commit 28df9fb323f14dc632c9502655abf69984b7d67e -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 18 21:57:02 2009 +0100 - - Remove unused label - - poppler/Catalog.cc | 1 - - 1 file changed, 1 deletion(-) - -commit 037979a01a6fcafc61360e758dbc4a5eb056825e -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Nov 17 19:12:30 2009 +0100 - - [cairo] If there's a soft mask available when filling, apply the - mask instead of filling - - Fixes bug #8474. - - poppler/CairoOutputDev.cc | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -commit 46380d36f004d71dd2c2e7bc82836af248684b51 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Nov 17 20:48:22 2009 +0100 - - i didn't want to commit this - - configure.ac | 60 - +++++++++++++++++++++++++++-------------------------- - splash/SplashMath.h | 5 ++--- - utils/pdftoppm.cc | 8 ------- - 3 files changed, 33 insertions(+), 40 deletions(-) - -commit 1844e0927ae89824f59b2b3378bf5e00a51a251c -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Nov 17 20:34:24 2009 +0100 - - do not use setAttribute with doubles - - it is evil and locale dependant, we do NOT want that so use - QString::number - - configure.ac | 60 +++++++++++++++---------------- - qt4/src/poppler-annotation.cc | 82 - +++++++++++++++++++++---------------------- - splash/SplashMath.h | 5 +-- - utils/pdftoppm.cc | 8 +++++ - 4 files changed, 81 insertions(+), 74 deletions(-) - -commit 572d79f4b8a7bf1717b88dbd2609d8fa9b036dee -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Nov 15 20:40:56 2009 +0100 - - Only calculate the matrix when it is really needed - - That only happens when outputting to 1 bit images - Speeds out rendering on some pdf up to 40% - - splash/SplashScreen.cc | 35 +++++++++++++++++++++++++++++++++-- - splash/SplashScreen.h | 16 ++++++++++++++++ - 2 files changed, 49 insertions(+), 2 deletions(-) - -commit 1c3113361fa376093e6fedfbf48feee7dcbc46b7 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Sun Nov 15 19:43:18 2009 +0100 - - Write out fixed-content portion of Type 1 fonts in PSOutputDev - - If /Length3 of a Type 1 FontFile is > 0 the fixed-content from the - FontFile should be used instead of adding the generic 512 zeros and - cleartomark. - - poppler/PSOutputDev.cc | 18 +++++++++++++----- - 1 file changed, 13 insertions(+), 5 deletions(-) - -commit 2d30dc605cd984f6c32124af9aa7b877d416d141 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Nov 15 17:31:36 2009 +0100 - - [glib-demo] Show attachment name in FileAttachment annot properties - table - - glib/demo/annots.c | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 6c8ae140256818401351a331787c83e043fdba09 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Nov 15 17:31:13 2009 +0100 - - [glib] Add poppler_annot_file_attachment_get_name() - - glib/poppler-annot.cc | 36 +++++++++++++++++++++++++++++------- - glib/poppler-annot.h | 1 + - 2 files changed, 30 insertions(+), 7 deletions(-) - -commit ecf5173eb288187a1f076fd4b116f1212fa9e203 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Nov 15 17:14:29 2009 +0100 - - [glib-demo] Add properties of FileAttachment annotations - - glib/demo/annots.c | 67 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 67 insertions(+) - -commit 8f4fdd864d79e4fa83951a3eb006ea8287c3a1ba -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Nov 15 17:12:43 2009 +0100 - - [glib-demo] Add pgd_table_add_property_with_custom_widget() - - To be able to add properties to a table that are not labels - - glib/demo/utils.c | 31 +++++++++++++++++++++---------- - glib/demo/utils.h | 30 +++++++++++++++++------------- - 2 files changed, 38 insertions(+), 23 deletions(-) - -commit 061b85f7a442107cda67e385bd772ec8565a936e -Author: Thomas Viehmann <tv@beamnet.de> -Date: Sun Nov 15 17:11:43 2009 +0100 - - [glib] Add support for file attachment annotations - - glib/poppler-annot.cc | 69 - +++++++++++++++++++++++++++++++++++++++++++++++--- - glib/poppler-annot.h | 8 ++++++ - glib/poppler-page.cc | 3 +++ - glib/poppler-private.h | 1 + - glib/poppler.h | 49 +++++++++++++++++------------------ - 5 files changed, 102 insertions(+), 28 deletions(-) - -commit 189c45332991bce51e40bcaf65da67d2d644045a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Nov 15 16:42:21 2009 +0100 - - [glib] Remove PopplerDocument from PopplerAttachment - - Since we are duplicating the stream we don't need to hold a - reference of - PopplerDocument anymore. - - glib/poppler-attachment.cc | 13 +------------ - glib/poppler-document.cc | 2 +- - glib/poppler-private.h | 3 +-- - 3 files changed, 3 insertions(+), 15 deletions(-) - -commit e55bfeb1ddc60053c5ee5fef840c409891781ce6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Nov 13 00:55:37 2009 +0100 - - jpeg_start_decompress can fail, check it - - Fixes KDE bug #214317 - - poppler/DCTStream.cc | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -commit c59d93061cf71d13916872a20aed37ecfbb3bfa4 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Nov 9 18:32:55 2009 +0100 - - [cairo] Do nothing when image mask is 1x1 and the pixel is 0 - - poppler/CairoOutputDev.cc | 14 ++++++++++++++ - 1 file changed, 14 insertions(+) - -commit 448f03cfc429d33bfa5527e3dc964ef5da10ee94 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Mon Nov 9 22:52:39 2009 +1030 - - Don't render the color white in type 3 glyphs in the cairo backend - - PDF allows the "g" operator in Type 3 charprocs but cairo user fonts - will render any stroke or fill in the font color. - - As the only PDFs I've seen with "g" in the charprocs are only using - the gray values 0 or 1, a workaround is to disable strokes and fills - of the charproc when the gray level is > 0.5. - - poppler/CairoOutputDev.cc | 14 ++++++++++++++ - 1 file changed, 14 insertions(+) - -commit 3fead2a3b53681ef95116f18f17f1a9febec6e48 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Nov 9 11:25:24 2009 +0100 - - Transitions dictionary can be a Ref too - - poppler/Page.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ac4955d03a532cab1933698aeb667d44300e52d0 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Nov 9 11:12:48 2009 +0100 - - [glib-demo] Explicitely add gio as dependency for GTK+ tests - - configure.ac | 4 ++-- - glib/demo/main.c | 1 + - 2 files changed, 3 insertions(+), 2 deletions(-) - -commit 32ea667ec8f18311539123c7b80c7ab4767070cb -Author: Chris Wilson <chris@chris-wilson.co.uk> -Date: Tue Aug 11 19:17:52 2009 +0100 - - [cairo] Mark images dirty - - After directly manipulating the pixel values we need to mark the - surface - as dirty. This means that cairo will refresh any caches it may - have taken - of the surface will the new data. - - poppler/CairoOutputDev.cc | 8 ++++++++ - 1 file changed, 8 insertions(+) - -commit 10a41150c4067bb3ab85e25dae76e0968a6cd586 -Author: Chris Wilson <chris@chris-wilson.co.uk> -Date: Tue Aug 11 19:17:06 2009 +0100 - - [cairo] Use colToDbl() to avoid rounding error. - - poppler/CairoOutputDev.cc | 37 +++++++++++++++++++------------------ - 1 file changed, 19 insertions(+), 18 deletions(-) - -commit c9491319689f04edd57adda7ee85f84f17fd1c47 -Author: Chris Wilson <chris@chris-wilson.co.uk> -Date: Tue Aug 11 18:07:17 2009 +0100 - - [cairo] Reduce the number of redundant pattern creations - - poppler/CairoOutputDev.cc | 84 - ++++++++++++++++++++++++++++------------------- - 1 file changed, 51 insertions(+), 33 deletions(-) - -commit ead78d9f703c8b2d556c94be3c47dbae7469eda8 -Author: Reece Dunn <msclrhd@gmail.com> -Date: Thu Nov 5 22:25:14 2009 +0100 - - fontpos is never set to -1, so remove the checks in HtmlOutputDev. - - utils/HtmlOutputDev.cc | 11 +++-------- - 1 file changed, 3 insertions(+), 8 deletions(-) - -commit 55dd6024a4672a1787e8b1a8276bd78fff94e2cd -Author: Ilya Gorenbein <igorenbein@finjan.com> -Date: Wed Nov 4 22:07:18 2009 +0100 - - Do not error on files without "Count" and "Kids" - - It is not spec compliant not to have those fields but Adobe Reader and - FoxIt seems to allow it so try to behave like them. See bug 24720 - to see why one would want such file - - poppler/Catalog.cc | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -commit 58a1d42aed7352c008d201b8f355f6e4146f71e5 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Oct 29 18:38:22 2009 +0100 - - [cairo] Don't render patterns when using CairoImageOutputDev - - poppler/CairoOutputDev.h | 15 +++++++++++++-- - 1 file changed, 13 insertions(+), 2 deletions(-) - -commit 7670cc48dcf3ffd77e3ffa29056a3e13b2926709 -Author: Ilya Gorenbein <igorenbein@finjan.com> -Date: Wed Oct 28 19:20:41 2009 +0100 - - There are some pdf where Aspect values are reals, use getNum - - Fixes bug 24733 - - poppler/Annot.cc | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -commit 4fe89e520a04a6ab6d6ec6a8294896b2f427c7da -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Oct 25 21:55:55 2009 +0100 - - do not accept negative interval lengths in the page labels tree - - See bug 24721 - - poppler/PageLabelInfo.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit b174ebd6b323c7a58a19d59c1a9e4ac4e6cba7d9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Oct 23 21:57:42 2009 +0200 - - Move the iccColorSpaceCache from a static in GfxState to a member - of Gfx - - Fixes the problem that the keys are per document but we had a static - that lived as much as the library. Now the cache only lives the - rendering - of a page so it's a bit slower but at least it's correct. Fixes - bug 24686 - - poppler/Gfx.cc | 49 ++++++++++++++++++---------- - poppler/Gfx.h | 13 ++++++-- - poppler/GfxState.cc | 94 - ++++++++++++++++++++++++++--------------------------- - poppler/GfxState.h | 33 +++++++++---------- - poppler/Page.cc | 4 +-- - 5 files changed, 107 insertions(+), 86 deletions(-) - -commit 4a9bdd30dc353865685e03eb1c1ac6093797695a -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Oct 22 21:26:29 2009 +0200 - - initialize len at 0 when reading the font fails - - See bug 24525 for more info - - poppler/GfxFont.cc | 1 + - 1 file changed, 1 insertion(+) - -commit c839b706092583f6b12ed3cc634bf5af34b7a2bb -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Oct 20 10:09:13 2009 +0200 - - [glib] Fix CVE-2009-3607 - - glib/poppler-page.cc | 20 ++++++++++---------- - 1 file changed, 10 insertions(+), 10 deletions(-) - -commit 44462e0ca39392e5629020226b901e4026089b46 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Oct 19 23:33:58 2009 +0200 - - fix memory leak - - poppler/PSOutputDev.cc | 1 + - 1 file changed, 1 insertion(+) - -commit d701aaa9eaa62567210070129f5feffe24bf1936 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Oct 18 01:22:16 2009 +0200 - - This include is needed as this file uses Ref - - poppler/OutputDev.h | 1 + - 1 file changed, 1 insertion(+) - -commit d4202536e1b62c326c301d5088fa0e176c523e85 -Author: Pino Toscano <pino@kde.org> -Date: Sat Oct 17 01:35:11 2009 +0200 - - SplashGlyphBitmap is a struct and not a class - - poppler/ArthurOutputDev.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 654176dee7c9325aa5a24a2de3c070faa16e8a9c -Author: Michael Jansen <kde@michael-jansen.biz> -Date: Sat Oct 17 01:30:40 2009 +0200 - - CMake: add the possibility to pass LIB_SUFFIX. - - This allows to tune the installation libdir by adding a suffix for it - (making it eg lib, lib32, or lib64) - - CMakeLists.txt | 16 +++++++++------- - glib/CMakeLists.txt | 2 +- - poppler-cairo.pc.cmake | 2 +- - poppler-glib.pc.cmake | 2 +- - poppler-qt.pc.cmake | 2 +- - poppler-qt4.pc.cmake | 2 +- - poppler-splash.pc.cmake | 2 +- - poppler.pc.cmake | 2 +- - qt/CMakeLists.txt | 2 +- - qt4/src/CMakeLists.txt | 2 +- - 10 files changed, 18 insertions(+), 16 deletions(-) - -commit 43829ae4b25a88ace06f05fa6750e5732539f4be -Author: Pino Toscano <pino@kde.org> -Date: Sat Oct 17 01:21:39 2009 +0200 - - put a space so MSVC won't try to see it as comment - - poppler/GfxState.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit f64086ea22a4e8cb3d4e7116db2a9541ac2fb19f -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 17 00:48:58 2009 +0200 - - check the document is not locked when printing - - qt4/src/poppler-ps-converter.cc | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit 85d1015480b7ab3f21cc5f78dc53d4c5efdc6e60 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 17 00:48:27 2009 +0200 - - fix file name comment - - qt4/src/poppler-ps-converter.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 270764ad1bf2cfe95aed0b6850d2347361b4268d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 17 00:47:34 2009 +0200 - - Add a way for converters to return more exact errors they had when - converting - - qt4/src/poppler-base-converter.cc | 8 +++++++- - qt4/src/poppler-converter-private.h | 3 ++- - qt4/src/poppler-pdf-converter.cc | 11 ++++++++++- - qt4/src/poppler-ps-converter.cc | 6 +++++- - qt4/src/poppler-qt4.h | 14 ++++++++++++++ - 5 files changed, 38 insertions(+), 4 deletions(-) - -commit 1082e1671afd8ab91583dabc876304008acb021c -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Oct 16 23:17:22 2009 +0200 - - Some "security" fixes based on newly released Xpdf 3.02pl4 - - poppler/Stream.cc | 4 ++++ - poppler/XRef.cc | 19 +++++++++++++++---- - splash/Splash.cc | 7 +++++++ - splash/SplashBitmap.cc | 37 ++++++++++++++++++++++++++++++------- - splash/SplashErrorCodes.h | 4 +++- - 5 files changed, 59 insertions(+), 12 deletions(-) - -commit c2458275e02f56226779b82d73c13defcbbda563 -Author: Glenn Ganz <glenn.ganz@uptime.ch> -Date: Fri Oct 16 20:54:32 2009 +0200 - - fix constructor of DCTStream - - poppler/Stream.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit fd91b79c053bb5cd01a766032b90981dbc5e5dd3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 10 14:53:42 2009 +0200 - - fix compiling with automake - - goo/Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit c3031b4318af6f85256f2478c8678dedd0d6acd1 -Author: Pino Toscano <pino@kde.org> -Date: Fri Oct 9 16:17:16 2009 +0200 - - cmake: simplify the linking to libpng - - CMakeLists.txt | 7 +++---- - 1 file changed, 3 insertions(+), 4 deletions(-) - -commit 96688dd7a091f8fa141fad2b3d05bae04b0b86fb -Author: Patrick Spendrin <ps_ml@gmx.de> -Date: Fri Oct 9 16:09:46 2009 +0200 - - MSVC: add _CRT_SECURE_NO_WARNINGS to the define's - - CMakeLists.txt | 1 + - 1 file changed, 1 insertion(+) - -commit f346c1f6b55f87ebd6bb0b0932462d5514aa40ff -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Oct 9 00:29:06 2009 +0200 - - add -ansi flag to default warnings - - cmake/modules/PopplerMacros.cmake | 2 +- - configure.ac | 2 +- - utils/parseargs.c | 30 +++++++++++++++--------------- - utils/parseargs.h | 26 +++++++++++++------------- - 4 files changed, 30 insertions(+), 30 deletions(-) - -commit 53e0016b772f1b78d998506e2f3106011d32cef3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Oct 9 00:15:52 2009 +0200 - - Add virtual destructor to ImgWriter - - CMakeLists.txt | 1 + - goo/ImgWriter.cc | 15 +++++++++++++++ - goo/ImgWriter.h | 2 ++ - goo/Makefile.am | 1 + - 4 files changed, 19 insertions(+) - -commit 699dcacced7be05b788c414c231dc2b5c07de06e -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Oct 9 00:13:11 2009 +0200 - - Add -Wnon-virtual-dtor flag - - cmake/modules/PopplerMacros.cmake | 4 ++-- - configure.ac | 2 +- - 2 files changed, 3 insertions(+), 3 deletions(-) - -commit d1e4fca4a8602994b010fae4f4fea5cd4df9276e -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Oct 9 00:10:03 2009 +0200 - - build on cmake too - - CMakeLists.txt | 1 + - 1 file changed, 1 insertion(+) - -commit d67511c92022121066f43003f01b955962ddcd33 -Author: Stefan Thomas <thomas@eload24.com> -Date: Fri Oct 9 00:09:23 2009 +0200 - - Add -jpeg to pdftoppm - - goo/ImgWriter.h | 28 +++++++++++++++ - goo/JpegWriter.cc | 92 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - goo/JpegWriter.h | 42 +++++++++++++++++++++++ - goo/Makefile.am | 2 ++ - goo/PNGWriter.cc | 5 +-- - goo/PNGWriter.h | 10 +++--- - splash/SplashBitmap.cc | 46 +++++++++++++++++-------- - splash/SplashBitmap.h | 5 +-- - splash/SplashTypes.h | 11 ++++++ - utils/pdftoppm.1 | 3 ++ - utils/pdftoppm.cc | 22 +++++++++--- - 11 files changed, 239 insertions(+), 27 deletions(-) - -commit 388196df1fb05fb2d88ae82bd81e823a23588ec1 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Oct 7 17:11:58 2009 +0200 - - [glib-demo] Show some of the annot flags in annots treeview - - glib/demo/annots.c | 35 +++++++++++++++++++++++++++++++++-- - 1 file changed, 33 insertions(+), 2 deletions(-) - -commit 034907c6582c1f50782ec9c58a29b140c6fc0688 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Oct 6 00:52:10 2009 +0200 - - Forgot to update the year here - - qt4/src/poppler-private.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit fef89acebf5312324c104fb52e629563fbc2de76 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Oct 6 00:42:52 2009 +0200 - - Add the possibility of enabling hinting - - qt4/src/poppler-document.cc | 2 +- - qt4/src/poppler-private.h | 1 + - qt4/src/poppler-qt4.h | 3 ++- - 3 files changed, 4 insertions(+), 2 deletions(-) - -commit 485252844b5e0964ee724b74e2a7ba2b820b259e -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Oct 6 00:41:57 2009 +0200 - - rework how hinting is used in the splash backend - - Basically we default to no hinting now with the possibility to - enable it - - poppler/ArthurOutputDev.cc | 2 +- - poppler/GlobalParams.cc | 19 ------------- - poppler/GlobalParams.h | 3 --- - poppler/SplashOutputDev.cc | 8 +++++- - poppler/SplashOutputDev.h | 3 +++ - splash/SplashFTFont.cc | 64 - ++++++++++---------------------------------- - splash/SplashFTFont.h | 4 +-- - splash/SplashFTFontEngine.cc | 8 +++--- - splash/SplashFTFontEngine.h | 7 ++--- - splash/SplashFontEngine.cc | 5 ++-- - splash/SplashFontEngine.h | 3 ++- - 11 files changed, 40 insertions(+), 86 deletions(-) - -commit 8194c156cf2167834779e1690a89b5068baf8d58 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Oct 5 00:55:55 2009 +0200 - - Fix includes for those using internal headers - - goo/FixedPoint.h | 2 +- - goo/gmem.h | 2 +- - poppler/OutputDev.h | 2 +- - poppler/PSOutputDev.h | 2 +- - poppler/PageLabelInfo.h | 2 +- - utils/ImageOutputDev.h | 2 +- - 6 files changed, 6 insertions(+), 6 deletions(-) - -commit 091f68ccd59413d6890dfbfcf8911f112e690b50 -Author: Kovid Goyal <kovid@kovidgoyal.net> -Date: Mon Oct 5 00:39:36 2009 +0200 - - Use _WIN32 instead of WIN32 - - More info at http://bugs.freedesktop.org/show_bug.cgi?id=24259 - - goo/GooMutex.h | 16 +++++++++++++++- - goo/gfile.cc | 33 +++++++++++++++++---------------- - goo/gfile.h | 5 +++-- - msvc/poppler/poppler-config.h | 2 +- - poppler-config.h.cmake | 2 +- - poppler/ABWOutputDev.h | 3 ++- - poppler/FileSpec.cc | 7 ++++--- - poppler/GlobalParams.cc | 37 +++++++++++++++++++------------------ - poppler/GlobalParams.h | 4 ++-- - poppler/Link.cc | 3 ++- - poppler/PDFDoc.cc | 4 ++-- - poppler/PDFDoc.h | 3 ++- - poppler/PSOutputDev.cc | 5 +++-- - poppler/TextOutputDev.cc | 5 +++-- - poppler/XpdfPluginAPI.cc | 13 ++++++++++++- - poppler/poppler-config.h.in | 2 +- - splash/SplashFontEngine.cc | 9 +++++---- - test/perf-test.cc | 24 ++++++++++++------------ - utils/HtmlOutputDev.h | 3 ++- - 19 files changed, 108 insertions(+), 72 deletions(-) - -commit 7fd8bdfa450db4e323e4e5d12159359fbc47f9ed -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Oct 5 00:21:15 2009 +0200 - - Remove spurious ; - - Found by -Wextra i think we should add more warnings to our default - flags - - qt4/src/poppler-annotation.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit d46f7343e446331489d3fe6711a7cf778e0bd902 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Oct 2 22:04:46 2009 +0200 - - Strings can have 0 inside so use the length - - Fixes saving some files - - poppler/PDFDoc.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 2bc2040081919340415f576ce8266356deadbfcd -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Oct 2 22:04:03 2009 +0200 - - Increase decimals from 5 to 10, a double has that precision - - Makes saving more faithful for some files - - poppler/PDFDoc.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 05eb7342d5234732f27c9c67b7fc1f9e40a4e075 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Oct 2 22:03:40 2009 +0200 - - If the stream was wrongly formed save the correct length - - Fixes saving of some files - - poppler/PDFDoc.cc | 12 ++++++++++++ - 1 file changed, 12 insertions(+) - -commit b98faa4c162392d9416a5a93c9042b41f82d8657 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Oct 2 22:02:13 2009 +0200 - - Return the save status as program status - - test/pdf-fullrewrite.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit f73f59f2c7bb7c7d57eb70cdc1bc30b80a92d0b7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Oct 2 22:01:45 2009 +0200 - - If the Length entry of the stream is wrong, fix it - - Fixes saving some files - - poppler/Parser.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 91135c7e788bc32e414e1a9c9ab43b326a07e970 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Oct 2 22:00:12 2009 +0200 - - increase the range of characters we sanitize - - Fixes saving of some files - - goo/GooString.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 9dcb3e8be2cd52a795605548e43d6bfc149b2ea5 -Author: Yaakov Selkowitz <yselkowitz@users.sourceforge.net> -Date: Sun Sep 27 17:17:32 2009 +0200 - - Fix the linking not to use the .so directly but the lib - - Fixes check on cygwin - - m4/qt.m4 | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit ed4a6f1cfc7ccd2717d939841c092347c3307547 -Author: Kovid Goyal <kovid@kovidgoyal.net> -Date: Sat Sep 26 19:26:19 2009 +0200 - - Do not crash when saving files that come from a stream without name - - Bug 24090 - - poppler/PDFDoc.cc | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -commit 04b232d48930af9bc614d7fef47f79ce247713a4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Sep 26 18:30:41 2009 +0200 - - Write the Info into the trailer dict if there is one - - Bug 24091 - - poppler/PDFDoc.cc | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -commit 343e4f9aceb935eb393ad94bbef4dbb1b1a450ee -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Sep 26 18:28:40 2009 +0200 - - Plug leak - - test/pdf-fullrewrite.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 2ea0032283c4717f1bb285fab7956fc38f375e87 -Author: Yaakov Selkowitz <yselkowitz@users.sourceforge.net> -Date: Sat Sep 26 15:01:35 2009 +0200 - - Patch to make poppler work on Cygwin - - Bug 4195 - - configure.ac | 3 +++ - qt/Makefile.am | 2 +- - qt4/src/Makefile.am | 2 +- - 3 files changed, 5 insertions(+), 2 deletions(-) - -commit 074dc5e5e39cebc1fbe9bf6a15b2cae2391006c1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Sep 26 14:56:38 2009 +0200 - - Improve realibility for Streams with broken Length - - Fixes bug 6841 - - poppler/Parser.cc | 17 +++++++++++++---- - 1 file changed, 13 insertions(+), 4 deletions(-) - -commit b7702820245fb6cdbf77afba37c53c03d4362a25 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 21 21:58:26 2009 +0200 - - Print with a . and not with a , in all locales - - This is a regression after the removal of setting LC_NUMERIC - - poppler/PDFDoc.cc | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -commit d31080d8195694cef740d4e77484179bb38d1f26 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Sep 20 17:21:13 2009 +0200 - - CharCodeToUnicode is not mandatory in fonts, don't crash one fonts - that do not have it - - Fixes bug #24036 - - poppler/Annot.cc | 33 ++++++++++++++++++++------------- - 1 file changed, 20 insertions(+), 13 deletions(-) - -commit a729d005a7204791fa8415de5aa0834136073ce8 -Author: Pino Toscano <pino@kde.org> -Date: Thu Sep 17 20:12:20 2009 +0200 - - Windows32/MSVC: initialize the font list once per GlobalParams, - instead of once at all - - this fixes the font list being empty at the second (and following) - GlobalParams creation - thanks for Christian Ehrlicher for reporting the bug and testing - its fix - - poppler/GlobalParams.cc | 1 + - poppler/GlobalParams.h | 1 + - poppler/GlobalParamsWin.cc | 1 - - 3 files changed, 2 insertions(+), 1 deletion(-) - -commit 68711d8494e2765c4a24ea59ce8d904981f0f917 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 9 23:24:22 2009 +0200 - - uint -> Guint - - some compilers don't know about uint - - poppler/Gfx.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 943a13c9354dec18cb023642aebbe5d3bb920ed7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 9 20:04:06 2009 +0200 - - poppler 0.12.0 - - CMakeLists.txt | 4 ++-- - NEWS | 18 ++++++++++++++++++ - configure.ac | 4 ++-- - msvc/config.h | 6 +++--- - qt4/src/Doxyfile | 2 +- - 5 files changed, 26 insertions(+), 8 deletions(-) - -commit e8ed7210346cb18f6e4588ad557f993c6d42f4a3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 9 19:21:21 2009 +0200 - - increase library to 3.2.0 - - qt4/src/CMakeLists.txt | 2 +- - qt4/src/Makefile.am | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit e950107006a3b1889646d3705323c1b3d41eaa49 -Author: David Benjamin <davidben@mit.edu> -Date: Wed Sep 9 01:19:38 2009 +0200 - - Fix infinite loop in JBIG2Decoder - - Bug 23025 - Also fixes problems in bug-poppler6881-2.pdf and bug-poppler6500.pdf - - poppler/JBIG2Stream.cc | 13 ++++++++----- - 1 file changed, 8 insertions(+), 5 deletions(-) - -commit 1cb25a4adaaf3e2da50724312a3db6928991f425 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Sep 6 10:45:56 2009 +0200 - - [glib] Ignore attachments with an invalid embedded file - - Fixes bug #10386 - - glib/poppler-document.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 842e00f3114666609ef4dec6fa613d46f330a40c -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Sep 5 15:20:35 2009 +0200 - - Add EmbeddedFile::isValid - - Also do not crash if data() is called on an invalid file - - qt4/src/poppler-embeddedfile.cc | 10 +++++++++- - qt4/src/poppler-qt4.h | 9 ++++++++- - 2 files changed, 17 insertions(+), 2 deletions(-) - -commit 9d40b268f5a9a9a0fb79da0e1627dd8eebc4db6a -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Sep 5 15:19:27 2009 +0200 - - Add EmbFile::isOk - - At the moment returns false if the object stream is not really - a stream - - poppler/Catalog.h | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 642650b6f70425c8fff2df978ae71249a5ae07f3 -Author: David Benjamin <davidben@mit.edu> -Date: Sat Sep 5 01:12:49 2009 +0200 - - Better fallback when there's a type mismatch - - Bug #17252 - - poppler/GfxFont.cc | 38 ++++++++++++++++++++++++++++++++------ - 1 file changed, 32 insertions(+), 6 deletions(-) - -commit bf5811f5331292ccf30f1b0f089fe43d351d96be -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Aug 26 00:43:46 2009 +0200 - - Improve shading color rendering - - Shading is not necessarily lineal so require another bisection to - assume all the area in between have the same color. Fixes bug #20238 - - poppler/Gfx.cc | 17 ++++++++++++++++- - 1 file changed, 16 insertions(+), 1 deletion(-) - -commit e94430b790fde6ce7b7cb163c2e0adf2d071c81d -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Aug 26 00:42:49 2009 +0200 - - Make code a bit more readable - - poppler/Gfx.cc | 23 +++++++++++------------ - 1 file changed, 11 insertions(+), 12 deletions(-) - -commit 465212780557705fd939dfe54f96913505bfc96e -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Aug 25 21:55:45 2009 +0200 - - forgot to update my copyright - - poppler/JPEG2000Stream.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 4f6016d01ced32002bef22b9b5d5426a74e55842 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Aug 25 21:10:07 2009 +0200 - - Fix format security warnings - - Don't just directly print strings of unknown content; use "%s". - - poppler/JPEG2000Stream.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 4616b23382b5d155f8b2f1942733037cf5730844 -Author: Christian Persch <chpe@gnome.org> -Date: Tue Aug 25 21:09:40 2009 +0200 - - Fix format security warnings - - Don't just directly print strings of unknown content; use "%s". - - poppler/GfxState.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 6c5c8d008456d1e4f3d60bc182209747c2a175dc -Author: Christian Persch <chpe@gnome.org> -Date: Tue Aug 25 21:03:16 2009 +0200 - - Support AM_SILENT_RULES - - When using automake 1.11, should support silent build rules. - - Makefile.am | 2 +- - configure.ac | 1 + - glib/Makefile.am | 4 ++-- - qt4/demos/Makefile.am | 2 +- - qt4/src/Makefile.am | 2 +- - qt4/tests/Makefile.am | 2 +- - 6 files changed, 7 insertions(+), 6 deletions(-) - -commit e7dd1c47b01d8f31599ee686eafbe7c54d7c023a -Author: Christian Persch <chpe@gnome.org> -Date: Tue Aug 25 21:01:13 2009 +0200 - - Fix automake check, and add automake 1.11 support - - Fix the automake checks to take the *newest* version available, - not the - oldest one. Add support for automake 1.11. FDO#23473. - - autogen.sh | 13 +++++++------ - 1 file changed, 7 insertions(+), 6 deletions(-) - -commit 493d2c5aa78a3241e70108c5d7eccba9ac72f834 -Author: Rex Dieter <rdieter@math.unl.edu> -Date: Mon Aug 24 20:08:46 2009 +0200 - - Use Requires.private if available - - The following patch minimizes pkg-config deps similar to how the - glib-related pkg-config deps are done. - - poppler-qt.pc.cmake | 3 ++- - poppler-qt.pc.in | 3 ++- - poppler-qt4.pc.cmake | 3 ++- - poppler-qt4.pc.in | 3 ++- - 4 files changed, 8 insertions(+), 4 deletions(-) - -commit 341cd3ecd08a39cd146c1c57f356b50a2881c03f -Author: Jakub Wilk <ubanus@users.sf.net> -Date: Mon Aug 24 19:51:34 2009 +0200 - - common options for pdftoabw - - The attached patch fixes command line handling for pdftoabw and - implements some - common options (e.g., --help) that are already found in other - pdftosomething - utilities. - - utils/pdftoabw.cc | 39 ++++++++++++++++++++++++++++++++------- - 1 file changed, 32 insertions(+), 7 deletions(-) - -commit 365683d5faea6e0a7570b139d1f3366c22271f8e -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Aug 18 21:18:13 2009 +0200 - - 0.11.3 - - CMakeLists.txt | 2 +- - NEWS | 22 ++++++++++++++++++++++ - configure.ac | 2 +- - msvc/config.h | 6 +++--- - qt4/src/Doxyfile | 2 +- - 5 files changed, 28 insertions(+), 6 deletions(-) - -commit cb28bc8a637d300664b3c7569263445275333878 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Aug 17 14:14:03 2009 +0200 - - [glib] Add FORMAT_MAJOR/MINOR properties to get the PDF version - - See bug #23076. - - glib/poppler-document.cc | 26 ++++++++++++++++++++++++++ - 1 file changed, 26 insertions(+) - -commit 1b5612841b0c663f6d391d4581f65f68a2975db0 -Author: Pino Toscano <pino@kde.org> -Date: Mon Aug 17 01:04:04 2009 +0200 - - [Qt] add Document::getPdfVersion(int *major, int *minor) for the - document PDF version numbers - - This new function reads the version of the PDF specification of the - document, putting major and minor numbers in own variables. - - qt/poppler-document.cc | 8 ++++++++ - qt/poppler-qt.h | 12 ++++++++++++ - 2 files changed, 20 insertions(+) - -commit aef8ecda1e80b921228f415a53c9c5a52df87d94 -Author: Pino Toscano <pino@kde.org> -Date: Mon Aug 17 00:57:08 2009 +0200 - - [Qt4] deprecate Document::pdfVersion() - - ... in favour of getPdfVersion() - - qt4/src/poppler-qt4.h | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 830140f70e48e8033ad4411b6bd405d5ad7358a3 -Author: Pino Toscano <pino@kde.org> -Date: Mon Aug 17 00:51:13 2009 +0200 - - [Qt4] add Document::getPdfVersion(int *major, int *minor) for the - document PDF version numbers - - This new function reads the version of the PDF specification of the - document, putting major and minor numbers in own variables. - Add them to the relative unit test. - - qt4/src/poppler-document.cc | 8 ++++++++ - qt4/src/poppler-qt4.h | 13 +++++++++++++ - qt4/tests/check_metadata.cpp | 4 ++++ - 3 files changed, 25 insertions(+) - -commit 5491d16dfbd73f0256c62e49d02622dc3185012e -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Aug 17 00:24:41 2009 +0200 - - Move poppler core away from using a double as PDF file version - - Frontends are yet to come - - glib/poppler-document.cc | 2 +- - poppler/PDFDoc.cc | 7 ++++--- - poppler/PDFDoc.h | 8 +++++--- - qt/poppler-document.cc | 4 ++-- - qt4/src/poppler-document.cc | 4 ++-- - utils/pdfinfo.cc | 4 ++-- - 6 files changed, 16 insertions(+), 13 deletions(-) - -commit efd5dd63a5b08249529d9a9f5906aefe806fb3aa -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Aug 17 00:21:22 2009 +0200 - - Forgot to update copyright info - - fofi/FoFiType1C.cc | 14 ++++++++++++++ - poppler/PDFDoc.cc | 2 +- - utils/parseargs.c | 2 +- - 3 files changed, 16 insertions(+), 2 deletions(-) - -commit 25ff4be0b4521cc3d2de386cdeb589beb245d435 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Aug 17 00:15:10 2009 +0200 - - No need to change the locale since we use gatof that does the - right thing - - poppler/PDFDoc.cc | 6 +----- - 1 file changed, 1 insertion(+), 5 deletions(-) - -commit a6f698b4edc42c0414dd4690e1e037088321db2c -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Aug 17 00:14:35 2009 +0200 - - Use gatof instead of atof - - fofi/FoFiType1C.cc | 3 ++- - poppler/Annot.cc | 5 +++-- - poppler/Function.cc | 3 ++- - poppler/PDFDoc.cc | 3 ++- - utils/parseargs.c | 4 +++- - 5 files changed, 12 insertions(+), 6 deletions(-) - -commit 807b121cae45832d2e5832bad19c31e77420bfec -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Aug 17 00:10:30 2009 +0200 - - Add a custom strtod that comes from libspectre - - Works over C locale integers without changing locale settings - - CMakeLists.txt | 2 + - goo/Makefile.am | 6 ++- - goo/gstrtod.cc | 147 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - goo/gstrtod.h | 43 +++++++++++++++++ - 4 files changed, 196 insertions(+), 2 deletions(-) - -commit 914bf7677a14494b69857b1d8070092a9999fe79 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Aug 16 20:50:02 2009 +0200 - - When writing the cm matrix write 4 significant digits not 4 decimals - - This fixes bug 23332 - Maybe we want to make this the default behaviour of 'g' instead of - a new 'gs' case, but i prefer to be on the safe side for the moment - - goo/GooString.cc | 27 +++++++++++++++++++++++++-- - goo/GooString.h | 4 +++- - poppler/PSOutputDev.cc | 4 ++-- - 3 files changed, 30 insertions(+), 5 deletions(-) - -commit b7dfca1aa52b825eb3b8f1cc0470398c31615b30 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Aug 16 19:28:37 2009 +0200 - - [cairo] CairoImageOutputDev doesn't implement patterns - - poppler/CairoOutputDev.h | 13 +++++++++++++ - 1 file changed, 13 insertions(+) - -commit d20d65111aee2ee4b8cdea2962ed1bb149122ba9 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Aug 16 17:36:14 2009 +0200 - - [cairo] Implement tiling patterns in cairo backend - - Fixes bug #13518 for the cairo backend. - - poppler/CairoOutputDev.cc | 56 - +++++++++++++++++++++++++++++++++++++++++++++++ - poppler/CairoOutputDev.h | 10 +++++++++ - 2 files changed, 66 insertions(+) - -commit e965d0686d979c775b64a93f8e2f775f81885417 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Aug 13 14:48:10 2009 +0200 - - Change OutputDev::tilingPatternFill to return a GBool - - It allows outputdevs to decide whether render the pattern or not - depending - on the parameters, like shaded patterns currently do. - - poppler/Gfx.cc | 37 +++++++++++++++++++------------------ - poppler/OutputDev.h | 11 ++++++----- - poppler/PSOutputDev.cc | 12 +++++++----- - poppler/PSOutputDev.h | 10 +++++----- - 4 files changed, 37 insertions(+), 33 deletions(-) - -commit ce70ef7d6afc800e24031dae43da301e9e542f0e -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Aug 15 17:45:57 2009 +0200 - - Fix backwards search - - qt4/src/poppler-page.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 5b7b1cdc5c3b8652d3ae583b4d7b8b6de625adc2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Aug 15 17:45:05 2009 +0200 - - Add an autotest showing previousresult fails - - qt4/tests/check_search.cpp | 51 - ++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 51 insertions(+) - -commit 2484b0dcb8eb62f8e2c147498c58871ec04630b5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Aug 14 11:47:11 2009 +0200 - - Implement the alpha path - - I wonder if this is the correct fix why it was not implemented - but if fixes rendering of files in KDE bug 145868, KDE bug 193657, - poppler bug 17473.pdf, poppler bug 21651, poppler bug 22143 and - poppler bug 22152 and causes no regression in all the other files - i have in my test dir so i'm commiting it - - poppler/SplashOutputDev.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 03970d8b6d7624444664320470baa6d1b1299622 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Aug 11 12:01:07 2009 +0200 - - [build] Fix build with autotools - - utils/Makefile.am | 1 + - 1 file changed, 1 insertion(+) - -commit 15752b7cd5c94620e3ad3b6afd9c70ccc754c9b3 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Aug 10 20:02:13 2009 +0200 - - [cairo] Add empty updateBlendMode to CairoImageOutputDev - - Fixes a crash when using CairoImageOutputDev with a document with - blend - modes. - - poppler/CairoOutputDev.h | 1 + - 1 file changed, 1 insertion(+) - -commit 45dae4e66b2b833f95656850b5f1b0ffd1d96f1d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Aug 10 20:00:04 2009 +0200 - - [cairo] Use current fill_opacity when drawing images - - Fixes launchpad bug #342282 (page 2 of the attached document) - - poppler/CairoOutputDev.cc | 16 +++++++++++++--- - 1 file changed, 13 insertions(+), 3 deletions(-) - -commit b1cd54546844f2f7cd6bf7cc14b7584c84c3fc14 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Aug 10 19:55:44 2009 +0200 - - [cairo] Do not save the font file twice for FreeType fonts - - Fixes bug #20491. - - poppler/CairoFontEngine.cc | 19 ++----------------- - 1 file changed, 2 insertions(+), 17 deletions(-) - -commit 4181a0ff11195eb7a56d76be23994b843e20b483 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Aug 10 19:58:09 2009 +0200 - - this branch is unlikely to happen - - poppler/Lexer.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 2a3025f32951ce7b7343aeef111902615d71595e -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Aug 10 19:55:40 2009 +0200 - - fix overflow calculation not to depend on the variable overflowing - - poppler/Lexer.cc | 12 ++++++++---- - 1 file changed, 8 insertions(+), 4 deletions(-) - -commit a38001f724f78231c2fdadd28e647a35b41bab74 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Aug 9 23:26:02 2009 +0200 - - Check for overflow when parsing integers - - Fixes bug 23078 - - poppler/Lexer.cc | 28 ++++++++++++++++++++++------ - 1 file changed, 22 insertions(+), 6 deletions(-) - -commit 4c4c0e44452d07bea88d98b7df0c01fadd7693cc -Author: Jakub Wilk <ubanus@users.sf.net> -Date: Sat Aug 8 17:26:14 2009 +0200 - - Silence some warnings when using internal headers and not compiling - with -Wno-write-strings - - People should not be using internal headers but it's just two lines - - poppler/Object.h | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit e2c319ba18ab473fd969db9519a9231be67538c3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Aug 8 00:48:18 2009 +0200 - - Also implement mono so that -mono in pdftoppm -png works - - Totally not optimized - - splash/SplashBitmap.cc | 23 ++++++++++++++++++++++- - 1 file changed, 22 insertions(+), 1 deletion(-) - -commit c669e7f3ca421265e78161cc3fdecd2a0c7510c9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Aug 8 00:38:50 2009 +0200 - - Support splashModeMono8 in writePNGFile - - Works though is non optimal - - splash/SplashBitmap.cc | 55 - +++++++++++++++++++++++++++++++++++--------------- - 1 file changed, 39 insertions(+), 16 deletions(-) - -commit 92744b72df9084fd2d69ba78406898378884aed8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Aug 8 00:20:52 2009 +0200 - - Add the -png flag to pdftoppm to output to PNG - - Based on a patch by Shen Liang <shenzhuxi@gmail.com> - Also factored common PNG code from HtmlOutputDev to PNGWriter - - CMakeLists.txt | 5 +++ - goo/Makefile.am | 9 +++- - goo/PNGWriter.cc | 110 - ++++++++++++++++++++++++++++++++++++++++++++++ - goo/PNGWriter.h | 43 ++++++++++++++++++ - poppler/Makefile.am | 8 ++++ - splash/SplashBitmap.cc | 70 +++++++++++++++++++++++++++++ - splash/SplashBitmap.h | 5 +++ - splash/SplashErrorCodes.h | 4 +- - utils/CMakeLists.txt | 4 -- - utils/HtmlOutputDev.cc | 66 +++++----------------------- - utils/Makefile.am | 4 -- - utils/pdftoppm.1 | 3 ++ - utils/pdftoppm.cc | 21 +++++++-- - 13 files changed, 283 insertions(+), 69 deletions(-) - -commit e4439ff527bb202d0239f78e647452983b733411 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Aug 7 15:23:57 2009 +0200 - - [cairo] Don't apply masks when fill color space mode is csPattern - - In that case the mask is used for clipping when drawing images. Fixes - bug #22216. - - poppler/CairoOutputDev.cc | 59 - ++++++++++++++++++++++++++++++----------------- - 1 file changed, 38 insertions(+), 21 deletions(-) - -commit 7194f59a18e4f6997ae560af3db1bd101d6f726e -Author: Chris Wilson <chris@chris-wilson.co.uk> -Date: Thu Aug 6 11:24:22 2009 +0100 - - [cairo] Use FT_New_Memory_Face() for mmapped fonts - - If we hold a mapping for the font, then we can pass that memory to - FreeType for it to use as well. This saves on FreeType having to - read the - file into a fresh block of memory. - - poppler/CairoFontEngine.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 7e2bbcf6f85111d1006b0d5bc1503cadaba83c9f -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Aug 4 00:10:58 2009 +0200 - - Set KDAB via gamaral copyright - - poppler/Form.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit ed5918e16dafebc9ecf6db8ce0186f407ecbf7d5 -Author: Pino Toscano <pino@kde.org> -Date: Sat Aug 1 20:00:22 2009 +0200 - - [Qt4 apidox] make example for FontIterator... not leak ;) - - qt4/src/poppler-qt4.h | 2 ++ - 1 file changed, 2 insertions(+) - -commit f3b36d9c992491e614e88dbf1a84b5433a7647f4 -Author: Pino Toscano <pino@kde.org> -Date: Sat Aug 1 19:54:52 2009 +0200 - - [Qt4] Add color management API. - - Add few wrapper functions to get/set color profiles. - Add a function to know whether the color management functions actually - do anything (ie support compiled or not). - Add few basic API docs for the new functions. - Based on an initial patch by Hal V. Engel <hvengel@astound.net>, - heavily reindented, polished and massaged in its API by me. - - qt4/src/poppler-document.cc | 52 - +++++++++++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-qt4.h | 50 - +++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 102 insertions(+) - -commit 78a1969d040018c0c2bb74c94f5507f786e4666e -Author: Pino Toscano <pino@kde.org> -Date: Sat Aug 1 18:00:06 2009 +0200 - - [Qt] add unhandled cases and remove unused code - - qt/poppler-page.cc | 12 ++---------- - 1 file changed, 2 insertions(+), 10 deletions(-) - -commit bddebec0712e92e13b57d3d05d652673fe737866 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Aug 1 17:12:22 2009 +0200 - - 0.11.2 - - CMakeLists.txt | 2 +- - NEWS | 30 ++++++++++++++++++++++++++++++ - configure.ac | 2 +- - msvc/config.h | 6 +++--- - qt4/src/Doxyfile | 2 +- - 5 files changed, 36 insertions(+), 6 deletions(-) - -commit 87e2af3454348f5568d155c15af5d85268e47f1b -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Aug 1 15:48:02 2009 +0200 - - [glib-demo] Add cast to make sure the comparison is always valid - - glib/demo/attachments.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 464e95ef451103daddc9a30cd26b986291f02176 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Aug 1 15:47:25 2009 +0200 - - [glib-demo] Add missing return - - glib/demo/attachments.c | 2 ++ - 1 file changed, 2 insertions(+) - -commit 7f48369e4d29b2a71abffa9e1966e3a2252de895 -Author: Guillermo Antonio Amaral Bastidas <gamaral@amaral.com.mx> -Date: Sat Aug 1 15:41:34 2009 +0200 - - Call fillChildrenSiblingsID in fillChildrenSiblingsID instaed of - loadChildrenDefaults - - poppler/Form.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit e21a3e40bf6f4365064cea751ae186580d8f81f5 -Author: William Bader <williambader@hotmail.com> -Date: Sat Aug 1 15:23:03 2009 +0200 - - Add the possibility of disabling font substitution in pdftops - - Bug #23030 - - poppler/GlobalParams.cc | 17 ++++++++++++++ - poppler/GlobalParams.h | 4 ++++ - poppler/PSOutputDev.cc | 59 - +++++++++++++++++++++++++++---------------------- - poppler/PSOutputDev.h | 2 ++ - utils/pdftops.1 | 8 ++++++- - utils/pdftops.cc | 7 ++++++ - 6 files changed, 70 insertions(+), 27 deletions(-) - -commit bd68c90338cbf16f468e5db59722610300a629e1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Aug 1 15:19:48 2009 +0200 - - Forgot to add my copyright - - poppler/GfxState.h | 1 + - 1 file changed, 1 insertion(+) - -commit 173451730948c320f16a0f5924a58302603eca0b -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Aug 1 15:13:35 2009 +0200 - - Try to workaround some incorrect PDF - - Fixes rendering of PDF where forms/patterns have more q than Q. Fixes - rendering in splash of pdf in bugs #22835, #21899 and #16402 - - poppler/Gfx.cc | 13 +++++++++++++ - poppler/GfxState.h | 1 + - 2 files changed, 14 insertions(+) - -commit 35c408ca49be08144bcf14aa112505fd556725d2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 31 23:27:02 2009 +0200 - - add the overloaded virtual warning also the autotools based build - - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 1c32bd2d101e5dfb37e28276ecad699f121b27b7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 31 23:22:25 2009 +0200 - - Add my copyright to files i just edited - - poppler/OutputDev.cc | 1 + - poppler/OutputDev.h | 1 + - utils/HtmlOutputDev.h | 2 +- - 3 files changed, 3 insertions(+), 1 deletion(-) - -commit 10717a48c85f1dbeff1c6bcd094006a9ecc92efc -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 31 23:22:10 2009 +0200 - - Add -Woverloaded-virtual as default CXX flag - - cmake/modules/PopplerMacros.cmake | 1 + - 1 file changed, 1 insertion(+) - -commit db5f736655f01575ac5d7c524cbf131924ae91fa -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 31 23:12:00 2009 +0200 - - rename the function - - That way the name is different from the OutputDev function and does - not seem like a wrong overload - - utils/HtmlOutputDev.cc | 4 ++-- - utils/HtmlOutputDev.h | 2 +- - 2 files changed, 3 insertions(+), 3 deletions(-) - -commit 4be87f87509b93c4fe4025f9bd788e9412416663 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 31 23:11:32 2009 +0200 - - Remove Outputdev::beginMarkedContent as noone uses it - - poppler/Gfx.cc | 2 -- - poppler/OutputDev.cc | 3 --- - poppler/OutputDev.h | 1 - - 3 files changed, 6 deletions(-) - -commit 6ab2ec8a89519d2bd1576c8d62f8aec51b04479a -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 31 23:10:56 2009 +0200 - - Warning-- - - poppler/PSOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 53c3d636ad645a350b576160e1498726238a7bd1 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Jul 31 18:23:57 2009 +0200 - - [cairo] Implement radialShadedFill in cairo backend using cairo - gradients - - Fixes bugs #10942, #14160 - - poppler/CairoOutputDev.cc | 28 +++++++++ - poppler/CairoOutputDev.h | 2 + - poppler/Gfx.cc | 141 - +++++++++++++++++++++++++++------------------- - poppler/OutputDev.h | 2 +- - poppler/PSOutputDev.cc | 3 +- - poppler/PSOutputDev.h | 2 +- - 6 files changed, 117 insertions(+), 61 deletions(-) - -commit 2ba937545d1a2b9fa798f04fee755ccdf0e74ec7 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Jul 31 17:49:18 2009 +0200 - - [cairo] Use cairo_pattern_set_extend for linear gradients - - poppler/CairoOutputDev.cc | 9 +++++++++ - poppler/CairoOutputDev.h | 1 + - poppler/Gfx.cc | 34 ++++++++++++++++++++++++++++------ - poppler/OutputDev.h | 4 ++++ - 4 files changed, 42 insertions(+), 6 deletions(-) - -commit b054756113f0df6b59935823882f412486e96db5 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jun 17 11:10:15 2009 +0200 - - [cairo] Implement blend mdoes in cairo backend - - It requires cairo from git master to work at the moment. Fixes bugs - #22384, #12979, #13603, #17919, #22255 - - configure.ac | 27 ++++++++++++++++++++++ - poppler/CairoOutputDev.cc | 59 - +++++++++++++++++++++++++++++++++++++++++++++++ - poppler/CairoOutputDev.h | 1 + - 3 files changed, 87 insertions(+) - -commit bf8964726c9311e7e82b1faf49cc2272e5c1e339 -Author: William Bader <williambader@hotmail.com> -Date: Thu Jul 30 22:08:43 2009 +0200 - - Fix some double to int warnings by explicit casting - - poppler/Gfx.cc | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -commit fdbd0c548e963461b2bc4bdf1beaa1577cafcea7 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 30 21:05:18 2009 +0200 - - Update gtk-doc build files - - gtk-doc.make | 102 - +++++++++++++++++++++++++++++++++++++++------------------- - m4/gtk-doc.m4 | 74 +++++++++++++++++++++++------------------- - 2 files changed, 110 insertions(+), 66 deletions(-) - -commit ae84dce5cea4d249526a6ed5b2feb2d3f241da1b -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 30 20:45:39 2009 +0200 - - Revert "Remove unneeded files from repo" - - This reverts commit 4cc9dee35e03d7b295a476f937ec0f2c43bb6592. - - See bug #22697. - - configure.ac | 2 +- - glib/reference/Makefile.am | 4 +- - gtk-doc.make | 155 - +++++++++++++++++++++++++++++++++++++++++++++ - m4/gtk-doc.m4 | 53 ++++++++++++++++ - 4 files changed, 211 insertions(+), 3 deletions(-) - -commit 7e14516a78b16453c747eb92b08665632e5f6844 -Author: Sanjoy Mahajan <sanjoy@mit.edu> -Date: Mon Jul 27 23:20:50 2009 +0200 - - Fix displayPages call - - Parameters are outputdev, first, last, dpi, dpi, rotate, usemediabox, - crop, printing - and we were doing - usemediabox = !noCrop - crop = gFasle - the correct is - usemediabox = noCrop - crop = !noCrop - - utils/pdftops.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 3d53a0eb14420d54c0ebf8590e34c018b8da105d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Jul 19 16:02:33 2009 +0200 - - Copy byte_lookup in copy constructor - - poppler/GfxState.cc | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit 8f7271acf17c46e663cd48d90c382b04a834fba2 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Jul 19 15:53:49 2009 +0200 - - Don't use byte_lookup table when color space doesn't support getLine - methods - - For color spaces that don't implement getRGBLine or getGrayLine - methods, - getRGB or getGray are called for every pixel, however we were - allocating - the byte_lookup table and converting colors in those cases - too. Instead - of falling back to generic methods in the base class, the new methods - useGetRGBLine and useGetGrayLine have been added to he base class, - so that - when they are not suopported in the current color space byte_lookup - table is - not used at all. - - Fixes bug #11027. - - poppler/GfxState.cc | 125 - ++++++++++++++++++++++++++++++---------------------- - poppler/GfxState.h | 21 +++++++-- - 2 files changed, 91 insertions(+), 55 deletions(-) - -commit 1bc737796bef1c65289a101b2d4c367267b9c974 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Jul 19 15:51:43 2009 +0200 - - Remove unused variable - - poppler/GfxState.h | 1 - - 1 file changed, 1 deletion(-) - -commit 512b2c654fd80c83b82e7adc828a478a18de17ab -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Jul 26 19:35:06 2009 +0200 - - [cairo] Use CAIRO_EXTEND_PAD in drawImageMaskPrescaled too - - poppler/CairoOutputDev.cc | 32 +++++++++++++++----------------- - 1 file changed, 15 insertions(+), 17 deletions(-) - -commit ad26e34bede53cb6300bc463cbdcc2b5adf101c2 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Jul 26 18:36:06 2009 +0200 - - [cairo] Use rectangle + clip instead of invert + tranform - - This is just for consistency of drawImage methods - - poppler/CairoOutputDev.cc | 30 ++++++++++++++---------------- - 1 file changed, 14 insertions(+), 16 deletions(-) - -commit ee6b761a55baef4c3bbe4614b0c3b3d761a3111f -Author: Chris Wilson <chris@chris-wilson.co.uk> -Date: Sun Jul 26 16:19:15 2009 +0200 - - [cairo] Apply a clip for masked drawImage - - In order to use EXTEND_PAD with a mask, we need to apply a clip (to - constrain the image to the appropriate region). The complicating - factor for - drawSoftImage() is that mask size is independent of the image size, - so we - need to compute the intersection of the mask with in the image - in userspace. - - poppler/CairoOutputDev.cc | 21 ++++++++++++++------- - 1 file changed, 14 insertions(+), 7 deletions(-) - -commit 499c6c972bac14936b5370276da723a6e98861b3 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Jul 26 11:30:08 2009 +0200 - - [cairo] Use CAIRO_EXTEND_PAD when drawing images - - poppler/CairoOutputDev.cc | 306 - +++++++++++++++++++++------------------------- - 1 file changed, 140 insertions(+), 166 deletions(-) - -commit f91eb7d01cef0897727c63267db309bc92297d37 -Author: Koji Otani <sho@bbr.jp> -Date: Sat Jul 25 16:34:12 2009 +0200 - - Fix generation of ps for some files - - For example fixes second pdf in bug 18908 - - poppler/PSOutputDev.cc | 68 - +++++++++++++++++++++++++++++++++++++------------- - 1 file changed, 51 insertions(+), 17 deletions(-) - -commit f93f5e17d8f23f3e2862f3411f43a95b334e6c91 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Jul 20 17:10:37 2009 +0200 - - [cairo] Improve performance when rendering one-channel images - - It implements the same idea already used in SplashOutputDev, for - one-channel (monochrome/gray/separation) images we build a lookup - table - so that we won't need to call colorMap->getRGBLine when filling the - image buffer. Fixes bug #18017. - - poppler/CairoOutputDev.cc | 36 ++++++++++++++++++++++++++++++++++-- - 1 file changed, 34 insertions(+), 2 deletions(-) - -commit e7475062b6ae5c495fa72faaf8fb3d97391f8544 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jul 14 17:22:52 2009 +0200 - - [cairo] Handle fontType1COT fonts in CairoFontEngine - - poppler/CairoFontEngine.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit d42b9425fb2f98fa79e7a60e4f71ef14f5bacfe9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jul 12 19:55:14 2009 +0200 - - glade is not used anymore - - cmake/modules/FindGTK.cmake | 9 ++++----- - 1 file changed, 4 insertions(+), 5 deletions(-) - -commit 454f7468c6a6a442a5064b5daa24d65ebf4fc6b6 -Author: Chris Wilson <chris@chris-wilson.co.uk> -Date: Thu Jul 9 10:43:00 2009 +0100 - - [cairo] Fix drawImage() for non-1x1 images - - Carlos noticed a nasty bug with converting drawImage() to use PAD - + fill, - instead of NONE + paint. That is the image was being padded out - far beyond - the correct output extents. The cause is that the caller pre-scales - the - context for the image, so the output rectangle was many times the true - image size - obliterating large amounts of the page. The temporary - fix is - to counter-act the scaling on the context. Longer term, after - fixing all - painters to use PAD correctly, we need to review the callers to remove - unnecessary pre-scaling. - - poppler/CairoOutputDev.cc | 16 ++++++++++++---- - 1 file changed, 12 insertions(+), 4 deletions(-) - -commit f8d93eae3c7b9388feabac71f2380d0b42a855e7 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jul 8 20:14:35 2009 +0200 - - Lookup UF and F entries before Unix, MAC and DOS in getFileSpec - - poppler/FileSpec.cc | 24 ++++++++++++------------ - 1 file changed, 12 insertions(+), 12 deletions(-) - -commit 767c534f5fdf6ccbccfd85a0086d72c215c278f1 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jul 8 19:13:54 2009 +0200 - - Use UF entry when present in dict in getFileSpecName() too - - poppler/FileSpec.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 569627ac4d56ddd58e109ce2a37179a85e042030 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jul 8 13:02:16 2009 +0200 - - Implement axialShadedFill in cairo backend using cairo gradients - - See bug #10942. - - poppler/CairoOutputDev.cc | 29 +++++++++++++++++++++++++++++ - poppler/CairoOutputDev.h | 10 ++++++++++ - poppler/Gfx.cc | 29 ++++++++++++++++++++--------- - poppler/OutputDev.h | 6 +++++- - poppler/PSOutputDev.cc | 2 +- - poppler/PSOutputDev.h | 2 +- - 6 files changed, 66 insertions(+), 12 deletions(-) - -commit 6ae0a6c0044713affa23eb1ee6a070785ed6c2f3 -Author: Chris Wilson <chris@chris-wilson.co.uk> -Date: Wed Jul 8 16:48:26 2009 +0100 - - [cairo] premultiply image mask - - Cairo uses a premultiplied colour-space, so when creating the - image mask - in drawImage() we need to remember to multiply by the alpha. In - this case - it just requires zeroing out the masked pixels. - - poppler/CairoOutputDev.cc | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -commit 646e5884e748ecce7094c673400484aa1d902bdd -Author: Chris Wilson <chris@chris-wilson.co.uk> -Date: Wed Jul 8 17:00:34 2009 +0100 - - [cairo] maskColors is an array of ints, no scaling required - - drawImage() was erroneously scaling the maskColors from what it - believed - to be [0:1] to [0:255]. However maskColors is already an integer - array, - [0:255]. - - poppler/CairoOutputDev.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit d75feb1ee84385a9f94308cf47a43f4583092ddf -Author: Chris Wilson <chris@chris-wilson.co.uk> -Date: Wed Jul 8 16:37:19 2009 +0100 - - [cairo] cleanse DrawImage() - - Just a small bit of code rearrangement to reduce repetition and - invalid checks. - - poppler/CairoOutputDev.cc | 102 - +++++++++++++++++++--------------------------- - 1 file changed, 41 insertions(+), 61 deletions(-) - -commit 52f3704fed16cfc1e9dd85f72dde7922371e4099 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jul 8 11:40:52 2009 +0200 - - [TODO] Update TODO file - - TODO | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit ef261f5f72d37a0aa2709611ee2bad7d55340ed8 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jul 7 10:57:31 2009 +0200 - - Do not use F and UF entries if Unix or DOS are present in FileSpec - dict - - poppler/FileSpec.cc | 114 - +++++++++++++++++++++++----------------------------- - 1 file changed, 51 insertions(+), 63 deletions(-) - -commit cafd4653dc6c7574214e80aa09489dcd24e347a6 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jul 1 11:41:32 2009 +0200 - - [glib-demo] Fix a typo - - glib/demo/utils.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit a3c9c6d0c0ee55dccd2d03f20d5683ae300cdc6b -Author: Pino Toscano <pino@kde.org> -Date: Wed Jul 8 02:01:39 2009 +0200 - - start updating the TODO file - - TODO file had quite some rust and dust in it, making quite "difficult" - for others to understand what can be done for helping. - First step has been removing all the items done. - Next is grouping items by areas, so it is more clear what should be - done in what area; current areas are: - - general items: for general stuff to be done, not specific to some - area; an example could have been "use littlecms for color management?" - - core: stuff which is specific to the core library - - Qt4/Qt/glib/etc frontend: stuff specific for that frontend - - new frontends: ideas for possible new frontends - - I was not sure about some items and Jeff Muizelaar's TODO, so I left - them there. - - TODO | 47 +++++++++++++++-------------------------------- - 1 file changed, 15 insertions(+), 32 deletions(-) - -commit 92ad0ef89fe7690d83854b4821178dfdb2e22897 -Author: Pino Toscano <pino@kde.org> -Date: Sat Jul 4 00:19:23 2009 +0200 - - [Qt4 demo] hopefully fix the page size on zoom change - - qt4/demos/pageview.cpp | 5 +---- - 1 file changed, 1 insertion(+), 4 deletions(-) - -commit 97094d13bc0f144b25e13c1de7a5328608ab13e3 -Author: Pino Toscano <pino@kde.org> -Date: Sat Jul 4 00:07:12 2009 +0200 - - [Qt4 demo] show a list of checked/unchecked items for the document - permissions - - qt4/demos/permissions.cpp | 25 ++++++++----------------- - qt4/demos/permissions.h | 6 +++--- - 2 files changed, 11 insertions(+), 20 deletions(-) - -commit 0d8f2ee0f03a14e7b8477c4b787c3441a758f26b -Author: Pino Toscano <pino@kde.org> -Date: Fri Jul 3 23:55:42 2009 +0200 - - [Qt4 demo] show page numbers in the toolbar as 1..n - - qt4/demos/navigationtoolbar.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit b0d48df9121c55f8162ddf0ee63832f9adebf37b -Author: Pino Toscano <pino@kde.org> -Date: Fri Jul 3 17:55:31 2009 +0200 - - [Qt4 demo] correctly use DPI values for the page sizes - - qt4/demos/pageview.cpp | 12 +++++++++--- - qt4/demos/pageview.h | 2 ++ - 2 files changed, 11 insertions(+), 3 deletions(-) - -commit dcc3c384919f1562b8f312ad3ac847e23f3e83ab -Author: Sebastien Bacher <seb128@ubuntu.com> -Date: Wed Jul 1 10:09:12 2009 +0200 - - [test] Use gtkbuilder rather than libglade - - Fixes bug #21673 - - cmake/modules/FindGTK.cmake | 1 - - configure.ac | 4 +- - test/Makefile.am | 2 +- - test/pdf-inspector.cc | 34 ++-- - test/pdf-inspector.glade | 434 - -------------------------------------------- - test/pdf-inspector.ui | 416 - ++++++++++++++++++++++++++++++++++++++++++ - 6 files changed, 439 insertions(+), 452 deletions(-) - -commit 28208d1c9b8afbb769a5f4d9b0655b99fd4af16e -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jul 1 09:52:12 2009 +0200 - - [glib-demo] Do not use gio if glib < 2.15 - - Fixes bug #22530. - - glib/demo/main.c | 33 +++++++++++++++++++++++++++++++-- - 1 file changed, 31 insertions(+), 2 deletions(-) - -commit 6ef83414ab55294cf46b6b05813927bb04066986 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 30 23:07:00 2009 +0200 - - Check getFileSpecNameForPlatform succeeded before using it's return - value - - Fixes crash on bug 22551 - - poppler/Annot.cc | 7 ++++--- - poppler/Link.cc | 30 +++++++++++++++++------------- - poppler/Sound.cc | 8 +++++--- - 3 files changed, 26 insertions(+), 19 deletions(-) - -commit 4b9db83841a8b97df1e0991c1b853897b7095777 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jun 30 11:24:29 2009 +0200 - - [glib-demo] Do not fill the surface before rendering - - The surface is guaranteed to be cleared - - glib/demo/render.c | 11 ++--------- - 1 file changed, 2 insertions(+), 9 deletions(-) - -commit 5deb6db5d340c08f337d2ba67aa1fd690e4eedd8 -Author: William Bader <williambader@hotmail.com> -Date: Mon Jun 29 21:55:49 2009 +0200 - - Fix interpolate parameter position - - poppler/SplashOutputDev.cc | 3 ++- - utils/ImageOutputDev.cc | 5 +++-- - 2 files changed, 5 insertions(+), 3 deletions(-) - -commit e1e9ae2826eff1665d798b4b50b5c63e8282246b -Author: Pino Toscano <pino@kde.org> -Date: Sun Jun 28 20:11:42 2009 +0200 - - [Qt4 demo] do not crash when changing the zoom with no document - - qt4/demos/pageview.cpp | 3 +++ - 1 file changed, 3 insertions(+) - -commit a98de97137cb343182bd03c443fc08ff4e0fd9a5 -Author: Pino Toscano <pino@kde.org> -Date: Sun Jun 28 19:08:02 2009 +0200 - - [Qt4 demo] add a zoom combobox - - qt4/demos/navigationtoolbar.cpp | 33 ++++++++++++++++++++++++++++++++- - qt4/demos/navigationtoolbar.h | 7 ++++++- - qt4/demos/pageview.cpp | 14 ++++++++++++-- - qt4/demos/pageview.h | 6 +++++- - qt4/demos/viewer.cpp | 2 ++ - 5 files changed, 57 insertions(+), 5 deletions(-) - -commit 40002d2c765398869a3b7d8d92715f0608e39ab3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jun 28 16:45:19 2009 +0200 - - Make sure the array is big enough to read from it - - poppler/Gfx.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 0a1b41ff6de5a41e3450ecbcb1ba754dc06c29d9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jun 26 19:31:22 2009 +0200 - - Do not crash when we can't find onStr - - Fixes crash in bug #22485 - Not sure this is the best solution, but Adobe doesn't even open - the file - - poppler/Form.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 6cb846664e57b02c99f1e6ad2b4e9128c9622e0a -Author: Ilya Gorenbein <igorenbein@finjan.com> -Date: Thu Jun 25 20:13:29 2009 +0200 - - Initilize AnnotColot properly when the Array is not correct - - poppler/Annot.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 5fdc3acb8dded2e7d08e6ef30f4c5ae1a4a11b5e -Author: Till Kamppeter <till.kamppeter@gmail.com> -Date: Mon Jun 22 21:38:23 2009 +0200 - - Only change the page size when it really changes, otherwise duplex - commands are lost - - poppler/PSOutputDev.cc | 10 +++++++++- - poppler/PSOutputDev.h | 4 ++++ - 2 files changed, 13 insertions(+), 1 deletion(-) - -commit bf69beeb257cfd750c6ddc8b68aeb859b36380b2 -Author: David Benjamin <davidben@mit.edu> -Date: Sat Jun 20 23:51:09 2009 +0200 - - Make DecryptStream return sane values for getPos() - - Many streams (notably JBIG2Stream) expect wrapped streams to return - correct - values for getPos(), i.e. increments by 1 when readChar() called, etc. - Fixes bug #19706. - - poppler/Decrypt.cc | 8 ++++++++ - poppler/Decrypt.h | 3 +++ - 2 files changed, 11 insertions(+) - -commit 5ee4ff2aaf98e2eaa1ec2dc9f7e659b3b01ba7bf -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Jun 20 15:00:16 2009 +0200 - - [glib-demo] Allow using relative paths in demo application - - glib/demo/main.c | 17 +++++------------ - 1 file changed, 5 insertions(+), 12 deletions(-) - -commit a568248d3255407fcaa7368c4925c20e95619d20 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jun 19 21:07:39 2009 +0200 - - 0.11.1 - - CMakeLists.txt | 2 +- - NEWS | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- - configure.ac | 2 +- - msvc/config.h | 6 +++--- - qt4/src/Doxyfile | 2 +- - 5 files changed, 54 insertions(+), 8 deletions(-) - -commit ac99e239f2726db32617ff03174a6ce74361ea1b -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jun 19 21:03:29 2009 +0200 - - ship PopplerCache.h - - CMakeLists.txt | 1 + - 1 file changed, 1 insertion(+) - -commit 84984d2aa25917d68c9971cefe636e626eada13d -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jun 19 20:54:15 2009 +0200 - - Ship PopplerCache.h too - - poppler/Makefile.am | 1 + - 1 file changed, 1 insertion(+) - -commit 3a52d46e5df8eb926b550d7f7a82f316dbf6808f -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Jun 19 17:45:44 2009 +0200 - - [glib-demo] Destroy pattern after using it - - glib/demo/render.c | 1 + - 1 file changed, 1 insertion(+) - -commit 2e97524e5d82a4c33a4e6410fead444681db6749 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Jun 19 14:20:16 2009 +0200 - - [glib-demo] Use a transparent surface and fill it in white after - rendering - - glib/demo/render.c | 12 +++++++++--- - 1 file changed, 9 insertions(+), 3 deletions(-) - -commit 009937842d5a8bfc12394e9e3ab71b7c33340a85 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Jun 19 14:10:05 2009 +0200 - - [glib-demo] Use cairo_paint instead of rectangle + fill - - glib/demo/render.c | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit 7248da095f67d57c3999cee7d980e62fd8a7cf49 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Jun 19 09:37:02 2009 +0200 - - Use Interpolate flag to decide whether applying image interpolation - during rendering - - Fixes bug #9860 - - poppler/ArthurOutputDev.cc | 4 +- - poppler/ArthurOutputDev.h | 5 ++- - poppler/CairoOutputDev.cc | 92 - ++++++++++++++++++++++++++------------------- - poppler/CairoOutputDev.h | 48 ++++++++++++----------- - poppler/Gfx.cc | 49 ++++++++++++++++++++---- - poppler/OutputDev.cc | 17 ++++++--- - poppler/OutputDev.h | 13 ++++--- - poppler/PSOutputDev.cc | 8 ++-- - poppler/PSOutputDev.h | 8 ++-- - poppler/PreScanOutputDev.cc | 25 ++++++++++-- - poppler/PreScanOutputDev.h | 25 ++++++++++-- - poppler/SplashOutputDev.cc | 16 +++++--- - poppler/SplashOutputDev.h | 12 ++++-- - utils/HtmlOutputDev.cc | 16 ++++---- - utils/HtmlOutputDev.h | 7 ++-- - utils/ImageOutputDev.cc | 20 +++++----- - utils/ImageOutputDev.h | 12 ++++-- - 17 files changed, 248 insertions(+), 129 deletions(-) - -commit 37e3f877ee725648734ff41e1e83870a210bcbd7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jun 19 00:37:21 2009 +0200 - - Handle Streams in CMap definitions - - Fixes bug 22334 - - poppler/CMap.cc | 50 - ++++++++++++++++++++++++++++++------------------- - poppler/CMap.h | 17 ++++++++++++----- - poppler/GfxFont.cc | 41 +++++++++++++++++++++++++++------------- - poppler/GlobalParams.cc | 6 +++--- - poppler/GlobalParams.h | 5 +++-- - 5 files changed, 77 insertions(+), 42 deletions(-) - -commit 47de8eef46300832556ce5ed869e391e477fd843 -Author: David Benjamin <davidben@mit.edu> -Date: Fri Jun 19 00:30:35 2009 +0200 - - Fix some bugs in JBIG2Stream handling - - For more info see bug 12014 and [poppler] Bug in JBIG2Stream from - 08-June-2009 - - poppler/JBIG2Stream.cc | 88 - +++++++++++++++++++++++++++----------------------- - poppler/JBIG2Stream.h | 15 +++++++++ - 2 files changed, 63 insertions(+), 40 deletions(-) - -commit d30b1013ea3ce45b5ea942fe7357c0fd07ff47f4 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jun 2 11:44:08 2009 +0200 - - Add setOpen() and setIcon() in AnnotText - - poppler/Annot.cc | 25 +++++++++++++++++++++++++ - poppler/Annot.h | 3 +++ - 2 files changed, 28 insertions(+) - -commit 287feffc1c1c0aa42a398fc071b489acef9ef22e -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jun 2 11:26:40 2009 +0200 - - Add setLabel() and setPopup() to AnnotMarkup - - poppler/Annot.cc | 36 ++++++++++++++++++++++++++++++++++++ - poppler/Annot.h | 4 ++++ - 2 files changed, 40 insertions(+) - -commit 2a938af5624fbc79316dd6bee5e550f2b4270a76 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jun 2 10:59:44 2009 +0200 - - Add setParent() and setOpen() to AnnotPopup - - poppler/Annot.cc | 19 +++++++++++++++++++ - poppler/Annot.h | 4 ++++ - 2 files changed, 23 insertions(+) - -commit 0af5464352dfa51f0458c57a3590c847a45964c7 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jun 2 10:37:49 2009 +0200 - - Save parent reference of popup annotations - - poppler/Annot.cc | 16 +++++----------- - poppler/Annot.h | 4 ++-- - 2 files changed, 7 insertions(+), 13 deletions(-) - -commit fc4bc43dcd6f6871a47b9198e8c2571a5d448c3e -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Jun 1 14:52:21 2009 +0200 - - Fix a crash in pdf-inspector - - test/pdf-inspector.cc | 11 +++++++++++ - 1 file changed, 11 insertions(+) - -commit 3da7a2657892fde52b62e1f73476cb33d6c75e96 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri May 29 13:35:39 2009 +0200 - - Add Annot::setColor() - - poppler/Annot.cc | 19 ++++++++++++++++++- - poppler/Annot.h | 6 +++++- - 2 files changed, 23 insertions(+), 2 deletions(-) - -commit 3eabdf57729852205855cf74ff2d2f9d7bc03f73 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri May 29 13:23:26 2009 +0200 - - Add construtors to create AnnotColor objects directly from color - values - - poppler/Annot.cc | 26 ++++++++++++++++++++++++++ - poppler/Annot.h | 3 +++ - 2 files changed, 29 insertions(+) - -commit 8045e7a1a84a3d54a1c9415ac63b5b9df5ecc349 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri May 29 13:06:40 2009 +0200 - - Add Page::addAnnot() to add a new annotation to the page - - poppler/Page.cc | 28 ++++++++++++++++++++++++++++ - poppler/Page.h | 2 ++ - 2 files changed, 30 insertions(+) - -commit fe80eb84ec711b7400cef95e791a74c8fd259af7 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri May 29 13:00:19 2009 +0200 - - Add getRef() to get the annotation reference - - poppler/Annot.h | 1 + - 1 file changed, 1 insertion(+) - -commit 1c92657be72c44dba7185808ffb00dd85c5ab289 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri May 29 12:14:02 2009 +0200 - - Save page object and ref in Page class - - This is needed to be able to modify the page object. - - poppler/Catalog.cc | 2 +- - poppler/Page.cc | 6 +++++- - poppler/Page.h | 4 +++- - 3 files changed, 9 insertions(+), 3 deletions(-) - -commit 4ad2d663262008e4b97342c4ed67c686ff5abd13 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri May 29 11:43:30 2009 +0200 - - Add annot constructors to create annot objects without a dict - - This allows to create annotation objects to be added to the document. - Required fields on the annotation dictionary are constructor - arguments, - setters will be added for the other fields. - - poppler/Annot.cc | 300 - +++++++++++++++++++++++++++++++++++++++++++++++++++++-- - poppler/Annot.h | 22 +++- - 2 files changed, 315 insertions(+), 7 deletions(-) - -commit e5c4862b0c1b08a0fab47070cb9c862026e93567 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jun 10 23:28:03 2009 +0200 - - ignore++ - - m4/.gitignore | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 572779f8037763c1e0ee64c47a3dad6df0d3b693 -Author: Koji Otani <sho@bbr.jp> -Date: Wed Jun 10 22:55:26 2009 +0200 - - Fix dashed line in page 1 of bug 20011 - - poppler/Gfx.cc | 6 ++---- - 1 file changed, 2 insertions(+), 4 deletions(-) - -commit b97591672e0d9c31a3d044fe52e34cc80a491221 -Author: Koji Otani <sho@bbr.jp> -Date: Wed Jun 10 22:54:57 2009 +0200 - - Fix "Conditional jump or move depends on uninitialised value" - - When stroking with a pattern, set strokeColor with a copy of - fillColor. - This is wrong and the fillColor may be uninitialized. - See bug 20011 - - poppler/Gfx.cc | 13 +++++++++++-- - 1 file changed, 11 insertions(+), 2 deletions(-) - -commit a92b38836b1e4475d5a7a1b9cb8f3e9429cef275 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 9 22:39:19 2009 +0200 - - Correctly duplicate the cache on PostScriptFunction(PostScriptFunction - *func) - - poppler/Function.cc | 28 ++++++++++++++++++++++++++++ - poppler/PopplerCache.cc | 20 ++++++++++++++++++++ - poppler/PopplerCache.h | 14 ++++++++++++++ - 3 files changed, 62 insertions(+) - -commit 2cecdf922f4c8178b0e55d3ddf86c31f8be3313a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jun 9 11:04:39 2009 +0200 - - [glib] Fix a crash when a destination points to an invalid page - - glib/poppler-action.cc | 21 +++++++++++++-------- - 1 file changed, 13 insertions(+), 8 deletions(-) - -commit 831288c13c3a7502bbccd1313c6e376283be367c -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jun 7 18:37:20 2009 +0200 - - Optimize roll() a bit - - If the number of times to roll is > than half the number of items - rotate in the reverse direction - Makes it be 33% of exec() instead of 42% - - poppler/Function.cc | 19 ++++++++++++++----- - 1 file changed, 14 insertions(+), 5 deletions(-) - -commit 3d40dcad850a2bc0e28845a15722db0c79920135 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jun 7 13:38:50 2009 +0200 - - Move the GfxState cache to the new poppler cache class - - poppler/GfxState.cc | 97 - +++++++++++++++++++++++++---------------------------- - poppler/GfxState.h | 19 ++--------- - 2 files changed, 49 insertions(+), 67 deletions(-) - -commit 2619e09833f421fb3d8cc68d41d15081ae6824e4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jun 7 13:37:40 2009 +0200 - - Implement a cache for PostscriptFunction transforms - - Makes time of rendering of bug 21562 go down from 24 to 8 seconds - - poppler/Function.cc | 76 - +++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Function.h | 2 ++ - 2 files changed, 78 insertions(+) - -commit 588bfe3c14f42be492066c2a98e30482475a6926 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jun 7 13:36:39 2009 +0200 - - Add a code to a generic cache based on Koji's code for GfxState cache - - CMakeLists.txt | 1 + - poppler/Makefile.am | 1 + - poppler/PopplerCache.cc | 82 - +++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/PopplerCache.h | 47 ++++++++++++++++++++++++++++ - 4 files changed, 131 insertions(+) - -commit d09478fcc44b5c594f1803fc24654af5e10fa129 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jun 7 01:34:01 2009 +0200 - - Move index and pop to class definition too - - poppler/Function.cc | 32 +++++++++++++++----------------- - 1 file changed, 15 insertions(+), 17 deletions(-) - -commit 2083264e8ab0fd9976294de08a18de615d5a1168 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jun 7 01:21:19 2009 +0200 - - Move the implementations to the class definition - - Make gcc inline the functions and time to render a heavy PSFunction - doc goes from 28 to 20 secs - - poppler/Function.cc | 151 - ++++++++++++++++++++++++---------------------------- - 1 file changed, 71 insertions(+), 80 deletions(-) - -commit 24580fcd2be74db5f3140bdb2ebff8431b7d3f1e -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Jun 6 16:17:26 2009 +0200 - - Add a debug saying how much rendering took - - qt4/tests/test-poppler-qt4.cpp | 2 ++ - 1 file changed, 2 insertions(+) - -commit 50cf7cffff760e41774957ad8f1f92803142438e -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Jun 6 16:04:54 2009 +0200 - - Use g_path_get_basename instead of g_basename in gtk-cairo-test - - Fixes bug #21361. - - test/gtk-cairo-test.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit 4cc9dee35e03d7b295a476f937ec0f2c43bb6592 -Author: Christian Persch <chpe@gnome.org> -Date: Sat Jun 6 12:13:48 2009 +0200 - - Remove unneeded files from repo - - See bug #22094 - - configure.ac | 2 +- - glib/reference/Makefile.am | 4 +- - gtk-doc.make | 155 - --------------------------------------------- - m4/gtk-doc.m4 | 53 ---------------- - 4 files changed, 3 insertions(+), 211 deletions(-) - -commit c94e476dbff9e527c72e52377d830f35f29ba3d6 -Author: Pino Toscano <pino@kde.org> -Date: Fri Jun 5 11:09:44 2009 +0200 - - when showing the tooltip for a text rect, show also its index in - the page text boxes list - - qt4/tests/test-poppler-qt4.cpp | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -commit 2298acac267257b1916c802bdb902428e69e683b -Author: Pino Toscano <pino@kde.org> -Date: Fri Jun 5 11:08:51 2009 +0200 - - [Qt4 apidox] FontInterator is new in 0.12 - - qt4/src/poppler-qt4.h | 2 ++ - 1 file changed, 2 insertions(+) - -commit 37c48c2521c623c485841472c4a174a1841aea33 -Author: Pino Toscano <pino@kde.org> -Date: Fri Jun 5 10:54:30 2009 +0200 - - [CMake] Add poppler version defines and version check macro - - Add POPPLER_[MAJOR|MINOR|MICRO]_VERSION defines and - POPPLER_CHECK_VERSION macro. FDO bug #22091. - - CMakeLists.txt | 5 ++++- - glib/poppler-features.h.cmake | 9 +++++++++ - 2 files changed, 13 insertions(+), 1 deletion(-) - -commit 26f6fb1d79c2589829cd896d57da63d16641f307 -Author: Pino Toscano <pino@kde.org> -Date: Fri Jun 5 10:51:26 2009 +0200 - - [CMake] switch poppler-features.h.cmake to a more autotools-like - syntax - - glib/CMakeLists.txt | 2 +- - glib/poppler-features.h.cmake | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 89704635b727db42f6c72ba101091eb7eddb967a -Author: Pino Toscano <pino@kde.org> -Date: Fri Jun 5 10:39:17 2009 +0200 - - [Qt4 demo] compile the new thumbnail module with autotools as well - - qt4/demos/Makefile.am | 3 +++ - 1 file changed, 3 insertions(+) - -commit 291bafe64c8755fe5f85a51b184ac6e3d3170e1d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Jun 5 10:07:16 2009 +0200 - - [glib] Use g_strerror instead of strerror - - Fixes bug #22095. - - glib/poppler-document.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 0ca7e214fb5f9c9fb59792149bd23c1617d38cac -Author: Christian Persch <chpe@gnome.org> -Date: Thu Jun 4 22:35:40 2009 +0200 - - Add poppler version defines and version check macro - - Add POPPLER_[MAJOR|MINOR|MICRO]_VERSION defines and - POPPLER_CHECK_VERSION macro. FDO bug #22091. - - configure.ac | 11 ++++- - glib/poppler-features.h.in | 9 ++++ - glib/reference/poppler-docs.sgml | 1 + - glib/reference/poppler-sections.txt | 10 ++++ - glib/reference/tmpl/poppler-features.sgml | 80 - +++++++++++++++++++++++++++++++ - 5 files changed, 110 insertions(+), 1 deletion(-) - -commit 4ce04da0040e5a2626c110f94a128e2d272401b9 -Author: Matthias Drochner <M.Drochner@fz-juelich.de> -Date: Thu Jun 4 23:05:22 2009 +0200 - - Use the correct value when creating the V field - - PDF Spec says: - For items represented in the Opt array by a two-element array, - the name string is the second of the two array elements. - - poppler/Form.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 7e01e37a834bfdd75d739ea2b48e9127ca7f259e -Author: Till Kamppeter <till.kamppeter@gmail.com> -Date: Thu Jun 4 20:25:55 2009 +0200 - - Add part of fix for bug 20420, the other part was checked in with - Thomas patches - - poppler/PSOutputDev.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 50a7b4bcaa6e5f56cc25fe6936f9dc537a1b4b37 -Author: Jeremy C. Reed <reed@reedmedia.net> -Date: Thu Jun 4 20:19:03 2009 +0200 - - [glib] Hyphenate UTF-8 and UTF-16BE - - Fixes bug #21953. - - where iconv() is called to fill in a text field, use "UTF-8" and - "UTF-16BE" as encoding names rather than the less portable - "UTF8" and "UTF16BE" -- this makes it work on NetBSD. - - glib/poppler-annot.cc | 2 +- - glib/poppler-form-field.cc | 4 ++-- - 2 files changed, 3 insertions(+), 3 deletions(-) - -commit 2cf9e6a2318b770ae62572944c687576d1801d31 -Author: Till Kamppeter <till.kamppeter@gmail.com> -Date: Thu Jun 4 19:48:42 2009 +0200 - - Support multiple page sizes when converting to PS - - Fixes byg #19777 - - poppler/PSOutputDev.cc | 31 +++++++++++++++++++++++++++++-- - poppler/PSOutputDev.h | 4 +++- - utils/pdftops.1 | 26 +++++++++++++++++++++----- - utils/pdftops.cc | 17 ++++++++++++----- - 4 files changed, 65 insertions(+), 13 deletions(-) - -commit 30fb7cb7e47cf6a8008c5083c8d0978fdfdf8e62 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jun 4 19:25:22 2009 +0200 - - Add missing { } - - poppler/Gfx.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 1beec21ed3a016998fee3849d460166895db9047 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jun 3 22:37:43 2009 +0200 - - Give an error when using level1sep without having CMYK support - - Fixes bug #22026 - - poppler/PSOutputDev.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit e80d645c34c7d44d1f35da0a25669d1c4cde6e7f -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jun 3 22:00:49 2009 +0200 - - Also accept tokens with to leading 00 - - Fixes bug 22025, based on a patch by William Bader - - poppler/CharCodeToUnicode.cc | 9 ++++++--- - 1 file changed, 6 insertions(+), 3 deletions(-) - -commit e521c1efaeba3f35d10e46bca3d9650dabd2d889 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Wed Jun 3 22:08:57 2009 +0930 - - Implement text in pattern colorspace for the cairo backend - - poppler/CairoOutputDev.cc | 47 - +++++++++++++++++++++++++++++++++++++++++++++++ - poppler/CairoOutputDev.h | 19 +++++++++++++++++++ - 2 files changed, 66 insertions(+) - -commit a87978b09a026b2db6b0f80271d87b44b336a121 -Author: Pino Toscano <pino@kde.org> -Date: Wed Jun 3 13:49:56 2009 +0200 - - [Qt4 demo] show the checksum for embedded files - - qt4/demos/embeddedfiles.cpp | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit db5102842494a124d813db1696bb60820db3442b -Author: Pino Toscano <pino@kde.org> -Date: Wed Jun 3 13:21:22 2009 +0200 - - [Qt4 demo] remove checks for Qt >= 4.2 - - poppler-qt4 requires Qt 4.3, so checking for 4.2 is no more needed - - qt4/demos/embeddedfiles.cpp | 2 -- - qt4/demos/fonts.cpp | 2 -- - qt4/demos/info.cpp | 2 -- - qt4/demos/optcontent.cpp | 2 -- - qt4/demos/permissions.cpp | 2 -- - qt4/demos/toc.cpp | 2 -- - 6 files changed, 12 deletions(-) - -commit e8d897581656ee4a20e9bb87dd999425663ace3b -Author: Pino Toscano <pino@kde.org> -Date: Wed Jun 3 02:54:29 2009 +0200 - - [Qt4 demo] simplier way to change page from the thumbnail view - - qt4/demos/pageview.cpp | 5 ----- - qt4/demos/pageview.h | 3 --- - qt4/demos/thumbnails.cpp | 2 +- - qt4/demos/thumbnails.h | 3 --- - qt4/demos/viewer.cpp | 1 - - 5 files changed, 1 insertion(+), 13 deletions(-) - -commit f69a4fe47d3478cccbc03e4ac0929c7eada681c0 -Author: Pino Toscano <pino@kde.org> -Date: Wed Jun 3 01:24:21 2009 +0200 - - [Qt4 demo] Add a thumbnail dock widget - - Useful to show the embedded page thumbnails in the document, if any. - Based on a patch by Shawn Rutledge <shawn.t.rutledge@gmail.com>, - reworked by me to be a QListWidget showing the page items at their - full size. - - qt4/demos/CMakeLists.txt | 1 + - qt4/demos/thumbnails.cpp | 84 - ++++++++++++++++++++++++++++++++++++++++++++++++ - qt4/demos/thumbnails.h | 51 +++++++++++++++++++++++++++++ - qt4/demos/viewer.cpp | 11 ++++++- - 4 files changed, 146 insertions(+), 1 deletion(-) - -commit 2f24ac0f4bbd6de1c9f137110b3ac2bd3b23b0b9 -Author: Shawn Rutledge <shawn.t.rutledge@gmail.com> -Date: Wed Jun 3 01:22:31 2009 +0200 - - [Qt4 demo] add a public slot to set the current page - - qt4/demos/pageview.cpp | 5 +++++ - qt4/demos/pageview.h | 3 +++ - 2 files changed, 8 insertions(+) - -commit 1f1baf186f9e37606765e51ec5b9893ddfbfa893 -Author: Shawn Rutledge <shawn.t.rutledge@gmail.com> -Date: Wed Jun 3 01:19:16 2009 +0200 - - [Qt4] Add Page::thumbnail() - - This function can be used to get the embedded thumbnail of the page, - present in the document. - Reindented by me, and avoid a memory leak because of non-freed data. - - qt4/src/poppler-page.cc | 21 ++++++++++++++++++++- - qt4/src/poppler-qt4.h | 11 +++++++++++ - 2 files changed, 31 insertions(+), 1 deletion(-) - -commit 5cc24be1e9af0a27ab88ffa719bcabc2378868e4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jun 3 00:05:54 2009 +0200 - - Remove unused variables - - poppler/SplashOutputDev.cc | 3 --- - 1 file changed, 3 deletions(-) - -commit 45823bf8f4abacbbf257f6708264de074eda3cf4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jun 3 00:02:54 2009 +0200 - - Make it compile :-/ - - poppler/SplashOutputDev.cc | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -commit f5ae14907261a46c121f3ed7aea9d7ad9b9c55de -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 2 23:52:59 2009 +0200 - - Really fix the typo - - README | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 5d4b1995cdd57db7cef3d88704850aaf66ed7fff -Author: William Bader <williambader@hotmail.com> -Date: Tue Jun 2 23:10:53 2009 +0200 - - Fix three typos in README - - README | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 104f9286ceb5fcb5f4795bca7633029142d5f6a4 -Author: Thomas Freitag <Thomas.Freitag@alfa.de> -Date: Tue Jun 2 22:59:42 2009 +0200 - - Support colorizing text in pattern colorspace - - This implements commits the final patches for bug 19670 and 19994 - Also fixes bugs 15819 and 2807 - Also implements blending for SPLASH_CMYK in Splash - It's a quite big change but i've done regression testing over my whole - pdf suite and did not fit anything that went worse, just improvements - Missing the Cairo support - - CMakeLists.txt | 1 + - poppler/Gfx.cc | 135 ++++++++++++--- - poppler/Gfx.h | 7 + - poppler/GfxState.cc | 58 +------ - poppler/GfxState_helpers.h | 80 +++++++++ - poppler/Makefile.am | 1 + - poppler/OutputDev.h | 14 ++ - poppler/PSOutputDev.cc | 285 +++++++++++++++++++------------- - poppler/PSOutputDev.h | 18 ++ - poppler/SplashOutputDev.cc | 404 - ++++++++++++++++++++++++++++++++++++++------- - poppler/SplashOutputDev.h | 19 +++ - 11 files changed, 766 insertions(+), 256 deletions(-) - -commit d3e4563146cbff4cb507522783e60462461c7524 -Author: Thomas Freitag <Thomas.Freitag@alfa.de> -Date: Sun May 31 23:23:07 2009 +0200 - - Set memory to 0 after allocation, fixes problems on Sun machines, - should not hurt for others - - poppler/GfxState.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 78a58931b4347ecb505bad5a51104382ef5f91c7 -Author: Thomas Freitag <Thomas.Freitag@alfa.de> -Date: Sun May 31 22:52:23 2009 +0200 - - Add splashClearColor that assigns white to the given colorptr - - splash/SplashTypes.h | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -commit 47c26747b32c242ec8ac60e7b93150a67eb22e31 -Author: Thomas Freitag <Thomas.Freitag@alfa.de> -Date: Sun May 31 22:51:22 2009 +0200 - - Fix splashColorModeNComps to correctly include all values for each - SplashColorMode - - splash/SplashState.cc | 17 +++++++++++++++++ - 1 file changed, 17 insertions(+) - -commit 41775d8c0b44bf591d8ff5ede7fad276e8fa9eef -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Jun 1 15:24:24 2009 +0200 - - [glib-demo] Use poppler_annot_markup_has_popup() - - glib/demo/annots.c | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -commit f542c5294394e837298cb7e7d1d94bb336bfd09d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Jun 1 15:24:04 2009 +0200 - - [glib] Add poppler_annot_markup_has_popup() - - glib/poppler-annot.cc | 20 ++++++++++++++++++++ - glib/poppler-annot.h | 1 + - 2 files changed, 21 insertions(+) - -commit af32d56af779edcc539b680e634755941d1bf45c -Author: Petr Gajdos <pgajdos@novell.com> -Date: Thu May 21 00:37:18 2009 +0200 - - Add the possibility of forcing no hinting of fonts - - poppler/ArthurOutputDev.cc | 2 ++ - poppler/GlobalParams.cc | 20 ++++++++++++ - poppler/GlobalParams.h | 4 +++ - poppler/SplashOutputDev.cc | 2 ++ - splash/SplashFTFont.cc | 76 - +++++++++++++++++++++++++++----------------- - splash/SplashFTFont.h | 2 ++ - splash/SplashFTFontEngine.cc | 8 +++-- - splash/SplashFTFontEngine.h | 6 ++-- - splash/SplashFontEngine.cc | 4 ++- - splash/SplashFontEngine.h | 2 ++ - 10 files changed, 91 insertions(+), 35 deletions(-) - -commit 1a69d9638214943b3c2278f570694d9722a5de15 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed May 20 23:58:44 2009 +0200 - - Do not create the GfxColorTransform if the lcms could not be created - - Fixes crash on pdf from bug 20108 - - poppler/GfxState.cc | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -commit 95246d39c1289111a4ba3eb2ffbec50d7702e5eb -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed May 20 23:20:20 2009 +0200 - - Check Mask entries are int before using them, also if they are real - cast to int and try to use them - - Fixes bug #21841 - - poppler/Gfx.cc | 11 ++++++++++- - 1 file changed, 10 insertions(+), 1 deletion(-) - -commit 0c3517bfb4e1e1a28962f8d490ad69ec5766b6a1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed May 20 23:08:41 2009 +0200 - - Fix pdftops crash on file from KDE bug 174899 - - Still does not generate a correct ps file, but at least the program - does not crash now - - fofi/FoFiTrueType.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 548c72600b8a5e076647041660ed5031feedc7cc -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed May 20 22:43:11 2009 +0200 - - Do not exit(1) on a pdf i have lying around - - PDF is 0f03b3539a436a9f18d7e4e29d410f89 6607907.pdf - - poppler/JBIG2Stream.cc | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -commit f78d3a7ff5ef4b500d76d84ebc45aac3be162dab -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon May 18 20:44:40 2009 +0200 - - Move lcms.h include to GfxState.cc, replace lcms typedefs by void * - - poppler/GfxState.cc | 70 - ++++++++++++++++++++++++++++++++++++++++++++++------- - poppler/GfxState.h | 64 +++++++++++------------------------------------- - 2 files changed, 75 insertions(+), 59 deletions(-) - -commit ec2467f9981b7e7c23d5dcd8eabf2e7c8cdf8930 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun May 17 20:00:53 2009 +0200 - - Use the lcms include dir - - CMakeLists.txt | 3 +++ - poppler/Makefile.am | 2 ++ - 2 files changed, 5 insertions(+) - -commit e0fcf7055af480498a81a000dcd9f977a783df66 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun May 17 12:07:05 2009 +0200 - - Use pkgconfig for autotools cms check - - configure.ac | 12 +++++++----- - poppler/Makefile.am | 2 +- - 2 files changed, 8 insertions(+), 6 deletions(-) - -commit 657734c19274ab281328cba9297eca45e48777aa -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun May 17 12:06:47 2009 +0200 - - Better lcms check comming from kdelibs - - cmake/modules/FindLCMS.cmake | 95 - +++++++++++++++++++++++++++++++++----------- - 1 file changed, 71 insertions(+), 24 deletions(-) - -commit 0974b7b4bfe3f8cf3a1408741ddf01c667c28044 -Author: Patrick Spendrin <ps_ml@gmx.de> -Date: Thu May 14 16:15:22 2009 +0200 - - [Win32] Build fix for MSVC. - - poppler-config.h.cmake | 2 +- - poppler/poppler-config.h.in | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit d1c0e8a6c63361304cd453bb4c51e84a1aab7efa -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu May 14 00:29:18 2009 +0200 - - Kill support for specifying extension in openTmpFile - - We don't use it and it would not work anyway, see bug #21713 - - goo/gfile.cc | 58 - ++++++++++---------------------------------- - goo/gfile.h | 3 ++- - poppler/CairoFontEngine.cc | 6 ++--- - splash/SplashFTFontEngine.cc | 3 ++- - splash/SplashT1FontEngine.cc | 3 ++- - splash/SplashT1FontFile.cc | 3 ++- - 6 files changed, 24 insertions(+), 52 deletions(-) - -commit e237d8b5c2ae8805487a0790d9fb218263686712 -Author: Pino Toscano <pino@kde.org> -Date: Wed May 13 18:37:07 2009 +0200 - - [Qt4] we don't need an output device anymore (since long, even) - for resolving destinations - - qt4/src/poppler-document.cc | 3 --- - 1 file changed, 3 deletions(-) - -commit 9a2a851da93ef1a0c291fc9523a468e808ffd08e -Author: Pino Toscano <pino@kde.org> -Date: Wed May 13 18:19:11 2009 +0200 - - [Qt4] Do not try to resolve named destinations for GoTo links pointing - to external documents. - - In such cases, the named destination is a destination in the external - document, so we would try to look up a destination which is not in - the current document (thus the look up is unuseful). - It is task of the users of poppler-qt4 detect such - situations, and resolve the named when necessary, using - Document::linkDestination(QString). - - qt4/src/poppler-document.cc | 2 +- - qt4/src/poppler-link.cc | 2 +- - qt4/src/poppler-page.cc | 6 ++++-- - qt4/src/poppler-private.cc | 4 ++-- - qt4/src/poppler-private.h | 5 +++-- - 5 files changed, 11 insertions(+), 8 deletions(-) - -commit 51f6cc26fc5fdccce1ba4d4816dec374ce85d67a -Author: Pino Toscano <pino@kde.org> -Date: Wed May 13 17:38:00 2009 +0200 - - [Qt4] start a (basic) unit test for links & destinations - - qt4/tests/CMakeLists.txt | 1 + - qt4/tests/Makefile.am | 5 +++ - qt4/tests/check_links.cpp | 96 - +++++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 102 insertions(+) - -commit 174f8087f5e09c5d1915de128b7a15acf47c1e13 -Author: Pino Toscano <pino@kde.org> -Date: Wed May 13 16:44:59 2009 +0200 - - [Qt4] set the destination name only when it is not resolved - - qt4/src/poppler-link.cc | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - -commit fb0cb2add9443992f166acdf744fbec875faaabf -Author: Pino Toscano <pino@kde.org> -Date: Tue May 12 01:53:43 2009 +0200 - - [Qt4] Add LinkDestination::destinationName() that returns the name - of the current destination. - - qt4/src/poppler-link.cc | 10 ++++++++++ - qt4/src/poppler-link.h | 7 +++++++ - 2 files changed, 17 insertions(+) - -commit b8bd44f1302f7b6a6923d41c98ec74c118a5abb8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon May 11 20:49:34 2009 +0200 - - Poppler 0.11.0 aka 0.12 Alpha 1 - - CMakeLists.txt | 4 +- - NEWS | 142 - ++++++++++++++++++++++++++++++++++++++++++++++++++++ - configure.ac | 2 +- - msvc/config.h | 6 +-- - poppler/Makefile.am | 2 +- - qt4/src/Doxyfile | 2 +- - 6 files changed, 150 insertions(+), 8 deletions(-) - -commit 79bcedd5602729b959f21aed222445de621e7ecb -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon May 11 19:59:57 2009 +0200 - - Update copyright headers for previous patches - - poppler/ArthurOutputDev.cc | 1 + - poppler/CairoOutputDev.cc | 2 +- - poppler/Page.cc | 2 +- - poppler/Stream.cc | 1 + - poppler/Stream.h | 1 + - utils/HtmlOutputDev.cc | 1 + - utils/ImageOutputDev.cc | 1 + - 7 files changed, 7 insertions(+), 2 deletions(-) - -commit f16e36df3a74e1adf14513a6340be2e8665f8d65 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun May 10 19:24:32 2009 +0200 - - Don't include popups annots with a parent in annots list - - poppler/Annot.cc | 13 +++++++++++++ - 1 file changed, 13 insertions(+) - -commit 5051ebed1477ff3f7721606f79d66d56a80c1145 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun May 10 19:10:51 2009 +0200 - - Make sure ImageStream::close() is called after ImageStream::reset() - - poppler/ArthurOutputDev.cc | 1 + - poppler/CairoOutputDev.cc | 20 +++++++++++++++++--- - poppler/Page.cc | 1 + - poppler/Stream.cc | 4 ++++ - poppler/Stream.h | 3 +++ - utils/HtmlOutputDev.cc | 1 + - utils/ImageOutputDev.cc | 1 + - 7 files changed, 28 insertions(+), 3 deletions(-) - -commit 829ed964374676ddfa4a9048c940dc20a309ca47 -Author: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi> -Date: Sun May 10 23:39:11 2009 +0200 - - Fix axial shading fix to ensure the painting passes by the four - edges of the bbox - - When j and teoricalj are the same, just change the value of ta[] - not the next[] ones - - poppler/Gfx.cc | 23 ++++++++++++++++------- - 1 file changed, 16 insertions(+), 7 deletions(-) - -commit 68d9644499676ed1553b2bfcdbfc9a5677c75345 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat May 9 22:25:12 2009 +0200 - - Hidden property depends on parent being hidden, not only yourself - - Fixes bug #16093 - - poppler/Gfx.cc | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -commit 810a71ea66f0e07d9849a5e9bf28911472482d1b -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri May 8 09:36:31 2009 +0200 - - [glib] Add poppler_annot_markup_get_popup_rectangle - - glib/demo/annots.c | 8 ++++++++ - glib/poppler-annot.cc | 35 +++++++++++++++++++++++++++++++++++ - glib/poppler-annot.h | 2 ++ - 3 files changed, 45 insertions(+) - -commit 5d328282da4713356fbe4283bd992ac2fc9010a2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu May 7 23:11:55 2009 +0200 - - bitmap->h can be 0, move to _checkoverflow variant, code already - knows how to deal with NULL - - splash/SplashFTFont.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 5b0fb6f94d6d54b1b0c97762db61e2ab0dd07c85 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed May 6 22:59:55 2009 +0200 - - Fix format printing - - poppler/JBIG2Stream.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit c21b08a254f42f53d4b59ad4fb308c7c68c32d15 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed May 6 15:56:21 2009 +0200 - - [glib] Several fixes in poppler_annot_get_color() - - PopplerColor is compatible with GdkColor where every component is - in the - range of 0 to 65535, we were returning values between 0 and 1 but - converted to guint16. - We were also showing a warning when AnnotColor::colorTransparent is - used, but we decided to return a PopplerColor * to be able to - represent - transparent color returning NULL, so it's actually supported. - - glib/demo/annots.c | 25 +++++++++++-------------- - glib/poppler-annot.cc | 36 +++++++++++++++++++++--------------- - 2 files changed, 32 insertions(+), 29 deletions(-) - -commit 63cc40ec02498e1ec249d5f74e23f574c665872e -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat May 2 14:08:23 2009 +0200 - - Link pdftoabw to abiword libs - - Fixes bug #21520 - - utils/Makefile.am | 22 ++++++++++++---------- - 1 file changed, 12 insertions(+), 10 deletions(-) - -commit 70e06e9ae28d08bb7495a7f2eb03b0b5714a1e54 -Author: Kouhei Sutou <kou@cozmixng.org> -Date: Wed Apr 29 09:52:21 2009 +0900 - - PopplerAttachment refers its document. - - glib/poppler-attachment.cc | 41 +++++++++++++++++++++++++++++++++++------ - 1 file changed, 35 insertions(+), 6 deletions(-) - -commit 977a13f1091700bf7e7b31859e0e6632dc323462 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Apr 25 19:07:01 2009 +0200 - - [glib] Only create checksum string for valid checksums - - glib/poppler-attachment.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit fb6e7141e3008ae230ae5819e2c7a0425296d8d2 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Apr 24 10:13:53 2009 +0200 - - Update copyright headers - - glib/poppler-annot.cc | 1 + - glib/poppler-annot.h | 1 + - poppler/Annot.cc | 2 +- - poppler/Annot.h | 2 +- - poppler/DateInfo.cc | 1 + - poppler/DateInfo.h | 1 + - 6 files changed, 6 insertions(+), 2 deletions(-) - -commit fc7e52fef0317f9c85ead2c4f8a0e9b688decca3 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Apr 24 09:53:41 2009 +0200 - - Fix typos in Annot::setContents() documentation - - poppler/Annot.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit df0032cf5f6e5dc44bad056c659180e4065d32e2 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Apr 23 13:19:25 2009 +0200 - - Document Annot::setContents() method - - poppler/Annot.h | 2 ++ - 1 file changed, 2 insertions(+) - -commit 86a37a8f3f93e3378b446f8d81d80571267c7660 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Apr 23 13:16:04 2009 +0200 - - Update the annotation last modified time when it's modified - - poppler/Annot.cc | 26 ++++++++++++++++---------- - poppler/Annot.h | 7 ++++--- - 2 files changed, 20 insertions(+), 13 deletions(-) - -commit 9662bfa2b4b2282d0fc29d2a327b62d8bde56ff2 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Apr 23 13:13:07 2009 +0200 - - Add timeToDateString() to DateInfo - - This function converts a time_t into a string in PDF date format. - - configure.ac | 1 + - poppler/DateInfo.cc | 47 +++++++++++++++++++++++++++++++++++++++++++++++ - poppler/DateInfo.h | 7 +++++++ - 3 files changed, 55 insertions(+) - -commit dc4cf0c29b53cda5c1c2badc5026af3429502e3a -Author: Pino Toscano <pino@kde.org> -Date: Tue Apr 21 21:51:52 2009 +0200 - - add poppler-date.{cc,h} - - glib/CMakeLists.txt | 2 ++ - 1 file changed, 2 insertions(+) - -commit 0750c6502faeabff571f5730b567097e793dca64 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Apr 21 20:04:27 2009 +0200 - - [glib-demo] Fix dates handling in annots demo - - glib/demo/annots.c | 69 - +++++++++++------------------------------------------- - 1 file changed, 14 insertions(+), 55 deletions(-) - -commit fe73bf9771e8294af4c8a11ec4c2891ff8f8d859 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Apr 21 20:02:25 2009 +0200 - - [glib-demo] GTime is deprecated, use time_t instead - - glib/demo/utils.c | 2 +- - glib/demo/utils.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 6d468cfa0cb89760e5d6cca43521cde6d99aa52e -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Apr 21 20:00:20 2009 +0200 - - [glib-demo] Use format_date from utils and remove duplicated code - - glib/demo/info.cc | 27 ++------------------------- - 1 file changed, 2 insertions(+), 25 deletions(-) - -commit e5f5ea01d0da4c4d877b93755523dc2a7f2ec049 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Apr 21 19:57:11 2009 +0200 - - [glib] Fix poppler_annot_markup_get_date() - - Date field in Markup annots is also a PDF format date string, so it - should be parsed and the resulting time_t used to create a correct - GDate. - - glib/poppler-annot.cc | 22 +++++++++++----------- - 1 file changed, 11 insertions(+), 11 deletions(-) - -commit 876ad1bcc8a7b2f37656bf15cee7eb888fd46ed4 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Apr 21 19:36:33 2009 +0200 - - [glib] Add info about the return value in poppler_annot_get_modified() - doc - - glib/poppler-annot.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit 8c54a15e1715721ee7af7e82c90b8dda3689c65f -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Apr 21 19:35:14 2009 +0200 - - [glib] Fix a typo in poppler_date_parse documentation - - glib/poppler-date.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 39d09fa237d06fa93b02eb916d2c0242c4e8fe85 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Apr 21 19:29:32 2009 +0200 - - [glib] Add poppler_date_parse to parse PDF format date strings - - We need to make this public because the field M in the Annot - dictionary - might be a Date string (in PDF date format) or a text - string. According - to the PDF spec: "The preferred format is a date string as described - in - Section 3.8.3, “Dates,” but viewer applications should be - prepared to - accept and display a string in any format". The only way to know - whether - it's a PDF date string or not, is by trying to parse it. For this - reason - poppler_annot_get_modified() returns a gchar * instead of a - time_t. So, - viewers should try to parse the string in order to convert it to a - time_t, and if it fails to parse, use the date string as provided - by the - document. - - glib/Makefile.am | 2 ++ - glib/poppler-attachment.cc | 4 +-- - glib/poppler-date.cc | 66 - ++++++++++++++++++++++++++++++++++++++++++++++ - glib/poppler-date.h | 30 +++++++++++++++++++++ - glib/poppler-document.cc | 45 ++++++------------------------- - glib/poppler-private.h | 2 +- - glib/poppler.h | 1 + - 7 files changed, 110 insertions(+), 40 deletions(-) - -commit 9c2714a3e1c02f445661618e24bcd27f1392b2b7 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Apr 21 18:08:06 2009 +0200 - - [glib] Implement poppler_annot_set_contents() - - glib/poppler-annot.cc | 25 +++++++++++++++++++++++++ - glib/poppler-annot.h | 2 ++ - 2 files changed, 27 insertions(+) - -commit eec550e8b3cf96aefed9b03a78d365c2848fb8f2 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Apr 21 18:06:34 2009 +0200 - - Add setContents() to modify the annot contents - - poppler/Annot.cc | 26 +++++++++++++++++++++++++- - poppler/Annot.h | 4 ++++ - 2 files changed, 29 insertions(+), 1 deletion(-) - -commit 047a8870a8cea9b680080e0d3bf68d0685431233 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Apr 20 23:38:53 2009 +0200 - - In case of err3 or err2 in readPageTree we need to free kidRef too - - poppler/Catalog.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit cb61b555f2c4db8685dec5491ca86570c962aab6 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Apr 18 18:30:04 2009 +0200 - - Extend test-poppler-glib to show more page annotations and actions - - Based on path by Thomas Viehmann <tv@beamnet.de> - - glib/test-poppler-glib.cc | 68 - +++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 68 insertions(+) - -commit 2221b8a9ae5e986c79ea3f6c9f3b0246d328c7ab -Author: Matthias Franz <matthias@ktug.or.kr> -Date: Sun Apr 19 23:29:18 2009 +0200 - - Fix decryption using owner password on some pdf - - See bug #21270 - - poppler/Decrypt.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit e20efbf6cc676758b8ef7d2ad607560fcdbbf89e -Author: Peter Kerzum <kerzum@yandex-team.ru> -Date: Fri Apr 17 22:14:26 2009 +0200 - - Fix typo in GfxFont.cc - - poppler/GfxFont.cc | 11 ++++++----- - 1 file changed, 6 insertions(+), 5 deletions(-) - -commit b760debea03380280d72cd39d792cbc1a380a87c -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Apr 17 21:04:26 2009 +0200 - - Fix rendering of axial shadings - - Fixes bug #19896 - - poppler/Gfx.cc | 102 - +++++++++++++++++++++++++++++++++++---------------------- - 1 file changed, 62 insertions(+), 40 deletions(-) - -commit 9f1312f3d7dfa7e536606a7c7296b7c876b11c00 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Apr 16 22:13:26 2009 +0200 - - Fix problems that happen when parsing broken JBIG2 files - - Fixes - CVE-2009-0799 xpdf OOB Read - CVE-2009-0800 xpdf Multiple Input Validation Flaws - CVE-2009-1179 xpdf Integer Overflow - CVE-2009-1180 xpdf Invalid free() - CVE-2009-1181 xpdf NULL dereference DoS - CVE-2009-1182 xpdf MMR Decoder Buffer Overflows - CVE-2009-1183 xpdf MMR Infinite Loop DoS - - Patch based on a patch by Derek Noonburg - Some files still hit the exit(1) in goo.c but at least none is - really crashing - - poppler/JBIG2Stream.cc | 447 - +++++++++++++++++++++++++++++++++++-------------- - poppler/JBIG2Stream.h | 4 + - 2 files changed, 324 insertions(+), 127 deletions(-) - -commit 284a92899602daa4a7f429e61849e794569310b5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Apr 13 21:51:12 2009 +0200 - - Did a mistake in the gmalloc -> gmallocn commit, it's a 4 here not a 3 - - poppler/SplashOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 9cf2325fb22f812b31858e519411f57747d39bd8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 11 00:31:57 2009 +0200 - - More gmalloc → gmallocn - - glib/poppler-page.cc | 2 +- - splash/Splash.cc | 8 ++++---- - splash/SplashBitmap.cc | 6 +++--- - splash/SplashFTFont.cc | 2 +- - 4 files changed, 9 insertions(+), 9 deletions(-) - -commit c399b2d512aa073b0d7cd8eb5413a4b43f0d6aef -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 11 00:26:23 2009 +0200 - - Revert part of last commit, i need more math classes :D - - poppler/JBIG2Stream.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 7b2d314a61fd0e12f47c62996cb49ec0d1ba747a -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 11 00:23:04 2009 +0200 - - Be paranoid, use gmallocn or gmallocn3 in all gmalloc with * - - poppler/ArthurOutputDev.cc | 4 ++-- - poppler/CairoOutputDev.cc | 14 +++++++------- - poppler/GfxState.cc | 8 ++++---- - poppler/JBIG2Stream.cc | 4 ++-- - poppler/PSOutputDev.cc | 6 +++--- - poppler/SplashOutputDev.cc | 20 ++++++++++---------- - 6 files changed, 28 insertions(+), 28 deletions(-) - -commit 0131f0a01cba8691d10a18de1137a4744988b346 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 11 00:20:55 2009 +0200 - - Add gmallocn3 that does the same as gmallocn but with 3 arguments - - goo/gmem.cc | 22 ++++++++++++++++++++++ - goo/gmem.h | 2 ++ - 2 files changed, 24 insertions(+) - -commit 75c3466ba2e4980802e80b939495981240261cd5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Apr 10 18:05:54 2009 +0200 - - Make it compile in Solaris - - See bug #21080 - - poppler/CairoFontEngine.cc | 14 ++++++++++++++ - 1 file changed, 14 insertions(+) - -commit 3210970dc1d6faf51bce59bb7ecb6b881f9c0fe6 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Apr 10 13:09:37 2009 +0200 - - [glib] Print annotations with the print flag enabled - - glib/poppler-page.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit b0b9798c85c7c6d6f336f73135a98974897b9f60 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Mar 30 23:26:39 2009 +0200 - - Fix clip test for fonts - - Fixes bug 20950 - I really don't remember why i put that -1 maybe i got mislead by - SplashClip::testRect - having a +1, but the idea of the +1 is correct because it's ints - vs floats - - splash/SplashFTFont.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 5c08f57aa80092954746d722bb13655aee3f162c -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Mar 29 23:52:31 2009 +0200 - - Forgot Ross copyright - - poppler/TextOutputDev.cc | 1 + - 1 file changed, 1 insertion(+) - -commit c6d3e7884010ebdcc961d81ca8c692870fc9b139 -Author: Ross Moore <ross@maths.mq.edu.au> -Date: Sun Mar 29 23:46:09 2009 +0200 - - Fix extraction of some ActualText content - - Fixes bug #20013 - - poppler/TextOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit e4b3f7cbcb6ccdfa8b18d8da5f7074f4140b776a -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Mar 25 22:16:07 2009 +0100 - - Fix getGlyphAdvance to behave correctly on font size changes - - Fixes bug #20769 - - splash/SplashFTFont.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 4acde05ac4d0b03466c949138321cc3445a14158 -Author: Eric Toombs <ewtoombs@uwaterloo.ca> -Date: Wed Mar 25 21:11:03 2009 +0100 - - Remove case-insensitive matching of filenames in PDFDoc constructor - - poppler/PDFDoc.cc | 39 ++++++++++----------------------------- - 1 file changed, 10 insertions(+), 29 deletions(-) - -commit 120c7f6697ed1edaff6e17ae1ed202c69f03a73c -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 24 22:56:33 2009 +0100 - - declare the matrix at the beginning - - poppler/ArthurOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 441a9cd56935bfe2d8fddc5d3bc2c0104aeffaca -Author: Eric Toombs <ewtoombs@uwaterloo.ca> -Date: Sun Mar 22 22:50:14 2009 +0100 - - Improved error reporting of ErrOpenFile errors - - See bug #20660 for more information - - glib/poppler-document.cc | 14 ++++++++++--- - poppler/PDFDoc.cc | 54 - ++++++++++++++++++++++++++++-------------------- - poppler/PDFDoc.h | 8 +++++++ - 3 files changed, 51 insertions(+), 25 deletions(-) - -commit 16af0ced4a0762f2f538135bd8dd72b469f6fdca -Author: Michael K. Johnson <a1237@danlj.org> -Date: Sat Mar 21 16:14:06 2009 +0100 - - Support rendering non-square pixels in pdftoppm - - Bug #20702 - - utils/pdftoppm.1 | 16 ++++++++++++++-- - utils/pdftoppm.cc | 37 ++++++++++++++++++++++++++++++++----- - 2 files changed, 46 insertions(+), 7 deletions(-) - -commit a103c60abd5fe4c721b099c005daf22d6350c355 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Mar 21 15:47:12 2009 +0100 - - Update version we need of Qt4 - - CMakeLists.txt | 2 +- - configure.ac | 8 ++++---- - 2 files changed, 5 insertions(+), 5 deletions(-) - -commit c4b1754fdd3a4649551556de2655c8291daafddf -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Mar 21 13:29:38 2009 +0100 - - Bump cairo dependency to 1.8.4 - - Cairo 1.8.4 fixes and important bug that affects the Type 3 font - rendering - - CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 50c4ee413929e5a70133839e3cde039da738fab2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Mar 18 22:00:05 2009 +0100 - - Add more _checkoverflow variants, rework internals - - goo/gmem.cc | 92 - ++++++++++++++++++++++++++++++------------------------------- - goo/gmem.h | 4 ++- - 2 files changed, 48 insertions(+), 48 deletions(-) - -commit 121c44db0884f0d70ba1470a66aa78441257c421 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Fri Mar 20 23:25:19 2009 +1030 - - Fix cairo luminosity smask when cairo ctm != identity - - poppler/CairoOutputDev.cc | 16 +++++++++++++++- - 1 file changed, 15 insertions(+), 1 deletion(-) - -commit 3f55aff56a1d2002ba79f3efba5eb77e94575439 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Thu Mar 19 22:34:23 2009 +1030 - - Fix bug in cairo backend with nested masks - - The previous smask was not restored after a q/Q pair or form xobject. - - poppler/CairoOutputDev.cc | 18 +++++++++++++++++- - poppler/CairoOutputDev.h | 5 +++++ - 2 files changed, 22 insertions(+), 1 deletion(-) - -commit 4cc3cb8992ac554352d68e97563823b9bbd556ce -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Mar 20 12:38:28 2009 +0100 - - Bump cairo dependency to 1.8.4 - - Cairo 1.8.4 fixes and important bug that affects the Type 3 font - rendering - - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit da94fe717a1ab60fb074fae61d582d1ee7151fc2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Mar 16 22:54:27 2009 +0100 - - Fix parsing of border arrays - - Fixes 19761 - - poppler/Annot.cc | 54 - ++++++++++++++++++++++++++++++++++++------------------ - 1 file changed, 36 insertions(+), 18 deletions(-) - -commit 8df0323f1ca4548a5d5824ece8736b356ce7ca42 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Mar 12 00:09:03 2009 +0100 - - Really fix jpeg lib init order? - - poppler/DCTStream.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 12aac6774fc6f92def3d5567051117951cc32223 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Mar 11 23:00:37 2009 +0100 - - fontCIDType2OT fonts can also have a CIDToGIDMap - - Fixes bug #20605 - - poppler/GfxFont.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 0ca9ae2848808d15e7a2b00f5eb33bb8f990c887 -Author: Vincent Torri <vtorri@univ-evry.fr> -Date: Wed Mar 11 00:39:59 2009 +0100 - - remove the fortran check during the initialisation of libtool - - configure.ac | 1 + - 1 file changed, 1 insertion(+) - -commit 710e329a3a6a9ee2eed997c9eeaea21c44237423 -Author: Vincent Torri <vtorri@univ-evry.fr> -Date: Wed Mar 11 00:37:11 2009 +0100 - - Add AC_CONFIG_MACRO_DIR([m4]) - - It is used by autoreconf to trace changes in m4 macros that are in - the m4/ subdirectory. - - configure.ac | 1 + - 1 file changed, 1 insertion(+) - -commit d15e47158ae31909212d3875159046afb208de97 -Author: Vincent Torri <vtorri@univ-evry.fr> -Date: Wed Mar 11 00:36:27 2009 +0100 - - Better check for pkg-config - - configure.ac | 5 +---- - 1 file changed, 1 insertion(+), 4 deletions(-) - -commit b3f569f9a6c117c097acac52ae6552209fcd2101 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Mar 11 00:25:07 2009 +0100 - - Check there is an optional content config before using it - - Fixes bug #20587 - - poppler/Gfx.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 7a5d1e57b2757c986da17f7238415b927e73127f -Author: Brian Ewins <Brian.Ewins@gmail.com> -Date: Mon Mar 9 22:54:58 2009 +0100 - - Check for pkgconfig before using it - - At the moment if pkgconfig is not installed, an unhelpful syntax - error appears when testing for freetype. Identify the problem - earlier on - - configure.ac | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit 8dc9e4d57a4759de2b56a87d9bace80d5d563fef -Author: Marc Kleine-Budde <mkl@pengutronix.de> -Date: Sun Mar 8 15:29:02 2009 +0100 - - use AC_CHECK_HEADER to find headers - - The original m4/libjpeg.m4 used AC_FIND_FILE to look for jpeg - header file. - This test is not cross-compiling save. This patch uses the autoconf - function - AC_CHECK_HEADER to look for the jpeg header, which works in the - native and - the cross compiling scenaria. - Bug #20538 - - m4/libjpeg.m4 | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit bf2e2f056cadbc488cd3e9576b44beb34689ec81 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Mar 8 13:44:44 2009 +0100 - - Add the new croptting options explanations - - utils/pdftotext.1 | 15 +++++++++++++++ - 1 file changed, 15 insertions(+) - -commit 663d9e5a448641421d290dd228be692a0f236b9c -Author: Jan Jockusch <jan@jockusch.de> -Date: Sun Mar 8 13:44:20 2009 +0100 - - Make pdftotext to accept cropping options like pdftoppm - - Bug #20331 - - utils/pdftotext.cc | 29 ++++++++++++++++++++++++++++- - 1 file changed, 28 insertions(+), 1 deletion(-) - -commit cc4b61f19b69c31d9a73ae7361c4b6a94345d1c2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Mar 8 12:55:45 2009 +0100 - - Fix the previous fix - - I should stop listening to people without checking that what they - say is - correct - - poppler/DCTStream.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit a4a73cd9f9ee9767d74fbb44ffe083d2057a9d61 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Mar 8 12:44:06 2009 +0100 - - I should compile before commiting :-/ - - poppler/DCTStream.cc | 1 - - 1 file changed, 1 deletion(-) - -commit 6a6b3cc91053e771a67dffa979076d130f87ff11 -Author: Ryszard Trojnacki <rysiek@menel.com> -Date: Sun Mar 8 12:38:42 2009 +0100 - - set up the error-manager before calling jpeg_create_decompress - - Bug #20484 - - poppler/DCTStream.cc | 11 +++++++---- - 1 file changed, 7 insertions(+), 4 deletions(-) - -commit 4dfa7460ddc4b5684d5ef8db17efa50b95b7b735 -Author: Nick Jones <nick.jones@network-box.com> -Date: Tue Mar 3 00:55:53 2009 +0100 - - Do not blindly follow loops parsing OutlineItem - - More details in bug 18364 - - poppler/Outline.cc | 15 ++++++++++++++- - 1 file changed, 14 insertions(+), 1 deletion(-) - -commit de3131ae38fc9442b198d4d7b0c57c6939ad66ce -Author: Pino Toscano <pino@kde.org> -Date: Mon Mar 2 15:20:07 2009 +0100 - - [Qt4] adapt to the new PDFDoc saving API - - store the error code instead of the bool - - qt4/src/poppler-pdf-converter.cc | 12 +++++++----- - 1 file changed, 7 insertions(+), 5 deletions(-) - -commit dac0542eb793603090416f1b7712ca08253f1e7f -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 2 09:54:22 2009 +0100 - - [glib] Correctly handle doc->saveAs() error code. - - Fixes bug #19915. - - glib/poppler-document.cc | 37 +++++++++++++++++++++++++++++++++---- - 1 file changed, 33 insertions(+), 4 deletions(-) - -commit bfc6572614727565d883b9545d4b6665f3c2fdfe -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Feb 28 13:16:49 2009 +0100 - - Return an error code instead of a GBool when saving - - poppler/PDFDoc.cc | 22 +++++++++++----------- - poppler/PDFDoc.h | 8 ++++---- - 2 files changed, 15 insertions(+), 15 deletions(-) - -commit f7c88148fdb671736d81dd5f01a3fb68f944510c -Author: Koji Otani <sho@bbr.jp> -Date: Wed Feb 25 23:38:35 2009 +0100 - - Fix cache shifting - - poppler/GfxState.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 305af8cdb6822858e152e1f930bba2ce3904bf1b -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Feb 25 22:40:24 2009 +0100 - - Make JBIG2Stream not crash in 2009-41414141.pdf - - poppler/JBIG2Stream.cc | 151 - ++++++++++++++++++++++++++++--------------------- - 1 file changed, 85 insertions(+), 66 deletions(-) - -commit 26a8217160c1eaeeadb92023b27e68f402e38dd0 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Feb 22 18:14:15 2009 +0100 - - Check if cairo_shape is not NULL before using it. - - We were checking shape instead. It fixes a crash with some documents. - See bug #17337. - - poppler/CairoOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 5e68e52da65b4d8c3817e5fbb6f1a937da321d48 -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 21 18:03:15 2009 +0100 - - [Qt4] do not assume the destination file name for links is ASCII - - qt4/src/poppler-page.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 439cb397fed33df627a09c70788d72bef20dc872 -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 21 18:02:36 2009 +0100 - - [Qt] do not assume the destination file name for links is ASCII - - qt/poppler-page.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 3ea5f45ad3e5a55e577a2e45f61b55932ed17013 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Feb 21 17:46:30 2009 +0100 - - [glib] Make sure filename is valid utf-8 for remote dests - - glib/poppler-action.cc | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit b5989e4ffece6c1831610ee163d05fd80386a001 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Feb 21 17:45:18 2009 +0100 - - Use the UF entry when present in Filespec dictionary - - poppler/FileSpec.cc | 14 +++++++------- - 1 file changed, 7 insertions(+), 7 deletions(-) - -commit 943fca42b5fa815fad650e42da4ad6e806adc3b1 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Feb 21 12:08:00 2009 +0100 - - [glib] Add a macro to define boxed types - - glib/poppler-action.cc | 26 +------------ - glib/poppler-annot.cc | 15 ++------ - glib/poppler-document.cc | 44 +++++---------------- - glib/poppler-page.cc | 99 - ++++++++++-------------------------------------- - glib/poppler-private.h | 20 ++++++++++ - 5 files changed, 53 insertions(+), 151 deletions(-) - -commit 7406337ed2d38a86308f20f8273a152538e524de -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Feb 21 11:11:20 2009 +0100 - - [glib] Use template files to create poppler-enums - - glib/Makefile.am | 43 - +++++++++++++----------------------------- - glib/poppler-enums.c.template | 44 - +++++++++++++++++++++++++++++++++++++++++++ - glib/poppler-enums.h.template | 25 ++++++++++++++++++++++++ - 3 files changed, 82 insertions(+), 30 deletions(-) - -commit 29bc9d1dd115b5d400975533c3924993c3adae30 -Author: Thomas Viehmann <tv@beamnet.de> -Date: Sat Jan 17 13:16:38 2009 +0100 - - glib small doc comment corrections - - glib/poppler-attachment.cc | 2 +- - glib/poppler-layer.cc | 2 ++ - glib/poppler.cc | 2 -- - 3 files changed, 3 insertions(+), 3 deletions(-) - -commit a06e715d89a99b909b8e7b73b733066c67b1ade3 -Author: Thomas Viehmann <tv@beamnet.de> -Date: Sat Jan 17 12:58:20 2009 +0100 - - Make glib API reference more complete - - glib/reference/poppler-docs.sgml | 2 + - glib/reference/poppler-sections.txt | 55 +++++ - glib/reference/tmpl/poppler-action.sgml | 9 +- - glib/reference/tmpl/poppler-annot.sgml | 368 - ++++++++++++++++++++++++++++++++ - glib/reference/tmpl/poppler-layer.sgml | 79 +++++++ - 5 files changed, 511 insertions(+), 2 deletions(-) - -commit 3a21dafa46d42d86daec440a85b9d63b292a3c88 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Feb 3 21:33:00 2009 +0100 - - Fix cache shifting - - If we do - for (i = 0;i < GFX_ICCBASED_CACHE_SIZE-1 && cache[i].num > 0;i++) { - cache[i+1] = cache[i]; - what we do at the end is copy position 0 to all others so - we need to do it in the reverse order - - poppler/GfxState.cc | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -commit 0ed3fd52bb2d3375ed302285b18f076721b8028e -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Feb 1 10:37:25 2009 +0100 - - [glib-demo] Fix a typo in format string - - glib/demo/page.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 2df6d530cd9acd8648a6196031218ef10e7b3891 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jan 29 00:51:13 2009 +0100 - - Add line that for some reason was not imported from xpdf file - - Fixes bug 19789 - - utils/ImageOutputDev.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 1fc342eadcbbb41302f190b215c5daf23c9ec9b1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jan 28 22:53:43 2009 +0100 - - Fix crash on unexepcted Form Opt value - - Fixes crash on bug 19790 - - poppler/Form.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit b1d4efb082ac3dadd7752a557e5aeb6651e17471 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jan 27 00:26:08 2009 +0100 - - PostScriptFunction::transform optimization - - Do not create and destroy a PSStack each time - PostScriptFunction::transform is called gives a 7% speedup on heavy - PostScriptFunction::transform pdf like nytimes firefox ad - - poppler/Function.cc | 12 ++++++++---- - poppler/Function.h | 15 +++++++++++++++ - 2 files changed, 23 insertions(+), 4 deletions(-) - -commit 90f95127d8d89cfcadeb7d701437ab07ce4a8a61 -Author: Koji Otani <sho@bbr.jp> -Date: Sun Jan 25 23:17:39 2009 +0100 - - Cache last 5 GfxICCBasedColorSpace - - poppler/GfxState.cc | 60 - +++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/GfxState.h | 15 ++++++++++++++ - 2 files changed, 75 insertions(+) - -commit d3f04f537fb3e963c149a7e2d8d83c7cb19da8c0 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jan 23 23:08:46 2009 +0100 - - Do not crash in some PDF we don't parse correctly - - Fixes bug 19702 - - poppler/JBIG2Stream.cc | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -commit 3990c9e52da7b17215506857c792c90a37ebac79 -Author: Koji Otani <sho@bbr.jp> -Date: Mon Jan 19 09:53:00 2009 +0100 - - Fix a problem in cairo backend when using a CMYK Profile - - poppler/GfxState.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 6e51ae7fe8b9dc8ad52b735f2fe056f8ea8f1dcb -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jan 15 22:33:04 2009 +0100 - - calculate the limit in a way that one does not access an invalid - index of the matrix - - poppler/DCTStream.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ea2aa7bd1ceb0e3282398f52683e4f52ef401f74 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jan 15 22:18:48 2009 +0100 - - Forgot my copyrights - - poppler/DCTStream.cc | 2 +- - poppler/DCTStream.h | 2 +- - poppler/Stream.cc | 2 +- - 3 files changed, 3 insertions(+), 3 deletions(-) - -commit d65dd23752ec14635d0d224afa7dd605f98a10a4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jan 15 22:17:14 2009 +0100 - - Minor optimizations - - poppler/DCTStream.cc | 17 ++++++++--------- - poppler/DCTStream.h | 3 ++- - poppler/Stream.cc | 3 ++- - 3 files changed, 12 insertions(+), 11 deletions(-) - -commit d3d2910f757dfc3e141aed62aa970136f9d7186f -Author: Pino Toscano <pino@kde.org> -Date: Sun Jan 11 00:40:46 2009 +0100 - - fix a (relatively small) memory leak when asking for a document-level - JS - - poppler/Catalog.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 869584a84eed507775ff1c3183fe484c14b6f77b -Author: Jonathan Kew <jonathan_kew@sil.org> -Date: Sat Jan 10 18:28:47 2009 +0100 - - Add the possibility of setting the datadir on runtime - - poppler/GlobalParams.cc | 27 ++++++++++++++++++++------- - poppler/GlobalParams.h | 5 ++++- - 2 files changed, 24 insertions(+), 8 deletions(-) - -commit cf112dceb1d6653beae73ce2fac6fb5eee48ff33 -Author: Koji Otani <sho@bbr.jp> -Date: Sat Jan 10 18:11:20 2009 +0100 - - Fix some problems with color management in CMYK Color Profile. - - Fixes bug 19483 - - poppler/GfxState.cc | 106 - ++++++++++++++++++++++++++-------------------------- - 1 file changed, 53 insertions(+), 53 deletions(-) - -commit 6dd77338d16f80760ae32ff9f3e2be9768fc0c49 -Author: Pino Toscano <pino@kde.org> -Date: Thu Jan 8 11:49:45 2009 +0100 - - [Qt4] use the cropbox for the annotations coordinates - - Fixes bug #18558. - - qt4/src/poppler-page.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 69c07c031159d36dde52609bffa6d48c3c56cef5 -Author: Pino Toscano <pino@kde.org> -Date: Thu Jan 8 00:59:19 2009 +0100 - - update Poppler copyright to 2009 - - msvc/poppler/poppler-config.h | 2 +- - poppler-config.h.cmake | 2 +- - poppler/poppler-config.h.in | 2 +- - 3 files changed, 3 insertions(+), 3 deletions(-) - -commit 79e0eea85cf063c6323caafbec97f3d71fc04ca2 -Author: Pino Toscano <pino@kde.org> -Date: Thu Jan 8 00:57:03 2009 +0100 - - remove old cmake modules, add a new one - - Makefile.am | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit 0e6420ece2d6fcc046d5814b48a2754fb86771e2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jan 7 23:33:02 2009 +0100 - - Require cmake 2.6.0, remove two cmake files provided upstream - - CMakeLists.txt | 4 +- - cmake/modules/FindFreetype.cmake | 74 - ----------------------- - cmake/modules/FindPackageHandleStandardArgs.cmake | 58 ------------------ - glib/CMakeLists.txt | 2 +- - 4 files changed, 3 insertions(+), 135 deletions(-) - -commit a69add73bf7bef17c677c735db77934ba67188a5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jan 7 19:06:13 2009 +0100 - - Update copyright notices - - poppler/FontInfo.cc | 1 + - poppler/FontInfo.h | 1 + - qt4/src/poppler-document.cc | 2 +- - qt4/src/poppler-fontinfo.cc | 2 +- - qt4/src/poppler-form.cc | 1 + - qt4/src/poppler-form.h | 1 + - qt4/src/poppler-private.h | 2 +- - qt4/src/poppler-qt4.h | 2 +- - 8 files changed, 8 insertions(+), 4 deletions(-) - -commit 18d584158a781fecb4f696b01fb4d17803ce7d7a -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jan 7 17:55:48 2009 +0100 - - Add lcms option to cmake buildsystem - - CMakeLists.txt | 9 +++++++++ - cmake/modules/FindLCMS.cmake | 37 +++++++++++++++++++++++++++++++++++++ - config.h.cmake | 3 +++ - 3 files changed, 49 insertions(+) - -commit 140b8ed97416f9c2ec02eb749ca45ca50bd651a8 -Author: Koji Otani <sho@bbr.jp> -Date: Wed Jan 7 17:43:44 2009 +0100 - - Add initial support for color management - - configure.ac | 19 ++ - poppler/GfxState.cc | 697 - ++++++++++++++++++++++++++++++++++++++++++++++++---- - poppler/GfxState.h | 74 +++++- - poppler/Makefile.am | 5 + - 4 files changed, 738 insertions(+), 57 deletions(-) - -commit bdc76dc811a6e4d5fd929bbdc8cd3300aeaea31f -Author: Pino Toscano <pino@kde.org> -Date: Tue Jan 6 15:45:37 2009 +0100 - - [Qt4] apidox improvements for the font functions of Document; mark - scanForFonts() as deprecated - - qt4/src/poppler-qt4.h | 22 ++++++++++++++++++---- - 1 file changed, 18 insertions(+), 4 deletions(-) - -commit 6630e715714161cd803fc064f5d3cf880f42b0a5 -Author: Pino Toscano <pino@kde.org> -Date: Tue Jan 6 15:36:19 2009 +0100 - - tell Doxygen to consider Q_DECL_DEPRECATED as empty - - qt4/src/Doxyfile | 1 + - 1 file changed, 1 insertion(+) - -commit d748d430b106580b8be29ca3ec75caf05b55812e -Author: Pino Toscano <pino@kde.org> -Date: Tue Jan 6 15:24:25 2009 +0100 - - [Qt4] Add a FontIterator for iterating through the fonts of the - document, page by page. - - This new iterator class is the new preferred way for getting the - fonts of a document in a page-by-page mode. - * Document::fonts() is adapted to use it, instead of relying on - scanForFonts() - * scanForFonts() is ported to FontIterator, but keeping the old - behaviour ("i can scan the document only once") - * added unit tests for fonts(), scanForFonts() and FontIterator - - qt4/src/poppler-document.cc | 27 +++++--- - qt4/src/poppler-fontinfo.cc | 36 +++++++++++ - qt4/src/poppler-private.h | 27 ++++++-- - qt4/src/poppler-qt4.h | 65 +++++++++++++++++++ - qt4/tests/check_fonts.cpp | 149 - ++++++++++++++++++++++++++++++++++++++++++++ - 5 files changed, 291 insertions(+), 13 deletions(-) - -commit b9804542bb50216786dc11ca16efd84304f4b832 -Author: Pino Toscano <pino@kde.org> -Date: Tue Jan 6 15:16:53 2009 +0100 - - Add the possibility to set the first page to scan. - - The default value is 0 (= first page), so it should be compatible - with any usage so far. - - poppler/FontInfo.cc | 4 ++-- - poppler/FontInfo.h | 2 +- - 2 files changed, 3 insertions(+), 3 deletions(-) - -commit af74fef03bfbd79334da5612c63c7793952542f9 -Author: Warren Toomey <poppler@tuhs.org> -Date: Tue Jan 6 01:36:31 2009 +0100 - - Add forgotten file to let the autotools based system build - - m4/libpng.m4 | 99 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 99 insertions(+) - -commit ae588500f62bab5666174ff3b1564c414c5a76c5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jan 6 01:35:38 2009 +0100 - - Fix the cmake buildsystem - - CMakeLists.txt | 6 ++++++ - config.h.cmake | 3 +++ - utils/CMakeLists.txt | 4 ++++ - 3 files changed, 13 insertions(+) - -commit 940d060a14712c09da427e2fac4ec579f7291b0f -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jan 6 01:27:06 2009 +0100 - - do not leak fName if fopen fails - - utils/HtmlOutputDev.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 7be9198adb940ad7c5fffc6db0158cf7042e1b8f -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jan 6 01:24:15 2009 +0100 - - Do not leak pgNum and imgnum if fopen fails - - utils/HtmlOutputDev.cc | 16 +++++++++------- - 1 file changed, 9 insertions(+), 7 deletions(-) - -commit dfba6c022b150553cb2b18b027e661b3b4625ce7 -Author: Warren Toomey <poppler@tuhs.org> -Date: Tue Jan 6 01:16:31 2009 +0100 - - Make pdftohtml output png images when the image stream is not a jpeg - - configure.ac | 14 ++++++ - utils/HtmlOutputDev.cc | 126 - ++++++++++++++++++++++++++++++++++++++++++++++--- - utils/HtmlOutputDev.h | 3 +- - utils/Makefile.am | 4 ++ - 4 files changed, 140 insertions(+), 7 deletions(-) - -commit 0963c276ba972a36c2895e4fe1c7475acd489738 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 4 16:54:32 2009 +0100 - - Fix some checked checkboxes not rendering correctly - - If we are forcing ZaDb/ZapfDingbats to correctly draw a checkmark - in the checkbox, but the file does not have such font defined we - need to create a fake one so the system really renders it - Fixes bug 19359 - - poppler/Annot.cc | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- - poppler/Annot.h | 2 ++ - poppler/Gfx.h | 7 ++++--- - 3 files changed, 53 insertions(+), 5 deletions(-) - -commit 46128cf83b322c112eb0c409c20052bdb2ea4a37 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 4 14:21:15 2009 +0100 - - Remove wrong and unused FormWidget(FormWidget *dest) contructor - - poppler/Form.cc | 11 ----------- - poppler/Form.h | 3 +-- - 2 files changed, 1 insertion(+), 13 deletions(-) - -commit 5203aefc41fa47c461812cc46f28281edd226515 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 4 14:03:16 2009 +0100 - - Plug some memory leaks - - poppler/Annot.cc | 5 ++++- - poppler/Form.cc | 4 +++- - 2 files changed, 7 insertions(+), 2 deletions(-) - -commit 5fb7ec7e6af4cfb2b256a5b9b9752e68330b4aec -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Dec 30 23:46:59 2008 +0100 - - If Length2 is zero just write until we find EOF of the stream - - Fixes exporting to PS of the two pdf i have that have fonts with - Length2 set to 0 - - poppler/PSOutputDev.cc | 26 +++++++++++++++++++++----- - 1 file changed, 21 insertions(+), 5 deletions(-) - -commit ca35fdbc7c31dae432d775b6c087a83fa9b897fc -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Dec 30 23:03:57 2008 +0100 - - We need spaces here too to satify other consumer parsers - - poppler/PDFDoc.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 3c07c73e07a9cb59ee4c23ca60d2adce92de45f7 -Author: Pino Toscano <pino@kde.org> -Date: Tue Dec 30 22:21:27 2008 +0100 - - [Qt4-demo] load a document when passed via command line - - qt4/demos/main_viewer.cpp | 4 ++++ - 1 file changed, 4 insertions(+) - -commit aba0aaa896d634a51fbb3a3e6eae411be462f930 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Dec 29 00:31:18 2008 +0100 - - More improvements in document writing - - Dictionary keys are names so need to be sanitized - Add a space after num gen obj - - poppler/PDFDoc.cc | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -commit e5b93a847ae4e20a77fecef0938da4f14dfbe3eb -Author: Hib Eris <hib@hiberis.nl> -Date: Sun Dec 28 22:59:14 2008 +0100 - - Let compiler figure out CDECL - - CDECL is a compiler specific macro to specify C calling convention. - - On Windows, some functions must be forced to use this calling - convention. - To do this, you can use the macro CDECL, which is defined in windef.h. - - Poppler should not try to be smarter than the compiler and try - to guess - the correct definition for CDECL. Instead it should rely on the - definitions in the windef.h file provided by the compiler. - - On Unix, specifying a calling convention is not nescessary, so - CDECL can - be an empty definition. - - poppler-config.h.cmake | 8 ++------ - poppler/poppler-config.h.in | 8 ++------ - 2 files changed, 4 insertions(+), 12 deletions(-) - -commit de70c0aeb37d788f595b0574796844f51ddedec1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Dec 28 21:21:12 2008 +0100 - - [qt4] improve doc a bit - - qt4/src/poppler-form.h | 2 +- - qt4/src/poppler-qt4.h | 4 ++-- - 2 files changed, 3 insertions(+), 3 deletions(-) - -commit effb32658019e09dc86c017e39154fd554fc94f8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Dec 28 02:56:30 2008 +0100 - - Form Rects are against the cropbox, not the media box - - Fixes second pdf at kde bug 161327 - - qt4/src/poppler-form.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 0f10561f3b1c90acc030d973399316bfca5f495e -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Dec 28 01:44:25 2008 +0100 - - Fix my last commit, copy&paste is really evil - - goo/GooString.cc | 9 +++++---- - goo/GooString.h | 2 +- - 2 files changed, 6 insertions(+), 5 deletions(-) - -commit 217b46484ff56bfd5906b293ebee70b82cc0263d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Dec 28 01:29:41 2008 +0100 - - Move PSOutputDev::filterPSName to GooString::sanitizedName so i can - use it from PDFDoc::writeObject - - goo/GooString.cc | 36 ++++++++++++++++++++++++++++++++++++ - goo/GooString.h | 7 +++++++ - poppler/PDFDoc.cc | 7 ++++++- - poppler/PSOutputDev.cc | 49 - +++++++++---------------------------------------- - poppler/PSOutputDev.h | 3 +-- - 5 files changed, 59 insertions(+), 43 deletions(-) - -commit f41fa9ee71aef5539cf9976c79b32bf1713c8167 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Dec 26 22:56:12 2008 +0100 - - Change the overflow check to the same used in gmem.cc, much more - easy to understand - - poppler/XRef.cc | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - -commit b8ae7d91dedc9a75200b6050628ec2740af84b98 -Author: Hib Eris <hib@hiberis.nl> -Date: Fri Dec 26 22:28:09 2008 +0100 - - Fix compile warnings on auto imports for mingw32 - - configure.ac | 3 +++ - glib/Makefile.am | 2 +- - glib/demo/Makefile.am | 2 ++ - test/Makefile.am | 2 ++ - utils/Makefile.am | 2 ++ - 5 files changed, 10 insertions(+), 1 deletion(-) - -commit ba47bd2ba05f883306606eda30bff17bd4a8eec6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Dec 26 19:47:42 2008 +0100 - - BaseFile.h has never been used and it fact it's not part of xpdf - sources - - Fixes bug 19298 - - CMakeLists.txt | 1 - - poppler/BaseFile.h | 82 - ----------------------------------------------------- - poppler/Makefile.am | 1 - - 3 files changed, 84 deletions(-) - -commit 84366d9e63b0d6a5ee1aae2463648cfc2ff5e1b8 -Author: Hib Eris <hib@hiberis.nl> -Date: Wed Dec 24 19:27:19 2008 +0100 - - Let libtool build DLLs on windows too - - configure.ac | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit 08cef528f2e51cc62cff4125f179021ad9555317 -Author: Hib Eris <hib@hiberis.nl> -Date: Wed Dec 24 17:48:46 2008 +0100 - - Fix compile warning on string literal format - - test/pdf-inspector.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 0606b4bba8e889204c7b7c9d376f63b659f83a4f -Author: Hib Eris <hib@hiberis.nl> -Date: Wed Dec 24 17:48:10 2008 +0100 - - Fix compile warnings on parentheses and/or - - poppler/CairoOutputDev.cc | 13 +++++++------ - 1 file changed, 7 insertions(+), 6 deletions(-) - -commit eba2232cabd5fb1e177db2a6053f0d1a0aee882b -Author: Hib Eris <hib@hiberis.nl> -Date: Wed Dec 24 17:46:32 2008 +0100 - - Fix some more warnings - - test/gtk-cairo-test.cc | 11 ----------- - test/pdf-inspector.cc | 9 +++++---- - 2 files changed, 5 insertions(+), 15 deletions(-) - -commit c80431eb1626d89e7b615e5a5149d3436b554b66 -Author: Hib Eris <hib@hiberis.nl> -Date: Mon Dec 22 09:28:47 2008 +0100 - - Fix compile warning on format type - - glib/test-poppler-glib.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit fda181c35b7c7500b6d3c6ca9d454addd54929c5 -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 22 00:53:44 2008 +0100 - - group condition within brackets - - poppler/ArthurOutputDev.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit c1beeecbd6cbf82811d70c75cb24059b4b492abe -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 22 00:46:49 2008 +0100 - - [demo] use the proper format field for gsize types - - glib/demo/attachments.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit bfb975466f0ff78e9e292b6af7cac66e4c331456 -Merge: 3e27892 ea3546f -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 22 00:29:38 2008 +0100 - - Merge branch 'master' of - ssh://pino@git.freedesktop.org/git/poppler/poppler - -commit 3e2789257f5fc4ae0573a0c62ea380d8e83a5bb5 -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 22 00:24:23 2008 +0100 - - [Qt] deserialize also the value of 'right' - - qt/poppler-link.cc | 11 ++++++----- - 1 file changed, 6 insertions(+), 5 deletions(-) - -commit 7c053ab7623cea1ac650d3e960d2d91a1ef21557 -Author: Pino Toscano <pino@kde.org> -Date: Mon Dec 22 00:19:02 2008 +0100 - - [Qt] move in a .cc file the implementation of the QString<->GooString - functions and DocumentData::addTocChildren() - - qt/CMakeLists.txt | 1 + - qt/Makefile.am | 1 + - qt/poppler-document.cc | 10 ---- - qt/poppler-page.cc | 1 + - qt/poppler-private.cc | 147 - +++++++++++++++++++++++++++++++++++++++++++++++++ - qt/poppler-private.h | 106 +++-------------------------------- - 6 files changed, 157 insertions(+), 109 deletions(-) - -commit ea3546f84c5335c58cdb2906b1a1a4656be9c8ea -Author: Hib Eris <hib@hiberis.nl> -Date: Sun Dec 21 23:33:49 2008 +0100 - - Fix compile warnings on signed/unsigned comparison - - goo/gfile.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit ca672ae51d2c1fa59a891717b418ba86b5e7345c -Author: Hib Eris <hib@hiberis.nl> -Date: Sun Dec 21 23:33:00 2008 +0100 - - Fix compile warnings on ignored pragma with mingw compiler - - poppler/Gfx.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 86cfe8ab2b4e0b600f3f6682701c2fcfbe5d0ca9 -Author: Hib Eris <hib@hiberis.nl> -Date: Sun Dec 21 23:08:56 2008 +0100 - - Fix compile warnings on signed/unsigned comparison - - poppler/GfxFont.cc | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit e34af7ffe0a4024e2eb39314bdb09eb9a662e53e -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Dec 21 22:16:39 2008 +0100 - - Update copyright of last commits - - poppler/TextOutputDev.cc | 1 + - poppler/TextOutputDev.h | 2 +- - qt4/src/poppler-page.cc | 1 + - 3 files changed, 3 insertions(+), 1 deletion(-) - -commit f6d84dcfc9cc587c7408af79b1ee7658d456f8d8 -Author: Hib Eris <hib@hiberis.nl> -Date: Sun Dec 21 22:09:00 2008 +0100 - - Fix compile warning to suggest parentheses and/or - - poppler/TextOutputDev.cc | 14 ++++++++------ - 1 file changed, 8 insertions(+), 6 deletions(-) - -commit 15205403eaa95d6fba0e36983de993877dd3a983 -Author: Hib Eris <hib@hiberis.nl> -Date: Sun Dec 21 21:59:45 2008 +0100 - - Fix warning to suggest parentheses inside shift - - poppler/PSOutputDev.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit cc24f37e582bfc0069faf286da97a48fe4794db1 -Author: Hib Eris <hib@hiberis.nl> -Date: Sun Dec 21 21:35:29 2008 +0100 - - Fix compile warning on ambiguous else - - test/perf-test.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit a8cc4ad8c2da804f25db8cca1c85433d5a63307c -Author: Hib Eris <hib@hiberis.nl> -Date: Sun Dec 21 21:34:28 2008 +0100 - - Fix compile warning on format not a string literal - - test/perf-test.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 3cbbf8226730aa7ee6273e154e4a9d58670a3cda -Author: Hib Eris <hib@hiberis.nl> -Date: Sun Dec 21 21:30:54 2008 +0100 - - Fix compile warning about uninitialized variable - - poppler/ABWOutputDev.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit f675916277cb76cd1293225a1271f835a02148fb -Author: Pino Toscano <pino@kde.org> -Date: Sat Dec 20 23:23:10 2008 +0100 - - reset to NULL after being deleted - - found with poppler-qt4 unit tests =) - - poppler/TextOutputDev.cc | 1 + - 1 file changed, 1 insertion(+) - -commit c976770c64e4c991fff27e413414473583b6fd86 -Author: Pino Toscano <pino@kde.org> -Date: Sat Dec 20 22:25:55 2008 +0100 - - [Qt4] use QHash instead of QMap where applicable - - using a hash table instead of a map mapes lookup faster; - in these cases we don't need the sorting a map gives - - qt4/src/poppler-page.cc | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -commit 944f6049a50eb3be9fb29174d67adc4ad1d0b9fe -Author: Pino Toscano <pino@kde.org> -Date: Sat Dec 20 20:13:43 2008 +0100 - - add find.c and text.c - - glib/demo/CMakeLists.txt | 2 ++ - 1 file changed, 2 insertions(+) - -commit ba91b889c3b50239e339938f3c9d31fffcd87d44 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Dec 20 19:29:40 2008 +0100 - - Make destructor private in TextPage - - poppler/TextOutputDev.h | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit 0da16537aa83f6ed6d8895c7e54266263a71c1cf -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Dec 19 19:08:21 2008 +0100 - - Refactor actual text code adding a new ActualText class - - It's used by both Text and Cairo ouput devices avoiding duplicated - code - in such classes. - - poppler/CairoOutputDev.cc | 108 +++--------------------- - poppler/CairoOutputDev.h | 7 +- - poppler/TextOutputDev.cc | 206 - ++++++++++++++++++++++++++-------------------- - poppler/TextOutputDev.h | 34 ++++++-- - 4 files changed, 160 insertions(+), 195 deletions(-) - -commit 0f8ab301c633133eea3dbd4f2254f31c50e3c4a9 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Dec 14 13:12:34 2008 +0100 - - [glib-demo] Add find demo - - glib/demo/Makefile.am | 2 + - glib/demo/find.c | 282 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - glib/demo/find.h | 31 ++++++ - glib/demo/main.c | 4 +- - 4 files changed, 318 insertions(+), 1 deletion(-) - -commit 88df9e9aa9adb53f0a9714ea404d46f111495df3 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Dec 14 11:54:35 2008 +0100 - - [glib-demo] Add Text demo - - glib/demo/Makefile.am | 2 + - glib/demo/main.c | 4 +- - glib/demo/text.c | 175 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - glib/demo/text.h | 31 +++++++++ - 4 files changed, 211 insertions(+), 1 deletion(-) - -commit 5b0f2355d55a5104820fd0bf16b4e76b25959de4 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Dec 14 11:49:00 2008 +0100 - - [glib] Use TextPage instead of TextOutputDev when cairo is enabled - - glib/poppler-page.cc | 148 - ++++++++++++++++++++++++++++++++++--------------- - glib/poppler-private.h | 4 ++ - 2 files changed, 107 insertions(+), 45 deletions(-) - -commit 3ced71fb68d62308db7b9535367eafefb55d1cde -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Dec 14 11:18:00 2008 +0100 - - Add optionally text support to CairoOutputDev - - If a TextPage is set, it'll be used when rendering so that we - don't need - to use TextOutputDev and render again. - - poppler/CairoOutputDev.cc | 144 - ++++++++++++++++++++++++++++++++++++++++++++-- - poppler/CairoOutputDev.h | 19 +++++- - 2 files changed, 155 insertions(+), 8 deletions(-) - -commit 0bdad35cc4cfdb8da5acaf44678920b7a0025f99 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Dec 14 11:14:12 2008 +0100 - - Add refcount support to TextPage - - poppler/TextOutputDev.cc | 12 +++++++++++- - poppler/TextOutputDev.h | 5 +++++ - qt4/src/poppler-page.cc | 2 +- - 3 files changed, 17 insertions(+), 2 deletions(-) - -commit f86514c3fbc867fc6457feacba23451e89993524 -Author: Koji Otani <sho@bbr.jp> -Date: Wed Dec 17 00:36:39 2008 +0100 - - Fix wrong PS generation when a large image is in Patterns - - Bug 18908 - - poppler/PSOutputDev.cc | 114 - +++++++++++++++++++++++++++++++------------------ - 1 file changed, 72 insertions(+), 42 deletions(-) - -commit fc395eb90b418e43453acefb42cd04baf0b7ad40 -Author: Richard Airlie <richard.airlie@maglabs.net> -Date: Tue Dec 16 21:11:53 2008 +0100 - - Allow the use of cropbox in pdftoppm - - utils/pdftoppm.cc | 16 +++++++++++++--- - 1 file changed, 13 insertions(+), 3 deletions(-) - -commit 80f415176952635a485356cf36048eee53396c25 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Dec 16 20:37:39 2008 +0100 - - Make destructors private/protected since you are not supposed to - use them - - poppler/GfxFont.cc | 2 +- - poppler/GfxFont.h | 11 +++++------ - 2 files changed, 6 insertions(+), 7 deletions(-) - -commit dbcebda953cb36a45a125aada68e85249fb73f43 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Dec 15 20:10:31 2008 +0100 - - Do not leak on AnnotScreen destructor - - Fixes bug 19095 - - poppler/Annot.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit aaeb0d137232bf1cb11dc5e37b8b45b50c6f9c6a -Author: Pino Toscano <pino@kde.org> -Date: Fri Dec 12 00:43:19 2008 +0100 - - update the xpdf headers installation - - CMakeLists.txt | 32 +++++++++++++++++++++----------- - 1 file changed, 21 insertions(+), 11 deletions(-) - -commit 7c6527fa05389f705872aaaaff12e739b5d1577e -Author: Pino Toscano <pino@kde.org> -Date: Fri Dec 12 00:41:21 2008 +0100 - - don't install Function.cc, as it is not an header - - poppler/Makefile.am | 1 - - 1 file changed, 1 deletion(-) - -commit 0179e21b128ffccb5afd13203137ab8435197609 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Dec 12 00:16:38 2008 +0100 - - Be more helpful with bad boys that want to use poppler core directly - - fofi/Makefile.am | 10 ++++++++++ - splash/SplashClip.h | 2 +- - splash/SplashPath.h | 2 +- - splash/SplashXPath.h | 2 +- - 4 files changed, 13 insertions(+), 3 deletions(-) - -commit 401632e4eeb4b10b1183a820f32461da77e8e4f2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Dec 12 00:14:04 2008 +0100 - - Try harder to look for openjpeg - - cmake/modules/FindLIBOPENJPEG.cmake | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ab539f46089702f60b96b1ba2b2bc1544173c264 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Dec 11 23:15:45 2008 +0100 - - Fix crash when reading outline - - Fixes bug 19024. Last as reference is required if the item has - children (Table 8.4) so if there is no last reference, don't try to - read children. - - poppler/Outline.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit c9a755f9fd14511f43a2ca7fcda36bdd64bb1d87 -Author: Ilya Gorenbein <igorenbein@finjan.com> -Date: Sun Dec 7 17:59:19 2008 +0100 - - Fix memory leak - - Bug 18924 - - poppler/Page.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 4cd364c179ae91ed383a8237ba1ad263952fd7aa -Author: Pino Toscano <pino@kde.org> -Date: Sun Nov 30 16:57:52 2008 +0100 - - add my copyright here - - qt4/src/poppler-private.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 6b1676deb773675d90469adc84c3de8dcdaf174c -Author: Pino Toscano <pino@kde.org> -Date: Sun Nov 30 16:56:43 2008 +0100 - - [Qt4] support URI actions for TOC items - - qt4/src/poppler-private.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit b5cd58b5565055fd0c13771461245ddcd80edfcf -Author: Pino Toscano <pino@kde.org> -Date: Sun Nov 30 16:34:57 2008 +0100 - - extract the LinkAction "serialization" in an own function, and make - it more safe - - qt4/src/poppler-private.cc | 85 - ++++++++++++++++++++++++++++++++-------------- - 1 file changed, 59 insertions(+), 26 deletions(-) - -commit ee191363e22940ae7b06945e68c4738b17c78348 -Author: Pino Toscano <pino@kde.org> -Date: Sun Nov 30 16:17:32 2008 +0100 - - move the addTocChildren() implementation in the cpp - - qt4/src/poppler-form.cc | 1 + - qt4/src/poppler-page.cc | 1 + - qt4/src/poppler-private.cc | 65 - ++++++++++++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-private.h | 64 - ++------------------------------------------- - 4 files changed, 69 insertions(+), 62 deletions(-) - -commit f8eaabf1aa7e384619129a7509be85d0c3bfb825 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Nov 30 13:33:12 2008 +0100 - - Update copyrights of the last commits - - poppler/TextOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 5f4fedfae6098e25644ffe5d4b1ed0bac043841d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Nov 29 19:51:27 2008 +0100 - - Use the Length specified in the Stream as initial bufSize - - This is a optimization to save a few reallocations, if the Length - value is incorrect it will still work - - poppler/JPEG2000Stream.cc | 10 ++++++++-- - 1 file changed, 8 insertions(+), 2 deletions(-) - -commit 12f6d6ba2052fbdc8ea4ba7c7c9277e75bf170a5 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Nov 23 18:20:14 2008 +0100 - - Fix a crash when the second argument of opMarkPoint is not a - dictionary - - According to the spec "If any of the values are indirect references to - objects outside the content stream, the property list dictionary must - instead be defined as a named resource. - - poppler/Gfx.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 817e123a28e9f6b7e5be23f7ac2ba3bcec5e3f3f -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Sat Nov 22 21:48:37 2008 +1030 - - Don't compare print flag for non Type 3 fonts in cairo font cache - - poppler/CairoFontEngine.cc | 7 ++++++- - poppler/CairoFontEngine.h | 4 +++- - 2 files changed, 9 insertions(+), 2 deletions(-) - -commit 68f8ade28764855d4f663607c50c8202b1268296 -Author: Albert Astals Cid <tsdgeos@samsung.localdomain> -Date: Sun Nov 23 10:54:46 2008 +0100 - - Compile with -pedantic - - Thanks to Bernard Leak for notifying - - test/pdf-inspector.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 4a4fa7ed44a87e47a6078a1f7bb6f41071672ea7 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Nov 18 20:11:07 2008 +0100 - - Fix a crash when selecting text in word mode - - poppler/TextOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit a6f5032ab0d6edbf3879f39efff7916b1f7233da -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Nov 16 18:24:06 2008 +0100 - - optContentConfig is not actually stored in PDFDoc but in Catalog - - poppler/PDFDoc.h | 1 - - 1 file changed, 1 deletion(-) - -commit b843ac34c6c4ca1580f99fa2220c59dfcd91f026 -Author: Pino Toscano <pino@kde.org> -Date: Sat Nov 15 14:49:02 2008 +0100 - - [Qt4] deserialize the value of the 'right' coordinate, too - - qt4/src/poppler-link.cc | 11 ++++++----- - 1 file changed, 6 insertions(+), 5 deletions(-) - -commit 03061fdae49842556c9ff48e61914fc88502e1d8 -Author: Tim Mooney <enchanter@users.sourceforge.net> -Date: Thu Nov 13 22:32:22 2008 +0100 - - Fix build on Solaris 10 + Sun Studio 12. - - Fixes bug 17496 - - configure.ac | 14 ++++++++++++++ - test/Makefile.am | 6 ++++-- - 2 files changed, 18 insertions(+), 2 deletions(-) - -commit 17b18be4fd25f2ca2b4ed7382d9fda50410c44f1 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Wed Nov 12 20:40:57 2008 +1030 - - Ensure cairo font matrix is invertable - - Fixes bugs #18254 and #18429 - - poppler/CairoOutputDev.cc | 15 ++++++++++++++- - 1 file changed, 14 insertions(+), 1 deletion(-) - -commit e2257e6916cd1067d43db9ed45f944413c61ed64 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Nov 9 22:44:48 2008 +0100 - - Update copyrights of the last commits - - poppler/CairoFontEngine.cc | 1 + - poppler/CairoFontEngine.h | 1 + - poppler/Form.cc | 2 +- - poppler/Gfx.h | 1 + - poppler/OptionalContent.h | 1 + - qt4/src/poppler-optcontent.cc | 1 + - 6 files changed, 6 insertions(+), 1 deletion(-) - -commit 069f8ad9453e612e907b561aa50983c34400193d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Nov 9 20:36:06 2008 +0100 - - MakeItBuild - - glib/CMakeLists.txt | 1 + - glib/demo/CMakeLists.txt | 1 + - 2 files changed, 2 insertions(+) - -commit 04025c4f65bbb7e4330f6d17d917a035c0906f3d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Nov 9 17:03:20 2008 +0100 - - Fix a crash when initializing an Annot with a null catalog - - Forms crate a temp annot just to get the font size of the form field - passing a NULL catalog. - - poppler/Annot.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 471255c5a3850984997d91c7850759eb0c7e8a9c -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Nov 8 20:58:57 2008 +0100 - - [glib-demo] Add Optional Content demo - - glib/demo/Makefile.am | 2 + - glib/demo/layers.c | 511 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - glib/demo/layers.h | 31 +++ - glib/demo/main.c | 4 +- - 4 files changed, 547 insertions(+), 1 deletion(-) - -commit 7363c25e1d83332932d9b4fe16d7fb4e364da628 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Oct 26 19:47:35 2008 +0100 - - [glib] Add Optional Content support - - glib/Makefile.am | 2 + - glib/poppler-document.cc | 377 - ++++++++++++++++++++++++++++++++++++++++++++++ - glib/poppler-document.h | 12 ++ - glib/poppler-layer.cc | 201 ++++++++++++++++++++++++ - glib/poppler-layer.h | 43 ++++++ - glib/poppler-private.h | 21 +++ - glib/poppler.h | 3 + - glib/test-poppler-glib.cc | 52 ++++++- - 8 files changed, 710 insertions(+), 1 deletion(-) - -commit c674566f458b54097f21aae0d4bf8637146565c5 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Oct 26 19:42:53 2008 +0100 - - Fix memory leaks in OptionalContent - - poppler/OptionalContent.cc | 13 +++---------- - poppler/OptionalContent.h | 10 ++++++---- - 2 files changed, 9 insertions(+), 14 deletions(-) - -commit 06ca313b8ecb8abb8dec3b418d118525b7bb0fdf -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Oct 26 19:11:45 2008 +0100 - - Check annotation optional content properties before drawing it - - poppler/Annot.cc | 20 ++++++++++++-------- - poppler/Annot.h | 4 ++-- - 2 files changed, 14 insertions(+), 10 deletions(-) - -commit a6d58927b048aa043cb6b6ed3ee9aeb213578924 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Nov 8 20:50:40 2008 +0100 - - Do not show hidden optional content - - Before any draw operation we first check whether we are inside an - optional marked content element that is currently hidden. - - poppler/Gfx.cc | 113 - ++++++++++++++++++++++++++++++++++++++++----------------- - poppler/Gfx.h | 7 +++- - 2 files changed, 84 insertions(+), 36 deletions(-) - -commit 5f168f991477e291290350a28f4a60a565e187b9 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Oct 20 17:56:11 2008 +0200 - - [glib] Show action titles when printing the index in test program - - glib/test-poppler-glib.cc | 13 ++++++++----- - 1 file changed, 8 insertions(+), 5 deletions(-) - -commit a906d12e16748d9a40c0db4043a576fd3d004341 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Nov 8 20:20:00 2008 +0100 - - Minor code cleanup and consistency issues - - poppler/OptionalContent.cc | 22 +++++++++++----------- - poppler/OptionalContent.h | 8 ++++---- - qt4/src/poppler-optcontent.cc | 6 +++--- - qt4/tests/check_optcontent.cpp | 8 ++++---- - 4 files changed, 22 insertions(+), 22 deletions(-) - -commit e73c2ce906b7e1f06d641f7e0733aad6336b4091 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Oct 19 12:44:13 2008 +0200 - - Delete the optContent object if it's invalid - - poppler/Catalog.cc | 4 ++++ - poppler/OptionalContent.cc | 3 +++ - poppler/OptionalContent.h | 5 +++++ - 3 files changed, 12 insertions(+) - -commit 2900e7e4c920d735d5a727e9e39f71df97bd7b93 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Nov 8 18:12:47 2008 +0100 - - A new cairo is needed - - CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit aaaecd2e86769d3a99e21577448a193711985958 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 5 22:47:30 2008 +0100 - - Do not abort if indexHighA is 'invalid', move it to the closest - valid value and try with it - - For the bug 18374 it works and does not seem a security problem - - poppler/GfxState.cc | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -commit 82f4228a50efe6447c68f7f6d34a7805b7e4b75e -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 5 20:57:17 2008 +0100 - - Add myself here - - qt4/demos/viewer.cpp | 1 + - 1 file changed, 1 insertion(+) - -commit 8df7d83439f0e9ab200840f912f1c08bbf44bd6e -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 5 20:49:01 2008 +0100 - - [Qt4Demo] Fix leak - - qt4/demos/viewer.cpp | 1 + - 1 file changed, 1 insertion(+) - -commit d3c424e0362f53bda5c4e2e415823d78ace76253 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 5 20:14:17 2008 +0100 - - Rename i to j so that code is more clear by not shadowing the - function parameter - - poppler/Catalog.cc | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit 9d12de9b59de4336eabb423f7bf0363b6a35e2a8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 5 20:00:01 2008 +0100 - - Fix crash in case indices is NULL - - Putting more than one "logical line" per "real line" is evil, we - think if will group it, but does not - - poppler/UnicodeTypeTable.cc | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -commit fc61dad9daa15f83802ffa5c3cd9b59d80bb310b -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 5 19:52:00 2008 +0100 - - [Qt] Fix leak - - qt/poppler-link.cc | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -commit 981fb857b0afb1cda7836744dcf37906285512b4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 5 19:49:18 2008 +0100 - - [Qt] Fix memory leak - - qt/poppler-document.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit e925e92d5cbfc009c138ece117227a3b0894ead6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 5 19:44:40 2008 +0100 - - Do not leak uBuf in the error case - - poppler/CharCodeToUnicode.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 0741a402632ec5a8641ff11707142bf2731c1833 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Sat Nov 1 22:27:48 2008 +1030 - - Restore the cairo Type3 font image prescaling funtionality - - poppler/CairoFontEngine.cc | 49 - +++++++++++++++++++++++++++------------------- - poppler/CairoFontEngine.h | 20 +++++++++++-------- - poppler/CairoOutputDev.cc | 2 +- - poppler/CairoOutputDev.h | 2 +- - 4 files changed, 43 insertions(+), 30 deletions(-) - -commit 91a7c3fdd44f30b0b50ed05a3313bbb1b5c86e71 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Sat Nov 1 20:57:24 2008 +1030 - - Remove cairo font matrix y flip when inside a Type 3 char - - Not sure why this was previously required but it now produces - incorrect results. - - poppler/CairoOutputDev.cc | 5 ----- - 1 file changed, 5 deletions(-) - -commit 3bf4d7d75b455a9a0b5ee3a8c78b218e5af5185a -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Sat Nov 1 20:50:07 2008 +1030 - - Transform the glyph advance by the font matrix - - poppler/CairoFontEngine.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 4aa32bad61d008a854fdc9e902d6834bb1687d7e -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Sat Nov 1 20:49:04 2008 +1030 - - Use the font BBox, not the font matrix to set the Gfx BBox - - poppler/CairoFontEngine.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 987955440c7711f440c3d2b5cc8c05ec07228a77 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Sat Nov 1 20:47:05 2008 +1030 - - Ensure both the font matrix and y-axis flip are in the matrix - - we use for transforming the glyph metrics. - - poppler/CairoFontEngine.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 5c051aa117477cba5d350adfc539acb4b5f2a56a -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Sat Nov 1 01:59:07 2008 +1030 - - Require cairo 1.8.2 for user-font support - - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit a3edfa30680864b95a5196c5619846de42980857 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Sat Nov 1 01:57:32 2008 +1030 - - Implement Type 3 fonts in cairo backend using cairo user-fonts - - poppler/CairoFontEngine.cc | 174 - +++++++++++++++++++++++++++++++++++++++++++-- - poppler/CairoFontEngine.h | 18 +++++ - poppler/CairoOutputDev.cc | 9 ++- - poppler/CairoOutputDev.h | 4 +- - 4 files changed, 194 insertions(+), 11 deletions(-) - -commit feab1e982a2ee39bb372d593633a06b6a499822f -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Sat Nov 1 01:21:39 2008 +1030 - - Add CairoOutputDev functions for getting Type 3 glyph metrics - - poppler/CairoOutputDev.cc | 10 ++++++++++ - poppler/CairoOutputDev.h | 7 +++++++ - 2 files changed, 17 insertions(+) - -commit a75efe208d899d4a23d5e2fcef200e4225721636 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Sat Nov 1 00:26:40 2008 +1030 - - Make the catalog available to CairoFontEngine - - glib/poppler-document.cc | 3 ++- - poppler/CairoFontEngine.cc | 2 +- - poppler/CairoFontEngine.h | 3 ++- - poppler/CairoOutputDev.cc | 7 +++++-- - poppler/CairoOutputDev.h | 3 ++- - test/pdf-inspector.cc | 2 +- - 6 files changed, 13 insertions(+), 7 deletions(-) - -commit 941d3976c496b75a3c5a9d19b80044fc2b57bd98 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Fri Oct 31 22:44:41 2008 +1030 - - Allow multiple instances of CairoOutputDev to be created - - for the same document that shares the same CairoFontEngine. - - poppler/CairoOutputDev.cc | 16 +++++++++++----- - poppler/CairoOutputDev.h | 4 +++- - 2 files changed, 14 insertions(+), 6 deletions(-) - -commit 94cff513d8589f51b243fcb078f82cb931bb6d35 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Fri Oct 31 21:11:01 2008 +1030 - - Use correct return type in _ft_new_face - - poppler/CairoFontEngine.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 0b5ee897a24ce1edfca19a3b843f9b7ee7026d07 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Fri Oct 31 20:55:14 2008 +1030 - - Refactor CairoFont - - Create a CairoFreeType subclass and move the FreeType specific code - into it. - - poppler/CairoFontEngine.cc | 197 - +++++++++++++++++++++++++-------------------- - poppler/CairoFontEngine.h | 26 ++++-- - 2 files changed, 131 insertions(+), 92 deletions(-) - -commit a5865dae5b414de5f6dbda2a512101050c374e06 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Oct 28 10:30:59 2008 +0100 - - [glib] Add DISABLE_SINGLE_INCLUDES flags and fix glib-demo - - configure.ac | 4 ++++ - glib/Makefile.am | 3 ++- - glib/demo/Makefile.am | 3 ++- - glib/demo/annots.h | 2 +- - glib/demo/attachments.h | 2 +- - glib/demo/fonts.h | 2 +- - glib/demo/forms.h | 2 +- - glib/demo/images.h | 2 +- - glib/demo/info.h | 2 +- - glib/demo/links.h | 2 +- - glib/demo/outline.h | 2 +- - glib/demo/page.h | 2 +- - glib/demo/render.h | 2 +- - glib/demo/transitions.h | 2 +- - glib/demo/utils.h | 2 +- - 15 files changed, 20 insertions(+), 14 deletions(-) - -commit e07bfb54b77430e10e50c33151cf0afc9854006c -Author: Christian Persch <chpe@gnome.org> -Date: Tue Oct 28 10:29:51 2008 +0100 - - [glib] Fix build when compiling with GTK_DISABLE_SINGLE_INCLUDES - - glib/poppler-page.h | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit a84d272ffd2b593ac98148e71b83fba299c60fea -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Oct 28 10:01:00 2008 +0100 - - [glib] Add disable deprecated compile flags and fix compile warnings - - configure.ac | 6 ++++++ - glib/Makefile.am | 3 ++- - glib/demo/Makefile.am | 4 +++- - glib/demo/attachments.c | 4 ++-- - 4 files changed, 13 insertions(+), 4 deletions(-) - -commit 43f2b84a81625abee84c93cdced7fb92c99cd944 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Oct 21 23:00:55 2008 +0200 - - [Qt4] Small docu improvement - - qt4/src/poppler-qt4.h | 3 +++ - 1 file changed, 3 insertions(+) - -commit 00f9995b4960575cd1f392474c585f2140c8e587 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Oct 12 14:20:01 2008 +0200 - - Do not crash if there is not font - - See bug 18023 for more info - - poppler/TextOutputDev.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit 084cc4335cfe2c0e66219eba4c1177ee7ff018c5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Oct 10 23:15:35 2008 +0200 - - obj4 should be the index 1 on the Array, not the 0, that's already - obj3 - - poppler/Form.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit d7442c90206d4b7a8ebc58f995647eb87ac35f42 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Oct 9 22:53:00 2008 +0200 - - If Name is a Ref we want to get the String it references, not the Ref - - poppler/OptionalContent.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 93f8dd9e837557bbfc0f058a664c356e3d6e82c0 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Oct 9 21:28:27 2008 +0200 - - Poppler 0.10.0 - - CMakeLists.txt | 2 +- - NEWS | 16 ++++++++++++++++ - configure.ac | 2 +- - msvc/config.h | 6 +++--- - qt4/src/Doxyfile | 2 +- - 5 files changed, 22 insertions(+), 6 deletions(-) - -commit cdd9bf016de0d3f96b1d5e304c9d02f2bf71ff18 -Author: Mark Kaplan <mkaplan@finjan.com> -Date: Wed Oct 8 22:29:11 2008 +0200 - - Initialize properly OptionalContentGroup::m_name - - poppler/OptionalContent.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit c7b87f3b8cbbcca29a1974debc2233f621a2e33b -Author: Carlo Bramini <carlo.bramix@libero.it> -Date: Mon Oct 6 19:32:27 2008 +0200 - - Fix link on Mingw+Msys - - test/Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit e92255296511cae9cbbac8de800d8b26e5f681f1 -Author: Pino Toscano <pino@kde.org> -Date: Sun Oct 5 15:57:06 2008 +0200 - - [Qt4] when the PDF exporting fails, delete the file if it was - created by - the (failed) exporting - - qt4/src/poppler-pdf-converter.cc | 13 +++++++++++++ - 1 file changed, 13 insertions(+) - -commit 360f470b852e37d400949343763a18bf598820e8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 4 20:04:44 2008 +0200 - - Remove unused var - - poppler/Annot.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit df7317f1320513b4f66cb6618d753b82042671f5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 4 19:48:57 2008 +0200 - - free the object - - poppler/PDFDoc.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 9946d9af9dd5d5b96d5c777413a3e253dfd1f291 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 4 19:39:46 2008 +0200 - - If we try saving a document that was encrypted, we break everything, - so just fail early - - poppler/PDFDoc.cc | 7 +++++++ - 1 file changed, 7 insertions(+) - -commit 108959432af7714cb8ffe42d98d40c97f936a2e6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 4 19:39:24 2008 +0200 - - Correctly return wheter it was saved or not - - qt4/src/poppler-pdf-converter.cc | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -commit 4c6cb1c204d782e2ac2113b57f6d372b4716017d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 4 01:46:58 2008 +0200 - - Remove spurious // - - fofi/FoFiType1.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit e8e7809ab4b115cbe67251da12989fc024912514 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 4 01:43:02 2008 +0200 - - There are files that have more than one encoding definition per line, - make them work - - Fixes bug 17018, while at it, i've added some comments and some - error() to make things a bit clearer - - fofi/FoFiType1.cc | 28 ++++++++++++++++++++++++---- - 1 file changed, 24 insertions(+), 4 deletions(-) - -commit 7604e025038fee24c2cb3001f2100d5d1e48efe1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Oct 4 00:35:46 2008 +0200 - - Fix Poppler::Link::linkArea for rotated pages - - we suck :-( Fixes kde bug 172105 - - qt4/src/poppler-link-extractor.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 450b21e4528a8e890d3dda37ecb0a68602f8efaa -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Oct 1 00:46:29 2008 +0200 - - I've changed these files this year too, update copyright - - goo/gmem.cc | 2 +- - goo/gmem.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 98310ca24841789cf53b10d34e271ceb4e054001 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 30 23:59:43 2008 +0200 - - Fix StitchingFunction(StitchingFunction *func) and - GfxAxialShading(GfxAxialShading *shading) - - Fixes bug 17852 - - poppler/Function.cc | 2 ++ - poppler/GfxState.cc | 2 +- - 2 files changed, 3 insertions(+), 1 deletion(-) - -commit d12f5f4395eb18f8d29182e24acddd3e2b5cfe88 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 30 23:20:26 2008 +0200 - - 0.9.3 - - CMakeLists.txt | 2 +- - NEWS | 17 +++++++++++++++++ - configure.ac | 2 +- - msvc/config.h | 6 +++--- - qt4/src/Doxyfile | 2 +- - 5 files changed, 23 insertions(+), 6 deletions(-) - -commit d61e464754521555a06ed0901955f49be4def29a -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 30 19:26:17 2008 +0200 - - Timothy also agreed, now Ed Catmur is the last one missing to answer - - utils/ImageOutputDev.cc | 3 +++ - utils/ImageOutputDev.h | 3 +++ - 2 files changed, 6 insertions(+) - -commit 3225f54fea7cbb6b25d7223268cdeccfdd823375 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 30 00:27:49 2008 +0200 - - And Marco said yes to GPLv2+ - - Only Timothy Lee and Ed Catmur left :-) - - poppler/Catalog.cc | 3 +++ - poppler/Outline.cc | 3 +++ - poppler/Outline.h | 3 +++ - splash/Splash.cc | 3 +++ - splash/Splash.h | 3 +++ - 5 files changed, 15 insertions(+) - -commit 268d803c9dd67b7f78f8dcdc3c7653c8b2c2d08f -Author: Warren Toomey <wkt@tuhs.org> -Date: Mon Sep 29 21:14:40 2008 +0200 - - Let HmtlOutputDev process images - - utils/HtmlOutputDev.h | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit a29984ab777c64a1cb286b667a6a91ad9b191f40 -Merge: f399afe 6865872 -Author: Pino Toscano <pino@kde.org> -Date: Sun Sep 28 23:39:08 2008 +0200 - - Merge branch 'master' of - ssh://pino@git.freedesktop.org/git/poppler/poppler - -commit f399afe6f6b9c250327d0e4c5b3f2839889d7095 -Author: Pino Toscano <pino@kde.org> -Date: Sun Sep 28 23:38:34 2008 +0200 - - [Qt4] various apidox improvements - - qt4/src/Mainpage.dox | 10 +--- - qt4/src/poppler-link.h | 92 +++++++++++++++++++++++++++++++++---- - qt4/src/poppler-qt4.h | 121 - +++++++++++++++++++++++++++++++++---------------- - 3 files changed, 168 insertions(+), 55 deletions(-) - -commit 68658721583b05ebacb1165ac36e91d49735bbd9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Sep 28 19:29:06 2008 +0200 - - If tables is null, don't try to write to file as it'll crash, fixes - crash on 17811 when using cairooutputdev - - fofi/FoFiTrueType.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 3cb5b7fc5ae168ef58fd1905f61c1b9abe6cb86c -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Sep 28 19:25:53 2008 +0200 - - Introduce greallocn_checkoverflow and use it in FoFiTrueType::parse - - Fixes the other part of bug 17811 - - fofi/FoFiTrueType.cc | 4 ++-- - goo/gmem.cc | 21 +++++++++++++++++++++ - goo/gmem.h | 1 + - 3 files changed, 24 insertions(+), 2 deletions(-) - -commit aa7ef03af49f74ed558dcbab8ad4c594bb2b7d53 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Sep 28 19:24:43 2008 +0200 - - If libjpeg tells us to abort, let's abort :D - - Fixes part of bug 17811 - - poppler/DCTStream.cc | 1 + - 1 file changed, 1 insertion(+) - -commit e2461c9aa4d74b5511621d7222979948e31541ad -Author: Pino Toscano <pino@kde.org> -Date: Sun Sep 28 18:07:25 2008 +0200 - - [Qt4] Activate the 'printing' flag by default in the PSConverter. - - qt4/src/poppler-ps-converter.cc | 2 +- - qt4/src/poppler-qt4.h | 2 ++ - 2 files changed, 3 insertions(+), 1 deletion(-) - -commit 957d7acb66635e9748c6bc7a31cdbbcbb8da9011 -Author: Carlo Bramini <carlo.bramix@libero.it> -Date: Sat Sep 27 17:23:20 2008 +0200 - - Misc mingw fixes - - configure.ac | 2 +- - glib/Makefile.am | 2 +- - glib/demo/info.cc | 1 + - m4/libjpeg.m4 | 2 +- - 4 files changed, 4 insertions(+), 3 deletions(-) - -commit b3828203c4e594754957033ea826e8e22164fd5b -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Sep 26 23:08:14 2008 +0200 - - Carl agreed too, so CairoOutputDev.cc is done - - Only miss, Marco Pesenti Gritti, Timothy Lee and Ed Catmur - - poppler/CairoOutputDev.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit a197a07728d19abc2708979c95b4ef53e88fcb55 -Author: Carlo Bramini <carlo.bramix@libero.it> -Date: Fri Sep 26 18:42:05 2008 +0200 - - Compile where localtime_r is not available - - glib/demo/info.cc | 10 ++++++++-- - 1 file changed, 8 insertions(+), 2 deletions(-) - -commit 38884e1722ac7e15c62cece20035c5fb0020f4b3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 24 14:18:38 2008 +0200 - - Do what Jeff really want to do, mark the font as invalid if it matches - any of the known collections that Identity is not a good fallback - - Fixes pdf on KDE bug 171365 - - poppler/GfxFont.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 0e080aaf44816e5d5b9008f3c2fb54868932f0ac -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 24 13:12:13 2008 +0200 - - Remove non-needed X includes - - Spotted by Carlo Bramini - - test/gtk-cairo-test.cc | 3 --- - test/pdf-inspector.cc | 3 --- - 2 files changed, 6 deletions(-) - -commit 6888b023fdb199d3c5fb705bd928aedf68eeffdb -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 23 23:28:04 2008 +0200 - - Only do the scale to 'm' size trick on non embedded fonts as it was - meant to be - - Fixes bug 17744 - - poppler/SplashOutputDev.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit 539d29f4f3b24b98c9fc5f88d3477e427fbe409d -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 23 22:39:50 2008 +0200 - - 0.9.2 - - CMakeLists.txt | 2 +- - NEWS | 19 +++++++++++++++++++ - configure.ac | 2 +- - msvc/config.h | 6 +++--- - qt4/src/Doxyfile | 2 +- - 5 files changed, 25 insertions(+), 6 deletions(-) - -commit abd070a79d8345bda3853395a39e4e2882c4ff8a -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 22 20:23:11 2008 +0200 - - Check the types here too - - Benchmarking in release mode, both in "human feel" and callgrind - the benefit/lost is almost inexistant - - poppler/Object.h | 36 ++++++++++++++++++++++-------------- - 1 file changed, 22 insertions(+), 14 deletions(-) - -commit df47e4c441e4ec79b1bb40de7044c9501f243b76 -Author: Chris Wilson <chris@chris-wilson.co.uk> -Date: Tue Sep 16 12:56:04 2008 +0100 - - Check for duplicate open fonts. - - Before creating a new FT_Face for a font, check to see if there is a - duplicate amongst the list of open fonts, kept alive by either - Poppler's - or Cairo's font cache . - - A quick example of the benefit of this check is that it reduces the - RSS of - the Poppler converter in the Cairo test suite from over 900 MiB to - just 90 - MiB. - - configure.ac | 1 + - poppler/CairoFontEngine.cc | 214 - +++++++++++++++++++++++++++++++++++++++------ - 2 files changed, 190 insertions(+), 25 deletions(-) - -commit 41d1edddcf84ca23c0fc39c5f4f3a49e408a9f1a -Author: Kouhei Sutou <kou@cozmixng.org> -Date: Sun Sep 21 16:33:33 2008 +0200 - - [glib-demo] Fix a crash in forms demo - - glib/demo/forms.c | 12 +++++++----- - 1 file changed, 7 insertions(+), 5 deletions(-) - -commit fe26075353226be9a02c8cf1a6a29586de15ce86 -Author: Pino Toscano <pino@kde.org> -Date: Sun Sep 21 12:03:21 2008 +0200 - - really use the key passed to it - - poppler/Form.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 8aa531cb478d6ae838a94f9f31e6a0bbd0dd957c -Author: Pino Toscano <pino@kde.org> -Date: Sun Sep 21 11:18:22 2008 +0200 - - Read the 'readOnly' attribute directly in the FormField constructor. - - poppler/Form.cc | 12 +++--------- - 1 file changed, 3 insertions(+), 9 deletions(-) - -commit b56f64d676bdabd4a3ebe0eb2237f4c202a3707d -Author: Pino Toscano <pino@kde.org> -Date: Sun Sep 21 00:53:54 2008 +0200 - - Handle streams as entries for the catalog JS name tree. - - poppler/Catalog.cc | 18 +++++++++++++----- - 1 file changed, 13 insertions(+), 5 deletions(-) - -commit 93386d67b3d7adbd87547e9742e4df1c10eadbc1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Sep 20 16:20:03 2008 +0200 - - Compile with -pedantic - - poppler/Form.h | 4 ++-- - qt4/src/poppler-embeddedfile.cc | 4 ++-- - qt4/src/poppler-movie.cc | 3 ++- - qt4/src/poppler-sound.cc | 3 ++- - qt4/src/poppler-textbox.cc | 2 +- - 5 files changed, 9 insertions(+), 7 deletions(-) - -commit 6961fd8efe3db6ee7077dc2ed072498696dae31a -Author: Tomas Are Haavet <tomasare@gmail.com> -Date: Sat Sep 20 16:13:37 2008 +0200 - - Remove some warnings and errors when compiling with gcc and -pedantic - - fofi/FoFiTrueType.cc | 3 ++- - glib/poppler-annot.cc | 8 ++++---- - glib/poppler-attachment.cc | 2 +- - glib/poppler-document.cc | 6 +++--- - glib/poppler-form-field.cc | 2 +- - glib/poppler-page.cc | 2 +- - poppler/Annot.h | 5 +++-- - splash/SplashTypes.h | 3 ++- - 8 files changed, 17 insertions(+), 14 deletions(-) - -commit 4e9a04da358b1527a08102e601a52f07930532f2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Sep 20 16:10:50 2008 +0200 - - Add mention of GPLv2 or later in poppler changes to all files except - Splash.cc and Splash.h, i've still no answer from Marco :-( - - splash/SplashBitmap.cc | 3 +++ - splash/SplashBitmap.h | 3 +++ - splash/SplashErrorCodes.h | 3 +++ - splash/SplashFTFont.cc | 3 +++ - splash/SplashFTFont.h | 3 +++ - splash/SplashFTFontEngine.cc | 3 +++ - splash/SplashFTFontEngine.h | 3 +++ - splash/SplashFTFontFile.cc | 3 +++ - splash/SplashFTFontFile.h | 3 +++ - splash/SplashFont.cc | 3 +++ - splash/SplashFont.h | 3 +++ - splash/SplashFontEngine.cc | 3 +++ - splash/SplashFontEngine.h | 3 +++ - splash/SplashFontFile.cc | 3 +++ - splash/SplashFontFile.h | 3 +++ - splash/SplashT1Font.cc | 3 +++ - splash/SplashT1Font.h | 3 +++ - splash/SplashT1FontEngine.cc | 3 +++ - splash/SplashT1FontFile.cc | 3 +++ - splash/SplashT1FontFile.h | 3 +++ - splash/SplashTypes.h | 3 +++ - splash/SplashXPathScanner.cc | 3 +++ - 22 files changed, 66 insertions(+) - -commit beb87362072d5b480cf6b2c02445ec17c119ff56 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Sep 20 15:47:25 2008 +0200 - - Add Tomas' Copyright - - utils/HtmlFonts.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 8ccb1bb651b129875ef802356c4a229b2ce31973 -Author: Tomas Are Haavet <tomasare@gmail.com> -Date: Sat Sep 20 15:45:47 2008 +0200 - - Initialize pos the correct value to not have crashes - - utils/HtmlFonts.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 77bf8ec94e36fef7e120f1dc4bb1390be71cfb97 -Author: Tomas Are Haavet <tomasare@gmail.com> -Date: Sat Sep 20 14:17:06 2008 +0200 - - Fix memory leak - - utils/HtmlOutputDev.cc | 1 + - 1 file changed, 1 insertion(+) - -commit b22be54dc2205269974315ca748d835d0990d6da -Author: Tomas Are Haavet <tomasare@gmail.com> -Date: Sat Sep 20 14:16:26 2008 +0200 - - Fix mismatched free/delete - - utils/HtmlOutputDev.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit ac16174da1d6f19445f78e7cd7c4a18cb9524dde -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Sep 20 00:52:19 2008 +0200 - - make sure the image is setup before using it, otherwise some things - don't print correctly like PDF from bug 17645 - - poppler/PSOutputDev.cc | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit ffa4ffdf7fe83035c72addd8c4c8ee566621ba06 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 17 23:27:30 2008 +0200 - - 0.9.1 - - CMakeLists.txt | 2 +- - NEWS | 13 +++++++++++++ - configure.ac | 2 +- - msvc/config.h | 6 +++--- - qt4/src/Doxyfile | 2 +- - 5 files changed, 19 insertions(+), 6 deletions(-) - -commit f57cbe32bcde0808943b9be2456dd69fa5b6dd27 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Sep 14 22:18:38 2008 +0200 - - If when looking for an object we get objSomeNumberAfter assume it - was an int of SomeNumberAfter - - Fixes bug 17568 and i don't see how it can break existing things - because it's already on an error path - - poppler/XRef.cc | 25 +++++++++++++++++++++++++ - 1 file changed, 25 insertions(+) - -commit 1a852064ff5a1a15bc315ddca472a0ad74292581 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Sep 13 12:11:41 2008 +0200 - - [glib-demo] Do not try to get info about remote destinations - - glib/demo/utils.c | 11 ++++++----- - 1 file changed, 6 insertions(+), 5 deletions(-) - -commit 951cffeb2cbff4e179043033b5ac7f5eb764d6dc -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Sep 12 12:05:53 2008 +0200 - - Make sure DecryptAESState::bufIdx is never bigger than 16, otherwise - we crash - - I am not sure this is the correct fix, but fixes crash on files of - bugs 13972, 16092 and 17523 and they seem to work ok - - poppler/Decrypt.cc | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit 491109edbe827860e764b5fcb67456867923858d -Author: Haruyuki Kawabe <Haruyuki.Kawabe@unisys.co.jp> -Date: Wed Sep 10 23:00:32 2008 +0200 - - Generate the outline file at the same place the other files are - generated - - Fixes bug 17504 - - utils/HtmlOutputDev.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 7dfc1e4c9348d537896bda7b0f2ae591afc72866 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 10 00:03:50 2008 +0200 - - we want to distribute this file too - - qt4/src/Makefile.am | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit ddb73e8dc1ccbddf3b170e12c7153ccaf716d7cc -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 9 23:47:33 2008 +0200 - - We want to distribute cmake/modules/FindLIBOPENJPEG.cmake too - - Makefile.am | 1 + - 1 file changed, 1 insertion(+) - -commit 646ccc2bb8563d411dc25bdbab53725ae08572ba -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 9 23:22:17 2008 +0200 - - m_doc->doc->getOptContentConfig() can be null, so check for it - - qt4/src/poppler-document.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit d7f0bce67101f37f8d3e69d7d701388bcdc7200f -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 9 23:18:49 2008 +0200 - - Qt4 frontend had timezone parsing that got lost when moving to the - common function, i suck - - glib/poppler-document.cc | 6 ++++-- - poppler/DateInfo.cc | 20 ++++++++++++++------ - poppler/DateInfo.h | 2 +- - qt/poppler-document.cc | 6 ++++-- - qt4/src/poppler-document.cc | 22 +++++++++++++++++++--- - utils/pdfinfo.cc | 6 ++++-- - utils/pdftohtml.cc | 6 ++++-- - 7 files changed, 50 insertions(+), 18 deletions(-) - -commit 0af8609e6c932de2d85168cc9147854ee84b3a1b -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 9 20:55:27 2008 +0200 - - i want this packaged too - - utils/Makefile.am | 2 ++ - 1 file changed, 2 insertions(+) - -commit dd0f4c1510382e17cf33d3fe163e384da1d6d289 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 9 20:48:04 2008 +0200 - - Fix includepath - - fofi/FoFiTrueType.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 16c0842c3e01608a72709af55cc5cb8b567efedf -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 9 20:36:18 2008 +0200 - - API changed, so increase soname - - glib/CMakeLists.txt | 2 +- - glib/Makefile.am | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 217c0d1f80a78713977a7bfbe680fce90f1c6b36 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 8 23:56:28 2008 +0200 - - change version to 0.9.0 - - Now only need to wait for Carlos and Iñigo's answer to a BIC change - in glib/ and we'll have 0.9.0 :-) - - CMakeLists.txt | 2 +- - configure.ac | 2 +- - msvc/config.h | 6 +++--- - qt4/src/Doxyfile | 2 +- - 4 files changed, 6 insertions(+), 6 deletions(-) - -commit e34022a8fcfb9fe211dd6b561377d855972b2087 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 8 23:36:04 2008 +0200 - - Increase soname for libpoppler, i'm almost sure we broke BC there - - CMakeLists.txt | 2 +- - poppler/Makefile.am | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit bc275049d6ef083daf71a043ccf23fd0634f5c4d -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 8 23:33:24 2008 +0200 - - soname 3.1.0 for qt4 libs, we are BC/SC but got new API - - qt4/src/CMakeLists.txt | 2 +- - qt4/src/Makefile.am | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 06743a25a73adc3fba95f7b4ad74a6dde1a54ead -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 8 23:23:06 2008 +0200 - - added news for 0.9.0 - - NEWS | 115 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 115 insertions(+) - -commit d35ca2ce5df12d40e295873e44b1f18ea40ba897 -Author: Pino Toscano <pino@kde.org> -Date: Sun Sep 7 01:13:33 2008 +0200 - - [Qt4] apidox improvements - - qt4/src/poppler-annotation.h | 70 - +++++++++++++++++++++++++++++++++++++++++--- - qt4/src/poppler-link.h | 12 +++++--- - qt4/src/poppler-qt4.h | 22 ++++++++++++-- - 3 files changed, 93 insertions(+), 11 deletions(-) - -commit 796d4c002d47c85716775d173eddfb2ae8866eaf -Author: Pino Toscano <pino@kde.org> -Date: Sat Sep 6 22:48:13 2008 +0200 - - no more need for including the qt3 paths - - qt4/demos/CMakeLists.txt | 1 - - qt4/src/CMakeLists.txt | 1 - - qt4/tests/CMakeLists.txt | 1 - - 3 files changed, 3 deletions(-) - -commit db7ee3b3ae0f42155f9245691e4bfdef98a8ed6f -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Sep 6 23:16:05 2008 +0200 - - [Qt4] Fix docu - - qt4/src/poppler-qt4.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 3366059a25611f19ab592cda18c5efe0b9359771 -Author: Pino Toscano <pino@kde.org> -Date: Sat Sep 6 16:34:58 2008 +0200 - - [Qt4] add option flags for the PS converter - - - map the 'strictMargins' and 'forceRasterize' bool options as flags - - add a flag for setting the "printing" mode - - qt4/src/poppler-ps-converter.cc | 34 ++++++++++++++++++++++++++-------- - qt4/src/poppler-qt4.h | 26 ++++++++++++++++++++++++++ - 2 files changed, 52 insertions(+), 8 deletions(-) - -commit afa26d5c9ac9feb61aad30eb65dc00c9854d7f2e -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Sep 6 15:46:12 2008 +0200 - - we are printing so pass the print flag as true - - qt/poppler-document.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit f5d1eb5eaabaf3ab4bb87b8b4b901bbf30b20b29 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Sep 6 15:43:32 2008 +0200 - - We are pringint here, so pass the printing flag as true - - Fixes KDE bug 170459, you'd wonder how many times i've made the - same mistake... - - qt4/src/poppler-ps-converter.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 58e828d732f06bae9133dd518d89fa4348f1cca8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Sep 5 18:45:23 2008 +0200 - - Only like QtTest to the tests, not to the lib itself - - configure.ac | 13 +++++++++++-- - qt4/tests/Makefile.am | 22 +++++++++++----------- - 2 files changed, 22 insertions(+), 13 deletions(-) - -commit 49b3e4560f62a9a7db350d94d50e229f5e1208bf -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Sep 5 18:17:45 2008 +0200 - - Movie filename is not a string, but a File Specification - - Fixes a crash when filename is a dictionary - - poppler/Annot.cc | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -commit 996d2e176057e22acbc374cff7a712ce6fd92d93 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Sep 5 18:17:25 2008 +0200 - - Unify multiple File Specification parsers - - CMakeLists.txt | 2 + - poppler/FileSpec.cc | 146 - +++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/FileSpec.h | 24 ++++++++ - poppler/Link.cc | 104 +++++------------------------------ - poppler/Link.h | 4 -- - poppler/Makefile.am | 2 + - poppler/PSOutputDev.cc | 35 +----------- - poppler/PSOutputDev.h | 1 - - poppler/Sound.cc | 7 ++- - 9 files changed, 197 insertions(+), 128 deletions(-) - -commit 31f3eb2d6b43f7fbf4d978730d109b08b1563989 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 3 21:49:23 2008 +0200 - - Only set the state to true if the AS value is the same as parent's V - - Fixes bug 16121 and 15535 - - poppler/Form.cc | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -commit c75abac7ba07990ef54a46fa0d429eea580a71ef -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 2 19:16:55 2008 +0200 - - Kjartan was missing and just agreed - - utils/HtmlOutputDev.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 630aa133017d15ddc7bf96c79f43c5b60fa9749a -Merge: b2bc9b3 de82255 -Author: Pino Toscano <pino@kde.org> -Date: Tue Sep 2 01:25:55 2008 +0200 - - Merge branch 'master' of - ssh://pino@git.freedesktop.org/git/poppler/poppler - -commit b2bc9b3f59ef8e5fea18f0bc91b71fc9eb9a4157 -Author: Pino Toscano <pino@kde.org> -Date: Tue Sep 2 01:24:39 2008 +0200 - - [Qt4] small apidox improvements - - mostly the start of the \since marker addition, plus few other - documentation addition/improvements - - qt4/src/poppler-annotation.h | 9 +++++++ - qt4/src/poppler-form.h | 8 ++++++ - qt4/src/poppler-link.h | 14 ++++++++--- - qt4/src/poppler-optcontent.h | 11 +++++++++ - qt4/src/poppler-qt4.h | 59 - ++++++++++++++++++++++++++++++++++++++------ - 5 files changed, 90 insertions(+), 11 deletions(-) - -commit 6bc4881477ea15d70d420e57b5663052f2f9df76 -Author: Pino Toscano <pino@kde.org> -Date: Tue Sep 2 00:47:56 2008 +0200 - - expand the macros, extract poppler-optcontent.h - - enable the macro expansion and define POPPLER_QT4_EXPORT to be - empty, so - we don't have it in the apidox - - qt4/src/Doxyfile | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -commit de822554acdb1b2bc9e70c0668c43a10c0ec129a -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 1 23:50:37 2008 +0200 - - Initialize widget to null before calling initialize not after :-( - - poppler/Annot.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 1a7b7199112d97e816a099cbc1a5672c83e64156 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 1 20:42:06 2008 +0200 - - Add my copyright - - poppler/Dict.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 1fef34782a003f46fceab0d3bed36212bbf32c4c -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 1 20:35:37 2008 +0200 - - Find reverse way in Dict - - This fixes Greg Stolze - Marriage Of Virtue & Viciousness.pdf - The issue with this pdf is that has a Dict with two entries with - the same key - The pdf spec says if that happens, results are undefined, but Acroread - uses the - second key while we were using the first, searching backwards we - use the second now too and the pdf works - - poppler/Dict.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit bb7996eaaad6a70404891bb2ff530160737ea3d7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 1 20:29:25 2008 +0200 - - Do not crash on documents with no pages - - qt4/tests/test-poppler-qt4.cpp | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit 0c11d390e4b0e3765ae20968359c7562c9857db7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 1 20:13:33 2008 +0200 - - All poppler commiters to these files agreed to GPLv2+ - - Still missing to answer - Marco Pesenti Gritti - Catalog.cc - Outline.cc - Outline.h - - Kjartan Maraas - HtmlOutputDev.cc - - Timothy Lee - ImageOutputDev.h - ImageOutputDev.cc - - Carl Worth - CairoOutputDev.cc - - Ed Catmur - GfxFont.cc - GlobalParams.cc - TextOutputDev.cc - TextOutputDev.h - UnicodeTypeTable.cc - UnicodeTypeTable.h - - poppler/Annot.cc | 3 +++ - poppler/Annot.h | 3 +++ - poppler/Array.cc | 3 +++ - poppler/Array.h | 3 +++ - poppler/ArthurOutputDev.cc | 3 +++ - poppler/ArthurOutputDev.h | 3 +++ - poppler/CMap.cc | 3 +++ - poppler/CMap.h | 3 +++ - poppler/CairoFontEngine.cc | 3 +++ - poppler/CairoFontEngine.h | 3 +++ - poppler/CairoOutputDev.h | 3 +++ - poppler/Catalog.h | 3 +++ - poppler/CharCodeToUnicode.cc | 3 +++ - poppler/CharCodeToUnicode.h | 3 +++ - poppler/Decrypt.cc | 3 +++ - poppler/Decrypt.h | 3 +++ - poppler/Dict.cc | 3 +++ - poppler/Dict.h | 3 +++ - poppler/Error.cc | 3 +++ - poppler/Error.h | 3 +++ - poppler/Function.cc | 3 +++ - poppler/Gfx.cc | 3 +++ - poppler/Gfx.h | 3 +++ - poppler/GfxFont.h | 3 +++ - poppler/GfxState.cc | 3 +++ - poppler/GfxState.h | 3 +++ - poppler/GlobalParams.h | 3 +++ - poppler/JBIG2Stream.cc | 3 +++ - poppler/JPXStream.cc | 3 +++ - poppler/Lexer.cc | 3 +++ - poppler/Lexer.h | 3 +++ - poppler/Link.cc | 3 +++ - poppler/Link.h | 3 +++ - poppler/Object.cc | 3 +++ - poppler/Object.h | 3 +++ - poppler/OutputDev.cc | 3 +++ - poppler/OutputDev.h | 3 +++ - poppler/PDFDoc.cc | 3 +++ - poppler/PDFDoc.h | 3 +++ - poppler/PDFDocEncoding.cc | 3 +++ - poppler/PDFDocEncoding.h | 3 +++ - poppler/PSOutputDev.cc | 3 +++ - poppler/PSOutputDev.h | 3 +++ - poppler/PSTokenizer.cc | 3 +++ - poppler/PSTokenizer.h | 3 +++ - poppler/Page.cc | 3 +++ - poppler/Page.h | 3 +++ - poppler/Parser.cc | 3 +++ - poppler/Parser.h | 3 +++ - poppler/SplashOutputDev.cc | 3 +++ - poppler/SplashOutputDev.h | 3 +++ - poppler/Stream-CCITT.h | 3 +++ - poppler/Stream.cc | 3 +++ - poppler/Stream.h | 3 +++ - poppler/UTF8.h | 3 +++ - poppler/XRef.cc | 3 +++ - poppler/XRef.h | 3 +++ - utils/HtmlFonts.cc | 3 +++ - utils/HtmlLinks.cc | 3 +++ - utils/HtmlOutputDev.h | 3 +++ - utils/parseargs.c | 3 +++ - utils/parseargs.h | 3 +++ - utils/pdffonts.cc | 3 +++ - utils/pdfimages.cc | 3 +++ - utils/pdfinfo.cc | 3 +++ - utils/pdftohtml.cc | 3 +++ - utils/pdftoppm.cc | 3 +++ - utils/pdftops.cc | 3 +++ - utils/pdftotext.cc | 3 +++ - 69 files changed, 207 insertions(+) - -commit 8670bfed7900586725b30e3af67f6849acc6efda -Author: Vasile Gaburici <gaburici@cs.umd.edu> -Date: Sat Aug 30 12:47:13 2008 +0200 - - Fix extraction of images - - See bug 16999 for more info - - utils/ImageOutputDev.cc | 12 +++++++++++- - 1 file changed, 11 insertions(+), 1 deletion(-) - -commit 1c98f197664b1a2c06e2caf32116a8487f4054bf -Author: Vasile Gaburici <gaburici@cs.umd.edu> -Date: Sat Aug 30 12:44:02 2008 +0200 - - Read sMap reverse so CMap entries take precedence - - See bug 17321 for a more in depth explanation - - poppler/CharCodeToUnicode.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 8f1deb3f8000bdeb845a6c786a654bc7eb684f0a -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Aug 29 23:06:19 2008 +0200 - - Are we a lib or aren't we? Unify String to Date parsing so we all - behave the same way - - CMakeLists.txt | 2 ++ - glib/poppler-document.cc | 29 ++--------------- - poppler/DateInfo.cc | 62 - +++++++++++++++++++++++++++++++++++++ - poppler/DateInfo.h | 27 ++++++++++++++++ - poppler/Makefile.am | 2 ++ - qt/poppler-document.cc | 22 ++----------- - qt4/src/poppler-annotation-helper.h | 16 ++-------- - qt4/src/poppler-document.cc | 52 +++---------------------------- - utils/pdfinfo.cc | 16 ++-------- - utils/pdftohtml.cc | 9 ++---- - 10 files changed, 111 insertions(+), 126 deletions(-) - -commit c39f23dca98d3efe8d094c9a3e1bd460ba57d1ce -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Aug 29 20:50:57 2008 +0200 - - Add a readme for contributors with licensing and misc info - - README.contributors | 20 ++++++++++++++++++++ - 1 file changed, 20 insertions(+) - -commit 35a72590ffd3284e63601af79599e5fa025e567f -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Aug 28 00:58:11 2008 +0200 - - Be more protective against huge font sizes in bogus documents like - the one in http://bugs.freedesktop.org/show_bug.cgi?id=17326 - - 10 MB in size is a font of 3200x3200, huge enough to be discarted - - poppler/SplashOutputDev.cc | 20 +++++++++++++++++++- - 1 file changed, 19 insertions(+), 1 deletion(-) - -commit 33727cf6773b12d736ba245fdd146559ce93102d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Aug 24 20:36:13 2008 +0200 - - fix location of the comment - - fofi/FoFiType1.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit abe29b4fdb33f449649fdea5d7af2deeb702f0bb -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Aug 24 20:24:35 2008 +0200 - - All changes made to fofi/ files under the poppler project are by - people that accepts to license the code under GPLv2+ - - fofi/FoFiBase.cc | 3 +++ - fofi/FoFiTrueType.cc | 3 +++ - fofi/FoFiTrueType.h | 3 +++ - fofi/FoFiType1.cc | 3 +++ - fofi/FoFiType1C.h | 3 +++ - 5 files changed, 15 insertions(+) - -commit 6346d7050a03935c71336c65d5f8f0fe2860d321 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Aug 24 20:23:50 2008 +0200 - - All changes made to goo/ files under the poppler project are by - people that accepts to license the code under GPLv2+ - - goo/GooString.cc | 3 +++ - goo/GooString.h | 3 +++ - goo/gfile.cc | 3 +++ - goo/gfile.h | 3 +++ - goo/gmem.cc | 3 +++ - goo/gmem.h | 3 +++ - 6 files changed, 18 insertions(+) - -commit d6e1f1fb4e83527d3ece51d98fa20262713b7da1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Aug 24 20:22:06 2008 +0200 - - .cc -> .h - - poppler/FontInfo.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 9f0ac70f7ad806cadce379d4fabb90eff697ad52 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Aug 24 19:25:27 2008 +0200 - - Add missing addresses - - poppler/ABWOutputDev.cc | 4 ++-- - poppler/ABWOutputDev.h | 2 +- - poppler/FlateStream.cc | 2 +- - poppler/FlateStream.h | 2 +- - 4 files changed, 5 insertions(+), 5 deletions(-) - -commit 22f6af73961686895f207fe13022a21333455862 -Merge: 12a9e42 6d6913a -Author: Pino Toscano <pino@kde.org> -Date: Sun Aug 24 19:03:24 2008 +0200 - - Merge branch 'master' of - ssh://pino@git.freedesktop.org/git/poppler/poppler - -commit 12a9e427fb487165b1797f81d52d733c27bfa2e1 -Author: Pino Toscano <pino@kde.org> -Date: Sun Aug 24 18:57:52 2008 +0200 - - [Qt4] add showControl and playMode properties of MovieObject's - - qt4/src/poppler-movie.cc | 14 ++++++++++++++ - qt4/src/poppler-qt4.h | 20 ++++++++++++++++++++ - 2 files changed, 34 insertions(+) - -commit c444c652859b6e52160e5571e84f8eb1292d65f1 -Author: Pino Toscano <pino@kde.org> -Date: Sun Aug 24 18:47:58 2008 +0200 - - [Qt4] make the MovieObject ctor private, with only Page able to use it - - qt4/src/poppler-qt4.h | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - -commit 6d6913a79779769ce0fe2f0b516a90a50e51b947 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Aug 24 18:45:45 2008 +0200 - - fix Jeff's entry - - poppler/DCTStream.cc | 2 +- - poppler/DCTStream.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 25bd5967f9f550a32e20eea91cd00cbeff98249e -Author: Pino Toscano <pino@kde.org> -Date: Sun Aug 24 18:45:25 2008 +0200 - - [Qt4] initialize the MovieObject from an AnnotMovie - - the annotation has all the data we need, so just init from that - - qt4/src/poppler-movie.cc | 8 ++++---- - qt4/src/poppler-page.cc | 4 +--- - qt4/src/poppler-qt4.h | 4 ++-- - 3 files changed, 7 insertions(+), 9 deletions(-) - -commit 47f54ad4de111f62a5b8c25520ef6b2bca6026d2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Aug 24 18:18:13 2008 +0200 - - Add more correct copyright statements on fofi, goo, poppler and - util directories to be more compliant with GPL that requires such - modification statements to be present. Meanwhile i did that, i did - qt and qt4 dirs too, glib is missing if someone wants to fix it, - but it's not crucial as it's not a fork of some other GPL software - - AUTHORS | 4 +++- - fofi/FoFiBase.cc | 11 +++++++++++ - fofi/FoFiTrueType.cc | 14 ++++++++++++++ - fofi/FoFiTrueType.h | 12 ++++++++++++ - fofi/FoFiType1.cc | 12 ++++++++++++ - fofi/FoFiType1C.h | 11 +++++++++++ - goo/GooString.cc | 13 +++++++++++++ - goo/GooString.h | 12 ++++++++++++ - goo/GooTimer.cc | 3 +++ - goo/GooTimer.h | 8 ++++++-- - goo/GooVector.h | 12 ++++++++++++ - goo/gfile.cc | 13 +++++++++++++ - goo/gfile.h | 11 +++++++++++ - goo/gmem.cc | 13 +++++++++++++ - goo/gmem.h | 13 +++++++++++++ - poppler/ABWOutputDev.cc | 3 ++- - poppler/ABWOutputDev.h | 2 +- - poppler/Annot.cc | 19 +++++++++++++++++++ - poppler/Annot.h | 17 +++++++++++++++++ - poppler/Array.cc | 11 +++++++++++ - poppler/Array.h | 11 +++++++++++ - poppler/ArthurOutputDev.cc | 14 +++++++++++++- - poppler/ArthurOutputDev.h | 13 ++++++++++++- - poppler/CMap.cc | 12 ++++++++++++ - poppler/CMap.h | 11 +++++++++++ - poppler/CairoFontEngine.cc | 17 +++++++++++++++++ - poppler/CairoFontEngine.h | 17 +++++++++++++++++ - poppler/CairoOutputDev.cc | 19 +++++++++++++++++++ - poppler/CairoOutputDev.h | 16 ++++++++++++++++ - poppler/Catalog.cc | 19 +++++++++++++++++++ - poppler/Catalog.h | 16 ++++++++++++++++ - poppler/CharCodeToUnicode.cc | 14 ++++++++++++++ - poppler/CharCodeToUnicode.h | 13 +++++++++++++ - poppler/DCTStream.cc | 5 ++++- - poppler/DCTStream.h | 6 +++++- - poppler/Decrypt.cc | 12 ++++++++++++ - poppler/Decrypt.h | 11 +++++++++++ - poppler/Dict.cc | 13 +++++++++++++ - poppler/Dict.h | 13 +++++++++++++ - poppler/Error.cc | 13 +++++++++++++ - poppler/Error.h | 13 +++++++++++++ - poppler/FlateStream.cc | 2 ++ - poppler/FlateStream.h | 2 ++ - poppler/FontInfo.cc | 22 ++++++++++++++++++++++ - poppler/FontInfo.h | 21 +++++++++++++++++++++ - poppler/Form.cc | 10 +++++++++- - poppler/Form.h | 6 +++++- - poppler/Function.cc | 12 ++++++++++++ - poppler/Gfx.cc | 23 +++++++++++++++++++++++ - poppler/Gfx.h | 13 +++++++++++++ - poppler/GfxFont.cc | 19 +++++++++++++++++++ - poppler/GfxFont.h | 16 ++++++++++++++++ - poppler/GfxState.cc | 14 ++++++++++++++ - poppler/GfxState.h | 13 +++++++++++++ - poppler/GlobalParams.cc | 19 +++++++++++++++++++ - poppler/GlobalParams.h | 15 +++++++++++++++ - poppler/JBIG2Stream.cc | 13 +++++++++++++ - poppler/JPXStream.cc | 11 +++++++++++ - poppler/Lexer.cc | 12 ++++++++++++ - poppler/Lexer.h | 12 ++++++++++++ - poppler/Link.cc | 14 ++++++++++++++ - poppler/Link.h | 12 ++++++++++++ - poppler/Movie.cc | 17 ++++++++++++++++- - poppler/Object.cc | 11 +++++++++++ - poppler/Object.h | 12 ++++++++++++ - poppler/OptionalContent.cc | 5 ++++- - poppler/Outline.cc | 11 +++++++++++ - poppler/Outline.h | 11 +++++++++++ - poppler/OutputDev.cc | 13 +++++++++++++ - poppler/OutputDev.h | 14 ++++++++++++++ - poppler/PDFDoc.cc | 15 +++++++++++++++ - poppler/PDFDoc.h | 15 +++++++++++++++ - poppler/PDFDocEncoding.cc | 13 ++++++++++++- - poppler/PDFDocEncoding.h | 11 +++++++++++ - poppler/PSOutputDev.cc | 15 +++++++++++++++ - poppler/PSOutputDev.h | 14 ++++++++++++++ - poppler/PSTokenizer.cc | 12 ++++++++++++ - poppler/PSTokenizer.h | 11 +++++++++++ - poppler/Page.cc | 20 ++++++++++++++++++++ - poppler/Page.h | 16 ++++++++++++++++ - poppler/PageLabelInfo.cc | 12 ++++++++++++ - poppler/PageLabelInfo.h | 12 ++++++++++++ - poppler/PageTransition.h | 18 ++++++++++++++++++ - poppler/Parser.cc | 12 ++++++++++++ - poppler/Parser.h | 11 +++++++++++ - poppler/SplashOutputDev.cc | 16 ++++++++++++++++ - poppler/SplashOutputDev.h | 11 +++++++++++ - poppler/Stream-CCITT.h | 11 +++++++++++ - poppler/Stream.cc | 14 ++++++++++++++ - poppler/Stream.h | 13 +++++++++++++ - poppler/TextOutputDev.cc | 18 ++++++++++++++++++ - poppler/TextOutputDev.h | 15 +++++++++++++++ - poppler/UTF8.h | 11 +++++++++++ - poppler/UnicodeTypeTable.cc | 13 +++++++++++++ - poppler/UnicodeTypeTable.h | 11 +++++++++++ - poppler/XRef.cc | 17 ++++++++++++++++- - poppler/XRef.h | 14 ++++++++++++++ - qt/poppler-document.cc | 3 +++ - qt/poppler-fontinfo.cc | 3 +-- - qt/poppler-page.cc | 7 ++++++- - qt/poppler-private.h | 4 ++++ - qt/poppler-qt.h | 5 ++++- - qt4/src/poppler-annotation-helper.h | 1 + - qt4/src/poppler-annotation.cc | 3 ++- - qt4/src/poppler-annotation.h | 4 +++- - qt4/src/poppler-document.cc | 4 +++- - qt4/src/poppler-embeddedfile.cc | 1 + - qt4/src/poppler-fontinfo.cc | 5 ++++- - qt4/src/poppler-form.cc | 2 +- - qt4/src/poppler-form.h | 2 +- - qt4/src/poppler-link-extractor-private.h | 2 +- - qt4/src/poppler-link-extractor.cc | 2 +- - qt4/src/poppler-link.cc | 3 ++- - qt4/src/poppler-link.h | 1 + - qt4/src/poppler-optcontent-private.h | 1 + - qt4/src/poppler-optcontent.cc | 1 + - qt4/src/poppler-optcontent.h | 1 + - qt4/src/poppler-page-private.h | 2 ++ - qt4/src/poppler-page.cc | 4 ++++ - qt4/src/poppler-private.h | 4 +++- - qt4/src/poppler-ps-converter.cc | 1 + - qt4/src/poppler-qt4.h | 5 ++++- - qt4/src/poppler-textbox.cc | 2 ++ - splash/Splash.cc | 12 ++++++++++++ - splash/Splash.h | 12 ++++++++++++ - splash/SplashBitmap.cc | 12 ++++++++++++ - splash/SplashBitmap.h | 11 +++++++++++ - splash/SplashErrorCodes.h | 11 +++++++++++ - splash/SplashFTFont.cc | 12 ++++++++++++ - splash/SplashFTFont.h | 11 +++++++++++ - splash/SplashFTFontEngine.cc | 11 +++++++++++ - splash/SplashFTFontEngine.h | 11 +++++++++++ - splash/SplashFTFontFile.cc | 11 +++++++++++ - splash/SplashFTFontFile.h | 11 +++++++++++ - splash/SplashFont.cc | 11 +++++++++++ - splash/SplashFont.h | 11 +++++++++++ - splash/SplashFontEngine.cc | 11 +++++++++++ - splash/SplashFontEngine.h | 11 +++++++++++ - splash/SplashFontFile.cc | 12 ++++++++++++ - splash/SplashFontFile.h | 12 ++++++++++++ - splash/SplashT1Font.cc | 11 +++++++++++ - splash/SplashT1Font.h | 11 +++++++++++ - splash/SplashT1FontEngine.cc | 11 +++++++++++ - splash/SplashT1FontFile.cc | 11 +++++++++++ - splash/SplashT1FontFile.h | 11 +++++++++++ - splash/SplashTypes.h | 11 +++++++++++ - splash/SplashXPathScanner.cc | 11 +++++++++++ - utils/HtmlFonts.cc | 24 ++++++++++++++++++++++++ - utils/HtmlFonts.h | 12 ++++++++++++ - utils/HtmlLinks.cc | 23 +++++++++++++++++++++++ - utils/HtmlLinks.h | 12 ++++++++++++ - utils/HtmlOutputDev.cc | 13 +++++++++++++ - utils/HtmlOutputDev.h | 11 +++++++++++ - utils/ImageOutputDev.cc | 13 +++++++++++++ - utils/ImageOutputDev.h | 12 ++++++++++++ - utils/parseargs.c | 13 +++++++++++++ - utils/parseargs.h | 11 +++++++++++ - utils/pdffonts.cc | 12 ++++++++++++ - utils/pdfimages.cc | 11 +++++++++++ - utils/pdfinfo.cc | 12 ++++++++++++ - utils/pdftoabw.cc | 26 +++++++++++++++++++------- - utils/pdftohtml.cc | 11 +++++++++++ - utils/pdftoppm.cc | 11 +++++++++++ - utils/pdftops.cc | 12 ++++++++++++ - utils/pdftotext.cc | 12 ++++++++++++ - 165 files changed, 1795 insertions(+), 37 deletions(-) - -commit 0dfbb8996ee91aa044eb2bdf2859ef64005116f8 -Author: Loïc Minier <lool@dooz.org> -Date: Wed Aug 20 22:10:07 2008 +0200 - - Fixes escaping of hyphens in man pages - - utils/pdfinfo.1 | 2 +- - utils/pdftops.1 | 16 ++++++++-------- - 2 files changed, 9 insertions(+), 9 deletions(-) - -commit 6cfa0e598a81460e5d0a7d60d8584366d2a70165 -Author: Loïc Minier <lool@dooz.org> -Date: Wed Aug 20 19:57:42 2008 +0200 - - Fix synopsis of pdftops in man page to clarify that a PDF file is - required in all cases - - utils/pdftops.1 | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 48a73cc709a8bed9d2d0f9cbd2a9d2b6c0dad05b -Author: Pino Toscano <pino@kde.org> -Date: Sat Aug 23 19:26:01 2008 +0200 - - [Qt4] convert the title of movie annotations - - qt4/src/poppler-page.cc | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit 419ec15ac825f2e0052b411462f00ac57fed030e -Author: Pino Toscano <pino@kde.org> -Date: Sat Aug 23 19:25:04 2008 +0200 - - [Qt4] get/set the title for movie annotations - - qt4/src/poppler-annotation.cc | 13 +++++++++++++ - qt4/src/poppler-annotation.h | 3 +++ - 2 files changed, 16 insertions(+) - -commit 63bcaf113fcb5a4a9e5c120df2c3dafb2977c90a -Author: Pino Toscano <pino@kde.org> -Date: Sat Aug 23 01:58:30 2008 +0200 - - [Qt4] convert the movie annotation from the core type to the Qt4 one - - qt4/src/poppler-page.cc | 18 +++++++++++++++--- - 1 file changed, 15 insertions(+), 3 deletions(-) - -commit 5cc490de74af12726bdeb9b5a6a0f0d1d79383b5 -Author: Pino Toscano <pino@kde.org> -Date: Sat Aug 23 01:55:41 2008 +0200 - - [Qt4] first version of a MovieAnnotation - - right mow it just holds the movie object - - qt4/src/poppler-annotation.cc | 74 - +++++++++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-annotation.h | 26 ++++++++++++++- - 2 files changed, 99 insertions(+), 1 deletion(-) - -commit 3d5c2e22d790d7c139e1cd28aebb21cfe76b8b6b -Author: Pino Toscano <pino@kde.org> -Date: Sat Aug 23 01:54:30 2008 +0200 - - compile the new poppler-movie.cc - - qt4/src/CMakeLists.txt | 1 + - qt4/src/Makefile.am | 1 + - 2 files changed, 2 insertions(+) - -commit 599698a9b133999f1f0bb0548489111e9d7b6f05 -Author: Pino Toscano <pino@kde.org> -Date: Sat Aug 23 01:52:58 2008 +0200 - - [Qt4] first version of a MovieObject object for movies - - slightly differs from the version in core - - qt4/src/poppler-movie.cc | 73 - ++++++++++++++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-qt4.h | 34 ++++++++++++++++++++++ - 2 files changed, 107 insertions(+) - -commit 820f15009845870701e1f4e7f4fc4fb93312ab3e -Author: Pino Toscano <pino@kde.org> -Date: Sat Aug 23 01:45:07 2008 +0200 - - fix Movie::copy() - - the default copy ctor already does the vertbatim copies, so no need to - do them on our own; what needs to be done is checking whether - an object - is valid before either doing a "smart copy" or "postprocessing" it - - poppler/Movie.cc | 14 ++++++++------ - 1 file changed, 8 insertions(+), 6 deletions(-) - -commit c3a006ae35250e9a5638c2ce713b7470380751c7 -Author: Pino Toscano <pino@kde.org> -Date: Sat Aug 23 01:04:34 2008 +0200 - - compile attachments.c in the demo with cmake as well - - glib/demo/CMakeLists.txt | 1 + - 1 file changed, 1 insertion(+) - -commit b5a7987a50b3d28fbfa219e2cef85b9e53aaf079 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Aug 21 20:40:18 2008 +0200 - - [glib-demo] Fix attachments demo with documents that don't contain - attachments - - glib/demo/attachments.c | 27 ++++++++++++++++++++------- - 1 file changed, 20 insertions(+), 7 deletions(-) - -commit a2b0aefedbdb20ce0ef8398a700202021fcf00db -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Aug 21 20:14:50 2008 +0200 - - [glib-demo] Fix typo - - glib/demo/attachments.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 9e563d6d877624b1caf82ac30c5ae30a1eb48f21 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Aug 21 20:12:33 2008 +0200 - - [glib-demo] Add checksum validation to attachments demo - - glib/demo/attachments.c | 101 - ++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 101 insertions(+) - -commit e233325e6f13d8b232bf68a2812fe755e7fccd4d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Aug 21 19:03:32 2008 +0200 - - [glib-demo] Add demo for attachments - - glib/demo/Makefile.am | 2 + - glib/demo/attachments.c | 242 - ++++++++++++++++++++++++++++++++++++++++++++++++ - glib/demo/attachments.h | 31 +++++++ - glib/demo/main.c | 4 +- - glib/demo/utils.c | 23 +++++ - glib/demo/utils.h | 1 + - 6 files changed, 302 insertions(+), 1 deletion(-) - -commit 0e2efa0fce5bf059ce85d3e3bec2293b405ec3c9 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Aug 21 19:02:24 2008 +0200 - - [glib] Make sure name and descripction are valid utf8 strings - - glib/poppler-attachment.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 15a73704ab6b009ca5e07c08f0b12d970adc387d -Author: Chris Wilson <chris@chris-wilson.co.uk> -Date: Tue Aug 19 09:18:03 2008 +0100 - - Memleak and invalid free. - - CairoOutputDev::setSoftMask() fails to free the cairo_t and mask - it uses - to draw the opaque soft mask and attempts to destroy a reference to a - surface it does not own (this bug was masked by the fact that - a reference - was still being held by the unfreed cairo_t). - - poppler/CairoOutputDev.cc | 11 ++++++++--- - 1 file changed, 8 insertions(+), 3 deletions(-) - -commit d3110e392097db54e9ee59300213e490dee39126 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Aug 19 19:19:09 2008 +0200 - - Fix include so it can be used in the unsupported way of installing - internal poppler/ headers - - Notified by Caolan McNamara <caolanm@redhat.com> - - poppler/PreScanOutputDev.h | 2 +- - poppler/SecurityHandler.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 303249e5548bfbf6823e97850e498970d802b4a0 -Author: Albert Astals Cid <tsdgeos@samsung.localdomain> -Date: Fri Aug 15 01:52:52 2008 +0200 - - Revert 123a87aff2e35b10efe6a1d715585b427e4a9afa it creates problems - with some pdf files - - poppler/Gfx.cc | 14 ++------------ - poppler/Gfx.h | 3 --- - 2 files changed, 2 insertions(+), 15 deletions(-) - -commit 27ddf3c5e839358c8553d41743faa8ee304767bf -Author: Pino Toscano <pino@kde.org> -Date: Wed Aug 13 13:55:57 2008 +0200 - - [Qt4] make sure to use the correct page width/height for form - widgets coordinates - - qt4/src/poppler-form.cc | 12 +++++++++--- - 1 file changed, 9 insertions(+), 3 deletions(-) - -commit 2e7b0eb4af8cf5938833e5659d01b77096e7b7f7 -Author: Pino Toscano <pino@kde.org> -Date: Tue Aug 12 13:49:52 2008 +0200 - - [Qt4] add a method to get the activation action of a FormField - - qt4/src/poppler-form.cc | 19 +++++++++++++++++++ - qt4/src/poppler-form.h | 8 ++++++++ - 2 files changed, 27 insertions(+) - -commit f9e679adbd6830da26eb9909bcb16e3bdf0da6b4 -Author: Pino Toscano <pino@kde.org> -Date: Tue Aug 12 13:47:15 2008 +0200 - - create a static version of PageData::convertLinkActionToLink() - - qt4/src/poppler-page-private.h | 2 ++ - qt4/src/poppler-page.cc | 5 +++++ - 2 files changed, 7 insertions(+) - -commit a6ecc864ea3e94d7232cff6a2e8f49919d8f24ff -Author: Albert Astals Cid <tsdgeos@samsung.localdomain> -Date: Tue Aug 12 01:23:21 2008 +0200 - - initialize widget, fixes crash on EC2006.pdf - - poppler/Annot.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 123a87aff2e35b10efe6a1d715585b427e4a9afa -Author: Albert Astals Cid <tsdgeos@samsung.localdomain> -Date: Tue Aug 12 00:37:09 2008 +0200 - - Cache the last created GfxResource, very useful because some pdf - created by pstopdf push and pop the same GfxResource all the time - - This brings us a speedup of 16 times (from 11 seconds to about 600 - msec) in kde bug 168663 - - poppler/Gfx.cc | 14 ++++++++++++-- - poppler/Gfx.h | 3 +++ - 2 files changed, 15 insertions(+), 2 deletions(-) - -commit 5ad1a12183f4b8e328f32386a74b5616e7e59070 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Aug 4 20:34:42 2008 +0200 - - Be less strict when parsing TTF tables - - With this change and freetype from CVS i can render Bug 16940 using - the splash renderer - - fofi/FoFiTrueType.cc | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -commit d322720428fa416b7d5f23acc72d1d4b4f74d041 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Aug 4 20:16:50 2008 +0200 - - Report an error when FoFiTrueType::load or FoFiTrueType::make fail - - poppler/SplashOutputDev.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 901ebc84ff7c0872c3f9f5e6eaf418ba6400fa10 -Author: Pino Toscano <pino@kde.org> -Date: Sun Aug 3 10:54:09 2008 +0200 - - [Qt4] Make the paper color setting working as it should. - - A BGR colorspace means that colors should be set as blue,green,red, - and - not red,green,blue. - - qt4/src/poppler-private.h | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit 66b34c78943be598778a3ef438b0cefac668c6a2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Aug 2 13:54:34 2008 +0200 - - This should not be here, breaks jpeg rendering when not using libjpeg - - That was included erroneously when the file writing code was added - - poppler/Stream.cc | 1 - - 1 file changed, 1 deletion(-) - -commit fd8d71ea8b12393201ece9c09372fd69c7573025 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Aug 1 23:47:51 2008 +0200 - - These defines are unneeded too - - msvc/poppler/poppler-config.h | 30 ------------------------------ - poppler-config.h.cmake | 30 ------------------------------ - poppler/poppler-config.h.in | 30 ------------------------------ - 3 files changed, 90 deletions(-) - -commit 391b5d5cdd9f63fe90229f88cdad628fb63c0206 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Aug 1 23:36:09 2008 +0200 - - Get rid of more defines, say our version on command line tools, - also say our copyright - - Did not modify PSOutputDev.cc output as PS is too fragile - - msvc/poppler/poppler-config.h | 9 +-------- - poppler-config.h.cmake | 9 +-------- - poppler/PSOutputDev.cc | 2 +- - poppler/poppler-config.h.in | 9 +-------- - utils/pdffonts.cc | 3 ++- - utils/pdfimages.cc | 3 ++- - utils/pdfinfo.cc | 3 ++- - utils/pdftohtml.cc | 3 ++- - utils/pdftoppm.cc | 3 ++- - utils/pdftops.cc | 3 ++- - utils/pdftotext.cc | 3 ++- - 11 files changed, 18 insertions(+), 32 deletions(-) - -commit d14fb1513be045363f7edec21cee04fd4937ede2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Aug 1 23:14:28 2008 +0200 - - Add GooList *getEncodingNames(); - - Forgot to commit this earlier :-( - - poppler/GlobalParams.cc | 19 +++++++++++++++++++ - poppler/GlobalParams.h | 2 ++ - 2 files changed, 21 insertions(+) - -commit 9fd34443d765ccd61864d18bceadc049d905b957 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Aug 1 23:09:39 2008 +0200 - - remove defines we don't use at all - - msvc/poppler/poppler-config.h | 4 ---- - poppler-config.h.cmake | 4 ---- - poppler/poppler-config.h.in | 4 ---- - 3 files changed, 12 deletions(-) - -commit 0f13013dc3079915572b6b002dac8d01d2dbde04 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Aug 1 23:06:50 2008 +0200 - - xpdfrc has been dead for a while - - msvc/poppler/poppler-config.h | 25 ------------------------- - poppler-config.h.cmake | 25 ------------------------- - poppler/poppler-config.h.in | 25 ------------------------- - 3 files changed, 75 deletions(-) - -commit 96392667d1331d2f8750f27c116e34bbf9282dca -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Aug 1 22:20:55 2008 +0200 - - Provide a default constructor for FontInfo so you can use it as - metatype for qvariant - - qt4/src/poppler-fontinfo.cc | 5 +++++ - qt4/src/poppler-private.h | 7 +++++++ - qt4/src/poppler-qt4.h | 5 +++++ - 3 files changed, 17 insertions(+) - -commit 9fd1077e63d97a316380b8df4821bf4c9434fb52 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Aug 1 17:47:51 2008 +0200 - - Build with cmake too - - utils/CMakeLists.txt | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit d8d6a3f46620d45c279b7ca1a4a2fa3a36285cde -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Aug 1 17:44:07 2008 +0200 - - Improve manpages and add -listenc to pdfinfo and pdftotext in the way - - Our manpages listed things like xpdfrc and -cfg options we don't - support at all. - Also some options were missing from the man pages - Finally there was the -enc option you completely had to guess which - string to pass, - so i've added the -listenc option to get the user the list of - encodings he can use - - utils/Makefile.am | 2 ++ - utils/pdffonts.1 | 18 ------------------ - utils/pdfimages.1 | 14 -------------- - utils/pdfinfo.1 | 28 ++++------------------------ - utils/pdfinfo.cc | 16 ++++++++++++++-- - utils/pdftoppm.1 | 42 +++++++++++++++++++++--------------------- - utils/pdftops.1 | 41 +++-------------------------------------- - utils/pdftotext.1 | 32 ++++---------------------------- - utils/pdftotext.cc | 16 ++++++++++++++-- - utils/printencodings.cc | 34 ++++++++++++++++++++++++++++++++++ - utils/printencodings.h | 24 ++++++++++++++++++++++++ - 11 files changed, 120 insertions(+), 147 deletions(-) - -commit f5b0ca794b0879e3d239bf1d6138b15ead27d9ca -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Tue Jul 29 20:18:33 2008 +0930 - - Fix ActualText string length check in TextOutputDev.cc - - poppler/TextOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 21bbdc9d663995336900f1ce97cf294f04464e01 -Author: Boris Toloknov <tlknv@yandex.ru> -Date: Mon Jul 28 21:02:07 2008 +0200 - - make xml output valid xml - - utils/HtmlLinks.cc | 33 ++++++++++++++++++-- - utils/HtmlOutputDev.cc | 85 - ++++++++++++++++++++++++++++++++------------------ - 2 files changed, 85 insertions(+), 33 deletions(-) - -commit dccfc4c2910b47a77cd7b6019d9365f1684ffd0c -Author: Boris Toloknov <tlknv@yandex.ru> -Date: Mon Jul 28 20:58:13 2008 +0200 - - Limit ascent and descent are to reasonable values. - - See bug 16592 to cases where this helps - - utils/HtmlOutputDev.cc | 14 ++++++++++++-- - 1 file changed, 12 insertions(+), 2 deletions(-) - -commit 0fd5a3db1ddad447d44b64eff9abfb077a7853a0 -Author: Boris Toloknov <tlknv@yandex.ru> -Date: Mon Jul 28 20:52:19 2008 +0200 - - Make html output to keep all the spaces with   - - utils/HtmlFonts.cc | 2 ++ - utils/HtmlOutputDev.cc | 2 +- - 2 files changed, 3 insertions(+), 1 deletion(-) - -commit 650c73fa0f570f699d907e33060fb23290940b42 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Jul 28 20:44:13 2008 +0200 - - findDest crashes on null goostrings so rework the ifs a bit - - utils/HtmlOutputDev.cc | 16 +++++++++------- - 1 file changed, 9 insertions(+), 7 deletions(-) - -commit adee9c0e9e8b2de20309b3ae6eb8e6d6ed05cf85 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Jul 26 00:04:03 2008 +0200 - - We are not storing the ctu, so decref and leak-- :-) - - poppler/Annot.cc | 1 + - 1 file changed, 1 insertion(+) - -commit e7b3e3ae3080bd6f239f7d96761729ad30b075ae -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 25 23:52:28 2008 +0200 - - Fix leak - - qt4/src/poppler-form.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 006b974d4faae53e6bd51a4281dd923ab1c2d4e8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 25 23:15:11 2008 +0200 - - Fix memory leak - - poppler/Annot.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 3a549d75acceedfa25dcf79074d0cdfb643c746e -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 25 23:08:21 2008 +0200 - - Free the previous modified object in case it exists - - poppler/XRef.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 040d244b97a554342061c777a286e99dbb9acabd -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 25 21:31:55 2008 +0200 - - Need this or otherwise it crashes on complete overwrite - - poppler/PDFDoc.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 11ebceeef938a7e6fa9b5437e65b5b4b822f3018 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 25 21:30:24 2008 +0200 - - Fix my last fix about saving, i think this is the correct one - - - One incremental update only write the modified entries xref, - not all - - Update gen to 0 when resizing entries - - On XRef::add correctly initialize all newly allocated entries - - poppler/PDFDoc.cc | 4 ++-- - poppler/XRef.cc | 57 - ++++++++++++++++++++++++++++++++++++++++++++----------- - poppler/XRef.h | 2 +- - 3 files changed, 49 insertions(+), 14 deletions(-) - -commit 03d445f485f90972ab1c05d79b2999b763ab7377 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 25 20:16:54 2008 +0200 - - Fix XRef::writeToFile after my change - - poppler/XRef.cc | 10 +++------- - 1 file changed, 3 insertions(+), 7 deletions(-) - -commit 136fa97576f2df0d7a7563b34651ca222927ea57 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 25 20:12:51 2008 +0200 - - Fix XRef::add and XRef::addIndirectObject, also remove num from - XRefEntry - - Previous code was under some incorrect assumptions: - * our XRef does not maintain the free link list so if you want to - find a free entry you have to go though all of them - * our XRefEntry does not need a num because the index itself is - the num - - Conflicts: - - poppler/XRef.cc - - poppler/XRef.cc | 70 - +++++++++++++++++++++------------------------------------ - poppler/XRef.h | 1 - - 2 files changed, 25 insertions(+), 46 deletions(-) - -commit 55572b77da95c47393b78f3aff804ea9c5ae17e5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jul 22 22:50:00 2008 +0200 - - Really do what the comment says and also init changeLeft, changeTop - and changeZoom - - poppler/Link.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 8dc7afaeea08183de331ecfd41ce1971e7772fd0 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jul 22 21:05:03 2008 +0200 - - Some documents have loops in XObject dictionaries, make sure we - don't get in an infinite loop while traversing them - - Fixes infinite loop on http://bugs.kde.org/show_bug.cgi?id=166145 - - poppler/FontInfo.cc | 44 ++++++++++++++++++++++++++++++++++++-------- - poppler/FontInfo.h | 4 ++++ - 2 files changed, 40 insertions(+), 8 deletions(-) - -commit 9fb17c952dcff798e45280eeb9c718680147e766 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jul 20 13:47:11 2008 +0200 - - Fix condition, we want thumb to be a Stream, not to be non null - - Fixes bug 16579 - - glib/poppler-page.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 3696025977fd345b12767f75a2de6ed7e9467365 -Author: Pino Toscano <pino@kde.org> -Date: Fri Jul 18 23:32:25 2008 +0200 - - initialize pageWidgets, otherwise it can be a rubbish pointer - is Annots - is not a valid object - - poppler/Page.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 0189ff8b86de18486f7397076f7a0fbf133a1a33 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jul 1 20:16:50 2008 +0200 - - Fix condition, we want fetched_thumb to be a Stream, not to be - non null - - Fixes bug 16579 - - poppler/Page.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 5bd77dcdd5220d63934f4b3e78d85a936947a53d -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jul 1 00:49:01 2008 +0200 - - forgot about we use autofoo too - - qt4/tests/Makefile.am | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 5ed2503003d973b5461594af15485af49591451d -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jul 1 00:43:26 2008 +0200 - - unittesting about ActualText - - qt4/tests/CMakeLists.txt | 1 + - qt4/tests/check_actualtext.cpp | 33 +++++++++++++++++++++++++++++++++ - 2 files changed, 34 insertions(+) - -commit f3bb2eb556f5248242f6db85052ef045fcb697c6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jul 1 00:41:35 2008 +0200 - - Unbreak ActualText extraction - - poppler/Gfx.cc | 10 +--------- - 1 file changed, 1 insertion(+), 9 deletions(-) - -commit 9e9543b105b39f8b0048c00fc94741e43ad615e9 -Author: Pino Toscano <pino@kde.org> -Date: Thu Jun 26 20:19:06 2008 +0200 - - use FindPackageHandleStandardArgs - - cmake/modules/FindLIBOPENJPEG.cmake | 11 ++--------- - 1 file changed, 2 insertions(+), 9 deletions(-) - -commit fec41ceddebe194f139bcc5b2f3fa74e7d1ae502 -Author: Pino Toscano <pino@kde.org> -Date: Thu Jun 26 20:18:27 2008 +0200 - - need to use LIBOPENJPEG_FOUND, as it really represents whether - libopenjpeg was found or not - - CMakeLists.txt | 18 +++++++++--------- - 1 file changed, 9 insertions(+), 9 deletions(-) - -commit 5498d93e59a0b79e5add3dc6181d5e98ba689217 -Author: Michael Vrable <mvrable@cs.ucsd.edu> -Date: Fri Jun 20 21:42:34 2008 -0700 - - Use a single global FT_Library in CairoOutputDev - - Cairo may internally keep references to the FreeType fonts loaded in - CairoFontEngine even after poppler is done with them. Commit - 42db4890e829 - ("Do not call FT_Done_Face on a live cairo_font_face_t") introduced - a fix - for one use-after-free bug, by delaying deleting an FT_Face objects - until - cairo is done with it. - - That fix doesn't correct all the bugs. An FT_Library object is - created for - each CairoOutputDev object, and deleted when the CairoOutputDev - goes away. - But the FT_Library object should not be deleted while fonts loaded - using it - are still in use. And cairo can keep references to fonts around - more or - less indefinitely. - - To more fully fix the problem, we can either: - 1. Keep a count of not-yet-deleted fonts associated with each - FT_Library, - and wait to call FT_Done_FreeType until it drops to zero. - 2. Never call FT_Done_FreeType. - - The second option is the simplest. To avoid leaking memory FT_Library - objects, use a single global FT_Library instead of a - per-CairoOutputDev - copy. - - poppler/CairoOutputDev.cc | 18 +++++++++++++++--- - poppler/CairoOutputDev.h | 4 +++- - 2 files changed, 18 insertions(+), 4 deletions(-) - -commit c75632d62a052d3c3739b96f5586f97c68baf25b -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 24 02:31:43 2008 +0200 - - Open in WriteOnly mode, fixes the fact that when writing to an - existing file, the contents beyond what we wrote were still there - - qt4/src/poppler-base-converter.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 9810fdfc54aac80aa99561a9d820d11b062e4637 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 24 02:12:21 2008 +0200 - - the entry is not updated here either, fix uninitialized variable use - - poppler/XRef.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 2da15db4751d3cb93d40b48e348dbc51f6e7a29f -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Jun 20 11:39:08 2008 +0200 - - Do not create an OCGs object if there isn't an OCProperties dictionary - in the Catalog - - poppler/Catalog.cc | 5 +++-- - poppler/Gfx.cc | 12 +++++++++++- - poppler/OptionalContent.cc | 25 +++++-------------------- - 3 files changed, 19 insertions(+), 23 deletions(-) - -commit d6fb5dcb7b7596961800d9744d17b6adb8d9a2ad -Author: Michael Vrable <mvrable@cs.ucsd.edu> -Date: Wed Jun 18 11:24:05 2008 -0700 - - Fix a crash in the cairo backend with Type 3 glyphs - - Commit 86b7e8a3bee7 ("Ensure cairo renders Type 3 glyphs with only - the fill - color") introduced a bug into the Cairo backend, causing evince - to crash - with the message - evince: cairo-pattern.c:679: cairo_pattern_destroy: Assertion - `((*&(&pattern->ref_count)->ref_count) > 0)' failed. - Fix this by updating reference counts to the fill and stroke - patterns when - modifying them in beginType3Char. - - Simplify the code as well by not saving the old stroke pattern before - overriding it; this is already done since beginType3Char/endType3Char - is - wrapped by calls to saveState/restoreState in Gfx::doShowText. - - poppler/CairoOutputDev.cc | 4 ++-- - poppler/CairoOutputDev.h | 2 +- - 2 files changed, 3 insertions(+), 3 deletions(-) - -commit c3a00c83f1d24c1f88e7ed3b3f772460e578f3cc -Author: Pino Toscano <pino@kde.org> -Date: Sun Jun 15 02:39:31 2008 +0200 - - poppler-page-transition.h is here now - - qt4/src/Doxyfile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 2affed0fc97b958ae46f531c471a3cf0b04c0f55 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Jun 14 01:24:49 2008 +0200 - - Give warnings if the build configuration for stream decoders is - different from default one - - configure.ac | 20 +++++++++++++++++--- - 1 file changed, 17 insertions(+), 3 deletions(-) - -commit 8e74bc612cb4102891324ffdbfcdb47293ecb95e -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Jun 14 01:13:53 2008 +0200 - - Warn the user if he does not have any enabled rendering backend - - configure.ac | 3 +++ - 1 file changed, 3 insertions(+) - -commit 99d2361032cbaafd69bd796170757ed6482f208d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Jun 14 00:53:38 2008 +0200 - - Add a JPEG2000 decoder based on OpenJPEG - - Enabled by default since it's generally better than xpdf one - See - http://lists.freedesktop.org/archives/poppler/2008-June/003874.html - for more information - - CMakeLists.txt | 30 +++++- - cmake/modules/FindLIBOPENJPEG.cmake | 44 +++++++++ - configure.ac | 33 +++++++ - poppler/JPEG2000Stream.cc | 181 - ++++++++++++++++++++++++++++++++++++ - poppler/JPEG2000Stream.h | 48 ++++++++++ - poppler/Makefile.am | 22 ++++- - poppler/Stream.cc | 7 +- - 7 files changed, 360 insertions(+), 5 deletions(-) - -commit e368838d7f9691c7b1adf7d7f62f65abed91eea7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jun 11 00:48:53 2008 +0200 - - [Qt4] Add the possibility of getting a QByteArray with the data of - an embedded font - - qt4/src/poppler-document.cc | 23 +++++++++++++++++++++++ - qt4/src/poppler-private.h | 3 +++ - qt4/src/poppler-qt4.h | 5 +++++ - 3 files changed, 31 insertions(+) - -commit 184292ffb8fef5aa5a72bdbfcc0c95b663f452bd -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 10 23:00:11 2008 +0200 - - Make the fontRef and the embRef accessible to FontInfo users - - poppler/FontInfo.cc | 2 +- - poppler/FontInfo.h | 3 +++ - 2 files changed, 4 insertions(+), 1 deletion(-) - -commit 86b7e8a3bee74c5b89c451137cf9c2758ba6913f -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Sun Jun 8 18:00:05 2008 +0930 - - Ensure cairo renders Type 3 glyphs with only the fill color - - poppler/CairoOutputDev.cc | 3 +++ - poppler/CairoOutputDev.h | 2 +- - 2 files changed, 4 insertions(+), 1 deletion(-) - -commit 99e2d95728f41c91ab59a01c62d82b19a7a2e083 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Sun Jun 1 00:49:32 2008 +0930 - - glib: save/restore cairo state when rendering a page - - glib/poppler-page.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 6f40ee4af6b59f9d2c326adc8d2574e45f4d4d29 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jun 8 23:46:04 2008 +0200 - - Make sure we use Qt4 moc to generate moc files of the qt4 frontend - - configure.ac | 20 ++++++++++++++++++++ - qt4/demos/Makefile.am | 2 +- - qt4/src/Makefile.am | 2 +- - qt4/tests/Makefile.am | 2 +- - 4 files changed, 23 insertions(+), 3 deletions(-) - -commit 86aa8fc0708f7da4a907a8bdb1845e53d29892b7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jun 5 19:21:08 2008 +0200 - - Fix leak on ABWOutputDev.cc - - poppler/ABWOutputDev.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 979ef1cafa968d776a2b804ce555b11212212397 -Author: Koji Otani <sho@bbr.jp> -Date: Tue Jun 3 21:07:15 2008 +0200 - - Support for surrogates outside the BMP plane - - poppler/TextOutputDev.cc | 19 ++++++++++++++++++- - poppler/UTF8.h | 14 ++++++++++++++ - 2 files changed, 32 insertions(+), 1 deletion(-) - -commit 1614ab3036cf25c9b94967163996678d386ce0ac -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jun 1 16:32:55 2008 +0200 - - Do not limit CharCodeToUnicodeString to 8 characters - - poppler/Annot.cc | 10 +++++----- - poppler/CharCodeToUnicode.cc | 37 +++++++++++++++++++++---------------- - poppler/CharCodeToUnicode.h | 2 +- - poppler/Gfx.cc | 8 ++++---- - poppler/GfxFont.cc | 43 - ++++++++++++++++++++++++------------------- - poppler/GfxFont.h | 6 +++--- - poppler/PSOutputDev.cc | 4 ++-- - 7 files changed, 60 insertions(+), 50 deletions(-) - -commit bf95c6970dacaa62512de858cf60ff6cf0c1bf7c -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jun 1 00:07:11 2008 +0200 - - [Qt] Fix leak when calling Poppler::Document::scanForFonts - - qt/poppler-document.cc | 1 + - 1 file changed, 1 insertion(+) - -commit d21d7271fc74ab78cd157549138d0027cf179471 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat May 31 23:57:31 2008 +0200 - - Make sure file exists before printing it - - utils/HtmlOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 0480a788c0f25af1bc09360b599debb37f831e10 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue May 27 23:20:32 2008 +0200 - - require gthread-2.0 - - cmake/modules/FindGTK.cmake | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - -commit 2e40ef652eb9fca7fe947acb2adfecc96ad3c50e -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon May 26 22:13:38 2008 +0200 - - Do not shadow a paramer with a local variable name - - qt4/src/poppler-page.cc | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit 1fd856aa1fb48869111e5b86f263bfd94fa7af17 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon May 26 20:52:53 2008 +0200 - - Do not leak tSplash if transpGroupStack->blendingColorSpace is NULL - - poppler/SplashOutputDev.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 492209ec8648342a3a5447611f3f1ce63b63e8e9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon May 26 20:51:06 2008 +0200 - - Move variables only used inside the loop inside the loop, fix delete - of uninitialized data due to my previous patch - - poppler/Page.cc | 16 ++++++---------- - 1 file changed, 6 insertions(+), 10 deletions(-) - -commit 79ab8cceb318f3bb5ebad431824e3ae593aea340 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon May 26 20:38:59 2008 +0200 - - Do not leak memory if data_out is NULL - - poppler/Page.cc | 35 ++++++++++++++++++----------------- - 1 file changed, 18 insertions(+), 17 deletions(-) - -commit f44c33344d4af31ee008826179bcd92db445f35a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun May 25 19:16:12 2008 +0200 - - [glib] Init glib threads in demo app as required by g_timer - - configure.ac | 4 ++-- - glib/demo/main.c | 4 ++++ - 2 files changed, 6 insertions(+), 2 deletions(-) - -commit 58d5b7b9ab9ac245481299c4765f3bd305580d2e -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed May 21 22:18:29 2008 +0200 - - [Qt4] Fix text() method - - I'm not sure this is the real and correct fix, but it works more - than previous code so it's and improvement - - qt4/src/poppler-page.cc | 6 +----- - 1 file changed, 1 insertion(+), 5 deletions(-) - -commit e3e4113c73128f49f99289b592446d4382b5d65c -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon May 12 15:39:43 2008 +0200 - - Add getters to some TextBlock members. - - Needed by some reader using poppler internals, bad you! - - poppler/TextOutputDev.h | 5 +++++ - 1 file changed, 5 insertions(+) - -commit ff699e64bd1de78915aad4ddb79d6f529aef2b87 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun May 11 23:44:50 2008 +0200 - - Check the OC we found exists before using it - - Fixes crash http://bugs.freedesktop.org/show_bug.cgi?id=15899 - - poppler/OptionalContent.cc | 33 ++++++++++++++++++--------------- - 1 file changed, 18 insertions(+), 15 deletions(-) - -commit ac26ba5148b99a03a56e37ba201ad420b8619943 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri May 9 20:17:37 2008 +0200 - - Do not crash on unlock with wrong password - - qt/poppler-private.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 19ec5a531cb03a7bee1cfcc9c7d5c4390fbd069d -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu May 8 23:15:58 2008 +0200 - - Fix build with --enable-fixedpoint - - splash/Splash.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 1cf5f0fda542efef575a123622637d81b9c42053 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed May 7 18:49:28 2008 +0200 - - [Qt] Fix Document::unlock - - qt/poppler-document.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit b5041924eb023cc095f2445935ff713cf65dacce -Author: Pino Toscano <pino@kde.org> -Date: Wed May 7 16:44:03 2008 +0200 - - do not delete the GooString owned by an Object - - poppler/Annot.cc | 4 ---- - 1 file changed, 4 deletions(-) - -commit 546a7b700862db00240de9fd50bdba1dd347765b -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun May 4 15:26:26 2008 +0200 - - Fix leaks on error conditions - - poppler/Annot.cc | 6 ++++++ - poppler/ArthurOutputDev.cc | 1 + - poppler/JBIG2Stream.cc | 1 + - 3 files changed, 8 insertions(+) - -commit 914f1b1d814ab3d958aa0ca21ad73ef5aed20b89 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat May 3 18:21:28 2008 +0200 - - A widget annot does not always belong to a form, so check before - accessing the widget member - - poppler/Annot.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit c907e41ab18dda10cd3c9789bd0e7fe71b6402a8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Apr 30 00:42:34 2008 +0200 - - findSegment can return NULL check for it - - poppler/JBIG2Stream.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 8b7f29b577bca3295e99fea4a5cf4a6bb7ba2617 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Apr 30 00:26:28 2008 +0200 - - new[] implies delete[] - - poppler/ABWOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 926c13825d5f7364286975db8ffa507b92f4b3ab -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 29 23:44:51 2008 +0200 - - add lost return when adding kees patch - - poppler/Object.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ba9283f6bc78e97006e52ef5de20c958ee9e1a37 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 29 23:42:00 2008 +0200 - - make the function static - - utils/pdftoppm.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 931a8272f556ba8a35342f0c5bf53bdb57ea7a31 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 29 23:41:31 2008 +0200 - - make the variable static - - utils/pdftoabw.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 1887d2910d2006c7fc3ecc95db0150f1537e9d0a -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 29 23:35:17 2008 +0200 - - constify some static arrays - - poppler/CompactFontTables.h | 2 +- - poppler/Decrypt.cc | 8 ++++---- - poppler/Function.cc | 2 +- - poppler/GfxFont.cc | 6 +++--- - poppler/GfxState.cc | 4 ++-- - poppler/JBIG2Stream.cc | 10 +++++----- - poppler/JPXStream.cc | 4 ++-- - poppler/Lexer.cc | 2 +- - poppler/PSOutputDev.cc | 6 +++--- - poppler/PSTokenizer.cc | 2 +- - poppler/SplashOutputDev.cc | 2 +- - poppler/Stream-CCITT.h | 12 ++++++------ - poppler/Stream.cc | 10 +++++----- - poppler/UnicodeTypeTable.cc | 2 +- - 14 files changed, 36 insertions(+), 36 deletions(-) - -commit 51140e2d9490696d716f77d3225da0bfdfc212b4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 29 23:14:59 2008 +0200 - - more static markers - - poppler/Annot.cc | 2 +- - poppler/DCTStream.cc | 2 +- - poppler/Object.cc | 2 +- - poppler/SplashOutputDev.cc | 2 +- - 4 files changed, 4 insertions(+), 4 deletions(-) - -commit 893703cb9eee879f728db329f7ee1fc19e7f980e -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 29 23:03:51 2008 +0200 - - add static - - poppler/XRef.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 7333bc913111e56ee241b7ef2bf6e9fea68b7da2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 29 23:01:13 2008 +0200 - - add static - - poppler/JBIG2Stream.cc | 30 +++++++++++++++--------------- - 1 file changed, 15 insertions(+), 15 deletions(-) - -commit 1ea36507f9c9f163b6772268046e7560d0c00dbc -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 29 22:47:19 2008 +0200 - - make findModifier static - - poppler/GlobalParams.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit be9961571dbfabb982e6f69abd3bbc98fa971864 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 29 21:48:09 2008 +0200 - - make variables not used outside static - - utils/pdftohtml.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit b157064a85350da6ea9c4f46e965e45ebc59d227 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 29 21:43:23 2008 +0200 - - constify setPSPaperSize - - utils/pdftops.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ee57ead8a6f34fa8de044399e5912395e0f3a425 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 29 21:37:57 2008 +0200 - - constify argDesc arrays - - Gives me binaries 2KB smaller (in total) in release build - - utils/parseargs.c | 18 +++++++++--------- - utils/parseargs.h | 4 ++-- - utils/pdffonts.cc | 2 +- - utils/pdfimages.cc | 2 +- - utils/pdfinfo.cc | 2 +- - utils/pdftoabw.cc | 2 +- - utils/pdftohtml.cc | 2 +- - utils/pdftoppm.cc | 2 +- - utils/pdftops.cc | 2 +- - utils/pdftotext.cc | 2 +- - 10 files changed, 19 insertions(+), 19 deletions(-) - -commit 9f93d9eb464877e0d23dcf205295da9162f03253 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 29 20:45:01 2008 +0200 - - make psOpNames static - - Makes my release build 64 bytes smaller - - poppler/Function.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 29e3e779c68371b7c4aadcf68ee0712046f39c6d -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 26 23:47:01 2008 +0200 - - remember to call the base implementation here - - qt4/demos/optcontent.cpp | 1 + - 1 file changed, 1 insertion(+) - -commit a188f3cd36775d78ace5b5d62c8ab7c059b3b2b1 -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 26 23:42:09 2008 +0200 - - reset the current page to 0, when closing a document - - qt4/demos/viewer.cpp | 1 + - 1 file changed, 1 insertion(+) - -commit 7eca6da6436ffc1c41cfed1a07be4dafa1172463 -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 26 23:41:45 2008 +0200 - - no need to manually disconnect from the model, as it will be deleted - by the document anyway - - qt4/demos/optcontent.cpp | 1 - - 1 file changed, 1 deletion(-) - -commit 6cddda7f3c3b8ddb95e6aba1b234a27c4454c23d -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 26 22:41:59 2008 +0200 - - sync updateFont() with SplashOutputDev - - poppler/ArthurOutputDev.cc | 75 - ++++++++++++++++++++++++++++++++++++---------- - 1 file changed, 59 insertions(+), 16 deletions(-) - -commit ddc7c1f8c24762bae615e7dec92e92a58c827478 -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 26 18:12:51 2008 +0200 - - construct AnnotPolygon for Polygon and PolyLine annotations - - poppler/Annot.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit f9c7e8037b7165b6271ce7aea0d315053c4d66a5 -Merge: 59d33d8 f5fec4f -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 26 18:09:59 2008 +0200 - - Merge branch 'master' of - ssh://pino@git.freedesktop.org/git/poppler/poppler - -commit 59d33d8e99673f73ccf2ad9a62bd25fca51f0eb8 -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 26 17:56:42 2008 +0200 - - use the base implementation to update all the states - - poppler/ArthurOutputDev.cc | 11 +---------- - 1 file changed, 1 insertion(+), 10 deletions(-) - -commit 45d2a9529bf241554c59437118cb8c705554dc27 -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 26 17:55:39 2008 +0200 - - Set the font antialiasing from the painter settings, instead of the - global settings. - - poppler/ArthurOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 5faa72fd70e0d85268e807a8b870d80dda9189a9 -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 26 17:53:28 2008 +0200 - - Get the font and painter matrices, and reenable the font drawing. - - poppler/ArthurOutputDev.cc | 28 +++++++++++++++++++++------- - 1 file changed, 21 insertions(+), 7 deletions(-) - -commit f5fec4fdedd8d316b19968545e447e2036a1bb47 -Author: Kees Cook <kees@outflux.net> -Date: Wed Apr 23 19:53:03 2008 +0200 - - provide type-checking for union pointer accesses - - poppler/Object.h | 68 - +++++++++++++++++++++++++++++++++++--------------------- - 1 file changed, 43 insertions(+), 25 deletions(-) - -commit a567c921ce538616f4ba0b7933086ef5a8ab0f55 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Tue Apr 22 23:09:10 2008 +0200 - - Little change to avoid AnnotWidget crashing when they aren't related - to FormWidgets. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 19 ++++++++++--------- - 1 file changed, 10 insertions(+), 9 deletions(-) - -commit 73798c95b8a4c0504e9246e6f73fd31f812ad6fa -Author: Albert Astals Cid <tsdgeos@bluebox.(none)> -Date: Mon Apr 21 19:56:52 2008 +0200 - - Link to pthread when needed - - Should fix bug 15625 - - configure.ac | 2 + - m4/acx_pthread.m4 | 280 - ++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Makefile.am | 4 + - 3 files changed, 286 insertions(+) - -commit 6c248bdad77235a45402d9693a0b822cc208b6b9 -Author: Pino Toscano <pino@kde.org> -Date: Sun Apr 20 18:32:59 2008 +0200 - - the dtor should be virtual - - qt4/src/poppler-converter-private.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 68dba1a452ca70add5b05ab8e2adab838bc2cb73 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Apr 20 16:21:10 2008 +0200 - - if ncand is a Guint cand should be one too - - poppler/CMap.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 0b91eb19f5a3d07b625ee5188f1fcb4b4b1544ea -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Apr 20 16:17:50 2008 +0200 - - Unused var-- - - poppler/GfxFont.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 1ed3cc40987b691319fd9f1a30296d80de5732fd -Author: Pino Toscano <pino@kde.org> -Date: Wed Apr 16 15:45:45 2008 +0200 - - fix border style conversion - - qt4/src/poppler-page.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 7c8feb4e3627bde2052a7e536d2d49d1cbbce8ee -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 15 21:57:31 2008 +0200 - - Hack to "support" 16 bits images - - Everywhere we assume a component fits in 8 bits, with this hack - we treat 16 bit images as 8 bit ones until it's fixed correctly. - Fixes http://bugs.kde.org/show_bug.cgi?id=158165 - - poppler/GfxState.cc | 6 ++++++ - poppler/Stream.cc | 9 +++++++++ - 2 files changed, 15 insertions(+) - -commit f338a9ded5d42dd65853c5c7bbe27f6724096416 -Author: Pino Toscano <pino@kde.org> -Date: Sun Apr 13 21:41:51 2008 +0200 - - [Qt4] convert the sound annotations - - qt4/src/poppler-page.cc | 16 ++++++++++++++-- - 1 file changed, 14 insertions(+), 2 deletions(-) - -commit 733d51fca04ee682fed2242f868edd545f3755fa -Author: Pino Toscano <pino@kde.org> -Date: Sun Apr 13 21:38:25 2008 +0200 - - [Qt4] First version of a SoundAnnotation. - - qt4/src/poppler-annotation.cc | 87 - +++++++++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-annotation.h | 30 ++++++++++++++- - 2 files changed, 116 insertions(+), 1 deletion(-) - -commit feb1ea091111bd7292879c465590acfd7671c876 -Author: Pino Toscano <pino@kde.org> -Date: Sun Apr 13 21:36:26 2008 +0200 - - First version of AnnotSound. - - poppler/Annot.cc | 37 ++++++++++++++++++++++++++++++++++++- - poppler/Annot.h | 26 ++++++++++++++++++++++++++ - 2 files changed, 62 insertions(+), 1 deletion(-) - -commit ec2cf81edf1b2c6707de4d30316ff5f5e24534d4 -Author: Pino Toscano <pino@kde.org> -Date: Sun Apr 13 18:31:21 2008 +0200 - - [Qt4] convert the file attachment annotations - - qt4/src/poppler-page.cc | 15 +++++++++++++-- - 1 file changed, 13 insertions(+), 2 deletions(-) - -commit 9fa2e96c96d365ae67859545ebd635d726784fca -Author: Pino Toscano <pino@kde.org> -Date: Sun Apr 13 18:29:00 2008 +0200 - - [Qt4] Initial version of FileAttachmentAnnotation - - qt4/src/poppler-annotation.cc | 88 - +++++++++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-annotation.h | 29 +++++++++++++- - 2 files changed, 116 insertions(+), 1 deletion(-) - -commit 5899aff11f94e707654574e830e0757b1df558d4 -Author: Pino Toscano <pino@kde.org> -Date: Sun Apr 13 10:50:39 2008 +0200 - - [Qt4] Read the annotations from the core, instead of own parsing. - - Almost all the data are converted correctly, the results seem to be - the same. - Added TODOs in the few parts (not essential) I was not able to figure - out how to convert, yet. - Covert also the Caret annotations. - - qt4/src/poppler-annotation-helper.h | 2 +- - qt4/src/poppler-page.cc | 851 - +++++++++++++++++------------------- - 2 files changed, 393 insertions(+), 460 deletions(-) - -commit 40a12793c5ccea206d79e0c17e2f2d0cf74bb4f3 -Author: Pino Toscano <pino@kde.org> -Date: Sun Apr 13 02:21:55 2008 +0200 - - add getters for the AnnotPolygon properties - - poppler/Annot.h | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit 9311f75d4c3da991efb8afd00701a0ce1cbae1b0 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Sun Apr 13 01:52:36 2008 +0200 - - Almost full AnnotPolygon support. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 99 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Annot.h | 37 +++++++++++++++++++++ - 2 files changed, 136 insertions(+) - -commit 01aa052ed761a4ada471d196985825986bb58627 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Sun Apr 13 01:13:49 2008 +0200 - - Extend AnnotPath behaviour to include cooordinate array parsing. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 96 - ++++++++++++++++++++++++++++++-------------------------- - poppler/Annot.h | 4 ++- - 2 files changed, 55 insertions(+), 45 deletions(-) - -commit ca52830e9519ae7b778f98e5c2547daef7da5f09 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Sun Apr 13 00:54:13 2008 +0200 - - Added OptionalContent support to Annots. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 9 +++------ - poppler/Annot.h | 5 +++-- - 2 files changed, 6 insertions(+), 8 deletions(-) - -commit 4b87196b7829c87d15af4e8b4138ca97548fb519 -Author: Pino Toscano <pino@kde.org> -Date: Sun Apr 13 00:18:24 2008 +0200 - - Isolate the embedded file reading logic into a new EmbFile - constructor. - - This way, it can be shared and reused in various places (Catalog, - AnnotFileAttachment, etc). - - poppler/Catalog.cc | 205 - +++++++++++++++++++++++++++++------------------------ - poppler/Catalog.h | 1 + - 2 files changed, 112 insertions(+), 94 deletions(-) - -commit 45b407e51905948690065749085a4af1cbb29a8e -Author: Pino Toscano <pino@kde.org> -Date: Sun Apr 13 00:14:38 2008 +0200 - - correctly get the FileSpec dictionary - - poppler/Annot.cc | 4 +++- - poppler/Annot.h | 2 +- - 2 files changed, 4 insertions(+), 2 deletions(-) - -commit c3aa3a97d9c553ea7976741d798901352fb5381c -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 12 22:45:57 2008 +0200 - - properly initialize an AnnotPath - - poppler/Annot.cc | 9 ++------- - 1 file changed, 2 insertions(+), 7 deletions(-) - -commit a3406fb2ace1390db1c181823a7bfc66c9174d98 -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 12 22:40:42 2008 +0200 - - properly dispose the memory of the ink lists - - poppler/Annot.cc | 13 ++++++++++++- - poppler/Annot.h | 1 + - 2 files changed, 13 insertions(+), 1 deletion(-) - -commit 0dad70e2d12e8b587cab8ce2d914c81c6897a1d1 -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 12 22:15:35 2008 +0200 - - make AnnotInk working. - - - get the point indexes in the correct way - - dispose with free what you allocate with malloc - - fix logic when checking for an even number of points - - poppler/Annot.cc | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit 77404e24ea1e175fc9b55097dc5b35cc34760659 -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 12 21:08:54 2008 +0200 - - a length is an int - - poppler/Annot.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit bc2b2ffd2144f951c311e968fba4bc50b7c43ff3 -Merge: cd5afe6 bacc1dd -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Sat Apr 12 17:40:49 2008 +0200 - - Fixed merging conflict. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - -commit cd5afe6d9eca687ee224ff7680a8cba28d81a36d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 12 00:44:08 2008 +0200 - - Do not take into account Colorspace resource subdictionary for - image XObjects - - Fixes bug 15125 - The motivation under that change is on section 4.5.2 of the spec: - Certain objects, such as image XObjects, specify a - color space as an explicit parameter, often associated with the - key ColorSpace. - In this case, the color space array or name is always defined - directly as a PDF - object, not by an entry in the ColorSpace resource - subdictionary. This conven- - tion also applies when color spaces are defined in terms of other - color spaces. - - poppler/Gfx.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit bacc1dd9f37ff19c5e54878a5b08e7d734584bbf -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 12 17:20:09 2008 +0200 - - Read the "in reply to" reference as such, without reading the - associated annotation dictionary. - - poppler/Annot.cc | 10 ++++------ - poppler/Annot.h | 4 ++-- - 2 files changed, 6 insertions(+), 8 deletions(-) - -commit ffe09454a0948a6107bcc38f23ba2068151c547d -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Sat Apr 12 17:17:59 2008 +0200 - - Initial Annot3D parsing a few general improvements. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 130 - +++++++++++++++++++++++++++++++++++++++++++++++++++---- - poppler/Annot.h | 84 +++++++++++++++++++++++++++++------ - 2 files changed, 193 insertions(+), 21 deletions(-) - -commit 8757c577241dda31bc59c7d1c208c159ad428877 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Sat Apr 12 10:38:07 2008 +0200 - - AnnotFileAttachment support. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 38 ++++++++++++++++++++++++++++++++++++-- - poppler/Annot.h | 25 +++++++++++++++++++++++++ - 2 files changed, 61 insertions(+), 2 deletions(-) - -commit 36989658149fc9e5e8a049ce070a102f35b7bddc -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Sat Apr 12 09:55:26 2008 +0200 - - AnnotInk support. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 113 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Annot.h | 45 ++++++++++++++++++++++ - 2 files changed, 158 insertions(+) - -commit 464b171d0e9b989196c287f2ee4dfbbc14212aa9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 12 00:44:08 2008 +0200 - - Do not take into account Colorspace resource subdictionary for - image XObjects - - Fixes bug 15125 - The motivation under that change is on section 4.5.2 of the spec: - Certain objects, such as image XObjects, specify a - color space as an explicit parameter, often associated with the - key ColorSpace. - In this case, the color space array or name is always defined - directly as a PDF - object, not by an entry in the ColorSpace resource - subdictionary. This conven- - tion also applies when color spaces are defined in terms of other - color spaces. - - poppler/Gfx.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 42db4890e8295aaec5a1be12d1414fc0a9048550 -Author: Chris Wilson <chris@chris-wilson.co.uk> -Date: Thu Mar 27 10:52:22 2008 +0000 - - Do not call FT_Done_Face on a live cairo_font_face_t. - - Currently CairoFont calls FT_Done_Face on its deletion, but the - FT_Face - is usually still in use within cairo. This causes a failure later when - cairo tries to create a glyph from its cairo_font_face_t. - - From http://bugs.freedesktop.org/show_bug.cgi?id=15216: - ==13745== Invalid read of size 4 - ==13745== at 0x51BE572: FT_Load_Glyph (ftobjs.c:549) - ==13745== by 0x4A24921: _cairo_ft_scaled_glyph_init - (cairo-ft-font.c:1922) - ==13745== by 0x4A117AB: _cairo_scaled_glyph_lookup - (cairo-scaled-font.c:1674) - ==13745== by 0x4A12A5A: _cairo_scaled_font_glyph_device_extents - (cairo-scaled-font.c:1124) - ==13745== by 0x4A21ECD: _cairo_analysis_surface_show_glyphs - (cairo-analysis-surface.c:516) - ==13745== by 0x4A144DC: _cairo_surface_show_glyphs - (cairo-surface.c:2086) - ==13745== by 0x4A1FCC8: _cairo_meta_surface_replay_internal - (cairo-meta-surface.c:816) - ==13745== by 0x4A214B1: _paint_page (cairo-paginated-surface.c:299) - ==13745== by 0x4A2171E: _cairo_paginated_surface_show_page - (cairo-paginated-surface.c:445) - ==13745== by 0x4A14BDF: cairo_surface_show_page - (cairo-surface.c:1702) - ==13745== by 0x49FF661: cairo_show_page (cairo.c:2155) - ==13745== by 0xA267D97: - pdf_document_file_exporter_end_page(_EvFileExporter*) - (ev-poppler.cc:1753) - ==13745== Address 0x55c5630 is 88 bytes inside a block of size - 552 free'd - ==13745== at 0x402269C: free (vg_replace_malloc.c:326) - ==13745== by 0x51B7ABC: ft_free (ftsystem.c:158) - ==13745== by 0x51BB319: ft_mem_free (ftutil.c:171) - ==13745== by 0x51BC318: destroy_face (ftobjs.c:856) - ==13745== by 0x51BC3B2: FT_Done_Face (ftobjs.c:1972) - ==13745== by 0x4363704: CairoFont::~CairoFont() - (CairoFontEngine.cc:251) - ==13745== by 0x436401D: CairoFontEngine::getFont(GfxFont*, XRef*) - (CairoFontEngine.cc:335) - ==13745== by 0x4366915: CairoOutputDev::updateFont(GfxState*) - (CairoOutputDev.cc:318) - ==13745== by 0x5093BF1: Gfx::opShowText(Object*, int) (Gfx.cc:3073) - ==13745== by 0x508F901: Gfx::execOp(Object*, Object*, int) - (Gfx.cc:726) - ==13745== by 0x50906FF: Gfx::go(int) (Gfx.cc:594) - ==13745== by 0x5090C96: Gfx::display(Object*, int) (Gfx.cc:557) - - The solution is to release the reference to the cairo_font_face_t upon - destruction of the CairoFont, and then to release the FT_Face from the - destroy notify of the cairo_font_face_t. - - poppler/CairoFontEngine.cc | 19 +++++++++---------- - 1 file changed, 9 insertions(+), 10 deletions(-) - -commit 5f60843824582ece36d806508ec388330ddee854 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Tue Apr 8 00:30:57 2008 +0200 - - Added AnnotCoord support. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 64 - ++++++++++++++++++---------------------------------- - poppler/Annot.h | 69 - ++++++++++++++++++++++++++------------------------------ - 2 files changed, 54 insertions(+), 79 deletions(-) - -commit a6f70f465a3e6719d63cefbe3c27bae015be43c1 -Author: Pino Toscano <pino@kde.org> -Date: Sun Apr 6 13:12:01 2008 +0200 - - add getters for the coordinates in an AnnotLine - - poppler/Annot.h | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 1d83d6edf9a843335e37a4d1e0e0dd71eb23d93b -Author: Pino Toscano <pino@kde.org> -Date: Sun Apr 6 12:24:42 2008 +0200 - - [Qt4] the caret symbol is an enum value, now - - qt4/src/poppler-annotation.cc | 35 ++++++++++++++++++++++++++++------- - qt4/src/poppler-annotation.h | 7 +++++-- - 2 files changed, 33 insertions(+), 9 deletions(-) - -commit 229d991a3258cb9b56f5e00f2deb3c976253cf68 -Author: Pino Toscano <pino@kde.org> -Date: Sun Apr 6 12:23:04 2008 +0200 - - the caret symbol does not seem to allow additional values, so convert - it to an enum - - poppler/Annot.cc | 11 +++++++---- - poppler/Annot.h | 9 +++++++-- - 2 files changed, 14 insertions(+), 6 deletions(-) - -commit fc24500ddd9182f97d23c46eaafc6be79a6721eb -Author: Pino Toscano <pino@kde.org> -Date: Sun Apr 6 11:43:49 2008 +0200 - - propetly initialise a couple of members; leak less - - poppler/ArthurOutputDev.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 9409de1e7c5b3770c7ef00c01ee376953dd532a5 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Sun Apr 6 01:38:25 2008 +0200 - - Changed AnnotFreeText RD field to the new parseDiffRectangle. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 35 ++--------------------------------- - 1 file changed, 2 insertions(+), 33 deletions(-) - -commit 28c5ee2e9fc2a24d2f2efb3d74d5cf882a106239 -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 5 23:19:33 2008 +0200 - - typo fix - - poppler/Annot.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ed02769688466ca72bf35d4223c3822a1245604b -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 5 19:36:21 2008 +0200 - - read the destination of a link annotation - - poppler/Annot.cc | 5 ++++- - poppler/Annot.h | 4 ++-- - 2 files changed, 6 insertions(+), 3 deletions(-) - -commit ca31bf12a9d70bac88e457f7799e9935aba58640 -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 5 16:48:53 2008 +0200 - - variable forgotten in the copy&paste... - - qt4/src/poppler-annotation.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 4168daa141b76e5fcd07d046aca8dac2f3037ff9 -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 5 16:34:12 2008 +0200 - - [Qt4] deserialize also CaretAnnotation's - - qt4/src/poppler-annotation.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit b55bcc2aa95825863bef23ab96364b350a49949d -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 5 16:31:31 2008 +0200 - - [Qt4] first version of a CaretAnnotation. - - qt4/src/poppler-annotation.cc | 80 - +++++++++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-annotation.h | 25 +++++++++++++- - 2 files changed, 104 insertions(+), 1 deletion(-) - -commit 4c9a02b7e49666efe10fdc16e7a03d8d520b65ec -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 5 16:01:58 2008 +0200 - - First version of AnnotCaret. - - poppler/Annot.cc | 36 +++++++++++++++++++++++++++++++++++- - poppler/Annot.h | 22 ++++++++++++++++++++++ - 2 files changed, 57 insertions(+), 1 deletion(-) - -commit d260fe9e514c667b66969b982119429cc922eb07 -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 5 15:54:29 2008 +0200 - - isolate the code for parsing a "difference rectangle" in an own - function - - poppler/Annot.cc | 54 - +++++++++++++++++++++++++++++++----------------------- - 1 file changed, 31 insertions(+), 23 deletions(-) - -commit 760833e409c122c0a61f7c87fd3133eebc10b402 -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 5 15:36:43 2008 +0200 - - First version of AnnotGeometry. - - poppler/Annot.cc | 77 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- - poppler/Annot.h | 24 ++++++++++++++++++ - 2 files changed, 99 insertions(+), 2 deletions(-) - -commit 95d9d2362534c0524ad0448818b2d69b0909d482 -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 5 03:23:00 2008 +0200 - - finally, load the QuadPoints correctly - - when checking the validity of the coordinate, do the comparison just - with the proper one (either X or Y); - free the "point" object after each iteration - - poppler/Annot.cc | 11 ++++++++--- - 1 file changed, 8 insertions(+), 3 deletions(-) - -commit af1ffcbcec1730332d11f8da4a7ddac833b22408 -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 5 02:54:00 2008 +0200 - - More robust reading of QuadPoints (reset the allocated memory, - use the heap) - - poppler/Annot.cc | 7 +++---- - 1 file changed, 3 insertions(+), 4 deletions(-) - -commit 68fd98d69bac20282665cf6b824da30c3b310f0b -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 5 02:51:41 2008 +0200 - - Really implement AnnotTextMarkup. - - poppler/Annot.cc | 29 +++++++++++++++++++++++++---- - poppler/Annot.h | 2 +- - 2 files changed, 26 insertions(+), 5 deletions(-) - -commit 69a2ecfaf8f8cffd3027db5c3cc88c41413e42f1 -Author: Pino Toscano <pino@kde.org> -Date: Sat Apr 5 01:38:28 2008 +0200 - - Add the Stamp annotation type. - - poppler/Annot.cc | 28 +++++++++++++++++++++++++++- - poppler/Annot.h | 20 ++++++++++++++++++++ - 2 files changed, 47 insertions(+), 1 deletion(-) - -commit 97be4332818bcf58461816be995d88926809a4e5 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Fri Apr 4 23:49:12 2008 +0200 - - Updated glib bindings. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - glib/demo/annots.c | 32 +++++--------------------------- - glib/poppler-annot.cc | 27 +++++---------------------- - glib/poppler-annot.h | 13 +------------ - 3 files changed, 11 insertions(+), 61 deletions(-) - -commit 5caac407cdaf58621ac27e5561b31a995404ccb3 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Fri Apr 4 23:36:46 2008 +0200 - - Fixed icon name in AnnotText. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 25 ++++++------------------- - poppler/Annot.h | 15 +++------------ - 2 files changed, 9 insertions(+), 31 deletions(-) - -commit 0b714a61383da1b62daf2a60e3f6fcda09b4e9f2 -Author: Adam Batkin <adam@batkin.net> -Date: Thu Apr 3 20:02:52 2008 +0200 - - FindFirstFile returns INVALID_HANDLE_VALUE and not NULL on error - - goo/gfile.cc | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - -commit be765f27cc5430d9bb2a3e113eb245d67c20a376 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Mar 31 12:37:33 2008 +0200 - - [glib] Fix a crash in outline demo due to page_num == dest_page_num - - 1 - - glib/demo/utils.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit e991e9ac6fcc0b6928b96fe8326eebcf3cb720ca -Author: Albert Astals Cid <tsdgeos@localhost.(none)> -Date: Sat Mar 29 13:25:52 2008 +0100 - - Add the export macro - - qt4/src/poppler-page-transition.h | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit b70ca35dce6da6efdff254c11a63de4f44228278 -Author: Albert Astals Cid <tsdgeos@localhost.(none)> -Date: Sat Mar 29 00:30:31 2008 +0100 - - Duplicate page-transition files on qt4 - - qt4/src/CMakeLists.txt | 4 +- - qt4/src/Makefile.am | 4 +- - qt4/src/poppler-page-transition-private.h | 28 ++++++ - qt4/src/poppler-page-transition.cc | 95 +++++++++++++++++++ - qt4/src/poppler-page-transition.h | 146 - ++++++++++++++++++++++++++++++ - 5 files changed, 273 insertions(+), 4 deletions(-) - -commit b5312785063235cef7584ab6a5d198fb72de0988 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Wed Mar 26 23:56:49 2008 +0100 - - Improved glib annot demo. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - glib/demo/annots.c | 314 - ++++++++++++++++++++++++++++++++++++++++++++++++----- - 1 file changed, 289 insertions(+), 25 deletions(-) - -commit 7cc8fd70f68d2cdab7ab83a0ecf6c8896c971d62 -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 26 21:03:34 2008 +0100 - - remove damn error - - qt4/src/poppler-page.cc.orig | 1317 - ------------------------------------------ - 1 file changed, 1317 deletions(-) - -commit 7a47ff3b54678a3de6964d25050e02186484f39a -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 26 21:00:32 2008 +0100 - - [Qt4] Add support for JavaScript links, and create them when present. - - qt4/src/poppler-link.cc | 36 ++ - qt4/src/poppler-link.h | 32 +- - qt4/src/poppler-page.cc | 7 + - qt4/src/poppler-page.cc.orig | 1317 - ++++++++++++++++++++++++++++++++++++++++++ - 4 files changed, 1391 insertions(+), 1 deletion(-) - -commit a6f2c10ee01ee62ae945b50f6b6eae380377fe03 -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 26 20:59:21 2008 +0100 - - [Qt4] Read the document-level JavaScript scripts. - - qt4/src/poppler-document.cc | 15 +++++++++++++++ - qt4/src/poppler-qt4.h | 8 ++++++++ - 2 files changed, 23 insertions(+) - -commit b8a471e55b998836c09c65ff736afdef8ac55189 -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 26 20:56:01 2008 +0100 - - Add support for JavaScript actions, and read them when found. - - poppler/Link.cc | 33 +++++++++++++++++++++++++++++++++ - poppler/Link.h | 23 +++++++++++++++++++++++ - 2 files changed, 56 insertions(+) - -commit 2fd85dc1b8b2ababadfc60e285c08a844737e4bb -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 26 20:53:42 2008 +0100 - - Read the JavaScript codes in the NameTree of the Catalog. - - poppler/Catalog.cc | 39 +++++++++++++++++++++++++++++++++++++++ - poppler/Catalog.h | 7 +++++++ - 2 files changed, 46 insertions(+) - -commit 312f14f5b7be1f0d62620477222919423c3869e0 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Mar 26 20:05:31 2008 +0100 - - compile++ - - fofi/FoFiBase.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 5bd750062e1fb136f77a55d1f35b2d6fabaad1b3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Mar 26 19:42:43 2008 +0100 - - update version - - CMakeLists.txt | 2 +- - configure.ac | 2 +- - msvc/config.h | 6 +++--- - qt4/src/Doxyfile | 2 +- - 4 files changed, 6 insertions(+), 6 deletions(-) - -commit 10d4a8b9aed51902157c04d9deea0e99d829c4f6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Mar 26 19:42:36 2008 +0100 - - fill news - - NEWS | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -commit 2069826d61ebd527768b6455689276c0a8288085 -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 26 16:05:06 2008 +0100 - - missing break - - qt4/src/poppler-page.cc | 1 + - 1 file changed, 1 insertion(+) - -commit d6a0c6a6803a03f402c2dcde41c6195e951470ba -Author: Pino Toscano <pino@kde.org> -Date: Wed Mar 26 15:50:39 2008 +0100 - - initialize posterStream to avoid crashing later - - poppler/Movie.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 0be811b3ad86b1cb14be94a017e70c65b8e64730 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Mar 25 22:59:22 2008 +0100 - - Don't end up in an infinite recursive loop in case resObj dict is - the same we are already in - - poppler/FontInfo.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 0222c6ceb0fcf1d7c4422691a68a035a558ad614 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Mar 24 17:14:07 2008 +0100 - - fix build when using cmake, not sure it's completely ok, but at - least i can compile - - CMakeLists.txt | 1 + - cmake/modules/FindGTK.cmake | 23 ++++++++++++++++------- - config.h.cmake | 3 +++ - glib/CMakeLists.txt | 17 +++++++++++------ - glib/poppler-page.cc | 2 +- - glib/test-poppler-glib.cc | 2 +- - 6 files changed, 33 insertions(+), 15 deletions(-) - -commit 3e4164f2db69358adf07596195842dd00458b621 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Mar 24 15:10:31 2008 +0100 - - fix some cmake HAVE_foo - - CMakeLists.txt | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit 22f615aee488cc363a078330861e80f389f47061 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Sun Mar 23 13:22:07 2008 +0100 - - Fixed wrong functions. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - glib/poppler-annot.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit cccfe42ed9c53d27cf6a1403ae55bf34a053012d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Mar 22 19:12:05 2008 +0100 - - Fix rm line not to error when no *moc file is present - - qt4/src/Makefile.am | 2 +- - qt4/tests/Makefile.am | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit e60d39ba0e8b9742106a0c9b1385b1c907729c3f -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Mar 22 19:11:17 2008 +0100 - - Fix rm line not to error if no *moc file is present - - qt4/demos/Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit d9d52e622c6b28a9941168bb73839ec335ca7232 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Mar 22 19:10:40 2008 +0100 - - Fix configure to not require gdk when we are on try mode - - configure.ac | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 9b8809298dd16cdbffcc12b6db8e274578934063 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Mar 22 15:49:02 2008 +0100 - - It's really only an error if < 0 - - poppler/PDFDoc.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 0fb1e697cc4100ce23298141c8b5829273872423 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Mar 22 15:46:44 2008 +0100 - - remove unneeded variable - - poppler/PDFDoc.cc | 1 - - 1 file changed, 1 deletion(-) - -commit 3404cb626ee9b4520d6fe601e07560745a4cb42a -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Mar 22 15:44:50 2008 +0100 - - Remove OutStream::reset since noone uses it - - This way we have a fseek less to care about if worked or not - - poppler/Stream.cc | 5 ----- - poppler/Stream.h | 5 ----- - qt4/src/poppler-qiodeviceoutstream-private.h | 1 - - qt4/src/poppler-qiodeviceoutstream.cc | 5 ----- - 4 files changed, 16 deletions(-) - -commit 066595dd06c930997d5ec65a06c822616af9baa0 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Mar 22 15:43:07 2008 +0100 - - Check the document stream is seekable when opening it - - Fixes bug 14126 - - poppler/PDFDoc.cc | 7 +++++++ - 1 file changed, 7 insertions(+) - -commit 23b6475463f8973b5ac83bb21a6b7b6000cc435b -Author: Ed Avis <eda@waniasset.com> -Date: Sat Mar 22 13:55:59 2008 +0100 - - Check for fseek return values - - fofi/FoFiBase.cc | 14 ++++++++++++-- - poppler/GfxFont.cc | 12 ++++++++++-- - 2 files changed, 22 insertions(+), 4 deletions(-) - -commit b33bb282e45cf1a083cfbb13603ac465d386c28d -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Fri Mar 21 13:53:21 2008 +0100 - - Fixed poppler glib public api. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - glib/poppler-annot.cc | 4 ++-- - glib/poppler-annot.h | 2 +- - 2 files changed, 3 insertions(+), 3 deletions(-) - -commit 371932f413d570d7784c668f30834d3d92d7aa80 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Mar 20 11:44:32 2008 +0100 - - [glib] Remove unused variable. - - glib/poppler-document.cc | 1 - - 1 file changed, 1 deletion(-) - -commit 21fa476ac384256c15a954b708e009f2b336b06f -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Mar 20 11:42:32 2008 +0100 - - [glib] Do not cache image_dev in poppler page. - - Thanks to Kouhei Sutou who caught the problem. - - glib/poppler-page.cc | 60 - +++++++++++++++++++++++++++-------------------- - glib/poppler-private.h | 3 --- - glib/test-poppler-glib.cc | 9 ++++++- - 3 files changed, 43 insertions(+), 29 deletions(-) - -commit 22cd70d8fc308fb8b19d36d0172014ba532230fb -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Mar 19 21:52:14 2008 +0100 - - poppler_annot_markup_get_opacity returns a double so use %f - - glib/demo/annots.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit b9a5fd4671638caa91f8a389be278d993391f499 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Mar 19 21:28:49 2008 +0100 - - updated by gtk-doc - - glib/reference/tmpl/poppler-action.sgml | 1 + - glib/reference/tmpl/poppler.sgml | 3 +++ - 2 files changed, 4 insertions(+) - -commit b7e0b740578ea1e84ac0ef850b5a03c66b2863e3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Mar 19 21:28:01 2008 +0100 - - Fill 0.7.3 news - - NEWS | 7 +++++++ - 1 file changed, 7 insertions(+) - -commit 3adaff1dad8127fdd06653cf49196027ad414a08 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Mar 19 21:27:46 2008 +0100 - - Bump version to 0.7.3 - - CMakeLists.txt | 2 +- - configure.ac | 2 +- - msvc/config.h | 6 +++--- - qt4/src/Doxyfile | 2 +- - 4 files changed, 6 insertions(+), 6 deletions(-) - -commit 52dd710b63911be2d8c960de0232c497c35ecac8 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Mar 19 18:35:35 2008 +0100 - - [glib] Update outline and links demos to the new POPPLER_ACTION_NONE - - glib/demo/utils.c | 3 +++ - 1 file changed, 3 insertions(+) - -commit 6a22f0a20df38156c06e8ba10649e0828a1da102 -Author: Eugen Dedu <Eugen.Dedu@pu-pm.univ-fcomte.fr> -Date: Wed Mar 19 18:32:48 2008 +0100 - - [glib] Consider no action as an action of type None instead of Unknown - - glib/poppler-action.cc | 2 +- - glib/poppler-action.h | 1 + - 2 files changed, 2 insertions(+), 1 deletion(-) - -commit 185d5818fd546f85934b041d5b0cdcdf1849b1dc -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Mar 18 20:08:21 2008 +0100 - - Improve error handling when creating a document - - glib/poppler-document.cc | 40 ++++++++++++++++++++++++++++------------ - glib/poppler.h | 5 ++++- - 2 files changed, 32 insertions(+), 13 deletions(-) - -commit 9bba2748985049515bfd9c9b44f26b92fa704078 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Mar 15 01:11:39 2008 +0100 - - Some more free - - poppler/OptionalContent.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -commit bfc308935fa138e27c4d2ad0e1c1cad20eba8e8a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Mar 15 01:05:32 2008 +0100 - - Use error instead of printf - - poppler/OptionalContent.cc | 15 ++++++++------- - 1 file changed, 8 insertions(+), 7 deletions(-) - -commit 998b1523ee653c1585f03b4a580e0d95ba694aca -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Mar 15 01:02:31 2008 +0100 - - Some free - - poppler/OptionalContent.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit c65a66a82259f547927cbb918611bcf4a8e264b2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Mar 14 20:29:53 2008 +0100 - - xx0 is non exclusive so that should be < not <= - - Fixes several warnings about writes on bad places - - splash/SplashXPathScanner.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit bd2272f3079319d1c05ca93f7fb6eb0a5370b938 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Mar 14 19:52:04 2008 +0100 - - Fix "Make sure we don't draw outside the bitmap on Splash::fillGlyph2" - when painting with no aa - - Fixes bug 15009 - - splash/Splash.cc | 12 ++++++++---- - 1 file changed, 8 insertions(+), 4 deletions(-) - -commit 5bf8d864e68854f0855e07fb67aa124e06c739cd -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Mar 12 22:48:07 2008 +0100 - - fix build - - glib/reference/Makefile.am | 1 + - 1 file changed, 1 insertion(+) - -commit d0be5c86dcd3310062d820b3515c31e4720af2ca -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Mar 12 22:40:59 2008 +0100 - - Update version to 0.7.2 and fill NEWS - - CMakeLists.txt | 2 +- - NEWS | 20 ++++++++++++++++++++ - configure.ac | 2 +- - msvc/config.h | 6 +++--- - qt4/src/Doxyfile | 2 +- - 5 files changed, 26 insertions(+), 6 deletions(-) - -commit 0b2ecf39572821a99374e6acec7c1bd438911bbc -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Mar 12 22:38:57 2008 +0100 - - update soname here too - - glib/CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit f5065016b168e4896e2fe774cd22bbd900849b52 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Mar 12 22:06:53 2008 +0100 - - Make GDK dependency option for glib bindings - - Fixes bug #13719. - - configure.ac | 45 ++- - glib/Makefile.am | 7 +- - glib/demo/page.c | 88 +++++- - glib/demo/render.c | 4 + - glib/poppler-action.h | 1 - - glib/poppler-annot.cc | 26 +- - glib/poppler-annot.h | 2 +- - glib/poppler-document.h | 2 - - glib/poppler-features.h.in | 1 + - glib/poppler-page.cc | 695 - ++++++++++++++++++++++++++------------------- - glib/poppler-page.h | 76 +++-- - glib/poppler.h | 2 +- - glib/test-poppler-glib.cc | 2 +- - 13 files changed, 610 insertions(+), 341 deletions(-) - -commit 46d4fab82332e71d0b68c0a8deeac78f2201ed14 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Mar 12 20:35:33 2008 +0100 - - Increment version of libpoppler and libpoppler-qt4 - - CMakeLists.txt | 2 +- - poppler/Makefile.am | 2 +- - qt4/src/CMakeLists.txt | 2 +- - qt4/src/Makefile.am | 2 +- - 4 files changed, 4 insertions(+), 4 deletions(-) - -commit 550c1fc73a6d2af65728751fd0b59ccc7110fa8b -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Mar 12 20:34:48 2008 +0100 - - Init to false updated field of XRefEntries plus indenting fixes - - poppler/XRef.cc | 11 ++++++----- - 1 file changed, 6 insertions(+), 5 deletions(-) - -commit 6a671686c6265ecdb4c48f04392de9c56d4e0936 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Wed Mar 12 21:43:12 2008 +1030 - - Fix regression in cairo output when transforming ctm - - The commit: - ec01926e5a9dc16e200060497c43e79a1623698d "Avoid setting a singular - ctm" - introduced a regression in the output when using a ctm. - - The check for an invertable matrix had the side effect of inverting - the matrix. Instead, make a copy of the matrix before testing if it is - invertable. - - poppler/CairoOutputDev.cc | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -commit 0b2c3bb25c908b07e760d824dbfe93c6051812aa -Merge: 362fe01 9c472f7 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Wed Mar 12 00:23:58 2008 +0100 - - Merge branch 'master' of - ssh://inigomartinez@git.freedesktop.org/git/poppler/poppler - -commit 362fe013c0d96698b52d70cf5226cddca7fe52d4 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Wed Mar 12 00:07:12 2008 +0100 - - Enabled back the AnnotWidget support. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 9c472f76d2462d0e775c851fdbac6ca2bc9812ea -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Mar 12 00:00:20 2008 +0100 - - cmake build - - glib/demo/CMakeLists.txt | 1 + - 1 file changed, 1 insertion(+) - -commit 821858f5c36786955d9475044bfee57f5060ad2f -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Mar 11 23:58:05 2008 +0100 - - Return char bounding box instead of edge, it's much more useful for - character positioning - - qt4/src/poppler-page.cc | 8 ++++++-- - qt4/src/poppler-private.h | 3 +-- - qt4/src/poppler-qt4.h | 6 ++---- - qt4/src/poppler-textbox.cc | 4 ++-- - 4 files changed, 11 insertions(+), 10 deletions(-) - -commit d7e642732ced592362d9787bddadb7a110dcc5a5 -Merge: 3642f0c 2d6c605 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Tue Mar 11 23:41:59 2008 +0100 - - Merge branch 'master' of - ssh://inigomartinez@git.freedesktop.org/git/poppler/poppler - -commit 3642f0c48bc49cd4d698e769544c1d8604c6482f -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Tue Mar 11 23:13:33 2008 +0100 - - glib annots demo. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - glib/demo/Makefile.am | 2 + - glib/demo/annots.c | 468 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - glib/demo/annots.h | 31 ++++ - glib/demo/main.c | 4 +- - 4 files changed, 504 insertions(+), 1 deletion(-) - -commit 2d6c60537317bd3ac9e0582e0da09e7365729097 -Author: Pino Toscano <pino@kde.org> -Date: Tue Mar 11 22:54:44 2008 +0100 - - For now we cannot handle MovieLink's, so comment them out. - - qt4/src/poppler-annotation.cc | 2 ++ - qt4/src/poppler-link.cc | 4 ++++ - qt4/src/poppler-link.h | 2 ++ - 3 files changed, 8 insertions(+) - -commit a354f7198c493990613a1db131c662ec27948863 -Author: Hugo Mercier <hmercier31@gmail.com> -Date: Tue Mar 11 22:49:00 2008 +0100 - - Initial Movie support (2) - - Now with the forgotten files - - poppler/Movie.cc | 443 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Movie.h | 177 ++++++++++++++++++++++ - 2 files changed, 620 insertions(+) - -commit 43e5dd941d4bc35c4eebbad66c13235639e0c1a0 -Merge: aab1768 4fdd254 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Mar 11 22:31:22 2008 +0100 - - Merge branch 'master' of - ssh://aacid@git.freedesktop.org/git/poppler/poppler - -commit 4fdd254370ea6055e95c8ebee51b69e06c501714 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Mar 11 22:31:00 2008 +0100 - - Fix build - - glib/poppler-page.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit aab17684dc3f21ff2b1ee6eacdc0c565d368df78 -Author: Hugo Mercier <hmercier31@gmail.com> -Date: Tue Mar 11 22:28:28 2008 +0100 - - Initial Movie support - - CMakeLists.txt | 2 + - poppler/Annot.cc | 316 - +++++++++++++++++++++++++++++++++++++++++++++++++++- - poppler/Annot.h | 125 +++++++++++++++++++++ - poppler/Link.cc | 108 +++++++++++++++--- - poppler/Link.h | 64 ++++++++++- - poppler/Makefile.am | 2 + - 6 files changed, 591 insertions(+), 26 deletions(-) - -commit 13a0d2390b9e4684af070c213f385485715353df -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Mar 11 22:27:38 2008 +0100 - - Add poppler-annot to the cmake build system - - glib/CMakeLists.txt | 2 ++ - 1 file changed, 2 insertions(+) - -commit 19f0e3b40bce4d8157d8c8bd04eaf6bacbef38b8 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Tue Mar 11 22:09:04 2008 +0100 - - Add preliminary annotations support in the glib frontend - - glib/Makefile.am | 2 + - glib/poppler-annot.cc | 776 - +++++++++++++++++++++++++++++++++++++++++++++++++ - glib/poppler-annot.h | 181 ++++++++++++ - glib/poppler-page.cc | 166 +++++++++++ - glib/poppler-page.h | 15 + - glib/poppler-private.h | 5 +- - glib/poppler.h | 7 + - 7 files changed, 1151 insertions(+), 1 deletion(-) - -commit 6fa3ab20fee311b4aff92be18870fd0e1730a81f -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Tue Mar 11 18:44:27 2008 +0100 - - Changed AnnotMarkup inheritance - - poppler/Annot.cc | 9 +++++---- - poppler/Annot.h | 10 +++++----- - 2 files changed, 10 insertions(+), 9 deletions(-) - -commit 3111cfe2ccb32f9680baaad0c3f0678dd5969f8b -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Mar 10 22:12:36 2008 +0100 - - And free the memory - - qt4/tests/test-poppler-qt4.cpp | 2 ++ - 1 file changed, 2 insertions(+) - -commit 58f88c23402ac2e678dc655f64d93d89bb1812be -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Mar 10 22:08:43 2008 +0100 - - Add the -textRects option to the test app so we can check text rects - are correct - - qt4/tests/test-poppler-qt4.cpp | 45 - +++++++++++++++++++++++++++++++++++++----- - 1 file changed, 40 insertions(+), 5 deletions(-) - -commit 94ceb3cae79dc7786fa59fd889a87160780ed5df -Merge: 0f9e843 35f34bd -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Mar 9 23:34:11 2008 +0100 - - Merge branch 'master' of - ssh://aacid@git.freedesktop.org/git/poppler/poppler - -commit 0f9e84302ac2108f05bdbb10e7e57ae19ad1e9f3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Mar 9 23:33:11 2008 +0100 - - Do not force default values to fontconfig patterns as fontconfig - already fills in default values for us - - Fixes bug 14883 - - poppler/GlobalParams.cc | 17 +++++++++-------- - 1 file changed, 9 insertions(+), 8 deletions(-) - -commit 35f34bd44c74eeb76a58b30acfbb0303d7285f06 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Mar 9 17:38:54 2008 +0100 - - Fix build when compiling without cairo support - - glib/demo/images.c | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 32637db19dd80a9b8452f86eb677b10e77290627 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Mar 9 00:57:08 2008 +0100 - - proper lib64 Qt detection - - Fixes bug 14583 - - m4/qt.m4 | 15 ++++++++++++--- - 1 file changed, 12 insertions(+), 3 deletions(-) - -commit 65a88a95a5c54c890048e8a986df361585d601dd -Author: Pino Toscano <pino@kde.org> -Date: Sat Mar 8 03:11:36 2008 +0100 - - Provide the mime type for an embedded file, if known. - - Adapt the unit test for that. - - qt4/src/poppler-embeddedfile.cc | 5 +++++ - qt4/src/poppler-qt4.h | 5 +++++ - qt4/tests/check_attachments.cpp | 7 +++++++ - 3 files changed, 17 insertions(+) - -commit 23da27a229c8b3cc2a0a0dd6354c40723934390c -Author: Pino Toscano <pino@kde.org> -Date: Sat Mar 8 03:10:58 2008 +0100 - - Optionally read the mimetype for the embedded files. - - poppler/Catalog.cc | 17 +++++++++-------- - poppler/Catalog.h | 7 ++++++- - 2 files changed, 15 insertions(+), 9 deletions(-) - -commit 42c254b978c61e2ccfda083dfeffec9fc35a5fe7 -Author: Pino Toscano <pino@kde.org> -Date: Mon Mar 3 16:56:09 2008 +0100 - - be safe about out-of-range values - - qt4/src/poppler-textbox.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 5db75df77938eb7620867d0618058be52ed2d3cb -Author: Pino Toscano <pino@kde.org> -Date: Mon Mar 3 16:53:39 2008 +0100 - - initialize nicely - - qt4/src/poppler-private.h | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 3ad0ab7e4abd37528284269c69be3cdfb8d31d2e -Author: Pino Toscano <pino@kde.org> -Date: Mon Mar 3 16:49:23 2008 +0100 - - apidox - - qt4/src/poppler-link.h | 17 +++++++++++++++++ - qt4/src/poppler-qt4.h | 23 ++++++++++++++++++++++- - 2 files changed, 39 insertions(+), 1 deletion(-) - -commit ec01926e5a9dc16e200060497c43e79a1623698d -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sun Mar 2 20:15:20 2008 -0500 - - Avoid setting a singular ctm - - Ignoring singular ctm's gives a better result than having - our cairo context error and turn off. Related to #14398. - - poppler/CairoOutputDev.cc | 14 ++++++++++++++ - 1 file changed, 14 insertions(+) - -commit 4882d7a118b93fdb5c441d70757e485be7ee25d7 -Author: Pino Toscano <pino@kde.org> -Date: Thu Feb 28 15:12:23 2008 +0100 - - printf -> qDebug - - qt4/src/poppler-optcontent.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 31ce4049bf12c2716be7ec0fb8eda502d989f66e -Author: Brad Hards <bradh@saxicola.cuneata.net> -Date: Thu Feb 28 22:09:30 2008 +1100 - - Respect PageMode for optional content and embedded files. - - This makes the PDF 1.7 spec open with the embedded files showing. - - qt4/demos/embeddedfiles.cpp | 7 +++++++ - qt4/demos/embeddedfiles.h | 1 + - qt4/demos/optcontent.cpp | 8 ++++++++ - qt4/demos/optcontent.h | 1 + - 4 files changed, 17 insertions(+) - -commit ff938c431799d49325c0f46f1e6cbe1033993a83 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Feb 27 23:12:53 2008 +0100 - - do not forget to distribute GlobalParamsWin.cc next time - - poppler/Makefile.am | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 277382b8186d137a9f2a62bc2d22e9f0cda7d923 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Feb 27 22:56:33 2008 +0100 - - fix typo - - glib/demo/images.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 5b2f8f21fca63508570a0c77c6f7221a322e6e57 -Merge: 7e65118 4254f12 -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 22:10:12 2008 +0100 - - Merge branch 'master' of - ssh://pino@git.freedesktop.org/git/poppler/poppler - -commit 7e651186f483976f9833de245b6c7add38e77a16 -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 22:03:17 2008 +0100 - - Properly enable/disable the contents when their parents are changed. - - Now, the children maintain the "checked state" they had, when their - parent is unchecked; - but, they are really disabled, both in the possibility to be checked - and in the drawing of their associated content [applying the same - to their children, and so on]. - - qt4/src/poppler-optcontent-private.h | 8 +++++++- - qt4/src/poppler-optcontent.cc | 37 - +++++++++++++++++++++++++++++++----- - 2 files changed, 39 insertions(+), 6 deletions(-) - -commit 4254f1237ebed09b8e1c85f935a20bde3d8f36ff -Merge: ed6c0c2 0569ae7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Feb 27 20:44:27 2008 +0100 - - Merge branch 'master' of - ssh://aacid@git.freedesktop.org/git/poppler/poppler - -commit 8d384c06f96ba8cb3e73c275b3c708c64da4595d -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 20:39:09 2008 +0100 - - small header cleanup - - qt4/src/poppler-optcontent-private.h | 9 +++++++-- - qt4/src/poppler-optcontent.cc | 7 ++++--- - 2 files changed, 11 insertions(+), 5 deletions(-) - -commit ed6c0c260837a0025279765ef7778b83d6ee2209 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Feb 27 20:43:45 2008 +0100 - - fix build and distcheck with autools - - qt4/demos/Makefile.am | 3 +++ - qt4/src/Makefile.am | 5 ++++- - qt4/tests/Makefile.am | 3 +++ - 3 files changed, 10 insertions(+), 1 deletion(-) - -commit 344d55539b1b6bcabec609fd828db372a07491b4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Feb 27 20:43:13 2008 +0100 - - fill the NEWS for 0.7.1 - - NEWS | 15 +++++++++++++++ - 1 file changed, 15 insertions(+) - -commit 1c47633ba782021978fa34d41a4ab0badf3af9d3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Feb 27 20:42:55 2008 +0100 - - Increase version number to 0.7.1 - - CMakeLists.txt | 2 +- - configure.ac | 2 +- - msvc/config.h | 6 +++--- - qt4/src/Doxyfile | 2 +- - 4 files changed, 6 insertions(+), 6 deletions(-) - -commit 0569ae76b6af1723b4606af189242a23199f387d -Merge: f395531 d8eba8c -Author: Brad Hards <bradh@kde.org> -Date: Thu Feb 28 06:26:09 2008 +1100 - - Merge branch 'master' of - ssh://bradh@git.freedesktop.org/git/poppler/poppler - -commit d8eba8c10834116b4f0f295375805172f5216993 -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 19:07:46 2008 +0100 - - export the OptContentModel - - qt4/src/poppler-optcontent.h | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit 0445e64a4124af7c1b84673f237022e133eb8542 -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 19:04:03 2008 +0100 - - make only the Document able to create OptContentsModel's - - qt4/src/poppler-optcontent.h | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -commit c965437b67a4f97ee8365a217bd10406fba3767a -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 18:58:31 2008 +0100 - - setRootNode() is private (and unused) API - - qt4/src/poppler-optcontent-private.h | 2 ++ - qt4/src/poppler-optcontent.cc | 8 ++++---- - qt4/src/poppler-optcontent.h | 4 ---- - 3 files changed, 6 insertions(+), 8 deletions(-) - -commit e293bfc384e2dfc4ef04582053ce18d8c0bcb7b3 -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 18:50:35 2008 +0100 - - small cleanup - - qt4/src/poppler-optcontent.cc | 11 ++++------- - 1 file changed, 4 insertions(+), 7 deletions(-) - -commit f11aa0008585e845ce509172d76f72f941be497d -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 18:44:09 2008 +0100 - - adapt the tests to the new layout of the contents model - - qt4/tests/check_optcontent.cpp | 66 - +++++++++++++++--------------------------- - 1 file changed, 23 insertions(+), 43 deletions(-) - -commit 4a324484b5c77ddc348746e7bcf6051ade28e389 -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 18:04:52 2008 +0100 - - free some objects (thus leak less) - - poppler/Gfx.cc | 2 ++ - poppler/OptionalContent.cc | 2 ++ - 2 files changed, 4 insertions(+) - -commit 0f4e7791ab6884072a1aee56e9cec212d8cea263 -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 15:58:21 2008 +0100 - - ignore any generated .moc here - - qt4/src/.gitignore | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 136ae44f155b17d9e8b041b67f75531d8544337c -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 15:56:09 2008 +0100 - - keep track of the items changed when toggling an item, so we can - update them properly - - qt4/src/poppler-optcontent-private.h | 4 ++-- - qt4/src/poppler-optcontent.cc | 38 - ++++++++++++++++++++++++++++-------- - 2 files changed, 32 insertions(+), 10 deletions(-) - -commit b73e2afef7e5e1b68d82a10c94bca3c201c5f8b3 -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 15:52:06 2008 +0100 - - fix indexFromItem once again, and make parent() call it with the - right node - - qt4/src/poppler-optcontent-private.h | 2 +- - qt4/src/poppler-optcontent.cc | 19 +++++++++---------- - 2 files changed, 10 insertions(+), 11 deletions(-) - -commit 803787f763578320aa5f405ed49c64e6b924bad3 -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 15:30:18 2008 +0100 - - compile with the autotools - - (second patch I forgot to apply with the first) - - qt4/src/Makefile.am | 9 ++++++--- - 1 file changed, 6 insertions(+), 3 deletions(-) - -commit 0b527a8ed62677bb09df4587f072a310c2959750 -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 14:34:13 2008 +0100 - - Extract the OptContentItem -> QModelIndex creation in an own function. - - qt4/src/poppler-optcontent-private.h | 1 + - qt4/src/poppler-optcontent.cc | 7 ++++++- - 2 files changed, 7 insertions(+), 1 deletion(-) - -commit c94d6cc95c6838f31e27832cb3090389bf4d8227 -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 14:30:26 2008 +0100 - - Make index(), data() and setData() more safe. - - Errors spotted using ModelTest. - - qt4/src/poppler-optcontent-private.h | 2 +- - qt4/src/poppler-optcontent.cc | 15 +++++++++------ - 2 files changed, 10 insertions(+), 7 deletions(-) - -commit b8e833733d84eaa93d6bae522710feb3075ca329 -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 14:05:19 2008 +0100 - - fix build with the autotools - - qt4/src/Makefile.am | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit f89ba474bae281f1cdeddb72ac8425dee1087e35 -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 13:28:50 2008 +0100 - - Put the check states of the optional contents in the same column as - the name. - - This feels a bit more elegant than changing a value in a different - column. - Cleanup data()/setData() so they can be extended easily. - - qt4/src/poppler-optcontent.cc | 74 - ++++++++++++++++++++++--------------------- - 1 file changed, 38 insertions(+), 36 deletions(-) - -commit defa0ecb2790402a4069fea3b3c285a50675682d -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 12:24:16 2008 +0100 - - Add a skeleton of OptContentModel::headerData(). - - It does nothing yet, but we can add stuff later on w/o breaking BC. - - qt4/src/poppler-optcontent.cc | 5 +++++ - qt4/src/poppler-optcontent.h | 2 ++ - 2 files changed, 7 insertions(+) - -commit f395531a3e8f71a46b3c942f8f437ade1d9fdb57 -Author: Brad Hards <bradh@kde.org> -Date: Wed Feb 27 22:22:51 2008 +1100 - - Minor cleanup. - - qt4/src/poppler-optcontent.cc | 7 +++---- - 1 file changed, 3 insertions(+), 4 deletions(-) - -commit 0a19486cb4de57c0c987cc4ce2434a96bbd18338 -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 12:15:44 2008 +0100 - - refresh the current page when the data of the content model change - - qt4/demos/optcontent.cpp | 8 ++++++++ - qt4/demos/optcontent.h | 3 +++ - 2 files changed, 11 insertions(+) - -commit 09b7cc2efb7d21fa4dabd23d2d2de877cc7d86ee -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 12:15:18 2008 +0100 - - optional method to reload the current page - - qt4/demos/documentobserver.cpp | 5 +++++ - qt4/demos/documentobserver.h | 1 + - 2 files changed, 6 insertions(+) - -commit 39fe905be8f2ae79d9c26cd87547f3ea2608411e -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 12:00:29 2008 +0100 - - Add a dock for showing the optional content tree. - - qt4/demos/CMakeLists.txt | 1 + - qt4/demos/Makefile.am | 3 +++ - qt4/demos/optcontent.cpp | 55 - ++++++++++++++++++++++++++++++++++++++++++++++++ - qt4/demos/optcontent.h | 43 +++++++++++++++++++++++++++++++++++++ - qt4/demos/viewer.cpp | 7 ++++++ - 5 files changed, 109 insertions(+) - -commit f17dd5539501a996479b903ac9b8aceb3c4cfafe -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 11:53:32 2008 +0100 - - cleanup - - qt4/src/poppler-optcontent-private.h | 3 ++- - qt4/src/poppler-optcontent.h | 4 +--- - 2 files changed, 3 insertions(+), 4 deletions(-) - -commit f3cc894559f10dbd4277fa9f30de9931ed69dfd4 -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 11:43:34 2008 +0100 - - OptContentModel::itemFromRef() and OptContentItem are private API. - - Hide them in the implementation. - - qt4/src/poppler-optcontent-private.h | 43 - ++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-optcontent.cc | 8 +++---- - qt4/src/poppler-optcontent.h | 42 - ----------------------------------- - 3 files changed, 47 insertions(+), 46 deletions(-) - -commit 48e8b2105cf8f177ca655b969470e45e2407db82 -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 11:28:16 2008 +0100 - - move all the private stuff of OptContentModel into its d-pointer - - qt4/src/poppler-optcontent-private.h | 9 +++++++-- - qt4/src/poppler-optcontent.cc | 29 +++++++++++++++-------------- - qt4/src/poppler-optcontent.h | 4 ---- - 3 files changed, 22 insertions(+), 20 deletions(-) - -commit b78a7f7a0e8d5a9c22014d34754090d863030e0d -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 27 11:06:57 2008 +0100 - - use a QPointer for the OptContentModel, so we are safe about - ownership. - - qt4/src/poppler-document.cc | 4 ++-- - qt4/src/poppler-private.h | 6 +++--- - 2 files changed, 5 insertions(+), 5 deletions(-) - -commit 48557da71adb0fe6bd4da2fb32433796a96c3576 -Author: Brad Hards <bradh@kde.org> -Date: Wed Feb 27 19:39:18 2008 +1100 - - We need to install the optional content header. - - qt4/src/CMakeLists.txt | 1 + - 1 file changed, 1 insertion(+) - -commit 6e2bb03b5ef256c03a8da1cbf9bbc87c593942ad -Author: Brad Hards <bradh@kde.org> -Date: Wed Feb 27 19:23:49 2008 +1100 - - Partial d-pointer implementation. - - qt4/src/poppler-optcontent-private.h | 57 - ++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-optcontent.cc | 49 +++++++++++++++++++------------ - qt4/src/poppler-optcontent.h | 24 ++++----------- - 3 files changed, 92 insertions(+), 38 deletions(-) - -commit c627b7aa10ae9cdceb78b751a7e826170f402af0 -Author: Brad Hards <bradh@kde.org> -Date: Wed Feb 27 16:12:38 2008 +1100 - - A couple of cleanups suggested by Pino. - - qt4/src/poppler-document.cc | 6 +++--- - qt4/src/poppler-qt4.h | 8 +++++--- - 2 files changed, 8 insertions(+), 6 deletions(-) - -commit 81891667e18fcf164af02f5f366de07f78d67c8f -Author: Brad Hards <bradh@kde.org> -Date: Wed Feb 27 15:47:03 2008 +1100 - - Add in the initial part of the optional content support. - - To see this work, compare ClarityOCGs.pdf with and - without this change. - - Right now we only handle optional content using - XObjects. Optional content using Marked Content has - infrastructure, but is not implemented. That will be - quite invasive in Gfx, and I'm not confident enough - to do it this late in the process. - - CMakeLists.txt | 1 + - poppler/Catalog.cc | 9 + - poppler/Catalog.h | 4 + - poppler/Gfx.cc | 65 +++++- - poppler/Gfx.h | 12 +- - poppler/Makefile.am | 2 + - poppler/OptionalContent.cc | 322 ++++++++++++++++++++++++++ - poppler/OptionalContent.h | 85 +++++++ - poppler/PDFDoc.h | 5 + - poppler/PSOutputDev.cc | 6 +- - poppler/Page.cc | 2 +- - qt4/src/.gitignore | 1 + - qt4/src/CMakeLists.txt | 3 + - qt4/src/Makefile.am | 6 + - qt4/src/poppler-document.cc | 13 ++ - qt4/src/poppler-optcontent.cc | 354 +++++++++++++++++++++++++++++ - qt4/src/poppler-optcontent.h | 122 ++++++++++ - qt4/src/poppler-private.h | 4 + - qt4/src/poppler-qt4.h | 18 ++ - qt4/tests/.gitignore | 1 + - qt4/tests/CMakeLists.txt | 1 + - qt4/tests/Makefile.am | 5 + - qt4/tests/check_optcontent.cpp | 499 - +++++++++++++++++++++++++++++++++++++++++ - 23 files changed, 1532 insertions(+), 8 deletions(-) - -commit 11b70bcda905e618c199a067db6b0246612e101d -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 26 23:01:27 2008 +0100 - - fixup the default export macro name (added by cmake); _WIN32 is - defined only on win32 (remove a plethora of warnings) - - qt4/src/poppler-export.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit d4d6c14cd83d04c61daa6618c3148a0bb47dc292 -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 26 22:57:02 2008 +0100 - - install the export header - - qt4/src/CMakeLists.txt | 1 + - qt4/src/Makefile.am | 1 + - 2 files changed, 2 insertions(+) - -commit 4ba2e2d21710135656adbf93c5994cfb46502308 -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 26 22:55:30 2008 +0100 - - no need to include the export header in private headers - - qt4/src/poppler-annotation-helper.h | 1 - - qt4/src/poppler-annotation-private.h | 1 - - qt4/src/poppler-converter-private.h | 1 - - qt4/src/poppler-link-extractor-private.h | 1 - - qt4/src/poppler-page-private.h | 1 - - qt4/src/poppler-private.h | 1 - - qt4/src/poppler-qiodeviceoutstream-private.h | 1 - - 7 files changed, 7 deletions(-) - -commit 0a466c09fb70b92f39df19bc315b6575e419ad5b -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Feb 26 22:47:31 2008 +0100 - - We also need to distribute poppler-export.h - - qt4/src/Makefile.am | 1 + - 1 file changed, 1 insertion(+) - -commit 2034d57c700049bc9a6565bbb818e1c9f4467784 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Feb 26 22:46:29 2008 +0100 - - Now for real: Add special casing in cmake buildsystem for MSVC, - also add Export markers to qt4 classes, although symbol visibility - is only used on MSVC at the moment - - CMakeLists.txt | 5 +++++ - qt4/src/CMakeLists.txt | 3 +++ - qt4/src/poppler-annotation-helper.h | 1 + - qt4/src/poppler-annotation-private.h | 1 + - qt4/src/poppler-annotation.h | 19 ++++++++++--------- - qt4/src/poppler-converter-private.h | 1 + - qt4/src/poppler-export.h | 6 +++--- - qt4/src/poppler-form.h | 9 +++++---- - qt4/src/poppler-link-extractor-private.h | 1 + - qt4/src/poppler-link.h | 17 +++++++++-------- - qt4/src/poppler-page-private.h | 1 + - qt4/src/poppler-private.h | 1 + - qt4/src/poppler-qiodeviceoutstream-private.h | 1 + - qt4/src/poppler-qt4.h | 21 +++++++++++---------- - qt4/tests/CMakeLists.txt | 6 ++++++ - 15 files changed, 59 insertions(+), 34 deletions(-) - -commit b931920f63f4276ec355118faa061bafa5ac5244 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Feb 26 22:42:16 2008 +0100 - - Add special casing in cmake buildsystem for MSVC, also add Export - markers to qt4 classes, although symbol visibility is only used on - MSVC at the moment - - qt4/src/poppler-export.h | 17 +++++++++++++++++ - 1 file changed, 17 insertions(+) - -commit 1778fddb36d6cb2c7f7848bee06189158f69f16e -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Feb 24 23:02:08 2008 +0100 - - Add the cmake files to EXTRA_DIST so they get added when i do make - dist to get the release tarball - - Makefile.am | 39 +++++++++++++++++++++++++++++++++++++++ - 1 file changed, 39 insertions(+) - -commit 51f171e10a42d492c8c32a5e2578d05b73d89238 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Feb 24 22:47:46 2008 +0100 - - ignore more - - qt4/demos/.gitignore | 2 ++ - 1 file changed, 2 insertions(+) - -commit adb1ccdb9265f0583cb348c456a39efac610aff1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Feb 24 22:46:33 2008 +0100 - - ignore - - qt4/demos/.gitignore | 2 ++ - 1 file changed, 2 insertions(+) - -commit 101e526c63175ffc1a75e1b68da7bb4fff9cd530 -Author: Patrick Spendrin <ps_ml@gmx.de> -Date: Sun Feb 24 20:52:41 2008 +0100 - - define snprintf to _snprintf if we are building on MSVC - - config.h.cmake | 4 ++++ - 1 file changed, 4 insertions(+) - -commit f7f8ab488257c3979d20e5c0690ec5d7c2cd831b -Author: Patrick Spendrin <ps_ml@gmx.de> -Date: Sun Feb 24 20:43:11 2008 +0100 - - define M_PI in case it is not defined - - poppler/Function.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit f00436b63bf9a42dcb2728a07db9c20f1f23d0bc -Author: Patrick Spendrin <ps_ml@gmx.de> -Date: Sun Feb 24 20:39:42 2008 +0100 - - Add proper dirent.h guards - - utils/pdftoabw.cc | 2 ++ - utils/pdftohtml.cc | 2 ++ - 2 files changed, 4 insertions(+) - -commit e1463451c584181f918265438cf6ddcb408bf731 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Feb 21 20:43:56 2008 +0100 - - Code uses if USE_EXCEPTIONS, so we need to defined it to 1, not just - define it - - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 88d4bbbcf828e3247454c8ba3c2fb0fb58207b6a -Author: Michael Vrable <mvrable@cs.ucsd.edu> -Date: Thu Feb 21 19:53:03 2008 +0100 - - If a bitmap's dimensions are invalid, do not try to display it. - - poppler/Gfx.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 452ae6f5674b00b43955952961f7ca0583f73e27 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Feb 21 19:46:19 2008 +0100 - - Make sure we don't draw outside the bitmap on Splash::fillGlyph2 - - splash/Splash.cc | 76 - ++++++++++++++++++++++++++++++++++++-------------------- - 1 file changed, 49 insertions(+), 27 deletions(-) - -commit 7f60fa806bd6d3d28917f349a2a19b52f97f593a -Author: James Cloos <cloos@jhcloos.com> -Date: Thu Feb 21 13:00:05 2008 -0500 - - Fix typo - - Signed-off-by: James Cloos <cloos@jhcloos.com> - - qt4/demos/Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 053ecae534a4522d152b0139b6aed6da2059d760 -Author: Carl Worth <cworth@cworth.org> -Date: Wed Feb 20 17:21:27 2008 -0800 - - Keep cairo and cairo_shape consistent - - The 'cairo_shape' state was not always being modified at the same - time as 'cairo'. In some cases this led to a sequence of ever - larger matrix scale factors until things just blew up. - - poppler/CairoOutputDev.cc | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit bf6dd890994150406b4464e45355a4a99870fc60 -Author: Pino Toscano <pino@kde.org> -Date: Thu Feb 21 01:23:07 2008 +0100 - - Add a dock for showing the document metadata. - - qt4/demos/CMakeLists.txt | 1 + - qt4/demos/Makefile.am | 3 +++ - qt4/demos/metadata.cpp | 50 - ++++++++++++++++++++++++++++++++++++++++++++++++ - qt4/demos/metadata.h | 43 +++++++++++++++++++++++++++++++++++++++++ - qt4/demos/viewer.cpp | 7 +++++++ - 5 files changed, 104 insertions(+) - -commit b6f0c8f83924c08be20b602b128651bf018172a3 -Author: Pino Toscano <pino@kde.org> -Date: Thu Feb 21 00:54:26 2008 +0100 - - Do not assign conflicting accelerators. - - qt4/demos/viewer.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit e0c27a968c7e7a0f6a89a050ddbfe328229f431d -Author: Pino Toscano <pino@kde.org> -Date: Thu Feb 21 00:53:24 2008 +0100 - - Apply the antialias settings w/o notify the observers. - - qt4/demos/viewer.cpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 2c6149abcecda15c6f73a1dee537072240ddd545 -Author: Pino Toscano <pino@kde.org> -Date: Thu Feb 21 00:51:21 2008 +0100 - - Add a settings menu to choose the render backend. - - qt4/demos/viewer.cpp | 28 ++++++++++++++++++++++++++++ - qt4/demos/viewer.h | 3 +++ - 2 files changed, 31 insertions(+) - -commit db2b0778dca364751a1d22294be29f8c7799e2e9 -Author: Pino Toscano <pino@kde.org> -Date: Thu Feb 21 00:33:23 2008 +0100 - - Add a dock for showing the embedded files. - - TODO: show the checksum in a pretty format. - - qt4/demos/CMakeLists.txt | 1 + - qt4/demos/Makefile.am | 3 ++ - qt4/demos/embeddedfiles.cpp | 75 - +++++++++++++++++++++++++++++++++++++++++++++ - qt4/demos/embeddedfiles.h | 43 ++++++++++++++++++++++++++ - qt4/demos/viewer.cpp | 7 +++++ - 5 files changed, 129 insertions(+) - -commit 51fba47ccb12a66282769fc504bac4c9f5123f75 -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 17 01:49:59 2008 +0100 - - clear the page label when the document is closed - - qt4/demos/pageview.cpp | 2 ++ - 1 file changed, 2 insertions(+) - -commit e964e2b9fbbe9b52b137ecd06729a06530835227 -Author: Michael Vrable <mvrable@cs.ucsd.edu> -Date: Tue Feb 19 23:22:55 2008 +0100 - - Allow grouped checkboxes to be selected individually. - - When checkboxes are in a group, they ought to behave like a - collection of - radio buttons. However, when deciding whether to draw a checkbox as - selected or not, the checkbox-drawing code was looking up the value - of the - V field in the form dictionary, which is shared among all checkboxes - in the - group. Thus, checkboxes would either all be on or off in unison. - - Instead, look up the AS (appearance state) value in each checkbox's - annotation dictionary, so that different checkboxes can be drawn - differently. - - poppler/Annot.cc | 6 ++---- - 1 file changed, 2 insertions(+), 4 deletions(-) - -commit 702fdd6c56b5369554c683d8c8e0e2c66e80886c -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Feb 19 00:18:04 2008 +0100 - - changes from gtk-doc - - glib/reference/tmpl/poppler-document.sgml | 1 + - glib/reference/tmpl/poppler-page.sgml | 2 +- - 2 files changed, 2 insertions(+), 1 deletion(-) - -commit 9e13b91ba38c20989d283588e73490a1601f5bb0 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Feb 19 00:10:24 2008 +0100 - - distribute the headers too - - qt4/demos/Makefile.am | 11 ++++++++++- - 1 file changed, 10 insertions(+), 1 deletion(-) - -commit 194e0ced7c38514ec3126666531862e3b29b4b77 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Feb 18 23:34:06 2008 +0100 - - Fill NEWS and increase version number to 0.7 - - CMakeLists.txt | 2 +- - NEWS | 96 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - configure.ac | 2 +- - msvc/config.h | 6 ++-- - qt4/src/Doxyfile | 2 +- - 5 files changed, 102 insertions(+), 6 deletions(-) - -commit 3c407efe9f1f0cc3f6366d3a2b6e9b687656cc95 -Merge: 51f0cea 7f4acb8 -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 18 21:30:42 2008 +0100 - - Merge branch 'master' of - ssh://pino@git.freedesktop.org/git/poppler/poppler - -commit 51f0cea0e3ba1acfc63877752e950fdd8c07e258 -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 18 21:29:41 2008 +0100 - - make the poppler_qt4viewer compile with the auto"tools" - - qt4/demos/Makefile.am | 16 ++++++++++++---- - 1 file changed, 12 insertions(+), 4 deletions(-) - -commit 7f4acb879d300e18dfaff768027c88195d7d8f1b -Author: Timothy Lee <timothy.lee@siriushk.com> -Date: Mon Feb 18 20:56:35 2008 +0100 - - Implement ImageOutputDev::drawMaskedImage and - ImageOutputDev::drawSoftMaskedImage so all images are exported when - using pdfimages - - utils/ImageOutputDev.cc | 19 +++++++++++++++++++ - utils/ImageOutputDev.h | 11 +++++++++++ - 2 files changed, 30 insertions(+) - -commit 064b316648e35416bb49336639da1d8d288d1ecf -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Feb 18 20:17:37 2008 +0100 - - xref can be null so check for it before checking we went out of bounds - - Fixes bug 14549 - - poppler/Lexer.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit b287b611b1c7b7dd00e12518cee3a6c35044e161 -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 17 01:21:07 2008 +0100 - - Really niptick: help menu with about dialog for us and Qt. - - qt4/demos/viewer.cpp | 15 +++++++++++++++ - qt4/demos/viewer.h | 2 ++ - 2 files changed, 17 insertions(+) - -commit 6400254fdabf3d0d32f27ebd00faa6958be62019 -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 17 01:12:27 2008 +0100 - - Add a title to the viewer :) - - qt4/demos/viewer.cpp | 2 ++ - 1 file changed, 2 insertions(+) - -commit b363c0568c9c61e7ee8ed86d808f0eed0b93b525 -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 17 01:09:57 2008 +0100 - - Add the possibility to save a copy of the file. - - qt4/demos/viewer.cpp | 29 +++++++++++++++++++++++++++++ - qt4/demos/viewer.h | 2 ++ - 2 files changed, 31 insertions(+) - -commit 42987dcdd8d7432145f78cfc550f0c099e6e7311 -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 17 00:33:01 2008 +0100 - - Add a Permissions dock. - - qt4/demos/CMakeLists.txt | 1 + - qt4/demos/Makefile.am | 1 + - qt4/demos/permissions.cpp | 77 - +++++++++++++++++++++++++++++++++++++++++++++++ - qt4/demos/permissions.h | 43 ++++++++++++++++++++++++++ - qt4/demos/viewer.cpp | 7 +++++ - 5 files changed, 129 insertions(+) - -commit 9d1dda64de1d9e3f6fc81e40a0c2246a6270dfa8 -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 16 23:56:17 2008 +0100 - - Add settings for antialias. - - qt4/demos/viewer.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ - qt4/demos/viewer.h | 4 ++++ - 2 files changed, 45 insertions(+) - -commit 3abb8703d7d8b7a5fbcbb3c19d8e84d640abe88c -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 16 22:25:11 2008 +0100 - - Add a TOC info dock. - - qt4/demos/CMakeLists.txt | 1 + - qt4/demos/Makefile.am | 1 + - qt4/demos/toc.cpp | 90 - ++++++++++++++++++++++++++++++++++++++++++++++++ - qt4/demos/toc.h | 43 +++++++++++++++++++++++ - qt4/demos/viewer.cpp | 7 ++++ - 5 files changed, 142 insertions(+) - -commit 80925f06d125ebfc9909e36bdbe5d37fd0e48bdc -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 16 21:51:10 2008 +0100 - - Adapt the Fonts and Info docks to the new abstract info dock. - - qt4/demos/fonts.cpp | 10 +++------- - qt4/demos/fonts.h | 11 +++++------ - qt4/demos/info.cpp | 10 +++------- - qt4/demos/info.h | 11 +++++------ - 4 files changed, 16 insertions(+), 26 deletions(-) - -commit c03531d691e56aba2b4c6538cf9e2463e1e0aa29 -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 16 21:43:19 2008 +0100 - - Introduce a base info dock for handling the "dirty" work. - - qt4/demos/CMakeLists.txt | 1 + - qt4/demos/Makefile.am | 1 + - qt4/demos/abstractinfodock.cpp | 57 - ++++++++++++++++++++++++++++++++++++++++++ - qt4/demos/abstractinfodock.h | 48 +++++++++++++++++++++++++++++++++++ - 4 files changed, 107 insertions(+) - -commit 0f7d51c7fc2439ee9392c166576c341238f00f36 -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 16 18:49:52 2008 +0100 - - Delete the poppler page after usage. - - qt4/demos/pageview.cpp | 1 + - 1 file changed, 1 insertion(+) - -commit b41d069cdd1435ddb14b3de2986875069523c814 -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 16 18:48:57 2008 +0100 - - Initialize the current page number correctly. - - qt4/demos/viewer.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 75e516af0e72a2e3041660300e522ad00869372b -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 16 18:43:56 2008 +0100 - - Add a side dock for showing the fonts of the document. - - qt4/demos/CMakeLists.txt | 1 + - qt4/demos/Makefile.am | 1 + - qt4/demos/fonts.cpp | 78 - ++++++++++++++++++++++++++++++++++++++++++++++++ - qt4/demos/fonts.h | 44 +++++++++++++++++++++++++++ - qt4/demos/viewer.cpp | 7 +++++ - 5 files changed, 131 insertions(+) - -commit 8e642d1cbd48d4790a6769287cbfd90c3bc9fc34 -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 16 17:21:30 2008 +0100 - - Add a View menu where the dock widget toogle actions will be. - - As start, put the Info dock there. - - qt4/demos/viewer.cpp | 4 ++++ - 1 file changed, 4 insertions(+) - -commit c1feb7c2b5008cc04edb3c028f888072920ce4dc -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 16 17:14:00 2008 +0100 - - Add a side dock for showing the info keys. - - qt4/demos/CMakeLists.txt | 1 + - qt4/demos/Makefile.am | 1 + - qt4/demos/info.cpp | 78 - ++++++++++++++++++++++++++++++++++++++++++++++++ - qt4/demos/info.h | 44 +++++++++++++++++++++++++++ - qt4/demos/viewer.cpp | 5 ++++ - 5 files changed, 129 insertions(+) - -commit abc9b00c6470f9f6b66c280455f544ad0ee3aa8c -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 16 16:09:52 2008 +0100 - - Basic work in the demo PDF viewer, open documents and navigate into - the pages. - - An observer structure was introduced, so extra components can be - easily added and made aware of the document/page changes. - Both the navigation toolbar and the page view are implemented as - observers. - - qt4/demos/CMakeLists.txt | 3 ++ - qt4/demos/Makefile.am | 3 ++ - qt4/demos/documentobserver.cpp | 45 +++++++++++++++++++ - qt4/demos/documentobserver.h | 49 +++++++++++++++++++++ - qt4/demos/navigationtoolbar.cpp | 98 - +++++++++++++++++++++++++++++++++++++++++ - qt4/demos/navigationtoolbar.h | 56 +++++++++++++++++++++++ - qt4/demos/pageview.cpp | 60 +++++++++++++++++++++++++ - qt4/demos/pageview.h | 44 ++++++++++++++++++ - qt4/demos/viewer.cpp | 98 - +++++++++++++++++++++++++++++++++++++++-- - qt4/demos/viewer.h | 17 +++++++ - 10 files changed, 470 insertions(+), 3 deletions(-) - -commit 14c88853a5675f40efb72f3ef01f49eb06ab846c -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 16 00:32:30 2008 +0100 - - Compile the poppler_qt4viewer. - - qt4/demos/CMakeLists.txt | 7 +++++++ - qt4/demos/Makefile.am | 12 ++++++++++-- - 2 files changed, 17 insertions(+), 2 deletions(-) - -commit aeb591f015d5e7a2643ed75d872358d2b1256b99 -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 16 00:31:46 2008 +0100 - - Add a very minimal base PDF viewer. - - So minimal that it does nothing at the moment... - - qt4/demos/main_viewer.cpp | 29 +++++++++++++++++++++++++++++ - qt4/demos/viewer.cpp | 46 - ++++++++++++++++++++++++++++++++++++++++++++++ - qt4/demos/viewer.h | 45 - +++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 120 insertions(+) - -commit 8da490b090487c4c37290b63bdc9abcfaf6d6940 -Author: Pino Toscano <pino@kde.org> -Date: Fri Feb 15 23:59:39 2008 +0100 - - Add a skeleton of directory where PopplerQt4 demos will be. - - configure.ac | 1 + - qt4/CMakeLists.txt | 1 + - qt4/Makefile.am | 2 +- - qt4/demos/CMakeLists.txt | 10 ++++++++++ - qt4/demos/Makefile.am | 20 ++++++++++++++++++++ - 5 files changed, 33 insertions(+), 1 deletion(-) - -commit e24b49d52a5c1716641695ee731dd49848a114d9 -Author: Pino Toscano <pino@kde.org> -Date: Thu Feb 14 22:21:54 2008 +0100 - - do not print it as string - - qt4/src/poppler-private.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 2316455864e9c900c08d051c59b9508eddcb7c34 -Author: Pino Toscano <pino@kde.org> -Date: Thu Feb 14 21:02:20 2008 +0100 - - Pipe the poppler error messages through the Qt debug system. - - qt4/src/poppler-private.cc | 21 +++++++++++++++++++++ - qt4/src/poppler-private.h | 8 +++++++- - 2 files changed, 28 insertions(+), 1 deletion(-) - -commit d985d3b0cdc57370137865add2a5f3a7802109c7 -Author: Pino Toscano <pino@kde.org> -Date: Thu Feb 14 14:56:18 2008 +0100 - - Use what FormWidgetText give us. - - qt4/src/poppler-form.cc | 13 +++---------- - 1 file changed, 3 insertions(+), 10 deletions(-) - -commit a69bd442e52f4495f8d6bfd3bb58b3ebd1be1a63 -Author: Michael Vrable <mvrable@cs.ucsd.edu> -Date: Thu Feb 14 12:52:22 2008 +0100 - - Provide Unicode mappings for some control characters in - PDFDocEncoding. - - Though they do not represent glyphs, values such as carriage return - can be - found in text strings in PDFDocEncoding. Provide mappings for - these bytes - to Unicode. - - Additionally, map unknown characters to U+FFFD instead of U+0000, - so that - unknown characters do not result in nulls (which can truncate strings - early, particularly if the string is later re-encoded into - null-terminated - UTF-8). - - poppler/PDFDocEncoding.cc | 23 +++++++++++++++++------ - 1 file changed, 17 insertions(+), 6 deletions(-) - -commit ce17383e0ed21770b471e88f25046a64a23e7e45 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Feb 13 20:56:39 2008 +0100 - - Yet another fix for buggy documents, do not use the cache if the - cache could not be created because it ought to be too big - - Fixes http://bugs.kde.org/show_bug.cgi?id=157777 - - splash/SplashFont.cc | 48 - ++++++++++++++++++++++++++++-------------------- - 1 file changed, 28 insertions(+), 20 deletions(-) - -commit 15a61cac718ae8cbf83911e299b4cfdd24cdf178 -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 13 20:55:18 2008 +0100 - - add images.c - - glib/demo/CMakeLists.txt | 1 + - 1 file changed, 1 insertion(+) - -commit 9cfe10ab7f51d329647e102e446baaef043d8cc6 -Merge: e918729 7d65b4d -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 13 20:53:43 2008 +0100 - - Merge branch 'master' of - ssh://pino@git.freedesktop.org/git/poppler/poppler - -commit 7d65b4da1bc060aeb94d67c2ff26912cef48c030 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Feb 13 20:32:43 2008 +0100 - - Add images demo - - glib/demo/Makefile.am | 2 + - glib/demo/images.c | 338 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - glib/demo/images.h | 31 +++++ - glib/demo/main.c | 4 +- - 4 files changed, 374 insertions(+), 1 deletion(-) - -commit e9187292701e72db1020f7701d0725d83eee4b00 -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 13 19:41:57 2008 +0100 - - Do the one-time initialisation in initTestCase(). - - qt4/tests/check_dateConversion.cpp | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -commit fb996c46e3c6b56a2c67819620000bcd804aacd6 -Author: Michael Vrable <mvrable@cs.ucsd.edu> -Date: Wed Feb 13 18:44:41 2008 +0100 - - Major rework of text display in form fields code. - - This adds support for UTF-16 strings as input, and will recode them - to the - appropriate character set for the font. - - The method Annot::layoutText packs a lot of functionality together, - but I - couldn't see a good way to split it apart. It will convert an - input text - string from PDFDocEncoding or UTF-16 (encoding is autodetected) to the - appropriate encoding for the font which will be used to display - the form - field. At the same time, it can compute the width of the resulting - string, - and optionally break the string at a specified width to aid in - wrapping - multi-line text. Text wrapping is integrated with encoding conversion - since wrapping is easiest with the original text (where spaces - and newlines - are easily identified), but text widths can only be computed after - re-encoding. - - Support for composite fonts is included, so long as those fonts use an - identity CMap, but this is still untested. Support for more - complex CMaps - is missing. - - The rewrite also includes a minor improvement to the formatting - of comb - fields; characters are now centered in the comb cells. - - poppler/Annot.cc | 507 - +++++++++++++++++++++++++++++++++++-------------------- - poppler/Annot.h | 9 +- - 2 files changed, 327 insertions(+), 189 deletions(-) - -commit 88c780aed4c9855f879e3c7a9f82500a859635a2 -Author: Michael Vrable <mvrable@cs.ucsd.edu> -Date: Wed Feb 13 18:42:49 2008 +0100 - - Fix what look to be a few bugs in functions for mapping to/from - Unicode. - - - Endianness fix in pdfDocEncodingToUTF16 (previously looked to - assume a - little-endian processor) - - Add support for CharCodeToUnicode::mapToCharCode for Unicode - codepoints - above 255. - - poppler/CharCodeToUnicode.cc | 4 ++-- - poppler/Form.cc | 4 ++-- - 2 files changed, 4 insertions(+), 4 deletions(-) - -commit 7574cb71f24ce5b32427f243c39b6029fb58ec81 -Merge: e798802 4e45e5c -Author: Pino Toscano <pino@kde.org> -Date: Wed Feb 13 01:07:31 2008 +0100 - - Merge branch 'master' of - ssh://pino@git.freedesktop.org/git/poppler/poppler - -commit 4e45e5ca4ab0ba2a6586505d80ed81f4b3426752 -Author: Patrick Spendrin <ps_ml@gmx.de> -Date: Tue Feb 12 21:41:26 2008 +0100 - - Do the right thing with CDECL, that is, undefine it if it is defined - so we can redefine it later - - poppler-config.h.cmake | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit e798802f00bff0a24ee6d1312d6c62624395865a -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 12 20:57:56 2008 +0100 - - Apidox fix: state which checksum is returned (if available). - - qt4/src/poppler-qt4.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 4e2ba70a88c40fef6775053b1cc5fa30e622cea7 -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 12 11:25:34 2008 +0100 - - Free the Object after you use it. - - poppler/Annot.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 039545fcd2c12631c7b8aea89c35f36cb387a17a -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 12 11:13:27 2008 +0100 - - Return the siblings even for checkboxes. - - qt4/src/poppler-form.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit fe5ee75cdf3e11e314318af12edf9d5bc8986250 -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 12 11:12:01 2008 +0100 - - Initialize correctly; free your memory. - - poppler/Form.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit e0eff92c7067d43faa8e93baed1f061863111251 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Feb 11 20:32:41 2008 +0100 - - Update the field dict instead of the annot dict for non composed dicts - - We were always updating the annot dictionary, adding or updating - the V field. While this is correct for composed dicts (annot + field) - it isn't for non composed ones since the annot dictionary doesn't - contain any V field because it's a field of the form field dictionary. - In these cases the form field is not correctly updated and if the - document is saved it will be wrong. - - poppler/Form.cc | 44 +++++++++++++++++++++++++++++++------------- - poppler/Form.h | 2 ++ - 2 files changed, 33 insertions(+), 13 deletions(-) - -commit 905e6da9795fee94329022c0cafbc229055fd4f6 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Feb 10 19:22:50 2008 +0100 - - Move forms specific draw methods from Annot to AnnotWidget class - - poppler/Annot.cc | 3433 - +++++++++++++++++++++++++++--------------------------- - poppler/Annot.h | 87 +- - poppler/Form.cc | 39 +- - poppler/Form.h | 2 + - poppler/Page.cc | 9 +- - 5 files changed, 1765 insertions(+), 1805 deletions(-) - -commit 78afbc4d7819654e8742d4457c9847ad02b73bf1 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Feb 10 17:12:59 2008 +0100 - - Some code refactoring and cleanup - - - Unused 'field' attribute in FormWidget class is now used and - getField() method has been added - - Method isReadOnly() in FormWidget class is not virtual anymore - but implemented in the base class - - Unused attribute 'catalog' in Form class has been removed and - 'acroForm' has been added instead with a getObj() method to get it. - - createFieldFromDict() method is now static - - poppler/Form.cc | 128 - ++++++++++++++++++++++++++++---------------------------- - poppler/Form.h | 41 +++++++++--------- - 2 files changed, 84 insertions(+), 85 deletions(-) - -commit 5f8e2f9140ee2ede841700726b974768ec863672 -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 11 20:16:44 2008 +0100 - - Use QVarLengthArray instead of relying on gcc-ism. - - qt4/src/poppler-page.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 7499764d382366823519aa13a38e1e44781c78af -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 11 11:57:50 2008 +0100 - - Add FormFieldButton::siblings(). - - This is needed for grouping together the radio buttons. - - qt4/src/poppler-form.cc | 14 ++++++++++++++ - qt4/src/poppler-form.h | 8 ++++++++ - 2 files changed, 22 insertions(+) - -commit 85bfa4f499a90d45b13df4d0a8760a7da6fc1532 -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 11 02:40:37 2008 +0100 - - Small apidox fix. - - qt4/src/poppler-form.h | 11 ++--------- - 1 file changed, 2 insertions(+), 9 deletions(-) - -commit ada05055c91e967dc3e2af32a2176dd12cb7fe70 -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 11 02:27:19 2008 +0100 - - Preliminary support for "button" form fields (ie, push buttons, - check boxes, and radio buttons). - - qt4/src/poppler-form.cc | 55 - +++++++++++++++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-form.h | 54 - ++++++++++++++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-page.cc | 6 ++++++ - 3 files changed, 115 insertions(+) - -commit 278b33f25df418ef12798100002845a3e2ceebd3 -Merge: c730b33 fdb0a4a -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 11 00:57:24 2008 +0100 - - Merge branch 'master' of - ssh://pino@git.freedesktop.org/git/poppler/poppler - -commit fdb0a4a2f1d86aec7a3b0fcd4b4d48455791ecad -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sun Feb 10 18:47:40 2008 -0500 - - Avoid prescaling images when printing. - - Adds a function for letting the CairoOutputDev know whether it is - targetting a - screen or not. It then uses this knowledge to avoid prescaling - images. This way - cairo gets the full resolution image for use in the printed output. - - glib/poppler-page.cc | 1 + - poppler/CairoOutputDev.cc | 3 ++- - poppler/CairoOutputDev.h | 2 ++ - 3 files changed, 5 insertions(+), 1 deletion(-) - -commit c730b33f1ec2032c4b8c2660738448d954eb0f7d -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 11 00:46:20 2008 +0100 - - Keep the EmbFile object, and use this for getting the data. - - qt4/src/poppler-embeddedfile.cc | 33 +++++++++++---------------------- - qt4/src/poppler-private.h | 1 - - 2 files changed, 11 insertions(+), 23 deletions(-) - -commit 5915e57e7785370ce305cbbb3c2fedf36886689f -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 10 03:19:18 2008 +0100 - - const & in foreach - - qt4/tests/poppler-fonts.cpp | 2 +- - qt4/tests/stress-poppler-dir.cpp | 2 +- - qt4/tests/stress-poppler-qt4.cpp | 2 +- - qt4/tests/test-password-qt4.cpp | 2 +- - qt4/tests/test-poppler-qt4.cpp | 2 +- - 5 files changed, 5 insertions(+), 5 deletions(-) - -commit d8374e0c2eb3ba05be101687e20c5fcbc42c1ad0 -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 10 01:32:24 2008 +0100 - - Include only what needed; remove extra includes. - - qt4/tests/poppler-attachments.cpp | 4 +++- - qt4/tests/poppler-fonts.cpp | 4 +++- - qt4/tests/stress-poppler-dir.cpp | 9 ++++++--- - qt4/tests/stress-poppler-qt4.cpp | 9 ++++++--- - qt4/tests/test-password-qt4.cpp | 10 ++++++---- - qt4/tests/test-poppler-qt4.cpp | 12 ++++++++---- - 6 files changed, 32 insertions(+), 16 deletions(-) - -commit fa01a1115c4554b18c3462b568d76860d2fbe17b -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 10 01:09:57 2008 +0100 - - Comment out unused vars. - - utils/pdftoabw.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit d3275e4263372b534c276f81d0c997ecb6675487 -Merge: c2186c1 5347a97 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Feb 9 23:57:03 2008 +0100 - - Merge branch 'master' of - ssh://aacid@git.freedesktop.org/git/poppler/poppler - -commit c2186c1829c695c4ddb6c471ef8ad4ffa23c1b70 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Feb 9 23:56:32 2008 +0100 - - Only check if we are out of bounds if the object we are searching - for has a known id (0 also means not known) - - Found by Michael Vrable - - poppler/Lexer.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 5347a97e39388ae38cf2ab9c67f953b0f7a02a13 -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 9 18:26:41 2008 +0100 - - Add the operators for the flags we have. - - qt4/src/poppler-qt4.h | 3 +++ - 1 file changed, 3 insertions(+) - -commit 329ade4f936bf063539cdc887aaf9a1722a5b8e0 -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 9 18:23:59 2008 +0100 - - Add options for the PDF export; add the WithChanges flag for saving - the changes to the document as well. - - qt4/src/poppler-pdf-converter.cc | 25 +++++++++++++++++++++++-- - qt4/src/poppler-qt4.h | 14 ++++++++++++++ - 2 files changed, 37 insertions(+), 2 deletions(-) - -commit afb255366d56551bdc307766199bef9c5021d3ac -Merge: 8c44b17 8cb0e75 -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 9 17:58:49 2008 +0100 - - Merge branch 'master' of - ssh://pino@git.freedesktop.org/git/poppler/poppler - -commit 8c44b175081983c492821858341109fee9e86b16 -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 9 17:57:57 2008 +0100 - - Do not rely on GNU extensions, but at least use Qt. - - qt4/src/poppler-qiodeviceoutstream.cc | 11 ++++------- - 1 file changed, 4 insertions(+), 7 deletions(-) - -commit 8cb0e75203daa01439413d1a775482b48e784baa -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Feb 9 17:56:13 2008 +0100 - - Domain order is x_min x_max y_min y_max and not x_min y_min x_max - y_max - - poppler/GfxState.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit c8f734ba4258059fa4521a4d364f62ca1632840b -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Feb 9 13:37:04 2008 +0100 - - PS cos and sin input values are degrees so convert to radians so we - can use the cos and sin cmath functions - - poppler/Function.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 5fb0c9d31c1abf2e6ad306c112fbd2a7c33d8772 -Merge: 2655663 2255c85 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Feb 9 13:15:15 2008 +0100 - - Merge branch 'master' of - ssh://carlosgc@git.freedesktop.org/git/poppler/poppler - -commit 26556636e71d5abcbfdd1373f5576d1233532cf8 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Feb 9 13:14:41 2008 +0100 - - Add saveWithoutChangesAs method to be able to save the document - ignoring changes made in forms or annots - - glib/poppler-document.cc | 41 ++++++++++++++++++++++++++++++++++++++++- - glib/poppler-document.h | 3 +++ - poppler/PDFDoc.cc | 38 ++++++++++++++++++++++++++++++++------ - poppler/PDFDoc.h | 4 ++++ - 4 files changed, 79 insertions(+), 7 deletions(-) - -commit 2255c85e4939a0752083dca21984ff4398baf8d2 -Merge: 5ba9287 56c9246 -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 9 12:49:45 2008 +0100 - - Merge branch 'master' of - ssh://pino@git.freedesktop.org/git/poppler/poppler - -commit 5ba928762471e1ea8b81acd4644dfd3f58d18f77 -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 9 12:48:04 2008 +0100 - - Fix placeholders in printf-like functions. - - glib/demo/page.c | 2 +- - glib/test-poppler-glib.cc | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit 56c924609223196c5c41b9e6d9102bc248bad947 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Feb 9 12:26:06 2008 +0100 - - atan operator must yield a degrees result between 0 and 360 - - See testcase at http://bugs.kde.org/show_bug.cgi?id=157497 - - poppler/Function.cc | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit 2a39932ae35a2716842bd2a1c3d4f9ce6b1e3dd8 -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 9 01:31:20 2008 +0100 - - Few improvements to the password test. - - - QString::fromUtf8() instead of QFile::encodeName() to correctly - pass the utf8 filenames - - QVERIFY(!foo) instead of QCOMPARE(foo, false) - - QVERIFY() also the return value of unlock() - - qt4/tests/check_password.cpp | 31 ++++++++++++++++--------------- - 1 file changed, 16 insertions(+), 15 deletions(-) - -commit cc9c124d4d859b845eebf4ca1e4397870a35fd4e -Author: Pino Toscano <pino@kde.org> -Date: Sat Feb 9 01:09:02 2008 +0100 - - Add an unit test case for few invalid dates. - - qt4/tests/check_dateConversion.cpp | 34 - ++++++++++++++++++++++++++++++++++ - 1 file changed, 34 insertions(+) - -commit eca91761741de5b340f7a2160db5b33401feb935 -Author: Pino Toscano <pino@kde.org> -Date: Fri Feb 8 18:42:14 2008 +0100 - - Remove unneeded headers. - - qt4/src/poppler-page.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 899627505a4645fb1cc7d3599adbeec449c57041 -Author: Pino Toscano <pino@kde.org> -Date: Fri Feb 8 18:41:13 2008 +0100 - - The return value is QString, so return QString's... - - qt4/src/poppler-document.cc | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -commit a1606fa4ff438983e3a7f55dd2d10a66f72e6711 -Author: Pino Toscano <pino@kde.org> -Date: Fri Feb 8 17:31:32 2008 +0100 - - Move checkDocument() inside the private class. - - qt4/src/poppler-document.cc | 6 +++--- - qt4/src/poppler-private.h | 2 ++ - qt4/src/poppler-qt4.h | 2 +- - 3 files changed, 6 insertions(+), 4 deletions(-) - -commit f1ec70a83f807493dab5118761df31c0f67decad -Author: Pino Toscano <pino@kde.org> -Date: Fri Feb 8 17:26:41 2008 +0100 - - Remove C-ism. - - qt4/src/poppler-document.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 3e994e8586fa1c87ef7e7f82af1cdacf2cd36310 -Author: Pino Toscano <pino@kde.org> -Date: Fri Feb 8 12:21:56 2008 +0100 - - Add the missing font types. - - qt4/src/poppler-fontinfo.cc | 11 +++++++++-- - 1 file changed, 9 insertions(+), 2 deletions(-) - -commit ba07963f85d777a441349e23d4c2f510e45c73be -Author: Pino Toscano <pino@kde.org> -Date: Fri Feb 8 12:19:04 2008 +0100 - - Be safe against self-assignment. - - qt4/src/poppler-fontinfo.cc | 3 +++ - 1 file changed, 3 insertions(+) - -commit 834b86548e09f4b24cdb2f194299d053b9b55022 -Author: Pino Toscano <pino@kde.org> -Date: Fri Feb 8 12:15:16 2008 +0100 - - Small apidox fix. - - qt4/src/poppler-qt4.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 11a61eac5b8cde04bf762bbbe0deab5c0bd52951 -Author: Pino Toscano <pino@kde.org> -Date: Fri Feb 8 02:21:32 2008 +0100 - - Pack few bools together. - - qt4/src/poppler-annotation.cc | 8 ++++---- - qt4/src/poppler-link.cc | 10 +++++----- - qt4/src/poppler-private.h | 4 ++-- - 3 files changed, 11 insertions(+), 11 deletions(-) - -commit 1aeba15b5eb9b30943259824678ebc9e4f56e870 -Merge: a489063 22d10c1 -Author: Pino Toscano <pino@kde.org> -Date: Fri Feb 8 01:39:16 2008 +0100 - - Merge branch 'master' of - ssh://pino@git.freedesktop.org/git/poppler/poppler - -commit a4890637a2c2ab1623311d9a6920e82131c2597c -Author: Pino Toscano <pino@kde.org> -Date: Fri Feb 8 01:36:56 2008 +0100 - - Move QStringToUnicodeGooString() and QStringToGooString() to the - private module. - - qt4/src/poppler-document.cc | 10 ---------- - qt4/src/poppler-form.cc | 15 --------------- - qt4/src/poppler-private.cc | 25 +++++++++++++++++++++++++ - qt4/src/poppler-private.h | 4 ++++ - 4 files changed, 29 insertions(+), 25 deletions(-) - -commit 5e44241c4976b819f7be6badd2d183fbfb8ee6de -Author: Pino Toscano <pino@kde.org> -Date: Fri Feb 8 01:30:07 2008 +0100 - - Move the string functions implementation in a .cc file. - - qt4/src/CMakeLists.txt | 1 + - qt4/src/Makefile.am | 1 + - qt4/src/poppler-private.cc | 70 - ++++++++++++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-private.h | 46 +++--------------------------- - 4 files changed, 76 insertions(+), 42 deletions(-) - -commit 124d92139241ad95da559d22af48254b45ac4a2e -Author: Pino Toscano <pino@kde.org> -Date: Fri Feb 8 01:07:43 2008 +0100 - - Include own header first, remove extra includes. - - qt4/src/poppler-document.cc | 1 - - qt4/src/poppler-embeddedfile.cc | 3 ++- - qt4/src/poppler-form.cc | 4 +++- - qt4/src/poppler-link-extractor-private.h | 2 ++ - qt4/src/poppler-link-extractor.cc | 7 +++++-- - qt4/src/poppler-page-private.h | 6 +++++- - qt4/src/poppler-private.h | 4 +++- - qt4/src/poppler-qt4.h | 2 -- - qt4/src/poppler-sound.cc | 4 ++-- - 9 files changed, 22 insertions(+), 11 deletions(-) - -commit 22d10c19e232dea143bda372c92aa12b999e4921 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Feb 7 23:38:50 2008 +0100 - - PDF spec says name tokens have a maximum length of 127, but there are - some docs in the wild with more than that and they work on acroread - so increase the allowed length to 128+127 - - poppler/Lexer.cc | 25 +++++++++++++++++++++---- - 1 file changed, 21 insertions(+), 4 deletions(-) - -commit ee9f85915feb86b54ace1a403baa13bbdd7c3966 -Author: Pino Toscano <pino@kde.org> -Date: Thu Feb 7 18:07:53 2008 +0100 - - Having a PageData is mandatory. - - Just assert when constructing instead of checking for it in each - link iteration. - - qt4/src/poppler-link-extractor.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit ad4b1361f6c25359e6ddb38599bfc1e4e3e80408 -Author: Pino Toscano <pino@kde.org> -Date: Thu Feb 7 18:03:30 2008 +0100 - - Precalc stuff we don't need to recalc in each link iteration. - - qt4/src/poppler-link-extractor-private.h | 3 ++- - qt4/src/poppler-link-extractor.cc | 14 ++++++++------ - 2 files changed, 10 insertions(+), 7 deletions(-) - -commit 82432dbc62a0879f4513640c2e0f594fda9347ad -Author: Pino Toscano <pino@kde.org> -Date: Thu Feb 7 17:51:50 2008 +0100 - - Store the ::Page internally, so we don't need to get it again - everytime. - - qt4/src/poppler-page-private.h | 3 +++ - qt4/src/poppler-page.cc | 37 ++++++++++++++----------------------- - 2 files changed, 17 insertions(+), 23 deletions(-) - -commit 8ec51f7ca518aa6a4a69f30d373722d05f50cf07 -Author: Pino Toscano <pino@kde.org> -Date: Thu Feb 7 16:48:16 2008 +0100 - - Compile the stress-poppler-dir test as well. - - qt4/tests/CMakeLists.txt | 1 + - 1 file changed, 1 insertion(+) - -commit 8a946b76ae2e7c2c5238b4e580c1c226eb457dc9 -Author: Pino Toscano <pino@kde.org> -Date: Thu Feb 7 01:07:28 2008 +0100 - - Micro-touches to the debug messages. - - qt4/src/poppler-page.cc | 26 +++++++++++++------------- - 1 file changed, 13 insertions(+), 13 deletions(-) - -commit c31990dfe50c7a0e3999e6d967699fce5ccb3339 -Merge: 7701e2a 6d58cda -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 5 00:38:00 2008 +0100 - - Merge branch 'master' of - ssh://pino@git.freedesktop.org/git/poppler/poppler - -commit 7701e2a5c7d18fdaa0fa40c190e6ee0524746046 -Author: Pino Toscano <pino@kde.org> -Date: Tue Feb 5 00:37:01 2008 +0100 - - Add a AnnotColor -> QColor conversion method. - - qt4/src/poppler-annotation-helper.h | 6 ++++++ - qt4/src/poppler-annotation.cc | 31 +++++++++++++++++++++++++++++++ - 2 files changed, 37 insertions(+) - -commit 6d58cda82b0181f2cca6e9d95b15877793be0812 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Feb 4 23:33:51 2008 +0100 - - Protect us against weird dateString values - - qt4/src/poppler-document.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit aa0435f1544fe1adcf10173e34eaeaf2a7a703c7 -Merge: b43f4e9 37600b5 -Author: Pino Toscano <pino@kde.org> -Date: Mon Feb 4 20:56:53 2008 +0100 - - Merge branch 'master' of - ssh://pino@git.freedesktop.org/git/poppler/poppler - -commit 37600b5e848386d2c92c3dff8219c9dda16b0dca -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Sun Feb 3 22:42:51 2008 +0100 - - Minor changes to Annot related stuff. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 15 ++++----------- - poppler/Annot.h | 12 ++++++++++-- - poppler/Gfx.cc | 7 ++++--- - poppler/Page.cc | 9 +++++++++ - poppler/Page.h | 3 +++ - 5 files changed, 30 insertions(+), 16 deletions(-) - -commit b43f4e9a161a1fd7b827244dc21b1bd2a6df7054 -Author: Pino Toscano <pino@kde.org> -Date: Sun Feb 3 20:32:15 2008 +0100 - - Pass the DocumentData to the Page (simplify a bit some code). - - qt4/src/poppler-document.cc | 2 +- - qt4/src/poppler-link-extractor-private.h | 4 +- - qt4/src/poppler-link-extractor.cc | 8 ++-- - qt4/src/poppler-page-private.h | 4 +- - qt4/src/poppler-page.cc | 64 - ++++++++++++++++---------------- - qt4/src/poppler-qt4.h | 5 +-- - 6 files changed, 42 insertions(+), 45 deletions(-) - -commit 4e0bb0307fccefc21f74a4c5a3a0d7e8e687b550 -Author: Pino Toscano <pino@draco.(none)> -Date: Sat Feb 2 12:57:25 2008 +0100 - - Fix include guard. - - poppler/ArthurOutputDev.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 6f11ef660540fd13aad1350385beb90758ca86af -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Feb 1 23:55:37 2008 +0100 - - Fix for end condition, init ucode to 0 - - poppler/GfxFont.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 1da2091807ae7f7d4d3f446953c41b4c440d4b1b -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jan 31 23:52:20 2008 +0100 - - Ensure we don't draw outside the main bitmap on - SplashOutputDev::setSoftMask - - Fixes crash on http://bugs.kde.org/show_bug.cgi?id=157000 - - poppler/SplashOutputDev.cc | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -commit ecabc9469b137e8251344e5502de1cbf875223b9 -Author: Pino Toscano <pino@kde.org> -Date: Thu Jan 31 00:20:55 2008 +0100 - - Set RelWithDebInfo as default build type, if not specified. - - cmake/modules/PopplerMacros.cmake | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 19da87a20b3906523a330e3c956903a58a3ede7f -Author: Pino Toscano <pino@kde.org> -Date: Thu Jan 31 00:11:58 2008 +0100 - - Support the different CMake build modes. - - Now you can specify (using -DCMAKE_BUILD_TYPE=type) a CMake build - type to have GCC or ICC w/ tuned C(XX)FLAGS. - The supported build types are: None (as in no type is specified on - command line), RelWithDebInfo, Release, Debug, DebugFull, Profile. - - CMakeLists.txt | 7 ------- - cmake/modules/PopplerMacros.cmake | 29 +++++++++++++++++++++++++++++ - 2 files changed, 29 insertions(+), 7 deletions(-) - -commit 37d2055137c310ceb217164a76814b188be3b1b2 -Author: Pino Toscano <pino@draco.(none)> -Date: Wed Jan 30 23:12:03 2008 +0100 - - Introduce the CMake-based build system. - - Mostly works nicely as the autotools, and it mimics (almost) all - the autotools behaviours. - Copied some scripts from the KDE cmake scripts (BSD-licensed). - TODO: gtk-doc. - - CMakeLists.txt | 390 +++++++ - ConfigureChecks.cmake | 47 + - cmake/modules/COPYING-CMAKE-SCRIPTS | 22 + - cmake/modules/FindCairo.cmake | 44 + - cmake/modules/FindFontconfig.cmake | 47 + - cmake/modules/FindFreetype.cmake | 74 ++ - cmake/modules/FindGTK.cmake | 70 ++ - cmake/modules/FindPackageHandleStandardArgs.cmake | 58 + - cmake/modules/FindQt3.cmake | 319 +++++ - cmake/modules/FindQt4.cmake | 1295 - +++++++++++++++++++++ - cmake/modules/MacroBoolTo01.cmake | 20 + - cmake/modules/MacroEnsureVersion.cmake | 117 ++ - cmake/modules/MacroOptionalFindPackage.cmake | 28 + - cmake/modules/MacroPushRequiredVars.cmake | 47 + - cmake/modules/PopplerDefaults.cmake | 10 + - cmake/modules/PopplerMacros.cmake | 83 ++ - config.h.cmake | 149 +++ - glib/CMakeLists.txt | 107 ++ - glib/demo/CMakeLists.txt | 17 + - glib/poppler-features.h.cmake | 24 + - poppler-cairo.pc.cmake | 9 + - poppler-config.h.cmake | 160 +++ - poppler-glib.pc.cmake | 13 + - poppler-qt.pc.cmake | 12 + - poppler-qt4.pc.cmake | 12 + - poppler-splash.pc.cmake | 9 + - poppler.pc.cmake | 11 + - qt/CMakeLists.txt | 33 + - qt4/CMakeLists.txt | 2 + - qt4/src/CMakeLists.txt | 43 + - qt4/tests/CMakeLists.txt | 47 + - test/CMakeLists.txt | 52 + - utils/CMakeLists.txt | 84 ++ - 33 files changed, 3455 insertions(+) - -commit 1ea831d3eee6eda35fadfb3c75962a0c708e6c7b -Author: Pino Toscano <pino@kde.org> -Date: Wed Jan 30 22:17:38 2008 +0100 - - Preprocessor #warning is GCC-specific. - - poppler/ArthurOutputDev.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 4c738cc6bd51f9d9e23ba83949c490c5c8691345 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jan 29 23:45:52 2008 +0100 - - Scale text to match 'm' size - - Fixes bug 12304 - - poppler/SplashOutputDev.cc | 37 +++++++++++++++++++++++++++++++ - splash/SplashFTFont.cc | 55 - +++++++++++++++++++++++++++++++++++++++++++++- - splash/SplashFTFont.h | 4 ++++ - splash/SplashFont.h | 4 ++++ - splash/SplashFontFile.cc | 1 + - splash/SplashFontFile.h | 2 ++ - 6 files changed, 102 insertions(+), 1 deletion(-) - -commit 64f16cf6ebf2870852fe8d937b25be58869ad40a -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jan 29 23:41:15 2008 +0100 - - Enable antialias by default on the test tool - - qt4/tests/test-poppler-qt4.cpp | 2 ++ - 1 file changed, 2 insertions(+) - -commit 90f0e6bc1e96d9f1666cb8476a92e127f5b927d4 -Author: Jonathan Kew <jonathan_kew@sil.org> -Date: Tue Jan 29 20:23:08 2008 +0100 - - Provide gstrndup as a portable substitue of strndup - - configure.ac | 1 - - goo/gmem.cc | 7 +++++++ - goo/gmem.h | 5 +++++ - poppler/GfxFont.cc | 8 +------- - 4 files changed, 13 insertions(+), 8 deletions(-) - -commit 77b91c852ad3d5554afc03aee92a1d928f233401 -Merge: 0babb0e 0533696 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Jan 28 20:44:34 2008 +0100 - - Merge branch 'master' of - ssh://aacid@git.freedesktop.org/git/poppler/poppler - -commit 0babb0eb1afa343fb12a3fd037b98d2d1c794a1c -Author: Jonathan Kew <jonathan_kew@sil.org> -Date: Mon Jan 28 20:42:44 2008 +0100 - - Introduce a check for strndup and alternative for systems without it - - configure.ac | 1 + - poppler/GfxFont.cc | 6 ++++++ - 2 files changed, 7 insertions(+) - -commit 053369678963206a4afa88a614de1994872c7c5a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Jan 27 19:36:28 2008 +0100 - - Add ok_to_fill_form permission flag - - glib/poppler-document.cc | 2 ++ - glib/poppler-document.h | 3 ++- - glib/test-poppler-glib.cc | 21 +++++++++++++++++++-- - 3 files changed, 23 insertions(+), 3 deletions(-) - -commit 3085a9495ad87a54758da0024372610fdaf88d57 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Jan 27 19:15:34 2008 +0100 - - Fix slice rendering in poppler glib demo - - glib/demo/render.c | 41 ++++++++++++++++++++++++----------------- - 1 file changed, 24 insertions(+), 17 deletions(-) - -commit 7ad6c4ba110b970516d5380444a03ae217496ddf -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jan 24 21:14:44 2008 +0100 - - Incrementing the iterator would be a good idea - - qt4/src/poppler-annotation.cc | 1 + - 1 file changed, 1 insertion(+) - -commit 7c99ec4635a4971321bbead7d1bc723da59b755e -Author: Julien Rebetez <julien@fhtagn.net> -Date: Thu Jan 24 19:18:15 2008 +0100 - - Revert unwanted change on Dict, fix leak on writeTrailer - - poppler/Dict.cc | 2 +- - poppler/PDFDoc.cc | 4 ++-- - 2 files changed, 3 insertions(+), 3 deletions(-) - -commit 2335fb6034d2e9ec304abba400119b88302b3160 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jan 23 23:26:20 2008 +0100 - - Draw underlined Links correctly - - See http://bugs.kde.org/show_bug.cgi?id=151359 for an example - - poppler/Gfx.cc | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit 96c532ea4b56a147de1deb965126e31f87df588b -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jan 23 13:30:12 2008 +0100 - - Fix memory leak - - poppler/Form.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 6bca64407c675ca837f83a12c0f655f975f14407 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jan 23 13:27:45 2008 +0100 - - Make sure default values are not loaded more than once for the - same widget. - - poppler/Form.cc | 18 +++++++++++++++++- - poppler/Form.h | 1 + - 2 files changed, 18 insertions(+), 1 deletion(-) - -commit eccf84b51a1cf5d478c0ec84be3fc9be8e458f4f -Author: Pino Toscano <pino@kde.org> -Date: Tue Jan 22 23:28:16 2008 +0100 - - Refactor the PSConverter and add a PDFConverter (for PDF export/save). - - Add an OutStream subclass to redirect the output to a QIODevice. - Split the PSConverter in a base class (BaseConverter) w/ d_ptr - structure. - Add a new PDFConverter that inherit BaseConverter, and do the - actual export - making use of the new QIODeviceOutStream. - The BaseConverter now handles automatically file or QIODevice output. - - qt4/src/Makefile.am | 5 + - qt4/src/poppler-base-converter.cc | 99 ++++++++++++++++ - qt4/src/poppler-converter-private.h | 48 ++++++++ - qt4/src/poppler-document.cc | 5 + - qt4/src/poppler-pdf-converter.cc | 68 +++++++++++ - qt4/src/poppler-ps-converter.cc | 162 - ++++++++++++--------------- - qt4/src/poppler-qiodeviceoutstream-private.h | 47 ++++++++ - qt4/src/poppler-qiodeviceoutstream.cc | 71 ++++++++++++ - qt4/src/poppler-qt4.h | 85 +++++++++++--- - 9 files changed, 483 insertions(+), 107 deletions(-) - -commit 547db8be1ab0b2987f0f06d8529eaaed2414028c -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jan 22 13:22:20 2008 +0100 - - Fix a crash when createAnnot returns NULL due to invalid annot dict. - - poppler/Annot.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 0d558841142587d66bd3b2025e5a9ca39f7a6159 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Jan 21 21:43:39 2008 +0100 - - Fix another reversed comparison due to cmp - - poppler/Annot.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit cb6a87e39336e2e3893f3e5f577e4d176d237a9f -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Mon Jan 21 10:07:35 2008 +0100 - - Fixed a few compare issues with Annots. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 24 ++++++++++++------------ - 1 file changed, 12 insertions(+), 12 deletions(-) - -commit 7cf85dc8d7c895a211684c7d36757063ed4f469b -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Mon Jan 21 21:27:49 2008 +0100 - - The glade file needs to be distributed - - test/Makefile.am | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 46e93d31dd9b5909ecd8f7a8f8de23329444a7bc -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Sun Jan 20 19:56:51 2008 +0100 - - we need time.h if we use time() - - poppler/PDFDoc.cc | 1 + - 1 file changed, 1 insertion(+) - -commit a0adb006c38ea07f010a01d9c0bb07ca0f48939d -Author: Pino Toscano <pino@kde.org> -Date: Sun Jan 20 19:55:55 2008 +0100 - - Added a saveAs() overload which takes a plain OutStream - - poppler/PDFDoc.cc | 9 +++++++-- - poppler/PDFDoc.h | 2 ++ - 2 files changed, 9 insertions(+), 2 deletions(-) - -commit fcdd5c51f370d040ae57aa64801c9bd4dbe88752 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Jan 19 18:00:10 2008 +0100 - - Do not render images when getting the image mapping, it can be done - later on demand. - - glib/poppler-page.cc | 81 +++++++++++++++------------- - glib/poppler-page.h | 6 ++- - poppler/CairoOutputDev.cc | 131 - ++++++++++++++++++++++++++-------------------- - poppler/CairoOutputDev.h | 12 ++++- - 4 files changed, 135 insertions(+), 95 deletions(-) - -commit 37ae465775d9a53e7c06cf51aa215439214fd79c -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Sat Jan 19 14:00:31 2008 +0100 - - ignore pdf-fullrewrite binary - - test/.gitignore | 1 + - 1 file changed, 1 insertion(+) - -commit 1d160935ea4c1116b745c584ed7f1fd03fbbfb46 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Sat Jan 19 13:59:46 2008 +0100 - - AnnotWidget support and few fixes - - poppler/Annot.cc | 243 - ++++++++++++++++++++++++++++++++++++++++++++++++++++--- - poppler/Annot.h | 142 +++++++++++++++++++++++++++++--- - 2 files changed, 365 insertions(+), 20 deletions(-) - -commit 0e91a3973e525d65236d15930a8ea0e5bbb6a6cc -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Sat Jan 19 13:59:25 2008 +0100 - - AnnotTextMarkup support and improved AnnotQuadrilaterals - - poppler/Annot.cc | 356 - ++++++++++++++++++++++++++++++++++++++++++++----------- - poppler/Annot.h | 130 +++++++++++++++++--- - 2 files changed, 400 insertions(+), 86 deletions(-) - -commit c13952cd56a40bad14a1bf28699b137f65162f10 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Sat Jan 19 13:59:02 2008 +0100 - - Changed AnnotQuadrilateral parsing inside AnnotLink - - poppler/Annot.cc | 246 - ++++++++++++++++++++++++++++++------------------------- - poppler/Annot.h | 19 +++-- - 2 files changed, 144 insertions(+), 121 deletions(-) - -commit 2f821f10fbbba9363405201c86494cd861cec2b2 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Sat Jan 19 13:49:43 2008 +0100 - - Add AnnotQuadPoints class - - poppler/Annot.cc | 16 ++++++++++++++++ - poppler/Annot.h | 23 +++++++++++++++++++++++ - 2 files changed, 39 insertions(+) - -commit de4c8fa6607e55c199bede1dc731227692ef4f53 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Sun Dec 30 21:21:56 2007 +0100 - - AnnotFreeText support. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 232 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++- - poppler/Annot.h | 127 ++++++++++++++++++++++++++++++ - 2 files changed, 358 insertions(+), 1 deletion(-) - -commit c3504a87933ae1516b1ef05e527fd1c039091235 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Sun Dec 30 19:37:18 2007 +0100 - - Improved AnnotLink support. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 116 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Annot.h | 51 ++++++++++++++++++++++++ - 2 files changed, 167 insertions(+) - -commit a20468cc38bb590124b2b028a08f364f90f2487f -Author: Julien Rebetez <julien@fhtagn.net> -Date: Sat Jan 19 13:02:17 2008 +0100 - - Adds a test application to test full rewrite functionnality. - - test/Makefile.am | 11 ++++++++++- - test/pdf-fullrewrite.cc | 44 ++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 54 insertions(+), 1 deletion(-) - -commit 246294714c6011651fd0e5b3649bd65919058c72 -Author: Julien Rebetez <julien@fhtagn.net> -Date: Sat Jan 19 12:59:03 2008 +0100 - - FormWidget's 'modified' member variable is now updated correctly - each time an update is done. - - Before, only text FormWidget had their 'modified' field set to 'true' - if they had been updated. - It is now the case for the other type of FormWidgets. - - poppler/Form.cc | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -commit 6e0f297b8b17afb95779724b8618ca39016e664a -Author: Julien Rebetez <julien@fhtagn.net> -Date: Sat Jan 19 12:54:09 2008 +0100 - - Annot will save their generated appearance in their AP dict. - - poppler/Annot.cc | 42 ++++++++++++++++++++++++++++++++++++++---- - poppler/Annot.h | 1 + - 2 files changed, 39 insertions(+), 4 deletions(-) - -commit e20f6a8e9ac3936b4bc03710a71fe390dfc4c094 -Author: Julien Rebetez <julien@fhtagn.net> -Date: Sat Jan 19 12:52:02 2008 +0100 - - Add deep copy constructor to Dict. - - poppler/Dict.cc | 14 +++++++++++++- - poppler/Dict.h | 1 + - 2 files changed, 14 insertions(+), 1 deletion(-) - -commit e8d46cab77c7167edb0896296118daafc0f13b6d -Author: Julien Rebetez <julien@fhtagn.net> -Date: Sat Jan 19 12:51:44 2008 +0100 - - Adds the ability to save PDF using either incremental update or by - rewriting completly the PDF. - - poppler/PDFDoc.cc | 379 - +++++++++++++++++++++++++++++++++++++++++++++++++++++- - poppler/PDFDoc.h | 18 ++- - poppler/XRef.cc | 12 +- - poppler/XRef.h | 3 +- - 4 files changed, 402 insertions(+), 10 deletions(-) - -commit 742b0c3dec01d8672b84f56d5bb0e2890b178594 -Author: Julien Rebetez <julien@fhtagn.net> -Date: Sat Jan 19 12:51:27 2008 +0100 - - Make the md5 method of Decrypt public so it can be used by other - files. - - poppler/Decrypt.cc | 5 ++--- - poppler/Decrypt.h | 1 + - 2 files changed, 3 insertions(+), 3 deletions(-) - -commit bb7867976740dea259d4110c072552fc5953910f -Author: Julien Rebetez <julien@fhtagn.net> -Date: Sat Jan 19 12:51:07 2008 +0100 - - Modify the writeToFile method of XRef so it uses OutStream instead - of a C file descriptor. - - poppler/XRef.cc | 10 +++++----- - poppler/XRef.h | 2 +- - 2 files changed, 6 insertions(+), 6 deletions(-) - -commit d80736587fdbc0e163077f27bfd21c5e3a7fa4c7 -Author: Julien Rebetez <julien@fhtagn.net> -Date: Sat Jan 19 12:50:49 2008 +0100 - - Adds addIndirectObject method to XRef. This method allow the creation - of new indirect objects. - - poppler/XRef.cc | 39 +++++++++++++++++++++++++++++++++++++++ - poppler/XRef.h | 1 + - 2 files changed, 40 insertions(+) - -commit 8bd00dd0872191b8806e9411d9a1adc441f08a47 -Author: Julien Rebetez <julien@fhtagn.net> -Date: Sat Jan 19 12:50:16 2008 +0100 - - Add some unfiltered methods to input stream. - - With these methods, it is possible to read the raw content from the - stream, without any filtering (even not the headers). - - poppler/Stream.cc | 41 ++++++++++++++++++++++++++++------------- - poppler/Stream.h | 26 ++++++++++++++++++++++++++ - 2 files changed, 54 insertions(+), 13 deletions(-) - -commit 8bcda287ddd316f90b3e47a3a307fbe63a5c21f7 -Author: Julien Rebetez <julien@fhtagn.net> -Date: Sat Jan 19 12:46:53 2008 +0100 - - Add setNeedFree method to MemStream so it is possible to choose if - the stream should take care of deleting the buffer. - - poppler/Stream.h | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 4fbd143de7e3a8ab386dd14b057e62b3b9fe04e4 -Author: Julien Rebetez <julien@fhtagn.net> -Date: Sat Jan 19 12:45:54 2008 +0100 - - Add Outstream, a base class for output streams and FileOutStream, - which implements OutStream for output to a file. - - poppler/Stream.cc | 55 +++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Stream.h | 64 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 119 insertions(+) - -commit 696eaa47169fb063b7e6998c876926c578b6fbfa -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jan 17 15:56:59 2008 +0100 - - Fix a crash when editing text form fields - - poppler/Annot.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 9ec1b28dcdade12498b94b650c26483581294ee6 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jan 17 14:54:34 2008 +0100 - - Fix a crash when a form field contains reference to non existant - children - - poppler/Form.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit f7ed40c465033bad26dfda008c5984954baa0607 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jan 16 21:01:50 2008 +0100 - - Add a cast to fix build - - glib/demo/info.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 1c0aa21e598b879ec49d96700e6438ccb8ac2283 -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Fri Jan 11 20:28:49 2008 +0100 - - rename info.c to info.cc to fix bug 14024 - - glib/demo/Makefile.am | 2 +- - glib/demo/info.c | 243 - -------------------------------------------------- - glib/demo/info.cc | 243 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 244 insertions(+), 244 deletions(-) - -commit 88f8bf850b6c41d25b9576597b5fc5bd75a122f4 -Author: Kjartan Maraas <kmaraas@gnome.org> -Date: Thu Jan 10 23:51:54 2008 +0100 - - Fix two use after free bugs in HtmlOutputDev.cc - - utils/HtmlOutputDev.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 348f4f9d9d5b0f91da6f46e0fcefec80255d4179 -Merge: 8a8a4f0 4eca2e0 -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Sat Jan 5 23:03:06 2008 +0100 - - Merge branch 'master' of - ssh://aacid@git.freedesktop.org/git/poppler/poppler - -commit 8a8a4f01272fb86898fafbda07129c0cbc03d527 -Author: Pino Toscano <pino@kde.org> -Date: Sat Jan 5 23:02:22 2008 +0100 - - Make Document::renderHints return the correct render hints - - qt4/src/poppler-document.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 4eca2e041c93349e0c4666e83ad1ca3caff91dee -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jan 1 14:34:00 2008 +0100 - - Add page transitions demo - - glib/demo/Makefile.am | 2 + - glib/demo/main.c | 16 +-- - glib/demo/transitions.c | 321 - ++++++++++++++++++++++++++++++++++++++++++++++++ - glib/demo/transitions.h | 31 +++++ - 4 files changed, 363 insertions(+), 7 deletions(-) - -commit e92b50bbd3dfc8657b611e3c33129d7c5bae2319 -Author: Koji Otani <sho@bbr.jp> -Date: Wed Dec 26 18:56:01 2007 +0100 - - Use getEmbeddedFontID instead of getEmbeddedFontName to check if a - font is embedded or not - - poppler/GfxFont.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 30e9bae97e3742913015f7ea46636b2b80937612 -Author: Ed Catmur <ed@catmur.co.uk> -Date: Sat Dec 22 22:54:51 2007 +0100 - - Fixlets for Adobe Glyph Naming convention implementation - - poppler/GfxFont.cc | 94 - ++++++++++++++++++++++++++++-------------------------- - 1 file changed, 48 insertions(+), 46 deletions(-) - -commit 40551e616b007ceb15c9d6e3d77c24538ffec924 -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Sat Dec 22 14:31:50 2007 +0100 - - Check the destination page of the link does exist - - qt4/src/poppler-link.cc | 20 ++++++++++++-------- - 1 file changed, 12 insertions(+), 8 deletions(-) - -commit c06d6f2236d854f05e7621be280109ff27dc73b9 -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Thu Dec 20 20:13:08 2007 +0100 - - Use UnicodeParsedString that does exactly what this code does - - qt4/src/poppler-document.cc | 28 +--------------------------- - 1 file changed, 1 insertion(+), 27 deletions(-) - -commit 5f9f06a10fdb72a9d809ee1f779e1a8f549840e7 -Author: Koji Otani <sho@bbr.jp> -Date: Thu Dec 20 19:59:26 2007 +0100 - - Fix for latest CJK code - - See - http://lists.freedesktop.org/archives/poppler/2007-December/003244.html - for more information - - poppler/GfxFont.cc | 14 ++++++++++---- - 1 file changed, 10 insertions(+), 4 deletions(-) - -commit bb49e1e3909fc7392c197dc67d9b7f5312fd0dad -Author: Ed Catmur <ed@catmur.co.uk> -Date: Tue Dec 18 20:20:11 2007 +0100 - - Implement Adobe Glyph Naming convention - - poppler/GfxFont.cc | 183 - ++++++++++++++++++++++++++++++++++++++++++++--------- - 1 file changed, 154 insertions(+), 29 deletions(-) - -commit 5634d63abdd64d371f2e8687a1c172f55b052008 -Author: Koji Otani <sho@bbr.jp> -Date: Mon Dec 17 20:43:41 2007 +0100 - - Allow seting some more Graphics States (Font, LW, LC, LJ, ML, D, - RI, FL) by operator 'gs' - - poppler/Gfx.cc | 67 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 67 insertions(+) - -commit 7a9e7fc96b47b9d833300233ac38bbd60097f425 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Dec 16 21:21:08 2007 +0100 - - Add AnnotLink class so that link annots are properly recognized - - Right now, all of the annots except Text, are created using the - base class Annot which sets the type to unknown. For link annots this - causes the border never be drawn, since we are checking first - whether the - annot is a Link and it's always false. - - poppler/Annot.cc | 12 +++++++++++- - poppler/Annot.h | 10 ++++++++++ - 2 files changed, 21 insertions(+), 1 deletion(-) - -commit 796d9cb9b188a8af69d7fbf9bccbb408cbf6a71a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Dec 15 15:21:49 2007 +0100 - - Fix a crash when trying to create a temp annot with catalog = NULL - - poppler/Annot.cc | 7 +++++++ - poppler/Annot.h | 1 + - poppler/Form.cc | 6 ++---- - 3 files changed, 10 insertions(+), 4 deletions(-) - -commit 99f049f0dfbfd9c22bea56ae96253837ae421e23 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Dec 14 15:26:24 2007 +0100 - - Use the default dash array when it's not correct in AnnotBorderBS - - poppler/Annot.cc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -commit cb2a997aa6f9dd5508ca8b04e63815da893497ef -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Dec 14 14:12:14 2007 +0100 - - Fix another crash due to uninitialized variables - - poppler/Annot.cc | 18 ++++++++---------- - poppler/Annot.h | 1 + - 2 files changed, 9 insertions(+), 10 deletions(-) - -commit f704e86d8c72bacbd9443c4d828cd284d3a11753 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Dec 14 12:58:12 2007 +0100 - - Fix several crashes due to uninitialized variables in Annots. - - poppler/Annot.cc | 11 +++++++---- - 1 file changed, 7 insertions(+), 4 deletions(-) - -commit 0820a93ba1c0e893681024feb9f9bd120a9eeb4d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Dec 14 12:38:58 2007 +0100 - - Check whether top and left should be changed in FitH, FitV, FitBH - and FitBV destinations - - According to the spec, if a null value is specified for top or left - parameter in such - destinations, the parameter should be retained unchanged. - - poppler/Link.cc | 36 ++++++++++++++++++++++++++++-------- - 1 file changed, 28 insertions(+), 8 deletions(-) - -commit 0fb42a2f557d5ec83b42326eb6b0be41622ca328 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Wed Dec 12 01:02:31 2007 +0100 - - Changed getters to const - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 28 +++++++++++----------- - poppler/Annot.h | 72 - ++++++++++++++++++++++++++++---------------------------- - 2 files changed, 50 insertions(+), 50 deletions(-) - -commit 29d39a8ae120e6045a16a7aa0944c36560b42508 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Mon Dec 10 17:56:44 2007 +0100 - - AnnotText support. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 123 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++- - poppler/Annot.h | 65 ++++++++++++++++++++++++----- - 2 files changed, 177 insertions(+), 11 deletions(-) - -commit 2acecde458122bd67487cc302478befa78bf6fbe -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Mon Dec 10 16:45:46 2007 +0100 - - AnnotMarkup support. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 115 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Annot.h | 51 ++++++++++++++++++++++++ - 2 files changed, 166 insertions(+) - -commit 1f8c1fe34e04688d2ba200f1166cfdd1ffe563f0 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Mon Dec 10 16:34:01 2007 +0100 - - AnnotPopup support. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 34 ++++++++++++++++++++++++++++++++++ - poppler/Annot.h | 21 +++++++++++++++++++++ - 2 files changed, 55 insertions(+) - -commit 6c83e06fb2eb77d0dbefd1ebfbcac3e5f0cbb622 -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Mon Dec 10 16:24:38 2007 +0100 - - Prepare code to Annotation Subtype support. - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - glib/poppler-page.cc | 11 +--- - poppler/Annot.cc | 160 - ++++++++++++++++++++++++++++++++++++--------------- - poppler/Annot.h | 54 ++++++++++++++--- - poppler/Form.cc | 6 +- - 4 files changed, 167 insertions(+), 64 deletions(-) - -commit fa0bb5bbea5bf2769c8b3084f78770b7781002eb -Author: Iñigo Martínez <inigomartinez@gmail.com> -Date: Mon Dec 10 15:41:38 2007 +0100 - - Various Annot improvements - - Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> - - poppler/Annot.cc | 613 - ++++++++++++++++++++++++++++++++++++------------------- - poppler/Annot.h | 140 +++++++++++-- - poppler/Gfx.cc | 21 +- - poppler/Gfx.h | 5 +- - 4 files changed, 543 insertions(+), 236 deletions(-) - -commit e0f49fd5aef3c798798ad7e7dba55857bde1b4c0 -Author: Koji Otani <sho@bbr.jp> -Date: Thu Dec 13 23:40:46 2007 +0100 - - Some CJK charecters are displayed vertical glyphs incorrectly when - horizontal mode - - poppler/GfxFont.cc | 46 +++++++++++++++++++++++++--------------------- - 1 file changed, 25 insertions(+), 21 deletions(-) - -commit 85901922bf354a1268037d0b6ec5cbf14da979a1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Dec 13 23:30:59 2007 +0100 - - Yet another gmallocn to gmallocn_checkoverflow - - Fixes http://bugs.kde.org/show_bug.cgi?id=153949 - - poppler/SplashOutputDev.cc | 23 ++++++++++++++++------- - 1 file changed, 16 insertions(+), 7 deletions(-) - -commit f24259cddb9c5e02cf9d2071bfa0106f3e88bd59 -Author: Koji Otani <sho@bbr.jp> -Date: Mon Dec 10 23:24:14 2007 +0100 - - Display characters outside of unicode BMP with TT font - - fofi/FoFiTrueType.cc | 33 ++++++++++++++++++++--- - fofi/FoFiTrueType.h | 2 +- - poppler/CMap.cc | 34 ++++++++++++++++++++++++ - poppler/CMap.h | 4 +++ - poppler/GfxFont.cc | 75 - ++++++++++++++++++++++++++++++++-------------------- - 5 files changed, 115 insertions(+), 33 deletions(-) - -commit 7cbabbf378cf5a9c0411558ff02b44dec2040ea1 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Dec 10 22:00:30 2007 +0100 - - Fix a crash when marked content properties operator is not a dict. - - poppler/Gfx.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit e807f9c72c7f0c5cc0655918f676f4af54739442 -Merge: bf57117 e2ea743 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Dec 9 18:07:30 2007 +0100 - - Merge branch 'master' of - ssh://aacid@git.freedesktop.org/git/poppler/poppler - -commit bf57117df8786778faf31e5d843533004f867ff3 -Author: Adrian Johnson <ajohnson@redneon.com> -Date: Sun Dec 9 18:07:00 2007 +0100 - - Add support for ActualText entries - - Patch by Adrian Johnson with two minor changes by me (one fordward - declaration and a leak fix) - - poppler/Form.cc | 2 +- - poppler/Gfx.cc | 2 +- - poppler/OutputDev.cc | 2 +- - poppler/OutputDev.h | 2 +- - poppler/PDFDocEncoding.h | 4 ++ - poppler/TextOutputDev.cc | 98 - +++++++++++++++++++++++++++++++++++++++++++++++- - poppler/TextOutputDev.h | 11 ++++++ - 7 files changed, 116 insertions(+), 5 deletions(-) - -commit e2ea7430e7d6db50cbfdac34713915e5b0942a89 -Author: Albert Astals Cid <tsdgeos@localhost.(none)> -Date: Sat Dec 8 23:21:34 2007 +0100 - - disable warnings about assigning const char * to char * - - We have them all over the place and we are not going to fix it as - that'll be too much overhead when re-merging xpdf changes - - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit acf70c666d4f534cd97de64d4378bf6399e31fd4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Dec 6 23:58:26 2007 +0100 - - Disable gtk tests if the user disabled glib frontend - - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit bb0ec68f21d355081ff75aad641bc3809141e398 -Merge: 5a34cdd b925ea2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Dec 6 18:38:54 2007 +0100 - - Merge branch 'master' of - ssh://aacid@git.freedesktop.org/git/poppler/poppler - -commit b925ea232b6ed5028712600f9aebe453f3b2ba06 -Author: Brad Hards <bradh@kde.org> -Date: Tue Dec 4 19:11:13 2007 +1100 - - Remove redundant check. - - poppler/PSOutputDev.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 275afca4ef24020273df652ccfdf76c6994e9294 -Author: Brad Hards <bradh@kde.org> -Date: Sun Dec 2 19:45:16 2007 +1100 - - Preserve PDF page labels when we output as postscript. - - Resolves bug 13338. - - poppler/PSOutputDev.cc | 81 - +++++++++++++++++++++++++++++++++++++++++++++++++- - poppler/PSOutputDev.h | 2 ++ - 2 files changed, 82 insertions(+), 1 deletion(-) - -commit 641edb83a457083c13f3e374f6ac6c570dd54d7f -Author: Brad Hards <bradh@kde.org> -Date: Wed Nov 28 19:42:53 2007 +1100 - - Minor API documentation update - - qt4/src/poppler-annotation.h | 81 - ++++++++++++++++++++++++++++++++++++++++++-- - 1 file changed, 79 insertions(+), 2 deletions(-) - -commit 3635ec6fcbc89daf633c03efb644df9031b80f59 -Author: Brad Hards <bradh@kde.org> -Date: Wed Nov 28 19:42:22 2007 +1100 - - Update doxygen configuration file to version 1.5.3 - - qt4/src/Doxyfile | 185 - ++++++++++++++++++++++++++++++++++++++++++------------- - 1 file changed, 141 insertions(+), 44 deletions(-) - -commit 02c7ea6e1fd3e225de1eda231813f4db0ffb9fdb -Author: Brad Hards <bradh@kde.org> -Date: Wed Nov 28 19:41:54 2007 +1100 - - Fix off-by-one in printCommands path. - - poppler/Gfx.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 74af7c1209f47ed39addf7fde3ea106a7c77a408 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Nov 24 18:12:00 2007 +0100 - - Convert passwords from utf-8 to latin-1 when needed. Fixes bug #4557 - - glib/poppler-document.cc | 16 ++++++++++++++-- - 1 file changed, 14 insertions(+), 2 deletions(-) - -commit 5a34cddf043cb484549cb411e034786a7d8688a3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Nov 23 23:13:57 2007 +0100 - - add a ignore - - glib/demo/.gitignore | 1 + - 1 file changed, 1 insertion(+) - -commit 21a58562cc1e575ec3d81b6e34bfcb21306eb67f -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Nov 23 23:12:06 2007 +0100 - - sscanf does not like null strings, so don't call it on empty qstrings - - qt/poppler-document.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 6f8451cf9d19f57f658d1568643ecb0f953e1075 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sun Nov 11 21:29:40 2007 -0500 - - Add support for knockout groups to the cairo backend - - This is sort of hacky because we need to keep track of shape and - opacity - seperately. It is also probably not entirely correct. However, - it should be - closer than previously. - - poppler/CairoOutputDev.cc | 309 - ++++++++++++++++++++++++++++++++++++++++++++-- - poppler/CairoOutputDev.h | 8 +- - 2 files changed, 303 insertions(+), 14 deletions(-) - -commit b0fbfb0ac366434d7e4c0350a9be83ddda7b03cf -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sun Nov 11 16:06:16 2007 -0500 - - Track the AlphaIsShape and TextKnockout state - - Parse, store and notify the OutputDevices about these entries. - - poppler/Gfx.cc | 14 ++++++++++++++ - poppler/GfxState.h | 6 ++++++ - poppler/OutputDev.h | 2 ++ - 3 files changed, 22 insertions(+) - -commit f6429b13a972f2deb25b3d3a9948dca024a54841 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sat Nov 10 14:08:09 2007 -0500 - - Fix accidental mode change. - - poppler/CairoFontEngine.cc | 0 - poppler/CairoOutputDev.cc | 0 - 2 files changed, 0 insertions(+), 0 deletions(-) - -commit 5797f50a99d1494767edc5928f9c3e9d927b946d -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sat Nov 10 01:52:00 2007 -0500 - - Scale text to match 'm' size - - This adds back the hack that was removed when fontconfig support - was added long - ago. It's not a great solution but lets us be at least as good as - xpdf. Fixes - #12304 with the cairo backend. The problem persists with the splash - backend. - - poppler/CairoFontEngine.cc | 56 - +++++++++++++++++++++++++++++++++++++++++++--- - poppler/CairoFontEngine.h | 7 +++++- - poppler/CairoOutputDev.cc | 8 +++++-- - 3 files changed, 65 insertions(+), 6 deletions(-) - -commit 551212e55127c7e46d9aff3318015fd9b5385687 -Author: Brad Hards <bradh@frogmouth.net> -Date: Sat Nov 10 11:56:15 2007 +0100 - - Fix uninitialized variable access - - Supported by Derek B. Noonburg - - poppler/GfxState.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 934a5ae45eb17bd0e2010be89f55510e8a69816b -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sat Nov 3 13:08:51 2007 -0400 - - Avoiding using floating point when converting to luminance. - - The code now also does proper rounding instead of just truncating. - - poppler/CairoOutputDev.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 1b3f045a25e5d172357bc87c15ba591c8e1511a7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Nov 8 23:34:07 2007 +0100 - - Move another gmallocn to gmallocn_checkoverflow. Fixes crashes on - incorrect pdf sent by Red Hat - - poppler/Stream.cc | 21 +++++++++++++++------ - 1 file changed, 15 insertions(+), 6 deletions(-) - -commit 944d327fd7036332a33b4ad6476ceca7a650ef6e -Merge: fb1d1f4 c340255 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 7 23:52:47 2007 +0100 - - Merge branch 'master' of - ssh://aacid@git.freedesktop.org/git/poppler/poppler - -commit fb1d1f459784a6c19034212a617268f7f5a90e9c -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 7 23:51:58 2007 +0100 - - merge ftp://ftp.foolabs.com/pub/xpdf/xpdf-3.02pl2.patch - - poppler/Stream.cc | 417 - +++++++++++++++++++++++++++++++----------------------- - poppler/Stream.h | 10 +- - 2 files changed, 245 insertions(+), 182 deletions(-) - -commit c340255f46bc95b5f850abcd3d9bcdc8594199bb -Author: Brad Hards <bradh@kde.org> -Date: Mon Nov 5 20:36:23 2007 +1100 - - Update .gitignore - - Suppress the noise a bit. - - qt4/.gitignore | 1 + - qt4/tests/.gitignore | 3 +++ - test/.gitignore | 2 ++ - 3 files changed, 6 insertions(+) - -commit cebf770379e7d71166e729aebf771a4ca291d48b -Author: Brad Hards <bradh@kde.org> -Date: Mon Nov 5 20:31:18 2007 +1100 - - Add a new unit test, for non-ASCII searching. - - There is a bug report (bug:7063) about not being able - to find text that isn't ASCII. I think that the problem isn't - in poppler core code - this unit test shows we can find - characters as long as they are properly encoded (which the - Qt4 front end does). - - qt4/tests/Makefile.am | 7 ++++++- - qt4/tests/check_search.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 46 insertions(+), 1 deletion(-) - -commit 570fe464a2aae4f22d0b47cce73b8bc36b116e9f -Merge: 1c7b7a0 7875067 -Author: Brad Hards <bradh@kde.org> -Date: Mon Nov 5 15:55:39 2007 +1100 - - Merge branch 'minor-fixes' - -commit 78750679e213d7307cce38166b6af32562e871b8 -Author: Brad Hards <bradh@kde.org> -Date: Mon Nov 5 15:54:36 2007 +1100 - - Additional check for password protected documents - - We need to bail out on locked documents. In the future, - we could probably go interactive, and ask the user for - a password. - - qt4/tests/test-poppler-qt4.cpp | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit 1c7b7a0c581b542945cac257202bbb819d33694c -Author: Brad Hards <bradh@kde.org> -Date: Mon Nov 5 15:49:45 2007 +1100 - - Minor Qt4 API documentation fix - - Also, this is a test of my git newbie-ness. - - qt4/src/poppler-form.h | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit b86fc565d175835cf27e9c8632da47a5e0b50237 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Nov 5 00:14:55 2007 +0100 - - Fix FSF address - - glib/demo/fonts.c | 2 +- - glib/demo/fonts.h | 2 +- - glib/demo/forms.c | 2 +- - glib/demo/forms.h | 2 +- - glib/demo/info.c | 2 +- - glib/demo/info.h | 2 +- - glib/demo/links.c | 2 +- - glib/demo/links.h | 2 +- - glib/demo/main.c | 2 +- - glib/demo/outline.c | 2 +- - glib/demo/outline.h | 2 +- - glib/demo/page.c | 2 +- - glib/demo/page.h | 2 +- - glib/demo/render.c | 2 +- - glib/demo/render.h | 2 +- - glib/demo/utils.c | 2 +- - glib/demo/utils.h | 2 +- - glib/poppler-action.cc | 2 +- - glib/poppler-action.h | 2 +- - glib/poppler-attachment.cc | 2 +- - glib/poppler-attachment.h | 2 +- - glib/poppler-document.cc | 2 +- - glib/poppler-document.h | 2 +- - glib/poppler-features.h.in | 2 +- - glib/poppler-form-field.cc | 2 +- - glib/poppler-form-field.h | 2 +- - glib/poppler-page.cc | 2 +- - glib/poppler-page.h | 2 +- - glib/poppler.cc | 2 +- - glib/poppler.h | 2 +- - poppler/PageTransition.cc | 2 +- - poppler/Sound.cc | 2 +- - poppler/Sound.h | 2 +- - qt/poppler-document.cc | 2 +- - qt/poppler-fontinfo.cc | 2 +- - qt/poppler-link-qt3.h | 2 +- - qt/poppler-link.cc | 2 +- - qt/poppler-page-transition-private.h | 2 +- - qt/poppler-page-transition.cc | 2 +- - qt/poppler-page-transition.h | 2 +- - qt/poppler-page.cc | 2 +- - qt/poppler-private.h | 2 +- - qt/poppler-qt.h | 2 +- - qt4/src/poppler-annotation-helper.h | 2 +- - qt4/src/poppler-annotation-private.h | 2 +- - qt4/src/poppler-annotation.cc | 2 +- - qt4/src/poppler-annotation.h | 2 +- - qt4/src/poppler-document.cc | 2 +- - qt4/src/poppler-embeddedfile.cc | 2 +- - qt4/src/poppler-fontinfo.cc | 2 +- - qt4/src/poppler-form.cc | 2 +- - qt4/src/poppler-form.h | 2 +- - qt4/src/poppler-link-extractor-private.h | 2 +- - qt4/src/poppler-link-extractor.cc | 2 +- - qt4/src/poppler-link.cc | 2 +- - qt4/src/poppler-link.h | 2 +- - qt4/src/poppler-page-private.h | 2 +- - qt4/src/poppler-page.cc | 2 +- - qt4/src/poppler-private.h | 2 +- - qt4/src/poppler-ps-converter.cc | 2 +- - qt4/src/poppler-qt4.h | 2 +- - qt4/src/poppler-sound.cc | 2 +- - qt4/src/poppler-textbox.cc | 2 +- - 63 files changed, 63 insertions(+), 63 deletions(-) - -commit 37776afc6f8a5733b41da6fb0f45e7ace4edf737 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Nov 5 00:03:55 2007 +0100 - - Update from http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - - COPYING | 27 +++++++++++++-------------- - 1 file changed, 13 insertions(+), 14 deletions(-) - -commit 34a90b35998b65539cf1e8f09194d45db71064a1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Nov 4 14:03:35 2007 +0100 - - Remove duplicate checking - - poppler/JBIG2Stream.cc | 8 -------- - 1 file changed, 8 deletions(-) - -commit d694e1dd042fb97fbc62046b69cafe30d6f9ea58 -Merge: ba5b31c 432e657 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Nov 4 13:26:47 2007 +0100 - - Merge branch 'master' of - ssh://aacid@git.freedesktop.org/git/poppler/poppler - -commit ba5b31c6a8b2317332bfa148f6d80f66891fb9ce -Author: Brad Hards <bradh@frogmouth.net> -Date: Sun Nov 4 13:25:12 2007 +0100 - - Require fontconfig >= 2.0 Fixes bug 9020 - - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 432e657a49cb097638a79e38c141088039572816 -Author: Jeff Muizelaar <jeff@freiheit.infidigm.net> -Date: Mon Sep 17 19:15:21 2007 -0400 - - Use realloc/free instead of new/delete when resizing GooStrings - - This allows for a large performance improvement when appending a - large number - of characters to a GooString. This is especially helpful for - TextOutputDev on - large PDFs. For example, the following code has the potential to be - O(n) instead of - O(n²) with a good implementation of realloc. - - while (n) { - string.append(character); - n--; - } - - goo/GooString.cc | 30 +++++++++++++++++------------- - 1 file changed, 17 insertions(+), 13 deletions(-) - -commit cb80112afed2c5b9642c3c43f1cc001ed88d08cb -Author: Jonathan Kew <jonathan_kew@sil.org> -Date: Thu Nov 1 20:53:05 2007 +0100 - - Do not try to parse directories when processing nameToUnicode - dir. Fixes ugly warnings on mingw32 - - poppler/GlobalParams.cc | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit ad6b888edff7b30be72df948c4052b9934a37705 -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Thu Nov 1 20:48:21 2007 +0100 - - Add some castings to make it compile - - glib/test-poppler-glib.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit a968dcc759379f48265c91bea63ca4cf987d94a9 -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Wed Oct 31 23:53:39 2007 +0100 - - Tests for passwords - - qt4/tests/Makefile.am | 13 +++++- - qt4/tests/check_password.cpp | 87 - ++++++++++++++++++++++++++++++++++++++++ - qt4/tests/stress-poppler-dir.cpp | 63 +++++++++++++++++++++++++++++ - qt4/tests/test-poppler-qt4.cpp | 15 ++++++- - 4 files changed, 175 insertions(+), 3 deletions(-) - -commit 7b7a08863a8278dee7aa1fe7789cf72223c26b35 -Author: Brad Hards <bradh@frogmouth.net> -Date: Wed Oct 31 23:53:27 2007 +0100 - - Improve documentation - - qt4/src/poppler-qt4.h | 64 - ++++++++++++++++++++++++++++++++++++++++++++------- - 1 file changed, 56 insertions(+), 8 deletions(-) - -commit 96493c9409186a7e964e894c7f730962b6995fd7 -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Wed Oct 31 23:51:25 2007 +0100 - - remove old file - - glib/test-poppler-glib.c | 514 - ----------------------------------------------- - 1 file changed, 514 deletions(-) - -commit 951a05f7a11af4a44e4cb85a015939d6a3e513f5 -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Sat Oct 27 12:33:22 2007 +0200 - - Remove fordward declaration of a non-existant class - - poppler/Form.h | 1 - - 1 file changed, 1 deletion(-) - -commit 289679405ab143bc2106cf269227c514a1602e56 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Thu Oct 25 22:16:10 2007 -0400 - - Avoid drawing borders unless /W and /S are specified in /BS - - Acroread doesn't sometimes doesn't draw borders when you'd - expect it to. Special case that behaviour so that we do the - same thing. - - poppler/Annot.cc | 15 ++++++++++++--- - 1 file changed, 12 insertions(+), 3 deletions(-) - -commit ab0a6c37faf9916edcd70e128d9f2654eb795ace -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Thu Oct 25 20:56:58 2007 +0200 - - Fix compilation on mingw. Bug 12493 - - Added a check for localtime_r in configure.ac - Moved test-poppler-glib.c to test-poppler-glib.cc to get the correct - compiler - - configure.ac | 1 + - glib/Makefile.am | 2 +- - glib/test-poppler-glib.cc | 520 - ++++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 522 insertions(+), 1 deletion(-) - -commit 6bd637dc135045b20abf024d394538d7a3160795 -Merge: c01ab71 25b273d -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Tue Oct 23 23:27:01 2007 +0200 - - Merge branch 'master' of - ssh://aacid@git.freedesktop.org/git/poppler/poppler - -commit c01ab714ecd42e39ecb0be1c0c2504635251ac01 -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Tue Oct 23 23:26:21 2007 +0200 - - Provide setters for some methods that only had getters. Fixes - bug 12894 - - poppler/GlobalParams.cc | 49 - +++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/GlobalParams.h | 7 +++++++ - 2 files changed, 56 insertions(+) - -commit 25b273db677815c8df11e52fe9df29fe857a8a88 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Mon Oct 22 23:01:37 2007 -0400 - - Unset the font if it doesn't exist or we can not load it properly - - Previously, the previous font stayed current and glyphs would be - drawn using - it. This resulted in random glyphs being chosen unless the encodings - happened - to match. Now, instead, we draw nothing which matches the behaviour of - acroread. - - poppler/Gfx.cc | 4 ++++ - poppler/GfxFont.cc | 4 ++++ - 2 files changed, 8 insertions(+) - -commit 57331767ed5306eba1f9bf60e48fc88debdc2198 -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Mon Oct 22 23:33:59 2007 +0200 - - builddir != srcdir fixes by Christian Persch <chpe gnome org> - - autogen.sh | 7 ++++--- - glib/demo/Makefile.am | 1 + - 2 files changed, 5 insertions(+), 3 deletions(-) - -commit 2a333e5a618b5c92f3c703816b950321f25d3aab -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Mon Oct 22 22:14:43 2007 +0200 - - Splash rework, check if font is inside clip area before rendering - it to a temporary bitmap. Fixes KDE bug 150693 - - This change is not trivial. What i did is: - It is getGlyph the one that does the intersection between clip area - and rendering area of the font instead fillGlyph2 - That means some clipRes = state->clip->testRect but we win more - robustness against broken pdf that specify HUGE fonts - - splash/Splash.cc | 207 - ++++++++++++++++++++++++------------------------- - splash/Splash.h | 4 +- - splash/SplashFTFont.cc | 23 +++++- - splash/SplashFTFont.h | 4 +- - splash/SplashFont.cc | 29 +++++-- - splash/SplashFont.h | 5 +- - splash/SplashT1Font.cc | 11 ++- - splash/SplashT1Font.h | 4 +- - 8 files changed, 162 insertions(+), 125 deletions(-) - -commit cf785cd12ae77e8dd778ed043584f8f26efe675f -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Mon Oct 22 21:59:35 2007 +0200 - - Add gmallocn_checkoverflow, it's the same as gmallocn but returns - NULL on overflow instead of doing exit() - - goo/gmem.cc | 18 ++++++++++++++++++ - goo/gmem.h | 3 +++ - 2 files changed, 21 insertions(+) - -commit 37e16ac301a35ceca2e3535f8c6100d4cf723c82 -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Mon Oct 22 21:54:02 2007 +0200 - - exit(1) is bad in library code, use the src.abort method to describe - failure - - poppler/DCTStream.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit dbe975c129999a3efceb1c86518fa6fda74f685c -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Oct 22 11:25:37 2007 +0200 - - Fix a crash with invalid TrueType fonts - - fofi/FoFiTrueType.cc | 10 ++++++---- - 1 file changed, 6 insertions(+), 4 deletions(-) - -commit 8bfe30a48fd7021591ab307bd51f86c06ff202b9 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Oct 19 15:46:50 2007 +0200 - - Do not generate appearance stream for radio button that are not active - - poppler/Annot.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit 1a531dcfee1c6fc79a414c38cbe7327fbf9a59d8 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Oct 19 13:12:24 2007 +0200 - - Fix a crash with invalid embedded fonts - - poppler/CairoFontEngine.cc | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit e1740278457e512676b623bcdf9968193f0a8d7b -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Oct 19 12:21:54 2007 +0200 - - Do not draw annotations when rendering for printing - - glib/poppler-page.cc | 25 ++++++++++++++++++++++--- - poppler/Annot.h | 2 ++ - 2 files changed, 24 insertions(+), 3 deletions(-) - -commit a4d25f79dfc1a7e4998e2e113ef92312bd4af553 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Oct 16 15:24:08 2007 +0200 - - Detect form fields at any depth level - - We were ignoring non root form fields that contain only a kids - dictionary. - See evince bug: http://bugzilla.gnome.org/show_bug.cgi?id=486957 - - poppler/Form.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 03e1da99f7393fb1103643311b0b5af7b875e09c -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sat Oct 13 19:38:15 2007 -0400 - - Add an implementation of CairoOutputDev::startPage() - - The implementation initializes fill_pattern and stroke_pattern - to black matching SplashOutputDev. This fixes #12504. - - poppler/CairoOutputDev.cc | 9 +++++++++ - poppler/CairoOutputDev.h | 2 +- - 2 files changed, 10 insertions(+), 1 deletion(-) - -commit 825c942d46e0c3e254028441015c5dd8440cc734 -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Fri Oct 12 13:47:09 2007 +0200 - - Copy the embeddef file description string correctly - - poppler/Catalog.cc | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit 5e60da78695eff44cc10dbce46ef170727f682b1 -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Fri Oct 12 13:46:52 2007 +0200 - - Correctly delete the embedded file stream - - qt4/src/poppler-embeddedfile.cc | 1 + - qt4/src/poppler-private.h | 2 +- - 2 files changed, 2 insertions(+), 1 deletion(-) - -commit 1627fbbde8be01af3bdd2583f3439897a37d5215 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sat Oct 6 23:27:40 2007 -0400 - - Use maskWidth and maskHeight for reading from the mask image in - CairoOutputDev::drawMaskedImage() - - Previously, drawMaskedImage() was incorrectly using the image width - and height which is - wrong when width != maskWidth or heigh != maskHeight. Fixes #12668. - - poppler/CairoOutputDev.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 3156d560c5eaf6970da422d0b09fd2e95bfe6d1d -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Oct 5 11:34:01 2007 +0200 - - Fix a crash when Form Fields array contains references - to non existent objects. Fixes bug #11865 - - poppler/Form.cc | 9 +++++++++ - 1 file changed, 9 insertions(+) - -commit f0b5e6286e94c6153c8247b5fae63a18622c48d3 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Oct 4 15:22:01 2007 +0200 - - Do not return unknown field type for signature form fields - - glib/poppler-form-field.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 498fd7fb99b01a879d07e2ad12c0b9462a8fc438 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Oct 4 12:36:39 2007 +0200 - - Add poppler_page_render_for_printing() and - poppler_page_render_to_pixbuf_for_printing() - - We were unconditionally passing printing=gFalse to displaySlice. With - these new - functions we can render to a pixbuf or cairo surface passing - printing=gTrue to - displaySlice. - - glib/poppler-page.cc | 135 - +++++++++++++++++++++++++++++++++++++++++---------- - glib/poppler-page.h | 10 ++++ - 2 files changed, 119 insertions(+), 26 deletions(-) - -commit 56af69787c78c2edbb69266e86a5a5b639ca6d3e -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed Oct 3 23:02:25 2007 -0400 - - Error out if we can't find a .cidToUnicode for a known character - collection - - This situation was caused by the fixes for bug #11413. I'm not sure - it's the best thing to do, but it seems better. - - poppler/GfxFont.cc | 19 +++++++++++++++++++ - 1 file changed, 19 insertions(+) - -commit 3d0df46908379bce1d196b9dc41153b1adb5f725 -Author: Michael Wolf <maw@ximian.com> -Date: Wed Oct 3 19:43:55 2007 +0200 - - Fix compile warning - - glib/test-poppler-glib.c | 2 ++ - 1 file changed, 2 insertions(+) - -commit aba29e12528025c2cc71bf46e02e76ac4db2b193 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Sep 28 21:01:50 2007 +0200 - - Add forms demo to glib poppler demo - - glib/demo/Makefile.am | 2 + - glib/demo/forms.c | 489 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - glib/demo/forms.h | 31 ++++ - glib/demo/main.c | 8 +- - glib/demo/utils.c | 1 - - 5 files changed, 527 insertions(+), 4 deletions(-) - -commit d0c0f26d2c95232c216e3daa15e98a3aff14ac27 -Merge: 59d55f7 38d5bb1 -Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> -Date: Tue Sep 25 03:33:52 2007 -0700 - - Merge branch 'master' of - ssh://kjk@git.freedesktop.org/git/poppler/poppler - -commit 38d5bb150a5fe883da1d4256463d1f796d201283 -Author: Krzysztof Kowalczyk <kkowalczyk@kjkubu.(none)> -Date: Tue Sep 25 16:13:51 2007 -0700 - - Silence deprecation warnings - annoying with msvc 2005. - - makefile.vc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 59d55f7371bee81c9392fa2d4174ceffaacde471 -Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> -Date: Tue Sep 25 01:21:19 2007 -0700 - - Fix misleading comment. - - goo/GooTimer.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit c36d8afc984795aca0a12a94ec7668092067db82 -Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> -Date: Tue Sep 25 00:32:29 2007 -0700 - - Revert "replace extremely confusing 'a*(int)sizeof(foo)/sizeof(foo) - != a' which, due to type promotions, if a is int, is equivalent to - a < 0; fix problems revealed by the change" - - This reverts commit 08bf7c1151d594d4c7d253a2c89f4f3a088ad8ec. - - poppler/XRef.cc | 25 +++++++++++++++++++++---- - 1 file changed, 21 insertions(+), 4 deletions(-) - -commit ff25e83abae1ca17e2e7dd6f20946026fca69fff -Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> -Date: Mon Sep 24 23:57:25 2007 -0700 - - Make perf-test compile on unix as well. - - test/Makefile.am | 16 ++++++- - test/perf-test-preview-dummy.cc | 1 + - test/perf-test.cc | 104 - +++++++++++++++++----------------------- - 3 files changed, 59 insertions(+), 62 deletions(-) - -commit 70f3bf42b3028d9a2e4aefdc2e1a458b3c77b0e7 -Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> -Date: Mon Sep 24 21:26:54 2007 -0700 - - Let perf-test.cc manage lifetime of rendered bitmap. - - test/perf-test-preview-win.cc | 7 ------- - 1 file changed, 7 deletions(-) - -commit b622b252cba068a15eae77df5deb261dd98affaf -Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> -Date: Mon Sep 24 21:20:12 2007 -0700 - - Disable my_error for now - seems to corrupt memory. - - test/perf-test.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit bde8c9669ca6b43cb6a664bd14df164a718041ea -Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> -Date: Mon Sep 24 21:08:58 2007 -0700 - - Con't copy the file unless COPY_FILE is defined. - - test/perf-test.cc | 11 ++++++++++- - 1 file changed, 10 insertions(+), 1 deletion(-) - -commit bf9b46b012c64624818a2110af7c4b7e3b419728 -Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> -Date: Mon Sep 24 20:13:54 2007 -0700 - - Respect -loadonly cmd-line arg. - - test/perf-test.cc | 2 ++ - 1 file changed, 2 insertions(+) - -commit 2f664b654ca19135f0f8a0fe89872b9e0d526fa2 -Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> -Date: Mon Sep 24 19:41:45 2007 -0700 - - Fix msvc debug build. Fix bitmap leak in perf-test. - - makefile.vc | 6 ++++-- - test/perf-test.cc | 1 + - 2 files changed, 5 insertions(+), 2 deletions(-) - -commit 05d41cd5aec39b4e3c8949445a9986e5ca8b50dd -Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> -Date: Mon Sep 24 08:10:37 2007 -0700 - - Use GooTimer instead of my own timer. - - test/perf-test.cc | 98 - +++++-------------------------------------------------- - 1 file changed, 8 insertions(+), 90 deletions(-) - -commit 05fbce5b6657e883ece9054c79576b25271a05a4 -Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> -Date: Mon Sep 24 08:01:11 2007 -0700 - - Make GooTimer work for Windows/msvc build. - - goo/GooTimer.cc | 69 - +++++++++++++++++++++++++++++++++++++++------------------ - goo/GooTimer.h | 28 ++++++++++++++--------- - poppler/Gfx.cc | 11 ++------- - 3 files changed, 66 insertions(+), 42 deletions(-) - -commit 6347915085a487da08d39a859f4261fa812dab09 -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Mon Sep 24 01:08:17 2007 -0700 - - Add Error.cc in msvc build and use setErrorFunction in perf-test. - - makefile.vc | 3 +-- - test/perf-test.cc | 10 +++++----- - 2 files changed, 6 insertions(+), 7 deletions(-) - -commit ed01b3965c57ce2a4eabf9c46b5319ea627d3324 -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Mon Sep 24 01:03:09 2007 -0700 - - Match declaration of setErrorFunction with its definition. - - Also enable this code for Windows, since CDECL was what - was throwing msvc off. - - poppler/Error.cc | 12 +++--------- - 1 file changed, 3 insertions(+), 9 deletions(-) - -commit 71fb15f8bd131a13d8cf0f394fe601cfbb6e1772 -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Mon Sep 24 00:38:29 2007 -0700 - - Even less compiler warnings. - - poppler/CairoOutputDev.cc | 6 +++--- - qt/poppler-page.cc | 3 +++ - utils/HtmlOutputDev.cc | 10 ++++++---- - 3 files changed, 12 insertions(+), 7 deletions(-) - -commit 7ba3f198a0651d2a7c91b7d9e10a5173dc3de0a3 -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Mon Sep 24 00:32:37 2007 -0700 - - Even less compiler warnings. - - qt/poppler-document.cc | 8 ++++++++ - qt/poppler-private.h | 8 -------- - qt4/src/poppler-document.cc | 10 ++++++++++ - qt4/src/poppler-form.cc | 15 +++++++++++++++ - qt4/src/poppler-private.h | 25 ------------------------- - 5 files changed, 33 insertions(+), 33 deletions(-) - -commit ab1059f594cb9fccd8568ca2a535a363c7521daa -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Mon Sep 24 00:14:01 2007 -0700 - - Don't break aliasing. - - poppler/GlobalParams.cc | 40 ++++++++++++++++++---------------------- - 1 file changed, 18 insertions(+), 22 deletions(-) - -commit 71c47b30adf687a0bcece22834933267053360de -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Sun Sep 23 23:49:31 2007 -0700 - - Reduce compiler warnings. - - poppler/JBIG2Stream.cc | 16 ++++++++++++---- - 1 file changed, 12 insertions(+), 4 deletions(-) - -commit 8466d94929844c976bbad8bb7d1ea7f7f77cc196 -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Sun Sep 23 23:34:52 2007 -0700 - - Reduce compiler warnings. Tabs to spaces. - - fofi/FoFiType1C.cc | 30 +++++++++++++++--------------- - 1 file changed, 15 insertions(+), 15 deletions(-) - -commit c53b8ccfba6fa4345086493f9e44212721c11d0a -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Sun Sep 23 23:23:34 2007 -0700 - - Reduce number of compiler warnings. - - poppler/CharCodeToUnicode.cc | 2 +- - poppler/Gfx.cc | 6 ++---- - poppler/PageLabelInfo.cc | 2 ++ - 3 files changed, 5 insertions(+), 5 deletions(-) - -commit abede2a06c5c9dc97b40479deda49621458f1171 -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Sun Sep 23 23:03:36 2007 -0700 - - Reduce number of compiler warnings. - - glib/poppler-action.cc | 1 - - glib/poppler-document.cc | 9 ++------- - glib/poppler-page.cc | 3 +-- - qt/poppler-document.cc | 1 - - qt4/src/poppler-annotation.cc | 16 +++++++++++++--- - 5 files changed, 16 insertions(+), 14 deletions(-) - -commit 60f5bcea4a920441e25ae11d677636242aabb2db -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Sun Sep 23 22:48:06 2007 -0700 - - Remove unused variables. - - utils/pdftoppm.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 3179eee44eb0afbc642675268b9a4abb16ccdde3 -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Sun Sep 23 22:47:21 2007 -0700 - - Remove unused variables. - - utils/HtmlOutputDev.cc | 23 ----------------------- - 1 file changed, 23 deletions(-) - -commit e9dc379190aa3166870d0b11a05ccc4e9dad2706 -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Sun Sep 23 22:41:59 2007 -0700 - - Remove unused variables. - - poppler/ArthurOutputDev.cc | 16 +++++----------- - 1 file changed, 5 insertions(+), 11 deletions(-) - -commit 08bf7c1151d594d4c7d253a2c89f4f3a088ad8ec -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Sun Sep 23 22:28:16 2007 -0700 - - replace extremely confusing 'a*(int)sizeof(foo)/sizeof(foo) != a' - which, due to type promotions, if a is int, is equivalent to a < 0; - fix problems revealed by the change - - poppler/XRef.cc | 25 ++++--------------------- - 1 file changed, 4 insertions(+), 21 deletions(-) - -commit 5a1f670a4d16affeed86cdf643ab22f481caa3a5 -Author: Krzysztof Kowalczyk <kkowalczyk@kjkubu.(none)> -Date: Sun Sep 23 20:42:59 2007 -0700 - - ignore *.o files - - .gitignore | 1 + - 1 file changed, 1 insertion(+) - -commit c156aed7234f82dea4cb384c1b8a7acdd34545be -Author: Krzysztof Kowalczyk <kkowalczyk@kjkubu.(none)> -Date: Sun Sep 23 20:41:19 2007 -0700 - - remove unused variables - - poppler/ABWOutputDev.cc | 10 ++-------- - 1 file changed, 2 insertions(+), 8 deletions(-) - -commit d0bdef4752be5fa609a0766ee87aa54d51611d9a -Author: Krzysztof Kowalczyk <kkowalczyk@kjkubu.(none)> -Date: Sat Sep 22 13:38:03 2007 -0700 - - undo accidental changes to file permissions - - msvc/poppler/poppler-config.h | 0 - poppler/Annot.cc | 0 - poppler/CairoFontEngine.cc | 0 - poppler/CairoOutputDev.cc | 0 - poppler/Catalog.cc | 0 - poppler/Form.cc | 0 - poppler/GfxFont.cc | 0 - poppler/GfxState.cc | 0 - poppler/Page.cc | 0 - poppler/SplashOutputDev.cc | 0 - poppler/TextOutputDev.cc | 0 - splash/Splash.cc | 0 - splash/SplashFTFontEngine.cc | 0 - test/perf-test-preview-dummy.cc | 0 - test/perf-test-preview-win.cc | 0 - test/perf-test.cc | 0 - 16 files changed, 0 insertions(+), 0 deletions(-) - -commit 6c69473f2f4a49757614ddd249e65bb7a13c63c1 -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Fri Sep 21 08:09:53 2007 -0700 - - undo accidental mode change - - makefile.vc | 0 - 1 file changed, 0 insertions(+), 0 deletions(-) - -commit e7e386e7ce8cb8eb8a7037ebdaa601524d332ae7 -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Fri Sep 21 08:08:53 2007 -0700 - - more simplification by removing unneded code - - makefile.vc | 2 +- - test/perf-test.cc | 60 - +++++++++---------------------------------------------- - 2 files changed, 10 insertions(+), 52 deletions(-) - -commit 3e10604637ec193269a3155985476d3b83dc7d62 -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Fri Sep 21 07:48:38 2007 -0700 - - for portability use bool/true/false instead of BOOL/TRUE/FALSE - - test/perf-test.cc | 176 - ++++++++++++++++++++++++++---------------------------- - 1 file changed, 86 insertions(+), 90 deletions(-) - -commit 634718936f2a95fac2a9d12fcea483b3d0ca8fa6 -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Fri Sep 21 07:41:14 2007 -0700 - - simplify perf-test - - test/perf-test-pdf-engine.h | 78 - ------------------------------------------- - test/perf-test-preview-win.cc | 5 ++- - test/perf-test.cc | 75 - +++++++++++++++++++++++++++++++++++++++-- - 3 files changed, 75 insertions(+), 83 deletions(-) - -commit 617550199762fab42ca2e202e641e047b3efbac0 -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Fri Sep 21 05:20:16 2007 -0700 - - simplify perf-test code - - test/perf-test-pdf-engine.h | 67 +++-------------------- - test/perf-test-preview-dummy.cc | 3 +- - test/perf-test-preview-win.cc | 80 ++++++++++++++++++++++++---- - test/perf-test.cc | 114 - ++++------------------------------------ - 4 files changed, 86 insertions(+), 178 deletions(-) - -commit fb5bf808b88992c1772a10e4ed9fe788fb618417 -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Fri Sep 21 03:03:26 2007 -0700 - - more msvc build fixes - - makefile.vc | 2 +- - test/perf-test.cc | 4 ++++ - 2 files changed, 5 insertions(+), 1 deletion(-) - -commit 60829b08a7440f36014f68ec54bee7a742412738 -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Fri Sep 21 03:02:34 2007 -0700 - - msvc build fixes - - msvc/poppler/poppler-config.h | 143 - ++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 143 insertions(+) - -commit 853c22a174bae81139edc9aeded7f26ae2655cef -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Thu Sep 20 23:21:35 2007 -0700 - - add pre-made config.h for msvc build - - msvc/config.h | 62 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 62 insertions(+) - -commit 31c43b118bd4372134018be6f6693f77d1f6a39b -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Thu Sep 20 22:10:09 2007 -0700 - - remove unused variables - - poppler/CairoFontEngine.cc | 6 ++---- - poppler/CairoOutputDev.cc | 14 ++------------ - splash/SplashFTFontEngine.cc | 2 ++ - 3 files changed, 6 insertions(+), 16 deletions(-) - -commit 01b99f60e36dd955817f23911ef38947360f61f7 -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Thu Sep 20 21:14:17 2007 -0700 - - remove unused variables - - poppler/GfxState.cc | 11 ++--------- - poppler/SplashOutputDev.cc | 9 +++------ - poppler/TextOutputDev.cc | 3 --- - 3 files changed, 5 insertions(+), 18 deletions(-) - -commit 7c406400532d68524a43cf963d894d3c4b269400 -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Thu Sep 20 20:57:44 2007 -0700 - - remove unused variables - - poppler/Catalog.cc | 1 - - poppler/Form.cc | 5 ----- - poppler/GfxFont.cc | 6 ++---- - poppler/Page.cc | 2 +- - splash/Splash.cc | 5 ++++- - 5 files changed, 7 insertions(+), 12 deletions(-) - -commit 70f23389c97b1870b7311d97322cdd16b580a79d -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Thu Sep 20 20:23:59 2007 -0700 - - don't silence warnings about unused variables/functions to keep - programmers honest - - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit cdb6fcf98137473efd993e1374a6f010e9db67db -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Thu Sep 20 20:00:56 2007 -0700 - - Remove unused variables - - poppler/Annot.cc | 5 ++--- - 1 file changed, 2 insertions(+), 3 deletions(-) - -commit 0e76b49ac852a5a7ebae4c1f67b153e0b7c9f905 -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Tue Sep 18 01:04:50 2007 -0700 - - Explain how to compile on Windows using msvc makefile. - - README.windows | 63 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 63 insertions(+) - -commit c002b4dc75b2688ffe8a734cf3e15f5891797842 -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Tue Sep 18 00:04:47 2007 -0700 - - Add Windows/msvc makefile. - - Add native msvc windows makefile and pre-made - config.h for windows in msvc directory. - - makefile.vc | 149 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 149 insertions(+) - -commit 1f33fc58201c92120c587189d2e0e819f83167da -Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> -Date: Mon Sep 17 23:53:02 2007 -0700 - - Start on a test program. - - Test program can be used for regression testing and - performance testing. It renders a page (or pages) - in a given PDF (or PDFs) and records rendering times. - For historical reasons the code is ugly and probably - only compiles on windows, but it'll get better. - - test/perf-test-pdf-engine.h | 131 ++++ - test/perf-test-preview-dummy.cc | 22 + - test/perf-test-preview-win.cc | 222 ++++++ - test/perf-test.cc | 1428 - +++++++++++++++++++++++++++++++++++++++ - 4 files changed, 1803 insertions(+) - -commit b96db4ad27535c2666fccdfe0a3c04cc7c37792d -Author: Jeff Muizelaar <jeff@freiheit.infidigm.net> -Date: Mon Sep 17 20:28:38 2007 -0400 - - Avoid double free caused by 302 merge - - The ownership of the the string returned by getKey() changed with - the 302 merge - but this code was not updated. Found by Matthew Woehlke. - - qt4/src/poppler-document.cc | 4 +--- - 1 file changed, 1 insertion(+), 3 deletions(-) - -commit 2a495f19d4465e15fd2fa96656d904315c79a443 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Sep 17 16:52:45 2007 -0400 - - Simplify ChangeLog rule a bit. - - ChangeLog.mk | 81 - ------------------------------------------------------------ - Makefile.am | 7 +++--- - 2 files changed, 4 insertions(+), 84 deletions(-) - -commit 7d5abbeec55e4b90b139671d96cfdf58bdab70b8 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Sep 17 15:45:26 2007 -0400 - - Add dist hook to generate ChangeLog. - - Taken from cairo. It still need some tweaking. - - ChangeLog.mk | 81 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - Makefile.am | 4 +++ - configure.ac | 2 +- - 3 files changed, 86 insertions(+), 1 deletion(-) - -commit 15ad81c64cd8b1cb438d41be402daa19a239db3d -Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> -Date: Mon Sep 17 19:39:29 2007 +0200 - - Use = instead of == in qt.m4 - - m4/qt.m4 | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 70fabcb96e207b9b889bb32c0cf5ea3fc0aa08f8 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sun Sep 16 20:40:53 2007 -0400 - - Rename .cvsignore files to .gitignore and drop ChangeLog file. - - .cvsignore | 25 - - .gitignore | 25 + - ChangeLog | 4586 - --------------------------------------------- - fofi/.cvsignore | 8 - - fofi/.gitignore | 8 + - glib/.cvsignore | 11 - - glib/.gitignore | 11 + - glib/reference/.cvsignore | 18 - - glib/reference/.gitignore | 18 + - goo/.cvsignore | 8 - - goo/.gitignore | 8 + - poppler/.cvsignore | 10 - - poppler/.gitignore | 10 + - qt/.cvsignore | 7 - - qt/.gitignore | 7 + - qt4/.cvsignore | 3 - - qt4/.gitignore | 3 + - qt4/src/.cvsignore | 8 - - qt4/src/.gitignore | 8 + - qt4/tests/.cvsignore | 20 - - qt4/tests/.gitignore | 20 + - splash/.cvsignore | 8 - - splash/.gitignore | 8 + - test/.cvsignore | 11 - - test/.gitignore | 11 + - utils/.cvsignore | 12 - - utils/.gitignore | 12 + - 27 files changed, 149 insertions(+), 4735 deletions(-) - -commit c9f9403ffc5b95ae790c3c81284c7786afe33f4d -Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> -Date: Fri Sep 14 20:50:07 2007 +0000 - - Windows implementation for matching fonts that doesn't use fontconfig - - ChangeLog | 6 + - poppler/GlobalParamsWin.cc | 285 - +++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 291 insertions(+) - -commit d18b5361a0504458da805ed6be037c9d648f9372 -Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> -Date: Fri Sep 14 20:47:11 2007 +0000 - - Update ChangeLog for previous checkin - - ChangeLog | 15 +++++++++++++++ - 1 file changed, 15 insertions(+) - -commit 3330763ddca66b30d5ee60aab94d6fe0bbae9c8f -Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> -Date: Fri Sep 14 06:17:35 2007 +0000 - - windows/msvc compilation fixes - - poppler/DCTStream.h | 2 +- - poppler/Error.cc | 6 ++++++ - poppler/FlateStream.h | 2 +- - poppler/GlobalParams.cc | 12 ++++++++++-- - poppler/GlobalParams.h | 17 +++++++++++++++++ - poppler/Stream.cc | 2 +- - splash/SplashFTFontEngine.cc | 2 ++ - splash/SplashFontEngine.cc | 2 +- - splash/SplashFontFile.cc | 2 ++ - splash/SplashFontFile.h | 3 ++- - splash/SplashT1FontEngine.cc | 2 +- - 11 files changed, 44 insertions(+), 8 deletions(-) - -commit 6eb159ef34eb7e2fb8adcfc48afd84d5f50efbbd -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 10 17:38:05 2007 +0000 - - * autogen.sh: Support automake-1.10. - Patch by Krzysztof Kowalczyk <kkowalczyk@gmail.com> - - ChangeLog | 5 +++++ - autogen.sh | 11 ++++++----- - 2 files changed, 11 insertions(+), 5 deletions(-) - -commit 31bbc8c727cfecc79bd8da962ad8d99a0d1d3d33 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Sep 8 10:40:17 2007 +0000 - - * qt4/src/poppler-qt4.h: - * qt4/src/poppler-ps-converter.cc: - Add PSConverter::setOutputDevice() to set a QIODevice where - writing the resulting PS. - - ChangeLog | 7 ++++++ - qt4/src/poppler-ps-converter.cc | 51 - +++++++++++++++++++++++++++++++++++++---- - qt4/src/poppler-qt4.h | 5 +++- - 3 files changed, 58 insertions(+), 5 deletions(-) - -commit b3d63d03c310f01cc5b23d00ffd2103c6891fef2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 5 20:22:32 2007 +0000 - - * qt4/src/poppler-ps-converter.cc: Fix Right<->Left - interchange - - ChangeLog | 1 + - qt4/src/poppler-ps-converter.cc | 4 ++-- - 2 files changed, 3 insertions(+), 2 deletions(-) - -commit 64368582d5ca4e28c236f440482c96f1dd3a8897 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 5 18:22:52 2007 +0000 - - * poppler/PSOutputDev.cc: Fix printing of second parameter - - ChangeLog | 4 ++++ - poppler/PSOutputDev.cc | 2 +- - 2 files changed, 5 insertions(+), 1 deletion(-) - -commit eaf9d06cf0d08ccdc183759e0331dc2439a6f10f -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Sep 5 10:57:09 2007 +0000 - - 2007-09-05 Carlos Garcia Campos <carlosgc@gnome.org> - * glib/poppler-page.cc: - * glib/demo/render.c: Fix build with --disable-cairo-output. - - ChangeLog | 5 +++++ - glib/demo/render.c | 31 +++++++++++++++++++++++++++---- - glib/poppler-page.cc | 22 ++++++++++++---------- - 3 files changed, 44 insertions(+), 14 deletions(-) - -commit c0f488c2b0e115be3e1b7e4dc7baa38db5837498 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 4 22:04:52 2007 +0000 - - did not want to commit this - - gtk-doc.make | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 3462851b4ea342651095f1803cd488bc3b3f5749 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 4 22:02:06 2007 +0000 - - * utils/pdftoppm.cc: Fix build on Sun Studio compiler. - Patch by Brian Cameron <brian.cameron@sun.com> - - ChangeLog | 5 +++++ - gtk-doc.make | 2 +- - utils/pdftoppm.cc | 2 +- - 3 files changed, 7 insertions(+), 2 deletions(-) - -commit cdf3b9062cc54d558b8dbeefb3211a920ff2cb94 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 3 19:23:11 2007 +0000 - - write news - fix qt4 build - - NEWS | 13 +++++++++++++ - qt4/src/Makefile.am | 3 ++- - 2 files changed, 15 insertions(+), 1 deletion(-) - -commit c82208a44f3b09c27bc33831641e4f746dd4361f -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 3 18:28:44 2007 +0000 - - * configure.ac: Bump version to 0.6 - * glib/Makefile.am - * poppler/Makefile.am - * qt/Makefile.am - * qt4/src/Makefile.am: Bump sonames - - ChangeLog | 8 ++++++++ - configure.ac | 2 +- - glib/Makefile.am | 2 +- - poppler/Makefile.am | 2 +- - qt/Makefile.am | 2 +- - qt4/src/Makefile.am | 2 +- - 6 files changed, 13 insertions(+), 5 deletions(-) - -commit 2a12409ebbf96ea3ca4556b71231a45ae37cb052 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 3 17:09:01 2007 +0000 - - * poppler/JBIG2Stream.cc: - * poppler/Stream.cc: Patch by Derek B. Noonburg - <derekn@foolabs.com> - to fix some errors in CCITTFaxStream and JBIG2Stream.cc - - ChangeLog | 6 ++++++ - poppler/JBIG2Stream.cc | 7 ++++--- - poppler/Stream.cc | 2 +- - 3 files changed, 11 insertions(+), 4 deletions(-) - -commit 0b483e71ef02b4040b665935c1018c8b30b9c1ca -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Sep 3 08:54:01 2007 +0000 - - 2007-09-03 Carlos Garcia Campos <carlosgc@gnome.org> - * gtk-doc.make: - * glib/poppler-document.cc: - * glib/poppler-form-field.cc: - * glib/poppler-page.cc: - * glib/reference/poppler-docs.sgml: - * glib/reference/poppler-sections.txt: - * glib/reference/poppler.types: - * glib/reference/tmpl/poppler-action.sgml: - * glib/reference/tmpl/poppler-attachment.sgml: - * glib/reference/tmpl/poppler-document.sgml: - * glib/reference/tmpl/poppler-enums.sgml: - * glib/reference/tmpl/poppler-form-field.sgml: - * glib/reference/tmpl/poppler-page.sgml: - * glib/reference/tmpl/poppler-private.sgml: - * glib/reference/tmpl/poppler.sgml: Update glib bindings API - documentation. - - ChangeLog | 19 ++ - glib/poppler-document.cc | 10 + - glib/poppler-form-field.cc | 205 ++++++++++++++++++ - glib/poppler-page.cc | 12 +- - glib/reference/poppler-docs.sgml | 2 + - glib/reference/poppler-sections.txt | 108 +++++++++- - glib/reference/poppler.types | 2 + - glib/reference/tmpl/poppler-action.sgml | 36 +++- - glib/reference/tmpl/poppler-attachment.sgml | 65 ++++++ - glib/reference/tmpl/poppler-document.sgml | 50 +++++ - glib/reference/tmpl/poppler-enums.sgml | 60 ++++++ - glib/reference/tmpl/poppler-form-field.sgml | 315 - ++++++++++++++++++++++++++++ - glib/reference/tmpl/poppler-page.sgml | 236 ++++++++++++++++++++- - glib/reference/tmpl/poppler-private.sgml | 6 + - glib/reference/tmpl/poppler.sgml | 49 +++++ - gtk-doc.make | 34 +-- - 16 files changed, 1181 insertions(+), 28 deletions(-) - -commit 289e3893cda45055951bb8d3b82a45644bc0b6c6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Sep 2 17:02:55 2007 +0000 - - * poppler/GfxState.cc: Pad zeroes instead of aborting when - rendering - 1-bit images and the stream is "too short" to mimic - Acroread and - ghostscript behaviour. Patch by <darren.kenny@sun.com>. Fixes - #12208 - - ChangeLog | 3 +++ - poppler/GfxState.cc | 4 ++-- - 2 files changed, 5 insertions(+), 2 deletions(-) - -commit 6f6c2180aca2e26ea0e3c2f21f11bc8f457c19c0 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Sep 2 16:31:19 2007 +0000 - - * glib/demo/Makefile.am: Add - $(top_builddir)/poppler/libpoppler.la - * poppler/TextOutputDev.cc: Patch from Ed Catmur - <ed@catmur.co.uk> to - improve matching of half strings of decomposed - characters/ligatures. - - ChangeLog | 3 +++ - glib/demo/Makefile.am | 1 + - poppler/TextOutputDev.cc | 21 +++++++++++++-------- - 3 files changed, 17 insertions(+), 8 deletions(-) - -commit be1b5a0196cdfc78f74e08a023b477cac16eb0f3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Sep 2 16:06:03 2007 +0000 - - poppler/PDFDoc.cc: Don't enforce %%EOF at the end of file - - ChangeLog | 4 ++++ - poppler/PDFDoc.cc | 3 ++- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit 500a87af9240344806c18ebbd05a89f4f4c69955 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sun Sep 2 00:53:42 2007 +0000 - - 2007-09-01 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: - * poppler/Error.cc: - * poppler/Error.h: Report any cairo errors when destroying - the cairo - context. - - ChangeLog | 7 +++++++ - poppler/CairoOutputDev.cc | 7 ++++++- - poppler/Error.cc | 7 +++++++ - poppler/Error.h | 1 + - 4 files changed, 21 insertions(+), 1 deletion(-) - -commit 0c22556bf70ff67eb388cdcd9784603030397785 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sat Sep 1 23:38:04 2007 +0000 - - 2007-09-01 Jeff Muizelaar <jeff@infidigm.net> - - * glib/demo/Makefile.am: Only build the demo app if the cflags - will be - appropriately set. - - ChangeLog | 5 +++++ - glib/demo/Makefile.am | 2 ++ - 2 files changed, 7 insertions(+) - -commit a23d45dd6cd8a2ac4181170a9ee924fe49a9781b -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sat Sep 1 23:00:59 2007 +0000 - - 2007-09-01 Jeff Muizelaar <jeff@infidigm.net> - - * glib/poppler-page.cc: Add note about clipping - - ChangeLog | 4 ++++ - glib/poppler-page.cc | 2 ++ - 2 files changed, 6 insertions(+) - -commit bf489d5cebc467807f2b38f74f6a6e34a503a9ca -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Aug 30 18:39:51 2007 +0000 - - * poppler/Form.h: Remove unused methods. Fixes 12013 - - ChangeLog | 4 ++++ - poppler/Form.h | 3 --- - 2 files changed, 4 insertions(+), 3 deletions(-) - -commit a81cc06c855385911dffa826b9e1407d6097e8c8 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Aug 30 18:15:34 2007 +0000 - - 2007-08-30 Carlos Garcia Campos <carlosgc@gnome.org> - * poppler/TextOutputDev.cc: - * poppler/TextOutputDev.h: - * glib/poppler.h: - * glib/poppler-page.cc: - * glib/poppler-page.h: - * glib/test-poppler-glib.c: Add support for word and line - selections. Based on patch by Kristian Høgsberg. - - ChangeLog | 10 ++++++ - glib/poppler-page.cc | 81 - ++++++++++++++++++++++++++++++++++++++++++------ - glib/poppler-page.h | 2 ++ - glib/poppler.h | 4 +-- - glib/test-poppler-glib.c | 2 +- - poppler/TextOutputDev.cc | 74 +++++++++++++++++++++++++++++-------------- - poppler/TextOutputDev.h | 34 +++++++++++++++----- - 7 files changed, 163 insertions(+), 44 deletions(-) - -commit 59ddb5cc8bec54305b6d256ad9975e95ecdcb935 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Aug 27 18:37:55 2007 +0000 - - * poppler/UnicodeTypeTable.cc: Fix error on the NFKC text - matching - routine. Fixes bug #11775. Patch by Ed Catmur - <ed@catmur.co.uk> - - ChangeLog | 5 +++++ - poppler/UnicodeTypeTable.cc | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit a6e46ce61670679f368e66c1a98a7d5d1c960c5b -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Aug 27 17:56:29 2007 +0000 - - * qt4/src/Doxyfile: - * qt4/src/Mainpage.dox: - * qt4/src/poppler-annotation.h: - * qt4/src/poppler-form.h: - * qt4/src/poppler-link.h: - * qt4/src/poppler-qt4.h: - A few API documentation fixes and improvements. - - ChangeLog | 10 +++++++ - qt4/src/Doxyfile | 26 ++++++------------ - qt4/src/Mainpage.dox | 26 +++++++++++------- - qt4/src/poppler-annotation.h | 34 ++++++++++++++++++++++++ - qt4/src/poppler-form.h | 18 ++++++------- - qt4/src/poppler-link.h | 63 - +++++++++++++++++++++++++++++++++++++++++--- - qt4/src/poppler-qt4.h | 44 +++++++++++++++++++++---------- - 7 files changed, 166 insertions(+), 55 deletions(-) - -commit a7f8d92fba8c45d6ca83568c045d5e324158ee6b -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Aug 27 17:17:14 2007 +0000 - - * qt4/src/poppler-link.cc: - * qt4/src/poppler-link.h: - Initialise correctly, and missing empty destructor. - * qt4/src/poppler-annotation.cc: - Don't leak the private class. - - ChangeLog | 9 +++++++++ - qt4/src/poppler-annotation.cc | 4 ++-- - qt4/src/poppler-link.cc | 8 ++++++-- - qt4/src/poppler-link.h | 1 + - 4 files changed, 18 insertions(+), 4 deletions(-) - -commit 2b1ef8f06879eb0b79288d57540c238ea833db24 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Aug 26 21:39:22 2007 +0000 - - Fix bug 12121 - - ChangeLog | 4 ++++ - utils/ImageOutputDev.cc | 2 +- - 2 files changed, 5 insertions(+), 1 deletion(-) - -commit 20bcac5ee1988befb9c590a0d16cb615f0c49901 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Aug 26 21:28:34 2007 +0000 - - forgot to cvs add - - qt4/src/poppler-annotation-private.h | 49 - ++++++++++++++++++++++++++++++++++++ - 1 file changed, 49 insertions(+) - -commit e48de657db0ef439457b4b5ca39b937da25d531e -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Aug 26 18:11:01 2007 +0000 - - * qt4/src/poppler-annotation.cc: - * qt4/src/poppler-annotation.h: - Move all the private members of the *Annotation classes into - a common - shared private. - - ChangeLog | 4 + - qt4/src/poppler-annotation.cc | 969 - +++++++++++++++++++++++++++++++++++------- - qt4/src/poppler-annotation.h | 277 ++++++++---- - qt4/src/poppler-page.cc | 249 ++++++----- - 4 files changed, 1155 insertions(+), 344 deletions(-) - -commit 392f050f909b6a1250acf1971446a1849534482c -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Aug 26 16:42:46 2007 +0000 - - * qt4/src/poppler-document.cc: - * qt4/src/poppler-embeddedfile.cc: - * qt4/src/poppler-fontinfo.cc: - * qt4/src/poppler-form.cc: - * qt4/src/poppler-form.h: - * qt4/src/poppler-qt4.h: - * qt4/src/poppler-sound.cc: - * qt4/src/poppler-textbox.cc: - API work: remove 'const' and 'const&' from return values - with Qt - classes; make the non-copiable classes really non-copiable; - uninline a Document::page() method; other related small - changes. - * qt4/src/poppler-link.cc: - * qt4/src/poppler-link.h: - Make LinkDestination an implicitely shared class, with all - the private - members into the private class; move all the private members - of the - Link* classes into a common shared private. - - ChangeLog | 23 ++- - qt4/src/poppler-document.cc | 7 +- - qt4/src/poppler-embeddedfile.cc | 12 -- - qt4/src/poppler-fontinfo.cc | 12 +- - qt4/src/poppler-form.cc | 16 +- - qt4/src/poppler-form.h | 14 +- - qt4/src/poppler-link.cc | 373 - ++++++++++++++++++++++++++++++---------- - qt4/src/poppler-link.h | 67 +++++--- - qt4/src/poppler-qt4.h | 32 ++-- - qt4/src/poppler-sound.cc | 7 - - qt4/src/poppler-textbox.cc | 4 +- - 11 files changed, 404 insertions(+), 163 deletions(-) - -commit f215aca25fdd8fe287b717dde53f0be273d995e4 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun Aug 26 10:52:19 2007 +0000 - - 2007-08-26 Carlos Garcia Campos <carlosgc@gnome.org> - * configure.ac: - * glib/Makefile.am: - * glib/demo/Makefile.am: - * glib/demo/fonts.[ch]: - * glib/demo/info.[ch]: - * glib/demo/links.[ch]: - * glib/demo/main.c: - * glib/demo/outline.[ch]: - * glib/demo/page.[ch]: - * glib/demo/render.[ch]: - * glib/demo/utils.[ch]: Add poppler glib demo tool. - - ChangeLog | 14 ++ - configure.ac | 1 + - glib/Makefile.am | 2 +- - glib/demo/Makefile.am | 26 +++ - glib/demo/fonts.c | 276 ++++++++++++++++++++++++++++ - glib/demo/fonts.h | 31 ++++ - glib/demo/info.c | 243 ++++++++++++++++++++++++ - glib/demo/info.h | 31 ++++ - glib/demo/links.c | 289 +++++++++++++++++++++++++++++ - glib/demo/links.h | 31 ++++ - glib/demo/main.c | 205 +++++++++++++++++++++ - glib/demo/outline.c | 218 ++++++++++++++++++++++ - glib/demo/outline.h | 31 ++++ - glib/demo/page.c | 249 +++++++++++++++++++++++++ - glib/demo/page.h | 31 ++++ - glib/demo/render.c | 498 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - glib/demo/render.h | 31 ++++ - glib/demo/utils.c | 234 ++++++++++++++++++++++++ - glib/demo/utils.h | 42 +++++ - 19 files changed, 2482 insertions(+), 1 deletion(-) - -commit 7c9529b70dc44bb001d21a3b47fc65916813dec1 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Aug 23 20:39:31 2007 +0000 - - 2007-08-23 Carlos Garcia Campos <carlosgc@gnome.org> - * glib/poppler-page.cc: Add missing comma. - - ChangeLog | 4 ++++ - glib/poppler-page.cc | 2 +- - 2 files changed, 5 insertions(+), 1 deletion(-) - -commit 3c4a85503261ee81a829a1683f1f5fa85d41f8ee -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Thu Aug 23 20:15:46 2007 +0000 - - 2007-08-23 Jeff Muizelaar <jeff@infidigm.net> - - * glib/poppler-page.cc: pass in -1 to displaySlice so that it - sets up - the slice size for us. This fixes the case of the wrong values - being - used when the pdf was rotated on its side. - Fixes #11913. - - ChangeLog | 7 +++++++ - glib/poppler-page.cc | 5 ++--- - 2 files changed, 9 insertions(+), 3 deletions(-) - -commit 3ba088d8caee3c40c2aba0cd85adcf9195ae88a3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Aug 22 21:29:32 2007 +0000 - - * splash/SplashBitmap.cc: - * splash/SplashBitmap.h: - * utils/pdftoppm.cc: Add the following features to pdftoppm - - if omitting input filename or using - for input filename - reads pdf from stdin - - if omitting output filename, prints output to stdout - - create image of a cropped rectangle of the pdf - - scale pdf to fit in a square of wanted size - Patch by Ilmari Heikkinen <ilmari.heikkinen@gmail.com> - - ChangeLog | 12 ++++++ - splash/SplashBitmap.cc | 18 +++++++-- - splash/SplashBitmap.h | 2 + - utils/pdftoppm.cc | 107 - +++++++++++++++++++++++++++++++++++++++++-------- - 4 files changed, 119 insertions(+), 20 deletions(-) - -commit 567e82c13aace4f40c7a555a62a3a4d223a46d92 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed Aug 22 19:34:02 2007 +0000 - - 2007-08-22 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/GlobalParams.cc: Fix debug spew. Patch from Matthias - Clasen. - - ChangeLog | 4 ++++ - poppler/GlobalParams.cc | 1 - - 2 files changed, 4 insertions(+), 1 deletion(-) - -commit bc499987074d046baf29deafe4a29d57039c0c5e -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed Aug 22 19:28:24 2007 +0000 - - 2007-08-22 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: Fix the computation of the padding - in the - image scaling code. - - ChangeLog | 5 +++++ - poppler/CairoOutputDev.cc | 6 ++++-- - 2 files changed, 9 insertions(+), 2 deletions(-) - -commit d9719233447cb4f85f2bf9d9ec6ef089caa21140 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sun Aug 19 16:20:21 2007 +0000 - - 2007-08-19 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: Avoid allocating the glyph array if - currentFont is not set in beginString. This closes a possible - memory leak. - - ChangeLog | 6 ++++++ - poppler/CairoOutputDev.cc | 3 +++ - 2 files changed, 9 insertions(+) - -commit 099eb56896046e020f4ef0365e1ee382f85ec1ab -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Aug 15 18:52:20 2007 +0000 - - * poppler/JBIG2Stream.cc: Quick fix for bug #12014 - - ChangeLog | 4 ++++ - poppler/JBIG2Stream.cc | 16 +++++++++++----- - 2 files changed, 15 insertions(+), 5 deletions(-) - -commit 3b7e3645c85c7a3d341457f105835b58c935bd67 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Aug 15 00:04:48 2007 +0000 - - RC2 is out! (0.5.91) - - ChangeLog | 1 + - NEWS | 18 ++++++++++++++++++ - configure.ac | 2 +- - 3 files changed, 20 insertions(+), 1 deletion(-) - -commit c240daefe660ac3456dc0c5f5dc82aa53ebc3313 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Aug 14 23:10:37 2007 +0000 - - * poppler/Stream.cc: Fix CVE-2007-3387 by merging xpdf-3.02pl1.patch - - ChangeLog | 1 + - poppler/Stream.cc | 12 +++++------- - 2 files changed, 6 insertions(+), 7 deletions(-) - -commit 1ba884b6b98ac8d755c9adc9f23a7a68d8b17b54 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Aug 14 22:47:30 2007 +0000 - - * configure.ac: - * pòppler/Makefile.am: Patch by Vincent Torri - <vtorri@univ-evry.fr> to - fix linking under MinGW - - ChangeLog | 6 ++++++ - configure.ac | 13 +++++++++++++ - poppler/Makefile.am | 5 +++-- - 3 files changed, 22 insertions(+), 2 deletions(-) - -commit 3c31f923fcf1aeb361910eb1e9445cc28aa5b3ca -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Tue Aug 7 16:22:12 2007 +0000 - - 2007-08-07 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: Don't use the prescaleMethod - when we have a rotation as that case has not been tested. - Also make sure that scaledHeight is at least 1. - - ChangeLog | 6 ++++++ - poppler/CairoOutputDev.cc | 7 ++++++- - 2 files changed, 12 insertions(+), 1 deletion(-) - -commit af97e5f8e0f3beeb43acde92a0788c02d9718adf -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Aug 6 17:41:17 2007 +0000 - - 2007-08-06 Carlos Garcia Campos <carlosgc@gnome.org> - * poppler/Annot.cc: - * poppler/Annot.h: - * poppler/Form.cc: - * poppler/Form.h: - * poppler/Page.cc: Do not always regenerate appearance stream for - every form widget, but only when it's actually needed. - - ChangeLog | 9 ++++++ - poppler/Annot.cc | 86 - ++++++++++++++++++++++++++++++++++---------------------- - poppler/Annot.h | 8 +++--- - poppler/Form.cc | 25 +++------------- - poppler/Form.h | 4 ++- - poppler/Page.cc | 8 ++---- - 6 files changed, 74 insertions(+), 66 deletions(-) - -commit 74627e71388ca0a4c0938a472c291ef87186f370 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Tue Jul 31 21:40:19 2007 +0000 - - 2007-07-31 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/GlobalParams.cc: s/GList/GooList/ some Windows code. - - ChangeLog | 4 ++++ - poppler/GlobalParams.cc | 8 ++++---- - 2 files changed, 8 insertions(+), 4 deletions(-) - -commit f421e2151345ac855b75e819e19343a90789b3bf -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Tue Jul 31 16:50:06 2007 +0000 - - 2007-07-31 Jeff Muizelaar <jeff@infidigm.net> - - * glib/poppler-document.cc: - * glib/poppler-document.h: Add poppler_fonts_iter_get_file_name. - - ChangeLog | 5 +++++ - glib/poppler-document.cc | 16 ++++++++++++++++ - glib/poppler-document.h | 1 + - 3 files changed, 22 insertions(+) - -commit 4d57b8a12b845d5d5ac321d7a4bca980d60d429f -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Tue Jul 31 16:48:35 2007 +0000 - - 2007-07-31 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.h: Add comment about - CairoImageOutputDevice's - implementation. - - ChangeLog | 5 +++++ - poppler/CairoOutputDev.h | 1 + - 2 files changed, 6 insertions(+) - -commit f04a67006abdb5843ab481aa1e25b51abd1b1b64 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jul 31 11:41:53 2007 +0000 - - 2007-07-31 Carlos Garcia Campos <carlosgc@gnome.org> - * poppler/Form.cc: - * poppler/Form.h: Fix memory leak. - - ChangeLog | 5 +++++ - poppler/Form.cc | 9 +++++---- - poppler/Form.h | 4 ++-- - 3 files changed, 12 insertions(+), 6 deletions(-) - -commit ee9d556a8b413160911a535a0e9089b919ca29f5 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jul 31 11:40:22 2007 +0000 - - 2007-07-31 Carlos Garcia Campos <carlosgc@gnome.org> - * poppler/CairoOutputDev.h: Empty implementation of transparency - groups and soft masks in CairoImageOutputDev. Fixes a crash in - poppler_page_get_image_mapping. - - ChangeLog | 6 ++++++ - poppler/CairoOutputDev.h | 11 +++++++++++ - 2 files changed, 17 insertions(+) - -commit e08779856c801b9968dc2d47e28e86abc1ec7110 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Tue Jul 31 05:29:57 2007 +0000 - - 2007-07-31 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/GfxFont.cc: Fix the case where the Encoding is - "Identity" - and ToUnicode exists. GfxCIDFont::getCodeToGIDMap makes - CIDTOGID map - from ToUnicde map, but when encoding is Identity, it should - not use - ToUnicode map to get GID. If encoding is Identity, No CIDTOGID - map is - needed. - Patch by Koji Otani. - Fixes #11413. - - ChangeLog | 10 ++++++++++ - poppler/GfxFont.cc | 1 + - 2 files changed, 11 insertions(+) - -commit 86fc9a6f343be920f5159e745947401227e41a37 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Mon Jul 30 19:28:17 2007 +0000 - - 2007-07-30 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: - * poppler/CairoOutputDev.h: Prescale image masks before giving - them - to cairo to improve the quality of the scaled image. Improves - #5589. - - ChangeLog | 6 + - poppler/CairoOutputDev.cc | 300 - ++++++++++++++++++++++++++++++++++++++++++++-- - poppler/CairoOutputDev.h | 10 +- - 3 files changed, 303 insertions(+), 13 deletions(-) - -commit f754246e47161e9bf99887201e283c1419ade4f1 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Mon Jul 30 19:07:45 2007 +0000 - - 2007-07-30 Jeff Muizelaar <jeff@infidigm.net> - - * configure.ac: Update require cairo version to 1.4 - - ChangeLog | 4 ++++ - configure.ac | 2 +- - 2 files changed, 5 insertions(+), 1 deletion(-) - -commit bb20249ac676995725b617ef442f5feb01f78205 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Mon Jul 30 18:44:41 2007 +0000 - - 2007-07-30 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: - * poppler/CairoOutputDev.h: Add transparency group support. - Fixes #7856. - - ChangeLog | 6 +++ - poppler/CairoOutputDev.cc | 133 - ++++++++++++++++++++++++++++++++++++++++++++++ - poppler/CairoOutputDev.h | 21 +++++++- - 3 files changed, 159 insertions(+), 1 deletion(-) - -commit a85acecaeb0d122becbc52a385d918561e995eca -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Mon Jul 30 00:22:35 2007 +0000 - - 2007-07-29 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: - * poppler/CairoOutputDev.h: transform the original matrix for - type3 fonts - instead of using set_matrix() - - ChangeLog | 6 ++++++ - poppler/CairoOutputDev.cc | 20 +++++++++++++++++--- - poppler/CairoOutputDev.h | 1 + - 3 files changed, 24 insertions(+), 3 deletions(-) - -commit a81a082169de32d01c36c969616a5c2279f1bac7 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Mon Jul 30 00:18:59 2007 +0000 - - 2007-07-29 Jeff Muizelaar <jeff@infidigm.net> - - * glib/test-poppler-glib.c: include <time.h> to fix compilation. - - ChangeLog | 4 ++++ - glib/test-poppler-glib.c | 1 + - 2 files changed, 5 insertions(+) - -commit 81393cb30f6287caf5195265cdc039555f2767d3 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Jul 28 08:22:40 2007 +0000 - - 2007-07-28 Carlos Garcia Campos <carlosgc@gnome.org> - * poppler/Annot.cc: - * poppler/Annot.h: - * poppler/Form.cc: - * poppler/Form.h: Make fieldLookup static in Form and use it from - both Form and Annot. - - ChangeLog | 8 +++++++ - poppler/Annot.cc | 43 +++++++++++------------------------- - poppler/Annot.h | 1 - - poppler/Form.cc | 66 - +++++++++++++++++++++++++++----------------------------- - poppler/Form.h | 2 ++ - 5 files changed, 54 insertions(+), 66 deletions(-) - -commit 81b669dcb14bf821a49c9879f8d4129075647f5f -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Jul 28 08:05:11 2007 +0000 - - 2007-07-28 Carlos Garcia Campos <carlosgc@gnome.org> - * glib/poppler-page.h: Remove unneeded declarations. Fixes bug - #11744. Patch by Kouhei Sutou <kou@cozmixng.org>. - - ChangeLog | 5 +++++ - glib/poppler-page.h | 2 -- - 2 files changed, 5 insertions(+), 2 deletions(-) - -commit f2c4e5305009f1da770c99d3e2e3371ff37c75f3 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri Jul 27 09:17:40 2007 +0000 - - 2007-07-27 Carlos Garcia Campos <carlosgc@gnome.org> - * glib/poppler-document.cc: - * glib/poppler-document.h: - * glib/poppler-private.h: - * glib/test-poppler-glib.c: Make PopplerFontInfo GObject. Patch by - Kouhei Sutou <kou@cozmixng.org>. - - ChangeLog | 8 ++++++++ - glib/poppler-document.cc | 44 - ++++++++++++++++++++++++++++++++++++++++---- - glib/poppler-document.h | 6 +++++- - glib/poppler-private.h | 1 + - glib/test-poppler-glib.c | 2 +- - 5 files changed, 55 insertions(+), 6 deletions(-) - -commit 975c7cff10d9b00359e147329ae2c7a93f8a3833 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jul 25 17:20:06 2007 +0000 - - micro optimization - - qt4/src/poppler-page.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 525a7f49dd95f2644870a1c59ca15124e30026b4 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jul 24 16:45:25 2007 +0000 - - 2007-07-24 Carlos Garcia Campos <carlosgc@gnome.org> - * poppler/Annot.cc: - * poppler/Form.cc: Several fixes in forms. Generate appearance for - field buttons that don't have an AP dict. Do not remove the first - character of the second and following lines in multiline text - fields. Fix a crash with pdf documents created by ooo which have - radio buttons. Look for some inheritable attributes in the - parent when needed. - - ChangeLog | 10 ++++++++ - poppler/Annot.cc | 27 ++++++++++---------- - poppler/Form.cc | 77 - +++++++++++++++++++++++++++++++++++++++----------------- - 3 files changed, 78 insertions(+), 36 deletions(-) - -commit 633a1cde65f86ee6577a68f4f8d36de43d14c714 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jul 15 21:03:50 2007 +0000 - - * utils/HtmlOutputDev.cc: - * utils/HtmlOutputDev.h: Create the html files in the - correct place, - not in the invocation dir. Fixes bug #11610 - - ChangeLog | 6 ++++++ - utils/HtmlOutputDev.cc | 37 ++++++++++--------------------------- - utils/HtmlOutputDev.h | 4 ---- - 3 files changed, 16 insertions(+), 31 deletions(-) - -commit ccb2d420ca8d818aa9ba1d64f08f5e94ab313a72 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jul 15 17:09:29 2007 +0000 - - * poppler/DCTStream.cc - * poppler/DCTStream.h: Implement less evil error handling. On - a - error_exit level error we don't want to actually exit the - program. See - http://bugs.kde.org/show_bug.cgi?id=147878 for a pdf with this - problem. libjpeg was printing "Bogus Huffman table definition" - and - exiting the program. - * poppler/Stream.cc: Remove bogus #warning - - ChangeLog | 10 ++++++++++ - poppler/DCTStream.cc | 17 ++++++++++++++++- - poppler/DCTStream.h | 1 + - poppler/Stream.cc | 1 - - 4 files changed, 27 insertions(+), 2 deletions(-) - -commit f9d82dfd299ae23a1baf3e35e2c3cd351129c525 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Jul 14 18:23:42 2007 +0000 - - * utils/pdftops.cc: init width/height to -1 so it is - calculated if not - specified - - ChangeLog | 5 +++++ - utils/pdftops.cc | 4 ++-- - 2 files changed, 7 insertions(+), 2 deletions(-) - -commit 1c04136e9538ccfaa2d6b968861682ca3b69ffb3 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Jul 14 15:23:31 2007 +0000 - - 2007-07-14 Pino Toscano <pino@kde.org> - * glib/poppler-action.h: - * glib/poppler-document.h: Remove trailing comma from the last - item of enums. - - ChangeLog | 6 ++++++ - glib/poppler-action.h | 2 +- - glib/poppler-document.h | 8 ++++---- - 3 files changed, 11 insertions(+), 5 deletions(-) - -commit b9b68cabce19a5e23911e5432ace8c13bd237391 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Jul 14 15:15:57 2007 +0000 - - 2007-07-14 Carlos Garcia Campos <carlosgc@gnome.org> - * glib/poppler-form-field.cc: - * glib/poppler-form-field.h: - * glib/test-poppler-glib.c: Make is_password a property instead of - a text form field type, since a text field could be multiline and - password at the same time. - - ChangeLog | 8 ++++++++ - glib/poppler-form-field.cc | 10 ++++++++-- - glib/poppler-form-field.h | 2 +- - glib/test-poppler-glib.c | 4 ++-- - 4 files changed, 19 insertions(+), 5 deletions(-) - -commit 14a8361039d708661b8699b2e7c4496135021a85 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 13 22:18:05 2007 +0000 - - * fofi/FoFiTrueType.cc - * fofi/FoFiTrueType.h - * poppler/CairoFontEngine.cc - * poppler/CharCodeToUnicode.cc - * poppler/CharCodeToUnicode.h - * poppler/GfxFont.cc - * poppler/GfxFont.h - * poppler/SplashOutputDev.cc: Patch by - Koji Otani <sho@bbr.jp> to fix several problems with - Japanese fonts. - Fixes bug 11413 - - ChangeLog | 13 ++ - fofi/FoFiTrueType.cc | 305 - +++++++++++++++++++++++++++++++++++++++++++ - fofi/FoFiTrueType.h | 12 ++ - poppler/CairoFontEngine.cc | 47 ++----- - poppler/CharCodeToUnicode.cc | 16 +++ - poppler/CharCodeToUnicode.h | 1 + - poppler/GfxFont.cc | 230 ++++++++++++++++++++++++++++---- - poppler/GfxFont.h | 2 + - poppler/SplashOutputDev.cc | 53 ++------ - 9 files changed, 577 insertions(+), 102 deletions(-) - -commit 8389099d8e8940e3f8920b14a83075d69bcd8e6c -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 13 18:21:02 2007 +0000 - - * poppler/FontInfo.cc: Fix the FontInfoScanner::scan method to - actually scan the number of requested pages - - ChangeLog | 6 ++++++ - poppler/FontInfo.cc | 12 ++++++------ - 2 files changed, 12 insertions(+), 6 deletions(-) - -commit 9ced4442372d08375e0ded62f79052d8a3ec9cd6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 13 18:08:44 2007 +0000 - - * poppler/GlobalParams.cc: Remove dead unused code from - Win32 ifdef - - ChangeLog | 4 ++++ - poppler/GlobalParams.cc | 6 ------ - 2 files changed, 4 insertions(+), 6 deletions(-) - -commit fb89fdb8de608ff94082e16819f042cddabf2bcc -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jul 11 18:52:12 2007 +0000 - - * poppler/PSOutputDev.cc - * poppler/PSOutputDev.h - * utils/pdftohtml.cc: Fix bug 9746. pdftohtml complex mode - had text - twice - - ChangeLog | 7 +++++++ - poppler/PSOutputDev.cc | 5 +++++ - poppler/PSOutputDev.h | 2 ++ - utils/pdftohtml.cc | 3 +-- - 4 files changed, 15 insertions(+), 2 deletions(-) - -commit 0c9fa59bf5edf3cfcca1792da51b904a7c7f7615 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jul 11 18:30:19 2007 +0000 - - 2007-07-11 Carlos Garcia Campos <carlosgc@gnome.org> - * poppler/Form.cc: - * poppler/XRef.cc: - * poppler/XRef.h: Fix memory leak. - - ChangeLog | 6 ++++++ - poppler/Form.cc | 49 ++++++++++++++++++++++++------------------------- - poppler/XRef.cc | 22 ++++++++++------------ - poppler/XRef.h | 2 +- - 4 files changed, 41 insertions(+), 38 deletions(-) - -commit 4ae7d43bd54c5b3e2f08c48441f741d3099e228f -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jul 11 18:12:26 2007 +0000 - - * goo/GooVector.h: Rename guard from _VECTOR_H to GOO_VECTOR_H - * goo/gfile.cc: GString -> GooString in Windows code - * poppler/GlobalParams.cc: GString -> GooString in Windows - code - * splash/SplashT1FontEngine.cc - * splash/SplashT1FontEngine.h - * splash/SplashT1FontFile.cc - * splash/SplashT1FontFile.h: T1 code is not supported, - but at least - make it compile :-D - - ChangeLog | 11 +++++++++++ - goo/GooVector.h | 4 ++-- - goo/gfile.cc | 6 +++--- - poppler/GlobalParams.cc | 26 +++++++++++++------------- - splash/SplashFontEngine.cc | 2 +- - splash/SplashT1FontEngine.cc | 8 ++++---- - splash/SplashT1FontEngine.h | 7 +++---- - splash/SplashT1FontFile.cc | 8 +++++--- - splash/SplashT1FontFile.h | 4 ++-- - 9 files changed, 44 insertions(+), 32 deletions(-) - -commit 7bd125ce96c603fd5cf42d7c6a29b542e82dd4ec -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jul 11 18:08:07 2007 +0000 - - 2007-07-11 Carlos Garcia Campos <carlosgc@gnome.org> - * poppler/Form.cc: - * poppler/Form.h: - * glib/poppler-form-field.cc: - * glib/poppler-form-field.h: - * glib/test-poppler-glib.c: Add a method to get the max length - allowed in text form fields. - - ChangeLog | 9 +++++++++ - glib/poppler-form-field.cc | 8 ++++++++ - glib/poppler-form-field.h | 1 + - glib/test-poppler-glib.c | 1 + - poppler/Form.cc | 11 +++++++++++ - poppler/Form.h | 4 ++++ - 6 files changed, 34 insertions(+) - -commit 8a68855735e9d295d71685e82de39204d639ea7a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Jul 9 08:52:58 2007 +0000 - - 2007-07-09 Carlos Garcia Campos <carlosgc@gnome.org> - * poppler/Annot.cc: - * poppler/Annot.h: Render '*' instead of the actual content in - password form fields. Patch by Julien Rebetez <julien@fhtagn.net> - - ChangeLog | 6 ++++++ - poppler/Annot.cc | 52 - +++++++++++++++++++++++++++++----------------------- - poppler/Annot.h | 5 +++-- - 3 files changed, 38 insertions(+), 25 deletions(-) - -commit 53cf7d7084dc03a28239f11c94f2095bb02d6108 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Jul 7 16:23:56 2007 +0000 - - 2007-07-07 Carlos Garcia Campos <carlosgc@gnome.org> - * poppler/Form.cc: - * poppler/Form.h: - * glib/poppler-form-field.cc: - * glib/poppler-form-field.h: - * glib/test-poppler-glib.c: Add a method to get the type of a Form - Field Button. - - ChangeLog | 9 +++++++++ - glib/poppler-form-field.cc | 18 ++++++++++++++++++ - glib/poppler-form-field.h | 8 ++++++++ - glib/test-poppler-glib.c | 26 +++++++++++++++++++++++--- - poppler/Form.cc | 5 +++++ - poppler/Form.h | 2 ++ - 6 files changed, 65 insertions(+), 3 deletions(-) - -commit de0a40181e5832a0dc263d40ed0a269867764623 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Jul 7 15:28:29 2007 +0000 - - 2007-07-07 Carlos Garcia Campos <carlosgc@gnome.org> - * poppler/Form.cc: Fix a crash when setting state on buttons that - don't have state. - - ChangeLog | 5 +++++ - poppler/Form.cc | 3 +++ - 2 files changed, 8 insertions(+) - -commit a33518a3283ff25aa5517bc535ddb61383b1cfdc -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 6 09:08:44 2007 +0000 - - * poppler/Form.cc: Fix a bug with FormField's destructor - which was not - checking if the FormField is terminal to determine wether - it needs to - delete children or widgets. Patch by - Julien Rebetez <julien@fhtagn.net> - - ChangeLog | 4 ++++ - poppler/Form.cc | 17 +++++++++++------ - 2 files changed, 15 insertions(+), 6 deletions(-) - -commit 43f0d5b9bb198cdcbc2f7111f294c6f947105314 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 6 08:47:11 2007 +0000 - - * goo/GooString.cc: - * poppler/ABWOutputDev.cc: Build on Sun Force compiler, - patch by - Darren Kenny <darren.kenny@sun.com> - - ChangeLog | 6 ++++++ - goo/GooString.cc | 2 +- - poppler/ABWOutputDev.cc | 4 +++- - 3 files changed, 10 insertions(+), 2 deletions(-) - -commit 4e7405071b69889362e4d49de3f881f0e3e261e3 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 5 13:04:01 2007 +0000 - - 2007-07-05 Carlos Garcia Campos <carlosgc@gnome.org> - * glib/poppler-form-field.cc: Allow to set NULL in form fields - that can contain text. - - ChangeLog | 5 +++++ - glib/poppler-form-field.cc | 30 ++++++++++++------------------ - 2 files changed, 17 insertions(+), 18 deletions(-) - -commit 625510797c528257527003477fe28adbacfe80e7 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Thu Jul 5 08:13:51 2007 +0000 - - 2007-07-05 Carlos Garcia Campos <carlosgc@gnome.org> - * glib/poppler-attachment.cc: - * glib/poppler-attachment.h: - * glib/test-poppler-glib.c: Rename cdate and mdate again to ctime - and mtime, since they are public attributes and we don't want to - break the API. - - ChangeLog | 8 ++++++++ - glib/poppler-attachment.cc | 4 ++-- - glib/poppler-attachment.h | 4 ++-- - glib/test-poppler-glib.c | 4 ++-- - 4 files changed, 14 insertions(+), 6 deletions(-) - -commit 9b2640f156f24b07c797d9461f84e64d550efa1a -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jul 4 13:57:31 2007 +0000 - - * qt4/src/poppler-form.cc: QStringToGooString -> - QStringToUnicodeGooString has FormWidgetText::setContent - wants to have - the unicode formated string - * qt4/src/poppler-private.h: create QStringToUnicodeGooString - - ChangeLog | 7 +++++++ - qt4/src/poppler-form.cc | 2 +- - qt4/src/poppler-private.h | 15 +++++++++++++++ - 3 files changed, 23 insertions(+), 1 deletion(-) - -commit b70115cf979b29f75c644518ae0e9c0dd9892ebf -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jul 4 13:06:38 2007 +0000 - - 2007-07-04 Carlos Garcia Campos <carlosgc@gnome.org> - * glib/poppler-form-field.cc: Convert strings from UTF8 to UTF16BE - before setting them. - - ChangeLog | 5 +++++ - glib/poppler-form-field.cc | 34 ++++++++++++++++++++++++---------- - 2 files changed, 29 insertions(+), 10 deletions(-) - -commit d37843877a6f93a9f27502d07ad82cba79e9aa73 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Wed Jul 4 08:26:52 2007 +0000 - - 2007-07-04 Carlos Garcia Campos <carlosgc@gnome.org> - * glib/poppler-attachment.cc: - * glib/poppler-attachment.h: Add size, creation and modification - date and checksum properties to attachments. Fix memory leaks. - * glib/test-poppler-glib.c: - * glib/poppler.h: - * glib/poppler-private.h: - * glib/poppler-document.cc: Add a function to convert a pdf date - into a GTime that is used by attachments and document - properties. Fix memory leak in attachments. - - ChangeLog | 12 ++++ - glib/poppler-attachment.cc | 25 +++++++- - glib/poppler-attachment.h | 16 ++--- - glib/poppler-document.cc | 142 - +++++++++++++++++++++++---------------------- - glib/poppler-private.h | 6 +- - glib/poppler.h | 1 + - glib/test-poppler-glib.c | 56 +++++++++++++++--- - 7 files changed, 171 insertions(+), 87 deletions(-) - -commit d933f47d4af0992059148259a189373b42499bbe -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jul 3 20:31:20 2007 +0000 - - * qt4/tests/poppler-fonts.cpp: For the sake of completeness, - add all - the enums - - ChangeLog | 2 ++ - qt4/tests/poppler-fonts.cpp | 28 ++++++++++++++++++++-------- - 2 files changed, 22 insertions(+), 8 deletions(-) - -commit d90b166cfbdc4857351baa627d158d5e0b6652b4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jul 3 16:46:51 2007 +0000 - - * poppler/Catalog.cc: Fix crash, - embeddedFileNameTree.getName(i) - returns a reference to its own data so does not have to - be deleted - * qt4/tests/poppler-attachments.cpp: Delete the doc, just - for sake of - correctness - - ChangeLog | 7 +++++++ - poppler/Catalog.cc | 1 - - qt4/tests/poppler-attachments.cpp | 1 + - 3 files changed, 8 insertions(+), 1 deletion(-) - -commit 7fa87eb2b093770271bc3a72de5b0b9dc228aa1b -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jul 3 14:01:40 2007 +0000 - - 2007-07-03 Carlos Garcia Campos <carlosgc@gnome.org> - * glib/poppler-form-field.cc: - * glib/poppler-form-field.h: - * glib/test-poppler-glib.c: Add choice_commit_on_change function - to glib bindings. - - ChangeLog | 7 +++++++ - glib/poppler-form-field.cc | 8 ++++++++ - glib/poppler-form-field.h | 1 + - glib/test-poppler-glib.c | 2 ++ - 4 files changed, 18 insertions(+) - -commit 8b67e0403f6eaab6770cc0b7861074ae0b6d85bb -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Tue Jul 3 13:49:18 2007 +0000 - - 2007-07-03 Carlos Garcia Campos <carlosgc@gnome.org> - * glib/poppler-form-field.cc: - * glib/poppler-form-field.h: - * glib/test-poppler-glib.c: Fix a typo. - - ChangeLog | 6 ++++++ - glib/poppler-form-field.cc | 2 +- - glib/poppler-form-field.h | 2 +- - glib/test-poppler-glib.c | 2 +- - 4 files changed, 9 insertions(+), 3 deletions(-) - -commit 33a5765eb404a4b321b09c26af74c1ed64a5d474 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jul 3 13:22:54 2007 +0000 - - * poppler/Catalog.cc: - * poppler/Catalog.h: Add size and checksum properties to - the embeded - files - * qt4/src/poppler-embeddedfile.cc: - * qt4/src/poppler-qt4.h: Add size and checksum properties - to the qt4 - frontend - - ChangeLog | 9 +++++++++ - poppler/Catalog.cc | 19 ++++++++++++++++--- - poppler/Catalog.h | 13 +++++++++++-- - qt4/src/poppler-embeddedfile.cc | 16 ++++++++++++++++ - qt4/src/poppler-qt4.h | 14 ++++++++++++++ - 5 files changed, 66 insertions(+), 5 deletions(-) - -commit c7d21f9354bbe090cce6459124dcaadf1e46639e -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Jul 2 13:39:32 2007 +0000 - - 2007-07-02 Carlos Garcia Campos <carlosgc@gnome.org> - * glib/poppler-form-field.cc: - * glib/poppler-form-field.h: - * glib/test-poppler-glib.c: - Use FILE_SELECT instead of FILESELECT and fix a typo. Patch by - Kouhei Sutou - - ChangeLog | 9 +++++++++ - glib/poppler-form-field.cc | 2 +- - glib/poppler-form-field.h | 2 +- - glib/test-poppler-glib.c | 2 +- - 4 files changed, 12 insertions(+), 3 deletions(-) - -commit 5e301064c62c6d58f488839d7bf804af912a3de1 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Mon Jul 2 13:34:26 2007 +0000 - - 2007-07-02 Carlos Garcia Campos <carlosgc@gnome.org> - * glib/poppler-form-field.cc: - * glib/poppler-form-field.h: - * glib/test-poppler-glib.c: - Add poppler_form_field_is_read_only to glib bindings. Patch by - Kouhei Sutou - - ChangeLog | 9 +++++++++ - glib/poppler-form-field.cc | 8 ++++++++ - glib/poppler-form-field.h | 1 + - glib/test-poppler-glib.c | 6 +++++- - 4 files changed, 23 insertions(+), 1 deletion(-) - -commit 11875746ce28e8999bcad46167fcfea131cd267a -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Jun 30 08:33:30 2007 +0000 - - 2007-06-30 Carlos Garcia Campos <carlosgc@gnome.org> - * glib/poppler-page.cc: Use poppler_page_transition_get_type - instead of poppler_page_transition which doesn't exist. Patch by - Kouhei Sutou - - ChangeLog | 6 ++++++ - glib/poppler-page.cc | 2 +- - 2 files changed, 7 insertions(+), 1 deletion(-) - -commit 0a5acaae3b9bfcd731bc4e072f35f9433aa773da -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Jun 30 08:25:15 2007 +0000 - - 2007-06-30 Carlos Garcia Campos <carlosgc@gnome.org> - * glib/Makefile.am: - * glib/poppler-form-field.cc: - * glib/poppler-form-field.h: - * glib/poppler-document.cc: - * glib/poppler-document.h: - * glib/poppler-page.cc: - * glib/poppler-page.h: - * glib/poppler-private.h: - * glib/poppler.h: - * glib/test-poppler-glib.c: Improve forms API in the glib bindings - in order to make it more consistent with the current API and - easier to use. - - ChangeLog | 15 +++ - glib/Makefile.am | 2 + - glib/poppler-document.cc | 197 ++-------------------------- - glib/poppler-document.h | 55 +------- - glib/poppler-form-field.cc | 316 - +++++++++++++++++++++++++++++++++++++++++++++ - glib/poppler-form-field.h | 96 ++++++++++++++ - glib/poppler-page.cc | 210 ++++++++++++------------------ - glib/poppler-page.h | 55 ++------ - glib/poppler-private.h | 11 +- - glib/poppler.h | 40 +++--- - glib/test-poppler-glib.c | 119 ++++++++++++++--- - 11 files changed, 662 insertions(+), 454 deletions(-) - -commit 2212874e57a6eb9db733b2e9a98f0cfcb88a8fc1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 26 21:31:07 2007 +0000 - - * poppler/Form.cc: Don't crash on documents with AcroForm - but no - AcroForm->Fields (it's mandatory but...) - - ChangeLog | 5 +++++ - poppler/Form.cc | 54 - +++++++++++++++++++++++++++++------------------------- - 2 files changed, 34 insertions(+), 25 deletions(-) - -commit e48ee9c4af6bf98b6988c51dcab9ee9ef6e3cafe -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sat Jun 23 18:06:07 2007 +0000 - - 2007-06-23 Carlos Garcia Campos <carlosgc@gnome.org> - * poppler/Annot.cc: - * poppler/Form.cc: Fix memory leaks. - - ChangeLog | 5 +++++ - poppler/Annot.cc | 2 +- - poppler/Form.cc | 13 +++++++++---- - 3 files changed, 15 insertions(+), 5 deletions(-) - -commit d874a2753e3ac51b6f539dfdf980435c8c381b4f -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jun 20 20:07:15 2007 +0000 - - * qt4/src/poppler-qt4.h: - * qt4/src/poppler-document.cc: Allow access to a document's - metadata contents - from the qt4 binding. Based on patch by Jason Kivlighn - * qt4/tests/test-poppler-qt4.cpp: Print metadata if it exists - - ChangeLog | 5 +++++ - qt4/src/poppler-document.cc | 13 +++++++++++++ - qt4/src/poppler-qt4.h | 5 +++++ - qt4/tests/test-poppler-qt4.cpp | 1 + - 4 files changed, 24 insertions(+) - -commit 08d4c437e735ac50a340c4ae17ee0eeccd00dc20 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jun 20 18:40:03 2007 +0000 - - * glib/poppler-document.cc: Allow access to a document's - metadata stream - through the glib binding. Patch by Jason Kivlighn - <jkivlighn@gmail.com> Approved by Carlos - - ChangeLog | 6 ++++++ - glib/poppler-document.cc | 21 +++++++++++++++++++++ - 2 files changed, 27 insertions(+) - -commit cdd2a49dc99aa16ded674c58dbb50298f06cf18a -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jun 15 18:15:53 2007 +0000 - - * poppler/ABWOutputDev.cc: Replaces the getBiggestSeperator - function - at the ABWoutputdev with one that is easier to read/debug - and less likely to contain bugs. Some cosmetic fixes at the - functions recursiveXYC and splitnodes. Patch by - Jauco Noordzij <jauco.noordzij@gmail.com>. More info at - bug #11273 - - ChangeLog | 8 + - poppler/ABWOutputDev.cc | 384 - ++++++++++++------------------------------------ - 2 files changed, 106 insertions(+), 286 deletions(-) - -commit 7f23383197b0e2fa24be7b4925ea6f39eb95bbc1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jun 13 20:39:21 2007 +0000 - - * poppler/ABWOutputDev.cc - * poppler/ABWOutputDev.h: Remove dependency on debugxml. Patch - by - Jauco Noordzij <jauco.noordzij@gmail.com>. Fixes bug #11187 - - ChangeLog | 6 ++++ - poppler/ABWOutputDev.cc | 80 - ++++++++++++++++++++++++++++++++++++++++++++++++- - poppler/ABWOutputDev.h | 1 + - 3 files changed, 86 insertions(+), 1 deletion(-) - -commit 948520cd529ce47d1970aae6a0b8058128e37c30 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jun 13 18:50:40 2007 +0000 - - * goo/FixedPoint.h - * goo/gmem.h - * poppler/SecurityHandler.h - * poppler/poppler-config.h.in - * utils/ImageOutputDev.h: - Patch by Axel Howind <Axel.Howind@htp-tel.de> - - include USE_EXCEPTIONS and USE_FIXEDPOINT in - poppler-config.h.in - - fix typo (MULTITHREADED/MULTITHREADING) in - poppler.config.h.in - - change installed headers to include poppler-config.h - instead of - config.h - - use <poppler/poppler-config.h> instead of <poppler-config.h> - so that - installed headers can be used without including - .../include/poppler - in the include path - - ChangeLog | 16 ++++++++++++++++ - goo/FixedPoint.h | 2 +- - goo/gmem.h | 2 +- - poppler/SecurityHandler.h | 2 +- - poppler/poppler-config.h.in | 12 +++++++++++- - utils/ImageOutputDev.h | 2 +- - 6 files changed, 31 insertions(+), 5 deletions(-) - -commit 825461e47b05595805e87a0d2960b07197c8da8b -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jun 13 18:24:56 2007 +0000 - - configure.ac: Fix detection of glib - - ChangeLog | 4 ++++ - configure.ac | 2 +- - 2 files changed, 5 insertions(+), 1 deletion(-) - -commit a67a93fc6b4812a4f892b311c5b299e59283cd47 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Jun 11 21:14:22 2007 +0000 - - * poppler/CMap.h: - * poppler/CharCodeToUnicode.h: - * poppler/GlobalParams.h: - * poppler/PageLabelInfo.h: - * poppler/UnicodeMap.h: Further include cleanup. Patch by - Axel Howind - on bug #11228 - - ChangeLog | 9 +++++++++ - poppler/CMap.h | 2 +- - poppler/CharCodeToUnicode.h | 2 +- - poppler/GlobalParams.h | 2 +- - poppler/PageLabelInfo.h | 6 +++--- - poppler/UnicodeMap.h | 2 +- - 6 files changed, 16 insertions(+), 7 deletions(-) - -commit 051b31af053cac4727718169b79b25451a4bdd95 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Jun 11 21:11:05 2007 +0000 - - * qt/poppler-qt.h - * qt4/src/poppler-qt4.h: Headers cleanup - - ChangeLog | 5 +++++ - qt/poppler-qt.h | 6 +++--- - qt4/src/poppler-qt4.h | 8 ++++---- - 3 files changed, 12 insertions(+), 7 deletions(-) - -commit 3e1597b80fc6750f1ec3269f9819aa8225879524 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jun 8 22:39:23 2007 +0000 - - poppler/Annot.cc: Fix leak - - ChangeLog | 4 ++++ - poppler/Annot.cc | 1 + - 2 files changed, 5 insertions(+) - -commit 49535c20b4f71d1c1381134233e2e1449cf560c0 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Thu Jun 7 21:23:03 2007 +0000 - - 2007-06-07 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/ABWOutputDev.cc: Change "and", "or", "not" to "&&", - "||", - "!" for consistency with the rest of the code. Patch by Jens - Granseuer - - ChangeLog | 5 +++ - poppler/ABWOutputDev.cc | 93 - +++++++++++++++++++++++++------------------------ - 2 files changed, 52 insertions(+), 46 deletions(-) - -commit dd8fa975bf51dd18120369d0ef2d8f1781e04d93 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Jun 2 09:18:11 2007 +0000 - - correct form of patch 11102 - - utils/HtmlFonts.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -commit cdf70857ece0748f13b11c923ccf9626094555b4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jun 1 18:34:48 2007 +0000 - - * poppler/ArthurOutputDev.cc - * splash/SplashFTFont.cc - * splash/SplashMath.h: Make it compile with - --enable-fixedpoint. Fixes - bug 11110 - - ChangeLog | 7 +++++++ - poppler/ArthurOutputDev.cc | 8 ++++---- - splash/SplashFTFont.cc | 8 ++++---- - splash/SplashMath.h | 2 +- - 4 files changed, 16 insertions(+), 9 deletions(-) - -commit 90b1a404629a884cc32737a3a729c9a75f7a59c1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed May 30 18:33:24 2007 +0000 - - * configure.ac: Fix to check for glib-2.0 not glib that is - 1.0. Patch - came though Pardus developers and they don't remember where - they got - it from. - - ChangeLog | 6 ++++++ - configure.ac | 2 +- - 2 files changed, 7 insertions(+), 1 deletion(-) - -commit 03d766ea1ddd4ce6d938f96b53906a7dc8bd179a -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed May 30 18:29:57 2007 +0000 - - make dist needs this - - qt4/src/Makefile.am | 2 ++ - 1 file changed, 2 insertions(+) - -commit d540c04268047fdd125ad932ca05c7553a97c0fe -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed May 30 17:50:00 2007 +0000 - - * utils/HtmlFonts.cc: Make pdftohtml not pollute stdout. Patch - by - Nanning Buitenhuis <nanning@elvenkind.com> - - And some changes in glib/reference/tmpl - - ChangeLog | 5 + - glib/reference/tmpl/poppler-document.sgml | 4 + - glib/reference/tmpl/poppler-enums.sgml | 150 - ++++++++++++++++++++++++++++++ - glib/reference/tmpl/poppler-page.sgml | 5 +- - glib/reference/tmpl/poppler-unused.sgml | 130 - -------------------------- - utils/HtmlFonts.cc | 2 +- - 6 files changed, 162 insertions(+), 134 deletions(-) - -commit ce414f2a36f4d97a3bddfd42baabdc1e34bf9321 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue May 29 22:01:58 2007 +0000 - - 2007-05-29 Kristian Høgsberg <krh@redhat.com> - - * poppler/gen-unicode-tables.py: Add this script to fix distcheck. - - ChangeLog | 4 ++++ - poppler/gen-unicode-tables.py | 38 ++++++++++++++++++++++++++++++++++++++ - 2 files changed, 42 insertions(+) - -commit 97e602752b05f3690acb1821bdca31c5771361e1 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun May 27 11:24:40 2007 +0000 - - 2007-05-27 Carlos Garcia Campos <carlosgc@gnome.org> - * glib/test-poppler-glib.c: Add forms test - * glib/poppler-page.cc: - * glib/poppler-page.h: - Fix indentation, some code cleanups and memory leaks. - - ChangeLog | 7 ++ - glib/poppler-page.cc | 198 - ++++++++++++++++++++++++++++------------------- - glib/poppler-page.h | 6 +- - glib/test-poppler-glib.c | 39 ++++++++++ - 4 files changed, 168 insertions(+), 82 deletions(-) - -commit 3d31c2b1ea913fc80211f1c6fed9b3666f124049 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Sun May 27 10:12:56 2007 +0000 - - 2007-05-27 Carlos Garcia Campos <carlosgc@gnome.org> - * glib/poppler-page.cc: - * glib/poppler-page.h: - Add missing image mapping type definition. - - ChangeLog | 6 ++++++ - glib/poppler-page.cc | 48 - +++++++++++++++++++++++++++++++++++++++++++++--- - glib/poppler-page.h | 5 +++++ - 3 files changed, 56 insertions(+), 3 deletions(-) - -commit 8284a769568322066a9d4626bd9b2cf3d18a6487 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat May 26 23:20:12 2007 +0000 - - * configure.ac: - * NEWS: Bump release to 0.5.9 (0.6 Release Candidate) - - ChangeLog | 2 ++ - NEWS | 15 +++++++++++++++ - configure.ac | 2 +- - 3 files changed, 18 insertions(+), 1 deletion(-) - -commit e6ff9e0d95e058f6aff3c72d5f4d7d7ccf661999 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat May 26 22:33:21 2007 +0000 - - * poppler-qt.pc.in: - * poppler-qt4.pc.in: - * qt/Makefile.am: - * qt4/src/Makefile.am: Install qt3 and qt4 headers in - separate dirs. - That way be can reuse poppler-page-transition.h and distros - don't get - conflicts when making separate qt3 and qt4 packages - - ChangeLog | 9 +++++++++ - poppler-qt.pc.in | 2 +- - poppler-qt4.pc.in | 2 +- - qt/Makefile.am | 2 +- - qt4/src/Makefile.am | 2 +- - 5 files changed, 13 insertions(+), 4 deletions(-) - -commit fefefe495a182c1745314186b99441b9e76ba5b4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri May 25 23:17:58 2007 +0000 - - * qt4/src/poppler-link-extractor-private.cc: - * qt4/src/poppler-link-extractor-private.h: - * qt4/src/poppler-link.cc: - * qt4/src/poppler-link.h: Return link coordinates in 0..1 - range - instead of 0..size, much more easier to do user<->dev - transformations - * qt4/src/poppler-private.h: Fix indentation - - ChangeLog | 6 ++++++ - qt4/src/poppler-link-extractor-private.h | 1 + - qt4/src/poppler-link-extractor.cc | 12 ++++++------ - qt4/src/poppler-link.cc | 25 +++++++++++++++---------- - qt4/src/poppler-link.h | 7 ++++++- - qt4/src/poppler-private.h | 15 ++++++++------- - 6 files changed, 42 insertions(+), 24 deletions(-) - -commit ecaeaa9512d1dae4a036703ea8739102a8e463f0 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri May 25 22:30:20 2007 +0000 - - * qt4/src/poppler-link-extractor.cc: Use correct page box - to extract - link clickable area - - ChangeLog | 5 +++++ - qt4/src/poppler-link-extractor.cc | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit 774a9456c668ef70b2e8f17d59f8f427aa97bad5 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Fri May 25 18:43:04 2007 +0000 - - 2007-05-25 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/GfxFont.cc: - * poppler/GfxFont.h: - * poppler/GlobalParams.cc: - Don't cache DisplayFontParams by font name, instead cache them - in GfxFont. Fixes #8140. - - ChangeLog | 8 ++++++++ - poppler/GfxFont.cc | 2 ++ - poppler/GfxFont.h | 6 ++++++ - poppler/GlobalParams.cc | 4 ++-- - 4 files changed, 18 insertions(+), 2 deletions(-) - -commit a88fadf0bb9af55c83c9c4f7d08deb17d6aa9ae4 -Author: Carlos Garcia Campos <carlosgc@gnome.org> -Date: Fri May 25 17:33:37 2007 +0000 - - 2007-05-25 Carlos Garcia Campos <carlosgc@gnome.org> - * glib/poppler-page.cc: - * glib/poppler-page.h: - * glib/poppler.h: - Add selection style parameter to render_selection in order - to allow - requesting selections of words and paragraphs. - - ChangeLog | 8 ++++++++ - glib/poppler-page.cc | 30 ++++++++++++++++-------------- - glib/poppler-page.h | 6 ++++-- - glib/poppler.h | 7 +++++++ - 4 files changed, 35 insertions(+), 16 deletions(-) - -commit bf195b489c22875695e202d6ca6659144ef57e61 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed May 23 21:20:58 2007 +0000 - - * qt4/src/poppler-document.cc: - * qt4/src/poppler-private.h: - Better handle the setting of the vector antialiasing for - Splash. - * qt4/src/Mainpage.dox: - * qt4/src/poppler-link.h: - * qt4/src/poppler-qt4.h: - A few of API documentation fixes and improvements. - - ChangeLog | 10 ++++++++ - qt4/src/Mainpage.dox | 8 ++----- - qt4/src/poppler-document.cc | 5 ++-- - qt4/src/poppler-link.h | 4 +++- - qt4/src/poppler-private.h | 1 + - qt4/src/poppler-qt4.h | 57 - ++++++++++++++++++++++++++++++--------------- - 6 files changed, 57 insertions(+), 28 deletions(-) - -commit 36d1fe292778ba29990a389c50a0df0d51f11913 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon May 21 21:42:38 2007 +0000 - - Fix assert in bug 11023 - - ChangeLog | 4 ++++ - glib/poppler-action.cc | 2 +- - 2 files changed, 5 insertions(+), 1 deletion(-) - -commit 5b411246a2cce6ed3bb2d8c9e9d856227b6aba7f -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon May 21 21:39:08 2007 +0000 - - * glib/poppler-page.cc: - * glib/poppler-page.h: - poppler_page_render_section() for cairo. Bug 7023 - - ChangeLog | 6 ++++ - glib/poppler-page.cc | 88 - ++++++++++++++++++++++++++++++++++++++++++++++------ - glib/poppler-page.h | 9 ++++++ - 3 files changed, 93 insertions(+), 10 deletions(-) - -commit 409f2a9cb31add29accb87011331c50dc08110cd -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon May 21 21:35:10 2007 +0000 - - * glib/poppler-page.cc: - * glib/poppler-page.h: - * glib/poppler-private.h: - * glib/poppler.h: - * glib/test-poppler-glib.c: - * poppler/CairoOutputDev.cc: - * poppler/CairoOutputDev.h: Extend CairoOutputdev to do - image caching when rendering - - ChangeLog | 11 +++ - glib/poppler-page.cc | 161 ++++++++++++++++++++++++++++++++-- - glib/poppler-page.h | 10 +++ - glib/poppler-private.h | 3 + - glib/poppler.h | 9 +- - glib/test-poppler-glib.c | 27 +++++- - poppler/CairoOutputDev.cc | 215 - ++++++++++++++++++++++++++++++++++++++++++++++ - poppler/CairoOutputDev.h | 122 ++++++++++++++++++++++++++ - 8 files changed, 545 insertions(+), 13 deletions(-) - -commit afd11ec66430dae084b5a5560333e933460fc637 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon May 21 21:29:09 2007 +0000 - - * poppler/Annot.cc: avoid crashing if the font for the - drawing methods - can not be found - * poppler/Form.cc: fix memory leak - * qt4/src/poppler-private.h: fix the UnicodeParsedString - function to - really work and not crash - * splash/SplashTypes.h: RGB8X mode makes max number of - components in - any SplashColor always be 4 - - ChangeLog | 11 +++++++++++ - poppler/Annot.cc | 6 ++++++ - poppler/Form.cc | 1 + - qt4/src/poppler-private.h | 5 ++++- - splash/SplashTypes.h | 6 +----- - 5 files changed, 23 insertions(+), 6 deletions(-) - -commit f019c8a8efde004e1663ea88cb48c0e46318d936 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu May 17 21:32:57 2007 +0000 - - 2007-05-17 Pino Toscano <pino@kde.org> - - * qt4/src/poppler-link.cc: - Give some default values to LinkDestination - * qt4/src/poppler-private.h: - Fix memory leak when converting QString -> GooString - - ChangeLog | 7 +++++++ - qt4/src/poppler-link.cc | 12 ++++++++++++ - qt4/src/poppler-private.h | 4 +++- - 3 files changed, 22 insertions(+), 1 deletion(-) - -commit d68a4eb44b5390b3093774f39a6805ad2e95c146 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sun May 13 00:53:43 2007 +0000 - - 2007-05-12 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/Annot.cc: Only do appearance generation for text, - choice or - other fields that contain text. Patch by Julien Rebetez. - - ChangeLog | 5 +++++ - poppler/Annot.cc | 52 - ++++++++++++++++++++++++++++++++++++++++++++++------ - 2 files changed, 51 insertions(+), 6 deletions(-) - -commit 96f8731e90af1abce67d00a3febc11880c69ce62 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon May 7 18:41:09 2007 +0000 - - * Catalog.cc: Fix leak - * Form.cc: Fix leak, provide empty - FormPageWidgets::~FormPageWidgets - implementation - * Page.cc: Fix leak - - ChangeLog | 7 +++++++ - poppler/Catalog.cc | 1 + - poppler/Form.cc | 5 +++++ - poppler/Page.cc | 1 + - 4 files changed, 14 insertions(+) - -commit d46553d696b2d7fe416ce8db40db54dd1d7c6733 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Apr 30 22:34:21 2007 +0000 - - * poppler/Makefile.am: Don't link cairo to all poppler, - just to - poppler_cairo so when compiling the qt frontend and the - glib frontend - the qt one does not end up depending on cairo - - ChangeLog | 6 ++++++ - poppler/Makefile.am | 1 - - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit d5c52409c532a126bcb8eb65f6f1390113a5f258 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Apr 29 17:37:38 2007 +0000 - - jeff committed this line by mistake - - ChangeLog | 1 - - 1 file changed, 1 deletion(-) - -commit 6ddc11ef4c534369ee104422bfb989603c466790 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sun Apr 29 17:33:58 2007 +0000 - - 2007-04-29 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/UnicodeTypeTable.cc: Make some of the unicode tables - const - which gets rid of about 20k of data. - - text data bss dec hex filename - before: 1415838 128864 8 1544710 179206 libpoppler.so - after: 1404574 140128 8 1544710 179206 libpoppler.so - - ChangeLog | 10 ++++++++++ - poppler/UnicodeTypeTable.cc | 24 ++++++++++++------------ - 2 files changed, 22 insertions(+), 12 deletions(-) - -commit c5613ab5ce65fc84eb3a5584cee1454171173fa7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 28 23:25:59 2007 +0000 - - * poppler/SplashOutputDev.cc: - * qt/poppler-private.h: - * qt4/src/poppler-private.h: - * splash/Splash.cc: - * splash/SplashBitmap.cc: - * splash/SplashTypes.h: Rename splashModeRGBX8 to - splashModeXBGR8 and - hopefully fix qt frontends image generation - - ChangeLog | 10 +++++ - poppler/SplashOutputDev.cc | 102 - +++++++++++++++++++++++++++++++++------------ - qt/poppler-private.h | 2 +- - qt4/src/poppler-private.h | 2 +- - splash/Splash.cc | 44 +++++++++---------- - splash/SplashBitmap.cc | 16 +++---- - splash/SplashTypes.h | 4 +- - 7 files changed, 120 insertions(+), 60 deletions(-) - -commit 6479ce224f1393235ca9888dfe0710327fbfccd2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 28 22:12:22 2007 +0000 - - fix merging problems - - splash/Splash.cc | 1 + - splash/SplashBitmap.cc | 1 - - 2 files changed, 1 insertion(+), 1 deletion(-) - -commit e2ac4ada3e29139053871ff7f53772e1ccc7adc0 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 28 15:39:36 2007 +0000 - - \n at the end of the printf - Although i'm not sure we want to printf this... - - poppler/GlobalParams.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 9b8133940638c95940edcb9b98126ca9a4f7b8d4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 28 12:00:38 2007 +0000 - - * qt4/src/Makefile.am: - * qt4/src/poppler-document.cc: - * qt4/src/poppler-ps-converter.cc: - * qt4/src/poppler-qt4.h: Replace Document::print function - with lots of - arguments with a helper class with lots of functions. Will - help - mantaining BC in case we decide to add more functionality - to the - printing process. - - ChangeLog | 10 +++ - qt4/src/Makefile.am | 1 + - qt4/src/poppler-document.cc | 39 ++------- - qt4/src/poppler-ps-converter.cc | 190 - ++++++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-qt4.h | 119 +++++++++++++++++++++---- - 5 files changed, 307 insertions(+), 52 deletions(-) - -commit 26d5fefcd4c858e2ebd689d963a65773957ac808 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 28 11:35:34 2007 +0000 - - * qt4/src/poppler-page.cc: - Hopefully fix the calculation of the image size when rendering - using - ArthurOutputDev. - - ChangeLog | 6 ++++++ - qt4/src/poppler-page.cc | 2 +- - 2 files changed, 7 insertions(+), 1 deletion(-) - -commit 218364bc4951682de8e63e1bd3f061636b08b615 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 28 11:34:14 2007 +0000 - - * glib/poppler-document.h: - * poppler/FontInfo.h: - * qt/poppler-qt.h: - * qt4/src/poppler-qt4.h: GfxFontType changed, adapt enums - of the - frontends and helper classes. Forgot to do it before merging. - - ChangeLog | 8 ++++++++ - glib/poppler-document.h | 6 +++++- - poppler/FontInfo.h | 6 +++++- - qt/poppler-qt.h | 6 +++++- - qt4/src/poppler-qt4.h | 20 ++++++++++++-------- - 5 files changed, 35 insertions(+), 11 deletions(-) - -commit c1a40d3b4e9b27e34c94c9477a0313534563a394 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 28 11:20:58 2007 +0000 - - * qt4/src/poppler-annotation.h: - Make the header clean. - - ChangeLog | 5 +++++ - qt4/src/poppler-annotation.h | 3 +++ - 2 files changed, 8 insertions(+) - -commit 3f4bf880b95e28a1ae7a38b18b341e089860780c -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 28 11:16:49 2007 +0000 - - * qt4/src/Makefile.am: - * qt4/src/poppler-link-extractor-private.h: - * qt4/src/poppler-link-extractor.cc: - * qt4/src/poppler-page-private.h: - * qt4/src/poppler-page.cc: - * qt4/src/poppler-private.h: - * qt4/src/poppler-qt4.h: - Getting the links of a page now is not more dependant on - the current - output device, and can be done anytime; thus, the doLinks - parameter - of the Page::render() can be dropped. - - ChangeLog | 13 ++++++ - qt4/src/Makefile.am | 3 +- - qt4/src/poppler-link-extractor-private.h | 55 ++++++++++++++++++++++++ - qt4/src/poppler-link-extractor.cc | 74 - ++++++++++++++++++++++++++++++++ - qt4/src/poppler-page-private.h | 38 ++++++++++++++++ - qt4/src/poppler-page.cc | 52 ++++------------------ - qt4/src/poppler-private.h | 5 ++- - qt4/src/poppler-qt4.h | 4 +- - 8 files changed, 195 insertions(+), 49 deletions(-) - -commit 7f9eec9ef4e7dc895d2a3e38014b6368cc7564b6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Apr 27 22:41:10 2007 +0000 - - 2007-04-28 Albert Astals Cid <aacid@kde.org> - - * qt4/*: Stop requyring users to declare UNSTABLE_POPPLER_QT4 - - ChangeLog | 4 ++++ - qt4/src/Doxyfile | 2 +- - qt4/src/Mainpage.dox | 3 +-- - qt4/src/poppler-document.cc | 2 -- - qt4/src/poppler-embeddedfile.cc | 2 -- - qt4/src/poppler-fontinfo.cc | 2 -- - qt4/src/poppler-form.cc | 1 - - qt4/src/poppler-link.cc | 2 -- - qt4/src/poppler-page.cc | 1 - - qt4/src/poppler-qt4.h | 3 --- - qt4/src/poppler-sound.cc | 2 -- - qt4/src/poppler-textbox.cc | 2 -- - qt4/tests/check_attachments.cpp | 1 - - qt4/tests/check_dateConversion.cpp | 1 - - qt4/tests/check_fonts.cpp | 1 - - qt4/tests/check_metadata.cpp | 1 - - qt4/tests/check_pagelayout.cpp | 1 - - qt4/tests/check_pagemode.cpp | 1 - - qt4/tests/check_permissions.cpp | 1 - - qt4/tests/poppler-attachments.cpp | 1 - - qt4/tests/poppler-fonts.cpp | 1 - - qt4/tests/stress-poppler-qt4.cpp | 1 - - qt4/tests/test-password-qt4.cpp | 1 - - qt4/tests/test-poppler-qt4.cpp | 1 - - 24 files changed, 6 insertions(+), 32 deletions(-) - -commit 45993a6faafd7646075bc6630d5d2ad7a44f7e20 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Apr 27 22:26:09 2007 +0000 - - 2007-04-28 Carlos Garcia Campos <carlosgc@gnome.org> - reviewed and some code by: Albert Astals Cid <aacid@kde.org> - - * glib/poppler-page.cc: - * glib/poppler-page.h: - * glib/poppler.h: - * glib/test-poppler-glib.c: - * poppler/Makefile.am: - * poppler/PageTransition.cc: - * poppler/PageTransition.h: - * qt/poppler-page-transition.cc: - * qt/poppler-page-transition.h: Move Page Transition parsing - from qt - frontends to poppler core. Expose Page transitions on the glib - frontend. - - ChangeLog | 15 ++++ - glib/poppler-page.cc | 122 ++++++++++++++++++++++++++ - glib/poppler-page.h | 111 ++++++++++++++---------- - glib/poppler.h | 58 +++++++++---- - glib/test-poppler-glib.c | 60 +++++++++++++ - poppler/Makefile.am | 2 + - poppler/PageTransition.cc | 197 - +++++++++++++++--------------------------- - poppler/PageTransition.h | 86 ++++++++++++++++++ - qt/poppler-page-transition.cc | 145 ++++++------------------------- - qt/poppler-page-transition.h | 9 +- - 10 files changed, 497 insertions(+), 308 deletions(-) - -commit 877d6b202a75eb12119b16e740f85cc8b477d589 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Apr 27 21:25:30 2007 +0000 - - * glib/poppler-page.cc: - * poppler/PSOutputDev.cc: - * poppler/PSOutputDev.h: - * qt/poppler-document.cc: - * qt4/src/poppler-document.cc: - * qt4/src/poppler-qt4.h: - * utils/pdftohtml.cc: - * utils/pdftops.cc: - Add option to force rasterizing the pages when printing them - Add functionality to output the title field on the PS file - Only Qt4 frontend exposes the functionality - - Bringing this features from KPDF 3.5.7 to poppler - Testers welcome - Patches for other frontends more than welcome - Comments and suggestions even more than welcome :-) - - ChangeLog | 14 +++++++++++++ - glib/poppler-page.cc | 3 ++- - poppler/PSOutputDev.cc | 48 - +++++++++++++++++++++++++++++++-------------- - poppler/PSOutputDev.h | 17 ++++++++++------ - qt/poppler-document.cc | 2 +- - qt4/src/poppler-document.cc | 9 +++++++-- - qt4/src/poppler-qt4.h | 2 +- - utils/pdftohtml.cc | 2 +- - utils/pdftops.cc | 2 +- - 9 files changed, 71 insertions(+), 28 deletions(-) - -commit 99053be5357235c47a87775985646ef8d9880ed9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Apr 26 17:57:01 2007 +0000 - - * goo/Makefile.am: Remove duplicate gmem.h - - ChangeLog | 4 ++++ - goo/Makefile.am | 1 - - 2 files changed, 4 insertions(+), 1 deletion(-) - -commit f6adb46cd88d23b34f1918d3be31c05b68b6a443 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Apr 25 21:31:17 2007 +0000 - - ignore pdftoabw binary - - utils/.cvsignore | 1 + - 1 file changed, 1 insertion(+) - -commit e09f231ac6c03ac2c3606f1bf20ba1bde3d85abd -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Apr 25 21:25:06 2007 +0000 - - 2007-04-25 Albert Astals Cid <aacid@kde.org> - - * qt4/src/poppler-document.cc: remove a delete[] no longer - needed - * qt4/src/poppler-private: initilize m_hints - - ChangeLog | 5 +++++ - qt4/src/poppler-document.cc | 1 - - qt4/src/poppler-private.h | 1 + - 3 files changed, 6 insertions(+), 1 deletion(-) - -commit bf7e0e980bf29994021cb1228f89f582adddf284 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Apr 25 19:59:09 2007 +0000 - - Merge xpdf302branch in HEAD as noone vetoed it. - Testing more than welcome - - ChangeLog | 140 + - configure.ac | 4 + - fofi/FoFiTrueType.cc | 458 +++- - fofi/FoFiTrueType.h | 42 +- - fofi/FoFiType1.cc | 65 +- - fofi/FoFiType1C.cc | 590 +++-- - fofi/FoFiType1C.h | 7 +- - glib/poppler-action.cc | 12 +- - glib/poppler-document.cc | 5 +- - glib/poppler-page.cc | 8 +- - goo/FixedPoint.cc | 31 +- - goo/FixedPoint.h | 5 + - goo/GooString.cc | 444 +++- - goo/GooString.h | 41 +- - goo/Makefile.am | 2 +- - goo/gfile.cc | 54 +- - goo/gmem.c | 238 -- - goo/gmem.cc | 264 ++ - goo/gmem.h | 27 +- - poppler/ABWOutputDev.cc | 1 - - poppler/ABWOutputDev.h | 1 - - poppler/Annot.cc | 1685 +++++++++--- - poppler/Annot.h | 83 +- - poppler/ArthurOutputDev.cc | 13 +- - poppler/Catalog.cc | 79 +- - poppler/Catalog.h | 16 +- - poppler/CharCodeToUnicode.cc | 31 +- - poppler/DCTStream.cc | 2 +- - poppler/DCTStream.h | 4 +- - poppler/Decrypt.cc | 427 ++- - poppler/Decrypt.h | 54 +- - poppler/Dict.cc | 23 +- - poppler/Dict.h | 27 +- - poppler/FontInfo.cc | 1 - - poppler/Form.cc | 19 +- - poppler/Form.h | 2 +- - poppler/Function.cc | 65 +- - poppler/Function.h | 8 +- - poppler/Gfx.cc | 1247 ++++++--- - poppler/Gfx.h | 39 +- - poppler/GfxFont.cc | 45 +- - poppler/GfxFont.h | 7 +- - poppler/GfxState.cc | 209 +- - poppler/GfxState.h | 42 +- - poppler/GlobalParams.cc | 399 ++- - poppler/GlobalParams.h | 41 +- - poppler/JBIG2Stream.cc | 96 +- - poppler/JBIG2Stream.h | 4 +- - poppler/JPXStream.cc | 246 +- - poppler/JPXStream.h | 8 +- - poppler/Lexer.cc | 18 +- - poppler/Link.cc | 150 +- - poppler/Link.h | 49 +- - poppler/Makefile.am | 4 +- - poppler/Object.cc | 5 +- - poppler/Object.h | 29 +- - poppler/Outline.cc | 1 - - poppler/OutputDev.cc | 2 + - poppler/OutputDev.h | 62 +- - poppler/PDFDoc.cc | 100 +- - poppler/PDFDoc.h | 21 +- - poppler/PSOutputDev.cc | 2715 ++++++++++++++----- - poppler/PSOutputDev.h | 58 +- - poppler/PSTokenizer.cc | 2 +- - poppler/Page.cc | 227 +- - poppler/Page.h | 22 +- - poppler/PageLabelInfo.cc | 1 - - poppler/Parser.cc | 66 +- - poppler/Parser.h | 11 +- - poppler/PreScanOutputDev.cc | 255 ++ - poppler/PreScanOutputDev.h | 128 + - poppler/SecurityHandler.cc | 17 +- - poppler/SecurityHandler.h | 5 + - poppler/SplashOutputDev.cc | 1480 ++++++----- - poppler/SplashOutputDev.h | 41 +- - poppler/Stream.cc | 338 +-- - poppler/Stream.h | 39 +- - poppler/TextOutputDev.cc | 537 +++- - poppler/TextOutputDev.h | 77 +- - poppler/UGooString.cc | 182 -- - poppler/UGooString.h | 79 - - poppler/XRef.cc | 29 +- - poppler/XRef.h | 6 +- - qt/poppler-document.cc | 15 +- - qt/poppler-page-transition.cc | 1 - - qt/poppler-page.cc | 4 +- - qt/poppler-private.h | 72 +- - qt4/src/poppler-annotation-helper.h | 38 +- - qt4/src/poppler-document.cc | 7 +- - qt4/src/poppler-embeddedfile.cc | 6 +- - qt4/src/poppler-form.cc | 12 +- - qt4/src/poppler-page.cc | 8 +- - qt4/src/poppler-private.h | 76 +- - splash/Splash.cc | 4994 - ++++++++++++++++++----------------- - splash/Splash.h | 137 +- - splash/SplashBitmap.cc | 110 +- - splash/SplashBitmap.h | 10 +- - splash/SplashClip.cc | 276 +- - splash/SplashClip.h | 28 +- - splash/SplashFTFont.cc | 104 +- - splash/SplashFTFont.h | 5 +- - splash/SplashFTFontEngine.cc | 54 +- - splash/SplashFTFontEngine.h | 9 +- - splash/SplashFTFontFile.cc | 19 +- - splash/SplashFTFontFile.h | 9 +- - splash/SplashFont.cc | 6 +- - splash/SplashFont.h | 13 +- - splash/SplashFontEngine.cc | 72 +- - splash/SplashFontEngine.h | 11 +- - splash/SplashFontFile.cc | 1 - - splash/SplashFontFile.h | 2 +- - splash/SplashMath.h | 15 +- - splash/SplashPath.cc | 42 +- - splash/SplashPath.h | 31 +- - splash/SplashPattern.cc | 28 - - splash/SplashPattern.h | 25 - - splash/SplashScreen.cc | 304 ++- - splash/SplashScreen.h | 18 +- - splash/SplashState.cc | 63 +- - splash/SplashState.h | 14 +- - splash/SplashT1Font.cc | 101 +- - splash/SplashT1Font.h | 6 +- - splash/SplashT1FontEngine.cc | 4 +- - splash/SplashT1FontFile.cc | 9 +- - splash/SplashT1FontFile.h | 7 +- - splash/SplashTypes.h | 72 +- - splash/SplashXPath.cc | 353 +-- - splash/SplashXPath.h | 26 +- - splash/SplashXPathScanner.cc | 143 + - splash/SplashXPathScanner.h | 13 + - utils/HtmlOutputDev.cc | 15 +- - utils/HtmlOutputDev.h | 15 +- - utils/pdffonts.cc | 15 +- - utils/pdfinfo.cc | 21 +- - utils/pdftoabw.cc | 1 - - utils/pdftohtml.cc | 3 +- - utils/pdftoppm.cc | 8 + - utils/pdftops.cc | 8 +- - utils/pdftotext.cc | 1 - - 139 files changed, 14538 insertions(+), 7039 deletions(-) - -commit ba74bb3b0632593d1937911d73709fc870480efd -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Apr 16 21:25:46 2007 +0000 - - * qt4/src/poppler-private.h: - Add the information about the open/close item in the DOM tree - of the TOC. - - ChangeLog | 7 +++++++ - qt4/src/poppler-private.h | 5 ++++- - 2 files changed, 11 insertions(+), 1 deletion(-) - -commit 6c7969f37c85f326327aca98e0346f2ebc86ffda -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 14 23:19:46 2007 +0000 - - * utils/HtmlFonts.cc: Fix rendering of text colors on - complex mode. - * utils/pdftohtml.cc: Fix rendering of links. - - ChangeLog | 5 +++++ - utils/HtmlFonts.cc | 8 ++++---- - utils/pdftohtml.cc | 2 +- - 3 files changed, 10 insertions(+), 5 deletions(-) - -commit add8515d7b3fba59c20ed1bbb058cea9e138c1a8 -Author: Brad Hards <bradh@frogmouth.net> -Date: Sat Apr 14 07:29:04 2007 +0000 - - Not sure what this was intended to do, but it triggers a lot of - problems with the unit tests (essentially, duplicate delete's). - - CCMAIL: aacid@kde.org - - qt4/src/poppler-embeddedfile.cc | 1 - - 1 file changed, 1 deletion(-) - -commit f3ded10305f6ac682640c37c21f569db0f830756 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sat Apr 7 21:12:35 2007 +0000 - - 2007-04-07 Jeff Muizelaar <jeff@infidigm.net> - - * utils/pdftoabw.cc: Fixing passing the wrong type - to fprintf. Patch by Kouhei Sutou. Fixes #10554. - - ChangeLog | 5 +++++ - utils/pdftoabw.cc | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit 2fcb76df955c143153fe4b273d0388fcb7f67d8a -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Fri Apr 6 15:27:52 2007 +0000 - - 2007-04-06 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/ABWOutputDev.cc: - * utils/pdftoabw.cc: Fix a number of issues with the new - AbiWord code: - *) Allows you to save to a file other than stdout - *) Checks for error conditions when reading the PDF - doc and - writing the ABW doc - *) Removes dead code in pdftoabw.cc - *) Fixes a SEGV I encountered when converting my new - home's floor plan - *) Returns proper error conditions should the conversion - fail for any reason - Patch by Dominic Lachowicz - - ChangeLog | 12 ++++++ - poppler/ABWOutputDev.cc | 3 ++ - utils/pdftoabw.cc | 101 - ++++++++++++++++++++++++++++-------------------- - 3 files changed, 74 insertions(+), 42 deletions(-) - -commit 29da65ec48b5ba91139084e197ce457d3cff3732 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Apr 5 12:13:51 2007 +0000 - - * poppler/PSOutputDev.cc: Readd code wrongly removed when doing the - GlobalParams cleaning - - ChangeLog | 5 +++++ - poppler/PSOutputDev.cc | 5 +++++ - 2 files changed, 10 insertions(+) - -commit 722b2bd86f58f2d7a914571cccfa195485a70c47 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed Apr 4 02:42:29 2007 +0000 - - 2007-04-03 Jeff Muizelaar <jeff@infidigm.net> - - * configure.ac: - * poppler/ABWOutputDev.cc: - * poppler/ABWOutputDev.h: - * poppler/Makefile.am: - * utils/Makefile.am: - * utils/pdftoabw.cc: Add AbiWord output device and pdftoabw - program. - Patch by Jauco Noordzij. Autotools stuff by Dominic Lachowicz. - - ChangeLog | 10 + - configure.ac | 15 + - poppler/ABWOutputDev.cc | 1286 - +++++++++++++++++++++++++++++++++++++++++++++++ - poppler/ABWOutputDev.h | 140 ++++++ - poppler/Makefile.am | 17 + - utils/Makefile.am | 16 +- - utils/pdftoabw.cc | 138 +++++ - 7 files changed, 1620 insertions(+), 2 deletions(-) - -commit c9b467da290476da5ebbe8dc25699cd25e589b57 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Mar 22 20:56:24 2007 +0000 - - * poppler/Gfx.cc: Accept reals for width and height of - images. Fixes - KDE bug 143322 - - ChangeLog | 5 +++++ - poppler/Gfx.cc | 14 ++++++++++---- - 2 files changed, 15 insertions(+), 4 deletions(-) - -commit ff8f8d44ef47a98f7dbdfaa4d27a720b1f37015f -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Mar 15 20:16:13 2007 +0000 - - * glib/Makefile.am: Make it build with BSD/Make. Patch by - Henry Precheur <henry@precheur.org> - - ChangeLog | 5 +++++ - glib/Makefile.am | 4 ++-- - 2 files changed, 7 insertions(+), 2 deletions(-) - -commit bbf7e78b6b2509ecdc476d7f55151ef327470d9d -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Mar 7 19:15:32 2007 +0000 - - 2007-03-07 Carlos Garcia Campos <carlosgc@gnome.org> - reviewed by: Albert Astals Cid <aacid@kde.org> - - * poppler/Page.cc: Consider 0x0 boxes as invalid. Fixes - http://bugzilla.gnome.org/show_bug.cgi?id=408682 - - 2007-03-06 Pino Toscano <pino@kde.org> - reviewed by: Albert Astals Cid <aacid@kde.org> - - * configure.ac: - * qt/Makefile.am: - * qt/poppler-link.cc: - * qt/poppler-page.cc: - * qt/poppler-private.h: - * qt4/poppler-link.cc: - Make the Qt4 frontend compilable again with no Splash. - Make the Qt3 frontend compilable with no Splash. - - ChangeLog | 18 ++++++++++++++++++ - configure.ac | 12 +----------- - poppler/Page.cc | 7 ++++++- - qt/Makefile.am | 1 - - qt/poppler-link.cc | 4 +++- - qt/poppler-page.cc | 16 +++++++++++++++- - qt/poppler-private.h | 11 ++++++++++- - qt4/src/poppler-link.cc | 10 ++++++---- - 8 files changed, 59 insertions(+), 20 deletions(-) - -commit 08dcc7121450cbfa163254001e73bb6a2670e055 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Mar 6 22:27:18 2007 +0000 - - * poppler/Annot.cc: - * poppler/Form.cc: - Fix uninitialized variables. - Properly escape parenthesis and slash in text field - - ChangeLog | 9 ++++++++- - poppler/Annot.cc | 3 +++ - poppler/Form.cc | 1 + - 3 files changed, 12 insertions(+), 1 deletion(-) - -commit e8d3b21d08a59ec8b62503b48504fe046d746bfa -Author: Brad Hards <bradh@frogmouth.net> -Date: Sun Mar 4 07:30:31 2007 +0000 - - Switch to using pkg-config to find Qt4. - - ChangeLog | 9 +++ - configure.ac | 36 +++++------ - m4/qt.m4 | 165 - -------------------------------------------------- - poppler/Makefile.am | 2 +- - qt4/src/Makefile.am | 3 +- - qt4/tests/Makefile.am | 21 +++---- - 6 files changed, 36 insertions(+), 200 deletions(-) - -commit bd99616b9c06f96beadb68e015d2904b7fe2df1d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Feb 25 00:34:21 2007 +0000 - - 007-02-25 Julien Rebetez <julienr@svn.gnome.org> - - reviewed by: Albert Astals Cid <aacid@kde.org> - - * poppler/Annot.cc: - * poppler/Annot.h: - * poppler/Form.cc: - * poppler/Form.h: - Fix compilation warnings. - - ChangeLog | 10 ++++++++++ - poppler/Annot.cc | 30 +++++++++++++++++------------- - poppler/Annot.h | 5 ++++- - poppler/Form.cc | 37 ++++++++++++++----------------------- - poppler/Form.h | 13 ++++++------- - 5 files changed, 51 insertions(+), 44 deletions(-) - -commit d8d23b56332618d8c7d8198f55ec6efafd24187e -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Feb 25 00:00:20 2007 +0000 - - forgot to commit these - - qt4/src/poppler-form.cc | 284 - ++++++++++++++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-form.h | 247 +++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 531 insertions(+) - -commit 984ce7f919aec27d5f4225376550cd6b58d4ae52 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Feb 24 23:58:31 2007 +0000 - - 2007-02-25 Pino Toscano <pino@kde.org> - reviewed by: Albert Astals Cid <aacid@kde.org> - - * qt4/src/Doxyfile: - * qt4/src/Makefile.am: - * qt4/src/poppler-annotation-helper.h: - * qt4/src/poppler-form.cc: - * qt4/src/poppler-form.h: - * qt4/src/poppler-page.cc: - * qt4/src/poppler-private.h: - * qt4/src/poppler-qt4.h: - Beginning of interactive forms support, first - implementation in the - Qt4 frontend. It supports text and choice fields in - a basic way. - - ChangeLog | 14 ++++++++++ - qt4/src/Doxyfile | 1 + - qt4/src/Makefile.am | 2 ++ - qt4/src/poppler-annotation-helper.h | 18 ++++++------- - qt4/src/poppler-page.cc | 36 +++++++++++++++++++++++++ - qt4/src/poppler-private.h | 52 - ++++++++++++++++++++++++++++++++++++- - qt4/src/poppler-qt4.h | 7 +++++ - 7 files changed, 120 insertions(+), 10 deletions(-) - -commit de7a90fc724de14151ec994d18f860ada3be2ac8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Feb 24 23:43:34 2007 +0000 - - 2007-02-25 Albert Astals Cid <aacid@kde.org> - - * configure.ac: - * glib/poppler-document.cc: - * poppler/GlobalParams.cc: - * poppler/GlobalParams.h: - * poppler/PSOutputDev.cc: - * qt/poppler-document.cc: - * qt4/src/poppler-document.cc: - * qt4/src/poppler-private.h: - * qt4/src/poppler-qt4.h: - * test/gtk-splash-test.cc: - * test/pdf-inspector.cc: - * utils/pdffonts.cc: - * utils/pdfimages.cc: - * utils/pdfinfo.cc: - * utils/pdftohtml.cc: - * utils/pdftoppm.cc: - * utils/pdftops.cc: - * utils/pdftotext.cc: Remove dependency on xpdfrc file - and cleanup - GlobalParams accordingly - - ChangeLog | 22 ++ - configure.ac | 1 - - glib/poppler-document.cc | 4 +- - poppler/GlobalParams.cc | 666 - +------------------------------------------- - poppler/GlobalParams.h | 59 +--- - poppler/PSOutputDev.cc | 8 - - qt/poppler-document.cc | 4 +- - qt4/src/poppler-document.cc | 2 +- - qt4/src/poppler-private.h | 2 +- - qt4/src/poppler-qt4.h | 6 +- - test/gtk-splash-test.cc | 2 +- - test/pdf-inspector.cc | 2 +- - utils/pdffonts.cc | 5 +- - utils/pdfimages.cc | 5 +- - utils/pdfinfo.cc | 5 +- - utils/pdftohtml.cc | 2 +- - utils/pdftoppm.cc | 15 +- - utils/pdftops.cc | 50 ++-- - utils/pdftotext.cc | 5 +- - 19 files changed, 72 insertions(+), 793 deletions(-) - -commit 74e70386b759a3cd9864d11eb4ca210010136aa5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Feb 24 23:32:22 2007 +0000 - - 2007-02-25 Julien Rebetez <julienr@svn.gnome.org> - reviewed by: <aacid@kde.org> - - * glib/poppler-document.cc: - * glib/poppler-document.h: - * glib/poppler-page.cc: - * glib/poppler-page.h: - * glib/poppler-private.h: - * glib/poppler.h: - * poppler/Annot.cc: - * poppler/Annot.h: - * poppler/Catalog.cc: - * poppler/Catalog.h: - * poppler/CharCodeToUnicode.cc: - * poppler/CharCodeToUnicode.h: - * poppler/Dict.cc: - * poppler/Dict.h: - * poppler/Form.cc: - * poppler/Form.h: - * poppler/GfxFont.cc: - * poppler/GfxFont.h: - * poppler/Makefile.am: - * poppler/Object.h: - * poppler/Page.cc: - * poppler/Page.h: - * poppler/XRef.cc: - * poppler/XRef.h: - Beginning of Interactive Form support: - Add a bunch of new classes (FormWidget / FormField) - to deal with form - fields. - Add support for object modification through - XRef::setModifiedObject, as - well as a function to write the Xref to a file, - which will be used - to implement PDF writing. - Add some functions to glib wrapper to expose the - new form features. - - ChangeLog | 35 ++ - glib/poppler-document.cc | 192 +++++++ - glib/poppler-document.h | 55 ++ - glib/poppler-page.cc | 120 +++++ - glib/poppler-page.h | 55 ++ - glib/poppler-private.h | 4 + - glib/poppler.h | 15 +- - poppler/Annot.cc | 344 +++++++++--- - poppler/Annot.h | 21 +- - poppler/Catalog.cc | 17 +- - poppler/Catalog.h | 4 + - poppler/CharCodeToUnicode.cc | 34 ++ - poppler/CharCodeToUnicode.h | 3 + - poppler/Dict.cc | 32 ++ - poppler/Dict.h | 4 + - poppler/Form.cc | 1187 - ++++++++++++++++++++++++++++++++++++++++++ - poppler/Form.h | 470 +++++++++++++++++ - poppler/GfxFont.cc | 27 + - poppler/GfxFont.h | 5 + - poppler/Makefile.am | 2 + - poppler/Object.h | 4 + - poppler/Page.cc | 11 +- - poppler/Page.h | 8 +- - poppler/XRef.cc | 87 ++++ - poppler/XRef.h | 9 + - 25 files changed, 2666 insertions(+), 79 deletions(-) - -commit 5c4ea446f33248964431e79b14592b30362634fe -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Feb 18 21:44:24 2007 +0000 - - * configure.ac: Change {datadir}/poppler to {datarootdir}/poppler so - that i get /usr/local/share/poppler in config.h - instead of - ${prefix}/poppler Better fixes are welcome. - - ChangeLog | 6 ++++++ - configure.ac | 2 +- - 2 files changed, 7 insertions(+), 1 deletion(-) - -commit dd140dd63de661303b578863af4d515d82117cca -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Feb 4 00:19:25 2007 +0000 - - fix date - - ChangeLog | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 3c1ed68bf4ee49b27275f7f65d49f42933b1cfa0 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Feb 4 00:16:43 2007 +0000 - - * poppler/Lexer.cc: - * poppler/Lexer.h: Patch to fix regression introduced by - optimizations - in bugzilla issue 7808 - - ChangeLog | 6 ++++++ - poppler/Lexer.cc | 30 ++++++++++++++++++++---------- - poppler/Lexer.h | 2 +- - 3 files changed, 27 insertions(+), 11 deletions(-) - -commit 672408839de0deac4c6006b54df723336ee4be2d -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jan 31 22:05:09 2007 +0000 - - * qt4/src/poppler-page.cc: - Patch by Pino Toscano <pino@kde.org> to remove a nonsense done - by him. - - * qt4/tests/test-poppler-qt4.cpp: - Simply a bit. Patch by Pino Toscano <pino@kde.org>. - - ChangeLog | 8 ++++++++ - qt4/src/poppler-page.cc | 2 -- - qt4/tests/test-poppler-qt4.cpp | 24 ++++++++++++------------ - 3 files changed, 20 insertions(+), 14 deletions(-) - -commit 9c64b8c754e09ff2858af56ce38ef013002bf8e4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jan 31 18:48:16 2007 +0000 - - * m4/qt.m4: Fix Qt4 detection on Mac. Patch by Benjamin Reed - <ranger@befunk.com> - - ChangeLog | 5 +++++ - m4/qt.m4 | 26 +++++++++++++++++++++++--- - 2 files changed, 28 insertions(+), 3 deletions(-) - -commit 1b81192ff2bb9fae4a7bbc685fafe1718f303a7b -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 28 15:55:11 2007 +0000 - - * glib/poppler-page.cc: Make link mapping coordinates - follow page - rotation. Patch by Carlos Garcia Campos <carlosgc@gnome.org> - * glib/poppler-action.cc: Fix link destination - coordinates. Patch by - Carlos Garcia Campos <carlosgc@gnome.org> - - ChangeLog | 4 ++ - glib/poppler-action.cc | 15 +++++- - glib/poppler-page.cc | 124 - +++++++++++++++++++++++++++++++------------------ - 3 files changed, 97 insertions(+), 46 deletions(-) - -commit 75dcf94f53c2d7241111f0d527ee4d3a2ef0b0cf -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 28 15:36:08 2007 +0000 - - * glib/poppler-document.cc: Plug memory leak in - poppler-document. Patch by Carlos Garcia Campos <carlosgc@gnome.org> - - ChangeLog | 5 +++++ - glib/poppler-document.cc | 30 ++++++++++++++---------------- - 2 files changed, 19 insertions(+), 16 deletions(-) - -commit 682a15fc38a2c569d9b1f9871e3e949b62b33cf8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 21 22:35:23 2007 +0000 - - * poppler-document.cc: - * poppler-page.cc: - * poppler-private.h: - * poppler-qt4.h: - No need to destroy the Splash output device to change its - paper color. - Add the possibility to set flags that affect the rendering - (some - backends supports only some of them, though). - Add a Page::label to get the label associated with a page. - Patches by Pino Toscano <pino@kde.org>. - - ChangeLog | 12 ++++++++++++ - qt4/src/poppler-document.cc | 20 ++++++++++++++++++++ - qt4/src/poppler-page.cc | 14 +++++++++++++- - qt4/src/poppler-private.h | 29 ++++++++++++++++++++++++----- - qt4/src/poppler-qt4.h | 25 +++++++++++++++++++++++++ - 5 files changed, 94 insertions(+), 6 deletions(-) - -commit 7331bc46c1cb323316501f05ae1740bea5655596 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jan 17 20:06:29 2007 +0000 - - * poppler/Sound.h: - * poppler/Sound.cc: - * qt4/src/poppler-sound.cc: Move most of the sound reading - code - into the Sound class, so frontends can use it easily. - Patch by Pino Toscano <pino@kde.org>. - - ChangeLog | 10 +++- - poppler/Sound.cc | 80 +++++++++++++++++++++++++- - poppler/Sound.h | 32 ++++++++++- - qt4/src/poppler-sound.cc | 144 - +++++++++++++++++------------------------------ - 4 files changed, 167 insertions(+), 99 deletions(-) - -commit 841bee94da7b6376d2e1fb3daaf8b727b90e42d8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Jan 13 23:19:21 2007 +0000 - - * poppler/Stream.h: - * poppler/Stream.cc: Remove MemStream::setNeedFree method - i really did - not need it - * qt4/src/poppler-document.cc: - * qt4/src/poppler-link.cc: - * qt4/src/poppler-page.cc: - * qt4/src/poppler-private.h: Make Document::loadFromData - work on - documents with a password and don't need to do a malloc and - a memcpy. - - ChangeLog | 11 +++++++ - poppler/Stream.cc | 5 --- - poppler/Stream.h | 1 - - qt4/src/poppler-document.cc | 74 - ++++++++++++++++++++++++--------------------- - qt4/src/poppler-link.cc | 4 +-- - qt4/src/poppler-page.cc | 34 ++++++++++----------- - qt4/src/poppler-private.h | 24 +++++++++------ - 7 files changed, 84 insertions(+), 69 deletions(-) - -commit e1432fd7c4a6a2386789f450d39c6d954fd4e656 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Jan 13 18:29:39 2007 +0000 - - * configure.ac - * poppler/Makefile.am - * qt4/src/Makefile.am - * qt4/src/poppler-document.cc - * qt4/src/poppler-link.cc - * qt4/src/poppler-page.cc - * qt4/src/poppler-private.h - * qt4/src/poppler-qt4.h: Make the Qt4 backend compilable - even with - no Splash backend. Patch by Pino Toscano <pino@kde.org>. - - ChangeLog | 12 ++++++++++++ - configure.ac | 5 ----- - poppler/Makefile.am | 5 +++-- - qt4/src/Makefile.am | 6 +++++- - qt4/src/poppler-document.cc | 16 ++++++++++++++-- - qt4/src/poppler-link.cc | 1 + - qt4/src/poppler-page.cc | 15 ++++++++++++--- - qt4/src/poppler-private.h | 8 +++++++- - qt4/src/poppler-qt4.h | 6 ++++++ - 9 files changed, 60 insertions(+), 14 deletions(-) - -commit 457038e97325720615c4390ffa075dd8283966ee -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Jan 13 17:56:07 2007 +0000 - - * poppler/Stream.h: - * poppler/Stream.cc: Add MemStream::setNeedFree method - * qt4/src/poppler-document.cc: - * qt4/src/poppler-private.h: - * qt4/src/poppler-qt4.h: Add Document::loadFromData method - - ChangeLog | 8 ++++++++ - poppler/Stream.cc | 5 +++++ - poppler/Stream.h | 1 + - qt4/src/poppler-document.cc | 22 ++++++++++++++++++++++ - qt4/src/poppler-private.h | 17 +++++++++++++++-- - qt4/src/poppler-qt4.h | 16 ++++++++++++++++ - 6 files changed, 67 insertions(+), 2 deletions(-) - -commit 4e2a9c49ecab00b1f5d175570165cd490afdd31e -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jan 11 22:28:03 2007 +0000 - - goo/gmem.c: Merge change from xpdf-3.01pl2 - - ChangeLog | 4 ++++ - goo/gmem.c | 13 +++++++++++-- - 2 files changed, 15 insertions(+), 2 deletions(-) - -commit bce14b274fd788d728116950d6464a85e33a9966 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jan 11 22:12:11 2007 +0000 - - * poppler/Catalog.h: - * poppler/Catalog.cc: Limit max depth of recursive calls on - readPageTree to fix MOAB-06-01-2007 - - ChangeLog | 6 ++++++ - poppler/Catalog.cc | 20 +++++++++++++++----- - poppler/Catalog.h | 2 +- - 3 files changed, 22 insertions(+), 6 deletions(-) - -commit 3f0679a336ffaf2aff149f8526fa11f8f8cbda59 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Jan 6 21:53:08 2007 +0000 - - Patch by Pino Toscano <pino@kde.org> to fix some memory leaks when - dealing with sounds. - - ChangeLog | 9 +++++++++ - poppler/Sound.cc | 1 + - qt4/src/poppler-link.cc | 5 +++++ - qt4/src/poppler-link.h | 1 + - qt4/src/poppler-page.cc | 4 ++++ - qt4/src/poppler-sound.cc | 7 ++++++- - 6 files changed, 26 insertions(+), 1 deletion(-) - -commit d41cd2f567a955031cb7498d9089e70e14df4a42 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jan 4 19:10:16 2007 +0000 - - qt4/src/poppler-private.h: gmallocn -> new[] - - ChangeLog | 4 ++++ - qt4/src/poppler-private.h | 2 +- - 2 files changed, 5 insertions(+), 1 deletion(-) - -commit f8edfb6832144cbbd1b234f6b35e33325269255c -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jan 4 18:56:13 2007 +0000 - - qt/poppler-page-transition.cc: Fix memory leak. Patch by Tobias - Koenig <tokoe@kde.org> - - ChangeLog | 5 +++++ - qt/poppler-page-transition.cc | 1 + - 2 files changed, 6 insertions(+) - -commit 250a9f4b429344e0968c7bd0c0cebe7af373ae0a -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Dec 30 14:50:25 2006 +0000 - - * qt4/src/poppler-qt4.h: - * qt4/src/poppler-document.cc: Add const & to some parameters. Patch - by Pino Toscano <pino@kde.org> - - ChangeLog | 6 ++++++ - qt4/src/poppler-document.cc | 4 ++-- - qt4/src/poppler-qt4.h | 4 ++-- - 3 files changed, 10 insertions(+), 4 deletions(-) - -commit 250c1f94cc9a53f980fd08364d6cce29db9fd067 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Dec 29 14:08:35 2006 +0000 - - * poppler/UGooString.cc: Patch by Pino Toscano <pino@kde.org> so - that QStringToUGooString does not crash. - - ChangeLog | 5 +++++ - poppler/UGooString.cc | 1 + - 2 files changed, 6 insertions(+) - -commit 42770e5f07407b03dce31c73fd6956f9c8fc9a06 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Fri Dec 29 04:12:40 2006 +0000 - - 2006-12-28 Brad Taylor <brad@getcoded.net> - - * poppler/glib/poppler-document.h: - * poppler/glib/poppler-document.cc: Add - poppler_document_new_from_data - to allow loading PDFs out of memory. - - ChangeLog | 6 +++ - glib/poppler-document.cc | 113 - ++++++++++++++++++++++++++++++++++------------- - glib/poppler-document.h | 4 ++ - 3 files changed, 93 insertions(+), 30 deletions(-) - -commit 6fedd991b584e300b5710630fa7942d357fe7aaa -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Dec 28 17:22:36 2006 +0000 - - * qt4/src/poppler-embeddedfile.cc: - * qt4/src/poppler-document.cc: - * qt/poppler-document.cc: Fix memory leaks - - ChangeLog | 6 ++++++ - qt/poppler-document.cc | 4 ++++ - qt4/src/poppler-document.cc | 4 +++- - qt4/src/poppler-embeddedfile.cc | 4 +++- - 4 files changed, 16 insertions(+), 2 deletions(-) - -commit 7da5885e45c33382060276c95d9a3bd117ae55c7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Dec 28 15:51:44 2006 +0000 - - * goo/GooString.cc - * goo/GooString.h - * goo/gmem.c - * goo/gmem.h - * poppler/Lexer.cc - * poppler/Lexer.h - * poppler/PageLabelInfo.cc - * poppler/Parser.cc - * poppler/UGooString.cc - * poppler/UGooString.h: Patch by Krzysztof Kowalczyk - <kkowalczyk@gmail.com> to improve performance. See bug 7808 for - details. - - ChangeLog | 15 ++++ - goo/GooString.cc | 186 - ++++++++++++++++++++++++----------------------- - goo/GooString.h | 28 +++++-- - goo/gmem.c | 3 +- - goo/gmem.h | 2 +- - poppler/Lexer.cc | 19 +++-- - poppler/Lexer.h | 10 +++ - poppler/PageLabelInfo.cc | 1 + - poppler/Parser.cc | 17 +++-- - poppler/UGooString.cc | 137 +++++++++++++++++++++++++++------- - poppler/UGooString.h | 40 ++++++++-- - 11 files changed, 313 insertions(+), 145 deletions(-) - -commit fbc05a6791fc28ee26a9d9188722ea3453c65ddc -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Dec 27 23:15:06 2006 +0000 - - * poppler/Annot.cc: - * poppler/Annot.h: Add type checking to processing of "Rect". Patch - by Scott Turner <scotty1024@mac.com> - - ChangeLog | 6 ++++++ - poppler/Annot.cc | 48 +++++++++++++++++++++++++++++------------------- - poppler/Annot.h | 1 + - 3 files changed, 36 insertions(+), 19 deletions(-) - -commit dc6b372358ac629c43aa2faabd644942cb0ed98b -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Dec 27 15:23:04 2006 +0000 - - Remove , after last value of enum. Thanks to André Wöbbeking - - ChangeLog | 1 + - poppler/Catalog.h | 2 +- - 2 files changed, 2 insertions(+), 1 deletion(-) - -commit c7d19539a95927eb277966a521f13393c9e116bb -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Dec 27 12:38:58 2006 +0000 - - qt4/src/poppler-qt4.h: Remove , after last value of enum. Thanks to - André Wöbbeking - - ChangeLog | 5 +++++ - qt4/src/poppler-qt4.h | 4 ++-- - 2 files changed, 7 insertions(+), 2 deletions(-) - -commit b29429c702e6540b9f35689b0a164f30e747d5d9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Dec 26 20:07:03 2006 +0000 - - * qt4/src/poppler-qt4.h: - * qt4/src/poppler-page.cc: Add Page::duration() function to the - qt4 frontend. - - ChangeLog | 6 ++++++ - qt4/src/poppler-page.cc | 8 ++++++++ - qt4/src/poppler-qt4.h | 9 ++++++++- - 3 files changed, 22 insertions(+), 1 deletion(-) - -commit 62dfc58903b496c4cc720c8b2c759c6fb82fb443 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Dec 26 19:56:28 2006 +0000 - - * glib/test-poppler-glib.c: - * glib/poppler-page.cc: - * glib/poppler-page.h: - * poppler/Page.cc: - * poppler/Page.h: Implement /Dur entry in page object. Patch - by Carlos - Garcia Campos <carlosgc@gnome.org> - - ChangeLog | 9 +++++++++ - glib/poppler-page.cc | 16 ++++++++++++++++ - glib/poppler-page.h | 1 + - glib/test-poppler-glib.c | 7 +++++++ - poppler/Page.cc | 13 +++++++++++++ - poppler/Page.h | 6 ++++++ - 6 files changed, 52 insertions(+) - -commit 34e5aa62f4d3ba7a2d94a68a91c11a48277a4119 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Dec 23 13:12:13 2006 +0000 - - * poppler/PSTokenizer.cc: Enhance PSTokenizer::getToken - performance. - Patch by Scott Turner <scotty1024@mac.com>. In a random pdf - i tested - the patchs improves PSTokenizer::getToken performance by 15% - - ChangeLog | 6 ++++++ - poppler/PSTokenizer.cc | 33 +++++++++++++++++++++------------ - poppler/PSTokenizer.h | 1 + - 3 files changed, 28 insertions(+), 12 deletions(-) - -commit 1a5fa1d2ced62e7d027e085663e987cff625ce0b -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Dec 22 23:39:41 2006 +0000 - - poppler/Page.cc: Fix memory leak when reading a wrong color map in - a thumbnail. Patch by Scott Turner <scotty1024@mac.com> - - ChangeLog | 3 +++ - poppler/Page.cc | 1 + - 2 files changed, 4 insertions(+) - -commit dd1c134dcf085338a85188c7f205fc300396dc86 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Dec 22 23:27:53 2006 +0000 - - qt/poppler-page.cc: Fix memory leak in Page::textList. Patch by - Jerry Epplin <jepplin@globalvelocity.com> - - ChangeLog | 5 +++++ - qt/poppler-page.cc | 4 +++- - 2 files changed, 8 insertions(+), 1 deletion(-) - -commit 87e474a018c4808d6251fd79f9e9640e0f733551 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Thu Dec 21 01:01:30 2006 +0000 - - 2006-12-20 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: Fix scaling of maskedImage - masks. They - should be scaled to the size of the image not the size of - the mask. - Fixes #9403. - - ChangeLog | 6 ++++++ - poppler/CairoOutputDev.cc | 8 ++------ - 2 files changed, 8 insertions(+), 6 deletions(-) - -commit 769a89623c680f51690db1751522b016b02b83a8 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed Dec 20 19:55:55 2006 +0000 - - 2006-12-20 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/GlobalParams.cc: Try to make zero-width lines as - close to - one pixel wide as we can. Fixes #9393. - - ChangeLog | 5 +++++ - poppler/CairoOutputDev.cc | 10 ++++++++-- - 2 files changed, 13 insertions(+), 2 deletions(-) - -commit 5c4bca18373528f293bd5e080efca572977fc1ff -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Dec 19 20:27:55 2006 +0000 - - poppler/SplashOutputDev.cc: Fix gray calculation. Patch by Scott - Turner <scotty1024@mac.com> - - ChangeLog | 5 +++++ - poppler/SplashOutputDev.cc | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit fba99578f6001ae0c0df0442bb73040b55109b1d -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Tue Dec 12 05:23:59 2006 +0000 - - 2006-12-12 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: Change a cairo_set_matrix to - cairo_transform so that we don't blindly clobber the existing - matrix. - Patch by Daniel Colascione. - Fixes #9190. - - ChangeLog | 7 +++++++ - poppler/CairoOutputDev.cc | 2 +- - 2 files changed, 8 insertions(+), 1 deletion(-) - -commit 9a6ffa1c6e009f8606a055f873efdcd5829fcfa2 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sun Dec 10 05:24:56 2006 +0000 - - 2006-12-09 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/Function.cc: Initialize PostScriptFunction::codeString - to - NULL so that it can safely deleted if initialization fails. - Fixes #9263. - - ChangeLog | 6 ++++++ - poppler/Function.cc | 1 + - 2 files changed, 7 insertions(+) - -commit e92d63a179ae022270156da4e396c15ff9236d89 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Nov 23 19:01:44 2006 +0000 - - * m4/libjpeg.m4: Make JPEG library header search work under - MSYS. Patch by Alexis Wilke - - ChangeLog | 5 +++++ - m4/libjpeg.m4 | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit 3913110f698fd006b394a395b5b0adfde30af31b -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 22 21:55:27 2006 +0000 - - there should not be any whitespace after the \ - - qt4/src/Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit c3ab7addec5a7990872949b813c2b727b1614d64 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Nov 19 18:51:23 2006 +0000 - - Another leak fix on qt4/src/poppler-page.cc the previous changelog - is enough for this one ;-) - - qt4/src/poppler-page.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 9e9b82da91abacb916b05302d40bf822af6ac7f1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Nov 19 12:59:48 2006 +0000 - - * qt4/src/poppler-link.cc: - * qt4/src/poppler-page.cc: - * qt4/src/poppler-qt4.h: - * qt4/src/poppler-textbox.cc: Fix memory leaks - * splash/Splash.cc: Initialize the values of nClipRes - - ChangeLog | 8 ++++++++ - qt4/src/poppler-link.cc | 6 ++++++ - qt4/src/poppler-page.cc | 4 +++- - qt4/src/poppler-qt4.h | 1 + - qt4/src/poppler-textbox.cc | 5 +++++ - splash/Splash.cc | 2 +- - 6 files changed, 24 insertions(+), 2 deletions(-) - -commit b9faacc62182efcbc84df2471e4c5dcf2b03bda8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Nov 18 17:08:04 2006 +0000 - - * qt4/src/poppler-document.cc - * qt4/src/poppler-qt4.h: Add int marginRight, int - marginBottom, int - marginLeft, int marginTop, bool strictMargins to - Document::print() - - ChangeLog | 6 ++++++ - qt4/src/poppler-document.cc | 11 +++++++++-- - qt4/src/poppler-qt4.h | 6 +++++- - 3 files changed, 20 insertions(+), 3 deletions(-) - -commit da8e6d4c3e0afdaa031413649ae20545c8a1f845 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Nov 16 21:03:27 2006 +0000 - - really commit pino's patch :-S - - qt4/src/Doxyfile | 11 +++-- - qt4/src/Mainpage.dox | 26 +++++----- - qt4/src/poppler-annotation.h | 33 ++++++++----- - qt4/src/poppler-link.h | 68 +++++++++++++++++++++---- - qt4/src/poppler-qt4.h | 115 - +++++++++++++++++++++++++++---------------- - 5 files changed, 171 insertions(+), 82 deletions(-) - -commit 4f26e65096e3133a39fc0c9e82084c90cf77dda9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Nov 16 21:00:10 2006 +0000 - - * qt4/src/Mainpage.dox: - * qt4/src/Doxyfile: - * qt4/src/poppler-annotation.h: - * qt4/src/poppler-link.h: - * qt4/src/poppler-qt4.h: Improve API documentation. Patch by - Pino Toscano. - - Generated docu at http://people.freedesktop.org/~aacid/docs/qt4/ - - ChangeLog | 9 +++++++++ - qt4/src/Mainpage.dox | 2 +- - 2 files changed, 10 insertions(+), 1 deletion(-) - -commit e68b6f3f8fea1e4f036eba0f19bb7e0c423d408c -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Nov 15 21:07:50 2006 +0000 - - 2006-11-15 Albert Astals Cid <aacid@kde.org> - - * qt4/src/poppler-link.cc: - * qt4/src/poppler-page.cc: - * qt4/src/poppler-qt4.h: - * qt4/src/poppler-document.cc: - * qt4/src/poppler-private.h: Generalize the way we render - the pages: - merge all the Page::renderTo* functions in only one that - renders on - a QImage, taking into account the currently chosen backend. - It is possible to switch rendering backend using the Document. - Patch by Pino Toscano. - - * qt4/tests/stress-poppler-qt4.cpp: - * qt4/tests/test-password-qt4.cpp: - * qt4/tests/test-poppler-qt4.cpp: Adapt the tests to the - changes in - the rendering API of Page. Patch by Pino Toscano. - - ChangeLog | 17 ++++++ - qt4/src/poppler-document.cc | 14 +++++ - qt4/src/poppler-link.cc | 2 +- - qt4/src/poppler-page.cc | 123 - +++++++++++++++++++++------------------ - qt4/src/poppler-private.h | 32 ++++++---- - qt4/src/poppler-qt4.h | 75 +++++++----------------- - qt4/tests/stress-poppler-qt4.cpp | 3 +- - qt4/tests/test-password-qt4.cpp | 12 ++-- - qt4/tests/test-poppler-qt4.cpp | 17 +++--- - 9 files changed, 152 insertions(+), 143 deletions(-) - -commit 37088dd3335be6e7641c47bea9b1ddd689b07372 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Nov 13 19:16:44 2006 +0000 - - * poppler/ArthurOutputDev.cc: Small fix to get colors right - - ChangeLog | 4 ++++ - poppler/ArthurOutputDev.cc | 8 ++++---- - 2 files changed, 8 insertions(+), 4 deletions(-) - -commit 302e2cab9fd626222c69ad40f7e40be2e65d34a9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Nov 11 15:41:27 2006 +0000 - - Fix typo when outputing PS scale - - ChangeLog | 4 ++++ - poppler/PSOutputDev.cc | 2 +- - 2 files changed, 5 insertions(+), 1 deletion(-) - -commit e3550fb286dae98992b30edbf4a9300fa58d2e77 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Tue Nov 7 23:53:31 2006 +0000 - - 2006-11-07 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: take horizontal scaling into account - when updating the font. Also, cleanup some unused code. Fixes - #8924. - - ChangeLog | 5 +++++ - poppler/CairoOutputDev.cc | 9 ++------- - 2 files changed, 7 insertions(+), 7 deletions(-) - -commit f020b64a72ad5c82c3e7bdcf15039bb0037b1f22 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Oct 18 18:43:59 2006 +0000 - - 2006-10-18 Albert Astals Cid <aacid@kde.org> - - * qt4/src/poppler-document.cc: - * qt4/src/poppler-private.h: Do not crash when opening a - encrypted document. Do not crash when unlocking a locked - document. - - ChangeLog | 7 +++++++ - qt4/src/poppler-document.cc | 41 - ++++++++++++++++------------------------- - qt4/src/poppler-private.h | 14 ++++++++++++++ - 3 files changed, 37 insertions(+), 25 deletions(-) - -commit 577330ee1d4d1021174cf1bd59557a83a017e06f -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Oct 11 23:09:24 2006 +0000 - - * splash/Splash.cc: - * splash/SplashErrorCodes.h: Do not crash on documents that - report a - 0x0 mask for an image, like - http://bugs.kde.org/attachment.cgi?id=18083&action=view - - ChangeLog | 7 +++++++ - splash/Splash.cc | 2 ++ - splash/SplashErrorCodes.h | 2 ++ - 3 files changed, 11 insertions(+) - -commit 42c016c6d3c6de65fd92b51b9d6cc96d52404689 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Oct 8 20:38:47 2006 +0000 - - * poppler/Link.cc: - * poppler/Link.h: - * poppler/Makefile.am: - * poppler/Page.cc: - * poppler/Page.h: - * poppler/Sound.cc: - * poppler/Sound.h: Make poppler able to read Sound objects, - Sound - actions and Opening/Closing page actions. Patch by Pino - Toscano. - - * qt4/src/Makefile.am: - * qt4/src/poppler-link.cc: - * qt4/src/poppler-link.h: - * qt4/src/poppler-qt4.h: - * qt4/src/poppler-page.cc: - * qt4/src/poppler-sound.cc: Support for sounds, sound links - and page - actions in the Qt4 backend. Patch by Pino Toscano. - - ChangeLog | 19 +++++ - poppler/Link.cc | 53 ++++++++++++++ - poppler/Link.h | 32 +++++++++ - poppler/Makefile.am | 2 + - poppler/Page.cc | 8 +++ - poppler/Page.h | 4 ++ - poppler/Sound.cc | 65 +++++++++++++++++ - poppler/Sound.h | 46 ++++++++++++ - qt4/src/Makefile.am | 1 + - qt4/src/poppler-link.cc | 35 ++++++++++ - qt4/src/poppler-link.h | 26 ++++++- - qt4/src/poppler-page.cc | 32 +++++++++ - qt4/src/poppler-qt4.h | 87 +++++++++++++++++++++++ - qt4/src/poppler-sound.cc | 177 - +++++++++++++++++++++++++++++++++++++++++++++++ - 14 files changed, 586 insertions(+), 1 deletion(-) - -commit 1da064d7e7403ec7111eecb2b9613e27a2c4bb5d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Sep 30 16:28:35 2006 +0000 - - * qt4/src/poppler-page.cc: PA is optional, H is a name not a string - - ChangeLog | 4 ++++ - qt4/src/poppler-page.cc | 15 +++++++++------ - 2 files changed, 13 insertions(+), 6 deletions(-) - -commit 29366d8e470ab2207cdfdab115c2fa9618c4c74e -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 25 20:43:18 2006 +0000 - - * glib/Makefile.am - * qt/Makefile.am - * qt4/src/Makefile.am - * qt4/tests/Makefile.am - * test/Makefile.am - * utils/Makefile.am: Add FONTCONFIG_CFLAGS FONTCONFIG_LIBS - for people - that need them. Patch by morfoh@opensde.org. Fixes bug #8415 - - ChangeLog | 10 ++++++++++ - glib/Makefile.am | 2 ++ - qt/Makefile.am | 6 ++++-- - qt4/src/Makefile.am | 2 ++ - qt4/tests/Makefile.am | 2 ++ - test/Makefile.am | 6 ++++-- - utils/Makefile.am | 6 ++++-- - 7 files changed, 28 insertions(+), 6 deletions(-) - -commit 957c1e59df213a01ca87f03d067a8dab5dc09fb6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 25 20:05:28 2006 +0000 - - ignore poppler-features.h - - glib/.cvsignore | 1 + - 1 file changed, 1 insertion(+) - -commit 3158b54375bdfdc82779362cc9442aade87f84f6 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Sep 22 00:55:54 2006 +0000 - - 2006-09-21 Kristian Høgsberg <krh@redhat.com> - - * NEWS: Update list of bugs fixes, release 0.5.4. - - ChangeLog | 2 ++ - NEWS | 2 +- - 2 files changed, 3 insertions(+), 1 deletion(-) - -commit 17dd1f60f9328ae68fbe262ae0745be976ff9f95 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Sep 21 23:28:14 2006 +0000 - - 2006-09-21 Kristian Høgsberg <krh@redhat.com> - - * configure.ac: Check for gtk+ 2.8 for the gtk+ test case, invert - help text for zlib option (#7788, #7661). - - ChangeLog | 3 +++ - configure.ac | 12 +++++------- - 2 files changed, 8 insertions(+), 7 deletions(-) - -commit ddbbd697424b9122ce1f0541ddada3fe8bb38fb1 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Sep 21 22:58:31 2006 +0000 - - 2006-09-21 Kristian Høgsberg <krh@redhat.com> - - * utils/pdftops.cc: Get duplex setting from GlobalParams. - - ChangeLog | 2 ++ - utils/pdftops.cc | 3 ++- - 2 files changed, 4 insertions(+), 1 deletion(-) - -commit 0d25592a1a5811ee8fffbd70307c7bcaaaacadf3 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Sep 21 22:40:52 2006 +0000 - - 2006-09-21 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc (_poppler_page_new): Make PopplerPage - reference its document throughout the lifetime of the page - (#7005). - - ChangeLog | 3 +++ - glib/poppler-page.cc | 5 ++++- - 2 files changed, 7 insertions(+), 1 deletion(-) - -commit b834755c7ae45eb4020e9cdbc3852eac0151fcdc -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Sep 21 22:37:00 2006 +0000 - - 2006-09-21 Kristian Høgsberg <krh@redhat.com> - - * poppler/Gfx.cc: Remove the right out->updateAll() call. - - ChangeLog | 4 ++++ - poppler/Gfx.cc | 2 +- - 2 files changed, 5 insertions(+), 1 deletion(-) - -commit 181e2af1edf2cbc3c8edadad0dce215a64a990dd -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Sep 21 01:05:23 2006 +0000 - - 2006-09-20 Kristian Høgsberg <krh@redhat.com> - - * NEWS: Sum up changes. - - * configure.ac: Bump release to 0.5.4. - - ChangeLog | 4 ++++ - NEWS | 10 ++++++++++ - configure.ac | 2 +- - 3 files changed, 15 insertions(+), 1 deletion(-) - -commit cc9c17a6730422be99ebcd69991fcf5d7b569640 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Sep 21 00:56:33 2006 +0000 - - 2006-09-20 Kristian Høgsberg <krh@redhat.com> - - * poppler/Gfx.cc: Remove last remnant of erroneous type3 commit a - while back, fixing #8182. - - ChangeLog | 5 +++++ - poppler/CairoOutputDev.cc | 1 - - poppler/Gfx.cc | 1 - - 3 files changed, 5 insertions(+), 2 deletions(-) - -commit 83be722b56d9266b89946fe994023351e47eb4fd -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed Sep 20 20:22:19 2006 +0000 - - 2006-09-20 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/TextOutputDev.cc: TextFontInfo stores a copy of - a pointer - to a GfxFont but does not increment the reference count. Fix the - problem by calling incRefCnt and decRefCnt appropriately. Fixes - #4649 - - ChangeLog | 6 ++++++ - poppler/TextOutputDev.cc | 4 ++++ - 2 files changed, 10 insertions(+) - -commit 1cf60015d7d78668c83737be6015dc880fd04ebf -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue Sep 19 04:39:07 2006 +0000 - - 2006-09-19 Kristian Høgsberg <krh@redhat.com> - - * poppler/GlobalParams.cc: Add scanEncodingDirs() to automatically - scan in any encodings found under ${datadir}/poppler. - - * m4/define-dir.m4: New file, adds AC_DEFINE_DIR macro. - - ChangeLog | 7 +++ - configure.ac | 16 +------ - goo/gfile.cc | 16 +++---- - goo/gfile.h | 2 + - m4/define-dir.m4 | 34 ++++++++++++++ - poppler/GlobalParams.cc | 116 - ++++++++++++++++++++++++++++++++---------------- - poppler/GlobalParams.h | 7 ++- - 7 files changed, 136 insertions(+), 62 deletions(-) - -commit 821c883f9df9cc0e5b81aa2e070727996cf3bc4e -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Sep 18 15:40:50 2006 +0000 - - 2006-09-13 Kristian Høgsberg <krh@redhat.com> - - * poppler/Makefile.am (libpoppler_la_LIBADD): Add cairo libs to - link if configured. - - ChangeLog | 3 +++ - poppler/Makefile.am | 4 ++++ - 2 files changed, 7 insertions(+) - -commit d8ab8ebc94c32d32ad17ed54cede453de25d7dd5 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed Sep 13 20:25:03 2006 +0000 - - 2006-09-13 Kristian Høgsberg <krh@redhat.com> - - * configure.ac: Tighten glib check (#7906), add check for C++ - compiler (#8048). - - ChangeLog | 5 +++++ - configure.ac | 3 ++- - 2 files changed, 7 insertions(+), 1 deletion(-) - -commit 7c748075e18cfe95be6a56adf09ce7f2f032b86f -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 12 19:48:47 2006 +0000 - - sorry Jeff - - ChangeLog | 7 +++++++ - 1 file changed, 7 insertions(+) - -commit 6cdcfae0e1c6fbec07ee5273e6ad97ef04110868 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Sep 11 21:20:56 2006 +0000 - - 2006-09-11 Albert Astals Cid <aacid@kde.org> - - * qt4/src/poppler-annotation.cc: - * qt4/src/poppler-annotation.h: - * qt4/src/poppler-page.cc: Add support for - LinkAnnotation. Patch by - Pino Toscano - - ChangeLog | 10 +- - qt4/src/poppler-annotation.cc | 230 - +++++++++++++++++++++++++++++++++++++++- - qt4/src/poppler-annotation.h | 22 +++- - qt4/src/poppler-page.cc | 237 - +++++++++++++++++++++++++----------------- - 4 files changed, 392 insertions(+), 107 deletions(-) - -commit 8335c7eea2aa62a580170f47323d8674bd89e412 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Fri Sep 8 23:28:22 2006 +0000 - - 2006-09-08 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: The work-around for 1x1 imagemasks - was not - calling cairo_set_source causing the rectangles to be drawn - the wrong - colour occasionally. Fix by moving the existing call to - cairo_set_source above the work-around. Fixes #7113. - - ChangeLog | 7 +++++++ - poppler/CairoOutputDev.cc | 8 ++++---- - 2 files changed, 11 insertions(+), 4 deletions(-) - -commit 02d505aa0176b6e5a54ee82426d8333a9ef8f000 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Thu Sep 7 04:01:39 2006 +0000 - - 2006-09-06 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: Avoid crashing in CairoOutputDev if - endString is called without a corresponding beginString. Fixes - #4515. - - ChangeLog | 5 +++++ - poppler/CairoOutputDev.cc | 8 +++++++- - 2 files changed, 12 insertions(+), 1 deletion(-) - -commit 3ea0aada0434c9f815814253dd9d1374ae6643cc -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed Sep 6 23:54:30 2006 +0000 - - 2006-09-06 Jeff Muizelaar <jeff@infidigm.net> - - * configure.ac: - * poppler/FlateStream.cc: - * poppler/FlateStream.h: Fix FlateStream to not read more than it - needs. This has a performance impact because our input buffer - is now - only 1 byte large, however correctness is better than performance. - This should fix #3948. - - ChangeLog | 9 +++++++++ - configure.ac | 2 +- - poppler/FlateStream.cc | 35 +++++++++++++++++++++++++---------- - poppler/FlateStream.h | 3 ++- - 4 files changed, 37 insertions(+), 12 deletions(-) - -commit 1d2e6aedca0b8fcce6ac84ae2576ab067912886b -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Tue Sep 5 01:21:50 2006 +0000 - - 2006-09-04 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: Initialize currentFont to NULL before - use. Found by Pascal Terjan. Fixes #7924. - - ChangeLog | 5 +++++ - poppler/CairoOutputDev.cc | 1 + - 2 files changed, 6 insertions(+) - -commit 7905adaa21f2347346927fa567c64be60e2bc69c -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Sep 3 09:27:21 2006 +0000 - - * poppler/Dict.cc: - * poppler/Dict.h: - * poppler/Object.h: - * poppler/Parser.cc: Patch by Krzysztof Kowalczyk to increase - speed by - means of doing less copies between objects. See bug 8112 - for more - information. - - ChangeLog | 9 +++++++++ - poppler/Dict.cc | 4 ++-- - poppler/Dict.h | 11 +++++++++-- - poppler/Object.h | 12 ++++++++++++ - poppler/Parser.cc | 15 +++++++++------ - 5 files changed, 41 insertions(+), 10 deletions(-) - -commit 4da7c90a619002e54f436c4efee723b5bc42a112 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Aug 24 22:32:31 2006 +0000 - - * qt4/src/poppler-private.h: Init m_fontInfoScanner to - NULL. Discovered by - Rafael Rodríguez <rafael.rodriguez.tf@gmail.com> - - ChangeLog | 5 +++++ - qt4/src/poppler-private.h | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit 469202e117910beb4e0ad906d5c154a3bae5c98b -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Aug 16 14:35:14 2006 +0000 - - * qt/poppler-page.cc: Report correct page size. Backport from Qt4 - frontend. Patch by Wilfried Huss - - ChangeLog | 5 +++++ - qt/poppler-page.cc | 10 ++++++++-- - 2 files changed, 13 insertions(+), 2 deletions(-) - -commit b881844e4d31009c5d54c9321a6daaf0f354cf6b -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Aug 16 09:18:04 2006 +0000 - - did not want to commit that, thanks Brad for noticing! - - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit f52380e6d569280839d7c37362bd7cc59f2573c3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Aug 15 22:27:31 2006 +0000 - - add a warning how nasty zlib can be, it can come and it your pdfs - and make your readers crash when you are not looking at it, so be - aware that if you enable it you are on your own ;-) - - ChangeLog | 4 ++++ - configure.ac | 4 ++-- - 2 files changed, 6 insertions(+), 2 deletions(-) - -commit 1caba84b1024f1fa7865deebbf70379855ce078d -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Aug 11 13:12:11 2006 +0000 - - 2006-08-11 Albert Astals Cid <aacid@kde.org> - - * poppler/Catalog.cc: Fix leak - - ChangeLog | 4 ++++ - poppler/Catalog.cc | 1 + - 2 files changed, 5 insertions(+) - -commit 9b6455f6530e273afaa5f948b67ceeec8a06f976 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Aug 10 16:08:51 2006 +0000 - - 2006-08-10 Albert Astals Cid <aacid@kde.org> - - * poppler/SplashOutputDev.cc: Try to fix refs to fonts - yet again - - ChangeLog | 4 ++++ - poppler/SplashOutputDev.cc | 4 ++-- - 2 files changed, 6 insertions(+), 2 deletions(-) - -commit 305f60e0437dcfc5babd449123a1fe4cd062a219 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Aug 5 17:10:07 2006 +0000 - - 2006-08-05 Albert Astals Cid <aacid@kde.org> - - * poppler/Catalog.cc: The name array can contain references - to strings - instead of stings themselves, or at least PDF of - https://bugs.freedesktop.org/show_bug.cgi?id=7780 does. This - makes it - work with that file - * qt4/src/poppler-embeddedfile.cc: Use UGooString for - description - - ChangeLog | 8 ++++++++ - poppler/Catalog.cc | 12 ++++++++++-- - qt4/src/poppler-embeddedfile.cc | 3 ++- - 3 files changed, 20 insertions(+), 3 deletions(-) - -commit dd8758ea3f0f44e9f8362343f15b2064f428ad64 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Aug 4 22:48:09 2006 +0000 - - 2006-08-05 Albert Astals Cid <aacid@kde.org> - - * utils/pdftotext.cc: - * utils/pdfinfo.cc: - * utils/pdffonts.cc: Add the posibility of reading a file - from stdin. - Patch by Dom Lachowicz - - ChangeLog | 7 +++++++ - utils/pdffonts.cc | 11 ++++++++++- - utils/pdfinfo.cc | 11 ++++++++++- - utils/pdftotext.cc | 11 ++++++++++- - 4 files changed, 37 insertions(+), 3 deletions(-) - -commit a418d844cf6baa797919796ceadaf21ef9b2e5b9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Aug 3 10:34:52 2006 +0000 - - * configure.ac: Use the correct variable to output the - utils status. - Patch by Dom Lachowic - - ChangeLog | 5 +++++ - configure.ac | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit 1673b895656143a8a1f1a45e07f777f39995940d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jul 30 20:31:31 2006 +0000 - - * poppler/GfxState.cc: make nGfxBlendModeNames define - return the - correct size of the gfxBlendModeNames array so it does - not access - invalid memory areas when the blend mode is not - found. Discovered by - Krzysztof Kowalczyk - - ChangeLog | 7 +++++++ - poppler/GfxState.cc | 12 +++++++----- - 2 files changed, 14 insertions(+), 5 deletions(-) - -commit e4561568d14e7b3b2aec6ecaf3cc09078bdf7a46 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jul 30 09:38:28 2006 +0000 - - * splash/SplashFontEngine.cc: - * poppler/SplashOutputDev.cc: Fix memory leak when using - embedded - fonts in the pdf file. Patch by Krzysztof Kowalczyk - - ChangeLog | 6 ++++++ - poppler/SplashOutputDev.cc | 8 ++++++-- - splash/SplashFontEngine.cc | 12 ++++++++---- - 3 files changed, 20 insertions(+), 6 deletions(-) - -commit 4a27502159a89992f54be2673b44bf7a8392b60d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Jul 29 16:24:53 2006 +0000 - - push back thing i did not want to commit, sorry - - configure.ac | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit ba448afc0e97a9e779409ff228adcd4f627971f5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Jul 29 16:22:52 2006 +0000 - - * configure.ac: Disable qt and qt4 frontends if splash - backend is - disabled - - ChangeLog | 5 +++++ - configure.ac | 18 ++++++++++++++---- - 2 files changed, 19 insertions(+), 4 deletions(-) - -commit 1e32d3baa5e8296caf55bd5853216a96618c74ac -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Jul 28 18:17:45 2006 +0000 - - 2006-07-28 Kristian Høgsberg <krh@redhat.com> - - * poppler/CairoOutputDev.cc: Don't set font matrix translation - (fix from Behdad Esfahbod). - - ChangeLog | 5 +++++ - poppler/CairoOutputDev.cc | 4 ++-- - 2 files changed, 7 insertions(+), 2 deletions(-) - -commit 0bc1b0f35c28cb80dd27d24110367348e52c143b -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jul 27 18:21:28 2006 +0000 - - fix date, i don't live in the past - - ChangeLog | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 2f27c3a0218608568f6cd1c718ef51b9879023a3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jul 27 18:17:50 2006 +0000 - - * poppler/Stream.cc: If you are going to test a variable, - better - initialize it first ;-) Fixes bug 7646 - - ChangeLog | 5 +++++ - poppler/Stream.cc | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit f39ab43ca824cb7e5db73137c4545b3e85134425 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jul 26 18:16:01 2006 +0000 - - 2006-07-26 Albert Astals Cid <aacid@kde.org> - - * qt/poppler-document.cc: - * qt/poppler-private.h: - * qt/poppler-qt.h: Port the QDomDocument *Document::toc() - const method - from the qt4 frontend to the qt frontend. Patch by Wilfried - Huss - - ChangeLog | 7 ++++++ - qt/poppler-document.cc | 18 ++++++++++++++++ - qt/poppler-private.h | 58 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - qt/poppler-qt.h | 16 ++++++++++++++ - 4 files changed, 99 insertions(+) - -commit c3a9fd546b853c85b6be5fc8f4e5a78d8a7e7437 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jul 25 18:39:57 2006 +0000 - - * qt4/src/poppler-document.cc: Obey kdeprint masters in that - a library - should output as much device independent PS as posible, - so disabling - duplex printing for default is a good idea. - - ChangeLog | 6 ++++++ - qt4/src/poppler-document.cc | 2 +- - 2 files changed, 7 insertions(+), 1 deletion(-) - -commit edc0499644b8083600ced9a5087ec0b0189e615b -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Jul 24 19:49:51 2006 +0000 - - 2006-07-24 Kristian Høgsberg <krh@redhat.com> - - * configure.ac: - * poppler/Makefile.am: Move fontconfig dependency to libpoppler. - - ChangeLog | 5 +++++ - configure.ac | 18 +++++++----------- - poppler/Makefile.am | 6 ++++-- - 3 files changed, 16 insertions(+), 13 deletions(-) - -commit 24b5a68a3f4cdba63fbcd01dc178a330b5f604a7 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Tue Jul 18 21:32:11 2006 +0000 - - 2006-07-18 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/Gfx.cc: fix opCloseStroke to match the behaviour of - a separate opClose and opStroke. Previously, opCloseStroke only - closes if there is a path however opClose closes unconditionally. - - ChangeLog | 6 ++++++ - poppler/Gfx.cc | 2 +- - 2 files changed, 7 insertions(+), 1 deletion(-) - -commit c57ebd40fcf85432b2e5045086d158a63af12525 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Tue Jul 18 21:26:57 2006 +0000 - - 2006-07-18 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/TextOutputDev.cc: call setDefaultCTM() after start page - like in Gfx.cc. This fixes a regression caused by the fix - to #6948. - - ChangeLog | 5 +++++ - poppler/TextOutputDev.cc | 1 + - 2 files changed, 6 insertions(+) - -commit 640d5d5a9d9e53f3f677eb05f3d18e6bfc74e95a -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jul 16 18:22:23 2006 +0000 - - 2006-07-16 Albert Astals Cid <aacid@kde.org> - - * poppler/GfxState.cc: Do not crash when we can not - parse a GfxImageColorMap - Fixes crash on pdf that can be found at - - ChangeLog | 7 +++++++ - poppler/GfxState.cc | 4 ++++ - qt4/src/Doxyfile | 4 ++-- - 3 files changed, 13 insertions(+), 2 deletions(-) - -commit c6926d1d8ab04468f56f4687cdd3f06af206226b -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jun 28 19:23:52 2006 +0000 - - * poppler/DCTStream.cc: - * poppler/DCTStream.h: Reset jpeg structures on reset. - Fixes crash while printing pdf at - http://bugs.kde.org/attachment.cgi?id=16818&action=view - - ChangeLog | 7 +++++++ - poppler/DCTStream.cc | 25 ++++++++++++++++++------- - poppler/DCTStream.h | 2 ++ - 3 files changed, 27 insertions(+), 7 deletions(-) - -commit 96ac8dec591a0325a822c1f7b7bc7e78b867e3a0 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jun 25 16:59:31 2006 +0000 - - Ask for paper size width and height to pass it to PSOutputDev in - both qt frontends (qt got abi mantained, qt4 changed as you still - have to define UNSTABLE_POPPLER_QT4 to be able of using it, one day - we'll have to think of removing it) - - ChangeLog | 8 ++++++++ - qt/poppler-document.cc | 9 +++++++-- - qt/poppler-qt.h | 9 +++++++++ - qt4/src/poppler-document.cc | 4 ++-- - qt4/src/poppler-qt4.h | 10 +++++++++- - 5 files changed, 35 insertions(+), 5 deletions(-) - -commit 965011f2001fb1ea36857995d5555266f82b8d96 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jun 25 16:20:50 2006 +0000 - - put back a change that was not meant to be commited - - qt/poppler-qt.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 4995d09c91173d34a435112828aff21a63b147e9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jun 25 16:19:32 2006 +0000 - - rename poppler-link.h to poppler-link-qt3.h to not get conflicts - on install - - qt/Makefile.am | 2 +- - qt/poppler-link-qt3.h | 188 ++++++++++++++++++++++++++++++++++++ - qt/poppler-link.cc | 258 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - qt/poppler-qt.h | 4 +- - 4 files changed, 449 insertions(+), 3 deletions(-) - -commit 087921b134c2646e6d41960f471a1819c7c8790a -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jun 25 10:29:22 2006 +0000 - - add link support to qt3 frontend. - Patch by Wilfried Huss based on Qt4 code - - ChangeLog | 11 ++++ - qt/Makefile.am | 4 +- - qt/poppler-document.cc | 19 ++++--- - qt/poppler-page.cc | 136 - ++++++++++++++++++++++++++++++++++++++++++++++--- - qt/poppler-private.h | 33 +++++++++++- - qt/poppler-qt.h | 14 +++-- - 6 files changed, 196 insertions(+), 21 deletions(-) - -commit 831bd8942ef3224354b128d5e14e68fdfc57168b -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jun 11 16:14:32 2006 +0000 - - optimization by Mario Teijeiro Otero - - poppler/UGooString.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 1223fd4b200f6c13996f8299f3563c818af0c21d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Jun 10 22:23:19 2006 +0000 - - * poppler/UGooString.cc: When any of the chars that we - are passing to the UGooString is not pdfencodable, do not - encode the string, because we loose information if we do, - this fixes rendering of - http://publikationen.ub.uni-frankfurt.de/volltexte/2005/890/pdf/TR_abs_g.pdf - and other docs with type3 fonts and ligatures - - ChangeLog | 9 +++++++++ - poppler/UGooString.cc | 8 ++++++++ - 2 files changed, 17 insertions(+) - -commit b85a39ddfc7de8c0621e995c114885ecd08fcdc2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jun 1 21:03:38 2006 +0000 - - * qt4/src/poppler-qt4.h: - * qt4/src/poppler-page.cc: Add Rotation parameter that - is passed - to the respective output devs - - ChangeLog | 6 ++++++ - qt4/src/poppler-page.cc | 22 ++++++++++++++-------- - qt4/src/poppler-qt4.h | 14 +++++++++----- - 3 files changed, 29 insertions(+), 13 deletions(-) - -commit 2b5d3277f36864ff1ef44f1942f22de247d67ab6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jun 1 17:23:45 2006 +0000 - - * qt/poppler-document.cc: - * qt/poppler-qt.h: Add printing support, patch by - Stefan Kebekus <stefan.kebekus@math.uni-koeln.de> - - ChangeLog | 6 ++++++ - qt/poppler-document.cc | 18 ++++++++++++++++++ - qt/poppler-qt.h | 2 ++ - 3 files changed, 26 insertions(+) - -commit 5380d005b7b54cc6587ce6e8c3bbb358da5cd9a5 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Thu Jun 1 06:42:25 2006 +0000 - - 2006-06-01 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/PSOutputDev.cc: - * poppler/PSOutputDev.h: Change filename parameter to PSOutputDev - constructor from char * to const char *. - - ChangeLog | 6 ++++++ - poppler/PSOutputDev.cc | 2 +- - poppler/PSOutputDev.h | 2 +- - 3 files changed, 8 insertions(+), 2 deletions(-) - -commit c2a81ea8b01f3943a2eb737cf957acc0d05f7eed -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed May 31 20:14:04 2006 +0000 - - * poppler/SplashOutputDev.cc: - * splash/Splash.cc: Fix no splashModeRGB8Qt mode, that is, - make it - show images - - I'm sorry, really, i'll try to do better - - ChangeLog | 6 ++++++ - poppler/SplashOutputDev.cc | 10 ++++++++++ - splash/Splash.cc | 3 +++ - 3 files changed, 19 insertions(+) - -commit 643b310cf51474b6dfc077fe086ea121e807f6e1 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed May 31 19:18:28 2006 +0000 - - 2006-05-31 Jeff Muizelaar <jeff@infidigm.net> - - * TODO: Remove items's from my list that are done. - - ChangeLog | 4 ++++ - TODO | 3 --- - 2 files changed, 4 insertions(+), 3 deletions(-) - -commit 96e582721dcb15ea258b989c7c500084bff9f56d -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed May 31 17:31:49 2006 +0000 - - 2006-05-31 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: - * poppler/CairoOutputDev.h: Change the cairo backend to use the - transformation in cairo instead of doing all of the - transformations in - the OutputDevice. Fixes #6948. - - ChangeLog | 7 ++ - poppler/CairoOutputDev.cc | 200 - ++++++++++++++++++++-------------------------- - poppler/CairoOutputDev.h | 1 + - 3 files changed, 96 insertions(+), 112 deletions(-) - -commit 00ffb9bf50b6b3b2e8eaa8af593aaa01d4a62a34 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed May 31 04:53:27 2006 +0000 - - 2006-05-31 Kristian Høgsberg <krh@redhat.com> - - * NEWS: Sum up changes. - - * configure.ac: Bump release to 0.5.3. - - ChangeLog | 6 ++++++ - NEWS | 8 ++++++++ - configure.ac | 2 +- - 3 files changed, 15 insertions(+), 1 deletion(-) - -commit 223a4bf3a679f666b6c963a8787cf5b5ac75c4b6 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed May 31 02:02:54 2006 +0000 - - 2006-05-30 Kristian Høgsberg <krh@redhat.com> - - * poppler-glib.pc.in: - * configure.ac: Add poppler as a private requires if pkg-config - supports it. - - ChangeLog | 6 ++++++ - configure.ac | 11 +++++++++++ - poppler-glib.pc.in | 3 ++- - 3 files changed, 19 insertions(+), 1 deletion(-) - -commit 7aaa4d3fbdb8ea2534d3cb80e68b2759b2e8fd2f -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue May 30 21:46:06 2006 +0000 - - 2006-05-30 Kristian Høgsberg <krh@redhat.com> - - * test/gtk-cairo-test.cc: Add --page option to gtk-cairo-test. - - ChangeLog | 4 ++++ - test/gtk-cairo-test.cc | 21 ++++++++++++++++++--- - 2 files changed, 22 insertions(+), 3 deletions(-) - -commit f7c1d519b9695ad8adfdcf3af696de746cdcf375 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Mon May 29 18:44:17 2006 +0000 - - 2006-05-29 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoFontEngine.cc: - * poppler/CairoFontEngine.h: - * poppler/CairoOutputDev.cc: Allow CairoFont creation to fail more - gracefully. Fixes #4030. - - ChangeLog | 7 +++++++ - poppler/CairoFontEngine.cc | 27 +++++++++++++++++++++------ - poppler/CairoFontEngine.h | 4 +++- - poppler/CairoOutputDev.cc | 5 +++++ - 4 files changed, 36 insertions(+), 7 deletions(-) - -commit 84861800dad3649d4757d5c5539b9e86e2b2c644 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sat May 27 17:27:37 2006 +0000 - - 2006-05-27 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: - * poppler/CairoOutputDev.h: Back out the rest of krh's type3 - font work. This fixes type3 fonts in CairoOutputDevice. - - ChangeLog | 6 ++++++ - poppler/CairoOutputDev.cc | 3 +++ - poppler/CairoOutputDev.h | 2 +- - 3 files changed, 10 insertions(+), 1 deletion(-) - -commit 6f5a89a0a2cf17d45d1c31ce105829be8c7ac456 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue May 23 20:49:16 2006 +0000 - - * poppler/SplashOutputDev.cc: - * qt4/src/poppler-private.h: - * splash/Splash.cc: - * splash/SplashBitmap.cc: - * splash/SplashTypes.h: bring splashModeRGB8 back to the - old code - (before Frank's patch), create splashModeRGB8Qt that has - Frank's - codepath and is used by Qt frontends. Fixes corruption on - other programs expecting the old behaviour. - - Remember dude we are now a lib! you can not change behaviour from - one day to another! - - /me hits himself - - ChangeLog | 11 +++ - poppler/SplashOutputDev.cc | 8 +++ - qt/poppler-private.h | 2 +- - qt4/src/poppler-private.h | 2 +- - splash/Splash.cc | 169 - +++++++++++++++++++++++++++++++++++++++++++++ - splash/SplashBitmap.cc | 26 ++++++- - splash/SplashTypes.h | 2 + - 7 files changed, 216 insertions(+), 4 deletions(-) - -commit 495d592c3ba7fe81e03774f5b2ed677e5aa560c7 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue May 23 19:16:37 2006 +0000 - - 2006-05-23 Kristian Høgsberg <krh@redhat.com> - - * qt4/src/Makefile.am (libpoppler_qt4_la_SOURCES): Add missing - - ChangeLog | 5 +++++ - qt4/src/Makefile.am | 1 + - 2 files changed, 6 insertions(+) - -commit eecd06c86585bca05c99cd2e9a1b1ff3bbae3c72 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon May 22 20:19:35 2006 +0000 - - 2006-05-22 Kristian Høgsberg <krh@redhat.com> - - * configure.ac: Bump release. - * NEWS: Sum up changes. - - ChangeLog | 5 +++++ - NEWS | 11 ++++++++++- - configure.ac | 2 +- - 3 files changed, 16 insertions(+), 2 deletions(-) - -commit 680f20dfd1cf0342d49516b3848a2aef5d2a3883 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon May 22 19:58:41 2006 +0000 - - 2006-05-22 Kristian Høgsberg <krh@redhat.com> - - Patch from Rainer Keller to fix the ImageOutputDev (#6984). - - * utils/ImageOutputDev.cc (drawImage): Upate to work with new - 16-bit color representation. - - * utils/ImageOutputDev.h: Return gTrue for needNonText(). - - ChangeLog | 9 +++++++++ - NEWS | 4 ++++ - utils/ImageOutputDev.cc | 6 +++--- - utils/ImageOutputDev.h | 2 +- - 4 files changed, 17 insertions(+), 4 deletions(-) - -commit e43a06bf6e953fa9af18476e2c9f27106398c09c -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sun May 21 23:26:45 2006 +0000 - - 2006-05-21 Kristian Høgsberg <krh@redhat.com> - - * poppler/CairoFontEngine.cc: - * poppler/CairoFontEngine.h: Back out type3 font work committed by - accident. - - ChangeLog | 6 + - poppler/CairoFontEngine.cc | 347 - +++++---------------------------------------- - poppler/CairoFontEngine.h | 17 +-- - 3 files changed, 47 insertions(+), 323 deletions(-) - -commit 7d4bb0533f88f06449ebd64c1220d0b75001937d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun May 21 18:14:15 2006 +0000 - - fix all is blue issue on ppc machines - - ChangeLog | 7 +++++++ - qt/poppler-page.cc | 17 +++++++++++++++++ - qt4/src/poppler-page.cc | 17 +++++++++++++++++ - 3 files changed, 41 insertions(+) - -commit 655af1e0126ca96d75c9c718d7d8f928c898b1f6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun May 21 17:19:53 2006 +0000 - - hope to fix really Kouhei's name now - - ChangeLog | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -commit cc783a1ebe868ff75db5472775dabe0020ae501f -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun May 21 11:54:30 2006 +0000 - - Fix Kouhei name - - ChangeLog | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit e4b6ad3bb873a6f334934921e6d56e9d26e06a9a -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri May 19 22:55:49 2006 +0000 - - Add bug number to ChangeLog entry. - - ChangeLog | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 46f5f070cceb2c0f3b53537c8e33340b9f1bba38 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri May 19 22:26:03 2006 +0000 - - 2006-05-19 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-action.h: - * glib/poppler-action.cc: Add poppler_dest_get_type(), patch from - Kouhei Souto (#6907). - - ChangeLog | 4 ++++ - glib/poppler-action.cc | 13 +++++++++++++ - glib/poppler-action.h | 4 ++++ - 3 files changed, 21 insertions(+) - -commit 875dc5b112dfe2d4a48a7567b1ff79257447cc0d -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri May 19 22:21:35 2006 +0000 - - 2006-05-19 Kristian Høgsberg <krh@redhat.com> - - * poppler-glib.pc.in (Requires): Add gdk-2.0 dependency, from - Kouhei Souto (#6896). - - ChangeLog | 3 +++ - poppler-glib.pc.in | 2 +- - 2 files changed, 4 insertions(+), 1 deletion(-) - -commit b66dda2640c088bbe205f698a0c4028144027922 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri May 19 22:19:21 2006 +0000 - - 2006-05-19 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-document.h (POPPLER_TYPE_INDEX_ITER) - (POPPLER_TYPE_FONTS_ITER): Add these macros, patch from Kouhei - Souto (#6897). - - ChangeLog | 4 ++++ - glib/poppler-document.h | 2 ++ - 2 files changed, 6 insertions(+) - -commit 095730456c0d8312067af10dd55a3b9165a83736 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri May 19 22:16:25 2006 +0000 - - 2006-05-19 Kristian Høgsberg <krh@redhat.com> - - * glib/Makefile.am (INCLUDES): Add define for G_LOG_DOMAIN, from - Kouhei Souto (#6899). - - ChangeLog | 3 +++ - glib/Makefile.am | 1 + - 2 files changed, 4 insertions(+) - -commit b8d77633899c1dec5f3b9c9a0f075f39afa98965 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri May 19 22:12:38 2006 +0000 - - 2006-05-19 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-document.cc (poppler_document_save): Memleak patch - from Paolo Borelli (#6908). - - ChangeLog | 5 +++++ - glib/poppler-document.cc | 2 ++ - 2 files changed, 7 insertions(+) - -commit 488f77298fee9eebbca5983c1c9fb186b3b67aa3 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri May 19 22:04:17 2006 +0000 - - 2006-05-19 Kristian Høgsberg <krh@redhat.com> - - * TextOutputDev.h: - * TextOutputDev.cc: - * UnicodeTypeTable.h: - * UnicodeTypeTable.cc: - * UnicodeCClassTables.h: - * UnicodeCompTables.h: - * UnicodeDecompTables.h: - * gen-unicode-tables.py: Patch from Ed Catmur (#2929) to convert - search string and document text to unicode NFKC (compatibility - composition) before matching so ligatures match correctly. - - ChangeLog | 13 + - poppler/Makefile.am | 5 + - poppler/TextOutputDev.cc | 41 +- - poppler/TextOutputDev.h | 3 + - poppler/UnicodeCClassTables.h | 1827 +++++++++ - poppler/UnicodeCompTables.h | 665 ++++ - poppler/UnicodeDecompTables.h | 8526 - +++++++++++++++++++++++++++++++++++++++++ - poppler/UnicodeTypeTable.cc | 235 ++ - poppler/UnicodeTypeTable.h | 3 + - 9 files changed, 11303 insertions(+), 15 deletions(-) - -commit ecb942e54a1ab0f7eded91b7d1278f0ac62e2071 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri May 19 21:42:54 2006 +0000 - - 2006-05-19 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc (poppler_page_prepare_output_dev): Fix the - rotation bug for real. - - ChangeLog | 5 +++++ - glib/poppler-page.cc | 16 +++++++++------- - 2 files changed, 14 insertions(+), 7 deletions(-) - -commit 28ae789afe0625a641525e4a0768d51fa8bd667c -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri May 19 20:54:13 2006 +0000 - - 2006-05-19 Kristian Høgsberg <krh@redhat.com> - - Patch from Kouhei Sutou (#6905). - - * glib/poppler-document.cc: - * glib/poppler-document.h: - * glib/poppler-private.h: - * glib/reference/tmpl/poppler-private.sgml: - * glib/reference/tmpl/poppler.sgml: Make PopplerPSOutput a proper - glib object. - - ChangeLog | 11 +++++++ - glib/poppler-document.cc | 51 - ++++++++++++++++++++++++++------ - glib/poppler-document.h | 4 +++ - glib/poppler-private.h | 2 ++ - glib/reference/tmpl/poppler-private.sgml | 1 + - glib/reference/tmpl/poppler.sgml | 1 + - 6 files changed, 61 insertions(+), 9 deletions(-) - -commit 02cf7fd7df0b2d8c2b1c6f108e581bc1c7a973b1 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri May 19 20:35:43 2006 +0000 - - 2006-05-19 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc (poppler_page_prepare_output_dev): Fix - rotation bug (#6913, #6926). - - ChangeLog | 3 +++ - glib/poppler-page.cc | 12 +++++++++++- - 2 files changed, 14 insertions(+), 1 deletion(-) - -commit 78ae3efd9541d7b63ff5a2c4de3fde300806688f -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri May 19 19:21:59 2006 +0000 - - 2006-05-19 Kristian Høgsberg <krh@redhat.com> - - Memory leak patch from Carlos Garcia Campos (#6947). - - * glib/poppler-action.cc: - * glib/poppler-document.cc: - * glib/poppler-page.cc: - * poppler/CairoFontEngine.cc: - * poppler/CairoFontEngine.h: - * poppler/CairoOutputDev.cc: - * poppler/CairoOutputDev.h: - * poppler/Gfx.cc: - * poppler/TextOutputDev.cc: Fix various memory leaks. - - ChangeLog | 14 ++ - glib/poppler-action.cc | 9 +- - glib/poppler-document.cc | 31 +++- - glib/poppler-page.cc | 2 + - poppler/CairoFontEngine.cc | 347 - ++++++++++++++++++++++++++++++++++++++++----- - poppler/CairoFontEngine.h | 17 ++- - poppler/CairoOutputDev.cc | 5 +- - poppler/CairoOutputDev.h | 2 +- - poppler/Gfx.cc | 1 + - poppler/TextOutputDev.cc | 9 ++ - 10 files changed, 381 insertions(+), 56 deletions(-) - -commit 354c1926b7181fd668f221e1d672974e04fda747 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri May 19 17:24:19 2006 +0000 - - * qt4/src/poppler-link.cc: Patch by Pino Toscano, ensure the - splashoutput is created when parsing the TOC. - - ChangeLog | 5 +++++ - qt4/src/poppler-link.cc | 5 +++-- - 2 files changed, 8 insertions(+), 2 deletions(-) - -commit 3c9a5f37704781c9a51e72edd18451870452b9a7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun May 14 16:11:54 2006 +0000 - - * poppler/FontInfo.cc: Fix possible crash, half patch - by Kouhei Sutou <kou@cozmixng.org> - - ChangeLog | 5 +++++ - poppler/FontInfo.cc | 4 ++-- - 2 files changed, 7 insertions(+), 2 deletions(-) - -commit 436f578fe762e8ceccce95a0f2003406527dde64 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat May 13 16:01:57 2006 +0000 - - * poppler/GfxState.cc: - * poppler/GfxState.h: Fix memleak, patch by - Carlos Garcia Campos <carlosgc@gnome.org> - - ChangeLog | 6 ++++++ - poppler/GfxState.cc | 8 ++++++++ - poppler/GfxState.h | 3 +-- - 3 files changed, 15 insertions(+), 2 deletions(-) - -commit 906515769097f2e38f6b2c2aff598919b9d1ee0d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat May 13 15:58:37 2006 +0000 - - * qt4/src/poppler-document.cc: leak-- - * qt4/src/poppler-private.h: Refcount globalparams - * qt4/tests/test-poppler-qt4.cpp: Some leaks less - - ChangeLog | 6 ++++++ - qt4/src/poppler-document.cc | 10 +++++----- - qt4/src/poppler-private.h | 8 ++++++++ - qt4/tests/test-poppler-qt4.cpp | 6 ++++-- - 4 files changed, 23 insertions(+), 7 deletions(-) - -commit 46fd63c44369c882d8dac473d4156001d9d4ed18 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat May 13 11:14:24 2006 +0000 - - numbers for easier casting - - qt4/src/poppler-link.h | 14 ++++++++++++-- - 1 file changed, 12 insertions(+), 2 deletions(-) - -commit 35500375e3f790c444ab7e7d0a687d270c5a66b1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri May 12 21:02:01 2006 +0000 - - fixing compile problems for some people - - qt4/src/poppler-page.cc | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit 181f09829cf4831965059e3064114d83348c51b5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri May 12 20:40:05 2006 +0000 - - * qt4/src/Makefile.am - * qt4/src/poppler-annotation-helper.h - * qt4/src/poppler-annotation.cc - * qt4/src/poppler-annotation.h - * qt4/src/poppler-link.cc - * qt4/src/poppler-link.h - * qt4/src/poppler-page.cc - * qt4/src/poppler-qt4.h: Code for annotations stripped - from oKular, - it's all based on Enrico's work, so ask him for details, - the problem - is that he left KDE development a while ago. - - ChangeLog | 14 + - qt4/src/Makefile.am | 2 + - qt4/src/poppler-annotation-helper.h | 213 ++++++++++ - qt4/src/poppler-annotation.cc | 792 - ++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-annotation.h | 257 ++++++++++++ - qt4/src/poppler-link.cc | 4 +- - qt4/src/poppler-link.h | 2 +- - qt4/src/poppler-page.cc | 691 +++++++++++++++++++++++++++++++ - qt4/src/poppler-qt4.h | 8 +- - 9 files changed, 1980 insertions(+), 3 deletions(-) - -commit 3a48e89dfbe54af73a68ed8e917938f14ad17f01 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue May 9 20:07:06 2006 +0000 - - * qt4/src/Makefile.am: - * qt4/src/poppler-document.cc: - * qt4/src/poppler-link.cc: - * qt4/src/poppler-page.cc: - * qt4/src/poppler-private.h: - * qt4/src/poppler-qt4.h: Adding links extraction code, - should work as - it is basically stripped out from kpdf, but comments are - obviously welcome as always - - ChangeLog | 10 +++ - qt4/src/Makefile.am | 1 + - qt4/src/poppler-document.cc | 13 +--- - qt4/src/poppler-link.cc | 129 ++++++++++++++++++++++++++++++-- - qt4/src/poppler-link.h | 178 - ++++++++++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-page.cc | 139 ++++++++++++++++++++++++++++++---- - qt4/src/poppler-private.h | 9 ++- - qt4/src/poppler-qt4.h | 56 +++----------- - 8 files changed, 456 insertions(+), 79 deletions(-) - -commit f628e1506e576a8553a9699c1d7f05ef55c24fa2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon May 8 19:03:51 2006 +0000 - - memleak-- by carlos - - ChangeLog | 5 +++++ - poppler/Catalog.cc | 5 ++++- - 2 files changed, 9 insertions(+), 1 deletion(-) - -commit 1fce6266564583d356817a21f43c6b1ad8ce3716 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat May 6 10:57:07 2006 +0000 - - fix code, i suck - - qt4/src/poppler-page.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit be913b90d59da35a347498b86fdd3edb065aef23 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri May 5 20:51:01 2006 +0000 - - * poppler/Function.cc: quick fix for KDE bug #126760 - - Better solutions are of course accepted - - ChangeLog | 4 ++++ - poppler/Function.cc | 2 +- - 2 files changed, 5 insertions(+), 1 deletion(-) - -commit 2b085293bd73b4e77da848b3fe63a7e82e9ba5e5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu May 4 19:10:55 2006 +0000 - - * qt4/src/poppler-qt4.h: - * qt4/src/poppler-page.cc: Implement search functionality - - more code to make oKular qt4popplered possible, probably not most - quickest code around, feel free to comment/optimize - - ChangeLog | 5 +++++ - qt4/src/poppler-page.cc | 43 +++++++++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-qt4.h | 16 ++++++++++++++++ - 3 files changed, 64 insertions(+) - -commit a9b0c7977aba7bc85a8673c7f95187ff17ee4173 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue May 2 04:38:39 2006 +0000 - - 2006-05-02 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc: - * poppler/Gfx.cc: - * poppler/GfxFont.cc: - * poppler/GfxFont.h: - * poppler/GfxState.cc: - * poppler/TextOutputDev.cc: Patch from Gary Coady to add reference - counting to GfxFont so we don't crash on text selection. - - ChangeLog | 10 ++++++++++ - glib/poppler-page.cc | 2 +- - poppler/Gfx.cc | 2 ++ - poppler/GfxFont.cc | 14 +++++++++++++- - poppler/GfxFont.h | 4 ++++ - poppler/GfxState.cc | 7 +++++++ - poppler/TextOutputDev.cc | 1 + - 7 files changed, 38 insertions(+), 2 deletions(-) - -commit 57af0207334ff1a407899370281ebb90fe953a32 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon May 1 18:33:47 2006 +0000 - - * qt4/src/poppler-page.cc: - * qt4/src/poppler-private.h: - * qt4/src/poppler-qt4.h: - * qt4/src/poppler-textbox.cc: Add nextWord(), hasSpaceAfter() - and - edge() to TextBox - - More things to make poppler-qt4Okular nearer - - ChangeLog | 8 ++++++++ - qt4/src/poppler-page.cc | 14 ++++++++++++++ - qt4/src/poppler-private.h | 11 +++++++++++ - qt4/src/poppler-qt4.h | 8 ++++++++ - qt4/src/poppler-textbox.cc | 23 ++++++++++++++++------- - 5 files changed, 57 insertions(+), 7 deletions(-) - -commit 61b126390f764fd38c79b6a64160a7dc7870bd4a -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon May 1 13:41:14 2006 +0000 - - revert thing that should not have gone in - - poppler/PageLabelInfo.cc | 43 +++++++++++++++++++++++++++++++++++++++++++ - poppler/PageLabelInfo.h | 44 - -------------------------------------------- - 2 files changed, 43 insertions(+), 44 deletions(-) - -commit f2424ef63e86d82b2be277e2b268b48aae29601e -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon May 1 13:32:31 2006 +0000 - - * qt4/src/poppler-document.cc: - * qt4/src/poppler-private.h: - * qt4/src/poppler-qt4.h: Add the possibility of setting - the paper - color - - One step more to make oKular fully use the qt4 bindings - - ChangeLog | 7 +++++++ - poppler/PageLabelInfo.cc | 43 - ------------------------------------------- - poppler/PageLabelInfo.h | 44 - ++++++++++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-document.cc | 10 ++++++++++ - qt4/src/poppler-private.h | 22 +++++++++++++++++----- - qt4/src/poppler-qt4.h | 6 ++++++ - 6 files changed, 84 insertions(+), 48 deletions(-) - -commit 4147400e2b692df7f70c3772e8a4b576d4d85294 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 29 15:23:41 2006 +0000 - - Fix memory leak. Bug 6765 - - ChangeLog | 5 +++++ - poppler/JBIG2Stream.cc | 1 + - 2 files changed, 6 insertions(+) - -commit 960d60467d62d28f20b127d07e8de1af42eec568 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Thu Apr 27 17:26:36 2006 +0000 - - 2006-04-27 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: delete imgStr if some of the cairo - functions fail. Fixes coverty reports #2106, #2107, #2077 and - bug #6764. Patch by Kjartan Maraas. - - ChangeLog | 6 ++++++ - poppler/CairoOutputDev.cc | 34 +++++++++++++++++++++++++--------- - 2 files changed, 31 insertions(+), 9 deletions(-) - -commit 155112131c6e25bfde752cf5daa80a6c9712cfed -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Apr 23 15:50:52 2006 +0000 - - qt4/src/poppler-private.h: Protect us against a link not having - a destination or a namedDestination - - ChangeLog | 5 +++++ - qt4/src/poppler-private.h | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit c902a3a22bcceedc8ee8ca377064efcc8a9178ca -Author: Brad Hards <bradh@frogmouth.net> -Date: Fri Apr 21 12:02:19 2006 +0000 - - Add another path to search for Qt4 libs and includes. - - CCMAIL: montel@kde.org - - m4/qt.m4 | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -commit 18f8e1f1d213dbcda27cd0ec429273801f65e208 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 18 19:11:56 2006 +0000 - - * goo/GooVector.h: Fix typo that was preventing build with MSVC8 - Discovered by Reece Dunn <msclrhd@hotmail.com> - - ChangeLog | 5 +++++ - goo/GooVector.h | 4 ++-- - 2 files changed, 7 insertions(+), 2 deletions(-) - -commit cbbb28a5959343d20dffe945ea83272c0b2e287b -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sun Apr 16 22:59:44 2006 +0000 - - 2006-04-16 Carlos Garcia Campos <carlosgc@gnome.org> - - * glib/poppler-action.cc: - * glib/poppler-action.h: - * glib/poppler-private.h: - * glib/poppler.h: - Add support for named destinations and named actions. - - * glib/poppler-document.cc: - * glib/poppler-document.h: - Allow to find named destinations in document. - - ChangeLog | 12 +++ - glib/poppler-action.cc | 152 - +++++++++++++++++++++++++----- - glib/poppler-action.h | 7 +- - glib/poppler-document.cc | 37 ++++++++ - glib/poppler-document.h | 4 +- - glib/poppler-private.h | 2 + - glib/poppler.h | 1 + - glib/reference/tmpl/poppler-action.sgml | 2 + - glib/reference/tmpl/poppler-document.sgml | 4 - - 9 files changed, 189 insertions(+), 32 deletions(-) - -commit 85687a1e0e4c6be2dbfb23ba00018b9c7c7454f5 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed Apr 12 06:52:07 2006 +0000 - - 2006-04-12 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: - * poppler/CairoOutputDev.h: Add support for masked images to - the cairo - backend. CairoOutputDevice really should have been refactored - before - committing this, but the results were so pretty I couldn't resist. - Fixes #6174. - - ChangeLog | 8 ++++ - poppler/CairoOutputDev.cc | 118 - ++++++++++++++++++++++++++++++++++++++++++++++ - poppler/CairoOutputDev.h | 8 ++++ - 3 files changed, 134 insertions(+) - -commit 6039d4fc65cb25bef20efa29bc29d42086fc0854 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed Apr 12 05:46:44 2006 +0000 - - 2006-04-12 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: Fix breakage by krh by only calling - cairo_destroy on non-null. - - ChangeLog | 5 +++++ - poppler/CairoOutputDev.cc | 4 +++- - 2 files changed, 8 insertions(+), 1 deletion(-) - -commit d839a0bd78361930e5e2fe889df12e1e853ffed3 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed Apr 12 02:07:07 2006 +0000 - - 2006-04-11 Kristian Høgsberg <krh@redhat.com> - - * configure.ac: - * poppler-glib.pc.in: - * glib/Makefile.am: - * glib/poppler-page.cc: - * glib/poppler-page.h: - * glib/poppler.h: - * poppler/CairoOutputDev.cc: - * poppler/CairoOutputDev.h: - * glib/poppler-features.h.in: - Make the CairoOutputDev render to a cairo_t instead of a - cairo_surface_t and expose that functionality in the glib wrapper - (poppler_page_render). - - * test/Makefile.am: - * test/gtk-cairo-test.cc: - Update gtk-cairo-test to use this new interface and add a spin - button for changing page (#5951). - - * utils/Makefile.am (EXTRA_DIST): Fix warning where this was - assigned twice. - - ChangeLog | 23 ++++ - configure.ac | 8 ++ - glib/Makefile.am | 10 +- - glib/poppler-features.h.in | 24 ++++ - glib/poppler-page.cc | 63 +++++++--- - glib/poppler-page.h | 10 ++ - glib/poppler.h | 1 + - poppler-glib.pc.in | 2 +- - poppler/CairoOutputDev.cc | 23 ++-- - poppler/CairoOutputDev.h | 6 +- - test/Makefile.am | 4 +- - test/gtk-cairo-test.cc | 286 - ++++++++++++++------------------------------- - utils/Makefile.am | 6 +- - 13 files changed, 221 insertions(+), 245 deletions(-) - -commit b198c9801c668014c0979c57033a0637e7e046e2 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Mon Apr 10 18:12:44 2006 +0000 - - 2006-04-10 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: take originX and originY into - account in - drawChar() to draw vertical text properly. Fixes #6551. - - ChangeLog | 5 +++++ - poppler/CairoOutputDev.cc | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit fd251f52efc7748fda91cc77fb9d3966e0f02ac8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Apr 9 11:05:51 2006 +0000 - - m4/qt.m4: Improve for systems that need -pthread to be linked when - linking Qt. Patch by Diego Pettenò - - ChangeLog | 5 +++++ - m4/qt.m4 | 28 +++++++++++++++++++++++++++- - 2 files changed, 32 insertions(+), 1 deletion(-) - -commit 36de9747153a2ea9b3cf86c41e75a521441a2e06 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 8 10:44:43 2006 +0000 - - * poppler/Makefile.am: - * qt4/src/Makefile.am: Don't link Qt4 in libpoppler when using - Qt4 frontend - Patch by Stefan Schweizer - - ChangeLog | 6 ++++++ - poppler/Makefile.am | 11 +++++------ - qt4/src/Makefile.am | 1 + - 3 files changed, 12 insertions(+), 6 deletions(-) - -commit bf7afe161d76c50fd1c480eb236607145782e59d -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Apr 5 18:20:56 2006 +0000 - - poppler/JBIG2Stream.cc: Fix for some buggy JBIG2 documents, patch - by Raj Kumar and Paul Walmsley. Fixes bug 6500 - - ChangeLog | 5 +++++ - poppler/JBIG2Stream.cc | 43 +++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 48 insertions(+) - -commit 315f8e488d3db848f88a06c7568b6583bbf0e432 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed Apr 5 17:20:56 2006 +0000 - - 2006-04-05 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: use a separate matrix for the - softmask. - fixes #6492. - - ChangeLog | 5 +++++ - poppler/CairoOutputDev.cc | 11 ++++++++++- - 2 files changed, 15 insertions(+), 1 deletion(-) - -commit 0d311518f678a479c1efeaec15011e0a34de80fc -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 4 21:01:01 2006 +0000 - - * splash/Splash.cc: - * splash/SplashBitmap.cc: Make Splashbitmap RGB8 use 32bits - internally - * qt/poppler-page.cc: - * qt4/src/poppler-page.cc: Adapt to splashbitmap change so - copying to - QImage is faster. - Patch by Frank Meerkötter slightly modified by Albert - Astals Cid - - I'll leave adapting the glib frontend for you guys, i tried to adapt - it but i got lost at gdk_pixbuf_get_n_channels (pixbuf); - - ChangeLog | 9 ++++++ - qt/poppler-page.cc | 18 ++++------- - qt4/src/poppler-page.cc | 15 ++++----- - splash/Splash.cc | 81 - +++++++++++++++++++++++++------------------------ - splash/SplashBitmap.cc | 10 +++--- - 5 files changed, 67 insertions(+), 66 deletions(-) - -commit 888bd41b42507f0a1af55c55495d31d802ce7706 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Apr 4 20:42:08 2006 +0000 - - Fix crash when using fixedpoint math. Patch by Frank Meerkoetter - - ChangeLog | 5 +++++ - splash/SplashFTFont.cc | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit 56c98450160b639790931226a045ce4712e7d45e -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Apr 2 18:07:59 2006 +0000 - - Improvements to the Qt4 frontend, comments welcome - - ChangeLog | 7 +++ - m4/qt.m4 | 4 +- - qt4/src/Makefile.am | 1 + - qt4/src/poppler-document.cc | 85 +++++++++++++++++++++------ - qt4/src/poppler-link.cc | 138 - ++++++++++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-page.cc | 9 ++- - qt4/src/poppler-private.h | 95 +++++++++++++++++++++++++++++- - qt4/src/poppler-qt4.h | 86 ++++++++++++++++++++++++--- - 8 files changed, 395 insertions(+), 30 deletions(-) - -commit c80ebf237e9c6232a1d0567a2688a294acfd481b -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Apr 1 11:25:57 2006 +0000 - - Fix bug 6454 - - ChangeLog | 5 +++++ - poppler/XRef.cc | 22 +++++++++++++--------- - 2 files changed, 18 insertions(+), 9 deletions(-) - -commit fe8142fbc12127682b8024673fe1af57b47bb5c9 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Tue Mar 21 04:25:53 2006 +0000 - - 2006-03-20 Jeff Muizelaar <jeff@infidigm.net> - - * glib/poppler-page.cc: Avoid strdup in poppler_page_get_property - and - make code cleaner. Combined with the memleak fix closes #6187. - Patch by chpe. - - ChangeLog | 6 ++++++ - glib/poppler-page.cc | 5 +---- - 2 files changed, 7 insertions(+), 4 deletions(-) - -commit 4f961df2e6e91a0dc0a024ae5acdefa394179a05 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Tue Mar 21 04:19:18 2006 +0000 - - 2006-03-20 Jeff Muizelaar <jeff@infidigm.net> - - * glib/poppler-page.cc: Fix memory leak in poppler_page_get_text - Patch by chpe. - - ChangeLog | 5 +++++ - glib/poppler-page.cc | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit ff4febab0a519732972c21bf76d7693c98265e0f -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Mar 20 20:07:36 2006 +0000 - - Use UGooString for dates, fixes KDE bug 123938 - - ChangeLog | 6 ++++++ - qt/poppler-document.cc | 2 +- - qt4/src/poppler-document.cc | 2 +- - 3 files changed, 8 insertions(+), 2 deletions(-) - -commit 75ac6de8cd651b1cbe2d6a7ffa4574097088041f -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Mon Mar 20 19:12:29 2006 +0000 - - 2006-03-20 Carlos Garcia Campos <calosgc@gnome.org> - - reviewed by: Jeff Muizelaar <jeff@infidigm.net> - - * glib/poppler-document.cc: Fix memory leak in - poppler_font_info_free - - ChangeLog | 6 ++++++ - glib/poppler-document.cc | 2 +- - 2 files changed, 7 insertions(+), 1 deletion(-) - -commit 784f6d9a0888dab34c586ffe14db8e55b8a11f51 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Mon Mar 20 19:02:10 2006 +0000 - - 2006-03-20 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoFontEngine.h: remove unused variables - - ChangeLog | 4 ++++ - poppler/CairoFontEngine.h | 1 - - 2 files changed, 4 insertions(+), 1 deletion(-) - -commit 847436779d7c82b428acfd6339130228bfadca24 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Mar 19 19:19:42 2006 +0000 - - fix date - - ChangeLog | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 401bae69cc7ade676cacd89b483f0a93a653c7a1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Mar 19 17:01:05 2006 +0000 - - fix htmloutputdev - - ChangeLog | 4 ++++ - utils/HtmlOutputDev.cc | 2 +- - utils/HtmlOutputDev.h | 2 +- - 3 files changed, 6 insertions(+), 2 deletions(-) - -commit d56330e688c0a40b4e206ed3bbddd06d7f3ee66c -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Mar 16 22:04:56 2006 +0000 - - * poppler/Page.cc: Remove a #ifdef that was never defined - (nice to - have so sucky W args), probably came from gpdf (it's not - on xpdf - sources) and was causing bugs 6079 and 6167 - - Might be worth backporting to the stable branch - - ChangeLog | 8 +++++++- - poppler/Page.cc | 2 -- - 2 files changed, 7 insertions(+), 3 deletions(-) - -commit 7ed6737b00ece7ca00cee1d148752b11700370e6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Mar 16 19:21:11 2006 +0000 - - poppler/FontInfo.cc: Embedded fonts don't have a font file - - ChangeLog | 4 ++++ - poppler/FontInfo.cc | 20 ++++++++++++-------- - 2 files changed, 16 insertions(+), 8 deletions(-) - -commit a34688ee29e1cdfcbaca232cf005af55af87f796 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Mar 14 19:34:10 2006 +0000 - - * qt4/src/poppler-qt4.h: Fix compilation with gcc4.1, patch by - Michael Olbrich - - ChangeLog | 5 +++++ - qt4/src/poppler-qt4.h | 10 +++++----- - 2 files changed, 10 insertions(+), 5 deletions(-) - -commit 1a90b3aaf6be4ca3ebb47e904842b1e14a0e8dfc -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Mar 11 15:19:02 2006 +0000 - - * poppler/FontInfo.cc: - * poppler/FontInfo.h: Add getFile() function that returns - the path of the font that is beign used in the system to - represent that font - * qt4/src/poppler-document.cc: - * qt4/src/poppler-fontinfo.cc: - * qt4/src/poppler-private.h: - * qt4/src/poppler-qt4.h: Add the file() function - * qt4/tests/poppler-fonts.cpp: Show the path of the font - used to represent each font - - May be interesting to have in the other frontends - - ChangeLog | 13 +++++++++++++ - poppler/FontInfo.cc | 10 ++++++++++ - poppler/FontInfo.h | 2 ++ - qt4/src/poppler-document.cc | 14 +------------- - qt4/src/poppler-fontinfo.cc | 29 +++++++++-------------------- - qt4/src/poppler-private.h | 29 +++++++++++++++++++++++++++++ - qt4/src/poppler-qt4.h | 8 ++++++-- - qt4/tests/poppler-fonts.cpp | 5 +++-- - 8 files changed, 73 insertions(+), 37 deletions(-) - -commit 22b1618185ec70895ec644d9e590c266ff98c9db -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Mar 9 21:56:07 2006 +0000 - - Build with cairo disabled, patch by Eduardo de Barros Lima - - ChangeLog | 5 +++++ - glib/Makefile.am | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit 50ecfadab36a9769b09e4c2c1670d86448a0e1ee -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue Feb 28 23:24:59 2006 +0000 - - 2006-02-28 Kristian Høgsberg <krh@redhat.com> - - * configure.ac: Bump release to 0.5.1. - - * NEWS: Sum up 0.5.1 changes so far. - - * TextOutputDev.h: add getters for a couple of attributes. - - * glib/Makefile.am: - * poppler/Makefile.am: Move cairo link dependency to glib - bindings. - - ChangeLog | 11 +++++++++++ - NEWS | 10 ++++++++++ - configure.ac | 2 +- - glib/Makefile.am | 11 ++++++----- - poppler/Makefile.am | 19 ++++++++----------- - poppler/TextOutputDev.h | 7 +++++-- - qt/Makefile.am | 1 + - test/Makefile.am | 16 +++++++++------- - utils/Makefile.am | 29 +++++++++++++++++------------ - 9 files changed, 68 insertions(+), 38 deletions(-) - -commit b9e951ac68b9977ab7217ad0346bcf46a3fa3dfe -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue Feb 28 19:59:58 2006 +0000 - - 2006-02-28 Kristian Høgsberg <krh@redhat.com> - - * goo/gmem.c: (gmalloc), (grealloc): - * poppler/JBIG2Stream.cc: - * poppler/Stream.cc: - * poppler/Stream.h: - * splash/SplashXPathScanner.cc: - - More integer overflow fixes from Derek Noonburg (#5922). - - ChangeLog | 10 ++++++++++ - goo/gmem.c | 9 +++++---- - poppler/JBIG2Stream.cc | 12 ++++++++++-- - poppler/Stream.cc | 7 +++++++ - poppler/Stream.h | 2 +- - 5 files changed, 33 insertions(+), 7 deletions(-) - -commit 46db73a142d65a0c944910388d5971debc06ecbf -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue Feb 28 18:31:59 2006 +0000 - - 2006-02-28 Kristian Høgsberg <krh@redhat.com> - - * poppler/PSOutputDev.cc: Make PSOutputDev constructor respect - passed in paper size (#5946, #5749). - - ChangeLog | 5 +++++ - poppler/PSOutputDev.cc | 14 ++++++++------ - 2 files changed, 13 insertions(+), 6 deletions(-) - -commit 0f7f2182b2abe965b382937f5569b65a8828fc93 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue Feb 28 18:25:00 2006 +0000 - - 2006-02-28 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-document.cc (info_dict_get_string): Refactor - _popper_goo_string_to_utf8() out into it's own function. - - * glib/poppler-page.cc (poppler_page_get_property): Use - _popper_goo_string_to_utf8() here to convert ucs2 page labels. - - * glib/poppler-page.cc (poppler_page_get_selection_region): - Add - braces to fix warning. - - * poppler/PageLabelInfo.cc: If the label prefix string has - a ucs2 - marker, append the number part of the label as ucs2 (#5952). - - ChangeLog | 14 +++ - glib/poppler-document.cc | 52 +++++------ - glib/poppler-page.cc | 23 +++-- - glib/poppler-private.h | 3 + - glib/reference/tmpl/poppler-enums.sgml | 150 - -------------------------------- - glib/reference/tmpl/poppler-unused.sgml | 130 +++++++++++++++++++++++++++ - glib/test-poppler-glib.c | 2 +- - goo/GooString.cc | 5 ++ - goo/GooString.h | 4 + - poppler/PageLabelInfo.cc | 39 ++++++--- - poppler/PageLabelInfo.h | 2 +- - 11 files changed, 228 insertions(+), 196 deletions(-) - -commit 1bf83cdc8b75e1c76956ae643ee273e0b558fd08 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Feb 25 12:30:30 2006 +0000 - - fix warning - - ChangeLog | 4 ++++ - poppler/Object.cc | 3 ++- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit eb5642f396c8772c83b2cf27da437413b692c952 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Feb 23 22:26:05 2006 +0000 - - Don't build pdftoppm when splashoutput is disabled as it does not link - - ChangeLog | 5 +++++ - utils/Makefile.am | 13 +++++++++++-- - 2 files changed, 16 insertions(+), 2 deletions(-) - -commit 7c5c1361045429a429a6f40d936f8c7c01fe0d07 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sat Feb 18 20:17:00 2006 +0000 - - 2006-02-18 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: - * poppler/CairoOutputDev.h: - * poppler/GfxState.cc: - * poppler/GfxState.h: Add support for drawSoftMaskedImage to - CairoOutputDev. Ugly but works. - - ChangeLog | 8 ++++ - poppler/CairoOutputDev.cc | 101 - ++++++++++++++++++++++++++++++++++++++++++++++ - poppler/CairoOutputDev.h | 6 +++ - poppler/GfxState.cc | 50 +++++++++++++++++++++++ - poppler/GfxState.h | 2 + - 5 files changed, 167 insertions(+) - -commit dcb748f68112bd5f99fea8a3da06666be6cff0c5 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Thu Feb 16 19:41:17 2006 +0000 - - 2006-02-16 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: Work around cairo bug when scaling - 1x1 bitmaps. Fixes #3387. Also gives a performance improvement. - - ChangeLog | 5 +++++ - poppler/CairoOutputDev.cc | 33 ++++++++++++++++++++++++--------- - 2 files changed, 29 insertions(+), 9 deletions(-) - -commit ef1070f6ca2d1e74c5f94728f3aaae22f0990c17 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Feb 16 19:28:54 2006 +0000 - - Update soname - - ChangeLog | 8 ++++++++ - glib/Makefile.am | 2 ++ - poppler/Makefile.am | 2 ++ - qt/Makefile.am | 2 ++ - qt4/src/Makefile.am | 2 ++ - 5 files changed, 16 insertions(+) - -commit 24b9f5c33fb00ff80a79b34444282a57288f636c -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Feb 13 23:04:54 2006 +0000 - - * poppler/ArthurOutputDev.cc: Make it compile after changing code - so we did not pass files to freetype but buffers - - ChangeLog | 5 +++++ - poppler/ArthurOutputDev.cc | 53 - +++++++++++++++++----------------------------- - 2 files changed, 24 insertions(+), 34 deletions(-) - -commit 0bda90310b267d3a4963096293eb2bd29b120768 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Feb 13 22:38:44 2006 +0000 - - Probably the last of inner patches missing from kpdf - Everybody will we happy now, kpdf has been finally assimilated - - ChangeLog | 5 ++ - poppler/PSOutputDev.cc | 124 - +++++++++++++++++++++++++++++++++++++++++++++---- - poppler/PSOutputDev.h | 4 +- - 3 files changed, 123 insertions(+), 10 deletions(-) - -commit cf9867fbbee2468a955b5845016585eeedf2debe -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Feb 6 20:49:21 2006 +0000 - - Various fixes from Frank Meerkötter to enable fixedpoint arithmetic - - ChangeLog | 8 ++++++++ - configure.ac | 2 +- - goo/FixedPoint.h | 2 +- - splash/Splash.cc | 4 ++-- - splash/SplashTypes.h | 2 +- - 5 files changed, 13 insertions(+), 5 deletions(-) - -commit f04e2c4f20f821ff8cb9465a715ccbb22091d449 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Feb 6 18:50:10 2006 +0000 - - Jeff Muizelaar's improvements to my yesterday's small patches - - ChangeLog | 6 ++++++ - poppler/Annot.cc | 9 ++++----- - poppler/JBIG2Stream.cc | 2 +- - 3 files changed, 11 insertions(+), 6 deletions(-) - -commit 33e98f81cdfda0935ac7ea79a691976465ec790b -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Feb 5 15:46:10 2006 +0000 - - Some small fixes from kpdf - - ChangeLog | 8 ++++++++ - poppler/Gfx.cc | 1 + - poppler/GfxFont.cc | 1 + - poppler/JBIG2Stream.cc | 2 +- - poppler/SplashOutputDev.cc | 1 - - 5 files changed, 11 insertions(+), 2 deletions(-) - -commit 6d9e6489d24b3105204ff4233f6493136e9b5715 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sat Feb 4 21:10:41 2006 +0000 - - 2006-02-04 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/Gfx.cc: - * poppler/OutputDev.cc: - * poppler/OutputDev.h: Let output devices know about pdf grouping - operators. - Patch by Thorkild Stray. - - ChangeLog | 8 ++++++++ - poppler/Gfx.cc | 14 ++++++++++++++ - poppler/OutputDev.cc | 16 ++++++++++++++++ - poppler/OutputDev.h | 10 ++++++++++ - 4 files changed, 48 insertions(+) - -commit b4e34d905cd0ca5815a450de35b4c2774f4887c9 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sat Feb 4 20:48:25 2006 +0000 - - 2006-02-04 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/GlobalParams.cc: Check all fonts returned by fontconfig. - Discard the ones that are not truetype or type1. Fixes #5758. - Patch by Ed Catmur. - - ChangeLog | 6 ++++++ - poppler/GlobalParams.cc | 51 - +++++++++++++++++++++++++++---------------------- - 2 files changed, 34 insertions(+), 23 deletions(-) - -commit fd85a0afdd7b4cafc68df400d4f94fccaea18c76 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Feb 4 20:34:13 2006 +0000 - - Remove bug from "do not use an external file to pass fonts to - Freetype" patch, patch by Stefan Schweizer - - ChangeLog | 3 +++ - poppler/SplashOutputDev.cc | 14 ++++++++++---- - 2 files changed, 13 insertions(+), 4 deletions(-) - -commit 67ca9d01f8badcf542f60b23521c384c9840ca1b -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Feb 4 20:31:00 2006 +0000 - - Added a DTD of the xml pdftohtml creates patch by Stefan Schweizer - - ChangeLog | 2 ++ - utils/Makefile.am | 2 ++ - utils/pdf2xml.dtd | 28 ++++++++++++++++++++++++++++ - 3 files changed, 32 insertions(+) - -commit f4df23ca7f396883a906f16dfc8db1ebd528e04a -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Feb 4 20:24:03 2006 +0000 - - ignore++ - - utils/.cvsignore | 1 + - 1 file changed, 1 insertion(+) - -commit 93ad488679f594e45547a67e2a7397f4c8bd2820 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Feb 4 20:07:07 2006 +0000 - - Actually create pdftoppm patch by Stefan Schweizer - - ChangeLog | 44 +++++++++++++++++++++++++------------------- - utils/Makefile.am | 10 ++++++++-- - utils/pdftoppm.cc | 9 +++++---- - 3 files changed, 38 insertions(+), 25 deletions(-) - -commit 7d2be955e6345a052590b06b29a6d2fb2111e2e6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Feb 2 23:06:20 2006 +0000 - - CVE-2006-0301 fix by Derek though KDE security team - - ChangeLog | 5 +++++ - splash/SplashXPathScanner.cc | 32 ++++++++++++++++++++------------ - 2 files changed, 25 insertions(+), 12 deletions(-) - -commit c191e7d0f13ea429017e4d4f79ce803e84c72e40 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Feb 2 22:54:27 2006 +0000 - - i should learn on which day i live - - ChangeLog | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 1ddeed60d07c3a7e011f3f594fa9299379d0b000 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Feb 2 22:50:01 2006 +0000 - - don't use files to pass fonts to freetype - - ChangeLog | 26 ++++++++++++ - fofi/FoFiTrueType.cc | 43 ++++++++++++++++---- - fofi/FoFiTrueType.h | 7 ++-- - fofi/FoFiType1C.h | 2 +- - goo/gfile.cc | 8 ++++ - poppler/GfxFont.cc | 49 ++++++++++++++++++++++- - poppler/GfxFont.h | 2 + - poppler/GlobalParams.cc | 1 + - poppler/GlobalParams.h | 1 + - poppler/SplashOutputDev.cc | 94 - ++++++++++++++++++++++---------------------- - splash/SplashFTFontEngine.cc | 44 +++++++++++++-------- - splash/SplashFTFontEngine.h | 16 ++++---- - splash/SplashFTFontFile.cc | 47 +++++++++++++--------- - splash/SplashFTFontFile.h | 18 ++++----- - splash/SplashFontEngine.cc | 46 +++++++++------------- - splash/SplashFontEngine.h | 16 ++++---- - splash/SplashFontFile.cc | 70 +++++++++++++++++++++++++++++---- - splash/SplashFontFile.h | 25 ++++++++++-- - splash/SplashT1FontEngine.cc | 29 +++++++------- - splash/SplashT1FontFile.cc | 30 +++++++++++--- - splash/SplashT1FontFile.h | 4 +- - 21 files changed, 396 insertions(+), 182 deletions(-) - -commit 34df4cfa5cd8788ccf2ea698cbedd05b209041f5 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed Feb 1 03:52:12 2006 +0000 - - 2006-01-31 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/GlobalParams.cc (GlobalParams::getDisplayFont): - Allow ttc fonts to be used. - - ChangeLog | 5 +++++ - poppler/GlobalParams.cc | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit 0184e7c928ec60c0aa3f8634d96ae0cf0ad6d157 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sun Jan 29 05:16:31 2006 +0000 - - 2006-01-28 Jeff Muizelaar <jeff@infidigm.net> - - * glib/poppler-attachment.h: fix compile by adding <time.h> - include. - Acked-by: Jonathan Blanford <jrb@redhat.com> - - ChangeLog | 5 +++++ - glib/poppler-attachment.h | 1 + - 2 files changed, 6 insertions(+) - -commit c805e25f2f074640e4345f8b71eef8d7de677109 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Jan 26 19:25:07 2006 +0000 - - 2006-01-26 Kristian Høgsberg <krh@redhat.com> - - * poppler/CairoOutputDev.cc: Patch from Christian Krause; - handle - 0-width lines (#5545). - - ChangeLog | 5 +++++ - poppler/CairoOutputDev.cc | 6 +++++- - 2 files changed, 10 insertions(+), 1 deletion(-) - -commit 4f48abcd4c21460d4c5b718a7ba18cdceb30c2d1 -Author: Jonathan Blandford <jrb@redhat.com> -Date: Tue Jan 24 06:21:39 2006 +0000 - - Tue Jan 24 01:19:40 2006 Jonathan Blandford <jrb@redhat.com> - - * glib/Makefile.am: - * glib/poppler-attachment.cc: - * glib/poppler-attachment.h: - * glib/poppler-document.cc: - * glib/poppler-document.h: - * glib/poppler-page.cc: - * glib/poppler-private.h: - * glib/poppler.h: - * glib/test-poppler-glib.c: - * glib/reference/tmpl/poppler-enums.sgml: - * glib/reference/tmpl/poppler-unused.sgml: glib bindings - for the - embedded file support. It doesn't support mtime and - ctime yet, - but the rest works. - - ChangeLog | 16 +++ - glib/Makefile.am | 2 + - glib/poppler-attachment.cc | 223 - ++++++++++++++++++++++++++++++++ - glib/poppler-attachment.h | 67 ++++++++++ - glib/poppler-document.cc | 63 +++++++++ - glib/poppler-document.h | 6 + - glib/poppler-page.cc | 2 +- - glib/poppler-private.h | 6 +- - glib/poppler.h | 1 + - glib/reference/tmpl/poppler-enums.sgml | 150 +++++++++++++++++++++ - glib/reference/tmpl/poppler-unused.sgml | 130 ------------------- - glib/test-poppler-glib.c | 26 +++- - 12 files changed, 559 insertions(+), 133 deletions(-) - -commit 052bf4b80c8a0dc45f6222617bfd8ae1b9c40410 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Jan 23 18:52:48 2006 +0000 - - 2006-01-23 Kristian Høgsberg <krh@redhat.com> - - * configure.ac: - * poppler/GlobalParams.cc: - * poppler/poppler-config.h.in: - * utils/pdftohtml.cc: - * utils/pdftops.cc: Respect command line paper size settings - (#5641). - Drop the built-in paper sizes. - - ChangeLog | 9 +++++++++ - configure.ac | 1 - - poppler/GlobalParams.cc | 23 ++--------------------- - poppler/poppler-config.h.in | 5 ----- - utils/pdftohtml.cc | 4 +--- - utils/pdftops.cc | 4 +++- - 6 files changed, 15 insertions(+), 31 deletions(-) - -commit fb2054a5031d60aac3ccc9a36b3ed88a32188e33 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Jan 23 15:40:54 2006 +0000 - - 2006-01-23 Kristian Høgsberg <krh@redhat.com> - - * glib/test-poppler-glib.c (print_document_info, print_index): - Move variable declarations to top (#5692). - - * utils/*.cc: Move config.h #include to top of #include's - (#5693). - - ChangeLog | 5 +++++ - glib/test-poppler-glib.c | 5 +++-- - poppler/FontInfo.cc | 2 +- - utils/HtmlOutputDev.cc | 2 +- - utils/ImageOutputDev.cc | 2 +- - utils/pdffonts.cc | 2 +- - utils/pdfimages.cc | 2 +- - utils/pdfinfo.cc | 2 +- - utils/pdftohtml.cc | 4 ++-- - utils/pdftoppm.cc | 2 +- - utils/pdftops.cc | 2 +- - utils/pdftotext.cc | 2 +- - 12 files changed, 19 insertions(+), 13 deletions(-) - -commit 836af3529e827e25f20cb4710cbbf9ed0371a42c -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Jan 23 14:45:30 2006 +0000 - - 2006-01-23 Kristian Høgsberg <krh@redhat.com> - - * splash/SplashFTFont.cc: Don't use deprecated freetype - include - files. - - ChangeLog | 5 +++++ - splash/SplashFTFont.cc | 3 ++- - 2 files changed, 7 insertions(+), 1 deletion(-) - -commit 60e13bf84e4f020a264811e4a5bf85d67e15d6df -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sat Jan 21 21:56:40 2006 +0000 - - 2006-01-21 Jeff Muizelaar <jeff@infidigm.net> - - * TODO: Add my todo list. - - ChangeLog | 4 ++++ - TODO | 10 ++++++++++ - 2 files changed, 14 insertions(+) - -commit cebba06563d1b691a8bbb83828e47c9cc91e231a -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jan 18 22:40:26 2006 +0000 - - ok, ok, lasts files, i promise :-/ - - qt4/tests/check_attachments.cpp | 151 - ++++++++++++++++++++++++++++++++++++++ - qt4/tests/poppler-attachments.cpp | 37 ++++++++++ - 2 files changed, 188 insertions(+) - -commit 0b12e7cce6c6633b1d07e2902a9fa13ff52079e7 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jan 18 22:38:59 2006 +0000 - - YAMF = Yet Another Missing File - - qt4/src/poppler-embeddedfile.cc | 106 - ++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 106 insertions(+) - -commit 38c8f3a53b3eb2be1fbfa360f77285037d89b719 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jan 18 22:36:01 2006 +0000 - - as usual i foget some files - - poppler/UGooString.cc | 86 - +++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/UGooString.h | 55 ++++++++++++++++++++++++++++++++ - 2 files changed, 141 insertions(+) - -commit ad6e7d862c8fa6e10a7dbbb3391cbb0b6c922375 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jan 18 22:32:13 2006 +0000 - - Brad patch for embedded document extraction, only has Qt4 bindings - for now, needs Qt3 and glib work - - ChangeLog | 42 +++++++++++++ - glib/poppler-action.cc | 2 +- - glib/poppler-document.cc | 1 + - poppler/Annot.cc | 1 + - poppler/Catalog.cc | 133 - +++++++++++++++++++++++++++++++++++++++--- - poppler/Catalog.h | 60 +++++++++++++++++-- - poppler/Dict.cc | 17 +++--- - poppler/Dict.h | 15 ++--- - poppler/FontInfo.cc | 1 + - poppler/Function.cc | 1 + - poppler/Gfx.cc | 1 + - poppler/GfxFont.cc | 5 +- - poppler/GfxState.cc | 1 + - poppler/Link.cc | 9 +-- - poppler/Link.h | 9 +-- - poppler/Makefile.am | 2 + - poppler/Object.h | 17 +++--- - poppler/Outline.cc | 1 + - poppler/PDFDoc.cc | 1 + - poppler/PDFDoc.h | 2 +- - poppler/PSOutputDev.cc | 5 +- - poppler/Page.cc | 1 + - poppler/PageLabelInfo.cc | 1 + - poppler/Parser.cc | 2 + - poppler/SecurityHandler.cc | 1 + - poppler/Stream.cc | 1 + - poppler/XRef.cc | 1 + - qt/poppler-document.cc | 1 + - qt/poppler-page-transition.cc | 1 + - qt4/src/Makefile.am | 1 + - qt4/src/poppler-document.cc | 26 ++++++++- - qt4/src/poppler-private.h | 2 + - qt4/src/poppler-qt4.h | 68 +++++++++++++++++++++ - qt4/tests/.cvsignore | 2 + - qt4/tests/Makefile.am | 16 ++++- - utils/HtmlOutputDev.cc | 1 + - utils/pdffonts.cc | 1 + - utils/pdfinfo.cc | 1 + - utils/pdftohtml.cc | 1 + - utils/pdftotext.cc | 1 + - 40 files changed, 401 insertions(+), 54 deletions(-) - -commit 550fb0b617ece7951ec39aec5fa5504cc90022fc -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jan 18 21:22:12 2006 +0000 - - Add some more documentation to PageTransition, patch by Stefan Kebekus - - ChangeLog | 6 ++++++ - qt/poppler-page-transition.h | 40 - +++++++++++++++++++++++++++++++++------- - qt4/src/Doxyfile | 2 +- - 3 files changed, 40 insertions(+), 8 deletions(-) - -commit d66f3647ff1c38318d4cd056cb4d4c7a32eb6603 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jan 18 18:54:12 2006 +0000 - - poppler/CharCodeToUnicode.cc: Fix check for length that was not - having into account that there could be \n or \r in tokens - an that - those do not have to be took into account. Fixes - http://bugs.kde.org/show_bug.cgi?id=120310 - - ChangeLog | 9 ++++++++- - poppler/CharCodeToUnicode.cc | 31 +++++++++++++++++++++++++++---- - 2 files changed, 35 insertions(+), 5 deletions(-) - -commit d78b670339c8f92a32ab5f0a574d0e21690806f8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jan 17 21:35:31 2006 +0000 - - When doing the parsing check with XREF we did not grow too much. Fixes - serialata10a.pdf - - ChangeLog | 10 ++++++++++ - poppler/Lexer.cc | 22 +++++++++++++++++++--- - poppler/Lexer.h | 8 +++++--- - poppler/Parser.cc | 6 +++--- - poppler/Parser.h | 2 +- - poppler/XRef.cc | 17 +++++++++++++++++ - poppler/XRef.h | 3 +++ - 7 files changed, 58 insertions(+), 10 deletions(-) - -commit f5db636af0cd6e05cd7ede37a8585001d51192a1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jan 17 20:33:08 2006 +0000 - - i suck - i suck - i suck - i suck - i suck - A file i forgot to add to make it compile :-/ - - qt/poppler-page-transition-private.h | 28 ++++++++++++++++++++++++++++ - 1 file changed, 28 insertions(+) - -commit 9cc97908ea67ab431e58129f589e00f41f40a143 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Thu Jan 12 23:54:08 2006 +0000 - - 2006-01-12 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/GlobalParams.cc: Make buildFcPattern() static. - - ChangeLog | 4 ++++ - poppler/GlobalParams.cc | 2 +- - 2 files changed, 5 insertions(+), 1 deletion(-) - -commit c7ce134fb1dadb46e2b3773d0976ea31da0a046f -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed Jan 11 16:52:58 2006 +0000 - - 2006-01-11 Kristian Høgsberg <krh@redhat.com> - - * poppler/JBIG2Stream.cc: - * poppler/Stream.cc: Merge patch to fix CVE-2005-3624, - CVE-2005-3625 and CVE-2005-3627 issues. - - ChangeLog | 6 ++++++ - poppler/JBIG2Stream.cc | 32 +++++++++++++++++++++++++++++++- - poppler/Stream.cc | 8 +++++--- - 3 files changed, 42 insertions(+), 4 deletions(-) - -commit ec7fb41725c19bc7f2aad1073fe6397ea0a8da0d -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jan 10 21:57:28 2006 +0000 - - * configure.ac: - * m4/qt.m4: Fix bugs created when splitting the code from - configure.ac, take QTDIR into account when looking for - QtTestLib and - do not die if it is not found as it is not mandatory - * qt/poppler-page-transition.cc: - * qt/poppler-page.cc: - * qt/poppler-private.h: - * qt4/tests/Makefile.am: - * qt4/src/poppler-qt4.h: - * qt4/src/poppler-page.cc: - * qt4/src/Makefile.am: Fix mess created my the moving and - renaming of - PageTransition.cc - - ChangeLog | 15 +++++++++++++++ - configure.ac | 14 ++++---------- - m4/qt.m4 | 5 +++++ - qt/poppler-page-transition.cc | 2 +- - qt/poppler-page.cc | 1 + - qt/poppler-private.h | 5 ----- - qt4/src/Makefile.am | 1 + - qt4/src/poppler-page.cc | 2 +- - qt4/src/poppler-qt4.h | 2 +- - qt4/tests/Makefile.am | 1 + - 10 files changed, 30 insertions(+), 18 deletions(-) - -commit d9bc53a741b3bbd2a202662c66fe70f49ac72a49 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue Jan 10 17:59:51 2006 +0000 - - 2006-01-10 Kristian Høgsberg <krh@redhat.com> - - * splash/Makefile.am: Only install splash headers if - --enable-xpdf-headers is given. - - * Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Set this here. - - ChangeLog | 7 +++++++ - Makefile.am | 1 + - splash/Makefile.am | 4 ++++ - 3 files changed, 12 insertions(+) - -commit ea6d9b97cec6fabf8a5005c565bbdb378bed7f54 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Tue Jan 10 17:55:59 2006 +0000 - - 2006-01-10 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: - * poppler/CairoOutputDev.h: - Fix the following fixme in CairoOutputDevice. - - // FIXME: This is quite right yet, we need to accumulate all - // glyphs within one text object before we clip. Right now this - // just add this one string. - - The fix uses a strategy similar to the one the Splash backend. - textClipPath is used to store the appended path from each call to - endString(). The accumulated path is clipped in endTextObject. - - ChangeLog | 14 ++++++++++++++ - poppler/CairoOutputDev.cc | 27 +++++++++++++++++++++++---- - poppler/CairoOutputDev.h | 1 + - 3 files changed, 38 insertions(+), 4 deletions(-) - -commit 9e8a655a2bd3ca8cff1a150dce0dd378aeca047b -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sun Jan 8 22:59:48 2006 +0000 - - 2006-01-08 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: Don't try and load type3 fonts - (#4030). - - ChangeLog | 6 +++++- - poppler/CairoOutputDev.cc | 5 ++++- - 2 files changed, 9 insertions(+), 2 deletions(-) - -commit 25fd8e1ea87c41855a4ee702fbe47f5661a54c22 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sun Jan 8 22:51:17 2006 +0000 - - 2006-01-08 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/Page.cc: use colToByte for reading thumbnails (#5420). - - Patch by Nickolay V. Shmyrev. - - ChangeLog | 6 ++++++ - poppler/Page.cc | 6 +++--- - 2 files changed, 9 insertions(+), 3 deletions(-) - -commit df73ee2ec4b65ccf611f0fd76fb456cc797693d4 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sat Jan 7 06:10:15 2006 +0000 - - 2006-01-07 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/CairoOutputDev.cc: Initialize (fill|stroke)_opacity. - - ChangeLog | 4 ++++ - poppler/CairoOutputDev.cc | 2 ++ - 2 files changed, 6 insertions(+) - -commit 18eb8de66749082e4aa65cc6d369a533826fab33 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Jan 6 10:05:58 2006 +0000 - - 2006-01-06 Kristian Høgsberg <krh@redhat.com> - - * qt/poppler-page.cc: - * qt/poppler-private.h: - * qt/poppler-qt.h: - * qt4/src/Makefile.am: - * qt/Makefile.am: - * poppler/Makefile.am: Move PageTransition to qt bindings, - move - contents from Private.h to qt/poppler-private.h. - - * poppler/TextOutputDev.cc (visitWord): Remove #warning. - - * utils/Makefile.am (pdfimages_SOURCES): Add ImageOutputDev.h, - use - dist_man1_MANS so we actually dist the man pages. - - * goo/Makefile.am (poppler_goo_include_HEADERS): Add - GooVector.h. - - * glib/reference/Makefile.am: DOC_SOURCE_DIR must be - relative to - $(srcdir), fix this to make distchek run. - - * m4/qt.m4: - * m4/libjpeg.m4: - * acinclude.m4: - * configure.ac: Split out Qt and libjpeg checks from - configure.ac - and acinclude.m4 to m4/qt.m4 and m4/libjpeg.m4. - - ChangeLog | 26 ++++ - acinclude.m4 | 112 ---------------- - configure.ac | 223 - +++----------------------------- - glib/reference/Makefile.am | 2 +- - glib/reference/tmpl/poppler-enums.sgml | 150 --------------------- - glib/reference/tmpl/poppler-unused.sgml | 130 +++++++++++++++++++ - goo/Makefile.am | 1 + - m4/libjpeg.m4 | 109 ++++++++++++++++ - m4/qt.m4 | 206 - +++++++++++++++++++++++++++++ - poppler/Makefile.am | 1 - - poppler/PageTransition.h | 118 ----------------- - poppler/Private.h | 30 ----- - poppler/TextOutputDev.cc | 2 - - qt/Makefile.am | 8 +- - qt/poppler-page-transition.cc | 187 ++++++++++++++++++++++++++ - qt/poppler-page-transition.h | 117 +++++++++++++++++ - qt/poppler-page.cc | 1 - - qt/poppler-private.h | 9 +- - qt/poppler-qt.h | 2 +- - qt4/src/Makefile.am | 8 +- - utils/Makefile.am | 54 ++++++-- - 21 files changed, 857 insertions(+), 639 deletions(-) - -commit 93921e77115ebe4d527f98675e438de485e84507 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jan 5 23:53:33 2006 +0000 - - * poppler/DCTStream.cc: Fix handling of malformed jpeg streams like - the one at http://bugs.kde.org/show_bug.cgi?id=119569 - - Might be worth backporting to 0.4.x - - ChangeLog | 5 +++++ - poppler/DCTStream.cc | 26 ++++++++++++++++---------- - 2 files changed, 21 insertions(+), 10 deletions(-) - -commit 0dc16af02071350a0dc11af4106799378c99cdad -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jan 5 13:53:58 2006 +0000 - - Introduce variants of renderTo that return a QImage and do not use - a QPixmap so threading is possible. - - ChangeLog | 8 +++++++ - qt/poppler-page.cc | 18 ++++++++++----- - qt/poppler-qt.h | 30 ++++++++++++++++++++----- - qt4/src/poppler-page.cc | 9 +++++++- - qt4/src/poppler-qt4.h | 59 - +++++++++++++++++++++++++++---------------------- - 5 files changed, 85 insertions(+), 39 deletions(-) - -commit 5c2cbf5d327c6cc75c073b56c3ab1748c0d24387 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Jan 2 14:24:31 2006 +0000 - - Use error() instead std::cerr in PageTranstion.cc - - ChangeLog | 4 ++++ - poppler/PageTransition.cc | 5 +++-- - 2 files changed, 7 insertions(+), 2 deletions(-) - -commit da5a4233498b56df611e1c7bca0090306cb5dbe0 -Author: Jonathan Blandford <jrb@redhat.com> -Date: Mon Jan 2 00:06:45 2006 +0000 - - Sun Jan 1 18:50:51 2006 Jonathan Blandford <jrb@redhat.com> - - * Makefile.am: - * autogen.sh: - * configure.ac: - * gtk-doc.make: - * glib/Makefile.am: enable gtk-doc support. - - ChangeLog | 8 +++ - Makefile.am | 2 + - autogen.sh | 14 +++++ - configure.ac | 4 ++ - glib/Makefile.am | 1 + - gtk-doc.make | 153 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++ - m4/gtk-doc.m4 | 53 +++++++++++++++++++ - 7 files changed, 235 insertions(+) - -commit 372c34cc9728d7041bc4f6893c0bae50c9501c50 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 1 22:35:48 2006 +0000 - - * qt4/src/poppler-private.h: - * qt4/src/poppler-page.cc: - * qt4/src/poppler-document.cc: Don't create a SplashOutputDev - for - every splashRenderToPixmap - - ChangeLog | 4 ++++ - qt4/src/poppler-document.cc | 1 - - qt4/src/poppler-page.cc | 18 +++++------------- - qt4/src/poppler-private.h | 24 +++++++++++++++++++++++- - 4 files changed, 32 insertions(+), 15 deletions(-) - -commit 6ff83474ac594368015334db9c6b33d3a552079f -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jan 1 22:18:47 2006 +0000 - - * qt/poppler-page.cc: - * qt/poppler-private.h: Don't create a SplashOutputDev for every - renderToPixmap. - - ChangeLog | 6 ++++++ - qt/poppler-page.cc | 8 +------- - qt/poppler-private.h | 24 +++++++++++++++++++++++- - 3 files changed, 30 insertions(+), 8 deletions(-) - -commit 6942646d4c82327a80b021838a38aa55c1026883 -Author: Jonathan Blandford <jrb@redhat.com> -Date: Sun Jan 1 20:34:36 2006 +0000 - - Sun Jan 1 15:32:08 2006 Jonathan Blandford <jrb@redhat.com> - - * glib/reference/*: More gtk-doc work. Not enabled for - building - by default, but filled in. - - .cvsignore | 1 + - ChangeLog | 5 + - glib/reference/.cvsignore | 18 ++ - glib/reference/Makefile.am | 87 +++++++ - glib/reference/poppler-docs.sgml | 17 ++ - glib/reference/poppler-overrides.txt | 0 - glib/reference/poppler-sections.txt | 151 ++++++++++++ - glib/reference/poppler.types | 4 + - glib/reference/tmpl/poppler-action.sgml | 172 +++++++++++++ - glib/reference/tmpl/poppler-document.sgml | 354 - +++++++++++++++++++++++++++ - glib/reference/tmpl/poppler-enums.sgml | 169 +++++++++++++ - glib/reference/tmpl/poppler-page.sgml | 243 ++++++++++++++++++ - glib/reference/tmpl/poppler-private.sgml | 128 ++++++++++ - glib/reference/tmpl/poppler-unused.sgml | 0 - glib/reference/tmpl/poppler.sgml | 216 ++++++++++++++++ - glib/reference/tmpl/stamp-poppler-enums.sgml | 19 ++ - 16 files changed, 1584 insertions(+) - -commit 0fab1b711f153859e113cb3b6d734ddcb58fb87a -Author: Jonathan Blandford <jrb@redhat.com> -Date: Sat Dec 31 02:10:33 2005 +0000 - - Fri Dec 30 21:08:33 2005 Jonathan Blandford <jrb@redhat.com> - - * glib/*{cc,h}: Update inline doc comments. This is in - preparation for gtk-doc support. - - ChangeLog | 5 ++ - glib/poppler-action.cc | 14 +++++ - glib/poppler-action.h | 2 - - glib/poppler-document.cc | 151 - ++++++++++++++++++++++++++++++++++++++++++++++- - glib/poppler-document.h | 4 +- - glib/poppler-page.cc | 28 +++++++++ - glib/poppler.cc | 16 +++++ - glib/test-poppler-glib.c | 29 +++++++++ - 8 files changed, 243 insertions(+), 6 deletions(-) - -commit 313530036b204eaa5ddfa150730302e855560d6a -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Dec 30 22:54:46 2005 +0000 - - A delete that slipped from the last patch-commit - - qt4/src/poppler-page.cc | 1 + - 1 file changed, 1 insertion(+) - -commit cf6f8123af19aca4200b58a454652f68ce8132e2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Dec 30 22:31:32 2005 +0000 - - Puting PageTransition implementation into poppler "core", both Qt - and Qt4 frontends use it. - - poppler/Makefile.am | 1 + - poppler/PageTransition.cc | 188 - ++++++++++++++++++++++++++++++++++++++++++++++ - poppler/PageTransition.h | 118 +++++++++++++++++++++++++++++ - poppler/Private.h | 30 ++++++++ - qt/Makefile.am | 2 +- - qt/poppler-page.cc | 111 +-------------------------- - qt/poppler-qt.h | 72 +----------------- - qt4/src/Makefile.am | 2 +- - qt4/src/poppler-page.cc | 17 ++++- - qt4/src/poppler-qt4.h | 14 +++- - 10 files changed, 374 insertions(+), 181 deletions(-) - -commit 56035ab199ac6deb5c1e07e745d120d1121a5960 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Dec 30 21:59:58 2005 +0000 - - * utils/HtmlOutputDev.cc: - * utils/ImageOutputDev.cc: Fix build when using --disable-libjpeg - - ChangeLog | 5 +++++ - utils/HtmlOutputDev.cc | 2 ++ - utils/ImageOutputDev.cc | 2 ++ - 3 files changed, 9 insertions(+) - -commit 8b64dafc7f1d198fb0052c0d6f0da6de97bbb48d -Author: Brad Hards <bradh@frogmouth.net> -Date: Wed Dec 28 09:23:43 2005 +0000 - - Plug a few memory leaks in the Qt4 bindings. - - ChangeLog | 25 ++++++++++++++++++++ - qt4/src/poppler-document.cc | 3 +++ - qt4/src/poppler-private.h | 7 +++++- - qt4/src/poppler-qt4.h | 3 +++ - qt4/tests/check_fonts.cpp | 8 +++++++ - qt4/tests/check_metadata.cpp | 50 - +++++++++++++++++++++++++++++++++++----- - qt4/tests/check_pagelayout.cpp | 6 +++++ - qt4/tests/check_pagemode.cpp | 10 ++++++++ - qt4/tests/check_permissions.cpp | 2 ++ - qt4/tests/check_version.cpp | 22 ------------------ - qt4/tests/poppler-fonts.cpp | 1 + - qt4/tests/stress-poppler-qt4.cpp | 2 ++ - 12 files changed, 110 insertions(+), 29 deletions(-) - -commit 64c07a20a4ed844f3b3dd26e974f58d5877cf9fd -Author: Brad Hards <bradh@frogmouth.net> -Date: Tue Dec 27 06:10:01 2005 +0000 - - qt4/src/poppler-qt4.h and qt4/src/poppler-document.cc: add - convertDate() function that - turns char* PDF date strings into QDateTime. This version handles - the timezone conversions. Refactored the existing date() method - to use it. - - qt4/tests/check_dateConversion.cpp: unit tests for convertDate() - qt4/tests/check_metadata.cpp: update to reflect UTC. - qt4/tests/.cvsignore: suppress check_dateConversion - - ChangeLog | 9 ++++ - qt4/src/poppler-document.cc | 89 ++++++++++++++++++++----------- - qt4/src/poppler-qt4.h | 5 ++ - qt4/tests/.cvsignore | 1 + - qt4/tests/Makefile.am | 11 ++-- - qt4/tests/check_dateConversion.cpp | 105 - +++++++++++++++++++++++++++++++++++++ - qt4/tests/check_metadata.cpp | 4 +- - 7 files changed, 188 insertions(+), 36 deletions(-) - -commit 4b2e3b5106b75f23c830837a886cd29beb1d1d1b -Author: Brad Hards <bradh@frogmouth.net> -Date: Tue Dec 27 05:08:34 2005 +0000 - - * qt4/src/Doxyfile (JAVADOC_AUTOBRIEF): Turned on automatic - \brief mode. - - * qt4/src/poppler-qt4.h: Update API documentation. Patch from - Stefan Kebekus, with some changes. Removed \brief entries. - - ChangeLog | 8 +++++ - qt4/src/Doxyfile | 2 +- - qt4/src/poppler-qt4.h | 81 - ++++++++++++++++++++++++++++++++++++++++----------- - 3 files changed, 73 insertions(+), 18 deletions(-) - -commit 8d9cf43aaa73d5012428a6a4c5d7e2cccbd3036e -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed Dec 21 22:09:47 2005 +0000 - - 2005-12-21 Kristian Høgsberg <krh@redhat.com> - - * NEWS: Sum up 0.5 changes so far. - - * acinclude.m4: Split jpeg macros out into this file. - - * poppler/Stream.cc: Apply latest CVE-2005-3191 updates. - - ChangeLog | 8 ++++ - NEWS | 8 ++++ - acinclude.m4 | 112 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - configure.ac | 114 - --------------------------------------------------- - poppler/JPXStream.cc | 1 + - poppler/Stream.cc | 11 +++-- - 6 files changed, 137 insertions(+), 117 deletions(-) - -commit 97243286560cb4f264b875185c8768a6af09d554 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed Dec 21 17:30:33 2005 +0000 - - 2005-12-21 Kristian Høgsberg <krh@redhat.com> - - * utils/Makefile.am: Add parseargs.h to sources and add - -I$(top_srcdir)/poppler to INCLUDES. - - * poppler/CairoFontEngine.cc: Apply patch from Hiroyuki - Ikezoe to - man non-embedded CJK fonts work. - - ChangeLog | 14 ++++++++++--- - configure.ac | 2 +- - poppler/CairoFontEngine.cc | 52 - +++++++++++++++++++++++++++++++++++++++++----- - utils/Makefile.am | 15 +++++++------ - 4 files changed, 68 insertions(+), 15 deletions(-) - -commit cf887a9a9fae7272165d3aae05c85444ff5ca604 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Dec 18 22:03:30 2005 +0000 - - * poppler/Page.cc: Only discard cropbox sizes one by one - and not - completely. Jeff and Martin were right - - ChangeLog | 2 ++ - poppler/Page.cc | 13 ++++++++++--- - 2 files changed, 12 insertions(+), 3 deletions(-) - -commit 495890b9cef9d5d61bb47e789add1cf2c3b8f83d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Dec 18 21:56:15 2005 +0000 - - + .cvsignore - - utils/.cvsignore | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -commit 5dca860bba6918e06fab3aa56a2c75f0ac9ecdfb -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Dec 18 21:08:48 2005 +0000 - - Fix utils building on Slackware - - ChangeLog | 3 +++ - configure.ac | 3 +++ - utils/Makefile.am | 3 ++- - 3 files changed, 8 insertions(+), 1 deletion(-) - -commit 03e3d9164ffd71f03136b57a9941ea14fadb21aa -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Dec 18 17:12:28 2005 +0000 - - 2005-12-18 Albert Astals Cid <aacid@kde.org> - - * configure.ac: Better jpeg detection, refer to ml PCbsd - problem - - ChangeLog | 4 ++ - configure.ac | 131 - +++++++++++++++++++++++++++++++++++++++++++++++++++-------- - 2 files changed, 118 insertions(+), 17 deletions(-) - -commit 888d76a29c9c5ea6c90cc4299b230ca0c2c2944f -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Dec 12 20:21:08 2005 +0000 - - * poppler/Page.cc: Ignore cropBox if it seems incorrect - - ChangeLog | 4 ++++ - poppler/Page.cc | 7 +++++++ - 2 files changed, 11 insertions(+) - -commit bcc5e3afe27c8787ce7022a0701997c96eddb4fe -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Dec 12 20:15:11 2005 +0000 - - 2005-12-12 Kristian Høgsberg <krh@redhat.com> - - * Makefile.am: - * configure.ac: - * goo/GooVector.h: - * utils/HtmlFonts.cc: - * utils/HtmlFonts.h: - * utils/HtmlLinks.cc: - * utils/HtmlLinks.h: - * utils/HtmlOutputDev.cc: - * utils/HtmlOutputDev.h: - * utils/ImageOutputDev.cc: - * utils/ImageOutputDev.h: - * utils/Makefile.am: - * utils/parseargs.c: - * utils/parseargs.h: - * utils/pdffonts.1: - * utils/pdffonts.cc: - * utils/pdfimages.1: - * utils/pdfimages.cc: - * utils/pdfinfo.1: - * utils/pdfinfo.cc: - * utils/pdftohtml.1: - * utils/pdftohtml.cc: - * utils/pdftoppm.1: - * utils/pdftoppm.cc: - * utils/pdftops.1: - * utils/pdftops.cc: - * utils/pdftotext.1: - * utils/pdftotext.cc: Add command line utilities from xpdf. - - ChangeLog | 31 + - Makefile.am | 6 +- - configure.ac | 25 +- - goo/GooVector.h | 101 +++ - utils/HtmlFonts.cc | 326 ++++++++++ - utils/HtmlFonts.h | 85 +++ - utils/HtmlLinks.cc | 101 +++ - utils/HtmlLinks.h | 49 ++ - utils/HtmlOutputDev.cc | 1569 - +++++++++++++++++++++++++++++++++++++++++++++++ - utils/HtmlOutputDev.h | 302 +++++++++ - utils/ImageOutputDev.cc | 195 ++++++ - utils/ImageOutputDev.h | 76 +++ - utils/Makefile.am | 18 + - utils/parseargs.c | 190 ++++++ - utils/parseargs.h | 71 +++ - utils/pdffonts.1 | 128 ++++ - utils/pdffonts.cc | 294 +++++++++ - utils/pdfimages.1 | 96 +++ - utils/pdfimages.cc | 159 +++++ - utils/pdfinfo.1 | 157 +++++ - utils/pdfinfo.cc | 376 ++++++++++++ - utils/pdftohtml.1 | 85 +++ - utils/pdftohtml.cc | 429 +++++++++++++ - utils/pdftoppm.1 | 113 ++++ - utils/pdftoppm.cc | 189 ++++++ - utils/pdftops.1 | 224 +++++++ - utils/pdftops.cc | 336 ++++++++++ - utils/pdftotext.1 | 135 ++++ - utils/pdftotext.cc | 337 ++++++++++ - 29 files changed, 6194 insertions(+), 9 deletions(-) - -commit 5fbded32741acb5fac411189f80cb57aa11df517 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Dec 10 10:52:15 2005 +0000 - - * qt4/src/poppler-page.cc: - * qt4/src/poppler-qt4.h: - * qt4/src/tests/test-poppler-qt4.cpp: The parameters x,y,w,h to the - method splashRenderToPixmap are now used. Convenient - defaults are provided. The test has been changed accordingly. Some - added documentation. Patch by Stefan Kebekus - - ChangeLog | 9 +++++++++ - qt4/src/poppler-page.cc | 4 ++-- - qt4/src/poppler-qt4.h | 31 +++++++++++++++++++++++-------- - qt4/tests/test-poppler-qt4.cpp | 2 +- - 4 files changed, 35 insertions(+), 11 deletions(-) - -commit bc6df8c41081c0c0107655cbf70ddb8b0c493c34 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Dec 9 20:49:59 2005 +0000 - - 2005-12-09 Kristian Høgsberg <krh@redhat.com> - - * poppler/GfxState.cc: Use colToByte() for converting - GxfColorComp - to bytes (really fix #5117). - - * poppler/Stream.cc: Remove duplicated check (#5243). - - ChangeLog | 5 +++++ - poppler/GfxState.cc | 6 +++--- - poppler/Stream.cc | 4 ---- - 3 files changed, 8 insertions(+), 7 deletions(-) - -commit 8a2464122455311c6d16ae62bb9ac9a0ae365a28 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Dec 9 19:40:40 2005 +0000 - - 2005-12-09 Kristian Høgsberg <krh@redhat.com> - - * configure.ac: - * poppler/Makefile.am (poppler_includedir): - * goo/Makefile.am (poppler_goo_include_HEADERS): Make - installation - of xpdf header files optional. - - ChangeLog | 10 +++++++++- - configure.ac | 8 ++++++++ - goo/Makefile.am | 4 ++++ - poppler/Makefile.am | 4 ++++ - 4 files changed, 25 insertions(+), 1 deletion(-) - -commit 830b61bfd1c985fe14ec4d0f6724c8f70e924fc1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Dec 8 18:17:42 2005 +0000 - - * configure.ac: Detect if gettimeofday is available, fixes - for correct - linking to Qt4 on windows - * goo/GooTimer.[cc|h]: Only build if gettimeofday is available - * poppler/Gfx.cc: Only use the timer for profiling if - gettimeofday is - available - * poppler/GlobalParams.cc: Remove extra unlockGlobalParams - that was - making windows hang - * splash/SplashFTFontEngine.cc: i need unistd.h on windows - also - * splash/SplashFontFile.cc: i need unistd.h on windows also - - ChangeLog | 12 ++++++++++++ - configure.ac | 14 +++++++++++++- - goo/GooTimer.cc | 3 +++ - goo/GooTimer.h | 4 ++++ - poppler/Gfx.cc | 6 ++++++ - poppler/GlobalParams.cc | 1 - - splash/SplashFTFontEngine.cc | 4 +--- - splash/SplashFontFile.cc | 4 +--- - 8 files changed, 40 insertions(+), 8 deletions(-) - -commit 0a1c33ed17fd7053ed455da3444856a5dab3c9b4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Dec 8 12:42:50 2005 +0000 - - Remove -DDATADIR we are not using if for anything and it shadows a - windows typedef - - ChangeLog | 8 ++++++++ - glib/Makefile.am | 3 +-- - poppler/Makefile.am | 3 +-- - qt/Makefile.am | 3 +-- - test/Makefile.am | 3 +-- - 5 files changed, 12 insertions(+), 8 deletions(-) - -commit adca042e666fd932f16213d0a4daba08b5021901 -Author: Brad Hards <bradh@frogmouth.net> -Date: Wed Dec 7 08:42:21 2005 +0000 - - Remove the version check. OK'd by krh. - - ChangeLog | 2 ++ - poppler/PDFDoc.cc | 6 +----- - 2 files changed, 3 insertions(+), 5 deletions(-) - -commit bc57f8dd73eef9a74e4a6e248ed6985c360db838 -Author: Brad Hards <bradh@frogmouth.net> -Date: Wed Dec 7 08:31:09 2005 +0000 - - Add infoKeys() - allows you to get a list of all the string names - (keys) - for the metadata. - - ChangeLog | 7 +++++++ - qt4/src/poppler-document.cc | 22 ++++++++++++++++++++++ - qt4/src/poppler-qt4.h | 7 +++++++ - qt4/tests/check_metadata.cpp | 18 ++++++++++++++++++ - 4 files changed, 54 insertions(+) - -commit 7ec41df91e6dbf792e11676d929acc2f634bd382 -Author: Brad Hards <bradh@frogmouth.net> -Date: Tue Dec 6 09:58:04 2005 +0000 - - Add more unit tests for better coverage. - - ChangeLog | 6 ++++ - qt4/tests/check_fonts.cpp | 24 ++++++++++++++++ - qt4/tests/check_metadata.cpp | 66 - ++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 96 insertions(+) - -commit a92b10016306ac46775c9b95b52d249b233ff950 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Dec 5 20:46:22 2005 +0000 - - * poppler/CairoFontEngine.cc: Correct fix for #5149, i broke it when - merging xpdf 3.01 patches - - ChangeLog | 5 +++++ - poppler/CairoFontEngine.cc | 4 +--- - 2 files changed, 6 insertions(+), 3 deletions(-) - -commit 66096477d1a86f13fcb07ae25caff1cc02b1e7cd -Author: Brad Hards <bradh@frogmouth.net> -Date: Sun Dec 4 19:48:25 2005 +0000 - - Add checking for Type3 fonts in the unit test. - - ChangeLog | 5 +++++ - qt4/tests/check_fonts.cpp | 24 ++++++++++++++++++++++++ - 2 files changed, 29 insertions(+) - -commit 62345b0affed8e2e37728fca7f2b750879192c43 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Dec 4 18:53:40 2005 +0000 - - Fix error in merging CAN-2005-3193 fix. Thanks Daniel Gryniewicz - for notifying - - ChangeLog | 5 +++++ - poppler/JPXStream.cc | 2 -- - 2 files changed, 5 insertions(+), 2 deletions(-) - -commit ba4b3f88271892f197aa2ec076c80ff63a175887 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Dec 4 11:30:00 2005 +0000 - - * qt/poppler-qt.h: - * qt/poppler-fontinfo.h: - * qt4/src/poppler-qt4.h: - * qt4/src/poppler-fontinfo.cc: Implement copy constructor of - FontInfo needed - as Q[Value]List<FontInfo> uses it when appending - - ChangeLog | 8 ++++++++ - qt/poppler-fontinfo.cc | 9 +++++++++ - qt/poppler-qt.h | 2 ++ - qt4/src/poppler-fontinfo.cc | 9 +++++++++ - qt4/src/poppler-qt4.h | 2 ++ - 5 files changed, 30 insertions(+) - -commit e091231d98d12c19b0098ffbaec6ecda28097dff -Author: Brad Hards <bradh@frogmouth.net> -Date: Sun Dec 4 10:45:25 2005 +0000 - - Add new unit test to .cvsignore suppressions. - - ChangeLog | 2 ++ - qt4/tests/.cvsignore | 1 + - 2 files changed, 3 insertions(+) - -commit 6a7b1eaaedbfdd3a8e6b4d899477350f2b485641 -Author: Brad Hards <bradh@frogmouth.net> -Date: Sun Dec 4 10:05:21 2005 +0000 - - * qt4/src/poppler-qt4.h: - qt4/src/fontinfo.cc: add implementation for FontInfo::typeName() - - * qt4/tests/check_fonts.cpp: - * qt4/tests/Makefile.am: add unit test for fonts - - * qt4/src/Mainpage.dox: Minor typo fixes. - - ChangeLog | 11 +++++++++++ - qt4/src/Mainpage.dox | 5 +++-- - qt4/src/poppler-fontinfo.cc | 24 ++++++++++++++++++++++++ - qt4/src/poppler-qt4.h | 14 +++++++++++++- - qt4/tests/Makefile.am | 5 +++++ - qt4/tests/check_fonts.cpp | 42 - ++++++++++++++++++++++++++++++++++++++++++ - 6 files changed, 98 insertions(+), 3 deletions(-) - -commit 31b28b4c59f7820901e9cf893197f381acbae8ce -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sun Dec 4 02:24:25 2005 +0000 - - 2005-12-03 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc (poppler_page_set_selection_alpha): Use - Nickolays original fix instead of trying to be clever with - gdk_pixbuf_fill(). - - * poppler/CairoFontEngine.cc: Fix text corruption bug (#5149), - a rerun of an old classic (#3340). - - ChangeLog | 7 +++++++ - glib/poppler-page.cc | 8 +++++++- - poppler/CairoFontEngine.cc | 2 ++ - 3 files changed, 16 insertions(+), 1 deletion(-) - -commit 4d169c5c345cdac84a39026e759b928977643417 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sun Dec 4 01:42:29 2005 +0000 - - 2005-12-03 Kristian Høgsberg <krh@redhat.com> - - * poppler/GfxState.cc: Fixing another problem with new GfxRGB - representation causing images to show up as random pixels - (#5117). - - ChangeLog | 5 +++++ - poppler/GfxState.cc | 6 +++--- - 2 files changed, 8 insertions(+), 3 deletions(-) - -commit 58de0458e17b1639ce0bcae45a4b09b2c0a56618 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sat Dec 3 23:23:53 2005 +0000 - - 2005-12-03 Kristian Høgsberg <krh@redhat.com> - - * qt/Makefile.am (noinst_PROGRAMS): Only build qt test - program if - splash is enabled. - - * poppler/CairoOutputDev.cc: Remove unused grid snapping code, - sidestepping #4507. - - * glib/poppler-document.h (PopplerPermissions): Breaking enum - definition over multiple lines confuses glib-mkenums (#4600). - - * poppler/Makefile.am (libpoppler_la_LIBADD): Add - FREETYPE_LIBS - (#4515). - - * poppler/TextOutputDev.cc: - * qt/poppler-qt.h: GCC-4.1 fixes (#5031). - - ChangeLog | 17 +++++++++++++++++ - glib/poppler-document.h | 5 +---- - poppler/CairoOutputDev.cc | 35 +++++++++-------------------------- - poppler/CairoOutputDev.h | 2 +- - poppler/Makefile.am | 3 ++- - poppler/TextOutputDev.cc | 2 +- - qt/Makefile.am | 4 ++++ - qt/poppler-qt.h | 6 +++--- - 8 files changed, 38 insertions(+), 36 deletions(-) - -commit df45483f1437d8a96519e1428d1f4b3ffc08c2cd -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Dec 3 22:39:06 2005 +0000 - - remove another chagne should not have gone in - - test/pdf-inspector.cc | 9 ++------- - 1 file changed, 2 insertions(+), 7 deletions(-) - -commit 7dfe02ee112dee51346525b62d877e6591135761 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Dec 3 22:28:46 2005 +0000 - - Add the font retrieveing on the qt3 backend also, based on a patch - by Wilfried Huss - - ChangeLog | 3 ++ - qt/poppler-fontinfo.cc | 75 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 78 insertions(+) - -commit 655b9dd195ac9faf2f7ea0255880b8c83b249a06 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Dec 3 22:26:07 2005 +0000 - - this should have not went in - - poppler/TextOutputDev.h | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -commit ab45eb562159d5b006e658ec66723a0a47908f65 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Dec 3 22:20:54 2005 +0000 - - * qt4/src/poppler-qt4.h: - * qt4/src/poppler-fontinfo.cc: - * qt4/src/poppler-textbox.cc: Remove implementation of that classes - from the header, use pimpl - - ChangeLog | 9 ++++- - poppler/TextOutputDev.h | 10 +++--- - qt/Makefile.am | 1 + - qt/poppler-document.cc | 29 ++++++++++++++++ - qt/poppler-private.h | 2 ++ - qt/poppler-qt.h | 80 - ++++++++++++++++++++++++++++++++++++++++++++- - qt4/src/Makefile.am | 2 ++ - qt4/src/poppler-fontinfo.cc | 69 ++++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-qt4.h | 43 ++++++++++-------------- - qt4/src/poppler-textbox.cc | 49 +++++++++++++++++++++++++++ - test/pdf-inspector.cc | 9 +++-- - 11 files changed, 268 insertions(+), 35 deletions(-) - -commit 64079ad81caf6d2cf66b1f3a3de9454146e15c6c -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sat Dec 3 21:55:36 2005 +0000 - - 2005-12-03 Kristian Høgsberg <krh@redhat.com> - - Fixes from Nickolay V. Shmyrev: - - * poppler/TextOutputDev.cc (TextLine::visitSelection, - TextBlock::visitSelection): Fix selection crash with - zero-width - word boxes or zero-height line boxes (#4402). - - * poppler/CairoOutputDev.h: Fix wrong cairo-ft.h include - (#4413). - - * poppler/CairoOutputDev.cc (eoFill, fill): - * glib/poppler-page.cc (poppler_page_render_selection): - Update to - work with new GfxColor definition and use - cairo_pattern_create_rgba() to cache cairo_pattern_t's for the - fill and stroke colors. - - * glib/poppler-page.cc (poppler_page_set_selection_alpha): - Zero - out pixbuf first. - - ChangeLog | 21 +++++++++++++++++ - glib/poppler-page.cc | 18 +++++++++------ - poppler/CairoOutputDev.cc | 59 - ++++++++++++++++++++++++++++++++++------------- - poppler/CairoOutputDev.h | 6 ++--- - poppler/TextOutputDev.cc | 8 +++---- - 5 files changed, 82 insertions(+), 30 deletions(-) - -commit f3da21a3ecdd2694290e64af86c8e35fcb61371b -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Dec 3 21:35:45 2005 +0000 - - More docs for the Qt4 frontend, patch by Stefan Kebekus - - ChangeLog | 8 ++++ - qt4/src/.cvsignore | 3 +- - qt4/src/Doxyfile | 4 +- - qt4/src/Mainpage.dox | 91 - ++++++++++++++++++++++++++++++++++++++++++ - qt4/src/poppler-page.cc | 20 +++------- - qt4/src/poppler-qt4.h | 57 ++++++++++++++++++-------- - qt4/tests/test-poppler-qt4.cpp | 5 ++- - 7 files changed, 151 insertions(+), 37 deletions(-) - -commit 7b2c6e92611db9350ca5dcaf3fd730fe5e69afea -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Dec 1 22:45:10 2005 +0000 - - Fix CAN-2005-3193 related bugs - Thanks Leonard for reporting - - ChangeLog | 6 ++++++ - poppler/JPXStream.cc | 9 ++++++++- - poppler/Stream.cc | 33 ++++++++++++++++++++++++++++++++- - poppler/Stream.h | 3 +++ - 4 files changed, 49 insertions(+), 2 deletions(-) - -commit a90f076af9ebb188895e7b223bcb7e5c3f4309c4 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Nov 28 22:50:19 2005 +0000 - - Fix QPixmap contents generation messed when doing the xpdf 3.01 - transition in qt4 frontend - Use Splash backend by default in the qt4 test, added -arthur option - to use the Arthur backend - - ChangeLog | 12 ++++++++-- - qt4/src/poppler-page.cc | 47 ++++++++++++++++++++++++++++--------- - qt4/src/poppler-qt4.h | 17 ++++++++++---- - qt4/tests/test-poppler-qt4.cpp | 53 - ++++++++++++++++++++++++++---------------- - 4 files changed, 91 insertions(+), 38 deletions(-) - -commit b7e4f0e7d175abde7fafb1fcc7ba129468bc8c1a -Author: Brad Hards <bradh@frogmouth.net> -Date: Sun Nov 27 01:33:51 2005 +0000 - - Convert Qt4 unit tests to use the new Qt4.1 QTestlib framework. - Add a little more API documentation - - ChangeLog | 7 +++++ - qt4/src/poppler-qt4.h | 11 +++++--- - qt4/tests/Makefile.am | 12 ++++++--- - qt4/tests/check_metadata.cpp | 58 - ++++++++++++++++++++--------------------- - qt4/tests/check_pagelayout.cpp | 14 +++++----- - qt4/tests/check_pagemode.cpp | 22 ++++++++-------- - qt4/tests/check_permissions.cpp | 18 ++++++------- - 7 files changed, 78 insertions(+), 64 deletions(-) - -commit d036fa022dbb6f4421ccc8b12b8f9e4f0c8d7406 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Nov 25 22:52:56 2005 +0000 - - patch from kebekus to add to the qt4 binding the same functions we - added to the qt3 one - - ChangeLog | 5 +++++ - qt4/src/poppler-page.cc | 44 ++++++++++++++++++++++++++++++++++++++++++-- - qt4/src/poppler-qt4.h | 22 ++++++++++++++++++++++ - 3 files changed, 69 insertions(+), 2 deletions(-) - -commit 3c9f09d76dc70e4ba766930facee8b6f30bcd2da -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Nov 22 21:50:44 2005 +0000 - - Fix page range in the inspector - - ChangeLog | 4 ++++ - test/pdf-inspector.cc | 2 +- - 2 files changed, 5 insertions(+), 1 deletion(-) - -commit e64f63416dbce497cb2167272b95491664f213e8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Nov 21 22:12:15 2005 +0000 - - PAtch to add some more functions to the qt binding by Stefan Kebekus - - ChangeLog | 5 ++++ - qt/poppler-page.cc | 69 - +++++++++++++++++++++++++++++++++++++++++++++++++++++- - qt/poppler-qt.h | 41 ++++++++++++++++++++++++++++++++ - 3 files changed, 114 insertions(+), 1 deletion(-) - -commit 8bd8cb4160b73da69d058783750352fbface66dc -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Nov 21 19:44:09 2005 +0000 - - Fix a possible build problem - - ChangeLog | 4 ++++ - qt/Makefile.am | 1 + - 2 files changed, 5 insertions(+) - -commit fc59b79dc375544681032a1618e96c458515d724 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sun Nov 20 23:17:32 2005 +0000 - - 2005-11-20 Kristian Høgsberg <krh@redhat.com> - - * poppler/GfxState.cc: Fix the byte_lookup initialization - broken - by the merges (#4350). Modify GfxColorSpace::getRGBLine() - to work - with new GfXColor type. - - ChangeLog | 13 +++++++++++- - poppler/GfxState.cc | 59 - +++++++++++++++++++++++++++++++---------------------- - 2 files changed, 47 insertions(+), 25 deletions(-) - -commit 6fe2cb0fcd53211143dcd0c47bf8c8c7a8c11a39 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Nov 17 21:37:34 2005 +0000 - - make it compile with freetype 2.2.0 preversions - - ChangeLog | 4 ++++ - splash/SplashFTFont.cc | 42 +++++++++++++++++++++++++++++++++++++----- - 2 files changed, 41 insertions(+), 5 deletions(-) - -commit 429d3521d788be702a3944bc290569f90ae04892 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Nov 4 19:03:55 2005 +0000 - - Make it compile using --disable-cairo-output - - ChangeLog | 4 ++++ - glib/poppler-document.cc | 6 ++++-- - glib/poppler-page.cc | 27 +++++++++++++-------------- - 3 files changed, 21 insertions(+), 16 deletions(-) - -commit b96c118eb08d478914c2981204d749a95957cbb3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Nov 1 15:29:32 2005 +0000 - - Comment some unused parameters to calm down compiler warnings when - using these heders on external projects with higher warning verbosity - - ChangeLog | 5 +++ - poppler/OutputDev.h | 125 - ++++++++++++++++++++++++++-------------------------- - poppler/Stream.h | 24 +++++----- - 3 files changed, 80 insertions(+), 74 deletions(-) - -commit 51670972777510a3ec64a56649716b31167b9d0e -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Oct 30 20:29:05 2005 +0000 - - Last xpdf 3.01 merge (at least from my side) - It's very big, but noone has opposed in the 2 weeks time i gave on - the ml so either poppler is dead or people agree with the patch - - ChangeLog | 39 + - glib/poppler-page.cc | 32 +- - poppler/ArthurOutputDev.cc | 2 +- - poppler/ArthurOutputDev.h | 2 +- - poppler/CairoOutputDev.cc | 2 +- - poppler/CairoOutputDev.h | 2 +- - poppler/Gfx.cc | 645 +++++++++-- - poppler/Gfx.h | 17 +- - poppler/GfxState.cc | 1410 ++++++++++++++++++++--- - poppler/GfxState.h | 196 +++- - poppler/OutputDev.cc | 25 + - poppler/OutputDev.h | 46 +- - poppler/PDFDoc.cc | 98 +- - poppler/PDFDoc.h | 24 +- - poppler/PSOutputDev.cc | 1461 ++++++++++++++++++++---- - poppler/PSOutputDev.h | 48 +- - poppler/Page.cc | 115 +- - poppler/Page.h | 23 +- - poppler/SplashOutputDev.cc | 1525 ++++++++++++++++++++++--- - poppler/SplashOutputDev.h | 59 +- - poppler/TextOutputDev.cc | 230 ++-- - poppler/TextOutputDev.h | 16 +- - qt/poppler-page.cc | 34 +- - qt4/src/poppler-page.cc | 31 +- - splash/Splash.cc | 2656 - +++++++++++++++++++++++++++++++++----------- - splash/Splash.h | 75 +- - splash/SplashBitmap.cc | 216 ++-- - splash/SplashBitmap.h | 13 +- - splash/SplashPattern.cc | 22 +- - splash/SplashPattern.h | 19 +- - splash/SplashState.cc | 11 + - splash/SplashState.h | 3 + - splash/SplashTypes.h | 145 ++- - test/gtk-cairo-test.cc | 2 +- - test/gtk-splash-test.cc | 23 +- - test/pdf-inspector.cc | 2 +- - 36 files changed, 7685 insertions(+), 1584 deletions(-) - -commit 10dfa2254dafb9de93692def2bfb3133d9a39989 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Oct 17 02:17:51 2005 +0000 - - 2005-10-05 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc (poppler_page_render_to_ps): - Fix another - off-by-one page number error (#4555). - - ChangeLog | 6 +++++- - poppler/poppler-config.h.in | 2 +- - 2 files changed, 6 insertions(+), 2 deletions(-) - -commit 9830f0ea41f09fefada740e9429c491e067a5082 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Oct 16 15:11:32 2005 +0000 - - GfxFont merges from xpdf 3.01 - - ChangeLog | 1 + - poppler/GfxFont.cc | 109 - ++++++++++++++++++++++++++++++++++++----------------- - 2 files changed, 75 insertions(+), 35 deletions(-) - -commit 62b5ba221aca8c320e964916b0c0329efc8da572 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Oct 16 15:04:39 2005 +0000 - - Stream[cc|h] merges from xpdf 3.01 - - ChangeLog | 1 + - poppler/Stream.cc | 714 - +++++++++++++++++++++++++++++++++++++++++++++++++----- - poppler/Stream.h | 19 +- - 3 files changed, 658 insertions(+), 76 deletions(-) - -commit b9fab51179f38e9798b10366be672f0432c874da -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Oct 16 14:58:14 2005 +0000 - - Function.cc|h merges from xpdf 3.01 - - ChangeLog | 1 + - poppler/Function.cc | 76 - ++++++++++++++++++++++++++++++----------------------- - poppler/Function.h | 42 +++++++++++++++++++++++++++++ - 3 files changed, 86 insertions(+), 33 deletions(-) - -commit c6e0242200f818c67508041763ff317e79daadd6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Oct 16 14:54:17 2005 +0000 - - Annot.[cc|h] and related merges from xpdf 3.01 - - ChangeLog | 7 +- - poppler/Annot.cc | 234 - +++++++++++++++++++++++++++++++++++++++++++------ - poppler/Annot.h | 20 ++--- - poppler/FontInfo.cc | 2 +- - poppler/PSOutputDev.cc | 2 +- - poppler/Page.cc | 2 +- - 6 files changed, 221 insertions(+), 46 deletions(-) - -commit 65d574fdc009e45ad66d1d402d5e805e4e94f427 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Oct 16 14:30:16 2005 +0000 - - Merge SplashFTFont.cc with xpdf 3.01 changes - - ChangeLog | 1 + - splash/SplashFTFont.cc | 64 - ++++++++++++++++++++++++++++++++++---------------- - 2 files changed, 45 insertions(+), 20 deletions(-) - -commit f9d208e86433b213b21a75089f82fd00dcd746fc -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Oct 16 14:25:32 2005 +0000 - - Merge SplashScreen.[cc|h] from xpdf 3.01 - - ChangeLog | 4 ++ - splash/SplashScreen.cc | 110 - ++++++++++++++++++++++++++++++++----------------- - splash/SplashScreen.h | 12 +++++- - 3 files changed, 87 insertions(+), 39 deletions(-) - -commit 7d46ac000316566503a27b5e5c68621be9c081d0 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Oct 16 14:19:47 2005 +0000 - - Merging SplashXPathScanner.cc changes from xpdf 3.01 - - splash/SplashXPathScanner.cc | 80 - ++++++++++++++++++++++++-------------------- - 1 file changed, 43 insertions(+), 37 deletions(-) - -commit e34713a2187e05358f98e749ec2923210a40a862 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed Oct 5 15:57:17 2005 +0000 - - 2005-10-05 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc (poppler_page_render_to_ps): - Fix another - off-by-one page number error (#4555). - - ChangeLog | 5 +++++ - glib/poppler-page.cc | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit fdd0934430ed251f9aeb45158b6ec95684b3e7b4 -Author: Marco Pesenti Gritti <mpg@redhat.com> -Date: Mon Sep 26 19:29:45 2005 +0000 - - 2005-09-26 Marco Pesenti Gritti <mpg@redhat.com> - - * glib/poppler-action.cc: - - Initialize window title even if the action is unknown - - ChangeLog | 6 ++++++ - glib/poppler-action.cc | 5 +++-- - 2 files changed, 9 insertions(+), 2 deletions(-) - -commit e9753049ddfbdf28df7a222d35eccdbcbcbc848d -Author: Marco Pesenti Gritti <mpg@redhat.com> -Date: Mon Sep 26 10:42:38 2005 +0000 - - 2005-09-26 Marco Pesenti Gritti <mpg@redhat.com> - - * glib/poppler-action.cc: - * glib/poppler-action.h: - - Implement launch action - - ChangeLog | 7 +++++++ - glib/poppler-action.cc | 11 ++++++++--- - glib/poppler-action.h | 1 + - 3 files changed, 16 insertions(+), 3 deletions(-) - -commit ab18b2cb6d1c62bb91173d105e8631fe4ef1bcfb -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 20 15:27:31 2005 +0000 - - Parser.cc merges from xpdf 3.01 - - ChangeLog | 1 + - poppler/Parser.cc | 19 +++++++++++-------- - 2 files changed, 12 insertions(+), 8 deletions(-) - -commit cf6723caaed24615c3b8965cee9c433007f80d77 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 20 15:08:52 2005 +0000 - - TextPage *TextOutpudDev::takeText() from xpdf 3.01 - - ChangeLog | 1 + - poppler/TextOutputDev.cc | 8 ++++++++ - poppler/TextOutputDev.h | 4 ++++ - 3 files changed, 13 insertions(+) - -commit e0cbb0ca2c611ad5ac0267e46279c9d61450902a -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 20 14:59:43 2005 +0000 - - more 3.00 -> 3.01 merging - - ChangeLog | 1 + - poppler/XRef.cc | 1 - - 2 files changed, 1 insertion(+), 1 deletion(-) - -commit 9c7adb318d395ff674c6febf6406a8d47e9e5bf6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 20 14:43:15 2005 +0000 - - * poppler/UnicodeMap.cc: More grealloc -> greallocn - * poppler/UnicodeTypeTable.cc: Merge from xpdf 3.01 - - ChangeLog | 2 ++ - poppler/UnicodeMap.cc | 4 ++-- - poppler/UnicodeTypeTable.cc | 4 ++-- - 3 files changed, 6 insertions(+), 4 deletions(-) - -commit 2c4c9b855b0df1dc0836d4f44e9471215a419ea6 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 20 14:34:31 2005 +0000 - - Merge link.cc changes from xpdf 3.00 -> 3.01 - - ChangeLog | 1 + - poppler/Link.cc | 64 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- - 2 files changed, 62 insertions(+), 3 deletions(-) - -commit 4e9490c0219dd9c99ba0e5533c96663b8570a87b -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Sep 20 14:00:43 2005 +0000 - - Merge GlobalParam.* changes, they are worthless for us as poppler - but this way we are nearer to have the 3.01 sources merged, then we - can remove them if we decide we don't need this options. - Remove a setEncryption from the Xref.h marco probably forgot to - remove when merging - - ChangeLog | 3 +++ - poppler/GlobalParams.cc | 41 +++++++++++++++++++++++++++++++++++++++++ - poppler/GlobalParams.h | 22 ++++++++++++++++------ - poppler/XRef.h | 4 ---- - 4 files changed, 60 insertions(+), 10 deletions(-) - -commit 22da021bf69d83d641e3f30cc0e1bd62394e56a4 -Author: Marco Pesenti Gritti <mpg@redhat.com> -Date: Tue Sep 20 13:23:08 2005 +0000 - - 2005-09-20 Marco Pesenti Gritti <mpg@redhat.com> - - * poppler/XRef.cc: - - Remove duplicated initialization - - ChangeLog | 6 ++++++ - poppler/XRef.cc | 4 ---- - 2 files changed, 6 insertions(+), 4 deletions(-) - -commit 2a8778147938e3ed2af177226a9c35655f898c95 -Author: Marco Pesenti Gritti <mpg@redhat.com> -Date: Tue Sep 20 10:18:57 2005 +0000 - - 2005-09-20 Marco Pesenti Gritti <mpg@redhat.com> - - * poppler/GlobalParams.cc: - - s/G/Goo in not yet compiled plugins code - - ChangeLog | 6 ++++++ - poppler/GlobalParams.cc | 8 ++++---- - 2 files changed, 10 insertions(+), 4 deletions(-) - -commit 16f720b87cfc491db585dbdc99236cf492ffe85b -Author: Marco Pesenti Gritti <mpg@redhat.com> -Date: Tue Sep 20 09:57:41 2005 +0000 - - 2005-09-20 Marco Pesenti Gritti <mpg@redhat.com> - - * poppler/Makefile.am: - - Add XPDFPlugin*. Thanks to TSDgeos that noticed this. - - * poppler/XpdfPluginAPI.cc: - - Fixup - - ChangeLog | 10 ++++++++++ - poppler/Makefile.am | 4 +++- - poppler/XpdfPluginAPI.cc | 2 +- - 3 files changed, 14 insertions(+), 2 deletions(-) - -commit 5f30791c3d87315ad1f742de64d2c1351ca70cb7 -Author: Marco Pesenti Gritti <mpg@redhat.com> -Date: Fri Sep 16 19:33:28 2005 +0000 - - *** empty log message *** - - ChangeLog | 9 +++++++++ - 1 file changed, 9 insertions(+) - -commit db62e07fcf57f45951b21f8aab44b0d943efe5d0 -Author: Marco Pesenti Gritti <mpg@redhat.com> -Date: Fri Sep 16 19:33:05 2005 +0000 - - 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> - - * poppler/PDFDoc.cc: - * poppler/PDFDoc.h: - * poppler/XRef.cc: - * poppler/XRef.h: - - Merge more from 3.01 - - poppler/PDFDoc.cc | 20 ++++++++++++++++---- - poppler/PDFDoc.h | 19 +++++++++---------- - poppler/XRef.cc | 13 +++++++++++-- - poppler/XRef.h | 7 +++++-- - 4 files changed, 41 insertions(+), 18 deletions(-) - -commit 3acc7be594712fd0ce7ac07b7188d5b38b382782 -Author: Marco Pesenti Gritti <mpg@redhat.com> -Date: Fri Sep 16 19:05:00 2005 +0000 - - 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> - - * poppler/XRef.cc: - - Merge some initialization that I lost before - - ChangeLog | 6 ++++++ - poppler/XRef.cc | 4 ++++ - 2 files changed, 10 insertions(+) - -commit 3badd82b72b2768be27e309b048cd8dcb1c80038 -Author: Marco Pesenti Gritti <mpg@redhat.com> -Date: Fri Sep 16 18:46:37 2005 +0000 - - 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> - - * poppler/XRef.cc: - - Merge change from 3.01 - - ChangeLog | 6 ++++++ - poppler/XRef.cc | 8 -------- - 2 files changed, 6 insertions(+), 8 deletions(-) - -commit 5474583e20ca773befa17242d4ad7b8f81d5bf99 -Author: Marco Pesenti Gritti <mpg@redhat.com> -Date: Fri Sep 16 18:38:58 2005 +0000 - - 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> - - * poppler/CharCodeToUnicode.cc: - * poppler/CharCodeToUnicode.h: - - Improvements from xpdf 3.01 - - ChangeLog | 7 +++++++ - poppler/CharCodeToUnicode.cc | 31 +++++++++++++++++++------------ - poppler/CharCodeToUnicode.h | 4 ++++ - 3 files changed, 30 insertions(+), 12 deletions(-) - -commit b2a6eab113fecd3823885c64f3302bea4f372a9f -Author: Marco Pesenti Gritti <mpg@redhat.com> -Date: Fri Sep 16 18:37:29 2005 +0000 - - 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> - - * poppler/CMap.cc: - - Improvements from xpdf 3.01 - - ChangeLog | 6 ++++++ - poppler/CMap.cc | 30 +++++++++++++++++++++++++++--- - 2 files changed, 33 insertions(+), 3 deletions(-) - -commit 3f69f2158453b9dab9efc280ed1578ac3d0cebe8 -Author: Marco Pesenti Gritti <mpg@redhat.com> -Date: Fri Sep 16 18:35:29 2005 +0000 - - 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> - - * poppler/NameToUnicodeTable.h: - * poppler/UnicodeTypeTable.cc: - * poppler/UnicodeTypeTable.h: - - Merge some unicode table changes from xpdf 3.01 - - ChangeLog | 8 + - poppler/NameToUnicodeTable.h | 168 +++++------ - poppler/UnicodeTypeTable.cc | 690 - +++++++++++++++++++++++++++++++++++++++++-- - poppler/UnicodeTypeTable.h | 2 + - 4 files changed, 764 insertions(+), 104 deletions(-) - -commit 6cbe76bc55d557fe5fca0f8f1b33bda95acdc0e9 -Author: Marco Pesenti Gritti <mpg@redhat.com> -Date: Fri Sep 16 18:32:29 2005 +0000 - - 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> - - * poppler/SplashOutputDev.h: - * splash/Splash.cc: - * splash/Splash.h: - - Modified region support from xpdf 3.01 - - ChangeLog | 8 ++++++++ - poppler/SplashOutputDev.h | 5 +++++ - splash/Splash.cc | 31 +++++++++++++++++++++++++++++++ - splash/Splash.h | 11 +++++++++++ - 4 files changed, 55 insertions(+) - -commit a9df3f3203c14161e5d6bc6048ec7e123536e6d3 -Author: Marco Pesenti Gritti <mpg@redhat.com> -Date: Fri Sep 16 18:29:18 2005 +0000 - - 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> - - * goo/Makefile.am: - * poppler/DCTStream.h: - * poppler/Decrypt.cc: - * poppler/Decrypt.h: - * poppler/FlateStream.h: - * poppler/GlobalParams.cc: - * poppler/GlobalParams.h: - * poppler/Makefile.am: - * poppler/PDFDoc.cc: - * poppler/PDFDoc.h: - * poppler/Parser.cc: - * poppler/Parser.h: - * poppler/Stream.cc: - * poppler/Stream.h: - * poppler/XRef.cc: - * poppler/XRef.h: - * poppler/poppler-config.h.in: - - Merge security plugins support from xpdf 3.01 - - ChangeLog | 24 +++ - goo/FixedPoint.cc | 95 +++++++++++ - goo/FixedPoint.h | 150 ++++++++++++++++++ - goo/Makefile.am | 6 +- - poppler/DCTStream.h | 2 - - poppler/Decrypt.cc | 23 ++- - poppler/Decrypt.h | 6 +- - poppler/FlateStream.h | 2 - - poppler/GlobalParams.cc | 229 +++++++++++++++++++++++++++ - poppler/GlobalParams.h | 16 ++ - poppler/Makefile.am | 5 +- - poppler/PDFDoc.cc | 36 +++++ - poppler/PDFDoc.h | 1 + - poppler/Parser.cc | 20 --- - poppler/Parser.h | 4 - - poppler/SecurityHandler.cc | 376 - ++++++++++++++++++++++++++++++++++++++++++++ - poppler/SecurityHandler.h | 157 ++++++++++++++++++ - poppler/Stream.cc | 18 --- - poppler/Stream.h | 8 - - poppler/XRef.cc | 162 ++----------------- - poppler/XRef.h | 13 +- - poppler/XpdfPluginAPI.cc | 262 ++++++++++++++++++++++++++++++ - poppler/XpdfPluginAPI.h | 341 +++++++++++++++++++++++++++++++++++++++ - poppler/poppler-config.h.in | 2 - - 24 files changed, 1737 insertions(+), 221 deletions(-) - -commit a777e5c26483b90d0910e85c2be666640835d0bf -Author: Marco Pesenti Gritti <mpg@redhat.com> -Date: Fri Sep 16 18:21:38 2005 +0000 - - 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> - - * configure.ac: - * goo/Makefile.am: - * splash/Makefile.am: - * splash/SplashFTFont.cc: - * splash/SplashMath.h: - * splash/SplashTypes.h: - - Merge support for fixed point - - ChangeLog | 11 +++++++++++ - configure.ac | 4 ++++ - splash/Makefile.am | 1 + - splash/SplashFTFont.cc | 7 +++++++ - splash/SplashMath.h | 34 +++++++++++++++++++++++++++++++++- - splash/SplashTypes.h | 5 +++++ - 6 files changed, 61 insertions(+), 1 deletion(-) - -commit 00457c5f44a246c9f867a114a72be9f7b2dc1cf5 -Author: Marco Pesenti Gritti <mpg@redhat.com> -Date: Fri Sep 16 18:11:14 2005 +0000 - - 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> - - * poppler/ArthurOutputDev.cc: - * poppler/CairoFontEngine.cc: - * poppler/TextOutputDev.cc: - * poppler/UnicodeMap.cc: - - Use mallocn when possible - - ChangeLog | 9 +++++++++ - poppler/ArthurOutputDev.cc | 2 +- - poppler/CairoFontEngine.cc | 4 ++-- - poppler/TextOutputDev.cc | 2 +- - poppler/UnicodeMap.cc | 2 +- - 5 files changed, 14 insertions(+), 5 deletions(-) - -commit 09c9ff67ceae5753811a2f625e3ad810628c782e -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Sep 16 18:00:43 2005 +0000 - - SplashXPath.cc merges from xpdf 3.00 -> 3.01 - - ChangeLog | 3 ++ - splash/SplashXPath.cc | 81 - +++++++++++++++++++++++++-------------------------- - 2 files changed, 42 insertions(+), 42 deletions(-) - -commit 0555ba861d3b84d88c80da4fa247274338ff7817 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Sep 16 17:42:56 2005 +0000 - - SplashFontEngine.cc merge from xpdf 3.00 -> 3.01 - - splash/SplashFontEngine.cc | 8 ++++++++ - 1 file changed, 8 insertions(+) - -commit ddc72bd8354168d992631d1ef8cd0939b428966c -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Sep 15 22:24:55 2005 +0000 - - Merge xpdf 3.00 -> 3.01 changes in SplashT1Font.* files - - splash/SplashT1Font.cc | 23 ++++++++++++++++++----- - splash/SplashT1Font.h | 2 ++ - 2 files changed, 20 insertions(+), 5 deletions(-) - -commit ba409db3157105f326b4bbc342ca7af859a44ce9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Sep 15 22:20:37 2005 +0000 - - Merge xpdf 3.00 -> 3.01 changes in SplashPath.* files - - splash/SplashPath.cc | 3 ++- - splash/SplashPath.h | 5 +++++ - 2 files changed, 7 insertions(+), 1 deletion(-) - -commit 3ea00e853049d8c26ee88aaef8ea6c47c8d46956 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Sep 15 22:15:47 2005 +0000 - - Merge xpdf 3.00 -> 3.01 changes in SplashFont.* files - - splash/SplashFont.cc | 6 ++++++ - splash/SplashFont.h | 10 +++++++++- - 2 files changed, 15 insertions(+), 1 deletion(-) - -commit e571dcbfd0c77a28e41710577859f632cc989de5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Sep 15 22:09:50 2005 +0000 - - Merge the xpdf 3.01 change that uses runtime detection of freetype - version - - ChangeLog | 6 ++++++ - configure.ac | 14 +++----------- - poppler/CairoFontEngine.cc | 21 ++++++++++++++------- - poppler/CairoFontEngine.h | 3 ++- - splash/SplashFTFontEngine.cc | 19 +++++++++++-------- - splash/SplashFTFontEngine.h | 1 + - 6 files changed, 37 insertions(+), 27 deletions(-) - -commit 59fe2937db192dc7b59bf28c3f29909faf11aae3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Sep 15 21:51:16 2005 +0000 - - Merge xpdf 3.00 -> 3.01 changes for that file - - splash/SplashClip.h | 9 +++++++++ - 1 file changed, 9 insertions(+) - -commit b2f94635249f2c5f0c876a1005826fe4c6eb6025 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Sep 15 12:52:36 2005 +0000 - - Merge xpdf 3.00 -> xpdf 3.01 changes for Catalog.[cc|h] - - poppler/Catalog.cc | 5 ++++- - poppler/Catalog.h | 3 +++ - 2 files changed, 7 insertions(+), 1 deletion(-) - -commit 0fc2e70576b1c48cf47a686e8aa7e202a802bc9d -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Sep 15 12:32:25 2005 +0000 - - Another small merge from xpdf 3.01 - - ChangeLog | 3 +++ - poppler/Outline.cc | 6 +++--- - 2 files changed, 6 insertions(+), 3 deletions(-) - -commit f8983ceb3c55df72c94870806d71db139c11bdeb -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Sep 15 12:28:34 2005 +0000 - - Another small xpdf 3.00 -> xpdf 3.01 merge - - poppler/Object.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 52efe9845cf3eb1dd836f90bfa203760baa2f87c -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Sep 15 11:46:56 2005 +0000 - - bradh forgot to remove the two returns when merging xpdf 3.00 -> - xpdf 3.01 changes of this file - - poppler/JPXStream.cc | 2 -- - 1 file changed, 2 deletions(-) - -commit 4b4fc5c017bf147c9069bbce32fc14467bd2a81a -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Sep 14 21:20:36 2005 +0000 - - Merge all the fofi/ changes from xpdf 3.01, there is only one api - change that affects PSOutputDev (also has been updated the part - that uses this api not the whole file). All our fixes in that dir - are included in the upgrade. - - ChangeLog | 4 + - fofi/FoFiTrueType.cc | 406 - +++++++++++++++++++++++++++++++++++++++++++------ - fofi/FoFiTrueType.h | 15 +- - fofi/FoFiType1.cc | 25 ++- - fofi/FoFiType1C.cc | 134 +++++++++++++--- - fofi/FoFiType1C.h | 6 + - poppler/PSOutputDev.cc | 7 +- - poppler/PSOutputDev.h | 3 +- - 8 files changed, 515 insertions(+), 85 deletions(-) - -commit a68e8e6330418b1f623867973b9c128a9a139c0c -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed Sep 7 03:00:36 2005 +0000 - - 2005-09-06 Kristian Høgsberg <krh@redhat.com> - - * configure.ac: Enable A4_PAPER and OPI_SUPPORT by default. - There - is no reason to not enable OPI and the paper size should be - controlled by the application. - - * test/Makefile.am (EXTRA_DIST): Add pdf-operators.c - - ChangeLog | 8 ++++++++ - configure.ac | 17 ++--------------- - test/Makefile.am | 3 +++ - 3 files changed, 13 insertions(+), 15 deletions(-) - -commit b6490944c081ff53f623acea7ab7a600c3e54816 -Author: Brad Hards <bradh@frogmouth.net> -Date: Sat Sep 3 11:53:44 2005 +0000 - - Switch the qt4/tests unittests to use QtTestLib. - - ChangeLog | 6 ++ - configure.ac | 66 +++++++++++++++++++++ - qt4/tests/.cvsignore | 17 ++---- - qt4/tests/Makefile.am | 71 ++++++++-------------- - qt4/tests/README.unittest | 23 ++++++++ - qt4/tests/check_author.cpp | 25 -------- - qt4/tests/check_linearised.cpp | 23 -------- - qt4/tests/check_metadata.cpp | 101 - ++++++++++++++++++++++++++++++++ - qt4/tests/check_orientation.cpp | 40 ------------- - qt4/tests/check_pagelayout.cpp | 44 ++++++++++++++ - qt4/tests/check_pagelayout_facing.cpp | 22 ------- - qt4/tests/check_pagelayout_none.cpp | 22 ------- - qt4/tests/check_pagelayout_single.cpp | 22 ------- - qt4/tests/check_pagemode.cpp | 64 ++++++++++++++++++++ - qt4/tests/check_pagemode_attach.cpp | 22 ------- - qt4/tests/check_pagemode_fullscreen.cpp | 22 ------- - qt4/tests/check_pagemode_none.cpp | 22 ------- - qt4/tests/check_pagemode_oc.cpp | 22 ------- - qt4/tests/check_pagemode_thumbs.cpp | 22 ------- - qt4/tests/check_permissions.cpp | 60 +++++++------------ - 20 files changed, 354 insertions(+), 362 deletions(-) - -commit 3725841417871d1051772068833dc908ca70b7ce -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Sep 2 14:47:24 2005 +0000 - - 2005-09-02 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc: Apply Marcos rotation fix. - - ChangeLog | 4 ++++ - glib/poppler-page.cc | 5 ++++- - 2 files changed, 8 insertions(+), 1 deletion(-) - -commit ecf3dcadb948013cbc987e464952933daf78e4bf -Author: Brad Hards <bradh@frogmouth.net> -Date: Wed Aug 31 15:28:46 2005 +0000 - - Merge some missing parts of previous patches, and some other minor - cleanups from xpdf 3.0.1 - - poppler/Catalog.cc | 16 +-- - poppler/JPXStream.cc | 380 - +++++++++++++++++++++++++++++++++---------------- - poppler/JPXStream.h | 25 ++-- - poppler/Lexer.cc | 11 ++ - poppler/Lexer.h | 3 + - poppler/PSOutputDev.cc | 31 ++-- - poppler/Stream.h | 7 + - 7 files changed, 309 insertions(+), 164 deletions(-) - -commit de78738164319b733e54a9abfb5957870facd6cd -Author: Brad Hards <bradh@frogmouth.net> -Date: Wed Aug 31 09:51:41 2005 +0000 - - poppler/JArithmeticDecoder.cc - poppler/JArithmeticDecoder.h - poppler/JBIG2Stream.cc - poppler/JBIG2Stream.h: merge in some of the JBIG2 changes from - xpdf 3.0.1. - - ChangeLog | 9 ++ - poppler/JArithmeticDecoder.cc | 42 ++++++-- - poppler/JArithmeticDecoder.h | 22 +++- - poppler/JBIG2Stream.cc | 227 - +++++++++++++++++++++++++----------------- - poppler/JBIG2Stream.h | 4 +- - 5 files changed, 201 insertions(+), 103 deletions(-) - -commit 55952feb637e300b073691ae95d68e766521a769 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Aug 29 15:24:32 2005 +0000 - - 2005-08-29 Kristian Høgsberg <krh@redhat.com> - - * configure.ac (HAVE_FREETYPE_H): Patch from Hiroyuki - Ikezoe: Set - HAVE_FREETYPE_217_OR_OLDER to 0 if we found freetype using - pkg-config (#4223). - - ChangeLog | 6 ++++++ - configure.ac | 2 +- - 2 files changed, 7 insertions(+), 1 deletion(-) - -commit 244e5c1f8f65da41ba6314028766dfe5973f6132 -Author: Brad Hards <bradh@frogmouth.net> -Date: Sun Aug 28 09:43:18 2005 +0000 - - Merge the Goo* improvements from xpdf 3.0.1. This change is based on - martink's work (7-xpdf-3.01-goo-improvements.patch), with some - tweaking - by me. - - ChangeLog | 13 ++++++++ - fofi/FoFiTrueType.cc | 1 + - goo/GooHash.cc | 24 +++++++++++++++ - goo/GooHash.h | 2 ++ - goo/GooList.cc | 5 ++++ - goo/GooList.h | 5 ++++ - goo/GooString.cc | 85 - +++++++++++++++++++++++++++++++++++++++++++++++++++- - goo/GooString.h | 11 +++---- - goo/gmem.c | 3 ++ - poppler/Decrypt.cc | 1 + - 10 files changed, 142 insertions(+), 8 deletions(-) - -commit eb91b274245b4f5f5389bc9ddfde2c2806557665 -Author: Brad Hards <bradh@frogmouth.net> -Date: Sun Aug 28 09:31:53 2005 +0000 - - This part of my previous gmallocn merge patch was missing. - - goo/GooHash.cc | 4 ++-- - goo/GooList.cc | 8 ++++---- - 2 files changed, 6 insertions(+), 6 deletions(-) - -commit b3474fd5e0efc96b5814d86e0cdedf39387e7ae3 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sun Aug 28 03:26:53 2005 +0000 - - add note about related bug - - ChangeLog | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit ace2eb6ba518b970b96f30f61c4795c161e0cb79 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sun Aug 28 03:22:04 2005 +0000 - - 2005-08-27 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/FlateStream.cc: Fix predictor leak. - - ChangeLog | 4 ++++ - poppler/FlateStream.cc | 1 + - 2 files changed, 5 insertions(+) - -commit 96657c5480bf2ecf445ad5a105b8e7393ae53c8b -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sun Aug 28 03:19:55 2005 +0000 - - 2005-08-27 Jeff Muizelaar <jeff@infidigm.net> - - * configure.ac: Disable the zlib-based decoder by default. - - ChangeLog | 4 ++++ - configure.ac | 2 +- - 2 files changed, 5 insertions(+), 1 deletion(-) - -commit d1d715158223c7ca3ae279cea420a948cfdb0428 -Author: Brad Hards <bradh@frogmouth.net> -Date: Sat Aug 27 08:43:42 2005 +0000 - - Merge the gmalloc -> gmallocn changes from xpdf 3.0.1. This change is - based on martink's work (13-xpdf-3.01-goo-allocn.patch) with some - tweaking by me. There may be some residual gmallocn changes still to - be merged. - - ChangeLog | 7 ++++++ - fofi/FoFiTrueType.cc | 12 +++++----- - fofi/FoFiType1.cc | 2 +- - fofi/FoFiType1C.cc | 14 +++++------ - goo/gmem.c | 22 ++++++++++++++++++ - goo/gmem.h | 9 ++++++++ - poppler/Annot.cc | 2 +- - poppler/Array.cc | 2 +- - poppler/BuiltinFont.cc | 2 +- - poppler/CMap.cc | 6 ++--- - poppler/Catalog.cc | 8 +++---- - poppler/CharCodeToUnicode.cc | 22 +++++++++--------- - poppler/Dict.cc | 2 +- - poppler/Function.cc | 20 ++++++++-------- - poppler/Gfx.cc | 2 +- - poppler/GfxFont.cc | 24 +++++++++---------- - poppler/GfxState.cc | 54 - +++++++++++++++++++++---------------------- - poppler/JArithmeticDecoder.cc | 2 +- - poppler/JBIG2Stream.cc | 30 ++++++++++++------------ - poppler/Link.cc | 6 ++--- - poppler/NameToCharCode.cc | 4 ++-- - poppler/Outline.cc | 4 ++-- - poppler/SplashOutputDev.cc | 8 +++---- - poppler/Stream.cc | 12 +++++----- - poppler/TextOutputDev.cc | 48 +++++++++++++++++++------------------- - poppler/XRef.cc | 18 +++++++-------- - splash/SplashClip.cc | 12 +++++----- - splash/SplashFTFontFile.cc | 2 +- - splash/SplashFont.cc | 6 ++--- - splash/SplashPath.cc | 8 +++---- - splash/SplashScreen.cc | 4 ++-- - splash/SplashState.cc | 4 ++-- - splash/SplashT1FontFile.cc | 4 ++-- - splash/SplashXPath.cc | 4 ++-- - splash/SplashXPathScanner.cc | 4 ++-- - 35 files changed, 214 insertions(+), 176 deletions(-) - -commit feb82c60b1f86a9d1260db57534d98c54ee615c4 -Author: Martin Kretzschmar <martink@gnome.org> -Date: Wed Aug 24 19:41:27 2005 +0000 - - * configure.ac: add /usr/include/qt4 to qt4_incdirs. That's what - Debian and Ubuntu use. Maybe we should just use pkg-config. If - it's usable with qt4. - - * test/.cvsignore: ignore pdf_inspector binary. - - ChangeLog | 8 ++++++++ - configure.ac | 2 +- - test/.cvsignore | 7 ++++--- - 3 files changed, 13 insertions(+), 4 deletions(-) - -commit 8dce80eb74f24f07ac7668905f1631e04a9c5841 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed Aug 24 18:57:46 2005 +0000 - - 2005-08-24 Kristian Høgsberg <krh@redhat.com> - - * poppler/TextOutputDev.cc: Push rotation argument down to - GfxState constructor. This is still not completely - functional yet. - - * glib/poppler-page.cc (poppler_page_render_selection): Add - rotation argument so API is useful. Not yet implemented. - (poppler_page_prepare_output_dev): Patch from Marco to fix - rotation using the cairo backend. - - ChangeLog | 10 ++++++++++ - glib/poppler-page.cc | 22 ++++++++++++++++------ - glib/poppler-page.h | 1 + - poppler/TextOutputDev.cc | 11 ++++++++--- - poppler/TextOutputDev.h | 4 +++- - 5 files changed, 38 insertions(+), 10 deletions(-) - -commit b909b5ae98bc3e557ef6e658e2b9120e82951259 -Author: Jonathan Blandford <jrb@redhat.com> -Date: Wed Aug 24 03:21:20 2005 +0000 - - Tue Aug 23 17:21:02 2005 Jonathan Blandford <jrb@redhat.com> - - * test/Makefile.am (gtk_cairo_test_LDADD): add - FREETYPE_{CFLAGS,LIBS} to the cairo deps - - ChangeLog | 5 +++++ - test/Makefile.am | 4 +++- - 2 files changed, 8 insertions(+), 1 deletion(-) - -commit da3aac379f07ffedd6078707ec9923800fc0c0a5 -Author: Jonathan Blandford <jrb@redhat.com> -Date: Tue Aug 23 18:20:45 2005 +0000 - - Tue Aug 23 13:38:01 2005 Jonathan Blandford <jrb@redhat.com> - - * configure.ac: - * poppler/Gfx.cc: - * poppler/Gfx.h: - * poppler/GlobalParams.cc: - * poppler/GlobalParams.h: - * poppler/Makefile.am: - * poppler/OutputDev.cc: - * poppler/OutputDev.h: - * poppler/ProfileData.cc: - * poppler/ProfileData.h: - * test/Makefile.am: - * test/pdf-inspector.cc: - * test/pdf-inspector.glade: - * test/pdf-operators.c: Initial cut at a pdf inspector. This - should help us look at PDF files. - - ChangeLog | 18 ++ - configure.ac | 4 +- - poppler/Gfx.cc | 30 ++++ - poppler/Gfx.h | 1 + - poppler/GlobalParams.cc | 16 ++ - poppler/GlobalParams.h | 3 + - poppler/Makefile.am | 2 + - poppler/OutputDev.cc | 17 ++ - poppler/OutputDev.h | 10 +- - poppler/ProfileData.cc | 44 +++++ - poppler/ProfileData.h | 41 +++++ - test/Makefile.am | 13 +- - test/pdf-inspector.cc | 358 ++++++++++++++++++++++++++++++++++++++ - test/pdf-inspector.glade | 434 - +++++++++++++++++++++++++++++++++++++++++++++++ - test/pdf-operators.c | 81 +++++++++ - 15 files changed, 1068 insertions(+), 4 deletions(-) - -commit 1aad886c6c19a964a3fc9e18f31acc8e115478e0 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Aug 22 18:20:12 2005 +0000 - - 2005-08-22 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc: - * glib/poppler-page.h: - * glib/poppler-private.h: - * glib/test-poppler-glib.c: Patch from Marco to simplify - the glib - rotation API. - - ChangeLog | 8 +++ - glib/poppler-page.cc | 136 - +++++++---------------------------------------- - glib/poppler-page.h | 4 +- - glib/poppler-private.h | 1 - - glib/test-poppler-glib.c | 2 +- - 5 files changed, 28 insertions(+), 123 deletions(-) - -commit 6070b1dc4b76c236f3100fbd255c2d906e61c3c2 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sun Aug 21 23:14:04 2005 +0000 - - 2005-08-21 Kristian Høgsberg <krh@redhat.com> - - * poppler/Makefile.am (INCLUDES): Add FREETYPE_CFLAGS. - - * configure.ac: Make freetype check use pkg-config if - possible. - - ChangeLog | 6 ++++++ - configure.ac | 34 ++++++++++++++++++++++++---------- - poppler/Makefile.am | 1 + - 3 files changed, 31 insertions(+), 10 deletions(-) - -commit 2698ca6fa107ea91dc01eb8cfb0c93383fbca125 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed Aug 17 16:54:01 2005 +0000 - - 2005-08-17 Kristian Høgsberg <krh@redhat.com> - - * poppler/GfxFont.cc: Add fix discussed in #3131 to only - use the - MacRoman char map if the font has one or the font dicts - specifies - /MacRoman. - - ChangeLog | 6 ++++++ - poppler/GfxFont.cc | 1 - - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit 5dc9b14b99f2efa2fe018e9267dd363d1bcd78b1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Aug 7 23:58:12 2005 +0000 - - Fix EOF checking - - ChangeLog | 4 ++++ - poppler/PDFDoc.cc | 10 +++++++++- - 2 files changed, 13 insertions(+), 1 deletion(-) - -commit 155d019d7b474f244a3e4bf64d192015f6a266c4 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sat Aug 6 18:09:51 2005 +0000 - - 2005-08-06 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc: - * glib/poppler-page.h: Use GdkColor for specifying selection - colors, we alreay depend on GDK anyway. - - ChangeLog | 6 ++++++ - glib/poppler-page.cc | 20 +++++++++----------- - glib/poppler-page.h | 5 +++-- - 3 files changed, 18 insertions(+), 13 deletions(-) - -commit c710b645c8297d356c101b13a9889bcaba691176 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Aug 6 11:58:59 2005 +0000 - - Update comment - - poppler/PDFDoc.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit de7953c8a8360d8bfc99298906c5fc1094684fc3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Sat Aug 6 11:47:37 2005 +0000 - - Increase EOF searching up to last 1024 characters - - ChangeLog | 7 +++++++ - poppler/PDFDoc.cc | 23 +++++++++++++---------- - 2 files changed, 20 insertions(+), 10 deletions(-) - -commit 5dd72618688763b50d5f5738d857c9294ef1b1c2 -Author: Brad Hards <bradh@frogmouth.net> -Date: Sat Aug 6 02:15:58 2005 +0000 - - Add password arguments to document constructor. - - ChangeLog | 4 ++++ - qt4/src/poppler-document.cc | 8 ++++++-- - qt4/src/poppler-qt4.h | 4 +++- - 3 files changed, 13 insertions(+), 3 deletions(-) - -commit edbd7957b393eb63f48df7db6b220b355d4fc461 -Author: Brad Hards <bradh@frogmouth.net> -Date: Sat Aug 6 02:07:55 2005 +0000 - - Make API extraction work again. - - ChangeLog | 3 +++ - qt4/src/Doxyfile | 2 +- - 2 files changed, 4 insertions(+), 1 deletion(-) - -commit f43a6f1d1c27c042f5736746c94430083baa4c1d -Author: Brad Hards <bradh@frogmouth.net> -Date: Sat Aug 6 01:53:06 2005 +0000 - - Add new test code for encrypted files. - - ChangeLog | 5 ++ - qt4/tests/.cvsignore | 1 + - qt4/tests/Makefile.am | 7 ++- - qt4/tests/test-password-qt4.cpp | 135 - ++++++++++++++++++++++++++++++++++++++++ - 4 files changed, 147 insertions(+), 1 deletion(-) - -commit 2ec26afaf80864b023899b890b8e229448da9bed -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Aug 5 22:30:20 2005 +0000 - - 2005-08-05 Kristian Høgsberg <krh@redhat.com> - - * poppler/TextOutputDev.cc (visitLine): Round selection - coordinates in device space, so selection isn't fuzzy. - - * poppler/GfxState.cc: - * poppler/GfxState.h: Add simple Matrix class. - - ChangeLog | 8 ++++++++ - poppler/CairoOutputDev.cc | 6 +++--- - poppler/GfxState.cc | 26 ++++++++++++++++++++++++++ - poppler/GfxState.h | 10 ++++++++++ - poppler/TextOutputDev.cc | 14 ++++++++++++++ - 5 files changed, 61 insertions(+), 3 deletions(-) - -commit ccba4f0773047eea5e4ad0ac736450160dd97664 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Aug 5 19:04:36 2005 +0000 - - 2005-08-05 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc: - * glib/poppler-page.h: - * poppler/TextOutputDev.cc: - * poppler/TextOutputDev.h: Propagate selection colors to - the glib API. - - ChangeLog | 7 ++++++ - glib/poppler-page.cc | 63 - ++++++++++++++++++++++++++++++++++++++++++------ - glib/poppler-page.h | 4 ++- - poppler/TextOutputDev.cc | 25 +++++++++---------- - poppler/TextOutputDev.h | 7 ++++-- - 5 files changed, 82 insertions(+), 24 deletions(-) - -commit 43e97129393f403c41f191ceae9a54793ece005f -Author: Brad Hards <bradh@frogmouth.net> -Date: Thu Aug 4 10:15:23 2005 +0000 - - Fix problem with drawing filled objects that was introduced in - Rev 1.4. - - ChangeLog | 5 +++++ - poppler/ArthurOutputDev.cc | 13 +++++++++++-- - 2 files changed, 16 insertions(+), 2 deletions(-) - -commit a75d80333a70d2e1ac7c9032d316034eebed9dd6 -Author: Brad Hards <bradh@frogmouth.net> -Date: Wed Aug 3 11:44:55 2005 +0000 - - Implement paging ability for Qt4, more than a little based - on Albert's work for Qt3. - Up arrow -> previous page - Down arrow -> next page - q -> quit. - - What more could you want from a PDF viewer :-) - - ChangeLog | 6 ++++++ - qt4/tests/test-poppler-qt4.cpp | 47 - +++++++++++++++++++++++++++++++++--------- - 2 files changed, 43 insertions(+), 10 deletions(-) - -commit f3e0a163b098da1cc389c2c4f47e28358b1bec77 -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Aug 1 19:15:40 2005 +0000 - - Fix problem in the patch to fix #3299 - - ChangeLog | 4 ++++ - poppler/DCTStream.cc | 15 ++++++++++----- - poppler/DCTStream.h | 1 + - 3 files changed, 15 insertions(+), 5 deletions(-) - -commit 5f7bd81bedd8c90e3312190256488ff0c15502e1 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Aug 1 15:21:19 2005 +0000 - - 2005-08-01 Kristian Høgsberg <krh@redhat.com> - - Patch from Dan Winship <danw@novell.com> - - * glib/poppler-page.cc (poppler_page_copy_to_pixbuf): Set - alpha to - 0xff (opaque), not 0x00. - - ChangeLog | 7 +++++++ - glib/poppler-page.cc | 2 +- - 2 files changed, 8 insertions(+), 1 deletion(-) - -commit 22f509e60f60ccaea1f91d9ec1ef7ba8200bee8a -Author: Brad Hards <bradh@frogmouth.net> -Date: Mon Aug 1 08:09:00 2005 +0000 - - Fix up the fill problem with drawing text, where the "middle" - of glyphs - with a "hole" (like d, o, p, b, g) got filled. Also remove some - debugging - code. The glyphs are still ugly though. - - ChangeLog | 7 +++++++ - poppler/ArthurOutputDev.cc | 13 +------------ - 2 files changed, 8 insertions(+), 12 deletions(-) - -commit 7bf5d10c1f6edd538769c3a83a3b3d5df56d604b -Author: Brad Hards <bradh@frogmouth.net> -Date: Sun Jul 31 09:54:04 2005 +0000 - - An initial version of proper font handling, heavily based on work by - Albert Astals Cid. I changed it to stroke the glyphs based on the - SplashPath. In the longer term, Arthur should use FreeType paths - directly - hopefully that will be less ugly, and not fill everything. - - ChangeLog | 8 + - poppler/ArthurOutputDev.cc | 401 - ++++++++++++++++++++++++++++++++------------- - poppler/ArthurOutputDev.h | 15 +- - qt4/src/poppler-page.cc | 2 +- - splash/SplashPath.h | 2 + - 5 files changed, 314 insertions(+), 114 deletions(-) - -commit 8567b794628786b82e8db2a7daf75e4ad2398960 -Author: Brad Hards <bradh@frogmouth.net> -Date: Fri Jul 29 12:15:19 2005 +0000 - - Add some more test cases. - - ChangeLog | 4 ++++ - qt4/tests/.cvsignore | 4 ++++ - qt4/tests/Makefile.am | 10 +++++++++- - qt4/tests/check_pagelayout_facing.cpp | 22 ++++++++++++++++++++++ - qt4/tests/check_version.cpp | 22 ++++++++++++++++++++++ - 5 files changed, 61 insertions(+), 1 deletion(-) - -commit 59d660cf4d614fdea09d6a62b8889f7682c2b4f9 -Author: Brad Hards <bradh@frogmouth.net> -Date: Fri Jul 29 11:41:14 2005 +0000 - - Compile fix associated with last change. - - poppler/ArthurOutputDev.cc | 2 -- - 1 file changed, 2 deletions(-) - -commit 88c57c73f57820d6a57e26825093fbc688845e67 -Author: Brad Hards <bradh@frogmouth.net> -Date: Fri Jul 29 11:24:42 2005 +0000 - - A couple of minor changes to the Arthur backend. - - ChangeLog | 9 +++++++++ - poppler/ArthurOutputDev.cc | 18 ++++++++++++++---- - 2 files changed, 23 insertions(+), 4 deletions(-) - -commit 481db9d9eae5ea16e5b382f4ad21e6e624a70dcf -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Jul 29 05:48:33 2005 +0000 - - 2005-07-29 Kristian Høgsberg <krh@redhat.com> - - * poppler/TextOutputDev.cc: Finish TextSelectionDumper - class for - extracting the text from a selection. Add - TextPage::getSelectionText() and - TextOutputDev::getSelectionText() - methods to expose the new functionality. - - * glib/poppler-page.cc (poppler_page_get_text): Use - TextOutputDev::getSelectionText() to get the text from the - selection. - - * glib/poppler-document.cc (poppler_document_new_from_file): - * glib/poppler-page.cc (_poppler_page_new): Add extra NULL to - g_object_new() constructor to silence gcc warning about - missing - sentinel. - - ChangeLog | 16 +++++ - glib/poppler-document.cc | 2 +- - glib/poppler-page.cc | 31 +++++---- - poppler/TextOutputDev.cc | 164 - +++++++++++++++++++++++++++++++++++------------ - poppler/TextOutputDev.h | 8 +++ - 5 files changed, 164 insertions(+), 57 deletions(-) - -commit ad312dbded4e8f70c3a2eac9a0964fa00ecb6b2c -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jul 28 22:56:17 2005 +0000 - - Fix memory leaks in PageLabelInfo.cc - - ChangeLog | 4 ++++ - poppler/PageLabelInfo.cc | 11 +++++++++++ - poppler/PageLabelInfo.h | 2 ++ - 3 files changed, 17 insertions(+) - -commit b45ad9f3409d7b1ed147135a70553e5255913c61 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jul 28 20:53:36 2005 +0000 - - - delete family; - + delete[] family; - as family is new[]'ed - - When assigning family if the font had "the proper info" and family - had to be deleted, do it. - - poppler/GlobalParams.cc | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -commit f93dfc5c5133e0b1bd9f4786cfe18bd796cbac2a -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jul 28 18:51:17 2005 +0000 - - Remove the debugging - - poppler/GlobalParams.cc | 5 ----- - 1 file changed, 5 deletions(-) - -commit 8022315004e1623c0be320f7671fcd72c15c0de3 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jul 28 18:37:17 2005 +0000 - - Wonder how that slipped here - - poppler/GlobalParams.cc | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -commit 82638babe89e402c0348619ec3205059b977c7e9 -Author: Albert Astals Cid <aacid@kde.org> -Date: Thu Jul 28 17:34:19 2005 +0000 - - Fontconfig patch is here, rejoice - - ChangeLog | 15 +- - glib/poppler-document.cc | 1 - - poppler/CairoFontEngine.cc | 95 +-------- - poppler/CairoFontEngine.h | 2 - - poppler/CairoOutputDev.cc | 4 - - poppler/GlobalParams.cc | 473 - ++++++++++++++++++++------------------------ - poppler/GlobalParams.h | 17 +- - poppler/SplashOutputDev.cc | 132 +------------ - poppler/SplashOutputDev.h | 3 - - qt/poppler-document.cc | 1 - - qt4/src/poppler-document.cc | 1 - - test/gtk-cairo-test.cc | 1 - - test/gtk-splash-test.cc | 1 - - 13 files changed, 241 insertions(+), 505 deletions(-) - -commit e9015531b1d0e5f2c8d8ca2bc50d5f14aaf954bc -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Jul 28 06:31:57 2005 +0000 - - 2005-07-28 Kristian Høgsberg <krh@redhat.com> - - * poppler/poppler-config.h.in: Add GCC_PRINTF_FORMAT macro to - annotate printf-like functions (#3638). - - * poppler/Error.h: Add GCC_PRINTF_FORMAT to error(). - - * poppler/PSOutputDev.h: Add GCC_PRINTF_FORMAT to - PSOutputDev::writePSFmt(). - - * poppler/PSOutputDev.cc, poppler/GlobalParams.cc: Quiet new - printf warnings. - - ChangeLog | 11 +++++++++++ - poppler/Error.h | 2 +- - poppler/GlobalParams.cc | 3 ++- - poppler/PSOutputDev.cc | 3 +-- - poppler/PSOutputDev.h | 2 +- - poppler/TextOutputDev.cc | 13 ++++++++++++- - poppler/poppler-config.h.in | 12 ++++++++++++ - 7 files changed, 40 insertions(+), 6 deletions(-) - -commit 9df89c495683e229b771b3d008ed25d478465c35 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Jul 28 05:52:43 2005 +0000 - - 2005-07-28 Kristian Høgsberg <krh@redhat.com> - - * poppler/TextOutputDev.cc (TextBlock::visitSelection): Assign - start and stop coordinates in one place so we don't assign the - same point to both in some corner cases. - (TextWord::visitSelection): Initialize begin to len, not - len + 1 - to fix crash. - - (TextWord::visitSelection, TextLine::visitSelection): Change - selection trigger; now midpoint of glyph must be included in - selection area for glyph to be in selection. - - ChangeLog | 12 +++++ - poppler/CairoOutputDev.cc | 2 +- - poppler/TextOutputDev.cc | 113 - ++++++++++++++++++++++------------------------ - 3 files changed, 67 insertions(+), 60 deletions(-) - -commit a3d9b5849cedf1316c6fc5859872e957f3f7b593 -Author: Martin Kretzschmar <martink@gnome.org> -Date: Wed Jul 27 19:21:08 2005 +0000 - - * poppler/PSOutputDev.cc (PSOutputDev): change the constructor to - take paper size and duplex setting parameters. - (init): add paper size and duplex parameters. - (writeDocSetup): add duplex parameter. - - * poppler/PSOutputDev.h: update declarations. - - * glib/poppler-private.h (struct _PopplerPSFile): store necessary - information to eventually construct a PSOutputDev. - - * glib/poppler-page.cc (poppler_page_render_to_ps): initialize the - output dev if it doesn't exist yet. - - * glib/poppler-document.cc (poppler_ps_file_new): don't create the - PSOutputDev here, just store filename and page range. - (poppler_ps_file_set_paper_size, poppler_ps_file_set_duplex): new - functions. - (poppler_ps_file_free): free the filename which we strdup now. - - * glib/poppler-document.h: add prototypes. - - ChangeLog | 23 +++++++++++++++++++++++ - glib/poppler-document.cc | 49 - +++++++++++++++++++++++++++++++++++++++++------- - glib/poppler-document.h | 15 ++++++++++----- - glib/poppler-page.cc | 10 ++++++++++ - glib/poppler-private.h | 6 ++++++ - poppler/PSOutputDev.cc | 23 ++++++++++++++--------- - poppler/PSOutputDev.h | 9 +++++++-- - 7 files changed, 112 insertions(+), 23 deletions(-) - -commit 7be920ecf13698c3cf4ab8df09c8c67f1a04bfa2 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jul 26 21:52:09 2005 +0000 - - Fix mem leak in qt test app - - ChangeLog | 4 ++++ - qt/test-poppler-qt.cpp | 2 ++ - 2 files changed, 6 insertions(+) - -commit 2bc26dffd9f296799617d319055648c20f748c8a -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue Jul 26 20:34:13 2005 +0000 - - 2005-07-26 Kristian Høgsberg <krh@redhat.com> - - * fofi/FoFiType1.cc: Make check for end of encoding array - a bit - more liberal so we don't crash on complex encoding arrays - (#3344). - - ChangeLog | 5 +++++ - fofi/FoFiType1.cc | 21 +++++++-------------- - 2 files changed, 12 insertions(+), 14 deletions(-) - -commit 07911274e4e850a628b1e587cafc2a73c05f93fe -Author: Albert Astals Cid <aacid@kde.org> -Date: Mon Jul 25 20:40:37 2005 +0000 - - Work on bad jpeg data that have garbage before the start marker. Fixes - bug #3299 - - ChangeLog | 5 +++++ - poppler/DCTStream.cc | 38 ++++++++++++++++++++++++++++++++++++++ - 2 files changed, 43 insertions(+) - -commit a1869eca39172fcb42f036a5846b19548be53568 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 22 11:01:25 2005 +0000 - - Fix bug #3586 - - ChangeLog | 5 +++++ - poppler/CairoFontEngine.cc | 2 ++ - 2 files changed, 7 insertions(+) - -commit 95529b41272484f08fb54393e1886bf7ff3e02c8 -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 22 10:45:19 2005 +0000 - - Make it possible to browse pages in test-poppler-qt - - ChangeLog | 13 +++++++++---- - qt/test-poppler-qt.cpp | 49 - ++++++++++++++++++++++++++++++++++++++++--------- - 2 files changed, 49 insertions(+), 13 deletions(-) - -commit 2d52650864eab0e9385ed1fe8fb594daac9d8322 -Author: Martin Kretzschmar <martink@gnome.org> -Date: Fri Jul 22 10:35:56 2005 +0000 - - * glib/poppler-document.cc (poppler_fonts_iter_get_name): if the - font is a subset, strip the ABCDEF+ tag. - (poppler_fonts_iter_get_full_name): does what the old get_name did. - (poppler_fonts_iter_get_font_type, poppler_fonts_iter_is_embedded) - (poppler_fonts_iter_is_subset): new wrappers. - - * glib/poppler-document.h (PopplerFontType): new enum. - Update prototypes. - - ChangeLog | 11 ++++++++++ - glib/poppler-document.cc | 54 - +++++++++++++++++++++++++++++++++++++++++++++++- - glib/poppler-document.h | 38 ++++++++++++++++++++++++---------- - 3 files changed, 91 insertions(+), 12 deletions(-) - -commit 43bed4aafcf1d291dc96fa5070efbd7936a6122f -Author: Albert Astals Cid <aacid@kde.org> -Date: Fri Jul 22 10:33:54 2005 +0000 - - Fix bugs #3728 and #3750 - - ChangeLog | 4 ++++ - splash/Splash.cc | 10 ++++++++++ - 2 files changed, 14 insertions(+) - -commit c7bcef87493d354a077dd223d76f86640acc0ce3 -Author: Martin Kretzschmar <martink@gnome.org> -Date: Fri Jul 15 19:55:30 2005 +0000 - - update for 2005-06-27 change to actually display something again. - - ChangeLog | 5 +++++ - test/gtk-cairo-test.cc | 10 ++++++---- - 2 files changed, 11 insertions(+), 4 deletions(-) - -commit 6623711d2d50dc52454904ee16b25337f0aab130 -Author: Brad Hards <bradh@frogmouth.net> -Date: Sun Jul 10 09:34:03 2005 +0000 - - A general cleanup of the Arthur output renderer. - - ChangeLog | 5 +++ - poppler/ArthurOutputDev.cc | 105 - ++++++++++++++++----------------------------- - 2 files changed, 41 insertions(+), 69 deletions(-) - -commit ea1cc9a7b12db9c44b89896c41d07e3ba932d054 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Jul 8 04:59:41 2005 +0000 - - 2005-07-08 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc (poppler_page_set_selection_alpha): Add - this function to initialize the alpha channel when using the - splash backend. - - * poppler/TextOutputDev.cc (visitLine): Add missing scaling of - intra-line selection edges. - - ChangeLog | 9 ++++++++ - glib/poppler-page.cc | 59 - +++++++++++++++++++++++++++++++++++++++++++++++- - poppler/TextOutputDev.cc | 17 ++++++++------ - 3 files changed, 77 insertions(+), 8 deletions(-) - -commit 1cd915397c9532ed80b4f905b6ed9c0126aa38f2 -Author: Brad Hards <bradh@frogmouth.net> -Date: Thu Jul 7 21:15:09 2005 +0000 - - Add support for page layout to the Qt4 bindings, plus - test cases. - - ChangeLog | 8 ++++++++ - qt4/src/poppler-document.cc | 22 ++++++++++++++++++++++ - qt4/src/poppler-qt4.h | 26 ++++++++++++++++++++++++-- - qt4/tests/Makefile.am | 10 +++++++++- - qt4/tests/check_pagelayout_none.cpp | 22 ++++++++++++++++++++++ - qt4/tests/check_pagelayout_single.cpp | 22 ++++++++++++++++++++++ - 6 files changed, 107 insertions(+), 3 deletions(-) - -commit 4e050aef7ba132900f84205be221fd48808848c3 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Jul 7 17:19:36 2005 +0000 - - 2005-07-07 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc (poppler_page_prepare_output_dev): - Account - for page rotation when creating the cairo surface. - - ChangeLog | 5 +++++ - glib/poppler-page.cc | 17 +++++++++++++++-- - 2 files changed, 20 insertions(+), 2 deletions(-) - -commit 2eeab0b8afeb4897806df2de6e496889c25dda5e -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Jul 7 15:58:43 2005 +0000 - - 2005-07-06 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc (poppler_page_copy_to_pixbuf): Add - out of - bounds checking (from Marco). - - ChangeLog | 6 +++++- - glib/poppler-page.cc | 5 +++++ - 2 files changed, 10 insertions(+), 1 deletion(-) - -commit b1015f6bdbd93b2a2574a9f0e0e1cd7dbae9af78 -Author: Brad Hards <bradh@frogmouth.net> -Date: Thu Jul 7 11:13:24 2005 +0000 - - At least try to fix glib issues. If you care about glib, - then you should review this. - - ChangeLog | 4 ++++ - glib/poppler-document.cc | 2 ++ - 2 files changed, 6 insertions(+) - -commit 8bf787031e7a2e93b4e1202918bd1aee86675082 -Author: Brad Hards <bradh@frogmouth.net> -Date: Thu Jul 7 11:04:08 2005 +0000 - - Update for page mode - new mode from PDF-1.6, API docs fixes - and some tests. - - ChangeLog | 15 +++++++++++++++ - poppler/Catalog.cc | 2 ++ - poppler/Catalog.h | 3 ++- - qt4/src/poppler-document.cc | 2 ++ - qt4/src/poppler-qt4.h | 14 +++++++++----- - qt4/tests/Makefile.am | 22 +++++++++++++++++++++- - qt4/tests/check_pagemode_attach.cpp | 22 ++++++++++++++++++++++ - qt4/tests/check_pagemode_fullscreen.cpp | 22 ++++++++++++++++++++++ - qt4/tests/check_pagemode_none.cpp | 22 ++++++++++++++++++++++ - qt4/tests/check_pagemode_oc.cpp | 22 ++++++++++++++++++++++ - qt4/tests/check_pagemode_thumbs.cpp | 22 ++++++++++++++++++++++ - 11 files changed, 161 insertions(+), 7 deletions(-) - -commit 695e27fb4d6fcc3466e2c9c95b4f02821b07e823 -Author: Brad Hards <bradh@frogmouth.net> -Date: Thu Jul 7 11:01:27 2005 +0000 - - Suppress noise from new test files. - - qt4/tests/.cvsignore | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit 8a8d57bdcf11ed2903913d938b9711053b9bb9f1 -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jul 6 17:12:36 2005 +0000 - - Extract family, stretch and weight from the font descriptor - - ChangeLog | 2 ++ - poppler/GfxFont.cc | 41 +++++++++++++++++++++++++++++++++++++++++ - poppler/GfxFont.h | 36 ++++++++++++++++++++++++++++++++++++ - 3 files changed, 79 insertions(+) - -commit 3a1646c2f776f5a07b0e830fcb8e1b0a80efb41c -Author: Albert Astals Cid <aacid@kde.org> -Date: Wed Jul 6 13:29:00 2005 +0000 - - Add checkFooter to check the document ends with %%EOF - - ChangeLog | 5 +++++ - poppler/PDFDoc.cc | 28 ++++++++++++++++++++++++++++ - poppler/PDFDoc.h | 1 + - 3 files changed, 34 insertions(+) - -commit 377c023d31cf74d8240aa5be9dba8e3838459a8c -Author: Brad Hards <bradh@frogmouth.net> -Date: Wed Jul 6 11:15:16 2005 +0000 - - Add unit tests for the isLinearized() property. - - ChangeLog | 4 ++++ - qt4/tests/Makefile.am | 6 +++++- - qt4/tests/check_linearised.cpp | 23 +++++++++++++++++++++++ - 3 files changed, 32 insertions(+), 1 deletion(-) - -commit 5fa869887a840a585340993718df0841010666cf -Author: Brad Hards <bradh@frogmouth.net> -Date: Wed Jul 6 09:52:30 2005 +0000 - - Remove boolean for unicode table lookup from Font - - ChangeLog | 14 ++++++++++++++ - qt4/src/poppler-document.cc | 2 -- - qt4/src/poppler-qt4.h | 14 +------------- - qt4/tests/poppler-fonts.cpp | 16 +++++++--------- - 4 files changed, 22 insertions(+), 24 deletions(-) - -commit 40469c5883e17e734f3d54872c59e76b95bc0f95 -Author: Brad Hards <bradh@frogmouth.net> -Date: Wed Jul 6 09:00:39 2005 +0000 - - Update to reflect recent changes. - - qt4/tests/.cvsignore | 2 ++ - 1 file changed, 2 insertions(+) - -commit 6cea437208f913085a6a8c7183b0826a107cefb5 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jul 5 21:15:48 2005 +0000 - - Don't crash with files that have fonts with no name - - ChangeLog | 7 +++++++ - qt4/src/poppler-document.cc | 13 ++++++++++--- - qt4/src/poppler-qt4.h | 2 +- - 3 files changed, 18 insertions(+), 4 deletions(-) - -commit 1323c74479848f5b87a3a13fa26e8b9e096e9f6a -Author: Brad Hards <bradh@frogmouth.net> -Date: Tue Jul 5 12:31:59 2005 +0000 - - Check in a couple more test apps - - qt4/tests/Makefile.am | 10 ++++++- - qt4/tests/check_author.cpp | 25 +++++++++++++++++ - qt4/tests/check_permissions.cpp | 59 - +++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 93 insertions(+), 1 deletion(-) - -commit 839a798ec3725427185de5a48c58ac448596b25d -Author: Brad Hards <bradh@frogmouth.net> -Date: Tue Jul 5 12:25:00 2005 +0000 - - Add Qt4 bindings for new user permission properties. - - ChangeLog | 4 ++++ - qt4/src/poppler-document.cc | 25 ++++++++++++++++++++++ - qt4/src/poppler-qt4.h | 51 - ++++++++++++++++++++++++++++++++++++++++----- - 3 files changed, 75 insertions(+), 5 deletions(-) - -commit e10f6990d3339e3a7adeaa50b1754cf7ecf82f87 -Author: Brad Hards <bradh@frogmouth.net> -Date: Tue Jul 5 12:15:04 2005 +0000 - - Add some more user permissions properties - high resolution - printing, document assembly, extraction for accessibility - and form completion. - - ChangeLog | 8 ++++++++ - poppler/PDFDoc.h | 9 +++++++++ - poppler/XRef.cc | 55 - +++++++++++++++++++++++++++++++++++++++++++++++++++---- - poppler/XRef.h | 4 ++++ - 4 files changed, 72 insertions(+), 4 deletions(-) - -commit 3a8e1ba03cdec6412dd0b79f0cc59a4cd97dd4e7 -Author: Brad Hards <bradh@frogmouth.net> -Date: Mon Jul 4 11:38:22 2005 +0000 - - A couple more little changes. - - ChangeLog | 6 ++++++ - 1 file changed, 6 insertions(+) - -commit a44bd0b45bb89f29ddca5d0e8986a8de50f9db39 -Author: Brad Hards <bradh@frogmouth.net> -Date: Mon Jul 4 11:37:21 2005 +0000 - - Change path to sample file to point to test module - - qt4/tests/check_orientation.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 2a7079087c35651c242d3843c94703a3199e61ca -Author: Brad Hards <bradh@frogmouth.net> -Date: Mon Jul 4 11:36:13 2005 +0000 - - Fix typo causing failure to pick up upside down pages. - - qt4/src/poppler-page.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 529a548044ae721a414c5b8e768c0498b1e6830b -Author: Brad Hards <bradh@frogmouth.net> -Date: Mon Jul 4 08:30:29 2005 +0000 - - Update to reflect recent changes - - ChangeLog | 30 +++++++++++++++++++++++++++++- - qt4/tests/.cvsignore | 2 ++ - 2 files changed, 31 insertions(+), 1 deletion(-) - -commit 08cca4670f8ae65333beacda85834112e76489d1 -Author: Brad Hards <bradh@frogmouth.net> -Date: Mon Jul 4 08:21:27 2005 +0000 - - Add in a simple demo/test application, similar to the pdffonts - application in xpdf. - - qt4/tests/Makefile.am | 9 +++++- - qt4/tests/poppler-fonts.cpp | 76 - +++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 84 insertions(+), 1 deletion(-) - -commit 52af89d8303b50c45d5e4584d19ec8b7d7ebcf9b -Author: Brad Hards <bradh@frogmouth.net> -Date: Mon Jul 4 08:18:52 2005 +0000 - - Update to reflect changes to rendering API. - - qt4/tests/stress-poppler-qt4.cpp | 4 ++-- - qt4/tests/test-poppler-qt4.cpp | 3 ++- - 2 files changed, 4 insertions(+), 3 deletions(-) - -commit d42998d0fc32b1e21a2aeef1311e0baf508ade3f -Author: Brad Hards <bradh@frogmouth.net> -Date: Mon Jul 4 08:16:17 2005 +0000 - - Qt4 update. - * qt4/src/poppler-qt4.h: - * qt4/src/poppler-document.cc complete Qt4 font metadata handling - - * qt4/src/poppler-qt4.h: - * qt4/src/poppler-page.cc: change the render API to make it more - Qt-like. - - qt4/src/poppler-document.cc | 7 ++++- - qt4/src/poppler-page.cc | 5 ++-- - qt4/src/poppler-qt4.h | 73 - ++++++++++++++++++++++++++++++++++++++++++--- - 3 files changed, 77 insertions(+), 8 deletions(-) - -commit 5d194b926d1ed642ed4bbd3304befa073d389cd4 -Author: Brad Hards <bradh@frogmouth.net> -Date: Mon Jul 4 08:10:16 2005 +0000 - - Change FontInfo::type() to return an enumerated value, - rather than a GooString. - - poppler/FontInfo.cc | 16 ++-------------- - poppler/FontInfo.h | 16 +++++++++++++--- - 2 files changed, 15 insertions(+), 17 deletions(-) - -commit 1303020b2e97bc110ccf045cd2811daf59ec72ce -Author: Brad Hards <bradh@frogmouth.net> -Date: Mon Jul 4 07:42:32 2005 +0000 - - Fix up the unit test, now that I have a real sample - file. - - qt4/tests/check_orientation.cpp | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -commit 96fc0ea3fc6c9c7d933e9e0c02a622b2aeef7617 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Jul 1 04:57:49 2005 +0000 - - 2005-07-01 Kristian Høgsberg <krh@redhat.com> - - * poppler/TextOutputDev.cc: Make selection also work when - dragging - backwards in the text flow. Currently this is a big pile of - if-statements, and there is certainly room for improvement. - - ChangeLog | 6 +++ - poppler/TextOutputDev.cc | 129 - ++++++++++++++++++++++++++++++++++++++--------- - 2 files changed, 111 insertions(+), 24 deletions(-) - -commit 06c49c496f28aba608101adcecd8cec34937ac78 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Jun 30 19:44:33 2005 +0000 - - 2005-06-30 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.h: * glib/poppler-page.cc - (poppler_page_copy_to_pixbuf): Fix splash compilation - (patch from - Marco). - (poppler_page_render_to_pixbuf): Drop dest_x and dest_y - coordinates from this function. This functionality can be - achieved using a sub-GdkPixbuf. - - * glib/test-poppler-glib.c (main): Update test case. - - ChangeLog | 11 +++++++++++ - NEWS | 6 ++++++ - glib/poppler-page.cc | 27 ++++++++++----------------- - glib/poppler-page.h | 4 +--- - glib/test-poppler-glib.c | 2 +- - 5 files changed, 29 insertions(+), 21 deletions(-) - -commit b126785aeda6b5576a13fc3f3853b027bd7dd306 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Jun 30 00:36:01 2005 +0000 - - 2005-06-29 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-private.h: Move TextOutputDev.h include - here from - poppler-page.cc - - ChangeLog | 5 +++++ - glib/poppler-page.cc | 1 - - glib/poppler-private.h | 1 + - 3 files changed, 6 insertions(+), 1 deletion(-) - -commit b15a8caf003d7d0631d4f78db5ab54e55a5a000a -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed Jun 29 21:24:48 2005 +0000 - - 2005-06-29 Kristian Høgsberg <krh@redhat.com> - - * configure.ac: - * glib/poppler-page.cc: - * glib/poppler-page.h: - * glib/poppler-private.h: - * poppler/CairoOutputDev.cc: - * poppler/CairoOutputDev.h: - * poppler/Page.cc: - * poppler/Page.h: - * poppler/TextOutputDev.cc: - * poppler/TextOutputDev.h: Add support for rendering real - selection (based on text flow). - - ChangeLog | 20 ++- - configure.ac | 4 +- - glib/poppler-page.cc | 224 +++++++++++++++++++------ - glib/poppler-page.h | 65 ++++---- - glib/poppler-private.h | 3 + - poppler/CairoOutputDev.cc | 13 +- - poppler/CairoOutputDev.h | 2 +- - poppler/Page.cc | 59 +++++-- - poppler/Page.h | 12 ++ - poppler/TextOutputDev.cc | 414 - +++++++++++++++++++++++++++++++++++++++++++++- - poppler/TextOutputDev.h | 38 ++++- - 11 files changed, 743 insertions(+), 111 deletions(-) - -commit 3b5e20465e482eb0e75a106697ee94d60aea2fdc -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 28 22:51:29 2005 +0000 - - Forgot assigning type on copy constructor - - poppler/FontInfo.cc | 1 + - 1 file changed, 1 insertion(+) - -commit e512cd1832a0e6d15149e12e8e67a39d335efc86 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 28 22:49:14 2005 +0000 - - Add FontInfo::getType() - - ChangeLog | 3 +++ - poppler/FontInfo.cc | 4 ++++ - poppler/FontInfo.h | 2 ++ - 3 files changed, 9 insertions(+) - -commit 8aeb5205f2876a9dc36eb1dc1e361bb87adf4e31 -Author: Albert Astals Cid <aacid@kde.org> -Date: Tue Jun 28 22:00:05 2005 +0000 - - use transformation matrix for image rendering in Arthur backend - - ChangeLog | 4 ++++ - poppler/ArthurOutputDev.cc | 12 +++++++----- - 2 files changed, 11 insertions(+), 5 deletions(-) - -commit a221d06fdc7b0688ca0744a1d6ad49d472c7f12c -Author: Brad Hards <bradh@frogmouth.net> -Date: Tue Jun 28 10:59:14 2005 +0000 - - Reduce cvs up noise - - .cvsignore | 1 + - ChangeLog | 7 +++++++ - qt4/.cvsignore | 3 +++ - qt4/src/.cvsignore | 7 +++++++ - qt4/tests/.cvsignore | 8 ++++++++ - 5 files changed, 26 insertions(+) - -commit ea58a20bbcf450a1ecb8fe00e8162cfdf76105f1 -Author: Brad Hards <bradh@frogmouth.net> -Date: Tue Jun 28 10:00:09 2005 +0000 - - Initial import of Qt4 bindings, and for a Qt4 "Arthur" (QPainter) - backend renderer. - - The bindings are currently unstable - you can expect substantial - change - in both source and binary interfaces. - - The Arthur renderer currently does a reasonable job of rendering path - and fill, but the image rendering doesn't work (for reasons that - aren't - clear to me) and text rendering doesn't use the right glyphs - it just - draws with the current font. There is a lot of work to do on this - too. Help is, of coure, welcome. - - ChangeLog | 12 + - Makefile.am | 10 +- - configure.ac | 94 ++- - poppler-qt4.pc.in | 12 + - poppler/ArthurOutputDev.cc | 604 +++++++++++++++++++ - poppler/ArthurOutputDev.h | 133 +++++ - poppler/Makefile.am | 20 + - qt4/Makefile.am | 1 + - qt4/src/Doxyfile | 1212 - ++++++++++++++++++++++++++++++++++++++ - qt4/src/Makefile.am | 22 + - qt4/src/poppler-document.cc | 309 ++++++++++ - qt4/src/poppler-page.cc | 170 ++++++ - qt4/src/poppler-private.h | 36 ++ - qt4/src/poppler-qt4.h | 286 +++++++++ - qt4/tests/Makefile.am | 34 ++ - qt4/tests/check_orientation.cpp | 40 ++ - qt4/tests/stress-poppler-qt4.cpp | 70 +++ - qt4/tests/test-poppler-qt4.cpp | 121 ++++ - 18 files changed, 3183 insertions(+), 3 deletions(-) - -commit 61e9bc76eb2fcb0b4b899ebfad1cc71c59fc8274 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue Jun 28 03:44:12 2005 +0000 - - 2005-06-27 Kristian Høgsberg <krh@redhat.com> - - * poppler/CairoOutputDev.cc: - * poppler/CairoOutputDev.h: Change CairoOutputDev to render - to a - given surface and let the user create that surface. - - * glib/poppler-document.cc: - * glib/poppler-page.cc: - * glib/poppler-private.h: Create the cairo image surface here - instead and pass it to the CairoOutputDev for rendering. - - * poppler/CairoOutputDevImage.cc: - * poppler/CairoOutputDevImage.h: - * poppler/CairoOutputDevX.cc: - * poppler/CairoOutputDevX.h: - * poppler/Makefile.am: Remove specialized cairo output - devices. - - ChangeLog | 17 ++++ - glib/poppler-document.cc | 2 +- - glib/poppler-page.cc | 21 +++- - glib/poppler-private.h | 4 +- - poppler/CairoOutputDev.cc | 24 +++-- - poppler/CairoOutputDev.h | 8 +- - poppler/CairoOutputDevImage.cc | 80 --------------- - poppler/CairoOutputDevImage.h | 44 --------- - poppler/CairoOutputDevX.cc | 216 - ----------------------------------------- - poppler/CairoOutputDevX.h | 117 ---------------------- - poppler/Makefile.am | 8 +- - 11 files changed, 54 insertions(+), 487 deletions(-) - -commit 8079dce3f0ed91dd531465f45c6d3c568ab4ecd1 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Jun 27 01:04:32 2005 +0000 - - 2005-06-26 Kristian Høgsberg <krh@redhat.com> - - * poppler/CairoOutputDev.cc: - * poppler/CairoOutputDev.h: Switch back to using drawChar() - for - text, but utilize the beginString() and endString() hooks - so we - can use cairo_show_glyphs() efficiently. - - ChangeLog | 7 +++ - poppler/CairoOutputDev.cc | 107 - ++++++++++++++-------------------------------- - poppler/CairoOutputDev.h | 12 +++++- - 3 files changed, 48 insertions(+), 78 deletions(-) - -commit 1aa48d6b7907a1d53830f0cf28085041f685368d -Author: Albert Astals Cid <aacid@kde.org> -Date: Sun Jun 26 23:35:26 2005 +0000 - - Add PageTransition class and PageTransition* Page::getTransition() - const; to the qt frontend. Code almost 100% copied from xpdf code - inside kpdf - - ChangeLog | 5 +++ - qt/poppler-page.cc | 121 - +++++++++++++++++++++++++++++++++++++++++++++++++++++ - qt/poppler-qt.h | 78 ++++++++++++++++++++++++++++++++++ - 3 files changed, 204 insertions(+) - -commit 9d4327eecd94299a3629b0814e84f981a4be1dfb -Author: Martin Kretzschmar <martink@gnome.org> -Date: Sun Jun 26 15:54:16 2005 +0000 - - add poppler-enums.[ch]. - - ChangeLog | 2 ++ - glib/.cvsignore | 8 +++++--- - 2 files changed, 7 insertions(+), 3 deletions(-) - -commit 768186514b9fc175cf330344408bb89ab4c909f3 -Author: Martin Kretzschmar <martink@gnome.org> -Date: Sun Jun 26 11:40:35 2005 +0000 - - require glib 2.4+ for g_value_take_string and G_DEFINE_TYPE. - - ChangeLog | 5 +++++ - configure.ac | 4 ++-- - 2 files changed, 7 insertions(+), 2 deletions(-) - -commit 5d40e34a367212c39af06332879f26824d6d62d2 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sun Jun 26 00:01:39 2005 +0000 - - 2005-06-25 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/Error.h: Maybe fix build on Solaris. - - ChangeLog | 4 ++++ - poppler/Error.h | 2 +- - 2 files changed, 5 insertions(+), 1 deletion(-) - -commit c2780a3b3f4615bb28bfe394d649b388db4ccf4d -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Jun 20 21:33:09 2005 +0000 - - 2005-06-20 Kristian Høgsberg <krh@redhat.com> - - * NEWS: - * configure.ac: Bump version to 0.3.3 and sum up changes since - last release. - - * glib/poppler-page.cc (poppler_page_find_text): Initialize - xMin - and yMin to avoid referencing unintialized memory (#3582). - - ChangeLog | 9 +++++++++ - NEWS | 10 ++++++++++ - configure.ac | 2 +- - glib/poppler-page.cc | 2 ++ - 4 files changed, 22 insertions(+), 1 deletion(-) - -commit 9023891f314ac37811b5c973be2e36b6de353cf2 -Author: Martin Kretzschmar <martink@gnome.org> -Date: Mon Jun 20 18:45:41 2005 +0000 - - (info_dict_get_string): convert from PDFDocEncoding to UTF-8. - - ChangeLog | 5 +++++ - glib/poppler-document.cc | 16 +++++++++++++++- - 2 files changed, 20 insertions(+), 1 deletion(-) - -commit bbf2fe757f0fd08d0e90e3810709ab7152c779c0 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Jun 20 17:58:38 2005 +0000 - - 2005-06-20 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc: - * glib/poppler-page.h: - * glib/poppler.h: Clean up glib rotation implementation and - add a - getter for rotation. Patch from Marco. - - ChangeLog | 7 ++++++ - glib/poppler-page.cc | 69 - +++++++++++++++++++++++++++++----------------------- - glib/poppler-page.h | 57 ++++++++++++++++++++++--------------------- - glib/poppler.h | 1 - - 4 files changed, 75 insertions(+), 59 deletions(-) - -commit c264d8a9f84587cd0f2ef67683a01fc8dd9395af -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Jun 20 17:38:27 2005 +0000 - - 2005-06-20 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-document.cc: - * poppler/FontInfo.cc: Fixes from Marco to handle fonts - without - name (typically type 3 fonts) and fix an iterator bug. - - ChangeLog | 6 ++++++ - glib/poppler-document.cc | 8 +++++++- - poppler/FontInfo.cc | 13 ++++++++++--- - 3 files changed, 23 insertions(+), 4 deletions(-) - -commit 4746e63a793a2881e904ac54d58b7d3e48b07dcf -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Jun 20 17:22:35 2005 +0000 - - 2005-06-20 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc (poppler_page_get_link_mapping): Adjust - link coordinates so they're relative to bounding box - lower left - corner (#3396). - - ChangeLog | 6 ++++++ - glib/poppler-page.cc | 6 ++++++ - 2 files changed, 12 insertions(+) - -commit bada3d03583ef6ed34d2aa743de8fd9ca4a5c748 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Jun 17 05:30:56 2005 +0000 - - 2005-06-17 Kristian Høgsberg <krh@redhat.com> - - * autogen.sh: Patch from Emil Soleyman-Zomalan to enable - checks - for automake >= 1.7 (#3554). - - ChangeLog | 5 +++ - autogen.sh | 104 - +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 109 insertions(+) - -commit 25db42831ddde500697126352458e092a9b0ab9b -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed Jun 15 15:02:46 2005 +0000 - - 2005-06-15 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-document.cc: - * glib/poppler-document.h: Patch from Marco to get initial - status - (open or closed) for bookmark subtrees. - ----------------------------------------------------------- - - ChangeLog | 6 ++++++ - glib/poppler-document.cc | 9 +++++++++ - glib/poppler-document.h | 1 + - 3 files changed, 16 insertions(+) - -commit e54e306ac5d603001fefda3b9ecd81821e4bd09e -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Jun 13 17:18:32 2005 +0000 - - Forgot to add new files. - - poppler/FontInfo.cc | 197 - ++++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/FontInfo.h | 51 ++++++++++++++ - 2 files changed, 248 insertions(+) - -commit 23e8ed5cbf4d7d999a8a1dcf714aaddaf339ceff -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Jun 13 16:09:33 2005 +0000 - - 2005-06-13 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-document.cc: - * glib/poppler-document.h: - * glib/poppler-private.h: - * glib/poppler.h: - * glib/test-poppler-glib.c: - * poppler/Makefile.am: Patch from Marco to extract font - info from - document. - - ChangeLog | 10 ++++ - glib/poppler-document.cc | 131 - +++++++++++++++++++++++++++++++++++++++++++++++ - glib/poppler-document.h | 13 +++++ - glib/poppler-private.h | 7 +++ - glib/poppler.h | 2 + - glib/test-poppler-glib.c | 14 +++++ - poppler/Makefile.am | 2 + - 7 files changed, 179 insertions(+) - -commit fbb86d2983a28ad2c46b8c5d475a2df1f0f0e4b9 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed Jun 8 14:35:46 2005 +0000 - - 2005-06-08 Kristian Høgsberg <krh@redhat.com> - - * poppler/CairoFontEngine.cc: Remember to delete tmpFileName. - Patch from Nikolai Weibull (#3491). - - ChangeLog | 5 +++++ - poppler/CairoFontEngine.cc | 37 +++++++++++++++++++------------------ - 2 files changed, 24 insertions(+), 18 deletions(-) - -commit 699b03025c1d38a42a49e39017097c5d0315fd6f -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue Jun 7 20:25:48 2005 +0000 - - 2005-06-07 Kristian Høgsberg <krh@redhat.com> - - * qt/test-poppler-qt.cpp: Add stdlib.h include for exit(). - - ChangeLog | 4 ++++ - qt/test-poppler-qt.cpp | 1 + - 2 files changed, 5 insertions(+) - -commit 0017b1a72c58e2d016d22451079c466abdfff15c -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Jun 2 19:14:45 2005 +0000 - - 2005-06-02 Kristian Høgsberg <krh@redhat.com> - - * poppler/TextOutputDev.h: - * qt/poppler-qt.h: Patch from Stanislav Brabec - <sbrabec@suse.cz> - to fix gcc 4.0.1 warnings on undeclared friend classes. - - * test/gtk-splash-test.cc: Fix from Martin Kretzschmar - <martink@gnome.org> to compile with OPI enabled (#2911). - - ChangeLog | 9 +++++++++ - poppler/TextOutputDev.h | 3 +++ - qt/poppler-qt.h | 2 ++ - test/gtk-splash-test.cc | 2 +- - 4 files changed, 15 insertions(+), 1 deletion(-) - -commit 47c3b4ec2c7691e44f5100b1f5956df0005467c8 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Jun 2 18:49:55 2005 +0000 - - 2005-06-02 Kristian Høgsberg <krh@redhat.com> - - Patch from Stanislav Brabec <sbrabec@suse.cz>: - - * configure.ac: - * poppler-cairo.pc.in: - * poppler-glib.pc.in: - * poppler-qt.pc.in: - * poppler-splash.pc.in: Misc fixes to pkg-config files. - - ChangeLog | 10 ++++++++++ - configure.ac | 6 ++++-- - poppler-cairo.pc.in | 3 +-- - poppler-glib.pc.in | 4 ++-- - poppler-qt.pc.in | 1 + - poppler-splash.pc.in | 3 +-- - 6 files changed, 19 insertions(+), 8 deletions(-) - -commit 9f0da96dd005defd5d82dd05b627ff1925430215 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Thu Jun 2 00:35:44 2005 +0000 - - 2005-06-01 Jeff Muizelaar <jeff@infidigm.net> - - * poppler/Error.cc: - * poppler/Error.h: Make error handling function setable through - setErrorFunction. - - Based on a patch by Albert Astals Cid. - - ChangeLog | 8 ++++++++ - poppler/Error.cc | 29 ++++++++++++++++++++--------- - poppler/Error.h | 2 ++ - 3 files changed, 30 insertions(+), 9 deletions(-) - -commit f688aa11d066f1c6f4115cbdb604ac61fb8b5146 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sun May 29 14:59:34 2005 +0000 - - 2005-05-29 Kristian Høgsberg <krh@redhat.com> - - * glib/*: Add more meta data properties to poppler document. - Patch by Emil Soleyman-Zomalan (#3359). - - ChangeLog | 5 ++ - glib/poppler-document.cc | 155 - ++++++++++++++++++++++++++++++++++++++++++++++- - glib/poppler.gidl | 5 ++ - glib/test-poppler-glib.c | 46 +++++++++----- - 4 files changed, 194 insertions(+), 17 deletions(-) - -commit 9e6eeec574d48d2341ee620e16360d3b21c40103 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu May 26 13:03:35 2005 +0000 - - 2005-05-26 Kristian Høgsberg <krh@redhat.com> - - * poppler/CairoOutputDev.cc (clip): Remove snapToGrid - so clip() - prototype matches what Gfx actually calls (fixes clipping). - - * poppler/CairoOutputDev.cc: Update fill color, stroke - color, fill - opacity and stroke opacity from GfxState on restore, - since they - aren't handled by cairo_restore() (#3362). - - * poppler/CairoOutputDev.cc: Comment out tolerance setting - until - we figure out how cairo settings relate to pdf settings. - - * poppler/CairoOutputDev.cc: Support fill and stroke opacity. - - ChangeLog | 12 ++++++++++++ - poppler/CairoOutputDev.cc | 41 ++++++++++++++++++++++++++++++----------- - poppler/CairoOutputDev.h | 6 +++++- - 3 files changed, 47 insertions(+), 12 deletions(-) - -commit 89a633edd860e3c6ded1e468edf6f28cfcb43d0e -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu May 26 12:52:38 2005 +0000 - - 2005-05-26 Kristian Høgsberg <krh@redhat.com> - - * poppler/GfxState.cc: - * poppler/GfxState.h: Add GfxColorSpace::getRGBLine here and - implement in subclasses. - - * poppler/CairoOutputDev.cc (drawImage): Use getRGBLine here. - - ChangeLog | 8 +++ - poppler/CairoOutputDev.cc | 66 +++++++++---------- - poppler/GfxState.cc | 160 - +++++++++++++++++++++++++++++++++++++++++++++- - poppler/GfxState.h | 14 ++++ - 4 files changed, 212 insertions(+), 36 deletions(-) - -commit 4d8224819da7a85e4d99f96c9bbb047ece58130a -Author: Jonathan Blandford <jrb@redhat.com> -Date: Mon May 23 04:23:53 2005 +0000 - - Mon May 23 00:22:41 2005 Jonathan Blandford <jrb@redhat.com> - - * glib/poppler-document.h: Add a permissions flag to the glib - bindings. - - ChangeLog | 5 +++++ - glib/poppler-document.cc | 24 ++++++++++++++++++++++++ - glib/poppler-document.h | 16 +++++++++------- - 3 files changed, 38 insertions(+), 7 deletions(-) - -commit 1f677e2f60634a7d0c5e0e0d2125ab15c2722979 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sat May 21 21:33:06 2005 +0000 - - 2005-05-21 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-document.cc (poppler_ps_file_new): Fix - off-by-one - error spotted by Jürg Billeter. - ----------------------------------------------------- - - ChangeLog | 5 +++++ - glib/poppler-document.cc | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit 0bbf2f08173866cde9b097eeeb1f4218a396588d -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri May 20 20:48:52 2005 +0000 - - 2005-05-20 Kristian Høgsberg <krh@redhat.com> - - * poppler/CairoOutputDev.cc: Account for different row - vs. column - vector conventions between cairo and poppler. - - ChangeLog | 3 +++ - poppler/CairoOutputDev.cc | 18 +++++++++--------- - 2 files changed, 12 insertions(+), 9 deletions(-) - -commit da44ec7e8de58e55e55b1f780bc3f4bc8307874f -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri May 20 18:38:10 2005 +0000 - - 2005-05-20 Kristian Høgsberg <krh@redhat.com> - - * poppler/CairoFontEngine.cc: Only get the code to gid map if - we're using freetype 2.1.7 or older (#3340). - - ChangeLog | 5 +++++ - poppler/CairoFontEngine.cc | 13 ++++++++----- - 2 files changed, 13 insertions(+), 5 deletions(-) - -commit 6fe29cf0a7e54b8d294471a0f94eb9e989ad1d7f -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu May 19 05:18:04 2005 +0000 - - Add bugzilla number. - - ChangeLog | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 42de1348622cf86a87bc22941bd48bffa943dac9 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu May 19 05:16:22 2005 +0000 - - 2005-05-19 Kristian Høgsberg <krh@redhat.com> - - * poppler/CairoFontEngine.cc: Only cast to Gfx8BitFont when we - know for sure we have a truetype font. - GfxCIDFont::getCIDToGIDLen() can return 0 in which case - codeToGID - will be NULL, and we end up casting it to a Gfx8BitFont. - - ChangeLog | 7 +++++++ - poppler/CairoFontEngine.cc | 2 +- - 2 files changed, 8 insertions(+), 1 deletion(-) - -commit afc05387c94a76ff0ed69b3f5d9a69ddd1448e83 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed May 18 17:39:59 2005 +0000 - - 2005-05-18 Kristian Høgsberg <krh@redhat.com> - - * configure.ac: Require cairo 0.5.0, bump release to 0.3.2. - - * NEWS: Sum up latest changes. - - * glib/poppler-document.cc (poppler_ps_file_new): Take a page - range here instead of just number of pages. - - ChangeLog | 9 +++++++++ - NEWS | 7 +++++++ - configure.ac | 6 +++--- - glib/poppler-document.cc | 15 ++++++++++----- - glib/poppler-document.h | 1 + - 5 files changed, 30 insertions(+), 8 deletions(-) - -commit 420134a194af9161282ccfe329d17adef8d325f2 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue May 17 23:38:27 2005 +0000 - - 2005-05-17 Kristian Høgsberg <krh@redhat.com> - - * poppler/CairoOutputDevX.cc: - * test/gtk-cairo-test.cc: Chase the cairo xlib constructor - again. - - ChangeLog | 5 +++++ - poppler/CairoOutputDevX.cc | 5 +++-- - test/gtk-cairo-test.cc | 5 +++-- - 3 files changed, 11 insertions(+), 4 deletions(-) - -commit 6fd62953a910dcfb4abd9de5ea18285b8fa5d202 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon May 16 23:16:15 2005 +0000 - - Add bug number and attribution to ChangeLog entry. - - ChangeLog | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 6d7f624c13e8a9a8251ac97388cd80e418c70250 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon May 16 21:56:31 2005 +0000 - - 2005-05-16 Kristian Høgsberg <krh@redhat.com> - - * configure.ac: Check for glib-mkenums. - - * glib/Makefile.am (poppler-enums.h): Generate glib enums at - compile time. - - * glib/poppler-enums.c: - * glib/poppler-enums.h: Removed. - - ChangeLog | 8 +++ - configure.ac | 3 + - glib/.cvsignore | 1 + - glib/Makefile.am | 67 ++++++++++++------ - glib/poppler-enums.c | 189 - --------------------------------------------------- - glib/poppler-enums.h | 49 ------------- - 6 files changed, 57 insertions(+), 260 deletions(-) - -commit 2801b54a944fc9e1072c5dcb9f1153a0c9f42de5 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon May 16 20:27:51 2005 +0000 - - 2005-05-16 Kristian Høgsberg <krh@redhat.com> - - * test/gtk-cairo-test.cc: Update this test case also. - - ChangeLog | 2 ++ - test/gtk-cairo-test.cc | 5 +++-- - 2 files changed, 5 insertions(+), 2 deletions(-) - -commit 8753ae8ba20fcceaef3ef1dda89129f0456fccf6 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon May 16 19:06:00 2005 +0000 - - 2005-05-16 Kristian Høgsberg <krh@redhat.com> - - * poppler/CairoOutputDevX.cc: Track changes to cairo Xlib - surface - constructors. - - * poppler/CairoFontEngine.cc (cairo_font_face_destroy): - Make this - static. - - ChangeLog | 8 ++++++++ - poppler/CairoFontEngine.cc | 2 +- - poppler/CairoOutputDevX.cc | 5 +++-- - 3 files changed, 12 insertions(+), 3 deletions(-) - -commit 2e17106ef4711097104a561d5be49980f8b2f5ab -Author: Jonathan Blandford <jrb@redhat.com> -Date: Fri May 13 03:47:36 2005 +0000 - - whoops! commit the right file. - - glib/poppler.gidl | 212 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++ - glib/test.gidl | 23 ------ - 2 files changed, 212 insertions(+), 23 deletions(-) - -commit 19b62e1c8ea8ce042ac089defe94f756dcaf194e -Author: Jonathan Blandford <jrb@redhat.com> -Date: Fri May 13 03:25:32 2005 +0000 - - Thu May 12 23:10:45 2005 Jonathan Blandford <jrb@redhat.com> - - * glib/poppler.gidl: add metadata file. - - ChangeLog | 4 ++++ - glib/test.gidl | 23 +++++++++++++++++++++++ - 2 files changed, 27 insertions(+) - -commit bef5a548f3b21e7220079155e9b5054fb0c6c3c7 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu May 12 21:26:25 2005 +0000 - - 2005-05-12 Kristian Høgsberg <krh@redhat.com> - - * poppler/CairoOutputDev.cc: - * poppler/CairoOutputDevX.cc: - * poppler/CairoOutputDevImage.cc: - * test/gtk-cairo-test.cc: Update to latest cairo changes, - patch - from Jens Taprogge (#3281) - - ChangeLog | 8 ++++++++ - poppler/CairoOutputDev.cc | 22 +++++++++++----------- - poppler/CairoOutputDevImage.cc | 11 ++++++----- - poppler/CairoOutputDevX.cc | 7 +++++-- - test/gtk-cairo-test.cc | 8 +++++--- - 5 files changed, 35 insertions(+), 21 deletions(-) - -commit c10ea2dd9bffaf9af023612ef196bab2b204d3e1 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed May 11 20:01:43 2005 +0000 - - 2005-05-11 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler.cc (poppler_get_backend, poppler_get_version): - Add - these functions so it's easy to tell if poppler is using - cairo or - splash and what version. - - * glib/test-poppler-glib.c (main): Print out version and - backend. - - ChangeLog | 8 ++++++++ - glib/poppler-enums.c | 26 ++++++++++++++++++++++++++ - glib/poppler-enums.h | 15 +++++++++++++++ - glib/poppler.cc | 21 +++++++++++++++++++++ - glib/poppler.h | 11 +++++++++++ - glib/test-poppler-glib.c | 9 ++++++++- - 6 files changed, 89 insertions(+), 1 deletion(-) - -commit 7d189e33cfa68e722561e9398ad85a77b538ab14 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri May 6 16:38:57 2005 +0000 - - 2005-05-06 Kristian Høgsberg <krh@redhat.com> - - * glib/Makefile.am (libpoppler_glib_la_LIBADD): Link - poppler-glib - against poppler. - - * qt/Makefile.am (libpoppler_qt_la_LIBADD): Ditto for qt. - - * poppler-glib.pc (Libs): Drop -lpoppler from link. - - * poppler-qt.pc (Libs): Ditto for qt. - - * configure.ac: Test for both libqt-mt.la and libqt-mt.so - in that - order. - - ChangeLog | 14 ++++++++++++++ - configure.ac | 8 +++++++- - glib/Makefile.am | 1 + - poppler-glib.pc.in | 2 +- - poppler-qt.pc.in | 2 +- - qt/Makefile.am | 1 + - qt/test-poppler-qt.cpp | 1 + - 7 files changed, 26 insertions(+), 3 deletions(-) - -commit c937e63f17a096b94a554103476ecb9ab1b71b90 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed May 4 20:08:41 2005 +0000 - - 2005-05-04 Kristian Høgsberg <krh@redhat.com> - - * poppler/CairoOutputDev.cc (CairoOutputDev::drawImageMask, - CairoOutputDev::drawImage): Track cairo cvs API changes; use - cairo_mask() and cairo_paint() for drawing image masks - and images. - - ChangeLog | 6 +++ - poppler/CairoOutputDev.cc | 98 - ++++++++++++++++++++++++----------------------- - 2 files changed, 57 insertions(+), 47 deletions(-) - -commit c142773ad30b409d8169a53921e731305de46e50 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed May 4 19:28:07 2005 +0000 - - 2005-05-04 Kristian Høgsberg <krh@redhat.com> - - * poppler/CairoOutputDev.cc: Fix matrix convention confusion. - - ChangeLog | 4 ++++ - poppler/CairoOutputDev.cc | 4 ++-- - 2 files changed, 6 insertions(+), 2 deletions(-) - -commit 28760927d724231d0137ca7ecc66c6c2250dff0d -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed May 4 19:11:11 2005 +0000 - - 2005-05-04 Kristian Høgsberg <krh@redhat.com> - - Patches from Albert Astals Cid: - - * qt/poppler-page.cc (getText): Use QString::fromUtf8() - instead of - implicit latin1 cast constructor. - - * qt/test-poppler-qt.cpp (main): Use a QLabel for showing text - instead of qDebug. - - ChangeLog | 10 ++++++++++ - qt/poppler-page.cc | 5 ++--- - qt/test-poppler-qt.cpp | 6 +++++- - 3 files changed, 17 insertions(+), 4 deletions(-) - -commit fd36522375bcf436639b8731acb3ad22c03c03f4 -Author: Jonathan Blandford <jrb@redhat.com> -Date: Wed May 4 06:32:38 2005 +0000 - - Wed May 4 02:31:05 2005 Jonathan Blandford <jrb@redhat.com> - - * glib/poppler-document.cc: - * glib/poppler-document.h: - * glib/poppler-enums.c: (poppler_permissions_get_type): - * glib/poppler-enums.h: - * glib/poppler-page.cc: - * glib/poppler-page.h: - * glib/poppler.h: - - Register a bunch of boxed types to test introspection, and for - LBs. Also, remove unused 'popper_document_save()' (-: - - ChangeLog | 13 ++++++++ - glib/poppler-document.cc | 48 ++++++++++++++++------------ - glib/poppler-document.h | 18 +++++++++-- - glib/poppler-enums.c | 19 +++++++++++ - glib/poppler-enums.h | 2 ++ - glib/poppler-page.cc | 83 - ++++++++++++++++++++++++++++++++++++++++++++++++ - glib/poppler-page.h | 36 ++++++++++++++------- - glib/poppler.h | 12 ++++--- - 8 files changed, 193 insertions(+), 38 deletions(-) - -commit 132647f8311c07b1f95ee4fca185e9774aae4913 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon May 2 05:39:11 2005 +0000 - - 2005-05-01 Kristian Høgsberg <krh@redhat.com> - - * poppler/CairoFontEngine.cc: - * poppler/CairoFontEngine.h: - * poppler/CairoOutputDev.cc: Back out workaround for cairo - 0.4.0 - font API and port to new cairo head. - - ChangeLog | 7 +++++ - configure.ac | 4 +-- - poppler/CairoFontEngine.cc | 67 - +++++++++++++++++------------------------- - poppler/CairoFontEngine.h | 12 ++++---- - poppler/CairoOutputDev.cc | 39 ++++++++++++++---------- - poppler/CairoOutputDevImage.cc | 2 +- - 6 files changed, 66 insertions(+), 65 deletions(-) - -commit 595c18c038f8dcef73fe58612fc8b93f891e65a1 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Mon May 2 00:44:26 2005 +0000 - - 2005-05-01 Jeff Muizelaar <jeff@infidigm.net> - - * splash/SplashFTFont.cc (SplashFTFont::getGlyphPath): - Use FT_LOAD_NO_BITMAP to make sure we get outlines loaded instead - of bitmaps for use in FT_Outline_Decompose. - - Patch from Albert Astals Cid. - - ChangeLog | 8 ++++++++ - splash/SplashFTFont.cc | 2 +- - 2 files changed, 9 insertions(+), 1 deletion(-) - -commit 49d89ca0ed3986bec7468f6c0ed295e84ba67239 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sun May 1 21:54:55 2005 +0000 - - 2005-05-01 Jeff Muizelaar <jeff@infidigm.net> - - * goo/gmem.c: (gmalloc), (grealloc), (gfree): - * goo/gmem.h: make memory functions use size_t instead of int. - - Patch from Takashi Iwai through Albert Astals Cid. - - ChangeLog | 7 +++++++ - goo/gmem.c | 10 +++++----- - goo/gmem.h | 4 ++-- - 3 files changed, 14 insertions(+), 7 deletions(-) - -commit 14d618bece894e4c6bed0f179a8fda4db5a67c9d -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sat Apr 30 19:53:57 2005 +0000 - - 2005-04-30 Jeff Muizelaar <jeff@infidigm.net> - - * qt/poppler-document.cc (Document::unlock) : - * qt/poppler-qt.h (Document::unlock): - Add const to the password argument. - - Patch from Albert Astals Cid. - - ChangeLog | 8 ++++++++ - qt/poppler-document.cc | 2 +- - qt/poppler-qt.h | 2 +- - 3 files changed, 10 insertions(+), 2 deletions(-) - -commit 1e66da32964cc76c6ed3773574f422b4608cb0e1 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sat Apr 30 17:31:47 2005 +0000 - - 2005-04-30 Jeff Muizelaar <jeff@infidigm.net> - - * fofi/FoFiType1.cc (FoFiType1::parse): - Don't assume Encoding array of Type1 fonts end in "foo def". - http://partners.adobe.com/public/developer/en/font/T1_SPEC.PDF - says - "This sequence of assignments must be followed by an instance - of the - token def or readonly; such a token may not occur within the - sequence - of assignments." so it must end with "readonly" "def" "readonly - def" - (That is what most fonts are using and this is why it was not - crashing) - - Patch from Albert Astals Cid. - - ChangeLog | 13 +++++++++++++ - fofi/FoFiType1.cc | 14 +++++++++++--- - 2 files changed, 24 insertions(+), 3 deletions(-) - -commit 0b532db77ef41937dd5be30d15c96557d81eceb2 -Author: Jonathan Blandford <jrb@redhat.com> -Date: Fri Apr 29 19:37:07 2005 +0000 - - Fri Apr 29 14:54:44 2005 Jonathan Blandford <jrb@redhat.com> - - * goo/GooTimer.h: New class to do simple timing checks. - - * glib/poppler-document.c: Patch from Martin Kretzschmar - to really - set the PDF version correct. Third time's the charm. - - ChangeLog | 7 ++++++ - glib/poppler-document.cc | 4 ++- - goo/GooTimer.cc | 63 - ++++++++++++++++++++++++++++++++++++++++++++++++ - goo/GooTimer.h | 40 ++++++++++++++++++++++++++++++ - goo/Makefile.am | 2 ++ - 5 files changed, 115 insertions(+), 1 deletion(-) - -commit 38948ea6f9ef76dae9b8a7156fe1ef32a0457380 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Apr 29 03:57:16 2005 +0000 - - 2005-04-29 Kristian Høgsberg <krh@bitplanet.net> - - * configure.ac: Bump release to 0.3.1. - - * NEWS: Write up news for 0.3.1 release. - - ChangeLog | 6 ++++++ - NEWS | 6 ++++++ - configure.ac | 2 +- - 3 files changed, 13 insertions(+), 1 deletion(-) - -commit af65146c92682a3af06e9d3147426445c78309de -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Apr 28 23:03:06 2005 +0000 - - 2005-04-28 Kristian Høgsberg <krh@redhat.com> - - Patch from Martin Kretzschmar: - - * poppler/GlobalParams.cc: use UTF-8 as the default text - encoding. - Fixes Bug 2934. - - ChangeLog | 7 +++++++ - poppler/GlobalParams.cc | 2 +- - 2 files changed, 8 insertions(+), 1 deletion(-) - -commit c2db3e1b297a9dc0accd0d8a1366970d45705c8f -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed Apr 27 20:56:18 2005 +0000 - - 2005-04-27 Jeff Muizelaar <jeff@infidigm.net> - - * configure.ac: - * poppler/FlateStream.cc: - * poppler/FlateStream.h: - * poppler/Makefile.am: - * poppler/Stream.cc: - * poppler/Stream.h: Add a reimplementation of FlateStream using - zlib. - - ChangeLog | 10 +++++ - configure.ac | 29 ++++++++++++++ - poppler/FlateStream.cc | 107 - +++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/FlateStream.h | 68 +++++++++++++++++++++++++++++++ - poppler/Makefile.am | 17 +++++++- - poppler/Stream.cc | 6 +++ - poppler/Stream.h | 2 + - 7 files changed, 237 insertions(+), 2 deletions(-) - -commit bc0afe524c2b87af191d83fc9e9bcdc8a6ce4042 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed Apr 27 18:53:20 2005 +0000 - - 2005-04-27 Kristian Høgsberg <krh@redhat.com> - - * poppler/Catalog.cc (NameTree::lookup): Fix bsearch return - value - NULL check. Found by Albert Astals Cid. - - ChangeLog | 5 +++++ - poppler/Catalog.cc | 8 ++++---- - 2 files changed, 9 insertions(+), 4 deletions(-) - -commit 3c37dc350d54e5a1035aecfba5bfa394f931cf51 -Author: Jonathan Blandford <jrb@redhat.com> -Date: Tue Apr 26 17:17:05 2005 +0000 - - Tue Apr 26 13:13:42 2005 Jonathan Blandford <jrb@redhat.com> - - * glib/test-poppler-glib.c (main): add a quick dump-to-text - test. - - ChangeLog | 4 ++++ - glib/test-poppler-glib.c | 20 ++++++++++++++++++++ - 2 files changed, 24 insertions(+) - -commit 44b800d520f90ffd143255d2c23835ea357c195b -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Apr 25 18:04:32 2005 +0000 - - Actually commit the qt/Makefile.am change advertised in the ChangeLog. - - qt/Makefile.am | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 437bec03dd2ab3cdf6215f9ad443b7f21ce84e18 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sun Apr 24 19:56:17 2005 +0000 - - 2005-04-24 Kristian Høgsberg <krh@redhat.com> - - * qt/Makefile.am (libpoppler_qt_la_SOURCES): Add - poppler-private.h - to SOURCES. - - ChangeLog | 5 +++++ - 1 file changed, 5 insertions(+) - -commit 9b2b1244ed5f30a99120aaee49c72f7cb6a4f556 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sat Apr 23 20:16:02 2005 +0000 - - 2005-04-23 Kristian Høgsberg <krh@redhat.com> - - * poppler/CairoFontEngine.cc: Use the right fileName for - loading - CID fonts (#3114). - - ChangeLog | 5 +++++ - poppler/CairoFontEngine.cc | 11 +++++++++-- - 2 files changed, 14 insertions(+), 2 deletions(-) - -commit e4516d728a4d1bc85831d5d00b6d6b8d49c79308 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sat Apr 23 00:09:05 2005 +0000 - - 2005-04-22 Kristian Høgsberg <krh@redhat.com> - - * configure.ac: Actually commit version number bump. - - ChangeLog | 4 ++++ - NEWS | 2 +- - configure.ac | 2 +- - 3 files changed, 6 insertions(+), 2 deletions(-) - -commit c20448cb26fa1c309d726f272ddf1227f5a0e6ea -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Apr 22 17:29:49 2005 +0000 - - 2005-04-22 Martin Kretzschmar <martink@gnome.org> - - * poppler/CairoFontEngine.cc: declare matrix variable - before the - first goto. Fixes build with gcc 3.3. - - ChangeLog | 5 +++++ - poppler/CairoFontEngine.cc | 3 ++- - 2 files changed, 7 insertions(+), 1 deletion(-) - -commit 42ecccf9b454893797e3d62f0f1c0a3276689e51 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Apr 22 04:09:23 2005 +0000 - - Fri Apr 22 00:01:40 2005 Kristian Høgsberg <krh@redhat.com> - - * poppler/CairoFontEngine.cc: Hack around semi-broken - cairo-0.4.0 - font API to fix the problem where some glyphs would show up - at the - wrong sizes. We now create an FT_Face for each size and font - combination we encounter, since an FT_Face can't be shared - between - several cairo_font_t. - - ChangeLog | 8 +++++ - poppler/CairoFontEngine.cc | 79 - ++++++++++++++++++++-------------------------- - poppler/CairoFontEngine.h | 23 ++++++-------- - poppler/CairoOutputDev.cc | 18 +++++------ - 4 files changed, 61 insertions(+), 67 deletions(-) - -commit 7a703616d9497eba4d7d318da9918dae9cbe8f12 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Apr 21 19:50:45 2005 +0000 - - Thu Apr 21 15:43:52 2005 Kristian Høgsberg <krh@redhat.com> - - * poppler/Outline.cc: - * poppler/Outline.h: Implement the documented behaviour for - Outline::getItems() and OutlineItem::getKids() and make - documentation more precise (Patch from Marco). - - ChangeLog | 7 +++++++ - poppler/Outline.cc | 6 ++++++ - poppler/Outline.h | 7 ++++--- - 3 files changed, 17 insertions(+), 3 deletions(-) - -commit 5c89902c5ee2cf13536225c141768b29505815ce -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Apr 21 06:35:33 2005 +0000 - - Thu Apr 21 02:25:20 2005 Kristian Høgsberg <krh@redhat.com> - - * poppler/CairoFontEngine.cc (CairoFont::getFont): Cache - cairo_font_t's for a given CairoFont. With this patch - cairo will - recognize glyphs coming from the same font as such and - the glyph - cache will actually work. - - * glib/poppler-document.cc (poppler_document_new_from_file): - Add - output device (cairo or splash) to PopplerDocument and - initialize - it in the constructor. - - * glib/poppler-page.cc (splash_render_to_pixbuf, - cairo_render_to_pixbuf): Use output device from associated - poppler - document instead of creating a new one. - - * poppler-glib.pc.in (Requires): Add Requires: field. - - * poppler/Page.cc (loadThumb): Remove unecessary and buggy - call to - Stream::addFilters(), reported by Ryan Lortie (#3046). - - ChangeLog | 7 ++++++- - NEWS | 12 +++--------- - poppler/CairoFontEngine.cc | 45 - +++++++++++++++++++++++++++++++++++++++------ - poppler/CairoFontEngine.h | 9 ++++++++- - poppler/CairoOutputDev.cc | 9 +-------- - 5 files changed, 57 insertions(+), 25 deletions(-) - -commit 71c1563bb0462154cb7caa4356d8f8d049073ac4 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Apr 21 05:20:24 2005 +0000 - - Thu Apr 21 00:15:30 2005 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-document.cc (poppler_document_new_from_file): - Add - output device (cairo or splash) to PopplerDocument and - initialize - it in the constructor. - - * glib/poppler-page.cc (splash_render_to_pixbuf, - cairo_render_to_pixbuf): Use output device from associated - poppler - document instead of creating a new one. - - * poppler-glib.pc.in (Requires): Add Requires: field. - - * poppler/Page.cc (loadThumb): Remove unecessary and buggy - call to - Stream::addFilters(), reported by Ryan Lortie (#3046). - - ChangeLog | 15 +++++++++++++++ - NEWS | 15 +++++++++++++++ - glib/poppler-document.cc | 10 ++++++++++ - glib/poppler-page.cc | 22 ++-------------------- - glib/poppler-private.h | 13 +++++++++++++ - poppler-glib.pc.in | 1 + - poppler/CairoFontEngine.cc | 2 +- - poppler/Page.cc | 2 -- - 8 files changed, 57 insertions(+), 23 deletions(-) - -commit c6328cbc6cea05890b52a8302f8deba443959c03 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed Apr 20 22:48:52 2005 +0000 - - 2005-04-13 Jeff Muizelaar <jrmuizel@nit.ca> - - * qt/poppler-page.cc (Page::getText): - * qt/poppler-qt.h: add a getText method for getting - the text on a page - - * qt/test-poppler-qt.c (PDFDisplay::PDFDisplay): - add the option to display the text on a page - - Patch from Albert Astals Cid. - - ChangeLog | 11 +++++++++++ - qt/poppler-page.cc | 37 +++++++++++++++++++++++++++++++++++++ - qt/poppler-qt.h | 20 ++++++++++++++++++++ - qt/test-poppler-qt.cpp | 40 ++++++++++++++++++++++++++++++---------- - 4 files changed, 98 insertions(+), 10 deletions(-) - -commit 86a32b65100a5baedd18ce0135703289839a317c -Author: Jonathan Blandford <jrb@redhat.com> -Date: Tue Apr 19 21:22:26 2005 +0000 - - Tue Apr 19 17:21:19 2005 Jonathan Blandford <jrb@redhat.com> - - * glib/poppler-document.cc (poppler_document_get_property): - Use - %.2g instead. - - ChangeLog | 5 +++++ - glib/poppler-document.cc | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit 4e81624dcc2d5218f2f8bb4eaa992e724014a853 -Author: Jonathan Blandford <jrb@redhat.com> -Date: Tue Apr 19 21:13:22 2005 +0000 - - Tue Apr 19 17:11:52 2005 Jonathan Blandford <jrb@redhat.com> - - * glib/poppler-document.cc (poppler_document_get_property): - Use %g - instead of %f to avoid versioning like PDF-1.50000 - - ChangeLog | 5 +++++ - glib/poppler-document.cc | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit 6ef9d30f06be2bd8a9e1470d70f49843a7e432ac -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue Apr 19 19:48:49 2005 +0000 - - Tue Apr 19 15:43:35 2005 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-action.cc (_poppler_action_new): Handle - NULL links - gracefully (fix from Jeff). - - ChangeLog | 5 +++++ - glib/poppler-action.cc | 7 ++++++- - 2 files changed, 11 insertions(+), 1 deletion(-) - -commit 770b7310ce8b07f95960c2014bf3f6040c060ac4 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue Apr 19 04:28:15 2005 +0000 - - Tue Apr 19 00:20:08 2005 Kristian Høgsberg <krh@redhat.com> - - * poppler/Catalog.cc: Fix from Marco to make sure we always - initialize Catalog::pageLabelInfo. - - ChangeLog | 5 +++++ - poppler/Catalog.cc | 3 +-- - 2 files changed, 6 insertions(+), 2 deletions(-) - -commit 49c10d9f2c4e0cef031f96929e38a14d7ce5af19 -Author: Jonathan Blandford <jrb@redhat.com> -Date: Sat Apr 16 18:57:43 2005 +0000 - - Sat Apr 16 14:53:15 2005 Jonathan Blandford <jrb@redhat.com> - - * glib/Makefile.am: Create poppler-enums.[ch] - - * glib/poppler.h: - * glib/poppler-page.cc: - * glib/poppler-page.h: - * glib/poppler-action.h: Try to clean up the headers a bit - - * glib/poppler-document.cc: - * glib/poppler-document.h: Add support for document data. - Implemented as a lot of GObject properties. - - * glib/poppler-enums.c: - * glib/poppler-enums.h: New autogenerated files. - - * glib/test-poppler-glib.c: Test the new document metadata. - Seems - to work nicely, other than the PDF string and View Prefs. - - * poppler/Catalog.cc: - * poppler/Catalog.h: Extend to support PageLayout. - - ChangeLog | 22 ++++++ - glib/Makefile.am | 32 +++++++- - glib/poppler-action.h | 15 ++-- - glib/poppler-document.cc | 196 - ++++++++++++++++++++++++++++++++++++++++++----- - glib/poppler-document.h | 43 +++++++++-- - glib/poppler-enums.c | 144 ++++++++++++++++++++++++++++++++++ - glib/poppler-enums.h | 32 ++++++++ - glib/poppler-page.cc | 3 - - glib/poppler-page.h | 1 + - glib/poppler.h | 7 ++ - glib/test-poppler-glib.c | 48 +++++++++++- - poppler/Catalog.cc | 17 ++++ - poppler/Catalog.h | 11 +++ - 13 files changed, 529 insertions(+), 42 deletions(-) - -commit f35c76cd3528f1e1de594e85e734ca23624b3a62 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Apr 15 02:25:10 2005 +0000 - - 2005-04-14 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc: - * glib/poppler-page.h: - * glib/poppler-private.h: - * glib/poppler.h: Patch from Marco Pesenti Gritti to set page - orientaton. - - ChangeLog | 8 ++++ - glib/poppler-page.cc | 109 - +++++++++++++++++++++++++++++++++++++++++++++---- - glib/poppler-page.h | 45 ++++++++++---------- - glib/poppler-private.h | 1 + - glib/poppler.h | 9 ++++ - 5 files changed, 142 insertions(+), 30 deletions(-) - -commit 538408a8845e167cc2d796ac8b8129d0a2e6a894 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Thu Apr 14 01:34:38 2005 +0000 - - 2005-04-13 Jeff Muizelaar <jrmuizel@nit.ca> - - * poppler/CairoOutputDevImage.cc (getBitmap): remove unused - SplashBitmap. Patch from Albert Astals Cid. - - ChangeLog | 5 +++++ - poppler/CairoOutputDevImage.cc | 2 -- - 2 files changed, 5 insertions(+), 2 deletions(-) - -commit 2903530492c24f3c7cb3bf3b993500694aaa27a8 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue Apr 12 15:37:39 2005 +0000 - - 2005-04-12 Kristian Høgsberg <krh@redhat.com> - - * configure.ac: Add fontconfig to PKG_CHECK_MODULES for - the cairo - backend too, since we shouldn't depend on cairo.pc to pull - that in - for us. - - * poppler/Makefile.am (INCLUDES): Add $(splash_includes) to - INCLUDES to make sure the fontconfig include path is - added when - using the splash backend. - - ChangeLog | 10 ++++++++++ - configure.ac | 4 ++-- - poppler/Makefile.am | 1 + - 3 files changed, 13 insertions(+), 2 deletions(-) - -commit 0f7dd9a0512ff97293ee3f8a762b0049393b3cc1 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sat Apr 9 18:14:39 2005 +0000 - - 2005-04-09 Jeff Muizelaar <jrmuizel@nit.ca> - - * poppler-qt.h: - * poppler-document.cc (okToPrint, okToChange, okToCopy): - Patch from Albert Astals Cid adding more metadata exports - - ChangeLog | 6 ++++++ - qt/poppler-document.cc | 20 ++++++++++++++++++++ - qt/poppler-qt.h | 4 ++++ - 3 files changed, 30 insertions(+) - -commit dee72b531dab83a29c7675ae06ffe376e4498a4e -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Apr 8 21:09:27 2005 +0000 - - 2005-04-08 Kristian Høgsberg <krh@redhat.com> - - * poppler-qt.pc.in (Libs): Add -lpoppler to Libs. - - ChangeLog | 4 ++++ - poppler-qt.pc.in | 2 +- - 2 files changed, 5 insertions(+), 1 deletion(-) - -commit df59ce3b1d5ca8cd46aaf5f189bc78953e21e1a9 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Fri Apr 8 03:30:33 2005 +0000 - - 2005-04-07 Jeff Muizelaar <jrmuizel@nit.ca> - - * configure.ac: redo the qt tests from Albert Astals Cid - - ChangeLog | 4 ++++ - configure.ac | 78 - ++++++++++++++++++++++++++++++++++++------------------------ - 2 files changed, 51 insertions(+), 31 deletions(-) - -commit 3f9dde10e4778255c468895942e45d1a2637af3a -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Fri Apr 8 03:11:00 2005 +0000 - - 2005-04-07 Jeff Muizelaar <jrmuizel@nit.ca> - - * qt/poppler-document.cc: - * qt/poppler-page.cc: - * qt/poppler-qt.h: - Patch from Albert Astals Cid adding consts and exporting some more - metadata. - - ChangeLog | 8 ++++++++ - qt/poppler-document.cc | 21 ++++++++++++++++++--- - qt/poppler-page.cc | 6 +++--- - qt/poppler-qt.h | 15 +++++++++------ - 4 files changed, 38 insertions(+), 12 deletions(-) - -commit e79a8b946e0d04b32da0b4ceea1649efd203cb07 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Apr 7 22:01:51 2005 +0000 - - 2005-04-07 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-document.cc: - * glib/poppler-document.h: - * glib/poppler-page.cc: - * glib/poppler-page.h: - * glib/poppler-private.h: Print to PS support from Marco - Pesenti - Gritti. - - ChangeLog | 9 +++++++++ - glib/poppler-document.cc | 45 - +++++++++++++++++++++++++++++++++++++++++++++ - glib/poppler-document.h | 8 ++++++-- - glib/poppler-page.cc | 19 +++++++++++++++++++ - glib/poppler-page.h | 40 +++++++++++++++++++++------------------- - glib/poppler-private.h | 7 +++++++ - 6 files changed, 107 insertions(+), 21 deletions(-) - -commit 7319b66eb64e735ae8b811306eb76755f088385b -Author: Jonathan Blandford <jrb@redhat.com> -Date: Thu Apr 7 16:26:15 2005 +0000 - - Thu Apr 7 12:25:39 2005 Jonathan Blandford <jrb@redhat.com> - - * configure.ac: check for qt, not glib, when enabling the qt - subdir - - ChangeLog | 5 +++++ - configure.ac | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit e258ed0cb42d524ee39451f680ad4c067e7721da -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed Apr 6 20:49:19 2005 +0000 - - 2005-04-06 Jeff Muizelaar <jrmuizel@nit.ca> - - * .cvsignore, glib/.cvsignore, qt/.cvsignore: - Add more things to .cvsignore. - Patch from Martin Kretzschmar. - - .cvsignore | 2 ++ - ChangeLog | 6 ++++++ - glib/.cvsignore | 7 +++++++ - qt/.cvsignore | 7 +++++++ - 4 files changed, 22 insertions(+) - -commit 2a5624a81aa84677a57e098d7d4045f44e3b6f3a -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed Apr 6 20:35:03 2005 +0000 - - 2005-04-06 Jeff Muizelaar <jrmuizel@nit.ca> - - * poppler-page.cc (Page::Page, Page::~Page): - Construct and deconstruct the PageData object. - Patch from Albert Astals Cid. - - ChangeLog | 6 ++++++ - qt/poppler-page.cc | 6 ++++++ - qt/poppler-qt.h | 1 + - 3 files changed, 13 insertions(+) - -commit f983e3d317660653f2bfc56f9b06e2cec675beca -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed Apr 6 14:39:40 2005 +0000 - - 2005-04-06 Jeff Muizelaar <jrmuizel@nit.ca> - - * Makefile.am, configure.ac: Add configuration for qt wrapper. - - * poppler-qt.pc.in: - * qt/Makefile.am: - * qt/poppler-document.cc: - * qt/poppler-page.cc: - * qt/poppler-private.h: - * qt/poppler-qt.h: - * qt/test-poppler-qt.cpp: - New files. - - ChangeLog | 13 +++ - Makefile.am | 13 ++- - configure.ac | 64 +++++++++++++- - poppler-qt.pc.in | 11 +++ - qt/Makefile.am | 32 +++++++ - qt/poppler-document.cc | 232 - +++++++++++++++++++++++++++++++++++++++++++++++++ - qt/poppler-page.cc | 66 ++++++++++++++ - qt/poppler-private.h | 32 +++++++ - qt/poppler-qt.h | 75 ++++++++++++++++ - qt/test-poppler-qt.cpp | 63 ++++++++++++++ - 10 files changed, 597 insertions(+), 4 deletions(-) - -commit d91dd69a7a0dd581c26728d2640e4d36a7ffe75f -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue Apr 5 17:46:44 2005 +0000 - - 2005-04-05 Kristian Høgsberg <krh@redhat.com> - - * NEWS: Attempt to sum up changes since 0.1.2. - - * configure.ac: Bump release to 0.2.0, add AC_DEFINEs - for cairo - and splash availability. - - * poppler/CairoFontEngine.cc: Disable hinting. - - * glib/poppler-page.cc (poppler_page_render_to_pixbuf): Choose - either splash or cairo rendering, based on configure choice. - (cairo_render_to_pixbuf): New function to render using - the cairo - backend. - (splash_render_to_pixbuf): Split out the splash code to this - function. - - ChangeLog | 16 +++++ - NEWS | 6 +- - configure.ac | 16 +++-- - glib/Makefile.am | 17 ++++- - glib/poppler-page.cc | 152 - +++++++++++++++++++++++++++++++++-------- - poppler/CairoFontEngine.cc | 2 +- - poppler/CairoOutputDevImage.cc | 20 ++---- - poppler/CairoOutputDevImage.h | 3 +- - 8 files changed, 179 insertions(+), 53 deletions(-) - -commit b62b0cec2335d987b31fbb0043cb33db29cc6a13 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue Apr 5 02:56:32 2005 +0000 - - 2005-04-04 Kristian Høgsberg <krh@redhat.com> - - * ChangeLog: Add this entry to test commit mailer script. - - ChangeLog | 2 ++ - 1 file changed, 2 insertions(+) - -commit 50b494266ce197fe88468ca2917b9910d77e5f98 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue Apr 5 02:49:18 2005 +0000 - - 2005-04-04 Kristian Høgsberg <krh@redhat.com> - - * TODO: Add reminder about using PDF font descriptors with - fontconfig. - - ChangeLog | 3 +++ - TODO | 2 ++ - 2 files changed, 5 insertions(+) - -commit d3d12235bf4de48363571b3d992ea3bfc29e6529 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Apr 4 21:50:56 2005 +0000 - - 2005-04-04 Kristian Høgsberg <krh@redhat.com> - - * configure.ac: Add checks for mkstemp() and mkstemps(). - - * glib/poppler-page.cc (poppler_page_find_text): Reverse - y-coordinates so we return PDF style coordinates. - - From Maro Pesenti Gritti <mpgritti@gmail.com>: - - * configure.ac, poppler/Makefile.am: Check for fontconfig when - we're building the splash backend. - - * glib/poppler-page.cc (poppler_page_get_text): New - function to - select text on page. - - ChangeLog | 15 +++++++++++++++ - configure.ac | 5 ++++- - glib/poppler-page.cc | 48 - +++++++++++++++++++++++++++++++++++++++++++++--- - glib/poppler-page.h | 3 +++ - poppler/Makefile.am | 4 ++++ - 5 files changed, 71 insertions(+), 4 deletions(-) - -commit 2cb9d70678e33504246cbfbe0525c33f5e3b7736 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Apr 4 05:56:29 2005 +0000 - - 2005-04-04 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc (poppler_page_find_text): Reverse - list of - matches so we get them in the right order. - - ChangeLog | 5 +++++ - glib/poppler-page.cc | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit 8c2a5ffb73c0f2d84adebcfbd43f8347ae8c8bbc -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sun Apr 3 18:17:55 2005 +0000 - - 2005-04-03 Martin Kretzschmar <martink@gnome.org> - - * poppler/DCTStream.h: Wrap #include <jpeglib.h> in extern "C" - Fixes build with unpatched libjpeg. - - ChangeLog | 5 +++++ - poppler/DCTStream.h | 2 ++ - 2 files changed, 7 insertions(+) - -commit 1879d82d9088aa36ef5e677f4bae44c84f90caa6 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Sat Apr 2 22:16:38 2005 +0000 - - 2005-04-02 Jeff Muizelaar <jrmuizel@nit.ca> - - * poppler/Page.h: - * poppler/Page.cc (Page::Page): - Some initial infrastructure for supporting transitions. - - ChangeLog | 6 ++++++ - poppler/Page.cc | 10 ++++++++++ - poppler/Page.h | 4 ++++ - 3 files changed, 20 insertions(+) - -commit fa4efbed51e12811070798a7cfb6b1f9e8d57abc -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Apr 1 00:32:34 2005 +0000 - - 2005-03-31 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc (poppler_page_render_to_pixbuf): Clip - output to destination pixbuf and fix RGB order. - - ChangeLog | 5 +++++ - glib/poppler-page.cc | 38 +++++++++++++++++++++++--------------- - 2 files changed, 28 insertions(+), 15 deletions(-) - -commit bb508ded0b8c5806a9db1ec73e57b14268896911 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Mar 31 22:45:05 2005 +0000 - - 2005-03-31 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc (poppler_page_find_text): New - function to - seach a page for occurrences of a given text string. - - * glib/poppler-page.cc: Add g_return_if_fail() checks to - a couple - of functions. - - ChangeLog | 8 +++++ - glib/poppler-page.cc | 82 - ++++++++++++++++++++++++++++++++++++++++++------ - glib/poppler-page.h | 18 ++++++++--- - glib/test-poppler-glib.c | 19 +++++++++-- - 4 files changed, 109 insertions(+), 18 deletions(-) - -commit 0b4d481e9c79cb18cf41b503970801bbf4b95b3c -Author: Jonathan Blandford <jrb@redhat.com> -Date: Thu Mar 31 05:29:42 2005 +0000 - - Thu Mar 31 00:26:20 2005 Jonathan Blandford <jrb@redhat.com> - - * glib/poppler-page.cc: - * glib/poppler-page.h (poppler_page_get_link_mapping, - poppler_page_free_link_mapping): New functions to get a - mapping of - links to locations on the current document. - :s - - ChangeLog | 7 +++++ - glib/poppler-page.cc | 85 - ++++++++++++++++++++++++++++++++++++++++++++++++---- - glib/poppler-page.h | 15 ++++++++++ - 3 files changed, 102 insertions(+), 5 deletions(-) - -commit c4e18f5a454794bd5e226f1106a54ccf807c6c3d -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Thu Mar 31 02:28:46 2005 +0000 - - 2005-03-30 Jeff Muizelaar <jrmuizel@nit.ca> - - * poppler/DCTStream.h: change x to unsigned int to eliminate - comparision warning - - ChangeLog | 5 +++++ - poppler/DCTStream.h | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -commit e6a2a588305b4797af901599eb6854028f2be476 -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed Mar 30 18:43:44 2005 +0000 - - 2005-03-30 Jeff Muizelaar <jrmuizel@nit.ca> - - * poppler/Catalog.cc: delete pageLabelInfo on deconstruction - - ChangeLog | 4 ++++ - poppler/Catalog.cc | 1 + - 2 files changed, 5 insertions(+) - -commit a52905c0f0bf4d10d2103b80924a4de204d03836 -Author: Jonathan Blandford <jrb@redhat.com> -Date: Wed Mar 30 04:08:26 2005 +0000 - - add this - - glib/poppler-action.cc | 285 - +++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 285 insertions(+) - -commit 9542860a74076020b5727d4b761c08cdab42d69e -Author: Jonathan Blandford <jrb@redhat.com> -Date: Wed Mar 30 04:07:57 2005 +0000 - - add these - - glib/poppler-action.h | 157 - ++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 157 insertions(+) - -commit 07720f98eca8736695f7d0d8e98465d301e6b7cf -Author: Jonathan Blandford <jrb@redhat.com> -Date: Wed Mar 30 04:07:39 2005 +0000 - - Tue Mar 29 23:07:17 2005 Jonathan Blandford <jrb@redhat.com> - - * glib/poppler-page.h: Reformat. - - ChangeLog | 4 ++++ - glib/poppler-page.h | 34 +++++++++++++++++----------------- - 2 files changed, 21 insertions(+), 17 deletions(-) - -commit 3437b9e122aa05f4ede24664ee5a9b2d423ef9c4 -Author: Jonathan Blandford <jrb@redhat.com> -Date: Wed Mar 30 04:04:53 2005 +0000 - - Tue Mar 29 22:49:15 2005 Jonathan Blandford <jrb@redhat.com> - - * glib/poppler-action.[ch]: New item to encapsulate links. - * glib/poppler-document.[ch] (poppler_index_iter_get_action): - New - function to get the action. Also, fix some warnings. - * glib/poppler-private.h (_poppler_action_new): New function. - * glib/test-poppler-glib.c: Fix warnings. - - ChangeLog | 8 +++++++ - glib/Makefile.am | 2 ++ - glib/poppler-document.cc | 57 - +++++++++++------------------------------------- - glib/poppler-document.h | 7 ++---- - glib/poppler-private.h | 12 ++++++++-- - glib/poppler.h | 1 + - glib/test-poppler-glib.c | 4 +++- - 7 files changed, 39 insertions(+), 52 deletions(-) - -commit cab0ec4d011c34b571050a446c6e3286cc8749c8 -Author: Jonathan Blandford <jrb@redhat.com> -Date: Tue Mar 29 18:49:26 2005 +0000 - - Tue Mar 29 02:36:00 2005 Jonathan Blandford <jrb@redhat.com> - - * glib/poppler-document.[ch] (PopplerIndexIter): Add an - iter to - extract the index from the doc. Includes a bad hack, for now. - - Mon Mar 28 22:02:07 2005 Jonathan Blandford <jrb@redhat.com> - - * glib/poppler-page.cc: - * glib/poppler-page.h (poppler_page_get_thumbnail_size): New - function. - * poppler-glib.pc.in: add -lpoppler-glib to the libs line. - - ChangeLog | 12 ++++ - glib/poppler-document.cc | 160 - ++++++++++++++++++++++++++++++++++++++++++++++- - glib/poppler-document.h | 15 +++++ - glib/poppler-page.cc | 48 +++++++++++++- - glib/poppler-page.h | 3 + - poppler-glib.pc.in | 2 +- - 6 files changed, 236 insertions(+), 4 deletions(-) - -commit 2de98f3871bc4ea3e361ca4fe37f5b6561918c77 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Mar 28 07:49:54 2005 +0000 - - 2005-03-28 Kristian Høgsberg <krh@redhat.com> - - * poppler/Page.cc (loadThumb): Backend agnostic method for - extracting an embedded thumbnail iamge. - - * poppler/Dict.cc (lookupInt): New convenience method. - - * glib/poppler-page.cc (poppler_page_get_thumbnail): New glib - function for getting the embedded thumbnail image for a page. - - ChangeLog | 10 +++++ - glib/poppler-page.cc | 23 ++++++++++ - glib/poppler-page.h | 32 +++++++------- - glib/test-poppler-glib.c | 24 ++++++++--- - poppler/Dict.cc | 20 +++++++++ - poppler/Dict.h | 1 + - poppler/Page.cc | 109 - +++++++++++++++++++++++++++++++++++++++++++++++ - poppler/Page.h | 1 + - 8 files changed, 196 insertions(+), 24 deletions(-) - -commit 591055d1fbcd0b9c2bb11f14040568051c5976d1 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sat Mar 26 00:34:21 2005 +0000 - - 2005-03-25 Kristian Høgsberg <krh@redhat.com> - - * glib/Makefile.am (libpoppler_glib_la_SOURCES): Add - - * configure.ac: Check for fontconfig for glib bindings. - - ChangeLog | 4 ++++ - configure.ac | 4 ++-- - glib/Makefile.am | 7 +++++-- - 3 files changed, 11 insertions(+), 4 deletions(-) - -commit 1e30abe94a96b91df05716ea079c58782d767951 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Mar 24 22:24:41 2005 +0000 - - 2005-03-24 Kristian Høgsberg <krh@redhat.com> - - * glib/Makefile.am: Use POPPLER_GLIB_CFLAGS and - POPPLER_GLIB_LIBS - instead of GTK_TEST_*. Reported by Adam Jackson - <ajax@nwnk.net>. - - ChangeLog | 5 +++++ - glib/Makefile.am | 7 +++---- - 2 files changed, 8 insertions(+), 4 deletions(-) - -commit 1d9fcaa34222b2ccd53280148561917dbb8d95d9 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed Mar 23 05:53:08 2005 +0000 - - File Edit Options Buffers Tools Help - 2005-03-23 Kristian Høgsberg <krh@redhat.com> - - * poppler/Catalog.cc (indexToLabel, labelToIndex): Add - stricter - checking of incoming labels and indices. - - * glib/test-poppler-glib.c (main): Change test program to - take the - page label from the command line. - - ChangeLog | 6 ++++++ - glib/test-poppler-glib.c | 5 ++++- - poppler/Catalog.cc | 31 +++++++++++++++++++++++++++++-- - 3 files changed, 39 insertions(+), 3 deletions(-) - -commit a9bbb465a0ee6ab320f76d322a3f575327ad1148 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed Mar 23 05:38:34 2005 +0000 - - 2005-03-23 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-page.cc: - * glib/poppler-page.h: Add poppler_page_get_index() and rename - popper_page_get_dimension() to popper_page_get_size() - - ChangeLog | 6 ++++++ - glib/poppler-page.cc | 12 +++++++++--- - glib/poppler-page.h | 32 +++++++++++++++++--------------- - glib/test-poppler-glib.c | 5 ++--- - 4 files changed, 34 insertions(+), 21 deletions(-) - -commit 178bff27d09d1e18d1fc00c975fa235b0e9f93d3 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed Mar 23 04:14:28 2005 +0000 - - 2005-03-22 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-document.cc: Implement poppler_document_save(). - - * glib/poppler-document.h: Add prototype and format headers - properly. - - ChangeLog | 7 +++++++ - glib/poppler-document.cc | 20 ++++++++++++++++++++ - glib/poppler-document.h | 30 +++++++++++++----------------- - 3 files changed, 40 insertions(+), 17 deletions(-) - -commit e40c6f69c9466df4cc70840b959f72cb0809c777 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed Mar 23 01:30:04 2005 +0000 - - 2005-03-22 Kristian Høgsberg <krh@redhat.com> - - * configure.ac: Fix --disable-popper typo reported by Albert. - Require exactly cairo 0.4 since CVS cairo has API changes. - - ChangeLog | 5 +++++ - configure.ac | 6 +++--- - 2 files changed, 8 insertions(+), 3 deletions(-) - -commit 2a1e4f6f6dd87dc59b3579175a87215fd7350ee0 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue Mar 22 22:46:37 2005 +0000 - - 2005-03-22 Kristian Høgsberg <krh@redhat.com> - - * poppler/Array.cc: - * poppler/Array.h: Add getString() convenience method. - - * poppler/Catalog.cc: - * poppler/Catalog.h: Optimize lookup of named destinations. - - ChangeLog | 8 +++ - poppler/Array.cc | 15 ++++++ - poppler/Array.h | 1 + - poppler/Catalog.cc | 142 - ++++++++++++++++++++++++++++++++++------------------- - poppler/Catalog.h | 32 +++++++++++- - 5 files changed, 146 insertions(+), 52 deletions(-) - -commit 4dfe0ce4a1ca09d632943f0f6315e31135957ada -Author: Kristian Høgsberg <krh@redhat.com> -Date: Tue Mar 22 01:50:05 2005 +0000 - - 2005-03-21 Kristian Høgsberg <krh@redhat.com> - - * NEWS, TODO: Update these. - - ChangeLog | 4 ++++ - NEWS | 1 + - TODO | 29 ++++++++++++++++++++--------- - 3 files changed, 25 insertions(+), 9 deletions(-) - -commit c158de90a5a8c6514d8aa22efa0b891a1801e822 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Mar 21 07:53:19 2005 +0000 - - 2005-03-21 Kristian Høgsberg <krh@redhat.com> - - From Albert Astals Cid <tsdgeos@yahoo.es>: - - * poppler/Catalog.cc, poppler/Catalog.h: Parse PageMode - setting - from the Catalog dict and expose it through getPageMode() - method. - - ChangeLog | 10 ++++++++-- - poppler/Catalog.cc | 16 ++++++++++++++++ - poppler/Catalog.h | 12 ++++++++++++ - 3 files changed, 36 insertions(+), 2 deletions(-) - -commit 9887679ca195714d71cbedde9297e9dcea04eb13 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Mon Mar 21 07:36:11 2005 +0000 - - 2005-03-21 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-document.cc: - - * glib/poppler-document.h: Expose the documenttitle as - a GObject - property. - - * glib/poppler-page.cc: Expose the page label as a GObject - property. - - * glib/poppler-private.h: Add the page index to PopplerPage. - - * glib/test-poppler-glib.c: Print out page label and document - title. - - * poppler/Catalog.cc: - * poppler/Catalog.h: Add page label accessors. - - * poppler/PageLabelInfo.cc: - * poppler/PageLabelInfo.h: New files. - - * poppler/Makefile.am: Add new files to sources. - - ChangeLog | 23 ++++ - glib/poppler-document.cc | 95 ++++++++++++- - glib/poppler-document.h | 3 + - glib/poppler-page.cc | 37 ++++- - glib/poppler-private.h | 3 +- - glib/test-poppler-glib.c | 13 +- - poppler/Catalog.cc | 15 ++ - poppler/Catalog.h | 6 + - poppler/Makefile.am | 4 +- - poppler/PageLabelInfo.cc | 346 - +++++++++++++++++++++++++++++++++++++++++++++++ - poppler/PageLabelInfo.h | 37 +++++ - 11 files changed, 573 insertions(+), 9 deletions(-) - -commit 2cfe917de909254bc3a114a6add68a14b5885fd0 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sun Mar 20 05:44:06 2005 +0000 - - 2005-03-20 Kristian Høgsberg <krh@redhat.com> - - * glib/poppler-document.cc: - * glib/poppler-page.h: - * glib/poppler.cc: - * poppler/Array.cc: - * poppler/Array.h: - * poppler/Catalog.cc: Fix up filenames in #include statements - and - comments. - - ChangeLog | 10 ++++++++++ - glib/poppler-document.cc | 2 +- - glib/poppler-document.h | 2 +- - glib/poppler-page.cc | 2 +- - glib/poppler-page.h | 2 +- - glib/poppler.cc | 2 +- - glib/poppler.h | 2 +- - 7 files changed, 16 insertions(+), 6 deletions(-) - -commit f9b6017cfaf8f814ae2fc027927477c29f24af71 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sun Mar 20 00:35:21 2005 +0000 - - 2005-03-19 Kristian Høgsberg <krh@redhat.com> - - Land the first bits of the glib wrapper. - - * Makefile.am: - * configure.ac: Add new glib subdirectory and configure - options - for glib wrapper. - - * glib/Makefile.am: - * glib/poppler-document.cc: - * glib/poppler-document.h: - * glib/poppler-page.cc: - * glib/poppler-page.h: - * glib/poppler-private.h: - * glib/poppler.cc: - * glib/poppler.h: - * glib/test-poppler-glib.c: - * poppler-glib.pc.in: New files. - - ChangeLog | 19 ++++++ - Makefile.am | 27 ++++---- - NEWS | 4 ++ - configure.ac | 25 ++++++- - glib/Makefile.am | 33 ++++++++++ - glib/poppler-document.cc | 165 - +++++++++++++++++++++++++++++++++++++++++++++++ - glib/poppler-document.h | 52 +++++++++++++++ - glib/poppler-page.cc | 158 - +++++++++++++++++++++++++++++++++++++++++++++ - glib/poppler-page.h | 50 ++++++++++++++ - glib/poppler-private.h | 20 ++++++ - glib/poppler.cc | 29 +++++++++ - glib/poppler.h | 42 ++++++++++++ - glib/test-poppler-glib.c | 43 ++++++++++++ - poppler-glib.pc.in | 11 ++++ - 14 files changed, 661 insertions(+), 17 deletions(-) - -commit 2a31446b227b5cdc8334e672a71835b6ea14713a -Author: Jeff Muizelaar <jeff@infidigm.net> -Date: Wed Mar 16 15:51:36 2005 +0000 - - 2005-03-16 Jeff Muizelaar <jrmuizel@nit.ca> - - From Dan Sheridan <dan.sheridan@postman.org.uk> - - * poppler/XRef.cc (XRef::checkEncrypted): - The key length should be 5 for revision 2 documents. - - ChangeLog | 7 +++++++ - poppler/XRef.cc | 6 ++++++ - 2 files changed, 13 insertions(+) - -commit e632a1d4b2f685993bda407458c34ef8e6b74136 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Mar 11 22:43:29 2005 +0000 - - 2005-03-11 Kristian Høgsberg <krh@redhat.com> - - From Jeff Muizelaar <jrmuizel@nit.ca>: - - * poppler/CairoOutputDev.cc (CairoOutputDev::drawImageMask): - Use - getLine instead of getPixel. - - ChangeLog | 3 +++ - poppler/CairoOutputDev.cc | 18 ++++++++---------- - 2 files changed, 11 insertions(+), 10 deletions(-) - -commit 83e904452f205a2c0cd2723cb12b7fd4640ce342 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Mar 11 21:42:52 2005 +0000 - - 2005-03-11 Kristian Høgsberg <krh@redhat.com> - - From Jeff Muizelaar <jrmuizel@nit.ca>: - - * configure.ac: Add checks for libjpeg. - - * DCTStream.cc, DCTStream.h, Stream.cc, Stream.h, Makefile.am: - Conditionally use libjpeg instead of xpdf jpeg decoder. - - ChangeLog | 9 +++++ - configure.ac | 34 +++++++++++++++- - poppler/DCTStream.cc | 110 - +++++++++++++++++++++++++++++++++++++++++++++++++++ - poppler/DCTStream.h | 70 ++++++++++++++++++++++++++++++++ - poppler/Makefile.am | 14 ++++++- - poppler/Stream.cc | 8 ++++ - poppler/Stream.h | 2 + - 7 files changed, 245 insertions(+), 2 deletions(-) - -commit e2af71338fd89760c4ac76999985efc5eb92817f -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Mar 11 16:42:20 2005 +0000 - - 2005-03-10 Kristian Høgsberg <krh@redhat.com> - - From Jeff Muizelaar <jrmuizel@nit.ca>: - - * poppler/CairoFontEngine.cc (CairoFontEngine::getFont): - Don't print "Type 3 font!" message. - - * poppler/CairoOutputDev.cc (CairoOutputDev::drawImageMask): - Enable image mask drawing and do it properly, albeit slowly. - - * poppler/CairoOutputDev.h - (CairoOutputDev::interpretType3Chars): Return true so that - Gfx.cc turns type3 characters into calls to drawImageMask - - ChangeLog | 14 ++++++++++++++ - poppler/CairoFontEngine.cc | 1 - - poppler/CairoOutputDev.cc | 25 ++++++++++--------------- - poppler/CairoOutputDev.h | 2 +- - 4 files changed, 25 insertions(+), 17 deletions(-) - -commit 3dc52373346e448077d2539163e873eef6406ed7 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed Mar 9 15:47:00 2005 +0000 - - 2005-03-09 Kristian Høgsberg <krh@redhat.com> - - * NEWS: Describe 0.1.2 (and 0.1.1) release. - - * configure.ac: Bump poppler version to 0.1.2 - - ChangeLog | 6 ++++++ - NEWS | 12 ++++++++++++ - configure.ac | 2 +- - 3 files changed, 19 insertions(+), 1 deletion(-) - -commit 5c6a2d34fc25df28ca5326e6910d7cf664f0c3d7 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Wed Mar 9 15:35:31 2005 +0000 - - 2005-03-09 Kristian Høgsberg <krh@redhat.com> - - * configure.ac: Bump cairo requirement to 0.4. - - ChangeLog | 4 ++++ - configure.ac | 4 ++-- - 2 files changed, 6 insertions(+), 2 deletions(-) - -commit 5b2d9a61e79cefd819888c8c89231a5fafccd114 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sat Mar 5 04:57:49 2005 +0000 - - 2005-03-04 Kristian Høgsberg <krh@redhat.com> - - Patch from Jeff Muizelaar <jrmuizel@nit.ca>. Changed to - allocate - glyphs using gmalloc. - - * poppler/CairoOutputDev.cc (CairoOutputDev::drawString): - Implement drawString instead of drawChar. This change should - make clipping to a text path work and has a performance - improvement. Currently the code is a little ugly because we - can't concat matrices to cairo without losing our current - font. - - * poppler/CairoOutputDev.h (CairoOutputDev::useDrawChar): - Tell Gfx.cc that it should use drawString instead of drawChar. - - ChangeLog | 14 ++++++ - TODO | 3 ++ - poppler/CairoOutputDev.cc | 110 - ++++++++++++++++++++++++++++++++++------------ - poppler/CairoOutputDev.h | 7 +-- - 4 files changed, 102 insertions(+), 32 deletions(-) - -commit 60d190ef80a0dcd9cc3a67306e2c65c5dd482f24 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sat Mar 5 04:37:14 2005 +0000 - - 2005-03-04 Kristian Høgsberg <krh@redhat.com> - - * test/gtk-cairo-test.cc (view_load): - * test/gtk-splash-test.cc (view_load): Fix missing return - statement, and remove unused variables. - - * configure.ac: Add configure option to enable the default KDE - flags as described by Albert Astals Cid <tsdgeos@yahoo.es>. - - * TODO: Update with Jeff's items. - - * .cvsignore: - * */.cvsignore: Add these to silence CVS. - - ChangeLog | 9 +++++++++ - TODO | 15 +++++++++++---- - configure.ac | 21 +++++++++++++++++++++ - test/gtk-cairo-test.cc | 6 ++---- - test/gtk-splash-test.cc | 5 ++--- - 5 files changed, 45 insertions(+), 11 deletions(-) - -commit e6706e505c1675724c8870f7c58079932661db5f -Author: Kristian Høgsberg <krh@redhat.com> -Date: Sat Mar 5 02:19:50 2005 +0000 - - 2005-03-04 Kristian Høgsberg <krh@redhat.com> - - * .cvsignore: - * */.cvsignore: Add these to silence CVS. - - .cvsignore | 21 +++++++++++++++++++++ - ChangeLog | 3 +++ - fofi/.cvsignore | 8 ++++++++ - goo/.cvsignore | 8 ++++++++ - poppler/.cvsignore | 10 ++++++++++ - splash/.cvsignore | 8 ++++++++ - test/.cvsignore | 10 ++++++++++ - 7 files changed, 68 insertions(+) - -commit 932edfc3c5c61e3b3e98957b717abbf8055e1c5e -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Mar 4 19:47:13 2005 +0000 - - 2005-03-04 Kristian Høgsberg <krh@redhat.com> - - * configure.ac: Implement same check for gtk+-2.0 tests as for - cairo. - - ChangeLog | 5 +++++ - configure.ac | 11 ++++++++--- - 2 files changed, 13 insertions(+), 3 deletions(-) - -commit c632b35ad9345f280d78c268f84ae3fd5a3921b9 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Mar 4 16:33:43 2005 +0000 - - 2005-03-04 Kristian Høgsberg <krh@redhat.com> - - * configure.ac: Only fail hard in check for cairo if the user - specified --enable-cairo-output (from Brad Hards - <bradh@frogmouth.net>). Print summary of configure results - at the - end of configure script. - - * poppler/poppler-config.h: Remove this file (noticed by Brad - Hards <bradh@frogmouth.net>). - - ChangeLog | 5 +++++ - configure.ac | 17 ++++++++++++++--- - 2 files changed, 19 insertions(+), 3 deletions(-) - -commit 80f9c90273eb31ac349c46bf86dedff7daf21db4 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Mar 4 15:32:32 2005 +0000 - - 2005-03-04 Kristian Høgsberg <krh@redhat.com> - - * poppler/poppler-config.h: Remove this file (noticed by Brad - Hards <bradh@frogmouth.net>). - - ChangeLog | 5 ++ - poppler/poppler-config.h | 146 - ----------------------------------------------- - 2 files changed, 5 insertions(+), 146 deletions(-) - -commit 338b83b6f08a7212fdde2bbce94385e9a71a3d23 -Author: Kristian Høgsberg <krh@redhat.com> -Date: Fri Mar 4 02:46:44 2005 +0000 - - 2005-03-03 Kristian Høgsberg <krh@redhat.com> - - Patch from Jeff Muizelaar <jrmuizel@nit.ca>: - - * poppler/CairoOutputDev.cc (CairoOutputDev::drawImage, - CairoOutputDev::drawImageMask): destroy the image surface and - free the image buffer. - - ChangeLog | 10 ++++++++++ - autogen.sh | 2 +- - poppler/CairoOutputDev.cc | 8 +++++--- - 3 files changed, 16 insertions(+), 4 deletions(-) - -commit 062aa51487f539406b54458885b4c9501da3c44d -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Mar 3 20:01:14 2005 +0000 - - 2005-03-03 Kristian Høgsberg <krh@redhat.com> - - * autogen.sh: Add to CVS. - - ChangeLog | 4 ++++ - autogen.sh | 4 ++++ - 2 files changed, 8 insertions(+) - -commit cb02d5d0e770e2a8cbe5a8ac810820a2ce5fec0c -Author: Kristian Høgsberg <krh@redhat.com> -Date: Thu Mar 3 19:45:58 2005 +0000 - - Initial revision - - AUTHORS | 3 + - COPYING | 340 ++++ - ChangeLog | 33 + - INSTALL | 236 +++ - Makefile.am | 29 + - NEWS | 4 + - README | 37 + - README-XPDF | 376 ++++ - TODO | 21 + - configure.ac | 139 ++ - fofi/FoFiBase.cc | 156 ++ - fofi/FoFiBase.h | 55 + - fofi/FoFiEncodings.cc | 994 ++++++++++ - fofi/FoFiEncodings.h | 34 + - fofi/FoFiTrueType.cc | 1438 ++++++++++++++ - fofi/FoFiTrueType.h | 131 ++ - fofi/FoFiType1.cc | 207 ++ - fofi/FoFiType1.h | 57 + - fofi/FoFiType1C.cc | 2385 ++++++++++++++++++++++ - fofi/FoFiType1C.h | 224 +++ - fofi/Makefile.am | 16 + - goo/GooHash.cc | 356 ++++ - goo/GooHash.h | 74 + - goo/GooList.cc | 92 + - goo/GooList.h | 89 + - goo/GooMutex.h | 49 + - goo/GooString.cc | 236 +++ - goo/GooString.h | 98 + - goo/Makefile.am | 20 + - goo/gfile.cc | 705 +++++++ - goo/gfile.h | 140 ++ - goo/gmem.c | 204 ++ - goo/gmem.h | 53 + - goo/gmempp.cc | 32 + - goo/gtypes.h | 29 + - poppler-cairo.pc.in | 10 + - poppler-splash.pc.in | 10 + - poppler.pc.in | 11 + - poppler/Annot.cc | 137 ++ - poppler/Annot.h | 79 + - poppler/Array.cc | 73 + - poppler/Array.h | 56 + - poppler/BaseFile.h | 82 + - poppler/BuiltinFont.cc | 65 + - poppler/BuiltinFont.h | 55 + - poppler/BuiltinFontTables.cc | 4284 - ++++++++++++++++++++++++++++++++++++++++ - poppler/BuiltinFontTables.h | 23 + - poppler/CMap.cc | 384 ++++ - poppler/CMap.h | 101 + - poppler/CairoFontEngine.cc | 367 ++++ - poppler/CairoFontEngine.h | 61 + - poppler/CairoOutputDev.cc | 569 ++++++ - poppler/CairoOutputDev.h | 146 ++ - poppler/CairoOutputDevImage.cc | 87 + - poppler/CairoOutputDevImage.h | 43 + - poppler/CairoOutputDevX.cc | 211 ++ - poppler/CairoOutputDevX.h | 117 ++ - poppler/Catalog.cc | 364 ++++ - poppler/Catalog.h | 87 + - poppler/CharCodeToUnicode.cc | 533 +++++ - poppler/CharCodeToUnicode.h | 112 ++ - poppler/CharTypes.h | 24 + - poppler/CompactFontTables.h | 464 +++++ - poppler/Decrypt.cc | 399 ++++ - poppler/Decrypt.h | 59 + - poppler/Dict.cc | 95 + - poppler/Dict.h | 75 + - poppler/Error.cc | 38 + - poppler/Error.h | 21 + - poppler/ErrorCodes.h | 36 + - poppler/FontEncodingTables.cc | 1824 +++++++++++++++++ - poppler/FontEncodingTables.h | 20 + - poppler/Function.cc | 1525 ++++++++++++++ - poppler/Function.h | 181 ++ - poppler/Gfx.cc | 3079 +++++++++++++++++++++++++++++ - poppler/Gfx.h | 279 +++ - poppler/GfxFont.cc | 1508 ++++++++++++++ - poppler/GfxFont.h | 313 +++ - poppler/GfxState.cc | 2782 ++++++++++++++++++++++++++ - poppler/GfxState.h | 1053 ++++++++++ - poppler/GlobalParams.cc | 1764 +++++++++++++++++ - poppler/GlobalParams.h | 312 +++ - poppler/JArithmeticDecoder.cc | 300 +++ - poppler/JArithmeticDecoder.h | 89 + - poppler/JBIG2Stream.cc | 3337 +++++++++++++++++++++++++++++++ - poppler/JBIG2Stream.h | 141 ++ - poppler/JPXStream.cc | 2822 ++++++++++++++++++++++++++ - poppler/JPXStream.h | 338 ++++ - poppler/Lexer.cc | 474 +++++ - poppler/Lexer.h | 75 + - poppler/Link.cc | 851 ++++++++ - poppler/Link.h | 407 ++++ - poppler/Makefile.am | 140 ++ - poppler/NameToCharCode.cc | 116 ++ - poppler/NameToCharCode.h | 40 + - poppler/NameToUnicodeTable.h | 1097 ++++++++++ - poppler/Object.cc | 231 +++ - poppler/Object.h | 301 +++ - poppler/Outline.cc | 151 ++ - poppler/Outline.h | 74 + - poppler/OutputDev.cc | 104 + - poppler/OutputDev.h | 162 ++ - poppler/PDFDoc.cc | 322 +++ - poppler/PDFDoc.h | 176 ++ - poppler/PDFDocEncoding.cc | 44 + - poppler/PDFDocEncoding.h | 16 + - poppler/PSOutputDev.cc | 3803 +++++++++++++++++++++++++++++++++++ - poppler/PSOutputDev.h | 312 +++ - poppler/PSTokenizer.cc | 135 ++ - poppler/PSTokenizer.h | 39 + - poppler/Page.cc | 370 ++++ - poppler/Page.h | 176 ++ - poppler/Parser.cc | 231 +++ - poppler/Parser.h | 58 + - poppler/SplashOutputDev.cc | 1348 +++++++++++++ - poppler/SplashOutputDev.h | 194 ++ - poppler/Stream-CCITT.h | 459 +++++ - poppler/Stream.cc | 3979 - +++++++++++++++++++++++++++++++++++++ - poppler/Stream.h | 841 ++++++++ - poppler/TextOutputDev.cc | 3529 +++++++++++++++++++++++++++++++++ - poppler/TextOutputDev.h | 569 ++++++ - poppler/UTF8.h | 56 + - poppler/UnicodeMap.cc | 293 +++ - poppler/UnicodeMap.h | 122 ++ - poppler/UnicodeMapTables.h | 361 ++++ - poppler/UnicodeTypeTable.cc | 299 +++ - poppler/UnicodeTypeTable.h | 18 + - poppler/XRef.cc | 1026 ++++++++++ - poppler/XRef.h | 133 ++ - poppler/poppler-config.h | 146 ++ - poppler/poppler-config.h.in | 145 ++ - splash/Makefile.am | 52 + - splash/Splash.cc | 1732 ++++++++++++++++ - splash/Splash.h | 174 ++ - splash/SplashBitmap.cc | 157 ++ - splash/SplashBitmap.h | 46 + - splash/SplashClip.cc | 270 +++ - splash/SplashClip.h | 86 + - splash/SplashErrorCodes.h | 30 + - splash/SplashFTFont.cc | 289 +++ - splash/SplashFTFont.h | 53 + - splash/SplashFTFontEngine.cc | 141 ++ - splash/SplashFTFontEngine.h | 58 + - splash/SplashFTFontFile.cc | 111 ++ - splash/SplashFTFontFile.h | 68 + - splash/SplashFont.cc | 166 ++ - splash/SplashFont.h | 87 + - splash/SplashFontEngine.cc | 245 +++ - splash/SplashFontEngine.h | 83 + - splash/SplashFontFile.cc | 55 + - splash/SplashFontFile.h | 58 + - splash/SplashFontFileID.cc | 23 + - splash/SplashFontFileID.h | 28 + - splash/SplashGlyphBitmap.h | 24 + - splash/SplashMath.h | 45 + - splash/SplashPath.cc | 177 ++ - splash/SplashPath.h | 105 + - splash/SplashPattern.cc | 64 + - splash/SplashPattern.h | 79 + - splash/SplashScreen.cc | 107 + - splash/SplashScreen.h | 38 + - splash/SplashState.cc | 99 + - splash/SplashState.h | 86 + - splash/SplashT1Font.cc | 251 +++ - splash/SplashT1Font.h | 49 + - splash/SplashT1FontEngine.cc | 124 ++ - splash/SplashT1FontEngine.h | 51 + - splash/SplashT1FontFile.cc | 96 + - splash/SplashT1FontFile.h | 55 + - splash/SplashTypes.h | 80 + - splash/SplashXPath.cc | 417 ++++ - splash/SplashXPath.h | 90 + - splash/SplashXPathScanner.cc | 271 +++ - splash/SplashXPathScanner.h | 72 + - test/Makefile.am | 48 + - test/gtk-cairo-test.cc | 298 +++ - test/gtk-splash-test.cc | 314 +++ - 177 files changed, 70512 insertions(+) diff --git a/source/libs/poppler/poppler-0.32.0/NEWS b/source/libs/poppler/poppler-0.32.0/NEWS deleted file mode 100755 index e83112497..000000000 --- a/source/libs/poppler/poppler-0.32.0/NEWS +++ /dev/null @@ -1,2296 +0,0 @@ -Release 0.32.0 - core: - * Annotations: Fix rendering of empty BG/BC arrays - * Splash: Fix wrong colour shown when GouraudTriangleShFill uses a DeviceN colorspace. Bug #89182 - * Splash: Fix use of uninitialized variable in Splash::pipeRun - * Remove unnecesary check for font validity. Bug #88939 - * Small optimization in GooString::appendfv(). Bug #89096 - * Fix crashes in malformed files - - utils: - * pdftops: Make colorpsace optimization an option instead of default - * pdfseparate: use always an unique instance for PDFDoc for savePageAs - - build system: - * cmake: If extra-cmake-modules is around include the Sanitizers module - -Release 0.31.0 - core: - * CairoOutputDev: support embedding JBIG2 image data - * Accept malformed documents whose root is a Page instead of a Pages. Bug #88172 - * Fix crash on broken documents - * JPEG2000Stream: Inline doGetChar and doLookChar - * GlobalParams cleaning - - utils: - * pdftops: Add rasterization option. Bug #85934 - - qt4: - * Expose whole-words search option - - qt5: - * Expose whole-words search option - -Release 0.30.0 - core: - * Openjpeg2 support (openjpeg 1 is preferred). Bug #58906 - * Fix potential memory corruption on TextSelectionDumper. Bug #84555 - * Check for invalid matrix in annotation. Bug #84990 - * Open some not conforming files. Bug #85919 - * PSOutputDev: Accept a list of pages indeces instead of first, last. Bug #84833 - * Fix memory leak on error condition - - cpp: - * New API to set debug output function - - build system: - * configure: Improve support with older clang versions. Bug #76963 - - utils: - * pdfunite: Support output intents, optional content and acroform - -Release 0.29.0 - core: - * Use correct LAB byte array for lcms input. Bug #86388 - * Write correct size in trailer dict. Bug #86063 - * Use Default colorspaces if present instead of Device colorspaces - * Solve blend mode problem in CYMK and DeviceN for separable blend modes - * Compilation/warning fixes on SunOS - * Regression test improvements - - glib: - * demo: Compilation fixlets - - build system: - * cofigure: print "no" instead of "auto" if lcms not found - -Release 0.28.0 - core: - * Fix rendering of file with a wrong embedded font. Bug #84270 - * Use alt colorspace to get CMYK values for an ICC based CMYK colorspace. Bug #79019 - * Map Standard/Expert encoding ligatures to AGLFN names. Bug #80093 - * Make Attribute::getName() work when UTF-16BE is used. Bug #84722 - * Fix memory leak in Dict::remove. Bug #84607 - * Fix crashes in broken files - * SplashOutputDev: Improve Overprintmode and shadings. Bug #80998 - * CairoOutputDev: fix crash when no group color space. Bug #85137 - * CairoOutputDev: Don't render text when text matrix is not invertable. Bug #78042 - * CairoOutputDev: Only embed mime data for gray/rgb/cmyk colorspaces. Bug #80719 - * CairoOutputDev: Only embed mime data if image decode map is identity - * cairo: Use matrix to determine pattern size. Bug #33364 - * Fix compile warnings - * regression test improvements - - glib: - * Fix use of uninitialized members in PopplerInputStream. Bug #82630 - * Documentation improvements - * Do not dist gir_DATA - * Remove use of GTK deprecated functions. Bug #82384. Bug #82385 - * Build introspection linking to the uninstalled libraries. Big #84526 - - qt4: - * Add a new Page::annotations() that let's you specify subtypes - - qt5: - * Add a new Page::annotations() that let's you specify subtypes - - utils: - * pdfseparate: additonal handling for annotations. Bug #77549 - * pdfdetach: fix crash when getPage() returns null. Bug #85145 - * pdftocairo: Add support for printing to a Windows printer. Bug #79936 - - build system: - * Move automake version check from autogen.sh to configure.ac. Bug #79797 - * Makefile.am cleanups. Bug #79411 - * Use poppler-data pkg-config - * Make autogen.sh work with variables with spaces - * Don't use -fPIC on mingw - * Fix build with --disable-utils. Bug #84448 - -Release 0.26.4 - core: - * CairoOutputDev: Make sure we always push a transparency group in setSoftMaskFromImageMask(). Bug #81624 - * Fix a crash when adding Annotation without contents - * Improve non-latin characters in inline notes. Bug #65956 - * Don't check for inlineImg twice. Bug #82059 - * printf() -> error() - - glib: - * Return NULL in poppler_annot_get_contents also for empty strings - * Fix a memory leak when getting text layout and attributes - -Release 0.26.3 - qt5: - * autoconf: Improve moc-qt5 detection - * Fix compilation with MinGW - - glib: - * Fix typo in api docs - * use C90-style comments in public headers - - core: - * Error out instead of exiting if allInter grows too much. Bug #78714 - - qt4: - * Update required version to Qt 4.7.0 - - build system: - * Include stdio.h from poppler-config.h - - misc: - * Update .gitignore files - -Release 0.26.2 - core: - * Make sure we have an xref before using. KDE Bug #335413 - - build system: - * autoconf: Fix typo in configure.ac - - utils: - * pdftohtml: exit with 0 with -v and -h - -Release 0.26.1 - core: - * Use field value V for radio buttons. Bug #75979 - * Fix extraction of text in some files. Bug #78145 - * Only add annotations of the current page when splitting. Bug #77549 - - build system: - * autoconf: Fix libopenjpeg 1.5 detection on some systems. Bug #78389 - - glib: - * Fix multiple definition of PopplerTextSpan - -Release 0.26.0 - qt4: - * Fix mismatched boolean logic in TextAnnotation::setInplaceIntent - - qt5: - * Fix mismatched boolean logic in TextAnnotation::setInplaceIntent - - core: - * Very small code cleanup - - cpp: - * Very small code cleanup - -Release 0.25.3 - core: - * Fix crashes on broken files - * Avoid MinGW/Cygwin warnings due to redefinition of NOMINMAX - * Fix some small memory leaks - - qt5: - * Fix some kinds of OCG models - * Cleanup some deprecated methods - - glib: - * Fix the first coord of the quadrilateral in create_poppler_quads_from_annot_quads(). Bug #76504 - - utils: - * pdftohtml: Fix typo in manpage - - qt4: - * Fix some kinds of OCG models - -Release 0.25.2 - core: - * Tagged-PDF support - * Open some broken files. Bug #75232 - * Fix crashes on broken files - * Fix regression parsing some broken files. KDE Bug #329600 - * Improve compilation under Win 8 with Visual Studio 2012. Bug #73111 - * PSOutputDev: Ensure paper size takes into account rotation. Bug #72312 - * PSOutputDev: Fix DocumentMedia/Page/Media/PageBBox DSC comments - * PSOutputDev: Use crop box as page size - * PSOutputDev: Remove origpagesizes mode and make -origpagesizes an alias for -paper match - * PSOutputDev: Only change paper size when different to previous size - * PSOutputDev: Ensure there is always a page size in the output - * PSOutputDev: Fix regression when creating level1 PS. Bug #75241 - * CairoOutputDev: Clip to crop box. Gnome Bug #649886 - * Splash: Blend usage in PDF with spot colors casue random output. Bug #74883 - * Splash: Fix off by one that caused crash in a file. Bug #76387 - * Make sure number of least objects in hints table is valid. Bug #74741 - * Limit numeric parsing of character names. Bug #38456 - - glib: - * Tagged-PDF support - * Annotation improvements - * Install error callback. Bug #73269 - * Fix gobject-introspection warnings - * demo: Fix performance in text markup annotations - * Increase gtk3 dependency - - qt4: - * Improve naming of internal export/import macros - * Add GCC visibility export attributes - * Expose document-supplied text direction - - qt5: - * Improve naming of internal export/import macros - * Add GCC visibility export attributes - * Expose document-supplied text direction - - utils: - * pdftocairo: Ensure page size and crop box works the same as pdftops - * Fix TIFF writting in Windows. Bug #75969 - - buildsystem: - * Learn about automake 1.14 - * Do not define -ansi. Bug #72499 - * cmake: Install JpegWriter.h depending on libjpeg - * cmake: Use c99 for the c compiler - -Release 0.25.1 - core: - * GooString format: Added some tests + improved documentation - * GooString format: fixed bug with printing LLONG_MIN - * regression test improvements - - qt4: - * Arthur backend font rendering improvements - * test program to save to file - - qt5: - * Arthur backend font rendering improvements - * Improve detection of Qt5 moc. Bug #72744 - * test program to save to file - - utils: - * pdfunite: Work even if there's a single file given - * pdfunite: do not lose fonts when merging some files - -Release 0.25.0 - core: - * Annotation improvements - * Tagged PDF work - * Improve speed on some files using ICC color space - * Use ICC profile in OutputIntents. Bug #34053 - * Limit use of ZapfDingbats character names. Bug #60243 - * Splash: correction for knockout transparency groups - * regression test improvements - - utils: - * pdftoppm: Added thinlinemode option setting - * pdfinfo: Indicate if pdf contains javascript - * pdfinfo: Add option to print out javascript - * pdfimages: Print size, ratio, and ppi - * pdfimages: More image output format support - * pdfseparate: allow zero-padded pagespecs - - glib: - * Annotation improvements - * Add API to get text, text layout and text attributes for a given area - * demo improvements - -Release 0.24.5 - core: - * Fix crash due to wrong formatting of error message. KDE Bug #328511 - -Release 0.24.4 - core: - * Fix regression in broken endstream detection. Bug #70854 - * Catalog: sort entries of NameTrees to make sure lookup works. Bug #26049 - * Don't infinite loop if reading from GooFile::read fails. Bug #71835 - - utils: - * pdftotext: Do not close stdout. Bug #71639 - * pdftotext: Silence warning for may be used uninitialized variable. Bug #71640 - * pdftotext: Escape the text of the xml headers - * Warn the user if he provides a wrong range - - qt4: - * Fix typo in xml API. Bug #71643 - - qt5: - * Fix typo in xml API. Bug #71643 - -Release 0.24.3 - core: - * PSOutputDev: Fix PFB font embedding. Bug #69717 - * CairoOutputDev: Do not set an invalid matrix in drawImage(). Bug #70085 - - qt4: - * Don't crash if getXRef()->copy() fails - - qt5: - * Don't crash if getXRef()->copy() fails - - utils: - * pdfseparate: Allow only one %d in the filename. Bug #69434 - -Release 0.24.2 - core: - * Windows: Fix CreateFile fails with ERROR_SHARING_VIOLATION. Bug #69597 - - utils: - * pdfseparate: improve the path building - * pdftocairo: check file opening failure in beginDocument() - -Release 0.24.1 - core: - * SplashOutputDev: use getRGBLine images if available. Bug #66928 - * SplashOutputDev: Don't copy bitmap if we don't need to. - * PSOutputDev: Fix regression in -eps -level1sep rendering. Bug #68321 - * Fix crash in malformed file 1026.asan.0.42.pdf - * use copyString instead of strdup where memory is freed with gfree. Bug #67666 - - utils: - * pdfdetach: don't mention xpdfrc - * pdftotext: Fix -bbox with stdin as input. Bug #45163 - * pdftohtml: Fix jpeg image export. Bug #48270 - * pdfimages: Fix typos in man page - - glib: - * demo: Remove GTK_DISABLE_DEPRECATED compilation flag - - qt4: - * Fix small typo in documentation - - qt5: - * Fix small typo in documentation - -Release 0.24.0 - core: - * TextOutputDev: Do not draw ligatures more than once when selected. Bug #9001 - * PSOutputDev: Make some pdftops conversions much faster - * PSOutputDev: Initialize t3FillColorOnly - * SplashOutputDev: Fallback to 1x1 bitmap if we fail to create the real size - -Release 0.23.4 - core: - * TextOutputDev: clip the selected text rendering to the selection box. Bug #66983 - * CairoImageOutputDev: Fix the bounding box of saved images - - build system: - * Improve linking against pthreads - -Release 0.23.3 - core: - * Annotation improvements - * Fix crashes on malformed files - * TextSelectionPainter: Draw glyphs after selection background - * TextOutputDev: add a method to TextPage to get the selection as a list of words - - qt5: - * Initial Qt5 port - - qt4: - * Windows compile fixes - * Demo: Allow the choose the page rotation - - build system: - * Fix mingw build - * Minor autotools fixes - -Release 0.23.2 - core: - * SplashOutputDev: Speed-up some tiling on a 10x factor - * Improve caching of lcms2 ICC color profiles - * Put some private classes in an anonymous namespace - - qt4: - * Add a thread stresser tool - - build system: - * Fix mingw build - -Release 0.23.1 - core: - * XRef stream writing: Write 32-bit offsets when possible - * Fix splashModeBGR8 rendering (Bug #64381) - - glib: - * Do not use deprecated gtk_scrolled_window_add_with_viewport() (Bug #64683) - - build system: - * Fix Large file support when using cmake - -Release 0.23.0 - core: - * Make rendering thread safe - * Large file support - * Implement Crypt filter (Bug #62800) - * Fix endstream detection (Bug #62985) - * CairoOutputDev: support uncolored tiling patterns (Bug #59179) - * SplashOutputDev: Introduce Thin Line mode support (Bug #37347) - - qt4: - * Expose Thin Line mode support - -Release 0.22.4 - core: - * Always consider a softmask transfer function (Bug #63587) - * Fix crash on malformed files (Bug #63190) - * Splash: Fix compilation with fixed point mode enabled - - utils: - * Fix crash on some files (Bug #63909) - - qt4: - * Fix name decoding of some attachments (KDE Bug #307786) - - build system: - * Fix compilation with mingw-w64 compiler - -Release 0.22.3 - core: - * Check order bounding box values in tiling pattern (Bug #62369) - * CairoImageOutputDev: Don't change image interpolation when printing (Bug #62418) - * TextOutputDev: Set text matrix when painting selection (Bug #61042) - * Only write the file once when saving (Bug #62739) - * Fix for complete rewrites in repaired files - * Fixlet regarding spec interpretation for Link Zoom value - * Fix typos in man pages - * Fix compile when not using libjpeg - - glib: - * Always start from the beginning when starting a new search on a page (Bug #59972) - - qt4: - * Fix crash in files with LinkRendition (KDE Bug #317710) - - build system: - * Small cmake improvements - -Release 0.22.2 - core: - * Correct rendering of underline and strike out annotations (Bug #61518) - * Workaround broken jpeg stream definitions (Bug #61994) - * SplashOutputDev: Restore CTM on early exits (Bug #61413) - * SplashOutputDev: Make sure we don't try to paint in x < 0 (KDE Bug #315432) - * Fix latin page labels. (Bug #61034) - * Fix compilation with jpeglib9 - * Fix minor valgrind warning - - utils: - * pdfimages: Fix extraction of some images (Bug #61168) - - build system: - * Fix the build with automake-1.13 - -Release 0.22.1 - core: - * Fix crash in some pdf files when extracting text (Bug #59561) - * Fix crashes in wrongly formed files - * Fix wrong warning when opening some files (Bug #58966) - - build system: - * Improve autoconf jpeglib.h detection (Bug #59186) - -Release 0.22.0 - core: - * Fix crash in invalid files that define a <= 0 bits per image value - * Fix a few issues in JPX decoding when not using OpenJPEG - * TextOutputDev: Use page size for max value in TextPage::visitSelection - * Fix typo in error message - - utils: - * Fix pdfunite regression (Bug #58569) - * Demo fixes and improvements - - misc: - * pdf-inspector improvements - -Release 0.21.4 - core: - * SplashOutputDev: Fix crash when rendering in monochrome mode - * SplashOutputDev: Fix line widths in monochrome mode (Bug #57294) - * PSOutputDev: Fix crop on EPS conversion (Bug #30692) - * TextOutputDev: Fix minor logic mistake - * Fix assert on some malformed files (Bug #58257) - * Move #include "jpeglib.h" into .cc file (Bug #57687) - * Filter text that may end up being written to the shell - * Fix windows compile warnings - - glib: - * Add poppler_annot_set_flags (Bug #58015) - * Demo fixes and improvements - - qt4: - * Fix check_lexer on 32-bit systems - -Release 0.21.3 - core: - * Splash: Implement bilinear image scaling (Bug #22138) - * CairoOutputDev: Update fill and stroke color in startPage (Bug #54526) - * Fix GooString::insert() - * Allow large chars in TextPage - * Fix crash on ActualText::end - * Don't use memcpy to copy classes - * Fix warnings - - glib: - * Check if words end with spaces (Bug #54504) - * Ensure text is only computed on first render - * Fix warnings while generating introspection file - * Fix returns tag in PopplerAttachmentSaveFunc api doc - * Minor demo fixes - -Release 0.21.2 - core: - * CairoOutputDev: make drawImage work with images > 32767 in width/height (Bug #56858) - * CairoOutputDev: Fix soft mask when image resolution != smask resolution (Bug #57070) - * CairoOutputDev: Fix crash in CairoImageOutputDev with setSoftMaskFromImageMask (Bug #57067) - * Remove a check on fonts that we don't need (Bug #56753) - * Misc code cleanups - - utils: - * pdftocairo: Add tiff output support (Bug #57006) - * pdfunite: Fix -v (Bug #56817) - * Misc code cleanups - -Release 0.21.1 - core: - * Annotation improvements - * Form improvements - * CairoImageOutputDev: Support parameterized Gouraud shading (Bug #56463) - * UTF validation fixes - * Do not call drawing routines if we don't need non text (Bug #54617) - * Fix Memory leak in CharCodeToUnicode (Bug #54702) - - qt4: - * Make LinkRendition properties available (Bug #55378) - * Accessors for FormWidgetChoice::editChoice - * Implement overprint - -Release 0.21.0 - core: - * Support the modification of files with Encrypt - * Annotation improvements - * Form improvements - * Splash: Implement DeviceN support - * Splash: Avoid bogus memory error for tilingPattern - * TextOutputDev: Allow multiple fonts in a TextWord - * Kill the concept of base dir - * PSOutputDev: Always write HiResBoundingBox (Bug #53159) - * Convert UTF-16 to UCS-4 when reading toUnicode cmap - * GooString formatting: add support for uppercase hexadecimal - * Use error() instead of fprintf(stderr, ...) in Annot::layoutText - * poppler-config.h: remove WITH_FONTCONFIGURATION_* macros - - glib: - * Annotation improvements - * Add poppler_page_remove_annot() - * Add poppler_document_new_from_stream - * Add poppler_document_new_from_gfile - * Add poppler_page_find_text_with_options (Bug #2951) - * Demo improvements - * Port tests and demo to GTK+3 - - qt4: - * Add accessor methods for movie poster information - * Make 'additional actions' available in Annotation API (Bug #53589) - * Add whole-page search method to Poppler::Page - * Small changes in tests - - utils: - * pdftohtml: Make the output more xhtml compliant - * pdftohtml: Add -fontfullname. (Bug #49872) - * pdftohtml: Do not invoke gs anymore - - build system: - * Add the possibility of using lcms1 even if lcms2 is installed - * Remove extra fontconfig CFLAGS and LIBS - -Release 0.20.5 - core: - * Fix crashes in malformed documents - * Fix parsing of very big numbers - * Splash: Do not render invalid font outlines (Bug #55573) - * Check for NaN in TextPage::addChar - - build system: - * Fix build using mingw64 with winpthread - * autotools: Fix compilation when lcms is on non standard locations (Bug #55326) - * Support automake-1.12 (Bug #55541) - - glib: - * Chain up finalize to the parent class (Bug #55521) - -Release 0.20.4 - core: - * Improvements regarding embedded file handling. (KDE Bug #306008) - * Fix opening some broken files (Bug #14303) - * Fix memory leaks - * Fix crashes in various broken files - * Refine warning to only complain when really needed - * Remove function declared but not implemented - * Remove execution permissions from a header file - - qt4: - * Improvements regarding embedded file handling. (KDE Bug #306008) - -Release 0.20.3 - core: - * If NULL, NULL fails as password try EMPTY, EMPTY before failing (Bug #3498) - * SplashOutputDev: Fix bogus memory allocation size in Splash::arbitraryTransformImage (Bug #49523) - * SplashOutputDev: Fix segfault when scaleImage returns NULL (Bug #52488) - * SplashOutputDev: Blend mode enhancements for CMYK - * PSOutputDev: Fix conversion when creating multiple strips (Bug #51982) - * PSOutputDev: Fix Bitmaps in level2sep or level3sep (Bug #52384) - * PSOutputDev: Fix DeviceN images with alternate Lab colorspace in level 3 PostScript (Bug #51822) - * PSOutputDev: Make sure xScale and yScale are always initialized (Bug #52215) - * Unify poppler-config.h includes in core "installed" headers (Bug #52193) - * Replace c++ style includes with c style ones (Bug #52426) - - utils: - * pdfseparate: Return 0 on success - -Release 0.20.2 - core: - * Fix compilation on Windows - * Copy resources content defined in the pages dict on save (Bug #51369) - * PSOutputDev: Correct %%DocumentCustomColors (Bug #51479) - * PSOutputDev: Fix handling of DeviceN images in level 3 PostScript (Bug #51548) - * Fix crash in malformed documents - - qt4: - * Do not hang on malformed /Annots objects (Bug #51361) - -Release 0.20.1 - core: - * Remove unnecesary transparency group handling in splash (Bug #13487) - * Include substitute font name in system font cache (Bug #49826) - * Fix logic on SplashBitmap::writeImgFile - * PSOutputDev: use setoverprintmode only if rip knows it - * Fix crash in malformed documents - - qt4: - * Make TextAnnotation constructor public - * Fix saving of default TextAnnotation to xml - * Keep page rotation into account when normalizing annotation coords - - glib: - * Fix memory leak when document fails to load - * Make sure password is always converted to latin1 - * Fix typo in documentation - - build system: - * Distribute cmake/modules/FindLCMS2.cmake (Bug #49818) - - utils: - * pdftohtml: Determine if font is bold or italic based on FontDescriptor (Bug #49758) - * pdfseparate: Syntax fixes in the man page - -Release 0.20.0 - core: - * Reconstruct xref table if xref needed but missing (Bug #40719) - * Fix getFullyQualifiedName with unicode field names (Bug #49256) - * SplashOutputDev: Fix rendering of knockout groups (Bug #12185) - * SplashOutputDev: Fix cmyk transfer bug (Bug #49341) - * Fix crashes in broken documents - * Bring back the Outputdev::begin/endMarkedContent virtuals - * Build fixes - - qt4: - * Convert propertly unicode encoded field qualified names - - glib: - * glib: Use delete[] to free array allocated with new[] (Bug #48447) - -Release 0.19.4 - core: - * Annotation improvements - * More compatible file writing - * SplashOutputDev: Fix slow rendering of pdf with a lot of image masks in pattern colorspace - * Fix crashes in broken documents - * Fix spurious warning messages - - utils: - * pdftotext: Add missing section heading to man page - * pdftohtml: Fix crash when the destination file does not exist - - build system: - * autoconf: Do not append "-ansi" to CXXFLAG, if "-std=XXX" is already specified. - * autoconf: Do not clear FREETYPE_CFLAGS, FREETYPE_LIBS before PKG_CHECK_MODULES() - * autoconf: Copying graphics library CFLAGS to cpp frontend Makefile.am - -Release 0.19.3 - core: - * Annotation improvements - * CairoOutputDev: Fix regression caused by mesh gradients - * CairoOutputDev: Use correct userfont font bbox (Bug #48399) - * CairoOutputDev: Fix paintTransparencyGroup when both mask and fill opacity are required (Bug #48453) - * CairoOutputDev: Ensure 0 width lines with stroke_adjust are aligned - * CairoOutputDev: Only align stroke coords for horizontal and vertical lines (Bug #48318) - * CairoOutputDev: Fix stroke pattern with transparency group (Bug #48468) - * Fix crash in JBIG2Stream decoding - * Fix memory leak when looking for a substitute font - * Fix page labels to not have a null character at the end - * Fix Splash CMYK merge error - * ttc<->ttf fallback is expected for CJK font list in for Windows (Bug #48046) - - qt4: - * Annotations can now be modified - * Annotations can now be added - * Annotations can now be removed - - utils: - * pdftohtml: Add producer and version to xml output - * pdftohtml: Fix the mask inversion for PNG - -Release 0.19.2 - core: - * Annotation improvements - * CairoOutputDev: update cairo mesh pattern to 1.12 api - * CairoOutputDev: fix some transparency issues (Bug #47739) - * CairoOutputDev: Fix regression in some shadings - * TextOutputDev: Don't add newline to last line extracted by TextSelectionDumper (Bug #45955) - * CJK font improvements - * Improve font matching for non embedded fonts - * Fix regression regarding forceRasterize in PSOutputDev - * Fix typos glyph names in truetype 'post' table standard mac ordering - - build system: - * minor cmake fixes - * misc autoconf fixes - * POPPLER_VERSION is now wrapped in quotes - - utils: - * pdftohtml: extract mask images even if they are not JPEG (Bug #47186) - * pdftohtml: Flip images if they need to (Bug #32340) - -Release 0.19.1 - core: - * Improve CJK suport in PSOutputDev - * CJK substitute implementation on WIndows platforms - * Do not crash on malformed files with 0 bits in the color map of an image - * Fix regression in some PSOutputDev array sizing - * Improvements to Annotation editing - * Fix logic error in Rendition parsing code (Bug #47063) - * Minor API changes to SplashOutputDev (Bug #46622) - * Fix mismatch in some functions declarations - * Update poppler copyright year - - utils: - * pdftops: Fix -passfonts regression. (Bug #46744) - * pdffonts: List the encoding of each font. (Bug #46888) - * pdftohtml: Add possibilty of controlling word breaks percentage. (Bug #47022) - - qt4: - * Support for LinkMovie object (Bug #40561) - * Support for Media Rendition - - glib: - * Add poppler_fonts_iter_get_encoding - * Improvements to the demo - -Release 0.19.0 - core: - * Merge Xpdf 3.03 - * Add support for lcms2 - * SplashOutputDev: Implement Overprint - * PSOutputDev: Implement Overprint - * Expand glyph name ligatures such as "ff", "ffi" etc to normal form (Bug #7002) - * Use an Identity CharCodeToUnicode for Adobe-Identity and Adobe-UCS collections (Bug #35468) - * CairoOutputDev: Avoid setting huge clip area when printing (Bug #44002) - * CairoOutputDev: Fix test for rotation (Bug #14619) - * CairoOutputDev: Don't read inline image streams twice (Bug #45668) - * CairoOutputDev: set mask matrix before drawing an image with a mask (Bug #40828) - * Update glyph names to Unicode values mapping (Bug #13131) - * Only use Hints table when there are no parse errors (Bug #46459) - * Expose POPPLER_VERSION in poppler-config.h - - utils: - * pdftohtml: Output images in -xml mode if no -i option is specified - * pdftohtml: Get rid of static data members; merge duplicated jpeg dumping code - * pdftohtml: Be more consistent generating the outlines - * pdftohtml: Generate outlines in pdftohtml in -xml mode (Bug #56993) - * pdftohtml: Combine UTF16 surrogate pairs (Bug #46521) - * pdfinfo: Report page rotation - * pdfinfo: Decode utf-16 surrogate pairs - * pdftoppm: Allow one of -scale-to-[xy] = -1 to mean the aspect ratio is to be preserved (Bug #43393) - * pdftocairo: Allow one of -scale-to-[xy] = -1 to mean the aspect ratio is to be preserved - * pdffonts: Add -subst option to list the substitute font name and filename - * pdfseparate: Produce PDF/X conformant pdf pages if the original PDF was PDF/X conformant - * pdfimages: Add -list option to list all images (Bug #46066) - * Improve various manpages - - glib: - * Add poppler_fonts_iter_get_substitute_name - * Demo improvements - * Update gtk-doc makefile and m4 file - * Fix typos in documentation - - qt4: - * Add the option of PSConverter creating EPS - * Form support improvements - - build system: - * autotools: Print the cairo version required if not found (Bug #44619) - * autotools: Print the glib version required if not found - * autotools: Use pkgconfig to check for libopenjpeg (Bug #21789) - * autotools: Replace openjpeg compile test with a version test - * Add a configuration option for the test data dir - -Release 0.18.4 - core: - * CairoOutputDev: Restore temporary clip used in CairoOutputDev::fill when painting a mask - * CairoOutputDev: Ensure paintTransparencyGroup uses same ctm as beginTransparencyGroup. Bug #29968 - * CairoOutputDev: Use fabs when comparing the transformed line width. Bug #43441 - * CairoOutputDev: Remove unused variable in CairoFontEngine.cc. Bug #45442 - * SplashOutputDev: Do not use 50Kb of stack in SplashXPath::addCurve. Bug #44905 - * JpegWriter: set image parameters after jpeg_set_defaults(). Bug #45224 - * OpenJPEG decoder: Set OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG if you have it. Bug #43414 - * Lexer: convert integer to real when overflow occurs. Bug #45605 - - glib: - * Various minor introspection and documentation improvements. Bug #44790 - * Fix return values. Bug #45440. Bug #45441 - * gtk-doc improvements. Bug #45549 - * Introspection improvements. Bug #45455 - - utils: - * HtmlOutputDev: Proper unicode support when dumping PDF outline. Bug #45572 - * HtmlOutputDev: Fix leaks. Bug #45805 - * HtmlOutputDev: Close li tags in generated outlines. Bug #45807 - * man pages: fix minor issues with hypens and % - - build system: - * automake: Link to lcms if needed - * automake: Fix build for builddir != srcdir. Bug #45434 - * automake: Improve moc detection when cross compiling - * Fix build with latest mingw-w64 headers. Bug #45407 - - qt4: - * remove non-existing 'qt' include dirs - -Release 0.18.3 - core: - * Do not fail if we are trying to save a file with Encrypt that has not been modified. KDE Bug #288045 - * Include .otf fonts when finding substitute fonts. Bug #44412 - * Fix stack overflow in PDFDoc::markObject(). Bug #44660 - * Include strings.h as we use memcpy. Bug #43558 - - utils: - * pdfunite: Properly initialize globalParams. Bug #44659 - * pdfseparate: Properly initialize globalParams - * Fix iniliazialization of GooString arguments - - build system: - * autoconf: Check for cairo-ft and other cairo backends. Bug #43969 - -Release 0.18.2 - core: - * Fix leak in GooString when resizing to a smaller string - * Fix crash if failing to parse the colorspace. Bug #42793 - * Make GfxColorSpace::parse accept dicts - - qt4: - * Use PDFDoc(wchar_t *, ...) on Windows. Bug #35378 - * Add missing include - * Minor fixes in documentation - - utils: - * pdftocairo: Fix crash when rendering only odd/even pages in a printing format - - build system: - * Fix pkg-config files - -Release 0.18.1 - core: - * PSOutputDev: Output PS that does not confuse libspectre - * PSOutputDev: Fix tiling pattern fill matrix. Bug #41374 - * PSOutputDev: Emit non repeating patterns just once - * PSOutputDev: Fix uncolored tiling patterns. Bug #41462 - * CairoOutputDev: Fix crash when using poppler_page_get_image() - * CairoOutputDev: Fix various setSoftMask bugs. Bug #41005 - - utils: - * pdftocairo: Flush/close files one we are done using them - * pdftocairo: Compile in Windows - - build system: - * CMake: Fix typo in option description - * CMake: Correctly include fontconfig include dir - * Remove poppler-cairo dependency from poppler-glib pkg-config file - - qt4: - * Minor fixes in documentation - -Release 0.18.0 - core: - * Fix small memory leak when dealing with marked content - * Remove DCTStream::getRawStream since Stream::getNextStream does the same - - utils: - * Rename pdfmerge to pdfunite - * Rename pdfextract to pdfseparate - * pdfseparate: Complain if %d is not present and it should - * Add pdfseparate and pdfunite man pages - - build system: - * Minor cleanup in regarding removed qt code - -Release 0.17.4 (0.18 RC) - core: - * SplashOutputDev: Compile when defining USE_FIXEDPOINT - * PNGWriter: Compile with libpng >= 1.5.0 - -Release 0.17.3 (0.18 Beta 3) - core: - * PSOutputDev: Use Patterns for tiling fill when PS level >= 2 - * PSOutputDev: Avoid using /PatternType if only one instance of the pattern is used - * PSOutputDev: Add poppler version as comment in the file - * CairoOutputDev: Set mime data for soft masked images (Bug #40192) - * CairoOutputDev: Assume printer pixel size is 1/600" when stroking 0 width lines (Bug #39067) - * CairoOutputDev: Use cairo_show_text_glyphs() when printing - * CairoOutputDev: Fix stroke patterns (Bug #11719) - * CairoOutputDev: Fix unique id mime data - * CairoOutputDev: fix stroking of very thin lines - * CairoOutputDev: align strokes when Stroke Adjust is true and line width <= 1 (Bug #4536) - * TextOutputDev: Add TextFontInfo::matches() - * Improve PNGWriter - * Rework writing of PDF files - - utils: - * Introduce pdftocairo - utility for creating png/jpeg/ps/eps/pdf/svg using CairoOutputDev - * Introduce pdfextract - utility to extract PDF pages - * Introduce pdfmerge - utility to merge PDF files - * Fix compilation warning - * pdftohtml: Support text rotation (Bug #38586) - * Update SEE ALSO section of man pages - - glib: - * Add poppler_page_get_text_attributes() - * Add text attributes information to text demo - - qt4: - * Add a way to get the fully qualified name of a FormField - * Minor documentation improvements - -Release 0.17.2 (0.18 Beta 2) - core: - * EmbeddedFile improvements - * don't gmalloc(-1) upon ftell failure - * Fix missing content in some pages (Bug #39637) - * Improve selection of CJK fonts (Bug #36474) - * SplashOutputDev: Implement overprint - * SplashOutputDev: Render dots for 0 length dashed lines (Bug #34150) - * SplashOutputDev: Fix bad memory access when not using antialias (Bug #37189) - * PSOutputDev: Make level2sep and level3sep write cmyk instead of rgb - * PSOutputDev: Make level1sep, level2sep and level3sep write gray instead of rgb for gray images - * Fix numerical overflow in libopenjpeg JPXStream (Bug #39361) - * Fix crash on truncated JPEG/DCT stream (Bug #36693) - * Make sure the dict is a page dict (Bugs #35925 #39072) - * Fix calculation of startXRefPos - * Handle missing startxref properly (Bug #38209) - * Parse the "Medium" modifier when asking fontconfig for a font - * Header cleanup - * Include cleanup - * Define cleanup - - glib: - * Add missing permissions flags to PopplerPermissions - * Add missing permission flags to info demo - * Update gtk-doc.make - * Add poppler_document_get_n_attachments() - - utils: - * pdftohtml: Fix encoding of PDF document metadata (Bug #37900) - * pdftohtml: Fix vertical spacing issues (Bug #38019) - * pdftotext: Fix -htmlmeta to correctly output U+2019 in PDF metadata (Bug #37900) - * pdftoppm: Implement overprint - - qt4: - * Rework EmbeddedFile internals - * Fix possible crash in test - -Release 0.17.1 (0.18 Beta 1) - core: - * Rework the way form fields tree is built - * Cleanup unused parameters/variables - - glib: - * Add JavaScript actions - * demo: Show javascript actions in actions view - - qt4: - * tests: Turn some assignments to bool into QVERIFY checks - -Release 0.17.0 (0.18 Alpha) - core: - * Splash: Implement tiling patterns - * Splash: Support slight hinting - * Splash: Radial shading improvements - * Splash: General speed improvements - * Arthur: Add Hinting API - * Cairo: Implement Type 4,5,6,7 shadings using cairo mesh gradients - * Cairo: Use the new cairo unique id to set the surface id when printing - * PS: Add PS level1 non standard binary output option - * PS: Allow setting the rasterization resolution - * Form support improvements - * Annotation support improvements - * General speed improvements - * Add support for handling ViewerPreferences - * Remove abiword output device - - utils: - * pdftoppm: Add -singlefile option (Bug #32025) - * pdftoppm: Add TIFF output format support (Bug #32027) - * pdftops: Add PS level1 non standard binary output option - * pdftops: Allow setting the rasterization resolution - * pdftoabw has been removed - - glib: - * Add poppler_form_field_get_action() (Bug 33174) - * Remove GDK API - * Remove test-poppler-glib - * demo: Add a tooltip with current selected character in text demo - * demo: show the activation action of form fields if there's one - - cpp: - * Add TIFF output possibility - * Add PNM output possibility - - qt4: - * Support slight hinting - * Form support improvements - - qt3: - * The Qt3 frontend has been removed - - tests: - * Merge splash and cairo tests into a single gtk-test tool - -Release 0.16.4 - core: - * Small improvements in Annot parsing - - glib: - * Add g_return macros to make sure index is correct in form field choice methods - * Fix a crash when a choice form field has no items selected in glib-demo - - utils: - * Small fixes to the pdftohtml manpage - * Fix copyright years - - qt4: - * Fix caption of push button fields - -Release 0.16.3 - core: - * Increase precision in PS output device - * Workaround bug when converting pdf to ps with level1 (Bug #31926) - * Fix crash in Splash output device in some broken pdf - * Fix infinite loop in some broken files - * Fix rendering of some substituted fonts (Bug #34522) - * Do not ask Freetype for 0x0 fonts in Splash output device (Bug #34602) - * Don't assume y1 > y3 for points of a highlight annotation (Gnome Bug #643028) - * Handle fontCIDType2OT when creating freetype font in Cairo output device (Gnome Bug #643273) - * Fix crash in some pdf that use ICC color space (Bug #34357) - - glib: - * Don't use an uninitialized local variable in demo - * Add some introspection markers - - qt4: - * Fix crash regression in unicodeToQString (again) - - utils: - * pdftotext: Do not crash when using -bbox - -Release 0.16.2 - core: - * Fix text extraction for some files - - qt4: - * Fix crash regression in unicodeToQString - -Release 0.16.1 - core: - * Fix colorspace issues in the Cairo backend (Bug #32746) - * Remove declaration of function without implementation - * Do not crash in case jpeg_create_decompress fails (Bug #32890) - * Fix variable access mismatch (Bug #33063) - * Fix converting some pdf to ps with -level1sep (Bug #32365) - * Fix line selection, dont check y for Line selections - * Include zlib header in PNGWriter.cc - * Fix leak in Splash backend when doing axial shaded fills - * Fix label to index conversion on multiple prefixes - - glib: - * Use NULL instead of FALSE for functions returning a pointer - * Fix memory leak in poppler_page_get_text_layout() for pages with no text - - qt4: - * Fix unicodeToQString() to correctly decode the Unicode sequence - -Release 0.16.0 - - core: - * Improve the correctness of radial shadings (Bug #32349) - * Adapt the zlib-based FlateStream code to API changes (Bug #32065) - * Make PreScanOutputDev be less agressive when deciding to rasterize (Bug #30107) - * Fix some warnings in newer gcc in Splash backend - * Fix the preliminary bbox/clip calculation in Splash backend - * Use A1 instead of A8 for imagemask in the Cairo backend - * Windows compile fixes - - utils: - * Do not return 99 (or 1) with -h, -v and -printenc (Bug #32149) - * Misc style improvements to pdftohtml code - * pdftohtml: Remove the -resolution flag introduced in 0.15.0 and fix the - existing -zoom flag - - build system: - * Add more warning flags to the default gcc builds - * Enable GObject introspection support in the cmake build system - - qt4: - * Windows compile fixes - -Release 0.15.3 (0.16 RC) - - core: - * Improve rendering of radial shadings - * Open a broken file (Bug #31861) - * Correct parsing of linearization table (Bug #31627) - * Find fonts inside patterns (Bug #31948) - * [win32] Simplify strtok_r implementation - * Use a std::vector<char> instead of a var-length-array of chars - * Fix crashes in broken files - * Use sets instead of arrays for looking for duplicate fonts - - cpp: - * Include correction - - utils: - * pdffonts: Remove duplicated code - -Release 0.15.2 (0.16 Beta 2) - - core: - * Improve shadings and antialias in the Splash backend (Bug #30436) - * Linearization improvements - * Small improvements to the Arthur backend - * Fix calculation of the size of some pages (Bug #30784) - * Fix crashes in broken documents - - qt4: - * Add Page::renderToPainter() method - * Add setDebugErrorFunction() method - - cpp: - * Add the hability to render pages to an image - - utils: - * Add -p flag to pdfimages - - build system: - * Remove -ansi flag for cywin and mingw - -Release 0.15.1 (0.16 Beta 1) - - core: - * Consider render value when colorizing text (Bug #2807) - * Improve rendering of Shading Type 6 and 7 - * Improve dict lookup speed for big dicts - * Fix multiple crashes in malformed PDF files - * Fix memory leak in in malformed PDF files - * Fix memory leak in the Catalog names - * Fix uninitialized uses on DCTScanInfo - * Fix a crash when drawing square/circle annots without a border (Bug #30580) - * Only clip boxes to mediabox if we are at the page level (Bug #30784) - * Do not omit the notdef glyph in the Splash backend - * Fix a crash when redering documents with invalid type 3 fonts in the Cairo backend - * Form improvements - * Add a method to get the PDF file identifier - - glib: - * Add more printing options to the API - * Add a method to get the PDF file identifier - * Add accessor for all PopplerDocument properties - * Form improvements - * Documentation improvements - * Improvements to the demo - - qt4: - * Add a callback to know which page has been printed - * Add a method to get the PDF file identifier - * Optimize GooString to QString conversion - * Some more autotests - * Update Doxyfile (enables .qch file for assistant) - - build system: - * Require Cairo 1.10 - - utils: - * pdftohtml: Add -s option to generate a single HTML page - * pdftotext: Add -bbox option - - cpp: - * Add the possibility of loading a document from raw data - * Add a method to get the PDF file identifier - * Improve Unicode to ustring conversion - * Documentation improvements - * Update Doxyfile - -Release 0.15.0 (0.16 Alpha) - - core: - * Remove exception support - * Improve creation of Annotations - * Fix failure to parse PDF with damaged internal structure. (Bugs #29189 #3870) - * Add a way to access the raw text of a page - * Speed improvements when reading multiple characters from a given Stream - * Speed improvements in the Splash backend - * Speed improvement in gray color space calculations - * Speed improvement in ICC color space calculations - * Speed improvement when reading some fonts - * Make GBool a bool instead of an int - - glib: - * Add GObject introspection support - * Improve creation of Annotations - * Add a way to get the coordinates of each character of a page - * Add a way to get the page label - * Documentation improvements - * Support password protected documents in the demo - * Support for selection in the demo - * Support for adding annotationss in the demo - * Misc improvements in the internals - - qt4: - * Add a way to access the raw text of a page - * Recognize "Print" as named action - * Documentation improvements - - build system: - * Add option for autogen.sh to skip configure - * Nicer autogen.sh output - * Improvements when build the glib frontend with CMake - - utils: - * pdftohtml: Use splash instead of external gs invocation to render the background - * pdftohtml: Let the user specify the resolution of the background. (Bug #29551) - - cpp: - * Add a way to access the raw text of a page - -Release 0.14.3 - - core: - * Tell Windows we are writing/reading binary data from stdout/stdio (Bug #29329) - * Fix crash when parsing some Movie elements (KDE Bug #249586) - -Release 0.14.2 - - core: - * Fix rendering of some documents involving tilingPatternFill in the cairo output device - * Improve rendering of some annotations - * Handle ColorTransform in DCT streams when using libjpeg (Bug #28873) - * Fix crash in the ps output device in some files (KDE Bug #246269) - * Fix crash in some malformed files (Bug #28842) - - build system: - * Improve build on windows - * Add uninstalled .pc file support when using autoconf - - glib: - * Fix a crash when a layer doesn't have a name (Bug #28842) - - utils: - * Fix padding of names in pdftoppm - -Release 0.14.1 - - core: - * Add ObjectStream caching, makes opening some files ten times faster (Bug #26759) - * Fix crash when writing to negative coordinates (Bug #28480) - * Check objects are the type we want them to be when parsing GfxICCBasedColorSpace - * Optimize Splash::compositeBackground - * Optimize color space calculations by using sqrt instead of pow 0.5 - * Fix crash in JBIG2Stream with malformed documents - - build system: - * Make sure we ship two needed cmake files - * Do not distribute glib/poppler-features.h and poppler/poppler-config.h - * Improve compilation with Sun Studio - * Fix linking of the cpp frontend when using autotools - - glib: - * Fix links/annots area for some documents (Bug #28588) - * Fix poppler_page_find_tex() when called more than once (Bug #27927) - - utils: - * Add -cropbox to pdftoppm manual - -Release 0.14.0 - - core: - * Fix crash when parsing pdf with broken JBIG2Stream (Bug #28170) - * Do not follow loops blindly when parsing XRef (Bug #28172) - * Allow quality & progressive mode to be utilised in JpegWriter - * Fix potential assert in Lexer code (KDE bug #240208) - * Fix opening of files whose /P is stored as unsigned integer - * Do not exit() when trying to allocate memory for the XRef fails - - cpp: - * Minor bugfixes - * Documentation improvements - - build system: - * Fix build in mingw32 when using autotools - * Preserve compiler flags when using cmake - -Release 0.13.4 (0.14 RC 1) - - core: - * Include standard float.h instead of unportable values.h - * Fix first color stop offset of linear gradients. Bug #27837 - * Fix compilation if JPEG nor PNG is used - * Use fabs for doubles instead of abs - * Use strtok_r instead strtok - * Adjust bbox for line annots when y1 = y2 - * Some fixes and regressions in the cairo output device - * Better check of overlapping of table cells when selecting text - - cpp: - * Make the pkg-config files really work - * Fix in/out buffer sizes in some functions - -Release 0.13.3 (0.14 Beta 2) - - core: - * Fix roll optimization in the PS function interpreter - * Correctly parse numbers with '+' sign. Gnome bug #614549 - * Add support for cached files - * Add support for reading a cached file from stdin - * Add HTTP support using libcurl, disabled by default - * Add some const correctnes to GooString - * Rework DCTStream error handling. Bug #26280 - * Use current fill_opacity when drawing soft masked images in Cairo backend. Gnome bug #614915 - * Use the topleft of the Rect of text annots to draw - * Fix saving update docs that have a compressed xref table. Bug #27450 - * Parse varius part of the document catalog on demand - * Implement colorizing image masks with pattern colorspace in Cairo backend - * Fix a crash when rendering 0x0 images in Cairo backend - * Check pattern status after setting matrix when rendering images - * Improve text selection/extraction order. Bug #3188 - * Fix pattern size when bbox is not at 0,0 - * Improve colorizing text and masks in pattern colorspace. Bug #27482 - * Silence some Illegal entry in bfrange block in ToUnicode CMap. Bug #27728 - - utils: - * Add the -o[dd] and -e[ven] options to pdftoppm - * Allow read from stdin using the new cached files feature - * Fix crash in pdftohtml when output filename was shorter than 5 characters - - glib: - * Use existing cairo api when rendering to a pixbuf - * Compile with -DGSEAL_ENABLE. Bug #27579 - -Release 0.13.2 (0.14 Beta 1) - - core: - * Improve Movie support - * Fix experimental Arthur backend to compile when if Splash backend is disable - * Fix usage of some streams in the Cairo backend - * Small improvements in the experimental Arthur backend - * Minor annotation improvements - * Rework LinkRendition to follow the spec - * Add support for Set-OCG-State actions - * Correctly initialize the grayscale softmask color in the Splash backend - * Correctly initialize actualText in TextOutputDev when initialization fails - * Various MSVC fixes - - glib: - * Add support for Movie objects - * Add support for Screen annotations - * Add support for rendition actions - * Add support for OCG State actions - * Improvements to the demo - - qt4: - * Always compile the experimental Arthur backend - * Minor speed improvement in QPainter usage - * Add a search overload that takes doubles instead of QRectF - - cpp: - * Fix iconv usage - * use gmtime() when gmtime_r() is not available - * Fix building in autotools in windows - * {from,to}_utf_8() -> {from,to}_utf8() - - build system: - * Multiple CMake build system fixes - * Fix of some DIST targets in autotools - * Make finding of Qt3 in autotools use pkg-config - -Release 0.13.1 (0.14 Alpha 2) - - core: - * New C++ frontend to interface with Poppler using only STL - * Use the right matrix for the mask in drawMaskedImage in Cairo output device. Bug #16906 - * Fix downscaling images when document is rotated in Cairo output device. Bug #26264 - * GooVector rewrite, old version had "unknown" origins/license - * Fix use after free in a error condition - * Improve handling of broken commands. Bug #24575 - * Fix potential use after free in Cairo output device. - * Fix regression in painting. Bug #26243 - * Improve handling of FontConfig. Bug #26544 - * Only assume the OC is not visible if it exists and is set to no. Bug #26532 - * Fix a potential crash in Splash font handling on out of memory conditions - * Implement writeImgFile for splashModeXBGR8 - * Several speed increases (around 40% in some documents) in the Splash output device - * Improve printing on the Cairo output device - * Do not use '\' character in PostScript names - * Omit writing of embedded fonts into temporary files in the Cairo output device. Bug #26694 - * Improve filtering of some images in the Cairo output device. Bugs #25268, #9860 - - utils: - * pdftoppm: Only swap w with h if rotation is 90 or 270 - - build system: - * Add POPPLER_WITH_GDK in cmake build system. Bug #26247 - * Fix typo: "MULTITHREAD" -> "MULTITHREADED in cmake build system - * Wrap #include <jpeglib.h> in extern "C" to fix build. Bug #26351 - * Add the Win32-specific ENABLE_RELOCATABLE option to cmake build system - * Reflect that poppler-glib needs cairo now in cmake build system - * Use pkgconfig to detect libpng on autotools build system - * Detect the need for nanosleep in solaris in cmake build system. Bug #26650 - -Release 0.13.0 (0.14 Alpha) - - core: - * Improvements to Annotation rendering. Bug #23108 - * Do not give an error when opening files without pages. Bug #24720 - * Try to read streams without Length - * Do not crop the transformation matrix at an arbitrary value. Bug #25763 - * Make poppler (optionally) relocatable on Windows - * Use a small object cache in GfxResources to cache GState objects - * Reduce the number of redundant pattern creations in the Cairo output device - * Use colToDbl() to avoid rounding error in the Cairo output device - * Fix problems with mask handling in the Cairo output device. Bug #8474 - * Use a better scale down implementation in the Cairo output device - * Various optimizations to the Splash output device - * Add the possibility to use floats instead of doubles in the Splash output device. Bug #25578 - * Write out fixed-content portion of Type 1 fonts in the PS output device - - build system: - * Improvements to the CMake build system - * Enable AM_SILENT_RULES by default in autotools - * Require glib 2.18 - * Require GTK+ 2.14 - * Make fontconfig optional with mingw compiler - * Remove makefile.vc - - glib: - * Add support for file attachment annotations - * Improvements to the demo - * Use TextOutputDev to get TextPage when we haven't rendered the page - * Remove support for the Splash output device - - utils: - * pdftoppm can now write to jpeg - * pdftoppm embeds the correct resolution in png and jpeg files - - qt4: - * Minor improvements to the tests - -Release 0.12.3 - - core: - * Be more lenient with /Decode key on images. Bug #17439 - * Correctly initialize fileName in LinkGoToR. Bug #25221 - * Improve the reconstruction of the XRef for broken files - * [Cairo backend] Do not crash on malformed files. Bug #24575 - * Accept Fontname if FontName is not present. KDE bug #217013 - * Make PSOutputDev code a bit more resilient - * Fix writing of null objects. Bug #25465 - * [Cairo backend] Fix crash in some documents. GNOME bug #603934 - * Correctly initialize profileCommands in Gfx constructor - - build system: - * Check for openjpeg in the C++ part as it uses bool in the header. Bug #25103 - -Release 0.12.2 - - core: - * Fix a memory leak when converting to PostScript - * Fix crash when reading a font fails. Bug #24525 - * Make the ICC cache per page instead of global. Bug #24686 - * Do not accept negative interval lengths in the page labels tree. Bug #24721 - * Do not crash on files Aspect of Movie objects are reals instead of integers. Bug #24733 - * Do not render patterns when using CairoImageOutputDev - * Allow Transitions dictionary to be a Ref - * Do not crash if jpeg_start_decompress fails. KDE bug #214317 - - glib: - * Fix CVE-2009-3607 - - qt4: - * Use '.' in the annotations XML instead of the decimal separator of the current locale - -Release 0.12.1 - - core: - * Fix compilation on some compilers - * Only initialize the font list once in Windows32/MSVC - * Do not crash on fonts without CharCodeToUnicode. Bug #24036 - * Fix regression due to not setting LC_NUMERIC anymore - * Improve realibility for Streams with broken Length. Bug #6841 - * Write the Info into the trailer dict if there is one. Bug #24091 - * Do not crash when saving files that come from a stream without name. Bug #24090 - * Improve relability of the save function - * Fix the Length value if it was wrong when saving - * Fix includes for those using internal headers - * Rework how hinting is used in the splash backend. It is disabled by default now - * fix constructor of DCTStream when using internal decoder - * Security fixes based xpdf 3.02pl4 - - qt4: - * Add the possibility of setting wheter to use or not font hinting - * Add a way for converters to return more exact errors they had when converting - * Check the document is not locked when converting to PS - - build system: - * Compile on Cygwin - * Use _WIN32 instead of WIN32. Bug #24259 - * Add the possibility to pass LIB_SUFFIX when using CMake - -Release 0.12.0 - - core: - * Fix printf format security warnings - * Improve rendering of radial shadings. Bug #20238 - * Better fallback when there's a font type mismatch. Bug #17252 - * Do not crash on attachments without data stream. Bug #10386 - * Fix infinite loop in JBIG2Decoder. Bug #23025 - - build system: - * Minimizes pkg-config dependencies for Qt frontends - * Add automake 1.11 support - * Use the newest automake found and not the oldest - * Support AM_SILENT_RULES when using automake 1.11 - - utils: - * Add common options to pdftoabw - -Release 0.11.3 (0.12 RC 1) - - core: - * Optimization in the Cairo renderer for some fonts - * Do not apply masks when fill color space mode is csPattern in the Cairo renderer. Bug #22216 - * Check for overflow when parsing integers. Bug #23078 - * Do not save the font file twice for FreeType fonts in the Cairo renderer. Bug #20491 - * Use current fill_opacity when drawing images in the Cairo renderer - * Fix alpha rendering in some files in the Splash renderer. Bug #22143, #22152 - * Implement tiling patterns in the Cairo renderer - * When converting a cm matrix to PS write 4 significant digits for numbers < 1 not 4 decimals. Bug #23332 - * Fix changing of locale, now poppler no longer changes LC_NUMERIC to "C" - * Return PDF version as two integers instead of as a double - - Qt4: - * Addition of the Color Management API - * Small fix to documentation - * Fix backwards text search - - utils: - * Add the -png flag to pdftoppm to output to PNG - -Release 0.11.2 (0.12 Beta 2) - - core: - * Make DecryptStream return sane values for getPos(). Bug #19706 - * Fix bug when printing pdf with multiple page sizes in duplex mode - * Initilize AnnotColot properly when the Array is not correct - * Fix crash on some files with forms. Bug #22485 - * Fix crash in files with invalid embedded files. Bug #22551 - * Improve FileSpec attribute parsing - * Cairo output device improvements. Bugs #10942, #18017, #14160 - * Implement blend modes in cairo backend - * Handle fontType1COT fonts in CairoFontEngine - * Fix generation of PS for some files. Bug #18908 - * Don't use byte_lookup table when color space doesn't support getLine methods. Bug #11027 - * Fix rendering of PDF files with malformed patterns. Bug #22835 - * Add the possibility of disabling font substitution in pdftops. Bug #23030 - * Fix some radio buttons not being detected as such - - glib: - * Improvements to the demo - - Qt4: - * Improvements to the demo - - build system: - * Use gtkbuilder rather than libglade for some tests - - utils: - * Fix bug with noCrop parameter in pdftops - -Release 0.11.1 (0.12 Beta 1) - - core: - * Support colorizing text in pattern colorspace. Bug #19670 and #19994 - * Add the possibility of forcing no hinting of fonts in the Splash backend - * Support multiple page sizes when converting to PS. Bug #19777 - * Also tokens with leading 00 when parsing the char to unicode map. Bug #22025 - * Improvements of rendering speed in documents using PS transformations a lot. Bug #21562 - * More work on Annotations support - * Use Interpolate flag to decide whether applying image interpolation during rendering. Bug #9860 - * Handle Streams in CMap definitions. Bug #22334 - * Fix some bugs in JBIG2Stream handling - * Fix dashed line in page 1 of bug 20011 - * Fix exit(1) when rendering a file - * Fix pdftops crash on file from KDE bug #174899 - * Fix PS generation in some files. Bug #20420 - * Do not create the GfxColorTransform if the lcms could not be created. Bug #20108 - * Check Mask entries are int before using them, if they are real cast to int and try to use them. Bug #21841 - * Use the correct value when creating the V field for form combo boxes - * Give an error when using level1sep in pdftops without having CMYK support. Bug #22026 - * Don't include lcms.h in GfxState.h - * Fix splashColorModeNComps to correctly include all values for each SplashColorMode - * Add splashClearColor that assigns white to the given colorptr - * Kill support for specifying extension in openTmpFile. Bug #21713 - * Fix "Conditional jump or move depends on uninitialised value". Bug #20011 - - glib: - * Add poppler_annot_markup_has_popup() - * Hyphenate UTF-8 and UTF-16BE. Bug #21953 - * Use g_strerror instead of strerror. Bug #22095 - * Fix a crash when a destination points to an invalid page - * Improvements to the demo - - Qt4: - * Add LinkDestination::destinationName() - * Do not try to resolve named destinations for GoTo links pointing to external documents - * Add Page::thumbnail() - * Improvements to the demo - * Improvements to the documentation - - build system: - * Build fix for MSVC - * Better lcms cmake check comming from kdelibs - * Use pkgconfig for autotools lcms check - * Remove unneeded files from repo. Bug #22094 - -Release 0.11.0 (0.12 Alpha) - - core: - * Add initial support for color management - * Remove case-insensitive matching of filenames in PDFDoc constructor - * Fix extraction of some ActualText content - * More work on Annotations support - * Improve font rendering in Cairo output device - * Fix bug in cairo backend with nested masks - * Fix cairo luminosity smask rendering - * Add optionally text support to Cairo output device - * Add the possibility of setting the datadir on runtime - * Return an error code instead of a boolean when saving - * Make the font scanner more versatile - * Small opimization in documents that use PostScriptFunction transforms - * Minor optimization to Stream handling - * Fix some compile warnings - - glib: - * Optional content support - * More work on Annotations support - * Improvements to the demo - * Documentation improvements - * Fix build when compiling with GTK_DISABLE_SINGLE_INCLUDES - - Qt4: - * Support URI actions for Table Of Contents items - * Documentation improvements - * Improvements to the demo - * Add a FontIterator for iterating through the fonts of the document - - utils: - * Allow the use of cropbox in pdftoppm - * Make pdftohtml output png images when the image stream is not a jpeg - * Make pdftotext accept cropping options like pdftoppm - * Support rendering non-square pixels in pdftoppm - - build system: - * Require Cairo 1.8.4 for the Cairo output device - * Require CMake 2.6 when using the CMake build system - * Optionally require libpng for pdftohtml - * Optionally require libcms for color management - -Release 0.10.6 - - core: - * Fix problems that happen when parsing broken JBIG2 files. - CVE-2009-0799, CVE-2009-0800, CVE-2009-1179, CVE-2009-1180 - CVE-2009-1181, CVE-2009-1182, CVE-2009-1183, CVE-2009-1187, CVE-2009-1188 - * Fix parsing of incorrect border arrays. Bug #19761 - * Fix clip test for fonts. Bug #20950 - * Fix getGlyphAdvance to behave correctly on font size changes. Bug #20769 - * Misc build fixes - - build system: - * Fix the Qt4 version we need - -Release 0.10.5 - - core: - * Read the UF entry if present and prefer it over F in Filespec dictionary - * Fix typo that was making CairoOutputDev crash on some files. Bug #17337 - * Make JBIG2Stream more robust to corrupt input data - * Do not blindly follow loops parsing OutlineItem. Bug #18364 - * Set up the error manager before calling jpeg_create_decompress. Bug #20484 - * Check there is an optional content config before using it. Bug #20587 - * Fix rendering of some PDF with OpenType fonts. Bug #20605 - - build system: - * Yet more support for build on windows - * Use AC_CHECK_HEADER to find headers. Bug #20538 - * Check for pkgconfig before using it - * General autotools improvements - -Release 0.10.4 - - core: - * Fix a memory leak when asking for a document-level JS - * Do not crash in some PDF we do not parse correctly. Bug #19702 - * Fix crash on unexepcted form Opt value. Bug #19790 - - utils: - * Fix pdfimages to extract i color components per pixel jpeg images. Bug #19789 - -Release 0.10.3 - - core: - * Fix a crash on documents with malformed outline. Bug #19024 - * Fix leak on AnnotScreen destructor. Bug #19095 - * Fix wrong PS generation when a large image is in Patterns. Bug #18908 - * Remove BaseFile.h it was never used. Bug #19298 - * Improve document saving - * Fix PS generation of PDF with malformed font Length2 definition - * Fix a leak while parsing annotations - * Fix rendering of some checkboxes - - Qt4: - * Fix positioning of Form rects on PDF with cropbox - * Fix positioning of Annotation rects on PDF with cropbox. Bug #18558. - * Small documentation improvements - * Make Document::fonts() work when called more than once. Bug #19405 - - build system: - * CMake: look harder for openjpeg - * CMake: update the poppler core headers installation - * Autotools: do not install Function.cc as it's not a header - - Qt: - * Fix deserialization of links right coordinate - -Release 0.10.2 - - core: - * Fix a crash when selecting text in word mode - * Fix a crash in some malformed documents (second argument of opMarkPoint is not a dictionary) - * Ensure cairo font matrix is invertable. Fixes bugs #18254 and #18429 - * Fix a memory leak (Bug #18924) - - Qt4: - * Fix deserization of links right coordinate - - misc: - * Fix build on Solaris 10 + Sun Studio 12 - * Compile with -pedantic - -Release 0.10.1 - - core: - * Improvements in Optional Content support - * Small fix in Form support - * Fix memory leak in case of error - * Fix potential crash on text search - * Try render documents with invalid indexed color space parameters. Bug #18374 - * Fix crash on text extraction when poppler-data is not installed. Bug #18023 - - Qt: - * Fix two memory leaks - - Qt4: - * Small documentation improvement - * Fix memory leak in the demo code - -Release 0.10.0 - - core: - * Fix crashes on PDF using Stitching or Axial Shading painting - * Fix rendering of PDF with Type1 fonts that have more than - one encoding definition per line - * Do not try to save documents that have Encryption as we - do not support that and the user ended with a broken file - * Fix crash on files with OptionalContentGroup but no Name - - Qt4: - * Fix the area of the links to be correctly reported on rotated documents - - misc: - * Mingw+Msys should work - -Release 0.9.3 (0.10 RC 2) - - core: - * Fix rendering regression on some embedded fonts - * Fix rendering regression of some special fonts - * Fix crash on documents with bogus jpeg data - - Qt4: - * The printing flag defaults to true on PSConverter - * Documentation improvement - - utils: - * Fix regression that made HmtlOutputDev ignore jpeg images - - misc: - * Improve compilation on mingw - -Release 0.9.2 (0.10 RC 1) - - core: - * Fix conversion to PS some files (bug #17645) - * Small Form fixes - * Small JS fixes - * Improve memory usage of the cairo renderer - - utils: - * Fix mismatched free/delete in pdftohtml - * Fix memory leak in pdftohtml - * Fix crash in pdftohtml - - glib: - * Fix a crash in forms demo - - misc: - * Compile with -pedantic - -Release 0.9.1 (0.10 Beta 2) - - Core: - * Fix crash on some AESv2 encrypted files (bugs #13972, #16092, #17523) - * Improve parsing of broken files (bug #17568) - - glib frontend: - * Minor improvements to the demo application - - utils: - * pdftohtml: Generate the outline file in the same place - of the other generated files (bug #17504) - -Release 0.9.0 (0.10 Beta 1) - - Core: - * Initial JavaScript support - * Annotation improvements - * Improvements in the Arthur based renderer - * Improvements in the Cairo based renderer - * Added a JPEG2000 decoder based on OpenJPEG - * Small fixes in ActualText implementation - * Fix jpeg rendering when not using the libjpeg based decoder - * Movie fixes - * Do not get out of memory on documents that specify huge fonts - * Emulate Adobe Reader behaviour on documents with duplicate keys in Dictionaries - * Forms improvements - - Qt4 frontend: - * Annotation improvements - * Forms improvements - * Add the possibility of extracting embedded fonts - * Initial Movie support - * Documentation improvements - * Small improvements in the PS exporter - - glib frontend: - * Annotation improvements - * Attachment fixes - - utils: - * updated man pages - * Added -listenc to pdfinfo and pdftotext - -Release 0.8.7 - - Core: - * Fix regression in Form rendering - * Fix memory leak in the cairo backend - -Release 0.8.6 - - Core: - * Call error() when font loading fails - * Be less strict parsing TTF tables (bug #16940) - * Fix crash due to uninitialized variable - - Qt 4 frontend: - * Make the paper color setting working as it should - * Make sure to use the correct page width/height for form widgets coordinates - -Release 0.8.5 - - Core: - * Fix crash on PDF that define a page thumbnail but it's not a Stream - * Fix crash when Annots object is not of the desired type - * Fix crash when obtaining fonts in PDF where XObjects link themselves in loops - * Fix crash on documents with an IRT object - * Saving should work much better now - * Plug some memory leaks in Annotation handling - - Utils: - * pdftohtml: Don't crash on documents that specify an invalid named dest for a link - * pdftohtml: Make html output to keep all the spaces with   - * pdftohtml: Improve a bit text layout - * pdftohtml: Make xml output valid xml - -Release 0.8.4 - - Core: - * Fix leak in ABWOutputDev.cc - * Fix uninitialized variable that broke file saving in some cases - * Use a single global FT_Library in CairoOutputDev. - Fixes some crashes in CairoOutputDev. - - Qt 4 frontend: - * Fix saving over existing files - - build system: - * Make sure Qt4 moc is used to generate moc files in Qt4 frontend - -Release 0.8.3 - - Core: - * Fix crash when reading some PDF with annotations - * Fix crash on PDF that reference Optional Content elements that don't exist - * Fix leaks on error conditions - * Do not limit CharCodeToUnicodeString to 8 characters - * Support for surrogates outside the BMP plane - - Qt 3 frontend: - * Fix crash when reading PDF with password - * Fix leak when calling scanForFonts() - - Qt 4 frontend: - * Fix the text() method - - Splash renderer: - * Fix compilation with --enable-fixedpoint - -Release 0.8.2 - - core: - * Fix call broken by a fix introduced in 0.8.1 - -Release 0.8.1 - - core: - * Do not call FT_Done_Face on a live cairo_font_face_t as it might cause crashes - * Do not take into account Colorspace resource subdictionary for image XObjects - * Downsample 16 bit per component images to 8 bit per component so they render - - build system: - * Link to pthread when the system needs it - - windows: - * Fix comparing against NULL instead against INVALID_HANDLE_VALUE when calling FindFirstFile - -Release 0.8.0 - - * Fix caching of members in the glib frontend causing issues with rendering - * Change glib public api to have a correct naming - * Some better error handling on corner cases - * Check the document stream is seekable when opening it - * Build fixes with autotools and with cmake - * Fix infinite recursion on some malformed documents when consulting the fonts - * Fix possible crash when asking for Movie contents - -Release 0.7.3 (0.8 RC 2) - - * Fix regression in Splash renderer - * Fix off-by-one write in Splash - * Plug some minor leaks in Optional Content code - * Improve error handling when creating a document in the glib frontend - -Release 0.7.2 (0.8 RC 1) - - Major Changes: - * Improve font matching not forcing default values onto Fontconfig - * Add preliminary annotations support in the glib frontend - * Initial Movie support in the core - * Make GDK dependency optional in glib bindings - - Minor Changes: - * Make the core able to read mime types of embedded files - * Qt4 API for accessing mime types of embedded files - * Handle correctly check state of optional content groups - regarding parents state - * Avoid setting singular CTM matrices on the Cairo backend - * Improved Qt4 API to get character position - * Qt4 api documentation improvements - * Qt4 minor stability fixes - * Proper lib64 Qt detection - * Fix build when compiling without cairo support - -Release 0.7.1 (0.8 Beta 2) - - Major Changes: - * Really distribute CMake files as optional build tool - * Initial Optional Content support in core and in the Qt4 frontend - - Minor Changes: - * Allow grouped checkboxes to be selected individually - * Qt4 demo program improvements - * Keep cairo and cairo_shape consistent - * Safety checks on Splash renderer so that it does not draw outside the allocated bitmap - * Do not try to display bitmaps of invalid size - * Fix building with exceptions - * Improvements for building with MSVC and CMake - -Release 0.7.0 (0.8 Beta 1) - - * Saving support - * Partial annotation support - * Forms improvements - * Add support for ActualText entries - * Display characters outside of unicode BMP with TT font - * CJK rendering fixes - * Implement Adobe Glyph Naming convention for fonts - * CMake as optional build tool - * Better font scaling for non embedded fonts - * Preserve PDF page labels when we output as postscript - -Release 0.6.4 - - Qt4 frontend: - * Fix crash on links that point to a non existant page - * Make Document::renderHints return the correct render hints - * Fix infinite loop when parsing LineAnnotation - - core: - * Fix crash in the Splash renderer when T3 fonts are badly defined - * Draw underlined Links correctly - - utils: - * Fix two use after free bugs in HtmlOutputDev.cc - - build system: - * Fix build on mingw32 - - tests: - * Distribute the glade file of pdf-inspector - -Release 0.6.3 - - core: - * Fix crash in extra debug code - - glib frontend: - * Make sure passwords are passed correctly to poppler core - - Qt frontend: - * Fix crash on documents that specify an empty date - - build system: - * Disable gtk tests if the user disabled glib frontend - -Release 0.6.2 - - poppler core: - * Fix CVE-2007-4352, CVE-2007-5392 and CVE-2007-5393 - * Fix a crash on documents with wrong CCITTFaxStream - * Fix a crash in the Cairo renderer with invalid embedded fonts - * Fix a crash with invalid TrueType fonts - * Check if font is inside the clip area before rendering - it to a temporary bitmap in the Splash renderer. Fixes crashes on - incorrect documents - * Do not use exit(1) on DCTStream errors - * Detect form fields at any depth level - * Do not generate appearance stream for radio buttons that are not active - * mingw fixes - - build system: - * Require fontconfig >= 2.0 - * builddir != srcdir fixes - - Qt4 frontend: - * Improved documentation - - misc: - * Fix FSF address - -Release 0.6.1 - - poppler core: - * Fix printing with different x and y scale - * Fix crash when Form Fields array contains references to non existent objects - * Fix crash in CairoOutputDev::drawMaskedImage() - * Fix embedded file description not working on some cases - - Qt4 frontend: - * Fix printing issue - * Avoid double free - * Fix memory leak when dealing with embedded files - - glib frontend: - * Fix build with --disable-cairo-output - * Do not return unknown field type for signature form fields - - build system: - * Support automake-1.10 - * More compatible sh code in qt.m4 - - utils: - * Fix build on Sun Studio compiler - -Release 0.6 - - - CairoOutputDev fixes - - Allow pdftoppm to read/write from stdin/stdout - - API work on Qt4 frontend - - Fix pdfimages produces inverted image for black & white image - - Fix error on the NFKC text matching routine - - Add support for word and line selections - - Do not enforce %%EOF at the end of file - - Pad zeroes instead of aborting when rendering 1-bit images - and the stream is too short - - Update glib bindings documentation - -Release 0.5.91 (0.6 Release Candidate 2) - - - Various memory leaks fixed - - Compile with --enable-fixedpoint. Bug #11110 - - Header cleanup - - Remove dependency on debugxml. Bug #11187 - - Allow access to document metadata in glib and qt4 frontends - - Several glib API frontend improvements - - Fix crash on accessing embedded files - - Build on Sun Force compiler - - Render '*' instead of the actual content in password form fields - - Fix pdftohtml complex output. Bug #9746 and #11610 - - Windows build fixes - - Improve Japanese font support. Bug #11413 - - Do not exit the program on files that confuse libjpeg - - Update required cairo version to 1.4 - - Fix CVE-2007-3387 - -Release 0.5.9 (0.6 Release Candidate) - - - Merge xpdf 3.02 changes - - Qt4 frontend is not marked anymore as unstable - - Support for Sound objects - - Support for Opening/Closing page actions - - Support for page duration - - Improve PS Tokenizer performance thanks to Scott Turner - - Various speed ups by Krzysztof Kowalczyk - - Beginning of Interactive Form support by Julien Rebetez - - xpdfrc is no longer used for anything - - Add AbiWord output device and pdftoabw program by Jauco Noordzij - - Fix security issue MOAB-06-01-2007 - - Lots of bugs fixed - -Release 0.5.4 - - - Automatically read in CJK encoding files if they're - installed (#2984, #7105, #7093). This works with the new - poppler-data package. - - Speed ups by Krzysztof Kowalczyk (#8112) - - Patch from Dom Lachowicz to let the utils take input on stdin. - - Bugs fixed (#8182, #4649, #7906, #8048, #7113, #4515, #3948, - #7924, #7780, #7646, #6948, #7788, #7661, #7005) - -Release 0.5.3 - - - Add poppler as a private requires of poppler-glib. - - Allow CairoFont creation to fail more gracefully (#4030). - - Back out the rest of krh's type3 font work. - - Revert splashModeRGB8 changes. - - Add missing poppler-annotation-helper.h. - -Release 0.5.2 - - - Much improved Qt bindings (Albert Astals Cid). - - Cairo backend now supports masked images (Jeff Muizelaar, #6174). - - Patches from Kouhei Sutou to make glib bindings more - language binding friendly (#6907, #6897, #6899, #6905). - - Search now works with ligatures (Ed Catmull, #2929). - - The glib bindings now has an entry point to render to a cairo_t. - - GCC 4.1 and MSVC compilation fixes. - - Memory leaks plugged: #6908, #6947, #6765, #6764, #6187 - - Misc bug fixes: #6984, #6896, #6913, #6926, #4481, #5951, - #6551, #6500, #6492, #6454, #6079, #6167. - -Release 0.5.1 - - - Support for embedded files. - - Handle 0-width lines correctly. - - Avoid external file use when opening fonts. - - Only use vector fonts returned from fontconfig (#5758). - - Fix scaled 1x1 pixmaps use for drawing lines (#3387). - - drawSoftMaskedImage support in cairo backend. - - Misc bug fixes: #5922, #5946, #5749, #5952, #4030, #5420. - -Release 0.5.0 - - - Font matching code for non embedded fonts now use fontconfig - instead of hard coded list of fonts. - - Merge in Xpdf 3.01 changes. - - Add command line tools from Xpdf. - - Make install of Xpdf header files ./configure'able. - -Release 0.4.0 - - - Real text selection. - - API breakage in glib wrapper: dropping dest_x and dest_y - arguments from poppler_page_render_to_pixbuf(). - -Release 0.3.3 - - - New glib API to get document font information (Marco). - - More document properties available as glib properties (Emil - Soleyman-Zomalan, #3359) - - Optimize color conversion for images. - - Support for constant opacity. - - Fix problems with pkg-config files. - - Bugs fixes: #3491, #2911, #3362, #3340, #3265, #3239, #3396. - -Release 0.3.2 - - - New API to get poppler version and backend type. - - Various font fixes from Albert Astals Cid. - - Update to cairo 0.5.0 API, including better font support. - - Meta data for the glib binding. - -Release 0.3.1 - - - Add qt/poppler-private.h to SOURCES - - Jeff's path to use zlib instead of builtin decompression. - - Bug fixes: #2934, segfault on invalid links, #3114 - -Release 0.3.0 - - - First cut at qt wrapper, including a getText() method for - getting text from a page. - - More glib functionality: meta data, set page orientation, - print to PS - - Performance fixes for glib cairo - - Bug fixes - -Release 0.2.0 (Tue Apr 5 12:32:10 EDT 2005) - - - Add glib wrapper for poppler, which will use cairo rendering - if available - - Support for page labels - - configure and build fixes. - -Release 0.1.2 (Wed Mar 9 10:45:58 EST 2005) - - - cairo optimizations and fixes from Jeff Muizelaar - - Bump cairo requirement to 0.4 - - Make cairo and gtk checks fail gracefully - -Release 0.1.1 - - - Fix issues with installed header files including config.h - - Fix a couple of typos in pkg-config files - - Install splash and cairo header files when necessary - -Release 0.1 - no date yet - - - First release - - More NEWS here diff --git a/source/libs/poppler/poppler-0.32.0/configure.ac b/source/libs/poppler/poppler-0.32.0/configure.ac deleted file mode 100755 index 56a972e45..000000000 --- a/source/libs/poppler/poppler-0.32.0/configure.ac +++ /dev/null @@ -1,991 +0,0 @@ -m4_define([poppler_version_major],[0]) -m4_define([poppler_version_minor],[32]) -m4_define([poppler_version_micro],[0]) -m4_define([poppler_version],[poppler_version_major.poppler_version_minor.poppler_version_micro]) - -AC_PREREQ(2.59) -AC_INIT([poppler],[poppler_version],[https://bugs.freedesktop.org/enter_bug.cgi?product=poppler]) -AC_CONFIG_MACRO_DIR([m4]) -AM_INIT_AUTOMAKE([1.7 foreign]) -m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) -AC_CONFIG_HEADERS([config.h poppler/poppler-config.h]) -AC_C_BIGENDIAN - -dnl ##### Initialize libtool. -AC_LIBTOOL_WIN32_DLL -define([AC_LIBTOOL_LANG_F77_CONFIG], [:]) -AC_PROG_LIBTOOL - -dnl ##### Checks for programs. -AC_PROG_CC -AC_PROG_CXX -AC_ISC_POSIX -AC_PROG_CC_STDC -#if test -z "$CXX" -a "$CC" = "gcc"; then -# CXX="gcc" -#fi -AC_PROG_CXX -AC_PROG_INSTALL - -dnl ##### Check for pkgconfig -PKG_PROG_PKG_CONFIG - -dnl ##### Export the version -AC_DEFINE_UNQUOTED([POPPLER_VERSION], ["poppler_version"], [Defines the poppler version]) - -dnl Enable these unconditionally. -AC_DEFINE([OPI_SUPPORT], [1], [Generate OPI comments in PS output.]) -AC_DEFINE([MULTITHREADED], [1], [Enable multithreading support.]) -AC_DEFINE([TEXTOUT_WORD_LIST], [1], [Enable word list support.]) - -dnl Check for OS specific flags -win32_libs="" -create_shared_lib="" -auto_import_flags="" -case "$host_os" in - cygwin*) - create_shared_lib="-no-undefined" - ;; - mingw*) - os_win32=yes - win32_libs="-lgdi32 -lwinspool -lcomdlg32" - create_shared_lib="-no-undefined" - auto_import_flags="-Wl,--enable-auto-import" - - # Use mingw's ansi stdio extensions - CXXFLAGS="$CXXFLAGS -D__USE_MINGW_ANSI_STDIO=1" - ;; -esac - -AC_SUBST(win32_libs) -AC_SUBST(create_shared_lib) -AC_SUBST(auto_import_flags) - -AX_PTHREAD() - -dnl Install xpdf headers -AC_ARG_ENABLE(xpdf-headers, - AC_HELP_STRING([--enable-xpdf-headers], - [Install unsupported xpdf headers.]), - enable_xpdf_headers=$enableval, - enable_xpdf_headers="no") -AM_CONDITIONAL(ENABLE_XPDF_HEADERS, test x$enable_xpdf_headers = xyes) - -AC_ARG_ENABLE(single-precision, -[ --enable-single-precision use single precision arithmetic (instead of double precision) in the Splash backend], -AC_DEFINE(USE_FLOAT, [1], [Use single precision arithmetic in the Splash backend])) - -AC_ARG_ENABLE(fixedpoint, -[ --enable-fixedpoint use fixed point (instead of double precision) arithmetic in the Splash backend], -AC_DEFINE(USE_FIXEDPOINT, [1], [Use fixed point arithmetic in the Splash backend])) - -dnl Relocation support -AC_ARG_ENABLE(relocatable, - AC_HELP_STRING([--disable-relocatable], - [Hardcode the poppler library location (on Windows).]), - enable_relocatable=$enableval, - [if test x$os_win32 = xyes; then - # default to yes on native Windows. - enable_relocatable="yes" - else - # default to no everywhere else. - enable_relocatable="no" - fi - ] -) - -if test x$enable_relocatable = xyes; then - if test x$os_win32 = xyes; then - AC_DEFINE([ENABLE_RELOCATABLE], - [1],[Do not hardcode the library location]) - else - AC_MSG_ERROR( - [Invalid setting for relocatable, only supported on windows]) - - fi -fi - -dnl ##### Check for installed poppler-data. Use the same datarootdir as default otherwise. -PKG_CHECK_EXISTS(poppler-data, - [POPPLER_DATADIR=`$PKG_CONFIG --variable=poppler_datadir poppler-data` - AC_DEFINE_DIR(POPPLER_DATADIR, "{POPPLER_DATADIR}", [Poppler data dir])], - [AC_DEFINE_DIR(POPPLER_DATADIR, "{datarootdir}/poppler", [Poppler data dir])] - ) - -dnl ##### Checks for header files. -AC_PATH_XTRA -AC_HEADER_DIRENT -AC_CHECK_HEADERS([stdint.h]) - -dnl ##### Switch over to C++. This will make the checks below a little -dnl ##### bit stricter (requiring function prototypes in include files). -dnl ##### (99% of xpdf is written in C++.) -AC_LANG_CPLUSPLUS - -AC_CHECK_DECL(gettimeofday, [AC_CHECK_FUNC(gettimeofday, AC_DEFINE(HAVE_GETTIMEOFDAY, 1, [Defines if gettimeofday is available on your system]))],[],[#include <sys/time.h>]) -AC_CHECK_FUNC(localtime_r, AC_DEFINE(HAVE_LOCALTIME_R, 1, [Defines if localtime_r is available on your system])) -AC_CHECK_FUNC(gmtime_r, AC_DEFINE(HAVE_GMTIME_R, 1, [Defines if gmtime_r is available on your system])) -AC_CHECK_FUNC(rand_r, AC_DEFINE(HAVE_RAND_R, 1, [Defines if rand_r is available on your system])) - -dnl ##### Check for extra libraries needed by X. (LynxOS needs this.) -AC_CHECK_FUNC(gethostbyname) -if test $ac_cv_func_gethostbyname = no; then - AC_CHECK_LIB(bsd, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd") -fi - -AC_CHECK_FUNC(nanosleep,,) -dnl try in librt if not found in current LIBS -if test x$ac_cv_func_nanosleep = xno -then - AC_CHECK_LIB(rt,nanosleep, X_EXTRA_LIBS="$X_EXTRA_LIBS -lrt") -fi - -dnl try in libposix4, if not found so far -if test x$ac_cv_func_nanosleep = xno && test x$ac_cv_lib_rt_nanosleep = xno -then - AC_CHECK_LIB(posix4,nanosleep, X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix4") -fi - - -dnl ##### Test for libopenjpeg. Versions prior to 1.4 do not provide a pkgconfig file. -openjpeg1="no" -openjpeg2="no" -AC_ARG_ENABLE(libopenjpeg, - AC_HELP_STRING([--enable-libopenjpeg=@<:@auto/openjpeg1/openjpeg2/none@:>@], - [Use openjpeg for JPEG2000 images. 'auto' prefers openjpeg1 over openjpeg2 if both are available due to regressions in openjpeg2 [[default=auto]]]), - [enable_libopenjpeg=$enableval], - [enable_libopenjpeg="auto"]) - -openjpeg_header=yes - -dnl test for libopenjpeg1 -if test x$enable_libopenjpeg = xopenjpeg1 || test x$enable_libopenjpeg = xauto; then - PKG_CHECK_MODULES(LIBOPENJPEG, libopenjpeg, - [openjpeg1="yes"], - [AC_CHECK_LIB([openjpeg], [opj_cio_open], - [openjpeg1="yes" - LIBOPENJPEG_LIBS="-lopenjpeg"],[openjpeg_header=no]) - AC_CHECK_HEADERS([openjpeg.h],, - [openjpeg="no"])]) -fi - -dnl test for libopenjpeg2 -if test x$openjpeg1 = xno; then - if test x$enable_libopenjpeg = xopenjpeg2 || test x$enable_libopenjpeg = xauto; then - PKG_CHECK_MODULES(LIBOPENJPEG, libopenjp2, - [openjpeg2=yes],[]) - fi -fi - -if test x$enable_libopenjpeg = xopenjpeg1 && test x$openjpeg1 = xno; then - if test x$openjpeg_header = xno; then - AC_MSG_ERROR("*** libopenjpeg headers not found ***") - else - AC_MSG_ERROR("*** libopenjpeg library not found ***") - fi -fi - -if test x$enable_libopenjpeg = xopenjpeg2 && test x$openjpeg2 = xno; then - AC_MSG_ERROR("*** libopenjp2 library not found ***") -fi - -if test x$openjpeg1 = xyes || test x$openjpeg2 = xyes; then - enable_libopenjpeg=yes - if test x$openjpeg1 = xyes; then - AC_DEFINE(USE_OPENJPEG1, 1, [Defined if using openjpeg1]) - fi - if test x$openjpeg2 = xyes; then - AC_DEFINE(USE_OPENJPEG2, 1, [Defined if using openjpeg2]) - fi - - AC_SUBST(LIBOPENJPEG_CFLAGS) - AC_SUBST(LIBOPENJPEG_LIBS) - AC_DEFINE(ENABLE_LIBOPENJPEG) - PKG_CHECK_EXISTS(libopenjpeg >= 1.5, - [AC_DEFINE(WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG, 1, [OpenJPEG with the OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG flag.])], - [PKG_CHECK_EXISTS(libopenjpeg1 >= 1.5, - [AC_DEFINE(WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG, 1, [OpenJPEG with the OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG flag.])], - []) - ]) -else - enable_libopenjpeg=no -fi - -AM_CONDITIONAL(BUILD_LIBOPENJPEG, test x$openjpeg1 = xyes || test x$openjpeg2 = xyes) -AH_TEMPLATE([ENABLE_LIBOPENJPEG], - [Use libopenjpeg instead of builtin jpeg2000 decoder.]) - -dnl ##### Test for libtiff -AC_ARG_ENABLE(libtiff, - AC_HELP_STRING([--disable-libtiff], - [Don't build against libtiff.]), - enable_libtiff=$enableval, - enable_libtiff="try") - -AC_ARG_VAR([LIBTIFF_CFLAGS], [C compiler flags for LIBTIFF]) -AC_ARG_VAR([LIBTIFF_LIBS], [linker flags to link LIBTIFF (default is -ltiff)]) -ac_save_CPPFLAGS="$CPPFLAGS" -ac_save_CXXFLAGS="$CXXFLAGS" -ac_save_LIBS="$LDFLAGS" -CPPFLAGS="$CPPFLAGS $LIBTIFF_CFLAGS" -CXXFLAGS="$CXXFLAGS $LIBTIFF_CFLAGS" -LIBS="$LIBS $LIBTIFF_LIBS" -if test x$enable_libtiff = xyes; then - if test x"$LIBTIFF_LIBS" != ; then - AC_CHECK_FUNC([TIFFOpen],, - AC_MSG_ERROR("*** libtiff library not found ***")) - else - AC_CHECK_LIB([tiff], [TIFFOpen],, - AC_MSG_ERROR("*** libtiff library not found ***")) - fi - AC_CHECK_HEADERS([tiffio.h],, - AC_MSG_ERROR("*** libtiff headers not found ***")) -elif test x$enable_libtiff = xtry; then - if test x"$LIBTIFF_LIBS" != x; then - AC_CHECK_FUNC([TIFFOpen], - [enable_libtiff="yes"], - [enable_libtiff="no"]) - else - AC_CHECK_LIB([tiff], [TIFFOpen], - [enable_libtiff="yes"], - [enable_libtiff="no"]) - fi - AC_CHECK_HEADERS([tiffio.h],, - [enable_libtiff="no"]) -fi -CPPFLAGS="$ac_save_CPPFLAGS" -CXXFLAGS="$ac_save_CXXFLAGS" -LIBS="$ac_save_LIBS" - -if test x$enable_libtiff = xyes; then - if test x"$LIBTIFF_LIBS" = x; then - LIBTIFF_LIBS="-ltiff" - fi - AC_SUBST(LIBTIFF_CFLAGS) - AC_SUBST(LIBTIFF_LIBS) - AC_DEFINE(ENABLE_LIBTIFF) -fi - -AM_CONDITIONAL(BUILD_LIBTIFF, test x$enable_libtiff = xyes) -AH_TEMPLATE([ENABLE_LIBTIFF], [Build against libtiff.]) -if test x$enable_libtiff = xyes; then - AC_DEFINE(ENABLE_LIBTIFF, 1, [Build against libtiff.]) -fi - -dnl ##### Checks for library functions. -AC_CHECK_FUNCS(popen mkstemp mkstemps) -AC_CHECK_FUNCS(strcpy_s strcat_s) - -dnl ##### Back to C for the library tests. -AC_LANG_C - -dnl ##### Check for fseeko/ftello or fseek64/ftell64 -dnl The LARGEFILE and FSEEKO macros have to be called in C, not C++, mode. -AC_SYS_LARGEFILE -AC_FUNC_FSEEKO -AC_CHECK_FUNCS(fseek64, xpdf_cv_func_fseek64=yes, xpdf_cv_func_fseek64=no) -AC_CHECK_FUNCS(ftell64, xpdf_cv_func_ftell64=yes, xpdf_cv_func_ftell64=no) -if test "$xpdf_cv_func_fseek64" = yes -a "$xpdf_cv_func_ftell64" = yes; then - AC_DEFINE(HAVE_FSEEK64) -fi -AC_CHECK_FUNCS(pread64 lseek64) - -dnl Test for zlib -AC_ARG_ENABLE([zlib], - [AS_HELP_STRING([--enable-zlib],[Build with zlib])], - [],[enable_zlib="no"]) -if test x$enable_zlib = xyes; then - AC_CHECK_LIB([z], [inflate],, - AC_MSG_ERROR("*** zlib library not found ***")) - AC_CHECK_HEADERS([zlib.h],, - AC_MSG_ERROR("*** zlib headers not found ***")) -elif test x$enable_zlib = xtry; then - AC_CHECK_LIB([z], [inflate], - [enable_zlib="yes"], - [enable_zlib="no"]) - AC_CHECK_HEADERS([zlib.h],, - [enable_zlib="no"]) -fi - -if test x$enable_zlib = xyes; then - ZLIB_LIBS="-lz" - AC_SUBST(ZLIB_LIBS) - AC_DEFINE(ENABLE_ZLIB) -fi - -AM_CONDITIONAL(BUILD_ZLIB, test x$enable_zlib = xyes) -AH_TEMPLATE([ENABLE_ZLIB], - [Use zlib instead of builtin zlib decoder.]) - -dnl Test for libcurl -AC_ARG_ENABLE(libcurl, - AC_HELP_STRING([--enable-libcurl], - [Build with libcurl based HTTP support.]), - enable_libcurl=$enableval, - enable_libcurl="no") - -if test x$enable_libcurl = xyes; then - PKG_CHECK_MODULES(LIBCURL, libcurl) - AC_DEFINE(ENABLE_LIBCURL, 1, [Build against libcurl.]) - AC_DEFINE(POPPLER_HAS_CURL_SUPPORT, 1, - [Support for curl based doc builder is compiled in.]) -fi - -AM_CONDITIONAL(BUILD_LIBCURL, test x$enable_libcurl = xyes) - -dnl Test for libjpeg -AC_ARG_ENABLE(libjpeg, - AC_HELP_STRING([--disable-libjpeg], - [Don't build against libjpeg.]), - enable_libjpeg=$enableval, - enable_libjpeg="try") -AC_ARG_VAR([LIBJPEG_CFLAGS], [C compiler flags for LIBJPEG]) -if test x$enable_libjpeg != xno; then - - dnl - dnl POPPLER_FIND_JPEG uses "USER_INCLUDES" and "USER_LIBS" - dnl to receive the flags for header and library directories. - dnl - ac_save_USER_INCLUDES="$USER_INCLUDES" - ac_save_USER_LDFLAGS="$USER_LDFLAGS" - USER_INCLUDES="$USER_INCLUDES $LIBJPEG_CFLAGS" - USER_LDFLAGS="$USER_LDFLAGS $LIBJPEG_CFLAGS" - POPPLER_FIND_JPEG - - dnl check INT16, INT32 typedef conflict in jmorecfg.h - ac_save_CPPFLAGS="$CPPFLAGS" - ac_save_CFLAGS="$CFLAGS" - CPPFLAGS="$CPPFLAGS $LIBJPEG_CFLAGS" - CFLAGS="$CFLAGS $LIBJPEG_CFLAGS" - AC_MSG_CHECKING([libjpeg.h works correctly]) - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([ -#ifdef _WIN32 -#include <windows.h> -#endif -#include <sys/types.h> -#include <stdio.h> -#include <jpeglib.h> -],[{return 0;}])],[ - AC_MSG_RESULT([ok]) - ],[ - AC_MSG_RESULT([no]) - AC_MSG_CHECKING([libjpeg.h problem can be fixed by XMD_H macro]) - CPPFLAGS="$CPPFLAGS -DXMD_H" - CFLAGS="$CFLAGS -DXMD_H" - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([ -#ifdef _WIN32 -#include <windows.h> -#endif -#include <sys/types.h> -#include <stdio.h> -#include <jpeglib.h> -],[{return 0;}])],[ - AC_MSG_RESULT([ok, -DXMD_H is added to LIBJPEG_CFLAGS]) - LIBJPEG_CFLAGS="$LIBJPEG_CFLAGS -DXMD_H" - ],[ - AC_MSG_RESULT([no, disable libjpeg]) - enable_libjpeg="no" - ]) - ]) - CPPFLAGS="$ac_save_CPPFLAGS" - CFLAGS="$ac_save_CFLAGS" - - dnl POPPLER_FIND_JPEG sets LIBJPEG_LIBS - AC_SUBST(LIBJPEG_CFLAGS) - USER_INCLUDES="$ac_save_USER_INCLUDES" - USER_LDFLAGS="$ac_save_USER_LDFLAGS" -fi - -AM_CONDITIONAL(BUILD_LIBJPEG, test x$enable_libjpeg = xyes) -AH_TEMPLATE([ENABLE_LIBJPEG], - [Use libjpeg instead of builtin jpeg decoder.]) - -dnl Test for libpng -AC_ARG_ENABLE(libpng, - AC_HELP_STRING([--disable-libpng], - [Do not build against libpng.]), - enable_libpng=$enableval, - enable_libpng="try") - -if test x$enable_libpng != xno; then - PKG_CHECK_MODULES(LIBPNG, libpng, [enable_libpng="yes"], - [enable_libpng="no"]) -fi - -if test x$enable_libpng = xyes; then - AC_DEFINE(ENABLE_LIBPNG, 1, [Build against libpng.]) -fi - -AM_CONDITIONAL(BUILD_LIBPNG, test x$enable_libpng = xyes) - -dnl Check for freetype headers - -PKG_CHECK_MODULES(FREETYPE, freetype2, - [freetype_pkgconfig=yes], [freetype_pkgconfig=no]) - -if test "x$freetype_pkgconfig" = "xyes"; then - - AC_DEFINE(HAVE_FREETYPE_H, 1, [Have FreeType2 include files]) - -else - - FREETYPE_LIBS= - FREETYPE_CFLAGS= - - AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, no) - if test "x$FREETYPE_CONFIG" != "xno" ; then - - FREETYPE_CFLAGS=`$FREETYPE_CONFIG --cflags` - FREETYPE_LIBS=`$FREETYPE_CONFIG --libs` - AC_DEFINE(HAVE_FREETYPE_H, 1, [Have FreeType2 include files]) - - fi - -fi - -AC_SUBST(FREETYPE_CFLAGS) -AC_SUBST(FREETYPE_LIBS) - -AC_MSG_CHECKING([which font configuration to use]) -AC_ARG_WITH([font_configuration], - [AS_HELP_STRING([--with-font-configuration=fontconfig|win32], - [Select font configuration backend])], - [], - [if test x$os_win32 = xyes; then - # default to win32 on native Windows. - with_font_configuration=win32 - else - # default to fontconig everywhere else. - with_font_configuration=fontconfig - fi - ] -) -AC_MSG_RESULT([$with_font_configuration]) - -case $with_font_configuration in - win32) - AC_DEFINE([WITH_FONTCONFIGURATION_WIN32], - [1],[Use win32 font configuration backend]) - # Set the minimum required Internet Explorer version to 5.0 - CPPFLAGS="$CPPFLAGS -D_WIN32_IE=0x0500" - ;; - fontconfig) - AC_DEFINE([WITH_FONTCONFIGURATION_FONTCONFIG], - [1],[Use fontconfig font configuration backend]) - PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 2.0.0) - ;; - *) - AC_MSG_ERROR( - [Invalid font configuration setting: $with_font_configuration]) - ;; -esac - -AM_CONDITIONAL(BUILD_WITH_WIN32_FONTCONFIGURATION, - test x$with_font_configuration = xwin32) - -AC_ARG_ENABLE(splash-output, - AC_HELP_STRING([--disable-splash-output], - [Don't build the Splash graphics backend.]),, - enable_splash_output="yes") -AM_CONDITIONAL(BUILD_SPLASH_OUTPUT, test x$enable_splash_output = xyes) -AH_TEMPLATE([HAVE_SPLASH], [Use splash for rendering.]) -if test x$enable_splash_output = xyes; then - AC_DEFINE(HAVE_SPLASH) -fi - -CAIRO_VERSION="1.10.0" -AC_SUBST(CAIRO_VERSION) -CAIRO_DEPS="cairo >= $CAIRO_VERSION cairo-ft >= $CAIRO_VERSION" -AC_ARG_ENABLE(cairo-output, - AC_HELP_STRING([--disable-cairo-output], - [Don't build the cairo graphics backend.]), - enable_cairo_output=$enableval, - enable_cairo_output="try") -use_cairo="" -if test x$enable_cairo_output = xyes; then - PKG_CHECK_MODULES(CAIRO, $CAIRO_DEPS) -elif test x$enable_cairo_output = xtry; then - PKG_CHECK_MODULES(CAIRO, $CAIRO_DEPS, - [enable_cairo_output="yes"], - [enable_cairo_output="no" - use_cairo="no (requires cairo >= $CAIRO_VERSION)"]) -fi -if test "x$use_cairo" = "x"; then - use_cairo=$enable_cairo_output -fi - -AC_SUBST(CAIRO_CFLAGS) -AC_SUBST(CAIRO_LIBS) - -AM_CONDITIONAL(BUILD_CAIRO_OUTPUT, test x$enable_cairo_output = xyes) -AH_TEMPLATE([HAVE_CAIRO], [Use cairo for rendering.]) -if test x$enable_cairo_output = xyes; then - PDFTOCAIRO_DEPS="cairo cairo-ft" - dnl Check for optional cairo backends used by pdftocairo - PKG_CHECK_EXISTS(cairo-pdf, [PDFTOCAIRO_DEPS="$PDFTOCAIRO_DEPS cairo-pdf"], []) - PKG_CHECK_EXISTS(cairo-ps, [PDFTOCAIRO_DEPS="$PDFTOCAIRO_DEPS cairo-ps"], []) - PKG_CHECK_EXISTS(cairo-svg, [PDFTOCAIRO_DEPS="$PDFTOCAIRO_DEPS cairo-svg"], []) - - PKG_CHECK_MODULES(PDFTOCAIRO, $PDFTOCAIRO_DEPS) - AC_SUBST(PDFTOCAIRO_CFLAGS) - AC_SUBST(PDFTOCAIRO_LIBS) - - AC_DEFINE(HAVE_CAIRO) - CAIRO_FEATURE="#define POPPLER_HAS_CAIRO 1" - CAIRO_REQ="cairo" - AC_CHECK_HEADERS(fcntl.h sys/mman.h sys/stat.h) -else - CAIRO_FEATURE="#undef POPPLER_HAS_CAIRO" - CAIRO_REQ="" -fi -AC_SUBST(CAIRO_FEATURE) -AC_SUBST(CAIRO_REQ) - -use_glib="" -found_introspection=no -if test x$enable_cairo_output = xyes; then - POPPLER_GLIB_DISABLE_DEPRECATED="" - POPPLER_GLIB_DISABLE_SINGLE_INCLUDES="" - - GLIB_REQUIRED=2.18 - AC_SUBST(GLIB_REQUIRED) - AC_ARG_ENABLE(poppler-glib, - AC_HELP_STRING([--disable-poppler-glib], - [Don't compile poppler glib wrapper.]), - enable_poppler_glib=$enableval, - enable_poppler_glib="try") - if test x$enable_poppler_glib = xyes; then - PKG_CHECK_MODULES(POPPLER_GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED cairo >= $CAIRO_VERSION) - elif test x$enable_poppler_glib = xtry; then - PKG_CHECK_MODULES(POPPLER_GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED cairo >= $CAIRO_VERSION, - [enable_poppler_glib="yes"], - [enable_poppler_glib="no" - use_glib="no (requires glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED cairo >= $CAIRO_VERSION)"]) - fi - if test x$enable_poppler_glib = xyes; then - # Check for introspection - GOBJECT_INTROSPECTION_CHECK([0.6.7]) - - AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums]) - POPPLER_GLIB_DISABLE_DEPRECATED="$POPPLER_GLIB_DISABLE_DEPRECATED -DG_DISABLE_DEPRECATED" - POPPLER_GLIB_DISABLE_SINGLE_INCLUDES="$POPPLER_GLIB_DISABLE_SINGLE_INCLUDES -DG_DISABLE_SINGLE_INCLUDES" - fi -else - if test x$enable_poppler_glib = xyes; then - AC_MSG_ERROR("Cairo output is required to build glib frontend") - fi - use_glib="no (requires cairo output)" - enable_poppler_glib="no" -fi -if test x"$use_glib" = x; then - use_glib="$enable_poppler_glib" -fi -AM_CONDITIONAL(BUILD_POPPLER_GLIB, test x$enable_poppler_glib = xyes) -AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes") -AC_SUBST(GLIB_REQ) -AC_SUBST(POPPLER_GLIB_DISABLE_DEPRECATED) -AC_SUBST(POPPLER_GLIB_DISABLE_SINGLE_INCLUDES) - -GTK_DOC_CHECK([1.14],[--flavour no-tmpl]) - -dnl -dnl Try Qt4 -dnl - -AC_ARG_ENABLE(poppler-qt4, - AC_HELP_STRING([--disable-poppler-qt4], - [Don't compile poppler Qt4 wrapper.]), - enable_poppler_qt4=$enableval, - enable_poppler_qt4="try") -if test x$enable_poppler_qt4 = xyes; then - PKG_CHECK_MODULES(POPPLER_QT4, - QtCore >= 4.7.0 QtGui >= 4.7.0 QtXml >= 4.7.0) - PKG_CHECK_MODULES(POPPLER_QT4_TEST, - QtTest >= 4.7.0) -elif test x$enable_poppler_qt4 = xtry; then - PKG_CHECK_MODULES(POPPLER_QT4, - QtCore >= 4.7.0 QtGui >= 4.7.0 QtXml >= 4.7.0, - [enable_poppler_qt4="yes"], - [enable_poppler_qt4="no"]) - if test x$enable_poppler_qt4 = xyes; then - PKG_CHECK_MODULES(POPPLER_QT4_TEST, - QtTest >= 4.7.0, - [enable_poppler_qt4="yes"], - [enable_poppler_qt4="no"]) - fi -fi - -AC_SUBST(POPPLER_QT4_CXXFLAGS) -AC_SUBST(POPPLER_QT4_LIBS) -AC_SUBST(POPPLER_QT4_TEST_LIBS) - -if test x$enable_poppler_qt4 = xyes; then - AC_CHECK_TOOL(MOCQT4, moc) - AC_MSG_CHECKING([for Qt4 moc]) - mocversion=`$MOCQT4 -v 2>&1` - mocversiongrep=`echo $mocversion | grep "Qt 4"` - if test x"$mocversiongrep" != x"$mocversion"; then - AC_MSG_RESULT([no]) - # moc was not the qt4 one, try with moc-qt4 - AC_CHECK_TOOL(MOCQT42, moc-qt4) - AC_MSG_CHECKING([for Qt4 moc-qt4]) - mocversion=`$MOCQT42 -v 2>&1` - mocversiongrep=`echo $mocversion | grep "Qt 4"` - if test x"$mocversiongrep" != x"$mocversion"; then - # no valid moc found - enable_poppler_qt4=no; - MOCQT4="not found" - else - MOCQT4=$MOCQT42 - fi - fi - AC_SUBST(MOCQT4) - AC_MSG_RESULT([$MOCQT4]) -fi - -AM_CONDITIONAL(BUILD_POPPLER_QT4, test "x$enable_poppler_qt4" = "xyes") - -dnl -dnl Try Qt5 -dnl - -AC_ARG_ENABLE(poppler-qt5, - AC_HELP_STRING([--disable-poppler-qt5], - [Don't compile poppler Qt5 wrapper.]), - enable_poppler_qt5=$enableval, - enable_poppler_qt5="try") -if test x$enable_poppler_qt5 = xyes; then - PKG_CHECK_MODULES(POPPLER_QT5, - Qt5Core >= 5.0.0 Qt5Gui >= 5.0.0 Qt5Xml >= 5.0.0 Qt5Widgets >= 5.0.0) - PKG_CHECK_MODULES(POPPLER_QT5_TEST, - Qt5Test >= 5.0.0 ) -elif test x$enable_poppler_qt5 = xtry; then - PKG_CHECK_MODULES(POPPLER_QT5, - Qt5Core >= 5.0.0 Qt5Gui >= 5.0.0 Qt5Xml >= 5.0.0 Qt5Widgets >= 5.0.0, - [enable_poppler_qt5="yes"], - [enable_poppler_qt5="no"]) - if test x$enable_poppler_qt5 = xyes; then - PKG_CHECK_MODULES(POPPLER_QT5_TEST, - Qt5Test >= 5.0.0, - [enable_poppler_qt5="yes"], - [enable_poppler_qt5="no"]) - fi -fi - -AC_SUBST(POPPLER_QT5_CXXFLAGS) -AC_SUBST(POPPLER_QT5_LIBS) -AC_SUBST(POPPLER_QT5_TEST_LIBS) - -if test x$enable_poppler_qt5 = xyes; then - AC_CHECK_TOOL(MOCQT5, moc) - AC_MSG_CHECKING([for Qt5 moc]) - mocversion=`$MOCQT5 -v 2>&1` - mocversiongrep=`echo $mocversion | grep "Qt 5\|moc 5"` - if test x"$mocversiongrep" != x"$mocversion"; then - AC_MSG_RESULT([no]) - # moc was not the qt5 one, try with moc-qt5 - AC_CHECK_TOOL(MOCQT52, moc-qt5) - AC_MSG_CHECKING([for Qt5 moc-qt5]) - mocversion=`$MOCQT52 -v 2>&1` - mocversiongrep=`echo $mocversion | grep "Qt 5\|moc-qt5 5\|moc 5"` - if test x"$mocversiongrep" != x"$mocversion"; then - AC_CHECK_TOOL(QTCHOOSER, qtchooser) - AC_MSG_CHECKING([for qtchooser]) - qt5tooldir=`QT_SELECT=qt5 qtchooser -print-env | grep QTTOOLDIR | cut -d '=' -f 2 | cut -d \" -f 2` - mocversion=`$qt5tooldir/moc -v 2>&1` - mocversiongrep=`echo $mocversion | grep "Qt 5\|moc 5"` - if test x"$mocversiongrep" != x"$mocversion"; then - # no valid moc found - enable_poppler_qt5=no; - MOCQT5="not found" - else - MOCQT5=$qt5tooldir/moc - fi - else - MOCQT5=$MOCQT52 - fi - fi - AC_SUBST(MOCQT5) - AC_MSG_RESULT([$MOCQT5]) -fi - -AM_CONDITIONAL(BUILD_POPPLER_QT5, test "x$enable_poppler_qt5" = "xyes") - -dnl -dnl CPP frontend -dnl - -AC_ARG_ENABLE(poppler-cpp, - AC_HELP_STRING([--disable-poppler-cpp], - [Don't compile poppler cpp wrapper.]), - enable_poppler_cpp=$enableval, - enable_poppler_cpp="yes") -if test x$enable_poppler_cpp = xyes; then - AM_ICONV() - if test x$am_func_iconv != xyes; then - enable_poppler_cpp=no - fi -fi - -AM_CONDITIONAL(BUILD_POPPLER_CPP, test "x$enable_poppler_cpp" = "xyes") - - -GTK_TEST_DEPS='gtk+-3.0 >= 3.8 gdk-pixbuf-2.0' -if test x$enable_cairo_output = xyes; then - GTK_TEST_DEPS="$GTK_TEST_DEPS $CAIRO_DEPS" -fi -AC_ARG_ENABLE(gtk-test, - AC_HELP_STRING([--disable-gtk-test], - [Don't compile GTK+ test program.]), - enable_gtk_test=$enableval, - enable_gtk_test="try") -if test x$enable_gtk_test = xyes; then - PKG_CHECK_MODULES(GTK_TEST, $GTK_TEST_DEPS) -elif test x$enable_gtk_test = xtry; then - PKG_CHECK_MODULES(GTK_TEST, $GTK_TEST_DEPS, - [enable_gtk_test="yes"], - [enable_gtk_test="no"]) -fi -AM_CONDITIONAL(BUILD_GTK_TEST, test x$enable_gtk_test = xyes -a x$enable_poppler_glib = xyes) - -AC_ARG_ENABLE(utils, - AC_HELP_STRING([--disable-utils], - [Don't compile poppler command line utils.]), - enable_utils=$enableval, - enable_utils="yes") -AM_CONDITIONAL(BUILD_UTILS, test x$enable_utils = xyes) - -AC_ARG_ENABLE(compile-warnings, - AC_HELP_STRING([--enable-compile-warnings=@<:@no/yes/kde@:>@], - [Turn on compiler warnings.]),, - [enable_compile_warnings="yes"]) - -dnl -dnl Color Management -dnl - -AC_ARG_ENABLE(cms, - AC_HELP_STRING([--enable-cms=@<:@auto/lcms1/lcms2/none@:>@], - [Use color management system. 'auto' prefers lcms2 over lcms1 if both are available [[default=auto]]]), - [enable_cms=$enableval], - [enable_cms="auto"]) -if test x$enable_cms = xauto; then - PKG_CHECK_MODULES(LCMS, lcms2, [lcms2=yes], [lcms2=no]) - if test x$lcms2 = xno; then - PKG_CHECK_MODULES(LCMS, lcms, [lcms1=yes], [lcms1=no]) - fi -elif test x$enable_cms = xlcms1; then - PKG_CHECK_MODULES(LCMS, lcms, [lcms1=yes], [lcms1=no]) -elif test x$enable_cms = xlcms2; then - PKG_CHECK_MODULES(LCMS, lcms2, [lcms2=yes], [lcms2=no]) -fi - -if test x$lcms1 = xyes || test x$lcms2 = xyes; then - enable_cms=yes - AC_DEFINE(USE_CMS, 1, [Defines if use cms]) - if test x$lcms1 = xyes; then - lcms1=yes; - AC_DEFINE(USE_LCMS1, 1, [Defines if use lcms1]) - fi -else - enable_cms=no -fi - -AM_CONDITIONAL(USE_CMS, test x$enable_cms = xyes) -AM_CONDITIONAL(USE_LCMS1, test x$lcms1 = xyes) - -AC_ARG_WITH([testdatadir], - [AS_HELP_STRING([--with-testdatadir=/path/to/testdatadir], - [Specify test data dir])], - [case $withval in - [[\\/]]* | ?:[[\\/]]* ) # Absolute name. - TESTDATADIR=$withval ;; - *) # Relative name. - TESTDATADIR=$ac_pwd/$withval ;; - esac - ], - [case $srcdir in - [[\\/]]* | ?:[[\\/]]* ) # Absolute name. - TESTDATADIR=$srcdir/../test ;; - *) # Relative name. - TESTDATADIR=$ac_pwd/$srcdir/../test ;; - esac - ] -) -AC_MSG_CHECKING([for test data in $TESTDATADIR]) -if test -d $TESTDATADIR && test -f $TESTDATADIR/test-poppler.c; then - AC_MSG_RESULT([yes]) -else - AC_MSG_RESULT([no]) - AC_MSG_WARN([ - No test data found in $TESTDATADIR. - You will not be able to run 'make check' successfully. - - The test data is not included in the source packages - and is also not part of the main git repository. Instead, - you can checkout the test data from its own git - repository with: - - git clone git://git.freedesktop.org/git/poppler/test - - You should checkout the test data as a sibling of your - poppler source folder or specify the location of your - checkout with --with-testdatadir=/path/to/checkoutdir/test. -]) -fi -AC_SUBST(TESTDATADIR) - -# some compilers do not support this flag (see bug #76963) -fno_check_new= -AC_MSG_CHECKING([for -fno-check-new compiler flag]) -AC_LANG_PUSH([C++]) -saved_CXXFLAGS=$CXXFLAGS -CXXFLAGS="-fno-check-new $CXXFLAGS" -AC_TRY_COMPILE([], [], - [AC_MSG_RESULT([yes]) - fno_check_new="-fno-check-new"], - AC_MSG_RESULT([no]) -) -CXXFLAGS=$saved_CXXFLAGS -AC_LANG_POP - -if test "x$GCC" != xyes; then - enable_compile_warnings=no -fi -case "$enable_compile_warnings" in - no) ;; - yes) CXXFLAGS="-Wall -Woverloaded-virtual -Wnon-virtual-dtor -Wcast-align -fno-exceptions $fno_check_new -fno-common $CXXFLAGS"; - CFLAGS="-Wall $CFLAGS" ;; - kde) CXXFLAGS="-Wnon-virtual-dtor -Wno-long-long -Wundef \ - -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -Wcast-align \ - -Wconversion -Wall -W -Wpointer-arith \ - -Wwrite-strings -O2 -Wformat-security \ - -Wmissing-format-attribute -fno-exceptions $fno_check_new \ - -fno-common $CXXFLAGS" ;; -esac - -case "$host_os" in - mingw*) - # mingw prints "warning: -fPIC ignored for target (all code is position independent)" - # for every file - ;; - *) - CXXFLAGS="-fPIC $CXXFLAGS"; - ;; -esac - - -case `$PKG_CONFIG --version` in - 0.?|0.1[0-7]) - PC_REQUIRES_PRIVATE=""; - PC_REQUIRES="poppler = $VERSION";; - *) - PC_REQUIRES_PRIVATE="Requires.private: poppler = $VERSION"; - PC_REQUIRES="";; -esac - -AC_SUBST(PC_REQUIRES) -AC_SUBST(PC_REQUIRES_PRIVATE) - -AC_SUBST([POPPLER_MAJOR_VERSION],[poppler_version_major]) -AC_SUBST([POPPLER_MINOR_VERSION],[poppler_version_minor]) -AC_SUBST([POPPLER_MICRO_VERSION],[poppler_version_micro]) -AC_SUBST([POPPLER_VERSION],[poppler_version]) - -AC_OUTPUT([ -Makefile -goo/Makefile -fofi/Makefile -splash/Makefile -poppler/Makefile -utils/Makefile -glib/Makefile -glib/poppler-features.h -glib/reference/Makefile -glib/reference/version.xml -glib/demo/Makefile -test/Makefile -qt4/Makefile -qt4/src/Makefile -qt4/tests/Makefile -qt4/demos/Makefile -qt5/Makefile -qt5/src/Makefile -qt5/tests/Makefile -qt5/demos/Makefile -cpp/Makefile -cpp/poppler-version.h -cpp/tests/Makefile -poppler.pc -poppler-uninstalled.pc -poppler-cairo.pc -poppler-cairo-uninstalled.pc -poppler-splash.pc -poppler-splash-uninstalled.pc -poppler-glib.pc -poppler-glib-uninstalled.pc -poppler-qt4.pc -poppler-qt4-uninstalled.pc -poppler-qt5.pc -poppler-qt5-uninstalled.pc -poppler-cpp.pc -poppler-cpp-uninstalled.pc]) - - -echo "" -echo "Building poppler with support for:" -echo " font configuration: $with_font_configuration" -echo " splash output: $enable_splash_output" -echo " cairo output: $use_cairo" -echo " qt4 wrapper: $enable_poppler_qt4" -echo " qt5 wrapper: $enable_poppler_qt5" -echo " glib wrapper: $use_glib" -echo " introspection: $found_introspection" -echo " cpp wrapper: $enable_poppler_cpp" -echo " use gtk-doc: $enable_gtk_doc" -echo " use libjpeg: $enable_libjpeg" -echo " use libpng: $enable_libpng" -echo " use libtiff: $enable_libtiff" -echo " use zlib: $enable_zlib" -echo " use libcurl: $enable_libcurl" -echo " use libopenjpeg: $enable_libopenjpeg" -if test x$enable_libopenjpeg = xyes;then - if test x$openjpeg1 = xyes;then - echo " with openjpeg1" - else - echo " with openjpeg2" - fi -fi -echo " use cms: $enable_cms" -if test x$enable_cms = xyes;then - if test x$lcms1 = xyes;then - echo " with lcms1" - else - echo " with lcms2" - fi -fi -echo " command line utils: $enable_utils" -echo " test data dir: $TESTDATADIR" -echo "" - -if test x$enable_splash_output = xno -a x$enable_cairo_output = xno; then - echo " Warning: There is no rendering backend enabled" -fi - -if test x$enable_single_precision = xyes -a x$enable_fixedpoint = xyes; then - echo " Warning: Single precision and fixed point options should not be enabled at the same time" -fi - -if test x$enable_libjpeg != xyes; then - echo " Warning: Using libjpeg is recommended" -fi - -if test x$enable_zlib != xno; then - echo " Warning: Using zlib is not totally safe" -fi - -if test x$enable_libopenjpeg != xyes; then - echo " Warning: Using libopenjpeg is recommended" -fi diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Annot.cc b/source/libs/poppler/poppler-0.32.0/poppler/Annot.cc deleted file mode 100755 index d7769a0f6..000000000 --- a/source/libs/poppler/poppler-0.32.0/poppler/Annot.cc +++ /dev/null @@ -1,6850 +0,0 @@ -//======================================================================== -// -// Annot.cc -// -// Copyright 2000-2003 Glyph & Cog, LLC -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2006 Scott Turner <scotty1024@mac.com> -// Copyright (C) 2007, 2008 Julien Rebetez <julienr@svn.gnome.org> -// Copyright (C) 2007-2013 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2007-2013 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright (C) 2007, 2008 Iñigo Martínez <inigomartinez@gmail.com> -// Copyright (C) 2007 Jeff Muizelaar <jeff@infidigm.net> -// Copyright (C) 2008, 2011 Pino Toscano <pino@kde.org> -// Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu> -// Copyright (C) 2008 Hugo Mercier <hmercier31@gmail.com> -// Copyright (C) 2009 Ilya Gorenbein <igorenbein@finjan.com> -// Copyright (C) 2011, 2013 José Aliste <jaliste@src.gnome.org> -// Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it> -// Copyright (C) 2012, 2013 Thomas Freitag <Thomas.Freitag@alfa.de> -// Copyright (C) 2012 Tobias Koenig <tokoe@kdab.com> -// Copyright (C) 2013 Peter Breitenlohner <peb@mppmu.mpg.de> -// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> -// Copyright (C) 2014 Marek Kasik <mkasik@redhat.com> -// Copyright (C) 2014 Jiri Slaby <jirislaby@gmail.com> -// Copyright (C) 2014 Anuj Khare <khareanuj18@gmail.com> -// Copyright (C) 2015 Petr Gajdos <pgajdos@suse.cz> -// -// To see a description of the changes please see the Changelog file that -// came with your tarball or type make ChangeLog if you are building from git -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <stdlib.h> -#include <math.h> -#include <assert.h> -#include "goo/gmem.h" -#include "goo/gstrtod.h" -#include "GooList.h" -#include "Error.h" -#include "Object.h" -#include "Catalog.h" -#include "Gfx.h" -#include "Lexer.h" -#include "PDFDoc.h" -#include "Page.h" -#include "Annot.h" -#include "GfxFont.h" -#include "CharCodeToUnicode.h" -#include "PDFDocEncoding.h" -#include "Form.h" -#include "Error.h" -#include "XRef.h" -#include "Movie.h" -#include "OptionalContent.h" -#include "Sound.h" -#include "FileSpec.h" -#include "DateInfo.h" -#include "Link.h" -#include <string.h> - -#if MULTITHREADED -# define annotLocker() MutexLocker locker(&mutex) -# define annotCondLocker(X) MutexLocker locker(&mutex, (X)) -#else -# define annotLocker() -# define annotCondLocker(X) -#endif - -#define fieldFlagReadOnly 0x00000001 -#define fieldFlagRequired 0x00000002 -#define fieldFlagNoExport 0x00000004 -#define fieldFlagMultiline 0x00001000 -#define fieldFlagPassword 0x00002000 -#define fieldFlagNoToggleToOff 0x00004000 -#define fieldFlagRadio 0x00008000 -#define fieldFlagPushbutton 0x00010000 -#define fieldFlagCombo 0x00020000 -#define fieldFlagEdit 0x00040000 -#define fieldFlagSort 0x00080000 -#define fieldFlagFileSelect 0x00100000 -#define fieldFlagMultiSelect 0x00200000 -#define fieldFlagDoNotSpellCheck 0x00400000 -#define fieldFlagDoNotScroll 0x00800000 -#define fieldFlagComb 0x01000000 -#define fieldFlagRichText 0x02000000 -#define fieldFlagRadiosInUnison 0x02000000 -#define fieldFlagCommitOnSelChange 0x04000000 - -#define fieldQuadLeft 0 -#define fieldQuadCenter 1 -#define fieldQuadRight 2 - -// distance of Bezier control point from center for circle approximation -// = (4 * (sqrt(2) - 1) / 3) * r -#define bezierCircle 0.55228475 - -AnnotLineEndingStyle parseAnnotLineEndingStyle(GooString *string) { - if (string != NULL) { - if (!string->cmp("Square")) { - return annotLineEndingSquare; - } else if (!string->cmp("Circle")) { - return annotLineEndingCircle; - } else if (!string->cmp("Diamond")) { - return annotLineEndingDiamond; - } else if (!string->cmp("OpenArrow")) { - return annotLineEndingOpenArrow; - } else if (!string->cmp("ClosedArrow")) { - return annotLineEndingClosedArrow; - } else if (!string->cmp("Butt")) { - return annotLineEndingButt; - } else if (!string->cmp("ROpenArrow")) { - return annotLineEndingROpenArrow; - } else if (!string->cmp("RClosedArrow")) { - return annotLineEndingRClosedArrow; - } else if (!string->cmp("Slash")) { - return annotLineEndingSlash; - } else { - return annotLineEndingNone; - } - } else { - return annotLineEndingNone; - } -} - -const char* convertAnnotLineEndingStyle(AnnotLineEndingStyle style) { - switch (style) { - case annotLineEndingSquare: - return "Square"; - case annotLineEndingCircle: - return "Circle"; - case annotLineEndingDiamond: - return "Diamond"; - case annotLineEndingOpenArrow: - return "OpenArrow"; - case annotLineEndingClosedArrow: - return "ClosedArrow"; - case annotLineEndingButt: - return "Butt"; - case annotLineEndingROpenArrow: - return "ROpenArrow"; - case annotLineEndingRClosedArrow: - return "RClosedArrow"; - case annotLineEndingSlash: - return "Slash"; - default: - return "None"; - } -} - -static AnnotExternalDataType parseAnnotExternalData(Dict* dict) { - Object obj1; - AnnotExternalDataType type; - - if (dict->lookup("Subtype", &obj1)->isName()) { - const char *typeName = obj1.getName(); - - if (!strcmp(typeName, "Markup3D")) { - type = annotExternalDataMarkup3D; - } else { - type = annotExternalDataMarkupUnknown; - } - } else { - type = annotExternalDataMarkupUnknown; - } - obj1.free(); - - return type; -} - -PDFRectangle *parseDiffRectangle(Array *array, PDFRectangle *rect) { - PDFRectangle *newRect = NULL; - if (array->getLength() == 4) { - // deltas - Object obj1; - double dx1 = (array->get(0, &obj1)->isNum() ? obj1.getNum() : 0); - obj1.free(); - double dy1 = (array->get(1, &obj1)->isNum() ? obj1.getNum() : 0); - obj1.free(); - double dx2 = (array->get(2, &obj1)->isNum() ? obj1.getNum() : 0); - obj1.free(); - double dy2 = (array->get(3, &obj1)->isNum() ? obj1.getNum() : 0); - obj1.free(); - - // checking that the numbers are valid (i.e. >= 0), - // and that applying the differences still give us a valid rect - if (dx1 >= 0 && dy1 >= 0 && dx2 >= 0 && dy2 - && (rect->x2 - rect->x1 - dx1 - dx2) >= 0 - && (rect->y2 - rect->y1 - dy1 - dy2) >= 0) { - newRect = new PDFRectangle(); - newRect->x1 = rect->x1 + dx1; - newRect->y1 = rect->y1 + dy1; - newRect->x2 = rect->x2 - dx2; - newRect->y2 = rect->y2 - dy2; - } - } - return newRect; -} - -static LinkAction* getAdditionalAction(Annot::AdditionalActionsType type, Object *additionalActions, PDFDoc *doc) { - Object additionalActionsObject; - LinkAction *linkAction = NULL; - - if (additionalActions->fetch(doc->getXRef(), &additionalActionsObject)->isDict()) { - const char *key = (type == Annot::actionCursorEntering ? "E" : - type == Annot::actionCursorLeaving ? "X" : - type == Annot::actionMousePressed ? "D" : - type == Annot::actionMouseReleased ? "U" : - type == Annot::actionFocusIn ? "Fo" : - type == Annot::actionFocusOut ? "BI" : - type == Annot::actionPageOpening ? "PO" : - type == Annot::actionPageClosing ? "PC" : - type == Annot::actionPageVisible ? "PV" : - type == Annot::actionPageInvisible ? "PI" : NULL); - - Object actionObject; - - if (additionalActionsObject.dictLookup(key, &actionObject)->isDict()) - linkAction = LinkAction::parseAction(&actionObject, doc->getCatalog()->getBaseURI()); - actionObject.free(); - } - - additionalActionsObject.free(); - - return linkAction; -} - -static LinkAction* getFormAdditionalAction(Annot::FormAdditionalActionsType type, Object *additionalActions, PDFDoc *doc) { - Object additionalActionsObject; - LinkAction *linkAction = NULL; - - if (additionalActions->fetch(doc->getXRef(), &additionalActionsObject)->isDict()) { - const char *key = (type == Annot::actionFieldModified ? "K" : - type == Annot::actionFormatField ? "F" : - type == Annot::actionValidateField ? "V" : - type == Annot::actionCalculateField ? "C" : NULL); - - Object actionObject; - - if (additionalActionsObject.dictLookup(key, &actionObject)->isDict()) - linkAction = LinkAction::parseAction(&actionObject, doc->getCatalog()->getBaseURI()); - actionObject.free(); - } - - additionalActionsObject.free(); - - return linkAction; -} - -//------------------------------------------------------------------------ -// AnnotBorderEffect -//------------------------------------------------------------------------ - -AnnotBorderEffect::AnnotBorderEffect(Dict *dict) { - Object obj1; - - if (dict->lookup("S", &obj1)->isName()) { - const char *effectName = obj1.getName(); - - if (!strcmp(effectName, "C")) - effectType = borderEffectCloudy; - else - effectType = borderEffectNoEffect; - } else { - effectType = borderEffectNoEffect; - } - obj1.free(); - - if ((dict->lookup("I", &obj1)->isNum()) && effectType == borderEffectCloudy) { - intensity = obj1.getNum(); - } else { - intensity = 0; - } - obj1.free(); -} - -//------------------------------------------------------------------------ -// AnnotPath -//------------------------------------------------------------------------ - -AnnotPath::AnnotPath() { - coords = NULL; - coordsLength = 0; -} - -AnnotPath::AnnotPath(Array *array) { - coords = NULL; - coordsLength = 0; - parsePathArray(array); -} - -AnnotPath::AnnotPath(AnnotCoord **coords, int coordsLength) { - this->coords = coords; - this->coordsLength = coordsLength; -} - -AnnotPath::~AnnotPath() { - if (coords) { - for (int i = 0; i < coordsLength; ++i) - delete coords[i]; - gfree(coords); - } -} - -double AnnotPath::getX(int coord) const { - if (coord >= 0 && coord < coordsLength) - return coords[coord]->getX(); - return 0; -} - -double AnnotPath::getY(int coord) const { - if (coord >= 0 && coord < coordsLength) - return coords[coord]->getY(); - return 0; -} - -AnnotCoord *AnnotPath::getCoord(int coord) const { - if (coord >= 0 && coord < coordsLength) - return coords[coord]; - return NULL; -} - -void AnnotPath::parsePathArray(Array *array) { - int tempLength; - AnnotCoord **tempCoords; - GBool correct = gTrue; - - if (array->getLength() % 2) { - error(errSyntaxError, -1, "Bad Annot Path"); - return; - } - - tempLength = array->getLength() / 2; - tempCoords = (AnnotCoord **) gmallocn (tempLength, sizeof(AnnotCoord *)); - memset(tempCoords, 0, tempLength * sizeof(AnnotCoord *)); - for (int i = 0; i < tempLength && correct; i++) { - Object obj1; - double x = 0, y = 0; - - if (array->get(i * 2, &obj1)->isNum()) { - x = obj1.getNum(); - } else { - correct = gFalse; - } - obj1.free(); - - if (array->get((i * 2) + 1, &obj1)->isNum()) { - y = obj1.getNum(); - } else { - correct = gFalse; - } - obj1.free(); - - if (!correct) { - for (int j = i - 1; j >= 0; j--) - delete tempCoords[j]; - gfree (tempCoords); - return; - } - - tempCoords[i] = new AnnotCoord(x, y); - } - - coords = tempCoords; - coordsLength = tempLength; -} - -//------------------------------------------------------------------------ -// AnnotCalloutLine -//------------------------------------------------------------------------ - -AnnotCalloutLine::AnnotCalloutLine(double x1, double y1, double x2, double y2) - : coord1(x1, y1), coord2(x2, y2) { -} - -//------------------------------------------------------------------------ -// AnnotCalloutMultiLine -//------------------------------------------------------------------------ - -AnnotCalloutMultiLine::AnnotCalloutMultiLine(double x1, double y1, double x2, - double y2, double x3, double y3) - : AnnotCalloutLine(x1, y1, x2, y2), coord3(x3, y3) { -} - -//------------------------------------------------------------------------ -// AnnotQuadrilateral -//------------------------------------------------------------------------ - -AnnotQuadrilaterals::AnnotQuadrilaterals(Array *array, PDFRectangle *rect) { - int arrayLength = array->getLength(); - GBool correct = gTrue; - int quadsLength = 0; - AnnotQuadrilateral **quads; - double quadArray[8]; - - // default values - quadrilaterals = NULL; - quadrilateralsLength = 0; - - if ((arrayLength % 8) == 0) { - int i; - - quadsLength = arrayLength / 8; - quads = (AnnotQuadrilateral **) gmallocn - ((quadsLength), sizeof(AnnotQuadrilateral *)); - memset(quads, 0, quadsLength * sizeof(AnnotQuadrilateral *)); - - for (i = 0; i < quadsLength; i++) { - for (int j = 0; j < 8; j++) { - Object obj; - if (array->get(i * 8 + j, &obj)->isNum()) { - quadArray[j] = obj.getNum(); - } else { - correct = gFalse; - obj.free(); - error (errSyntaxError, -1, "Invalid QuadPoint in annot"); - break; - } - obj.free(); - } - - if (!correct) - break; - - quads[i] = new AnnotQuadrilateral(quadArray[0], quadArray[1], - quadArray[2], quadArray[3], - quadArray[4], quadArray[5], - quadArray[6], quadArray[7]); - } - - if (correct) { - quadrilateralsLength = quadsLength; - quadrilaterals = quads; - } else { - for (int j = 0; j < i; j++) - delete quads[j]; - gfree (quads); - } - } -} - -AnnotQuadrilaterals::AnnotQuadrilaterals(AnnotQuadrilaterals::AnnotQuadrilateral **quads, int quadsLength) { - quadrilaterals = quads; - quadrilateralsLength = quadsLength; -} - -AnnotQuadrilaterals::~AnnotQuadrilaterals() { - if (quadrilaterals) { - for(int i = 0; i < quadrilateralsLength; i++) - delete quadrilaterals[i]; - - gfree (quadrilaterals); - } -} - -double AnnotQuadrilaterals::getX1(int quadrilateral) { - if (quadrilateral >= 0 && quadrilateral < quadrilateralsLength) - return quadrilaterals[quadrilateral]->coord1.getX(); - return 0; -} - -double AnnotQuadrilaterals::getY1(int quadrilateral) { - if (quadrilateral >= 0 && quadrilateral < quadrilateralsLength) - return quadrilaterals[quadrilateral]->coord1.getY(); - return 0; -} - -double AnnotQuadrilaterals::getX2(int quadrilateral) { - if (quadrilateral >= 0 && quadrilateral < quadrilateralsLength) - return quadrilaterals[quadrilateral]->coord2.getX(); - return 0; -} - -double AnnotQuadrilaterals::getY2(int quadrilateral) { - if (quadrilateral >= 0 && quadrilateral < quadrilateralsLength) - return quadrilaterals[quadrilateral]->coord2.getY(); - return 0; -} - -double AnnotQuadrilaterals::getX3(int quadrilateral) { - if (quadrilateral >= 0 && quadrilateral < quadrilateralsLength) - return quadrilaterals[quadrilateral]->coord3.getX(); - return 0; -} - -double AnnotQuadrilaterals::getY3(int quadrilateral) { - if (quadrilateral >= 0 && quadrilateral < quadrilateralsLength) - return quadrilaterals[quadrilateral]->coord3.getY(); - return 0; -} - -double AnnotQuadrilaterals::getX4(int quadrilateral) { - if (quadrilateral >= 0 && quadrilateral < quadrilateralsLength) - return quadrilaterals[quadrilateral]->coord4.getX(); - return 0; -} - -double AnnotQuadrilaterals::getY4(int quadrilateral) { - if (quadrilateral >= 0 && quadrilateral < quadrilateralsLength) - return quadrilaterals[quadrilateral]->coord4.getY(); - return 0; -} - -AnnotQuadrilaterals::AnnotQuadrilateral::AnnotQuadrilateral(double x1, double y1, - double x2, double y2, double x3, double y3, double x4, double y4) - : coord1(x1, y1), coord2(x2, y2), coord3(x3, y3), coord4(x4, y4) { -} - -//------------------------------------------------------------------------ -// AnnotBorder -//------------------------------------------------------------------------ -AnnotBorder::AnnotBorder() { - width = 1; - dashLength = 0; - dash = NULL; - style = borderSolid; -} - -GBool AnnotBorder::parseDashArray(Object *dashObj) { - GBool correct = gTrue; - int tempLength = dashObj->arrayGetLength(); - double *tempDash = (double *) gmallocn (tempLength, sizeof (double)); - - // TODO: check not all zero (Line Dash Pattern Page 217 PDF 8.1) - for (int i = 0; i < tempLength && i < DASH_LIMIT && correct; i++) { - Object obj1; - - if (dashObj->arrayGet(i, &obj1)->isNum()) { - tempDash[i] = obj1.getNum(); - - correct = tempDash[i] >= 0; - obj1.free(); - } - } - - if (correct) { - dashLength = tempLength; - dash = tempDash; - style = borderDashed; - } else { - gfree (tempDash); - } - - return correct; -} - -AnnotBorder::~AnnotBorder() { - if (dash) - gfree (dash); -} - -//------------------------------------------------------------------------ -// AnnotBorderArray -//------------------------------------------------------------------------ - -AnnotBorderArray::AnnotBorderArray() { - horizontalCorner = 0; - verticalCorner = 0; -} - -AnnotBorderArray::AnnotBorderArray(Array *array) { - Object obj1; - int arrayLength = array->getLength(); - - GBool correct = gTrue; - if (arrayLength == 3 || arrayLength == 4) { - // implementation note 81 in Appendix H. - - if (array->get(0, &obj1)->isNum()) - horizontalCorner = obj1.getNum(); - else - correct = gFalse; - obj1.free(); - - if (array->get(1, &obj1)->isNum()) - verticalCorner = obj1.getNum(); - else - correct = gFalse; - obj1.free(); - - if (array->get(2, &obj1)->isNum()) - width = obj1.getNum(); - else - correct = gFalse; - obj1.free(); - - if (arrayLength == 4) { - if (array->get(3, &obj1)->isArray()) - correct = parseDashArray(&obj1); - else - correct = gFalse; - obj1.free(); - } - } else { - correct = gFalse; - } - - if (!correct) { - width = 0; - } -} - -void AnnotBorderArray::writeToObject(XRef *xref, Object *obj1) const { - Object obj2; - - obj1->initArray(xref); - obj1->arrayAdd(obj2.initReal(horizontalCorner)); - obj1->arrayAdd(obj2.initReal(verticalCorner)); - obj1->arrayAdd(obj2.initReal(width)); - - if (dashLength > 0) { - Object obj3; - - obj1->arrayAdd(obj3.initArray(xref)); - for (int i = 0; i < dashLength; i++) - obj3.arrayAdd(obj2.initReal(dash[i])); - } -} - -//------------------------------------------------------------------------ -// AnnotBorderBS -//------------------------------------------------------------------------ - -AnnotBorderBS::AnnotBorderBS() { -} - -AnnotBorderBS::AnnotBorderBS(Dict *dict) { - Object obj1, obj2; - - // acroread 8 seems to need both W and S entries for - // any border to be drawn, even though the spec - // doesn't claim anything of that sort. We follow - // that behaviour by veryifying both entries exist - // otherwise we set the borderWidth to 0 - // --jrmuizel - dict->lookup("W", &obj1); - dict->lookup("S", &obj2); - if (obj1.isNum() && obj2.isName()) { - const char *styleName = obj2.getName(); - - width = obj1.getNum(); - - if (!strcmp(styleName, "S")) { - style = borderSolid; - } else if (!strcmp(styleName, "D")) { - style = borderDashed; - } else if (!strcmp(styleName, "B")) { - style = borderBeveled; - } else if (!strcmp(styleName, "I")) { - style = borderInset; - } else if (!strcmp(styleName, "U")) { - style = borderUnderlined; - } else { - style = borderSolid; - } - } else { - width = 0; - } - obj2.free(); - obj1.free(); - - if (style == borderDashed) { - if (dict->lookup("D", &obj1)->isArray()) - parseDashArray(&obj1); - obj1.free(); - - if (!dash) { - dashLength = 1; - dash = (double *) gmallocn (dashLength, sizeof (double)); - dash[0] = 3; - } - } -} - -const char *AnnotBorderBS::getStyleName() const { - switch (style) { - case borderSolid: - return "S"; - case borderDashed: - return "D"; - case borderBeveled: - return "B"; - case borderInset: - return "I"; - case borderUnderlined: - return "U"; - } - - return "S"; -} - -void AnnotBorderBS::writeToObject(XRef *xref, Object *obj1) const { - Object obj2; - - obj1->initDict(xref); - obj1->dictSet("W", obj2.initReal(width)); - obj1->dictSet("S", obj2.initName(getStyleName())); - if (style == borderDashed && dashLength > 0) { - Object obj3; - - obj1->dictSet("D", obj3.initArray(xref)); - for (int i = 0; i < dashLength; i++) - obj3.arrayAdd(obj2.initReal(dash[i])); - } -} - -//------------------------------------------------------------------------ -// AnnotColor -//------------------------------------------------------------------------ - -AnnotColor::AnnotColor() { - length = 0; -} - -AnnotColor::AnnotColor(double gray) { - length = 1; - - values[0] = gray; -} - -AnnotColor::AnnotColor(double r, double g, double b) { - length = 3; - - values[0] = r; - values[1] = g; - values[2] = b; -} - -AnnotColor::AnnotColor(double c, double m, double y, double k) { - length = 4; - - values[0] = c; - values[1] = m; - values[2] = y; - values[3] = k; -} - -// If <adjust> is +1, color is brightened; -// if <adjust> is -1, color is darkened; -// otherwise color is not modified. -AnnotColor::AnnotColor(Array *array, int adjust) { - int i; - - length = array->getLength(); - if (length > 4) - length = 4; - - for (i = 0; i < length; i++) { - Object obj1; - - if (array->get(i, &obj1)->isNum()) { - values[i] = obj1.getNum(); - - if (values[i] < 0 || values[i] > 1) - values[i] = 0; - } else { - values[i] = 0; - } - obj1.free(); - } - - if (adjust != 0) - adjustColor(adjust); -} - -void AnnotColor::adjustColor(int adjust) { - int i; - - if (length == 4) { - adjust = -adjust; - } - if (adjust > 0) { - for (i = 0; i < length; ++i) { - values[i] = 0.5 * values[i] + 0.5; - } - } else if (adjust < 0) { - for (i = 0; i < length; ++i) { - values[i] = 0.5 * values[i]; - } - } -} - -void AnnotColor::writeToObject(XRef *xref, Object *obj1) const { - Object obj2; - int i; - - if (length == 0) { - obj1->initNull(); // Transparent (no color) - } else { - obj1->initArray(xref); - for (i = 0; i < length; ++i) - obj1->arrayAdd( obj2.initReal( values[i] ) ); - } -} - -//------------------------------------------------------------------------ -// AnnotIconFit -//------------------------------------------------------------------------ - -AnnotIconFit::AnnotIconFit(Dict* dict) { - Object obj1; - - if (dict->lookup("SW", &obj1)->isName()) { - const char *scaleName = obj1.getName(); - - if(!strcmp(scaleName, "B")) { - scaleWhen = scaleBigger; - } else if(!strcmp(scaleName, "S")) { - scaleWhen = scaleSmaller; - } else if(!strcmp(scaleName, "N")) { - scaleWhen = scaleNever; - } else { - scaleWhen = scaleAlways; - } - } else { - scaleWhen = scaleAlways; - } - obj1.free(); - - if (dict->lookup("S", &obj1)->isName()) { - const char *scaleName = obj1.getName(); - - if(!strcmp(scaleName, "A")) { - scale = scaleAnamorphic; - } else { - scale = scaleProportional; - } - } else { - scale = scaleProportional; - } - obj1.free(); - - if (dict->lookup("A", &obj1)->isArray() && obj1.arrayGetLength() == 2) { - Object obj2; - (obj1.arrayGet(0, &obj2)->isNum() ? left = obj2.getNum() : left = 0); - obj2.free(); - (obj1.arrayGet(1, &obj2)->isNum() ? bottom = obj2.getNum() : bottom = 0); - obj2.free(); - - if (left < 0 || left > 1) - left = 0.5; - - if (bottom < 0 || bottom > 1) - bottom = 0.5; - - } else { - left = bottom = 0.5; - } - obj1.free(); - - if (dict->lookup("FB", &obj1)->isBool()) { - fullyBounds = obj1.getBool(); - } else { - fullyBounds = gFalse; - } - obj1.free(); -} - -//------------------------------------------------------------------------ -// AnnotAppearance -//------------------------------------------------------------------------ - -AnnotAppearance::AnnotAppearance(PDFDoc *docA, Object *dict) { - assert(dict->isDict()); - doc = docA; - xref = docA->getXRef(); - dict->copy(&appearDict); -} - -AnnotAppearance::~AnnotAppearance() { - appearDict.free(); -} - -void AnnotAppearance::getAppearanceStream(AnnotAppearanceType type, const char *state, Object *dest) { - Object apData, stream; - apData.initNull(); - - // Obtain dictionary or stream associated to appearance type - switch (type) { - case appearRollover: - if (appearDict.dictLookupNF("R", &apData)->isNull()) - appearDict.dictLookupNF("N", &apData); - break; - case appearDown: - if (appearDict.dictLookupNF("D", &apData)->isNull()) - appearDict.dictLookupNF("N", &apData); - break; - case appearNormal: - appearDict.dictLookupNF("N", &apData); - break; - } - - dest->initNull(); - if (apData.isDict() && state) - apData.dictLookupNF(state, dest); - else if (apData.isRef()) - apData.copy(dest); - apData.free(); -} - -GooString * AnnotAppearance::getStateKey(int i) { - Object obj1; - GooString * res = NULL; - if (appearDict.dictLookupNF("N", &obj1)->isDict()) - res = new GooString(obj1.dictGetKey(i)); - obj1.free(); - return res; -} - -int AnnotAppearance::getNumStates() { - Object obj1; - int res = 0; - if (appearDict.dictLookupNF("N", &obj1)->isDict()) - res = obj1.dictGetLength(); - obj1.free(); - return res; -} - -// Test if stateObj (a Ref or a Dict) points to the specified stream -GBool AnnotAppearance::referencesStream(Object *stateObj, Ref refToStream) { - if (stateObj->isRef()) { - Ref r = stateObj->getRef(); - if (r.num == refToStream.num && r.gen == refToStream.gen) { - return gTrue; - } - } else if (stateObj->isDict()) { // Test each value - const int size = stateObj->dictGetLength(); - for (int i = 0; i < size; ++i) { - Object obj1; - stateObj->dictGetValNF(i, &obj1); - if (obj1.isRef()) { - Ref r = obj1.getRef(); - if (r.num == refToStream.num && r.gen == refToStream.gen) { - return gTrue; - } - } - obj1.free(); - } - } - return gFalse; // Not found -} - -// Test if this AnnotAppearance references the specified stream -GBool AnnotAppearance::referencesStream(Ref refToStream) { - Object obj1; - GBool found; - - // Scan each state's ref/subdictionary - appearDict.dictLookupNF("N", &obj1); - found = referencesStream(&obj1, refToStream); - obj1.free(); - if (found) - return gTrue; - - appearDict.dictLookupNF("R", &obj1); - found = referencesStream(&obj1, refToStream); - obj1.free(); - if (found) - return gTrue; - - appearDict.dictLookupNF("D", &obj1); - found = referencesStream(&obj1, refToStream); - obj1.free(); - return found; -} - -// If this is the only annotation in the document that references the -// specified appearance stream, remove the appearance stream -void AnnotAppearance::removeStream(Ref refToStream) { - const int lastpage = doc->getNumPages(); - for (int pg = 1; pg <= lastpage; ++pg) { // Scan all annotations in the document - Page *page = doc->getPage(pg); - if (!page) { - error(errSyntaxError, -1, "Failed check for shared annotation stream at page {0:d}", pg); - continue; - } - Annots *annots = page->getAnnots(); - for (int i = 0; i < annots->getNumAnnots(); ++i) { - AnnotAppearance *annotAp = annots->getAnnot(i)->getAppearStreams(); - if (annotAp && annotAp != this && annotAp->referencesStream(refToStream)) { - return; // Another annotation points to the stream -> Don't delete it - } - } - } - - // TODO: stream resources (e.g. font), AP name tree - xref->removeIndirectObject(refToStream); -} - -// Removes stream if obj is a Ref, or removes pointed streams if obj is a Dict -void AnnotAppearance::removeStateStreams(Object *obj1) { - if (obj1->isRef()) { - removeStream(obj1->getRef()); - } else if (obj1->isDict()) { - const int size = obj1->dictGetLength(); - for (int i = 0; i < size; ++i) { - Object obj2; - obj1->dictGetValNF(i, &obj2); - if (obj2.isRef()) { - removeStream(obj2.getRef()); - } - obj2.free(); - } - } -} - -void AnnotAppearance::removeAllStreams() { - Object obj1; - appearDict.dictLookupNF("N", &obj1); - removeStateStreams(&obj1); - obj1.free(); - appearDict.dictLookupNF("R", &obj1); - removeStateStreams(&obj1); - obj1.free(); - appearDict.dictLookupNF("D", &obj1); - removeStateStreams(&obj1); - obj1.free(); -} - -//------------------------------------------------------------------------ -// AnnotAppearanceCharacs -//------------------------------------------------------------------------ - -AnnotAppearanceCharacs::AnnotAppearanceCharacs(Dict *dict) { - Object obj1; - - if (dict->lookup("R", &obj1)->isInt()) { - rotation = obj1.getInt(); - } else { - rotation = 0; - } - obj1.free(); - - if (dict->lookup("BC", &obj1)->isArray()) { - Array *colorComponents = obj1.getArray(); - if (colorComponents->getLength() > 0) { - borderColor = new AnnotColor(colorComponents); - } else { - borderColor = NULL; - } - } else { - borderColor = NULL; - } - obj1.free(); - - if (dict->lookup("BG", &obj1)->isArray()) { - Array *colorComponents = obj1.getArray(); - if (colorComponents->getLength() > 0) { - backColor = new AnnotColor(colorComponents); - } else { - backColor = NULL; - } - } else { - backColor = NULL; - } - obj1.free(); - - if (dict->lookup("CA", &obj1)->isString()) { - normalCaption = new GooString(obj1.getString()); - } else { - normalCaption = NULL; - } - obj1.free(); - - if (dict->lookup("RC", &obj1)->isString()) { - rolloverCaption = new GooString(obj1.getString()); - } else { - rolloverCaption = NULL; - } - obj1.free(); - - if (dict->lookup("AC", &obj1)->isString()) { - alternateCaption = new GooString(obj1.getString()); - } else { - alternateCaption = NULL; - } - obj1.free(); - - if (dict->lookup("IF", &obj1)->isDict()) { - iconFit = new AnnotIconFit(obj1.getDict()); - } else { - iconFit = NULL; - } - obj1.free(); - - if (dict->lookup("TP", &obj1)->isInt()) { - position = (AnnotAppearanceCharacsTextPos) obj1.getInt(); - } else { - position = captionNoIcon; - } - obj1.free(); -} - -AnnotAppearanceCharacs::~AnnotAppearanceCharacs() { - if (borderColor) - delete borderColor; - - if (backColor) - delete backColor; - - if (normalCaption) - delete normalCaption; - - if (rolloverCaption) - delete rolloverCaption; - - if (alternateCaption) - delete alternateCaption; - - if (iconFit) - delete iconFit; -} - -//------------------------------------------------------------------------ -// AnnotAppearanceBBox -//------------------------------------------------------------------------ - -AnnotAppearanceBBox::AnnotAppearanceBBox(PDFRectangle *rect) { - origX = rect->x1; - origY = rect->y1; - borderWidth = 0; - - // Initially set the same size as rect - minX = 0; - minY = 0; - maxX = rect->x2 - rect->x1; - maxY = rect->y2 - rect->y1; -} - -void AnnotAppearanceBBox::extendTo(double x, double y) { - if (x < minX) { - minX = x; - } else if (x > maxX) { - maxX = x; - } - if (y < minY) { - minY = y; - } else if (y > maxY) { - maxY = y; - } -} - -void AnnotAppearanceBBox::getBBoxRect(double bbox[4]) const { - bbox[0] = minX - borderWidth; - bbox[1] = minY - borderWidth; - bbox[2] = maxX + borderWidth; - bbox[3] = maxY + borderWidth; -} - -double AnnotAppearanceBBox::getPageXMin() const { - return origX + minX - borderWidth; -} - -double AnnotAppearanceBBox::getPageYMin() const { - return origY + minY - borderWidth; -} - -double AnnotAppearanceBBox::getPageXMax() const { - return origX + maxX + borderWidth; -} - -double AnnotAppearanceBBox::getPageYMax() const { - return origY + maxY + borderWidth; -} - -//------------------------------------------------------------------------ -// Annot -//------------------------------------------------------------------------ - -Annot::Annot(PDFDoc *docA, PDFRectangle *rectA) { - Object obj1; - - refCnt = 1; - flags = flagUnknown; - type = typeUnknown; - - obj1.initArray (docA->getXRef()); - Object obj2; - obj1.arrayAdd (obj2.initReal (rectA->x1)); - obj1.arrayAdd (obj2.initReal (rectA->y1)); - obj1.arrayAdd (obj2.initReal (rectA->x2)); - obj1.arrayAdd (obj2.initReal (rectA->y2)); - obj2.free (); - - annotObj.initDict (docA->getXRef()); - annotObj.dictSet ("Type", obj2.initName ("Annot")); - annotObj.dictSet ("Rect", &obj1); - // obj1 is owned by the dict - - ref = docA->getXRef()->addIndirectObject (&annotObj); - - initialize (docA, annotObj.getDict()); -} - -Annot::Annot(PDFDoc *docA, Dict *dict) { - refCnt = 1; - hasRef = false; - flags = flagUnknown; - type = typeUnknown; - annotObj.initDict (dict); - initialize (docA, dict); -} - -Annot::Annot(PDFDoc *docA, Dict *dict, Object *obj) { - refCnt = 1; - if (obj->isRef()) { - hasRef = gTrue; - ref = obj->getRef(); - } else { - hasRef = gFalse; - } - flags = flagUnknown; - type = typeUnknown; - annotObj.initDict (dict); - initialize (docA, dict); -} - -void Annot::initialize(PDFDoc *docA, Dict *dict) { - Object apObj, asObj, obj1, obj2; - - ok = gTrue; - doc = docA; - xref = doc->getXRef(); - appearStreams = NULL; - appearBBox = NULL; - appearState = NULL; - appearBuf = NULL; - fontSize = 0; - - appearance.initNull(); - - //----- parse the rectangle - rect = new PDFRectangle(); - if (dict->lookup("Rect", &obj1)->isArray() && obj1.arrayGetLength() == 4) { - Object obj2; - (obj1.arrayGet(0, &obj2)->isNum() ? rect->x1 = obj2.getNum() : rect->x1 = 0); - obj2.free(); - (obj1.arrayGet(1, &obj2)->isNum() ? rect->y1 = obj2.getNum() : rect->y1 = 0); - obj2.free(); - (obj1.arrayGet(2, &obj2)->isNum() ? rect->x2 = obj2.getNum() : rect->x2 = 1); - obj2.free(); - (obj1.arrayGet(3, &obj2)->isNum() ? rect->y2 = obj2.getNum() : rect->y2 = 1); - obj2.free(); - - if (rect->x1 > rect->x2) { - double t = rect->x1; - rect->x1 = rect->x2; - rect->x2 = t; - } - - if (rect->y1 > rect->y2) { - double t = rect->y1; - rect->y1 = rect->y2; - rect->y2 = t; - } - } else { - rect->x1 = rect->y1 = 0; - rect->x2 = rect->y2 = 1; - error(errSyntaxError, -1, "Bad bounding box for annotation"); - ok = gFalse; - } - obj1.free(); - - if (dict->lookup("Contents", &obj1)->isString()) { - contents = obj1.getString()->copy(); - } else { - contents = new GooString(); - } - obj1.free(); - - // Note: This value is overwritten by Annots ctor - if (dict->lookupNF("P", &obj1)->isRef()) { - Ref ref = obj1.getRef(); - - page = doc->getCatalog()->findPage (ref.num, ref.gen); - } else { - page = 0; - } - obj1.free(); - - if (dict->lookup("NM", &obj1)->isString()) { - name = obj1.getString()->copy(); - } else { - name = NULL; - } - obj1.free(); - - if (dict->lookup("M", &obj1)->isString()) { - modified = obj1.getString()->copy(); - } else { - modified = NULL; - } - obj1.free(); - - //----- get the flags - if (dict->lookup("F", &obj1)->isInt()) { - flags |= obj1.getInt(); - } else { - flags = flagUnknown; - } - obj1.free(); - - //----- get the annotation appearance dictionary - dict->lookup("AP", &apObj); - if (apObj.isDict()) { - appearStreams = new AnnotAppearance(doc, &apObj); - } - apObj.free(); - - //----- get the appearance state - dict->lookup("AS", &asObj); - if (asObj.isName()) { - appearState = new GooString(asObj.getName()); - } else if (appearStreams && appearStreams->getNumStates() != 0) { - error (errSyntaxError, -1, "Invalid or missing AS value in annotation containing one or more appearance subdictionaries"); - // AS value is required in this case, but if the - // N dictionary contains only one entry - // take it as default appearance. - if (appearStreams->getNumStates() == 1) { - appearState = appearStreams->getStateKey(0); - } - } - if (!appearState) { - appearState = new GooString("Off"); - } - asObj.free(); - - //----- get the annotation appearance - if (appearStreams) { - appearStreams->getAppearanceStream(AnnotAppearance::appearNormal, appearState->getCString(), &appearance); - } - - //----- parse the border style - // According to the spec if neither the Border nor the BS entry is present, - // the border shall be drawn as a solid line with a width of 1 point. But acroread - // seems to ignore the Border entry for annots that can't have a BS entry. So, we only - // follow this rule for annots tha can have a BS entry. - if (dict->lookup("Border", &obj1)->isArray()) - border = new AnnotBorderArray(obj1.getArray()); - else - border = NULL; - obj1.free(); - - if (dict->lookup("C", &obj1)->isArray()) { - color = new AnnotColor(obj1.getArray()); - } else { - color = NULL; - } - obj1.free(); - - if (dict->lookup("StructParent", &obj1)->isInt()) { - treeKey = obj1.getInt(); - } else { - treeKey = 0; - } - obj1.free(); - - dict->lookupNF("OC", &oc); - -#if MULTITHREADED - gInitMutex(&mutex); -#endif -} - -void Annot::getRect(double *x1, double *y1, double *x2, double *y2) const { - *x1 = rect->x1; - *y1 = rect->y1; - *x2 = rect->x2; - *y2 = rect->y2; -} - -void Annot::setRect(PDFRectangle *rect) { - setRect(rect->x1, rect->y1, rect->x2, rect->y2); -} - -void Annot::setRect(double x1, double y1, double x2, double y2) { - Object obj1, obj2; - - if (x1 < x2) { - rect->x1 = x1; - rect->x2 = x2; - } else { - rect->x1 = x2; - rect->x2 = x1; - } - - if (y1 < y2) { - rect->y1 = y1; - rect->y2 = y2; - } else { - rect->y1 = y2; - rect->y2 = y1; - } - - obj1.initArray (xref); - obj1.arrayAdd (obj2.initReal (rect->x1)); - obj1.arrayAdd (obj2.initReal (rect->y1)); - obj1.arrayAdd (obj2.initReal (rect->x2)); - obj1.arrayAdd (obj2.initReal (rect->y2)); - - update("Rect", &obj1); - invalidateAppearance(); -} - -GBool Annot::inRect(double x, double y) const { - return rect->contains(x, y); -} - -void Annot::update(const char *key, Object *value) { - annotLocker(); - /* Set M to current time, unless we are updating M itself */ - if (strcmp(key, "M") != 0) { - delete modified; - modified = timeToDateString(NULL); - - Object obj1; - obj1.initString (modified->copy()); - annotObj.dictSet("M", &obj1); - } - - annotObj.dictSet(const_cast<char*>(key), value); - - xref->setModifiedObject(&annotObj, ref); -} - -void Annot::setContents(GooString *new_content) { - annotLocker(); - delete contents; - - if (new_content) { - contents = new GooString(new_content); - //append the unicode marker <FE FF> if needed - if (!contents->hasUnicodeMarker()) { - contents->insert(0, 0xff); - contents->insert(0, 0xfe); - } - } else { - contents = new GooString(); - } - - Object obj1; - obj1.initString(contents->copy()); - update ("Contents", &obj1); -} - -void Annot::setName(GooString *new_name) { - annotLocker(); - delete name; - - if (new_name) { - name = new GooString(new_name); - } else { - name = new GooString(); - } - - Object obj1; - obj1.initString(name->copy()); - update ("NM", &obj1); -} - -void Annot::setModified(GooString *new_modified) { - annotLocker(); - delete modified; - - if (new_modified) - modified = new GooString(new_modified); - else - modified = new GooString(); - - Object obj1; - obj1.initString(modified->copy()); - update ("M", &obj1); -} - -void Annot::setFlags(Guint new_flags) { - annotLocker(); - Object obj1; - flags = new_flags; - obj1.initInt(flags); - update ("F", &obj1); -} - -void Annot::setBorder(AnnotBorder *new_border) { - annotLocker(); - delete border; - - if (new_border) { - Object obj1; - new_border->writeToObject(xref, &obj1); - update(new_border->getType() == AnnotBorder::typeArray ? "Border" : "BS", &obj1); - border = new_border; - } else { - border = NULL; - } - invalidateAppearance(); -} - -void Annot::setColor(AnnotColor *new_color) { - annotLocker(); - delete color; - - if (new_color) { - Object obj1; - new_color->writeToObject(xref, &obj1); - update ("C", &obj1); - color = new_color; - } else { - color = NULL; - } - invalidateAppearance(); -} - -void Annot::setPage(int pageIndex, GBool updateP) { - annotLocker(); - Page *pageobj = doc->getPage(pageIndex); - Object obj1; - - if (pageobj) { - Ref pageRef = pageobj->getRef(); - obj1.initRef(pageRef.num, pageRef.gen); - page = pageIndex; - } else { - obj1.initNull(); - page = 0; - } - - if (updateP) { - update("P", &obj1); - } -} - -void Annot::setAppearanceState(const char *state) { - annotLocker(); - if (!state) - return; - - delete appearState; - appearState = new GooString(state); - - delete appearBBox; - appearBBox = NULL; - - Object obj1; - obj1.initName(state); - update ("AS", &obj1); - - // The appearance state determines the current appearance stream - appearance.free(); - if (appearStreams) { - appearStreams->getAppearanceStream(AnnotAppearance::appearNormal, appearState->getCString(), &appearance); - } else { - appearance.initNull(); - } -} - -void Annot::invalidateAppearance() { - annotLocker(); - if (appearStreams) { // Remove existing appearance streams - appearStreams->removeAllStreams(); - } - delete appearStreams; - appearStreams = NULL; - - delete appearState; - appearState = NULL; - - delete appearBBox; - appearBBox = NULL; - - appearance.free(); - appearance.initNull(); - - Object obj1, obj2; - obj1.initNull(); - if (!annotObj.dictLookup("AP", &obj2)->isNull()) - update ("AP", &obj1); // Remove AP - obj2.free(); - - if (!annotObj.dictLookup("AS", &obj2)->isNull()) - update ("AS", &obj1); // Remove AS - obj2.free(); -} - -double Annot::getXMin() { - return rect->x1; -} - -double Annot::getYMin() { - return rect->y1; -} - -double Annot::getXMax() { - return rect->x2; -} - -double Annot::getYMax() { - return rect->y2; -} - -void Annot::readArrayNum(Object *pdfArray, int key, double *value) { - Object valueObject; - - pdfArray->arrayGet(key, &valueObject); - if (valueObject.isNum()) { - *value = valueObject.getNum(); - } else { - *value = 0; - ok = gFalse; - } - valueObject.free(); -} - -void Annot::removeReferencedObjects() { - // Remove appearance streams (if any) - invalidateAppearance(); -} - -void Annot::incRefCnt() { - annotLocker(); - refCnt++; -} - -void Annot::decRefCnt() { -#if MULTITHREADED - gLockMutex(&mutex); -#endif - if (--refCnt == 0) { -#if MULTITHREADED - gUnlockMutex(&mutex); -#endif - delete this; - return; - } -#if MULTITHREADED - gUnlockMutex(&mutex); -#endif -} - -Annot::~Annot() { - annotObj.free(); - - delete rect; - delete contents; - - if (name) - delete name; - - if (modified) - delete modified; - - delete appearStreams; - delete appearBBox; - appearance.free(); - - if (appearState) - delete appearState; - - if (border) - delete border; - - if (color) - delete color; - - oc.free(); - -#if MULTITHREADED - gDestroyMutex(&mutex); -#endif -} - -void Annot::setColor(AnnotColor *color, GBool fill) { - const double *values = color->getValues(); - - switch (color->getSpace()) { - case AnnotColor::colorCMYK: - appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:c}\n", - values[0], values[1], values[2], values[3], - fill ? 'k' : 'K'); - break; - case AnnotColor::colorRGB: - appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:s}\n", - values[0], values[1], values[2], - fill ? "rg" : "RG"); - break; - case AnnotColor::colorGray: - appearBuf->appendf("{0:.2f} {1:c}\n", - values[0], - fill ? 'g' : 'G'); - break; - case AnnotColor::colorTransparent: - default: - break; - } -} - -void Annot::setLineStyleForBorder(AnnotBorder *border) { - int i, dashLength; - double *dash; - - switch (border->getStyle()) { - case AnnotBorder::borderDashed: - appearBuf->append("["); - dashLength = border->getDashLength(); - dash = border->getDash(); - for (i = 0; i < dashLength; ++i) - appearBuf->appendf(" {0:.2f}", dash[i]); - appearBuf->append(" ] 0 d\n"); - break; - default: - appearBuf->append("[] 0 d\n"); - break; - } - appearBuf->appendf("{0:.2f} w\n", border->getWidth()); -} - -// Draw an (approximate) circle of radius <r> centered at (<cx>, <cy>). -// If <fill> is true, the circle is filled; otherwise it is stroked. -void Annot::drawCircle(double cx, double cy, double r, GBool fill) { - appearBuf->appendf("{0:.2f} {1:.2f} m\n", - cx + r, cy); - appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", - cx + r, cy + bezierCircle * r, - cx + bezierCircle * r, cy + r, - cx, cy + r); - appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", - cx - bezierCircle * r, cy + r, - cx - r, cy + bezierCircle * r, - cx - r, cy); - appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", - cx - r, cy - bezierCircle * r, - cx - bezierCircle * r, cy - r, - cx, cy - r); - appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", - cx + bezierCircle * r, cy - r, - cx + r, cy - bezierCircle * r, - cx + r, cy); - appearBuf->append(fill ? "f\n" : "s\n"); -} - -// Draw the top-left half of an (approximate) circle of radius <r> -// centered at (<cx>, <cy>). -void Annot::drawCircleTopLeft(double cx, double cy, double r) { - double r2; - - r2 = r / sqrt(2.0); - appearBuf->appendf("{0:.2f} {1:.2f} m\n", - cx + r2, cy + r2); - appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", - cx + (1 - bezierCircle) * r2, - cy + (1 + bezierCircle) * r2, - cx - (1 - bezierCircle) * r2, - cy + (1 + bezierCircle) * r2, - cx - r2, - cy + r2); - appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", - cx - (1 + bezierCircle) * r2, - cy + (1 - bezierCircle) * r2, - cx - (1 + bezierCircle) * r2, - cy - (1 - bezierCircle) * r2, - cx - r2, - cy - r2); - appearBuf->append("S\n"); -} - -// Draw the bottom-right half of an (approximate) circle of radius <r> -// centered at (<cx>, <cy>). -void Annot::drawCircleBottomRight(double cx, double cy, double r) { - double r2; - - r2 = r / sqrt(2.0); - appearBuf->appendf("{0:.2f} {1:.2f} m\n", - cx - r2, cy - r2); - appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", - cx - (1 - bezierCircle) * r2, - cy - (1 + bezierCircle) * r2, - cx + (1 - bezierCircle) * r2, - cy - (1 + bezierCircle) * r2, - cx + r2, - cy - r2); - appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", - cx + (1 + bezierCircle) * r2, - cy - (1 - bezierCircle) * r2, - cx + (1 + bezierCircle) * r2, - cy + (1 - bezierCircle) * r2, - cx + r2, - cy + r2); - appearBuf->append("S\n"); -} - -void Annot::createForm(double *bbox, GBool transparencyGroup, Object *resDict, Object *aStream) { - Object obj1, obj2; - Object appearDict; - - appearDict.initDict(xref); - appearDict.dictSet("Length", obj1.initInt(appearBuf->getLength())); - appearDict.dictSet("Subtype", obj1.initName("Form")); - obj1.initArray(xref); - obj1.arrayAdd(obj2.initReal(bbox[0])); - obj1.arrayAdd(obj2.initReal(bbox[1])); - obj1.arrayAdd(obj2.initReal(bbox[2])); - obj1.arrayAdd(obj2.initReal(bbox[3])); - appearDict.dictSet("BBox", &obj1); - if (transparencyGroup) { - Object transDict; - transDict.initDict(xref); - transDict.dictSet("S", obj1.initName("Transparency")); - appearDict.dictSet("Group", &transDict); - } - if (resDict) - appearDict.dictSet("Resources", resDict); - - MemStream *mStream = new MemStream(copyString(appearBuf->getCString()), 0, - appearBuf->getLength(), &appearDict); - mStream->setNeedFree(gTrue); - aStream->initStream(mStream); -} - -void Annot::createResourcesDict(const char *formName, Object *formStream, - const char *stateName, - double opacity, const char *blendMode, - Object *resDict) { - Object gsDict, stateDict, formDict, obj1; - - gsDict.initDict(xref); - if (opacity != 1) { - gsDict.dictSet("CA", obj1.initReal(opacity)); - gsDict.dictSet("ca", obj1.initReal(opacity)); - } - if (blendMode) - gsDict.dictSet("BM", obj1.initName(blendMode)); - stateDict.initDict(xref); - stateDict.dictSet(stateName, &gsDict); - formDict.initDict(xref); - formDict.dictSet(formName, formStream); - - resDict->initDict(xref); - resDict->dictSet("ExtGState", &stateDict); - resDict->dictSet("XObject", &formDict); -} - -Object *Annot::getAppearanceResDict(Object *dest) { - Object obj1, obj2; - - dest->initNull(); // Default value - - // Fetch appearance's resource dict (if any) - appearance.fetch(xref, &obj1); - if (obj1.isStream()) { - obj1.streamGetDict()->lookup("Resources", &obj2); - if (obj2.isDict()) { - obj2.copy(dest); - } - obj2.free(); - } - obj1.free(); - - return dest; -} - -GBool Annot::isVisible(GBool printing) { - // check the flags - if ((flags & flagHidden) || - (printing && !(flags & flagPrint)) || - (!printing && (flags & flagNoView))) { - return gFalse; - } - - // check the OC - OCGs *optContentConfig = doc->getCatalog()->getOptContentConfig(); - if (optContentConfig) { - if (! optContentConfig->optContentIsVisible(&oc)) - return gFalse; - } - - return gTrue; -} - -int Annot::getRotation() const -{ - Page *pageobj = doc->getPage(page); - assert(pageobj != NULL); - - if (flags & flagNoRotate) { - return (360 - pageobj->getRotate()) % 360; - } else { - return 0; - } -} - -void Annot::draw(Gfx *gfx, GBool printing) { - Object obj; - - annotLocker(); - if (!isVisible (printing)) - return; - - // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); - gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, - rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - obj.free(); -} - -//------------------------------------------------------------------------ -// AnnotPopup -//------------------------------------------------------------------------ - -AnnotPopup::AnnotPopup(PDFDoc *docA, PDFRectangle *rect) : - Annot(docA, rect) { - Object obj1; - - type = typePopup; - - annotObj.dictSet ("Subtype", obj1.initName ("Popup")); - initialize (docA, annotObj.getDict()); -} - -AnnotPopup::AnnotPopup(PDFDoc *docA, Dict *dict, Object *obj) : - Annot(docA, dict, obj) { - type = typePopup; - initialize(docA, dict); -} - -AnnotPopup::~AnnotPopup() { - parent.free(); -} - -void AnnotPopup::initialize(PDFDoc *docA, Dict *dict) { - Object obj1; - - if (!dict->lookupNF("Parent", &parent)->isRef()) { - parent.initNull(); - } - - if (dict->lookup("Open", &obj1)->isBool()) { - open = obj1.getBool(); - } else { - open = gFalse; - } - obj1.free(); -} - -void AnnotPopup::setParent(Object *parentA) { - parentA->copy(&parent); - update ("Parent", &parent); -} - -void AnnotPopup::setParent(Annot *parentA) { - Ref parentRef = parentA->getRef(); - parent.initRef(parentRef.num, parentRef.gen); - update ("Parent", &parent); -} - -void AnnotPopup::setOpen(GBool openA) { - Object obj1; - - open = openA; - obj1.initBool(open); - update ("Open", &obj1); -} - -//------------------------------------------------------------------------ -// AnnotMarkup -//------------------------------------------------------------------------ -AnnotMarkup::AnnotMarkup(PDFDoc *docA, PDFRectangle *rect) : - Annot(docA, rect) { - initialize(docA, annotObj.getDict(), &annotObj); -} - -AnnotMarkup::AnnotMarkup(PDFDoc *docA, Dict *dict, Object *obj) : - Annot(docA, dict, obj) { - initialize(docA, dict, obj); -} - -AnnotMarkup::~AnnotMarkup() { - if (label) - delete label; - - if (popup) - delete popup; - - if (date) - delete date; - - if (subject) - delete subject; -} - -void AnnotMarkup::initialize(PDFDoc *docA, Dict *dict, Object *obj) { - Object obj1, obj2; - - if (dict->lookup("T", &obj1)->isString()) { - label = obj1.getString()->copy(); - } else { - label = NULL; - } - obj1.free(); - - if (dict->lookup("Popup", &obj1)->isDict() && dict->lookupNF("Popup", &obj2)->isRef()) { - popup = new AnnotPopup(docA, obj1.getDict(), &obj2); - } else { - popup = NULL; - } - obj1.free(); - - if (dict->lookup("CA", &obj1)->isNum()) { - opacity = obj1.getNum(); - } else { - opacity = 1.0; - } - obj1.free(); - - if (dict->lookup("CreationDate", &obj1)->isString()) { - date = obj1.getString()->copy(); - } else { - date = NULL; - } - obj1.free(); - - if (dict->lookupNF("IRT", &obj1)->isRef()) { - inReplyTo = obj1.getRef(); - } else { - inReplyTo.num = 0; - inReplyTo.gen = 0; - } - obj1.free(); - - if (dict->lookup("Subj", &obj1)->isString()) { - subject = obj1.getString()->copy(); - } else { - subject = NULL; - } - obj1.free(); - - if (dict->lookup("RT", &obj1)->isName()) { - const char *replyName = obj1.getName(); - - if (!strcmp(replyName, "R")) { - replyTo = replyTypeR; - } else if (!strcmp(replyName, "Group")) { - replyTo = replyTypeGroup; - } else { - replyTo = replyTypeR; - } - } else { - replyTo = replyTypeR; - } - obj1.free(); - - if (dict->lookup("ExData", &obj1)->isDict()) { - exData = parseAnnotExternalData(obj1.getDict()); - } else { - exData = annotExternalDataMarkupUnknown; - } - obj1.free(); -} - -void AnnotMarkup::setLabel(GooString *new_label) { - delete label; - - if (new_label) { - label = new GooString(new_label); - //append the unicode marker <FE FF> if needed - if (!label->hasUnicodeMarker()) { - label->insert(0, 0xff); - label->insert(0, 0xfe); - } - } else { - label = new GooString(); - } - - Object obj1; - obj1.initString(label->copy()); - update ("T", &obj1); -} - -void AnnotMarkup::setPopup(AnnotPopup *new_popup) { - delete popup; - - if (new_popup) { - Object obj1; - Ref popupRef = new_popup->getRef(); - - obj1.initRef (popupRef.num, popupRef.gen); - update ("Popup", &obj1); - - new_popup->setParent(this); - popup = new_popup; - } else { - popup = NULL; - } -} - -void AnnotMarkup::setOpacity(double opacityA) { - Object obj1; - - opacity = opacityA; - obj1.initReal(opacity); - update ("CA", &obj1); - invalidateAppearance(); -} - -void AnnotMarkup::setDate(GooString *new_date) { - delete date; - - if (new_date) - date = new GooString(new_date); - else - date = new GooString(); - - Object obj1; - obj1.initString(date->copy()); - update ("CreationDate", &obj1); -} - -void AnnotMarkup::removeReferencedObjects() { - Page *pageobj = doc->getPage(page); - assert(pageobj != NULL); // We're called when removing an annot from a page - - // Remove popup - if (popup) { - pageobj->removeAnnot(popup); - } - - Annot::removeReferencedObjects(); -} - -//------------------------------------------------------------------------ -// AnnotText -//------------------------------------------------------------------------ - -AnnotText::AnnotText(PDFDoc *docA, PDFRectangle *rect) : - AnnotMarkup(docA, rect) { - Object obj1; - - type = typeText; - flags |= flagNoZoom | flagNoRotate; - - annotObj.dictSet ("Subtype", obj1.initName ("Text")); - initialize (docA, annotObj.getDict()); -} - -AnnotText::AnnotText(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { - - type = typeText; - flags |= flagNoZoom | flagNoRotate; - initialize (docA, dict); -} - -AnnotText::~AnnotText() { - delete icon; -} - -void AnnotText::initialize(PDFDoc *docA, Dict *dict) { - Object obj1; - - if (dict->lookup("Open", &obj1)->isBool()) - open = obj1.getBool(); - else - open = gFalse; - obj1.free(); - - if (dict->lookup("Name", &obj1)->isName()) { - icon = new GooString(obj1.getName()); - } else { - icon = new GooString("Note"); - } - obj1.free(); - - if (dict->lookup("StateModel", &obj1)->isString()) { - Object obj2; - GooString *modelName = obj1.getString(); - - if (dict->lookup("State", &obj2)->isString()) { - GooString *stateName = obj2.getString(); - - if (!stateName->cmp("Marked")) { - state = stateMarked; - } else if (!stateName->cmp("Unmarked")) { - state = stateUnmarked; - } else if (!stateName->cmp("Accepted")) { - state = stateAccepted; - } else if (!stateName->cmp("Rejected")) { - state = stateRejected; - } else if (!stateName->cmp("Cancelled")) { - state = stateCancelled; - } else if (!stateName->cmp("Completed")) { - state = stateCompleted; - } else if (!stateName->cmp("None")) { - state = stateNone; - } else { - state = stateUnknown; - } - } else { - state = stateUnknown; - } - obj2.free(); - - if (!modelName->cmp("Marked")) { - switch (state) { - case stateUnknown: - state = stateMarked; - break; - case stateAccepted: - case stateRejected: - case stateCancelled: - case stateCompleted: - case stateNone: - state = stateUnknown; - break; - default: - break; - } - } else if (!modelName->cmp("Review")) { - switch (state) { - case stateUnknown: - state = stateNone; - break; - case stateMarked: - case stateUnmarked: - state = stateUnknown; - break; - default: - break; - } - } else { - state = stateUnknown; - } - } else { - state = stateUnknown; - } - obj1.free(); -} - -void AnnotText::setOpen(GBool openA) { - Object obj1; - - open = openA; - obj1.initBool(open); - update ("Open", &obj1); -} - -void AnnotText::setIcon(GooString *new_icon) { - if (new_icon && icon->cmp(new_icon) == 0) - return; - - delete icon; - - if (new_icon) { - icon = new GooString (new_icon); - } else { - icon = new GooString("Note"); - } - - Object obj1; - obj1.initName (icon->getCString()); - update("Name", &obj1); - invalidateAppearance(); -} - -#define ANNOT_TEXT_AP_NOTE \ - "3.602 24 m 20.398 24 l 22.387 24 24 22.387 24 20.398 c 24 3.602 l 24\n" \ - "1.613 22.387 0 20.398 0 c 3.602 0 l 1.613 0 0 1.613 0 3.602 c 0 20.398\n" \ - "l 0 22.387 1.613 24 3.602 24 c h\n" \ - "3.602 24 m f\n" \ - "0.533333 0.541176 0.521569 RG 2 w\n" \ - "1 J\n" \ - "1 j\n" \ - "[] 0.0 d\n" \ - "4 M 9 18 m 4 18 l 4 7 4 4 6 3 c 20 3 l 18 4 18 7 18 18 c 17 18 l S\n" \ - "1.5 w\n" \ - "0 j\n" \ - "10 16 m 14 21 l S\n" \ - "1.85625 w\n" \ - "1 j\n" \ - "15.07 20.523 m 15.07 19.672 14.379 18.977 13.523 18.977 c 12.672 18.977\n" \ - "11.977 19.672 11.977 20.523 c 11.977 21.379 12.672 22.07 13.523 22.07 c\n" \ - "14.379 22.07 15.07 21.379 15.07 20.523 c h\n" \ - "15.07 20.523 m S\n" \ - "1 w\n" \ - "0 j\n" \ - "6.5 13.5 m 15.5 13.5 l S\n" \ - "6.5 10.5 m 13.5 10.5 l S\n" \ - "6.801 7.5 m 15.5 7.5 l S\n" \ - "0.729412 0.741176 0.713725 RG 2 w\n" \ - "1 j\n" \ - "9 19 m 4 19 l 4 8 4 5 6 4 c 20 4 l 18 5 18 8 18 19 c 17 19 l S\n" \ - "1.5 w\n" \ - "0 j\n" \ - "10 17 m 14 22 l S\n" \ - "1.85625 w\n" \ - "1 j\n" \ - "15.07 21.523 m 15.07 20.672 14.379 19.977 13.523 19.977 c 12.672 19.977\n" \ - "11.977 20.672 11.977 21.523 c 11.977 22.379 12.672 23.07 13.523 23.07 c\n" \ - "14.379 23.07 15.07 22.379 15.07 21.523 c h\n" \ - "15.07 21.523 m S\n" \ - "1 w\n" \ - "0 j\n" \ - "6.5 14.5 m 15.5 14.5 l S\n" \ - "6.5 11.5 m 13.5 11.5 l S\n" \ - "6.801 8.5 m 15.5 8.5 l S\n" - -#define ANNOT_TEXT_AP_COMMENT \ - "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ - "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ - "l 1 21.523 2.477 23 4.301 23 c h\n" \ - "4.301 23 m f\n" \ - "0.533333 0.541176 0.521569 RG 2 w\n" \ - "0 J\n" \ - "1 j\n" \ - "[] 0.0 d\n" \ - "4 M 8 20 m 16 20 l 18.363 20 20 18.215 20 16 c 20 13 l 20 10.785 18.363 9\n" \ - "16 9 c 13 9 l 8 3 l 8 9 l 8 9 l 5.637 9 4 10.785 4 13 c 4 16 l 4 18.215\n" \ - "5.637 20 8 20 c h\n" \ - "8 20 m S\n" \ - "0.729412 0.741176 0.713725 RG 8 21 m 16 21 l 18.363 21 20 19.215 20 17\n" \ - "c 20 14 l 20 11.785 18.363 10\n" \ - "16 10 c 13 10 l 8 4 l 8 10 l 8 10 l 5.637 10 4 11.785 4 14 c 4 17 l 4\n" \ - "19.215 5.637 21 8 21 c h\n" \ - "8 21 m S\n" - -#define ANNOT_TEXT_AP_KEY \ - "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ - "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ - "l 1 21.523 2.477 23 4.301 23 c h\n" \ - "4.301 23 m f\n" \ - "0.533333 0.541176 0.521569 RG 2 w\n" \ - "1 J\n" \ - "0 j\n" \ - "[] 0.0 d\n" \ - "4 M 11.895 18.754 m 13.926 20.625 17.09 20.496 18.961 18.465 c 20.832\n" \ - "16.434 20.699 13.27 18.668 11.398 c 17.164 10.016 15.043 9.746 13.281\n" \ - "10.516 c 12.473 9.324 l 11.281 10.078 l 9.547 8.664 l 9.008 6.496 l\n" \ - "7.059 6.059 l 6.34 4.121 l 5.543 3.668 l 3.375 4.207 l 2.938 6.156 l\n" \ - "10.57 13.457 l 9.949 15.277 10.391 17.367 11.895 18.754 c h\n" \ - "11.895 18.754 m S\n" \ - "1.5 w\n" \ - "16.059 15.586 m 16.523 15.078 17.316 15.043 17.824 15.512 c 18.332\n" \ - "15.98 18.363 16.77 17.895 17.277 c 17.43 17.785 16.637 17.816 16.129\n" \ - "17.352 c 15.621 16.883 15.59 16.094 16.059 15.586 c h\n" \ - "16.059 15.586 m S\n" \ - "0.729412 0.741176 0.713725 RG 2 w\n" \ - "11.895 19.754 m 13.926 21.625 17.09 21.496 18.961 19.465 c 20.832\n" \ - "17.434 20.699 14.27 18.668 12.398 c 17.164 11.016 15.043 10.746 13.281\n" \ - "11.516 c 12.473 10.324 l 11.281 11.078 l 9.547 9.664 l 9.008 7.496 l\n" \ - "7.059 7.059 l 6.34 5.121 l 5.543 4.668 l 3.375 5.207 l 2.938 7.156 l\n" \ - "10.57 14.457 l 9.949 16.277 10.391 18.367 11.895 19.754 c h\n" \ - "11.895 19.754 m S\n" \ - "1.5 w\n" \ - "16.059 16.586 m 16.523 16.078 17.316 16.043 17.824 16.512 c 18.332\n" \ - "16.98 18.363 17.77 17.895 18.277 c 17.43 18.785 16.637 18.816 16.129\n" \ - "18.352 c 15.621 17.883 15.59 17.094 16.059 16.586 c h\n" \ - "16.059 16.586 m S\n" - -#define ANNOT_TEXT_AP_HELP \ - "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ - "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ - "l 1 21.523 2.477 23 4.301 23 c h\n" \ - "4.301 23 m f\n" \ - "0.533333 0.541176 0.521569 RG 2.5 w\n" \ - "1 J\n" \ - "1 j\n" \ - "[] 0.0 d\n" \ - "4 M 8.289 16.488 m 8.824 17.828 10.043 18.773 11.473 18.965 c 12.902 19.156\n" \ - "14.328 18.559 15.195 17.406 c 16.062 16.254 16.242 14.723 15.664 13.398\n" \ - "c S\n" \ - "0 j\n" \ - "12 8 m 12 12 16 11 16 15 c S\n" \ - "1.539286 w\n" \ - "1 j\n" \ - "q 1 0 0 -0.999991 0 24 cm\n" \ - "12.684 20.891 m 12.473 21.258 12.004 21.395 11.629 21.196 c 11.254\n" \ - "20.992 11.105 20.531 11.297 20.149 c 11.488 19.77 11.945 19.61 12.332\n" \ - "19.789 c 12.719 19.969 12.891 20.426 12.719 20.817 c S Q\n" \ - "0.729412 0.741176 0.713725 RG 2.5 w\n" \ - "8.289 17.488 m 9.109 19.539 11.438 20.535 13.488 19.711 c 15.539 18.891\n" \ - "16.535 16.562 15.711 14.512 c 15.699 14.473 15.684 14.438 15.664 14.398\n" \ - "c S\n" \ - "0 j\n" \ - "12 9 m 12 13 16 12 16 16 c S\n" \ - "1.539286 w\n" \ - "1 j\n" \ - "q 1 0 0 -0.999991 0 24 cm\n" \ - "12.684 19.891 m 12.473 20.258 12.004 20.395 11.629 20.195 c 11.254\n" \ - "19.992 11.105 19.531 11.297 19.149 c 11.488 18.77 11.945 18.61 12.332\n" \ - "18.789 c 12.719 18.969 12.891 19.426 12.719 19.817 c S Q\n" - -#define ANNOT_TEXT_AP_NEW_PARAGRAPH \ - "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ - "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ - "l 1 21.523 2.477 23 4.301 23 c h\n" \ - "4.301 23 m f\n" \ - "0.533333 0.541176 0.521569 RG 4 w\n" \ - "0 J\n" \ - "2 j\n" \ - "[] 0.0 d\n" \ - "4 M q 1 0 0 -1 0 24 cm\n" \ - "9.211 11.988 m 8.449 12.07 7.711 11.707 7.305 11.059 c 6.898 10.41\n" \ - "6.898 9.59 7.305 8.941 c 7.711 8.293 8.449 7.93 9.211 8.012 c S Q\n" \ - "1.004413 w\n" \ - "1 J\n" \ - "1 j\n" \ - "q 1 0 0 -0.991232 0 24 cm\n" \ - "18.07 11.511 m 15.113 10.014 l 12.199 11.602 l 12.711 8.323 l 10.301\n" \ - "6.045 l 13.574 5.517 l 14.996 2.522 l 16.512 5.474 l 19.801 5.899 l\n" \ - "17.461 8.252 l 18.07 11.511 l h\n" \ - "18.07 11.511 m S Q\n" \ - "2 w\n" \ - "0 j\n" \ - "11 17 m 10 17 l 10 3 l S\n" \ - "14 3 m 14 13 l S\n" \ - "0.729412 0.741176 0.713725 RG 4 w\n" \ - "0 J\n" \ - "2 j\n" \ - "q 1 0 0 -1 0 24 cm\n" \ - "9.211 10.988 m 8.109 11.105 7.125 10.309 7.012 9.211 c 6.895 8.109\n" \ - "7.691 7.125 8.789 7.012 c 8.93 6.996 9.07 6.996 9.211 7.012 c S Q\n" \ - "1.004413 w\n" \ - "1 J\n" \ - "1 j\n" \ - "q 1 0 0 -0.991232 0 24 cm\n" \ - "18.07 10.502 m 15.113 9.005 l 12.199 10.593 l 12.711 7.314 l 10.301\n" \ - "5.036 l 13.574 4.508 l 14.996 1.513 l 16.512 4.465 l 19.801 4.891 l\n" \ - "17.461 7.243 l 18.07 10.502 l h\n" \ - "18.07 10.502 m S Q\n" \ - "2 w\n" \ - "0 j\n" \ - "11 18 m 10 18 l 10 4 l S\n" \ - "14 4 m 14 14 l S\n" - -#define ANNOT_TEXT_AP_PARAGRAPH \ - "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ - "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ - "l 1 21.523 2.477 23 4.301 23 c h\n" \ - "4.301 23 m f\n" \ - "0.533333 0.541176 0.521569 RG 2 w\n" \ - "1 J\n" \ - "1 j\n" \ - "[] 0.0 d\n" \ - "4 M 15 3 m 15 18 l 11 18 l 11 3 l S\n" \ - "4 w\n" \ - "q 1 0 0 -1 0 24 cm\n" \ - "9.777 10.988 m 8.746 10.871 7.973 9.988 8 8.949 c 8.027 7.91 8.844\n" \ - "7.066 9.879 7.004 c S Q\n" \ - "0.729412 0.741176 0.713725 RG 2 w\n" \ - "15 4 m 15 19 l 11 19 l 11 4 l S\n" \ - "4 w\n" \ - "q 1 0 0 -1 0 24 cm\n" \ - "9.777 9.988 m 8.746 9.871 7.973 8.988 8 7.949 c 8.027 6.91 8.844 6.066\n" \ - "9.879 6.004 c S Q\n" - -#define ANNOT_TEXT_AP_INSERT \ - "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ - "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ - "l 1 21.523 2.477 23 4.301 23 c h\n" \ - "4.301 23 m f\n" \ - "0.533333 0.541176 0.521569 RG 2 w\n" \ - "1 J\n" \ - "0 j\n" \ - "[] 0.0 d\n" \ - "4 M 12 18.012 m 20 18 l S\n" \ - "9 10 m 17 10 l S\n" \ - "12 14.012 m 20 14 l S\n" \ - "12 6.012 m 20 6.012 l S\n" \ - "4 12 m 6 10 l 4 8 l S\n" \ - "4 12 m 4 8 l S\n" \ - "0.729412 0.741176 0.713725 RG 12 19.012 m 20 19 l S\n" \ - "9 11 m 17 11 l S\n" \ - "12 15.012 m 20 15 l S\n" \ - "12 7.012 m 20 7.012 l S\n" \ - "4 13 m 6 11 l 4 9 l S\n" \ - "4 13 m 4 9 l S\n" - -#define ANNOT_TEXT_AP_CROSS \ - "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ - "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ - "l 1 21.523 2.477 23 4.301 23 c h\n" \ - "4.301 23 m f\n" \ - "0.533333 0.541176 0.521569 RG 2.5 w\n" \ - "1 J\n" \ - "0 j\n" \ - "[] 0.0 d\n" \ - "4 M 18 5 m 6 17 l S\n" \ - "6 5 m 18 17 l S\n" \ - "0.729412 0.741176 0.713725 RG 18 6 m 6 18 l S\n" \ - "6 6 m 18 18 l S\n" - -#define ANNOT_TEXT_AP_CIRCLE \ - "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ - "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ - "l 1 21.523 2.477 23 4.301 23 c h\n" \ - "4.301 23 m f\n" \ - "0.533333 0.541176 0.521569 RG 2.5 w\n" \ - "1 J\n" \ - "1 j\n" \ - "[] 0.0 d\n" \ - "4 M 19.5 11.5 m 19.5 7.359 16.141 4 12 4 c 7.859 4 4.5 7.359 4.5 11.5 c 4.5\n" \ - "15.641 7.859 19 12 19 c 16.141 19 19.5 15.641 19.5 11.5 c h\n" \ - "19.5 11.5 m S\n" \ - "0.729412 0.741176 0.713725 RG 19.5 12.5 m 19.5 8.359 16.141 5 12 5 c\n" \ - "7.859 5 4.5 8.359 4.5 12.5 c 4.5\n" \ - "16.641 7.859 20 12 20 c 16.141 20 19.5 16.641 19.5 12.5 c h\n" \ - "19.5 12.5 m S\n" - -void AnnotText::draw(Gfx *gfx, GBool printing) { - Object obj; - double ca = 1; - - if (!isVisible (printing)) - return; - - annotLocker(); - if (appearance.isNull()) { - ca = opacity; - - appearBuf = new GooString (); - - appearBuf->append ("q\n"); - if (color) - setColor(color, gTrue); - else - appearBuf->append ("1 1 1 rg\n"); - if (!icon->cmp("Note")) - appearBuf->append (ANNOT_TEXT_AP_NOTE); - else if (!icon->cmp("Comment")) - appearBuf->append (ANNOT_TEXT_AP_COMMENT); - else if (!icon->cmp("Key")) - appearBuf->append (ANNOT_TEXT_AP_KEY); - else if (!icon->cmp("Help")) - appearBuf->append (ANNOT_TEXT_AP_HELP); - else if (!icon->cmp("NewParagraph")) - appearBuf->append (ANNOT_TEXT_AP_NEW_PARAGRAPH); - else if (!icon->cmp("Paragraph")) - appearBuf->append (ANNOT_TEXT_AP_PARAGRAPH); - else if (!icon->cmp("Insert")) - appearBuf->append (ANNOT_TEXT_AP_INSERT); - else if (!icon->cmp("Cross")) - appearBuf->append (ANNOT_TEXT_AP_CROSS); - else if (!icon->cmp("Circle")) - appearBuf->append (ANNOT_TEXT_AP_CIRCLE); - appearBuf->append ("Q\n"); - - // Force 24x24 rectangle - PDFRectangle fixedRect(rect->x1, rect->y2 - 24, rect->x1 + 24, rect->y2); - appearBBox = new AnnotAppearanceBBox(&fixedRect); - double bbox[4]; - appearBBox->getBBoxRect(bbox); - if (ca == 1) { - createForm(bbox, gFalse, NULL, &appearance); - } else { - Object aStream, resDict; - - createForm(bbox, gTrue, NULL, &aStream); - delete appearBuf; - - appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); - createForm(bbox, gFalse, &resDict, &appearance); - } - delete appearBuf; - } - - // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); - if (appearBBox) { - gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, - appearBBox->getPageXMin(), appearBBox->getPageYMin(), - appearBBox->getPageXMax(), appearBBox->getPageYMax(), - getRotation()); - } else { - gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, - rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - } - obj.free(); -} - -//------------------------------------------------------------------------ -// AnnotLink -//------------------------------------------------------------------------ -AnnotLink::AnnotLink(PDFDoc *docA, PDFRectangle *rect) : - Annot(docA, rect) { - Object obj1; - - type = typeLink; - annotObj.dictSet ("Subtype", obj1.initName ("Link")); - initialize (docA, annotObj.getDict()); -} - -AnnotLink::AnnotLink(PDFDoc *docA, Dict *dict, Object *obj) : - Annot(docA, dict, obj) { - - type = typeLink; - initialize (docA, dict); -} - -AnnotLink::~AnnotLink() { - delete action; - /* - if (uriAction) - delete uriAction; - */ - if (quadrilaterals) - delete quadrilaterals; -} - -void AnnotLink::initialize(PDFDoc *docA, Dict *dict) { - Object obj1; - - action = NULL; - - // look for destination - if (!dict->lookup("Dest", &obj1)->isNull()) { - action = LinkAction::parseDest(&obj1); - // look for action - } else { - obj1.free(); - if (dict->lookup("A", &obj1)->isDict()) { - action = LinkAction::parseAction(&obj1, doc->getCatalog()->getBaseURI()); - } - } - obj1.free(); - - if (dict->lookup("H", &obj1)->isName()) { - const char *effect = obj1.getName(); - - if (!strcmp(effect, "N")) { - linkEffect = effectNone; - } else if (!strcmp(effect, "I")) { - linkEffect = effectInvert; - } else if (!strcmp(effect, "O")) { - linkEffect = effectOutline; - } else if (!strcmp(effect, "P")) { - linkEffect = effectPush; - } else { - linkEffect = effectInvert; - } - } else { - linkEffect = effectInvert; - } - obj1.free(); - /* - if (dict->lookup("PA", &obj1)->isDict()) { - uriAction = NULL; - } else { - uriAction = NULL; - } - obj1.free(); - */ - if (dict->lookup("QuadPoints", &obj1)->isArray()) { - quadrilaterals = new AnnotQuadrilaterals(obj1.getArray(), rect); - } else { - quadrilaterals = NULL; - } - obj1.free(); - - if (dict->lookup("BS", &obj1)->isDict()) { - delete border; - border = new AnnotBorderBS(obj1.getDict()); - } else if (!border) { - border = new AnnotBorderBS(); - } - obj1.free(); -} - -void AnnotLink::draw(Gfx *gfx, GBool printing) { - Object obj; - - if (!isVisible (printing)) - return; - - annotLocker(); - // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); - gfx->drawAnnot(&obj, border, color, - rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - obj.free(); -} - -//------------------------------------------------------------------------ -// AnnotFreeText -//------------------------------------------------------------------------ -AnnotFreeText::AnnotFreeText(PDFDoc *docA, PDFRectangle *rect, GooString *da) : - AnnotMarkup(docA, rect) { - Object obj1; - - type = typeFreeText; - - annotObj.dictSet ("Subtype", obj1.initName ("FreeText")); - - Object obj2; - obj2.initString (da->copy()); - annotObj.dictSet("DA", &obj2); - - initialize (docA, annotObj.getDict()); -} - -AnnotFreeText::AnnotFreeText(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { - type = typeFreeText; - initialize(docA, dict); -} - -AnnotFreeText::~AnnotFreeText() { - delete appearanceString; - - if (styleString) - delete styleString; - - if (calloutLine) - delete calloutLine; - - if (borderEffect) - delete borderEffect; - - if (rectangle) - delete rectangle; -} - -void AnnotFreeText::initialize(PDFDoc *docA, Dict *dict) { - Object obj1; - - if (dict->lookup("DA", &obj1)->isString()) { - appearanceString = obj1.getString()->copy(); - } else { - appearanceString = new GooString(); - error(errSyntaxError, -1, "Bad appearance for annotation"); - ok = gFalse; - } - obj1.free(); - - if (dict->lookup("Q", &obj1)->isInt()) { - quadding = (AnnotFreeTextQuadding) obj1.getInt(); - } else { - quadding = quaddingLeftJustified; - } - obj1.free(); - - if (dict->lookup("DS", &obj1)->isString()) { - styleString = obj1.getString()->copy(); - } else { - styleString = NULL; - } - obj1.free(); - - if (dict->lookup("CL", &obj1)->isArray() && obj1.arrayGetLength() >= 4) { - double x1, y1, x2, y2; - Object obj2; - - (obj1.arrayGet(0, &obj2)->isNum() ? x1 = obj2.getNum() : x1 = 0); - obj2.free(); - (obj1.arrayGet(1, &obj2)->isNum() ? y1 = obj2.getNum() : y1 = 0); - obj2.free(); - (obj1.arrayGet(2, &obj2)->isNum() ? x2 = obj2.getNum() : x2 = 0); - obj2.free(); - (obj1.arrayGet(3, &obj2)->isNum() ? y2 = obj2.getNum() : y2 = 0); - obj2.free(); - - if (obj1.arrayGetLength() == 6) { - double x3, y3; - (obj1.arrayGet(4, &obj2)->isNum() ? x3 = obj2.getNum() : x3 = 0); - obj2.free(); - (obj1.arrayGet(5, &obj2)->isNum() ? y3 = obj2.getNum() : y3 = 0); - obj2.free(); - calloutLine = new AnnotCalloutMultiLine(x1, y1, x2, y2, x3, y3); - } else { - calloutLine = new AnnotCalloutLine(x1, y1, x2, y2); - } - } else { - calloutLine = NULL; - } - obj1.free(); - - if (dict->lookup("IT", &obj1)->isName()) { - const char *intentName = obj1.getName(); - - if (!strcmp(intentName, "FreeText")) { - intent = intentFreeText; - } else if (!strcmp(intentName, "FreeTextCallout")) { - intent = intentFreeTextCallout; - } else if (!strcmp(intentName, "FreeTextTypeWriter")) { - intent = intentFreeTextTypeWriter; - } else { - intent = intentFreeText; - } - } else { - intent = intentFreeText; - } - obj1.free(); - - if (dict->lookup("BS", &obj1)->isDict()) { - delete border; - border = new AnnotBorderBS(obj1.getDict()); - } else if (!border) { - border = new AnnotBorderBS(); - } - obj1.free(); - - if (dict->lookup("BE", &obj1)->isDict()) { - borderEffect = new AnnotBorderEffect(obj1.getDict()); - } else { - borderEffect = NULL; - } - obj1.free(); - - if (dict->lookup("RD", &obj1)->isArray()) { - rectangle = parseDiffRectangle(obj1.getArray(), rect); - } else { - rectangle = NULL; - } - obj1.free(); - - if (dict->lookup("LE", &obj1)->isName()) { - GooString styleName(obj1.getName()); - endStyle = parseAnnotLineEndingStyle(&styleName); - } else { - endStyle = annotLineEndingNone; - } - obj1.free(); -} - -void AnnotFreeText::setContents(GooString *new_content) { - Annot::setContents(new_content); - invalidateAppearance(); -} - -void AnnotFreeText::setAppearanceString(GooString *new_string) { - delete appearanceString; - - if (new_string) { - appearanceString = new GooString(new_string); - } else { - appearanceString = new GooString(); - } - - Object obj1; - obj1.initString(appearanceString->copy()); - update ("DA", &obj1); - invalidateAppearance(); -} - -void AnnotFreeText::setQuadding(AnnotFreeTextQuadding new_quadding) { - Object obj1; - quadding = new_quadding; - obj1.initInt((int)quadding); - update ("Q", &obj1); - invalidateAppearance(); -} - -void AnnotFreeText::setStyleString(GooString *new_string) { - delete styleString; - - if (new_string) { - styleString = new GooString(new_string); - //append the unicode marker <FE FF> if needed - if (!styleString->hasUnicodeMarker()) { - styleString->insert(0, 0xff); - styleString->insert(0, 0xfe); - } - } else { - styleString = new GooString(); - } - - Object obj1; - obj1.initString(styleString->copy()); - update ("DS", &obj1); -} - -void AnnotFreeText::setCalloutLine(AnnotCalloutLine *line) { - delete calloutLine; - - Object obj1; - if (line == NULL) { - obj1.initNull(); - calloutLine = NULL; - } else { - double x1 = line->getX1(), y1 = line->getY1(); - double x2 = line->getX2(), y2 = line->getY2(); - Object obj2; - obj1.initArray(xref); - obj1.arrayAdd( obj2.initReal(x1) ); - obj1.arrayAdd( obj2.initReal(y1) ); - obj1.arrayAdd( obj2.initReal(x2) ); - obj1.arrayAdd( obj2.initReal(y2) ); - - AnnotCalloutMultiLine *mline = dynamic_cast<AnnotCalloutMultiLine*>(line); - if (mline) { - double x3 = mline->getX3(), y3 = mline->getY3(); - obj1.arrayAdd( obj2.initReal(x3) ); - obj1.arrayAdd( obj2.initReal(y3) ); - calloutLine = new AnnotCalloutMultiLine(x1, y1, x2, y2, x3, y3); - } else { - calloutLine = new AnnotCalloutLine(x1, y1, x2, y2); - } - } - - update("CL", &obj1); - invalidateAppearance(); -} - -void AnnotFreeText::setIntent(AnnotFreeTextIntent new_intent) { - Object obj1; - - intent = new_intent; - if (new_intent == intentFreeText) - obj1.initName("FreeText"); - else if (new_intent == intentFreeTextCallout) - obj1.initName("FreeTextCallout"); - else // intentFreeTextTypeWriter - obj1.initName("FreeTextTypeWriter"); - update ("IT", &obj1); -} - -static GfxFont * createAnnotDrawFont(XRef * xref, Object *fontResDict) -{ - Ref dummyRef = { -1, -1 }; - - Object baseFontObj, subtypeObj, encodingObj; - baseFontObj.initName("Helvetica"); - subtypeObj.initName("Type0"); - encodingObj.initName("WinAnsiEncoding"); - - Object fontDictObj; - Dict *fontDict = new Dict(xref); - fontDict->decRef(); - fontDict->add(copyString("BaseFont"), &baseFontObj); - fontDict->add(copyString("Subtype"), &subtypeObj); - fontDict->add(copyString("Encoding"), &encodingObj); - fontDictObj.initDict(fontDict); - - Object fontsDictObj; - Dict *fontsDict = new Dict(xref); - fontsDict->decRef(); - fontsDict->add(copyString("AnnotDrawFont"), &fontDictObj); - fontsDictObj.initDict(fontsDict); - - Dict *dict = new Dict(xref); - dict->add(copyString("Font"), &fontsDictObj); - - fontResDict->initDict(dict); - return GfxFont::makeFont(xref, "AnnotDrawFont", dummyRef, fontDict); -} - -void AnnotFreeText::parseAppearanceString(GooString *da, double &fontsize, AnnotColor* &fontcolor) { - fontsize = -1; - fontcolor = NULL; - if (da) { - GooList * daToks = new GooList(); - int j, i = 0; - - // Tokenize - while (i < da->getLength()) { - while (i < da->getLength() && Lexer::isSpace(da->getChar(i))) { - ++i; - } - if (i < da->getLength()) { - for (j = i + 1; j < da->getLength() && !Lexer::isSpace(da->getChar(j)); ++j) { - } - daToks->append(new GooString(da, i, j - i)); - i = j; - } - } - - // Scan backwards: we are looking for the last set value - for (i = daToks->getLength()-1; i >= 0; --i) { - if (fontsize == -1) { - if (!((GooString *)daToks->get(i))->cmp("Tf") && i >= 2) { - // TODO: Font name - fontsize = gatof(( (GooString *)daToks->get(i-1) )->getCString()); - } - } - if (fontcolor == NULL) { - if (!((GooString *)daToks->get(i))->cmp("g") && i >= 1) { - fontcolor = new AnnotColor(gatof(( (GooString *)daToks->get(i-1) )->getCString())); - } else if (!((GooString *)daToks->get(i))->cmp("rg") && i >= 3) { - fontcolor = new AnnotColor(gatof(( (GooString *)daToks->get(i-3) )->getCString()), - gatof(( (GooString *)daToks->get(i-2) )->getCString()), - gatof(( (GooString *)daToks->get(i-1) )->getCString())); - } else if (!((GooString *)daToks->get(i))->cmp("k") && i >= 4) { - fontcolor = new AnnotColor(gatof(( (GooString *)daToks->get(i-4) )->getCString()), - gatof(( (GooString *)daToks->get(i-3) )->getCString()), - gatof(( (GooString *)daToks->get(i-2) )->getCString()), - gatof(( (GooString *)daToks->get(i-1) )->getCString())); - } - } - } - deleteGooList(daToks, GooString); - } -} - -void AnnotFreeText::generateFreeTextAppearance() -{ - double borderWidth, ca = opacity; - - appearBuf = new GooString (); - appearBuf->append ("q\n"); - - borderWidth = border->getWidth(); - if (borderWidth > 0) - setLineStyleForBorder(border); - - // Box size - const double width = rect->x2 - rect->x1; - const double height = rect->y2 - rect->y1; - - // Parse some properties from the appearance string - double fontsize; - AnnotColor *fontcolor; - parseAppearanceString(appearanceString, fontsize, fontcolor); - // Default values - if (fontsize <= 0) - fontsize = 10; - if (fontcolor == NULL) - fontcolor = new AnnotColor(0, 0, 0); // Black - if (!contents) - contents = new GooString (); - - // Draw box - GBool doFill = (color && color->getSpace() != AnnotColor::colorTransparent); - GBool doStroke = (borderWidth != 0); - if (doFill || doStroke) { - if (doStroke) { - setColor(fontcolor, gFalse); // Border color: same as font color - } - appearBuf->appendf ("{0:.2f} {0:.2f} {1:.2f} {2:.2f} re\n", borderWidth/2, width-borderWidth, height-borderWidth); - if (doFill) { - setColor(color, gTrue); - appearBuf->append(doStroke ? "B\n" : "f\n"); - } else { - appearBuf->append("S\n"); - } - } - - // Setup text clipping - const double textmargin = borderWidth * 2; - const double textwidth = width - 2*textmargin; - appearBuf->appendf ("{0:.2f} {0:.2f} {1:.2f} {2:.2f} re W n\n", textmargin, textwidth, height - 2*textmargin); - - Object fontResDict; - GfxFont *font = createAnnotDrawFont(xref, &fontResDict); - - // Set font state - setColor(fontcolor, gTrue); - appearBuf->appendf ("BT 1 0 0 1 {0:.2f} {1:.2f} Tm\n", textmargin, height - textmargin - fontsize * font->getDescent()); - appearBuf->appendf ("/AnnotDrawFont {0:.2f} Tf\n", fontsize); - - int i = 0; - double xposPrev = 0; - while (i < contents->getLength()) { - GooString out; - double linewidth, xpos; - layoutText(contents, &out, &i, font, &linewidth, textwidth/fontsize, NULL, gFalse); - linewidth *= fontsize; - switch (quadding) { - case quaddingCentered: - xpos = (textwidth - linewidth) / 2; - break; - case quaddingRightJustified: - xpos = textwidth - linewidth; - break; - default: // quaddingLeftJustified: - xpos = 0; - break; - } - appearBuf->appendf("{0:.2f} {1:.2f} Td\n", xpos - xposPrev, -fontsize); - writeString(&out, appearBuf); - appearBuf->append("Tj\n"); - xposPrev = xpos; - } - - font->decRefCnt(); - delete fontcolor; - appearBuf->append ("ET Q\n"); - - double bbox[4]; - bbox[0] = bbox[1] = 0; - bbox[2] = rect->x2 - rect->x1; - bbox[3] = rect->y2 - rect->y1; - - if (ca == 1) { - createForm(bbox, gFalse, &fontResDict, &appearance); - } else { - Object aStream, resDict; - - createForm(bbox, gTrue, &fontResDict, &aStream); - delete appearBuf; - - appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); - createForm(bbox, gFalse, &resDict, &appearance); - } - delete appearBuf; -} - -void AnnotFreeText::draw(Gfx *gfx, GBool printing) { - Object obj; - - if (!isVisible (printing)) - return; - - annotLocker(); - if (appearance.isNull()) { - generateFreeTextAppearance(); - } - - // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); - gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, - rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - obj.free(); -} - -// Before retrieving the res dict, regenerate the appearance stream if needed, -// because AnnotFreeText::draw needs to store font info in the res dict -Object *AnnotFreeText::getAppearanceResDict(Object *dest) { - if (appearance.isNull()) { - generateFreeTextAppearance(); - } - return Annot::getAppearanceResDict(dest); -} - -//------------------------------------------------------------------------ -// AnnotLine -//------------------------------------------------------------------------ - -AnnotLine::AnnotLine(PDFDoc *docA, PDFRectangle *rect) : - AnnotMarkup(docA, rect) { - Object obj1; - - type = typeLine; - annotObj.dictSet ("Subtype", obj1.initName ("Line")); - - initialize (docA, annotObj.getDict()); -} - -AnnotLine::AnnotLine(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { - type = typeLine; - initialize(docA, dict); -} - -AnnotLine::~AnnotLine() { - delete coord1; - delete coord2; - - if (interiorColor) - delete interiorColor; - - if (measure) - delete measure; -} - -void AnnotLine::initialize(PDFDoc *docA, Dict *dict) { - Object obj1; - - if (dict->lookup("L", &obj1)->isArray() && obj1.arrayGetLength() == 4) { - Object obj2; - double x1, y1, x2, y2; - - (obj1.arrayGet(0, &obj2)->isNum() ? x1 = obj2.getNum() : x1 = 0); - obj2.free(); - (obj1.arrayGet(1, &obj2)->isNum() ? y1 = obj2.getNum() : y1 = 0); - obj2.free(); - (obj1.arrayGet(2, &obj2)->isNum() ? x2 = obj2.getNum() : x2 = 0); - obj2.free(); - (obj1.arrayGet(3, &obj2)->isNum() ? y2 = obj2.getNum() : y2 = 0); - obj2.free(); - - coord1 = new AnnotCoord(x1, y1); - coord2 = new AnnotCoord(x2, y2); - } else { - coord1 = new AnnotCoord(); - coord2 = new AnnotCoord(); - } - obj1.free(); - - if (dict->lookup("LE", &obj1)->isArray() && obj1.arrayGetLength() == 2) { - Object obj2; - - if(obj1.arrayGet(0, &obj2)->isString()) - startStyle = parseAnnotLineEndingStyle(obj2.getString()); - else - startStyle = annotLineEndingNone; - obj2.free(); - - if(obj1.arrayGet(1, &obj2)->isString()) - endStyle = parseAnnotLineEndingStyle(obj2.getString()); - else - endStyle = annotLineEndingNone; - obj2.free(); - - } else { - startStyle = endStyle = annotLineEndingNone; - } - obj1.free(); - - if (dict->lookup("IC", &obj1)->isArray()) { - interiorColor = new AnnotColor(obj1.getArray()); - } else { - interiorColor = NULL; - } - obj1.free(); - - if (dict->lookup("LL", &obj1)->isNum()) { - leaderLineLength = obj1.getNum(); - } else { - leaderLineLength = 0; - } - obj1.free(); - - if (dict->lookup("LLE", &obj1)->isNum()) { - leaderLineExtension = obj1.getNum(); - - if (leaderLineExtension < 0) - leaderLineExtension = 0; - } else { - leaderLineExtension = 0; - } - obj1.free(); - - if (dict->lookup("Cap", &obj1)->isBool()) { - caption = obj1.getBool(); - } else { - caption = gFalse; - } - obj1.free(); - - if (dict->lookup("IT", &obj1)->isName()) { - const char *intentName = obj1.getName(); - - if(!strcmp(intentName, "LineArrow")) { - intent = intentLineArrow; - } else if(!strcmp(intentName, "LineDimension")) { - intent = intentLineDimension; - } else { - intent = intentLineArrow; - } - } else { - intent = intentLineArrow; - } - obj1.free(); - - if (dict->lookup("LLO", &obj1)->isNum()) { - leaderLineOffset = obj1.getNum(); - - if (leaderLineOffset < 0) - leaderLineOffset = 0; - } else { - leaderLineOffset = 0; - } - obj1.free(); - - if (dict->lookup("CP", &obj1)->isName()) { - const char *captionName = obj1.getName(); - - if(!strcmp(captionName, "Inline")) { - captionPos = captionPosInline; - } else if(!strcmp(captionName, "Top")) { - captionPos = captionPosTop; - } else { - captionPos = captionPosInline; - } - } else { - captionPos = captionPosInline; - } - obj1.free(); - - if (dict->lookup("Measure", &obj1)->isDict()) { - measure = NULL; - } else { - measure = NULL; - } - obj1.free(); - - if ((dict->lookup("CO", &obj1)->isArray()) && (obj1.arrayGetLength() == 2)) { - Object obj2; - - (obj1.arrayGet(0, &obj2)->isNum() ? captionTextHorizontal = obj2.getNum() : - captionTextHorizontal = 0); - obj2.free(); - (obj1.arrayGet(1, &obj2)->isNum() ? captionTextVertical = obj2.getNum() : - captionTextVertical = 0); - obj2.free(); - } else { - captionTextHorizontal = captionTextVertical = 0; - } - obj1.free(); - - if (dict->lookup("BS", &obj1)->isDict()) { - delete border; - border = new AnnotBorderBS(obj1.getDict()); - } else if (!border) { - border = new AnnotBorderBS(); - } - obj1.free(); -} - -void AnnotLine::setContents(GooString *new_content) { - Annot::setContents(new_content); - if (caption) - invalidateAppearance(); -} - -void AnnotLine::setVertices(double x1, double y1, double x2, double y2) { - Object obj1, obj2; - - delete coord1; - coord1 = new AnnotCoord(x1, y1); - delete coord2; - coord2 = new AnnotCoord(x2, y2); - - obj1.initArray(xref); - obj1.arrayAdd( obj2.initReal(x1) ); - obj1.arrayAdd( obj2.initReal(y1) ); - obj1.arrayAdd( obj2.initReal(x2) ); - obj1.arrayAdd( obj2.initReal(y2) ); - - update("L", &obj1); - invalidateAppearance(); -} - -void AnnotLine::setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end) { - Object obj1, obj2; - - startStyle = start; - endStyle = end; - - obj1.initArray(xref); - obj1.arrayAdd( obj2.initName(convertAnnotLineEndingStyle( startStyle )) ); - obj1.arrayAdd( obj2.initName(convertAnnotLineEndingStyle( endStyle )) ); - - update("LE", &obj1); - invalidateAppearance(); -} - -void AnnotLine::setInteriorColor(AnnotColor *new_color) { - delete interiorColor; - - if (new_color) { - Object obj1; - new_color->writeToObject(xref, &obj1); - update ("IC", &obj1); - interiorColor = new_color; - } else { - interiorColor = NULL; - } - invalidateAppearance(); -} - -void AnnotLine::setLeaderLineLength(double len) { - Object obj1; - - leaderLineLength = len; - obj1.initReal(len); - update ("LL", &obj1); - invalidateAppearance(); -} - -void AnnotLine::setLeaderLineExtension(double len) { - Object obj1; - - leaderLineExtension = len; - obj1.initReal(len); - update ("LLE", &obj1); - - // LL is required if LLE is present - obj1.initReal(leaderLineLength); - update ("LL", &obj1); - invalidateAppearance(); -} - -void AnnotLine::setCaption(bool new_cap) { - Object obj1; - - caption = new_cap; - obj1.initBool(new_cap); - update ("Cap", &obj1); - invalidateAppearance(); -} - -void AnnotLine::setIntent(AnnotLineIntent new_intent) { - Object obj1; - - intent = new_intent; - if (new_intent == intentLineArrow) - obj1.initName("LineArrow"); - else // intentLineDimension - obj1.initName("LineDimension"); - update ("IT", &obj1); -} - -void AnnotLine::generateLineAppearance() -{ - double borderWidth, ca = opacity; - - appearBBox = new AnnotAppearanceBBox(rect); - appearBuf = new GooString (); - appearBuf->append ("q\n"); - if (color) { - setColor(color, gFalse); - } - - setLineStyleForBorder(border); - borderWidth = border->getWidth(); - appearBBox->setBorderWidth(std::max(1., borderWidth)); - - const double x1 = coord1->getX(); - const double y1 = coord1->getY(); - const double x2 = coord2->getX(); - const double y2 = coord2->getY(); - - // Main segment length - const double main_len = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)); - - // Main segment becomes positive x direction, coord1 becomes (0,0) - Matrix matr; - const double angle = atan2(y2 - y1, x2 - x1); - matr.m[0] = matr.m[3] = cos(angle); - matr.m[1] = sin(angle); - matr.m[2] = -matr.m[1]; - matr.m[4] = x1-rect->x1; - matr.m[5] = y1-rect->y1; - - double tx, ty, captionwidth = 0, captionheight = 0; - AnnotLineCaptionPos actualCaptionPos = captionPos; - const double fontsize = 9; - const double captionhmargin = 2; // Left and right margin (inline caption only) - const double captionmaxwidth = main_len - 2 * captionhmargin; - - Object fontResDict; - GfxFont *font; - - // Calculate caption width and height - if (caption) { - font = createAnnotDrawFont(xref, &fontResDict); - int lines = 0; - int i = 0; - while (i < contents->getLength()) { - GooString out; - double linewidth; - layoutText(contents, &out, &i, font, &linewidth, 0, NULL, gFalse); - linewidth *= fontsize; - if (linewidth > captionwidth) { - captionwidth = linewidth; - } - ++lines; - } - captionheight = lines * fontsize; - // If text is longer than available space, turn into captionPosTop - if (captionwidth > captionmaxwidth) { - actualCaptionPos = captionPosTop; - } - } else { - fontResDict.initNull(); - font = NULL; - } - - // Draw main segment - matr.transform (0, leaderLineLength, &tx, &ty); - appearBuf->appendf ("{0:.2f} {1:.2f} m\n", tx, ty); - appearBBox->extendTo (tx, ty); - - if (captionwidth != 0 && actualCaptionPos == captionPosInline) { // Break in the middle - matr.transform ((main_len-captionwidth)/2 - captionhmargin, leaderLineLength, &tx, &ty); - appearBuf->appendf ("{0:.2f} {1:.2f} l S\n", tx, ty); - - matr.transform ((main_len+captionwidth)/2 + captionhmargin, leaderLineLength, &tx, &ty); - appearBuf->appendf ("{0:.2f} {1:.2f} m\n", tx, ty); - } - - matr.transform (main_len, leaderLineLength, &tx, &ty); - appearBuf->appendf ("{0:.2f} {1:.2f} l S\n", tx, ty); - appearBBox->extendTo (tx, ty); - - // TODO: Line endings - - // Draw caption text - if (caption) { - double tlx = (main_len - captionwidth) / 2, tly; // Top-left coords - if (actualCaptionPos == captionPosInline) { - tly = leaderLineLength + captionheight / 2; - } else { - tly = leaderLineLength + captionheight + 2*borderWidth; - } - - tlx += captionTextHorizontal; - tly += captionTextVertical; - - // Adjust bounding box - matr.transform (tlx, tly-captionheight, &tx, &ty); - appearBBox->extendTo (tx, ty); - matr.transform (tlx+captionwidth, tly-captionheight, &tx, &ty); - appearBBox->extendTo (tx, ty); - matr.transform (tlx+captionwidth, tly, &tx, &ty); - appearBBox->extendTo (tx, ty); - matr.transform (tlx, tly, &tx, &ty); - appearBBox->extendTo (tx, ty); - - // Setup text state (reusing transformed top-left coord) - appearBuf->appendf ("0 g BT /AnnotDrawFont {0:.2f} Tf\n", fontsize); // Font color: black - appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} Tm\n", - matr.m[0], matr.m[1], matr.m[2], matr.m[3], tx, ty); - appearBuf->appendf ("0 {0:.2f} Td\n", -fontsize * font->getDescent()); - // Draw text - int i = 0; - double xposPrev = 0; - while (i < contents->getLength()) { - GooString out; - double linewidth, xpos; - layoutText(contents, &out, &i, font, &linewidth, 0, NULL, gFalse); - linewidth *= fontsize; - xpos = (captionwidth - linewidth) / 2; - appearBuf->appendf("{0:.2f} {1:.2f} Td\n", xpos - xposPrev, -fontsize); - writeString(&out, appearBuf); - appearBuf->append ("Tj\n"); - xposPrev = xpos; - } - appearBuf->append ("ET\n"); - font->decRefCnt(); - } - - // Draw leader lines - double ll_len = fabs(leaderLineLength) + leaderLineExtension; - double sign = leaderLineLength >= 0 ? 1 : -1; - if (ll_len != 0) { - matr.transform (0, 0, &tx, &ty); - appearBuf->appendf ("{0:.2f} {1:.2f} m\n", tx, ty); - appearBBox->extendTo (tx, ty); - matr.transform (0, sign*ll_len, &tx, &ty); - appearBuf->appendf ("{0:.2f} {1:.2f} l S\n", tx, ty); - appearBBox->extendTo (tx, ty); - - matr.transform (main_len, 0, &tx, &ty); - appearBuf->appendf ("{0:.2f} {1:.2f} m\n", tx, ty); - appearBBox->extendTo (tx, ty); - matr.transform (main_len, sign*ll_len, &tx, &ty); - appearBuf->appendf ("{0:.2f} {1:.2f} l S\n", tx, ty); - appearBBox->extendTo (tx, ty); - } - - appearBuf->append ("Q\n"); - - double bbox[4]; - appearBBox->getBBoxRect(bbox); - if (ca == 1) { - createForm(bbox, gFalse, &fontResDict, &appearance); - } else { - Object aStream, resDict; - - createForm(bbox, gTrue, &fontResDict, &aStream); - delete appearBuf; - - appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); - createForm(bbox, gFalse, &resDict, &appearance); - } - delete appearBuf; -} - -void AnnotLine::draw(Gfx *gfx, GBool printing) { - Object obj; - - if (!isVisible (printing)) - return; - - annotLocker(); - if (appearance.isNull()) { - generateLineAppearance(); - } - - // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); - if (appearBBox) { - gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, - appearBBox->getPageXMin(), appearBBox->getPageYMin(), - appearBBox->getPageXMax(), appearBBox->getPageYMax(), - getRotation()); - } else { - gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, - rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - } - obj.free(); -} - -// Before retrieving the res dict, regenerate the appearance stream if needed, -// because AnnotLine::draw may need to store font info in the res dict -Object *AnnotLine::getAppearanceResDict(Object *dest) { - if (appearance.isNull()) { - generateLineAppearance(); - } - return Annot::getAppearanceResDict(dest); -} - -//------------------------------------------------------------------------ -// AnnotTextMarkup -//------------------------------------------------------------------------ -AnnotTextMarkup::AnnotTextMarkup(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType) : - AnnotMarkup(docA, rect) { - Object obj1; - - switch (subType) { - case typeHighlight: - annotObj.dictSet ("Subtype", obj1.initName ("Highlight")); - break; - case typeUnderline: - annotObj.dictSet ("Subtype", obj1.initName ("Underline")); - break; - case typeSquiggly: - annotObj.dictSet ("Subtype", obj1.initName ("Squiggly")); - break; - case typeStrikeOut: - annotObj.dictSet ("Subtype", obj1.initName ("StrikeOut")); - break; - default: - assert (0 && "Invalid subtype for AnnotTextMarkup\n"); - } - - // Store dummy quadrilateral with null coordinates - Object obj2, obj3; - obj2.initArray (doc->getXRef()); - for (int i = 0; i < 4*2; ++i) { - obj2.arrayAdd (obj3.initReal (0)); - } - annotObj.dictSet ("QuadPoints", &obj2); - - initialize(docA, annotObj.getDict()); -} - -AnnotTextMarkup::AnnotTextMarkup(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { - // the real type will be read in initialize() - type = typeHighlight; - initialize(docA, dict); -} - -void AnnotTextMarkup::initialize(PDFDoc *docA, Dict *dict) { - Object obj1; - - if (dict->lookup("Subtype", &obj1)->isName()) { - GooString typeName(obj1.getName()); - if (!typeName.cmp("Highlight")) { - type = typeHighlight; - } else if (!typeName.cmp("Underline")) { - type = typeUnderline; - } else if (!typeName.cmp("Squiggly")) { - type = typeSquiggly; - } else if (!typeName.cmp("StrikeOut")) { - type = typeStrikeOut; - } - } - obj1.free(); - - if(dict->lookup("QuadPoints", &obj1)->isArray()) { - quadrilaterals = new AnnotQuadrilaterals(obj1.getArray(), rect); - } else { - error(errSyntaxError, -1, "Bad Annot Text Markup QuadPoints"); - quadrilaterals = NULL; - ok = gFalse; - } - obj1.free(); -} - -AnnotTextMarkup::~AnnotTextMarkup() { - if(quadrilaterals) { - delete quadrilaterals; - } -} - -void AnnotTextMarkup::setType(AnnotSubtype new_type) { - Object obj1; - - switch (new_type) { - case typeHighlight: - obj1.initName("Highlight"); - break; - case typeUnderline: - obj1.initName("Underline"); - break; - case typeSquiggly: - obj1.initName("Squiggly"); - break; - case typeStrikeOut: - obj1.initName("StrikeOut"); - break; - default: - assert(!"Invalid subtype"); - } - - type = new_type; - update("Subtype", &obj1); - invalidateAppearance(); -} - -void AnnotTextMarkup::setQuadrilaterals(AnnotQuadrilaterals *quadPoints) { - Object obj1, obj2; - obj1.initArray (xref); - - for (int i = 0; i < quadPoints->getQuadrilateralsLength(); ++i) { - obj1.arrayAdd (obj2.initReal (quadPoints->getX1(i))); - obj1.arrayAdd (obj2.initReal (quadPoints->getY1(i))); - obj1.arrayAdd (obj2.initReal (quadPoints->getX2(i))); - obj1.arrayAdd (obj2.initReal (quadPoints->getY2(i))); - obj1.arrayAdd (obj2.initReal (quadPoints->getX3(i))); - obj1.arrayAdd (obj2.initReal (quadPoints->getY3(i))); - obj1.arrayAdd (obj2.initReal (quadPoints->getX4(i))); - obj1.arrayAdd (obj2.initReal (quadPoints->getY4(i))); - } - - delete quadrilaterals; - quadrilaterals = new AnnotQuadrilaterals(obj1.getArray(), rect); - - annotObj.dictSet ("QuadPoints", &obj1); - invalidateAppearance(); -} - -void AnnotTextMarkup::draw(Gfx *gfx, GBool printing) { - Object obj; - double ca = 1; - int i; - Object obj1, obj2; - - if (!isVisible (printing)) - return; - - annotLocker(); - if (appearance.isNull() || type == typeHighlight) { - GBool blendMultiply = gTrue; - ca = opacity; - - appearBuf = new GooString (); - appearBuf->append ("q\n"); - - /* Adjust BBox */ - delete appearBBox; - appearBBox = new AnnotAppearanceBBox(rect); - for (i = 0; i < quadrilaterals->getQuadrilateralsLength(); ++i) { - appearBBox->extendTo (quadrilaterals->getX1(i) - rect->x1, quadrilaterals->getY1(i) - rect->y1); - appearBBox->extendTo (quadrilaterals->getX2(i) - rect->x1, quadrilaterals->getY2(i) - rect->y1); - appearBBox->extendTo (quadrilaterals->getX3(i) - rect->x1, quadrilaterals->getY3(i) - rect->y1); - appearBBox->extendTo (quadrilaterals->getX4(i) - rect->x1, quadrilaterals->getY4(i) - rect->y1); - } - - switch (type) { - case typeUnderline: - if (color) { - setColor(color, gFalse); - } - appearBuf->append ("[] 0 d 1 w\n"); - - for (i = 0; i < quadrilaterals->getQuadrilateralsLength(); ++i) { - double x3, y3, x4, y4; - - x3 = quadrilaterals->getX3(i); - y3 = quadrilaterals->getY3(i); - x4 = quadrilaterals->getX4(i); - y4 = quadrilaterals->getY4(i); - - appearBuf->appendf ("{0:.2f} {1:.2f} m\n", x3, y3); - appearBuf->appendf ("{0:.2f} {1:.2f} l\n", x4, y4); - appearBuf->append ("S\n"); - } - break; - case typeStrikeOut: - if (color) { - setColor(color, gFalse); - } - blendMultiply = gFalse; - appearBuf->append ("[] 0 d 1 w\n"); - - for (i = 0; i < quadrilaterals->getQuadrilateralsLength(); ++i) { - double x1, y1, x2, y2; - double x3, y3, x4, y4; - - x1 = quadrilaterals->getX1(i); - y1 = quadrilaterals->getY1(i); - x2 = quadrilaterals->getX2(i); - y2 = quadrilaterals->getY2(i); - - x3 = quadrilaterals->getX3(i); - y3 = quadrilaterals->getY3(i); - x4 = quadrilaterals->getX4(i); - y4 = quadrilaterals->getY4(i); - - appearBuf->appendf ("{0:.2f} {1:.2f} m\n", (x1+x3)/2., (y1+y3)/2.); - appearBuf->appendf ("{0:.2f} {1:.2f} l\n", (x2+x4)/2., (y2+y4)/2.); - appearBuf->append ("S\n"); - } - break; - case typeSquiggly: - if (color) { - setColor(color, gFalse); - } - appearBuf->append ("[] 0 d 1 w\n"); - - for (i = 0; i < quadrilaterals->getQuadrilateralsLength(); ++i) { - double x1, y1, x2, y3; - double h6; - - x1 = quadrilaterals->getX1(i); - y1 = quadrilaterals->getY1(i); - x2 = quadrilaterals->getX2(i); - y3 = quadrilaterals->getY3(i); - h6 = (y1 - y3) / 6.0; - - appearBuf->appendf ("{0:.2f} {1:.2f} m\n", x1, y3+h6); - bool down = false; - do { - down = !down; // Zigzag line - x1 += 2; - appearBuf->appendf ("{0:.2f} {1:.2f} l\n", x1, y3 + (down ? 0 : h6)); - } while (x1 < x2); - appearBuf->append ("S\n"); - } - break; - default: - case typeHighlight: - appearance.free(); - - if (color) - setColor(color, gTrue); - - double biggestBorder = 0; - for (i = 0; i < quadrilaterals->getQuadrilateralsLength(); ++i) { - double x1, y1, x2, y2, x3, y3, x4, y4; - double h4; - - x1 = quadrilaterals->getX1(i); - y1 = quadrilaterals->getY1(i); - x2 = quadrilaterals->getX2(i); - y2 = quadrilaterals->getY2(i); - x3 = quadrilaterals->getX3(i); - y3 = quadrilaterals->getY3(i); - x4 = quadrilaterals->getX4(i); - y4 = quadrilaterals->getY4(i); - h4 = fabs(y1 - y3) / 4.0; - - if (h4 > biggestBorder) { - biggestBorder = h4; - } - - appearBuf->appendf ("{0:.2f} {1:.2f} m\n", x3, y3); - appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", - x3 - h4, y3 + h4, x1 - h4, y1 - h4, x1, y1); - appearBuf->appendf ("{0:.2f} {1:.2f} l\n", x2, y2); - appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", - x2 + h4, y2 - h4, x4 + h4, y4 + h4, x4, y4); - appearBuf->append ("f\n"); - } - appearBBox->setBorderWidth(biggestBorder); - break; - } - appearBuf->append ("Q\n"); - - Object aStream, resDict; - double bbox[4]; - bbox[0] = appearBBox->getPageXMin(); - bbox[1] = appearBBox->getPageYMin(); - bbox[2] = appearBBox->getPageXMax(); - bbox[3] = appearBBox->getPageYMax(); - createForm(bbox, gTrue, NULL, &aStream); - delete appearBuf; - - appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", 1, blendMultiply ? "Multiply" : NULL, &resDict); - if (ca == 1) { - createForm(bbox, gFalse, &resDict, &appearance); - } else { - createForm(bbox, gTrue, &resDict, &aStream); - delete appearBuf; - - appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); - createForm(bbox, gFalse, &resDict, &appearance); - } - delete appearBuf; - } - - // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); - if (appearBBox) { - gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, - appearBBox->getPageXMin(), appearBBox->getPageYMin(), - appearBBox->getPageXMax(), appearBBox->getPageYMax(), - getRotation()); - } else { - gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, - rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - } - obj.free(); -} - -//------------------------------------------------------------------------ -// AnnotWidget -//------------------------------------------------------------------------ - -AnnotWidget::AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj) : - Annot(docA, dict, obj) { - type = typeWidget; - field = NULL; - initialize(docA, dict); -} - -AnnotWidget::AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj, FormField *fieldA) : - Annot(docA, dict, obj) { - type = typeWidget; - field = fieldA; - initialize(docA, dict); -} - -AnnotWidget::~AnnotWidget() { - if (appearCharacs) - delete appearCharacs; - - if (action) - delete action; - - additionalActions.free(); - - if (parent) - delete parent; -} - -void AnnotWidget::initialize(PDFDoc *docA, Dict *dict) { - Object obj1; - - form = doc->getCatalog()->getForm(); - - if(dict->lookup("H", &obj1)->isName()) { - const char *modeName = obj1.getName(); - - if(!strcmp(modeName, "N")) { - mode = highlightModeNone; - } else if(!strcmp(modeName, "O")) { - mode = highlightModeOutline; - } else if(!strcmp(modeName, "P") || !strcmp(modeName, "T")) { - mode = highlightModePush; - } else { - mode = highlightModeInvert; - } - } else { - mode = highlightModeInvert; - } - obj1.free(); - - if(dict->lookup("MK", &obj1)->isDict()) { - appearCharacs = new AnnotAppearanceCharacs(obj1.getDict()); - } else { - appearCharacs = NULL; - } - obj1.free(); - - action = NULL; - if(dict->lookup("A", &obj1)->isDict()) { - action = LinkAction::parseAction(&obj1, doc->getCatalog()->getBaseURI()); - } - obj1.free(); - - dict->lookupNF("AA", &additionalActions); - - if(dict->lookup("Parent", &obj1)->isDict()) { - parent = NULL; - } else { - parent = NULL; - } - obj1.free(); - - if (dict->lookup("BS", &obj1)->isDict()) { - delete border; - border = new AnnotBorderBS(obj1.getDict()); - } - obj1.free(); - - updatedAppearanceStream.num = updatedAppearanceStream.gen = -1; -} - -LinkAction* AnnotWidget::getAdditionalAction(AdditionalActionsType type) -{ - return ::getAdditionalAction(type, &additionalActions, doc); -} - -LinkAction* AnnotWidget::getFormAdditionalAction(FormAdditionalActionsType type) -{ - return ::getFormAdditionalAction(type, &additionalActions, doc); -} - -// Grand unified handler for preparing text strings to be drawn into form -// fields. Takes as input a text string (in PDFDocEncoding or UTF-16). -// Converts some or all of this string to the appropriate encoding for the -// specified font, and computes the width of the text. Can optionally stop -// converting when a specified width has been reached, to perform line-breaking -// for multi-line fields. -// -// Parameters: -// text: input text string to convert -// outBuf: buffer for writing re-encoded string -// i: index at which to start converting; will be updated to point just after -// last character processed -// font: the font which will be used for display -// width: computed width (unscaled by font size) will be stored here -// widthLimit: if non-zero, stop converting to keep width under this value -// (should be scaled down by font size) -// charCount: count of number of characters will be stored here -// noReencode: if set, do not try to translate the character encoding -// (useful for Zapf Dingbats or other unusual encodings) -// can only be used with simple fonts, not CID-keyed fonts -// -// TODO: Handle surrogate pairs in UTF-16. -// Should be able to generate output for any CID-keyed font. -// Doesn't handle vertical fonts--should it? -void Annot::layoutText(GooString *text, GooString *outBuf, int *i, - GfxFont *font, double *width, double widthLimit, - int *charCount, GBool noReencode) -{ - CharCode c; - Unicode uChar, *uAux; - double w = 0.0; - int uLen, n; - double dx, dy, ox, oy; - GBool unicode = text->hasUnicodeMarker(); - GBool spacePrev; // previous character was a space - - // State for backtracking when more text has been processed than fits within - // widthLimit. We track for both input (text) and output (outBuf) the offset - // to the first character to discard. - // - // We keep track of several points: - // 1 - end of previous completed word which fits - // 2 - previous character which fit - int last_i1, last_i2, last_o1, last_o2; - - if (unicode && text->getLength() % 2 != 0) { - error(errSyntaxError, -1, "AnnotWidget::layoutText, bad unicode string"); - return; - } - - // skip Unicode marker on string if needed - if (unicode && *i == 0) - *i = 2; - - // Start decoding and copying characters, until either: - // we reach the end of the string - // we reach the maximum width - // we reach a newline character - // As we copy characters, keep track of the last full word to fit, so that we - // can backtrack if we exceed the maximum width. - last_i1 = last_i2 = *i; - last_o1 = last_o2 = 0; - spacePrev = gFalse; - outBuf->clear(); - - while (*i < text->getLength()) { - last_i2 = *i; - last_o2 = outBuf->getLength(); - - if (unicode) { - uChar = (unsigned char)(text->getChar(*i)) << 8; - uChar += (unsigned char)(text->getChar(*i + 1)); - *i += 2; - } else { - if (noReencode) - uChar = text->getChar(*i) & 0xff; - else - uChar = pdfDocEncoding[text->getChar(*i) & 0xff]; - *i += 1; - } - - // Explicit line break? - if (uChar == '\r' || uChar == '\n') { - // Treat a <CR><LF> sequence as a single line break - if (uChar == '\r' && *i < text->getLength()) { - if (unicode && text->getChar(*i) == '\0' - && text->getChar(*i + 1) == '\n') - *i += 2; - else if (!unicode && text->getChar(*i) == '\n') - *i += 1; - } - - break; - } - - if (noReencode) { - outBuf->append(uChar); - } else { - CharCodeToUnicode *ccToUnicode = font->getToUnicode(); - if (!ccToUnicode) { - // This assumes an identity CMap. - outBuf->append((uChar >> 8) & 0xff); - outBuf->append(uChar & 0xff); - } else if (ccToUnicode->mapToCharCode(&uChar, &c, 2)) { - ccToUnicode->decRefCnt(); - if (font->isCIDFont()) { - // TODO: This assumes an identity CMap. It should be extended to - // handle the general case. - outBuf->append((c >> 8) & 0xff); - outBuf->append(c & 0xff); - } else { - // 8-bit font - outBuf->append(c); - } - } else { - ccToUnicode->decRefCnt(); - error(errSyntaxError, -1, "AnnotWidget::layoutText, cannot convert U+{0:04uX}", uChar); - } - } - - // If we see a space, then we have a linebreak opportunity. - if (uChar == ' ') { - last_i1 = *i; - if (!spacePrev) - last_o1 = last_o2; - spacePrev = gTrue; - } else { - spacePrev = gFalse; - } - - // Compute width of character just output - if (outBuf->getLength() > last_o2) { - dx = 0.0; - font->getNextChar(outBuf->getCString() + last_o2, - outBuf->getLength() - last_o2, - &c, &uAux, &uLen, &dx, &dy, &ox, &oy); - w += dx; - } - - // Current line over-full now? - if (widthLimit > 0.0 && w > widthLimit) { - if (last_o1 > 0) { - // Back up to the previous word which fit, if there was a previous - // word. - *i = last_i1; - outBuf->del(last_o1, outBuf->getLength() - last_o1); - } else if (last_o2 > 0) { - // Otherwise, back up to the previous character (in the only word on - // this line) - *i = last_i2; - outBuf->del(last_o2, outBuf->getLength() - last_o2); - } else { - // Otherwise, we were trying to fit the first character; include it - // anyway even if it overflows the space--no updates to make. - } - break; - } - } - - // If splitting input into lines because we reached the width limit, then - // consume any remaining trailing spaces that would go on this line from the - // input. If in doing so we reach a newline, consume that also. This code - // won't run if we stopped at a newline above, since in that case w <= - // widthLimit still. - if (widthLimit > 0.0 && w > widthLimit) { - if (unicode) { - while (*i < text->getLength() - && text->getChar(*i) == '\0' && text->getChar(*i + 1) == ' ') - *i += 2; - if (*i < text->getLength() - && text->getChar(*i) == '\0' && text->getChar(*i + 1) == '\r') - *i += 2; - if (*i < text->getLength() - && text->getChar(*i) == '\0' && text->getChar(*i + 1) == '\n') - *i += 2; - } else { - while (*i < text->getLength() && text->getChar(*i) == ' ') - *i += 1; - if (*i < text->getLength() && text->getChar(*i) == '\r') - *i += 1; - if (*i < text->getLength() && text->getChar(*i) == '\n') - *i += 1; - } - } - - // Compute the actual width and character count of the final string, based on - // breakpoint, if this information is requested by the caller. - if (width != NULL || charCount != NULL) { - char *s = outBuf->getCString(); - int len = outBuf->getLength(); - - if (width != NULL) - *width = 0.0; - if (charCount != NULL) - *charCount = 0; - - while (len > 0) { - dx = 0.0; - n = font->getNextChar(s, len, &c, &uAux, &uLen, &dx, &dy, &ox, &oy); - - if (n == 0) { - break; - } - - if (width != NULL) - *width += dx; - if (charCount != NULL) - *charCount += 1; - - s += n; - len -= n; - } - } -} - -// Copy the given string to appearBuf, adding parentheses around it and -// escaping characters as appropriate. -void Annot::writeString(GooString *str, GooString *appearBuf) -{ - char c; - int i; - - appearBuf->append('('); - - for (i = 0; i < str->getLength(); ++i) { - c = str->getChar(i); - if (c == '(' || c == ')' || c == '\\') { - appearBuf->append('\\'); - appearBuf->append(c); - } else if (c < 0x20) { - appearBuf->appendf("\\{0:03o}", (unsigned char)c); - } else { - appearBuf->append(c); - } - } - - appearBuf->append(')'); -} - -// Draw the variable text or caption for a field. -void AnnotWidget::drawText(GooString *text, GooString *da, GfxResources *resources, - GBool multiline, int comb, int quadding, - GBool txField, GBool forceZapfDingbats, - GBool password) { - GooList *daToks; - GooString *tok, *convertedText; - GfxFont *font; - double dx, dy; - double fontSize, fontSize2, borderWidth, x, xPrev, y, w, wMax; - int tfPos, tmPos, i, j; - int rot; - GBool freeText = gFalse; // true if text should be freed before return - GBool freeFont = gFalse; - - //~ if there is no MK entry, this should use the existing content stream, - //~ and only replace the marked content portion of it - //~ (this is only relevant for Tx fields) - - // parse the default appearance string - tfPos = tmPos = -1; - if (da) { - daToks = new GooList(); - i = 0; - while (i < da->getLength()) { - while (i < da->getLength() && Lexer::isSpace(da->getChar(i))) { - ++i; - } - if (i < da->getLength()) { - for (j = i + 1; - j < da->getLength() && !Lexer::isSpace(da->getChar(j)); - ++j) ; - daToks->append(new GooString(da, i, j - i)); - i = j; - } - } - for (i = 2; i < daToks->getLength(); ++i) { - if (i >= 2 && !((GooString *)daToks->get(i))->cmp("Tf")) { - tfPos = i - 2; - } else if (i >= 6 && !((GooString *)daToks->get(i))->cmp("Tm")) { - tmPos = i - 6; - } - } - } else { - daToks = NULL; - } - - // force ZapfDingbats - if (forceZapfDingbats) { - if (tfPos >= 0) { - tok = (GooString *)daToks->get(tfPos); - if (tok->cmp("/ZaDb")) { - tok->clear(); - tok->append("/ZaDb"); - } - } - } - // get the font and font size - font = NULL; - fontSize = 0; - if (tfPos >= 0) { - tok = (GooString *)daToks->get(tfPos); - if (tok->getLength() >= 1 && tok->getChar(0) == '/') { - if (!resources || !(font = resources->lookupFont(tok->getCString() + 1))) { - if (forceZapfDingbats) { - // We are forcing ZaDb but the font does not exist - // so create a fake one - Ref r; // dummy Ref, it's not used at all in this codepath - r.num = -1; - r.gen = -1; - Dict *d = new Dict(xref); - font = new Gfx8BitFont(xref, "ZaDb", r, new GooString("ZapfDingbats"), fontType1, r, d); - delete d; - freeFont = gTrue; - addDingbatsResource = gTrue; - } else { - error(errSyntaxError, -1, "Unknown font in field's DA string"); - } - } - } else { - error(errSyntaxError, -1, "Invalid font name in 'Tf' operator in field's DA string"); - } - tok = (GooString *)daToks->get(tfPos + 1); - fontSize = gatof(tok->getCString()); - } else { - error(errSyntaxError, -1, "Missing 'Tf' operator in field's DA string"); - } - if (!font) { - if (daToks) { - deleteGooList(daToks, GooString); - } - return; - } - - // get the border width - borderWidth = border ? border->getWidth() : 0; - - // for a password field, replace all characters with asterisks - if (password) { - int len; - if (text->hasUnicodeMarker()) - len = (text->getLength() - 2) / 2; - else - len = text->getLength(); - - text = new GooString; - for (i = 0; i < len; ++i) - text->append('*'); - freeText = gTrue; - } - - convertedText = new GooString; - - // setup - if (txField) { - appearBuf->append("/Tx BMC\n"); - } - appearBuf->append("q\n"); - rot = appearCharacs ? appearCharacs->getRotation() : 0; - switch (rot) { - case 90: - appearBuf->appendf("0 1 -1 0 {0:.2f} 0 cm\n", rect->x2 - rect->x1); - dx = rect->y2 - rect->y1; - dy = rect->x2 - rect->x1; - break; - case 180: - appearBuf->appendf("-1 0 0 -1 {0:.2f} {1:.2f} cm\n", - rect->x2 - rect->x1, rect->y2 - rect->y1); - dx = rect->x2 - rect->y2; - dy = rect->y2 - rect->y1; - break; - case 270: - appearBuf->appendf("0 -1 1 0 0 {0:.2f} cm\n", rect->y2 - rect->y1); - dx = rect->y2 - rect->y1; - dy = rect->x2 - rect->x1; - break; - default: // assume rot == 0 - dx = rect->x2 - rect->x1; - dy = rect->y2 - rect->y1; - break; - } - appearBuf->append("BT\n"); - // multi-line text - if (multiline) { - // note: the comb flag is ignored in multiline mode - - wMax = dx - 2 * borderWidth - 4; - - // compute font autosize - if (fontSize == 0) { - for (fontSize = 20; fontSize > 1; --fontSize) { - y = dy - 3; - i = 0; - while (i < text->getLength()) { - layoutText(text, convertedText, &i, font, &w, wMax / fontSize, NULL, - forceZapfDingbats); - y -= fontSize; - } - // approximate the descender for the last line - if (y >= 0.33 * fontSize) { - break; - } - } - if (tfPos >= 0) { - tok = (GooString *)daToks->get(tfPos + 1); - tok->clear(); - tok->appendf("{0:.2f}", fontSize); - } - } - - // starting y coordinate - // (note: each line of text starts with a Td operator that moves - // down a line) - y = dy - 3; - - // set the font matrix - if (tmPos >= 0) { - tok = (GooString *)daToks->get(tmPos + 4); - tok->clear(); - tok->append('0'); - tok = (GooString *)daToks->get(tmPos + 5); - tok->clear(); - tok->appendf("{0:.2f}", y); - } - - // write the DA string - if (daToks) { - for (i = 0; i < daToks->getLength(); ++i) { - appearBuf->append((GooString *)daToks->get(i))->append(' '); - } - } - - // write the font matrix (if not part of the DA string) - if (tmPos < 0) { - appearBuf->appendf("1 0 0 1 0 {0:.2f} Tm\n", y); - } - - // write a series of lines of text - i = 0; - xPrev = 0; - while (i < text->getLength()) { - layoutText(text, convertedText, &i, font, &w, wMax / fontSize, NULL, - forceZapfDingbats); - w *= fontSize; - - // compute text start position - switch (quadding) { - case quaddingLeftJustified: - default: - x = borderWidth + 2; - break; - case quaddingCentered: - x = (dx - w) / 2; - break; - case quaddingRightJustified: - x = dx - borderWidth - 2 - w; - break; - } - - // draw the line - appearBuf->appendf("{0:.2f} {1:.2f} Td\n", x - xPrev, -fontSize); - writeString(convertedText, appearBuf); - appearBuf->append(" Tj\n"); - - // next line - xPrev = x; - } - - // single-line text - } else { - //~ replace newlines with spaces? - what does Acrobat do? - - // comb formatting - if (comb > 0) { - int charCount; - - // compute comb spacing - w = (dx - 2 * borderWidth) / comb; - - // compute font autosize - if (fontSize == 0) { - fontSize = dy - 2 * borderWidth; - if (w < fontSize) { - fontSize = w; - } - fontSize = floor(fontSize); - if (tfPos >= 0) { - tok = (GooString *)daToks->get(tfPos + 1); - tok->clear(); - tok->appendf("{0:.2f}", fontSize); - } - } - - i = 0; - layoutText(text, convertedText, &i, font, NULL, 0.0, &charCount, - forceZapfDingbats); - if (charCount > comb) - charCount = comb; - - // compute starting text cell - switch (quadding) { - case quaddingLeftJustified: - default: - x = borderWidth; - break; - case quaddingCentered: - x = borderWidth + (comb - charCount) / 2 * w; - break; - case quaddingRightJustified: - x = borderWidth + (comb - charCount) * w; - break; - } - y = 0.5 * dy - 0.4 * fontSize; - - // set the font matrix - if (tmPos >= 0) { - tok = (GooString *)daToks->get(tmPos + 4); - tok->clear(); - tok->appendf("{0:.2f}", x); - tok = (GooString *)daToks->get(tmPos + 5); - tok->clear(); - tok->appendf("{0:.2f}", y); - } - - // write the DA string - if (daToks) { - for (i = 0; i < daToks->getLength(); ++i) { - appearBuf->append((GooString *)daToks->get(i))->append(' '); - } - } - - // write the font matrix (if not part of the DA string) - if (tmPos < 0) { - appearBuf->appendf("1 0 0 1 {0:.2f} {1:.2f} Tm\n", x, y); - } - - // write the text string - char *s = convertedText->getCString(); - int len = convertedText->getLength(); - i = 0; - xPrev = w; // so that first character is placed properly - while (i < comb && len > 0) { - CharCode code; - Unicode *uAux; - int uLen, n; - double dx, dy, ox, oy; - - dx = 0.0; - n = font->getNextChar(s, len, &code, &uAux, &uLen, &dx, &dy, &ox, &oy); - dx *= fontSize; - - // center each character within its cell, by advancing the text - // position the appropriate amount relative to the start of the - // previous character - x = 0.5 * (w - dx); - appearBuf->appendf("{0:.2f} 0 Td\n", x - xPrev + w); - - GooString *charBuf = new GooString(s, n); - writeString(charBuf, appearBuf); - appearBuf->append(" Tj\n"); - delete charBuf; - - i++; - s += n; - len -= n; - xPrev = x; - } - - // regular (non-comb) formatting - } else { - i = 0; - layoutText(text, convertedText, &i, font, &w, 0.0, NULL, - forceZapfDingbats); - - // compute font autosize - if (fontSize == 0) { - fontSize = dy - 2 * borderWidth; - fontSize2 = (dx - 4 - 2 * borderWidth) / w; - if (fontSize2 < fontSize) { - fontSize = fontSize2; - } - fontSize = floor(fontSize); - if (tfPos >= 0) { - tok = (GooString *)daToks->get(tfPos + 1); - tok->clear(); - tok->appendf("{0:.2f}", fontSize); - } - } - - // compute text start position - w *= fontSize; - switch (quadding) { - case quaddingLeftJustified: - default: - x = borderWidth + 2; - break; - case quaddingCentered: - x = (dx - w) / 2; - break; - case quaddingRightJustified: - x = dx - borderWidth - 2 - w; - break; - } - y = 0.5 * dy - 0.4 * fontSize; - - // set the font matrix - if (tmPos >= 0) { - tok = (GooString *)daToks->get(tmPos + 4); - tok->clear(); - tok->appendf("{0:.2f}", x); - tok = (GooString *)daToks->get(tmPos + 5); - tok->clear(); - tok->appendf("{0:.2f}", y); - } - - // write the DA string - if (daToks) { - for (i = 0; i < daToks->getLength(); ++i) { - appearBuf->append((GooString *)daToks->get(i))->append(' '); - } - } - - // write the font matrix (if not part of the DA string) - if (tmPos < 0) { - appearBuf->appendf("1 0 0 1 {0:.2f} {1:.2f} Tm\n", x, y); - } - - // write the text string - writeString(convertedText, appearBuf); - appearBuf->append(" Tj\n"); - } - } - // cleanup - appearBuf->append("ET\n"); - appearBuf->append("Q\n"); - if (txField) { - appearBuf->append("EMC\n"); - } - if (daToks) { - deleteGooList(daToks, GooString); - } - if (freeText) { - delete text; - } - delete convertedText; - if (freeFont) { - font->decRefCnt(); - } -} - -// Draw the variable text or caption for a field. -void AnnotWidget::drawListBox(FormFieldChoice *fieldChoice, - GooString *da, GfxResources *resources, int quadding) { - GooList *daToks; - GooString *tok, *convertedText; - GfxFont *font; - double fontSize, fontSize2, borderWidth, x, y, w, wMax; - int tfPos, tmPos, i, j; - - //~ if there is no MK entry, this should use the existing content stream, - //~ and only replace the marked content portion of it - //~ (this is only relevant for Tx fields) - - // parse the default appearance string - tfPos = tmPos = -1; - if (da) { - daToks = new GooList(); - i = 0; - while (i < da->getLength()) { - while (i < da->getLength() && Lexer::isSpace(da->getChar(i))) { - ++i; - } - if (i < da->getLength()) { - for (j = i + 1; - j < da->getLength() && !Lexer::isSpace(da->getChar(j)); - ++j) ; - daToks->append(new GooString(da, i, j - i)); - i = j; - } - } - for (i = 2; i < daToks->getLength(); ++i) { - if (i >= 2 && !((GooString *)daToks->get(i))->cmp("Tf")) { - tfPos = i - 2; - } else if (i >= 6 && !((GooString *)daToks->get(i))->cmp("Tm")) { - tmPos = i - 6; - } - } - } else { - daToks = NULL; - } - - // get the font and font size - font = NULL; - fontSize = 0; - if (tfPos >= 0) { - tok = (GooString *)daToks->get(tfPos); - if (tok->getLength() >= 1 && tok->getChar(0) == '/') { - if (!resources || !(font = resources->lookupFont(tok->getCString() + 1))) { - error(errSyntaxError, -1, "Unknown font in field's DA string"); - } - } else { - error(errSyntaxError, -1, "Invalid font name in 'Tf' operator in field's DA string"); - } - tok = (GooString *)daToks->get(tfPos + 1); - fontSize = gatof(tok->getCString()); - } else { - error(errSyntaxError, -1, "Missing 'Tf' operator in field's DA string"); - } - if (!font) { - if (daToks) { - deleteGooList(daToks, GooString); - } - return; - } - - convertedText = new GooString; - - // get the border width - borderWidth = border ? border->getWidth() : 0; - - // compute font autosize - if (fontSize == 0) { - wMax = 0; - for (i = 0; i < fieldChoice->getNumChoices(); ++i) { - j = 0; - if (fieldChoice->getChoice(i) == NULL) { - error(errSyntaxError, -1, "Invalid annotation listbox"); - if (daToks) { - deleteGooList(daToks, GooString); - } - delete convertedText; - return; - } - layoutText(fieldChoice->getChoice(i), convertedText, &j, font, &w, 0.0, NULL, gFalse); - if (w > wMax) { - wMax = w; - } - } - fontSize = rect->y2 - rect->y1 - 2 * borderWidth; - fontSize2 = (rect->x2 - rect->x1 - 4 - 2 * borderWidth) / wMax; - if (fontSize2 < fontSize) { - fontSize = fontSize2; - } - fontSize = floor(fontSize); - if (tfPos >= 0) { - tok = (GooString *)daToks->get(tfPos + 1); - tok->clear(); - tok->appendf("{0:.2f}", fontSize); - } - } - // draw the text - y = rect->y2 - rect->y1 - 1.1 * fontSize; - for (i = fieldChoice->getTopIndex(); i < fieldChoice->getNumChoices(); ++i) { - // setup - appearBuf->append("q\n"); - - // draw the background if selected - if (fieldChoice->isSelected(i)) { - appearBuf->append("0 g f\n"); - appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} re f\n", - borderWidth, - y - 0.2 * fontSize, - rect->x2 - rect->x1 - 2 * borderWidth, - 1.1 * fontSize); - } - - // setup - appearBuf->append("BT\n"); - - // compute text width and start position - j = 0; - layoutText(fieldChoice->getChoice(i), convertedText, &j, font, &w, 0.0, NULL, gFalse); - w *= fontSize; - switch (quadding) { - case quaddingLeftJustified: - default: - x = borderWidth + 2; - break; - case quaddingCentered: - x = (rect->x2 - rect->x1 - w) / 2; - break; - case quaddingRightJustified: - x = rect->x2 - rect->x1 - borderWidth - 2 - w; - break; - } - - // set the font matrix - if (tmPos >= 0) { - tok = (GooString *)daToks->get(tmPos + 4); - tok->clear(); - tok->appendf("{0:.2f}", x); - tok = (GooString *)daToks->get(tmPos + 5); - tok->clear(); - tok->appendf("{0:.2f}", y); - } - - // write the DA string - if (daToks) { - for (j = 0; j < daToks->getLength(); ++j) { - appearBuf->append((GooString *)daToks->get(j))->append(' '); - } - } - - // write the font matrix (if not part of the DA string) - if (tmPos < 0) { - appearBuf->appendf("1 0 0 1 {0:.2f} {1:.2f} Tm\n", x, y); - } - - // change the text color if selected - if (fieldChoice->isSelected(i)) { - appearBuf->append("1 g\n"); - } - - // write the text string - writeString(convertedText, appearBuf); - appearBuf->append(" Tj\n"); - - // cleanup - appearBuf->append("ET\n"); - appearBuf->append("Q\n"); - - // next line - y -= 1.1 * fontSize; - } - - if (daToks) { - deleteGooList(daToks, GooString); - } - - delete convertedText; -} - -void AnnotWidget::drawBorder() { - int dashLength; - double *dash; - AnnotColor adjustedColor; - double w = border->getWidth(); - - AnnotColor *aColor = appearCharacs->getBorderColor(); - if (!aColor) - aColor = appearCharacs->getBackColor(); - if (!aColor) - return; - - double dx = rect->x2 - rect->x1; - double dy = rect->y2 - rect->y1; - - // radio buttons with no caption have a round border - GBool hasCaption = appearCharacs->getNormalCaption() != NULL; - if (field->getType() == formButton && - static_cast<FormFieldButton*>(field)->getButtonType() == formButtonRadio && !hasCaption) { - double r = 0.5 * (dx < dy ? dx : dy); - switch (border->getStyle()) { - case AnnotBorder::borderDashed: - appearBuf->append("["); - dashLength = border->getDashLength(); - dash = border->getDash(); - for (int i = 0; i < dashLength; ++i) { - appearBuf->appendf(" {0:.2f}", dash[i]); - } - appearBuf->append("] 0 d\n"); - // fall through to the solid case - case AnnotBorder::borderSolid: - case AnnotBorder::borderUnderlined: - appearBuf->appendf("{0:.2f} w\n", w); - setColor(aColor, gFalse); - drawCircle(0.5 * dx, 0.5 * dy, r - 0.5 * w, gFalse); - break; - case AnnotBorder::borderBeveled: - case AnnotBorder::borderInset: - appearBuf->appendf("{0:.2f} w\n", 0.5 * w); - setColor(aColor, gFalse); - drawCircle(0.5 * dx, 0.5 * dy, r - 0.25 * w, gFalse); - adjustedColor = AnnotColor(*aColor); - adjustedColor.adjustColor(border->getStyle() == AnnotBorder::borderBeveled ? 1 : -1); - setColor(&adjustedColor, gFalse); - drawCircleTopLeft(0.5 * dx, 0.5 * dy, r - 0.75 * w); - adjustedColor = AnnotColor(*aColor); - adjustedColor.adjustColor(border->getStyle() == AnnotBorder::borderBeveled ? -1 : 1); - setColor(&adjustedColor, gFalse); - drawCircleBottomRight(0.5 * dx, 0.5 * dy, r - 0.75 * w); - break; - } - } else { - switch (border->getStyle()) { - case AnnotBorder::borderDashed: - appearBuf->append("["); - dashLength = border->getDashLength(); - dash = border->getDash(); - for (int i = 0; i < dashLength; ++i) { - appearBuf->appendf(" {0:.2f}", dash[i]); - } - appearBuf->append("] 0 d\n"); - // fall through to the solid case - case AnnotBorder::borderSolid: - appearBuf->appendf("{0:.2f} w\n", w); - setColor(aColor, gFalse); - appearBuf->appendf("{0:.2f} {0:.2f} {1:.2f} {2:.2f} re s\n", - 0.5 * w, dx - w, dy - w); - break; - case AnnotBorder::borderBeveled: - case AnnotBorder::borderInset: - adjustedColor = AnnotColor(*aColor); - adjustedColor.adjustColor(border->getStyle() == AnnotBorder::borderBeveled ? 1 : -1); - setColor(&adjustedColor, gTrue); - appearBuf->append("0 0 m\n"); - appearBuf->appendf("0 {0:.2f} l\n", dy); - appearBuf->appendf("{0:.2f} {1:.2f} l\n", dx, dy); - appearBuf->appendf("{0:.2f} {1:.2f} l\n", dx - w, dy - w); - appearBuf->appendf("{0:.2f} {1:.2f} l\n", w, dy - w); - appearBuf->appendf("{0:.2f} {0:.2f} l\n", w); - appearBuf->append("f\n"); - adjustedColor = AnnotColor(*aColor); - adjustedColor.adjustColor(border->getStyle() == AnnotBorder::borderBeveled ? -1 : 1); - setColor(&adjustedColor, gTrue); - appearBuf->append("0 0 m\n"); - appearBuf->appendf("{0:.2f} 0 l\n", dx); - appearBuf->appendf("{0:.2f} {1:.2f} l\n", dx, dy); - appearBuf->appendf("{0:.2f} {1:.2f} l\n", dx - w, dy - w); - appearBuf->appendf("{0:.2f} {1:.2f} l\n", dx - w, w); - appearBuf->appendf("{0:.2f} {0:.2f} l\n", w); - appearBuf->append("f\n"); - break; - case AnnotBorder::borderUnderlined: - appearBuf->appendf("{0:.2f} w\n", w); - setColor(aColor, gFalse); - appearBuf->appendf("0 0 m {0:.2f} 0 l s\n", dx); - break; - } - - // clip to the inside of the border - appearBuf->appendf("{0:.2f} {0:.2f} {1:.2f} {2:.2f} re W n\n", - w, dx - 2 * w, dy - 2 * w); - } -} - -void AnnotWidget::drawFormFieldButton(GfxResources *resources, GooString *da) { - GooString *caption = NULL; - if (appearCharacs) - caption = appearCharacs->getNormalCaption(); - - switch (static_cast<FormFieldButton *>(field)->getButtonType()) { - case formButtonRadio: { - //~ Acrobat doesn't draw a caption if there is no AP dict (?) - if (appearState && appearState->cmp("Off") != 0 && - static_cast<FormFieldButton *>(field)->getState(appearState->getCString())) { - if (caption) { - drawText(caption, da, resources, gFalse, 0, fieldQuadCenter, - gFalse, gTrue); - } else if (appearCharacs) { - AnnotColor *aColor = appearCharacs->getBorderColor(); - if (aColor) { - double dx = rect->x2 - rect->x1; - double dy = rect->y2 - rect->y1; - setColor(aColor, gTrue); - drawCircle(0.5 * dx, 0.5 * dy, 0.2 * (dx < dy ? dx : dy), gTrue); - } - } - } - } - break; - case formButtonPush: - if (caption) - drawText(caption, da, resources, gFalse, 0, fieldQuadCenter, gFalse, gFalse); - break; - case formButtonCheck: - if (appearState && appearState->cmp("Off") != 0) { - if (!caption) { - GooString checkMark("3"); - drawText(&checkMark, da, resources, gFalse, 0, fieldQuadCenter, gFalse, gTrue); - } else { - drawText(caption, da, resources, gFalse, 0, fieldQuadCenter, gFalse, gTrue); - } - } - break; - } -} - -void AnnotWidget::drawFormFieldText(GfxResources *resources, GooString *da) { - VariableTextQuadding quadding; - GooString *contents; - FormFieldText *fieldText = static_cast<FormFieldText *>(field); - - contents = fieldText->getContent(); - if (contents) { - quadding = field->hasTextQuadding() ? field->getTextQuadding() : form->getTextQuadding(); - - int comb = 0; - if (fieldText->isComb()) - comb = fieldText->getMaxLen(); - - drawText(contents, da, resources, - fieldText->isMultiline(), comb, quadding, gTrue, gFalse, fieldText->isPassword()); - } -} - -void AnnotWidget::drawFormFieldChoice(GfxResources *resources, GooString *da) { - GooString *selected; - VariableTextQuadding quadding; - FormFieldChoice *fieldChoice = static_cast<FormFieldChoice *>(field); - - quadding = field->hasTextQuadding() ? field->getTextQuadding() : form->getTextQuadding(); - - if (fieldChoice->isCombo()) { - selected = fieldChoice->getSelectedChoice(); - if (selected) { - drawText(selected, da, resources, gFalse, 0, quadding, gTrue, gFalse); - //~ Acrobat draws a popup icon on the right side - } - // list box - } else { - drawListBox(fieldChoice, da, resources, quadding); - } -} - -void AnnotWidget::generateFieldAppearance() { - Object appearDict, obj1, obj2; - GfxResources *resources; - MemStream *appearStream; - GooString *da; - - appearBuf = new GooString (); - - // draw the background - if (appearCharacs) { - AnnotColor *aColor = appearCharacs->getBackColor(); - if (aColor) { - setColor(aColor, gTrue); - appearBuf->appendf("0 0 {0:.2f} {1:.2f} re f\n", - rect->x2 - rect->x1, rect->y2 - rect->y1); - } - } - - // draw the border - if (appearCharacs && border && border->getWidth() > 0) - drawBorder(); - - da = field->getDefaultAppearance(); - if (!da) - da = form->getDefaultAppearance(); - - resources = form->getDefaultResources(); - - // draw the field contents - switch (field->getType()) { - case formButton: - drawFormFieldButton(resources, da); - break; - case formText: - drawFormFieldText(resources, da); - break; - case formChoice: - drawFormFieldChoice(resources, da); - break; - case formSignature: - //~unimp - break; - case formUndef: - default: - error(errSyntaxError, -1, "Unknown field type"); - } - - // build the appearance stream dictionary - appearDict.initDict(xref); - appearDict.dictAdd(copyString("Length"), - obj1.initInt(appearBuf->getLength())); - appearDict.dictAdd(copyString("Subtype"), obj1.initName("Form")); - obj1.initArray(xref); - obj1.arrayAdd(obj2.initReal(0)); - obj1.arrayAdd(obj2.initReal(0)); - obj1.arrayAdd(obj2.initReal(rect->x2 - rect->x1)); - obj1.arrayAdd(obj2.initReal(rect->y2 - rect->y1)); - appearDict.dictAdd(copyString("BBox"), &obj1); - - // set the resource dictionary - Object *resDict = form->getDefaultResourcesObj(); - if (resDict->isDict()) { - appearDict.dictAdd(copyString("Resources"), resDict->copy(&obj1)); - } - - // build the appearance stream - appearStream = new MemStream(copyString(appearBuf->getCString()), 0, - appearBuf->getLength(), &appearDict); - appearance.free(); - appearance.initStream(appearStream); - delete appearBuf; - - appearStream->setNeedFree(gTrue); -} - -void AnnotWidget::updateAppearanceStream() -{ - // If this the first time updateAppearanceStream() is called on this widget, - // destroy the AP dictionary because we are going to create a new one. - if (updatedAppearanceStream.num == -1) { - invalidateAppearance(); // Delete AP dictionary and all referenced streams - } - - // There's no need to create a new appearance stream if NeedAppearances is - // set, because it will be ignored next time anyway. - if (form && form->getNeedAppearances()) - return; - - // Create the new appearance - generateFieldAppearance(); - - // Fetch the appearance stream we've just created - Object obj1; - appearance.fetch(xref, &obj1); - - // If this the first time updateAppearanceStream() is called on this widget, - // create a new AP dictionary containing the new appearance stream. - // Otherwise, just update the stream we had created previously. - if (updatedAppearanceStream.num == -1) { - // Write the appearance stream - updatedAppearanceStream = xref->addIndirectObject(&obj1); - obj1.free(); - - // Write the AP dictionary - Object obj2; - obj1.initDict(xref); - obj1.dictAdd(copyString("N"), obj2.initRef(updatedAppearanceStream.num, updatedAppearanceStream.gen)); - update("AP", &obj1); - - // Update our internal pointers to the appearance dictionary - appearStreams = new AnnotAppearance(doc, &obj1); - } else { - // Replace the existing appearance stream - xref->setModifiedObject(&obj1, updatedAppearanceStream); - obj1.free(); - } -} - -void AnnotWidget::draw(Gfx *gfx, GBool printing) { - Object obj; - - if (!isVisible (printing)) - return; - - annotLocker(); - addDingbatsResource = gFalse; - - // Only construct the appearance stream when - // - annot doesn't have an AP or - // - NeedAppearances is true - if (field) { - if (appearance.isNull() || (form && form->getNeedAppearances())) - generateFieldAppearance(); - } - - // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); - if (addDingbatsResource) { - // We are forcing ZaDb but the font does not exist - // so create a fake one - Object baseFontObj, subtypeObj; - baseFontObj.initName("ZapfDingbats"); - subtypeObj.initName("Type1"); - - Object fontDictObj; - Dict *fontDict = new Dict(gfx->getXRef()); - fontDict->decRef(); - fontDict->add(copyString("BaseFont"), &baseFontObj); - fontDict->add(copyString("Subtype"), &subtypeObj); - fontDictObj.initDict(fontDict); - - Object fontsDictObj; - Dict *fontsDict = new Dict(gfx->getXRef()); - fontsDict->decRef(); - fontsDict->add(copyString("ZaDb"), &fontDictObj); - fontsDictObj.initDict(fontsDict); - - Dict *dict = new Dict(gfx->getXRef()); - dict->add(copyString("Font"), &fontsDictObj); - gfx->pushResources(dict); - delete dict; - } - gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, - rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - if (addDingbatsResource) { - gfx->popResources(); - } - obj.free(); -} - - -//------------------------------------------------------------------------ -// AnnotMovie -//------------------------------------------------------------------------ -AnnotMovie::AnnotMovie(PDFDoc *docA, PDFRectangle *rect, Movie *movieA) : - Annot(docA, rect) { - Object obj1; - - type = typeMovie; - annotObj.dictSet ("Subtype", obj1.initName ("Movie")); - - movie = movieA->copy(); - // TODO: create movie dict from movieA - - initialize(docA, annotObj.getDict()); -} - -AnnotMovie::AnnotMovie(PDFDoc *docA, Dict *dict, Object *obj) : - Annot(docA, dict, obj) { - type = typeMovie; - initialize(docA, dict); -} - -AnnotMovie::~AnnotMovie() { - if (title) - delete title; - delete movie; -} - -void AnnotMovie::initialize(PDFDoc *docA, Dict* dict) { - Object obj1; - - if (dict->lookup("T", &obj1)->isString()) { - title = obj1.getString()->copy(); - } else { - title = NULL; - } - obj1.free(); - - Object movieDict; - if (dict->lookup("Movie", &movieDict)->isDict()) { - Object obj2; - dict->lookup("A", &obj2); - if (obj2.isDict()) - movie = new Movie (&movieDict, &obj2); - else - movie = new Movie (&movieDict); - if (!movie->isOk()) { - delete movie; - movie = NULL; - ok = gFalse; - } - obj2.free(); - } else { - error(errSyntaxError, -1, "Bad Annot Movie"); - movie = NULL; - ok = gFalse; - } - movieDict.free(); -} - -void AnnotMovie::draw(Gfx *gfx, GBool printing) { - Object obj; - - if (!isVisible (printing)) - return; - - annotLocker(); - if (appearance.isNull() && movie->getShowPoster()) { - int width, height; - Object poster; - movie->getPoster(&poster); - movie->getAspect(&width, &height); - - if (width != -1 && height != -1 && !poster.isNone()) { - MemStream *mStream; - - appearBuf = new GooString (); - appearBuf->append ("q\n"); - appearBuf->appendf ("{0:d} 0 0 {1:d} 0 0 cm\n", width, height); - appearBuf->append ("/MImg Do\n"); - appearBuf->append ("Q\n"); - - Object imgDict; - imgDict.initDict(gfx->getXRef()); - imgDict.dictSet ("MImg", &poster); - - Object resDict; - resDict.initDict(gfx->getXRef()); - resDict.dictSet ("XObject", &imgDict); - - Object formDict, obj1, obj2; - formDict.initDict(gfx->getXRef()); - formDict.dictSet("Length", obj1.initInt(appearBuf->getLength())); - formDict.dictSet("Subtype", obj1.initName("Form")); - formDict.dictSet("Name", obj1.initName("FRM")); - obj1.initArray(gfx->getXRef()); - obj1.arrayAdd(obj2.initInt(0)); - obj1.arrayAdd(obj2.initInt(0)); - obj1.arrayAdd(obj2.initInt(width)); - obj1.arrayAdd(obj2.initInt(height)); - formDict.dictSet("BBox", &obj1); - obj1.initArray(gfx->getXRef()); - obj1.arrayAdd(obj2.initInt(1)); - obj1.arrayAdd(obj2.initInt(0)); - obj1.arrayAdd(obj2.initInt(0)); - obj1.arrayAdd(obj2.initInt(1)); - obj1.arrayAdd(obj2.initInt(-width / 2)); - obj1.arrayAdd(obj2.initInt(-height / 2)); - formDict.dictSet("Matrix", &obj1); - formDict.dictSet("Resources", &resDict); - - Object aStream; - mStream = new MemStream(copyString(appearBuf->getCString()), 0, - appearBuf->getLength(), &formDict); - mStream->setNeedFree(gTrue); - aStream.initStream(mStream); - delete appearBuf; - - Object objDict; - objDict.initDict(gfx->getXRef()); - objDict.dictSet ("FRM", &aStream); - - resDict.initDict(gfx->getXRef()); - resDict.dictSet ("XObject", &objDict); - - appearBuf = new GooString (); - appearBuf->append ("q\n"); - appearBuf->appendf ("0 0 {0:d} {1:d} re W n\n", width, height); - appearBuf->append ("q\n"); - appearBuf->appendf ("0 0 {0:d} {1:d} re W n\n", width, height); - appearBuf->appendf ("1 0 0 1 {0:d} {1:d} cm\n", width / 2, height / 2); - appearBuf->append ("/FRM Do\n"); - appearBuf->append ("Q\n"); - appearBuf->append ("Q\n"); - - double bbox[4]; - bbox[0] = bbox[1] = 0; - bbox[2] = width; - bbox[3] = height; - createForm(bbox, gFalse, &resDict, &appearance); - delete appearBuf; - } - poster.free(); - } - - // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); - gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, - rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - obj.free(); -} - -//------------------------------------------------------------------------ -// AnnotScreen -//------------------------------------------------------------------------ -AnnotScreen::AnnotScreen(PDFDoc *docA, PDFRectangle *rect) : - Annot(docA, rect) { - Object obj1; - - type = typeScreen; - - annotObj.dictSet ("Subtype", obj1.initName ("Screen")); - initialize(docA, annotObj.getDict()); -} - -AnnotScreen::AnnotScreen(PDFDoc *docA, Dict *dict, Object *obj) : - Annot(docA, dict, obj) { - type = typeScreen; - initialize(docA, dict); -} - -AnnotScreen::~AnnotScreen() { - if (title) - delete title; - if (appearCharacs) - delete appearCharacs; - if (action) - delete action; - - additionalActions.free(); -} - -void AnnotScreen::initialize(PDFDoc *docA, Dict* dict) { - Object obj1; - - title = NULL; - if (dict->lookup("T", &obj1)->isString()) { - title = obj1.getString()->copy(); - } - obj1.free(); - - action = NULL; - if (dict->lookup("A", &obj1)->isDict()) { - action = LinkAction::parseAction(&obj1, doc->getCatalog()->getBaseURI()); - if (action->getKind() == actionRendition && page == 0) { - error (errSyntaxError, -1, "Invalid Rendition action: associated screen annotation without P"); - delete action; - action = NULL; - ok = gFalse; - } - } - obj1.free(); - - dict->lookupNF("AA", &additionalActions); - - appearCharacs = NULL; - if(dict->lookup("MK", &obj1)->isDict()) { - appearCharacs = new AnnotAppearanceCharacs(obj1.getDict()); - } - obj1.free(); -} - -LinkAction* AnnotScreen::getAdditionalAction(AdditionalActionsType type) -{ - if (type == actionFocusIn || type == actionFocusOut) // not defined for screen annotation - return NULL; - - return ::getAdditionalAction(type, &additionalActions, doc); -} - -//------------------------------------------------------------------------ -// AnnotStamp -//------------------------------------------------------------------------ -AnnotStamp::AnnotStamp(PDFDoc *docA, PDFRectangle *rect) : - AnnotMarkup(docA, rect) { - Object obj1; - - type = typeStamp; - annotObj.dictSet ("Subtype", obj1.initName ("Stamp")); - initialize(docA, annotObj.getDict()); -} - -AnnotStamp::AnnotStamp(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { - type = typeStamp; - initialize(docA, dict); -} - -AnnotStamp::~AnnotStamp() { - delete icon; -} - -void AnnotStamp::initialize(PDFDoc *docA, Dict* dict) { - Object obj1; - - if (dict->lookup("Name", &obj1)->isName()) { - icon = new GooString(obj1.getName()); - } else { - icon = new GooString("Draft"); - } - obj1.free(); - -} - -void AnnotStamp::setIcon(GooString *new_icon) { - delete icon; - - if (new_icon) { - icon = new GooString (new_icon); - } else { - icon = new GooString(); - } - - Object obj1; - obj1.initName (icon->getCString()); - update("Name", &obj1); - invalidateAppearance(); -} - -//------------------------------------------------------------------------ -// AnnotGeometry -//------------------------------------------------------------------------ -AnnotGeometry::AnnotGeometry(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType) : - AnnotMarkup(docA, rect) { - Object obj1; - - switch (subType) { - case typeSquare: - annotObj.dictSet ("Subtype", obj1.initName ("Square")); - break; - case typeCircle: - annotObj.dictSet ("Subtype", obj1.initName ("Circle")); - break; - default: - assert (0 && "Invalid subtype for AnnotGeometry\n"); - } - - initialize(docA, annotObj.getDict()); -} - -AnnotGeometry::AnnotGeometry(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { - // the real type will be read in initialize() - type = typeSquare; - initialize(docA, dict); -} - -AnnotGeometry::~AnnotGeometry() { - delete interiorColor; - delete borderEffect; - delete geometryRect; -} - -void AnnotGeometry::initialize(PDFDoc *docA, Dict* dict) { - Object obj1; - - if (dict->lookup("Subtype", &obj1)->isName()) { - GooString typeName(obj1.getName()); - if (!typeName.cmp("Square")) { - type = typeSquare; - } else if (!typeName.cmp("Circle")) { - type = typeCircle; - } - } - obj1.free(); - - if (dict->lookup("IC", &obj1)->isArray()) { - interiorColor = new AnnotColor(obj1.getArray()); - } else { - interiorColor = NULL; - } - obj1.free(); - - if (dict->lookup("BS", &obj1)->isDict()) { - delete border; - border = new AnnotBorderBS(obj1.getDict()); - } else if (!border) { - border = new AnnotBorderBS(); - } - obj1.free(); - - if (dict->lookup("BE", &obj1)->isDict()) { - borderEffect = new AnnotBorderEffect(obj1.getDict()); - } else { - borderEffect = NULL; - } - obj1.free(); - - geometryRect = NULL; - if (dict->lookup("RD", &obj1)->isArray()) { - geometryRect = parseDiffRectangle(obj1.getArray(), rect); - } - obj1.free(); - -} - -void AnnotGeometry::setType(AnnotSubtype new_type) { - Object obj1; - - switch (new_type) { - case typeSquare: - obj1.initName("Square"); - break; - case typeCircle: - obj1.initName("Circle"); - break; - default: - assert(!"Invalid subtype"); - } - - type = new_type; - update("Subtype", &obj1); - invalidateAppearance(); -} - -void AnnotGeometry::setInteriorColor(AnnotColor *new_color) { - delete interiorColor; - - if (new_color) { - Object obj1; - new_color->writeToObject(xref, &obj1); - update ("IC", &obj1); - interiorColor = new_color; - } else { - interiorColor = NULL; - } - invalidateAppearance(); -} - -void AnnotGeometry::draw(Gfx *gfx, GBool printing) { - Object obj; - double ca = 1; - - if (!isVisible (printing)) - return; - - annotLocker(); - if (appearance.isNull()) { - ca = opacity; - - appearBuf = new GooString (); - appearBuf->append ("q\n"); - if (color) - setColor(color, gFalse); - - double borderWidth = border->getWidth(); - setLineStyleForBorder(border); - - if (interiorColor) - setColor(interiorColor, gTrue); - - if (type == typeSquare) { - appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} re\n", - borderWidth / 2.0, borderWidth / 2.0, - (rect->x2 - rect->x1) - borderWidth, - (rect->y2 - rect->y1) - borderWidth); - } else { - double width, height; - double b; - double x1, y1, x2, y2, x3, y3; - - width = rect->x2 - rect->x1; - height = rect->y2 - rect->y1; - b = borderWidth / 2.0; - - x1 = b; - y1 = height / 2.0; - appearBuf->appendf ("{0:.2f} {1:.2f} m\n", x1, y1); - - y1 += height / 4.0; - x2 = width / 4.0; - y2 = height - b; - x3 = width / 2.0; - y3 = y2; - appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", - x1, y1, x2, y2, x3, y3); - x2 = width - b; - y2 = y1; - x1 = x3 + (width / 4.0); - y1 = y3; - x3 = x2; - y3 = height / 2.0; - appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", - x1, y1, x2, y2, x3, y3); - - x2 = x1; - y2 = b; - x1 = x3; - y1 = height / 4.0; - x3 = width / 2.0; - y3 = b; - appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", - x1, y1, x2, y2, x3, y3); - - x2 = b; - y2 = y1; - x1 = width / 4.0; - y1 = b; - x3 = b; - y3 = height / 2.0; - appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", - x1, y1, x2, y2, x3, y3); - } - - if (interiorColor && interiorColor->getSpace() != AnnotColor::colorTransparent) - appearBuf->append ("b\n"); - else - appearBuf->append ("S\n"); - - appearBuf->append ("Q\n"); - - double bbox[4]; - bbox[0] = bbox[1] = 0; - bbox[2] = rect->x2 - rect->x1; - bbox[3] = rect->y2 - rect->y1; - if (ca == 1) { - createForm(bbox, gFalse, NULL, &appearance); - } else { - Object aStream; - - createForm(bbox, gTrue, NULL, &aStream); - delete appearBuf; - - Object resDict; - appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); - createForm(bbox, gFalse, &resDict, &appearance); - } - delete appearBuf; - } - - // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); - gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, - rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - obj.free(); -} - -//------------------------------------------------------------------------ -// AnnotPolygon -//------------------------------------------------------------------------ -AnnotPolygon::AnnotPolygon(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType) : - AnnotMarkup(docA, rect) { - Object obj1; - - switch (subType) { - case typePolygon: - annotObj.dictSet ("Subtype", obj1.initName ("Polygon")); - break; - case typePolyLine: - annotObj.dictSet ("Subtype", obj1.initName ("PolyLine")); - break; - default: - assert (0 && "Invalid subtype for AnnotGeometry\n"); - } - - // Store dummy path with one null vertex only - Object obj2, obj3; - obj2.initArray (doc->getXRef()); - obj2.arrayAdd (obj3.initReal (0)); - obj2.arrayAdd (obj3.initReal (0)); - annotObj.dictSet ("Vertices", &obj2); - - initialize(docA, annotObj.getDict()); -} - -AnnotPolygon::AnnotPolygon(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { - // the real type will be read in initialize() - type = typePolygon; - initialize(docA, dict); -} - -AnnotPolygon::~AnnotPolygon() { - delete vertices; - - if (interiorColor) - delete interiorColor; - - if (borderEffect) - delete borderEffect; -} - -void AnnotPolygon::initialize(PDFDoc *docA, Dict* dict) { - Object obj1; - - if (dict->lookup("Subtype", &obj1)->isName()) { - GooString typeName(obj1.getName()); - if (!typeName.cmp("Polygon")) { - type = typePolygon; - } else if (!typeName.cmp("PolyLine")) { - type = typePolyLine; - } - } - obj1.free(); - - if (dict->lookup("Vertices", &obj1)->isArray()) { - vertices = new AnnotPath(obj1.getArray()); - } else { - vertices = new AnnotPath(); - error(errSyntaxError, -1, "Bad Annot Polygon Vertices"); - ok = gFalse; - } - obj1.free(); - - if (dict->lookup("LE", &obj1)->isArray() && obj1.arrayGetLength() == 2) { - Object obj2; - - if(obj1.arrayGet(0, &obj2)->isString()) - startStyle = parseAnnotLineEndingStyle(obj2.getString()); - else - startStyle = annotLineEndingNone; - obj2.free(); - - if(obj1.arrayGet(1, &obj2)->isString()) - endStyle = parseAnnotLineEndingStyle(obj2.getString()); - else - endStyle = annotLineEndingNone; - obj2.free(); - - } else { - startStyle = endStyle = annotLineEndingNone; - } - obj1.free(); - - if (dict->lookup("IC", &obj1)->isArray()) { - interiorColor = new AnnotColor(obj1.getArray()); - } else { - interiorColor = NULL; - } - obj1.free(); - - if (dict->lookup("BS", &obj1)->isDict()) { - delete border; - border = new AnnotBorderBS(obj1.getDict()); - } else if (!border) { - border = new AnnotBorderBS(); - } - obj1.free(); - - if (dict->lookup("BE", &obj1)->isDict()) { - borderEffect = new AnnotBorderEffect(obj1.getDict()); - } else { - borderEffect = NULL; - } - obj1.free(); - - if (dict->lookup("IT", &obj1)->isName()) { - const char *intentName = obj1.getName(); - - if(!strcmp(intentName, "PolygonCloud")) { - intent = polygonCloud; - } else if(!strcmp(intentName, "PolyLineDimension")) { - intent = polylineDimension; - } else { - intent = polygonDimension; - } - } else { - intent = polygonCloud; - } - obj1.free(); -} - -void AnnotPolygon::setType(AnnotSubtype new_type) { - Object obj1; - - switch (new_type) { - case typePolygon: - obj1.initName("Polygon"); - break; - case typePolyLine: - obj1.initName("PolyLine"); - break; - default: - assert(!"Invalid subtype"); - } - - type = new_type; - update("Subtype", &obj1); - invalidateAppearance(); -} - -void AnnotPolygon::setVertices(AnnotPath *path) { - Object obj1, obj2; - delete vertices; - - obj1.initArray(xref); - - for (int i = 0; i < path->getCoordsLength(); i++) { - obj1.arrayAdd (obj2.initReal (path->getX(i))); - obj1.arrayAdd (obj2.initReal (path->getY(i))); - } - - vertices = new AnnotPath(obj1.getArray()); - - update("Vertices", &obj1); - invalidateAppearance(); -} - -void AnnotPolygon::setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end) { - Object obj1, obj2; - - startStyle = start; - endStyle = end; - - obj1.initArray(xref); - obj1.arrayAdd( obj2.initName(convertAnnotLineEndingStyle( startStyle )) ); - obj1.arrayAdd( obj2.initName(convertAnnotLineEndingStyle( endStyle )) ); - - update("LE", &obj1); - invalidateAppearance(); -} - -void AnnotPolygon::setInteriorColor(AnnotColor *new_color) { - delete interiorColor; - - if (new_color) { - Object obj1; - new_color->writeToObject(xref, &obj1); - update ("IC", &obj1); - interiorColor = new_color; - } else { - interiorColor = NULL; - } - invalidateAppearance(); -} - -void AnnotPolygon::setIntent(AnnotPolygonIntent new_intent) { - Object obj1; - - intent = new_intent; - if (new_intent == polygonCloud) - obj1.initName("PolygonCloud"); - else if (new_intent == polylineDimension) - obj1.initName("PolyLineDimension"); - else // polygonDimension - obj1.initName("PolygonDimension"); - update ("IT", &obj1); -} - -void AnnotPolygon::draw(Gfx *gfx, GBool printing) { - Object obj; - double ca = 1; - - if (!isVisible (printing)) - return; - - annotLocker(); - if (appearance.isNull()) { - appearBBox = new AnnotAppearanceBBox(rect); - ca = opacity; - - appearBuf = new GooString (); - appearBuf->append ("q\n"); - - if (color) { - setColor(color, gFalse); - } - - setLineStyleForBorder(border); - appearBBox->setBorderWidth(std::max(1., border->getWidth())); - - if (interiorColor) { - setColor(interiorColor, gTrue); - } - - if (vertices->getCoordsLength() != 0) { - appearBuf->appendf ("{0:.2f} {1:.2f} m\n", vertices->getX(0) - rect->x1, vertices->getY(0) - rect->y1); - appearBBox->extendTo (vertices->getX(0) - rect->x1, vertices->getY(0) - rect->y1); - - for (int i = 1; i < vertices->getCoordsLength(); ++i) { - appearBuf->appendf ("{0:.2f} {1:.2f} l\n", vertices->getX(i) - rect->x1, vertices->getY(i) - rect->y1); - appearBBox->extendTo (vertices->getX(i) - rect->x1, vertices->getY(i) - rect->y1); - } - - if (type == typePolygon) { - if (interiorColor && interiorColor->getSpace() != AnnotColor::colorTransparent) { - appearBuf->append ("b\n"); - } else { - appearBuf->append ("s\n"); - } - } else { - appearBuf->append ("S\n"); - } - } - - appearBuf->append ("Q\n"); - - double bbox[4]; - appearBBox->getBBoxRect(bbox); - if (ca == 1) { - createForm(bbox, gFalse, NULL, &appearance); - } else { - Object aStream, resDict; - - createForm(bbox, gTrue, NULL, &aStream); - delete appearBuf; - - appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); - createForm(bbox, gFalse, &resDict, &appearance); - } - delete appearBuf; - } - - // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); - if (appearBBox) { - gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, - appearBBox->getPageXMin(), appearBBox->getPageYMin(), - appearBBox->getPageXMax(), appearBBox->getPageYMax(), - getRotation()); - } else { - gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, - rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - } - obj.free(); -} - -//------------------------------------------------------------------------ -// AnnotCaret -//------------------------------------------------------------------------ -AnnotCaret::AnnotCaret(PDFDoc *docA, PDFRectangle *rect) : - AnnotMarkup(docA, rect) { - Object obj1; - - type = typeCaret; - - annotObj.dictSet ("Subtype", obj1.initName ("Caret")); - initialize(docA, annotObj.getDict()); -} - -AnnotCaret::AnnotCaret(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { - type = typeCaret; - initialize(docA, dict); -} - -AnnotCaret::~AnnotCaret() { - delete caretRect; -} - -void AnnotCaret::initialize(PDFDoc *docA, Dict* dict) { - Object obj1; - - symbol = symbolNone; - if (dict->lookup("Sy", &obj1)->isName()) { - GooString typeName(obj1.getName()); - if (!typeName.cmp("P")) { - symbol = symbolP; - } else if (!typeName.cmp("None")) { - symbol = symbolNone; - } - } - obj1.free(); - - if (dict->lookup("RD", &obj1)->isArray()) { - caretRect = parseDiffRectangle(obj1.getArray(), rect); - } else { - caretRect = NULL; - } - obj1.free(); - -} - -void AnnotCaret::setSymbol(AnnotCaretSymbol new_symbol) { - Object obj1; - obj1.initName( new_symbol == symbolP ? "P" : "None" ); - symbol = new_symbol; - update("Sy", &obj1); - invalidateAppearance(); -} - -//------------------------------------------------------------------------ -// AnnotInk -//------------------------------------------------------------------------ -AnnotInk::AnnotInk(PDFDoc *docA, PDFRectangle *rect) : - AnnotMarkup(docA, rect) { - Object obj1; - - type = typeInk; - - annotObj.dictSet ("Subtype", obj1.initName ("Ink")); - - // Store dummy path with one null vertex only - Object obj2, obj3, obj4; - obj2.initArray (doc->getXRef()); - obj2.arrayAdd (obj3.initArray (doc->getXRef())); - obj3.arrayAdd (obj4.initReal (0)); - obj3.arrayAdd (obj4.initReal (0)); - annotObj.dictSet ("InkList", &obj2); - - initialize(docA, annotObj.getDict()); -} - -AnnotInk::AnnotInk(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { - type = typeInk; - initialize(docA, dict); -} - -AnnotInk::~AnnotInk() { - freeInkList(); -} - -void AnnotInk::initialize(PDFDoc *docA, Dict* dict) { - Object obj1; - - if (dict->lookup("InkList", &obj1)->isArray()) { - parseInkList(obj1.getArray()); - } else { - inkListLength = 0; - inkList = NULL; - error(errSyntaxError, -1, "Bad Annot Ink List"); - ok = gFalse; - } - obj1.free(); - - if (dict->lookup("BS", &obj1)->isDict()) { - delete border; - border = new AnnotBorderBS(obj1.getDict()); - } else if (!border) { - border = new AnnotBorderBS(); - } - obj1.free(); -} - -void AnnotInk::writeInkList(AnnotPath **paths, int n_paths, Array *dest_array) { - Object obj1, obj2; - for (int i = 0; i < n_paths; ++i) { - AnnotPath *path = paths[i]; - obj1.initArray (xref); - for (int j = 0; j < path->getCoordsLength(); ++j) { - obj1.arrayAdd (obj2.initReal (path->getX(j))); - obj1.arrayAdd (obj2.initReal (path->getY(j))); - } - dest_array->add (&obj1); - } -} - -void AnnotInk::parseInkList(Array *array) { - inkListLength = array->getLength(); - inkList = (AnnotPath **) gmallocn ((inkListLength), sizeof(AnnotPath *)); - memset(inkList, 0, inkListLength * sizeof(AnnotPath *)); - for (int i = 0; i < inkListLength; i++) { - Object obj2; - if (array->get(i, &obj2)->isArray()) - inkList[i] = new AnnotPath(obj2.getArray()); - obj2.free(); - } -} - -void AnnotInk::freeInkList() { - if (inkList) { - for (int i = 0; i < inkListLength; ++i) - delete inkList[i]; - gfree(inkList); - } -} - -void AnnotInk::setInkList(AnnotPath **paths, int n_paths) { - Object obj1; - - freeInkList(); - - obj1.initArray (xref); - writeInkList(paths, n_paths, obj1.getArray()); - - parseInkList(obj1.getArray()); - annotObj.dictSet ("InkList", &obj1); - invalidateAppearance(); -} - -void AnnotInk::draw(Gfx *gfx, GBool printing) { - Object obj; - double ca = 1; - - if (!isVisible (printing)) - return; - - annotLocker(); - if (appearance.isNull()) { - appearBBox = new AnnotAppearanceBBox(rect); - ca = opacity; - - appearBuf = new GooString (); - appearBuf->append ("q\n"); - - if (color) { - setColor(color, gFalse); - } - - setLineStyleForBorder(border); - appearBBox->setBorderWidth(std::max(1., border->getWidth())); - - for (int i = 0; i < inkListLength; ++i) { - const AnnotPath * path = inkList[i]; - if (path->getCoordsLength() != 0) { - appearBuf->appendf ("{0:.2f} {1:.2f} m\n", path->getX(0) - rect->x1, path->getY(0) - rect->y1); - appearBBox->extendTo (path->getX(0) - rect->x1, path->getY(0) - rect->y1); - - for (int j = 1; j < path->getCoordsLength(); ++j) { - appearBuf->appendf ("{0:.2f} {1:.2f} l\n", path->getX(j) - rect->x1, path->getY(j) - rect->y1); - appearBBox->extendTo (path->getX(j) - rect->x1, path->getY(j) - rect->y1); - } - - appearBuf->append ("S\n"); - } - } - - appearBuf->append ("Q\n"); - - double bbox[4]; - appearBBox->getBBoxRect(bbox); - if (ca == 1) { - createForm(bbox, gFalse, NULL, &appearance); - } else { - Object aStream, resDict; - - createForm(bbox, gTrue, NULL, &aStream); - delete appearBuf; - - appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); - createForm(bbox, gFalse, &resDict, &appearance); - } - delete appearBuf; - } - - // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); - if (appearBBox) { - gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, - appearBBox->getPageXMin(), appearBBox->getPageYMin(), - appearBBox->getPageXMax(), appearBBox->getPageYMax(), - getRotation()); - } else { - gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, - rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - } - obj.free(); -} - -//------------------------------------------------------------------------ -// AnnotFileAttachment -//------------------------------------------------------------------------ -AnnotFileAttachment::AnnotFileAttachment(PDFDoc *docA, PDFRectangle *rect, GooString *filename) : - AnnotMarkup(docA, rect) { - Object obj1; - - type = typeFileAttachment; - - annotObj.dictSet ("Subtype", obj1.initName ("FileAttachment")); - - Object obj2; - obj2.initString(filename->copy()); - annotObj.dictSet ("FS", &obj2); - - initialize(docA, annotObj.getDict()); -} - -AnnotFileAttachment::AnnotFileAttachment(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { - type = typeFileAttachment; - initialize(docA, dict); -} - -AnnotFileAttachment::~AnnotFileAttachment() { - file.free(); - - if (name) - delete name; -} - -void AnnotFileAttachment::initialize(PDFDoc *docA, Dict* dict) { - Object obj1; - - if (dict->lookup("FS", &obj1)->isDict() || dict->lookup("FS", &obj1)->isString()) { - obj1.copy(&file); - } else { - error(errSyntaxError, -1, "Bad Annot File Attachment"); - ok = gFalse; - } - obj1.free(); - - if (dict->lookup("Name", &obj1)->isName()) { - name = new GooString(obj1.getName()); - } else { - name = new GooString("PushPin"); - } - obj1.free(); -} - -#define ANNOT_FILE_ATTACHMENT_AP_PUSHPIN \ - "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ - "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ - "l 1 21.523 2.477 23 4.301 23 c h\n" \ - "4.301 23 m f\n" \ - "0.533333 0.541176 0.521569 RG 2 w\n" \ - "1 J\n" \ - "1 j\n" \ - "[] 0.0 d\n" \ - "4 M 5 4 m 6 5 l S\n" \ - "2 w\n" \ - "11 14 m 9 12 l 6 12 l 13 5 l 13 8 l 15 10 l 18 11 l 20 11 l 12 19 l 12\n" \ - "17 l 11 14 l h\n" \ - "11 14 m S\n" \ - "3 w\n" \ - "6 5 m 9 8 l S\n" \ - "0.729412 0.741176 0.713725 RG 2 w\n" \ - "5 5 m 6 6 l S\n" \ - "2 w\n" \ - "11 15 m 9 13 l 6 13 l 13 6 l 13 9 l 15 11 l 18 12 l 20 12 l 12 20 l 12\n" \ - "18 l 11 15 l h\n" \ - "11 15 m S\n" \ - "3 w\n" \ - "6 6 m 9 9 l S\n" - -#define ANNOT_FILE_ATTACHMENT_AP_PAPERCLIP \ - "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ - "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ - "l 1 21.523 2.477 23 4.301 23 c h\n" \ - "4.301 23 m f\n" \ - "0.533333 0.541176 0.521569 RG 2 w\n" \ - "1 J\n" \ - "1 j\n" \ - "[] 0.0 d\n" \ - "4 M 16.645 12.035 m 12.418 7.707 l 10.902 6.559 6.402 11.203 8.09 12.562 c\n" \ - "14.133 18.578 l 14.949 19.387 16.867 19.184 17.539 18.465 c 20.551\n" \ - "15.23 l 21.191 14.66 21.336 12.887 20.426 12.102 c 13.18 4.824 l 12.18\n" \ - "3.82 6.25 2.566 4.324 4.461 c 3 6.395 3.383 11.438 4.711 12.801 c 9.648\n" \ - "17.887 l S\n" \ - "0.729412 0.741176 0.713725 RG 16.645 13.035 m 12.418 8.707 l\n" \ - "10.902 7.559 6.402 12.203 8.09 13.562 c\n" \ - "14.133 19.578 l 14.949 20.387 16.867 20.184 17.539 19.465 c 20.551\n" \ - "16.23 l 21.191 15.66 21.336 13.887 20.426 13.102 c 13.18 5.824 l 12.18\n" \ - "4.82 6.25 3.566 4.324 5.461 c 3 7.395 3.383 12.438 4.711 13.801 c 9.648\n" \ - "18.887 l S\n" - -#define ANNOT_FILE_ATTACHMENT_AP_GRAPH \ - "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ - "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ - "l 1 21.523 2.477 23 4.301 23 c h\n" \ - "4.301 23 m f\n" \ - "0.533333 0.541176 0.521569 RG 1 w\n" \ - "1 J\n" \ - "0 j\n" \ - "[] 0.0 d\n" \ - "4 M 18.5 15.5 m 18.5 13.086 l 16.086 15.5 l 18.5 15.5 l h\n" \ - "18.5 15.5 m S\n" \ - "7 7 m 10 11 l 13 9 l 18 15 l S\n" \ - "0.729412 0.741176 0.713725 RG 7 8 m 10 12 l 13 10 l 18 16 l S\n" \ - "18.5 16.5 m 18.5 14.086 l 16.086 16.5 l 18.5 16.5 l h\n" \ - "18.5 16.5 m S\n" \ - "0.533333 0.541176 0.521569 RG 2 w\n" \ - "1 j\n" \ - "3 19 m 3 3 l 21 3 l S\n" \ - "0.729412 0.741176 0.713725 RG 3 20 m 3 4 l 21 4 l S\n" - -#define ANNOT_FILE_ATTACHMENT_AP_TAG \ - "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ - "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ - "l 1 21.523 2.477 23 4.301 23 c h\n" \ - "4.301 23 m f\n" \ - "0.533333 0.541176 0.521569 RG 0.999781 w\n" \ - "1 J\n" \ - "1 j\n" \ - "[] 0.0 d\n" \ - "4 M q 1 0 0 -1 0 24 cm\n" \ - "8.492 8.707 m 8.492 9.535 7.82 10.207 6.992 10.207 c 6.164 10.207 5.492\n" \ - "9.535 5.492 8.707 c 5.492 7.879 6.164 7.207 6.992 7.207 c 7.82 7.207\n" \ - "8.492 7.879 8.492 8.707 c h\n" \ - "8.492 8.707 m S Q\n" \ - "2 w\n" \ - "20.078 11.414 m 20.891 10.602 20.785 9.293 20.078 8.586 c 14.422 2.93 l\n" \ - "13.715 2.223 12.301 2.223 11.594 2.93 c 3.816 10.707 l 3.109 11.414\n" \ - "2.402 17.781 3.816 19.195 c 5.23 20.609 11.594 19.902 12.301 19.195 c\n" \ - "20.078 11.414 l h\n" \ - "20.078 11.414 m S\n" \ - "0.729412 0.741176 0.713725 RG 20.078 12.414 m\n" \ - "20.891 11.605 20.785 10.293 20.078 9.586 c 14.422 3.93 l\n" \ - "13.715 3.223 12.301 3.223 11.594 3.93 c 3.816 11.707 l 3.109 12.414\n" \ - "2.402 18.781 3.816 20.195 c 5.23 21.609 11.594 20.902 12.301 20.195 c\n" \ - "20.078 12.414 l h\n" \ - "20.078 12.414 m S\n" \ - "0.533333 0.541176 0.521569 RG 1 w\n" \ - "0 j\n" \ - "11.949 13.184 m 16.191 8.941 l S\n" \ - "0.729412 0.741176 0.713725 RG 11.949 14.184 m 16.191 9.941 l S\n" \ - "0.533333 0.541176 0.521569 RG 14.07 6.82 m 9.828 11.062 l S\n" \ - "0.729412 0.741176 0.713725 RG 14.07 7.82 m 9.828 12.062 l S\n" \ - "0.533333 0.541176 0.521569 RG 6.93 15.141 m 8 20 14.27 20.5 16 20.5 c\n" \ - "18.094 20.504 19.5 20 19.5 18 c 19.5 16.699 20.91 16.418 22.5 16.5 c S\n" \ - "0.729412 0.741176 0.713725 RG 0.999781 w\n" \ - "1 j\n" \ - "q 1 0 0 -1 0 24 cm\n" \ - "8.492 7.707 m 8.492 8.535 7.82 9.207 6.992 9.207 c 6.164 9.207 5.492\n" \ - "8.535 5.492 7.707 c 5.492 6.879 6.164 6.207 6.992 6.207 c 7.82 6.207\n" \ - "8.492 6.879 8.492 7.707 c h\n" \ - "8.492 7.707 m S Q\n" \ - "1 w\n" \ - "0 j\n" \ - "6.93 16.141 m 8 21 14.27 21.5 16 21.5 c 18.094 21.504 19.5 21 19.5 19 c\n" \ - "19.5 17.699 20.91 17.418 22.5 17.5 c S\n" - -void AnnotFileAttachment::draw(Gfx *gfx, GBool printing) { - Object obj; - double ca = 1; - - if (!isVisible (printing)) - return; - - annotLocker(); - if (appearance.isNull()) { - ca = opacity; - - appearBuf = new GooString (); - - appearBuf->append ("q\n"); - if (color) - setColor(color, gTrue); - else - appearBuf->append ("1 1 1 rg\n"); - if (!name->cmp("PushPin")) - appearBuf->append (ANNOT_FILE_ATTACHMENT_AP_PUSHPIN); - else if (!name->cmp("Paperclip")) - appearBuf->append (ANNOT_FILE_ATTACHMENT_AP_PAPERCLIP); - else if (!name->cmp("Graph")) - appearBuf->append (ANNOT_FILE_ATTACHMENT_AP_GRAPH); - else if (!name->cmp("Tag")) - appearBuf->append (ANNOT_FILE_ATTACHMENT_AP_TAG); - appearBuf->append ("Q\n"); - - double bbox[4]; - bbox[0] = bbox[1] = 0; - bbox[2] = bbox[3] = 24; - if (ca == 1) { - createForm (bbox, gFalse, NULL, &appearance); - } else { - Object aStream; - - createForm (bbox, gTrue, NULL, &aStream); - delete appearBuf; - - Object resDict; - appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); - createForm(bbox, gFalse, &resDict, &appearance); - } - delete appearBuf; - } - - // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); - gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, - rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - obj.free(); -} - -//------------------------------------------------------------------------ -// AnnotSound -//------------------------------------------------------------------------ -AnnotSound::AnnotSound(PDFDoc *docA, PDFRectangle *rect, Sound *soundA) : - AnnotMarkup(docA, rect) { - Object obj1; - - type = typeSound; - - annotObj.dictSet ("Subtype", obj1.initName ("Sound")); - - Object obj2; - Stream *str = soundA->getStream(); - obj2.initStream (str); - str->incRef(); //FIXME: initStream should do this? - annotObj.dictSet ("Sound", &obj2); - - initialize(docA, annotObj.getDict()); -} - -AnnotSound::AnnotSound(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { - type = typeSound; - initialize(docA, dict); -} - -AnnotSound::~AnnotSound() { - delete sound; - - delete name; -} - -void AnnotSound::initialize(PDFDoc *docA, Dict* dict) { - Object obj1; - - sound = Sound::parseSound(dict->lookup("Sound", &obj1)); - if (!sound) { - error(errSyntaxError, -1, "Bad Annot Sound"); - ok = gFalse; - } - obj1.free(); - - if (dict->lookup("Name", &obj1)->isName()) { - name = new GooString(obj1.getName()); - } else { - name = new GooString("Speaker"); - } - obj1.free(); -} - -#define ANNOT_SOUND_AP_SPEAKER \ - "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ - "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ - "l 1 21.523 2.477 23 4.301 23 c h\n" \ - "4.301 23 m f\n" \ - "0.533333 0.541176 0.521569 RG 2 w\n" \ - "0 J\n" \ - "1 j\n" \ - "[] 0.0 d\n" \ - "4 M 4 14 m 4.086 8.043 l 7 8 l 11 4 l 11 18 l 7 14 l 4 14 l h\n" \ - "4 14 m S\n" \ - "1 w\n" \ - "1 J\n" \ - "0 j\n" \ - "13.699 15.398 m 14.699 13.398 14.699 9.398 13.699 7.398 c S\n" \ - "18.199 19.398 m 21.199 17.398 21.199 5.398 18.199 3.398 c S\n" \ - "16 17.398 m 18 16.398 18 7.398 16 5.398 c S\n" \ - "0.729412 0.741176 0.713725 RG 2 w\n" \ - "0 J\n" \ - "1 j\n" \ - "4 15 m 4.086 9.043 l 7 9 l 11 5 l 11 19 l 7 15 l 4 15 l h\n" \ - "4 15 m S\n" \ - "1 w\n" \ - "1 J\n" \ - "0 j\n" \ - "13.699 16 m 14.699 14 14.699 10 13.699 8 c S\n" \ - "18.199 20 m 21.199 18 21.199 6 18.199 4 c S\n" \ - "16 18 m 18 17 18 8 16 6 c S\n" - -#define ANNOT_SOUND_AP_MIC \ - "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ - "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ - "l 1 21.523 2.477 23 4.301 23 c h\n" \ - "4.301 23 m f\n" \ - "0.533333 0.541176 0.521569 RG 2 w\n" \ - "1 J\n" \ - "0 j\n" \ - "[] 0.0 d\n" \ - "4 M 12 20 m 12 20 l 13.656 20 15 18.656 15 17 c 15 13 l 15 11.344 13.656 10\n" \ - "12 10 c 12 10 l 10.344 10 9 11.344 9 13 c 9 17 l 9 18.656 10.344 20 12\n" \ - "20 c h\n" \ - "12 20 m S\n" \ - "1 w\n" \ - "17.5 14.5 m 17.5 11.973 l 17.5 8.941 15.047 6.5 12 6.5 c 8.953 6.5 6.5\n" \ - "8.941 6.5 11.973 c 6.5 14.5 l S\n" \ - "2 w\n" \ - "0 J\n" \ - "12 6.52 m 12 3 l S\n" \ - "1 J\n" \ - "8 3 m 16 3 l S\n" \ - "0.729412 0.741176 0.713725 RG 12 21 m 12 21 l 13.656 21 15 19.656 15 18 c\n" \ - "15 14 l 15 12.344 13.656 11 12 11 c 12 11 l 10.344 11 9 12.344 9 14 c\n" \ - "9 18 l 9 19.656 10.344 21 12 21 c h\n" \ - "12 21 m S\n" \ - "1 w\n" \ - "17.5 15.5 m 17.5 12.973 l 17.5 9.941 15.047 7.5 12 7.5 c 8.953 7.5 6.5\n" \ - "9.941 6.5 12.973 c 6.5 15.5 l S\n" \ - "2 w\n" \ - "0 J\n" \ - "12 7.52 m 12 4 l S\n" \ - "1 J\n" \ - "8 4 m 16 4 l S\n" - -void AnnotSound::draw(Gfx *gfx, GBool printing) { - Object obj; - double ca = 1; - - if (!isVisible (printing)) - return; - - annotLocker(); - if (appearance.isNull()) { - ca = opacity; - - appearBuf = new GooString (); - - appearBuf->append ("q\n"); - if (color) - setColor(color, gTrue); - else - appearBuf->append ("1 1 1 rg\n"); - if (!name->cmp("Speaker")) - appearBuf->append (ANNOT_SOUND_AP_SPEAKER); - else if (!name->cmp("Mic")) - appearBuf->append (ANNOT_SOUND_AP_MIC); - appearBuf->append ("Q\n"); - - double bbox[4]; - bbox[0] = bbox[1] = 0; - bbox[2] = bbox[3] = 24; - if (ca == 1) { - createForm(bbox, gFalse, NULL, &appearance); - } else { - Object aStream, resDict; - - createForm(bbox, gTrue, NULL, &aStream); - delete appearBuf; - - appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); - createForm(bbox, gFalse, &resDict, &appearance); - } - delete appearBuf; - } - - // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); - gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, - rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - obj.free(); -} - -//------------------------------------------------------------------------ -// Annot3D -//------------------------------------------------------------------------ -Annot3D::Annot3D(PDFDoc *docA, PDFRectangle *rect) : - Annot(docA, rect) { - Object obj1; - - type = type3D; - - annotObj.dictSet ("Subtype", obj1.initName ("3D")); - - initialize(docA, annotObj.getDict()); -} - -Annot3D::Annot3D(PDFDoc *docA, Dict *dict, Object *obj) : - Annot(docA, dict, obj) { - type = type3D; - initialize(docA, dict); -} - -Annot3D::~Annot3D() { - if (activation) - delete activation; -} - -void Annot3D::initialize(PDFDoc *docA, Dict* dict) { - Object obj1; - - if (dict->lookup("3DA", &obj1)->isDict()) { - activation = new Activation(obj1.getDict()); - } else { - activation = NULL; - } - obj1.free(); -} - -Annot3D::Activation::Activation(Dict *dict) { - Object obj1; - - if (dict->lookup("A", &obj1)->isName()) { - const char *name = obj1.getName(); - - if(!strcmp(name, "PO")) { - aTrigger = aTriggerPageOpened; - } else if(!strcmp(name, "PV")) { - aTrigger = aTriggerPageVisible; - } else if(!strcmp(name, "XA")) { - aTrigger = aTriggerUserAction; - } else { - aTrigger = aTriggerUnknown; - } - } else { - aTrigger = aTriggerUnknown; - } - obj1.free(); - - if(dict->lookup("AIS", &obj1)->isName()) { - const char *name = obj1.getName(); - - if(!strcmp(name, "I")) { - aState = aStateEnabled; - } else if(!strcmp(name, "L")) { - aState = aStateDisabled; - } else { - aState = aStateUnknown; - } - } else { - aState = aStateUnknown; - } - obj1.free(); - - if(dict->lookup("D", &obj1)->isName()) { - const char *name = obj1.getName(); - - if(!strcmp(name, "PC")) { - dTrigger = dTriggerPageClosed; - } else if(!strcmp(name, "PI")) { - dTrigger = dTriggerPageInvisible; - } else if(!strcmp(name, "XD")) { - dTrigger = dTriggerUserAction; - } else { - dTrigger = dTriggerUnknown; - } - } else { - dTrigger = dTriggerUnknown; - } - obj1.free(); - - if(dict->lookup("DIS", &obj1)->isName()) { - const char *name = obj1.getName(); - - if(!strcmp(name, "U")) { - dState = dStateUninstantiaded; - } else if(!strcmp(name, "I")) { - dState = dStateInstantiated; - } else if(!strcmp(name, "L")) { - dState = dStateLive; - } else { - dState = dStateUnknown; - } - } else { - dState = dStateUnknown; - } - obj1.free(); - - if (dict->lookup("TB", &obj1)->isBool()) { - displayToolbar = obj1.getBool(); - } else { - displayToolbar = gTrue; - } - obj1.free(); - - if (dict->lookup("NP", &obj1)->isBool()) { - displayNavigation = obj1.getBool(); - } else { - displayNavigation = gFalse; - } - obj1.free(); -} - -//------------------------------------------------------------------------ -// Annots -//------------------------------------------------------------------------ - -Annots::Annots(PDFDoc *docA, int page, Object *annotsObj) { - Annot *annot; - Object obj1; - int i; - - doc = docA; - annots = NULL; - size = 0; - nAnnots = 0; - - if (annotsObj->isArray()) { - for (i = 0; i < annotsObj->arrayGetLength(); ++i) { - //get the Ref to this annot and pass it to Annot constructor - //this way, it'll be possible for the annot to retrieve the corresponding - //form widget - Object obj2; - if (annotsObj->arrayGet(i, &obj1)->isDict()) { - annotsObj->arrayGetNF(i, &obj2); - annot = createAnnot (obj1.getDict(), &obj2); - if (annot) { - if (annot->isOk()) { - annot->setPage(page, gFalse); // Don't change /P - appendAnnot(annot); - } - annot->decRefCnt(); - } - } - obj2.free(); - obj1.free(); - } - } -} - -void Annots::appendAnnot(Annot *annot) { - if (annot && annot->isOk()) { - if (nAnnots >= size) { - size += 16; - annots = (Annot **)greallocn(annots, size, sizeof(Annot *)); - } - annots[nAnnots++] = annot; - annot->incRefCnt(); - } -} - -GBool Annots::removeAnnot(Annot *annot) { - int idx = -1; - // Search annot and determine its index - for (int i = 0; idx == -1 && i < nAnnots; i++) { - if (annots[i] == annot) { - idx = i; - } - } - if (idx == -1) { - return gFalse; - } else { - --nAnnots; - memmove( annots + idx, annots + idx + 1, sizeof(annots[0]) * (nAnnots - idx) ); - annot->decRefCnt(); - return gTrue; - } -} - -Annot *Annots::createAnnot(Dict* dict, Object *obj) { - Annot *annot = NULL; - Object obj1; - - if (dict->lookup("Subtype", &obj1)->isName()) { - const char *typeName = obj1.getName(); - - if (!strcmp(typeName, "Text")) { - annot = new AnnotText(doc, dict, obj); - } else if (!strcmp(typeName, "Link")) { - annot = new AnnotLink(doc, dict, obj); - } else if (!strcmp(typeName, "FreeText")) { - annot = new AnnotFreeText(doc, dict, obj); - } else if (!strcmp(typeName, "Line")) { - annot = new AnnotLine(doc, dict, obj); - } else if (!strcmp(typeName, "Square")) { - annot = new AnnotGeometry(doc, dict, obj); - } else if (!strcmp(typeName, "Circle")) { - annot = new AnnotGeometry(doc, dict, obj); - } else if (!strcmp(typeName, "Polygon")) { - annot = new AnnotPolygon(doc, dict, obj); - } else if (!strcmp(typeName, "PolyLine")) { - annot = new AnnotPolygon(doc, dict, obj); - } else if (!strcmp(typeName, "Highlight")) { - annot = new AnnotTextMarkup(doc, dict, obj); - } else if (!strcmp(typeName, "Underline")) { - annot = new AnnotTextMarkup(doc, dict, obj); - } else if (!strcmp(typeName, "Squiggly")) { - annot = new AnnotTextMarkup(doc, dict, obj); - } else if (!strcmp(typeName, "StrikeOut")) { - annot = new AnnotTextMarkup(doc, dict, obj); - } else if (!strcmp(typeName, "Stamp")) { - annot = new AnnotStamp(doc, dict, obj); - } else if (!strcmp(typeName, "Caret")) { - annot = new AnnotCaret(doc, dict, obj); - } else if (!strcmp(typeName, "Ink")) { - annot = new AnnotInk(doc, dict, obj); - } else if (!strcmp(typeName, "FileAttachment")) { - annot = new AnnotFileAttachment(doc, dict, obj); - } else if (!strcmp(typeName, "Sound")) { - annot = new AnnotSound(doc, dict, obj); - } else if(!strcmp(typeName, "Movie")) { - annot = new AnnotMovie(doc, dict, obj); - } else if(!strcmp(typeName, "Widget")) { - // Find the annot in forms - if (obj->isRef()) { - Form *form = doc->getCatalog()->getForm(); - if (form) { - FormWidget *widget = form->findWidgetByRef(obj->getRef()); - if (widget) { - annot = widget->getWidgetAnnotation(); - annot->incRefCnt(); - } - } - } - if (!annot) - annot = new AnnotWidget(doc, dict, obj); - } else if(!strcmp(typeName, "Screen")) { - annot = new AnnotScreen(doc, dict, obj); - } else if(!strcmp(typeName, "PrinterMark")) { - annot = new Annot(doc, dict, obj); - } else if (!strcmp(typeName, "TrapNet")) { - annot = new Annot(doc, dict, obj); - } else if (!strcmp(typeName, "Watermark")) { - annot = new Annot(doc, dict, obj); - } else if (!strcmp(typeName, "3D")) { - annot = new Annot3D(doc, dict, obj); - } else if (!strcmp(typeName, "Popup")) { - /* Popup annots are already handled by markup annots - * Here we only care about popup annots without a - * markup annotation associated - */ - Object obj2; - - if (dict->lookup("Parent", &obj2)->isNull()) - annot = new AnnotPopup(doc, dict, obj); - else - annot = NULL; - - obj2.free(); - } else { - annot = new Annot(doc, dict, obj); - } - } - obj1.free(); - - return annot; -} - -Annot *Annots::findAnnot(Ref *ref) { - int i; - - for (i = 0; i < nAnnots; ++i) { - if (annots[i]->match(ref)) { - return annots[i]; - } - } - return NULL; -} - - -Annots::~Annots() { - int i; - - for (i = 0; i < nAnnots; ++i) { - annots[i]->decRefCnt(); - } - gfree(annots); -} diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Annot.h b/source/libs/poppler/poppler-0.32.0/poppler/Annot.h deleted file mode 100755 index 8fde6a673..000000000 --- a/source/libs/poppler/poppler-0.32.0/poppler/Annot.h +++ /dev/null @@ -1,1439 +0,0 @@ -//======================================================================== -// -// Annot.h -// -// Copyright 2000-2003 Glyph & Cog, LLC -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2006 Scott Turner <scotty1024@mac.com> -// Copyright (C) 2007, 2008 Julien Rebetez <julienr@svn.gnome.org> -// Copyright (C) 2007-2011, 2013 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright (C) 2007, 2008 Iñigo Martínez <inigomartinez@gmail.com> -// Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu> -// Copyright (C) 2008 Hugo Mercier <hmercier31@gmail.com> -// Copyright (C) 2008 Pino Toscano <pino@kde.org> -// Copyright (C) 2008 Tomas Are Haavet <tomasare@gmail.com> -// Copyright (C) 2009-2011, 2013 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it> -// Copyright (C) 2012 Tobias Koenig <tokoe@kdab.com> -// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> -// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> -// -// To see a description of the changes please see the Changelog file that -// came with your tarball or type make ChangeLog if you are building from git -// -//======================================================================== - -#ifndef ANNOT_H -#define ANNOT_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "Object.h" - -class XRef; -class Gfx; -class CharCodeToUnicode; -class GfxFont; -class GfxResources; -class Page; -class PDFDoc; -class Form; -class FormWidget; -class FormField; -class FormFieldChoice; -class PDFRectangle; -class Movie; -class LinkAction; -class Sound; - -enum AnnotLineEndingStyle { - annotLineEndingSquare, // Square - annotLineEndingCircle, // Circle - annotLineEndingDiamond, // Diamond - annotLineEndingOpenArrow, // OpenArrow - annotLineEndingClosedArrow, // ClosedArrow - annotLineEndingNone, // None - annotLineEndingButt, // Butt - annotLineEndingROpenArrow, // ROpenArrow - annotLineEndingRClosedArrow, // RClosedArrow - annotLineEndingSlash // Slash -}; - -enum AnnotExternalDataType { - annotExternalDataMarkupUnknown, - annotExternalDataMarkup3D // Markup3D -}; - -//------------------------------------------------------------------------ -// AnnotCoord -//------------------------------------------------------------------------ - -class AnnotCoord { -public: - - AnnotCoord() : x(0), y(0) { } - AnnotCoord(double _x, double _y) : x(_x), y(_y) { } - - double getX() const { return x; } - double getY() const { return y; } - -protected: - - double x, y; -}; - -//------------------------------------------------------------------------ -// AnnotPath -//------------------------------------------------------------------------ - -class AnnotPath { -public: - AnnotPath(); - AnnotPath(Array *array); - AnnotPath(AnnotCoord **coords, int coordLength); - ~AnnotPath(); - - double getX(int coord) const; - double getY(int coord) const; - AnnotCoord *getCoord(int coord) const; - int getCoordsLength() const { return coordsLength; } -protected: - AnnotCoord **coords; - int coordsLength; - - void parsePathArray(Array *array); -}; - -//------------------------------------------------------------------------ -// AnnotCalloutLine -//------------------------------------------------------------------------ - -class AnnotCalloutLine { -public: - - AnnotCalloutLine(double x1, double y1, double x2, double y2); - virtual ~AnnotCalloutLine() { } - - double getX1() const { return coord1.getX(); } - double getY1() const { return coord1.getY(); } - double getX2() const { return coord2.getX(); } - double getY2() const { return coord2.getY(); } - -protected: - - AnnotCoord coord1, coord2; -}; - -//------------------------------------------------------------------------ -// AnnotCalloutMultiLine -//------------------------------------------------------------------------ - -class AnnotCalloutMultiLine: public AnnotCalloutLine { -public: - - AnnotCalloutMultiLine(double x1, double y1, double x2, double y2, - double x3, double y3); - - double getX3() const { return coord3.getX(); } - double getY3() const { return coord3.getY(); } - -protected: - - AnnotCoord coord3; -}; - -//------------------------------------------------------------------------ -// AnnotBorderEffect -//------------------------------------------------------------------------ - -class AnnotBorderEffect { -public: - - enum AnnotBorderEffectType { - borderEffectNoEffect, // S - borderEffectCloudy // C - }; - - AnnotBorderEffect(Dict *dict); - - AnnotBorderEffectType getEffectType() const { return effectType; } - double getIntensity() const { return intensity; } - -private: - - AnnotBorderEffectType effectType; // S (Default S) - double intensity; // I (Default 0) -}; - -//------------------------------------------------------------------------ -// AnnotQuadrilateral -//------------------------------------------------------------------------ - -class AnnotQuadrilaterals { -public: - class AnnotQuadrilateral { - public: - AnnotQuadrilateral(double x1, double y1, double x2, double y2, double x3, - double y3, double x4, double y4); - - AnnotCoord coord1, coord2, coord3, coord4; - }; - - AnnotQuadrilaterals(Array *array, PDFRectangle *rect); - AnnotQuadrilaterals(AnnotQuadrilateral **quads, int quadsLength); - ~AnnotQuadrilaterals(); - - double getX1(int quadrilateral); - double getY1(int quadrilateral); - double getX2(int quadrilateral); - double getY2(int quadrilateral); - double getX3(int quadrilateral); - double getY3(int quadrilateral); - double getX4(int quadrilateral); - double getY4(int quadrilateral); - int getQuadrilateralsLength() const { return quadrilateralsLength; } -protected: - - AnnotQuadrilateral** quadrilaterals; - int quadrilateralsLength; -}; - -//------------------------------------------------------------------------ -// AnnotBorder -//------------------------------------------------------------------------ - -class AnnotBorder { -public: - enum AnnotBorderType { - typeArray, - typeBS - }; - - enum AnnotBorderStyle { - borderSolid, // Solid - borderDashed, // Dashed - borderBeveled, // Beveled - borderInset, // Inset - borderUnderlined // Underlined - }; - - virtual ~AnnotBorder(); - - virtual void setWidth(double new_width) { width = new_width; } - - virtual AnnotBorderType getType() const = 0; - virtual double getWidth() const { return width; } - virtual int getDashLength() const { return dashLength; } - virtual double *getDash() const { return dash; } - virtual AnnotBorderStyle getStyle() const { return style; } - - virtual void writeToObject(XRef *xref, Object *obj1) const = 0; - -protected: - AnnotBorder(); - - GBool parseDashArray(Object *dashObj); - - AnnotBorderType type; - double width; - static const int DASH_LIMIT = 10; // implementation note 82 in Appendix H. - int dashLength; - double *dash; - AnnotBorderStyle style; -}; - -//------------------------------------------------------------------------ -// AnnotBorderArray -//------------------------------------------------------------------------ - -class AnnotBorderArray: public AnnotBorder { -public: - AnnotBorderArray(); - AnnotBorderArray(Array *array); - - void setHorizontalCorner(double hc) { horizontalCorner = hc; } - void setVerticalCorner(double vc) { verticalCorner = vc; } - - double getHorizontalCorner() const { return horizontalCorner; } - double getVerticalCorner() const { return verticalCorner; } - -private: - virtual AnnotBorderType getType() const { return typeArray; } - virtual void writeToObject(XRef *xref, Object *obj1) const; - - double horizontalCorner; // (Default 0) - double verticalCorner; // (Default 0) - // double width; // (Default 1) (inherited from AnnotBorder) -}; - -//------------------------------------------------------------------------ -// AnnotBorderBS -//------------------------------------------------------------------------ - -class AnnotBorderBS: public AnnotBorder { -public: - - AnnotBorderBS(); - AnnotBorderBS(Dict *dict); - -private: - virtual AnnotBorderType getType() const { return typeBS; } - virtual void writeToObject(XRef *xref, Object *obj1) const; - - const char *getStyleName() const; - - // double width; // W (Default 1) (inherited from AnnotBorder) - // AnnotBorderStyle style; // S (Default S) (inherited from AnnotBorder) - // double *dash; // D (Default [3]) (inherited from AnnotBorder) -}; - -//------------------------------------------------------------------------ -// AnnotColor -//------------------------------------------------------------------------ - -class AnnotColor { -public: - - enum AnnotColorSpace { - colorTransparent = 0, - colorGray = 1, - colorRGB = 3, - colorCMYK = 4 - }; - - AnnotColor(); - AnnotColor(double gray); - AnnotColor(double r, double g, double b); - AnnotColor(double c, double m, double y, double k); - AnnotColor(Array *array, int adjust = 0); - - void adjustColor(int adjust); - - AnnotColorSpace getSpace() const { return (AnnotColorSpace) length; } - const double *getValues() const { return values; } - - void writeToObject(XRef *xref, Object *dest) const; - -private: - - double values[4]; - int length; -}; - -//------------------------------------------------------------------------ -// AnnotIconFit -//------------------------------------------------------------------------ - -class AnnotIconFit { -public: - - enum AnnotIconFitScaleWhen { - scaleAlways, // A - scaleBigger, // B - scaleSmaller, // S - scaleNever // N - }; - - enum AnnotIconFitScale { - scaleAnamorphic, // A - scaleProportional // P - }; - - AnnotIconFit(Dict *dict); - - AnnotIconFitScaleWhen getScaleWhen() { return scaleWhen; } - AnnotIconFitScale getScale() { return scale; } - double getLeft() { return left; } - double getBottom() { return bottom; } - bool getFullyBounds() { return fullyBounds; } - -protected: - - AnnotIconFitScaleWhen scaleWhen; // SW (Default A) - AnnotIconFitScale scale; // S (Default P) - double left; // A (Default [0.5 0.5] - double bottom; // Only if scale is P - bool fullyBounds; // FB (Default false) -}; - -//------------------------------------------------------------------------ -// AnnotAppearance -//------------------------------------------------------------------------ - -class AnnotAppearance { -public: - - enum AnnotAppearanceType { - appearNormal, - appearRollover, - appearDown - }; - - AnnotAppearance(PDFDoc *docA, Object *dict); - ~AnnotAppearance(); - - // State is ignored if no subdictionary is present - void getAppearanceStream(AnnotAppearanceType type, const char *state, Object *dest); - - // Access keys in normal appearance subdictionary (N) - GooString * getStateKey(int i); - int getNumStates(); - - // Removes all associated streams in the xref table. Caller is required to - // reset parent annotation's AP and AS after this call. - void removeAllStreams(); - - // Test if this AnnotAppearance references the specified stream - GBool referencesStream(Ref targetStreamRef); - -private: - static GBool referencesStream(Object *stateObj, Ref targetStreamRef); - void removeStream(Ref refToStream); - void removeStateStreams(Object *state); - -protected: - PDFDoc *doc; - XRef *xref; // the xref table for this PDF file - Object appearDict; // Annotation's AP -}; - -//------------------------------------------------------------------------ -// AnnotAppearanceCharacs -//------------------------------------------------------------------------ - -class AnnotAppearanceCharacs { -public: - - enum AnnotAppearanceCharacsTextPos { - captionNoIcon, // 0 - captionNoCaption, // 1 - captionBelow, // 2 - captionAbove, // 3 - captionRight, // 4 - captionLeft, // 5 - captionOverlaid // 6 - }; - - AnnotAppearanceCharacs(Dict *dict); - ~AnnotAppearanceCharacs(); - - int getRotation() { return rotation; } - AnnotColor *getBorderColor() { return borderColor; } - AnnotColor *getBackColor() { return backColor; } - GooString *getNormalCaption() { return normalCaption; } - GooString *getRolloverCaption() { return rolloverCaption; } - GooString *getAlternateCaption() { return alternateCaption; } - AnnotIconFit *getIconFit() { return iconFit; } - AnnotAppearanceCharacsTextPos getPosition() { return position; } - -protected: - - int rotation; // R (Default 0) - AnnotColor *borderColor; // BC - AnnotColor *backColor; // BG - GooString *normalCaption; // CA - GooString *rolloverCaption; // RC - GooString *alternateCaption; // AC - // I - // RI - // IX - AnnotIconFit *iconFit; // IF - AnnotAppearanceCharacsTextPos position; // TP (Default 0) -}; - -//------------------------------------------------------------------------ -// AnnotAppearanceBBox -//------------------------------------------------------------------------ - -class AnnotAppearanceBBox -{ -public: - AnnotAppearanceBBox(PDFRectangle *init); - - void setBorderWidth(double w) { borderWidth = w; } - - // The following functions operate on coords relative to [origX origY] - void extendTo(double x, double y); - void getBBoxRect(double bbox[4]) const; - - // Get boundaries in page coordinates - double getPageXMin() const; - double getPageYMin() const; - double getPageXMax() const; - double getPageYMax() const; - -private: - double origX, origY, borderWidth; - double minX, minY, maxX, maxY; -}; - -//------------------------------------------------------------------------ -// Annot -//------------------------------------------------------------------------ - -class Annot { - friend class Annots; - friend class Page; -public: - enum AnnotFlag { - flagUnknown = 0x0000, - flagInvisible = 0x0001, - flagHidden = 0x0002, - flagPrint = 0x0004, - flagNoZoom = 0x0008, - flagNoRotate = 0x0010, - flagNoView = 0x0020, - flagReadOnly = 0x0040, - flagLocked = 0x0080, - flagToggleNoView = 0x0100, - flagLockedContents = 0x0200 - }; - - enum AnnotSubtype { - typeUnknown, // 0 - typeText, // Text 1 - typeLink, // Link 2 - typeFreeText, // FreeText 3 - typeLine, // Line 4 - typeSquare, // Square 5 - typeCircle, // Circle 6 - typePolygon, // Polygon 7 - typePolyLine, // PolyLine 8 - typeHighlight, // Highlight 9 - typeUnderline, // Underline 10 - typeSquiggly, // Squiggly 11 - typeStrikeOut, // StrikeOut 12 - typeStamp, // Stamp 13 - typeCaret, // Caret 14 - typeInk, // Ink 15 - typePopup, // Popup 16 - typeFileAttachment, // FileAttachment 17 - typeSound, // Sound 18 - typeMovie, // Movie 19 - typeWidget, // Widget 20 - typeScreen, // Screen 21 - typePrinterMark, // PrinterMark 22 - typeTrapNet, // TrapNet 23 - typeWatermark, // Watermark 24 - type3D // 3D 25 - }; - - /** - * Describes the additional actions of a screen or widget annotation. - */ - enum AdditionalActionsType { - actionCursorEntering, ///< Performed when the cursor enters the annotation's active area - actionCursorLeaving, ///< Performed when the cursor exists the annotation's active area - actionMousePressed, ///< Performed when the mouse button is pressed inside the annotation's active area - actionMouseReleased, ///< Performed when the mouse button is released inside the annotation's active area - actionFocusIn, ///< Performed when the annotation receives the input focus - actionFocusOut, ///< Performed when the annotation loses the input focus - actionPageOpening, ///< Performed when the page containing the annotation is opened - actionPageClosing, ///< Performed when the page containing the annotation is closed - actionPageVisible, ///< Performed when the page containing the annotation becomes visible - actionPageInvisible ///< Performed when the page containing the annotation becomes invisible - }; - - enum FormAdditionalActionsType { - actionFieldModified, ///< Performed when the when the user modifies the field - actionFormatField, ///< Performed before the field is formatted to display its value - actionValidateField, ///< Performed when the field value changes - actionCalculateField, ///< Performed when the field needs to be recalculated - }; - - Annot(PDFDoc *docA, PDFRectangle *rectA); - Annot(PDFDoc *docA, Dict *dict); - Annot(PDFDoc *docA, Dict *dict, Object *obj); - GBool isOk() { return ok; } - - void incRefCnt(); - void decRefCnt(); - - virtual void draw(Gfx *gfx, GBool printing); - // Get the resource dict of the appearance stream - virtual Object *getAppearanceResDict(Object *dest); - - GBool match(Ref *refA) - { return ref.num == refA->num && ref.gen == refA->gen; } - - double getXMin(); - double getYMin(); - double getXMax(); - double getYMax(); - - double getFontSize() { return fontSize; } - - void setRect(PDFRectangle *rect); - void setRect(double x1, double y1, double x2, double y2); - - // Sets the annot contents to new_content - // new_content should never be NULL - virtual void setContents(GooString *new_content); - void setName(GooString *new_name); - void setModified(GooString *new_date); - void setFlags(Guint new_flags); - - void setBorder(AnnotBorder *new_border); // Takes ownership - - // The annotation takes the ownership of - // new_color. - void setColor(AnnotColor *new_color); - - void setAppearanceState(const char *state); - - // getters - PDFDoc *getDoc() const { return doc; } - XRef *getXRef() const { return xref; } - GBool getHasRef() const { return hasRef; } - Ref getRef() const { return ref; } - AnnotSubtype getType() const { return type; } - PDFRectangle *getRect() const { return rect; } - void getRect(double *x1, double *y1, double *x2, double *y2) const; - GooString *getContents() const { return contents; } - int getPageNum() const { return page; } - GooString *getName() const { return name; } - GooString *getModified() const { return modified; } - Guint getFlags() const { return flags; } - AnnotAppearance *getAppearStreams() const { return appearStreams; } - GooString *getAppearState() const { return appearState; } - AnnotBorder *getBorder() const { return border; } - AnnotColor *getColor() const { return color; } - int getTreeKey() const { return treeKey; } - - int getId() { return ref.num; } - - // Check if point is inside the annot rectangle. - GBool inRect(double x, double y) const; - -private: - void readArrayNum(Object *pdfArray, int key, double *value); - // write vStr[i:j[ in appearBuf - - void initialize (PDFDoc *docA, Dict *dict); - void setPage (int new_page, GBool updateP); // Called by Page::addAnnot and Annots ctor - - -protected: - virtual ~Annot(); - virtual void removeReferencedObjects(); // Called by Page::removeAnnot - void setColor(AnnotColor *color, GBool fill); - void setLineStyleForBorder(AnnotBorder *border); - void drawCircle(double cx, double cy, double r, GBool fill); - void drawCircleTopLeft(double cx, double cy, double r); - void drawCircleBottomRight(double cx, double cy, double r); - void layoutText(GooString *text, GooString *outBuf, int *i, GfxFont *font, - double *width, double widthLimit, int *charCount, - GBool noReencode); - void writeString(GooString *str, GooString *appearBuf); - void createForm(double *bbox, GBool transparencyGroup, Object *resDict, Object *aStream); - void createResourcesDict(const char *formName, Object *formStream, const char *stateName, - double opacity, const char *blendMode, Object *resDict); - GBool isVisible(GBool printing); - int getRotation() const; - - // Updates the field key of the annotation dictionary - // and sets M to the current time - void update(const char *key, Object *value); - - // Delete appearance streams and reset appearance state - void invalidateAppearance(); - - int refCnt; - - Object annotObj; - - // required data - AnnotSubtype type; // Annotation type - PDFRectangle *rect; // Rect - - // optional data - GooString *contents; // Contents - int page; // P - GooString *name; // NM - GooString *modified; // M - Guint flags; // F (must be a 32 bit unsigned int) - AnnotAppearance *appearStreams; // AP - Object appearance; // a reference to the Form XObject stream - // for the normal appearance - AnnotAppearanceBBox *appearBBox; // BBox of generated appearance - GooString *appearState; // AS - int treeKey; // Struct Parent; - Object oc; // OC - - PDFDoc *doc; - XRef *xref; // the xref table for this PDF file - Ref ref; // object ref identifying this annotation - GooString *appearBuf; - AnnotBorder *border; // Border, BS - AnnotColor *color; // C - double fontSize; - GBool ok; - - bool hasRef; -#if MULTITHREADED - GooMutex mutex; -#endif -}; - -//------------------------------------------------------------------------ -// AnnotPopup -//------------------------------------------------------------------------ - -class AnnotPopup: public Annot { -public: - AnnotPopup(PDFDoc *docA, PDFRectangle *rect); - AnnotPopup(PDFDoc *docA, Dict *dict, Object *obj); - ~AnnotPopup(); - - Object *getParent(Object *obj) { return parent.fetch (xref, obj); } - Object *getParentNF(Object *obj) { return &parent; } - void setParent(Object *parentA); - void setParent(Annot *parentA); - GBool getOpen() const { return open; } - void setOpen(GBool openA); - -protected: - void initialize(PDFDoc *docA, Dict *dict); - - Object parent; // Parent - GBool open; // Open -}; - -//------------------------------------------------------------------------ -// AnnotMarkup -//------------------------------------------------------------------------ - -class AnnotMarkup: public Annot { -public: - enum AnnotMarkupReplyType { - replyTypeR, // R - replyTypeGroup // Group - }; - - AnnotMarkup(PDFDoc *docA, PDFRectangle *rect); - AnnotMarkup(PDFDoc *docA, Dict *dict, Object *obj); - virtual ~AnnotMarkup(); - - // getters - GooString *getLabel() const { return label; } - AnnotPopup *getPopup() const { return popup; } - double getOpacity() const { return opacity; } - // getRC - GooString *getDate() const { return date; } - int getInReplyToID() const { return inReplyTo.num; } - GooString *getSubject() const { return subject; } - AnnotMarkupReplyType getReplyTo() const { return replyTo; } - AnnotExternalDataType getExData() const { return exData; } - - // The annotation takes the ownership of new_popup - void setPopup(AnnotPopup *new_popup); - void setLabel(GooString *new_label); - void setOpacity(double opacityA); - void setDate(GooString *new_date); - -protected: - virtual void removeReferencedObjects(); - - GooString *label; // T (Default autor) - AnnotPopup *popup; // Popup - double opacity; // CA (Default 1.0) - // RC - GooString *date; // CreationDate - Ref inReplyTo; // IRT - GooString *subject; // Subj - AnnotMarkupReplyType replyTo; // RT (Default R) - // this object is overrided by the custom intent fields defined in some - // annotation types. - //GooString *intent; // IT - AnnotExternalDataType exData; // ExData - -private: - void initialize(PDFDoc *docA, Dict *dict, Object *obj); -}; - -//------------------------------------------------------------------------ -// AnnotText -//------------------------------------------------------------------------ - -class AnnotText: public AnnotMarkup { -public: - enum AnnotTextState { - stateUnknown, - // Marked state model - stateMarked, // Marked - stateUnmarked, // Unmarked - // Review state model - stateAccepted, // Accepted - stateRejected, // Rejected - stateCancelled, // Cancelled - stateCompleted, // Completed - stateNone // None - }; - - AnnotText(PDFDoc *docA, PDFRectangle *rect); - AnnotText(PDFDoc *docA, Dict *dict, Object *obj); - ~AnnotText(); - - virtual void draw(Gfx *gfx, GBool printing); - - // getters - GBool getOpen() const { return open; } - GooString *getIcon() const { return icon; } - AnnotTextState getState() const { return state; } - - void setOpen(GBool openA); - void setIcon(GooString *new_icon); - -private: - - void initialize(PDFDoc *docA, Dict *dict); - - GBool open; // Open (Default false) - GooString *icon; // Name (Default Note) - AnnotTextState state; // State (Default Umarked if - // StateModel Marked - // None if StareModel Review) -}; - -//------------------------------------------------------------------------ -// AnnotMovie -//------------------------------------------------------------------------ - - - -class AnnotMovie: public Annot { - public: - AnnotMovie(PDFDoc *docA, PDFRectangle *rect, Movie *movieA); - AnnotMovie(PDFDoc *docA, Dict *dict, Object *obj); - ~AnnotMovie(); - - virtual void draw(Gfx *gfx, GBool printing); - - GooString* getTitle() { return title; } - Movie* getMovie() { return movie; } - - private: - void initialize(PDFDoc *docA, Dict *dict); - - GooString* title; // T - Movie* movie; // Movie + A -}; - - -//------------------------------------------------------------------------ -// AnnotScreen -//------------------------------------------------------------------------ - -class AnnotScreen: public Annot { - public: - - AnnotScreen(PDFDoc *docA, PDFRectangle *rect); - AnnotScreen(PDFDoc *docA, Dict *dict, Object *obj); - ~AnnotScreen(); - - GooString* getTitle() { return title; } - - AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs; } - LinkAction* getAction() { return action; } - LinkAction *getAdditionalAction(AdditionalActionsType type); - - private: - void initialize(PDFDoc *docA, Dict *dict); - - - GooString* title; // T - - AnnotAppearanceCharacs* appearCharacs; // MK - - LinkAction *action; // A - Object additionalActions; // AA -}; - -//------------------------------------------------------------------------ -// AnnotLink -//------------------------------------------------------------------------ - -class AnnotLink: public Annot { -public: - - enum AnnotLinkEffect { - effectNone, // N - effectInvert, // I - effectOutline, // O - effectPush // P - }; - - AnnotLink(PDFDoc *docA, PDFRectangle *rect); - AnnotLink(PDFDoc *docA, Dict *dict, Object *obj); - virtual ~AnnotLink(); - - virtual void draw(Gfx *gfx, GBool printing); - - // getters - LinkAction *getAction() const { return action; } - AnnotLinkEffect getLinkEffect() const { return linkEffect; } - Dict *getUriAction() const { return uriAction; } - AnnotQuadrilaterals *getQuadrilaterals() const { return quadrilaterals; } - -protected: - - void initialize(PDFDoc *docA, Dict *dict); - - LinkAction *action; // A, Dest - AnnotLinkEffect linkEffect; // H (Default I) - Dict *uriAction; // PA - - AnnotQuadrilaterals *quadrilaterals; // QuadPoints -}; - -//------------------------------------------------------------------------ -// AnnotFreeText -//------------------------------------------------------------------------ - -class AnnotFreeText: public AnnotMarkup { -public: - - enum AnnotFreeTextQuadding { - quaddingLeftJustified, // 0 - quaddingCentered, // 1 - quaddingRightJustified // 2 - }; - - enum AnnotFreeTextIntent { - intentFreeText, // FreeText - intentFreeTextCallout, // FreeTextCallout - intentFreeTextTypeWriter // FreeTextTypeWriter - }; - - AnnotFreeText(PDFDoc *docA, PDFRectangle *rect, GooString *da); - AnnotFreeText(PDFDoc *docA, Dict *dict, Object *obj); - ~AnnotFreeText(); - - virtual void draw(Gfx *gfx, GBool printing); - virtual Object *getAppearanceResDict(Object *dest); - virtual void setContents(GooString *new_content); - - void setAppearanceString(GooString *new_string); - void setQuadding(AnnotFreeTextQuadding new_quadding); - void setStyleString(GooString *new_string); - void setCalloutLine(AnnotCalloutLine *line); - void setIntent(AnnotFreeTextIntent new_intent); - - // getters - GooString *getAppearanceString() const { return appearanceString; } - AnnotFreeTextQuadding getQuadding() const { return quadding; } - // return rc - GooString *getStyleString() const { return styleString; } - AnnotCalloutLine *getCalloutLine() const { return calloutLine; } - AnnotFreeTextIntent getIntent() const { return intent; } - AnnotBorderEffect *getBorderEffect() const { return borderEffect; } - PDFRectangle *getRectangle() const { return rectangle; } - AnnotLineEndingStyle getEndStyle() const { return endStyle; } - -protected: - - void initialize(PDFDoc *docA, Dict *dict); - static void parseAppearanceString(GooString *da, double &fontsize, AnnotColor* &fontcolor); - void generateFreeTextAppearance(); - - // required - GooString *appearanceString; // DA - - // optional - AnnotFreeTextQuadding quadding; // Q (Default 0) - // RC - GooString *styleString; // DS - AnnotCalloutLine *calloutLine; // CL - AnnotFreeTextIntent intent; // IT - AnnotBorderEffect *borderEffect; // BE - PDFRectangle *rectangle; // RD - // inherited from Annot - // AnnotBorderBS border; // BS - AnnotLineEndingStyle endStyle; // LE (Default None) -}; - -//------------------------------------------------------------------------ -// AnnotLine -//------------------------------------------------------------------------ - -class AnnotLine: public AnnotMarkup { -public: - - enum AnnotLineIntent { - intentLineArrow, // LineArrow - intentLineDimension // LineDimension - }; - - enum AnnotLineCaptionPos { - captionPosInline, // Inline - captionPosTop // Top - }; - - AnnotLine(PDFDoc *docA, PDFRectangle *rect); - AnnotLine(PDFDoc *docA, Dict *dict, Object *obj); - ~AnnotLine(); - - virtual void draw(Gfx *gfx, GBool printing); - virtual Object *getAppearanceResDict(Object *dest); - virtual void setContents(GooString *new_content); - - void setVertices(double x1, double y1, double x2, double y2); - void setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end); - void setInteriorColor(AnnotColor *new_color); - void setLeaderLineLength(double len); - void setLeaderLineExtension(double len); - void setCaption(bool new_cap); - void setIntent(AnnotLineIntent new_intent); - - // getters - AnnotLineEndingStyle getStartStyle() const { return startStyle; } - AnnotLineEndingStyle getEndStyle() const { return endStyle; } - AnnotColor *getInteriorColor() const { return interiorColor; } - double getLeaderLineLength() const { return leaderLineLength; } - double getLeaderLineExtension() const { return leaderLineExtension; } - bool getCaption() const { return caption; } - AnnotLineIntent getIntent() const { return intent; } - double getLeaderLineOffset() const { return leaderLineOffset; } - AnnotLineCaptionPos getCaptionPos() const { return captionPos; } - Dict *getMeasure() const { return measure; } - double getCaptionTextHorizontal() const { return captionTextHorizontal; } - double getCaptionTextVertical() const { return captionTextVertical; } - double getX1() const { return coord1->getX(); } - double getY1() const { return coord1->getY(); } - double getX2() const { return coord2->getX(); } - double getY2() const { return coord2->getY(); } - -protected: - - void initialize(PDFDoc *docA, Dict *dict); - void generateLineAppearance(); - - // required - AnnotCoord *coord1, *coord2; - - // optional - // inherited from Annot - // AnnotBorderBS border; // BS - AnnotLineEndingStyle startStyle; // LE (Default [/None /None]) - AnnotLineEndingStyle endStyle; // - AnnotColor *interiorColor; // IC - double leaderLineLength; // LL (Default 0) - double leaderLineExtension; // LLE (Default 0) - bool caption; // Cap (Default false) - AnnotLineIntent intent; // IT - double leaderLineOffset; // LLO - AnnotLineCaptionPos captionPos; // CP (Default Inline) - Dict *measure; // Measure - double captionTextHorizontal; // CO (Default [0, 0]) - double captionTextVertical; // -}; - -//------------------------------------------------------------------------ -// AnnotTextMarkup -//------------------------------------------------------------------------ - -class AnnotTextMarkup: public AnnotMarkup { -public: - - AnnotTextMarkup(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType); - AnnotTextMarkup(PDFDoc *docA, Dict *dict, Object *obj); - virtual ~AnnotTextMarkup(); - - virtual void draw(Gfx *gfx, GBool printing); - - // typeHighlight, typeUnderline, typeSquiggly or typeStrikeOut - void setType(AnnotSubtype new_type); - - void setQuadrilaterals(AnnotQuadrilaterals *quadPoints); - - AnnotQuadrilaterals *getQuadrilaterals() const { return quadrilaterals; } - -protected: - - void initialize(PDFDoc *docA, Dict *dict); - - AnnotQuadrilaterals *quadrilaterals; // QuadPoints -}; - -//------------------------------------------------------------------------ -// AnnotStamp -//------------------------------------------------------------------------ - -class AnnotStamp: public AnnotMarkup { -public: - - AnnotStamp(PDFDoc *docA, PDFRectangle *rect); - AnnotStamp(PDFDoc *docA, Dict *dict, Object *obj); - ~AnnotStamp(); - - void setIcon(GooString *new_icon); - - // getters - GooString *getIcon() const { return icon; } - -private: - - void initialize(PDFDoc *docA, Dict *dict); - - GooString *icon; // Name (Default Draft) -}; - -//------------------------------------------------------------------------ -// AnnotGeometry -//------------------------------------------------------------------------ - -class AnnotGeometry: public AnnotMarkup { -public: - - AnnotGeometry(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType); - AnnotGeometry(PDFDoc *docA, Dict *dict, Object *obj); - ~AnnotGeometry(); - - virtual void draw(Gfx *gfx, GBool printing); - - void setType(AnnotSubtype new_type); // typeSquare or typeCircle - void setInteriorColor(AnnotColor *new_color); - - // getters - AnnotColor *getInteriorColor() const { return interiorColor; } - AnnotBorderEffect *getBorderEffect() const { return borderEffect; } - PDFRectangle *getGeometryRect() const { return geometryRect; } - -private: - - void initialize(PDFDoc *docA, Dict *dict); - - AnnotColor *interiorColor; // IC - AnnotBorderEffect *borderEffect; // BE - PDFRectangle *geometryRect; // RD (combined with Rect) -}; - -//------------------------------------------------------------------------ -// AnnotPolygon -//------------------------------------------------------------------------ - -class AnnotPolygon: public AnnotMarkup { -public: - - enum AnnotPolygonIntent { - polygonCloud, // PolygonCloud - polylineDimension, // PolyLineDimension - polygonDimension // PolygonDimension - }; - - AnnotPolygon(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType); - AnnotPolygon(PDFDoc *docA, Dict *dict, Object *obj); - ~AnnotPolygon(); - - virtual void draw(Gfx *gfx, GBool printing); - - void setType(AnnotSubtype new_type); // typePolygon or typePolyLine - void setVertices(AnnotPath *path); - void setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end); - void setInteriorColor(AnnotColor *new_color); - void setIntent(AnnotPolygonIntent new_intent); - - // getters - AnnotPath *getVertices() const { return vertices; } - AnnotLineEndingStyle getStartStyle() const { return startStyle; } - AnnotLineEndingStyle getEndStyle() const { return endStyle; } - AnnotColor *getInteriorColor() const { return interiorColor; } - AnnotBorderEffect *getBorderEffect() const { return borderEffect; } - AnnotPolygonIntent getIntent() const { return intent; } - -private: - - void initialize(PDFDoc *docA, Dict *dict); - - // required - AnnotPath *vertices; // Vertices - - // optional - AnnotLineEndingStyle startStyle; // LE (Default [/None /None]) - AnnotLineEndingStyle endStyle; // - // inherited from Annot - // AnnotBorderBS border; // BS - AnnotColor *interiorColor; // IC - AnnotBorderEffect *borderEffect; // BE - AnnotPolygonIntent intent; // IT - // Measure -}; - -//------------------------------------------------------------------------ -// AnnotCaret -//------------------------------------------------------------------------ - -class AnnotCaret: public AnnotMarkup { -public: - - enum AnnotCaretSymbol { - symbolNone, // None - symbolP // P - }; - - AnnotCaret(PDFDoc *docA, PDFRectangle *rect); - AnnotCaret(PDFDoc *docA, Dict *dict, Object *obj); - ~AnnotCaret(); - - void setSymbol(AnnotCaretSymbol new_symbol); - - // getters - AnnotCaretSymbol getSymbol() const { return symbol; } - PDFRectangle *getCaretRect() const { return caretRect; } - -private: - - void initialize(PDFDoc *docA, Dict *dict); - - AnnotCaretSymbol symbol; // Sy (Default None) - PDFRectangle *caretRect; // RD (combined with Rect) -}; - -//------------------------------------------------------------------------ -// AnnotInk -//------------------------------------------------------------------------ - -class AnnotInk: public AnnotMarkup { -public: - - AnnotInk(PDFDoc *docA, PDFRectangle *rect); - AnnotInk(PDFDoc *docA, Dict *dict, Object *obj); - ~AnnotInk(); - - virtual void draw(Gfx *gfx, GBool printing); - - void setInkList(AnnotPath **paths, int n_paths); - - // getters - AnnotPath **getInkList() const { return inkList; } - int getInkListLength() const { return inkListLength; } - -private: - - void initialize(PDFDoc *docA, Dict *dict); - void writeInkList(AnnotPath **paths, int n_paths, Array *dest_array); - void parseInkList(Array *src_array); - void freeInkList(); - - // required - AnnotPath **inkList; // InkList - int inkListLength; - - // optional - // inherited from Annot - // AnnotBorderBS border; // BS -}; - -//------------------------------------------------------------------------ -// AnnotFileAttachment -//------------------------------------------------------------------------ - -class AnnotFileAttachment: public AnnotMarkup { -public: - - AnnotFileAttachment(PDFDoc *docA, PDFRectangle *rect, GooString *filename); - AnnotFileAttachment(PDFDoc *docA, Dict *dict, Object *obj); - ~AnnotFileAttachment(); - - virtual void draw(Gfx *gfx, GBool printing); - - // getters - Object *getFile() { return &file; } - GooString *getName() const { return name; } - -private: - - void initialize(PDFDoc *docA, Dict *dict); - - // required - Object file; // FS - - // optional - GooString *name; // Name -}; - -//------------------------------------------------------------------------ -// AnnotSound -//------------------------------------------------------------------------ - -class AnnotSound: public AnnotMarkup { -public: - - AnnotSound(PDFDoc *docA, PDFRectangle *rect, Sound *soundA); - AnnotSound(PDFDoc *docA, Dict *dict, Object *obj); - ~AnnotSound(); - - virtual void draw(Gfx *gfx, GBool printing); - - // getters - Sound *getSound() { return sound; } - GooString *getName() const { return name; } - -private: - - void initialize(PDFDoc *docA, Dict *dict); - - // required - Sound *sound; // Sound - - // optional - GooString *name; // Name -}; - -//------------------------------------------------------------------------ -// AnnotWidget -//------------------------------------------------------------------------ - -class AnnotWidget: public Annot { -public: - - enum AnnotWidgetHighlightMode { - highlightModeNone, // N - highlightModeInvert, // I - highlightModeOutline, // O - highlightModePush // P,T - }; - - AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj); - AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj, FormField *fieldA); - virtual ~AnnotWidget(); - - virtual void draw(Gfx *gfx, GBool printing); - - void drawBorder(); - void drawFormFieldButton(GfxResources *resources, GooString *da); - void drawFormFieldText(GfxResources *resources, GooString *da); - void drawFormFieldChoice(GfxResources *resources, GooString *da); - void generateFieldAppearance (); - void updateAppearanceStream (); - - AnnotWidgetHighlightMode getMode() { return mode; } - AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs; } - LinkAction *getAction() { return action; } - LinkAction *getAdditionalAction(AdditionalActionsType type); - LinkAction *getFormAdditionalAction(FormAdditionalActionsType type); - Dict *getParent() { return parent; } - -private: - - void initialize(PDFDoc *docA, Dict *dict); - - void drawText(GooString *text, GooString *da, GfxResources *resources, - GBool multiline, int comb, int quadding, - GBool txField, GBool forceZapfDingbats, - GBool password=false); - void drawListBox(FormFieldChoice *fieldChoice, - GooString *da, GfxResources *resources, int quadding); - - Form *form; - FormField *field; // FormField object for this annotation - AnnotWidgetHighlightMode mode; // H (Default I) - AnnotAppearanceCharacs *appearCharacs; // MK - LinkAction *action; // A - Object additionalActions; // AA - // inherited from Annot - // AnnotBorderBS border; // BS - Dict *parent; // Parent - GBool addDingbatsResource; - Ref updatedAppearanceStream; // {-1,-1} if updateAppearanceStream has never been called -}; - -//------------------------------------------------------------------------ -// Annot3D -//------------------------------------------------------------------------ - -class Annot3D: public Annot { - class Activation { - public: - enum ActivationATrigger { - aTriggerUnknown, - aTriggerPageOpened, // PO - aTriggerPageVisible, // PV - aTriggerUserAction // XA - }; - - enum ActivationAState { - aStateUnknown, - aStateEnabled, // I - aStateDisabled // L - }; - - enum ActivationDTrigger { - dTriggerUnknown, - dTriggerPageClosed, // PC - dTriggerPageInvisible, // PI - dTriggerUserAction // XD - }; - - enum ActivationDState { - dStateUnknown, - dStateUninstantiaded, // U - dStateInstantiated, // I - dStateLive // L - }; - - Activation(Dict *dict); - private: - - ActivationATrigger aTrigger; // A (Default XA) - ActivationAState aState; // AIS (Default L) - ActivationDTrigger dTrigger; // D (Default PI) - ActivationDState dState; // DIS (Default U) - GBool displayToolbar; // TB (Default true) - GBool displayNavigation; // NP (Default false); - }; -public: - - Annot3D(PDFDoc *docA, PDFRectangle *rect); - Annot3D(PDFDoc *docA, Dict *dict, Object *obj); - ~Annot3D(); - - // getters - -private: - - void initialize(PDFDoc *docA, Dict *dict); - - Activation *activation; // 3DA -}; - -//------------------------------------------------------------------------ -// Annots -//------------------------------------------------------------------------ - -class Annots { -public: - - // Build a list of Annot objects and call setPage on them - Annots(PDFDoc *docA, int page, Object *annotsObj); - - ~Annots(); - - // Iterate through list of annotations. - int getNumAnnots() { return nAnnots; } - Annot *getAnnot(int i) { return annots[i]; } - void appendAnnot(Annot *annot); - GBool removeAnnot(Annot *annot); - -private: - Annot* createAnnot(Dict* dict, Object *obj); - Annot *findAnnot(Ref *ref); - - PDFDoc *doc; - Annot **annots; - int nAnnots; - int size; -}; - -#endif diff --git a/source/libs/poppler/poppler-0.32.0/poppler/CairoFontEngine.cc b/source/libs/poppler/poppler-0.32.0/poppler/CairoFontEngine.cc deleted file mode 100755 index a5a302320..000000000 --- a/source/libs/poppler/poppler-0.32.0/poppler/CairoFontEngine.cc +++ /dev/null @@ -1,825 +0,0 @@ -//======================================================================== -// -// CairoFontEngine.cc -// -// Copyright 2003 Glyph & Cog, LLC -// Copyright 2004 Red Hat, Inc -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2005-2007 Jeff Muizelaar <jeff@infidigm.net> -// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> -// Copyright (C) 2005, 2009, 2012, 2013, 2015 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2006, 2007, 2010, 2011 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright (C) 2007 Koji Otani <sho@bbr.jp> -// Copyright (C) 2008, 2009 Chris Wilson <chris@chris-wilson.co.uk> -// Copyright (C) 2008, 2012, 2014 Adrian Johnson <ajohnson@redneon.com> -// Copyright (C) 2009 Darren Kenny <darren.kenny@sun.com> -// Copyright (C) 2010 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> -// Copyright (C) 2010 Jan Kümmel <jan+freedesktop@snorc.org> -// Copyright (C) 2012 Hib Eris <hib@hiberis.nl> -// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> -// -// To see a description of the changes please see the Changelog file that -// came with your tarball or type make ChangeLog if you are building from git -// -//======================================================================== - -#include <config.h> - -#include "config.h" -#include <string.h> -#include "CairoFontEngine.h" -#include "CairoOutputDev.h" -#include "GlobalParams.h" -#include <fofi/FoFiTrueType.h> -#include <fofi/FoFiType1C.h> -#include "goo/gfile.h" -#include "Error.h" -#include "XRef.h" -#include "Gfx.h" -#include "Page.h" - -#if HAVE_FCNTL_H && HAVE_SYS_MMAN_H && HAVE_SYS_STAT_H -#include <fcntl.h> -#include <sys/stat.h> -#include <sys/mman.h> -#define CAN_CHECK_OPEN_FACES 1 -#endif - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#if MULTITHREADED -# define fontEngineLocker() MutexLocker locker(&mutex) -#else -# define fontEngineLocker() -#endif - -//------------------------------------------------------------------------ -// CairoFont -//------------------------------------------------------------------------ - -CairoFont::CairoFont(Ref ref, - cairo_font_face_t *cairo_font_face, - int *codeToGID, - Guint codeToGIDLen, - GBool substitute, - GBool printing) : ref(ref), - cairo_font_face(cairo_font_face), - codeToGID(codeToGID), - codeToGIDLen(codeToGIDLen), - substitute(substitute), - printing(printing) { } - -CairoFont::~CairoFont() { - cairo_font_face_destroy (cairo_font_face); - gfree(codeToGID); -} - -GBool -CairoFont::matches(Ref &other, GBool printingA) { - return (other.num == ref.num && other.gen == ref.gen); -} - -cairo_font_face_t * -CairoFont::getFontFace(void) { - return cairo_font_face; -} - -unsigned long -CairoFont::getGlyph(CharCode code, - Unicode *u, int uLen) { - FT_UInt gid; - - if (codeToGID && code < codeToGIDLen) { - gid = (FT_UInt)codeToGID[code]; - } else { - gid = (FT_UInt)code; - } - return gid; -} - -double -CairoFont::getSubstitutionCorrection(GfxFont *gfxFont) -{ - double w1, w2; - CharCode code; - char *name; - - // for substituted fonts: adjust the font matrix -- compare the - // width of 'm' in the original font and the substituted font - if (isSubstitute() && !gfxFont->isCIDFont()) { - for (code = 0; code < 256; ++code) { - if ((name = ((Gfx8BitFont *)gfxFont)->getCharName(code)) && - name[0] == 'm' && name[1] == '\0') { - break; - } - } - if (code < 256) { - w1 = ((Gfx8BitFont *)gfxFont)->getWidth(code); - { - cairo_matrix_t m; - cairo_matrix_init_identity(&m); - cairo_font_options_t *options = cairo_font_options_create(); - cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE); - cairo_font_options_set_hint_metrics(options, CAIRO_HINT_METRICS_OFF); - cairo_scaled_font_t *scaled_font = cairo_scaled_font_create(cairo_font_face, &m, &m, options); - - cairo_text_extents_t extents; - cairo_scaled_font_text_extents(scaled_font, "m", &extents); - - cairo_scaled_font_destroy(scaled_font); - cairo_font_options_destroy(options); - w2 = extents.x_advance; - } - if (!gfxFont->isSymbolic()) { - // if real font is substantially narrower than substituted - // font, reduce the font size accordingly - if (w1 > 0.01 && w1 < 0.9 * w2) { - w1 /= w2; - return w1; - } - } - } - } - return 1.0; -} - -//------------------------------------------------------------------------ -// CairoFreeTypeFont -//------------------------------------------------------------------------ - -static cairo_user_data_key_t _ft_cairo_key; - -static void -_ft_done_face_uncached (void *closure) -{ - FT_Face face = (FT_Face) closure; - FT_Done_Face (face); -} - -static GBool -_ft_new_face_uncached (FT_Library lib, - const char *filename, - char *font_data, - int font_data_len, - FT_Face *face_out, - cairo_font_face_t **font_face_out) -{ - FT_Face face; - cairo_font_face_t *font_face; - - if (font_data == NULL) { - if (FT_New_Face (lib, filename, 0, &face)) - return gFalse; - } else { - if (FT_New_Memory_Face (lib, (unsigned char *)font_data, font_data_len, 0, &face)) - return gFalse; - } - - font_face = cairo_ft_font_face_create_for_ft_face (face, - FT_LOAD_NO_HINTING | - FT_LOAD_NO_BITMAP); - if (cairo_font_face_set_user_data (font_face, - &_ft_cairo_key, - face, - _ft_done_face_uncached)) - { - _ft_done_face_uncached (face); - cairo_font_face_destroy (font_face); - return gFalse; - } - - *face_out = face; - *font_face_out = font_face; - return gTrue; -} - -#if CAN_CHECK_OPEN_FACES -static struct _ft_face_data { - struct _ft_face_data *prev, *next, **head; - - int fd; - unsigned long hash; - size_t size; - unsigned char *bytes; - - FT_Library lib; - FT_Face face; - cairo_font_face_t *font_face; -} *_ft_open_faces; - -static unsigned long -_djb_hash (const unsigned char *bytes, size_t len) -{ - unsigned long hash = 5381; - while (len--) { - unsigned char c = *bytes++; - hash *= 33; - hash ^= c; - } - return hash; -} - -static GBool -_ft_face_data_equal (struct _ft_face_data *a, struct _ft_face_data *b) -{ - if (a->lib != b->lib) - return gFalse; - if (a->size != b->size) - return gFalse; - if (a->hash != b->hash) - return gFalse; - - return memcmp (a->bytes, b->bytes, a->size) == 0; -} - -static void -_ft_done_face (void *closure) -{ - struct _ft_face_data *data = (struct _ft_face_data *) closure; - - if (data->next) - data->next->prev = data->prev; - if (data->prev) - data->prev->next = data->next; - else - _ft_open_faces = data->next; - -#if defined(__SUNPRO_CC) && defined(__sun) && defined(__SVR4) - munmap ((char*)data->bytes, data->size); -#else - munmap (data->bytes, data->size); -#endif - close (data->fd); - - FT_Done_Face (data->face); - gfree (data); -} - -static GBool -_ft_new_face (FT_Library lib, - const char *filename, - char *font_data, - int font_data_len, - FT_Face *face_out, - cairo_font_face_t **font_face_out) -{ - struct _ft_face_data *l; - struct stat st; - struct _ft_face_data tmpl; - - tmpl.fd = -1; - - if (font_data == NULL) { - /* if we fail to mmap the file, just pass it to FreeType instead */ - tmpl.fd = open (filename, O_RDONLY); - if (tmpl.fd == -1) - return _ft_new_face_uncached (lib, filename, font_data, font_data_len, face_out, font_face_out); - - if (fstat (tmpl.fd, &st) == -1) { - close (tmpl.fd); - return _ft_new_face_uncached (lib, filename, font_data, font_data_len, face_out, font_face_out); - } - - tmpl.bytes = (unsigned char *) mmap (NULL, st.st_size, - PROT_READ, MAP_PRIVATE, - tmpl.fd, 0); - if (tmpl.bytes == MAP_FAILED) { - close (tmpl.fd); - return _ft_new_face_uncached (lib, filename, font_data, font_data_len, face_out, font_face_out); - } - tmpl.size = st.st_size; - } else { - tmpl.bytes = (unsigned char*) font_data; - tmpl.size = font_data_len; - } - - /* check to see if this is a duplicate of any of the currently open fonts */ - tmpl.lib = lib; - tmpl.hash = _djb_hash (tmpl.bytes, tmpl.size); - - for (l = _ft_open_faces; l; l = l->next) { - if (_ft_face_data_equal (l, &tmpl)) { - if (tmpl.fd != -1) { -#if defined(__SUNPRO_CC) && defined(__sun) && defined(__SVR4) - munmap ((char*)tmpl.bytes, tmpl.size); -#else - munmap (tmpl.bytes, tmpl.size); -#endif - close (tmpl.fd); - } - *face_out = l->face; - *font_face_out = cairo_font_face_reference (l->font_face); - return gTrue; - } - } - - /* not a dup, open and insert into list */ - if (FT_New_Memory_Face (lib, - (FT_Byte *) tmpl.bytes, tmpl.size, - 0, &tmpl.face)) - { - if (tmpl.fd != -1) { -#if defined(__SUNPRO_CC) && defined(__sun) && defined(__SVR4) - munmap ((char*)tmpl.bytes, tmpl.size); -#else - munmap (tmpl.bytes, tmpl.size); -#endif - - close (tmpl.fd); - } - return gFalse; - } - - l = (struct _ft_face_data *) gmallocn (1, sizeof (struct _ft_face_data)); - *l = tmpl; - l->prev = NULL; - l->next = _ft_open_faces; - if (_ft_open_faces) - _ft_open_faces->prev = l; - _ft_open_faces = l; - - l->font_face = cairo_ft_font_face_create_for_ft_face (tmpl.face, - FT_LOAD_NO_HINTING | - FT_LOAD_NO_BITMAP); - if (cairo_font_face_set_user_data (l->font_face, - &_ft_cairo_key, - l, - _ft_done_face)) - { - cairo_font_face_destroy (l->font_face); - _ft_done_face (l); - return gFalse; - } - - *face_out = l->face; - *font_face_out = l->font_face; - return gTrue; -} -#else -#define _ft_new_face _ft_new_face_uncached -#endif - -CairoFreeTypeFont::CairoFreeTypeFont(Ref ref, - cairo_font_face_t *cairo_font_face, - int *codeToGID, - Guint codeToGIDLen, - GBool substitute) : CairoFont(ref, - cairo_font_face, - codeToGID, - codeToGIDLen, - substitute, - gTrue) { } - -CairoFreeTypeFont::~CairoFreeTypeFont() { } - -CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, - FT_Library lib, GBool useCIDs) { - Object refObj, strObj; - GooString *fileName; - char *fileNameC; - char *font_data; - int font_data_len; - int i, n; - GfxFontType fontType; - GfxFontLoc *fontLoc; - char **enc; - const char *name; - FoFiTrueType *ff; - FoFiType1C *ff1c; - Ref ref; - FT_Face face; - cairo_font_face_t *font_face; - - int *codeToGID; - Guint codeToGIDLen; - - codeToGID = NULL; - codeToGIDLen = 0; - font_data = NULL; - font_data_len = 0; - fileName = NULL; - fileNameC = NULL; - - GBool substitute = gFalse; - - ref = *gfxFont->getID(); - fontType = gfxFont->getType(); - - if (!(fontLoc = gfxFont->locateFont(xref, NULL))) { - error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'", - gfxFont->getName() ? gfxFont->getName()->getCString() - : "(unnamed)"); - goto err2; - } - - // embedded font - if (fontLoc->locType == gfxFontLocEmbedded) { - font_data = gfxFont->readEmbFontFile(xref, &font_data_len); - if (NULL == font_data) - goto err2; - - // external font - } else { // gfxFontLocExternal - fileName = fontLoc->path; - fontType = fontLoc->fontType; - substitute = gTrue; - } - - if (fileName != NULL) { - fileNameC = fileName->getCString(); - } - - switch (fontType) { - case fontType1: - case fontType1C: - case fontType1COT: - if (! _ft_new_face (lib, fileNameC, font_data, font_data_len, &face, &font_face)) { - error(errSyntaxError, -1, "could not create type1 face"); - goto err2; - } - - enc = ((Gfx8BitFont *)gfxFont)->getEncoding(); - - codeToGID = (int *)gmallocn(256, sizeof(int)); - codeToGIDLen = 256; - for (i = 0; i < 256; ++i) { - codeToGID[i] = 0; - if ((name = enc[i])) { - codeToGID[i] = FT_Get_Name_Index(face, (char*)name); - if (codeToGID[i] == 0) { - name = GfxFont::getAlternateName(name); - if (name) { - codeToGID[i] = FT_Get_Name_Index(face, (char*)name); - } - } - } - } - break; - case fontCIDType2: - case fontCIDType2OT: - codeToGID = NULL; - n = 0; - if (((GfxCIDFont *)gfxFont)->getCIDToGID()) { - n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen(); - if (n) { - codeToGID = (int *)gmallocn(n, sizeof(int)); - memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), - n * sizeof(int)); - } - } else { - if (font_data != NULL) { - ff = FoFiTrueType::make(font_data, font_data_len); - } else { - ff = FoFiTrueType::load(fileNameC); - } - if (! ff) - goto err2; - codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n); - delete ff; - } - codeToGIDLen = n; - /* Fall through */ - case fontTrueType: - if (font_data != NULL) { - ff = FoFiTrueType::make(font_data, font_data_len); - } else { - ff = FoFiTrueType::load(fileNameC); - } - if (! ff) { - error(errSyntaxError, -1, "failed to load truetype font\n"); - goto err2; - } - /* This might be set already for the CIDType2 case */ - if (fontType == fontTrueType) { - codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff); - codeToGIDLen = 256; - } - delete ff; - if (! _ft_new_face (lib, fileNameC, font_data, font_data_len, &face, &font_face)) { - error(errSyntaxError, -1, "could not create truetype face\n"); - goto err2; - } - break; - - case fontCIDType0: - case fontCIDType0C: - - codeToGID = NULL; - codeToGIDLen = 0; - - if (!useCIDs) - { - if (font_data != NULL) { - ff1c = FoFiType1C::make(font_data, font_data_len); - } else { - ff1c = FoFiType1C::load(fileNameC); - } - if (ff1c) { - codeToGID = ff1c->getCIDToGIDMap((int *)&codeToGIDLen); - delete ff1c; - } - } - - if (! _ft_new_face (lib, fileNameC, font_data, font_data_len, &face, &font_face)) { - gfree(codeToGID); - codeToGID = NULL; - error(errSyntaxError, -1, "could not create cid face\n"); - goto err2; - } - break; - - default: - fprintf (stderr, "font type %d not handled\n", (int)fontType); - goto err2; - break; - } - - delete fontLoc; - return new CairoFreeTypeFont(ref, - font_face, - codeToGID, codeToGIDLen, - substitute); - - err2: - /* hmm? */ - delete fontLoc; - fprintf (stderr, "some font thing failed\n"); - return NULL; -} - -//------------------------------------------------------------------------ -// CairoType3Font -//------------------------------------------------------------------------ - -static const cairo_user_data_key_t type3_font_key = {0}; - -typedef struct _type3_font_info { - GfxFont *font; - PDFDoc *doc; - CairoFontEngine *fontEngine; - GBool printing; - XRef *xref; -} type3_font_info_t; - -static void -_free_type3_font_info(void *closure) -{ - type3_font_info_t *info = (type3_font_info_t *) closure; - - info->font->decRefCnt(); - free (info); -} - -static cairo_status_t -_init_type3_glyph (cairo_scaled_font_t *scaled_font, - cairo_t *cr, - cairo_font_extents_t *extents) -{ - type3_font_info_t *info; - GfxFont *font; - double *mat; - - info = (type3_font_info_t *) - cairo_font_face_get_user_data (cairo_scaled_font_get_font_face (scaled_font), - &type3_font_key); - font = info->font; - mat = font->getFontBBox(); - extents->ascent = mat[3]; /* y2 */ - extents->descent = -mat[3]; /* -y1 */ - extents->height = extents->ascent + extents->descent; - extents->max_x_advance = mat[2] - mat[1]; /* x2 - x1 */ - extents->max_y_advance = 0; - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_status_t -_render_type3_glyph (cairo_scaled_font_t *scaled_font, - unsigned long glyph, - cairo_t *cr, - cairo_text_extents_t *metrics) -{ - Dict *charProcs; - Object charProc; - CairoOutputDev *output_dev; - cairo_matrix_t matrix, invert_y_axis; - double *mat; - double wx, wy; - PDFRectangle box; - type3_font_info_t *info; - GfxFont *font; - Dict *resDict; - Gfx *gfx; - - info = (type3_font_info_t *) - cairo_font_face_get_user_data (cairo_scaled_font_get_font_face (scaled_font), - &type3_font_key); - - font = info->font; - resDict = ((Gfx8BitFont *)font)->getResources(); - charProcs = ((Gfx8BitFont *)(info->font))->getCharProcs(); - if (!charProcs) - return CAIRO_STATUS_USER_FONT_ERROR; - - if ((int)glyph >= charProcs->getLength()) - return CAIRO_STATUS_USER_FONT_ERROR; - - mat = font->getFontMatrix(); - matrix.xx = mat[0]; - matrix.yx = mat[1]; - matrix.xy = mat[2]; - matrix.yy = mat[3]; - matrix.x0 = mat[4]; - matrix.y0 = mat[5]; - cairo_matrix_init_scale (&invert_y_axis, 1, -1); - cairo_matrix_multiply (&matrix, &matrix, &invert_y_axis); - cairo_transform (cr, &matrix); - - output_dev = new CairoOutputDev(); - output_dev->setCairo(cr); - output_dev->setPrinting(info->printing); - - mat = font->getFontBBox(); - box.x1 = mat[0]; - box.y1 = mat[1]; - box.x2 = mat[2]; - box.y2 = mat[3]; - gfx = new Gfx(info->doc, output_dev, resDict, &box, NULL); - output_dev->startDoc(info->doc, info->fontEngine); - output_dev->startPage (1, gfx->getState(), gfx->getXRef()); - output_dev->setInType3Char(gTrue); - gfx->display(charProcs->getVal(glyph, &charProc)); - - output_dev->getType3GlyphWidth (&wx, &wy); - cairo_matrix_transform_distance (&matrix, &wx, &wy); - metrics->x_advance = wx; - metrics->y_advance = wy; - if (output_dev->hasType3GlyphBBox()) { - double *bbox = output_dev->getType3GlyphBBox(); - - cairo_matrix_transform_point (&matrix, &bbox[0], &bbox[1]); - cairo_matrix_transform_point (&matrix, &bbox[2], &bbox[3]); - metrics->x_bearing = bbox[0]; - metrics->y_bearing = bbox[1]; - metrics->width = bbox[2] - bbox[0]; - metrics->height = bbox[3] - bbox[1]; - } - - delete gfx; - delete output_dev; - charProc.free(); - - return CAIRO_STATUS_SUCCESS; -} - - -CairoType3Font *CairoType3Font::create(GfxFont *gfxFont, PDFDoc *doc, - CairoFontEngine *fontEngine, - GBool printing, XRef *xref) { - Object refObj, strObj; - type3_font_info_t *info; - cairo_font_face_t *font_face; - Ref ref; - int *codeToGID; - Guint codeToGIDLen; - int i, j; - char **enc; - Dict *charProcs; - char *name; - - charProcs = ((Gfx8BitFont *)gfxFont)->getCharProcs(); - info = (type3_font_info_t *) malloc(sizeof(*info)); - ref = *gfxFont->getID(); - font_face = cairo_user_font_face_create(); - cairo_user_font_face_set_init_func (font_face, _init_type3_glyph); - cairo_user_font_face_set_render_glyph_func (font_face, _render_type3_glyph); - gfxFont->incRefCnt(); - info->font = gfxFont; - info->doc = doc; - info->fontEngine = fontEngine; - info->printing = printing; - info->xref = xref; - - cairo_font_face_set_user_data (font_face, &type3_font_key, (void *) info, _free_type3_font_info); - - enc = ((Gfx8BitFont *)gfxFont)->getEncoding(); - codeToGID = (int *)gmallocn(256, sizeof(int)); - codeToGIDLen = 256; - for (i = 0; i < 256; ++i) { - codeToGID[i] = 0; - if (charProcs && (name = enc[i])) { - for (j = 0; j < charProcs->getLength(); j++) { - if (strcmp(name, charProcs->getKey(j)) == 0) { - codeToGID[i] = j; - } - } - } - } - - return new CairoType3Font(ref, doc, font_face, codeToGID, codeToGIDLen, printing, xref); -} - -CairoType3Font::CairoType3Font(Ref ref, - PDFDoc *doc, - cairo_font_face_t *cairo_font_face, - int *codeToGID, - Guint codeToGIDLen, - GBool printing, XRef *xref) : CairoFont(ref, - cairo_font_face, - codeToGID, - codeToGIDLen, - gFalse, - printing), - doc(doc) { } - -CairoType3Font::~CairoType3Font() { } - -GBool -CairoType3Font::matches(Ref &other, GBool printingA) { - return (other.num == ref.num && other.gen == ref.gen && printing == printingA); -} - - -//------------------------------------------------------------------------ -// CairoFontEngine -//------------------------------------------------------------------------ - -CairoFontEngine::CairoFontEngine(FT_Library libA) { - int i; - - lib = libA; - for (i = 0; i < cairoFontCacheSize; ++i) { - fontCache[i] = NULL; - } - - FT_Int major, minor, patch; - // as of FT 2.1.8, CID fonts are indexed by CID instead of GID - FT_Library_Version(lib, &major, &minor, &patch); - useCIDs = major > 2 || - (major == 2 && (minor > 1 || (minor == 1 && patch > 7))); -#if MULTITHREADED - gInitMutex(&mutex); -#endif -} - -CairoFontEngine::~CairoFontEngine() { - int i; - - for (i = 0; i < cairoFontCacheSize; ++i) { - if (fontCache[i]) - delete fontCache[i]; - } -#if MULTITHREADED - gDestroyMutex(&mutex); -#endif -} - -CairoFont * -CairoFontEngine::getFont(GfxFont *gfxFont, PDFDoc *doc, GBool printing, XRef *xref) { - int i, j; - Ref ref; - CairoFont *font; - GfxFontType fontType; - - fontEngineLocker(); - ref = *gfxFont->getID(); - - for (i = 0; i < cairoFontCacheSize; ++i) { - font = fontCache[i]; - if (font && font->matches(ref, printing)) { - for (j = i; j > 0; --j) { - fontCache[j] = fontCache[j-1]; - } - fontCache[0] = font; - return font; - } - } - - fontType = gfxFont->getType(); - if (fontType == fontType3) - font = CairoType3Font::create (gfxFont, doc, this, printing, xref); - else - font = CairoFreeTypeFont::create (gfxFont, xref, lib, useCIDs); - - //XXX: if font is null should we still insert it into the cache? - if (fontCache[cairoFontCacheSize - 1]) { - delete fontCache[cairoFontCacheSize - 1]; - } - for (j = cairoFontCacheSize - 1; j > 0; --j) { - fontCache[j] = fontCache[j-1]; - } - fontCache[0] = font; - return font; -} diff --git a/source/libs/poppler/poppler-0.32.0/poppler/GfxFont.cc b/source/libs/poppler/poppler-0.32.0/poppler/GfxFont.cc deleted file mode 100755 index 3e9b7db42..000000000 --- a/source/libs/poppler/poppler-0.32.0/poppler/GfxFont.cc +++ /dev/null @@ -1,2632 +0,0 @@ -//======================================================================== -// -// GfxFont.cc -// -// Copyright 1996-2003 Glyph & Cog, LLC -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2005, 2006, 2008-2010, 2012, 2014, 2015 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> -// Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org> -// Copyright (C) 2007 Jeff Muizelaar <jeff@infidigm.net> -// Copyright (C) 2007 Koji Otani <sho@bbr.jp> -// Copyright (C) 2007 Ed Catmur <ed@catmur.co.uk> -// Copyright (C) 2008 Jonathan Kew <jonathan_kew@sil.org> -// Copyright (C) 2008 Ed Avis <eda@waniasset.com> -// Copyright (C) 2008, 2010 Hib Eris <hib@hiberis.nl> -// Copyright (C) 2009 Peter Kerzum <kerzum@yandex-team.ru> -// Copyright (C) 2009, 2010 David Benjamin <davidben@mit.edu> -// Copyright (C) 2011 Axel Strübing <axel.struebing@freenet.de> -// Copyright (C) 2011, 2012, 2014 Adrian Johnson <ajohnson@redneon.com> -// Copyright (C) 2012 Yi Yang <ahyangyi@gmail.com> -// Copyright (C) 2012 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> -// Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de> -// Copyright (C) 2013, 2014 Jason Crain <jason@aquaticape.us> -// Copyright (C) 2014 Olly Betts <olly@survex.com> -// -// To see a description of the changes please see the Changelog file that -// came with your tarball or type make ChangeLog if you are building from git -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <ctype.h> -#include <math.h> -#include <limits.h> -#include <algorithm> -#include "goo/gmem.h" -#include "Error.h" -#include "Object.h" -#include "Dict.h" -#include "GlobalParams.h" -#include "CMap.h" -#include "CharCodeToUnicode.h" -#include "FontEncodingTables.h" -#include "BuiltinFontTables.h" -#include "UnicodeTypeTable.h" -#include <fofi/FoFiIdentifier.h> -#include <fofi/FoFiType1.h> -#include <fofi/FoFiType1C.h> -#include <fofi/FoFiTrueType.h> -#include "GfxFont.h" -#include "PSOutputDev.h" - -//------------------------------------------------------------------------ - -struct Base14FontMapEntry { - const char *altName; - const char *base14Name; -}; - -static const Base14FontMapEntry base14FontMap[] = { - { "Arial", "Helvetica" }, - { "Arial,Bold", "Helvetica-Bold" }, - { "Arial,BoldItalic", "Helvetica-BoldOblique" }, - { "Arial,Italic", "Helvetica-Oblique" }, - { "Arial-Bold", "Helvetica-Bold" }, - { "Arial-BoldItalic", "Helvetica-BoldOblique" }, - { "Arial-BoldItalicMT", "Helvetica-BoldOblique" }, - { "Arial-BoldMT", "Helvetica-Bold" }, - { "Arial-Italic", "Helvetica-Oblique" }, - { "Arial-ItalicMT", "Helvetica-Oblique" }, - { "ArialMT", "Helvetica" }, - { "Courier", "Courier" }, - { "Courier,Bold", "Courier-Bold" }, - { "Courier,BoldItalic", "Courier-BoldOblique" }, - { "Courier,Italic", "Courier-Oblique" }, - { "Courier-Bold", "Courier-Bold" }, - { "Courier-BoldOblique", "Courier-BoldOblique" }, - { "Courier-Oblique", "Courier-Oblique" }, - { "CourierNew", "Courier" }, - { "CourierNew,Bold", "Courier-Bold" }, - { "CourierNew,BoldItalic", "Courier-BoldOblique" }, - { "CourierNew,Italic", "Courier-Oblique" }, - { "CourierNew-Bold", "Courier-Bold" }, - { "CourierNew-BoldItalic", "Courier-BoldOblique" }, - { "CourierNew-Italic", "Courier-Oblique" }, - { "CourierNewPS-BoldItalicMT", "Courier-BoldOblique" }, - { "CourierNewPS-BoldMT", "Courier-Bold" }, - { "CourierNewPS-ItalicMT", "Courier-Oblique" }, - { "CourierNewPSMT", "Courier" }, - { "Helvetica", "Helvetica" }, - { "Helvetica,Bold", "Helvetica-Bold" }, - { "Helvetica,BoldItalic", "Helvetica-BoldOblique" }, - { "Helvetica,Italic", "Helvetica-Oblique" }, - { "Helvetica-Bold", "Helvetica-Bold" }, - { "Helvetica-BoldItalic", "Helvetica-BoldOblique" }, - { "Helvetica-BoldOblique", "Helvetica-BoldOblique" }, - { "Helvetica-Italic", "Helvetica-Oblique" }, - { "Helvetica-Oblique", "Helvetica-Oblique" }, - { "Symbol", "Symbol" }, - { "Symbol,Bold", "Symbol" }, - { "Symbol,BoldItalic", "Symbol" }, - { "Symbol,Italic", "Symbol" }, - { "Times-Bold", "Times-Bold" }, - { "Times-BoldItalic", "Times-BoldItalic" }, - { "Times-Italic", "Times-Italic" }, - { "Times-Roman", "Times-Roman" }, - { "TimesNewRoman", "Times-Roman" }, - { "TimesNewRoman,Bold", "Times-Bold" }, - { "TimesNewRoman,BoldItalic", "Times-BoldItalic" }, - { "TimesNewRoman,Italic", "Times-Italic" }, - { "TimesNewRoman-Bold", "Times-Bold" }, - { "TimesNewRoman-BoldItalic", "Times-BoldItalic" }, - { "TimesNewRoman-Italic", "Times-Italic" }, - { "TimesNewRomanPS", "Times-Roman" }, - { "TimesNewRomanPS-Bold", "Times-Bold" }, - { "TimesNewRomanPS-BoldItalic", "Times-BoldItalic" }, - { "TimesNewRomanPS-BoldItalicMT", "Times-BoldItalic" }, - { "TimesNewRomanPS-BoldMT", "Times-Bold" }, - { "TimesNewRomanPS-Italic", "Times-Italic" }, - { "TimesNewRomanPS-ItalicMT", "Times-Italic" }, - { "TimesNewRomanPSMT", "Times-Roman" }, - { "TimesNewRomanPSMT,Bold", "Times-Bold" }, - { "TimesNewRomanPSMT,BoldItalic", "Times-BoldItalic" }, - { "TimesNewRomanPSMT,Italic", "Times-Italic" }, - { "ZapfDingbats", "ZapfDingbats" } -}; - -//------------------------------------------------------------------------ - -// index: {fixed:0, sans-serif:4, serif:8} + bold*2 + italic -// NB: must be in same order as psSubstFonts in PSOutputDev.cc -static const char *base14SubstFonts[14] = { - "Courier", - "Courier-Oblique", - "Courier-Bold", - "Courier-BoldOblique", - "Helvetica", - "Helvetica-Oblique", - "Helvetica-Bold", - "Helvetica-BoldOblique", - "Times-Roman", - "Times-Italic", - "Times-Bold", - "Times-BoldItalic", - // the last two are never used for substitution - "Symbol", - "ZapfDingbats" -}; - -//------------------------------------------------------------------------ - -static int parseCharName(char *charName, Unicode *uBuf, int uLen, - GBool names, GBool ligatures, - GBool numeric, GBool hex, GBool variants); - -//------------------------------------------------------------------------ - -static int readFromStream(void *data) { - return ((Stream *)data)->getChar(); -} - -//------------------------------------------------------------------------ -// GfxFontLoc -//------------------------------------------------------------------------ - -GfxFontLoc::GfxFontLoc() { - path = NULL; - fontNum = 0; - encoding = NULL; - substIdx = -1; -} - -GfxFontLoc::~GfxFontLoc() { - if (path) { - delete path; - } - if (encoding) { - delete encoding; - } -} - -//------------------------------------------------------------------------ -// GfxFont -//------------------------------------------------------------------------ - -GfxFont *GfxFont::makeFont(XRef *xref, const char *tagA, Ref idA, Dict *fontDict) { - GooString *nameA; - Ref embFontIDA; - GfxFontType typeA; - GfxFont *font; - Object obj1; - - // get base font name - nameA = NULL; - fontDict->lookup("BaseFont", &obj1); - if (obj1.isName()) { - nameA = new GooString(obj1.getName()); - } - obj1.free(); - - // get embedded font ID and font type - typeA = getFontType(xref, fontDict, &embFontIDA); - - // create the font object - font = NULL; - if (typeA < fontCIDType0) { - font = new Gfx8BitFont(xref, tagA, idA, nameA, typeA, embFontIDA, - fontDict); - } else { - font = new GfxCIDFont(xref, tagA, idA, nameA, typeA, embFontIDA, - fontDict); - } - - return font; -} - -GfxFont::GfxFont(const char *tagA, Ref idA, GooString *nameA, - GfxFontType typeA, Ref embFontIDA) { - ok = gFalse; - tag = new GooString(tagA); - id = idA; - name = nameA; - type = typeA; - embFontID = embFontIDA; - embFontName = NULL; - family = NULL; - stretch = StretchNotDefined; - weight = WeightNotDefined; - refCnt = 1; - encodingName = new GooString(""); - hasToUnicode = gFalse; -} - -GfxFont::~GfxFont() { - delete tag; - delete family; - if (name) { - delete name; - } - if (embFontName) { - delete embFontName; - } - if (encodingName) { - delete encodingName; - } -} - -void GfxFont::incRefCnt() { - refCnt++; -} - -void GfxFont::decRefCnt() { - if (--refCnt == 0) - delete this; -} - -// This function extracts three pieces of information: -// 1. the "expected" font type, i.e., the font type implied by -// Font.Subtype, DescendantFont.Subtype, and -// FontDescriptor.FontFile3.Subtype -// 2. the embedded font object ID -// 3. the actual font type - determined by examining the embedded font -// if there is one, otherwise equal to the expected font type -// If the expected and actual font types don't match, a warning -// message is printed. The expected font type is not used for -// anything else. -GfxFontType GfxFont::getFontType(XRef *xref, Dict *fontDict, Ref *embID) { - GfxFontType t, expectedType; - FoFiIdentifierType fft; - Dict *fontDict2; - Object subtype, fontDesc, obj1, obj2, obj3, obj4; - GBool isType0, err; - - t = fontUnknownType; - embID->num = embID->gen = -1; - err = gFalse; - - fontDict->lookup("Subtype", &subtype); - expectedType = fontUnknownType; - isType0 = gFalse; - if (subtype.isName("Type1") || subtype.isName("MMType1")) { - expectedType = fontType1; - } else if (subtype.isName("Type1C")) { - expectedType = fontType1C; - } else if (subtype.isName("Type3")) { - expectedType = fontType3; - } else if (subtype.isName("TrueType")) { - expectedType = fontTrueType; - } else if (subtype.isName("Type0")) { - isType0 = gTrue; - } else { - error(errSyntaxWarning, -1, "Unknown font type: '{0:s}'", - subtype.isName() ? subtype.getName() : "???"); - } - subtype.free(); - - fontDict2 = fontDict; - if (fontDict->lookup("DescendantFonts", &obj1)->isArray()) { - if (obj1.arrayGetLength() == 0) { - error(errSyntaxWarning, -1, "Empty DescendantFonts array in font"); - obj2.initNull(); - } else if (obj1.arrayGet(0, &obj2)->isDict()) { - if (!isType0) { - error(errSyntaxWarning, -1, "Non-CID font with DescendantFonts array"); - } - fontDict2 = obj2.getDict(); - fontDict2->lookup("Subtype", &subtype); - if (subtype.isName("CIDFontType0")) { - if (isType0) { - expectedType = fontCIDType0; - } - } else if (subtype.isName("CIDFontType2")) { - if (isType0) { - expectedType = fontCIDType2; - } - } - subtype.free(); - } - } else { - obj2.initNull(); - } - - if (fontDict2->lookup("FontDescriptor", &fontDesc)->isDict()) { - if (fontDesc.dictLookupNF("FontFile", &obj3)->isRef()) { - *embID = obj3.getRef(); - if (expectedType != fontType1) { - err = gTrue; - } - } - obj3.free(); - if (embID->num == -1 && - fontDesc.dictLookupNF("FontFile2", &obj3)->isRef()) { - *embID = obj3.getRef(); - if (isType0) { - expectedType = fontCIDType2; - } else if (expectedType != fontTrueType) { - err = gTrue; - } - } - obj3.free(); - if (embID->num == -1 && - fontDesc.dictLookupNF("FontFile3", &obj3)->isRef()) { - *embID = obj3.getRef(); - if (obj3.fetch(xref, &obj4)->isStream()) { - obj4.streamGetDict()->lookup("Subtype", &subtype); - if (subtype.isName("Type1")) { - if (expectedType != fontType1) { - err = gTrue; - expectedType = isType0 ? fontCIDType0 : fontType1; - } - } else if (subtype.isName("Type1C")) { - if (expectedType == fontType1) { - expectedType = fontType1C; - } else if (expectedType != fontType1C) { - err = gTrue; - expectedType = isType0 ? fontCIDType0C : fontType1C; - } - } else if (subtype.isName("TrueType")) { - if (expectedType != fontTrueType) { - err = gTrue; - expectedType = isType0 ? fontCIDType2 : fontTrueType; - } - } else if (subtype.isName("CIDFontType0C")) { - if (expectedType == fontCIDType0) { - expectedType = fontCIDType0C; - } else { - err = gTrue; - expectedType = isType0 ? fontCIDType0C : fontType1C; - } - } else if (subtype.isName("OpenType")) { - if (expectedType == fontTrueType) { - expectedType = fontTrueTypeOT; - } else if (expectedType == fontType1) { - expectedType = fontType1COT; - } else if (expectedType == fontCIDType0) { - expectedType = fontCIDType0COT; - } else if (expectedType == fontCIDType2) { - expectedType = fontCIDType2OT; - } else { - err = gTrue; - } - } else { - error(errSyntaxError, -1, "Unknown font type '{0:s}'", - subtype.isName() ? subtype.getName() : "???"); - } - subtype.free(); - } - obj4.free(); - } - obj3.free(); - } - fontDesc.free(); - - t = fontUnknownType; - if (embID->num >= 0) { - obj3.initRef(embID->num, embID->gen); - obj3.fetch(xref, &obj4); - if (obj4.isStream()) { - obj4.streamReset(); - fft = FoFiIdentifier::identifyStream(&readFromStream, obj4.getStream()); - obj4.streamClose(); - switch (fft) { - case fofiIdType1PFA: - case fofiIdType1PFB: - t = fontType1; - break; - case fofiIdCFF8Bit: - t = isType0 ? fontCIDType0C : fontType1C; - break; - case fofiIdCFFCID: - t = fontCIDType0C; - break; - case fofiIdTrueType: - case fofiIdTrueTypeCollection: - t = isType0 ? fontCIDType2 : fontTrueType; - break; - case fofiIdOpenTypeCFF8Bit: - t = expectedType; // hack: open type always == expected type? s. bug-poppler20605.pdf - break; - case fofiIdOpenTypeCFFCID: - t = fontCIDType0COT; - break; - default: - error(errSyntaxError, -1, "Embedded font file may be invalid"); - break; - } - } - obj4.free(); - obj3.free(); - } - - if (t == fontUnknownType) { - t = expectedType; - } - - if (t != expectedType) { - err = gTrue; - } - - if (err) { - error(errSyntaxWarning, -1, - "Mismatch between font type and embedded font file"); - } - - obj2.free(); - obj1.free(); - - return t; -} - -void GfxFont::readFontDescriptor(XRef *xref, Dict *fontDict) { - Object obj1, obj2, obj3, obj4; - double t; - int i; - - // assume Times-Roman by default (for substitution purposes) - flags = fontSerif; - - missingWidth = 0; - - if (fontDict->lookup("FontDescriptor", &obj1)->isDict()) { - - // get flags - if (obj1.dictLookup("Flags", &obj2)->isInt()) { - flags = obj2.getInt(); - } - obj2.free(); - - // get name - obj1.dictLookup("FontName", &obj2); - if (obj2.isName()) { - embFontName = new GooString(obj2.getName()); - } - obj2.free(); - if (embFontName == NULL) { - // get name with typo - obj1.dictLookup("Fontname", &obj2); - if (obj2.isName()) { - embFontName = new GooString(obj2.getName()); - error(errSyntaxWarning, -1, "The file uses Fontname instead of FontName please notify the creator that the file is broken"); - } - obj2.free(); - } - - // get family - obj1.dictLookup("FontFamily", &obj2); - if (obj2.isString()) family = new GooString(obj2.getString()); - obj2.free(); - - // get stretch - obj1.dictLookup("FontStretch", &obj2); - if (obj2.isName()) { - if (strcmp(obj2.getName(), "UltraCondensed") == 0) stretch = UltraCondensed; - else if (strcmp(obj2.getName(), "ExtraCondensed") == 0) stretch = ExtraCondensed; - else if (strcmp(obj2.getName(), "Condensed") == 0) stretch = Condensed; - else if (strcmp(obj2.getName(), "SemiCondensed") == 0) stretch = SemiCondensed; - else if (strcmp(obj2.getName(), "Normal") == 0) stretch = Normal; - else if (strcmp(obj2.getName(), "SemiExpanded") == 0) stretch = SemiExpanded; - else if (strcmp(obj2.getName(), "Expanded") == 0) stretch = Expanded; - else if (strcmp(obj2.getName(), "ExtraExpanded") == 0) stretch = ExtraExpanded; - else if (strcmp(obj2.getName(), "UltraExpanded") == 0) stretch = UltraExpanded; - else error(errSyntaxWarning, -1, "Invalid Font Stretch"); - } - obj2.free(); - - // get weight - obj1.dictLookup("FontWeight", &obj2); - if (obj2.isNum()) { - if (obj2.getNum() == 100) weight = W100; - else if (obj2.getNum() == 200) weight = W200; - else if (obj2.getNum() == 300) weight = W300; - else if (obj2.getNum() == 400) weight = W400; - else if (obj2.getNum() == 500) weight = W500; - else if (obj2.getNum() == 600) weight = W600; - else if (obj2.getNum() == 700) weight = W700; - else if (obj2.getNum() == 800) weight = W800; - else if (obj2.getNum() == 900) weight = W900; - else error(errSyntaxWarning, -1, "Invalid Font Weight"); - } - obj2.free(); - - // look for MissingWidth - obj1.dictLookup("MissingWidth", &obj2); - if (obj2.isNum()) { - missingWidth = obj2.getNum(); - } - obj2.free(); - - // get Ascent and Descent - obj1.dictLookup("Ascent", &obj2); - if (obj2.isNum()) { - t = 0.001 * obj2.getNum(); - // some broken font descriptors specify a negative ascent - if (t < 0) { - t = -t; - } - // some broken font descriptors set ascent and descent to 0; - // others set it to ridiculous values (e.g., 32768) - if (t != 0 && t < 3) { - ascent = t; - } - } - obj2.free(); - obj1.dictLookup("Descent", &obj2); - if (obj2.isNum()) { - t = 0.001 * obj2.getNum(); - // some broken font descriptors specify a positive descent - if (t > 0) { - t = -t; - } - // some broken font descriptors set ascent and descent to 0 - if (t != 0 && t > -3) { - descent = t; - } - } - obj2.free(); - - // font FontBBox - if (obj1.dictLookup("FontBBox", &obj2)->isArray()) { - for (i = 0; i < 4 && i < obj2.arrayGetLength(); ++i) { - if (obj2.arrayGet(i, &obj3)->isNum()) { - fontBBox[i] = 0.001 * obj3.getNum(); - } - obj3.free(); - } - } - obj2.free(); - - } - obj1.free(); -} - -CharCodeToUnicode *GfxFont::readToUnicodeCMap(Dict *fontDict, int nBits, - CharCodeToUnicode *ctu) { - GooString *buf; - Object obj1; - - if (!fontDict->lookup("ToUnicode", &obj1)->isStream()) { - obj1.free(); - return NULL; - } - buf = new GooString(); - obj1.getStream()->fillGooString(buf); - obj1.streamClose(); - obj1.free(); - if (ctu) { - ctu->mergeCMap(buf, nBits); - } else { - ctu = CharCodeToUnicode::parseCMap(buf, nBits); - } - hasToUnicode = gTrue; - delete buf; - return ctu; -} - -GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev *ps) { - GfxFontLoc *fontLoc; - SysFontType sysFontType; - GooString *path, *base14Name, *substName; - PSFontParam16 *psFont16; - Object refObj, embFontObj; - int substIdx, fontNum; - GBool embed; - - if (type == fontType3) { - return NULL; - } - - //----- embedded font - if (embFontID.num >= 0) { - embed = gTrue; - refObj.initRef(embFontID.num, embFontID.gen); - refObj.fetch(xref, &embFontObj); - if (!embFontObj.isStream()) { - error(errSyntaxError, -1, "Embedded font object is wrong type"); - embed = gFalse; - } - embFontObj.free(); - refObj.free(); - if (embed) { - if (ps) { - switch (type) { - case fontType1: - case fontType1C: - case fontType1COT: - embed = ps->getEmbedType1(); - break; - case fontTrueType: - case fontTrueTypeOT: - embed = ps->getEmbedTrueType(); - break; - case fontCIDType0C: - case fontCIDType0COT: - embed = ps->getEmbedCIDPostScript(); - break; - case fontCIDType2: - case fontCIDType2OT: - embed = ps->getEmbedCIDTrueType(); - break; - default: - break; - } - } - if (embed) { - fontLoc = new GfxFontLoc(); - fontLoc->locType = gfxFontLocEmbedded; - fontLoc->fontType = type; - fontLoc->embFontID = embFontID; - return fontLoc; - } - } - } - - //----- PS passthrough - if (ps && !isCIDFont() && ps->getFontPassthrough()) { - fontLoc = new GfxFontLoc(); - fontLoc->locType = gfxFontLocResident; - fontLoc->fontType = fontType1; - fontLoc->path = name->copy(); - return fontLoc; - } - - //----- PS resident Base-14 font - if (ps && !isCIDFont() && ((Gfx8BitFont *)this)->base14) { - fontLoc = new GfxFontLoc(); - fontLoc->locType = gfxFontLocResident; - fontLoc->fontType = fontType1; - fontLoc->path = new GooString(((Gfx8BitFont *)this)->base14->base14Name); - return fontLoc; - } - - //----- external font file (fontFile, fontDir) - if (name && (path = globalParams->findFontFile(name))) { - if ((fontLoc = getExternalFont(path, isCIDFont()))) { - return fontLoc; - } - } - - //----- external font file for Base-14 font - if (!ps && !isCIDFont() && ((Gfx8BitFont *)this)->base14) { - base14Name = new GooString(((Gfx8BitFont *)this)->base14->base14Name); - if ((path = globalParams->findBase14FontFile(base14Name, this))) { - if ((fontLoc = getExternalFont(path, gFalse))) { - delete base14Name; - return fontLoc; - } - } - delete base14Name; - } - - //----- system font - if ((path = globalParams->findSystemFontFile(this, &sysFontType, - &fontNum))) { - if (isCIDFont()) { - if (sysFontType == sysFontTTF || sysFontType == sysFontTTC) { - fontLoc = new GfxFontLoc(); - fontLoc->locType = gfxFontLocExternal; - fontLoc->fontType = fontCIDType2; - fontLoc->path = path; - fontLoc->fontNum = fontNum; - return fontLoc; - } - } else { - if (sysFontType == sysFontTTF || sysFontType == sysFontTTC) { - fontLoc = new GfxFontLoc(); - fontLoc->locType = gfxFontLocExternal; - fontLoc->fontType = fontTrueType; - fontLoc->path = path; - return fontLoc; - } else if (sysFontType == sysFontPFA || sysFontType == sysFontPFB) { - fontLoc = new GfxFontLoc(); - fontLoc->locType = gfxFontLocExternal; - fontLoc->fontType = fontType1; - fontLoc->path = path; - fontLoc->fontNum = fontNum; - return fontLoc; - } - } - delete path; - } - - if (!isCIDFont()) { - - //----- 8-bit PS resident font - if (name && ps) { - if ((path = globalParams->getPSResidentFont(name))) { - fontLoc = new GfxFontLoc(); - fontLoc->locType = gfxFontLocResident; - fontLoc->fontType = fontType1; - fontLoc->path = path; - return fontLoc; - } - } - - //----- 8-bit font substitution - if (flags & fontFixedWidth) { - substIdx = 0; - } else if (flags & fontSerif) { - substIdx = 8; - } else { - substIdx = 4; - } - if (isBold()) { - substIdx += 2; - } - if (isItalic()) { - substIdx += 1; - } - substName = new GooString(base14SubstFonts[substIdx]); - if (ps) { - error(errSyntaxWarning, -1, "Substituting font '{0:s}' for '{1:s}'", - base14SubstFonts[substIdx], name ? name->getCString() : "null"); - fontLoc = new GfxFontLoc(); - fontLoc->locType = gfxFontLocResident; - fontLoc->fontType = fontType1; - fontLoc->path = substName; - fontLoc->substIdx = substIdx; - return fontLoc; - } else { - path = globalParams->findFontFile(substName); - delete substName; - if (path) { - if ((fontLoc = getExternalFont(path, gFalse))) { - error(errSyntaxWarning, -1, "Substituting font '{0:s}' for '{1:s}'", - base14SubstFonts[substIdx], name ? name->getCString() : ""); - name = new GooString(base14SubstFonts[substIdx]); - fontLoc->substIdx = substIdx; - return fontLoc; - } - } - } - - // failed to find a substitute font - return NULL; - } - - //----- 16-bit PS resident font - if (ps && ((psFont16 = globalParams->getPSResidentFont16( - name, - ((GfxCIDFont *)this)->getWMode())))) { - fontLoc = new GfxFontLoc(); - fontLoc->locType = gfxFontLocResident; - fontLoc->fontType = fontCIDType0; // this is not used - fontLoc->path = psFont16->psFontName->copy(); - fontLoc->encoding = psFont16->encoding->copy(); - fontLoc->wMode = psFont16->wMode; - return fontLoc; - } - if (ps && ((psFont16 = globalParams->getPSResidentFontCC( - ((GfxCIDFont *)this)->getCollection(), - ((GfxCIDFont *)this)->getWMode())))) { - error(errSyntaxWarning, -1, "Substituting font '{0:t}' for '{1:t}'", - psFont16->psFontName, name); - fontLoc = new GfxFontLoc(); - fontLoc->locType = gfxFontLocResident; - fontLoc->fontType = fontCIDType0; // this is not used - fontLoc->path = psFont16->psFontName->copy(); - fontLoc->encoding = psFont16->encoding->copy(); - fontLoc->wMode = psFont16->wMode; - return fontLoc; - } - - //----- CID font substitution - if ((path = globalParams->findCCFontFile( - ((GfxCIDFont *)this)->getCollection()))) { - if ((fontLoc = getExternalFont(path, gTrue))) { - error(errSyntaxWarning, -1, "Substituting font '{0:t}' for '{1:t}'", - fontLoc->path, name); - return fontLoc; - } - } - - // failed to find a substitute font - return NULL; -} - -GfxFontLoc *GfxFont::locateBase14Font(GooString *base14Name) { - GooString *path; - - path = globalParams->findFontFile(base14Name); - if (!path) { - return NULL; - } - return getExternalFont(path, gFalse); -} - -GfxFontLoc *GfxFont::getExternalFont(GooString *path, GBool cid) { - FoFiIdentifierType fft; - GfxFontType fontType; - GfxFontLoc *fontLoc; - - fft = FoFiIdentifier::identifyFile(path->getCString()); - switch (fft) { - case fofiIdType1PFA: - case fofiIdType1PFB: - fontType = fontType1; - break; - case fofiIdCFF8Bit: - fontType = fontType1C; - break; - case fofiIdCFFCID: - fontType = fontCIDType0C; - break; - case fofiIdTrueType: - case fofiIdTrueTypeCollection: - fontType = cid ? fontCIDType2 : fontTrueType; - break; - case fofiIdOpenTypeCFF8Bit: - fontType = fontType1COT; - break; - case fofiIdOpenTypeCFFCID: - fontType = fontCIDType0COT; - break; - case fofiIdUnknown: - case fofiIdError: - default: - fontType = fontUnknownType; - break; - } - if (fontType == fontUnknownType || - (cid ? (fontType < fontCIDType0) - : (fontType >= fontCIDType0))) { - delete path; - return NULL; - } - fontLoc = new GfxFontLoc(); - fontLoc->locType = gfxFontLocExternal; - fontLoc->fontType = fontType; - fontLoc->path = path; - return fontLoc; -} - -char *GfxFont::readEmbFontFile(XRef *xref, int *len) { - char *buf; - Object obj1, obj2; - Stream *str; - - obj1.initRef(embFontID.num, embFontID.gen); - obj1.fetch(xref, &obj2); - if (!obj2.isStream()) { - error(errSyntaxError, -1, "Embedded font file is not a stream"); - obj2.free(); - obj1.free(); - embFontID.num = -1; - *len = 0; - return NULL; - } - str = obj2.getStream(); - - buf = (char*)str->toUnsignedChars(len); - str->close(); - - obj2.free(); - obj1.free(); - - return buf; -} - - -struct AlternateNameMap { - const char *name; - const char *alt; -}; - -static const AlternateNameMap alternateNameMap[] = -{ - { "fi", "f_i" }, - { "fl", "f_l" }, - { "ff", "f_f" }, - { "ffi", "f_f_i" }, - { "ffl", "f_f_l" }, - { 0, 0 } -}; - -const char *GfxFont::getAlternateName(const char *name) { - const AlternateNameMap *map = alternateNameMap; - while (map->name) { - if (strcmp(name, map->name) == 0) { - return map->alt; - } - map++; - } - return 0; -} - -//------------------------------------------------------------------------ -// Gfx8BitFont -//------------------------------------------------------------------------ - -// Parse character names of the form 'Axx', 'xx', 'Ann', 'ABnn', or -// 'nn', where 'A' and 'B' are any letters, 'xx' is two hex digits, -// and 'nn' is decimal digits. -static GBool parseNumericName(char *s, GBool hex, unsigned int *u) { - char *endptr; - - // Strip leading alpha characters. - if (hex) { - int n = 0; - - // Get string length while ignoring junk at end. - while (isalnum(s[n])) - ++n; - - // Only 2 hex characters with optional leading alpha is allowed. - if (n == 3 && isalpha(*s)) { - ++s; - } else if (n != 2) { - return gFalse; - } - } else { - // Strip up to two alpha characters. - for (int i = 0; i < 2 && isalpha(*s); ++i) - ++s; - } - - int v = strtol(s, &endptr, hex ? 16 : 10); - - if (endptr == s) - return gFalse; - - // Skip trailing junk characters. - while (*endptr != '\0' && !isalnum(*endptr)) - ++endptr; - - if (*endptr == '\0') { - if (u) - *u = v; - return gTrue; - } - return gFalse; -} - -// Returns gTrue if the font has character names like xx or Axx which -// should be parsed for hex or decimal values. -static GBool testForNumericNames(Dict *fontDict, GBool hex) { - Object enc, diff, obj; - GBool numeric = gTrue; - - fontDict->lookup("Encoding", &enc); - if (!enc.isDict()) { - enc.free(); - return gFalse; - } - - enc.dictLookup("Differences", &diff); - enc.free(); - if (!diff.isArray()) { - diff.free(); - return gFalse; - } - - for (int i = 0; i < diff.arrayGetLength() && numeric; ++i) { - diff.arrayGet(i, &obj); - if (obj.isInt()) { - // All sequences must start between character codes 0 and 5. - if (obj.getInt() > 5) - numeric = gFalse; - } else if (obj.isName()) { - // All character names must sucessfully parse. - if (!parseNumericName(obj.getName(), hex, NULL)) - numeric = gFalse; - } else { - numeric = gFalse; - } - obj.free(); - } - - diff.free(); - return numeric; -} - -Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, - GfxFontType typeA, Ref embFontIDA, Dict *fontDict): - GfxFont(tagA, idA, nameA, typeA, embFontIDA) { - GooString *name2; - BuiltinFont *builtinFont; - const char **baseEnc; - GBool baseEncFromFontFile; - char *buf; - int len; - FoFiType1 *ffT1; - FoFiType1C *ffT1C; - int code; - char *charName; - GBool missing, hex; - GBool numeric; - Unicode toUnicode[256]; - CharCodeToUnicode *utu, *ctu2; - Unicode uBuf[8]; - double mul; - int firstChar, lastChar; - Gushort w; - Object obj1, obj2, obj3; - int n, i, a, b, m; - - refCnt = 1; - ctu = NULL; - - // do font name substitution for various aliases of the Base 14 font - // names - base14 = NULL; - if (name) { - name2 = name->copy(); - i = 0; - while (i < name2->getLength()) { - if (name2->getChar(i) == ' ') { - name2->del(i); - } else { - ++i; - } - } - a = 0; - b = sizeof(base14FontMap) / sizeof(Base14FontMapEntry); - // invariant: base14FontMap[a].altName <= name2 < base14FontMap[b].altName - while (b - a > 1) { - m = (a + b) / 2; - if (name2->cmp(base14FontMap[m].altName) >= 0) { - a = m; - } else { - b = m; - } - } - if (!name2->cmp(base14FontMap[a].altName)) { - base14 = &base14FontMap[a]; - } - delete name2; - } - - // is it a built-in font? - builtinFont = NULL; - if (base14) { - for (i = 0; i < nBuiltinFonts; ++i) { - if (!strcmp(base14->base14Name, builtinFonts[i].name)) { - builtinFont = &builtinFonts[i]; - break; - } - } - } - - // default ascent/descent values - if (builtinFont) { - ascent = 0.001 * builtinFont->ascent; - descent = 0.001 * builtinFont->descent; - fontBBox[0] = 0.001 * builtinFont->bbox[0]; - fontBBox[1] = 0.001 * builtinFont->bbox[1]; - fontBBox[2] = 0.001 * builtinFont->bbox[2]; - fontBBox[3] = 0.001 * builtinFont->bbox[3]; - } else { - ascent = 0.95; - descent = -0.35; - fontBBox[0] = fontBBox[1] = fontBBox[2] = fontBBox[3] = 0; - } - - // get info from font descriptor - readFontDescriptor(xref, fontDict); - - // for non-embedded fonts, don't trust the ascent/descent/bbox - // values from the font descriptor - if (builtinFont && embFontID.num < 0) { - ascent = 0.001 * builtinFont->ascent; - descent = 0.001 * builtinFont->descent; - fontBBox[0] = 0.001 * builtinFont->bbox[0]; - fontBBox[1] = 0.001 * builtinFont->bbox[1]; - fontBBox[2] = 0.001 * builtinFont->bbox[2]; - fontBBox[3] = 0.001 * builtinFont->bbox[3]; - } - - // get font matrix - fontMat[0] = fontMat[3] = 1; - fontMat[1] = fontMat[2] = fontMat[4] = fontMat[5] = 0; - if (fontDict->lookup("FontMatrix", &obj1)->isArray()) { - for (i = 0; i < 6 && i < obj1.arrayGetLength(); ++i) { - if (obj1.arrayGet(i, &obj2)->isNum()) { - fontMat[i] = obj2.getNum(); - } - obj2.free(); - } - } - obj1.free(); - - // get Type 3 bounding box, font definition, and resources - if (type == fontType3) { - if (fontDict->lookup("FontBBox", &obj1)->isArray()) { - for (i = 0; i < 4 && i < obj1.arrayGetLength(); ++i) { - if (obj1.arrayGet(i, &obj2)->isNum()) { - fontBBox[i] = obj2.getNum(); - } - obj2.free(); - } - } - obj1.free(); - if (!fontDict->lookup("CharProcs", &charProcs)->isDict()) { - error(errSyntaxError, -1, - "Missing or invalid CharProcs dictionary in Type 3 font"); - charProcs.free(); - } - if (!fontDict->lookup("Resources", &resources)->isDict()) { - resources.free(); - } - } - - //----- build the font encoding ----- - - // Encodings start with a base encoding, which can come from - // (in order of priority): - // 1. FontDict.Encoding or FontDict.Encoding.BaseEncoding - // - MacRoman / MacExpert / WinAnsi / Standard - // 2. embedded or external font file - // 3. default: - // - builtin --> builtin encoding - // - TrueType --> WinAnsiEncoding - // - others --> StandardEncoding - // and then add a list of differences (if any) from - // FontDict.Encoding.Differences. - - // check FontDict for base encoding - hasEncoding = gFalse; - usesMacRomanEnc = gFalse; - baseEnc = NULL; - baseEncFromFontFile = gFalse; - fontDict->lookup("Encoding", &obj1); - if (obj1.isDict()) { - obj1.dictLookup("BaseEncoding", &obj2); - if (obj2.isName("MacRomanEncoding")) { - hasEncoding = gTrue; - usesMacRomanEnc = gTrue; - baseEnc = macRomanEncoding; - } else if (obj2.isName("MacExpertEncoding")) { - hasEncoding = gTrue; - baseEnc = macExpertEncoding; - } else if (obj2.isName("WinAnsiEncoding")) { - hasEncoding = gTrue; - baseEnc = winAnsiEncoding; - } - obj2.free(); - } else if (obj1.isName("MacRomanEncoding")) { - hasEncoding = gTrue; - usesMacRomanEnc = gTrue; - baseEnc = macRomanEncoding; - } else if (obj1.isName("MacExpertEncoding")) { - hasEncoding = gTrue; - baseEnc = macExpertEncoding; - } else if (obj1.isName("WinAnsiEncoding")) { - hasEncoding = gTrue; - baseEnc = winAnsiEncoding; - } - - // check embedded font file for base encoding - // (only for Type 1 fonts - trying to get an encoding out of a - // TrueType font is a losing proposition) - ffT1 = NULL; - ffT1C = NULL; - buf = NULL; - if (type == fontType1 && embFontID.num >= 0) { - if ((buf = readEmbFontFile(xref, &len))) { - if ((ffT1 = FoFiType1::make(buf, len))) { - if (ffT1->getName()) { - if (embFontName) { - delete embFontName; - } - embFontName = new GooString(ffT1->getName()); - } - if (!baseEnc) { - baseEnc = (const char **)ffT1->getEncoding(); - baseEncFromFontFile = gTrue; - } - } - gfree(buf); - } - } else if (type == fontType1C && embFontID.num >= 0) { - if ((buf = readEmbFontFile(xref, &len))) { - if ((ffT1C = FoFiType1C::make(buf, len))) { - if (ffT1C->getName()) { - if (embFontName) { - delete embFontName; - } - embFontName = new GooString(ffT1C->getName()); - } - if (!baseEnc) { - baseEnc = (const char **)ffT1C->getEncoding(); - baseEncFromFontFile = gTrue; - } - } - gfree(buf); - } - } - - // get default base encoding - if (!baseEnc) { - if (builtinFont && embFontID.num < 0) { - baseEnc = builtinFont->defaultBaseEnc; - hasEncoding = gTrue; - } else if (type == fontTrueType) { - baseEnc = winAnsiEncoding; - } else { - baseEnc = standardEncoding; - } - } - - if (baseEncFromFontFile) { - encodingName->Set("Builtin"); - } else if (baseEnc == winAnsiEncoding) { - encodingName->Set("WinAnsi"); - } else if (baseEnc == macRomanEncoding) { - encodingName->Set("MacRoman"); - } else if (baseEnc == macExpertEncoding) { - encodingName->Set("MacExpert"); - } else if (baseEnc == symbolEncoding) { - encodingName->Set("Symbol"); - } else if (baseEnc == zapfDingbatsEncoding) { - encodingName->Set("ZapfDingbats"); - } else { - encodingName->Set("Standard"); - } - - // copy the base encoding - for (i = 0; i < 256; ++i) { - enc[i] = (char *)baseEnc[i]; - if ((encFree[i] = baseEncFromFontFile) && enc[i]) { - enc[i] = copyString(baseEnc[i]); - } - } - - // some Type 1C font files have empty encodings, which can break the - // T1C->T1 conversion (since the 'seac' operator depends on having - // the accents in the encoding), so we fill in any gaps from - // StandardEncoding - if (type == fontType1C && embFontID.num >= 0 && baseEncFromFontFile) { - for (i = 0; i < 256; ++i) { - if (!enc[i] && standardEncoding[i]) { - enc[i] = (char *)standardEncoding[i]; - encFree[i] = gFalse; - } - } - } - - // merge differences into encoding - if (obj1.isDict()) { - obj1.dictLookup("Differences", &obj2); - if (obj2.isArray()) { - encodingName->Set("Custom"); - hasEncoding = gTrue; - code = 0; - for (i = 0; i < obj2.arrayGetLength(); ++i) { - obj2.arrayGet(i, &obj3); - if (obj3.isInt()) { - code = obj3.getInt(); - } else if (obj3.isName()) { - if (code >= 0 && code < 256) { - if (encFree[code]) { - gfree(enc[code]); - } - enc[code] = copyString(obj3.getName()); - encFree[code] = gTrue; - } - ++code; - } else { - error(errSyntaxError, -1, - "Wrong type in font encoding resource differences ({0:s})", - obj3.getTypeName()); - } - obj3.free(); - } - } - obj2.free(); - } - obj1.free(); - if (ffT1) { - delete ffT1; - } - if (ffT1C) { - delete ffT1C; - } - - //----- build the mapping to Unicode ----- - - // pass 1: use the name-to-Unicode mapping table - missing = hex = gFalse; - GBool isZapfDingbats = name && name->endsWith("ZapfDingbats"); - for (code = 0; code < 256; ++code) { - if ((charName = enc[code])) { - if (isZapfDingbats) { - // include ZapfDingbats names - toUnicode[code] = globalParams->mapNameToUnicodeAll(charName); - } else { - toUnicode[code] = globalParams->mapNameToUnicodeText(charName); - } - if (!toUnicode[code] && strcmp(charName, ".notdef")) { - // if it wasn't in the name-to-Unicode table, check for a - // name that looks like 'Axx' or 'xx', where 'A' is any letter - // and 'xx' is two hex digits - if ((strlen(charName) == 3 && - isalpha(charName[0]) && - isxdigit(charName[1]) && isxdigit(charName[2]) && - ((charName[1] >= 'a' && charName[1] <= 'f') || - (charName[1] >= 'A' && charName[1] <= 'F') || - (charName[2] >= 'a' && charName[2] <= 'f') || - (charName[2] >= 'A' && charName[2] <= 'F'))) || - (strlen(charName) == 2 && - isxdigit(charName[0]) && isxdigit(charName[1]) && - // Only check idx 1 to avoid misidentifying a decimal - // number like a0 - ((charName[1] >= 'a' && charName[1] <= 'f') || - (charName[1] >= 'A' && charName[1] <= 'F')))) { - hex = gTrue; - } - missing = gTrue; - } - } else { - toUnicode[code] = 0; - } - } - - numeric = testForNumericNames(fontDict, hex); - - // construct the char code -> Unicode mapping object - ctu = CharCodeToUnicode::make8BitToUnicode(toUnicode); - - // pass 1a: Expand ligatures in the Alphabetic Presentation Form - // block (eg "fi", "ffi") to normal form - for (code = 0; code < 256; ++code) { - if (unicodeIsAlphabeticPresentationForm(toUnicode[code])) { - Unicode *normalized = unicodeNormalizeNFKC(&toUnicode[code], 1, &len, NULL); - if (len > 1) - ctu->setMapping((CharCode)code, normalized, len); - gfree(normalized); - } - } - - // pass 2: try to fill in the missing chars, looking for ligatures, numeric - // references and variants - if (missing) { - for (code = 0; code < 256; ++code) { - if (!toUnicode[code]) { - if ((charName = enc[code]) && strcmp(charName, ".notdef") - && (n = parseCharName(charName, uBuf, sizeof(uBuf)/sizeof(*uBuf), - gFalse, // don't check simple names (pass 1) - gTrue, // do check ligatures - numeric, - hex, - gTrue))) { // do check variants - ctu->setMapping((CharCode)code, uBuf, n); - continue; - } - - // if the 'mapUnknownCharNames' flag is set, do a simple pass-through - // mapping for unknown character names - if (globalParams->getMapUnknownCharNames()) { - uBuf[0] = code; - ctu->setMapping((CharCode)code, uBuf, 1); - } - } - } - } - - // merge in a ToUnicode CMap, if there is one -- this overwrites - // existing entries in ctu, i.e., the ToUnicode CMap takes - // precedence, but the other encoding info is allowed to fill in any - // holes - readToUnicodeCMap(fontDict, 16, ctu); - - // look for a Unicode-to-Unicode mapping - if (name && (utu = globalParams->getUnicodeToUnicode(name))) { - Unicode *uAux; - for (i = 0; i < 256; ++i) { - toUnicode[i] = 0; - } - ctu2 = CharCodeToUnicode::make8BitToUnicode(toUnicode); - for (i = 0; i < 256; ++i) { - n = ctu->mapToUnicode((CharCode)i, &uAux); - if (n >= 1) { - n = utu->mapToUnicode((CharCode)uAux[0], &uAux); - if (n >= 1) { - ctu2->setMapping((CharCode)i, uAux, n); - } - } - } - utu->decRefCnt(); - delete ctu; - ctu = ctu2; - } - - //----- get the character widths ----- - - // initialize all widths - for (code = 0; code < 256; ++code) { - widths[code] = missingWidth * 0.001; - } - - // use widths from font dict, if present - fontDict->lookup("FirstChar", &obj1); - firstChar = obj1.isInt() ? obj1.getInt() : 0; - obj1.free(); - if (firstChar < 0 || firstChar > 255) { - firstChar = 0; - } - fontDict->lookup("LastChar", &obj1); - lastChar = obj1.isInt() ? obj1.getInt() : 255; - obj1.free(); - if (lastChar < 0 || lastChar > 255) { - lastChar = 255; - } - mul = (type == fontType3) ? fontMat[0] : 0.001; - fontDict->lookup("Widths", &obj1); - if (obj1.isArray()) { - flags |= fontFixedWidth; - if (obj1.arrayGetLength() < lastChar - firstChar + 1) { - lastChar = firstChar + obj1.arrayGetLength() - 1; - } - for (code = firstChar; code <= lastChar; ++code) { - obj1.arrayGet(code - firstChar, &obj2); - if (obj2.isNum()) { - widths[code] = obj2.getNum() * mul; - if (fabs(widths[code] - widths[firstChar]) > 0.00001) { - flags &= ~fontFixedWidth; - } - } - obj2.free(); - } - - // use widths from built-in font - } else if (builtinFont) { - // this is a kludge for broken PDF files that encode char 32 - // as .notdef - if (builtinFont->widths->getWidth("space", &w)) { - widths[32] = 0.001 * w; - } - for (code = 0; code < 256; ++code) { - if (enc[code] && builtinFont->widths->getWidth(enc[code], &w)) { - widths[code] = 0.001 * w; - } - } - - // couldn't find widths -- use defaults - } else { - // this is technically an error -- the Widths entry is required - // for all but the Base-14 fonts -- but certain PDF generators - // apparently don't include widths for Arial and TimesNewRoman - if (isFixedWidth()) { - i = 0; - } else if (isSerif()) { - i = 8; - } else { - i = 4; - } - if (isBold()) { - i += 2; - } - if (isItalic()) { - i += 1; - } - builtinFont = builtinFontSubst[i]; - // this is a kludge for broken PDF files that encode char 32 - // as .notdef - if (builtinFont->widths->getWidth("space", &w)) { - widths[32] = 0.001 * w; - } - for (code = 0; code < 256; ++code) { - if (enc[code] && builtinFont->widths->getWidth(enc[code], &w)) { - widths[code] = 0.001 * w; - } - } - } - obj1.free(); - - ok = gTrue; -} - -Gfx8BitFont::~Gfx8BitFont() { - int i; - - for (i = 0; i < 256; ++i) { - if (encFree[i] && enc[i]) { - gfree(enc[i]); - } - } - ctu->decRefCnt(); - if (charProcs.isDict()) { - charProcs.free(); - } - if (resources.isDict()) { - resources.free(); - } -} - -// This function is in part a derived work of the Adobe Glyph Mapping -// Convention: http://www.adobe.com/devnet/opentype/archives/glyph.html -// Algorithmic comments are excerpted from that document to aid -// maintainability. -static int parseCharName(char *charName, Unicode *uBuf, int uLen, - GBool names, GBool ligatures, - GBool numeric, GBool hex, GBool variants) -{ - if (uLen <= 0) { - error(errInternal, -1, "Zero-length output buffer (recursion overflow?) in " - "parseCharName, component \"{0:s}\"", charName); - return 0; - } - // Step 1: drop all the characters from the glyph name starting with the - // first occurrence of a period (U+002E FULL STOP), if any. - if (variants) { - char *var_part = strchr(charName, '.'); - if (var_part == charName) { - return 0; // .notdef or similar - } else if (var_part != NULL) { - // parse names of the form 7.oldstyle, P.swash, s.sc, etc. - char *main_part = gstrndup(charName, var_part - charName); - GBool namesRecurse = gTrue, variantsRecurse = gFalse; - int n = parseCharName(main_part, uBuf, uLen, namesRecurse, ligatures, - numeric, hex, variantsRecurse); - gfree(main_part); - return n; - } - } - // Step 2: split the remaining string into a sequence of components, using - // underscore (U+005F LOW LINE) as the delimiter. - if (ligatures && strchr(charName, '_')) { - // parse names of the form A_a (e.g. f_i, T_h, l_quotesingle) - char *lig_part, *lig_end, *lig_copy; - int n = 0, m; - lig_part = lig_copy = copyString(charName); - do { - if ((lig_end = strchr(lig_part, '_'))) - *lig_end = '\0'; - if (lig_part[0] != '\0') { - GBool namesRecurse = gTrue, ligaturesRecurse = gFalse; - if ((m = parseCharName(lig_part, uBuf + n, uLen - n, namesRecurse, - ligaturesRecurse, numeric, hex, variants))) - n += m; - else - error(errSyntaxWarning, -1, "Could not parse ligature component \"{0:s}\" of \"{1:s}\" in " - "parseCharName", lig_part, charName); - } - lig_part = lig_end + 1; - } while (lig_end && n < uLen); - gfree(lig_copy); - return n; - } - // Step 3: map each component to a character string according to the - // procedure below, and concatenate those strings; the result is the - // character string to which the glyph name is mapped. - // 3.1. if the font is Zapf Dingbats (PostScript FontName ZapfDingbats), and - // the component is in the ZapfDingbats list, then map it to the - // corresponding character in that list. - // 3.2. otherwise, if the component is in the Adobe Glyph List, then map it - // to the corresponding character in that list. - if (names && (uBuf[0] = globalParams->mapNameToUnicodeText(charName))) { - return 1; - } - if (globalParams->getMapNumericCharNames()) { - unsigned int n = strlen(charName); - // 3.3. otherwise, if the component is of the form "uni" (U+0075 U+006E - // U+0069) followed by a sequence of uppercase hexadecimal digits (0 .. 9, - // A .. F, i.e. U+0030 .. U+0039, U+0041 .. U+0046), the length of that - // sequence is a multiple of four, and each group of four digits represents - // a number in the set {0x0000 .. 0xD7FF, 0xE000 .. 0xFFFF}, then interpret - // each such number as a Unicode scalar value and map the component to the - // string made of those scalar values. Note that the range and digit length - // restrictions mean that the "uni" prefix can be used only with Unicode - // values from the Basic Multilingual Plane (BMP). - if (n >= 7 && (n % 4) == 3 && !strncmp(charName, "uni", 3)) { - int i; - unsigned int m; - for (i = 0, m = 3; i < uLen && m < n; m += 4) { - if (isxdigit(charName[m]) && isxdigit(charName[m + 1]) && - isxdigit(charName[m + 2]) && isxdigit(charName[m + 3])) { - unsigned int u; - sscanf(charName + m, "%4x", &u); - if (u <= 0xD7FF || (0xE000 <= u && u <= 0xFFFF)) { - uBuf[i++] = u; - } - } - } - return i; - } - // 3.4. otherwise, if the component is of the form "u" (U+0075) followed by - // a sequence of four to six uppercase hexadecimal digits {0 .. 9, A .. F} - // (U+0030 .. U+0039, U+0041 .. U+0046), and those digits represent a - // number in {0x0000 .. 0xD7FF, 0xE000 .. 0x10FFFF}, then interpret this - // number as a Unicode scalar value and map the component to the string - // made of this scalar value. - if (n >= 5 && n <= 7 && charName[0] == 'u' && isxdigit(charName[1]) && - isxdigit(charName[2]) && isxdigit(charName[3]) && isxdigit(charName[4]) - && (n <= 5 || isxdigit(charName[5])) - && (n <= 6 || isxdigit(charName[6]))) { - unsigned int u; - sscanf(charName + 1, "%x", &u); - if (u <= 0xD7FF || (0xE000 <= u && u <= 0x10FFFF)) { - uBuf[0] = u; - return 1; - } - } - // Not in Adobe Glyph Mapping convention: look for names like xx - // or Axx and parse for hex or decimal values. - if (numeric && parseNumericName(charName, hex, uBuf)) - return 1; - } - // 3.5. otherwise, map the component to the empty string - return 0; -} - -int Gfx8BitFont::getNextChar(char *s, int len, CharCode *code, - Unicode **u, int *uLen, - double *dx, double *dy, double *ox, double *oy) { - CharCode c; - - *code = c = (CharCode)(*s & 0xff); - *uLen = ctu->mapToUnicode(c, u); - *dx = widths[c]; - *dy = *ox = *oy = 0; - return 1; -} - -CharCodeToUnicode *Gfx8BitFont::getToUnicode() { - ctu->incRefCnt(); - return ctu; -} - -int *Gfx8BitFont::getCodeToGIDMap(FoFiTrueType *ff) { - int *map; - int cmapPlatform, cmapEncoding; - int unicodeCmap, macRomanCmap, msSymbolCmap, cmap; - GBool useMacRoman, useUnicode; - char *charName; - Unicode u; - int code, i, n; - - map = (int *)gmallocn(256, sizeof(int)); - for (i = 0; i < 256; ++i) { - map[i] = 0; - } - - // To match up with the Adobe-defined behaviour, we choose a cmap - // like this: - // 1. If the PDF font has an encoding: - // 1a. If the PDF font specified MacRomanEncoding and the - // TrueType font has a Macintosh Roman cmap, use it, and - // reverse map the char names through MacRomanEncoding to - // get char codes. - // 1b. If the PDF font is not symbolic or the PDF font is not - // embedded, and the TrueType font has a Microsoft Unicode - // cmap or a non-Microsoft Unicode cmap, use it, and use the - // Unicode indexes, not the char codes. - // 1c. If the PDF font is symbolic and the TrueType font has a - // Microsoft Symbol cmap, use it, and use char codes - // directly (possibly with an offset of 0xf000). - // 1d. If the TrueType font has a Macintosh Roman cmap, use it, - // as in case 1a. - // 2. If the PDF font does not have an encoding or the PDF font is - // symbolic: - // 2a. If the TrueType font has a Macintosh Roman cmap, use it, - // and use char codes directly (possibly with an offset of - // 0xf000). - // 2b. If the TrueType font has a Microsoft Symbol cmap, use it, - // and use char codes directly (possible with an offset of - // 0xf000). - // 3. If none of these rules apply, use the first cmap and hope for - // the best (this shouldn't happen). - unicodeCmap = macRomanCmap = msSymbolCmap = -1; - for (i = 0; i < ff->getNumCmaps(); ++i) { - cmapPlatform = ff->getCmapPlatform(i); - cmapEncoding = ff->getCmapEncoding(i); - if ((cmapPlatform == 3 && cmapEncoding == 1) || - cmapPlatform == 0) { - unicodeCmap = i; - } else if (cmapPlatform == 1 && cmapEncoding == 0) { - macRomanCmap = i; - } else if (cmapPlatform == 3 && cmapEncoding == 0) { - msSymbolCmap = i; - } - } - cmap = 0; - useMacRoman = gFalse; - useUnicode = gFalse; - if (hasEncoding || type == fontType1) { - if (usesMacRomanEnc && macRomanCmap >= 0) { - cmap = macRomanCmap; - useMacRoman = gTrue; - } else if ((!(flags & fontSymbolic) || embFontID.num < 0) && - unicodeCmap >= 0) { - cmap = unicodeCmap; - useUnicode = gTrue; - } else if ((flags & fontSymbolic) && msSymbolCmap >= 0) { - cmap = msSymbolCmap; - } else if ((flags & fontSymbolic) && macRomanCmap >= 0) { - cmap = macRomanCmap; - } else if (macRomanCmap >= 0) { - cmap = macRomanCmap; - useMacRoman = gTrue; - } - } else { - if (msSymbolCmap >= 0) { - cmap = msSymbolCmap; - } else if (macRomanCmap >= 0) { - cmap = macRomanCmap; - } - } - - // reverse map the char names through MacRomanEncoding, then map the - // char codes through the cmap - if (useMacRoman) { - for (i = 0; i < 256; ++i) { - if ((charName = enc[i])) { - if ((code = globalParams->getMacRomanCharCode(charName))) { - map[i] = ff->mapCodeToGID(cmap, code); - } - } else { - map[i] = -1; - } - } - - // map Unicode through the cmap - } else if (useUnicode) { - Unicode *uAux; - for (i = 0; i < 256; ++i) { - if (((charName = enc[i]) && (u = globalParams->mapNameToUnicodeAll(charName)))) - map[i] = ff->mapCodeToGID(cmap, u); - else - { - n = ctu->mapToUnicode((CharCode)i, &uAux); - if (n > 0) map[i] = ff->mapCodeToGID(cmap, uAux[0]); - else map[i] = -1; - } - } - - // map the char codes through the cmap, possibly with an offset of - // 0xf000 - } else { - for (i = 0; i < 256; ++i) { - if (!(map[i] = ff->mapCodeToGID(cmap, i))) { - map[i] = ff->mapCodeToGID(cmap, 0xf000 + i); - } - } - } - - // try the TrueType 'post' table to handle any unmapped characters - for (i = 0; i < 256; ++i) { - if (map[i] <= 0 && (charName = enc[i])) { - map[i] = ff->mapNameToGID(charName); - } - } - - return map; -} - -Dict *Gfx8BitFont::getCharProcs() { - return charProcs.isDict() ? charProcs.getDict() : (Dict *)NULL; -} - -Object *Gfx8BitFont::getCharProc(int code, Object *proc) { - if (enc[code] && charProcs.isDict()) { - charProcs.dictLookup(enc[code], proc); - } else { - proc->initNull(); - } - return proc; -} - -Dict *Gfx8BitFont::getResources() { - return resources.isDict() ? resources.getDict() : (Dict *)NULL; -} - -//------------------------------------------------------------------------ -// GfxCIDFont -//------------------------------------------------------------------------ - -struct cmpWidthExcepFunctor { - bool operator()(const GfxFontCIDWidthExcep &w1, - const GfxFontCIDWidthExcep &w2) { - return w1.first < w2.first; - } -}; - -struct cmpWidthExcepVFunctor { - bool operator()(const GfxFontCIDWidthExcepV &w1, - const GfxFontCIDWidthExcepV &w2) { - return w1.first < w2.first; - } -}; - -GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, - GfxFontType typeA, Ref embFontIDA, Dict *fontDict): - GfxFont(tagA, idA, nameA, typeA, embFontIDA) -{ - Dict *desFontDict; - Object desFontDictObj; - Object obj1, obj2, obj3, obj4, obj5, obj6; - CharCodeToUnicode *utu; - CharCode c; - Unicode *uBuf; - int c1, c2; - int excepsSize, i, j, k, n; - - refCnt = 1; - ascent = 0.95; - descent = -0.35; - fontBBox[0] = fontBBox[1] = fontBBox[2] = fontBBox[3] = 0; - collection = NULL; - cMap = NULL; - ctu = NULL; - ctuUsesCharCode = gTrue; - widths.defWidth = 1.0; - widths.defHeight = -1.0; - widths.defVY = 0.880; - widths.exceps = NULL; - widths.nExceps = 0; - widths.excepsV = NULL; - widths.nExcepsV = 0; - cidToGID = NULL; - cidToGIDLen = 0; - - // get the descendant font - if (!fontDict->lookup("DescendantFonts", &obj1)->isArray() || - obj1.arrayGetLength() == 0) { - error(errSyntaxError, -1, "Missing or empty DescendantFonts entry in Type 0 font"); - obj1.free(); - goto err1; - } - if (!obj1.arrayGet(0, &desFontDictObj)->isDict()) { - error(errSyntaxError, -1, "Bad descendant font in Type 0 font"); - goto err3; - } - obj1.free(); - desFontDict = desFontDictObj.getDict(); - - // get info from font descriptor - readFontDescriptor(xref, desFontDict); - - //----- encoding info ----- - - // char collection - if (!desFontDict->lookup("CIDSystemInfo", &obj1)->isDict()) { - error(errSyntaxError, -1, "Missing CIDSystemInfo dictionary in Type 0 descendant font"); - goto err3; - } - obj1.dictLookup("Registry", &obj2); - obj1.dictLookup("Ordering", &obj3); - if (!obj2.isString() || !obj3.isString()) { - error(errSyntaxError, -1, "Invalid CIDSystemInfo dictionary in Type 0 descendant font"); - goto err3; - } - collection = obj2.getString()->copy()->append('-')->append(obj3.getString()); - obj3.free(); - obj2.free(); - obj1.free(); - - // look for a ToUnicode CMap - if (!(ctu = readToUnicodeCMap(fontDict, 16, NULL))) { - ctuUsesCharCode = gFalse; - - // use an identity mapping for the "Adobe-Identity" and - // "Adobe-UCS" collections - if (!collection->cmp("Adobe-Identity") || - !collection->cmp("Adobe-UCS")) { - ctu = CharCodeToUnicode::makeIdentityMapping(); - } else { - // look for a user-supplied .cidToUnicode file - if (!(ctu = globalParams->getCIDToUnicode(collection))) { - // I'm not completely sure that this is the best thing to do - // but it seems to produce better results when the .cidToUnicode - // files from the poppler-data package are missing. At least - // we know that assuming the Identity mapping is definitely wrong. - // -- jrmuizel - static const char * knownCollections [] = { - "Adobe-CNS1", - "Adobe-GB1", - "Adobe-Japan1", - "Adobe-Japan2", - "Adobe-Korea1", - }; - for (size_t i = 0; i < sizeof(knownCollections)/sizeof(knownCollections[0]); i++) { - if (collection->cmp(knownCollections[i]) == 0) { - error(errSyntaxError, -1, "Missing language pack for '{0:t}' mapping", collection); - goto err2; - } - } - error(errSyntaxError, -1, "Unknown character collection '{0:t}'", - collection); - // fall-through, assuming the Identity mapping -- this appears - // to match Adobe's behavior - } - } - } - - // look for a Unicode-to-Unicode mapping - if (name && (utu = globalParams->getUnicodeToUnicode(name))) { - if (ctu) { - for (c = 0; c < ctu->getLength(); ++c) { - n = ctu->mapToUnicode(c, &uBuf); - if (n >= 1) { - n = utu->mapToUnicode((CharCode)uBuf[0], &uBuf); - if (n >= 1) { - ctu->setMapping(c, uBuf, n); - } - } - } - utu->decRefCnt(); - } else { - ctu = utu; - } - } - - // encoding (i.e., CMap) - if (fontDict->lookup("Encoding", &obj1)->isNull()) { - error(errSyntaxError, -1, "Missing Encoding entry in Type 0 font"); - goto err2; - } - if (!(cMap = CMap::parse(NULL, collection, &obj1))) { - goto err2; - } - obj1.free(); - if (cMap->getCMapName()) { - encodingName->Set(cMap->getCMapName()->getCString()); - } else { - encodingName->Set("Custom"); - } - - // CIDToGIDMap (for embedded TrueType fonts) - if (type == fontCIDType2 || type == fontCIDType2OT) { - desFontDict->lookup("CIDToGIDMap", &obj1); - if (obj1.isStream()) { - cidToGIDLen = 0; - i = 64; - cidToGID = (int *)gmallocn(i, sizeof(int)); - obj1.streamReset(); - while ((c1 = obj1.streamGetChar()) != EOF && - (c2 = obj1.streamGetChar()) != EOF) { - if (cidToGIDLen == i) { - i *= 2; - cidToGID = (int *)greallocn(cidToGID, i, sizeof(int)); - } - cidToGID[cidToGIDLen++] = (c1 << 8) + c2; - } - } else if (!obj1.isName("Identity") && !obj1.isNull()) { - error(errSyntaxError, -1, "Invalid CIDToGIDMap entry in CID font"); - } - obj1.free(); - } - - //----- character metrics ----- - - // default char width - if (desFontDict->lookup("DW", &obj1)->isInt()) { - widths.defWidth = obj1.getInt() * 0.001; - } - obj1.free(); - - // char width exceptions - if (desFontDict->lookup("W", &obj1)->isArray()) { - excepsSize = 0; - i = 0; - while (i + 1 < obj1.arrayGetLength()) { - obj1.arrayGet(i, &obj2); - obj1.arrayGet(i + 1, &obj3); - if (obj2.isInt() && obj3.isInt() && i + 2 < obj1.arrayGetLength()) { - if (obj1.arrayGet(i + 2, &obj4)->isNum()) { - if (widths.nExceps == excepsSize) { - excepsSize += 16; - widths.exceps = (GfxFontCIDWidthExcep *) - greallocn(widths.exceps, - excepsSize, sizeof(GfxFontCIDWidthExcep)); - } - widths.exceps[widths.nExceps].first = obj2.getInt(); - widths.exceps[widths.nExceps].last = obj3.getInt(); - widths.exceps[widths.nExceps].width = obj4.getNum() * 0.001; - ++widths.nExceps; - } else { - error(errSyntaxError, -1, "Bad widths array in Type 0 font"); - } - obj4.free(); - i += 3; - } else if (obj2.isInt() && obj3.isArray()) { - if (widths.nExceps + obj3.arrayGetLength() > excepsSize) { - excepsSize = (widths.nExceps + obj3.arrayGetLength() + 15) & ~15; - widths.exceps = (GfxFontCIDWidthExcep *) - greallocn(widths.exceps, - excepsSize, sizeof(GfxFontCIDWidthExcep)); - } - j = obj2.getInt(); - for (k = 0; k < obj3.arrayGetLength(); ++k) { - if (obj3.arrayGet(k, &obj4)->isNum()) { - widths.exceps[widths.nExceps].first = j; - widths.exceps[widths.nExceps].last = j; - widths.exceps[widths.nExceps].width = obj4.getNum() * 0.001; - ++j; - ++widths.nExceps; - } else { - error(errSyntaxError, -1, "Bad widths array in Type 0 font"); - } - obj4.free(); - } - i += 2; - } else { - error(errSyntaxError, -1, "Bad widths array in Type 0 font"); - ++i; - } - obj3.free(); - obj2.free(); - } - std::sort(widths.exceps, widths.exceps + widths.nExceps, - cmpWidthExcepFunctor()); - } - obj1.free(); - - // default metrics for vertical font - if (desFontDict->lookup("DW2", &obj1)->isArray() && - obj1.arrayGetLength() == 2) { - if (obj1.arrayGet(0, &obj2)->isNum()) { - widths.defVY = obj2.getNum() * 0.001; - } - obj2.free(); - if (obj1.arrayGet(1, &obj2)->isNum()) { - widths.defHeight = obj2.getNum() * 0.001; - } - obj2.free(); - } - obj1.free(); - - // char metric exceptions for vertical font - if (desFontDict->lookup("W2", &obj1)->isArray()) { - excepsSize = 0; - i = 0; - while (i + 1 < obj1.arrayGetLength()) { - obj1.arrayGet(i, &obj2); - obj1.arrayGet(i+ 1, &obj3); - if (obj2.isInt() && obj3.isInt() && i + 4 < obj1.arrayGetLength()) { - if (obj1.arrayGet(i + 2, &obj4)->isNum() && - obj1.arrayGet(i + 3, &obj5)->isNum() && - obj1.arrayGet(i + 4, &obj6)->isNum()) { - if (widths.nExcepsV == excepsSize) { - excepsSize += 16; - widths.excepsV = (GfxFontCIDWidthExcepV *) - greallocn(widths.excepsV, - excepsSize, sizeof(GfxFontCIDWidthExcepV)); - } - widths.excepsV[widths.nExcepsV].first = obj2.getInt(); - widths.excepsV[widths.nExcepsV].last = obj3.getInt(); - widths.excepsV[widths.nExcepsV].height = obj4.getNum() * 0.001; - widths.excepsV[widths.nExcepsV].vx = obj5.getNum() * 0.001; - widths.excepsV[widths.nExcepsV].vy = obj6.getNum() * 0.001; - ++widths.nExcepsV; - } else { - error(errSyntaxError, -1, "Bad widths (W2) array in Type 0 font"); - } - obj6.free(); - obj5.free(); - obj4.free(); - i += 5; - } else if (obj2.isInt() && obj3.isArray()) { - if (widths.nExcepsV + obj3.arrayGetLength() / 3 > excepsSize) { - excepsSize = - (widths.nExcepsV + obj3.arrayGetLength() / 3 + 15) & ~15; - widths.excepsV = (GfxFontCIDWidthExcepV *) - greallocn(widths.excepsV, - excepsSize, sizeof(GfxFontCIDWidthExcepV)); - } - j = obj2.getInt(); - for (k = 0; k < obj3.arrayGetLength(); k += 3) { - if (obj3.arrayGet(k, &obj4)->isNum() && - obj3.arrayGet(k+1, &obj5)->isNum() && - obj3.arrayGet(k+2, &obj6)->isNum()) { - widths.excepsV[widths.nExcepsV].first = j; - widths.excepsV[widths.nExcepsV].last = j; - widths.excepsV[widths.nExcepsV].height = obj4.getNum() * 0.001; - widths.excepsV[widths.nExcepsV].vx = obj5.getNum() * 0.001; - widths.excepsV[widths.nExcepsV].vy = obj6.getNum() * 0.001; - ++j; - ++widths.nExcepsV; - } else { - error(errSyntaxError, -1, "Bad widths (W2) array in Type 0 font"); - } - obj6.free(); - obj5.free(); - obj4.free(); - } - i += 2; - } else { - error(errSyntaxError, -1, "Bad widths (W2) array in Type 0 font"); - ++i; - } - obj3.free(); - obj2.free(); - } - std::sort(widths.excepsV, widths.excepsV + widths.nExcepsV, - cmpWidthExcepVFunctor()); - } - obj1.free(); - - desFontDictObj.free(); - ok = gTrue; - return; - - err3: - obj3.free(); - obj2.free(); - err2: - obj1.free(); - desFontDictObj.free(); - err1:; -} - -GfxCIDFont::~GfxCIDFont() { - if (collection) { - delete collection; - } - if (cMap) { - cMap->decRefCnt(); - } - if (ctu) { - ctu->decRefCnt(); - } - gfree(widths.exceps); - gfree(widths.excepsV); - if (cidToGID) { - gfree(cidToGID); - } -} - -int GfxCIDFont::getNextChar(char *s, int len, CharCode *code, - Unicode **u, int *uLen, - double *dx, double *dy, double *ox, double *oy) { - CID cid; - CharCode c; - double w, h, vx, vy; - int n, a, b, m; - - if (!cMap) { - *code = 0; - *uLen = 0; - *dx = *dy = 0; - return 1; - } - - *code = (CharCode)(cid = cMap->getCID(s, len, &c, &n)); - if (ctu) { - if (hasToUnicode) { - int i = 0, c = 0; - while (i < n) { - c = (c << 8 ) + (s[i] & 0xff); - ++i; - } - *uLen = ctu->mapToUnicode(c, u); - } else { - *uLen = ctu->mapToUnicode(cid, u); - } - } else { - *uLen = 0; - } - - // horizontal - if (cMap->getWMode() == 0) { - w = widths.defWidth; - h = vx = vy = 0; - if (widths.nExceps > 0 && cid >= widths.exceps[0].first) { - a = 0; - b = widths.nExceps; - // invariant: widths.exceps[a].first <= cid < widths.exceps[b].first - while (b - a > 1) { - m = (a + b) / 2; - if (widths.exceps[m].first <= cid) { - a = m; - } else { - b = m; - } - } - if (cid <= widths.exceps[a].last) { - w = widths.exceps[a].width; - } - } - - // vertical - } else { - w = 0; - h = widths.defHeight; - vx = widths.defWidth / 2; - vy = widths.defVY; - if (widths.nExcepsV > 0 && cid >= widths.excepsV[0].first) { - a = 0; - b = widths.nExcepsV; - // invariant: widths.excepsV[a].first <= cid < widths.excepsV[b].first - while (b - a > 1) { - m = (a + b) / 2; - if (widths.excepsV[m].last <= cid) { - a = m; - } else { - b = m; - } - } - if (cid <= widths.excepsV[a].last) { - h = widths.excepsV[a].height; - vx = widths.excepsV[a].vx; - vy = widths.excepsV[a].vy; - } - } - } - - *dx = w; - *dy = h; - *ox = vx; - *oy = vy; - - return n; -} - -int GfxCIDFont::getWMode() { - return cMap ? cMap->getWMode() : 0; -} - -CharCodeToUnicode *GfxCIDFont::getToUnicode() { - if (ctu) { - ctu->incRefCnt(); - } - return ctu; -} - -GooString *GfxCIDFont::getCollection() { - return cMap ? cMap->getCollection() : (GooString *)NULL; -} - -int GfxCIDFont::mapCodeToGID(FoFiTrueType *ff, int cmapi, - Unicode unicode, GBool wmode) { - Gushort gid = ff->mapCodeToGID(cmapi,unicode); - if (wmode) { - Gushort vgid = ff->mapToVertGID(gid); - if (vgid != 0) gid = vgid; - } - return gid; -} - -int *GfxCIDFont::getCodeToGIDMap(FoFiTrueType *ff, int *mapsizep) { -#define N_UCS_CANDIDATES 2 - /* space characters */ - static const unsigned long spaces[] = { - 0x2000,0x2001,0x2002,0x2003,0x2004,0x2005,0x2006,0x2007, - 0x2008,0x2009,0x200A,0x00A0,0x200B,0x2060,0x3000,0xFEFF, - 0 - }; - static const char *adobe_cns1_cmaps[] = { - "UniCNS-UTF32-V", - "UniCNS-UCS2-V", - "UniCNS-UTF32-H", - "UniCNS-UCS2-H", - 0 - }; - static const char *adobe_gb1_cmaps[] = { - "UniGB-UTF32-V", - "UniGB-UCS2-V", - "UniGB-UTF32-H", - "UniGB-UCS2-H", - 0 - }; - static const char *adobe_japan1_cmaps[] = { - "UniJIS-UTF32-V", - "UniJIS-UCS2-V", - "UniJIS-UTF32-H", - "UniJIS-UCS2-H", - 0 - }; - static const char *adobe_japan2_cmaps[] = { - "UniHojo-UTF32-V", - "UniHojo-UCS2-V", - "UniHojo-UTF32-H", - "UniHojo-UCS2-H", - 0 - }; - static const char *adobe_korea1_cmaps[] = { - "UniKS-UTF32-V", - "UniKS-UCS2-V", - "UniKS-UTF32-H", - "UniKS-UCS2-H", - 0 - }; - static struct CMapListEntry { - const char *collection; - const char *scriptTag; - const char *languageTag; - const char *toUnicodeMap; - const char **CMaps; - } CMapList[] = { - { - "Adobe-CNS1", - "hani", "CHN ", - "Adobe-CNS1-UCS2", - adobe_cns1_cmaps, - }, - { - "Adobe-GB1", - "hani", "CHN ", - "Adobe-GB1-UCS2", - adobe_gb1_cmaps, - }, - { - "Adobe-Japan1", - "kana", "JAN ", - "Adobe-Japan1-UCS2", - adobe_japan1_cmaps, - }, - { - "Adobe-Japan2", - "kana", "JAN ", - "Adobe-Japan2-UCS2", - adobe_japan2_cmaps, - }, - { - "Adobe-Korea1", - "hang", "KOR ", - "Adobe-Korea1-UCS2", - adobe_korea1_cmaps, - }, - {0, 0, 0, 0} - }; - Unicode *humap = 0; - Unicode *vumap = 0; - Unicode *tumap = 0; - int *codeToGID = 0; - unsigned long n; - int i; - unsigned long code; - int wmode; - const char **cmapName; - CMap *cMap; - CMapListEntry *lp; - int cmap; - int cmapPlatform, cmapEncoding; - Ref embID; - - *mapsizep = 0; - if (!ctu) return NULL; - if (getCollection()->cmp("Adobe-Identity") == 0) return NULL; - if (getEmbeddedFontID(&embID)) { - /* if this font is embedded font, - * CIDToGIDMap should be embedded in PDF file - * and already set. So return it. - */ - *mapsizep = getCIDToGIDLen(); - return getCIDToGID(); - } - - /* we use only unicode cmap */ - cmap = -1; - for (i = 0; i < ff->getNumCmaps(); ++i) { - cmapPlatform = ff->getCmapPlatform(i); - cmapEncoding = ff->getCmapEncoding(i); - if (cmapPlatform == 3 && cmapEncoding == 10) { - /* UCS-4 */ - cmap = i; - /* use UCS-4 cmap */ - break; - } else if (cmapPlatform == 3 && cmapEncoding == 1) { - /* Unicode */ - cmap = i; - } else if (cmapPlatform == 0 && cmap < 0) { - cmap = i; - } - } - if (cmap < 0) - return NULL; - - wmode = getWMode(); - for (lp = CMapList;lp->collection != 0;lp++) { - if (strcmp(lp->collection,getCollection()->getCString()) == 0) { - break; - } - } - n = 65536; - tumap = new Unicode[n]; - humap = new Unicode[n*N_UCS_CANDIDATES]; - memset(humap,0,sizeof(Unicode)*n*N_UCS_CANDIDATES); - if (lp->collection != 0) { - CharCodeToUnicode *tctu; - GooString tname(lp->toUnicodeMap); - - if ((tctu = CharCodeToUnicode::parseCMapFromFile(&tname,16)) != 0) { - CharCode cid; - for (cid = 0;cid < n ;cid++) { - int len; - Unicode *ucodes; - - len = tctu->mapToUnicode(cid,&ucodes); - if (len == 1) { - tumap[cid] = ucodes[0]; - } else { - /* if not single character, ignore it */ - tumap[cid] = 0; - } - } - delete tctu; - } - vumap = new Unicode[n]; - memset(vumap,0,sizeof(Unicode)*n); - for (cmapName = lp->CMaps;*cmapName != 0;cmapName++) { - GooString cname(*cmapName); - - if ((cMap = globalParams->getCMap(getCollection(),&cname)) - != 0) { - if (cMap->getWMode()) { - cMap->setReverseMap(vumap,n,1); - } else { - cMap->setReverseMap(humap,n,N_UCS_CANDIDATES); - } - cMap->decRefCnt(); - } - } - ff->setupGSUB(lp->scriptTag, lp->languageTag); - } else { - error(errSyntaxError, -1, "Unknown character collection {0:t}\n", - getCollection()); - if ((ctu = getToUnicode()) != 0) { - CharCode cid; - for (cid = 0;cid < n ;cid++) { - Unicode *ucode; - - if (ctu->mapToUnicode(cid, &ucode)) - humap[cid*N_UCS_CANDIDATES] = ucode[0]; - else - humap[cid*N_UCS_CANDIDATES] = 0; - for (i = 1;i < N_UCS_CANDIDATES;i++) { - humap[cid*N_UCS_CANDIDATES+i] = 0; - } - } - ctu->decRefCnt(); - } - } - // map CID -> Unicode -> GID - codeToGID = (int *)gmallocn(n, sizeof(int)); - for (code = 0; code < n; ++code) { - Unicode unicode; - unsigned long gid; - - unicode = 0; - gid = 0; - if (humap != 0) { - for (i = 0;i < N_UCS_CANDIDATES - && gid == 0 && (unicode = humap[code*N_UCS_CANDIDATES+i]) != 0;i++) { - gid = mapCodeToGID(ff,cmap,unicode,gFalse); - } - } - if (gid == 0 && vumap != 0) { - unicode = vumap[code]; - if (unicode != 0) { - gid = mapCodeToGID(ff,cmap,unicode,gTrue); - if (gid == 0 && tumap != 0) { - if ((unicode = tumap[code]) != 0) { - gid = mapCodeToGID(ff,cmap,unicode,gTrue); - } - } - } - } - if (gid == 0 && tumap != 0) { - if ((unicode = tumap[code]) != 0) { - gid = mapCodeToGID(ff,cmap,unicode,gFalse); - } - } - if (gid == 0) { - /* special handling space characters */ - const unsigned long *p; - - if (humap != 0) unicode = humap[code]; - if (unicode != 0) { - /* check if code is space character , so map code to 0x0020 */ - for (p = spaces;*p != 0;p++) { - if (*p == unicode) { - unicode = 0x20; - gid = mapCodeToGID(ff,cmap,unicode,wmode); - break; - } - } - } - } - codeToGID[code] = gid; - } - *mapsizep = n; - if (humap != 0) delete[] humap; - if (tumap != 0) delete[] tumap; - if (vumap != 0) delete[] vumap; - return codeToGID; -} - -double GfxCIDFont::getWidth (char* s, int len) { - int nUsed; - double w; - int a, b, m; - CharCode c; - - CID cid = cMap->getCID(s, len, &c, &nUsed); - - w = widths.defWidth; - if (widths.nExceps > 0 && cid >= widths.exceps[0].first) { - a = 0; - b = widths.nExceps; - // invariant: widths.exceps[a].first <= cid < widths.exceps[b].first - while (b - a > 1) { - m = (a + b) / 2; - if (widths.exceps[m].first <= cid) { - a = m; - } else { - b = m; - } - } - if (cid <= widths.exceps[a].last) { - w = widths.exceps[a].width; - } - } - return w; -} - -//------------------------------------------------------------------------ -// GfxFontDict -//------------------------------------------------------------------------ - -GfxFontDict::GfxFontDict(XRef *xref, Ref *fontDictRef, Dict *fontDict) { - int i; - Object obj1, obj2; - Ref r; - - numFonts = fontDict->getLength(); - fonts = (GfxFont **)gmallocn(numFonts, sizeof(GfxFont *)); - for (i = 0; i < numFonts; ++i) { - fontDict->getValNF(i, &obj1); - obj1.fetch(xref, &obj2); - if (obj2.isDict()) { - if (obj1.isRef()) { - r = obj1.getRef(); - } else { - // no indirect reference for this font, so invent a unique one - // (legal generation numbers are five digits, so any 6-digit - // number would be safe) - r.num = i; - if (fontDictRef) { - r.gen = 100000 + fontDictRef->num; - } else { - r.gen = 999999; - } - } - fonts[i] = GfxFont::makeFont(xref, fontDict->getKey(i), - r, obj2.getDict()); - if (fonts[i] && !fonts[i]->isOk()) { - // XXX: it may be meaningful to distinguish between - // NULL and !isOk() so that when we do lookups - // we can tell the difference between a missing font - // and a font that is just !isOk() - fonts[i]->decRefCnt(); - fonts[i] = NULL; - } - } else { - error(errSyntaxError, -1, "font resource is not a dictionary"); - fonts[i] = NULL; - } - obj1.free(); - obj2.free(); - } -} - -GfxFontDict::~GfxFontDict() { - int i; - - for (i = 0; i < numFonts; ++i) { - if (fonts[i]) { - fonts[i]->decRefCnt(); - } - } - gfree(fonts); -} - -GfxFont *GfxFontDict::lookup(char *tag) { - int i; - - for (i = 0; i < numFonts; ++i) { - if (fonts[i] && fonts[i]->matches(tag)) { - return fonts[i]; - } - } - return NULL; -} diff --git a/source/libs/poppler/poppler-0.32.0/poppler/GfxFont.h b/source/libs/poppler/poppler-0.32.0/poppler/GfxFont.h deleted file mode 100755 index 1f01cc757..000000000 --- a/source/libs/poppler/poppler-0.32.0/poppler/GfxFont.h +++ /dev/null @@ -1,442 +0,0 @@ -//======================================================================== -// -// GfxFont.h -// -// Copyright 1996-2003 Glyph & Cog, LLC -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2005, 2008, 2015 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> -// Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org> -// Copyright (C) 2007 Jeff Muizelaar <jeff@infidigm.net> -// Copyright (C) 2007 Koji Otani <sho@bbr.jp> -// Copyright (C) 2011 Axel Strübing <axel.struebing@freenet.de> -// Copyright (C) 2011, 2012, 2014 Adrian Johnson <ajohnson@redneon.com> -// -// To see a description of the changes please see the Changelog file that -// came with your tarball or type make ChangeLog if you are building from git -// -//======================================================================== - -#ifndef GFXFONT_H -#define GFXFONT_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "goo/gtypes.h" -#include "goo/GooString.h" -#include "Object.h" -#include "CharTypes.h" - -class Dict; -class CMap; -class CharCodeToUnicode; -class FoFiTrueType; -class PSOutputDev; -struct GfxFontCIDWidths; -struct Base14FontMapEntry; - -//------------------------------------------------------------------------ -// GfxFontType -//------------------------------------------------------------------------ - -enum GfxFontType { - //----- Gfx8BitFont - fontUnknownType, - fontType1, - fontType1C, - fontType1COT, - fontType3, - fontTrueType, - fontTrueTypeOT, - //----- GfxCIDFont - fontCIDType0, - fontCIDType0C, - fontCIDType0COT, - fontCIDType2, - fontCIDType2OT -}; - -//------------------------------------------------------------------------ -// GfxFontCIDWidths -//------------------------------------------------------------------------ - -struct GfxFontCIDWidthExcep { - CID first; // this record applies to - CID last; // CIDs <first>..<last> - double width; // char width -}; - -struct GfxFontCIDWidthExcepV { - CID first; // this record applies to - CID last; // CIDs <first>..<last> - double height; // char height - double vx, vy; // origin position -}; - -struct GfxFontCIDWidths { - double defWidth; // default char width - double defHeight; // default char height - double defVY; // default origin position - GfxFontCIDWidthExcep *exceps; // exceptions - int nExceps; // number of valid entries in exceps - GfxFontCIDWidthExcepV * // exceptions for vertical font - excepsV; - int nExcepsV; // number of valid entries in excepsV -}; - -//------------------------------------------------------------------------ -// GfxFontLoc -//------------------------------------------------------------------------ - -enum GfxFontLocType { - gfxFontLocEmbedded, // font embedded in PDF file - gfxFontLocExternal, // external font file - gfxFontLocResident // font resident in PS printer -}; - -class GfxFontLoc { -public: - - GfxFontLoc(); - ~GfxFontLoc(); - - GfxFontLocType locType; - GfxFontType fontType; - Ref embFontID; // embedded stream obj ID - // (if locType == gfxFontLocEmbedded) - GooString *path; // font file path - // (if locType == gfxFontLocExternal) - // PS font name - // (if locType == gfxFontLocResident) - int fontNum; // for TrueType collections - // (if locType == gfxFontLocExternal) - GooString *encoding; // PS font encoding, only for 16-bit fonts - // (if locType == gfxFontLocResident) - int wMode; // writing mode, only for 16-bit fonts - // (if locType == gfxFontLocResident) - int substIdx; // substitute font index - // (if locType == gfxFontLocExternal, - // and a Base-14 substitution was made) -}; - -//------------------------------------------------------------------------ -// GfxFont -//------------------------------------------------------------------------ - -#define fontFixedWidth (1 << 0) -#define fontSerif (1 << 1) -#define fontSymbolic (1 << 2) -#define fontItalic (1 << 6) -#define fontBold (1 << 18) - -class GfxFont { -public: - - enum Stretch { - StretchNotDefined, - UltraCondensed, - ExtraCondensed, - Condensed, - SemiCondensed, - Normal, - SemiExpanded, - Expanded, - ExtraExpanded, - UltraExpanded }; - - enum Weight { - WeightNotDefined, - W100, - W200, - W300, - W400, // Normal - W500, - W600, - W700, // Bold - W800, - W900 }; - - // Build a GfxFont object. - static GfxFont *makeFont(XRef *xref, const char *tagA, Ref idA, Dict *fontDict); - - GfxFont(const char *tagA, Ref idA, GooString *nameA, - GfxFontType typeA, Ref embFontIDA); - - GBool isOk() { return ok; } - - void incRefCnt(); - void decRefCnt(); - - // Get font tag. - GooString *getTag() { return tag; } - - // Get font dictionary ID. - Ref *getID() { return &id; } - - // Does this font match the tag? - GBool matches(char *tagA) { return !tag->cmp(tagA); } - - // Get font family name. - GooString *getFamily() { return family; } - - // Get font stretch. - Stretch getStretch() { return stretch; } - - // Get font weight. - Weight getWeight() { return weight; } - - // Get the original font name (ignornig any munging that might have - // been done to map to a canonical Base-14 font name). - GooString *getName() { return name; } - - // Get font type. - GfxFontType getType() { return type; } - virtual GBool isCIDFont() { return gFalse; } - - // Get embedded font ID, i.e., a ref for the font file stream. - // Returns false if there is no embedded font. - GBool getEmbeddedFontID(Ref *embID) - { *embID = embFontID; return embFontID.num >= 0; } - - // Get the PostScript font name for the embedded font. Returns - // NULL if there is no embedded font. - GooString *getEmbeddedFontName() { return embFontName; } - - // Get font descriptor flags. - int getFlags() { return flags; } - GBool isFixedWidth() { return flags & fontFixedWidth; } - GBool isSerif() { return flags & fontSerif; } - GBool isSymbolic() { return flags & fontSymbolic; } - GBool isItalic() { return flags & fontItalic; } - GBool isBold() { return flags & fontBold; } - - // Return the Unicode map. - virtual CharCodeToUnicode *getToUnicode() = 0; - - // Return the font matrix. - double *getFontMatrix() { return fontMat; } - - // Return the font bounding box. - double *getFontBBox() { return fontBBox; } - - // Return the ascent and descent values. - double getAscent() { return ascent; } - double getDescent() { return descent; } - - // Return the writing mode (0=horizontal, 1=vertical). - virtual int getWMode() { return 0; } - - // Locate the font file for this font. If <ps> is not null, includes PS - // printer-resident fonts. Returns NULL on failure. - GfxFontLoc *locateFont(XRef *xref, PSOutputDev *ps); - - // Locate a Base-14 font file for a specified font name. - static GfxFontLoc *locateBase14Font(GooString *base14Name); - - // Read an external or embedded font file into a buffer. - char *readEmbFontFile(XRef *xref, int *len); - - // Get the next char from a string <s> of <len> bytes, returning the - // char <code>, its Unicode mapping <u>, its displacement vector - // (<dx>, <dy>), and its origin offset vector (<ox>, <oy>). <uSize> - // is the number of entries available in <u>, and <uLen> is set to - // the number actually used. Returns the number of bytes used by - // the char code. - virtual int getNextChar(char *s, int len, CharCode *code, - Unicode **u, int *uLen, - double *dx, double *dy, double *ox, double *oy) = 0; - - // Does this font have a toUnicode map? - GBool hasToUnicodeCMap() { return hasToUnicode; } - - // Return the name of the encoding - GooString *getEncodingName() { return encodingName; } - - // Return AGLFN names of ligatures in the Standard and Expert encodings - // for use with fonts that are not compatible with the Standard 14 fonts. - // http://sourceforge.net/adobe/aglfn/wiki/AGL%20Specification/ - static const char *getAlternateName(const char *name); - -protected: - - virtual ~GfxFont(); - - static GfxFontType getFontType(XRef *xref, Dict *fontDict, Ref *embID); - void readFontDescriptor(XRef *xref, Dict *fontDict); - CharCodeToUnicode *readToUnicodeCMap(Dict *fontDict, int nBits, - CharCodeToUnicode *ctu); - static GfxFontLoc *getExternalFont(GooString *path, GBool cid); - - GooString *tag; // PDF font tag - Ref id; // reference (used as unique ID) - GooString *name; // font name - GooString *family; // font family - Stretch stretch; // font stretch - Weight weight; // font weight - GfxFontType type; // type of font - int flags; // font descriptor flags - GooString *embFontName; // name of embedded font - Ref embFontID; // ref to embedded font file stream - double fontMat[6]; // font matrix (Type 3 only) - double fontBBox[4]; // font bounding box (Type 3 only) - double missingWidth; // "default" width - double ascent; // max height above baseline - double descent; // max depth below baseline - int refCnt; - GBool ok; - GBool hasToUnicode; - GooString *encodingName; -}; - -//------------------------------------------------------------------------ -// Gfx8BitFont -//------------------------------------------------------------------------ - -class Gfx8BitFont: public GfxFont { -public: - - Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, - GfxFontType typeA, Ref embFontIDA, Dict *fontDict); - - virtual int getNextChar(char *s, int len, CharCode *code, - Unicode **u, int *uLen, - double *dx, double *dy, double *ox, double *oy); - - // Return the encoding. - char **getEncoding() { return enc; } - - // Return the Unicode map. - CharCodeToUnicode *getToUnicode(); - - // Return the character name associated with <code>. - char *getCharName(int code) { return enc[code]; } - - // Returns true if the PDF font specified an encoding. - GBool getHasEncoding() { return hasEncoding; } - - // Returns true if the PDF font specified MacRomanEncoding. - GBool getUsesMacRomanEnc() { return usesMacRomanEnc; } - - // Get width of a character. - double getWidth(Guchar c) { return widths[c]; } - - // Return a char code-to-GID mapping for the provided font file. - // (This is only useful for TrueType fonts.) - int *getCodeToGIDMap(FoFiTrueType *ff); - - // Return the Type 3 CharProc dictionary, or NULL if none. - Dict *getCharProcs(); - - // Return the Type 3 CharProc for the character associated with <code>. - Object *getCharProc(int code, Object *proc); - - // Return the Type 3 Resources dictionary, or NULL if none. - Dict *getResources(); - -private: - virtual ~Gfx8BitFont(); - - const Base14FontMapEntry *base14; // for Base-14 fonts only; NULL otherwise - char *enc[256]; // char code --> char name - char encFree[256]; // boolean for each char name: if set, - // the string is malloc'ed - CharCodeToUnicode *ctu; // char code --> Unicode - GBool hasEncoding; - GBool usesMacRomanEnc; - double widths[256]; // character widths - Object charProcs; // Type 3 CharProcs dictionary - Object resources; // Type 3 Resources dictionary - - friend class GfxFont; -}; - -//------------------------------------------------------------------------ -// GfxCIDFont -//------------------------------------------------------------------------ - -class GfxCIDFont: public GfxFont { -public: - - GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, - GfxFontType typeA, Ref embFontIDA, Dict *fontDict); - - virtual GBool isCIDFont() { return gTrue; } - - virtual int getNextChar(char *s, int len, CharCode *code, - Unicode **u, int *uLen, - double *dx, double *dy, double *ox, double *oy); - - // Return the writing mode (0=horizontal, 1=vertical). - virtual int getWMode(); - - // Return the Unicode map. - CharCodeToUnicode *getToUnicode(); - - // Get the collection name (<registry>-<ordering>). - GooString *getCollection(); - - // Return the CID-to-GID mapping table. These should only be called - // if type is fontCIDType2. - int *getCIDToGID() { return cidToGID; } - int getCIDToGIDLen() { return cidToGIDLen; } - - int *getCodeToGIDMap(FoFiTrueType *ff, int *length); - - double getWidth(char* s, int len); - -private: - virtual ~GfxCIDFont(); - - int mapCodeToGID(FoFiTrueType *ff, int cmapi, - Unicode unicode, GBool wmode); - - GooString *collection; // collection name - CMap *cMap; // char code --> CID - CharCodeToUnicode *ctu; // CID --> Unicode - GBool ctuUsesCharCode; // true: ctu maps char code to Unicode; - // false: ctu maps CID to Unicode - GfxFontCIDWidths widths; // character widths - int *cidToGID; // CID --> GID mapping (for embedded - // TrueType fonts) - int cidToGIDLen; -}; - -//------------------------------------------------------------------------ -// GfxFontDict -//------------------------------------------------------------------------ - -class GfxFontDict { -public: - - // Build the font dictionary, given the PDF font dictionary. - GfxFontDict(XRef *xref, Ref *fontDictRef, Dict *fontDict); - - // Destructor. - ~GfxFontDict(); - - // Get the specified font. - GfxFont *lookup(char *tag); - - // Iterative access. - int getNumFonts() { return numFonts; } - GfxFont *getFont(int i) { return fonts[i]; } - -private: - - GfxFont **fonts; // list of fonts - int numFonts; // number of fonts -}; - -#endif diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Makefile.am b/source/libs/poppler/poppler-0.32.0/poppler/Makefile.am deleted file mode 100755 index 43faa7e39..000000000 --- a/source/libs/poppler/poppler-0.32.0/poppler/Makefile.am +++ /dev/null @@ -1,317 +0,0 @@ -CFLAGS+=$(PTHREAD_CFLAGS) -CXXFLAGS+=$(PTHREAD_CFLAGS) - -AM_CPPFLAGS = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/goo - -lib_LTLIBRARIES = libpoppler.la - -if BUILD_CAIRO_OUTPUT -noinst_LTLIBRARIES = libpoppler-cairo.la -endif - -if BUILD_SPLASH_OUTPUT - -splash_sources = \ - SplashOutputDev.cc - -splash_headers = \ - SplashOutputDev.h - -splash_includes = \ - $(SPLASH_CFLAGS) - -splash_libs = \ - $(SPLASH_LIBS) \ - $(top_builddir)/splash/libsplash.la - -endif - -if BUILD_LIBJPEG - -libjpeg_sources = \ - DCTStream.h \ - DCTStream.cc - -libjpeg_libs = \ - $(LIBJPEG_LIBS) -libjpeg_includes = \ - $(LIBJPEG_CFLAGS) - -endif - -if BUILD_LIBPNG - -libpng_libs = \ - $(LIBPNG_LIBS) -libpng_includes = \ - $(LIBPNG_CFLAGS) - -endif - -if BUILD_LIBTIFF - -libtiff_libs = \ - $(LIBTIFF_LIBS) -libtiff_includes = \ - $(LIBTIFF_CFLAGS) - -endif - -if BUILD_LIBOPENJPEG - -libjpeg2000_sources = \ - JPEG2000Stream.h \ - JPEG2000Stream.cc - -libjpeg2000_libs = \ - $(LIBOPENJPEG_LIBS) -libjpeg2000_includes = \ - $(LIBOPENJPEG_CFLAGS) - -else - -libjpeg2000_sources = \ - JPXStream.h \ - JPXStream.cc - -endif - - -if BUILD_ZLIB - -zlib_sources = \ - FlateStream.h \ - FlateStream.cc - -zlib_libs = \ - $(ZLIB_LIBS) - -endif - -if BUILD_LIBCURL - -libcurl_libs = \ - $(LIBCURL_LIBS) - -libcurl_includes = \ - $(LIBCURL_CFLAGS) - -curl_headers = \ - CurlCachedFile.h \ - CurlPDFDocBuilder.h - -curl_sources = \ - CurlCachedFile.cc \ - CurlPDFDocBuilder.cc - -endif - -if USE_CMS -cms_includes = $(LCMS_CFLAGS) -cms_libs = $(LCMS_LIBS) -endif - -if ENABLE_XPDF_HEADERS - -poppler_includedir = $(includedir)/poppler -poppler_include_HEADERS = \ - $(splash_headers) \ - $(curl_headers) \ - Annot.h \ - Array.h \ - BuiltinFont.h \ - BuiltinFontTables.h \ - CachedFile.h \ - Catalog.h \ - CharCodeToUnicode.h \ - CMap.h \ - DateInfo.h \ - Decrypt.h \ - Dict.h \ - Error.h \ - FileSpec.h \ - FontEncodingTables.h \ - FontInfo.h \ - Form.h \ - Function.h \ - Gfx.h \ - GfxFont.h \ - GfxState.h \ - GfxState_helpers.h \ - GlobalParams.h \ - Hints.h \ - JArithmeticDecoder.h \ - JBIG2Stream.h \ - Lexer.h \ - Linearization.h \ - Link.h \ - LocalPDFDocBuilder.h \ - Movie.h \ - NameToCharCode.h \ - Object.h \ - OptionalContent.h \ - Outline.h \ - OutputDev.h \ - Page.h \ - PageTransition.h \ - Parser.h \ - PDFDoc.h \ - PDFDocBuilder.h \ - PDFDocEncoding.h \ - PDFDocFactory.h \ - PopplerCache.h \ - ProfileData.h \ - PreScanOutputDev.h \ - PSTokenizer.h \ - Rendition.h \ - StdinCachedFile.h \ - StdinPDFDocBuilder.h \ - Stream-CCITT.h \ - Stream.h \ - StructElement.h \ - StructTreeRoot.h \ - UnicodeMap.h \ - UnicodeMapTables.h \ - UnicodeTypeTable.h \ - UnicodeCClassTables.h \ - UnicodeCompTables.h \ - UnicodeDecompTables.h \ - ViewerPreferences.h \ - XRef.h \ - CharTypes.h \ - CompactFontTables.h \ - ErrorCodes.h \ - NameToUnicodeTable.h \ - PSOutputDev.h \ - TextOutputDev.h \ - MarkedContentOutputDev.h \ - SecurityHandler.h \ - UTF.h \ - UTF8.h \ - XpdfPluginAPI.h \ - Sound.h -nodist_poppler_include_HEADERS = poppler-config.h - -endif - -libpoppler_la_SOURCES = \ - $(splash_sources) \ - $(libjpeg_sources) \ - $(zlib_sources) \ - $(libjpeg2000_sources) \ - $(curl_sources) \ - Annot.cc \ - Array.cc \ - BuiltinFont.cc \ - BuiltinFontTables.cc \ - CachedFile.cc \ - Catalog.cc \ - CharCodeToUnicode.cc \ - CMap.cc \ - DateInfo.cc \ - Decrypt.cc \ - Dict.cc \ - Error.cc \ - FileSpec.cc \ - FontEncodingTables.cc \ - Form.cc \ - FontInfo.cc \ - Function.cc \ - Gfx.cc \ - GfxFont.cc \ - GfxState.cc \ - GlobalParams.cc \ - Hints.cc \ - JArithmeticDecoder.cc \ - JBIG2Stream.cc \ - Lexer.cc \ - Linearization.cc \ - Link.cc \ - LocalPDFDocBuilder.cc \ - Movie.cc \ - NameToCharCode.cc \ - Object.cc \ - OptionalContent.cc \ - Outline.cc \ - OutputDev.cc \ - Page.cc \ - PageTransition.cc \ - Parser.cc \ - PDFDoc.cc \ - PDFDocEncoding.cc \ - PDFDocFactory.cc \ - PopplerCache.cc \ - ProfileData.cc \ - PreScanOutputDev.cc \ - PSTokenizer.cc \ - Rendition.cc \ - StdinCachedFile.cc \ - StdinPDFDocBuilder.cc \ - Stream.cc \ - StructTreeRoot.cc \ - StructElement.cc \ - strtok_r.cpp \ - UnicodeMap.cc \ - UnicodeTypeTable.cc \ - UTF.cc \ - ViewerPreferences.cc \ - XRef.cc \ - PSOutputDev.cc \ - TextOutputDev.cc \ - MarkedContentOutputDev.cc \ - PageLabelInfo.h \ - PageLabelInfo.cc \ - SecurityHandler.cc \ - Sound.cc \ - XpdfPluginAPI.cc - -libpoppler_la_CPPFLAGS = \ - $(cms_includes) \ - $(splash_includes) \ - $(libjpeg_includes) \ - $(libtiff_includes) \ - $(libjpeg2000_includes) \ - $(libpng_includes) \ - $(libcurl_includes) \ - $(FREETYPE_CFLAGS) \ - $(FONTCONFIG_CFLAGS) \ - $(AM_CPPFLAGS) - -libpoppler_la_LIBADD = \ - $(top_builddir)/goo/libgoo.la \ - $(top_builddir)/fofi/libfofi.la \ - $(cms_libs) \ - $(splash_libs) \ - $(libtiff_libs) \ - $(libjpeg_libs) \ - $(libpng_libs) \ - $(zlib_libs) \ - $(libcurl_libs) \ - $(libjpeg2000_libs) \ - $(FREETYPE_LIBS) \ - $(FONTCONFIG_LIBS) \ - $(PTHREAD_LIBS) \ - $(win32_libs) - -libpoppler_la_LDFLAGS = \ - -version-info 51:0:0 \ - @create_shared_lib@ \ - @auto_import_flags@ - -libpoppler_cairo_la_SOURCES = \ - CairoFontEngine.cc \ - CairoFontEngine.h \ - CairoOutputDev.cc \ - CairoOutputDev.h \ - CairoRescaleBox.cc \ - CairoRescaleBox.h - -libpoppler_cairo_la_CPPFLAGS = \ - $(CAIRO_CFLAGS) \ - $(AM_CPPFLAGS) - -EXTRA_DIST = gen-unicode-tables.py \ - GlobalParamsWin.cc \ - PageLabelInfo_p.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PSOutputDev.cc b/source/libs/poppler/poppler-0.32.0/poppler/PSOutputDev.cc deleted file mode 100755 index 2502f5fc2..000000000 --- a/source/libs/poppler/poppler-0.32.0/poppler/PSOutputDev.cc +++ /dev/null @@ -1,7483 +0,0 @@ -//======================================================================== -// -// PSOutputDev.cc -// -// Copyright 1996-2003 Glyph & Cog, LLC -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> -// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2006-2009, 2011-2013, 2015 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net> -// Copyright (C) 2007, 2008 Brad Hards <bradh@kde.org> -// Copyright (C) 2008, 2009 Koji Otani <sho@bbr.jp> -// Copyright (C) 2008, 2010 Hib Eris <hib@hiberis.nl> -// Copyright (C) 2009-2013 Thomas Freitag <Thomas.Freitag@alfa.de> -// Copyright (C) 2009 Till Kamppeter <till.kamppeter@gmail.com> -// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright (C) 2009, 2011, 2012, 2014, 2015 William Bader <williambader@hotmail.com> -// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net> -// Copyright (C) 2009-2011, 2013, 2014 Adrian Johnson <ajohnson@redneon.com> -// Copyright (C) 2012, 2014 Fabio D'Urso <fabiodurso@hotmail.it> -// Copyright (C) 2012 Lu Wang <coolwanglu@gmail.com> -// Copyright (C) 2014 Till Kamppeter <till.kamppeter@gmail.com> -// -// To see a description of the changes please see the Changelog file that -// came with your tarball or type make ChangeLog if you are building from git -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <stdio.h> -#include <stddef.h> -#include <stdarg.h> -#include <signal.h> -#include <math.h> -#include <limits.h> -#include "goo/GooString.h" -#include "goo/GooList.h" -#include "goo/GooHash.h" -#include "poppler-config.h" -#include "GlobalParams.h" -#include "Object.h" -#include "Error.h" -#include "Function.h" -#include "Gfx.h" -#include "GfxState.h" -#include "GfxFont.h" -#include "UnicodeMap.h" -#include <fofi/FoFiType1C.h> -#include <fofi/FoFiTrueType.h> -#include "Catalog.h" -#include "Page.h" -#include "Stream.h" -#include "Annot.h" -#include "XRef.h" -#include "PreScanOutputDev.h" -#include "FileSpec.h" -#include "CharCodeToUnicode.h" -#if HAVE_SPLASH -# include "splash/Splash.h" -# include "splash/SplashBitmap.h" -# include "SplashOutputDev.h" -#endif -#include "PSOutputDev.h" -#include "PDFDoc.h" - -#ifdef MACOS -// needed for setting type/creator of MacOS files -#include "ICSupport.h" -#endif - -// the MSVC math.h doesn't define this -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -//------------------------------------------------------------------------ - -// Max size of a slice when rasterizing pages, in pixels. -#define rasterizationSliceSize 20000000 - -//------------------------------------------------------------------------ -// PostScript prolog and setup -//------------------------------------------------------------------------ - -// The '~' escapes mark prolog code that is emitted only in certain -// levels: -// -// ~[123][sn] -// ^ ^----- s=psLevel*Sep, n=psLevel* -// +----- 1=psLevel1*, 2=psLevel2*, 3=psLevel3* - -static const char *prolog[] = { - "/xpdf 75 dict def xpdf begin", - "% PDF special state", - "/pdfDictSize 15 def", - "~1sn", - "/pdfStates 64 array def", - " 0 1 63 {", - " pdfStates exch pdfDictSize dict", - " dup /pdfStateIdx 3 index put", - " put", - " } for", - "~123sn", - "/pdfSetup {", - " /setpagedevice where {", - " pop 2 dict begin", - " /Policies 1 dict dup begin /PageSize 6 def end def", - " { /Duplex true def } if", - " currentdict end setpagedevice", - " } {", - " pop", - " } ifelse", - "} def", - "/pdfSetupPaper {", - " % Change paper size, but only if different from previous paper size otherwise", - " % duplex fails. PLRM specifies a tolerance of 5 pts when matching paper size", - " % so we use the same when checking if the size changes.", - " /setpagedevice where {", - " pop currentpagedevice", - " /PageSize known {", - " 2 copy", - " currentpagedevice /PageSize get aload pop", - " exch 4 1 roll", - " sub abs 5 gt", - " 3 1 roll", - " sub abs 5 gt", - " or", - " } {", - " true", - " } ifelse", - " {", - " 2 array astore", - " 2 dict begin", - " /PageSize exch def", - " /ImagingBBox null def", - " currentdict end", - " setpagedevice", - " } {", - " pop pop", - " } ifelse", - " } {", - " pop", - " } ifelse", - "} def", - "~1sn", - "/pdfOpNames [", - " /pdfFill /pdfStroke /pdfLastFill /pdfLastStroke", - " /pdfTextMat /pdfFontSize /pdfCharSpacing /pdfTextRender /pdfPatternCS", - " /pdfTextRise /pdfWordSpacing /pdfHorizScaling /pdfTextClipPath", - "] def", - "~123sn", - "/pdfStartPage {", - "~1sn", - " pdfStates 0 get begin", - "~23sn", - " pdfDictSize dict begin", - "~23n", - " /pdfFillCS [] def", - " /pdfFillXform {} def", - " /pdfStrokeCS [] def", - " /pdfStrokeXform {} def", - "~1n", - " /pdfFill 0 def", - " /pdfStroke 0 def", - "~1s", - " /pdfFill [0 0 0 1] def", - " /pdfStroke [0 0 0 1] def", - "~23sn", - " /pdfFill [0] def", - " /pdfStroke [0] def", - " /pdfFillOP false def", - " /pdfStrokeOP false def", - "~3sn", - " /pdfOPM false def", - "~123sn", - " /pdfLastFill false def", - " /pdfLastStroke false def", - " /pdfTextMat [1 0 0 1 0 0] def", - " /pdfFontSize 0 def", - " /pdfCharSpacing 0 def", - " /pdfTextRender 0 def", - " /pdfPatternCS false def", - " /pdfTextRise 0 def", - " /pdfWordSpacing 0 def", - " /pdfHorizScaling 1 def", - " /pdfTextClipPath [] def", - "} def", - "/pdfEndPage { end } def", - "~23s", - "% separation convention operators", - "/findcmykcustomcolor where {", - " pop", - "}{", - " /findcmykcustomcolor { 5 array astore } def", - "} ifelse", - "/setcustomcolor where {", - " pop", - "}{", - " /setcustomcolor {", - " exch", - " [ exch /Separation exch dup 4 get exch /DeviceCMYK exch", - " 0 4 getinterval cvx", - " [ exch /dup load exch { mul exch dup } /forall load", - " /pop load dup ] cvx", - " ] setcolorspace setcolor", - " } def", - "} ifelse", - "/customcolorimage where {", - " pop", - "}{", - " /customcolorimage {", - " gsave", - " [ exch /Separation exch dup 4 get exch /DeviceCMYK exch", - " 0 4 getinterval", - " [ exch /dup load exch { mul exch dup } /forall load", - " /pop load dup ] cvx", - " ] setcolorspace", - " 10 dict begin", - " /ImageType 1 def", - " /DataSource exch def", - " /ImageMatrix exch def", - " /BitsPerComponent exch def", - " /Height exch def", - " /Width exch def", - " /Decode [1 0] def", - " currentdict end", - " image", - " grestore", - " } def", - "} ifelse", - "~123sn", - "% PDF color state", - "~1n", - "/g { dup /pdfFill exch def setgray", - " /pdfLastFill true def /pdfLastStroke false def } def", - "/G { dup /pdfStroke exch def setgray", - " /pdfLastStroke true def /pdfLastFill false def } def", - "/fCol {", - " pdfLastFill not {", - " pdfFill setgray", - " /pdfLastFill true def /pdfLastStroke false def", - " } if", - "} def", - "/sCol {", - " pdfLastStroke not {", - " pdfStroke setgray", - " /pdfLastStroke true def /pdfLastFill false def", - " } if", - "} def", - "~1s", - "/k { 4 copy 4 array astore /pdfFill exch def setcmykcolor", - " /pdfLastFill true def /pdfLastStroke false def } def", - "/K { 4 copy 4 array astore /pdfStroke exch def setcmykcolor", - " /pdfLastStroke true def /pdfLastFill false def } def", - "/fCol {", - " pdfLastFill not {", - " pdfFill aload pop setcmykcolor", - " /pdfLastFill true def /pdfLastStroke false def", - " } if", - "} def", - "/sCol {", - " pdfLastStroke not {", - " pdfStroke aload pop setcmykcolor", - " /pdfLastStroke true def /pdfLastFill false def", - " } if", - "} def", - "~3n", - "/opm { dup /pdfOPM exch def", - " /setoverprintmode where{pop setoverprintmode}{pop}ifelse } def", - "~23n", - "/cs { /pdfFillXform exch def dup /pdfFillCS exch def", - " setcolorspace } def", - "/CS { /pdfStrokeXform exch def dup /pdfStrokeCS exch def", - " setcolorspace } def", - "/sc { pdfLastFill not { pdfFillCS setcolorspace } if", - " dup /pdfFill exch def aload pop pdfFillXform setcolor", - " /pdfLastFill true def /pdfLastStroke false def } def", - "/SC { pdfLastStroke not { pdfStrokeCS setcolorspace } if", - " dup /pdfStroke exch def aload pop pdfStrokeXform setcolor", - " /pdfLastStroke true def /pdfLastFill false def } def", - "/op { /pdfFillOP exch def", - " pdfLastFill { pdfFillOP setoverprint } if } def", - "/OP { /pdfStrokeOP exch def", - " pdfLastStroke { pdfStrokeOP setoverprint } if } def", - "/fCol {", - " pdfLastFill not {", - " pdfFillCS setcolorspace", - " pdfFill aload pop pdfFillXform setcolor", - " pdfFillOP setoverprint", - " /pdfLastFill true def /pdfLastStroke false def", - " } if", - "} def", - "/sCol {", - " pdfLastStroke not {", - " pdfStrokeCS setcolorspace", - " pdfStroke aload pop pdfStrokeXform setcolor", - " pdfStrokeOP setoverprint", - " /pdfLastStroke true def /pdfLastFill false def", - " } if", - "} def", - "~3s", - "/opm { dup /pdfOPM exch def", - " /setoverprintmode where{pop setoverprintmode}{pop}ifelse } def", - "~23s", - "/k { 4 copy 4 array astore /pdfFill exch def setcmykcolor", - " /pdfLastFill true def /pdfLastStroke false def } def", - "/K { 4 copy 4 array astore /pdfStroke exch def setcmykcolor", - " /pdfLastStroke true def /pdfLastFill false def } def", - "/ck { 6 copy 6 array astore /pdfFill exch def", - " findcmykcustomcolor exch setcustomcolor", - " /pdfLastFill true def /pdfLastStroke false def } def", - "/CK { 6 copy 6 array astore /pdfStroke exch def", - " findcmykcustomcolor exch setcustomcolor", - " /pdfLastStroke true def /pdfLastFill false def } def", - "/op { /pdfFillOP exch def", - " pdfLastFill { pdfFillOP setoverprint } if } def", - "/OP { /pdfStrokeOP exch def", - " pdfLastStroke { pdfStrokeOP setoverprint } if } def", - "/fCol {", - " pdfLastFill not {", - " pdfFill aload length 4 eq {", - " setcmykcolor", - " }{", - " findcmykcustomcolor exch setcustomcolor", - " } ifelse", - " pdfFillOP setoverprint", - " /pdfLastFill true def /pdfLastStroke false def", - " } if", - "} def", - "/sCol {", - " pdfLastStroke not {", - " pdfStroke aload length 4 eq {", - " setcmykcolor", - " }{", - " findcmykcustomcolor exch setcustomcolor", - " } ifelse", - " pdfStrokeOP setoverprint", - " /pdfLastStroke true def /pdfLastFill false def", - " } if", - "} def", - "~123sn", - "% build a font", - "/pdfMakeFont {", - " 4 3 roll findfont", - " 4 2 roll matrix scale makefont", - " dup length dict begin", - " { 1 index /FID ne { def } { pop pop } ifelse } forall", - " /Encoding exch def", - " currentdict", - " end", - " definefont pop", - "} def", - "/pdfMakeFont16 {", - " exch findfont", - " dup length dict begin", - " { 1 index /FID ne { def } { pop pop } ifelse } forall", - " /WMode exch def", - " currentdict", - " end", - " definefont pop", - "} def", - "~3sn", - "/pdfMakeFont16L3 {", - " 1 index /CIDFont resourcestatus {", - " pop pop 1 index /CIDFont findresource /CIDFontType known", - " } {", - " false", - " } ifelse", - " {", - " 0 eq { /Identity-H } { /Identity-V } ifelse", - " exch 1 array astore composefont pop", - " } {", - " pdfMakeFont16", - " } ifelse", - "} def", - "~123sn", - "% graphics state operators", - "~1sn", - "/q {", - " gsave", - " pdfOpNames length 1 sub -1 0 { pdfOpNames exch get load } for", - " pdfStates pdfStateIdx 1 add get begin", - " pdfOpNames { exch def } forall", - "} def", - "/Q { end grestore } def", - "~23sn", - "/q { gsave pdfDictSize dict begin } def", - "/Q {", - " end grestore", - " /pdfLastFill where {", - " pop", - " pdfLastFill {", - " pdfFillOP setoverprint", - " } {", - " pdfStrokeOP setoverprint", - " } ifelse", - " } if", - "~3sn", - " /pdfOPM where {", - " pop", - " pdfOPM /setoverprintmode where{pop setoverprintmode}{pop}ifelse ", - " } if", - "~23sn", - "} def", - "~123sn", - "/cm { concat } def", - "/d { setdash } def", - "/i { setflat } def", - "/j { setlinejoin } def", - "/J { setlinecap } def", - "/M { setmiterlimit } def", - "/w { setlinewidth } def", - "% path segment operators", - "/m { moveto } def", - "/l { lineto } def", - "/c { curveto } def", - "/re { 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto", - " neg 0 rlineto closepath } def", - "/h { closepath } def", - "% path painting operators", - "/S { sCol stroke } def", - "/Sf { fCol stroke } def", - "/f { fCol fill } def", - "/f* { fCol eofill } def", - "% clipping operators", - "/W { clip newpath } def", - "/W* { eoclip newpath } def", - "/Ws { strokepath clip newpath } def", - "% text state operators", - "/Tc { /pdfCharSpacing exch def } def", - "/Tf { dup /pdfFontSize exch def", - " dup pdfHorizScaling mul exch matrix scale", - " pdfTextMat matrix concatmatrix dup 4 0 put dup 5 0 put", - " exch findfont exch makefont setfont } def", - "/Tr { /pdfTextRender exch def } def", - "/Tp { /pdfPatternCS exch def } def", - "/Ts { /pdfTextRise exch def } def", - "/Tw { /pdfWordSpacing exch def } def", - "/Tz { /pdfHorizScaling exch def } def", - "% text positioning operators", - "/Td { pdfTextMat transform moveto } def", - "/Tm { /pdfTextMat exch def } def", - "% text string operators", - "/xyshow where {", - " pop", - " /xyshow2 {", - " dup length array", - " 0 2 2 index length 1 sub {", - " 2 index 1 index 2 copy get 3 1 roll 1 add get", - " pdfTextMat dtransform", - " 4 2 roll 2 copy 6 5 roll put 1 add 3 1 roll dup 4 2 roll put", - " } for", - " exch pop", - " xyshow", - " } def", - "}{", - " /xyshow2 {", - " currentfont /FontType get 0 eq {", - " 0 2 3 index length 1 sub {", - " currentpoint 4 index 3 index 2 getinterval show moveto", - " 2 copy get 2 index 3 2 roll 1 add get", - " pdfTextMat dtransform rmoveto", - " } for", - " } {", - " 0 1 3 index length 1 sub {", - " currentpoint 4 index 3 index 1 getinterval show moveto", - " 2 copy 2 mul get 2 index 3 2 roll 2 mul 1 add get", - " pdfTextMat dtransform rmoveto", - " } for", - " } ifelse", - " pop pop", - " } def", - "} ifelse", - "/cshow where {", - " pop", - " /xycp {", // xycharpath - " 0 3 2 roll", - " {", - " pop pop currentpoint 3 2 roll", - " 1 string dup 0 4 3 roll put false charpath moveto", - " 2 copy get 2 index 2 index 1 add get", - " pdfTextMat dtransform rmoveto", - " 2 add", - " } exch cshow", - " pop pop", - " } def", - "}{", - " /xycp {", // xycharpath - " currentfont /FontType get 0 eq {", - " 0 2 3 index length 1 sub {", - " currentpoint 4 index 3 index 2 getinterval false charpath moveto", - " 2 copy get 2 index 3 2 roll 1 add get", - " pdfTextMat dtransform rmoveto", - " } for", - " } {", - " 0 1 3 index length 1 sub {", - " currentpoint 4 index 3 index 1 getinterval false charpath moveto", - " 2 copy 2 mul get 2 index 3 2 roll 2 mul 1 add get", - " pdfTextMat dtransform rmoveto", - " } for", - " } ifelse", - " pop pop", - " } def", - "} ifelse", - "/Tj {", - " fCol", // because stringwidth has to draw Type 3 chars - " 0 pdfTextRise pdfTextMat dtransform rmoveto", - " currentpoint 4 2 roll", - " pdfTextRender 1 and 0 eq {", - " 2 copy xyshow2", - " } if", - " pdfTextRender 3 and dup 1 eq exch 2 eq or {", - " 3 index 3 index moveto", - " 2 copy", - " currentfont /FontType get 3 eq { fCol } { sCol } ifelse", - " xycp currentpoint stroke moveto", - " } if", - " pdfTextRender 4 and 0 ne {", - " 4 2 roll moveto xycp", - " /pdfTextClipPath [ pdfTextClipPath aload pop", - " {/moveto cvx}", - " {/lineto cvx}", - " {/curveto cvx}", - " {/closepath cvx}", - " pathforall ] def", - " currentpoint newpath moveto", - " } {", - " pop pop pop pop", - " } ifelse", - " 0 pdfTextRise neg pdfTextMat dtransform rmoveto", - "} def", - "/TJm { 0.001 mul pdfFontSize mul pdfHorizScaling mul neg 0", - " pdfTextMat dtransform rmoveto } def", - "/TJmV { 0.001 mul pdfFontSize mul neg 0 exch", - " pdfTextMat dtransform rmoveto } def", - "/Tclip { pdfTextClipPath cvx exec clip newpath", - " /pdfTextClipPath [] def } def", - "/Tclip* { pdfTextClipPath cvx exec eoclip newpath", - " /pdfTextClipPath [] def } def", - "~1ns", - "% Level 1 image operators", - "/pdfIm1 {", - " /pdfImBuf1 4 index string def", - " { currentfile pdfImBuf1 readhexstring pop } image", - "} def", - "/pdfIm1Bin {", - " /pdfImBuf1 4 index string def", - " { currentfile pdfImBuf1 readstring pop } image", - "} def", - "~1s", - "/pdfIm1Sep {", - " /pdfImBuf1 4 index string def", - " /pdfImBuf2 4 index string def", - " /pdfImBuf3 4 index string def", - " /pdfImBuf4 4 index string def", - " { currentfile pdfImBuf1 readhexstring pop }", - " { currentfile pdfImBuf2 readhexstring pop }", - " { currentfile pdfImBuf3 readhexstring pop }", - " { currentfile pdfImBuf4 readhexstring pop }", - " true 4 colorimage", - "} def", - "/pdfIm1SepBin {", - " /pdfImBuf1 4 index string def", - " /pdfImBuf2 4 index string def", - " /pdfImBuf3 4 index string def", - " /pdfImBuf4 4 index string def", - " { currentfile pdfImBuf1 readstring pop }", - " { currentfile pdfImBuf2 readstring pop }", - " { currentfile pdfImBuf3 readstring pop }", - " { currentfile pdfImBuf4 readstring pop }", - " true 4 colorimage", - "} def", - "~1ns", - "/pdfImM1 {", - " fCol /pdfImBuf1 4 index 7 add 8 idiv string def", - " { currentfile pdfImBuf1 readhexstring pop } imagemask", - "} def", - "/pdfImM1Bin {", - " fCol /pdfImBuf1 4 index 7 add 8 idiv string def", - " { currentfile pdfImBuf1 readstring pop } imagemask", - "} def", - "/pdfImStr {", - " 2 copy exch length lt {", - " 2 copy get exch 1 add exch", - " } {", - " ()", - " } ifelse", - "} def", - "/pdfImM1a {", - " { pdfImStr } imagemask", - " pop pop", - "} def", - "~23sn", - "% Level 2/3 image operators", - "/pdfImBuf 100 string def", - "/pdfImStr {", - " 2 copy exch length lt {", - " 2 copy get exch 1 add exch", - " } {", - " ()", - " } ifelse", - "} def", - "/skipEOD {", - " { currentfile pdfImBuf readline", - " not { pop exit } if", - " (%-EOD-) eq { exit } if } loop", - "} def", - "/pdfIm { image skipEOD } def", - "~3sn", - "/pdfMask {", - " /ReusableStreamDecode filter", - " skipEOD", - " /maskStream exch def", - "} def", - "/pdfMaskEnd { maskStream closefile } def", - "/pdfMaskInit {", - " /maskArray exch def", - " /maskIdx 0 def", - "} def", - "/pdfMaskSrc {", - " maskIdx maskArray length lt {", - " maskArray maskIdx get", - " /maskIdx maskIdx 1 add def", - " } {", - " ()", - " } ifelse", - "} def", - "~23s", - "/pdfImSep {", - " findcmykcustomcolor exch", - " dup /Width get /pdfImBuf1 exch string def", - " dup /Decode get aload pop 1 index sub /pdfImDecodeRange exch def", - " /pdfImDecodeLow exch def", - " begin Width Height BitsPerComponent ImageMatrix DataSource end", - " /pdfImData exch def", - " { pdfImData pdfImBuf1 readstring pop", - " 0 1 2 index length 1 sub {", - " 1 index exch 2 copy get", - " pdfImDecodeRange mul 255 div pdfImDecodeLow add round cvi", - " 255 exch sub put", - " } for }", - " 6 5 roll customcolorimage", - " skipEOD", - "} def", - "~23sn", - "/pdfImM { fCol imagemask skipEOD } def", - "~123sn", - "/pr { 2 index 2 index 3 2 roll putinterval 4 add } def", - "/pdfImClip {", - " gsave", - " 0 2 4 index length 1 sub {", - " dup 4 index exch 2 copy", - " get 5 index div put", - " 1 add 3 index exch 2 copy", - " get 3 index div put", - " } for", - " pop pop rectclip", - "} def", - "/pdfImClipEnd { grestore } def", - "~23sn", - "% shading operators", - "/colordelta {", - " false 0 1 3 index length 1 sub {", - " dup 4 index exch get 3 index 3 2 roll get sub abs 0.004 gt {", - " pop true", - " } if", - " } for", - " exch pop exch pop", - "} def", - "/funcCol { func n array astore } def", - "/funcSH {", - " dup 0 eq {", - " true", - " } {", - " dup 6 eq {", - " false", - " } {", - " 4 index 4 index funcCol dup", - " 6 index 4 index funcCol dup", - " 3 1 roll colordelta 3 1 roll", - " 5 index 5 index funcCol dup", - " 3 1 roll colordelta 3 1 roll", - " 6 index 8 index funcCol dup", - " 3 1 roll colordelta 3 1 roll", - " colordelta or or or", - " } ifelse", - " } ifelse", - " {", - " 1 add", - " 4 index 3 index add 0.5 mul exch 4 index 3 index add 0.5 mul exch", - " 6 index 6 index 4 index 4 index 4 index funcSH", - " 2 index 6 index 6 index 4 index 4 index funcSH", - " 6 index 2 index 4 index 6 index 4 index funcSH", - " 5 3 roll 3 2 roll funcSH pop pop", - " } {", - " pop 3 index 2 index add 0.5 mul 3 index 2 index add 0.5 mul", - "~23n", - " funcCol sc", - "~23s", - " funcCol aload pop k", - "~23sn", - " dup 4 index exch mat transform m", - " 3 index 3 index mat transform l", - " 1 index 3 index mat transform l", - " mat transform l pop pop h f*", - " } ifelse", - "} def", - "/axialCol {", - " dup 0 lt {", - " pop t0", - " } {", - " dup 1 gt {", - " pop t1", - " } {", - " dt mul t0 add", - " } ifelse", - " } ifelse", - " func n array astore", - "} def", - "/axialSH {", - " dup 0 eq {", - " true", - " } {", - " dup 8 eq {", - " false", - " } {", - " 2 index axialCol 2 index axialCol colordelta", - " } ifelse", - " } ifelse", - " {", - " 1 add 3 1 roll 2 copy add 0.5 mul", - " dup 4 3 roll exch 4 index axialSH", - " exch 3 2 roll axialSH", - " } {", - " pop 2 copy add 0.5 mul", - "~23n", - " axialCol sc", - "~23s", - " axialCol aload pop k", - "~23sn", - " exch dup dx mul x0 add exch dy mul y0 add", - " 3 2 roll dup dx mul x0 add exch dy mul y0 add", - " dx abs dy abs ge {", - " 2 copy yMin sub dy mul dx div add yMin m", - " yMax sub dy mul dx div add yMax l", - " 2 copy yMax sub dy mul dx div add yMax l", - " yMin sub dy mul dx div add yMin l", - " h f*", - " } {", - " exch 2 copy xMin sub dx mul dy div add xMin exch m", - " xMax sub dx mul dy div add xMax exch l", - " exch 2 copy xMax sub dx mul dy div add xMax exch l", - " xMin sub dx mul dy div add xMin exch l", - " h f*", - " } ifelse", - " } ifelse", - "} def", - "/radialCol {", - " dup t0 lt {", - " pop t0", - " } {", - " dup t1 gt {", - " pop t1", - " } if", - " } ifelse", - " func n array astore", - "} def", - "/radialSH {", - " dup 0 eq {", - " true", - " } {", - " dup 8 eq {", - " false", - " } {", - " 2 index dt mul t0 add radialCol", - " 2 index dt mul t0 add radialCol colordelta", - " } ifelse", - " } ifelse", - " {", - " 1 add 3 1 roll 2 copy add 0.5 mul", - " dup 4 3 roll exch 4 index radialSH", - " exch 3 2 roll radialSH", - " } {", - " pop 2 copy add 0.5 mul dt mul t0 add", - "~23n", - " radialCol sc", - "~23s", - " radialCol aload pop k", - "~23sn", - " encl {", - " exch dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add", - " 0 360 arc h", - " dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add", - " 360 0 arcn h f", - " } {", - " 2 copy", - " dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add", - " a1 a2 arcn", - " dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add", - " a2 a1 arcn h", - " dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add", - " a1 a2 arc", - " dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add", - " a2 a1 arc h f", - " } ifelse", - " } ifelse", - "} def", - "~123sn", - "end", - NULL -}; - -static const char *cmapProlog[] = { - "/CIDInit /ProcSet findresource begin", - "10 dict begin", - " begincmap", - " /CMapType 1 def", - " /CMapName /Identity-H def", - " /CIDSystemInfo 3 dict dup begin", - " /Registry (Adobe) def", - " /Ordering (Identity) def", - " /Supplement 0 def", - " end def", - " 1 begincodespacerange", - " <0000> <ffff>", - " endcodespacerange", - " 0 usefont", - " 1 begincidrange", - " <0000> <ffff> 0", - " endcidrange", - " endcmap", - " currentdict CMapName exch /CMap defineresource pop", - "end", - "10 dict begin", - " begincmap", - " /CMapType 1 def", - " /CMapName /Identity-V def", - " /CIDSystemInfo 3 dict dup begin", - " /Registry (Adobe) def", - " /Ordering (Identity) def", - " /Supplement 0 def", - " end def", - " /WMode 1 def", - " 1 begincodespacerange", - " <0000> <ffff>", - " endcodespacerange", - " 0 usefont", - " 1 begincidrange", - " <0000> <ffff> 0", - " endcidrange", - " endcmap", - " currentdict CMapName exch /CMap defineresource pop", - "end", - "end", - NULL -}; - -//------------------------------------------------------------------------ -// Fonts -//------------------------------------------------------------------------ - -struct PSSubstFont { - const char *psName; // PostScript name - double mWidth; // width of 'm' character -}; - -// NB: must be in same order as base14SubstFonts in GfxFont.cc -static PSSubstFont psBase14SubstFonts[14] = { - {"Courier", 0.600}, - {"Courier-Oblique", 0.600}, - {"Courier-Bold", 0.600}, - {"Courier-BoldOblique", 0.600}, - {"Helvetica", 0.833}, - {"Helvetica-Oblique", 0.833}, - {"Helvetica-Bold", 0.889}, - {"Helvetica-BoldOblique", 0.889}, - {"Times-Roman", 0.788}, - {"Times-Italic", 0.722}, - {"Times-Bold", 0.833}, - {"Times-BoldItalic", 0.778}, - // the last two are never used for substitution - {"Symbol", 0}, - {"ZapfDingbats", 0} -}; - -// Mapping from Type 1/1C font file to PS font name. -struct PST1FontName { - Ref fontFileID; - GooString *psName; // PostScript font name used for this - // embedded font file -}; - -// Info for 8-bit fonts -struct PSFont8Info { - Ref fontID; - int *codeToGID; // code-to-GID mapping for TrueType fonts -}; - -// Encoding info for substitute 16-bit font -struct PSFont16Enc { - Ref fontID; - GooString *enc; -}; - -//------------------------------------------------------------------------ -// process colors -//------------------------------------------------------------------------ - -#define psProcessCyan 1 -#define psProcessMagenta 2 -#define psProcessYellow 4 -#define psProcessBlack 8 -#define psProcessCMYK 15 - -//------------------------------------------------------------------------ -// PSOutCustomColor -//------------------------------------------------------------------------ - -class PSOutCustomColor { -public: - - PSOutCustomColor(double cA, double mA, - double yA, double kA, GooString *nameA); - ~PSOutCustomColor(); - - double c, m, y, k; - GooString *name; - PSOutCustomColor *next; -}; - -PSOutCustomColor::PSOutCustomColor(double cA, double mA, - double yA, double kA, GooString *nameA) { - c = cA; - m = mA; - y = yA; - k = kA; - name = nameA; - next = NULL; -} - -PSOutCustomColor::~PSOutCustomColor() { - delete name; -} - -//------------------------------------------------------------------------ - -struct PSOutImgClipRect { - int x0, x1, y0, y1; -}; - -//------------------------------------------------------------------------ - -struct PSOutPaperSize { - PSOutPaperSize(GooString *nameA, int wA, int hA) { name = nameA; w = wA; h = hA; } - ~PSOutPaperSize() { delete name; } - GooString *name; - int w, h; -}; - -//------------------------------------------------------------------------ -// DeviceNRecoder -//------------------------------------------------------------------------ - -class DeviceNRecoder: public FilterStream { -public: - - DeviceNRecoder(Stream *strA, int widthA, int heightA, - GfxImageColorMap *colorMapA); - virtual ~DeviceNRecoder(); - virtual StreamKind getKind() { return strWeird; } - virtual void reset(); - virtual int getChar() - { return (bufIdx >= bufSize && !fillBuf()) ? EOF : buf[bufIdx++]; } - virtual int lookChar() - { return (bufIdx >= bufSize && !fillBuf()) ? EOF : buf[bufIdx]; } - virtual GooString *getPSFilter(int psLevel, const char *indent) { return NULL; } - virtual GBool isBinary(GBool last = gTrue) { return gTrue; } - virtual GBool isEncoder() { return gTrue; } - -private: - - GBool fillBuf(); - - int width, height; - GfxImageColorMap *colorMap; - Function *func; - ImageStream *imgStr; - int buf[gfxColorMaxComps]; - int pixelIdx; - int bufIdx; - int bufSize; -}; - -DeviceNRecoder::DeviceNRecoder(Stream *strA, int widthA, int heightA, - GfxImageColorMap *colorMapA): - FilterStream(strA) { - width = widthA; - height = heightA; - colorMap = colorMapA; - imgStr = NULL; - pixelIdx = 0; - bufIdx = gfxColorMaxComps; - bufSize = ((GfxDeviceNColorSpace *)colorMap->getColorSpace())-> - getAlt()->getNComps(); - func = ((GfxDeviceNColorSpace *)colorMap->getColorSpace())-> - getTintTransformFunc(); -} - -DeviceNRecoder::~DeviceNRecoder() { - if (imgStr) { - delete imgStr; - } - if (str->isEncoder()) { - delete str; - } -} - -void DeviceNRecoder::reset() { - imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(), - colorMap->getBits()); - imgStr->reset(); -} - -GBool DeviceNRecoder::fillBuf() { - Guchar pixBuf[gfxColorMaxComps]; - GfxColor color; - double x[gfxColorMaxComps], y[gfxColorMaxComps]; - int i; - - if (pixelIdx >= width * height) { - return gFalse; - } - imgStr->getPixel(pixBuf); - colorMap->getColor(pixBuf, &color); - for (i = 0; - i < ((GfxDeviceNColorSpace *)colorMap->getColorSpace())->getNComps(); - ++i) { - x[i] = colToDbl(color.c[i]); - } - func->transform(x, y); - for (i = 0; i < bufSize; ++i) { - buf[i] = (int)(y[i] * 255 + 0.5); - } - bufIdx = 0; - ++pixelIdx; - return gTrue; -} - -//------------------------------------------------------------------------ -// PSOutputDev -//------------------------------------------------------------------------ - -extern "C" { -typedef void (*SignalFunc)(int); -} - -static void outputToFile(void *stream, const char *data, int len) { - fwrite(data, 1, len, (FILE *)stream); -} - -PSOutputDev::PSOutputDev(const char *fileName, PDFDoc *doc, - char *psTitle, - const std::vector<int> &pages, PSOutMode modeA, - int paperWidthA, int paperHeightA, - GBool noCropA, GBool duplexA, - int imgLLXA, int imgLLYA, int imgURXA, int imgURYA, - GBool forceRasterizeA, - GBool manualCtrlA, - PSOutCustomCodeCbk customCodeCbkA, - void *customCodeCbkDataA) { - FILE *f; - PSFileType fileTypeA; - - underlayCbk = NULL; - underlayCbkData = NULL; - overlayCbk = NULL; - overlayCbkData = NULL; - customCodeCbk = customCodeCbkA; - customCodeCbkData = customCodeCbkDataA; - - fontIDs = NULL; - fontNames = new GooHash(gTrue); - t1FontNames = NULL; - font8Info = NULL; - font16Enc = NULL; - imgIDs = NULL; - formIDs = NULL; - paperSizes = NULL; - embFontList = NULL; - customColors = NULL; - haveTextClip = gFalse; - t3String = NULL; - forceRasterize = forceRasterizeA; - - // open file or pipe - if (!strcmp(fileName, "-")) { - fileTypeA = psStdout; - f = stdout; - } else if (fileName[0] == '|') { - fileTypeA = psPipe; -#ifdef HAVE_POPEN -#ifndef _WIN32 - signal(SIGPIPE, (SignalFunc)SIG_IGN); -#endif - if (!(f = popen(fileName + 1, "w"))) { - error(errIO, -1, "Couldn't run print command '{0:s}'", fileName); - ok = gFalse; - return; - } -#else - error(errIO, -1, "Print commands are not supported ('{0:s}')", fileName); - ok = gFalse; - return; -#endif - } else { - fileTypeA = psFile; - if (!(f = fopen(fileName, "w"))) { - error(errIO, -1, "Couldn't open PostScript file '{0:s}'", fileName); - ok = gFalse; - return; - } - } - - init(outputToFile, f, fileTypeA, psTitle, - doc, pages, modeA, - imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA, - paperWidthA, paperHeightA, noCropA, duplexA); -} - -PSOutputDev::PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA, - char *psTitle, - PDFDoc *doc, - const std::vector<int> &pages, PSOutMode modeA, - int paperWidthA, int paperHeightA, - GBool noCropA, GBool duplexA, - int imgLLXA, int imgLLYA, int imgURXA, int imgURYA, - GBool forceRasterizeA, - GBool manualCtrlA, - PSOutCustomCodeCbk customCodeCbkA, - void *customCodeCbkDataA) { - underlayCbk = NULL; - underlayCbkData = NULL; - overlayCbk = NULL; - overlayCbkData = NULL; - customCodeCbk = customCodeCbkA; - customCodeCbkData = customCodeCbkDataA; - - fontIDs = NULL; - fontNames = new GooHash(gTrue); - t1FontNames = NULL; - font8Info = NULL; - font16Enc = NULL; - imgIDs = NULL; - formIDs = NULL; - paperSizes = NULL; - embFontList = NULL; - customColors = NULL; - haveTextClip = gFalse; - t3String = NULL; - forceRasterize = forceRasterizeA; - - init(outputFuncA, outputStreamA, psGeneric, psTitle, - doc, pages, modeA, - imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA, - paperWidthA, paperHeightA, noCropA, duplexA); -} - -struct StandardMedia { - const char *name; - int width; - int height; -}; - -static const StandardMedia standardMedia[] = -{ - { "A0", 2384, 3371 }, - { "A1", 1685, 2384 }, - { "A2", 1190, 1684 }, - { "A3", 842, 1190 }, - { "A4", 595, 842 }, - { "A5", 420, 595 }, - { "B4", 729, 1032 }, - { "B5", 516, 729 }, - { "Letter", 612, 792 }, - { "Tabloid", 792, 1224 }, - { "Ledger", 1224, 792 }, - { "Legal", 612, 1008 }, - { "Statement", 396, 612 }, - { "Executive", 540, 720 }, - { "Folio", 612, 936 }, - { "Quarto", 610, 780 }, - { "10x14", 720, 1008 }, - { NULL, 0, 0 } -}; - -/* PLRM specifies a tolerance of 5 points when matching page sizes */ -static bool pageDimensionEqual(int a, int b) { - return (abs (a - b) < 5); -} - -void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA, - PSFileType fileTypeA, char *pstitle, PDFDoc *docA, - const std::vector<int> &pagesA, PSOutMode modeA, - int imgLLXA, int imgLLYA, int imgURXA, int imgURYA, - GBool manualCtrlA, int paperWidthA, int paperHeightA, - GBool noCropA, GBool duplexA) { - Catalog *catalog; - PDFRectangle *box; - PSOutPaperSize *size; - GooList *names; - int w, h, i; - - if (pagesA.empty()) { - ok = gFalse; - return; - } - - // initialize - embedType1 = gTrue; - embedTrueType = gTrue; - embedCIDPostScript = gTrue; - embedCIDTrueType = gTrue; - fontPassthrough = gFalse; - optimizeColorSpace = gFalse; - preloadImagesForms = gFalse; - generateOPI = gFalse; - useASCIIHex = gFalse; - useBinary = gFalse; - rasterMono = gFalse; - rasterResolution = 300; - uncompressPreloadedImages = gFalse; - rasterAntialias = gFalse; - displayText = gTrue; - ok = gTrue; - outputFunc = outputFuncA; - outputStream = outputStreamA; - fileType = fileTypeA; - doc = docA; - xref = doc->getXRef(); - catalog = doc->getCatalog(); - level = globalParams->getPSLevel(); - mode = modeA; - paperWidth = paperWidthA; - paperHeight = paperHeightA; - noCrop = noCropA; - imgLLX = imgLLXA; - imgLLY = imgLLYA; - imgURX = imgURXA; - imgURY = imgURYA; - if (paperWidth < 0 || paperHeight < 0) { - paperMatch = gTrue; - } else { - paperMatch = gFalse; - } - Page *page; - paperSizes = new GooList(); - for (size_t pgi = 0; pgi < pagesA.size(); ++pgi) { - const int pg = pagesA[pgi]; - page = catalog->getPage(pg); - if (page == NULL) - paperMatch = gFalse; - if (!paperMatch) { - w = paperWidth; - h = paperHeight; - if (w < 0 || h < 0) { - // Unable to obtain a paper size from the document and no page size - // specified. In this case use A4 as the page size to ensure the PS output is - // valid. This will only occur if the PDF is very broken. - w = 595; - h = 842; - } - } else if (noCropA) { - w = (int)ceil(page->getMediaWidth()); - h = (int)ceil(page->getMediaHeight()); - } else { - w = (int)ceil(page->getCropWidth()); - h = (int)ceil(page->getCropHeight()); - } - if (paperMatch) { - int rotate = page->getRotate(); - if (rotate == 90 || rotate == 270) - std::swap(w, h); - } - if (w > paperWidth) - paperWidth = w; - if (h > paperHeight) - paperHeight = h; - for (i = 0; i < paperSizes->getLength(); ++i) { - size = (PSOutPaperSize *)paperSizes->get(i); - if (pageDimensionEqual(w, size->w) && pageDimensionEqual(h, size->h)) - break; - } - if (i == paperSizes->getLength()) { - const StandardMedia *media = standardMedia; - GooString *name = NULL; - while (media->name) { - if (pageDimensionEqual(w, media->width) && pageDimensionEqual(h, media->height)) { - name = new GooString(media->name); - w = media->width; - h = media->height; - break; - } - media++; - } - if (!name) - name = GooString::format("{0:d}x{1:d}mm", int(w*25.4/72), int(h*25.4/72)); - paperSizes->append(new PSOutPaperSize(name, w, h)); - } - pagePaperSize.insert(std::pair<int,int>(pg, i)); - if (!paperMatch) - break; // we only need one entry when all pages are the same size - } - if (imgLLX == 0 && imgURX == 0 && imgLLY == 0 && imgURY == 0) { - imgLLX = imgLLY = 0; - imgURX = paperWidth; - imgURY = paperHeight; - } - manualCtrl = manualCtrlA; - std::vector<int> pages; - if (mode == psModeForm) { - pages.push_back(pagesA[0]); - } else { - pages = pagesA; - } - processColors = 0; - inType3Char = gFalse; - inUncoloredPattern = gFalse; - t3FillColorOnly = gFalse; - -#if OPI_SUPPORT - // initialize OPI nesting levels - opi13Nest = 0; - opi20Nest = 0; -#endif - - tx0 = ty0 = -1; - xScale0 = yScale0 = 0; - rotate0 = -1; - clipLLX0 = clipLLY0 = 0; - clipURX0 = clipURY0 = -1; - - // initialize fontIDs, fontFileIDs, and fontFileNames lists - fontIDSize = 64; - fontIDLen = 0; - fontIDs = (Ref *)gmallocn(fontIDSize, sizeof(Ref)); - for (i = 0; i < 14; ++i) { - fontNames->add(new GooString(psBase14SubstFonts[i].psName), 1); - } - names = globalParams->getPSResidentFonts(); - for (i = 0; i < names->getLength(); ++i) { - fontNames->add((GooString *)names->get(i), 1); - } - delete names; - t1FontNameSize = 64; - t1FontNameLen = 0; - t1FontNames = (PST1FontName *)gmallocn(t1FontNameSize, sizeof(PST1FontName)); - font8InfoLen = 0; - font8InfoSize = 0; - font16EncLen = 0; - font16EncSize = 0; - imgIDLen = 0; - imgIDSize = 0; - formIDLen = 0; - formIDSize = 0; - - numSaves = 0; - numTilingPatterns = 0; - nextFunc = 0; - - // initialize embedded font resource comment list - embFontList = new GooString(); - - if (!manualCtrl) { - Page *page; - // this check is needed in case the document has zero pages - if ((page = doc->getPage(pages[0]))) { - writeHeader(pages, - page->getMediaBox(), - page->getCropBox(), - page->getRotate(), - pstitle); - } else { - error(errSyntaxError, -1, "Invalid page {0:d}", pages[0]); - box = new PDFRectangle(0, 0, 1, 1); - writeHeader(pages, box, box, 0, pstitle); - delete box; - } - if (mode != psModeForm) { - writePS("%%BeginProlog\n"); - } - writeXpdfProcset(); - if (mode != psModeForm) { - writePS("%%EndProlog\n"); - writePS("%%BeginSetup\n"); - } - writeDocSetup(doc, catalog, pages, duplexA); - if (mode != psModeForm) { - writePS("%%EndSetup\n"); - } - } - - // initialize sequential page number - seqPage = 1; -} - -PSOutputDev::~PSOutputDev() { - PSOutCustomColor *cc; - int i; - - if (ok) { - if (!manualCtrl) { - writePS("%%Trailer\n"); - writeTrailer(); - if (mode != psModeForm) { - writePS("%%EOF\n"); - } - } - if (fileType == psFile) { -#ifdef MACOS - ICS_MapRefNumAndAssign((short)((FILE *)outputStream)->handle); -#endif - fclose((FILE *)outputStream); - } -#ifdef HAVE_POPEN - else if (fileType == psPipe) { - pclose((FILE *)outputStream); -#ifndef _WIN32 - signal(SIGPIPE, (SignalFunc)SIG_DFL); -#endif - } -#endif - } - if (paperSizes) { - deleteGooList(paperSizes, PSOutPaperSize); - } - if (embFontList) { - delete embFontList; - } - if (fontIDs) { - gfree(fontIDs); - } - delete fontNames; - if (t1FontNames) { - for (i = 0; i < t1FontNameLen; ++i) { - delete t1FontNames[i].psName; - } - gfree(t1FontNames); - } - if (font8Info) { - for (i = 0; i < font8InfoLen; ++i) { - gfree(font8Info[i].codeToGID); - } - gfree(font8Info); - } - if (font16Enc) { - for (i = 0; i < font16EncLen; ++i) { - if (font16Enc[i].enc) { - delete font16Enc[i].enc; - } - } - gfree(font16Enc); - } - gfree(imgIDs); - gfree(formIDs); - while (customColors) { - cc = customColors; - customColors = cc->next; - delete cc; - } -} - -void PSOutputDev::writeHeader(const std::vector<int> &pages, - PDFRectangle *mediaBox, PDFRectangle *cropBox, - int pageRotate, char *psTitle) { - Object info, obj1; - PSOutPaperSize *size; - double x1, y1, x2, y2; - int i; - - switch (mode) { - case psModePS: - writePS("%!PS-Adobe-3.0\n"); - break; - case psModeEPS: - writePS("%!PS-Adobe-3.0 EPSF-3.0\n"); - break; - case psModeForm: - writePS("%!PS-Adobe-3.0 Resource-Form\n"); - break; - } - writePSFmt("%Produced by poppler pdftops version: {0:s} (http://poppler.freedesktop.org)\n", PACKAGE_VERSION); - xref->getDocInfo(&info); - if (info.isDict() && info.dictLookup("Creator", &obj1)->isString()) { - writePS("%%Creator: "); - writePSTextLine(obj1.getString()); - } - obj1.free(); - info.free(); - if(psTitle) { - char *sanitizedTile = strdup(psTitle); - for (Guint i = 0; i < strlen(sanitizedTile); ++i) { - if (sanitizedTile[i] == '\n' || sanitizedTile[i] == '\r') { - sanitizedTile[i] = ' '; - } - } - writePSFmt("%%Title: {0:s}\n", sanitizedTile); - free(sanitizedTile); - } - writePSFmt("%%LanguageLevel: {0:d}\n", - (level == psLevel1 || level == psLevel1Sep) ? 1 : - (level == psLevel2 || level == psLevel2Sep) ? 2 : 3); - if (level == psLevel1Sep || level == psLevel2Sep || level == psLevel3Sep) { - writePS("%%DocumentProcessColors: (atend)\n"); - writePS("%%DocumentCustomColors: (atend)\n"); - } - writePS("%%DocumentSuppliedResources: (atend)\n"); - if ((level == psLevel1 || level == psLevel1Sep) && useBinary) { - writePS("%%DocumentData: Binary\n"); - } - - switch (mode) { - case psModePS: - for (i = 0; i < paperSizes->getLength(); ++i) { - size = (PSOutPaperSize *)paperSizes->get(i); - writePSFmt("%%{0:s} {1:t} {2:d} {3:d} 0 () ()\n", - i==0 ? "DocumentMedia:" : "+", size->name, size->w, size->h); - } - writePSFmt("%%BoundingBox: 0 0 {0:d} {1:d}\n", paperWidth, paperHeight); - writePSFmt("%%Pages: {0:d}\n", static_cast<int>(pages.size())); - writePS("%%EndComments\n"); - if (!paperMatch) { - size = (PSOutPaperSize *)paperSizes->get(0); - writePS("%%BeginDefaults\n"); - writePSFmt("%%PageMedia: {0:t}\n", size->name); - writePS("%%EndDefaults\n"); - } - break; - case psModeEPS: - epsX1 = cropBox->x1; - epsY1 = cropBox->y1; - epsX2 = cropBox->x2; - epsY2 = cropBox->y2; - if (pageRotate == 0 || pageRotate == 180) { - x1 = epsX1; - y1 = epsY1; - x2 = epsX2; - y2 = epsY2; - } else { // pageRotate == 90 || pageRotate == 270 - x1 = 0; - y1 = 0; - x2 = epsY2 - epsY1; - y2 = epsX2 - epsX1; - } - writePSFmt("%%BoundingBox: {0:d} {1:d} {2:d} {3:d}\n", - (int)floor(x1), (int)floor(y1), (int)ceil(x2), (int)ceil(y2)); - writePSFmt("%%HiResBoundingBox: {0:.6g} {1:.6g} {2:.6g} {3:.6g}\n", - x1, y1, x2, y2); - writePS("%%DocumentSuppliedResources: (atend)\n"); - writePS("%%EndComments\n"); - break; - case psModeForm: - writePS("%%EndComments\n"); - writePS("32 dict dup begin\n"); - writePSFmt("/BBox [{0:d} {1:d} {2:d} {3:d}] def\n", - (int)floor(mediaBox->x1), (int)floor(mediaBox->y1), - (int)ceil(mediaBox->x2), (int)ceil(mediaBox->y2)); - writePS("/FormType 1 def\n"); - writePS("/Matrix [1 0 0 1 0 0] def\n"); - break; - } -} - -void PSOutputDev::writeXpdfProcset() { - GBool lev1, lev2, lev3, sep, nonSep; - const char **p; - const char *q; - - writePSFmt("%%BeginResource: procset xpdf {0:s} 0\n", "3.00"); - writePSFmt("%%Copyright: {0:s}\n", xpdfCopyright); - lev1 = lev2 = lev3 = sep = nonSep = gTrue; - for (p = prolog; *p; ++p) { - if ((*p)[0] == '~') { - lev1 = lev2 = lev3 = sep = nonSep = gFalse; - for (q = *p + 1; *q; ++q) { - switch (*q) { - case '1': lev1 = gTrue; break; - case '2': lev2 = gTrue; break; - case '3': lev3 = gTrue; break; - case 's': sep = gTrue; break; - case 'n': nonSep = gTrue; break; - } - } - } else if ((level == psLevel1 && lev1 && nonSep) || - (level == psLevel1Sep && lev1 && sep) || - (level == psLevel2 && lev2 && nonSep) || - (level == psLevel2Sep && lev2 && sep) || - (level == psLevel3 && lev3 && nonSep) || - (level == psLevel3Sep && lev3 && sep)) { - writePSFmt("{0:s}\n", *p); - } - } - writePS("%%EndResource\n"); - - if (level >= psLevel3) { - for (p = cmapProlog; *p; ++p) { - writePSFmt("{0:s}\n", *p); - } - } -} - -void PSOutputDev::writeDocSetup(PDFDoc *doc, Catalog *catalog, - const std::vector<int> &pages, - GBool duplexA) { - Page *page; - Dict *resDict; - Annots *annots; - Object *acroForm; - Object obj1, obj2, obj3; - GooString *s; - int i; - - if (mode == psModeForm) { - // swap the form and xpdf dicts - writePS("xpdf end begin dup begin\n"); - } else { - writePS("xpdf begin\n"); - } - for (size_t pgi = 0; pgi < pages.size(); ++pgi) { - const int pg = pages[pgi]; - page = doc->getPage(pg); - if (!page) { - error(errSyntaxError, -1, "Failed writing resources for page {0:d}", pg); - continue; - } - if ((resDict = page->getResourceDict())) { - setupResources(resDict); - } - annots = page->getAnnots(); - for (i = 0; i < annots->getNumAnnots(); ++i) { - if (annots->getAnnot(i)->getAppearanceResDict(&obj1)->isDict()) { - setupResources(obj1.getDict()); - } - obj1.free(); - } - } - if ((acroForm = catalog->getAcroForm()) && acroForm->isDict()) { - if (acroForm->dictLookup("DR", &obj1)->isDict()) { - setupResources(obj1.getDict()); - } - obj1.free(); - if (acroForm->dictLookup("Fields", &obj1)->isArray()) { - for (i = 0; i < obj1.arrayGetLength(); ++i) { - if (obj1.arrayGet(i, &obj2)->isDict()) { - if (obj2.dictLookup("DR", &obj3)->isDict()) { - setupResources(obj3.getDict()); - } - obj3.free(); - } - obj2.free(); - } - } - obj1.free(); - } - if (mode != psModeForm) { - if (mode != psModeEPS && !manualCtrl) { - writePSFmt("{0:s} pdfSetup\n", - duplexA ? "true" : "false"); - if (!paperMatch) { - writePSFmt("{0:d} {1:d} pdfSetupPaper\n", paperWidth, paperHeight); - } - } -#if OPI_SUPPORT - if (generateOPI) { - writePS("/opiMatrix matrix currentmatrix def\n"); - } -#endif - } - if (customCodeCbk) { - if ((s = (*customCodeCbk)(this, psOutCustomDocSetup, 0, - customCodeCbkData))) { - writePS(s->getCString()); - delete s; - } - } -} - -void PSOutputDev::writePageTrailer() { - if (mode != psModeForm) { - writePS("pdfEndPage\n"); - } -} - -void PSOutputDev::writeTrailer() { - PSOutCustomColor *cc; - - if (mode == psModeForm) { - writePS("/Foo exch /Form defineresource pop\n"); - } else { - writePS("end\n"); - writePS("%%DocumentSuppliedResources:\n"); - writePS(embFontList->getCString()); - if (level == psLevel1Sep || level == psLevel2Sep || - level == psLevel3Sep) { - writePS("%%DocumentProcessColors:"); - if (processColors & psProcessCyan) { - writePS(" Cyan"); - } - if (processColors & psProcessMagenta) { - writePS(" Magenta"); - } - if (processColors & psProcessYellow) { - writePS(" Yellow"); - } - if (processColors & psProcessBlack) { - writePS(" Black"); - } - writePS("\n"); - writePS("%%DocumentCustomColors:"); - for (cc = customColors; cc; cc = cc->next) { - writePS(" "); - writePSString(cc->name); - } - writePS("\n"); - writePS("%%CMYKCustomColor:\n"); - for (cc = customColors; cc; cc = cc->next) { - writePSFmt("%%+ {0:.4g} {1:.4g} {2:.4g} {3:.4g} ", - cc->c, cc->m, cc->y, cc->k); - writePSString(cc->name); - writePS("\n"); - } - } - } -} - -void PSOutputDev::setupResources(Dict *resDict) { - Object xObjDict, xObjRef, xObj, patDict, patRef, pat, resObj; - Ref ref0; - GBool skip; - int i; - - setupFonts(resDict); - setupImages(resDict); - setupForms(resDict); - - //----- recursively scan XObjects - resDict->lookup("XObject", &xObjDict); - if (xObjDict.isDict()) { - for (i = 0; i < xObjDict.dictGetLength(); ++i) { - - // avoid infinite recursion on XObjects - skip = gFalse; - if ((xObjDict.dictGetValNF(i, &xObjRef)->isRef())) { - ref0 = xObjRef.getRef(); - if (resourceIDs.find(ref0.num) != resourceIDs.end()) { - skip = gTrue; - } else { - resourceIDs.insert(ref0.num); - } - } - if (!skip) { - - // process the XObject's resource dictionary - xObjDict.dictGetVal(i, &xObj); - if (xObj.isStream()) { - xObj.streamGetDict()->lookup("Resources", &resObj); - if (resObj.isDict()) { - setupResources(resObj.getDict()); - } - resObj.free(); - } - xObj.free(); - } - - xObjRef.free(); - } - } - xObjDict.free(); - - //----- recursively scan Patterns - resDict->lookup("Pattern", &patDict); - if (patDict.isDict()) { - inType3Char = gTrue; - for (i = 0; i < patDict.dictGetLength(); ++i) { - - // avoid infinite recursion on Patterns - skip = gFalse; - if ((patDict.dictGetValNF(i, &patRef)->isRef())) { - ref0 = patRef.getRef(); - if (resourceIDs.find(ref0.num) != resourceIDs.end()) { - skip = gTrue; - } else { - resourceIDs.insert(ref0.num); - } - } - if (!skip) { - - // process the Pattern's resource dictionary - patDict.dictGetVal(i, &pat); - if (pat.isStream()) { - pat.streamGetDict()->lookup("Resources", &resObj); - if (resObj.isDict()) { - setupResources(resObj.getDict()); - } - resObj.free(); - } - pat.free(); - } - - patRef.free(); - } - inType3Char = gFalse; - } - patDict.free(); -} - -void PSOutputDev::setupFonts(Dict *resDict) { - Object obj1, obj2; - Ref r; - GfxFontDict *gfxFontDict; - GfxFont *font; - int i; - - gfxFontDict = NULL; - resDict->lookupNF("Font", &obj1); - if (obj1.isRef()) { - obj1.fetch(xref, &obj2); - if (obj2.isDict()) { - r = obj1.getRef(); - gfxFontDict = new GfxFontDict(xref, &r, obj2.getDict()); - } - obj2.free(); - } else if (obj1.isDict()) { - gfxFontDict = new GfxFontDict(xref, NULL, obj1.getDict()); - } - if (gfxFontDict) { - for (i = 0; i < gfxFontDict->getNumFonts(); ++i) { - if ((font = gfxFontDict->getFont(i))) { - setupFont(font, resDict); - } - } - delete gfxFontDict; - } - obj1.free(); -} - -void PSOutputDev::setupFont(GfxFont *font, Dict *parentResDict) { - GfxFontLoc *fontLoc; - GooString *psName; - char buf[16]; - GBool subst; - UnicodeMap *uMap; - const char *charName; - double xs, ys; - int code; - double w1, w2; - int i, j; - - // check if font is already set up - for (i = 0; i < fontIDLen; ++i) { - if (fontIDs[i].num == font->getID()->num && - fontIDs[i].gen == font->getID()->gen) { - return; - } - } - - // add entry to fontIDs list - if (fontIDLen >= fontIDSize) { - fontIDSize += 64; - fontIDs = (Ref *)greallocn(fontIDs, fontIDSize, sizeof(Ref)); - } - fontIDs[fontIDLen++] = *font->getID(); - - psName = NULL; - xs = ys = 1; - subst = gFalse; - - if (font->getType() == fontType3) { - psName = GooString::format("T3_{0:d}_{1:d}", - font->getID()->num, font->getID()->gen); - setupType3Font(font, psName, parentResDict); - } else { - fontLoc = font->locateFont(xref, this); - if (fontLoc != NULL) { - switch (fontLoc->locType) { - case gfxFontLocEmbedded: - switch (fontLoc->fontType) { - case fontType1: - // this assumes that the PS font name matches the PDF font name - psName = font->getEmbeddedFontName() ? font->getEmbeddedFontName()->copy() : new GooString(); - setupEmbeddedType1Font(&fontLoc->embFontID, psName); - break; - case fontType1C: - psName = makePSFontName(font, &fontLoc->embFontID); - setupEmbeddedType1CFont(font, &fontLoc->embFontID, psName); - break; - case fontType1COT: - psName = makePSFontName(font, &fontLoc->embFontID); - setupEmbeddedOpenTypeT1CFont(font, &fontLoc->embFontID, psName); - break; - case fontTrueType: - case fontTrueTypeOT: - psName = makePSFontName(font, font->getID()); - setupEmbeddedTrueTypeFont(font, &fontLoc->embFontID, psName); - break; - case fontCIDType0C: - psName = makePSFontName(font, &fontLoc->embFontID); - setupEmbeddedCIDType0Font(font, &fontLoc->embFontID, psName); - break; - case fontCIDType2: - case fontCIDType2OT: - psName = makePSFontName(font, font->getID()); - //~ should check to see if font actually uses vertical mode - setupEmbeddedCIDTrueTypeFont(font, &fontLoc->embFontID, psName, gTrue); - break; - case fontCIDType0COT: - psName = makePSFontName(font, &fontLoc->embFontID); - setupEmbeddedOpenTypeCFFFont(font, &fontLoc->embFontID, psName); - break; - default: - break; - } - break; - case gfxFontLocExternal: - //~ add cases for external 16-bit fonts - switch (fontLoc->fontType) { - case fontType1: - if (font->getEmbeddedFontName()) { - // this assumes that the PS font name matches the PDF font name - psName = font->getEmbeddedFontName()->copy(); - } else { - //~ this won't work -- the PS font name won't match - psName = makePSFontName(font, font->getID()); - } - setupExternalType1Font(fontLoc->path, psName); - break; - case fontTrueType: - case fontTrueTypeOT: - psName = makePSFontName(font, font->getID()); - setupExternalTrueTypeFont(font, fontLoc->path, psName); - break; - case fontCIDType2: - case fontCIDType2OT: - psName = makePSFontName(font, font->getID()); - //~ should check to see if font actually uses vertical mode - setupExternalCIDTrueTypeFont(font, fontLoc->path, psName, gTrue); - break; - default: - break; - } - break; - case gfxFontLocResident: - psName = fontLoc->path->copy(); - break; - } - } - - if (!psName) { - if (font->isCIDFont()) { - error(errSyntaxError, -1, - "Couldn't find a font to substitute for '{0:s}' ('{1:s}' character collection)", - font->getName() ? font->getName()->getCString() - : "(unnamed)", - ((GfxCIDFont *)font)->getCollection() - ? ((GfxCIDFont *)font)->getCollection()->getCString() - : "(unknown)"); - if (font16EncLen >= font16EncSize) { - font16EncSize += 16; - font16Enc = (PSFont16Enc *)greallocn(font16Enc, - font16EncSize, - sizeof(PSFont16Enc)); - } - font16Enc[font16EncLen].fontID = *font->getID(); - font16Enc[font16EncLen].enc = NULL; - ++font16EncLen; - } else { - error(errSyntaxError, -1, - "Couldn't find a font to substitute for '{0:s}'", - font->getName() ? font->getName()->getCString() - : "(unnamed)"); - } - delete fontLoc; - return; - } - - // scale substituted 8-bit fonts - if (fontLoc->locType == gfxFontLocResident && - fontLoc->substIdx >= 0) { - subst = gTrue; - for (code = 0; code < 256; ++code) { - if ((charName = ((Gfx8BitFont *)font)->getCharName(code)) && - charName[0] == 'm' && charName[1] == '\0') { - break; - } - } - if (code < 256) { - w1 = ((Gfx8BitFont *)font)->getWidth(code); - } else { - w1 = 0; - } - w2 = psBase14SubstFonts[fontLoc->substIdx].mWidth; - xs = w1 / w2; - if (xs < 0.1) { - xs = 1; - } - } - - // handle encodings for substituted CID fonts - if (fontLoc->locType == gfxFontLocResident && - fontLoc->fontType >= fontCIDType0) { - subst = gTrue; - if (font16EncLen >= font16EncSize) { - font16EncSize += 16; - font16Enc = (PSFont16Enc *)greallocn(font16Enc, - font16EncSize, - sizeof(PSFont16Enc)); - } - font16Enc[font16EncLen].fontID = *font->getID(); - if ((uMap = globalParams->getUnicodeMap(fontLoc->encoding))) { - font16Enc[font16EncLen].enc = fontLoc->encoding->copy(); - uMap->decRefCnt(); - } else { - error(errSyntaxError, -1, - "Couldn't find Unicode map for 16-bit font encoding '{0:t}'", - fontLoc->encoding); - font16Enc[font16EncLen].enc = NULL; - } - ++font16EncLen; - } - - delete fontLoc; - } - - // generate PostScript code to set up the font - if (font->isCIDFont()) { - if (level == psLevel3 || level == psLevel3Sep) { - writePSFmt("/F{0:d}_{1:d} /{2:t} {3:d} pdfMakeFont16L3\n", - font->getID()->num, font->getID()->gen, psName, - font->getWMode()); - } else { - writePSFmt("/F{0:d}_{1:d} /{2:t} {3:d} pdfMakeFont16\n", - font->getID()->num, font->getID()->gen, psName, - font->getWMode()); - } - } else { - writePSFmt("/F{0:d}_{1:d} /{2:t} {3:.6g} {4:.6g}\n", - font->getID()->num, font->getID()->gen, psName, xs, ys); - for (i = 0; i < 256; i += 8) { - writePS((char *)((i == 0) ? "[ " : " ")); - for (j = 0; j < 8; ++j) { - if (font->getType() == fontTrueType && - !subst && - !((Gfx8BitFont *)font)->getHasEncoding()) { - sprintf(buf, "c%02x", i+j); - charName = buf; - } else { - charName = ((Gfx8BitFont *)font)->getCharName(i+j); - } - writePS("/"); - writePSName(charName ? charName : (char *)".notdef"); - // the empty name is legal in PDF and PostScript, but PostScript - // uses a double-slash (//...) for "immediately evaluated names", - // so we need to add a space character here - if (charName && !charName[0]) { - writePS(" "); - } - } - writePS((i == 256-8) ? (char *)"]\n" : (char *)"\n"); - } - writePS("pdfMakeFont\n"); - } - - delete psName; -} - -void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) { - static const char hexChar[17] = "0123456789abcdef"; - Object refObj, strObj, obj1, obj2, obj3; - Dict *dict; - int length1, length2, length3; - int c; - int start[4]; - GBool binMode; - GBool writePadding = gTrue; - int i; - - // check if font is already embedded - if (fontNames->lookupInt(psName)) { - return; - } - fontNames->add(psName->copy(), 1); - - // get the font stream and info - refObj.initRef(id->num, id->gen); - refObj.fetch(xref, &strObj); - refObj.free(); - if (!strObj.isStream()) { - error(errSyntaxError, -1, "Embedded font file object is not a stream"); - goto err1; - } - if (!(dict = strObj.streamGetDict())) { - error(errSyntaxError, -1, - "Embedded font stream is missing its dictionary"); - goto err1; - } - dict->lookup("Length1", &obj1); - dict->lookup("Length2", &obj2); - dict->lookup("Length3", &obj3); - if (!obj1.isInt() || !obj2.isInt() || !obj3.isInt()) { - error(errSyntaxError, -1, - "Missing length fields in embedded font stream dictionary"); - obj1.free(); - obj2.free(); - obj3.free(); - goto err1; - } - length1 = obj1.getInt(); - length2 = obj2.getInt(); - length3 = obj3.getInt(); - obj1.free(); - obj2.free(); - obj3.free(); - - // beginning comment - writePSFmt("%%BeginResource: font {0:t}\n", psName); - embFontList->append("%%+ font "); - embFontList->append(psName->getCString()); - embFontList->append("\n"); - - // copy ASCII portion of font - strObj.streamReset(); - for (i = 0; i < length1 && (c = strObj.streamGetChar()) != EOF; ++i) { - writePSChar(c); - } - - // figure out if encrypted portion is binary or ASCII - binMode = gFalse; - for (i = 0; i < 4; ++i) { - start[i] = strObj.streamGetChar(); - if (start[i] == EOF) { - error(errSyntaxError, -1, - "Unexpected end of file in embedded font stream"); - goto err1; - } - if (!((start[i] >= '0' && start[i] <= '9') || - (start[i] >= 'A' && start[i] <= 'F') || - (start[i] >= 'a' && start[i] <= 'f'))) - binMode = gTrue; - } - - if (length2 == 0) - { - // length2 == 0 is an error - // trying to solve it by just piping all - // the stream data - error(errSyntaxWarning, -1, "Font has length2 as 0, trying to overcome the problem reading the stream until the end"); - length2 = INT_MAX; - writePadding = gFalse; - } - - - // convert binary data to ASCII - if (binMode) { - for (i = 0; i < 4; ++i) { - writePSChar(hexChar[(start[i] >> 4) & 0x0f]); - writePSChar(hexChar[start[i] & 0x0f]); - } -#if 0 // this causes trouble for various PostScript printers - // if Length2 is incorrect (too small), font data gets chopped, so - // we take a few extra characters from the trailer just in case - length2 += length3 >= 8 ? 8 : length3; -#endif - while (i < length2) { - if ((c = strObj.streamGetChar()) == EOF) { - break; - } - writePSChar(hexChar[(c >> 4) & 0x0f]); - writePSChar(hexChar[c & 0x0f]); - if (++i % 32 == 0) { - writePSChar('\n'); - } - } - if (i % 32 > 0) { - writePSChar('\n'); - } - - // already in ASCII format -- just copy it - } else { - for (i = 0; i < 4; ++i) { - writePSChar(start[i]); - } - for (i = 4; i < length2; ++i) { - if ((c = strObj.streamGetChar()) == EOF) { - break; - } - writePSChar(c); - } - } - - if (writePadding) - { - if (length3 > 0) { - // write fixed-content portion - while ((c = strObj.streamGetChar()) != EOF) { - writePSChar(c); - } - } else { - // write padding and "cleartomark" - for (i = 0; i < 8; ++i) { - writePS("00000000000000000000000000000000" - "00000000000000000000000000000000\n"); - } - writePS("cleartomark\n"); - } - } - - // ending comment - writePS("%%EndResource\n"); - - err1: - if (strObj.isStream()) - strObj.streamClose(); - strObj.free(); -} - -void PSOutputDev::setupExternalType1Font(GooString *fileName, GooString *psName) { - static const char hexChar[17] = "0123456789abcdef"; - FILE *fontFile; - int c; - - if (fontNames->lookupInt(psName)) { - return; - } - fontNames->add(psName->copy(), 1); - - // beginning comment - writePSFmt("%%BeginResource: font {0:t}\n", psName); - embFontList->append("%%+ font "); - embFontList->append(psName->getCString()); - embFontList->append("\n"); - - // copy the font file - if (!(fontFile = fopen(fileName->getCString(), "rb"))) { - error(errIO, -1, "Couldn't open external font file"); - return; - } - - c = fgetc(fontFile); - if (c == 0x80) { - // PFB file - ungetc(c, fontFile); - while (!feof(fontFile)) { - fgetc(fontFile); // skip start of segment byte (0x80) - int segType = fgetc(fontFile); - long segLen = fgetc(fontFile) | - (fgetc(fontFile) << 8) | - (fgetc(fontFile) << 16) | - (fgetc(fontFile) << 24); - if (feof(fontFile)) - break; - - if (segType == 1) { - // ASCII segment - for (long i = 0; i < segLen; i++) { - c = fgetc(fontFile); - if (c == EOF) - break; - writePSChar(c); - } - } else if (segType == 2) { - // binary segment - for (long i = 0; i < segLen; i++) { - c = fgetc(fontFile); - if (c == EOF) - break; - writePSChar(hexChar[(c >> 4) & 0x0f]); - writePSChar(hexChar[c & 0x0f]); - if (i % 36 == 35) - writePSChar('\n'); - } - } else { - // end of file - break; - } - } - } else if (c != EOF) { - writePSChar(c); - while ((c = fgetc(fontFile)) != EOF) - writePSChar(c); - } - fclose(fontFile); - - // ending comment - writePS("%%EndResource\n"); -} - -void PSOutputDev::setupEmbeddedType1CFont(GfxFont *font, Ref *id, - GooString *psName) { - char *fontBuf; - int fontLen; - FoFiType1C *ffT1C; - int i; - - // check if font is already embedded - for (i = 0; i < t1FontNameLen; ++i) { - if (t1FontNames[i].fontFileID.num == id->num && - t1FontNames[i].fontFileID.gen == id->gen) { - psName->clear(); - psName->insert(0, t1FontNames[i].psName); - return; - } - } - if (t1FontNameLen == t1FontNameSize) { - t1FontNameSize *= 2; - t1FontNames = (PST1FontName *)greallocn(t1FontNames, t1FontNameSize, - sizeof(PST1FontName)); - } - t1FontNames[t1FontNameLen].fontFileID = *id; - t1FontNames[t1FontNameLen].psName = psName->copy(); - ++t1FontNameLen; - - // beginning comment - writePSFmt("%%BeginResource: font {0:t}\n", psName); - embFontList->append("%%+ font "); - embFontList->append(psName->getCString()); - embFontList->append("\n"); - - // convert it to a Type 1 font - if ((fontBuf = font->readEmbFontFile(xref, &fontLen))) { - if ((ffT1C = FoFiType1C::make(fontBuf, fontLen))) { - ffT1C->convertToType1(psName->getCString(), NULL, gTrue, - outputFunc, outputStream); - delete ffT1C; - } - gfree(fontBuf); - } - - // ending comment - writePS("%%EndResource\n"); -} - -void PSOutputDev::setupEmbeddedOpenTypeT1CFont(GfxFont *font, Ref *id, - GooString *psName) { - char *fontBuf; - int fontLen; - FoFiTrueType *ffTT; - int i; - - // check if font is already embedded - for (i = 0; i < t1FontNameLen; ++i) { - if (t1FontNames[i].fontFileID.num == id->num && - t1FontNames[i].fontFileID.gen == id->gen) { - psName->clear(); - psName->insert(0, t1FontNames[i].psName); - return; - } - } - if (t1FontNameLen == t1FontNameSize) { - t1FontNameSize *= 2; - t1FontNames = (PST1FontName *)greallocn(t1FontNames, t1FontNameSize, - sizeof(PST1FontName)); - } - t1FontNames[t1FontNameLen].fontFileID = *id; - t1FontNames[t1FontNameLen].psName = psName->copy(); - ++t1FontNameLen; - - // beginning comment - writePSFmt("%%BeginResource: font {0:t}\n", psName); - embFontList->append("%%+ font "); - embFontList->append(psName->getCString()); - embFontList->append("\n"); - - // convert it to a Type 1 font - if ((fontBuf = font->readEmbFontFile(xref, &fontLen))) { - if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) { - if (ffTT->isOpenTypeCFF()) { - ffTT->convertToType1(psName->getCString(), NULL, gTrue, - outputFunc, outputStream); - } - delete ffTT; - } - gfree(fontBuf); - } - - // ending comment - writePS("%%EndResource\n"); -} - -void PSOutputDev::setupEmbeddedTrueTypeFont(GfxFont *font, Ref *id, - GooString *psName) { - char *fontBuf; - int fontLen; - FoFiTrueType *ffTT; - int *codeToGID; - - // beginning comment - writePSFmt("%%BeginResource: font {0:t}\n", psName); - embFontList->append("%%+ font "); - embFontList->append(psName->getCString()); - embFontList->append("\n"); - - // convert it to a Type 42 font - if ((fontBuf = font->readEmbFontFile(xref, &fontLen))) { - if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) { - codeToGID = ((Gfx8BitFont *)font)->getCodeToGIDMap(ffTT); - ffTT->convertToType42(psName->getCString(), - ((Gfx8BitFont *)font)->getHasEncoding() - ? ((Gfx8BitFont *)font)->getEncoding() - : (char **)NULL, - codeToGID, outputFunc, outputStream); - if (codeToGID) { - if (font8InfoLen >= font8InfoSize) { - font8InfoSize += 16; - font8Info = (PSFont8Info *)greallocn(font8Info, - font8InfoSize, - sizeof(PSFont8Info)); - } - font8Info[font8InfoLen].fontID = *font->getID(); - font8Info[font8InfoLen].codeToGID = codeToGID; - ++font8InfoLen; - } - delete ffTT; - } - gfree(fontBuf); - } - - // ending comment - writePS("%%EndResource\n"); -} - -void PSOutputDev::setupExternalTrueTypeFont(GfxFont *font, GooString *fileName, - GooString *psName) { - FoFiTrueType *ffTT; - int *codeToGID; - - // beginning comment - writePSFmt("%%BeginResource: font {0:t}\n", psName); - embFontList->append("%%+ font "); - embFontList->append(psName->getCString()); - embFontList->append("\n"); - - // convert it to a Type 42 font - if ((ffTT = FoFiTrueType::load(fileName->getCString()))) { - codeToGID = ((Gfx8BitFont *)font)->getCodeToGIDMap(ffTT); - ffTT->convertToType42(psName->getCString(), - ((Gfx8BitFont *)font)->getHasEncoding() - ? ((Gfx8BitFont *)font)->getEncoding() - : (char **)NULL, - codeToGID, outputFunc, outputStream); - if (codeToGID) { - if (font8InfoLen >= font8InfoSize) { - font8InfoSize += 16; - font8Info = (PSFont8Info *)greallocn(font8Info, - font8InfoSize, - sizeof(PSFont8Info)); - } - font8Info[font8InfoLen].fontID = *font->getID(); - font8Info[font8InfoLen].codeToGID = codeToGID; - ++font8InfoLen; - } - delete ffTT; - } - - // ending comment - writePS("%%EndResource\n"); -} - -void PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont *font, - GooString *fileName, - GooString *psName, - GBool needVerticalMetrics) { - FoFiTrueType *ffTT; - int *codeToGID; - int codeToGIDLen; - - // beginning comment - writePSFmt("%%BeginResource: font {0:t}\n", psName); - embFontList->append("%%+ font "); - embFontList->append(psName->getCString()); - embFontList->append("\n"); - - // convert it to a Type 0 font - //~ this should use fontNum to load the correct font - if ((ffTT = FoFiTrueType::load(fileName->getCString()))) { - - // check for embedding permission - if (ffTT->getEmbeddingRights() >= 1) { - codeToGID = NULL; - codeToGIDLen = 0; - if (((GfxCIDFont *)font)->getCIDToGID()) { - codeToGIDLen = ((GfxCIDFont *)font)->getCIDToGIDLen(); - if (codeToGIDLen) { - codeToGID = (int *)gmallocn(codeToGIDLen, sizeof(int)); - memcpy(codeToGID, ((GfxCIDFont *)font)->getCIDToGID(), - codeToGIDLen * sizeof(int)); - } - } else { - codeToGID = ((GfxCIDFont *)font)->getCodeToGIDMap(ffTT, &codeToGIDLen); - } - if (ffTT->isOpenTypeCFF()) { - ffTT->convertToCIDType0(psName->getCString(), - codeToGID, codeToGIDLen, - outputFunc, outputStream); - } else if (globalParams->getPSLevel() >= psLevel3) { - // Level 3: use a CID font - ffTT->convertToCIDType2(psName->getCString(), - codeToGID, codeToGIDLen, - needVerticalMetrics, - outputFunc, outputStream); - } else { - // otherwise: use a non-CID composite font - ffTT->convertToType0(psName->getCString(), - codeToGID, codeToGIDLen, - needVerticalMetrics, - outputFunc, outputStream); - } - gfree(codeToGID); - } else { - error(errSyntaxError, -1, - "TrueType font '{0:s}' does not allow embedding", - font->getName() ? font->getName()->getCString() : "(unnamed)"); - - } - delete ffTT; - } - - // ending comment - writePS("%%EndResource\n"); -} - -void PSOutputDev::setupEmbeddedCIDType0Font(GfxFont *font, Ref *id, - GooString *psName) { - char *fontBuf; - int fontLen; - FoFiType1C *ffT1C; - int i; - - // check if font is already embedded - for (i = 0; i < t1FontNameLen; ++i) { - if (t1FontNames[i].fontFileID.num == id->num && - t1FontNames[i].fontFileID.gen == id->gen) { - psName->clear(); - psName->insert(0, t1FontNames[i].psName); - return; - } - } - if (t1FontNameLen == t1FontNameSize) { - t1FontNameSize *= 2; - t1FontNames = (PST1FontName *)greallocn(t1FontNames, t1FontNameSize, - sizeof(PST1FontName)); - } - t1FontNames[t1FontNameLen].fontFileID = *id; - t1FontNames[t1FontNameLen].psName = psName->copy(); - ++t1FontNameLen; - - // beginning comment - writePSFmt("%%BeginResource: font {0:t}\n", psName); - embFontList->append("%%+ font "); - embFontList->append(psName->getCString()); - embFontList->append("\n"); - - // convert it to a Type 0 font - if ((fontBuf = font->readEmbFontFile(xref, &fontLen))) { - if ((ffT1C = FoFiType1C::make(fontBuf, fontLen))) { - if (globalParams->getPSLevel() >= psLevel3) { - // Level 3: use a CID font - ffT1C->convertToCIDType0(psName->getCString(), NULL, 0, - outputFunc, outputStream); - } else { - // otherwise: use a non-CID composite font - ffT1C->convertToType0(psName->getCString(), NULL, 0, - outputFunc, outputStream); - } - delete ffT1C; - } - gfree(fontBuf); - } - - // ending comment - writePS("%%EndResource\n"); -} - -void PSOutputDev::setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id, - GooString *psName, - GBool needVerticalMetrics) { - char *fontBuf; - int fontLen; - FoFiTrueType *ffTT; - - // beginning comment - writePSFmt("%%BeginResource: font {0:t}\n", psName); - embFontList->append("%%+ font "); - embFontList->append(psName->getCString()); - embFontList->append("\n"); - - // convert it to a Type 0 font - if ((fontBuf = font->readEmbFontFile(xref, &fontLen))) { - if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) { - if (globalParams->getPSLevel() >= psLevel3) { - // Level 3: use a CID font - ffTT->convertToCIDType2(psName->getCString(), - ((GfxCIDFont *)font)->getCIDToGID(), - ((GfxCIDFont *)font)->getCIDToGIDLen(), - needVerticalMetrics, - outputFunc, outputStream); - } else { - // otherwise: use a non-CID composite font - ffTT->convertToType0(psName->getCString(), - ((GfxCIDFont *)font)->getCIDToGID(), - ((GfxCIDFont *)font)->getCIDToGIDLen(), - needVerticalMetrics, - outputFunc, outputStream); - } - delete ffTT; - } - gfree(fontBuf); - } - - // ending comment - writePS("%%EndResource\n"); -} - -void PSOutputDev::setupEmbeddedOpenTypeCFFFont(GfxFont *font, Ref *id, - GooString *psName) { - char *fontBuf; - int fontLen; - FoFiTrueType *ffTT; - int i; - - // check if font is already embedded - for (i = 0; i < t1FontNameLen; ++i) { - if (t1FontNames[i].fontFileID.num == id->num && - t1FontNames[i].fontFileID.gen == id->gen) { - psName->clear(); - psName->insert(0, t1FontNames[i].psName); - return; - } - } - if (t1FontNameLen == t1FontNameSize) { - t1FontNameSize *= 2; - t1FontNames = (PST1FontName *)greallocn(t1FontNames, t1FontNameSize, - sizeof(PST1FontName)); - } - t1FontNames[t1FontNameLen].fontFileID = *id; - t1FontNames[t1FontNameLen].psName = psName->copy(); - ++t1FontNameLen; - - // beginning comment - writePSFmt("%%BeginResource: font {0:t}\n", psName); - embFontList->append("%%+ font "); - embFontList->append(psName->getCString()); - embFontList->append("\n"); - - // convert it to a Type 0 font - if ((fontBuf = font->readEmbFontFile(xref, &fontLen))) { - if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) { - if (ffTT->isOpenTypeCFF()) { - if (globalParams->getPSLevel() >= psLevel3) { - // Level 3: use a CID font - ffTT->convertToCIDType0(psName->getCString(), - ((GfxCIDFont *)font)->getCIDToGID(), - ((GfxCIDFont *)font)->getCIDToGIDLen(), - outputFunc, outputStream); - } else { - // otherwise: use a non-CID composite font - ffTT->convertToType0(psName->getCString(), - ((GfxCIDFont *)font)->getCIDToGID(), - ((GfxCIDFont *)font)->getCIDToGIDLen(), - outputFunc, outputStream); - } - } - delete ffTT; - } - gfree(fontBuf); - } - - // ending comment - writePS("%%EndResource\n"); -} - -void PSOutputDev::setupType3Font(GfxFont *font, GooString *psName, - Dict *parentResDict) { - Dict *resDict; - Dict *charProcs; - Object charProc; - Gfx *gfx; - PDFRectangle box; - double *m; - GooString *buf; - int i; - - // set up resources used by font - if ((resDict = ((Gfx8BitFont *)font)->getResources())) { - inType3Char = gTrue; - setupResources(resDict); - inType3Char = gFalse; - } else { - resDict = parentResDict; - } - - // beginning comment - writePSFmt("%%BeginResource: font {0:t}\n", psName); - embFontList->append("%%+ font "); - embFontList->append(psName->getCString()); - embFontList->append("\n"); - - // font dictionary - writePS("8 dict begin\n"); - writePS("/FontType 3 def\n"); - m = font->getFontMatrix(); - writePSFmt("/FontMatrix [{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g}] def\n", - m[0], m[1], m[2], m[3], m[4], m[5]); - m = font->getFontBBox(); - writePSFmt("/FontBBox [{0:.6g} {1:.6g} {2:.6g} {3:.6g}] def\n", - m[0], m[1], m[2], m[3]); - writePS("/Encoding 256 array def\n"); - writePS(" 0 1 255 { Encoding exch /.notdef put } for\n"); - writePS("/BuildGlyph {\n"); - writePS(" exch /CharProcs get exch\n"); - writePS(" 2 copy known not { pop /.notdef } if\n"); - writePS(" get exec\n"); - writePS("} bind def\n"); - writePS("/BuildChar {\n"); - writePS(" 1 index /Encoding get exch get\n"); - writePS(" 1 index /BuildGlyph get exec\n"); - writePS("} bind def\n"); - if ((charProcs = ((Gfx8BitFont *)font)->getCharProcs())) { - writePSFmt("/CharProcs {0:d} dict def\n", charProcs->getLength()); - writePS("CharProcs begin\n"); - box.x1 = m[0]; - box.y1 = m[1]; - box.x2 = m[2]; - box.y2 = m[3]; - gfx = new Gfx(doc, this, resDict, &box, NULL); - inType3Char = gTrue; - for (i = 0; i < charProcs->getLength(); ++i) { - t3FillColorOnly = gFalse; - t3Cacheable = gFalse; - t3NeedsRestore = gFalse; - writePS("/"); - writePSName(charProcs->getKey(i)); - writePS(" {\n"); - gfx->display(charProcs->getVal(i, &charProc)); - charProc.free(); - if (t3String) { - if (t3Cacheable) { - buf = GooString::format("{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g} setcachedevice\n", - t3WX, t3WY, t3LLX, t3LLY, t3URX, t3URY); - } else { - buf = GooString::format("{0:.6g} {1:.6g} setcharwidth\n", t3WX, t3WY); - } - (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); - delete buf; - (*outputFunc)(outputStream, t3String->getCString(), - t3String->getLength()); - delete t3String; - t3String = NULL; - } - if (t3NeedsRestore) { - (*outputFunc)(outputStream, "Q\n", 2); - } - writePS("} def\n"); - } - inType3Char = gFalse; - delete gfx; - writePS("end\n"); - } - writePS("currentdict end\n"); - writePSFmt("/{0:t} exch definefont pop\n", psName); - - // ending comment - writePS("%%EndResource\n"); -} - -// Make a unique PS font name, based on the names given in the PDF -// font object, and an object ID (font file object for -GooString *PSOutputDev::makePSFontName(GfxFont *font, Ref *id) { - GooString *psName, *s; - - if ((s = font->getEmbeddedFontName())) { - psName = filterPSName(s); - if (!fontNames->lookupInt(psName)) { - fontNames->add(psName->copy(), 1); - return psName; - } - delete psName; - } - if ((s = font->getName())) { - psName = filterPSName(s); - if (!fontNames->lookupInt(psName)) { - fontNames->add(psName->copy(), 1); - return psName; - } - delete psName; - } - psName = GooString::format("FF{0:d}_{1:d}", id->num, id->gen); - if ((s = font->getEmbeddedFontName())) { - s = filterPSName(s); - psName->append('_')->append(s); - delete s; - } else if ((s = font->getName())) { - s = filterPSName(s); - psName->append('_')->append(s); - delete s; - } - fontNames->add(psName->copy(), 1); - return psName; -} - -void PSOutputDev::setupImages(Dict *resDict) { - Object xObjDict, xObj, xObjRef, subtypeObj, maskObj, maskRef; - Ref imgID; - int i, j; - - if (!(mode == psModeForm || inType3Char || preloadImagesForms)) { - return; - } - - //----- recursively scan XObjects - resDict->lookup("XObject", &xObjDict); - if (xObjDict.isDict()) { - for (i = 0; i < xObjDict.dictGetLength(); ++i) { - xObjDict.dictGetValNF(i, &xObjRef); - xObjDict.dictGetVal(i, &xObj); - if (xObj.isStream()) { - xObj.streamGetDict()->lookup("Subtype", &subtypeObj); - if (subtypeObj.isName("Image")) { - if (xObjRef.isRef()) { - imgID = xObjRef.getRef(); - for (j = 0; j < imgIDLen; ++j) { - if (imgIDs[j].num == imgID.num && imgIDs[j].gen == imgID.gen) { - break; - } - } - if (j == imgIDLen) { - if (imgIDLen >= imgIDSize) { - if (imgIDSize == 0) { - imgIDSize = 64; - } else { - imgIDSize *= 2; - } - imgIDs = (Ref *)greallocn(imgIDs, imgIDSize, sizeof(Ref)); - } - imgIDs[imgIDLen++] = imgID; - setupImage(imgID, xObj.getStream(), gFalse); - if (level >= psLevel3 && - xObj.streamGetDict()->lookup("Mask", &maskObj)->isStream()) { - setupImage(imgID, maskObj.getStream(), gTrue); - } - maskObj.free(); - } - } else { - error(errSyntaxError, -1, - "Image in resource dict is not an indirect reference"); - } - } - subtypeObj.free(); - } - xObj.free(); - xObjRef.free(); - } - } - xObjDict.free(); -} - -void PSOutputDev::setupImage(Ref id, Stream *str, GBool mask) { - GBool useRLE, useCompressed, doUseASCIIHex; - GooString *s; - int c; - int size, line, col, i; - int outerSize, outer; - - // filters - //~ this does not correctly handle the DeviceN color space - //~ -- need to use DeviceNRecoder - if (level < psLevel2) { - useRLE = gFalse; - useCompressed = gFalse; - doUseASCIIHex = gTrue; - } else { - if (uncompressPreloadedImages) { - useRLE = gFalse; - useCompressed = gFalse; - } else { - s = str->getPSFilter(level < psLevel3 ? 2 : 3, ""); - if (s) { - useRLE = gFalse; - useCompressed = gTrue; - delete s; - } else { - useRLE = gTrue; - useCompressed = gFalse; - } - } - doUseASCIIHex = useASCIIHex; - } - if (useCompressed) { - str = str->getUndecodedStream(); - } - if (useRLE) { - str = new RunLengthEncoder(str); - } - if (doUseASCIIHex) { - str = new ASCIIHexEncoder(str); - } else { - str = new ASCII85Encoder(str); - } - - // compute image data size - str->reset(); - col = size = 0; - do { - do { - c = str->getChar(); - } while (c == '\n' || c == '\r'); - if (c == (doUseASCIIHex ? '>' : '~') || c == EOF) { - break; - } - if (c == 'z') { - ++col; - } else { - ++col; - for (i = 1; i <= (doUseASCIIHex ? 1 : 4); ++i) { - do { - c = str->getChar(); - } while (c == '\n' || c == '\r'); - if (c == (doUseASCIIHex ? '>' : '~') || c == EOF) { - break; - } - ++col; - } - if (c == (doUseASCIIHex ? '>' : '~') || c == EOF) { - break; - } - } - if (col > 225) { - ++size; - col = 0; - } - } while (c != (doUseASCIIHex ? '>' : '~') && c != EOF); - // add one entry for the final line of data; add another entry - // because the RunLengthDecode filter may read past the end - ++size; - if (useRLE) { - ++size; - } - outerSize = size/65535 + 1; - - writePSFmt("{0:d} array dup /{1:s}Data_{2:d}_{3:d} exch def\n", - outerSize, mask ? "Mask" : "Im", id.num, id.gen); - str->close(); - - // write the data into the array - str->reset(); - for (outer = 0;outer < outerSize;outer++) { - int innerSize = size > 65535 ? 65535 : size; - - // put the inner array into the outer array - writePSFmt("{0:d} array 1 index {1:d} 2 index put\n", - innerSize, outer); - line = col = 0; - writePS((char *)(doUseASCIIHex ? "dup 0 <" : "dup 0 <~")); - for (;;) { - do { - c = str->getChar(); - } while (c == '\n' || c == '\r'); - if (c == (doUseASCIIHex ? '>' : '~') || c == EOF) { - break; - } - if (c == 'z') { - writePSChar(c); - ++col; - } else { - writePSChar(c); - ++col; - for (i = 1; i <= (doUseASCIIHex ? 1 : 4); ++i) { - do { - c = str->getChar(); - } while (c == '\n' || c == '\r'); - if (c == (doUseASCIIHex ? '>' : '~') || c == EOF) { - break; - } - writePSChar(c); - ++col; - } - } - if (c == (doUseASCIIHex ? '>' : '~') || c == EOF) { - break; - } - // each line is: "dup nnnnn <~...data...~> put<eol>" - // so max data length = 255 - 20 = 235 - // chunks are 1 or 4 bytes each, so we have to stop at 232 - // but make it 225 just to be safe - if (col > 225) { - writePS((char *)(doUseASCIIHex ? "> put\n" : "~> put\n")); - ++line; - if (line >= innerSize) break; - writePSFmt((char *)(doUseASCIIHex ? "dup {0:d} <" : "dup {0:d} <~"), line); - col = 0; - } - } - if (c == (doUseASCIIHex ? '>' : '~') || c == EOF) { - writePS((char *)(doUseASCIIHex ? "> put\n" : "~> put\n")); - if (useRLE) { - ++line; - writePSFmt("{0:d} <> put\n", line); - } else { - writePS("pop\n"); - } - break; - } - writePS("pop\n"); - size -= innerSize; - } - writePS("pop\n"); - str->close(); - - delete str; -} - -void PSOutputDev::setupForms(Dict *resDict) { - Object xObjDict, xObj, xObjRef, subtypeObj; - int i; - - if (!preloadImagesForms) { - return; - } - - resDict->lookup("XObject", &xObjDict); - if (xObjDict.isDict()) { - for (i = 0; i < xObjDict.dictGetLength(); ++i) { - xObjDict.dictGetValNF(i, &xObjRef); - xObjDict.dictGetVal(i, &xObj); - if (xObj.isStream()) { - xObj.streamGetDict()->lookup("Subtype", &subtypeObj); - if (subtypeObj.isName("Form")) { - if (xObjRef.isRef()) { - setupForm(xObjRef.getRef(), &xObj); - } else { - error(errSyntaxError, -1, - "Form in resource dict is not an indirect reference"); - } - } - subtypeObj.free(); - } - xObj.free(); - xObjRef.free(); - } - } - xObjDict.free(); -} - -void PSOutputDev::setupForm(Ref id, Object *strObj) { - Dict *dict, *resDict; - Object matrixObj, bboxObj, resObj, obj1; - double m[6], bbox[4]; - PDFRectangle box; - Gfx *gfx; - int i; - - // check if form is already defined - for (i = 0; i < formIDLen; ++i) { - if (formIDs[i].num == id.num && formIDs[i].gen == id.gen) { - return; - } - } - - // add entry to formIDs list - if (formIDLen >= formIDSize) { - if (formIDSize == 0) { - formIDSize = 64; - } else { - formIDSize *= 2; - } - formIDs = (Ref *)greallocn(formIDs, formIDSize, sizeof(Ref)); - } - formIDs[formIDLen++] = id; - - dict = strObj->streamGetDict(); - - // get bounding box - dict->lookup("BBox", &bboxObj); - if (!bboxObj.isArray()) { - bboxObj.free(); - error(errSyntaxError, -1, "Bad form bounding box"); - return; - } - for (i = 0; i < 4; ++i) { - bboxObj.arrayGet(i, &obj1); - bbox[i] = obj1.getNum(); - obj1.free(); - } - bboxObj.free(); - - // get matrix - dict->lookup("Matrix", &matrixObj); - if (matrixObj.isArray()) { - for (i = 0; i < 6; ++i) { - matrixObj.arrayGet(i, &obj1); - m[i] = obj1.getNum(); - obj1.free(); - } - } else { - m[0] = 1; m[1] = 0; - m[2] = 0; m[3] = 1; - m[4] = 0; m[5] = 0; - } - matrixObj.free(); - - // get resources - dict->lookup("Resources", &resObj); - resDict = resObj.isDict() ? resObj.getDict() : (Dict *)NULL; - - writePSFmt("/f_{0:d}_{1:d} {{\n", id.num, id.gen); - writePS("q\n"); - writePSFmt("[{0:.6gs} {1:.6gs} {2:.6gs} {3:.6gs} {4:.6gs} {5:.6gs}] cm\n", - m[0], m[1], m[2], m[3], m[4], m[5]); - - box.x1 = bbox[0]; - box.y1 = bbox[1]; - box.x2 = bbox[2]; - box.y2 = bbox[3]; - gfx = new Gfx(doc, this, resDict, &box, &box); - gfx->display(strObj); - delete gfx; - - writePS("Q\n"); - writePS("} def\n"); - - resObj.free(); -} - -GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, - int rotateA, GBool useMediaBox, GBool crop, - int sliceX, int sliceY, - int sliceW, int sliceH, - GBool printing, - GBool (*abortCheckCbk)(void *data), - void *abortCheckCbkData, - GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data), - void *annotDisplayDecideCbkData) { - PreScanOutputDev *scan; - GBool rasterize; -#if HAVE_SPLASH - SplashOutputDev *splashOut; - SplashColor paperColor; - PDFRectangle box; - GfxState *state; - SplashBitmap *bitmap; - Stream *str0, *str; - Object obj; - Guchar *p; - Guchar col[4]; - double hDPI2, vDPI2; - double m0, m1, m2, m3, m4, m5; - int nStripes, stripeH, stripeY; - int c, w, h, x, y, comp, i; - int numComps, initialNumComps; -#endif - char hexBuf[32*2 + 2]; // 32 values X 2 chars/value + line ending + null - Guchar digit; - GBool isGray; - - if (forceRasterize) { - rasterize = gTrue; - } else { - scan = new PreScanOutputDev(doc); - page->displaySlice(scan, 72, 72, rotateA, useMediaBox, crop, - sliceX, sliceY, sliceW, sliceH, - printing, abortCheckCbk, abortCheckCbkData, - annotDisplayDecideCbk, annotDisplayDecideCbkData); - rasterize = scan->usesTransparency() || scan->usesPatternImageMask(); - delete scan; - } - if (!rasterize) { - return gTrue; - } - -#if HAVE_SPLASH - // start the PS page - page->makeBox(rasterResolution, rasterResolution, rotateA, useMediaBox, gFalse, - sliceX, sliceY, sliceW, sliceH, &box, &crop); - rotateA += page->getRotate(); - if (rotateA >= 360) { - rotateA -= 360; - } else if (rotateA < 0) { - rotateA += 360; - } - state = new GfxState(rasterResolution, rasterResolution, &box, rotateA, gFalse); - startPage(page->getNum(), state, xref); - delete state; - - // set up the SplashOutputDev - if (rasterMono || level == psLevel1) { - numComps = 1; - paperColor[0] = 0xff; - splashOut = new SplashOutputDev(splashModeMono8, 1, gFalse, - paperColor, gFalse); -#if SPLASH_CMYK - } else if (level == psLevel1Sep || level == psLevel2Sep || - level == psLevel3Sep || globalParams->getOverprintPreview()) { - numComps = 4; - paperColor[0] = paperColor[1] = paperColor[2] = paperColor[3] = 0; - splashOut = new SplashOutputDev(splashModeCMYK8, 1, gFalse, - paperColor, gFalse); -#endif - } else { - numComps = 3; - paperColor[0] = paperColor[1] = paperColor[2] = 0xff; - splashOut = new SplashOutputDev(splashModeRGB8, 1, gFalse, - paperColor, gFalse); - } - splashOut->setFontAntialias(rasterAntialias); - splashOut->setVectorAntialias(rasterAntialias); - splashOut->startDoc(doc); - - // break the page into stripes - hDPI2 = xScale * rasterResolution; - vDPI2 = yScale * rasterResolution; - if (sliceW < 0 || sliceH < 0) { - if (useMediaBox) { - box = *page->getMediaBox(); - } else { - box = *page->getCropBox(); - } - sliceX = sliceY = 0; - sliceW = (int)((box.x2 - box.x1) * hDPI2 / 72.0); - sliceH = (int)((box.y2 - box.y1) * vDPI2 / 72.0); - } - nStripes = (int)ceil((double)(sliceW * sliceH) / - (double)rasterizationSliceSize); - stripeH = (sliceH + nStripes - 1) / nStripes; - - // render the stripes - initialNumComps = numComps; - for (stripeY = sliceY; stripeY < sliceH; stripeY += stripeH) { - - // rasterize a stripe - page->makeBox(hDPI2, vDPI2, 0, useMediaBox, gFalse, - sliceX, stripeY, sliceW, stripeH, &box, &crop); - m0 = box.x2 - box.x1; - m1 = 0; - m2 = 0; - m3 = box.y2 - box.y1; - m4 = box.x1; - m5 = box.y1; - page->displaySlice(splashOut, hDPI2, vDPI2, - (360 - page->getRotate()) % 360, useMediaBox, crop, - sliceX, stripeY, sliceW, stripeH, - printing, abortCheckCbk, abortCheckCbkData, - annotDisplayDecideCbk, annotDisplayDecideCbkData); - - // draw the rasterized image - bitmap = splashOut->getBitmap(); - numComps = initialNumComps; - w = bitmap->getWidth(); - h = bitmap->getHeight(); - writePS("gsave\n"); - writePSFmt("[{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g}] concat\n", - m0, m1, m2, m3, m4, m5); - switch (level) { - case psLevel1: - writePSFmt("{0:d} {1:d} 8 [{2:d} 0 0 {3:d} 0 {4:d}] pdfIm1{5:s}\n", - w, h, w, -h, h, - useBinary ? "Bin" : ""); - p = bitmap->getDataPtr() + (h - 1) * bitmap->getRowSize(); - i = 0; - if (useBinary) { - for (y = 0; y < h; ++y) { - for (x = 0; x < w; ++x) { - hexBuf[i++] = *p++; - if (i >= 64) { - writePSBuf(hexBuf, i); - i = 0; - } - } - } - } else { - for (y = 0; y < h; ++y) { - for (x = 0; x < w; ++x) { - digit = *p / 16; - hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); - digit = *p++ % 16; - hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); - if (i >= 64) { - hexBuf[i++] = '\n'; - writePSBuf(hexBuf, i); - i = 0; - } - } - } - } - if (i != 0) { - if (!useBinary) { - hexBuf[i++] = '\n'; - } - writePSBuf(hexBuf, i); - } - break; - case psLevel1Sep: - p = bitmap->getDataPtr(); - // Check for an all gray image - if (getOptimizeColorSpace()) { - isGray = gTrue; - for (y = 0; y < h; ++y) { - for (x = 0; x < w; ++x) { - if (p[4*x] != p[4*x + 1] || p[4*x] != p[4*x + 2]) { - isGray = gFalse; - y = h; - break; - } - } - p += bitmap->getRowSize(); - } - } else { - isGray = gFalse; - } - writePSFmt("{0:d} {1:d} 8 [{2:d} 0 0 {3:d} 0 {4:d}] pdfIm1{5:s}{6:s}\n", - w, h, w, -h, h, - isGray ? "" : "Sep", - useBinary ? "Bin" : ""); - p = bitmap->getDataPtr() + (h - 1) * bitmap->getRowSize(); - i = 0; - col[0] = col[1] = col[2] = col[3] = 0; - if (isGray) { - int g; - if ((psProcessBlack & processColors) == 0) { - // Check if the image uses black - for (y = 0; y < h; ++y) { - for (x = 0; x < w; ++x) { - if (p[4*x] > 0 || p[4*x + 3] > 0) { - col[3] = 1; - y = h; - break; - } - } - p -= bitmap->getRowSize(); - } - p = bitmap->getDataPtr() + (h - 1) * bitmap->getRowSize(); - } - for (y = 0; y < h; ++y) { - if (useBinary) { - // Binary gray image - for (x = 0; x < w; ++x) { - g = p[4*x] + p[4*x + 3]; - g = 255 - g; - if (g < 0) g = 0; - hexBuf[i++] = (Guchar) g; - if (i >= 64) { - writePSBuf(hexBuf, i); - i = 0; - } - } - } else { - // Hex gray image - for (x = 0; x < w; ++x) { - g = p[4*x] + p[4*x + 3]; - g = 255 - g; - if (g < 0) g = 0; - digit = g / 16; - hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); - digit = g % 16; - hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); - if (i >= 64) { - hexBuf[i++] = '\n'; - writePSBuf(hexBuf, i); - i = 0; - } - } - } - p -= bitmap->getRowSize(); - } - } else if (((psProcessCyan | psProcessMagenta | psProcessYellow | psProcessBlack) & ~processColors) != 0) { - // Color image, need to check color flags for each dot - for (y = 0; y < h; ++y) { - for (comp = 0; comp < 4; ++comp) { - if (useBinary) { - // Binary color image - for (x = 0; x < w; ++x) { - col[comp] |= p[4*x + comp]; - hexBuf[i++] = p[4*x + comp]; - if (i >= 64) { - writePSBuf(hexBuf, i); - i = 0; - } - } - } else { - // Gray color image - for (x = 0; x < w; ++x) { - col[comp] |= p[4*x + comp]; - digit = p[4*x + comp] / 16; - hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); - digit = p[4*x + comp] % 16; - hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); - if (i >= 64) { - hexBuf[i++] = '\n'; - writePSBuf(hexBuf, i); - i = 0; - } - } - } - } - p -= bitmap->getRowSize(); - } - } else { - // Color image, do not need to check color flags - for (y = 0; y < h; ++y) { - for (comp = 0; comp < 4; ++comp) { - if (useBinary) { - // Binary color image - for (x = 0; x < w; ++x) { - hexBuf[i++] = p[4*x + comp]; - if (i >= 64) { - writePSBuf(hexBuf, i); - i = 0; - } - } - } else { - // Hex color image - for (x = 0; x < w; ++x) { - digit = p[4*x + comp] / 16; - hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); - digit = p[4*x + comp] % 16; - hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); - if (i >= 64) { - hexBuf[i++] = '\n'; - writePSBuf(hexBuf, i); - i = 0; - } - } - } - } - p -= bitmap->getRowSize(); - } - } - if (i != 0) { - if (!useBinary) { - hexBuf[i++] = '\n'; - } - writePSBuf(hexBuf, i); - } - if (col[0]) { - processColors |= psProcessCyan; - } - if (col[1]) { - processColors |= psProcessMagenta; - } - if (col[2]) { - processColors |= psProcessYellow; - } - if (col[3]) { - processColors |= psProcessBlack; - } - break; - case psLevel2: - case psLevel2Sep: - case psLevel3: - case psLevel3Sep: - obj.initNull(); - p = bitmap->getDataPtr() + (h - 1) * bitmap->getRowSize(); - str0 = new MemStream((char *)p, 0, w * h * numComps, &obj); - // Check for a color image that uses only gray - if (!getOptimizeColorSpace()) { - isGray = gFalse; - } else if (numComps == 4) { - int compCyan; - isGray = gTrue; - while ((compCyan = str0->getChar()) != EOF) { - if (str0->getChar() != compCyan || - str0->getChar() != compCyan) { - isGray = gFalse; - break; - } - str0->getChar(); - } - } else if (numComps == 3) { - int compRed; - isGray = gTrue; - while ((compRed = str0->getChar()) != EOF) { - if (str0->getChar() != compRed || - str0->getChar() != compRed) { - isGray = gFalse; - break; - } - } - } else { - isGray = gFalse; - } - str0->reset(); - if (isGray && numComps == 4) { - str = new RunLengthEncoder(new CMYKGrayEncoder(str0)); - numComps = 1; - } else if (isGray && numComps == 3) { - str = new RunLengthEncoder(new RGBGrayEncoder(str0)); - numComps = 1; - } else { - str = new RunLengthEncoder(str0); - } - if (numComps == 1) { - writePS("/DeviceGray setcolorspace\n"); - } else if (numComps == 3) { - writePS("/DeviceRGB setcolorspace\n"); - } else { - writePS("/DeviceCMYK setcolorspace\n"); - } - writePS("<<\n /ImageType 1\n"); - writePSFmt(" /Width {0:d}\n", bitmap->getWidth()); - writePSFmt(" /Height {0:d}\n", bitmap->getHeight()); - writePSFmt(" /ImageMatrix [{0:d} 0 0 {1:d} 0 {2:d}]\n", w, -h, h); - writePS(" /BitsPerComponent 8\n"); - if (numComps == 1) { - writePS(" /Decode [1 0]\n"); - } else if (numComps == 3) { - writePS(" /Decode [0 1 0 1 0 1]\n"); - } else { - writePS(" /Decode [0 1 0 1 0 1 0 1]\n"); - } - writePS(" /DataSource currentfile\n"); - if (useBinary) { - /* nothing to do */; - } else if (useASCIIHex) { - writePS(" /ASCIIHexDecode filter\n"); - } else { - writePS(" /ASCII85Decode filter\n"); - } - writePS(" /RunLengthDecode filter\n"); - writePS(">>\n"); - if (useBinary) { - /* nothing to do */; - } else if (useASCIIHex) { - str = new ASCIIHexEncoder(str); - } else { - str = new ASCII85Encoder(str); - } - str->reset(); - if (useBinary) { - // Count the bytes to write a document comment - int len = 0; - while (str->getChar() != EOF) { - len++; - } - str->reset(); - writePSFmt("%%BeginData: {0:d} Binary Bytes\n", len+6+1); - } - writePS("image\n"); - while ((c = str->getChar()) != EOF) { - writePSChar(c); - } - str->close(); - delete str; - delete str0; - writePSChar('\n'); - if (useBinary) { - writePS("%%EndData\n"); - } - processColors |= (numComps == 1) ? psProcessBlack : psProcessCMYK; - break; - } - writePS("grestore\n"); - } - - delete splashOut; - - // finish the PS page - endPage(); - - return gFalse; - -#else // HAVE_SPLASH - - error(errSyntaxWarning, -1, - "PDF page uses transparency and PSOutputDev was built without" - " the Splash rasterizer - output may not be correct"); - return gTrue; -#endif // HAVE_SPLASH -} - -void PSOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) { - Page *page; - int x1, y1, x2, y2, width, height, t; - int imgWidth, imgHeight, imgWidth2, imgHeight2; - GBool landscape; - GooString *s; - PSOutPaperSize *paperSize; - - xref = xrefA; - if (mode == psModePS) { - GooString pageLabel; - const GBool gotLabel = doc->getCatalog()->indexToLabel(pageNum -1, &pageLabel); - if (gotLabel) { - // See bug13338 for why we try to avoid parentheses... - GBool needParens; - GooString *filteredString = filterPSLabel(&pageLabel, &needParens); - if (needParens) { - writePSFmt("%%Page: ({0:t}) {1:d}\n", filteredString, seqPage); - } else { - writePSFmt("%%Page: {0:t} {1:d}\n", filteredString, seqPage); - } - delete filteredString; - } else { - writePSFmt("%%Page: {0:d} {1:d}\n", pageNum, seqPage); - } - if (paperMatch) { - page = doc->getCatalog()->getPage(pageNum); - imgLLX = imgLLY = 0; - if (noCrop) { - imgURX = (int)ceil(page->getMediaWidth()); - imgURY = (int)ceil(page->getMediaHeight()); - } else { - imgURX = (int)ceil(page->getCropWidth()); - imgURY = (int)ceil(page->getCropHeight()); - } - if (state->getRotate() == 90 || state->getRotate() == 270) { - t = imgURX; - imgURX = imgURY; - imgURY = t; - } - } - } - - // underlays - if (underlayCbk) { - (*underlayCbk)(this, underlayCbkData); - } - if (overlayCbk) { - saveState(NULL); - } - - xScale = yScale = 1; - switch (mode) { - - case psModePS: - // rotate, translate, and scale page - imgWidth = imgURX - imgLLX; - imgHeight = imgURY - imgLLY; - x1 = (int)floor(state->getX1()); - y1 = (int)floor(state->getY1()); - x2 = (int)ceil(state->getX2()); - y2 = (int)ceil(state->getY2()); - width = x2 - x1; - height = y2 - y1; - tx = ty = 0; - // rotation and portrait/landscape mode - if (paperMatch) { - rotate = (360 - state->getRotate()) % 360; - landscape = gFalse; - } else if (rotate0 >= 0) { - rotate = (360 - rotate0) % 360; - landscape = gFalse; - } else { - rotate = (360 - state->getRotate()) % 360; - if (rotate == 0 || rotate == 180) { - if ((width < height && imgWidth > imgHeight && height > imgHeight) || - (width > height && imgWidth < imgHeight && width > imgWidth)) { - rotate += 90; - landscape = gTrue; - } else { - landscape = gFalse; - } - } else { // rotate == 90 || rotate == 270 - if ((height < width && imgWidth > imgHeight && width > imgHeight) || - (height > width && imgWidth < imgHeight && height > imgWidth)) { - rotate = 270 - rotate; - landscape = gTrue; - } else { - landscape = gFalse; - } - } - } - if (paperMatch) { - paperSize = (PSOutPaperSize *)paperSizes->get(pagePaperSize[pageNum]); - writePSFmt("%%PageMedia: {0:t}\n", paperSize->name); - } - if (rotate == 0 || rotate == 180) { - writePSFmt("%%PageBoundingBox: 0 0 {0:d} {1:d}\n", width, height); - } else { - writePSFmt("%%PageBoundingBox: 0 0 {0:d} {1:d}\n", height, width); - } - writePSFmt("%%PageOrientation: {0:s}\n", - landscape ? "Landscape" : "Portrait"); - writePS("%%BeginPageSetup\n"); - if (paperMatch) { - writePSFmt("{0:d} {1:d} pdfSetupPaper\n", imgURX, imgURY); - } - writePS("pdfStartPage\n"); - if (rotate == 0) { - imgWidth2 = imgWidth; - imgHeight2 = imgHeight; - } else if (rotate == 90) { - writePS("90 rotate\n"); - ty = -imgWidth; - imgWidth2 = imgHeight; - imgHeight2 = imgWidth; - } else if (rotate == 180) { - writePS("180 rotate\n"); - imgWidth2 = imgWidth; - imgHeight2 = imgHeight; - tx = -imgWidth; - ty = -imgHeight; - } else { // rotate == 270 - writePS("270 rotate\n"); - tx = -imgHeight; - imgWidth2 = imgHeight; - imgHeight2 = imgWidth; - } - // shrink or expand - if (xScale0 > 0 && yScale0 > 0) { - xScale = xScale0; - yScale = yScale0; - } else if ((globalParams->getPSShrinkLarger() && - (width > imgWidth2 || height > imgHeight2)) || - (globalParams->getPSExpandSmaller() && - (width < imgWidth2 && height < imgHeight2))) { - xScale = (double)imgWidth2 / (double)width; - yScale = (double)imgHeight2 / (double)height; - if (yScale < xScale) { - xScale = yScale; - } else { - yScale = xScale; - } - } - // deal with odd bounding boxes or clipping - if (clipLLX0 < clipURX0 && clipLLY0 < clipURY0) { - tx -= xScale * clipLLX0; - ty -= yScale * clipLLY0; - } else { - tx -= xScale * x1; - ty -= yScale * y1; - } - // center - if (tx0 >= 0 && ty0 >= 0) { - tx += (rotate == 0 || rotate == 180) ? tx0 : ty0; - ty += (rotate == 0 || rotate == 180) ? ty0 : -tx0; - } else if (globalParams->getPSCenter()) { - if (clipLLX0 < clipURX0 && clipLLY0 < clipURY0) { - tx += (imgWidth2 - xScale * (clipURX0 - clipLLX0)) / 2; - ty += (imgHeight2 - yScale * (clipURY0 - clipLLY0)) / 2; - } else { - tx += (imgWidth2 - xScale * width) / 2; - ty += (imgHeight2 - yScale * height) / 2; - } - } - tx += (rotate == 0 || rotate == 180) ? imgLLX : imgLLY; - ty += (rotate == 0 || rotate == 180) ? imgLLY : -imgLLX; - if (tx != 0 || ty != 0) { - writePSFmt("{0:.6g} {1:.6g} translate\n", tx, ty); - } - if (xScale != 1 || yScale != 1) { - writePSFmt("{0:.6f} {1:.6f} scale\n", xScale, yScale); - } - if (clipLLX0 < clipURX0 && clipLLY0 < clipURY0) { - writePSFmt("{0:.6g} {1:.6g} {2:.6g} {3:.6g} re W\n", - clipLLX0, clipLLY0, clipURX0 - clipLLX0, clipURY0 - clipLLY0); - } else { - writePSFmt("{0:d} {1:d} {2:d} {3:d} re W\n", x1, y1, x2 - x1, y2 - y1); - } - - ++seqPage; - break; - - case psModeEPS: - writePS("pdfStartPage\n"); - tx = ty = 0; - rotate = (360 - state->getRotate()) % 360; - if (rotate == 0) { - } else if (rotate == 90) { - writePS("90 rotate\n"); - tx = -epsX1; - ty = -epsY2; - } else if (rotate == 180) { - writePS("180 rotate\n"); - tx = -(epsX1 + epsX2); - ty = -(epsY1 + epsY2); - } else { // rotate == 270 - writePS("270 rotate\n"); - tx = -epsX2; - ty = -epsY1; - } - if (tx != 0 || ty != 0) { - writePSFmt("{0:.6g} {1:.6g} translate\n", tx, ty); - } - break; - - case psModeForm: - writePS("/PaintProc {\n"); - writePS("begin xpdf begin\n"); - writePS("pdfStartPage\n"); - tx = ty = 0; - rotate = 0; - break; - } - - if (customCodeCbk) { - if ((s = (*customCodeCbk)(this, psOutCustomPageSetup, pageNum, - customCodeCbkData))) { - writePS(s->getCString()); - delete s; - } - } - - writePS("%%EndPageSetup\n"); -} - -void PSOutputDev::endPage() { - if (overlayCbk) { - restoreState(NULL); - (*overlayCbk)(this, overlayCbkData); - } - - - if (mode == psModeForm) { - writePS("pdfEndPage\n"); - writePS("end end\n"); - writePS("} def\n"); - writePS("end end\n"); - } else { - if (!manualCtrl) { - writePS("showpage\n"); - } - writePS("%%PageTrailer\n"); - writePageTrailer(); - } -} - -void PSOutputDev::saveState(GfxState *state) { - writePS("q\n"); - ++numSaves; -} - -void PSOutputDev::restoreState(GfxState *state) { - writePS("Q\n"); - --numSaves; -} - -void PSOutputDev::updateCTM(GfxState *state, double m11, double m12, - double m21, double m22, double m31, double m32) { - writePSFmt("[{0:.6gs} {1:.6gs} {2:.6gs} {3:.6gs} {4:.6gs} {5:.6gs}] cm\n", - m11, m12, m21, m22, m31, m32); -} - -void PSOutputDev::updateLineDash(GfxState *state) { - double *dash; - double start; - int length, i; - - state->getLineDash(&dash, &length, &start); - writePS("["); - for (i = 0; i < length; ++i) { - writePSFmt("{0:.6g}{1:w}", - dash[i] < 0 ? 0 : dash[i], - (i == length-1) ? 0 : 1); - } - writePSFmt("] {0:.6g} d\n", start); -} - -void PSOutputDev::updateFlatness(GfxState *state) { - writePSFmt("{0:d} i\n", state->getFlatness()); -} - -void PSOutputDev::updateLineJoin(GfxState *state) { - writePSFmt("{0:d} j\n", state->getLineJoin()); -} - -void PSOutputDev::updateLineCap(GfxState *state) { - writePSFmt("{0:d} J\n", state->getLineCap()); -} - -void PSOutputDev::updateMiterLimit(GfxState *state) { - writePSFmt("{0:.6g} M\n", state->getMiterLimit()); -} - -void PSOutputDev::updateLineWidth(GfxState *state) { - writePSFmt("{0:.6g} w\n", state->getLineWidth()); -} - -void PSOutputDev::updateFillColorSpace(GfxState *state) { - if (inUncoloredPattern) { - return; - } - switch (level) { - case psLevel1: - case psLevel1Sep: - break; - case psLevel2: - case psLevel3: - if (state->getFillColorSpace()->getMode() != csPattern) { - dumpColorSpaceL2(state->getFillColorSpace(), gTrue, gFalse, gFalse); - writePS(" cs\n"); - } - break; - case psLevel2Sep: - case psLevel3Sep: - break; - } -} - -void PSOutputDev::updateStrokeColorSpace(GfxState *state) { - if (inUncoloredPattern) { - return; - } - switch (level) { - case psLevel1: - case psLevel1Sep: - break; - case psLevel2: - case psLevel3: - if (state->getStrokeColorSpace()->getMode() != csPattern) { - dumpColorSpaceL2(state->getStrokeColorSpace(), gTrue, gFalse, gFalse); - writePS(" CS\n"); - } - break; - case psLevel2Sep: - case psLevel3Sep: - break; - } -} - -void PSOutputDev::updateFillColor(GfxState *state) { - GfxColor color; - GfxColor *colorPtr; - GfxGray gray; - GfxCMYK cmyk; - GfxSeparationColorSpace *sepCS; - double c, m, y, k; - int i; - - if (inUncoloredPattern) { - return; - } - switch (level) { - case psLevel1: - state->getFillGray(&gray); - writePSFmt("{0:.4g} g\n", colToDbl(gray)); - break; - case psLevel1Sep: - state->getFillCMYK(&cmyk); - c = colToDbl(cmyk.c); - m = colToDbl(cmyk.m); - y = colToDbl(cmyk.y); - k = colToDbl(cmyk.k); - writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} k\n", c, m, y, k); - addProcessColor(c, m, y, k); - break; - case psLevel2: - case psLevel3: - if (state->getFillColorSpace()->getMode() != csPattern) { - colorPtr = state->getFillColor(); - writePS("["); - for (i = 0; i < state->getFillColorSpace()->getNComps(); ++i) { - if (i > 0) { - writePS(" "); - } - writePSFmt("{0:.4g}", colToDbl(colorPtr->c[i])); - } - writePS("] sc\n"); - } - break; - case psLevel2Sep: - case psLevel3Sep: - if (state->getFillColorSpace()->getMode() == csSeparation) { - sepCS = (GfxSeparationColorSpace *)state->getFillColorSpace(); - color.c[0] = gfxColorComp1; - sepCS->getCMYK(&color, &cmyk); - writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} {4:.4g} ({5:t}) ck\n", - colToDbl(state->getFillColor()->c[0]), - colToDbl(cmyk.c), colToDbl(cmyk.m), - colToDbl(cmyk.y), colToDbl(cmyk.k), - sepCS->getName()); - addCustomColor(sepCS); - } else { - state->getFillCMYK(&cmyk); - c = colToDbl(cmyk.c); - m = colToDbl(cmyk.m); - y = colToDbl(cmyk.y); - k = colToDbl(cmyk.k); - writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} k\n", c, m, y, k); - addProcessColor(c, m, y, k); - } - break; - } - t3Cacheable = gFalse; -} - -void PSOutputDev::updateStrokeColor(GfxState *state) { - GfxColor color; - GfxColor *colorPtr; - GfxGray gray; - GfxCMYK cmyk; - GfxSeparationColorSpace *sepCS; - double c, m, y, k; - int i; - - if (inUncoloredPattern) { - return; - } - switch (level) { - case psLevel1: - state->getStrokeGray(&gray); - writePSFmt("{0:.4g} G\n", colToDbl(gray)); - break; - case psLevel1Sep: - state->getStrokeCMYK(&cmyk); - c = colToDbl(cmyk.c); - m = colToDbl(cmyk.m); - y = colToDbl(cmyk.y); - k = colToDbl(cmyk.k); - writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} K\n", c, m, y, k); - addProcessColor(c, m, y, k); - break; - case psLevel2: - case psLevel3: - if (state->getStrokeColorSpace()->getMode() != csPattern) { - colorPtr = state->getStrokeColor(); - writePS("["); - for (i = 0; i < state->getStrokeColorSpace()->getNComps(); ++i) { - if (i > 0) { - writePS(" "); - } - writePSFmt("{0:.4g}", colToDbl(colorPtr->c[i])); - } - writePS("] SC\n"); - } - break; - case psLevel2Sep: - case psLevel3Sep: - if (state->getStrokeColorSpace()->getMode() == csSeparation) { - sepCS = (GfxSeparationColorSpace *)state->getStrokeColorSpace(); - color.c[0] = gfxColorComp1; - sepCS->getCMYK(&color, &cmyk); - writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} {4:.4g} ({5:t}) CK\n", - colToDbl(state->getStrokeColor()->c[0]), - colToDbl(cmyk.c), colToDbl(cmyk.m), - colToDbl(cmyk.y), colToDbl(cmyk.k), - sepCS->getName()); - addCustomColor(sepCS); - } else { - state->getStrokeCMYK(&cmyk); - c = colToDbl(cmyk.c); - m = colToDbl(cmyk.m); - y = colToDbl(cmyk.y); - k = colToDbl(cmyk.k); - writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} K\n", c, m, y, k); - addProcessColor(c, m, y, k); - } - break; - } - t3Cacheable = gFalse; -} - -void PSOutputDev::addProcessColor(double c, double m, double y, double k) { - if (c > 0) { - processColors |= psProcessCyan; - } - if (m > 0) { - processColors |= psProcessMagenta; - } - if (y > 0) { - processColors |= psProcessYellow; - } - if (k > 0) { - processColors |= psProcessBlack; - } -} - -void PSOutputDev::addCustomColor(GfxSeparationColorSpace *sepCS) { - PSOutCustomColor *cc; - GfxColor color; - GfxCMYK cmyk; - - if (!sepCS->getName()->cmp("Black")) { - processColors |= psProcessBlack; - return; - } - if (!sepCS->getName()->cmp("Cyan")) { - processColors |= psProcessCyan; - return; - } - if (!sepCS->getName()->cmp("Yellow")) { - processColors |= psProcessYellow; - return; - } - if (!sepCS->getName()->cmp("Magenta")) { - processColors |= psProcessMagenta; - return; - } - if (!sepCS->getName()->cmp("All")) - return; - if (!sepCS->getName()->cmp("None")) - return; - for (cc = customColors; cc; cc = cc->next) { - if (!cc->name->cmp(sepCS->getName())) { - return; - } - } - color.c[0] = gfxColorComp1; - sepCS->getCMYK(&color, &cmyk); - cc = new PSOutCustomColor(colToDbl(cmyk.c), colToDbl(cmyk.m), - colToDbl(cmyk.y), colToDbl(cmyk.k), - sepCS->getName()->copy()); - cc->next = customColors; - customColors = cc; -} - -void PSOutputDev::updateFillOverprint(GfxState *state) { - if (level >= psLevel2) { - writePSFmt("{0:s} op\n", state->getFillOverprint() ? "true" : "false"); - } -} - -void PSOutputDev::updateStrokeOverprint(GfxState *state) { - if (level >= psLevel2) { - writePSFmt("{0:s} OP\n", state->getStrokeOverprint() ? "true" : "false"); - } -} - -void PSOutputDev::updateOverprintMode(GfxState *state) { - if (level >= psLevel3) { - writePSFmt("{0:s} opm\n", state->getOverprintMode() ? "true" : "false"); - } -} - -void PSOutputDev::updateTransfer(GfxState *state) { - Function **funcs; - int i; - - funcs = state->getTransfer(); - if (funcs[0] && funcs[1] && funcs[2] && funcs[3]) { - if (level >= psLevel2) { - for (i = 0; i < 4; ++i) { - cvtFunction(funcs[i]); - } - writePS("setcolortransfer\n"); - } else { - cvtFunction(funcs[3]); - writePS("settransfer\n"); - } - } else if (funcs[0]) { - cvtFunction(funcs[0]); - writePS("settransfer\n"); - } else { - writePS("{} settransfer\n"); - } -} - -void PSOutputDev::updateFont(GfxState *state) { - if (state->getFont()) { - writePSFmt("/F{0:d}_{1:d} {2:.6g} Tf\n", - state->getFont()->getID()->num, state->getFont()->getID()->gen, - fabs(state->getFontSize()) < 0.0001 ? 0.0001 - : state->getFontSize()); - } -} - -void PSOutputDev::updateTextMat(GfxState *state) { - double *mat; - - mat = state->getTextMat(); - if (fabs(mat[0] * mat[3] - mat[1] * mat[2]) < 0.00001) { - // avoid a singular (or close-to-singular) matrix - writePSFmt("[0.00001 0 0 0.00001 {0:.6g} {1:.6g}] Tm\n", mat[4], mat[5]); - } else { - writePSFmt("[{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g}] Tm\n", - mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]); - } -} - -void PSOutputDev::updateCharSpace(GfxState *state) { - writePSFmt("{0:.6g} Tc\n", state->getCharSpace()); -} - -void PSOutputDev::updateRender(GfxState *state) { - int rm; - - rm = state->getRender(); - writePSFmt("{0:d} Tr\n", rm); - rm &= 3; - if (rm != 0 && rm != 3) { - t3Cacheable = gFalse; - } -} - -void PSOutputDev::updateRise(GfxState *state) { - writePSFmt("{0:.6g} Ts\n", state->getRise()); -} - -void PSOutputDev::updateWordSpace(GfxState *state) { - writePSFmt("{0:.6g} Tw\n", state->getWordSpace()); -} - -void PSOutputDev::updateHorizScaling(GfxState *state) { - double h; - - h = state->getHorizScaling(); - if (fabs(h) < 0.01) { - h = 0.01; - } - writePSFmt("{0:.6g} Tz\n", h); -} - -void PSOutputDev::updateTextPos(GfxState *state) { - writePSFmt("{0:.6g} {1:.6g} Td\n", state->getLineX(), state->getLineY()); -} - -void PSOutputDev::updateTextShift(GfxState *state, double shift) { - if (state->getFont()->getWMode()) { - writePSFmt("{0:.6g} TJmV\n", shift); - } else { - writePSFmt("{0:.6g} TJm\n", shift); - } -} - -void PSOutputDev::saveTextPos(GfxState *state) { - writePS("currentpoint\n"); -} - -void PSOutputDev::restoreTextPos(GfxState *state) { - writePS("m\n"); -} - -void PSOutputDev::stroke(GfxState *state) { - doPath(state->getPath()); - if (inType3Char && t3FillColorOnly) { - // if we're construct a cacheable Type 3 glyph, we need to do - // everything in the fill color - writePS("Sf\n"); - } else { - writePS("S\n"); - } -} - -void PSOutputDev::fill(GfxState *state) { - doPath(state->getPath()); - writePS("f\n"); -} - -void PSOutputDev::eoFill(GfxState *state) { - doPath(state->getPath()); - writePS("f*\n"); -} - -GBool PSOutputDev::tilingPatternFillL1(GfxState *state, Catalog *cat, Object *str, - double *pmat, int paintType, int tilingType, Dict *resDict, - double *mat, double *bbox, - int x0, int y0, int x1, int y1, - double xStep, double yStep) { - PDFRectangle box; - Gfx *gfx; - - // define a Type 3 font - writePS("8 dict begin\n"); - writePS("/FontType 3 def\n"); - writePS("/FontMatrix [1 0 0 1 0 0] def\n"); - writePSFmt("/FontBBox [{0:.6g} {1:.6g} {2:.6g} {3:.6g}] def\n", - bbox[0], bbox[1], bbox[2], bbox[3]); - writePS("/Encoding 256 array def\n"); - writePS(" 0 1 255 { Encoding exch /.notdef put } for\n"); - writePS(" Encoding 120 /x put\n"); - writePS("/BuildGlyph {\n"); - writePS(" exch /CharProcs get exch\n"); - writePS(" 2 copy known not { pop /.notdef } if\n"); - writePS(" get exec\n"); - writePS("} bind def\n"); - writePS("/BuildChar {\n"); - writePS(" 1 index /Encoding get exch get\n"); - writePS(" 1 index /BuildGlyph get exec\n"); - writePS("} bind def\n"); - writePS("/CharProcs 1 dict def\n"); - writePS("CharProcs begin\n"); - box.x1 = bbox[0]; - box.y1 = bbox[1]; - box.x2 = bbox[2]; - box.y2 = bbox[3]; - gfx = new Gfx(doc, this, resDict, &box, NULL); - writePS("/x {\n"); - if (paintType == 2) { - writePSFmt("{0:.6g} 0 {1:.6g} {2:.6g} {3:.6g} {4:.6g} setcachedevice\n", - xStep, bbox[0], bbox[1], bbox[2], bbox[3]); - t3FillColorOnly = gTrue; - } else - { - if (x1 - 1 <= x0) { - writePS("1 0 setcharwidth\n"); - } else { - writePSFmt("{0:.6g} 0 setcharwidth\n", xStep); - } - t3FillColorOnly = gFalse; - } - inType3Char = gTrue; - if (paintType == 2) { - inUncoloredPattern = gTrue; - // ensure any PS procedures that contain sCol or fCol do not change the color - writePS("/pdfLastFill true def\n"); - writePS("/pdfLastStroke true def\n"); - } - ++numTilingPatterns; - gfx->display(str); - --numTilingPatterns; - if (paintType == 2) { - inUncoloredPattern = gFalse; - // ensure the next PS procedures that uses sCol or fCol will update the color - writePS("/pdfLastFill false def\n"); - writePS("/pdfLastStroke false def\n"); - } - inType3Char = gFalse; - writePS("} def\n"); - delete gfx; - writePS("end\n"); - writePS("currentdict end\n"); - writePSFmt("/xpdfTile{0:d} exch definefont pop\n", numTilingPatterns); - - // draw the tiles - writePSFmt("/xpdfTile{0:d} findfont setfont\n", numTilingPatterns); - writePS("fCol\n"); - writePSFmt("gsave [{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g}] concat\n", - mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]); - writePSFmt("{0:d} 1 {1:d} {{ {2:.6g} exch {3:.6g} mul m {4:d} 1 {5:d} {{ pop (x) show }} for }} for\n", - y0, y1 - 1, x0 * xStep, yStep, x0, x1 - 1); - writePS("grestore\n"); - - return gTrue; -} - -GBool PSOutputDev::tilingPatternFillL2(GfxState *state, Catalog *cat, Object *str, - double *pmat, int paintType, int tilingType, Dict *resDict, - double *mat, double *bbox, - int x0, int y0, int x1, int y1, - double xStep, double yStep) { - PDFRectangle box; - Gfx *gfx; - - if (paintType == 2) { - // setpattern with PaintType 2 needs the paint color - writePS("currentcolor\n"); - } - writePS("<<\n /PatternType 1\n"); - writePSFmt(" /PaintType {0:d}\n", paintType); - writePSFmt(" /TilingType {0:d}\n", tilingType); - writePSFmt(" /BBox [{0:.6g} {1:.6g} {2:.6g} {3:.6g}]\n", bbox[0], bbox[1], bbox[2], bbox[3]); - writePSFmt(" /XStep {0:.6g}\n", xStep); - writePSFmt(" /YStep {0:.6g}\n", yStep); - writePS(" /PaintProc { \n"); - box.x1 = bbox[0]; - box.y1 = bbox[1]; - box.x2 = bbox[2]; - box.y2 = bbox[3]; - gfx = new Gfx(doc, this, resDict, &box, NULL); - inType3Char = gTrue; - if (paintType == 2) { - inUncoloredPattern = gTrue; - // ensure any PS procedures that contain sCol or fCol do not change the color - writePS("/pdfLastFill true def\n"); - writePS("/pdfLastStroke true def\n"); - } - gfx->display(str); - if (paintType == 2) { - inUncoloredPattern = gFalse; - // ensure the next PS procedures that uses sCol or fCol will update the color - writePS("/pdfLastFill false def\n"); - writePS("/pdfLastStroke false def\n"); - } - inType3Char = gFalse; - delete gfx; - writePS(" }\n"); - writePS(">>\n"); - writePSFmt("[{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g}]\n", mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]); - writePS("makepattern setpattern\n"); - writePS("clippath fill\n"); // Gfx sets up a clip before calling out->tilingPatternFill() - - return gTrue; -} - -GBool PSOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *cat, Object *str, - double *pmat, int paintType, int tilingType, Dict *resDict, - double *mat, double *bbox, - int x0, int y0, int x1, int y1, - double xStep, double yStep) { - if (x1 - x0 == 1 && y1 - y0 == 1) { - // Don't need to use patterns if only one instance of the pattern is used - PDFRectangle box; - Gfx *gfx; - double x, y, tx, ty; - - x = x0 * xStep; - y = y0 * yStep; - tx = x * mat[0] + y * mat[2] + mat[4]; - ty = x * mat[1] + y * mat[3] + mat[5]; - box.x1 = bbox[0]; - box.y1 = bbox[1]; - box.x2 = bbox[2]; - box.y2 = bbox[3]; - gfx = new Gfx(doc, this, resDict, &box, NULL, NULL, NULL, gfxA->getXRef()); - writePSFmt("[{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g}] cm\n", mat[0], mat[1], mat[2], mat[3], tx, ty); - inType3Char = gTrue; - gfx->display(str); - inType3Char = gFalse; - delete gfx; - return gTrue; - } - - if (level == psLevel1 || level == psLevel1Sep) { - return tilingPatternFillL1(state, cat, str, pmat, paintType, tilingType, resDict, - mat, bbox, x0, y0, x1, y1, xStep, yStep); - } else { - return tilingPatternFillL2(state, cat, str, pmat, paintType, tilingType, resDict, - mat, bbox, x0, y0, x1, y1, xStep, yStep); - } -} - -GBool PSOutputDev::functionShadedFill(GfxState *state, - GfxFunctionShading *shading) { - double x0, y0, x1, y1; - double *mat; - int i; - - if (level == psLevel2Sep || level == psLevel3Sep) { - if (shading->getColorSpace()->getMode() != csDeviceCMYK) { - return gFalse; - } - processColors |= psProcessCMYK; - } - - shading->getDomain(&x0, &y0, &x1, &y1); - mat = shading->getMatrix(); - writePSFmt("/mat [{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g}] def\n", - mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]); - writePSFmt("/n {0:d} def\n", shading->getColorSpace()->getNComps()); - if (shading->getNFuncs() == 1) { - writePS("/func "); - cvtFunction(shading->getFunc(0)); - writePS("def\n"); - } else { - writePS("/func {\n"); - for (i = 0; i < shading->getNFuncs(); ++i) { - if (i < shading->getNFuncs() - 1) { - writePS("2 copy\n"); - } - cvtFunction(shading->getFunc(i)); - writePS("exec\n"); - if (i < shading->getNFuncs() - 1) { - writePS("3 1 roll\n"); - } - } - writePS("} def\n"); - } - writePSFmt("{0:.6g} {1:.6g} {2:.6g} {3:.6g} 0 funcSH\n", x0, y0, x1, y1); - - return gTrue; -} - -GBool PSOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading, double /*tMin*/, double /*tMax*/) { - double xMin, yMin, xMax, yMax; - double x0, y0, x1, y1, dx, dy, mul; - double tMin, tMax, t, t0, t1; - int i; - - if (level == psLevel2Sep || level == psLevel3Sep) { - if (shading->getColorSpace()->getMode() != csDeviceCMYK) { - return gFalse; - } - processColors |= psProcessCMYK; - } - - // get the clip region bbox - state->getUserClipBBox(&xMin, &yMin, &xMax, &yMax); - - // compute min and max t values, based on the four corners of the - // clip region bbox - shading->getCoords(&x0, &y0, &x1, &y1); - dx = x1 - x0; - dy = y1 - y0; - if (fabs(dx) < 0.01 && fabs(dy) < 0.01) { - return gTrue; - } else { - mul = 1 / (dx * dx + dy * dy); - tMin = tMax = ((xMin - x0) * dx + (yMin - y0) * dy) * mul; - t = ((xMin - x0) * dx + (yMax - y0) * dy) * mul; - if (t < tMin) { - tMin = t; - } else if (t > tMax) { - tMax = t; - } - t = ((xMax - x0) * dx + (yMin - y0) * dy) * mul; - if (t < tMin) { - tMin = t; - } else if (t > tMax) { - tMax = t; - } - t = ((xMax - x0) * dx + (yMax - y0) * dy) * mul; - if (t < tMin) { - tMin = t; - } else if (t > tMax) { - tMax = t; - } - if (tMin < 0 && !shading->getExtend0()) { - tMin = 0; - } - if (tMax > 1 && !shading->getExtend1()) { - tMax = 1; - } - } - - // get the function domain - t0 = shading->getDomain0(); - t1 = shading->getDomain1(); - - // generate the PS code - writePSFmt("/t0 {0:.6g} def\n", t0); - writePSFmt("/t1 {0:.6g} def\n", t1); - writePSFmt("/dt {0:.6g} def\n", t1 - t0); - writePSFmt("/x0 {0:.6g} def\n", x0); - writePSFmt("/y0 {0:.6g} def\n", y0); - writePSFmt("/dx {0:.6g} def\n", x1 - x0); - writePSFmt("/x1 {0:.6g} def\n", x1); - writePSFmt("/y1 {0:.6g} def\n", y1); - writePSFmt("/dy {0:.6g} def\n", y1 - y0); - writePSFmt("/xMin {0:.6g} def\n", xMin); - writePSFmt("/yMin {0:.6g} def\n", yMin); - writePSFmt("/xMax {0:.6g} def\n", xMax); - writePSFmt("/yMax {0:.6g} def\n", yMax); - writePSFmt("/n {0:d} def\n", shading->getColorSpace()->getNComps()); - if (shading->getNFuncs() == 1) { - writePS("/func "); - cvtFunction(shading->getFunc(0)); - writePS("def\n"); - } else { - writePS("/func {\n"); - for (i = 0; i < shading->getNFuncs(); ++i) { - if (i < shading->getNFuncs() - 1) { - writePS("dup\n"); - } - cvtFunction(shading->getFunc(i)); - writePS("exec\n"); - if (i < shading->getNFuncs() - 1) { - writePS("exch\n"); - } - } - writePS("} def\n"); - } - writePSFmt("{0:.6g} {1:.6g} 0 axialSH\n", tMin, tMax); - - return gTrue; -} - -GBool PSOutputDev::radialShadedFill(GfxState *state, GfxRadialShading *shading, double /*sMin*/, double /*sMax*/) { - double xMin, yMin, xMax, yMax; - double x0, y0, r0, x1, y1, r1, t0, t1; - double xa, ya, ra; - double sMin, sMax, h, ta; - double sLeft, sRight, sTop, sBottom, sZero, sDiag; - GBool haveSLeft, haveSRight, haveSTop, haveSBottom, haveSZero; - GBool haveSMin, haveSMax; - double theta, alpha, a1, a2; - GBool enclosed; - int i; - - if (level == psLevel2Sep || level == psLevel3Sep) { - if (shading->getColorSpace()->getMode() != csDeviceCMYK) { - return gFalse; - } - processColors |= psProcessCMYK; - } - - // get the shading info - shading->getCoords(&x0, &y0, &r0, &x1, &y1, &r1); - t0 = shading->getDomain0(); - t1 = shading->getDomain1(); - - // Compute the point at which r(s) = 0; check for the enclosed - // circles case; and compute the angles for the tangent lines. - // Compute the point at which r(s) = 0; check for the enclosed - // circles case; and compute the angles for the tangent lines. - h = sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)); - if (h == 0) { - enclosed = gTrue; - theta = 0; // make gcc happy - } else if (r1 - r0 == 0) { - enclosed = gFalse; - theta = 0; - } else if (fabs(r1 - r0) >= h) { - enclosed = gTrue; - theta = 0; // make gcc happy - } else { - enclosed = gFalse; - theta = asin((r1 - r0) / h); - } - if (enclosed) { - a1 = 0; - a2 = 360; - } else { - alpha = atan2(y1 - y0, x1 - x0); - a1 = (180 / M_PI) * (alpha + theta) + 90; - a2 = (180 / M_PI) * (alpha - theta) - 90; - while (a2 < a1) { - a2 += 360; - } - } - - // compute the (possibly extended) s range - state->getUserClipBBox(&xMin, &yMin, &xMax, &yMax); - if (enclosed) { - sMin = 0; - sMax = 1; - } else { - // solve x(sLeft) + r(sLeft) = xMin - if ((haveSLeft = fabs((x1 + r1) - (x0 + r0)) > 0.000001)) { - sLeft = (xMin - (x0 + r0)) / ((x1 + r1) - (x0 + r0)); - } else { - sLeft = 0; // make gcc happy - } - // solve x(sRight) - r(sRight) = xMax - if ((haveSRight = fabs((x1 - r1) - (x0 - r0)) > 0.000001)) { - sRight = (xMax - (x0 - r0)) / ((x1 - r1) - (x0 - r0)); - } else { - sRight = 0; // make gcc happy - } - // solve y(sBottom) + r(sBottom) = yMin - if ((haveSBottom = fabs((y1 + r1) - (y0 + r0)) > 0.000001)) { - sBottom = (yMin - (y0 + r0)) / ((y1 + r1) - (y0 + r0)); - } else { - sBottom = 0; // make gcc happy - } - // solve y(sTop) - r(sTop) = yMax - if ((haveSTop = fabs((y1 - r1) - (y0 - r0)) > 0.000001)) { - sTop = (yMax - (y0 - r0)) / ((y1 - r1) - (y0 - r0)); - } else { - sTop = 0; // make gcc happy - } - // solve r(sZero) = 0 - if ((haveSZero = fabs(r1 - r0) > 0.000001)) { - sZero = -r0 / (r1 - r0); - } else { - sZero = 0; // make gcc happy - } - // solve r(sDiag) = sqrt((xMax-xMin)^2 + (yMax-yMin)^2) - if (haveSZero) { - sDiag = (sqrt((xMax - xMin) * (xMax - xMin) + - (yMax - yMin) * (yMax - yMin)) - r0) / (r1 - r0); - } else { - sDiag = 0; // make gcc happy - } - // compute sMin - if (shading->getExtend0()) { - sMin = 0; - haveSMin = gFalse; - if (x0 < x1 && haveSLeft && sLeft < 0) { - sMin = sLeft; - haveSMin = gTrue; - } else if (x0 > x1 && haveSRight && sRight < 0) { - sMin = sRight; - haveSMin = gTrue; - } - if (y0 < y1 && haveSBottom && sBottom < 0) { - if (!haveSMin || sBottom > sMin) { - sMin = sBottom; - haveSMin = gTrue; - } - } else if (y0 > y1 && haveSTop && sTop < 0) { - if (!haveSMin || sTop > sMin) { - sMin = sTop; - haveSMin = gTrue; - } - } - if (haveSZero && sZero < 0) { - if (!haveSMin || sZero > sMin) { - sMin = sZero; - } - } - } else { - sMin = 0; - } - // compute sMax - if (shading->getExtend1()) { - sMax = 1; - haveSMax = gFalse; - if (x1 < x0 && haveSLeft && sLeft > 1) { - sMax = sLeft; - haveSMax = gTrue; - } else if (x1 > x0 && haveSRight && sRight > 1) { - sMax = sRight; - haveSMax = gTrue; - } - if (y1 < y0 && haveSBottom && sBottom > 1) { - if (!haveSMax || sBottom < sMax) { - sMax = sBottom; - haveSMax = gTrue; - } - } else if (y1 > y0 && haveSTop && sTop > 1) { - if (!haveSMax || sTop < sMax) { - sMax = sTop; - haveSMax = gTrue; - } - } - if (haveSZero && sDiag > 1) { - if (!haveSMax || sDiag < sMax) { - sMax = sDiag; - } - } - } else { - sMax = 1; - } - } - - // generate the PS code - writePSFmt("/x0 {0:.6g} def\n", x0); - writePSFmt("/x1 {0:.6g} def\n", x1); - writePSFmt("/dx {0:.6g} def\n", x1 - x0); - writePSFmt("/y0 {0:.6g} def\n", y0); - writePSFmt("/y1 {0:.6g} def\n", y1); - writePSFmt("/dy {0:.6g} def\n", y1 - y0); - writePSFmt("/r0 {0:.6g} def\n", r0); - writePSFmt("/r1 {0:.6g} def\n", r1); - writePSFmt("/dr {0:.6g} def\n", r1 - r0); - writePSFmt("/t0 {0:.6g} def\n", t0); - writePSFmt("/t1 {0:.6g} def\n", t1); - writePSFmt("/dt {0:.6g} def\n", t1 - t0); - writePSFmt("/n {0:d} def\n", shading->getColorSpace()->getNComps()); - writePSFmt("/encl {0:s} def\n", enclosed ? "true" : "false"); - writePSFmt("/a1 {0:.6g} def\n", a1); - writePSFmt("/a2 {0:.6g} def\n", a2); - if (shading->getNFuncs() == 1) { - writePS("/func "); - cvtFunction(shading->getFunc(0)); - writePS("def\n"); - } else { - writePS("/func {\n"); - for (i = 0; i < shading->getNFuncs(); ++i) { - if (i < shading->getNFuncs() - 1) { - writePS("dup\n"); - } - cvtFunction(shading->getFunc(i)); - writePS("exec\n"); - if (i < shading->getNFuncs() - 1) { - writePS("exch\n"); - } - } - writePS("} def\n"); - } - writePSFmt("{0:.6g} {1:.6g} 0 radialSH\n", sMin, sMax); - - // extend the 'enclosed' case - if (enclosed) { - // extend the smaller circle - if ((shading->getExtend0() && r0 <= r1) || - (shading->getExtend1() && r1 < r0)) { - if (r0 <= r1) { - ta = t0; - ra = r0; - xa = x0; - ya = y0; - } else { - ta = t1; - ra = r1; - xa = x1; - ya = y1; - } - if (level == psLevel2Sep || level == psLevel3Sep) { - writePSFmt("{0:.6g} radialCol aload pop k\n", ta); - } else { - writePSFmt("{0:.6g} radialCol sc\n", ta); - } - writePSFmt("{0:.6g} {1:.6g} {2:.6g} 0 360 arc h f*\n", xa, ya, ra); - } - - // extend the larger circle - if ((shading->getExtend0() && r0 > r1) || - (shading->getExtend1() && r1 >= r0)) { - if (r0 > r1) { - ta = t0; - ra = r0; - xa = x0; - ya = y0; - } else { - ta = t1; - ra = r1; - xa = x1; - ya = y1; - } - if (level == psLevel2Sep || level == psLevel3Sep) { - writePSFmt("{0:.6g} radialCol aload pop k\n", ta); - } else { - writePSFmt("{0:.6g} radialCol sc\n", ta); - } - writePSFmt("{0:.6g} {1:.6g} {2:.6g} 0 360 arc h\n", xa, ya, ra); - writePSFmt("{0:.6g} {1:.6g} m {2:.6g} {3:.6g} l {4:.6g} {5:.6g} l {6:.6g} {7:.6g} l h f*\n", - xMin, yMin, xMin, yMax, xMax, yMax, xMax, yMin); - } - } - - return gTrue; -} - -void PSOutputDev::clip(GfxState *state) { - doPath(state->getPath()); - writePS("W\n"); -} - -void PSOutputDev::eoClip(GfxState *state) { - doPath(state->getPath()); - writePS("W*\n"); -} - -void PSOutputDev::clipToStrokePath(GfxState *state) { - doPath(state->getPath()); - writePS("Ws\n"); -} - -void PSOutputDev::doPath(GfxPath *path) { - GfxSubpath *subpath; - double x0, y0, x1, y1, x2, y2, x3, y3, x4, y4; - int n, m, i, j; - - n = path->getNumSubpaths(); - - if (n == 1 && path->getSubpath(0)->getNumPoints() == 5) { - subpath = path->getSubpath(0); - x0 = subpath->getX(0); - y0 = subpath->getY(0); - x4 = subpath->getX(4); - y4 = subpath->getY(4); - if (x4 == x0 && y4 == y0) { - x1 = subpath->getX(1); - y1 = subpath->getY(1); - x2 = subpath->getX(2); - y2 = subpath->getY(2); - x3 = subpath->getX(3); - y3 = subpath->getY(3); - if (x0 == x1 && x2 == x3 && y0 == y3 && y1 == y2) { - writePSFmt("{0:.6g} {1:.6g} {2:.6g} {3:.6g} re\n", - x0 < x2 ? x0 : x2, y0 < y1 ? y0 : y1, - fabs(x2 - x0), fabs(y1 - y0)); - return; - } else if (x0 == x3 && x1 == x2 && y0 == y1 && y2 == y3) { - writePSFmt("{0:.6g} {1:.6g} {2:.6g} {3:.6g} re\n", - x0 < x1 ? x0 : x1, y0 < y2 ? y0 : y2, - fabs(x1 - x0), fabs(y2 - y0)); - return; - } - } - } - - for (i = 0; i < n; ++i) { - subpath = path->getSubpath(i); - m = subpath->getNumPoints(); - writePSFmt("{0:.6g} {1:.6g} m\n", subpath->getX(0), subpath->getY(0)); - j = 1; - while (j < m) { - if (subpath->getCurve(j)) { - writePSFmt("{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g} c\n", - subpath->getX(j), subpath->getY(j), - subpath->getX(j+1), subpath->getY(j+1), - subpath->getX(j+2), subpath->getY(j+2)); - j += 3; - } else { - writePSFmt("{0:.6g} {1:.6g} l\n", subpath->getX(j), subpath->getY(j)); - ++j; - } - } - if (subpath->isClosed()) { - writePS("h\n"); - } - } -} - -void PSOutputDev::drawString(GfxState *state, GooString *s) { - GfxFont *font; - int wMode; - int *codeToGID; - GooString *s2; - double dx, dy, originX, originY; - char *p; - UnicodeMap *uMap; - CharCode code; - Unicode *u; - char buf[8]; - double *dxdy; - int dxdySize, len, nChars, uLen, n, m, i, j; - - // for pdftohtml, output PS without text - if( displayText == gFalse ) - return; - - // check for invisible text -- this is used by Acrobat Capture - if (state->getRender() == 3) { - return; - } - - // ignore empty strings - if (s->getLength() == 0) { - return; - } - - // get the font - if (!(font = state->getFont())) { - return; - } - wMode = font->getWMode(); - - // check for a subtitute 16-bit font - uMap = NULL; - codeToGID = NULL; - if (font->isCIDFont()) { - for (i = 0; i < font16EncLen; ++i) { - if (font->getID()->num == font16Enc[i].fontID.num && - font->getID()->gen == font16Enc[i].fontID.gen) { - if (!font16Enc[i].enc) { - // font substitution failed, so don't output any text - return; - } - uMap = globalParams->getUnicodeMap(font16Enc[i].enc); - break; - } - } - - // check for a code-to-GID map - } else { - for (i = 0; i < font8InfoLen; ++i) { - if (font->getID()->num == font8Info[i].fontID.num && - font->getID()->gen == font8Info[i].fontID.gen) { - codeToGID = font8Info[i].codeToGID; - break; - } - } - } - - // compute the positioning (dx, dy) for each char in the string - nChars = 0; - p = s->getCString(); - len = s->getLength(); - s2 = new GooString(); - dxdySize = font->isCIDFont() ? 8 : s->getLength(); - dxdy = (double *)gmallocn(2 * dxdySize, sizeof(double)); - while (len > 0) { - n = font->getNextChar(p, len, &code, - &u, &uLen, - &dx, &dy, &originX, &originY); - dx *= state->getFontSize(); - dy *= state->getFontSize(); - if (wMode) { - dy += state->getCharSpace(); - if (n == 1 && *p == ' ') { - dy += state->getWordSpace(); - } - } else { - dx += state->getCharSpace(); - if (n == 1 && *p == ' ') { - dx += state->getWordSpace(); - } - } - dx *= state->getHorizScaling(); - if (font->isCIDFont()) { - if (uMap) { - if (nChars + uLen > dxdySize) { - do { - dxdySize *= 2; - } while (nChars + uLen > dxdySize); - dxdy = (double *)greallocn(dxdy, 2 * dxdySize, sizeof(double)); - } - for (i = 0; i < uLen; ++i) { - m = uMap->mapUnicode(u[i], buf, (int)sizeof(buf)); - for (j = 0; j < m; ++j) { - s2->append(buf[j]); - } - //~ this really needs to get the number of chars in the target - //~ encoding - which may be more than the number of Unicode - //~ chars - dxdy[2 * nChars] = dx; - dxdy[2 * nChars + 1] = dy; - ++nChars; - } - } else { - if (nChars + 1 > dxdySize) { - dxdySize *= 2; - dxdy = (double *)greallocn(dxdy, 2 * dxdySize, sizeof(double)); - } - s2->append((char)((code >> 8) & 0xff)); - s2->append((char)(code & 0xff)); - dxdy[2 * nChars] = dx; - dxdy[2 * nChars + 1] = dy; - ++nChars; - } - } else { - if (!codeToGID || codeToGID[code] >= 0) { - s2->append((char)code); - dxdy[2 * nChars] = dx; - dxdy[2 * nChars + 1] = dy; - ++nChars; - } - } - p += n; - len -= n; - } - if (uMap) { - uMap->decRefCnt(); - } - - if (nChars > 0) { - writePSString(s2); - writePS("\n["); - for (i = 0; i < 2 * nChars; ++i) { - if (i > 0) { - writePS("\n"); - } - writePSFmt("{0:.6g}", dxdy[i]); - } - writePS("] Tj\n"); - } - gfree(dxdy); - delete s2; - - if (state->getRender() & 4) { - haveTextClip = gTrue; - } -} - -void PSOutputDev::beginTextObject(GfxState *state) { -} - -void PSOutputDev::endTextObject(GfxState *state) { - if (haveTextClip) { - writePS("Tclip\n"); - haveTextClip = gFalse; - } -} - -void PSOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, - int width, int height, GBool invert, - GBool interpolate, GBool inlineImg) { - int len; - - len = height * ((width + 7) / 8); - switch (level) { - case psLevel1: - case psLevel1Sep: - doImageL1(ref, NULL, invert, inlineImg, str, width, height, len, - NULL, NULL, 0, 0, gFalse); - break; - case psLevel2: - case psLevel2Sep: - doImageL2(ref, NULL, invert, inlineImg, str, width, height, len, - NULL, NULL, 0, 0, gFalse); - break; - case psLevel3: - case psLevel3Sep: - doImageL3(ref, NULL, invert, inlineImg, str, width, height, len, - NULL, NULL, 0, 0, gFalse); - break; - } -} - -void PSOutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, - int width, int height, GBool invert, - GBool inlineImg, double *baseMatrix) { - if (level != psLevel1 && level != psLevel1Sep) { - maskToClippingPath(str, width, height, invert); - } -} - -void PSOutputDev::unsetSoftMaskFromImageMask(GfxState * state, double *baseMatrix) { - if (level != psLevel1 && level != psLevel1Sep) { - writePS("pdfImClipEnd\n"); - } -} - -void PSOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, - int width, int height, GfxImageColorMap *colorMap, - GBool interpolate, int *maskColors, GBool inlineImg) { - int len; - - len = height * ((width * colorMap->getNumPixelComps() * - colorMap->getBits() + 7) / 8); - switch (level) { - case psLevel1: - doImageL1(ref, colorMap, gFalse, inlineImg, str, - width, height, len, maskColors, NULL, 0, 0, gFalse); - break; - case psLevel1Sep: - //~ handle indexed, separation, ... color spaces - doImageL1Sep(ref, colorMap, gFalse, inlineImg, str, - width, height, len, maskColors, NULL, 0, 0, gFalse); - break; - case psLevel2: - case psLevel2Sep: - doImageL2(ref, colorMap, gFalse, inlineImg, str, - width, height, len, maskColors, NULL, 0, 0, gFalse); - break; - case psLevel3: - case psLevel3Sep: - doImageL3(ref, colorMap, gFalse, inlineImg, str, - width, height, len, maskColors, NULL, 0, 0, gFalse); - break; - } - t3Cacheable = gFalse; -} - -void PSOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str, - int width, int height, - GfxImageColorMap *colorMap, - GBool interpolate, - Stream *maskStr, - int maskWidth, int maskHeight, - GBool maskInvert, GBool maskInterpolate) { - int len; - - len = height * ((width * colorMap->getNumPixelComps() * - colorMap->getBits() + 7) / 8); - switch (level) { - case psLevel1: - doImageL1(ref, colorMap, gFalse, gFalse, str, width, height, len, - NULL, maskStr, maskWidth, maskHeight, maskInvert); - break; - case psLevel1Sep: - //~ handle indexed, separation, ... color spaces - doImageL1Sep(ref, colorMap, gFalse, gFalse, str, width, height, len, - NULL, maskStr, maskWidth, maskHeight, maskInvert); - break; - case psLevel2: - case psLevel2Sep: - doImageL2(ref, colorMap, gFalse, gFalse, str, width, height, len, - NULL, maskStr, maskWidth, maskHeight, maskInvert); - break; - case psLevel3: - case psLevel3Sep: - doImageL3(ref, colorMap, gFalse, gFalse, str, width, height, len, - NULL, maskStr, maskWidth, maskHeight, maskInvert); - break; - } - t3Cacheable = gFalse; -} - -void PSOutputDev::doImageL1(Object *ref, GfxImageColorMap *colorMap, - GBool invert, GBool inlineImg, - Stream *str, int width, int height, int len, - int *maskColors, Stream *maskStr, - int maskWidth, int maskHeight, GBool maskInvert) { - ImageStream *imgStr; - Guchar pixBuf[gfxColorMaxComps]; - GfxGray gray; - int col, x, y, c, i; - char hexBuf[32*2 + 2]; // 32 values X 2 chars/value + line ending + null - Guchar digit, grayValue; - - // explicit masking - if (maskStr && !(maskColors && colorMap)) { - maskToClippingPath(maskStr, maskWidth, maskHeight, maskInvert); - } - - if ((inType3Char || preloadImagesForms) && !colorMap) { - if (inlineImg) { - // create an array - str = new FixedLengthEncoder(str, len); - str = new ASCIIHexEncoder(str); - str->reset(); - col = 0; - writePS("[<"); - do { - do { - c = str->getChar(); - } while (c == '\n' || c == '\r'); - if (c == '>' || c == EOF) { - break; - } - writePSChar(c); - ++col; - // each line is: "<...data...><eol>" - // so max data length = 255 - 4 = 251 - // but make it 240 just to be safe - // chunks are 2 bytes each, so we need to stop on an even col number - if (col == 240) { - writePS(">\n<"); - col = 0; - } - } while (c != '>' && c != EOF); - writePS(">]\n"); - writePS("0\n"); - str->close(); - delete str; - } else { - // make sure the image is setup, it sometimes is not like on bug #17645 - setupImage(ref->getRef(), str, gFalse); - // set up to use the array already created by setupImages() - writePSFmt("ImData_{0:d}_{1:d} 0 0\n", ref->getRefNum(), ref->getRefGen()); - } - } - - // image/imagemask command - if ((inType3Char || preloadImagesForms) && !colorMap) { - writePSFmt("{0:d} {1:d} {2:s} [{3:d} 0 0 {4:d} 0 {5:d}] pdfImM1a\n", - width, height, invert ? "true" : "false", - width, -height, height); - } else if (colorMap) { - writePSFmt("{0:d} {1:d} 8 [{2:d} 0 0 {3:d} 0 {4:d}] pdfIm1{5:s}\n", - width, height, - width, -height, height, - useBinary ? "Bin" : ""); - } else { - writePSFmt("{0:d} {1:d} {2:s} [{3:d} 0 0 {4:d} 0 {5:d}] pdfImM1{6:s}\n", - width, height, invert ? "true" : "false", - width, -height, height, - useBinary ? "Bin" : ""); - } - - // image data - if (!((inType3Char || preloadImagesForms) && !colorMap)) { - - if (colorMap) { - - // set up to process the data stream - imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(), - colorMap->getBits()); - imgStr->reset(); - - // process the data stream - i = 0; - for (y = 0; y < height; ++y) { - - // write the line - for (x = 0; x < width; ++x) { - imgStr->getPixel(pixBuf); - colorMap->getGray(pixBuf, &gray); - grayValue = colToByte(gray); - if (useBinary) { - hexBuf[i++] = grayValue; - } else { - digit = grayValue / 16; - hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); - digit = grayValue % 16; - hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); - } - if (i >= 64) { - if (!useBinary) { - hexBuf[i++] = '\n'; - } - writePSBuf(hexBuf, i); - i = 0; - } - } - } - if (i != 0) { - if (!useBinary) { - hexBuf[i++] = '\n'; - } - writePSBuf(hexBuf, i); - } - str->close(); - delete imgStr; - - // imagemask - } else { - str->reset(); - i = 0; - for (y = 0; y < height; ++y) { - for (x = 0; x < width; x += 8) { - grayValue = str->getChar(); - if (useBinary) { - hexBuf[i++] = grayValue; - } else { - digit = grayValue / 16; - hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); - digit = grayValue % 16; - hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); - } - if (i >= 64) { - if (!useBinary) { - hexBuf[i++] = '\n'; - } - writePSBuf(hexBuf, i); - i = 0; - } - } - } - if (i != 0) { - if (!useBinary) { - hexBuf[i++] = '\n'; - } - writePSBuf(hexBuf, i); - } - str->close(); - } - } - - if (maskStr && !(maskColors && colorMap)) { - writePS("pdfImClipEnd\n"); - } -} - -void PSOutputDev::doImageL1Sep(Object *ref, GfxImageColorMap *colorMap, - GBool invert, GBool inlineImg, - Stream *str, int width, int height, int len, - int *maskColors, Stream *maskStr, - int maskWidth, int maskHeight, GBool maskInvert) { - ImageStream *imgStr; - Guchar *lineBuf; - Guchar pixBuf[gfxColorMaxComps]; - GfxCMYK cmyk; - int x, y, i, comp; - GBool checkProcessColor; - char hexBuf[32*2 + 2]; // 32 values X 2 chars/value + line ending + null - Guchar digit; - - // explicit masking - if (maskStr && !(maskColors && colorMap)) { - maskToClippingPath(maskStr, maskWidth, maskHeight, maskInvert); - } - - // width, height, matrix, bits per component - writePSFmt("{0:d} {1:d} 8 [{2:d} 0 0 {3:d} 0 {4:d}] pdfIm1Sep{5:s}\n", - width, height, - width, -height, height, - useBinary ? "Bin" : ""); - - // allocate a line buffer - lineBuf = (Guchar *)gmallocn(width, 4); - - // set up to process the data stream - imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(), - colorMap->getBits()); - imgStr->reset(); - - // process the data stream - checkProcessColor = gTrue; - i = 0; - for (y = 0; y < height; ++y) { - - // read the line - if (checkProcessColor) { - checkProcessColor = (((psProcessCyan | psProcessMagenta | psProcessYellow | psProcessBlack) & ~processColors) != 0); - } - if (checkProcessColor) { - for (x = 0; x < width; ++x) { - imgStr->getPixel(pixBuf); - colorMap->getCMYK(pixBuf, &cmyk); - lineBuf[4*x+0] = colToByte(cmyk.c); - lineBuf[4*x+1] = colToByte(cmyk.m); - lineBuf[4*x+2] = colToByte(cmyk.y); - lineBuf[4*x+3] = colToByte(cmyk.k); - addProcessColor(colToDbl(cmyk.c), colToDbl(cmyk.m), - colToDbl(cmyk.y), colToDbl(cmyk.k)); - } - } else { - for (x = 0; x < width; ++x) { - imgStr->getPixel(pixBuf); - colorMap->getCMYK(pixBuf, &cmyk); - lineBuf[4*x+0] = colToByte(cmyk.c); - lineBuf[4*x+1] = colToByte(cmyk.m); - lineBuf[4*x+2] = colToByte(cmyk.y); - lineBuf[4*x+3] = colToByte(cmyk.k); - } - } - - // write one line of each color component - if (useBinary) { - for (comp = 0; comp < 4; ++comp) { - for (x = 0; x < width; ++x) { - hexBuf[i++] = lineBuf[4*x + comp]; - if (i >= 64) { - writePSBuf(hexBuf, i); - i = 0; - } - } - } - } else { - for (comp = 0; comp < 4; ++comp) { - for (x = 0; x < width; ++x) { - digit = lineBuf[4*x + comp] / 16; - hexBuf[i++] = digit + ((digit >= 10)? 'a'-10: '0'); - digit = lineBuf[4*x + comp] % 16; - hexBuf[i++] = digit + ((digit >= 10)? 'a'-10: '0'); - if (i >= 64) { - hexBuf[i++] = '\n'; - writePSBuf(hexBuf, i); - i = 0; - } - } - } - } - } - - if (i != 0) { - if (!useBinary) { - hexBuf[i++] = '\n'; - } - writePSBuf(hexBuf, i); - } - - str->close(); - delete imgStr; - gfree(lineBuf); - - if (maskStr && !(maskColors && colorMap)) { - writePS("pdfImClipEnd\n"); - } -} - -void PSOutputDev::maskToClippingPath(Stream *maskStr, int maskWidth, int maskHeight, GBool maskInvert) { - ImageStream *imgStr; - Guchar *line; - PSOutImgClipRect *rects0, *rects1, *rectsTmp, *rectsOut; - int rects0Len, rects1Len, rectsSize, rectsOutLen, rectsOutSize; - GBool emitRect, addRect, extendRect; - int i, x0, x1, y, maskXor; - - imgStr = new ImageStream(maskStr, maskWidth, 1, 1); - imgStr->reset(); - rects0Len = rects1Len = rectsOutLen = 0; - rectsSize = rectsOutSize = 64; - rects0 = (PSOutImgClipRect *)gmallocn(rectsSize, sizeof(PSOutImgClipRect)); - rects1 = (PSOutImgClipRect *)gmallocn(rectsSize, sizeof(PSOutImgClipRect)); - rectsOut = (PSOutImgClipRect *)gmallocn(rectsOutSize, sizeof(PSOutImgClipRect)); - maskXor = maskInvert ? 1 : 0; - for (y = 0; y < maskHeight; ++y) { - if (!(line = imgStr->getLine())) { - break; - } - i = 0; - rects1Len = 0; - for (x0 = 0; x0 < maskWidth && (line[x0] ^ maskXor); ++x0) ; - for (x1 = x0; x1 < maskWidth && !(line[x1] ^ maskXor); ++x1) ; - while (x0 < maskWidth || i < rects0Len) { - emitRect = addRect = extendRect = gFalse; - if (x0 >= maskWidth) { - emitRect = gTrue; - } else if (i >= rects0Len) { - addRect = gTrue; - } else if (rects0[i].x0 < x0) { - emitRect = gTrue; - } else if (x0 < rects0[i].x0) { - addRect = gTrue; - } else if (rects0[i].x1 == x1) { - extendRect = gTrue; - } else { - emitRect = addRect = gTrue; - } - if (emitRect) { - if (rectsOutLen == rectsOutSize) { - rectsOutSize *= 2; - rectsOut = (PSOutImgClipRect *)greallocn(rectsOut, rectsOutSize, sizeof(PSOutImgClipRect)); - } - rectsOut[rectsOutLen].x0 = rects0[i].x0; - rectsOut[rectsOutLen].x1 = rects0[i].x1; - rectsOut[rectsOutLen].y0 = maskHeight - y - 1; - rectsOut[rectsOutLen].y1 = maskHeight - rects0[i].y0 - 1; - ++rectsOutLen; - ++i; - } - if (addRect || extendRect) { - if (rects1Len == rectsSize) { - rectsSize *= 2; - rects0 = (PSOutImgClipRect *)greallocn(rects0, rectsSize, sizeof(PSOutImgClipRect)); - rects1 = (PSOutImgClipRect *)greallocn(rects1, rectsSize, sizeof(PSOutImgClipRect)); - } - rects1[rects1Len].x0 = x0; - rects1[rects1Len].x1 = x1; - if (addRect) { - rects1[rects1Len].y0 = y; - } - if (extendRect) { - rects1[rects1Len].y0 = rects0[i].y0; - ++i; - } - ++rects1Len; - for (x0 = x1; x0 < maskWidth && (line[x0] ^ maskXor); ++x0) ; - for (x1 = x0; x1 < maskWidth && !(line[x1] ^ maskXor); ++x1) ; - } - } - rectsTmp = rects0; - rects0 = rects1; - rects1 = rectsTmp; - i = rects0Len; - rects0Len = rects1Len; - rects1Len = i; - } - for (i = 0; i < rects0Len; ++i) { - if (rectsOutLen == rectsOutSize) { - rectsOutSize *= 2; - rectsOut = (PSOutImgClipRect *)greallocn(rectsOut, rectsOutSize, sizeof(PSOutImgClipRect)); - } - rectsOut[rectsOutLen].x0 = rects0[i].x0; - rectsOut[rectsOutLen].x1 = rects0[i].x1; - rectsOut[rectsOutLen].y0 = maskHeight - y - 1; - rectsOut[rectsOutLen].y1 = maskHeight - rects0[i].y0 - 1; - ++rectsOutLen; - } - if (rectsOutLen < 65536/4) { - writePSFmt("{0:d} array 0\n", rectsOutLen * 4); - for (i = 0; i < rectsOutLen; ++i) { - writePSFmt("[{0:d} {1:d} {2:d} {3:d}] pr\n", - rectsOut[i].x0, rectsOut[i].y0, - rectsOut[i].x1 - rectsOut[i].x0, - rectsOut[i].y1 - rectsOut[i].y0); - } - writePSFmt("pop {0:d} {1:d} pdfImClip\n", maskWidth, maskHeight); - } else { - // would be over the limit of array size. - // make each rectangle path and clip. - writePS("gsave newpath\n"); - for (i = 0; i < rectsOutLen; ++i) { - writePSFmt("{0:.6g} {1:.6g} {2:.6g} {3:.6g} re\n", - ((double)rectsOut[i].x0)/maskWidth, - ((double)rectsOut[i].y0)/maskHeight, - ((double)(rectsOut[i].x1 - rectsOut[i].x0))/maskWidth, - ((double)(rectsOut[i].y1 - rectsOut[i].y0))/maskHeight); - } - writePS("clip\n"); - } - gfree(rectsOut); - gfree(rects0); - gfree(rects1); - delete imgStr; - maskStr->close(); -} - -void PSOutputDev::doImageL2(Object *ref, GfxImageColorMap *colorMap, - GBool invert, GBool inlineImg, - Stream *str, int width, int height, int len, - int *maskColors, Stream *maskStr, - int maskWidth, int maskHeight, GBool maskInvert) { - Stream *str2; - ImageStream *imgStr; - Guchar *line; - PSOutImgClipRect *rects0, *rects1, *rectsTmp, *rectsOut; - int rects0Len, rects1Len, rectsSize, rectsOutLen, rectsOutSize; - GBool emitRect, addRect, extendRect; - GooString *s; - int n, numComps; - GBool useRLE, useASCII, useCompressed; - GfxSeparationColorSpace *sepCS; - GfxColor color; - GfxCMYK cmyk; - int c; - int col, i, j, x0, x1, y; - char dataBuf[4096]; - - rectsOutLen = 0; - - // color key masking - if (maskColors && colorMap && !inlineImg) { - // can't read the stream twice for inline images -- but masking - // isn't allowed with inline images anyway - numComps = colorMap->getNumPixelComps(); - imgStr = new ImageStream(str, width, numComps, colorMap->getBits()); - imgStr->reset(); - rects0Len = rects1Len = 0; - rectsSize = rectsOutSize = 64; - rects0 = (PSOutImgClipRect *)gmallocn(rectsSize, sizeof(PSOutImgClipRect)); - rects1 = (PSOutImgClipRect *)gmallocn(rectsSize, sizeof(PSOutImgClipRect)); - rectsOut = (PSOutImgClipRect *)gmallocn(rectsOutSize, - sizeof(PSOutImgClipRect)); - for (y = 0; y < height; ++y) { - if (!(line = imgStr->getLine())) { - break; - } - i = 0; - rects1Len = 0; - for (x0 = 0; x0 < width; ++x0) { - for (j = 0; j < numComps; ++j) { - if (line[x0*numComps+j] < maskColors[2*j] || - line[x0*numComps+j] > maskColors[2*j+1]) { - break; - } - } - if (j < numComps) { - break; - } - } - for (x1 = x0; x1 < width; ++x1) { - for (j = 0; j < numComps; ++j) { - if (line[x1*numComps+j] < maskColors[2*j] || - line[x1*numComps+j] > maskColors[2*j+1]) { - break; - } - } - if (j == numComps) { - break; - } - } - while (x0 < width || i < rects0Len) { - emitRect = addRect = extendRect = gFalse; - if (x0 >= width) { - emitRect = gTrue; - } else if (i >= rects0Len) { - addRect = gTrue; - } else if (rects0[i].x0 < x0) { - emitRect = gTrue; - } else if (x0 < rects0[i].x0) { - addRect = gTrue; - } else if (rects0[i].x1 == x1) { - extendRect = gTrue; - } else { - emitRect = addRect = gTrue; - } - if (emitRect) { - if (rectsOutLen == rectsOutSize) { - rectsOutSize *= 2; - rectsOut = (PSOutImgClipRect *)greallocn(rectsOut, rectsOutSize, - sizeof(PSOutImgClipRect)); - } - rectsOut[rectsOutLen].x0 = rects0[i].x0; - rectsOut[rectsOutLen].x1 = rects0[i].x1; - rectsOut[rectsOutLen].y0 = height - y - 1; - rectsOut[rectsOutLen].y1 = height - rects0[i].y0 - 1; - ++rectsOutLen; - ++i; - } - if (addRect || extendRect) { - if (rects1Len == rectsSize) { - rectsSize *= 2; - rects0 = (PSOutImgClipRect *)greallocn(rects0, rectsSize, - sizeof(PSOutImgClipRect)); - rects1 = (PSOutImgClipRect *)greallocn(rects1, rectsSize, - sizeof(PSOutImgClipRect)); - } - rects1[rects1Len].x0 = x0; - rects1[rects1Len].x1 = x1; - if (addRect) { - rects1[rects1Len].y0 = y; - } - if (extendRect) { - rects1[rects1Len].y0 = rects0[i].y0; - ++i; - } - ++rects1Len; - for (x0 = x1; x0 < width; ++x0) { - for (j = 0; j < numComps; ++j) { - if (line[x0*numComps+j] < maskColors[2*j] || - line[x0*numComps+j] > maskColors[2*j+1]) { - break; - } - } - if (j < numComps) { - break; - } - } - for (x1 = x0; x1 < width; ++x1) { - for (j = 0; j < numComps; ++j) { - if (line[x1*numComps+j] < maskColors[2*j] || - line[x1*numComps+j] > maskColors[2*j+1]) { - break; - } - } - if (j == numComps) { - break; - } - } - } - } - rectsTmp = rects0; - rects0 = rects1; - rects1 = rectsTmp; - i = rects0Len; - rects0Len = rects1Len; - rects1Len = i; - } - for (i = 0; i < rects0Len; ++i) { - if (rectsOutLen == rectsOutSize) { - rectsOutSize *= 2; - rectsOut = (PSOutImgClipRect *)greallocn(rectsOut, rectsOutSize, - sizeof(PSOutImgClipRect)); - } - rectsOut[rectsOutLen].x0 = rects0[i].x0; - rectsOut[rectsOutLen].x1 = rects0[i].x1; - rectsOut[rectsOutLen].y0 = height - y - 1; - rectsOut[rectsOutLen].y1 = height - rects0[i].y0 - 1; - ++rectsOutLen; - } - if (rectsOutLen < 65536/4) { - writePSFmt("{0:d} array 0\n", rectsOutLen * 4); - for (i = 0; i < rectsOutLen; ++i) { - writePSFmt("[{0:d} {1:d} {2:d} {3:d}] pr\n", - rectsOut[i].x0, rectsOut[i].y0, - rectsOut[i].x1 - rectsOut[i].x0, - rectsOut[i].y1 - rectsOut[i].y0); - } - writePSFmt("pop {0:d} {1:d} pdfImClip\n", width, height); - } else { - // would be over the limit of array size. - // make each rectangle path and clip. - writePS("gsave newpath\n"); - for (i = 0; i < rectsOutLen; ++i) { - writePSFmt("{0:.6g} {1:.6g} {2:.6g} {3:.6g} re\n", - ((double)rectsOut[i].x0)/width, - ((double)rectsOut[i].y0)/height, - ((double)(rectsOut[i].x1 - rectsOut[i].x0))/width, - ((double)(rectsOut[i].y1 - rectsOut[i].y0))/height); - } - writePS("clip\n"); - } - gfree(rectsOut); - gfree(rects0); - gfree(rects1); - delete imgStr; - str->close(); - - // explicit masking - } else if (maskStr) { - maskToClippingPath(maskStr, maskWidth, maskHeight, maskInvert); - } - - // color space - if (colorMap) { - dumpColorSpaceL2(colorMap->getColorSpace(), gFalse, gTrue, gFalse); - writePS(" setcolorspace\n"); - } - - // set up the image data - if (mode == psModeForm || inType3Char || preloadImagesForms) { - if (inlineImg) { - // create an array - str2 = new FixedLengthEncoder(str, len); - str2 = new RunLengthEncoder(str2); - if (useASCIIHex) { - str2 = new ASCIIHexEncoder(str2); - } else { - str2 = new ASCII85Encoder(str2); - } - str2->reset(); - col = 0; - writePS((char *)(useASCIIHex ? "[<" : "[<~")); - do { - do { - c = str2->getChar(); - } while (c == '\n' || c == '\r'); - if (c == (useASCIIHex ? '>' : '~') || c == EOF) { - break; - } - if (c == 'z') { - writePSChar(c); - ++col; - } else { - writePSChar(c); - ++col; - for (i = 1; i <= (useASCIIHex ? 1 : 4); ++i) { - do { - c = str2->getChar(); - } while (c == '\n' || c == '\r'); - if (c == (useASCIIHex ? '>' : '~') || c == EOF) { - break; - } - writePSChar(c); - ++col; - } - } - // each line is: "<~...data...~><eol>" - // so max data length = 255 - 6 = 249 - // chunks are 1 or 5 bytes each, so we have to stop at 245 - // but make it 240 just to be safe - if (col > 240) { - writePS((char *)(useASCIIHex ? ">\n<" : "~>\n<~")); - col = 0; - } - } while (c != (useASCIIHex ? '>' : '~') && c != EOF); - writePS((char *)(useASCIIHex ? ">\n" : "~>\n")); - // add an extra entry because the RunLengthDecode filter may - // read past the end - writePS("<>]\n"); - writePS("0\n"); - str2->close(); - delete str2; - } else { - // make sure the image is setup, it sometimes is not like on bug #17645 - setupImage(ref->getRef(), str, gFalse); - // set up to use the array already created by setupImages() - writePSFmt("ImData_{0:d}_{1:d} 0 0\n",ref->getRefNum(), ref->getRefGen()); - } - } - - // image dictionary - writePS("<<\n /ImageType 1\n"); - - // width, height, matrix, bits per component - writePSFmt(" /Width {0:d}\n", width); - writePSFmt(" /Height {0:d}\n", height); - writePSFmt(" /ImageMatrix [{0:d} 0 0 {1:d} 0 {2:d}]\n", - width, -height, height); - if (colorMap && colorMap->getColorSpace()->getMode() == csDeviceN) { - writePS(" /BitsPerComponent 8\n"); - } else { - writePSFmt(" /BitsPerComponent {0:d}\n", - colorMap ? colorMap->getBits() : 1); - } - - // decode - if (colorMap) { - writePS(" /Decode ["); - if ((level == psLevel2Sep || level == psLevel3Sep) && - colorMap->getColorSpace()->getMode() == csSeparation) { - // this matches up with the code in the pdfImSep operator - n = (1 << colorMap->getBits()) - 1; - writePSFmt("{0:.4g} {1:.4g}", colorMap->getDecodeLow(0) * n, - colorMap->getDecodeHigh(0) * n); - } else if (colorMap->getColorSpace()->getMode() == csDeviceN) { - numComps = ((GfxDeviceNColorSpace *)colorMap->getColorSpace())-> - getAlt()->getNComps(); - for (i = 0; i < numComps; ++i) { - if (i > 0) { - writePS(" "); - } - writePS("0 1"); - } - } else { - numComps = colorMap->getNumPixelComps(); - for (i = 0; i < numComps; ++i) { - if (i > 0) { - writePS(" "); - } - writePSFmt("{0:.4g} {1:.4g}", - colorMap->getDecodeLow(i), colorMap->getDecodeHigh(i)); - } - } - writePS("]\n"); - } else { - writePSFmt(" /Decode [{0:d} {1:d}]\n", invert ? 1 : 0, invert ? 0 : 1); - } - - // data source - if (mode == psModeForm || inType3Char || preloadImagesForms) { - if (inlineImg) { - writePS(" /DataSource { pdfImStr }\n"); - } else { - writePS(" /DataSource { dup 65535 ge { pop 1 add 0 } if 2 index 2" - " index get 1 index get exch 1 add exch }\n"); - } - } else { - writePS(" /DataSource currentfile\n"); - } - - // filters - if ((mode == psModeForm || inType3Char || preloadImagesForms) && - uncompressPreloadedImages) { - s = NULL; - useRLE = gFalse; - useCompressed = gFalse; - useASCII = gFalse; - } else { - s = str->getPSFilter(level < psLevel2 ? 1 : level < psLevel3 ? 2 : 3, - " "); - if ((colorMap && colorMap->getColorSpace()->getMode() == csDeviceN) || - inlineImg || !s) { - useRLE = gTrue; - useASCII = !(mode == psModeForm || inType3Char || preloadImagesForms); - useCompressed = gFalse; - } else { - useRLE = gFalse; - useASCII = str->isBinary() && - !(mode == psModeForm || inType3Char || preloadImagesForms); - useCompressed = gTrue; - } - } - if (useASCII) { - writePSFmt(" /ASCII{0:s}Decode filter\n", - useASCIIHex ? "Hex" : "85"); - } - if (useRLE) { - writePS(" /RunLengthDecode filter\n"); - } - if (useCompressed) { - writePS(s->getCString()); - } - if (s) { - delete s; - } - - if (mode == psModeForm || inType3Char || preloadImagesForms) { - - // end of image dictionary - writePSFmt(">>\n{0:s}\n", colorMap ? "image" : "imagemask"); - - // get rid of the array and index - if (!inlineImg) writePS("pop "); - writePS("pop pop\n"); - - } else { - - // cut off inline image streams at appropriate length - if (inlineImg) { - str = new FixedLengthEncoder(str, len); - } else if (useCompressed) { - str = str->getUndecodedStream(); - } - - // recode DeviceN data - if (colorMap && colorMap->getColorSpace()->getMode() == csDeviceN) { - str = new DeviceNRecoder(str, width, height, colorMap); - } - - // add RunLengthEncode and ASCIIHex/85 encode filters - if (useRLE) { - str = new RunLengthEncoder(str); - } - if (useASCII) { - if (useASCIIHex) { - str = new ASCIIHexEncoder(str); - } else { - str = new ASCII85Encoder(str); - } - } - - // end of image dictionary - writePS(">>\n"); -#if OPI_SUPPORT - if (opi13Nest) { - if (inlineImg) { - // this can't happen -- OPI dictionaries are in XObjects - error(errSyntaxError, -1, "OPI in inline image"); - n = 0; - } else { - // need to read the stream to count characters -- the length - // is data-dependent (because of ASCII and RLE filters) - str->reset(); - n = 0; - while ((c = str->getChar()) != EOF) { - ++n; - } - str->close(); - } - // +6/7 for "pdfIm\n" / "pdfImM\n" - // +8 for newline + trailer - n += colorMap ? 14 : 15; - writePSFmt("%%BeginData: {0:d} Hex Bytes\n", n); - } -#endif - if ((level == psLevel2Sep || level == psLevel3Sep) && colorMap && - colorMap->getColorSpace()->getMode() == csSeparation && colorMap->getBits() == 8) { - color.c[0] = gfxColorComp1; - sepCS = (GfxSeparationColorSpace *)colorMap->getColorSpace(); - sepCS->getCMYK(&color, &cmyk); - writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} ({4:t}) pdfImSep\n", - colToDbl(cmyk.c), colToDbl(cmyk.m), - colToDbl(cmyk.y), colToDbl(cmyk.k), - sepCS->getName()); - } else { - writePSFmt("{0:s}\n", colorMap ? "pdfIm" : "pdfImM"); - } - - // copy the stream data - str->reset(); - i = 0; - while ((c = str->getChar()) != EOF) { - dataBuf[i++] = c; - if (i >= (int)sizeof(dataBuf)) { - writePSBuf(dataBuf, i); - i = 0; - } - } - if (i > 0) { - writePSBuf(dataBuf, i); - } - str->close(); - - // add newline and trailer to the end - writePSChar('\n'); - writePS("%-EOD-\n"); -#if OPI_SUPPORT - if (opi13Nest) { - writePS("%%EndData\n"); - } -#endif - - // delete encoders - if (useRLE || useASCII || inlineImg) { - delete str; - } - } - - if ((maskColors && colorMap && !inlineImg) || maskStr) { - if (rectsOutLen < 65536/4) { - writePS("pdfImClipEnd\n"); - } else { - writePS("grestore\n"); - } - } -} - -//~ this doesn't currently support OPI -void PSOutputDev::doImageL3(Object *ref, GfxImageColorMap *colorMap, - GBool invert, GBool inlineImg, - Stream *str, int width, int height, int len, - int *maskColors, Stream *maskStr, - int maskWidth, int maskHeight, GBool maskInvert) { - Stream *str2; - GooString *s; - int n, numComps; - GBool useRLE, useASCII, useCompressed; - GBool maskUseRLE, maskUseASCII, maskUseCompressed; - GooString *maskFilters; - GfxSeparationColorSpace *sepCS; - GfxColor color; - GfxCMYK cmyk; - int c; - int col, i; - - useRLE = useASCII = useCompressed = gFalse; // make gcc happy - maskUseRLE = maskUseASCII = maskUseCompressed = gFalse; // make gcc happy - maskFilters = NULL; // make gcc happy - - // explicit masking - if (maskStr) { - - // mask data source - if ((mode == psModeForm || inType3Char || preloadImagesForms) && - uncompressPreloadedImages) { - s = NULL; - maskUseRLE = gFalse; - maskUseCompressed = gFalse; - maskUseASCII = gFalse; - } else { - s = maskStr->getPSFilter(3, " "); - if (!s) { - maskUseRLE = gTrue; - maskUseASCII = !(mode == psModeForm || inType3Char || preloadImagesForms); - maskUseCompressed = gFalse; - } else { - maskUseRLE = gFalse; - maskUseASCII = maskStr->isBinary() && - !(mode == psModeForm || inType3Char || preloadImagesForms); - maskUseCompressed = gTrue; - } - } - maskFilters = new GooString(); - if (maskUseASCII) { - maskFilters->appendf(" /ASCII{0:s}Decode filter\n", - useASCIIHex ? "Hex" : "85"); - } - if (maskUseRLE) { - maskFilters->append(" /RunLengthDecode filter\n"); - } - if (maskUseCompressed) { - maskFilters->append(s); - } - if (s) { - delete s; - } - if (mode == psModeForm || inType3Char || preloadImagesForms) { - writePSFmt("MaskData_{0:d}_{1:d} pdfMaskInit\n", - ref->getRefNum(), ref->getRefGen()); - } else { - writePS("currentfile\n"); - writePS(maskFilters->getCString()); - writePS("pdfMask\n"); - - // add RunLengthEncode and ASCIIHex/85 encode filters - if (maskUseCompressed) { - maskStr = maskStr->getUndecodedStream(); - } - if (maskUseRLE) { - maskStr = new RunLengthEncoder(maskStr); - } - if (maskUseASCII) { - if (useASCIIHex) { - maskStr = new ASCIIHexEncoder(maskStr); - } else { - maskStr = new ASCII85Encoder(maskStr); - } - } - - // copy the stream data - maskStr->reset(); - while ((c = maskStr->getChar()) != EOF) { - writePSChar(c); - } - maskStr->close(); - writePSChar('\n'); - writePS("%-EOD-\n"); - - // delete encoders - if (maskUseRLE || maskUseASCII) { - delete maskStr; - } - } - } - - // color space - if (colorMap) { - dumpColorSpaceL2(colorMap->getColorSpace(), gFalse, gTrue, gFalse); - writePS(" setcolorspace\n"); - } - - // set up the image data - if (mode == psModeForm || inType3Char || preloadImagesForms) { - if (inlineImg) { - // create an array - str2 = new FixedLengthEncoder(str, len); - str2 = new RunLengthEncoder(str2); - if (useASCIIHex) { - str2 = new ASCIIHexEncoder(str2); - } else { - str2 = new ASCII85Encoder(str2); - } - str2->reset(); - col = 0; - writePS((char *)(useASCIIHex ? "[<" : "[<~")); - do { - do { - c = str2->getChar(); - } while (c == '\n' || c == '\r'); - if (c == (useASCIIHex ? '>' : '~') || c == EOF) { - break; - } - if (c == 'z') { - writePSChar(c); - ++col; - } else { - writePSChar(c); - ++col; - for (i = 1; i <= (useASCIIHex ? 1 : 4); ++i) { - do { - c = str2->getChar(); - } while (c == '\n' || c == '\r'); - if (c == (useASCIIHex ? '>' : '~') || c == EOF) { - break; - } - writePSChar(c); - ++col; - } - } - // each line is: "<~...data...~><eol>" - // so max data length = 255 - 6 = 249 - // chunks are 1 or 5 bytes each, so we have to stop at 245 - // but make it 240 just to be safe - if (col > 240) { - writePS((char *)(useASCIIHex ? ">\n<" : "~>\n<~")); - col = 0; - } - } while (c != (useASCIIHex ? '>' : '~') && c != EOF); - writePS((char *)(useASCIIHex ? ">\n" : "~>\n")); - // add an extra entry because the RunLengthDecode filter may - // read past the end - writePS("<>]\n"); - writePS("0\n"); - str2->close(); - delete str2; - } else { - // make sure the image is setup, it sometimes is not like on bug #17645 - setupImage(ref->getRef(), str, gFalse); - // set up to use the array already created by setupImages() - writePSFmt("ImData_{0:d}_{1:d} 0 0\n", ref->getRefNum(), ref->getRefGen()); - } - } - - // explicit masking - if (maskStr) { - writePS("<<\n /ImageType 3\n"); - writePS(" /InterleaveType 3\n"); - writePS(" /DataDict\n"); - } - - // image (data) dictionary - writePSFmt("<<\n /ImageType {0:d}\n", (maskColors && colorMap) ? 4 : 1); - - // color key masking - if (maskColors && colorMap) { - writePS(" /MaskColor [\n"); - numComps = colorMap->getNumPixelComps(); - for (i = 0; i < 2 * numComps; i += 2) { - writePSFmt(" {0:d} {1:d}\n", maskColors[i], maskColors[i+1]); - } - writePS(" ]\n"); - } - - // width, height, matrix, bits per component - writePSFmt(" /Width {0:d}\n", width); - writePSFmt(" /Height {0:d}\n", height); - writePSFmt(" /ImageMatrix [{0:d} 0 0 {1:d} 0 {2:d}]\n", - width, -height, height); - if (colorMap && colorMap->getColorSpace()->getMode() == csDeviceN) { - writePS(" /BitsPerComponent 8\n"); - } else { - writePSFmt(" /BitsPerComponent {0:d}\n", - colorMap ? colorMap->getBits() : 1); - } - - // decode - if (colorMap) { - writePS(" /Decode ["); - if ((level == psLevel2Sep || level == psLevel3Sep) && - colorMap->getColorSpace()->getMode() == csSeparation) { - // this matches up with the code in the pdfImSep operator - n = (1 << colorMap->getBits()) - 1; - writePSFmt("{0:.4g} {1:.4g}", colorMap->getDecodeLow(0) * n, - colorMap->getDecodeHigh(0) * n); - } else { - numComps = colorMap->getNumPixelComps(); - for (i = 0; i < numComps; ++i) { - if (i > 0) { - writePS(" "); - } - writePSFmt("{0:.4g} {1:.4g}", colorMap->getDecodeLow(i), - colorMap->getDecodeHigh(i)); - } - } - writePS("]\n"); - } else { - writePSFmt(" /Decode [{0:d} {1:d}]\n", invert ? 1 : 0, invert ? 0 : 1); - } - - // data source - if (mode == psModeForm || inType3Char || preloadImagesForms) { - if (inlineImg) { - writePS(" /DataSource { pdfImStr }\n"); - } else { - writePS(" /DataSource { dup 65535 ge { pop 1 add 0 } if 2 index 2" - " index get 1 index get exch 1 add exch }\n"); - } - } else { - writePS(" /DataSource currentfile\n"); - } - - // filters - if ((mode == psModeForm || inType3Char || preloadImagesForms) && - uncompressPreloadedImages) { - s = NULL; - useRLE = gFalse; - useCompressed = gFalse; - useASCII = gFalse; - } else { - s = str->getPSFilter(level < psLevel2 ? 1 : level < psLevel3 ? 2 : 3, - " "); - if ((colorMap && colorMap->getColorSpace()->getMode() == csDeviceN) || - inlineImg || !s) { - useRLE = gTrue; - useASCII = !(mode == psModeForm || inType3Char || preloadImagesForms); - useCompressed = gFalse; - } else { - useRLE = gFalse; - useASCII = str->isBinary() && - !(mode == psModeForm || inType3Char || preloadImagesForms); - useCompressed = gTrue; - } - } - if (useASCII) { - writePSFmt(" /ASCII{0:s}Decode filter\n", - useASCIIHex ? "Hex" : "85"); - } - if (useRLE) { - writePS(" /RunLengthDecode filter\n"); - } - if (useCompressed) { - writePS(s->getCString()); - } - if (s) { - delete s; - } - - // end of image (data) dictionary - writePS(">>\n"); - - // explicit masking - if (maskStr) { - writePS(" /MaskDict\n"); - writePS("<<\n"); - writePS(" /ImageType 1\n"); - writePSFmt(" /Width {0:d}\n", maskWidth); - writePSFmt(" /Height {0:d}\n", maskHeight); - writePSFmt(" /ImageMatrix [{0:d} 0 0 {1:d} 0 {2:d}]\n", - maskWidth, -maskHeight, maskHeight); - writePS(" /BitsPerComponent 1\n"); - writePSFmt(" /Decode [{0:d} {1:d}]\n", - maskInvert ? 1 : 0, maskInvert ? 0 : 1); - - // mask data source - if (mode == psModeForm || inType3Char || preloadImagesForms) { - writePS(" /DataSource {pdfMaskSrc}\n"); - writePS(maskFilters->getCString()); - } else { - writePS(" /DataSource maskStream\n"); - } - delete maskFilters; - - writePS(">>\n"); - writePS(">>\n"); - } - - if (mode == psModeForm || inType3Char || preloadImagesForms) { - - // image command - writePSFmt("{0:s}\n", colorMap ? "image" : "imagemask"); - - } else { - - if ((level == psLevel2Sep || level == psLevel3Sep) && colorMap && - colorMap->getColorSpace()->getMode() == csSeparation && colorMap->getBits() == 8) { - color.c[0] = gfxColorComp1; - sepCS = (GfxSeparationColorSpace *)colorMap->getColorSpace(); - sepCS->getCMYK(&color, &cmyk); - writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} ({4:t}) pdfImSep\n", - colToDbl(cmyk.c), colToDbl(cmyk.m), - colToDbl(cmyk.y), colToDbl(cmyk.k), - sepCS->getName()); - } else { - writePSFmt("{0:s}\n", colorMap ? "pdfIm" : "pdfImM"); - } - - } - - // get rid of the array and index - if (mode == psModeForm || inType3Char || preloadImagesForms) { - if (!inlineImg) writePS("pop "); - writePS("pop pop\n"); - - // image data - } else { - - // cut off inline image streams at appropriate length - if (inlineImg) { - str = new FixedLengthEncoder(str, len); - } else if (useCompressed) { - str = str->getUndecodedStream(); - } - - // add RunLengthEncode and ASCIIHex/85 encode filters - if (useRLE) { - str = new RunLengthEncoder(str); - } - if (useASCII) { - if (useASCIIHex) { - str = new ASCIIHexEncoder(str); - } else { - str = new ASCII85Encoder(str); - } - } - - // copy the stream data - str->reset(); - while ((c = str->getChar()) != EOF) { - writePSChar(c); - } - str->close(); - - // add newline and trailer to the end - writePSChar('\n'); - writePS("%-EOD-\n"); - - // delete encoders - if (useRLE || useASCII || inlineImg) { - delete str; - } - } - - // close the mask stream - if (maskStr) { - if (!(mode == psModeForm || inType3Char || preloadImagesForms)) { - writePS("pdfMaskEnd\n"); - } - } -} - -void PSOutputDev::dumpColorSpaceL2(GfxColorSpace *colorSpace, - GBool genXform, GBool updateColors, - GBool map01) { - GfxCalGrayColorSpace *calGrayCS; - GfxCalRGBColorSpace *calRGBCS; - GfxLabColorSpace *labCS; - GfxIndexedColorSpace *indexedCS; - GfxSeparationColorSpace *separationCS; - GfxDeviceNColorSpace *deviceNCS; - GfxColorSpace *baseCS; - Guchar *lookup, *p; - double x[gfxColorMaxComps], y[gfxColorMaxComps]; - double low[gfxColorMaxComps], range[gfxColorMaxComps]; - GfxColor color; - GfxCMYK cmyk; - Function *func; - int n, numComps, numAltComps; - int byte; - int i, j, k; - - switch (colorSpace->getMode()) { - - case csDeviceGray: - writePS("/DeviceGray"); - if (genXform) { - writePS(" {}"); - } - if (updateColors) { - processColors |= psProcessBlack; - } - break; - - case csCalGray: - calGrayCS = (GfxCalGrayColorSpace *)colorSpace; - writePS("[/CIEBasedA <<\n"); - writePSFmt(" /DecodeA {{{0:.4g} exp}} bind\n", calGrayCS->getGamma()); - writePSFmt(" /MatrixA [{0:.4g} {1:.4g} {2:.4g}]\n", - calGrayCS->getWhiteX(), calGrayCS->getWhiteY(), - calGrayCS->getWhiteZ()); - writePSFmt(" /WhitePoint [{0:.4g} {1:.4g} {2:.4g}]\n", - calGrayCS->getWhiteX(), calGrayCS->getWhiteY(), - calGrayCS->getWhiteZ()); - writePSFmt(" /BlackPoint [{0:.4g} {1:.4g} {2:.4g}]\n", - calGrayCS->getBlackX(), calGrayCS->getBlackY(), - calGrayCS->getBlackZ()); - writePS(">>]"); - if (genXform) { - writePS(" {}"); - } - if (updateColors) { - processColors |= psProcessBlack; - } - break; - - case csDeviceRGB: - writePS("/DeviceRGB"); - if (genXform) { - writePS(" {}"); - } - if (updateColors) { - processColors |= psProcessCMYK; - } - break; - - case csCalRGB: - calRGBCS = (GfxCalRGBColorSpace *)colorSpace; - writePS("[/CIEBasedABC <<\n"); - writePSFmt(" /DecodeABC [{{{0:.4g} exp}} bind {{{1:.4g} exp}} bind {{{2:.4g} exp}} bind]\n", - calRGBCS->getGammaR(), calRGBCS->getGammaG(), - calRGBCS->getGammaB()); - writePSFmt(" /MatrixABC [{0:.4g} {1:.4g} {2:.4g} {3:.4g} {4:.4g} {5:.4g} {6:.4g} {7:.4g} {8:.4g}]\n", - calRGBCS->getMatrix()[0], calRGBCS->getMatrix()[1], - calRGBCS->getMatrix()[2], calRGBCS->getMatrix()[3], - calRGBCS->getMatrix()[4], calRGBCS->getMatrix()[5], - calRGBCS->getMatrix()[6], calRGBCS->getMatrix()[7], - calRGBCS->getMatrix()[8]); - writePSFmt(" /WhitePoint [{0:.4g} {1:.4g} {2:.4g}]\n", - calRGBCS->getWhiteX(), calRGBCS->getWhiteY(), - calRGBCS->getWhiteZ()); - writePSFmt(" /BlackPoint [{0:.4g} {1:.4g} {2:.4g}]\n", - calRGBCS->getBlackX(), calRGBCS->getBlackY(), - calRGBCS->getBlackZ()); - writePS(">>]"); - if (genXform) { - writePS(" {}"); - } - if (updateColors) { - processColors |= psProcessCMYK; - } - break; - - case csDeviceCMYK: - writePS("/DeviceCMYK"); - if (genXform) { - writePS(" {}"); - } - if (updateColors) { - processColors |= psProcessCMYK; - } - break; - - case csLab: - labCS = (GfxLabColorSpace *)colorSpace; - writePS("[/CIEBasedABC <<\n"); - if (map01) { - writePS(" /RangeABC [0 1 0 1 0 1]\n"); - writePSFmt(" /DecodeABC [{{100 mul 16 add 116 div}} bind {{{0:.4g} mul {1:.4g} add}} bind {{{2:.4g} mul {3:.4g} add}} bind]\n", - (labCS->getAMax() - labCS->getAMin()) / 500.0, - labCS->getAMin() / 500.0, - (labCS->getBMax() - labCS->getBMin()) / 200.0, - labCS->getBMin() / 200.0); - } else { - writePSFmt(" /RangeABC [0 100 {0:.4g} {1:.4g} {2:.4g} {3:.4g}]\n", - labCS->getAMin(), labCS->getAMax(), - labCS->getBMin(), labCS->getBMax()); - writePS(" /DecodeABC [{16 add 116 div} bind {500 div} bind {200 div} bind]\n"); - } - writePS(" /MatrixABC [1 1 1 1 0 0 0 0 -1]\n"); - writePS(" /DecodeLMN\n"); - writePS(" [{dup 6 29 div ge {dup dup mul mul}\n"); - writePSFmt(" {{4 29 div sub 108 841 div mul }} ifelse {0:.4g} mul}} bind\n", - labCS->getWhiteX()); - writePS(" {dup 6 29 div ge {dup dup mul mul}\n"); - writePSFmt(" {{4 29 div sub 108 841 div mul }} ifelse {0:.4g} mul}} bind\n", - labCS->getWhiteY()); - writePS(" {dup 6 29 div ge {dup dup mul mul}\n"); - writePSFmt(" {{4 29 div sub 108 841 div mul }} ifelse {0:.4g} mul}} bind]\n", - labCS->getWhiteZ()); - writePSFmt(" /WhitePoint [{0:.4g} {1:.4g} {2:.4g}]\n", - labCS->getWhiteX(), labCS->getWhiteY(), labCS->getWhiteZ()); - writePSFmt(" /BlackPoint [{0:.4g} {1:.4g} {2:.4g}]\n", - labCS->getBlackX(), labCS->getBlackY(), labCS->getBlackZ()); - writePS(">>]"); - if (genXform) { - writePS(" {}"); - } - if (updateColors) { - processColors |= psProcessCMYK; - } - break; - - case csICCBased: - // there is no transform function to the alternate color space, so - // we can use it directly - dumpColorSpaceL2(((GfxICCBasedColorSpace *)colorSpace)->getAlt(), - genXform, updateColors, gFalse); - break; - - case csIndexed: - indexedCS = (GfxIndexedColorSpace *)colorSpace; - baseCS = indexedCS->getBase(); - writePS("[/Indexed "); - dumpColorSpaceL2(baseCS, gFalse, gFalse, gTrue); - n = indexedCS->getIndexHigh(); - numComps = baseCS->getNComps(); - lookup = indexedCS->getLookup(); - writePSFmt(" {0:d} <\n", n); - if (baseCS->getMode() == csDeviceN && level != psLevel3 && level != psLevel3Sep) { - func = ((GfxDeviceNColorSpace *)baseCS)->getTintTransformFunc(); - baseCS->getDefaultRanges(low, range, indexedCS->getIndexHigh()); - if (((GfxDeviceNColorSpace *)baseCS)->getAlt()->getMode() == csLab) { - labCS = (GfxLabColorSpace *)((GfxDeviceNColorSpace *)baseCS)->getAlt(); - } else { - labCS = NULL; - } - numAltComps = ((GfxDeviceNColorSpace *)baseCS)->getAlt()->getNComps(); - p = lookup; - for (i = 0; i <= n; i += 8) { - writePS(" "); - for (j = i; j < i+8 && j <= n; ++j) { - for (k = 0; k < numComps; ++k) { - x[k] = low[k] + (*p++ / 255.0) * range[k]; - } - func->transform(x, y); - if (labCS) { - y[0] /= 100.0; - y[1] = (y[1] - labCS->getAMin()) / - (labCS->getAMax() - labCS->getAMin()); - y[2] = (y[2] - labCS->getBMin()) / - (labCS->getBMax() - labCS->getBMin()); - } - for (k = 0; k < numAltComps; ++k) { - byte = (int)(y[k] * 255 + 0.5); - if (byte < 0) { - byte = 0; - } else if (byte > 255) { - byte = 255; - } - writePSFmt("{0:02x}", byte); - } - if (updateColors) { - color.c[0] = dblToCol(j); - indexedCS->getCMYK(&color, &cmyk); - addProcessColor(colToDbl(cmyk.c), colToDbl(cmyk.m), - colToDbl(cmyk.y), colToDbl(cmyk.k)); - } - } - writePS("\n"); - } - } else { - for (i = 0; i <= n; i += 8) { - writePS(" "); - for (j = i; j < i+8 && j <= n; ++j) { - for (k = 0; k < numComps; ++k) { - writePSFmt("{0:02x}", lookup[j * numComps + k]); - } - if (updateColors) { - color.c[0] = dblToCol(j); - indexedCS->getCMYK(&color, &cmyk); - addProcessColor(colToDbl(cmyk.c), colToDbl(cmyk.m), - colToDbl(cmyk.y), colToDbl(cmyk.k)); - } - } - writePS("\n"); - } - } - writePS(">]"); - if (genXform) { - writePS(" {}"); - } - break; - - case csSeparation: - separationCS = (GfxSeparationColorSpace *)colorSpace; - writePS("[/Separation "); - writePSString(separationCS->getName()); - writePS(" "); - dumpColorSpaceL2(separationCS->getAlt(), gFalse, gFalse, gFalse); - writePS("\n"); - cvtFunction(separationCS->getFunc()); - writePS("]"); - if (genXform) { - writePS(" {}"); - } - if (updateColors) { - addCustomColor(separationCS); - } - break; - - case csDeviceN: - deviceNCS = (GfxDeviceNColorSpace *)colorSpace; - if (level == psLevel3 || level == psLevel3Sep) { - writePS("[/DeviceN\n"); - writePS(" [ "); - for (i = 0; i < deviceNCS->getNComps(); i++) { - writePSString(deviceNCS->getColorantName(i)); - writePS(" "); - } - writePS("]\n"); - dumpColorSpaceL2(deviceNCS->getAlt(), gFalse, updateColors, gFalse); - writePS("\n"); - cvtFunction(deviceNCS->getTintTransformFunc(), map01 && deviceNCS->getAlt()->getMode() == csLab); - writePS("]\n"); - if (genXform) { - writePS(" {}"); - } - } else { - // DeviceN color spaces are a Level 3 PostScript feature. - dumpColorSpaceL2(deviceNCS->getAlt(), gFalse, updateColors, map01); - if (genXform) { - writePS(" "); - cvtFunction(deviceNCS->getTintTransformFunc()); - } - } - break; - - case csPattern: - //~ unimplemented - break; - } -} - -#if OPI_SUPPORT -void PSOutputDev::opiBegin(GfxState *state, Dict *opiDict) { - Object dict; - - if (generateOPI) { - opiDict->lookup("2.0", &dict); - if (dict.isDict()) { - opiBegin20(state, dict.getDict()); - dict.free(); - } else { - dict.free(); - opiDict->lookup("1.3", &dict); - if (dict.isDict()) { - opiBegin13(state, dict.getDict()); - } - dict.free(); - } - } -} - -void PSOutputDev::opiBegin20(GfxState *state, Dict *dict) { - Object obj1, obj2, obj3, obj4; - double width, height, left, right, top, bottom; - int w, h; - int i; - - writePS("%%BeginOPI: 2.0\n"); - writePS("%%Distilled\n"); - - dict->lookup("F", &obj1); - if (getFileSpecName(&obj1, &obj2)) { - writePSFmt("%%ImageFileName: {0:t}\n", obj2.getString()); - obj2.free(); - } - obj1.free(); - - dict->lookup("MainImage", &obj1); - if (obj1.isString()) { - writePSFmt("%%MainImage: {0:t}\n", obj1.getString()); - } - obj1.free(); - - //~ ignoring 'Tags' entry - //~ need to use writePSString() and deal with >255-char lines - - dict->lookup("Size", &obj1); - if (obj1.isArray() && obj1.arrayGetLength() == 2) { - obj1.arrayGet(0, &obj2); - width = obj2.getNum(); - obj2.free(); - obj1.arrayGet(1, &obj2); - height = obj2.getNum(); - obj2.free(); - writePSFmt("%%ImageDimensions: {0:.6g} {1:.6g}\n", width, height); - } - obj1.free(); - - dict->lookup("CropRect", &obj1); - if (obj1.isArray() && obj1.arrayGetLength() == 4) { - obj1.arrayGet(0, &obj2); - left = obj2.getNum(); - obj2.free(); - obj1.arrayGet(1, &obj2); - top = obj2.getNum(); - obj2.free(); - obj1.arrayGet(2, &obj2); - right = obj2.getNum(); - obj2.free(); - obj1.arrayGet(3, &obj2); - bottom = obj2.getNum(); - obj2.free(); - writePSFmt("%%ImageCropRect: {0:.6g} {1:.6g} {2:.6g} {3:.6g}\n", - left, top, right, bottom); - } - obj1.free(); - - dict->lookup("Overprint", &obj1); - if (obj1.isBool()) { - writePSFmt("%%ImageOverprint: {0:s}\n", obj1.getBool() ? "true" : "false"); - } - obj1.free(); - - dict->lookup("Inks", &obj1); - if (obj1.isName()) { - writePSFmt("%%ImageInks: {0:s}\n", obj1.getName()); - } else if (obj1.isArray() && obj1.arrayGetLength() >= 1) { - obj1.arrayGet(0, &obj2); - if (obj2.isName()) { - writePSFmt("%%ImageInks: {0:s} {1:d}", - obj2.getName(), (obj1.arrayGetLength() - 1) / 2); - for (i = 1; i+1 < obj1.arrayGetLength(); i += 2) { - obj1.arrayGet(i, &obj3); - obj1.arrayGet(i+1, &obj4); - if (obj3.isString() && obj4.isNum()) { - writePS(" "); - writePSString(obj3.getString()); - writePSFmt(" {0:.6g}", obj4.getNum()); - } - obj3.free(); - obj4.free(); - } - writePS("\n"); - } - obj2.free(); - } - obj1.free(); - - writePS("gsave\n"); - - writePS("%%BeginIncludedImage\n"); - - dict->lookup("IncludedImageDimensions", &obj1); - if (obj1.isArray() && obj1.arrayGetLength() == 2) { - obj1.arrayGet(0, &obj2); - w = obj2.getInt(); - obj2.free(); - obj1.arrayGet(1, &obj2); - h = obj2.getInt(); - obj2.free(); - writePSFmt("%%IncludedImageDimensions: {0:d} {1:d}\n", w, h); - } - obj1.free(); - - dict->lookup("IncludedImageQuality", &obj1); - if (obj1.isNum()) { - writePSFmt("%%IncludedImageQuality: {0:.6g}\n", obj1.getNum()); - } - obj1.free(); - - ++opi20Nest; -} - -void PSOutputDev::opiBegin13(GfxState *state, Dict *dict) { - Object obj1, obj2; - int left, right, top, bottom, samples, bits, width, height; - double c, m, y, k; - double llx, lly, ulx, uly, urx, ury, lrx, lry; - double tllx, tlly, tulx, tuly, turx, tury, tlrx, tlry; - double horiz, vert; - int i, j; - - writePS("save\n"); - writePS("/opiMatrix2 matrix currentmatrix def\n"); - writePS("opiMatrix setmatrix\n"); - - dict->lookup("F", &obj1); - if (getFileSpecName(&obj1, &obj2)) { - writePSFmt("%ALDImageFileName: {0:t}\n", obj2.getString()); - obj2.free(); - } - obj1.free(); - - dict->lookup("CropRect", &obj1); - if (obj1.isArray() && obj1.arrayGetLength() == 4) { - obj1.arrayGet(0, &obj2); - left = obj2.getInt(); - obj2.free(); - obj1.arrayGet(1, &obj2); - top = obj2.getInt(); - obj2.free(); - obj1.arrayGet(2, &obj2); - right = obj2.getInt(); - obj2.free(); - obj1.arrayGet(3, &obj2); - bottom = obj2.getInt(); - obj2.free(); - writePSFmt("%ALDImageCropRect: {0:d} {1:d} {2:d} {3:d}\n", - left, top, right, bottom); - } - obj1.free(); - - dict->lookup("Color", &obj1); - if (obj1.isArray() && obj1.arrayGetLength() == 5) { - obj1.arrayGet(0, &obj2); - c = obj2.getNum(); - obj2.free(); - obj1.arrayGet(1, &obj2); - m = obj2.getNum(); - obj2.free(); - obj1.arrayGet(2, &obj2); - y = obj2.getNum(); - obj2.free(); - obj1.arrayGet(3, &obj2); - k = obj2.getNum(); - obj2.free(); - obj1.arrayGet(4, &obj2); - if (obj2.isString()) { - writePSFmt("%ALDImageColor: {0:.4g} {1:.4g} {2:.4g} {3:.4g} ", - c, m, y, k); - writePSString(obj2.getString()); - writePS("\n"); - } - obj2.free(); - } - obj1.free(); - - dict->lookup("ColorType", &obj1); - if (obj1.isName()) { - writePSFmt("%ALDImageColorType: {0:s}\n", obj1.getName()); - } - obj1.free(); - - //~ ignores 'Comments' entry - //~ need to handle multiple lines - - dict->lookup("CropFixed", &obj1); - if (obj1.isArray()) { - obj1.arrayGet(0, &obj2); - ulx = obj2.getNum(); - obj2.free(); - obj1.arrayGet(1, &obj2); - uly = obj2.getNum(); - obj2.free(); - obj1.arrayGet(2, &obj2); - lrx = obj2.getNum(); - obj2.free(); - obj1.arrayGet(3, &obj2); - lry = obj2.getNum(); - obj2.free(); - writePSFmt("%ALDImageCropFixed: {0:.6g} {1:.6g} {2:.6g} {3:.6g}\n", - ulx, uly, lrx, lry); - } - obj1.free(); - - dict->lookup("GrayMap", &obj1); - if (obj1.isArray()) { - writePS("%ALDImageGrayMap:"); - for (i = 0; i < obj1.arrayGetLength(); i += 16) { - if (i > 0) { - writePS("\n%%+"); - } - for (j = 0; j < 16 && i+j < obj1.arrayGetLength(); ++j) { - obj1.arrayGet(i+j, &obj2); - writePSFmt(" {0:d}", obj2.getInt()); - obj2.free(); - } - } - writePS("\n"); - } - obj1.free(); - - dict->lookup("ID", &obj1); - if (obj1.isString()) { - writePSFmt("%ALDImageID: {0:t}\n", obj1.getString()); - } - obj1.free(); - - dict->lookup("ImageType", &obj1); - if (obj1.isArray() && obj1.arrayGetLength() == 2) { - obj1.arrayGet(0, &obj2); - samples = obj2.getInt(); - obj2.free(); - obj1.arrayGet(1, &obj2); - bits = obj2.getInt(); - obj2.free(); - writePSFmt("%ALDImageType: {0:d} {1:d}\n", samples, bits); - } - obj1.free(); - - dict->lookup("Overprint", &obj1); - if (obj1.isBool()) { - writePSFmt("%ALDImageOverprint: {0:s}\n", - obj1.getBool() ? "true" : "false"); - } - obj1.free(); - - dict->lookup("Position", &obj1); - if (obj1.isArray() && obj1.arrayGetLength() == 8) { - obj1.arrayGet(0, &obj2); - llx = obj2.getNum(); - obj2.free(); - obj1.arrayGet(1, &obj2); - lly = obj2.getNum(); - obj2.free(); - obj1.arrayGet(2, &obj2); - ulx = obj2.getNum(); - obj2.free(); - obj1.arrayGet(3, &obj2); - uly = obj2.getNum(); - obj2.free(); - obj1.arrayGet(4, &obj2); - urx = obj2.getNum(); - obj2.free(); - obj1.arrayGet(5, &obj2); - ury = obj2.getNum(); - obj2.free(); - obj1.arrayGet(6, &obj2); - lrx = obj2.getNum(); - obj2.free(); - obj1.arrayGet(7, &obj2); - lry = obj2.getNum(); - obj2.free(); - opiTransform(state, llx, lly, &tllx, &tlly); - opiTransform(state, ulx, uly, &tulx, &tuly); - opiTransform(state, urx, ury, &turx, &tury); - opiTransform(state, lrx, lry, &tlrx, &tlry); - writePSFmt("%ALDImagePosition: {0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g} {6:.6g} {7:.6g}\n", - tllx, tlly, tulx, tuly, turx, tury, tlrx, tlry); - obj2.free(); - } - obj1.free(); - - dict->lookup("Resolution", &obj1); - if (obj1.isArray() && obj1.arrayGetLength() == 2) { - obj1.arrayGet(0, &obj2); - horiz = obj2.getNum(); - obj2.free(); - obj1.arrayGet(1, &obj2); - vert = obj2.getNum(); - obj2.free(); - writePSFmt("%ALDImageResoution: {0:.6g} {1:.6g}\n", horiz, vert); - obj2.free(); - } - obj1.free(); - - dict->lookup("Size", &obj1); - if (obj1.isArray() && obj1.arrayGetLength() == 2) { - obj1.arrayGet(0, &obj2); - width = obj2.getInt(); - obj2.free(); - obj1.arrayGet(1, &obj2); - height = obj2.getInt(); - obj2.free(); - writePSFmt("%ALDImageDimensions: {0:d} {1:d}\n", width, height); - } - obj1.free(); - - //~ ignoring 'Tags' entry - //~ need to use writePSString() and deal with >255-char lines - - dict->lookup("Tint", &obj1); - if (obj1.isNum()) { - writePSFmt("%ALDImageTint: {0:.6g}\n", obj1.getNum()); - } - obj1.free(); - - dict->lookup("Transparency", &obj1); - if (obj1.isBool()) { - writePSFmt("%ALDImageTransparency: {0:s}\n", - obj1.getBool() ? "true" : "false"); - } - obj1.free(); - - writePS("%%BeginObject: image\n"); - writePS("opiMatrix2 setmatrix\n"); - ++opi13Nest; -} - -// Convert PDF user space coordinates to PostScript default user space -// coordinates. This has to account for both the PDF CTM and the -// PSOutputDev page-fitting transform. -void PSOutputDev::opiTransform(GfxState *state, double x0, double y0, - double *x1, double *y1) { - double t; - - state->transform(x0, y0, x1, y1); - *x1 += tx; - *y1 += ty; - if (rotate == 90) { - t = *x1; - *x1 = -*y1; - *y1 = t; - } else if (rotate == 180) { - *x1 = -*x1; - *y1 = -*y1; - } else if (rotate == 270) { - t = *x1; - *x1 = *y1; - *y1 = -t; - } - *x1 *= xScale; - *y1 *= yScale; -} - -void PSOutputDev::opiEnd(GfxState *state, Dict *opiDict) { - Object dict; - - if (generateOPI) { - opiDict->lookup("2.0", &dict); - if (dict.isDict()) { - writePS("%%EndIncludedImage\n"); - writePS("%%EndOPI\n"); - writePS("grestore\n"); - --opi20Nest; - dict.free(); - } else { - dict.free(); - opiDict->lookup("1.3", &dict); - if (dict.isDict()) { - writePS("%%EndObject\n"); - writePS("restore\n"); - --opi13Nest; - } - dict.free(); - } - } -} -#endif // OPI_SUPPORT - -void PSOutputDev::type3D0(GfxState *state, double wx, double wy) { - writePSFmt("{0:.6g} {1:.6g} setcharwidth\n", wx, wy); - writePS("q\n"); - t3NeedsRestore = gTrue; -} - -void PSOutputDev::type3D1(GfxState *state, double wx, double wy, - double llx, double lly, double urx, double ury) { - t3WX = wx; - t3WY = wy; - t3LLX = llx; - t3LLY = lly; - t3URX = urx; - t3URY = ury; - t3String = new GooString(); - writePS("q\n"); - t3FillColorOnly = gTrue; - t3Cacheable = gTrue; - t3NeedsRestore = gTrue; -} - -void PSOutputDev::drawForm(Ref id) { - writePSFmt("f_{0:d}_{1:d}\n", id.num, id.gen); -} - -void PSOutputDev::psXObject(Stream *psStream, Stream *level1Stream) { - Stream *str; - int c; - - if ((level == psLevel1 || level == psLevel1Sep) && level1Stream) { - str = level1Stream; - } else { - str = psStream; - } - str->reset(); - while ((c = str->getChar()) != EOF) { - writePSChar(c); - } - str->close(); -} - -//~ can nextFunc be reset to 0 -- maybe at the start of each page? -//~ or maybe at the start of each color space / pattern? -void PSOutputDev::cvtFunction(Function *func, GBool invertPSFunction) { - SampledFunction *func0; - ExponentialFunction *func2; - StitchingFunction *func3; - PostScriptFunction *func4; - int thisFunc, m, n, nSamples, i, j, k; - - switch (func->getType()) { - - case -1: // identity - writePS("{}\n"); - break; - - case 0: // sampled - func0 = (SampledFunction *)func; - thisFunc = nextFunc++; - m = func0->getInputSize(); - n = func0->getOutputSize(); - nSamples = n; - for (i = 0; i < m; ++i) { - nSamples *= func0->getSampleSize(i); - } - writePSFmt("/xpdfSamples{0:d} [\n", thisFunc); - for (i = 0; i < nSamples; ++i) { - writePSFmt("{0:.6g}\n", func0->getSamples()[i]); - } - writePS("] def\n"); - writePSFmt("{{ {0:d} array {1:d} array {2:d} 2 roll\n", 2*m, m, m+2); - // [e01] [efrac] x0 x1 ... xm-1 - for (i = m-1; i >= 0; --i) { - // [e01] [efrac] x0 x1 ... xi - writePSFmt("{0:.6g} sub {1:.6g} mul {2:.6g} add\n", - func0->getDomainMin(i), - (func0->getEncodeMax(i) - func0->getEncodeMin(i)) / - (func0->getDomainMax(i) - func0->getDomainMin(i)), - func0->getEncodeMin(i)); - // [e01] [efrac] x0 x1 ... xi-1 xi' - writePSFmt("dup 0 lt {{ pop 0 }} {{ dup {0:d} gt {{ pop {1:d} }} if }} ifelse\n", - func0->getSampleSize(i) - 1, func0->getSampleSize(i) - 1); - // [e01] [efrac] x0 x1 ... xi-1 xi' - writePS("dup floor cvi exch dup ceiling cvi exch 2 index sub\n"); - // [e01] [efrac] x0 x1 ... xi-1 floor(xi') ceiling(xi') xi'-floor(xi') - writePSFmt("{0:d} index {1:d} 3 2 roll put\n", i+3, i); - // [e01] [efrac] x0 x1 ... xi-1 floor(xi') ceiling(xi') - writePSFmt("{0:d} index {1:d} 3 2 roll put\n", i+3, 2*i+1); - // [e01] [efrac] x0 x1 ... xi-1 floor(xi') - writePSFmt("{0:d} index {1:d} 3 2 roll put\n", i+2, 2*i); - // [e01] [efrac] x0 x1 ... xi-1 - } - // [e01] [efrac] - for (i = 0; i < n; ++i) { - // [e01] [efrac] y(0) ... y(i-1) - for (j = 0; j < (1<<m); ++j) { - // [e01] [efrac] y(0) ... y(i-1) s(0) s(1) ... s(j-1) - writePSFmt("xpdfSamples{0:d}\n", thisFunc); - k = m - 1; - writePSFmt("{0:d} index {1:d} get\n", i+j+2, 2 * k + ((j >> k) & 1)); - for (k = m - 2; k >= 0; --k) { - writePSFmt("{0:d} mul {1:d} index {2:d} get add\n", - func0->getSampleSize(k), - i + j + 3, - 2 * k + ((j >> k) & 1)); - } - if (n > 1) { - writePSFmt("{0:d} mul {1:d} add ", n, i); - } - writePS("get\n"); - } - // [e01] [efrac] y(0) ... y(i-1) s(0) s(1) ... s(2^m-1) - for (j = 0; j < m; ++j) { - // [e01] [efrac] y(0) ... y(i-1) s(0) s(1) ... s(2^(m-j)-1) - for (k = 0; k < (1 << (m - j)); k += 2) { - // [e01] [efrac] y(0) ... y(i-1) <k/2 s' values> <2^(m-j)-k s values> - writePSFmt("{0:d} index {1:d} get dup\n", - i + k/2 + (1 << (m-j)) - k, j); - writePS("3 2 roll mul exch 1 exch sub 3 2 roll mul add\n"); - writePSFmt("{0:d} 1 roll\n", k/2 + (1 << (m-j)) - k - 1); - } - // [e01] [efrac] s'(0) s'(1) ... s(2^(m-j-1)-1) - } - // [e01] [efrac] y(0) ... y(i-1) s - writePSFmt("{0:.6g} mul {1:.6g} add\n", - func0->getDecodeMax(i) - func0->getDecodeMin(i), - func0->getDecodeMin(i)); - writePSFmt("dup {0:.6g} lt {{ pop {1:.6g} }} {{ dup {2:.6g} gt {{ pop {3:.6g} }} if }} ifelse\n", - func0->getRangeMin(i), func0->getRangeMin(i), - func0->getRangeMax(i), func0->getRangeMax(i)); - // [e01] [efrac] y(0) ... y(i-1) y(i) - } - // [e01] [efrac] y(0) ... y(n-1) - writePSFmt("{0:d} {1:d} roll pop pop \n", n+2, n); - if (invertPSFunction) { - for (i = 0; i < n; ++i) { - writePSFmt("{0:d} -1 roll ", n); - writePSFmt("{0:.6g} sub {1:.6g} div ", func0->getRangeMin(i), func0->getRangeMax(i) - func0->getRangeMin(i)); - } - } - writePS("}\n"); - break; - - case 2: // exponential - func2 = (ExponentialFunction *)func; - n = func2->getOutputSize(); - writePSFmt("{{ dup {0:.6g} lt {{ pop {1:.6g} }} {{ dup {2:.6g} gt {{ pop {3:.6g} }} if }} ifelse\n", - func2->getDomainMin(0), func2->getDomainMin(0), - func2->getDomainMax(0), func2->getDomainMax(0)); - // x - for (i = 0; i < n; ++i) { - // x y(0) .. y(i-1) - writePSFmt("{0:d} index {1:.6g} exp {2:.6g} mul {3:.6g} add\n", - i, func2->getE(), func2->getC1()[i] - func2->getC0()[i], - func2->getC0()[i]); - if (func2->getHasRange()) { - writePSFmt("dup {0:.6g} lt {{ pop {1:.6g} }} {{ dup {2:.6g} gt {{ pop {3:.6g} }} if }} ifelse\n", - func2->getRangeMin(i), func2->getRangeMin(i), - func2->getRangeMax(i), func2->getRangeMax(i)); - } - } - // x y(0) .. y(n-1) - writePSFmt("{0:d} {1:d} roll pop \n", n+1, n); - if (invertPSFunction && func2->getHasRange()) { - for (i = 0; i < n; ++i) { - writePSFmt("{0:d} -1 roll ", n); - writePSFmt("{0:.6g} sub {1:.6g} div ", func2->getRangeMin(i), func2->getRangeMax(i) - func2->getRangeMin(i)); - } - } - writePS("}\n"); - break; - - case 3: // stitching - func3 = (StitchingFunction *)func; - thisFunc = nextFunc++; - for (i = 0; i < func3->getNumFuncs(); ++i) { - cvtFunction(func3->getFunc(i)); - writePSFmt("/xpdfFunc{0:d}_{1:d} exch def\n", thisFunc, i); - } - writePSFmt("{{ dup {0:.6g} lt {{ pop {1:.6g} }} {{ dup {2:.6g} gt {{ pop {3:.6g} }} if }} ifelse\n", - func3->getDomainMin(0), func3->getDomainMin(0), - func3->getDomainMax(0), func3->getDomainMax(0)); - for (i = 0; i < func3->getNumFuncs() - 1; ++i) { - writePSFmt("dup {0:.6g} lt {{ {1:.6g} sub {2:.6g} mul {3:.6g} add xpdfFunc{4:d}_{5:d} }} {{\n", - func3->getBounds()[i+1], - func3->getBounds()[i], - func3->getScale()[i], - func3->getEncode()[2*i], - thisFunc, i); - } - writePSFmt("{0:.6g} sub {1:.6g} mul {2:.6g} add xpdfFunc{3:d}_{4:d}\n", - func3->getBounds()[i], - func3->getScale()[i], - func3->getEncode()[2*i], - thisFunc, i); - for (i = 0; i < func3->getNumFuncs() - 1; ++i) { - writePS("} ifelse\n"); - } - if (invertPSFunction && func3->getHasRange()) { - n = func3->getOutputSize(); - for (i = 0; i < n; ++i) { - writePSFmt("{0:d} -1 roll ", n); - writePSFmt("{0:.6g} sub {1:.6g} div ", func3->getRangeMin(i), func3->getRangeMax(i) - func3->getRangeMin(i)); - } - } - writePS("}\n"); - break; - - case 4: // PostScript - func4 = (PostScriptFunction *)func; - if (invertPSFunction) { - GooString *codeString = new GooString(func4->getCodeString()); - for (i = codeString->getLength() -1; i > 0; i--) { - if (codeString->getChar(i) == '}') { - codeString->del(i); - break; - } - } - writePS(codeString->getCString()); - writePS("\n"); - delete codeString; - n = func4->getOutputSize(); - for (i = 0; i < n; ++i) { - writePSFmt("{0:d} -1 roll ", n); - writePSFmt("{0:.6g} sub {1:.6g} div ", func4->getRangeMin(i), func4->getRangeMax(i) - func4->getRangeMin(i)); - } - writePS("}\n"); - } else { - writePS(func4->getCodeString()->getCString()); - writePS("\n"); - } - break; - } -} - -void PSOutputDev::writePSChar(char c) { - if (t3String) { - t3String->append(c); - } else { - (*outputFunc)(outputStream, &c, 1); - } -} - -void PSOutputDev::writePS(const char *s) { - if (t3String) { - t3String->append(s); - } else { - (*outputFunc)(outputStream, s, strlen(s)); - } -} - -void PSOutputDev::writePSBuf(const char *s, int len) { - if (t3String) { - for (int i = 0; i < len; i++) { - t3String->append(s[i]); - } - } else { - (*outputFunc)(outputStream, s, len); - } -} - -void PSOutputDev::writePSFmt(const char *fmt, ...) { - va_list args; - GooString *buf; - - va_start(args, fmt); - if (t3String) { - t3String->appendfv((char *)fmt, args); - } else { - buf = GooString::formatv((char *)fmt, args); - (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); - delete buf; - } - va_end(args); -} - -void PSOutputDev::writePSString(GooString *s) { - Guchar *p; - int n, line; - char buf[8]; - - writePSChar('('); - line = 1; - for (p = (Guchar *)s->getCString(), n = s->getLength(); n; ++p, --n) { - if (line >= 64) { - writePSChar('\\'); - writePSChar('\n'); - line = 0; - } - if (*p == '(' || *p == ')' || *p == '\\') { - writePSChar('\\'); - writePSChar((char)*p); - line += 2; - } else if (*p < 0x20 || *p >= 0x80) { - sprintf(buf, "\\%03o", *p); - writePS(buf); - line += 4; - } else { - writePSChar((char)*p); - ++line; - } - } - writePSChar(')'); -} - -void PSOutputDev::writePSName(const char *s) { - const char *p; - char c; - - p = s; - while ((c = *p++)) { - if (c <= (char)0x20 || c >= (char)0x7f || - c == '(' || c == ')' || c == '<' || c == '>' || - c == '[' || c == ']' || c == '{' || c == '}' || - c == '/' || c == '%' || c == '\\') { - writePSFmt("#{0:02x}", c & 0xff); - } else { - writePSChar(c); - } - } -} - -GooString *PSOutputDev::filterPSName(GooString *name) { - GooString *name2; - char buf[8]; - int i; - char c; - - name2 = new GooString(); - - // ghostscript chokes on names that begin with out-of-limits - // numbers, e.g., 1e4foo is handled correctly (as a name), but - // 1e999foo generates a limitcheck error - c = name->getChar(0); - if (c >= '0' && c <= '9') { - name2->append('f'); - } - - for (i = 0; i < name->getLength(); ++i) { - c = name->getChar(i); - if (c <= (char)0x20 || c >= (char)0x7f || - c == '(' || c == ')' || c == '<' || c == '>' || - c == '[' || c == ']' || c == '{' || c == '}' || - c == '/' || c == '%') { - sprintf(buf, "#%02x", c & 0xff); - name2->append(buf); - } else { - name2->append(c); - } - } - return name2; -} - -// Convert GooString to GooString, with appropriate escaping -// of things that can't appear in a label -// This is heavily based on the writePSTextLine() method -GooString* PSOutputDev::filterPSLabel(GooString *label, GBool *needParens) { - int i, step; - GBool isNumeric; - - // - DSC comments must be printable ASCII; control chars and - // backslashes have to be escaped (we do cheap UCS2-to-ASCII - // conversion by simply ignoring the high byte) - // - parentheses are escaped. this isn't strictly necessary for matched - // parentheses, but shouldn't be a problem - // - lines are limited to 255 chars (we limit to 200 here to allow - // for the keyword, which was emitted by the caller) - - GooString *label2 = new GooString(); - int labelLength = label->getLength(); - - if (labelLength == 0) { - isNumeric = false; - } else { - // this gets changed later if we find a non-numeric character - isNumeric = true; - } - - if ( (labelLength >= 2) && - ( (label->getChar(0) & 0xff) == 0xfe) && - ( (label->getChar(1) & 0xff) == 0xff) ) { - // UCS2 mode - i = 3; - step = 2; - if ( (label->getChar(labelLength-1) == 0) ) { - // prune the trailing null (0x000 for UCS2) - labelLength -= 2; - } - } else { - i = 0; - step = 1; - } - for (int j = 0; i < labelLength && j < 200; i += step) { - char c = label->getChar(i); - if ( (c < '0') || (c > '9') ) { - isNumeric = false; - } - if (c == '\\') { - label2->append("\\\\"); - j += 2; - } else if (c == ')') { - label2->append("\\)"); - } else if (c == '(') { - label2->append("\\("); - } else if (c < 0x20 || c > 0x7e) { - label2->append(GooString::format("\\{0:03o}", c)); - j += 4; - } else { - label2->append(c); - ++j; - } - } - if (needParens) { - *needParens = !(isNumeric); - } - return label2; -} - -// Write a DSC-compliant <textline>. -void PSOutputDev::writePSTextLine(GooString *s) { - int i, j, step; - int c; - - // - DSC comments must be printable ASCII; control chars and - // backslashes have to be escaped (we do cheap Unicode-to-ASCII - // conversion by simply ignoring the high byte) - // - lines are limited to 255 chars (we limit to 200 here to allow - // for the keyword, which was emitted by the caller) - // - lines that start with a left paren are treated as <text> - // instead of <textline>, so we escape a leading paren - if (s->getLength() >= 2 && - (s->getChar(0) & 0xff) == 0xfe && - (s->getChar(1) & 0xff) == 0xff) { - i = 3; - step = 2; - } else { - i = 0; - step = 1; - } - for (j = 0; i < s->getLength() && j < 200; i += step) { - c = s->getChar(i) & 0xff; - if (c == '\\') { - writePS("\\\\"); - j += 2; - } else if (c < 0x20 || c > 0x7e || (j == 0 && c == '(')) { - writePSFmt("\\{0:03o}", c); - j += 4; - } else { - writePSChar(c); - ++j; - } - } - writePS("\n"); -} diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PSOutputDev.h b/source/libs/poppler/poppler-0.32.0/poppler/PSOutputDev.h deleted file mode 100755 index 6c14cef7b..000000000 --- a/source/libs/poppler/poppler-0.32.0/poppler/PSOutputDev.h +++ /dev/null @@ -1,541 +0,0 @@ -//======================================================================== -// -// PSOutputDev.h -// -// Copyright 1996-2003 Glyph & Cog, LLC -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> -// Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2006-2008, 2012, 2013, 2015 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2007 Brad Hards <bradh@kde.org> -// Copyright (C) 2009-2013 Thomas Freitag <Thomas.Freitag@alfa.de> -// Copyright (C) 2009 Till Kamppeter <till.kamppeter@gmail.com> -// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright (C) 2009, 2011, 2015 William Bader <williambader@hotmail.com> -// Copyright (C) 2010 Hib Eris <hib@hiberis.nl> -// Copyright (C) 2011, 2014 Adrian Johnson <ajohnson@redneon.com> -// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> -// -// To see a description of the changes please see the Changelog file that -// came with your tarball or type make ChangeLog if you are building from git -// -//======================================================================== - -#ifndef PSOUTPUTDEV_H -#define PSOUTPUTDEV_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "poppler-config.h" -#include <stddef.h> -#include "Object.h" -#include "GfxState.h" -#include "GlobalParams.h" -#include "OutputDev.h" -#include <set> -#include <map> -#include <vector> - -class GHooash; -class PDFDoc; -class XRef; -class Function; -class GfxPath; -class GfxFont; -class GfxColorSpace; -class GfxSeparationColorSpace; -class PDFRectangle; -struct PST1FontName; -struct PSFont8Info; -struct PSFont16Enc; -class PSOutCustomColor; -class PSOutputDev; - -//------------------------------------------------------------------------ -// PSOutputDev -//------------------------------------------------------------------------ - -enum PSOutMode { - psModePS, - psModeEPS, - psModeForm -}; - -enum PSFileType { - psFile, // write to file - psPipe, // write to pipe - psStdout, // write to stdout - psGeneric // write to a generic stream -}; - -enum PSOutCustomCodeLocation { - psOutCustomDocSetup, - psOutCustomPageSetup -}; - -typedef void (*PSOutputFunc)(void *stream, const char *data, int len); - -typedef GooString *(*PSOutCustomCodeCbk)(PSOutputDev *psOut, - PSOutCustomCodeLocation loc, int n, - void *data); - -class PSOutputDev: public OutputDev { -public: - - // Open a PostScript output file, and write the prolog. - // pages has to be sorted in increasing order - PSOutputDev(const char *fileName, PDFDoc *docA, - char *psTitle, - const std::vector<int> &pages, PSOutMode modeA, - int paperWidthA = -1, int paperHeightA = -1, - GBool noCrop = gFalse, - GBool duplexA = gTrue, - int imgLLXA = 0, int imgLLYA = 0, - int imgURXA = 0, int imgURYA = 0, - GBool forceRasterizeA = gFalse, - GBool manualCtrlA = gFalse, - PSOutCustomCodeCbk customCodeCbkA = NULL, - void *customCodeCbkDataA = NULL); - - // Open a PSOutputDev that will write to a generic stream. - // pages has to be sorted in increasing order - PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA, - char *psTitle, - PDFDoc *docA, - const std::vector<int> &pages, PSOutMode modeA, - int paperWidthA = -1, int paperHeightA = -1, - GBool noCrop = gFalse, - GBool duplexA = gTrue, - int imgLLXA = 0, int imgLLYA = 0, - int imgURXA = 0, int imgURYA = 0, - GBool forceRasterizeA = gFalse, - GBool manualCtrlA = gFalse, - PSOutCustomCodeCbk customCodeCbkA = NULL, - void *customCodeCbkDataA = NULL); - - // Destructor -- writes the trailer and closes the file. - virtual ~PSOutputDev(); - - // Check if file was successfully created. - virtual GBool isOk() { return ok; } - - //---- get info about output device - - // Does this device use upside-down coordinates? - // (Upside-down means (0,0) is the top left corner of the page.) - virtual GBool upsideDown() { return gFalse; } - - // Does this device use drawChar() or drawString()? - virtual GBool useDrawChar() { return gFalse; } - - // Does this device use tilingPatternFill()? If this returns false, - // tiling pattern fills will be reduced to a series of other drawing - // operations. - virtual GBool useTilingPatternFill() { return gTrue; } - - // Does this device use functionShadedFill(), axialShadedFill(), and - // radialShadedFill()? If this returns false, these shaded fills - // will be reduced to a series of other drawing operations. - virtual GBool useShadedFills(int type) - { return type < 4 && level >= psLevel2; } - - // Does this device use drawForm()? If this returns false, - // form-type XObjects will be interpreted (i.e., unrolled). - virtual GBool useDrawForm() { return preloadImagesForms; } - - // Does this device use beginType3Char/endType3Char? Otherwise, - // text in Type 3 fonts will be drawn with drawChar/drawString. - virtual GBool interpretType3Chars() { return gFalse; } - - virtual GBool needClipToCropBox() { return mode == psModeEPS; } - - //----- header/trailer (used only if manualCtrl is true) - - // Write the document-level header. - void writeHeader(const std::vector<int> &pages, - PDFRectangle *mediaBox, PDFRectangle *cropBox, - int pageRotate, char *pstitle); - - // Write the Xpdf procset. - void writeXpdfProcset(); - - // Write the trailer for the current page. - void writePageTrailer(); - - // Write the document trailer. - void writeTrailer(); - - //----- initialization and control - - // Check to see if a page slice should be displayed. If this - // returns false, the page display is aborted. Typically, an - // OutputDev will use some alternate means to display the page - // before returning false. - virtual GBool checkPageSlice(Page *page, double hDPI, double vDPI, - int rotate, GBool useMediaBox, GBool crop, - int sliceX, int sliceY, int sliceW, int sliceH, - GBool printing, - GBool (*abortCheckCbk)(void *data) = NULL, - void *abortCheckCbkData = NULL, - GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = NULL, - void *annotDisplayDecideCbkData = NULL); - - // Start a page. - virtual void startPage(int pageNum, GfxState *state, XRef *xref); - - // End a page. - virtual void endPage(); - - //----- save/restore graphics state - virtual void saveState(GfxState *state); - virtual void restoreState(GfxState *state); - - //----- update graphics state - virtual void updateCTM(GfxState *state, double m11, double m12, - double m21, double m22, double m31, double m32); - virtual void updateLineDash(GfxState *state); - virtual void updateFlatness(GfxState *state); - virtual void updateLineJoin(GfxState *state); - virtual void updateLineCap(GfxState *state); - virtual void updateMiterLimit(GfxState *state); - virtual void updateLineWidth(GfxState *state); - virtual void updateFillColorSpace(GfxState *state); - virtual void updateStrokeColorSpace(GfxState *state); - virtual void updateFillColor(GfxState *state); - virtual void updateStrokeColor(GfxState *state); - virtual void updateFillOverprint(GfxState *state); - virtual void updateStrokeOverprint(GfxState *state); - virtual void updateOverprintMode(GfxState *state); - virtual void updateTransfer(GfxState *state); - - //----- update text state - virtual void updateFont(GfxState *state); - virtual void updateTextMat(GfxState *state); - virtual void updateCharSpace(GfxState *state); - virtual void updateRender(GfxState *state); - virtual void updateRise(GfxState *state); - virtual void updateWordSpace(GfxState *state); - virtual void updateHorizScaling(GfxState *state); - virtual void updateTextPos(GfxState *state); - virtual void updateTextShift(GfxState *state, double shift); - virtual void saveTextPos(GfxState *state); - virtual void restoreTextPos(GfxState *state); - - //----- path painting - virtual void stroke(GfxState *state); - virtual void fill(GfxState *state); - virtual void eoFill(GfxState *state); - virtual GBool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, Object *str, - double *pmat, int paintType, int tilingType, Dict *resDict, - double *mat, double *bbox, - int x0, int y0, int x1, int y1, - double xStep, double yStep); - virtual GBool functionShadedFill(GfxState *state, - GfxFunctionShading *shading); - virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double /*tMin*/, double /*tMax*/); - virtual GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double /*sMin*/, double /*sMax*/); - - //----- path clipping - virtual void clip(GfxState *state); - virtual void eoClip(GfxState *state); - virtual void clipToStrokePath(GfxState *state); - - //----- text drawing - virtual void drawString(GfxState *state, GooString *s); - virtual void beginTextObject(GfxState *state); - virtual void endTextObject(GfxState *state); - - //----- image drawing - virtual void drawImageMask(GfxState *state, Object *ref, Stream *str, - int width, int height, GBool invert, - GBool interpolate, GBool inlineImg); - virtual void setSoftMaskFromImageMask(GfxState *state, - Object *ref, Stream *str, - int width, int height, GBool invert, - GBool inlineImg, double *baseMatrix); - virtual void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix); - virtual void drawImage(GfxState *state, Object *ref, Stream *str, - int width, int height, GfxImageColorMap *colorMap, - GBool interpolate, int *maskColors, GBool inlineImg); - virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str, - int width, int height, - GfxImageColorMap *colorMap, - GBool interpolate, - Stream *maskStr, int maskWidth, int maskHeight, - GBool maskInvert, GBool maskInterpolate); - -#if OPI_SUPPORT - //----- OPI functions - virtual void opiBegin(GfxState *state, Dict *opiDict); - virtual void opiEnd(GfxState *state, Dict *opiDict); -#endif - - //----- Type 3 font operators - virtual void type3D0(GfxState *state, double wx, double wy); - virtual void type3D1(GfxState *state, double wx, double wy, - double llx, double lly, double urx, double ury); - - //----- form XObjects - virtual void drawForm(Ref ref); - - //----- PostScript XObjects - virtual void psXObject(Stream *psStream, Stream *level1Stream); - - //----- miscellaneous - void setOffset(double x, double y) - { tx0 = x; ty0 = y; } - void setScale(double x, double y) - { xScale0 = x; yScale0 = y; } - void setRotate(int rotateA) - { rotate0 = rotateA; } - void setClip(double llx, double lly, double urx, double ury) - { clipLLX0 = llx; clipLLY0 = lly; clipURX0 = urx; clipURY0 = ury; } - void setUnderlayCbk(void (*cbk)(PSOutputDev *psOut, void *data), - void *data) - { underlayCbk = cbk; underlayCbkData = data; } - void setOverlayCbk(void (*cbk)(PSOutputDev *psOut, void *data), - void *data) - { overlayCbk = cbk; overlayCbkData = data; } - void setDisplayText(GBool display) { displayText = display; } - - void setRasterAntialias(GBool a) { rasterAntialias = a; } - void setRasterResolution(double r) { rasterResolution = r; } - void setRasterMono(GBool b) { rasterMono = b; } - void setUncompressPreloadedImages(GBool b) { uncompressPreloadedImages = b; } - - GBool getEmbedType1() const { return embedType1; } - GBool getEmbedTrueType() const { return embedTrueType; } - GBool getEmbedCIDPostScript() const { return embedCIDPostScript; } - GBool getEmbedCIDTrueType() const { return embedCIDTrueType; } - GBool getFontPassthrough() const { return fontPassthrough; } - GBool getOptimizeColorSpace() const { return optimizeColorSpace; } - void setEmbedType1(GBool b) { embedType1 = b; } - void setEmbedTrueType(GBool b) { embedTrueType = b; } - void setEmbedCIDPostScript(GBool b) { embedCIDPostScript = b; } - void setEmbedCIDTrueType(GBool b) { embedCIDTrueType = b; } - void setFontPassthrough(GBool b) { fontPassthrough = b; } - void setOptimizeColorSpace(GBool b) { optimizeColorSpace = b; } - void setPreloadImagesForms(GBool b) { preloadImagesForms = b; } - void setGenerateOPI(GBool b) { generateOPI = b; } - void setUseASCIIHex(GBool b) { useASCIIHex = b; } - void setUseBinary(GBool b) { useBinary = b; } - -private: - - void init(PSOutputFunc outputFuncA, void *outputStreamA, - PSFileType fileTypeA, char *pstitle, PDFDoc *doc, - const std::vector<int> &pages, PSOutMode modeA, - int imgLLXA, int imgLLYA, int imgURXA, int imgURYA, - GBool manualCtrlA, int paperWidthA, int paperHeightA, - GBool noCropA, GBool duplexA); - void setupResources(Dict *resDict); - void setupFonts(Dict *resDict); - void setupFont(GfxFont *font, Dict *parentResDict); - void setupEmbeddedType1Font(Ref *id, GooString *psName); - void setupExternalType1Font(GooString *fileName, GooString *psName); - void setupEmbeddedType1CFont(GfxFont *font, Ref *id, GooString *psName); - void setupEmbeddedOpenTypeT1CFont(GfxFont *font, Ref *id, GooString *psName); - void setupEmbeddedTrueTypeFont(GfxFont *font, Ref *id, GooString *psName); - void setupExternalTrueTypeFont(GfxFont *font, GooString *fileName, - GooString *psName); - void setupEmbeddedCIDType0Font(GfxFont *font, Ref *id, GooString *psName); - void setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id, GooString *psName, - GBool needVerticalMetrics); - void setupExternalCIDTrueTypeFont(GfxFont *font, - GooString *fileName, - GooString *psName, - GBool needVerticalMetrics); - void setupEmbeddedOpenTypeCFFFont(GfxFont *font, Ref *id, GooString *psName); - void setupType3Font(GfxFont *font, GooString *psName, Dict *parentResDict); - GooString *makePSFontName(GfxFont *font, Ref *id); - void setupImages(Dict *resDict); - void setupImage(Ref id, Stream *str, GBool mask); - void setupForms(Dict *resDict); - void setupForm(Ref id, Object *strObj); - void addProcessColor(double c, double m, double y, double k); - void addCustomColor(GfxSeparationColorSpace *sepCS); - void doPath(GfxPath *path); - void maskToClippingPath(Stream *maskStr, int maskWidth, int maskHeight, GBool maskInvert); - void doImageL1(Object *ref, GfxImageColorMap *colorMap, - GBool invert, GBool inlineImg, - Stream *str, int width, int height, int len, - int *maskColors, Stream *maskStr, - int maskWidth, int maskHeight, GBool maskInvert); - void doImageL1Sep(Object *ref, GfxImageColorMap *colorMap, - GBool invert, GBool inlineImg, - Stream *str, int width, int height, int len, - int *maskColors, Stream *maskStr, - int maskWidth, int maskHeight, GBool maskInvert); - void doImageL2(Object *ref, GfxImageColorMap *colorMap, - GBool invert, GBool inlineImg, - Stream *str, int width, int height, int len, - int *maskColors, Stream *maskStr, - int maskWidth, int maskHeight, GBool maskInvert); - void doImageL3(Object *ref, GfxImageColorMap *colorMap, - GBool invert, GBool inlineImg, - Stream *str, int width, int height, int len, - int *maskColors, Stream *maskStr, - int maskWidth, int maskHeight, GBool maskInvert); - void dumpColorSpaceL2(GfxColorSpace *colorSpace, - GBool genXform, GBool updateColors, - GBool map01); - GBool tilingPatternFillL1(GfxState *state, Catalog *cat, Object *str, - double *pmat, int paintType, int tilingType, Dict *resDict, - double *mat, double *bbox, - int x0, int y0, int x1, int y1, - double xStep, double yStep); - GBool tilingPatternFillL2(GfxState *state, Catalog *cat, Object *str, - double *pmat, int paintType, int tilingType, Dict *resDict, - double *mat, double *bbox, - int x0, int y0, int x1, int y1, - double xStep, double yStep); - -#if OPI_SUPPORT - void opiBegin20(GfxState *state, Dict *dict); - void opiBegin13(GfxState *state, Dict *dict); - void opiTransform(GfxState *state, double x0, double y0, - double *x1, double *y1); -#endif - void cvtFunction(Function *func, GBool invertPSFunction = gFalse); - GooString *filterPSName(GooString *name); - - // Write the document-level setup. - void writeDocSetup(PDFDoc *doc, Catalog *catalog, const std::vector<int> &pages, GBool duplexA); - - void writePSChar(char c); - void writePS(const char *s); - void writePSBuf(const char *s, int len); - void writePSFmt(const char *fmt, ...); - void writePSString(GooString *s); - void writePSName(const char *s); - GooString *filterPSLabel(GooString *label, GBool *needParens=0); - void writePSTextLine(GooString *s); - - PSLevel level; // PostScript level (1, 2, separation) - PSOutMode mode; // PostScript mode (PS, EPS, form) - int paperWidth; // width of paper, in pts - int paperHeight; // height of paper, in pts - GBool paperMatch; // true if paper size is set to match each page - int prevWidth; // width of previous page - // (only psModePSOrigPageSizes output mode) - int prevHeight; // height of previous page - // (only psModePSOrigPageSizes output mode) - int imgLLX, imgLLY, // imageable area, in pts - imgURX, imgURY; - GBool noCrop; - - PSOutputFunc outputFunc; - void *outputStream; - PSFileType fileType; // file / pipe / stdout - GBool manualCtrl; - int seqPage; // current sequential page number - void (*underlayCbk)(PSOutputDev *psOut, void *data); - void *underlayCbkData; - void (*overlayCbk)(PSOutputDev *psOut, void *data); - void *overlayCbkData; - GooString *(*customCodeCbk)(PSOutputDev *psOut, - PSOutCustomCodeLocation loc, int n, - void *data); - void *customCodeCbkData; - - PDFDoc *doc; - XRef *xref; // the xref table for this PDF file - - Ref *fontIDs; // list of object IDs of all used fonts - int fontIDLen; // number of entries in fontIDs array - int fontIDSize; // size of fontIDs array - std::set<int> resourceIDs; // list of object IDs of objects containing Resources we've already set up - GooHash *fontNames; // all used font names - PST1FontName *t1FontNames; // font names for Type 1/1C fonts - int t1FontNameLen; // number of entries in t1FontNames array - int t1FontNameSize; // size of t1FontNames array - PSFont8Info *font8Info; // info for 8-bit fonts - int font8InfoLen; // number of entries in font8Info array - int font8InfoSize; // size of font8Info array - PSFont16Enc *font16Enc; // encodings for substitute 16-bit fonts - int font16EncLen; // number of entries in font16Enc array - int font16EncSize; // size of font16Enc array - Ref *imgIDs; // list of image IDs for in-memory images - int imgIDLen; // number of entries in imgIDs array - int imgIDSize; // size of imgIDs array - Ref *formIDs; // list of IDs for predefined forms - int formIDLen; // number of entries in formIDs array - int formIDSize; // size of formIDs array - int numSaves; // current number of gsaves - int numTilingPatterns; // current number of nested tiling patterns - int nextFunc; // next unique number to use for a function - - GooList *paperSizes; // list of used paper sizes, if paperMatch - // is true [PSOutPaperSize] - std::map<int,int> pagePaperSize; // page num to paperSize entry mapping - double tx0, ty0; // global translation - double xScale0, yScale0; // global scaling - int rotate0; // rotation angle (0, 90, 180, 270) - double clipLLX0, clipLLY0, - clipURX0, clipURY0; - double tx, ty; // global translation for current page - double xScale, yScale; // global scaling for current page - int rotate; // rotation angle for current page - double epsX1, epsY1, // EPS bounding box (unrotated) - epsX2, epsY2; - - GooString *embFontList; // resource comments for embedded fonts - - int processColors; // used process colors - PSOutCustomColor // used custom colors - *customColors; - - GBool haveTextClip; // set if text has been drawn with a - // clipping render mode - - GBool inType3Char; // inside a Type 3 CharProc - GBool inUncoloredPattern; // inside a uncolored pattern (PaintType = 2) - GooString *t3String; // Type 3 content string - double t3WX, t3WY, // Type 3 character parameters - t3LLX, t3LLY, t3URX, t3URY; - GBool t3FillColorOnly; // operators should only use the fill color - GBool t3Cacheable; // cleared if char is not cacheable - GBool t3NeedsRestore; // set if a 'q' operator was issued - GBool forceRasterize; // forces the page to be rasterized into a image before printing - GBool displayText; // displayText - GBool rasterAntialias; // antialias on rasterize - GBool uncompressPreloadedImages; - double rasterResolution; // PostScript rasterization resolution (dpi) - GBool rasterMono; // true to do PostScript rasterization - // in monochrome (gray); false to do it - // in color (RGB/CMYK) - GBool embedType1; // embed Type 1 fonts? - GBool embedTrueType; // embed TrueType fonts? - GBool embedCIDPostScript; // embed CID PostScript fonts? - GBool embedCIDTrueType; // embed CID TrueType fonts? - GBool fontPassthrough; // pass all fonts through as-is? - GBool optimizeColorSpace; // false to keep gray RGB images in their original color space - // true to optimize gray images to DeviceGray color space - GBool preloadImagesForms; // preload PostScript images and forms into - // memory - GBool generateOPI; // generate PostScript OPI comments? - GBool useASCIIHex; // use ASCIIHex instead of ASCII85? - GBool useBinary; // use binary instead of hex - -#if OPI_SUPPORT - int opi13Nest; // nesting level of OPI 1.3 objects - int opi20Nest; // nesting level of OPI 2.0 objects -#endif - - GBool ok; // set up ok? - - friend class WinPDFPrinter; -}; - -#endif diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Page.cc b/source/libs/poppler/poppler-0.32.0/poppler/Page.cc deleted file mode 100755 index 98c13c14f..000000000 --- a/source/libs/poppler/poppler-0.32.0/poppler/Page.cc +++ /dev/null @@ -1,846 +0,0 @@ -//======================================================================== -// -// Page.cc -// -// Copyright 1996-2007 Glyph & Cog, LLC -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net> -// Copyright (C) 2005-2013 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2006-2008 Pino Toscano <pino@kde.org> -// Copyright (C) 2006 Nickolay V. Shmyrev <nshmyrev@yandex.ru> -// Copyright (C) 2006 Scott Turner <scotty1024@mac.com> -// Copyright (C) 2006-2011 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org> -// Copyright (C) 2008 Iñigo Martínez <inigomartinez@gmail.com> -// Copyright (C) 2008 Brad Hards <bradh@kde.org> -// Copyright (C) 2008 Ilya Gorenbein <igorenbein@finjan.com> -// Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it> -// Copyright (C) 2013, 2014 Thomas Freitag <Thomas.Freitag@alfa.de> -// Copyright (C) 2013 Jason Crain <jason@aquaticape.us> -// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> -// -// To see a description of the changes please see the Changelog file that -// came with your tarball or type make ChangeLog if you are building from git -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <stddef.h> -#include <limits.h> -#include "GlobalParams.h" -#include "Object.h" -#include "Array.h" -#include "Dict.h" -#include "PDFDoc.h" -#include "XRef.h" -#include "Link.h" -#include "OutputDev.h" -#include "Gfx.h" -#include "GfxState.h" -#include "Annot.h" -#include "TextOutputDev.h" -#include "Form.h" -#include "Error.h" -#include "Page.h" -#include "Catalog.h" -#include "Form.h" - -#if MULTITHREADED -# define pageLocker() MutexLocker locker(&mutex) -#else -# define pageLocker() -#endif -//------------------------------------------------------------------------ -// PDFRectangle -//------------------------------------------------------------------------ - -void PDFRectangle::clipTo(PDFRectangle *rect) { - if (x1 < rect->x1) { - x1 = rect->x1; - } else if (x1 > rect->x2) { - x1 = rect->x2; - } - if (x2 < rect->x1) { - x2 = rect->x1; - } else if (x2 > rect->x2) { - x2 = rect->x2; - } - if (y1 < rect->y1) { - y1 = rect->y1; - } else if (y1 > rect->y2) { - y1 = rect->y2; - } - if (y2 < rect->y1) { - y2 = rect->y1; - } else if (y2 > rect->y2) { - y2 = rect->y2; - } -} - -//------------------------------------------------------------------------ -// PageAttrs -//------------------------------------------------------------------------ - -PageAttrs::PageAttrs(PageAttrs *attrs, Dict *dict) { - Object obj1; - PDFRectangle mBox; - const GBool isPage = dict->is("Page"); - - // get old/default values - if (attrs) { - mediaBox = attrs->mediaBox; - cropBox = attrs->cropBox; - haveCropBox = attrs->haveCropBox; - rotate = attrs->rotate; - attrs->resources.copy(&resources); - } else { - // set default MediaBox to 8.5" x 11" -- this shouldn't be necessary - // but some (non-compliant) PDF files don't specify a MediaBox - mediaBox.x1 = 0; - mediaBox.y1 = 0; - mediaBox.x2 = 612; - mediaBox.y2 = 792; - cropBox.x1 = cropBox.y1 = cropBox.x2 = cropBox.y2 = 0; - haveCropBox = gFalse; - rotate = 0; - resources.initNull(); - } - - // media box - if (readBox(dict, "MediaBox", &mBox)) { - mediaBox = mBox; - } - - // crop box - if (readBox(dict, "CropBox", &cropBox)) { - haveCropBox = gTrue; - } - if (!haveCropBox) { - cropBox = mediaBox; - } - - if (isPage) { - // cropBox can not be bigger than mediaBox - if (cropBox.x2 - cropBox.x1 > mediaBox.x2 - mediaBox.x1) - { - cropBox.x1 = mediaBox.x1; - cropBox.x2 = mediaBox.x2; - } - if (cropBox.y2 - cropBox.y1 > mediaBox.y2 - mediaBox.y1) - { - cropBox.y1 = mediaBox.y1; - cropBox.y2 = mediaBox.y2; - } - } - - // other boxes - bleedBox = cropBox; - readBox(dict, "BleedBox", &bleedBox); - trimBox = cropBox; - readBox(dict, "TrimBox", &trimBox); - artBox = cropBox; - readBox(dict, "ArtBox", &artBox); - - // rotate - dict->lookup("Rotate", &obj1); - if (obj1.isInt()) { - rotate = obj1.getInt(); - } - obj1.free(); - while (rotate < 0) { - rotate += 360; - } - while (rotate >= 360) { - rotate -= 360; - } - - // misc attributes - dict->lookup("LastModified", &lastModified); - dict->lookup("BoxColorInfo", &boxColorInfo); - dict->lookup("Group", &group); - dict->lookup("Metadata", &metadata); - dict->lookup("PieceInfo", &pieceInfo); - dict->lookup("SeparationInfo", &separationInfo); - - // resource dictionary - dict->lookup("Resources", &obj1); - if (obj1.isDict()) { - resources.free(); - obj1.copy(&resources); - } - obj1.free(); -} - -PageAttrs::~PageAttrs() { - lastModified.free(); - boxColorInfo.free(); - group.free(); - metadata.free(); - pieceInfo.free(); - separationInfo.free(); - resources.free(); -} - -void PageAttrs::clipBoxes() { - cropBox.clipTo(&mediaBox); - bleedBox.clipTo(&mediaBox); - trimBox.clipTo(&mediaBox); - artBox.clipTo(&mediaBox); -} - -GBool PageAttrs::readBox(Dict *dict, const char *key, PDFRectangle *box) { - PDFRectangle tmp; - double t; - Object obj1, obj2; - GBool ok; - - dict->lookup(key, &obj1); - if (obj1.isArray() && obj1.arrayGetLength() == 4) { - ok = gTrue; - obj1.arrayGet(0, &obj2); - if (obj2.isNum()) { - tmp.x1 = obj2.getNum(); - } else { - ok = gFalse; - } - obj2.free(); - obj1.arrayGet(1, &obj2); - if (obj2.isNum()) { - tmp.y1 = obj2.getNum(); - } else { - ok = gFalse; - } - obj2.free(); - obj1.arrayGet(2, &obj2); - if (obj2.isNum()) { - tmp.x2 = obj2.getNum(); - } else { - ok = gFalse; - } - obj2.free(); - obj1.arrayGet(3, &obj2); - if (obj2.isNum()) { - tmp.y2 = obj2.getNum(); - } else { - ok = gFalse; - } - obj2.free(); - if (tmp.x1 == 0 && tmp.x2 == 0 && tmp.y1 == 0 && tmp.y2 == 0) - ok = gFalse; - if (ok) { - if (tmp.x1 > tmp.x2) { - t = tmp.x1; tmp.x1 = tmp.x2; tmp.x2 = t; - } - if (tmp.y1 > tmp.y2) { - t = tmp.y1; tmp.y1 = tmp.y2; tmp.y2 = t; - } - *box = tmp; - } - } else { - ok = gFalse; - } - obj1.free(); - return ok; -} - -//------------------------------------------------------------------------ -// Page -//------------------------------------------------------------------------ - -Page::Page(PDFDoc *docA, int numA, Dict *pageDict, Ref pageRefA, PageAttrs *attrsA, Form *form) { - Object tmp; - -#if MULTITHREADED - gInitMutex(&mutex); -#endif - ok = gTrue; - doc = docA; - xref = doc->getXRef(); - num = numA; - duration = -1; - annots = NULL; - - pageObj.initDict(pageDict); - pageRef = pageRefA; - - // get attributes - attrs = attrsA; - attrs->clipBoxes(); - - // transtion - pageDict->lookupNF("Trans", &trans); - if (!(trans.isRef() || trans.isDict() || trans.isNull())) { - error(errSyntaxError, -1, "Page transition object (page {0:d}) is wrong type ({1:s})", - num, trans.getTypeName()); - trans.free(); - } - - // duration - pageDict->lookupNF("Dur", &tmp); - if (!(tmp.isNum() || tmp.isNull())) { - error(errSyntaxError, -1, "Page duration object (page {0:d}) is wrong type ({1:s})", - num, tmp.getTypeName()); - } else if (tmp.isNum()) { - duration = tmp.getNum(); - } - tmp.free(); - - // annotations - pageDict->lookupNF("Annots", &annotsObj); - if (!(annotsObj.isRef() || annotsObj.isArray() || annotsObj.isNull())) { - error(errSyntaxError, -1, "Page annotations object (page {0:d}) is wrong type ({1:s})", - num, annotsObj.getTypeName()); - annotsObj.free(); - goto err2; - } - - // contents - pageDict->lookupNF("Contents", &contents); - if (!(contents.isRef() || contents.isArray() || - contents.isNull())) { - error(errSyntaxError, -1, "Page contents object (page {0:d}) is wrong type ({1:s})", - num, contents.getTypeName()); - contents.free(); - goto err1; - } - - // thumb - pageDict->lookupNF("Thumb", &thumb); - if (!(thumb.isStream() || thumb.isNull() || thumb.isRef())) { - error(errSyntaxError, -1, "Page thumb object (page {0:d}) is wrong type ({1:s})", - num, thumb.getTypeName()); - thumb.initNull(); - } - - // actions - pageDict->lookupNF("AA", &actions); - if (!(actions.isDict() || actions.isNull())) { - error(errSyntaxError, -1, "Page additional action object (page {0:d}) is wrong type ({1:s})", - num, actions.getTypeName()); - actions.initNull(); - } - - return; - - trans.initNull(); - err2: - annotsObj.initNull(); - err1: - contents.initNull(); - ok = gFalse; -} - -Page::~Page() { - delete attrs; - delete annots; - pageObj.free(); - annotsObj.free(); - contents.free(); - trans.free(); - thumb.free(); - actions.free(); -#if MULTITHREADED - gDestroyMutex(&mutex); -#endif -} - -Dict *Page::getResourceDict() { - return attrs->getResourceDict(); -} - -Dict *Page::getResourceDictCopy(XRef *xrefA) { - pageLocker(); - Dict *dict = attrs->getResourceDict(); - return dict ? dict->copy(xrefA) : NULL; -} - -void Page::replaceXRef(XRef *xrefA) { - Object obj1; - Dict *pageDict = pageObj.getDict()->copy(xrefA); - xref = xrefA; - trans.free(); - pageDict->lookupNF("Trans", &trans); - annotsObj.free(); - pageDict->lookupNF("Annots", &annotsObj); - contents.free(); - pageDict->lookupNF("Contents", &contents); - if (contents.isArray()) { - contents.free(); - pageDict->lookupNF("Contents", &obj1)->getArray()->copy(xrefA, &contents); - obj1.free(); - } - thumb.free(); - pageDict->lookupNF("Thumb", &thumb); - actions.free(); - pageDict->lookupNF("AA", &actions); - pageDict->lookup("Resources", &obj1); - if (obj1.isDict()) { - attrs->replaceResource(obj1); - } - obj1.free(); - delete pageDict; -} - -Annots *Page::getAnnots(XRef *xrefA) { - if (!annots) { - Object obj; - annots = new Annots(doc, num, getAnnots(&obj, (xrefA == NULL) ? xref : xrefA)); - obj.free(); - } - - return annots; -} - -void Page::addAnnot(Annot *annot) { - Object obj1; - Object tmp; - Ref annotRef = annot->getRef (); - - // Make sure we have annots before adding the new one - // even if it's an empty list so that we can safely - // call annots->appendAnnot(annot) - pageLocker(); - getAnnots(); - - if (annotsObj.isNull()) { - Ref annotsRef; - // page doesn't have annots array, - // we have to create it - - obj1.initArray(xref); - obj1.arrayAdd(tmp.initRef (annotRef.num, annotRef.gen)); - tmp.free(); - - annotsRef = xref->addIndirectObject (&obj1); - annotsObj.initRef(annotsRef.num, annotsRef.gen); - pageObj.dictSet ("Annots", &annotsObj); - xref->setModifiedObject (&pageObj, pageRef); - } else { - getAnnots(&obj1); - if (obj1.isArray()) { - obj1.arrayAdd (tmp.initRef (annotRef.num, annotRef.gen)); - if (annotsObj.isRef()) - xref->setModifiedObject (&obj1, annotsObj.getRef()); - else - xref->setModifiedObject (&pageObj, pageRef); - } - obj1.free(); - } - - annots->appendAnnot(annot); - annot->setPage(num, gTrue); -} - -void Page::removeAnnot(Annot *annot) { - Ref annotRef = annot->getRef(); - Object annArray; - - pageLocker(); - getAnnots(&annArray); - if (annArray.isArray()) { - int idx = -1; - // Get annotation position - for (int i = 0; idx == -1 && i < annArray.arrayGetLength(); ++i) { - Object tmp; - if (annArray.arrayGetNF(i, &tmp)->isRef()) { - Ref currAnnot = tmp.getRef(); - if (currAnnot.num == annotRef.num && currAnnot.gen == annotRef.gen) { - idx = i; - } - } - tmp.free(); - } - - if (idx == -1) { - error(errInternal, -1, "Annotation doesn't belong to this page"); - annArray.free(); - return; - } - annots->removeAnnot(annot); // Gracefully fails on popup windows - annArray.arrayRemove(idx); - xref->removeIndirectObject(annotRef); - - if (annotsObj.isRef()) { - xref->setModifiedObject (&annArray, annotsObj.getRef()); - } else { - xref->setModifiedObject (&pageObj, pageRef); - } - } - annArray.free(); - annot->removeReferencedObjects(); // Note: Might recurse in removeAnnot again - annot->setPage(0, gFalse); -} - -Links *Page::getLinks() { - return new Links(getAnnots()); -} - -FormPageWidgets *Page::getFormWidgets() { - return new FormPageWidgets(getAnnots(), num, doc->getCatalog()->getForm()); -} - -void Page::display(OutputDev *out, double hDPI, double vDPI, - int rotate, GBool useMediaBox, GBool crop, - GBool printing, - GBool (*abortCheckCbk)(void *data), - void *abortCheckCbkData, - GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data), - void *annotDisplayDecideCbkData, - GBool copyXRef) { - displaySlice(out, hDPI, vDPI, rotate, useMediaBox, crop, -1, -1, -1, -1, printing, - abortCheckCbk, abortCheckCbkData, - annotDisplayDecideCbk, annotDisplayDecideCbkData, copyXRef); -} - -Gfx *Page::createGfx(OutputDev *out, double hDPI, double vDPI, - int rotate, GBool useMediaBox, GBool crop, - int sliceX, int sliceY, int sliceW, int sliceH, - GBool printing, - GBool (*abortCheckCbk)(void *data), - void *abortCheckCbkData, XRef *xrefA) { - PDFRectangle *mediaBox, *cropBox; - PDFRectangle box; - Gfx *gfx; - - rotate += getRotate(); - if (rotate >= 360) { - rotate -= 360; - } else if (rotate < 0) { - rotate += 360; - } - - makeBox(hDPI, vDPI, rotate, useMediaBox, out->upsideDown(), - sliceX, sliceY, sliceW, sliceH, &box, &crop); - cropBox = getCropBox(); - mediaBox = getMediaBox(); - - if (globalParams->getPrintCommands()) { - printf("***** MediaBox = ll:%g,%g ur:%g,%g\n", - mediaBox->x1, mediaBox->y1, mediaBox->x2, mediaBox->y2); - printf("***** CropBox = ll:%g,%g ur:%g,%g\n", - cropBox->x1, cropBox->y1, cropBox->x2, cropBox->y2); - printf("***** Rotate = %d\n", attrs->getRotate()); - } - - if (!crop) { - crop = (box == *cropBox) && out->needClipToCropBox(); - } - gfx = new Gfx(doc, out, num, attrs->getResourceDict(), - hDPI, vDPI, &box, crop ? cropBox : (PDFRectangle *)NULL, - rotate, abortCheckCbk, abortCheckCbkData, xrefA); - - return gfx; -} - -void Page::displaySlice(OutputDev *out, double hDPI, double vDPI, - int rotate, GBool useMediaBox, GBool crop, - int sliceX, int sliceY, int sliceW, int sliceH, - GBool printing, - GBool (*abortCheckCbk)(void *data), - void *abortCheckCbkData, - GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data), - void *annotDisplayDecideCbkData, - GBool copyXRef) { - Gfx *gfx; - Object obj; - Annots *annotList; - int i; - - if (!out->checkPageSlice(this, hDPI, vDPI, rotate, useMediaBox, crop, - sliceX, sliceY, sliceW, sliceH, - printing, - abortCheckCbk, abortCheckCbkData, - annotDisplayDecideCbk, annotDisplayDecideCbkData)) { - return; - } - pageLocker(); - XRef *localXRef = (copyXRef) ? xref->copy() : xref; - if (copyXRef) { - replaceXRef(localXRef); - } - - gfx = createGfx(out, hDPI, vDPI, rotate, useMediaBox, crop, - sliceX, sliceY, sliceW, sliceH, - printing, - abortCheckCbk, abortCheckCbkData, localXRef); - - contents.fetch(localXRef, &obj); - if (!obj.isNull()) { - gfx->saveState(); - gfx->display(&obj); - gfx->restoreState(); - } else { - // empty pages need to call dump to do any setup required by the - // OutputDev - out->dump(); - } - obj.free(); - - // draw annotations - annotList = getAnnots(); - - if (annotList->getNumAnnots() > 0) { - if (globalParams->getPrintCommands()) { - printf("***** Annotations\n"); - } - for (i = 0; i < annotList->getNumAnnots(); ++i) { - Annot *annot = annotList->getAnnot(i); - if ((annotDisplayDecideCbk && - (*annotDisplayDecideCbk)(annot, annotDisplayDecideCbkData)) || - !annotDisplayDecideCbk) { - annotList->getAnnot(i)->draw(gfx, printing); - } - } - out->dump(); - } - - delete gfx; - if (copyXRef) { - replaceXRef(doc->getXRef()); - delete localXRef; - } -} - -void Page::display(Gfx *gfx) { - Object obj; - - contents.fetch(xref, &obj); - if (!obj.isNull()) { - gfx->saveState(); - gfx->display(&obj); - gfx->restoreState(); - } - obj.free(); -} - -GBool Page::loadThumb(unsigned char **data_out, - int *width_out, int *height_out, - int *rowstride_out) -{ - unsigned int pixbufdatasize; - int width, height, bits; - Object obj1, fetched_thumb; - Dict *dict; - GfxColorSpace *colorSpace; - GBool success = gFalse; - Stream *str; - GfxImageColorMap *colorMap; - - /* Get stream dict */ - pageLocker(); - thumb.fetch(xref, &fetched_thumb); - if (!fetched_thumb.isStream()) { - fetched_thumb.free(); - return gFalse; - } - - dict = fetched_thumb.streamGetDict(); - str = fetched_thumb.getStream(); - - if (!dict->lookupInt("Width", "W", &width)) - goto fail1; - if (!dict->lookupInt("Height", "H", &height)) - goto fail1; - if (!dict->lookupInt("BitsPerComponent", "BPC", &bits)) - goto fail1; - - /* Check for invalid dimensions and integer overflow. */ - if (width <= 0 || height <= 0) - goto fail1; - if (width > INT_MAX / 3 / height) - goto fail1; - pixbufdatasize = width * height * 3; - - /* Get color space */ - dict->lookup ("ColorSpace", &obj1); - if (obj1.isNull ()) { - obj1.free (); - dict->lookup ("CS", &obj1); - } - colorSpace = GfxColorSpace::parse(NULL, &obj1, NULL, NULL); - obj1.free(); - if (!colorSpace) { - fprintf (stderr, "Error: Cannot parse color space\n"); - goto fail1; - } - - dict->lookup("Decode", &obj1); - if (obj1.isNull()) { - obj1.free(); - dict->lookup("D", &obj1); - } - colorMap = new GfxImageColorMap(bits, &obj1, colorSpace); - obj1.free(); - if (!colorMap->isOk()) { - fprintf (stderr, "Error: invalid colormap\n"); - delete colorMap; - goto fail1; - } - - if (data_out) { - unsigned char *pixbufdata = (unsigned char *) gmalloc(pixbufdatasize); - unsigned char *p = pixbufdata; - ImageStream *imgstr = new ImageStream(str, width, - colorMap->getNumPixelComps(), - colorMap->getBits()); - imgstr->reset(); - for (int row = 0; row < height; ++row) { - for (int col = 0; col < width; ++col) { - Guchar pix[gfxColorMaxComps]; - GfxRGB rgb; - - imgstr->getPixel(pix); - colorMap->getRGB(pix, &rgb); - - *p++ = colToByte(rgb.r); - *p++ = colToByte(rgb.g); - *p++ = colToByte(rgb.b); - } - } - *data_out = pixbufdata; - imgstr->close(); - delete imgstr; - } - - success = gTrue; - - if (width_out) - *width_out = width; - if (height_out) - *height_out = height; - if (rowstride_out) - *rowstride_out = width * 3; - - delete colorMap; - fail1: - fetched_thumb.free(); - - return success; -} - -void Page::makeBox(double hDPI, double vDPI, int rotate, - GBool useMediaBox, GBool upsideDown, - double sliceX, double sliceY, double sliceW, double sliceH, - PDFRectangle *box, GBool *crop) { - PDFRectangle *mediaBox, *cropBox, *baseBox; - double kx, ky; - - mediaBox = getMediaBox(); - cropBox = getCropBox(); - if (sliceW >= 0 && sliceH >= 0) { - baseBox = useMediaBox ? mediaBox : cropBox; - kx = 72.0 / hDPI; - ky = 72.0 / vDPI; - if (rotate == 90) { - if (upsideDown) { - box->x1 = baseBox->x1 + ky * sliceY; - box->x2 = baseBox->x1 + ky * (sliceY + sliceH); - } else { - box->x1 = baseBox->x2 - ky * (sliceY + sliceH); - box->x2 = baseBox->x2 - ky * sliceY; - } - box->y1 = baseBox->y1 + kx * sliceX; - box->y2 = baseBox->y1 + kx * (sliceX + sliceW); - } else if (rotate == 180) { - box->x1 = baseBox->x2 - kx * (sliceX + sliceW); - box->x2 = baseBox->x2 - kx * sliceX; - if (upsideDown) { - box->y1 = baseBox->y1 + ky * sliceY; - box->y2 = baseBox->y1 + ky * (sliceY + sliceH); - } else { - box->y1 = baseBox->y2 - ky * (sliceY + sliceH); - box->y2 = baseBox->y2 - ky * sliceY; - } - } else if (rotate == 270) { - if (upsideDown) { - box->x1 = baseBox->x2 - ky * (sliceY + sliceH); - box->x2 = baseBox->x2 - ky * sliceY; - } else { - box->x1 = baseBox->x1 + ky * sliceY; - box->x2 = baseBox->x1 + ky * (sliceY + sliceH); - } - box->y1 = baseBox->y2 - kx * (sliceX + sliceW); - box->y2 = baseBox->y2 - kx * sliceX; - } else { - box->x1 = baseBox->x1 + kx * sliceX; - box->x2 = baseBox->x1 + kx * (sliceX + sliceW); - if (upsideDown) { - box->y1 = baseBox->y2 - ky * (sliceY + sliceH); - box->y2 = baseBox->y2 - ky * sliceY; - } else { - box->y1 = baseBox->y1 + ky * sliceY; - box->y2 = baseBox->y1 + ky * (sliceY + sliceH); - } - } - } else if (useMediaBox) { - *box = *mediaBox; - } else { - *box = *cropBox; - *crop = gFalse; - } -} - -void Page::processLinks(OutputDev *out) { - Links *links; - int i; - - links = getLinks(); - for (i = 0; i < links->getNumLinks(); ++i) { - out->processLink(links->getLink(i)); - } - delete links; -} - -void Page::getDefaultCTM(double *ctm, double hDPI, double vDPI, - int rotate, GBool useMediaBox, GBool upsideDown) { - GfxState *state; - int i; - rotate += getRotate(); - if (rotate >= 360) { - rotate -= 360; - } else if (rotate < 0) { - rotate += 360; - } - state = new GfxState(hDPI, vDPI, - useMediaBox ? getMediaBox() : getCropBox(), - rotate, upsideDown); - for (i = 0; i < 6; ++i) { - ctm[i] = state->getCTM()[i]; - } - delete state; -} - -LinkAction* Page::getAdditionalAction(PageAdditionalActionsType type) { - Object additionalActionsObject; - LinkAction *linkAction = NULL; - - if (actions.fetch(doc->getXRef(), &additionalActionsObject)->isDict()) { - const char *key = (type == actionOpenPage ? "O" : - type == actionClosePage ? "C" : NULL); - - Object actionObject; - - if (additionalActionsObject.dictLookup(key, &actionObject)->isDict()) - linkAction = LinkAction::parseAction(&actionObject, doc->getCatalog()->getBaseURI()); - actionObject.free(); - } - - additionalActionsObject.free(); - - return linkAction; -} diff --git a/source/libs/poppler/poppler-0.32.0/poppler/SplashOutputDev.cc b/source/libs/poppler/poppler-0.32.0/poppler/SplashOutputDev.cc deleted file mode 100755 index 455c2be62..000000000 --- a/source/libs/poppler/poppler-0.32.0/poppler/SplashOutputDev.cc +++ /dev/null @@ -1,4467 +0,0 @@ -//======================================================================== -// -// SplashOutputDev.cc -// -// Copyright 2003 Glyph & Cog, LLC -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2005 Takashi Iwai <tiwai@suse.de> -// Copyright (C) 2006 Stefan Schweizer <genstef@gentoo.org> -// Copyright (C) 2006-2015 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com> -// Copyright (C) 2006 Scott Turner <scotty1024@mac.com> -// Copyright (C) 2007 Koji Otani <sho@bbr.jp> -// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com> -// Copyright (C) 2009-2015 Thomas Freitag <Thomas.Freitag@alfa.de> -// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright (C) 2009, 2014, 2015 William Bader <williambader@hotmail.com> -// Copyright (C) 2010 Patrick Spendrin <ps_ml@gmx.de> -// Copyright (C) 2010 Brian Cameron <brian.cameron@oracle.com> -// Copyright (C) 2010 Paweł Wiejacha <pawel.wiejacha@gmail.com> -// Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> -// Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com> -// Copyright (C) 2011 Andrea Canciani <ranma42@gmail.com> -// Copyright (C) 2011, 2012 Adrian Johnson <ajohnson@redneon.com> -// Copyright (C) 2013 Lu Wang <coolwanglu@gmail.com> -// Copyright (C) 2013 Li Junling <lijunling@sina.com> -// Copyright (C) 2014 Ed Porras <ed@moto-research.com> -// Copyright (C) 2014 Richard PALO <richard@netbsd.org> -// -// To see a description of the changes please see the Changelog file that -// came with your tarball or type make ChangeLog if you are building from git -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <string.h> -#include <math.h> -#include "goo/gfile.h" -#include "GlobalParams.h" -#include "Error.h" -#include "Object.h" -#include "Gfx.h" -#include "GfxFont.h" -#include "Page.h" -#include "PDFDoc.h" -#include "Link.h" -#include "FontEncodingTables.h" -#include "fofi/FoFiTrueType.h" -#include "splash/SplashBitmap.h" -#include "splash/SplashGlyphBitmap.h" -#include "splash/SplashPattern.h" -#include "splash/SplashScreen.h" -#include "splash/SplashPath.h" -#include "splash/SplashState.h" -#include "splash/SplashErrorCodes.h" -#include "splash/SplashFontEngine.h" -#include "splash/SplashFont.h" -#include "splash/SplashFontFile.h" -#include "splash/SplashFontFileID.h" -#include "splash/Splash.h" -#include "SplashOutputDev.h" - -#ifdef VMS -#if (__VMS_VER < 70000000) -extern "C" int unlink(char *filename); -#endif -#endif - -#ifdef _MSC_VER -#include <float.h> -#define isfinite(x) _finite(x) -#endif - -#ifdef __sun -#include <ieeefp.h> -#ifndef isfinite -#define isfinite(x) finite(x) -#endif -#endif - -static inline void convertGfxColor(SplashColorPtr dest, - SplashColorMode colorMode, - GfxColorSpace *colorSpace, - GfxColor *src) { - SplashColor color; - GfxGray gray; - GfxRGB rgb; -#if SPLASH_CMYK - GfxCMYK cmyk; - GfxColor deviceN; -#endif - - // make gcc happy - color[0] = color[1] = color[2] = 0; -#if SPLASH_CMYK - color[3] = 0; -#endif - switch (colorMode) { - case splashModeMono1: - case splashModeMono8: - colorSpace->getGray(src, &gray); - color[0] = colToByte(gray); - break; - case splashModeXBGR8: - color[3] = 255; - case splashModeBGR8: - case splashModeRGB8: - colorSpace->getRGB(src, &rgb); - color[0] = colToByte(rgb.r); - color[1] = colToByte(rgb.g); - color[2] = colToByte(rgb.b); - break; -#if SPLASH_CMYK - case splashModeCMYK8: - colorSpace->getCMYK(src, &cmyk); - color[0] = colToByte(cmyk.c); - color[1] = colToByte(cmyk.m); - color[2] = colToByte(cmyk.y); - color[3] = colToByte(cmyk.k); - break; - case splashModeDeviceN8: - colorSpace->getDeviceN(src, &deviceN); - for (int i = 0; i < SPOT_NCOMPS + 4; i++) - color[i] = colToByte(deviceN.c[i]); - break; -#endif - } - splashColorCopy(dest, color); -} - -//------------------------------------------------------------------------ -// SplashGouraudPattern -//------------------------------------------------------------------------ -SplashGouraudPattern::SplashGouraudPattern(GBool bDirectColorTranslationA, - GfxState *stateA, GfxGouraudTriangleShading *shadingA, SplashColorMode modeA) { - SplashColor defaultColor; - GfxColor srcColor; - state = stateA; - shading = shadingA; - mode = modeA; - bDirectColorTranslation = bDirectColorTranslationA; - shadingA->getColorSpace()->getDefaultColor(&srcColor); - convertGfxColor(defaultColor, mode, shadingA->getColorSpace(), &srcColor); - gfxMode = shadingA->getColorSpace()->getMode(); -} - -SplashGouraudPattern::~SplashGouraudPattern() { -} - -void SplashGouraudPattern::getParameterizedColor(double colorinterp, SplashColorMode mode, SplashColorPtr dest) { - GfxColor src; - GfxColorSpace* srcColorSpace = shading->getColorSpace(); - int colorComps = 3; -#if SPLASH_CMYK - if (mode == splashModeCMYK8) - colorComps=4; - else if (mode == splashModeDeviceN8) - colorComps=4 + SPOT_NCOMPS; -#endif - - shading->getParameterizedColor(colorinterp, &src); - - if (bDirectColorTranslation) { - for (int m = 0; m < colorComps; ++m) - dest[m] = colToByte(src.c[m]); - } else { - convertGfxColor(dest, mode, srcColorSpace, &src); - } -} - -//------------------------------------------------------------------------ -// SplashUnivariatePattern -//------------------------------------------------------------------------ - -SplashUnivariatePattern::SplashUnivariatePattern(SplashColorMode colorModeA, GfxState *stateA, GfxUnivariateShading *shadingA) { - Matrix ctm; - double xMin, yMin, xMax, yMax; - - shading = shadingA; - state = stateA; - colorMode = colorModeA; - - state->getCTM(&ctm); - ctm.invertTo(&ictm); - - // get the function domain - t0 = shading->getDomain0(); - t1 = shading->getDomain1(); - dt = t1 - t0; - - stateA->getUserClipBBox(&xMin, &yMin, &xMax, &yMax); - shadingA->setupCache(&ctm, xMin, yMin, xMax, yMax); - gfxMode = shadingA->getColorSpace()->getMode(); -} - -SplashUnivariatePattern::~SplashUnivariatePattern() { -} - -GBool SplashUnivariatePattern::getColor(int x, int y, SplashColorPtr c) { - GfxColor gfxColor; - double xc, yc, t; - - ictm.transform(x, y, &xc, &yc); - if (! getParameter (xc, yc, &t)) - return gFalse; - - shading->getColor(t, &gfxColor); - convertGfxColor(c, colorMode, shading->getColorSpace(), &gfxColor); - return gTrue; -} - -GBool SplashUnivariatePattern::testPosition(int x, int y) { - double xc, yc, t; - - ictm.transform(x, y, &xc, &yc); - if (! getParameter (xc, yc, &t)) - return gFalse; - return (t0 < t1) ? (t > t0 && t < t1) : (t > t1 && t < t0); -} - - -//------------------------------------------------------------------------ -// SplashRadialPattern -//------------------------------------------------------------------------ -#define RADIAL_EPSILON (1. / 1024 / 1024) - -SplashRadialPattern::SplashRadialPattern(SplashColorMode colorModeA, GfxState *stateA, GfxRadialShading *shadingA): - SplashUnivariatePattern(colorModeA, stateA, shadingA) -{ - SplashColor defaultColor; - GfxColor srcColor; - - shadingA->getCoords(&x0, &y0, &r0, &dx, &dy, &dr); - dx -= x0; - dy -= y0; - dr -= r0; - a = dx*dx + dy*dy - dr*dr; - if (fabs(a) > RADIAL_EPSILON) - inva = 1.0 / a; - shadingA->getColorSpace()->getDefaultColor(&srcColor); - convertGfxColor(defaultColor, colorModeA, shadingA->getColorSpace(), &srcColor); -} - -SplashRadialPattern::~SplashRadialPattern() { -} - -GBool SplashRadialPattern::getParameter(double xs, double ys, double *t) { - double b, c, s0, s1; - - // We want to solve this system of equations: - // - // 1. (x - xc(s))^2 + (y -yc(s))^2 = rc(s)^2 - // 2. xc(s) = x0 + s * (x1 - xo) - // 3. yc(s) = y0 + s * (y1 - yo) - // 4. rc(s) = r0 + s * (r1 - ro) - // - // To simplify the system a little, we translate - // our coordinates to have the origin in (x0,y0) - - xs -= x0; - ys -= y0; - - // Then we have to solve the equation: - // A*s^2 - 2*B*s + C = 0 - // where - // A = dx^2 + dy^2 - dr^2 - // B = xs*dx + ys*dy + r0*dr - // C = xs^2 + ys^2 - r0^2 - - b = xs*dx + ys*dy + r0*dr; - c = xs*xs + ys*ys - r0*r0; - - if (fabs(a) <= RADIAL_EPSILON) { - // A is 0, thus the equation simplifies to: - // -2*B*s + C = 0 - // If B is 0, we can either have no solution or an indeterminate - // equation, thus we behave as if we had an invalid solution - if (fabs(b) <= RADIAL_EPSILON) - return gFalse; - - s0 = s1 = 0.5 * c / b; - } else { - double d; - - d = b*b - a*c; - if (d < 0) - return gFalse; - - d = sqrt (d); - s0 = b + d; - s1 = b - d; - - // If A < 0, one of the two solutions will have negative radius, - // thus it will be ignored. Otherwise we know that s1 <= s0 - // (because d >=0 implies b - d <= b + d), so if both are valid it - // will be the true solution. - s0 *= inva; - s1 *= inva; - } - - if (r0 + s0 * dr >= 0) { - if (0 <= s0 && s0 <= 1) { - *t = t0 + dt * s0; - return gTrue; - } else if (s0 < 0 && shading->getExtend0()) { - *t = t0; - return gTrue; - } else if (s0 > 1 && shading->getExtend1()) { - *t = t1; - return gTrue; - } - } - - if (r0 + s1 * dr >= 0) { - if (0 <= s1 && s1 <= 1) { - *t = t0 + dt * s1; - return gTrue; - } else if (s1 < 0 && shading->getExtend0()) { - *t = t0; - return gTrue; - } else if (s1 > 1 && shading->getExtend1()) { - *t = t1; - return gTrue; - } - } - - return gFalse; -} - -#undef RADIAL_EPSILON - -//------------------------------------------------------------------------ -// SplashAxialPattern -//------------------------------------------------------------------------ - -SplashAxialPattern::SplashAxialPattern(SplashColorMode colorModeA, GfxState *stateA, GfxAxialShading *shadingA): - SplashUnivariatePattern(colorModeA, stateA, shadingA) -{ - SplashColor defaultColor; - GfxColor srcColor; - - shadingA->getCoords(&x0, &y0, &x1, &y1); - dx = x1 - x0; - dy = y1 - y0; - mul = 1 / (dx * dx + dy * dy); - shadingA->getColorSpace()->getDefaultColor(&srcColor); - convertGfxColor(defaultColor, colorModeA, shadingA->getColorSpace(), &srcColor); -} - -SplashAxialPattern::~SplashAxialPattern() { -} - -GBool SplashAxialPattern::getParameter(double xc, double yc, double *t) { - double s; - - xc -= x0; - yc -= y0; - - s = (xc * dx + yc * dy) * mul; - if (0 <= s && s <= 1) { - *t = t0 + dt * s; - } else if (s < 0 && shading->getExtend0()) { - *t = t0; - } else if (s > 1 && shading->getExtend1()) { - *t = t1; - } else { - return gFalse; - } - - return gTrue; -} - -//------------------------------------------------------------------------ -// Type 3 font cache size parameters -#define type3FontCacheAssoc 8 -#define type3FontCacheMaxSets 8 -#define type3FontCacheSize (128*1024) - -//------------------------------------------------------------------------ -// Divide a 16-bit value (in [0, 255*255]) by 255, returning an 8-bit result. -static inline Guchar div255(int x) { - return (Guchar)((x + (x >> 8) + 0x80) >> 8); -} - -#if SPLASH_CMYK - -#include "GfxState_helpers.h" - -//------------------------------------------------------------------------- -// helper for Blend functions (convert CMYK to RGB, do blend, convert back) -//------------------------------------------------------------------------- - -// based in GfxState.cc - -static void cmykToRGB(SplashColorPtr cmyk, SplashColor rgb) { - double c, m, y, k, c1, m1, y1, k1, r, g, b; - - c = colToDbl(byteToCol(cmyk[0])); - m = colToDbl(byteToCol(cmyk[1])); - y = colToDbl(byteToCol(cmyk[2])); - k = colToDbl(byteToCol(cmyk[3])); - c1 = 1 - c; - m1 = 1 - m; - y1 = 1 - y; - k1 = 1 - k; - cmykToRGBMatrixMultiplication(c, m, y, k, c1, m1, y1, k1, r, g, b); - rgb[0] = colToByte(clip01(dblToCol(r))); - rgb[1] = colToByte(clip01(dblToCol(g))); - rgb[2] = colToByte(clip01(dblToCol(b))); -} - -static void rgbToCMYK(SplashColor rgb, SplashColorPtr cmyk) { - GfxColorComp c, m, y, k; - - c = clip01(gfxColorComp1 - byteToCol(rgb[0])); - m = clip01(gfxColorComp1 - byteToCol(rgb[1])); - y = clip01(gfxColorComp1 - byteToCol(rgb[2])); - k = c; - if (m < k) { - k = m; - } - if (y < k) { - k = y; - } - cmyk[0] = colToByte(c - k); - cmyk[1] = colToByte(m - k); - cmyk[2] = colToByte(y - k); - cmyk[3] = colToByte(k); -} - -#endif - -//------------------------------------------------------------------------ -// Blend functions -//------------------------------------------------------------------------ - -static void splashOutBlendMultiply(SplashColorPtr src, SplashColorPtr dest, - SplashColorPtr blend, SplashColorMode cm) { - int i; - -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - } - } -#endif - { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - blend[i] = (dest[i] * src[i]) / 255; - } - } -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - blend[i] = 255 - blend[i]; - } - } -#endif -} - -static void splashOutBlendScreen(SplashColorPtr src, SplashColorPtr dest, - SplashColorPtr blend, SplashColorMode cm) { - int i; - -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - } - } -#endif - { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - blend[i] = dest[i] + src[i] - (dest[i] * src[i]) / 255; - } - } -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - blend[i] = 255 - blend[i]; - } - } -#endif -} - -static void splashOutBlendOverlay(SplashColorPtr src, SplashColorPtr dest, - SplashColorPtr blend, SplashColorMode cm) { - int i; - -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - } - } -#endif - { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - blend[i] = dest[i] < 0x80 - ? (src[i] * 2 * dest[i]) / 255 - : 255 - 2 * ((255 - src[i]) * (255 - dest[i])) / 255; - } - } -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - blend[i] = 255 - blend[i]; - } - } -#endif -} - -static void splashOutBlendDarken(SplashColorPtr src, SplashColorPtr dest, - SplashColorPtr blend, SplashColorMode cm) { - int i; - -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - } - } -#endif - { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - blend[i] = dest[i] < src[i] ? dest[i] : src[i]; - } - } -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - blend[i] = 255 - blend[i]; - } - } -#endif -} - -static void splashOutBlendLighten(SplashColorPtr src, SplashColorPtr dest, - SplashColorPtr blend, SplashColorMode cm) { - int i; - -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - } - } -#endif - { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - blend[i] = dest[i] > src[i] ? dest[i] : src[i]; - } - } -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - blend[i] = 255 - blend[i]; - } - } -#endif -} - -static void splashOutBlendColorDodge(SplashColorPtr src, SplashColorPtr dest, - SplashColorPtr blend, - SplashColorMode cm) { - int i, x; - -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - } - } -#endif - { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - if (src[i] == 255) { - blend[i] = 255; - } else { - x = (dest[i] * 255) / (255 - src[i]); - blend[i] = x <= 255 ? x : 255; - } - } - } -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - blend[i] = 255 - blend[i]; - } - } -#endif -} - -static void splashOutBlendColorBurn(SplashColorPtr src, SplashColorPtr dest, - SplashColorPtr blend, SplashColorMode cm) { - int i, x; - -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - } - } -#endif - { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - if (src[i] == 0) { - blend[i] = 0; - } else { - x = ((255 - dest[i]) * 255) / src[i]; - blend[i] = x <= 255 ? 255 - x : 0; - } - } - } -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - blend[i] = 255 - blend[i]; - } - } -#endif -} - -static void splashOutBlendHardLight(SplashColorPtr src, SplashColorPtr dest, - SplashColorPtr blend, SplashColorMode cm) { - int i; - -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - } - } -#endif - { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - blend[i] = src[i] < 0x80 - ? (dest[i] * 2 * src[i]) / 255 - : 255 - 2 * ((255 - dest[i]) * (255 - src[i])) / 255; - } - } -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - blend[i] = 255 - blend[i]; - } - } -#endif -} - -static void splashOutBlendSoftLight(SplashColorPtr src, SplashColorPtr dest, - SplashColorPtr blend, SplashColorMode cm) { - int i, x; - -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - } - } -#endif - { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - if (src[i] < 0x80) { - blend[i] = dest[i] - (255 - 2 * src[i]) * dest[i] * (255 - dest[i]) / (255 * 255); - } else { - if (dest[i] < 0x40) { - x = (((((16 * dest[i] - 12 * 255) * dest[i]) / 255) + 4 * 255) * dest[i]) / 255; - } else { - x = (int)sqrt(255.0 * dest[i]); - } - blend[i] = dest[i] + (2 * src[i] - 255) * (x - dest[i]) / 255; - } - } - } -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - blend[i] = 255 - blend[i]; - } - } -#endif -} - -static void splashOutBlendDifference(SplashColorPtr src, SplashColorPtr dest, - SplashColorPtr blend, - SplashColorMode cm) { - int i; - -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - } - } -#endif - { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - blend[i] = dest[i] < src[i] ? src[i] - dest[i] : dest[i] - src[i]; - } - } -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - blend[i] = 255 - blend[i]; - } - } - if (cm == splashModeDeviceN8) { - for (i = 4; i < splashColorModeNComps[cm]; ++i) { - if (dest[i] == 0 && src[i] == 0) - blend[i] = 0; - } - } -#endif -} - -static void splashOutBlendExclusion(SplashColorPtr src, SplashColorPtr dest, - SplashColorPtr blend, SplashColorMode cm) { - int i; - -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - } - } -#endif - { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - blend[i] = dest[i] + src[i] - (2 * dest[i] * src[i]) / 255; - } - } -#if SPLASH_CMYK - if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - dest[i] = 255 - dest[i]; - src[i] = 255 - src[i]; - blend[i] = 255 - blend[i]; - } - } - if (cm == splashModeDeviceN8) { - for (i = 4; i < splashColorModeNComps[cm]; ++i) { - if (dest[i] == 0 && src[i] == 0) - blend[i] = 0; - } - } -#endif -} - -static int getLum(int r, int g, int b) { - return (int)(0.3 * r + 0.59 * g + 0.11 * b); -} - -static int getSat(int r, int g, int b) { - int rgbMin, rgbMax; - - rgbMin = rgbMax = r; - if (g < rgbMin) { - rgbMin = g; - } else if (g > rgbMax) { - rgbMax = g; - } - if (b < rgbMin) { - rgbMin = b; - } else if (b > rgbMax) { - rgbMax = b; - } - return rgbMax - rgbMin; -} - -static void clipColor(int rIn, int gIn, int bIn, - Guchar *rOut, Guchar *gOut, Guchar *bOut) { - int lum, rgbMin, rgbMax; - - lum = getLum(rIn, gIn, bIn); - rgbMin = rgbMax = rIn; - if (gIn < rgbMin) { - rgbMin = gIn; - } else if (gIn > rgbMax) { - rgbMax = gIn; - } - if (bIn < rgbMin) { - rgbMin = bIn; - } else if (bIn > rgbMax) { - rgbMax = bIn; - } - if (rgbMin < 0) { - *rOut = (Guchar)(lum + ((rIn - lum) * lum) / (lum - rgbMin)); - *gOut = (Guchar)(lum + ((gIn - lum) * lum) / (lum - rgbMin)); - *bOut = (Guchar)(lum + ((bIn - lum) * lum) / (lum - rgbMin)); - } else if (rgbMax > 255) { - *rOut = (Guchar)(lum + ((rIn - lum) * (255 - lum)) / (rgbMax - lum)); - *gOut = (Guchar)(lum + ((gIn - lum) * (255 - lum)) / (rgbMax - lum)); - *bOut = (Guchar)(lum + ((bIn - lum) * (255 - lum)) / (rgbMax - lum)); - } else { - *rOut = rIn; - *gOut = gIn; - *bOut = bIn; - } -} - -static void setLum(Guchar rIn, Guchar gIn, Guchar bIn, int lum, - Guchar *rOut, Guchar *gOut, Guchar *bOut) { - int d; - - d = lum - getLum(rIn, gIn, bIn); - clipColor(rIn + d, gIn + d, bIn + d, rOut, gOut, bOut); -} - -static void setSat(Guchar rIn, Guchar gIn, Guchar bIn, int sat, - Guchar *rOut, Guchar *gOut, Guchar *bOut) { - int rgbMin, rgbMid, rgbMax; - Guchar *minOut, *midOut, *maxOut; - - if (rIn < gIn) { - rgbMin = rIn; minOut = rOut; - rgbMid = gIn; midOut = gOut; - } else { - rgbMin = gIn; minOut = gOut; - rgbMid = rIn; midOut = rOut; - } - if (bIn > rgbMid) { - rgbMax = bIn; maxOut = bOut; - } else if (bIn > rgbMin) { - rgbMax = rgbMid; maxOut = midOut; - rgbMid = bIn; midOut = bOut; - } else { - rgbMax = rgbMid; maxOut = midOut; - rgbMid = rgbMin; midOut = minOut; - rgbMin = bIn; minOut = bOut; - } - if (rgbMax > rgbMin) { - *midOut = (Guchar)((rgbMid - rgbMin) * sat) / (rgbMax - rgbMin); - *maxOut = (Guchar)sat; - } else { - *midOut = *maxOut = 0; - } - *minOut = 0; -} - -static void splashOutBlendHue(SplashColorPtr src, SplashColorPtr dest, - SplashColorPtr blend, SplashColorMode cm) { - Guchar r0, g0, b0; -#ifdef SPLASH_CMYK - Guchar r1, g1, b1; - int i; - SplashColor src2, dest2; -#endif - - switch (cm) { - case splashModeMono1: - case splashModeMono8: - blend[0] = dest[0]; - break; - case splashModeXBGR8: - src[3] = 255; - case splashModeRGB8: - case splashModeBGR8: - setSat(src[0], src[1], src[2], getSat(dest[0], dest[1], dest[2]), - &r0, &g0, &b0); - setLum(r0, g0, b0, getLum(dest[0], dest[1], dest[2]), - &blend[0], &blend[1], &blend[2]); - break; -#if SPLASH_CMYK - case splashModeCMYK8: - case splashModeDeviceN8: - for (i = 0; i < 4; i++) { - // convert to additive - src2[i] = 0xff - src[i]; - dest2[i] = 0xff - dest[i]; - } - // NB: inputs have already been converted to additive mode - setSat(src2[0], src2[1], src2[2], getSat(dest2[0], dest2[1], dest2[2]), - &r0, &g0, &b0); - setLum(r0, g0, b0, getLum(dest2[0], dest2[1], dest2[2]), - &r1, &g1, &b1); - blend[0] = r1; - blend[1] = g1; - blend[2] = b1; - blend[3] = dest2[3]; - for (i = 0; i < 4; i++) { - // convert back to subtractive - blend[i] = 0xff - blend[i]; - } - break; -#endif - } -} - -static void splashOutBlendSaturation(SplashColorPtr src, SplashColorPtr dest, - SplashColorPtr blend, - SplashColorMode cm) { - Guchar r0, g0, b0; -#ifdef SPLASH_CMYK - Guchar r1, g1, b1; - int i; - SplashColor src2, dest2; -#endif - - switch (cm) { - case splashModeMono1: - case splashModeMono8: - blend[0] = dest[0]; - break; - case splashModeXBGR8: - src[3] = 255; - case splashModeRGB8: - case splashModeBGR8: - setSat(dest[0], dest[1], dest[2], getSat(src[0], src[1], src[2]), - &r0, &g0, &b0); - setLum(r0, g0, b0, getLum(dest[0], dest[1], dest[2]), - &blend[0], &blend[1], &blend[2]); - break; -#if SPLASH_CMYK - case splashModeCMYK8: - case splashModeDeviceN8: - for (i = 0; i < 4; i++) { - // convert to additive - src2[i] = 0xff - src[i]; - dest2[i] = 0xff - dest[i]; - } - setSat(dest2[0], dest2[1], dest2[2], getSat(src2[0], src2[1], src2[2]), - &r0, &g0, &b0); - setLum(r0, g0, b0, getLum(dest2[0], dest2[1], dest2[2]), - &r1, &g1, &b1); - blend[0] = r1; - blend[1] = g1; - blend[2] = b1; - blend[3] = dest2[3]; - for (i = 0; i < 4; i++) { - // convert back to subtractive - blend[i] = 0xff - blend[i]; - } - break; -#endif - } -} - -static void splashOutBlendColor(SplashColorPtr src, SplashColorPtr dest, - SplashColorPtr blend, SplashColorMode cm) { -#if SPLASH_CMYK - Guchar r, g, b; - int i; - SplashColor src2, dest2; -#endif - - switch (cm) { - case splashModeMono1: - case splashModeMono8: - blend[0] = dest[0]; - break; - case splashModeXBGR8: - src[3] = 255; - case splashModeRGB8: - case splashModeBGR8: - setLum(src[0], src[1], src[2], getLum(dest[0], dest[1], dest[2]), - &blend[0], &blend[1], &blend[2]); - break; -#if SPLASH_CMYK - case splashModeCMYK8: - case splashModeDeviceN8: - for (i = 0; i < 4; i++) { - // convert to additive - src2[i] = 0xff - src[i]; - dest2[i] = 0xff - dest[i]; - } - setLum(src2[0], src2[1], src2[2], getLum(dest2[0], dest2[1], dest2[2]), - &r, &g, &b); - blend[0] = r; - blend[1] = g; - blend[2] = b; - blend[3] = dest2[3]; - for (i = 0; i < 4; i++) { - // convert back to subtractive - blend[i] = 0xff - blend[i]; - } - break; -#endif - } -} - -static void splashOutBlendLuminosity(SplashColorPtr src, SplashColorPtr dest, - SplashColorPtr blend, - SplashColorMode cm) { -#if SPLASH_CMYK - Guchar r, g, b; - int i; - SplashColor src2, dest2; -#endif - - switch (cm) { - case splashModeMono1: - case splashModeMono8: - blend[0] = dest[0]; - break; - case splashModeXBGR8: - src[3] = 255; - case splashModeRGB8: - case splashModeBGR8: - setLum(dest[0], dest[1], dest[2], getLum(src[0], src[1], src[2]), - &blend[0], &blend[1], &blend[2]); - break; -#if SPLASH_CMYK - case splashModeCMYK8: - case splashModeDeviceN8: - for (i = 0; i < 4; i++) { - // convert to additive - src2[i] = 0xff - src[i]; - dest2[i] = 0xff - dest[i]; - } - setLum(dest2[0], dest2[1], dest2[2], getLum(src2[0], src2[1], src2[2]), - &r, &g, &b); - blend[0] = r; - blend[1] = g; - blend[2] = b; - blend[3] = src2[3]; - for (i = 0; i < 4; i++) { - // convert back to subtractive - blend[i] = 0xff - blend[i]; - } - break; -#endif - } -} - -// NB: This must match the GfxBlendMode enum defined in GfxState.h. -static const SplashBlendFunc splashOutBlendFuncs[] = { - NULL, - &splashOutBlendMultiply, - &splashOutBlendScreen, - &splashOutBlendOverlay, - &splashOutBlendDarken, - &splashOutBlendLighten, - &splashOutBlendColorDodge, - &splashOutBlendColorBurn, - &splashOutBlendHardLight, - &splashOutBlendSoftLight, - &splashOutBlendDifference, - &splashOutBlendExclusion, - &splashOutBlendHue, - &splashOutBlendSaturation, - &splashOutBlendColor, - &splashOutBlendLuminosity -}; - -//------------------------------------------------------------------------ -// SplashOutFontFileID -//------------------------------------------------------------------------ - -class SplashOutFontFileID: public SplashFontFileID { -public: - - SplashOutFontFileID(Ref *rA) { r = *rA; } - - ~SplashOutFontFileID() {} - - GBool matches(SplashFontFileID *id) { - return ((SplashOutFontFileID *)id)->r.num == r.num && - ((SplashOutFontFileID *)id)->r.gen == r.gen; - } - -private: - - Ref r; -}; - -//------------------------------------------------------------------------ -// T3FontCache -//------------------------------------------------------------------------ - -struct T3FontCacheTag { - Gushort code; - Gushort mru; // valid bit (0x8000) and MRU index -}; - -class T3FontCache { -public: - - T3FontCache(Ref *fontID, double m11A, double m12A, - double m21A, double m22A, - int glyphXA, int glyphYA, int glyphWA, int glyphHA, - GBool aa, GBool validBBoxA); - ~T3FontCache(); - GBool matches(Ref *idA, double m11A, double m12A, - double m21A, double m22A) - { return fontID.num == idA->num && fontID.gen == idA->gen && - m11 == m11A && m12 == m12A && m21 == m21A && m22 == m22A; } - - Ref fontID; // PDF font ID - double m11, m12, m21, m22; // transform matrix - int glyphX, glyphY; // pixel offset of glyph bitmaps - int glyphW, glyphH; // size of glyph bitmaps, in pixels - GBool validBBox; // false if the bbox was [0 0 0 0] - int glyphSize; // size of glyph bitmaps, in bytes - int cacheSets; // number of sets in cache - int cacheAssoc; // cache associativity (glyphs per set) - Guchar *cacheData; // glyph pixmap cache - T3FontCacheTag *cacheTags; // cache tags, i.e., char codes -}; - -T3FontCache::T3FontCache(Ref *fontIDA, double m11A, double m12A, - double m21A, double m22A, - int glyphXA, int glyphYA, int glyphWA, int glyphHA, - GBool validBBoxA, GBool aa) { - int i; - - fontID = *fontIDA; - m11 = m11A; - m12 = m12A; - m21 = m21A; - m22 = m22A; - glyphX = glyphXA; - glyphY = glyphYA; - glyphW = glyphWA; - glyphH = glyphHA; - validBBox = validBBoxA; - // sanity check for excessively large glyphs (which most likely - // indicate an incorrect BBox) - i = glyphW * glyphH; - if (i > 100000 || glyphW > INT_MAX / glyphH || glyphW <= 0 || glyphH <= 0) { - glyphW = glyphH = 100; - validBBox = gFalse; - } - if (aa) { - glyphSize = glyphW * glyphH; - } else { - glyphSize = ((glyphW + 7) >> 3) * glyphH; - } - cacheAssoc = type3FontCacheAssoc; - for (cacheSets = type3FontCacheMaxSets; - cacheSets > 1 && - cacheSets * cacheAssoc * glyphSize > type3FontCacheSize; - cacheSets >>= 1) ; - if (glyphSize < 10485760 / cacheAssoc / cacheSets) { - cacheData = (Guchar *)gmallocn_checkoverflow(cacheSets * cacheAssoc, glyphSize); - } else { - error(errSyntaxWarning, -1, "Not creating cacheData for T3FontCache, it asked for too much memory.\n" - " This could teoretically result in wrong rendering,\n" - " but most probably the document is bogus.\n" - " Please report a bug if you think the rendering may be wrong because of this."); - cacheData = NULL; - } - if (cacheData != NULL) - { - cacheTags = (T3FontCacheTag *)gmallocn(cacheSets * cacheAssoc, - sizeof(T3FontCacheTag)); - for (i = 0; i < cacheSets * cacheAssoc; ++i) { - cacheTags[i].mru = i & (cacheAssoc - 1); - } - } - else - { - cacheTags = NULL; - } -} - -T3FontCache::~T3FontCache() { - gfree(cacheData); - gfree(cacheTags); -} - -struct T3GlyphStack { - Gushort code; // character code - - //----- cache info - T3FontCache *cache; // font cache for the current font - T3FontCacheTag *cacheTag; // pointer to cache tag for the glyph - Guchar *cacheData; // pointer to cache data for the glyph - - //----- saved state - SplashBitmap *origBitmap; - Splash *origSplash; - double origCTM4, origCTM5; - - T3GlyphStack *next; // next object on stack -}; - -//------------------------------------------------------------------------ -// SplashTransparencyGroup -//------------------------------------------------------------------------ - -struct SplashTransparencyGroup { - int tx, ty; // translation coordinates - SplashBitmap *tBitmap; // bitmap for transparency group - GfxColorSpace *blendingColorSpace; - GBool isolated; - - //----- for knockout - SplashBitmap *shape; - GBool knockout; - SplashCoord knockoutOpacity; - GBool fontAA; - - //----- saved state - SplashBitmap *origBitmap; - Splash *origSplash; - - SplashTransparencyGroup *next; -}; - -//------------------------------------------------------------------------ -// SplashOutputDev -//------------------------------------------------------------------------ - -SplashOutputDev::SplashOutputDev(SplashColorMode colorModeA, - int bitmapRowPadA, - GBool reverseVideoA, - SplashColorPtr paperColorA, - GBool bitmapTopDownA, - SplashThinLineMode thinLineMode, - GBool overprintPreviewA) { - colorMode = colorModeA; - bitmapRowPad = bitmapRowPadA; - bitmapTopDown = bitmapTopDownA; - bitmapUpsideDown = gFalse; - fontAntialias = gTrue; - vectorAntialias = gTrue; - overprintPreview = overprintPreviewA; - enableFreeTypeHinting = gFalse; - enableSlightHinting = gFalse; - setupScreenParams(72.0, 72.0); - reverseVideo = reverseVideoA; - if (paperColorA != NULL) { - splashColorCopy(paperColor, paperColorA); - } else { - splashClearColor(paperColor); - } - skipHorizText = gFalse; - skipRotatedText = gFalse; - keepAlphaChannel = paperColorA == NULL; - - doc = NULL; - - bitmap = new SplashBitmap(1, 1, bitmapRowPad, colorMode, - colorMode != splashModeMono1, bitmapTopDown); - splash = new Splash(bitmap, vectorAntialias, &screenParams); - splash->setMinLineWidth(globalParams->getMinLineWidth()); - splash->setThinLineMode(thinLineMode); - splash->clear(paperColor, 0); - - fontEngine = NULL; - - nT3Fonts = 0; - t3GlyphStack = NULL; - - font = NULL; - needFontUpdate = gFalse; - textClipPath = NULL; - transpGroupStack = NULL; - nestCount = 0; - xref = NULL; -} - -void SplashOutputDev::setupScreenParams(double hDPI, double vDPI) { - screenParams.size = globalParams->getScreenSize(); - screenParams.dotRadius = globalParams->getScreenDotRadius(); - screenParams.gamma = (SplashCoord)globalParams->getScreenGamma(); - screenParams.blackThreshold = - (SplashCoord)globalParams->getScreenBlackThreshold(); - screenParams.whiteThreshold = - (SplashCoord)globalParams->getScreenWhiteThreshold(); - switch (globalParams->getScreenType()) { - case screenDispersed: - screenParams.type = splashScreenDispersed; - if (screenParams.size < 0) { - screenParams.size = 4; - } - break; - case screenClustered: - screenParams.type = splashScreenClustered; - if (screenParams.size < 0) { - screenParams.size = 10; - } - break; - case screenStochasticClustered: - screenParams.type = splashScreenStochasticClustered; - if (screenParams.size < 0) { - screenParams.size = 64; - } - if (screenParams.dotRadius < 0) { - screenParams.dotRadius = 2; - } - break; - case screenUnset: - default: - // use clustered dithering for resolution >= 300 dpi - // (compare to 299.9 to avoid floating point issues) - if (hDPI > 299.9 && vDPI > 299.9) { - screenParams.type = splashScreenStochasticClustered; - if (screenParams.size < 0) { - screenParams.size = 64; - } - if (screenParams.dotRadius < 0) { - screenParams.dotRadius = 2; - } - } else { - screenParams.type = splashScreenDispersed; - if (screenParams.size < 0) { - screenParams.size = 4; - } - } - } -} - -SplashOutputDev::~SplashOutputDev() { - int i; - - for (i = 0; i < nT3Fonts; ++i) { - delete t3FontCache[i]; - } - if (fontEngine) { - delete fontEngine; - } - if (splash) { - delete splash; - } - if (bitmap) { - delete bitmap; - } -} - -void SplashOutputDev::startDoc(PDFDoc *docA) { - int i; - - doc = docA; - if (fontEngine) { - delete fontEngine; - } - fontEngine = new SplashFontEngine( -#if HAVE_T1LIB_H - globalParams->getEnableT1lib(), -#endif -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - globalParams->getEnableFreeType(), - enableFreeTypeHinting, - enableSlightHinting, -#endif - getFontAntialias() && - colorMode != splashModeMono1); - for (i = 0; i < nT3Fonts; ++i) { - delete t3FontCache[i]; - } - nT3Fonts = 0; -} - -void SplashOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) { - int w, h; - double *ctm; - SplashCoord mat[6]; - SplashColor color; - - xref = xrefA; - if (state) { - setupScreenParams(state->getHDPI(), state->getVDPI()); - w = (int)(state->getPageWidth() + 0.5); - if (w <= 0) { - w = 1; - } - h = (int)(state->getPageHeight() + 0.5); - if (h <= 0) { - h = 1; - } - } else { - w = h = 1; - } - SplashThinLineMode thinLineMode = splashThinLineDefault; - if (splash) { - thinLineMode = splash->getThinLineMode(); - delete splash; - splash = NULL; - } - if (!bitmap || w != bitmap->getWidth() || h != bitmap->getHeight()) { - if (bitmap) { - delete bitmap; - bitmap = NULL; - } - bitmap = new SplashBitmap(w, h, bitmapRowPad, colorMode, - colorMode != splashModeMono1, bitmapTopDown); - if (!bitmap->getDataPtr()) { - delete bitmap; - w = h = 1; - bitmap = new SplashBitmap(w, h, bitmapRowPad, colorMode, - colorMode != splashModeMono1, bitmapTopDown); - } - } - splash = new Splash(bitmap, vectorAntialias, &screenParams); - splash->setThinLineMode(thinLineMode); - splash->setMinLineWidth(globalParams->getMinLineWidth()); - if (state) { - ctm = state->getCTM(); - mat[0] = (SplashCoord)ctm[0]; - mat[1] = (SplashCoord)ctm[1]; - mat[2] = (SplashCoord)ctm[2]; - mat[3] = (SplashCoord)ctm[3]; - mat[4] = (SplashCoord)ctm[4]; - mat[5] = (SplashCoord)ctm[5]; - splash->setMatrix(mat); - } - switch (colorMode) { - case splashModeMono1: - case splashModeMono8: - color[0] = 0; - break; - case splashModeXBGR8: - color[3] = 255; - case splashModeRGB8: - case splashModeBGR8: - color[0] = color[1] = color[2] = 0; - break; -#if SPLASH_CMYK - case splashModeCMYK8: - color[0] = color[1] = color[2] = color[3] = 0; - break; - case splashModeDeviceN8: - for (int i = 0; i < 4 + SPOT_NCOMPS; i++) - color[i] = 0; - break; -#endif - } - splash->setStrokePattern(new SplashSolidColor(color)); - splash->setFillPattern(new SplashSolidColor(color)); - splash->setLineCap(splashLineCapButt); - splash->setLineJoin(splashLineJoinMiter); - splash->setLineDash(NULL, 0, 0); - splash->setMiterLimit(10); - splash->setFlatness(1); - // the SA parameter supposedly defaults to false, but Acrobat - // apparently hardwires it to true - splash->setStrokeAdjust(globalParams->getStrokeAdjust()); - splash->clear(paperColor, 0); -} - -void SplashOutputDev::endPage() { - if (colorMode != splashModeMono1 && !keepAlphaChannel) { - splash->compositeBackground(paperColor); - } -} - -void SplashOutputDev::saveState(GfxState *state) { - splash->saveState(); -} - -void SplashOutputDev::restoreState(GfxState *state) { - splash->restoreState(); - needFontUpdate = gTrue; -} - -void SplashOutputDev::updateAll(GfxState *state) { - updateLineDash(state); - updateLineJoin(state); - updateLineCap(state); - updateLineWidth(state); - updateFlatness(state); - updateMiterLimit(state); - updateStrokeAdjust(state); - updateFillColorSpace(state); - updateFillColor(state); - updateStrokeColorSpace(state); - updateStrokeColor(state); - needFontUpdate = gTrue; -} - -void SplashOutputDev::updateCTM(GfxState *state, double m11, double m12, - double m21, double m22, - double m31, double m32) { - double *ctm; - SplashCoord mat[6]; - - ctm = state->getCTM(); - mat[0] = (SplashCoord)ctm[0]; - mat[1] = (SplashCoord)ctm[1]; - mat[2] = (SplashCoord)ctm[2]; - mat[3] = (SplashCoord)ctm[3]; - mat[4] = (SplashCoord)ctm[4]; - mat[5] = (SplashCoord)ctm[5]; - splash->setMatrix(mat); -} - -void SplashOutputDev::updateLineDash(GfxState *state) { - double *dashPattern; - int dashLength; - double dashStart; - SplashCoord dash[20]; - int i; - - state->getLineDash(&dashPattern, &dashLength, &dashStart); - if (dashLength > 20) { - dashLength = 20; - } - for (i = 0; i < dashLength; ++i) { - dash[i] = (SplashCoord)dashPattern[i]; - if (dash[i] < 0) { - dash[i] = 0; - } - } - splash->setLineDash(dash, dashLength, (SplashCoord)dashStart); -} - -void SplashOutputDev::updateFlatness(GfxState *state) { -#if 0 // Acrobat ignores the flatness setting, and always renders curves - // with a fairly small flatness value - splash->setFlatness(state->getFlatness()); -#endif -} - -void SplashOutputDev::updateLineJoin(GfxState *state) { - splash->setLineJoin(state->getLineJoin()); -} - -void SplashOutputDev::updateLineCap(GfxState *state) { - splash->setLineCap(state->getLineCap()); -} - -void SplashOutputDev::updateMiterLimit(GfxState *state) { - splash->setMiterLimit(state->getMiterLimit()); -} - -void SplashOutputDev::updateLineWidth(GfxState *state) { - splash->setLineWidth(state->getLineWidth()); -} - -void SplashOutputDev::updateStrokeAdjust(GfxState * /*state*/) { -#if 0 // the SA parameter supposedly defaults to false, but Acrobat - // apparently hardwires it to true - splash->setStrokeAdjust(state->getStrokeAdjust()); -#endif -} - -void SplashOutputDev::updateFillColorSpace(GfxState *state) { -#if SPLASH_CMYK - if (colorMode == splashModeDeviceN8) - state->getFillColorSpace()->createMapping(bitmap->getSeparationList(), SPOT_NCOMPS); -#endif -} - -void SplashOutputDev::updateStrokeColorSpace(GfxState *state) { -#if SPLASH_CMYK - if (colorMode == splashModeDeviceN8) - state->getStrokeColorSpace()->createMapping(bitmap->getSeparationList(), SPOT_NCOMPS); -#endif -} - -void SplashOutputDev::updateFillColor(GfxState *state) { - GfxGray gray; - GfxRGB rgb; -#if SPLASH_CMYK - GfxCMYK cmyk; - GfxColor deviceN; -#endif - - switch (colorMode) { - case splashModeMono1: - case splashModeMono8: - state->getFillGray(&gray); - splash->setFillPattern(getColor(gray)); - break; - case splashModeXBGR8: - case splashModeRGB8: - case splashModeBGR8: - state->getFillRGB(&rgb); - splash->setFillPattern(getColor(&rgb)); - break; -#if SPLASH_CMYK - case splashModeCMYK8: - state->getFillCMYK(&cmyk); - splash->setFillPattern(getColor(&cmyk)); - break; - case splashModeDeviceN8: - state->getFillDeviceN(&deviceN); - splash->setFillPattern(getColor(&deviceN)); - break; -#endif - } -} - -void SplashOutputDev::updateStrokeColor(GfxState *state) { - GfxGray gray; - GfxRGB rgb; -#if SPLASH_CMYK - GfxCMYK cmyk; - GfxColor deviceN; -#endif - - switch (colorMode) { - case splashModeMono1: - case splashModeMono8: - state->getStrokeGray(&gray); - splash->setStrokePattern(getColor(gray)); - break; - case splashModeXBGR8: - case splashModeRGB8: - case splashModeBGR8: - state->getStrokeRGB(&rgb); - splash->setStrokePattern(getColor(&rgb)); - break; -#if SPLASH_CMYK - case splashModeCMYK8: - state->getStrokeCMYK(&cmyk); - splash->setStrokePattern(getColor(&cmyk)); - break; - case splashModeDeviceN8: - state->getStrokeDeviceN(&deviceN); - splash->setStrokePattern(getColor(&deviceN)); - break; -#endif - } -} - -SplashPattern *SplashOutputDev::getColor(GfxGray gray) { - SplashColor color; - - if (reverseVideo) { - gray = gfxColorComp1 - gray; - } - color[0] = colToByte(gray); - return new SplashSolidColor(color); -} - -SplashPattern *SplashOutputDev::getColor(GfxRGB *rgb) { - GfxColorComp r, g, b; - SplashColor color; - - if (reverseVideo) { - r = gfxColorComp1 - rgb->r; - g = gfxColorComp1 - rgb->g; - b = gfxColorComp1 - rgb->b; - } else { - r = rgb->r; - g = rgb->g; - b = rgb->b; - } - color[0] = colToByte(r); - color[1] = colToByte(g); - color[2] = colToByte(b); - if (colorMode == splashModeXBGR8) color[3] = 255; - return new SplashSolidColor(color); -} - -#if SPLASH_CMYK -SplashPattern *SplashOutputDev::getColor(GfxCMYK *cmyk) { - SplashColor color; - - color[0] = colToByte(cmyk->c); - color[1] = colToByte(cmyk->m); - color[2] = colToByte(cmyk->y); - color[3] = colToByte(cmyk->k); - return new SplashSolidColor(color); -} - -SplashPattern *SplashOutputDev::getColor(GfxColor *deviceN) { - SplashColor color; - - for (int i = 0; i < 4 + SPOT_NCOMPS; i++) - color[i] = colToByte(deviceN->c[i]); - return new SplashSolidColor(color); -} -#endif - -void SplashOutputDev::setOverprintMask(GfxColorSpace *colorSpace, - GBool overprintFlag, - int overprintMode, - GfxColor *singleColor, - GBool grayIndexed) { -#if SPLASH_CMYK - Guint mask; - GfxCMYK cmyk; - GBool additive = gFalse; - int i; - - if (colorSpace->getMode() == csIndexed) { - setOverprintMask(((GfxIndexedColorSpace *)colorSpace)->getBase(), - overprintFlag, - overprintMode, - singleColor, - grayIndexed); - return; - } - if (overprintFlag && overprintPreview) { - mask = colorSpace->getOverprintMask(); - if (singleColor && overprintMode && - colorSpace->getMode() == csDeviceCMYK) { - colorSpace->getCMYK(singleColor, &cmyk); - if (cmyk.c == 0) { - mask &= ~1; - } - if (cmyk.m == 0) { - mask &= ~2; - } - if (cmyk.y == 0) { - mask &= ~4; - } - if (cmyk.k == 0) { - mask &= ~8; - } - } - if (grayIndexed) { - mask &= ~7; - } else if (colorSpace->getMode() == csSeparation) { - GfxSeparationColorSpace *deviceSep = (GfxSeparationColorSpace *)colorSpace; - additive = deviceSep->getName()->cmp("All") != 0 && mask == 0x0f && !deviceSep->isNonMarking(); - } else if (colorSpace->getMode() == csDeviceN) { - GfxDeviceNColorSpace *deviceNCS = (GfxDeviceNColorSpace *)colorSpace; - additive = mask == 0x0f && !deviceNCS->isNonMarking(); - for (i = 0; i < deviceNCS->getNComps() && additive; i++) { - if (deviceNCS->getColorantName(i)->cmp("Cyan") == 0) { - additive = gFalse; - } else if (deviceNCS->getColorantName(i)->cmp("Magenta") == 0) { - additive = gFalse; - } else if (deviceNCS->getColorantName(i)->cmp("Yellow") == 0) { - additive = gFalse; - } else if (deviceNCS->getColorantName(i)->cmp("Black") == 0) { - additive = gFalse; - } - } - } - } else { - mask = 0xffffffff; - } - splash->setOverprintMask(mask, additive); -#endif -} - -void SplashOutputDev::updateBlendMode(GfxState *state) { - splash->setBlendFunc(splashOutBlendFuncs[state->getBlendMode()]); -} - -void SplashOutputDev::updateFillOpacity(GfxState *state) { - splash->setFillAlpha((SplashCoord)state->getFillOpacity()); - if (transpGroupStack != NULL && (SplashCoord)state->getFillOpacity() < transpGroupStack->knockoutOpacity) { - transpGroupStack->knockoutOpacity = (SplashCoord)state->getFillOpacity(); - } -} - -void SplashOutputDev::updateStrokeOpacity(GfxState *state) { - splash->setStrokeAlpha((SplashCoord)state->getStrokeOpacity()); - if (transpGroupStack != NULL && (SplashCoord)state->getStrokeOpacity() < transpGroupStack->knockoutOpacity) { - transpGroupStack->knockoutOpacity = (SplashCoord)state->getStrokeOpacity(); - } -} - -void SplashOutputDev::updateFillOverprint(GfxState *state) { - splash->setFillOverprint(state->getFillOverprint()); -} - -void SplashOutputDev::updateStrokeOverprint(GfxState *state) { - splash->setStrokeOverprint(state->getStrokeOverprint()); -} - -void SplashOutputDev::updateOverprintMode(GfxState *state) { - splash->setOverprintMode(state->getOverprintMode()); -} - -void SplashOutputDev::updateTransfer(GfxState *state) { - Function **transfer; - Guchar red[256], green[256], blue[256], gray[256]; - double x, y; - int i; - - transfer = state->getTransfer(); - if (transfer[0] && - transfer[0]->getInputSize() == 1 && - transfer[0]->getOutputSize() == 1) { - if (transfer[1] && - transfer[1]->getInputSize() == 1 && - transfer[1]->getOutputSize() == 1 && - transfer[2] && - transfer[2]->getInputSize() == 1 && - transfer[2]->getOutputSize() == 1 && - transfer[3] && - transfer[3]->getInputSize() == 1 && - transfer[3]->getOutputSize() == 1) { - for (i = 0; i < 256; ++i) { - x = i / 255.0; - transfer[0]->transform(&x, &y); - red[i] = (Guchar)(y * 255.0 + 0.5); - transfer[1]->transform(&x, &y); - green[i] = (Guchar)(y * 255.0 + 0.5); - transfer[2]->transform(&x, &y); - blue[i] = (Guchar)(y * 255.0 + 0.5); - transfer[3]->transform(&x, &y); - gray[i] = (Guchar)(y * 255.0 + 0.5); - } - } else { - for (i = 0; i < 256; ++i) { - x = i / 255.0; - transfer[0]->transform(&x, &y); - red[i] = green[i] = blue[i] = gray[i] = (Guchar)(y * 255.0 + 0.5); - } - } - } else { - for (i = 0; i < 256; ++i) { - red[i] = green[i] = blue[i] = gray[i] = (Guchar)i; - } - } - splash->setTransfer(red, green, blue, gray); -} - -void SplashOutputDev::updateFont(GfxState * /*state*/) { - needFontUpdate = gTrue; -} - -void SplashOutputDev::doUpdateFont(GfxState *state) { - GfxFont *gfxFont; - GfxFontLoc *fontLoc; - GfxFontType fontType; - SplashOutFontFileID *id; - SplashFontFile *fontFile; - SplashFontSrc *fontsrc = NULL; - FoFiTrueType *ff; - Object refObj, strObj; - GooString *fileName; - char *tmpBuf; - int tmpBufLen; - int *codeToGID; - double *textMat; - double m11, m12, m21, m22, fontSize; - int faceIndex = 0; - SplashCoord mat[4]; - int n, i; - GBool recreateFont = gFalse; - GBool doAdjustFontMatrix = gFalse; - - needFontUpdate = gFalse; - font = NULL; - fileName = NULL; - tmpBuf = NULL; - fontLoc = NULL; - - if (!(gfxFont = state->getFont())) { - goto err1; - } - fontType = gfxFont->getType(); - if (fontType == fontType3) { - goto err1; - } - - // sanity-check the font size - skip anything larger than 10 inches - // (this avoids problems allocating memory for the font cache) - if (state->getTransformedFontSize() - > 10 * (state->getHDPI() + state->getVDPI())) { - goto err1; - } - - // check the font file cache - id = new SplashOutFontFileID(gfxFont->getID()); - if ((fontFile = fontEngine->getFontFile(id))) { - delete id; - - } else { - - if (!(fontLoc = gfxFont->locateFont((xref) ? xref : doc->getXRef(), NULL))) { - error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'", - gfxFont->getName() ? gfxFont->getName()->getCString() - : "(unnamed)"); - goto err2; - } - - // embedded font - if (fontLoc->locType == gfxFontLocEmbedded) { - // if there is an embedded font, read it to memory - tmpBuf = gfxFont->readEmbFontFile((xref) ? xref : doc->getXRef(), &tmpBufLen); - if (! tmpBuf) - goto err2; - - // external font - } else { // gfxFontLocExternal - fileName = fontLoc->path; - fontType = fontLoc->fontType; - doAdjustFontMatrix = gTrue; - } - - fontsrc = new SplashFontSrc; - if (fileName) - fontsrc->setFile(fileName, gFalse); - else - fontsrc->setBuf(tmpBuf, tmpBufLen, gTrue); - - // load the font file - switch (fontType) { - case fontType1: - if (!(fontFile = fontEngine->loadType1Font( - id, - fontsrc, - (const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) { - error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", - gfxFont->getName() ? gfxFont->getName()->getCString() - : "(unnamed)"); - goto err2; - } - break; - case fontType1C: - if (!(fontFile = fontEngine->loadType1CFont( - id, - fontsrc, - (const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) { - error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", - gfxFont->getName() ? gfxFont->getName()->getCString() - : "(unnamed)"); - goto err2; - } - break; - case fontType1COT: - if (!(fontFile = fontEngine->loadOpenTypeT1CFont( - id, - fontsrc, - (const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) { - error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", - gfxFont->getName() ? gfxFont->getName()->getCString() - : "(unnamed)"); - goto err2; - } - break; - case fontTrueType: - case fontTrueTypeOT: - if (fileName) - ff = FoFiTrueType::load(fileName->getCString()); - else - ff = FoFiTrueType::make(tmpBuf, tmpBufLen); - if (ff) { - codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff); - n = 256; - delete ff; - // if we're substituting for a non-TrueType font, we need to mark - // all notdef codes as "do not draw" (rather than drawing TrueType - // notdef glyphs) - if (gfxFont->getType() != fontTrueType && - gfxFont->getType() != fontTrueTypeOT) { - for (i = 0; i < 256; ++i) { - if (codeToGID[i] == 0) { - codeToGID[i] = -1; - } - } - } - } else { - codeToGID = NULL; - n = 0; - } - if (!(fontFile = fontEngine->loadTrueTypeFont( - id, - fontsrc, - codeToGID, n))) { - error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", - gfxFont->getName() ? gfxFont->getName()->getCString() - : "(unnamed)"); - goto err2; - } - break; - case fontCIDType0: - case fontCIDType0C: - if (!(fontFile = fontEngine->loadCIDFont( - id, - fontsrc))) { - error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", - gfxFont->getName() ? gfxFont->getName()->getCString() - : "(unnamed)"); - goto err2; - } - break; - case fontCIDType0COT: - if (((GfxCIDFont *)gfxFont)->getCIDToGID()) { - n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen(); - codeToGID = (int *)gmallocn(n, sizeof(int)); - memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), - n * sizeof(int)); - } else { - codeToGID = NULL; - n = 0; - } - if (!(fontFile = fontEngine->loadOpenTypeCFFFont( - id, - fontsrc, - codeToGID, n))) { - error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", - gfxFont->getName() ? gfxFont->getName()->getCString() - : "(unnamed)"); - goto err2; - } - break; - case fontCIDType2: - case fontCIDType2OT: - codeToGID = NULL; - n = 0; - if (((GfxCIDFont *)gfxFont)->getCIDToGID()) { - n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen(); - if (n) { - codeToGID = (int *)gmallocn(n, sizeof(int)); - memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), - n * sizeof(int)); - } - } else { - if (fileName) - ff = FoFiTrueType::load(fileName->getCString()); - else - ff = FoFiTrueType::make(tmpBuf, tmpBufLen); - if (! ff) - { - error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", - gfxFont->getName() ? gfxFont->getName()->getCString() - : "(unnamed)"); - goto err2; - } - codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n); - delete ff; - } - if (!(fontFile = fontEngine->loadTrueTypeFont( - id, - fontsrc, - codeToGID, n, faceIndex))) { - error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", - gfxFont->getName() ? gfxFont->getName()->getCString() - : "(unnamed)"); - goto err2; - } - break; - default: - // this shouldn't happen - goto err2; - } - fontFile->doAdjustMatrix = doAdjustFontMatrix; - } - - // get the font matrix - textMat = state->getTextMat(); - fontSize = state->getFontSize(); - m11 = textMat[0] * fontSize * state->getHorizScaling(); - m12 = textMat[1] * fontSize * state->getHorizScaling(); - m21 = textMat[2] * fontSize; - m22 = textMat[3] * fontSize; - - // create the scaled font - mat[0] = m11; mat[1] = m12; - mat[2] = m21; mat[3] = m22; - font = fontEngine->getFont(fontFile, mat, splash->getMatrix()); - - // for substituted fonts: adjust the font matrix -- compare the - // width of 'm' in the original font and the substituted font - if (fontFile->doAdjustMatrix && !gfxFont->isCIDFont()) { - double w1, w2; - CharCode code; - char *name; - for (code = 0; code < 256; ++code) { - if ((name = ((Gfx8BitFont *)gfxFont)->getCharName(code)) && - name[0] == 'm' && name[1] == '\0') { - break; - } - } - if (code < 256) { - w1 = ((Gfx8BitFont *)gfxFont)->getWidth(code); - w2 = font->getGlyphAdvance(code); - if (!gfxFont->isSymbolic() && w2 > 0) { - // if real font is substantially narrower than substituted - // font, reduce the font size accordingly - if (w1 > 0.01 && w1 < 0.9 * w2) { - w1 /= w2; - m11 *= w1; - m21 *= w1; - recreateFont = gTrue; - } - } - } - } - - if (recreateFont) - { - mat[0] = m11; mat[1] = m12; - mat[2] = m21; mat[3] = m22; - font = fontEngine->getFont(fontFile, mat, splash->getMatrix()); - } - - delete fontLoc; - if (fontsrc && !fontsrc->isFile) - fontsrc->unref(); - return; - - err2: - delete id; - delete fontLoc; - err1: - if (fontsrc && !fontsrc->isFile) - fontsrc->unref(); - return; -} - -void SplashOutputDev::stroke(GfxState *state) { - SplashPath *path; - - if (state->getStrokeColorSpace()->isNonMarking()) { - return; - } - setOverprintMask(state->getStrokeColorSpace(), state->getStrokeOverprint(), - state->getOverprintMode(), state->getStrokeColor()); - path = convertPath(state, state->getPath(), gFalse); - splash->stroke(path); - delete path; -} - -void SplashOutputDev::fill(GfxState *state) { - SplashPath *path; - - if (state->getFillColorSpace()->isNonMarking()) { - return; - } - setOverprintMask(state->getFillColorSpace(), state->getFillOverprint(), - state->getOverprintMode(), state->getFillColor()); - path = convertPath(state, state->getPath(), gTrue); - splash->fill(path, gFalse); - delete path; -} - -void SplashOutputDev::eoFill(GfxState *state) { - SplashPath *path; - - if (state->getFillColorSpace()->isNonMarking()) { - return; - } - setOverprintMask(state->getFillColorSpace(), state->getFillOverprint(), - state->getOverprintMode(), state->getFillColor()); - path = convertPath(state, state->getPath(), gTrue); - splash->fill(path, gTrue); - delete path; -} - -void SplashOutputDev::clip(GfxState *state) { - SplashPath *path; - - path = convertPath(state, state->getPath(), gTrue); - splash->clipToPath(path, gFalse); - delete path; -} - -void SplashOutputDev::eoClip(GfxState *state) { - SplashPath *path; - - path = convertPath(state, state->getPath(), gTrue); - splash->clipToPath(path, gTrue); - delete path; -} - -void SplashOutputDev::clipToStrokePath(GfxState *state) { - SplashPath *path, *path2; - - path = convertPath(state, state->getPath(), gFalse); - path2 = splash->makeStrokePath(path, state->getLineWidth()); - delete path; - splash->clipToPath(path2, gFalse); - delete path2; -} - -SplashPath *SplashOutputDev::convertPath(GfxState *state, GfxPath *path, - GBool dropEmptySubpaths) { - SplashPath *sPath; - GfxSubpath *subpath; - int n, i, j; - - n = dropEmptySubpaths ? 1 : 0; - sPath = new SplashPath(); - for (i = 0; i < path->getNumSubpaths(); ++i) { - subpath = path->getSubpath(i); - if (subpath->getNumPoints() > n) { - sPath->moveTo((SplashCoord)subpath->getX(0), - (SplashCoord)subpath->getY(0)); - j = 1; - while (j < subpath->getNumPoints()) { - if (subpath->getCurve(j)) { - sPath->curveTo((SplashCoord)subpath->getX(j), - (SplashCoord)subpath->getY(j), - (SplashCoord)subpath->getX(j+1), - (SplashCoord)subpath->getY(j+1), - (SplashCoord)subpath->getX(j+2), - (SplashCoord)subpath->getY(j+2)); - j += 3; - } else { - sPath->lineTo((SplashCoord)subpath->getX(j), - (SplashCoord)subpath->getY(j)); - ++j; - } - } - if (subpath->isClosed()) { - sPath->close(); - } - } - } - return sPath; -} - -void SplashOutputDev::drawChar(GfxState *state, double x, double y, - double dx, double dy, - double originX, double originY, - CharCode code, int nBytes, - Unicode *u, int uLen) { - SplashPath *path; - int render; - GBool doFill, doStroke, doClip, strokeAdjust; - double m[4]; - GBool horiz; - - if (skipHorizText || skipRotatedText) { - state->getFontTransMat(&m[0], &m[1], &m[2], &m[3]); - horiz = m[0] > 0 && fabs(m[1]) < 0.001 && - fabs(m[2]) < 0.001 && m[3] < 0; - if ((skipHorizText && horiz) || (skipRotatedText && !horiz)) { - return; - } - } - - // check for invisible text -- this is used by Acrobat Capture - render = state->getRender(); - if (render == 3) { - return; - } - - if (needFontUpdate) { - doUpdateFont(state); - } - if (!font) { - return; - } - - x -= originX; - y -= originY; - - doFill = !(render & 1) && !state->getFillColorSpace()->isNonMarking(); - doStroke = ((render & 3) == 1 || (render & 3) == 2) && - !state->getStrokeColorSpace()->isNonMarking(); - doClip = render & 4; - - path = NULL; - if (doStroke || doClip) { - if ((path = font->getGlyphPath(code))) { - path->offset((SplashCoord)x, (SplashCoord)y); - } - } - - // don't use stroke adjustment when stroking text -- the results - // tend to be ugly (because characters with horizontal upper or - // lower edges get misaligned relative to the other characters) - strokeAdjust = gFalse; // make gcc happy - if (doStroke) { - strokeAdjust = splash->getStrokeAdjust(); - splash->setStrokeAdjust(gFalse); - } - - // fill and stroke - if (doFill && doStroke) { - if (path) { - setOverprintMask(state->getFillColorSpace(), state->getFillOverprint(), - state->getOverprintMode(), state->getFillColor()); - splash->fill(path, gFalse); - setOverprintMask(state->getStrokeColorSpace(), - state->getStrokeOverprint(), - state->getOverprintMode(), - state->getStrokeColor()); - splash->stroke(path); - } - - // fill - } else if (doFill) { - setOverprintMask(state->getFillColorSpace(), state->getFillOverprint(), - state->getOverprintMode(), state->getFillColor()); - splash->fillChar((SplashCoord)x, (SplashCoord)y, code, font); - - // stroke - } else if (doStroke) { - if (path) { - setOverprintMask(state->getStrokeColorSpace(), - state->getStrokeOverprint(), - state->getOverprintMode(), - state->getStrokeColor()); - splash->stroke(path); - } - } - - // clip - if (doClip) { - if (path) { - if (textClipPath) { - textClipPath->append(path); - } else { - textClipPath = path; - path = NULL; - } - } - } - - if (doStroke) { - splash->setStrokeAdjust(strokeAdjust); - } - - if (path) { - delete path; - } -} - -GBool SplashOutputDev::beginType3Char(GfxState *state, double x, double y, - double dx, double dy, - CharCode code, Unicode *u, int uLen) { - GfxFont *gfxFont; - Ref *fontID; - double *ctm, *bbox; - T3FontCache *t3Font; - T3GlyphStack *t3gs; - GBool validBBox; - double m[4]; - GBool horiz; - double x1, y1, xMin, yMin, xMax, yMax, xt, yt; - int i, j; - - if (skipHorizText || skipRotatedText) { - state->getFontTransMat(&m[0], &m[1], &m[2], &m[3]); - horiz = m[0] > 0 && fabs(m[1]) < 0.001 && - fabs(m[2]) < 0.001 && m[3] < 0; - if ((skipHorizText && horiz) || (skipRotatedText && !horiz)) { - return gTrue; - } - } - - if (!(gfxFont = state->getFont())) { - return gFalse; - } - fontID = gfxFont->getID(); - ctm = state->getCTM(); - state->transform(0, 0, &xt, &yt); - - // is it the first (MRU) font in the cache? - if (!(nT3Fonts > 0 && - t3FontCache[0]->matches(fontID, ctm[0], ctm[1], ctm[2], ctm[3]))) { - - // is the font elsewhere in the cache? - for (i = 1; i < nT3Fonts; ++i) { - if (t3FontCache[i]->matches(fontID, ctm[0], ctm[1], ctm[2], ctm[3])) { - t3Font = t3FontCache[i]; - for (j = i; j > 0; --j) { - t3FontCache[j] = t3FontCache[j - 1]; - } - t3FontCache[0] = t3Font; - break; - } - } - if (i >= nT3Fonts) { - - // create new entry in the font cache - if (nT3Fonts == splashOutT3FontCacheSize) { - t3gs = t3GlyphStack; - while (t3gs != NULL) { - if (t3gs->cache == t3FontCache[nT3Fonts - 1]) { - error(errSyntaxWarning, -1, "t3FontCache reaches limit but font still on stack in SplashOutputDev::beginType3Char"); - return gTrue; - } - t3gs = t3gs->next; - } - delete t3FontCache[nT3Fonts - 1]; - --nT3Fonts; - } - for (j = nT3Fonts; j > 0; --j) { - t3FontCache[j] = t3FontCache[j - 1]; - } - ++nT3Fonts; - bbox = gfxFont->getFontBBox(); - if (bbox[0] == 0 && bbox[1] == 0 && bbox[2] == 0 && bbox[3] == 0) { - // unspecified bounding box -- just take a guess - xMin = xt - 5; - xMax = xMin + 30; - yMax = yt + 15; - yMin = yMax - 45; - validBBox = gFalse; - } else { - state->transform(bbox[0], bbox[1], &x1, &y1); - xMin = xMax = x1; - yMin = yMax = y1; - state->transform(bbox[0], bbox[3], &x1, &y1); - if (x1 < xMin) { - xMin = x1; - } else if (x1 > xMax) { - xMax = x1; - } - if (y1 < yMin) { - yMin = y1; - } else if (y1 > yMax) { - yMax = y1; - } - state->transform(bbox[2], bbox[1], &x1, &y1); - if (x1 < xMin) { - xMin = x1; - } else if (x1 > xMax) { - xMax = x1; - } - if (y1 < yMin) { - yMin = y1; - } else if (y1 > yMax) { - yMax = y1; - } - state->transform(bbox[2], bbox[3], &x1, &y1); - if (x1 < xMin) { - xMin = x1; - } else if (x1 > xMax) { - xMax = x1; - } - if (y1 < yMin) { - yMin = y1; - } else if (y1 > yMax) { - yMax = y1; - } - validBBox = gTrue; - } - t3FontCache[0] = new T3FontCache(fontID, ctm[0], ctm[1], ctm[2], ctm[3], - (int)floor(xMin - xt) - 2, - (int)floor(yMin - yt) - 2, - (int)ceil(xMax) - (int)floor(xMin) + 4, - (int)ceil(yMax) - (int)floor(yMin) + 4, - validBBox, - colorMode != splashModeMono1); - } - } - t3Font = t3FontCache[0]; - - // is the glyph in the cache? - i = (code & (t3Font->cacheSets - 1)) * t3Font->cacheAssoc; - for (j = 0; j < t3Font->cacheAssoc; ++j) { - if (t3Font->cacheTags != NULL) { - if ((t3Font->cacheTags[i+j].mru & 0x8000) && - t3Font->cacheTags[i+j].code == code) { - drawType3Glyph(state, t3Font, &t3Font->cacheTags[i+j], - t3Font->cacheData + (i+j) * t3Font->glyphSize); - return gTrue; - } - } - } - - // push a new Type 3 glyph record - t3gs = new T3GlyphStack(); - t3gs->next = t3GlyphStack; - t3GlyphStack = t3gs; - t3GlyphStack->code = code; - t3GlyphStack->cache = t3Font; - t3GlyphStack->cacheTag = NULL; - t3GlyphStack->cacheData = NULL; - - haveT3Dx = gFalse; - - return gFalse; -} - -void SplashOutputDev::endType3Char(GfxState *state) { - T3GlyphStack *t3gs; - double *ctm; - - if (t3GlyphStack->cacheTag) { - --nestCount; - memcpy(t3GlyphStack->cacheData, bitmap->getDataPtr(), - t3GlyphStack->cache->glyphSize); - delete bitmap; - delete splash; - bitmap = t3GlyphStack->origBitmap; - splash = t3GlyphStack->origSplash; - ctm = state->getCTM(); - state->setCTM(ctm[0], ctm[1], ctm[2], ctm[3], - t3GlyphStack->origCTM4, t3GlyphStack->origCTM5); - updateCTM(state, 0, 0, 0, 0, 0, 0); - drawType3Glyph(state, t3GlyphStack->cache, - t3GlyphStack->cacheTag, t3GlyphStack->cacheData); - } - t3gs = t3GlyphStack; - t3GlyphStack = t3gs->next; - delete t3gs; -} - -void SplashOutputDev::type3D0(GfxState *state, double wx, double wy) { - haveT3Dx = gTrue; -} - -void SplashOutputDev::type3D1(GfxState *state, double wx, double wy, - double llx, double lly, double urx, double ury) { - double *ctm; - T3FontCache *t3Font; - SplashColor color; - double xt, yt, xMin, xMax, yMin, yMax, x1, y1; - int i, j; - - // ignore multiple d0/d1 operators - if (haveT3Dx) { - return; - } - haveT3Dx = gTrue; - - if (unlikely(t3GlyphStack == NULL)) { - error(errSyntaxWarning, -1, "t3GlyphStack was null in SplashOutputDev::type3D1"); - return; - } - - if (unlikely(t3GlyphStack->origBitmap != NULL)) { - error(errSyntaxWarning, -1, "t3GlyphStack origBitmap was not null in SplashOutputDev::type3D1"); - return; - } - - if (unlikely(t3GlyphStack->origSplash != NULL)) { - error(errSyntaxWarning, -1, "t3GlyphStack origSplash was not null in SplashOutputDev::type3D1"); - return; - } - - t3Font = t3GlyphStack->cache; - - // check for a valid bbox - state->transform(0, 0, &xt, &yt); - state->transform(llx, lly, &x1, &y1); - xMin = xMax = x1; - yMin = yMax = y1; - state->transform(llx, ury, &x1, &y1); - if (x1 < xMin) { - xMin = x1; - } else if (x1 > xMax) { - xMax = x1; - } - if (y1 < yMin) { - yMin = y1; - } else if (y1 > yMax) { - yMax = y1; - } - state->transform(urx, lly, &x1, &y1); - if (x1 < xMin) { - xMin = x1; - } else if (x1 > xMax) { - xMax = x1; - } - if (y1 < yMin) { - yMin = y1; - } else if (y1 > yMax) { - yMax = y1; - } - state->transform(urx, ury, &x1, &y1); - if (x1 < xMin) { - xMin = x1; - } else if (x1 > xMax) { - xMax = x1; - } - if (y1 < yMin) { - yMin = y1; - } else if (y1 > yMax) { - yMax = y1; - } - if (xMin - xt < t3Font->glyphX || - yMin - yt < t3Font->glyphY || - xMax - xt > t3Font->glyphX + t3Font->glyphW || - yMax - yt > t3Font->glyphY + t3Font->glyphH) { - if (t3Font->validBBox) { - error(errSyntaxWarning, -1, "Bad bounding box in Type 3 glyph"); - } - return; - } - - if (t3Font->cacheTags == NULL) - return; - - // allocate a cache entry - i = (t3GlyphStack->code & (t3Font->cacheSets - 1)) * t3Font->cacheAssoc; - for (j = 0; j < t3Font->cacheAssoc; ++j) { - if ((t3Font->cacheTags[i+j].mru & 0x7fff) == t3Font->cacheAssoc - 1) { - t3Font->cacheTags[i+j].mru = 0x8000; - t3Font->cacheTags[i+j].code = t3GlyphStack->code; - t3GlyphStack->cacheTag = &t3Font->cacheTags[i+j]; - t3GlyphStack->cacheData = t3Font->cacheData + (i+j) * t3Font->glyphSize; - } else { - ++t3Font->cacheTags[i+j].mru; - } - } - - // save state - t3GlyphStack->origBitmap = bitmap; - t3GlyphStack->origSplash = splash; - ctm = state->getCTM(); - t3GlyphStack->origCTM4 = ctm[4]; - t3GlyphStack->origCTM5 = ctm[5]; - - // create the temporary bitmap - if (colorMode == splashModeMono1) { - bitmap = new SplashBitmap(t3Font->glyphW, t3Font->glyphH, 1, - splashModeMono1, gFalse); - splash = new Splash(bitmap, gFalse, - t3GlyphStack->origSplash->getScreen()); - color[0] = 0; - splash->clear(color); - color[0] = 0xff; - } else { - bitmap = new SplashBitmap(t3Font->glyphW, t3Font->glyphH, 1, - splashModeMono8, gFalse); - splash = new Splash(bitmap, vectorAntialias, - t3GlyphStack->origSplash->getScreen()); - color[0] = 0x00; - splash->clear(color); - color[0] = 0xff; - } - splash->setMinLineWidth(globalParams->getMinLineWidth()); - splash->setThinLineMode(splashThinLineDefault); - splash->setFillPattern(new SplashSolidColor(color)); - splash->setStrokePattern(new SplashSolidColor(color)); - //~ this should copy other state from t3GlyphStack->origSplash? - state->setCTM(ctm[0], ctm[1], ctm[2], ctm[3], - -t3Font->glyphX, -t3Font->glyphY); - updateCTM(state, 0, 0, 0, 0, 0, 0); - ++nestCount; -} - -void SplashOutputDev::drawType3Glyph(GfxState *state, T3FontCache *t3Font, - T3FontCacheTag * /*tag*/, Guchar *data) { - SplashGlyphBitmap glyph; - - setOverprintMask(state->getFillColorSpace(), state->getFillOverprint(), - state->getOverprintMode(), state->getFillColor()); - glyph.x = -t3Font->glyphX; - glyph.y = -t3Font->glyphY; - glyph.w = t3Font->glyphW; - glyph.h = t3Font->glyphH; - glyph.aa = colorMode != splashModeMono1; - glyph.data = data; - glyph.freeData = gFalse; - splash->fillGlyph(0, 0, &glyph); -} - -void SplashOutputDev::beginTextObject(GfxState *state) { -} - -void SplashOutputDev::endTextObject(GfxState *state) { - if (textClipPath) { - splash->clipToPath(textClipPath, gFalse); - delete textClipPath; - textClipPath = NULL; - } -} - -struct SplashOutImageMaskData { - ImageStream *imgStr; - GBool invert; - int width, height, y; -}; - -GBool SplashOutputDev::imageMaskSrc(void *data, SplashColorPtr line) { - SplashOutImageMaskData *imgMaskData = (SplashOutImageMaskData *)data; - Guchar *p; - SplashColorPtr q; - int x; - - if (imgMaskData->y == imgMaskData->height) { - return gFalse; - } - if (!(p = imgMaskData->imgStr->getLine())) { - return gFalse; - } - for (x = 0, q = line; x < imgMaskData->width; ++x) { - *q++ = *p++ ^ imgMaskData->invert; - } - ++imgMaskData->y; - return gTrue; -} - -void SplashOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, - int width, int height, GBool invert, - GBool interpolate, GBool inlineImg) { - double *ctm; - SplashCoord mat[6]; - SplashOutImageMaskData imgMaskData; - - if (state->getFillColorSpace()->isNonMarking()) { - return; - } - setOverprintMask(state->getFillColorSpace(), state->getFillOverprint(), - state->getOverprintMode(), state->getFillColor()); - - ctm = state->getCTM(); - for (int i = 0; i < 6; ++i) { - if (!isfinite(ctm[i])) return; - } - mat[0] = ctm[0]; - mat[1] = ctm[1]; - mat[2] = -ctm[2]; - mat[3] = -ctm[3]; - mat[4] = ctm[2] + ctm[4]; - mat[5] = ctm[3] + ctm[5]; - - imgMaskData.imgStr = new ImageStream(str, width, 1, 1); - imgMaskData.imgStr->reset(); - imgMaskData.invert = invert ? 0 : 1; - imgMaskData.width = width; - imgMaskData.height = height; - imgMaskData.y = 0; - - splash->fillImageMask(&imageMaskSrc, &imgMaskData, width, height, mat, t3GlyphStack != NULL); - if (inlineImg) { - while (imgMaskData.y < height) { - imgMaskData.imgStr->getLine(); - ++imgMaskData.y; - } - } - - delete imgMaskData.imgStr; - str->close(); -} - -void SplashOutputDev::setSoftMaskFromImageMask(GfxState *state, - Object *ref, Stream *str, - int width, int height, - GBool invert, - GBool inlineImg, double *baseMatrix) { - double *ctm; - SplashCoord mat[6]; - SplashOutImageMaskData imgMaskData; - Splash *maskSplash; - SplashColor maskColor; - double bbox[4] = {0, 0, 1, 1}; // default; - - if (state->getFillColorSpace()->isNonMarking()) { - return; - } - - ctm = state->getCTM(); - for (int i = 0; i < 6; ++i) { - if (!isfinite(ctm[i])) return; - } - - beginTransparencyGroup(state, bbox, NULL, gFalse, gFalse, gFalse); - baseMatrix[4] -= transpGroupStack->tx; - baseMatrix[5] -= transpGroupStack->ty; - - ctm = state->getCTM(); - mat[0] = ctm[0]; - mat[1] = ctm[1]; - mat[2] = -ctm[2]; - mat[3] = -ctm[3]; - mat[4] = ctm[2] + ctm[4]; - mat[5] = ctm[3] + ctm[5]; - imgMaskData.imgStr = new ImageStream(str, width, 1, 1); - imgMaskData.imgStr->reset(); - imgMaskData.invert = invert ? 0 : 1; - imgMaskData.width = width; - imgMaskData.height = height; - imgMaskData.y = 0; - - maskBitmap = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(), 1, splashModeMono8, gFalse); - maskSplash = new Splash(maskBitmap, vectorAntialias); - maskColor[0] = 0; - maskSplash->clear(maskColor); - maskColor[0] = 0xff; - maskSplash->setFillPattern(new SplashSolidColor(maskColor)); - maskSplash->fillImageMask(&imageMaskSrc, &imgMaskData, width, height, mat, t3GlyphStack != NULL); - delete maskSplash; - delete imgMaskData.imgStr; - str->close(); -} - -void SplashOutputDev::unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) { - double bbox[4] = {0,0,1,1}; // dummy - - /* transfer mask to alpha channel! */ - // memcpy(maskBitmap->getAlphaPtr(), maskBitmap->getDataPtr(), bitmap->getRowSize() * bitmap->getHeight()); - // memset(maskBitmap->getDataPtr(), 0, bitmap->getRowSize() * bitmap->getHeight()); - Guchar *dest = bitmap->getAlphaPtr(); - Guchar *src = maskBitmap->getDataPtr(); - for (int c= 0; c < maskBitmap->getRowSize() * maskBitmap->getHeight(); c++) { - dest[c] = src[c]; - } - delete maskBitmap; - maskBitmap = NULL; - endTransparencyGroup(state); - baseMatrix[4] += transpGroupStack->tx; - baseMatrix[5] += transpGroupStack->ty; - paintTransparencyGroup(state, bbox); -} - -struct SplashOutImageData { - ImageStream *imgStr; - GfxImageColorMap *colorMap; - SplashColorPtr lookup; - int *maskColors; - SplashColorMode colorMode; - int width, height, y; -}; - -GBool SplashOutputDev::imageSrc(void *data, SplashColorPtr colorLine, - Guchar * /*alphaLine*/) { - SplashOutImageData *imgData = (SplashOutImageData *)data; - Guchar *p; - SplashColorPtr q, col; - GfxRGB rgb; - GfxGray gray; -#if SPLASH_CMYK - GfxCMYK cmyk; - GfxColor deviceN; -#endif - int nComps, x; - - if (imgData->y == imgData->height) { - return gFalse; - } - if (!(p = imgData->imgStr->getLine())) { - return gFalse; - } - - nComps = imgData->colorMap->getNumPixelComps(); - - if (imgData->lookup) { - switch (imgData->colorMode) { - case splashModeMono1: - case splashModeMono8: - for (x = 0, q = colorLine; x < imgData->width; ++x, ++p) { - *q++ = imgData->lookup[*p]; - } - break; - case splashModeRGB8: - case splashModeBGR8: - for (x = 0, q = colorLine; x < imgData->width; ++x, ++p) { - col = &imgData->lookup[3 * *p]; - *q++ = col[0]; - *q++ = col[1]; - *q++ = col[2]; - } - break; - case splashModeXBGR8: - for (x = 0, q = colorLine; x < imgData->width; ++x, ++p) { - col = &imgData->lookup[4 * *p]; - *q++ = col[0]; - *q++ = col[1]; - *q++ = col[2]; - *q++ = col[3]; - } - break; -#if SPLASH_CMYK - case splashModeCMYK8: - for (x = 0, q = colorLine; x < imgData->width; ++x, ++p) { - col = &imgData->lookup[4 * *p]; - *q++ = col[0]; - *q++ = col[1]; - *q++ = col[2]; - *q++ = col[3]; - } - break; - case splashModeDeviceN8: - for (x = 0, q = colorLine; x < imgData->width; ++x, ++p) { - col = &imgData->lookup[(SPOT_NCOMPS+4) * *p]; - for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) - *q++ = col[cp]; - } - break; -#endif - } - } else { - switch (imgData->colorMode) { - case splashModeMono1: - case splashModeMono8: - for (x = 0, q = colorLine; x < imgData->width; ++x, p += nComps) { - imgData->colorMap->getGray(p, &gray); - *q++ = colToByte(gray); - } - break; - case splashModeRGB8: - case splashModeBGR8: - if (imgData->colorMap->useRGBLine()) { - imgData->colorMap->getRGBLine(p, (Guchar *) colorLine, imgData->width); - } else { - for (x = 0, q = colorLine; x < imgData->width; ++x, p += nComps) { - imgData->colorMap->getRGB(p, &rgb); - *q++ = colToByte(rgb.r); - *q++ = colToByte(rgb.g); - *q++ = colToByte(rgb.b); - } - } - break; - case splashModeXBGR8: - if (imgData->colorMap->useRGBLine()) { - imgData->colorMap->getRGBXLine(p, (Guchar *) colorLine, imgData->width); - } else { - for (x = 0, q = colorLine; x < imgData->width; ++x, p += nComps) { - imgData->colorMap->getRGB(p, &rgb); - *q++ = colToByte(rgb.r); - *q++ = colToByte(rgb.g); - *q++ = colToByte(rgb.b); - *q++ = 255; - } - } - break; -#if SPLASH_CMYK - case splashModeCMYK8: - if (imgData->colorMap->useCMYKLine()) { - imgData->colorMap->getCMYKLine(p, (Guchar *) colorLine, imgData->width); - } else { - for (x = 0, q = colorLine; x < imgData->width; ++x, p += nComps) { - imgData->colorMap->getCMYK(p, &cmyk); - *q++ = colToByte(cmyk.c); - *q++ = colToByte(cmyk.m); - *q++ = colToByte(cmyk.y); - *q++ = colToByte(cmyk.k); - } - } - break; - case splashModeDeviceN8: - if (imgData->colorMap->useDeviceNLine()) { - imgData->colorMap->getDeviceNLine(p, (Guchar *) colorLine, imgData->width); - } else { - for (x = 0, q = colorLine; x < imgData->width; ++x, p += nComps) { - imgData->colorMap->getDeviceN(p, &deviceN); - for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) - *q++ = colToByte(deviceN.c[cp]); - } - } - break; -#endif - } - } - - ++imgData->y; - return gTrue; -} - -GBool SplashOutputDev::alphaImageSrc(void *data, SplashColorPtr colorLine, - Guchar *alphaLine) { - SplashOutImageData *imgData = (SplashOutImageData *)data; - Guchar *p, *aq; - SplashColorPtr q, col; - GfxRGB rgb; - GfxGray gray; -#if SPLASH_CMYK - GfxCMYK cmyk; - GfxColor deviceN; -#endif - Guchar alpha; - int nComps, x, i; - - if (imgData->y == imgData->height) { - return gFalse; - } - if (!(p = imgData->imgStr->getLine())) { - return gFalse; - } - - nComps = imgData->colorMap->getNumPixelComps(); - - for (x = 0, q = colorLine, aq = alphaLine; - x < imgData->width; - ++x, p += nComps) { - alpha = 0; - for (i = 0; i < nComps; ++i) { - if (p[i] < imgData->maskColors[2*i] || - p[i] > imgData->maskColors[2*i+1]) { - alpha = 0xff; - break; - } - } - if (imgData->lookup) { - switch (imgData->colorMode) { - case splashModeMono1: - case splashModeMono8: - *q++ = imgData->lookup[*p]; - break; - case splashModeRGB8: - case splashModeBGR8: - col = &imgData->lookup[3 * *p]; - *q++ = col[0]; - *q++ = col[1]; - *q++ = col[2]; - break; - case splashModeXBGR8: - col = &imgData->lookup[4 * *p]; - *q++ = col[0]; - *q++ = col[1]; - *q++ = col[2]; - *q++ = 255; - break; -#if SPLASH_CMYK - case splashModeCMYK8: - col = &imgData->lookup[4 * *p]; - *q++ = col[0]; - *q++ = col[1]; - *q++ = col[2]; - *q++ = col[3]; - break; - case splashModeDeviceN8: - col = &imgData->lookup[(SPOT_NCOMPS+4) * *p]; - for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) - *q++ = col[cp]; - break; -#endif - } - *aq++ = alpha; - } else { - switch (imgData->colorMode) { - case splashModeMono1: - case splashModeMono8: - imgData->colorMap->getGray(p, &gray); - *q++ = colToByte(gray); - break; - case splashModeXBGR8: - case splashModeRGB8: - case splashModeBGR8: - imgData->colorMap->getRGB(p, &rgb); - *q++ = colToByte(rgb.r); - *q++ = colToByte(rgb.g); - *q++ = colToByte(rgb.b); - if (imgData->colorMode == splashModeXBGR8) *q++ = 255; - break; -#if SPLASH_CMYK - case splashModeCMYK8: - imgData->colorMap->getCMYK(p, &cmyk); - *q++ = colToByte(cmyk.c); - *q++ = colToByte(cmyk.m); - *q++ = colToByte(cmyk.y); - *q++ = colToByte(cmyk.k); - break; - case splashModeDeviceN8: - imgData->colorMap->getDeviceN(p, &deviceN); - for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) - *q++ = colToByte(deviceN.c[cp]); - break; -#endif - } - *aq++ = alpha; - } - } - - ++imgData->y; - return gTrue; -} - -struct TilingSplashOutBitmap { - SplashBitmap *bitmap; - SplashPattern *pattern; - SplashColorMode colorMode; - int paintType; - int repeatX; - int repeatY; - int y; -}; - -GBool SplashOutputDev::tilingBitmapSrc(void *data, SplashColorPtr colorLine, - Guchar *alphaLine) { - TilingSplashOutBitmap *imgData = (TilingSplashOutBitmap *)data; - - if (imgData->y == imgData->bitmap->getHeight()) { - imgData->repeatY--; - if (imgData->repeatY == 0) - return gFalse; - imgData->y = 0; - } - - if (imgData->paintType == 1) { - const SplashColorMode cMode = imgData->bitmap->getMode(); - SplashColorPtr q = colorLine; - // For splashModeBGR8 and splashModeXBGR8 we need to use getPixel - // for the others we can use raw access - if (cMode == splashModeBGR8 || cMode == splashModeXBGR8) { - for (int m = 0; m < imgData->repeatX; m++) { - for (int x = 0; x < imgData->bitmap->getWidth(); x++) { - imgData->bitmap->getPixel(x, imgData->y, q); - q += splashColorModeNComps[cMode]; - } - } - } else { - const int n = imgData->bitmap->getRowSize(); - SplashColorPtr p; - for (int m = 0; m < imgData->repeatX; m++) { - p = imgData->bitmap->getDataPtr() + imgData->y * imgData->bitmap->getRowSize(); - for (int x = 0; x < n; ++x) { - *q++ = *p++; - } - } - } - if (alphaLine != NULL) { - SplashColorPtr aq = alphaLine; - SplashColorPtr p; - const int n = imgData->bitmap->getWidth() - 1; - for (int m = 0; m < imgData->repeatX; m++) { - p = imgData->bitmap->getAlphaPtr() + imgData->y * imgData->bitmap->getWidth(); - for (int x = 0; x < n; ++x) { - *aq++ = *p++; - } - // This is a hack, because of how Splash antialias works if we overwrite the - // last alpha pixel of the tile most/all of the files look much better - *aq++ = (n == 0) ? *p : *(p - 1); - } - } - } else { - SplashColor col, pat; - SplashColorPtr dest = colorLine; - for (int m = 0; m < imgData->repeatX; m++) { - for (int x = 0; x < imgData->bitmap->getWidth(); x++) { - imgData->bitmap->getPixel(x, imgData->y, col); - imgData->pattern->getColor(x, imgData->y, pat); - for (int i = 0; i < splashColorModeNComps[imgData->colorMode]; ++i) { -#if SPLASH_CMYK - if (imgData->colorMode == splashModeCMYK8 || imgData->colorMode == splashModeDeviceN8) - dest[i] = div255(pat[i] * (255 - col[0])); - else -#endif - dest[i] = 255 - div255((255 - pat[i]) * (255 - col[0])); - } - dest += splashColorModeNComps[imgData->colorMode]; - } - } - if (alphaLine != NULL) { - const int y = (imgData->y == imgData->bitmap->getHeight() - 1 && imgData->y > 50) ? imgData->y - 1 : imgData->y; - SplashColorPtr aq = alphaLine; - SplashColorPtr p; - const int n = imgData->bitmap->getWidth(); - for (int m = 0; m < imgData->repeatX; m++) { - p = imgData->bitmap->getAlphaPtr() + y * imgData->bitmap->getWidth(); - for (int x = 0; x < n; ++x) { - *aq++ = *p++; - } - } - } - } - ++imgData->y; - return gTrue; -} - -void SplashOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, - int width, int height, - GfxImageColorMap *colorMap, - GBool interpolate, - int *maskColors, GBool inlineImg) { - double *ctm; - SplashCoord mat[6]; - SplashOutImageData imgData; - SplashColorMode srcMode; - SplashImageSource src; - GfxGray gray; - GfxRGB rgb; -#if SPLASH_CMYK - GfxCMYK cmyk; - GBool grayIndexed = gFalse; - GfxColor deviceN; -#endif - Guchar pix; - int n, i; - - ctm = state->getCTM(); - for (i = 0; i < 6; ++i) { - if (!isfinite(ctm[i])) return; - } - mat[0] = ctm[0]; - mat[1] = ctm[1]; - mat[2] = -ctm[2]; - mat[3] = -ctm[3]; - mat[4] = ctm[2] + ctm[4]; - mat[5] = ctm[3] + ctm[5]; - - imgData.imgStr = new ImageStream(str, width, - colorMap->getNumPixelComps(), - colorMap->getBits()); - imgData.imgStr->reset(); - imgData.colorMap = colorMap; - imgData.maskColors = maskColors; - imgData.colorMode = colorMode; - imgData.width = width; - imgData.height = height; - imgData.y = 0; - - // special case for one-channel (monochrome/gray/separation) images: - // build a lookup table here - imgData.lookup = NULL; - if (colorMap->getNumPixelComps() == 1) { - n = 1 << colorMap->getBits(); - switch (colorMode) { - case splashModeMono1: - case splashModeMono8: - imgData.lookup = (SplashColorPtr)gmalloc(n); - for (i = 0; i < n; ++i) { - pix = (Guchar)i; - colorMap->getGray(&pix, &gray); - imgData.lookup[i] = colToByte(gray); - } - break; - case splashModeRGB8: - case splashModeBGR8: - imgData.lookup = (SplashColorPtr)gmallocn(n, 3); - for (i = 0; i < n; ++i) { - pix = (Guchar)i; - colorMap->getRGB(&pix, &rgb); - imgData.lookup[3*i] = colToByte(rgb.r); - imgData.lookup[3*i+1] = colToByte(rgb.g); - imgData.lookup[3*i+2] = colToByte(rgb.b); - } - break; - case splashModeXBGR8: - imgData.lookup = (SplashColorPtr)gmallocn(n, 4); - for (i = 0; i < n; ++i) { - pix = (Guchar)i; - colorMap->getRGB(&pix, &rgb); - imgData.lookup[4*i] = colToByte(rgb.r); - imgData.lookup[4*i+1] = colToByte(rgb.g); - imgData.lookup[4*i+2] = colToByte(rgb.b); - imgData.lookup[4*i+3] = 255; - } - break; -#if SPLASH_CMYK - case splashModeCMYK8: - grayIndexed = colorMap->getColorSpace()->getMode() != csDeviceGray; - imgData.lookup = (SplashColorPtr)gmallocn(n, 4); - for (i = 0; i < n; ++i) { - pix = (Guchar)i; - colorMap->getCMYK(&pix, &cmyk); - if (cmyk.c != 0 || cmyk.m != 0 || cmyk.y != 0) { - grayIndexed = gFalse; - } - imgData.lookup[4*i] = colToByte(cmyk.c); - imgData.lookup[4*i+1] = colToByte(cmyk.m); - imgData.lookup[4*i+2] = colToByte(cmyk.y); - imgData.lookup[4*i+3] = colToByte(cmyk.k); - } - break; - case splashModeDeviceN8: - colorMap->getColorSpace()->createMapping(bitmap->getSeparationList(), SPOT_NCOMPS); - grayIndexed = colorMap->getColorSpace()->getMode() != csDeviceGray; - imgData.lookup = (SplashColorPtr)gmallocn(n, SPOT_NCOMPS+4); - for (i = 0; i < n; ++i) { - pix = (Guchar)i; - colorMap->getCMYK(&pix, &cmyk); - if (cmyk.c != 0 || cmyk.m != 0 || cmyk.y != 0) { - grayIndexed = gFalse; - } - colorMap->getDeviceN(&pix, &deviceN); - for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) - imgData.lookup[(SPOT_NCOMPS+4)*i +cp] = colToByte(deviceN.c[cp]); - } - break; -#endif - } - } - -#if SPLASH_CMYK - setOverprintMask(colorMap->getColorSpace(), state->getFillOverprint(), - state->getOverprintMode(), NULL, grayIndexed); -#else - setOverprintMask(colorMap->getColorSpace(), state->getFillOverprint(), - state->getOverprintMode(), NULL); -#endif - - if (colorMode == splashModeMono1) { - srcMode = splashModeMono8; - } else { - srcMode = colorMode; - } - src = maskColors ? &alphaImageSrc : &imageSrc; - splash->drawImage(src, &imgData, srcMode, maskColors ? gTrue : gFalse, - width, height, mat, interpolate); - if (inlineImg) { - while (imgData.y < height) { - imgData.imgStr->getLine(); - ++imgData.y; - } - } - - gfree(imgData.lookup); - delete imgData.imgStr; - str->close(); -} - -struct SplashOutMaskedImageData { - ImageStream *imgStr; - GfxImageColorMap *colorMap; - SplashBitmap *mask; - SplashColorPtr lookup; - SplashColorMode colorMode; - int width, height, y; -}; - -GBool SplashOutputDev::maskedImageSrc(void *data, SplashColorPtr colorLine, - Guchar *alphaLine) { - SplashOutMaskedImageData *imgData = (SplashOutMaskedImageData *)data; - Guchar *p, *aq; - SplashColorPtr q, col; - GfxRGB rgb; - GfxGray gray; -#if SPLASH_CMYK - GfxCMYK cmyk; - GfxColor deviceN; -#endif - Guchar alpha; - Guchar *maskPtr; - int maskBit; - int nComps, x; - - if (imgData->y == imgData->height) { - return gFalse; - } - if (!(p = imgData->imgStr->getLine())) { - return gFalse; - } - - nComps = imgData->colorMap->getNumPixelComps(); - - maskPtr = imgData->mask->getDataPtr() + - imgData->y * imgData->mask->getRowSize(); - maskBit = 0x80; - for (x = 0, q = colorLine, aq = alphaLine; - x < imgData->width; - ++x, p += nComps) { - alpha = (*maskPtr & maskBit) ? 0xff : 0x00; - if (!(maskBit >>= 1)) { - ++maskPtr; - maskBit = 0x80; - } - if (imgData->lookup) { - switch (imgData->colorMode) { - case splashModeMono1: - case splashModeMono8: - *q++ = imgData->lookup[*p]; - break; - case splashModeRGB8: - case splashModeBGR8: - col = &imgData->lookup[3 * *p]; - *q++ = col[0]; - *q++ = col[1]; - *q++ = col[2]; - break; - case splashModeXBGR8: - col = &imgData->lookup[4 * *p]; - *q++ = col[0]; - *q++ = col[1]; - *q++ = col[2]; - *q++ = 255; - break; -#if SPLASH_CMYK - case splashModeCMYK8: - col = &imgData->lookup[4 * *p]; - *q++ = col[0]; - *q++ = col[1]; - *q++ = col[2]; - *q++ = col[3]; - break; - case splashModeDeviceN8: - col = &imgData->lookup[(SPOT_NCOMPS+4) * *p]; - for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) - *q++ = col[cp]; - break; -#endif - } - *aq++ = alpha; - } else { - switch (imgData->colorMode) { - case splashModeMono1: - case splashModeMono8: - imgData->colorMap->getGray(p, &gray); - *q++ = colToByte(gray); - break; - case splashModeXBGR8: - case splashModeRGB8: - case splashModeBGR8: - imgData->colorMap->getRGB(p, &rgb); - *q++ = colToByte(rgb.r); - *q++ = colToByte(rgb.g); - *q++ = colToByte(rgb.b); - if (imgData->colorMode == splashModeXBGR8) *q++ = 255; - break; -#if SPLASH_CMYK - case splashModeCMYK8: - imgData->colorMap->getCMYK(p, &cmyk); - *q++ = colToByte(cmyk.c); - *q++ = colToByte(cmyk.m); - *q++ = colToByte(cmyk.y); - *q++ = colToByte(cmyk.k); - break; - case splashModeDeviceN8: - imgData->colorMap->getDeviceN(p, &deviceN); - for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) - *q++ = colToByte(deviceN.c[cp]); - break; -#endif - } - *aq++ = alpha; - } - } - - ++imgData->y; - return gTrue; -} - -void SplashOutputDev::drawMaskedImage(GfxState *state, Object *ref, - Stream *str, int width, int height, - GfxImageColorMap *colorMap, - GBool interpolate, - Stream *maskStr, int maskWidth, - int maskHeight, GBool maskInvert, - GBool maskInterpolate) { - GfxImageColorMap *maskColorMap; - Object maskDecode, decodeLow, decodeHigh; - double *ctm; - SplashCoord mat[6]; - SplashOutMaskedImageData imgData; - SplashOutImageMaskData imgMaskData; - SplashColorMode srcMode; - SplashBitmap *maskBitmap; - Splash *maskSplash; - SplashColor maskColor; - GfxGray gray; - GfxRGB rgb; -#if SPLASH_CMYK - GfxCMYK cmyk; - GfxColor deviceN; -#endif - Guchar pix; - int n, i; - -#if SPLASH_CMYK - colorMap->getColorSpace()->createMapping(bitmap->getSeparationList(), SPOT_NCOMPS); -#endif - setOverprintMask(colorMap->getColorSpace(), state->getFillOverprint(), - state->getOverprintMode(), NULL); - - // If the mask is higher resolution than the image, use - // drawSoftMaskedImage() instead. - if (maskWidth > width || maskHeight > height) { - decodeLow.initInt(maskInvert ? 0 : 1); - decodeHigh.initInt(maskInvert ? 1 : 0); - maskDecode.initArray((xref) ? xref : doc->getXRef()); - maskDecode.arrayAdd(&decodeLow); - maskDecode.arrayAdd(&decodeHigh); - maskColorMap = new GfxImageColorMap(1, &maskDecode, - new GfxDeviceGrayColorSpace()); - maskDecode.free(); - drawSoftMaskedImage(state, ref, str, width, height, colorMap, interpolate, - maskStr, maskWidth, maskHeight, maskColorMap, maskInterpolate); - delete maskColorMap; - - } else { - //----- scale the mask image to the same size as the source image - - mat[0] = (SplashCoord)width; - mat[1] = 0; - mat[2] = 0; - mat[3] = (SplashCoord)height; - mat[4] = 0; - mat[5] = 0; - imgMaskData.imgStr = new ImageStream(maskStr, maskWidth, 1, 1); - imgMaskData.imgStr->reset(); - imgMaskData.invert = maskInvert ? 0 : 1; - imgMaskData.width = maskWidth; - imgMaskData.height = maskHeight; - imgMaskData.y = 0; - maskBitmap = new SplashBitmap(width, height, 1, splashModeMono1, gFalse); - maskSplash = new Splash(maskBitmap, gFalse); - maskColor[0] = 0; - maskSplash->clear(maskColor); - maskColor[0] = 0xff; - maskSplash->setFillPattern(new SplashSolidColor(maskColor)); - maskSplash->fillImageMask(&imageMaskSrc, &imgMaskData, - maskWidth, maskHeight, mat, gFalse); - delete imgMaskData.imgStr; - maskStr->close(); - delete maskSplash; - - //----- draw the source image - - ctm = state->getCTM(); - for (i = 0; i < 6; ++i) { - if (!isfinite(ctm[i])) { - delete maskBitmap; - return; - } - } - mat[0] = ctm[0]; - mat[1] = ctm[1]; - mat[2] = -ctm[2]; - mat[3] = -ctm[3]; - mat[4] = ctm[2] + ctm[4]; - mat[5] = ctm[3] + ctm[5]; - - imgData.imgStr = new ImageStream(str, width, - colorMap->getNumPixelComps(), - colorMap->getBits()); - imgData.imgStr->reset(); - imgData.colorMap = colorMap; - imgData.mask = maskBitmap; - imgData.colorMode = colorMode; - imgData.width = width; - imgData.height = height; - imgData.y = 0; - - // special case for one-channel (monochrome/gray/separation) images: - // build a lookup table here - imgData.lookup = NULL; - if (colorMap->getNumPixelComps() == 1) { - n = 1 << colorMap->getBits(); - switch (colorMode) { - case splashModeMono1: - case splashModeMono8: - imgData.lookup = (SplashColorPtr)gmalloc(n); - for (i = 0; i < n; ++i) { - pix = (Guchar)i; - colorMap->getGray(&pix, &gray); - imgData.lookup[i] = colToByte(gray); - } - break; - case splashModeRGB8: - case splashModeBGR8: - imgData.lookup = (SplashColorPtr)gmallocn(n, 3); - for (i = 0; i < n; ++i) { - pix = (Guchar)i; - colorMap->getRGB(&pix, &rgb); - imgData.lookup[3*i] = colToByte(rgb.r); - imgData.lookup[3*i+1] = colToByte(rgb.g); - imgData.lookup[3*i+2] = colToByte(rgb.b); - } - break; - case splashModeXBGR8: - imgData.lookup = (SplashColorPtr)gmallocn(n, 4); - for (i = 0; i < n; ++i) { - pix = (Guchar)i; - colorMap->getRGB(&pix, &rgb); - imgData.lookup[4*i] = colToByte(rgb.r); - imgData.lookup[4*i+1] = colToByte(rgb.g); - imgData.lookup[4*i+2] = colToByte(rgb.b); - imgData.lookup[4*i+3] = 255; - } - break; -#if SPLASH_CMYK - case splashModeCMYK8: - imgData.lookup = (SplashColorPtr)gmallocn(n, 4); - for (i = 0; i < n; ++i) { - pix = (Guchar)i; - colorMap->getCMYK(&pix, &cmyk); - imgData.lookup[4*i] = colToByte(cmyk.c); - imgData.lookup[4*i+1] = colToByte(cmyk.m); - imgData.lookup[4*i+2] = colToByte(cmyk.y); - imgData.lookup[4*i+3] = colToByte(cmyk.k); - } - break; - case splashModeDeviceN8: - imgData.lookup = (SplashColorPtr)gmallocn(n, SPOT_NCOMPS+4); - for (i = 0; i < n; ++i) { - pix = (Guchar)i; - colorMap->getDeviceN(&pix, &deviceN); - for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) - imgData.lookup[(SPOT_NCOMPS+4)*i + cp] = colToByte(deviceN.c[cp]); - } - break; -#endif - } - } - - if (colorMode == splashModeMono1) { - srcMode = splashModeMono8; - } else { - srcMode = colorMode; - } - splash->drawImage(&maskedImageSrc, &imgData, srcMode, gTrue, - width, height, mat, interpolate); - delete maskBitmap; - gfree(imgData.lookup); - delete imgData.imgStr; - str->close(); - } -} - -void SplashOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, - Stream *str, int width, int height, - GfxImageColorMap *colorMap, - GBool interpolate, - Stream *maskStr, - int maskWidth, int maskHeight, - GfxImageColorMap *maskColorMap, - GBool maskInterpolate) { - double *ctm; - SplashCoord mat[6]; - SplashOutImageData imgData; - SplashOutImageData imgMaskData; - SplashColorMode srcMode; - SplashBitmap *maskBitmap; - Splash *maskSplash; - SplashColor maskColor; - GfxGray gray; - GfxRGB rgb; -#if SPLASH_CMYK - GfxCMYK cmyk; - GfxColor deviceN; -#endif - Guchar pix; - int n, i; - -#if SPLASH_CMYK - colorMap->getColorSpace()->createMapping(bitmap->getSeparationList(), SPOT_NCOMPS); -#endif - setOverprintMask(colorMap->getColorSpace(), state->getFillOverprint(), - state->getOverprintMode(), NULL); - - ctm = state->getCTM(); - for (i = 0; i < 6; ++i) { - if (!isfinite(ctm[i])) return; - } - mat[0] = ctm[0]; - mat[1] = ctm[1]; - mat[2] = -ctm[2]; - mat[3] = -ctm[3]; - mat[4] = ctm[2] + ctm[4]; - mat[5] = ctm[3] + ctm[5]; - - //----- set up the soft mask - - imgMaskData.imgStr = new ImageStream(maskStr, maskWidth, - maskColorMap->getNumPixelComps(), - maskColorMap->getBits()); - imgMaskData.imgStr->reset(); - imgMaskData.colorMap = maskColorMap; - imgMaskData.maskColors = NULL; - imgMaskData.colorMode = splashModeMono8; - imgMaskData.width = maskWidth; - imgMaskData.height = maskHeight; - imgMaskData.y = 0; - n = 1 << maskColorMap->getBits(); - imgMaskData.lookup = (SplashColorPtr)gmalloc(n); - for (i = 0; i < n; ++i) { - pix = (Guchar)i; - maskColorMap->getGray(&pix, &gray); - imgMaskData.lookup[i] = colToByte(gray); - } - maskBitmap = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(), - 1, splashModeMono8, gFalse); - maskSplash = new Splash(maskBitmap, vectorAntialias); - maskColor[0] = 0; - maskSplash->clear(maskColor); - maskSplash->drawImage(&imageSrc, &imgMaskData, splashModeMono8, gFalse, - maskWidth, maskHeight, mat, maskInterpolate); - delete imgMaskData.imgStr; - maskStr->close(); - gfree(imgMaskData.lookup); - delete maskSplash; - splash->setSoftMask(maskBitmap); - - //----- draw the source image - - imgData.imgStr = new ImageStream(str, width, - colorMap->getNumPixelComps(), - colorMap->getBits()); - imgData.imgStr->reset(); - imgData.colorMap = colorMap; - imgData.maskColors = NULL; - imgData.colorMode = colorMode; - imgData.width = width; - imgData.height = height; - imgData.y = 0; - - // special case for one-channel (monochrome/gray/separation) images: - // build a lookup table here - imgData.lookup = NULL; - if (colorMap->getNumPixelComps() == 1) { - n = 1 << colorMap->getBits(); - switch (colorMode) { - case splashModeMono1: - case splashModeMono8: - imgData.lookup = (SplashColorPtr)gmalloc(n); - for (i = 0; i < n; ++i) { - pix = (Guchar)i; - colorMap->getGray(&pix, &gray); - imgData.lookup[i] = colToByte(gray); - } - break; - case splashModeRGB8: - case splashModeBGR8: - imgData.lookup = (SplashColorPtr)gmallocn(n, 3); - for (i = 0; i < n; ++i) { - pix = (Guchar)i; - colorMap->getRGB(&pix, &rgb); - imgData.lookup[3*i] = colToByte(rgb.r); - imgData.lookup[3*i+1] = colToByte(rgb.g); - imgData.lookup[3*i+2] = colToByte(rgb.b); - } - break; - case splashModeXBGR8: - imgData.lookup = (SplashColorPtr)gmallocn(n, 4); - for (i = 0; i < n; ++i) { - pix = (Guchar)i; - colorMap->getRGB(&pix, &rgb); - imgData.lookup[4*i] = colToByte(rgb.r); - imgData.lookup[4*i+1] = colToByte(rgb.g); - imgData.lookup[4*i+2] = colToByte(rgb.b); - imgData.lookup[4*i+3] = 255; - } - break; -#if SPLASH_CMYK - case splashModeCMYK8: - imgData.lookup = (SplashColorPtr)gmallocn(n, 4); - for (i = 0; i < n; ++i) { - pix = (Guchar)i; - colorMap->getCMYK(&pix, &cmyk); - imgData.lookup[4*i] = colToByte(cmyk.c); - imgData.lookup[4*i+1] = colToByte(cmyk.m); - imgData.lookup[4*i+2] = colToByte(cmyk.y); - imgData.lookup[4*i+3] = colToByte(cmyk.k); - } - break; - case splashModeDeviceN8: - imgData.lookup = (SplashColorPtr)gmallocn(n, SPOT_NCOMPS+4); - for (i = 0; i < n; ++i) { - pix = (Guchar)i; - colorMap->getDeviceN(&pix, &deviceN); - for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) - imgData.lookup[(SPOT_NCOMPS+4)*i + cp] = colToByte(deviceN.c[cp]); - } - break; -#endif - } - } - - if (colorMode == splashModeMono1) { - srcMode = splashModeMono8; - } else { - srcMode = colorMode; - } - splash->drawImage(&imageSrc, &imgData, srcMode, gFalse, width, height, mat, interpolate); - splash->setSoftMask(NULL); - gfree(imgData.lookup); - delete imgData.imgStr; - str->close(); -} - -GBool SplashOutputDev::checkTransparencyGroup(GfxState *state, GBool knockout) { - if (state->getFillOpacity() != 1 || - state->getStrokeOpacity() != 1 || - state->getAlphaIsShape() || - state->getBlendMode() != gfxBlendNormal || - splash->getSoftMask() != NULL || - knockout) - return gTrue; - return transpGroupStack != NULL && transpGroupStack->shape != NULL; -} - -void SplashOutputDev::beginTransparencyGroup(GfxState *state, double *bbox, - GfxColorSpace *blendingColorSpace, - GBool isolated, GBool knockout, - GBool forSoftMask) { - SplashTransparencyGroup *transpGroup; - SplashColor color; - double xMin, yMin, xMax, yMax, x, y; - int tx, ty, w, h, i; - - // transform the bbox - state->transform(bbox[0], bbox[1], &x, &y); - xMin = xMax = x; - yMin = yMax = y; - state->transform(bbox[0], bbox[3], &x, &y); - if (x < xMin) { - xMin = x; - } else if (x > xMax) { - xMax = x; - } - if (y < yMin) { - yMin = y; - } else if (y > yMax) { - yMax = y; - } - state->transform(bbox[2], bbox[1], &x, &y); - if (x < xMin) { - xMin = x; - } else if (x > xMax) { - xMax = x; - } - if (y < yMin) { - yMin = y; - } else if (y > yMax) { - yMax = y; - } - state->transform(bbox[2], bbox[3], &x, &y); - if (x < xMin) { - xMin = x; - } else if (x > xMax) { - xMax = x; - } - if (y < yMin) { - yMin = y; - } else if (y > yMax) { - yMax = y; - } - tx = (int)floor(xMin); - if (tx < 0) { - tx = 0; - } else if (tx >= bitmap->getWidth()) { - tx = bitmap->getWidth() - 1; - } - ty = (int)floor(yMin); - if (ty < 0) { - ty = 0; - } else if (ty >= bitmap->getHeight()) { - ty = bitmap->getHeight() - 1; - } - w = (int)ceil(xMax) - tx + 1; - if (tx + w > bitmap->getWidth()) { - w = bitmap->getWidth() - tx; - } - if (w < 1) { - w = 1; - } - h = (int)ceil(yMax) - ty + 1; - if (ty + h > bitmap->getHeight()) { - h = bitmap->getHeight() - ty; - } - if (h < 1) { - h = 1; - } - - // push a new stack entry - transpGroup = new SplashTransparencyGroup(); - transpGroup->tx = tx; - transpGroup->ty = ty; - transpGroup->blendingColorSpace = blendingColorSpace; - transpGroup->isolated = isolated; - transpGroup->shape = (knockout && !isolated) ? SplashBitmap::copy(bitmap) : NULL; - transpGroup->knockout = (knockout && isolated); - transpGroup->knockoutOpacity = 1.0; - transpGroup->next = transpGroupStack; - transpGroupStack = transpGroup; - - // save state - transpGroup->origBitmap = bitmap; - transpGroup->origSplash = splash; - transpGroup->fontAA = fontEngine->getAA(); - - //~ this handles the blendingColorSpace arg for soft masks, but - //~ not yet for transparency groups - - // switch to the blending color space - if (forSoftMask && isolated && blendingColorSpace) { - if (blendingColorSpace->getMode() == csDeviceGray || - blendingColorSpace->getMode() == csCalGray || - (blendingColorSpace->getMode() == csICCBased && - blendingColorSpace->getNComps() == 1)) { - colorMode = splashModeMono8; - } else if (blendingColorSpace->getMode() == csDeviceRGB || - blendingColorSpace->getMode() == csCalRGB || - (blendingColorSpace->getMode() == csICCBased && - blendingColorSpace->getNComps() == 3)) { - //~ does this need to use BGR8? - colorMode = splashModeRGB8; -#if SPLASH_CMYK - } else if (blendingColorSpace->getMode() == csDeviceCMYK || - (blendingColorSpace->getMode() == csICCBased && - blendingColorSpace->getNComps() == 4)) { - colorMode = splashModeCMYK8; -#endif - } - } - - // create the temporary bitmap - bitmap = new SplashBitmap(w, h, bitmapRowPad, colorMode, gTrue, - bitmapTopDown, bitmap->getSeparationList()); - splash = new Splash(bitmap, vectorAntialias, - transpGroup->origSplash->getScreen()); - if (transpGroup->next != NULL && transpGroup->next->knockout) { - fontEngine->setAA(gFalse); - } - splash->setThinLineMode(transpGroup->origSplash->getThinLineMode()); - splash->setMinLineWidth(globalParams->getMinLineWidth()); - //~ Acrobat apparently copies at least the fill and stroke colors, and - //~ maybe other state(?) -- but not the clipping path (and not sure - //~ what else) - //~ [this is likely the same situation as in type3D1()] - splash->setFillPattern(transpGroup->origSplash->getFillPattern()->copy()); - splash->setStrokePattern( - transpGroup->origSplash->getStrokePattern()->copy()); - if (isolated) { - for (i = 0; i < splashMaxColorComps; ++i) { - color[i] = 0; - } - if (colorMode == splashModeXBGR8) color[3] = 255; - splash->clear(color, 0); - } else { - SplashBitmap *shape = (knockout) ? transpGroup->shape : - (transpGroup->next != NULL && transpGroup->next->shape != NULL) ? transpGroup->next->shape : transpGroup->origBitmap; - int shapeTx = (knockout) ? tx : - (transpGroup->next != NULL && transpGroup->next->shape != NULL) ? transpGroup->next->tx + tx : tx; - int shapeTy = (knockout) ? ty : - (transpGroup->next != NULL && transpGroup->next->shape != NULL) ? transpGroup->next->ty + ty : ty; - splash->blitTransparent(transpGroup->origBitmap, tx, ty, 0, 0, w, h); - splash->setInNonIsolatedGroup(shape, shapeTx, shapeTy); - } - transpGroup->tBitmap = bitmap; - state->shiftCTMAndClip(-tx, -ty); - updateCTM(state, 0, 0, 0, 0, 0, 0); - ++nestCount; -} - -void SplashOutputDev::endTransparencyGroup(GfxState *state) { - // restore state - --nestCount; - delete splash; - bitmap = transpGroupStack->origBitmap; - colorMode = bitmap->getMode(); - splash = transpGroupStack->origSplash; - state->shiftCTMAndClip(transpGroupStack->tx, transpGroupStack->ty); - updateCTM(state, 0, 0, 0, 0, 0, 0); -} - -void SplashOutputDev::paintTransparencyGroup(GfxState *state, double *bbox) { - SplashBitmap *tBitmap; - SplashTransparencyGroup *transpGroup; - GBool isolated; - int tx, ty; - - tx = transpGroupStack->tx; - ty = transpGroupStack->ty; - tBitmap = transpGroupStack->tBitmap; - isolated = transpGroupStack->isolated; - - // paint the transparency group onto the parent bitmap - // - the clip path was set in the parent's state) - if (tx < bitmap->getWidth() && ty < bitmap->getHeight()) { - SplashCoord knockoutOpacity = (transpGroupStack->next != NULL) ? transpGroupStack->next->knockoutOpacity - : transpGroupStack->knockoutOpacity; - splash->setOverprintMask(0xffffffff, gFalse); - splash->composite(tBitmap, 0, 0, tx, ty, - tBitmap->getWidth(), tBitmap->getHeight(), - gFalse, !isolated, transpGroupStack->next != NULL && transpGroupStack->next->knockout, knockoutOpacity); - fontEngine->setAA(transpGroupStack->fontAA); - if (transpGroupStack->next != NULL && transpGroupStack->next->shape != NULL) { - transpGroupStack->next->knockout = gTrue; - } - } - - // pop the stack - transpGroup = transpGroupStack; - transpGroupStack = transpGroup->next; - if (transpGroupStack != NULL && transpGroup->knockoutOpacity < transpGroupStack->knockoutOpacity) { - transpGroupStack->knockoutOpacity = transpGroup->knockoutOpacity; - } - delete transpGroup->shape; - delete transpGroup; - - delete tBitmap; -} - -void SplashOutputDev::setSoftMask(GfxState *state, double *bbox, - GBool alpha, Function *transferFunc, - GfxColor *backdropColor) { - SplashBitmap *softMask, *tBitmap; - Splash *tSplash; - SplashTransparencyGroup *transpGroup; - SplashColor color; - SplashColorPtr p; - GfxGray gray; - GfxRGB rgb; -#if SPLASH_CMYK - GfxCMYK cmyk; - GfxColor deviceN; -#endif - double lum, lum2; - int tx, ty, x, y; - - tx = transpGroupStack->tx; - ty = transpGroupStack->ty; - tBitmap = transpGroupStack->tBitmap; - - // composite with backdrop color - if (!alpha && tBitmap->getMode() != splashModeMono1) { - //~ need to correctly handle the case where no blending color - //~ space is given - if (transpGroupStack->blendingColorSpace) { - tSplash = new Splash(tBitmap, vectorAntialias, - transpGroupStack->origSplash->getScreen()); - switch (tBitmap->getMode()) { - case splashModeMono1: - // transparency is not supported in mono1 mode - break; - case splashModeMono8: - transpGroupStack->blendingColorSpace->getGray(backdropColor, &gray); - color[0] = colToByte(gray); - tSplash->compositeBackground(color); - break; - case splashModeXBGR8: - color[3] = 255; - case splashModeRGB8: - case splashModeBGR8: - transpGroupStack->blendingColorSpace->getRGB(backdropColor, &rgb); - color[0] = colToByte(rgb.r); - color[1] = colToByte(rgb.g); - color[2] = colToByte(rgb.b); - tSplash->compositeBackground(color); - break; -#if SPLASH_CMYK - case splashModeCMYK8: - transpGroupStack->blendingColorSpace->getCMYK(backdropColor, &cmyk); - color[0] = colToByte(cmyk.c); - color[1] = colToByte(cmyk.m); - color[2] = colToByte(cmyk.y); - color[3] = colToByte(cmyk.k); - tSplash->compositeBackground(color); - break; - case splashModeDeviceN8: - transpGroupStack->blendingColorSpace->getDeviceN(backdropColor, &deviceN); - for (int cp=0; cp < SPOT_NCOMPS+4; cp++) - color[cp] = colToByte(deviceN.c[cp]); - tSplash->compositeBackground(color); - break; -#endif - } - delete tSplash; - } - } - - softMask = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(), - 1, splashModeMono8, gFalse); - unsigned char fill = 0; - if (transpGroupStack->blendingColorSpace) { - transpGroupStack->blendingColorSpace->getGray(backdropColor, &gray); - fill = colToByte(gray); - } - memset(softMask->getDataPtr(), fill, - softMask->getRowSize() * softMask->getHeight()); - p = softMask->getDataPtr() + ty * softMask->getRowSize() + tx; - int xMax = tBitmap->getWidth(); - int yMax = tBitmap->getHeight(); - if (xMax > bitmap->getWidth() - tx) xMax = bitmap->getWidth() - tx; - if (yMax > bitmap->getHeight() - ty) yMax = bitmap->getHeight() - ty; - for (y = 0; y < yMax; ++y) { - for (x = 0; x < xMax; ++x) { - if (alpha) { - if (transferFunc) { - lum = tBitmap->getAlpha(x, y) / 255.0; - transferFunc->transform(&lum, &lum2); - p[x] = (int)(lum2 * 255.0 + 0.5); - } else - p[x] = tBitmap->getAlpha(x, y); - } else { - tBitmap->getPixel(x, y, color); - // convert to luminosity - switch (tBitmap->getMode()) { - case splashModeMono1: - case splashModeMono8: - lum = color[0] / 255.0; - break; - case splashModeXBGR8: - case splashModeRGB8: - case splashModeBGR8: - lum = (0.3 / 255.0) * color[0] + - (0.59 / 255.0) * color[1] + - (0.11 / 255.0) * color[2]; - break; -#if SPLASH_CMYK - case splashModeCMYK8: - case splashModeDeviceN8: - lum = (1 - color[3] / 255.0) - - (0.3 / 255.0) * color[0] - - (0.59 / 255.0) * color[1] - - (0.11 / 255.0) * color[2]; - if (lum < 0) { - lum = 0; - } - break; -#endif - } - if (transferFunc) { - transferFunc->transform(&lum, &lum2); - } else { - lum2 = lum; - } - p[x] = (int)(lum2 * 255.0 + 0.5); - } - } - p += softMask->getRowSize(); - } - splash->setSoftMask(softMask); - - // pop the stack - transpGroup = transpGroupStack; - transpGroupStack = transpGroup->next; - delete transpGroup; - - delete tBitmap; -} - -void SplashOutputDev::clearSoftMask(GfxState *state) { - splash->setSoftMask(NULL); -} - -void SplashOutputDev::setPaperColor(SplashColorPtr paperColorA) { - splashColorCopy(paperColor, paperColorA); -} - -int SplashOutputDev::getBitmapWidth() { - return bitmap->getWidth(); -} - -int SplashOutputDev::getBitmapHeight() { - return bitmap->getHeight(); -} - -SplashBitmap *SplashOutputDev::takeBitmap() { - SplashBitmap *ret; - - ret = bitmap; - bitmap = new SplashBitmap(1, 1, bitmapRowPad, colorMode, - colorMode != splashModeMono1, bitmapTopDown); - return ret; -} - -void SplashOutputDev::getModRegion(int *xMin, int *yMin, - int *xMax, int *yMax) { - splash->getModRegion(xMin, yMin, xMax, yMax); -} - -void SplashOutputDev::clearModRegion() { - splash->clearModRegion(); -} - -#if 1 //~tmp: turn off anti-aliasing temporarily -GBool SplashOutputDev::getVectorAntialias() { - return splash->getVectorAntialias(); -} - -void SplashOutputDev::setVectorAntialias(GBool vaa) { - vaa = vaa && colorMode != splashModeMono1; - vectorAntialias = vaa; - splash->setVectorAntialias(vaa); -} -#endif - -void SplashOutputDev::setFreeTypeHinting(GBool enable, GBool enableSlightHintingA) -{ - enableFreeTypeHinting = enable; - enableSlightHinting = enableSlightHintingA; -} - -GBool SplashOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *catalog, Object *str, - double *ptm, int paintType, int /*tilingType*/, Dict *resDict, - double *mat, double *bbox, - int x0, int y0, int x1, int y1, - double xStep, double yStep) -{ - PDFRectangle box; - Gfx *gfx; - Splash *formerSplash = splash; - SplashBitmap *formerBitmap = bitmap; - double width, height; - int surface_width, surface_height, result_width, result_height, i; - int repeatX, repeatY; - SplashCoord matc[6]; - Matrix m1; - double *ctm, savedCTM[6]; - double kx, ky, sx, sy; - GBool retValue = gFalse; - - width = bbox[2] - bbox[0]; - height = bbox[3] - bbox[1]; - - if (xStep != width || yStep != height) - return gFalse; - - // calculate offsets - ctm = state->getCTM(); - for (i = 0; i < 6; ++i) { - savedCTM[i] = ctm[i]; - } - state->concatCTM(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]); - state->concatCTM(1, 0, 0, 1, bbox[0], bbox[1]); - ctm = state->getCTM(); - for (i = 0; i < 6; ++i) { - if (!isfinite(ctm[i])) { - state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]); - return gFalse; - } - } - matc[4] = x0 * xStep * ctm[0] + y0 * yStep * ctm[2] + ctm[4]; - matc[5] = x0 * xStep * ctm[1] + y0 * yStep * ctm[3] + ctm[5]; - if (splashAbs(ctm[1]) > splashAbs(ctm[0])) { - kx = -ctm[1]; - ky = ctm[2] - (ctm[0] * ctm[3]) / ctm[1]; - } else { - kx = ctm[0]; - ky = ctm[3] - (ctm[1] * ctm[2]) / ctm[0]; - } - result_width = (int) ceil(fabs(kx * width * (x1 - x0))); - result_height = (int) ceil(fabs(ky * height * (y1 - y0))); - kx = state->getHDPI() / 72.0; - ky = state->getVDPI() / 72.0; - m1.m[0] = (ptm[0] == 0) ? fabs(ptm[2]) * kx : fabs(ptm[0]) * kx; - m1.m[1] = 0; - m1.m[2] = 0; - m1.m[3] = (ptm[3] == 0) ? fabs(ptm[1]) * ky : fabs(ptm[3]) * ky; - m1.m[4] = 0; - m1.m[5] = 0; - m1.transform(width, height, &kx, &ky); - surface_width = (int) ceil (fabs(kx)); - surface_height = (int) ceil (fabs(ky)); - - sx = (double) result_width / (surface_width * (x1 - x0)); - sy = (double) result_height / (surface_height * (y1 - y0)); - m1.m[0] *= sx; - m1.m[3] *= sy; - m1.transform(width, height, &kx, &ky); - - if(fabs(kx) < 1 && fabs(ky) < 1) { - kx = std::min<double>(kx, ky); - ky = 2 / kx; - m1.m[0] *= ky; - m1.m[3] *= ky; - m1.transform(width, height, &kx, &ky); - surface_width = (int) ceil (fabs(kx)); - surface_height = (int) ceil (fabs(ky)); - repeatX = x1 - x0; - repeatY = y1 - y0; - } else { - if ((unsigned long) result_width * result_height > 0x800000L) { - state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]); - return gFalse; - } - while(fabs(kx) > 16384 || fabs(ky) > 16384) { - // limit pattern bitmap size - m1.m[0] /= 2; - m1.m[3] /= 2; - m1.transform(width, height, &kx, &ky); - } - surface_width = (int) ceil (fabs(kx)); - surface_height = (int) ceil (fabs(ky)); - // adjust repeat values to completely fill region - repeatX = result_width / surface_width; - repeatY = result_height / surface_height; - if (surface_width * repeatX < result_width) - repeatX++; - if (surface_height * repeatY < result_height) - repeatY++; - if (x1 - x0 > repeatX) - repeatX = x1 - x0; - if (y1 - y0 > repeatY) - repeatY = y1 - y0; - } - // restore CTM and calculate rotate and scale with rounded matric - state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]); - state->concatCTM(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]); - state->concatCTM(width * repeatX, 0, 0, height * repeatY, bbox[0], bbox[1]); - ctm = state->getCTM(); - matc[0] = ctm[0]; - matc[1] = ctm[1]; - matc[2] = ctm[2]; - matc[3] = ctm[3]; - - if (surface_width == 0 || surface_height == 0) { - state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]); - return gFalse; - } - m1.transform(bbox[0], bbox[1], &kx, &ky); - m1.m[4] = -kx; - m1.m[5] = -ky; - - bitmap = new SplashBitmap(surface_width, surface_height, 1, - (paintType == 1) ? colorMode : splashModeMono8, gTrue); - splash = new Splash(bitmap, gTrue); - if (paintType == 2) { - SplashColor clearColor; -#if SPLASH_CMYK - clearColor[0] = (colorMode == splashModeCMYK8 || colorMode == splashModeDeviceN8) ? 0x00 : 0xFF; -#else - clearColor[0] = 0xFF; -#endif - splash->clear(clearColor, 0); - } else { - splash->clear(paperColor, 0); - } - splash->setThinLineMode(formerSplash->getThinLineMode()); - splash->setMinLineWidth(globalParams->getMinLineWidth()); - - box.x1 = bbox[0]; box.y1 = bbox[1]; - box.x2 = bbox[2]; box.y2 = bbox[3]; - gfx = new Gfx(doc, this, resDict, &box, NULL, NULL, NULL, gfxA->getXRef()); - // set pattern transformation matrix - gfx->getState()->setCTM(m1.m[0], m1.m[1], m1.m[2], m1.m[3], m1.m[4], m1.m[5]); - updateCTM(gfx->getState(), m1.m[0], m1.m[1], m1.m[2], m1.m[3], m1.m[4], m1.m[5]); - gfx->display(str); - delete splash; - splash = formerSplash; - TilingSplashOutBitmap imgData; - imgData.bitmap = bitmap; - imgData.paintType = paintType; - imgData.pattern = splash->getFillPattern(); - imgData.colorMode = colorMode; - imgData.y = 0; - imgData.repeatX = repeatX; - imgData.repeatY = repeatY; - SplashBitmap *tBitmap = bitmap; - bitmap = formerBitmap; - result_width = tBitmap->getWidth() * imgData.repeatX; - result_height = tBitmap->getHeight() * imgData.repeatY; - - if (splashAbs(matc[1]) > splashAbs(matc[0])) { - kx = -matc[1]; - ky = matc[2] - (matc[0] * matc[3]) / matc[1]; - } else { - kx = matc[0]; - ky = matc[3] - (matc[1] * matc[2]) / matc[0]; - } - kx = result_width / (fabs(kx) + 1); - ky = result_height / (fabs(ky) + 1); - state->concatCTM(kx, 0, 0, ky, 0, 0); - ctm = state->getCTM(); - matc[0] = ctm[0]; - matc[1] = ctm[1]; - matc[2] = ctm[2]; - matc[3] = ctm[3]; - GBool minorAxisZero = matc[1] == 0 && matc[2] == 0; - if (matc[0] > 0 && minorAxisZero && matc[3] > 0) { - // draw the tiles - for (int y = 0; y < imgData.repeatY; ++y) { - for (int x = 0; x < imgData.repeatX; ++x) { - x0 = splashFloor(matc[4]) + x * tBitmap->getWidth(); - y0 = splashFloor(matc[5]) + y * tBitmap->getHeight(); - splash->blitImage(tBitmap, gTrue, x0, y0); - } - } - retValue = gTrue; - } else { - retValue = splash->drawImage(&tilingBitmapSrc, &imgData, colorMode, gTrue, result_width, result_height, matc, gFalse, gTrue) == splashOk; - } - delete tBitmap; - delete gfx; - return retValue; -} - -GBool SplashOutputDev::gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading) -{ - GfxColorSpaceMode shadingMode = shading->getColorSpace()->getMode(); - GBool bDirectColorTranslation = gFalse; // triggers an optimization. - switch (colorMode) { - case splashModeRGB8: - bDirectColorTranslation = (shadingMode == csDeviceRGB); - break; -#if SPLASH_CMYK - case splashModeCMYK8: - case splashModeDeviceN8: - bDirectColorTranslation = (shadingMode == csDeviceCMYK); - break; -#endif - default: - break; - } - SplashGouraudColor *splashShading = new SplashGouraudPattern(bDirectColorTranslation, state, shading, colorMode); - // restore vector antialias because we support it here - if (shading->isParameterized()) { - GBool vaa = getVectorAntialias(); - GBool retVal = gFalse; - setVectorAntialias(gTrue); - retVal = splash->gouraudTriangleShadedFill(splashShading); - setVectorAntialias(vaa); - return retVal; - } - delete splashShading; - return gFalse; -} - -GBool SplashOutputDev::univariateShadedFill(GfxState *state, SplashUnivariatePattern *pattern, double tMin, double tMax) { - double xMin, yMin, xMax, yMax; - SplashPath *path; - GBool vaa = getVectorAntialias(); - // restore vector antialias because we support it here - setVectorAntialias(gTrue); - - GBool retVal = gFalse; - // get the clip region bbox - if (pattern->getShading()->getHasBBox()) { - pattern->getShading()->getBBox(&xMin, &yMin, &xMax, &yMax); - } else { - state->getClipBBox(&xMin, &yMin, &xMax, &yMax); - - xMin = floor (xMin); - yMin = floor (yMin); - xMax = ceil (xMax); - yMax = ceil (yMax); - - { - Matrix ctm, ictm; - double x[4], y[4]; - int i; - - state->getCTM(&ctm); - ctm.invertTo(&ictm); - - ictm.transform(xMin, yMin, &x[0], &y[0]); - ictm.transform(xMax, yMin, &x[1], &y[1]); - ictm.transform(xMin, yMax, &x[2], &y[2]); - ictm.transform(xMax, yMax, &x[3], &y[3]); - - xMin = xMax = x[0]; - yMin = yMax = y[0]; - for (i = 1; i < 4; i++) { - xMin = std::min<double>(xMin, x[i]); - yMin = std::min<double>(yMin, y[i]); - xMax = std::max<double>(xMax, x[i]); - yMax = std::max<double>(yMax, y[i]); - } - } - } - - // fill the region - state->moveTo(xMin, yMin); - state->lineTo(xMax, yMin); - state->lineTo(xMax, yMax); - state->lineTo(xMin, yMax); - state->closePath(); - path = convertPath(state, state->getPath(), gTrue); - -#if SPLASH_CMYK - pattern->getShading()->getColorSpace()->createMapping(bitmap->getSeparationList(), SPOT_NCOMPS); -#endif - setOverprintMask(pattern->getShading()->getColorSpace(), state->getFillOverprint(), - state->getOverprintMode(), NULL); - retVal = (splash->shadedFill(path, pattern->getShading()->getHasBBox(), pattern) == splashOk); - state->clearPath(); - setVectorAntialias(vaa); - delete path; - - return retVal; -} - -GBool SplashOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) { - SplashAxialPattern *pattern = new SplashAxialPattern(colorMode, state, shading); - GBool retVal = univariateShadedFill(state, pattern, tMin, tMax); - - delete pattern; - - return retVal; -} - -GBool SplashOutputDev::radialShadedFill(GfxState *state, GfxRadialShading *shading, double tMin, double tMax) { - SplashRadialPattern *pattern = new SplashRadialPattern(colorMode, state, shading); - GBool retVal = univariateShadedFill(state, pattern, tMin, tMax); - - delete pattern; - - return retVal; -} diff --git a/source/libs/poppler/poppler-0.32.0/poppler/TextOutputDev.cc b/source/libs/poppler/poppler-0.32.0/poppler/TextOutputDev.cc deleted file mode 100755 index 150d44496..000000000 --- a/source/libs/poppler/poppler-0.32.0/poppler/TextOutputDev.cc +++ /dev/null @@ -1,5625 +0,0 @@ -//======================================================================== -// -// TextOutputDev.cc -// -// Copyright 1997-2003 Glyph & Cog, LLC -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2005-2007 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru> -// Copyright (C) 2006-2008, 2011-2013 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright (C) 2006, 2007, 2013 Ed Catmur <ed@catmur.co.uk> -// Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net> -// Copyright (C) 2007, 2008, 2012 Adrian Johnson <ajohnson@redneon.com> -// Copyright (C) 2008 Koji Otani <sho@bbr.jp> -// Copyright (C) 2008, 2010-2012, 2014, 2015 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2008 Pino Toscano <pino@kde.org> -// Copyright (C) 2008, 2010 Hib Eris <hib@hiberis.nl> -// Copyright (C) 2009 Ross Moore <ross@maths.mq.edu.au> -// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net> -// Copyright (C) 2010 Brian Ewins <brian.ewins@gmail.com> -// Copyright (C) 2010 Marek Kasik <mkasik@redhat.com> -// Copyright (C) 2010 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> -// Copyright (C) 2011 Sam Liao <phyomh@gmail.com> -// Copyright (C) 2012 Horst Prote <prote@fmi.uni-stuttgart.de> -// Copyright (C) 2012, 2013, 2014 Jason Crain <jason@aquaticape.us> -// Copyright (C) 2012 Peter Breitenlohner <peb@mppmu.mpg.de> -// Copyright (C) 2013 José Aliste <jaliste@src.gnome.org> -// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> -// Copyright (C) 2013 Ed Catmur <ed@catmur.co.uk> -// -// To see a description of the changes please see the Changelog file that -// came with your tarball or type make ChangeLog if you are building from git -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <stddef.h> -#include <math.h> -#include <float.h> -#include <ctype.h> -#ifdef _WIN32 -#include <fcntl.h> // for O_BINARY -#include <io.h> // for setmode -#endif -#include "goo/gmem.h" -#include "goo/GooString.h" -#include "goo/GooList.h" -#include "poppler-config.h" -#include "Error.h" -#include "GlobalParams.h" -#include "UnicodeMap.h" -#include "UnicodeTypeTable.h" -#include "Link.h" -#include "TextOutputDev.h" -#include "Page.h" -#include "Annot.h" -#include "UTF.h" - -#ifdef MACOS -// needed for setting type/creator of MacOS files -#include "ICSupport.h" -#endif - -//------------------------------------------------------------------------ -// parameters -//------------------------------------------------------------------------ - -// Each bucket in a text pool includes baselines within a range of -// this many points. -#define textPoolStep 4 - -// Inter-character space width which will cause addChar to start a new -// word. -#define minWordBreakSpace 0.1 - -// Negative inter-character space width, i.e., overlap, which will -// cause addChar to start a new word. -#define minDupBreakOverlap 0.2 - -// Max distance between baselines of two lines within a block, as a -// fraction of the font size. -#define maxLineSpacingDelta 1.5 - -// Max difference in primary font sizes on two lines in the same -// block. Delta1 is used when examining new lines above and below the -// current block; delta2 is used when examining text that overlaps the -// current block; delta3 is used when examining text to the left and -// right of the current block. -#define maxBlockFontSizeDelta1 0.05 -#define maxBlockFontSizeDelta2 0.6 -#define maxBlockFontSizeDelta3 0.2 - -// Max difference in font sizes inside a word. -#define maxWordFontSizeDelta 0.05 - -// Maximum distance between baselines of two words on the same line, -// e.g., distance between subscript or superscript and the primary -// baseline, as a fraction of the font size. -#define maxIntraLineDelta 0.5 - -// Minimum inter-word spacing, as a fraction of the font size. (Only -// used for raw ordering.) -#define minWordSpacing 0.15 - -// Maximum inter-word spacing, as a fraction of the font size. -#define maxWordSpacing 1.5 - -// Maximum horizontal spacing which will allow a word to be pulled -// into a block. -#define minColSpacing1 0.3 - -// Minimum spacing between columns, as a fraction of the font size. -#define minColSpacing2 1.0 - -// Maximum vertical spacing between blocks within a flow, as a -// multiple of the font size. -#define maxBlockSpacing 2.5 - -// Minimum spacing between characters within a word, as a fraction of -// the font size. -#define minCharSpacing -0.5 - -// Maximum spacing between characters within a word, as a fraction of -// the font size, when there is no obvious extra-wide character -// spacing. -#define maxCharSpacing 0.03 - -// When extra-wide character spacing is detected, the inter-character -// space threshold is set to the minimum inter-character space -// multiplied by this constant. -#define maxWideCharSpacingMul 1.3 - -// Upper limit on spacing between characters in a word. -#define maxWideCharSpacing 0.4 - -// Max difference in primary,secondary coordinates (as a fraction of -// the font size) allowed for duplicated text (fake boldface, drop -// shadows) which is to be discarded. -#define dupMaxPriDelta 0.1 -#define dupMaxSecDelta 0.2 - -// Max width of underlines (in points). -#define maxUnderlineWidth 3 - -// Min distance between baseline and underline (in points). -//~ this should be font-size-dependent -#define minUnderlineGap -2 - -// Max distance between baseline and underline (in points). -//~ this should be font-size-dependent -#define maxUnderlineGap 4 - -// Max horizontal distance between edge of word and start of underline -// (in points). -//~ this should be font-size-dependent -#define underlineSlack 1 - -// Max distance between edge of text and edge of link border -#define hyperlinkSlack 2 - -//------------------------------------------------------------------------ -// TextUnderline -//------------------------------------------------------------------------ - -class TextUnderline { -public: - - TextUnderline(double x0A, double y0A, double x1A, double y1A) - { x0 = x0A; y0 = y0A; x1 = x1A; y1 = y1A; horiz = y0 == y1; } - ~TextUnderline() {} - - double x0, y0, x1, y1; - GBool horiz; -}; - -//------------------------------------------------------------------------ -// TextLink -//------------------------------------------------------------------------ - -class TextLink { -public: - - TextLink(int xMinA, int yMinA, int xMaxA, int yMaxA, AnnotLink *linkA) - { xMin = xMinA; yMin = yMinA; xMax = xMaxA; yMax = yMaxA; link = linkA; } - ~TextLink() {} - - int xMin, yMin, xMax, yMax; - AnnotLink *link; -}; - -//------------------------------------------------------------------------ -// TextFontInfo -//------------------------------------------------------------------------ - -TextFontInfo::TextFontInfo(GfxState *state) { - gfxFont = state->getFont(); - if (gfxFont) - gfxFont->incRefCnt(); -#if TEXTOUT_WORD_LIST - fontName = (gfxFont && gfxFont->getName()) ? gfxFont->getName()->copy() - : (GooString *)NULL; - flags = gfxFont ? gfxFont->getFlags() : 0; -#endif -} - -TextFontInfo::~TextFontInfo() { - if (gfxFont) - gfxFont->decRefCnt(); -#if TEXTOUT_WORD_LIST - if (fontName) { - delete fontName; - } -#endif -} - -GBool TextFontInfo::matches(GfxState *state) { - return state->getFont() == gfxFont; -} - -GBool TextFontInfo::matches(TextFontInfo *fontInfo) { - return gfxFont == fontInfo->gfxFont; -} - -//------------------------------------------------------------------------ -// TextWord -//------------------------------------------------------------------------ - -TextWord::TextWord(GfxState *state, int rotA, double fontSizeA) { - rot = rotA; - fontSize = fontSizeA; - text = NULL; - charcode = NULL; - edge = NULL; - charPos = NULL; - font = NULL; - textMat = NULL; - len = size = 0; - spaceAfter = gFalse; - next = NULL; - -#if TEXTOUT_WORD_LIST - GfxRGB rgb; - - if ((state->getRender() & 3) == 1) { - state->getStrokeRGB(&rgb); - } else { - state->getFillRGB(&rgb); - } - colorR = colToDbl(rgb.r); - colorG = colToDbl(rgb.g); - colorB = colToDbl(rgb.b); -#endif - - underlined = gFalse; - link = NULL; -} - -TextWord::~TextWord() { - gfree(text); - gfree(charcode); - gfree(edge); - gfree(charPos); - gfree(font); - gfree(textMat); -} - -void TextWord::addChar(GfxState *state, TextFontInfo *fontA, double x, double y, - double dx, double dy, int charPosA, int charLen, - CharCode c, Unicode u, Matrix textMatA) { - GfxFont *gfxFont; - double ascent, descent; - ascent = descent = 0; // make gcc happy - - if (len == size) { - size += 16; - text = (Unicode *)greallocn(text, size, sizeof(Unicode)); - charcode = (Unicode *)greallocn(charcode, size, sizeof(CharCode)); - edge = (double *)greallocn(edge, (size + 1), sizeof(double)); - charPos = (int *)greallocn(charPos, size + 1, sizeof(int)); - font = (TextFontInfo **)greallocn(font, size, sizeof(TextFontInfo *)); - textMat = (Matrix *)greallocn(textMat, size, sizeof(Matrix)); - } - text[len] = u; - charcode[len] = c; - charPos[len] = charPosA; - charPos[len + 1] = charPosA + charLen; - font[len] = fontA; - textMat[len] = textMatA; - - if (len == 0) { - if ((gfxFont = fontA->gfxFont)) { - ascent = gfxFont->getAscent() * fontSize; - descent = gfxFont->getDescent() * fontSize; - wMode = gfxFont->getWMode(); - } else { - // this means that the PDF file draws text without a current font, - // which should never happen - ascent = 0.95 * fontSize; - descent = -0.35 * fontSize; - wMode = 0; - } - } - - if (wMode) { // vertical writing mode - // NB: the rotation value has been incremented by 1 (in - // TextPage::beginWord()) for vertical writing mode - switch (rot) { - case 0: - if (len == 0) { - xMin = x - fontSize; - yMin = y - fontSize; - yMax = y; - base = y; - } - edge[len] = x - fontSize; - xMax = edge[len+1] = x; - break; - case 1: - if (len == 0) { - xMin = x; - yMin = y - fontSize; - xMax = x + fontSize; - base = x; - } - edge[len] = y - fontSize; - yMax = edge[len+1] = y; - break; - case 2: - if (len == 0) { - yMin = y; - xMax = x + fontSize; - yMax = y + fontSize; - base = y; - } - edge[len] = x + fontSize; - xMin = edge[len+1] = x; - break; - case 3: - if (len == 0) { - xMin = x - fontSize; - xMax = x; - yMax = y + fontSize; - base = x; - } - edge[len] = y + fontSize; - yMin = edge[len+1] = y; - break; - } - } else { // horizontal writing mode - switch (rot) { - case 0: - if (len == 0) { - xMin = x; - yMin = y - ascent; - yMax = y - descent; - if (yMin == yMax) { - // this is a sanity check for a case that shouldn't happen -- but - // if it does happen, we want to avoid dividing by zero later - yMin = y; - yMax = y + 1; - } - base = y; - } - edge[len] = x; - xMax = edge[len+1] = x + dx; - break; - case 1: - if (len == 0) { - xMin = x + descent; - yMin = y; - xMax = x + ascent; - if (xMin == xMax) { - // this is a sanity check for a case that shouldn't happen -- but - // if it does happen, we want to avoid dividing by zero later - xMin = x; - xMax = x + 1; - } - base = x; - } - edge[len] = y; - yMax = edge[len+1] = y + dy; - break; - case 2: - if (len == 0) { - yMin = y + descent; - xMax = x; - yMax = y + ascent; - if (yMin == yMax) { - // this is a sanity check for a case that shouldn't happen -- but - // if it does happen, we want to avoid dividing by zero later - yMin = y; - yMax = y + 1; - } - base = y; - } - edge[len] = x; - xMin = edge[len+1] = x + dx; - break; - case 3: - if (len == 0) { - xMin = x - ascent; - xMax = x - descent; - yMax = y; - if (xMin == xMax) { - // this is a sanity check for a case that shouldn't happen -- but - // if it does happen, we want to avoid dividing by zero later - xMin = x; - xMax = x + 1; - } - base = x; - } - edge[len] = y; - yMin = edge[len+1] = y + dy; - break; - } - } - ++len; -} - -void TextWord::merge(TextWord *word) { - int i; - - if (word->xMin < xMin) { - xMin = word->xMin; - } - if (word->yMin < yMin) { - yMin = word->yMin; - } - if (word->xMax > xMax) { - xMax = word->xMax; - } - if (word->yMax > yMax) { - yMax = word->yMax; - } - if (len + word->len > size) { - size = len + word->len; - text = (Unicode *)greallocn(text, size, sizeof(Unicode)); - charcode = (CharCode *)greallocn(charcode, (size + 1), sizeof(CharCode)); - edge = (double *)greallocn(edge, (size + 1), sizeof(double)); - charPos = (int *)greallocn(charPos, size + 1, sizeof(int)); - font = (TextFontInfo **)greallocn(font, size, sizeof(TextFontInfo *)); - textMat = (Matrix *)greallocn(textMat, size, sizeof(Matrix)); - } - for (i = 0; i < word->len; ++i) { - text[len + i] = word->text[i]; - charcode[len + i] = word->charcode[i]; - edge[len + i] = word->edge[i]; - charPos[len + i] = word->charPos[i]; - font[len + i] = word->font[i]; - textMat[len + i] = word->textMat[i]; - } - edge[len + word->len] = word->edge[word->len]; - charPos[len + word->len] = word->charPos[word->len]; - len += word->len; -} - -inline int TextWord::primaryCmp(TextWord *word) { - double cmp; - - cmp = 0; // make gcc happy - switch (rot) { - case 0: - cmp = xMin - word->xMin; - break; - case 1: - cmp = yMin - word->yMin; - break; - case 2: - cmp = word->xMax - xMax; - break; - case 3: - cmp = word->yMax - yMax; - break; - } - return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; -} - -double TextWord::primaryDelta(TextWord *word) { - double delta; - - delta = 0; // make gcc happy - switch (rot) { - case 0: - delta = word->xMin - xMax; - break; - case 1: - delta = word->yMin - yMax; - break; - case 2: - delta = xMin - word->xMax; - break; - case 3: - delta = yMin - word->yMax; - break; - } - return delta; -} - -int TextWord::cmpYX(const void *p1, const void *p2) { - TextWord *word1 = *(TextWord **)p1; - TextWord *word2 = *(TextWord **)p2; - double cmp; - - cmp = word1->yMin - word2->yMin; - if (cmp == 0) { - cmp = word1->xMin - word2->xMin; - } - return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; -} - -#if TEXTOUT_WORD_LIST - -GooString *TextWord::getText() { - GooString *s; - UnicodeMap *uMap; - char buf[8]; - int n, i; - - s = new GooString(); - if (!(uMap = globalParams->getTextEncoding())) { - return s; - } - for (i = 0; i < len; ++i) { - n = uMap->mapUnicode(text[i], buf, sizeof(buf)); - s->append(buf, n); - } - uMap->decRefCnt(); - return s; -} - -void TextWord::getCharBBox(int charIdx, double *xMinA, double *yMinA, - double *xMaxA, double *yMaxA) { - if (charIdx < 0 || charIdx >= len) { - return; - } - switch (rot) { - case 0: - *xMinA = edge[charIdx]; - *xMaxA = edge[charIdx + 1]; - *yMinA = yMin; - *yMaxA = yMax; - break; - case 1: - *xMinA = xMin; - *xMaxA = xMax; - *yMinA = edge[charIdx]; - *yMaxA = edge[charIdx + 1]; - break; - case 2: - *xMinA = edge[charIdx + 1]; - *xMaxA = edge[charIdx]; - *yMinA = yMin; - *yMaxA = yMax; - break; - case 3: - *xMinA = xMin; - *xMaxA = xMax; - *yMinA = edge[charIdx + 1]; - *yMaxA = edge[charIdx]; - break; - } -} - -#endif // TEXTOUT_WORD_LIST - -//------------------------------------------------------------------------ -// TextPool -//------------------------------------------------------------------------ - -TextPool::TextPool() { - minBaseIdx = 0; - maxBaseIdx = -1; - pool = NULL; - cursor = NULL; - cursorBaseIdx = -1; -} - -TextPool::~TextPool() { - int baseIdx; - TextWord *word, *word2; - - for (baseIdx = minBaseIdx; baseIdx <= maxBaseIdx; ++baseIdx) { - for (word = pool[baseIdx - minBaseIdx]; word; word = word2) { - word2 = word->next; - delete word; - } - } - gfree(pool); -} - -int TextPool::getBaseIdx(double base) { - int baseIdx; - - baseIdx = (int)(base / textPoolStep); - if (baseIdx < minBaseIdx) { - return minBaseIdx; - } - if (baseIdx > maxBaseIdx) { - return maxBaseIdx; - } - return baseIdx; -} - -void TextPool::addWord(TextWord *word) { - TextWord **newPool; - int wordBaseIdx, newMinBaseIdx, newMaxBaseIdx, baseIdx; - TextWord *w0, *w1; - - // expand the array if needed - if (unlikely((word->base / textPoolStep) > INT_MAX)) { - error(errSyntaxWarning, -1, "word->base / textPoolStep > INT_MAX"); - return; - } - wordBaseIdx = (int)(word->base / textPoolStep); - if (minBaseIdx > maxBaseIdx) { - minBaseIdx = wordBaseIdx - 128; - maxBaseIdx = wordBaseIdx + 128; - pool = (TextWord **)gmallocn(maxBaseIdx - minBaseIdx + 1, - sizeof(TextWord *)); - for (baseIdx = minBaseIdx; baseIdx <= maxBaseIdx; ++baseIdx) { - pool[baseIdx - minBaseIdx] = NULL; - } - } else if (wordBaseIdx < minBaseIdx) { - newMinBaseIdx = wordBaseIdx - 128; - newPool = (TextWord **)gmallocn(maxBaseIdx - newMinBaseIdx + 1, - sizeof(TextWord *)); - for (baseIdx = newMinBaseIdx; baseIdx < minBaseIdx; ++baseIdx) { - newPool[baseIdx - newMinBaseIdx] = NULL; - } - memcpy(&newPool[minBaseIdx - newMinBaseIdx], pool, - (maxBaseIdx - minBaseIdx + 1) * sizeof(TextWord *)); - gfree(pool); - pool = newPool; - minBaseIdx = newMinBaseIdx; - } else if (wordBaseIdx > maxBaseIdx) { - newMaxBaseIdx = wordBaseIdx + 128; - pool = (TextWord **)greallocn(pool, newMaxBaseIdx - minBaseIdx + 1, - sizeof(TextWord *)); - for (baseIdx = maxBaseIdx + 1; baseIdx <= newMaxBaseIdx; ++baseIdx) { - pool[baseIdx - minBaseIdx] = NULL; - } - maxBaseIdx = newMaxBaseIdx; - } - - // insert the new word - if (cursor && wordBaseIdx == cursorBaseIdx && - word->primaryCmp(cursor) >= 0) { - w0 = cursor; - w1 = cursor->next; - } else { - w0 = NULL; - w1 = pool[wordBaseIdx - minBaseIdx]; - } - for (; w1 && word->primaryCmp(w1) > 0; w0 = w1, w1 = w1->next) ; - word->next = w1; - if (w0) { - w0->next = word; - } else { - pool[wordBaseIdx - minBaseIdx] = word; - } - cursor = word; - cursorBaseIdx = wordBaseIdx; -} - -//------------------------------------------------------------------------ -// TextLine -//------------------------------------------------------------------------ - -TextLine::TextLine(TextBlock *blkA, int rotA, double baseA) { - blk = blkA; - rot = rotA; - base = baseA; - words = lastWord = NULL; - text = NULL; - edge = NULL; - col = NULL; - len = 0; - convertedLen = 0; - hyphenated = gFalse; - next = NULL; - xMin = yMin = 0; - xMax = yMax = -1; - normalized = NULL; - normalized_len = 0; - normalized_idx = NULL; -} - -TextLine::~TextLine() { - TextWord *word; - - while (words) { - word = words; - words = words->next; - delete word; - } - gfree(text); - gfree(edge); - gfree(col); - if (normalized) { - gfree(normalized); - gfree(normalized_idx); - } -} - -void TextLine::addWord(TextWord *word) { - if (lastWord) { - lastWord->next = word; - } else { - words = word; - } - lastWord = word; - - if (xMin > xMax) { - xMin = word->xMin; - xMax = word->xMax; - yMin = word->yMin; - yMax = word->yMax; - } else { - if (word->xMin < xMin) { - xMin = word->xMin; - } - if (word->xMax > xMax) { - xMax = word->xMax; - } - if (word->yMin < yMin) { - yMin = word->yMin; - } - if (word->yMax > yMax) { - yMax = word->yMax; - } - } -} - -double TextLine::primaryDelta(TextLine *line) { - double delta; - - delta = 0; // make gcc happy - switch (rot) { - case 0: - delta = line->xMin - xMax; - break; - case 1: - delta = line->yMin - yMax; - break; - case 2: - delta = xMin - line->xMax; - break; - case 3: - delta = yMin - line->yMax; - break; - } - return delta; -} - -int TextLine::primaryCmp(TextLine *line) { - double cmp; - - cmp = 0; // make gcc happy - switch (rot) { - case 0: - cmp = xMin - line->xMin; - break; - case 1: - cmp = yMin - line->yMin; - break; - case 2: - cmp = line->xMax - xMax; - break; - case 3: - cmp = line->yMax - yMax; - break; - } - return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; -} - -int TextLine::secondaryCmp(TextLine *line) { - double cmp; - - cmp = (rot == 0 || rot == 3) ? base - line->base : line->base - base; - return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; -} - -int TextLine::cmpYX(TextLine *line) { - int cmp; - - if ((cmp = secondaryCmp(line))) { - return cmp; - } - return primaryCmp(line); -} - -int TextLine::cmpXY(const void *p1, const void *p2) { - TextLine *line1 = *(TextLine **)p1; - TextLine *line2 = *(TextLine **)p2; - int cmp; - - if ((cmp = line1->primaryCmp(line2))) { - return cmp; - } - return line1->secondaryCmp(line2); -} - -void TextLine::coalesce(UnicodeMap *uMap) { - TextWord *word0, *word1; - double space, delta, minSpace; - GBool isUnicode; - char buf[8]; - int i, j; - - if (words->next) { - - // compute the inter-word space threshold - if (words->len > 1 || words->next->len > 1) { - minSpace = 0; - } else { - minSpace = words->primaryDelta(words->next); - for (word0 = words->next, word1 = word0->next; - word1 && minSpace > 0; - word0 = word1, word1 = word0->next) { - if (word1->len > 1) { - minSpace = 0; - } - delta = word0->primaryDelta(word1); - if (delta < minSpace) { - minSpace = delta; - } - } - } - if (minSpace <= 0) { - space = maxCharSpacing * words->fontSize; - } else { - space = maxWideCharSpacingMul * minSpace; - if (space > maxWideCharSpacing * words->fontSize) { - space = maxWideCharSpacing * words->fontSize; - } - } - - // merge words - word0 = words; - word1 = words->next; - while (word1) { - if (word0->primaryDelta(word1) >= space) { - word0->spaceAfter = gTrue; - word0 = word1; - word1 = word1->next; - } else if (word0->font[word0->len - 1] == word1->font[0] && - word0->underlined == word1->underlined && - fabs(word0->fontSize - word1->fontSize) < - maxWordFontSizeDelta * words->fontSize && - word1->charPos[0] == word0->charPos[word0->len]) { - word0->merge(word1); - word0->next = word1->next; - delete word1; - word1 = word0->next; - } else { - word0 = word1; - word1 = word1->next; - } - } - } - - // build the line text - isUnicode = uMap ? uMap->isUnicode() : gFalse; - len = 0; - for (word1 = words; word1; word1 = word1->next) { - len += word1->len; - if (word1->spaceAfter) { - ++len; - } - } - text = (Unicode *)gmallocn(len, sizeof(Unicode)); - edge = (double *)gmallocn(len + 1, sizeof(double)); - i = 0; - for (word1 = words; word1; word1 = word1->next) { - for (j = 0; j < word1->len; ++j) { - text[i] = word1->text[j]; - edge[i] = word1->edge[j]; - ++i; - } - edge[i] = word1->edge[word1->len]; - if (word1->spaceAfter) { - text[i] = (Unicode)0x0020; - ++i; - } - } - - // compute convertedLen and set up the col array - col = (int *)gmallocn(len + 1, sizeof(int)); - convertedLen = 0; - for (i = 0; i < len; ++i) { - col[i] = convertedLen; - if (isUnicode) { - ++convertedLen; - } else if (uMap) { - convertedLen += uMap->mapUnicode(text[i], buf, sizeof(buf)); - } - } - col[len] = convertedLen; - - // check for hyphen at end of line - //~ need to check for other chars used as hyphens - hyphenated = text[len - 1] == (Unicode)'-'; -} - -//------------------------------------------------------------------------ -// TextLineFrag -//------------------------------------------------------------------------ - -class TextLineFrag { -public: - - TextLine *line; // the line object - int start, len; // offset and length of this fragment - // (in Unicode chars) - double xMin, xMax; // bounding box coordinates - double yMin, yMax; - double base; // baseline virtual coordinate - int col; // first column - - void init(TextLine *lineA, int startA, int lenA); - void computeCoords(GBool oneRot); - - static int cmpYXPrimaryRot(const void *p1, const void *p2); - static int cmpYXLineRot(const void *p1, const void *p2); - static int cmpXYLineRot(const void *p1, const void *p2); - static int cmpXYColumnPrimaryRot(const void *p1, const void *p2); - static int cmpXYColumnLineRot(const void *p1, const void *p2); -}; - -void TextLineFrag::init(TextLine *lineA, int startA, int lenA) { - line = lineA; - start = startA; - len = lenA; - col = line->col[start]; -} - -void TextLineFrag::computeCoords(GBool oneRot) { - TextBlock *blk; - double d0, d1, d2, d3, d4; - - if (oneRot) { - - switch (line->rot) { - case 0: - xMin = line->edge[start]; - xMax = line->edge[start + len]; - yMin = line->yMin; - yMax = line->yMax; - break; - case 1: - xMin = line->xMin; - xMax = line->xMax; - yMin = line->edge[start]; - yMax = line->edge[start + len]; - break; - case 2: - xMin = line->edge[start + len]; - xMax = line->edge[start]; - yMin = line->yMin; - yMax = line->yMax; - break; - case 3: - xMin = line->xMin; - xMax = line->xMax; - yMin = line->edge[start + len]; - yMax = line->edge[start]; - break; - } - base = line->base; - - } else { - - if (line->rot == 0 && line->blk->page->primaryRot == 0) { - - xMin = line->edge[start]; - xMax = line->edge[start + len]; - yMin = line->yMin; - yMax = line->yMax; - base = line->base; - - } else { - - blk = line->blk; - d0 = line->edge[start]; - d1 = line->edge[start + len]; - d2 = d3 = d4 = 0; // make gcc happy - - switch (line->rot) { - case 0: - d2 = line->yMin; - d3 = line->yMax; - d4 = line->base; - d0 = (d0 - blk->xMin) / (blk->xMax - blk->xMin); - d1 = (d1 - blk->xMin) / (blk->xMax - blk->xMin); - d2 = (d2 - blk->yMin) / (blk->yMax - blk->yMin); - d3 = (d3 - blk->yMin) / (blk->yMax - blk->yMin); - d4 = (d4 - blk->yMin) / (blk->yMax - blk->yMin); - break; - case 1: - d2 = line->xMax; - d3 = line->xMin; - d4 = line->base; - d0 = (d0 - blk->yMin) / (blk->yMax - blk->yMin); - d1 = (d1 - blk->yMin) / (blk->yMax - blk->yMin); - d2 = (blk->xMax - d2) / (blk->xMax - blk->xMin); - d3 = (blk->xMax - d3) / (blk->xMax - blk->xMin); - d4 = (blk->xMax - d4) / (blk->xMax - blk->xMin); - break; - case 2: - d2 = line->yMax; - d3 = line->yMin; - d4 = line->base; - d0 = (blk->xMax - d0) / (blk->xMax - blk->xMin); - d1 = (blk->xMax - d1) / (blk->xMax - blk->xMin); - d2 = (blk->yMax - d2) / (blk->yMax - blk->yMin); - d3 = (blk->yMax - d3) / (blk->yMax - blk->yMin); - d4 = (blk->yMax - d4) / (blk->yMax - blk->yMin); - break; - case 3: - d2 = line->xMin; - d3 = line->xMax; - d4 = line->base; - d0 = (blk->yMax - d0) / (blk->yMax - blk->yMin); - d1 = (blk->yMax - d1) / (blk->yMax - blk->yMin); - d2 = (d2 - blk->xMin) / (blk->xMax - blk->xMin); - d3 = (d3 - blk->xMin) / (blk->xMax - blk->xMin); - d4 = (d4 - blk->xMin) / (blk->xMax - blk->xMin); - break; - } - - switch (line->blk->page->primaryRot) { - case 0: - xMin = blk->xMin + d0 * (blk->xMax - blk->xMin); - xMax = blk->xMin + d1 * (blk->xMax - blk->xMin); - yMin = blk->yMin + d2 * (blk->yMax - blk->yMin); - yMax = blk->yMin + d3 * (blk->yMax - blk->yMin); - base = blk->yMin + d4 * (blk->yMax - blk->yMin); - break; - case 1: - xMin = blk->xMax - d3 * (blk->xMax - blk->xMin); - xMax = blk->xMax - d2 * (blk->xMax - blk->xMin); - yMin = blk->yMin + d0 * (blk->yMax - blk->yMin); - yMax = blk->yMin + d1 * (blk->yMax - blk->yMin); - base = blk->xMax - d4 * (blk->xMax - blk->xMin); - break; - case 2: - xMin = blk->xMax - d1 * (blk->xMax - blk->xMin); - xMax = blk->xMax - d0 * (blk->xMax - blk->xMin); - yMin = blk->yMax - d3 * (blk->yMax - blk->yMin); - yMax = blk->yMax - d2 * (blk->yMax - blk->yMin); - base = blk->yMax - d4 * (blk->yMax - blk->yMin); - break; - case 3: - xMin = blk->xMin + d2 * (blk->xMax - blk->xMin); - xMax = blk->xMin + d3 * (blk->xMax - blk->xMin); - yMin = blk->yMax - d1 * (blk->yMax - blk->yMin); - yMax = blk->yMax - d0 * (blk->yMax - blk->yMin); - base = blk->xMin + d4 * (blk->xMax - blk->xMin); - break; - } - - } - } -} - -int TextLineFrag::cmpYXPrimaryRot(const void *p1, const void *p2) { - TextLineFrag *frag1 = (TextLineFrag *)p1; - TextLineFrag *frag2 = (TextLineFrag *)p2; - double cmp; - - cmp = 0; // make gcc happy - switch (frag1->line->blk->page->primaryRot) { - case 0: - if (fabs(cmp = frag1->yMin - frag2->yMin) < 0.01) { - cmp = frag1->xMin - frag2->xMin; - } - break; - case 1: - if (fabs(cmp = frag2->xMax - frag1->xMax) < 0.01) { - cmp = frag1->yMin - frag2->yMin; - } - break; - case 2: - if (fabs(cmp = frag2->yMin - frag1->yMin) < 0.01) { - cmp = frag2->xMax - frag1->xMax; - } - break; - case 3: - if (fabs(cmp = frag1->xMax - frag2->xMax) < 0.01) { - cmp = frag2->yMax - frag1->yMax; - } - break; - } - return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; -} - -int TextLineFrag::cmpYXLineRot(const void *p1, const void *p2) { - TextLineFrag *frag1 = (TextLineFrag *)p1; - TextLineFrag *frag2 = (TextLineFrag *)p2; - double cmp; - - cmp = 0; // make gcc happy - switch (frag1->line->rot) { - case 0: - if ((cmp = frag1->yMin - frag2->yMin) == 0) { - cmp = frag1->xMin - frag2->xMin; - } - break; - case 1: - if ((cmp = frag2->xMax - frag1->xMax) == 0) { - cmp = frag1->yMin - frag2->yMin; - } - break; - case 2: - if ((cmp = frag2->yMin - frag1->yMin) == 0) { - cmp = frag2->xMax - frag1->xMax; - } - break; - case 3: - if ((cmp = frag1->xMax - frag2->xMax) == 0) { - cmp = frag2->yMax - frag1->yMax; - } - break; - } - return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; -} - -int TextLineFrag::cmpXYLineRot(const void *p1, const void *p2) { - TextLineFrag *frag1 = (TextLineFrag *)p1; - TextLineFrag *frag2 = (TextLineFrag *)p2; - double cmp; - - cmp = 0; // make gcc happy - switch (frag1->line->rot) { - case 0: - if ((cmp = frag1->xMin - frag2->xMin) == 0) { - cmp = frag1->yMin - frag2->yMin; - } - break; - case 1: - if ((cmp = frag1->yMin - frag2->yMin) == 0) { - cmp = frag2->xMax - frag1->xMax; - } - break; - case 2: - if ((cmp = frag2->xMax - frag1->xMax) == 0) { - cmp = frag2->yMin - frag1->yMin; - } - break; - case 3: - if ((cmp = frag2->yMax - frag1->yMax) == 0) { - cmp = frag1->xMax - frag2->xMax; - } - break; - } - return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; -} - -int TextLineFrag::cmpXYColumnPrimaryRot(const void *p1, const void *p2) { - TextLineFrag *frag1 = (TextLineFrag *)p1; - TextLineFrag *frag2 = (TextLineFrag *)p2; - double cmp; - - // if columns overlap, compare y values - if (frag1->col < frag2->col + (frag2->line->col[frag2->start + frag2->len] - - frag2->line->col[frag2->start]) && - frag2->col < frag1->col + (frag1->line->col[frag1->start + frag1->len] - - frag1->line->col[frag1->start])) { - cmp = 0; // make gcc happy - switch (frag1->line->blk->page->primaryRot) { - case 0: cmp = frag1->yMin - frag2->yMin; break; - case 1: cmp = frag2->xMax - frag1->xMax; break; - case 2: cmp = frag2->yMin - frag1->yMin; break; - case 3: cmp = frag1->xMax - frag2->xMax; break; - } - return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; - } - - // otherwise, compare starting column - return frag1->col - frag2->col; -} - -int TextLineFrag::cmpXYColumnLineRot(const void *p1, const void *p2) { - TextLineFrag *frag1 = (TextLineFrag *)p1; - TextLineFrag *frag2 = (TextLineFrag *)p2; - double cmp; - - // if columns overlap, compare y values - if (frag1->col < frag2->col + (frag2->line->col[frag2->start + frag2->len] - - frag2->line->col[frag2->start]) && - frag2->col < frag1->col + (frag1->line->col[frag1->start + frag1->len] - - frag1->line->col[frag1->start])) { - cmp = 0; // make gcc happy - switch (frag1->line->rot) { - case 0: cmp = frag1->yMin - frag2->yMin; break; - case 1: cmp = frag2->xMax - frag1->xMax; break; - case 2: cmp = frag2->yMin - frag1->yMin; break; - case 3: cmp = frag1->xMax - frag2->xMax; break; - } - return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; - } - - // otherwise, compare starting column - return frag1->col - frag2->col; -} - -//------------------------------------------------------------------------ -// TextBlock -//------------------------------------------------------------------------ - -TextBlock::TextBlock(TextPage *pageA, int rotA) { - page = pageA; - rot = rotA; - xMin = yMin = 0; - xMax = yMax = -1; - priMin = 0; - priMax = page->pageWidth; - pool = new TextPool(); - lines = NULL; - curLine = NULL; - next = NULL; - stackNext = NULL; - tableId = -1; - tableEnd = gFalse; -} - -TextBlock::~TextBlock() { - TextLine *line; - - delete pool; - while (lines) { - line = lines; - lines = lines->next; - delete line; - } -} - -void TextBlock::addWord(TextWord *word) { - pool->addWord(word); - if (xMin > xMax) { - xMin = word->xMin; - xMax = word->xMax; - yMin = word->yMin; - yMax = word->yMax; - } else { - if (word->xMin < xMin) { - xMin = word->xMin; - } - if (word->xMax > xMax) { - xMax = word->xMax; - } - if (word->yMin < yMin) { - yMin = word->yMin; - } - if (word->yMax > yMax) { - yMax = word->yMax; - } - } -} - -void TextBlock::coalesce(UnicodeMap *uMap, double fixedPitch) { - TextWord *word0, *word1, *word2, *bestWord0, *bestWord1, *lastWord; - TextLine *line, *line0, *line1; - int poolMinBaseIdx, startBaseIdx, minBaseIdx, maxBaseIdx; - int baseIdx, bestWordBaseIdx, idx0, idx1; - double minBase, maxBase; - double fontSize, wordSpacing, delta, priDelta, secDelta; - TextLine **lineArray; - GBool found, overlap; - int col1, col2; - int i, j, k; - - // discard duplicated text (fake boldface, drop shadows) - for (idx0 = pool->minBaseIdx; idx0 <= pool->maxBaseIdx; ++idx0) { - word0 = pool->getPool(idx0); - while (word0) { - priDelta = dupMaxPriDelta * word0->fontSize; - secDelta = dupMaxSecDelta * word0->fontSize; - maxBaseIdx = pool->getBaseIdx(word0->base + secDelta); - found = gFalse; - word1 = word2 = NULL; // make gcc happy - for (idx1 = idx0; idx1 <= maxBaseIdx; ++idx1) { - if (idx1 == idx0) { - word1 = word0; - word2 = word0->next; - } else { - word1 = NULL; - word2 = pool->getPool(idx1); - } - for (; word2; word1 = word2, word2 = word2->next) { - if (word2->len == word0->len && - !memcmp(word2->text, word0->text, - word0->len * sizeof(Unicode))) { - switch (rot) { - case 0: - case 2: - found = fabs(word0->xMin - word2->xMin) < priDelta && - fabs(word0->xMax - word2->xMax) < priDelta && - fabs(word0->yMin - word2->yMin) < secDelta && - fabs(word0->yMax - word2->yMax) < secDelta; - break; - case 1: - case 3: - found = fabs(word0->xMin - word2->xMin) < secDelta && - fabs(word0->xMax - word2->xMax) < secDelta && - fabs(word0->yMin - word2->yMin) < priDelta && - fabs(word0->yMax - word2->yMax) < priDelta; - break; - } - } - if (found) { - break; - } - } - if (found) { - break; - } - } - if (found) { - if (word1) { - word1->next = word2->next; - } else { - pool->setPool(idx1, word2->next); - } - delete word2; - } else { - word0 = word0->next; - } - } - } - - // build the lines - curLine = NULL; - poolMinBaseIdx = pool->minBaseIdx; - charCount = 0; - nLines = 0; - while (1) { - - // find the first non-empty line in the pool - for (; - poolMinBaseIdx <= pool->maxBaseIdx && !pool->getPool(poolMinBaseIdx); - ++poolMinBaseIdx) ; - if (poolMinBaseIdx > pool->maxBaseIdx) { - break; - } - - // look for the left-most word in the first four lines of the - // pool -- this avoids starting with a superscript word - startBaseIdx = poolMinBaseIdx; - for (baseIdx = poolMinBaseIdx + 1; - baseIdx < poolMinBaseIdx + 4 && baseIdx <= pool->maxBaseIdx; - ++baseIdx) { - if (!pool->getPool(baseIdx)) { - continue; - } - if (pool->getPool(baseIdx)->primaryCmp(pool->getPool(startBaseIdx)) - < 0) { - startBaseIdx = baseIdx; - } - } - - // create a new line - word0 = pool->getPool(startBaseIdx); - pool->setPool(startBaseIdx, word0->next); - word0->next = NULL; - line = new TextLine(this, word0->rot, word0->base); - line->addWord(word0); - lastWord = word0; - - // compute the search range - fontSize = word0->fontSize; - minBase = word0->base - maxIntraLineDelta * fontSize; - maxBase = word0->base + maxIntraLineDelta * fontSize; - minBaseIdx = pool->getBaseIdx(minBase); - maxBaseIdx = pool->getBaseIdx(maxBase); - wordSpacing = fixedPitch ? fixedPitch : maxWordSpacing * fontSize; - - // find the rest of the words in this line - while (1) { - - // find the left-most word whose baseline is in the range for - // this line - bestWordBaseIdx = 0; - bestWord0 = bestWord1 = NULL; - overlap = gFalse; - for (baseIdx = minBaseIdx; - !overlap && baseIdx <= maxBaseIdx; - ++baseIdx) { - for (word0 = NULL, word1 = pool->getPool(baseIdx); - word1; - word0 = word1, word1 = word1->next) { - if (word1->base >= minBase && - word1->base <= maxBase) { - delta = lastWord->primaryDelta(word1); - if (delta < minCharSpacing * fontSize) { - overlap = gTrue; - break; - } else { - if (delta < wordSpacing && - (!bestWord1 || word1->primaryCmp(bestWord1) < 0)) { - bestWordBaseIdx = baseIdx; - bestWord0 = word0; - bestWord1 = word1; - } - break; - } - } - } - } - if (overlap || !bestWord1) { - break; - } - - // remove it from the pool, and add it to the line - if (bestWord0) { - bestWord0->next = bestWord1->next; - } else { - pool->setPool(bestWordBaseIdx, bestWord1->next); - } - bestWord1->next = NULL; - line->addWord(bestWord1); - lastWord = bestWord1; - } - - // add the line - if (curLine && line->cmpYX(curLine) > 0) { - line0 = curLine; - line1 = curLine->next; - } else { - line0 = NULL; - line1 = lines; - } - for (; - line1 && line->cmpYX(line1) > 0; - line0 = line1, line1 = line1->next) ; - if (line0) { - line0->next = line; - } else { - lines = line; - } - line->next = line1; - curLine = line; - line->coalesce(uMap); - charCount += line->len; - ++nLines; - } - - // sort lines into xy order for column assignment - lineArray = (TextLine **)gmallocn(nLines, sizeof(TextLine *)); - for (line = lines, i = 0; line; line = line->next, ++i) { - lineArray[i] = line; - } - qsort(lineArray, nLines, sizeof(TextLine *), &TextLine::cmpXY); - - // column assignment - nColumns = 0; - if (fixedPitch) { - for (i = 0; i < nLines; ++i) { - line0 = lineArray[i]; - col1 = 0; // make gcc happy - switch (rot) { - case 0: - col1 = (int)((line0->xMin - xMin) / fixedPitch + 0.5); - break; - case 1: - col1 = (int)((line0->yMin - yMin) / fixedPitch + 0.5); - break; - case 2: - col1 = (int)((xMax - line0->xMax) / fixedPitch + 0.5); - break; - case 3: - col1 = (int)((yMax - line0->yMax) / fixedPitch + 0.5); - break; - } - for (k = 0; k <= line0->len; ++k) { - line0->col[k] += col1; - } - if (line0->col[line0->len] > nColumns) { - nColumns = line0->col[line0->len]; - } - } - } else { - for (i = 0; i < nLines; ++i) { - line0 = lineArray[i]; - col1 = 0; - for (j = 0; j < i; ++j) { - line1 = lineArray[j]; - if (line1->primaryDelta(line0) >= 0) { - col2 = line1->col[line1->len] + 1; - } else { - k = 0; // make gcc happy - switch (rot) { - case 0: - for (k = 0; - k < line1->len && - line0->xMin >= 0.5 * (line1->edge[k] + line1->edge[k+1]); - ++k) ; - break; - case 1: - for (k = 0; - k < line1->len && - line0->yMin >= 0.5 * (line1->edge[k] + line1->edge[k+1]); - ++k) ; - break; - case 2: - for (k = 0; - k < line1->len && - line0->xMax <= 0.5 * (line1->edge[k] + line1->edge[k+1]); - ++k) ; - break; - case 3: - for (k = 0; - k < line1->len && - line0->yMax <= 0.5 * (line1->edge[k] + line1->edge[k+1]); - ++k) ; - break; - } - col2 = line1->col[k]; - } - if (col2 > col1) { - col1 = col2; - } - } - for (k = 0; k <= line0->len; ++k) { - line0->col[k] += col1; - } - if (line0->col[line0->len] > nColumns) { - nColumns = line0->col[line0->len]; - } - } - } - gfree(lineArray); -} - -void TextBlock::updatePriMinMax(TextBlock *blk) { - double newPriMin, newPriMax; - GBool gotPriMin, gotPriMax; - - gotPriMin = gotPriMax = gFalse; - newPriMin = newPriMax = 0; // make gcc happy - switch (page->primaryRot) { - case 0: - case 2: - if (blk->yMin < yMax && blk->yMax > yMin) { - if (blk->xMin < xMin) { - newPriMin = blk->xMax; - gotPriMin = gTrue; - } - if (blk->xMax > xMax) { - newPriMax = blk->xMin; - gotPriMax = gTrue; - } - } - break; - case 1: - case 3: - if (blk->xMin < xMax && blk->xMax > xMin) { - if (blk->yMin < yMin) { - newPriMin = blk->yMax; - gotPriMin = gTrue; - } - if (blk->yMax > yMax) { - newPriMax = blk->yMin; - gotPriMax = gTrue; - } - } - break; - } - if (gotPriMin) { - if (newPriMin > xMin) { - newPriMin = xMin; - } - if (newPriMin > priMin) { - priMin = newPriMin; - } - } - if (gotPriMax) { - if (newPriMax < xMax) { - newPriMax = xMax; - } - if (newPriMax < priMax) { - priMax = newPriMax; - } - } -} - -int TextBlock::cmpXYPrimaryRot(const void *p1, const void *p2) { - TextBlock *blk1 = *(TextBlock **)p1; - TextBlock *blk2 = *(TextBlock **)p2; - double cmp; - - cmp = 0; // make gcc happy - switch (blk1->page->primaryRot) { - case 0: - if ((cmp = blk1->xMin - blk2->xMin) == 0) { - cmp = blk1->yMin - blk2->yMin; - } - break; - case 1: - if ((cmp = blk1->yMin - blk2->yMin) == 0) { - cmp = blk2->xMax - blk1->xMax; - } - break; - case 2: - if ((cmp = blk2->xMax - blk1->xMax) == 0) { - cmp = blk2->yMin - blk1->yMin; - } - break; - case 3: - if ((cmp = blk2->yMax - blk1->yMax) == 0) { - cmp = blk1->xMax - blk2->xMax; - } - break; - } - return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; -} - -int TextBlock::cmpYXPrimaryRot(const void *p1, const void *p2) { - TextBlock *blk1 = *(TextBlock **)p1; - TextBlock *blk2 = *(TextBlock **)p2; - double cmp; - - cmp = 0; // make gcc happy - switch (blk1->page->primaryRot) { - case 0: - if ((cmp = blk1->yMin - blk2->yMin) == 0) { - cmp = blk1->xMin - blk2->xMin; - } - break; - case 1: - if ((cmp = blk2->xMax - blk1->xMax) == 0) { - cmp = blk1->yMin - blk2->yMin; - } - break; - case 2: - if ((cmp = blk2->yMin - blk1->yMin) == 0) { - cmp = blk2->xMax - blk1->xMax; - } - break; - case 3: - if ((cmp = blk1->xMax - blk2->xMax) == 0) { - cmp = blk2->yMax - blk1->yMax; - } - break; - } - return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; -} - -int TextBlock::primaryCmp(TextBlock *blk) { - double cmp; - - cmp = 0; // make gcc happy - switch (rot) { - case 0: - cmp = xMin - blk->xMin; - break; - case 1: - cmp = yMin - blk->yMin; - break; - case 2: - cmp = blk->xMax - xMax; - break; - case 3: - cmp = blk->yMax - yMax; - break; - } - return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; -} - -double TextBlock::secondaryDelta(TextBlock *blk) { - double delta; - - delta = 0; // make gcc happy - switch (rot) { - case 0: - delta = blk->yMin - yMax; - break; - case 1: - delta = xMin - blk->xMax; - break; - case 2: - delta = yMin - blk->yMax; - break; - case 3: - delta = blk->xMin - xMax; - break; - } - return delta; -} - -GBool TextBlock::isBelow(TextBlock *blk) { - GBool below; - - below = gFalse; // make gcc happy - switch (page->primaryRot) { - case 0: - below = xMin >= blk->priMin && xMax <= blk->priMax && - yMin > blk->yMin; - break; - case 1: - below = yMin >= blk->priMin && yMax <= blk->priMax && - xMax < blk->xMax; - break; - case 2: - below = xMin >= blk->priMin && xMax <= blk->priMax && - yMax < blk->yMax; - break; - case 3: - below = yMin >= blk->priMin && yMax <= blk->priMax && - xMin > blk->xMin; - break; - } - - return below; -} - -GBool TextBlock::isBeforeByRule1(TextBlock *blk1) { - GBool before = gFalse; - GBool overlap = gFalse; - - switch (this->page->primaryRot) { - case 0: - case 2: - overlap = ((this->ExMin <= blk1->ExMin) && - (blk1->ExMin <= this->ExMax)) || - ((blk1->ExMin <= this->ExMin) && - (this->ExMin <= blk1->ExMax)); - break; - case 1: - case 3: - overlap = ((this->EyMin <= blk1->EyMin) && - (blk1->EyMin <= this->EyMax)) || - ((blk1->EyMin <= this->EyMin) && - (this->EyMin <= blk1->EyMax)); - break; - } - switch (this->page->primaryRot) { - case 0: - before = overlap && this->EyMin < blk1->EyMin; - break; - case 1: - before = overlap && this->ExMax > blk1->ExMax; - break; - case 2: - before = overlap && this->EyMax > blk1->EyMax; - break; - case 3: - before = overlap && this->ExMin < blk1->ExMin; - break; - } - return before; -} - -GBool TextBlock::isBeforeByRule2(TextBlock *blk1) { - double cmp = 0; - int rotLR = rot; - - if (!page->primaryLR) { - rotLR = (rotLR + 2) % 4; - } - - switch (rotLR) { - case 0: - cmp = ExMax - blk1->ExMin; - break; - case 1: - cmp = EyMin - blk1->EyMax; - break; - case 2: - cmp = blk1->ExMax - ExMin; - break; - case 3: - cmp = blk1->EyMin - EyMax; - break; - } - return cmp <= 0; -} - -// Sort into reading order by performing a topological sort using the rules -// given in "High Performance Document Layout Analysis", T.M. Breuel, 2003. -// See http://pubs.iupr.org/#2003-breuel-sdiut -// Topological sort is done by depth first search, see -// http://en.wikipedia.org/wiki/Topological_sorting -int TextBlock::visitDepthFirst(TextBlock *blkList, int pos1, - TextBlock **sorted, int sortPos, - GBool* visited) { - int pos2; - TextBlock *blk1, *blk2, *blk3; - GBool before; - - if (visited[pos1]) { - return sortPos; - } - - blk1 = this; - -#if 0 // for debugging - printf("visited: %d %.2f..%.2f %.2f..%.2f\n", - sortPos, blk1->ExMin, blk1->ExMax, blk1->EyMin, blk1->EyMax); -#endif - visited[pos1] = gTrue; - pos2 = -1; - for (blk2 = blkList; blk2; blk2 = blk2->next) { - pos2++; - if (visited[pos2]) { - // skip visited nodes - continue; - } - before = gFalse; - - // is blk2 before blk1? (for table entries) - if (blk1->tableId >= 0 && blk1->tableId == blk2->tableId) { - if (page->primaryLR) { - if (blk2->xMax <= blk1->xMin && - blk2->yMin <= blk1->yMax && - blk2->yMax >= blk1->yMin) - before = gTrue; - } else { - if (blk2->xMin >= blk1->xMax && - blk2->yMin <= blk1->yMax && - blk2->yMax >= blk1->yMin) - before = gTrue; - } - - if (blk2->yMax <= blk1->yMin) - before = gTrue; - } else { - if (blk2->isBeforeByRule1(blk1)) { - // Rule (1) blk1 and blk2 overlap, and blk2 is above blk1. - before = gTrue; -#if 0 // for debugging - printf("rule1: %.2f..%.2f %.2f..%.2f %.2f..%.2f %.2f..%.2f\n", - blk2->ExMin, blk2->ExMax, blk2->EyMin, blk2->EyMax, - blk1->ExMin, blk1->ExMax, blk1->EyMin, blk1->EyMax); -#endif - } else if (blk2->isBeforeByRule2(blk1)) { - // Rule (2) blk2 left of blk1, and no intervening blk3 - // such that blk1 is before blk3 by rule 1, - // and blk3 is before blk2 by rule 1. - before = gTrue; - for (blk3 = blkList; blk3; blk3 = blk3->next) { - if (blk3 == blk2 || blk3 == blk1) { - continue; - } - if (blk1->isBeforeByRule1(blk3) && - blk3->isBeforeByRule1(blk2)) { - before = gFalse; - break; - } - } -#if 0 // for debugging - if (before) { - printf("rule2: %.2f..%.2f %.2f..%.2f %.2f..%.2f %.2f..%.2f\n", - blk1->ExMin, blk1->ExMax, blk1->EyMin, blk1->EyMax, - blk2->ExMin, blk2->ExMax, blk2->EyMin, blk2->EyMax); - } -#endif - } - } - if (before) { - // blk2 is before blk1, so it needs to be visited - // before we can add blk1 to the sorted list. - sortPos = blk2->visitDepthFirst(blkList, pos2, sorted, sortPos, visited); - } - } -#if 0 // for debugging - printf("sorted: %d %.2f..%.2f %.2f..%.2f\n", - sortPos, blk1->ExMin, blk1->ExMax, blk1->EyMin, blk1->EyMax); -#endif - sorted[sortPos++] = blk1; - return sortPos; -} - -//------------------------------------------------------------------------ -// TextFlow -//------------------------------------------------------------------------ - -TextFlow::TextFlow(TextPage *pageA, TextBlock *blk) { - page = pageA; - xMin = blk->xMin; - xMax = blk->xMax; - yMin = blk->yMin; - yMax = blk->yMax; - priMin = blk->priMin; - priMax = blk->priMax; - blocks = lastBlk = blk; - next = NULL; -} - -TextFlow::~TextFlow() { - TextBlock *blk; - - while (blocks) { - blk = blocks; - blocks = blocks->next; - delete blk; - } -} - -void TextFlow::addBlock(TextBlock *blk) { - if (lastBlk) { - lastBlk->next = blk; - } else { - blocks = blk; - } - lastBlk = blk; - if (blk->xMin < xMin) { - xMin = blk->xMin; - } - if (blk->xMax > xMax) { - xMax = blk->xMax; - } - if (blk->yMin < yMin) { - yMin = blk->yMin; - } - if (blk->yMax > yMax) { - yMax = blk->yMax; - } -} - -GBool TextFlow::blockFits(TextBlock *blk, TextBlock *prevBlk) { - GBool fits; - - // lower blocks must use smaller fonts - if (blk->lines->words->fontSize > lastBlk->lines->words->fontSize) { - return gFalse; - } - - fits = gFalse; // make gcc happy - switch (page->primaryRot) { - case 0: - fits = blk->xMin >= priMin && blk->xMax <= priMax; - break; - case 1: - fits = blk->yMin >= priMin && blk->yMax <= priMax; - break; - case 2: - fits = blk->xMin >= priMin && blk->xMax <= priMax; - break; - case 3: - fits = blk->yMin >= priMin && blk->yMax <= priMax; - break; - } - return fits; -} - -#if TEXTOUT_WORD_LIST - -//------------------------------------------------------------------------ -// TextWordList -//------------------------------------------------------------------------ - -TextWordList::TextWordList(TextPage *text, GBool physLayout) { - TextFlow *flow; - TextBlock *blk; - TextLine *line; - TextWord *word; - TextWord **wordArray; - int nWords, i; - - words = new GooList(); - - if (text->rawOrder) { - for (word = text->rawWords; word; word = word->next) { - words->append(word); - } - - } else if (physLayout) { - // this is inefficient, but it's also the least useful of these - // three cases - nWords = 0; - for (flow = text->flows; flow; flow = flow->next) { - for (blk = flow->blocks; blk; blk = blk->next) { - for (line = blk->lines; line; line = line->next) { - for (word = line->words; word; word = word->next) { - ++nWords; - } - } - } - } - wordArray = (TextWord **)gmallocn(nWords, sizeof(TextWord *)); - i = 0; - for (flow = text->flows; flow; flow = flow->next) { - for (blk = flow->blocks; blk; blk = blk->next) { - for (line = blk->lines; line; line = line->next) { - for (word = line->words; word; word = word->next) { - wordArray[i++] = word; - } - } - } - } - qsort(wordArray, nWords, sizeof(TextWord *), &TextWord::cmpYX); - for (i = 0; i < nWords; ++i) { - words->append(wordArray[i]); - } - gfree(wordArray); - - } else { - for (flow = text->flows; flow; flow = flow->next) { - for (blk = flow->blocks; blk; blk = blk->next) { - for (line = blk->lines; line; line = line->next) { - for (word = line->words; word; word = word->next) { - words->append(word); - } - } - } - } - } -} - -TextWordList::~TextWordList() { - delete words; -} - -int TextWordList::getLength() { - return words->getLength(); -} - -TextWord *TextWordList::get(int idx) { - if (idx < 0 || idx >= words->getLength()) { - return NULL; - } - return (TextWord *)words->get(idx); -} - -#endif // TEXTOUT_WORD_LIST - -//------------------------------------------------------------------------ -// TextPage -//------------------------------------------------------------------------ - -TextPage::TextPage(GBool rawOrderA) { - int rot; - - refCnt = 1; - rawOrder = rawOrderA; - curWord = NULL; - charPos = 0; - curFont = NULL; - curFontSize = 0; - nest = 0; - nTinyChars = 0; - lastCharOverlap = gFalse; - if (!rawOrder) { - for (rot = 0; rot < 4; ++rot) { - pools[rot] = new TextPool(); - } - } - flows = NULL; - blocks = NULL; - rawWords = NULL; - rawLastWord = NULL; - fonts = new GooList(); - lastFindXMin = lastFindYMin = 0; - haveLastFind = gFalse; - underlines = new GooList(); - links = new GooList(); -} - -TextPage::~TextPage() { - int rot; - - clear(); - if (!rawOrder) { - for (rot = 0; rot < 4; ++rot) { - delete pools[rot]; - } - } - delete fonts; - deleteGooList(underlines, TextUnderline); - deleteGooList(links, TextLink); -} - -void TextPage::incRefCnt() { - refCnt++; -} - -void TextPage::decRefCnt() { - if (--refCnt == 0) - delete this; -} - -void TextPage::startPage(GfxState *state) { - clear(); - if (state) { - pageWidth = state->getPageWidth(); - pageHeight = state->getPageHeight(); - } else { - pageWidth = pageHeight = 0; - } -} - -void TextPage::endPage() { - if (curWord) { - endWord(); - } -} - -void TextPage::clear() { - int rot; - TextFlow *flow; - TextWord *word; - - if (curWord) { - delete curWord; - curWord = NULL; - } - if (rawOrder) { - while (rawWords) { - word = rawWords; - rawWords = rawWords->next; - delete word; - } - } else { - for (rot = 0; rot < 4; ++rot) { - delete pools[rot]; - } - while (flows) { - flow = flows; - flows = flows->next; - delete flow; - } - gfree(blocks); - } - deleteGooList(fonts, TextFontInfo); - deleteGooList(underlines, TextUnderline); - deleteGooList(links, TextLink); - - curWord = NULL; - charPos = 0; - curFont = NULL; - curFontSize = 0; - nest = 0; - nTinyChars = 0; - if (!rawOrder) { - for (rot = 0; rot < 4; ++rot) { - pools[rot] = new TextPool(); - } - } - flows = NULL; - blocks = NULL; - rawWords = NULL; - rawLastWord = NULL; - fonts = new GooList(); - underlines = new GooList(); - links = new GooList(); -} - -void TextPage::updateFont(GfxState *state) { - GfxFont *gfxFont; - double *fm; - char *name; - int code, mCode, letterCode, anyCode; - double w; - int i; - - // get the font info object - curFont = NULL; - for (i = 0; i < fonts->getLength(); ++i) { - curFont = (TextFontInfo *)fonts->get(i); - if (curFont->matches(state)) { - break; - } - curFont = NULL; - } - if (!curFont) { - curFont = new TextFontInfo(state); - fonts->append(curFont); - } - - // adjust the font size - gfxFont = state->getFont(); - curFontSize = state->getTransformedFontSize(); - if (gfxFont && gfxFont->getType() == fontType3) { - // This is a hack which makes it possible to deal with some Type 3 - // fonts. The problem is that it's impossible to know what the - // base coordinate system used in the font is without actually - // rendering the font. This code tries to guess by looking at the - // width of the character 'm' (which breaks if the font is a - // subset that doesn't contain 'm'). - mCode = letterCode = anyCode = -1; - for (code = 0; code < 256; ++code) { - name = ((Gfx8BitFont *)gfxFont)->getCharName(code); - int nameLen = name ? strlen(name) : 0; - GBool nameOneChar = nameLen == 1 || (nameLen > 1 && name[1] == '\0'); - if (nameOneChar && name[0] == 'm') { - mCode = code; - } - if (letterCode < 0 && nameOneChar && - ((name[0] >= 'A' && name[0] <= 'Z') || - (name[0] >= 'a' && name[0] <= 'z'))) { - letterCode = code; - } - if (anyCode < 0 && name && - ((Gfx8BitFont *)gfxFont)->getWidth(code) > 0) { - anyCode = code; - } - } - if (mCode >= 0 && - (w = ((Gfx8BitFont *)gfxFont)->getWidth(mCode)) > 0) { - // 0.6 is a generic average 'm' width -- yes, this is a hack - curFontSize *= w / 0.6; - } else if (letterCode >= 0 && - (w = ((Gfx8BitFont *)gfxFont)->getWidth(letterCode)) > 0) { - // even more of a hack: 0.5 is a generic letter width - curFontSize *= w / 0.5; - } else if (anyCode >= 0 && - (w = ((Gfx8BitFont *)gfxFont)->getWidth(anyCode)) > 0) { - // better than nothing: 0.5 is a generic character width - curFontSize *= w / 0.5; - } - fm = gfxFont->getFontMatrix(); - if (fm[0] != 0) { - curFontSize *= fabs(fm[3] / fm[0]); - } - } -} - -void TextPage::beginWord(GfxState *state) { - GfxFont *gfxFont; - double *fontm; - double m[4], m2[4]; - int rot; - - // This check is needed because Type 3 characters can contain - // text-drawing operations (when TextPage is being used via - // {X,Win}SplashOutputDev rather than TextOutputDev). - if (curWord) { - ++nest; - return; - } - - // compute the rotation - state->getFontTransMat(&m[0], &m[1], &m[2], &m[3]); - gfxFont = state->getFont(); - if (gfxFont && gfxFont->getType() == fontType3) { - fontm = state->getFont()->getFontMatrix(); - m2[0] = fontm[0] * m[0] + fontm[1] * m[2]; - m2[1] = fontm[0] * m[1] + fontm[1] * m[3]; - m2[2] = fontm[2] * m[0] + fontm[3] * m[2]; - m2[3] = fontm[2] * m[1] + fontm[3] * m[3]; - m[0] = m2[0]; - m[1] = m2[1]; - m[2] = m2[2]; - m[3] = m2[3]; - } - if (fabs(m[0] * m[3]) > fabs(m[1] * m[2])) { - rot = (m[0] > 0 || m[3] < 0) ? 0 : 2; - } else { - rot = (m[2] > 0) ? 1 : 3; - } - - // for vertical writing mode, the lines are effectively rotated 90 - // degrees - if (gfxFont && gfxFont->getWMode()) { - rot = (rot + 1) & 3; - } - - curWord = new TextWord(state, rot, curFontSize); -} - -void TextPage::addChar(GfxState *state, double x, double y, - double dx, double dy, - CharCode c, int nBytes, Unicode *u, int uLen) { - double x1, y1, w1, h1, dx2, dy2, base, sp, delta; - GBool overlap; - int i; - int wMode; - Matrix mat; - - // subtract char and word spacing from the dx,dy values - sp = state->getCharSpace(); - if (c == (CharCode)0x20) { - sp += state->getWordSpace(); - } - state->textTransformDelta(sp * state->getHorizScaling(), 0, &dx2, &dy2); - dx -= dx2; - dy -= dy2; - state->transformDelta(dx, dy, &w1, &h1); - - // throw away chars that aren't inside the page bounds - // (and also do a sanity check on the character size) - state->transform(x, y, &x1, &y1); - if (x1 + w1 < 0 || x1 > pageWidth || - y1 + h1 < 0 || y1 > pageHeight || - x1 != x1 || y1 != y1 || // IEEE way of checking for isnan - w1 != w1 || h1 != h1) { - charPos += nBytes; - return; - } - - // check the tiny chars limit - if (!globalParams->getTextKeepTinyChars() && - fabs(w1) < 3 && fabs(h1) < 3) { - if (++nTinyChars > 50000) { - charPos += nBytes; - return; - } - } - - // break words at space character - if (uLen == 1 && u[0] == (Unicode)0x20) { - charPos += nBytes; - endWord(); - return; - } - - // start a new word if: - // (1) this character doesn't fall in the right place relative to - // the end of the previous word (this places upper and lower - // constraints on the position deltas along both the primary - // and secondary axes), or - // (2) this character overlaps the previous one (duplicated text), or - // (3) the previous character was an overlap (we want each duplicated - // character to be in a word by itself at this stage), - // (4) the font size has changed - // (5) the WMode changed - if (curWord && curWord->len > 0) { - base = sp = delta = 0; // make gcc happy - switch (curWord->rot) { - case 0: - base = y1; - sp = x1 - curWord->xMax; - delta = x1 - curWord->edge[curWord->len - 1]; - break; - case 1: - base = x1; - sp = y1 - curWord->yMax; - delta = y1 - curWord->edge[curWord->len - 1]; - break; - case 2: - base = y1; - sp = curWord->xMin - x1; - delta = curWord->edge[curWord->len - 1] - x1; - break; - case 3: - base = x1; - sp = curWord->yMin - y1; - delta = curWord->edge[curWord->len - 1] - y1; - break; - } - overlap = fabs(delta) < dupMaxPriDelta * curWord->fontSize && - fabs(base - curWord->base) < dupMaxSecDelta * curWord->fontSize; - wMode = curFont->gfxFont ? curFont->gfxFont->getWMode() : 0; - if (overlap || lastCharOverlap || - sp < -minDupBreakOverlap * curWord->fontSize || - sp > minWordBreakSpace * curWord->fontSize || - fabs(base - curWord->base) > 0.5 || - curFontSize != curWord->fontSize || - wMode != curWord->wMode) { - endWord(); - } - lastCharOverlap = overlap; - } else { - lastCharOverlap = gFalse; - } - - if (uLen != 0) { - // start a new word if needed - if (!curWord) { - beginWord(state); - } - - state->getFontTransMat(&mat.m[0], &mat.m[1], &mat.m[2], &mat.m[3]); - mat.m[4] = x1; - mat.m[5] = y1; - - // page rotation and/or transform matrices can cause text to be - // drawn in reverse order -- in this case, swap the begin/end - // coordinates and break text into individual chars - if ((curWord->rot == 0 && w1 < 0) || - (curWord->rot == 1 && h1 < 0) || - (curWord->rot == 2 && w1 > 0) || - (curWord->rot == 3 && h1 > 0)) { - endWord(); - beginWord(state); - x1 += w1; - y1 += h1; - w1 = -w1; - h1 = -h1; - } - - // add the characters to the current word - w1 /= uLen; - h1 /= uLen; - for (i = 0; i < uLen; ++i) { - curWord->addChar(state, curFont, x1 + i*w1, y1 + i*h1, w1, h1, charPos, nBytes, c, u[i], mat); - } - } - charPos += nBytes; -} - -void TextPage::incCharCount(int nChars) { - charPos += nChars; -} - -void TextPage::endWord() { - // This check is needed because Type 3 characters can contain - // text-drawing operations (when TextPage is being used via - // {X,Win}SplashOutputDev rather than TextOutputDev). - if (nest > 0) { - --nest; - return; - } - - if (curWord) { - addWord(curWord); - curWord = NULL; - } -} - -void TextPage::addWord(TextWord *word) { - // throw away zero-length words -- they don't have valid xMin/xMax - // values, and they're useless anyway - if (word->len == 0) { - delete word; - return; - } - - if (rawOrder) { - if (rawLastWord) { - rawLastWord->next = word; - } else { - rawWords = word; - } - rawLastWord = word; - } else { - pools[word->rot]->addWord(word); - } -} - -void TextPage::addUnderline(double x0, double y0, double x1, double y1) { - underlines->append(new TextUnderline(x0, y0, x1, y1)); -} - -void TextPage::addLink(int xMin, int yMin, int xMax, int yMax, AnnotLink *link) { - links->append(new TextLink(xMin, yMin, xMax, yMax, link)); -} - -void TextPage::coalesce(GBool physLayout, double fixedPitch, GBool doHTML) { - UnicodeMap *uMap; - TextPool *pool; - TextWord *word0, *word1, *word2; - TextLine *line; - TextBlock *blkList, *blk, *lastBlk, *blk0, *blk1, *blk2; - TextFlow *flow, *lastFlow; - TextUnderline *underline; - TextLink *link; - int rot, poolMinBaseIdx, baseIdx, startBaseIdx, endBaseIdx; - double minBase, maxBase, newMinBase, newMaxBase; - double fontSize, colSpace1, colSpace2, lineSpace, intraLineSpace, blkSpace; - GBool found; - int count[4]; - int lrCount; - int col1, col2; - int i, j, n; - - if (rawOrder) { - primaryRot = 0; - primaryLR = gTrue; - return; - } - - uMap = globalParams->getTextEncoding(); - blkList = NULL; - lastBlk = NULL; - nBlocks = 0; - primaryRot = 0; - -#if 0 // for debugging - printf("*** initial words ***\n"); - for (rot = 0; rot < 4; ++rot) { - pool = pools[rot]; - for (baseIdx = pool->minBaseIdx; baseIdx <= pool->maxBaseIdx; ++baseIdx) { - for (word0 = pool->getPool(baseIdx); word0; word0 = word0->next) { - printf(" word: x=%.2f..%.2f y=%.2f..%.2f base=%.2f fontSize=%.2f rot=%d link=%p '", - word0->xMin, word0->xMax, word0->yMin, word0->yMax, - word0->base, word0->fontSize, rot*90, word0->link); - for (i = 0; i < word0->len; ++i) { - fputc(word0->text[i] & 0xff, stdout); - } - printf("'\n"); - } - } - } - printf("\n"); -#endif - -#if 0 //~ for debugging - for (i = 0; i < underlines->getLength(); ++i) { - underline = (TextUnderline *)underlines->get(i); - printf("underline: x=%g..%g y=%g..%g horiz=%d\n", - underline->x0, underline->x1, underline->y0, underline->y1, - underline->horiz); - } -#endif - - if (doHTML) { - - //----- handle underlining - for (i = 0; i < underlines->getLength(); ++i) { - underline = (TextUnderline *)underlines->get(i); - if (underline->horiz) { - // rot = 0 - if (pools[0]->minBaseIdx <= pools[0]->maxBaseIdx) { - startBaseIdx = pools[0]->getBaseIdx(underline->y0 + minUnderlineGap); - endBaseIdx = pools[0]->getBaseIdx(underline->y0 + maxUnderlineGap); - for (j = startBaseIdx; j <= endBaseIdx; ++j) { - for (word0 = pools[0]->getPool(j); word0; word0 = word0->next) { - //~ need to check the y value against the word baseline - if (underline->x0 < word0->xMin + underlineSlack && - word0->xMax - underlineSlack < underline->x1) { - word0->underlined = gTrue; - } - } - } - } - - // rot = 2 - if (pools[2]->minBaseIdx <= pools[2]->maxBaseIdx) { - startBaseIdx = pools[2]->getBaseIdx(underline->y0 - maxUnderlineGap); - endBaseIdx = pools[2]->getBaseIdx(underline->y0 - minUnderlineGap); - for (j = startBaseIdx; j <= endBaseIdx; ++j) { - for (word0 = pools[2]->getPool(j); word0; word0 = word0->next) { - if (underline->x0 < word0->xMin + underlineSlack && - word0->xMax - underlineSlack < underline->x1) { - word0->underlined = gTrue; - } - } - } - } - } else { - // rot = 1 - if (pools[1]->minBaseIdx <= pools[1]->maxBaseIdx) { - startBaseIdx = pools[1]->getBaseIdx(underline->x0 - maxUnderlineGap); - endBaseIdx = pools[1]->getBaseIdx(underline->x0 - minUnderlineGap); - for (j = startBaseIdx; j <= endBaseIdx; ++j) { - for (word0 = pools[1]->getPool(j); word0; word0 = word0->next) { - if (underline->y0 < word0->yMin + underlineSlack && - word0->yMax - underlineSlack < underline->y1) { - word0->underlined = gTrue; - } - } - } - } - - // rot = 3 - if (pools[3]->minBaseIdx <= pools[3]->maxBaseIdx) { - startBaseIdx = pools[3]->getBaseIdx(underline->x0 + minUnderlineGap); - endBaseIdx = pools[3]->getBaseIdx(underline->x0 + maxUnderlineGap); - for (j = startBaseIdx; j <= endBaseIdx; ++j) { - for (word0 = pools[3]->getPool(j); word0; word0 = word0->next) { - if (underline->y0 < word0->yMin + underlineSlack && - word0->yMax - underlineSlack < underline->y1) { - word0->underlined = gTrue; - } - } - } - } - } - } - - //----- handle links - for (i = 0; i < links->getLength(); ++i) { - link = (TextLink *)links->get(i); - - // rot = 0 - if (pools[0]->minBaseIdx <= pools[0]->maxBaseIdx) { - startBaseIdx = pools[0]->getBaseIdx(link->yMin); - endBaseIdx = pools[0]->getBaseIdx(link->yMax); - for (j = startBaseIdx; j <= endBaseIdx; ++j) { - for (word0 = pools[0]->getPool(j); word0; word0 = word0->next) { - if (link->xMin < word0->xMin + hyperlinkSlack && - word0->xMax - hyperlinkSlack < link->xMax && - link->yMin < word0->yMin + hyperlinkSlack && - word0->yMax - hyperlinkSlack < link->yMax) { - word0->link = link->link; - } - } - } - } - - // rot = 2 - if (pools[2]->minBaseIdx <= pools[2]->maxBaseIdx) { - startBaseIdx = pools[2]->getBaseIdx(link->yMin); - endBaseIdx = pools[2]->getBaseIdx(link->yMax); - for (j = startBaseIdx; j <= endBaseIdx; ++j) { - for (word0 = pools[2]->getPool(j); word0; word0 = word0->next) { - if (link->xMin < word0->xMin + hyperlinkSlack && - word0->xMax - hyperlinkSlack < link->xMax && - link->yMin < word0->yMin + hyperlinkSlack && - word0->yMax - hyperlinkSlack < link->yMax) { - word0->link = link->link; - } - } - } - } - - // rot = 1 - if (pools[1]->minBaseIdx <= pools[1]->maxBaseIdx) { - startBaseIdx = pools[1]->getBaseIdx(link->xMin); - endBaseIdx = pools[1]->getBaseIdx(link->xMax); - for (j = startBaseIdx; j <= endBaseIdx; ++j) { - for (word0 = pools[1]->getPool(j); word0; word0 = word0->next) { - if (link->yMin < word0->yMin + hyperlinkSlack && - word0->yMax - hyperlinkSlack < link->yMax && - link->xMin < word0->xMin + hyperlinkSlack && - word0->xMax - hyperlinkSlack < link->xMax) { - word0->link = link->link; - } - } - } - } - - // rot = 3 - if (pools[3]->minBaseIdx <= pools[3]->maxBaseIdx) { - startBaseIdx = pools[3]->getBaseIdx(link->xMin); - endBaseIdx = pools[3]->getBaseIdx(link->xMax); - for (j = startBaseIdx; j <= endBaseIdx; ++j) { - for (word0 = pools[3]->getPool(j); word0; word0 = word0->next) { - if (link->yMin < word0->yMin + hyperlinkSlack && - word0->yMax - hyperlinkSlack < link->yMax && - link->xMin < word0->xMin + hyperlinkSlack && - word0->xMax - hyperlinkSlack < link->xMax) { - word0->link = link->link; - } - } - } - } - } - } - - //----- assemble the blocks - - //~ add an outer loop for writing mode (vertical text) - - // build blocks for each rotation value - for (rot = 0; rot < 4; ++rot) { - pool = pools[rot]; - poolMinBaseIdx = pool->minBaseIdx; - count[rot] = 0; - - // add blocks until no more words are left - while (1) { - - // find the first non-empty line in the pool - for (; - poolMinBaseIdx <= pool->maxBaseIdx && - !pool->getPool(poolMinBaseIdx); - ++poolMinBaseIdx) ; - if (poolMinBaseIdx > pool->maxBaseIdx) { - break; - } - - // look for the left-most word in the first four lines of the - // pool -- this avoids starting with a superscript word - startBaseIdx = poolMinBaseIdx; - for (baseIdx = poolMinBaseIdx + 1; - baseIdx < poolMinBaseIdx + 4 && baseIdx <= pool->maxBaseIdx; - ++baseIdx) { - if (!pool->getPool(baseIdx)) { - continue; - } - if (pool->getPool(baseIdx)->primaryCmp(pool->getPool(startBaseIdx)) - < 0) { - startBaseIdx = baseIdx; - } - } - - // create a new block - word0 = pool->getPool(startBaseIdx); - pool->setPool(startBaseIdx, word0->next); - word0->next = NULL; - blk = new TextBlock(this, rot); - blk->addWord(word0); - - fontSize = word0->fontSize; - minBase = maxBase = word0->base; - colSpace1 = minColSpacing1 * fontSize; - colSpace2 = minColSpacing2 * fontSize; - lineSpace = maxLineSpacingDelta * fontSize; - intraLineSpace = maxIntraLineDelta * fontSize; - - // add words to the block - do { - found = gFalse; - - // look for words on the line above the current top edge of - // the block - newMinBase = minBase; - for (baseIdx = pool->getBaseIdx(minBase); - baseIdx >= pool->getBaseIdx(minBase - lineSpace); - --baseIdx) { - word0 = NULL; - word1 = pool->getPool(baseIdx); - while (word1) { - if (word1->base < minBase && - word1->base >= minBase - lineSpace && - ((rot == 0 || rot == 2) - ? (word1->xMin < blk->xMax && word1->xMax > blk->xMin) - : (word1->yMin < blk->yMax && word1->yMax > blk->yMin)) && - fabs(word1->fontSize - fontSize) < - maxBlockFontSizeDelta1 * fontSize) { - word2 = word1; - if (word0) { - word0->next = word1->next; - } else { - pool->setPool(baseIdx, word1->next); - } - word1 = word1->next; - word2->next = NULL; - blk->addWord(word2); - found = gTrue; - newMinBase = word2->base; - } else { - word0 = word1; - word1 = word1->next; - } - } - } - minBase = newMinBase; - - // look for words on the line below the current bottom edge of - // the block - newMaxBase = maxBase; - for (baseIdx = pool->getBaseIdx(maxBase); - baseIdx <= pool->getBaseIdx(maxBase + lineSpace); - ++baseIdx) { - word0 = NULL; - word1 = pool->getPool(baseIdx); - while (word1) { - if (word1->base > maxBase && - word1->base <= maxBase + lineSpace && - ((rot == 0 || rot == 2) - ? (word1->xMin < blk->xMax && word1->xMax > blk->xMin) - : (word1->yMin < blk->yMax && word1->yMax > blk->yMin)) && - fabs(word1->fontSize - fontSize) < - maxBlockFontSizeDelta1 * fontSize) { - word2 = word1; - if (word0) { - word0->next = word1->next; - } else { - pool->setPool(baseIdx, word1->next); - } - word1 = word1->next; - word2->next = NULL; - blk->addWord(word2); - found = gTrue; - newMaxBase = word2->base; - } else { - word0 = word1; - word1 = word1->next; - } - } - } - maxBase = newMaxBase; - - // look for words that are on lines already in the block, and - // that overlap the block horizontally - for (baseIdx = pool->getBaseIdx(minBase - intraLineSpace); - baseIdx <= pool->getBaseIdx(maxBase + intraLineSpace); - ++baseIdx) { - word0 = NULL; - word1 = pool->getPool(baseIdx); - while (word1) { - if (word1->base >= minBase - intraLineSpace && - word1->base <= maxBase + intraLineSpace && - ((rot == 0 || rot == 2) - ? (word1->xMin < blk->xMax + colSpace1 && - word1->xMax > blk->xMin - colSpace1) - : (word1->yMin < blk->yMax + colSpace1 && - word1->yMax > blk->yMin - colSpace1)) && - fabs(word1->fontSize - fontSize) < - maxBlockFontSizeDelta2 * fontSize) { - word2 = word1; - if (word0) { - word0->next = word1->next; - } else { - pool->setPool(baseIdx, word1->next); - } - word1 = word1->next; - word2->next = NULL; - blk->addWord(word2); - found = gTrue; - } else { - word0 = word1; - word1 = word1->next; - } - } - } - - // only check for outlying words (the next two chunks of code) - // if we didn't find anything else - if (found) { - continue; - } - - // scan down the left side of the block, looking for words - // that are near (but not overlapping) the block; if there are - // three or fewer, add them to the block - n = 0; - for (baseIdx = pool->getBaseIdx(minBase - intraLineSpace); - baseIdx <= pool->getBaseIdx(maxBase + intraLineSpace); - ++baseIdx) { - word1 = pool->getPool(baseIdx); - while (word1) { - if (word1->base >= minBase - intraLineSpace && - word1->base <= maxBase + intraLineSpace && - ((rot == 0 || rot == 2) - ? (word1->xMax <= blk->xMin && - word1->xMax > blk->xMin - colSpace2) - : (word1->yMax <= blk->yMin && - word1->yMax > blk->yMin - colSpace2)) && - fabs(word1->fontSize - fontSize) < - maxBlockFontSizeDelta3 * fontSize) { - ++n; - break; - } - word1 = word1->next; - } - } - if (n > 0 && n <= 3) { - for (baseIdx = pool->getBaseIdx(minBase - intraLineSpace); - baseIdx <= pool->getBaseIdx(maxBase + intraLineSpace); - ++baseIdx) { - word0 = NULL; - word1 = pool->getPool(baseIdx); - while (word1) { - if (word1->base >= minBase - intraLineSpace && - word1->base <= maxBase + intraLineSpace && - ((rot == 0 || rot == 2) - ? (word1->xMax <= blk->xMin && - word1->xMax > blk->xMin - colSpace2) - : (word1->yMax <= blk->yMin && - word1->yMax > blk->yMin - colSpace2)) && - fabs(word1->fontSize - fontSize) < - maxBlockFontSizeDelta3 * fontSize) { - word2 = word1; - if (word0) { - word0->next = word1->next; - } else { - pool->setPool(baseIdx, word1->next); - } - word1 = word1->next; - word2->next = NULL; - blk->addWord(word2); - if (word2->base < minBase) { - minBase = word2->base; - } else if (word2->base > maxBase) { - maxBase = word2->base; - } - found = gTrue; - break; - } else { - word0 = word1; - word1 = word1->next; - } - } - } - } - - // scan down the right side of the block, looking for words - // that are near (but not overlapping) the block; if there are - // three or fewer, add them to the block - n = 0; - for (baseIdx = pool->getBaseIdx(minBase - intraLineSpace); - baseIdx <= pool->getBaseIdx(maxBase + intraLineSpace); - ++baseIdx) { - word1 = pool->getPool(baseIdx); - while (word1) { - if (word1->base >= minBase - intraLineSpace && - word1->base <= maxBase + intraLineSpace && - ((rot == 0 || rot == 2) - ? (word1->xMin >= blk->xMax && - word1->xMin < blk->xMax + colSpace2) - : (word1->yMin >= blk->yMax && - word1->yMin < blk->yMax + colSpace2)) && - fabs(word1->fontSize - fontSize) < - maxBlockFontSizeDelta3 * fontSize) { - ++n; - break; - } - word1 = word1->next; - } - } - if (n > 0 && n <= 3) { - for (baseIdx = pool->getBaseIdx(minBase - intraLineSpace); - baseIdx <= pool->getBaseIdx(maxBase + intraLineSpace); - ++baseIdx) { - word0 = NULL; - word1 = pool->getPool(baseIdx); - while (word1) { - if (word1->base >= minBase - intraLineSpace && - word1->base <= maxBase + intraLineSpace && - ((rot == 0 || rot == 2) - ? (word1->xMin >= blk->xMax && - word1->xMin < blk->xMax + colSpace2) - : (word1->yMin >= blk->yMax && - word1->yMin < blk->yMax + colSpace2)) && - fabs(word1->fontSize - fontSize) < - maxBlockFontSizeDelta3 * fontSize) { - word2 = word1; - if (word0) { - word0->next = word1->next; - } else { - pool->setPool(baseIdx, word1->next); - } - word1 = word1->next; - word2->next = NULL; - blk->addWord(word2); - if (word2->base < minBase) { - minBase = word2->base; - } else if (word2->base > maxBase) { - maxBase = word2->base; - } - found = gTrue; - break; - } else { - word0 = word1; - word1 = word1->next; - } - } - } - } - - } while (found); - - //~ need to compute the primary writing mode (horiz/vert) in - //~ addition to primary rotation - - // coalesce the block, and add it to the list - blk->coalesce(uMap, fixedPitch); - if (lastBlk) { - lastBlk->next = blk; - } else { - blkList = blk; - } - lastBlk = blk; - count[rot] += blk->charCount; - ++nBlocks; - } - - if (count[rot] > count[primaryRot]) { - primaryRot = rot; - } - } - -#if 0 // for debugging - printf("*** rotation ***\n"); - for (rot = 0; rot < 4; ++rot) { - printf(" %d: %6d\n", rot, count[rot]); - } - printf(" primary rot = %d\n", primaryRot); - printf("\n"); -#endif - -#if 0 // for debugging - printf("*** blocks ***\n"); - for (blk = blkList; blk; blk = blk->next) { - printf("block: rot=%d x=%.2f..%.2f y=%.2f..%.2f\n", - blk->rot, blk->xMin, blk->xMax, blk->yMin, blk->yMax); - for (line = blk->lines; line; line = line->next) { - printf(" line: x=%.2f..%.2f y=%.2f..%.2f base=%.2f\n", - line->xMin, line->xMax, line->yMin, line->yMax, line->base); - for (word0 = line->words; word0; word0 = word0->next) { - printf(" word: x=%.2f..%.2f y=%.2f..%.2f base=%.2f fontSize=%.2f space=%d: '", - word0->xMin, word0->xMax, word0->yMin, word0->yMax, - word0->base, word0->fontSize, word0->spaceAfter); - for (i = 0; i < word0->len; ++i) { - fputc(word0->text[i] & 0xff, stdout); - } - printf("'\n"); - } - } - } - printf("\n"); -#endif - - // determine the primary direction - lrCount = 0; - for (blk = blkList; blk; blk = blk->next) { - for (line = blk->lines; line; line = line->next) { - for (word0 = line->words; word0; word0 = word0->next) { - for (i = 0; i < word0->len; ++i) { - if (unicodeTypeL(word0->text[i])) { - ++lrCount; - } else if (unicodeTypeR(word0->text[i])) { - --lrCount; - } - } - } - } - } - primaryLR = lrCount >= 0; - -#if 0 // for debugging - printf("*** direction ***\n"); - printf("lrCount = %d\n", lrCount); - printf("primaryLR = %d\n", primaryLR); -#endif - - //----- column assignment - - // sort blocks into xy order for column assignment - if (blocks) - gfree (blocks); - if (physLayout && fixedPitch) { - - blocks = (TextBlock **)gmallocn(nBlocks, sizeof(TextBlock *)); - for (blk = blkList, i = 0; blk; blk = blk->next, ++i) { - blocks[i] = blk; - col1 = 0; // make gcc happy - switch (primaryRot) { - case 0: - col1 = (int)(blk->xMin / fixedPitch + 0.5); - break; - case 1: - col1 = (int)(blk->yMin / fixedPitch + 0.5); - break; - case 2: - col1 = (int)((pageWidth - blk->xMax) / fixedPitch + 0.5); - break; - case 3: - col1 = (int)((pageHeight - blk->yMax) / fixedPitch + 0.5); - break; - } - blk->col = col1; - for (line = blk->lines; line; line = line->next) { - for (j = 0; j <= line->len; ++j) { - line->col[j] += col1; - } - } - } - - } else { - - // sort blocks into xy order for column assignment - blocks = (TextBlock **)gmallocn(nBlocks, sizeof(TextBlock *)); - for (blk = blkList, i = 0; blk; blk = blk->next, ++i) { - blocks[i] = blk; - } - qsort(blocks, nBlocks, sizeof(TextBlock *), &TextBlock::cmpXYPrimaryRot); - - // column assignment - for (i = 0; i < nBlocks; ++i) { - blk0 = blocks[i]; - col1 = 0; - for (j = 0; j < i; ++j) { - blk1 = blocks[j]; - col2 = 0; // make gcc happy - switch (primaryRot) { - case 0: - if (blk0->xMin > blk1->xMax) { - col2 = blk1->col + blk1->nColumns + 3; - } else if (blk1->xMax == blk1->xMin) { - col2 = blk1->col; - } else { - col2 = blk1->col + (int)(((blk0->xMin - blk1->xMin) / - (blk1->xMax - blk1->xMin)) * - blk1->nColumns); - } - break; - case 1: - if (blk0->yMin > blk1->yMax) { - col2 = blk1->col + blk1->nColumns + 3; - } else if (blk1->yMax == blk1->yMin) { - col2 = blk1->col; - } else { - col2 = blk1->col + (int)(((blk0->yMin - blk1->yMin) / - (blk1->yMax - blk1->yMin)) * - blk1->nColumns); - } - break; - case 2: - if (blk0->xMax < blk1->xMin) { - col2 = blk1->col + blk1->nColumns + 3; - } else if (blk1->xMin == blk1->xMax) { - col2 = blk1->col; - } else { - col2 = blk1->col + (int)(((blk0->xMax - blk1->xMax) / - (blk1->xMin - blk1->xMax)) * - blk1->nColumns); - } - break; - case 3: - if (blk0->yMax < blk1->yMin) { - col2 = blk1->col + blk1->nColumns + 3; - } else if (blk1->yMin == blk1->yMax) { - col2 = blk1->col; - } else { - col2 = blk1->col + (int)(((blk0->yMax - blk1->yMax) / - (blk1->yMin - blk1->yMax)) * - blk1->nColumns); - } - break; - } - if (col2 > col1) { - col1 = col2; - } - } - blk0->col = col1; - for (line = blk0->lines; line; line = line->next) { - for (j = 0; j <= line->len; ++j) { - line->col[j] += col1; - } - } - } - - } - -#if 0 // for debugging - printf("*** blocks, after column assignment ***\n"); - for (blk = blkList; blk; blk = blk->next) { - printf("block: rot=%d x=%.2f..%.2f y=%.2f..%.2f col=%d nCols=%d\n", - blk->rot, blk->xMin, blk->xMax, blk->yMin, blk->yMax, blk->col, - blk->nColumns); - for (line = blk->lines; line; line = line->next) { - printf(" line: col[0]=%d\n", line->col[0]); - for (word0 = line->words; word0; word0 = word0->next) { - printf(" word: x=%.2f..%.2f y=%.2f..%.2f base=%.2f fontSize=%.2f space=%d: '", - word0->xMin, word0->xMax, word0->yMin, word0->yMax, - word0->base, word0->fontSize, word0->spaceAfter); - for (i = 0; i < word0->len; ++i) { - fputc(word0->text[i] & 0xff, stdout); - } - printf("'\n"); - } - } - } - printf("\n"); -#endif - - //----- reading order sort - - // compute space on left and right sides of each block - for (i = 0; i < nBlocks; ++i) { - blk0 = blocks[i]; - for (j = 0; j < nBlocks; ++j) { - blk1 = blocks[j]; - if (blk1 != blk0) { - blk0->updatePriMinMax(blk1); - } - } - } - -#if 0 // for debugging - printf("PAGE\n"); -#endif - - int sortPos = 0; - GBool *visited = (GBool *)gmallocn(nBlocks, sizeof(GBool)); - for (i = 0; i < nBlocks; i++) { - visited[i] = gFalse; - } - - double bxMin0, byMin0, bxMin1, byMin1; - int numTables = 0; - int tableId = -1; - int correspondenceX, correspondenceY; - double xCentre1, yCentre1, xCentre2, yCentre2; - double xCentre3, yCentre3, xCentre4, yCentre4; - double deltaX, deltaY; - TextBlock *fblk2 = NULL, *fblk3 = NULL, *fblk4 = NULL; - - for (blk1 = blkList; blk1; blk1 = blk1->next) { - blk1->ExMin = blk1->xMin; - blk1->ExMax = blk1->xMax; - blk1->EyMin = blk1->yMin; - blk1->EyMax = blk1->yMax; - - bxMin0 = DBL_MAX; - byMin0 = DBL_MAX; - bxMin1 = DBL_MAX; - byMin1 = DBL_MAX; - - fblk2 = NULL; - fblk3 = NULL; - fblk4 = NULL; - - /* find fblk2, fblk3 and fblk4 so that - * fblk2 is on the right of blk1 and overlap with blk1 in y axis - * fblk3 is under blk1 and overlap with blk1 in x axis - * fblk4 is under blk1 and on the right of blk1 - * and they are closest to blk1 - */ - for (blk2 = blkList; blk2; blk2 = blk2->next) { - if (blk2 != blk1) { - if (blk2->yMin <= blk1->yMax && - blk2->yMax >= blk1->yMin && - blk2->xMin > blk1->xMax && - blk2->xMin < bxMin0) { - bxMin0 = blk2->xMin; - fblk2 = blk2; - } else if (blk2->xMin <= blk1->xMax && - blk2->xMax >= blk1->xMin && - blk2->yMin > blk1->yMax && - blk2->yMin < byMin0) { - byMin0 = blk2->yMin; - fblk3 = blk2; - } else if (blk2->xMin > blk1->xMax && - blk2->xMin < bxMin1 && - blk2->yMin > blk1->yMax && - blk2->yMin < byMin1) { - bxMin1 = blk2->xMin; - byMin1 = blk2->yMin; - fblk4 = blk2; - } - } - } - - /* fblk4 can not overlap with fblk3 in x and with fblk2 in y - * fblk2 can not overlap with fblk3 in x and y - * fblk4 has to overlap with fblk3 in y and with fblk2 in x - */ - if (fblk2 != NULL && - fblk3 != NULL && - fblk4 != NULL) { - if (((fblk3->xMin <= fblk4->xMax && fblk3->xMax >= fblk4->xMin) || - (fblk2->yMin <= fblk4->yMax && fblk2->yMax >= fblk4->yMin) || - (fblk2->xMin <= fblk3->xMax && fblk2->xMax >= fblk3->xMin) || - (fblk2->yMin <= fblk3->yMax && fblk2->yMax >= fblk3->yMin)) || - !(fblk4->xMin <= fblk2->xMax && fblk4->xMax >= fblk2->xMin && - fblk4->yMin <= fblk3->yMax && fblk4->yMax >= fblk3->yMin)) { - fblk2 = NULL; - fblk3 = NULL; - fblk4 = NULL; - } - } - - // if we found any then look whether they form a table - if (fblk2 != NULL && - fblk3 != NULL && - fblk4 != NULL) { - tableId = -1; - correspondenceX = 0; - correspondenceY = 0; - deltaX = 0.0; - deltaY = 0.0; - - if (blk1->lines && blk1->lines->words) - deltaX = blk1->lines->words->getFontSize(); - if (fblk2->lines && fblk2->lines->words) - deltaX = deltaX < fblk2->lines->words->getFontSize() ? - deltaX : fblk2->lines->words->getFontSize(); - if (fblk3->lines && fblk3->lines->words) - deltaX = deltaX < fblk3->lines->words->getFontSize() ? - deltaX : fblk3->lines->words->getFontSize(); - if (fblk4->lines && fblk4->lines->words) - deltaX = deltaX < fblk4->lines->words->getFontSize() ? - deltaX : fblk4->lines->words->getFontSize(); - - deltaY = deltaX; - - deltaX *= minColSpacing1; - deltaY *= maxIntraLineDelta; - - xCentre1 = (blk1->xMax + blk1->xMin) / 2.0; - yCentre1 = (blk1->yMax + blk1->yMin) / 2.0; - xCentre2 = (fblk2->xMax + fblk2->xMin) / 2.0; - yCentre2 = (fblk2->yMax + fblk2->yMin) / 2.0; - xCentre3 = (fblk3->xMax + fblk3->xMin) / 2.0; - yCentre3 = (fblk3->yMax + fblk3->yMin) / 2.0; - xCentre4 = (fblk4->xMax + fblk4->xMin) / 2.0; - yCentre4 = (fblk4->yMax + fblk4->yMin) / 2.0; - - // are blocks centrally aligned in x ? - if (fabs (xCentre1 - xCentre3) <= deltaX && - fabs (xCentre2 - xCentre4) <= deltaX) - correspondenceX++; - - // are blocks centrally aligned in y ? - if (fabs (yCentre1 - yCentre2) <= deltaY && - fabs (yCentre3 - yCentre4) <= deltaY) - correspondenceY++; - - // are blocks aligned to the left ? - if (fabs (blk1->xMin - fblk3->xMin) <= deltaX && - fabs (fblk2->xMin - fblk4->xMin) <= deltaX) - correspondenceX++; - - // are blocks aligned to the right ? - if (fabs (blk1->xMax - fblk3->xMax) <= deltaX && - fabs (fblk2->xMax - fblk4->xMax) <= deltaX) - correspondenceX++; - - // are blocks aligned to the top ? - if (fabs (blk1->yMin - fblk2->yMin) <= deltaY && - fabs (fblk3->yMin - fblk4->yMin) <= deltaY) - correspondenceY++; - - // are blocks aligned to the bottom ? - if (fabs (blk1->yMax - fblk2->yMax) <= deltaY && - fabs (fblk3->yMax - fblk4->yMax) <= deltaY) - correspondenceY++; - - // are blocks aligned in x and y ? - if (correspondenceX > 0 && - correspondenceY > 0) { - - // find maximal tableId - tableId = tableId < fblk4->tableId ? fblk4->tableId : tableId; - tableId = tableId < fblk3->tableId ? fblk3->tableId : tableId; - tableId = tableId < fblk2->tableId ? fblk2->tableId : tableId; - tableId = tableId < blk1->tableId ? blk1->tableId : tableId; - - // if the tableId is -1, then we found new table - if (tableId < 0) { - tableId = numTables; - numTables++; - } - - blk1->tableId = tableId; - fblk2->tableId = tableId; - fblk3->tableId = tableId; - fblk4->tableId = tableId; - } - } - } - - /* set extended bounding boxes of all table entries - * so that they contain whole table - * (we need to process whole table size when comparing it - * with regular text blocks) - */ - PDFRectangle *envelopes = new PDFRectangle [numTables]; - TextBlock **ending_blocks = new TextBlock* [numTables]; - - for (i = 0; i < numTables; i++) { - envelopes[i].x1 = DBL_MAX; - envelopes[i].x2 = DBL_MIN; - envelopes[i].y1 = DBL_MAX; - envelopes[i].y2 = DBL_MIN; - } - - for (blk1 = blkList; blk1; blk1 = blk1->next) { - if (blk1->tableId >= 0) { - if (blk1->ExMin < envelopes[blk1->tableId].x1) { - envelopes[blk1->tableId].x1 = blk1->ExMin; - if (!blk1->page->primaryLR) - ending_blocks[blk1->tableId] = blk1; - } - - if (blk1->ExMax > envelopes[blk1->tableId].x2) { - envelopes[blk1->tableId].x2 = blk1->ExMax; - if (blk1->page->primaryLR) - ending_blocks[blk1->tableId] = blk1; - } - - envelopes[blk1->tableId].y1 = blk1->EyMin < envelopes[blk1->tableId].y1 ? - blk1->EyMin : envelopes[blk1->tableId].y1; - envelopes[blk1->tableId].y2 = blk1->EyMax > envelopes[blk1->tableId].y2 ? - blk1->EyMax : envelopes[blk1->tableId].y2; - } - } - - for (blk1 = blkList; blk1; blk1 = blk1->next) { - if (blk1->tableId >= 0 && - blk1->xMin <= ending_blocks[blk1->tableId]->xMax && - blk1->xMax >= ending_blocks[blk1->tableId]->xMin) { - blk1->tableEnd = gTrue; - } - } - - for (blk1 = blkList; blk1; blk1 = blk1->next) { - if (blk1->tableId >= 0) { - blk1->ExMin = envelopes[blk1->tableId].x1; - blk1->ExMax = envelopes[blk1->tableId].x2; - blk1->EyMin = envelopes[blk1->tableId].y1; - blk1->EyMax = envelopes[blk1->tableId].y2; - } - } - delete[] envelopes; - delete[] ending_blocks; - - - /* set extended bounding boxes of all other blocks - * so that they extend in x without hitting neighbours - */ - for (blk1 = blkList; blk1; blk1 = blk1->next) { - if (!(blk1->tableId >= 0)) { - double xMax = DBL_MAX; - double xMin = DBL_MIN; - - for (blk2 = blkList; blk2; blk2 = blk2->next) { - if (blk2 == blk1) - continue; - - if (blk1->yMin <= blk2->yMax && blk1->yMax >= blk2->yMin) { - if (blk2->xMin < xMax && blk2->xMin > blk1->xMax) - xMax = blk2->xMin; - - if (blk2->xMax > xMin && blk2->xMax < blk1->xMin) - xMin = blk2->xMax; - } - } - - for (blk2 = blkList; blk2; blk2 = blk2->next) { - if (blk2 == blk1) - continue; - - if (blk2->xMax > blk1->ExMax && - blk2->xMax <= xMax && - blk2->yMin >= blk1->yMax) { - blk1->ExMax = blk2->xMax; - } - - if (blk2->xMin < blk1->ExMin && - blk2->xMin >= xMin && - blk2->yMin >= blk1->yMax) - blk1->ExMin = blk2->xMin; - } - } - } - - i = -1; - for (blk1 = blkList; blk1; blk1 = blk1->next) { - i++; - sortPos = blk1->visitDepthFirst(blkList, i, blocks, sortPos, visited); - } - if (visited) { - gfree(visited); - } - -#if 0 // for debugging - printf("*** blocks, after ro sort ***\n"); - for (i = 0; i < nBlocks; ++i) { - blk = blocks[i]; - printf("block: rot=%d x=%.2f..%.2f y=%.2f..%.2f space=%.2f..%.2f\n", - blk->rot, blk->xMin, blk->xMax, blk->yMin, blk->yMax, - blk->priMin, blk->priMax); - for (line = blk->lines; line; line = line->next) { - printf(" line:\n"); - for (word0 = line->words; word0; word0 = word0->next) { - printf(" word: x=%.2f..%.2f y=%.2f..%.2f base=%.2f fontSize=%.2f space=%d: '", - word0->xMin, word0->xMax, word0->yMin, word0->yMax, - word0->base, word0->fontSize, word0->spaceAfter); - for (j = 0; j < word0->len; ++j) { - fputc(word0->text[j] & 0xff, stdout); - } - printf("'\n"); - } - } - } - printf("\n"); - fflush(stdout); -#endif - - // build the flows - //~ this needs to be adjusted for writing mode (vertical text) - //~ this also needs to account for right-to-left column ordering - flow = NULL; - while (flows) { - flow = flows; - flows = flows->next; - delete flow; - } - flows = lastFlow = NULL; - // assume blocks are already in reading order, - // and construct flows accordingly. - for (i = 0; i < nBlocks; i++) { - blk = blocks[i]; - blk->next = NULL; - if (flow) { - blk1 = blocks[i - 1]; - blkSpace = maxBlockSpacing * blk1->lines->words->fontSize; - if (blk1->secondaryDelta(blk) <= blkSpace && - blk->isBelow(blk1) && - flow->blockFits(blk, blk1)) { - flow->addBlock(blk); - continue; - } - } - flow = new TextFlow(this, blk); - if (lastFlow) { - lastFlow->next = flow; - } else { - flows = flow; - } - lastFlow = flow; - } - -#if 0 // for debugging - printf("*** flows ***\n"); - for (flow = flows; flow; flow = flow->next) { - printf("flow: x=%.2f..%.2f y=%.2f..%.2f pri:%.2f..%.2f\n", - flow->xMin, flow->xMax, flow->yMin, flow->yMax, - flow->priMin, flow->priMax); - for (blk = flow->blocks; blk; blk = blk->next) { - printf(" block: rot=%d x=%.2f..%.2f y=%.2f..%.2f pri=%.2f..%.2f\n", - blk->rot, blk->ExMin, blk->ExMax, blk->EyMin, blk->EyMax, - blk->priMin, blk->priMax); - for (line = blk->lines; line; line = line->next) { - printf(" line:\n"); - for (word0 = line->words; word0; word0 = word0->next) { - printf(" word: x=%.2f..%.2f y=%.2f..%.2f base=%.2f fontSize=%.2f space=%d: '", - word0->xMin, word0->xMax, word0->yMin, word0->yMax, - word0->base, word0->fontSize, word0->spaceAfter); - for (i = 0; i < word0->len; ++i) { - fputc(word0->text[i] & 0xff, stdout); - } - printf("'\n"); - } - } - } - } - printf("\n"); -#endif - - if (uMap) { - uMap->decRefCnt(); - } -} - -GBool TextPage::findText(Unicode *s, int len, - GBool startAtTop, GBool stopAtBottom, - GBool startAtLast, GBool stopAtLast, - GBool caseSensitive, GBool backward, - GBool wholeWord, - double *xMin, double *yMin, - double *xMax, double *yMax) { - TextBlock *blk; - TextLine *line; - Unicode *s2, *txt; - Unicode *p; - int txtSize, m, i, j, k; - double xStart, yStart, xStop, yStop; - double xMin0, yMin0, xMax0, yMax0; - double xMin1, yMin1, xMax1, yMax1; - GBool found; - - //~ needs to handle right-to-left text - - if (rawOrder) { - return gFalse; - } - - // convert the search string to uppercase - if (!caseSensitive) { - s2 = unicodeNormalizeNFKC(s, len, &len, NULL); - for (i = 0; i < len; ++i) { - s2[i] = unicodeToUpper(s2[i]); - } - } else { - s2 = unicodeNormalizeNFKC(s, len, &len, NULL); - } - - txt = NULL; - txtSize = 0; - - xStart = yStart = xStop = yStop = 0; - if (startAtLast && haveLastFind) { - xStart = lastFindXMin; - yStart = lastFindYMin; - } else if (!startAtTop) { - xStart = *xMin; - yStart = *yMin; - } - if (stopAtLast && haveLastFind) { - xStop = lastFindXMin; - yStop = lastFindYMin; - } else if (!stopAtBottom) { - xStop = *xMax; - yStop = *yMax; - } - - found = gFalse; - xMin0 = xMax0 = yMin0 = yMax0 = 0; // make gcc happy - xMin1 = xMax1 = yMin1 = yMax1 = 0; // make gcc happy - - for (i = backward ? nBlocks - 1 : 0; - backward ? i >= 0 : i < nBlocks; - i += backward ? -1 : 1) { - blk = blocks[i]; - - // check: is the block above the top limit? - // (this only works if the page's primary rotation is zero -- - // otherwise the blocks won't be sorted in the useful order) - if (!startAtTop && primaryRot == 0 && - (backward ? blk->yMin > yStart : blk->yMax < yStart)) { - continue; - } - - // check: is the block below the bottom limit? - // (this only works if the page's primary rotation is zero -- - // otherwise the blocks won't be sorted in the useful order) - if (!stopAtBottom && primaryRot == 0 && - (backward ? blk->yMax < yStop : blk->yMin > yStop)) { - break; - } - - for (line = blk->lines; line; line = line->next) { - - // check: is the line above the top limit? - // (this only works if the page's primary rotation is zero -- - // otherwise the lines won't be sorted in the useful order) - if (!startAtTop && primaryRot == 0 && - (backward ? line->yMin > yStart : line->yMin < yStart)) { - continue; - } - - // check: is the line below the bottom limit? - // (this only works if the page's primary rotation is zero -- - // otherwise the lines won't be sorted in the useful order) - if (!stopAtBottom && primaryRot == 0 && - (backward ? line->yMin < yStop : line->yMin > yStop)) { - continue; - } - - if (!line->normalized) - line->normalized = unicodeNormalizeNFKC(line->text, line->len, - &line->normalized_len, - &line->normalized_idx); - // convert the line to uppercase - m = line->normalized_len; - if (!caseSensitive) { - if (m > txtSize) { - txt = (Unicode *)greallocn(txt, m, sizeof(Unicode)); - txtSize = m; - } - for (k = 0; k < m; ++k) { - txt[k] = unicodeToUpper(line->normalized[k]); - } - } else { - txt = line->normalized; - } - - // search each position in this line - j = backward ? m - len : 0; - p = txt + j; - while (backward ? j >= 0 : j <= m - len) { - if (!wholeWord || - ((j == 0 || !unicodeTypeAlphaNum(txt[j - 1])) && - (j + len == m || !unicodeTypeAlphaNum(txt[j + len])))) { - - // compare the strings - for (k = 0; k < len; ++k) { - if (p[k] != s2[k]) { - break; - } - } - - // found it - if (k == len) { - // where s2 matches a subsequence of a compatibility equivalence - // decomposition, highlight the entire glyph, since we don't know - // the internal layout of subglyph components - int normStart = line->normalized_idx[j]; - int normAfterEnd = line->normalized_idx[j + len - 1] + 1; - switch (line->rot) { - case 0: - xMin1 = line->edge[normStart]; - xMax1 = line->edge[normAfterEnd]; - yMin1 = line->yMin; - yMax1 = line->yMax; - break; - case 1: - xMin1 = line->xMin; - xMax1 = line->xMax; - yMin1 = line->edge[normStart]; - yMax1 = line->edge[normAfterEnd]; - break; - case 2: - xMin1 = line->edge[normAfterEnd]; - xMax1 = line->edge[normStart]; - yMin1 = line->yMin; - yMax1 = line->yMax; - break; - case 3: - xMin1 = line->xMin; - xMax1 = line->xMax; - yMin1 = line->edge[normAfterEnd]; - yMax1 = line->edge[normStart]; - break; - } - if (backward) { - if ((startAtTop || - yMin1 < yStart || (yMin1 == yStart && xMin1 < xStart)) && - (stopAtBottom || - yMin1 > yStop || (yMin1 == yStop && xMin1 > xStop))) { - if (!found || - yMin1 > yMin0 || (yMin1 == yMin0 && xMin1 > xMin0)) { - xMin0 = xMin1; - xMax0 = xMax1; - yMin0 = yMin1; - yMax0 = yMax1; - found = gTrue; - } - } - } else { - if ((startAtTop || - yMin1 > yStart || (yMin1 == yStart && xMin1 > xStart)) && - (stopAtBottom || - yMin1 < yStop || (yMin1 == yStop && xMin1 < xStop))) { - if (!found || - yMin1 < yMin0 || (yMin1 == yMin0 && xMin1 < xMin0)) { - xMin0 = xMin1; - xMax0 = xMax1; - yMin0 = yMin1; - yMax0 = yMax1; - found = gTrue; - } - } - } - } - } - if (backward) { - --j; - --p; - } else { - ++j; - ++p; - } - } - } - } - - gfree(s2); - if (!caseSensitive) { - gfree(txt); - } - - if (found) { - *xMin = xMin0; - *xMax = xMax0; - *yMin = yMin0; - *yMax = yMax0; - lastFindXMin = xMin0; - lastFindYMin = yMin0; - haveLastFind = gTrue; - return gTrue; - } - - return gFalse; -} - -GooString *TextPage::getText(double xMin, double yMin, - double xMax, double yMax) { - GooString *s; - UnicodeMap *uMap; - TextBlock *blk; - TextLine *line; - TextLineFrag *frags; - int nFrags, fragsSize; - TextLineFrag *frag; - char space[8], eol[16]; - int spaceLen, eolLen; - int lastRot; - double x, y, delta; - int col, idx0, idx1, i, j; - GBool multiLine, oneRot; - - s = new GooString(); - - // get the output encoding - if (!(uMap = globalParams->getTextEncoding())) { - return s; - } - - if (rawOrder) { - TextWord* word; - char mbc[16]; - int mbc_len; - - for (word = rawWords; word && word <= rawLastWord; word = word->next) { - for (j = 0; j < word->getLength(); ++j) { - double gXMin, gXMax, gYMin, gYMax; - word->getCharBBox(j, &gXMin, &gYMin, &gXMax, &gYMax); - if (xMin <= gXMin && gXMax <= xMax && yMin <= gYMin && gYMax <= yMax) - { - mbc_len = uMap->mapUnicode( *(word->getChar(j)), mbc, sizeof(mbc) ); - s->append(mbc, mbc_len); - } - } - } - return s; - } - - spaceLen = uMap->mapUnicode(0x20, space, sizeof(space)); - eolLen = 0; // make gcc happy - switch (globalParams->getTextEOL()) { - case eolUnix: - eolLen = uMap->mapUnicode(0x0a, eol, sizeof(eol)); - break; - case eolDOS: - eolLen = uMap->mapUnicode(0x0d, eol, sizeof(eol)); - eolLen += uMap->mapUnicode(0x0a, eol + eolLen, sizeof(eol) - eolLen); - break; - case eolMac: - eolLen = uMap->mapUnicode(0x0d, eol, sizeof(eol)); - break; - } - - //~ writing mode (horiz/vert) - - // collect the line fragments that are in the rectangle - fragsSize = 256; - frags = (TextLineFrag *)gmallocn(fragsSize, sizeof(TextLineFrag)); - nFrags = 0; - lastRot = -1; - oneRot = gTrue; - for (i = 0; i < nBlocks; ++i) { - blk = blocks[i]; - if (xMin < blk->xMax && blk->xMin < xMax && - yMin < blk->yMax && blk->yMin < yMax) { - for (line = blk->lines; line; line = line->next) { - if (xMin < line->xMax && line->xMin < xMax && - yMin < line->yMax && line->yMin < yMax) { - idx0 = idx1 = -1; - switch (line->rot) { - case 0: - y = 0.5 * (line->yMin + line->yMax); - if (yMin < y && y < yMax) { - j = 0; - while (j < line->len) { - if (0.5 * (line->edge[j] + line->edge[j+1]) > xMin) { - idx0 = j; - break; - } - ++j; - } - j = line->len - 1; - while (j >= 0) { - if (0.5 * (line->edge[j] + line->edge[j+1]) < xMax) { - idx1 = j; - break; - } - --j; - } - } - break; - case 1: - x = 0.5 * (line->xMin + line->xMax); - if (xMin < x && x < xMax) { - j = 0; - while (j < line->len) { - if (0.5 * (line->edge[j] + line->edge[j+1]) > yMin) { - idx0 = j; - break; - } - ++j; - } - j = line->len - 1; - while (j >= 0) { - if (0.5 * (line->edge[j] + line->edge[j+1]) < yMax) { - idx1 = j; - break; - } - --j; - } - } - break; - case 2: - y = 0.5 * (line->yMin + line->yMax); - if (yMin < y && y < yMax) { - j = 0; - while (j < line->len) { - if (0.5 * (line->edge[j] + line->edge[j+1]) < xMax) { - idx0 = j; - break; - } - ++j; - } - j = line->len - 1; - while (j >= 0) { - if (0.5 * (line->edge[j] + line->edge[j+1]) > xMin) { - idx1 = j; - break; - } - --j; - } - } - break; - case 3: - x = 0.5 * (line->xMin + line->xMax); - if (xMin < x && x < xMax) { - j = 0; - while (j < line->len) { - if (0.5 * (line->edge[j] + line->edge[j+1]) < yMax) { - idx0 = j; - break; - } - ++j; - } - j = line->len - 1; - while (j >= 0) { - if (0.5 * (line->edge[j] + line->edge[j+1]) > yMin) { - idx1 = j; - break; - } - --j; - } - } - break; - } - if (idx0 >= 0 && idx1 >= 0) { - if (nFrags == fragsSize) { - fragsSize *= 2; - frags = (TextLineFrag *) - greallocn(frags, fragsSize, sizeof(TextLineFrag)); - } - frags[nFrags].init(line, idx0, idx1 - idx0 + 1); - ++nFrags; - if (lastRot >= 0 && line->rot != lastRot) { - oneRot = gFalse; - } - lastRot = line->rot; - } - } - } - } - } - - // sort the fragments and generate the string - if (nFrags > 0) { - - for (i = 0; i < nFrags; ++i) { - frags[i].computeCoords(oneRot); - } - assignColumns(frags, nFrags, oneRot); - - // if all lines in the region have the same rotation, use it; - // otherwise, use the page's primary rotation - if (oneRot) { - qsort(frags, nFrags, sizeof(TextLineFrag), - &TextLineFrag::cmpYXLineRot); - } else { - qsort(frags, nFrags, sizeof(TextLineFrag), - &TextLineFrag::cmpYXPrimaryRot); - } - i = 0; - while (i < nFrags) { - delta = maxIntraLineDelta * frags[i].line->words->fontSize; - for (j = i+1; - j < nFrags && fabs(frags[j].base - frags[i].base) < delta; - ++j) ; - qsort(frags + i, j - i, sizeof(TextLineFrag), - oneRot ? &TextLineFrag::cmpXYColumnLineRot - : &TextLineFrag::cmpXYColumnPrimaryRot); - i = j; - } - - col = 0; - multiLine = gFalse; - for (i = 0; i < nFrags; ++i) { - frag = &frags[i]; - - // insert a return - if (frag->col < col || - (i > 0 && fabs(frag->base - frags[i-1].base) > - maxIntraLineDelta * frags[i-1].line->words->fontSize)) { - s->append(eol, eolLen); - col = 0; - multiLine = gTrue; - } - - // column alignment - for (; col < frag->col; ++col) { - s->append(space, spaceLen); - } - - // get the fragment text - col += dumpFragment(frag->line->text + frag->start, frag->len, uMap, s); - } - - if (multiLine) { - s->append(eol, eolLen); - } - } - - gfree(frags); - uMap->decRefCnt(); - - return s; -} - -class TextSelectionVisitor { -public: - TextSelectionVisitor (TextPage *page); - virtual ~TextSelectionVisitor () { } - virtual void visitBlock (TextBlock *block, - TextLine *begin, - TextLine *end, - PDFRectangle *selection) = 0; - virtual void visitLine (TextLine *line, - TextWord *begin, - TextWord *end, - int edge_begin, - int edge_end, - PDFRectangle *selection) = 0; - virtual void visitWord (TextWord *word, int begin, int end, - PDFRectangle *selection) = 0; - -protected: - TextPage *page; -}; - -TextSelectionVisitor::TextSelectionVisitor (TextPage *page) - : page(page) -{ -} - - -class TextSelectionDumper : public TextSelectionVisitor { -public: - TextSelectionDumper(TextPage *page); - virtual ~TextSelectionDumper(); - - virtual void visitBlock (TextBlock *block, - TextLine *begin, - TextLine *end, - PDFRectangle *selection) { }; - virtual void visitLine (TextLine *line, - TextWord *begin, - TextWord *end, - int edge_begin, - int edge_end, - PDFRectangle *selection); - virtual void visitWord (TextWord *word, int begin, int end, - PDFRectangle *selection); - void endPage(); - - GooString *getText(void); - GooList **takeWordList(int *nLines); - -private: - - void startLine(); - void finishLine(); - - GooList **lines; - int nLines, linesSize; - GooList *words; - int tableId; - TextBlock *currentBlock; -}; - -TextSelectionDumper::TextSelectionDumper(TextPage *page) - : TextSelectionVisitor(page) -{ - linesSize = 256; - lines = (GooList **)gmallocn(linesSize, sizeof(GooList *)); - nLines = 0; - - tableId = -1; - currentBlock = NULL; - words = NULL; -} - -TextSelectionDumper::~TextSelectionDumper() -{ - for (int i = 0; i < nLines; i++) - deleteGooList(lines[i], TextWordSelection); - gfree(lines); -} - -void TextSelectionDumper::startLine() -{ - finishLine(); - words = new GooList(); -} - -void TextSelectionDumper::finishLine() -{ - if (nLines == linesSize) { - linesSize *= 2; - lines = (GooList **)grealloc(lines, linesSize * sizeof(GooList *)); - } - - if (words && words->getLength() > 0) - lines[nLines++] = words; - else if (words) - delete words; - words = NULL; -} - -void TextSelectionDumper::visitLine (TextLine *line, - TextWord *begin, - TextWord *end, - int edge_begin, - int edge_end, - PDFRectangle *selection) -{ - TextLineFrag frag; - - frag.init(line, edge_begin, edge_end - edge_begin); - - if (tableId >= 0 && frag.line->blk->tableId < 0) { - finishLine(); - - tableId = -1; - currentBlock = NULL; - } - - if (frag.line->blk->tableId >= 0) { // a table - if (tableId == -1) { - tableId = frag.line->blk->tableId; - currentBlock = frag.line->blk; - } - - if (currentBlock == frag.line->blk) { // the same block - startLine(); - } else { // another block - if (currentBlock->tableEnd) { // previous block ended its row - startLine(); - } - currentBlock = frag.line->blk; - } - } else { // not a table - startLine(); - } -} - -void TextSelectionDumper::visitWord (TextWord *word, int begin, int end, - PDFRectangle *selection) -{ - words->append(new TextWordSelection(word, begin, end)); -} - -void TextSelectionDumper::endPage() -{ - finishLine(); -} - -GooString *TextSelectionDumper::getText (void) -{ - GooString *text; - int i, j; - UnicodeMap *uMap; - char space[8], eol[16]; - int spaceLen, eolLen; - - text = new GooString(); - - if (!(uMap = globalParams->getTextEncoding())) - return text; - - spaceLen = uMap->mapUnicode(0x20, space, sizeof(space)); - eolLen = uMap->mapUnicode(0x0a, eol, sizeof(eol)); - - for (i = 0; i < nLines; i++) { - GooList *lineWords = lines[i]; - for (j = 0; j < lineWords->getLength(); j++) { - TextWordSelection *sel = (TextWordSelection *)lineWords->get(j); - - page->dumpFragment (sel->word->text + sel->begin, sel->end - sel->begin, uMap, text); - if (j < lineWords->getLength() - 1) - text->append(space, spaceLen); - } - if (i < nLines - 1) - text->append(eol, eolLen); - } - - uMap->decRefCnt(); - - return text; -} - -GooList **TextSelectionDumper::takeWordList(int *nLinesOut) -{ - GooList **returnValue = lines; - - *nLinesOut = nLines; - if (nLines == 0) - return NULL; - - nLines = 0; - lines = NULL; - - return returnValue; -} - -class TextSelectionSizer : public TextSelectionVisitor { -public: - TextSelectionSizer(TextPage *page, double scale); - ~TextSelectionSizer() { } - - virtual void visitBlock (TextBlock *block, - TextLine *begin, - TextLine *end, - PDFRectangle *selection) { }; - virtual void visitLine (TextLine *line, - TextWord *begin, - TextWord *end, - int edge_begin, - int edge_end, - PDFRectangle *selection); - virtual void visitWord (TextWord *word, int begin, int end, - PDFRectangle *selection) { }; - - GooList *getRegion () { return list; } - -private: - GooList *list; - double scale; -}; - -TextSelectionSizer::TextSelectionSizer(TextPage *page, double scale) - : TextSelectionVisitor(page), - scale(scale) -{ - list = new GooList(); -} - -void TextSelectionSizer::visitLine (TextLine *line, - TextWord *begin, - TextWord *end, - int edge_begin, - int edge_end, - PDFRectangle *selection) -{ - PDFRectangle *rect; - double x1, y1, x2, y2, margin; - - margin = (line->yMax - line->yMin) / 8; - x1 = line->edge[edge_begin]; - y1 = line->yMin - margin; - x2 = line->edge[edge_end]; - y2 = line->yMax + margin; - - rect = new PDFRectangle (floor (x1 * scale), - floor (y1 * scale), - ceil (x2 * scale), - ceil (y2 * scale)); - list->append (rect); -} - - -class TextSelectionPainter : public TextSelectionVisitor { -public: - TextSelectionPainter(TextPage *page, - double scale, - int rotation, - OutputDev *out, - GfxColor *box_color, - GfxColor *glyph_color); - ~TextSelectionPainter(); - - virtual void visitBlock (TextBlock *block, - TextLine *begin, - TextLine *end, - PDFRectangle *selection) { }; - virtual void visitLine (TextLine *line, - TextWord *begin, - TextWord *end, - int edge_begin, - int edge_end, - PDFRectangle *selection); - virtual void visitWord (TextWord *word, int begin, int end, - PDFRectangle *selection); - void endPage(); - -private: - OutputDev *out; - GfxColor *box_color, *glyph_color; - GfxState *state; - GooList *selectionList; - Matrix ctm, ictm; -}; - -TextSelectionPainter::TextSelectionPainter(TextPage *page, - double scale, - int rotation, - OutputDev *out, - GfxColor *box_color, - GfxColor *glyph_color) - : TextSelectionVisitor(page), - out(out), - box_color(box_color), - glyph_color(glyph_color) -{ - PDFRectangle box(0, 0, page->pageWidth, page->pageHeight); - - selectionList = new GooList(); - state = new GfxState(72 * scale, 72 * scale, &box, rotation, gFalse); - - state->getCTM(&ctm); - ctm.invertTo(&ictm); - - out->startPage(0, state, NULL); - out->setDefaultCTM (state->getCTM()); - - state->setFillColorSpace(new GfxDeviceRGBColorSpace()); - state->setFillColor(box_color); - out->updateFillColor(state); -} - -TextSelectionPainter::~TextSelectionPainter() -{ - deleteGooList(selectionList, TextWordSelection); - delete state; -} - -void TextSelectionPainter::visitLine (TextLine *line, - TextWord *begin, - TextWord *end, - int edge_begin, - int edge_end, - PDFRectangle *selection) -{ - double x1, y1, x2, y2, margin; - - margin = (line->yMax - line->yMin) / 8; - x1 = floor (line->edge[edge_begin]); - y1 = floor (line->yMin - margin); - x2 = ceil (line->edge[edge_end]); - y2 = ceil (line->yMax + margin); - - ctm.transform(line->edge[edge_begin], line->yMin - margin, &x1, &y1); - ctm.transform(line->edge[edge_end], line->yMax + margin, &x2, &y2); - - x1 = floor (x1); - y1 = floor (y1); - x2 = ceil (x2); - y2 = ceil (y2); - - ictm.transform(x1, y1, &x1, &y1); - ictm.transform(x2, y2, &x2, &y2); - - state->moveTo(x1, y1); - state->lineTo(x2, y1); - state->lineTo(x2, y2); - state->lineTo(x1, y2); - state->closePath(); -} - -void TextSelectionPainter::visitWord (TextWord *word, int begin, int end, - PDFRectangle *selection) -{ - selectionList->append(new TextWordSelection(word, begin, end)); -} - -void TextSelectionPainter::endPage() -{ - out->fill(state); - - out->saveState(state); - out->clip(state); - - state->clearPath(); - - state->setFillColor(glyph_color); - out->updateFillColor(state); - - for (int i = 0; i < selectionList->getLength(); i++) { - TextWordSelection *sel = (TextWordSelection *) selectionList->get(i); - int begin = sel->begin; - - while (begin < sel->end) { - TextFontInfo *font = sel->word->font[begin]; - font->gfxFont->incRefCnt(); - Matrix *mat = &sel->word->textMat[begin]; - - state->setTextMat(mat->m[0], mat->m[1], mat->m[2], mat->m[3], 0, 0); - state->setFont(font->gfxFont, 1); - out->updateFont(state); - - int fEnd = begin + 1; - while (fEnd < sel->end && font->matches(sel->word->font[fEnd]) && - mat->m[0] == sel->word->textMat[fEnd].m[0] && - mat->m[1] == sel->word->textMat[fEnd].m[1] && - mat->m[2] == sel->word->textMat[fEnd].m[2] && - mat->m[3] == sel->word->textMat[fEnd].m[3]) - fEnd++; - - /* The only purpose of this string is to let the output device query - * it's length. Might want to change this interface later. */ - GooString *string = new GooString ((char *) sel->word->charcode, fEnd - begin); - out->beginString(state, string); - - for (int i = begin; i < fEnd; i++) { - if (i != begin && sel->word->charPos[i] == sel->word->charPos[i - 1]) - continue; - - out->drawChar(state, sel->word->textMat[i].m[4], sel->word->textMat[i].m[5], 0, 0, 0, 0, - sel->word->charcode[i], 1, NULL, 0); - } - out->endString(state); - delete string; - begin = fEnd; - } - } - - out->restoreState(state); - out->endPage (); -} - -void TextWord::visitSelection(TextSelectionVisitor *visitor, - PDFRectangle *selection, - SelectionStyle style) -{ - int i, begin, end; - double mid; - - begin = len; - end = 0; - for (i = 0; i < len; i++) { - mid = (edge[i] + edge[i + 1]) / 2; - if (selection->x1 < mid || selection->x2 < mid) - if (i < begin) - begin = i; - if (mid < selection->x1 || mid < selection->x2) - end = i + 1; - } - - /* Skip empty selection. */ - if (end <= begin) - return; - - visitor->visitWord (this, begin, end, selection); -} - -void TextLine::visitSelection(TextSelectionVisitor *visitor, - PDFRectangle *selection, - SelectionStyle style) { - TextWord *p, *begin, *end, *current; - int i, edge_begin, edge_end; - PDFRectangle child_selection; - - begin = NULL; - end = NULL; - current = NULL; - for (p = words; p != NULL; p = p->next) { - if (blk->page->primaryLR) { - if ((selection->x1 < p->xMax) || - (selection->x2 < p->xMax)) - if (begin == NULL) - begin = p; - - if (((selection->x1 > p->xMin) || - (selection->x2 > p->xMin)) && (begin != NULL)) { - end = p->next; - current = p; - } - } else { - if ((selection->x1 > p->xMin) || - (selection->x2 > p->xMin)) - if (begin == NULL) - begin = p; - - if (((selection->x1 < p->xMax) || - (selection->x2 < p->xMax)) && (begin != NULL)) { - end = p->next; - current = p; - } - } - } - - if (!current) - current = begin; - - child_selection = *selection; - if (style == selectionStyleWord) { - child_selection.x1 = begin ? begin->xMin : xMin; - if (end && end->xMax != -1) { - child_selection.x2 = current->xMax; - } else { - child_selection.x2 = xMax; - } - } - - edge_begin = len; - edge_end = 0; - for (i = 0; i < len; i++) { - double mid = (edge[i] + edge[i + 1]) / 2; - if (child_selection.x1 < mid || child_selection.x2 < mid) - if (i < edge_begin) - edge_begin = i; - if (mid < child_selection.x2 || mid < child_selection.x1) - edge_end = i + 1; - } - - /* Skip empty selection. */ - if (edge_end <= edge_begin) - return; - - visitor->visitLine (this, begin, end, edge_begin, edge_end, - &child_selection); - - for (p = begin; p != end; p = p->next) - p->visitSelection (visitor, &child_selection, style); -} - -void TextBlock::visitSelection(TextSelectionVisitor *visitor, - PDFRectangle *selection, - SelectionStyle style) { - PDFRectangle child_selection; - double x[2], y[2], d, best_d[2]; - TextLine *p, *best_line[2]; - int i, count = 0, best_count[2], start, stop; - GBool all[2]; - - x[0] = selection->x1; - y[0] = selection->y1; - x[1] = selection->x2; - y[1] = selection->y2; - - for (i = 0; i < 2; i++) { - // the first/last lines are often not nearest - // the corners, so we have to force them to be - // selected when the selection runs outside this - // block. - if (page->primaryLR) { - all[i] = x[i] >= this->xMax && y[i] >= this->yMax; - if (x[i] <= this->xMin && y[i] <= this->yMin) { - best_line[i] = this->lines; - best_count[i] = 1; - } else { - best_line[i] = NULL; - best_count[i] = 0; - } - } else { - all[i] = x[i] <= this->xMin && y[i] >= this->yMax; - if (x[i] >= this->xMax && y[i] <= this->yMin) { - best_line[i] = this->lines; - best_count[i] = 1; - } else { - best_line[i] = NULL; - best_count[i] = 0; - } - } - best_d[i] = 0; - } - - // find the nearest line to the selection points - // using the manhattan distance. - for (p = this->lines; p; p = p->next) { - count++; - for (i = 0; i < 2; i++) { - d = fmax(p->xMin - x[i], 0.0) + - fmax(x[i] - p->xMax, 0.0) + - fmax(p->yMin - y[i], 0.0) + - fmax(y[i] - p->yMax, 0.0); - if (!best_line[i] || all[i] || - d < best_d[i]) { - best_line[i] = p; - best_count[i] = count; - best_d[i] = d; - } - } - } - // assert: best is always set. - if (!best_line[0] || !best_line[1]) { - return; - } - - // Now decide which point was first. - if (best_count[0] < best_count[1] || - (best_count[0] == best_count[1] && - y[0] < y[1])) { - start = 0; - stop = 1; - } else { - start = 1; - stop = 0; - } - - visitor->visitBlock(this, best_line[start], best_line[stop], selection); - - for (p = best_line[start]; p; p = p->next) { - if (page->primaryLR) { - child_selection.x1 = p->xMin; - child_selection.x2 = p->xMax; - } else { - child_selection.x1 = p->xMax; - child_selection.x2 = p->xMin; - } - child_selection.y1 = p->yMin; - child_selection.y2 = p->yMax; - if (style == selectionStyleLine) { - if (p == best_line[start]) { - child_selection.x1 = 0; - child_selection.y1 = 0; - } - if (p == best_line[stop]) { - child_selection.x2 = page->pageWidth; - child_selection.y2 = page->pageHeight; - } - } else { - if (p == best_line[start]) { - child_selection.x1 = fmax(p->xMin, fmin(p->xMax, x[start])); - child_selection.y1 = fmax(p->yMin, fmin(p->yMax, y[start])); - } - if (p == best_line[stop]) { - child_selection.x2 = fmax(p->xMin, fmin(p->xMax, x[stop])); - child_selection.y2 = fmax(p->yMin, fmin(p->yMax, y[stop])); - } - } - p->visitSelection(visitor, &child_selection, style); - if (p == best_line[stop]) { - return; - } - } -} - -void TextPage::visitSelection(TextSelectionVisitor *visitor, - PDFRectangle *selection, - SelectionStyle style) -{ - PDFRectangle child_selection; - double x[2], y[2], d, best_d[2]; - double xMin, yMin, xMax, yMax; - TextFlow *flow, *best_flow[2]; - TextBlock *blk, *best_block[2]; - int i, count = 0, best_count[2], start, stop; - - if (!flows) - return; - - x[0] = selection->x1; - y[0] = selection->y1; - x[1] = selection->x2; - y[1] = selection->y2; - - xMin = pageWidth; - yMin = pageHeight; - xMax = 0.0; - yMax = 0.0; - - for (i = 0; i < 2; i++) { - best_block[i] = NULL; - best_flow[i] = NULL; - best_count[i] = 0; - best_d[i] = 0; - } - - // find the nearest blocks to the selection points - // using the manhattan distance. - for (flow = flows; flow; flow = flow->next) { - for (blk = flow->blocks; blk; blk = blk->next) { - count++; - // the first/last blocks in reading order are - // often not the closest to the page corners; - // track the corners, force those blocks to - // be selected if the selection runs across - // multiple pages. - xMin = fmin(xMin, blk->xMin); - yMin = fmin(yMin, blk->yMin); - xMax = fmax(xMax, blk->xMax); - yMax = fmax(yMax, blk->yMax); - for (i = 0; i < 2; i++) { - d = fmax(blk->xMin - x[i], 0.0) + - fmax(x[i] - blk->xMax, 0.0) + - fmax(blk->yMin - y[i], 0.0) + - fmax(y[i] - blk->yMax, 0.0); - if (!best_block[i] || - d < best_d[i] || - (!blk->next && !flow->next && - x[i] >= fmin(xMax, pageWidth) && - y[i] >= fmin(yMax, pageHeight))) { - best_block[i] = blk; - best_flow[i] = flow; - best_count[i] = count; - best_d[i] = d; - } - } - } - } - for (i = 0; i < 2; i++) { - if (primaryLR) { - if (x[i] < xMin && y[i] < yMin) { - best_block[i] = flows->blocks; - best_flow[i] = flows; - best_count[i] = 1; - } - } else { - if (x[i] > xMax && y[i] < yMin) { - best_block[i] = flows->blocks; - best_flow[i] = flows; - best_count[i] = 1; - } - } - } - // assert: best is always set. - if (!best_block[0] || !best_block[1]) { - return; - } - - // Now decide which point was first. - if (best_count[0] < best_count[1] || - (best_count[0] == best_count[1] && y[0] < y[1])) { - start = 0; - stop = 1; - } else { - start = 1; - stop = 0; - } - - for (flow = best_flow[start]; flow; flow = flow->next) { - if (flow == best_flow[start]) { - blk = best_block[start]; - } else { - blk = flow->blocks; - } - for (; blk; blk = blk->next) { - if (primaryLR) { - child_selection.x1 = blk->xMin; - child_selection.x2 = blk->xMax; - } else { - child_selection.x1 = blk->xMax; - child_selection.x2 = blk->xMin; - } - child_selection.y1 = blk->yMin; - child_selection.y2 = blk->yMax; - if (blk == best_block[start]) { - child_selection.x1 = fmax(blk->xMin, fmin(blk->xMax, x[start])); - child_selection.y1 = fmax(blk->yMin, fmin(blk->yMax, y[start])); - } - if (blk == best_block[stop]) { - child_selection.x2 = fmax(blk->xMin, fmin(blk->xMax, x[stop])); - child_selection.y2 = fmax(blk->yMin, fmin(blk->yMax, y[stop])); - blk->visitSelection(visitor, &child_selection, style); - return; - } - blk->visitSelection(visitor, &child_selection, style); - } - } -} - -void TextPage::drawSelection(OutputDev *out, - double scale, - int rotation, - PDFRectangle *selection, - SelectionStyle style, - GfxColor *glyph_color, GfxColor *box_color) -{ - TextSelectionPainter painter(this, scale, rotation, - out, box_color, glyph_color); - - visitSelection(&painter, selection, style); - painter.endPage(); -} - -GooList *TextPage::getSelectionRegion(PDFRectangle *selection, - SelectionStyle style, - double scale) { - TextSelectionSizer sizer(this, scale); - - visitSelection(&sizer, selection, style); - - return sizer.getRegion(); -} - -GooString *TextPage::getSelectionText(PDFRectangle *selection, - SelectionStyle style) -{ - TextSelectionDumper dumper(this); - - visitSelection(&dumper, selection, style); - dumper.endPage(); - - return dumper.getText(); -} - -GooList **TextPage::getSelectionWords(PDFRectangle *selection, - SelectionStyle style, - int *nLines) -{ - TextSelectionDumper dumper(this); - - visitSelection(&dumper, selection, style); - dumper.endPage(); - - return dumper.takeWordList(nLines); -} - -GBool TextPage::findCharRange(int pos, int length, - double *xMin, double *yMin, - double *xMax, double *yMax) { - TextBlock *blk; - TextLine *line; - TextWord *word; - double xMin0, xMax0, yMin0, yMax0; - double xMin1, xMax1, yMin1, yMax1; - GBool first; - int i, j0, j1; - - if (rawOrder) { - return gFalse; - } - - //~ this doesn't correctly handle ranges split across multiple lines - //~ (the highlighted region is the bounding box of all the parts of - //~ the range) - first = gTrue; - xMin0 = xMax0 = yMin0 = yMax0 = 0; // make gcc happy - xMin1 = xMax1 = yMin1 = yMax1 = 0; // make gcc happy - for (i = 0; i < nBlocks; ++i) { - blk = blocks[i]; - for (line = blk->lines; line; line = line->next) { - for (word = line->words; word; word = word->next) { - if (pos < word->charPos[word->len] && - pos + length > word->charPos[0]) { - for (j0 = 0; - j0 < word->len && pos >= word->charPos[j0 + 1]; - ++j0) ; - for (j1 = word->len - 1; - j1 > j0 && pos + length <= word->charPos[j1]; - --j1) ; - switch (line->rot) { - case 0: - xMin1 = word->edge[j0]; - xMax1 = word->edge[j1 + 1]; - yMin1 = word->yMin; - yMax1 = word->yMax; - break; - case 1: - xMin1 = word->xMin; - xMax1 = word->xMax; - yMin1 = word->edge[j0]; - yMax1 = word->edge[j1 + 1]; - break; - case 2: - xMin1 = word->edge[j1 + 1]; - xMax1 = word->edge[j0]; - yMin1 = word->yMin; - yMax1 = word->yMax; - break; - case 3: - xMin1 = word->xMin; - xMax1 = word->xMax; - yMin1 = word->edge[j1 + 1]; - yMax1 = word->edge[j0]; - break; - } - if (first || xMin1 < xMin0) { - xMin0 = xMin1; - } - if (first || xMax1 > xMax0) { - xMax0 = xMax1; - } - if (first || yMin1 < yMin0) { - yMin0 = yMin1; - } - if (first || yMax1 > yMax0) { - yMax0 = yMax1; - } - first = gFalse; - } - } - } - } - if (!first) { - *xMin = xMin0; - *xMax = xMax0; - *yMin = yMin0; - *yMax = yMax0; - return gTrue; - } - return gFalse; -} - -void TextPage::dump(void *outputStream, TextOutputFunc outputFunc, - GBool physLayout) { - UnicodeMap *uMap; - TextFlow *flow; - TextBlock *blk; - TextLine *line; - TextLineFrag *frags; - TextWord *word; - int nFrags, fragsSize; - TextLineFrag *frag; - char space[8], eol[16], eop[8]; - int spaceLen, eolLen, eopLen; - GBool pageBreaks; - GooString *s; - double delta; - int col, i, j, d, n; - - // get the output encoding - if (!(uMap = globalParams->getTextEncoding())) { - return; - } - spaceLen = uMap->mapUnicode(0x20, space, sizeof(space)); - eolLen = 0; // make gcc happy - switch (globalParams->getTextEOL()) { - case eolUnix: - eolLen = uMap->mapUnicode(0x0a, eol, sizeof(eol)); - break; - case eolDOS: - eolLen = uMap->mapUnicode(0x0d, eol, sizeof(eol)); - eolLen += uMap->mapUnicode(0x0a, eol + eolLen, sizeof(eol) - eolLen); - break; - case eolMac: - eolLen = uMap->mapUnicode(0x0d, eol, sizeof(eol)); - break; - } - eopLen = uMap->mapUnicode(0x0c, eop, sizeof(eop)); - pageBreaks = globalParams->getTextPageBreaks(); - - //~ writing mode (horiz/vert) - - // output the page in raw (content stream) order - if (rawOrder) { - - for (word = rawWords; word; word = word->next) { - s = new GooString(); - dumpFragment(word->text, word->len, uMap, s); - (*outputFunc)(outputStream, s->getCString(), s->getLength()); - delete s; - if (word->next && - fabs(word->next->base - word->base) < - maxIntraLineDelta * word->fontSize && - word->next->xMin > - word->xMax - minDupBreakOverlap * word->fontSize) { - if (word->next->xMin > word->xMax + minWordSpacing * word->fontSize) { - (*outputFunc)(outputStream, space, spaceLen); - } - } else { - (*outputFunc)(outputStream, eol, eolLen); - } - } - - // output the page, maintaining the original physical layout - } else if (physLayout) { - - // collect the line fragments for the page and sort them - fragsSize = 256; - frags = (TextLineFrag *)gmallocn(fragsSize, sizeof(TextLineFrag)); - nFrags = 0; - for (i = 0; i < nBlocks; ++i) { - blk = blocks[i]; - for (line = blk->lines; line; line = line->next) { - if (nFrags == fragsSize) { - fragsSize *= 2; - frags = (TextLineFrag *)greallocn(frags, - fragsSize, sizeof(TextLineFrag)); - } - frags[nFrags].init(line, 0, line->len); - frags[nFrags].computeCoords(gTrue); - ++nFrags; - } - } - qsort(frags, nFrags, sizeof(TextLineFrag), &TextLineFrag::cmpYXPrimaryRot); - i = 0; - while (i < nFrags) { - delta = maxIntraLineDelta * frags[i].line->words->fontSize; - for (j = i+1; - j < nFrags && fabs(frags[j].base - frags[i].base) < delta; - ++j) ; - qsort(frags + i, j - i, sizeof(TextLineFrag), - &TextLineFrag::cmpXYColumnPrimaryRot); - i = j; - } - -#if 0 // for debugging - printf("*** line fragments ***\n"); - for (i = 0; i < nFrags; ++i) { - frag = &frags[i]; - printf("frag: x=%.2f..%.2f y=%.2f..%.2f base=%.2f '", - frag->xMin, frag->xMax, frag->yMin, frag->yMax, frag->base); - for (n = 0; n < frag->len; ++n) { - fputc(frag->line->text[frag->start + n] & 0xff, stdout); - } - printf("'\n"); - } - printf("\n"); -#endif - - // generate output - col = 0; - for (i = 0; i < nFrags; ++i) { - frag = &frags[i]; - - // column alignment - for (; col < frag->col; ++col) { - (*outputFunc)(outputStream, space, spaceLen); - } - - // print the line - s = new GooString(); - col += dumpFragment(frag->line->text + frag->start, frag->len, uMap, s); - (*outputFunc)(outputStream, s->getCString(), s->getLength()); - delete s; - - // print one or more returns if necessary - if (i == nFrags - 1 || - frags[i+1].col < col || - fabs(frags[i+1].base - frag->base) > - maxIntraLineDelta * frag->line->words->fontSize) { - if (i < nFrags - 1) { - d = (int)((frags[i+1].base - frag->base) / - frag->line->words->fontSize); - if (d < 1) { - d = 1; - } else if (d > 5) { - d = 5; - } - } else { - d = 1; - } - for (; d > 0; --d) { - (*outputFunc)(outputStream, eol, eolLen); - } - col = 0; - } - } - - gfree(frags); - - // output the page, "undoing" the layout - } else { - for (flow = flows; flow; flow = flow->next) { - for (blk = flow->blocks; blk; blk = blk->next) { - for (line = blk->lines; line; line = line->next) { - n = line->len; - if (line->hyphenated && (line->next || blk->next)) { - --n; - } - s = new GooString(); - dumpFragment(line->text, n, uMap, s); - (*outputFunc)(outputStream, s->getCString(), s->getLength()); - delete s; - // output a newline when a hyphen is not suppressed - if (n == line->len) { - (*outputFunc)(outputStream, eol, eolLen); - } - } - } - (*outputFunc)(outputStream, eol, eolLen); - } - } - - // end of page - if (pageBreaks) { - (*outputFunc)(outputStream, eop, eopLen); - } - - uMap->decRefCnt(); -} - -void TextPage::assignColumns(TextLineFrag *frags, int nFrags, GBool oneRot) { - TextLineFrag *frag0, *frag1; - int rot, col1, col2, i, j, k; - - // all text in the region has the same rotation -- recompute the - // column numbers based only on the text in the region - if (oneRot) { - qsort(frags, nFrags, sizeof(TextLineFrag), &TextLineFrag::cmpXYLineRot); - rot = frags[0].line->rot; - for (i = 0; i < nFrags; ++i) { - frag0 = &frags[i]; - col1 = 0; - for (j = 0; j < i; ++j) { - frag1 = &frags[j]; - col2 = 0; // make gcc happy - switch (rot) { - case 0: - if (frag0->xMin >= frag1->xMax) { - col2 = frag1->col + (frag1->line->col[frag1->start + frag1->len] - - frag1->line->col[frag1->start]) + 1; - } else { - for (k = frag1->start; - k < frag1->start + frag1->len && - frag0->xMin >= 0.5 * (frag1->line->edge[k] + - frag1->line->edge[k+1]); - ++k) ; - col2 = frag1->col + - frag1->line->col[k] - frag1->line->col[frag1->start]; - } - break; - case 1: - if (frag0->yMin >= frag1->yMax) { - col2 = frag1->col + (frag1->line->col[frag1->start + frag1->len] - - frag1->line->col[frag1->start]) + 1; - } else { - for (k = frag1->start; - k < frag1->start + frag1->len && - frag0->yMin >= 0.5 * (frag1->line->edge[k] + - frag1->line->edge[k+1]); - ++k) ; - col2 = frag1->col + - frag1->line->col[k] - frag1->line->col[frag1->start]; - } - break; - case 2: - if (frag0->xMax <= frag1->xMin) { - col2 = frag1->col + (frag1->line->col[frag1->start + frag1->len] - - frag1->line->col[frag1->start]) + 1; - } else { - for (k = frag1->start; - k < frag1->start + frag1->len && - frag0->xMax <= 0.5 * (frag1->line->edge[k] + - frag1->line->edge[k+1]); - ++k) ; - col2 = frag1->col + - frag1->line->col[k] - frag1->line->col[frag1->start]; - } - break; - case 3: - if (frag0->yMax <= frag1->yMin) { - col2 = frag1->col + (frag1->line->col[frag1->start + frag1->len] - - frag1->line->col[frag1->start]) + 1; - } else { - for (k = frag1->start; - k < frag1->start + frag1->len && - frag0->yMax <= 0.5 * (frag1->line->edge[k] + - frag1->line->edge[k+1]); - ++k) ; - col2 = frag1->col + - frag1->line->col[k] - frag1->line->col[frag1->start]; - } - break; - } - if (col2 > col1) { - col1 = col2; - } - } - frag0->col = col1; - } - - // the region includes text at different rotations -- use the - // globally assigned column numbers, offset by the minimum column - // number (i.e., shift everything over to column 0) - } else { - col1 = frags[0].col; - for (i = 1; i < nFrags; ++i) { - if (frags[i].col < col1) { - col1 = frags[i].col; - } - } - for (i = 0; i < nFrags; ++i) { - frags[i].col -= col1; - } - } -} - -int TextPage::dumpFragment(Unicode *text, int len, UnicodeMap *uMap, - GooString *s) { - char lre[8], rle[8], popdf[8], buf[8]; - int lreLen, rleLen, popdfLen, n; - int nCols, i, j, k; - - nCols = 0; - - if (uMap->isUnicode()) { - - lreLen = uMap->mapUnicode(0x202a, lre, sizeof(lre)); - rleLen = uMap->mapUnicode(0x202b, rle, sizeof(rle)); - popdfLen = uMap->mapUnicode(0x202c, popdf, sizeof(popdf)); - - if (primaryLR) { - - i = 0; - while (i < len) { - // output a left-to-right section - for (j = i; j < len && !unicodeTypeR(text[j]); ++j) ; - for (k = i; k < j; ++k) { - n = uMap->mapUnicode(text[k], buf, sizeof(buf)); - s->append(buf, n); - ++nCols; - } - i = j; - // output a right-to-left section - for (j = i; - j < len && !(unicodeTypeL(text[j]) || unicodeTypeNum(text[j])); - ++j) ; - if (j > i) { - s->append(rle, rleLen); - for (k = j - 1; k >= i; --k) { - n = uMap->mapUnicode(text[k], buf, sizeof(buf)); - s->append(buf, n); - ++nCols; - } - s->append(popdf, popdfLen); - i = j; - } - } - - } else { - - // Note: This code treats numeric characters (European and - // Arabic/Indic) as left-to-right, which isn't strictly correct - // (incurs extra LRE/POPDF pairs), but does produce correct - // visual formatting. - s->append(rle, rleLen); - i = len - 1; - while (i >= 0) { - // output a right-to-left section - for (j = i; - j >= 0 && !(unicodeTypeL(text[j]) || unicodeTypeNum(text[j])); - --j) ; - for (k = i; k > j; --k) { - n = uMap->mapUnicode(text[k], buf, sizeof(buf)); - s->append(buf, n); - ++nCols; - } - i = j; - // output a left-to-right section - for (j = i; j >= 0 && !unicodeTypeR(text[j]); --j) ; - if (j < i) { - s->append(lre, lreLen); - for (k = j + 1; k <= i; ++k) { - n = uMap->mapUnicode(text[k], buf, sizeof(buf)); - s->append(buf, n); - ++nCols; - } - s->append(popdf, popdfLen); - i = j; - } - } - s->append(popdf, popdfLen); - - } - - } else { - for (i = 0; i < len; ++i) { - n = uMap->mapUnicode(text[i], buf, sizeof(buf)); - s->append(buf, n); - nCols += n; - } - } - - return nCols; -} - -#if TEXTOUT_WORD_LIST -TextWordList *TextPage::makeWordList(GBool physLayout) { - return new TextWordList(this, physLayout); -} -#endif - -//------------------------------------------------------------------------ -// ActualText -//------------------------------------------------------------------------ -ActualText::ActualText(TextPage *out) { - out->incRefCnt(); - text = out; - actualText = NULL; - actualTextNBytes = 0; -} - -ActualText::~ActualText() { - if (actualText) - delete actualText; - text->decRefCnt(); -} - -void ActualText::addChar(GfxState *state, double x, double y, - double dx, double dy, - CharCode c, int nBytes, Unicode *u, int uLen) { - if (!actualText) { - text->addChar(state, x, y, dx, dy, c, nBytes, u, uLen); - return; - } - - // Inside ActualText span. - if (!actualTextNBytes) { - actualTextX0 = x; - actualTextY0 = y; - } - actualTextX1 = x + dx; - actualTextY1 = y + dy; - actualTextNBytes += nBytes; -} - -void ActualText::begin(GfxState *state, GooString *text) { - if (actualText) - delete actualText; - actualText = new GooString(text); - actualTextNBytes = 0; -} - -void ActualText::end(GfxState *state) { - // ActualText span closed. Output the span text and the - // extents of all the glyphs inside the span - - if (actualTextNBytes) { - Unicode *uni = NULL; - int length; - - // now that we have the position info for all of the text inside - // the marked content span, we feed the "ActualText" back through - // text->addChar() - length = TextStringToUCS4(actualText, &uni); - text->addChar(state, actualTextX0, actualTextY0, - actualTextX1 - actualTextX0, actualTextY1 - actualTextY0, - 0, actualTextNBytes, uni, length); - gfree(uni); - } - - delete actualText; - actualText = NULL; - actualTextNBytes = 0; -} - -//------------------------------------------------------------------------ -// TextOutputDev -//------------------------------------------------------------------------ - -static void TextOutputDev_outputToFile(void *stream, const char *text, int len) { - fwrite(text, 1, len, (FILE *)stream); -} - -TextOutputDev::TextOutputDev(char *fileName, GBool physLayoutA, - double fixedPitchA, GBool rawOrderA, - GBool append) { - text = NULL; - physLayout = physLayoutA; - fixedPitch = physLayout ? fixedPitchA : 0; - rawOrder = rawOrderA; - doHTML = gFalse; - ok = gTrue; - - // open file - needClose = gFalse; - if (fileName) { - if (!strcmp(fileName, "-")) { - outputStream = stdout; -#ifdef _WIN32 - // keep DOS from munging the end-of-line characters - setmode(fileno(stdout), O_BINARY); -#endif - } else if ((outputStream = fopen(fileName, append ? "ab" : "wb"))) { - needClose = gTrue; - } else { - error(errIO, -1, "Couldn't open text file '{0:s}'", fileName); - ok = gFalse; - actualText = NULL; - return; - } - outputFunc = &TextOutputDev_outputToFile; - } else { - outputStream = NULL; - } - - // set up text object - text = new TextPage(rawOrderA); - actualText = new ActualText(text); -} - -TextOutputDev::TextOutputDev(TextOutputFunc func, void *stream, - GBool physLayoutA, double fixedPitchA, - GBool rawOrderA) { - outputFunc = func; - outputStream = stream; - needClose = gFalse; - physLayout = physLayoutA; - fixedPitch = physLayout ? fixedPitchA : 0; - rawOrder = rawOrderA; - doHTML = gFalse; - text = new TextPage(rawOrderA); - actualText = new ActualText(text); - ok = gTrue; -} - -TextOutputDev::~TextOutputDev() { - if (needClose) { -#ifdef MACOS - ICS_MapRefNumAndAssign((short)((FILE *)outputStream)->handle); -#endif - fclose((FILE *)outputStream); - } - if (text) { - text->decRefCnt(); - } - delete actualText; -} - -void TextOutputDev::startPage(int pageNum, GfxState *state, XRef *xref) { - text->startPage(state); -} - -void TextOutputDev::endPage() { - text->endPage(); - text->coalesce(physLayout, fixedPitch, doHTML); - if (outputStream) { - text->dump(outputStream, outputFunc, physLayout); - } -} - -void TextOutputDev::restoreState(GfxState *state) { - text->updateFont(state); -} - -void TextOutputDev::updateFont(GfxState *state) { - text->updateFont(state); -} - -void TextOutputDev::beginString(GfxState *state, GooString *s) { -} - -void TextOutputDev::endString(GfxState *state) { -} - -void TextOutputDev::drawChar(GfxState *state, double x, double y, - double dx, double dy, - double originX, double originY, - CharCode c, int nBytes, Unicode *u, int uLen) { - actualText->addChar(state, x, y, dx, dy, c, nBytes, u, uLen); -} - -void TextOutputDev::incCharCount(int nChars) { - text->incCharCount(nChars); -} - -void TextOutputDev::beginActualText(GfxState *state, GooString *text) -{ - actualText->begin(state, text); -} - -void TextOutputDev::endActualText(GfxState *state) -{ - actualText->end(state); -} - -void TextOutputDev::stroke(GfxState *state) { - GfxPath *path; - GfxSubpath *subpath; - double x[2], y[2]; - - if (!doHTML) { - return; - } - path = state->getPath(); - if (path->getNumSubpaths() != 1) { - return; - } - subpath = path->getSubpath(0); - if (subpath->getNumPoints() != 2) { - return; - } - state->transform(subpath->getX(0), subpath->getY(0), &x[0], &y[0]); - state->transform(subpath->getX(1), subpath->getY(1), &x[1], &y[1]); - - // look for a vertical or horizontal line - if (x[0] == x[1] || y[0] == y[1]) { - text->addUnderline(x[0], y[0], x[1], y[1]); - } -} - -void TextOutputDev::fill(GfxState *state) { - GfxPath *path; - GfxSubpath *subpath; - double x[5], y[5]; - double rx0, ry0, rx1, ry1, t; - int i; - - if (!doHTML) { - return; - } - path = state->getPath(); - if (path->getNumSubpaths() != 1) { - return; - } - subpath = path->getSubpath(0); - if (subpath->getNumPoints() != 5) { - return; - } - for (i = 0; i < 5; ++i) { - if (subpath->getCurve(i)) { - return; - } - state->transform(subpath->getX(i), subpath->getY(i), &x[i], &y[i]); - } - - // look for a rectangle - if (x[0] == x[1] && y[1] == y[2] && x[2] == x[3] && y[3] == y[4] && - x[0] == x[4] && y[0] == y[4]) { - rx0 = x[0]; - ry0 = y[0]; - rx1 = x[2]; - ry1 = y[1]; - } else if (y[0] == y[1] && x[1] == x[2] && y[2] == y[3] && x[3] == x[4] && - x[0] == x[4] && y[0] == y[4]) { - rx0 = x[0]; - ry0 = y[0]; - rx1 = x[1]; - ry1 = y[2]; - } else { - return; - } - if (rx1 < rx0) { - t = rx0; - rx0 = rx1; - rx1 = t; - } - if (ry1 < ry0) { - t = ry0; - ry0 = ry1; - ry1 = t; - } - - // skinny horizontal rectangle - if (ry1 - ry0 < rx1 - rx0) { - if (ry1 - ry0 < maxUnderlineWidth) { - ry0 = 0.5 * (ry0 + ry1); - text->addUnderline(rx0, ry0, rx1, ry0); - } - - // skinny vertical rectangle - } else { - if (rx1 - rx0 < maxUnderlineWidth) { - rx0 = 0.5 * (rx0 + rx1); - text->addUnderline(rx0, ry0, rx0, ry1); - } - } -} - -void TextOutputDev::eoFill(GfxState *state) { - if (!doHTML) { - return; - } - fill(state); -} - -void TextOutputDev::processLink(AnnotLink *link) { - double x1, y1, x2, y2; - int xMin, yMin, xMax, yMax, x, y; - - if (!doHTML) { - return; - } - link->getRect(&x1, &y1, &x2, &y2); - cvtUserToDev(x1, y1, &x, &y); - xMin = xMax = x; - yMin = yMax = y; - cvtUserToDev(x1, y2, &x, &y); - if (x < xMin) { - xMin = x; - } else if (x > xMax) { - xMax = x; - } - if (y < yMin) { - yMin = y; - } else if (y > yMax) { - yMax = y; - } - cvtUserToDev(x2, y1, &x, &y); - if (x < xMin) { - xMin = x; - } else if (x > xMax) { - xMax = x; - } - if (y < yMin) { - yMin = y; - } else if (y > yMax) { - yMax = y; - } - cvtUserToDev(x2, y2, &x, &y); - if (x < xMin) { - xMin = x; - } else if (x > xMax) { - xMax = x; - } - if (y < yMin) { - yMin = y; - } else if (y > yMax) { - yMax = y; - } - text->addLink(xMin, yMin, xMax, yMax, link); -} - -GBool TextOutputDev::findText(Unicode *s, int len, - GBool startAtTop, GBool stopAtBottom, - GBool startAtLast, GBool stopAtLast, - GBool caseSensitive, GBool backward, - GBool wholeWord, - double *xMin, double *yMin, - double *xMax, double *yMax) { - return text->findText(s, len, startAtTop, stopAtBottom, - startAtLast, stopAtLast, - caseSensitive, backward, wholeWord, - xMin, yMin, xMax, yMax); -} - -GooString *TextOutputDev::getText(double xMin, double yMin, - double xMax, double yMax) { - return text->getText(xMin, yMin, xMax, yMax); -} - -void TextOutputDev::drawSelection(OutputDev *out, - double scale, - int rotation, - PDFRectangle *selection, - SelectionStyle style, - GfxColor *glyph_color, GfxColor *box_color) { - text->drawSelection(out, scale, rotation, selection, style, glyph_color, box_color); -} - -GooList *TextOutputDev::getSelectionRegion(PDFRectangle *selection, - SelectionStyle style, - double scale) { - return text->getSelectionRegion(selection, style, scale); -} - -GooString *TextOutputDev::getSelectionText(PDFRectangle *selection, - SelectionStyle style) -{ - return text->getSelectionText(selection, style); -} - -GBool TextOutputDev::findCharRange(int pos, int length, - double *xMin, double *yMin, - double *xMax, double *yMax) { - return text->findCharRange(pos, length, xMin, yMin, xMax, yMax); -} - -#if TEXTOUT_WORD_LIST -TextWordList *TextOutputDev::makeWordList() { - return text->makeWordList(physLayout); -} -#endif - -TextPage *TextOutputDev::takeText() { - TextPage *ret; - - ret = text; - text = new TextPage(rawOrder); - return ret; -} diff --git a/source/libs/poppler/poppler-0.32.0/poppler/TextOutputDev.h b/source/libs/poppler/poppler-0.32.0/poppler/TextOutputDev.h deleted file mode 100755 index 23fb3b726..000000000 --- a/source/libs/poppler/poppler-0.32.0/poppler/TextOutputDev.h +++ /dev/null @@ -1,851 +0,0 @@ -//======================================================================== -// -// TextOutputDev.h -// -// Copyright 1997-2003 Glyph & Cog, LLC -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2005-2007 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2006 Ed Catmur <ed@catmur.co.uk> -// Copyright (C) 2007, 2008, 2011, 2013 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright (C) 2007 Adrian Johnson <ajohnson@redneon.com> -// Copyright (C) 2008, 2010 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2010 Brian Ewins <brian.ewins@gmail.com> -// Copyright (C) 2012, 2013 Jason Crain <jason@aquaticape.us> -// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> -// -// To see a description of the changes please see the Changelog file that -// came with your tarball or type make ChangeLog if you are building from git -// -//======================================================================== - -#ifndef TEXTOUTPUTDEV_H -#define TEXTOUTPUTDEV_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "poppler-config.h" -#include <stdio.h> -#include "goo/gtypes.h" -#include "GfxFont.h" -#include "GfxState.h" -#include "OutputDev.h" - -class GooString; -class GooList; -class Gfx; -class GfxFont; -class GfxState; -class UnicodeMap; -class AnnotLink; - -class TextWord; -class TextPool; -class TextLine; -class TextLineFrag; -class TextBlock; -class TextFlow; -class TextWordList; -class TextPage; -class TextSelectionVisitor; - -//------------------------------------------------------------------------ - -typedef void (*TextOutputFunc)(void *stream, const char *text, int len); - -enum SelectionStyle { - selectionStyleGlyph, - selectionStyleWord, - selectionStyleLine -}; - -//------------------------------------------------------------------------ -// TextFontInfo -//------------------------------------------------------------------------ - -class TextFontInfo { -public: - - TextFontInfo(GfxState *state); - ~TextFontInfo(); - - GBool matches(GfxState *state); - GBool matches(TextFontInfo *fontInfo); - -#if TEXTOUT_WORD_LIST - // Get the font name (which may be NULL). - GooString *getFontName() { return fontName; } - - // Get font descriptor flags. - GBool isFixedWidth() { return flags & fontFixedWidth; } - GBool isSerif() { return flags & fontSerif; } - GBool isSymbolic() { return flags & fontSymbolic; } - GBool isItalic() { return flags & fontItalic; } - GBool isBold() { return flags & fontBold; } -#endif - -private: - - GfxFont *gfxFont; -#if TEXTOUT_WORD_LIST - GooString *fontName; - int flags; -#endif - - friend class TextWord; - friend class TextPage; - friend class TextSelectionPainter; -}; - -//------------------------------------------------------------------------ -// TextWord -//------------------------------------------------------------------------ - -class TextWord { -public: - - // Constructor. - TextWord(GfxState *state, int rotA, double fontSize); - - // Destructor. - ~TextWord(); - - // Add a character to the word. - void addChar(GfxState *state, TextFontInfo *fontA, double x, double y, - double dx, double dy, int charPosA, int charLen, - CharCode c, Unicode u, Matrix textMatA); - - // Merge <word> onto the end of <this>. - void merge(TextWord *word); - - // Compares <this> to <word>, returning -1 (<), 0 (=), or +1 (>), - // based on a primary-axis comparison, e.g., x ordering if rot=0. - int primaryCmp(TextWord *word); - - // Return the distance along the primary axis between <this> and - // <word>. - double primaryDelta(TextWord *word); - - static int cmpYX(const void *p1, const void *p2); - - void visitSelection(TextSelectionVisitor *visitor, - PDFRectangle *selection, - SelectionStyle style); - - // Get the TextFontInfo object associated with a character. - TextFontInfo *getFontInfo(int idx) { return font[idx]; } - - // Get the next TextWord on the linked list. - TextWord *getNext() { return next; } - -#if TEXTOUT_WORD_LIST - int getLength() { return len; } - const Unicode *getChar(int idx) { return &text[idx]; } - GooString *getText(); - GooString *getFontName(int idx) { return font[idx]->fontName; } - void getColor(double *r, double *g, double *b) - { *r = colorR; *g = colorG; *b = colorB; } - void getBBox(double *xMinA, double *yMinA, double *xMaxA, double *yMaxA) - { *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; } - void getCharBBox(int charIdx, double *xMinA, double *yMinA, - double *xMaxA, double *yMaxA); - double getFontSize() { return fontSize; } - int getRotation() { return rot; } - int getCharPos() { return charPos[0]; } - int getCharLen() { return charPos[len] - charPos[0]; } - GBool getSpaceAfter() { return spaceAfter; } -#endif - GBool isUnderlined() { return underlined; } - AnnotLink *getLink() { return link; } - double getEdge(int i) { return edge[i]; } - double getBaseline () { return base; } - GBool hasSpaceAfter () { return spaceAfter; } - TextWord* nextWord () { return next; }; -private: - - int rot; // rotation, multiple of 90 degrees - // (0, 1, 2, or 3) - double xMin, xMax; // bounding box x coordinates - double yMin, yMax; // bounding box y coordinates - double base; // baseline x or y coordinate - Unicode *text; // the text - CharCode *charcode; // glyph indices - double *edge; // "near" edge x or y coord of each char - // (plus one extra entry for the last char) - int *charPos; // character position (within content stream) - // of each char (plus one extra entry for - // the last char) - int len; // length of text/edge/charPos/font arrays - int size; // size of text/edge/charPos/font arrays - TextFontInfo **font; // font information for each char - Matrix *textMat; // transformation matrix for each char - double fontSize; // font size - GBool spaceAfter; // set if there is a space between this - // word and the next word on the line - TextWord *next; // next word in line - int wMode; // horizontal (0) or vertical (1) writing mode - -#if TEXTOUT_WORD_LIST - double colorR, // word color - colorG, - colorB; -#endif - - GBool underlined; - AnnotLink *link; - - friend class TextPool; - friend class TextLine; - friend class TextBlock; - friend class TextFlow; - friend class TextWordList; - friend class TextPage; - - friend class TextSelectionPainter; - friend class TextSelectionDumper; -}; - -//------------------------------------------------------------------------ -// TextPool -//------------------------------------------------------------------------ - -class TextPool { -public: - - TextPool(); - ~TextPool(); - - TextWord *getPool(int baseIdx) { return pool[baseIdx - minBaseIdx]; } - void setPool(int baseIdx, TextWord *p) { pool[baseIdx - minBaseIdx] = p; } - - int getBaseIdx(double base); - - void addWord(TextWord *word); - -private: - - int minBaseIdx; // min baseline bucket index - int maxBaseIdx; // max baseline bucket index - TextWord **pool; // array of linked lists, one for each - // baseline value (multiple of 4 pts) - TextWord *cursor; // pointer to last-accessed word - int cursorBaseIdx; // baseline bucket index of last-accessed word - - friend class TextBlock; - friend class TextPage; -}; - -struct TextFlowData; - -//------------------------------------------------------------------------ -// TextLine -//------------------------------------------------------------------------ - -class TextLine { -public: - - TextLine(TextBlock *blkA, int rotA, double baseA); - ~TextLine(); - - void addWord(TextWord *word); - - // Return the distance along the primary axis between <this> and - // <line>. - double primaryDelta(TextLine *line); - - // Compares <this> to <line>, returning -1 (<), 0 (=), or +1 (>), - // based on a primary-axis comparison, e.g., x ordering if rot=0. - int primaryCmp(TextLine *line); - - // Compares <this> to <line>, returning -1 (<), 0 (=), or +1 (>), - // based on a secondary-axis comparison of the baselines, e.g., y - // ordering if rot=0. - int secondaryCmp(TextLine *line); - - int cmpYX(TextLine *line); - - static int cmpXY(const void *p1, const void *p2); - - void coalesce(UnicodeMap *uMap); - - void visitSelection(TextSelectionVisitor *visitor, - PDFRectangle *selection, - SelectionStyle style); - - // Get the head of the linked list of TextWords. - TextWord *getWords() { return words; } - - // Get the next TextLine on the linked list. - TextLine *getNext() { return next; } - - // Returns true if the last char of the line is a hyphen. - GBool isHyphenated() { return hyphenated; } - -private: - - TextBlock *blk; // parent block - int rot; // text rotation - double xMin, xMax; // bounding box x coordinates - double yMin, yMax; // bounding box y coordinates - double base; // baseline x or y coordinate - TextWord *words; // words in this line - TextWord *lastWord; // last word in this line - Unicode *text; // Unicode text of the line, including - // spaces between words - double *edge; // "near" edge x or y coord of each char - // (plus one extra entry for the last char) - int *col; // starting column number of each Unicode char - int len; // number of Unicode chars - int convertedLen; // total number of converted characters - GBool hyphenated; // set if last char is a hyphen - TextLine *next; // next line in block - Unicode *normalized; // normalized form of Unicode text - int normalized_len; // number of normalized Unicode chars - int *normalized_idx; // indices of normalized chars into Unicode text - - friend class TextLineFrag; - friend class TextBlock; - friend class TextFlow; - friend class TextWordList; - friend class TextPage; - - friend class TextSelectionPainter; - friend class TextSelectionSizer; - friend class TextSelectionDumper; -}; - -//------------------------------------------------------------------------ -// TextBlock -//------------------------------------------------------------------------ - -class TextBlock { -public: - - TextBlock(TextPage *pageA, int rotA); - ~TextBlock(); - - void addWord(TextWord *word); - - void coalesce(UnicodeMap *uMap, double fixedPitch); - - // Update this block's priMin and priMax values, looking at <blk>. - void updatePriMinMax(TextBlock *blk); - - static int cmpXYPrimaryRot(const void *p1, const void *p2); - - static int cmpYXPrimaryRot(const void *p1, const void *p2); - - int primaryCmp(TextBlock *blk); - - double secondaryDelta(TextBlock *blk); - - // Returns true if <this> is below <blk>, relative to the page's - // primary rotation. - GBool isBelow(TextBlock *blk); - - void visitSelection(TextSelectionVisitor *visitor, - PDFRectangle *selection, - SelectionStyle style); - - // Get the head of the linked list of TextLines. - TextLine *getLines() { return lines; } - - // Get the next TextBlock on the linked list. - TextBlock *getNext() { return next; } - - void getBBox(double *xMinA, double *yMinA, double *xMaxA, double *yMaxA) - { *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; } - - int getLineCount() { return nLines; } - -private: - - GBool isBeforeByRule1(TextBlock *blk1); - GBool isBeforeByRepeatedRule1(TextBlock *blkList, TextBlock *blk1); - GBool isBeforeByRule2(TextBlock *blk1); - - int visitDepthFirst(TextBlock *blkList, int pos1, - TextBlock **sorted, int sortPos, - GBool* visited); - - TextPage *page; // the parent page - int rot; // text rotation - double xMin, xMax; // bounding box x coordinates - double yMin, yMax; // bounding box y coordinates - double priMin, priMax; // whitespace bounding box along primary axis - double ExMin, ExMax; // extended bounding box x coordinates - double EyMin, EyMax; // extended bounding box y coordinates - int tableId; // id of table to which this block belongs - GBool tableEnd; // is this block at end of line of actual table - - TextPool *pool; // pool of words (used only until lines - // are built) - TextLine *lines; // linked list of lines - TextLine *curLine; // most recently added line - int nLines; // number of lines - int charCount; // number of characters in the block - int col; // starting column - int nColumns; // number of columns in the block - - TextBlock *next; - TextBlock *stackNext; - - friend class TextLine; - friend class TextLineFrag; - friend class TextFlow; - friend class TextWordList; - friend class TextPage; - friend class TextSelectionPainter; - friend class TextSelectionDumper; -}; - -//------------------------------------------------------------------------ -// TextFlow -//------------------------------------------------------------------------ - -class TextFlow { -public: - - TextFlow(TextPage *pageA, TextBlock *blk); - ~TextFlow(); - - // Add a block to the end of this flow. - void addBlock(TextBlock *blk); - - // Returns true if <blk> fits below <prevBlk> in the flow, i.e., (1) - // it uses a font no larger than the last block added to the flow, - // and (2) it fits within the flow's [priMin, priMax] along the - // primary axis. - GBool blockFits(TextBlock *blk, TextBlock *prevBlk); - - // Get the head of the linked list of TextBlocks. - TextBlock *getBlocks() { return blocks; } - - // Get the next TextFlow on the linked list. - TextFlow *getNext() { return next; } - -private: - - TextPage *page; // the parent page - double xMin, xMax; // bounding box x coordinates - double yMin, yMax; // bounding box y coordinates - double priMin, priMax; // whitespace bounding box along primary axis - TextBlock *blocks; // blocks in flow - TextBlock *lastBlk; // last block in this flow - TextFlow *next; - - friend class TextWordList; - friend class TextPage; -}; - -#if TEXTOUT_WORD_LIST - -//------------------------------------------------------------------------ -// TextWordList -//------------------------------------------------------------------------ - -class TextWordList { -public: - - // Build a flat word list, in content stream order (if - // text->rawOrder is true), physical layout order (if <physLayout> - // is true and text->rawOrder is false), or reading order (if both - // flags are false). - TextWordList(TextPage *text, GBool physLayout); - - ~TextWordList(); - - // Return the number of words on the list. - int getLength(); - - // Return the <idx>th word from the list. - TextWord *get(int idx); - -private: - - GooList *words; // [TextWord] -}; - -#endif // TEXTOUT_WORD_LIST - -class TextWordSelection { -public: - TextWordSelection(TextWord *word, int begin, int end) - : word(word), begin(begin), end(end) - { - } - - TextWord * getWord() const { return word; } - int getBegin() const { return begin; } - int getEnd() const { return end; } - -private: - TextWord *word; - int begin; - int end; - - friend class TextSelectionPainter; - friend class TextSelectionDumper; -}; - -//------------------------------------------------------------------------ -// TextPage -//------------------------------------------------------------------------ - -class TextPage { -public: - - // Constructor. - TextPage(GBool rawOrderA); - - void incRefCnt(); - void decRefCnt(); - - // Start a new page. - void startPage(GfxState *state); - - // End the current page. - void endPage(); - - // Update the current font. - void updateFont(GfxState *state); - - // Begin a new word. - void beginWord(GfxState *state); - - // Add a character to the current word. - void addChar(GfxState *state, double x, double y, - double dx, double dy, - CharCode c, int nBytes, Unicode *u, int uLen); - - // Add <nChars> invisible characters. - void incCharCount(int nChars); - - // End the current word, sorting it into the list of words. - void endWord(); - - // Add a word, sorting it into the list of words. - void addWord(TextWord *word); - - // Add a (potential) underline. - void addUnderline(double x0, double y0, double x1, double y1); - - // Add a hyperlink. - void addLink(int xMin, int yMin, int xMax, int yMax, AnnotLink *link); - - // Coalesce strings that look like parts of the same line. - void coalesce(GBool physLayout, double fixedPitch, GBool doHTML); - - // Find a string. If <startAtTop> is true, starts looking at the - // top of the page; else if <startAtLast> is true, starts looking - // immediately after the last find result; else starts looking at - // <xMin>,<yMin>. If <stopAtBottom> is true, stops looking at the - // bottom of the page; else if <stopAtLast> is true, stops looking - // just before the last find result; else stops looking at - // <xMax>,<yMax>. - GBool findText(Unicode *s, int len, - GBool startAtTop, GBool stopAtBottom, - GBool startAtLast, GBool stopAtLast, - GBool caseSensitive, GBool backward, - GBool wholeWord, - double *xMin, double *yMin, - double *xMax, double *yMax); - - // Get the text which is inside the specified rectangle. - GooString *getText(double xMin, double yMin, - double xMax, double yMax); - - void visitSelection(TextSelectionVisitor *visitor, - PDFRectangle *selection, - SelectionStyle style); - - void drawSelection(OutputDev *out, - double scale, - int rotation, - PDFRectangle *selection, - SelectionStyle style, - GfxColor *glyph_color, GfxColor *box_color); - - GooList *getSelectionRegion(PDFRectangle *selection, - SelectionStyle style, - double scale); - - GooString *getSelectionText(PDFRectangle *selection, - SelectionStyle style); - - GooList **getSelectionWords(PDFRectangle *selection, - SelectionStyle style, - int *nLines); - - // Find a string by character position and length. If found, sets - // the text bounding rectangle and returns true; otherwise returns - // false. - GBool findCharRange(int pos, int length, - double *xMin, double *yMin, - double *xMax, double *yMax); - - // Dump contents of page to a file. - void dump(void *outputStream, TextOutputFunc outputFunc, - GBool physLayout); - - // Get the head of the linked list of TextFlows. - TextFlow *getFlows() { return flows; } - -#if TEXTOUT_WORD_LIST - // Build a flat word list, in content stream order (if - // this->rawOrder is true), physical layout order (if <physLayout> - // is true and this->rawOrder is false), or reading order (if both - // flags are false). - TextWordList *makeWordList(GBool physLayout); -#endif - -private: - - // Destructor. - ~TextPage(); - - void clear(); - void assignColumns(TextLineFrag *frags, int nFrags, GBool rot); - int dumpFragment(Unicode *text, int len, UnicodeMap *uMap, GooString *s); - - GBool rawOrder; // keep text in content stream order - - double pageWidth, pageHeight; // width and height of current page - TextWord *curWord; // currently active string - int charPos; // next character position (within content - // stream) - TextFontInfo *curFont; // current font - double curFontSize; // current font size - int nest; // current nesting level (for Type 3 fonts) - int nTinyChars; // number of "tiny" chars seen so far - GBool lastCharOverlap; // set if the last added char overlapped the - // previous char - - TextPool *pools[4]; // a "pool" of TextWords for each rotation - TextFlow *flows; // linked list of flows - TextBlock **blocks; // array of blocks, in yx order - int nBlocks; // number of blocks - int primaryRot; // primary rotation - GBool primaryLR; // primary direction (true means L-to-R, - // false means R-to-L) - TextWord *rawWords; // list of words, in raw order (only if - // rawOrder is set) - TextWord *rawLastWord; // last word on rawWords list - - GooList *fonts; // all font info objects used on this - // page [TextFontInfo] - - double lastFindXMin, // coordinates of the last "find" result - lastFindYMin; - GBool haveLastFind; - - GooList *underlines; // [TextUnderline] - GooList *links; // [TextLink] - - int refCnt; - - friend class TextLine; - friend class TextLineFrag; - friend class TextBlock; - friend class TextFlow; - friend class TextWordList; - friend class TextSelectionPainter; - friend class TextSelectionDumper; -}; - -//------------------------------------------------------------------------ -// ActualText -//------------------------------------------------------------------------ - -class ActualText { -public: - // Create an ActualText - ActualText(TextPage *out); - ~ActualText(); - - void addChar(GfxState *state, double x, double y, - double dx, double dy, - CharCode c, int nBytes, Unicode *u, int uLen); - void begin(GfxState *state, GooString *text); - void end(GfxState *state); - -private: - TextPage *text; - - GooString *actualText; // replacement text for the span - double actualTextX0; - double actualTextY0; - double actualTextX1; - double actualTextY1; - int actualTextNBytes; -}; - - -//------------------------------------------------------------------------ -// TextOutputDev -//------------------------------------------------------------------------ - -class TextOutputDev: public OutputDev { -public: - - // Open a text output file. If <fileName> is NULL, no file is - // written (this is useful, e.g., for searching text). If - // <physLayoutA> is true, the original physical layout of the text - // is maintained. If <rawOrder> is true, the text is kept in - // content stream order. - TextOutputDev(char *fileName, GBool physLayoutA, - double fixedPitchA, GBool rawOrderA, - GBool append); - - // Create a TextOutputDev which will write to a generic stream. If - // <physLayoutA> is true, the original physical layout of the text - // is maintained. If <rawOrder> is true, the text is kept in - // content stream order. - TextOutputDev(TextOutputFunc func, void *stream, - GBool physLayoutA, double fixedPitchA, - GBool rawOrderA); - - // Destructor. - virtual ~TextOutputDev(); - - // Check if file was successfully created. - virtual GBool isOk() { return ok; } - - //---- get info about output device - - // Does this device use upside-down coordinates? - // (Upside-down means (0,0) is the top left corner of the page.) - virtual GBool upsideDown() { return gTrue; } - - // Does this device use drawChar() or drawString()? - virtual GBool useDrawChar() { return gTrue; } - - // Does this device use beginType3Char/endType3Char? Otherwise, - // text in Type 3 fonts will be drawn with drawChar/drawString. - virtual GBool interpretType3Chars() { return gFalse; } - - // Does this device need non-text content? - virtual GBool needNonText() { return gFalse; } - - // Does this device require incCharCount to be called for text on - // non-shown layers? - virtual GBool needCharCount() { return gTrue; } - - //----- initialization and control - - // Start a page. - virtual void startPage(int pageNum, GfxState *state, XRef *xref); - - // End a page. - virtual void endPage(); - - //----- save/restore graphics state - virtual void restoreState(GfxState *state); - - //----- update text state - virtual void updateFont(GfxState *state); - - //----- text drawing - virtual void beginString(GfxState *state, GooString *s); - virtual void endString(GfxState *state); - virtual void drawChar(GfxState *state, double x, double y, - double dx, double dy, - double originX, double originY, - CharCode c, int nBytes, Unicode *u, int uLen); - virtual void incCharCount(int nChars); - virtual void beginActualText(GfxState *state, GooString *text); - virtual void endActualText(GfxState *state); - - //----- path painting - virtual void stroke(GfxState *state); - virtual void fill(GfxState *state); - virtual void eoFill(GfxState *state); - - //----- link borders - virtual void processLink(AnnotLink *link); - - //----- special access - - // Find a string. If <startAtTop> is true, starts looking at the - // top of the page; else if <startAtLast> is true, starts looking - // immediately after the last find result; else starts looking at - // <xMin>,<yMin>. If <stopAtBottom> is true, stops looking at the - // bottom of the page; else if <stopAtLast> is true, stops looking - // just before the last find result; else stops looking at - // <xMax>,<yMax>. - GBool findText(Unicode *s, int len, - GBool startAtTop, GBool stopAtBottom, - GBool startAtLast, GBool stopAtLast, - GBool caseSensitive, GBool backward, - GBool wholeWord, - double *xMin, double *yMin, - double *xMax, double *yMax); - - // Get the text which is inside the specified rectangle. - GooString *getText(double xMin, double yMin, - double xMax, double yMax); - - // Find a string by character position and length. If found, sets - // the text bounding rectangle and returns true; otherwise returns - // false. - GBool findCharRange(int pos, int length, - double *xMin, double *yMin, - double *xMax, double *yMax); - - void drawSelection(OutputDev *out, double scale, int rotation, - PDFRectangle *selection, - SelectionStyle style, - GfxColor *glyph_color, GfxColor *box_color); - - GooList *getSelectionRegion(PDFRectangle *selection, - SelectionStyle style, - double scale); - - GooString *getSelectionText(PDFRectangle *selection, - SelectionStyle style); - -#if TEXTOUT_WORD_LIST - // Build a flat word list, in content stream order (if - // this->rawOrder is true), physical layout order (if - // this->physLayout is true and this->rawOrder is false), or reading - // order (if both flags are false). - TextWordList *makeWordList(); -#endif - - // Returns the TextPage object for the last rasterized page, - // transferring ownership to the caller. - TextPage *takeText(); - - // Turn extra processing for HTML conversion on or off. - void enableHTMLExtras(GBool doHTMLA) { doHTML = doHTMLA; } - -private: - - TextOutputFunc outputFunc; // output function - void *outputStream; // output stream - GBool needClose; // need to close the output file? - // (only if outputStream is a FILE*) - TextPage *text; // text for the current page - GBool physLayout; // maintain original physical layout when - // dumping text - double fixedPitch; // if physLayout is true and this is non-zero, - // assume fixed-pitch characters with this - // width - GBool rawOrder; // keep text in content stream order - GBool doHTML; // extra processing for HTML conversion - GBool ok; // set up ok? - - ActualText *actualText; -}; - -#endif diff --git a/source/libs/poppler/poppler-0.33.0-PATCHES/ChangeLog b/source/libs/poppler/poppler-0.33.0-PATCHES/ChangeLog new file mode 100644 index 000000000..6a2495cc2 --- /dev/null +++ b/source/libs/poppler/poppler-0.33.0-PATCHES/ChangeLog @@ -0,0 +1,263 @@ +2015-06-12 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.33.0 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + +2015-03-08 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.32.0 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + +2015-02-06 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.31.0 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + +2015-01-07 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.30.0 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + +2014-12-05 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.29.0 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + +2014-11-04 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.28.0 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + * patch-10-UTF-16BE (removed): Included upstream. + +2014-10-08 Peter Breitenlohner <peb@mppmu.mpg.de> + + * patch-10-UTF-16BE (new): Backport from poppler git + (submitted by Luigi Scarso <luigi.scarso@gmail.com>). + +2014-09-29 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.26.5 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + +2014-08-22 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.26.4 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + +2014-07-21 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.26.3 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + +2014-06-20 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.26.2 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + +2014-05-24 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.26.1 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + +2014-05-19 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.26.0 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + + * patch-03-NOMINMAX (removed): Now included upstream. + +2014-03-27 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.25.2 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + + * patch-03-NOMINMAX (new): Avoid to redefine NOMINMAX. + +2014-01-03 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.25.1 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + +2013-12-12 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.25.0 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + +2013-12-02 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.24.4 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + +2013-10-28 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.24.3 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + +2013-09-30 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.24.2 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + +2013-09-10 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.24.1 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + +2013-07-30 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.24.0 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + +2013-07-19 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.23.4 source tree from: + http://poppler.freedesktop.org/ + + * patch-02-LLONG_MAX: Adapted. + +2013-07-02 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.23.3 source tree from: + http://poppler.freedesktop.org/ + + * patch-01-MINGW_PRINTF_FORMAT (removed): Now included upstream. + * patch-02-LLONG_MAX: Adapted. + +2013-06-18 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.23.2 source tree from: + http://poppler.freedesktop.org/ + + * patch-01-disable-jpeg (removed): Now included upstream. + * patch-02-warnings (removed): Obsoleted by gcc-4.6. + + * patch-01-MINGW_PRINTF_FORMAT (new): MinGW32 may not define + __MINGW_PRINTF_FORMAT (and __USE_MINGW_ANSI_STDIO could be 0). + * patch-02-LLONG_MAX (new): If necessary define LLONG_MAX etc. + +2013-03-12 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.22.2 source tree from: + http://poppler.freedesktop.org/ + * patch-02-warnings: Adapted. + + * patch-01-disable-jpeg (new): We build without libjpeg. + +2012-12-31 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.22.0 source tree from: + http://poppler.freedesktop.org/ + * patch-02-warnings: Adapted. + +2012-10-15 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.21.0 source tree from: + http://poppler.freedesktop.org/ + * patch-02-warnings: Adapted. + +2012-07-11 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.20.2 source tree from: + http://poppler.freedesktop.org/ + * patch-02-warnings: Adapted. + +2012-05-11 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.20.0 source tree from: + http://poppler.freedesktop.org/ + * patch-01-missing-param (removed): Obsolete. + * patch-02-warnings: Adapted. + +2012-05-09 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.19.4 source tree from: + http://poppler.freedesktop.org/ + * patch-03-POPPLER_VERSION (removed): Obsolete. + * patch-01-missing-param (new): Bug fix, missing new func param. + * patch-02-warnings: Adapted. + +2012-02-23 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.18.4 source tree from: + http://poppler.freedesktop.org/ + * patch-01-PDF_PARSER_ONLY (removed): Obsolete. + * patch-0[23]-*: Adapted. + +2011-10-18 Peter Breitenlohner <peb@mppmu.mpg.de> + + * patch-04-mingw (removed): Instead add `-lgdi32'. + +2011-10-11 Peter Breitenlohner <peb@mppmu.mpg.de> + + * patch-04-mingw (new): Split off ... + * patch-01-PDF_PARSER_ONLY: ... from here. + +2011-10-10 Peter Breitenlohner <peb@mppmu.mpg.de> + + * patch-03-POPPLER_VERSION: Reorg definition of POPPLER_VERSION. + +2011-10-08 Peter Breitenlohner <peb@mppmu.mpg.de> + + Imported poppler-0.18.0 source tree from: + http://poppler.freedesktop.org/ + * patch-0[123]-*: Adapted. + +2011-04-14 Peter Breitenlohner <peb@mppmu.mpg.de> + + * patch-01-PDF_PARSER_ONLY: Fix PDF_PARSER_ONLY for MinGW. + + * patch-03-POPPLER_VERSION (new): #define POPPLER_VERSION. + +2011-04-12 Peter Breitenlohner <peb@mppmu.mpg.de> + + * patch-02-warnings (new): + poppler/Movie.cc: Cast -1 to Gulong. + goo/PNGWriter.h: Add newline at end of file. + +2011-04-12 Taco Hoekwater <taco@luatex.org> + + Imported poppler-0.12.4 source tree from: + http://poppler.freedesktop.org/ + + * patch-01-PDF_PARSER_ONLY (new): Implement PDF_PARSER_ONLY. + diff --git a/source/libs/poppler/poppler-0.33.0-PATCHES/TL-Changes b/source/libs/poppler/poppler-0.33.0-PATCHES/TL-Changes new file mode 100644 index 000000000..7c0f1e745 --- /dev/null +++ b/source/libs/poppler/poppler-0.33.0-PATCHES/TL-Changes @@ -0,0 +1,30 @@ +Changes applied to the poppler-0.33.0 tree as obtained from: + http://poppler.freedesktop.org/ + +Removed: + Makefile.in + aclocal.m4 + compile + config.guess + config.sub + configure + depcomp + install-sh + ltmain.sh + missing + test-driver + fofi/Makefile.in + goo/Makefile.in + poppler/Makefile.in + splash/Makefile.in + +Removed unused dirs: + cmake + cpp + glib + m4 + qt4 + qt5 + test + utils + diff --git a/source/libs/poppler/poppler-0.33.0-PATCHES/patch-02-LLONG_MAX b/source/libs/poppler/poppler-0.33.0-PATCHES/patch-02-LLONG_MAX new file mode 100644 index 000000000..aba3105f8 --- /dev/null +++ b/source/libs/poppler/poppler-0.33.0-PATCHES/patch-02-LLONG_MAX @@ -0,0 +1,25 @@ +diff -ur poppler-0.33.0.orig/goo/GooString.h poppler-0.33.0/goo/GooString.h +--- poppler-0.33.0.orig/goo/GooString.h 2014-10-07 22:41:15.000000000 +0200 ++++ poppler-0.33.0/goo/GooString.h 2014-11-04 10:20:40.567904859 +0100 +@@ -34,6 +34,21 @@ + #endif + + #include <limits.h> // for LLONG_MAX and ULLONG_MAX ++ ++/* <limits.h> and/or the compiler may or may not define these. */ ++/* Minimum and maximum values a `signed long long int' can hold. */ ++#ifndef LLONG_MAX ++# define LLONG_MAX 9223372036854775807LL ++#endif ++#ifndef LLONG_MIN ++# define LLONG_MIN (-LLONG_MAX - 1LL) ++#endif ++ ++/* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */ ++#ifndef ULLONG_MAX ++# define ULLONG_MAX 18446744073709551615ULL ++#endif ++ + #include <stdarg.h> + #include <stdlib.h> // for NULL + #include "gtypes.h" diff --git a/source/libs/poppler/poppler-0.32.0/AUTHORS b/source/libs/poppler/poppler-0.33.0/AUTHORS old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/AUTHORS rename to source/libs/poppler/poppler-0.33.0/AUTHORS diff --git a/source/libs/poppler/poppler-0.33.0/CMakeLists.txt b/source/libs/poppler/poppler-0.33.0/CMakeLists.txt new file mode 100644 index 000000000..f77e366fb --- /dev/null +++ b/source/libs/poppler/poppler-0.33.0/CMakeLists.txt @@ -0,0 +1,735 @@ +project(poppler) + +cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR) + +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) + +include(PopplerDefaults) +include(PopplerMacros) +include(MacroOptionalFindPackage) +find_package(PkgConfig) +include(MacroEnsureVersion) +include(MacroBoolTo01) +find_package(Threads) +include(TestBigEndian) +test_big_endian(WORDS_BIGENDIAN) +include(CheckFileOffsetBits) +CHECK_FILE_OFFSET_BITS() + +find_package (ECM 1.6.0 QUIET NO_MODULE) +if (ECM_FOUND) + include("${ECM_MODULE_DIR}/ECMEnableSanitizers.cmake") +endif() + +set(POPPLER_MAJOR_VERSION "0") +set(POPPLER_MINOR_VERSION "33") +set(POPPLER_MICRO_VERSION "0") +set(POPPLER_VERSION "${POPPLER_MAJOR_VERSION}.${POPPLER_MINOR_VERSION}.${POPPLER_MICRO_VERSION}") + +# command line switches +option(ENABLE_XPDF_HEADERS "Install unsupported xpdf headers." OFF) +option(BUILD_GTK_TESTS "Whether compile the GTK+ test programs." ON) +option(BUILD_QT4_TESTS "Whether compile the Qt4 test programs." ON) +option(BUILD_QT5_TESTS "Whether compile the Qt5 test programs." ON) +option(BUILD_CPP_TESTS "Whether compile the CPP test programs." ON) +option(ENABLE_SPLASH "Build the Splash graphics backend." ON) +option(ENABLE_UTILS "Compile poppler command line utils." ON) +option(ENABLE_CPP "Compile poppler cpp wrapper." ON) +set(ENABLE_LIBOPENJPEG "auto" CACHE STRING "Use libopenjpeg for JPX streams. Possible values: auto, openjpeg1, openjpeg2. 'auto' prefers openjpeg1 over openjpeg2 if both are available. Unset to not use openjpeg.") +set(ENABLE_CMS "auto" CACHE STRING "Use color management system. Possible values: auto, lcms1, lcms2. 'auto' prefers lcms2 over lcms1 if both are available. Unset to disable color management system.") +option(ENABLE_LIBCURL "Build libcurl based HTTP support." OFF) +option(ENABLE_ZLIB "Build with zlib (not totally safe)." OFF) +option(USE_FIXEDPOINT "Use fixed point arithmetic in the Splash backend" OFF) +option(USE_FLOAT "Use single precision arithmetic in the Splash backend" OFF) +if(WIN32) + option(ENABLE_RELOCATABLE "Do not hardcode the poppler library location (on Windows)." ON) +else(WIN32) + set(ENABLE_RELOCATABLE OFF) +endif(WIN32) + +set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)") + +set(TESTDATADIR "${CMAKE_SOURCE_DIR}/../test" CACHE STRING "Specify test data dir.") +if(NOT (EXISTS ${TESTDATADIR} AND EXISTS ${TESTDATADIR}/test-poppler.c)) + message(WARNING " + No test data found in $testdatadir. + You will not be able to run 'make test' successfully. + + The test data is not included in the source packages + and is also not part of the main git repository. Instead, + you can checkout the test data from its own git + repository with: + + git clone git://git.freedesktop.org/git/poppler/test + + You should checkout the test data as a sibling of your + poppler source folder or specify the location of your + checkout with -DTESTDATADIR=/path/to/checkoutdir/test. + ") +endif() + +if(WIN32) + set(_default_fontconfiguration "win32") +else(WIN32) + set(_default_fontconfiguration "fontconfig") +endif(WIN32) +set(FONT_CONFIGURATION "${_default_fontconfiguration}" CACHE STRING "The font configuration backend (win32|fontconfig).") +string(TOLOWER "${FONT_CONFIGURATION}" font_configuration) +set(WITH_FONTCONFIGURATION_WIN32 OFF) +set(WITH_FONTCONFIGURATION_FONTCONFIG OFF) +if(font_configuration STREQUAL "win32") + set(WITH_FONTCONFIGURATION_WIN32 ON) +elseif(font_configuration STREQUAL "fontconfig") + set(WITH_FONTCONFIGURATION_FONTCONFIG ON) +else(font_configuration STREQUAL "win32") + message(FATAL_ERROR "Invalid font configuration setting: ${FONT_CONFIGURATION}") +endif(font_configuration STREQUAL "win32") + +# Enable these unconditionally. +set(MULTITHREADED ON) +set(OPI_SUPPORT ON) +set(TEXTOUT_WORD_LIST ON) + +# setting the minimum required versions for some components +set(QT4_MIN_VERSION "4.7.0") +set(CAIRO_VERSION "1.10.0") +set(GLIB_REQUIRED "2.18") + +macro_bool_to_01(ENABLE_SPLASH HAVE_SPLASH) +find_package(Freetype REQUIRED) +if(WITH_FONTCONFIGURATION_FONTCONFIG) + find_package(Fontconfig REQUIRED) +endif(WITH_FONTCONFIGURATION_FONTCONFIG) +macro_optional_find_package(JPEG) +macro_optional_find_package(PNG) +macro_optional_find_package(TIFF) +if(JPEG_FOUND) + set(ENABLE_LIBJPEG ${JPEG_FOUND}) +endif(JPEG_FOUND) +macro_optional_find_package(Qt4) +if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.8.7) + find_package(Qt5Core) + find_package(Qt5Gui) + find_package(Qt5Xml) + find_package(Qt5Widgets) + find_package(Qt5Test) + if (Qt5Core_FOUND AND Qt5Gui_FOUND AND Qt5Xml_FOUND AND Qt5Widgets_FOUND AND Qt5Test_FOUND) + set(QT5_FOUND true) + else () + message("-- Package Qt5Core or Qt5Gui or Qt5Xml or Qt5Widgets or Qt5Test not found") + set(QT5_FOUND false) + endif() +else(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.8.7) + set(QT5_FOUND false) + message("-- CMake >= 2.8.8 is needed to enable Qt5") +endif(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.8.7) + +macro_optional_find_package(Cairo ${CAIRO_VERSION}) +if(CAIRO_FOUND) + set(HAVE_CAIRO ${CAIRO_FOUND}) + set(CAIRO_FEATURE "#define POPPLER_HAS_CAIRO 1") + set(CAIRO_REQ "cairo") + set(POPPLER_GLIB_DISABLE_DEPRECATED "") + set(POPPLER_GLIB_DISABLE_SINGLE_INCLUDES "") + macro_optional_find_package(GLIB) + if(GLIB_FOUND) + set(ENABLE_GLIB ON) + # Check for introspection + macro_optional_find_package(GObjectIntrospection 0.9.12) + set(HAVE_INTROSPECTION ${INTROSPECTION_FOUND}) + set(POPPLER_GLIB_DISABLE_DEPRECATED "${POPPLER_GLIB_DISABLE_DEPRECATED} -DG_DISABLE_DEPRECATED") + set(POPPLER_GLIB_DISABLE_SINGLE_INCLUDES "${POPPLER_GLIB_DISABLE_SINGLE_INCLUDES} -DG_DISABLE_SINGLE_INCLUDES") + macro_optional_find_package(GTK) + endif(GLIB_FOUND) +else(CAIRO_FOUND) + set(CAIRO_FEATURE "#undef POPPLER_HAS_CAIRO") +endif(CAIRO_FOUND) +if(ENABLE_CPP) + macro_optional_find_package(Iconv) + set(ENABLE_CPP ${ICONV_FOUND}) + set(HAVE_ICONV ${ICONV_FOUND}) +endif(ENABLE_CPP) +if(ENABLE_ZLIB) + find_package(ZLIB) + if(ZLIB_FOUND) + set(HAVE_LIBZ ${ZLIB_FOUND}) + endif(ZLIB_FOUND) + set(ENABLE_ZLIB ${ZLIB_FOUND}) +endif(ENABLE_ZLIB) +set(USE_OPENJPEG1 FALSE) +set(USE_OPENJPEG2 FALSE) +if(ENABLE_LIBOPENJPEG STREQUAL "auto") + find_package(LIBOPENJPEG) + set(USE_OPENJPEG1 ${LIBOPENJPEG_FOUND}) + set(WITH_OPENJPEG ${LIBOPENJPEG_FOUND}) + if(NOT LIBOPENJPEG_FOUND) + find_package(LIBOPENJPEG2) + set(USE_OPENJPEG2 ${LIBOPENJPEG2_FOUND}) + set(WITH_OPENJPEG ${LIBOPENJPEG2_FOUND}) + endif() +elseif(ENABLE_LIBOPENJPEG STREQUAL "openjpeg1") + find_package(LIBOPENJPEG) + set(USE_OPENJPEG1 ${LIBOPENJPEG_FOUND}) + set(WITH_OPENJPEG ${LIBOPENJPEG_FOUND}) +elseif(ENABLE_LIBOPENJPEG STREQUAL "openjpeg2") + find_package(LIBOPENJPEG2) + set(USE_OPENJPEG2 ${LIBOPENJPEG2_FOUND}) + set(WITH_OPENJPEG ${LIBOPENJPEG2_FOUND}) +endif() +if(ENABLE_CMS STREQUAL "auto") + find_package(LCMS2) + set(USE_CMS ${LCMS2_FOUND}) + if(NOT LCMS2_FOUND) + find_package(LCMS) + set(USE_CMS ${LCMS_FOUND}) + set(USE_LCMS1 ${LCMS_FOUND}) + endif(NOT LCMS2_FOUND) +elseif(ENABLE_CMS STREQUAL "lcms1") + find_package(LCMS) + set(USE_CMS ${LCMS_FOUND}) + set(USE_LCMS1 ${LCMS_FOUND}) +elseif(ENABLE_CMS STREQUAL "lcms2") + find_package(LCMS2) + set(USE_CMS ${LCMS2_FOUND}) +endif() +if(ENABLE_LIBCURL) + find_package(CURL) + include_directories(${CURL_INCLUDE_DIR}) + set(POPPLER_HAS_CURL_SUPPORT ON) +endif(ENABLE_LIBCURL) + +add_definitions(-DHAVE_CONFIG_H=1) +if(MINGW) + # Use mingw's ansi stdio extensions + add_definitions(-D__USE_MINGW_ANSI_STDIO=1) +endif(MINGW) +if(FONTCONFIG_FOUND) + add_definitions(${FONTCONFIG_DEFINITIONS}) + include_directories(${FONTCONFIG_INCLUDE_DIR}) +endif(FONTCONFIG_FOUND) +if(WITH_FONTCONFIGURATION_WIN32) + if(MINGW) + # Set the minimum required Internet Explorer version to 5.0 + add_definitions(-D_WIN32_IE=0x0500) + endif(MINGW) +endif(WITH_FONTCONFIGURATION_WIN32) +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/fofi + ${CMAKE_CURRENT_SOURCE_DIR}/goo + ${CMAKE_CURRENT_SOURCE_DIR}/poppler + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/poppler + ${FREETYPE_INCLUDE_DIRS} +) +set(HAVE_FREETYPE_H ON) +if(CMAKE_USE_PTHREADS_INIT) + set(HAVE_PTHREAD ON) +endif(CMAKE_USE_PTHREADS_INIT) + +if(ENABLE_ZLIB) + include_directories(${ZLIB_INCLUDE_DIR}) +endif(ENABLE_ZLIB) +if(JPEG_FOUND) + include_directories(${JPEG_INCLUDE_DIR}) + set(ENABLE_LIBJPEG ON) +endif(JPEG_FOUND) +if(PNG_FOUND) + include_directories(${PNG_INCLUDE_DIR}) + set(ENABLE_LIBPNG ON) +endif(PNG_FOUND) +if(TIFF_FOUND) + include_directories(${TIFF_INCLUDE_DIR}) + set(ENABLE_LIBTIFF ON) +endif(TIFF_FOUND) +if(LIBOPENJPEG_FOUND) + include_directories(${LIBOPENJPEG_INCLUDE_DIR}) +endif(LIBOPENJPEG_FOUND) +if(LIBOPENJPEG2_FOUND) + include_directories(${LIBOPENJPEG2_INCLUDE_DIRS}) +endif() +if(LCMS_FOUND) + include_directories(${LCMS_INCLUDE_DIR}) +endif(LCMS_FOUND) +if(LCMS2_FOUND) + include_directories(${LCMS2_INCLUDE_DIR}) +endif(LCMS2_FOUND) + +# Recent versions of poppler-data install a .pc file. +# Use it to determine the encoding data path, if available. +# Default to the same prefix otherwise. +pkg_check_modules(POPPLER_DATA poppler-data) +if(POPPLER_DATA_FOUND) + execute_process(COMMAND "${PKG_CONFIG_EXECUTABLE}" --variable=poppler_datadir poppler-data + RESULT_VARIABLE _result_var + OUTPUT_VARIABLE _output_var OUTPUT_STRIP_TRAILING_WHITESPACE) + if(_result_var STREQUAL "0" AND NOT _output_var STREQUAL "") + set(POPPLER_DATADIR "${_output_var}") + endif(_result_var STREQUAL "0" AND NOT _output_var STREQUAL "") +endif(POPPLER_DATA_FOUND) +if(NOT DEFINED POPPLER_DATADIR) + set(POPPLER_DATADIR "${CMAKE_INSTALL_PREFIX}/share/poppler") +endif(NOT DEFINED POPPLER_DATADIR) + +if(DEFINED COMPILE_WARNINGS) +else(DEFINED COMPILE_WARNINGS) + set(COMPILE_WARNINGS "yes") +endif(DEFINED COMPILE_WARNINGS) +string(TOLOWER "${COMPILE_WARNINGS}" _comp_warnings) +if(_comp_warnings STREQUAL "no") + set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS_NO} ${CMAKE_CXX_FLAGS}") +endif(_comp_warnings STREQUAL "no") +if(_comp_warnings STREQUAL "yes") + set(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS_YES} ${CMAKE_CXX_FLAGS}") +endif(_comp_warnings STREQUAL "yes") +if(_comp_warnings STREQUAL "kde") + set(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS_KDE} ${CMAKE_CXX_FLAGS}") +endif(_comp_warnings STREQUAL "kde") + + +include(ConfigureChecks.cmake) +configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) +configure_file(poppler/poppler-config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/poppler/poppler-config.h) + + +set(poppler_SRCS + goo/gfile.cc + goo/gmempp.cc + goo/GooHash.cc + goo/GooList.cc + goo/GooTimer.cc + goo/GooString.cc + goo/gmem.cc + goo/FixedPoint.cc + goo/NetPBMWriter.cc + goo/PNGWriter.cc + goo/TiffWriter.cc + goo/JpegWriter.cc + goo/ImgWriter.cc + goo/gstrtod.cc + goo/grandom.cc + fofi/FoFiBase.cc + fofi/FoFiEncodings.cc + fofi/FoFiTrueType.cc + fofi/FoFiType1.cc + fofi/FoFiType1C.cc + fofi/FoFiIdentifier.cc + poppler/Annot.cc + poppler/Array.cc + poppler/BuiltinFont.cc + poppler/BuiltinFontTables.cc + poppler/CachedFile.cc + poppler/Catalog.cc + poppler/CharCodeToUnicode.cc + poppler/CMap.cc + poppler/DateInfo.cc + poppler/Decrypt.cc + poppler/Dict.cc + poppler/Error.cc + poppler/FileSpec.cc + poppler/FontEncodingTables.cc + poppler/Form.cc + poppler/FontInfo.cc + poppler/Function.cc + poppler/Gfx.cc + poppler/GfxFont.cc + poppler/GfxState.cc + poppler/GlobalParams.cc + poppler/Hints.cc + poppler/JArithmeticDecoder.cc + poppler/JBIG2Stream.cc + poppler/Lexer.cc + poppler/Link.cc + poppler/Linearization.cc + poppler/LocalPDFDocBuilder.cc + poppler/MarkedContentOutputDev.cc + poppler/NameToCharCode.cc + poppler/Object.cc + poppler/OptionalContent.cc + poppler/Outline.cc + poppler/OutputDev.cc + poppler/Page.cc + poppler/PageTransition.cc + poppler/Parser.cc + poppler/PDFDoc.cc + poppler/PDFDocEncoding.cc + poppler/PDFDocFactory.cc + poppler/PopplerCache.cc + poppler/ProfileData.cc + poppler/PreScanOutputDev.cc + poppler/PSTokenizer.cc + poppler/Stream.cc + poppler/StructTreeRoot.cc + poppler/StructElement.cc + poppler/strtok_r.cpp + poppler/UnicodeMap.cc + poppler/UnicodeTypeTable.cc + poppler/UTF.cc + poppler/XRef.cc + poppler/PSOutputDev.cc + poppler/TextOutputDev.cc + poppler/PageLabelInfo.cc + poppler/SecurityHandler.cc + poppler/StdinCachedFile.cc + poppler/StdinPDFDocBuilder.cc + poppler/Sound.cc + poppler/ViewerPreferences.cc + poppler/XpdfPluginAPI.cc + poppler/Movie.cc + poppler/Rendition.cc +) +set(poppler_LIBS ${FREETYPE_LIBRARIES}) +if(ENABLE_SPLASH) + set(poppler_SRCS ${poppler_SRCS} + poppler/SplashOutputDev.cc + splash/Splash.cc + splash/SplashBitmap.cc + splash/SplashClip.cc + splash/SplashFTFont.cc + splash/SplashFTFontEngine.cc + splash/SplashFTFontFile.cc + splash/SplashFont.cc + splash/SplashFontEngine.cc + splash/SplashFontFile.cc + splash/SplashFontFileID.cc + splash/SplashPath.cc + splash/SplashPattern.cc + splash/SplashScreen.cc + splash/SplashState.cc + splash/SplashT1Font.cc + splash/SplashT1FontEngine.cc + splash/SplashT1FontFile.cc + splash/SplashXPath.cc + splash/SplashXPathScanner.cc + ) +endif(ENABLE_SPLASH) +if(FONTCONFIG_FOUND) + set(poppler_LIBS ${poppler_LIBS} ${FONTCONFIG_LIBRARIES}) +endif(FONTCONFIG_FOUND) +if(JPEG_FOUND) + set(poppler_SRCS ${poppler_SRCS} + poppler/DCTStream.cc + ) + set(poppler_LIBS ${poppler_LIBS} ${JPEG_LIBRARIES}) +endif(JPEG_FOUND) +if(ENABLE_ZLIB) + set(poppler_SRCS ${poppler_SRCS} + poppler/FlateStream.cc + ) + set(poppler_LIBS ${poppler_LIBS} ${ZLIB_LIBRARIES}) +endif(ENABLE_ZLIB) +if(ENABLE_LIBCURL) + set(poppler_SRCS ${poppler_SRCS} + poppler/CurlCachedFile.cc + poppler/CurlPDFDocBuilder.cc + ) + set(poppler_LIBS ${poppler_LIBS} ${CURL_LIBRARIES}) +endif(ENABLE_LIBCURL) +if(LIBOPENJPEG_FOUND) + set(poppler_SRCS ${poppler_SRCS} + poppler/JPEG2000Stream.cc + ) + set(poppler_LIBS ${poppler_LIBS} ${LIBOPENJPEG_LIBRARIES}) + add_definitions(-DUSE_OPENJPEG1) +elseif (LIBOPENJPEG2_FOUND) + set(poppler_SRCS ${poppler_SRCS} + poppler/JPEG2000Stream.cc + ) + add_definitions(-DUSE_OPENJPEG2) +MESSAGE(${LIBOPENJPEG2_LIBRARIES}) + set(poppler_LIBS ${poppler_LIBS} ${LIBOPENJPEG2_LIBRARIES}) +else () + set(poppler_SRCS ${poppler_SRCS} + poppler/JPXStream.cc + ) +endif() +if(USE_CMS) + if(LCMS_FOUND) + set(poppler_LIBS ${poppler_LIBS} ${LCMS_LIBRARIES}) + endif(LCMS_FOUND) + if(LCMS2_FOUND) + set(poppler_LIBS ${poppler_LIBS} ${LCMS2_LIBRARIES}) + endif(LCMS2_FOUND) +endif(USE_CMS) +if(WIN32) + # gdi32 is needed under win32 + set(poppler_LIBS ${poppler_LIBS} gdi32) +endif(WIN32) +if(PNG_FOUND) + set(poppler_LIBS ${poppler_LIBS} ${PNG_LIBRARIES}) +endif(PNG_FOUND) +if(TIFF_FOUND) + set(poppler_LIBS ${poppler_LIBS} ${TIFF_LIBRARIES}) +endif(TIFF_FOUND) +if(HAVE_PTHREAD) + set(poppler_LIBS ${poppler_LIBS} ${CMAKE_THREAD_LIBS_INIT}) +endif() + +if(MSVC) +add_definitions(-D_CRT_SECURE_NO_WARNINGS) +set(CMAKE_CXX_FLAGS "/Zc:wchar_t- ${CMAKE_CXX_FLAGS}") +add_library(poppler STATIC ${poppler_SRCS}) +else(MSVC) +add_library(poppler SHARED ${poppler_SRCS}) +endif(MSVC) +set_target_properties(poppler PROPERTIES VERSION 52.0.0 SOVERSION 52) +target_link_libraries(poppler ${poppler_LIBS}) +target_link_libraries(poppler LINK_INTERFACE_LIBRARIES "") +install(TARGETS poppler RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) + +if(ENABLE_XPDF_HEADERS) + install(FILES + poppler/Annot.h + poppler/Array.h + poppler/BuiltinFont.h + poppler/BuiltinFontTables.h + poppler/CachedFile.h + poppler/Catalog.h + poppler/CharCodeToUnicode.h + poppler/CMap.h + poppler/DateInfo.h + poppler/Decrypt.h + poppler/Dict.h + poppler/Error.h + poppler/FileSpec.h + poppler/FontEncodingTables.h + poppler/FontInfo.h + poppler/Form.h + poppler/Function.cc + poppler/Function.h + poppler/Gfx.h + poppler/GfxFont.h + poppler/GfxState.h + poppler/GfxState_helpers.h + poppler/GlobalParams.h + poppler/Hints.h + poppler/JArithmeticDecoder.h + poppler/JBIG2Stream.h + poppler/Lexer.h + poppler/Link.h + poppler/Linearization.h + poppler/LocalPDFDocBuilder.h + poppler/MarkedContentOutputDev.h + poppler/Movie.h + poppler/NameToCharCode.h + poppler/Object.h + poppler/OptionalContent.h + poppler/Outline.h + poppler/OutputDev.h + poppler/Page.h + poppler/PageTransition.h + poppler/Parser.h + poppler/PDFDoc.h + poppler/PDFDocBuilder.h + poppler/PDFDocEncoding.h + poppler/PDFDocFactory.h + poppler/PopplerCache.h + poppler/ProfileData.h + poppler/PreScanOutputDev.h + poppler/PSTokenizer.h + poppler/Rendition.h + poppler/Stream-CCITT.h + poppler/Stream.h + poppler/StructElement.h + poppler/StructTreeRoot.h + poppler/UnicodeMap.h + poppler/UnicodeMapTables.h + poppler/UnicodeTypeTable.h + poppler/UnicodeCClassTables.h + poppler/UnicodeCompTables.h + poppler/UnicodeDecompTables.h + poppler/ViewerPreferences.h + poppler/XRef.h + poppler/CharTypes.h + poppler/CompactFontTables.h + poppler/ErrorCodes.h + poppler/NameToUnicodeTable.h + poppler/PSOutputDev.h + poppler/TextOutputDev.h + poppler/SecurityHandler.h + poppler/StdinCachedFile.h + poppler/StdinPDFDocBuilder.h + poppler/UTF.h + poppler/UTF8.h + poppler/XpdfPluginAPI.h + poppler/Sound.h + ${CMAKE_CURRENT_BINARY_DIR}/poppler/poppler-config.h + DESTINATION include/poppler) + install(FILES + goo/GooHash.h + goo/GooList.h + goo/GooTimer.h + goo/GooMutex.h + goo/GooString.h + goo/gtypes.h + goo/gmem.h + goo/gfile.h + goo/FixedPoint.h + goo/ImgWriter.h + goo/GooLikely.h + goo/gstrtod.h + goo/grandom.h + DESTINATION include/poppler/goo) + if(PNG_FOUND) + install(FILES + goo/PNGWriter.h + DESTINATION include/poppler/goo) + endif(PNG_FOUND) + if(TIFF_FOUND) + install(FILES + goo/TiffWriter.h + DESTINATION include/poppler/goo) + endif(TIFF_FOUND) + if(JPEG_FOUND) + install(FILES + goo/JpegWriter.h + DESTINATION include/poppler/goo) + endif(JPEG_FOUND) + install(FILES + fofi/FoFiBase.h + fofi/FoFiEncodings.h + fofi/FoFiTrueType.h + fofi/FoFiType1.h + fofi/FoFiType1C.h + fofi/FoFiIdentifier.h + DESTINATION include/poppler/fofi) + if(ENABLE_LIBCURL) + install(FILES + poppler/CurlCachedFile.h + poppler/CurlPDFDocBuilder.h + DESTINATION include/poppler) + endif(ENABLE_LIBCURL) + if(LIBOPENJPEG_FOUND) + install(FILES + poppler/JPEG2000Stream.h + DESTINATION include/poppler) + elseif(LIBOPENJPEG2_FOUND) + install(FILES + poppler/JPEG2000Stream.h + DESTINATION include/poppler) + else() + install(FILES + poppler/JPXStream.h + DESTINATION include/poppler) + endif() + if(ENABLE_SPLASH) + install(FILES + poppler/SplashOutputDev.h + DESTINATION include/poppler) + install(FILES + splash/Splash.h + splash/SplashBitmap.h + splash/SplashClip.h + splash/SplashErrorCodes.h + splash/SplashFTFont.h + splash/SplashFTFontEngine.h + splash/SplashFTFontFile.h + splash/SplashFont.h + splash/SplashFontEngine.h + splash/SplashFontFile.h + splash/SplashFontFileID.h + splash/SplashGlyphBitmap.h + splash/SplashMath.h + splash/SplashPath.h + splash/SplashPattern.h + splash/SplashScreen.h + splash/SplashState.h + splash/SplashT1Font.h + splash/SplashT1FontEngine.h + splash/SplashT1FontFile.h + splash/SplashTypes.h + splash/SplashXPath.h + splash/SplashXPathScanner.h + DESTINATION include/poppler/splash) + endif(ENABLE_SPLASH) +endif(ENABLE_XPDF_HEADERS) + + +if(ENABLE_UTILS) + add_subdirectory(utils) +endif(ENABLE_UTILS) +if(ENABLE_GLIB) + add_subdirectory(glib) +endif(ENABLE_GLIB) +add_subdirectory(test) +if(QT4_FOUND) + add_subdirectory(qt4) +endif(QT4_FOUND) +if(QT5_FOUND) + add_subdirectory(qt5) +endif(QT5_FOUND) +if(ENABLE_CPP) + add_subdirectory(cpp) +endif(ENABLE_CPP) + +set(PKG_CONFIG_VERSION_0_18 TRUE) +if(PKG_CONFIG_EXECUTABLE) + exec_program(${PKG_CONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _output_VAR) + macro_ensure_version("0.18" "${_output_VAR}" PKG_CONFIG_VERSION_0_18) +endif(PKG_CONFIG_EXECUTABLE) +if(PKG_CONFIG_VERSION_0_18) + set(PC_REQUIRES "") + set(PC_REQUIRES_PRIVATE "Requires.private: poppler = ${POPPLER_VERSION}") +else(PKG_CONFIG_VERSION_0_18) + set(PC_REQUIRES "poppler = ${POPPLER_VERSION}") + set(PC_REQUIRES_PRIVATE "") +endif(PKG_CONFIG_VERSION_0_18) + +poppler_create_install_pkgconfig(poppler.pc lib${LIB_SUFFIX}/pkgconfig) +if(ENABLE_SPLASH) + poppler_create_install_pkgconfig(poppler-splash.pc lib${LIB_SUFFIX}/pkgconfig) +endif(ENABLE_SPLASH) +if(QT4_FOUND) + poppler_create_install_pkgconfig(poppler-qt4.pc lib${LIB_SUFFIX}/pkgconfig) +endif(QT4_FOUND) +if(QT5_FOUND) + poppler_create_install_pkgconfig(poppler-qt5.pc lib${LIB_SUFFIX}/pkgconfig) +endif(QT5_FOUND) +if(ENABLE_GLIB) + poppler_create_install_pkgconfig(poppler-glib.pc lib${LIB_SUFFIX}/pkgconfig) +endif(ENABLE_GLIB) +if(CAIRO_FOUND) + poppler_create_install_pkgconfig(poppler-cairo.pc lib${LIB_SUFFIX}/pkgconfig) +endif(CAIRO_FOUND) +if(ENABLE_CPP) + poppler_create_install_pkgconfig(poppler-cpp.pc lib${LIB_SUFFIX}/pkgconfig) +endif(ENABLE_CPP) + + +message("Building Poppler with support for:") +show_end_message("font configuration" ${font_configuration}) +show_end_message_yesno("splash output" ENABLE_SPLASH) +show_end_message_yesno("cairo output" CAIRO_FOUND) +show_end_message_yesno("qt4 wrapper" QT4_FOUND) +show_end_message_yesno("qt5 wrapper" QT5_FOUND) +show_end_message_yesno("glib wrapper" ENABLE_GLIB) +show_end_message_yesno(" introspection" INTROSPECTION_FOUND) +show_end_message_yesno("cpp wrapper" ENABLE_CPP) +show_end_message("use gtk-doc" "not supported with this CMake build system") +show_end_message_yesno("use libjpeg" ENABLE_LIBJPEG) +show_end_message_yesno("use libpng" ENABLE_LIBPNG) +show_end_message_yesno("use libtiff" ENABLE_LIBTIFF) +show_end_message_yesno("use zlib" ENABLE_ZLIB) +show_end_message_yesno("use curl" ENABLE_LIBCURL) +show_end_message_yesno("use libopenjpeg" WITH_OPENJPEG) +if(USE_OPENJPEG1) + message(" with openjpeg1") +endif() +if(USE_OPENJPEG2) + message(" with openjpeg2") +endif() +show_end_message_yesno("use cms" USE_CMS) +if(LCMS_FOUND) + message(" with lcms1") +endif(LCMS_FOUND) +if(LCMS2_FOUND) + message(" with lcms2") +endif(LCMS2_FOUND) +show_end_message_yesno("command line utils" ENABLE_UTILS) +show_end_message("test data dir" ${TESTDATADIR}) + +if(USE_FIXEDPOINT AND USE_FLOAT) + message("Warning: Single precision and fixed point options should not be enabled at the same time") +endif(USE_FIXEDPOINT AND USE_FLOAT) diff --git a/source/libs/poppler/poppler-0.32.0/COPYING b/source/libs/poppler/poppler-0.33.0/COPYING old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/COPYING rename to source/libs/poppler/poppler-0.33.0/COPYING diff --git a/source/libs/poppler/poppler-0.33.0/ChangeLog b/source/libs/poppler/poppler-0.33.0/ChangeLog new file mode 100644 index 000000000..1d774030b --- /dev/null +++ b/source/libs/poppler/poppler-0.33.0/ChangeLog @@ -0,0 +1,57589 @@ +commit 2b2fb719aa5ffe32fbc3fb500444b1643b1c6099 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 14 20:17:12 2015 +0200 + + Add missing (C) + + poppler/Annot.cc | 1 + + poppler/Annot.h | 2 +- + poppler/CairoFontEngine.cc | 1 + + poppler/Page.cc | 3 ++- + 4 files changed, 5 insertions(+), 2 deletions(-) + +commit ae76b75c6a5383eb52f58fba0faba69ae8698ef9 +Author: William Bader <williambader@hotmail.com> +Date: Thu May 14 20:06:22 2015 +0200 + + Fix regression in pdftops parameter passing + + Recent changes to the command line processing moved some options + from GlobalParams to PSOutputDev. + The options used to be set by calling setters in GlobalParams before + creating the PSOutputDev. + Now the options are set by calling setters in PSOutputDev after it + is created. + The problem is that PSOutputDev() calls init() which uses options + that now can not be set until later after PSOutputDev() returns. + These patches split some of the code of init() into a new postInit() + that is automatically called later after the pdftops main program + has had a chance to set the command line options. + When I was looking through the code, I also fixed a misspelling of + sanitizedTitle as sanitizedTile. + + Bug #89827 + + poppler/PSOutputDev.cc | 138 + +++++++++++++++++++++++++++++++------------------ + poppler/PSOutputDev.h | 11 ++-- + 2 files changed, 96 insertions(+), 53 deletions(-) + +commit c516b341a9c2e0c9a985bc14ad3cae73bf10fb02 +Author: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> +Date: Sun May 3 15:27:19 2015 +0200 + + Fix invalid shell comparaison in libtiff test + + Bug #115523 + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 040b316f0cb1ac933dce616fabe24c93f96fe1cd +Author: Jason Crain <jason@aquaticape.us> +Date: Sat Apr 18 12:44:47 2015 -0500 + + glib: Fix segfault when creating PopplerAction + + Screen annotations and form fields currently pass a NULL pointer to + _poppler_action_new. Pass the PopplerDocument instead. + + Bug #90093 + + glib/poppler-annot.cc | 4 ++-- + glib/poppler-form-field.cc | 2 +- + glib/poppler-page.cc | 2 +- + glib/poppler-private.h | 2 +- + 4 files changed, 5 insertions(+), 5 deletions(-) + +commit 056ee89122385bc2df7cb2c05e1cb1770af8ecce +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Apr 18 12:16:56 2015 +0200 + + glib: Add poppler_annot_markup_set_popup_rectangle() + + It updates the popup rectangle of a markup annotation that already + has a + popup associated. + + glib/poppler-annot.cc | 31 +++++++++++++++++++++++++++++++ + glib/poppler-annot.h | 2 ++ + glib/reference/poppler-sections.txt | 1 + + 3 files changed, 34 insertions(+) + +commit 1aae63ebc6fffe9fa1a2898e4ed733c22e312015 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Apr 18 11:46:41 2015 +0200 + + annots: Add popup annots without a markup annot associated to the + list of annots + + For consistency with Annots::createAnnot(). + + poppler/Annot.h | 2 +- + poppler/Page.cc | 6 +++++- + 2 files changed, 6 insertions(+), 2 deletions(-) + +commit 05ef3f9feee760544108c68e0d45d1de25fd8901 +Author: Philipp Reinkemeier <philipp.reinkemeier@offis.de> +Date: Mon Feb 16 09:11:58 2015 +0100 + + annots: Fixed adding annotation of Subtype Popup to pdf page + + https://bugs.freedesktop.org/show_bug.cgi?id=89136 + + poppler/Annot.cc | 19 +++++++++++++++++++ + poppler/Page.cc | 11 ++++++++++- + 2 files changed, 29 insertions(+), 1 deletion(-) + +commit 8ca43bebf36f8da085917f28230e25524de4f4f4 +Author: Jason Crain <jason@aquaticape.us> +Date: Tue Mar 24 02:51:47 2015 -0500 + + cairo: Fix memory leak in CairoFreeTypeFont::create + + - Free embedded font data in _ft_done_face when the cairo font is + destroyed. + - Free embedded font data if _ft_new_face finds it's a duplicate of an + already open font. + - Free embedded font data and codeToGID array if font creation fails. + + Bug #89952 + + poppler/CairoFontEngine.cc | 16 +++++++++++----- + 1 file changed, 11 insertions(+), 5 deletions(-) + +commit edc7bb4fe7b5e718431de12bee1d95036d06efa0 +Author: Jason Crain <jason@aquaticape.us> +Date: Sat Apr 4 18:40:48 2015 +0200 + + Combine base characters and diacritical marks + + LaTeX adds base characters and diacritical marks as separate + characters. When a base character and diacritical mark are drawn over + each other, this patch converts them into a combining character + sequence. + + Bug #87215 + C# poppler-0.31.0.tar.xz + + poppler/TextOutputDev.cc | 419 + ++++++++++++++++++++++++++++++++++------------- + poppler/TextOutputDev.h | 31 +++- + 2 files changed, 336 insertions(+), 114 deletions(-) + +commit 96c35dfde6722ff8c5ef7ff59e37be90d273acab +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Mar 27 22:42:34 2015 +0100 + + pdftohtml: Set exit status adecuately + + Based on a patch by Matt Atkinson <mutley456@ntlworld.com> + Bug #83609 + + utils/pdftohtml.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 0969801c12a6ec0fbc079c8203cece9c70466955 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 26 16:08:20 2015 +0100 + + Fix previous commit about initializing on failure + + It's the nComps of the destination not of the origin we need + + poppler/SplashOutputDev.cc | 15 +++++++++++++-- + 1 file changed, 13 insertions(+), 2 deletions(-) + +commit ede6d00688fcf0e3c843b0a507304f5a98395d41 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 26 15:44:40 2015 +0100 + + memset on error to have reproducible outputs + + poppler/SplashOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 4bb2c9b98299f429752b4c60820cea31ef05f7e0 +Author: Jason Crain <jason@aquaticape.us> +Date: Wed Mar 25 21:04:19 2015 +0100 + + Use width from W array for WMode positioning + + Bug #89621 + + poppler/GfxFont.cc | 36 ++++++++++++------------------------ + poppler/GfxFont.h | 2 ++ + 2 files changed, 14 insertions(+), 24 deletions(-) + +commit 033dbbd7fef8c04c7f4961455cc1cd8d6d1bd93b +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Mar 15 14:06:15 2015 +0100 + + Fix the previous pdfDocEncoding fix + + Since actually the previous fix didn't account for non ascii + characters as output of pdfDocEncoding + + qt4/src/poppler-private.cc | 36 +++++++++++++++--------------------- + qt5/src/poppler-private.cc | 36 +++++++++++++++--------------------- + 2 files changed, 30 insertions(+), 42 deletions(-) + +commit bc8076d8f638ccb44f8e3b94aaae96850b025deb +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Mar 15 13:32:41 2015 +0100 + + Fix PDF Text String -> QString conversion + + If they are not UTF16-BE they are in PDFDocEncoding (not ascii) + + Fixes KDE bug #344849 + + qt4/src/poppler-private.cc | 5 +++-- + qt5/src/poppler-private.cc | 5 +++-- + 2 files changed, 6 insertions(+), 4 deletions(-) + +commit d7cc90a8b60d7e353db6e0acdd0b789485e32972 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 7 15:04:52 2015 +0100 + + 0.32.0 + + CMakeLists.txt | 4 ++-- + NEWS | 16 ++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 7 files changed, 23 insertions(+), 7 deletions(-) + +commit c13297d154ded11721fe7d3abdba459ca628cef8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 7 14:58:10 2015 +0100 + + Update (C) + + poppler/SecurityHandler.cc | 2 +- + poppler/SplashOutputDev.cc | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit c909964bff671d5ff0d8eee5f613ded4562f8afd +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 7 14:54:43 2015 +0100 + + Do not assert on broken document + + Bug #89422 + + poppler/SecurityHandler.cc | 14 +++++++++----- + 1 file changed, 9 insertions(+), 5 deletions(-) + +commit 3705fcee0309c50b5fecd563e8e466cbe2c5972b +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Fri Mar 6 15:19:58 2015 +0100 + + Fix Wrong colour shown when GouraudTriangleShFill uses a DeviceN + colorspace + + Bug #89182 + + poppler/SplashOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit b7fde1ec83a5fff9bec73becc22e581583a30d43 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 25 21:51:34 2015 +0100 + + Fix last commit regression + + It seems it actually needs to be pipe->shape and not pipe->usesShape + (i.e. it seems at some point we use pipe->shape with useShape + being false) + Otherwise we had a regression on + eci_altona-test-suite-v2_technical2_x4.pdf + + splash/Splash.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 7980fe868a8ef2ee3315f0bcb606c448d6604039 +Author: William Bader <williambader@hotmail.com> +Date: Wed Feb 25 15:00:33 2015 +0100 + + Fix uninitialized variable in Splash::pipeRun + + Use useShape is actually the guard for shape, so use it in the if + + splash/Splash.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 57b6b78a0831fb31c06fd1bc6e9803de524f9d2d +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Tue Feb 24 23:34:57 2015 +0100 + + pdfseparate: use always an unique instance for PDFDoc for savePageAs + + utils/pdfseparate.cc | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +commit 8a30d219df71ead323649ff0dfd4a724b5e7bd18 +Author: William Bader <williambader@hotmail.com> +Date: Sat Feb 21 23:55:10 2015 +0100 + + Fix memcpy introduced in ec956ab8552dbe10fac4e649951042bddc424b7d + + goo/GooString.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ec956ab8552dbe10fac4e649951042bddc424b7d +Author: William Bader <williambader@hotmail.com> +Date: Tue Feb 17 22:55:14 2015 +0100 + + Reduce use of gmalloc() in GooString::appendfv() + + Bug #89096 + + goo/GooString.cc | 18 ++++++++++++++---- + 1 file changed, 14 insertions(+), 4 deletions(-) + +commit 132ef18324f62c1f2a08dcd794b379fadaa4daf5 +Author: Petr Gajdos <pgajdos@suse.cz> +Date: Wed Feb 11 19:37:21 2015 +0100 + + Annot BG/BC: Empty Array means no color + + poppler/Annot.cc | 15 +++++++++++++-- + 1 file changed, 13 insertions(+), 2 deletions(-) + +commit bf4aae25a244b1033a2479b9a8f633224f7d5de5 +Author: William Bader <williambader@hotmail.com> +Date: Wed Feb 11 17:35:40 2015 +0100 + + Off by one fix to the previous crash fix + + fofi/FoFiTrueType.cc | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +commit 97dd46bae5424818ca808c20506d7d96f7b85fb5 +Author: William Bader <williambader@hotmail.com> +Date: Mon Feb 9 22:30:51 2015 +0100 + + pdftops: Add aaRaster and overprint to man file + + utils/pdftops.1 | 9 +++++++++ + 1 file changed, 9 insertions(+) + +commit c114a90063d755639d2b0dbf816690a66b54bee0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 8 00:24:11 2015 +0100 + + Fix crash in fuzzed file from Bug #84988 + + poppler/TextOutputDev.cc | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit 22895623e6cd2a5923f552421d44cc80cab77dd8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 7 22:28:21 2015 +0100 + + Fix malformed file crash from bug #86854 + + poppler/PSOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit cdb7ad95f7c8fbf63ade040d8a07ec96467042fc +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 7 22:21:16 2015 +0100 + + Fix malformed file crash in bug #85243 + + fofi/FoFiTrueType.cc | 15 +++++++++++++-- + 1 file changed, 13 insertions(+), 2 deletions(-) + +commit 6641b935e1fc0c4151a723b6b476d987b8324ed2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 7 21:58:23 2015 +0100 + + If ECM is around include the sanitizers module + + This way you can run + cmake -DECM_ENABLE_SANITIZERS='address' + and get an ASAN built poppler + + CMakeLists.txt | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 92e41685dcef538a7fc669ca357ce9f448a8078e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 7 21:54:39 2015 +0100 + + Fix crash in malformed file from bug #85275 + + poppler/SplashOutputDev.cc | 4 ++-- + splash/Splash.cc | 10 +++++++++- + splash/SplashBitmap.cc | 4 ++-- + 3 files changed, 13 insertions(+), 5 deletions(-) + +commit 9842b3b00492eda21297d5d65f769f77a565f6ac +Author: Aleksei Volkov <Aleksei Volkov> +Date: Sat Feb 7 20:46:26 2015 +0100 + + No need to check for hmtx, freetype does for us + + Bug #88939 + + fofi/FoFiTrueType.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 4849eb43892640062c485e48ba7a29b5a0cc9587 +Author: William Bader <williambader@hotmail.com> +Date: Sat Feb 7 16:41:53 2015 +0100 + + Make the colorpsace optimization and option and not the default + + Bug #88971 + + poppler/PSOutputDev.cc | 25 ++++++++++++++++--------- + poppler/PSOutputDev.h | 4 ++++ + utils/pdftops.1 | 10 +++++++++- + utils/pdftops.cc | 4 ++++ + 4 files changed, 33 insertions(+), 10 deletions(-) + +commit 8e16e423a718b92514885e771e31048f1ae2a766 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Feb 5 20:18:13 2015 +0100 + + 0.31.0 + + And copyright updating + + CMakeLists.txt | 4 ++-- + NEWS | 17 +++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/CairoOutputDev.cc | 1 + + poppler/CairoOutputDev.h | 1 + + poppler/JBIG2Stream.cc | 1 + + poppler/JBIG2Stream.h | 1 + + poppler/Makefile.am | 2 +- + poppler/Stream.cc | 1 + + qt4/src/CMakeLists.txt | 2 +- + qt4/src/Doxyfile | 2 +- + qt4/src/Makefile.am | 2 +- + qt5/src/CMakeLists.txt | 2 +- + qt5/src/Doxyfile | 2 +- + qt5/src/Makefile.am | 2 +- + 16 files changed, 33 insertions(+), 11 deletions(-) + +commit f932315e559a7857d9c5642eb04efc0d2b717789 +Author: suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Tue Jan 20 22:05:29 2015 +1030 + + cairo: support embedding JBIG2 image data + + http://lists.freedesktop.org/archives/poppler/2014-December/011183.html + + poppler/CairoOutputDev.cc | 117 + ++++++++++++++++++++++++++++++++++++++-------- + poppler/CairoOutputDev.h | 3 ++ + poppler/JBIG2Stream.cc | 9 +++- + poppler/JBIG2Stream.h | 4 +- + poppler/Stream.cc | 13 +++++- + 5 files changed, 121 insertions(+), 25 deletions(-) + +commit 78abf540057181b708c546aee421f81a1dd58331 +Author: Adam Reichold <adamreichold@myopera.com> +Date: Wed Jan 21 22:30:45 2015 +0100 + + Worlds -> Words + + qt4/src/poppler-page.cc | 4 ++-- + qt4/src/poppler-qt4.h | 2 +- + qt4/tests/check_search.cpp | 4 ++-- + qt5/src/poppler-page.cc | 4 ++-- + qt5/src/poppler-qt5.h | 2 +- + qt5/tests/check_search.cpp | 4 ++-- + 6 files changed, 10 insertions(+), 10 deletions(-) + +commit 027eac4e565576ca2e7042e21426e28abd775d98 +Author: Adam Reichold <adamreichold@myopera.com> +Date: Tue Jan 20 00:09:09 2015 +0100 + + Expose whole-words search option in Qt frontends + + qt4/src/poppler-page-private.h | 5 +- + qt4/src/poppler-page.cc | 114 + +++++++++++++++++++++++++------------ + qt4/src/poppler-qt4.h | 44 +++++++++++++- + qt4/tests/check_search.cpp | 112 +++++++++++++++++++++++++++++++----- + qt5/src/poppler-page-private.h | 5 +- + qt5/src/poppler-page.cc | 116 + +++++++++++++++++++++++++------------ + qt5/src/poppler-qt5.h | 46 +++++++++++++-- + qt5/tests/check_search.cpp | 126 + +++++++++++++++++++++++++++++++++-------- + 8 files changed, 447 insertions(+), 121 deletions(-) + +commit 30a0baa353c374165e5f411efc4203746f14a74d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 18 15:39:53 2015 +0100 + + Move more variables from GlobalParams to PSOutputDev + + poppler/CairoFontEngine.cc | 4 +- + poppler/GfxFont.cc | 15 ++--- + poppler/GfxFont.h | 7 ++- + poppler/GlobalParams.cc | 144 + --------------------------------------------- + poppler/GlobalParams.h | 28 --------- + poppler/PSOutputDev.cc | 121 +++++++++++++++++++------------------ + poppler/PSOutputDev.h | 30 +++++++++- + poppler/SplashOutputDev.cc | 2 +- + qt4/src/ArthurOutputDev.cc | 4 +- + qt5/src/ArthurOutputDev.cc | 4 +- + utils/pdftops.cc | 36 ++++-------- + 11 files changed, 116 insertions(+), 279 deletions(-) + +commit 8fed995c3457d64669ae12901450b7c811599dba +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 18 14:52:53 2015 +0100 + + Forgot to delete this in the previous commit + + poppler/GlobalParams.h | 1 - + 1 file changed, 1 deletion(-) + +commit 4992ff7fa062462507733494827fdad7eaaa95b3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 18 13:57:36 2015 +0100 + + Move raster mono and resolution from GlobalParams to PSOutputDev + + poppler/GlobalParams.cc | 32 -------------------------------- + poppler/GlobalParams.h | 7 ------- + poppler/PSOutputDev.cc | 18 +++++++----------- + poppler/PSOutputDev.h | 6 ++++++ + utils/pdftops.cc | 7 ++++--- + 5 files changed, 17 insertions(+), 53 deletions(-) + +commit 54908f675eda96c363528198e8c530921df2f45a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 18 13:34:45 2015 +0100 + + Move psUncompressPreloadedImages from GlobalParams to PSOutputDev + + It belongs there and PSOutputDev is always created by the external + user + so in case someone wants to set it, it is the same amount of work + to set it in GlobalParams than in PSOutputDev + + poppler/GlobalParams.cc | 16 ---------------- + poppler/GlobalParams.h | 3 --- + poppler/PSOutputDev.cc | 9 +++++---- + poppler/PSOutputDev.h | 2 ++ + 4 files changed, 7 insertions(+), 23 deletions(-) + +commit 136d7aa5e79f153dfcb216c58598e33a8ff16630 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 18 13:28:26 2015 +0100 + + Remove declared but not defined function + + poppler/GlobalParams.h | 1 - + 1 file changed, 1 deletion(-) + +commit fdba9154d9a176759c765180805e608d4959c34e +Author: Adam Reichold <adamreichold@myopera.com> +Date: Fri Jan 16 19:57:59 2015 +0100 + + pdftoppm: parse the flags earlier and only once + + utils/pdftoppm.cc | 42 +++++++++++++++--------------------------- + 1 file changed, 15 insertions(+), 27 deletions(-) + +commit 6b072500b5ac936631be6b29b7d5a591848a18f3 +Author: William Bader <williambader@hotmail.com> +Date: Wed Jan 14 23:28:03 2015 +0100 + + Add rasterization option to pdftops + + Also removes GlobalParams stuff \o/ + + Coded in conjuntion with Albert + + Bug #85934 + + cpp/poppler-page-renderer.cpp | 5 ++-- + poppler/GlobalParams.cc | 58 + ++----------------------------------------- + poppler/GlobalParams.h | 16 +++--------- + poppler/PSOutputDev.cc | 14 +++++------ + poppler/PSOutputDev.h | 5 +++- + poppler/SplashOutputDev.cc | 19 ++++++-------- + poppler/SplashOutputDev.h | 11 +++++--- + qt4/src/poppler-page.cc | 7 +++--- + qt5/src/poppler-page.cc | 7 +++--- + utils/pdftohtml.cc | 9 +++---- + utils/pdftoppm.cc | 49 ++++++++++++++++++++++++++---------- + utils/pdftops.cc | 14 ++++++++++- + 12 files changed, 96 insertions(+), 118 deletions(-) + +commit dc9751e6ac47a708ba6e7a68560bdce6a2e4a010 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jan 9 15:50:02 2015 +0100 + + Compile++ + + poppler/GfxState.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit d91876a0c7a936b1f6f461d80131d7586a6c1a5e +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 8 20:13:06 2015 +0100 + + Accept malformed documents whose root is a Page instead of a Pages + + gs and Adobe Reader do it so it's "common" enough + + Bug #88172 + + poppler/Catalog.cc | 37 ++++++++++++++++++++++++++++++++----- + 1 file changed, 32 insertions(+), 5 deletions(-) + +commit 7ce86b9be058408eb567d8d0b9747853a66c116f +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 8 17:35:28 2015 +0100 + + Remove assert in gouraudFillTriangle + + We don't *need* the assert, an error() is fine and the malformed + document + will just get rendered wrongly instead of "crashing" + + Bugs #85274 + + poppler/Gfx.cc | 28 +++++++++++++++++----------- + 1 file changed, 17 insertions(+), 11 deletions(-) + +commit 9e9df4b20d17478996780008bc9802a857d173fc +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 8 17:01:52 2015 +0100 + + Fix crash on broken document + + Bug #85281 + + poppler/GfxState.cc | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +commit 636faafcb84b856580398f7883b6406d645c85d1 +Author: Adam Reichold <adamreichold@myopera.com> +Date: Tue Jan 6 22:57:20 2015 +0100 + + JPEG2000Stream: Inline doGetChar and doLookChar + + poppler/JPEG2000Stream.cc | 49 + +++++++++++++++++++++++++---------------------- + poppler/JPEG2000Stream.h | 7 ++----- + 2 files changed, 28 insertions(+), 28 deletions(-) + +commit c13bffe92963c4969037695992f4c2776bbe973f +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 4 23:17:42 2015 +0100 + + 0.30 + + CMakeLists.txt | 4 ++-- + NEWS | 18 ++++++++++++++++++ + configure.ac | 2 +- + cpp/CMakeLists.txt | 2 +- + cpp/Doxyfile | 2 +- + cpp/Makefile.am | 2 +- + poppler/Makefile.am | 2 +- + poppler/PDFDoc.cc | 1 + + poppler/TextOutputDev.cc | 2 +- + poppler/poppler-config.h.cmake | 2 +- + poppler/poppler-config.h.in | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 13 files changed, 31 insertions(+), 12 deletions(-) + +commit e499fdab2e96cb3069db7ac8ffa0df20ccccddc9 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Jan 4 20:23:39 2015 +0100 + + extended openjpeg2 support + + poppler/JPEG2000Stream.cc | 101 + +++++++++++++++++++++++++++++++++++----------- + 1 file changed, 78 insertions(+), 23 deletions(-) + +commit 2841f3c34dd6366a70e4d6d307a08b3fbc3e9897 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Jan 4 20:22:47 2015 +0100 + + Cmake support for openjpeg2 + + With some tweaks from Albert + + CMakeLists.txt | 56 + +++++++++++++++++++++++++++++------- + cmake/modules/FindLIBOPENJPEG2.cmake | 30 +++++++++++++++++++ + 2 files changed, 76 insertions(+), 10 deletions(-) + +commit 117af9c6bbd923954ef7de63adec8c22d51da1e4 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Jan 4 19:42:34 2015 +0100 + + Initial attempt at libopenjpeg2 support + + OpenJPEG 2 has a new pkg-config name and API. + + - Update configure.ac to find openjpeg 2 and provide V1/v2 macros + - Update JPEG2000Stream to use new API depending on openjpeg v1/v2 + macros + - OpenJPEG 2.1 changed the API so provide a version macro to make + it easier + to handle the the 2.1 change and any future changes. + - Move openjpeg.h into the .cc file + + configure.ac | 80 ++++++++---- + poppler/JPEG2000Stream.cc | 313 + +++++++++++++++++++++++++++++++++++++--------- + poppler/JPEG2000Stream.h | 41 ++---- + 3 files changed, 323 insertions(+), 111 deletions(-) + +commit 9caf7525409d699c16896653528486451123b485 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 4 18:48:02 2015 +0100 + + Make PSOutputDev accept a list of pages indeces + + Instead of first, last + + Bug #84833 + + Reviewed in the mailing list, see "Can anyone have a look at my + patch?" + + glib/poppler-page.cc | 10 ++++++--- + poppler/PSOutputDev.cc | 50 + ++++++++++++++++++++++++----------------- + poppler/PSOutputDev.h | 14 +++++++----- + qt4/src/poppler-ps-converter.cc | 11 ++++++--- + qt5/src/poppler-ps-converter.cc | 11 ++++++--- + utils/pdftops.cc | 15 +++++++++---- + 6 files changed, 71 insertions(+), 40 deletions(-) + +commit 173f182fb568843f97e7d45d1b16bebbd2aa7413 +Author: Li Junling <lijunling@sina.com> +Date: Fri Jan 2 17:23:24 2015 +0100 + + Find last 'startxref' in the last 24K instead of the last 1K + + Bug #85919 + + poppler/PDFDoc.cc | 38 ++++++++++++++++++++++---------------- + 1 file changed, 22 insertions(+), 16 deletions(-) + +commit 0b1cd9403b8a240e58ec4f1832588d25f8295278 +Author: Jason Crain <jason@aquaticape.us> +Date: Sat Dec 20 03:22:23 2014 -0600 + + Free BBox object on error + + poppler/Gfx.cc | 1 + + 1 file changed, 1 insertion(+) + +commit acc33a6950031ac4a5c759d043d24df0cfa7e8b6 +Author: Jason Crain <jason@aquaticape.us> +Date: Sat Dec 20 02:24:49 2014 -0600 + + Check for invalid matrix in annotation + + Bug #84990 + + poppler/Gfx.cc | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +commit 56aff7d78658f586e3c4cd41685f189dafb3098a +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Tue Dec 23 15:49:15 2014 +0100 + + pdfunite: Support output intents, optional content and acroform + + utils/pdfunite.cc | 116 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 116 insertions(+) + +commit 9e734063e6a6a4b9743c9aa27d3d3127b5a960d7 +Author: Jason Crain <jason@aquaticape.us> +Date: Fri Dec 19 01:56:45 2014 -0600 + + Move array reallocation from visitLine to startLine + + Fixes potential memory corruption from writing after end of lines + array. + + https://bugs.freedesktop.org/show_bug.cgi?id=84555 + + poppler/TextOutputDev.cc | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +commit 0c47b769a77795bd866b6686b79fd20ad6f554bf +Author: Daniel Macks <dmacks@netspace.org> +Date: Sun Dec 14 18:52:48 2014 +0100 + + Only consider adding -fno-check-new if compiler supports it + + Helps compiling on old clang's + + Bug #76963 + + configure.ac | 18 ++++++++++++++++-- + 1 file changed, 16 insertions(+), 2 deletions(-) + +commit c9c90d50e3708f6fac313aa8b458aef6dba5dcfb +Author: Hans-Peter Deifel <hpdeifel@gmx.de> +Date: Fri Dec 12 13:09:51 2014 +0100 + + cpp: New API to set debug output function + + Adds the global function set_debug_error_function, that allows users + to install their own function to print internal poppler errors. + + cpp/poppler-global.cpp | 29 +++++++++++++++++++++++++++++ + cpp/poppler-global.h | 5 +++++ + cpp/poppler-private.cpp | 15 ++++++++++++--- + cpp/poppler-private.h | 3 +++ + 4 files changed, 49 insertions(+), 3 deletions(-) + +commit fa8f276a10911c97d2777fff3270771802bc3892 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Dec 4 23:11:12 2014 +0100 + + 0.29.0 + + CMakeLists.txt | 4 ++-- + NEWS | 15 +++++++++++++++ + configure.ac | 4 ++-- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 7 files changed, 23 insertions(+), 8 deletions(-) + +commit fee700cfecb9d7d5fa938704a5f457f15aaa4676 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Dec 1 20:52:42 2014 +0100 + + Run dos2unix as suggested by Volker Grabsch + + splash/SplashState.h | 278 ++++++++++---------- + test/perf-test-preview-dummy.cc | 44 ++-- + test/perf-test-preview-win.cc | 544 + ++++++++++++++++++++-------------------- + 3 files changed, 433 insertions(+), 433 deletions(-) + +commit d3fe0661c6dc6050e14cd5cb4afa089b7d7d66b0 +Author: Richard PALO <richard@netbsd.org> +Date: Sun Nov 30 22:46:22 2014 +0100 + + warning: "_FILE_OFFSET_BITS" redefined + + Bug #86870 + + test/perf-test.cc | 2559 + +++++++++++++++++++++++++++-------------------------- + 1 file changed, 1280 insertions(+), 1279 deletions(-) + +commit 18884065e11fee82506915095619107a43172ecb +Author: Richard PALO <richard@netbsd.org> +Date: Sun Nov 30 22:36:29 2014 +0100 + + The isfinite macro is defined on SunOS under c99 + + Bug #86869 + + poppler/SplashOutputDev.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit bcb470064dd9f75ab0b0a0d9b7319fe8f1e558ae +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Nov 25 05:53:38 2014 +1030 + + cofigure: print "no" instead of "auto" if lcms not found + + configure.ac | 2 ++ + 1 file changed, 2 insertions(+) + +commit 832046c57ab2909d329340f1c941b29e8246ff73 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Fri Nov 28 11:08:34 2014 +0100 + + Use correct LAB byte array for lcms input + + Bug #86388 + + poppler/GfxState.cc | 51 + ++++++++++++++++++++++++++++++++++++++------------- + poppler/GfxState.h | 4 +++- + 2 files changed, 41 insertions(+), 14 deletions(-) + +commit a604bc3a2ed9f9181aa3b12d795608fcf5e08220 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Fri Nov 14 11:56:50 2014 +0100 + + Solve blend mode problem in CYMK and DeviceN for separable blend modes + + Fixes part of #68986 + + poppler/SplashOutputDev.cc | 277 + +++++++++++++++++++++++++-------------------- + 1 file changed, 155 insertions(+), 122 deletions(-) + +commit b7802ff39db270dda2aa20f005fb87c22ed34137 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Fri Nov 14 11:47:38 2014 +0100 + + Use Default colorspaces if present instead of Device colorspaces + + Fixes part of #68986 + + poppler/CairoOutputDev.cc | 4 +- + poppler/Gfx.cc | 40 +++++----- + poppler/GfxState.cc | 197 + ++++++++++++++++++++++++++++++++++------------ + poppler/GfxState.h | 31 ++++---- + poppler/Page.cc | 4 +- + 5 files changed, 188 insertions(+), 88 deletions(-) + +commit 07aa6f4030418883d8d45a8dfa3d80d2dadca4e7 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Thu Nov 13 12:26:25 2014 +0100 + + write correct size in trailer dict + + Bug #86063 + + poppler/PDFDoc.cc | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +commit 51e7c29cabedc72e097023e6d8d6d68ed43fa20c +Author: Carlos Garcia Campos <cgarcia@igalia.com> +Date: Fri Nov 7 18:30:36 2014 +0100 + + regtest: Update references also for tests that no longer crash + + We are currently updating the refs only when we have checksums to + compare, but if a test used to crash there's no md5 file in refs. + + regtest/TestRun.py | 2 ++ + regtest/backends/__init__.py | 24 ++++++++++++++++++++++++ + 2 files changed, 26 insertions(+) + +commit d205908930d5dc4ec3a1a1a2c2b93fbb92c2c867 +Author: William Bader <williambader@hotmail.com> +Date: Wed Nov 5 20:23:49 2014 +0100 + + Make it proper C + + glib/demo/annots.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit fa1d636b00210b9c52787ab3c833fe9aa2e293fa +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Nov 4 20:00:08 2014 +0100 + + 0.28.1 + + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +commit 7debbb05df18afc86df8a4fd37980728ec2e5788 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Nov 4 19:29:58 2014 +0100 + + Fix typo + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit d5489ef37742227176e800390a990f2b882d9710 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Nov 4 01:27:05 2014 +0100 + + 0.28.0 + + CMakeLists.txt | 6 +++--- + NEWS | 43 +++++++++++++++++++++++++++++++++++++++++++ + configure.ac | 4 ++-- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/CMakeLists.txt | 2 +- + qt4/src/Doxyfile | 2 +- + qt4/src/Makefile.am | 2 +- + qt5/src/CMakeLists.txt | 2 +- + qt5/src/Doxyfile | 2 +- + qt5/src/Makefile.am | 2 +- + 11 files changed, 56 insertions(+), 13 deletions(-) + +commit f87115a1129e4e03802769181a3392c8dce3192a +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Nov 4 01:25:18 2014 +0100 + + Don't ship the moc files + + qt4/demos/Makefile.am | 1 - + qt5/demos/Makefile.am | 1 - + 2 files changed, 2 deletions(-) + +commit 0a9c38076f1555196029372b7e08714b43c7a58d +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Nov 3 21:43:28 2014 +0100 + + Update (C) + + fofi/FoFiType1.cc | 1 + + poppler/PDFDoc.cc | 4 ++-- + poppler/PDFDoc.h | 2 +- + poppler/XRef.cc | 2 +- + qt4/src/poppler-annotation-private.h | 2 +- + qt4/src/poppler-annotation.cc | 2 +- + qt4/src/poppler-page.cc | 2 +- + qt4/src/poppler-qt4.h | 2 +- + qt5/src/poppler-annotation-private.h | 2 +- + qt5/src/poppler-annotation.cc | 2 +- + qt5/src/poppler-page.cc | 2 +- + qt5/src/poppler-qt5.h | 2 +- + utils/pdfdetach.cc | 1 + + utils/pdftocairo-win32.cc | 12 ++++++++++++ + utils/pdftocairo-win32.h | 12 ++++++++++++ + utils/pdftocairo.cc | 3 ++- + 16 files changed, 40 insertions(+), 13 deletions(-) + +commit 73cf1e87c9803bbe4271be297b486d9932677d46 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Nov 3 21:37:13 2014 +0100 + + Need to dist this file + + utils/Makefile.am | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 2fd0cd652cfc03c9af35a59192729e4ed26e8146 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Nov 3 19:20:23 2014 +0100 + + Fix memory leaks when running pdfseparate + + Bug #84768 + + poppler/PDFDoc.cc | 102 + +++++++++++++++++++++------------------------------ + poppler/PDFDoc.h | 2 +- + utils/pdfseparate.cc | 8 +++- + utils/pdfunite.cc | 4 +- + 4 files changed, 50 insertions(+), 66 deletions(-) + +commit d6ea8acbb348fdb43601a963ba5407e933565003 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Nov 3 19:11:25 2014 +0100 + + fix crash in Xref::getEntry + + Bug 85234 + + poppler/XRef.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit bd142810b9f66b017a58b3e1840d4d72794f1ef4 +Author: Jason Crain <jason@aquaticape.us> +Date: Thu May 15 02:22:44 2014 -0500 + + cairo: Use matrix to determine pattern size + + https://bugs.freedesktop.org/show_bug.cgi?id=33364 + + poppler/CairoOutputDev.cc | 22 ++++++++++++++++++---- + 1 file changed, 18 insertions(+), 4 deletions(-) + +commit 06dd7dc337c7db6122329e98783a126d59035aff +Author: Hib Eris <hib@hiberis.nl> +Date: Thu May 29 12:45:33 2014 +0200 + + Include windows.h, not Windows.h + + Fixes building on file systems that are case sensitive, e.g. when + cross compiling on Linux for win32. + + https://bugs.freedesktop.org/show_bug.cgi?id=79407 + + qt4/tests/stress-threads-qt4.cpp | 2 +- + qt5/tests/stress-threads-qt5.cpp | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 76a350b11160ac203a41b27fbc85a3264bfe4735 +Author: Carlos Garcia Campos <cgarcia@igalia.com> +Date: Thu Oct 30 18:25:06 2014 +0100 + + regtest: Try to fix again the paths of the resources in the generated + HTML report + + Use always relatives paths for the resources under the out directory, + and absolute paths for all other resources when no-absolute-path + command + line option is used. + + regtest/HTMLReport.py | 47 + +++++++++++++++++++++++------------------------ + 1 file changed, 23 insertions(+), 24 deletions(-) + +commit c93d6b264dc77c46c72281d966bf826274a43d15 +Author: Carlos Garcia Campos <cgarcia@igalia.com> +Date: Wed Oct 29 17:37:06 2014 +0100 + + regtest: respect --no-absolute-paths when creating the pretty + diff links + + regtest/HTMLReport.py | 16 ++++++++++------ + 1 file changed, 10 insertions(+), 6 deletions(-) + +commit 9f953e47a6ea92d806aeea61e227af54c889c6be +Author: Carlos Garcia Campos <cgarcia@igalia.com> +Date: Mon Oct 27 19:53:28 2014 +0100 + + regtest: Add an option to create the HTML report without absolute + paths + + It uses the paths as received from the command line attributes. + + regtest/HTMLReport.py | 15 +++++++++++---- + regtest/commands/create-report.py | 4 ++++ + 2 files changed, 15 insertions(+), 4 deletions(-) + +commit 3d840231bc6f0714da361493ef32913af2eb78d7 +Author: Carlos Garcia Campos <cgarcia@igalia.com> +Date: Sun Oct 26 12:09:28 2014 +0100 + + regtest: Fix png diff generation with python-pil pillow fork + + Use from PIL import Image instead of just import Image, since pillow + only doesn't support import Image without using PIL.Image. + + regtest/backends/__init__.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 68e58ec5465efc289d85ae104941db92450a3168 +Author: Carlos Garcia Campos <cgarcia@igalia.com> +Date: Sun Oct 26 11:21:23 2014 +0100 + + regtest: Limit the number of worker threads to the number of documents + to test + + We are always spawning all the threads even if the documents to + test is + less than the worker threads. Also optimize the case of running + only one + test to not spwn any thread. + + regtest/TestRun.py | 27 ++++++++++++++++++--------- + 1 file changed, 18 insertions(+), 9 deletions(-) + +commit 7c21b95852e891060cd2e276949acf0945306ab7 +Author: Carlos Garcia Campos <cgarcia@igalia.com> +Date: Sun Oct 26 11:08:45 2014 +0100 + + regtest: Allow to run groups of tests individually + + Now it's possible to pass more than one argument to run-tests + command and + optionally the docs directory. When more than one test is passed + and the + docs directory is not provided, the common base path of all passed + tests + is used as docs directory. The tests passed can be documents or + directories, using absolute paths or paths relative to the docs + directory. + This also allows us to update the refs for a group of tests. + + regtest/TestRun.py | 26 ++++++++++++++++++++++++-- + regtest/Utils.py | 7 +++++-- + regtest/commands/run-tests.py | 29 ++++++++++++++++++++--------- + 3 files changed, 49 insertions(+), 13 deletions(-) + +commit 53be607edc18a861aeb0b6663bac3c05de46c84c +Author: Hib Eris <hib@hiberis.nl> +Date: Fri Oct 24 11:35:17 2014 +0200 + + Fix warning on unused variable in pdftocairo.cc + + Fixes warning: + + CXX pdftocairo-pdftocairo.o + pdftocairo.cc:130:14: warning: ‘setupdlg’ defined but not used + [-Wunused-variable] + static GBool setupdlg = gFalse; + ^ + + https://bugs.freedesktop.org/show_bug.cgi?id=85400 + + utils/pdftocairo.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit f966b8766d40b2c912e69a1e17ef8cc4bd52be95 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Oct 21 16:42:27 2014 +0200 + + fofi: Fix a crash when parsing an invalid font due to a integer + overflow + + This fixes a crash rendering trust_metrics.f2495.f0.pdf. + + fofi/FoFiType1.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 4963332ca4db13d8a9186b06d2aa0d59abbc10ee +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Oct 5 21:58:37 2014 +1030 + + pdftocairo: add -printdlg output option for win32 + + when set the win32 print dialog is displayed before printing + + configure.ac | 2 +- + utils/pdftocairo-win32.cc | 303 + ++++++++++++++++++++++++++++++++++++++++++++-- + utils/pdftocairo-win32.h | 14 +-- + utils/pdftocairo.1 | 14 ++- + utils/pdftocairo.cc | 31 ++++- + 5 files changed, 337 insertions(+), 27 deletions(-) + +commit d8fe025c36f555a5438677e20df803eee216bb13 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Oct 5 18:11:09 2014 +1030 + + pdftocairo: add a -setupdlg option that will the show printer + properties + + dialog when printing to a win32 printer. + + utils/pdftocairo-win32.cc | 22 +++++++++++++++++++--- + utils/pdftocairo-win32.h | 3 ++- + utils/pdftocairo.1 | 5 +++++ + utils/pdftocairo.cc | 24 ++++++++++++++++-------- + 4 files changed, 42 insertions(+), 12 deletions(-) + +commit c091aa14513859ab76223f5e4e6055d92082433c +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Sep 14 20:43:47 2014 +0930 + + pdftocairo: fix a number of bugs in win32 printing + + - make origPageSizes work + - make landscape pages work + - make -noshrink option work + - return actual page size in use back to main() so fit page transform + works + - hdc should be destroyed after cairo surface + - improve option parsing and rename duplex values + - Add third call to DocumentProperties as discussed in bug 79936 + - fix error messages + + utils/pdftocairo-win32.cc | 181 + ++++++++++++++++++++++++++-------------------- + utils/pdftocairo-win32.h | 2 +- + utils/pdftocairo.1 | 5 +- + utils/pdftocairo.cc | 49 ++++++------- + 4 files changed, 132 insertions(+), 105 deletions(-) + +commit cc3b39d49c656e912a7461212f3bb4e58c6444e7 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Sep 12 18:17:49 2014 +0930 + + make pdftocairo-win32.cc a standalone .cc file + + instead of #including it in pdftocairo.cc + + utils/CMakeLists.txt | 1 + + utils/Makefile.am | 3 +- + utils/pdftocairo-win32.cc | 74 + +++++++++++++++++++++++------------------------ + utils/pdftocairo-win32.h | 22 ++++++++++++++ + utils/pdftocairo.cc | 24 +++++++++------ + 5 files changed, 77 insertions(+), 47 deletions(-) + +commit 700205af19ef1ae5f2c713d118ebd5dd4a0afba3 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Sep 7 20:18:36 2014 +0930 + + pdftocairo: Allow an output file for win32 printing to be specified + + Can be used for testing win32 print output without wasting paper. + + utils/pdftocairo-win32.cc | 12 ++++++++---- + utils/pdftocairo.1 | 4 ++++ + utils/pdftocairo.cc | 13 +++++++------ + 3 files changed, 19 insertions(+), 10 deletions(-) + +commit 40d3ae87befad489fd8c0b38ff2561a0782cae0b +Author: Rodrigo Rivas Costa <rodrigorivascosta@gmail.com> +Date: Sat Sep 6 21:04:10 2014 +0930 + + Add support for printing to a Windows printer from pdftocairo + + Bug 79936 + + configure.ac | 2 +- + utils/pdftocairo-win32.cc | 219 + ++++++++++++++++++++++++++++++++++++++++++++++ + utils/pdftocairo.1 | 23 ++++- + utils/pdftocairo.cc | 61 ++++++++++--- + 4 files changed, 292 insertions(+), 13 deletions(-) + +commit ee4a389872d86b619c677888da8f13f1f6c54472 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Oct 20 22:32:30 2014 +1030 + + PDFDoc: fix crash when getPage() returns NULL + + Bug 85235 + + poppler/PDFDoc.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0c3f53e34ec287dab2784e1f3411ad06b62dffc7 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Oct 20 22:17:20 2014 +1030 + + PDFDOC: Check for EOF when reading raw stream + + Bug 85233 + + poppler/PDFDoc.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 88dbd4df0998233939b4a51cedbfc65c58a315f9 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Oct 19 22:47:15 2014 +1030 + + pdfdetach: fix crash when getPage() returns null + + Bug 85145 + + utils/pdfdetach.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit e0179304cdef615fcf639046410d214fd5b5f276 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Oct 19 21:36:39 2014 +1030 + + cairo: fix crash when no group color space + + Bug 85137 + + poppler/CairoOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 745f1241bf903969e50f0e1139641e389a9c331f +Author: Scott West <scott.gregory.west@gmail.com> +Date: Tue Oct 7 23:54:52 2014 +0200 + + Fix memory leak in Dict.remove. + + The entry was previously just overwritten now it is freed + + Small fixes by Albert oo + + Bug #84607 + + poppler/Dict.cc | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +commit b8810703ca76f0bbc8185ab87679cf18eb006d52 +Author: Luigi Scarso <luigi.scarso@gmail.com> +Date: Tue Oct 7 22:45:05 2014 +0200 + + Make Attribute::getName() work when UTF-16BE is used + + Contains some ideas by me + Bug #84722 + + goo/GooString.h | 9 +++++---- + poppler/StructElement.cc | 17 +++++++++++------ + poppler/StructElement.h | 7 +++++-- + 3 files changed, 21 insertions(+), 12 deletions(-) + +commit 96a04336c7a6331727724125686a0d6f42f19f46 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Oct 6 10:21:51 2014 +1030 + + cairo: only embed mime data if image decode map is identity + + https://bugs.launchpad.net/ubuntu/+source/cairo/+bug/1317517 + + poppler/CairoOutputDev.cc | 19 ++++++++++++++++--- + poppler/CairoOutputDev.h | 3 ++- + 2 files changed, 18 insertions(+), 4 deletions(-) + +commit 18541054bebce3f9d4729629785bf140d67d2da0 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Sep 24 21:20:42 2014 +0930 + + cairo: Only embed mime data for gray/rgb/cmyk colorspaces + + Bug 80719 + + poppler/CairoOutputDev.cc | 39 +++++++++++++++++++++++++++++++-------- + poppler/CairoOutputDev.h | 2 +- + 2 files changed, 32 insertions(+), 9 deletions(-) + +commit cbf2652c483d7010fc36191c8b209a57eeec93d8 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu Jan 26 00:37:17 2012 +1030 + + cairo: don't render text when text matrix is not invertable + + Emulates acroread behavior. + + Bug 78042 + + poppler/CairoOutputDev.cc | 14 +++++++++----- + poppler/CairoOutputDev.h | 1 + + 2 files changed, 10 insertions(+), 5 deletions(-) + +commit 4fe17e97a4bd7873caad771c446199b282039697 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Oct 5 11:30:43 2014 +0200 + + glib: Build introspection linking to the uninstalled libraries + + https://bugs.freedesktop.org/show_bug.cgi?id=84526 + + glib/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit a2477da56a4d1c534175940d7c01a9d3db6c72d4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Oct 1 22:33:11 2014 +0200 + + Fix 303287ebdad0de9fb2655c4d7eab627c0045ea04 + + It may happen that j is bigger than macGlyphNames size, so don't + try to access it + + fofi/FoFiTrueType.cc | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +commit ce95ecda450361496aedd5d5cd0bf47fd2c66703 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 30 19:50:20 2014 +0200 + + Fix assert in 5068.asan.0.6052.pdf + + poppler/Gfx.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 01723aa17e836e818158dbdc56df642a290be300 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Sep 30 18:48:47 2014 +0200 + + Map Standard/Expert encoding ligatures to AGLFN names + + for use with substitute fonts that are not compatible with the + Standard 14 fonts. + + Bug 80093 + + poppler/CairoFontEngine.cc | 12 +++++++++--- + poppler/GfxFont.cc | 29 ++++++++++++++++++++++++++++- + poppler/GfxFont.h | 7 ++++++- + splash/SplashFTFontFile.cc | 8 ++++++++ + 4 files changed, 51 insertions(+), 5 deletions(-) + +commit 529db4a94607c1ad909764d26f740c601bbe896f +Author: Hib Eris <hib@hiberis.nl> +Date: Mon Sep 29 22:59:15 2014 +0200 + + Fix build with --disable-utils + + Since 21b5fd655ce45b90668d1416d21c526ab7eb3ad6, building Poppler + fails when configured + with '--disable-utils'. + + Bug #84448 + + Makefile.am | 6 +----- + utils/Makefile.am | 4 ++++ + 2 files changed, 5 insertions(+), 5 deletions(-) + +commit c54f6aceed983a221d88ce5c21becbf8aab2931b +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Mon Sep 29 21:42:46 2014 +0200 + + use alt colorspace to get CMYK values for an ICC based CMYK colorspace + + The reason for the pale image is that GfxICCBasedColorSpace::getCMYK() + uses the cms transformation to get RGB values and the convert it + back to CMYK even for a ICC based CMYK colorspace instead of just + returning the CMYK values itself. + + Bug #79019 + + poppler/GfxState.cc | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +commit 21b5fd655ce45b90668d1416d21c526ab7eb3ad6 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Sep 14 11:20:23 2014 +0200 + + Refactor Makefiles to build a noinst library for parsing args + + Prevents this automake warning about possible forward-incompatibility: + + $ ./autogen.sh + ... + cpp/tests/Makefile.am:16: warning: source file + '$(top_srcdir)/utils/parseargs.cc' is in a subdirectory, + cpp/tests/Makefile.am:16: but option 'subdir-objects' is disabled + automake: warning: possible forward-incompatibility. + automake: At least a source file is in a subdirectory, but the + 'subdir-objects' + automake: automake option hasn't been enabled. For now, the + corresponding output + automake: object file(s) will be placed in the top-level directory. + However, + automake: this behaviour will change in future Automake versions: + they will + automake: unconditionally cause object files to be placed in the + same subdirectory + automake: of the corresponding sources. + automake: You are advised to start using 'subdir-objects' option + throughout your + automake: project, to avoid future incompatibilities. + cpp/tests/Makefile.am:20: warning: source file + '$(top_srcdir)/utils/parseargs.cc' is in a subdirectory, + cpp/tests/Makefile.am:20: but option 'subdir-objects' is disabled + parallel-tests: installing './test-driver' + test/Makefile.am:58: warning: source file '../utils/parseargs.cc' + is in a subdirectory, + test/Makefile.am:58: but option 'subdir-objects' is disabled + + $ automake --version + automake (GNU automake) 1.14.1 + ... + + https://bugs.freedesktop.org/show_bug.cgi?id=83839 + + cpp/tests/Makefile.am | 3 +-- + test/Makefile.am | 8 ++++---- + utils/.gitignore | 2 ++ + utils/Makefile.am | 42 ++++++++++++++++++------------------------ + 4 files changed, 25 insertions(+), 30 deletions(-) + +commit 70a851b0cc58241d1f2f6bc48af2614595326c8f +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Sep 6 21:16:04 2014 +0930 + + Update .gitignore + + .gitignore | 2 ++ + 1 file changed, 2 insertions(+) + +commit d44e7e3560bdc79253df98db05385dce3e8ccbb4 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Sep 6 21:53:21 2014 +0930 + + Don't use -fPIC on mingw + + it emits a warning for every file stating that -fPIC is ignored + + configure.ac | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +commit 2723371b2e2f7684301ea1c5272ab49851f28c03 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Sep 6 21:19:46 2014 +0930 + + make autogen.sh work with variables with spaces + + eg ./autogen.sh CXXFLAGS="-O0 -g3" + + autogen.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ebc814a7e31511308bbcd8856d0356f4d7cc74be +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Sep 14 11:45:12 2014 +0200 + + Add compile to .gitignore + + Automake automatically creates a wrapper script called 'compile' for + compilers which do not understand '-c -o'. + + $ automake --version + automake (GNU automake) 1.14.1 + + https://bugs.freedesktop.org/show_bug.cgi?id=83840 + + .gitignore | 1 + + 1 file changed, 1 insertion(+) + +commit 8ce31485faa26994c52f4d032cc5a8355aba23d1 +Merge: 4589ce1 303287e +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 26 00:40:43 2014 +0200 + + Merge remote-tracking branch 'origin/poppler-0.26' + +commit 303287ebdad0de9fb2655c4d7eab627c0045ea04 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Fri Sep 26 00:25:38 2014 +0200 + + Fix rendering of file with a wrong embedded font + + Bug #84270 + + fofi/FoFiTrueType.cc | 22 ++++++++++++++-------- + 1 file changed, 14 insertions(+), 8 deletions(-) + +commit f94ba85a736b4c90c05e7782939f32506472658e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Sep 12 19:22:20 2014 +0200 + + glib: Fix use of uninitialized members in PopplerInputStream + + https://bugs.freedesktop.org/show_bug.cgi?id=82630 + + glib/poppler-input-stream.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 4589ce17caf94e7c5fa856906d3a8cc08e999d73 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Sep 12 19:22:20 2014 +0200 + + glib: Fix use of uninitialized members in PopplerInputStream + + https://bugs.freedesktop.org/show_bug.cgi?id=82630 + + glib/poppler-input-stream.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit fe67324d450c356b7c876cf50da705156112513a +Merge: e62e18e f74a596 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 21 21:39:52 2014 +0200 + + Merge remote-tracking branch 'origin/poppler-0.26' + +commit f74a5964078224c01bd5642aabc928d185bb0b69 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 21 20:07:54 2014 +0200 + + 0.26.4 + + CMakeLists.txt | 2 +- + NEWS | 12 ++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 6 files changed, 17 insertions(+), 5 deletions(-) + +commit ce92e4ccefc7dad79db7f0af7a792ffa47824849 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 21 20:03:42 2014 +0200 + + Update (C) years + + poppler/Annot.cc | 1 + + poppler/CairoOutputDev.cc | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +commit 42315c28809e62da7872add917e82853cf8c7e33 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 21 19:58:35 2014 +0200 + + Make sure e is always initialized + + goo/gfile.cc | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +commit e62e18e1b318d6fa664d236723de3c06ae43e86b +Author: Jehan Pagès <jehan@zemarmot.net> +Date: Tue Aug 12 21:05:03 2014 +0200 + + poppler: use poppler-data pkg-config for both cmake and autotools + builds + + CMakeLists.txt | 16 ++++++++++++++++ + config.h.cmake | 2 +- + configure.ac | 7 ++++++- + 3 files changed, 23 insertions(+), 2 deletions(-) + +commit 572c60764bbbd2080bfd7a926c646ad20b467aea +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Aug 12 18:12:45 2014 +0200 + + Makefile.am cleanups + + Bug #79411 + + configure.ac | 13 +++-- + cpp/Makefile.am | 66 +++++++++++++------------ + cpp/tests/Makefile.am | 13 ++--- + fofi/Makefile.am | 6 +-- + glib/Makefile.am | 29 ++++++----- + glib/demo/Makefile.am | 18 +++---- + glib/reference/Makefile.am | 3 +- + goo/Makefile.am | 38 +++++++-------- + poppler/Makefile.am | 118 + ++++++++++++++++++++++----------------------- + qt4/demos/Makefile.am | 59 +++++++++++------------ + qt4/src/Makefile.am | 31 ++++++------ + qt4/tests/Makefile.am | 97 +++++++++++++------------------------ + qt5/demos/Makefile.am | 59 +++++++++++------------ + qt5/src/Makefile.am | 27 ++++++----- + qt5/tests/Makefile.am | 98 ++++++++++++++----------------------- + splash/Makefile.am | 42 ++++++++-------- + test/Makefile.am | 68 +++++++++----------------- + utils/Makefile.am | 97 ++++++++++++++++++------------------- + 18 files changed, 405 insertions(+), 477 deletions(-) + +commit 4a4fe80d85a31b10822c7cd8eb5a0698bf306a52 +Author: Hib Eris <hib@hiberis.nl> +Date: Fri Aug 1 07:16:36 2014 +0200 + + glib-demo: Replace use of deprecated gtk stock items + + https://bugs.freedesktop.org/show_bug.cgi?id=82384 + + glib/demo/annots.c | 8 ++++---- + glib/demo/attachments.c | 4 ++-- + glib/demo/main.c | 6 +++--- + glib/demo/page.c | 6 +++--- + glib/demo/utils.c | 4 ++-- + 5 files changed, 14 insertions(+), 14 deletions(-) + +commit ec6bad36cf5e9521f35285a3295976c05a69f76a +Author: Hib Eris <hib@hiberis.nl> +Date: Fri Aug 1 07:51:10 2014 +0200 + + glib-demo: Remove use of deprecated gtk_dialog_get_action_area() + + https://bugs.freedesktop.org/show_bug.cgi?id=82385 + + glib/demo/main.c | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +commit b72a534d6c7d8bc026812b68f9d9ac6bf9a2200a +Merge: f2e4154 ef3f758 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 3 01:06:57 2014 +0200 + + Merge remote-tracking branch 'origin/poppler-0.26' + +commit ef3f7585fac086de0919aa0bb0ef91a5070ac23e +Author: Jiri Slaby <jirislaby@gmail.com> +Date: Sun Aug 3 01:05:00 2014 +0200 + + Improve non-latin characters in inline notes + + Preview commit had by mistake changes in these two files that + belong here + + Bug #65956 + + poppler/Annot.cc | 1 + + poppler/CharCodeToUnicode.cc | 1 + + 2 files changed, 2 insertions(+) + +commit 1b9c54286a4cdfaa284795933c20acf3c7e13bfc +Author: Ed Porras <ed@moto-research.com> +Date: Sun Aug 3 01:01:35 2014 +0200 + + Don't check for inlineImg twice + + Bug #82059 + + poppler/Annot.cc | 2 +- + poppler/CharCodeToUnicode.cc | 2 +- + poppler/SplashOutputDev.cc | 9 ++++----- + 3 files changed, 6 insertions(+), 7 deletions(-) + +commit f2e4154eff52b86e62490a3ccba470824c9cf436 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sat Jul 26 00:12:37 2014 +0200 + + pdfseparate: additonal handling for annotations + + Bug #77549 + + poppler/PDFDoc.cc | 46 ++++++++++++++++++++++++++++------------------ + poppler/PDFDoc.h | 6 +++--- + utils/pdfunite.cc | 2 +- + 3 files changed, 32 insertions(+), 22 deletions(-) + +commit e7825f7cbbe7cc9c324fcb34c2e0dcae75f4172a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jul 25 15:45:55 2014 +0200 + + glib: Fix a memory leak when getting text layout and attributes + + glib/poppler-page.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit b729bf92ea1522a1eed9579e53e7580215cb9555 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jul 25 15:45:55 2014 +0200 + + glib: Fix a memory leak when getting text layout and attributes + + glib/poppler-page.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit a1ecff0f0ab81fe76f63244250d96e7ef275f402 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jul 25 11:25:42 2014 +0200 + + glib: Return NULL in poppler_annot_get_contents also for empty strings + + glib/poppler-annot.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ab1113d10ef712c7c44cd4b4bb6bc79f9ca3702c +Author: Anuj Khare <khareanuj18@gmail.com> +Date: Thu Jul 24 19:47:22 2014 +0200 + + annots: Fix a crash when adding annot without contents + + Having no content in an annotation results in a crash when generating + its appearance, since the contents pointer is dereferenced. + For consistency, the same has been done in Annot::initialize. + + poppler/Annot.cc | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit f302864ed354b313ec39433f65ca3b107b55789d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jul 25 11:25:42 2014 +0200 + + glib: Return NULL in poppler_annot_get_contents also for empty strings + + glib/poppler-annot.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 13a5c5f4b61d05f2d18f94ad15e210a47021a576 +Author: Anuj Khare <khareanuj18@gmail.com> +Date: Thu Jul 24 19:47:22 2014 +0200 + + annots: Fix a crash when adding annot without contents + + Having no content in an annotation results in a crash when generating + its appearance, since the contents pointer is dereferenced. + For consistency, the same has been done in Annot::initialize. + + poppler/Annot.cc | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit 94ea9d8e1631abfbb8cc078100942d46b1356970 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 24 10:46:17 2014 +0200 + + cairo: Make sure we always push a transparency group in + setSoftMaskFromImageMask() + + Because that's what unsetSoftMaskFromImageMask() assumes. + + https://bugs.freedesktop.org/show_bug.cgi?id=81624 + + poppler/CairoOutputDev.cc | 64 + +++++++++++++++++++++++------------------------ + 1 file changed, 31 insertions(+), 33 deletions(-) + +commit 02c127b355bb8a98684a5d0af063c60b8bfd09dd +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 24 10:46:17 2014 +0200 + + cairo: Make sure we always push a transparency group in + setSoftMaskFromImageMask() + + Because that's what unsetSoftMaskFromImageMask() assumes. + + https://bugs.freedesktop.org/show_bug.cgi?id=81624 + + poppler/CairoOutputDev.cc | 64 + +++++++++++++++++++++++------------------------ + 1 file changed, 31 insertions(+), 33 deletions(-) + +commit c841a703c4c1750fd7ac0d04c6c3e7d4af80b8fa +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 21 00:29:28 2014 +0200 + + Improve Overprintmode and shadings + + Bug #80998 + + poppler/SplashOutputDev.cc | 6 ++++-- + poppler/SplashOutputDev.h | 8 +++++++- + splash/Splash.cc | 24 ++++++++++++++++++++++-- + splash/SplashPattern.h | 6 +++++- + 4 files changed, 38 insertions(+), 6 deletions(-) + +commit ce782112746f629a8e7be6f2daf6ece6ab19917d +Merge: 2c0cb68 26372cf +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jul 20 20:35:13 2014 +0200 + + Merge remote-tracking branch 'origin/poppler-0.26' + +commit 26372cfae029a1124e042855c58bf5b70f281c76 +Author: Ed Porras <ed@moto-research.com> +Date: Sun Jul 20 20:33:48 2014 +0200 + + printf -> error + + Bug #81513 + + poppler/Catalog.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 87d12c09281e3d12cda0fadcd65ab78928dff283 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jul 20 18:20:57 2014 +0200 + + 0.26.3 + + CMakeLists.txt | 2 +- + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 5 files changed, 5 insertions(+), 5 deletions(-) + +commit 69e5b81640c9bb31f0876fa8eb7ba28dbf38923f +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jul 20 18:18:29 2014 +0200 + + News for 0.26.3 + + NEWS | 21 +++++++++++++++++++++ + 1 file changed, 21 insertions(+) + +commit c368c0714d57c089057d974908295d850a1b5108 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jul 20 18:15:22 2014 +0200 + + Update Thomas' (C) + + splash/SplashXPathScanner.cc | 2 +- + splash/SplashXPathScanner.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 639179318c43a907a27e86778b720d33d481a9f9 +Author: Pino Toscano <pino@kde.org> +Date: Thu Jul 17 07:33:10 2014 +0200 + + glib: use C90-style comments in public headers + + glib/poppler-media.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 2c0cb689910e8579bf428b3999bcac0cb27b0e51 +Merge: 0b639cd 1161e72 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jul 12 17:21:07 2014 +0200 + + Merge remote-tracking branch 'origin/poppler-0.26' + +commit 1161e728de9ca7c9a5fb0e24c4a5e4a79c65a849 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sat Jul 12 17:04:42 2014 +0200 + + Error out instead of exiting if allInter grows too much + + Bug #78714 + + splash/SplashXPathScanner.cc | 25 +++++++++++++++++-------- + splash/SplashXPathScanner.h | 2 +- + 2 files changed, 18 insertions(+), 9 deletions(-) + +commit e82a24a585d251f767725f61700dc1f8fe169a52 +Author: Pino Toscano <pino@kde.org> +Date: Sat Jul 12 08:35:45 2014 +0200 + + cmake: sync poppler-config.h.cmake with poppler-config.h.in + + poppler/poppler-config.h.cmake | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +commit 0b639cd2ac1071f5b741031a78d8e2bc18d2b7d7 +Merge: bb16c71 a5ad55b +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 11 00:32:46 2014 +0200 + + Merge remote-tracking branch 'origin/poppler-0.26' + +commit a5ad55b7cb9dc4e62754954291e4ecb8e05b5d67 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 11 00:32:07 2014 +0200 + + Add Hib's (C) + + poppler/poppler-config.h.in | 1 + + 1 file changed, 1 insertion(+) + +commit 4f4ee736075d5b1d1bf4911a26c2f80a7122fe04 +Author: Aki Koskinen <freedesktop@akikoskinen.info> +Date: Fri Jul 11 00:30:52 2014 +0200 + + Fix compilation of Qt5 frontend with MinGW + + qt5/src/poppler-private.h | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +commit ddd91675792d9d496b06223867e05d2a190b878b +Author: Hib Eris <hib@hiberis.nl> +Date: Thu May 29 16:58:55 2014 +0200 + + Include stdio.h from poppler-config.h + + In poppler-config.h there is a check for __MINGW_PRINTF_FORMAT, + which is set by stdio.h. + + This fixes this warning when compling with the mingw-w64-compiler: + + XRef.cc: In member function 'virtual void + XRef::XRefTableWriter::writeEntry(Goffset, int, XRefEntryType)': + XRef.cc:1460:94: warning: unknown conversion type character 'l' + in format [-Wformat=] + outStr->printf("%010lli %05i %c\r\n", (long long)offset, gen, + (type==xrefEntryFree)?'f':'n'); + ^ + XRef.cc:1460:94: warning: format '%i' expects argument of type 'int', + but argument 3 has type 'Goffset {aka long long int}' [-Wformat=] + XRef.cc:1460:94: warning: too many arguments for format + [-Wformat-extra-args] + + https://bugs.freedesktop.org/show_bug.cgi?id=79762 + + poppler/poppler-config.h.in | 2 ++ + 1 file changed, 2 insertions(+) + +commit bb16c7162c73b871e26f508823c0ee259b7e5420 +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Jun 7 12:00:52 2014 +0200 + + Move automake version check from autogen.sh to configure.ac + + https://bugs.freedesktop.org/show_bug.cgi?id=79797 + + autogen.sh | 18 ------------------ + configure.ac | 2 +- + 2 files changed, 1 insertion(+), 19 deletions(-) + +commit 74c72223cf609e7c24594f95cab6f9865ad562ac +Merge: f8f7b3a 47a947f +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 11 00:23:04 2014 +0200 + + Merge remote-tracking branch 'origin/poppler-0.26' + +commit 47a947f1dc664793a7037888a46a297a46c79d6c +Author: Hib Eris <hib@hiberis.nl> +Date: Thu Jun 19 10:11:21 2014 +0200 + + Fix moc-qt5 detection + + https://bugs.freedesktop.org/show_bug.cgi?id=80250 + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit f8f7b3a61bc7eb1e569c25a630b5e127b5dcae62 +Merge: 805ff76 aa6205d +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jul 9 00:23:22 2014 +0200 + + Merge remote-tracking branch 'origin/poppler-0.26' + +commit aa6205d195c56a77e897bad125bf213aba138422 +Author: Jason Crain <jason@aquaticape.us> +Date: Mon Jul 7 23:52:39 2014 -0500 + + Increase required Qt4 version to 4.7.0 + + We use Qt::LayoutDirectionAuto, introduced in 4.7.0. + + bug #81005 + + CMakeLists.txt | 2 +- + configure.ac | 8 ++++---- + 2 files changed, 5 insertions(+), 5 deletions(-) + +commit 805ff76112ebfd57276ea78f1f0891abc61a6c03 +Author: Yaakov Selkowitz <yselkowitz@users.sourceforge.net> +Date: Mon Apr 11 16:26:11 2011 -0500 + + Do not dist gir_DATA + + See https://bugzilla.gnome.org/show_bug.cgi?id=621611 for rationale. + + glib/Makefile.am | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit e5862155b1c549b6774bb4f25c09c45857ff1734 +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Jun 4 20:58:56 2014 +0200 + + Add Changelog to .gitignore + + https://bugs.freedesktop.org/show_bug.cgi?id=79744 + + .gitignore | 1 + + 1 file changed, 1 insertion(+) + +commit 5f22649694d64c4170db82847b599576d5377176 +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Jun 4 20:56:23 2014 +0200 + + Add *.gir, *.typelib to glib/.gitignore + + https://bugs.freedesktop.org/show_bug.cgi?id=79744 + + glib/.gitignore | 2 ++ + 1 file changed, 2 insertions(+) + +commit b63f57985719c7884b67f46fc4afd4954c44c5ab +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Jun 4 20:54:30 2014 +0200 + + Add poppler-undeclared.txt to .gitignore + + https://bugs.freedesktop.org/show_bug.cgi?id=79744 + + glib/reference/.gitignore | 1 + + 1 file changed, 1 insertion(+) + +commit 5e0f4e2516d5a3997ea9c9a9927e24d4f3abe136 +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Jun 4 20:52:15 2014 +0200 + + Add poppler-forms, stress-threads-qt, test-render-to-file to + .gitignore + + https://bugs.freedesktop.org/show_bug.cgi?id=79744 + + qt4/tests/.gitignore | 3 +++ + qt5/tests/.gitignore | 3 +++ + 2 files changed, 6 insertions(+) + +commit 4d2400e7bb8ae9208030b9615dda7c53e571be8b +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Jun 4 10:09:16 2014 +0200 + + Add test-driver to .gitignore + + https://bugs.freedesktop.org/show_bug.cgi?id=79744 + + .gitignore | 1 + + 1 file changed, 1 insertion(+) + +commit 4c35e0213be26f21b628ff8d9f170252bb0106c9 +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Jun 4 10:06:20 2014 +0200 + + Add poppler-qt5.pc to .gitignore + + https://bugs.freedesktop.org/show_bug.cgi?id=79744 + + .gitignore | 2 ++ + 1 file changed, 2 insertions(+) + +commit 2b455b85168d5c9d8641d9a91bfde81ccab18e54 +Author: Pino Toscano <pino@kde.org> +Date: Sun Jul 6 11:13:54 2014 +0200 + + glib: fix typo in apidox + + glib/poppler.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 266a61ab1c9f536a4fb7d68c8f285c854eb2d6e9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jun 19 20:16:19 2014 +0200 + + 0.26.2 + + CMakeLists.txt | 2 +- + NEWS | 10 ++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 6 files changed, 15 insertions(+), 5 deletions(-) + +commit 3381ee20efca2ce27733182d0d6720c1e6936a7f +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jun 19 19:57:31 2014 +0200 + + Update (C) + + poppler/Lexer.cc | 2 +- + utils/pdftohtml.cc | 1 + + 2 files changed, 2 insertions(+), 1 deletion(-) + +commit 8a5e59c6ea7ccd0ecbdb4b37bf3fe4e74e1c0e8e +Merge: 1b70533 310fbee +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 18 00:37:03 2014 +0200 + + Merge remote-tracking branch 'origin/poppler-0.26' + +commit 310fbeec692b02d555e3e8dd6c851be11b25e26a +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 18 00:31:48 2014 +0200 + + Make sure we have an xref before using + + KDE bug #335413 had this backtrace + XRef::getNumEntry (this=0x0, offset=-1) at XRef.cc:1300 + 0x00007f29aec1681e in Lexer::getObj (this=0x1648760, + obj=obj@entry=0x1bdf978, cmdA=cmdA@entry=0x7f29aeca66c8 "endstream", + objNum=objNum@entry=0) at Lexer.cc:594 + 0x00007f29aec20dfd in Parser::shift (this=this@entry=0x1bdf950, + cmdA=cmdA@entry=0x7f29aeca66c8 "endstream", objNum=objNum@entry=0) + at Parser.cc:323 + 0x00007f29aec20fde in Parser::makeStream (this=this@entry=0x1bdf950, + dict=dict@entry=0x7fff2541cad0, fileKey=fileKey@entry=0x0, + encAlgorithm=encAlgorithm@entry=cryptRC4, keyLength=keyLength@entry=0, + objNum=objNum@entry=0, objGen=objGen@entry=0, + recursion=recursion@entry=1, strict=strict@entry=false) at + Parser.cc:245 + 0x00007f29aec216b8 in Parser::getObj (this=this@entry=0x1bdf950, + obj=obj@entry=0x7fff2541cad0, simpleOnly=simpleOnly@entry=false, + fileKey=fileKey@entry=0x0, encAlgorithm=encAlgorithm@entry=cryptRC4, + keyLength=keyLength@entry=0, objNum=objNum@entry=0, + objGen=objGen@entry=0, recursion=recursion@entry=0, + strict=strict@entry=false) at Parser.cc:131 + 0x00007f29aec350fc in XRef::readXRef + (this=this@entry=0xfe43a0, pos=pos@entry=0xfe4438, + followedXRefStm=followedXRefStm@entry=0x7fff2541cb30, + xrefStreamObjsNum=xrefStreamObjsNum@entry=0x0) at XRef.cc:551 + 0x00007f29aec35319 in XRef::XRef (this=0xfe43a0, + strA=0x1c54ff0, pos=<optimized out>, mainXRefEntriesOffsetA=0, + wasReconstructed=0x7fff2541cbaf, reconstruct=<optimized out>) + at XRef.cc:342 + 0x00007f29aec2534f in PDFDoc::setup (this=this@entry=0x311e1b0, + ownerPassword=ownerPassword@entry=0x1165830, + userPassword=userPassword@entry=0x447f550) at PDFDoc.cc:262 + + poppler/Lexer.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1b705331019b155f2138d4b9f5a5bd03ec59193d +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Jun 8 17:07:15 2014 +0200 + + [glib] doc: Move poppler_date_parse to utility functions section + + https://bugs.freedesktop.org/show_bug.cgi?id=79798 + + glib/reference/poppler-docs.sgml | 1 + + glib/reference/poppler-sections.txt | 7 ++++++- + 2 files changed, 7 insertions(+), 1 deletion(-) + +commit d661553b0a13855aa5a1240e9c04a0e49dafd910 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Jun 8 16:11:26 2014 +0200 + + [glib] doc: Document PopplerFindFlags:POPPLER_FIND_DEFAULT + + Fixes warning: + DOC Building XML + ../../glib/poppler.h:157: warning: Value description for + PopplerFindFlags::POPPLER_FIND_DEFAULT is missing in source code + comment + block. + + https://bugs.freedesktop.org/show_bug.cgi?id=79798 + + glib/poppler.h | 1 + + 1 file changed, 1 insertion(+) + +commit 237a1402ab836d10eb5fdc1aa6ceccabea10a316 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Jun 8 16:07:14 2014 +0200 + + [glib] doc: Use <emphasis> instead of <em> + + Fixes: + DOC Building HTML + Element em in namespace '' encountered in para, but no template + matches. + + https://bugs.freedesktop.org/show_bug.cgi?id=79798 + + glib/poppler-structure-element.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 66abf3992228be2559542e9d2753f45f06ae7728 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Jun 8 16:02:01 2014 +0200 + + [glib] doc: Add PopplerBackend documentation + + https://bugs.freedesktop.org/show_bug.cgi?id=79798 + + glib/poppler.h | 8 ++++++++ + 1 file changed, 8 insertions(+) + +commit a30ec8e4abe3875aad068c83265b47f9beea33d1 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Jun 8 15:05:52 2014 +0200 + + [glib] doc: Add missing POPPLER_TYPE_POINT + + And while we are here, also move poppler_point_get_type() and + poppler_quadrilateral_get_type() to private subsection. + + https://bugs.freedesktop.org/show_bug.cgi?id=79798 + + glib/reference/poppler-sections.txt | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +commit 6eb0537ac5163356c8e8f689d2408fa695e99423 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Jun 8 14:59:15 2014 +0200 + + [glib] doc: Fix typo + + https://bugs.freedesktop.org/show_bug.cgi?id=79798 + + glib/reference/poppler-sections.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 96adcad85d76409cb8ed4266a08ae776b42661e4 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Jun 8 14:53:42 2014 +0200 + + [glib] doc: Add poppler_annot_set_flags() to documentation + + https://bugs.freedesktop.org/show_bug.cgi?id=79798 + + glib/reference/poppler-sections.txt | 1 + + 1 file changed, 1 insertion(+) + +commit f3519352c70537009cc6bd660c0bd3e727db8b8a +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Jun 8 14:38:13 2014 +0200 + + [glib] doc: Move PopplerFindFlags to PopplerPage section + + And also add the missing POPPLER_TYPE_FIND_FLAGS and + poppler_find_flags_get_type. + + https://bugs.freedesktop.org/show_bug.cgi?id=79798 + + glib/reference/poppler-sections.txt | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 45b0d49330d9d089b2480b91e418924a490c82ce +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Jun 8 14:22:28 2014 +0200 + + [glib] doc: Move PopplerPrintFlags to PopplerPage section + + https://bugs.freedesktop.org/show_bug.cgi?id=79798 + + glib/reference/poppler-sections.txt | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit ce357147d17004a2772ca3b32d106da511bba360 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Jun 8 13:22:51 2014 +0200 + + [glib] doc: Move poppler_get_{version, backend} documentation to + features section + + https://bugs.freedesktop.org/show_bug.cgi?id=79798 + + glib/reference/poppler-sections.txt | 15 +++++++++------ + 1 file changed, 9 insertions(+), 6 deletions(-) + +commit 1bfd6b69e7e98d4b3e6e891a46b58c9109b8c14c +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Jun 8 12:57:25 2014 +0200 + + [glib] doc: Move PopplerColor documentation to it's own section + + https://bugs.freedesktop.org/show_bug.cgi?id=79798 + + glib/poppler-page.cc | 6 ++++++ + glib/reference/poppler-docs.sgml | 1 + + glib/reference/poppler-sections.txt | 21 +++++++++++++++------ + 3 files changed, 22 insertions(+), 6 deletions(-) + +commit 2dd9b95fd910023a7d9d23f2c2e41dcab91d3c31 +Merge: fed71eb b36d27b +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jun 6 21:43:49 2014 +0200 + + Merge remote-tracking branch 'origin/poppler-0.26' + +commit b36d27b42417d15866a5729409e39d6f7c2b0289 +Author: Hib Eris <hib@hiberis.nl> +Date: Fri Jun 6 21:42:10 2014 +0200 + + Fix typo in configure.ac + + Bug #79742 + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit fed71ebd8e43e24eace9dcebe24bd318ff3d04a6 +Author: Hib Eris <hib@hiberis.nl> +Date: Thu May 29 13:22:05 2014 +0200 + + Change pagenum arguments in PDFDoc::markAnnotations from Guint to int + + Bug #79410 + Fixes compile warning: + + CXX PDFDoc.lo + PDFDoc.cc: In member function 'GBool PDFDoc::markAnnotations(Object*, + XRef*, XRef*, Guint, Guint, Guint)': + PDFDoc.cc:1607:40: warning: comparison between signed and unsigned + integer expressions [-Wsign-compare] + if (obj2.getRef().num == oldPageNum) { + ^ + PDFDoc.cc:1617:47: warning: comparison between signed and unsigned + integer expressions [-Wsign-compare] + } else if (obj2.getRef().num == newPageNum) { + + https://bugs.freedesktop.org/show_bug.cgi?id=79410 + + poppler/PDFDoc.cc | 4 ++-- + poppler/PDFDoc.h | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +commit f5e702060a84362bfdf75260531920d4ba8b7333 +Author: Pino Toscano <pino@kde.org> +Date: Sat May 24 15:59:42 2014 +0200 + + pdftohtml: exit with 0 with -v and -h + + utils/pdftohtml.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 700bf398ef7b20306f5035e423becfaa3d28fb10 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 23 20:05:41 2014 +0200 + + 0.26.1 + + CMakeLists.txt | 2 +- + NEWS | 12 ++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 6 files changed, 17 insertions(+), 5 deletions(-) + +commit 93373cd113d046b65538fe983b46842d689a2112 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 11 18:31:10 2014 +0200 + + Qt: Add a new page->annotations() call that let's you specify subtypes + + This way we don't return annotations you may not be interested in + + qt4/src/poppler-annotation-private.h | 4 +-- + qt4/src/poppler-annotation.cc | 48 + ++++++++++++++++++++++++++++++++++-- + qt4/src/poppler-page.cc | 7 +++++- + qt4/src/poppler-qt4.h | 14 +++++++++++ + qt5/src/poppler-annotation-private.h | 4 +-- + qt5/src/poppler-annotation.cc | 48 + ++++++++++++++++++++++++++++++++++-- + qt5/src/poppler-page.cc | 7 +++++- + qt5/src/poppler-qt5.h | 15 +++++++++++ + 8 files changed, 137 insertions(+), 10 deletions(-) + +commit d2892cd893e4379914a08e66682ed5c423743a41 +Merge: 0844220 7e9fc61 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed May 7 22:27:41 2014 +0200 + + Merge remote-tracking branch 'origin/poppler-0.26' + +commit 7e9fc61e287889eefd6b08ef5991d31fed79cafd +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed May 7 22:25:59 2014 +0200 + + Fix libopenjpeg 1.5 detection on some systems + + Someone somewhere decided the pc file will be called libopenjpeg1 + instead of libopenjpeg + + Bug #78389 + + configure.ac | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 0844220347f984c3d9b04fe53e690ee0e8c74afe +Merge: 84278d8 0a6c1ff +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed May 7 21:56:07 2014 +0200 + + Merge remote-tracking branch 'origin/poppler-0.26' + +commit 0a6c1ff777aa23c7a5654b313b639e66600883b9 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Wed May 7 21:54:46 2014 +0200 + + Only add annotations of the current page when splitting + + Bug #77549 + + poppler/PDFDoc.cc | 153 + +++++++++++++++++++++++++++++++++++++++++++++++++++++- + poppler/PDFDoc.h | 4 +- + utils/pdfunite.cc | 9 +++- + 3 files changed, 162 insertions(+), 4 deletions(-) + +commit 84278d8adbb1f6e9a28588fcb4db30c9ef70adde +Merge: 7b94b11 5b2cdef +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 4 22:21:25 2014 +0200 + + Merge remote-tracking branch 'origin/poppler-0.26' + +commit 5b2cdef49a8a0a92fd323fbe45841a5098a42ece +Author: Olly Betts <olly@survex.com> +Date: Sun May 4 22:20:30 2014 +0200 + + Fix extraction of text in some files + + Bug #78145 + + poppler/GfxFont.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 7b94b119f07713af7b8b9f1ac3ea3f1d35c1e240 +Merge: c859d2b bae836c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 4 16:21:24 2014 +0200 + + Merge remote-tracking branch 'origin/poppler-0.26' + +commit bae836cd3dd3511ca9cf4745626142334bafd1a6 +Author: Marek Kasik <mkasik@redhat.com> +Date: Sun May 4 16:20:33 2014 +0200 + + Use field value V for radio buttons + + Turn on radio button only if its appearance state is equal to + the value + of name object "V" of the field. + + Bug #75979 + + poppler/Annot.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit a748b3a059938e6ae98b51eb82bab7c33a5e23c7 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Apr 30 09:25:31 2014 +0200 + + glib: Fix multiple definition of PopplerTextSpan + + https://bugs.freedesktop.org/show_bug.cgi?id=78103 + + glib/poppler-structure-element.h | 3 --- + 1 file changed, 3 deletions(-) + +commit c859d2b891a115c79d04db14463791dfb1c46a20 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Apr 30 09:25:31 2014 +0200 + + glib: Fix multiple definition of PopplerTextSpan + + https://bugs.freedesktop.org/show_bug.cgi?id=78103 + + glib/poppler-structure-element.h | 3 --- + 1 file changed, 3 deletions(-) + +commit 9a68daee2b3c7f8a992ee47c0e9ac78b346d4348 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Apr 25 01:01:08 2014 +0200 + + 0.26.0 + + CMakeLists.txt | 4 ++-- + NEWS | 13 +++++++++++++ + configure.ac | 4 ++-- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 6 files changed, 20 insertions(+), 7 deletions(-) + +commit 8073852c84b71257d487aa8a46e441aa82f4b42c +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Mon Apr 14 23:35:50 2014 +0200 + + qt: Fix missing ! in TextAnnotation::setInplaceIntent + + CID #16814 + + qt4/src/poppler-annotation.cc | 2 +- + qt5/src/poppler-annotation.cc | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 1fbf98664c0879ac035a63602242a910c0c1d316 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Apr 14 11:53:59 2014 +0200 + + Initialize tmpBufLen + + CID #16957 + + It isn't really needed since locateFont always returns a fontLoc + with a non null + path if fontLoc itself is not null, but it doesn't hurt either + + qt4/src/ArthurOutputDev.cc | 4 ++-- + qt5/src/ArthurOutputDev.cc | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +commit b3e5c582a279b1b8d8309322ac3f4d0e51831f77 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 10 23:38:09 2014 +0200 + + Remove unused member + + cpp/poppler-font.cpp | 2 -- + 1 file changed, 2 deletions(-) + +commit b86f471c43e387cf873358cf3cbcd27470646713 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 10 22:50:56 2014 +0200 + + 0.25.3 + + CMakeLists.txt | 2 +- + NEWS | 19 +++++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/CairoOutputDev.cc | 2 +- + poppler/GfxFont.cc | 2 +- + qt4/src/Doxyfile | 2 +- + qt4/src/poppler-optcontent.cc | 2 +- + qt5/src/Doxyfile | 2 +- + qt5/src/poppler-optcontent.cc | 2 +- + qt5/src/poppler-private.cc | 2 +- + qt5/src/poppler-private.h | 2 +- + 12 files changed, 30 insertions(+), 11 deletions(-) + +commit 80107c72ac03bf4d00b2d71d6f947c139ea84ab5 +Author: Pino Toscano <pino@kde.org> +Date: Sun Apr 6 20:17:31 2014 +0200 + + qt5: remove m_fontInfoIterator from Document + + it was used by the deprecated scanForFonts API, which was not provided + in poppler-qt5 + + qt5/src/poppler-private.cc | 2 -- + qt5/src/poppler-private.h | 2 -- + 2 files changed, 4 deletions(-) + +commit b8325316e41fb03eb5fac5c80d6a550fe9ce9695 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 6 16:05:51 2014 +0200 + + Fix memory leak + + CID #16943 + + utils/pdfseparate.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit ca9713118d6ce3fdd245f9ca4f595229a5be19c3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 6 15:59:43 2014 +0200 + + Don't check twice for the same variable ^_^ + + CID #16804 + + splash/Splash.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0ef290a7c5a8fa54d3fe0f646abdf098443a7a67 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 6 15:57:38 2014 +0200 + + Fix memory leak + + CID #16852 + + splash/Splash.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 8810b8917fded340b784873a91ca025b0bb49f3d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 6 15:49:18 2014 +0200 + + Fix Out-of-bounds read + + CID #16844 + + poppler/PageLabelInfo_p.h | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit 9309907673e8557a25021dce79d9b4354640e2d0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 6 15:35:00 2014 +0200 + + Fix memory leak + + Don't pass new'ed GooStrings as parameters to error() + + CID #16915 + + poppler/GfxFont.cc | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit a511005584a38217fed582ced6ce2c937526cf96 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 6 15:28:50 2014 +0200 + + Fix Uninitialized pointer read when nFucnsA is 0 + + CID #16965 + + poppler/GfxState.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 26b961a64030d91c5db2769dcd0ab8dff7b9b6a6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 6 15:23:35 2014 +0200 + + gfree -> delete since it was new'ed + + CID #16786 + + poppler/JBIG2Stream.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 814ac2230b594cce3b871588804dd92f4a187e7e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 6 15:22:13 2014 +0200 + + delete -> gfree since it was gmaloced + + CID #16785 + + poppler/JBIG2Stream.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit b496b6665803247b10b018ae939a2a452fa4a48f +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 6 15:17:50 2014 +0200 + + Fix memory leak + + CID #16864 + + poppler/SplashOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 1b612f355e9f29fa93c15a9de1188049a8e086b6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 6 15:14:50 2014 +0200 + + Fix memory leak + + CID #16853 + + poppler/XRef.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 07621ebbda8ab85cf4cd76a6092efc67aa14454d +Merge: 8d3a2c9 9fcd46a +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 5 15:49:31 2014 +0200 + + Merge remote-tracking branch 'origin/poppler-0.24' + +commit 9fcd46ac4a94f138981ec5afaab3875918c6a175 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 5 15:48:27 2014 +0200 + + qt4/qt5: remove extra qDebug + + qt4/src/poppler-optcontent.cc | 1 - + qt5/src/poppler-optcontent.cc | 1 - + 2 files changed, 2 deletions(-) + +commit 37286ee2923de060ae463ac6b178ffd0e6096b90 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 5 15:46:44 2014 +0200 + + qt4/qt5: fix some kinds of OCG models + + properly pass parent and child when building the tree + + qt4/src/poppler-optcontent.cc | 2 +- + qt5/src/poppler-optcontent.cc | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 8d3a2c9d007052bcb8719200760a1abb6314f804 +Author: Peter Breitenlohner <peb@mppmu.mpg.de> +Date: Sun Mar 30 23:34:23 2014 +0200 + + Avoid MinGW/Cygwin warnings due to redefinition of NOMINMAX + + goo/GooMutex.h | 3 +++ + goo/GooTimer.h | 5 ++++- + goo/gfile.h | 5 ++++- + poppler/XpdfPluginAPI.h | 3 +++ + 4 files changed, 14 insertions(+), 2 deletions(-) + +commit 38dcaf96f308265ff6958e4683bcec2be0c254b9 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Mar 28 20:49:17 2014 +1030 + + cairo: fix segv cause by bad image stream + + bug 76445 + + poppler/CairoOutputDev.cc | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +commit 07b0a038b194eb0392a1e9a4236064d37247d687 +Author: Jakub Wilk <jwilk@jwilk.net> +Date: Sun Mar 30 16:12:28 2014 +0200 + + pdftohtml: Fix typo in manpage + + utils/pdftohtml.1 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ac3c8303396a0b8de5e4ad32f480b8da5f3b396e +Author: Thomas Liebetraut <thomas@tommie-lie.de> +Date: Sun Mar 30 12:25:26 2014 +0200 + + glib: Fix the first coord of the qudrilateral in + create_poppler_quads_from_annot_quads() + + https://bugs.freedesktop.org/show_bug.cgi?id=76504 + + glib/poppler-annot.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 82d69da7c2f67e774c51fb7b146fdf639a6b9616 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Mar 28 15:53:22 2014 +0100 + + Fix error reported by ASAN in 3628.asan.0.3910.pdf + + ==20743== ERROR: AddressSanitizer: heap-buffer-overflow on + address 0x60040005c6ef at pc 0x7f8912ca0c90 bp 0x7fff8509ee20 sp + 0x7fff8509ee18 + READ of size 1 at 0x60040005c6ef thread T0 + #0 0x7f8912ca0c8f in expandRow(unsigned char*, unsigned char*, + int, int, int) /home/tsdgeos/devel/poppler/splash/Splash.cc:4855 + #1 0x7f8912ca1097 in Splash::scaleImageYuXuBilinear(bool + (*)(void*, unsigned char*, unsigned char*), void*, + SplashColorMode, int, bool, int, int, int, int, SplashBitmap*) + /home/tsdgeos/devel/poppler/splash/Splash.cc:4897 + #2 0x7f8912c9d2b7 in Splash::scaleImage(bool + (*)(void*, unsigned char*, unsigned char*), void*, + SplashColorMode, int, bool, int, int, int, int, bool, bool) + /home/tsdgeos/devel/poppler/splash/Splash.cc:4127 + #3 0x7f8912c98101 in Splash::drawImage(bool + (*)(void*, unsigned char*, unsigned char*), void*, + SplashColorMode, bool, int, int, double*, bool, bool) + /home/tsdgeos/devel/poppler/splash/Splash.cc:3726 + #4 0x7f8912c7056a in + SplashOutputDev::drawSoftMaskedImage(GfxState*, + Object*, Stream*, int, int, GfxImageColorMap*, + bool, Stream*, int, int, GfxImageColorMap*, bool) + /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:3630 + #5 0x7f8912ac7aa7 in Gfx::doImage(Object*, Stream*, bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4646 + #6 0x7f8912ac4de0 in Gfx::opXObject(Object*, int) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4179 + #7 0x7f8912a9f33a in Gfx::execOp(Object*, Object*, int) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:903 + #8 0x7f8912a9e50f in Gfx::go(bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:762 + #9 0x7f8912a9e163 in Gfx::display(Object*, bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:728 + #10 0x7f8912b80e13 in Page::displaySlice(OutputDev*, double, + double, int, bool, bool, int, int, int, int, bool, bool + (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/Page.cc:585 + #11 0x7f8912b8833f in PDFDoc::displayPageSlice(OutputDev*, + int, double, double, int, bool, bool, bool, int, int, int, int, + bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 + #12 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, + int, int, int, int, int, double, double, char*) + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 + #13 0x404416 in main + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 + #14 0x7f89121a8ec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) + #15 0x401d58 in _start + (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) + + splash/Splash.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 38ec8cbeeaf69d96b9d7bcd662187c8916cf7903 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Mar 28 11:18:02 2014 +0100 + + Fix error reported by ASAN in 5782.asan.0.7113.pdf + + ==32161== ERROR: AddressSanitizer: heap-buffer-overflow on + address 0x6008000e3bcf at pc 0x7f66bae0e117 bp 0x7fffcb54ea70 sp + 0x7fffcb54ea68 + READ of size 1 at 0x6008000e3bcf thread T0 + #0 0x7f66bae0e116 in GooString::getChar(int) + /home/tsdgeos/devel/poppler/goo/GooString.h:119 + #1 0x7f66bafb5dca in LinkURI::LinkURI(Object*, GooString*) + /home/tsdgeos/devel/poppler/poppler/Link.cc:562 + #2 0x7f66bafb2a05 in LinkAction::parseAction(Object*, GooString*) + /home/tsdgeos/devel/poppler/poppler/Link.cc:98 + #3 0x7f66bae69c0e in AnnotLink::initialize(PDFDoc*, Dict*) + /home/tsdgeos/devel/poppler/poppler/Annot.cc:2621 + #4 0x7f66bae698d9 in AnnotLink::AnnotLink(PDFDoc*, Dict*, Object*) + /home/tsdgeos/devel/poppler/poppler/Annot.cc:2596 + #5 0x7f66bae8d998 in Annots::createAnnot(Dict*, Object*) + /home/tsdgeos/devel/poppler/poppler/Annot.cc:6737 + #6 0x7f66bae8d269 in Annots::Annots(PDFDoc*, int, Object*) + /home/tsdgeos/devel/poppler/poppler/Annot.cc:6683 + #7 0x7f66bafc750d in Page::getAnnots(XRef*) + /home/tsdgeos/devel/poppler/poppler/Page.cc:402 + #8 0x7f66bafc8e66 in Page::displaySlice(OutputDev*, double, + double, int, bool, bool, int, int, int, int, bool, bool + (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/Page.cc:595 + #9 0x7f66bafd02fd in PDFDoc::displayPageSlice(OutputDev*, int, + double, double, int, bool, bool, bool, int, int, int, int, + bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 + #10 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, + int, int, int, int, int, double, double, char*) + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 + #11 0x404416 in main + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 + #12 0x7f66ba5f0ec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) + #13 0x401d58 in _start + (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) + + poppler/Link.cc | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +commit 49b4eb68ee646aefe49b70f9e2831ebf93576053 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Mar 28 11:08:18 2014 +0100 + + Fix error reported by ASAN in 590.asan.0.7288.pdf + + ==31898== ERROR: AddressSanitizer: heap-use-after-free on + address 0x60ae0007432c at pc 0x7f03483026aa bp 0x7fff6ec0c820 sp + 0x7fff6ec0c818 + READ of size 4 at 0x60ae0007432c thread T0 + #0 0x7f03483026a9 in SplashFTFont::getGlyphPath(int) + /home/tsdgeos/devel/poppler/splash/SplashFTFont.cc:414 + #1 0x7f034829f681 in SplashOutputDev::drawChar(GfxState*, + double, double, double, double, double, + double, unsigned int, int, unsigned int*, int) + /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:2239 + #2 0x7f0348100599 in Gfx::doShowText(GooString*) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4054 + #3 0x7f03480fddb0 in Gfx::opShowSpaceText(Object*, int) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:3886 + #4 0x7f03480dc33a in Gfx::execOp(Object*, Object*, int) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:903 + #5 0x7f03480db50f in Gfx::go(bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:762 + #6 0x7f03480db163 in Gfx::display(Object*, bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:728 + #7 0x7f03481bddd1 in Page::displaySlice(OutputDev*, double, + double, int, bool, bool, int, int, int, int, bool, bool + (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/Page.cc:585 + #8 0x7f03481c52fd in PDFDoc::displayPageSlice(OutputDev*, int, + double, double, int, bool, bool, bool, int, int, int, int, + bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 + #9 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, + int, int, int, int, int, double, double, char*) + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 + #10 0x404416 in main + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 + #11 0x7f03477e5ec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) + #12 0x401d58 in _start + (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) + + splash/SplashFTFont.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 89a64b508e5f8445798c95fcec6c87180f6c9b73 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Mar 28 00:35:17 2014 +0100 + + Fix error reported by ASAN in 2279.asan.0.1904.pdf + + ==20507== ERROR: AddressSanitizer: heap-buffer-overflow on + address 0x60420000ff04 at pc 0x7fa1492e8012 bp 0x7fff8406d900 sp + 0x7fff8406d8f8 + READ of size 4 at 0x60420000ff04 thread T0 + #0 0x7fa1492e8011 in SplashFTFont::makeGlyph(int, int, int, + SplashGlyphBitmap*, int, int, SplashClip*, SplashClipResult*) + /home/tsdgeos/devel/poppler/splash/SplashFTFont.cc:284 + #1 0x7fa1492eda32 in SplashFont::getGlyph(int, int, int, + SplashGlyphBitmap*, int, int, SplashClip*, SplashClipResult*) + /home/tsdgeos/devel/poppler/splash/SplashFont.cc:168 + #2 0x7fa1492e7c69 in SplashFTFont::getGlyph(int, int, int, + SplashGlyphBitmap*, int, int, SplashClip*, SplashClipResult*) + /home/tsdgeos/devel/poppler/splash/SplashFTFont.cc:233 + #3 0x7fa1492b3368 in Splash::fillChar(double, double, int, + SplashFont*) /home/tsdgeos/devel/poppler/splash/Splash.cc:2714 + #4 0x7fa149286a20 in SplashOutputDev::drawChar(GfxState*, + double, double, double, double, double, + double, unsigned int, int, unsigned int*, int) + /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:2270 + #5 0x7fa1490e7599 in Gfx::doShowText(GooString*) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4054 + #6 0x7fa1490e4db0 in Gfx::opShowSpaceText(Object*, int) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:3886 + #7 0x7fa1490c333a in Gfx::execOp(Object*, Object*, int) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:903 + #8 0x7fa1490c250f in Gfx::go(bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:762 + #9 0x7fa1490c2163 in Gfx::display(Object*, bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:728 + #10 0x7fa1491a4dd1 in Page::displaySlice(OutputDev*, double, + double, int, bool, bool, int, int, int, int, bool, bool + (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/Page.cc:585 + #11 0x7fa1491ac2fd in PDFDoc::displayPageSlice(OutputDev*, + int, double, double, int, bool, bool, bool, int, int, int, int, + bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 + #12 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, + int, int, int, int, int, double, double, char*) + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 + #13 0x404416 in main + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 + #14 0x7fa1487ccec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) + #15 0x401d58 in _start + (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) + + splash/SplashFTFont.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 5055479634dc8d0cd5afb3373de600fb121357fe +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 27 23:54:20 2014 +0100 + + Fix error reported by ASAN in 2010.asan.0.1506.pdf + + ==18859== ERROR: AddressSanitizer: unknown-crash on address + 0x7f1e4a6beb50 at pc 0x7f1e5557444d bp 0x7fff6af3c340 sp + 0x7fff6af3bb00 + WRITE of size 442216446 at 0x7f1e4a6beb50 thread T0 + #0 0x7f1e5557444c (/usr/lib/x86_64-linux-gnu/libasan.so.0+0xe44c) + #1 0x7f1e550e04ff in SplashFont::getGlyph(int, int, int, + SplashGlyphBitmap*, int, int, SplashClip*, SplashClipResult*) + /home/tsdgeos/devel/poppler/splash/SplashFont.cc:206 + #2 0x7f1e550d9c69 in SplashFTFont::getGlyph(int, int, int, + SplashGlyphBitmap*, int, int, SplashClip*, SplashClipResult*) + /home/tsdgeos/devel/poppler/splash/SplashFTFont.cc:233 + #3 0x7f1e550a5368 in Splash::fillChar(double, double, int, + SplashFont*) /home/tsdgeos/devel/poppler/splash/Splash.cc:2714 + #4 0x7f1e55078a20 in SplashOutputDev::drawChar(GfxState*, + double, double, double, double, double, + double, unsigned int, int, unsigned int*, int) + /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:2270 + #5 0x7f1e54ed9599 in Gfx::doShowText(GooString*) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4054 + #6 0x7f1e54ed6db0 in Gfx::opShowSpaceText(Object*, int) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:3886 + #7 0x7f1e54eb533a in Gfx::execOp(Object*, Object*, int) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:903 + #8 0x7f1e54eb450f in Gfx::go(bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:762 + #9 0x7f1e54eb4163 in Gfx::display(Object*, bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:728 + #10 0x7f1e54f96dd1 in Page::displaySlice(OutputDev*, double, + double, int, bool, bool, int, int, int, int, bool, bool + (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/Page.cc:585 + #11 0x7f1e54f9e2fd in PDFDoc::displayPageSlice(OutputDev*, + int, double, double, int, bool, bool, bool, int, int, int, int, + bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 + #12 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, + int, int, int, int, int, double, double, char*) + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 + #13 0x404416 in main + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 + #14 0x7f1e545beec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) + #15 0x401d58 in _start + (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) + + splash/SplashFont.cc | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +commit 3e7779935ec2610410bc4a42e9b0174e41ca9672 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 27 16:49:57 2014 +0100 + + Fix error reported by ASAN in 139.asan.0.581.pdf + + ==15244== ERROR: AddressSanitizer: SEGV on unknown address + 0x605df000f3ee (pc 0x7f1087b3a22e sp 0x7fffec30ff20 bp 0x7fffec30ff80 + T0) + AddressSanitizer can not provide additional info. + #0 0x7f1087b3a22d + (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x48f22d) + #1 0x7f1087b19d92 + (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x46ed92) + #2 0x7f1087ae570b + (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x43a70b) + #3 0x7f1087ae4061 + (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x439061) + #4 0x7f1087ab9b38 + (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x40eb38) + #5 0x7f1087900989 + (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x255989) + #6 0x7f10878f733a + (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x24c33a) + #7 0x7f10878f650f + (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x24b50f) + #8 0x7f10878f6163 + (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x24b163) + #9 0x7f10879d8dd1 + (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x32ddd1) + #10 0x7f10879e02fd + (/home/tsdgeos/devel/poppler/build-debug/libpoppler.so.46.0.0+0x3352fd) + #11 0x40311e + (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x40311e) + #12 0x404416 + (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x404416) + #13 0x7f1087000ec4 (/lib/x86_64-linux-gnu/libc-2.19.so+0x21ec4) + #14 0x401d58 + (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) + + splash/SplashXPathScanner.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 23ad7fa5253a4fec6543d1435827aa1b59b62ced +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 27 01:14:05 2014 +0100 + + 0.25.2 + + CMakeLists.txt | 4 ++-- + NEWS | 48 + +++++++++++++++++++++++++++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + gtk-doc.make | 33 +++++++++++++++++++--------- + m4/gtk-doc.m4 | 47 + +++++++++++++++++++++++++++------------- + poppler/CairoOutputDev.h | 2 +- + poppler/Hints.cc | 2 +- + poppler/Makefile.am | 2 +- + poppler/PSOutputDev.cc | 3 ++- + poppler/PSOutputDev.h | 2 +- + poppler/StructElement.cc | 2 +- + poppler/StructElement.h | 2 +- + poppler/StructTreeRoot.cc | 2 +- + poppler/StructTreeRoot.h | 2 +- + qt4/src/CMakeLists.txt | 2 +- + qt4/src/Doxyfile | 2 +- + qt4/src/Makefile.am | 2 +- + qt4/src/poppler-ps-converter.cc | 1 + + qt5/src/CMakeLists.txt | 2 +- + qt5/src/Doxyfile | 2 +- + qt5/src/Makefile.am | 2 +- + qt5/src/poppler-ps-converter.cc | 1 + + utils/pdftocairo.cc | 2 +- + utils/pdftops.cc | 1 + + 25 files changed, 127 insertions(+), 45 deletions(-) + +commit ec2f8bca9f48935d3180dab65ef2ca455a893afd +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 26 18:38:13 2014 +0100 + + Fix overflow malloc + + poppler/Stream.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 322e416451b7b33cba8fb3d4702207693c3c7921 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 26 17:58:48 2014 +0100 + + Fix error reported by ASAN in 1195.asan.0.293.pdf + + ==31060== ERROR: AddressSanitizer: heap-buffer-overflow on + address 0x60040002a215 at pc 0x7f5614cd96c4 bp 0x7fff54a44050 sp + 0x7fff54a44048 + READ of size 1 at 0x60040002a215 thread T0 + #0 0x7f5614cd96c3 in JBIG2Stream::readGenericBitmap(bool, + int, int, int, bool, bool, JBIG2Bitmap*, int*, int*, int) + /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:3389 + #1 0x7f5614cce0e7 in JBIG2Stream::readSymbolDictSeg(unsigned + int, unsigned int, unsigned int*, unsigned int) + /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:1867 + #2 0x7f5614ccb8fe in JBIG2Stream::readSegments() + /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:1408 + #3 0x7f5614cca72e in JBIG2Stream::reset() + /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:1248 + #4 0x7f5614d1648b in ImageStream::reset() + /home/tsdgeos/devel/poppler/poppler/Stream.cc:484 + #5 0x7f5614de6578 in SplashOutputDev::drawImage(GfxState*, + Object*, Stream*, int, int, GfxImageColorMap*, bool, int*, bool) + /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:3158 + #6 0x7f5614c41d64 in Gfx::doImage(Object*, Stream*, bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4653 + #7 0x7f5614c3ede0 in Gfx::opXObject(Object*, int) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4179 + #8 0x7f5614c1933a in Gfx::execOp(Object*, Object*, int) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:903 + #9 0x7f5614c1850f in Gfx::go(bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:762 + #10 0x7f5614c18163 in Gfx::display(Object*, bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:728 + #11 0x7f5614cfae27 in Page::displaySlice(OutputDev*, double, + double, int, bool, bool, int, int, int, int, bool, bool + (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/Page.cc:585 + #12 0x7f5614d02353 in PDFDoc::displayPageSlice(OutputDev*, + int, double, double, int, bool, bool, bool, int, int, int, int, + bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 + #13 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, + int, int, int, int, int, double, double, char*) + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 + #14 0x404416 in main + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 + #15 0x7f5614322ec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) + #16 0x401d58 in _start + (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) + + poppler/JBIG2Stream.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 225232f6f070d17d8570108ffe39ffd4350fc6e8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 26 15:00:09 2014 +0100 + + Fix error reported by ASAN in 6609.asan.0.8343.pdf + + ==8470== ERROR: AddressSanitizer: heap-buffer-overflow on + address 0x7f3b12f7b5e1 at pc 0x7f3b0f915f5e bp 0x7fff47842de0 sp + 0x7fff47842dd8 + READ of size 1 at 0x7f3b12f7b5e1 thread T0 + #0 0x7f3b0f915f5d in JBIG2Stream::readGenericBitmap(bool, + int, int, int, bool, bool, JBIG2Bitmap*, int*, int*, int) + /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:3628 + #1 0x7f3b0f910558 in JBIG2Stream::readGenericRegionSeg(unsigned + int, bool, bool, unsigned int) + /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:2849 + #2 0x7f3b0f906b33 in JBIG2Stream::readSegments() + /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:1443 + #3 0x7f3b0f90572e in JBIG2Stream::reset() + /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:1248 + #4 0x7f3b0f951459 in ImageStream::reset() + /home/tsdgeos/devel/poppler/poppler/Stream.cc:484 + #5 0x7f3b0fa21546 in SplashOutputDev::drawImage(GfxState*, + Object*, Stream*, int, int, GfxImageColorMap*, bool, int*, bool) + /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:3158 + #6 0x7f3b0f87cd64 in Gfx::doImage(Object*, Stream*, bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4653 + #7 0x7f3b0f879de0 in Gfx::opXObject(Object*, int) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4179 + #8 0x7f3b0f85433a in Gfx::execOp(Object*, Object*, int) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:903 + #9 0x7f3b0f85350f in Gfx::go(bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:762 + #10 0x7f3b0f853163 in Gfx::display(Object*, bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:728 + #11 0x7f3b0f935df5 in Page::displaySlice(OutputDev*, double, + double, int, bool, bool, int, int, int, int, bool, bool + (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/Page.cc:585 + #12 0x7f3b0f93d321 in PDFDoc::displayPageSlice(OutputDev*, + int, double, double, int, bool, bool, bool, int, int, int, int, + bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 + #13 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, + int, int, int, int, int, double, double, char*) + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 + #14 0x404416 in main + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 + #15 0x7f3b0ef5dec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) + #16 0x401d58 in _start + (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) + + poppler/JBIG2Stream.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 216890f1f147b25643e0d6e18e361d4d34b6c332 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 26 12:19:42 2014 +0100 + + Fix error reported by ASAN in 6760.asan.0.8568.pdf + + ==26566== ERROR: AddressSanitizer: SEGV on unknown address + 0x7fffbc3e5ea8 (pc 0x7fe1fa858db1 sp 0x7fffc788eb30 bp 0x7fffc788eb40 + T0) + AddressSanitizer can not provide additional info. + #0 0x7fe1fa858db0 in PSStack::index(int) + /home/tsdgeos/devel/poppler/poppler/Function.cc:1067 + #1 0x7fe1fa856fd6 in PostScriptFunction::exec(PSStack*, int) + /home/tsdgeos/devel/poppler/poppler/Function.cc:1621 + #2 0x7fe1fa854c10 in PostScriptFunction::transform(double*, + double*) /home/tsdgeos/devel/poppler/poppler/Function.cc:1266 + #3 0x7fe1fa854097 in + PostScriptFunction::PostScriptFunction(Object*, Dict*) + /home/tsdgeos/devel/poppler/poppler/Function.cc:1216 + #4 0x7fe1fa84a0c2 in Function::parse(Object*, + std::set<int, std::less<int>, std::allocator<int> >*) + /home/tsdgeos/devel/poppler/poppler/Function.cc:98 + #5 0x7fe1fa849e3c in Function::parse(Object*) + /home/tsdgeos/devel/poppler/poppler/Function.cc:63 + #6 0x7fe1fa8c1d8c in GfxDeviceNColorSpace::parse(Array*, + OutputDev*, GfxState*, int) + /home/tsdgeos/devel/poppler/poppler/GfxState.cc:2978 + #7 0x7fe1fa8a6fb7 in GfxColorSpace::parse(Object*, + OutputDev*, GfxState*, int) + /home/tsdgeos/devel/poppler/poppler/GfxState.cc:328 + #8 0x7fe1fa88440f in Gfx::doImage(Object*, Stream*, bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4403 + #9 0x7fe1fa882d6c in Gfx::opXObject(Object*, int) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4179 + #10 0x7fe1fa85d2c6 in Gfx::execOp(Object*, Object*, int) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:903 + #11 0x7fe1fa85c49b in Gfx::go(bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:762 + #12 0x7fe1fa85c0ef in Gfx::display(Object*, bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:728 + #13 0x7fe1fa93ed81 in Page::displaySlice(OutputDev*, double, + double, int, bool, bool, int, int, int, int, bool, bool + (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/Page.cc:585 + #14 0x7fe1fa9462ad in PDFDoc::displayPageSlice(OutputDev*, + int, double, double, int, bool, bool, bool, int, int, int, int, + bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 + #15 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, + int, int, int, int, int, double, double, char*) + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 + #16 0x404416 in main + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 + #17 0x7fe1f9f66ec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) + #18 0x401d58 in _start + (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) + + poppler/Function.cc | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +commit fb7d91435c71603697b652c70cfa76dd595ee200 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 26 12:08:52 2014 +0100 + + Fix ASAN in 750.asan.0.9621.pdf + + ==25876== ERROR: AddressSanitizer: heap-buffer-overflow on + address 0x60040002a10f at pc 0x7fc396c3c23e bp 0x7ffff1123d20 sp + 0x7ffff1123d18 + READ of size 1 at 0x60040002a10f thread T0 + #0 0x7fc396c3c23d in JBIG2Stream::readGenericBitmap(bool, + int, int, int, bool, bool, JBIG2Bitmap*, int*, int*, int) + /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:3504 + #1 0x7fc396c30073 in JBIG2Stream::readSymbolDictSeg(unsigned + int, unsigned int, unsigned int*, unsigned int) + /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:1867 + #2 0x7fc396c2d88a in JBIG2Stream::readSegments() + /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:1408 + #3 0x7fc396c2c6ba in JBIG2Stream::reset() + /home/tsdgeos/devel/poppler/poppler/JBIG2Stream.cc:1248 + #4 0x7fc396c783f7 in ImageStream::reset() + /home/tsdgeos/devel/poppler/poppler/Stream.cc:484 + #5 0x7fc396d484e4 in SplashOutputDev::drawImage(GfxState*, + Object*, Stream*, int, int, GfxImageColorMap*, bool, int*, bool) + /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:3158 + #6 0x7fc396ba3cf0 in Gfx::doImage(Object*, Stream*, bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4653 + #7 0x7fc396ba0d6c in Gfx::opXObject(Object*, int) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:4179 + #8 0x7fc396b7b2c6 in Gfx::execOp(Object*, Object*, int) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:903 + #9 0x7fc396b7a49b in Gfx::go(bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:762 + #10 0x7fc396b7a0ef in Gfx::display(Object*, bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:728 + #11 0x7fc396c5cd93 in Page::displaySlice(OutputDev*, double, + double, int, bool, bool, int, int, int, int, bool, bool + (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/Page.cc:585 + #12 0x7fc396c642bf in PDFDoc::displayPageSlice(OutputDev*, + int, double, double, int, bool, bool, bool, int, int, int, int, + bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 + #13 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, + int, int, int, int, int, double, double, char*) + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 + #14 0x404416 in main + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 + #15 0x7fc396284ec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) + #16 0x401d58 in _start + (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) + + poppler/JBIG2Stream.cc | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +commit 9002b3b7cbbbc5802abfa8383ded2093a29d1746 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 26 00:48:15 2014 +0100 + + Fix ASAN in 784.asan.0.9671.pdf + + ================================================================= + ==24856== ERROR: AddressSanitizer: SEGV on unknown address + 0x603bfffe5804 (pc 0x7f7aa3310c6b sp 0x7fff0e656bd0 bp 0x7fff0e656e90 + T0) + AddressSanitizer can not provide additional info. + #0 0x7f7aa3310c6a in + GfxIndexedColorSpace::mapColorToBase(GfxColor*, GfxColor*) + /home/tsdgeos/devel/poppler/poppler/GfxState.cc:2509 + #1 0x7f7aa33110d2 in GfxIndexedColorSpace::getRGB(GfxColor*, + GfxRGB*) /home/tsdgeos/devel/poppler/poppler/GfxState.cc:2529 + #2 0x7f7aa3466712 in convertGfxColor(unsigned + char*, SplashColorMode, GfxColorSpace*, GfxColor*) + /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:117 + #3 0x7f7aa34675a9 in SplashUnivariatePattern::getColor(int, + int, unsigned char*) + /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:215 + #4 0x7f7aa348d2a2 in Splash::pipeRun(SplashPipe*) + /home/tsdgeos/devel/poppler/splash/Splash.cc:363 + #5 0x7f7aa34c9c29 in Splash::drawAALine(SplashPipe*, + int, int, int, bool, unsigned char) + /home/tsdgeos/devel/poppler/splash/Splash.cc:1537 + #6 0x7f7aa34c4787 in Splash::shadedFill(SplashPath*, bool, + SplashPattern*) /home/tsdgeos/devel/poppler/splash/Splash.cc:6388 + #7 0x7f7aa348b65c in + SplashOutputDev::univariateShadedFill(GfxState*, + SplashUnivariatePattern*, double, double) + /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:4408 + #8 0x7f7aa348b93d in SplashOutputDev::radialShadedFill(GfxState*, + GfxRadialShading*, double, double) + /home/tsdgeos/devel/poppler/poppler/SplashOutputDev.cc:4427 + #9 0x7f7aa32c7574 in Gfx::doRadialShFill(GfxRadialShading*) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:3058 + #10 0x7f7aa32c188f in Gfx::opShFill(Object*, int) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:2476 + #11 0x7f7aa32b12c6 in Gfx::execOp(Object*, Object*, int) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:903 + #12 0x7f7aa32b049b in Gfx::go(bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:762 + #13 0x7f7aa32b00ef in Gfx::display(Object*, bool) + /home/tsdgeos/devel/poppler/poppler/Gfx.cc:728 + #14 0x7f7aa3392dc9 in Page::displaySlice(OutputDev*, double, + double, int, bool, bool, int, int, int, int, bool, bool + (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/Page.cc:585 + #15 0x7f7aa339a2f5 in PDFDoc::displayPageSlice(OutputDev*, + int, double, double, int, bool, bool, bool, int, int, int, int, + bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) + /home/tsdgeos/devel/poppler/poppler/PDFDoc.cc:503 + #16 0x40311e in savePageSlice(PDFDoc*, SplashOutputDev*, + int, int, int, int, int, double, double, char*) + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:222 + #17 0x404416 in main + /home/tsdgeos/devel/poppler/utils/pdftoppm.cc:521 + #18 0x7f7aa29baec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) + #19 0x401d58 in _start + (/home/tsdgeos/devel/poppler/build-debug/utils/pdftoppm+0x401d58) + SUMMARY: AddressSanitizer: SEGV + /home/tsdgeos/devel/poppler/poppler/GfxState.cc:2509 + GfxIndexedColorSpace::mapColorToBase(GfxColor*, GfxColor*) + + poppler/GfxState.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 8947c6bc1dcb768b9d9c03a7a5db1573abdc2e87 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 26 00:47:59 2014 +0100 + + Forgot my (C) in the last commit + + poppler/TextOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1d7095ab7bdf0f14c3bfe99d6d5985bce98abe16 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 25 22:29:07 2014 +0100 + + Fix Heap-buffer-overflow in TextPage::updateFont + + Bug #76442 + + poppler/TextOutputDev.cc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit 37ad83d69bd1d10da6ea1eb559c4bd320917ae25 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 22 17:33:55 2014 +0100 + + Reorder the if check condition + + I think the previous condition was correct anyway because of the + extra -1 in the i check + but it really makes more sense to have the i check first + + Bug #76478 + + goo/gfile.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 3535d658095ffa49ef8615d69843afa9c5ada061 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 22 17:29:46 2014 +0100 + + Make the test rect go to xMax, yMax not xMax-1,yMax-1 + + I don't understand why the -1 is there and removing + it actually fixes bug #76387 + + splash/Splash.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 1e93c3f2d1c86edd40ca283ed422089f64886d04 +Author: William Bader <williambader@hotmail.com> +Date: Sat Mar 15 17:14:21 2014 +0100 + + Fix regression when creating level1 PS + + Bug #75241 + + poppler/PreScanOutputDev.cc | 16 ++++++++++++++-- + poppler/PreScanOutputDev.h | 3 ++- + 2 files changed, 16 insertions(+), 3 deletions(-) + +commit 1ea2eb412d12d97eaf49d1e51d7fda7abd8fbf9d +Author: Jason Crain <jason@aquaticape.us> +Date: Wed Mar 12 00:34:13 2014 +0100 + + Limit numeric parsing of character names + + Bug #38456 + + poppler/GfxFont.cc | 139 + ++++++++++++++++++++++++++++++++++-------------- + poppler/GlobalParams.cc | 4 +- + 2 files changed, 102 insertions(+), 41 deletions(-) + +commit e24cbeae22d6c8630e292897bd982a87e6290ca6 +Author: Steven Lee <roc.sky@gmail.com> +Date: Tue Mar 11 21:24:59 2014 +0100 + + Fix TIFF writting in Windows + + Bug #75969 + + goo/TiffWriter.cc | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +commit b984a3b5946ebcd736e0583a10eb614cede3388a +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Wed Mar 5 11:19:48 2014 +0200 + + glib: Use flags argument in poppler_structure_element_get_text() + + Instead of accepting a boolean argument to enable recursive text + extraction, + use a flags value. Text extraction may add features in the future (for + example, allowing using alternate text as replacement for inline + figures), + and this will allow to extend the method without introducing ABI + or API + breakage. + + https://bugs.freedesktop.org/show_bug.cgi?id=75796 + + glib/poppler-structure-element.cc | 12 +++++++----- + glib/poppler-structure-element.h | 14 +++++++++++++- + glib/reference/poppler-sections.txt | 3 +++ + 3 files changed, 23 insertions(+), 6 deletions(-) + +commit 94df09de1e07d442895ec1fb5cc23cacd9826552 +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Thu Mar 6 10:44:51 2014 +0200 + + glib: Add missing underscore in method name + + The correct name is poppler_structure_element_get_form_state(). + + https://bugs.freedesktop.org/show_bug.cgi?id=75827 + + glib/poppler-structure-element.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 7ddd03f9a00dcf505921821c55bebe6817aa3605 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Mar 5 17:48:39 2014 +0100 + + Rename getNumElements, getElement and appendElement as getNumChildren, + getChild and appendChild + + It's more consistent with other internal API and less confusing. + + glib/poppler-structure-element.cc | 16 ++++++++-------- + poppler/StructElement.cc | 6 +++--- + poppler/StructElement.h | 8 ++++---- + poppler/StructTreeRoot.cc | 4 ++-- + poppler/StructTreeRoot.h | 8 ++++---- + 5 files changed, 21 insertions(+), 21 deletions(-) + +commit 7d6a5b65f8497537248d405177ae141f3765a419 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Mar 5 17:40:14 2014 +0100 + + glib: Update the documentation symbols after the PopplerStructureScope + rename + + glib/reference/poppler-sections.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 9282b5a26e9ce81d81d42c0cbe449543c8366b7c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Mar 5 17:37:38 2014 +0100 + + glib: Rename PopplerStructureScope as PopplerStructureTableScope + + It's a table specific attribute + + glib/poppler-structure-element.cc | 14 +++++++------- + glib/poppler-structure-element.h | 12 ++++++------ + 2 files changed, 13 insertions(+), 13 deletions(-) + +commit 9888eb65c6fad0eabcf525a7e88941dec2a27e92 +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Thu Sep 26 19:36:12 2013 +0300 + + glib: Implement accessors for element attributes + + Implement inspecting the standard attributes of + PopplerStructureElement + objects. + + https://bugs.freedesktop.org/show_bug.cgi?id=64821 + + glib/poppler-structure-element.cc | 1279 + ++++++++++++++++++++++++++++++++++- + glib/poppler-structure-element.h | 252 ++++++- + glib/reference/poppler-sections.txt | 84 +++ + 3 files changed, 1597 insertions(+), 18 deletions(-) + +commit b346df59ef0775f5bd74a9f7379b5f430ccd7b79 +Author: Adam Reichold <adamreichold@myopera.com> +Date: Tue Mar 4 23:40:59 2014 +0100 + + Qt: Expose document-supplied text direction + + qt4/src/poppler-document.cc | 17 +++++++++++++++++ + qt4/src/poppler-qt4.h | 10 +++++++++- + qt5/src/poppler-document.cc | 17 +++++++++++++++++ + qt5/src/poppler-qt5.h | 10 +++++++++- + 4 files changed, 52 insertions(+), 2 deletions(-) + +commit 2fc38c1866243598e22be07f0177e7d9385542d5 +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Fri Feb 28 19:14:36 2014 +0200 + + glib: Fixes in the API reference documentation + + - Remove the references to non-existent methods for + PopplerStructureElement, + and point to PopplerStructureElementIter instead to point out how to + obtain the structure tree. + - Remove a non-existent include in poppler-docs.sgml + - Add POPPLER_TYPE_TEXT_SPAN to the list of private symbols. + + https://bugs.freedesktop.org/show_bug.cgi?id=75615 + + glib/poppler-structure-element.cc | 6 +++--- + glib/reference/poppler-docs.sgml | 1 - + glib/reference/poppler-sections.txt | 1 + + 3 files changed, 4 insertions(+), 4 deletions(-) + +commit cfe47a655ec5e280168e000da85bbf13f5f5f8b8 +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Fri Feb 28 19:17:45 2014 +0200 + + glib: Remove poppler_text_span_is_link() in header + + The method poppler_text_span_is_link() does not exist, and must + be removed from the API header. + + https://bugs.freedesktop.org/show_bug.cgi?id=75613 + + glib/poppler-structure-element.h | 1 - + 1 file changed, 1 deletion(-) + +commit 7a2db63b5f7cae4bc215baa0859c4d4f8a660951 +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Wed Feb 26 20:16:29 2014 +0200 + + glib: Remove unneeded POPPLER_STRUCTURE_ELEMENT_UNKNOWN + + The enum value POPPLER_STRUCTURE_ELEMENT_UNKNOWN because Poppler does + not add invalid StructElements ("invalid" being nodes of type + StructElement::Unknown) to the Tagged-PDF structure tree. That means + that poppler-glib does not need to expose it in the API. An assertion + is left to aid in finding issues when using debug builds. + + https://bugs.freedesktop.org/show_bug.cgi?id=75541 + + glib/poppler-structure-element.cc | 12 +++++++----- + glib/poppler-structure-element.h | 1 - + 2 files changed, 7 insertions(+), 6 deletions(-) + +commit db909c2a14f962234a813ba9853535b9692cfd5a +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 26 22:09:44 2014 +0100 + + Try harder to open broken files + + Bug #75232 + + poppler/PDFDoc.cc | 33 ++++++++++++++++++++++----------- + poppler/PDFDoc.h | 8 ++++---- + 2 files changed, 26 insertions(+), 15 deletions(-) + +commit b2394eee5384edf4128d598030989e66d64714ef +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Mon Feb 10 20:29:35 2014 +0200 + + Tagged-PDF: Fix parsing of attached element attributes + + The wrong object was used as attribute dictionary, which caused + a segmentation fault when parsing PDF files in which the structure + elements included attributes attached to them. This patch fixes the + issue. + + Thanks to Joanmarie Diggs <jdiggs@igalia.com> for helping in + debugging the problem. + + https://bugs.freedesktop.org/show_bug.cgi?id=74805 + + poppler/StructElement.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit c549b5e9ce2dcc8beb2511ee315bfff2fdfdf6e8 +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Sun Feb 9 18:31:22 2014 +0200 + + glib: Add poppler_structure_element_is_grouping() + + Implement a method to check whether a structure element is a grouping + element, wrapping the StructElement::isGrouping() method. + + https://bugs.freedesktop.org/show_bug.cgi?id=74753 + + glib/poppler-structure-element.cc | 20 ++++++++++++++++++++ + glib/poppler-structure-element.h | 1 + + glib/reference/poppler-sections.txt | 1 + + 3 files changed, 22 insertions(+) + +commit 6fbd6cb85bdd32dc5a3d4c3c719556269a4488ac +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Fri Feb 21 15:02:44 2014 +0200 + + glib: Handle missing structure element types + + Element Art (article); RB, RP, RB (Ruby text inner elements); and + WT, WP (Warichu inner elements) were not being handled. This adds + the corresponding handling in poppler-glib. Also, the "default" case + in the switch in poppler_structure_element_get_type() is removed, so + the compiler can emit warnings when enum values are not handled. + + https://bugs.freedesktop.org/show_bug.cgi?id=75323 + + glib/poppler-structure-element.cc | 25 +++++++++++++++++++------ + glib/poppler-structure-element.h | 9 +++++++-- + 2 files changed, 26 insertions(+), 8 deletions(-) + +commit 63e9c0b67fa2e64ca20258d873a849386c7eb295 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Mon Feb 17 23:58:09 2014 +0100 + + Some error() usage fixes + + poppler/Hints.cc | 3 ++- + poppler/JBIG2Stream.cc | 4 ++-- + poppler/PSOutputDev.cc | 4 ++-- + poppler/SecurityHandler.cc | 3 ++- + poppler/StructTreeRoot.cc | 3 ++- + qt4/src/poppler-annotation.cc | 6 +++--- + qt5/src/poppler-annotation.cc | 6 +++--- + utils/HtmlOutputDev.cc | 11 ++++++----- + 8 files changed, 22 insertions(+), 18 deletions(-) + +commit 8f2d847f1d0224a297e642944f8da9c1409732b6 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Mon Feb 17 23:56:49 2014 +0100 + + Clang++ plugin that checks for usage errors in GooString::format-style + calls + + goo/GooString.h | 12 +- + poppler/Error.h | 4 +- + test/goostring-format-checker/README | 16 + + .../goostring-format-checker.cc | 369 + +++++++++++++++++++++ + 4 files changed, 397 insertions(+), 4 deletions(-) + +commit d7d61dcda91910f7eb2548b19e8380d7c3232dd3 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Wed Feb 12 21:50:38 2014 +0100 + + blend usage in PDF with spot colors casue random output + + The reason for the random colors is the uninitialized local variable + cBlend. The blend functions only fills offset 0 to 3, so offset 4 + up to 4 + SPOT_NCOMPS are left uninitialized, but all offsets are + stored in the bitmap. + So we need to initialize these offsets with 0! + + Bug #74883 + + splash/Splash.cc | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +commit b2905a0d299cc09fcd219afe49cb370f6db61c5a +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Feb 10 20:19:07 2014 +0100 + + increase gtk3 dependency + + gtk_tree_view_set_activate_on_single_click was introduced in 3.8 + + cmake/modules/FindGTK.cmake | 2 +- + configure.ac | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit 71d4041b061c109a965e72230640cf8ee616dac3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Feb 10 20:16:46 2014 +0100 + + Make sure number of least objects in hints table is valid + + Bug #74741 + + poppler/Hints.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit a865f13def88153fdbe8a0a054d2005e3e2bb737 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 9 23:22:07 2014 +0100 + + Fix cmake build + + glib/CMakeLists.txt | 2 ++ + glib/demo/CMakeLists.txt | 1 + + 2 files changed, 3 insertions(+) + +commit d6fde0fac0120b1622942d8344d5153d9abf3e1e +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Wed May 29 23:44:03 2013 +0300 + + glib-demo: Pane showing the document structure + + Adds a new pane in poppler-glib-demo showing the structure for + Tagged-PDF + documents. It also serves as an example on how to to use the API for + PopplerStructure and PopplerStructureElement. + + glib/demo/Makefile.am | 2 + + glib/demo/main.c | 2 + + glib/demo/taggedstruct.c | 232 + +++++++++++++++++++++++++++++++++++++++++++++++ + glib/demo/taggedstruct.h | 31 +++++++ + 4 files changed, 267 insertions(+) + +commit 0f9fa775c469c03d1613b955ee7b06b823e6e080 +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Thu Sep 26 17:50:51 2013 +0300 + + glib: Expose inline attributes of structure elements + + Allows obtaining inline text attributes from structure elements. The + text + is divived into "spans", which are groups of consecutive glyphs + that share + their attributes. Each one of those is represented by a + PopplerTextSpan, + which gives information about the text font and color, and the + link target + for links. The list of PopplerTextSpans is created lazily when + first used. + + https://bugs.freedesktop.org/show_bug.cgi?id=64821 + + glib/poppler-structure-element.cc | 269 + ++++++++++++++++++++++++++++++++++++ + glib/poppler-structure-element.h | 16 ++- + glib/poppler.h | 1 + + glib/reference/poppler-sections.txt | 12 ++ + 4 files changed, 297 insertions(+), 1 deletion(-) + +commit 8072d4b0e3ea10b4308f8172891f769f30466133 +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Thu May 9 12:01:59 2013 +0300 + + glib: Expose the document structure tree + + Implements a new PopplerStructureElement classe, which builds upon + StructTreeRoot and StructElement to expose the document structure of + tagged PDFs in the GLib binding. + + Navigation of the structure tree is done by an iterator-based + interface, + using PopplerStructureElementIter. + + https://bugs.freedesktop.org/show_bug.cgi?id=64821 + + glib/Makefile.am | 2 + + glib/poppler-private.h | 10 + + glib/poppler-structure-element.cc | 663 + ++++++++++++++++++++++++++++++++++++ + glib/poppler-structure-element.h | 112 ++++++ + glib/poppler.h | 3 + + glib/reference/poppler-docs.sgml | 2 + + glib/reference/poppler-sections.txt | 37 ++ + glib/reference/poppler.types | 2 + + 8 files changed, 831 insertions(+) + +commit 46b7470ae9846d7e6dbb72bbb3ff831acd954168 +Author: Germán Poo-Caamaño <gpoo@gnome.org> +Date: Thu Jan 30 14:42:51 2014 -0800 + + glib-demo: Fix performance in text markup annotations + + Fix https://bugs.freedesktop.org/show_bug.cgi?id=51487#c45 + + glib/demo/annots.c | 19 +++++++++++++------ + 1 file changed, 13 insertions(+), 6 deletions(-) + +commit 8a84b45674aed8c27a1d172b07eb0531c0ec14f1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Feb 8 09:17:02 2014 +0100 + + glib: Fix gobject-introspection warnings + + glib/poppler-page.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 899799df78c00fc2ca6d2d0e612536b87a871817 +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Tue Feb 4 19:26:53 2014 +0200 + + Allow properly identifying grouping elements + + Grouping elements in the Tagged-PDF structure should be identifiable + as + such (see section 14.8.4.2 "Grouping Elements" of the PDF + standard). Those + were previously reported as inline elements, which is quite not + correct. + This patch introduces a new StructElement::isGrouping() method which + correctly reports grouping elements as such. + + https://bugs.freedesktop.org/show_bug.cgi?id=74520 + + poppler/StructElement.cc | 31 +++++++++++++++++++------------ + poppler/StructElement.h | 1 + + 2 files changed, 20 insertions(+), 12 deletions(-) + +commit 27cd9a00bfebf0602e7ed29a8ee8e16ffff67bde +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Tue Feb 4 19:35:58 2014 +0200 + + Report LBody elements in Tagged-PDF structure as block elements + + According to section 14.8.4.3 "Block-Level Structure Elements" + (in particular subsection 14.8.4.3.3 "List Elements"), structure + elements of type LBody must be reported as block elements. This + patch changes the reported type from elementTypeUndefined to + elementTypeBlock accordingly. + + https://bugs.freedesktop.org/show_bug.cgi?id=74522 + + poppler/StructElement.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 4cda839cb489fe5cd4726109cb9ab8b0ba2fa563 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Jan 28 06:06:09 2014 +1030 + + pdftops: ensure there is always a page size in the output + + even if the PDF file as badly broken. + + poppler/PSOutputDev.cc | 7 +++++++ + 1 file changed, 7 insertions(+) + +commit 45a87afdf1372911aa1ba840557e61627cdc7b4f +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Dec 29 15:16:37 2013 +1030 + + cairo: clip to crop box + + when printing the cairo surface may larger than the crop box + + fixes https://bugzilla.gnome.org/show_bug.cgi?id=649886 + + poppler/CairoOutputDev.h | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 6d39a1d7b348329dd057a8e7c77bfd47921fc495 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Dec 30 17:59:09 2013 +1030 + + pdftocairo: ensure page size and crop box works the same as pdftops + + Bug 72312 + + utils/pdftocairo.1 | 26 +++++++++----------------- + utils/pdftocairo.cc | 20 +++++++++++++++----- + 2 files changed, 24 insertions(+), 22 deletions(-) + +commit b1da7e20dcef78ef6036418b37a47ba3f8818453 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu Dec 19 22:18:26 2013 +1030 + + pdftops: Only change paper size when different to previous size + + Previously this check was done in the code (removed in previous + commit). + Moving this check into the pdfSetupPaper macro preserves page + independence. + + Bug 72312 + + poppler/PSOutputDev.cc | 30 +++++++++++++++++++++++++----- + 1 file changed, 25 insertions(+), 5 deletions(-) + +commit 7ac7d3bad4b868950ee96fd9c5ece88632f8827c +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Dec 20 07:19:21 2013 +1030 + + pdftops: Remove origpagesizes mode and make -origpagesizes an alias + for -paper match + + Bug 72312 + + poppler/PSOutputDev.cc | 9 ++------- + poppler/PSOutputDev.h | 4 ++-- + utils/pdftops.1 | 30 ++++++++++-------------------- + utils/pdftops.cc | 23 ++++++++++++++--------- + 4 files changed, 28 insertions(+), 38 deletions(-) + +commit 31fc5181bc491ff2e4aee0ae05c0f611a36e585c +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Dec 20 07:16:37 2013 +1030 + + pdftops: Use crop box as page size + + unless -nocrop is used. The fontends use the crop box as the page + size and + acroread uses the cropbox as the page size for display and printing. + + Bug 72312 + + poppler/PSOutputDev.cc | 28 +++++++--------------------- + 1 file changed, 7 insertions(+), 21 deletions(-) + +commit bf2049b17ac4706f472c59e50266f4eaf0ffaa32 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Dec 15 18:00:41 2013 +1030 + + pdftps: fix DocumentMedia/Page/Media/PageBBox DSC comments + + Bug 72312 + + poppler/PSOutputDev.cc | 167 + ++++++++++++++++++++++++++-------------- + poppler/PSOutputDev.h | 6 +- + qt4/src/poppler-ps-converter.cc | 1 + + qt5/src/poppler-ps-converter.cc | 1 + + utils/pdftops.cc | 1 + + 5 files changed, 119 insertions(+), 57 deletions(-) + +commit fe49033c9bd2103c13d4eb59983e06fdcdd33a8d +Author: Till Kamppeter <till.kamppeter@gmail.com> +Date: Sat Dec 14 16:05:09 2013 +1030 + + pdftops: ensure paper size takes into account rotation + + Bug 72312 + + poppler/PSOutputDev.cc | 48 + ++++++++++++++++++++---------------------------- + 1 file changed, 20 insertions(+), 28 deletions(-) + +commit 31edf585e62f4e91b7b64295cc8b978ac466ce58 +Author: Bogdan Cristea <cristeab@gmail.com> +Date: Mon Jan 27 20:06:11 2014 +0100 + + [qt] Improve compilation under Win 8 with Visual Studio 2012 + + Bug #73111 + + goo/GooMutex.h | 3 ++- + goo/GooTimer.h | 2 ++ + goo/gfile.h | 2 ++ + poppler/PDFDoc.cc | 4 +--- + poppler/XpdfPluginAPI.h | 2 ++ + poppler/poppler-config.h.cmake | 18 ++++++++++++++++-- + poppler/poppler-config.h.in | 18 ++++++++++++++++-- + qt4/tests/stress-threads-qt4.cpp | 5 +++++ + qt5/src/poppler-private.h | 6 ++++-- + qt5/tests/stress-threads-qt5.cpp | 5 +++++ + test/perf-test.cc | 1 - + 11 files changed, 55 insertions(+), 11 deletions(-) + +commit 834cd18e3ddfda44a11316290f7eee98cd871305 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 26 16:10:20 2014 +0100 + + Use c99 for the c compiler + + cmake/modules/PopplerMacros.cmake | 1 + + 1 file changed, 1 insertion(+) + +commit 03674a141a96806e5e1a134dc3dec2ee61b68713 +Author: Pino Toscano <pino@kde.org> +Date: Sun Jan 26 12:43:13 2014 +0100 + + qt4/qt5: add GCC visibility export attributes + + this does no actual changes to the exported symbols, but can help in + hiding symbols if the right GCC flags for symbols visibility are + specified + + qt4/src/poppler-export.h | 3 +++ + qt5/src/poppler-export.h | 3 +++ + 2 files changed, 6 insertions(+) + +commit 52b46d05219cf9898ee4adae7c8c2702adb1ba23 +Author: Pino Toscano <pino@kde.org> +Date: Sun Jan 26 12:38:03 2014 +0100 + + qt4/qt5: improve naming of internal export/import macros + + use something less generic than LIB_EXPORT/LIB_IMPORT + + qt4/src/poppler-export.h | 12 ++++++------ + qt5/src/poppler-export.h | 12 ++++++------ + 2 files changed, 12 insertions(+), 12 deletions(-) + +commit 7a8bcea11ad71fccbbba2787fc442f6ba4bf7100 +Author: Pino Toscano <pino@kde.org> +Date: Thu Jan 23 22:34:07 2014 +0100 + + cmake: install JpegWriter.h depending on libjpeg + + ... and not libopenjpeg + + CMakeLists.txt | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +commit 57f34f525fa2c2e62ebc7383ceba48ebc80ebba6 +Author: Andres Gomez <agomez@igalia.com> +Date: Wed Jan 8 12:26:14 2014 +0200 + + glib-demo: Fix conding style issue in render.c + + glib/demo/render.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 3fac919eeb1ca1abfdbb4f9923a454e532256f5c +Author: Andres Gomez <agomez@igalia.com> +Date: Wed Jan 8 12:25:52 2014 +0200 + + glib-demo: Fix trailing whitespaces in render.c + + glib/demo/render.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 92ea15642a6d3fe65d66d5c59fb6bed54e060e5d +Author: Christian Persch <chpe@gnome.org> +Date: Fri Jan 3 23:31:56 2014 +0100 + + glib: Install error callback + + Install an error callback so that poppler error messages can be + redirected + to the GLib logging API. + + https://bugs.freedesktop.org/show_bug.cgi?id=73269 + + glib/poppler.cc | 47 +++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 47 insertions(+) + +commit f99128e38bbff43623d5cd1c1bc27fd789d0bc0c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jan 19 16:03:35 2014 +0100 + + glib: Make vertices a constructor parameter of line annotations + + It's a required field in the line annotation. + + glib/demo/annots.c | 4 +--- + glib/poppler-annot.cc | 12 ++++++++++-- + glib/poppler-annot.h | 4 +++- + 3 files changed, 14 insertions(+), 6 deletions(-) + +commit 587a40f90e4ac5a1b6ab9044495a1ae403bc8c58 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jan 19 15:58:43 2014 +0100 + + annots: Fix memory leak when setting AnnotTextMarkup quads twice + + poppler/Annot.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 69e73da1fbab9bf3365b40dced1008b0283ac931 +Author: Germán Poo-Caamaño <gpoo@gnome.org> +Date: Wed Nov 20 11:53:30 2013 -0800 + + glib-demo: Add support for PopplerTextAnnotMarkup + + * The subtypes are: Highlihght, Squiggly, StrikeOut and Underline. + * Use ScrolledWindow for annotation properties to make room to + show the Quadrilaterals of TextMarkup annotations. + + https://bugs.freedesktop.org/show_bug.cgi?id=51487 + + glib/demo/annots.c | 232 + +++++++++++++++++++++++++++++++++++++++++++++++------ + 1 file changed, 206 insertions(+), 26 deletions(-) + +commit 9a7699ebe3e644ba845ef75d9295c88d321cb934 +Author: Germán Poo-Caamaño <gpoo@gnome.org> +Date: Mon Nov 18 16:42:08 2013 -0800 + + glib: Add PopplerAnnotTextMarkup class and subtypes + + The subtypes are: Highlihght, Squiggly, StrikeOut and Underline. + It adds convenient methods to set/get/free quadrilaterals + necessaries for TextMarkup annotations. + + https://bugs.freedesktop.org/show_bug.cgi?id=51487 + + glib/poppler-annot.cc | 264 + ++++++++++++++++++++++++++++++++++++ + glib/poppler-annot.h | 23 ++++ + glib/poppler-page.cc | 6 + + glib/poppler-private.h | 1 + + glib/poppler.h | 1 + + glib/reference/poppler-sections.txt | 11 ++ + 6 files changed, 306 insertions(+) + +commit 40040b41216a3dcc833fc224f1c6f15517a88aed +Author: Germán Poo-Caamaño <gpoo@gnome.org> +Date: Mon Nov 18 16:26:27 2013 -0800 + + glib: Add PopplerQuadrilateral boxed type + + https://bugs.freedesktop.org/show_bug.cgi?id=51487 + + glib/poppler-page.cc | 53 + +++++++++++++++++++++++++++++++++++++ + glib/poppler-page.h | 33 +++++++++++++++++++++++ + glib/poppler.h | 1 + + glib/reference/poppler-sections.txt | 6 +++++ + 4 files changed, 93 insertions(+) + +commit c8a845cf7c7752d3b7dad06013d3154812c66c92 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jan 14 20:26:59 2014 +0100 + + Do not define -ansi + + We are using long long that is not defined in ansi, so forcing ansi + strictness does + not make any sense. Bug #72499 + + cmake/modules/PopplerMacros.cmake | 5 ----- + configure.ac | 15 --------------- + 2 files changed, 20 deletions(-) + +commit f0c13ee72e8a7df17bdf847f5e922c01acee1f0d +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jan 6 21:55:07 2014 +0100 + + C for last commit + + poppler/Parser.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1e1b9991a911fb610e74119979b20b179f3f2a67 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jan 6 21:51:25 2014 +0100 + + Fix rendering of pdf file from KDE bug 329600 + + It used to work and regressed with large file support (used to work + because stuff just overflowed) + + lexer->getPos needs lexer to be a stream, if it is not, just resort + to the +5000 kludge + + poppler/Parser.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 4cd5c349cfbc745688c0c38fc50d364092bc3718 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jan 6 21:48:25 2014 +0100 + + Update popplers (C) + + poppler/poppler-config.h.cmake | 2 +- + poppler/poppler-config.h.in | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 7ca2f42b06757587dfd9521fb1c6c7d657545553 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jan 6 15:48:22 2014 +0100 + + Learn about automake 1.14 + + autogen.sh | 19 ++++++++++--------- + 1 file changed, 10 insertions(+), 9 deletions(-) + +commit de9643b6f76774ebe131c4787df82dd213181c71 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jan 3 00:53:37 2014 +0100 + + 0.25.1 + + CMakeLists.txt | 2 +- + NEWS | 19 +++++++++++++++++++ + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 5 files changed, 23 insertions(+), 4 deletions(-) + +commit e238c1f83fd5f667336bfbb0e9a59569ff638ecc +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jan 3 00:29:28 2014 +0100 + + Fix qt5 moc detection fix + + configure.ac | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit 381ae2877acace4e8908b07ee5fb442bc19bf814 +Merge: 64100e7 a2f0e4b +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jan 3 00:04:29 2014 +0100 + + Merge remote-tracking branch 'origin/poppler-0.24' + + Conflicts: + CMakeLists.txt + NEWS + configure.ac + cpp/Doxyfile + qt4/src/Doxyfile + qt5/src/Doxyfile + +commit a2f0e4b1fd8b3d9675cc00a561094bd78a63d048 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 2 23:48:29 2014 +0100 + + 0.24.5 + + CMakeLists.txt | 2 +- + NEWS | 4 ++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 6 files changed, 9 insertions(+), 5 deletions(-) + +commit 523b2731e0489bab58e66b21016bd6f010e616ea +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 2 22:54:42 2014 +0100 + + Update copyrights + + poppler/JBIG2Stream.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 64100e7f1f6b550e952838fce38615ec3788e17c +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Dec 28 12:11:47 2013 +0100 + + Simplify some calls to GooString::format-family functions + + poppler/Object.h | 4 ++-- + utils/pdftocairo.cc | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit 0abde34d0f7ba0fc04a30dbfd78373ec9d9d0695 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Dec 28 12:11:05 2013 +0100 + + Fixed some GooString format markers + + poppler/CMap.cc | 3 ++- + poppler/Function.cc | 3 ++- + poppler/StructElement.cc | 2 +- + 3 files changed, 5 insertions(+), 3 deletions(-) + +commit a7da4c6ac2b13308803806009c3437332b140586 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Fri Dec 27 17:09:39 2013 +0100 + + GooString format: fixed bug with printing LLONG_MIN + + ( -LLONG_MIN doesn't fit in a signed long long ) + + goo/GooString.cc | 19 +++++++++++++------ + 1 file changed, 13 insertions(+), 6 deletions(-) + +commit fe88f20cc565b4cf4765fed56c821989148ef454 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Fri Dec 27 17:08:50 2013 +0100 + + GooString format: Added some tests + improved documentation + + goo/GooString.h | 10 +++++-- + qt4/tests/check_goostring.cpp | 66 + +++++++++++++++++++++++++++++++++++++++++++ + qt5/tests/check_goostring.cpp | 66 + +++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 139 insertions(+), 3 deletions(-) + +commit 5234a349adb678d267a3d8ca13176ac8abb7afd2 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Fri Dec 20 20:25:26 2013 +0100 + + pdfunite: do not lose fonts when merging some files + + utils/pdfunite.cc | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit 8e24fcc0d296e07327e9cbe297f627bfc6471ee3 +Merge: 85efba3 b02f873 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Dec 18 21:51:57 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.24' + + Conflicts: + poppler/GfxState.cc + +commit b02f873174865837fed3a9544b70b8b21747a3dd +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Dec 18 21:46:12 2013 +0100 + + Fixed some GooString format markers + + poppler/GfxState.cc | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +commit 85efba38c02b5daf7d3fc46bc85850e6842a085d +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Wed Dec 18 00:46:00 2013 +0100 + + Make pdfunite work even if there's a single file given + + Bug #72720 + + utils/pdfunite.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit a766c55f68db38feed91cf003a0d5710e2f925a8 +Author: Tuomas Jormola <tj@solitudo.net> +Date: Mon Dec 16 20:43:28 2013 +0100 + + Fix detection of moc for Qt5 + + Bug #72744 + + On my Mac OS X 10.9 Mavericks system with Qt 5.2.0 installed using + Homebrew, the output of the moc command doesn't include the string + "Qt 5" which is expected by the moc version detection logic in + configure.ac of poppler 0.24.4. This patch updates the grep pattern so + that the current expected moc version output and the version output of + this installation of Qt5 are both detected as a valid moc for + Qt5. With + this patch applied, I was able to build and test poppler with Qt5 + support successfully. + + (09:26:05)(tj@gauri)(~)$ uname -a + Darwin gauri.ad.local.domain 13.0.0 Darwin Kernel Version 13.0.0: + Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 + x86_64 i386 MacBookPro3,1 Darwin + (09:26:08)(tj@gauri)(~)$ /usr/local/opt/qt5/bin/moc -v + moc 5.2.0 + (09:26:24)(tj@gauri)(~)$ + + configure.ac | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit a43b4bf84fe4bde6649049685bf4ed6a682e8286 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Dec 15 11:59:57 2013 +0100 + + regtest: Add a command line option to create-report command to not + launch the browser + + regtest/HTMLReport.py | 5 +++-- + regtest/commands/create-report.py | 5 ++++- + 2 files changed, 7 insertions(+), 3 deletions(-) + +commit 113958276b96d7f1aab7042e1807a9970425d234 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Dec 15 11:48:51 2013 +0100 + + regtest: Return an exist status code depending on whether the + command succeeded + + regtest/TestRun.py | 2 ++ + regtest/commands/__init__.py | 4 ++-- + regtest/commands/create-refs.py | 2 ++ + regtest/commands/create-report.py | 2 ++ + regtest/commands/find-regression.py | 4 +++- + regtest/commands/run-tests.py | 6 ++++-- + regtest/main.py | 8 ++++---- + regtest/poppler-regtest | 2 +- + 8 files changed, 20 insertions(+), 10 deletions(-) + +commit 44cf2de0df351d5948893f6a4e2bca1168d16b70 +Author: Dominik Haumann <dhaumann@kde.org> +Date: Thu Dec 12 23:12:35 2013 +0100 + + Arthur font rendering improvements + + The patch does does the following: + - use NoPen to fill the glyphs + - since SplashPath seems to bitwise OR stop and start of path, + closing a subpath needs to happen before starting a path. + + Arthur needs serious work but this is a definite improvement in all + the files i've tried it on + + qt4/src/ArthurOutputDev.cc | 18 +++++++++--------- + qt5/src/ArthurOutputDev.cc | 18 +++++++++--------- + 2 files changed, 18 insertions(+), 18 deletions(-) + +commit 02863f683be4543a2af6c26d53be93785d2b836a +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Dec 12 23:09:43 2013 +0100 + + qt: Simple silly test program to save to file + + Allows us to do some quick arthur testing + + qt4/tests/CMakeLists.txt | 1 + + qt4/tests/Makefile.am | 8 ++++- + qt4/tests/test-render-to-file.cpp | 69 + +++++++++++++++++++++++++++++++++++++++ + qt5/tests/CMakeLists.txt | 1 + + qt5/tests/Makefile.am | 8 ++++- + qt5/tests/test-render-to-file.cpp | 69 + +++++++++++++++++++++++++++++++++++++++ + 6 files changed, 154 insertions(+), 2 deletions(-) + +commit 018892d4ceccd5e2994cdb74cd2d401293fc929d +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Dec 11 23:05:53 2013 +0100 + + 0.25.0 + + CMakeLists.txt | 6 +++--- + configure.ac | 4 ++-- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 6 files changed, 9 insertions(+), 9 deletions(-) + +commit a1b99b26da9124fa55f773af55ae7382bd911d47 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Dec 11 23:00:00 2013 +0100 + + NEWS + + NEWS | 23 +++++++++++++++++++++++ + 1 file changed, 23 insertions(+) + +commit 10a0c45676ef56bee5924e889a7e7c21244b4339 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Dec 10 20:48:36 2013 +0100 + + Update copyrights + + cpp/poppler-image.cpp | 1 + + goo/PNGWriter.cc | 2 +- + poppler/MarkedContentOutputDev.cc | 2 ++ + poppler/MarkedContentOutputDev.h | 2 ++ + poppler/Object.h | 1 + + poppler/PDFDoc.h | 1 + + utils/ImageOutputDev.h | 2 +- + 7 files changed, 9 insertions(+), 2 deletions(-) + +commit 6c0e7d35f273583acc2aa818860e3120b0cab64f +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Tue Dec 10 20:14:39 2013 +0100 + + correction for knockout transparency groups + + Fixes test "G" in eci_altona-test-suite-v2_technical2_x4.pdf + + poppler/SplashOutputDev.cc | 18 ++++++++++--- + splash/Splash.cc | 63 + +++++++++++++++++++++++++++++++++------------ + splash/SplashFTFontEngine.h | 3 +++ + splash/SplashFontEngine.cc | 13 ++++++++++ + splash/SplashFontEngine.h | 5 ++++ + 5 files changed, 82 insertions(+), 20 deletions(-) + +commit f77bc21813ae7234ec4ce94ce4e92230fe5c174a +Merge: 06e9dc9 58e04a0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 7 16:56:11 2013 +0000 + + Merge remote-tracking branch 'origin/poppler-0.24' + + Conflicts: + utils/pdfimages.cc + utils/pdfinfo.cc + utils/pdfseparate.cc + +commit 06e9dc917650f562cd6f6666190a8c25756514a3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 7 16:39:02 2013 +0000 + + Compile++ + + CMakeLists.txt | 2 ++ + 1 file changed, 2 insertions(+) + +commit 58e04a08afee39370283c494ee2e4e392fd3b684 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Dec 7 16:33:09 2013 +0000 + + segExtraBytes is a goffset not an int so use lld + + Fixes KDE bug #328511 + + poppler/JBIG2Stream.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 3335d5e52fd7527bba7368ad6e87f1188808582f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Dec 6 17:28:13 2013 +0100 + + regtest: Limit the stderr files to ~1MB + + Some tests send a lot of information to stderr, usually due to parsing + errors in buggy documents. More than 1MB of stderr output is + diffcult to + hanlde and in most cases it's redundant with a lot of duplicated + messages. + This patch reduced the size of the refs dir for the complete test + suite + by 1GB. + + regtest/backends/__init__.py | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit 24107ac47625438837d7c29053bff795f986a6bb +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Dec 6 13:24:47 2013 +0100 + + regtest: Save checksum results sorted in md5 files + + We are using os.listdir() to get the list of test results that returns + files in arbitrary order. + + regtest/backends/__init__.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit f1c9993d58fb9d191a7b3e26bfcaf7b5eec5323d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Dec 6 13:03:24 2013 +0100 + + regtest: Show also the tests expected to crash/fail to run but + don't fail + + regtest/TestRun.py | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit 64d1e79c863d12b12b87ed0e3139d364f503e026 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Dec 6 12:51:48 2013 +0100 + + regtest: Improve readability of test results + + Show a summary of tests failed per backend with the percentages and + use a + new line for every test in the result instead of using a comma + separated + line. + + regtest/TestRun.py | 67 + ++++++++++++++++++++++++++++++++++++++---------------- + 1 file changed, 47 insertions(+), 20 deletions(-) + +commit c35bc1da9402896c88999f9cffed6962a265f32e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Dec 6 10:04:48 2013 +0100 + + glib-demo: Increase the default size of the main window + + Some demos like annots that show a document view use more space than + they used to, requiring to manually resize the window everytime. + + glib/demo/main.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ab7da0bf62bb5032c4683d9cd841075d26045aae +Author: Germán Poo-Caamaño <gpoo@gnome.org> +Date: Mon Oct 28 22:52:22 2013 -0700 + + glib-demo: Add Square and Circle annotations demo + + https://bugs.freedesktop.org/show_bug.cgi?id=70983 + + glib/demo/annots.c | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +commit 2ec450567f27bba3ee4a08b5e69b7c9605bea4bb +Author: Germán Poo-Caamaño <gpoo@gnome.org> +Date: Mon Oct 28 22:48:39 2013 -0700 + + glib: Add implementation of Square and Circle annotations + + Square and Circle only differ in the constructor which defines + the subtype. Therefore, it uses the same name than Poppler's + Geometry class. + + https://bugs.freedesktop.org/show_bug.cgi?id=70983 + + glib/poppler-annot.cc | 263 + ++++++++++++++++++++++++++++++++---- + glib/poppler-annot.h | 23 ++++ + glib/poppler-page.cc | 6 + + glib/poppler-private.h | 2 + + glib/poppler.h | 2 + + glib/reference/poppler-sections.txt | 16 +++ + 6 files changed, 286 insertions(+), 26 deletions(-) + +commit e109cf2461d5be93d004593123d875a28fd79b61 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Nov 26 20:12:22 2013 +0100 + + annots: Make Annot::setBorder receive an AnnotBorder object + + Instead of receiving AnnotBorderArray. Also implement writeToObject in + both AnnotBorderArray and AnnotBorderBS to make sure that + Annot::setBorder will work for both cases. + + poppler/Annot.cc | 51 +++++++++++++++++++++++++++++++++++++++++++++------ + poppler/Annot.h | 10 +++++++--- + 2 files changed, 52 insertions(+), 9 deletions(-) + +commit 3979b82982e84107d93fbbe95350bf25ce47398d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Nov 26 14:44:57 2013 +0100 + + annots: Use a default border for annots that can have a BS entry + + According to the spec if neither the Border nor the BS entry is + present, + the border shall be drawn as a solid line with a width of 1 point. + However, acroread seems to ignore the Border entry for annots + that can't + have a BS entry. + + poppler/Annot.cc | 223 + ++++++++++++++++++++++++++++++++----------------------- + 1 file changed, 132 insertions(+), 91 deletions(-) + +commit 36c07c82bdff010695c5d615b67506922522d0e8 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Nov 26 14:07:21 2013 +0100 + + annots: Add helper function Annot::setLineStyleForBorder + + It sets the line dash and width based on the given AnnotBorder. Use it + only when the border width is greater than 0 for FreeText annotations + and always for annotations that use the border to set the line + width and + dash, but don't draw a border. + + poppler/Annot.cc | 110 + ++++++++++++++++--------------------------------------- + poppler/Annot.h | 1 + + 2 files changed, 32 insertions(+), 79 deletions(-) + +commit e7b1ff97318fd6c3a8fed3a33d45f1cb55208b28 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Nov 26 11:40:57 2013 +0100 + + annots: Remove unused typeUnknown AnnotBorderType from AnnotBorder + + Also make the AnnotBorder constructor protected to make sure it's not + possible to create AnnotBorder instances. + + poppler/Annot.cc | 3 --- + poppler/Annot.h | 12 ++++++++---- + 2 files changed, 8 insertions(+), 7 deletions(-) + +commit 17b2623360ed8917e94a8e5b880e92e6db70335e +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Tue Jun 18 00:35:51 2013 +0300 + + Tagged-PDF: Text content extraction from structure elements + + Implement StructElement::getText(), by using MCOutputDev. This + output device + captures pieces of text (aka "spans") which have the same attributes + into + a list of TextSpan objects. + + https://bugs.freedesktop.org/show_bug.cgi?id=64815 + + poppler/Makefile.am | 2 + + poppler/MarkedContentOutputDev.cc | 210 + ++++++++++++++++++++++++++++++++++++++ + poppler/MarkedContentOutputDev.h | 128 +++++++++++++++++++++++ + poppler/StructElement.cc | 50 +++++++++ + poppler/StructElement.h | 28 +++++ + 5 files changed, 418 insertions(+) + +commit 2c4320c26744ea28be10eac7cc54980c9eb4fc27 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Dec 3 19:07:09 2013 +0100 + + glib-demo: Show number of charcters and text layout units in text demo + + It helps to easily detect the cases where these values mismatch. + + glib/demo/text.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 98d75dcdb9b73feb6f35d8ad76f5d0c428289f91 +Author: Jason Crain <jason@aquaticape.us> +Date: Sat Nov 30 17:29:50 2013 +0100 + + Limit use of ZapfDingbats character names + + Some PDFs use names from ZapfDingbats (a1-a206) without intending for + them to be used for text extraction. Only use these character names + to locate glyphs or for text extraction with ZapfDingbats fonts. + + Bug #60243 + + goo/GooString.cc | 10 ++ + goo/GooString.h | 4 + + poppler/GfxFont.cc | 15 +- + poppler/GlobalParams.cc | 33 +++- + poppler/GlobalParams.h | 16 +- + poppler/NameToUnicodeTable.h | 415 + ++++++++++++++++++++++--------------------- + 6 files changed, 274 insertions(+), 219 deletions(-) + +commit 817cc333ca8009998f2099583fd0a2fc703f3db3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Nov 29 10:07:16 2013 +0100 + + regtest: Do not buffer stderr output + + Some buggy documents can produce a huge stderr output because + of parsing + errors or whatever. We could give a file directly to Popen to + write the + stderr file, but we only want to create the file when there's output, + because it's what we use to know whether the command produced + output or + not. So, instead of buffering the whole output and then write it + to the + file, now we read from the pipe while the command is running, writing + the output in chunks to the file. This improves a lot the memory + consumption when running some tests. + + regtest/backends/__init__.py | 40 + ++++++++++++++++++++++++++++++---------- + 1 file changed, 30 insertions(+), 10 deletions(-) + +commit f8f82f1cc3a948239a05d7762210a3f244299db6 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Nov 29 10:03:24 2013 +0100 + + regtest: Read test results in chunks to get the md5 digest + + Some backends can generate huge results, like huge postscript + files that + we don't want to load in memory to get the md5. So, instead of + creating + thr md5 object with the entire file, we feed it with chunks of data + using the update method. This improves a lot the memory consumption + and + performance as well. + + regtest/backends/__init__.py | 19 ++++++++++++------- + 1 file changed, 12 insertions(+), 7 deletions(-) + +commit 3444a44397a890dbeb1bd10357dbc8246fd21ad0 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Nov 29 10:01:20 2013 +0100 + + regtest: Remove unused method _check_exit_status2 + + It was used when the backends ran in parallel odd and even pages, but + it's no longer used since threads support was added. + + regtest/backends/__init__.py | 20 -------------------- + 1 file changed, 20 deletions(-) + +commit 5f825df417947c51943f1db327e1aa6c3faa15b0 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Nov 29 09:57:57 2013 +0100 + + regtest: Do not store the current line in Printer but only its length + + We are not using the line text anymore, but only the length. + + regtest/Printer.py | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +commit 1486d93f0f6418b37ccc57568717d9349a79935b +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Nov 27 18:29:36 2013 +0100 + + regtest: Do not consider docs with no refs as skipped + + Handle them differently as new docs, and show them in the summary + suggesting to use create-refs command to include them in the test + suite. + + regtest/TestRun.py | 40 +++++++++++++++++++++++----------------- + 1 file changed, 23 insertions(+), 17 deletions(-) + +commit 5241c0cc730c380dc44c3a081e1de675e1915861 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Nov 27 17:18:37 2013 +0100 + + regtest: Use number of tests run to show the progress + + Instead of using the number of document tested. We don't really + need to + set a number to a particular document, we only want to know the + progress + of the whole process. This ensures that the progress is shown in the + correct order. It also simplifies the code a bit. + Also improved the output formatting to make it easier to read. + + regtest/Printer.py | 44 ++++----------- + regtest/TestReferences.py | 50 +++++++++++------ + regtest/TestRun.py | 136 + +++++++++++++++++++++++++--------------------- + 3 files changed, 118 insertions(+), 112 deletions(-) + +commit 0af3e009a702d0c6ca716565ab87b386baa0a1ed +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 27 00:53:16 2013 +0100 + + 0.24.4 + + CMakeLists.txt | 4 ++-- + NEWS | 18 ++++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 7 files changed, 25 insertions(+), 7 deletions(-) + +commit a42a13be0a0cda71dc230a73f7b16eb4eb066251 +Author: suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Wed Nov 27 00:05:57 2013 +0100 + + Warn the user if he provides a wrong range + + utils/pdffonts.cc | 7 +++++++ + utils/pdfimages.cc | 7 +++++++ + utils/pdfinfo.cc | 7 +++++++ + utils/pdfseparate.cc | 7 +++++++ + utils/pdftocairo.cc | 7 +++++++ + utils/pdftohtml.cc | 8 +++++++- + utils/pdftoppm.cc | 7 +++++++ + utils/pdftops.cc | 7 +++++++ + utils/pdftotext.cc | 6 ++++++ + 9 files changed, 62 insertions(+), 1 deletion(-) + +commit 45552cafaeef6b883078db269437586add1dc32c +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Nov 26 23:36:12 2013 +0100 + + Update copyrights + + utils/pdftotext.cc | 1 + + 1 file changed, 1 insertion(+) + +commit f20fe89d4f5a8f768e2019f25cecf40cd0e4f5f8 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Nov 25 09:05:41 2013 +0100 + + glib-demo: Add an area selector to text demo + + And use the for_area variants of the API to get the text, text layout + and text attributes. + + glib/demo/text.c | 114 + +++++++++++++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 110 insertions(+), 4 deletions(-) + +commit bb2b7fb491fb72f0ea024d80df89680ede3457b4 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Nov 25 09:04:30 2013 +0100 + + glib: Add API to get text, text layout and text attributes for a + given area + + glib/poppler-page.cc | 107 + ++++++++++++++++++++++++++++++++++-- + glib/poppler-page.h | 8 +++ + glib/reference/poppler-sections.txt | 3 + + 3 files changed, 113 insertions(+), 5 deletions(-) + +commit f662973b0da52da84acc3668a0e037ee72498193 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Nov 2 14:07:07 2013 +0100 + + TextOutputDev: Honor the selection rectangle passed to + TextPage::getSelectionWords() + + Make TextPage::getSelectionWords() return a list of TextWordSelection + instead of a list of TextWord so that it's possible to know which + characters of the word are inside the given selection rectangle. + Adapt the glib frontend to the new API and use the selection bounds + instead of the whole word to build the list of characters in + poppler_page_get_text_layout() and poppler_page_get_text_attributes(), + which ensures the number of glyphs returned is in sync with the number + of characters returned by poppler_page_get_text(). + + https://bugs.freedesktop.org/show_bug.cgi?id=71160 + + glib/poppler-page.cc | 22 ++++++++++++++-------- + poppler/TextOutputDev.cc | 40 ++++++++-------------------------------- + poppler/TextOutputDev.h | 20 ++++++++++++++++++++ + 3 files changed, 42 insertions(+), 40 deletions(-) + +commit 18fab454c59b1c77c691617aaef99245eacd83b5 +Author: Germán Poo-Caamaño <gpoo@gnome.org> +Date: Mon Oct 28 22:41:41 2013 -0700 + + glib-demo: Simplify annotations list and its properties + + * Move the annotation's rectangle to properties to make the + list view of annotations cleaner. + * Remove duplicated information: flags and page are already + present in the UI. + + https://bugs.freedesktop.org/show_bug.cgi?id=70982 + + glib/demo/annots.c | 70 + ++++++++++++------------------------------------------ + 1 file changed, 15 insertions(+), 55 deletions(-) + +commit 770a7ac9833a3c4f4f0399093272d4d0bdc7923b +Merge: e7a0f2b 9ae29c7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Nov 21 23:58:29 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.24' + +commit 9ae29c7a07d0f372dbfc4aca17bbb646126aedb5 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Thu Nov 21 23:53:53 2013 +0100 + + Don't end loop if reading from GooFile fails + + Bug #71835 + + poppler/Stream.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit e7a0f2b942fe621304275175324f7809d1c83d80 +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Nov 20 00:43:27 2013 +0100 + + Fix warning on signed/unsigned comparison in GfxState.cc + + Bug #71641 + + poppler/GfxState.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit c784c4c3a582aaa4e10c223665cb876e12b7c16f +Author: Germán Poo-Caamaño <gpoo@gnome.org> +Date: Mon Nov 18 00:57:53 2013 -0800 + + glib-demo: Add support for simple line annotations + + https://bugs.freedesktop.org/show_bug.cgi?id=70981 + + glib/demo/annots.c | 99 + +++++++++++++++++++++++++++++++++++++++++++++++++----- + 1 file changed, 91 insertions(+), 8 deletions(-) + +commit 2d164e06b8a84ade6689d85bba2d606c66bf62a9 +Author: Germán Poo-Caamaño <gpoo@gnome.org> +Date: Mon Nov 18 00:48:13 2013 -0800 + + glib-demo: add color selection for new annotations + + https://bugs.freedesktop.org/show_bug.cgi?id=71727 + + glib/demo/annots.c | 34 ++++++++++++++++++++++++++++++++++ + 1 file changed, 34 insertions(+) + +commit 7127a2c705787f6f44b0852efeabe9fdeae7e2c0 +Author: Germán Poo-Caamaño <gpoo@gnome.org> +Date: Sun Nov 17 23:38:32 2013 -0800 + + glib: Add support for simple line annotations + + https://bugs.freedesktop.org/show_bug.cgi?id=70981 + + glib/poppler-annot.cc | 79 + +++++++++++++++++++++++++++++++++++++ + glib/poppler-annot.h | 12 ++++++ + glib/poppler-page.cc | 3 ++ + glib/poppler-private.h | 1 + + glib/poppler.h | 1 + + glib/reference/poppler-sections.txt | 7 ++++ + 6 files changed, 103 insertions(+) + +commit 451bac9f05bab18f3aa0392ddf6eb6b569004cb8 +Author: Germán Poo-Caamaño <gpoo@gnome.org> +Date: Sun Nov 17 23:30:14 2013 -0800 + + glib: Add PopplerPoint boxed type + + https://bugs.freedesktop.org/show_bug.cgi?id=70981 + + glib/poppler-page.cc | 54 + +++++++++++++++++++++++++++++++++++++ + glib/poppler-page.h | 20 ++++++++++++++ + glib/poppler.h | 1 + + glib/reference/poppler-sections.txt | 5 ++++ + 4 files changed, 80 insertions(+) + +commit c01cee165392ba8297e4168111a66d2acb272a99 +Merge: 07c2554 47605a8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Nov 18 22:58:28 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.24' + + Conflicts: + poppler/Catalog.cc + poppler/Catalog.h + +commit 47605a8aaf85bee21601219b04c0c8e6cf982507 +Author: José Aliste <jaliste@src.gnome.org> +Date: Mon Nov 18 22:52:08 2013 +0100 + + Catalog: sort entries of NameTrees to make sure lookup works + + Bug #26049 + + poppler/Catalog.cc | 12 ++++++++++++ + poppler/Catalog.h | 2 ++ + 2 files changed, 14 insertions(+) + +commit 07c255482f7ec8a8cfd4eaeaf7b07de317bbcc7a +Author: Germán Poo-Caamaño <gpoo@gnome.org> +Date: Sun Oct 27 13:30:22 2013 -0700 + + glib-demo: Add annotations interactively + + * Prepare UI to add multiple annotations type. + * Remove dialog and button add annotations. + + https://bugs.freedesktop.org/show_bug.cgi?id=69978 + + glib/demo/annots.c | 348 + ++++++++++++++++++++++++++++++++--------------------- + 1 file changed, 213 insertions(+), 135 deletions(-) + +commit 4b7c91ea697359751f9abe9ec5e63021c90a60ed +Author: Germán Poo-Caamaño <gpoo@gnome.org> +Date: Sat Sep 28 23:18:07 2013 -0700 + + glib: Add getter and setter for annotation's rectangle + + Annotation objects contain at least two keys, Rect and Subtype. + The former has the coordinates where the annotation is placed. + The getter and setter allows to obtain and modify the position + of a given annotation. + + https://bugs.freedesktop.org/show_bug.cgi?id=70901 + + glib/poppler-annot.cc | 48 + +++++++++++++++++++++++++++++++++++++ + glib/poppler-annot.h | 4 ++++ + glib/reference/poppler-sections.txt | 2 ++ + 3 files changed, 54 insertions(+) + +commit 491f0a170c72271a7a9ce049fbcfe81f08cff162 +Author: suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Fri Nov 15 20:35:12 2013 +0100 + + pdftotext: Escape the text of the xml headers + + utils/pdftotext.cc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit 4da94680d4d2d6b1bd3351d476a20f9c7ae565bc +Merge: 3ea3d7c 78c407a +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Nov 15 20:27:00 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.24' + +commit 3ea3d7c6c7a0ede76428204ec11aec3a844117fc +Author: Hib Eris <hib@hiberis.nl> +Date: Fri Nov 15 19:59:52 2013 +0100 + + pdftotext: Silence warning for may be used uninitialized variable + + Bug #71640 + + utils/pdftotext.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 97910b9eb92df49757915bde02e0d54de04552d4 +Author: Hib Eris <hib@hiberis.nl> +Date: Fri Nov 15 19:55:19 2013 +0100 + + Do not close stdout in pdftotext + + Bug #71639 + + utils/pdftotext.cc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit 78c407ac7e8f48ae2d2c75ad0f5960390190d2e3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Nov 15 20:25:52 2013 +0100 + + destionation -> destination + + And this is why the xml based api has to die + + Bug #71643 + Found by Hib + + qt4/src/poppler-annotation.cc | 5 +++-- + qt5/src/poppler-annotation.cc | 3 ++- + 2 files changed, 5 insertions(+), 3 deletions(-) + +commit a23c9ad4c0536d680bedc563444ce3adf6e1ee9e +Author: Hib Eris <hib@hiberis.nl> +Date: Fri Nov 15 11:38:45 2013 +0100 + + Silence warning for may be used uninitialized variable in + ImageOutputDec.cc + + Fixes warning: + + CXX ImageOutputDev.lo + ImageOutputDev.cc: In member function 'void + ImageOutputDev::writeImageFile(ImgWriter*, + ImageOutputDev::ImageFormat, const char*, Stream*, int, int, + GfxImageColorMap*)': + ImageOutputDev.cc:409:28: warning: 'imgStr' may be used uninitialized + in this function [-Wmaybe-uninitialized] + + Bug #71642 + + utils/ImageOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit c43a80e65fc570a8017892ba111a8c48ac33d9ad +Author: Hib Eris <hib@hiberis.nl> +Date: Fri Nov 15 19:59:52 2013 +0100 + + pdftotext: Silence warning for may be used uninitialized variable + + Bug #71640 + + utils/pdftotext.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit f905d804c0d1c715d8423938f41b5a002c0ef15d +Author: Hib Eris <hib@hiberis.nl> +Date: Fri Nov 15 19:55:19 2013 +0100 + + Do not close stdout in pdftotext + + Bug #71639 + + utils/pdftotext.cc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit 33e703ac9bb6cf69664d6c6fddd3bebd56336074 +Merge: 8294d18 7c74bcc +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Nov 15 19:50:10 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.24' + +commit 7c74bccdf514cce05987dde7fb1cce4ac65ff025 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Nov 15 19:48:07 2013 +0100 + + Forgot to update the copyrights + + poppler/Lexer.cc | 2 +- + poppler/Lexer.h | 2 +- + poppler/Parser.cc | 2 +- + poppler/Parser.h | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +commit ebe49d597a62aa94601c2e4595dbad1895ea7ef0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Nov 15 19:33:00 2013 +0100 + + Fix regression in broken endstream detection + + Rregression was caused by e1ffa9100cf6b4a444be7ed76b11698a5c5bb441 + Fixes bug #70854 + + poppler/Lexer.cc | 4 ++-- + poppler/Lexer.h | 2 +- + poppler/Parser.cc | 11 ++++------- + poppler/Parser.h | 2 +- + 4 files changed, 8 insertions(+), 11 deletions(-) + +commit 8294d18ea96bd18be076bccbdbdaa015fc48aa12 +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Thu Sep 26 20:46:34 2013 +0300 + + Tagged-PDF: Parsing of StructElem standard types and attributes + + Parse attributes and standard types of StructElem nodes of the + document structure tree. Type name aliases are resolved via the + RoleMap (and cycles detected). Both standard attributes and user + properties are mapped to instances of the Attribute class. + Attributes are parsed both via ClassMap references and directly + referenced from the StructElem objects. + + https://bugs.freedesktop.org/show_bug.cgi?id=64815 + + poppler/StructElement.cc | 1018 + +++++++++++++++++++++++++++++++++++++++++++++- + poppler/StructElement.h | 113 ++++- + 2 files changed, 1126 insertions(+), 5 deletions(-) + +commit 4e0cbd37b964107c0fb531d48876a33ae843bf27 +Author: suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Mon Nov 11 22:46:07 2013 +0100 + + pdftohtml: Add -? and --help + + utils/pdftohtml.cc | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit 4dbd36f5b35dd0964e59d942242aecdc6b474c89 +Author: Andres Gomez <agomez@igalia.com> +Date: Tue Nov 5 09:52:23 2013 +0200 + + glib-demo: Fix conding style issue in main.c + + https://bugs.freedesktop.org/show_bug.cgi?id=71245 + + glib/demo/main.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 02f3c235eaf60350c98e88dbe266378fccef59d7 +Author: Andres Gomez <agomez@igalia.com> +Date: Tue Nov 5 09:52:23 2013 +0200 + + glib-demo: Fix a typo in function name + + https://bugs.freedesktop.org/show_bug.cgi?id=71245 + + glib/demo/main.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 5620b82e69335b7f12d877a24f1a463604f0e515 +Author: Andres Gomez <agomez@igalia.com> +Date: Tue Nov 5 09:52:23 2013 +0200 + + glib-demo: Fix trailing whitespaces in main.c + + https://bugs.freedesktop.org/show_bug.cgi?id=71245 + + glib/demo/main.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +commit 43309d92d327b4ae8e89edb15482247045d726a4 +Author: Germán Poo-Caamaño <gpoo@gnome.org> +Date: Sat Sep 28 20:45:32 2013 -0700 + + glib-demo: Make the Remove annotation button prominent in demo + + Move out from Annotation properties to the top. This make better + use of the space. + Make the remove button active only if there is an annotation + selected. + + https://bugs.freedesktop.org/show_bug.cgi?id=69978 + + glib/demo/annots.c | 22 +++++++++++++--------- + 1 file changed, 13 insertions(+), 9 deletions(-) + +commit f4a72fd3c61091d6b455af9a881c2390da19b506 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 26 19:06:34 2013 +0200 + + 0.24.3 + + CMakeLists.txt | 2 +- + NEWS | 14 ++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 6 files changed, 19 insertions(+), 5 deletions(-) + +commit 33a5af32cd5769cf1b6c6344077ac4a3f407ba21 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 26 18:48:50 2013 +0200 + + Update copyrights + + qt4/src/poppler-document.cc | 2 +- + utils/pdfseparate.cc | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 9f09b9596f1fc52481914019d68c8f9b85b5c438 +Merge: bd893d4 61f79b8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 24 01:03:02 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.24' + +commit 61f79b8447c3ac8ab5a26e79e0c28053ffdccf75 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 24 00:54:56 2013 +0200 + + Allow only one %d in the filename + + Fixes crashes if you had %s and similar in the filename + + Inspired from patch by Pedro Ribeiro <pedrib@gmail.com> + + Bug #69434 + + utils/pdfseparate.cc | 31 ++++++++++++++++++++++++++++++- + 1 file changed, 30 insertions(+), 1 deletion(-) + +commit bd893d4a543a6cc3a525655f37def38440944f28 +Merge: 93e8b05 daa0990 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 10 02:19:34 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.24' + +commit daa0990a7baf17d00d12574a4de815e070727a86 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 10 02:16:25 2013 +0200 + + Return empty if getXRef()->copy() fails + + Seems this can happen by looking at the backtrace in + https://bugs.kde.org/show_bug.cgi?id=325810 + + qt4/src/poppler-document.cc | 6 ++++++ + qt5/src/poppler-document.cc | 6 ++++++ + 2 files changed, 12 insertions(+) + +commit f4bfa940aa40a82a1080cdaf765da1d1615ccfb1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Oct 5 11:20:04 2013 +0200 + + cairo: Do not set an invalid matrix in drawImage() + + https://bugs.freedesktop.org/show_bug.cgi?id=70085 + + poppler/CairoOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 93e8b05fb2a6d225f048db6a3a735717433a5a13 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Oct 5 11:20:04 2013 +0200 + + cairo: Do not set an invalid matrix in drawImage() + + https://bugs.freedesktop.org/show_bug.cgi?id=70085 + + poppler/CairoOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 3084f8f4a5ad55937094b14e30169dccf1fa4ec9 +Author: Germán Poo-Caamaño <gpoo@gnome.org> +Date: Sat Sep 21 11:59:32 2013 -0700 + + glib-demo: Expand short names for annotations used in demo + + https://bugs.freedesktop.org/show_bug.cgi?id=69978 + + glib/demo/annots.c | 10 +++++----- + glib/demo/main.c | 2 +- + 2 files changed, 6 insertions(+), 6 deletions(-) + +commit ff674f57a3587142165fd56aec089d9840ceda36 +Author: Germán Poo-Caamaño <gpoo@gnome.org> +Date: Fri Sep 27 22:33:42 2013 -0700 + + glib-demo: Merge columns Type and Color in annotations demo + + Reduce the space used by both columns, makes the color + pixbuf smaller enough to give a clue of the annotation + color. + + https://bugs.freedesktop.org/show_bug.cgi?id=69978 + + glib/demo/annots.c | 28 ++++++++++++++++------------ + 1 file changed, 16 insertions(+), 12 deletions(-) + +commit 76d6e2d385e2cbad7f44bc8aee05147efd3970a4 +Author: Germán Poo-Caamaño <gpoo@gnome.org> +Date: Fri Sep 20 23:27:20 2013 -0700 + + glib-demo: Rearrange layout for annotations in demo + + Add render area to visualize the annotations per page. + + https://bugs.freedesktop.org/show_bug.cgi?id=69978 + + glib/demo/annots.c | 130 + ++++++++++++++++++++++++++++++++++++++++++++++++----- + 1 file changed, 118 insertions(+), 12 deletions(-) + +commit a6b1fc1a2ca83b3e4c52bcaa95b99d0289354f4b +Author: Germán Poo-Caamaño <gpoo@gnome.org> +Date: Sun Sep 29 22:50:42 2013 -0700 + + glib-demo: Fix rectangle calculation for new annotations in demo + + https://bugs.freedesktop.org/show_bug.cgi?id=69978 + + glib/demo/annots.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit bd49b3c0c6f2adccc5bda561edbaf9f00ed2917a +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Wed Oct 2 23:32:09 2013 +0200 + + Use icc profile in OutputIntents + + Bug #34053 + + poppler/Gfx.cc | 114 +++++++++++--- + poppler/Gfx.h | 8 +- + poppler/GfxState.cc | 429 + +++++++++++++++++++++++++++++++++++++++++----------- + poppler/GfxState.h | 72 ++++++--- + poppler/Page.cc | 2 +- + 5 files changed, 490 insertions(+), 135 deletions(-) + +commit df947a0641082f530200880d46e20cd3e1fd962f +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Oct 2 20:53:32 2013 +0200 + + Compile++ + + CMakeLists.txt | 4 ++++ + 1 file changed, 4 insertions(+) + +commit fa83d7e4f36cfc11c7b4f81f5f5e8ed69eb6dbbe +Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net> +Date: Wed Oct 2 20:35:58 2013 +0200 + + pdfseparate: allow zero-padded pagespecs + + Bug #50914 + + utils/pdfseparate.cc | 22 +++++++++++++++++++--- + 1 file changed, 19 insertions(+), 3 deletions(-) + +commit e04cabd878a0fd84faa5178f423fd828d010b664 +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Mon Jun 17 17:00:27 2013 +0300 + + Tagged-PDF: Implement parsing of StructTreeRoot + + Implement parsing of the StructTreeRoot entry of the Catalog. Also, + the + Catalog::getStructTreeRoot() and PDFDoc::getStructTreeRoot() + methods are + modified to return an instance of StructTreeRoot instead of an Object. + + All elements from the StructTreeRoot are parsed except for: + + - IDTree: it is a lookup tree to locate items by their ID, which would + be barely useful because the whole structure tree is to be kept in + memory, which should be fast enough to traverse. + - ParentTreeNextKey: This is needed only when the ParentTree object is + to be modified. For the moment the implementation deals only with + reading, so this has been deliberately left out. + + StructElem tree nodes from the document structure tree are parsed as a + StructElement instance. Attributes and extraction of content out from + elements are not yet handled. + + https://bugs.freedesktop.org/show_bug.cgi?id=64815 + + poppler/Catalog.cc | 36 +++--- + poppler/Catalog.h | 5 +- + poppler/Makefile.am | 4 + + poppler/PDFDoc.h | 3 +- + poppler/StructElement.cc | 322 + ++++++++++++++++++++++++++++++++++++++++++++++ + poppler/StructElement.h | 167 ++++++++++++++++++++++++ + poppler/StructTreeRoot.cc | 174 +++++++++++++++++++++++++ + poppler/StructTreeRoot.h | 83 ++++++++++++ + 8 files changed, 776 insertions(+), 18 deletions(-) + +commit 45e0fe56985f34e695c99a2f6ec1ffe14e239b9e +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Thu Sep 26 20:56:52 2013 +0300 + + Implement Object::takeString() method + + Object::takeString() behaves like Object::getString(), but transfers + ownership of the returned string to the caller. Also, it makes + sure that + calling Object::free() afterwards won't free the string that the + Object + is holding. + + poppler/Object.h | 4 ++++ + 1 file changed, 4 insertions(+) + +commit d80eb4a34c218de34633ee2f1b9dfd65504a0ad9 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Tue Oct 1 22:57:55 2013 +0200 + + cache cms values in getGray(), getRGB() and getCMYK() + + Bug #68420 + + poppler/GfxState.cc | 111 + ++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/GfxState.h | 2 + + 2 files changed, 113 insertions(+) + +commit 9bc8f3240698d5a8ae4c0129e768840664d28c22 +Merge: a2742c8 e2fe851 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Oct 1 19:19:32 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.24' + +commit e2fe85137ecb59eb0d177682c552febc64cda643 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Oct 1 19:15:08 2013 +0200 + + Fix PFB font embedding + + Bug #69717 + + poppler/PSOutputDev.cc | 52 + ++++++++++++++++++++++++++++++++++++++++++++------ + 1 file changed, 46 insertions(+), 6 deletions(-) + +commit a2742c8fce0594ccbdb036dd0c29c6e15d2229f3 +Merge: 6b30a52 06dabe1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 30 19:32:41 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.24' + +commit 06dabe1eed912e5f5c96fe9f371ab459516e5a99 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 27 12:41:23 2013 +0200 + + 0.24.2 + + CMakeLists.txt | 2 +- + NEWS | 8 ++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 6 files changed, 13 insertions(+), 5 deletions(-) + +commit 78141da189c42a04b6a303767284de755a4a2d4d +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 27 12:39:00 2013 +0200 + + Update copyrights + + utils/pdfseparate.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 6b30a5214e39993025cf2fb9f221e1360de7fa9c +Merge: 4966b6f dc344b4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 21 10:38:45 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.24' + +commit dc344b410f49410174ee902b7649ebd8c2cb0fa2 +Author: Lu Wang <coolwanglu@gmail.com> +Date: Sat Sep 21 10:37:30 2013 +0200 + + pdftocairo: check file opening failure in beginDocument() + + utils/pdftocairo.cc | 7 +++++++ + 1 file changed, 7 insertions(+) + +commit 4966b6f4193cc9d13f63e92bdc2aac0c8b78298d +Merge: 0f074b1 1e612d3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 21 10:15:28 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.24' + +commit 1e612d331b79dabec66ad241d7ffe66674a10bc4 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sat Sep 21 10:10:16 2013 +0200 + + Windows: Fix CreateFile fails with ERROR_SHARING_VIOLATION + + Bug #69597 + + goo/gfile.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 0f074b16317d874fe58d7042f8434282786ca757 +Merge: d277432 b8682d8 +Author: Pino Toscano <pino@kde.org> +Date: Mon Sep 16 19:53:10 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.24' + + Conflicts: + utils/pdfimages.1 + +commit b8682d868ddf7f741e93b791588af0932893f95c +Author: Pino Toscano <pino@kde.org> +Date: Mon Sep 16 19:46:55 2013 +0200 + + pdfseparate: improve the path building + + Make use of snprintf to limit the output to the pathName buffer; + while I'm there, expand its size to 4096 (might help longer paths), + although a better fix would be dynamically allocate its length + (and/or using GooString, maybe). + + utils/pdfseparate.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit d2774325f5248018977d3ab8f8dd7155ed972668 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Sep 14 14:08:11 2013 +0930 + + pdfimages.1: fix typo + + utils/pdfimages.1 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 9b5957278c7f249fa1010e61a0ed79f0eb20e26d +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Aug 31 17:33:25 2013 +0930 + + pdfimages: ensure dump* variables are intialized + + utils/ImageOutputDev.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit e116ef32504b589001814f0f579309ecf7ec89d9 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Aug 28 08:05:23 2013 +0930 + + Make cpp/poppler-image.cc use goo/NetPBMWriter + + cpp/CMakeLists.txt | 1 - + cpp/Makefile.am | 2 - + cpp/PNMWriter.cc | 119 + -------------------------------------------------- + cpp/PNMWriter.h | 43 ------------------ + cpp/poppler-image.cpp | 14 +++--- + 5 files changed, 6 insertions(+), 173 deletions(-) + +commit a87a11ee6bbd0f5707a3ac34ac2b9cc79f4e92d0 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu Aug 29 22:42:34 2013 +0930 + + pdfimages: support cmyk tiff output + + If -tiff is specified, CMYK images will be written as CMYK TIFF files + instead of converting to RGB. If both -png and -tiff are specified (as + is the case with the -all option), CMYK images are written as TIFF and + all other types as PNG. + + utils/ImageOutputDev.cc | 32 +++++++++++++++++++++++++++++++- + utils/ImageOutputDev.h | 3 ++- + utils/pdfimages.1 | 13 ++++++++----- + utils/pdfimages.cc | 3 ++- + 4 files changed, 43 insertions(+), 8 deletions(-) + +commit 63da26f8fb0b2b5ffaa127762d4e36d995c482ee +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Tue Aug 27 20:40:29 2013 +0200 + + resolve copy&paste error + + poppler/GfxState.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 563da2d375c003478d398897796ecbf45ce03482 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 26 22:33:10 2013 +0200 + + 0.24.1 + + CMakeLists.txt | 2 +- + NEWS | 23 +++++++++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 6 files changed, 28 insertions(+), 5 deletions(-) + +commit 2c73f1ea9116172692d8350cb7adf1b5376f795c +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 26 21:50:51 2013 +0200 + + Fix typo + + qt5/src/poppler-qt5.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit f58e9b64d5cf62906876c5c0f8da0f3c2c6c2bac +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 26 00:27:59 2013 +0200 + + Some more files Adrian has changed + + goo/PNGWriter.h | 2 +- + utils/HtmlOutputDev.cc | 2 +- + utils/pdftocairo.cc | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +commit 16da389c61c495111a5a49f62539a423a0655c28 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Aug 26 07:50:51 2013 +0930 + + fix typo in pdfimages.1 + + utils/pdfimages.1 | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 56c0d4f3a231dca141c06493b50ab25959b5b15c +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Aug 26 07:47:46 2013 +0930 + + fix typo in pdfimages.1 + + utils/pdfimages.1 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit af4f2b775946815b572622bf4c4d42ad3aea1141 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Aug 24 21:25:51 2013 +0930 + + pdfimages: Add -all option to write all image in their native format + + utils/pdfimages.1 | 4 ++++ + utils/pdfimages.cc | 23 +++++++++++++++++------ + 2 files changed, 21 insertions(+), 6 deletions(-) + +commit 25e96b6ddbbe54a75ddb97d2e235c1bd6033fe79 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Aug 21 22:22:28 2013 +0930 + + pdfimages: support ccitt output + + poppler/Stream.h | 5 +++++ + utils/ImageOutputDev.cc | 35 +++++++++++++++++++++++++++++++++++ + utils/ImageOutputDev.h | 4 ++++ + utils/pdfimages.1 | 39 ++++++++++++++++++++++++++++++++++++++- + utils/pdfimages.cc | 4 ++++ + 5 files changed, 86 insertions(+), 1 deletion(-) + +commit 086413263cb63a24d9492fbe534fdcc34b45951a +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Aug 18 20:37:01 2013 +0930 + + pdfimages: support JBIG2 output + + poppler/JBIG2Stream.h | 1 + + utils/ImageOutputDev.cc | 25 +++++++++++++++++++++++++ + utils/ImageOutputDev.h | 4 ++++ + utils/pdfimages.1 | 13 ++++++++----- + utils/pdfimages.cc | 4 ++++ + 5 files changed, 42 insertions(+), 5 deletions(-) + +commit 2845ebabd00a2755549b8db436e78a3e0e0c0713 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Aug 18 20:07:31 2013 +0930 + + pdfimages: add support for writing JPEG2000 files + + utils/ImageOutputDev.cc | 4 ++++ + utils/ImageOutputDev.h | 4 ++++ + utils/pdfimages.1 | 12 ++++++++---- + utils/pdfimages.cc | 4 ++++ + 4 files changed, 20 insertions(+), 4 deletions(-) + +commit 2021c8ffcb36432049c4305e85ced2ae139086f3 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Aug 18 17:29:00 2013 +0930 + + pdfimages: add support for png and tiff output + + utils/ImageOutputDev.cc | 67 + ++++++++++++++++++++++++++++++++++++++++++++++--- + utils/ImageOutputDev.h | 17 +++++++++++-- + utils/pdfimages.1 | 22 ++++++++++------ + utils/pdfimages.cc | 19 +++++++++++--- + 4 files changed, 110 insertions(+), 15 deletions(-) + +commit 8f466775c77b09a7114c688004317e6db05bcd3f +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Aug 18 16:08:02 2013 +0930 + + Change PNGWriter monochrome format to be 8 pixels/byte + + to be consistent with TiffWriter and NetPBMWriter + + goo/PNGWriter.cc | 4 ---- + goo/PNGWriter.h | 2 +- + utils/HtmlOutputDev.cc | 31 +++++++++++++++++++------------ + utils/ImageOutputDev.cc | 9 ++++++--- + utils/pdftocairo.cc | 2 +- + 5 files changed, 27 insertions(+), 21 deletions(-) + +commit e53aec2c61ba42cf0635dc05f8e27e3503c1eaac +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Aug 18 15:50:39 2013 +0930 + + Refactor ImageOutputDev to facilitate adding more output formats + + - Move PPM/PBM code into a NetPBMWriter class so PNGWriter and + TiffWritersupport be added. + + - Create generic WriteRawIMage function for writing jpeg files so + support for jpeg2000/jbig2 can be added. + + CMakeLists.txt | 1 + + goo/Makefile.am | 2 + + goo/NetPBMWriter.cc | 84 ++++++++++++++++ + goo/NetPBMWriter.h | 52 ++++++++++ + utils/ImageOutputDev.cc | 261 + +++++++++++++++++++++--------------------------- + utils/ImageOutputDev.h | 15 +-- + 6 files changed, 262 insertions(+), 153 deletions(-) + +commit 0ca0fcc9f536a57365048914cd8a8cc3eb5ed4fd +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Aug 17 15:24:43 2013 +0930 + + pdfimages: fix bug in -list output + + Images of type /ImageMask should have type 'stencil'. + + utils/ImageOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit f8ee5a931c795013d17f73f083b6e6f9a683d061 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Aug 17 15:17:11 2013 +0930 + + pdfimages: print size, ratio, and ppi + + utils/ImageOutputDev.cc | 100 + ++++++++++++++++++++++++++++++++++++++++++++---- + utils/pdfimages.1 | 12 ++++++ + utils/pdfimages.cc | 2 +- + 3 files changed, 106 insertions(+), 8 deletions(-) + +commit b5321c4f40fb56b10f75c14c5c955c5775cf2ef9 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Aug 25 20:13:12 2013 +0200 + + use getCMYK/DeviceNLine in CMYK mode if available + + Second part of bug 66928 + + poppler/GfxState.cc | 310 + ++++++++++++++++++++++++++++++++++++++++++++- + poppler/GfxState.h | 32 ++++- + poppler/SplashOutputDev.cc | 28 ++-- + splash/SplashTypes.h | 2 - + 4 files changed, 355 insertions(+), 17 deletions(-) + +commit d006ac567e59e82c4c6cb42c5e429a4aa516ac0b +Merge: d391af7 ed3585e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 25 19:36:33 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.24' + +commit ed3585efc8b259cb065eac361a6a499f9f26851f +Author: William Bader <williambader@hotmail.com> +Date: Sun Aug 25 19:31:11 2013 +0200 + + Fix pdftops -eps -level1sep rendering of a file + + Since 8fb243bf11a979af8bfa36427436940706c9f71d we have + case splashModeXBGR8: + + cSrcNonIso[3] = 255; + and that means splashModeDeviceN8 and splashModeCMYK8 can't + skip their breaks anymore otherwise the cSrcNonIso[3] gets + overwritten + + Bug #68321 + + splash/Splash.cc | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +commit d391af7ea63c4bc884bb81895aea0cdd8f8b282a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Aug 24 14:03:49 2013 +0200 + + Update copyrights + + poppler/Annot.cc | 1 + + poppler/Annot.h | 1 + + poppler/Catalog.cc | 2 ++ + poppler/Catalog.h | 2 ++ + poppler/Form.cc | 2 +- + poppler/Form.h | 1 + + poppler/Page.cc | 1 + + poppler/Page.h | 1 + + utils/pdfinfo.cc | 1 + + 9 files changed, 11 insertions(+), 1 deletion(-) + +commit a47b7f853174d6101f2b882a2db1a7dc95b33293 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Aug 3 10:28:20 2013 +0930 + + Add pdfinfo option to print out javascript + + poppler/Catalog.h | 1 + + utils/JSInfo.cc | 164 + +++++++++++++++++++++++++++++++++++++++++------------- + utils/JSInfo.h | 12 +++- + utils/pdfinfo.1 | 3 + + utils/pdfinfo.cc | 10 ++++ + 5 files changed, 151 insertions(+), 39 deletions(-) + +commit 8f7155e7e3180bb1966a5e7df6af6acdd479939b +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Aug 3 09:05:21 2013 +0930 + + pdfinfo: indicate if pdf contains javascript + + poppler/Annot.cc | 27 ++++++++++ + poppler/Annot.h | 8 +++ + poppler/Catalog.cc | 26 +++++++++ + poppler/Catalog.h | 12 +++++ + poppler/Form.cc | 4 ++ + poppler/Form.h | 2 + + poppler/Page.cc | 20 +++++++ + poppler/Page.h | 10 +++- + utils/CMakeLists.txt | 4 ++ + utils/JSInfo.cc | 145 + +++++++++++++++++++++++++++++++++++++++++++++++++++ + utils/JSInfo.h | 50 ++++++++++++++++++ + utils/Makefile.am | 4 ++ + utils/pdfinfo.1 | 3 ++ + utils/pdfinfo.cc | 8 +++ + 14 files changed, 322 insertions(+), 1 deletion(-) + +commit c2453fc1307ebb222747f976e1311ecc5e99abfa +Merge: 3bb8c2e 70298a0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 20 19:53:17 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.24' + +commit 70298a021657a72ae80389687a86247144e6d6b6 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Tue Aug 20 19:46:01 2013 +0200 + + Don't copy not needed bitmap + + Speeds up rendering of fixes from bug 67105 + As example one file is down from 130s to 6.5s + + poppler/SplashOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 3bb8c2e34039cf473bf72ed9dab55664deab3ab7 +Merge: 71c1d16 fc78330 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 20 00:41:13 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.24' + +commit fc78330072b9771fa39d21896703adb4836e5398 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 20 00:37:56 2013 +0200 + + use getRGBLine images if available + + Speeds up greatly files from bug #66928 + + E.g. some file went from 21s to 2s in my computer + + poppler/SplashOutputDev.cc | 30 +++++++++++++++++++----------- + 1 file changed, 19 insertions(+), 11 deletions(-) + +commit 71c1d162477a243db07b62ef3c056a2946f8986e +Merge: 7d1de78 678c767 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 18 16:41:20 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.24' + +commit 7d1de78ad79162217ee0ca6c2e99ce51017a327d +Merge: 7e0d969 fbea224 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 18 16:40:34 2013 +0200 + + Merge commit 'origin/poppler-0.24~1' + + This is merging the revert commits with the "ours" strategy, so + it's virtually + doing nothing other than making the stable branch mergeable again + to master + +commit 678c767584fa80620cc58a1d8a913cb3473209d4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 18 16:19:27 2013 +0200 + + Fix crash in 1026.asan.0.42.pdf + + We were not checking that bitmapOff was in bounds + + splash/Splash.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit fbea2241cccdde0106d2c34592b6ddda28a8d848 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Aug 17 01:32:51 2013 +0200 + + Revert "Tagged-PDF: Accessors in Catalog for the MarkInfo dictionary" + + This reverts commit 402ee8b4e31630a42a0a38db1d39164cc5789f3c. + + No clue how this ended up in the stable branch + + poppler/Catalog.cc | 45 --------------------------------------------- + poppler/Catalog.h | 10 ---------- + 2 files changed, 55 deletions(-) + +commit 6d2771b8a8c0cb0f2288d0900fea3c9edc3dd172 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Aug 17 01:32:38 2013 +0200 + + Revert "pdfinfo: Use Catalog::getMarkInfo() to show mark info + properties" + + This reverts commit 73cca518c479594e26605196d54b429fbf42dcdc. + + No clue how this ended up in the stable branch + + utils/pdfinfo.cc | 8 ++------ + 1 file changed, 2 insertions(+), 6 deletions(-) + +commit 7e0d969dc2439637ab16e609df8223504316f87d +Merge: 6efc0c7 ef64206 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Aug 17 01:13:30 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.24' + +commit ef6420656c7b88eb22a63ec2cb3e504e0bda0384 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Aug 17 01:11:37 2013 +0200 + + Fix jpeg image export + + Use same logic than the one used in ImageOutputDev + Bug #48270 + + utils/HtmlOutputDev.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 681f52a572b08c068cb376e5b2dc8a31676aad07 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Aug 16 23:58:44 2013 +0200 + + Fix exit(1) in 1026.asan.0.42.pdf + + The main crash in discussion with Thomas + + splash/Splash.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 9f4d7796589e4c9c1645fbbcf0cfabd79a71bde9 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Thu Aug 8 20:33:54 2013 +0200 + + use copyString where memory is freed with gfree + + Bug #67666 + + poppler/Annot.cc | 2 +- + poppler/Dict.cc | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 73cca518c479594e26605196d54b429fbf42dcdc +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Thu Apr 25 09:52:56 2013 +0300 + + pdfinfo: Use Catalog::getMarkInfo() to show mark info properties + + utils/pdfinfo.cc | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +commit 402ee8b4e31630a42a0a38db1d39164cc5789f3c +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Thu Apr 25 09:52:56 2013 +0300 + + Tagged-PDF: Accessors in Catalog for the MarkInfo dictionary + + poppler/Catalog.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++ + poppler/Catalog.h | 10 ++++++++++ + 2 files changed, 55 insertions(+) + +commit 6efc0c7ad97a82064a1e2c47e0b063b606e56bb7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Aug 16 23:31:54 2013 +0200 + + Remove unused xref member + + poppler/OptionalContent.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit cb5160aa74f64b78a20aaed4b89fead850b42e9b +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Aug 16 23:31:17 2013 +0200 + + Remove usnused objectNumberFirst member + + poppler/Hints.h | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit a642aad68733c25f4055c268d691eedcf4e14a22 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Aug 16 23:30:50 2013 +0200 + + PNGWriterPrivate is actually a struct not a class + + goo/PNGWriter.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 31947d413eae115acc147c33fc55b8ab4adccd91 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Tue Aug 13 19:39:30 2013 +0200 + + pdftoppm: Add thinlinemode option setting + + utils/pdftoppm.1 | 12 ++++++++++++ + utils/pdftoppm.cc | 17 +++++++++++++++-- + 2 files changed, 27 insertions(+), 2 deletions(-) + +commit 8a1740b0b6ee4b217ecbe9d0046e4afa491e9f17 +Merge: b27588c c3f953d +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 12 22:47:44 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.24' + +commit c3f953dc87f83ac726f99cb8f1f959c486098391 +Author: Yury G. Kudryashov <urkud.urkud@gmail.com> +Date: Sat Aug 10 21:43:57 2013 +0300 + + Fix a typo + + qt4/src/poppler-qt4.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit b27588c4c946ef4f9a62248fbead4dffcb60b4d1 +Author: Yury G. Kudryashov <urkud.urkud@gmail.com> +Date: Mon Aug 12 22:42:13 2013 +0200 + + Fix indentation + + utils/pdftotext.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit b8b5773386ee4f57e72c2b867421cdff8a2eab5a +Merge: 5f9d385 62d079b +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 8 20:47:05 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.24' + +commit 62d079b40a2f816f59cc533b1624ea57458331f3 +Author: Yury G. Kudryashov <urkud.urkud@gmail.com> +Date: Thu Aug 8 20:45:08 2013 +0200 + + Fix `pdftotext -bbox in.pdf -` + + Print body text to stdout if invoked as above. + + Bug #45163 + + utils/pdftotext.cc | 15 ++++++--------- + 1 file changed, 6 insertions(+), 9 deletions(-) + +commit 5f9d385dbec3148614b84ae24cae47177e18dbfc +Merge: af450a8 86dbc5f +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 8 20:41:25 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.24' + +commit 86dbc5f6f850ba3919bed9979386e5a4d0e7dba3 +Author: Yury G. Kudryashov <urkud.urkud@gmail.com> +Date: Thu Aug 8 20:39:30 2013 +0200 + + pdfdetach: don't mention xpdfrc + + - drop -cfg command line argument; the old code passed its value to + GlobalParams constructor which is the data dir, not a cfg file + - remove corresponding lines from pdfdetach.1 + - fix '-enc' documentation in pdfdetach.1 + + utils/pdfdetach.1 | 23 +++-------------------- + utils/pdfdetach.cc | 6 ++---- + 2 files changed, 5 insertions(+), 24 deletions(-) + +commit af450a885ede5a3eac1a12734310722963764d83 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Thu Aug 8 20:33:54 2013 +0200 + + use copyString where memory is freed with gfree + + Bug #67666 + + poppler/Annot.cc | 2 +- + poppler/Dict.cc | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 030ee12875a562f5976c5569d5c76783aadf89bd +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Thu Apr 25 09:52:56 2013 +0300 + + pdfinfo: Use Catalog::getMarkInfo() to show mark info properties + + utils/pdfinfo.cc | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +commit 9a232273988c0d2fd752dc2016e5111227ae6646 +Author: Adrian Perez de Castro <aperez@igalia.com> +Date: Thu Apr 25 09:52:56 2013 +0300 + + Tagged-PDF: Accessors in Catalog for the MarkInfo dictionary + + poppler/Catalog.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++ + poppler/Catalog.h | 10 ++++++++++ + 2 files changed, 55 insertions(+) + +commit 2724a7b9f723789491b4991ce7fe0cfa3e5488c3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jul 30 09:36:44 2013 +0200 + + glib-demo: Remove GTK_DISABLE_DEPRECATED compilation flag + + Deprecations are now compile warnings, there's no reason to make them + fatal. + + glib/demo/Makefile.am | 1 - + 1 file changed, 1 deletion(-) + +commit ef9d861486d54fb3dcf7b8bca01bd44c3b3361a9 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jul 30 09:36:44 2013 +0200 + + glib-demo: Remove GTK_DISABLE_DEPRECATED compilation flag + + Deprecations are now compile warnings, there's no reason to make them + fatal. + + glib/demo/Makefile.am | 1 - + 1 file changed, 1 deletion(-) + +commit eac752dc25942439de3e1c7a4ff815500a41dd2a +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 29 19:11:55 2013 +0200 + + 0.24.0 + + CMakeLists.txt | 6 +++--- + NEWS | 7 +++++++ + configure.ac | 4 ++-- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 7 files changed, 16 insertions(+), 9 deletions(-) + +commit 892433a068a8a11c09a7c4f57c5fc941747c4453 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 29 19:08:10 2013 +0200 + + Update Ed's copyright + + poppler/TextOutputDev.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 4637b1581286381c3d1c6963828d9cd8afc5b9e0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 29 01:08:06 2013 +0200 + + Make some pdftops conversions *much* faster + + For example: http://ev.kde.org/resources/expense_report.pdf + + Without this patch it seems "infinite", which this patch it's a + few seconds + + The change: Instead of just remembering in xobjStack the set of + XObjects (and Patterns, + the variable name was 'wrong') we are currently setting up (i.e. the + current chain), we + remember all of them. + + This has passed the pdf->ps regression test without a single issue + + poppler/PSOutputDev.cc | 42 ++++++++++-------------------------------- + poppler/PSOutputDev.h | 6 +++--- + 2 files changed, 13 insertions(+), 35 deletions(-) + +commit e04287f2682e46831c04e0ef8d60411f521a2572 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 29 00:55:43 2013 +0200 + + Fallback to 1x1 bitmap If we fail to create the corrent one + + poppler/SplashOutputDev.cc | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit fe5ff20cb93a70fa1650ef5e00b67e35de20f0ca +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 29 00:54:07 2013 +0200 + + Initialize t3FillColorOnly + + poppler/PSOutputDev.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 19930d9f104b63070dcd7636758eb8b90a86fc0d +Author: Ed Catmur <ed@catmur.co.uk> +Date: Sun Jul 21 11:07:00 2013 +0200 + + TextOutputDev: Do not draw ligatures more than once when selected + + When the selection covers a ligature presentation form where a single + character code corresponds to multiple Unicode codepoints, the + glyph for + the ligature is drawn multiple times, once for each Unicode character. + + https://bugs.freedesktop.org/show_bug.cgi?id=9001 + + poppler/TextOutputDev.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 6b451b2d3f785c28d98907ae338d58380db518d2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 19 02:55:29 2013 +0200 + + 0.23.4 + + CMakeLists.txt | 4 +-- + NEWS | 8 ++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + gtk-doc.make | 70 + +++++++++++++++++++++++++++++++----------------- + m4/gtk-doc.m4 | 6 ++++- + poppler/CairoOutputDev.h | 2 +- + poppler/Makefile.am | 2 +- + poppler/TextOutputDev.cc | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 11 files changed, 67 insertions(+), 35 deletions(-) + +commit 6cf43442e38c501b49293a28f38e06ab143852c6 +Author: Ed Catmur <ed@catmur.co.uk> +Date: Thu Jul 18 10:34:29 2013 +0200 + + TextOutputDev: clip the selected text rendering to the selection box + + Sometimes with italic text or text containing ligatures, part of the + glyph falls outside the selection box. By clipping to the selection + box + we avoid drawing the whole glyph with the selection color. + + https://bugs.freedesktop.org/show_bug.cgi?id=66983 + + poppler/TextOutputDev.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 269b3f3d572a15f1007f8cc84f758b1a293ef8af +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Jul 8 20:19:30 2013 +0200 + + build: Make -lpthread take preference over -pthread + + This makes libpoppler link to pthreads and fixes runtime error due to + unresolved pthread symbols when running some of the utils and tests. + + m4/ax_pthread.m4 | 2 +- + test/Makefile.am | 6 ++++-- + utils/Makefile.am | 4 +++- + 3 files changed, 8 insertions(+), 4 deletions(-) + +commit 40f857d27930aa002a99c96f3892c5e240e7ecb5 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Jul 8 19:55:10 2013 +0200 + + m4: Replace old acx_pthread.m4 with new one ax_pthread.m4 + + configure.ac | 2 +- + m4/acx_pthread.m4 | 280 ----------------------------------------------- + m4/ax_pthread.m4 | 317 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 318 insertions(+), 281 deletions(-) + +commit 44b7070aa713b2e20eb97b868000d432e2f8504e +Author: Pino Toscano <pino@kde.org> +Date: Mon Jul 8 19:42:15 2013 +0200 + + cmake: improve linking with pthreads + + Use the CMake-provided variable instead of hardcoding -lpthread. + + CMakeLists.txt | 6 +++--- + utils/CMakeLists.txt | 2 +- + 2 files changed, 4 insertions(+), 4 deletions(-) + +commit 69c281fdcf23520151c0eb5471a4259c73fa1273 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jul 7 11:51:27 2013 +0200 + + cairo: Fix the bounding box of images saved in CairoImageOutputDev + + We were using the size of the original image instead of the rendered + size and asuming the scales were always positive. + + poppler/CairoOutputDev.cc | 145 + ++++++++++++++++++---------------------------- + poppler/CairoOutputDev.h | 5 +- + 2 files changed, 59 insertions(+), 91 deletions(-) + +commit 759e0266b36c4ea9f66912f1e53ed6392dbfd6da +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jul 2 00:47:13 2013 +0200 + + News for 0.23.3 + + forgot to add them to the tarball, oh well + + NEWS | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +commit df1fe9dc7ade5228e37c16c6f0c9a2d4890fdc90 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jul 2 00:33:04 2013 +0200 + + 0.23.3 + + CMakeLists.txt | 4 ++-- + Makefile.am | 2 +- + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 7 files changed, 8 insertions(+), 8 deletions(-) + +commit df9d4fee17adfe003c822175b6921a3cd93675f6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 1 21:04:10 2013 +0200 + + Update copyrights + + poppler/Annot.cc | 2 +- + poppler/Annot.h | 2 +- + poppler/Page.cc | 2 +- + poppler/TextOutputDev.cc | 2 +- + poppler/TextOutputDev.h | 2 +- + qt5/src/poppler-annotation.cc | 2 +- + qt5/src/poppler-annotation.h | 2 +- + qt5/src/poppler-document.cc | 2 +- + qt5/src/poppler-link.cc | 2 +- + qt5/src/poppler-qt5.h | 2 +- + 10 files changed, 10 insertions(+), 10 deletions(-) + +commit 67129e9db88e8332907407f14d3e09ee5c49e274 +Author: Jason Crain <jason@aquaticape.us> +Date: Mon Jul 1 02:24:47 2013 -0500 + + Check for NULL in Page::getResourceDictCopy + + poppler/Page.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit c376559bc412e90204162bb4b2d20cd586db70c1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jun 30 13:14:07 2013 +0200 + + annots: Invalidate the appearance stream when annot properties change + + Make invalidateAppearance() protected and only call it when properties + that affect the appearance stream are updated. Remove all calls to + invalidateAppearance() from qt frontend, this is now handled by + the core + and fixes the appearance stream regeneration in the glib frontend too. + + poppler/Annot.cc | 36 ++++++++++++++++++++++++++++++++++++ + poppler/Annot.h | 10 ++++++---- + qt4/src/poppler-annotation.cc | 34 ---------------------------------- + qt5/src/poppler-annotation.cc | 34 ---------------------------------- + 4 files changed, 42 insertions(+), 72 deletions(-) + +commit c746e8b38e821d1ebeaf52c4c816515bc3ddaaf6 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jun 30 11:44:59 2013 +0200 + + annots: Remove unused variable + + poppler/Annot.cc | 1 - + 1 file changed, 1 deletion(-) + +commit 7d9d5d2518f7760e6a4317a358040ddd9164fdef +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jun 30 11:40:15 2013 +0200 + + annots: Do not update AP and AS entries if they are not present when + invaliding the appaearance stream + + poppler/Annot.cc | 17 ++++++++++++++--- + 1 file changed, 14 insertions(+), 3 deletions(-) + +commit 347b53f7fca644564724c230fe6c0dcbffa0d6f9 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jun 30 11:23:54 2013 +0200 + + annots: do not set the default appearance state when invalidating + appearances + + We are setting the default appareance state to Off and then we are + updating AS dictionary to NULL in the XRef. The appearance state + is only + required when there's more than once appearance stream, but when + invalidating the apperance we remove all streams. + + poppler/Annot.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit b5e9941c145fc99e03a28d92a50840638895908d +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 1 00:32:51 2013 +0200 + + Fix crash on malformed doc + + Where the Colorants dictionary values are not arrays + Document can be found on KDE bug #319925 + + poppler/GfxState.cc | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +commit 19f8a88bba6022b8172477e6f52dfd36b2fc5e92 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Thu Mar 7 00:20:15 2013 +0100 + + qt5: Free some temporary memory in + TextAnnotationPrivate::createNativeAnnot + + There's no need to keep this buffer around after it has been flushed + + qt5/src/poppler-annotation.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 8bac4d1e43ce9a4c66fddc8430d7bed2d9aabba1 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Tue Jun 25 20:09:00 2013 +0200 + + qt5: Some documentation about annotations + + * Removed incorrect hint "Use uniqueName to test for Annotation + equality": uniqueNames are optional and we don't actually guarantee + uniqueness + * Added "How to add annotations" and "FixedRotation flag specifics" + sections in the Annotation class page + * Added links from enum Annotation::SubType items to actual subclasses + * Added documentation for annotation flags that are known to work + * Added "see also" links between annotation flag and boundary + setters/getters + * Added warning on Annotation::setPopup to tell that it's currently + not + implemented + + qt5/src/poppler-annotation.h | 143 + ++++++++++++++++++++++++++++++++++++++++--- + 1 file changed, 135 insertions(+), 8 deletions(-) + +commit 1d5fe3f20189fd3928121e954bcc8fa7278b39fb +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Mar 2 19:06:49 2013 +0100 + + qt5: FixedRotation annotations' coordinate conversion + + FixedRotation(=flagNoRotate) annotations use a different coordinate + system than regular annotations. This patch implements transparent + conversion so that qt5 clients don't notice the difference. + + Important! When dealing with FixedRotation annotations, poppler-qt5 + clients will need to set geometry-related annotation properties in + the following order: + 1) flags (because we need to know if this is a FixedRotation + annotation or not) + 2) boundary (because we need to know what the topleft corner is, + so that we can construct the conversion matrix) + 3) anything else + + This requirement will be documented in the next patch + + qt5/src/poppler-annotation-private.h | 7 ++- + qt5/src/poppler-annotation.cc | 111 + +++++++++++++++++++++++++++-------- + 2 files changed, 92 insertions(+), 26 deletions(-) + +commit ab130c91492765f8be29ed112dd2e2e6f665641b +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Mar 2 00:55:58 2013 +0100 + + core: Remove geometry-related arguments from annotation constructors + + Removed arguments from annotation constructors related to the geometry + of the annotation. This change will make it easier to support creating + annotations with flag NoRotate in the next patch (because no special + cases will be needed: coordinate conversion code will be able + to always + assume that the underlying annotation object already exists). + + Data that used to be taken from these arguments is now replaced + by dummy + values, which can be modified using appropriate setter methods after + the annotation object is created. + + Affected annotation types: + - AnnotLine + - AnnotTextMarkup + - AnnotPolygon + - AnnotInk + + qt5/src/poppler-annotation.cc | 34 ++++++++++++++++++---------------- + 1 file changed, 18 insertions(+), 16 deletions(-) + +commit 35cfb6914e1be4c5eda2f355900b1a0a1fa69d19 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Fri Feb 15 12:24:18 2013 +0100 + + poppler_qt5viewer: Add combobox to select rotation + + qt5/demos/navigationtoolbar.cpp | 15 +++++++++++++++ + qt5/demos/navigationtoolbar.h | 4 ++++ + qt5/demos/pageview.cpp | 24 +++++++++++++++++++++++- + qt5/demos/pageview.h | 3 +++ + qt5/demos/viewer.cpp | 2 ++ + 5 files changed, 47 insertions(+), 1 deletion(-) + +commit de2a93c0bc6e92a95c687796f59780c998b90ca4 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Thu Mar 7 00:20:15 2013 +0100 + + qt4: Free some temporary memory in + TextAnnotationPrivate::createNativeAnnot + + There's no need to keep this buffer around after it has been flushed + + qt4/src/poppler-annotation.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 738b0b4fedaa2b2b28ea1c11622dfd880180d1c9 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Thu Mar 7 20:50:52 2013 +0100 + + qt4: Some documentation about annotations + + * Removed incorrect hint "Use uniqueName to test for Annotation + equality": uniqueNames are optional and we don't actually guarantee + uniqueness + * Added "How to add annotations" and "FixedRotation flag specifics" + sections in the Annotation class page + * Added links from enum Annotation::SubType items to actual subclasses + * Added documentation for annotation flags that are known to work + * Added "see also" links between annotation flag and boundary + setters/getters + * Added warning on Annotation::setPopup to tell that it's currently + not + implemented + + qt4/src/poppler-annotation.h | 143 + ++++++++++++++++++++++++++++++++++++++++--- + 1 file changed, 135 insertions(+), 8 deletions(-) + +commit cf950a2b7e8278e70719c67b441b0d324ffd0399 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Mar 2 19:06:49 2013 +0100 + + qt4: FixedRotation annotations' coordinate conversion + + FixedRotation(=flagNoRotate) annotations use a different coordinate + system than regular annotations. This patch implements transparent + conversion so that qt4 clients don't notice the difference. + + Important! When dealing with FixedRotation annotations, poppler-qt4 + clients will need to set geometry-related annotation properties in + the following order: + 1) flags (because we need to know if this is a FixedRotation + annotation or not) + 2) boundary (because we need to know what the topleft corner is, + so that we can construct the conversion matrix) + 3) anything else + + This requirement will be documented in the next patch + + poppler/Annot.cc | 8 +++ + poppler/Annot.h | 2 + + qt4/src/poppler-annotation-private.h | 7 ++- + qt4/src/poppler-annotation.cc | 111 + +++++++++++++++++++++++++++-------- + 4 files changed, 102 insertions(+), 26 deletions(-) + +commit 4b13085568df09d8b75099f6a5438f025a028fd5 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Mar 2 00:55:58 2013 +0100 + + core: Remove geometry-related arguments from annotation constructors + + Removed arguments from annotation constructors related to the geometry + of the annotation. This change will make it easier to support creating + annotations with flag NoRotate in the next patch (because no special + cases will be needed: coordinate conversion code will be able + to always + assume that the underlying annotation object already exists). + + Data that used to be taken from these arguments is now replaced + by dummy + values, which can be modified using appropriate setter methods after + the annotation object is created. + + Affected annotation types: + - AnnotLine + - AnnotTextMarkup + - AnnotPolygon + - AnnotInk + + poppler/Annot.cc | 56 + +++++++++++++------------------------------ + poppler/Annot.h | 9 ++++--- + qt4/src/poppler-annotation.cc | 34 +++++++++++++------------- + 3 files changed, 39 insertions(+), 60 deletions(-) + +commit 5923cfb5f7e3a0703de17e21f4952f92a44f3c14 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Fri Feb 15 12:24:18 2013 +0100 + + poppler_qt4viewer: Add combobox to select rotation + + qt4/demos/navigationtoolbar.cpp | 15 +++++++++++++++ + qt4/demos/navigationtoolbar.h | 4 ++++ + qt4/demos/pageview.cpp | 24 +++++++++++++++++++++++- + qt4/demos/pageview.h | 3 +++ + qt4/demos/viewer.cpp | 2 ++ + 5 files changed, 47 insertions(+), 1 deletion(-) + +commit 74ea15cc454f31b772e71b3525b71045dbfa5527 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Tue Jun 25 19:56:20 2013 +0200 + + core: Support for rendering annotations with flagNoRotate + + Gfx::drawAnnot now makes a counter-rotation if flagNoRotate is set + + poppler/Annot.cc | 55 + ++++++++++++++++++++++++++++++++++++------------------- + poppler/Annot.h | 3 ++- + poppler/Gfx.cc | 41 +++++++++++++++++++++++++++++++++++++---- + poppler/Gfx.h | 3 ++- + 4 files changed, 77 insertions(+), 25 deletions(-) + +commit 2639957ba78defd2ab6282679375fb7969bad21f +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Jun 26 23:12:40 2013 +0200 + + Do not crash in page::removeAnnot if there are non-Ref entries + in /Annots + + poppler/Page.cc | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +commit ae016aa263c218fbfbd607cc92feac1013348c7e +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 26 11:33:55 2013 +0200 + + Fix qt5 found/not found logic + + CMakeLists.txt | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit e27c1057caf4d878a0dc43c92c9e0b565db8fe40 +Merge: c55b577 ee8cfbc +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 25 19:17:13 2013 +0200 + + Merge remote-tracking branch 'origin/qt5' + +commit c55b577ce69ad4bb69f5261b3e120e92c9fdb3d0 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jun 25 10:01:38 2013 +0200 + + glib: Use TextPage::getSelectionWords to build text layout and + attributes + + This way we can make sure that the list of words used in + poppler_page_get_text_layout and poppler_page_get_text_attributes + is the + same that the one used in poppler_page_get_text. This fixes the + mismatch + between the number of characters in the text returned by + poppler_page_get_text and the number of characters returned by + poppler_page_get_text_layout in some documents. + + glib/poppler-page.cc | 168 + +++++++++++++++++++++++++++------------------------ + 1 file changed, 90 insertions(+), 78 deletions(-) + +commit fc534f571315c064005515c19d7d70ad3af1563e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jun 25 10:05:01 2013 +0200 + + TextOutputDev: add a method to TextPage to get the selection as a + list of words + + Returns a list of lines of words. + + poppler/TextOutputDev.cc | 36 ++++++++++++++++++++++++++++++++++++ + poppler/TextOutputDev.h | 4 ++++ + 2 files changed, 40 insertions(+) + +commit a924246b7534e86165f8e9ab6c60d56b73a17b94 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jun 25 09:57:48 2013 +0200 + + TextOutputDev: simplify the text selection dumper + + Build a list of lines of words and don't try to format the text when + detecting tables, simply add the words and lines in the right order. + + poppler/TextOutputDev.cc | 200 + ++++++++++++++++++++++------------------------- + 1 file changed, 92 insertions(+), 108 deletions(-) + +commit c849094a2daf896d085937adff1f7659a09da062 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Jun 24 18:29:11 2013 +0200 + + TextOutputDev: Move TextSelection class from TextSelectionPainter + to TextSelectionVisitor + + So that it can be used by other TextSelectionVisitor implementations. + Also renamed it as TextWordSelection since it contains a word + selection. + + poppler/TextOutputDev.cc | 35 ++++++++++++++++++----------------- + 1 file changed, 18 insertions(+), 17 deletions(-) + +commit b3ff3f2c3e131556d2b27cbe52f0ddbbb4820c19 +Author: Jason Crain <jason@aquaticape.us> +Date: Thu Jun 20 21:47:13 2013 -0500 + + Draw glyphs after selection background + + When multiple lines of text are selected, TextSelectionPainter will + draw selections over each other, hiding the previous line with the + selection background of the current line. This patch changes + TextSelectionPainter so that glyphs are drawn only after the entire + background is drawn. + + https://bugs.freedesktop.org/show_bug.cgi?id=65989 + + poppler/TextOutputDev.cc | 109 + ++++++++++++++++++++++++++++++----------------- + 1 file changed, 69 insertions(+), 40 deletions(-) + +commit ee8cfbc78fe9de109abbe0727a738870f6027a73 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 18 23:20:01 2013 +0200 + + Fix indent + + qt5/src/poppler-optcontent.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 9d0a5b6afb25a1273504383e108bdb95ca82f099 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 18 23:19:30 2013 +0200 + + Bring changes from the qt4 dir + + qt5/src/Doxyfile | 2 +- + qt5/src/poppler-private.h | 2 +- + qt5/tests/CMakeLists.txt | 1 + + qt5/tests/Makefile.am | 13 +- + qt5/tests/stress-threads-qt5.cpp | 304 + +++++++++++++++++++++++++++++++++++++++ + qt5/tests/test-poppler-qt5.cpp | 2 +- + 6 files changed, 320 insertions(+), 4 deletions(-) + +commit 1adb1ab7aee026e227d25716a4b7be22b19b5b84 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 18 20:50:49 2013 +0200 + + Make it build with autotools + + poppler/ArthurOutputDev.cc | 816 + ------------------------------------------ + poppler/ArthurOutputDev.h | 170 --------- + poppler/Makefile.am | 23 +- + qt4/src/ArthurOutputDev.cc | 816 + ++++++++++++++++++++++++++++++++++++++++++ + qt4/src/ArthurOutputDev.h | 170 +++++++++ + qt4/src/CMakeLists.txt | 2 +- + qt4/src/Makefile.am | 5 +- + qt5/src/ArthurOutputDev.cc | 816 + ++++++++++++++++++++++++++++++++++++++++++ + qt5/src/ArthurOutputDev.h | 170 +++++++++ + qt5/src/CMakeLists.txt | 2 +- + qt5/src/Makefile.am | 5 +- + qt5/src/poppler-optcontent.cc | 2 + + 12 files changed, 1983 insertions(+), 1014 deletions(-) + +commit 93a1c2b768cc419c5bf9b3033bf85fb21326a65a +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 18 00:33:38 2013 +0200 + + If qmake gives us a Qt5 qmake try with qmake4 and qmake-qt4 + + cmake/modules/FindQt4.cmake | 62 + ++++++++++++++++++++++++++++----------------- + 1 file changed, 39 insertions(+), 23 deletions(-) + +commit 7cc33a752ef864b595748ce7724ba553a8e3ba8e +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 17 22:57:56 2013 +0200 + + We are not compiling an executable + + qt5/src/CMakeLists.txt | 1 - + 1 file changed, 1 deletion(-) + +commit 87cfcd41e8e970186c6ce753aa660ef86aca8878 +Author: Granger Anthony <grangeranthony@gmail.com> +Date: Mon Jun 17 09:17:51 2013 +0200 + + Allow to enable Qt5 support only with CMake >= 2.8.8 + + CMakeLists.txt | 26 ++++++++++++++++---------- + qt5/tests/CMakeLists.txt | 1 - + 2 files changed, 16 insertions(+), 11 deletions(-) + +commit b44c70f04758000cf0e049b06cc7864287570f7b +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 17 22:10:05 2013 +0200 + + Bring PIC back to the toplevel, still have linking errors tohugh :-/ + + configure.ac | 1 + + 1 file changed, 1 insertion(+) + +commit be49073f5ce79f56b38197758a5cf1253b972306 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 17 21:50:31 2013 +0200 + + Use qtchooser if available + + configure.ac | 15 ++++++++++++--- + 1 file changed, 12 insertions(+), 3 deletions(-) + +commit b1958228d4bc6793a3606b5e31c61a57b9fac9f5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 17 20:21:08 2013 +0200 + + No distro ships moc-qt5 but make it work in case someone would + + configure.ac | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit 06f45c7177afc67e02985be1a97cd976c530c4ae +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 17 20:04:49 2013 +0200 + + Build fixes + + Fix moc when moc-qt4 is qt4 moc but moc is qt5 one + Do not add -fPIE everywhere, just -fPIC to qt5 + + configure.ac | 10 ++++++---- + qt5/src/Makefile.am | 2 +- + 2 files changed, 7 insertions(+), 5 deletions(-) + +commit cb617c21fba727781f46278f5475b91d528a488b +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 17 18:12:18 2013 +0200 + + Files i forgot + + poppler-qt5-uninstalled.pc.in | 7 +++++++ + poppler-qt5.pc.cmake | 13 +++++++++++++ + poppler-qt5.pc.in | 13 +++++++++++++ + 3 files changed, 33 insertions(+) + +commit 5c521bba427eb163e4b77d936865fbdd0e07faf3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 17 18:12:07 2013 +0200 + + soversion 1 + + qt5/src/CMakeLists.txt | 2 +- + qt5/src/Makefile.am | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 43786964946b4f4c005a0526e16fead3ffa6ba4a +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 17 00:23:31 2013 +0200 + + harmonize spaces + + CMakeLists.txt | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +commit 2e2ea27fe3dc688c87003d170b82451a6a872b0d +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 17 00:22:18 2013 +0200 + + Remove qt4 mentions + + qt5/src/poppler-converter-private.h | 6 +++--- + qt5/src/poppler-embeddedfile-private.h | 2 +- + qt5/src/poppler-form.cc | 2 +- + qt5/src/poppler-form.h | 6 +++--- + qt5/src/poppler-pdf-converter.cc | 2 +- + qt5/src/poppler-private.cc | 4 ++-- + qt5/src/poppler-private.h | 2 +- + qt5/src/poppler-qt5.h | 2 +- + 8 files changed, 13 insertions(+), 13 deletions(-) + +commit e2264ce82af3e971e34930f5307b7c9b43a1e346 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 17 00:19:27 2013 +0200 + + remove deprecated stuff + + qt5/src/poppler-annotation.cc | 19 ++------ + qt5/src/poppler-annotation.h | 18 ------- + qt5/src/poppler-document.cc | 19 -------- + qt5/src/poppler-link.cc | 5 -- + qt5/src/poppler-link.h | 10 ---- + qt5/src/poppler-page.cc | 18 ------- + qt5/src/poppler-qt5.h | 41 ---------------- + qt5/tests/check_fonts.cpp | 21 ++------- + qt5/tests/check_metadata.cpp | 1 - + qt5/tests/check_search.cpp | 107 + ++++++++++++++++++++++-------------------- + 10 files changed, 65 insertions(+), 194 deletions(-) + +commit 21808e203eed46e379954b58b7014998b3836573 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 17 00:03:45 2013 +0200 + + remove commented stuff + + qt5/src/CMakeLists.txt | 1 - + 1 file changed, 1 deletion(-) + +commit 16e7033f18a8da8e27aaed6f63cce156abf8837a +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 17 00:01:27 2013 +0200 + + Initial Qt5 port + + CMakeLists.txt | 20 + + Makefile.am | 18 +- + configure.ac | 66 +- + qt5/.gitignore | 4 + + qt5/CMakeLists.txt | 3 + + qt5/Makefile.am | 1 + + qt5/demos/.gitignore | 4 + + qt5/demos/CMakeLists.txt | 38 + + qt5/demos/Makefile.am | 67 + + qt5/demos/abstractinfodock.cpp | 57 + + qt5/demos/abstractinfodock.h | 48 + + qt5/demos/documentobserver.cpp | 50 + + qt5/demos/documentobserver.h | 50 + + qt5/demos/embeddedfiles.cpp | 82 + + qt5/demos/embeddedfiles.h | 44 + + qt5/demos/fonts.cpp | 72 + + qt5/demos/fonts.h | 43 + + qt5/demos/info.cpp | 72 + + qt5/demos/info.h | 43 + + qt5/demos/main_viewer.cpp | 33 + + qt5/demos/metadata.cpp | 50 + + qt5/demos/metadata.h | 43 + + qt5/demos/navigationtoolbar.cpp | 129 + + qt5/demos/navigationtoolbar.h | 61 + + qt5/demos/optcontent.cpp | 69 + + qt5/demos/optcontent.h | 47 + + qt5/demos/pageview.cpp | 79 + + qt5/demos/pageview.h | 50 + + qt5/demos/permissions.cpp | 66 + + qt5/demos/permissions.h | 43 + + qt5/demos/thumbnails.cpp | 84 + + qt5/demos/thumbnails.h | 48 + + qt5/demos/toc.cpp | 88 + + qt5/demos/toc.h | 43 + + qt5/demos/viewer.cpp | 317 ++ + qt5/demos/viewer.h | 73 + + qt5/src/.gitignore | 9 + + qt5/src/CMakeLists.txt | 54 + + qt5/src/Doxyfile | 1637 ++++++++++ + qt5/src/Mainpage.dox | 85 + + qt5/src/Makefile.am | 73 + + qt5/src/poppler-annotation-helper.h | 198 ++ + qt5/src/poppler-annotation-private.h | 111 + + qt5/src/poppler-annotation.cc | 4394 + ++++++++++++++++++++++++++ + qt5/src/poppler-annotation.h | 921 ++++++ + qt5/src/poppler-base-converter.cc | 105 + + qt5/src/poppler-converter-private.h | 49 + + qt5/src/poppler-document.cc | 679 ++++ + qt5/src/poppler-embeddedfile-private.h | 42 + + qt5/src/poppler-embeddedfile.cc | 135 + + qt5/src/poppler-export.h | 17 + + qt5/src/poppler-fontinfo.cc | 149 + + qt5/src/poppler-form.cc | 416 +++ + qt5/src/poppler-form.h | 343 ++ + qt5/src/poppler-link-extractor-private.h | 57 + + qt5/src/poppler-link-extractor.cc | 84 + + qt5/src/poppler-link.cc | 711 +++++ + qt5/src/poppler-link.h | 612 ++++ + qt5/src/poppler-media.cc | 168 + + qt5/src/poppler-media.h | 100 + + qt5/src/poppler-movie.cc | 110 + + qt5/src/poppler-optcontent-private.h | 121 + + qt5/src/poppler-optcontent.cc | 427 +++ + qt5/src/poppler-optcontent.h | 77 + + qt5/src/poppler-page-private.h | 54 + + qt5/src/poppler-page-transition-private.h | 28 + + qt5/src/poppler-page-transition.cc | 95 + + qt5/src/poppler-page-transition.h | 148 + + qt5/src/poppler-page.cc | 744 +++++ + qt5/src/poppler-pdf-converter.cc | 115 + + qt5/src/poppler-private.cc | 292 ++ + qt5/src/poppler-private.h | 240 ++ + qt5/src/poppler-ps-converter.cc | 273 ++ + qt5/src/poppler-qiodeviceoutstream-private.h | 47 + + qt5/src/poppler-qiodeviceoutstream.cc | 64 + + qt5/src/poppler-qt5.h | 1812 +++++++++++ + qt5/src/poppler-sound.cc | 132 + + qt5/src/poppler-textbox.cc | 63 + + qt5/tests/.gitignore | 30 + + qt5/tests/CMakeLists.txt | 75 + + qt5/tests/Makefile.am | 152 + + qt5/tests/README.unittest | 23 + + qt5/tests/check_actualtext.cpp | 33 + + qt5/tests/check_attachments.cpp | 157 + + qt5/tests/check_dateConversion.cpp | 142 + + qt5/tests/check_fonts.cpp | 248 ++ + qt5/tests/check_goostring.cpp | 61 + + qt5/tests/check_lexer.cpp | 128 + + qt5/tests/check_links.cpp | 96 + + qt5/tests/check_metadata.cpp | 275 ++ + qt5/tests/check_optcontent.cpp | 484 +++ + qt5/tests/check_pagelabelinfo.cpp | 43 + + qt5/tests/check_pagelayout.cpp | 49 + + qt5/tests/check_pagemode.cpp | 73 + + qt5/tests/check_password.cpp | 88 + + qt5/tests/check_permissions.cpp | 44 + + qt5/tests/check_search.cpp | 91 + + qt5/tests/check_strings.cpp | 250 ++ + qt5/tests/poppler-attachments.cpp | 39 + + qt5/tests/poppler-fonts.cpp | 89 + + qt5/tests/poppler-forms.cpp | 166 + + qt5/tests/poppler-texts.cpp | 40 + + qt5/tests/stress-poppler-dir.cpp | 67 + + qt5/tests/stress-poppler-qt5.cpp | 74 + + qt5/tests/test-password-qt5.cpp | 136 + + qt5/tests/test-poppler-qt5.cpp | 235 ++ + 106 files changed, 21480 insertions(+), 4 deletions(-) + +commit 714ee1e61d853394818dca7155b1b882408ffc6a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 16 19:00:01 2013 +0200 + + Pass down the recursion param + + Fixes heap smashing in 168.pdf.SIGSEGV.598.462 + + poppler/Stream.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1f3e3828b9a57e044b86640b9bf9ad2437cc5656 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 15 17:21:36 2013 +0200 + + Add quotes since use_cairo can have spaces + + BUG #65709 + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit fe3ffab19d54326052fd0ff8ee3ee1feb9fa928c +Author: Adam Reichold <adamreichold@myopera.com> +Date: Tue Jun 11 23:08:07 2013 +0200 + + Windows compile fixes + + qt4/tests/stress-threads-qt4.cpp | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +commit 99908cb0c8a784791ffa0682c8f105acdef0d5ab +Author: Peter Breitenlohner <peb@mppmu.mpg.de> +Date: Tue Jun 11 10:02:01 2013 +0200 + + MinGW32 may or may not define __MINGW_PRINTF_FORMAT + + Moreover __USE_MINGW_ANSI_STDIO might be defined as 0 + + poppler/poppler-config.h.cmake | 2 +- + poppler/poppler-config.h.in | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 0673f3d8024554c414f578e0770086f475e6a605 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 11 00:19:19 2013 +0200 + + 0.23.2 + + CMakeLists.txt | 4 ++-- + NEWS | 12 ++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 6 files changed, 18 insertions(+), 6 deletions(-) + +commit 7f1bf8d94302c15a2ff68debfb6fba49df526d16 +Author: Christoph Duelli <duelli@melosgmbh.de> +Date: Thu May 16 16:16:32 2013 +0200 + + Do not pollute global namespace with internal classes + + Bug #64680 + + fofi/FoFiIdentifier.cc | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +commit 07992075a6d1d29db57f997f67d5a4a6deacbbb4 +Merge: 4a0bd6f 25f453e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 9 12:17:53 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.22' + + Conflicts: + poppler/Catalog.cc + qt4/src/poppler-private.h + utils/HtmlOutputDev.cc + +commit 25f453ef49004452ac4c201d59d9ce2ef52ffeee +Author: Julien Nabet <serval2412@yahoo.fr> +Date: Sun Jun 9 12:12:06 2013 +0200 + + Prefer prefix ++/-- operators for non-primitive types + + Part of bug #80537 + + poppler/CachedFile.cc | 3 ++- + poppler/Catalog.cc | 5 +++-- + utils/HtmlFonts.cc | 3 ++- + utils/HtmlLinks.cc | 3 ++- + 4 files changed, 9 insertions(+), 5 deletions(-) + +commit ed01688a899c5e7560a93ca2424ca302ff3452f1 +Author: Julien Nabet <serval2412@yahoo.fr> +Date: Sun Jun 9 12:10:01 2013 +0200 + + Fix mismatched allocation and deallocation + + Part of bug #65551 + + qt4/src/poppler-private.h | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit a27890ac441fbd613ddfe6fcf404b92be371e554 +Author: Julien Nabet <serval2412@yahoo.fr> +Date: Sun Jun 9 12:08:06 2013 +0200 + + Fix memory leak + + utils/HtmlOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 4a0bd6fdb2e9e3c589e1bdb282e7c2bfca8567b1 +Merge: bbd27c9 17a16a2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 9 12:06:10 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit 17a16a2731b1110a12c7163c139d85bccee04492 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 9 12:04:40 2013 +0200 + + Fix mismatched free/delete + + Bug #65553 + + poppler/UTF.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit bbd27c92b5e5034dc2899ea26b47fcb983209f82 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Thu Jun 6 23:52:36 2013 +0200 + + Speed-up some tiling on a 10x factor + + Bug #64892 + + poppler/SplashOutputDev.cc | 15 ++++++++++++++- + splash/Splash.cc | 15 +++++++++++---- + splash/Splash.h | 3 ++- + 3 files changed, 27 insertions(+), 6 deletions(-) + +commit 7847769a24bd3ccf863f653bc2215e84157ccfb6 +Author: Peter Breitenlohner <peb@mppmu.mpg.de> +Date: Tue Jun 4 15:31:06 2013 +0200 + + Use fseeko64/ftello64 for MinGW32 + + goo/gfile.cc | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +commit 0c3548087b379dd6ffa2291d03f0ea1c7e6a69d1 +Author: Peter Breitenlohner <peb@mppmu.mpg.de> +Date: Tue Jun 4 15:31:05 2013 +0200 + + Allow to build without multithreading + + poppler/Annot.cc | 7 +++++++ + poppler/XRef.cc | 4 ++++ + 2 files changed, 11 insertions(+) + +commit 1e74ac4589daf80dcac54b094145d32c90069738 +Author: Adam Reichold <adamreichold@myopera.com> +Date: Thu Jun 6 01:03:48 2013 +0200 + + [qt4] fix autotools + + qt4/tests/Makefile.am | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 342cc0d8a101e99199d447d632a1cd5ba7beb5b2 +Author: Li Junling <lijunling@sina.com> +Date: Tue Jun 4 22:39:35 2013 +0200 + + Fix memory leak + + poppler/SplashOutputDev.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 52945a072b6f864e80485cc4321a27530a76c452 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 4 22:35:32 2013 +0200 + + Move the iccColorSpaceCache from Gfx to OutputDev + + This way it's shared when doing tiling. Page 35 of + bug-poppler64963.pdf + goes down from 150 to 133 seconds + + poppler/Gfx.cc | 61 ++++++++++++++-------------------- + poppler/Gfx.h | 12 ++----- + poppler/GfxState.cc | 93 + ++++++++++++++++++++++++++-------------------------- + poppler/GfxState.h | 33 ++++++++++--------- + poppler/OutputDev.cc | 8 ++++- + poppler/OutputDev.h | 19 +++++++++-- + 6 files changed, 114 insertions(+), 112 deletions(-) + +commit 7d4bda198b8ac767bdf4e0a4fdcaae5541113f92 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 3 23:34:11 2013 +0200 + + Compile + + qt4/tests/stress-threads-qt4.cpp | 1 + + 1 file changed, 1 insertion(+) + +commit 395b3fa021850225e1fea66736f3a3f00571571f +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 3 23:31:52 2013 +0200 + + Fix #end -> #endif + + poppler/poppler-config.h.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 425d1b4835389e2031631ce54cee157af39f1cb6 +Author: Adam Reichold <adamreichold@myopera.com> +Date: Mon Jun 3 20:04:21 2013 +0200 + + Check for the correct number of arguments + + qt4/tests/stress-threads-qt4.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 9d3eb07a1ea01b98aabe4f32481dd4a83bc8f2a5 +Author: Hib Eris <hib@hiberis.nl> +Date: Mon Jun 3 08:49:37 2013 +0200 + + Fix cmake build to use ansi stdio extensions when using a mingw + compiler + + https://bugs.freedesktop.org/show_bug.cgi?id=65238 + + poppler/poppler-config.h.cmake | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 287afe2290d64ca63cdb75fef8f3fbdc20997970 +Author: Adam Reichold <adamreichold@myopera.com> +Date: Sun Jun 2 23:29:00 2013 +0200 + + Add a thread stresser in qt4 + + qt4/tests/CMakeLists.txt | 1 + + qt4/tests/Makefile.am | 9 +- + qt4/tests/stress-threads-qt4.cpp | 298 + +++++++++++++++++++++++++++++++++++++++ + 3 files changed, 307 insertions(+), 1 deletion(-) + +commit 77ecb3823c2db4a6cca5af5889c07c73f90de7f0 +Author: Adam Reichold <adamreichold@myopera.com> +Date: Sat Jun 1 19:04:10 2013 +0200 + + Add a pthread option to pdftoppm + + It's mostly a developer tool only to test thread support + Not end user oriented (hence no buildsystem) + + Parts also by Thomas + + utils/pdftoppm.cc | 130 + ++++++++++++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 126 insertions(+), 4 deletions(-) + +commit caa19f4961146915f51be6c72f60c3aa43037235 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 1 17:22:54 2013 +0200 + + qt4: Fix test binary name in help + + qt4/tests/test-poppler-qt4.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit a0b48b1d05f08605bca5e1a2e2518e16578f6055 +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Jun 1 14:42:42 2013 +0200 + + Fix printf format warning for size_t + + Fixes: + + CXX pdfunite.o + pdfunite.cc: In function ‘int main(int, char**)’: + pdfunite.cc:142:59: warning: format ‘%d’ expects argument of type + ‘int’, but argument 3 has type ‘std::vector<Object>::size_type + {aka long unsigned int}’ [-Wformat] + + https://bugs.freedesktop.org/show_bug.cgi?id=65242 + + utils/pdfunite.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 860737c2a19c734a0c5b65ad506ba229ba439985 +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Jun 1 12:05:17 2013 +0200 + + Use ansi stdio extensions when using a mingw compiler + + In the C runtime used by mingw compilers (msvcrt.dll) the printf + function does not support the C99 format-width specifier "%ll". + + Defining __USE_MINGW_ANSI_STDIO enables mingw's ansi stdio extensions + that implement a C99 compliant printf function. + + https://bugs.freedesktop.org/show_bug.cgi?id=65238 + + CMakeLists.txt | 4 ++++ + configure.ac | 3 +++ + poppler/poppler-config.h.in | 5 +++++ + 3 files changed, 12 insertions(+) + +commit dd30ce39252a3820254b43f90699849ab5a1ca58 +Author: Hib Eris <hib@hiberis.nl> +Date: Fri May 31 12:24:55 2013 +0200 + + Fix warning on narrowing conversion from int to DWORD + + Fixes warning when compiling for Windows: + + gfile.cc: In member function 'Goffset GooFile::size() const': + gfile.cc:609:30: warning: narrowing conversion of '-1' from 'int' + to 'DWORD {aka long unsigned int}' inside { } is ill-formed in C++11 + [-Wnarrowing] + LARGE_INTEGER size = {-1,-1}; + + https://bugs.freedesktop.org/show_bug.cgi?id=65239 + + goo/gfile.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 01a825f3f9f5dcf686fc123d2cf80b9c525d0d89 +Merge: a57f937 b4b1310 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 1 13:47:29 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit b4b13102716cd33636a94fd99c49487924761670 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 1 13:45:53 2013 +0200 + + Fix crash on malformed file + + Also remove outdated comment + + Bug #65221 + + poppler/Stream.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit a57f93780de12732875e0195127a92bff835ff61 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 28 00:11:10 2013 +0200 + + 0.23.1 + + CMakeLists.txt | 4 ++-- + NEWS | 11 +++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 6 files changed, 17 insertions(+), 6 deletions(-) + +commit 299a1447e3d9a845b5e964f29e698046abdb63f2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 28 00:10:43 2013 +0200 + + Build poppler-forms in the autotools buildsystem + + qt4/tests/Makefile.am | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +commit dcfaf20503868d0956ee81208265a975b480fb52 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 27 23:40:49 2013 +0200 + + Dist these two files too + + Makefile.am | 2 ++ + 1 file changed, 2 insertions(+) + +commit de7a3fb715811be6be9ed51b1c5ab1a63c523403 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 27 23:40:07 2013 +0200 + + Add missing copyright + + poppler/Hints.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 30282d3fdbbb3029d9a0f838b2cd979bb962235c +Merge: 61f6658 56044ef +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 27 00:20:12 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit 56044ef482c26f10a8a1371dace049c144659dc7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 27 00:18:22 2013 +0200 + + Fix infinite loop while feeding wrong data in stdin + + Take into account that CachedFile::read might not always return + the number of elems we asked it to read + + Bug #64967 + + poppler/Stream.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 61f665885daeb0009ecac2cc85188f23d6addb60 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 27 00:01:24 2013 +0200 + + Fix big file support in cmake + + Tested by Fabio + + CMakeLists.txt | 2 ++ + cmake/modules/CheckFileOffsetBits.c | 14 +++++++++++ + cmake/modules/CheckFileOffsetBits.cmake | 44 + +++++++++++++++++++++++++++++++++ + config.h.cmake | 6 ++--- + 4 files changed, 63 insertions(+), 3 deletions(-) + +commit f536a4ec37246e10f03fe4de309bd31deb6a4727 +Author: Hib Eris <hib@hiberis.nl> +Date: Thu May 16 21:06:56 2013 +0200 + + Do not use deprecated gtk_scrolled_window_add_with_viewport() + + https://bugs.freedesktop.org/show_bug.cgi?id=64683 + + glib/demo/find.c | 4 ++++ + glib/demo/images.c | 4 ++++ + glib/demo/layers.c | 4 ++++ + glib/demo/render.c | 4 ++++ + glib/demo/selections.c | 4 ++++ + test/gtk-test.cc | 4 ++++ + 6 files changed, 24 insertions(+) + +commit c10f2f8777927d8cfe547941ea2f70fcce14da7a +Author: Pino Toscano <pino@kde.org> +Date: Mon May 20 00:09:45 2013 +0200 + + fix typo in error message + + poppler/Hints.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 71d327194293cb3d1a0e274eaf4451c7afe81e8a +Merge: 7b2df1f 6a98b56 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 17 23:04:12 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit 6a98b56f6ded957477ddcccd4ff849a870020395 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 17 23:01:20 2013 +0200 + + Make an invalid nSharedGroupsFirst a real error + + Instead trying to recover + Fixes bug #46703 + + poppler/Hints.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 7b2df1f935192c89eacddd98c4bf92f38013c8e0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 17 20:56:51 2013 +0200 + + A simple form dumper + + qt4/tests/CMakeLists.txt | 1 + + qt4/tests/poppler-forms.cpp | 166 + ++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 167 insertions(+) + +commit 54f539b4436a1a3e0eab2ef0904c302865082982 +Merge: b3d8f51 3a6e2de +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 16 21:27:47 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit 3a6e2de1d35e3ee4fd86f71713c49bec8e09e41d +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 16 21:27:02 2013 +0200 + + Make sure that Title: doesn't contain \n or \n + + Bug #63862 + + poppler/PSOutputDev.cc | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +commit b3d8f510e30fb4d8da9069390d5e9bd8a283fbd6 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Thu May 16 20:52:09 2013 +0200 + + Fix splashModeBGR8 rendering + + Also make SplashBitmap able to write splashModeBGR8 images + + Bug #64381 + + splash/Splash.cc | 4 ++-- + splash/SplashBitmap.cc | 24 ++++++++++++++++++++++-- + 2 files changed, 24 insertions(+), 4 deletions(-) + +commit 8640933a3aa7dbafa21765d029e97b4bba76716c +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Thu Apr 25 19:18:30 2013 +0200 + + Fix printf format specifiers (Goffset is a long long, not a int) + + poppler/PDFDoc.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit f8e8805bbce3e94b16b77fece0072645c66f6a31 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Thu Apr 25 19:06:09 2013 +0200 + + Re-enable commented-out printf-format attribute on OutStream::printf + + The answer to the question "2,3 because the first arg is class + instance ?" is yes. It's documented behavior: + Since non-static C++ methods have an implicit this argument, the + arguments of such methods should be counted from two, not one. + from + http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Function-Attributes.html + + poppler/Stream.h | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +commit 013b2b247268f9b8dcd8e0461580e0bbcf7554c1 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Thu Apr 25 17:58:25 2013 +0200 + + XRef stream writing: Write 32-bit offsets when possible + + For compatibility reasons: some pdf readers don't support 64-bit + offsets + yet (for example, poppler 0.22 doesn't) + + poppler/XRef.cc | 38 ++++++++++++++++++++++++++++---------- + poppler/XRef.h | 17 +++++++++++++++-- + 2 files changed, 43 insertions(+), 12 deletions(-) + +commit ea61a9dc012fbffd9bc9fe8a09264ba8744635fc +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 13 23:15:55 2013 +0200 + + 0.23.0 + + Includes news, soversions, updated copyrights, etc + + CMakeLists.txt | 6 +++--- + NEWS | 12 ++++++++++++ + configure.ac | 4 ++-- + cpp/Doxyfile | 2 +- + goo/gfile.cc | 1 + + goo/gfile.h | 1 + + poppler/CairoOutputDev.h | 2 +- + poppler/Makefile.am | 2 +- + poppler/Stream.cc | 1 + + poppler/Stream.h | 1 + + poppler/XRef.cc | 1 + + qt4/src/CMakeLists.txt | 2 +- + qt4/src/Doxyfile | 2 +- + qt4/src/Makefile.am | 2 +- + 14 files changed, 28 insertions(+), 11 deletions(-) + +commit 7a5eee1cbebe241b8bd44027fc07682944686910 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 13 23:00:40 2013 +0200 + + Add check_pagelabelinfo test + + qt4/tests/Makefile.am | 1 + + 1 file changed, 1 insertion(+) + +commit 30a519f21dd5df8d41a43a58b2cbd95fe657df73 +Merge: 998a9e7 0c0aef2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 13 20:40:04 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit 0c0aef20d9cecaee1de0badc6cd56dd6e5b5bf12 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 13 19:57:02 2013 +0200 + + 0.22.4 version + + Also increase soversion since Gfx.h got a new member + + CMakeLists.txt | 4 ++-- + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 5 files changed, 6 insertions(+), 6 deletions(-) + +commit 4d6662d05f6b652af97ac6e0eb1f1c1dca8e9550 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 13 19:55:21 2013 +0200 + + 0.22.4 NEWS + + NEWS | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +commit 93e08d96867d636a70ab04ee4ad22c2214ae4b6a +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 13 19:51:52 2013 +0200 + + Update copyright years + + poppler/CairoOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 998a9e7c982a72b0e931304b719de40f30094d12 +Merge: 5e73cb0 73d09cd +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 13 19:30:26 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.22' + + Conflicts: + splash/Splash.cc + +commit 73d09cd55f3bd307450c2dd095e039ea39c69cea +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 13 19:28:40 2013 +0200 + + Fix compilation with fixed point mode enabled + + Thanks to Andreas Müller for the tip + + splash/Splash.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5e73cb059e27f68b329513de609d52e84d73f8af +Merge: 5e9654a b3e44fc +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 7 22:00:02 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit b3e44fc59a9258ad701bc67132dea0646fd8b61a +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 7 21:53:31 2013 +0200 + + We need UnicodeParsedString here too + + Fixes KDE bug #307786 + + qt4/src/poppler-embeddedfile.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 5e9654a3eb28b2c8b0985545778dd0e45829f8e1 +Merge: eeecd97 a107428 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 25 20:45:34 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.22' + + Conflicts: + poppler/Gfx.h + +commit a107428e7db0c420b60418a33b9f815909ac9a33 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 25 20:44:36 2013 +0200 + + Update my C of the last two previous commits + + poppler/Gfx.cc | 2 +- + poppler/Gfx.h | 2 +- + utils/HtmlOutputDev.cc | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +commit eeecd9718f201dc795b2cb8469c43860aec6e07d +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 25 20:29:24 2013 +0200 + + Do not start drawing a form we are already drawing + + Bug #63190 + + poppler/Gfx.cc | 23 +++++++++++++++++++---- + poppler/Gfx.h | 2 ++ + 2 files changed, 21 insertions(+), 4 deletions(-) + +commit 43d66e11aa9e692c1c6b3a237e7e972d317e5c4d +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 25 20:27:43 2013 +0200 + + Make sure getKids returns != 0 before using it + + Fixes crash in bug #63909 + + utils/HtmlOutputDev.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit ec298b3b780f885464aa00880150eaa2b9b50b08 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 25 20:29:24 2013 +0200 + + Do not start drawing a form we are already drawing + + Bug #63190 + + poppler/Gfx.cc | 23 +++++++++++++++++++---- + poppler/Gfx.h | 2 ++ + 2 files changed, 21 insertions(+), 4 deletions(-) + +commit 11ab42e7e90099d0cebf8f02197413fd5dee044b +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 25 20:27:43 2013 +0200 + + Make sure getKids returns != 0 before using it + + Fixes crash in bug #63909 + + utils/HtmlOutputDev.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 4ee78e77f7d6cadc8e150ceff96b546ddca329d4 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Apr 20 16:41:56 2013 +0200 + + cairo: Always use the trasnfer function if present in setSoftMask + + "If the subtype is Alpha, the transparency group XObject G shall be + evaluated to compute a group alpha only. The colours of the + constituent + objects shall be ignored and the colour compositing computations shall + not be performed. The transfer function TR shall then be applied + to the + computed group alpha to produce the mask values." + + We were using the transfer function only for luminosity soft masks. + + https://bugs.freedesktop.org/show_bug.cgi?id=63587 + + poppler/CairoOutputDev.cc | 37 +++++++++++++++++++------------------ + 1 file changed, 19 insertions(+), 18 deletions(-) + +commit 3c2a92b06a6541071bd1e555606bb2096de17ef6 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Apr 20 16:41:56 2013 +0200 + + cairo: Always use the trasnfer function if present in setSoftMask + + "If the subtype is Alpha, the transparency group XObject G shall be + evaluated to compute a group alpha only. The colours of the + constituent + objects shall be ignored and the colour compositing computations shall + not be performed. The transfer function TR shall then be applied + to the + computed group alpha to produce the mask values." + + We were using the transfer function only for luminosity soft masks. + + https://bugs.freedesktop.org/show_bug.cgi?id=63587 + + poppler/CairoOutputDev.cc | 37 +++++++++++++++++++------------------ + 1 file changed, 19 insertions(+), 18 deletions(-) + +commit fd648e83e60db7157b7273ffddc02308b0c5813b +Merge: 970e9f6 53b9cec +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 21 23:30:16 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit 53b9cec6c1334020f90b885cff6fc30293437e5f +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Apr 21 23:28:40 2013 +0200 + + Splash: Always consider a softmask transfer function + + Fixes bug 63587 in splash + + poppler/SplashOutputDev.cc | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +commit 970e9f6304c3b59ac3e44495b90a5cfe7c7ceb8b +Author: Hib Eris <hib@hiberis.nl> +Date: Fri Apr 12 13:26:55 2013 +0200 + + Remove unused variables from Lexer::getObj() + + https://bugs.freedesktop.org/show_bug.cgi?id=63467 + + poppler/Lexer.cc | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +commit f8bf602620b3c7570f483ac66fc4d6a76a81a882 +Merge: bbd27dc 62a5b4d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 14 16:40:51 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit 62a5b4d5c6d5c368d190b86eab63ccb07d642c01 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Apr 14 16:37:14 2013 +0200 + + Check for strcpy_s() and strcat_s() at configure time + + It is better to test for functions than to hardcode exceptions for + specific compilers. + + This fixes compiling poppler with the latest mingw-w64 compiler which + has strcpy_s() and strcat_s() build in. + + Bug #63459 + + ConfigureChecks.cmake | 2 ++ + configure.ac | 1 + + test/perf-test.cc | 6 ++++-- + 3 files changed, 7 insertions(+), 2 deletions(-) + +commit bbd27dc4ce7b24af890d80f597f74e5d7ee0215a +Merge: ea3698c 5bc0080 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Apr 12 00:10:27 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.22' + + Conflicts: + poppler/TextOutputDev.h + +commit 5bc00809ebe560a180d5df93eb50bdf0ff0e97e6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 11 23:29:00 2013 +0200 + + Increase poppler core soname + + CMakeLists.txt | 2 +- + poppler/Makefile.am | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 115d4c1465291adde86c3c905f265ac03374441f +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 11 23:28:17 2013 +0200 + + Increase version number to 0.22.3 + + CMakeLists.txt | 2 +- + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +commit ae1a3553b85e2616a339aacb6efecd15db373858 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 11 23:26:44 2013 +0200 + + News file + + NEWS | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +commit 1fefe98fc86cf8449346bdc230dff5758b1bb7a3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 11 23:22:20 2013 +0200 + + Update copyrgihts + + poppler/CairoOutputDev.cc | 2 +- + poppler/PDFDoc.cc | 2 +- + poppler/TextOutputDev.cc | 2 +- + poppler/TextOutputDev.h | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +commit ea3698cfffc9c132081f5691287ef1fd17911b2a +Merge: fcc1468 aaaea5d +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Apr 10 20:42:01 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit aaaea5d0f2f427e82625a04f90c178e24892e539 +Author: Marek Kasik <mkasik@redhat.com> +Date: Wed Apr 10 16:41:48 2013 +0200 + + man pages: Fix typos + + Fix several typos in manual pages of pdftops and pdfseparate. + + utils/pdfseparate.1 | 2 +- + utils/pdftops.1 | 6 +++--- + 2 files changed, 4 insertions(+), 4 deletions(-) + +commit fcc14682899ff4981bfece74dbc8c290a625b05c +Merge: f11e216 e6559a0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 7 17:44:12 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit e6559a0d836df127ed5061794dc737d435ef534c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 7 17:42:23 2013 +0200 + + Fix crash in KDE bug #317710 + + It is not guaranteed that the ::LinkAction passed to + PageData::convertLinkActionToLink + will be always around (e.g. Page::action deletes it) so make a copy + of the ::MediaRendition object + + qt4/src/poppler-link.h | 6 +++--- + qt4/src/poppler-media.cc | 6 ++++++ + qt4/src/poppler-media.h | 5 ++++- + qt4/src/poppler-page.cc | 4 ++-- + 4 files changed, 15 insertions(+), 6 deletions(-) + +commit f11e21627121c3ff81c0ec7f4d71936a2dd590c3 +Merge: e1ffa91 b9fdb0c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 6 23:26:54 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit e1ffa9100cf6b4a444be7ed76b11698a5c5bb441 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sat Apr 6 23:21:58 2013 +0200 + + Fix endstream detection + + Part 1 of bug #62985 + + the endstream search, and at least with bug-poppler16579.pdf this + doesn't work correctly: the shift(-1) with the used token mechanism + in Lexer isn't correct for a binary data stream. If there is i.e. a + "(" without corresponding ")" in the binary data, which of course can + happen and happens in that pdf, shift(-1) skips the searched endstream + and can therefore in worst case reach the end-of-file. Therefore I + implemented a shift("endstream") in Java, which I now port back to + C++, or in other words "There and Back Again" :-) + + You can test it with bug-poppler16579.pdf if You just change temporary + + if (longNumber <= INT_MAX && longNumber >= INT_MIN && + *end_ptr == '\0') { + + in XRef.cc to + + if (gFalse && longNumber <= INT_MAX && longNumber >= + INT_MIN && *end_ptr == '\0') { + + poppler/Lexer.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++ + poppler/Lexer.h | 2 ++ + poppler/Parser.cc | 28 ++++++++++++++++++++++++++-- + poppler/Parser.h | 2 ++ + 4 files changed, 75 insertions(+), 2 deletions(-) + +commit b9fdb0cb767a228c56f3f0635a7f78e3e0a8c7b6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 6 23:20:48 2013 +0200 + + Last commit was Thomas' forgot his (C) + + poppler/XRef.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 94bee4601cbbda0e7c6205a04650e0510f198aee +Merge: 42368fb b312210 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 6 23:19:25 2013 +0200 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit b312210b630f96baeb8b2f3b49b0b79779609d98 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 6 23:18:18 2013 +0200 + + Fix for complete rewrites in repaired files + + Part 2 of bug #62985 + if You save a PDF with defect xref offsets, the + + readXRefUntil(-1 /* read all xref sections */, &xrefStreamObjNums) + + in XRef::scanSpecialFlags() will destroy the already reconstructed + entries table, but this means that any modification which the user did + in the meantime get lost. This can be tested i.e. with bug168518.pdf. + + poppler/XRef.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 42368fb9452c3719a7bbd159f1c1421068f40653 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 6 18:28:35 2013 +0200 + + Add missing free() + + poppler/PDFDoc.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 2264e7a95e5dc252de1b5736a1edd6bf5de3ad1f +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sat Apr 6 18:27:57 2013 +0200 + + implement Crypt filter + + Bug #62800 + + poppler/Decrypt.h | 3 ++- + poppler/PDFDoc.cc | 37 ++++++++++++++++++++++++++++++++++--- + poppler/Stream.cc | 6 ++++++ + poppler/Stream.h | 3 ++- + 4 files changed, 44 insertions(+), 5 deletions(-) + +commit a65a4e6f878ff033b780b2f1e3362f2918c93b6b +Author: Adam Reichold <adamreichold@myopera.com> +Date: Sat Apr 6 18:25:21 2013 +0200 + + No need to keep the mutex attributes around all the time + + goo/GooMutex.h | 27 ++++++++++----------------- + 1 file changed, 10 insertions(+), 17 deletions(-) + +commit 73ff5ad58cfe7ec9415cc1459b6ca083fee608f4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 6 18:19:28 2013 +0200 + + Pass the recursion flag + + poppler/DCTStream.cc | 6 +++--- + poppler/DCTStream.h | 2 +- + poppler/Stream.cc | 4 ++-- + poppler/Stream.h | 2 +- + 4 files changed, 7 insertions(+), 7 deletions(-) + +commit 837e3704e76ea857b3de45503840e9b855096fef +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 6 17:01:08 2013 +0200 + + Make our mutexes recursive + + Fixes a deadlock problem found with a pdf i can't share + (411klaralv.pdf) + Reviewed by Thomas and Adam on the mailing list + + CMakeLists.txt | 3 +++ + glib/CMakeLists.txt | 3 +++ + goo/GooMutex.h | 36 ++++++++++++++++++++++-------------- + poppler/Annot.cc | 34 +++++++++++++++++----------------- + poppler/Annot.h | 4 ++-- + poppler/Catalog.cc | 24 +++++++++++------------- + poppler/Catalog.h | 8 ++++---- + poppler/XRef.cc | 2 +- + utils/CMakeLists.txt | 3 +++ + 9 files changed, 66 insertions(+), 51 deletions(-) + +commit 0a243c8c14d09a40f25338999c3ca06273277b45 +Author: Adam Reichold <adamreichold@myopera.com> +Date: Fri Apr 5 00:00:07 2013 +0200 + + Add a GooFile class to encapsulate file read access using offsets + + Bug #62735 + + ConfigureChecks.cmake | 2 ++ + config.h.cmake | 6 ++++ + configure.ac | 1 + + goo/gfile.cc | 80 + ++++++++++++++++++++++++++++++++++++++++++++++ + goo/gfile.h | 30 +++++++++++++++++ + poppler/GlobalParamsWin.cc | 19 ++++------- + poppler/PDFDoc.cc | 37 ++++++--------------- + poppler/PDFDoc.h | 4 ++- + poppler/Stream.cc | 46 +++++++++----------------- + poppler/Stream.h | 17 +++------- + 10 files changed, 158 insertions(+), 84 deletions(-) + +commit 70e6af4739d2eea58e6f3200a8c9467597a12ae5 +Author: Rodrigo Rivas Costa <rodrigorivascosta@gmail.com> +Date: Thu Apr 4 23:10:09 2013 +0200 + + Be pedantic about setjmp use + + Bug #63067 + + poppler/DCTStream.cc | 57 + +++++++++++++++++++++++++++------------------------- + 1 file changed, 30 insertions(+), 27 deletions(-) + +commit c7e28e3d672654f31f1a0f95245a1fba3bc9c28f +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 25 22:55:58 2013 +0100 + + Only write the file once when saving + + Bug #62739 + + poppler/PDFDoc.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 09ddb34f202be2111c70901724d64d3b61483c7a +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 25 22:55:58 2013 +0100 + + Only write the file once when saving + + Bug #62739 + + poppler/PDFDoc.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 75378557f409a5a2305ea0fb42c56184c74ba887 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Mar 24 12:53:29 2013 +0100 + + glib: Always start from the beginning when starting a new search on + a page + + And start from previous match when searching the next one on the same + page. This allows to search for the same string multiple times on the + same page. + + https://bugs.freedesktop.org/show_bug.cgi?id=59972 + + glib/poppler-page.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 4ee6757dd7de9211faf8601531342a199225a06d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Mar 24 12:53:29 2013 +0100 + + glib: Always start from the beginning when starting a new search on + a page + + And start from previous match when searching the next one on the same + page. This allows to search for the same string multiple times on the + same page. + + https://bugs.freedesktop.org/show_bug.cgi?id=59972 + + glib/poppler-page.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 83cf2d3d3ecce6340d858a2ee037cd5120ac1db5 +Author: Jason Crain <jason@aquaticape.us> +Date: Sat Mar 9 08:44:36 2013 -0600 + + TextOutputDev: Set text matrix when painting selection + + https://bugs.freedesktop.org/show_bug.cgi?id=61042 + + poppler/TextOutputDev.cc | 30 +++++++++++++++++++++++------- + poppler/TextOutputDev.h | 3 ++- + 2 files changed, 25 insertions(+), 8 deletions(-) + +commit a3bc584fdd7f74a7dab701c743df0bb0bf74a03e +Author: Jason Crain <jason@aquaticape.us> +Date: Sat Mar 9 08:44:36 2013 -0600 + + TextOutputDev: Set text matrix when painting selection + + https://bugs.freedesktop.org/show_bug.cgi?id=61042 + + poppler/TextOutputDev.cc | 30 +++++++++++++++++++++++------- + poppler/TextOutputDev.h | 3 ++- + 2 files changed, 25 insertions(+), 8 deletions(-) + +commit 8cbdbc64897a34beb226d4dc4c58095f10013f29 +Merge: 2bce2cf a01e2d4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 20 22:37:06 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit a01e2d41fcb638fe340bd3d4d22bd13db245e0fd +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Wed Mar 20 22:35:08 2013 +0100 + + check order bounding box values in tiling pattern + + Bug #62369 + + poppler/Gfx.cc | 20 +++++++++++++++----- + 1 file changed, 15 insertions(+), 5 deletions(-) + +commit 2bce2cf2a523f9b8db7f5e255384044b8dfe1a24 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 19 22:53:47 2013 +0100 + + Avoid blackboxes on weird files using the thin line mode + + Bug #61719 + + splash/Splash.cc | 35 +++++++++++++++++++++++++++++++++++ + splash/Splash.h | 1 + + 2 files changed, 36 insertions(+) + +commit b2d07cbf0c2f94bd25e1422e366ff78031815867 +Merge: 80cf78f 3206950 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 18 21:06:59 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit 3206950658521009b52f638cc5e712e0cef42706 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 18 21:06:09 2013 +0100 + + Spec says Zoom -> 0 means no zoom change + + poppler/Link.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 13ee9f8b7d42ed7d7bc0f9dbf190ff66e6ab5a81 +Author: Pino Toscano <pino@kde.org> +Date: Mon Mar 18 18:15:57 2013 +0100 + + cmake: drop search of gthread-2.0 and gio-2.0 from GTK + + this matches what is done in the autoconf counterpart + + cmake/modules/FindGTK.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 47e869e60fb147caca825380eeaa2a0851d502b9 +Author: Michael Weiser <michael@weiser.dinsnail.net> +Date: Mon Mar 18 18:15:14 2013 +0100 + + cmake: search also for gio-2.0 as GLIB library + + cmake/modules/FindGLIB.cmake | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 80cf78f2020e2f4cf33ed49fe522c6861d710588 +Merge: b21780e 72c8312 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Mar 18 20:02:08 2013 +1030 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit 72c8312d77704211f55c8de35b47bd811c792878 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Mar 17 19:39:14 2013 +1030 + + cairo: Don't change image interpolation when printing + + Bug 62418 + + poppler/CairoOutputDev.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit b21780e69dd92f3f2bcb7851608d3e0557dc81f8 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sat Mar 16 23:20:35 2013 +0100 + + Fix typo + + poppler/XRef.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 75849a0d7c205c048714b90883695b6bebd2298c +Merge: ec7140b 5a51812 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 12 20:27:59 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.22' + + Conflicts: + poppler/Stream.h + +commit 5a51812b7c1457feb8acaa106f43d7d5252b3980 +Author: Peter Breitenlohner <peb@mppmu.mpg.de> +Date: Tue Mar 12 20:25:50 2013 +0100 + + Fix compile when not using libjpeg + + poppler/Stream.h | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 341e863d65fdd5619a071e4fd903fa82bf33c757 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 11 19:20:06 2013 +0100 + + 0.22.2 + + CMakeLists.txt | 4 ++-- + NEWS | 16 ++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 6 files changed, 22 insertions(+), 6 deletions(-) + +commit ec7140b3f56b034fbbc53cb8066ba01fe9f60f47 +Merge: c86062f 5db6585 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Mar 8 16:41:21 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.22' + + Conflicts: + poppler/Stream.cc + poppler/Stream.h + +commit 5db6585c2b02dd4071f1adabd53509506333dcf8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Mar 8 16:38:49 2013 +0100 + + Make the non jpeglib based DCTStream compile + + poppler/Stream.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 6402e291e1f9374fbaf4de3b97b21f43d38d6ab8 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Fri Mar 8 16:37:11 2013 +0100 + + Workaround broken jpeg stream definitions + + Bug #61994 + + poppler/DCTStream.cc | 22 +++++++++++++++++++--- + poppler/DCTStream.h | 6 +++++- + poppler/Stream.cc | 8 ++++---- + poppler/Stream.h | 4 ++-- + 4 files changed, 30 insertions(+), 10 deletions(-) + +commit c86062f982d6eb08cb27b654b6317c71ab77c692 +Merge: 677e5b2 4e142b6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 4 20:13:36 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit 4e142b60790638e4495b4fd6551702470cf4c38f +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 4 20:12:01 2013 +0100 + + Make sure we don't try to paint in x < 0 + + Fixes crash in KDE bug #315432 + + splash/Splash.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 677e5b265a0d39a988f65d642a4f964a279fad28 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Mar 3 19:07:32 2013 +0100 + + Small improvements over locker class + + * Remove the namespace (we don't use much/any namespaces in + poppler core) + * Rename the class and defines from lock to locker since lock and be + either the action "to lock" or the "thing that locks", with locker + it is more clear (i think) that is "the thing" than "the action" + * Make Annot::decRefCnt use gLockMutex since we the object itself + is being deleted in the if and not sure the locker would be happy + with that + * change the getNumPages() param to be DoNotLockMutex since + previously it was a gFalse (i guess Thomas made a c&p typo here) + * Have only one constructor like Adam suggested. + + goo/GooMutex.h | 33 +++++++++-------- + poppler/Annot.cc | 92 + +++++++++++++++++++++++----------------------- + poppler/Annot.h | 6 +-- + poppler/Array.cc | 15 ++++---- + poppler/CairoFontEngine.cc | 8 ++-- + poppler/Catalog.cc | 52 +++++++++++++------------- + poppler/Catalog.h | 10 ++--- + poppler/Dict.cc | 20 +++++----- + poppler/PDFDoc.cc | 12 +++--- + poppler/Page.cc | 16 ++++---- + poppler/Stream.cc | 8 ++-- + poppler/XRef.cc | 18 ++++----- + 12 files changed, 147 insertions(+), 143 deletions(-) + +commit d5c929fc253c2748bb8fa3642d9b5383c5fe96f8 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Mar 3 18:00:11 2013 +0100 + + Add a locker helper and a bool -> enum changes + + Bug #59933 + + goo/GooMutex.h | 16 +++++++ + poppler/Annot.cc | 114 + +++++++++++++++++---------------------------- + poppler/Annot.h | 4 +- + poppler/Array.cc | 22 +++------ + poppler/CairoFontEngine.cc | 10 ++-- + poppler/Catalog.cc | 79 ++++++++++--------------------- + poppler/Catalog.h | 9 ++-- + poppler/Dict.cc | 29 ++++-------- + poppler/FontInfo.cc | 2 +- + poppler/PDFDoc.cc | 21 ++------- + poppler/Page.cc | 32 ++++++------- + poppler/Page.h | 3 +- + poppler/Stream.cc | 12 ++--- + poppler/XRef.cc | 29 ++++-------- + 14 files changed, 145 insertions(+), 237 deletions(-) + +commit 1f4a012f7570ffd2120e3e8c2236de5408f3dda3 +Merge: 15d4039 a766740 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Mar 1 19:16:52 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit a766740cf5a5a7580935a026bf15fbd668aa0fdf +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Fri Mar 1 19:12:22 2013 +0100 + + Restore CTM on early exits + + Bug #61413 + + poppler/SplashOutputDev.cc | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +commit 15d40392a29dded8a29c2dc9d7c15b402515e033 +Merge: be5d9af 39882df +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Feb 28 19:46:59 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit 39882dfecdccc00db353946a31d395582ee37022 +Author: José Aliste <jaliste@src.gnome.org> +Date: Wed Feb 27 01:33:38 2013 +0100 + + Correct rendering of underline and strike out annotations + + Current code assumes that the text to underline or strike out is + horizontal. + Fixes bug #61518 + + poppler/Annot.cc | 27 ++++++++++++++++----------- + 1 file changed, 16 insertions(+), 11 deletions(-) + +commit be5d9af38655496a2eaa4eb12cea84461c5aeb3f +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sat Feb 23 23:41:46 2013 +0100 + + expose thin line modes in qt frontend + + qt4/src/poppler-page.cc | 5 ++++- + qt4/src/poppler-qt4.h | 6 ++++-- + 2 files changed, 8 insertions(+), 3 deletions(-) + +commit f96cbacfdbc97ace35f843854992f06e9322f485 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sat Feb 23 23:39:52 2013 +0100 + + Refine splashThinLineShape support + + splash/Splash.cc | 14 +++++++++++--- + 1 file changed, 11 insertions(+), 3 deletions(-) + +commit 47453a78e52aa43edd148aef53b67306603161f5 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Wed Feb 20 23:12:17 2013 +0100 + + More threading safety + + poppler/Annot.cc | 97 + +++++++++++++++++++++++++++++++++++------ + poppler/Annot.h | 8 +++- + poppler/FontInfo.cc | 29 ++++++------ + poppler/FontInfo.h | 5 ++- + poppler/Page.cc | 11 ++++- + poppler/Page.h | 6 +-- + poppler/SplashOutputDev.cc | 7 ++- + poppler/SplashOutputDev.h | 5 ++- + poppler/XRef.cc | 4 +- + qt4/src/poppler-page.cc | 9 ++-- + qt4/src/poppler-ps-converter.cc | 3 +- + 11 files changed, 139 insertions(+), 45 deletions(-) + +commit 60c5e072d4b930507469e6e8c234971725a4aa26 +Merge: 0d42a6d 8d62625 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 20 21:08:53 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit 8d62625610746ad70ffb88d845791fa03f5e35cc +Author: Thomas Fischer <fischer@unix-ag.uni-kl.de> +Date: Wed Feb 20 21:07:10 2013 +0100 + + height -> maskHeight + + Bug #61168 + + utils/ImageOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 0d42a6dab479d27de1ecb2b47ad3f7568b1ee638 +Merge: 7eb7880 8fb243b +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 20 00:00:09 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit 8fb243bf11a979af8bfa36427436940706c9f71d +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 19 23:59:17 2013 +0100 + + Initialize cSrcNonIso[3] in splashModeXBGR8 + + Fixes valgrind warning + + splash/Splash.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 8a0199a0247c1a03a4d64375ca8bc900570d1817 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 19 23:11:46 2013 +0100 + + Fix indent + + splash/Splash.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 7eb7880907cb7b6bd1032013d6ce4c49aa3525c4 +Merge: 2c84acb 1389aa4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 19 22:26:37 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit 1389aa41b2984de9da7bb66c11485f6c6aeaea41 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 19 22:25:56 2013 +0100 + + fix indent + + splash/Splash.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 2c84acbfd02eeeaf0d20542798e907cb011c1e57 +Merge: 401c35b ffd33e7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 19 11:32:11 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit ffd33e7b5aea44bc54a74f433f6bfff859b913dd +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 19 11:31:22 2013 +0100 + + Fix missing ) here too + + README.contributors | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 14466ecc320387c9b6568280614a96e6f56309b4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 19 11:31:02 2013 +0100 + + Forgot my C here + + poppler/PageLabelInfo.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 401c35b797d3c25c734fbfb5b95be16a666a6012 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Feb 18 22:33:07 2013 +0100 + + Fix closing ) as suggested by William Bader + + README.contributors | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 94364adade4dc27e5d80bc14511d4f2b7ea4ab0d +Merge: 164805b 47f30fa +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Feb 18 20:34:34 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit 47f30fa96e62fc215c0e80f42517908760ef8065 +Author: Brad Hards <bradh@frogmouth.net> +Date: Mon Feb 18 20:38:10 2013 +1100 + + Minor rewording of contributor README + + README.contributors | 13 +++++++------ + 1 file changed, 7 insertions(+), 6 deletions(-) + +commit 164805b4471256d3915c5e49fff28c9cdcbf89e6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Feb 18 20:05:12 2013 +0100 + + Move the commented test to a proper one + + poppler/Makefile.am | 3 +- + poppler/PageLabelInfo.cc | 160 + +------------------------------------- + poppler/PageLabelInfo_p.h | 147 + ++++++++++++++++++++++++++++++++++ + qt4/tests/CMakeLists.txt | 1 + + qt4/tests/Makefile.am | 4 + + qt4/tests/check_pagelabelinfo.cpp | 43 ++++++++++ + 6 files changed, 198 insertions(+), 160 deletions(-) + +commit 527b91a0ef97906041ffe57e88f0d26e1c407af0 +Merge: df35562 95609be +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Feb 18 19:49:14 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit 95609be551fc4413874b8980010be70fbbab112a +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Feb 18 19:47:19 2013 +0100 + + Use the toLatin function in PageLabelInfo::indexToLabel + + Wonder why Kristian never enabled it? + Fixes bug #61034 + + poppler/PageLabelInfo.cc | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit df3556240d5e4b4546b3c42b29be6d2be83a2802 +Merge: 4dacd7c 5c7057c +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 12 23:55:24 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit 5c7057c61ed6e270e001c1f86632f265bebb6890 +Author: Nuno Araujo <nuno.araujo@russo79.com> +Date: Tue Feb 12 23:54:47 2013 +0100 + + Fix the build with automake-1.13 + + autogen.sh | 17 +++++++++-------- + configure.ac | 3 +-- + 2 files changed, 10 insertions(+), 10 deletions(-) + +commit 4dacd7cdeb19d16fe7737c71e34904c7363c6b63 +Merge: 7f2c255 9fc4b9f +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 12 22:59:56 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.22' + +commit 9fc4b9f7a7e6105a6fd85aed9c21b78742e89ddd +Author: Peter Breitenlohner <peb@mppmu.mpg.de> +Date: Tue Feb 12 22:58:17 2013 +0100 + + true->TRUE + + Fixes compilation with jpeglib9 + + goo/JpegWriter.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 7f2c255ff28386ba992717f729f25a979f240375 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Tue Feb 12 22:48:40 2013 +0100 + + Introduce option SplashThinLineMode + + More info at bug #37347 + + poppler/SplashOutputDev.cc | 9 ++++++++- + poppler/SplashOutputDev.h | 3 ++- + splash/Splash.cc | 37 ++++++++++++++++++++++++++++++------- + splash/Splash.h | 9 +++++++-- + splash/SplashClip.cc | 7 ++++--- + splash/SplashClip.h | 4 +++- + splash/SplashTypes.h | 8 +++++++- + splash/SplashXPath.cc | 14 ++++++++++++-- + splash/SplashXPath.h | 17 ++++++++++++++++- + splash/SplashXPathScanner.cc | 9 +++++---- + splash/SplashXPathScanner.h | 17 ++++++++++++++++- + 11 files changed, 110 insertions(+), 24 deletions(-) + +commit c2ebcbea2267f861c491c0cd6c1fbf2dc2aff7d2 +Merge: 48ed05d dca21f8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 10 12:01:13 2013 +0100 + + Merge remote-tracking branch 'origin/poppler-0.22' + + Conflicts: + poppler/Parser.cc + +commit dca21f86359b6b2a925f7b05a2f36ab854cefbce +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 10 11:47:21 2013 +0100 + + 0.22.1 + + CMakeLists.txt | 2 +- + NEWS | 9 +++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + 5 files changed, 13 insertions(+), 4 deletions(-) + +commit e8e9245f6a4884da3940fc281b7ff1a42d7f5964 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 10 11:43:14 2013 +0100 + + Update C year here too + + poppler/poppler-config.h.cmake | 2 +- + poppler/poppler-config.h.in | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit ebbacd897e2b529d1c3637b6af438b8dcc1d7ce8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 10 11:42:21 2013 +0100 + + Update C + + poppler/Parser.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 48ed05d95598b642a57456a843baf9f246502bb6 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Feb 6 21:56:01 2013 +1030 + + Make Goffset long long and factor out all fseek/ftell into gfile.cc + + This fixes build problems on 32-bit machines due to off_t being + defined differently depending on whether source files included + condig.h. + + Bug 60095 + + goo/gfile.cc | 38 ++++++++++++++++++++++++ + goo/gfile.h | 7 +++++ + goo/gtypes.h | 19 +----------- + poppler/Stream.cc | 67 + ++++++------------------------------------ + poppler/XRef.cc | 4 +-- + poppler/poppler-config.h.cmake | 6 ---- + poppler/poppler-config.h.in | 6 ---- + utils/pdfinfo.cc | 16 ++-------- + 8 files changed, 60 insertions(+), 103 deletions(-) + +commit fbcd64386c1b189db6e06234577261973bdc88cc +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Jan 25 22:24:50 2013 +1030 + + cairo: support uncolored tiling patterns + + Bug 59179 + + poppler/CairoOutputDev.cc | 20 ++++++++++++++++++++ + poppler/CairoOutputDev.h | 1 + + 2 files changed, 21 insertions(+) + +commit c60ad119363c65d097dff56a68c1ab3fb2933f0b +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Jan 27 15:50:26 2013 +1030 + + A few more missing Goffsets + + glib/poppler-input-stream.h | 2 +- + poppler/PDFDoc.cc | 16 ++++++++-------- + poppler/PDFDoc.h | 6 +++--- + poppler/Stream.cc | 4 ++-- + poppler/Stream.h | 4 ++-- + 5 files changed, 16 insertions(+), 16 deletions(-) + +commit 9b113dc86a27085693ac4bcad061780c881ea7f9 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Jan 27 11:32:34 2013 +1030 + + Use sys/types.h instead of stdio.h for the off_t type + + Bug 44085 + + goo/gtypes.h | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit f3aa5236361dca3db64f110520ebe721ba1c9464 +Author: Pino Toscano <pino@kde.org> +Date: Sun Jan 27 18:50:10 2013 +0100 + + use Goffset also for length in MemStream ctor + + poppler/Stream.cc | 2 +- + poppler/Stream.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit eb5ce6990522bac91d8f5d0d3636c46178386d25 +Author: Pino Toscano <pino@kde.org> +Date: Sun Jan 27 15:20:42 2013 +0100 + + avoid max() macro expansion + + protect against compilers defining max as macro + + poppler/XRef.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 6b716b1ab60b573b5770d8636992247387bc3513 +Author: Pino Toscano <pino@kde.org> +Date: Sun Jan 27 15:18:04 2013 +0100 + + cmake: provide HAVE_FSEEK64 and HAVE_FSEEKO in poppler-config + + followup of a3cee0e7e9dd292c70fe1fa19a92e70bbc1e1b41 also for the + cmake-generated poppler-config.h + + poppler/poppler-config.h.cmake | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit fe59ac914230b80aa82b314398a8a038ef083e06 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Jan 26 16:44:49 2013 +1030 + + Read 8 byte xref offsets when sizeof(Goffset) < 8 + + and print an error if the offset read is too large for Goffset. + + Bug 56318 + + poppler/XRef.cc | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +commit 098d98dfc3846150098f5b20f3f5a07cb565c465 +Author: Lu Wang <coolwanglu@gmail.com> +Date: Sat Jan 26 19:31:20 2013 +0100 + + Rename function + + Makes it say more what it does + + poppler/GfxState.cc | 3 ++- + poppler/GfxState.h | 3 ++- + poppler/SplashOutputDev.cc | 5 +++-- + 3 files changed, 7 insertions(+), 4 deletions(-) + +commit 97e93d7583f2a6a5b1c8b51474744ca05277dc28 +Author: Lu Wang <coolwanglu@gmail.com> +Date: Sat Jan 26 16:56:00 2013 +0100 + + Remove unused deviceHasTextClip + + poppler/CairoOutputDev.h | 1 - + poppler/OutputDev.h | 1 - + poppler/PSOutputDev.h | 1 - + poppler/SplashOutputDev.h | 1 - + utils/pdftohtml.cc | 1 - + 5 files changed, 5 deletions(-) + +commit 1bb3ddc2264cb65dffd553a952ee4518344df0de +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jan 25 19:37:24 2013 +0100 + + A few Goffsets we missed + + charactersRead is returned in BaseCryptStream::getPos thus should + be a Goffset + Gfx::getPos returns Parser::getPos and thus should be a Goffset too + + poppler/Decrypt.h | 3 ++- + poppler/Gfx.cc | 4 ++-- + poppler/Gfx.h | 4 ++-- + 3 files changed, 6 insertions(+), 5 deletions(-) + +commit 5f8b1275a19b2036c6e9323a744d8bc64af31c36 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jan 25 19:32:58 2013 +0100 + + New year! + + poppler/poppler-config.h.cmake | 2 +- + poppler/poppler-config.h.in | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 574907e6a74e62a5ee6d7f17c43fdd9bcb07e069 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jan 25 19:31:59 2013 +0100 + + Adrian C for 2013 because of the big files support + + cpp/poppler-private.cpp | 1 + + cpp/poppler-private.h | 1 + + goo/gtypes.h | 1 + + poppler/Decrypt.cc | 1 + + poppler/Decrypt.h | 1 + + poppler/Error.cc | 1 + + poppler/Error.h | 1 + + poppler/Hints.cc | 1 + + poppler/Hints.h | 1 + + poppler/JBIG2Stream.cc | 1 + + poppler/JBIG2Stream.h | 1 + + poppler/JPEG2000Stream.cc | 1 + + poppler/JPEG2000Stream.h | 1 + + poppler/Lexer.cc | 2 +- + poppler/Lexer.h | 1 + + poppler/Object.cc | 1 + + poppler/Object.h | 1 + + poppler/PDFDoc.cc | 1 + + poppler/PDFDoc.h | 1 + + poppler/PageTransition.cc | 1 + + poppler/Parser.cc | 1 + + poppler/Parser.h | 1 + + poppler/SecurityHandler.cc | 1 + + poppler/Stream.cc | 1 + + poppler/Stream.h | 1 + + poppler/XRef.cc | 1 + + poppler/XRef.h | 1 + + qt4/src/poppler-private.cc | 1 + + qt4/src/poppler-qiodeviceoutstream-private.h | 1 + + qt4/src/poppler-qiodeviceoutstream.cc | 1 + + utils/pdfinfo.cc | 2 +- + utils/pdfunite.cc | 1 + + 32 files changed, 32 insertions(+), 2 deletions(-) + +commit 95b81ae9b5a345c9caa3d658b9b543d1937c6c02 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Jan 25 21:37:51 2013 +1030 + + gitignore + + qt4/tests/.gitignore | 2 ++ + 1 file changed, 2 insertions(+) + +commit 576dc53c857d99bb5d81fe7c9c52fe314a6e58ee +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Fri Jan 25 21:27:13 2013 +1030 + + splash: fix uninitialized memory + + Bug 44085 + + poppler/SplashOutputDev.cc | 13 +++++++------ + 1 file changed, 7 insertions(+), 6 deletions(-) + +commit a9768588cd6086f4ca4e6906db038cfdbfd551d5 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Jan 25 21:24:29 2013 +1030 + + win32 large file support + + Bug 44085 + + goo/gtypes.h | 2 ++ + poppler/Stream.cc | 13 +++++++++++++ + utils/pdfinfo.cc | 3 +++ + 3 files changed, 18 insertions(+) + +commit a3cee0e7e9dd292c70fe1fa19a92e70bbc1e1b41 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Jan 25 21:23:43 2013 +1030 + + Large file support + + Create a Goffset type and use this type for all file offsets and file + sizes. + + Bug 44085 + + cpp/poppler-private.cpp | 2 +- + cpp/poppler-private.h | 2 +- + glib/poppler-input-stream.cc | 10 +- + glib/poppler-input-stream.h | 16 +-- + goo/gtypes.h | 15 +++ + poppler/Decrypt.cc | 2 +- + poppler/Decrypt.h | 2 +- + poppler/Error.cc | 10 +- + poppler/Error.h | 5 +- + poppler/Hints.cc | 4 +- + poppler/Hints.h | 6 +- + poppler/JBIG2Stream.cc | 8 +- + poppler/JBIG2Stream.h | 2 +- + poppler/JPEG2000Stream.cc | 2 +- + poppler/JPEG2000Stream.h | 2 +- + poppler/Lexer.h | 8 +- + poppler/Object.h | 8 +- + poppler/PDFDoc.cc | 54 +++++----- + poppler/PDFDoc.h | 14 +-- + poppler/Parser.cc | 10 +- + poppler/Parser.h | 2 +- + poppler/Stream.cc | 88 ++++++++--------- + poppler/Stream.h | 102 +++++++++---------- + poppler/XRef.cc | 141 + +++++++++++++++++---------- + poppler/XRef.h | 34 +++---- + poppler/poppler-config.h.in | 6 ++ + qt4/src/poppler-private.cc | 2 +- + qt4/src/poppler-qiodeviceoutstream-private.h | 2 +- + qt4/src/poppler-qiodeviceoutstream.cc | 4 +- + test/perf-test.cc | 6 +- + utils/pdfinfo.cc | 6 +- + utils/pdfunite.cc | 2 +- + 32 files changed, 320 insertions(+), 257 deletions(-) + +commit 6eebbb9c015f98b713205e56ab2f1d4d430e9206 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Jan 25 21:22:51 2013 +1030 + + Add Int64 object type + + Bug 44085 + + poppler/Lexer.cc | 46 + ++++++++++++++++++++-------------------------- + poppler/Object.cc | 6 +++--- + poppler/Object.h | 26 +++++++++++++++----------- + poppler/PDFDoc.cc | 4 ++-- + poppler/SecurityHandler.cc | 4 ++-- + qt4/tests/check_lexer.cpp | 24 +++++++++++++++++------- + test/pdf-fullrewrite.cc | 9 +-------- + 7 files changed, 60 insertions(+), 59 deletions(-) + +commit be495d73ce7324963a979cffc149330f5512288b +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Jan 25 21:14:21 2013 +1030 + + use getNum instead of getReal + + poppler/PageTransition.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit a5adb6738e1e191c64457e0c07ee2e3422a042dd +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jan 19 18:13:33 2013 +0100 + + Don't use config.h but poppler-config.h + + That was already included but i forgot to kill the other one + + poppler/XRef.h | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit 8eb489c355d734a72e140ce7e32470d048362499 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sat Jan 19 17:43:08 2013 +0100 + + Make rendering thread-safe + + Bug #50992 + + glib/poppler-input-stream.cc | 4 ++ + glib/poppler-input-stream.h | 1 + + poppler/Annot.cc | 52 +++++++++---------- + poppler/Array.cc | 48 +++++++++++++++++- + poppler/Array.h | 15 ++++-- + poppler/ArthurOutputDev.cc | 3 +- + poppler/ArthurOutputDev.h | 3 +- + poppler/CairoFontEngine.cc | 33 +++++++++--- + poppler/CairoFontEngine.h | 11 ++-- + poppler/CairoOutputDev.cc | 15 ++++-- + poppler/CairoOutputDev.h | 5 +- + poppler/Catalog.cc | 84 +++++++++++++++++++++++++++---- + poppler/Catalog.h | 15 ++++-- + poppler/Dict.cc | 67 ++++++++++++++++++++++++- + poppler/Dict.h | 11 +++- + poppler/Gfx.cc | 18 ++++--- + poppler/Gfx.h | 8 +-- + poppler/GlobalParamsWin.cc | 4 +- + poppler/Object.h | 7 +-- + poppler/OutputDev.h | 4 +- + poppler/PDFDoc.cc | 66 ++++++++++++++++++------ + poppler/PDFDoc.h | 11 ++-- + poppler/PSOutputDev.cc | 12 ++--- + poppler/PSOutputDev.h | 4 +- + poppler/Page.cc | 75 ++++++++++++++++++++++++--- + poppler/Page.h | 18 +++++-- + poppler/Parser.cc | 3 +- + poppler/PreScanOutputDev.cc | 4 +- + poppler/PreScanOutputDev.h | 4 +- + poppler/SplashOutputDev.cc | 16 +++--- + poppler/SplashOutputDev.h | 5 +- + poppler/Stream.cc | 117 + ++++++++++++++++++++++++++++++++----------- + poppler/Stream.h | 35 +++++++++---- + poppler/TextOutputDev.cc | 5 +- + poppler/TextOutputDev.h | 3 +- + poppler/XRef.cc | 99 +++++++++++++++++++++++++++++++++--- + poppler/XRef.h | 16 +++++- + qt4/src/poppler-document.cc | 23 ++++----- + qt4/src/poppler-page.cc | 64 ++++++++++++++++++++--- + qt4/src/poppler-private.cc | 3 +- + qt4/src/poppler-private.h | 74 +-------------------------- + test/gtk-test.cc | 2 +- + utils/HtmlOutputDev.cc | 3 +- + utils/HtmlOutputDev.h | 3 +- + utils/ImageOutputDev.h | 3 +- + 45 files changed, 793 insertions(+), 283 deletions(-) + +commit 3db9472e2b016f1b411174273f27848193ab18e5 +Author: José Aliste <jaliste@src.gnome.org> +Date: Fri Jan 18 15:22:03 2013 +0100 + + Add a null check for gfxFont + + Bug #59561 + + poppler/TextOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 4b69217f72f3fd313f73df059eb1e6294878a95e +Author: Peter Dyballa <Peter_Dyballa@Freenet.DE> +Date: Fri Jan 11 00:32:46 2013 +0100 + + Use CPPFLAGS for CPPFLAGS not CFLAGS + + Bug #59186 + + m4/libjpeg.m4 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 8b6dc55e530b2f5ede6b9dfb64aafdd1d5836492 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 10 22:31:52 2013 +0100 + + Fix invalid memory access in 1150.pdf.asan.8.69 + + splash/Splash.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit e14b6e9c13d35c9bd1e0c50906ace8e707816888 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 10 20:52:02 2013 +0100 + + Fix invalid memory access in 2030.pdf.asan.69.463 + + poppler/Function.cc | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit 0388837f01bc467045164f9ddaff787000a8caaa +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 10 20:29:06 2013 +0100 + + Fix another invalid memory access in 1091.pdf.asan.72.42 + + poppler/Stream.cc | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +commit 957aa252912cde85d76c41e9710b33425a82b696 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 10 19:16:19 2013 +0100 + + Fix invalid memory accesses in 1091.pdf.asan.72.42 + + splash/Splash.cc | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +commit bbc2d8918fe234b7ef2c480eb148943922cc0959 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 10 19:07:48 2013 +0100 + + Fix invalid memory accesses in 1036.pdf.asan.23.17 + + splash/Splash.cc | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +commit a9b8ab4657dec65b8b86c225d12c533ad7e984e2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 9 22:56:45 2013 +0100 + + Fix crash in broken file 1031.pdf.asan.48.15 + + splash/Splash.cc | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +commit 7266a634e01e20648cc877371edc95651d30d4fc +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 9 22:52:45 2013 +0100 + + Forgot the C of the last commit + + splash/Splash.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit a205e71a2dbe0c8d4f4905a76a3f79ec522eacec +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 9 22:47:28 2013 +0100 + + Do not crash in broken documents like 1007.pdf.asan.48.4 + + splash/Splash.cc | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +commit b1026b5978c385328f2a15a2185c599a563edf91 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 9 22:17:09 2013 +0100 + + Initialize refLine totally + + Fixes uninitialized memory read in 1004.pdf.asan.7.3 + + poppler/Stream.cc | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +commit bef2c42f381c74fdb8bbb43babe1a93a0e229fb0 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu Jan 3 15:27:36 2013 +1030 + + Parser: return error if stream encountered when allowStreams = false + + Opening a PDF file where the first object is a stream prints a + "Command token too long" error message. This is caused by the + Linearization check in Linearization::Linearization reading objects + with allowStreams = false. The Parser ignores the "stream" token and + tries reading the next token which is usually binary data. Setting + allowStreams to true will not work since the stream length is often an + indirect object and at this point the XRef has not been created. + + Fix this by making Parser return an error object if the "stream" token + is encountered when allowStreams is false. + + Bug 58966 + + poppler/Parser.cc | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +commit 801f7feea79e5bc3b5417566552e4df1e6b8a51c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 29 19:22:54 2012 +0100 + + 0.22.0 + + CMakeLists.txt | 6 +++--- + NEWS | 14 ++++++++++++++ + configure.ac | 4 ++-- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 6 files changed, 22 insertions(+), 8 deletions(-) + +commit bf5ef68c89d4189b18458b764f807cfc6599bad7 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Dec 29 19:43:11 2012 +0100 + + regtest: Print test results when the test has finished + + To make sure the result corresponds to the test now that we are using + multiple threads. + + regtest/Printer.py | 25 +++++++++++++++++++------ + regtest/TestRun.py | 18 +++++++++--------- + 2 files changed, 28 insertions(+), 15 deletions(-) + +commit 80c7f6aa3fa83175fafc71fa8c834350d513a48f +Author: Jason Crain <jason@aquaticape.us> +Date: Fri Nov 23 23:31:01 2012 -0600 + + TextOutputDev: Use page size for max value in TextPage::visitSelection + + https://bugs.freedesktop.org/show_bug.cgi?id=50138 + + poppler/TextOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 0d31edfa5617f4fecb04d5476de54a63b6146686 +Author: Ross Lagerwall <rosslagerwall@gmail.com> +Date: Fri Nov 30 09:23:55 2012 +0000 + + pdf-inspector Change from the deprecated GtkTable to GtkGrid + + This fixes the problem of the description_label height changing after + its text changes which was introduced since the port to Gtk3. + + https://bugs.freedesktop.org/show_bug.cgi?id=57727 + + test/pdf-inspector.ui | 39 +++++++++++++++------------------------ + 1 file changed, 15 insertions(+), 24 deletions(-) + +commit 9977a4f26b5698b0b85ca911e7392013941944e0 +Author: Ross Lagerwall <rosslagerwall@gmail.com> +Date: Tue Nov 13 15:49:44 2012 +0000 + + pdf-inspector: Remove deprectated has-separator property + + https://bugs.freedesktop.org/show_bug.cgi?id=57727 + + test/pdf-inspector.ui | 1 - + 1 file changed, 1 deletion(-) + +commit 806d116a38c2a6552c9bcee2c6f753d7059c17aa +Author: Ross Lagerwall <rosslagerwall@gmail.com> +Date: Tue Nov 13 15:44:15 2012 +0000 + + pdf-inspector: Add correct title and copyright + + https://bugs.freedesktop.org/show_bug.cgi?id=57727 + + test/pdf-inspector.cc | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +commit 7d5bf74c19768fa3447819a4debff06d5d83900a +Author: Ross Lagerwall <rosslagerwall@gmail.com> +Date: Tue Nov 13 15:23:36 2012 +0000 + + pdf-inspector: Fix crash by not freeing filename_g + + It is not necessary because PDFDoc takes over filename_g and destroys + it in its deconstructor. + + https://bugs.freedesktop.org/show_bug.cgi?id=57727 + + test/pdf-inspector.cc | 1 - + 1 file changed, 1 deletion(-) + +commit d61c6d4944d6f7c9e8b517dd28958124f4923d08 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Fri Dec 28 01:18:48 2012 +0100 + + Repair pdfunite + + Sorry, when I implemented the support encrypted pdf files in + pdfseparate I + missed that writePageObjects of course is also used in pdfunite + for combining + pages, and even more that encrypted files are still not supported + by pdfunite, + I removed the numoffset from writing the objects itself. Therefore + there are + still all objects in the combined pdf file, but the references + missing the + numoffset and therefore were no more reachable. + The patch repairs it. + + Bug #58569 + + poppler/PDFDoc.cc | 6 ++++-- + poppler/PDFDoc.h | 4 ++-- + utils/pdfunite.cc | 4 ++-- + 3 files changed, 8 insertions(+), 6 deletions(-) + +commit be4804bff2b722ceac180da52ad436fee548f9ee +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 28 01:17:14 2012 +0100 + + dos2unix + + poppler/PDFDoc.cc | 36 ++++++++++++++++++------------------ + 1 file changed, 18 insertions(+), 18 deletions(-) + +commit 703c77eb59aa22ab6372d56a20ee81dc7dfa6e4a +Author: Even Rouault <even.rouault@mines-paris.org> +Date: Fri Dec 28 00:57:17 2012 +0100 + + Fix very long loop in JPXStream::getImageParams() + + poppler/JPXStream.cc | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +commit 7e0be7854adc49e4e00c0badb0dc470fbdf6d612 +Author: Even Rouault <even.rouault@mines-paris.org> +Date: Fri Dec 28 00:44:29 2012 +0100 + + Avoid DoS due to huge number of JPX tiles in a stream + + poppler/JPXStream.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 2017dbebd9afd4f172242ff8462fce739d911e64 +Author: Even Rouault <even.rouault@mines-paris.org> +Date: Fri Dec 28 00:30:13 2012 +0100 + + Do not crash on 0 or negative nBits values + + poppler/Stream.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 858df0dc04e2f306e806fe0fc4fb5c8ec804e263 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Dec 27 23:30:27 2012 +0100 + + Fix arg typo + + poppler/PDFDoc.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1dd6280d79ad22461208702b3c929377887c99ff +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 15 16:39:23 2012 +0100 + + 0.21.4 soversion increases + + CMakeLists.txt | 2 +- + glib/CMakeLists.txt | 2 +- + glib/Makefile.am | 2 +- + poppler/Makefile.am | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +commit 99d0288bb0b6879ae5414d174939bbd9c1e90bd3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 15 16:37:19 2012 +0100 + + 0.21.4 version increase + + CMakeLists.txt | 2 +- + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +commit 2bc48d5369f1dbecfc4db2878f33bdeb80d8d90f +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 15 16:36:38 2012 +0100 + + 0.21.4 NEWS + + NEWS | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +commit b3423d54b1254597d7ca953872211fa3aa83e29c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 15 16:29:54 2012 +0100 + + Updated copyrights + + goo/JpegWriter.h | 2 +- + goo/PNGWriter.cc | 1 + + goo/PNGWriter.h | 1 + + goo/TiffWriter.cc | 1 + + goo/TiffWriter.h | 1 + + poppler/GlobalParams.cc | 2 +- + poppler/TextOutputDev.cc | 1 + + splash/Splash.cc | 1 + + utils/HtmlOutputDev.cc | 1 + + 9 files changed, 9 insertions(+), 2 deletions(-) + +commit 487f20d24830a97cad4773ae27f0c2cc58df2ed0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Dec 13 20:40:39 2012 +0100 + + Check obj1 is a dict before using it + + Fixes bug #58257 + + poppler/Gfx.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 03045469206adbd797e3a38fee3a16cdd1716812 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Dec 13 19:24:54 2012 +0100 + + Fix crop on EPS conversion + + Bug #30692 + Patch is half William Bader's and half mine + + poppler/OutputDev.h | 5 +++++ + poppler/PSOutputDev.h | 4 +++- + poppler/Page.cc | 3 +++ + poppler/Page.h | 2 ++ + 4 files changed, 13 insertions(+), 1 deletion(-) + +commit 5d50b2765428e5a417967be2f41452ab05917db7 +Author: Peter Breitenlohner <peb@mppmu.mpg.de> +Date: Tue Dec 11 18:54:30 2012 +0100 + + Correct bad semantics + + Negation has higher precedence than comparison + Confirmed by Marek Kasik that wrote the code originally + + poppler/TextOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e306bad391a3ff49593f1f3bac0717d62599bd13 +Author: Pino Toscano <pino@kde.org> +Date: Sun Dec 9 22:40:27 2012 +0100 + + pngwriter: move #include <png.h> into .cc file + + Move all the private data (including the libpng types) to a private + class. + + This requires HtmlOutputDev.cc to include <png.h> on its own (which + is correct, since it uses the libpng API directly). + + goo/PNGWriter.cc | 98 + +++++++++++++++++++++++++++++--------------------- + goo/PNGWriter.h | 12 ++----- + utils/HtmlOutputDev.cc | 4 +++ + 3 files changed, 64 insertions(+), 50 deletions(-) + +commit cf338551e9d031cc00d56cea0d258ec5fd96e79a +Author: Pino Toscano <pino@kde.org> +Date: Sun Dec 9 22:22:03 2012 +0100 + + tiffwriter: move #include <tiffio.h> into .cc file + + Move all the private data (including the libtiff types) to a private + class. + + goo/TiffWriter.cc | 94 + ++++++++++++++++++++++++++++++++----------------------- + goo/TiffWriter.h | 12 ++----- + 2 files changed, 56 insertions(+), 50 deletions(-) + +commit 0dfa51f0bfa787ee9c865fd4f05e4bd964c260fc +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 9 22:31:50 2012 +0100 + + Having a look at the log Marek has (C) in this file + + poppler/TextOutputDev.cc | 1 + + 1 file changed, 1 insertion(+) + +commit f1b2e29e1d5f420903085318f06c4dc83ebb24f3 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Dec 9 20:59:26 2012 +0100 + + Fix crash when rendering on mono1 + + poppler/SplashOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 71bad47ed6a36d825b0d08992c8db56845c71e40 +Author: Marek Kasik <mkasik@redhat.com> +Date: Sun Dec 9 20:20:00 2012 +0100 + + Filter stuff that might end up in the shell + + Since it seems shells don't know how to filter stuff and might + causing bad things to happen + + poppler/Error.cc | 21 +++++++++++++++++---- + 1 file changed, 17 insertions(+), 4 deletions(-) + +commit c35d030472e6cb140c3dff30b91541772c992eb0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 8 23:51:59 2012 +0100 + + Add private copy constructor and operator= to make sure we don't + use the default ones + + Since using them would results in bad things happening + + goo/GooHash.h | 16 ++++++++++++++++ + goo/GooList.h | 16 ++++++++++++++++ + goo/PNGWriter.h | 5 ++++- + goo/TiffWriter.h | 5 ++++- + goo/gfile.h | 4 ++++ + 5 files changed, 44 insertions(+), 2 deletions(-) + +commit f6741d9242bf2d9c13c8d534c50c8e4d404afc7f +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Dec 2 09:34:35 2012 +1030 + + jpegwriter: move #include "jpeglib.h" into .cc file + + On cygwin pdftocairo -v shows the wrong version due to + jpeglib.h defining PACKAGE_VERSION. + + Avoid polluting our header files by moving libjpeg.h and + libjpeg types into JpegWriter.cc + + Bug 57687 + + goo/JpegWriter.cc | 120 + ++++++++++++++++++++++++++++++++----------------- + goo/JpegWriter.h | 25 ++++++----- + splash/SplashBitmap.cc | 2 +- + utils/pdftocairo.cc | 4 +- + 4 files changed, 95 insertions(+), 56 deletions(-) + +commit e78dbb1b7dbd20c3ae547b02270ab0648c1bfc61 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Dec 2 09:10:32 2012 +1030 + + Reformat goo/*Writer files to poppler style + + goo/ImgWriter.h | 20 ++--- + goo/JpegWriter.cc | 184 ++++++++++++++++++++++---------------------- + goo/JpegWriter.h | 38 ++++----- + goo/PNGWriter.cc | 224 + +++++++++++++++++++++++++++--------------------------- + goo/PNGWriter.h | 62 +++++++-------- + goo/TiffWriter.cc | 40 +++++----- + goo/TiffWriter.h | 58 +++++++------- + 7 files changed, 313 insertions(+), 313 deletions(-) + +commit 1bfe4b22cf893dd498d6f306ee9cf942c72fe3ed +Author: Matthias Kramm <kramm@quiss.org> +Date: Mon Nov 19 12:39:56 2012 -0800 + + Fix linewidths in monochrome mode. + + For zoom levels that scale the page below sqrt(2) of the original + resolution, monochrome line widths were wrong (snapped back to 1 pixel + wide.) This patch fixes that issue. + + splash/Splash.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e5008bdb26df0135edfbd30a811df2332f4e036c +Author: José Aliste <jaliste@src.gnome.org> +Date: Sat Dec 8 10:33:21 2012 -0300 + + glib-demo: Update the demo to modify flags of annotations + + https://bugs.freedesktop.org/show_bug.cgi?id=58015 + + glib/demo/annots.c | 65 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 65 insertions(+) + +commit 8cd5cae953de374276c11711dc106de15c8dcad0 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Dec 8 18:57:07 2012 +0100 + + regtest: Use the number of cpus as default number of worker threads + + regtest/main.py | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +commit 605c363b04ba3853883010c0a413054fe246d9aa +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Dec 8 18:45:22 2012 +0100 + + regtest: Remove trailing whitespaces + + regtest/TestReferences.py | 10 +++++----- + regtest/TestRun.py | 10 +++++----- + regtest/main.py | 6 +++--- + 3 files changed, 13 insertions(+), 13 deletions(-) + +commit 787a8438708397f0a1bf26e93726f544c91533e6 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Dec 2 08:03:10 2012 +0100 + + Fix compile warning on deprecated conversion from string constant + + Fixes (for win32): + + CXX GlobalParams.lo + GlobalParams.cc: In function 'char* get_poppler_datadir()': + GlobalParams.cc:181:12: warning: deprecated conversion from string + constant to 'char*' [-Wwrite-strings] + + poppler/GlobalParams.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit cb3a10417ae659fdb7b77132c569c93ec00bc95e +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sun Dec 2 01:41:05 2012 +0100 + + Fixed check_lexer on 32-bit systems + + qt4/tests/check_lexer.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 8550576bdf74180b62f54f9fd59213fbcd0a1be1 +Author: José Aliste <jaliste@src.gnome.org> +Date: Sat Dec 8 10:33:04 2012 -0300 + + glib: Add poppler_annot_set_flags + + https://bugs.freedesktop.org/show_bug.cgi?id=58015 + + glib/poppler-annot.cc | 22 ++++++++++++++++++++++ + glib/poppler-annot.h | 2 ++ + 2 files changed, 24 insertions(+) + +commit 15dcc5426ce319429e1a2c518902effb2ddf06cf +Author: Adam Reichold <adamreichold@myopera.com> +Date: Thu Dec 6 18:45:46 2012 +0100 + + implement parallel testing using Python's Queue class + + regtest/Printer.py | 36 +++++++++++++++++----------- + regtest/TestReferences.py | 23 +++++++++++++++++- + regtest/TestRun.py | 58 + ++++++++++++++++++++++++++++++++++++---------- + regtest/backends/cairo.py | 5 ++-- + regtest/backends/splash.py | 5 ++-- + regtest/main.py | 11 ++++++++- + 6 files changed, 104 insertions(+), 34 deletions(-) + +commit c46646020826136b403e9aae8e2ded24c7165522 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Dec 2 10:04:28 2012 +0100 + + glib-demo: Do not use deprecated gtk_color_button_{get,set}_rgba() + + Since Gtk 3.4, gtk_color_button_get_rgba() and + gtk_color_button_set_rgba() have been deprecated. + + https://bugs.freedesktop.org/show_bug.cgi?id=57798 + + glib/demo/selections.c | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +commit f8c1b55e764a6e79b0530fb1be9ee11917f4237e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 1 22:19:17 2012 +0100 + + 0.21.3 + + CMakeLists.txt | 4 ++-- + NEWS | 17 +++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 6 files changed, 23 insertions(+), 6 deletions(-) + +commit e3716d9d735a1093399a3c5c33ea5471a6adc405 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 1 22:34:00 2012 +0100 + + Build on make check correctly + + qt4/tests/check_goostring.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit c7ae96b162e8a05269a54c31f8e7c411edc84553 +Merge: 1f279c3 b1dacd1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 1 21:26:24 2012 +0100 + + Merge commit 'b1dacd1e6ab00eb1976491eb2b45c76671011b38' + +commit 1f279c32dcdc899b509fc00aaa57382bc8af90f3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 1 20:37:52 2012 +0100 + + Update copyrights + + poppler/CairoOutputDev.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 5daa17c013be8ebe180ff48207e189bd9bd50a84 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 1 20:06:17 2012 +0100 + + Initialize to NULL, fixes crash + + Since the TextStringToUCS4 not always assigns to second param, + initialize uni to NULL + + poppler/TextOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit f673be852e6564e039b5ec24e5bf583149b1d5a4 +Author: Jason Crain <jason@aquaticape.us> +Date: Sat Dec 1 20:03:00 2012 +0100 + + Allow large chars in TextPage + + poppler/TextOutputDev.cc | 1 - + 1 file changed, 1 deletion(-) + +commit aca122432951c4c0a2a5dbaba046d848f2153b84 +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Jun 23 18:27:55 2012 +0200 + + Fix compile warning on unused variable filename_g + + glib/poppler-document.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit c702066961b1cc2a9c0fb16546e9db93c312813b +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Jun 23 18:23:59 2012 +0200 + + Do not use 'size' uninitialized + + poppler/PDFDoc.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 14bdeacb0eb8e4a1d3995f310a1b526e4dcc96dc +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Jun 23 18:09:01 2012 +0200 + + Fix compile warnings on deprecated conversion from string constant to + 'char*' + + poppler/FileSpec.cc | 3 ++- + poppler/GlobalParamsWin.cc | 4 ++-- + 2 files changed, 4 insertions(+), 3 deletions(-) + +commit 72d4a1ba998218de876e2a0e939bbec4b7795299 +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Jun 23 17:52:13 2012 +0200 + + Fix compile warning on signed/unsigned comparison + + goo/gfile.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1262111e70ff161e495505bd6a262cc0357a943c +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Jun 23 17:46:54 2012 +0200 + + Remove unused variable + + goo/gfile.cc | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit 85572b85950ed4e4421f1e61e704e5c250ca27d9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 1 01:50:25 2012 +0100 + + Silence gcc warning + + Bug #57572 + + goo/TiffWriter.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit a97aead193a927b91a4e33d7b5d2ba7179e664df +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Nov 30 21:30:19 2012 +0100 + + Splash: Implement bilinear image scaling + + Bug #22138 + + poppler/SplashOutputDev.cc | 10 +-- + splash/Splash.cc | 183 + ++++++++++++++++++++++++++++++++++++++++++--- + splash/Splash.h | 13 +++- + 3 files changed, 188 insertions(+), 18 deletions(-) + +commit e6806d893a9a104e3f23d69d0245ad0e4948a409 +Author: Pino Toscano <pino@kde.org> +Date: Wed Nov 28 17:59:36 2012 +0100 + + cmake: Enable compiler warnings for C code + + Compilation of glib/demo uses a C compiler, thus compiler warnings + should be enabled in the CFLAGS variable. + + followup of 5c5945d163fe406960ccc2e3a71882722b9e69d1 + + CMakeLists.txt | 2 ++ + 1 file changed, 2 insertions(+) + +commit bdb17da35de49b9fd1a549c3afd5e36004552080 +Author: Hib Eris <hib@hiberis.nl> +Date: Mon Nov 26 20:38:03 2012 +0100 + + cairo: Fix uninitaliazed warning in CairoOutputDev + + Fix warning: + + CXX CairoOutputDev.lo + ../../poppler/poppler/CairoOutputDev.cc: In member function 'virtual + void RescaleDrawImage::getRow(int, uint32_t*)': + ../../poppler/poppler/CairoOutputDev.cc:2813:25: warning: 'pix' + may be used uninitialized in this function [-Wuninitialized] + + https://bugs.freedesktop.org/show_bug.cgi?id=57571 + + poppler/CairoOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit beff044e4fdf44e80ad7c75255cb71a83e70a293 +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Nov 27 22:19:01 2012 +0100 + + glib-demo: Fix warning on signedness + + Fixes: + + CC attachments.o + ../../../poppler/glib/demo/attachments.c: In function + ‘attachment_save_callback’: + ../../../poppler/glib/demo/attachments.c:190:2: warning: pointer + targets in passing argument 2 of ‘g_checksum_update’ differ in + signedness [-Wpointer-sign] + /usr/include/glib-2.0/glib/gchecksum.h:69:23: note: expected ‘const + guchar *’ but argument is of type ‘const gchar *’ + + https://bugs.freedesktop.org/show_bug.cgi?id=57620 + + glib/demo/attachments.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit b484749ffa58315e4b61738d652347d7a77da982 +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Nov 27 19:38:59 2012 +0100 + + glib-demo: Fix set but unused warning + + Fixes: + + CC print.o + ../../../poppler/glib/demo/print.c: In function + ‘pgd_print_draw_page’: + ../../../poppler/glib/demo/print.c:68:27: warning: variable + ‘settings’ set but not used [-Wunused-but-set-variable] + + https://bugs.freedesktop.org/show_bug.cgi?id=57620 + + glib/demo/print.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +commit 8438daf7bf7ab1b96c6899baab7e47d9c634cb3d +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Jun 24 14:54:31 2012 +0200 + + glib-demo: pgd_text_view_query_tooltip(): return a gboolean + + https://bugs.freedesktop.org/show_bug.cgi?id=57620 + + glib/demo/text.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit ff9e211cfb60eb820b9b046da546352fa59d7df9 +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Jun 23 22:56:02 2012 +0200 + + glib-demo: Remove set but unused variable textinfo + + https://bugs.freedesktop.org/show_bug.cgi?id=57620 + + glib/demo/text.c | 2 -- + 1 file changed, 2 deletions(-) + +commit 8e5ae33bc63eca5297dea12fc281ba223f5be09a +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Jun 23 22:44:22 2012 +0200 + + glib-demo: Fix warning "operation on 'page' may be undefined + [-Wsequence-point]" + + https://bugs.freedesktop.org/show_bug.cgi?id=57620 + + glib/demo/text.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit c6f98d62b885e1d7f6ce1f265d4a87dca36494de +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Jun 23 22:38:35 2012 +0200 + + glib-demo: Remove unused variable slice_selector + + https://bugs.freedesktop.org/show_bug.cgi?id=57620 + + glib/demo/render.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit da56d280e2a51229c93117d8b537897ba63296cf +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Jun 23 22:36:29 2012 +0200 + + glib-demo: Remove unused variable region + + https://bugs.freedesktop.org/show_bug.cgi?id=57620 + + glib/demo/selections.c | 1 - + 1 file changed, 1 deletion(-) + +commit c792e59064018e0fd899f32080489419517f2bbe +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Jun 23 22:34:44 2012 +0200 + + glib-demo: Do not use 'text' uninitialized + + https://bugs.freedesktop.org/show_bug.cgi?id=57620 + + glib/demo/utils.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit c5a8f7eda14030436e6905dd826e72cabbcf0e5f +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Jun 23 22:26:53 2012 +0200 + + glib-demo: Fix warning on unused variable selection + + https://bugs.freedesktop.org/show_bug.cgi?id=57620 + + glib/demo/layers.c | 1 - + 1 file changed, 1 deletion(-) + +commit 4ceb3f4f4ca0092e79bb36723a7332b071491666 +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Jun 23 18:36:12 2012 +0200 + + glib-demo: Fix warnings on unused variables + + https://bugs.freedesktop.org/show_bug.cgi?id=57620 + + glib/demo/annots.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +commit 5c5945d163fe406960ccc2e3a71882722b9e69d1 +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Nov 27 19:21:34 2012 +0100 + + Enable compiler warnings for C code + + Compilation of glib/demo uses a C compiler, thus compiler warnings + should be enabled in the CFLAGS variable. + + configure.ac | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 55940e989701eb9118015e30f4f48eb654fa34c4 +Author: Pino Toscano <pino@kde.org> +Date: Tue Nov 27 16:05:15 2012 +0100 + + fix my previous GooString::insert fix + + we need only to move the characters after the specified position, + not all of them + + extend qt4's check_goostring with few more checks covering this + (and the previous) fix + + goo/GooString.cc | 2 +- + qt4/tests/check_goostring.cpp | 39 + +++++++++++++++++++++++++++++++++++++++ + 2 files changed, 40 insertions(+), 1 deletion(-) + +commit dcbc9686d97f4f6596c43d1f701207278c25f8eb +Author: Pino Toscano <pino@kde.org> +Date: Mon Nov 26 14:44:21 2012 +0100 + + glib/cmake: Include Gio-2.0 for introspection + + Fixes g-ir-scanner warnings: + poppler-document.cc:257: Warning: Poppler: + poppler_document_new_from_stream: argument stream: Unresolved type: + 'GInputStream*' + poppler-document.cc:257: Warning: Poppler: + poppler_document_new_from_stream: argument cancellable: Unresolved + type: 'GCancellable*' + poppler-document.cc:315: Warning: Poppler: + poppler_document_new_from_gfile: argument file: Unresolved type: + 'GFile*' + poppler-document.cc:315: Warning: Poppler: + poppler_document_new_from_gfile: argument cancellable: Unresolved + type: 'GCancellable*' + + https://bugs.freedesktop.org/show_bug.cgi?id=56218 + + folloup of c84753e12029fcc6113f80dedc9a943ce1deb214 + + glib/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 169e4cb001fa235ca608d3d0b42ea4214161fc2d +Author: Pino Toscano <pino@kde.org> +Date: Mon Nov 26 14:42:59 2012 +0100 + + glib/cmake: Show all suppressed introspection scanner warnings + + https://bugs.freedesktop.org/show_bug.cgi?id=56218 + + followup of 11a1f6f512a7d7b86defeb5963fa16bc08e3ba1c + + glib/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 62c0dbbe9f1987c78eeb87f248d35e7fd73e968a +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Nov 26 00:40:57 2012 +0100 + + Check GooString::insert + + Checks we don't break what we just fixed with Pino's patch + + qt4/tests/CMakeLists.txt | 1 + + qt4/tests/Makefile.am | 7 ++++++- + qt4/tests/check_goostring.cpp | 22 ++++++++++++++++++++++ + 3 files changed, 29 insertions(+), 1 deletion(-) + +commit 01e438ca47776075c8171bda090e7d859fd9f620 +Author: Adam Reichold <adamreichold@myopera.com> +Date: Mon Nov 26 00:39:05 2012 +0100 + + Don't use memcpy to copy classes + + poppler/Function.cc | 63 + +++++++++++++++++++++++++++++++++++++++++++---------- + poppler/Function.h | 11 ++++++---- + 2 files changed, 59 insertions(+), 15 deletions(-) + +commit 7ba15d11e56175601104d125d5e4a47619c224bf +Author: Pino Toscano <pino@kde.org> +Date: Mon Nov 26 00:29:35 2012 +0100 + + fix GooString::insert() + + Hi, + + as reported in a Debian bug [1], it seems GooString::insert could lead + to using uninitialized memory. + The case is a simple: + GooString goo; + goo.insert(0, "."); + goo.insert(0, "This is a very long long test string"); + i.e. basically first insert a single character at position 0, and + then a + string longer than STR_STATIC_SIZE always at position 0. + + [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=693817 + + goo/GooString.cc | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +commit 703f85a10cf7ad61d2f2d3a5faf347fdddcb4738 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Nov 25 12:36:33 2012 +0100 + + glib: Fix returns tag in PopplerAttachmentSaveFunc api doc + + glib/poppler-attachment.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 52896031783b28cee350ea92c8736e2c2e4e9d33 +Author: José Aliste <jaliste@src.gnome.org> +Date: Mon Nov 19 23:47:19 2012 +0100 + + glib: Add missing ":" at the end of some functions documentation + + New versions of gir-scanner emit a warning when the : at + the end of the function documentation is not found. + + https://bugs.freedesktop.org/show_bug.cgi?id=56218 + + glib/poppler-annot.cc | 2 +- + glib/poppler-form-field.cc | 10 +++++----- + glib/poppler-layer.cc | 12 ++++++------ + 3 files changed, 12 insertions(+), 12 deletions(-) + +commit 60dfc1a3471f824f40b0bef5b97a7b04bd78e72b +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Oct 20 10:17:01 2012 +0200 + + glib: Exclude poppler-input-stream.h from introspection files + + Fixes warning: + + poppler-input-stream.h:28: Warning: Poppler: + symbol='inputStreamBufSize': Unknown namespace for symbol + 'inputStreamBufSize' + + https://bugs.freedesktop.org/show_bug.cgi?id=56218 + + glib/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit c84753e12029fcc6113f80dedc9a943ce1deb214 +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Oct 20 09:40:09 2012 +0200 + + glib: Include Gio-2.0 for introspection + + Fixes g-ir-scanner warnings: + poppler-document.cc:257: Warning: Poppler: + poppler_document_new_from_stream: argument stream: Unresolved type: + 'GInputStream*' + poppler-document.cc:257: Warning: Poppler: + poppler_document_new_from_stream: argument cancellable: Unresolved + type: 'GCancellable*' + poppler-document.cc:315: Warning: Poppler: + poppler_document_new_from_gfile: argument file: Unresolved type: + 'GFile*' + poppler-document.cc:315: Warning: Poppler: + poppler_document_new_from_gfile: argument cancellable: Unresolved + type: 'GCancellable*' + + https://bugs.freedesktop.org/show_bug.cgi?id=56218 + + glib/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 11a1f6f512a7d7b86defeb5963fa16bc08e3ba1c +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Oct 20 09:30:05 2012 +0200 + + glib: Show all suppressed introspection scanner warnings + + https://bugs.freedesktop.org/show_bug.cgi?id=56218 + + glib/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 16812829a7d4816717731318b1aa1bc3ab5e3935 +Author: Jason Crain <jason@aquaticape.us> +Date: Mon Aug 27 22:42:11 2012 -0500 + + Update fill and stroke color in CairoOutputDev::startPage + + Keep fill_color and stroke_color from falling out of sync with + fill_pattern and stroke_pattern. + + https://bugs.freedesktop.org/show_bug.cgi?id=54526 + + glib/poppler-page.cc | 2 +- + poppler/CairoOutputDev.cc | 2 ++ + 2 files changed, 3 insertions(+), 1 deletion(-) + +commit c93702bea0718d67660f2255344dcf9b0f502d57 +Author: José Aliste <jaliste@src.gnome.org> +Date: Tue Nov 20 11:25:41 2012 +0100 + + glib: Ensure text is only computed on first render + + Getting the text on a page could be quite slow on + complex pages without structured text. Before this patch, + poppler_page_render would reprocess the text each time + is called. + + glib/poppler-page.cc | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +commit b0297110c455eb18096268b59d6095d428380de5 +Author: Jason Crain <jason@aquaticape.us> +Date: Wed Nov 21 14:15:59 2012 -0600 + + glib: check if words end with spaces + + poppler_page_get_text_layout and poppler_page_get_text_attributes + assume that each word ends with a space or newline, causing them to + become mismatched from the text. This adds a check to + TextWord::getSpaceAfter. + + https://bugs.freedesktop.org/show_bug.cgi?id=54504 + + glib/poppler-page.cc | 62 + +++++++++++++++++++++++++++++----------------------- + 1 file changed, 35 insertions(+), 27 deletions(-) + +commit b1dacd1e6ab00eb1976491eb2b45c76671011b38 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Nov 23 00:12:24 2012 +0100 + + 0.21.2 + + CMakeLists.txt | 4 ++-- + NEWS | 13 +++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 6 files changed, 19 insertions(+), 6 deletions(-) + +commit 2d2a3af7159945c3fd54f22878e2eb09e019bbc6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Nov 23 00:06:39 2012 +0100 + + Update copyrights + + goo/TiffWriter.cc | 1 + + goo/TiffWriter.h | 1 + + poppler/CairoRescaleBox.cc | 1 + + poppler/CairoRescaleBox.h | 38 ++++++++++++++++++++++++++++++++++++++ + splash/SplashBitmap.cc | 2 +- + 5 files changed, 42 insertions(+), 1 deletion(-) + +commit e0d0177562ff546b59b3bc8eb68a08dc740d6f6c +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Nov 14 22:44:20 2012 +1030 + + cairo: Fix crash in CairoImageOutputDev with setSoftMaskFromImageMask + + Bug 57067 + + poppler/CairoOutputDev.cc | 46 + ++++++++++++++++++++++++++++++++++++++++++++++ + poppler/CairoOutputDev.h | 5 +++++ + 2 files changed, 51 insertions(+) + +commit f050717f986a6c2833876d14083363a540fa849a +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Nov 14 23:50:10 2012 +1030 + + cairo: fix soft mask when image resolution != smask resolution + + Both image and mask are drawn the same size (unit square) regardless + of the size of the image data. + + Bug 57070 + + poppler/CairoOutputDev.cc | 12 +++--------- + 1 file changed, 3 insertions(+), 9 deletions(-) + +commit 87fd5275514b63f13622b79a8fcfe443ccc4f45d +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Nov 11 18:53:12 2012 +1030 + + cairo: make drawImage work with images > 32767 in width/height + + Cairo images are limited to 32767 in width and height due to the + 16.16 format used by pixman. Make drawImage work with large images + by scaling down the image before a cairo image is created. + + CairoRescaleBox.cc has been turned into a class with a virtual + function to get the next row of the source image. This allows the + rescale code to access the source data one row at a time to avoid + needing to allocate an image the size of the source image. + + A RescaleDrawImage class derived from CairoRescaleBox has been + written to create the cairo source image to be used by drawImage. The + code from drawImage that created the cairo source image has been moved + into RescaleDrawImage::getSourceImage and RescaleDrawImage::getRow. + + Bug 56858 + + poppler/CairoOutputDev.cc | 278 + ++++++++++++++++++++++++--------------------- + poppler/CairoRescaleBox.cc | 177 +++++++++++++++-------------- + poppler/CairoRescaleBox.h | 21 +++- + 3 files changed, 258 insertions(+), 218 deletions(-) + +commit d1c509c48fc422649d0c2c2d70af5e13e3472874 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Nov 17 10:04:55 2012 +1030 + + pdftocairo: add tiff support + + Bug 57006 + + utils/pdftocairo.1 | 23 ++++++++------ + utils/pdftocairo.cc | 88 + +++++++++++++++++++++++++++++++++++++++++------------ + 2 files changed, 83 insertions(+), 28 deletions(-) + +commit 6d3fe48cf30b298b4436462904d781ea441c1f3d +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Nov 17 10:03:22 2012 +1030 + + tiff: remove splash dependency and add RGBA support + + Bug 57006 + + goo/TiffWriter.cc | 47 + +++++++++++++++++++---------------------------- + goo/TiffWriter.h | 13 ++++++++++--- + splash/SplashBitmap.cc | 23 +++++++++++++++++++++-- + 3 files changed, 50 insertions(+), 33 deletions(-) + +commit 15f600a5702788f7e5b91cd67bc2438179921939 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Nov 15 22:17:27 2012 +0100 + + Don't do a check for sanity that then we don't use + + Fixes bugs 56753 and 51684 + + fofi/FoFiTrueType.cc | 26 -------------------------- + 1 file changed, 26 deletions(-) + +commit c7e3c2d7087e4fc36564ba7bd55e27e100e0a5e5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 14 14:58:45 2012 +0100 + + Remove unused code + + fofi/FoFiTrueType.cc | 658 + ------------------------------------------- + fofi/FoFiTrueType.h | 11 +- + splash/SplashFTFontEngine.cc | 42 +-- + 3 files changed, 2 insertions(+), 709 deletions(-) + +commit 06951f529e6514a0c26d6d821ab5fab0920a7cf3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Nov 13 23:37:22 2012 +0100 + + Simplify >= 0 ifs for unsigned + + cpp/poppler-global.cpp | 8 ++------ + 1 file changed, 2 insertions(+), 6 deletions(-) + +commit fa813adc3f7b7ee3cc819f1e0cb85e01f13c2c01 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Nov 13 23:37:01 2012 +0100 + + Remove < 0 ifs for unsigned + + splash/SplashFTFont.cc | 8 -------- + 1 file changed, 8 deletions(-) + +commit 1969bcd693289eba1138fcaa74a684cb3ff2aefc +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Nov 13 23:36:40 2012 +0100 + + Remove unused members + + poppler/Gfx.cc | 3 --- + poppler/Gfx.h | 5 +---- + 2 files changed, 1 insertion(+), 7 deletions(-) + +commit 3a6e5ed5e28b6113696a7ae60b0b85d7097eb731 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Nov 13 23:35:53 2012 +0100 + + Remove >= 0 checks for unsigned variables + + utils/HtmlFonts.cc | 6 +++--- + utils/HtmlFonts.h | 4 ++-- + 2 files changed, 5 insertions(+), 5 deletions(-) + +commit 0dcc2d711810dd64aa8d8721ce53a6b72e12c47c +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Nov 13 23:35:10 2012 +0100 + + Remove unused var + + utils/pdfinfo.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1fc97862d30bf723135310bfc8701e6788bfd284 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Nov 13 23:24:19 2012 +0100 + + size can't be smaller than 0 because it's a size_t + + goo/gmem.cc | 22 +--------------------- + 1 file changed, 1 insertion(+), 21 deletions(-) + +commit bb801a9b889bc0e62cf8b853c26cc6636b4af9a1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Nov 13 22:51:17 2012 +0100 + + Removed unused var + + utils/pdfinfo.cc | 1 - + 1 file changed, 1 deletion(-) + +commit fd651fb49653e89d96b032e010a7d8e891536bb0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Nov 12 00:42:49 2012 +0100 + + Parse the args (so that -v says vesion only) + + Fixes bug #56817 + + utils/pdfunite.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 7e2e9567f51d01be9a88848e1141c6d4f0f768a1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Nov 9 20:02:25 2012 +0100 + + 0.21.1 + + CMakeLists.txt | 4 ++-- + NEWS | 14 ++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/CMakeLists.txt | 2 +- + qt4/src/Doxyfile | 2 +- + qt4/src/Makefile.am | 2 +- + 8 files changed, 22 insertions(+), 8 deletions(-) + +commit 98b7cfd289abb53a745a88d6ec99e95df477fc8f +Merge: 40efa72 d254174 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Nov 9 00:38:19 2012 +0100 + + Merge remote-tracking branch 'origin/poppler-0.20' + + Conflicts: + poppler/Form.cc + +commit 40efa72987ebf62cbf2c761c10a209e2e6be612e +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sun Nov 4 11:20:29 2012 +0100 + + Replaced forward declaration of enum CryptAlgorithm with a proper + #include + + Forward-declaring enums is illegal. It hasn't caused problems so far + because XRef.h includes Object.h, which in turn includes Stream.h, + where + the enum is defined. + Therefore, enum is alreadly defined when the compiler reaches + that line. + + To avoid future issues, I've replaced it with a proper #include + "Stream.h" + (which expands to nothing as Stream.h has already been included + at that + point). + + I've also added a #include in XRef.h because it references enum + CryptAlgorithm too. Also in this case, it expands to nothing. + + poppler/PDFDoc.h | 2 +- + poppler/XRef.h | 1 + + 2 files changed, 2 insertions(+), 1 deletion(-) + +commit 0f7c17d7f92d4cdfbd8816dba666aeed924d8bc2 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Fri Nov 2 10:54:17 2012 +0100 + + qt4: Export information about the document form type + + This patch also wraps the code that checks the form type and moves it + from pdfinfo to the Catalog class. + + poppler/Catalog.cc | 19 +++++++++++++++++++ + poppler/Catalog.h | 9 +++++++++ + qt4/src/poppler-document.cc | 16 ++++++++++++++++ + qt4/src/poppler-qt4.h | 18 ++++++++++++++++++ + utils/pdfinfo.cc | 19 ++++++++++--------- + 5 files changed, 72 insertions(+), 9 deletions(-) + +commit f3f5a166bcd16b6f2cb516cceb2b3f41b6faf0b4 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Fri Nov 2 01:53:24 2012 +0100 + + Editable FormFieldChoice: Clear editedChoice when one of the + predefined option is selected + + This patch clears the user-entered text when the user interacts with + predefined options. + + poppler/Form.cc | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +commit ddcd5dc0ceecc02f0d4f740cb6c9b557dfd33c74 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Thu Nov 1 00:58:51 2012 +0100 + + FormFieldChoice ctor: Added support to recognize user strings as + /V value + + Fixes + http://lists.freedesktop.org/archives/poppler/2012-October/009688.html + + poppler/Form.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 1302bf52bba7e6446f01358240a4b5b583e196a9 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Oct 31 19:56:37 2012 +0100 + + FormFieldChoice ctor: Stop scanning if /V is a string and the + corresponding option has been identified + + poppler/Form.cc | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +commit d254174e08146115ad04ac1f1bf82bb26e56c684 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Oct 31 16:57:56 2012 +0100 + + FormFieldChoice::updateSelection: Fixed wrong loop condition + + poppler/Form.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 401de95f5ab42ab0f5d8fd92d76b5def50f84a2b +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Oct 31 19:43:51 2012 +0100 + + FormFieldChoice ctor: Look for selected options in /I instead of /V + if /I is available + + Since /I stores the indices of the selected options, it can + distinguish + duplicate option (i.e. options with the same name/export value). + + poppler/Form.cc | 71 + ++++++++++++++++++++++++++++++++++----------------------- + 1 file changed, 42 insertions(+), 29 deletions(-) + +commit cfd3a46a857100cb634e18192b762e7342165348 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Oct 31 15:44:32 2012 +0100 + + FormFieldChoice: Handle /V values containing the export value instead + of the option name + + According to the PDF spec, /V should always contain an "option + name" and + never an "export value" if /Opt is an array of couples. However, it + seems that acroread works the other way round: it is able to identify + selected options only if they are referred by their export value + instead of the option name. + With this patch, we mimic this behavior. + + poppler/Form.cc | 49 ++++++++++++++++++++++++++++++++++--------------- + 1 file changed, 34 insertions(+), 15 deletions(-) + +commit ce99940bcac0447f32ee2ad46efb09af93989c12 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Oct 13 00:13:33 2012 +0200 + + FormFieldChoice::updateSelection: Write /I too + + This improves handling of choice fields containing two or more entries + with the same name, and also makes sure that the previous value of /I + gets updated (failing to update it results in acroread still showing + the old selection). + + poppler/Form.cc | 50 ++++++++++++++++++++++++++++++++++++-------------- + 1 file changed, 36 insertions(+), 14 deletions(-) + +commit 102553e2104a1b223c8ac924aa6702829adebbdb +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Oct 31 16:57:56 2012 +0100 + + FormFieldChoice::updateSelection: Fixed wrong loop condition + + poppler/Form.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit d7522ea1d2e66beef64f705e8986142f15fcf613 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Oct 31 15:26:37 2012 +0100 + + FormFieldChoice ctor: Don't convert "human-readable" option names + to unicode + + Despite that comment, they're not meant to be read by humans only, + but they + are also used as option identifiers. + + This patch stops poppler from forcing them to be unicode. Instead, + they now stay the same encoding as their corresponding /Opt entry. + + This fixes poppler not being able to recognize selected entries + in documents produced by poppler itself: previously, the /V value was + always written in Unicode encoding, and therefore it was very + often not + binary-equal to the corresponding /Opt entry. + Now the /V value is always binary-equal to the corresponding /Opt + entry. + + poppler/Form.cc | 16 +--------------- + 1 file changed, 1 insertion(+), 15 deletions(-) + +commit da08ebeee241198907378c6461721fddb5106875 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Oct 28 12:13:22 2012 +1030 + + Don't allow invalid unicode to be passed to backends + + poppler/CharCodeToUnicode.cc | 11 +++++++++-- + poppler/UTF.cc | 11 +++++++++++ + poppler/UTF.h | 4 ++++ + 3 files changed, 24 insertions(+), 2 deletions(-) + +commit 9f92feda5eff9b2542c64349f33ae3cf250e7f4b +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Fri Nov 2 23:05:55 2012 +0100 + + Memory leak in CharCodeToUnicode + + Bug #54702 + + poppler/CharCodeToUnicode.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit ef11b4f0e642dff0be02bf3327eb56bf0b364847 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Fri Nov 2 22:44:27 2012 +0100 + + Implement overprint in qt interface + + With minor api fixes by me (Albert Astals Cid) + + qt4/src/poppler-document.cc | 23 ++++++++++++--- + qt4/src/poppler-page.cc | 38 +++++++++++++----------- + qt4/src/poppler-private.h | 69 + ++++++++++++++++++++++++++++---------------- + qt4/src/poppler-qt4.h | 11 ++++++- + splash/SplashBitmap.cc | 70 + +++++++++++++++++++++++++++++++++++++++++++++ + splash/SplashBitmap.h | 5 +++- + 6 files changed, 169 insertions(+), 47 deletions(-) + +commit ae8fc0cbfc6123189e17b3cf1286e0540f181646 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Oct 30 21:22:04 2012 +1030 + + cairo: support parameterized Gouraud shading + + Bug 56463 + + poppler/CairoOutputDev.cc | 19 +++++++++++++++---- + 1 file changed, 15 insertions(+), 4 deletions(-) + +commit 3be4e835d765f2f060e2a2e07dd23905c3212cdd +Author: Pino Toscano <pino@kde.org> +Date: Wed Oct 24 18:37:06 2012 +0200 + + dos2unix + + utils/pdftoppm.cc | 876 + +++++++++++++++++++++++++++--------------------------- + 1 file changed, 438 insertions(+), 438 deletions(-) + +commit 77a980472e76b568346a49057b0217111a14a4cd +Merge: 74d6217 46fb365 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Oct 23 00:23:53 2012 +0200 + + Merge remote-tracking branch 'origin/poppler-0.20' + +commit 46fb3653c7ae44c34d12d799df8f70d649eaa995 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Oct 23 00:22:55 2012 +0200 + + Fix the or-ing of flags + + qt4/src/poppler-document.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 74d6217ba164fdfe263b4edac8047b60506e39a6 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Oct 21 17:48:57 2012 +0200 + + regstest: Add print_test_result_ln() and use it for failed test + results + + To make sure they are always shown. + + regtest/Printer.py | 3 +++ + regtest/TestRun.py | 10 +++++----- + 2 files changed, 8 insertions(+), 5 deletions(-) + +commit 4e9b8d2cca44241a501bb8095b3980d17fcda6c5 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Oct 21 17:48:22 2012 +0200 + + regtest: Do not rewrite lines in verbose mode + + regtest/Printer.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 2a25264afe3c59931f6a3638e2d6c6c2e0e5dfba +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Oct 19 17:22:56 2012 +0200 + + make static + + because i can + + qt4/tests/check_fonts.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit bc4a54c0a4430216c9aeaf2c3bddbaeef5a004e4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Oct 19 17:22:13 2012 +0200 + + Compile with clang + + qt4/tests/check_fonts.cpp | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit f38194cfae8f8690bc3767cbdcf140519564366c +Merge: 80cf434 5312984 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Oct 19 00:02:02 2012 +0200 + + Merge remote-tracking branch 'origin/poppler-0.20' + +commit 5312984b40355b067001704e9c688ea0a72b1159 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Oct 19 00:00:53 2012 +0200 + + Define the numbers a bit better so gcc in i386 understands them better + + qt4/tests/check_lexer.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 80cf43472e5913f5f64bf73cb4a8ac5a53063f2e +Author: Adam Reichold <adamreichold@myopera.com> +Date: Wed Oct 17 08:27:13 2012 +0200 + + added accessors for FormWidgetChoice::editChoice property to qt4 + frontend + + qt4/src/poppler-form.cc | 23 +++++++++++++++++++++++ + qt4/src/poppler-form.h | 15 +++++++++++++++ + 2 files changed, 38 insertions(+) + +commit 0b3ff2dc4e1ba37dd66f5913b10a9d69e31c40ce +Merge: fb5cb0f 528b64b +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Oct 17 00:28:40 2012 +0200 + + Merge remote-tracking branch 'origin/poppler-0.20' + + Conflicts: + CMakeLists.txt + NEWS + configure.ac + cpp/Doxyfile + poppler/Annot.cc + poppler/Form.h + qt4/src/Doxyfile + +commit 528b64bb077ed37c0d8fc7ae2ef3dc2c0dbb26ca +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Tue Sep 4 23:10:17 2012 +0200 + + Free entries in the xref form a linked list: terminate it properly + when writing the XRef + + The last entry must point back to object 0. Previously it was left + unitialized and resulted in "-000000001 00000 f" being written in the + XRef table. + + poppler/XRef.cc | 1 + + 1 file changed, 1 insertion(+) + +commit fb5cb0fbdfcd06556661b38b0c598922fff2d759 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Thu Oct 4 11:20:42 2012 +0200 + + Create the 24x24 rectangle for text annotation icons from the top-left + corner instead of bottom-left + + poppler/Annot.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 35c07fe40d7b18e19f6ef0f5615f9f5ac8195cf7 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Tue Oct 9 15:24:02 2012 +0200 + + AnnotWidget: Avoid repeatedly deleting and creating xref entries + for appearance streams + + Previously updating the appearance stream always involved deleting + the old + stream's xref entry and creating a new one. + Since xref entry deletion causes the generation number to be + incremented, this + behavior caused the generation number to quickly rise during user + input. + + This patch stops it by reusing the same entry as the old appearance + stream in + case of repeated modifications. + + poppler/Annot.cc | 40 ++++++++++++++++++++++++++++------------ + poppler/Annot.h | 1 + + 2 files changed, 29 insertions(+), 12 deletions(-) + +commit 2127a977bbe9985aa58561116508ad4f08430a2c +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Tue Oct 9 12:49:26 2012 +0200 + + Generate and write the appearance stream in + AnnotWidget::updateWidgetApperance() + + Note: At the moment the old appearance is deleted and a *new* xref + entry is + created every time AnnotWidget::updateWidgetApperance() is called. + + poppler/Annot.cc | 30 +++++++++++++++++++++++++----- + 1 file changed, 25 insertions(+), 5 deletions(-) + +commit 0446e2cc1073f4579a90284d28bc5872e46e0536 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Tue Oct 9 10:47:40 2012 +0200 + + Killed FormField::isModified() in favor of a new AnnotWidget callback + + Instead of having to ask FormField from AnnotWidget::draw if the + widget's appearance needs to be rebuilt, now AnnotWidget gets notified + of changes via the new AnnotWidget::updateAppearanceStream() callback. + + poppler/Annot.cc | 16 ++++++++++------ + poppler/Annot.h | 1 + + poppler/Form.cc | 52 + ++++++++++++++++++++++++++++++++++++++-------------- + poppler/Form.h | 12 +++++++++--- + 4 files changed, 58 insertions(+), 23 deletions(-) + +commit 68d732ab2d55ae15e194ececfffa753977fae84c +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Tue Oct 9 15:24:02 2012 +0200 + + AnnotWidget: Avoid repeatedly deleting and creating xref entries + for appearance streams + + Previously updating the appearance stream always involved deleting + the old + stream's xref entry and creating a new one. + Since xref entry deletion causes the generation number to be + incremented, this + behavior caused the generation number to quickly rise during user + input. + + This patch stops it by reusing the same entry as the old appearance + stream in + case of repeated modifications. + + poppler/Annot.cc | 40 ++++++++++++++++++++++++++++------------ + poppler/Annot.h | 1 + + 2 files changed, 29 insertions(+), 12 deletions(-) + +commit e2993cc9551dc7521528904646f941c9747473f7 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Tue Oct 9 12:49:26 2012 +0200 + + Generate and write the appearance stream in + AnnotWidget::updateWidgetApperance() + + Note: At the moment the old appearance is deleted and a *new* xref + entry is + created every time AnnotWidget::updateWidgetApperance() is called. + + poppler/Annot.cc | 30 +++++++++++++++++++++++++----- + 1 file changed, 25 insertions(+), 5 deletions(-) + +commit df924493922e8c0f7b1e19c2847d33b28a098913 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Tue Oct 9 10:47:40 2012 +0200 + + Killed FormField::isModified() in favor of a new AnnotWidget callback + + Instead of having to ask FormField from AnnotWidget::draw if the + widget's appearance needs to be rebuilt, now AnnotWidget gets notified + of changes via the new AnnotWidget::updateAppearanceStream() callback. + + poppler/Annot.cc | 16 ++++++++++------ + poppler/Annot.h | 1 + + poppler/Form.cc | 52 + ++++++++++++++++++++++++++++++++++++++-------------- + poppler/Form.h | 12 +++++++++--- + 4 files changed, 58 insertions(+), 23 deletions(-) + +commit 0a5bda01ace9f8576d687c5a28feb5cf09b48a92 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Oct 14 23:05:27 2012 +0200 + + New/old header for cmake buildsystem + + CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit 6d46f0b477143eb0df09f718e96dd2ff2a7dd61b +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Sep 22 20:50:07 2012 +0200 + + Split our UTF.h into xpdf based UTF8.h and a poppler specific UTF.h + + poppler/GlobalParams.cc | 2 +- + poppler/Makefile.am | 1 + + poppler/UTF.h | 79 + +--------------------------------------------- + poppler/UTF8.h | 84 + +++++++++++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 87 insertions(+), 79 deletions(-) + +commit 03cbba935c90ce9a6d9ad44f7cda4901c2f81f2e +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Sep 22 19:58:40 2012 +0200 + + Do not use mapUTF8() directly in CairoOutputDev + + poppler/CairoOutputDev.cc | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +commit f219bdbcadcb0334d595bbd9afd01f00c37d1978 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Oct 14 22:59:55 2012 +0200 + + Make sure array index is >= 0 + + Fixes this warning on array subscript type: + UTF.cc: In function 'int TextStringToUCS4(GooString*, Unicode**)': + UTF.cc:99:33: warning: array subscript has type 'char' + [-Wchar-subscripts] + + poppler/UTF.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 65a2555607e03c94d77ae9ebdb34ab6d4f8844b6 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Fri Oct 12 23:54:57 2012 +0200 + + FormFieldChoice ctor: Fixed wrong index variable + + It caused a crash if multiple items are initially selected. + + poppler/Form.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 710bb3383306a9aa6debbfe1364029ee12a15576 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Fri Oct 12 23:54:57 2012 +0200 + + FormFieldChoice ctor: Fixed wrong index variable + + It caused a crash if multiple items are initially selected. + + poppler/Form.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ce18c9b3d5251305eb76d294fdf4b4de9382b3a4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Oct 10 19:54:57 2012 +0200 + + 0.20.5 + + CMakeLists.txt | 2 +- + NEWS | 15 +++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + 5 files changed, 19 insertions(+), 4 deletions(-) + +commit b112602334a5de84ae30c2e90d9bc6d4609f7f96 +Author: Tobias Koening <tobias.koenig@kdab.com> +Date: Mon Oct 8 22:32:34 2012 +0200 + + [qt4] make LinkRendition properties available + + Bug #55378 + + poppler/Link.cc | 34 +++++++++++++++++++----- + poppler/Link.h | 17 +++++++++--- + qt4/src/poppler-annotation.cc | 2 -- + qt4/src/poppler-annotation.h | 1 + + qt4/src/poppler-link.cc | 60 + ++++++++++++++++++++++++++++++++++++++++--- + qt4/src/poppler-link.h | 57 + +++++++++++++++++++++++++++++++++++++--- + qt4/src/poppler-page.cc | 8 +++++- + 7 files changed, 158 insertions(+), 21 deletions(-) + +commit 6d6bd660dbb652f2f3e87c81c55a87d1fc11ec70 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Oct 6 10:26:55 2012 +0200 + + glib: chain up finalize to the parent class + + This was missing in some of the classes. + + https://bugs.freedesktop.org/show_bug.cgi?id=55521 + + glib/poppler-document.cc | 6 ++++++ + glib/poppler-page.cc | 2 ++ + 2 files changed, 8 insertions(+) + +commit ac3875a9e7f2f4f31881d3d1b3081f2adaef65a1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Oct 6 10:26:55 2012 +0200 + + glib: chain up finalize to the parent class + + This was missing in some of the classes. + + https://bugs.freedesktop.org/show_bug.cgi?id=55521 + + glib/poppler-document.cc | 6 ++++++ + glib/poppler-page.cc | 2 ++ + 2 files changed, 8 insertions(+) + +commit 042d332c1c9f628e3bfaabf3da9e04436a8677b5 +Merge: 7b9a9f8 e044814 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 4 00:53:01 2012 +0200 + + Merge remote-tracking branch 'origin/poppler-0.20' + +commit e044814c0657a6c5b44939a01dcbdc8d83396d43 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Thu Oct 4 00:51:04 2012 +0200 + + Do not render invalid outlines + + Bug #55573 + + splash/SplashFTFont.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 7b9a9f809d07303fe5adff9210731613df8b2adf +Merge: 3b0962c 9451b7a +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Oct 3 01:24:04 2012 +0200 + + Merge remote-tracking branch 'origin/poppler-0.20' + +commit 9451b7a61b6dcaa6c4a76f3efda82f1ebd408654 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Oct 3 01:21:45 2012 +0200 + + Fix crash when parsing some unknown colorspaces + + Can't do csObj->getName if csObj is a dict + + poppler/GfxState.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 3b0962cd14b15ce92c0916f58ed5ba00aebe80b0 +Merge: a9d7ea2 42908e6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Oct 2 19:51:48 2012 +0200 + + Merge remote-tracking branch 'origin/poppler-0.20' + +commit 42908e6e72d95cec0f70b202c4b1c23f7e47c2a4 +Author: Lu Wang <coolwanglu@gmail.com> +Date: Tue Oct 2 19:31:04 2012 +0200 + + support automake-1.12 in autogen.sh + + Bug #55541 + + autogen.sh | 15 ++++++++------- + 1 file changed, 8 insertions(+), 7 deletions(-) + +commit a9d7ea2eb549acbf6ca7e2a299ffed46ff3d8758 +Merge: 397d7b4 9bb6845 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 26 15:31:29 2012 +0200 + + Merge remote-tracking branch 'origin/poppler-0.20' + + Conflicts: + poppler/XRef.cc + +commit 9bb68456de41d24db7acf61204bc3f4e36e98505 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 26 15:13:47 2012 +0200 + + Initilize rootNum + + Fixes valgrind warnings about uninitialized uses + + poppler/XRef.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 397d7b4597ad4bc8ab41fd7a99078473a3c93eb0 +Merge: 6013d49 2c0f70a +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 26 15:00:04 2012 +0200 + + Merge remote-tracking branch 'origin/poppler-0.20' + +commit 2c0f70afff03798165c2b609e115dc7e9c034c57 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Wed Sep 26 14:58:05 2012 +0200 + + More crash fixes for broken documents + + poppler/JPXStream.cc | 97 + ++++++++++++++++++++++++++++++++++++++++++++-------- + 1 file changed, 82 insertions(+), 15 deletions(-) + +commit 78558d24692c68212da35a88deb68069c5a06d81 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Wed Sep 26 14:32:05 2012 +0200 + + Fix more crashes in broken files + + solves 1258.pdf.SIGSEGV.dee.288 and 1255.pdf.asan.38.285, extends + 1043.pdf.asan.47.50 and 557.pdf.asan.47.894 + + poppler/GfxState.cc | 26 +++++++++++++++++++++++--- + 1 file changed, 23 insertions(+), 3 deletions(-) + +commit e8822c0f3a46195ec7c6e55c556dd0c5716be742 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 26 14:21:46 2012 +0200 + + Add unlikelys + + poppler/Stream.cc | 32 ++++++++++++++++---------------- + 1 file changed, 16 insertions(+), 16 deletions(-) + +commit 31874f2e065b0d68f726ef404de98f42489c80c7 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Wed Sep 26 14:17:00 2012 +0200 + + Less crashes in broken files + + rebased patch for 1001.pdf.asan.2a.4, extends patch for + 100.pdf.asan.38.2 + + poppler/Stream.cc | 100 + ++++++++++++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 98 insertions(+), 2 deletions(-) + +commit 81b1d9207840ec1e66eef469b29a36a8556b7265 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 26 13:38:54 2012 +0200 + + Add some unlikelys + + poppler/JBIG2Stream.cc | 28 ++++++++++++++-------------- + 1 file changed, 14 insertions(+), 14 deletions(-) + +commit 9ae1184e3049cabc695c8645a10eaef748b6e641 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Wed Sep 26 12:32:26 2012 +0200 + + More fixes against broken files + + solves 121.pdf.asan.6f.235, extends 682.pdf.SIGFPE.f3.1033 and + 569.pdf.SIGSEGV.c1.907, extends Patch for 829. and 839. asan and + sigsegv series + + poppler/JBIG2Stream.cc | 105 + +++++++++++++++++++++++++++++++++++++++++++------ + 1 file changed, 93 insertions(+), 12 deletions(-) + +commit 1d72c14b3877ae730ac0aa92f36923269e8a2004 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Wed Sep 26 11:48:14 2012 +0200 + + Fix crash in 158.pdf.asan.d.451 + + poppler/SplashOutputDev.cc | 8 ++++++++ + 1 file changed, 8 insertions(+) + +commit 6013d49d852c58c4c23f787fd7dd64731c0918f1 +Merge: b97c28c 671df5d +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 26 00:53:28 2012 +0200 + + Merge remote-tracking branch 'origin/poppler-0.20' + +commit 671df5dad0732882ceb9e053c3f947dfe0597f3d +Author: Lu Wang <coolwanglu@gmail.com> +Date: Wed Sep 26 00:52:32 2012 +0200 + + Don't close the stream if it's not a stream + + poppler/PSOutputDev.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit b97c28c42a18d1c2a8fabea52c092d948811d582 +Merge: 32bb874 f8c116f +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 25 23:22:23 2012 +0200 + + Merge remote-tracking branch 'origin/poppler-0.20' + + Conflicts: + qt4/src/Makefile.am + +commit f8c116f1e0fbf3516ce228fbb34c33d6b618bed0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 25 23:07:55 2012 +0200 + + Add LCMS_FLAGS + + Fixes compilation when lcms is on non standard locations + Bug #55326 + + qt4/src/Makefile.am | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 32bb87419c360a3b14c717c0f385198b70a1b2e7 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 23 18:15:13 2012 +0200 + + regtest: Reduce the noise of the default output when running tests + + Show permanent information only about failed tests, without the + details + about the failing pages. Previous verbose output is available passing + --verbose command line output. + + regtest/Printer.py | 96 + +++++++++++++++++++++++++++++++++++++ + regtest/TestReferences.py | 8 ++-- + regtest/TestRun.py | 35 +++++++------- + regtest/backends/__init__.py | 13 +++-- + regtest/commands/create-refs.py | 3 +- + regtest/commands/find-regression.py | 5 +- + regtest/commands/run-tests.py | 3 +- + regtest/main.py | 3 ++ + 8 files changed, 137 insertions(+), 29 deletions(-) + +commit ca6afce24aac2ef9d88e215177b11760f7468a6d +Author: Lu Wang <coolwanglu@gmail.com> +Date: Fri Sep 21 21:33:05 2012 +0200 + + Do not call drawing routines if we don't need non text + + Bug #54617 + + poppler/Gfx.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 70030b91ce2280f23c3e5adf863f1d336c9c5faf +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 21 08:18:29 2012 +0200 + + Increase sonames + + CMakeLists.txt | 2 +- + glib/CMakeLists.txt | 2 +- + glib/Makefile.am | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/CMakeLists.txt | 2 +- + qt4/src/Makefile.am | 2 +- + 6 files changed, 6 insertions(+), 6 deletions(-) + +commit 2323e38f1a54cb58ec31b4cf15e6c2b1db742ca5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 21 08:12:52 2012 +0200 + + Version increase + + CMakeLists.txt | 4 ++-- + configure.ac | 4 ++-- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + 4 files changed, 6 insertions(+), 6 deletions(-) + +commit 11a9a620276d199701be5811eb63687ace85ace1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 21 08:10:15 2012 +0200 + + Drop the s from AdditionalActionsType + + qt4/src/poppler-annotation-private.h | 5 +++-- + qt4/src/poppler-annotation.cc | 6 +++--- + qt4/src/poppler-annotation.h | 6 +++--- + 3 files changed, 9 insertions(+), 8 deletions(-) + +commit 028e0e7ddf8c30d311feb937385ef21acd34a52d +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 20 18:13:08 2012 +0200 + + 0.21.0 news + + NEWS | 39 +++++++++++++++++++++++++++++++++++++++ + 1 file changed, 39 insertions(+) + +commit 2f2d053352e04e434d83dd93dfdbd08ab5b23f2e +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 20 18:12:57 2012 +0200 + + Update copyrights + + poppler/Annot.cc | 3 ++- + poppler/Annot.h | 1 + + poppler/TextOutputDev.cc | 2 +- + poppler/UTF.h | 1 + + 4 files changed, 5 insertions(+), 2 deletions(-) + +commit 9fad83913791478b63fc76360f1a13e955cdcf4a +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 17 23:15:10 2012 +0200 + + Move to init + + poppler/XRef.cc | 11 +++-------- + 1 file changed, 3 insertions(+), 8 deletions(-) + +commit c470a3929c0a02b8a543fcada22138ab1fc18176 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Mon Sep 17 23:13:48 2012 +0200 + + Support encrypted pdf files in pdfseparate + + poppler/PDFDoc.cc | 35 ++++++++++++++++++++++++++++++++--- + poppler/XRef.cc | 15 +++++++++++++++ + poppler/XRef.h | 2 ++ + utils/pdfseparate.cc | 4 ---- + 4 files changed, 49 insertions(+), 7 deletions(-) + +commit 9b613dcf3c77bc2801d1125dc9bbc5a4dd04e16b +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 17 23:12:43 2012 +0200 + + Compile + + goo/TiffWriter.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit fb5c383bd5be7090fc78380b4bb3244c3316c0cd +Author: William Bader <williambader@hotmail.com> +Date: Mon Sep 17 00:03:49 2012 +0200 + + Make pdftoppm -tiff -overprint work + + Bug #54896 + + goo/TiffWriter.cc | 13 ++++++++++++- + goo/TiffWriter.h | 4 +++- + 2 files changed, 15 insertions(+), 2 deletions(-) + +commit 3794916572a0531b10ee57c9f189497489b90bc8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 16 17:53:47 2012 +0200 + + Fix the siblings field correctly + + Fixes KDE bug #302334 + + poppler/Form.cc | 45 + +++++++++++++++++++++++++-------------------- + poppler/Form.h | 24 +++++++++++++----------- + qt4/src/poppler-form.cc | 13 ++++++++++--- + 3 files changed, 48 insertions(+), 34 deletions(-) + +commit e8b6d2ac3a874dd5de166b52625fa628004ea5fe +Merge: 7cb4072 9f51baa +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 16 14:08:34 2012 +0200 + + Merge remote-tracking branch 'origin/poppler-0.20' + +commit 9f51baaf7a86680f2195ecdb978f1eb59a8aa734 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 16 14:07:45 2012 +0200 + + Rework the #ifdef so that i don't get a gcc warning + + poppler/strtok_r.cpp | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit b63049f97629a93ec346033e0ec56fc11f34c4fe +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 16 14:05:01 2012 +0200 + + Forgot to add the new test to autotools + + qt4/tests/Makefile.am | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +commit 7cb40726f9e80ee2b2f27ca6ce151b46c6ec091d +Merge: e980d11 c6d7084 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 16 13:50:19 2012 +0200 + + Merge remote-tracking branch 'origin/poppler-0.20' + +commit c6d7084d316e94b5b042b086f5440f8543ff5947 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 16 13:48:51 2012 +0200 + + Fix parsing of numbers + + -2147483648 is an integer + -2147483649 is a real + + poppler/Lexer.cc | 14 +++++- + qt4/tests/CMakeLists.txt | 1 + + qt4/tests/check_lexer.cpp | 118 + ++++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 131 insertions(+), 2 deletions(-) + +commit e980d11061c19f13c75f93506e07903b4d1c7f97 +Merge: b72c02d 3658088 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 15 20:41:50 2012 +0200 + + Merge remote-tracking branch 'origin/poppler-0.20' + +commit 365808837080574080b4f8da079124c172fb2123 +Author: Alexey Pavlov <alexpux@gmail.com> +Date: Sat Sep 15 20:38:10 2012 +0200 + + Fix build using mingw64 with winpthread + + strtok_r in winpthread is declared as a macro, that is why + the error happens. Therefore, it is necessary to check whether + the macro + __WINPTHREADS_VERSION is declared. + + Bug #54851 + + poppler/poppler-config.h.cmake | 2 +- + poppler/poppler-config.h.in | 2 +- + poppler/strtok_r.cpp | 16 +++++++++++++++- + 3 files changed, 17 insertions(+), 3 deletions(-) + +commit b72c02d1a2ec8180b3ddfd2bb2b462c0189377d5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 13 19:56:45 2012 +0200 + + Remove the fonts loop + + sometimes it's very slow and doesn't really add much + + qt4/tests/test-poppler-qt4.cpp | 4 ---- + 1 file changed, 4 deletions(-) + +commit cb93d51ccb6b1f6938946ae5d38fb9817005fd7a +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 12 00:12:07 2012 +0200 + + Make gcc happy + + It is stupid and can't see that we only use them when we init them + and complains + they might be used un-initialized + + poppler/TextOutputDev.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 3349a8dd7e0469cc5b5aaa8dd929c6078183ef86 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Wed Sep 12 00:04:45 2012 +0200 + + Splash: Avoid bogus memory error for tilingPattern + + just return gFalse if the resulting + tiling pattern bitmap reaches a memory limit and so the Gfx + implemention of + tiling patterns will be used. I think that this is an acceptable + approach also + concerning performance, because it would take also a while to paint + such a huge + bitmap and then draw it to splash. + + poppler/SplashOutputDev.cc | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +commit 2e77799a1668f949612f551425d0665c59ff1d93 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Tue Sep 11 23:33:25 2012 +0200 + + Splash: Implement DeviceN support + + Bug #53140 + + Some copying from the bug tracker + + To explain + it a little bit more I copy a few lines from "Patch 8.01 — DeviceN + Support (6 + colors)" of the Ghent PDF workgroup: + "This patch tests the DeviceN capabilities of a workflow. If DeviceN + is not + handled correctly the colors are converted to CMYK. Instead of the + check marks + an X will appear in the lower left corner of each image and in + the gradient. + In addition you could inspect the color separations. The objects + should appear + only in the Black, Pantone 265C and GWG Green separations as indicated + in the + captions." + Without the patch all DeviceN colors are immediately converted to CMYK + (with + SPLASH_CMYK). This leads especially to problems, if overprint is + used: in + overprint mode a CMYK color will knockout the underlying CMYK + components, BUT + neither any spot colors. But if underlying spot colors are immediately + converted to CMYK colors, they will be kocked out then, too! + The patch now spends up to four (or up to SPOT_NCOMPS) additional + spot colors + in the splash bitmap, so the order in the bitmap will be + CMYKSTUVCMYKSTUVCMYKSTUV... where S, T, U, V are spot colors (I + would use + S1,S2, S3, S4 if it's possible to use indexes), and all painting + operations are + done now in this new device. Only at the end, when we want to store + the bitmap + in a CMYK or RGB color, the spot colors are converted and their + alternate CMYK + components are added to the normal CMYK components. + According to the PDF spec are PDF writer should use different spot + color names + if they have a different appearance in their alternate CMYK + colorspace. + "hasDifferntResultSet" (sorry for the typo) proofs that: if the same + spot color + name is reused BUT has a different appearance in the alternate + colorspace, it + will be converted immediately to its alternate colorspace. + "createMapping" is used so that getDeviceN (color) returns the + components in + the correct order according their appearance in the splash bitmap, + i.e. the + fourth detected spot color must be placed in index 7 of the color + array. + updateFill- and updateStrokeColorspace are needed to create this + mapping at the + appropriate place. And they are not called once but everytime the + colorspace + changed in the PDF (but of course only once in Gfx). + The GooList *getSeparationList() is used to store the functions + for converting + the spot colors to their alternate colorspace in order of their + appearance in + the splash bitmap. The functions are needed to compare if a spot + color with the + same name has really the same appearance and at the end when the + splash bitmap + has to be converted to a CMYK or RGB bitmap (s. ahead). + deviceNTransfer is needed simular to rgbTransferX or cmykTransferX + if a + transfer function is specified in the ExtGState and splash uses + the DeviceN8. + "Do we really need splashModeDeviceN8?": Do we really need + splashModeXBGR8? But + kidding aside: splashModeDeviceN8 needs four more components than + splashModeCMYK8, so the bitmap size in memory doubles the size of + a pure CMYK + bitmap, and it is only needed if the PDF uses spot colors. So I + think it's a + good idea to spend an additional mode and let it up to the calling + application + and the cirumstances if it wants to use this new mode or not. + + poppler/Function.cc | 14 + + poppler/Function.h | 4 + + poppler/GfxState.cc | 341 +++++++++++++++++- + poppler/GfxState.h | 41 ++- + poppler/SplashOutputDev.cc | 173 ++++++++- + poppler/SplashOutputDev.h | 3 + + splash/Splash.cc | 255 ++++++++++++- + splash/Splash.h | 7 +- + splash/SplashBitmap.cc | 115 +++++- + splash/SplashBitmap.h | 8 +- + splash/SplashState.cc | 30 +- + splash/SplashState.h | 3 + + splash/SplashTypes.h | 30 +- + utils/pdftoppm.cc | 878 + ++++++++++++++++++++++----------------------- + 14 files changed, 1415 insertions(+), 487 deletions(-) + +commit cb2ed646c4ef4161e443ee0a377d1111b3be28ff +Merge: f3a1b76 3ce4d21 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 11 19:29:19 2012 +0200 + + Merge remote-tracking branch 'origin/poppler-0.20' + +commit f3a1b765bd6a58d327a80feedbe30e1c0792076e +Author: Jason Crain <jason@aquaticape.us> +Date: Tue Sep 11 19:28:28 2012 +0200 + + Allow multiple fonts in a TextWord + + Bug #6923 + + glib/poppler-page.cc | 49 ++++++----- + poppler/TextOutputDev.cc | 224 + ++++++++++++++++++++++------------------------- + poppler/TextOutputDev.h | 21 ++--- + 3 files changed, 145 insertions(+), 149 deletions(-) + +commit 3ce4d213480471dfd8e307c24c99bf3c6308cd6f +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 11 19:24:58 2012 +0200 + + Do not use isnan as it is C99 + + poppler/TextOutputDev.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 4d7a64a23fd4b4b5ee0d47ead8677f374aaaf6c9 +Author: Jason Crain <jason@aquaticape.us> +Date: Tue Sep 11 19:24:11 2012 +0200 + + Check for NaN in TextPage::addChar + + poppler/TextOutputDev.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit e79b70ec13ab4d2cce8f245d150fa9329b436658 +Author: Tobias Koenig <tokoe@kdab.com> +Date: Tue Sep 11 16:39:55 2012 +0200 + + Make 'additional actions' available in Annotation API of Qt4 frontend + + Bug #53589 + + qt4/src/poppler-annotation-private.h | 3 ++ + qt4/src/poppler-annotation.cc | 99 + +++++++++++++++++++++++++++++++++++- + qt4/src/poppler-annotation.h | 68 ++++++++++++++++++++++++- + 3 files changed, 168 insertions(+), 2 deletions(-) + +commit 5f338ea7d01cabc0f8c50690d0bc262d85baa0ed +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 10 19:47:20 2012 +0200 + + Fix typo + + NEWS | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 5fd691dc58aac817bca81c87c4820afcf53989d1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 10 19:29:01 2012 +0200 + + 0.20.40.20.40.20.40.20.4 + + CMakeLists.txt | 4 ++-- + NEWS | 13 +++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 6 files changed, 19 insertions(+), 6 deletions(-) + +commit 1b40cdd9f863cd3868db85b5ccfa77a8350c56d6 +Merge: 6c40a55 b3e86db +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 10 18:49:52 2012 +0200 + + Merge remote-tracking branch 'origin/poppler-0.20' + +commit b3e86dbdba82956f125e37f69176072e2d0127f2 +Author: Thomas Freitag <Thomas.Freitag@kabelmail.de> +Date: Sun Sep 9 23:35:45 2012 +0200 + + Try to find another rootNum if actual rootNum doesn't point to a dict + + Bug #14303 + + poppler/XRef.cc | 14 ++++++++++++-- + poppler/XRef.h | 4 ++-- + 2 files changed, 14 insertions(+), 4 deletions(-) + +commit 6c40a553a3c8825931c59797059392fd110531cc +Merge: 17fc1bf 558a7d9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 9 23:27:40 2012 +0200 + + Merge remote-tracking branch 'origin/poppler-0.20' + +commit 558a7d9b046bbbe185dea263b48a3cb2664378fc +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Sep 9 23:25:47 2012 +0200 + + Fix invalid memory access in solves 1066.pdf.asan.38.75 + + splash/SplashClip.cc | 23 +++++++++++++++++++++++ + splash/SplashXPathScanner.cc | 3 +++ + 2 files changed, 26 insertions(+) + +commit d0df8e54512f584ca2b3edbae1c19e167948e5c3 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Sep 9 23:21:38 2012 +0200 + + Fix invalid memory access in 1106.pdf.asan.30.120.patch + + poppler/Function.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 86b89864396a1dcf027e5793e6ac75411977bcf9 +Author: Thomas Freitag <Thomas.Freitag@kabelmail.de> +Date: Sun Sep 9 23:08:49 2012 +0200 + + Fix crash in 1255.pdf.SIGSEGV.56f.285 + + poppler/XRef.cc | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 96931732f343d2bbda9af9488b485da031866c3b +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Sep 9 22:47:57 2012 +0200 + + Fix invalid memory access in 61.pdf.asan.13.95 + + fofi/FoFiType1C.cc | 25 +++++++++++++++++-------- + fofi/FoFiType1C.h | 2 ++ + 2 files changed, 19 insertions(+), 8 deletions(-) + +commit 26917d69c4da6a110db02b120133c36579fbb17c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 9 22:23:36 2012 +0200 + + Add unlikely + + poppler/Gfx.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e6a3c797c01aa343f640f2e6f45de5bf379aa8ad +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Sep 9 22:22:59 2012 +0200 + + Fix wrong memory access in 68.pdf.asan.7.1030 + + poppler/Gfx.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 48fe18cf277cd2a4e665c74b3a594482f762f4b6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 9 22:09:44 2012 +0200 + + Fix memory leak + + poppler/Gfx.cc | 1 + + 1 file changed, 1 insertion(+) + +commit b87aafc0cdb36c3555053f2684c45f1a9d7b2f94 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 9 21:42:48 2012 +0200 + + Add unlikelys to the ifs + + poppler/DCTStream.cc | 4 ++-- + poppler/JBIG2Stream.cc | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit a019eef2f8ca53addd7ccab7f9c47657f4e52286 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Sep 9 21:41:09 2012 +0200 + + Fix crash in 1162.pdf.SIGSEGV.28e.182 + + poppler/DCTStream.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit ad7c6ac88f2315c9ce003308d1b4988592d4434b +Author: William Bader <williambader@hotmail.com> +Date: Sun Sep 9 21:31:58 2012 +0200 + + Fix crash in 1028.pdf.SIGSEGV.ae6.33 + + poppler/JBIG2Stream.cc | 8 ++++++++ + 1 file changed, 8 insertions(+) + +commit b861af714daee4125e54b250dddf82106f5a8ce8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 9 21:15:06 2012 +0200 + + Fix memory leak + + poppler/Form.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 17fc1bfa8013cafe3b348f0cc07ef08bf9c7dd9a +Merge: e0118be a4f5911 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 9 12:52:49 2012 +0200 + + Merge remote-tracking branch 'origin/poppler-0.20' + +commit a4f59113574a8d7460c6ce5000cb09d20fe52b74 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 9 12:49:43 2012 +0200 + + Fix memory leak + + poppler/Annot.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 28240046f8fe37ca96f9a80cb1ea3a59af9c66f3 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Sep 9 12:48:26 2012 +0200 + + Fix crash in 589.pdf.SIGSEGV.8b1.929 + + poppler/Annot.cc | 8 ++++++++ + 1 file changed, 8 insertions(+) + +commit e0118be3ba38bd00fa2a9c20c5b4cd82e820ba0b +Merge: 2c41430 ccd3db5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 8 18:15:43 2012 +0200 + + Merge remote-tracking branch 'origin/poppler-0.20' + + Conflicts: + glib/poppler-document.cc + poppler/PDFDoc.cc + poppler/XRef.h + utils/HtmlFonts.cc + +commit ccd3db5a7723ddb692f6dc85ed9d0f5e3dde189f +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 8 18:10:14 2012 +0200 + + Only complain when the malloc really failed + + poppler/JBIG2Stream.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 2c41430732f517d4d57e914a315ba315a2545541 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 6 22:12:38 2012 +0200 + + Add missing licenses + + goo/grandom.cc | 2 ++ + goo/grandom.h | 2 ++ + splash/SplashScreen.cc | 1 + + utils/pdfinfo.cc | 1 + + 4 files changed, 6 insertions(+) + +commit be88963a5955ac033e7a7d224bdcc4049085a9dc +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Thu Aug 9 13:18:22 2012 +0200 + + pdf-fullrewrite: Added support for encrypted documents, checks on + output documents, incremental update mode + + test/CMakeLists.txt | 1 + + test/Makefile.am | 3 +- + test/pdf-fullrewrite.cc | 354 + ++++++++++++++++++++++++++++++++++++++++++++++-- + 3 files changed, 342 insertions(+), 16 deletions(-) + +commit 381be58e9e0d0e323acbd975a2334eca6d9018fd +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Aug 4 13:00:06 2012 +0200 + + pdfinfo: Show info about the encryption algorithm + + utils/pdfinfo.cc | 24 ++++++++++++++++++++++-- + 1 file changed, 22 insertions(+), 2 deletions(-) + +commit 273e8c896e95b548093159dc8bb14d48ce447053 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Aug 15 18:09:02 2012 +0200 + + Mark object streams as DontRewrite + + So that they don't get copied in full rewrite mode, because they're + not referenced from the XRef table we build, and we already + individually write each object they contain. + + poppler/XRef.cc | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +commit 59db8deaa7b1907831b526de3011dc22d0ffb333 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Thu Aug 9 20:08:44 2012 +0200 + + Mark XRef streams as Unencrypted and DontRewrite + + - Unencrypted because they are stored in unencrypted form + - DontRewrite because they must not be copied in full rewrite mode, + because we always build a new XRef table, and existing XRef streams + are not referenced any more (ie they become "leaked" objects). + Furthermore, since readers know that XRef streams' objects are + unencrypted from the fact that they are XRef streams, but these + leaked objects are no longer referred as XRef streams, readers would + think that they are regularly encrypted objects, resulting in + currupt objects. + + poppler/PDFDoc.cc | 5 +++ + poppler/XRef.cc | 126 + +++++++++++++++++++++++++++++++++++------------------- + poppler/XRef.h | 9 ++-- + 3 files changed, 94 insertions(+), 46 deletions(-) + +commit 116722cc74e267ac44dd5a70924557cdf6f25d02 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Aug 4 12:47:22 2012 +0200 + + Encrypt strWeird streams before writing them in PDFDoc::writeObject + + poppler/Decrypt.cc | 9 ++++++++- + poppler/Decrypt.h | 2 ++ + poppler/PDFDoc.cc | 10 ++++++++++ + 3 files changed, 20 insertions(+), 1 deletion(-) + +commit 695889c1330ca5b37338b8363dbf233fce936bc6 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Aug 4 12:24:25 2012 +0200 + + Encrypt strings before writing them in PDFDoc::writeString + + poppler/PDFDoc.cc | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +commit 4ab8e7be536db40db8a1a4af50dad3ba59c49f14 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Aug 4 02:06:11 2012 +0200 + + Propagate encryption parameters to PDFDoc's write functions + + poppler/PDFDoc.cc | 54 + ++++++++++++++++++++++++++++++++++++------------------ + poppler/PDFDoc.h | 20 +++++++++++++------- + poppler/XRef.cc | 14 ++++++++++++++ + poppler/XRef.h | 2 ++ + utils/pdfunite.cc | 2 +- + 5 files changed, 66 insertions(+), 26 deletions(-) + +commit 9e43f9a8bcbee9060309b9679dbcc6b501a79cfb +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Aug 1 16:14:22 2012 +0200 + + Separated header and footer write commands from the rest of + PDFDoc::writeObject + + Because in next patch I'll need to pass the object's num and gen + always, + not only if the object's header and footer need to be written. + + poppler/PDFDoc.cc | 51 + +++++++++++++++++++++++++++++++++------------------ + poppler/PDFDoc.h | 11 +++++++---- + utils/pdfunite.cc | 2 +- + 3 files changed, 41 insertions(+), 23 deletions(-) + +commit 4d19a002801531b07f11382daaf9880e4691a10e +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Aug 4 01:36:06 2012 +0200 + + Do not change encrypted documents' ID, not even in case of full + rewrite + + Because we will raw-copy encrypted streams, and the ID is part of the + decryption key. + + poppler/PDFDoc.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 800b2e37d3c4c73147bf9e11d9f38afe2183ab9d +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Aug 1 14:07:10 2012 +0200 + + Initial support for saving encrypted documents + + - Do not refuse to save encrypted documents + - Copy the /Encrypt value in the new document's trailer dictionary + - Mark indirect objects referred from /Encrypt as not encrypted + in XRef::scanSpecialFlags + + poppler/PDFDoc.cc | 49 ++++++++++++++++++------------------------- + poppler/XRef.cc | 62 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++- + poppler/XRef.h | 16 +++++++++++++- + 3 files changed, 96 insertions(+), 31 deletions(-) + +commit 6647153d47b1d67d2a4d6b90dce2184ab6c7dda6 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Thu Aug 9 12:26:53 2012 +0200 + + Added field XRefEntry::flags, and turned XRefEntry::updated into + a flag + + In next patches I'll add other flags + + poppler/PDFDoc.cc | 4 ++-- + poppler/XRef.cc | 18 +++++++++--------- + poppler/XRef.h | 20 +++++++++++++++++++- + 3 files changed, 30 insertions(+), 12 deletions(-) + +commit a284c6c6623587abb7da7e4c171c42e006ea477b +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Aug 4 01:57:41 2012 +0200 + + Be able to output overflown integers back + + Because Lexer.cc:241 can read them, and we must be able to write them + back (especially in full rewrite mode). + + poppler/PDFDoc.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 53baea19658a27f15c7ed870a24be82b8219ddfe +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Aug 4 01:32:08 2012 +0200 + + FlateStream::unfilteredReset should call str->unfilteredReset() + + Just like any other FilterStream-derived class does + + poppler/Stream.cc | 14 +++++++++++--- + poppler/Stream.h | 2 ++ + 2 files changed, 13 insertions(+), 3 deletions(-) + +commit 4e5fee4e9156480173f05e7b3d0bdf604127d481 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Mon Aug 6 02:08:27 2012 +0200 + + Initialize AES encryption with random CBC IV data + + poppler/Decrypt.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 1b008f273359b8df6b64ffa94bb2828e42ffa63e +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Mon Aug 6 02:08:40 2012 +0200 + + Replaced srand/rand calls in SplashScreen with grandom calls + + splash/SplashScreen.cc | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +commit faff947d8106048b19ba74dd483b90b8cebb16c7 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Mon Aug 6 02:06:47 2012 +0200 + + Added goo/grandom.[cc|h] with POSIX implementation + + CMakeLists.txt | 2 ++ + ConfigureChecks.cmake | 1 + + config.h.cmake | 3 +++ + configure.ac | 1 + + goo/Makefile.am | 6 +++-- + goo/grandom.cc | 68 + +++++++++++++++++++++++++++++++++++++++++++++++++++ + goo/grandom.h | 32 ++++++++++++++++++++++++ + 7 files changed, 111 insertions(+), 2 deletions(-) + +commit af8d05d1ab89b74e307e90aaf19c750528f5f561 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Fri Aug 3 12:46:06 2012 +0200 + + Added encryption support in Decrypt.cc/.h + + poppler/Decrypt.cc | 222 + +++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Decrypt.h | 21 ++++- + 2 files changed, 242 insertions(+), 1 deletion(-) + +commit ba6ff179aa78a42a384166ace2df80101cfbe7b9 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Thu Aug 2 18:56:29 2012 +0200 + + Refactoring of Decrypt.cc/.h in preparation for encryption support + + poppler/Decrypt.cc | 219 + +++++++++++++++++++++++++++-------------------------- + poppler/Decrypt.h | 35 ++++++--- + 2 files changed, 133 insertions(+), 121 deletions(-) + +commit cd1ab1e34032d5620140bd0b6b6ec4b74f89ae19 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 30 22:36:14 2012 +0200 + + Update Adrian's copyrights + + goo/GooString.cc | 1 + + poppler/CharCodeToUnicode.cc | 1 + + poppler/TextOutputDev.cc | 2 +- + poppler/UTF.cc | 23 +++++++++++++++++++++++ + utils/HtmlOutputDev.cc | 2 +- + 5 files changed, 27 insertions(+), 2 deletions(-) + +commit ce8a579f339507da3fd7802e1531fbf6849c0c98 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Aug 28 22:16:34 2012 +0930 + + Move text to unicode conversion into a separate function + + This also ensures UTF-16 ActualText strings are converted to UCS-4 + before calling addChar. + + goo/GooString.cc | 2 +- + poppler/TextOutputDev.cc | 32 ++++---------------------------- + poppler/UTF.cc | 34 ++++++++++++++++++++++++++++++++++ + poppler/UTF.h | 8 ++++++++ + utils/pdfinfo.cc | 37 ++++++------------------------------- + 5 files changed, 53 insertions(+), 60 deletions(-) + +commit cac13e782cf4413703cfd1fa23e76133dfbe5ef9 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Aug 28 21:48:16 2012 +0930 + + text: increase the tolerance for overlapping glyphs + + TextOutputDev will start a new line when encountering consecutive + glyphs with overlapping bounding boxes. This can occur when drawing + diacritics with a separate glyph. In this case, due to the diacritic + having a different baseline, the lines may be output in the wrong + order. + + This patch increases the tolerance for overlapping bounding boxes to + prevent diacritics from splitting lines. + + poppler/TextOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 6f6386219449e70c2c3bc3559fdde3df4a57a809 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu Mar 8 20:52:28 2012 +1030 + + Convert UTF-16 to UCS-4 when reading toUnicode cmap + + to ensure only UCS-4 values are used with the "Unicode" type. + + CMakeLists.txt | 3 +- + poppler/CairoOutputDev.cc | 2 +- + poppler/CharCodeToUnicode.cc | 12 ++--- + poppler/GlobalParams.cc | 2 +- + poppler/Makefile.am | 3 +- + poppler/TextOutputDev.cc | 19 +------- + poppler/UTF.cc | 47 ++++++++++++++++++++ + poppler/UTF.h | 103 + +++++++++++++++++++++++++++++++++++++++++++ + poppler/UTF8.h | 84 ----------------------------------- + utils/HtmlOutputDev.cc | 14 +----- + 10 files changed, 165 insertions(+), 124 deletions(-) + +commit b3b0f5abe4fdcc39d884670e4a998d39324659f6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 30 00:57:51 2012 +0200 + + qt4: unbreak spacing + + qt4/src/poppler-embeddedfile.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 6356c0bbae47db291a3585d31c7727bc3f8d97a4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 30 00:57:51 2012 +0200 + + qt4: unbreak spacing + + qt4/src/poppler-embeddedfile.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 46948868dee6d4e68b658c68d7df482590e34da3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 30 00:43:45 2012 +0200 + + Accept FileSpec as Dict too and not only as Ref + + File to try in KDE bug #306008 + + poppler/Catalog.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit debc8fb497bc22c0f9f34d785852981a87475c30 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 30 00:35:40 2012 +0200 + + Take into account the embFile returned by the core may be NULL + + qt4/src/poppler-embeddedfile-private.h | 4 +++- + qt4/src/poppler-embeddedfile.cc | 19 ++++++++++++------- + 2 files changed, 15 insertions(+), 8 deletions(-) + +commit 3ca67a59fc15782abb1e479eb2b8916de5b1b6ed +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 30 00:34:06 2012 +0200 + + Return NULL EmbFile if the FileSpec is not ok + + Otherwise we might end up asserting + + poppler/FileSpec.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 9264b375eec19e639c524b677f770ad750b1cb43 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 30 00:43:45 2012 +0200 + + Accept FileSpec as Dict too and not only as Ref + + File to try in KDE bug #306008 + + poppler/Catalog.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 01528eaedc77d5559f6dc4229b66f1a819678fb7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 30 00:35:40 2012 +0200 + + Take into account the embFile returned by the core may be NULL + + qt4/src/poppler-embeddedfile-private.h | 4 +++- + qt4/src/poppler-embeddedfile.cc | 19 ++++++++++++------- + 2 files changed, 15 insertions(+), 8 deletions(-) + +commit c1fba45be106dc30a5136efe41493b1cf6d2a1b5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 30 00:34:06 2012 +0200 + + Return NULL EmbFile if the FileSpec is not ok + + Otherwise we might end up asserting + + poppler/FileSpec.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 1881486e9817304d0817ce24b177c1bc79587138 +Author: Tobias Koenig <tobias.koenig@kdab.com> +Date: Fri Aug 24 19:12:20 2012 +0200 + + annots: Unify parsing of additional actions entries + + https://bugs.freedesktop.org/show_bug.cgi?id=53586 + + poppler/Annot.cc | 58 + ++++++++++++++++++++++++++++++++++++++++++++------------ + poppler/Annot.h | 24 +++++++++++++++++++---- + 2 files changed, 66 insertions(+), 16 deletions(-) + +commit 686ec0cc92e25f74eaa9e09a328724cbdf939bca +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 15 20:02:05 2012 +0200 + + Remove declared but not implemented function + + poppler/XRef.h | 1 - + 1 file changed, 1 deletion(-) + +commit 0b3259c1d5679cb8d59d770e5fbe7e1bc141a025 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 15 20:02:05 2012 +0200 + + Remove declared but not implemented function + + poppler/XRef.h | 1 - + 1 file changed, 1 deletion(-) + +commit 5fd2a35227c22dbddedfb397eff0e0a09c3d1b03 +Author: Pino Toscano <pino@kde.org> +Date: Wed Aug 15 19:51:43 2012 +0200 + + poppler-config.h: remove WITH_FONTCONFIGURATION_* macros + + no public header uses them anymore, so need to expose them + + poppler/poppler-config.h.cmake | 10 ---------- + poppler/poppler-config.h.in | 10 ---------- + 2 files changed, 20 deletions(-) + +commit edd0ea4847c143adb1d15a57b42b0ce2b2c80b0e +Author: Pino Toscano <pino@kde.org> +Date: Wed Aug 15 19:31:50 2012 +0200 + + ignore more qt4 tests + + qt4/tests/.gitignore | 3 +++ + 1 file changed, 3 insertions(+) + +commit 2df57857000c5adbee6b029ff7a79acc707786a0 +Author: Pino Toscano <pino@kde.org> +Date: Wed Aug 15 18:59:15 2012 +0200 + + build: remove extra fontconfig CFLAGS and LIBS + + fontconfig is used only in .cpp sources inside the 'poppler' + subdirectory, so there is no need to add the include paths for it + in other directories; + likewise, do not to link to it if not needed + + glib/Makefile.am | 4 +--- + qt4/demos/Makefile.am | 2 -- + qt4/src/Makefile.am | 2 -- + qt4/tests/Makefile.am | 2 -- + test/Makefile.am | 6 ++---- + utils/CMakeLists.txt | 3 --- + utils/Makefile.am | 4 +--- + 7 files changed, 4 insertions(+), 19 deletions(-) + +commit 3e802949264d9310df057daff891a3fccb2eb8d3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 15 00:02:23 2012 +0200 + + PSOutputDev: Always write HiResBoundingBox + + Makes some people happier and it doesn't hurt us much + Bug #53159 + + poppler/PSOutputDev.cc | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +commit e83568065f77ba722b147b3b10faed1ff66f22dc +Author: Pino Toscano <pino@kde.org> +Date: Sat Aug 11 01:38:08 2012 +0200 + + remove extra execution permissions + + (cherry picked from commit 9a5a19ee2f9cd536c3527b30c0256ca9dce3638c) + + goo/GooTimer.h | 0 + 1 file changed, 0 insertions(+), 0 deletions(-) + +commit 9a5a19ee2f9cd536c3527b30c0256ca9dce3638c +Author: Pino Toscano <pino@kde.org> +Date: Sat Aug 11 01:38:08 2012 +0200 + + remove extra execution permissions + + goo/GooTimer.h | 0 + 1 file changed, 0 insertions(+), 0 deletions(-) + +commit 1b2903c104012fdd3c982d57898910945dff9a15 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Aug 11 00:05:10 2012 +0200 + + 0.20.3 + + CMakeLists.txt | 4 ++-- + NEWS | 16 ++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 6 files changed, 22 insertions(+), 6 deletions(-) + +commit 40e7b744d32152ab4c6201b8bda7fb7caf6bfd4e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 5 15:07:16 2012 +0200 + + If NULL, NULL fails as password try EMPTY, EMPTY before failing + + Reviewed by Jose Aliste + Bug #3498 + + poppler/SecurityHandler.cc | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +commit a53e0641365608f832b455404f1ee584d278e0c4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 5 15:07:16 2012 +0200 + + If NULL, NULL fails as password try EMPTY, EMPTY before failing + + Reviewed by Jose Aliste + Bug #3498 + + poppler/SecurityHandler.cc | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +commit 3ca2bc0d3abdf92741b7921ea402c9de09e531f6 +Author: Markus Trippelsdorf <markus@trippelsdorf.de> +Date: Fri Aug 3 00:48:12 2012 +0200 + + Fix segfault when scaleImage returns NULL + + Bug 52488 + + splash/Splash.cc | 7 +++++++ + 1 file changed, 7 insertions(+) + +commit 31fe12c63f0133d124e2115aba607857aaff0978 +Author: Markus Trippelsdorf <markus@trippelsdorf.de> +Date: Fri Aug 3 00:48:12 2012 +0200 + + Fix segfault when scaleImage returns NULL + + Bug 52488 + + splash/Splash.cc | 7 +++++++ + 1 file changed, 7 insertions(+) + +commit d3c339017857cd762d8419260e33e1cc4e197743 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Thu Aug 2 00:22:19 2012 +0200 + + PSOutputDev: Fix Bitmaps in level2sep or level3sep + + Bug #52384 + + poppler/PSOutputDev.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 768cf5877f48f8cee80fe96e2ee52f42f230dfdf +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Thu Aug 2 00:22:19 2012 +0200 + + PSOutputDev: Fix Bitmaps in level2sep or level3sep + + Bug #52384 + + poppler/PSOutputDev.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit d0e55aa49484263882345fa648e1e907d2b172f2 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Wed Aug 1 22:56:49 2012 +0200 + + Splash: Blend mode enhancements for CMYK + + poppler/SplashOutputDev.cc | 76 + ++++++++++++++++++++++++++++++++-------------- + splash/Splash.cc | 22 -------------- + 2 files changed, 54 insertions(+), 44 deletions(-) + +commit 315447843a368556a8536bc30e579c9bf338682e +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Wed Aug 1 22:56:49 2012 +0200 + + Splash: Blend mode enhancements for CMYK + + poppler/SplashOutputDev.cc | 76 + ++++++++++++++++++++++++++++++++-------------- + splash/Splash.cc | 22 -------------- + 2 files changed, 54 insertions(+), 44 deletions(-) + +commit 78c6a5615013d26b8a2babb13b3c4f7d6a1d70a4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jul 31 23:32:19 2012 +0200 + + Replace c++ style includes with c style ones + + Fixes build in Solaris 10 + Bug #52426 + + goo/gstrtod.cc | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +commit c0c88b3707fc7337e814ae4252d80002641a19ee +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jul 31 23:32:19 2012 +0200 + + Replace c++ style includes with c style ones + + Fixes build in Solaris 10 + Bug #52426 + + goo/gstrtod.cc | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +commit dcbc923bd3592a81876f84005fbaddcea18641cc +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Jul 22 18:40:46 2012 +0200 + + Make sure xScale and yScale are always initialized + + Bug #52215 + + poppler/PSOutputDev.cc | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +commit 36481939e3064de920e49d9d1742a85473a50963 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Jul 22 18:40:46 2012 +0200 + + Make sure xScale and yScale are always initialized + + Bug #52215 + + poppler/PSOutputDev.cc | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +commit ef7c2418e12d3e6a79f1d89a0051b005fadbc344 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sat Jul 21 00:01:49 2012 +0200 + + Fix conversion to ps when having multiple strips + + Bug 51982 + + poppler/PSOutputDev.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 6b567565b7b9d591fbd7441592096960a303bd39 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sat Jul 21 00:01:49 2012 +0200 + + Fix conversion to ps when having multiple strips + + Bug 51982 + + poppler/PSOutputDev.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 349b21acc249c130fb053bc4a0c75019f75bd35b +Author: Torsten Kasch <tk@CeBiTec.Uni-Bielefeld.DE> +Date: Thu Jul 19 00:18:14 2012 +0200 + + Unify poppler-config.h includes in core "installed" headers + + Bug 52193 + + goo/FixedPoint.h | 2 +- + goo/GooTimer.h | 2 +- + goo/JpegWriter.h | 2 +- + goo/PNGWriter.h | 2 +- + goo/TiffWriter.h | 2 +- + goo/gfile.h | 2 +- + goo/gmem.h | 2 +- + splash/SplashFTFont.h | 2 +- + splash/SplashMath.h | 2 +- + 9 files changed, 9 insertions(+), 9 deletions(-) + +commit 34327b2c201392f96e3449941411b7ad4b3e8bcb +Author: Torsten Kasch <tk@CeBiTec.Uni-Bielefeld.DE> +Date: Thu Jul 19 00:18:14 2012 +0200 + + Unify poppler-config.h includes in core "installed" headers + + Bug 52193 + + goo/FixedPoint.h | 2 +- + goo/GooTimer.h | 2 +- + goo/JpegWriter.h | 2 +- + goo/PNGWriter.h | 2 +- + goo/TiffWriter.h | 2 +- + goo/gfile.h | 2 +- + goo/gmem.h | 2 +- + splash/SplashFTFont.h | 2 +- + splash/SplashMath.h | 2 +- + 9 files changed, 9 insertions(+), 9 deletions(-) + +commit 8fe700217ab6ce786a8272f2c338e3dab434c56e +Author: Torsten Kasch <tk@CeBiTec.Uni-Bielefeld.DE> +Date: Thu Jul 19 00:06:45 2012 +0200 + + autoconf: Do not assume the shell is bash compatible + + Bug 52197 + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 15c6ae699f083ea6c9716c1098ae9833a56eeb3e +Author: Torsten Kasch <tk@CeBiTec.Uni-Bielefeld.DE> +Date: Thu Jul 19 00:06:45 2012 +0200 + + autoconf: Do not assume the shell is bash compatible + + Bug 52197 + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit f5311da76ec7cd7c1e6cdfc4e18df6dd56e8398b +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jul 19 00:01:49 2012 +0200 + + pdfseparate: Return 0 on success + + utils/pdfseparate.cc | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit dc8833a36b514c13cfd6b1fd4665d2fddd71f357 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jul 19 00:01:49 2012 +0200 + + pdfseparate: Return 0 on success + + utils/pdfseparate.cc | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit 51f22ca0badfc41c19cba66cabd63184244f81c7 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Mon Jul 16 23:32:23 2012 +0200 + + PSOutputDev: Fix DeviceN images with alternate Lab colorspace in + level 3 PostScript + + Bug #51822 + + poppler/PSOutputDev.cc | 54 + +++++++++++++++++++++++++++++++++++++++++++------- + poppler/PSOutputDev.h | 2 +- + 2 files changed, 48 insertions(+), 8 deletions(-) + +commit 31ef967033407de91109ff46db9c60cb8748bc55 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Mon Jul 16 23:32:23 2012 +0200 + + PSOutputDev: Fix DeviceN images with alternate Lab colorspace in + level 3 PostScript + + Bug #51822 + + poppler/PSOutputDev.cc | 54 + +++++++++++++++++++++++++++++++++++++++++++------- + poppler/PSOutputDev.h | 2 +- + 2 files changed, 48 insertions(+), 8 deletions(-) + +commit f9f5238d32615f93d07afa3aa7384a8b30737203 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Fri Jul 13 00:56:48 2012 +0200 + + Fix Splash::arbitraryTransformImage causes bogus memory allocation + size + + Bug #49523 + + poppler/SplashOutputDev.cc | 2 +- + splash/Splash.cc | 79 + ++++++++++++++++++++++++++-------------------- + splash/Splash.h | 4 +-- + 3 files changed, 48 insertions(+), 37 deletions(-) + +commit 950d5f3dec4bff5d3c523d55689d7b70215dc110 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Fri Jul 13 00:56:48 2012 +0200 + + Fix Splash::arbitraryTransformImage causes bogus memory allocation + size + + Bug #49523 + + poppler/SplashOutputDev.cc | 2 +- + splash/Splash.cc | 79 + ++++++++++++++++++++++++++-------------------- + splash/Splash.h | 4 +-- + 3 files changed, 48 insertions(+), 37 deletions(-) + +commit e09be3bc6ba1290fd31bde0c3d19c4ffcbadbf00 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jul 10 23:06:53 2012 +0200 + + 0.20.2 + + CMakeLists.txt | 2 +- + NEWS | 11 +++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + 5 files changed, 15 insertions(+), 4 deletions(-) + +commit e15fe0e1e6accf779caeb1179a8d62161c0aa650 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Thu Jul 5 17:44:02 2012 +0200 + + Fix handling of DeviceN images in level 3 PostScript + + bug #51548 + + poppler/PSOutputDev.cc | 14 -------------- + 1 file changed, 14 deletions(-) + +commit 31837201cf5b3db735c89ef4969105b7a6ab465d +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Thu Jul 5 17:44:02 2012 +0200 + + Fix handling of DeviceN images in level 3 PostScript + + bug #51548 + + poppler/PSOutputDev.cc | 14 -------------- + 1 file changed, 14 deletions(-) + +commit 262203bd86403e43034fbfbbeef5a5894a62ecb2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 30 14:36:28 2012 +0200 + + [qt4] Refactor part of ::search() functions + + qt4/src/poppler-page-private.h | 7 ++++- + qt4/src/poppler-page.cc | 61 + +++++++++++++++++++----------------------- + 2 files changed, 34 insertions(+), 34 deletions(-) + +commit bd71f80c409dbb47231088c3c6661946ccde6e67 +Author: Adam Reichold <adamreichold@myopera.com> +Date: Thu Jun 28 17:42:17 2012 +0200 + + [qt4] add whole-page search method to Poppler::Page + + qt4/src/poppler-page.cc | 39 +++++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-qt4.h | 14 ++++++++++++++ + 2 files changed, 53 insertions(+) + +commit 46ebe7dc84b14ce8dda7b3b1da516b9d99ac3344 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jun 29 01:56:55 2012 +0200 + + PSOutputDev: Correct %%DocumentCustomColors + + Bug 51479 + + poppler/PSOutputDev.cc | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +commit 02c4e6bf4cc0f5535946fe31815081a40b1de986 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jun 29 01:56:55 2012 +0200 + + PSOutputDev: Correct %%DocumentCustomColors + + Bug 51479 + + poppler/PSOutputDev.cc | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +commit 2b8d95aeede56c75699bb83ca3b23ea199b81c2c +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jun 28 00:18:07 2012 +0200 + + Add some security checks to JPXStream decoding + + Fixes crash in broken/fuzzed pdf sent by Mateusz "j00ru" Jurczyk + and Gynvael Coldwind + + poppler/JPXStream.cc | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +commit f7990386d268a444c297958e9c50ed27a0825a00 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jun 28 00:18:07 2012 +0200 + + Add some security checks to JPXStream decoding + + Fixes crash in broken/fuzzed pdf sent by Mateusz "j00ru" Jurczyk + and Gynvael Coldwind + + poppler/JPXStream.cc | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +commit c5c6eed1623506e1206e89cee0b7c887d815ba62 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 24 23:43:03 2012 +0200 + + Change SplashBitmap gmallocn to gmallocn_checkoverflow + + Fixes abort in KDE bug #302372 + + splash/Splash.cc | 37 +++++++++++++++++++++++-------------- + splash/SplashBitmap.cc | 18 +++++++++++------- + 2 files changed, 34 insertions(+), 21 deletions(-) + +commit f48eb669ae5c729c026554802e666e64399c0900 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 24 23:43:03 2012 +0200 + + Change SplashBitmap gmallocn to gmallocn_checkoverflow + + Fixes abort in KDE bug #302372 + + splash/Splash.cc | 37 +++++++++++++++++++++++-------------- + splash/SplashBitmap.cc | 18 +++++++++++------- + 2 files changed, 34 insertions(+), 21 deletions(-) + +commit c87738ee234aafc6eda5a263ad789205037020e1 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Jun 24 20:20:38 2012 +0200 + + copy resources content defined in the pages dict + + Fixes bug #51369 + + poppler/PDFDoc.cc | 16 ++++++++++++++-- + 1 file changed, 14 insertions(+), 2 deletions(-) + +commit ff48a5d67a130211fbbb98aa0011bca0c1185114 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Jun 24 20:20:38 2012 +0200 + + copy resources content defined in the pages dict + + Fixes bug #51369 + + poppler/PDFDoc.cc | 16 ++++++++++++++-- + 1 file changed, 14 insertions(+), 2 deletions(-) + +commit 6cdf879e389f05abba30b3fad8083b7fff23056e +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sun Jun 24 11:48:04 2012 +0200 + + qt4: Do not hang on malformed /Annots objects + + Don't recurse infinitely if the /Annots object contains annotation + dictionaries (according to specs, /Annots must contain *references* + to annotation dictionaries). + + Fixes bug #51361 + + qt4/src/poppler-annotation.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit bd1dab39a857b852c09d21f64254ffc1f24c2df0 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sun Jun 24 11:48:04 2012 +0200 + + qt4: Do not hang on malformed /Annots objects + + Don't recurse infinitely if the /Annots object contains annotation + dictionaries (according to specs, /Annots must contain *references* + to annotation dictionaries). + + Fixes bug #51361 + + qt4/src/poppler-annotation.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 31db47d077825045edd1a2d229e873a6f8e09fb1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jun 17 12:00:43 2012 +0200 + + Simplify AnnotAppearance::getAppearanceStream() + + - Use a switch instead of if to get the stream object + - Use the return value of dictLookupNF to check whether the object is + null + - Don't fetch the stream to check the reference is valid, this is + already done when used + + poppler/Annot.cc | 50 ++++++++++++++++++-------------------------------- + 1 file changed, 18 insertions(+), 32 deletions(-) + +commit b15d02b92aca1348564e70d0245064bc27eefce8 +Author: Maciej Mrozowski <reavertm@gmail.com> +Date: Fri May 18 01:47:55 2012 +0200 + + Add the possibility of using lcms1 even if lcms2 is installed + + CMakeLists.txt | 20 +++++++++++++------- + configure.ac | 31 +++++++++++++++---------------- + 2 files changed, 28 insertions(+), 23 deletions(-) + +commit 0cc2738737ed411159c8c8045eff5d1a4463ed16 +Author: Mark Brand <mabrand@mabrand.nl> +Date: Thu Jun 14 20:31:26 2012 +0200 + + fix typo to compile in Windows + + poppler/GlobalParamsWin.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 3575becd60585324bcefc0631b1bac47c1db3c5c +Author: Mark Brand <mabrand@mabrand.nl> +Date: Thu Jun 14 20:31:26 2012 +0200 + + fix typo to compile in Windows + + poppler/GlobalParamsWin.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 2e1410ea62fe99e52c94f878d02181f0b59f1cd5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 11 15:17:59 2012 +0200 + + Add some security checks to JBIG2Stream decoding + + Fixes crash in broken/fuzzed pdf sent by Mateusz "j00ru" Jurczyk + and Gynvael Coldwind + + poppler/JBIG2Stream.cc | 58 + ++++++++++++++++++++++++++++++++++++++------------ + 1 file changed, 44 insertions(+), 14 deletions(-) + +commit 06618065c8a97a5bec125560546b98edfc1210f3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 11 15:17:59 2012 +0200 + + Add some security checks to JBIG2Stream decoding + + Fixes crash in broken/fuzzed pdf sent by Mateusz "j00ru" Jurczyk + and Gynvael Coldwind + + poppler/JBIG2Stream.cc | 58 + ++++++++++++++++++++++++++++++++++++++------------ + 1 file changed, 44 insertions(+), 14 deletions(-) + +commit 6a76d21661add4f84ee0859c4e7a4c23e7a63bc4 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Jun 10 19:44:18 2012 +0200 + + Check value of first page in linearization table + + Fixes crash in broken/fuzzed pdf sent by Mateusz "j00ru" Jurczyk + and Gynvael Coldwind + + poppler/Linearization.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit e3fe88df3646a80945210ba426eb4681a98b55e9 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Jun 10 19:44:18 2012 +0200 + + Check value of first page in linearization table + + Fixes crash in broken/fuzzed pdf sent by Mateusz "j00ru" Jurczyk + and Gynvael Coldwind + + poppler/Linearization.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 1240eee8c0d0d01113443e0fda87721775a76da9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 10 20:42:55 2012 +0200 + + 0.20.1 + + CMakeLists.txt | 4 ++-- + NEWS | 25 +++++++++++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 6 files changed, 31 insertions(+), 6 deletions(-) + +commit d483436517c5d9679fd6f4ec5544128ffcc2188e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 10 20:15:01 2012 +0200 + + Update copyrights + + poppler/GlobalParamsWin.cc | 1 + + 1 file changed, 1 insertion(+) + +commit c783037619e2b4c101e8ecd7e61c94ee077b4be2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 10 20:15:01 2012 +0200 + + Update copyrights + + poppler/GlobalParamsWin.cc | 1 + + 1 file changed, 1 insertion(+) + +commit d791101fbdebf7a3b3f333939f9bbff6bbecf45f +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 10 19:09:17 2012 +0200 + + Do use NULL function + + Fixes crash in broken/fuzzed pdf sent by Mateusz "j00ru" Jurczyk + and Gynvael Coldwind + + poppler/Gfx.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit f3f9d8f28a97338da92c842d5668b0ef3495ef13 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 10 19:09:17 2012 +0200 + + Do use NULL function + + Fixes crash in broken/fuzzed pdf sent by Mateusz "j00ru" Jurczyk + and Gynvael Coldwind + + poppler/Gfx.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 8b3fa65f293804dab7ae2fd069132d0d6f44bbb2 +Author: Tobias Koenig <tobias.koenig@kdab.com> +Date: Sun Jun 10 17:48:08 2012 +0200 + + [qt4] Add accessor methods for poster information + + qt4/src/poppler-movie.cc | 15 +++++++++++++++ + qt4/src/poppler-qt4.h | 15 +++++++++++++++ + 2 files changed, 30 insertions(+) + +commit e8aa8266254bfd2189d5b5105e3d76caa4cc6713 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Jun 10 16:58:54 2012 +0200 + + use setoverprintmode only if rip knows it + + poppler/PSOutputDev.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 92ef16e3699da949c80716c3fd4b438fe79c134d +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Jun 10 16:58:54 2012 +0200 + + use setoverprintmode only if rip knows it + + poppler/PSOutputDev.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 6e3503b5591b105fa92e6cc6568b8819f6acd625 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Thu May 24 23:17:27 2012 +0200 + + qt4: Keep page rotation into account when normalizing annotation + coords + + If the page is rotated by 90 or 270 degrees, width and height need + to be swapped + + qt4/src/poppler-annotation.cc | 16 ++++++++++++++-- + 1 file changed, 14 insertions(+), 2 deletions(-) + +commit 99aa734ae2d3ba51f840d4c8ef450488fb702a31 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Thu May 24 23:17:27 2012 +0200 + + qt4: Keep page rotation into account when normalizing annotation + coords + + If the page is rotated by 90 or 270 degrees, width and height need + to be swapped + + qt4/src/poppler-annotation.cc | 16 ++++++++++++++-- + 1 file changed, 14 insertions(+), 2 deletions(-) + +commit 4f2ac544f36aa11747c3e13ff69fc19bdd0136dc +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Jun 9 01:31:29 2012 +0200 + + Fix saving to xml + + The default icon is Note not comment + + qt4/src/poppler-annotation.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit bde31ce7b223abc86d25e06f3d73668b792c70df +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Jun 9 01:31:29 2012 +0200 + + Fix saving to xml + + The default icon is Note not comment + + qt4/src/poppler-annotation.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0df0aa439eed1d9838a80942e00af08e9acabb8d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jun 2 17:33:23 2012 +0200 + + glib-demo: Add find options to find demo + + glib/demo/find.c | 61 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 60 insertions(+), 1 deletion(-) + +commit 52b3ede4bfd1e2288a0efca34da5d6239d3563e9 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jun 2 16:25:06 2012 +0200 + + glib-demo: Show search matches in a document view + + glib/demo/find.c | 253 + +++++++++++++++++++++++++++++++++++++++++++++++-------- + 1 file changed, 218 insertions(+), 35 deletions(-) + +commit ed0c761c2190a3c1959a60ae9b7961f58a43c939 +Author: Thomas Schenker <mail.thomas.schenker@googlemail.com> +Date: Sat Jun 2 11:54:21 2012 +0200 + + glib: Add poppler_page_find_text_with_options + + To be able to search text with options like case sensitive, search + backwards and whole words only. + + https://bugs.freedesktop.org/show_bug.cgi?id=2951 + + glib/poppler-page.cc | 52 + +++++++++++++++++++++++++++---------- + glib/poppler-page.h | 3 +++ + glib/poppler.h | 18 +++++++++++++ + glib/reference/poppler-sections.txt | 2 ++ + 4 files changed, 62 insertions(+), 13 deletions(-) + +commit 126b55c9a44ccb0dba55e758843e9ee4aa43ee2b +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jun 2 17:19:30 2012 +0200 + + Implement whole words only option to search text + + It seems we missed it in the xpdf303 merge. + + poppler/TextOutputDev.cc | 144 + ++++++++++++++++++++++++----------------------- + 1 file changed, 74 insertions(+), 70 deletions(-) + +commit 20210fbb6117649b20f6930031f24b8fc97b773d +Author: Luis Parravicini <lparravi@gmail.com> +Date: Mon May 28 23:44:17 2012 +0200 + + pdftohtml: Add -fontfullname + + Outputs the font name without any substitutions. Bug #49872 + + utils/HtmlFonts.cc | 4 +++- + utils/pdftohtml.1 | 3 +++ + utils/pdftohtml.cc | 4 ++++ + 3 files changed, 10 insertions(+), 1 deletion(-) + +commit 03f979a7e59c4eb5ecb8acc324c7faf700144589 +Author: Gerald Schmidt <solahcin@gmail.com> +Date: Sat May 26 17:46:59 2012 +0200 + + Make the output more xhtml compliant + + utils/HtmlOutputDev.cc | 105 + +++++++++++++++++++++++++------------------------ + 1 file changed, 53 insertions(+), 52 deletions(-) + +commit ba6406222f828e354323223fc4bdb01c1726fb49 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Mon May 21 18:16:06 2012 +0200 + + Added Annot::removeReferencedObjects + Always set annotations' + page field + + - Now Page::removeAnnot calls Annot::removeReferencedObjects, which + takes care of + removing referenced objects (such as the annot popup and the + appearance streams). + - Previously, Annot's page field was set only if the annotation + dictionary + contained /P + + poppler/Annot.cc | 40 + ++++++++++++++++++++++++++++++++++------ + poppler/Annot.h | 13 +++++++++---- + poppler/Page.cc | 7 ++++--- + poppler/Page.h | 2 +- + qt4/src/poppler-annotation.cc | 8 -------- + 5 files changed, 48 insertions(+), 22 deletions(-) + +commit 9904b8f10abf068a7816bd90976ccbb320387645 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu May 24 18:24:48 2012 +0930 + + glib docs: fix typo + + glib/poppler-document.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 028f580056f99719cfb8af7bbe8184ceac02cb16 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun May 13 21:36:36 2012 +0930 + + add sustitute font name to GlobalParamsWin32 to fix compilation + + poppler/GlobalParamsWin.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 1916d000a86336213ffd6e9bd44ce873e8955895 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat May 12 16:31:38 2012 +0930 + + Include substitute font name in system font cache + + Bug 49826 + + poppler/FontInfo.cc | 1 + + poppler/GlobalParams.cc | 58 + +++++++++++++++++++++++++++---------------------- + 2 files changed, 33 insertions(+), 26 deletions(-) + +commit b47d38e2ccd8563394df89765e277bde95730052 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu May 24 18:24:48 2012 +0930 + + glib docs: fix typo + + glib/poppler-document.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 14a29dbff585cbe55247431a346c2ac3e12473fe +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun May 13 21:36:36 2012 +0930 + + add sustitute font name to GlobalParamsWin32 to fix compilation + + poppler/GlobalParamsWin.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 7436b2c8a853f5121eb7dd13168ab997f1cf7d80 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat May 12 16:31:38 2012 +0930 + + Include substitute font name in system font cache + + Bug 49826 + + poppler/FontInfo.cc | 1 + + poppler/GlobalParams.cc | 58 + +++++++++++++++++++++++++++---------------------- + 2 files changed, 33 insertions(+), 26 deletions(-) + +commit 1c6e84555572a6bf3a2e3fbe9a54b40f11c122ad +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Fri May 18 16:22:46 2012 +0200 + + qt4: Make TextAnnotation ctor public + + qt4/src/poppler-annotation.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit fe28614e7aab6e029f4b420353b67a7eea24de36 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Fri May 18 16:22:46 2012 +0200 + + qt4: Make TextAnnotation ctor public + + qt4/src/poppler-annotation.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 8e504bf2543621973fdaddbd29055ce435540146 +Author: Ville Skyttä <ville.skytta@iki.fi> +Date: Wed May 16 23:49:01 2012 +0300 + + pdfseparate.1: Syntax fixes. + + utils/pdfseparate.1 | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 918456372548810c9efbf0533fa155034dd081f2 +Author: Ville Skyttä <ville.skytta@iki.fi> +Date: Wed May 16 23:49:01 2012 +0300 + + pdfseparate.1: Syntax fixes. + + utils/pdfseparate.1 | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 892e486addcbcad619613c7be1ca692a0d36d6e5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 21 20:28:42 2012 +0200 + + Compile++ + + cmake/modules/FindGTK.cmake | 8 ++++---- + glib/demo/CMakeLists.txt | 6 +++--- + test/CMakeLists.txt | 6 +++--- + 3 files changed, 10 insertions(+), 10 deletions(-) + +commit 794e89ed41d03997778fc4c59b7f1ba557b5e6b7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 21 20:18:42 2012 +0200 + + Compile + + glib/CMakeLists.txt | 2 ++ + 1 file changed, 2 insertions(+) + +commit 78e6c9905a52c0cd4bfc1e56874f50689f04a1c6 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun May 20 12:11:27 2012 +0200 + + glib-demo: Make text characters list fill and expand in text demo + + glib/demo/text.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 610eb24426d9b36ac7da40a2fceb3dbeeec19a5c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun May 20 12:08:09 2012 +0200 + + glib-demo: Add a button to remove annots from the annot view + + glib/demo/annots.c | 48 +++++++++++++++++++++++++++++++++++++++++------- + 1 file changed, 41 insertions(+), 7 deletions(-) + +commit 11a3093e093319e88f14af0ab6c15009104d17ee +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun May 20 11:22:49 2012 +0200 + + glib: Add poppler_page_remove_annot() + + https://bugs.freedesktop.org/show_bug.cgi?id=40473 + + glib/poppler-page.cc | 19 +++++++++++++++++++ + glib/poppler-page.h | 2 ++ + glib/reference/poppler-sections.txt | 1 + + 3 files changed, 22 insertions(+) + +commit 0dd157ae7f19cd91ea425a607b968f08addc3a40 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun May 20 10:37:47 2012 +0200 + + glib: Take a reference of the core annotation when creating a + PopplerAnnot + + This way if the annotation is removed from the page, the core + annotation + object is not destroyed. Also, a new PopplerAnnot that is never + added to + a page doesn't leak the core annotation anymore. + + glib/poppler-annot.cc | 53 + +++++++++++++++++++++------------------------------ + 1 file changed, 22 insertions(+), 31 deletions(-) + +commit f818b842f54d6860920b39778228e8b247b4e761 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat May 19 12:32:33 2012 +0200 + + glib-demo: Fix runtime warning + + glib/demo/selections.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit a24e326425e198eeb70c4d9205bb7a0a3a9db297 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat May 19 12:09:45 2012 +0200 + + gtk-tests: Port to GTK+ 3.0 + + configure.ac | 4 +- + glib/demo/annots.c | 74 +++++++------- + glib/demo/attachments.c | 4 +- + glib/demo/find.c | 4 +- + glib/demo/fonts.c | 4 +- + glib/demo/forms.c | 64 ++++++------ + glib/demo/images.c | 21 ++-- + glib/demo/info.cc | 67 ++++++------ + glib/demo/layers.c | 22 ++-- + glib/demo/links.c | 6 +- + glib/demo/main.c | 31 ++---- + glib/demo/outline.c | 2 +- + glib/demo/page.c | 23 ++--- + glib/demo/print.c | 14 +-- + glib/demo/render.c | 263 + ++++++++++++++---------------------------------- + glib/demo/selections.c | 77 ++++++-------- + glib/demo/text.c | 22 ++-- + glib/demo/transitions.c | 4 +- + glib/demo/utils.c | 101 +++++++++---------- + glib/demo/utils.h | 6 +- + test/gtk-test.cc | 48 +++++---- + 21 files changed, 350 insertions(+), 511 deletions(-) + +commit 9f7d919e68a26bb7dd809986d8394fe20b750bd0 +Author: Anthony Wesley <awesley@smartnetworks.com.au> +Date: Thu May 17 19:54:47 2012 +0200 + + Fix logic on SplashBitmap::writeImgFile + + splash/SplashBitmap.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 87093d1250807f660042295747a012032f84c034 +Author: Anthony Wesley <awesley@smartnetworks.com.au> +Date: Thu May 17 19:54:47 2012 +0200 + + Fix logic on SplashBitmap::writeImgFile + + splash/SplashBitmap.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 7e7997e12faccf4c0513811b324a2fd0fa960a96 +Author: Igor Slepchin <igor.slepchin@gmail.com> +Date: Tue May 15 23:16:27 2012 +0200 + + Determine if font is bold or italic based on FontDescriptor. + + Bug #49758 + + utils/HtmlFonts.cc | 24 ++++++++++++++++++------ + utils/HtmlFonts.h | 3 ++- + utils/HtmlOutputDev.cc | 4 +--- + 3 files changed, 21 insertions(+), 10 deletions(-) + +commit 3a249aa8ad5e9f7511bcafd0416ce51c7efe5f4d +Author: Igor Slepchin <igor.slepchin@gmail.com> +Date: Tue May 15 23:16:27 2012 +0200 + + Determine if font is bold or italic based on FontDescriptor. + + Bug #49758 + + utils/HtmlFonts.cc | 24 ++++++++++++++++++------ + utils/HtmlFonts.h | 3 ++- + utils/HtmlOutputDev.cc | 4 +--- + 3 files changed, 21 insertions(+), 10 deletions(-) + +commit ff2c251dbaef9b964af48f51ebb517626ac3145c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun May 13 20:13:32 2012 +0200 + + glib-demo: Use poppler_document_new_from_gfile to load the given uri + + glib/demo/main.c | 9 ++------- + 1 file changed, 2 insertions(+), 7 deletions(-) + +commit a7629331ab4ba5b256213af1f1b2954a49953c34 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun May 13 20:13:03 2012 +0200 + + glib: Add poppler_document_new_from_gfile + + glib/poppler-document.cc | 46 + +++++++++++++++++++++++++++++++++++++ + glib/poppler-document.h | 4 ++++ + glib/reference/poppler-sections.txt | 1 + + 3 files changed, 51 insertions(+) + +commit 95277b1f481e274ab0ce22ffb44b40437bffa3c8 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun May 13 20:11:12 2012 +0200 + + glib Add missing cancellable param in poppler_document_new_from_stream + doc + + glib/poppler-document.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 329bb1e2b4f4b58832847bcf805d19ac0fd5ef02 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun May 13 19:45:55 2012 +0200 + + glib: Make sure password is always converted to latin1 + + Remove the utf8 validation since glib API is supposed to always + receive + utf8 strings. + + glib/poppler-document.cc | 38 +++++++++++++++++++------------------- + 1 file changed, 19 insertions(+), 19 deletions(-) + +commit c4bf7b162028a2f9ffcd2baba2759bdb14fae51f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun May 13 19:45:55 2012 +0200 + + glib: Make sure password is always converted to latin1 + + Remove the utf8 validation since glib API is supposed to always + receive + utf8 strings. + + glib/poppler-document.cc | 43 ++++++++++++++++++++----------------------- + 1 file changed, 20 insertions(+), 23 deletions(-) + +commit 7714b4e319c48ee915061a172208245ae7c4141b +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun May 13 19:30:17 2012 +0200 + + glib: Fix memory leak when document fails to load + + glib/poppler-document.cc | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit 4d0786a97e061a752686968bd7976bdda01b1f84 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun May 13 19:30:17 2012 +0200 + + glib: Fix memory leak when document fails to load + + glib/poppler-document.cc | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit 1d1c8175c57ebe6518f4252ab92a20286b7d4c6f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun May 13 18:41:25 2012 +0200 + + glib: Add poppler_document_new_from_stream + + A PopplerInputStream has been added to handle GMemoryInputStream and + GLocalFileInputStream, since we don't want to cache the contents in + those cases. A PopplerCachedFileLoader has been added to handle all + other cases. + + configure.ac | 10 +-- + glib/Makefile.am | 4 + + glib/poppler-cached-file-loader.cc | 108 +++++++++++++++++++++++++++ + glib/poppler-cached-file-loader.h | 44 +++++++++++ + glib/poppler-document.cc | 69 ++++++++++++++++++ + glib/poppler-document.h | 6 ++ + glib/poppler-input-stream.cc | 141 + ++++++++++++++++++++++++++++++++++++ + glib/poppler-input-stream.h | 74 +++++++++++++++++++ + glib/reference/poppler-docs.sgml | 4 + + glib/reference/poppler-sections.txt | 1 + + poppler-glib-uninstalled.pc.in | 2 +- + poppler-glib.pc.in | 2 +- + 12 files changed, 458 insertions(+), 7 deletions(-) + +commit 13d2aa303eb1fd900f1045efec14af8002477b02 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun May 13 17:25:15 2012 +0200 + + remove unnecesary transparency group handling in splash + + Bug #13487 + + poppler/Gfx.cc | 64 + +++++++++++++++++++++++++++++++++++++++++++++- + poppler/Gfx.h | 4 ++- + poppler/GfxState.cc | 4 ++- + poppler/OutputDev.h | 1 + + poppler/SplashOutputDev.cc | 11 ++++++++ + poppler/SplashOutputDev.h | 1 + + 6 files changed, 82 insertions(+), 3 deletions(-) + +commit b477443e8a4c52500529aaf3be76f01a61e85f28 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun May 13 17:25:15 2012 +0200 + + remove unnecesary transparency group handling in splash + + Bug #13487 + + poppler/Gfx.cc | 64 + +++++++++++++++++++++++++++++++++++++++++++++- + poppler/Gfx.h | 4 ++- + poppler/GfxState.cc | 4 ++- + poppler/OutputDev.h | 1 + + poppler/SplashOutputDev.cc | 11 ++++++++ + poppler/SplashOutputDev.h | 1 + + 6 files changed, 82 insertions(+), 3 deletions(-) + +commit a76867003a7bff5ab03016156c75b4c928788d50 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 13 13:10:40 2012 +0200 + + Distribute cmake/modules/FindLCMS2.cmake + + Bug #49818 + + Makefile.am | 1 + + 1 file changed, 1 insertion(+) + +commit 8f040dec2ce2eae24dd1eb15900d4d284e4b3848 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 13 13:10:40 2012 +0200 + + Distribute cmake/modules/FindLCMS2.cmake + + Bug #49818 + + Makefile.am | 1 + + 1 file changed, 1 insertion(+) + +commit 7f47630a7fc19214cd48dbd164ecf577ba35cc46 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 10 23:12:04 2012 +0200 + + Compile with the unsupported ENABLE_PLUGINS defined + + poppler/GlobalParams.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 22264cb230fc5902aea14ab43fa013a8ebdbf812 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 10 23:04:33 2012 +0200 + + Make it compile + + Sorry :-/ + + goo/gfile.cc | 82 + -------------------------------------------------- + goo/gfile.h | 4 --- + poppler/GlobalParams.h | 2 +- + 3 files changed, 1 insertion(+), 87 deletions(-) + +commit 44bf99a7b8683a077f2a5db50541099c109aa069 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 10 22:59:18 2012 +0200 + + Kill the concept of "base dir" + + We are a library so having a "common configuration folder" does + not really + make much sense at a library level, and even less if it's called + .xpdf :D + + Fixes bug 49448 + + goo/gfile.cc | 46 + ---------------------------------------------- + goo/gfile.h | 3 --- + poppler/GfxState.cc | 16 ++-------------- + poppler/GlobalParams.cc | 21 --------------------- + poppler/GlobalParams.h | 3 --- + test/perf-test.cc | 1 - + 6 files changed, 2 insertions(+), 88 deletions(-) + +commit bb091e38a1c0248ba24b0711b4afc0b0524cce10 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 10 22:38:41 2012 +0200 + + Make it be something closer to real english + + utils/pdftohtml.1 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 67f3c3e0d03ec63df7c6028cbd626e384d231c2b +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed May 9 16:48:15 2012 +0200 + + GooString formatting: add support for uppercase hexadecimal + Use + it in Annot::layoutText + + goo/GooString.cc | 61 + ++++++++++++++++++++++++++++++++++++++++++++++---------- + goo/GooString.h | 17 ++++++++-------- + poppler/Annot.cc | 2 +- + 3 files changed, 61 insertions(+), 19 deletions(-) + +commit 1f7f8a78409e6bcc90bd32ea2aaa75ed3a7b6218 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed May 9 16:18:05 2012 +0200 + + Use error() instead of fprintf(stderr, ...) in Annot::layoutText + + poppler/Annot.cc | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit a7a2e72f9ba43816a81278e0565d31807ac5ceb5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 10 22:31:24 2012 +0200 + + More gs cleanup and forgot the (C) on modification + + goo/gfile.cc | 2 +- + goo/gfile.h | 2 +- + utils/pdftohtml.cc | 4 ---- + 3 files changed, 2 insertions(+), 6 deletions(-) + +commit ad36d22d1f11339be90403534b921cce120fdbad +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 10 22:24:40 2012 +0200 + + pdftohtml: Remove the option to invoke gs + + goo/gfile.cc | 8 --- + goo/gfile.h | 3 -- + utils/pdftohtml.1 | 8 +-- + utils/pdftohtml.cc | 149 + ++++++++++++----------------------------------------- + 4 files changed, 36 insertions(+), 132 deletions(-) + +commit 4114c928fa2560937e02319f57937f1c267a9817 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 10 21:09:14 2012 +0200 + + 0.20.0 + + CMakeLists.txt | 6 +++--- + NEWS | 16 ++++++++++++++++ + configure.ac | 4 ++-- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 6 files changed, 24 insertions(+), 8 deletions(-) + +commit df05d084cb26807c39695280cd8ea52d13aa1255 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 10 20:54:13 2012 +0200 + + Bring back the begin/endMarkedContent virtuals + + For those evil people that keep using poppler internals + + poppler/Gfx.cc | 8 ++++++++ + poppler/OutputDev.cc | 8 +++++++- + poppler/OutputDev.h | 4 +++- + 3 files changed, 18 insertions(+), 2 deletions(-) + +commit b6159fea4a13ecfd1c38b3a666a797c5147dd952 +Author: William Bader <williambader@hotmail.com> +Date: Thu May 10 20:02:19 2012 +0200 + + splash uses cmykTransferC for M, Y and K in two places + + splash/Splash.cc | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +commit c2146219d555cab277906daefd2589f9056f536c +Author: Peter Breitenlohner <peb@mppmu.mpg.de> +Date: Thu May 10 13:26:18 2012 +0200 + + Add missing function parameter + + poppler/GlobalParams.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 753f6ab9347f972223ec21b7ed4b4f7ebed3d420 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 3 15:29:57 2012 -0700 + + Compile with ENABLE_PLUGINS defined + + poppler/SecurityHandler.cc | 4 ++-- + poppler/SecurityHandler.h | 16 ++++++++++++++++ + poppler/XpdfPluginAPI.cc | 35 +---------------------------------- + poppler/XpdfPluginAPI.h | 34 +++++++++++++++------------------- + 4 files changed, 34 insertions(+), 55 deletions(-) + +commit 23df93aaf495428b580bafd0fd1f41515828b08d +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 3 14:50:09 2012 -0700 + + We don't support the keyBinding concept + + remove wrong merge + + poppler/GlobalParams.cc | 1 - + 1 file changed, 1 deletion(-) + +commit e55838b41959acc311e9b00dc390c9816a9afac2 +Author: Jason <jasongross9+bugzilla@gmail.com> +Date: Wed May 2 19:35:26 2012 +0200 + + glib: Use delete[] to free array allocated with new[] + + https://bugs.freedesktop.org/show_bug.cgi?id=48447 + + glib/poppler-document.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit dec873463b06bfe76ff48e36282877e6ac11b59d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 29 23:36:57 2012 +0200 + + Add the objUint type + + poppler/Object.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 50c0b294d08114920a5db711876e20d991f474a6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 29 22:33:09 2012 +0200 + + Make sure the index to dcHuffTables and acHuffTables is in bounds + + Found in a fuzzed pdf sent by Mateusz "j00ru" Jurczyk and Gynvael + Coldwind + + poppler/Stream.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 9e36206465289c96cb189c648a6f5121714c647b +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 29 22:18:12 2012 +0200 + + include for memcpy + + splash/SplashBitmap.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 931051fe0bb445545355027d999515bc3d4b32ef +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 29 22:07:34 2012 +0200 + + Make sure the index for refLine is in bounds + + Found in a fuzzed pdf sent by Mateusz "j00ru" Jurczyk and Gynvael + Coldwind + + poppler/Stream.cc | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +commit 53b9c2e2806320d0d0e35134b75da5da72514742 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 29 22:00:18 2012 +0200 + + Just call getNum if isNum is true + + Found in a fuzzed pdf sent by Mateusz "j00ru" Jurczyk and Gynvael + Coldwind + + poppler/Link.cc | 17 ++++++++++------- + 1 file changed, 10 insertions(+), 7 deletions(-) + +commit da8d858c4fc610718a5f14b14dc3a4a11564a73d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 29 20:28:37 2012 +0200 + + Do not access args[-1] + + Found in a fuzzed pdf sent by Mateusz "j00ru" Jurczyk and Gynvael + Coldwind + + poppler/Gfx.cc | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +commit 934b1a7cd502fe5537a350cdfc650989992693f7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 29 19:59:15 2012 +0200 + + Do not access invalid lookup indexes + + Found by Mateusz "j00ru" Jurczyk and Gynvael Coldwind + + poppler/GfxState.cc | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +commit e80fd082914fe29fad7e60c321a747eb8634e413 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 29 18:27:41 2012 +0200 + + [qt4] the qualified name may be unicode encoded + + qt4/src/poppler-form.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 251be1787a2a003862691f5a825eb3468eceb6a2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 29 18:26:42 2012 +0200 + + Fix getFullyQualifiedName with unicode field names + + Based on a patch from Mark Riedesel. + Bug #49256 + + poppler/Form.cc | 71 + +++++++++++++++++++++++++++++++++++++++++++++++++-------- + 1 file changed, 61 insertions(+), 10 deletions(-) + +commit be41f1c7905d695d17e19ced83a1018531d00199 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 29 16:02:45 2012 +0200 + + SplashOutputDev: Fix rendering of knockout groups + + Bug #12185 + + poppler/SplashOutputDev.cc | 31 ++++++++++++++++++++++++++++--- + splash/Splash.cc | 21 ++++++++++++++++++--- + splash/Splash.h | 6 ++++-- + splash/SplashBitmap.cc | 22 +++++++++++++++++++++- + splash/SplashBitmap.h | 2 ++ + 5 files changed, 73 insertions(+), 9 deletions(-) + +commit 800cb9ec7189a539d64b99fa181cd4126496c1ec +Author: Thomas Freitag <Thomas.Freitag@kabelmail.de> +Date: Sat Apr 28 17:15:30 2012 +0200 + + Reconstruct xref table if xref needed but missing + + Bug #40719 + + poppler/XRef.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 410822d7013ce1f61325afdb61d75ea64666755e +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Apr 27 01:10:22 2012 +0200 + + 0.19.4 + + CMakeLists.txt | 4 ++-- + NEWS | 17 +++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 6 files changed, 23 insertions(+), 6 deletions(-) + +commit b1d5c6c0a20a4a24b42de66db23e0f63d10ca52d +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Tue Apr 24 21:00:11 2012 +0200 + + Output XRef stream when incrementally updating if there's already + a XRef stream + + poppler/PDFDoc.cc | 45 ++++++++++++++++++++++++++++++-- + poppler/XRef.cc | 76 + +++++++++++++++++++++++++++++++++++++++++++++++-------- + poppler/XRef.h | 34 +++++++++++++++++++++++++ + 3 files changed, 142 insertions(+), 13 deletions(-) + +commit 2ecf3b2e49a4c35e995d25016b810592260edfeb +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Tue Apr 24 18:10:15 2012 +0200 + + Refactoring of XRef table write support (in preparation for XRef + stream write support) + + - Trailer dictionary creation now lives in its own function + "createTrailerDict" + (that will be used by XRef stream creation too) + - writeXRefTableTrailer (WAS writeTrailer) now takes care of writing + the XRef + table too (previously it was demanded to the caller) + + poppler/PDFDoc.cc | 61 + +++++++++++++++++++++++++++---------------------------- + poppler/PDFDoc.h | 14 ++++++++++--- + poppler/XRef.cc | 2 +- + poppler/XRef.h | 2 +- + utils/pdfunite.cc | 10 +++++---- + 5 files changed, 49 insertions(+), 40 deletions(-) + +commit cf7a20adbd15f901d414ce06825459c33eeef3f5 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Wed Apr 25 18:51:23 2012 +0200 + + Fix slow rendering of pdf with a lot of image masks in pattern + colorspace + + Makes it around 8 times faster + + poppler/CairoOutputDev.cc | 6 +++--- + poppler/CairoOutputDev.h | 6 +++--- + poppler/Gfx.cc | 4 ++-- + poppler/OutputDev.cc | 5 +++-- + poppler/OutputDev.h | 6 +++--- + poppler/PSOutputDev.cc | 4 ++-- + poppler/PSOutputDev.h | 4 ++-- + poppler/SplashOutputDev.cc | 35 +++++++++++------------------------ + poppler/SplashOutputDev.h | 4 ++-- + 9 files changed, 31 insertions(+), 43 deletions(-) + +commit 26fd142a3608283fd41e07b54067a51a9db76e93 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Apr 21 18:16:46 2012 +0200 + + Preserve z-index after annotation removal + + poppler/Annot.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 7b10014c1fe9ef1cba57fd6b01c63129ac31386a +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Apr 21 17:53:22 2012 +0200 + + Do not remove appearance stream if it's shared with other annotations + + poppler/Annot.cc | 78 + +++++++++++++++++++++++++++++++++++++++++++++++++++++--- + poppler/Annot.h | 6 +++++ + 2 files changed, 80 insertions(+), 4 deletions(-) + +commit 7684c325929493ad9de01a891de0aef197e176dd +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Apr 21 20:26:49 2012 +0200 + + AnnotText: Always force 24x24 size with custom stamps, not only on + first rendering + + poppler/Annot.cc | 21 ++++++++++++--------- + 1 file changed, 12 insertions(+), 9 deletions(-) + +commit 44cd46a6e04a87bd702dab4a662042f69f16c4ad +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Apr 23 20:02:55 2012 +0200 + + Do not try to access nPatches - 1 if nPatches is 0 + + Found by Mateusz "j00ru" Jurczyk and Gynvael Coldwind + + poppler/GfxState.cc | 20 +++++++++++++++++++- + 1 file changed, 19 insertions(+), 1 deletion(-) + +commit a92f87b83e3c6c9078508c644aa09f4f2b14e9cc +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Apr 23 00:06:18 2012 +0200 + + Do not complain if the entry is missing + + Since we are actually looking for non existing entries :D + + poppler/XRef.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 114e113e3278d02baaffd6c0da7fda266283c176 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Apr 21 21:08:55 2012 +0200 + + Do not allocate XRef entries whose generation number is 65535 + + poppler/XRef.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit ad8785b053aa115b593b2f20073e2989d59a77c9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Apr 18 22:51:33 2012 +0200 + + Remove duplicate call + + utils/pdftohtml.cc | 1 - + 1 file changed, 1 deletion(-) + +commit 80d4e1843c56801508f476fed64ecb3201ba18c8 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Tue Apr 17 20:25:57 2012 +0200 + + Do not draw border in AnnotText::draw + + poppler/Annot.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit a1e3d868ccd7fb84d52d94754d8681c97119fb6e +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Fri Mar 30 21:52:04 2012 +0200 + + Save/restore gfx state when drawing annot border + + poppler/Gfx.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 7fbeaac5c0d0240564add6c252c1ba7c14639d98 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 17 20:36:51 2012 +0200 + + Be sure we are checking a non free entry + + poppler/XRef.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit d1254c7e8e995302542093968a0c2967f3c0b5ff +Author: Thomas Freitag <Thomas.Freitag@kabelmail.de> +Date: Tue Apr 17 20:36:03 2012 +0200 + + Do not complain if the entry does not exist + + XRef::getNumEntry is only trying to find which entry a given stream + pos belongs so no need to cry if the entry is not there + Bug 48679 + + poppler/XRef.cc | 10 ++++++---- + poppler/XRef.h | 2 +- + 2 files changed, 7 insertions(+), 5 deletions(-) + +commit bcbe9497a4fa50b41852abd538ad139c7b6693e5 +Author: suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Tue Apr 17 20:21:58 2012 +0200 + + Copying graphics library CFLAGS to cpp frontend Makefile.am. + + Because poppler-image.cpp includes PNGWriter.h, JpegWriter.h, + TiffWriter.h, + CFLAGS to include libpng, libjpeg and libtiff headers are expected. + + cpp/Makefile.am | 22 +++++++++++++++++++++- + 1 file changed, 21 insertions(+), 1 deletion(-) + +commit 44c9df8277877ee1021317a3b6c253f80310f826 +Author: suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Tue Apr 17 20:21:00 2012 +0200 + + Do not clear FREETYPE_CFLAGS, FREETYPE_LIBS before PKG_CHECK_MODULES() + + Although configure --help says as if environmental variables + FREETYPE_CFLAGS and FREETYPE_LIBS will overwrite the values obtained + by pkg-config. But it is not. These help messages are automatically + given + by pkg-config macro (so I guess no poppler developer designed so + intentionally). + + In current configure, FREETYPE_CFLAGS, FREETYPE_LIBS are cleared + before + PKG_CONFIG_MODULES(), like: + + dnl Check for freetype headers + FREETYPE_LIBS= + FREETYPE_CFLAGS= + + PKG_CHECK_MODULES(FREETYPE, freetype2, + [freetype_pkgconfig=yes], + [freetype_pkgconfig=no]) + + if test "x$freetype_pkgconfig" = "xyes"; then + + AC_DEFINE(HAVE_FREETYPE_H, 1, [Have FreeType2 include + files]) + + else + + AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, no) + [...] + + Checking the history why these values are cleared, it seems that + the initial revision of poppler did not use pkg-config to detect + FREETYPE_CFLAGS, _LIBS. At that time, only freetype-config is used. + In later, when PKG_CHECK_MODULES is introduced, it was accidentally + introduced AFTER the clearning of FREETYPE_CFLAGS,_LIBS. As a result, + the inconsistency between "configure --help" and what configure does + really. I propose to move the clearance of FREETYPE_CFLAGS,_LIBS + just before AC_PATH_PROG, to make PKG_CHECK_MODULES catch the + environmental + values. + + configure.ac | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 9e0f0368e543df46b40cbd7bed6fdc1abf846e7d +Author: suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Tue Apr 17 20:19:41 2012 +0200 + + Do not append "-ansi" to CXXFLAG, if "-std=XXX" is already specified. + + SplashOutputDev.cc uses isfinite() function (defined by math.h). + isfinite() was standardized in C99, and imported to C++0x in later. + + In QNX header file system, isfinite() is disabled by default, + the definition of __STDC_VERSION__ > 199901 is required to enable it. + In the case of GCC, "-std=c99" (for C) or "-std=gnu++0x" (for C++) + is expected. + + But, current configure of poppler appends "-ansi" flag for CXXFLAGS, + if the compiler is known to be GNU. "-ansi" is C89 or C++98, + so isfinite() + is unavailable. I propose a patch NOT to "-ansi" flag, if CXXFLAGS + includes "-std=XXX" already. + + configure.ac | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit 2f1e7ef252b8d1f7ee6004825c2926f0f5e181a5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 12 23:11:41 2012 +0200 + + Do not crash in broken documents + + They might trigger an xref reconstruct and then i could not be in + bounds anymore + Crash found by Joel Voss of Leviathan Security Group + + poppler/XRef.cc | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +commit 19fb9caecb1b265a8b8651e9bcf4b779f593fefd +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 12 22:24:50 2012 +0200 + + Fix crash when the destination file does not exist + + Issue found by Joel Voss of Leviathan Security Group + + utils/HtmlOutputDev.cc | 18 ++++++++++-------- + 1 file changed, 10 insertions(+), 8 deletions(-) + +commit fa4848eae370437ab1b9863124e9a340830f66c7 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Apr 13 22:11:01 2012 +0930 + + man pages: add missing section heading + + utils/pdftotext.1 | 1 + + 1 file changed, 1 insertion(+) + +commit 08a14aa37b177bb4586869857ae678cb4bcd4039 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 12 21:52:30 2012 +0200 + + 0.19.3 + + CMakeLists.txt | 4 ++-- + NEWS | 26 +++++++++++++++++++++++++- + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/CMakeLists.txt | 2 +- + qt4/src/Doxyfile | 2 +- + qt4/src/Makefile.am | 2 +- + 8 files changed, 33 insertions(+), 9 deletions(-) + +commit 52227b59d1fa2a2029bfff2f8a167efd81faebbb +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 12 20:52:55 2012 +0200 + + Update (C) + + poppler/CairoFontEngine.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 40cb3f27f4dcad4fe8c48f0b638eac7913fc3722 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 12 20:50:38 2012 +0200 + + Do not pass those params to createGfx since they aren't used + + glib/poppler-page.cc | 4 ++-- + poppler/Page.cc | 9 +++------ + poppler/Page.h | 5 ++--- + 3 files changed, 7 insertions(+), 11 deletions(-) + +commit 9a10d31fca7f060f24bae9efe15662f02a9684ca +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Thu Apr 12 20:31:23 2012 +0200 + + qt4: Remove unimplemented revision setters from public API + + qt4/src/poppler-annotation-private.h | 2 ++ + qt4/src/poppler-annotation.cc | 62 + ++++++++---------------------------- + qt4/src/poppler-annotation.h | 13 -------- + 3 files changed, 16 insertions(+), 61 deletions(-) + +commit 0531329aeb8783c48f056929e6e81cebda33500f +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 12 20:07:13 2012 +0200 + + [qt4] Mark the dummy stuff as deprecated + + qt4/src/poppler-annotation.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 67b7b2bdd0943680437d96349c3415aa40082cbb +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 12 20:06:52 2012 +0200 + + [qt4] initialize the dummy members here too + + qt4/src/poppler-annotation.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit bf171382afb6b50284c3855e3a1815a15ec34366 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 12 19:24:42 2012 +0200 + + Add since markers + + qt4/src/poppler-annotation.h | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +commit e36fd775394ee752c0f62f789359c72b52094975 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 12 18:58:29 2012 +0200 + + Remove unneeded forward declaration + + qt4/src/poppler-qt4.h | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit c1aa4a8c0aa9d46757e3849776acac42731e02d1 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Thu Apr 12 00:39:33 2012 +0200 + + qt4: Annotation appearance invalidation + + Call Annot::invalidateAppearance every time the visual aspect + is changed + + qt4/src/poppler-annotation.cc | 34 ++++++++++++++++++++++++++++++++++ + 1 file changed, 34 insertions(+) + +commit 4338ae354c66e4df8d7d70a156517e27b3b80539 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sun Mar 25 22:58:33 2012 +0200 + + qt4: Added HideAnnotations option to PSConverter + + qt4/src/poppler-ps-converter.cc | 23 ++++++++++++++++++++++- + qt4/src/poppler-qt4.h | 3 ++- + 2 files changed, 24 insertions(+), 2 deletions(-) + +commit e50993b3b47a759c93ccdeeaef289d6985b05bb1 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Thu Mar 22 19:58:12 2012 +0100 + + qt4: DOM annotation store - Black color is different than invalid + color + + qt4/src/poppler-annotation.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 4739a6a02097f110c37defdfa616351459902806 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Mon Mar 19 19:17:33 2012 +0100 + + qt4: Annotation removal + + qt4/src/poppler-annotation-private.h | 3 +++ + qt4/src/poppler-annotation.cc | 29 +++++++++++++++++++++++++++++ + qt4/src/poppler-page.cc | 5 +++++ + qt4/src/poppler-qt4.h | 8 ++++++++ + 4 files changed, 45 insertions(+) + +commit 25a64d69aaab61c8cf944107e649e19920244a2b +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Tue Mar 20 01:46:07 2012 +0100 + + qt4: TextAnnotation write support + basic textFont getter + + Also makes inplaceText a synoym for contents + + qt4/src/poppler-annotation.cc | 159 + ++++++++++++++++++++++++++++++++---------- + 1 file changed, 124 insertions(+), 35 deletions(-) + +commit a31a8118ba07aa7f90c69130476fb7d86f8614ad +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sun Mar 11 23:57:51 2012 +0100 + + qt4: GeomAnnotation, InkAnnotation and CaretAnnotation write support + + qt4/src/poppler-annotation.cc | 103 + ++++++++++++++++++++++++++++++++++++++---- + qt4/src/poppler-annotation.h | 6 +-- + 2 files changed, 96 insertions(+), 13 deletions(-) + +commit e4052b52002447772e24571fd13f0f22fd2bfb16 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Mar 10 17:48:56 2012 +0100 + + qt4: HighlightAnnotation and StampAnnotation write support + + qt4/src/poppler-annotation.cc | 96 + +++++++++++++++++++++++++++++++++++++++---- + qt4/src/poppler-annotation.h | 4 +- + 2 files changed, 91 insertions(+), 9 deletions(-) + +commit b5e948b6130cdb04387a8244179337c7904dcd03 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Mar 14 17:44:50 2012 +0100 + + qt4: Annotation insertion and LineAnnotation support + + This patch adds Page::addAnnotation to insert new annotations in + a page. + The only annotation type that can be added is LineAnnotation. Support + for other + types will be added in the next patches. + + qt4/src/poppler-annotation-private.h | 12 ++ + qt4/src/poppler-annotation.cc | 297 + +++++++++++++++++++++++++++++++++-- + qt4/src/poppler-annotation.h | 4 +- + qt4/src/poppler-page.cc | 5 + + qt4/src/poppler-qt4.h | 9 ++ + 5 files changed, 316 insertions(+), 11 deletions(-) + +commit 20b4feec612448be8a800173ddadbf257657477e +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Fri Mar 9 19:31:16 2012 +0100 + + qt4: Basic setters to edit annotations + + qt4/src/poppler-annotation-helper.h | 15 ++++ + qt4/src/poppler-annotation-private.h | 1 + + qt4/src/poppler-annotation.cc | 128 + ++++++++++++++++++++++++++++++++--- + 3 files changed, 135 insertions(+), 9 deletions(-) + +commit 0e8c35b59f0fba926b30c9a87823c92ae03bf116 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Fri Mar 9 01:04:28 2012 +0100 + + qt4: Changes to Annotation API (part 2/2) + + 1) Moved annotation data retrieval logic to getters for types of + annotations + that will be made editable in next patches. + Others (Link, FileAttachment, Sound, Movie and Screen) are still + entirely filled + at creation time. + + 2) TextAnnotation's callout points setter now takes an array, not just + individual points. + + 3) AnnotationPrivate::pdfObjectReference replaced with a getter + method that + directly queries the tied Annot object (if any) + + qt4/src/poppler-annotation-helper.h | 31 +- + qt4/src/poppler-annotation-private.h | 23 +- + qt4/src/poppler-annotation.cc | 1254 + +++++++++++++++++++++++++++++++--- + qt4/src/poppler-annotation.h | 58 +- + qt4/src/poppler-link.cc | 2 +- + qt4/src/poppler-page.cc | 778 +-------------------- + qt4/src/poppler-qt4.h | 4 +- + 7 files changed, 1217 insertions(+), 933 deletions(-) + +commit 73b91207649a81740183e2288809d3b84b52f595 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Mar 7 17:05:50 2012 +0100 + + qt4: Changes to Annotation API (part 1/2) + + This is part 1/2 of a change in annotation API. It breaks both source + and binary + compatibility. + + Note that, even though DOM methods are partially modified by this + patch, their + output is 100% backward compatible. Therefore code relying only on + DOM methods + (i.e. AnnotationUtils methods) will keep working. + + 1) Style and Popup container classes + + Style and Popup (previously known as Window) properties are now + wrapped in + container classes. In both of them, private data is implicitly shared. + The old Window structure is removed, but an undocumented window + field is still + exported to make Okular 4.8.0 compile. It must not be used. + + 2) Revisions + + The Annotation::Revision structure was removed, because it added an + extra layer + of indirection that can be avoided. Now revision scope and type + are stored + directly in the target Annotation, and Annotation::revisions() + returns a list + of pointers to child annotations. + + 3) All constructors are temporarily made private + + This patch hides all constructors from user code. Subsequent + patches will + restore them in the same patch as their type-specific creation + support. + + 4) Minor fixes + - Popup size was incorrectly stored as an integer value, now + it's part of + a QRectF. + - Typo: LinkAnnotation::linkDestionation() --> linkDestination + - Dash array is now exported as QVector<doubles> instead of + a marks/spaces + integer pair + - GeomAnnotation's geometricalPointWidth removed, because it + was never + referenced and it doesn't exist in PDF specs + + 5) AnnotationPrivate data is now explicitly shared + Annotation private data has been rearranged so that it's now + possible to + uniformly give ownership of all Annotation objects to the caller. + Previously Page::annotations() did leave ownership to user, but + Annotation::revisions() didn't. Now both of them give ownership + to user. + + qt4/src/poppler-annotation-private.h | 19 +- + qt4/src/poppler-annotation.cc | 1022 + ++++++++++++++++++++++++---------- + qt4/src/poppler-annotation.h | 292 +++++++--- + qt4/src/poppler-page.cc | 92 ++- + qt4/src/poppler-qt4.h | 6 + + 5 files changed, 997 insertions(+), 434 deletions(-) + +commit 7f0f080277d35f6f2e426ca2a3ff76c2856daeaf +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Apr 10 00:08:49 2012 +0930 + + cairo: fix stroke pattern with transparency group + + Cairo copy path/append path with device offsets is broken. Use GfxPath + instead. + + Bug 48468 + + poppler/CairoOutputDev.cc | 15 ++++++--------- + poppler/CairoOutputDev.h | 4 ++-- + 2 files changed, 8 insertions(+), 11 deletions(-) + +commit 5ea305c3924cead302092378ab67300c3099afd9 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Apr 8 23:11:30 2012 +0930 + + cairo: only align stroke coords for horizontal and vertical lines + + Bug 48318 + + poppler/CairoOutputDev.cc | 80 + ++++++++++++++++++++++++++++++++++++----------- + poppler/CairoOutputDev.h | 2 +- + 2 files changed, 62 insertions(+), 20 deletions(-) + +commit 8414d8f621b8abb018e80f2255cfb511a1e558d4 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Apr 9 12:08:20 2012 +0930 + + cairo: ensure 0 width lines with stroke_adjust are aligned + + Previously the code path for 0 width lines ignored the stroke_adjust + setting. Rearrange the code so the code path for stroke_adjust == TRUE + is performed first (this will also set 0 width lines to 1 pixel wide). + + poppler/CairoOutputDev.cc | 42 +++++++++++++++++++++--------------------- + 1 file changed, 21 insertions(+), 21 deletions(-) + +commit af1a84eb90656de68bb14f2c4ae4f813c51bc3a3 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Apr 9 17:17:29 2012 +0930 + + cairo: fix paintTransparencyGroup when both mask and fill opacity + are required + + Bug 48453 + + poppler/CairoOutputDev.cc | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit 46b3a70cae3b37cb4270a83afaddd6734442b752 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Mon Apr 9 19:32:24 2012 +0200 + + Caption text rendering in AnnotLine + + poppler/Annot.cc | 262 + ++++++++++++++++++++++++++++++++++++++----------------- + poppler/Annot.h | 2 + + 2 files changed, 183 insertions(+), 81 deletions(-) + +commit 855607828447ecec2c8444650d015e21bd17d2e2 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Mon Apr 9 16:45:50 2012 +0200 + + AnnotFreeText rendering improvements (auto word-wrap, quadding, + border style, font/border color) + + poppler/Annot.cc | 146 + +++++++++++++++++++++++++++++++++++++++++++------------ + poppler/Annot.h | 1 + + 2 files changed, 115 insertions(+), 32 deletions(-) + +commit 80f662162698c1ec27771d9cf5e2e6bc3d21c4df +Author: Ihar Filipau <thephilips@gmail.com> +Date: Thu Apr 12 00:19:26 2012 +0200 + + Fix the mask inversion + + utils/HtmlOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 06591d848e53598973f7d5fddac50785a46e8027 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Wed Apr 11 23:49:29 2012 +0200 + + Fix Splash CMYK merge error + + Mail says + ****** + Hi, + + playing around with the attached PDF to get a better CMYK support for + the blend mode soft light, I encountered that I made a big mistake + during merge in the CMYK part of splash. I fixed that. The attached + patch also includes the small enhancement I made in soft light + routine. + ****** + + poppler/SplashOutputDev.cc | 9 +++++++++ + splash/Splash.cc | 2 +- + 2 files changed, 10 insertions(+), 1 deletion(-) + +commit 1f45afde6410f03c79fcf4b66d5834079879d38f +Author: Ihar Filipau <thephilips@gmail.com> +Date: Mon Apr 9 19:17:41 2012 +0200 + + Add producer and version to xml output + + utils/HtmlOutputDev.cc | 2 +- + utils/pdf2xml.dtd | 4 ++++ + 2 files changed, 5 insertions(+), 1 deletion(-) + +commit cef6ac0ebbf8451beaadb3ddb6c991bbb7239432 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sun Apr 8 23:15:15 2012 +0200 + + FIX: Do not append a NUL character to Unicode page labels + + poppler/PageLabelInfo.cc | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit 3d4985f14e54ddcc64ea654b23e931b7e6acfbdc +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Apr 7 11:28:36 2012 +0200 + + Do not trust the rect of AnnotTextMarkup when drawing + + poppler/Annot.cc | 43 +++++++++++++++++++++++++++++-------------- + 1 file changed, 29 insertions(+), 14 deletions(-) + +commit c6296cd8c1ca398beac20f1e88c87b9082386247 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Apr 7 00:30:54 2012 +0200 + + Do not trust the rect of AnnotLine, AnnotPolygon and AnnotInk + when drawing + + poppler/Annot.cc | 126 + ++++++++++++++++++++++++++++++++++++++++++++----------- + poppler/Annot.h | 27 ++++++++++++ + 2 files changed, 128 insertions(+), 25 deletions(-) + +commit 503620ae74d719da52e3374725e490c62f7be7a3 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Thu Mar 29 19:07:05 2012 +0200 + + Do not recreate Annots when writing to PS, Export poppler-generated + Annot appearance resource dict + + 1) With previous code each Annot object was reconstructed from the + pdf object when + writing to PS, leading to the fact that writeDocSetup couldn't see the + generated appearance. + This patch makes writeDocSetup use the same Annots object returned by + Page::getAnnots. + + 2) This patch also enables each Annot subtype to control the exported + resources. AnnotFreeText uses this new method to export font + information. + + 3) Comment fixed in Page.h: Page::getAnnots does *not* give away + ownership, in + fact the returned object is destroyed by ~Page. + + poppler/Annot.cc | 28 ++++++++++++++++++++++++++++ + poppler/Annot.h | 5 +++-- + poppler/FontInfo.cc | 11 ++++------- + poppler/PSOutputDev.cc | 12 +++--------- + poppler/Page.h | 2 +- + 5 files changed, 39 insertions(+), 19 deletions(-) + +commit 2733504890333b0925d95e01310726d11fed44d8 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Fri Mar 23 20:54:58 2012 +0100 + + Basic AnnotFreeText rendering (hardcoded font, WinAnsi characters + only) + + This patch also moves layoutText and writeString from AnnotWidget + to Annot + + poppler/Annot.cc | 137 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++- + poppler/Annot.h | 11 +++-- + 2 files changed, 142 insertions(+), 6 deletions(-) + +commit 3023a59c0a1a5974b232f6f8cb629eabb6797616 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sun Mar 25 22:04:11 2012 +0200 + + AnnotTextMarkup rendering improvements + + 1) FIX: Wrong coords in typeUnderline and typeStrikeout + 2) Implementation of typeSquiggly + 3) FIX: Form creation is common to all markup types + + poppler/Annot.cc | 92 + ++++++++++++++++++++++++++++++++++---------------------- + 1 file changed, 56 insertions(+), 36 deletions(-) + +commit 8927ddc448edc016043107e88e3bc3b2b8b03269 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Thu Mar 22 17:33:01 2012 +0100 + + Improvements to AnnotLine::draw + + poppler/Annot.cc | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- + 1 file changed, 46 insertions(+), 4 deletions(-) + +commit bd7a40fd0312c753d1871558b566376304f1ff35 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Mar 21 22:48:05 2012 +0100 + + AnnotInk rendering + + poppler/Annot.cc | 62 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Annot.h | 2 ++ + 2 files changed, 64 insertions(+) + +commit 6a8794abe639db8284db079e028cbcd66e138884 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Mar 21 22:33:13 2012 +0100 + + AnnotPolygon rendering + + poppler/Annot.cc | 87 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Annot.h | 2 ++ + 2 files changed, 89 insertions(+) + +commit f389c50458079f24164b1c12b1151c8617485acb +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Mar 21 21:12:59 2012 +0100 + + Do not fill AnnotGeometry with transparent color + + Previously it was filled with black. + + poppler/Annot.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit c63cc22dd82f827305ad57f241ad49998f2a1c23 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 8 12:28:17 2012 +0200 + + Remove extra copy() (memleak) + + poppler/GlobalParams.cc | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit ed0c9640abcbea459e3a276ee0b27631b01c32c4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 8 12:24:20 2012 +0200 + + Do not crash if mallocing too much memory + + Fixes crash in + https://ritdml.rit.edu/bitstream/handle/1850/11220/TYehThesis1992.pdf?sequence=1 + even though the page is still unrendered + + poppler/JBIG2Stream.cc | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +commit f1e621adbbb74ec709022b2a31195331651c83fa +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Apr 8 19:42:05 2012 +0930 + + cairo: use correct userfont font bbox + + cairo 1.12 started clipping text to the font bbox + + Bug 48399 + + poppler/CairoFontEngine.cc | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +commit f5b708c3e04ba50756cd9f9530cf82f547443ce9 +Author: Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Fri Apr 6 15:22:36 2012 +0200 + + ttc<->ttf fallback is expected for CJK font list in GlobalParamsWin.cc + + Bug 48046 + + poppler/GlobalParamsWin.cc | 224 + ++++++++++++++++++++++++++------------------- + 1 file changed, 128 insertions(+), 96 deletions(-) + +commit 4e940b14a6fddde9a1714976ff8045e26cbf7d40 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Apr 2 20:03:11 2012 +0930 + + cairo: fix regression caused by mesh gradients + + poppler/CairoOutputDev.cc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit 74a7d963de75c0097eedcf4224d13cf275a64757 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Apr 1 19:35:48 2012 +0200 + + regtest: remove debug print to show bisect exit status in Bisect.py + + regtest/Bisect.py | 1 - + 1 file changed, 1 deletion(-) + +commit 2749db77eb8ccdbc4b0771163c8942f882f259f4 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Apr 1 19:20:37 2012 +0200 + + regtest: Fix crash when creating HTML report for a single test + + regtest/commands/create-report.py | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +commit 1c8e1bb637347d0d31945f9d265b29e7b49396e2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Apr 1 19:11:57 2012 +0200 + + regtest: Don't show results for crashed or failed to run tests in + HTML report + + regtest/HTMLReport.py | 2 ++ + 1 file changed, 2 insertions(+) + +commit a5f4936dfb3e60ca37f932cc066aa10765f3cbc9 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sat Mar 24 23:13:48 2012 +0100 + + Fix: annotDisplayDecideCbk was not propagated + + poppler/OutputDev.h | 6 +++++- + poppler/PSOutputDev.cc | 11 ++++++++--- + poppler/PSOutputDev.h | 5 ++++- + poppler/Page.cc | 3 ++- + utils/HtmlOutputDev.h | 5 ++++- + 5 files changed, 23 insertions(+), 7 deletions(-) + +commit aab8c9a026f781da47ecedd453e225f906361444 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 29 21:49:38 2012 +0200 + + Increase version + + CMakeLists.txt | 4 ++-- + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 5 files changed, 6 insertions(+), 6 deletions(-) + +commit f7e65b62480631d0485167a81a588a176630dd8d +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 29 21:48:11 2012 +0200 + + 0.19.2 news + + NEWS | 23 ++++++++++++++++++++++- + 1 file changed, 22 insertions(+), 1 deletion(-) + +commit 627e072eb1edbfabf549656e9abf10100ed7340c +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 29 21:40:13 2012 +0200 + + Update copyrights + + poppler/TextOutputDev.cc | 1 + + 1 file changed, 1 insertion(+) + +commit e9ad888b003d343d8ca60f044c7cf10a8df81cf4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 29 19:49:34 2012 +0200 + + Add quotes to the poppler version define + + poppler/poppler-config.h.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 8172bb03b6e8f1c16e1a152fb251b10446f54129 +Author: Peter Breitenlohner <peb@mppmu.mpg.de> +Date: Mon Mar 26 11:13:34 2012 +0200 + + define POPPLER_VERSION as C string + + Signed-off-by: Peter Breitenlohner <peb@mppmu.mpg.de> + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 4a38d933d06d189317b1b9028c3fa4ae2a1551af +Author: Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Thu Mar 29 19:34:25 2012 +0200 + + per-collection fallback for missing CID-keyed fonts on Win32 + + poppler/GlobalParamsWin.cc | 38 ++++++++++++++++++++++++++++++++++---- + 1 file changed, 34 insertions(+), 4 deletions(-) + +commit a0b3e0938e08847d10c5d7b7528c7c5d43a7a3b8 +Author: Hib Eris <hib@hiberis.nl> +Date: Thu Mar 29 07:52:30 2012 +0200 + + Fix help message + + Partial credit goes to suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> + + configure.ac | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 631224dc0c721119c91984f1940c9e51edf17eca +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Tue Mar 20 00:56:50 2012 +0100 + + Annotation removal + + poppler/Annot.cc | 17 +++++++++++++++++ + poppler/Annot.h | 1 + + poppler/Page.cc | 36 ++++++++++++++++++++++++++++++++++++ + poppler/Page.h | 3 +++ + 4 files changed, 57 insertions(+) + +commit 20476370a445a26f1fae9db6ad58727ee3c63550 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Mar 28 23:16:37 2012 +0200 + + Basic support for Annot appearance stream removal and invalidation + + poppler/Annot.cc | 190 + +++++++++++++++++++++++++++++++++++++++++-------------- + poppler/Annot.h | 29 +++++++-- + 2 files changed, 168 insertions(+), 51 deletions(-) + +commit e9a066c3a53cc1cb73dd43a243390ae4e3c76ca3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 28 23:33:37 2012 +0200 + + Fix another typo in macGlyphNames + + fofi/FoFiTrueType.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 3d277b230e806a648fcc6d9e7af39370aa89c2ae +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Feb 18 09:19:51 2012 +1030 + + Fix typo in "mu" glyph name in truetype 'post' table standard mac + ordering + + The standard mac ordering table is at: + + https://developer.apple.com/fonts/ttrefman/rm06/Chap6post.html + + fofi/FoFiTrueType.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 47b910d35b2cf5914ed4c07f751c5e8c304be7fc +Author: suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Wed Mar 28 20:21:44 2012 +0200 + + Add quotes + + this is quite small fix. In poppler's configure, basically the shell + variables are not enclosed, and not quoted, aslike + if test x$use_glib = x; then + This syntax make the test command confused when use_glib is multi-word + value, as, "no (required cairo output)". In such case, test cannot + know + how to evaluate the token "no" "(required" "cairo", so some "syntax + error" + messages are given. Thus, quoting of the variable would be safer. + + configure.ac | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 78224609f6c1d87deee72b60a8f8f9f6c36ac75f +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 28 20:21:11 2012 +0200 + + Workaround Windows problem with libjpeg + + In libjpeg6b, there is a type definition conflict issue in jmorecfg.h. + jmorecfg.h typedefs INT16 as short, INT32 as long. The latter conflict + with basetsd.h of Microsoft Windows SDK or MinGW that typedefs INT32 + as int. basetsd.h is included by windows.h, so, if the users work with + ANSI C features only, the conflict does not appear, it would be the + background why such fundamental error has been preserved. + Anyway, jmorecfg.h designer was aware about the conflict with + X11 headers + (Xmd.h defines INT16, INT32, etc), so if we pretend as if Xmd.h were + included (by defining XMD_H), this issue can be bypassed. Attached + patch + checks the conflict, then, if there is a conflict, tries XMD_H + trick, and + uses it if it works. If jmorecfg.h or basetsd.h was manually fixed to + prevent this issue, this trick is not used. + + configure.ac | 42 ++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 42 insertions(+) + +commit d8cf31f8c7e190939525ad68cd4617fb48fea60e +Author: suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Wed Mar 28 20:20:43 2012 +0200 + + update Makefile.am to reflect LIBJPEG_CFLAGS, LIBTIFF_CFLAGS, + LIBPNG_CFLAGS for related sources. + + goo/Makefile.am | 15 +++++++++++++++ + poppler/Makefile.am | 6 ++++++ + splash/Makefile.am | 16 ++++++++++++++++ + utils/Makefile.am | 6 ++++++ + 4 files changed, 43 insertions(+) + +commit f0c13f5efc641c63627b8f0b0815b6b511d8d196 +Author: suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Wed Mar 28 20:20:06 2012 +0200 + + Configure improvements for libs in non default paths + + evaluate pkg-config-like environmental variables like LIBJPEG_CFLAGS, + LIBJPEG_LIBS, LIBTIFF_CFLAGS and LIBTIFF_LIBS in configuration. + + configure.ac | 50 ++++++++++++++++++++++++++++++++++++++++++++------ + 1 file changed, 44 insertions(+), 6 deletions(-) + +commit e55f485d803cb1f82e0d8a53d1998e1887c7920f +Author: suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Wed Mar 28 20:19:08 2012 +0200 + + Improve m4/libjpeg.m4 + + m4/libjpeg.m4 uses USER_INCLUDES and USER_LDFLAGS in it, but + USER_INCLUDES is not reflected when jpeglib.h is searched. + this patch modifies m4/libjpeg.m4 to reflect USER_INCLUDES + when jpeglib.h is searched. + + m4/libjpeg.m4 | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit e88c17d45220eea60a3dd7fab26a067616388c5f +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 28 20:05:45 2012 +0200 + + Fix compile in windows + + poppler/GlobalParamsWin.cc | 35 ++++++++++++++++++++++++++++++----- + 1 file changed, 30 insertions(+), 5 deletions(-) + +commit ee0eaabe24019d2af226ef03e3f456787525e040 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Mon Mar 19 00:05:49 2012 +0100 + + Added Array::remove (and Object::arrayRemove) + + poppler/Array.cc | 13 +++++++++++++ + poppler/Array.h | 4 ++++ + poppler/Object.h | 5 +++++ + 3 files changed, 22 insertions(+) + +commit d6a1b7dcaeac1e49533519b9f8a279fd64d04c67 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Tue Mar 27 00:00:05 2012 +0200 + + Some regression fixes/improvements + + I just finished the patch for these regressions, they had differents + reasons + 1. In CharCodeToUnicode::mapToUnicode the identity support was missing + 2. The new algorithms for axial and radial shading caused problems in + cairo. I revert these changes but removed the examination of hidden + content (this is already done in the calling function) + 3. The examination of optional hidden content in showing text + was wrong: + of course hidden text should not be shown, but text parameters + like text + position in the state must be changed! + 4. Searching and finding fonts especially with base14 fonts should be + more exact than just looking at the base14 name (i.e. fixed width + and so + on) when using fontconfig. I implement that to find the best font + fitting to the needs. + + poppler/CharCodeToUnicode.cc | 5 + + poppler/Gfx.cc | 329 + ++++++++++++++++++++----------------------- + poppler/GfxFont.cc | 3 +- + poppler/GlobalParams.cc | 78 +++++++--- + poppler/GlobalParams.h | 6 +- + 5 files changed, 218 insertions(+), 203 deletions(-) + +commit a5257efe00d0fe850b1abe5c552f7581027ac64c +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Mon Mar 26 19:28:55 2012 +0200 + + Re-added forceRasterize to PSOutputDev (and qt4 fix too)‏ + + The patch restores the forceRasterize argument in PSOutputDev ctors. + Commit 6ee907f291427b8751a872b31210bf32e8d2b722 had removed it, + turning it + into a global param. + As a side effect, this patch also fixes qt4/poppler-ps-converter, + which had + not been updated to the new signature, and thus produced corrupted + output if + forceRasterization was set. + + glib/poppler-page.cc | 2 +- + poppler/GlobalParams.cc | 16 ---------------- + poppler/GlobalParams.h | 3 --- + poppler/PSOutputDev.cc | 6 +++++- + poppler/PSOutputDev.h | 3 +++ + 5 files changed, 9 insertions(+), 21 deletions(-) + +commit 55d039ada063a9427de6dd59846ce1570ab26e9f +Author: Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Mon Mar 26 22:31:29 2012 +0200 + + CJK improvements + + More info in the mailing list threads + * script names for vertical writing mode should be differentiated + for CJK + * 2 workarounds for a Korean font on Microsoft Windows + + fofi/FoFiTrueType.cc | 47 ++++++++++++++++++++++++++++++++++++----------- + fofi/FoFiTrueType.h | 8 +++++++- + poppler/GfxFont.cc | 14 ++++++++------ + 3 files changed, 51 insertions(+), 18 deletions(-) + +commit a8b0fa4d07480242afba7751995e38eaf3147ac5 +Author: Horst Prote <prote@fmi.uni-stuttgart.de> +Date: Mon Mar 26 21:04:32 2012 +1030 + + don't add newline to last line extracted by TextSelectionDumper + + Bug 45955 + + poppler/TextOutputDev.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit c40e2315cd796ba928969d13a761f5f19d8438fc +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Mar 23 21:49:42 2012 +1030 + + cairo: use a transparency group with + setSoftMaskFromImageMask/unsetSoftMaskFromImageMask + + Drawing a tiling pattern between setSoftMaskFromImageMask and + unsetSoftMaskFromImageMask clears the softmask. + + Similar to Splash, create a transparency group in + setSoftMaskFromImageMask. Pop and paint the group in + unsetSoftMaskFromImageMask. The saveState/restoreState is to ensure + the softmask is restored before painting the group. + + Bug 47739 + + poppler/CairoOutputDev.cc | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +commit 7b57afea2e433fc7b6f359a62b1289f0e1da3267 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Mar 24 08:27:34 2012 +1030 + + cairo: update cairo mesh pattern to 1.12 api + + Now that a stable version of cairo with mesh gradient support is + released update poppler to use this api. + + poppler/CairoOutputDev.cc | 40 ++++++++++++++++++++-------------------- + poppler/CairoOutputDev.h | 4 ++-- + 2 files changed, 22 insertions(+), 22 deletions(-) + +commit 2f156b34fc8755ddd2a32cac830f3073d6b2c481 +Author: Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Fri Mar 23 20:00:18 2012 +0100 + + Fix compile in mingw-gcc + + poppler/GlobalParamsWin.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 06b6db92dd1ec32f9a55347073f8b533aa074ee1 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Sun Mar 18 23:58:05 2012 +0100 + + Added XRef::removeIndirectObject + + poppler/PDFDoc.cc | 15 ++++++++++----- + poppler/XRef.cc | 15 +++++++++++++++ + poppler/XRef.h | 2 ++ + 3 files changed, 27 insertions(+), 5 deletions(-) + +commit a2e9b7c02ffa0e5edc4da18cc726993bc92fc684 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Mon Mar 19 19:17:09 2012 +0100 + + Fix in AnnotMarkup's popup window handling + + AnnotPopup's ref was previously set to the *parent* annot, now + it's correctly + set to the *popup* annot's own. + + poppler/Annot.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 05641304df67beae546a2fe18071f3be52707aa8 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Mon Mar 19 20:56:45 2012 +0100 + + Basic Annot border editing support + + poppler/Annot.cc | 23 +++++++++++++++++++++++ + poppler/Annot.h | 9 +++++++++ + 2 files changed, 32 insertions(+) + +commit 3e6275a05066c152b265cc27275d9e4107c089e9 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Fri Mar 16 21:47:02 2012 +0100 + + Yet new setters to AnnotFreeText + + poppler/Annot.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++ + poppler/Annot.h | 2 ++ + 2 files changed, 47 insertions(+) + +commit f69f41056fc8cd8a70b38024f255e9074af20bdc +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 20 15:18:33 2012 +0100 + + cmake: reset CMAKE_REQUIRED_INCLUDES/CMAKE_REQUIRED_LIBRARIES + + cmake/modules/FindLIBOPENJPEG.cmake | 3 +++ + 1 file changed, 3 insertions(+) + +commit 4a9238441a5317c3304296e4e6430cccefe8322c +Author: Ihar Filipau <thephilips@gmail.com> +Date: Fri Mar 16 00:07:45 2012 +0100 + + Flip images if they need to + + Bug 32340 + + utils/HtmlOutputDev.cc | 50 + ++++++++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 48 insertions(+), 2 deletions(-) + +commit 6d68d0d3acc8c8e0d9d310b2e1ba2b07d6bfe942 +Author: Ihar Filipau <thephilips@gmail.com> +Date: Thu Mar 15 22:56:10 2012 +0100 + + pdftohtml: extract mask images even if they are not JPEG + + Bug #47186 + + utils/HtmlOutputDev.cc | 203 + +++++++++++++++++++++++++++++++------------------ + utils/HtmlOutputDev.h | 3 + + 2 files changed, 131 insertions(+), 75 deletions(-) + +commit 60155e0fc7224a6b479bf62133f72c460fe48078 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 15 20:46:53 2012 +0100 + + Install poppler-media.h + + qt4/src/Makefile.am | 1 + + 1 file changed, 1 insertion(+) + +commit 6a173844d5ca6f32e188406ab14cae6a7548fc1d +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 15 20:44:12 2012 +0100 + + Add the export + + qt4/src/poppler-media.h | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit e401f8e6ba3e18d5a3a4920cd111b2174c75f415 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 15 20:32:12 2012 +0100 + + Increase version and sonames + + CMakeLists.txt | 4 ++-- + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + glib/CMakeLists.txt | 2 +- + glib/Makefile.am | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/CMakeLists.txt | 2 +- + qt4/src/Doxyfile | 2 +- + qt4/src/Makefile.am | 2 +- + 9 files changed, 10 insertions(+), 10 deletions(-) + +commit ce059698e8c5097f75e7a0f828af0936aa104af0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 15 20:27:45 2012 +0100 + + 0.19.1 news + + Also inclusing 0.18.x ones + + NEWS | 110 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 110 insertions(+) + +commit 2041d5721871adb2a23999c16ecbdc60abb7b1c4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 15 20:20:31 2012 +0100 + + Update C years + + poppler/CMap.h | 1 + + poppler/GfxFont.h | 2 +- + poppler/Rendition.cc | 1 + + 3 files changed, 3 insertions(+), 1 deletion(-) + +commit 95d684aa2a87d01296f5e93516f2ac3f54adbec8 +Author: Guillermo Amaral <gamaral@kde.org> +Date: Thu Mar 15 20:13:20 2012 +0100 + + Remove the QIODevice and go with a not so good but more safer + QByteArray + + Bug #47336 + + qt4/src/CMakeLists.txt | 1 - + qt4/src/Makefile.am | 1 - + qt4/src/poppler-media.cc | 35 ++++++++++----- + qt4/src/poppler-media.h | 4 +- + qt4/src/poppler-page.cc | 1 - + qt4/src/poppler-streamsequentialdevice-private.h | 51 + --------------------- + qt4/src/poppler-streamsequentialdevice.cc | 56 + ------------------------ + 7 files changed, 26 insertions(+), 123 deletions(-) + +commit 9fee12f9bee7252db0974ef69870b69ff1452053 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 15 19:23:47 2012 +0100 + + Compile++ + + qt4/src/Makefile.am | 2 ++ + 1 file changed, 2 insertions(+) + +commit aa1e6d12d063a64a22841f7996101b45aa680ec7 +Author: Guillermo Amaral <gamaral@kdab.com> +Date: Thu Mar 15 00:35:31 2012 +0100 + + Added media rendition support for Qt4 + + qt4/src/CMakeLists.txt | 3 + + qt4/src/poppler-annotation.cc | 66 ++++++++++ + qt4/src/poppler-annotation.h | 47 ++++++- + qt4/src/poppler-link.cc | 44 +++++++ + qt4/src/poppler-link.h | 38 +++++- + qt4/src/poppler-media.cc | 149 + +++++++++++++++++++++++ + qt4/src/poppler-media.h | 94 ++++++++++++++ + qt4/src/poppler-page.cc | 32 ++++- + qt4/src/poppler-qt4.h | 2 + + qt4/src/poppler-streamsequentialdevice-private.h | 51 ++++++++ + qt4/src/poppler-streamsequentialdevice.cc | 56 +++++++++ + 11 files changed, 579 insertions(+), 3 deletions(-) + +commit 258e2197afa49e60b0b13a05408fc8d484dd8147 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Mar 14 23:25:00 2012 +0100 + + Added some new setters to AnnotFreeText + + poppler/Annot.cc | 39 +++++++++++++++++++++++++++++++++++++++ + poppler/Annot.h | 4 ++++ + 2 files changed, 43 insertions(+) + +commit 84a62ac157e03880c1c1eda60c3927bd4414640e +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Mar 14 23:24:28 2012 +0100 + + Added some new setters to AnnotGeometry, AnnotInk and AnnotCaret + + poppler/Annot.cc | 116 + +++++++++++++++++++++++++++++++++++++++++-------------- + poppler/Annot.h | 10 +++++ + 2 files changed, 96 insertions(+), 30 deletions(-) + +commit 233c9a097bdc382f6a2eb6319ee15528c72e9632 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Mar 14 23:23:59 2012 +0100 + + Added some new setters to AnnotTextMarkup and AnnotStamp + + poppler/Annot.cc | 61 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Annot.h | 11 ++++++++-- + 2 files changed, 70 insertions(+), 2 deletions(-) + +commit 8fb3ac6cf66233b80959ba99a2c706111050f5f1 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Mar 14 23:23:23 2012 +0100 + + Added Page::getDoc() + + poppler/Page.h | 2 ++ + 1 file changed, 2 insertions(+) + +commit dc4cb07c1e735006d5168e0e65f5143d7fc53e12 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Mar 14 23:22:10 2012 +0100 + + Added some new setters to AnnotLine and AnnotPolygon + + poppler/Annot.cc | 201 + +++++++++++++++++++++++++++++++++++++++++++++++++++++-- + poppler/Annot.h | 16 +++++ + 2 files changed, 211 insertions(+), 6 deletions(-) + +commit 4931018eecc37dbbe0df1a456347ab200f1b057a +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Mar 14 23:21:07 2012 +0100 + + Make Dict::set remove the entry if object is Null + + poppler/Dict.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 13ac2c0bed3fa5515a3c068488cb6a0b17410a97 +Author: Fabio D'Urso <fabiodurso@hotmail.it> +Date: Wed Mar 14 23:20:13 2012 +0100 + + Added some new setters to Annot and AnnotMarkup + + poppler/Annot.cc | 94 + ++++++++++++++++++++++++++++++++++++++++++++++++++++---- + poppler/Annot.h | 8 +++++ + 2 files changed, 96 insertions(+), 6 deletions(-) + +commit aa2b5ffa7961aac0aea33ae9a42bf1f38a756b1b +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 14 16:25:35 2012 +0100 + + qt4: replace ObjectReference with simplier Ref + + instead of roll out a new (still private) version of Ref, just use + it for private annotation and link data; + this needed a couple of explicit initializations of Ref (since it's + a simple struct with no methods) and a private operator== for it + + qt4/src/CMakeLists.txt | 1 - + qt4/src/poppler-annotation-private.h | 4 +- + qt4/src/poppler-annotation.cc | 1 + + qt4/src/poppler-link.cc | 16 ++++--- + qt4/src/poppler-link.h | 5 +- + qt4/src/poppler-objectreference.cc | 89 + ------------------------------------ + qt4/src/poppler-objectreference_p.h | 77 ------------------------------- + qt4/src/poppler-page.cc | 7 ++- + 8 files changed, 21 insertions(+), 179 deletions(-) + +commit e5b914b2bfbb5e95ecde5f1ce148374b1d58dadd +Author: Ihar Filipau <thephilips@gmail.com> +Date: Tue Mar 13 23:54:26 2012 +0100 + + Add possibilty of controlling word breaks percentage + + Bug #47022 + + utils/HtmlOutputDev.cc | 7 +++++-- + utils/pdftohtml.1 | 5 +++++ + utils/pdftohtml.cc | 7 +++++++ + 3 files changed, 17 insertions(+), 2 deletions(-) + +commit 4388cb69114e406ec29e8b6976d1a900e4ab1b7d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Mar 11 23:37:39 2012 +0100 + + Make doUpdateFont protected + + So that people inheriting from SplashOutputDev *yuck* can use it + more easily + Bug 46622 + + poppler/SplashOutputDev.h | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 448cfc431b7067af38da51e725ac0f1b2a0bc8f8 +Author: Tobias Koenig <tokoe@kdab.com> +Date: Sun Mar 11 23:22:18 2012 +0100 + + support for LinkMovie object in Qt4 frontend + + Bug #40561 + + qt4/src/CMakeLists.txt | 1 + + qt4/src/poppler-annotation-private.h | 4 ++ + qt4/src/poppler-annotation.h | 4 ++ + qt4/src/poppler-link.cc | 42 +++++++++++++---- + qt4/src/poppler-link.h | 43 +++++++++++++++-- + qt4/src/poppler-objectreference.cc | 89 + ++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-objectreference_p.h | 77 +++++++++++++++++++++++++++++++ + qt4/src/poppler-page.cc | 39 ++++++++++++---- + 8 files changed, 276 insertions(+), 23 deletions(-) + +commit a0d151deabf8243c98ff9953f8a43bb56fbf95a9 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Mar 11 16:05:15 2012 +0100 + + regtest: Add find-regression command to run git bisect automatically + + regtest/Bisect.py | 113 + ++++++++++++++++++++++++++++++++++++ + regtest/builder/__init__.py | 86 +++++++++++++++++++++++++++ + regtest/builder/autotools.py | 63 ++++++++++++++++++++ + regtest/commands/find-regression.py | 77 ++++++++++++++++++++++++ + 4 files changed, 339 insertions(+) + +commit 856768c380ecea30ce9727b81c4c44b4f9489626 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Mar 10 18:15:58 2012 +0100 + + regtest: Add information about skipped tests in the summary + + regtest/TestRun.py | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +commit 508c7c3ef1f22459daa822f8287cab382119e753 +Author: Tobias Koenig <tobias.koenig@kdab.com> +Date: Wed Mar 7 18:35:05 2012 +0100 + + Fix logic error in Rendition parsing code + + Make the rendition object invalid when both P an C entries are not + present or are invalid in Media Rendition dictionary. + + https://bugs.freedesktop.org/show_bug.cgi?id=47063 + + poppler/Rendition.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 68625258ab3cfc3e8e10a727e397f80bed0d1f5c +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Mar 4 18:37:53 2012 +1030 + + glib demo: make ctrl-q quit the demo + + glib/demo/main.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +commit 684b47727ba810ad6bf239e2838aa65b6f6cec36 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Mar 4 18:10:49 2012 +1030 + + glib demo: show font encoding in font demo + + glib/demo/fonts.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +commit 48c08d28645d82ab9d67433a0150f6e1ba24b7c6 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Mar 4 17:49:56 2012 +1030 + + glib: add poppler_fonts_iter_get_encoding + + glib/poppler-document.cc | 26 ++++++++++++++++++++++++++ + glib/poppler-document.h | 1 + + glib/reference/poppler-sections.txt | 1 + + 3 files changed, 28 insertions(+) + +commit 8d935569a977675afac35cf1bd5f2611b6a771b6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 5 21:59:09 2012 +0100 + + Fix regression in some PSOutputDev array sizing + + poppler/PSOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 2484bc0f29aef74c45ea39ef1e24804ed736154c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Mar 4 23:47:24 2012 +0100 + + Fix mismatch in some functions declarations + + goo/GooString.h | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 35c960d198d2efa97d15e962662114c5c31b8d20 +Author: Even Rouault <even.rouault@mines-paris.org> +Date: Sun Mar 4 20:32:42 2012 +0100 + + Do not crash on malformed files with 0 bits in the color map of + an image + + poppler/Gfx.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit dae29c6c201cd69cbf4f008de865cc19a36f29b3 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Mar 4 15:22:02 2012 +0100 + + CJK substitute implementation on WIndows platforms. + + When You install ghostscript on WIndows You're able to switch on CJK + support. This will create a cidfmap file in the gs-lib directory. The + ps file which creates it (mkcidfm.ps) runs over the windows font + directory and tries to create a suitable substitution table for + missing + CJK fonts. The cidfmap file is more or less PDF like, so it's + quite easy + to parse it with our parser and create a substitution table in + GlobalParamsWin and use that table. But I expect it in the poppler + data + dir instead of searching for ghostscript installation. If it is not + there, it always returns the default CID font of point 2. + You can either copy it from the gs lib directory or create it with the + ghostscript tool calling + + gswin32c -q -dBATCH -sFONTDIR=<windows font directory> + -sCIDFMAP=<popper data dir>/cidfmap mkcidfm.ps + + poppler/GlobalParams.cc | 5 +++ + poppler/GlobalParams.h | 2 + + poppler/GlobalParamsWin.cc | 106 + ++++++++++++++++++++++++++++++++++++++++----- + 3 files changed, 103 insertions(+), 10 deletions(-) + +commit 32e47ee03840cc8f21c00497025864d77edb75f5 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Mar 4 15:21:13 2012 +0100 + + Improve CJK suport in PSOutputDev + + 1. Adapt bug fix for bug 11413 to the postscript device + 2. A small bug fix when locateFont doesn't find a suitable font and + returns a null pointer + + to 1.: + Adapting the implementation of the bug fix for splash and cairo to the + postscript device was quite easy. But my first proofs of the + output with + ghostscript 8.71 shows some regressions where the CJK chars have a + smaller height than the default square of the font. But the "48" + in the + output of bug-poppler11413.pdf which is set in a "normal" font but + rotated was at the right position. Then I stepped to ghostscript 9.04, + and now the CJK chars were shown correctly, but the 48 was positioned + wrong. But because of these different tests I think that it is still a + problem in ghostscript when using a mix of CJK fonts and "normal" + fonts. + BTW, also Acrobat X distiller has problems with the position of the + "48"! + + to 2.: + On my first tests with PDF which uses non embedded CJK fonts on + Windows + I got crashes. Reason for it was that GlobalParamWin returns + Helvetica, + which is not a CID font, but locateFont accepts here only CID + fonts and + therefore returns a NULL pointer. I first fixed that and then + decided to + return as default MS Mincho if a CID font is expected. + + poppler/PSOutputDev.cc | 203 + ++++++++++++++++++++++--------------------------- + 1 file changed, 92 insertions(+), 111 deletions(-) + +commit 61037a6de157e39331ae7a8b12ee5a115fd7e936 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Mar 4 17:40:40 2012 +1030 + + glib demo: fix typo + + glib/demo/selections.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit aff5b0a4f04c12ad7733aedbc9997367f5873aa1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Mar 3 20:10:17 2012 +0100 + + regtest: Ignore backends with no results when creating html report + + regtest/HTMLReport.py | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 9d28b8db3561845f4ca94c29479a259ceaf78bc5 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Mar 3 14:42:51 2012 +0100 + + regtest: Add --pretty-diff option to create-report command + + It includes a pretty-diff link to make a bit easier to check + differences + in test results. For images it creates a html with javascript that + toggles actual and expected image, using the same code than WebKit + layout test results. For text files it uses HtmlDiff class from python + difflib. It's an option disabled by default because pretty diff + for text + files is very slow. + + regtest/HTMLReport.py | 128 + +++++++++++++++++++++++++++++++++++++- + regtest/commands/create-report.py | 4 ++ + 2 files changed, 129 insertions(+), 3 deletions(-) + +commit 670ea176495b8b580daba061840c914714bf422d +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Mar 2 22:22:16 2012 +1030 + + pdffonts: list the encoding of each font + + Bug 46888 + + poppler/CMap.h | 2 ++ + poppler/FontInfo.cc | 3 +++ + poppler/FontInfo.h | 2 ++ + poppler/GfxFont.cc | 26 ++++++++++++++++++++++++++ + poppler/GfxFont.h | 4 ++++ + utils/pdffonts.1 | 3 +++ + utils/pdffonts.cc | 7 ++++--- + 7 files changed, 44 insertions(+), 3 deletions(-) + +commit 3ab6b5ebf3b6c0d59bcb2ec68eae1aa95cab1d0e +Author: William Bader <williambader@hotmail.com> +Date: Fri Mar 2 19:40:44 2012 +0100 + + Fix pdftops -passfonts regression + + This patch fixes pdftops -passfonts by using the new psFontPassthrough + variable + consistently and removing the old psSubstFonts and its setter and + getter in + GlobalParams. + + Bug 46744 + + poppler/GlobalParams.cc | 9 +-------- + poppler/GlobalParams.h | 4 +--- + utils/pdftops.cc | 10 +++++----- + 3 files changed, 7 insertions(+), 16 deletions(-) + +commit 6c1ee34424b1122c0a2222b776d8d475f7c555cd +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Mar 2 18:41:58 2012 +1030 + + Update poppler copyright + + poppler/poppler-config.h.cmake | 2 +- + poppler/poppler-config.h.in | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit cdb1350d1e28cf3bceda75736ca91e13d193de84 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 1 18:58:02 2012 +0100 + + Increase versions + + CMakeLists.txt | 4 ++-- + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + glib/CMakeLists.txt | 2 +- + glib/Makefile.am | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/CMakeLists.txt | 2 +- + qt4/src/Doxyfile | 2 +- + qt4/src/Makefile.am | 2 +- + 9 files changed, 10 insertions(+), 10 deletions(-) + +commit 2c9e6fa5b3bc6cd01618c3fb4f46533bfce97466 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 1 18:48:17 2012 +0100 + + 0.19.0 news file + + NEWS | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 48 insertions(+) + +commit 14f6abfcb83f91755e6de05cd33870934bba3cfb +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 1 17:53:25 2012 +0100 + + Update copyrights + + goo/JpegWriter.cc | 2 +- + poppler/CairoFontEngine.cc | 1 + + poppler/CairoOutputDev.cc | 3 ++- + poppler/CairoOutputDev.h | 2 +- + poppler/CairoRescaleBox.cc | 15 +++++++++++++++ + poppler/FontInfo.cc | 2 +- + poppler/FontInfo.h | 1 + + poppler/Gfx.cc | 2 +- + poppler/GfxFont.cc | 1 + + poppler/GlobalParams.cc | 2 ++ + poppler/GlobalParams.h | 1 + + poppler/Lexer.cc | 1 + + poppler/NameToUnicodeTable.h | 2 +- + utils/ImageOutputDev.cc | 1 + + utils/ImageOutputDev.h | 1 + + utils/parseargs.cc | 1 + + utils/parseargs.h | 1 + + utils/pdffonts.cc | 1 + + utils/pdfimages.cc | 1 + + utils/pdftocairo.cc | 2 +- + utils/pdftoppm.cc | 2 +- + 21 files changed, 37 insertions(+), 8 deletions(-) + +commit e63ca8184168f824575be9bbb64e9b1eac1eff94 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu Mar 1 21:46:12 2012 +1030 + + pdftocairo: document that -scale-to will preserve aspect ratio + + based on pdftpppm patch 7ec31b8dc40ec8a3534fbb89964aa011aeb81f5e + + utils/pdftocairo.1 | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit fa82a7ce1372e5976ad95624115fcd7a4d9bd22c +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu Mar 1 21:43:32 2012 +1030 + + pdftocairo: allow one of -scale-to-[xy] = -1 to mean the aspect + ratio is to be preserved + + based on pdftoppm patch 38ace7db5de0b2b247fd520e48a8f26e5d28c9d7 + + utils/pdftocairo.1 | 8 ++++++-- + utils/pdftocairo.cc | 8 ++++++-- + 2 files changed, 12 insertions(+), 4 deletions(-) + +commit a2b008223ad6887f00d76c535f2b0b0f13f52b76 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Feb 28 21:38:19 2012 +1030 + + glib: add copy button to selections demo + + glib/demo/selections.c | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +commit b666d19308a043206e405c7e9d4ad709d68d331b +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Feb 28 21:07:06 2012 +1030 + + glib: show substitute font name in demo + + glib/demo/fonts.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit 18bc59fcf5a59b1fd51a631c02e900790c3a6dc0 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Feb 28 21:06:38 2012 +1030 + + glib: add poppler_fonts_iter_get_substitute_name + + glib/poppler-document.cc | 27 +++++++++++++++++++++++++++ + glib/poppler-document.h | 1 + + glib/reference/poppler-docs.sgml | 4 ++++ + glib/reference/poppler-sections.txt | 1 + + 4 files changed, 33 insertions(+) + +commit 4eaafe67de79fb63ebf61f031a97bbc0ed6a8891 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 29 23:22:34 2012 +0100 + + Change nnnnnn to number + + This way people won't expect it to be six fixed digits + Bug #46708 + + utils/pdftoppm.1 | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit aec6cb67951e56e4557a11c4fdf301e585268fe4 +Author: William Bader <williambader@hotmail.com> +Date: Wed Feb 29 23:18:16 2012 +0100 + + Fix stuff lost when merging xpdf303 + + restore the implementation of -binary + restore the fix that level2sep and level3sep must write cmyk instead + of rgb + restore the conversion of bitmaps with all gray to mono8 + fixed the CMYK misspelling in Stream. + + poppler/PSOutputDev.cc | 284 + +++++++++++++++++++++++++++++++++++++++++-------- + poppler/Stream.cc | 55 ++++++++-- + poppler/Stream.h | 39 ++++++- + 3 files changed, 320 insertions(+), 58 deletions(-) + +commit e977925a1eb15083e6b020b31da77ddef9d5df02 +Author: William Bader <williambader@hotmail.com> +Date: Wed Feb 29 23:12:24 2012 +0100 + + Fix double alloc + + xpdf303 merge glitch + + poppler/PSOutputDev.cc | 1 - + 1 file changed, 1 deletion(-) + +commit e13efe04facdc10f3acffece3b057544f018f40c +Author: William Bader <williambader@hotmail.com> +Date: Wed Feb 29 23:10:43 2012 +0100 + + Fix memory leak + + Wrong merge from xpdf303 + + poppler/GfxState.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit adfc03e441b2a86dab5216dc560fd79343dfbe4f +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Feb 29 21:10:56 2012 +0100 + + Only use Hints table when there are no parse errors + + Fixes bug #46459. + + poppler/Hints.cc | 6 ++++-- + poppler/Parser.cc | 30 ++++++++++++++++++++++++------ + poppler/Parser.h | 7 +++++-- + 3 files changed, 33 insertions(+), 10 deletions(-) + +commit 7ec31b8dc40ec8a3534fbb89964aa011aeb81f5e +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Feb 27 21:15:39 2012 +1030 + + pdftoppm: document that -scale-to will preserve aspect ratio + + utils/pdftoppm.1 | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 38ace7db5de0b2b247fd520e48a8f26e5d28c9d7 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Feb 25 20:02:22 2012 +1030 + + pdftoppm: allow one of -scale-to-[xy] = -1 to mean the aspect ratio + is to be preserved + + bug 43393 + + utils/pdftoppm.1 | 8 ++++++-- + utils/pdftoppm.cc | 8 ++++++-- + 2 files changed, 12 insertions(+), 4 deletions(-) + +commit 738b879ebb536cc84d7ec96543d484023b69e6d3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Feb 25 20:53:58 2012 +0100 + + regtest: Add create-report command to generate html report of + test results + + regtest/HTMLReport.py | 197 + ++++++++++++++++++++++++++++++++++++++ + regtest/backends/__init__.py | 20 +++- + regtest/commands/create-report.py | 57 +++++++++++ + 3 files changed, 273 insertions(+), 1 deletion(-) + +commit d5faabd509c2860ab199ee89b8ef9d4c14fa5118 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Feb 25 20:50:53 2012 +0100 + + regtest: Use diff.png extension for image diff files + + So that they are recognized as images + + regtest/backends/__init__.py | 16 ++++++++++++++-- + regtest/backends/cairo.py | 2 +- + regtest/backends/splash.py | 2 +- + regtest/backends/text.py | 2 +- + 4 files changed, 17 insertions(+), 5 deletions(-) + +commit 2a5f1594a23cf521497f904b502fbadf56a9e780 +Author: William Bader <williambader@hotmail.com> +Date: Sat Feb 25 16:32:33 2012 +0100 + + Fix PSOutputDev regression with -level1 + + poppler/PSOutputDev.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 6a5deb0a86ad227cce3f85b1f58a9b86755cd812 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Feb 25 19:39:02 2012 +1030 + + autoconf: PKG_CHECK_EXISTS should not have the variable prefix in + the first argument + + configure.ac | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 8f4566c14a727fb75c4c353989cf5eb96516c2e3 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Feb 22 21:21:52 2012 +1030 + + autoconf: replace openjpeg compile test with a version test + + Now that openjpeg 1.5 is released and supports pkg-config the compile + test can be replaced with a pkg-config version check. + + configure.ac | 11 +++-------- + 1 file changed, 3 insertions(+), 8 deletions(-) + +commit 30f38bf425e2f76b3f6cc4c080137ac7219a9dbe +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Feb 22 21:01:59 2012 +1030 + + autoconf: Use pkgconfig to check for libopenjpeg + + and if not found fallback to using AC_CHECK_LIB/AC_CHECK_HEADERS + + openjpeg >= 1.4 installs a pkgconfig file + + Bug 21789 + + configure.ac | 28 +++++++++++++++++----------- + 1 file changed, 17 insertions(+), 11 deletions(-) + +commit 466340d257ff0fe7e3a88a4e013e3feec3f7b70a +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Feb 23 23:47:15 2012 +0100 + + Combine UTF16 surrogate pairs + + Bug 46521 + + utils/HtmlOutputDev.cc | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +commit 675ef2bda3c4e06b39e2ba09b3b19d99cfb001b6 +Author: Oliver Sander <sander@mi.fu-berlin.de> +Date: Thu Feb 23 23:22:50 2012 +0100 + + Compile + + poppler/Stream.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 7705e65c231cc3af296bf19f5cba110cabb72e7d +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Feb 23 23:09:23 2012 +0100 + + Generate outlines in pdftohtml in -xml mode. + + Bug 56993 + + utils/HtmlOutputDev.cc | 130 + ++++++++++++++++++++++++++++++++++++------------- + utils/HtmlOutputDev.h | 7 ++- + utils/pdf2xml.dtd | 7 ++- + utils/pdftohtml.cc | 5 +- + 4 files changed, 108 insertions(+), 41 deletions(-) + +commit 30446bdd7e202eed88d131e04477c76861fd145c +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Feb 23 22:56:17 2012 +0100 + + Use an Identity CharCodeToUnicode for Adobe-Identity and Adobe-UCS + collections + + Also fix Identity CharCodeToUnicode code + + Bug #35468 + + poppler/CharCodeToUnicode.cc | 18 +++++++++++++----- + poppler/CharCodeToUnicode.h | 7 +++++-- + poppler/GfxFont.cc | 13 +++++++------ + 3 files changed, 25 insertions(+), 13 deletions(-) + +commit 71104f1ec55d3be999afaa1b62405454b31066a9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Feb 23 19:34:57 2012 +0100 + + Remove unneded CharCodeToUnicode includes + + poppler/ArthurOutputDev.cc | 3 +-- + poppler/CairoFontEngine.cc | 3 +-- + poppler/CairoOutputDev.cc | 3 +-- + poppler/SplashOutputDev.cc | 3 +-- + 4 files changed, 4 insertions(+), 8 deletions(-) + +commit c0c8cc1592ee6aa13157e34f8083b951d487a413 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu Feb 23 21:13:23 2012 +1030 + + glib docs: fix typo + + glib/poppler.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit fde3bed0f400a50f31f1f6bcee44ac1b2c17ddc6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 22 00:03:37 2012 +0100 + + pdfinfo: decode utf-16 surrogate pairs + + Based on a patch by Adrian Johnson + Bug 23075 + + utils/pdfinfo.cc | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +commit 3361564364a1799fc3d6c6df9f208c5531c407dc +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Feb 21 22:20:02 2012 +0100 + + Expand glyph name ligatures such as "ff", "ffi" etc to normal form + + Bug 7002 + + poppler/GfxFont.cc | 14 +++++++++++++- + poppler/UnicodeTypeTable.cc | 9 +++++++++ + poppler/UnicodeTypeTable.h | 3 +++ + 3 files changed, 25 insertions(+), 1 deletion(-) + +commit d0186c558f4a84a9317687ad50b460d34fb5fdf0 +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 20 22:18:00 2012 +0100 + + cmake: support for lcms2 + + followup of e48c22d3b70412015b9cc07a9a6ce07845274e13 also for the + CMake build system, + importing the FindLCMS2.cmake from kdelibs + + CMakeLists.txt | 26 +++++++++++++-- + cmake/modules/FindLCMS2.cmake | 73 + +++++++++++++++++++++++++++++++++++++++++++ + config.h.cmake | 3 ++ + utils/CMakeLists.txt | 3 ++ + 4 files changed, 102 insertions(+), 3 deletions(-) + +commit e48c22d3b70412015b9cc07a9a6ce07845274e13 +Author: Koji Otani <sho@bbr.jp> +Date: Mon Feb 20 22:04:01 2012 +0100 + + Add support for lcms2 + + configure.ac | 24 ++++++- + poppler/GfxState.cc | 159 + +++++++++++++++++++++++++++----------------- + qt4/src/poppler-document.cc | 5 ++ + utils/pdftocairo.cc | 17 +++++ + 4 files changed, 143 insertions(+), 62 deletions(-) + +commit 1bcae7aa8f87cc85ee6b477bf0abb49452e46505 +Author: Igor Slepchin <igor.redhat@gmail.com> +Date: Sun Feb 19 23:40:50 2012 +0100 + + Consistently check if pdftohtml needs to generate outlines. + + utils/pdftohtml.cc | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +commit 126bf08105e319f9216654782e5a63f99f1d1825 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 19 23:18:25 2012 +0100 + + Update glyph names to Unicode values mapping + + Added Zapf Dingbat names and fixed copyrightsans, copyrightserif, + registersans, registerserif, trademarksans, trademarkserif + Kudos to Adrian Johnson for find what was missing :-) + Bug #13131 + + poppler/NameToUnicodeTable.h | 213 + +++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 207 insertions(+), 6 deletions(-) + +commit c0fec84312a37f62bdbfdee7c8e9b520af28330a +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 19 14:47:24 2012 +0100 + + fix typo, GString -> GooString + + goo/GooString.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit aaae8996766f259dcc329755c7cccde7c916c1fb +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu Feb 16 22:22:15 2012 +1030 + + cairo: set mask matrix before drawing an image with a mask + + Bug 40828 + + poppler/CairoOutputDev.cc | 1 + + 1 file changed, 1 insertion(+) + +commit fff439f25d9bbd199db5646deccd80733138898e +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Feb 19 15:45:31 2012 +1030 + + update .gitignore + + utils/.gitignore | 1 + + 1 file changed, 1 insertion(+) + +commit 1cc3e152d6e879eb13fbdf2964ede3e01d13d097 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Feb 19 15:43:09 2012 +1030 + + glib docs: fix typo + + glib/poppler-page.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 4f4db591276ec156c55b3a3c2020a1cf82f1519b +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Feb 19 15:37:04 2012 +1030 + + cairo: fix pdftocairo crash when pdf document uses actualText + + poppler/CairoOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 9b72ee4e4c8658b2f7cd542d601a5c3be621d3fc +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sat Feb 18 17:34:12 2012 +0100 + + Make some of the unfilteredResets be really unfiltered + + poppler/Stream.cc | 26 ++++++++++++++++++++------ + poppler/Stream.h | 3 +++ + 2 files changed, 23 insertions(+), 6 deletions(-) + +commit 33aded82fbd98832eaab7cb7487fe6a1c7ef15f5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 18 17:21:10 2012 +0100 + + Rework XRef getNumObjects and getSize + + Kill XRef::last since we do not maintain it correctly, now + getNumObjects returns size as it did + Kill getSize as it just returns the same as getNumObjects + + poppler/PDFDoc.cc | 10 +++++----- + poppler/XRef.cc | 12 +----------- + poppler/XRef.h | 6 ++---- + 3 files changed, 8 insertions(+), 20 deletions(-) + +commit 521d3740e9b7d2cfacf29f089a4a8f6c962de807 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Feb 13 22:05:18 2012 +1030 + + pdfimages: add -list option to list all images + + Bug 46066 + + utils/ImageOutputDev.cc | 204 + ++++++++++++++++++++++++++++++++++++++++++------ + utils/ImageOutputDev.h | 20 ++++- + utils/pdfimages.1 | 101 ++++++++++++++++++++++++ + utils/pdfimages.cc | 12 ++- + 4 files changed, 307 insertions(+), 30 deletions(-) + +commit 119b6b752314c9b13440eddf5bd1d5cef2966e80 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Feb 6 16:50:11 2012 +1030 + + cairo: don't read inline image streams twice + + Bug 45668 + + poppler/CairoOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit a76135391555145ec740d49a7141e60da0ea5dee +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Feb 14 20:11:19 2012 +0100 + + Add a configuration option for the test data dir + + This makes 'make distcheck' run succesfully. + + CMakeLists.txt | 20 ++++++++++++++++++++ + Makefile.am | 2 +- + configure.ac | 42 + +++++++++++++++++++++++++++++++++++++++++ + qt4/tests/CMakeLists.txt | 1 + + qt4/tests/Makefile.am | 1 + + qt4/tests/check_actualtext.cpp | 2 +- + qt4/tests/check_attachments.cpp | 14 +++++++------- + qt4/tests/check_fonts.cpp | 18 +++++++++--------- + qt4/tests/check_links.cpp | 6 +++--- + qt4/tests/check_metadata.cpp | 32 +++++++++++++++---------------- + qt4/tests/check_optcontent.cpp | 12 ++++++------ + qt4/tests/check_pagelayout.cpp | 6 +++--- + qt4/tests/check_pagemode.cpp | 10 +++++----- + qt4/tests/check_password.cpp | 12 ++++++------ + qt4/tests/check_permissions.cpp | 2 +- + qt4/tests/check_search.cpp | 4 ++-- + 16 files changed, 124 insertions(+), 60 deletions(-) + +commit 59946e0c34e762eb5f5a13b4ae8c9ec7fb21379a +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Tue Feb 14 19:37:21 2012 +0100 + + Overprint implementation in postscript and splash device + + It is an enhancement patch, a + merge fix and a bug fix in one: an enhancement, because it now + completes + the implementation overprint mode and devicen in postscript, a merge + fix, because it fixes some bugs in the overprint implementation in + splash of xpdf 3.0.3 and has now the complete functionality (and + more!) + of my implementation back again and a bug fix, because it fixes + the use + of splash cmyk in postscript which never had worked. + + 1. Overprint implementation in postscript + To have a complete overprint implementation in the (pure) postscript + device there were just two things missing: overprint mode and the + implementation of the DeviceN colorspace in PostScript. I double + checked + my implementation with the Ghent Test Suite with GhostScript (device + pdfwrite) and Acrobat X distiller, and all the tests now succeeds, + either in Acrobat X distiller or in GhostScript. As overprint is a + device dependent feature, it is up to the output device if it supports + overprint and what features of overprint are supported, and often You + have various configuration possibilities there. Nearly all PostScript + output of the Ghent tests show now the desired results if converting + it + back to PDF with ghostscript pdfwrite, the implementation in + ghostscript + is complete. On the other hand a few tests failed when using Acrobat X + distiller, all of them with the overprint mode switch. Funny, because + overprint mode 1 is often also called the illustrator overprint mode + because it was introduced by illustrator, but probably the destiller + only handles EPS correctly which comes from illustrator + + 2. Overprint implementation in postscript if using splash + rasterization + Of course the postscript overprint implementation will only work if + pdftops doesn't decide to use splash to rasterize it because of + the use + of transparencies in the PDF. But because overprint is device + dependent + I decided to spend an additional parameter "overprint" to pdftops + (simular to pdftoppm). Switching it on (only available if compiled + with + SPLASH_CMYK, because overprint is only in CMYK colorspace showable) + will + use the overprint implementation in splash also if rasterizing + the PDF. + + 3. Overprint implementation in splash + The overprint implementation in splash now uses the better designed + interface of xpdf and therefore now also works in transparency groups. + Thanks to the developper team of xpdf. I just fixed a small bug in it, + where it defies the technical specification. Of course it is still in + the nature of the splash implementation that it fails if CMYK values + should overprint spot colors, because spot colors are converted + immediately in their CMYK alternates. And in the implementation of + overprinting spot colors over CMYK colors I made a small assumption to + get it running which causes undesired results if this assumption + fails, + but I didn't want to implement more and more configuration switches. I + still plan to implement a DeviceN output in splash and make a complete + implementation there, but this is of course a bigger task (but + doable). + The overprint switch in pdftoppm is still only available if compiled + with the SPLASH_CMYK directive. + + poppler/PSOutputDev.cc | 67 ++++++++++-- + poppler/PSOutputDev.h | 3 +- + poppler/SplashOutputDev.cc | 62 ++++++++++-- + poppler/SplashOutputDev.h | 4 +- + splash/Splash.cc | 70 +++++++++---- + splash/Splash.h | 4 +- + splash/SplashState.cc | 5 +- + splash/SplashState.h | 247 + +++++++++++++++++++++++---------------------- + utils/pdftops.cc | 13 +++ + 9 files changed, 308 insertions(+), 167 deletions(-) + +commit b505920db6d3dac58c7e9f4f8917f4c4449b08a0 +Merge: 9250449 a631281 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 14 19:18:54 2012 +0100 + + Merge remote-tracking branch 'origin/xpdf303merge' + + Conflicts: + utils/HtmlOutputDev.cc + utils/HtmlOutputDev.h + +commit 9250449aaa279840d789b3a7cef75d06a0fd88e7 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Feb 12 23:16:41 2012 +0100 + + Improve moc detection when cross compiling + + configure.ac | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit 66cf1fdb3ba6894f61d9078f5c30046b464347ae +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 12 22:27:58 2012 +0100 + + qt4: remove non-existing 'qt' include dirs + + qt4/demos/Makefile.am | 1 - + qt4/src/Makefile.am | 1 - + qt4/tests/Makefile.am | 1 - + 3 files changed, 3 deletions(-) + +commit 53d8fc4d2978b70e8926e3df71facd1f39de9348 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 12 17:36:55 2012 +0100 + + man pages: fix minor issues with hypens and % + + utils/pdfseparate.1 | 6 +++--- + utils/pdftocairo.1 | 4 ++-- + 2 files changed, 5 insertions(+), 5 deletions(-) + +commit a63128179c65b5d9d6d9d41fa601a593b0a05d94 +Author: Thomas Freitag <Thomas.Freitag@kabelmail.de> +Date: Thu Feb 9 22:02:52 2012 +0100 + + [xpdf303] Fix merge issue + + utils/pdftoppm.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit cd5a6a4d02e579e543067d1847164aff90363f16 +Author: Thomas Freitag <Thomas.Freitag@kabelmail.de> +Date: Thu Feb 9 22:01:42 2012 +0100 + + [xpdf303] Fix merge bug + + poppler/GfxState.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 597fa37cacec928c40d0491174ce843fe01f26d9 +Author: Igor Slepchin <igor.slepchin@gmail.com> +Date: Wed Feb 8 19:22:13 2012 -0500 + + Close li tags in generated outlines. + + Also, add newlines after ul tags for better readability. + Bug #45807 + (cherry picked from commit bf81250ff7d0968852fc7559fafb6389cd695b91) + + utils/HtmlOutputDev.cc | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +commit 2fc36dba5f63703896722adb5127896e4c2840e7 +Author: Igor Slepchin <igor.slepchin@gmail.com> +Date: Thu Feb 9 00:15:13 2012 +0100 + + Get rid of static data members; merge duplicated jpeg dumping code. + + HtmlPage::pgNum is never used; + imgNum is always equal to imgList->getLength()+1 + imgList is now maintained in HtmlPage. + + utils/HtmlOutputDev.cc | 143 + +++++++++++++++++++------------------------------ + utils/HtmlOutputDev.h | 15 ++++-- + 2 files changed, 65 insertions(+), 93 deletions(-) + +commit f655efe327ddd3b6a68353a62589d4e4f8a318a8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 8 23:58:27 2012 +0100 + + Fix memory leak when using HtmlOutputDev::mapEncodingToHtml + + Bug #45805 + (cherry picked from commit 53a0c2043dfd56f6da7780f1a049f75af368b84b) + + utils/HtmlOutputDev.cc | 47 + ++++++++++++++++++++++++----------------------- + utils/HtmlOutputDev.h | 7 ++++--- + 2 files changed, 28 insertions(+), 26 deletions(-) + +commit 68f02d19c571fce956c7f4af6ccd0ff9ba8b1b03 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 8 23:47:46 2012 +0100 + + Fix leak in pdftohtml getInfoString + + Bug #45805 + (cherry picked from commit 4afe4d827a342a847e8b89aba5b4164ed3b4cc32) + + utils/pdftohtml.cc | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit 2b7ba166c28e32653db4ae7acf90e06e0dd5975b +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 8 19:12:52 2012 +0100 + + [xpdf303] Compile fixes + + poppler/GlobalParamsWin.cc | 2 +- + poppler/SplashOutputDev.cc | 10 ---------- + 2 files changed, 1 insertion(+), 11 deletions(-) + +commit b8c9b179c9491cf6755b07bfdec4174e78b7d241 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Feb 6 19:55:07 2012 +0100 + + [xpdf303] Adapt better to what we did and what xpdf303 does + + poppler/ArthurOutputDev.cc | 1 - + poppler/GlobalParams.cc | 10 ---------- + poppler/GlobalParams.h | 1 - + poppler/SplashOutputDev.cc | 3 --- + poppler/SplashOutputDev.h | 1 - + splash/SplashFTFont.cc | 40 + +++++++++++++++++++--------------------- + splash/SplashFTFont.h | 1 - + splash/SplashFTFontEngine.cc | 7 +++---- + splash/SplashFTFontEngine.h | 5 ++--- + splash/SplashFontEngine.cc | 3 +-- + splash/SplashFontEngine.h | 1 - + utils/pdftoppm.cc | 2 +- + 12 files changed, 26 insertions(+), 49 deletions(-) + +commit ea6bc19564865e04431d9154802ae7fba975a716 +Merge: e17f095 92ce79f +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Feb 6 01:18:25 2012 +0100 + + Merge branch 'master' into xpdf303merge + + Conflicts: + poppler/CairoOutputDev.cc + poppler/CairoOutputDev.h + poppler/FontInfo.cc + poppler/GfxFont.cc + poppler/GfxState.cc + poppler/GlobalParams.cc + poppler/GlobalParams.h + poppler/Lexer.cc + +commit e17f09563276ee25b6acfc127b6ea360da650030 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Feb 6 00:25:53 2012 +0100 + + [xpdf303] TextOutputDev and associated changes + + cpp/poppler-page.cpp | 10 +- + glib/poppler-page.cc | 5 +- + poppler/ArthurOutputDev.cc | 1 + + poppler/CairoOutputDev.cc | 2 +- + poppler/Gfx.cc | 6 +- + poppler/PSOutputDev.cc | 6 +- + poppler/TextOutputDev.cc | 360 + ++++++++++++++++++++++++++++----------------- + poppler/TextOutputDev.h | 18 ++- + qt4/src/poppler-page.cc | 12 +- + test/perf-test.cc | 2 +- + utils/pdftotext.1 | 4 + + utils/pdftotext.cc | 10 +- + 12 files changed, 270 insertions(+), 166 deletions(-) + +commit 548648bf29dc1551443eb1925814342e7aadee46 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 5 23:08:44 2012 +0100 + + [xpdf303] Merge PDFDoc encryption related code + + poppler/PDFDoc.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 6ee907f291427b8751a872b31210bf32e8d2b722 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 5 22:57:25 2012 +0100 + + [xpdf303] More merges from Thomas, basically PSOutputDev and some + other small stuff + + poppler/GfxFont.cc | 4 +- + poppler/GlobalParams.cc | 95 ++- + poppler/GlobalParams.h | 18 +- + poppler/GlobalParamsWin.cc | 16 +- + poppler/Hints.cc | 2 +- + poppler/PSOutputDev.cc | 1814 + ++++++++++++++++++++++--------------------- + poppler/PSOutputDev.h | 51 +- + poppler/Parser.cc | 13 +- + poppler/Parser.h | 7 +- + poppler/PreScanOutputDev.cc | 70 +- + poppler/PreScanOutputDev.h | 16 +- + poppler/XRef.cc | 91 ++- + poppler/XRef.h | 3 +- + utils/pdftops.cc | 2 +- + 14 files changed, 1231 insertions(+), 971 deletions(-) + +commit 92ce79f47f929392f48737612a9690088573f63d +Author: Igor Slepchin <igor.redhat@gmail.com> +Date: Sun Feb 5 15:55:39 2012 +0100 + + Proper unicode support when dumping PDF outline. + + Also use of already existing Outline class rather than parsing the + outline anew. + + Bug 45572 + (cherry picked from commit 40f7289ab04787734b856c53d5c0139445b52635) + + Conflicts: + + utils/HtmlOutputDev.cc + + utils/HtmlOutputDev.cc | 197 + ++++++++++++++++++++++++++----------------------- + utils/HtmlOutputDev.h | 6 +- + utils/pdftohtml.cc | 3 +- + 3 files changed, 112 insertions(+), 94 deletions(-) + +commit 38ec58ed1cb54722aece875287b847643aa2c4b8 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Feb 4 17:13:30 2012 +1030 + + Lexer: convert integer to real when overflow occurs + + Bug 45605 + + poppler/Lexer.cc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit df89de61b7d01f0f816e773cdb809faa3053e962 +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Jan 31 20:01:30 2012 +0100 + + glib: Exclude poppler-private.h from introspection files + + Fixes bug #45455. + + glib/CMakeLists.txt | 2 +- + glib/Makefile.am | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 88cb6d9360bc943fc2cdda262dc46bf831641541 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Feb 4 12:04:03 2012 +0100 + + glib: Update gtk-doc makefile and m4 file + + gtk-doc.make | 112 + +++++++++++++++++++++++++++++++++------------------------- + m4/gtk-doc.m4 | 6 ++++ + 2 files changed, 70 insertions(+), 48 deletions(-) + +commit 3f4164f84bbf748a2f919741669ef20db0fbda9f +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Feb 1 10:44:17 2012 +0100 + + gtk-doc: Fix build when builddir != srcdir + + Bug #45549. + + glib/reference/Makefile.am | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +commit 8daeb82f982eba25fe8c7d07358f0a6593ddc89a +Author: Hib Eris <hib@hiberis.nl> +Date: Thu Feb 2 13:01:45 2012 +0100 + + gtk-doc: Fix API documentation for poppler_page_free_annot_mapping() + + Remove reference to non existent method poppler_annot_free() and use + ref/unref instead of copy/free. + + Bug #45549. + + glib/poppler-page.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit f8ce9966e4f480949799a26c01bd861f4011b587 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Feb 4 11:51:34 2012 +0100 + + gtk-doc: Remove reference to non existent method poppler_layer_free() + + Bug #45549. + + glib/poppler-document.cc | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +commit f58f3525f135bc47e89c23c33e96e43db10d4853 +Author: Hib Eris <hib@hiberis.nl> +Date: Thu Feb 2 15:59:47 2012 +0100 + + gtk-doc: Add more glib API documentation for poppler-document + + Fixes several gtk-doc warnings. + + Bug #45549. + + glib/poppler-document.h | 26 +++++++++++++------------- + 1 file changed, 13 insertions(+), 13 deletions(-) + +commit 080247f6a47bc929b25f6e000f4474801af74b1f +Author: Hib Eris <hib@hiberis.nl> +Date: Thu Feb 2 15:45:37 2012 +0100 + + gtk-doc: remove references to removed pixbuf functions + + Bug #45549. + + glib/poppler-page.cc | 6 ++---- + glib/reference/poppler-sections.txt | 4 ---- + 2 files changed, 2 insertions(+), 8 deletions(-) + +commit 47780d9ed1fd69068fdb9b9782e2cb37e2a5b217 +Author: Hib Eris <hib@hiberis.nl> +Date: Thu Feb 2 15:43:30 2012 +0100 + + gtk-doc: do not build doc for glib-demo + + Fixes glib-demo symbols in poppler-unused.txt + + Bug #45549. + + glib/reference/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e320f335cc6e54c60bd2436799dd1f05beb060ba +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Feb 4 11:32:50 2012 +0100 + + gtk-doc: Fix typo's + + Bug #45549. + + glib/poppler-annot.cc | 6 +++--- + glib/poppler-annot.h | 2 +- + glib/poppler-document.cc | 2 +- + glib/poppler-media.cc | 2 +- + glib/poppler-page.cc | 3 +-- + glib/poppler-page.h | 4 ++-- + glib/reference/poppler-sections.txt | 4 +++- + 7 files changed, 12 insertions(+), 11 deletions(-) + +commit 1fe27b07975e9a9455708563118fb73cce696f81 +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Jan 31 12:49:01 2012 +0100 + + cairo: Remove unused variable in CairoFontEngine.cc + + Fixes bug #45442. + + poppler/CairoFontEngine.cc | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit e3d80c79815ce46daf3c3f2b944f49eaf19bfea5 +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Jan 31 14:42:04 2012 +0100 + + Fix return value of downscale_box_filter() + + Fixes bug #45441. + + poppler/CairoRescaleBox.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e074e526fa206403b84da5ce0f27d7357223c7ac +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Jan 31 13:02:16 2012 +0100 + + Fix return value of poppler_attachment_save + + Fixes bug #45440. + + glib/poppler-attachment.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit bc389cff91c350d7da186d4cf707c389c77bbc29 +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Jan 31 14:03:08 2012 +0100 + + glib-demo: Do not use deprecated gtk_dialog_set_has_separator() + + Bug #45439 + + glib/demo/main.c | 2 ++ + 1 file changed, 2 insertions(+) + +commit e52e3c24663edaa630d9187e832223b474b74089 +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Jan 31 13:39:05 2012 +0100 + + glib-demo: Do not use deprecated GtkComboBox API + + Bug #45439. + + glib/demo/annots.c | 6 ++++++ + glib/demo/print.c | 9 ++++++++- + glib/demo/render.c | 16 ++++++++++++++++ + glib/demo/selections.c | 8 ++++++++ + 4 files changed, 38 insertions(+), 1 deletion(-) + +commit 165ab4ec122d0e1a6f30dcfba80aefc422cd83b7 +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Jan 31 12:15:51 2012 +0100 + + Fix build for builddir != srcdir + + Fixes bug #45434. + + glib/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e424a13bb516464d59ad76fd0933e92f3307b21b +Author: Thomas Freitag <Thomas.Freitag@kabelmail.de> +Date: Fri Feb 3 00:12:10 2012 +0100 + + pdfseparate fixes by Thomas after his last commit + + poppler/PDFDoc.cc | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit 4fcd42cfa4424992cd4b36af38bc6230ce0706c9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 1 22:53:03 2012 +0100 + + [xpdf303] More merges from Thomas (with minor fixes from me) + + Basically fonts related and some other small stuff + + poppler/Annot.cc | 6 +- + poppler/ArthurOutputDev.cc | 47 +-- + poppler/CMap.cc | 153 ++++++++ + poppler/CMap.h | 16 + + poppler/CairoFontEngine.cc | 43 +-- + poppler/CharCodeToUnicode.h | 1 + + poppler/FontInfo.cc | 8 +- + poppler/Gfx.cc | 363 +++++++++++-------- + poppler/GfxFont.cc | 831 + +++++++++++++++++++++++++++++--------------- + poppler/GfxFont.h | 34 +- + poppler/GfxState.cc | 81 +++-- + poppler/GfxState.h | 2 + + poppler/GlobalParams.cc | 738 ++++++++++++++++++++++----------------- + poppler/GlobalParams.h | 112 +++--- + poppler/GlobalParamsWin.cc | 180 ++++++++-- + poppler/PSOutputDev.cc | 591 +++++++++++++++---------------- + poppler/PSOutputDev.h | 12 +- + poppler/PreScanOutputDev.cc | 10 +- + poppler/SplashOutputDev.cc | 59 ++-- + poppler/XRef.cc | 16 +- + 20 files changed, 2008 insertions(+), 1295 deletions(-) + +commit 0089357de8ea96f3e394ea9cb37e8182ccf15ae2 +Author: Thomas Freitag <Thomas.Freitag@kabelmail.de> +Date: Wed Feb 1 19:17:38 2012 +0100 + + pdfseparate: Produce PDF/X conformant pdf pages if the original PDF + was PDF/X conformant. + + poppler/PDFDoc.cc | 63 + ++++++++++++++++++++++++++++++++++--------------------- + poppler/XRef.cc | 9 +++++++- + poppler/XRef.h | 5 ++++- + 3 files changed, 51 insertions(+), 26 deletions(-) + +commit be62a4f2e7d5db3b6d85d1b3026979f9561e6e15 +Author: Hib Eris <hib@hiberis.nl> +Date: Mon Jan 30 17:07:28 2012 +0100 + + Fix build with latest mingw-w64 headers + + Fixes bug #45407. + (cherry picked from commit 58c17c3a61f18a6808ec9ba37e82734a655090ac) + + glib/poppler-annot.cc | 1 + + glib/poppler-document.cc | 1 + + 2 files changed, 2 insertions(+) + +commit acbc63348ce5e279e4d66ed4f240dc8d61df4e57 +Author: Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Mon Jan 30 20:46:04 2012 +1030 + + pdftocairo/automake: link with lcms + + utils/Makefile.am | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 9548573a16629fecdbd44c9aac8b626ec6f53b81 +Author: Pino Toscano <pino@kde.org> +Date: Mon Jan 30 00:32:52 2012 +0100 + + glib/cmake: various minor introspection improvements + + "port" to CMake of the automake equivalents of + 4765c3289635fe4fb006e7df4f83d7056eb42855 + + glib/CMakeLists.txt | 3 +++ + 1 file changed, 3 insertions(+) + +commit bf2ffb1cc76bcf569419ac495f524c41bb6f1650 +Author: Pino Toscano <pino@kde.org> +Date: Mon Jan 30 00:21:31 2012 +0100 + + cmake: support $(gir_name)_EXPORT_PACKAGES for g-ir-scanner + + cmake/modules/GObjectIntrospectionMacros.cmake | 2 ++ + 1 file changed, 2 insertions(+) + +commit cbe7131e63c5896010e7e1ad5c0c3aa91611704d +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jan 27 00:36:18 2012 +0100 + + Set OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG if you have it + + Fixes/workarounds bug 43414 with openjpeg 1.5 (unreleased) + (cherry picked from commit de6415af1a39ec7dfa4f149c6c5e311b86352cec) + + cmake/modules/FindLIBOPENJPEG.cmake | 13 +++++++++++++ + config.h.cmake | 3 +++ + configure.ac | 8 ++++++++ + poppler/JPEG2000Stream.cc | 7 ++++++- + 4 files changed, 30 insertions(+), 1 deletion(-) + +commit 641526d1a7e8032ea8f7b8ac42c5ad8c20448d9b +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Jan 25 22:44:27 2012 +1030 + + jpeg: set image parameters after jpeg_set_defaults() + + so the resolution does not get overwritten by the defaults. + + The libjpeg documentation for jpeg_set_defaults() states: "This + routine sets all JPEG parameters to reasonable defaults, using only + the input image's color space (field in_color_space, which must + already be set in cinfo)" + + Bug 45224 + + goo/JpegWriter.cc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit f7356a88fe983c2ddd7d5a50400768310a26c4d2 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu Jan 26 11:33:28 2012 +1030 + + glib: add section in docs for new symbols in 0.18 + + glib/reference/poppler-docs.sgml | 4 ++++ + 1 file changed, 4 insertions(+) + +commit b42c171de93dba56859beb21cfe5312d825fedd6 +Author: Alexander Saprykin <xelfium@gmail.com> +Date: Mon Jan 23 22:07:15 2012 +0100 + + Do not use 50Kb of stack in SplashXPath::addCurve + + Bug 44905 + + splash/SplashXPath.cc | 69 + ++++++++++++++++++++++++++++++++++++--------------- + 1 file changed, 49 insertions(+), 20 deletions(-) + +commit a04fca6266bda6d04068f38f16fe492cb6b8677b +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Jan 21 09:41:12 2012 +1030 + + cairo: use fabs when comparing the transformed line width + + as the transform may cause a negative width. + + Bug 43441 + + poppler/CairoOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ce1b6c7ca16847f07eeafc29c6503be6fa5a9a3d +Author: Patrick Pfeifer <p2000@mailinator.com> +Date: Thu Jan 19 14:54:48 2012 +0100 + + cairo: Fix test for rotation + + Fixes bug #14619. + + poppler/CairoOutputDev.cc | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit 4765c3289635fe4fb006e7df4f83d7056eb42855 +Author: Evan Nemerson <evan@coeus-group.com> +Date: Sun Jan 15 11:02:50 2012 -0800 + + glib: various minor introspection and documentation improvements + + Bug 44790 + + glib/Makefile.am | 4 +++- + glib/poppler-annot.cc | 8 ++++---- + glib/poppler-attachment.h | 7 ++++--- + glib/poppler-document.cc | 6 ++++-- + glib/poppler-media.h | 7 ++++--- + glib/poppler-page.cc | 23 +++++++++++++++-------- + 6 files changed, 34 insertions(+), 21 deletions(-) + +commit e8e42988c5cebab2ffa5fe020f30a3a645e90b5f +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Jan 16 21:25:19 2012 +1030 + + cairo: ensure paintTransparencyGroup uses same ctm as + beginTransparencyGroup + + Bug 29968 + + poppler/CairoOutputDev.cc | 8 ++++++-- + poppler/CairoOutputDev.h | 1 + + 2 files changed, 7 insertions(+), 2 deletions(-) + +commit f6c7aa752f9455bba1aa3c72e0998e7911c1d43e +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Jan 18 21:19:43 2012 +1030 + + configure.ac: print the glib version required if not found + + configure.ac | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +commit 100488ec7db2d1f3e25bfda42c1603ca86696195 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Jan 15 23:52:28 2012 +1030 + + cairo: restore temporary clip used in CairoOutputDev::fill when + painting a mask + + The clip is only used to clip the paint to the fill path so it should + be moved inside the save/restore. + + poppler/CairoOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 9c092e17e8f0cf0335b431a223e6e44bddc27e64 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 15 23:28:51 2012 +0100 + + [xpdf] More Splash and Gfx changes from Thomas + + 1. merge of blend changes + Here I had not only merged the changed in blend modes, I made also + a few + changes in the SPLASH_CMYK area, so that the already sent PDF now also + be rendered correctly with the -jpegcmyk option + 2. merge of font handling in SplashOutputDev.cc + There were a few changes left in font handling, I took them over + 3. merge of getcolor-changes + The getcolor changes win a price for well defined C++ code. I wouldn't + have merged them, if there were not a lot of other things to merge. + 4. merge of image handling in SplashOutputDev.cc + I merged the left changes in image handling including colorizing masks + in pattern colorspace + 5. cleanup of overprint + I tested the overprint implementation of Derek. They succeed only + in 70 + % percent of the PDF where my solution had success, but Derek's + solution + is much cleaner, and I'm sure that I could also fix the rest in + it. BUT: + as I already considered, when I implemented overprint, there are some + overprint situations, which can not be solved in a CMYK colorspace, we + have to implement a DeviceN colorpace when also overprint from CMYK + colors over spot colors should work. Therefore I decided to remove my + overprint implementation completely from the code and let Derek's + solution in, even if there could be done some enhancements in it. + 6. colorizing text in pattern colorspace + When I saw Derek's implementation with a clean interface only at one + place in Gfx.cc, I first was very surprised. My solution had a lot of + places in Gfx.cc, where I looked if the current colorspace is + a pattern + colorspace. Therefore I first had a look into the PDF specification + again, and really, it can be done in the way of Derek. Therefore I + merged it and removed the fragments of my code. + + On this step I started a regtest against the version after the fourth + patch. There were a lot of enhancements, especially in texts with + symbolic chars like mathematical and so on, but there was one + (and ONLY + one) regression, shown in bug-poppler27482.pdf + I examined that (that is also the reason for the delay) and + encountered + that on merging I removed my solution for this bug, therefore + + 7. insert enhancements for colorizing masks in pattern colorspace + I adapt the bug fix from bug 27482 to the merge. + + poppler/CairoOutputDev.cc | 101 ++-- + poppler/CairoOutputDev.h | 21 +- + poppler/Gfx.cc | 705 +++++++++++++++----------- + poppler/Gfx.h | 22 +- + poppler/GfxState.cc | 208 +++++--- + poppler/GfxState.h | 37 +- + poppler/GlobalParams.cc | 17 + + poppler/GlobalParams.h | 3 + + poppler/OutputDev.cc | 13 +- + poppler/OutputDev.h | 25 +- + poppler/PSOutputDev.cc | 87 ++-- + poppler/PSOutputDev.h | 21 +- + poppler/PreScanOutputDev.cc | 2 +- + poppler/SplashOutputDev.cc | 1179 + +++++++++++++++++++++---------------------- + poppler/SplashOutputDev.h | 80 +-- + poppler/TextOutputDev.cc | 8 + + poppler/TextOutputDev.h | 8 + + splash/Splash.cc | 11 +- + splash/Splash.h | 122 ++--- + splash/SplashPattern.cc | 14 - + splash/SplashPattern.h | 7 - + utils/pdftoppm.cc | 1 + + 22 files changed, 1390 insertions(+), 1302 deletions(-) + +commit 69df13c49cea2390f2c5036f3d450f134f7a2656 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Jan 15 15:07:18 2012 +0100 + + Fix stack overflow in PDFDoc::markObject() + + Bug 44660 + + poppler/PDFDoc.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit cdb56567c60b492ad08befff54f2ff70620b86fe +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun Jan 15 15:04:51 2012 +0100 + + Correctly initialize globalParams + + utils/pdfseparate.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 4e205a6625431dcf95375de009b4354746a4f0b7 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Jan 15 22:18:30 2012 +1030 + + parseargs: don't use arg->size with GooString argument + + 40b56994 added GooString arguments but incorrectly used arg->size as + the string length. arg->size is always 0 for GooString arguments. This + worked because the arg->size - 1 string length passed to + GooString::Set() just happened to be the the same value as the + CALC_STRING_LEN default argument indicating the string length is to be + calculated with strlen. + + utils/parseargs.cc | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit a7210a7ebc3d3ca88643bfbc2f0d660a5553a668 +Author: Arseny Solokha <asolokha@gmx.com> +Date: Fri Jan 13 18:52:17 2012 +0100 + + Properly initialize globalParams + + Bug 44659 + + utils/pdfunite.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit baaf93f0e47a1978f9ea80e9394543a25b763d77 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu Jan 12 01:05:07 2012 +1030 + + configure.ac: print the cairo version required if not found + + Bug 44619 + + configure.ac | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +commit 9b8b4232587831fdada37de033c272a3c5049c34 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu Jan 12 00:26:03 2012 +1030 + + cairo: avoid setting huge clip area when printing + + Bug 44002 + + poppler/CairoOutputDev.cc | 21 ++++++++++++--------- + 1 file changed, 12 insertions(+), 9 deletions(-) + +commit efe115f22f8f00a2863ef265ad6f4e7cc2e0336c +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jan 10 23:41:54 2012 +0100 + + compile + + poppler/ArthurOutputDev.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 52d190d8ff962a57a59218f6871c3a63a443ea53 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jan 10 23:33:40 2012 +0100 + + [xpdf303] tiling "merges" from Thomas, using mostly our "old" code + instead of xpdf's + + poppler/CairoOutputDev.cc | 2 +- + poppler/CairoOutputDev.h | 4 ++-- + poppler/Gfx.cc | 45 + +++++++++++++++++++++++++++++++++------------ + poppler/Gfx.h | 15 +++++++++------ + poppler/GfxState.cc | 5 ++++- + poppler/GfxState.h | 7 ++++--- + poppler/OutputDev.h | 3 ++- + poppler/PSOutputDev.cc | 2 +- + poppler/PSOutputDev.h | 2 +- + poppler/PreScanOutputDev.cc | 15 +++++++-------- + poppler/PreScanOutputDev.h | 2 +- + poppler/SplashOutputDev.cc | 8 ++++++-- + poppler/SplashOutputDev.h | 3 ++- + splash/Splash.cc | 32 ++++++++++++++++++++++++-------- + utils/ImageOutputDev.cc | 2 +- + utils/ImageOutputDev.h | 2 +- + 16 files changed, 99 insertions(+), 50 deletions(-) + +commit bf75a957650dd5208ecf1f6db1555a3d00b7949c +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jan 10 23:31:27 2012 +0100 + + [xpdf303] Splash::blitTransparent merges from Thomas + + splash/Splash.cc | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +commit 296244ab74e56b2781daae0a664617d1da30527c +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jan 10 23:30:34 2012 +0100 + + [xpdf303] Merge xpath Splash stuff from Thomas + + splash/SplashXPath.cc | 22 +++++++++++++--------- + 1 file changed, 13 insertions(+), 9 deletions(-) + +commit e1ae7b900b01db7c7703da68ad94aa9bda1938f6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jan 10 23:29:38 2012 +0100 + + [xpdf303] Merge splash font stuff from Thomas + + poppler/GlobalParams.cc | 17 +++++++++++++++++ + poppler/GlobalParams.h | 3 +++ + poppler/SplashOutputDev.cc | 3 +++ + poppler/SplashOutputDev.h | 1 + + splash/SplashFTFont.cc | 34 ++++++++++++++++++++++++++++------ + splash/SplashFTFont.h | 1 + + splash/SplashFTFontEngine.cc | 7 ++++--- + splash/SplashFTFontEngine.h | 5 +++-- + splash/SplashFontEngine.cc | 3 ++- + splash/SplashFontEngine.h | 1 + + 10 files changed, 63 insertions(+), 12 deletions(-) + +commit d46b673c46a72132fb3918b64733be552e35952f +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jan 10 23:28:43 2012 +0100 + + [xpdf303] More merges from Thomas + + splash/Splash.cc | 2800 + ++++++++++++++++++++++++++++++++++++------------------ + splash/Splash.h | 60 ++ + 2 files changed, 1943 insertions(+), 917 deletions(-) + +commit 2cb40bab3b8c49d54c2a49554b30268ccb32899b +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Jan 8 21:35:41 2012 +1030 + + Fix typo in pdffonts man page + + utils/pdffonts.1 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 34ae382915d9d9b2b3c015fee3c24907a6b52b8b +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jan 7 17:14:05 2012 +0100 + + xpdf303: Merge some stuff in Splash [Thomas Freitag] + + 1. merge the complete pipe changes + a) including the overprint implementation from Derek used by pipe + b) including the transfer function implementation + 2. Two changes (not really a merge) to get it compiled under windows + (in + GlobalParams.cc & PDFDoc.cc) + 3. merge fill and stroke changes + a) including merge of SplashClip.cc + b) including merge of SplashXPathScanner.cc + + poppler/GfxState.cc | 94 ++- + poppler/GfxState.h | 17 +- + poppler/GlobalParams.cc | 7 + + poppler/GlobalParams.h | 3 + + poppler/GlobalParamsWin.cc | 2 +- + poppler/PDFDoc.cc | 2 +- + poppler/SplashOutputDev.cc | 134 +++- + poppler/SplashOutputDev.h | 8 +- + splash/Splash.cc | 1658 + ++++++++++++++++++++++++++++++------------ + splash/Splash.h | 42 +- + splash/SplashClip.cc | 57 +- + splash/SplashState.cc | 49 ++ + splash/SplashState.h | 12 + + splash/SplashXPathScanner.cc | 474 +++++++----- + splash/SplashXPathScanner.h | 24 +- + 15 files changed, 1845 insertions(+), 738 deletions(-) + +commit c2378609ae52523beb64e0f040fc79dce4877e03 +Author: Thomas Freitag <thomas.freitag@kabelmail.de> +Date: Sat Jan 7 11:47:19 2012 +0100 + + regtest: read stderr output before calling wait to fix a possible + deadlock + + In the way the scripts starts it subprocesses, stderr becomes buffered + for the subprocesses. And unforunately, when the buffer limit is + reached, the subprocess suspends it work until it can print again on + stderr. That's why the python script runs into a deadlock when the + subprocess produces a lot of error messages. A small rearrange of the + commands, first read the stderr output and then wait that the + subprocess + ends, will remove this deadlock. + + regtest/backends/__init__.py | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit da6bfacb0f858f27bd47f247a25d6bc9ab778411 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Jan 7 10:35:17 2012 +1030 + + Add -subst option to pdffonts to list the substitute font name + and filename + + Bug 44416 + + poppler/FontInfo.cc | 8 ++++-- + poppler/FontInfo.h | 2 ++ + poppler/GlobalParams.cc | 29 +++++++++++++++++++-- + poppler/GlobalParams.h | 3 ++- + utils/pdffonts.1 | 3 +++ + utils/pdffonts.cc | 67 + +++++++++++++++++++++++++++++++++++-------------- + 6 files changed, 88 insertions(+), 24 deletions(-) + +commit 9979b1b3e36dc8085d8c684692fece463fa474b1 +Author: Yi Yang <ahyangyi@gmail.com> +Date: Sat Jan 7 09:44:42 2012 +1030 + + Include .otf fonts when finding substitute fonts + + Bug 44412 + + poppler/GfxFont.cc | 2 +- + poppler/GlobalParams.cc | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit ebfab832ab4f2642b9ab2ededd25de670a3c7147 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Dec 23 09:55:20 2011 +1030 + + autoconf: Check for cairo-ft and other cairo backends + + so that CAIRO_LIBS includes the freetype dependency and pdftocairo + includes the dependencies for optional cairo backends. + + Bug 43969 + + configure.ac | 14 ++++++++++++-- + utils/Makefile.am | 4 ++-- + 2 files changed, 14 insertions(+), 4 deletions(-) + +commit 51ca2b7c7dec5430d29860fd887ad5c5d9b3f574 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Dec 15 00:26:09 2011 +0100 + + [xpdf303] Some more changes in TextOutputDev + + poppler/TextOutputDev.cc | 23 ++++++++++++++++------- + 1 file changed, 16 insertions(+), 7 deletions(-) + +commit c5ce12993a4d2bcd3b3e95b1f08d00dc8960678c +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Dec 14 22:49:33 2011 +0100 + + [xpdf303] Merge some stuff from TextOutputDev + + Yes, this is the best commit log i could think of + + poppler/TextOutputDev.cc | 268 + ++++++++++++++++++++++++++++++----------------- + poppler/TextOutputDev.h | 19 ++-- + 2 files changed, 180 insertions(+), 107 deletions(-) + +commit 388d72ac27ae98fe3a1ebd21760f2b0fa0249a9b +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Dec 6 23:21:15 2011 +0100 + + include strings.h as we use memcpy + + Fixes bug 43558 + + goo/PNGWriter.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 743f70f594bf3c9a58d1ff0738b9a2bc3ea03382 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Dec 6 20:27:03 2011 +0100 + + xpdf303: Use xpdf method against recursion while parsing + + Ours detected loops correctly, but not "valid" files containing lots + of arrays one inside the other [[[[[[[[[[[[[[[[[[[ + So go to this more crude "fix" used in xpdf + + poppler/Dict.cc | 4 ++-- + poppler/Dict.h | 2 +- + poppler/Object.cc | 4 ++-- + poppler/Object.h | 8 ++++---- + poppler/Parser.cc | 32 +++++++++++++++----------------- + poppler/Parser.h | 10 +++------- + poppler/XRef.cc | 33 +++++++-------------------------- + poppler/XRef.h | 2 +- + 8 files changed, 35 insertions(+), 60 deletions(-) + +commit 63c942a45227ef28fb94ef4765171d9812fffafa +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 4 17:29:45 2011 +0100 + + Do not fail if we are trying to save a file with Encrypt but that + we have not modified at all + + Fixes KDE bug #288045 + + poppler/PDFDoc.cc | 49 +++++++++++++++++++++++++++++-------------------- + 1 file changed, 29 insertions(+), 20 deletions(-) + +commit 0937d775e59a963b72fa7924e0f7be484f8345fc +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 4 15:37:20 2011 +0100 + + update name and copyright + (cherry picked from commit 22601c2a64f094ede8085a3ccca3de9daaa556e7) + + utils/pdftocairo.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit bdb439ac5a751d6146204ae0d61fdbf7828c89c3 +Author: Axel Strübing <axel.struebing@freenet.de> +Date: Thu Nov 24 22:32:57 2011 +0100 + + Fix typo/regression introduced in + f6d026bfa18624ccd321e102bb39ba744998de1e + + poppler/Gfx.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 74e11d8c912dd95d235e44e7b34b8ea1be082b9f +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Nov 24 18:54:27 2011 +0100 + + Fix typo + + qt4/src/poppler-qt4.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit ec2a1c3fca92a28c56911729927838f7aacf1078 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 16 23:13:52 2011 +0100 + + xpdf303: Use the correct sizeof() for the greallocn + + poppler/XRef.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 544440b9d19ce99f3a7fcacdea70999b1efc217f +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 16 23:09:23 2011 +0100 + + xpdf303: Add XRef::getPermFlags + + poppler/XRef.h | 1 + + 1 file changed, 1 insertion(+) + +commit b2e43e531edcecaeacf02a627c98cf7ef57f3e3c +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 16 23:04:04 2011 +0100 + + xpdf303: make strToUnsigned "safer" + + poppler/PDFDoc.cc | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +commit bd1513742182ed4c80d21401dd30180981879f24 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 16 22:59:12 2011 +0100 + + xpdf303: Check xrefEntryCompressed entries to be of correct type + and in bounds + + poppler/XRef.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 3bf3e82d1f3eb19a454239d8c7641fc68ff4e462 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 16 22:54:17 2011 +0100 + + xpdf303: Adobe apparently ignores the generation number on compressed + objects + + poppler/XRef.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 73e6f19c4e76762eb5131b168e3b24167ba126cb +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 16 22:29:11 2011 +0100 + + xpdf303: Add PDFDoc::fileNameU to windows builds + + poppler/PDFDoc.cc | 43 +++++++++++++++++++++++++++++++++++-------- + poppler/PDFDoc.h | 6 ++++++ + 2 files changed, 41 insertions(+), 8 deletions(-) + +commit 65388b1aaf9a78efcf9486d5e2d4bdce76f11194 +Author: Igor Slepchin <igor.slepchin@gmail.com> +Date: Tue Nov 15 21:53:40 2011 +0100 + + Output images in pdftohtml -xml mode if no -i option is specified. + + Comes with an attached update to pdf2xml.dtd + + utils/HtmlOutputDev.cc | 48 + ++++++++++++++++++++++++++++++++++++++++-------- + utils/pdf2xml.dtd | 22 +++++++++++++++++----- + 2 files changed, 57 insertions(+), 13 deletions(-) + +commit a4c78946bc1fc3d52152af2e319051050ab05e28 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Nov 14 13:22:53 2011 +0100 + + Make GfxColorSpace::parse accept dicts too + + poppler/GfxState.cc | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +commit f6d026bfa18624ccd321e102bb39ba744998de1e +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Nov 11 16:37:27 2011 +0100 + + Do not crash if failing to parse the colorspace + + Fixes bug 42793 + + poppler/Gfx.cc | 52 +++++++++++++++++++++++++++++----------------------- + 1 file changed, 29 insertions(+), 23 deletions(-) + +commit c9da140bb476dcbb3928950ae9b506de82695cd2 +Author: David King <amigadave@amigadave.com> +Date: Thu Oct 20 11:31:10 2011 +0200 + + glib-demo: Conditionally initialise threading + + In GLib 2.24.0 and above, threading is enabled by default, and the + thread initialization functions are deprecated since GLib 2.31.0. + + Fixes bug #42036. + + glib/demo/main.c | 3 +++ + 1 file changed, 3 insertions(+) + +commit a0db250bbdefff6361551cf9db344bd5268fea11 +Author: Vittal Aithal <vittal.aithal@cognidox.com> +Date: Wed Nov 9 20:07:58 2011 +0100 + + pdfinfo: report page rotation + + utils/pdfinfo.cc | 8 ++++++++ + 1 file changed, 8 insertions(+) + +commit e7dbd17ff07afa465636a90f526cd7ac8c731862 +Author: Kenji Uno <ku@digitaldolphins.jp> +Date: Wed Nov 9 12:39:41 2011 +0100 + + Fix leak in GooString when resizing + + If resizing from "long" to shorter + + goo/GooString.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 6a4f0c32b6723b127034d59a34bf076942e9935f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Nov 6 15:44:06 2011 +0100 + + regtest: Skip tests with results when creating refs + + Not only tests that have md5, but also crashed or failed tests. + + regtest/TestReferences.py | 4 ++-- + regtest/backends/__init__.py | 3 +++ + 2 files changed, 5 insertions(+), 2 deletions(-) + +commit eab952d121c7ab88a0d41587cfa449c0978bea04 +Author: Pino Toscano <pino@kde.org> +Date: Thu Nov 3 21:58:11 2011 +0100 + + qt4: remove unused variable + + qt4/src/poppler-embeddedfile.cc | 1 - + 1 file changed, 1 deletion(-) + +commit 85615f04e040dd38792533a4522e437644e97548 +Author: Pino Toscano <pino@kde.org> +Date: Thu Nov 3 16:15:40 2011 +0100 + + qt4: get rid of the own F and Ff flags reading + + no more useful now, as they are available either directly or as + parsed values in both Annot and FormField + + qt4/src/poppler-form.cc | 16 ---------------- + qt4/src/poppler-private.h | 4 +--- + 2 files changed, 1 insertion(+), 19 deletions(-) + +commit 43347b43eeb66b5c8dc9637c36436baacc626bc4 +Author: Pino Toscano <pino@kde.org> +Date: Thu Nov 3 16:10:57 2011 +0100 + + qt4: use the flags of the associated Annot object + + qt4/src/poppler-form.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 6c9492202de9b3b43da9eac3e40dc7fe218f21da +Author: Pino Toscano <pino@kde.org> +Date: Thu Nov 3 16:03:11 2011 +0100 + + qt4: remove old commented code + + qt4/src/poppler-form.cc | 1 - + 1 file changed, 1 deletion(-) + +commit f0eca54131f7cdf6c1e0e78a18be0bf642567af4 +Author: Pino Toscano <pino@kde.org> +Date: Thu Nov 3 15:46:33 2011 +0100 + + qt4: use the quadding read already in FormField + + ... instead of reading it again + + qt4/src/poppler-form.cc | 24 ++++++++---------------- + 1 file changed, 8 insertions(+), 16 deletions(-) + +commit d92bce1ae87d2f351bb1b972c64466502fb212aa +Author: Pino Toscano <pino@kde.org> +Date: Thu Nov 3 15:30:45 2011 +0100 + + qt4: include <QFile> + + qt4/src/poppler-private.h | 1 + + 1 file changed, 1 insertion(+) + +commit 955cd0c7bd3a72340deba098f4242a4904adc60f +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 2 20:20:41 2011 +0100 + + Compile with MSVC needed for last change in the qt4 frontend + + CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit e0f5bc1deebaa9861baffd7c9ba31ea31585cd1d +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Nov 1 14:15:09 2011 +0100 + + qt4: Use PDFDoc(wchar_t *, ...) on Windows + + Bug 35378 + + qt4/src/poppler-document.cc | 6 +++--- + qt4/src/poppler-private.h | 17 +++++++++++++++-- + 2 files changed, 18 insertions(+), 5 deletions(-) + +commit 52c1e9c5109299255d13b5b1e7d3eedaab512084 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Nov 1 14:13:10 2011 +0100 + + regtest: Add --update-refs command line option to run-tests command + + It allows to update the references of failing tests. + + regtest/TestRun.py | 2 +- + regtest/backends/__init__.py | 34 ++++++++++++++++++++++++++++++++-- + regtest/commands/run-tests.py | 4 ++++ + 3 files changed, 37 insertions(+), 3 deletions(-) + +commit b4896a416b1df14a81b944b3c577fec85c9c7f7d +Author: Rex Dieter <rdieter@math.unl.edu> +Date: Tue Nov 1 09:40:53 2011 +0100 + + Fix pkg-config files + + We were using $FOO_REQUIRED instead of @FOO_REQUIRED@ + + configure.ac | 1 + + poppler-glib-uninstalled.pc.in | 2 +- + poppler-glib.pc.cmake | 2 +- + poppler-glib.pc.in | 2 +- + 4 files changed, 4 insertions(+), 3 deletions(-) + +commit 53f1b0c5edfdbef817bff31566893ac4e111516a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Oct 30 16:02:19 2011 +0100 + + pdftocairo: Make sure beginDocument() is always called + + This fixes a crash when rendering only odd/even pages in a printing + format. + + utils/pdftocairo.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 8b0dfe9537082eaccd982530f1eddc2fcfc92f8e +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 27 19:58:31 2011 +0200 + + xpdf303: Use splashDist instead of splashSqrt and USE_FIXEDPOINT + enhacements + + splash/SplashFTFont.cc | 70 + +++++++++++++++++++++++++++++++++++++++++++++----- + splash/SplashFTFont.h | 2 +- + 2 files changed, 65 insertions(+), 7 deletions(-) + +commit b021bce2583c8e1e3a4c129106d80e7a4e223600 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 27 19:54:22 2011 +0200 + + xpdf303: wops, make it compile + + poppler/Lexer.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 76295f4d401c36bdef3b2a20d18ac57a3b976410 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 27 19:42:42 2011 +0200 + + xpdf303: Adopt xpdf solution for the name too long problem + + poppler/Lexer.cc | 37 +++++++++++++++++-------------------- + 1 file changed, 17 insertions(+), 20 deletions(-) + +commit be6d4c19b8ce1515ce995eee408dc5752012c649 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 27 19:34:38 2011 +0200 + + xpdf303: Add brackets + + poppler/Lexer.cc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit 904ae1385e93155a55008977c89aa664b7c8cb9b +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Oct 26 14:22:28 2011 +0200 + + Expose POPPLER_VERSION in poppler-config.h + + configure.ac | 3 +++ + poppler/poppler-config.h.cmake | 5 +++++ + poppler/poppler-config.h.in | 5 +++++ + 3 files changed, 13 insertions(+) + +commit aa83d4fe942ef0685c5990ddf3eccc2fbdf82292 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 20 00:59:57 2011 +0200 + + xpdf303: Add readFromStream + + poppler/GfxFont.cc | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 74d771d58a4d1868669117709eb6811ec28bf840 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 20 00:56:58 2011 +0200 + + xpdf303: Add base14SubstFonts + + poppler/GfxFont.cc | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +commit 71260f987161d5b122caced6af14e9d64be46e4d +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 20 00:55:42 2011 +0200 + + xpdf303: GfxFontLoc implementation + + poppler/GfxFont.cc | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +commit 586430137985fd303ce87bdb9b902ee9a01341e8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 20 00:54:09 2011 +0200 + + xpdf303: More stuff into base14FontMap + + poppler/GfxFont.cc | 16 +++++++++++++++- + 1 file changed, 15 insertions(+), 1 deletion(-) + +commit c0affb1845c339f89ca67608cb9fd9134ff902f5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 20 00:51:31 2011 +0200 + + xpdf303: GfxFont::getOrignName/getName rework + + poppler/FontInfo.cc | 4 ++-- + poppler/GfxFont.cc | 4 ---- + poppler/GfxFont.h | 6 +----- + poppler/PSOutputDev.cc | 8 ++++---- + poppler/TextOutputDev.cc | 5 ++--- + 5 files changed, 9 insertions(+), 18 deletions(-) + +commit c5c513b5b72e03f6f0a94d04f7d8a22fe9bdaa80 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 20 00:45:30 2011 +0200 + + xpdf303: GfxFontLoc + + poppler/GfxFont.h | 35 +++++++++++++++++++++++++++++++++++ + 1 file changed, 35 insertions(+) + +commit 4ec5e5e6d4785eb7a60744ae7e33c7ba3f603e8e +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 20 00:34:10 2011 +0200 + + xpdf303: StdFontMapEntry renaming + + poppler/GfxFont.cc | 26 +++++++++++--------------- + poppler/GfxFont.h | 2 ++ + 2 files changed, 13 insertions(+), 15 deletions(-) + +commit e71088dc5087303b1ae5f3e72af287ec4e0a1342 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Oct 17 13:42:06 2011 +0200 + + remove useless #if + + poppler/Page.cc | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +commit 40b56994dda79653c902977423f349efa55cf21e +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Oct 17 20:33:03 2011 +1030 + + utils: Add GooString arg to parseargs and use for paths in pdftocairo + + <sys/param.h> and MAXPATHLEN is not available on windows. Avoid the + need to know the max path length by using GooString for the path. + + utils/parseargs.cc | 12 ++++++++++++ + utils/parseargs.h | 2 ++ + utils/pdftocairo.cc | 17 ++++++++--------- + 3 files changed, 22 insertions(+), 9 deletions(-) + +commit 4bb34757dbbff780baba053371274c05b29771e1 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Sep 19 21:11:44 2011 +0930 + + cairo: fix setSoftMask bugs + + - Getting the clip extents in device space requires transforming all + four corners of the clip extents and translating by the group device + offset other wise the device extents will not be correct for rotated + ctm. + + - Adjust matrix to include translation of the clip extents origin + since the mask surface does not start at (0,0). + + - the ctm when called cairo_mask() needs to be the same as the + ctm when + the mask was created. + + - implement transfer function in setSoftMask + + Bug 41005 + + poppler/CairoOutputDev.cc | 97 + +++++++++++++++++++++++++++++------------------ + poppler/CairoOutputDev.h | 6 ++- + 2 files changed, 65 insertions(+), 38 deletions(-) + +commit 50adbed183e9bf70eb4c41e8858cf464c3042e45 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Oct 16 12:40:27 2011 +0200 + + Remove poppler-cairo dependency from poppler-glib pkg-config file + + poppler-glib links to poppler-cairo statically, so it doesn'tm + depend on + the dynamic library. + + CMakeLists.txt | 1 - + configure.ac | 2 -- + poppler-glib-uninstalled.pc.in | 2 +- + poppler-glib.pc.cmake | 2 +- + poppler-glib.pc.in | 2 +- + 5 files changed, 3 insertions(+), 6 deletions(-) + +commit acd8ecc9121db58851f73764f046a4f54bd80581 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Oct 8 15:03:24 2011 +1030 + + ps: fix uncolored tiling patterns + + Uncolored patterns and type 3 chars must not use color setting + operators. When emitting an uncolored pattern: + - disable the update color space functions + - disable the update color functions + - set pdfLastFill and pdfLastStroke to true to ensure the the sCol + and fCol procedures that is used by some of the PS procedures that + emulate PDF operators do not update the color. + + Bug 41462 + + poppler/PSOutputDev.cc | 41 +++++++++++++++++++++++++++++++++++++++++ + poppler/PSOutputDev.h | 1 + + 2 files changed, 42 insertions(+) + +commit 6e1326b11f98f2b277e53a6cdbcb373ce6c29958 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Oct 7 20:29:36 2011 +1030 + + ps: emit non repeating patterns in PSOutput with inType3Char = true + + instead of falling back to Gfx. This avoids emitting the image data + twice. + + poppler/PSOutputDev.cc | 23 +++++++++++++++++++++++ + 1 file changed, 23 insertions(+) + +commit ed05fcb8c442b716c5e382c98f2625701926c86a +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Oct 1 20:19:19 2011 +0930 + + ps: fix tiling pattern fill matrix + + In PS the pattern matrix maps the pattern space to user space. In PDF + the pattern matrix maps the pattern space to the default ctm of the + content stream (baseMatrix in Gfx). The matrix mat already contains + the + correct pattern->baseMatrix so use it instead of pmat. + + Bug 41374 + + poppler/PSOutputDev.cc | 9 ++------- + 1 file changed, 2 insertions(+), 7 deletions(-) + +commit 087757866de13b6164967a1d241d3c0e47065f1a +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 13 12:18:52 2011 +0200 + + xpdf303: Merge SplashT1Font::getGlyphPath changes + + splash/SplashT1Font.cc | 39 +++++++++++++++++++++------------------ + 1 file changed, 21 insertions(+), 18 deletions(-) + +commit c84f46ee16a8dcc6e2cad2359df621cc6cdb8fa5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 13 12:16:14 2011 +0200 + + xpdf303: Add GBool type1 to SplashFTFontFile + + splash/SplashFTFontFile.cc | 9 +++++---- + splash/SplashFTFontFile.h | 3 ++- + 2 files changed, 7 insertions(+), 5 deletions(-) + +commit d845da2c3c1acbeaa4b9bb3125f9143e785210ff +Author: Yury G. Kudryashov <urkud.urkud@gmail.com> +Date: Thu Oct 6 14:49:19 2011 +0200 + + Okular moved to git, fix docs + + Fix URLs in poppler-qt4 documentation + + qt4/src/Mainpage.dox | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit bb40c980f7ab7a6eb9735af17103f87bc65893d6 +Author: Yury G. Kudryashov <urkud.urkud@gmail.com> +Date: Thu Oct 6 14:49:08 2011 +0200 + + Explicitly include fontconfig include dir + + This fixes cmake-driven build on systems where fontconfig is + installed in + non-standard location. + + CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit 776ca137984556530ba938265714934bdc3d6443 +Author: Yury G. Kudryashov <urkud.urkud@gmail.com> +Date: Thu Oct 6 14:48:46 2011 +0200 + + Fix typo in cmake option documentation + + Relocatable build does *not* (was missing in docs) hardcode library + location. + + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ab8616dcb637ac1aeb4d5f142c3c4bff9aecd041 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu Oct 6 14:21:10 2011 +0200 + + close the file or flush stdout + + utils/pdftocairo.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 72c2d563684ab6937a98a0c1c79be3639d29c9ce +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Oct 4 17:46:11 2011 +0200 + + xpdf303: Make sure array length is > 0 + + This is not scritcly necessary since Array::get already returns a + null object in case + the index is out of range but let's merge it for the sake of being + more closer to xpdf + + poppler/GfxState.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit c814c2452c7f60623fdd0fee6f915adeaf5b49e3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Oct 4 17:40:27 2011 +0200 + + xpdf303: Limit recursion in GfxColorSpace parsing + + I think we could do it better, but it'd take more time and it's not + what we are doing in this branch anyway + + poppler/GfxState.cc | 43 +++++++++++++++++++++++++++---------------- + poppler/GfxState.h | 14 +++++++------- + 2 files changed, 34 insertions(+), 23 deletions(-) + +commit 0e53ba5709296dc2ba1399f885af200d2041f0cd +Author: Glad Deschrijver <glad.deschrijver@gmail.com> +Date: Sat Oct 1 15:41:51 2011 +0200 + + qt4: Add the option of PSConverter creating EPS + + qt4/src/poppler-ps-converter.cc | 3 ++- + qt4/src/poppler-qt4.h | 6 ++++-- + 2 files changed, 6 insertions(+), 3 deletions(-) + +commit 04e271a0c10807c9c3967daa1f656e87b97b9901 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 1 14:34:50 2011 +0200 + + Fix typo in documentation + + Reported by Glad Deschrijver + (cherry picked from commit 1346caac6c564035d368617a329b361d0253fbf6) + + qt4/src/poppler-qt4.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 9855529e8e1a83c6d77a9e4221ea2132d44e9fb1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 1 14:27:44 2011 +0200 + + Remove space after % as it confuses libspectre + + Discussed with Adrian Johnson + Problem found by Glad Deschrijver + + poppler/PSOutputDev.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 8e8cde6f374b59222d834e2e7f08fb4a6a4d55a5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 28 23:32:24 2011 +0200 + + xpdf303: More manpage merging + + utils/pdftotext.1 | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +commit f798f00c9ec55bff2eb93938424c436ba2663e7a +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 28 23:30:55 2011 +0200 + + xpdf303: mention pdfdetach in non xpdf tools + + utils/pdftocairo.1 | 1 + + utils/pdftohtml.1 | 1 + + 2 files changed, 2 insertions(+) + +commit 3fc46ac1c046460ccf46ba4b8a92f728e775694a +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 28 23:30:00 2011 +0200 + + xpdf303: Fix pdfdetach man page references + + utils/pdfdetach.1 | 14 ++++++-------- + 1 file changed, 6 insertions(+), 8 deletions(-) + +commit 79e1d77fb00a7c7f0bda4ae76328c4211c7f16e6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 28 23:27:53 2011 +0200 + + xpdf303: Merge some more manpages + + utils/pdfinfo.1 | 15 +++++++++++---- + utils/pdftoppm.1 | 9 +++++---- + 2 files changed, 16 insertions(+), 8 deletions(-) + +commit 841c96be59ddad32f51d4d114ba1dcc42285ab55 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 28 23:23:25 2011 +0200 + + xpdf303: Merge some man pages + + utils/pdffonts.1 | 9 +++++---- + utils/pdfimages.1 | 9 +++++---- + utils/pdftops.1 | 9 +++++---- + 3 files changed, 15 insertions(+), 12 deletions(-) + +commit d2706a05513134f961e2500e0e596f2769707ce5 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Sep 28 21:20:23 2011 +0930 + + cairo: fix crash when using poppler_page_get_image() + + poppler/CairoOutputDev.h | 1 + + 1 file changed, 1 insertion(+) + +commit 0c0591fa23441c54c9443072615273ea65482d76 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 27 00:45:59 2011 +0200 + + 0.18.0 + + CMakeLists.txt | 6 ++-- + NEWS | 14 ++++++++ + configure.ac | 4 +-- + cpp/Doxyfile | 2 +- + gtk-doc.make | 102 + ++++++++++++++++++++++------------------------------ + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 7 files changed, 64 insertions(+), 68 deletions(-) + +commit 19f5db7acd64330d198f18695175df02141794d7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 27 00:15:15 2011 +0200 + + Update Carlos (C) year + + poppler/Gfx.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 6d34d4af90b8b41360de4dabb000bbcc894775d0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 27 00:09:54 2011 +0200 + + Rename pdfmerge and pdfextract + + To pdfunite and pdfseparate, the old names were taken + + utils/.gitignore | 4 +- + utils/CMakeLists.txt | 28 ++++---- + utils/Makefile.am | 16 ++--- + utils/pdfextract.1 | 49 -------------- + utils/pdfextract.cc | 115 --------------------------------- + utils/pdfmerge.1 | 33 ---------- + utils/pdfmerge.cc | 176 + --------------------------------------------------- + utils/pdfseparate.1 | 49 ++++++++++++++ + utils/pdfseparate.cc | 115 +++++++++++++++++++++++++++++++++ + utils/pdfunite.1 | 33 ++++++++++ + utils/pdfunite.cc | 176 + +++++++++++++++++++++++++++++++++++++++++++++++++++ + 11 files changed, 397 insertions(+), 397 deletions(-) + +commit baf54c2876edd476ffc68da6518598847bb7ec8a +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 26 15:54:46 2011 +0200 + + Remove getRawStream + + Since it does exactly the same as getNextStream + + poppler/DCTStream.h | 1 - + poppler/Stream.h | 1 - + utils/HtmlOutputDev.cc | 7 ++----- + utils/ImageOutputDev.cc | 9 +++------ + 4 files changed, 5 insertions(+), 13 deletions(-) + +commit bba57e588fd1ee3a61f18405d1d1bf89fceb5b96 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 25 12:21:02 2011 +0200 + + xpdf303: Added the pdfdetach tool + + I haven't merged xpdf code for embedded files, I think our + implementation is better and more complete. I've adapated pdfdetach + code to use our code and return also embedded files of file attachment + annotations to match what xpdf does. + + poppler/FileSpec.cc | 22 ++++ + poppler/FileSpec.h | 3 + + utils/CMakeLists.txt | 9 ++ + utils/Makefile.am | 6 + + utils/pdfdetach.1 | 105 +++++++++++++++++ + utils/pdfdetach.cc | 318 + +++++++++++++++++++++++++++++++++++++++++++++++++++ + 6 files changed, 463 insertions(+) + +commit f62c2f002c782d3a7887525f031d266aca6eb582 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Sep 24 11:20:13 2011 +0200 + + xpdf303: Parse ActualText in Gfx instead of output devices + + Remove beginMarkedContent and endMarkedcontent and add beginActualText + and endActualText. ActualText is parsed in Gfx, that already + handles the + marked content stack, so that text output dev doesn't need to + handle it + too. The text string is passed to beginActualText(). This change + is not + an exact merge of xpdf code, I've tried to keep our implementation. + + poppler/CairoOutputDev.cc | 8 +-- + poppler/CairoOutputDev.h | 6 +- + poppler/Gfx.cc | 40 +++++++++---- + poppler/OutputDev.cc | 6 -- + poppler/OutputDev.h | 4 +- + poppler/TextOutputDev.cc | 145 + +++++++++++++++++++--------------------------- + poppler/TextOutputDev.h | 21 ++++--- + 7 files changed, 108 insertions(+), 122 deletions(-) + +commit a097447ed13cb021003425f85597e2628935feb2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Sep 24 09:43:05 2011 +0200 + + Use new error syntax in pdfextract + + utils/pdfextract.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 718c735aed540aa49b8dde250ca886c6ad93f5b6 +Merge: 6721916 69707f0 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Sep 24 09:38:52 2011 +0200 + + Merge branch 'master' into xpdf303merge + +commit 69707f0a9b5a94c80817039db943fb4f26e743e3 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Sep 19 22:00:34 2011 +0930 + + Update .gitignore + + regtest/.gitignore | 1 + + utils/.gitignore | 2 ++ + 2 files changed, 3 insertions(+) + +commit 0de477817e424078cfcfcae114e7745809f0848d +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Sep 19 21:57:07 2011 +0930 + + utils: Add Glyph & Cog copyright to pdfmerge and pdfextract man pages + + utils/pdfextract.1 | 3 ++- + utils/pdfmerge.1 | 3 ++- + 2 files changed, 4 insertions(+), 2 deletions(-) + +commit ce7372db64ee807dc2b491e121fbe557dbf697e8 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Sep 19 22:04:27 2011 +0930 + + regtest: render cairo at 72ppi + + For consistency with splash. It is faster and easier to compare with + splash results. + + regtest/backends/cairo.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 6cf7330089c4dcc1099906d9c37c3607a2a1eeba +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Sep 19 18:42:35 2011 +0200 + + regtest: Ignore checksums of crashed, failed and stderr files + + They shouldn't have a checksum, but it might happen with md5 files + generated with previous versions. + + regtest/backends/__init__.py | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 6512bf1c5dab37058460882fec3407b396830981 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 18 18:38:32 2011 +0200 + + Render at 72 instead of 150, it's faster :D + + regtest/backends/splash.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit b828f63ed3896a22f3fe7ddbe2ec2f549d7a2c62 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 18 18:20:47 2011 +0200 + + install pdfextract and pdfmerge manpages + + utils/CMakeLists.txt | 2 ++ + 1 file changed, 2 insertions(+) + +commit 986759dfbe85998c85ee9b0825c7522395567531 +Author: Thomas Freitag <Thomas.Freitag@kabelmail.de> +Date: Sun Sep 18 18:19:30 2011 +0200 + + pdfextract and pdfmerge man pages + + utils/Makefile.am | 2 ++ + utils/pdfextract.1 | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ + utils/pdfmerge.1 | 32 ++++++++++++++++++++++++++++++++ + 3 files changed, 82 insertions(+) + +commit 90da1af542fd7f3cecef31b15da6971345b38209 +Author: Thomas Freitag <Thomas.Freitag@kabelmail.de> +Date: Sun Sep 18 18:19:04 2011 +0200 + + Complain if %d is not present and it should + + utils/pdfextract.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 40e066a84ddb3a5c41805c095659af5f5704d6d8 +Author: suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Sun Sep 18 18:16:14 2011 +0200 + + qt_subdir is unneeded + + Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 6721916c92d720947b3285c85fdbe6610c6bf013 +Merge: 8456a6e e23f6b9 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 18 16:31:10 2011 +0200 + + Merge branch 'master' into xpdf303merge + + Conflicts: + poppler/Gfx.cc + +commit e23f6b9cade804136bd4bb58182f4fe0b072fbf2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 18 16:27:50 2011 +0200 + + regtest: Do not create checksums for crashed, failed and stderr files + + regtest/backends/__init__.py | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +commit 110b8be1d9f2694b42bd12dcb6af02bfca9866dd +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 18 16:26:58 2011 +0200 + + Fix memory leak + + poppler/Gfx.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 8456a6e1354126dc98357fb806595bd3bc198522 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 18 16:07:54 2011 +0200 + + xpdf303: Add OCDisplayNode + + It's not used by poppler yet, but we might want to use it from the + frontends after the merge. + + poppler/OptionalContent.cc | 127 + +++++++++++++++++++++++++++++++++++++++++++++ + poppler/OptionalContent.h | 36 ++++++++++++- + 2 files changed, 162 insertions(+), 1 deletion(-) + +commit 06c6660dc9fe326f185ff323e643af6714b32ec8 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 18 15:08:44 2011 +0200 + + xpdf303: Parse usage dictionary of optional content groups + + poppler/OptionalContent.cc | 28 ++++++++++++++++++++++++++++ + poppler/OptionalContent.h | 14 +++++++++++++- + 2 files changed, 41 insertions(+), 1 deletion(-) + +commit 528d5b0d40302b3fee3aec69b85bdd1daa4db568 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 18 14:03:36 2011 +0200 + + xpdf303: Image XObjects can have a OC entry too + + poppler/Gfx.cc | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +commit c40353d3bb761f5be8ddbd2bf5341e83901fb132 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 18 13:32:07 2011 +0200 + + xpdf303: OC entry is specific to form XObjects + + poppler/Gfx.cc | 17 +++++++++-------- + 1 file changed, 9 insertions(+), 8 deletions(-) + +commit 6ddb51d81b064346dc85d2ae72570a956a184d74 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 18 12:59:28 2011 +0200 + + xpdf303: The spec doesn't say OC must be null or ref + + poppler/Annot.cc | 5 +---- + poppler/Gfx.cc | 22 +++++++--------------- + 2 files changed, 8 insertions(+), 19 deletions(-) + +commit 434bb9b38319edc7282be22044bd7761403a38a6 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 18 12:45:12 2011 +0200 + + xpdf303: OC entry can be an optional content group too + + Not only an optional content membership dictionary. + + poppler/OptionalContent.cc | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +commit 56410b80fdabb99e2de0c6589de6ee745936c523 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 18 12:44:02 2011 +0200 + + xpdf303: Not finding an oc group is not necessarily a syntax error + + poppler/OptionalContent.cc | 2 -- + 1 file changed, 2 deletions(-) + +commit 4bb4439450e342479375cb56d10561457475bd13 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 18 12:42:15 2011 +0200 + + xpdf303: Fix check of OptionalContentGroup::getState() + + We use an enum, not a boolean. + + poppler/OptionalContent.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit d737e3098e02e46525c0edf2165462e03ac7a0e6 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 18 11:36:11 2011 +0200 + + xpdf303: Add support for visibility expressions in OptContent + + poppler/OptionalContent.cc | 113 + +++++++++++++++++++++++++++++++++++---------- + poppler/OptionalContent.h | 3 +- + 2 files changed, 91 insertions(+), 25 deletions(-) + +commit 258d56ba85902a8ab50eec3fe66dd6425226fa59 +Merge: 72a7736 12c6239 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 18 11:12:38 2011 +0200 + + Merge branch 'master' into xpdf303merge + +commit 12c6239ca4f1f6a5de72aebd755f9d1354ea5837 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 18 11:08:06 2011 +0200 + + regtest: Fix checksum check for tests containing spaces in filename + + regtest/backends/__init__.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 72a7736389cbe36c1f8a526f1a659cae1a3f85a3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 18 10:47:51 2011 +0200 + + xpdf303: No need to cache optContentConfig object in Annot + + poppler/Annot.cc | 2 +- + poppler/Annot.h | 2 -- + 2 files changed, 1 insertion(+), 3 deletions(-) + +commit 93ba92db0a3af35f197a4faa5a528af98ea0f624 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 14 00:58:44 2011 +0200 + + Make it work with Python3 + + regtest/Config.py | 4 ++-- + regtest/TestReferences.py | 8 ++++---- + regtest/TestRun.py | 32 ++++++++++++++++---------------- + regtest/Timer.py | 8 ++++---- + regtest/backends/__init__.py | 12 ++++++------ + regtest/commands/__init__.py | 6 +++--- + regtest/commands/create-refs.py | 2 +- + regtest/commands/run-tests.py | 2 +- + regtest/main.py | 2 +- + 9 files changed, 38 insertions(+), 38 deletions(-) + +commit da1b5437148e1e6317246b16f7235c8bc280be97 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Sep 13 20:09:56 2011 +0200 + + regtest: Add a way to skip files + + A new command line option --skip has been added to give a file + with the + list of test to skip. When --skip is not used, it look for a file + named + Skipped in the tests dir. Lines starting with '#' are considered + comments and are ignored. + + regtest/TestReferences.py | 9 +++++++-- + regtest/TestRun.py | 9 +++++++-- + regtest/Utils.py | 20 ++++++++++++++++++++ + regtest/main.py | 6 +++++- + 4 files changed, 39 insertions(+), 5 deletions(-) + +commit b730b2c1d9666f62f940762663c8318e64049d61 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Sep 13 19:04:04 2011 +0200 + + regtest: Limit the number of arguments to 1 + + It's easier to run poppler-regtest more than once if you need to run + different tests. + + regtest/commands/create-refs.py | 24 ++++++++++++------------ + regtest/commands/run-tests.py | 26 +++++++++++++------------- + regtest/main.py | 2 +- + 3 files changed, 26 insertions(+), 26 deletions(-) + +commit 5ce045d0358318859c844340c639483485b69c58 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Sep 13 18:18:21 2011 +0200 + + regtest: Sort tests before create-refs/run-tests and show progress + + regtest/TestReferences.py | 20 ++++++++------------ + regtest/TestRun.py | 21 ++++++++++----------- + regtest/Utils.py | 35 +++++++++++++++++++++++++++++++++++ + 3 files changed, 53 insertions(+), 23 deletions(-) + +commit 10801b6faee9037af054fe74cc4a03620ea41d45 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Sep 12 20:13:17 2011 +0200 + + Add initial poppler regressions test program + + regtest/Config.py | 32 ++++++ + regtest/TestReferences.py | 73 +++++++++++++ + regtest/TestRun.py | 156 ++++++++++++++++++++++++++++ + regtest/Timer.py | 73 +++++++++++++ + regtest/backends/__init__.py | 220 + ++++++++++++++++++++++++++++++++++++++++ + regtest/backends/cairo.py | 39 +++++++ + regtest/backends/postscript.py | 35 +++++++ + regtest/backends/splash.py | 39 +++++++ + regtest/backends/text.py | 48 +++++++++ + regtest/commands/__init__.py | 93 +++++++++++++++++ + regtest/commands/create-refs.py | 65 ++++++++++++ + regtest/commands/run-tests.py | 69 +++++++++++++ + regtest/main.py | 77 ++++++++++++++ + regtest/poppler-regtest | 6 ++ + 14 files changed, 1025 insertions(+) + +commit 245e331a14e11a615bf47abbeb34a3561e393b41 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 12 13:43:49 2011 +0200 + + 0.17.4 + + CMakeLists.txt | 2 +- + NEWS | 5 +++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + 5 files changed, 9 insertions(+), 4 deletions(-) + +commit 194b2413eb2c6a1641508aec63336aaf89ec3b51 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 12 13:43:35 2011 +0200 + + gir 0.18 + + glib/CMakeLists.txt | 12 ++++++------ + glib/Makefile.am | 12 ++++++------ + 2 files changed, 12 insertions(+), 12 deletions(-) + +commit 61c06d2efad20880e1e0b399cf797dd55f6c8dab +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 12 00:32:38 2011 +0200 + + xpdf303: Useless NULL assignments + + poppler/SplashOutputDev.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 4fbcbf1ffb8a98fe8c12643fdab2cbd90b4e60f9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 12 00:30:52 2011 +0200 + + xpdf303: Set size to 64 instead of 100 + + poppler/SplashOutputDev.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 1c7203e57e9c7c264f5cada6362a6b449dd8689c +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 12 00:21:03 2011 +0200 + + xpdf303: Avoid calling a "slow" function + + poppler/PSOutputDev.cc | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +commit db4c5789bf95af9f45a7911153acc20a26a447f1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 12 00:19:49 2011 +0200 + + xpdf303: fix spacing + + poppler/PSOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 10c3d15f841865929d2f66353cb01d0d321e8b82 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 12 00:03:13 2011 +0200 + + xpdf303: make limit smaller + + poppler/PSOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1d4e6e739701ba817576752ced169b24c5e95156 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 11 23:57:22 2011 +0200 + + xpdf303: Remove 512 limit in pdftoppm + + utils/pdftoppm.cc | 13 ++++++------- + 1 file changed, 6 insertions(+), 7 deletions(-) + +commit e4e843f1115d95c54967f0386bfb28f685d6c88d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 11 22:49:34 2011 +0200 + + xpdf303: Rework nComps != colorSpace->getNComps() handling + + poppler/GfxState.cc | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit dda45b6a67f3f97705e5d806eaf7d37171789e66 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 11 22:46:51 2011 +0200 + + xpdf303: NULL GfxICCBasedColorSpace if array does not have 2 elements + + poppler/GfxState.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 760e814a6d26db8eba567520aad771002e11357a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 11 22:21:40 2011 +0200 + + xpdf303: increase formDepth limit + + poppler/Gfx.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 59442e5994f3b94d5221cbc90f79fad235fe2611 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 11 22:10:41 2011 +0200 + + xpdf303: Remove flags that were never used + + splash/Splash.cc | 6 +----- + splash/SplashXPath.cc | 34 ++++------------------------------ + splash/SplashXPath.h | 13 ++++--------- + 3 files changed, 9 insertions(+), 44 deletions(-) + +commit 41a620ef60507ceda42a14d06d6587ed10016468 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 8 16:18:01 2011 +0200 + + xpdf303: Adapt use of getBlock to our use of getChars + + poppler/Stream.cc | 58 + +++++++++++++++++++++++++++++++++---------------------- + poppler/Stream.h | 2 ++ + 2 files changed, 37 insertions(+), 23 deletions(-) + +commit 2f7701fe730a648d0a1d181c5b20e4802640dc52 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 8 15:59:27 2011 +0200 + + xpdf303: Adapt xpdf getBlock to our getChars + + poppler/JBIG2Stream.cc | 17 ++++++++ + poppler/JBIG2Stream.h | 2 + + poppler/Stream.cc | 113 + ++++++++++++++++++++++++++++++++++++++++++++----- + poppler/Stream.h | 55 +++++++++++++----------- + 4 files changed, 152 insertions(+), 35 deletions(-) + +commit 3a1988db40def1655ec638cd521ed40eadc0acca +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Sep 8 15:40:12 2011 +0200 + + xpdf303: empty pages need to call dump to do any setup required by + the OutputDev + + poppler/Page.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 4cddaed21592ac491519a81a003035bc4e618705 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Sep 8 15:35:33 2011 +0200 + + xpdf303: Don't clip the other page boxes to the MediaBox at the + intermediate nodes + + only do it at the leaf (Page) nodes - the other boxes can be specified + before the MediaBox is specified. + I think we already had that change, we checked isPage before clipping, + I've merged this way just to make future merges a bit easier. + + poppler/Page.cc | 16 ++++++++-------- + poppler/Page.h | 3 +++ + 2 files changed, 11 insertions(+), 8 deletions(-) + +commit 3538ac89bfea750de8907847d1d5e3515d0b8be7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 8 15:07:21 2011 +0200 + + xpdf303: compile + + poppler/ArthurOutputDev.cc | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +commit 89d95d0f254a828d28d943b698eeaec51f03686f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Sep 8 12:38:36 2011 +0200 + + xpdf303: Add codeToGID and codeToGIDLen params to + loadOpenTypeCFFFont() + + poppler/SplashOutputDev.cc | 12 +++++++++++- + splash/SplashFTFontEngine.cc | 29 +++++++++++++++++------------ + splash/SplashFTFontEngine.h | 3 ++- + splash/SplashFontEngine.cc | 6 ++++-- + splash/SplashFontEngine.h | 3 ++- + 5 files changed, 36 insertions(+), 17 deletions(-) + +commit d768204e51e6bdbcac4d6b43537297616cbedbf3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 6 21:56:43 2011 +0200 + + xpdf303: Revert b36d150931cd555b84ee996d505e8b91e2afde19 + + Breaks bug164568-2.pdf so our fix was better :-) + + poppler/JBIG2Stream.cc | 91 + ++++++++++++++++++++++---------------------------- + poppler/JBIG2Stream.h | 1 - + 2 files changed, 40 insertions(+), 52 deletions(-) + +commit 2230b8f2128edf4994d8a742f562e1b5acf96b74 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 6 00:05:53 2011 +0200 + + xpdf303: Merge JPXStream changes + + poppler/JPXStream.cc | 1000 + +++++++++++++++++++++++++++++++------------------- + poppler/JPXStream.h | 43 +-- + 2 files changed, 632 insertions(+), 411 deletions(-) + +commit 35bb53feaa2e469253368f03a9835d73aeb1a240 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 23:20:09 2011 +0200 + + xpdf303: Add BufStream + + poppler/Stream.cc | 46 ++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Stream.h | 25 +++++++++++++++++++++++++ + 2 files changed, 71 insertions(+) + +commit 8a9d92fcf05285c1f06bc153aa79d0200d05bbd9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 22:57:02 2011 +0200 + + xpdf303: CCITTFaxStream header misc fixes + + poppler/Stream.h | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 22d370c0a1f8c016ebc5a6d8320fe55bfd31c8a7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 22:53:45 2011 +0200 + + xpdf303: DCTStream misc fixes + + poppler/Stream.cc | 32 ++++++++++++++++++++++++++------ + 1 file changed, 26 insertions(+), 6 deletions(-) + +commit 36d3057546b5a1d717c71b8dcb9773f91e3b5960 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 22:46:59 2011 +0200 + + xpdf303: Add some {} + + poppler/Stream.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 308654eb5dfbb783f29bd645f60c79d5b5fe42c9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 22:45:50 2011 +0200 + + xpdf303: code1 changed to int in CCITTFaxStream::reset + + poppler/Stream.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit f097dc1f9d580eb1cdc8180d3920fe795493cf89 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 22:43:16 2011 +0200 + + xpdf303: Use 32 bits in CCITTFaxStream::lookBits + + poppler/Stream.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit b5417659042c95891aa549cae396ba4cc6604030 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 22:40:02 2011 +0200 + + xpdf303: Check against lookBits returning EOF + + poppler/Stream.cc | 17 ++++++++++------- + 1 file changed, 10 insertions(+), 7 deletions(-) + +commit eaf9d31c97a3cc06f4ce94d9190ae1a337634749 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 22:38:05 2011 +0200 + + xpdf303: Set endOfLine to true if code1 is 1 + + poppler/Stream.cc | 1 + + 1 file changed, 1 insertion(+) + +commit a654a77e26a6c7d76c318636303f8c636a3d2495 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 22:36:58 2011 +0200 + + xpdf303: Tweaks to CCITTFaxStream::lookChar + + poppler/Stream.cc | 55 + +++++++++++++++++++++++++++++++++++++++++++------------ + 1 file changed, 43 insertions(+), 12 deletions(-) + +commit abdf828449cd543e66f326ba862efcb3ca6d342d +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 22:19:30 2011 +0200 + + xpdf303: Remove cygwin workaround + + poppler/Stream.cc | 4 ---- + 1 file changed, 4 deletions(-) + +commit 05ef4227d09381e3a9e8050e447770f44d532386 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 22:18:33 2011 +0200 + + xpdf303: Return false if getLine fails + + poppler/Stream.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit c2d6158bd56328754d77ab8f1bf84d46e6ede773 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 22:14:39 2011 +0200 + + xpdf303: Return NULL if size < 0 + + poppler/Stream.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 04947e1dca858b890302a5a1005b84b34255d670 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 22:11:24 2011 +0200 + + xpdf303: Add -rawdates and print Form information + + utils/pdfinfo.cc | 30 +++++++++++++++++++++++++++--- + 1 file changed, 27 insertions(+), 3 deletions(-) + +commit 9529e776e53e71069ba4215cdb8b84592d37b555 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Sep 5 21:19:58 2011 +0200 + + xpdf303: Other fixes in PostScriptFunction + + poppler/Function.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 071f983f461ba0b872dd93d7f1a24d325312799d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Sep 5 21:19:13 2011 +0200 + + xpdf303: Fixed a bug in the PostScript-type function parser + + Real numbers that start with a decimal point weren't being handled + correctly. + + poppler/Function.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit da0eff1aaa31c2bf357a64b6275645100c9629d4 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Sep 5 21:12:02 2011 +0200 + + xpdf303: Fixes in StitchingFunction + + poppler/Function.cc | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +commit b655316706ec394fa6c8ad076d9d9d96ac8ed563 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 21:05:55 2011 +0200 + + xpdf303: Rework LinkURI decoding + + poppler/Link.cc | 35 +++++++++++++++++++---------------- + 1 file changed, 19 insertions(+), 16 deletions(-) + +commit abad9b4e44d81a206bccff8a109ceb9a7effa2ad +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Sep 5 21:00:31 2011 +0200 + + xpdf303: Cache the last transform for PostScript-type functions + + poppler/Function.cc | 37 ++++++++++++++++++++++++++++++++++--- + poppler/Function.h | 2 ++ + 2 files changed, 36 insertions(+), 3 deletions(-) + +commit e1c6b4c6e6df0854b040c9af9ef2d3f6789e24b2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 21:02:31 2011 +0200 + + xpdf303: Only call getNum if isNum + + poppler/Link.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit e5661e1a08c38d4c8d69976a8c1c02c1102bc88c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Sep 5 20:49:13 2011 +0200 + + Optimize SampledFunction + + Pull index computation code out of the transform function; cache the + last transform. + + poppler/Function.cc | 87 + ++++++++++++++++++++++++++++++++++++++++++++--------- + poppler/Function.h | 4 ++- + 2 files changed, 75 insertions(+), 16 deletions(-) + +commit b36d150931cd555b84ee996d505e8b91e2afde19 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 20:52:05 2011 +0200 + + xpdf303: Take xpdf way of handling bug 6500 + + poppler/JBIG2Stream.cc | 91 + ++++++++++++++++++++++++++++---------------------- + poppler/JBIG2Stream.h | 1 + + 2 files changed, 52 insertions(+), 40 deletions(-) + +commit 065565a67c7826b64d89fac9719049d0a57da721 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 20:39:50 2011 +0200 + + xpdf303: Merge ¿speed? improvements in JBIG2Stream::readGenericBitmap + + poppler/JBIG2Stream.cc | 586 + +++++++++++++++++++++++++++++++++++++++---------- + 1 file changed, 471 insertions(+), 115 deletions(-) + +commit 28adb3884dafcf1d36aae1ec05855b10b22aa4ae +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 20:26:57 2011 +0200 + + xpdf303: Change bpp calculation + + poppler/JBIG2Stream.cc | 16 +++++++++++----- + 1 file changed, 11 insertions(+), 5 deletions(-) + +commit c163a82f45d869b7c35a1a7141ab237507671f82 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 20:25:04 2011 +0200 + + xpdf303: Change symCodeLen calculation + + poppler/JBIG2Stream.cc | 16 +++++++++++----- + 1 file changed, 11 insertions(+), 5 deletions(-) + +commit 1d1a985101c26f90bde8340dcfae3d6a1e0a08ba +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 20:20:03 2011 +0200 + + xpdf303: symCodeLen calculation fix + + poppler/JBIG2Stream.cc | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +commit 5c0274572c65972434293a30f3ba5afd3905005f +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 20:07:54 2011 +0200 + + xpdf303: add line accessor + + poppler/JBIG2Stream.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 7b77a264b5c21ba693677b1249a2122743e4e395 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 19:46:16 2011 +0200 + + xpdf303: segments with unspecified length + + poppler/JBIG2Stream.cc | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit 23066e8e8309babd61ade9f50ef7d82c9e275055 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 19:41:16 2011 +0200 + + xpdf303: More EOF detection + + poppler/JBIG2Stream.cc | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +commit bc6eded798d6e5dc7a58f88afbe4ab2904698db5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 19:38:29 2011 +0200 + + xpdf303: Comment++ + + poppler/JBIG2Stream.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit adb98856a745340b4ffb34ffd2ed701600cfc82f +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 19:38:02 2011 +0200 + + xpdf303: Exit loop in case of EOF + + poppler/JBIG2Stream.cc | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +commit 112154567ebcab63959294533b00075d6ca6ea65 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 19:33:27 2011 +0200 + + xpdf303: Initialize to NULL + + poppler/JBIG2Stream.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit b9ecfdf4cb27a19e65817af51c048e8030825035 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 5 19:27:36 2011 +0200 + + xpdf303: Delay memory allocation up to when it is really needed + + poppler/CMap.cc | 58 + ++++++++------------------------------------------------- + poppler/CMap.h | 2 -- + 2 files changed, 8 insertions(+), 52 deletions(-) + +commit 7af7b4b2d1941ee9dcd575535d4fc31f29026d8d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Sep 5 19:05:31 2011 +0200 + + xpdf303: Rework initialization of appearance state + + Merged a slightly different patch, adding an error when the AS + entry is + missing and the AP contains one or more subdictionaries. + + poppler/Annot.cc | 62 + +++++++++++++++++++++++++++++++------------------------- + 1 file changed, 34 insertions(+), 28 deletions(-) + +commit f7d307b818bca9553a05b5d43deb429abbf04824 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 4 13:56:35 2011 +0200 + + xpdf303: Rewrote the code that handles annotation transforms + + It was not handling non-rectangular transforms correctly. + + poppler/Gfx.cc | 143 + ++++++++++++++++++++++++++++++--------------------------- + 1 file changed, 75 insertions(+), 68 deletions(-) + +commit 4609f9feeca22620c6e143962a3717784a843a68 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 4 13:09:50 2011 +0200 + + xpdf303: Implement rotation in the form field appearance regeneration + + poppler/Annot.cc | 51 ++++++++++++++++++++++++++++++++++++++------------- + 1 file changed, 38 insertions(+), 13 deletions(-) + +commit ca7d77a27e2f3a692842968f08dcb9fa5379bf0f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 4 11:53:40 2011 +0200 + + Create forms with a PDFDoc instead of XRef too + + poppler/Form.cc | 79 + +++++++++++++++++++++++++++++---------------------------- + poppler/Form.h | 28 ++++++++++---------- + 2 files changed, 55 insertions(+), 52 deletions(-) + +commit ec52e46e309a0307fdf12113a1b7d41a760f9d6c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 4 11:32:38 2011 +0200 + + xpdf303: Create annots with a doc instead of xref + catalog + + glib/poppler-action.cc | 2 +- + glib/poppler-annot.cc | 4 +- + poppler/Annot.cc | 364 + +++++++++++++++++++++++++------------------------ + poppler/Annot.h | 128 ++++++++--------- + poppler/Catalog.cc | 9 +- + poppler/Form.cc | 22 +-- + poppler/Form.h | 11 +- + poppler/PSOutputDev.cc | 2 +- + poppler/Page.cc | 2 +- + 9 files changed, 274 insertions(+), 270 deletions(-) + +commit ce5e620f07e984927610866467705bb526f9ad8d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Sep 3 11:05:42 2011 +0200 + + xpdf303: Handle the case where sid < 0 + + fofi/FoFiType1C.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 9d77f999de973f3c547245bca0568f8984faa5d7 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Sep 3 11:02:55 2011 +0200 + + xpdf303: Initialize nFDs in FoFiType1C::parse() + + fofi/FoFiType1C.cc | 1 + + 1 file changed, 1 insertion(+) + +commit d9594c95713ac79b46e313ecf2875196ea076ef4 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Sep 3 11:01:28 2011 +0200 + + xpdf303: Check whether fdSelect is NULL before using it + + fofi/FoFiType1C.cc | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +commit 4e4a8ec52c5662e21036f219636a39fc97a32353 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Sep 3 10:52:14 2011 +0200 + + xpdf303: Add writePSString() helper function to FoFiType1C + + fofi/FoFiType1C.cc | 68 + +++++++++++++++++++++++++++++++++++++++--------------- + fofi/FoFiType1C.h | 1 + + 2 files changed, 51 insertions(+), 18 deletions(-) + +commit ff03811db1ef833df4bab12fe3bf3a8c1534c174 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Sep 3 10:40:15 2011 +0200 + + xpdf303: More checks in GooString + + goo/GooString.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 0029efbe2a8a97ff34353f8028ac649b2fd07013 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Sep 3 10:32:14 2011 +0200 + + xpdf303: Use a double instead of an int with a cast + + goo/GooString.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 419ee8c30ba0df02e9f0281b321fbe38387e5a21 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Sep 2 18:44:04 2011 +0200 + + xpdf303: Add more formats to GooString + + goo/GooString.cc | 102 + ++++++++++++++++++++++++++++++++++++++++++++++++++----- + goo/GooString.h | 21 ++++++++++-- + 2 files changed, 111 insertions(+), 12 deletions(-) + +commit 738a6954da01fd3fc8c1cd5baa49fc7b8c959169 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Sep 2 18:24:04 2011 +0200 + + xpdf303: Add getGlyphName() to FoFiType1C + + fofi/FoFiType1C.cc | 12 ++++++++++++ + fofi/FoFiType1C.h | 4 ++++ + 2 files changed, 16 insertions(+) + +commit 39b77a193996b0916690a246f4a9874dad596b2f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Sep 2 18:17:51 2011 +0200 + + xpdf303: Improvements in FoFiType1 parser + + fofi/FoFiType1.cc | 75 + ++++++++++++++++++++++++++----------------------------- + 1 file changed, 35 insertions(+), 40 deletions(-) + +commit 44dbb28a07125f92a0835aea7ad3403310bc451d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Sep 2 18:08:39 2011 +0200 + + xpdf303: Handle PFB headers in Type 1 font files + + fofi/FoFiType1.cc | 36 ++++++++++++++++++++++++++++++++++++ + fofi/FoFiType1.h | 1 + + 2 files changed, 37 insertions(+) + +commit 9531a52b227a994ab8e0d66aeaff2b21358ca73e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Sep 2 18:01:35 2011 +0200 + + xpdf303: New signature of methods convertToCIDType0() and + convertToType0() + + fofi/FoFiTrueType.cc | 8 ++--- + fofi/FoFiTrueType.h | 4 +-- + fofi/FoFiType1C.cc | 84 + +++++++++++++++++++++++++++++++++++--------------- + fofi/FoFiType1C.h | 19 +++++++++--- + poppler/PSOutputDev.cc | 13 ++++++-- + 5 files changed, 91 insertions(+), 37 deletions(-) + +commit 830d2b40770333489a08f23a3b16a372770a8d19 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 23:23:57 2011 +0200 + + xpdf303: Use openFile + + poppler/CharCodeToUnicode.cc | 4 ++-- + poppler/GlobalParams.cc | 10 +++++----- + 2 files changed, 7 insertions(+), 7 deletions(-) + +commit ddf9d6e35b40b902519cbaa8cb664ba6dfdfd510 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 23:21:26 2011 +0200 + + xpdf303: openFile + minor fixes for openTempFile in Windows + + goo/gfile.cc | 108 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- + goo/gfile.h | 13 +++++++ + 2 files changed, 118 insertions(+), 3 deletions(-) + +commit 68e8fa9ff4f13b6703148b3eb6ea628418211243 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 23:17:59 2011 +0200 + + xpdf303: make gcc happy + + fofi/FoFiType1C.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 876021b1aa16ad38767a91e1be31c392f368fde2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Sep 1 19:07:01 2011 +0200 + + xpdf303: Add getFontMatrix() + + fofi/FoFiTrueType.cc | 76 + +++++++++++++++++++++++++++++++--------------------- + fofi/FoFiTrueType.h | 9 +++++++ + fofi/FoFiType1.cc | 37 +++++++++++++++++++++++++ + fofi/FoFiType1.h | 4 +++ + fofi/FoFiType1C.cc | 29 ++++++++++++++++++++ + fofi/FoFiType1C.h | 3 +++ + 6 files changed, 127 insertions(+), 31 deletions(-) + +commit 1369862ed61ef8b0f81c52fce36f6c1602d82ddb +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Sep 1 18:27:51 2011 +0200 + + xpdf303: Ignore entries that have an invalid tag too + + fofi/FoFiTrueType.cc | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +commit 0fe7cc82e84dc2a3b79248b111656e5e7df9fdc2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Sep 1 18:21:33 2011 +0200 + + xpdf303: Update cmap, name, post and os2 tables in FoFiTrueType + + fofi/FoFiTrueType.cc | 29 ++++++++++++++++------------- + 1 file changed, 16 insertions(+), 13 deletions(-) + +commit 0feebf5f3c9da8d7a1154456a00492a623340cec +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Sep 1 18:16:59 2011 +0200 + + xpdf303: Ignore any bogus entries in the table directory + + It's a different approach to fix the same issue we had already fixed, + added just to make future merge easier. We were also reallocating the + tables array, I've kept that but doing it only when the size actually + changes. + + fofi/FoFiTrueType.cc | 25 +++++++++++++------------ + 1 file changed, 13 insertions(+), 12 deletions(-) + +commit 68c6ebc78b89eec94a9c3538fe6e27561a21b680 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Sep 1 17:49:46 2011 +0200 + + xpdf303: codeToGID items can be < 0 now + + fofi/FoFiTrueType.cc | 12 ++++++++++-- + poppler/PSOutputDev.cc | 2 +- + splash/SplashFTFont.cc | 2 +- + 3 files changed, 12 insertions(+), 4 deletions(-) + +commit 19204ed5cd5cb64809f1a1f51dd5ffdef2b9417a +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 17:28:39 2011 +0200 + + xpdf303: CMap::getCID signature change + + poppler/CMap.cc | 47 +++++++++++++++++++++++++++++++---------------- + poppler/CMap.h | 8 +++++--- + poppler/GfxFont.cc | 6 ++++-- + 3 files changed, 40 insertions(+), 21 deletions(-) + +commit 9c74bef77e7e1d7a8464dff43cae16bb1206665e +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 17:04:04 2011 +0200 + + xpdf303: Use splashDist instead of splashSqrt + + splash/SplashT1Font.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0568d0dc3c42b68b715226e5ce0ff98d73a94ac7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 17:01:30 2011 +0200 + + xpdf303: Do the multiplication the other way around + + No idea why :-D + + splash/SplashFTFont.cc | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit 3c0da502aa1d5b1acae01cf1e43fb96f5ecc11da +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 17:00:31 2011 +0200 + + xpdf303: Use splashCheckDet isntead of splashAbs + + splash/SplashFontEngine.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 2b4303c66f8de9a267413465898897fd6b0ebb17 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 16:51:53 2011 +0200 + + xpdf303: Bigger fileKey + + poppler/XRef.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 53060857e31a01413936fbe33b7032a0a325b384 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 16:50:08 2011 +0200 + + xpdf303: Merge JArithmeticDecoder.* + + poppler/JArithmeticDecoder.cc | 47 + ++++++++++++++++++++++++++++++++++++------- + poppler/JArithmeticDecoder.h | 4 ++++ + 2 files changed, 44 insertions(+), 7 deletions(-) + +commit 0722960b4cf4ce40b6bd278ac7287d64a1d70bf2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 16:48:31 2011 +0200 + + xpdf303: Do not crash if imgStr->getLine() is NULL + + utils/ImageOutputDev.cc | 21 ++++++++++++++------- + 1 file changed, 14 insertions(+), 7 deletions(-) + +commit f848edab849910b8291c7974e484ef5d02b2234c +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 16:42:30 2011 +0200 + + xpdf303: Do not extract the million tiles of a pattern + + utils/ImageOutputDev.cc | 9 +++++++++ + utils/ImageOutputDev.h | 12 ++++++++++++ + 2 files changed, 21 insertions(+) + +commit 01adb7ef6a524d7313a45e7c5f441da4fd0250bd +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 16:31:50 2011 +0200 + + xpdf303: Assembler for some functions + + splash/SplashMath.h | 110 + ++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 110 insertions(+) + +commit 4f87a3163f133565e8774ef416e67d05f906723d +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 16:25:19 2011 +0200 + + xpdf303: Add splashAvg + + splash/SplashMath.h | 8 ++++++++ + 1 file changed, 8 insertions(+) + +commit 64cf42f89939763d105be4948a20e9ecb81a64c1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 16:23:08 2011 +0200 + + xpdf303: Add getters to SplashClip + + splash/SplashClip.h | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 28c6a55742f55a719ef63b8e0eff7c242653cf36 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 16:17:56 2011 +0200 + + xpdf303: unneeded forward declare + + poppler/Page.h | 1 - + 1 file changed, 1 deletion(-) + +commit 38ebe8c568aafbe5f248f9e0a654f46829e0b659 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 16:13:53 2011 +0200 + + xpdf303: Page functions do not need Catalog * anymore + + glib/poppler-document.cc | 2 +- + glib/poppler-page.cc | 11 ++++------ + poppler/FontInfo.cc | 2 +- + poppler/OutputDev.h | 4 ++-- + poppler/PDFDoc.cc | 8 +++---- + poppler/PSOutputDev.cc | 6 +++--- + poppler/PSOutputDev.h | 2 +- + poppler/Page.cc | 36 + ++++++++++++++++---------------- + poppler/Page.h | 16 +++++++------- + poppler/TextOutputDev.cc | 2 +- + poppler/TextOutputDev.h | 2 +- + qt4/src/poppler-link-extractor-private.h | 2 +- + qt4/src/poppler-link-extractor.cc | 4 ++-- + qt4/src/poppler-page.cc | 4 ++-- + utils/HtmlOutputDev.cc | 9 ++++---- + utils/HtmlOutputDev.h | 7 +++---- + utils/pdftohtml.cc | 2 +- + 17 files changed, 58 insertions(+), 61 deletions(-) + +commit 7d794f6411499fb8f26778bf2b54cb9734d004af +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 15:47:32 2011 +0200 + + xpdf303: API rework, Gfx wants a PDFDoc instead of an XRef + + cpp/poppler-page-renderer.cpp | 2 +- + glib/poppler-document.cc | 2 +- + glib/poppler-page.cc | 2 -- + poppler/CairoFontEngine.cc | 28 ++++++++++++---------------- + poppler/CairoFontEngine.h | 13 ++++++------- + poppler/CairoOutputDev.cc | 12 +++++------- + poppler/CairoOutputDev.h | 6 +++--- + poppler/Catalog.cc | 8 +++++--- + poppler/Catalog.h | 4 +++- + poppler/Gfx.cc | 15 +++++++++------ + poppler/Gfx.h | 6 ++++-- + poppler/PDFDoc.cc | 6 +++--- + poppler/PSOutputDev.cc | 29 +++++++++++++++-------------- + poppler/PSOutputDev.h | 9 ++++----- + poppler/Page.cc | 8 +++++--- + poppler/Page.h | 4 +++- + poppler/PreScanOutputDev.cc | 6 +++--- + poppler/PreScanOutputDev.h | 4 ++-- + poppler/SplashOutputDev.cc | 13 +++++++------ + poppler/SplashOutputDev.h | 5 +++-- + qt4/src/poppler-private.h | 2 +- + qt4/src/poppler-ps-converter.cc | 2 -- + test/gtk-test.cc | 2 +- + test/pdf-inspector.cc | 2 +- + test/perf-test.cc | 2 +- + utils/pdftocairo.cc | 2 +- + utils/pdftohtml.cc | 6 +++--- + utils/pdftoppm.cc | 2 +- + utils/pdftops.cc | 4 ++-- + 29 files changed, 105 insertions(+), 101 deletions(-) + +commit 52fb80a7b3f98eb8322a7ba84e2900f044b3a18a +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 13:27:01 2011 +0200 + + xpdf303: compile++ + + poppler/ArthurOutputDev.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 37ca8dc4215693ec657d165ebdb6c315a0ae92c9 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Sep 1 12:34:32 2011 +0200 + + xpdf303: Use int instead of Gushort for gid/cid maps + + fofi/FoFiTrueType.cc | 18 +++++++++--------- + fofi/FoFiTrueType.h | 14 +++++++------- + fofi/FoFiType1C.cc | 8 ++++---- + fofi/FoFiType1C.h | 2 +- + poppler/CairoFontEngine.cc | 22 +++++++++++----------- + poppler/CairoFontEngine.h | 8 ++++---- + poppler/GfxFont.cc | 22 +++++++++++----------- + poppler/GfxFont.h | 10 +++++----- + poppler/PSOutputDev.cc | 14 +++++++------- + poppler/SplashOutputDev.cc | 6 +++--- + splash/SplashFTFontEngine.cc | 6 +++--- + splash/SplashFTFontEngine.h | 2 +- + splash/SplashFTFontFile.cc | 12 ++++++------ + splash/SplashFTFontFile.h | 8 ++++---- + splash/SplashFontEngine.cc | 2 +- + splash/SplashFontEngine.h | 2 +- + 16 files changed, 78 insertions(+), 78 deletions(-) + +commit df942e25bff9b014bde0ff69c8a01fa3c1963015 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 01:08:10 2011 +0200 + + xpdf303: More parsing flexibility + + poppler/CharCodeToUnicode.cc | 18 ++++++------------ + 1 file changed, 6 insertions(+), 12 deletions(-) + +commit 5305dfc5702e8004e5ae35697c6aebd0b1a5c96e +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 01:05:02 2011 +0200 + + xpdf303: Make sure codes are inside the range + + poppler/CharCodeToUnicode.cc | 17 ++++++++++++++++- + 1 file changed, 16 insertions(+), 1 deletion(-) + +commit 45212483572c68abd612b5c62b21cbb545e10143 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 01:01:13 2011 +0200 + + xpdf303: change mapLen growing stragegy + + poppler/CharCodeToUnicode.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 75d70f190e97f69047cdbe97a872a936788392d9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 01:00:23 2011 +0200 + + xpdf303: Limit code to 0xffffff + + poppler/CharCodeToUnicode.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit b4180a187f9246b6390df112e5536ead9ef9bcbe +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 00:59:09 2011 +0200 + + xpdf303: Use parseHex instead of sscanf + + poppler/CharCodeToUnicode.cc | 18 ++++++++---------- + 1 file changed, 8 insertions(+), 10 deletions(-) + +commit 121f648f233adcdc631c7e29d67b60baa922e29a +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 00:28:40 2011 +0200 + + Add helper parseHex function + + poppler/CharCodeToUnicode.cc | 35 +++++++++++++++++++++++++++++++++++ + 1 file changed, 35 insertions(+) + +commit be0436ace671070bab4304efee607f40c959bc55 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 00:26:57 2011 +0200 + + xpdf303: CharCodeToUnicode::makeIdentityMapping & friends + + poppler/CharCodeToUnicode.cc | 25 +++++++++++++++++++++++++ + poppler/CharCodeToUnicode.h | 4 ++++ + 2 files changed, 29 insertions(+) + +commit 5dd94447b14db1894f06ad0590187dae7575e33a +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 00:15:59 2011 +0200 + + xpdf303: Remove unused constructor + + splash/SplashXPath.cc | 5 ----- + splash/SplashXPath.h | 1 - + 2 files changed, 6 deletions(-) + +commit d00d56e4a46e8534378534de0d94ce0551d75d84 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 1 00:11:49 2011 +0200 + + xpdf303: Speedup SplashScreen + + By using << instead of * and by putting some functions on the header + so they can be inlined + + splash/SplashScreen.cc | 89 + +++++++++++++++++--------------------------------- + splash/SplashScreen.h | 14 ++++++-- + 2 files changed, 42 insertions(+), 61 deletions(-) + +commit 5e8debf96ab1bb9db31a0332a482d08c181d52ea +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 31 23:56:52 2011 +0200 + + xpdf303: Add splashCheckDet helper + + splash/SplashMath.h | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +commit 4cef5a52b33b1afba28d890bbe48000b734ac357 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 31 21:09:50 2011 +0200 + + xpdf303: Protect against NULL from lexer->getStream() + + poppler/Parser.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 2547ec60db6d954e5c8318e30fcc54f70bcfa95c +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 31 21:05:11 2011 +0200 + + xpdf303: Add GBool force = gFalse to SplashPath::close + + splash/SplashPath.cc | 5 +++-- + splash/SplashPath.h | 6 ++++-- + 2 files changed, 7 insertions(+), 4 deletions(-) + +commit 9370f9640a24c7b944f3da7c10e070a960bdd8f9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 31 21:01:32 2011 +0200 + + xpdf303: Add guards to the header + + poppler/Stream-CCITT.h | 5 +++++ + 1 file changed, 5 insertions(+) + +commit ab9dea663a4df5af8f54c1ff5149254adfd72ce9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 31 20:34:17 2011 +0200 + + xpdf303: Add SplashBitmap::writeAlphaPGMFile and + SplashBitmap::takeData + + splash/SplashBitmap.cc | 22 ++++++++++++++++++++++ + splash/SplashBitmap.h | 6 ++++++ + 2 files changed, 28 insertions(+) + +commit 6558d735c65a3dca9b9e16de5588c8b8c482f04f +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 31 20:30:27 2011 +0200 + + xpdf303: Write faster + + splash/SplashBitmap.cc | 14 ++------------ + 1 file changed, 2 insertions(+), 12 deletions(-) + +commit a9b26d9c35fccc7b46a96acdb2064a9976bd49bd +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 31 20:29:58 2011 +0200 + + xpdf303: Only free data if there is data to free + + splash/SplashBitmap.cc | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +commit 8f6e0285d7e80d8c1a8defaad9d0f87a2e054151 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 31 20:20:47 2011 +0200 + + xpdf303: PDFDocEncoding changes + + This overwrites Michael Vrable's changes of using U+FFFD to actually + using the order, i'm taking Derek's change here + + poppler/PDFDocEncoding.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 9c8f30fb4a2a0dd2cf359610e33749e1682921c7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 31 20:17:38 2011 +0200 + + xpdf303: comment changes + + poppler/Link.h | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit b78046057657b44c5cc9353d9e3dde356eb7fcbd +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 31 19:32:03 2011 +0200 + + xpdf303: Introduce unicodeTypeNum and unicodeTypeAlphaNum + + poppler/UnicodeTypeTable.cc | 11 +++++++++++ + poppler/UnicodeTypeTable.h | 4 ++++ + 2 files changed, 15 insertions(+) + +commit 0ec4b390ddb7fa7d028b8f0515ecd3e61c488c9f +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 31 19:30:55 2011 +0200 + + xpdf303: UnicodeTypeTable tables changes + + poppler/UnicodeTypeTable.cc | 28 ++++++++++++++-------------- + 1 file changed, 14 insertions(+), 14 deletions(-) + +commit f331c009f94703d6007fce9570ee19c6e4822339 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 31 19:20:12 2011 +0200 + + xpdf303: Remove warning() from Error.h + + poppler/CairoOutputDev.cc | 6 +++--- + poppler/Error.cc | 7 ------- + poppler/Error.h | 1 - + 3 files changed, 3 insertions(+), 11 deletions(-) + +commit 53f94df2ce21793914ccc153ba6b2fe5cbeb8371 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 31 19:17:13 2011 +0200 + + Port to setErrorCallback + + cpp/poppler-document.cpp | 2 +- + cpp/poppler-private.cpp | 6 ++---- + cpp/poppler-private.h | 3 ++- + qt4/src/poppler-private.cc | 8 +++----- + test/perf-test.cc | 4 ++-- + 5 files changed, 10 insertions(+), 13 deletions(-) + +commit 95a52f06a98f49f7c8f2b92634b75af96b4eee1d +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 31 19:07:22 2011 +0200 + + xpdf303: Forgot this when doing the char * -> const char * + + poppler/JPXStream.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 00549400f155d8e36b4ac718603fc945858fe50d +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 31 19:04:14 2011 +0200 + + xpdf303: error() changes, new param and formatting + + fofi/FoFiBase.cc | 8 +-- + fofi/FoFiTrueType.cc | 2 +- + fofi/FoFiType1.cc | 4 +- + goo/JpegWriter.cc | 2 +- + goo/PNGWriter.cc | 16 ++--- + poppler/Annot.cc | 40 +++++------ + poppler/ArthurOutputDev.cc | 16 ++--- + poppler/CMap.cc | 26 +++---- + poppler/CachedFile.cc | 2 +- + poppler/CairoFontEngine.cc | 10 +-- + poppler/Catalog.cc | 50 ++++++------- + poppler/CharCodeToUnicode.cc | 54 +++++++------- + poppler/CurlCachedFile.cc | 2 +- + poppler/DCTStream.cc | 2 +- + poppler/Decrypt.cc | 2 +- + poppler/Error.cc | 55 ++++++++++----- + poppler/Error.h | 23 +++++- + poppler/FileSpec.cc | 8 +-- + poppler/Form.cc | 44 ++++++------ + poppler/Function.cc | 107 ++++++++++++++-------------- + poppler/Gfx.cc | 161 + +++++++++++++++++++++--------------------- + poppler/GfxFont.cc | 102 ++++++++++++++------------- + poppler/GfxState.cc | 128 ++++++++++++++++----------------- + poppler/GfxState.h | 8 +-- + poppler/GlobalParams.cc | 38 +++++----- + poppler/GlobalParamsWin.cc | 4 +- + poppler/Hints.cc | 22 +++--- + poppler/JBIG2Stream.cc | 88 +++++++++++------------ + poppler/JPEG2000Stream.cc | 10 +-- + poppler/JPXStream.cc | 164 + ++++++++++++++++++++++--------------------- + poppler/Lexer.cc | 24 +++---- + poppler/Linearization.cc | 20 +++--- + poppler/Link.cc | 77 ++++++++++---------- + poppler/Movie.cc | 2 +- + poppler/Object.h | 8 +-- + poppler/OptionalContent.cc | 14 ++-- + poppler/PDFDoc.cc | 43 ++++++------ + poppler/PDFDocFactory.cc | 2 +- + poppler/PSOutputDev.cc | 45 ++++++------ + poppler/Page.cc | 12 ++-- + poppler/Parser.cc | 10 +-- + poppler/Rendition.cc | 6 +- + poppler/SecurityHandler.cc | 12 ++-- + poppler/SplashOutputDev.cc | 28 ++++---- + poppler/Stream.cc | 116 ++++++++++++++++-------------- + poppler/TextOutputDev.cc | 2 +- + poppler/UnicodeMap.cc | 15 ++-- + poppler/XRef.cc | 32 ++++----- + splash/Splash.cc | 2 +- + splash/SplashBitmap.cc | 6 +- + test/perf-test.cc | 4 +- + utils/HtmlOutputDev.cc | 18 ++--- + utils/ImageOutputDev.cc | 10 +-- + utils/pdfextract.cc | 4 +- + utils/pdfimages.cc | 2 +- + utils/pdfinfo.cc | 6 +- + utils/pdfmerge.cc | 6 +- + utils/pdftocairo.cc | 6 +- + utils/pdftohtml.cc | 6 +- + utils/pdftops.cc | 6 +- + utils/pdftotext.cc | 12 ++-- + 61 files changed, 912 insertions(+), 842 deletions(-) + +commit cd0764921064bfd455e9df52dc9bda6fbd2c2db2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Aug 31 17:23:28 2011 +0200 + + xpdf303: Always define at least 256 glyphs for Type 0 fonts + + fofi/FoFiTrueType.cc | 41 ++++++++++++++++++++++++++++++++++------- + fofi/FoFiTrueType.h | 3 ++- + 2 files changed, 36 insertions(+), 8 deletions(-) + +commit 4d4318e258fb68704b1a51a14fa89134606e2aa7 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Aug 31 17:07:25 2011 +0200 + + xpdf303: Different growing strategy for vmtxTab in FoFiTrueType + + fofi/FoFiTrueType.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit c8c7fcef9bc8f802be2d376c9d2099971f159317 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Aug 31 17:05:16 2011 +0200 + + xpdf303: Fix memory leak in FoFiTrueType + + fofi/FoFiTrueType.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 655b1a97db5449c009e5b63fc7c12233e6fae450 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Aug 31 16:54:05 2011 +0200 + + xpdf303: Check for an invalid loca format field in the head table + in FoFiTrueType + + fofi/FoFiTrueType.cc | 7 +++++++ + 1 file changed, 7 insertions(+) + +commit 9710ab96f1cf26394cc473952a3331d60c149451 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Aug 31 16:49:54 2011 +0200 + + Fix the build + + fofi/FoFiIdentifier.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 36b733a3165fd26aa8c25ba57faa5d2277aa31ec +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Aug 30 16:31:52 2011 +0200 + + xpdf303: Handle bogus loca table entries in FoFiTrueType + + where the offset is past the end of the glyf table. This part was + missing in previous commit. + + fofi/FoFiTrueType.cc | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +commit a288bdb417582f07a5a0cb13d5218946a1d0ccc8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 21:55:43 2011 +0200 + + xpdf303: Increase max keyLength to 32 + + poppler/XRef.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 12e0acd9d393df76e297bb3fde323092c428be21 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 21:03:05 2011 +0200 + + xpdf303: GfxXXXpath different growing strategy + + poppler/GfxState.cc | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +commit 7c5e496715f56498fb1aa08371d2b8d4d0e73d25 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 20:59:36 2011 +0200 + + xpdf303: No need for 4 Guint when 1 is enough + + poppler/GfxState.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit e7e8082901e108130d5c98cc7648f143978c9562 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 20:50:17 2011 +0200 + + xpdf303: GooList::copy, GooList::reverse and GooList::put + + goo/GooList.cc | 22 ++++++++++++++++++++++ + goo/GooList.h | 10 ++++++++++ + 2 files changed, 32 insertions(+) + +commit 8a119cf205467c20269e7beffde9497ffd277c15 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 20:48:40 2011 +0200 + + xpdf303: Inserting with a negative i means prepending + + goo/GooList.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 95142a8e63e476324e368785001a23d4f1d462b9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 20:47:12 2011 +0200 + + xpdf303: If size is 0 reserve 8 anyway + + goo/GooList.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit bd1076da03f76fb62998a9409d366412f4aa5d13 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 20:45:36 2011 +0200 + + xpdf303: Complain for gmalloc and grealloc < 0 + + goo/gmem.cc | 28 ++++++++++++++++++++++++---- + 1 file changed, 24 insertions(+), 4 deletions(-) + +commit 5a42b3693a9e501a27d790d4aeafcb68f63cb950 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 20:38:39 2011 +0200 + + xpdf303: Honor the deleteKeys setting + + goo/GooHash.cc | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +commit d584b54eff52c47f983947b2aff0967dfed0ccf9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 20:36:03 2011 +0200 + + xpdf303: set to NULL on failure + + goo/gfile.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit bf2cb5c9c47b4a61192101f0a48771657228e383 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Aug 30 19:08:40 2011 +0930 + + Fix compile error with libpng >= 1.5.0 + + libpng 1.5.0 changed one of the types in the png_set_iCCP() function + prototype. + + goo/PNGWriter.cc | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +commit 6364c50ffb4053cc30cecbefff7a3142cab8c50b +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 18:27:09 2011 +0200 + + xpdf303: Support for aes256 et all in Decrypt/SecurityHandler + + poppler/Decrypt.cc | 488 + +++++++++++++++++++++++++++++++++++++++------ + poppler/Decrypt.h | 19 +- + poppler/PDFDoc.cc | 2 +- + poppler/SecurityHandler.cc | 238 ++++++++++++---------- + poppler/SecurityHandler.h | 7 +- + poppler/Stream.h | 3 +- + 6 files changed, 595 insertions(+), 162 deletions(-) + +commit 39ce4575f96953b499d09074e847d492d18379fa +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 17:39:30 2011 +0200 + + xpdf303: Add FoFiIdentifier + + CMakeLists.txt | 2 + + fofi/FoFiIdentifier.cc | 630 + +++++++++++++++++++++++++++++++++++++++++++++++++ + fofi/FoFiIdentifier.h | 42 ++++ + fofi/Makefile.am | 2 + + 4 files changed, 676 insertions(+) + +commit 33e7d54b4a29d297108ef3dc6008190625125ec8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 17:36:22 2011 +0200 + + xpdf303: Also check against INT_MAX in FoFiBase + + fofi/FoFiBase.cc | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +commit fb1f56f091e5329b30279916b182f64134f3b2e6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 17:34:50 2011 +0200 + + xpdf303: Introduce FoFiBase::getU32LE + + fofi/FoFiBase.cc | 15 +++++++++++++++ + fofi/FoFiBase.h | 1 + + 2 files changed, 16 insertions(+) + +commit a79bc3359586cbc2c235d20dfa934dab1f475561 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Aug 30 16:59:08 2011 +0200 + + xpdf303: Check for a zero-entry cmap table in FoFiTrueType + + fofi/FoFiTrueType.cc | 28 +++++++++++++++++----------- + 1 file changed, 17 insertions(+), 11 deletions(-) + +commit efce014e39d0d13157b21a10ff8d483b5cfc561a +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 17:02:16 2011 +0200 + + xpdf303: upddate xpdfCopyright + + poppler/poppler-config.h.cmake | 4 ++-- + poppler/poppler-config.h.in | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +commit 2eb388ccc6c7526e66da804d9d800cf29a027914 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 16:50:39 2011 +0200 + + xpdf303: Merge README + + README | 2 +- + README-XPDF | 153 + +++++++++++++++++++++++++++++++++++++++--------------------- + 2 files changed, 101 insertions(+), 54 deletions(-) + +commit 331b0f1c16c4f636fc616569bab030969aa848f2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Aug 30 16:42:33 2011 +0200 + + xpdf303: Check for entries in the table directory with bogus tags + in FoFiTrueType + + This handles the case where the number of tables given in the + header is + too high. + + fofi/FoFiTrueType.cc | 30 +++++++++++++++++++++++++----- + 1 file changed, 25 insertions(+), 5 deletions(-) + +commit faaba717046ba87ef5ded614e2bcab6260a9f7c2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 16:36:24 2011 +0200 + + xpdf303: FixedPoint improvements + + goo/FixedPoint.cc | 51 + ++++++++++++++++++++++++++++++++------------------ + goo/FixedPoint.h | 15 +++++++++++++-- + splash/Splash.cc | 12 ++++++++++++ + splash/SplashFTFont.cc | 16 ++++++++-------- + splash/SplashMath.h | 8 +++++--- + splash/SplashXPath.cc | 9 +++++++++ + 6 files changed, 80 insertions(+), 31 deletions(-) + +commit 73efc96eef6bd32a7c058b7dda8101f4f23c454f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Aug 30 16:31:52 2011 +0200 + + xpdf303: Handle bogus loca table entries in FoFiTrueType + + where the offset is past the end of the glyf table. + + fofi/FoFiTrueType.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 1df3489392a77e2b75adbafcc2fa10de829c172e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Aug 30 16:21:40 2011 +0200 + + xpdf303: Use std::sort (with functors) in place of qsort + + It can be significantly faster. Not included changes in + SplashXPathScanner.cc since they depend on other changes not yet + merged. + + fofi/FoFiTrueType.cc | 55 + +++++++++++++++++++++++--------------------------- + poppler/GfxFont.cc | 24 ++++++++++++++-------- + splash/SplashScreen.cc | 12 +++++++---- + splash/SplashXPath.cc | 44 ++++++++++++++++++---------------------- + 4 files changed, 69 insertions(+), 66 deletions(-) + +commit f298e7f844105f2d9a36144e59be86c341e37507 +Merge: 2a6bd7a 0ca5453 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 16:21:58 2011 +0200 + + Merge branch 'master' into xpdf303merge + +commit 0ca5453fea9e5342188f772acd6f31af1778f236 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 16:20:17 2011 +0200 + + Compile when defining USE_FIXEDPOINT + + splash/Splash.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit bd7a53bc2f27fc3979f8de306e2dcaca53d4570a +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 16:20:08 2011 +0200 + + match function definition + + poppler/SplashOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 2a6bd7aae37f73a94bf1a84f699f310177661611 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 15:13:17 2011 +0200 + + xpdf303: Expand latin1UnicodeMapRanges and ascii7UnicodeMapRanges + + poppler/UnicodeMapTables.h | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +commit 4d31785409e464d0e96dcf11167ecdffd64026d1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 15:09:01 2011 +0200 + + xpdf303: More entries for nameToUnicodeTab + + poppler/NameToUnicodeTable.h | 3159 + ++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 3159 insertions(+) + +commit 2658030836f3a15dadadd7f1989dfaa858bf876f +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 14:49:23 2011 +0200 + + xpdf303: char * -> const char * + + cmake/modules/PopplerMacros.cmake | 2 +- + configure.ac | 2 +- + cpp/poppler-private.cpp | 2 +- + cpp/poppler-private.h | 2 +- + fofi/FoFiBase.h | 2 +- + fofi/FoFiEncodings.cc | 6 ++--- + fofi/FoFiEncodings.h | 6 ++--- + fofi/FoFiTrueType.cc | 10 ++++----- + fofi/FoFiTrueType.h | 4 ++-- + fofi/FoFiType1.cc | 4 ++-- + fofi/FoFiType1.h | 2 +- + fofi/FoFiType1C.cc | 14 ++++++------ + fofi/FoFiType1C.h | 6 ++--- + goo/GooHash.cc | 16 +++++++------- + goo/GooHash.h | 12 +++++----- + goo/GooString.cc | 22 +++++++++---------- + goo/GooString.h | 16 +++++++------- + goo/gfile.cc | 4 ++-- + goo/gfile.h | 4 ++-- + goo/gmem.cc | 2 +- + goo/gmem.h | 2 +- + poppler/Annot.cc | 8 +++---- + poppler/Annot.h | 6 ++--- + poppler/ArthurOutputDev.cc | 6 ++--- + poppler/BuiltinFont.cc | 6 ++--- + poppler/BuiltinFont.h | 10 ++++----- + poppler/DCTStream.cc | 2 +- + poppler/DCTStream.h | 2 +- + poppler/Dict.cc | 14 ++++++------ + poppler/Dict.h | 14 ++++++------ + poppler/Error.cc | 10 ++++----- + poppler/Error.h | 6 ++--- + poppler/FileSpec.cc | 2 +- + poppler/FlateStream.cc | 2 +- + poppler/FlateStream.h | 2 +- + poppler/FontEncodingTables.cc | 14 ++++++------ + poppler/FontEncodingTables.h | 14 ++++++------ + poppler/FontInfo.cc | 2 +- + poppler/Form.cc | 6 ++--- + poppler/Form.h | 4 ++-- + poppler/Gfx.cc | 2 +- + poppler/Gfx.h | 2 +- + poppler/GfxFont.cc | 46 + +++++++++++++++++++-------------------- + poppler/GfxFont.h | 8 +++---- + poppler/GfxState.cc | 6 ++--- + poppler/GfxState.h | 2 +- + poppler/GlobalParams.cc | 21 +++++++++--------- + poppler/GlobalParams.h | 8 +++---- + poppler/GlobalParamsWin.cc | 6 ++--- + poppler/JBIG2Stream.cc | 2 +- + poppler/JBIG2Stream.h | 2 +- + poppler/JPEG2000Stream.cc | 2 +- + poppler/JPEG2000Stream.h | 2 +- + poppler/JPXStream.h | 2 +- + poppler/NameToCharCode.cc | 8 +++---- + poppler/NameToCharCode.h | 6 ++--- + poppler/NameToUnicodeTable.h | 2 +- + poppler/Object.cc | 4 ++-- + poppler/Object.h | 28 ++++++++++++------------ + poppler/PDFDoc.cc | 2 +- + poppler/PSOutputDev.cc | 24 ++++++++++---------- + poppler/PSOutputDev.h | 8 +++---- + poppler/Page.cc | 2 +- + poppler/Page.h | 2 +- + poppler/SplashOutputDev.cc | 6 ++--- + poppler/Stream.cc | 16 +++++++------- + poppler/Stream.h | 28 ++++++++++++------------ + poppler/TextOutputDev.cc | 2 +- + poppler/TextOutputDev.h | 2 +- + poppler/UnicodeMap.cc | 4 ++-- + poppler/UnicodeMap.h | 4 ++-- + poppler/UnicodeTypeTable.cc | 4 ++-- + qt4/src/poppler-private.cc | 2 +- + qt4/src/poppler-ps-converter.cc | 2 +- + splash/SplashFTFontEngine.cc | 8 +++---- + splash/SplashFTFontEngine.h | 6 ++--- + splash/SplashFTFontFile.cc | 6 ++--- + splash/SplashFTFontFile.h | 2 +- + splash/SplashFontEngine.cc | 6 ++--- + splash/SplashFontEngine.h | 6 ++--- + splash/SplashT1FontEngine.cc | 6 ++--- + splash/SplashT1FontEngine.h | 4 ++-- + splash/SplashT1FontFile.cc | 10 ++++----- + splash/SplashT1FontFile.h | 6 ++--- + test/pdf-operators.c | 4 ++-- + test/perf-test.cc | 4 ++-- + utils/HtmlFonts.cc | 4 ++-- + utils/HtmlOutputDev.cc | 12 +++++----- + utils/HtmlOutputDev.h | 4 ++-- + utils/parseargs.cc | 4 ++-- + utils/parseargs.h | 6 ++--- + utils/pdffonts.cc | 2 +- + utils/pdfinfo.cc | 12 +++++----- + utils/pdftocairo.cc | 4 ++-- + utils/pdftohtml.cc | 10 ++++----- + utils/pdftotext.cc | 12 +++++----- + 96 files changed, 337 insertions(+), 338 deletions(-) + +commit c899d26e0f7a61db99925179330c28df015a676b +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 30 00:31:00 2011 +0200 + + Add COPYING3 from xpdf3.03 + + COPYING3 | 674 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 674 insertions(+) + +commit 508517a35cb3bc5195682a9cd89fb50a801eddc2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 29 23:55:42 2011 +0200 + + 0.17.3 + + CMakeLists.txt | 4 ++-- + NEWS | 32 ++++++++++++++++++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + glib/CMakeLists.txt | 2 +- + glib/Makefile.am | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/CMakeLists.txt | 2 +- + qt4/src/Doxyfile | 2 +- + qt4/src/Makefile.am | 2 +- + 10 files changed, 42 insertions(+), 10 deletions(-) + +commit 1431564f3363a63a8669c8dd15970db814f4969f +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Mon Aug 29 22:22:02 2011 +0200 + + Add pdfextract and pdfmerge + + See "Creating PDF with poppler ?" thread for more info + + utils/CMakeLists.txt | 15 +++++ + utils/Makefile.am | 10 +++ + utils/pdfextract.cc | 111 ++++++++++++++++++++++++++++++++ + utils/pdfmerge.cc | 176 + +++++++++++++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 312 insertions(+) + +commit 8ca2f41089bc6402baf9b24428af04314c037b54 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Mon Aug 29 22:20:52 2011 +0200 + + Rework writing of PDF files + + Makes it more compatible with other PDF readers + See "Creating PDF with poppler ?" thread in the mailing list for + more info + + poppler/PDFDoc.cc | 389 + ++++++++++++++++++++++++++++++++++++++++++++++++------ + poppler/PDFDoc.h | 30 ++++- + 2 files changed, 375 insertions(+), 44 deletions(-) + +commit 33da7e270431e8e4c500e7573b3ca0dddd9f237e +Author: suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Sun Aug 28 22:07:38 2011 +0200 + + Fix building static-linked pdftocairo + + utils/Makefile.am | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 91fafce028ca6620c0eb22e370fb4c6fd3404e3c +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Aug 23 21:02:02 2011 +0930 + + cairo: align strokes when Stroke Adjust is true and line width <= 1 + + If the stroke coordinates are not aligned, lines in cairo may be up to + 1 pixel wider than the requested width. This is most obvious when the + line width is 1 and the rendered line is 2 pixels. + + When Stroke Adjust is true, the PDF standard requires that stroke + coordinates be adjusted to ensure the stroke width is within half a + pixel of the requested width. + + If Stroke Adjust is enabled and the width is <= 1 pixel (the previous + commit adjusts the width to be at least 1 pixel), use the method + documented at http://www.cairographics.org/FAQ/#sharp_lines to align + the coordinates to ensure the rendered width is 1 pixel. + + Fixes bug #4536. + + poppler/CairoOutputDev.cc | 40 +++++++++++++++++++++++++++++++++++----- + poppler/CairoOutputDev.h | 3 +++ + 2 files changed, 38 insertions(+), 5 deletions(-) + +commit cfc67afe80b963ba662018674cadf3085466bb9f +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Aug 23 20:46:24 2011 +0930 + + cairo: fix stroking of very thin lines + + Lines with a width less than 1.0 are almost invisible in cairo output + due to antialising. The PDF standard states that when the Stroke + Adjust graphics parameter is true, all lines must be at least one + pixel wide. + + Add a stroke_adjust flag to the CairoOuputDev. Like splash, use the + globalParam strokeAdjust setting (which defaults to true) to + initialize the flag and ignore the Stroke Adjust settng in PDF + files. This emulates Acrobat behavior. + + When stroke_adjust is true, find the line width in device pixels and + if less than 0.5 set the line width to 0.5 device pixels. The value + 0.5 pixels seems to make horizontal and vertical lines look better + because integer aligned 1.0 wide lines in cairo are rendered two + pixels wide which looks too fat. + + poppler/CairoOutputDev.cc | 20 +++++++++++++++++++- + poppler/CairoOutputDev.h | 1 + + 2 files changed, 20 insertions(+), 1 deletion(-) + +commit 7a7c932e09796b944dda69df1b339c889ee1d63a +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 25 00:23:40 2011 +0200 + + Add a way to get the fully qualified name + + qt4/src/poppler-form.cc | 12 +++++++++++- + qt4/src/poppler-form.h | 8 +++++++- + 2 files changed, 18 insertions(+), 2 deletions(-) + +commit e001871d927f9cc86b4327d64e4c66ad00172ad0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 24 23:44:18 2011 +0200 + + Clarify ownership + + qt4/src/poppler-qt4.h | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 87c48fdc175be4d852b953778f915ea93cd50194 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Aug 24 19:53:48 2011 +0930 + + cairo: fix unique id mime data + + The unique id string was copied before the object number was appended + resulting in all images in pdf output being the same. + + poppler/CairoOutputDev.cc | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit 08a2ba6f1603246651f0d5e697b88d38363d7df2 +Author: Pino Toscano <pino@kde.org> +Date: Tue Aug 23 20:20:32 2011 +0200 + + pdftocairo/cmake: need to link to freetype + + utils/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 82496b18dc4aff66cc29f2b6607c8f894afe8b49 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 22 16:42:28 2011 +0200 + + Update Adrian (C) + + poppler/GfxFont.h | 1 + + 1 file changed, 1 insertion(+) + +commit 2576e3a6d9746e2272c620a775e11295932eb5f2 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Aug 22 21:41:36 2011 +0930 + + update SEE ALSO section of man pages + + - ensure each man page references all other utils + - sort list of utils in alphabetical order + + utils/pdffonts.1 | 8 +++++--- + utils/pdfimages.1 | 8 +++++--- + utils/pdfinfo.1 | 8 +++++--- + utils/pdftocairo.1 | 2 +- + utils/pdftohtml.1 | 8 ++++++++ + utils/pdftoppm.1 | 8 +++++--- + utils/pdftops.1 | 8 +++++--- + utils/pdftotext.1 | 9 +++++---- + 8 files changed, 39 insertions(+), 20 deletions(-) + +commit 23ec5c8d394beb632ee45f6308215646cd1a0195 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Aug 22 21:26:24 2011 +0930 + + cairo: only use show_text_glyphs if the surface supports it and the + font has toUnicode + + When generating pdf output, fonts that do not have toUnicode cause an + excessive number of empty text ActualText entries to be written due to + glyphs that do not have have a mapping. + + poppler/CairoOutputDev.cc | 12 ++++++++---- + poppler/CairoOutputDev.h | 1 + + poppler/GfxFont.h | 3 +++ + 3 files changed, 12 insertions(+), 4 deletions(-) + +commit 3a574f13fa22b7c31eda0d0437f4094a5a39ff34 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Aug 19 23:23:24 2011 +0930 + + cairo: fix stroke patterns + + Since cairo still does not yet have cairo_stroke_to_path(), this + implements a workaround for stroke patterns. In clipToStrokePath, the + stroke path and stroke parameters are saved. In tilingPatternFill and + fill (used to draw shading patterns) if a stroke path clip has been + saved, the current pattern is stroked instead of filled using the + saved stroke. + Fixes bug #11719. + + poppler/CairoOutputDev.cc | 52 + ++++++++++++++++++++++++++++++++++++++++++++++- + poppler/CairoOutputDev.h | 17 ++++++++++++++-- + 2 files changed, 66 insertions(+), 3 deletions(-) + +commit eb740dac838d2a1e32899327ca6d25c3dca641df +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Aug 22 13:41:56 2011 +0200 + + glib-demo: Add text attributes information to text demo + + glib/demo/text.c | 103 + +++++++++++++++++++++++++++++++++++++++++++++++++++---- + 1 file changed, 97 insertions(+), 6 deletions(-) + +commit cda4aefaa136ae07778de3b1593808a5aaa2db5b +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Aug 22 13:40:49 2011 +0200 + + glib-demo: Add pgd_pixbuf_new_for_color() to utils + + To get a pixbuf for a given poppler color. + + glib/demo/annots.c | 22 +--------------------- + glib/demo/utils.c | 27 +++++++++++++++++++++++++++ + glib/demo/utils.h | 1 + + 3 files changed, 29 insertions(+), 21 deletions(-) + +commit 2a11b2963a548186654722a393db1e19d57828f1 +Author: danigm <danigm@wadobo.com> +Date: Mon Aug 22 12:51:50 2011 +0200 + + glib: Add poppler_page_get_text_attributes() + + It returns a list of text attributes that apply to a range of text as + returned by poppler_page_get_text(). Text attributes are represented + by + a PopplerTextAttributes struct that contains font name, font size, + whether text is undrlined and foreground color for a range of text. + Fixes bug #33269. + + glib/poppler-page.cc | 202 + ++++++++++++++++++++++++++++++++++++ + glib/poppler-page.h | 33 ++++++ + glib/poppler.h | 1 + + glib/reference/poppler-sections.txt | 7 ++ + 4 files changed, 243 insertions(+) + +commit 15f99157cf3900bf20cf619e204ae53085af497d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Aug 22 12:43:12 2011 +0200 + + textoutputdev: Add TextFontInfo::matches() + + It checks whether two TextFontInfo objects contain the same font. + + poppler/TextOutputDev.cc | 4 ++++ + poppler/TextOutputDev.h | 1 + + 2 files changed, 5 insertions(+) + +commit 5b554b39fca634c8ba58915c14522cb2920fe280 +Author: Pino Toscano <pino@kde.org> +Date: Mon Aug 22 13:16:23 2011 +0200 + + pdftocairo/cmake: link to lcms library if available + + utils/CMakeLists.txt | 3 +++ + 1 file changed, 3 insertions(+) + +commit f7cd236fea8740ef05635d1fd7917a778cc373f0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 22 00:00:32 2011 +0200 + + Ship HtmlUtils.h + + utils/Makefile.am | 1 + + 1 file changed, 1 insertion(+) + +commit a128a858c50287cfba74c69996276ea44370dc26 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 21 23:52:06 2011 +0200 + + Update Adrian's (C) + + goo/PNGWriter.cc | 2 +- + goo/PNGWriter.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit b78134314107d8344360c3313478115ed291630d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 21 23:46:09 2011 +0200 + + Fix copyright + + c&p is evil + + goo/gtypes_p.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ade53277546cef4ba19d982518c0cd83a4bb9c12 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 21 23:42:53 2011 +0200 + + Move HAVE_STDINT_H use to a private header + + This way we do not need to expose it in poppler-config.h since + gtypes.h is a half public header + + goo/Makefile.am | 1 + + goo/gtypes.h | 18 ------------------ + goo/gtypes_p.h | 30 ++++++++++++++++++++++++++++++ + poppler/CairoOutputDev.cc | 1 + + poppler/CairoRescaleBox.cc | 1 + + utils/pdftocairo.cc | 1 + + 6 files changed, 34 insertions(+), 18 deletions(-) + +commit 6166c3a37a4d6307d4f23ee272ea07c95bbba74a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 21 23:31:30 2011 +0200 + + Silence silly gcc + + goo/PNGWriter.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit eb5b228c4c24152e632c931b63c64ffb1e10d45d +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Aug 20 21:13:18 2011 +0930 + + pdftocairo: fix writing to stdout for ps/pdf/svg + + utils/pdftocairo.cc | 23 ++++++++++++++++++++--- + 1 file changed, 20 insertions(+), 3 deletions(-) + +commit 1beac5896a301be68de22240017fef11e7d27d40 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Aug 13 00:23:23 2011 +0930 + + Add poppler version to PSOutputDev ouput + + poppler/PSOutputDev.cc | 1 + + 1 file changed, 1 insertion(+) + +commit b35fd3651fd3dbaa876fc64b8c5cfe77ae67335f +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Aug 5 23:01:51 2011 +0930 + + cairo: use cairo_show_text_glyphs() when printing + + This will allow cairo to setup the correct toUnicode or glyph names to + ensure text can be extracted. + + poppler/CairoOutputDev.cc | 41 ++++++++++++++++++++++++++++++++++++++--- + poppler/CairoOutputDev.h | 5 +++++ + 2 files changed, 43 insertions(+), 3 deletions(-) + +commit 51ade078bc1fa737e20120ae4cb3bf693a219823 +Author: Stefan Thomas <thomas@txtbear.com> +Date: Thu Jul 15 16:24:55 2010 +0100 + + pdftocairo: Added to CMake build system. + + utils/CMakeLists.txt | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +commit 5a8745cdf428e22641937977eedfc1d605f6ff07 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Aug 12 23:57:01 2011 +0930 + + Add pdftocairo man page + + utils/Makefile.am | 5 +- + utils/pdftocairo.1 | 254 + +++++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 258 insertions(+), 1 deletion(-) + +commit b67a12b2b26692e2ccec7ff2e6df18fee05be535 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu Aug 11 21:34:11 2011 +0930 + + pdftocairo - utility for creating png/jpeg/ps/eps/pdf/svg using + CairoOutputDev + + utils/.gitignore | 2 +- + utils/Makefile.am | 20 +- + utils/pdftocairo.cc | 970 + ++++++++++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 989 insertions(+), 3 deletions(-) + +commit 4f2d774826bf7bb7b3825e02c5ca4c2928643950 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu Aug 11 21:32:53 2011 +0930 + + png: add support for embedding ICC profile + + goo/PNGWriter.cc | 28 ++++++++++++++++++++++++++++ + goo/PNGWriter.h | 8 ++++++++ + 2 files changed, 36 insertions(+) + +commit 1091f47310bf0fc71bac5dd4ec81dad50b2f2537 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Aug 10 18:48:15 2011 +0930 + + png: Add additional pixel formats + + RGBA is required for images with transparency. GRAY and MONOCHROME + allow PNGWriter write more compact PNG files when the images is known + to be all gray or monochrome. + + goo/PNGWriter.cc | 30 ++++++++++++++++++++++++++---- + goo/PNGWriter.h | 11 ++++++++++- + 2 files changed, 36 insertions(+), 5 deletions(-) + +commit c6f26915db568f12892d48005746ad2922c19000 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Aug 10 18:45:24 2011 +0930 + + png: use PNG_RESOLUTION_METER instead of PNG_RESOLUTION_UNKNOWN to + set resolution + + gimp does not show the correct resolution unless PNG_RESOLUTION_METER + is used + + goo/PNGWriter.cc | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit 2667d2a5b34e1bbf322aea42876e7e81aa06dc29 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Aug 9 22:05:53 2011 +0930 + + Use stdint.h instead of assuming the size of types + + configure.ac | 1 + + goo/gtypes.h | 18 ++++++++++++++++++ + poppler/CairoOutputDev.cc | 2 -- + poppler/CairoRescaleBox.cc | 2 -- + 4 files changed, 19 insertions(+), 4 deletions(-) + +commit c043f298e68bdfffcb7505ec354ec7487b5bd7b2 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Jul 8 21:13:36 2011 +0930 + + cairo: assume printer pixel size is 1/600" when stroking 0 width lines + + Fixes bug #39067. + + poppler/CairoOutputDev.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 961adf0b767be78d3556b7315de3761d3d46b107 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu Aug 18 17:44:35 2011 +0930 + + cairo: set mime data for soft masked images + + Fixes bug #40192. + + poppler/CairoOutputDev.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 86271e4810f714d4ba7a2a6651a9b1d04f653262 +Author: Joshua Richardson <jric@chegg.com> +Date: Thu Aug 18 18:48:40 2011 +0200 + + pdftohtml: Support text rotation + + Includes a few other fixlets. + See bug 38586 for more info + + utils/HtmlFonts.cc | 64 ++++++++++--------- + utils/HtmlFonts.h | 10 ++- + utils/HtmlOutputDev.cc | 170 + ++++++++++++++++++++++++++++++++++--------------- + utils/HtmlOutputDev.h | 8 ++- + utils/HtmlUtils.h | 51 +++++++++++++++ + 5 files changed, 218 insertions(+), 85 deletions(-) + +commit 56248b84e2185483dd54704c13838e8f78029d49 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 18 12:40:51 2011 +0200 + + Only declare overprint if we are going to use it + + utils/pdftoppm.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit a1093aae9f64cb6768164551d50cafaef52876c1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 18 12:30:29 2011 +0200 + + Fix Adrian's (C) + + poppler/PSOutputDev.cc | 2 +- + poppler/PSOutputDev.h | 3 ++- + poppler/PreScanOutputDev.cc | 1 + + poppler/PreScanOutputDev.h | 1 + + poppler/SplashOutputDev.cc | 1 + + poppler/SplashOutputDev.h | 1 + + 6 files changed, 7 insertions(+), 2 deletions(-) + +commit 7741b24d05f50c134cf15361d52f5df7ae3c3115 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Aug 14 22:06:22 2011 +0930 + + ps: Avoid using /PatternType if only one instance of the pattern + is used + + this optimization makes pages print faster on my LaserJet + + poppler/PSOutputDev.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit a60e61ac64634dc59c80d8e6b0288c1269fc0154 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Aug 14 21:55:24 2011 +0930 + + ps: use PS Patterns for tiling fill when PS level >= 2 + + poppler/CairoOutputDev.cc | 2 +- + poppler/CairoOutputDev.h | 4 +-- + poppler/Gfx.cc | 4 +-- + poppler/OutputDev.h | 2 +- + poppler/PSOutputDev.cc | 59 + +++++++++++++++++++++++++++++++++++++++++---- + poppler/PSOutputDev.h | 13 +++++++++- + poppler/PreScanOutputDev.cc | 2 +- + poppler/PreScanOutputDev.h | 2 +- + poppler/SplashOutputDev.cc | 2 +- + poppler/SplashOutputDev.h | 2 +- + 10 files changed, 76 insertions(+), 16 deletions(-) + +commit 9938770e737b2fcec8269147e70663517f848925 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 15 13:17:24 2011 +0200 + + 0.17.2 + + CMakeLists.txt | 4 ++-- + NEWS | 37 +++++++++++++++++++++++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + glib/CMakeLists.txt | 2 +- + glib/Makefile.am | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/CMakeLists.txt | 2 +- + qt4/src/Doxyfile | 2 +- + qt4/src/Makefile.am | 5 +++-- + 10 files changed, 49 insertions(+), 11 deletions(-) + +commit 378fc06c574b85b5c003ca842aa743f0ffe5587e +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 1 22:14:12 2011 +0200 + + Only assume the OC is not visible if it exists and is set to no + + Similar to commit e2def20a45c1d8307fd62fabb9769121af975abf + but in the other branch of the if, fixes bug 39637 + + poppler/OptionalContent.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 861a7bfb9431609e1e148240447f23c8e83b9d0f +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Fri Jul 29 00:30:58 2011 +0200 + + Implement overprint in Splash + + See the "Implementing overprint in Splash" thread in the mailing + list for more info + + goo/ImgWriter.h | 2 + + goo/JpegWriter.cc | 54 ++++++-- + goo/JpegWriter.h | 7 +- + poppler/Gfx.cc | 98 +++++++++++++-- + poppler/GfxState.cc | 1 + + poppler/GfxState.h | 4 + + poppler/OutputDev.h | 1 + + poppler/SplashOutputDev.cc | 307 + +++++++++++++++++++++++++++++++++++++++------ + poppler/SplashOutputDev.h | 51 +++++++- + splash/Splash.cc | 86 +++++++++---- + splash/Splash.h | 9 +- + splash/SplashBitmap.cc | 64 +++++++++- + splash/SplashBitmap.h | 1 + + splash/SplashPattern.cc | 16 ++- + splash/SplashPattern.h | 7 ++ + splash/SplashState.cc | 11 +- + splash/SplashState.h | 22 ++++ + splash/SplashTypes.h | 5 +- + utils/pdftoppm.cc | 36 +++++- + 19 files changed, 686 insertions(+), 96 deletions(-) + +commit e2fa8a2ca8459d19c0f9dca445a2399b9a3d483d +Author: Koji Otani <sho@bbr.jp> +Date: Thu Jul 28 12:43:57 2011 +0200 + + Parse the "Medium" modifier when asking fontconfig for a font + + poppler/GlobalParams.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 0a677dd8dc9c55936530ea1fee901cab831c52af +Author: Koji Otani <sho@bbr.jp> +Date: Thu Jul 28 12:42:16 2011 +0200 + + Improve selection of CJK fonts + + Seems we need to do some more fontconfig magic for some special + fontconfig configurations + More info at bug 36474 + + poppler/GlobalParams.cc | 137 + +++++++++++++++++++++++++++++++----------------- + 1 file changed, 89 insertions(+), 48 deletions(-) + +commit e78aff6796a5d5a0a4f2fe8c7ceb33c506e2c8f5 +Author: William Bader <williambader@hotmail.com> +Date: Tue Jul 26 00:10:34 2011 +0200 + + make -level1sep write gray instead of cmyk + + If it is a gray only image + Bug 39012 + + poppler/PSOutputDev.cc | 63 + +++++++++++++++++++++++++++++++++++++++++++++++--- + 1 file changed, 60 insertions(+), 3 deletions(-) + +commit ea31309487aab6ed407a086dff1f350b6e4bdbc9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jul 26 00:09:27 2011 +0200 + + Update (C) + + poppler/PDFDoc.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit a945641497946a825dc880f94200ea1d5409332b +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Jul 23 08:44:06 2011 +0200 + + Handle missing startxref properly + + Bug 38209 + + poppler/PDFDoc.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 2c1b25ef2592367f4c18e204ab5d102f15cf272f +Author: William Bader <williambader@hotmail.com> +Date: Mon Jul 25 23:43:27 2011 +0200 + + Fix a bad memory access + + When not using antialias and the character starts to the left/top + of the image + Bug 37189 + + splash/Splash.cc | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +commit 300900afa2140141748a7571270be5d850274072 +Author: Daniel Glöckner <daniel-gl@gmx.net> +Date: Sat Jul 23 19:49:15 2011 +0200 + + Fix numerical overflow in libopenjpeg JPXStream::doLookChar() + + It also includes a speed optimization. Bug 39361 + + poppler/JPEG2000Stream.cc | 37 ++++++++++++++++++++++++++++++++++++- + poppler/JPEG2000Stream.h | 36 +++++++++++------------------------- + 2 files changed, 47 insertions(+), 26 deletions(-) + +commit ec6ea621b066a3b332a8099341664889d2ff3743 +Author: Axel Struebing <axel.struebing@freenet.de> +Date: Thu Jul 21 23:12:36 2011 +0200 + + Fix calculation of startXRefPos + + Reviewed by Hib Eris + See "another problem with saving linearized files" in the mailing + list for more info + + poppler/PDFDoc.cc | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +commit ce97cfcd6373c98fb8c63e9b3ef6c51738f22a50 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jul 20 00:24:52 2011 +0200 + + Render dots for 0 length dashed lines + + Bug 34150 + + splash/Splash.cc | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +commit 42c1b1c4af6b07f488d1b2b02a4700f19b0ab0ef +Author: Tomas Hoger <thoger@redhat.com> +Date: Wed Jul 20 00:23:15 2011 +0200 + + Fix crash on truncated JPEG/DCT stream + + Bug 36693 + + poppler/DCTStream.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 091b570c63694e475c24bb8805638ac70c654892 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jul 20 00:19:43 2011 +0200 + + Make sure the dict is a page dict + + Fixes second part of 35925 and 39072 + + poppler/PDFDoc.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ac566c887ffae9d384587f7587609642aef7a016 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jul 20 00:17:49 2011 +0200 + + Do not crash if can not get page 0 for some reason + + qt4/tests/test-poppler-qt4.cpp | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +commit 6ad95e7b8b9766aa19f01f06f02eb430e4a4a899 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 11 15:04:49 2011 +0100 + + Complete the list of preprocessor defines that we never define + + When using any of the two sanctioned build systems + + poppler/poppler-config.h.cmake | 6 ++++-- + poppler/poppler-config.h.in | 6 ++++-- + 2 files changed, 8 insertions(+), 4 deletions(-) + +commit edcc84ef0137a733cf3fab79b919af309d87325c +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 11 15:00:39 2011 +0100 + + Harmonize all SPLASH_CMYK to use #if + + poppler/SplashOutputDev.cc | 24 ++++++++++++------------ + 1 file changed, 12 insertions(+), 12 deletions(-) + +commit a8fca630d592941c033ca6a380bf46b6e733a748 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 11 14:57:33 2011 +0100 + + Sanitize headers a big + + * Remove includes to config.h as that file does not exist + * Add to poppler-config.h all the defines we define in the + configure/cmake process and are used in headers + * Include poppker-config.h where needed + + goo/GooTimer.h | 2 ++ + goo/ImgWriter.h | 3 +- + goo/JpegWriter.h | 3 +- + goo/PNGWriter.h | 4 +-- + goo/TiffWriter.h | 3 +- + goo/gfile.h | 3 +- + poppler/DCTStream.h | 5 ++-- + poppler/FlateStream.h | 5 ++-- + poppler/Gfx.h | 3 +- + poppler/GfxState.h | 2 ++ + poppler/Stream.h | 3 +- + poppler/poppler-config.h.cmake | 63 + ++++++++++++++++++++++++++++++++++++++++++ + poppler/poppler-config.h.in | 63 + ++++++++++++++++++++++++++++++++++++++++++ + splash/SplashFTFont.h | 4 ++- + splash/SplashMath.h | 4 ++- + 15 files changed, 153 insertions(+), 17 deletions(-) + +commit 214322f3c66a9aad4e2a46f6e305a3dacaa4f8b1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jul 10 01:20:21 2011 +0100 + + And 3 years later, Ed has answered :-) + + Now all our changes are GPLv2+ + + poppler/GfxFont.cc | 3 +++ + poppler/GlobalParams.cc | 3 +++ + poppler/TextOutputDev.cc | 3 +++ + poppler/TextOutputDev.h | 3 +++ + poppler/UnicodeTypeTable.cc | 3 +++ + poppler/UnicodeTypeTable.h | 3 +++ + 6 files changed, 18 insertions(+) + +commit 37cc1344672f480d4062aafbd2f3245ca1392279 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jul 10 01:15:44 2011 +0100 + + Fix header + + The file was modified in 2009 and README.contributors stating + everything is GPLv2+ is from 2008 + + poppler/XpdfPluginAPI.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 230ab66f52a992557464e325d18f88573ec52423 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jul 10 01:06:41 2011 +0100 + + make files easier to include by themselves + + fofi/FoFiTrueType.h | 2 ++ + splash/Splash.h | 3 ++- + splash/SplashFontEngine.h | 3 ++- + 3 files changed, 6 insertions(+), 2 deletions(-) + +commit 866c6d1b0daa8b28f259e1faba075026cf9007e0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jul 10 00:55:25 2011 +0100 + + Name most of the classes in poppler/ includable by themselves + + poppler/Annot.h | 4 +++- + poppler/Catalog.h | 2 ++ + poppler/CharCodeToUnicode.h | 4 +++- + poppler/CompactFontTables.h | 16 ++++++++++++++++ + poppler/FontInfo.h | 6 +++++- + poppler/GfxState_helpers.h | 4 +++- + poppler/NameToUnicodeTable.h | 18 ++++++++++++++++++ + 7 files changed, 50 insertions(+), 4 deletions(-) + +commit 6b62fb7e9bd7de7f79b9b9a6fe36a5f5da099133 +Author: William Bader <williambader@hotmail.com> +Date: Mon Jun 27 19:38:52 2011 +0100 + + Remove unused variable + + poppler/PSOutputDev.cc | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +commit 4bc6c5bd3a001bb4eb9f61488e3d4f356638e391 +Author: Adrian Bunk <bunk@stusta.de> +Date: Tue Jul 5 15:21:06 2011 +0300 + + .gitignore tests additions + + The following files were missing in .gitignore: + - cpp/tests/poppler-render + - qt4/tests/poppler-texts + - test/gtk-test + + cpp/tests/.gitignore | 1 + + qt4/tests/.gitignore | 1 + + test/.gitignore | 1 + + 3 files changed, 3 insertions(+) + +commit 00076bc308ae320244c47777fe351c1c2bef2da8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jun 24 22:51:55 2011 +0100 + + Forgot William's (C) here + + poppler/Stream.cc | 1 + + poppler/Stream.h | 1 + + 2 files changed, 2 insertions(+) + +commit 7e244fde4ec03da08d81af3402b21646c803bd31 +Author: William Bader <williambader@hotmail.com> +Date: Fri Jun 24 22:39:13 2011 +0100 + + patch to make -level2sep and -level3sep write gray instead of cmyk + + If they are only gray of course :D + + poppler/PSOutputDev.cc | 34 ++++++++++++++++++++++++++++++---- + poppler/Stream.cc | 43 +++++++++++++++++++++++++++++++++++++++++++ + poppler/Stream.h | 29 +++++++++++++++++++++++++++++ + 3 files changed, 102 insertions(+), 4 deletions(-) + +commit abba8140a9972197faaca96ec590af7dc9408fb0 +Author: William Bader <williambader@hotmail.com> +Date: Fri Jun 24 22:38:33 2011 +0100 + + patch to make -level2sep and -level3sep write cmyk instead of rgb + + poppler/PSOutputDev.cc | 59 + +++++++++++++++++++++++++++++++++++++++++++++----- + 1 file changed, 54 insertions(+), 5 deletions(-) + +commit 706007431325b1e8c9bf4cba35c89511b10ebf0c +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 20 23:30:50 2011 +0100 + + (C) for Jim + + fofi/FoFiBase.cc | 1 + + 1 file changed, 1 insertion(+) + +commit e23384fbb3542941d2cf59ce6560913255ca2b01 +Author: Jim Meyering <meyering@redhat.com> +Date: Mon Jun 20 11:09:01 2011 +0200 + + don't gmalloc(-1) upon ftell failure + + * fofi/FoFiBase.cc: Diagnose ftell failure. + + fofi/FoFiBase.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit c5601bde9d8f3f56e558a6f63e563c9d337810eb +Author: Steven Murdoch <Steven.Murdoch@cl.cam.ac.uk> +Date: Mon Jun 20 23:25:43 2011 +0100 + + Fix encoding of PDF document metadata in output of pdftohtml + + pdftohtml simply copies the PDF document title into the <title> HTML + tag, which fails when the title is UCS-2 encoded, or if it contains + characters which are in pdfDocEncoding (a ISO 8859-1 superset), + but not + in ISO 8859-1. This patch fixes the problem by decoding UCS-2 or + pdfDocEncoding into Unicode, then encoding this in the desired output + encoding. HTML escaping wasn't being done either, so I have used the + existing function HtmlFont::HtmlFilter to perform both HTML escaping + and character set encoding. This static method had to be made public + to call it from pdftohtml. See bug #37900. + + utils/HtmlFonts.h | 3 ++- + utils/pdftohtml.cc | 41 ++++++++++++++++++++++++++++++++++++++--- + 2 files changed, 40 insertions(+), 4 deletions(-) + +commit d4af1c4ef46abf1f11b7215c7b144ce7bb7912eb +Author: Joshua Richardson <joshuarbox-junk1@yahoo.com> +Date: Sat Jun 18 13:39:54 2011 +0100 + + Fix vertical spacing issues in pdftohtml output. + + Bug 38019 + + utils/HtmlFonts.cc | 3 ++- + utils/HtmlOutputDev.cc | 21 +++++++++++++++++++-- + 2 files changed, 21 insertions(+), 3 deletions(-) + +commit 589933ef105b60e8d48854cce15a7548c2850116 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 13 21:24:39 2011 +0100 + + Forgot my (C) + + poppler/PreScanOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit f5d2ddd13d27078355dee63207671885bf9b0926 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 13 18:57:29 2011 +0100 + + We need to include config.h here + + Fixes crash after patch to fix bug 13518 + + poppler/PreScanOutputDev.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 147ae4bf76a85768c9ed729ca10ee3dae93b8876 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 8 23:36:14 2011 +0100 + + Do not crash if link does not have an action + + utils/HtmlOutputDev.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 5d9489bf566b700ef38e5e33665a2648b535e1e7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 4 21:46:10 2011 +0100 + + forgot to update the C + + utils/pdftotext.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 7b123bf2b11ac81f24a966186a06de739d3c8f02 +Author: Steven Murdoch <Steven.Murdoch@cl.cam.ac.uk> +Date: Sat Jun 4 20:22:52 2011 +0100 + + Fix pdftotext -htmlmeta to correctly output U+2019 in PDF metadata + + In PDF documents, right single quotation mark (U+2019) may be + encoded as + 0x90 because PDFDocEncoding uses some of the reserved characters in + ISO 8859-1. However, pdftotext -htmlmeta assumes that characters + are either + UCS-2 or ISO 8859-1. Thus when a right single quotation mark is + encoded as + 0x90, it is output as unicode 0x90 (which is a control + character). pdfinfo + does the right thing by first converting from PDFDocEncoding to + Unicode + with pdfDocEncoding[], before encoding it in the desired character + set. + This patch applies the same logic to pdftotext. pdftohtml is broken + in the + same way, but this patch does not attempt to fix it. + + Bug 37900 + + utils/pdftotext.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit db2ae1bdbb7fcb64ba4c91dfc574d9f970bebdf6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 4 13:23:11 2011 +0100 + + Make sure catDict is a dict + + poppler/Catalog.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 58915affbdf1b5780f25d172a582c69fb2413230 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 4 13:20:02 2011 +0100 + + Make sure catDict is a dict before using it + + KDE Bug 274888 shows it's possible to get aborts because of that + + poppler/Catalog.cc | 26 ++++++++++++++++---------- + 1 file changed, 16 insertions(+), 10 deletions(-) + +commit 4ebc7e364409fe303e7a5729b568913e3c92e7d4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 4 13:19:34 2011 +0100 + + We need to free catDict on failure + + poppler/Catalog.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 335a7fc6d98f5facc1ff098a91ac968387473cb3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 31 23:18:26 2011 +0100 + + Make parse() private + + poppler/Catalog.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 311d69ef2222409859817737c44b8e741289d897 +Author: Axel Strübing <axel.struebing@freenet.de> +Date: Sun May 29 16:12:29 2011 +0100 + + Needs to be freed + + As i said in my last commit comment :D + + poppler/PDFDoc.cc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit 66c7d0199b45bc7c81c88a9989c9515398d30d43 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat May 28 17:32:02 2011 +0100 + + No need to check for NULL + + We probably need to free obj4 but i don't have the stamina to properly + test it + + poppler/PDFDoc.cc | 21 ++++++++++----------- + 1 file changed, 10 insertions(+), 11 deletions(-) + +commit 450934619a1c5b2a58f65649f567274af8d24ea7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat May 28 12:37:08 2011 +0100 + + Parse that as unicode + + Fixes KDE Bug #274055 + + qt4/src/poppler-page.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 04dfb2c984b3c9949466e2b70e26b58029c5a7d3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat May 7 12:55:34 2011 +0200 + + Make FileSpec a class and move EmbFile from Catalog to FileSpec + + Qt and cpp frontends adapted by Pino Toscano + + cpp/poppler-document.cpp | 4 +- + cpp/poppler-embedded-file-private.h | 10 +-- + cpp/poppler-embedded-file.cpp | 42 +++++++---- + glib/poppler-annot.cc | 6 +- + glib/poppler-attachment.cc | 33 +++++---- + glib/poppler-document.cc | 5 +- + glib/poppler-private.h | 3 +- + poppler/Catalog.cc | 118 + +++--------------------------- + poppler/Catalog.h | 55 +------------- + poppler/FileSpec.cc | 128 + +++++++++++++++++++++++++++++++++ + poppler/FileSpec.h | 51 ++++++++++++- + qt4/src/poppler-embeddedfile-private.h | 6 +- + qt4/src/poppler-embeddedfile.cc | 34 +++++---- + qt4/src/poppler-page.cc | 5 +- + qt4/src/poppler-private.h | 4 +- + qt4/tests/check_attachments.cpp | 12 ++-- + 16 files changed, 284 insertions(+), 232 deletions(-) + +commit 74f9befddd4b5848c4af0c1b2848a1322f8cd0a2 +Author: Pino Toscano <pino@kde.org> +Date: Wed May 25 16:46:15 2011 +0200 + + [qt4] Page needs to be a friend of EmbeddedFile, too + + qt4/src/poppler-qt4.h | 1 + + 1 file changed, 1 insertion(+) + +commit 74853614d617486b7b62e9c08be39a6e58bc7d9b +Author: Pino Toscano <pino@kde.org> +Date: Wed May 25 16:40:49 2011 +0200 + + update copyrights + + qt4/src/poppler-embeddedfile-private.h | 2 +- + qt4/src/poppler-embeddedfile.cc | 2 +- + qt4/src/poppler-qt4.h | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +commit e6b2dec502c02f9fbaed480f227cf7145249a98e +Author: Pino Toscano <pino@kde.org> +Date: Wed May 25 16:39:09 2011 +0200 + + [qt4] one more usage of the new EmbeddedFile ctor + + followup of a264e5385b2d0fee5126b3d0e57d42d34cafa45d + + qt4/src/poppler-page.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit a264e5385b2d0fee5126b3d0e57d42d34cafa45d +Author: Pino Toscano <pino@kde.org> +Date: Wed May 25 16:12:02 2011 +0200 + + [qt4] create EmbeddedFile by EmbeddedFileData only + + - create the private class and pass it to the EmbeddedFile ctor, + reducing the amount of poppler code API exposed to the outside + - turn the old private EmbeddedFile(EmbFile*) ctor in a death machine + + qt4/src/poppler-embeddedfile-private.h | 3 +++ + qt4/src/poppler-embeddedfile.cc | 21 ++++++++++++++++++--- + qt4/src/poppler-private.h | 3 ++- + qt4/src/poppler-qt4.h | 2 ++ + 4 files changed, 25 insertions(+), 4 deletions(-) + +commit 232bfa1c59013637fd7e858e22194becb636ad21 +Author: Pino Toscano <pino@kde.org> +Date: Wed May 25 15:55:48 2011 +0200 + + [Qt4] split EmbeddedFileData in an own file + + qt4/src/poppler-embeddedfile-private.h | 37 + ++++++++++++++++++++++++++++++++++ + qt4/src/poppler-embeddedfile.cc | 7 +------ + 2 files changed, 38 insertions(+), 6 deletions(-) + +commit a7242b78b3c9a64cf38ac150e6a914d7abce3355 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat May 7 11:10:11 2011 +0100 + + Do not free a shallow copy of an object we'll free later + + Make sure we have our own copy we can free + Fixes KDE BUG #268816 + (cherry picked from commit dab9cdf795d6caead555326958e86e844ace067b) + + poppler/Catalog.cc | 12 +++++------- + poppler/Catalog.h | 2 +- + 2 files changed, 6 insertions(+), 8 deletions(-) + +commit 4db2452b3d345d9531987998e6b5532a59137e1d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri May 6 14:57:51 2011 +0200 + + glib: Add poppler_document_get_n_attachments() + + glib/poppler-document.cc | 34 + ++++++++++++++++++++++++---------- + glib/poppler-document.h | 1 + + glib/reference/poppler-sections.txt | 1 + + 3 files changed, 26 insertions(+), 10 deletions(-) + +commit 3e3284de3fe1916d7f8161ede7bf49c76d01f303 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri May 6 14:49:05 2011 +0200 + + glib: Update gtk-doc.make + + gtk-doc.make | 151 + ++++++++++++++++++++++++++++++++++++++--------------------- + 1 file changed, 98 insertions(+), 53 deletions(-) + +commit 9a77bd7706a08d9aeabe600e3500c14493ac8519 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri May 6 14:48:38 2011 +0200 + + glib-demo: Add missing permission flags to info demo + + glib/demo/info.cc | 39 ++++++++++++++++++++++++++++++++++++--- + 1 file changed, 36 insertions(+), 3 deletions(-) + +commit 091c155f8a7bc79da84cd21877be389de1f2b1a3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri May 6 14:47:36 2011 +0200 + + glib: Add missing permissions flags to PopplerPermissions + + glib/poppler-document.cc | 6 ++++++ + glib/poppler-document.h | 10 +++++++++- + 2 files changed, 15 insertions(+), 1 deletion(-) + +commit 632d6a40ce3a5d3d8e10bf7e93e8eb578beae907 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 3 21:54:59 2011 +0100 + + 0.17.1 + + CMakeLists.txt | 4 ++-- + NEWS | 12 ++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 6 files changed, 18 insertions(+), 6 deletions(-) + +commit ecb136b9927a454df9360a307ccd741eaea3ca93 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 3 21:42:45 2011 +0100 + + remove unused vars + + poppler/Annot.cc | 9 ++------- + poppler/ArthurOutputDev.cc | 12 ++---------- + 2 files changed, 4 insertions(+), 17 deletions(-) + +commit ad131763640b2e27dde75c42b514386284b6a60d +Author: Pino Toscano <pino@kde.org> +Date: Wed Apr 27 22:36:13 2011 +0200 + + [qt4/tests] turn some assignments to bool into QVERIFY checks + + qt4/tests/check_optcontent.cpp | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit be08dd69d9dd4fcb22400f2f0aea331222e88e4a +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Apr 27 20:45:36 2011 +0100 + + update copyright years + (cherry picked from commit 2fbd493197309de5700f71f09967c9d23add88d3) + + poppler/Annot.cc | 1 + + utils/pdftotext.cc | 1 + + 2 files changed, 2 insertions(+) + +commit 39bcce0c8ed378aafb1019ffd1ae40330f6bb63f +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Apr 27 19:39:01 2011 +0100 + + Remove more variables that are set but then unused + + poppler/SplashOutputDev.cc | 11 +------ + utils/HtmlOutputDev.cc | 75 + +--------------------------------------------- + 2 files changed, 2 insertions(+), 84 deletions(-) + +commit 6656cf657b62d626910a02dfae9b6a1eb77772dd +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Apr 27 08:46:37 2011 +0100 + + Remove unused vars + + poppler/TextOutputDev.cc | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +commit ce55510f4dd10dfec2fc5b1c211c4a546c6ebc98 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Apr 27 08:42:34 2011 +0100 + + Remove unused vars + + splash/Splash.cc | 5 ++--- + splash/SplashFTFontEngine.cc | 4 +--- + splash/SplashXPath.cc | 6 ++---- + 3 files changed, 5 insertions(+), 10 deletions(-) + +commit 49d199fd1ea14383638739d95d019adb33b17768 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Apr 27 08:38:17 2011 +0100 + + Fix page_transition::operator= + + cpp/poppler-page-transition.cpp | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 807c1df2bf79c7c6378390b41dc230d80533ae3f +Author: Tom Gleason <tom@buildadam.com> +Date: Tue Apr 26 17:06:07 2011 +0100 + + bbox coordinates are relative to MediaBox size, not CropBox size + + utils/pdftotext.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 813f41367a681702ae7a155d5c2f3195124a9096 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Apr 3 20:40:15 2011 +0200 + + forms: fix mem leak in case of error + + poppler/Form.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 722baf8baf42e2c7a49e1560aae5235677d1ddee +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Apr 3 20:17:57 2011 +0200 + + forms: check form field is actually terminal before creating the + widget + + poppler/Form.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 5f6f7fc569d1c891956a3c37b3e328504635ab33 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 3 15:06:45 2011 +0100 + + Properly initialize pageObjectNum to 0 + + Bug 35925 + + poppler/Hints.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit d6786edc2549164214342a50782b72c2fd904b63 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Apr 3 13:11:18 2011 +0200 + + forms: Remove unused parameter + + poppler/Form.cc | 2 +- + poppler/Form.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 62692ff381f3b7907b330bfc2019416ed058ea46 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Apr 3 13:01:42 2011 +0200 + + forms: rework the way form fields tree is built + + Now we build the tree as described by the doc, without ignoring + container fields and always creating a child widget for composed + (field + + annot) dictionaries. The way check and radio buttons are set + has been + reworked too, since now it's possible to have a set of buttons where + children are not widgets, but form fields with a child widget. + + poppler/Annot.cc | 4 +- + poppler/Form.cc | 237 + +++++++++++++++++++++++++++++-------------------------- + poppler/Form.h | 17 ++-- + 3 files changed, 137 insertions(+), 121 deletions(-) + +commit a6802301d9c3ab8bf68bd8821f562f8ecced8491 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 28 17:42:37 2011 +0200 + + forms: Add debug methods to print the forms tree + + poppler/Form.cc | 78 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Form.h | 25 ++++++++++++++++++ + 2 files changed, 103 insertions(+) + +commit 46f87da04700cdd1afa634f9c554e376f6f6f752 +Author: José Aliste <jaliste@src.gnome.org> +Date: Thu Mar 31 08:09:41 2011 -0400 + + Fix a memleak in AnnotScreen::initialize + + poppler/Annot.cc | 1 + + 1 file changed, 1 insertion(+) + +commit b64178eaa5dd01f914649d6faa870fa140ddaf9b +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Mar 30 15:17:54 2011 +0200 + + glib: docs: Add PopplerActionJavascript to poppler-sections.txt + + glib/reference/poppler-sections.txt | 1 + + 1 file changed, 1 insertion(+) + +commit 3d777181ddee8f7ab2cc9e4684879cb5b52b065c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Mar 30 15:16:04 2011 +0200 + + glib: Use Javascript instead of JavaScript for consistency + + glib/poppler-action.h | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit c4774fecfe3d523f32d5980f50e31daa798c9692 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Mar 30 15:08:59 2011 +0200 + + glib-demo: show javascript actions in actions view + + glib/demo/utils.c | 25 +++++++++++++++++++++++++ + 1 file changed, 25 insertions(+) + +commit 68bbbe1a3f68d242b35027ae41f5751b02a2a700 +Author: José Aliste <jaliste@src.gnome.org> +Date: Tue Mar 29 04:56:37 2011 -0400 + + glib: add JavaScript actions + + glib/poppler-action.cc | 24 ++++++++++++++++++++++++ + glib/poppler-action.h | 14 +++++++++++++- + 2 files changed, 37 insertions(+), 1 deletion(-) + +commit 3dd934088a06f246718382601030c9b093d04160 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 30 00:03:58 2011 +0100 + + Need to create the globalParams + + qt4/tests/check_optcontent.cpp | 5 +++++ + 1 file changed, 5 insertions(+) + +commit ce0d4278a32b3ba19c2002ed0c481c58b1854d59 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 29 23:47:33 2011 +0100 + + Long gone + + Makefile.am | 2 -- + 1 file changed, 2 deletions(-) + +commit 12337026533aa59bb66022ce8a119f37aafd4fad +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 29 23:40:57 2011 +0100 + + increase sonames + + CMakeLists.txt | 2 +- + glib/CMakeLists.txt | 2 +- + glib/Makefile.am | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/CMakeLists.txt | 2 +- + qt4/src/Makefile.am | 2 +- + 6 files changed, 6 insertions(+), 6 deletions(-) + +commit a6e613b01698c6b38deff5248fcf7c0b17d041c3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 29 23:40:38 2011 +0100 + + more typos + + NEWS | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit e3ee037ede67212836be158b935deb7ea974b7f7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 29 23:38:24 2011 +0100 + + typo + + NEWS | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 8bcd94964f0af17a3f5b6edf71127df3daa00b1a +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 29 23:30:30 2011 +0100 + + typo + + NEWS | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit a05b9dacbe5dbd4337fdbb3e7d7d364ad5fbaeab +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 29 23:28:49 2011 +0100 + + 0.17.0 version number + + CMakeLists.txt | 2 +- + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +commit 4637b737b4735c70017b46a3ed6c0ee069c02c9b +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 29 23:28:41 2011 +0100 + + 0.17.0 news + + NEWS | 108 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 108 insertions(+) + +commit a55cc5d9c67ede1d96f6e5a58179ddd9f563c53f +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 29 22:51:40 2011 +0100 + + Update years + + poppler/Catalog.cc | 2 +- + poppler/Catalog.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit d96efb6c1af621be78e998ba1a228022c3c076fc +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 29 11:13:03 2011 +0200 + + fix comment + + poppler/ViewerPreferences.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 74ec81d66d4d5bc45cccc4aa8794df1c517f2d74 +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 29 11:07:36 2011 +0200 + + viewer preferences: read PrintScaling and Duplex + + poppler/ViewerPreferences.cc | 24 ++++++++++++++++++++++++ + poppler/ViewerPreferences.h | 14 ++++++++++++++ + 2 files changed, 38 insertions(+) + +commit b41bcd484dd7a93a339270926c57caa524059d8f +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 29 10:58:46 2011 +0200 + + free the viewerPreferences Object + + poppler/Catalog.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 1dd88d0b6b7cbfda76e81902a351c89457a061a8 +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 29 09:58:10 2011 +0200 + + read the ViewerPreferences dict once, and construct ViewerPreferences + on demand + + this way it is possible to know whether the ViewerPreferences + dictionary is present in the Catalog + + poppler/Catalog.cc | 24 +++++++++--------------- + poppler/Catalog.h | 3 ++- + 2 files changed, 11 insertions(+), 16 deletions(-) + +commit f10b0b8c88a7df83ada09f32b6cb6fd930fcb748 +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 29 09:57:46 2011 +0200 + + assume the prefDict is not null + + poppler/ViewerPreferences.cc | 4 ---- + 1 file changed, 4 deletions(-) + +commit d4a5ea45057cad531a8979cf9861ac05cdd56613 +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 29 09:54:22 2011 +0200 + + fix variable name for DisplayDocTitle + + poppler/ViewerPreferences.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit cf84a05ae524aa9b266463cc23cccc3860ff1ba3 +Author: Pino Toscano <pino@kde.org> +Date: Mon Mar 28 23:18:02 2011 +0200 + + viewer preferences: read NonFullScreenPageMode and Direction + + poppler/ViewerPreferences.cc | 26 ++++++++++++++++++++++++++ + poppler/ViewerPreferences.h | 15 +++++++++++++++ + 2 files changed, 41 insertions(+) + +commit 460253a6705a227ff7c36e9c31cceb93cce4d78b +Author: Pino Toscano <pino@kde.org> +Date: Mon Mar 28 22:37:54 2011 +0200 + + read some boolean viewer preferences + + - HideToolbar + - HideMenubar + - HideWindowUI + - FitWindow + - CenterWindow + - DisplayDocTitle + + poppler/ViewerPreferences.cc | 41 + +++++++++++++++++++++++++++++++++++++++++ + poppler/ViewerPreferences.h | 13 +++++++++++++ + 2 files changed, 54 insertions(+) + +commit 9fa9ac3546674120532bb512b82af6471cbebf01 +Author: Pino Toscano <pino@kde.org> +Date: Mon Mar 28 19:58:16 2011 +0200 + + add skeleton for ViewerPreferences + + a small class for handling the ViewerPreferences dictionary of + a Catalog, + created on demand and in any occasion (so defaults are in one + place only) + + CMakeLists.txt | 2 ++ + poppler/Catalog.cc | 23 +++++++++++++++++++++++ + poppler/Catalog.h | 4 ++++ + poppler/Makefile.am | 2 ++ + poppler/ViewerPreferences.cc | 30 ++++++++++++++++++++++++++++++ + poppler/ViewerPreferences.h | 34 ++++++++++++++++++++++++++++++++++ + 6 files changed, 95 insertions(+) + +commit c6081f0bf00d7dcdfa1d09e91e4c9a1fe5a54ad6 +Author: Pino Toscano <pino@kde.org> +Date: Mon Mar 28 19:55:00 2011 +0200 + + delete the temporary buffers created by pdfDocEncodingToUTF16() + + poppler/Form.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit d94d5056d5570e2f5cb578736eba12317ea63fa4 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 28 18:20:31 2011 +0200 + + glib-demo: show the activation action of form fields if there's one + + glib/demo/forms.c | 21 ++++++++++++++++----- + 1 file changed, 16 insertions(+), 5 deletions(-) + +commit ba0f36b76d0c2fd4ef39f3013fc125a53747c03f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 28 18:17:52 2011 +0200 + + glib: Add poppler_form_field_get_action() + + Fixes bug #33174. + + glib/poppler-form-field.cc | 34 + ++++++++++++++++++++++++++++++++++ + glib/poppler-form-field.h | 1 + + glib/poppler-private.h | 1 + + glib/reference/poppler-sections.txt | 1 + + 4 files changed, 37 insertions(+) + +commit ae5b9cf884ce38dde409c3e5b0f6c46f7d6327d2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 28 17:43:53 2011 +0200 + + Revert "Patch for embedding videos in to the pdf" + + This reverts commit 66575c990f379871e4b796befc899de178332670. + + It introduces new API to glib frontend that is wrong and will be + changed soon. + + glib/poppler-annot.cc | 33 ----- + glib/poppler-annot.h | 5 - + poppler/Annot.cc | 377 + -------------------------------------------------- + poppler/Annot.h | 2 - + 4 files changed, 417 deletions(-) + +commit b7edd4c93539585652961ecf2db9c4462415c8bc +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Mar 27 12:31:19 2011 +0200 + + annot: Always create appearance streams when NeedAppearances is true + + Fixes regression in document example_054.pdf + + poppler/Annot.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit e9350899e77c28452c48b56349ad7758b3fd47ba +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 24 20:09:18 2011 +0000 + + Introduce splash-friendly getRGBLine functions + + So it does not need to pack and unpack the color again and again + + poppler/GfxState.cc | 248 + ++++++++++++++++++++++++++++++++++++++++++--- + poppler/GfxState.h | 22 +++- + poppler/SplashOutputDev.cc | 43 ++------ + 3 files changed, 265 insertions(+), 48 deletions(-) + +commit 7b08795a9541e9fa01836b4c7fd63f6fe295ad80 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Mar 24 12:16:07 2011 +0100 + + glib: Add g_return macros to make sure index is correct in form + field choice methods + + glib/poppler-form-field.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit f1102fccd2899bc7f97414b1e2a295c59f03da22 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Mar 24 12:15:30 2011 +0100 + + glib-demo: Fix a crash when a choice form field has no items selected + + glib/demo/forms.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit b3971ee6bca6b14b75f046c831a31ac1e5e3241e +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 22 22:08:27 2011 +0000 + + kill this TODO, n is too small + + poppler/SplashOutputDev.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 1064d75817401fe24f728c189b450e9e906beb56 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 22 20:43:05 2011 +0000 + + kill unmaintained abiword backend + + CMakeLists.txt | 16 - + configure.ac | 16 - + poppler/ABWOutputDev.cc | 1179 + ----------------------------------------------- + poppler/ABWOutputDev.h | 141 ------ + poppler/Makefile.am | 17 - + utils/CMakeLists.txt | 10 - + utils/Makefile.am | 18 +- + utils/pdftoabw.cc | 201 -------- + 8 files changed, 2 insertions(+), 1596 deletions(-) + +commit abf167af8b15e5f3b510275ce619e6fdb42edd40 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Mon Mar 21 21:34:46 2011 +0000 + + Implement tiling/patterns in SplashOutputDev + + Fixes bug 13518 + + poppler/CairoOutputDev.cc | 5 +- + poppler/CairoOutputDev.h | 10 +- + poppler/Gfx.cc | 6 +- + poppler/OutputDev.h | 6 +- + poppler/PSOutputDev.cc | 8 +- + poppler/PSOutputDev.h | 6 +- + poppler/PreScanOutputDev.cc | 22 +++- + poppler/PreScanOutputDev.h | 16 ++- + poppler/SplashOutputDev.cc | 265 + ++++++++++++++++++++++++++++++++++++++++++++ + poppler/SplashOutputDev.h | 12 ++ + 10 files changed, 334 insertions(+), 22 deletions(-) + +commit 66575c990f379871e4b796befc899de178332670 +Author: Srinivas Adicherla <srinivas.adicherla@gmail.com> +Date: Thu Mar 17 20:14:05 2011 +0000 + + Patch for embedding videos in to the pdf + + glib/poppler-annot.cc | 33 +++++ + glib/poppler-annot.h | 5 + + poppler/Annot.cc | 377 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Annot.h | 2 + + 4 files changed, 417 insertions(+) + +commit ec1917968d2f1c7a00772a0829b3fcc6957d8f3c +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 14 00:13:26 2011 +0000 + + Only build gtk-test if we have to build gtk-test + + test/Makefile.am | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 1acbb01e72a22f70f00dc058ff206e3bc05bc0ab +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Mar 13 14:49:48 2011 +0000 + + (C) years + + poppler/CachedFile.cc | 2 +- + poppler/CurlCachedFile.cc | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit bc8aeb269aa92406081f749064ceff75bb3145e7 +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Mar 12 23:17:59 2011 +0100 + + Check response code of libcurl call + + poppler/CachedFile.cc | 8 +++++++- + poppler/CurlCachedFile.cc | 12 +++++++++--- + 2 files changed, 16 insertions(+), 4 deletions(-) + +commit 0268cedee5b460835a4747d0ea41bbe12269310d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Mar 12 15:24:30 2011 +0100 + + cairo: Fix typo + + poppler/CairoFontEngine.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5aa369e68e5c9f14efc888c7b26da06aa8bd2a78 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 12 13:47:34 2011 +0000 + + Remove unused variable + + poppler/CurlCachedFile.cc | 2 -- + 1 file changed, 2 deletions(-) + +commit c0dffbe28f91b30b36310ab0b9a9b948610550ae +Author: Pino Toscano <pino@kde.org> +Date: Sat Mar 12 12:15:58 2011 +0100 + + update copyright years + + cpp/poppler-document-private.h | 2 +- + cpp/poppler-document.cpp | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit b8fab173ffdd1e62a34b530228d08bc5ec6725ac +Author: Pino Toscano <pino@kde.org> +Date: Sat Mar 12 12:13:05 2011 +0100 + + [cpp] init the globalParams early in the document loading + + introduce a small RAII class to init/deinit the globalParams, and + make document_private inherit from it + + cpp/poppler-document-private.h | 17 +++++++++----- + cpp/poppler-document.cpp | 52 + +++++++++++++++++++++++------------------- + 2 files changed, 39 insertions(+), 30 deletions(-) + +commit a97a54cb22def2a9fc381fb81842dad9e5c3931f +Author: Pino Toscano <pino@kde.org> +Date: Sat Mar 12 12:12:11 2011 +0100 + + forms: delete tmp_str after being converted to GooString + + poppler/Form.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 9671fe07f8c9ade956742cb141b99518c3b12bad +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Mar 11 00:05:52 2011 +0000 + + getForm can return NULL, do not crash if that happens + + poppler/Annot.cc | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +commit bd32672899f5ca4509ec9311de8092d14bec8ab1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 10 23:33:15 2011 +0000 + + update copyright years + + poppler/Catalog.cc | 2 +- + qt4/src/poppler-form.cc | 1 + + 2 files changed, 2 insertions(+), 1 deletion(-) + +commit 841f3bbca37015ec2c58d7b85a73cef5681294f8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 10 23:30:51 2011 +0000 + + Do not infinite loop + + poppler/Form.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit f2fcafdc2b982d9bbed3c01bc7d45c8bd0603f19 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 10 23:27:41 2011 +0000 + + Create the globalParams before the pdfdoc + + qt4/src/poppler-private.cc | 5 +---- + qt4/src/poppler-private.h | 12 ++++++++---- + 2 files changed, 9 insertions(+), 8 deletions(-) + +commit f956b03604b195623ab034a06942a39547adf905 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 10 00:01:18 2011 +0000 + + compile + + qt4/src/poppler-form.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit f0ec3bedc5490aa35e54563019fcf2c3f8b7647d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Mar 9 20:54:15 2011 +0100 + + forms: Remove unused method FormWidget::updateField() + + poppler/Form.cc | 22 ---------------------- + poppler/Form.h | 2 -- + 2 files changed, 24 deletions(-) + +commit 93c25e100ae2564b9a866b95bed16d2fac619bd7 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Mar 9 20:49:32 2011 +0100 + + forms: Rename FormField::createActivationAction() to + FormField::getActivationAction() + + And use the existing action from the AnnotWidget instead of creating a + new one. + + poppler/Form.cc | 11 ++--------- + poppler/Form.h | 2 +- + qt4/src/poppler-form.cc | 3 +-- + 3 files changed, 4 insertions(+), 12 deletions(-) + +commit 59fb0489bfabfd8acccafdcd0361ce005664962a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Mar 9 20:19:24 2011 +0100 + + annots: Check whether we need to create an appearance stream in + AnnotWidget::draw() + + And never modify the AP entry since it breaks check and radio buttons + that doesn't have an appearance for the Off state. + + poppler/Annot.cc | 79 + ++++++++++---------------------------------------------- + poppler/Annot.h | 1 - + 2 files changed, 13 insertions(+), 67 deletions(-) + +commit f3b00ef51ceef6d9b7a1aa7e0f19249abf8ca6f3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Mar 9 18:19:12 2011 +0100 + + annots: Add Annot::setAppearanceState() and use it from FormWidget + + This method not only updates the current appearance state, but + also the + appearance stream corresponding to the new state. + + poppler/Annot.cc | 43 ++++++++++++++++++++++++++++++++++++------- + poppler/Annot.h | 2 ++ + poppler/Form.cc | 7 +++---- + 3 files changed, 41 insertions(+), 11 deletions(-) + +commit d59561212253302d4dcb23392bb8306b8e5c68d1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Mar 9 17:35:28 2011 +0100 + + forms: Make FormWidget use a real widget annotation instead of + duplicating code + + When creating annotations, if it's a widget annotation, look first + whether it has already been created by a FormWidget and reuse + it instead + of duplicating it. + + poppler/Annot.cc | 42 +++++++++++++-------- + poppler/Annot.h | 2 +- + poppler/Catalog.cc | 2 +- + poppler/Form.cc | 107 + +++++++++++++++++++++++++---------------------------- + poppler/Form.h | 23 ++++++------ + 5 files changed, 89 insertions(+), 87 deletions(-) + +commit 2dd7e1ba09d4501adf9d10ab4cb8ee003cace74a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Mar 9 10:25:00 2011 +0100 + + forms: Move modified flag from FormWidget to FormField + + poppler/Form.cc | 16 ++++++++-------- + poppler/Form.h | 6 ++++-- + 2 files changed, 12 insertions(+), 10 deletions(-) + +commit b04f03be7e43e309af5f164ef71788e7b8915841 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Mar 9 10:17:57 2011 +0100 + + forms: Move field names handling from FormWidget to FormField + + poppler/Form.cc | 149 + +++++++++++++++++++++++++++++++------------------------- + poppler/Form.h | 20 +++++--- + 2 files changed, 95 insertions(+), 74 deletions(-) + +commit abe1e0d5a37bcdb4376901306d3adccfb33ff3b4 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Mar 8 21:39:00 2011 +0100 + + annots: Make sure no border is drawn for invalid border arrays + + Fixes regression on ClassSchedule_2091_ENGL.pdf + + poppler/Annot.cc | 8 ++++++-- + poppler/Annot.h | 2 +- + 2 files changed, 7 insertions(+), 3 deletions(-) + +commit 14d145371e86ccb92f09b1ca750ced52171b2885 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Mar 8 20:14:57 2011 +0100 + + forms: Remove loadDefaults method + + Moving the code to initialize form field stuff to form field + constructors and widget stuff to form widget constructors. Clean up an + simplify the code. + + poppler/Form.cc | 227 + +++++++++++++++++++++----------------------------------- + poppler/Form.h | 21 ++---- + 2 files changed, 91 insertions(+), 157 deletions(-) + +commit 0585d7820455c93fe5b732b7a9a20d423df47075 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Mar 8 15:36:45 2011 +0100 + + forms: Handle field values (V entry) by field objects + + Rather than AnnotWidget or FormWidget, and use the form field object + from AnnotWidget to get the values. + + poppler/Annot.cc | 52 ++++---- + poppler/Form.cc | 400 + +++++++++++++++++++++++++++---------------------------- + poppler/Form.h | 21 +-- + 3 files changed, 230 insertions(+), 243 deletions(-) + +commit dc100eb9080fb58164fc94c86bfb1728cecd21c3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 7 20:14:27 2011 +0100 + + annots: Use the field object to get MaxLen instead of parsing the + field dict + + poppler/Annot.cc | 10 ++++------ + 1 file changed, 4 insertions(+), 6 deletions(-) + +commit 7149634f184dc3f07f2a70c296aac207ef24952c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 7 19:55:45 2011 +0100 + + forms: Parse the default resources dictionary in Form + + And use it in AnnotWidget instead of parsing the dictionary again. + + poppler/Annot.cc | 65 + ++++++++++++++++++++++---------------------------------- + poppler/Annot.h | 12 +++++------ + poppler/Form.cc | 16 ++++++++++++++ + poppler/Form.h | 5 +++++ + 4 files changed, 52 insertions(+), 46 deletions(-) + +commit 2e73f17975811177c0b3c16b8bd97c7eb912bc44 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 7 18:41:48 2011 +0100 + + forms: Parse field variable text entries (DA, Q) in FormField() + + And use them from AnnotWidget instead of parsing the field dictionary + again. + + poppler/Annot.cc | 28 +++++----------------------- + poppler/Form.cc | 17 +++++++++++++++++ + poppler/Form.h | 9 +++++++++ + 3 files changed, 31 insertions(+), 23 deletions(-) + +commit 8677a34911563a712b2dcf0b6e411cee0bad9c44 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 7 18:24:07 2011 +0100 + + forms: Parse default variable text entries (DA, Q) on Form + construction + + And use them from AnnotWidget instead of parsing the acroForm + dictionary + again. + + poppler/Annot.cc | 99 + +++++++++++++++++++++++++++----------------------------- + poppler/Form.cc | 11 +++++++ + poppler/Form.h | 12 +++++++ + 3 files changed, 70 insertions(+), 52 deletions(-) + +commit 41420bfd88685d9b1ac44dc7444ea3abee92097c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 7 09:18:25 2011 +0100 + + annots: Only parse the dash array for dashed borders + + poppler/Annot.cc | 16 +++++++++------- + 1 file changed, 9 insertions(+), 7 deletions(-) + +commit c198a3f83d8508ddaf84564871d9202ffba8096c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Mar 6 17:52:01 2011 +0100 + + annots: Use the field object to get the top index of a form field + choice + + Instead of parsing the field dictionary again. + + poppler/Annot.cc | 14 ++------------ + poppler/Annot.h | 1 - + 2 files changed, 2 insertions(+), 13 deletions(-) + +commit 5cf803ec181dbf1112f67b4f4a9c77b88d102e3b +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Mar 6 17:47:18 2011 +0100 + + forms: Add FormFieldChoice::getTopIndex() + + poppler/Form.cc | 5 +++++ + poppler/Form.h | 5 ++++- + 2 files changed, 9 insertions(+), 1 deletion(-) + +commit 1248f59e2045749ece1f5a5e579b866b8330a752 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Mar 6 17:41:33 2011 +0100 + + annots: Draw widget background using the existing appearance + characteristics + + Instead of parsing the appearance characteristics dictionary again + + poppler/Annot.cc | 23 +++++++---------------- + 1 file changed, 7 insertions(+), 16 deletions(-) + +commit dc249ad4529997001ae1f96dcfd7351766ca8e8d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Mar 6 17:34:33 2011 +0100 + + annots: Factor out generateFieldAppearance() + + Adding methods to render every form field type and using the field + object when possible instead of parsing the field dictionary again. + + poppler/Annot.cc | 312 + +++++++++++++++++++++++-------------------------------- + poppler/Annot.h | 8 +- + 2 files changed, 138 insertions(+), 182 deletions(-) + +commit f98b3540db731026e0febf1f010548f0f0ef9142 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Mar 6 15:57:22 2011 +0100 + + annots: Move code to draw the border of an AnnotWidget to a new method + + And use the field object instead of parsing the field dictionary + again. + + poppler/Annot.cc | 242 + +++++++++++++++++++++++++++---------------------------- + poppler/Annot.h | 3 + + 2 files changed, 124 insertions(+), 121 deletions(-) + +commit 9854f3173f994bbe3f57d33bd1d0e045833859c2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Mar 6 15:56:06 2011 +0100 + + annots: Add AnnotColor::adjustColor() to be able to adjust an + existing AnnotColor + + poppler/Annot.cc | 7 +++++++ + poppler/Annot.h | 2 ++ + 2 files changed, 9 insertions(+) + +commit 2bf82f27bd9c8f97e5484ea97be661f65221163d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Mar 5 15:30:01 2011 +0100 + + annots: Remove unused class AnnotBorderStyle + + poppler/Annot.cc | 22 ---------------------- + poppler/Annot.h | 36 ------------------------------------ + 2 files changed, 58 deletions(-) + +commit 128dcaf282f418d8c45cea4df6ad4d3167b3e39c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Mar 5 13:12:49 2011 +0100 + + annots: Add AnnotBorder::parseDashArray() to parse dash arrays + + The code was duplicated in AnnotBorderArray and AnnotBorderBS + + poppler/Annot.cc | 91 + +++++++++++++++++++------------------------------------- + poppler/Annot.h | 4 ++- + 2 files changed, 34 insertions(+), 61 deletions(-) + +commit ec2643d311e0ce55f0ff5309c0c420140d053a50 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 1 19:50:55 2011 +0000 + + fix copyright years + + poppler/Annot.cc | 2 +- + poppler/Annot.h | 2 +- + poppler/ArthurOutputDev.cc | 2 +- + poppler/ArthurOutputDev.h | 2 +- + poppler/FontInfo.cc | 1 + + poppler/Form.cc | 4 ++-- + poppler/Form.h | 3 ++- + poppler/GlobalParams.cc | 1 + + poppler/GlobalParams.h | 1 + + poppler/Link.cc | 2 +- + poppler/Link.h | 2 +- + poppler/OutputDev.h | 2 +- + poppler/PDFDoc.cc | 2 +- + poppler/Page.cc | 2 +- + poppler/Page.h | 2 +- + poppler/TextOutputDev.cc | 2 +- + poppler/TextOutputDev.h | 2 +- + qt4/src/poppler-form.cc | 2 +- + qt4/src/poppler-link-extractor-private.h | 2 +- + qt4/src/poppler-link-extractor.cc | 2 +- + qt4/src/poppler-page.cc | 2 +- + qt4/src/poppler-private.h | 2 +- + utils/HtmlOutputDev.cc | 2 +- + utils/HtmlOutputDev.h | 4 ++-- + 24 files changed, 27 insertions(+), 23 deletions(-) + +commit 900974ebfbe6ab7ae21ed151ff79f9578d2bdae2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 1 19:42:22 2011 +0000 + + Fix years + + poppler/poppler-config.h.cmake | 2 +- + poppler/poppler-config.h.in | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit c804db4d8261274b013f8c340abfc921c77bb3cf +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 1 19:22:31 2011 +0100 + + move the fontconfig.h inclusion from GlobalParams.h to GlobalParams.cc + + this avoids a dependency on the fontconfig headers to the users of + the core + + poppler/GlobalParams.cc | 4 ++++ + poppler/GlobalParams.h | 3 --- + 2 files changed, 4 insertions(+), 3 deletions(-) + +commit 2d77c7f9c41f1121354413bcdc3beded35a247f9 +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 1 16:51:04 2011 +0100 + + create the GooString on stack, not in heap + + poppler/Annot.cc | 5 ++--- + poppler/Form.cc | 5 ++--- + 2 files changed, 4 insertions(+), 6 deletions(-) + +commit 5dc2ef0e27ac48c81739cdfe8e8070ebbc410c87 +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 1 16:39:36 2011 +0100 + + annots: avoid temporary GooString's just for comparisons, just + use strcmp + + other than reducing few GooString allocations, strcmp should be much + faster than GooString::cmp + + poppler/Annot.cc | 128 + ++++++++++++++++++++++++------------------------------- + 1 file changed, 56 insertions(+), 72 deletions(-) + +commit 535e48ab764ee4e377451ddd032044b51b842c4a +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 1 16:07:34 2011 +0100 + + [qt4] ignore "Widget" annotations + + they usually are forms or something else we do not support, so do + not complain about them for now + + qt4/src/poppler-page.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit f0e5c36e7f1c5d0f0f51e3a6a6acd6c423f86df7 +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 1 16:02:54 2011 +0100 + + annots: avoid a temporary GooString just for comparisons, just + use strcmp + + other than reducing few GooString allocations, strcmp should be much + faster than GooString::cmp + + poppler/Annot.cc | 54 + ++++++++++++++++++++++++++---------------------------- + 1 file changed, 26 insertions(+), 28 deletions(-) + +commit 58a3b83a8fbd8b13eb98c4f677f4ed19b6ae44cd +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 1 15:35:45 2011 +0100 + + fix appendAnnot() invocation on annotations reading + + 1) check that the annot is actually a non-NULL pointer (otherwise + doing anything else is pointless) + 2) call appendAnnot() only if the annotation isOk() (that will + increase the annot refcount), but always decrement the refcount + (so valid annotation will have it at 1, while invalid will be deleted) + + poppler/Annot.cc | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +commit 664865a2ddca9c20ac36a41aef52ebf12eab838d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Mar 1 10:56:40 2011 +0100 + + Merge Link and AnnotLink code + + Annotations now belong to the Page and are created only once on + demand. + Annots are now ref counted and Links is a list of AnnotLink objects, + Link object has been removed. The AnnotLink API is mostly the + same than + Link and frontends APIs are not affected. + Qt4 changes made by Pino Toscano. + + glib/poppler-document.cc | 2 +- + glib/poppler-page.cc | 29 ++++---- + glib/poppler-private.h | 1 - + poppler/Annot.cc | 79 +++++++++++++------- + poppler/Annot.h | 24 ++++-- + poppler/ArthurOutputDev.cc | 4 - + poppler/ArthurOutputDev.h | 3 - + poppler/CairoOutputDev.cc | 3 - + poppler/CairoOutputDev.h | 6 -- + poppler/FontInfo.cc | 4 +- + poppler/Form.cc | 36 ++++----- + poppler/Form.h | 5 +- + poppler/Link.cc | 124 + +++++-------------------------- + poppler/Link.h | 43 ++--------- + poppler/OutputDev.h | 4 +- + poppler/PDFDoc.cc | 4 +- + poppler/Page.cc | 63 ++++++++-------- + poppler/Page.h | 11 +-- + poppler/TextOutputDev.cc | 9 ++- + poppler/TextOutputDev.h | 10 +-- + qt4/src/poppler-link-extractor-private.h | 2 +- + qt4/src/poppler-link-extractor.cc | 3 +- + qt4/src/poppler-page.cc | 12 ++- + utils/HtmlOutputDev.cc | 7 +- + utils/HtmlOutputDev.h | 4 +- + 25 files changed, 188 insertions(+), 304 deletions(-) + +commit 1f6573e949aaba0eb0a4c2f9cd73d7ad45ba67be +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 27 21:53:32 2011 +0100 + + small fixes to the pdftohtml manpage + + - capitalize HTML, PDF, XML, PNG + - dont -> do not + - fix UTF-8 character + - fix hypens used as minus + + utils/pdftohtml.1 | 18 +++++++++--------- + 1 file changed, 9 insertions(+), 9 deletions(-) + +commit e927384897595f1bda5f7e41b552602f9cc8ed95 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 27 16:39:59 2011 +0100 + + [qt4] fix caption of push button fields + + instead of asking the 'onStr' of the underlying form widget, + take (if available) the 'MK' entry, i.e. the appearance + characteristics dictionary, + and use the normal caption of that + + qt4/src/poppler-form.cc | 25 +++++++++++++++++++++++-- + 1 file changed, 23 insertions(+), 2 deletions(-) + +commit 5b24ee2c934feea1b7d46c8ec423d1c547258be2 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 27 16:24:22 2011 +0100 + + annots: 'CA', 'RC' and 'AC' are strings, not names + + poppler/Annot.cc | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +commit e64f6cb23e9a564b3f80daea9abcfe8bb29189eb +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 27 15:22:32 2011 +0100 + + make getOnStr() return the GooString* instead of its char* + + ... and modify its use accordingly + this way it is easier to check for a numm onStr, without the risk + of dereferencing a NULL pointer + + poppler/Form.cc | 6 +++--- + poppler/Form.h | 2 +- + qt4/src/poppler-form.cc | 7 ++----- + 3 files changed, 6 insertions(+), 9 deletions(-) + +commit f9c978fc2ab8a1f901f2136ae95deb9d41076155 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 27 14:39:52 2011 +0100 + + [qt4] directly use the dict + + qt4/src/poppler-form.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 071966e48577c515b17a424baeae85ae4fc80a20 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 27 14:21:11 2011 +0100 + + [qt4] move textAlignment() as a private function + + qt4/src/poppler-form.cc | 33 +++++++++++++++++++++++++++++++-- + qt4/src/poppler-private.h | 25 ------------------------- + 2 files changed, 31 insertions(+), 27 deletions(-) + +commit adc236771f11eeb4197064747836e8ed3fbfeba9 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 27 14:13:50 2011 +0100 + + [qt4] use FormWidget::getAlternateUiName() + + ... instead of read the value on our own + + qt4/src/poppler-form.cc | 9 ++------- + 1 file changed, 2 insertions(+), 7 deletions(-) + +commit 9f111483cf6196dedf3cee380c3e5224776203ea +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 27 14:12:16 2011 +0100 + + forms: read the TU field as alternateUiName + + poppler/Form.cc | 8 ++++++++ + poppler/Form.h | 2 ++ + 2 files changed, 10 insertions(+) + +commit cfaadaa9e4a857fcea3b5a2cadacd352de6c469d +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 27 14:07:35 2011 +0100 + + [qt4] use FormWidget::getPartialName() + + ... instead of read the value on our own + + qt4/src/poppler-form.cc | 9 ++------- + 1 file changed, 2 insertions(+), 7 deletions(-) + +commit 2478896a0c1f6e5842f3d8b172e4cc7e6bd58cd8 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 27 13:24:09 2011 +0100 + + [qt4] use the new FormWidget::createActivationAction() + + qt4/src/poppler-form.cc | 13 +++---------- + 1 file changed, 3 insertions(+), 10 deletions(-) + +commit 1dcb683a5c2dd6a1de654e90a4394f65d63dc296 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 27 13:22:48 2011 +0100 + + add FormWidget::createActivationAction() + + used to get and create a new activation action object of a form widget + + poppler/Form.cc | 12 ++++++++++++ + poppler/Form.h | 3 +++ + 2 files changed, 15 insertions(+) + +commit bd4cc73e438a7d4d4a10c50c69e65b5bdc63ddf2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 27 11:04:45 2011 +0000 + + Some more missing copyrights + + poppler/CairoOutputDev.cc | 2 +- + poppler/CairoOutputDev.h | 2 +- + poppler/Gfx.cc | 2 +- + poppler/OutputDev.h | 2 +- + poppler/TextOutputDev.cc | 1 + + 5 files changed, 5 insertions(+), 4 deletions(-) + +commit 6c2ed4781d8ecfffdf24e1459aafd554b3527686 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 27 10:55:22 2011 +0000 + + Add 2011 years + + poppler/Annot.cc | 2 +- + poppler/CairoFontEngine.cc | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit b297fb9de0779ac84d5b7ef68c792afefe598320 +Author: William Bader <williambader@hotmail.com> +Date: Sun Feb 27 01:48:55 2011 +0000 + + access the pixels directly + + Faster, bug 34005 + + splash/Splash.cc | 21 +++++++++++---------- + 1 file changed, 11 insertions(+), 10 deletions(-) + +commit de77e26759f1c33698abe248ad29b75c329a043c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 27 01:39:23 2011 +0000 + + Fix crash in some pdf + + Has to be 3 and not nComps since it's a output buffer, a the input one + Bug 34357 + + poppler/GfxState.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 4f82a2e08cb2c930956c6b38030fa7b015a0de5a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 27 01:38:33 2011 +0000 + + Implement GfxDeviceCMYKColorSpace::getRGBLine + + poppler/GfxState.cc | 22 +++++++++++++++++++++- + poppler/GfxState.h | 12 +++++++++++- + 2 files changed, 32 insertions(+), 2 deletions(-) + +commit 4980b99214281dcab8f82b5b618aadc24de371f4 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Feb 26 14:00:33 2011 +0100 + + annots: Don't assume y1 > y3 for quad points of a highlight annotation + + Fixes https://bugzilla.gnome.org/show_bug.cgi?id=643028 + + poppler/Annot.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e6ae0f8609cd66e9e124af59adefdff9d610dcd4 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Feb 26 13:23:47 2011 +0100 + + cairo: Handle font type fontCIDType2OT when creating freetype font + + Fixes https://bugzilla.gnome.org/show_bug.cgi?id=643273 + + poppler/CairoFontEngine.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 22eb01d305ea2560d26417ca8df9c0465d4e9a82 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Feb 26 12:17:49 2011 +0100 + + cairo: Fix a crash when rendering a document with inline images + + poppler/CairoOutputDev.cc | 28 ++++++++++++++++------------ + poppler/CairoOutputDev.h | 2 +- + 2 files changed, 17 insertions(+), 13 deletions(-) + +commit a6599dd1fda37186b876b5b2de80be1731dd5946 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Feb 26 11:59:03 2011 +0100 + + glib: Add some more introspection annotations + + glib/poppler-attachment.cc | 2 +- + glib/poppler-document.cc | 4 ++-- + glib/poppler-media.cc | 2 +- + glib/poppler-page.cc | 6 +++--- + 4 files changed, 7 insertions(+), 7 deletions(-) + +commit 89c66f236c85ac5a53ae12b01cdebc30e27b78d3 +Author: Peter Ward <peteraward@gmail.com> +Date: Sat Feb 26 11:39:58 2011 +0100 + + glib: Add missing "out" annotation to poppler_page_get_size() + + glib/poppler-page.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 7a68199b342eb3f33733f7d7446ede8f94130fba +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Feb 26 11:09:27 2011 +0100 + + cairo: Check if cairo version is == 1.11.2 to use mesh gradients api + + Cairo API has changed in 1.11.3. + + poppler/CairoOutputDev.cc | 4 ++-- + poppler/CairoOutputDev.h | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +commit 97e7ab1a4eea2160f3f0847d10f6c16f2d66ef11 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Feb 25 20:33:39 2011 +0000 + + Do not ask freetype for a font of size 0x0 + + Fixes rendering bug at 34602 + + splash/SplashFTFont.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 3590a2d38082fc705040cdb31bf0b22ff12dd3e4 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu Feb 24 18:47:35 2011 +0000 + + Fix rendering of some substituted fonts + + More info in bug 34522 + + poppler/GfxFont.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 384753f1f9f780687bdead99a6548ef8598b898a +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Feb 21 19:19:48 2011 +0000 + + Use gfree since we allocate with gmalloc + + Bug 34512 + + goo/GooString.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit d775420c3c6cb5a29ff74712d3fc210fcb4b4627 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 19 11:19:57 2011 +0000 + + Do not delete textOut twice when using -bbox + + utils/pdftotext.cc | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit e1a56d73b066e7152ccf6ccf36206def7956cb00 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 16 00:06:45 2011 +0000 + + Lots of rendering improvements by Thomas and Andrea + + Function.cc: Stitching functions incorrectly reported 0 as output + size. + Function.cc: Remove cache from PostScriptFunction + Function.cc: Make PSStack stack allocated + GfxState.cc & GfxState.h: Abstract GfxSimpleShading, add Matrix::norm + method, add simple caching, parameter range computation + SplashOutputDev.cc & SplashOutputDev..h & Splash.cc & SplashPattern.h: + Improve splash rendering, implement radial and abstract simple + shadings + in splash + + And maybe something more, look at the + Followup Bug 32349 & Poppler: More shading fun ;-) + thread for more info + + poppler/Function.cc | 122 +-------- + poppler/Function.h | 3 +- + poppler/GfxState.cc | 634 + +++++++++++++++++++++++++++++++++++++++------ + poppler/GfxState.h | 90 +++++-- + poppler/SplashOutputDev.cc | 253 +++++++++++++++--- + poppler/SplashOutputDev.h | 67 ++++- + splash/Splash.cc | 126 ++++++--- + splash/SplashPattern.h | 7 +- + 8 files changed, 1006 insertions(+), 296 deletions(-) + +commit 675b3505f963a0110dac7f865654232cbb865ef5 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Feb 13 16:21:52 2011 +0100 + + tests: Merge splash and cairo tests into a single gtk-test tool + + With a command line option to use cairo or splash backends. + + test/CMakeLists.txt | 20 +-- + test/Makefile.am | 29 ++-- + test/gtk-cairo-test.cc | 190 ----------------------- + test/gtk-splash-test.cc | 311 ------------------------------------- + test/gtk-test.cc | 397 + ++++++++++++++++++++++++++++++++++++++++++++++++ + 5 files changed, 412 insertions(+), 535 deletions(-) + +commit 728c022cdc1ea12aa54077d44276f9d7714930d4 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 13 13:25:51 2011 +0100 + + remove more references to the qt3 frontend + + followup of d82f98a274bfa008c218e265a080c4af7ce95131 + + Makefile.am | 3 --- + 1 file changed, 3 deletions(-) + +commit 15e5b3f16015361754fdc14da4a0dde5af887568 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 13 13:23:06 2011 +0100 + + remove more GDK-related stuff + + followup of 149b7fec472beda9d1538e0f26607c9498d504c2 + + Makefile.am | 1 - + cmake/modules/FindGDK.cmake | 22 ---------------------- + config.h.cmake | 3 --- + glib/reference/Makefile.am | 1 - + glib/reference/poppler-sections.txt | 1 - + 5 files changed, 28 deletions(-) + +commit 50aa15a0bd7100fc9b9243de1d6e6f4b59df1488 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 13 13:07:19 2011 +0100 + + remove GDK API here too + + followup of 149b7fec472beda9d1538e0f26607c9498d504c2 + + glib/poppler-features.h.cmake | 1 - + 1 file changed, 1 deletion(-) + +commit f410cd11268254b9d0422201c9860d775f73fdd8 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Feb 13 12:55:37 2011 +0100 + + gtk-splash-test: Don't use GDK deprecated API + + test/gtk-splash-test.cc | 28 +++++++++++++++------------- + 1 file changed, 15 insertions(+), 13 deletions(-) + +commit a0568e449061d6b6af5485e340cd6f9d3e54ef7c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Feb 13 12:27:22 2011 +0100 + + glib: remove gdk referenes from pkg-config files + + poppler-glib-uninstalled.pc.in | 2 +- + poppler-glib.pc.cmake | 2 +- + poppler-glib.pc.in | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +commit 149b7fec472beda9d1538e0f26607c9498d504c2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Feb 13 11:51:57 2011 +0100 + + glib: Remove deprecated GDK API + + It removes the GDK dependency so that poppler-glib now only depends on + glib and cairo. + + CMakeLists.txt | 9 -- + configure.ac | 44 +------ + glib/CMakeLists.txt | 14 +-- + glib/Makefile.am | 8 +- + glib/poppler-features.h.in | 6 - + glib/poppler-page.cc | 296 + --------------------------------------------- + glib/poppler-page.h | 34 ------ + 7 files changed, 4 insertions(+), 407 deletions(-) + +commit a5482d64472a81206dd8d0c5bb80007f6d5bb893 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Feb 13 11:40:23 2011 +0100 + + glib: Remove test-poppler-glib, poppler-glib-demo does the same + and more + + glib/CMakeLists.txt | 8 - + glib/Makefile.am | 14 - + glib/test-poppler-glib.cc | 657 + ---------------------------------------------- + 3 files changed, 679 deletions(-) + +commit cab0cf028a192772dcb5c3f4aefa0a421e73e9e7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Feb 11 19:42:34 2011 +0000 + + Do not infinite loop in some broken files + + poppler/JBIG2Stream.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 1125cc8ccf386d8e0a0679aa73614bc2cb8037b0 +Author: William Bader <williambader@hotmail.com> +Date: Tue Feb 8 20:27:16 2011 +0000 + + Allow setting the rasterization resolution + + More info at bug 34001 + + poppler/GlobalParams.cc | 15 +++++++++++++++ + poppler/GlobalParams.h | 3 +++ + poppler/PSOutputDev.cc | 7 ++++++- + utils/pdftops.1 | 6 ++++++ + utils/pdftops.cc | 6 ++++++ + 5 files changed, 36 insertions(+), 1 deletion(-) + +commit 96e169b0eca31891f3cd564365d4a2a5c6e2a2c0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 8 19:58:31 2011 +0000 + + Make really sure the uMap static pointer is valid + + It might happen you are extremely unlucky and get the same + globalParams after a new delete/creation + + qt4/src/poppler-private.cc | 51 + +++++++++++++++++++++++++++++++++++++++------- + qt4/src/poppler-private.h | 34 +++---------------------------- + 2 files changed, 47 insertions(+), 38 deletions(-) + +commit c3470145f95791167c19a438934a923eab8a93cf +Author: William Bader <williambader@hotmail.com> +Date: Tue Feb 8 19:54:48 2011 +0000 + + Add PS level1 non standard binary output option + + More info at bug 34003 + + poppler/GlobalParams.cc | 18 +++- + poppler/GlobalParams.h | 5 +- + poppler/PSOutputDev.cc | 227 + ++++++++++++++++++++++++++++++++++-------------- + utils/pdftops.1 | 7 ++ + utils/pdftops.cc | 8 +- + 5 files changed, 198 insertions(+), 67 deletions(-) + +commit 37077aa475d2dee81f87daa05297b201eeb99c87 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Feb 7 19:48:28 2011 +0000 + + Make sure tx is inside the bitmap + + Seems to be what the code tried to do, fixes crash in bug 33948 + depending on + the resolution you render it + + poppler/SplashOutputDev.cc | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +commit 5aa854f70c8f563efe56dafa8bd6b3cdd5c95451 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Feb 6 13:24:35 2011 +0100 + + cairo: Use the new cairo unique id to set the surface id when printing + + Set the unique surface id when attaching jpeg images to the surface so + that cairo can reuse the mime data even when a new surface is created + with the same mime data. This reduces the size of the output file when + printing. + + poppler/CairoOutputDev.cc | 18 ++++++++++++++++-- + poppler/CairoOutputDev.h | 2 +- + 2 files changed, 17 insertions(+), 3 deletions(-) + +commit fe7b8aa4fc78aacf3226d019db74146ceaebd63c +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 2 22:35:40 2011 +0000 + + Workaround bug when converting pdf to ps with level1 + + See bug 31926 for more info + + poppler/PSOutputDev.cc | 2 +- + poppler/PreScanOutputDev.cc | 7 +++++++ + poppler/PreScanOutputDev.h | 7 +++++++ + 3 files changed, 15 insertions(+), 1 deletion(-) + +commit 5984ad081cd609f3146e0da5e22097ef073eb519 +Author: William Bader <williambader@hotmail.com> +Date: Sun Jan 30 17:02:02 2011 +0000 + + Increase precision + + Fixes some issues with pdf from bug 27482 + + poppler/PSOutputDev.cc | 200 + ++++++++++++++++++++++++------------------------- + 1 file changed, 100 insertions(+), 100 deletions(-) + +commit c60d5afbeb986c1b335357202c5f551a3c146a76 +Author: Jim Meyering <meyering@redhat.com> +Date: Mon Jan 24 15:51:20 2011 +0100 + + demo: don't use an uninitialized local variable + + * text.c (pgd_text_get_text): Before this change, when + poppler_page_get_text returned NULL, we'd use "n_recs" uninitialized. + + glib/demo/text.c | 1 + + 1 file changed, 1 insertion(+) + +commit a3bdc56e2f086444419eddfcda5d2010a9a6b5c0 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jan 29 11:23:33 2011 +0100 + + glib-demo: Add a tooltip with current selected character in text demo + + To make sure that the offset of the text returned by + poppler_page_get_text() matches + the list of rectangles returned by poppler_page_get_text_layout(). + + glib/demo/text.c | 60 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 60 insertions(+) + +commit bf2d86c8db430595fb3c55edd3f6c8d289bdaeb5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jan 28 20:34:08 2011 +0000 + + Make sure uMap is still valid before using it + + Fixes KDE bug 264667 + + qt4/src/poppler-private.cc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit e6fb20d7b3bf8ea8aedc1bcd910e035059835b5f +Author: Axel Strübing <axel.struebing@freenet.de> +Date: Fri Jan 28 19:20:15 2011 +0000 + + Extract text of a pdf correctly + + See "[poppler] text extraction does not work" in the mailing list + for more info + + poppler/GfxFont.cc | 14 +++++++++++++- + poppler/GfxFont.h | 2 ++ + 2 files changed, 15 insertions(+), 1 deletion(-) + +commit 4829d36a3b005585db8c8115f7ee81a4e2384780 +Author: Simon Kellner <kellner@kit.edu> +Date: Wed Jan 26 22:59:49 2011 +0000 + + fix labelToIndex on multiple prefixes + + A PDF document can use page label prefixes, for example, to label + only inside a chapter ("A-1" .. "A-<n>", "B-1" .. "B-<m>" et cetera). + When calculating a page index for a given label, poppler would + disregard the page range for all preceding prefixes that do not + match the given prefix. + + poppler/PageLabelInfo.cc | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +commit e57c75fbd95ef8399b0785500f6893465bc808c3 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Jan 24 19:48:09 2011 +1030 + + cairo: Implement Type 4,5,6,7 shadings using cairo mesh gradients + + Fixes bugs #19076 and #32791. + + poppler/CairoOutputDev.cc | 139 + ++++++++++++++++++++++++++++++++++++++++++++++ + poppler/CairoOutputDev.h | 12 ++++ + poppler/Gfx.cc | 10 +++- + poppler/OutputDev.h | 2 + + 4 files changed, 161 insertions(+), 2 deletions(-) + +commit 5081356fcc69012e9df95dbf1e3c36e7c1e751c4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jan 25 20:26:25 2011 +0000 + + Fix leak in SplashOutputDev::axialShadedFill + + poppler/SplashOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 19dc283c3af597deab297341a37495c06988948b +Author: Thomas Klausner <wiz@danbala.tuwien.ac.at> +Date: Mon Jan 24 19:05:08 2011 +0000 + + Include zlib header since we use things defined there + + goo/PNGWriter.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 5056e33e01ce0f7db1a5401b7b38d30e84eedf69 +Author: Sam Liao <phyomh@gmail.com> +Date: Mon Jan 17 13:07:22 2011 +0800 + + Poppler: Fix line selection, dont check y for Line selection + + When a line is selected while the Y values of selection is + not in the y range of words, the render will render the + line with reverse color while the words does not show up. + + This fix neglect the Y vaules to make sure that the words + also displayed when line is selected. + + poppler/TextOutputDev.cc | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +commit 88812e716c1a0c87a504118d47eb4cc6f52962fa +Author: Andreas Hartmetz <ahartmetz@gmail.com> +Date: Fri Jan 21 23:33:47 2011 +0000 + + Add Hinting API to ArthurOutputDev + + poppler/ArthurOutputDev.cc | 11 +++++++++-- + poppler/ArthurOutputDev.h | 15 ++++++++++++++- + 2 files changed, 23 insertions(+), 3 deletions(-) + +commit dc5ec4668bdfe3b6ba41f0a2e551bbc07f8839ba +Author: Andreas Hartmetz <ahartmetz@gmail.com> +Date: Fri Jan 21 23:32:50 2011 +0000 + + support slight hinting in Splash backend + + cpp/poppler-page-renderer.cpp | 2 +- + poppler/SplashOutputDev.cc | 6 +++++- + poppler/SplashOutputDev.h | 4 +++- + qt4/src/poppler-private.h | 3 ++- + qt4/src/poppler-qt4.h | 4 +++- + splash/SplashFTFont.cc | 27 ++++++++++++++++++--------- + splash/SplashFTFont.h | 2 ++ + splash/SplashFTFontEngine.cc | 10 +++++++--- + splash/SplashFTFontEngine.h | 6 ++++-- + splash/SplashFontEngine.cc | 4 +++- + splash/SplashFontEngine.h | 2 ++ + 11 files changed, 50 insertions(+), 20 deletions(-) + +commit 0c5b1bef9f3f98001cee20061b1eaf20b965c5a9 +Author: William Bader <williambader@hotmail.com> +Date: Fri Jan 21 19:01:45 2011 +0000 + + Fix rendering for some pdf with -level1sep + + Also some speed improvemensts. Bug #32365 + + poppler/PSOutputDev.cc | 207 + ++++++++++++++++++++++++++++++++++++++----------- + poppler/PSOutputDev.h | 13 +++- + 2 files changed, 170 insertions(+), 50 deletions(-) + +commit 6cb8965fb8bce6da2a4460e86f592c1ea3a84a5c +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jan 21 18:43:21 2011 +0000 + + fix (C) years + + poppler/CairoOutputDev.cc | 2 +- + poppler/CairoOutputDev.h | 2 +- + qt4/src/poppler-private.cc | 2 +- + qt4/tests/check_strings.cpp | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +commit 24f9c8924b2135da616386d0fa691fe790b4e7a4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jan 21 08:43:34 2011 +0000 + + Access the correct variable + + Fixes asert on bug 33063 + + poppler/Annot.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 07a8808c22445c421f3064da7e5227dcbf40358b +Author: Pino Toscano <pino@kde.org> +Date: Mon Jan 17 21:34:23 2011 +0100 + + fix unicodeToQString() to correctly decode the Unicode sequence + + Use a UnicodeMap to convert the sequence to UTF-8, and convert from + that to QString. + Also, ignore the last character of the Unicode sequence if it is 0x0. + + Add a couple of testcases for it. + + qt4/src/poppler-private.cc | 30 ++++++++++++++++++++++++------ + qt4/tests/check_strings.cpp | 21 +++++++++++++++++++++ + 2 files changed, 45 insertions(+), 6 deletions(-) + +commit ed367c08d788c88c49de770019bf826cfebb3e2c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 16 17:25:02 2011 +0000 + + Don't need this either + + configure.ac | 1 - + 1 file changed, 1 deletion(-) + +commit 76ab657dc81ed0af7d9f2efaca2e68d570063001 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 16 17:22:56 2011 +0000 + + And this is the last bit of qt3 cleaning? + + configure.ac | 1 - + 1 file changed, 1 deletion(-) + +commit 9a02856c2762e65b8f03e443e728e05e5a86f65b +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 16 17:21:00 2011 +0000 + + Another qt3 unused file + + m4/qt.m4 | 16 ---------------- + 1 file changed, 16 deletions(-) + +commit 26da7a52d31eb677ab6399de2c07140aa272b35e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 16 17:17:59 2011 +0000 + + Yet more qt3 cleaning + + configure.ac | 2 -- + 1 file changed, 2 deletions(-) + +commit 8dc9c693abb0033247a338d0f7d1f3f7a57c1a55 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 16 17:14:34 2011 +0000 + + Some more qt3 thigs i forgot to kill + + CMakeLists.txt | 5 - + Makefile.am | 1 - + cmake/modules/FindQt3.cmake | 319 + -------------------------------------------- + 3 files changed, 325 deletions(-) + +commit d82f98a274bfa008c218e265a080c4af7ce95131 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 16 17:13:06 2011 +0000 + + Kill qt3 frontend + + CMakeLists.txt | 5 - + Makefile.am | 5 - + configure.ac | 18 -- + poppler-qt-uninstalled.pc.in | 7 - + poppler-qt.pc.cmake | 13 -- + poppler-qt.pc.in | 13 -- + qt/.gitignore | 7 - + qt/CMakeLists.txt | 34 ---- + qt/Makefile.am | 48 ----- + qt/poppler-document.cc | 344 + --------------------------------- + qt/poppler-fontinfo.cc | 83 -------- + qt/poppler-link-qt3.h | 188 ------------------ + qt/poppler-link.cc | 267 -------------------------- + qt/poppler-page-transition-private.h | 28 --- + qt/poppler-page-transition.cc | 95 ---------- + qt/poppler-page-transition.h | 146 -------------- + qt/poppler-page.cc | 357 + ----------------------------------- + qt/poppler-private.cc | 147 --------------- + qt/poppler-private.h | 102 ---------- + qt/poppler-qt.h | 311 ------------------------------ + qt/test-poppler-qt.cpp | 122 ------------ + 21 files changed, 2340 deletions(-) + +commit 301352e5585d4ab6e7b609b4ab79b4d8b8656092 +Author: Daiki Ueno <ueno@unixuser.org> +Date: Sun Jan 9 18:48:50 2011 +0000 + + Do not crash in case jpeg_create_decompress fails + + Bug 32890 + + poppler/DCTStream.cc | 21 ++++++++++++--------- + poppler/DCTStream.h | 8 ++++++-- + 2 files changed, 18 insertions(+), 11 deletions(-) + +commit 17baf0498485720b4ea5952bb46287f533139d0a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jan 8 13:03:31 2011 +0000 + + Remove declaration of function without implementation + + poppler/XRef.h | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit a9e280508f5d669c8b6e1a6bb888b9369d868ab3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jan 8 10:39:41 2011 +0100 + + glib: Fix memory leak when calling poppler_page_get_text_layout() + for pages with no text + + glib/poppler-page.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 5d62d18941810ef7d668eafa8b001085133fb169 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jan 8 10:33:32 2011 +0100 + + glib: Use NULL instead of FALSE in g_return_val_if_fail() for + functions returning a pointer + + glib/poppler-page.cc | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +commit 1324ae13f1fc2fa28951c2c7f7d63d4756537229 +Author: Pino Toscano <pino@kde.org> +Date: Thu Jan 6 01:15:30 2011 +0100 + + [cpp/apidox] advertize the 'pnm' image format + + cpp/poppler-image.cpp | 1 + + 1 file changed, 1 insertion(+) + +commit b192363960c26111167b1b08db9910e5f39dcf8b +Author: Pino Toscano <pino@kde.org> +Date: Thu Jan 6 01:09:09 2011 +0100 + + [cpp] Add PNM (PBM/PGM/PPM) exporting to 'image'. + + Introduce a custom ImgWriter (PNMWriter) for exporting in the PNM + variants, + and use it choosing the output format matching as close as possible + the format of the image. + + cpp/CMakeLists.txt | 1 + + cpp/Makefile.am | 2 + + cpp/PNMWriter.cc | 119 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + cpp/PNMWriter.h | 43 ++++++++++++++++++ + cpp/poppler-image.cpp | 22 +++++++++- + 5 files changed, 186 insertions(+), 1 deletion(-) + +commit bebc530cbde7898759e1bd3629d2836ce0fb1d08 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Dec 31 12:11:40 2010 +1030 + + cairo: Don't set JPX mime data if the stream specifies a colorspace + + The stream colorspace overides, and may be different to, the + colorspace in the JPX data. + + https://bugs.freedesktop.org/show_bug.cgi?id=32746 + + poppler/CairoOutputDev.cc | 46 + +++++++++++++++++++++++++++++++--------------- + poppler/CairoOutputDev.h | 1 + + 2 files changed, 32 insertions(+), 15 deletions(-) + +commit 1399b9ab14b19f25583c75af2b36f63a6a01129a +Author: Pino Toscano <pino@kde.org> +Date: Wed Dec 29 15:56:45 2010 +0100 + + [cpp] add TIFF output to 'image' + + cpp/poppler-image.cpp | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +commit 1c7937dbc3c577ffc12cacc8de33d320e2f30ce9 +Author: William Bader <williambader@hotmail.com> +Date: Wed Dec 29 14:47:06 2010 +0000 + + Make pdftoppm be able of writing tif files + + BUG 32027 + + CMakeLists.txt | 15 ++++ + config.h.cmake | 3 + + configure.ac | 32 ++++++++ + goo/Makefile.am | 2 + + goo/TiffWriter.cc | 202 + +++++++++++++++++++++++++++++++++++++++++++++++++ + goo/TiffWriter.h | 53 +++++++++++++ + poppler/Makefile.am | 11 +++ + splash/SplashBitmap.cc | 18 ++++- + splash/SplashBitmap.h | 5 +- + splash/SplashTypes.h | 4 +- + utils/pdftoppm.1 | 6 ++ + utils/pdftoppm.cc | 14 +++- + 12 files changed, 358 insertions(+), 7 deletions(-) + +commit bae91ecb638fcfee001e5c9a86a754610da796e4 +Author: William Bader <williambader@hotmail.com> +Date: Tue Dec 28 11:53:54 2010 +0000 + + Add -singlefile option to pdftoppm + + Bug 32025 + + utils/pdftoppm.1 | 3 +++ + utils/pdftoppm.cc | 26 +++++++++++++++++++++++--- + 2 files changed, 26 insertions(+), 3 deletions(-) + +commit ff58ee66c27da09a370a3000ab55eb1a24921852 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Dec 27 20:07:21 2010 +0000 + + bump soname just in case the getPage change is not BC + + qt/CMakeLists.txt | 2 +- + qt/Makefile.am | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 453df02e195a96d0210f297c21c8ffba646659da +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Dec 27 19:51:13 2010 +0000 + + Make distcheck work + + glib/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 6a34cec72c1a1b6576858a7836aae4a902fb5ed7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Dec 27 19:29:52 2010 +0000 + + increase core soname + + CMakeLists.txt | 2 +- + poppler/Makefile.am | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 8c11e9d68dceb609d04b3b383d22c307b5981d86 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Dec 27 19:23:29 2010 +0000 + + 0.16.0 project version increase + + CMakeLists.txt | 4 ++-- + configure.ac | 4 ++-- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + 4 files changed, 6 insertions(+), 6 deletions(-) + +commit 8c1fd83c6061279af00c1172fe41cee61f19d917 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Dec 27 19:22:22 2010 +0000 + + 0.16.0 NEWS + + NEWS | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +commit 0294d6e50691a3e40fad0d6e4fa9056944a91efd +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Thu Dec 23 15:56:32 2010 +0000 + + Be more correct when drawing radial shadings + + Fixes 32349 + + poppler/Gfx.cc | 25 ++++++++++++++++--------- + 1 file changed, 16 insertions(+), 9 deletions(-) + +commit 3aa08e378927889b35b6fa858d6da568250ba6ec +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 19 22:36:47 2010 +0000 + + Seems to work with this version, so enable it + + CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 93cf184b7573980bf2e56342e64f9b99c5d0b415 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 19 14:16:25 2010 +0000 + + Fix last commit + + Applying patches by hand is bad + + poppler/PDFDoc.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit ebb580d756a8321de87814f05ab572564732c15e +Author: Philip Lorenz <lorenzph+freedesktop@gmail.com> +Date: Sun Dec 19 14:08:31 2010 +0000 + + Windows fixes + + poppler/PDFDoc.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 88a4154420e016d93c5ce05b5b8e09b6bddcadc9 +Author: Philip Lorenz <lorenzph+freedesktop@gmail.com> +Date: Sun Dec 19 13:03:01 2010 +0000 + + build on newer MSVC + + qt4/src/poppler-annotation.h | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +commit 18cd9f6aeb48266c551952c395eb9cd662bc27f5 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sat Dec 18 17:59:54 2010 +0000 + + compile in windows + + poppler/FontInfo.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 471102ef68b439dfa13e20e3b0f2e143f8d0dc85 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 17 00:36:36 2010 +0000 + + Remove -resolution + + Actually use -zoom that is there for a reason + + utils/pdftohtml.1 | 3 --- + utils/pdftohtml.cc | 15 ++++++--------- + 2 files changed, 6 insertions(+), 12 deletions(-) + +commit edf6c47feb5b7658e585bcce196e465245e1dc98 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Dec 16 22:56:40 2010 +0000 + + kill useless code + + utils/pdftohtml.cc | 8 -------- + 1 file changed, 8 deletions(-) + +commit 185a2f81485e19f96393a431be5523a277747b94 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Dec 16 22:56:15 2010 +0000 + + static-ify some vars + + utils/HtmlOutputDev.cc | 9 --------- + utils/pdftohtml.cc | 8 ++++---- + 2 files changed, 4 insertions(+), 13 deletions(-) + +commit e4dfc548c57b690db9122d1db3342ed0a785c8bb +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Dec 14 19:45:46 2010 +0000 + + We need this to make the define really be defined + + config.h.cmake | 3 +++ + 1 file changed, 3 insertions(+) + +commit 06da4b46c442778c67b788b747f04b386b5247ac +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Dec 14 09:06:57 2010 +1030 + + cairo: Use A1 instead of A8 for imagemask + + The cairo PDF surface now optimizes the case of cairo_mask() with + solid source and A1 mask to use a PDF stencil mask. + + Fixes https://bugs.launchpad.net/ubuntu/+source/libcairo/+bug/680628 + where a 65K PDF printed to PDF using poppler-cairo turns into an 8MB + PDF. + + CMakeLists.txt | 2 ++ + configure.ac | 1 + + poppler/CairoOutputDev.cc | 25 ++++++++++++++++++------- + 3 files changed, 21 insertions(+), 7 deletions(-) + +commit 6ef457dc818e7e241e5d2e264bc2d78b132ae638 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Dec 13 14:08:29 2010 +0000 + + Move -fno-exceptions -fno-check-new to default flags + + Makes sense since we decided not to support the exception path in + gmem a + while ago + + cmake/modules/PopplerMacros.cmake | 2 +- + configure.ac | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 86e469600b58ae05cb6ede1b4017fbdac99cc556 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Dec 13 14:04:00 2010 +0000 + + More gcc flags movement + + -Wchar-subscripts is part of -Wall so remove it + Move -fno-common to default options since it makes sense to use it + + cmake/modules/PopplerMacros.cmake | 4 ++-- + configure.ac | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +commit 2b74241d8b1fd1ec9fab4f6f673bbaaa1cb3d949 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Dec 13 13:56:52 2010 +0000 + + Promote -Wcast-align to the general warnings we ask gcc to give + + cmake/modules/PopplerMacros.cmake | 2 +- + configure.ac | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 7313e0a4de6f2146c1dcb3d235f18a3c844d12d5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 12 23:28:18 2010 +0000 + + Do not return 99 (or 1) with -h, -v and -printenc + + Bug 32149 + + utils/pdffonts.cc | 2 ++ + utils/pdfimages.cc | 2 ++ + utils/pdfinfo.cc | 3 +++ + utils/pdftoppm.cc | 2 ++ + utils/pdftops.cc | 5 ++++- + utils/pdftotext.cc | 3 +++ + 6 files changed, 16 insertions(+), 1 deletion(-) + +commit 669cbfc9fd78a22d4f14b0af43143e1f5dc28cd5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 11 19:04:22 2010 +0000 + + Fix the preliminary bbox/clip calculation + + Code based in code posted by Suzuki Toshiya in the freetype mailing + list + + splash/SplashFTFont.cc | 15 +++++++++------ + 1 file changed, 9 insertions(+), 6 deletions(-) + +commit 2984002a64acca7014edeadd900dd52cdf7d9eac +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 11 18:57:52 2010 +0000 + + Remove the * we just need to increase the pointer + + Gives a warning with newer gcc's + + splash/Splash.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 9b45fa072198da4a5032004ac943cf2227aa97ea +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 10 12:05:58 2010 +0000 + + Make PreScanOutputDev be less agressive when deciding to rasterize + + BUG 30107 + + poppler/PreScanOutputDev.cc | 14 +++++++++++++- + poppler/PreScanOutputDev.h | 4 ++++ + 2 files changed, 17 insertions(+), 1 deletion(-) + +commit f96f6a06cdc33b4654669ac74d5abd0d546a127d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 5 12:06:21 2010 +0000 + + Adapt the zlib-base FlateStream code to API changes + + Bug 32065 + + poppler/FlateStream.cc | 9 ++++++--- + poppler/FlateStream.h | 9 +++++++++ + 2 files changed, 15 insertions(+), 3 deletions(-) + +commit 7b1f83990a1f68306daf5f7dbeabcd38f4382e3b +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Nov 29 22:27:46 2010 +0000 + + 0.15.3 + + CMakeLists.txt | 4 ++-- + NEWS | 18 ++++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 6 files changed, 24 insertions(+), 6 deletions(-) + +commit 7c23a993193aaaa4d4b5b6d1161a0455d1e2a8c0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Nov 29 21:33:31 2010 +0000 + + Add some more isNum before calling getNum + + poppler/GfxState.cc | 48 ++++++++++++++++++++++++++++++++---------------- + 1 file changed, 32 insertions(+), 16 deletions(-) + +commit 62ec4f591c258e702ee79b519919a931517220bf +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Nov 29 20:50:43 2010 +0000 + + pass fetchOriginatorNums in some more calls + + Fixes some more crashes in broken files + + poppler/Parser.cc | 7 ++++++- + poppler/Parser.h | 1 + + poppler/XRef.cc | 6 +++--- + 3 files changed, 10 insertions(+), 4 deletions(-) + +commit d2a0e2ca723142478858f7edfb7c98807d554578 +Author: Hib Eris <hib@hiberis.nl> +Date: Thu Nov 25 10:36:38 2010 +0000 + + Skip over loops in Pages tree + + poppler/Catalog.cc | 15 ++++++++++----- + 1 file changed, 10 insertions(+), 5 deletions(-) + +commit 7abd371364e6e4aaef932f26b0664f7f9d760c42 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Nov 28 13:57:50 2010 +0000 + + this var is not about xobjects only anymroe + + poppler/FontInfo.cc | 6 +++--- + poppler/FontInfo.h | 2 +- + 2 files changed, 4 insertions(+), 4 deletions(-) + +commit 1ac14df61d711097837e44d80a9332f0a854b95e +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Nov 28 13:49:41 2010 +0000 + + find fonts inside patterns + + Bug 31948 + + poppler/FontInfo.cc | 50 + +++++++++++++++++++++++++++----------------------- + 1 file changed, 27 insertions(+), 23 deletions(-) + +commit d30dd8c6f6491beac9750447126930168394cd9f +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Nov 28 13:25:39 2010 +0000 + + Use sets instead of arrays + + poppler/FontInfo.cc | 46 ++++++++-------------------------------------- + poppler/FontInfo.h | 11 +++-------- + 2 files changed, 11 insertions(+), 46 deletions(-) + +commit 4c20bf14c0b1d7f1d5e530ded890186487da32b5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Nov 28 12:50:24 2010 +0000 + + Use FontInfoScanner + + No idea why we didn't do this before, duplicate code is evil and now + pdffonts doesn't crash on pdf from bug 20486 + + utils/pdffonts.cc | 185 + ++++++++---------------------------------------------- + 1 file changed, 26 insertions(+), 159 deletions(-) + +commit d915f3d5a9e9e2e5dcd6be4cf8fac1b5849a13e9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 24 21:51:46 2010 +0000 + + protect against null ref here + + poppler/Catalog.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit cf32faaa16d763561fb9dfc4469345e4b3ba2369 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 24 21:48:54 2010 +0000 + + Protect against NULL values here + + poppler/JPEG2000Stream.h | 2 ++ + 1 file changed, 2 insertions(+) + +commit 46a6cc5952c59504863baed3ad2870093c462f12 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 24 19:42:59 2010 +0000 + + Check the objects are numbers before using them + + Bug 31895 + + poppler/GfxState.cc | 26 ++++++++++++++++++-------- + 1 file changed, 18 insertions(+), 8 deletions(-) + +commit 52e25cca7e75a8b8eac95a3cec258f1cd9f8ecaa +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Nov 23 20:31:14 2010 +0000 + + If it is not a Page but has no Kids either let's just pretend it's + a page + + Fixes broken PDF at bug 31861 + + poppler/Catalog.cc | 2 +- + poppler/Dict.cc | 4 ++++ + poppler/Dict.h | 2 ++ + 3 files changed, 7 insertions(+), 1 deletion(-) + +commit c6127898b13311197971b1c6b1b306b91e28cf0e +Author: Hib Eris <hib@hiberis.nl> +Date: Mon Nov 22 13:08:48 2010 +0000 + + Use gmallocn_checkoverflow when parsing Hints table + + Prevents running out of memory with malicious documents. + + poppler/Hints.cc | 26 +++++++++++++------------- + 1 file changed, 13 insertions(+), 13 deletions(-) + +commit 6a17cc89eda52f08cbacbf9bfaaeda22cf041e82 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Mon Nov 22 19:20:56 2010 +0000 + + Improve rendering of radial shadings + + Improves the duck rendering in bug 22098 + + poppler/Gfx.cc | 71 + ++++++++++++++++++++++++++++------------------------------ + 1 file changed, 34 insertions(+), 37 deletions(-) + +commit 9093adede4f9ad6fb2962dcefcb09c1d8c357715 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Nov 21 23:49:12 2010 +0000 + + pedantic ; + + poppler/CurlPDFDocBuilder.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 61445f5af749510fb647059af01abf1faf664195 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Nov 20 22:19:35 2010 +0000 + + forgot to upadte year here + + poppler/Parser.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 3628837febb21bcd1b54f3fb737628ea59e5d95d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Nov 20 22:15:08 2010 +0000 + + And now generalize the previous fix + + Works for loops of more than one item as in bug 28784 + + poppler/Dict.cc | 4 ++-- + poppler/Dict.h | 2 +- + poppler/Object.cc | 4 ++-- + poppler/Object.h | 9 +++++---- + poppler/Parser.cc | 19 +++++++++++++------ + poppler/Parser.h | 7 ++++++- + poppler/XRef.cc | 30 +++++++++++++++++++++++++----- + poppler/XRef.h | 2 +- + 8 files changed, 55 insertions(+), 22 deletions(-) + +commit b0555189a7fbd7f6a899e582783b9e0df44d5d6a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Nov 20 21:32:24 2010 +0000 + + Protect against more loops when parsing + + poppler/Dict.cc | 4 ++-- + poppler/Dict.h | 2 +- + poppler/Object.cc | 4 ++-- + poppler/Object.h | 8 ++++---- + poppler/Parser.cc | 2 +- + poppler/XRef.cc | 4 ++-- + poppler/XRef.h | 2 +- + 7 files changed, 13 insertions(+), 13 deletions(-) + +commit 555fa897b275ca7195f22a727b049c8c4f2d74cd +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Nov 20 19:14:38 2010 +0000 + + Detect loops in FormField creation + + poppler/Form.cc | 88 + ++++++++++++++++++++++++++++++++------------------------- + poppler/Form.h | 14 +++++---- + 2 files changed, 58 insertions(+), 44 deletions(-) + +commit 1802ddef374cb1451975480b2427e5d23ee2c737 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Nov 20 18:58:17 2010 +0000 + + Forgot to port this away from GooVector :-S + + poppler/CurlCachedFile.cc | 3 +-- + poppler/CurlCachedFile.h | 2 +- + 2 files changed, 2 insertions(+), 3 deletions(-) + +commit 32e53c5436b8c3654e7043f1d86596a79511a4cf +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Nov 20 18:54:59 2010 +0000 + + fix spacing + + poppler/Form.cc | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit 1cb3d5d94a1d89ccded96d977bcabfbe438fb81f +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Nov 20 18:08:45 2010 +0000 + + fix the memset + + Fixes crash in broken pdf + + poppler/Hints.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 22e8cebaa15adb4b19c9556cdca43cc3e77832b7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Nov 20 17:20:34 2010 +0000 + + Ensure the obj are num before reading them + + poppler/GfxState.cc | 32 ++++++++++++++++++++++---------- + 1 file changed, 22 insertions(+), 10 deletions(-) + +commit 08b2db36db4e011ebe36d2d945cb1a0498f1c5fb +Author: Pino Toscano <pino@kde.org> +Date: Sat Nov 20 14:00:36 2010 +0100 + + add my copyright here + + poppler/Hints.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 91aa4b02aa93ffe3828479194067de42d52be465 +Author: Pino Toscano <pino@kde.org> +Date: Sat Nov 20 13:13:46 2010 +0100 + + [cpp] include <ios> for std::hex() and std::left() + + cpp/poppler-global.cpp | 1 + + cpp/tests/poppler-dump.cpp | 1 + + 2 files changed, 2 insertions(+) + +commit 1c924412923cb01f2cb95b0943cb7bbaf7e8cfb6 +Author: Pino Toscano <pino@kde.org> +Date: Sat Nov 20 13:02:36 2010 +0100 + + [cpp] include <iterator> for std::back_inserter() + + cpp/poppler-document.cpp | 1 + + 1 file changed, 1 insertion(+) + +commit 95b551025a34f3a7bcff2852eac6d186bc8a7cb0 +Author: Pino Toscano <pino@kde.org> +Date: Sat Nov 20 12:54:21 2010 +0100 + + use a std::vector<char> instead of a var-length-array of char's + + poppler/Hints.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 4faaff893515c80cb69b02e431a0f8483274a497 +Author: Hib Eris <hib@hiberis.nl> +Date: Fri Nov 19 23:53:35 2010 +0000 + + [win32] Simplify strtok_r implementation + + The previous implementation did not compile with mingw64. + + poppler/strtok_r.cpp | 137 + +-------------------------------------------------- + 1 file changed, 1 insertion(+), 136 deletions(-) + +commit 255f84927a649d980f047fe755c9c308535a3779 +Author: Hib Eris <hib@hiberis.nl> +Date: Fri Nov 19 23:45:33 2010 +0000 + + Correct parsing of linearization table + + Fixes bug #31627 + + poppler/Linearization.cc | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +commit 9d05138f0b7d15945f546564036bc67815593db0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Nov 14 16:05:28 2010 +0000 + + 0.15.2 + + CMakeLists.txt | 4 ++-- + NEWS | 22 ++++++++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 6 files changed, 28 insertions(+), 6 deletions(-) + +commit 2d18543bd6b3a5a9ff2dfab63339d5bfcccd0b2f +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Nov 14 15:41:56 2010 +0000 + + This does actually work now :D + + qt4/tests/check_metadata.cpp | 1 - + 1 file changed, 1 deletion(-) + +commit d772364b8a5858cbd98e256547d319260fa9d084 +Author: Pino Toscano <pino@kde.org> +Date: Thu Nov 11 21:52:25 2010 +0100 + + [Qt4] New function setDebugErrorFunction(). + + This new function + typedef can be useful to direct the ebug/error + messages + to a different place than the default qDebug()'s one. + + Base on an idea of Albert, added closure and polish by me. + + qt4/src/poppler-private.cc | 20 +++++++++++++++++++- + qt4/src/poppler-qt4.h | 24 ++++++++++++++++++++++++ + 2 files changed, 43 insertions(+), 1 deletion(-) + +commit ce929cf33f4b6b6421f9d327b4bb792816d47aac +Author: Jakob Voss <jakob.voss@gbv.de> +Date: Wed Nov 10 23:41:44 2010 +0000 + + Add -p flag to pdfimages + + Adds the page the image is in to the image filename + + utils/ImageOutputDev.cc | 25 ++++++++++++++++++------- + utils/ImageOutputDev.h | 19 +++++++++++++++---- + utils/pdfimages.1 | 3 +++ + utils/pdfimages.cc | 6 +++++- + 4 files changed, 41 insertions(+), 12 deletions(-) + +commit 6296c28968613aadb7ea084092945a54005eca9b +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 10 23:28:45 2010 +0000 + + Kill GooVector + + std::vector does the same and GooVector is not part of xpdf so + we don't + need to maintain it in case we ever get a new xpdf release we want to + merge with + + CMakeLists.txt | 1 - + goo/GooVector.h | 159 + --------------------------------------------- + goo/Makefile.am | 1 - + poppler/CachedFile.cc | 19 +++--- + poppler/CachedFile.h | 15 +++-- + poppler/Catalog.cc | 12 ++-- + poppler/Catalog.h | 10 +-- + poppler/Form.h | 3 +- + poppler/Gfx.h | 7 +- + poppler/Hints.cc | 5 +- + poppler/Hints.h | 6 +- + poppler/StdinCachedFile.cc | 2 +- + poppler/StdinCachedFile.h | 2 +- + poppler/Stream.h | 1 - + poppler/XRef.cc | 10 +-- + poppler/XRef.h | 7 +- + utils/HtmlFonts.cc | 8 +-- + utils/HtmlFonts.h | 12 ++-- + utils/HtmlLinks.cc | 8 +-- + utils/HtmlLinks.h | 4 +- + 20 files changed, 66 insertions(+), 226 deletions(-) + +commit 5934c320aa136c1a6e97fb9bf54bdfdccfcab521 +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Nov 10 22:50:36 2010 +0000 + + Linearization improvements + + Read + http://lists.freedesktop.org/archives/poppler/2010-November/006642.html + for the detailed patch description + + CMakeLists.txt | 4 + + glib/poppler-action.cc | 4 +- + glib/poppler-document.cc | 17 +- + glib/poppler-page.cc | 1 + + poppler/CachedFile.h | 2 +- + poppler/Catalog.cc | 352 +++++++++++++++++++++----------- + poppler/Catalog.h | 14 +- + poppler/FontInfo.cc | 5 +- + poppler/Hints.cc | 439 + ++++++++++++++++++++++++++++++++++++++++ + poppler/Hints.h | 95 +++++++++ + poppler/Linearization.cc | 224 ++++++++++++++++++++ + poppler/Linearization.h | 45 ++++ + poppler/Makefile.am | 4 + + poppler/PDFDoc.cc | 284 ++++++++++++++++++++++---- + poppler/PDFDoc.h | 38 +++- + poppler/PSOutputDev.cc | 39 ++-- + poppler/PSOutputDev.h | 14 +- + poppler/Stream.cc | 13 +- + poppler/Stream.h | 11 +- + poppler/XRef.cc | 351 +++++++++++++++++++------------- + poppler/XRef.h | 25 ++- + qt/poppler-document.cc | 14 +- + qt/poppler-page.cc | 19 +- + qt/poppler-private.h | 14 +- + qt/poppler-qt.h | 3 +- + qt4/src/poppler-document.cc | 12 +- + qt4/src/poppler-link.cc | 7 +- + qt4/src/poppler-page.cc | 3 +- + qt4/src/poppler-ps-converter.cc | 2 + + utils/HtmlOutputDev.cc | 2 +- + utils/HtmlOutputDev.h | 3 + + utils/pdffonts.cc | 6 +- + utils/pdfinfo.cc | 22 +- + utils/pdftohtml.cc | 2 +- + utils/pdftops.cc | 3 +- + 35 files changed, 1690 insertions(+), 403 deletions(-) + +commit abb1313ae40ab7efb073406f47fa53bf7afe0b88 +Author: Pino Toscano <pino@kde.org> +Date: Mon Nov 8 01:54:03 2010 +0100 + + [cpp/apidox] add the minimum version of 'image' + + cpp/poppler-image.cpp | 2 ++ + 1 file changed, 2 insertions(+) + +commit f559e77cb7d76c5fe6a79be9086667a29613c912 +Author: Pino Toscano <pino@kde.org> +Date: Mon Nov 8 01:52:48 2010 +0100 + + [cpp] add image::bytes_per_row() + + cpp/poppler-image.cpp | 8 ++++++++ + cpp/poppler-image.h | 1 + + 2 files changed, 9 insertions(+) + +commit 14dea4d74698d5d7d994e687f8176652d790dba7 +Author: Pino Toscano <pino@kde.org> +Date: Sun Nov 7 22:57:31 2010 +0100 + + [arthur] use the untransformed line width, not the transformed one + + ... as the painter will do the transformation itself already; + seems to product better results + + poppler/ArthurOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit f077e82af0724be88d28c896a3c208f1d50ccff9 +Author: Pino Toscano <pino@kde.org> +Date: Sun Nov 7 21:50:48 2010 +0100 + + [qt4] New Page::renderToPainter() + + This new painter-based painting function ican be used for painting + (with Arthur only for now) without getting an image first. + Also add a new flag type for it, with a single item telling whether + do not save+restore the provided painter. + + Mostly based on a patch by Matthias Fauconneau + (matthias.fauconneau@gmail.com), thanks! + + qt4/src/poppler-page.cc | 62 + +++++++++++++++++++++++++++++++--------------- + qt4/src/poppler-qt4.h | 65 + ++++++++++++++++++++++++++++++++++++++++++++++++- + 2 files changed, 107 insertions(+), 20 deletions(-) + +commit df02d1fc9e65422121e5e8f493c13229552ec0e7 +Author: Pino Toscano <pino@kde.org> +Date: Sun Nov 7 19:47:56 2010 +0100 + + [arthur] remove unused 'm_image' attribute + + poppler/ArthurOutputDev.cc | 1 - + poppler/ArthurOutputDev.h | 2 +- + 2 files changed, 1 insertion(+), 2 deletions(-) + +commit b29582cd0d542a3e70dbca3fb75770daa4cc91ca +Author: Matthias Fauconneau <matthias.fauconneau@gmail.com> +Date: Sun Nov 7 19:44:11 2010 +0100 + + [arthur] small fixes and memory leaks + + - fix font rendering (transforming the glyph path and not only the + glyph origin) + - fix image rendering (alpha was set to zero) + + poppler/ArthurOutputDev.cc | 122 + ++++++++++++++++++++------------------------- + 1 file changed, 54 insertions(+), 68 deletions(-) + +commit 970f075569bf9be5e5ddc3a9ad1fabec5435dfaf +Author: Pino Toscano <pino@kde.org> +Date: Sun Nov 7 16:31:02 2010 +0100 + + [cpp/tests] add a simple poppler-render test + + ... to ease testing the render capabilities of poppler-cpp. + quite minimal at the moment. + + cpp/tests/CMakeLists.txt | 3 ++ + cpp/tests/Makefile.am | 9 +++- + cpp/tests/poppler-render.cpp | 113 + +++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 124 insertions(+), 1 deletion(-) + +commit bfe4139c742cb0a669f5504df7e22e3e57243d9a +Author: Pino Toscano <pino@kde.org> +Date: Sun Nov 7 16:23:26 2010 +0100 + + [cpp] Add page_renderer, to render pages over images. + + This new class introduces a very simple way to render a page, using + the Splash backend, + giving an 'image' as result. + It can hold a color for the "paper" of the pages, and some hints + for the actual rendering. + + cpp/CMakeLists.txt | 2 + + cpp/Makefile.am | 2 + + cpp/poppler-page-renderer.cpp | 212 + ++++++++++++++++++++++++++++++++++++++++++ + cpp/poppler-page-renderer.h | 66 +++++++++++++ + 4 files changed, 282 insertions(+) + +commit 91e3f7b4ea42a5821fd78e1edf55e95250c9bc68 +Author: Pino Toscano <pino@kde.org> +Date: Sun Nov 7 16:19:34 2010 +0100 + + [cpp] add an internal way to get a 'page_private' of a 'page' + + useful for getting a 'page_private' in the implementation of other + cpp classes + without the need to add friends to 'page' + + cpp/poppler-page-private.h | 5 +++++ + 1 file changed, 5 insertions(+) + +commit fa7c41cb9c52ecd3d7c574455b1258a3021b8c75 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Nov 4 20:55:34 2010 +0000 + + Improvements to the splash backend + + Antialias and shadings. + Code by Thomas Freitag <Thomas.Freitag@alfa.de> and Christian + Feuersänger <cfeuersaenger@googlemail.com> + More info at bug 30436 + + poppler/CairoOutputDev.h | 5 +- + poppler/Function.cc | 4 +- + poppler/Function.h | 2 + + poppler/Gfx.cc | 12 +- + poppler/OutputDev.h | 16 +- + poppler/PSOutputDev.h | 4 +- + poppler/SplashOutputDev.cc | 182 ++++++++++++++++++++- + poppler/SplashOutputDev.h | 68 +++++++- + splash/Splash.cc | 395 + ++++++++++++++++++++++++++++++++++++++++++++- + splash/Splash.h | 11 +- + splash/SplashBitmap.cc | 4 +- + splash/SplashBitmap.h | 3 + + splash/SplashPattern.cc | 17 +- + splash/SplashPattern.h | 36 ++++- + 14 files changed, 735 insertions(+), 24 deletions(-) + +commit 0aa040163741ab8ba093a742e556bba2a5ab7edf +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 3 20:40:24 2010 +0000 + + Do not add sibling children as parents + + Fixes c2ff94b1600b8a5841a5e4627f014560ac460f1a + + poppler/Function.cc | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +commit c2ff94b1600b8a5841a5e4627f014560ac460f1a +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 3 00:02:02 2010 +0000 + + Do not loop forever in broken documents + + StitchingFunctions that have themselves up in the parent chain + are wrong + + poppler/Function.cc | 22 +++++++++++++++++++--- + poppler/Function.h | 6 ++++-- + 2 files changed, 23 insertions(+), 5 deletions(-) + +commit cad66a7d25abdb6aa15f3aa94a35737b119b2659 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Nov 2 19:14:34 2010 +0000 + + Fix crash in broken documents + + mapLen = (code + 256) & ~255; can wrap and you end up with mapLen + < code + that is not what you wanted + + poppler/CharCodeToUnicode.cc | 16 +++++++++++----- + 1 file changed, 11 insertions(+), 5 deletions(-) + +commit 7e5f31c1c41193c6e49355970e6d027b91d45825 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Nov 2 00:32:01 2010 +0000 + + make some more fields private + + splash/SplashFontFile.h | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 6751eb48dc49890f7ad8b732b3fc29a2db746ec4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Nov 2 00:26:08 2010 +0000 + + Make the destructor private + + You are not supposed to call it, you should call unref + + splash/SplashFontFile.h | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit b718e821d5f21ea5b0c44c6c2b59769c9b94892a +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 28 08:46:09 2010 +0100 + + Revert fdfffc9c68314d3f64dee7e0ef8617105e3198dd + + It is not a leak and makes things crash :D + + poppler/SplashOutputDev.cc | 1 - + 1 file changed, 1 deletion(-) + +commit 15b9aeac5a20c544db1aebe00113ebc2f7ba52c7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 28 00:37:29 2010 +0100 + + if reallocn fails, free p + + goo/gmem.cc | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +commit 561c0567a5741d7c49903c51c8020187dccaa0d9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Oct 27 22:43:51 2010 +0100 + + fix comment + + poppler/SplashOutputDev.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 4ef38cc99a879202e717447a422272cf85eeccfc +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Oct 27 22:36:07 2010 +0100 + + Fix memory leaks that can happen with broken documents + + poppler/SplashOutputDev.cc | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +commit fdfffc9c68314d3f64dee7e0ef8617105e3198dd +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Oct 27 20:40:19 2010 +0100 + + Fix memory leak + + poppler/SplashOutputDev.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 90d479d9d5c947175e60ab689f440ae9c24f0b2b +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Oct 27 20:39:48 2010 +0100 + + Do not crash if bitmap->alpha == NULL + + Happens in broken files + + splash/Splash.cc | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 6ad36277971ec46d4a4ef0c45625e60f8c5f1247 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Oct 25 18:59:49 2010 +0100 + + Initialze movie to NULL on broken pdf files + + poppler/Annot.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 2d0b6e2956a81164bca6adc9aacad0e620480957 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Oct 24 00:23:21 2010 +0100 + + Here the chars to read is the increment size not the initialSize + + Fixes crash in file provided by Robert Święcki + + poppler/Stream.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit dcb02d2100136b6035485be3be214ce3d9f1c102 +Author: Vincent Torri <vtorri@univ-evry.fr> +Date: Sat Oct 23 23:45:05 2010 +0100 + + remove -ansi flag for cywin and mingw + + configure.ac | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit 17cdc81224c72f7b58de61734c9ead337ff7b42b +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 23 23:37:59 2010 +0100 + + update my C year + + poppler/SplashOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e09ddce7e21bbd62b384d9d59fbd1e0f14f7d05f +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 23 23:33:00 2010 +0100 + + Fix crash in malformed documents + + poppler/SplashOutputDev.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 906e4e15421d8f3f0a825ca767e5eac3169853d6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 23 23:12:44 2010 +0100 + + Do not leak attrs1 + + poppler/Catalog.cc | 1 + + 1 file changed, 1 insertion(+) + +commit ec32bb45a57a8a839156c946fcde1270aa6019d9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 23 23:00:03 2010 +0100 + + Do not crash if n is 0 + + poppler/Function.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 9edf7e4fefb37989af9a2558aaa83d7cd4694ec6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 23 22:59:50 2010 +0100 + + add unlikely marker + + poppler/Decrypt.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit c46e863b7b94dc2f83a7d89f4afb8fe3bc8ec35c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 23 22:55:49 2010 +0100 + + Do not divide by 0 in rc4InitKey + + poppler/Decrypt.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit bcb13ed5828e2a855efd5e38b2acd15ca37a9991 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 23 22:40:17 2010 +0100 + + Check obj2 is a num before reading it + + poppler/Gfx.cc | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit c64a49307782299cb7a950a66419f9d59707f38b +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Oct 20 22:29:29 2010 +0100 + + 0.15.1 + + CMakeLists.txt | 4 ++-- + NEWS | 46 ++++++++++++++++++++++++++++++++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 6 files changed, 52 insertions(+), 6 deletions(-) + +commit 3b45c66de91243d7419657512cf726c9e1c26dfb +Author: Kenneth Berland <ken@hero.com> +Date: Sun Oct 17 14:24:16 2010 +0100 + + Add -bbox option to pdftotext + + utils/pdftotext.1 | 4 ++ + utils/pdftotext.cc | 125 + ++++++++++++++++++++++++++++++++++++++++++----------- + 2 files changed, 103 insertions(+), 26 deletions(-) + +commit 71ec4c7a6715a40d536d1e4b911dae48d1bba7b9 +Author: Pino Toscano <pino@kde.org> +Date: Sun Oct 17 14:57:43 2010 +0200 + + [CMake] update MacroOptionalFindPackage.cmake from KDE SVN + + no radical changes, just a minor improvement for the "explicitly + disabled" case + + cmake/modules/MacroOptionalFindPackage.cmake | 40 + +++++++++++++++++++++------- + 1 file changed, 30 insertions(+), 10 deletions(-) + +commit ab0049d8be5dfe1989c4aa33c2732915c62fecb2 +Author: Pino Toscano <pino@kde.org> +Date: Sun Oct 17 14:29:22 2010 +0200 + + [CMake] Cairo package: make the version check really working + + cmake/modules/FindCairo.cmake | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit 1cea33717c92631ee9c417d9f89e32b03695c75a +Author: Pino Toscano <pino@kde.org> +Date: Sun Oct 17 13:55:58 2010 +0200 + + [CMake] Bump cairo dependency to 1.10 + + followup of fc9b85894754d175af916eaf6cb127efd601df7e + + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit d6f49aa2da15cd2e9cf775d6b1d2d04a005c8cdd +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Oct 17 14:22:57 2010 +0200 + + [cairo] Fix a crash when redering documents with invalid type 3 fonts + + poppler/CairoFontEngine.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e2fad550c3cbf86541730582151e1bb6470ed9c1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Oct 17 13:47:33 2010 +0200 + + [glib-demo] Use poppler_page_get_selected_region() in selections demo + + glib/demo/selections.c | 73 + +++++++++++++++----------------------------------- + 1 file changed, 22 insertions(+), 51 deletions(-) + +commit 88013458e141de58ed801480707ae0dfe92b9aa2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Oct 17 13:46:26 2010 +0200 + + [glib] Add poppler_page_get_selected_region() + + that returns a cairo_region_t, and deprecate + poppler_page_get_selection_region(). + + glib/poppler-page.cc | 81 + +++++++++++++++++++++++++++++++++++++ + glib/poppler-page.h | 4 ++ + glib/reference/poppler-sections.txt | 1 + + 3 files changed, 86 insertions(+) + +commit fc9b85894754d175af916eaf6cb127efd601df7e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Oct 17 12:54:18 2010 +0200 + + [configure] Bump cairo dependency to 1.10 + + configure.ac | 2 +- + poppler/CairoOutputDev.cc | 4 ---- + 2 files changed, 1 insertion(+), 5 deletions(-) + +commit dd14ef6b211ac1c8a4f16bb6094dbfd6a09cbef9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Oct 17 12:46:55 2010 +0100 + + Improve dict lookup speed for big dicts + + Based on a patch by Paweł Wiejacha <pawel.wiejacha@gmail.com> + + poppler/Dict.cc | 98 + +++++++++++++++++++++++++++++++++++++++++++++------------ + poppler/Dict.h | 2 ++ + 2 files changed, 80 insertions(+), 20 deletions(-) + +commit bb38a0c71434413f2728109c73278de1b8a58571 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Oct 17 12:52:01 2010 +0200 + + [glib-demo] Make glib demo program installable + + It's a useful tool for testing and debugging not only for people who + install from sources. + + glib/demo/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit d26d0fab2ddfff853f6681a3518813a2d65a4112 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Oct 17 12:36:46 2010 +0200 + + [glib-demo] Use printing options in print demo + + glib/demo/print.c | 96 + +++++++++++++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 93 insertions(+), 3 deletions(-) + +commit 4a71dcdd350d0c0515ca349f0b875b33289d25ee +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Oct 17 12:31:41 2010 +0200 + + [glib] Add poppler_page_render_for_printing_with_options() + + It allows to print with the same options acroread has: + + - Print document + - Print document and markup + - Print document and stamps + + glib/poppler-page.cc | 77 + ++++++++++++++++++++++++++++++++----- + glib/poppler-page.h | 3 ++ + glib/poppler.h | 19 +++++++++ + glib/reference/poppler-sections.txt | 4 ++ + 4 files changed, 94 insertions(+), 9 deletions(-) + +commit 0b3b2ebc3930bd46fb13fb2158fc695b0962f7c5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 16 15:09:05 2010 +0100 + + Add a callback to know which page has been printed + + qt4/src/poppler-ps-converter.cc | 16 ++++++++++++++-- + qt4/src/poppler-qt4.h | 10 ++++++++++ + 2 files changed, 24 insertions(+), 2 deletions(-) + +commit 4bd25223c4d15dfa91965a6e86eaa444a5a81f71 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 16 15:08:05 2010 +0100 + + Do not omit this character + + Mimics Cairo backend and Adode Reader behaviour + + splash/SplashFTFont.cc | 4 ---- + 1 file changed, 4 deletions(-) + +commit b604a008a2a379a21e5fdfa0799886f80d893a08 +Author: Christian Feuersänger <cfeuersaenger@googlemail.com> +Date: Thu Oct 14 23:56:36 2010 +0100 + + Improve rendering of Shading Type 6 and 7 + + poppler/Gfx.cc | 214 + +++++++++++++++++++++++++++++++++++++++++----------- + poppler/Gfx.h | 9 ++- + poppler/GfxState.cc | 96 ++++++++++++++++++++++- + poppler/GfxState.h | 127 ++++++++++++++++++++++++++++++- + 4 files changed, 398 insertions(+), 48 deletions(-) + +commit c6bb63b31c268e4e842532e6839b15edb31cf25c +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 14 23:33:13 2010 +0100 + + Only clip boxes to mediabox if we are at the page level + + Fixes bug 30784 + + poppler/Page.cc | 19 +++++++++++-------- + 1 file changed, 11 insertions(+), 8 deletions(-) + +commit 4a248b3f523209ec16ace587229412653b2276d0 +Author: Pino Toscano <pino@kde.org> +Date: Thu Oct 14 18:32:05 2010 +0200 + + [cpp] make it compile also when there are no image formats available + + including the ImgWirter.h is enough to get the definition of ImgWriter + + cpp/poppler-image.cpp | 1 + + 1 file changed, 1 insertion(+) + +commit de1501d87549269f9214c9e3fba4cbf39960826e +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Oct 13 19:18:36 2010 +0100 + + remove windows eol + + poppler/Gfx.cc | 38 +++++++++++++++++++------------------- + 1 file changed, 19 insertions(+), 19 deletions(-) + +commit 12e68b49feef10b654944dd71eab0852cfeceb89 +Author: Pino Toscano <pino@kde.org> +Date: Sun Oct 10 23:04:57 2010 +0200 + + [cpp] Add a new 'image' class. + + This implicitely shared class represents the data buffer of an + "image", + with direct access to the data. + It also has a function to save to file (png/jpeg). + + Still a FIXME in the copy() method and in the save() (for mono + images only). + + cpp/CMakeLists.txt | 2 + + cpp/Makefile.am | 3 + + cpp/poppler-image-private.h | 48 +++++ + cpp/poppler-image.cpp | 431 + ++++++++++++++++++++++++++++++++++++++++++++ + cpp/poppler-image.h | 70 +++++++ + 5 files changed, 554 insertions(+) + +commit db31687ba476e272b72625a8a78b50780522ee7d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Oct 9 10:33:06 2010 +0200 + + [glib] docs: Document poppler_annot_markup_get_date() + + glib/poppler-annot.cc | 9 +++++++++ + 1 file changed, 9 insertions(+) + +commit a7cf8d322a4a687c9810a577cc92ff6b9725ecdc +Author: Fernando Herrera <fherrera@onirica.com> +Date: Thu Oct 7 17:28:31 2010 +0200 + + [glib] Fix introspection annotations for poppler_document_get_page*() + + Return value should be transfer full since the caller owns the only + reference. + + glib/poppler-document.cc | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +commit d690bea929553d1a4392d42d949843e9467ba8cb +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Oct 5 22:18:22 2010 +0100 + + Make sure obj is a num before reading it + + Not sure if using a 0 is correct otherwise, but if your matrix is + broken you're probably going to get a wrong rendering anyway, so who + cares. Bug #30590 + + poppler/Gfx.cc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit b17be2bc32cf71bac0473bf4ac16359e3027b4fc +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Oct 3 12:14:11 2010 +0200 + + [annots] Fix a crash when drawing square/circle annots without + a border + + Fixes bug #30580 + + poppler/Annot.cc | 121 + ++++++++++++++++++++++++++++--------------------------- + 1 file changed, 61 insertions(+), 60 deletions(-) + +commit e3d3944c1988343704e3ba3a5d60609719466afb +Author: Tomas Hoger <thoger@redhat.com> +Date: Wed Sep 29 20:03:45 2010 +0100 + + Fix uninitialized uses on DCTScanInfo + + poppler/Stream.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit f380647f09d88339c936184bbe86c70c0d47de4b +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 29 20:02:10 2010 +0100 + + Free names + + poppler/Catalog.cc | 1 + + 1 file changed, 1 insertion(+) + +commit aa0fd32a8501473832bce1b8b804dd3f9a45735b +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 27 22:39:09 2010 +0100 + + Consider render value when colorizing text + + Fixes bug 2807 + + poppler/CairoOutputDev.cc | 18 +++--------------- + poppler/CairoOutputDev.h | 2 -- + poppler/Gfx.cc | 21 +++++++++++++++++---- + poppler/PSOutputDev.cc | 26 ++++++++++---------------- + poppler/PSOutputDev.h | 3 +-- + poppler/SplashOutputDev.cc | 18 +++--------------- + poppler/SplashOutputDev.h | 4 +--- + 7 files changed, 35 insertions(+), 57 deletions(-) + +commit cf710b999b510203e9348ea9f04360be1fe957b8 +Author: Pino Toscano <pino@kde.org> +Date: Fri Sep 24 00:50:37 2010 +0200 + + [Qt4] enable the generation of the QCH file + + ... usable in Qt Assistant + + qt4/src/Doxyfile | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +commit be6d933071c9ab043f01f374a884472c4ce3007e +Author: Pino Toscano <pino@kde.org> +Date: Thu Sep 23 15:55:45 2010 +0200 + + update Doxyfile's for qt4 and cpp + + no changes in the actual configuration values + + cpp/Doxyfile | 155 ++++-- + qt4/src/Doxyfile | 1469 + +++++++++++++++++++++++++++++++++--------------------- + 2 files changed, 1018 insertions(+), 606 deletions(-) + +commit 721da3d542ab9b234b058f3c14ea9303d748107e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Sep 23 14:09:11 2010 +0200 + + [glib] Use g_memdup instead of g_strdup in poppler_document_get_id() + + Ids are not null-terminated strings, but fixed size byte arrays. + + glib/demo/info.cc | 8 ++++++-- + glib/poppler-document.cc | 33 ++++++++++++++------------------- + 2 files changed, 20 insertions(+), 21 deletions(-) + +commit 4ffc0ed73397e4e58f04c3577b093a3fd39c22bd +Author: Pino Toscano <pino@kde.org> +Date: Thu Sep 23 02:21:12 2010 +0200 + + [cpp] small clarification in document::load_from_data() apidox + + cpp/poppler-document.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 9491dc4a10706109d0f2b4d15f21b9a1db51d8c9 +Author: Pino Toscano <pino@kde.org> +Date: Thu Sep 23 02:18:07 2010 +0200 + + [cpp] add document::load_from_raw_data() + + ... to be able to load a document from an external data buffer, + with no need to copy the data. + + add as well a new document_private constructor to handle the new + situation, + and make sure to properly use the raw data when unlocking the document + + cpp/poppler-document-private.h | 5 ++++ + cpp/poppler-document.cpp | 53 + ++++++++++++++++++++++++++++++++++++++++++ + cpp/poppler-document.h | 4 ++++ + 3 files changed, 62 insertions(+) + +commit a3c1f2d5ea1de969e9aaaa84ee38866938b4ce0c +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 22 20:14:27 2010 +0100 + + fix copyright + + poppler/Form.cc | 1 + + poppler/Form.h | 1 + + 2 files changed, 2 insertions(+) + +commit 1aad013e353a9e59bdab8a1b4ce93f2ad7aaf4f2 +Author: Pino Toscano <pino@kde.org> +Date: Wed Sep 22 17:07:38 2010 +0200 + + update copyrights + + cpp/poppler-document.h | 2 +- + cpp/poppler-page-transition.cpp | 2 +- + cpp/poppler-private.cpp | 2 +- + cpp/poppler-rectangle.cpp | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +commit 2d6d66ebe0215df66e33cb5974c58c324fab50b6 +Author: Pino Toscano <pino@kde.org> +Date: Wed Sep 22 17:07:13 2010 +0200 + + [cpp/tests] poppler-dump: show the PDF IDs, if available + + cpp/tests/poppler-dump.cpp | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit e39fde1b62544b90e73a2fc3609a260991db3a47 +Author: Pino Toscano <pino@kde.org> +Date: Wed Sep 22 16:52:08 2010 +0200 + + [cpp] add document::get_pdf_id() + + ... to get the IDs of a PDF document, if present. + + cpp/poppler-document.cpp | 29 +++++++++++++++++++++++++++++ + cpp/poppler-document.h | 1 + + 2 files changed, 30 insertions(+) + +commit 299a1849a148fa0a7b3171c45ec68b9901aa93bb +Author: Pino Toscano <pino@kde.org> +Date: Wed Sep 22 16:36:30 2010 +0200 + + [Qt4] add Document::getPdfId() + + ... to get the IDs of a PDF document, if present. + + also, add two test cases for it in the metadata unit test + + qt4/src/poppler-document.cc | 16 ++++++++++++++ + qt4/src/poppler-qt4.h | 14 +++++++++++++ + qt4/tests/check_metadata.cpp | 50 + ++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 80 insertions(+) + +commit dd9bcdb720ac1bf8a022635bcbb3b56e4b75bb15 +Author: Pino Toscano <pino@kde.org> +Date: Wed Sep 22 16:29:46 2010 +0200 + + Make the internal get_id() not fail because of null bytes in the ID. + + Passing the const char* of the byte string to convert is not enough + if its length must be checked, + as it might fail when the string of the ID contains null bytes. + Instead, pass the original GooString so its size is properly checked. + + Also, remove an hardcoded 16 and make it dependent on pdfIdLength, + as used elsewhere in get_id() function. + + poppler/PDFDoc.cc | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +commit 9554cbc3cb4fc0cd7ad2295f5d27a18e030c6aee +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Sep 22 12:54:25 2010 +0200 + + [glib-demo] Show form field names in forms demo + + glib/demo/forms.c | 26 ++++++++++++++++++++------ + 1 file changed, 20 insertions(+), 6 deletions(-) + +commit 257634b26b682628dba5ee5f94cb0bad030bcb4f +Author: Mark Riedesel <mark@klowner.com> +Date: Wed Sep 22 12:52:49 2010 +0200 + + [glib] Add methods to get mapping, partial an fully qualified form + field names + + See bug #28780. + + glib/poppler-form-field.cc | 68 + +++++++++++++++++++++++++++++++++++++ + glib/poppler-form-field.h | 3 ++ + glib/reference/poppler-sections.txt | 3 ++ + 3 files changed, 74 insertions(+) + +commit 6db98abc59c154dcb18d69fc37e44ce804c3ccc9 +Author: Mark Riedesel <mark@klowner.com> +Date: Wed Sep 22 12:41:16 2010 +0200 + + Add getLabel method to FormWidget + + See bug #28780. + + poppler/Form.cc | 64 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Form.h | 8 ++++++++ + 2 files changed, 72 insertions(+) + +commit bcdca66fd57439735e0b9aa182ab7cfce29e9ed0 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Sep 21 11:49:37 2010 +0200 + + [glib] Fix minimum value of creation and modification date properties + + It should be -1 which means there's no date specified + + glib/poppler-document.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit d2578bd66129466b2dd114b6407c147598e09d2b +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 21 19:19:27 2010 +0100 + + Avoid loops in Form::fieldLookup + + Fixes crash in broken pdf provided by Joel Voss of Leviathan + Security Group + + poppler/Dict.h | 3 +++ + poppler/Form.cc | 27 ++++++++++++++++++++++++--- + 2 files changed, 27 insertions(+), 3 deletions(-) + +commit 2fe825deac055be82b220d0127169cb3d61387a8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 21 19:15:25 2010 +0100 + + Make sure obj1 is a num before reading it + + Fixes crash in broken pdf provided by Joel Voss of Leviathan + Security Group + + poppler/Gfx.cc | 20 ++++++++++++++++---- + 1 file changed, 16 insertions(+), 4 deletions(-) + +commit 473de6f88a055bb03470b4af5fa584be8cb5fda4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 21 19:11:42 2010 +0100 + + Fix memory leak if obj2 is not a dict + + Found thanks to PDF provided by Joel Voss of Leviathan Security Group + + poppler/Form.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 9706e28657ff7ea52aa69d9efb3f91d0cfaee70b +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 21 19:09:37 2010 +0100 + + Fix crash when idx is out of range + + Found thanks to PDF provided by Joel Voss of Leviathan Security Group + + poppler/Function.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 26a5817ffec9f05ac63db6c5cd5b1f0871d271c7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 21 19:08:54 2010 +0100 + + Fix crash when idx is out of range + + Fixes crash in broken pdf provided by Joel Voss of Leviathan + Security Group + + poppler/Function.cc | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit dfdf3602bde47d1be7788a44722c258bfa0c6d6e +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 21 19:07:12 2010 +0100 + + Give a value to color.c[i] + + Might not be the better solution but it's better than having a random + value there + + Found thanks to PDF provided by Joel Voss of Leviathan Security Group + + poppler/Gfx.cc | 8 ++++++++ + 1 file changed, 8 insertions(+) + +commit 01c85c08305bae16242f5979ab107fa5bb5f5100 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 21 19:04:37 2010 +0100 + + Forgot my (C) here + + poppler/Decrypt.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit bf2055088a3a2d3bb3d3c37d464954ec1a25771f +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 21 19:03:19 2010 +0100 + + Properly initialize stack + + Fixes crash in broken pdf provided by Joel Voss of Leviathan + Security Group + + poppler/Function.cc | 1 + + 1 file changed, 1 insertion(+) + +commit e853106b58d6b4b0467dbd6436c9bb1cfbd372cf +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 21 19:01:36 2010 +0100 + + Properly initialize parser + + Fixes crash in broken pdf provided by Joel Voss of Leviathan + Security Group + + poppler/Gfx.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 3422638b2a39cbdd33a114a7d7debc0a5f688501 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 21 18:58:43 2010 +0100 + + Fix crash in broken pdf (parser->getStream() is 0) + + Found thanks to PDF provided by Joel Voss of Leviathan Security Group + + poppler/Gfx.cc | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +commit a2dab0238a69240dad08eca2083110b52ce488b7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 21 18:55:51 2010 +0100 + + Initialize properly charactersRead + + It is possible that there are calls to getPos before reset + Found thanks to PDF provided by Joel Voss of Leviathan Security Group + + poppler/Decrypt.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 39d140bfc0b8239bdd96d6a55842034ae5c05473 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 21 18:54:31 2010 +0100 + + Fix crash in broken pdf (code < 0) + + Found thanks to PDF provided by Joel Voss of Leviathan Security Group + + fofi/FoFiType1.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit c6a091512745771894b54a71613fd6b5ca1adcb3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 21 18:50:25 2010 +0100 + + Fix memory leak + + Found thanks to PDF provided by Joel Voss of Leviathan Security Group + + poppler/Stream.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 9b6ddb68b80ef19cd2615900bd24da76374003d9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 20 19:47:47 2010 +0100 + + Fix copyright + + poppler/PDFDoc.cc | 1 + + poppler/PDFDoc.h | 1 + + 2 files changed, 2 insertions(+) + +commit fa3abc23656204eedd022ee1c73d9e5af758cdac +Author: Pino Toscano <pino@kde.org> +Date: Fri Sep 17 22:20:09 2010 +0200 + + [cpp] More bits of API documentation. + + cpp/poppler-global.cpp | 124 + ++++++++++++++++++++++++++++++++++++++++ + cpp/poppler-page-transition.cpp | 32 +++++++++++ + cpp/poppler-rectangle.cpp | 19 ++++++ + 3 files changed, 175 insertions(+) + +commit c5f7b5becc9993c05b67a470d5a1e431806b98d6 +Author: Pino Toscano <pino@kde.org> +Date: Fri Sep 17 20:26:37 2010 +0200 + + update copyrights + + qt4/src/poppler-private.cc | 2 +- + qt4/tests/check_strings.cpp | 18 ++++++++++++++++++ + 2 files changed, 19 insertions(+), 1 deletion(-) + +commit ae517042570327b860c1db6b68f9697d5c104657 +Author: Pino Toscano <pino@kde.org> +Date: Fri Sep 17 19:39:10 2010 +0200 + + [cpp] improve a bit the Unicode* -> ustring conversion + + (although IMHO not yet solved) + + cpp/poppler-private.cpp | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit f4c6ef88f01f6763943a3e6e006e52dbea0b149c +Author: Pino Toscano <pino@kde.org> +Date: Fri Sep 17 16:07:05 2010 +0200 + + [Qt4/tests] check_strings: add a new test case for + QStringToUnicodeGooString + + not much test data at the moment though + + qt4/tests/check_strings.cpp | 37 +++++++++++++++++++++++++++++++++++++ + 1 file changed, 37 insertions(+) + +commit ffd227b7669895325d752009d5185973cf86ce5b +Author: Pino Toscano <pino@kde.org> +Date: Fri Sep 17 14:25:57 2010 +0200 + + [Qt4] optimize UnicodeParsedString using less memory from QString + + - reserve() the right number of chars in the result string, so there + is less possibility to make it gr + ow its buffer + - do not call unicodeToQString() just to create a 1 character string, + but directly append a QChar crea + ted with the resulting unicode value (always belonging to the BMP) + + this should reduce of a very little bit the memory usage, while give + a sensible speedup of UnicodeParsedString invocations + + qt4/src/poppler-private.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 6180890008f2b1814f092f50b8f75376399905ba +Author: Pino Toscano <pino@kde.org> +Date: Fri Sep 17 13:23:25 2010 +0200 + + [Qt4/tests] check_strings: add a test case for UnicodeParsedString + + very simple test data for it, at the moment + + qt4/tests/check_strings.cpp | 48 + +++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 48 insertions(+) + +commit c5f78d7d3953d62a746c6f5a90085ea020fe5ec7 +Author: Pino Toscano <pino@kde.org> +Date: Fri Sep 17 12:54:32 2010 +0200 + + [Qt4/tests] check_string: use a pool of GooString + + this way we can reuse the GooString in a data set even after a test + run (eg in benchmarks), + making sure they all are properly freed + + qt4/tests/check_strings.cpp | 35 ++++++++++++++++++++++++++++++----- + 1 file changed, 30 insertions(+), 5 deletions(-) + +commit 0cd5a256bdf7778c0c720941a611ad8ab56fa2e9 +Author: Pino Toscano <pino@kde.org> +Date: Fri Sep 17 00:27:53 2010 +0200 + + [Qt4/tests] first version of a unit test for strings + + this is used for testing the various string conversions: + - unicodeToQString + - UnicodeParsedString + - QStringToUnicodeGooString + - QStringToGooString + the 1st and the 4th have basic tests + + given private symbols are used, this unit test is not compiled on + windows (at least, it supposed to be so) + + qt4/tests/CMakeLists.txt | 3 ++ + qt4/tests/Makefile.am | 7 ++- + qt4/tests/check_strings.cpp | 101 + ++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 110 insertions(+), 1 deletion(-) + +commit c6e8b21c9829672e6ca42e6cdc0ca631a06af73f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Sep 17 13:44:38 2010 +0200 + + [glib] docs: Document PopplerDocument properties + + glib/poppler-document.cc | 380 + +++++++++++++++++++++++++++-------------------- + 1 file changed, 223 insertions(+), 157 deletions(-) + +commit d4a6c17255821925906c17b79b88eebed9edfee1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Sep 17 13:04:33 2010 +0200 + + [glib] Add accessor for all PopplerDocument properties + + PopplerDocument:linearized is now a boolean value rather than string, + so this commit breaks the API again. + + glib/demo/info.cc | 8 +- + glib/poppler-document.cc | 532 + +++++++++++++++++++++++++++++------- + glib/poppler-document.h | 74 +++-- + glib/reference/poppler-sections.txt | 16 ++ + 4 files changed, 498 insertions(+), 132 deletions(-) + +commit a5fec843dbb40fdd2007b926405b96789b21496d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Sep 17 10:38:14 2010 +0200 + + [glib-demo] Show permanent/update ID in document info demo + + glib/demo/info.cc | 9 +++++++++ + 1 file changed, 9 insertions(+) + +commit bfaf8f3cc62f28c6255d42680b9464ab9973737e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Sep 17 10:37:32 2010 +0200 + + [glib] Add poppler_document_get_id() to get the PDF file identifier + + glib/poppler-document.cc | 52 + +++++++++++++++++++++++++++++++++++++ + glib/poppler-document.h | 3 +++ + glib/reference/poppler-sections.txt | 1 + + 3 files changed, 56 insertions(+) + +commit b15641677447b2e89853a667fc34bcca1383a97a +Author: srinivas adicherla <srinivas.adicherla@gmail.com> +Date: Fri Sep 17 10:36:22 2010 +0200 + + Add a method to get the PDF file identifier + + poppler/PDFDoc.cc | 65 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/PDFDoc.h | 3 +++ + 2 files changed, 68 insertions(+) + +commit 3b4a901a4431814590449b6cd5ea418f4d6c1172 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 16 23:23:03 2010 +0100 + + Add -s option + + Writes a single html file + Since git does not allow multiple authors i'm adding them here + OSSD CDAC Mumbai by Leena Chourey (leenac@cdacmumbai.in) and Onkar + Potdar (onkar@cdacmumbai.in) + + utils/HtmlFonts.cc | 11 +++++-- + utils/HtmlFonts.h | 18 +++++++++-- + utils/HtmlOutputDev.cc | 84 + +++++++++++++++++++++++++++++++------------------- + utils/pdftohtml.1 | 3 ++ + utils/pdftohtml.cc | 15 +++++++-- + 5 files changed, 93 insertions(+), 38 deletions(-) + +commit 2792330f6caeeb42e2996271456b562489215c4c +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 15 22:42:09 2010 +0100 + + new soversions + + CMakeLists.txt | 2 +- + cpp/CMakeLists.txt | 2 +- + cpp/Makefile.am | 2 +- + glib/CMakeLists.txt | 2 +- + glib/Makefile.am | 4 ++-- + poppler/Makefile.am | 2 +- + qt4/src/CMakeLists.txt | 2 +- + qt4/src/Makefile.am | 2 +- + 8 files changed, 9 insertions(+), 9 deletions(-) + +commit 1cf56c732b63d0a310bc45b8e4b3f3f357a42cb1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 15 20:56:42 2010 +0100 + + 0.15.0 in the versions + + CMakeLists.txt | 2 +- + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +commit 4ec0be498b557c3cf631e43823c6d7004304dff3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 15 20:56:34 2010 +0100 + + 0.15.0 NEWS + + NEWS | 90 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 90 insertions(+) + +commit c01a17745c04aef3e6f2225679c867a03e731e83 +Author: Pino Toscano <pino@kde.org> +Date: Thu Sep 16 20:55:56 2010 +0200 + + [CMake] disable the GObject introspection system + + it cannot complete the scanning propecure correctly without libtool + it seems + + CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 9be7d3143b12f291409f88f3d725a239934b205e +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 15 19:19:30 2010 +0100 + + update copyright + + poppler/OptionalContent.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit b9333529bba43a71655fdbf1919ba515f7df9ca3 +Author: Pino Toscano <pino@kde.org> +Date: Wed Sep 15 17:23:54 2010 +0200 + + [cpp/tests] poppler-dump: convert out_ustring() to an + operator<<(std::ostream&) + + so we have a chance to better output the bytearray of a string to + the stream + + cpp/tests/poppler-dump.cpp | 26 ++++++++++++++++++-------- + 1 file changed, 18 insertions(+), 8 deletions(-) + +commit a44f711b4412332875337e9fb7509f18db806ddc +Author: Pino Toscano <pino@kde.org> +Date: Wed Sep 15 16:44:30 2010 +0200 + + [cpp/tests] poppler-dump: add a "--show-text <physical|raw>" option + + ... to show the text of a page in the specified layout + + cpp/tests/poppler-dump.cpp | 29 +++++++++++++++++++++++++++++ + 1 file changed, 29 insertions(+) + +commit 0094c9372b5b439af2564d83d6fb7439f4bdba88 +Author: Pino Toscano <pino@kde.org> +Date: Wed Sep 15 13:19:13 2010 +0200 + + [cpp] add a new page::text() for specifying a layout mode + + add a new text_layout_enum enum for the layout mode, used by the + new text() + make the old text() implementation call the new one with the old value + (= physical) + add & adapt the apidox accordingly + + cpp/poppler-page.cpp | 27 +++++++++++++++++++++++++-- + cpp/poppler-page.h | 5 +++++ + 2 files changed, 30 insertions(+), 2 deletions(-) + +commit 4ec3e7784cdba5c0720b1992ba500e97a7e0ed2b +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Sep 15 11:24:07 2010 +0200 + + Set initial state of optional content groups based on BaseState field + + There's a test case using BaseState attached to bug #30106 + + poppler/OptionalContent.cc | 14 +++++++++----- + 1 file changed, 9 insertions(+), 5 deletions(-) + +commit f49aa86812ed8ad91d41c675bc670b3d88d3444a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Sep 13 14:37:10 2010 +0200 + + [glib] doc: Document PopplerPage:label property + + glib/poppler-page.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit f41fe7ae6e374100574c49d1bb7a3ddc646786c8 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Sep 13 14:36:43 2010 +0200 + + [glib] doc: Add poppler_page_get_label to poppler-sections.txt + + glib/reference/poppler-sections.txt | 1 + + 1 file changed, 1 insertion(+) + +commit 91b8246766a8e5d9cca385b5854667d7967a9d71 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Sep 13 14:22:56 2010 +0200 + + [glib-demo] Use poppler_page_get_label() instead of g_object_get() + + glib/demo/page.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit b82412ef86091f4d249c818cebf00e4c59bae311 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Sep 13 14:22:03 2010 +0200 + + [glib] Add poppler_page_get_label() + + It's just an accessor for the property label + + glib/poppler-page.cc | 47 ++++++++++++++++++++++++++++++++++------------- + glib/poppler-page.h | 1 + + 2 files changed, 35 insertions(+), 13 deletions(-) + +commit ff88abf61f4bf90ad276a8593be1818d39c8ecac +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Sep 13 10:05:45 2010 +0200 + + [glib] Avoid core headers to be parsed by the g-i scanner + + glib/poppler-document.cc | 2 ++ + glib/poppler-page.cc | 2 ++ + glib/poppler-private.h | 3 +++ + 3 files changed, 7 insertions(+) + +commit 53324502898ae5fbbb21a4fb819e4a84acdc1a64 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 12 11:42:03 2010 +0200 + + [glib] Fix a crash when building layer actions + + Some layers are just the parent of others, but not actually a layer so + they don't have an optional content object. Fixes bug #30106. + + glib/poppler-action.cc | 15 +++++++++------ + 1 file changed, 9 insertions(+), 6 deletions(-) + +commit dfc6ea7877635212aa7c5f7ade07af4aa9467e96 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 12 11:36:58 2010 +0200 + + [glib] Fix layers array generation when it contains multiple arrays + + Fixes layers for document attached to bug #30106. + + glib/poppler-document.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 7574912b6c0ff0421c69b6e8c6835957d5126d7d +Author: Jonathan Liu <net147@gmail.com> +Date: Thu Sep 9 20:34:03 2010 +0100 + + Fix checking whether _WIN32 is defined + + Bug 29329 + + poppler/StdinCachedFile.cc | 2 +- + utils/pdftoppm.cc | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 2fc83068c32e09fa3de03a157a420490431ea706 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 5 14:26:27 2010 +0100 + + Increase the number of cached glyphs for small sizes + + Should not increase memory usage much and gives me a 17% speed + increase + in the firefox nytimes advertisment pdf + + splash/SplashFont.cc | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +commit 0d96f74f31171c58a55e4ac36d492ce36dd5e7c5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 5 12:31:57 2010 +0100 + + Use std::sort instead of qsort + + Gives a nice speed improvement without any real code change + Passes regression tests + Based on Paweł Wiejacha patches + + poppler/GfxFont.cc | 17 +++++++--------- + splash/SplashXPath.cc | 48 + ++++++++++++++++++++++++++++---------------- + splash/SplashXPathScanner.cc | 10 +++++---- + 3 files changed, 44 insertions(+), 31 deletions(-) + +commit 3b4816b2b8caa0e2baafbe4c0eb1e45e452d01ce +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 1 20:43:35 2010 +0100 + + forgot the file + + qt4/tests/poppler-texts.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 40 insertions(+) + +commit b0db93c71a83946aa3e02bae6b396223dcca19d1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 1 20:43:14 2010 +0100 + + add since and rename enum + + qt4/src/poppler-page.cc | 2 +- + qt4/src/poppler-qt4.h | 5 ++++- + 2 files changed, 5 insertions(+), 2 deletions(-) + +commit a86f9d90be99a36c41c6932fb4d9a202c4ff6d05 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 1 20:20:48 2010 +0100 + + Clarify the ownership + + qt4/src/poppler-qt4.h | 2 ++ + 1 file changed, 2 insertions(+) + +commit 33ad3a17ac26879fcd6a7fad2023dd219bc5919f +Author: Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Wed Sep 1 20:19:54 2010 +0100 + + Add a way to access the raw text + + poppler/TextOutputDev.cc | 23 ++++++++++++++++++++--- + qt4/src/poppler-page.cc | 11 +++++++++-- + qt4/src/poppler-qt4.h | 19 +++++++++++++++++++ + qt4/tests/CMakeLists.txt | 1 + + qt4/tests/Makefile.am | 7 ++++++- + 5 files changed, 55 insertions(+), 6 deletions(-) + +commit 46e89248b3c5b1789baa3bd9bfa012570720ddb5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 1 19:54:02 2010 +0100 + + quadding is not a GBool but an int + + poppler/Annot.cc | 2 +- + poppler/Annot.h | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit ae79fc504c5424be2fa21dbc5498ced4db6e5dd3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 31 22:14:57 2010 +0100 + + Make GBool a bool instead of an int + + Passes the regression tests and might make things faster and use a bit + less memory + + cpp/tests/CMakeLists.txt | 2 +- + cpp/tests/Makefile.am | 2 +- + goo/gtypes.h | 7 +- + utils/CMakeLists.txt | 2 +- + utils/Makefile.am | 2 +- + utils/parseargs.c | 208 + ----------------------------------------------- + utils/parseargs.cc | 208 + +++++++++++++++++++++++++++++++++++++++++++++++ + 7 files changed, 216 insertions(+), 215 deletions(-) + +commit d3f32f2c4f9f46620c0287c44bef686f340461f3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 31 18:51:17 2010 +0100 + + Read from the correct variable + + Fixes crash on KDE bug 249586 + + poppler/Movie.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 681bb38eafc720b309172ed7c650439c559663a0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 26 23:55:58 2010 +0100 + + Make declaration match what there is in the .cc file + + poppler/TextOutputDev.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit c91e869304fc263c52f21ee484a57a6f1900f6b2 +Author: Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> +Date: Thu Aug 26 19:40:46 2010 +0100 + + Add -r option to pdftohtml + + Fixes bug 29551 + + utils/pdftohtml.1 | 3 +++ + utils/pdftohtml.cc | 18 +++++++++++++----- + 2 files changed, 16 insertions(+), 5 deletions(-) + +commit 9b4be586640b4ad344b1b3ed4c9cda8351257f0c +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 25 19:26:30 2010 +0100 + + Use 3 not nComps + + poppler/GfxState.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 218f67c527fb41babf2703ba068d072f8326e37b +Author: Paweł Wiejacha <pawel.wiejacha@gmail.com> +Date: Tue Aug 24 23:47:06 2010 +0100 + + Make SplashOutputDev::imageSrc faster + + By using getRGBLine when possible + + poppler/SplashOutputDev.cc | 39 ++++++++++++++++++++++++++++++--------- + 1 file changed, 30 insertions(+), 9 deletions(-) + +commit 868f4a1f22051b7978f47a0614f23fd66dbb7ca8 +Author: Paweł Wiejacha <pawel.wiejacha@gmail.com> +Date: Tue Aug 24 23:35:21 2010 +0100 + + Make GfxICCBasedColorSpace::getRGBLine faster + + By calling doTransform less + + poppler/GfxState.cc | 15 +++++++-------- + poppler/GfxState.h | 4 +++- + 2 files changed, 10 insertions(+), 9 deletions(-) + +commit 46e37c54c6365cf37dc1e223a3c146e7b96a56af +Author: Paweł Wiejacha <pawel.wiejacha@gmail.com> +Date: Tue Aug 24 21:23:34 2010 +0100 + + Do not call pow three times when one is enough + + poppler/GfxState.cc | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +commit 8591c804598576556c6d24a66b6648de8ed1c4eb +Author: Mike Slegeir <tehpola@yahoo.com> +Date: Sun Aug 22 22:01:03 2010 +0100 + + Use splash instead of external gs invocation to render the background + + Patch in bug 19404, should fix 9746 too + + utils/pdftohtml.1 | 8 +- + utils/pdftohtml.cc | 210 + ++++++++++++++++++++++++++++++++++++++--------------- + 2 files changed, 158 insertions(+), 60 deletions(-) + +commit 7fc3c21a8c5d6cf8517100427b182887a9569ed0 +Author: Ilya Gorenbein <igorenbein@finjan.com> +Date: Fri Aug 20 20:24:31 2010 +0100 + + Fix failure to parse PDF with damaged internal structure + + Patch in bug 29189, fixes bug 3870 + + poppler/PDFDoc.cc | 24 +++++++++++++---- + poppler/XRef.cc | 80 + ++++++++++++++++++++++++++++++++----------------------- + poppler/XRef.h | 5 ++-- + 3 files changed, 68 insertions(+), 41 deletions(-) + +commit bedf48d4397ae412a6d28fc8fea16cc23a29f07c +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 17 22:02:59 2010 +0100 + + use memset instead of a for + + splash/Splash.cc | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +commit 03ca5b4a5c9964d9c0e9913eb2061692848c4b95 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 10 19:55:31 2010 +0100 + + Update copyrights + + goo/GooTimer.cc | 1 + + goo/GooTimer.h | 1 + + goo/gfile.cc | 2 +- + poppler/DCTStream.cc | 1 + + poppler/DCTStream.h | 1 + + poppler/GfxState.cc | 2 +- + poppler/Page.cc | 2 +- + qt4/src/poppler-annotation.cc | 2 +- + 8 files changed, 8 insertions(+), 4 deletions(-) + +commit 3bca8ddc10bf4291bf0c0e39c67341a05953e949 +Author: Jonathan Liu <net147@gmail.com> +Date: Tue Aug 10 19:42:40 2010 +0100 + + Tell windows we are writing/reading binary data + + Bug #29329 + + poppler/StdinCachedFile.cc | 9 +++++++++ + utils/pdftoppm.cc | 9 +++++++++ + 2 files changed, 18 insertions(+) + +commit bdd617f2177a7836f6b6686fde892664513a32a7 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Aug 3 13:05:26 2010 +0200 + + [glib] Fix a crash when a layer doesn't have a name + + Fixes bug #28842. + + glib/poppler-layer.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit e9f0646ca664cc27825f7e084f8419fe0de1fcfc +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Aug 3 13:02:52 2010 +0200 + + Catalog page array might contain NULL for some pages in invalid + documents + + Fixes a crash reproducible with gtk-splash-test when opening document + attached to bug #28842. + + poppler/PDFDoc.cc | 27 +++++++++++++++------------ + 1 file changed, 15 insertions(+), 12 deletions(-) + +commit 842209782ca3ba8c1c783cccf565372a18b3fda5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 30 19:29:12 2010 +0100 + + Do not crash when using pdftops in some files + + Fixes crash in file in kde bug 246269. The output is still wrong + though + + fofi/FoFiType1C.cc | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +commit 0dd7c80b7baf2622eb4780a867c4dc6291773f3b +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 26 23:58:26 2010 +0100 + + Do not overwrite the rgb values + + Recommended by Koji Otani in Re: [poppler] Question about code + Passed the regression testing in my files + + poppler/GfxState.cc | 1 - + 1 file changed, 1 deletion(-) + +commit 627edf88c8f5c073a68bd05990df56e1af547292 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jul 25 13:56:03 2010 +0200 + + [annots] Fix a crash when adding a new annotation and annots object + is an array + + When annots object is an array instead of a ref, the modified + object is + actually de page object. + + poppler/Page.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 5d86f9b600b1e10de93bcaf1b925fadbc2a47522 +Author: mpsuzuki <mpsuzuki@hiroshima-u.ac.jp> +Date: Sat Jul 24 15:12:05 2010 +0100 + + reindent correctly + + poppler/TextOutputDev.cc | 34 +++++++++++++++++----------------- + 1 file changed, 17 insertions(+), 17 deletions(-) + +commit d0a6f9abdab88ec43004b6766337db304cbf6a25 +Author: Pino Toscano <pino@kde.org> +Date: Thu Jul 22 21:28:55 2010 +0200 + + [CMake] improve the way include dirs and cflags for gdk and gtk + are set + + correctly include_directories() for the include dirs, while add the + cflags which are not include dirs as definitions + + glib/CMakeLists.txt | 5 +++-- + glib/demo/CMakeLists.txt | 5 ++++- + 2 files changed, 7 insertions(+), 3 deletions(-) + +commit 02d85dd2cc154dbb6caa04a349532033d833edd1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jul 20 13:53:56 2010 +0200 + + [glib-demo] Add support for adding annots in annot demo + + glib/demo/annots.c | 114 + +++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 114 insertions(+) + +commit 969cb850f5c2bc31de82c591b2b3210b5cfabf5f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jul 20 13:53:29 2010 +0200 + + [glib] docs: Add new symbols to poppler-sections.txt + + glib/reference/poppler-sections.txt | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +commit 251959438b6257fe71ed58e79eec60cda68a66cf +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jul 20 13:53:00 2010 +0200 + + [glib] Add poppler_page_add_annot() + + glib/poppler-document.cc | 7 ++++--- + glib/poppler-page.cc | 19 +++++++++++++++++++ + glib/poppler-page.h | 2 ++ + 3 files changed, 25 insertions(+), 3 deletions(-) + +commit 78a4f6976e708f2cc23aac49fbff0faf00e74bc3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jul 20 13:51:16 2010 +0200 + + [glib] annots: Add several setter methods + + glib/poppler-annot.cc | 278 + ++++++++++++++++++++++++++++++++++++++++++++----- + glib/poppler-annot.h | 26 +++++ + glib/poppler-private.h | 6 ++ + 3 files changed, 285 insertions(+), 25 deletions(-) + +commit fee488c9db60ab691ce9ff5eef284be2af897aee +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jul 18 11:26:59 2010 +0200 + + [annots] Add AnnotMarkup::setOpacity + + poppler/Annot.cc | 8 ++++++++ + poppler/Annot.h | 1 + + 2 files changed, 9 insertions(+) + +commit d15a355ede2d8510c4df847ea0b92b5357b29914 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jul 18 09:57:35 2010 +0200 + + Set the page reference (P in annot dict) when adding a new annot to + a page + + poppler/Annot.cc | 9 +++++++++ + poppler/Annot.h | 3 +++ + poppler/Page.cc | 2 ++ + 3 files changed, 14 insertions(+) + +commit 49ffb46db3118db874d2d9830bb034762d625c61 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 19 16:31:54 2010 +0100 + + Remove exception support + + We don't use it and don't even support it properly + + CMakeLists.txt | 1 - + config.h.cmake | 3 --- + configure.ac | 4 --- + goo/gmem.cc | 56 + ++++++++++++------------------------------ + goo/gmem.h | 38 +++++++++------------------- + poppler/poppler-config.h.cmake | 5 ---- + poppler/poppler-config.h.in | 5 ---- + 7 files changed, 27 insertions(+), 85 deletions(-) + +commit dd2e9399868e3dbf2fa4ede050f8d74d29ebbbb4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 19 16:31:43 2010 +0100 + + add uninstalled.pc to ignore + + .gitignore | 7 +++++++ + 1 file changed, 7 insertions(+) + +commit d1033006aae381a0f075e02d54638a1af997caf3 +Author: Pino Toscano <pino@kde.org> +Date: Sat Jul 17 21:46:14 2010 +0200 + + add FindGObjectIntrospection.cmake and + GObjectIntrospectionMacros.cmake to the dist + + Makefile.am | 2 ++ + 1 file changed, 2 insertions(+) + +commit ce8d03950736cc35d035a44a7d88e5f2a9defa74 +Author: Pino Toscano <pino@kde.org> +Date: Sat Jul 17 21:39:08 2010 +0200 + + [CMake/glib] add support for gobject-introspection + + other than a module to find (using pkg-config) gobject-introspection, + this adds a macro (gir_add_introspections) to add new introspections + in a directory. + its working is much similar (even the variable names used) to + the Makefile version provided by gobject-repository itself, with + the notable difference of a disabled libtool in the g-ir-scanner + invocation. + the only additional step needed is adding two custom targets, compiled + by ALL, which have the gir and the typelib files as dependencies, + to make them build with the usual `make all'. + + CMakeLists.txt | 5 +- + cmake/modules/FindGObjectIntrospection.cmake | 61 +++++++++++++++++ + cmake/modules/GObjectIntrospectionMacros.cmake | 94 + ++++++++++++++++++++++++++ + glib/CMakeLists.txt | 36 ++++++++++ + 4 files changed, 194 insertions(+), 2 deletions(-) + +commit 78bf43d8e11aa52db9862af118c597e117d31083 +Author: Pino Toscano <pino@kde.org> +Date: Sat Jul 17 20:28:58 2010 +0200 + + [CMake] properly use the glib2 include dirs + + properly use GLIB2_INCLUDE_DIRS (pkg-config result) for the glib + include dirs, + while turn GLIB2_CFLAGS into GLIB2_CFLAGS_OTHERS to add the remaining + CFLAGS as definitions + + glib/CMakeLists.txt | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 6f3082d677bc62aa3f8124132e3e337c01be2629 +Author: Pino Toscano <pino@kde.org> +Date: Sat Jul 17 19:28:09 2010 +0200 + + [CMake] split the generated sources of poppler_glib_SRCS in an own + poppler_glib_generated_SRCS + + glib/CMakeLists.txt | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 2a252dd9b05857bbd10dee235e873886fc74ec17 +Author: Pino Toscano <pino@kde.org> +Date: Sat Jul 17 14:57:38 2010 +0200 + + [CMake] add stub message and TODO for the gobject-introspection + support + + CMakeLists.txt | 3 +++ + 1 file changed, 3 insertions(+) + +commit 8a3d1794a8ef5d525bb454755fec018e3fcb3816 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 16 14:00:32 2010 +0100 + + update + + TODO | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 31ac578942b82cbd16b064abca586ccb89dfa7ce +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 15 15:05:10 2010 +0200 + + Rework ChangeLog generation to fix make distcheck + + Makefile.am | 22 +++++++++++++++++++--- + 1 file changed, 19 insertions(+), 3 deletions(-) + +commit 5da5825ecab63089a19aac694826271019a94e6d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 15 15:03:20 2010 +0200 + + [glib] docs: Add version.xml to content_files var + + glib/reference/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit fe69b474ae63c9d5d2538db9e51e666dd6ea9fb3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jul 15 10:51:21 2010 +0100 + + Fix padding of names + + The previous method returned 2 for documents with 100 pages, which + is wrong as 100 needs 3 + characters, not 2 + + utils/pdftoppm.cc | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +commit e265ae2d8a46df00ab1bbd863f01f652068d265f +Author: Brian Cameron <brian.cameron@oracle.com> +Date: Wed Jul 14 20:26:25 2010 +0100 + + Add uninstalled .pc file for poppler when using autoconf + + Makefile.am | 9 ++++++++- + configure.ac | 9 ++++++++- + poppler-cairo-uninstalled.pc.in | 6 ++++++ + poppler-cpp-uninstalled.pc.in | 7 +++++++ + poppler-glib-uninstalled.pc.in | 7 +++++++ + poppler-qt-uninstalled.pc.in | 7 +++++++ + poppler-qt4-uninstalled.pc.in | 7 +++++++ + poppler-splash-uninstalled.pc.in | 7 +++++++ + poppler-uninstalled.pc.in | 6 ++++++ + 9 files changed, 63 insertions(+), 2 deletions(-) + +commit 552ab99e60fe4068be8e4e415924e4be289e47cd +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jul 13 10:18:01 2010 +0200 + + Handle ColorTransform in DCT streams when using libjpeg + + Fixes bug #28873. + + poppler/DCTStream.cc | 30 ++++++++++++++++++++++++++++++ + poppler/DCTStream.h | 1 + + 2 files changed, 31 insertions(+) + +commit 8a6697f89625106f3c373dbc7b4dc521e22502f7 +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Jul 3 16:42:04 2010 +0200 + + Only define findModifier() when used + + Prevents a warning when building with win32 font backend. + + poppler/GlobalParams.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit b1fdb87a4ebb5079c731256cce1870de8c54c65d +Author: Hib Eris <hib@hiberis.nl> +Date: Fri Jul 2 10:53:20 2010 +0200 + + Fix compile warnings on auto imports for mingw compiler + + cpp/Makefile.am | 2 +- + cpp/tests/Makefile.am | 2 ++ + glib/Makefile.am | 2 ++ + poppler/Makefile.am | 2 +- + qt4/demos/Makefile.am | 2 ++ + qt4/src/Makefile.am | 2 +- + qt4/tests/Makefile.am | 2 ++ + 7 files changed, 11 insertions(+), 3 deletions(-) + +commit 9e577110134eb1e093e697b7504efca759000086 +Author: Hib Eris <hib@hiberis.nl> +Date: Fri Jul 2 10:51:24 2010 +0200 + + Check for declaration of gettimeofday() + + The function gettimeofday() is not declared in ansi mode with the + mingw compiler, even though the function exists. Therefore, + configure must + not only check with AC_CHECK_FUNC, but also with AC_CHECK_DECL. + + Also, the checks must run in a C++ context because that is where + gettimeofday() is used. + + configure.ac | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +commit 58c8430ac584f3ba5e97aceb148e6287bfc45f95 +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Jun 30 15:06:44 2010 +0200 + + Set -ansi compiler flag early in configure.ac + + The -ansi compiler flag does not enable warnings, but turns of certain + features of GCC. To force feature tests to use this flag, it should be + set early in configure.ac + + This is important for the mingw compiler where header files refrain + from declaring certain function (e.g. gettimeofday()) when the -ansi + flag is set. + + configure.ac | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +commit e3663a855a9c86f0a3988a7a50fa40d37d0ea069 +Author: Hib Eris <hib@hiberis.nl> +Date: Fri Jul 2 14:45:15 2010 +0200 + + Use MAX_PATH instead of _MAX_PATH everywhere + + _MAX_PATH is compiler specific and not availble with the mingw + compiler + in ansi mode. MAX_PATH is in the Windows api and thus always available + when windows.h is included. + + goo/gfile.cc | 4 ++-- + poppler/GlobalParams.cc | 2 +- + poppler/PDFDoc.cc | 4 ++-- + 3 files changed, 5 insertions(+), 5 deletions(-) + +commit 7227c407d23a37f5d95e6c01cb7411be2f82ca85 +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Jun 30 16:15:06 2010 +0200 + + Check for _WIN32 instead of _MSC_VER + + goo/GooTimer.cc | 6 +++--- + goo/GooTimer.h | 4 ++-- + 2 files changed, 5 insertions(+), 5 deletions(-) + +commit 34e727e011529be312313a1f4d4fa1ba9c545888 +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Jun 29 16:43:31 2010 +0200 + + Fix cross compiling for Windows with autotools + + When cross compiling for Windows with autotools, libtool creates + libpoppler_qt4_la-poppler-optcontent.lo instead of + poppler-optcontent.lo. Thus, explicitly using poppler-optcontent.lo to + create poppler-optcontent.moc does not work well. + + qt4/src/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1bc2f4501ea4e56ca99ae4d94d6cf34cf33c2c7a +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Jun 29 15:34:22 2010 +0200 + + define poppler_qt4_EXPORTS when building with autotools + + Lets you build the qt4 bindings for Windows with automake/autoconf. + + qt4/src/Makefile.am | 3 +++ + 1 file changed, 3 insertions(+) + +commit 5825114a26cc6eece2e556063f640dda53ea1e11 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jul 11 12:24:20 2010 +0100 + + Compile++ + + glib/demo/CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit 5e4d8eeea0b9dba68420c164975418c76a53be85 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jul 10 15:54:28 2010 +0200 + + [pdf-inspector] Do not render for printing + + test/pdf-inspector.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit e6824972a213a888ca0185b7ae0a75fc23f75797 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jul 10 15:52:15 2010 +0200 + + [annots] Use a transparency group for markup annots without AP and + opacity != 1 + + Fixes bug #623616. + + poppler/Annot.cc | 346 + +++++++++++++++++++++++++------------------------------ + poppler/Annot.h | 3 + + poppler/Gfx.cc | 9 +- + poppler/Gfx.h | 2 +- + 4 files changed, 165 insertions(+), 195 deletions(-) + +commit 70ce0b6ea1a0d61f5048d2ae49c639d74a643b29 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jul 9 17:04:00 2010 +0200 + + [annots] Clamp QuadPoints coords to annot rectangle instead of + ignore points + + Fixes appearance stream generation for document attached to bug + #623616. + + poppler/Annot.cc | 38 +++++++++++++++++++++----------------- + 1 file changed, 21 insertions(+), 17 deletions(-) + +commit 8a9e561bfe64f71e9f38c43e5c6be7e5069b2349 +Author: Hib Eris <hib@hiberis.nl> +Date: Fri Jul 2 21:07:53 2010 +0200 + + Nicer autogen.sh output + + autogen.sh | 1 + + 1 file changed, 1 insertion(+) + +commit ce4d328294cea73f4b7368691dc1fed6bd45d569 +Author: Hib Eris <hib@hiberis.nl> +Date: Fri Jul 2 20:51:47 2010 +0200 + + Add option for autogen.sh to skip configure + + If you do not want to automatically run configure when calling + autogen.sh, run it with: + + $ NOCONFIGURE=1 ./autogen.sh + + This feature is modeled after gnome-autogen.sh behaviour. + + autogen.sh | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit d7ee87c5d0a35c8d4fcc88bde4b8496c49f397c6 +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Jul 6 15:16:08 2010 +0100 + + warnings-=2 + + poppler/GfxFont.cc | 3 ++- + utils/HtmlOutputDev.cc | 3 ++- + 2 files changed, 4 insertions(+), 2 deletions(-) + +commit 1e7f457ca1617fd8c958feef8dd7e694476dedd9 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jul 9 12:29:14 2010 +0200 + + [cairo] Use ceil to convert double to int in tilingPatternFill() + + Fixes rendering of page 2 of document attached to bug #28954. + + poppler/CairoOutputDev.cc | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +commit 91a7605eb51144f2e7dea69aa9454fff47c49bd2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jul 9 11:42:56 2010 +0200 + + [glib] Fix build when GDK is enabled + + glib/test-poppler-glib.cc | 8 +------- + 1 file changed, 1 insertion(+), 7 deletions(-) + +commit 09e3e0e9c5134688c4ed2af5cd3a12aa2986474c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 8 18:56:38 2010 +0200 + + [glib] Fix poppler_page_find_tex() when called more than once + + Fixes bug #27927 + + glib/poppler-page.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 25427bdecb219ffe6f0592d2ac36de60c247bfd9 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 8 17:46:22 2010 +0200 + + Fix build when compiling without glib frontend + + configure.ac | 1 + + 1 file changed, 1 insertion(+) + +commit 550684731356a66753ec19f5a8ca4b572db6d2d5 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 8 17:16:02 2010 +0200 + + [glib-demo] Add selections demo + + glib/demo/Makefile.am | 2 + + glib/demo/main.c | 4 +- + glib/demo/selections.c | 687 + +++++++++++++++++++++++++++++++++++++++++++++++++ + glib/demo/selections.h | 31 +++ + 4 files changed, 723 insertions(+), 1 deletion(-) + +commit b257428150e2c13dcc24fd8f75e4ee2c679ab414 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 8 14:45:29 2010 +0200 + + [glib] Add poppler_page_get_selected_text() + + And change poppler_page_get_text() to return the text of the whole + page. For consistency with poppler_page_get_selection_region() + get_seletect_text() doesn't invert the y coords as get_text() + did. This + change breaks the API. Users of poppler_page_get_text should: + + - Use the new poppler_page_get_text() if they want the text of the + whole page + + - Use poppler_page_get_selected_text() if they want the text of the + selected area. In this case they shouldn't invert the y coords + anymore + before calling the method. + + glib/demo/text.c | 9 +------- + glib/poppler-page.cc | 43 + +++++++++++++++++++++++++++---------- + glib/poppler-page.h | 3 ++- + glib/reference/poppler-sections.txt | 1 + + 4 files changed, 36 insertions(+), 20 deletions(-) + +commit bedc88225c948ad1288b69c6c106adce36233442 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jul 7 11:55:47 2010 +0200 + + [cairo] Fix warning on signed/unsigned comparison + + poppler/CairoFontEngine.cc | 12 ++++++------ + poppler/CairoFontEngine.h | 8 ++++---- + 2 files changed, 10 insertions(+), 10 deletions(-) + +commit 092aa901b9ec35a48bc1fb229ad16a3b00eef5f2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Jul 5 11:16:49 2010 +0200 + + [glib] docs: add some more introspection annotations + + glib/poppler-attachment.cc | 4 ++-- + glib/poppler-document.cc | 12 ++++++------ + glib/poppler-media.cc | 4 ++-- + glib/poppler-page.cc | 4 ++-- + 4 files changed, 12 insertions(+), 12 deletions(-) + +commit 6c4e14fd90d5ef2d6670a980ab2476b6fab58df7 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Jul 5 10:49:59 2010 +0200 + + [glib] docs: fix POPPLER_CHECK_VERSION() docs + + glib/poppler-features.h.in | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit ed324a867ecf1f616c4b2dc575f01d5cf1b67c38 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jul 2 18:28:45 2010 +0200 + + [glib] Rename instrospection files as 0.16 instead of 0.14 + + glib/Makefile.am | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +commit a55f567ff1ea0858eda13a024ed765a016f3bff0 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jul 2 18:23:03 2010 +0200 + + [glib] docs: Remove unneeded empty line in doc comment + + glib/poppler-features.h.in | 1 - + 1 file changed, 1 deletion(-) + +commit f16015303422280eaa21c3144eca0f1a330dce8a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jul 2 18:19:13 2010 +0200 + + [glib] docs: Add GObject introspection annotations + + glib/poppler-annot.cc | 45 + ++++++++++++++++++++-------------------- + glib/poppler-document.cc | 8 +++---- + glib/poppler-page.cc | 23 +++++++++++++------- + glib/reference/poppler-docs.sgml | 2 ++ + 4 files changed, 43 insertions(+), 35 deletions(-) + +commit 60242038e4dce7f0c90f2bfa0e771120247dbc9d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jun 30 09:35:29 2010 +0200 + + [glib] Add GObject introspection support + + configure.ac | 5 +++ + glib/Makefile.am | 29 +++++++++++++++++ + m4/introspection.m4 | 94 + +++++++++++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 128 insertions(+) + +commit 3160950a7d7161457405c9084c31af230329b3f0 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jul 2 12:47:04 2010 +0200 + + [glib] docs: Add index of deprecated symbols + + glib/reference/poppler-docs.sgml | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 593db7acf6edce1267f69d12310bf4098ff24c97 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jul 2 12:44:39 2010 +0200 + + [glib] docs: deprecate GDK API + + glib/poppler-page.cc | 8 ++++++++ + 1 file changed, 8 insertions(+) + +commit 6facefb3fa8f97a9d330545308fb2d89c7f57fa0 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 1 18:01:45 2010 +0200 + + [glib] docs: Add index of new symbols for versions 0.12, 0.14 and 0.16 + + glib/poppler-action.h | 10 +++++++--- + glib/poppler-annot.cc | 17 +++++++++++++++++ + glib/poppler-date.cc | 2 ++ + glib/poppler-document.cc | 16 +++++++++++++++- + glib/poppler-layer.cc | 12 ++++++++++++ + glib/poppler-media.cc | 14 ++++++++++++-- + glib/poppler-media.h | 3 +++ + glib/poppler-movie.cc | 6 ++++++ + glib/poppler-page.cc | 2 ++ + glib/reference/poppler-docs.sgml | 12 ++++++++++++ + 10 files changed, 88 insertions(+), 6 deletions(-) + +commit 166b78c0ce8a4536873c4f60b392c24c8a68e7aa +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 1 17:25:03 2010 +0200 + + [glib] docs: document PopplerMediaSaveFunc + + glib/poppler-media.h | 18 +++++++++++++++++- + 1 file changed, 17 insertions(+), 1 deletion(-) + +commit 5cc0a51f88580c65ac2d5c6ff02b8cf14697b70c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 1 17:20:13 2010 +0200 + + [glib] Use the same name for parameter in function prototype + + glib/poppler-media.h | 10 +++++----- + glib/poppler-movie.h | 6 +++--- + 2 files changed, 8 insertions(+), 8 deletions(-) + +commit 6793fd8fd2d33d3d58c6556b5dbe6d0497e56646 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 1 15:49:49 2010 +0200 + + [glib] docs: document some enums in poppler-action + + glib/poppler-action.h | 92 + +++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 92 insertions(+) + +commit 8e139696dbe19f54ad54364a711b929146f11080 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 1 15:02:58 2010 +0200 + + [glib] docs: mark structures in poppler-private.h as private + + glib/poppler-private.h | 7 +++++++ + 1 file changed, 7 insertions(+) + +commit ccae7e574047d66c638003cc36fa1edeef4d35ed +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 1 14:59:50 2010 +0200 + + [glib] docs: document PopplerDocument enums + + glib/poppler-document.h | 65 + +++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 65 insertions(+) + +commit 4fbff172693c38cdc4ae8070a55ceb706aa213cd +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 1 14:26:53 2010 +0200 + + [glib] docs: document PopplerFontInfo + + glib/poppler-document.cc | 106 + +++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 106 insertions(+) + +commit 465dd4897ff603a6fd96503cf4746fc808b0f827 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 1 12:59:39 2010 +0200 + + [glib] docs: document some enums + + glib/poppler.h | 55 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 55 insertions(+) + +commit de3d599ea9e948867cfe395f42ed659670110c4c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 1 12:31:10 2010 +0200 + + [glib] docs: document boxed types defined in poppler-page + + glib/poppler-page.cc | 147 + +++++++++++++++++++++++++++++++++++++++++++++++++++ + glib/poppler-page.h | 79 +++++++++++++++++++++++++++ + 2 files changed, 226 insertions(+) + +commit 34c52190e1dbf4d3effa44b4408faa1fbae0d12d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 1 09:33:08 2010 +0200 + + [glib] Remove splash header file + + glib/poppler-page.cc | 1 - + 1 file changed, 1 deletion(-) + +commit 6910545a487f206ccd059bb295d2312228dbf2ba +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jun 30 19:03:04 2010 +0200 + + [glib] docs: Remove invalid symbol from poppler-sections.txt + + glib/reference/poppler-sections.txt | 1 - + 1 file changed, 1 deletion(-) + +commit 65ea3b636cb5a38660e526a483a4d95f5acdf8db +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jun 30 19:02:32 2010 +0200 + + [glib] docs: fix typo + + glib/poppler-form-field.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 689bfec40b5b3030c2819cb4aac42c3ab6279278 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jun 30 19:01:47 2010 +0200 + + [glib] docs: Add missing doc for parameter + + glib/poppler-document.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 0b3d77627f255a4bf3da6ee875ad8d9eb931c96e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jun 30 19:00:59 2010 +0200 + + [glib] Use the same name for parameter in function prototype + + glib/poppler-page.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 19e1944c00ac2da6b18b015721fc3a8d1898a23a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jun 30 18:01:52 2010 +0200 + + [glib] docs: Add media and movie to docs + + glib/poppler-media.cc | 6 ++++++ + glib/poppler-movie.cc | 6 ++++++ + glib/reference/poppler-docs.sgml | 3 ++- + 3 files changed, 14 insertions(+), 1 deletion(-) + +commit ca48bee07e6b4a20ea7b40b472a335e75feb4739 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jun 30 17:56:50 2010 +0200 + + [glib] docs: Add missing types to poppler.types + + glib/reference/poppler.types | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 613ccf81317a007ed5017ee788466613a6699bb5 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jun 30 17:54:22 2010 +0200 + + [glib] docs: rework poppler-sections.txt + + - Better organization of sections and contents + - Use of Standard and Private subsections + - Add missing sections + - Remove enums section + + glib/reference/poppler-sections.txt | 424 + +++++++++++++++++++++++++----------- + 1 file changed, 295 insertions(+), 129 deletions(-) + +commit b37556a32b79f8711ed7eca24abf19511872a70a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jun 30 12:01:44 2010 +0200 + + [glib] docs: Add index of symbols + + glib/reference/poppler-docs.sgml | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 7f5fa4e19b4e324a396d64261b9125c1a557ac84 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jun 30 12:00:35 2010 +0200 + + [glib] docs: Add version information + + configure.ac | 1 + + glib/reference/Makefile.am | 2 +- + glib/reference/poppler-docs.sgml | 7 ++++++- + glib/reference/version.xml.in | 1 + + 4 files changed, 9 insertions(+), 2 deletions(-) + +commit 848d5e158fa9eadd19a658db314ba3fff9d026e8 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jun 30 11:30:41 2010 +0200 + + [glib] docs: do not use gtk-doc templates + + configure.ac | 2 +- + glib/poppler-action.cc | 6 + + glib/poppler-annot.cc | 6 + + glib/poppler-attachment.cc | 6 + + glib/poppler-attachment.h | 16 + + glib/poppler-document.cc | 8 + + glib/poppler-features.h.in | 59 ++++ + glib/poppler-form-field.cc | 6 + + glib/poppler-layer.cc | 6 + + glib/poppler-page.cc | 6 + + glib/reference/tmpl/poppler-action.sgml | 216 ------------ + glib/reference/tmpl/poppler-annot.sgml | 377 --------------------- + glib/reference/tmpl/poppler-attachment.sgml | 68 ---- + glib/reference/tmpl/poppler-document.sgml | 410 + ----------------------- + glib/reference/tmpl/poppler-enums.sgml | 246 -------------- + glib/reference/tmpl/poppler-features.sgml | 83 ----- + glib/reference/tmpl/poppler-form-field.sgml | 318 ------------------ + glib/reference/tmpl/poppler-layer.sgml | 83 ----- + glib/reference/tmpl/poppler-page.sgml | 483 + --------------------------- + glib/reference/tmpl/poppler-private.sgml | 148 -------- + glib/reference/tmpl/poppler-unused.sgml | 8 - + glib/reference/tmpl/poppler.sgml | 285 ---------------- + glib/reference/tmpl/stamp-poppler-enums.sgml | 22 -- + gtk-doc.make | 78 +++-- + m4/gtk-doc.m4 | 2 +- + 25 files changed, 171 insertions(+), 2777 deletions(-) + +commit 16e15ac845206217086e2adac9f220e75c0c630d +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 29 21:44:02 2010 +0100 + + bitmap can be null at this stage, check it isn't + + poppler/JBIG2Stream.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 38e5d28a184d0ca8df71a7ea910ce85d7a225e4e +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 21 20:38:00 2010 +0100 + + more pow 0.5 -> sqrt + + poppler/GfxState.cc | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +commit 58a53ca0a4e8434e8478f8fe121067dcf05c017d +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 21 19:24:20 2010 +0100 + + sqrt is much faster than pow 0.5 + + poppler/GfxState.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit bf86a9fc464aca57ebec207a213dcc2cc6031940 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 21 19:20:47 2010 +0100 + + introduce getChars to save some method calls + + Can give us a decent speedup when we go a lot though this methods + + poppler/Catalog.cc | 12 +---- + poppler/DCTStream.cc | 51 ++++++++++++++------ + poppler/DCTStream.h | 3 ++ + poppler/GfxFont.cc | 22 ++------- + poppler/GfxState.cc | 30 ++++-------- + poppler/JPEG2000Stream.cc | 67 +++++++------------------- + poppler/JPEG2000Stream.h | 38 ++++++++++++++- + poppler/Link.cc | 14 ++---- + poppler/Object.h | 4 ++ + poppler/Stream.cc | 90 +++++++++++++++++++---------------- + poppler/Stream.h | 118 + +++++++++++++++++++++++++++++++++++++++++++++- + 11 files changed, 279 insertions(+), 170 deletions(-) + +commit 65c14073a3b1035ca5fe3bd6667abd315272841e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Jun 21 17:19:22 2010 +0200 + + Reduce pow operations in GfxCalRGBColorSpace::getXYZ() + + We were doing the same pow operation 3 times!. It makes document + attached to bug #28591 render a little faster. + + poppler/GfxState.cc | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +commit 9365c05c1f66b3000febf32c45cef2ffe79e041a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jun 19 10:36:39 2010 +0200 + + [glib] Fix links/annots area for rotated documents with page CropBox + not starting at 0,0 + + Fixes bug #28588. + + glib/poppler-page.cc | 25 ++++++++++--------------- + 1 file changed, 10 insertions(+), 15 deletions(-) + +commit d9504c0a288c84b68a516f715505d6bc94b911f5 +Author: Pino Toscano <pino@kde.org> +Date: Fri Jun 18 23:59:04 2010 +0200 + + [autotools] link the 'cpp' tests against libpoppler as well + + ... this way gatof() can be found correctly + should fix bug #28605 + + cpp/tests/Makefile.am | 1 + + 1 file changed, 1 insertion(+) + +commit 62975737bcaa6e0a2ecab981aa3e0c8f2ff10571 +Author: Brian Cameron <brian.cameron@oracle.com> +Date: Fri Jun 18 19:22:17 2010 +0100 + + Compile with Sun Studio + + goo/ImgWriter.h | 3 ++- + goo/JpegWriter.h | 3 ++- + poppler/SplashOutputDev.cc | 6 ++++++ + 3 files changed, 10 insertions(+), 2 deletions(-) + +commit 7cbe3d1521aea8b484efb8663e75684e05b6fb61 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jun 17 23:01:21 2010 +0100 + + Optimize Splash::compositeBackground + + Optimization takes into account the two most common cases, the + pixel not + being painted at all (alpha == 0) meaning we just copy the paperColor + and the pixel being opage meaning we have to do nothing + + splash/Splash.cc | 34 ++++++++++++++++++++++++++-------- + 1 file changed, 26 insertions(+), 8 deletions(-) + +commit f323e5e4cdcc20075ee7c722f7adc088c0772249 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jun 17 22:59:37 2010 +0100 + + Check the objects are num before reading them + + Might have caused the kde bug #241995 + + poppler/GfxState.cc | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +commit 35e87d2062b1d82db0d765de5a6187122a0fa99c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jun 16 11:52:25 2010 +0200 + + [gib-demo] Add demo for poppler_page_get_text_layout() + + glib/demo/text.c | 182 + +++++++++++++++++++++++++++++++++++++++++++++++++------ + 1 file changed, 164 insertions(+), 18 deletions(-) + +commit ddcea568b3a7334e062d6214f43d0a2c2ec95be4 +Author: Daniel Garcia <danigm@yaco.es> +Date: Tue Jun 15 16:57:32 2010 +0200 + + [glib] Add poppler_page_get_text_layout() + + Returns an array of PopplerRectangle items and each Rectangle is a + text character position. + + The position in this array represent the offset in text returned by + poppler_page_get_text + + glib/poppler-page.cc | 91 + ++++++++++++++++++++++++++++++++++++++++++++++++++++ + glib/poppler-page.h | 4 ++- + 2 files changed, 94 insertions(+), 1 deletion(-) + +commit 6e9fe8832c37b560ac4d0b0e32d618bde70ee117 +Author: Pino Toscano <pino@kde.org> +Date: Wed Jun 16 00:22:59 2010 +0200 + + [Qt4] and support 'Print' named action here too... + + qt4/src/poppler-annotation.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 53c003f36af5d77f50fe238eaec4c5f7c3a485c7 +Author: Pino Toscano <pino@kde.org> +Date: Wed Jun 16 00:18:13 2010 +0200 + + [CMake] install the new goo/GooLikely.h + + CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit 2ba752aabc8dad4bb35a351697b1590795c54ca4 +Author: Pino Toscano <pino@kde.org> +Date: Wed Jun 16 00:06:30 2010 +0200 + + update copyrights + + qt4/src/poppler-link.h | 3 ++- + qt4/src/poppler-page.cc | 1 + + 2 files changed, 3 insertions(+), 1 deletion(-) + +commit 38bf54bbad40288be763c6a1a89d90477c9ef89d +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 15 23:05:43 2010 +0100 + + move the declaration of likely/unlikely to an own file in goo/ + + goo/GooLikely.h | 22 ++++++++++++++++++++++ + goo/Makefile.am | 1 + + poppler/Object.h | 9 +-------- + splash/Splash.cc | 4 +--- + 4 files changed, 25 insertions(+), 11 deletions(-) + +commit 9838edf8c7497858e3bac2743784a3259f61cfdd +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 15 22:54:34 2010 +0100 + + Protect us against negative y coordinates + + Happens very rarely, like in bug 28480 + + splash/Splash.cc | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 8b32c3e9826d4462fd9d16fab4200ebb23251046 +Author: Pino Toscano <pino@kde.org> +Date: Tue Jun 15 23:55:01 2010 +0200 + + [Qt4/apidox] ok, now the *proper* version for 'Print'... + + qt4/src/poppler-link.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit b54e5ac49f69bd1c906e517edcb436e042199cd5 +Author: Pino Toscano <pino@kde.org> +Date: Tue Jun 15 23:53:50 2010 +0200 + + [Qt4/apidox] add the proper version for the new 'Print' + + qt4/src/poppler-link.h | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 71ad18c3b6b73e23d71600d07ce00bdfaf0bef60 +Author: Pino Toscano <pino@kde.org> +Date: Tue Jun 15 23:51:01 2010 +0200 + + [Qt4] recognize the 'Print' named action here too + + qt4/src/poppler-annotation.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 96f60f2748ba76de0d296a9838dbd7181f506e36 +Author: Guillermo Amaral <gamaral@kdab.com> +Date: Tue Jun 15 23:47:46 2010 +0200 + + [Qt4] recognize 'Print' as name in named actions + + qt4/src/poppler-link.h | 3 ++- + qt4/src/poppler-page.cc | 2 ++ + 2 files changed, 4 insertions(+), 1 deletion(-) + +commit 25494311c5b8eb88d43df420ec91a1aedad20d05 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jun 15 17:44:23 2010 +0200 + + [glib] Add some G_UNLIKELY() + + glib/poppler-document.cc | 12 ++++++------ + glib/poppler-page.cc | 17 ++++++++++------- + 2 files changed, 16 insertions(+), 13 deletions(-) + +commit 52f133fb962256edb577b7f639c5c13221c6365d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jun 15 14:20:49 2010 +0200 + + [glib] Use g_slice for actions and destinations + + glib/poppler-action.cc | 21 +++++++++------------ + 1 file changed, 9 insertions(+), 12 deletions(-) + +commit f035c94d8b5b34c0c3bb47b8cfc2f9c720a4fc71 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jun 15 14:01:07 2010 +0200 + + [glib] Use g_slice_dup in _copy() function for iterators + + glib/poppler-document.cc | 9 +++------ + 1 file changed, 3 insertions(+), 6 deletions(-) + +commit c84f69681828c7e3b969f666f9b84f1531976c6f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jun 15 13:57:18 2010 +0200 + + [glib] Use g_slice for mappings and PopplerRectangle + + glib/poppler-page.cc | 50 + ++++++++++++++++++-------------------------------- + 1 file changed, 18 insertions(+), 32 deletions(-) + +commit e12b9ab105f3b56b47ded871693b939ed421c853 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jun 15 13:49:27 2010 +0200 + + [glib] Use poppler_image_mapping_free() instead of g_free() + + glib/poppler-page.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit fb791a15f7472042fb2174e6f5df6924dd4eeb9b +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jun 15 13:37:52 2010 +0200 + + [glib] Remove poppler_mapping_free and use poppler_link_mapping_free + instead + + glib/poppler-page.cc | 9 +-------- + 1 file changed, 1 insertion(+), 8 deletions(-) + +commit 6186d7220e545eb89597626933a10acd0cd25173 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jun 15 13:16:59 2010 +0200 + + [glib] Use _new() methods instead of g_new() to create boxed structs + + glib/poppler-page.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 44639cb7b10ab6d66122ae2b6b7f3e5745f933bd +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jun 15 10:39:00 2010 +0200 + + [glib-demo] Use poppler_rectangle_free() instead of g_free() + + glib/demo/find.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 3ca304f3837af27ae49541a5f441d8729264a945 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 14 19:16:41 2010 +0100 + + Add more caching to ObjectStreams + + Makes opening of file from bug 26759 ten times faster + + poppler/XRef.cc | 62 + ++++++++++++++++++++++++++++++++++++++++++++++++--------- + poppler/XRef.h | 4 ++-- + 2 files changed, 55 insertions(+), 11 deletions(-) + +commit cc2e5f190e19ee8169f67df2541302a2816873d3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Jun 14 18:17:01 2010 +0200 + + [glib-demo] Support password protected documents + + glib/demo/main.c | 175 + +++++++++++++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 170 insertions(+), 5 deletions(-) + +commit 34b2dbb6bbaf0189c92eea6b7924999ab2b6ad11 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Jun 14 17:41:51 2010 +0200 + + [glib-demo] Remove GLIB_CHECK_VERSION(), we already depend on + glib 2.18 + + glib/demo/attachments.c | 5 ----- + glib/demo/main.c | 32 +------------------------------- + 2 files changed, 1 insertion(+), 36 deletions(-) + +commit a52670a46c0561025d8b86cd2865603f0720c695 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 13 15:31:15 2010 +0100 + + do not distribute these two files + + they are generated on configure/cmake time and depend on the machine + + glib/Makefile.am | 7 +++---- + poppler/Makefile.am | 4 ++-- + 2 files changed, 5 insertions(+), 6 deletions(-) + +commit eb0206ba8458f1dba004ac7bef856dcbb2ccbba5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 9 18:56:16 2010 +0100 + + we need to ship these two files + + Bug 28458 + + Makefile.am | 2 ++ + 1 file changed, 2 insertions(+) + +commit 7dfdf1ee293b7d36a049a90d8a17462ed0e50f2c +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 8 21:54:52 2010 +0100 + + Typo-- + + utils/pdftoppm.1 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 57cc04ee1a122794b338c0d9818dbdaea46a42d6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 8 21:49:40 2010 +0100 + + Add cropbox to the manpage + + utils/pdftoppm.1 | 3 +++ + 1 file changed, 3 insertions(+) + +commit f9e6cb9647981f7afbb20261b3ccedaf003657d2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 8 20:43:11 2010 +0100 + + 0.14.0 + + CMakeLists.txt | 4 ++-- + NEWS | 18 ++++++++++++++++++ + configure.ac | 4 ++-- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + 5 files changed, 24 insertions(+), 6 deletions(-) + +commit 963afdc39153fee69ecb939c98deeef4f64638de +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 8 20:29:58 2010 +0100 + + libpoppler-qt4.so.3.2.0 -> libpoppler-qt4.so.3.3.0 + + qt4/src/CMakeLists.txt | 2 +- + qt4/src/Makefile.am | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit c1629be8011f3bddbf619246090640d62136d521 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 8 20:23:00 2010 +0100 + + Increase soname as _PopplerActionMovie struct grew + + glib/CMakeLists.txt | 2 +- + glib/Makefile.am | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 5ef45b1e72aed88ece0905b1204edee641f3c8fc +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 8 19:35:20 2010 +0100 + + Do not exit when trying to allocate memory for the XRef fails + + See bug 28406 + + poppler/XRef.cc | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit e7a5e9f70ee1283a2ca6734552d905279c97989b +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jun 4 08:46:33 2010 +0100 + + a bit of docu + + poppler/Object.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 9ff4dab2558f7c2700fd7fcaccacdad9619dbdda +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jun 4 08:44:34 2010 +0100 + + Add support for unsigned integer numbers + + So files store their P as a 32 bit unsigned instead of as a 32 bit + signed, making us to overflow our objInt parsing and rejecting to open + the file, this patch introduces objUint that only happens when the + number is not real, does not fit in a 32 bit integer but still fits + in a + 32 bit unsigned integer + + poppler/Lexer.cc | 32 +++++++++++++++++++++++++------- + poppler/Object.cc | 5 ++++- + poppler/Object.h | 14 +++++++++++--- + poppler/SecurityHandler.cc | 22 ++++++++++++++++++++++ + 4 files changed, 62 insertions(+), 11 deletions(-) + +commit 41e9af7f505dbfbda36f6ac97df90f2a42ab3160 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 1 21:40:07 2010 +0100 + + If the document is not encrypted it is ok to print + + poppler/XRef.cc | 16 ++++++++++------ + 1 file changed, 10 insertions(+), 6 deletions(-) + +commit b15c793a8a58b17a7fe7b32c1037726e1e0e1bf0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 1 20:57:16 2010 +0100 + + Check it is a stream, not that it is not none + + People is reporting aborts, e.g. KDE bug 240208 + but can not check if this really fixes it since he can not share the + document + + poppler/Lexer.h | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit a72c68117ba05f3934e2df227cdcaf53a375f0ce +Author: Pino Toscano <pino@kde.org> +Date: Fri May 28 18:11:02 2010 +0200 + + [cpp apidox] add a start of API documentation for the 'page' class + + cpp/poppler-page.cpp | 68 + ++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 68 insertions(+) + +commit acf7729e8e270e1b4b2a552272dc280ae6d7b352 +Author: Pino Toscano <pino@kde.org> +Date: Fri May 28 17:38:35 2010 +0200 + + [cpp] fix the font_iterator current page status + + cpp/poppler-font.cpp | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +commit 4e017ff24a01cbbf1b39eedc3d7697f8b180fdd9 +Author: Pino Toscano <pino@kde.org> +Date: Fri May 28 17:15:28 2010 +0200 + + [cpp apidox] add API documentation for the 'font_info' and + 'font_iterator' classes + + cpp/poppler-font.cpp | 71 + ++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 71 insertions(+) + +commit 2ff840b62e41e2fc98e9fcff7330f40216de58a5 +Author: Pino Toscano <pino@kde.org> +Date: Fri May 28 14:34:37 2010 +0200 + + [cpp] move the actual convert_date(const char*) implementation in + the detail + + this way it is possible to call it from inside poppler-cpp without + an implicit conversion to std::string + + cpp/poppler-document.cpp | 2 +- + cpp/poppler-embedded-file.cpp | 4 ++-- + cpp/poppler-global.cpp | 23 ++--------------------- + cpp/poppler-private.cpp | 25 +++++++++++++++++++++++++ + cpp/poppler-private.h | 2 ++ + 5 files changed, 32 insertions(+), 24 deletions(-) + +commit 8112e9111313eaded4cd2e89d0e67efb0f3e29db +Author: Pino Toscano <pino@kde.org> +Date: Fri May 28 13:13:50 2010 +0200 + + [cpp] add a time_type typedef + + ... defined as unsigned int, and use it all around + (it changes nothing for client code) + + cpp/poppler-document.cpp | 8 ++++---- + cpp/poppler-document.h | 2 +- + cpp/poppler-embedded-file.cpp | 4 ++-- + cpp/poppler-embedded-file.h | 4 ++-- + cpp/poppler-global.cpp | 4 ++-- + cpp/poppler-global.h | 4 +++- + 6 files changed, 14 insertions(+), 12 deletions(-) + +commit bc5bdb43b12437e00aaddc27a74b9ac4b6498446 +Author: Pino Toscano <pino@kde.org> +Date: Fri May 28 13:01:53 2010 +0200 + + use the proper type for iterating on a GooVector + + poppler/XRef.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 87128ab0dfec6be1a034361512ee41301b078831 +Author: Maciej Mrozowski <reavertm@gmail.com> +Date: Thu May 27 17:31:00 2010 +0200 + + [CMake] Do not force -O2, preserve compiler flags instead. + + cmake/modules/PopplerMacros.cmake | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 241c338facb45641ef1a271c904355a014bbf28d +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 27 20:37:55 2010 +0100 + + Allow quality & progressive mode to be utilised in JpegWriter + + goo/JpegWriter.cc | 15 +++++++++++++-- + goo/JpegWriter.h | 4 ++++ + splash/SplashBitmap.cc | 18 +++++++++--------- + splash/SplashBitmap.h | 4 ++++ + 4 files changed, 30 insertions(+), 11 deletions(-) + +commit 9eda6e8aaae412a9882141d1b5b8c7bf0c823c68 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 25 23:44:30 2010 +0100 + + Do not follow loops blindly + + Fixes crash in pdf in bug 28172 + + poppler/XRef.cc | 21 +++++++++++++++------ + poppler/XRef.h | 7 ++++--- + 2 files changed, 19 insertions(+), 9 deletions(-) + +commit bbee6e0c8c9b181f8d19c167c867d74a765685fb +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 25 23:13:38 2010 +0100 + + update copyright + + poppler/JBIG2Stream.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 80b72b9f2fd70395580205b8b176e0576e132cf5 +Author: Hib Eris <hib@hiberis.nl> +Date: Wed May 26 13:07:57 2010 +0200 + + [autotools] sync autotool build with cmake build + + In addition to commit 69c2cf76cef9c190ac07726f60f1dccd3df5cb6d + + poppler/poppler-config.h.in | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 30ea3ab8a1eecafb3366aef193910098fdb7ccc8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 25 23:07:56 2010 +0100 + + Fix crash when parsing pdf in bug 28170 + + This code is a can of crashing worms :-7 + + poppler/JBIG2Stream.cc | 23 ++++++++++++++++------- + 1 file changed, 16 insertions(+), 7 deletions(-) + +commit b5a9021037c4e6cbbfd622433f3de693d1f47671 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 25 20:00:57 2010 +0100 + + 0.13.4 + + CMakeLists.txt | 2 +- + NEWS | 16 ++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + glib/reference/tmpl/poppler-action.sgml | 5 +++++ + glib/reference/tmpl/poppler-annot.sgml | 18 ++++++++++++++++++ + glib/reference/tmpl/poppler-attachment.sgml | 3 +++ + glib/reference/tmpl/poppler-document.sgml | 5 +++++ + glib/reference/tmpl/poppler-enums.sgml | 17 +++++++++++++++++ + glib/reference/tmpl/poppler-features.sgml | 3 +++ + glib/reference/tmpl/poppler-form-field.sgml | 3 +++ + glib/reference/tmpl/poppler-layer.sgml | 4 ++++ + glib/reference/tmpl/poppler-page.sgml | 13 +++++++++++++ + glib/reference/tmpl/poppler-private.sgml | 3 +++ + glib/reference/tmpl/poppler.sgml | 6 ++++++ + glib/reference/tmpl/stamp-poppler-enums.sgml | 3 +++ + qt4/src/Doxyfile | 2 +- + 17 files changed, 103 insertions(+), 4 deletions(-) + +commit 57ab0ebe993d79fe551bba58e0a70d55d32828f8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed May 12 20:49:31 2010 +0100 + + better copyright + + poppler/strtok_r.cpp | 23 +++++++++++++++++++++++ + 1 file changed, 23 insertions(+) + +commit 69c2cf76cef9c190ac07726f60f1dccd3df5cb6d +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed May 12 20:47:25 2010 +0100 + + mingw does not provide strtok_r + + Copy the glibc implementation + + CMakeLists.txt | 1 + + poppler/Makefile.am | 1 + + poppler/poppler-config.h.cmake | 4 + + poppler/strtok_r.cpp | 189 + +++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 195 insertions(+) + +commit 9e9b5e0d87a7450bd2223538673321ecec720c36 +Author: Marek Kasik <mkasik@redhat.com> +Date: Tue May 11 12:06:17 2010 +0200 + + Better check of overlapping of table cells when selecting text + + Add check for overlapping of upper right cell with lower left cell + of assumed table (related to #3188). + + poppler/TextOutputDev.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit a3e40b460b7690ef73ccf143b10da07e91d9ee7f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon May 10 17:41:04 2010 +0200 + + [annots] Adjust bbox for line annots when y1 = y2 + + Some documents like pdf_commenting_new.pdf, have y1 = y2 but + line_width > 0, acroread renders the lines in such cases even + though the + annot bbox is empty. + + poppler/Annot.cc | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +commit e30d24c506a9ff742f8af5d6c71273abeddaa265 +Author: Pino Toscano <pino@kde.org> +Date: Tue May 4 15:19:26 2010 +0200 + + [cpp] ustring::{from,to}_utf8(): fix in/out buffer sizes + + cpp/poppler-global.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit aaa19a673020e12dbfceb4d25ade0ece7875fd83 +Author: Pino Toscano <pino@kde.org> +Date: Tue May 4 12:07:43 2010 +0200 + + [cpp] make the pkg-config files really working + + poppler-cpp.pc.cmake | 6 +++++- + poppler-cpp.pc.in | 6 +++++- + 2 files changed, 10 insertions(+), 2 deletions(-) + +commit 8f963ccde41ef1faa719254fccc5bdfe75e9fa87 +Author: Patrick Spendrin <ps_ml@gmx.de> +Date: Sun May 2 18:42:10 2010 +0200 + + Windows: define strtok_r as strtok_s + + poppler/poppler-config.h.cmake | 4 ++++ + poppler/poppler-config.h.in | 4 ++++ + 2 files changed, 8 insertions(+) + +commit c9d8df51c96e50ad72f7954baba2254259fc894c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat May 1 19:52:51 2010 +0100 + + 2010 in these copyrights + + poppler/poppler-config.h.cmake | 2 +- + poppler/poppler-config.h.in | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 9ce71fb35fdd66c55872956432160a5c76a62080 +Author: Jakub Wilk <ubanus@users.sf.net> +Date: Sat May 1 19:50:54 2010 +0100 + + Use strtok_r instead strtok + + strtok is not thread safe + + fofi/FoFiType1.cc | 8 +++++--- + poppler/CharCodeToUnicode.cc | 6 ++++-- + poppler/GlobalParams.cc | 6 ++++-- + poppler/PDFDoc.cc | 4 +++- + poppler/UnicodeMap.cc | 21 ++++++++++++++++++--- + 5 files changed, 34 insertions(+), 11 deletions(-) + +commit 6b2983f89e87792a393880dab6dc1fedb748db2c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Apr 30 14:48:50 2010 +0200 + + [cairo] Set device offset and matrix to smask depending on the + group target + + It seems to fix all of my test cases. Fixes bug #27208. + + poppler/CairoOutputDev.cc | 21 +++++++++++++++------ + 1 file changed, 15 insertions(+), 6 deletions(-) + +commit ac32021704178721ee007a6b6831283e323e500f +Author: Pino Toscano <pino@kde.org> +Date: Fri Apr 30 01:14:14 2010 +0200 + + demote the #warning to a simple FIXME comment + + poppler/ArthurOutputDev.cc | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +commit 8c1bc17552c989c15f318d9d109607a9a594ca6b +Author: Pino Toscano <pino@kde.org> +Date: Fri Apr 30 01:12:19 2010 +0200 + + MSVC: define fmax() and fmin() + + MSVC does not provide those functions, so we need to define them to + the existing max()/mix() macros. + Thanks to Patrick Spendrin for the hint! + + poppler/poppler-config.h.cmake | 5 +++++ + poppler/poppler-config.h.in | 5 +++++ + 2 files changed, 10 insertions(+) + +commit 71063d51a45835b0267a7e3f823ef49689cfd06f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Apr 29 20:28:07 2010 +0200 + + Make sure we are drawing text before calling endTextObject() + + This is actually the right fix for the previous commit. + + poppler/Gfx.cc | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +commit e909219d8e92994bd52976f9676015fa6ca9fc91 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Apr 29 18:34:22 2010 +0200 + + Set textHaveCSPattern=false again before filling the pattern in + opEndText() + + Fixes cairo backend regressions caused by commit + ccf238b32e236f69c0507a5421ac2649dfa8d865. + + poppler/Gfx.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 29572d6ac7829b60efce2d8e489473c55e370f26 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 27 23:39:23 2010 +0100 + + fabs for doubles + + poppler/TextOutputDev.cc | 24 ++++++++++++------------ + 1 file changed, 12 insertions(+), 12 deletions(-) + +commit 4905e2bd764ea601e3bf9c5195c740e5bf186af5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 27 23:34:34 2010 +0100 + + fix include + + splash/SplashBitmap.cc | 1 + + 1 file changed, 1 insertion(+) + +commit f9f0e4b747a1527bd6354897cdba7954d58651de +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Apr 27 14:26:23 2010 +0200 + + Fix first color stop offset of linear gradients + + Fixes bug #27837. + + poppler/Gfx.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5b822011029f3721fbafd4a7bf01b9d6fee35d25 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 24 18:18:08 2010 +0200 + + include standard float.h instead of unportable values.h + + poppler/TextOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit dee7cb8691528293bb5b8f266970cdb6771e301b +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 24 15:39:23 2010 +0100 + + 0.13.3 + + CMakeLists.txt | 2 +- + NEWS | 31 +++++++++++++++++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + 5 files changed, 35 insertions(+), 4 deletions(-) + +commit 07864c9e2a7a32b48bdbab92c8b2f79bce1d9f5b +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 24 13:07:02 2010 +0100 + + minor cleanups + + utils/HtmlLinks.cc | 15 ++------------- + utils/HtmlLinks.h | 16 ++++++++++++++-- + 2 files changed, 16 insertions(+), 15 deletions(-) + +commit e501eabb2f0775444a2bf64005a3a3f1ffa281b4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 24 13:06:12 2010 +0100 + + Do not assume the parameter will have more than 5 chars + + utils/pdftohtml.cc | 30 ++++++++++++++++++------------ + 1 file changed, 18 insertions(+), 12 deletions(-) + +commit 6cc4d571339214e9eeeb682ba48fb220cef905f9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 24 13:04:05 2010 +0100 + + Fix end() to return the correct last valid value + + goo/GooVector.h | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 4ed53e30e735b79c46eab9d54883531c6e187b17 +Author: William Bader <williambader@hotmail.com> +Date: Fri Apr 23 22:52:24 2010 +0100 + + Silence some Illegal entry in bfrange block in ToUnicode CMap + + Fixes #27728 + + poppler/CharCodeToUnicode.cc | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +commit 16a004784043e2a8587c0c3c6d23889df8a80470 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 22 19:39:01 2010 +0100 + + Avoid the usage of std:: + + poppler/TextOutputDev.cc | 25 +++++++++++-------------- + 1 file changed, 11 insertions(+), 14 deletions(-) + +commit a7dcb2b4ffee57b7f78529cbaeaab647ab93de86 +Author: Pino Toscano <pino@kde.org> +Date: Thu Apr 22 13:31:41 2010 +0200 + + Windows: include config.h in GlobalParamsWin.cc only if not included + already + + GlobalParamsWin.cc is not compiled standalone but only #include'd by + GlobalParams.cc (on Windows only), so config.h has already included + already + as safety check, check for PACKAGE_NAME (#define'd in config.h) + before #include'ing it again + + poppler/GlobalParamsWin.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit fba076e17af24a9c9883504282316bba119a908c +Author: Pino Toscano <pino@kde.org> +Date: Thu Apr 22 13:24:04 2010 +0200 + + avoid accidental max() macro replacement with some compilers (eg MSVC) + + defining an empty macro and using it between "max" and "(", such + compilers won't try to replace their macro max(a, b) there; in any + case, empty spaces are just fine + + poppler/TextOutputDev.cc | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +commit ccf238b32e236f69c0507a5421ac2649dfa8d865 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Wed Apr 21 19:21:37 2010 +0100 + + Improve colorizing text and masks in pattern colorspace + + Bug #27482 + + poppler/Gfx.cc | 137 + ++++++++++++++++++++++----------------------- + poppler/Gfx.h | 4 +- + poppler/SplashOutputDev.cc | 41 ++++++++++++-- + poppler/SplashOutputDev.h | 3 +- + 4 files changed, 106 insertions(+), 79 deletions(-) + +commit 8e86dfb328d94939ecf390d34af533b831b2837b +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Apr 21 19:19:53 2010 +0100 + + Add copyright + + poppler/TextOutputDev.cc | 1 + + poppler/TextOutputDev.h | 1 + + 2 files changed, 2 insertions(+) + +commit 6f9f3d33ff8058e28243ba45b8547e21ad0d088a +Author: Andre Klapper <a9016009@gmx.de> +Date: Wed Apr 21 19:57:15 2010 +0200 + + [glib-demo] Compile with -DGSEAL_ENABLE + + Fixes bug #27579. + + glib/demo/images.c | 2 +- + glib/demo/layers.c | 4 ++-- + glib/demo/render.c | 8 ++++---- + 3 files changed, 7 insertions(+), 7 deletions(-) + +commit 6b14c18d60cae130869f9a5c7688dfe880602224 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Apr 21 19:56:49 2010 +0200 + + [cairo] Make sure we always use a new path in doPath() + + Fixes document + http://acroeng.adobe.com/Test_Files/images/transparency/Untitled-2.pdf + when rendering with cairo backend. + + poppler/CairoOutputDev.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 4f71d64c69500ed78daf4d797c8af6cfbd3d970e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Apr 21 11:44:49 2010 +0200 + + [cairo] Fix pattern size when bbox is not at 0,0 + + poppler/CairoOutputDev.cc | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +commit 9c5612f6e013a8698eff6531ec388a7e6c1fb89a +Author: Marek Kasik <mkasik@redhat.com> +Date: Fri Feb 12 14:31:01 2010 +0100 + + Distinguish between columns and tables when selecting text + + This commit add ability to detect tables in text by checking borders + of 4 neighbouring text blocks for arrangement (to the left, to + the right, + center, ...). Detected border of whole table is then stored in + ExMin, ExMax, + EyMin and EyMax of each block together with id of detected + table. Sorting + of blocks is then performed on the these borders to be able to + distinguish + tables from columns. + Pasting of selected text was modified so that tables are pasted + correctly + (even with multi line cells). + + poppler/TextOutputDev.cc | 490 + +++++++++++++++++++++++++++++++++++++++++------ + poppler/TextOutputDev.h | 5 + + 2 files changed, 437 insertions(+), 58 deletions(-) + +commit db014ffb357e760d9397544c5a8fe747cdb497ab +Author: Brian Ewins <brian.ewins@gmail.com> +Date: Mon Nov 23 08:58:19 2009 +0000 + + Select top right to bottom left in RTL mode + + This makes pure RTL selection work. Bidi is not handled at all. + Rendering of the selection is poor and the dumped text appears + to still be in reverse order to me. + + poppler/TextOutputDev.cc | 57 + ++++++++++++++++++++++++++++++++++++------------ + 1 file changed, 43 insertions(+), 14 deletions(-) + +commit b1d43fa052d9160c4f319a67415ecf3ebf2cf9b3 +Author: Brian Ewins <brian.ewins@gmail.com> +Date: Sun Nov 22 09:47:40 2009 +0000 + + Make pdftotext newlines match copy and paste + + The output of pdftotext didn't insert line breaks, + resulting in jumbled text. Change the rules to + emit a newline at the end of each line unless + a hyphenation is being supressed, and an extra + newline at the end of each flow. + + poppler/TextOutputDev.cc | 17 +++-------------- + 1 file changed, 3 insertions(+), 14 deletions(-) + +commit f83b677a8eb44d65698b77edb13a5c7de3a72c0f +Author: Brian Ewins <brian.ewins@gmail.com> +Date: Thu Nov 12 02:50:29 2009 +0000 + + Use a reading-order sort to order blocks + + This switches the block sort from XY to reading order, + using the rules from T. Breuel's "High Performance + Document Layout Analysis". + + Signed-off-by: Brian Ewins <brian.ewins@gmail.com> + + poppler/TextOutputDev.cc | 164 + +++++++++++++++++++++++++++++++++++++++++++++-- + poppler/TextOutputDev.h | 8 +++ + 2 files changed, 167 insertions(+), 5 deletions(-) + +commit a2191a4d45e0abaec97c19aacae37c4c5824bd36 +Author: Brian Ewins <brian.ewins@gmail.com> +Date: Mon Nov 9 06:24:51 2009 +0000 + + Separate flow construction from reading order + + If the blocks were already in reading order, then + constructing flows is simplified, since blocks + cannot be picked out-of-order. Make this change + first in preparation for adding a reading-order + sort. + + Signed-off-by: Brian Ewins <brian.ewins@gmail.com> + + poppler/TextOutputDev.cc | 96 + +++++++++--------------------------------------- + 1 file changed, 17 insertions(+), 79 deletions(-) + +commit 345ed51af9b9e7ea53af42727b91ed68dcc52370 +Author: Brian Ewins <brian.ewins@gmail.com> +Date: Thu Oct 29 01:46:29 2009 +0000 + + Fix bug 3188, text selection across table cells + + Bug 3188. When selecting text, poppler goes across the whole + page then down, rather than across each cell, down that cell, + then across to the next cell. This leads to illegible paste + results. + + Teach TextPage to visit the selection in flow order rather than + block order. + + Signed-off-by: Brian Ewins <brian.ewins@gmail.com> + + poppler/TextOutputDev.cc | 334 + +++++++++++++++++++++++++---------------------- + 1 file changed, 178 insertions(+), 156 deletions(-) + +commit 12d83931ae1b899b70c7ea5c01f03f123b1bb9a8 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Apr 18 17:53:48 2010 +0200 + + [cairo] Check pattern status after setting matrix when rendering + images + + Fixes rendering of document attached to kde bug + http://bugs.kde.org/show_bug.cgi?id=135417. + + poppler/CairoOutputDev.cc | 34 ++++++++++++++++++++++++++++++++++ + 1 file changed, 34 insertions(+) + +commit ff6d501a2fc887fd49a985161f756d6d6b8e6c0d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Apr 18 17:51:42 2010 +0200 + + [cairo] Fix a crash when rendering 0x0 images + + See kde bug http://bugs.kde.org/show_bug.cgi?id=135417 + + poppler/CairoOutputDev.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 84cd2186861436fbaa7c29aa691e69fcd543a1c2 +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Apr 13 23:42:28 2010 +0200 + + Properly initialize variable + + poppler/CachedFile.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 24f244f486f332b0bd76c6525c5d9d03168a76e6 +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Apr 13 23:54:28 2010 +0200 + + pdftops: require output filename when reading from stdin + + utils/pdftops.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 955f9f53ff225f6794a494fdd0f0fe5ee1a41d88 +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Apr 13 23:47:40 2010 +0200 + + pdftotext: require output filename when reading from stdin + + utils/pdftotext.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 31388aa8b5117619878431b7fed2d033000af541 +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Apr 13 23:27:20 2010 +0200 + + pdftohtml: require output filename when reading from stdin + + utils/pdftohtml.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit a8d43ec1c7f5448a7f63d9bbd9062d56ee1c7c58 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Apr 14 19:21:33 2010 +0100 + + update XOPEN_SOURCE to 600 in non standard compile options + + it seems helps compiling on some BSD + + cmake/modules/PopplerMacros.cmake | 2 +- + configure.ac | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 4cce1f14e964edf1bf2d9fb8286ee002a67dc212 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 13 21:57:16 2010 +0100 + + include strings.h on non windows platforms + + poppler/GlobalParams.cc | 2 ++ + test/perf-test.cc | 2 ++ + 2 files changed, 4 insertions(+) + +commit 55c76069c52f9f51c6b8c60fe1aa8de499012ea8 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Apr 12 19:32:46 2010 +0200 + + [glib] Use existing cairo api when rendering to a pixbuf + + I should fix bug #5589 for the GDK api too. + + glib/poppler-page.cc | 227 + +++++++++++++++++++++------------------------------ + 1 file changed, 93 insertions(+), 134 deletions(-) + +commit 51aefe1423a068e8c119c21a8791d265aecbeaf5 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Apr 9 12:50:00 2010 +0200 + + [cairo] Implement colorizing image masks with pattern colorspace + + poppler/CairoOutputDev.cc | 9 +++++++++ + 1 file changed, 9 insertions(+) + +commit bd8f44289770175a17ac45e4788b0d374cc93d5a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Apr 9 12:02:38 2010 +0200 + + Partially revert "[cairo] Do not change device offset of mask surface" + + This partially reverts commit + a32f6f9ebaed3e4827b9dc6cb37e307c2798f521. + It fixed bug #27208, but it's causing regressions on other documents. + + poppler/CairoOutputDev.cc | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +commit bcb405c43fb7140f5d601d00de4d30913a0050ef +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Apr 8 12:02:48 2010 +0200 + + Pages were always created without forms by Catalog + + Use getForm() instead of form when creating a page object. + + poppler/Catalog.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit d46581c574b3088a82555cbc3b76e95e2571b9c0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Apr 7 20:25:23 2010 +0100 + + Fix destructor + + poppler/Catalog.cc | 19 +++++++------------ + poppler/Catalog.h | 3 +-- + 2 files changed, 8 insertions(+), 14 deletions(-) + +commit ab14433f8b3d7c67f279cece65dfdd40c6675ac0 +Author: Hib Eris <hib@hiberis.nl> +Date: Thu Mar 25 15:33:33 2010 +0100 + + Parse Form on demand + + poppler/Catalog.cc | 21 +++++++++++++-------- + poppler/Catalog.h | 2 +- + 2 files changed, 14 insertions(+), 9 deletions(-) + +commit c72a2c7f70b13a7b7b531b3c983d9a9bc104bac7 +Author: Hib Eris <hib@hiberis.nl> +Date: Thu Mar 25 17:33:11 2010 +0100 + + Parse Names on demand + + poppler/Catalog.cc | 112 + +++++++++++++++++++++++++++++++++++++++++++---------- + poppler/Catalog.h | 18 ++++++--- + 2 files changed, 104 insertions(+), 26 deletions(-) + +commit 32053360c93607cf9bdc092257cefad5d4df9ec5 +Author: Hib Eris <hib@hiberis.nl> +Date: Thu Mar 25 16:32:22 2010 +0100 + + Parse Dests on demand + + poppler/Catalog.cc | 27 +++++++++++++++++++++------ + poppler/Catalog.h | 2 +- + 2 files changed, 22 insertions(+), 7 deletions(-) + +commit da0f8e69eecb944e128474f62829f729eeabd189 +Author: Hib Eris <hib@hiberis.nl> +Date: Thu Mar 25 16:48:07 2010 +0100 + + Parse Outline on demand in PDFDoc + + poppler/PDFDoc.cc | 17 ++++++++++++----- + poppler/PDFDoc.h | 2 +- + 2 files changed, 13 insertions(+), 6 deletions(-) + +commit d7a69c8cad112cb6616d0192d8a4028fdaee2f73 +Author: Hib Eris <hib@hiberis.nl> +Date: Thu Mar 25 16:05:02 2010 +0100 + + Parse Outline on demand + + poppler/Catalog.cc | 23 ++++++++++++++++++++--- + poppler/Catalog.h | 2 +- + 2 files changed, 21 insertions(+), 4 deletions(-) + +commit c149e027fa76824221a78fe6d3bf9bfe953491d4 +Author: Hib Eris <hib@hiberis.nl> +Date: Thu Mar 25 15:51:51 2010 +0100 + + Parse StructTreeRoot on demand + + poppler/Catalog.cc | 22 +++++++++++++++++++--- + poppler/Catalog.h | 2 +- + 2 files changed, 20 insertions(+), 4 deletions(-) + +commit 3c6effe44d6d97f175c2ee7f3913d8c4ba34d612 +Author: Hib Eris <hib@hiberis.nl> +Date: Thu Mar 25 14:55:22 2010 +0100 + + Parse Metadata on demand + + poppler/Catalog.cc | 16 +++++++++++++--- + 1 file changed, 13 insertions(+), 3 deletions(-) + +commit 749d67ea2346a3453ef41dc37ba59d419ad900b0 +Author: Hib Eris <hib@hiberis.nl> +Date: Thu Mar 25 15:09:58 2010 +0100 + + Parse PageLabelInfo on demand + + poppler/Catalog.cc | 37 +++++++++++++++++++++++++++++-------- + poppler/Catalog.h | 3 +++ + 2 files changed, 32 insertions(+), 8 deletions(-) + +commit 78f7d106714fa489a66c39410163a6902ba24856 +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Mar 27 14:43:57 2010 +0100 + + Parse PageMode and PageLayout on demand + + poppler/Catalog.cc | 109 + ++++++++++++++++++++++++++++++++++++----------------- + poppler/Catalog.h | 11 ++++-- + 2 files changed, 81 insertions(+), 39 deletions(-) + +commit f5dd5be64d09186ee289632c1a61979d15edd605 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Apr 7 19:48:39 2010 +0200 + + Fix saving update docs that have a compressed xref table + + - Use the original xref table size as Size field in the trailer + dictionary to make sure size = maxObjId + 1 + + - Use the right generation number for compressed objects that which + must be 0. gen field in xref entry for compressed objects is the + index of the object in the stream, not the generation number. + + Fixes bug #27450. + + poppler/PDFDoc.cc | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +commit 3f302fdd78cd78873bf5376af84e83741a8daadb +Author: Pino Toscano <pino@kde.org> +Date: Tue Apr 6 23:58:46 2010 +0200 + + use a GooVector<bool> instead of a non-standard variable-length-array + + poppler/CachedFile.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 425a62b5fa8e4e69bfc1c64ed126b5baac06d78a +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Apr 6 10:57:30 2010 +0200 + + pdfutils: fix deleting fileName + + utils/pdfinfo.cc | 2 +- + utils/pdftoabw.cc | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 198c9d61ba93ba62ea2da44a23cd948d43556c3e +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 6 22:00:14 2010 +0100 + + Use the topleft of the Rect of text annots to draw + + Not use the full rect when we are drawing "our" notes + + poppler/Annot.cc | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +commit 1422802f029483ad3e62a3a13e66b2d3990ac58f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Apr 6 12:32:12 2010 +0200 + + [cairo] Use current fill_opacity when drawing soft masked images + + Fixes GNOME Bug https://bugzilla.gnome.org/show_bug.cgi?id=614915 + + poppler/CairoOutputDev.cc | 27 ++++++++++++++++++++------- + 1 file changed, 20 insertions(+), 7 deletions(-) + +commit c152d30f879e6cde45de58bb9249035e127e84e7 +Author: Hib Eris <hib@hiberis.nl> +Date: Mon Apr 5 18:55:29 2010 +0200 + + delete fileName in utils + + utils/pdftohtml.cc | 1 + + utils/pdftops.cc | 1 + + utils/pdftotext.cc | 1 + + 3 files changed, 3 insertions(+) + +commit f091c83414ab32a4ecf1fa2bd15f13a3cf113a86 +Author: Hib Eris <hib@hiberis.nl> +Date: Mon Apr 5 20:12:01 2010 +0100 + + add some docu + + poppler/CachedFile.h | 30 ++++++++++++++++++++++++++++++ + poppler/CurlPDFDocBuilder.h | 2 ++ + poppler/LocalPDFDocBuilder.h | 2 ++ + poppler/PDFDocBuilder.h | 9 +++++++++ + poppler/PDFDocFactory.h | 12 ++++++++++++ + poppler/StdinPDFDocBuilder.h | 2 ++ + 6 files changed, 57 insertions(+) + +commit fc071d800cb4329a3ccf898d7bf16b4db7323ad8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Apr 5 19:11:26 2010 +0100 + + Rework DCTStream error handling, should work better now + + Fixes bug 26280 + + poppler/DCTStream.cc | 35 ++++++++++++++--------------------- + poppler/DCTStream.h | 5 +++-- + utils/HtmlOutputDev.cc | 4 ++-- + 3 files changed, 19 insertions(+), 25 deletions(-) + +commit a9d801b2db20ecb08734ee5cdb703abf11994b6e +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Apr 5 16:55:02 2010 +0100 + + Make some paremeters const & to clearly show we just read them + + poppler/CachedFile.cc | 18 ++++++++++-------- + poppler/CachedFile.h | 8 +++++--- + poppler/CurlCachedFile.cc | 9 +++++---- + poppler/CurlCachedFile.h | 3 ++- + poppler/CurlPDFDocBuilder.cc | 9 +++++---- + poppler/CurlPDFDocBuilder.h | 5 +++-- + poppler/LocalPDFDocBuilder.cc | 15 ++++++++------- + poppler/LocalPDFDocBuilder.h | 5 +++-- + poppler/PDFDocBuilder.h | 5 +++-- + poppler/PDFDocFactory.cc | 7 ++++--- + poppler/PDFDocFactory.h | 3 ++- + poppler/StdinCachedFile.cc | 3 ++- + poppler/StdinCachedFile.h | 3 ++- + poppler/StdinPDFDocBuilder.cc | 7 ++++--- + poppler/StdinPDFDocBuilder.h | 5 +++-- + utils/pdffonts.cc | 4 ++-- + utils/pdfimages.cc | 4 ++-- + utils/pdfinfo.cc | 4 ++-- + utils/pdftoabw.cc | 4 ++-- + utils/pdftohtml.cc | 4 ++-- + utils/pdftoppm.cc | 2 +- + utils/pdftops.cc | 4 ++-- + utils/pdftotext.cc | 4 ++-- + 23 files changed, 76 insertions(+), 59 deletions(-) + +commit a04ee3ea6066c97d41fc40d5d97c600a1870855a +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Apr 5 16:50:58 2010 +0100 + + forgot my (C) + + poppler/Form.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ed723c8ac4a21a50d7d236cdcf7a635defd8dffb +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Apr 5 16:50:15 2010 +0100 + + The copy constructor of GooString never worked, so do not use it + + poppler/Form.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit a28be8e4009b86fdfd92da928def194225a736c6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Apr 5 16:49:06 2010 +0100 + + Add some const correctnes to GooString + + goo/GooString.cc | 12 ++++++------ + goo/GooString.h | 21 ++++++++++++--------- + 2 files changed, 18 insertions(+), 15 deletions(-) + +commit 46aee9e4d225b88a3dfd4afbe57259f337bb15d3 +Author: Hib Eris <hib@hiberis.nl> +Date: Mon Apr 5 14:36:09 2010 +0200 + + Use PDFDocFactory in utils + + utils/pdffonts.cc | 16 ++++++++-------- + utils/pdfimages.cc | 11 ++++++++++- + utils/pdfinfo.cc | 31 +++++++------------------------ + utils/pdftoabw.cc | 10 +++++++++- + utils/pdftohtml.cc | 10 +++++++++- + utils/pdftoppm.cc | 17 +++++++++++------ + utils/pdftops.cc | 9 ++++++++- + utils/pdftotext.cc | 14 +++++++------- + 8 files changed, 69 insertions(+), 49 deletions(-) + +commit d487a90688c4431075c9e4db040b3b02625e208f +Author: Hib Eris <hib@hiberis.nl> +Date: Mon Apr 5 14:35:52 2010 +0200 + + Add PDFDocFactory + + CMakeLists.txt | 2 ++ + poppler/Makefile.am | 2 ++ + poppler/PDFDocFactory.cc | 71 + ++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/PDFDocFactory.h | 42 ++++++++++++++++++++++++++++ + 4 files changed, 117 insertions(+) + +commit 869135920831fb0d15db734f3dcd7a67146cc241 +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Feb 24 15:24:26 2010 +0100 + + Add CurlPDFDocBuilder + + CMakeLists.txt | 2 ++ + poppler/CurlPDFDocBuilder.cc | 46 + ++++++++++++++++++++++++++++++++++++++++++++ + poppler/CurlPDFDocBuilder.h | 30 +++++++++++++++++++++++++++++ + poppler/Makefile.am | 6 ++++-- + 4 files changed, 82 insertions(+), 2 deletions(-) + +commit ec5c6117a64f9cb03560091c4d7948d4287b6975 +Author: Hib Eris <hib@hiberis.nl> +Date: Thu Feb 25 11:23:28 2010 +0100 + + Add LocalPDFDocBuilder and StdinPDFDocBuilder + + CMakeLists.txt | 4 ++++ + poppler/LocalPDFDocBuilder.cc | 45 + +++++++++++++++++++++++++++++++++++++++++++ + poppler/LocalPDFDocBuilder.h | 30 +++++++++++++++++++++++++++++ + poppler/Makefile.am | 4 ++++ + poppler/StdinPDFDocBuilder.cc | 42 + ++++++++++++++++++++++++++++++++++++++++ + poppler/StdinPDFDocBuilder.h | 30 +++++++++++++++++++++++++++++ + 6 files changed, 155 insertions(+) + +commit 919b735d1c0b99bf72280aff8db87ba503954498 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Apr 4 11:05:35 2010 +0200 + + Add PDFDocBuilder + + CMakeLists.txt | 1 + + poppler/Makefile.am | 1 + + poppler/PDFDocBuilder.h | 32 ++++++++++++++++++++++++++++++++ + 3 files changed, 34 insertions(+) + +commit 1ab07faf05661d6d92186974c4b1c279b6178747 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Apr 4 11:29:53 2010 +0200 + + Add PDFDoc::ErrorPDFDoc + + poppler/PDFDoc.cc | 14 ++++++++++++++ + poppler/PDFDoc.h | 3 +++ + 2 files changed, 17 insertions(+) + +commit efc7e5efeddd8f70b7c74573d3194aba0a7d4631 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Apr 4 11:17:37 2010 +0200 + + Cleanup PDFDoc + + poppler/PDFDoc.cc | 40 +++++++++++++++------------------------- + poppler/PDFDoc.h | 3 ++- + 2 files changed, 17 insertions(+), 26 deletions(-) + +commit 08a3435e67ebf21beac2fefcbd21ad65f9293fd1 +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Feb 23 02:29:26 2010 +0100 + + Add HTTP support using libcurl + + With libcurl, poppler can handle documents over http. + + CMakeLists.txt | 18 ++++++++ + config.h.cmake | 6 +++ + configure.ac | 16 +++++++ + poppler/CurlCachedFile.cc | 95 + ++++++++++++++++++++++++++++++++++++++++++ + poppler/CurlCachedFile.h | 39 +++++++++++++++++ + poppler/Makefile.am | 20 +++++++++ + poppler/poppler-config.h.cmake | 5 +++ + poppler/poppler-config.h.in | 5 +++ + utils/pdfinfo.cc | 16 ++++++- + 9 files changed, 219 insertions(+), 1 deletion(-) + +commit a87abf6ad9fb66d35a70c9412adc5d8ba2889b96 +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Feb 24 14:46:59 2010 +0100 + + Use cached files to read from stdin in pdfinfo + + This fixes reading from stdin. + + utils/pdfinfo.cc | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit 958b04b14baf03c07492fa1cbd225d9968b9efc1 +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Feb 23 02:02:10 2010 +0100 + + Add support for reading a cached file from stdin + + CMakeLists.txt | 2 ++ + poppler/Makefile.am | 2 ++ + poppler/StdinCachedFile.cc | 37 +++++++++++++++++++++++++++++++++++++ + poppler/StdinCachedFile.h | 26 ++++++++++++++++++++++++++ + 4 files changed, 67 insertions(+) + +commit 9539f75bd06150a3868209c5b04a75f5253722cc +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Apr 3 15:08:20 2010 +0200 + + Add support for cached files + + CMakeLists.txt | 2 + + poppler/CachedFile.cc | 246 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/CachedFile.h | 113 +++++++++++++++++++++++ + poppler/Makefile.am | 2 + + poppler/Stream.cc | 102 +++++++++++++++++++++ + poppler/Stream.h | 58 ++++++++++++ + 6 files changed, 523 insertions(+) + +commit 8c6aefb8aa8929b9c47791d3062ed3ac8512626f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Apr 4 16:08:12 2010 +0200 + + [lexer] Correctly parse numbers with '+' sign + + See GNOME Bug: https://bugzilla.gnome.org/show_bug.cgi?id=614549 + + poppler/Lexer.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit ab5044e451e3714d385295f0b4ce9a15c8f2562c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 4 12:32:42 2010 +0100 + + Add the -o[dd] and -e[ven] options to pdftoppm + + I've been using this patch forever and it's a pain to apply and + unapply + it each time + + utils/pdftoppm.1 | 6 ++++++ + utils/pdftoppm.cc | 8 ++++++++ + 2 files changed, 14 insertions(+) + +commit 0e371fb628a7e7d0cc1656e6405af4c97dbebf5d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 4 12:30:34 2010 +0100 + + Fix my roll optimization + + Thanks Carlos for noticing + + poppler/Function.cc | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +commit a32f6f9ebaed3e4827b9dc6cb37e307c2798f521 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Mar 28 18:43:14 2010 +0200 + + [cairo] Do not change device offset of mask surface + + Also call cairo_paint() after set_source_rgb() to paint the + background. + Fixes bug #27208. + + poppler/CairoOutputDev.cc | 13 ++----------- + 1 file changed, 2 insertions(+), 11 deletions(-) + +commit efa5d9544d29252e3df36cc4e65c3d880b3c5172 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 27 22:11:49 2010 +0000 + + remove empty section + + NEWS | 2 -- + 1 file changed, 2 deletions(-) + +commit 5722df7a5387e43ec73f659ca58d2d07b9c4be3b +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 27 22:04:43 2010 +0000 + + poppler 0.13.2 + + CMakeLists.txt | 2 +- + NEWS | 39 +++++++++++++++++++++++++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + 5 files changed, 43 insertions(+), 4 deletions(-) + +commit b82fd707747b9d87ebf3c8f7ce5ab70ccdf82809 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 27 22:00:58 2010 +0000 + + gtk-doc changes + + glib/reference/tmpl/poppler-action.sgml | 7 +++---- + glib/reference/tmpl/poppler-annot.sgml | 9 --------- + glib/reference/tmpl/poppler-private.sgml | 10 ++++++++++ + glib/reference/tmpl/poppler-unused.sgml | 8 ++++++++ + glib/reference/tmpl/poppler.sgml | 10 ++++++++++ + 5 files changed, 31 insertions(+), 13 deletions(-) + +commit ed0354be4eac615b80e7a868984cc527853788b4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 27 21:44:59 2010 +0000 + + some forgotten copyrights + + qt/poppler-page.cc | 2 +- + qt4/src/poppler-document.cc | 2 +- + qt4/src/poppler-movie.cc | 3 ++- + qt4/src/poppler-page.cc | 2 +- + 4 files changed, 5 insertions(+), 4 deletions(-) + +commit 2aedeedf9ef2e2d3eb17bc36d728e68c2f7af762 +Author: Hib Eris <hib@hiberis.nl> +Date: Sat Mar 27 14:38:27 2010 +0000 + + Correctly initialize actualText + + poppler/TextOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit b53f9b203598555d6d706c3804aba013b8566921 +Author: Jan Engelhardt <jengelh@medozas.de> +Date: Sat Mar 27 13:23:42 2010 +0000 + + make qt3 detection use pkgconfig + + m4/qt.m4 | 101 + +++++---------------------------------------------------- + qt/Makefile.am | 4 +-- + 2 files changed, 10 insertions(+), 95 deletions(-) + +commit 320d4cee46e108498440179d8f9eab22cd5383d9 +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 24 21:51:58 2010 +0100 + + Revert "no more needed" + + This reverts commit 24d6bc8c78cb3148db2098ae4d69bd744340cf52. + It is actually needed. + + cpp/tests/CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit af21b5ab366bfdda203c26a77f4ae6ed0e70f64e +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 23 00:13:21 2010 +0100 + + [CMake] remove the (now) unneeded stuff from Find{GLIB,GDK,GTK}.cmake, + and search for them + + this way each bit (GLIB, GDK, and GTK) can be enabled/disabled + independently from the others + + CMakeLists.txt | 4 +++- + cmake/modules/FindGDK.cmake | 14 +------------- + cmake/modules/FindGLIB.cmake | 14 +------------- + cmake/modules/FindGTK.cmake | 14 +------------- + 4 files changed, 6 insertions(+), 40 deletions(-) + +commit 9b93ed5ce6712ec4cdf58148628e95685c289ef5 +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 23 00:02:27 2010 +0100 + + [CMake] copy FindGTK.cmake as FindGLIB.cmake and FindGDK.cmake + + this way FindGTK.cmake can be split in the various parts + + cmake/modules/FindGDK.cmake | 34 ++++++++++++++++++++++++++++++++++ + cmake/modules/FindGLIB.cmake | 34 ++++++++++++++++++++++++++++++++++ + 2 files changed, 68 insertions(+) + +commit 0ec21cae0b4623644c3efca1d2836a9f38f25737 +Author: Pino Toscano <pino@kde.org> +Date: Mon Mar 22 22:11:04 2010 +0100 + + [Qt] add the unhandled cases for 'actionOCGState' + + qt/poppler-page.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 5211e09595135b8e6c68efd1b8b689b518092b84 +Author: Pino Toscano <pino@kde.org> +Date: Mon Mar 22 22:07:44 2010 +0100 + + [CMake/cpp] move the BUILD_CPP_TESTS option to the main CMakeLists.txt + + CMakeLists.txt | 1 + + cpp/tests/CMakeLists.txt | 3 --- + 2 files changed, 1 insertion(+), 3 deletions(-) + +commit 24d6bc8c78cb3148db2098ae4d69bd744340cf52 +Author: Pino Toscano <pino@kde.org> +Date: Mon Mar 22 22:00:55 2010 +0100 + + no more needed + + cpp/tests/CMakeLists.txt | 1 - + 1 file changed, 1 deletion(-) + +commit a07ef8f703ab896f89ed211a5780e4a669b04fc7 +Author: Pino Toscano <pino@kde.org> +Date: Mon Mar 22 22:00:15 2010 +0100 + + [CMake] revert addition of "-Wl,--no-add-needed" to the link flags, + if available + + for now it is safer without it + + cmake/modules/PopplerMacros.cmake | 6 ------ + 1 file changed, 6 deletions(-) + +commit 86debcc9bba28a7c86f01ca9e63bde5fcd541846 +Author: Pino Toscano <pino@kde.org> +Date: Mon Mar 22 21:49:22 2010 +0100 + + [CMake] add "-ansi" to the CXXFLAGS only on Linux + + cmake/modules/PopplerMacros.cmake | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +commit 0819acd52a2ce74f0e176626d7b2233e10232d53 +Merge: c4ddbe8 92738eb +Author: Pino Toscano <pino@kde.org> +Date: Mon Mar 22 21:43:01 2010 +0100 + + Merge branch 'master' of ssh://git.freedesktop.org/git/poppler/poppler + +commit 92738ebb8a9c7cfc879aae59c2cbdf3159f03cd3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 22 20:28:15 2010 +0000 + + Add a search overload that takes doubles + + QRectF is evil and is float in some arch and causes search to loop + infinitely because of double->float conversion + + qt4/src/poppler-page.cc | 22 +++++++++++++++------- + qt4/src/poppler-qt4.h | 16 ++++++++++++++-- + 2 files changed, 29 insertions(+), 9 deletions(-) + +commit 0a895f14c8125c5de7b97e8e799459c431eb51cb +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Mon Mar 22 19:03:54 2010 +0000 + + correctly initialize the grayscale softmask color + + Fixes file with sha1sum e6e1576803a1bd74ad822eebbd750ee7b8357d25 + + poppler/SplashOutputDev.cc | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +commit c4ddbe89df9e48343a9606728b7c182080d87ece +Author: Patrick Spendrin <ps_ml@gmx.de> +Date: Sat Mar 20 21:55:17 2010 +0100 + + [CMake] when the conf configuration backend is "win32", set the + required Internet Explorer version to 5.0 + + ... as done with autotools as well + + CMakeLists.txt | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 97da1f9d060493d9fb54a20e980c3f6e2b82c97e +Author: Pino Toscano <pino@kde.org> +Date: Sat Mar 20 17:51:07 2010 +0100 + + [CMake] check whether a link flag is supported before adding it to + the link flags + + this way we can add -Wl,--as-needed and -Wl,--no-add-needed only if + the current GCC/LD supports them + + cmake/modules/PopplerMacros.cmake | 23 ++++++++++++++++++++--- + 1 file changed, 20 insertions(+), 3 deletions(-) + +commit 223bce6d14e632f457a81b2ec091fe16369d2eb6 +Author: Pino Toscano <pino@kde.org> +Date: Sat Mar 20 14:08:58 2010 +0100 + + [CMake] with GCC, pass --as-needed and --no-add-needed to the linker + + --as-needed allows to avoid overlinking, linking only to the libraries + whose symbols are actually used + --no-add-needed makes the linker not use the NEEDED libraries + automatically, so we have to always make sure we specify all the + libraries actually used in a exe/lib + + cmake/modules/PopplerMacros.cmake | 4 ++++ + 1 file changed, 4 insertions(+) + +commit fc761f0d385708daaef1b95968532795b04f11b0 +Author: Pino Toscano <pino@kde.org> +Date: Sat Mar 20 14:05:59 2010 +0100 + + [CMake] poppler-dump uses parseargs.c which uses the poppler core API, + so it must link to it + + cpp/tests/CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit a210440b05d14efc53224a10e8b3ac7d508043b5 +Author: Pino Toscano <pino@kde.org> +Date: Sat Mar 20 14:04:02 2010 +0100 + + [CMake] poppler-glib uses the freetype API, so it must explicitly + link to it + + glib/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit f5d352666b92cee0390470d7b892ec8dcbf046a5 +Author: Pino Toscano <pino@kde.org> +Date: Sat Mar 20 14:03:19 2010 +0100 + + [CMake] pdftoabw uses the libxml2 API, so it must explicitly link + to it + + utils/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 3fc2c4affe825f4aabcee161ec794338bd359403 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Mar 18 13:52:52 2010 +0100 + + [glib] Use g_slice_new/free instead of g_new/free to alloc/free + iterators + + glib/poppler-document.cc | 27 +++++++++++++-------------- + 1 file changed, 13 insertions(+), 14 deletions(-) + +commit 7bd6a8558646983669ce699f83d5ed42d7fce476 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Mar 18 13:34:03 2010 +0100 + + [glib] Move find_annot_movie_for_action() from page to action + + And remove _poppler_action_movie_set_movie(). + + glib/poppler-action.cc | 93 + ++++++++++++++++++++++++++++++++++++++++++++------ + glib/poppler-page.cc | 79 ------------------------------------------ + glib/poppler-private.h | 2 -- + 3 files changed, 82 insertions(+), 92 deletions(-) + +commit e5e3d310aa488638431dd85ac3383a12056674bf +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Mar 18 12:20:26 2010 +0100 + + Update copyright header + + poppler/Link.cc | 2 +- + poppler/Link.h | 1 + + 2 files changed, 2 insertions(+), 1 deletion(-) + +commit c76870178a031e437de3f9ed7baa64efb96955d6 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Mar 18 12:13:36 2010 +0100 + + [glib-demo] OCG State Actions demo + + glib/demo/utils.c | 64 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 64 insertions(+) + +commit 456e42f91dfbf73b71a5dbdde13d7ccdb5637d79 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Mar 18 12:12:51 2010 +0100 + + [glib] Add support for OCG State actions + + glib/poppler-action.cc | 125 + +++++++++++++++++++++++++++++++++++++++++++++++++ + glib/poppler-action.h | 25 +++++++++- + glib/poppler.h | 1 + + 3 files changed, 150 insertions(+), 1 deletion(-) + +commit 4b109899e0732bbf65cacd875829e869e61eda48 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Mar 18 12:10:19 2010 +0100 + + [glib] Make get_layer_rbgroup() and get_layers() doc funcs public + for internal use + + glib/poppler-document.cc | 12 ++++++------ + glib/poppler-private.h | 3 +++ + 2 files changed, 9 insertions(+), 6 deletions(-) + +commit 38a55f6118debf994ce1fc41e987b0e3766047ba +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Mar 18 12:08:30 2010 +0100 + + Add support for Set-OCG-State actions + + Fixes bug #23522. + + poppler/Link.cc | 80 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Link.h | 31 ++++++++++++++++++++++ + 2 files changed, 111 insertions(+) + +commit bf398e53b0823d0a6272679858b67c5ffd704425 +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 17 23:06:44 2010 +0100 + + [CMake] fix pkg-config executable variable name + + CMakeLists.txt | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit ab1a37666704d6b15c19b694ee191327847c23da +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 17 23:04:01 2010 +0100 + + [CMake] proper way of looking for pkg-config + + cmake/modules/FindGTK.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 7f07a7dcea031f99a9a6d7c424184a2e69ee0062 +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 17 22:58:08 2010 +0100 + + [CMake] update FindFontconfig.cmake with a more recent version + + ... present in KDE (as before) + + cmake/modules/FindFontconfig.cmake | 15 +++++++++------ + 1 file changed, 9 insertions(+), 6 deletions(-) + +commit beee143ffbdc699ab19f10a01e5747200ea1927a +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 17 18:36:32 2010 +0100 + + [CMake] set the LINK_INTERFACE_LIBRARIES for the poppler and + poppler-cpp libraries + + this should reduce the libraries linked by frontends and utility + applications + + CMakeLists.txt | 1 + + cpp/CMakeLists.txt | 1 + + 2 files changed, 2 insertions(+) + +commit 5ab791cb2a029edcde84b00a47165adfe4d98a98 +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 17 16:39:38 2010 +0100 + + [CMake] small cleanups in FindGTK.cmake + + - update the header will all the stuff found and the variables set + - add my copyright for this year + - remove no more useful UsePkgConfig inclusion + + cmake/modules/FindGTK.cmake | 17 ++++++++++++----- + 1 file changed, 12 insertions(+), 5 deletions(-) + +commit fcbc76d82e3059c8288fbdc8da117ac9b38a70f2 +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 17 16:36:41 2010 +0100 + + [CMake] switch gtk2 (gtk+, gdk-pixbuf, gthread, gio) search to use + the new pkg_check_modules() way + + cmake/modules/FindGTK.cmake | 27 ++------------------------- + 1 file changed, 2 insertions(+), 25 deletions(-) + +commit 5b8135e0899aa3578045eca40940a3495c48d895 +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 17 16:27:40 2010 +0100 + + [CMake] link poppler-glib to the gdk2 libraries, if gdk2 was found + + glib/CMakeLists.txt | 3 +++ + 1 file changed, 3 insertions(+) + +commit 3dc4979d72048e81ae3b2d60dab11e791ac95696 +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 17 16:26:04 2010 +0100 + + [CMake] switch gdk2 search to use the new pkg_check_modules() way + + cmake/modules/FindGTK.cmake | 13 +------------ + 1 file changed, 1 insertion(+), 12 deletions(-) + +commit 0ef3d899cb8dea75c97ae1038cac5006f97bc0d2 +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 17 16:05:07 2010 +0100 + + [CMake] switch glib2 search to use the new pkg_check_modules() way + + cmake/modules/FindGTK.cmake | 18 ++---------------- + 1 file changed, 2 insertions(+), 16 deletions(-) + +commit d2dc83cb8de481e44ea584eee77881978af920fa +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 17 15:56:16 2010 +0100 + + [CMake] rename GLIB_VERSION to GLIB_REQUIRED + + this way it matches autotools, and it is going to not conflict with + my next changes + + CMakeLists.txt | 4 ++-- + cmake/modules/FindGTK.cmake | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit 34accfe27305cae18e09243ab2a607287b86fa47 +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 17 13:55:09 2010 +0100 + + [CMake] set all the definitions for poppler-glib in a single place + + glib/CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 3d93daf50c61019ca70f42e7ccf33897800b262a +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 17 13:49:22 2010 +0100 + + [CMake] no need to check for BUILD_GTK_TESTS for single tests + + poppler_add_test(... BUILD_GTK_TESTS ...) takes care of that already + + glib/CMakeLists.txt | 4 ++-- + test/CMakeLists.txt | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +commit 946a11345d01d39538d22114e50aa3e179059883 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 15 20:24:25 2010 +0100 + + [build] Update cmake files + + CMakeLists.txt | 2 ++ + glib/CMakeLists.txt | 4 ++++ + 2 files changed, 6 insertions(+) + +commit 922c0fe392ba439453edb5b2e88b74f0caa586b3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 15 20:08:23 2010 +0100 + + [glib-demo] Rendition actions demo + + glib/demo/utils.c | 112 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 112 insertions(+) + +commit 163b3f79d67543bc37b64875e30dcc9b7053e1d5 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 15 20:08:00 2010 +0100 + + [glib] Add support for rendition actions + + glib/poppler-action.cc | 22 ++++++++++++++++++++++ + glib/poppler-action.h | 14 +++++++++++++- + 2 files changed, 35 insertions(+), 1 deletion(-) + +commit d9b1e40751beddf48a8694b20bfcc4b4cb41060a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 15 20:06:45 2010 +0100 + + [glib] Add PopplerMedia representing a Rendition Media Clip + + glib/Makefile.am | 2 + + glib/poppler-media.cc | 302 + +++++++++++++++++++++++++++++++++++++++++++++++++ + glib/poppler-media.h | 53 +++++++++ + glib/poppler-private.h | 2 + + glib/poppler.h | 2 + + 5 files changed, 361 insertions(+) + +commit 0224b81c4729a98a56b7a68054422ea655018d6a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 15 17:54:03 2010 +0100 + + [glib-demo] Add page number to annots demo + + glib/demo/annots.c | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 0153b892c63e4fccd0819150cf7b4213857a11c5 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 15 17:49:51 2010 +0100 + + [glib] Add poppler_annot_get_page_index() to get the page associated + to annot + + glib/poppler-annot.cc | 19 +++++++++++++++++++ + glib/poppler-annot.h | 1 + + 2 files changed, 20 insertions(+) + +commit b47337ea91696fea8f42a68a6fa160681ab284b2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 15 17:49:17 2010 +0100 + + [annots] Checks screen annots associated with a rendition action + have a valid page ref + + poppler/Annot.cc | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 9417fd793ec8d806822669aa614193073e7dfe50 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 15 16:52:30 2010 +0100 + + [annots] Save page index of the page associated with the annot + + poppler/Annot.cc | 14 +++++--------- + poppler/Annot.h | 4 ++-- + 2 files changed, 7 insertions(+), 11 deletions(-) + +commit 36b76a5d01b74c6381433b6f6f7ffb9f02696a60 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 15 14:12:11 2010 +0100 + + Rework LinkRendition to follow the spec + + poppler/Link.cc | 68 + +++++++++++++++++++++++++++++++++++---------------------- + poppler/Link.h | 12 ++++++---- + 2 files changed, 50 insertions(+), 30 deletions(-) + +commit 7b5885ee7d2026df9a6e87327b6d02f37d79b8b2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 15 12:25:12 2010 +0100 + + [glib-demo] Annot screen demo + + glib/demo/annots.c | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +commit bdb76c7cb89bcb6fb139b0ef348d96b7780d57ed +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 15 12:24:19 2010 +0100 + + [glib] Add support for screen annotation + + Based on patch by Sam Kaplan. + + glib/poppler-annot.cc | 75 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + glib/poppler-annot.h | 8 ++++++ + glib/poppler-page.cc | 3 ++ + glib/poppler-private.h | 1 + + glib/poppler.h | 1 + + 5 files changed, 88 insertions(+) + +commit 54892b1375e360113432b07c6ba058f861d21fe8 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 15 12:21:30 2010 +0100 + + [annots] Save the action already parsed in AnnotScreen + + poppler/Annot.cc | 9 +++++++-- + poppler/Annot.h | 5 +++-- + 2 files changed, 10 insertions(+), 4 deletions(-) + +commit 5a84a2d749478f19631dbfad2be06ec4ea85038c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 15 11:16:17 2010 +0100 + + [glib-demo] Annot and links movie demo + + glib/demo/annots.c | 20 ++++++++++ + glib/demo/utils.c | 115 + ++++++++++++++++++++++++++++++++++++++++++++++++++++- + glib/demo/utils.h | 3 ++ + 3 files changed, 137 insertions(+), 1 deletion(-) + +commit 2cf5ee4f62089df099f78cd4d39a4eb7589d1b47 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 15 11:04:17 2010 +0100 + + [glib] Add support for movie actions + + Based on patch by Hugo Mercier. + + glib/poppler-action.cc | 35 ++++++++++++++++++---- + glib/poppler-action.h | 15 ++++++++-- + glib/poppler-page.cc | 81 + +++++++++++++++++++++++++++++++++++++++++++++++++- + glib/poppler-private.h | 2 ++ + 4 files changed, 125 insertions(+), 8 deletions(-) + +commit 132b6f072fefd231d42f31626f1b5009c4e8319e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 15 10:56:23 2010 +0100 + + [glib] Add support for movie annotations + + Based on patch by Hugo Mercier. + + glib/poppler-annot.cc | 97 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + glib/poppler-annot.h | 10 ++++++ + glib/poppler-page.cc | 3 ++ + glib/poppler-private.h | 1 + + glib/poppler.h | 1 + + 5 files changed, 112 insertions(+) + +commit aecad2bb12be44825d273e364ec6a0444dac5605 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 15 10:48:03 2010 +0100 + + [glib] Add PopplerMovie class + + glib/Makefile.am | 2 + + glib/poppler-movie.cc | 140 + +++++++++++++++++++++++++++++++++++++++++++++++++ + glib/poppler-movie.h | 42 +++++++++++++++ + glib/poppler-private.h | 2 + + glib/poppler.h | 2 + + 5 files changed, 188 insertions(+) + +commit 5b3234a16e0d465bff2b5e277cb64b4f4b0a8dbd +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Mar 14 16:10:26 2010 +0100 + + Split Movie class into Rendition and Movie classes to follow the spec + + poppler/Annot.cc | 16 +- + poppler/Link.cc | 10 +- + poppler/Link.h | 6 +- + poppler/Makefile.am | 2 + + poppler/Movie.cc | 438 + +++++------------------------------------------ + poppler/Movie.h | 138 +++------------ + poppler/Rendition.cc | 400 + +++++++++++++++++++++++++++++++++++++++++++ + poppler/Rendition.h | 157 +++++++++++++++++ + qt4/src/poppler-movie.cc | 9 +- + 9 files changed, 657 insertions(+), 519 deletions(-) + +commit f9c163730478e3b6d8a1e73dbae6c52c28ae1e84 +Author: Pino Toscano <pino@kde.org> +Date: Mon Mar 8 14:49:12 2010 +0100 + + [Qt4] include Object.h and Annot.h, now needed + + qt4/src/poppler-movie.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit a00532f509c19c5455e0db5068db95dd4583e8dd +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 8 14:22:53 2010 +0100 + + Check for Null instead of None to know whether a dict entry is present + + Dict::lookup returns obj->initNull() when the key is not found. + + poppler/Movie.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit b51e66c9a7e2f7f39ae1edf8bda02a7bc1ad4ebd +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 8 14:15:22 2010 +0100 + + [annots] Create appearance stream for Movie Annotations when not + defined + + See bug #23108 + + poppler/Annot.cc | 103 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++- + poppler/Annot.h | 4 ++- + 2 files changed, 105 insertions(+), 2 deletions(-) + +commit fae59411852e5c2c45825c5ea963318f1ed5dc6a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 8 14:07:09 2010 +0100 + + Fix handling of poster in Movie + + Poster is not always a stream, it can be a boolean too. Also, get the + reference when available instead of fetching the stream. + + poppler/Movie.cc | 25 ++++++++++++------------- + poppler/Movie.h | 6 ++++-- + 2 files changed, 16 insertions(+), 15 deletions(-) + +commit a451f83d101bf265a1e7e2a17c0b320895e70f4e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Mar 7 12:22:57 2010 +0100 + + Save width, height (aspect) in Movie object and provide getAspect() + method + + poppler/Movie.cc | 3 ++- + poppler/Movie.h | 4 ++++ + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit f88d469f860da17055fc4b98b64aef241fcf0185 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Mar 6 12:33:40 2010 +0100 + + Move Movie objects parsing code from Annot to Movie + + poppler/Annot.cc | 244 + ++------------------------------------------- + poppler/Annot.h | 73 +------------- + poppler/Link.cc | 4 +- + poppler/Movie.cc | 255 + +++++++++++++++++++++++++++++++++++++++-------- + poppler/Movie.h | 25 +++-- + qt4/src/poppler-movie.cc | 11 +- + 6 files changed, 246 insertions(+), 366 deletions(-) + +commit ec9138b574c7226ad733880d3d43b86bb72073f4 +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 23:17:50 2010 +0100 + + [autotools] add also cpp/tests/CMakeLists.txt to the "dist files" + + Makefile.am | 1 + + 1 file changed, 1 insertion(+) + +commit ef3258d6fc57e7a62d951cc826804e50e8e1b526 +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 23:14:12 2010 +0100 + + [autotools] fix location of poppler-config.h.cmake + + Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit fd1d9c882997ff35acd5a458e9dfeba3ad6c8b25 +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 22:42:06 2010 +0100 + + [CMake] just enable what needed each time + + CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 476bde472a7e694afde96a04ea335fe9582d6fad +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 22:39:45 2010 +0100 + + [CMake] add small description for the zlib option + + taken from two bits in configure.ac + + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1267d7e0c36e262984070a3b55fea46e7289a4b4 +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 19:34:03 2010 +0100 + + [CMake] add a note about gtk-doc not supported yet + + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 201b18ad0837e84d874b56e1b0469d1b2d45378b +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 19:30:36 2010 +0100 + + [CMake] sync with poppler-config.h.in: add + WITH_FONTCONFIGURATION_{FONTCONFIG,WIN32} + + poppler/poppler-config.h.cmake | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +commit 0d0044e8cc2d406f066338102ec73e1b56214cc3 +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 19:25:27 2010 +0100 + + [CMake] move poppler-config.h.cmake in the poppler subdirectory, + where poppler-config.h.in is + + CMakeLists.txt | 2 +- + poppler-config.h.cmake | 90 + ------------------------------------------ + poppler/poppler-config.h.cmake | 90 + ++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 91 insertions(+), 91 deletions(-) + +commit f785e29a901d2c76204dd26e9585446fdd817ebd +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 18:35:34 2010 +0100 + + [CMake] remove the generated poppler-enums.{c,h} in the clean target + + ie usually when doing `make clean' + + glib/CMakeLists.txt | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 369604603375dbe3516136b6f8f9d0c26e0b744f +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 18:26:45 2010 +0100 + + [CMake] use the --template option of glib-mkenums (like done with + autotools) + + glib/CMakeLists.txt | 24 ++++-------------------- + 1 file changed, 4 insertions(+), 20 deletions(-) + +commit bbcbb34fec10c90edd5960bdbcc6849bc8f39526 +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 17:34:40 2010 +0100 + + [CMake] set POPPLER_GLIB_DISABLE_DEPRECATED and + POPPLER_GLIB_DISABLE_SINGLE_INCLUDES as done with autotools + + CMakeLists.txt | 6 ++++++ + glib/CMakeLists.txt | 6 +++++- + 2 files changed, 11 insertions(+), 1 deletion(-) + +commit 190fa971c12ca1b3007f6ba349a77a7c15c47490 +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 17:24:25 2010 +0100 + + reorder to match what's in the correspondent .in + + glib/poppler-features.h.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ff46def8b178420a86a974ec2ce767a538bba8be +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 17:23:16 2010 +0100 + + [CMake] GDK_FEATURE is no more needed here + + glib/CMakeLists.txt | 1 - + 1 file changed, 1 deletion(-) + +commit 1eb8026a3060ef61a88c535177510f7ac7e7fc25 +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 17:19:58 2010 +0100 + + [CMake] set in one place whether to build the glib frontend + + CMakeLists.txt | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +commit a1a6f23e2345814e147a72211ce9139555385223 +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 17:09:58 2010 +0100 + + [CMake] correctly set the GLIB_REQ stuff + + CMakeLists.txt | 1 + + poppler-glib.pc.cmake | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +commit 0f2e5d6925c5938281d9bafc297a43867c4a915b +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 17:03:21 2010 +0100 + + [CMake] move the minimum GLib version to the main CMakeLists.txt + + CMakeLists.txt | 1 + + cmake/modules/FindGTK.cmake | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +commit efdffba45d15b538dbfb294403e99f3a6470b4d9 +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 16:58:27 2010 +0100 + + [CMake] align the GDK stuff (GDK_{FEATURE,REQ}) to what done with + autotools + + CMakeLists.txt | 6 +++++- + poppler-glib.pc.cmake | 2 +- + 2 files changed, 6 insertions(+), 2 deletions(-) + +commit cfecc69b7f05920f543ee7e9aafeafaa4c3506fb +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 16:49:14 2010 +0100 + + [CMake] apparently there's not a minimum version requirement for GDK, + so drop the check + + cmake/modules/FindGTK.cmake | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +commit 8ff1cf03d2607b0f13bbbbf272f2b03d8927bd24 +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 16:47:21 2010 +0100 + + [CMake] first look for Cairo, then for GLib/GDK/GTK + + this starts to align to the searches done with autotools + also, move the CAIRO_FEATURE to the main CMakeLists.txt + + CMakeLists.txt | 19 +++++++++++-------- + glib/CMakeLists.txt | 1 - + 2 files changed, 11 insertions(+), 9 deletions(-) + +commit bcaf62b8e252594530d3050761ba563cf3b1fb6e +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 16:00:03 2010 +0100 + + [CMake] enhance/rewrite a bit the FindCairo module + + make use of some features of CMake 2.6 (as we require it): + - newer pkg-config handling (aka pkg_check_modules()) + - version checking for modules (PACKAGE_FIND_VERSION*) + - find_package_handle_standard_args() + also, after the pkg-config search to win32, search for cairo again + (double-check plus real search for win32) + furthermore, introduce CAIRO_INCLUDE_DIRS with the include paths + requires (kind of "obsoletes" CAIRO_CFLAGS, left there in case it + is used again) + + apply the changes to the rest of the build system (specify the + version needed, use the correct variable for includes) + + CMakeLists.txt | 2 +- + cmake/modules/FindCairo.cmake | 64 + +++++++++++++++++++++++++++---------------- + glib/CMakeLists.txt | 2 +- + 3 files changed, 43 insertions(+), 25 deletions(-) + +commit c96aa0f5fc74ae04f483485b787aaf65f1791991 +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 02:01:13 2010 +0100 + + add Patrick's copyright notices + + cpp/poppler-global.h | 1 + + goo/gtypes.h | 14 ++++++++++++++ + poppler/GlobalParams.cc | 1 + + poppler/SplashOutputDev.cc | 1 + + 4 files changed, 17 insertions(+) + +commit 3311bedd2eb831ef1fd553f3f50960331cf6885f +Author: Patrick Spendrin <ps_ml@gmx.de> +Date: Sun Mar 7 01:56:15 2010 +0100 + + MSVC: disable for the 'ustring' class the warning C4251 (which does + not apply) + + cpp/poppler-global.h | 8 ++++++++ + 1 file changed, 8 insertions(+) + +commit 9efa18397bd05fbd27c7811fa6e0f34ce94012e0 +Author: Patrick Spendrin <ps_ml@gmx.de> +Date: Sun Mar 7 01:48:03 2010 +0100 + + MSVC: disable warning C4800, which is of no use for now + + goo/gtypes.h | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 3a88d1bf8d2c5a9e8014e0d46e24c9ec06556469 +Author: Patrick Spendrin <ps_ml@gmx.de> +Date: Sun Mar 7 01:26:10 2010 +0100 + + MSVC: no isfinite(), so provide it using _finite() + + poppler/SplashOutputDev.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 7774912c46f832f25c51b4cfc0e9430b1cd7fa1f +Author: Patrick Spendrin <ps_ml@gmx.de> +Date: Sun Mar 7 01:22:31 2010 +0100 + + MSVC: do not force constness here, so the right overload will + be chosen + + poppler/GlobalParams.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit cf07a5d85b402b6956c9605fbdc88bddcb94a3cf +Author: Pino Toscano <pino@kde.org> +Date: Sun Mar 7 00:49:07 2010 +0100 + + [CMake] show end yes/no message about the GDK usage + + just like done with autotools + + CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit 42c98f8eabe304d5e3dc8c1ebdd5b0b6c221e696 +Author: Pino Toscano <pino@kde.org> +Date: Sat Mar 6 17:18:08 2010 +0100 + + [CMake] make the font configuration backend selection take a string + (like with autotools) + + this way it is possible to set the cmake variable FONT_CONFIGURATION + to either "win32" (default on windows) or "fontconfig" (default + elsewhere) to the font backend to use + as a consequence, make fontconfig a requirement only if the font + backend chosen is "fontconfig" + + CMakeLists.txt | 39 +++++++++++++++++++++++++++++---------- + 1 file changed, 29 insertions(+), 10 deletions(-) + +commit bda6e7cd089f2970af2e9540b4415633ffcf0ebb +Author: Pino Toscano <pino@kde.org> +Date: Sat Mar 6 17:13:30 2010 +0100 + + [CMake] add a show_end_message() macro to show a generic string + as value + + make show_end_message_yesno() call it with the proper "yes" or + "no" string + + cmake/modules/PopplerMacros.cmake | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +commit d313c0f508711b3b7166b84608c43ebf1f07194b +Author: Pino Toscano <pino@kde.org> +Date: Sat Mar 6 17:08:59 2010 +0100 + + [CMake] rename the show_end_message() macro to + show_end_message_yesno() + + CMakeLists.txt | 26 +++++++++++++------------- + cmake/modules/PopplerMacros.cmake | 4 ++-- + 2 files changed, 15 insertions(+), 15 deletions(-) + +commit 0425ff835fa26df5e25e628a6c56f3a180713905 +Author: Pino Toscano <pino@kde.org> +Date: Fri Mar 5 22:21:56 2010 +0100 + + update copyright + + poppler/ArthurOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit c5ea135ca58e112110be3ae10d887f3188172765 +Author: Pino Toscano <pino@kde.org> +Date: Fri Mar 5 22:14:57 2010 +0100 + + [arthur] update the miter limit + + poppler/ArthurOutputDev.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 552f344b3e3df7c796afa6946149b0a5590cc4f7 +Author: Pino Toscano <pino@kde.org> +Date: Fri Mar 5 22:04:39 2010 +0100 + + [arthur] update the line dash style + + poppler/ArthurOutputDev.cc | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +commit bc42ee05fceef0d0dd2ab0587c184dfc37cf29bf +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Mar 5 18:54:32 2010 +0000 + + fix copyright year + + poppler/CairoOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit b21461e91ed671ef29fd3cf4780fda44f82a0679 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Mar 5 15:14:08 2010 +0100 + + [cairo] Close image stream before resetting it again + + poppler/CairoOutputDev.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 866bcc7edb47fe11355081045e2d316a4d530649 +Author: Pino Toscano <pino@kde.org> +Date: Thu Mar 4 14:19:50 2010 +0100 + + [Qt4] no need to save&restore on a newly created painter + + qt4/src/poppler-page.cc | 2 -- + 1 file changed, 2 deletions(-) + +commit 654698b556eb53eab7c2d55fc6b3fdd9e35173bb +Author: Pino Toscano <pino@kde.org> +Date: Thu Mar 4 13:16:11 2010 +0100 + + [Qt4] use Arthur unconditionally + + arthur is no more tied to splash, so can be used in an occasion + + qt4/src/poppler-document.cc | 2 +- + qt4/src/poppler-page.cc | 4 +--- + 2 files changed, 2 insertions(+), 4 deletions(-) + +commit 41931b6310d2ae81e622db904246f019ceb8410d +Author: Pino Toscano <pino@kde.org> +Date: Thu Mar 4 13:13:11 2010 +0100 + + [Qt4] compile Arthur unconditionally + + as the arthur output dev does not require splash anymore, we can + always compile it with poppler-qt4 + + poppler/Makefile.am | 4 ++-- + qt4/src/CMakeLists.txt | 6 +----- + qt4/src/Makefile.am | 6 +----- + 3 files changed, 4 insertions(+), 12 deletions(-) + +commit 48a29e2bbc9aa9bd0cb2775a2365c0ffdeb6ce87 +Author: Pino Toscano <pino@kde.org> +Date: Thu Mar 4 13:11:43 2010 +0100 + + [Arthur] make ArthurOutputDev compile even with Splash disabled + + text rendering is disabled in that case for now + + poppler/ArthurOutputDev.cc | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +commit 2013a19b6457753890affad8c4049f2ce4627df7 +Author: Pino Toscano <pino@kde.org> +Date: Thu Mar 4 13:02:43 2010 +0100 + + [CMake/tests] compile gtk-splash-test only if splash is enabled + + test/CMakeLists.txt | 14 +++++++++----- + 1 file changed, 9 insertions(+), 5 deletions(-) + +commit ae740c5cfefbae13f82b750e39fa3dbbdc94858b +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 2 23:22:06 2010 +0100 + + [cpp] update the copyrights + + cpp/poppler-document-private.h | 2 +- + cpp/poppler-document.cpp | 2 +- + cpp/poppler-embedded-file.cpp | 2 +- + cpp/poppler-embedded-file.h | 2 +- + cpp/poppler-global.cpp | 3 ++- + cpp/poppler-global.h | 2 +- + cpp/poppler-page.cpp | 2 +- + cpp/poppler-page.h | 2 +- + cpp/poppler-rectangle.h | 2 +- + cpp/poppler-toc.cpp | 2 +- + cpp/poppler-version.cpp | 2 +- + cpp/tests/poppler-dump.cpp | 2 +- + 12 files changed, 13 insertions(+), 12 deletions(-) + +commit 24b1d8d0b4ae7cea9fbc331f19cd5ce3917b8b4d +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 2 23:15:56 2010 +0100 + + [cpp] {from,to}_utf_8() -> {from,to}_utf8() + + cpp/poppler-global.cpp | 4 ++-- + cpp/poppler-global.h | 4 ++-- + cpp/poppler-page.cpp | 2 +- + 3 files changed, 5 insertions(+), 5 deletions(-) + +commit 690af1bc58de1ebe710c5e599f1cb635e4838fc8 +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Mar 2 16:33:04 2010 +0100 + + [cpp] define poppler_cpp_EXPORTS when building with autotools as well + + fixes building on Windows + + cpp/Makefile.am | 3 +++ + 1 file changed, 3 insertions(+) + +commit 7492a376e7e5ec35534276ac15485123645617b0 +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 2 22:16:07 2010 +0100 + + [cpp/tests] use gmtime() when gmtime_r() is not available + + cpp/tests/poppler-dump.cpp | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +commit de013cc14a0621782c53f481ed7e559f241855a3 +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 2 22:05:25 2010 +0100 + + [cpp] include config.h _after_ the other includes + + cpp/poppler-global.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 388e5d6aebcabbfc90894c86248159c63701cb0a +Author: Hib Eris <hib@hiberis.nl> +Date: Tue Mar 2 15:51:23 2010 +0100 + + Use ICONV_CONST when necessary + + cpp/poppler-global.cpp | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +commit aaa58b26733a2f7c778632da4942b588050cf33f +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 2 21:53:55 2010 +0100 + + [CMake] properly define ICONV_CONST + + CMakeLists.txt | 1 - + cmake/modules/FindIconv.cmake | 3 +++ + config.h.cmake | 2 +- + 3 files changed, 4 insertions(+), 2 deletions(-) + +commit 6304b0d8959fccf96b030c757d78e845d04757e4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 28 15:33:53 2010 +0100 + + poppler 0.13.1 + + CMakeLists.txt | 2 +- + NEWS | 33 +++++++++++++++++++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + 5 files changed, 37 insertions(+), 4 deletions(-) + +commit 9eac71862915c851c07075e3ca3af82eb9e4e775 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 28 15:33:19 2010 +0100 + + Make sure the private headers end up in the tarball on make dist + + cpp/Makefile.am | 5 +++++ + 1 file changed, 5 insertions(+) + +commit b488172311c2921ab4c365d71ad8b1ab7f596c71 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 28 14:25:36 2010 +0100 + + Add copyright notices + + poppler/CairoFontEngine.cc | 3 ++- + poppler/CairoFontEngine.h | 2 +- + 2 files changed, 3 insertions(+), 2 deletions(-) + +commit 5453cff5b7cb47cadfdae585a58409117af8c1f1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Feb 28 13:51:22 2010 +0100 + + [cairo] Select filter for images based on scale factor + + When rendering images and interpolate flag is disabled or missing, we + always interpolate unless scale factor is >= 400% + + See bugs #25268, #9860 + + poppler/CairoOutputDev.cc | 64 + ++++++++++++++++++++++++++++++++++------------- + poppler/CairoOutputDev.h | 2 ++ + 2 files changed, 49 insertions(+), 17 deletions(-) + +commit e65456cbd5cae2750426aabeb2d66a10537616f0 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Feb 28 13:13:13 2010 +0100 + + [cairo] Refactor scaled size computation into a new method + + poppler/CairoOutputDev.cc | 52 + +++++++++++++++++++++++------------------------ + poppler/CairoOutputDev.h | 2 ++ + 2 files changed, 28 insertions(+), 26 deletions(-) + +commit 32aa9ae7d0087298661829265de00e93398272b3 +Author: Jan Kümmel <jan+freedesktop@snorc.org> +Date: Sat Feb 27 17:58:46 2010 +0100 + + [cairo] Omit writing of embedded fonts into tempary files + + Fixes bug #26694. + + poppler/CairoFontEngine.cc | 146 + +++++++++++++++++++++++++-------------------- + 1 file changed, 80 insertions(+), 66 deletions(-) + +commit 7ba52a32343ca73730a80b64c136e3f03348e7d9 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Feb 27 17:42:46 2010 +0100 + + [cairo] Remove unused 'face' from CairoFreeTypeFont class + + poppler/CairoFontEngine.cc | 6 ++---- + poppler/CairoFontEngine.h | 3 +-- + 2 files changed, 3 insertions(+), 6 deletions(-) + +commit 7c3140c88c00282e10888143fffe3c402d48fb05 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Feb 27 13:13:47 2010 +0100 + + Don't use '\' character in PostScript names + + poppler/PSOutputDev.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 8e354a15a1861719c00799937ad9f9bb1bb71e9f +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Wed Feb 24 18:58:11 2010 +0000 + + Fix remaining part of 26243 + + Thomas says: The "gn" is colored with a shading pattern, but the + shading has a bbox, + so it is clipped to this bbox, too. But when coloring text or masks in + pattern colorspace, this is definely wrong. + + poppler/Gfx.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit fcbc571a98775b1daa8f562fc8674fb2d15b6626 +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 23 17:02:47 2010 +0100 + + [cpp] make checksum() return an array of data, instead of a string + + a checksum is a sequence of values after all, so just return it as + such instead of pretending it is a string + accordingly adapt the mini dump application + + cpp/poppler-embedded-file.cpp | 10 ++++++++-- + cpp/poppler-embedded-file.h | 2 +- + cpp/tests/poppler-dump.cpp | 4 ++-- + 3 files changed, 11 insertions(+), 5 deletions(-) + +commit fbefb9bef9f7a099d51919255a98f412d1e1d696 +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 23 16:56:47 2010 +0100 + + [cpp apidox] add API documentation for the 'embedded_file' class + + cpp/poppler-embedded-file.cpp | 43 + +++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 43 insertions(+) + +commit 6d39cca0a035fc656d3b86ba66dedaccee532fcb +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 23 16:41:56 2010 +0100 + + [cpp apidox] add API documentation for the 'toc' and 'toc_item' + classes + + cpp/poppler-toc.cpp | 57 + +++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 57 insertions(+) + +commit 857e4ceb26d959c48c7af6bff53ca1bfe5307236 +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 23 15:39:58 2010 +0100 + + [cpp] when the loading of the document fails, put back the data + where it was before + + cpp/poppler-document-private.h | 2 +- + cpp/poppler-document.cpp | 10 +++++++--- + 2 files changed, 8 insertions(+), 4 deletions(-) + +commit 7838b182143086192ac8dcf571da0ce1743619e2 +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 23 00:04:09 2010 +0100 + + [cpp] add the directory of the generated html apidox to the ignore + list + + cpp/.gitignore | 1 + + 1 file changed, 1 insertion(+) + +commit 71a38a23a9db5cac872c666283b7abcb1462210c +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 22 23:43:34 2010 +0100 + + [cpp] add page::text() to get the text inside a page region + + cpp/poppler-page.cpp | 16 ++++++++++++++++ + cpp/poppler-page.h | 1 + + 2 files changed, 17 insertions(+) + +commit 4c75360233bc67f097551980a46ecce976927220 +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 22 23:05:53 2010 +0100 + + [cpp] add page::search() + + cpp/poppler-page.cpp | 51 + +++++++++++++++++++++++++++++++++++++++++++++++++++ + cpp/poppler-page.h | 8 ++++++++ + 2 files changed, 59 insertions(+) + +commit 8932c53a084083eb42d109dd17bac3ad41ce65b5 +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 22 22:39:36 2010 +0100 + + [cpp] add getters and setters for left/top/right/bottom + + cpp/poppler-rectangle.h | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +commit 8e1ea57f558fa3a1702a17d79b5aaffc486c6a56 +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 22 22:19:51 2010 +0100 + + [cpp] add a global enum for case sensitivity + + cpp/poppler-global.h | 2 ++ + 1 file changed, 2 insertions(+) + +commit ae41b087de8f0a7d525320dcf1d64ff22fe982b6 +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 22 19:06:21 2010 +0100 + + [cpp apidox] doxygen configuration for poppler-cpp + + cpp/Doxyfile | 1551 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 1551 insertions(+) + +commit 1a36a7bcc684065478a3ade2c2938f0e3672140a +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 22 19:05:49 2010 +0100 + + [cpp apidox] very small start of intro page + + cpp/Mainpage.dox | 9 +++++++++ + 1 file changed, 9 insertions(+) + +commit 85e052ab7a4c462143325ecf60eebba35411b790 +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 22 18:53:20 2010 +0100 + + [cpp apidox] start adding API documentation for the global 'poppler' + namespace + + ... including the 'convert_date' function and faking the 'noncopyable' + class + + cpp/poppler-global.cpp | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +commit b01608f91fb6cf6e9c4fb6e6ee3cb57517a766bf +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 22 18:52:24 2010 +0100 + + [cpp apidox] exclude the 'detail' namespace from apidox extraction + + this includes also the 'noncopyable' typedef, but that will be + handled differently + + cpp/poppler-global.h | 2 ++ + 1 file changed, 2 insertions(+) + +commit f17a7a8cfdeabb3ced3ba8d42c869d892c528e13 +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 22 18:51:30 2010 +0100 + + [cpp apidox] add API documentation for the version functions + + cpp/poppler-version.cpp | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +commit f6c4bbddc7d04c0b1a6b25c41cbf6d81ae40cc0c +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 22 18:50:54 2010 +0100 + + [cpp apidox] start adding API documentation for 'document' + + cpp/poppler-document.cpp | 182 + +++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 182 insertions(+) + +commit cbb7519904d9b6395d0128e16a79324e4b8bfcc0 +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 22 13:15:11 2010 +0100 + + [CMake] no more need to build system check for the Cairo blend modes + + followup of 880890c14e99a954b365a3a6b59deeffa5304d30 for the cmake + build system + + cmake/modules/FindCairo.cmake | 18 ------------------ + config.h.cmake | 3 --- + 2 files changed, 21 deletions(-) + +commit 80f47bbf45faf751c661c1d0931e8e1da622b8ca +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Feb 22 12:43:06 2010 +0100 + + [cairo] Use cairo_surface_set_mime_data() when printing + + When rendering a jpeg image for printing, using + cairo_surface_set_mime_data() to attach the jpeg stream to the + surface reduces drastically the size of the output file. + + poppler/CairoOutputDev.cc | 42 ++++++++++++++++++++++++++++++++++++++++++ + poppler/CairoOutputDev.h | 1 + + 2 files changed, 43 insertions(+) + +commit d63293af6dbff65f160be0118b1580c03a1aab56 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Nov 27 09:52:23 2009 +0100 + + [cairo] Turn EXTEND_PAD off when printing + + poppler/CairoOutputDev.cc | 98 + ++++++++++++++++++++++++++++++++--------------- + 1 file changed, 67 insertions(+), 31 deletions(-) + +commit 880890c14e99a954b365a3a6b59deeffa5304d30 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Feb 22 11:01:05 2010 +0100 + + [cairo] Use CAIRO_VERSION macros to check whether blend modes are + available + + configure.ac | 24 ------------------------ + poppler/CairoOutputDev.cc | 4 ++-- + 2 files changed, 2 insertions(+), 26 deletions(-) + +commit 5c300ce00b5c59da767ca1ffec12f96f0ebbe701 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 21 21:20:10 2010 +0100 + + [Qt4/apidox] fix typo + + qt4/src/poppler-qt4.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 3f89ccf871e2f4a14129ad3e986b8cd19cdf129c +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 21 21:06:31 2010 +0100 + + [CMake] set the CXXFLAGS in a better way + + CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit a18dab9e53a20a76eb46fa3a868fffdd3c754ce2 +Merge: fa09892 f3862f7 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 21 19:56:38 2010 +0100 + + Merge remote branch 'origin/cpp-frontend' + + * origin/cpp-frontend: (34 commits) + [cpp/tests] poppler-dump: show a string for the font type + [cpp/tests] poppler-dump: show the orientation of the pages + [cpp/tests] poppler-dump: a bit less output in permissions lines + [cpp/tests] poppler-dump: add --show-all to show all the information + [cpp] use iconv for the utf8 <-> utf16 conversions + [cpp] add the build system stuff for iconv, mandatory for cpp + [cpp] fixup unicode GooString <-> ustring conversions + [cpp] fix installation of poppler-version.h with autotools and + builddir != srcdir + simplify + [cpp/tests] add a simple poppler-dump test + [cpp] use the correct index (instead of an uninitialized variable) + [cpp] properly delete the children of a toc item + [cpp] actually implement toc::root() + [cpp] fix the reference to the vector data + [cpp] fix the reference to the vector data + [cpp] add destructor for 'rectangle' + [cpp] add out stream operators for rect and rectf + [cpp] add namespace to namespace functiond to link properly + [cpp] add default empty parameters for the passwords of the document + loading functions + [cpp] add "human friendly" output representation for byte_array + ... + + Conflicts: + config.h.cmake + +commit fa0989297e95b6adebed71336ea206d1b279ab24 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 21 16:59:57 2010 +0000 + + Detect the need for nanosleep in solaris + + Fixes bug 26650 + + ConfigureChecks.cmake | 5 +++++ + test/CMakeLists.txt | 17 +++++++++++------ + 2 files changed, 16 insertions(+), 6 deletions(-) + +commit d074485aa9d9fac6b715382002f53e3303bbc519 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 20 10:08:33 2010 +0000 + + Do not call getPixel if we know how to access the data + + Gives a 20% speed increase in some pdf + + splash/Splash.cc | 19 ++++++++++--------- + 1 file changed, 10 insertions(+), 9 deletions(-) + +commit d4cafe357bd86feb4b56e5dfbf5b7822e237a2ee +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 20 10:07:20 2010 +0000 + + Only call getPixel when really needed + + Gives a 8% speed increase in some pdf + + splash/Splash.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit c3122cfbe090f3a4045269222f941cd5ce77c171 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 20 10:04:37 2010 +0000 + + Move test code to the header to it can be inlined + + Gives a 10% speed increase in some documents + + splash/SplashClip.cc | 40 ++++++++++++++-------------------------- + splash/SplashClip.h | 43 +++++++++++++++++++++++++++++++++++++++++-- + 2 files changed, 55 insertions(+), 28 deletions(-) + +commit d987fb9b77e6da454eb898cc6c8baaf747b7ac4f +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Feb 19 23:59:03 2010 +0000 + + implement writeImgFile for splashModeXBGR8 + + splash/SplashBitmap.cc | 25 +++++++++++++++++++++++-- + 1 file changed, 23 insertions(+), 2 deletions(-) + +commit f9425c0b5b112ac673d0499f79a743afce719593 +Author: Hib Eris <hib@hiberis.nl> +Date: Fri Feb 19 20:18:13 2010 +0000 + + use pkgconfig to detect libpng on autotools too + + configure.ac | 12 ++++--- + goo/Makefile.am | 7 +++- + m4/libpng.m4 | 99 + ----------------------------------------------------- + poppler/Makefile.am | 3 ++ + 4 files changed, 17 insertions(+), 104 deletions(-) + +commit 0cb07d645527f25997f5e1b104a6be92441d8ffa +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Feb 18 23:27:20 2010 +0000 + + Only swap w with h if rotation is 90 or 270 + + utils/pdftoppm.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 35015ed11090d67cab69443e607d4d80ca03c619 +Author: Nils Höglund <nils.hoglund@gmail.com> +Date: Thu Feb 18 23:14:51 2010 +0000 + + Match the number of calls to beginMarkedContent and endMarkedContent + + poppler/Gfx.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit ee265760e6ecec93fe26fb8e02848872555daefd +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Feb 18 23:13:48 2010 +0000 + + make sure properties exists before using it + + poppler/TextOutputDev.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit eab7a55815c06525c7aeba254b66498ab147a958 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 17 21:54:31 2010 +0000 + + if malloc failed return false + + splash/SplashFTFont.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit e2def20a45c1d8307fd62fabb9769121af975abf +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 16 23:31:05 2010 +0000 + + Only assume the OC is not visible if it exists and is set to no + + Fixes bug 26532 and a small line that was not drawn in 15899 + + poppler/OptionalContent.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 5edd175bdd0f7c2fc3aecb72384de4cb0788fc4e +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 16 20:57:22 2010 +0000 + + Add and fix copyright years + + poppler/CairoOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0f0fba1b04589061449f98b9dcd8a0c4e7ad2d74 +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 16 22:00:51 2010 +0100 + + make the descriptions specify they refer to the Splash backend + + config.h.cmake | 4 ++-- + configure.ac | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +commit 39b4699020b5cfa1a10e5ef00f0e355e27b21c9f +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 16 21:56:30 2010 +0100 + + [CMake] reflect that poppler-glib needs cairo now + + poppler-glib.pc.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5c66c775bcd686c61ea136bcd8f261fb631c5e71 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 16 20:52:15 2010 +0000 + + We don't need to pass anything to FontConfig + + Makes it much easier to manage and also fixes bug 26544 + + poppler/GlobalParams.cc | 11 +++-------- + poppler/GlobalParams.h | 6 +----- + 2 files changed, 4 insertions(+), 13 deletions(-) + +commit 582b5259b3c65ee1bef99dbdfccf00f37269b76f +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 16 16:36:24 2010 +0100 + + [CMake] find the system threads, and define in the config.h if we + have pthreads + + CMakeLists.txt | 4 ++++ + config.h.cmake | 3 +++ + 2 files changed, 7 insertions(+) + +commit 1dff9d440556a155fb5ca7bed15fc6a1f77a1c97 +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 16 16:10:44 2010 +0100 + + [CMake] add the HAVE_LIBOPENJPEG and HAVE_OPENJPEG_H defines, to + match autotools' ones + + CMakeLists.txt | 1 + + config.h.cmake | 6 ++++++ + 2 files changed, 7 insertions(+) + +commit 4a0bcaa83e6e6533cd48c63449a08467d51c13ea +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 16 16:01:53 2010 +0100 + + [CMake] config.h.cmake: change some comments to match autotools' ones + + config.h.cmake | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +commit 9e38082c3e571d035f0152d65661e5dd97fdd5d8 +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 16 15:58:30 2010 +0100 + + [CMake] add the Win32-specific ENABLE_RELOCATABLE option, matching + autotools' one + + CMakeLists.txt | 5 +++++ + config.h.cmake | 3 +++ + 2 files changed, 8 insertions(+) + +commit eb03020893ed591c18817d75d427a1296cb1f233 +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 16 15:49:50 2010 +0100 + + [CMake] config.h.cmake: move POPPLER_WITH_GDK in the same place of + autotools' generated one, and with the same comment + + config.h.cmake | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit ba65b3af047b758094b999b2939065c5127508dd +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 10 23:08:04 2010 +0000 + + Wrap #include <jpeglib.h> in extern "C" to fix build + + Fixes bug 26351 + + goo/JpegWriter.h | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit d3d2a3ee0a3505f44d1196823716b768d434ba73 +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 10 23:16:27 2010 +0100 + + [CMake] fix typo: "MULTITHREAD" -> "MULTITHREADED" + + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0dae2294cf8a2f312d8e6504be4e1be516b34b1b +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Tue Feb 9 21:44:07 2010 +0000 + + Fix regression in painting. Fixes bug 26243 + + poppler/Gfx.cc | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +commit aa9c3acbc73bafb33c8a797701ed0488a4a74263 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jan 28 17:23:18 2010 +0100 + + [cairo] Add clipToStrokePath() method + + It's unimplemented, it just contains a log message to help when + debugging. + + poppler/CairoOutputDev.cc | 4 ++++ + poppler/CairoOutputDev.h | 1 + + 2 files changed, 5 insertions(+) + +commit 41a450c8db45fd064798d15c3d8fe5ab536a7b30 +Author: David Benjamin <davidben@mit.edu> +Date: Fri Jan 22 00:26:59 2010 -0500 + + [cairo] Avoid leaving pointers to free'd memory + + Fixes potential free'd memory access introduced by + 3a94e8ce90c0a4d11c5c5aa8805c167c8a0434e5. I don't think this is + actually + possible in the current code; we push/pop before and after rendering a + PDF, so the bottom state should never have a mask. + + Still, better to clean this up. + + poppler/CairoOutputDev.cc | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +commit 309228404710debee4337cc53c641dfef64ad86c +Author: David Benjamin <davidben@mit.edu> +Date: Wed Jan 27 22:41:16 2010 +0000 + + Allow commands to abort the current stream + + In many instances, the sensible response (and what acroread does) in + case of an error is abort the PDF stream. To avoid changing the return + value of every function and using C++ exceptions, we communicate via a + commandAborted variable. + + This patch, matching acroread's behavior aborts the current stream + when + there are too few arguments or we pop too many times. Implementation + note 39 in Appendix H of the PDF reference contradicts the former, but + hand-crafted test PDFs as well as the file in #24575 suggest + otherwise. + + Unlike all the other attempts, this patch actually fixes the PDF in + bug #24575. + + poppler/Gfx.cc | 11 +++++++++++ + poppler/Gfx.h | 1 + + 2 files changed, 12 insertions(+) + +commit 8284008aa8230a92ba08d547864353d3290e9bf9 +Author: David Benjamin <davidben@mit.edu> +Date: Wed Jan 27 22:40:33 2010 +0000 + + Add a stack of stateGuards to Gfx + + While a stack of states is a good way to maintain graphics contexts, + if + the command stream you are interpreting is untrusted, we must place + appropriate guards to be sure that, not only do we not pop past + the end + of the stack, but we do not pop past the stack as it was when we began + rendering. + + poppler/Gfx.cc | 30 +++++++++++++++++++++++++++++- + poppler/Gfx.h | 11 +++++++++++ + 2 files changed, 40 insertions(+), 1 deletion(-) + +commit 4ae84c830f842d100cbb702b32970951a5a5769f +Author: David Benjamin <davidben@mit.edu> +Date: Wed Jan 27 22:39:20 2010 +0000 + + Maintain the height of the stack in Gfx + + Introduces a new variable Gfx::stackHeight that maintains up-to-date + information about the current height of the stack. + + poppler/Gfx.cc | 4 ++++ + poppler/Gfx.h | 1 + + 2 files changed, 5 insertions(+) + +commit 120fe6ef673c648ae7b19ad2a7e9aef22ee25810 +Author: David Benjamin <davidben@mit.edu> +Date: Wed Jan 27 22:38:43 2010 +0000 + + Do not use objects just after deleting them + + The error condition in GfxCIDFont::GfxCIDFont references cMapName and + collection, so they should not be deleted yet. + + poppler/GfxFont.cc | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +commit 3375fa96c7a7dbbb98f5a7b3df9e840a5f30bc80 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 27 22:32:29 2010 +0000 + + GooVector rewrite, old version had "unknown" origins/license + + goo/GooVector.h | 237 + +++++++++++++++++++++++++++++++++----------------------- + 1 file changed, 141 insertions(+), 96 deletions(-) + +commit a945fe64e16ac9aa2577c5db05fc7f3fd4955b7b +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jan 27 16:15:40 2010 +0100 + + [cairo] Fix downscaling images when document is rotated + + Fixes bug #26264. + + poppler/CairoOutputDev.cc | 37 +++++++++++++++++++++++++++++++++++-- + 1 file changed, 35 insertions(+), 2 deletions(-) + +commit 428cc965c17f167ea00540beeaeaac5c3e426686 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jan 26 21:01:32 2010 +0000 + + Add POPPLER_WITH_GDK in cmake build system + + Bug 26247 + + glib/CMakeLists.txt | 1 + + glib/poppler-features.h.cmake | 1 + + 2 files changed, 2 insertions(+) + +commit 0af1ae75fd4c8031343f668bed5d8ca6588ee652 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jan 26 20:49:17 2010 +0100 + + [cairo] Use the right matrix for the mask in drawMaskedImage() + + Fixes bug #16906. + + poppler/CairoOutputDev.cc | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +commit d8ceaff39f5b80624b6bdc703c2a180dfc3d73ee +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jan 26 11:57:06 2010 +0100 + + [cairo] Add some more LOG messages + + poppler/CairoOutputDev.cc | 18 +++++++++++++++--- + 1 file changed, 15 insertions(+), 3 deletions(-) + +commit 778e764b3cb77526260c3c8b46acf19ad06fc61d +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jan 25 22:40:20 2010 +0000 + + poppler 0.13.0 + + CMakeLists.txt | 4 +-- + NEWS | 99 + +++++++++++++++++++++++++++++++++++++++++++++++++++++ + configure.ac | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 5 files changed, 104 insertions(+), 5 deletions(-) + +commit 1b5333f2685b8ab85bb1f5b899332c5a0ac99a3d +Author: Pino Toscano <pino@kde.org> +Date: Mon Jan 25 02:19:00 2010 +0100 + + [CMake] allow multiple targets with the same name + + this is needed for building the unit tests later without explicitly + having + enabling them at configure time (thus compile them on-demand) + for this, set the cmake policy 0003 as OLD (allow), and consecuently + 0011 for + setting the former from an include()d script + + cmake/modules/PopplerDefaults.cmake | 7 +++++++ + 1 file changed, 7 insertions(+) + +commit 92e1f46866c063c370ef1d6324f6a6c01aed6680 +Author: Pino Toscano <pino@kde.org> +Date: Mon Jan 25 02:15:27 2010 +0100 + + [CMake] do not add the fake buildtests target for the MSVC IDE + + cmake/modules/PopplerMacros.cmake | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit dea5aa37de079196fa916b1db9af782cf25045f9 +Author: Maciej Mrozowski <reavertm@gmail.com> +Date: Mon Jan 25 00:51:20 2010 +0000 + + Install some more goo files + + CMakeLists.txt | 9 +++++++++ + 1 file changed, 9 insertions(+) + +commit 671a971c45a1e8ce8f6daade82117a9a137034d6 +Author: Maciej Mrozowski <reavertm@gmail.com> +Date: Mon Jan 25 00:48:31 2010 +0000 + + do not install a private header + + qt4/src/Makefile.am | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 54c86e53a143a8f9d196e4bef2a733c6f00f6026 +Author: Maciej Mrozowski <reavertm@gmail.com> +Date: Mon Jan 25 00:33:07 2010 +0000 + + Only build tests if told to + + test/CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit eb082274694aadb80dd16caea65d7f0a1adf8b46 +Author: Maciej Mrozowski <reavertm@gmail.com> +Date: Mon Jan 25 00:29:55 2010 +0000 + + Only build demos and test if told so. Install poppler-layer.h + + glib/CMakeLists.txt | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +commit 73fcc310cd7d6ef435b453485c1c99a33f77212a +Author: Maciej Mrozowski <reavertm@gmail.com> +Date: Mon Jan 25 00:29:09 2010 +0000 + + install man pages + + utils/CMakeLists.txt | 7 +++++++ + 1 file changed, 7 insertions(+) + +commit 8672217af4cf88d5506572c2b40fbb0d1d0dbd87 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jan 25 00:11:50 2010 +0000 + + Make the poppler object cache params be a ref + + And make sure what we was is a ref, otherwise we abort + + poppler/Gfx.cc | 14 ++++++++------ + poppler/PopplerCache.cc | 12 ++++++------ + poppler/PopplerCache.h | 6 +++--- + 3 files changed, 17 insertions(+), 15 deletions(-) + +commit 9567fd8d3d905897d0abacd77885102ae86ba8a9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 24 20:15:49 2010 +0000 + + ImgWriter is a header too + + goo/Makefile.am | 1 + + 1 file changed, 1 insertion(+) + +commit 735e8a690d0bd3ab4bec90bdad975d19ac3d4689 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 24 19:51:19 2010 +0000 + + noone maintains this either + + msvc/config.h | 62 ---------------------------------- + msvc/poppler/poppler-config.h | 77 + ------------------------------------------- + 2 files changed, 139 deletions(-) + +commit d485564f0dc86f62b996380bfbd570cf3f543e4f +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 24 19:22:33 2010 +0000 + + remove files noone maintains + + README.windows | 63 ------------------------ + makefile.vc | 150 + --------------------------------------------------------- + 2 files changed, 213 deletions(-) + +commit 38467f2738c88f060ae1d30332e34da743a888a5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 24 19:18:44 2010 +0000 + + only compile glib frontend if cairo is found + + CMakeLists.txt | 4 ++-- + glib/CMakeLists.txt | 25 +++++++------------------ + 2 files changed, 9 insertions(+), 20 deletions(-) + +commit cf045acf46307d51fb6d9959451b53681e6cac03 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 24 19:01:52 2010 +0000 + + compile + + glib/CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit 0397cf4f193015286464ae70ab202ed400110e30 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 24 19:00:09 2010 +0000 + + Add and fix copyright years + + poppler/CairoFontEngine.cc | 1 + + poppler/CairoOutputDev.cc | 2 +- + poppler/CairoOutputDev.h | 2 +- + poppler/Gfx.cc | 2 +- + poppler/Gfx.h | 2 +- + poppler/PopplerCache.cc | 1 + + poppler/PopplerCache.h | 1 + + 7 files changed, 7 insertions(+), 4 deletions(-) + +commit 9c9f18b6ceea546dfb21ef0aab29ba99733dcb52 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jan 24 19:27:29 2010 +0100 + + [glib-demo] Remove #ifdef HAVE_CAIRO macros from several demos + + glib/demo/images.c | 2 -- + glib/demo/layers.c | 71 + +++--------------------------------------------------- + glib/demo/render.c | 29 ++++------------------ + 3 files changed, 9 insertions(+), 93 deletions(-) + +commit 4e938c1f81add2162ced0e97b24fe588f15f178d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jan 24 19:15:06 2010 +0100 + + [glib] Make glib frontend unconditionally use cairo output device + + Splash support has been removed. + + configure.ac | 74 ++++++++------- + glib/Makefile.am | 20 +--- + glib/poppler-document.cc | 9 -- + glib/poppler-page.cc | 237 + +--------------------------------------------- + glib/poppler-page.h | 7 -- + glib/poppler-private.h | 14 --- + glib/poppler.cc | 6 -- + glib/test-poppler-glib.cc | 6 +- + poppler-glib.pc.in | 2 +- + 9 files changed, 51 insertions(+), 324 deletions(-) + +commit 59ff9d66fc3b0c9612b1c12fc1ae4dbb8dc85b39 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jan 24 17:57:48 2010 +0100 + + Use a small object cache in GfxResources to cache GState objects + + It drastically improves performance with some documents like page + 742 of + PDF32000_2008.pdf + + poppler/Gfx.cc | 19 +++++++++++++++++-- + poppler/Gfx.h | 2 ++ + 2 files changed, 19 insertions(+), 2 deletions(-) + +commit 880a4a9a60a10f7aa7d3dc7c2802b31b7ef01e06 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jan 24 17:56:35 2010 +0100 + + Add a generic cache to store objects by its reference + + poppler/PopplerCache.cc | 60 + +++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/PopplerCache.h | 16 +++++++++++++ + 2 files changed, 76 insertions(+) + +commit 5ad492df75c0c2394719e85db4c8b43f15b52110 +Author: mpsuzuki <mpsuzuki@hiroshima-u.ac.jp> +Date: Sun Jan 24 13:34:41 2010 +0100 + + [cairo] Fix memory leak + + poppler/CairoFontEngine.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 3160464b4b70c714c36234320878acab81b866cc +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Nov 26 13:17:19 2009 +0100 + + [cairo] Use our own implementation to scale down images instead + of cairo + + This is a workaround for the low quality downscaling of pixman. + Rescaler implementation is a box filter that supports non-integer box + sizes written by Jeff Muizelaar. + Fixes bug #5589. + + poppler/CairoOutputDev.cc | 89 ++++++++++++ + poppler/CairoOutputDev.h | 1 + + poppler/CairoRescaleBox.cc | 352 + +++++++++++++++++++++++++++++++++++++++++++++ + poppler/CairoRescaleBox.h | 12 ++ + poppler/Makefile.am | 4 +- + 5 files changed, 457 insertions(+), 1 deletion(-) + +commit 6825a219f0bc0ac6fd469fb8a6ebb86df774375f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jan 23 11:24:15 2010 +0100 + + [glib] Use TextOutputDev to get TextPage when we haven't rendered + the page + + glib/poppler-page.cc | 27 ++++++++++++++++++--------- + 1 file changed, 18 insertions(+), 9 deletions(-) + +commit 6c61a457e9a8ec10945bc1e0700c8e4d121faa58 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 20 21:59:05 2010 +0000 + + Fix GfxRadialShading::GfxRadialShading + + Fixes crash in KDE bug 223359 + + poppler/GfxState.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 442894d371879a6bf2adb5a39b9dd0a49e76e4ac +Author: Pino Toscano <pino@kde.org> +Date: Fri Jan 15 21:28:42 2010 +0100 + + [glib-demo/cmake] compile print.c + + followup of b64d4bd46b052feb0b143f1348773afbd93e5e33 + + glib/demo/CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit b64d4bd46b052feb0b143f1348773afbd93e5e33 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Nov 27 11:47:22 2009 +0100 + + [glib-demo] Add print demo + + glib/demo/Makefile.am | 2 + + glib/demo/main.c | 4 +- + glib/demo/print.c | 135 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + glib/demo/print.h | 31 ++++++++++++ + 4 files changed, 171 insertions(+), 1 deletion(-) + +commit ba2c746f358a5785d8cbaaf03d8628ee3754c388 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Nov 27 09:52:50 2009 +0100 + + [glib-demo] Add render for printing option to render demo + + glib/demo/render.c | 47 ++++++++++++++++++++++++++++++++++++++--------- + 1 file changed, 38 insertions(+), 9 deletions(-) + +commit 9a478008ccb61641f09bd77eaa55033cca266c43 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jan 15 12:03:11 2010 +0100 + + Add FONTCONFIGURATION macros to poppler-config.h + + They are used in a header file (GlobalParams.h). It fixes a crash + when opening any document. + + poppler/poppler-config.h.in | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +commit 1f80f874d8e132411816302465f04bc59d404d89 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 14 08:43:11 2010 +0000 + + Fix Uncover and Fade to return correct values + + Bug 26034 + + poppler/PageTransition.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 350ff407e06a961f2a5b9d203cb8e78ce09313a0 +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Jan 13 22:20:41 2010 +0000 + + Make poppler (optionally) relocatable on Windows + + configure.ac | 26 ++++++++++++++++++++++ + poppler/GlobalParams.cc | 57 + +++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 83 insertions(+) + +commit 36b67b002db802bfad553720e2114b76b07bb614 +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Jan 13 22:17:03 2010 +0000 + + Make fontconfig optional with mingw compiler + + CMakeLists.txt | 8 +++++++- + config.h.cmake | 6 ++++++ + configure.ac | 39 ++++++++++++++++++++++++++++++++++++++- + makefile.vc | 2 +- + poppler/GlobalParams.cc | 10 +++++++--- + poppler/GlobalParams.h | 7 ++++--- + poppler/GlobalParamsWin.cc | 5 +++++ + 7 files changed, 68 insertions(+), 9 deletions(-) + +commit 9c0b20ab8c104c2f5398a5a3b8409ca554f5fa39 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jan 12 22:55:06 2010 +0000 + + Add the possibility of using float for splash variables instead + of double + + Based on a patch by Marius Vollmer marius.vollmer@nokia.com + See bug 25578 for more info + + CMakeLists.txt | 7 ++++++- + config.h.cmake | 5 ++++- + configure.ac | 10 +++++++++- + splash/SplashMath.h | 14 ++++++++++++-- + splash/SplashTypes.h | 4 +++- + 5 files changed, 34 insertions(+), 6 deletions(-) + +commit 30e5f76e372114339fa1d37c335e6bbade8b6d8a +Author: Pino Toscano <pino@kde.org> +Date: Thu Jan 7 11:18:36 2010 +0100 + + [CMake] followup recent glib/gtk+ version requirements + + - glib to 2.18, see ce9404b1999f81b3f9e5a89bcd6e715463f89024 + - gtk+ to 2.14, see e338643f2cebb1203f7ff0646f87b3dea8318757 + + cmake/modules/FindGTK.cmake | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit e338643f2cebb1203f7ff0646f87b3dea8318757 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jan 7 11:08:31 2010 +0100 + + [tests] Bump GTK+ requirements to 2.14 + + Fixes bug #22090. + + configure.ac | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit ce9404b1999f81b3f9e5a89bcd6e715463f89024 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jan 7 11:06:19 2010 +0100 + + Bump glib requirements to 2.18 + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 526c8871cbdfbc119e013ee96887a79f65403790 +Author: Hib Eris <hib@hiberis.nl> +Date: Thu Dec 31 17:52:33 2009 +0100 + + [glib] Use PDFDoc(wchar_t *, ...) on Windows + + Fixes bug #25032 + + glib/poppler-document.cc | 22 +++++++++++++++++++--- + 1 file changed, 19 insertions(+), 3 deletions(-) + +commit e0c8188136958b853269179079efefdd3488dc22 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jan 4 18:36:01 2010 +0000 + + Require Qt 4.4 + + This updates the requirement to real requirement + + CMakeLists.txt | 2 +- + configure.ac | 8 ++++---- + 2 files changed, 5 insertions(+), 5 deletions(-) + +commit f9accdb878b23ebd2152dd05d61cfcc71d46cd03 +Author: Pino Toscano <pino@kde.org> +Date: Mon Jan 4 14:13:13 2010 +0100 + + [Qt4/tests] use getPdfVersion() instead of the deprecated pdfVersion() + + qt4/tests/stress-poppler-dir.cpp | 3 ++- + qt4/tests/stress-poppler-qt4.cpp | 3 ++- + qt4/tests/test-password-qt4.cpp | 4 +++- + qt4/tests/test-poppler-qt4.cpp | 4 +++- + 4 files changed, 10 insertions(+), 4 deletions(-) + +commit 898e939d8c0ac74cc7ee3f5d42d83083ed31036e +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Jan 2 02:33:58 2010 +0100 + + Make pdftoppm embed correct resolution in PNG and JPEG files + + goo/ImgWriter.h | 3 ++- + goo/JpegWriter.cc | 6 +++++- + goo/JpegWriter.h | 3 ++- + goo/PNGWriter.cc | 6 +++++- + goo/PNGWriter.h | 3 ++- + splash/SplashBitmap.cc | 9 +++++---- + splash/SplashBitmap.h | 5 +++-- + utils/HtmlOutputDev.cc | 4 +++- + utils/pdftoppm.cc | 9 +++++---- + 9 files changed, 32 insertions(+), 16 deletions(-) + +commit df569dc2fb89d7e0780bbf7a687ce2464ff5cb43 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Jan 2 01:19:50 2010 +0100 + + enable AM_SILENT_RULES by default + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit f3862f7d987aae52a1fd2bb0af27d1cd803a5b84 +Author: Pino Toscano <pino@kde.org> +Date: Thu Dec 31 00:20:11 2009 +0100 + + [cpp/tests] poppler-dump: show a string for the font type + + cpp/tests/poppler-dump.cpp | 23 ++++++++++++++++++++++- + 1 file changed, 22 insertions(+), 1 deletion(-) + +commit 9c343c821593ebae51ac47b58ad007a82f198652 +Author: Pino Toscano <pino@kde.org> +Date: Thu Dec 31 00:13:09 2009 +0100 + + [cpp/tests] poppler-dump: show the orientation of the pages + + cpp/tests/poppler-dump.cpp | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +commit bc91fe3824f37cd17a38aac85c817e8ada1b2f43 +Author: Pino Toscano <pino@kde.org> +Date: Wed Dec 30 23:53:31 2009 +0100 + + [cpp/tests] poppler-dump: a bit less output in permissions lines + + cpp/tests/poppler-dump.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1199de8f097a78edb831313841ac0ed3f9ec9905 +Author: Pino Toscano <pino@kde.org> +Date: Wed Dec 30 23:50:36 2009 +0100 + + [cpp/tests] poppler-dump: add --show-all to show all the information + + cpp/tests/poppler-dump.cpp | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +commit 9522f830b59942adfc91d5f03c274415a4737ccc +Author: Pino Toscano <pino@kde.org> +Date: Wed Dec 30 23:38:40 2009 +0100 + + [cpp] use iconv for the utf8 <-> utf16 conversions + + cpp/poppler-global.cpp | 92 + +++++++++++++++++++++++++++++++++++--------------- + 1 file changed, 64 insertions(+), 28 deletions(-) + +commit b156b4031f5daf658f40db8efa2a3016d95b98b5 +Author: Pino Toscano <pino@kde.org> +Date: Wed Dec 30 23:24:23 2009 +0100 + + [cpp] add the build system stuff for iconv, mandatory for cpp + + CMakeLists.txt | 6 ++ + Makefile.am | 1 + + cmake/modules/FindIconv.cmake | 57 +++++++++++++ + config.h.cmake | 6 ++ + configure.ac | 6 ++ + cpp/CMakeLists.txt | 2 +- + cpp/Makefile.am | 3 +- + m4/iconv.m4 | 180 + ++++++++++++++++++++++++++++++++++++++++++ + 8 files changed, 259 insertions(+), 2 deletions(-) + +commit a0cffb8b69e0595a2afe15ecc4928e0df1eeb063 +Author: Pino Toscano <pino@kde.org> +Date: Wed Dec 30 18:57:09 2009 +0100 + + [cpp] fixup unicode GooString <-> ustring conversions + + better make them use the "hand-made" code, it is more correct for them + + cpp/poppler-private.cpp | 44 +++++++++++++++++++++++++++++++++++++++++--- + 1 file changed, 41 insertions(+), 3 deletions(-) + +commit 3b6e3605209d5db453725b9ce4e6e54679d9c5da +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 27 15:30:22 2009 +0100 + + Do not crop the transformation matrix at an arbitrary value + + Fixes bug 25763 and gave no regression on my test suite + + poppler/GfxState.cc | 21 --------------------- + poppler/SplashOutputDev.cc | 15 +++++++++++++++ + 2 files changed, 15 insertions(+), 21 deletions(-) + +commit ea44c60645001ffea7d297f8549aaa4f5ce5e16c +Author: Ilya Gorenbein <igorenbein@finjan.com> +Date: Sun Dec 27 15:27:00 2009 +0100 + + Try to work on streams without Length + + We have code that finds the Length if it's wrong so let that code + do its job + instead of returning a NULL stream + + poppler/Parser.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 283dd326a00c804b6332ee3ca1aaa0d86377b3f3 +Author: Pino Toscano <pino@kde.org> +Date: Sat Dec 19 12:50:10 2009 +0100 + + [cpp] fix installation of poppler-version.h with autotools and + builddir != srcdir + + cpp/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit df0ccddb7f784b4a8564beda51b3047cb9e3611a +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 18 20:23:48 2009 +0000 + + move the retrieval of the bitmap after rendering the page as it can + change on render time + + utils/pdftoppm.cc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit ab88a02f7efefc950a316d7a5edf88dad8f3e4d0 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Dec 17 18:24:20 2009 +0100 + + [annots] QuadPoints is required in Text Markup annotations + + Show an error message and mark annotation as invalid when it's + missing. + + poppler/Annot.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 39dc99431b3ea9e00f6f645dd7169c0319571dc9 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Dec 17 18:17:20 2009 +0100 + + [annots] Create appearance stream for Sound Annotations when not + defined + + See bug #23108. + + poppler/Annot.cc | 112 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Annot.h | 2 + + 2 files changed, 114 insertions(+) + +commit e4f5a78a853b88b1586ef59fc8893a321ea23736 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Dec 17 17:39:39 2009 +0100 + + [annots] Add Tag and Graph icons for File Attachment annotations + + See bug #23108. + + poppler/Annot.cc | 70 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 70 insertions(+) + +commit 752b14857cfb0669fd6d7dfef2ea73c13a2369fc +Author: Pino Toscano <pino@kde.org> +Date: Thu Dec 17 17:16:01 2009 +0100 + + simplify + + cpp/poppler-toc.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit a26e4b7903fabc667d7d16c23ca2c7a535dd05fa +Author: Pino Toscano <pino@kde.org> +Date: Thu Dec 17 17:09:35 2009 +0100 + + [cpp/tests] add a simple poppler-dump test + + this small test executable can dump various features of the document, + like the general info, permissions, metadata, toc, fonts, + embedded files, pages, etc + + also add the necessary autotools+cmake machinery to compile it + + configure.ac | 1 + + cpp/CMakeLists.txt | 2 + + cpp/Makefile.am | 1 + + cpp/tests/.gitignore | 1 + + cpp/tests/CMakeLists.txt | 24 ++++ + cpp/tests/Makefile.am | 17 +++ + cpp/tests/poppler-dump.cpp | 293 + +++++++++++++++++++++++++++++++++++++++++++++ + 7 files changed, 339 insertions(+) + +commit 86c871cc625d00b8ee7f93dc8c0f9ef8462bba5a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Dec 17 17:05:45 2009 +0100 + + [annots] Create appearance stream for Text Markup Annotations when + not defined + + Highlight annotations are an exception, we always ignore the + appearance stream to use our own, since for most of the documents the + appearance stream provided by the annotation is not enough. That's why + it's currently broken. This is what acroread does indeed and Leonard + Rosenthol recommended us to do the same. + See bug #23108. + + poppler/Annot.cc | 199 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Annot.h | 2 + + 2 files changed, 201 insertions(+) + +commit 904ecd929c6acbbad6d782b950c53c0a80e1f39c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Dec 17 12:49:20 2009 +0100 + + [annots] Fix memory leaks + + poppler/Annot.cc | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit ef7954b86f9b1a762c4f77a48d5f42f8db4bbed7 +Author: Pino Toscano <pino@kde.org> +Date: Tue Dec 15 02:20:18 2009 +0100 + + [cpp] use the correct index (instead of an uninitialized variable) + + cpp/poppler-page.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 2547b5e53e7799cf7299838ae9bd882c21a228ae +Author: Pino Toscano <pino@kde.org> +Date: Tue Dec 15 02:14:57 2009 +0100 + + [cpp] properly delete the children of a toc item + + cpp/poppler-toc.cpp | 1 + + 1 file changed, 1 insertion(+) + +commit 771bd3594740fe16bd030dbe73928a8b1d4d113f +Author: Pino Toscano <pino@kde.org> +Date: Tue Dec 15 02:04:24 2009 +0100 + + [cpp] actually implement toc::root() + + cpp/poppler-toc.cpp | 5 +++++ + 1 file changed, 5 insertions(+) + +commit ca1d2ec4588b2437b58b4448ae2fc5ebd0f130d3 +Author: Pino Toscano <pino@kde.org> +Date: Tue Dec 15 00:54:29 2009 +0100 + + [cpp] fix the reference to the vector data + + cpp/poppler-global.cpp | 2 +- + cpp/poppler-private.cpp | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 16c946e7658b0e9cff701ce1d6bbf7d3828cbe08 +Author: Pino Toscano <pino@kde.org> +Date: Tue Dec 15 00:35:25 2009 +0100 + + [cpp] fix the reference to the vector data + + cpp/poppler-document.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 9bb90c99b65e0e9d9b65c7dbeb5b4d66377ceb21 +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 23:43:12 2009 +0100 + + [cpp] add destructor for 'rectangle' + + cpp/poppler-rectangle.h | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 61ccdc9ab3b816174896fcae0899ff34f11eee80 +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 23:40:51 2009 +0100 + + [cpp] add out stream operators for rect and rectf + + cpp/CMakeLists.txt | 1 + + cpp/Makefile.am | 1 + + cpp/poppler-rectangle.cpp | 35 +++++++++++++++++++++++++++++++++++ + cpp/poppler-rectangle.h | 5 +++++ + 4 files changed, 42 insertions(+) + +commit 69dd51fed3de41f8b799b811ae5ee59c0d5f59c2 +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 22:24:07 2009 +0100 + + [cpp] add namespace to namespace functiond to link properly + + cpp/poppler-global.cpp | 4 ++-- + cpp/poppler-version.cpp | 8 ++++---- + 2 files changed, 6 insertions(+), 6 deletions(-) + +commit 3923fa4890984d8616d86016f4f4a94e8ef3e992 +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 22:23:15 2009 +0100 + + [cpp] add default empty parameters for the passwords of the document + loading functions + + cpp/poppler-document.h | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit 1d23cc677e9b0a9f61c53e0ea365537f33abe5bf +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 21:44:56 2009 +0100 + + [cpp] add "human friendly" output representation for byte_array + + cpp/poppler-global.cpp | 23 +++++++++++++++++++++++ + cpp/poppler-global.h | 3 +++ + 2 files changed, 26 insertions(+) + +commit 82954ea5f8ba880276328765f104690a05adbd9e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Dec 7 12:05:54 2009 +0100 + + [annot] Create appearance stream for Attachment Annotations when + not defined + + See bug #23108. + + poppler/Annot.cc | 94 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Annot.h | 2 ++ + 2 files changed, 96 insertions(+) + +commit c6195472326c183fcfd8a3e9da1ee7f6fa8b7c3d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Dec 6 17:09:23 2009 +0100 + + [annots] Use opacity when drawing Markup Annotations + + According to the spec: + + "The constant opacity value that shall be used in painting the + annotation. This value shall apply to all visible elements of the + annotation in its closed state (including its background and border) + but + not to the pop-up window that appears when the annotation is opened. + + The specified value shall not used if the annotation has an appearance + stream in that case, the appearance stream shall specify any + transparency. + + If no explicit appearance stream is defined for the annotation, it may + be painted by implementation-dependent means that do not necessarily + conform to the PDF imaging model; in this case, the effect of + this entry + is implementation-dependent as well." + + poppler/Annot.cc | 21 +++++++++++++++------ + poppler/Gfx.cc | 9 ++++++++- + poppler/Gfx.h | 2 +- + 3 files changed, 24 insertions(+), 8 deletions(-) + +commit a337c1d757d52c1c238229d2f0cd3a41694b0e08 +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 16:18:22 2009 +0100 + + [cpp] add document metadata reading + + cpp/poppler-document.cpp | 9 +++++++++ + cpp/poppler-document.h | 1 + + 2 files changed, 10 insertions(+) + +commit 6c4fa513e60dbdd5ab693434f239d82d95756994 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Dec 6 16:56:22 2009 +0100 + + [annot] Create appearance stream for Geometry Annotations when + not defined + + See bug #23108. + + poppler/Annot.cc | 120 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Annot.h | 2 + + 2 files changed, 122 insertions(+) + +commit eed94b8bd2855dce1fd39b835e3280cbd0ccd1cf +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Dec 6 16:51:37 2009 +0100 + + [annot] Create appearance stream for Line Annotations when not defined + + See bug #23108. + + poppler/Annot.cc | 62 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Annot.h | 2 ++ + 2 files changed, 64 insertions(+) + +commit 1c7a5f5e89c4c51e31b6de345d4862ef8dcc2bc0 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Dec 6 16:40:14 2009 +0100 + + [annot] Create appearance stream for Text Annotations when not defined + + Streams have been created by using the svg icons created by mac_v and + ulisse. See bug #23108. + + poppler/Annot.cc | 305 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Annot.h | 2 + + 2 files changed, 307 insertions(+) + +commit c9cb6353ad5279d09615eb2c944b2b053cdf5ccc +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 15:52:25 2009 +0100 + + [cpp] add function to query for document "permissions" + + cpp/poppler-document.cpp | 23 +++++++++++++++++++++++ + cpp/poppler-document.h | 1 + + cpp/poppler-global.h | 4 ++++ + 3 files changed, 28 insertions(+) + +commit 30e90c7c1b41c62ddc21905e7ccdea4c95547e80 +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 15:33:36 2009 +0100 + + [cpp] add is_encrypted and is_linearized for document + + cpp/poppler-document.cpp | 10 ++++++++++ + cpp/poppler-document.h | 2 ++ + 2 files changed, 12 insertions(+) + +commit 93fd588c519958a1f66231c111ea8a6b0a759be1 +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 13:19:24 2009 +0100 + + [cpp] add the possibility to load a document from raw data + + cpp/poppler-document-private.h | 5 +++++ + cpp/poppler-document.cpp | 35 ++++++++++++++++++++++++++++++++++- + cpp/poppler-document.h | 3 +++ + 3 files changed, 42 insertions(+), 1 deletion(-) + +commit 53996365b159cf84adf2cac56c76b8bda8dfb12e +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 12:57:41 2009 +0100 + + [cpp] use the byte_array typedef + + cpp/poppler-embedded-file.cpp | 6 +++--- + cpp/poppler-embedded-file.h | 2 +- + 2 files changed, 4 insertions(+), 4 deletions(-) + +commit e4969c1aaed4a8eb770d8b54920f2476129bbcb7 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Dec 6 16:19:36 2009 +0100 + + [annots] Refactor Annot::setColor to receive an AnnotColor + + Removes duplicated code since color arrays are already parsed in + AnnotColor + + poppler/Annot.cc | 136 + +++++++++++++++++++++++++++++-------------------------- + poppler/Annot.h | 4 +- + 2 files changed, 73 insertions(+), 67 deletions(-) + +commit cfb4f5dfabf31de22d68aa0d5796cb7a33d8b462 +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 11:06:36 2009 +0100 + + [cpp] add a byte_array typedef, and use it for utf8 string data + + cpp/poppler-global.cpp | 12 +++--------- + cpp/poppler-global.h | 5 ++++- + cpp/poppler-private.cpp | 5 ++--- + 3 files changed, 9 insertions(+), 13 deletions(-) + +commit 2d13ac31671b2007e44a90f45a82cb3adfa9c80c +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 02:30:06 2009 +0100 + + update ignore files + + .gitignore | 1 + + cpp/.gitignore | 1 + + 2 files changed, 2 insertions(+) + +commit 01e902e40ca15acf0319e37d39a271d6875bfce9 +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 02:02:47 2009 +0100 + + [cpp] add a version header+functions + + this way, it is possible to get (either at build time and at runtime) + the version of the current poppler-cpp library + + poppler-config.h is generated by the build system (autotools or cmake) + with the correct version information + + configure.ac | 2 ++ + cpp/CMakeLists.txt | 5 +++++ + cpp/Makefile.am | 6 ++++-- + cpp/poppler-version.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ + cpp/poppler-version.h.in | 39 +++++++++++++++++++++++++++++++++++++++ + 5 files changed, 91 insertions(+), 2 deletions(-) + +commit b3f5e5d60bc9109da961940f6216722f9db4a87b +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 00:56:15 2009 +0100 + + [CMake] add the configure check for the Cairo blend modes support + (as in autotools) + + cmake/modules/FindCairo.cmake | 18 ++++++++++++++++++ + config.h.cmake | 3 +++ + 2 files changed, 21 insertions(+) + +commit f6ba877e0c22538cfe34d32d69814f660de59d2c +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 00:44:55 2009 +0100 + + [CMake] add configure check for sys/mman.h (as in autotools) + + ConfigureChecks.cmake | 1 + + config.h.cmake | 3 +++ + 2 files changed, 4 insertions(+) + +commit e12801320ae030628fc62c073983c06b39ee13d7 +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 00:42:20 2009 +0100 + + minor spello + + config.h.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 6428907ebcf33d4391673aadcfa71c3061f6d352 +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 00:41:49 2009 +0100 + + [CMake] add configure check for fcntl.h (as in autotools) + + ConfigureChecks.cmake | 1 + + config.h.cmake | 3 +++ + 2 files changed, 4 insertions(+) + +commit 916ab7163249e23bd5ba00922fdcad9caaf92c75 +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 00:34:59 2009 +0100 + + [CMake] oops, those should have been '#cmakedefine' and not '#define' + + config.h.cmake | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit ea655d8c7e24e97ee710110a783ed9c209cf76e3 +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 00:33:51 2009 +0100 + + [CMake] move and rename to match more the autotools output + + config.h.cmake | 21 ++++++++++++++------- + 1 file changed, 14 insertions(+), 7 deletions(-) + +commit 9f0146c5b2f9326e834104b89791f66b18f85adc +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 14 00:28:04 2009 +0100 + + [CMake] add checks for gmtime_r and localtime_r + + ConfigureChecks.cmake | 2 ++ + config.h.cmake | 6 ++++++ + 2 files changed, 8 insertions(+) + +commit 9d0cf201e96044dd679c26bea6255d986a6cd246 +Author: Pino Toscano <pino@kde.org> +Date: Sun Dec 13 23:45:39 2009 +0100 + + [cpp] add ignore file + + cpp/.gitignore | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit d783e92b863d8b22de6ca326328115fec63193ed +Author: Pino Toscano <pino@kde.org> +Date: Sun Dec 13 23:42:33 2009 +0100 + + [cpp] don't forget the cmake stuff when packing with the autotools + + Makefile.am | 2 ++ + 1 file changed, 2 insertions(+) + +commit 0105caefe860e7a45fc7d3a1bd1162fe56bcfe6a +Author: Pino Toscano <pino@kde.org> +Date: Sun Dec 13 23:40:55 2009 +0100 + + [cpp] add the pkg-config stuff + + CMakeLists.txt | 3 +++ + Makefile.am | 7 +++++-- + configure.ac | 3 ++- + poppler-cpp.pc.cmake | 9 +++++++++ + poppler-cpp.pc.in | 9 +++++++++ + 5 files changed, 28 insertions(+), 3 deletions(-) + +commit d5a74f78df0dca24fd537b30424fd2ebb3efe3e2 +Author: Pino Toscano <pino@kde.org> +Date: Sun Dec 13 23:35:06 2009 +0100 + + [cpp] add the (rest of the) CMake build system for it + + CMakeLists.txt | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 0e41f937946e4e4c1b660406bd74e4afe8825b5f +Author: Pino Toscano <pino@kde.org> +Date: Sun Dec 13 23:31:46 2009 +0100 + + [cpp] add the autotools buildsystem for it + + Makefile.am | 6 +++++- + configure.ac | 15 +++++++++++++++ + cpp/Makefile.am | 32 ++++++++++++++++++++++++++++++++ + 3 files changed, 52 insertions(+), 1 deletion(-) + +commit 9727fdc0c682742335e44ddc2f32d60e4c59983a +Author: Pino Toscano <pino@kde.org> +Date: Sun Dec 13 22:55:28 2009 +0100 + + Start of a pure C++ frontend for Poppler. + + This initial version (called 'poppler-cpp') includes preliminary + support for: + - document (loading from file name, some query methods, unlocking, + font listing, embedded files) + - page (some query methods) with page transitions + - TOC + + Modelled a bit on the Qt4 API, it provides also an own "ustring" + typedef representing UTF-16 strings, + with methods to convert back/to UTF-8 and Latin 1. + + Most probably it has bugs, but nevertheless worth testing and + developing. + + cpp/CMakeLists.txt | 34 ++++ + cpp/poppler-document-private.h | 55 +++++++ + cpp/poppler-document.cpp | 316 + ++++++++++++++++++++++++++++++++++++ + cpp/poppler-document.h | 92 +++++++++++ + cpp/poppler-embedded-file-private.h | 40 +++++ + cpp/poppler-embedded-file.cpp | 116 +++++++++++++ + cpp/poppler-embedded-file.h | 55 +++++++ + cpp/poppler-font.cpp | 166 +++++++++++++++++++ + cpp/poppler-font.h | 91 +++++++++++ + cpp/poppler-global.cpp | 162 ++++++++++++++++++ + cpp/poppler-global.h | 86 ++++++++++ + cpp/poppler-page-private.h | 44 +++++ + cpp/poppler-page-transition.cpp | 95 +++++++++++ + cpp/poppler-page-transition.h | 82 ++++++++++ + cpp/poppler-page.cpp | 121 ++++++++++++++ + cpp/poppler-page.h | 62 +++++++ + cpp/poppler-private.cpp | 70 ++++++++ + cpp/poppler-private.h | 66 ++++++++ + cpp/poppler-rectangle.h | 60 +++++++ + cpp/poppler-toc-private.h | 62 +++++++ + cpp/poppler-toc.cpp | 136 ++++++++++++++++ + cpp/poppler-toc.h | 74 +++++++++ + 22 files changed, 2085 insertions(+) + +commit 62854051f4e47028147cc93a5faac39e2fa2c9fd +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Dec 12 17:22:08 2009 +0100 + + Initialize profileCommands in Gfx constructor + + poppler/Gfx.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 4e6af25a028d16608111634c5467420e31fa399b +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Dec 9 19:45:40 2009 +0100 + + [cairo] Update font of TextPage in CairoOutputDev::updateAll() + + Fixes a crash with some documents, see Evince bug + https://bugzilla.gnome.org/show_bug.cgi?id=603934 + + poppler/CairoOutputDev.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 6798d3e52e36e91bceff3a1a96372e9d9c6f3813 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Dec 6 15:34:36 2009 +0100 + + Use fixed size array in AnnotColor + + glib/poppler-annot.cc | 2 +- + poppler/Annot.cc | 24 +++++------------------- + poppler/Annot.h | 5 ++--- + poppler/Gfx.cc | 2 +- + qt4/src/poppler-annotation.cc | 2 +- + 5 files changed, 10 insertions(+), 25 deletions(-) + +commit 92fab93bee3748a73c09429cc8a105c16f21fed0 +Author: Axel Struebing <axel.struebing@freenet.de> +Date: Sat Dec 5 22:31:29 2009 +0000 + + Add a empty space after null + + Fixes bug 25465 + + poppler/PDFDoc.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 32103f45d0193b31e95269ea9123b8011d93e994 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Dec 5 10:14:18 2009 +0100 + + [annots] Add isVisible() to check whether annot is visible before + drawing it + + It takes into account annot flags and optional content. + + poppler/Annot.cc | 29 ++++++++++++++--------------- + poppler/Annot.h | 1 + + 2 files changed, 15 insertions(+), 15 deletions(-) + +commit c14dfc7102341f5e1ed67a05c0738d55befab1ec +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Dec 5 10:07:46 2009 +0100 + + [annots] Do not check if annot is a link in Annot::draw() + + AnnotLink already implements draw() + + poppler/Annot.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ddf85d4a51f605eed998c633857b8bb5c74ab590 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 4 14:59:41 2009 +0100 + + Make the code a bit more resilient + + By checking the GooString we are going to use really exists + + poppler/PSOutputDev.cc | 24 ++++++++++++++++-------- + 1 file changed, 16 insertions(+), 8 deletions(-) + +commit 78b4afa0a44048b8d40438d400652dbae4cb99b1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 4 14:57:10 2009 +0100 + + Accept Fontname if FontName is not present + + Fixes KDE bug 217013 + + poppler/GfxFont.cc | 9 +++++++++ + 1 file changed, 9 insertions(+) + +commit fee5cb0eec2ddb8d596289e9a6285cf04d97632e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Dec 4 13:26:42 2009 +0100 + + [annots] Remove redundant flags definition + + poppler/Annot.cc | 22 +++++++++------------- + 1 file changed, 9 insertions(+), 13 deletions(-) + +commit 3a94e8ce90c0a4d11c5c5aa8805c167c8a0434e5 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Nov 27 15:23:11 2009 +0100 + + [cairo] Revert commit 77c2e154c2cb57300116ecd4295f1e67b06b411f + + And fix bug #24575 jut by checking pointer is not null before + using it. + + poppler/CairoOutputDev.cc | 12 +++++------- + 1 file changed, 5 insertions(+), 7 deletions(-) + +commit a093b768e64d477ebdd5f6b519d80a6c45706e7e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Nov 22 20:23:49 2009 +0100 + + Add copyrights + + poppler/CairoFontEngine.cc | 2 +- + poppler/CairoOutputDev.cc | 4 ++-- + poppler/CairoOutputDev.h | 2 +- + 3 files changed, 4 insertions(+), 4 deletions(-) + +commit 77c2e154c2cb57300116ecd4295f1e67b06b411f +Author: David Benjamin <davidben@mit.edu> +Date: Sun Nov 22 20:19:29 2009 +0100 + + Do not crash on malformed files + + bug 24575 + + poppler/CairoOutputDev.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 1d0cb9b2cfd4d4d9aa9b0ad83ad6408544263a09 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Nov 22 19:59:34 2009 +0100 + + [cairo] Initialize fill_color and stroke_color + + poppler/CairoOutputDev.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 32de2ac62fb87570e1a59152f37b86e571a01180 +Author: Ilya Gorenbein <igorenbein@finjan.com> +Date: Sun Nov 22 19:51:54 2009 +0100 + + Improve the reconstruction of the XRef + + Makes load a file Ilya can't share + + poppler/XRef.cc | 165 + ++++++++++++++++++++++++++++++++------------------------ + 1 file changed, 95 insertions(+), 70 deletions(-) + +commit 039c6dffbfbed46a11e207048a3247d6921d6b02 +Author: Ilya Gorenbein <igorenbein@finjan.com> +Date: Sun Nov 22 15:14:20 2009 +0100 + + Correctly initialize fileName + + poppler/Link.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit b905caf1785ee207cc0480953da69be302d3d4e9 +Author: David Benjamin <davidben@mit.edu> +Date: Sat Nov 21 02:43:21 2009 +0100 + + Be more lenient with /Decode key on images + + The spec requires the field be [1 0] or [0 1]. Adobe accepts + floating point + values as well. This fixes bug #17439. + + poppler/Gfx.cc | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +commit d99e7a88845a5f4b35e2c538c597316b2ad541ca +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Nov 20 22:09:44 2009 +0100 + + Check for openjpeg in the C++ part as it uses bool in the header + + Bug 25103 + + configure.ac | 61 + ++++++++++++++++++++++++++++++------------------------------ + 1 file changed, 30 insertions(+), 31 deletions(-) + +commit 55261a2dc86241c8d132e590e76e7398b3ca5090 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 18 22:26:01 2009 +0100 + + replace floor with a cast to int for numbers > 0 + + bug-poppler13487.pdf gets a 15% faster rendering + + splash/SplashMath.h | 19 +++++++++++++++++-- + 1 file changed, 17 insertions(+), 2 deletions(-) + +commit 28df9fb323f14dc632c9502655abf69984b7d67e +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 18 21:57:02 2009 +0100 + + Remove unused label + + poppler/Catalog.cc | 1 - + 1 file changed, 1 deletion(-) + +commit 037979a01a6fcafc61360e758dbc4a5eb056825e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Nov 17 19:12:30 2009 +0100 + + [cairo] If there's a soft mask available when filling, apply the + mask instead of filling + + Fixes bug #8474. + + poppler/CairoOutputDev.cc | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +commit 46380d36f004d71dd2c2e7bc82836af248684b51 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Nov 17 20:48:22 2009 +0100 + + i didn't want to commit this + + configure.ac | 60 + +++++++++++++++++++++++++++-------------------------- + splash/SplashMath.h | 5 ++--- + utils/pdftoppm.cc | 8 ------- + 3 files changed, 33 insertions(+), 40 deletions(-) + +commit 1844e0927ae89824f59b2b3378bf5e00a51a251c +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Nov 17 20:34:24 2009 +0100 + + do not use setAttribute with doubles + + it is evil and locale dependant, we do NOT want that so use + QString::number + + configure.ac | 60 +++++++++++++++---------------- + qt4/src/poppler-annotation.cc | 82 + +++++++++++++++++++++---------------------- + splash/SplashMath.h | 5 +-- + utils/pdftoppm.cc | 8 +++++ + 4 files changed, 81 insertions(+), 74 deletions(-) + +commit 572d79f4b8a7bf1717b88dbd2609d8fa9b036dee +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Nov 15 20:40:56 2009 +0100 + + Only calculate the matrix when it is really needed + + That only happens when outputting to 1 bit images + Speeds out rendering on some pdf up to 40% + + splash/SplashScreen.cc | 35 +++++++++++++++++++++++++++++++++-- + splash/SplashScreen.h | 16 ++++++++++++++++ + 2 files changed, 49 insertions(+), 2 deletions(-) + +commit 1c3113361fa376093e6fedfbf48feee7dcbc46b7 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Nov 15 19:43:18 2009 +0100 + + Write out fixed-content portion of Type 1 fonts in PSOutputDev + + If /Length3 of a Type 1 FontFile is > 0 the fixed-content from the + FontFile should be used instead of adding the generic 512 zeros and + cleartomark. + + poppler/PSOutputDev.cc | 18 +++++++++++++----- + 1 file changed, 13 insertions(+), 5 deletions(-) + +commit 2d30dc605cd984f6c32124af9aa7b877d416d141 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Nov 15 17:31:36 2009 +0100 + + [glib-demo] Show attachment name in FileAttachment annot properties + table + + glib/demo/annots.c | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 6c8ae140256818401351a331787c83e043fdba09 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Nov 15 17:31:13 2009 +0100 + + [glib] Add poppler_annot_file_attachment_get_name() + + glib/poppler-annot.cc | 36 +++++++++++++++++++++++++++++------- + glib/poppler-annot.h | 1 + + 2 files changed, 30 insertions(+), 7 deletions(-) + +commit ecf5173eb288187a1f076fd4b116f1212fa9e203 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Nov 15 17:14:29 2009 +0100 + + [glib-demo] Add properties of FileAttachment annotations + + glib/demo/annots.c | 67 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 67 insertions(+) + +commit 8f4fdd864d79e4fa83951a3eb006ea8287c3a1ba +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Nov 15 17:12:43 2009 +0100 + + [glib-demo] Add pgd_table_add_property_with_custom_widget() + + To be able to add properties to a table that are not labels + + glib/demo/utils.c | 31 +++++++++++++++++++++---------- + glib/demo/utils.h | 30 +++++++++++++++++------------- + 2 files changed, 38 insertions(+), 23 deletions(-) + +commit 061b85f7a442107cda67e385bd772ec8565a936e +Author: Thomas Viehmann <tv@beamnet.de> +Date: Sun Nov 15 17:11:43 2009 +0100 + + [glib] Add support for file attachment annotations + + glib/poppler-annot.cc | 69 + +++++++++++++++++++++++++++++++++++++++++++++++--- + glib/poppler-annot.h | 8 ++++++ + glib/poppler-page.cc | 3 +++ + glib/poppler-private.h | 1 + + glib/poppler.h | 49 +++++++++++++++++------------------ + 5 files changed, 102 insertions(+), 28 deletions(-) + +commit 189c45332991bce51e40bcaf65da67d2d644045a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Nov 15 16:42:21 2009 +0100 + + [glib] Remove PopplerDocument from PopplerAttachment + + Since we are duplicating the stream we don't need to hold a + reference of + PopplerDocument anymore. + + glib/poppler-attachment.cc | 13 +------------ + glib/poppler-document.cc | 2 +- + glib/poppler-private.h | 3 +-- + 3 files changed, 3 insertions(+), 15 deletions(-) + +commit e55bfeb1ddc60053c5ee5fef840c409891781ce6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Nov 13 00:55:37 2009 +0100 + + jpeg_start_decompress can fail, check it + + Fixes KDE bug #214317 + + poppler/DCTStream.cc | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit c59d93061cf71d13916872a20aed37ecfbb3bfa4 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Nov 9 18:32:55 2009 +0100 + + [cairo] Do nothing when image mask is 1x1 and the pixel is 0 + + poppler/CairoOutputDev.cc | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +commit 448f03cfc429d33bfa5527e3dc964ef5da10ee94 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Nov 9 22:52:39 2009 +1030 + + Don't render the color white in type 3 glyphs in the cairo backend + + PDF allows the "g" operator in Type 3 charprocs but cairo user fonts + will render any stroke or fill in the font color. + + As the only PDFs I've seen with "g" in the charprocs are only using + the gray values 0 or 1, a workaround is to disable strokes and fills + of the charproc when the gray level is > 0.5. + + poppler/CairoOutputDev.cc | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +commit 3fead2a3b53681ef95116f18f17f1a9febec6e48 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Nov 9 11:25:24 2009 +0100 + + Transitions dictionary can be a Ref too + + poppler/Page.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ac4955d03a532cab1933698aeb667d44300e52d0 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Nov 9 11:12:48 2009 +0100 + + [glib-demo] Explicitely add gio as dependency for GTK+ tests + + configure.ac | 4 ++-- + glib/demo/main.c | 1 + + 2 files changed, 3 insertions(+), 2 deletions(-) + +commit 32ea667ec8f18311539123c7b80c7ab4767070cb +Author: Chris Wilson <chris@chris-wilson.co.uk> +Date: Tue Aug 11 19:17:52 2009 +0100 + + [cairo] Mark images dirty + + After directly manipulating the pixel values we need to mark the + surface + as dirty. This means that cairo will refresh any caches it may + have taken + of the surface will the new data. + + poppler/CairoOutputDev.cc | 8 ++++++++ + 1 file changed, 8 insertions(+) + +commit 10a41150c4067bb3ab85e25dae76e0968a6cd586 +Author: Chris Wilson <chris@chris-wilson.co.uk> +Date: Tue Aug 11 19:17:06 2009 +0100 + + [cairo] Use colToDbl() to avoid rounding error. + + poppler/CairoOutputDev.cc | 37 +++++++++++++++++++------------------ + 1 file changed, 19 insertions(+), 18 deletions(-) + +commit c9491319689f04edd57adda7ee85f84f17fd1c47 +Author: Chris Wilson <chris@chris-wilson.co.uk> +Date: Tue Aug 11 18:07:17 2009 +0100 + + [cairo] Reduce the number of redundant pattern creations + + poppler/CairoOutputDev.cc | 84 + ++++++++++++++++++++++++++++------------------- + 1 file changed, 51 insertions(+), 33 deletions(-) + +commit ead78d9f703c8b2d556c94be3c47dbae7469eda8 +Author: Reece Dunn <msclrhd@gmail.com> +Date: Thu Nov 5 22:25:14 2009 +0100 + + fontpos is never set to -1, so remove the checks in HtmlOutputDev. + + utils/HtmlOutputDev.cc | 11 +++-------- + 1 file changed, 3 insertions(+), 8 deletions(-) + +commit 55dd6024a4672a1787e8b1a8276bd78fff94e2cd +Author: Ilya Gorenbein <igorenbein@finjan.com> +Date: Wed Nov 4 22:07:18 2009 +0100 + + Do not error on files without "Count" and "Kids" + + It is not spec compliant not to have those fields but Adobe Reader and + FoxIt seems to allow it so try to behave like them. See bug 24720 + to see why one would want such file + + poppler/Catalog.cc | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +commit 58a1d42aed7352c008d201b8f355f6e4146f71e5 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Oct 29 18:38:22 2009 +0100 + + [cairo] Don't render patterns when using CairoImageOutputDev + + poppler/CairoOutputDev.h | 15 +++++++++++++-- + 1 file changed, 13 insertions(+), 2 deletions(-) + +commit 7670cc48dcf3ffd77e3ffa29056a3e13b2926709 +Author: Ilya Gorenbein <igorenbein@finjan.com> +Date: Wed Oct 28 19:20:41 2009 +0100 + + There are some pdf where Aspect values are reals, use getNum + + Fixes bug 24733 + + poppler/Annot.cc | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +commit 4fe89e520a04a6ab6d6ec6a8294896b2f427c7da +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Oct 25 21:55:55 2009 +0100 + + do not accept negative interval lengths in the page labels tree + + See bug 24721 + + poppler/PageLabelInfo.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit b174ebd6b323c7a58a19d59c1a9e4ac4e6cba7d9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Oct 23 21:57:42 2009 +0200 + + Move the iccColorSpaceCache from a static in GfxState to a member + of Gfx + + Fixes the problem that the keys are per document but we had a static + that lived as much as the library. Now the cache only lives the + rendering + of a page so it's a bit slower but at least it's correct. Fixes + bug 24686 + + poppler/Gfx.cc | 49 ++++++++++++++++++---------- + poppler/Gfx.h | 13 ++++++-- + poppler/GfxState.cc | 94 + ++++++++++++++++++++++++++--------------------------- + poppler/GfxState.h | 33 +++++++++---------- + poppler/Page.cc | 4 +-- + 5 files changed, 107 insertions(+), 86 deletions(-) + +commit 4a9bdd30dc353865685e03eb1c1ac6093797695a +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 22 21:26:29 2009 +0200 + + initialize len at 0 when reading the font fails + + See bug 24525 for more info + + poppler/GfxFont.cc | 1 + + 1 file changed, 1 insertion(+) + +commit c839b706092583f6b12ed3cc634bf5af34b7a2bb +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Oct 20 10:09:13 2009 +0200 + + [glib] Fix CVE-2009-3607 + + glib/poppler-page.cc | 20 ++++++++++---------- + 1 file changed, 10 insertions(+), 10 deletions(-) + +commit 44462e0ca39392e5629020226b901e4026089b46 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Oct 19 23:33:58 2009 +0200 + + fix memory leak + + poppler/PSOutputDev.cc | 1 + + 1 file changed, 1 insertion(+) + +commit d701aaa9eaa62567210070129f5feffe24bf1936 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Oct 18 01:22:16 2009 +0200 + + This include is needed as this file uses Ref + + poppler/OutputDev.h | 1 + + 1 file changed, 1 insertion(+) + +commit d4202536e1b62c326c301d5088fa0e176c523e85 +Author: Pino Toscano <pino@kde.org> +Date: Sat Oct 17 01:35:11 2009 +0200 + + SplashGlyphBitmap is a struct and not a class + + poppler/ArthurOutputDev.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 654176dee7c9325aa5a24a2de3c070faa16e8a9c +Author: Michael Jansen <kde@michael-jansen.biz> +Date: Sat Oct 17 01:30:40 2009 +0200 + + CMake: add the possibility to pass LIB_SUFFIX. + + This allows to tune the installation libdir by adding a suffix for it + (making it eg lib, lib32, or lib64) + + CMakeLists.txt | 16 +++++++++------- + glib/CMakeLists.txt | 2 +- + poppler-cairo.pc.cmake | 2 +- + poppler-glib.pc.cmake | 2 +- + poppler-qt.pc.cmake | 2 +- + poppler-qt4.pc.cmake | 2 +- + poppler-splash.pc.cmake | 2 +- + poppler.pc.cmake | 2 +- + qt/CMakeLists.txt | 2 +- + qt4/src/CMakeLists.txt | 2 +- + 10 files changed, 18 insertions(+), 16 deletions(-) + +commit 43829ae4b25a88ace06f05fa6750e5732539f4be +Author: Pino Toscano <pino@kde.org> +Date: Sat Oct 17 01:21:39 2009 +0200 + + put a space so MSVC won't try to see it as comment + + poppler/GfxState.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit f64086ea22a4e8cb3d4e7116db2a9541ac2fb19f +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 17 00:48:58 2009 +0200 + + check the document is not locked when printing + + qt4/src/poppler-ps-converter.cc | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 85d1015480b7ab3f21cc5f78dc53d4c5efdc6e60 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 17 00:48:27 2009 +0200 + + fix file name comment + + qt4/src/poppler-ps-converter.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 270764ad1bf2cfe95aed0b6850d2347361b4268d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 17 00:47:34 2009 +0200 + + Add a way for converters to return more exact errors they had when + converting + + qt4/src/poppler-base-converter.cc | 8 +++++++- + qt4/src/poppler-converter-private.h | 3 ++- + qt4/src/poppler-pdf-converter.cc | 11 ++++++++++- + qt4/src/poppler-ps-converter.cc | 6 +++++- + qt4/src/poppler-qt4.h | 14 ++++++++++++++ + 5 files changed, 38 insertions(+), 4 deletions(-) + +commit 1082e1671afd8ab91583dabc876304008acb021c +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Oct 16 23:17:22 2009 +0200 + + Some "security" fixes based on newly released Xpdf 3.02pl4 + + poppler/Stream.cc | 4 ++++ + poppler/XRef.cc | 19 +++++++++++++++---- + splash/Splash.cc | 7 +++++++ + splash/SplashBitmap.cc | 37 ++++++++++++++++++++++++++++++------- + splash/SplashErrorCodes.h | 4 +++- + 5 files changed, 59 insertions(+), 12 deletions(-) + +commit c2458275e02f56226779b82d73c13defcbbda563 +Author: Glenn Ganz <glenn.ganz@uptime.ch> +Date: Fri Oct 16 20:54:32 2009 +0200 + + fix constructor of DCTStream + + poppler/Stream.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit fd91b79c053bb5cd01a766032b90981dbc5e5dd3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 10 14:53:42 2009 +0200 + + fix compiling with automake + + goo/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit c3031b4318af6f85256f2478c8678dedd0d6acd1 +Author: Pino Toscano <pino@kde.org> +Date: Fri Oct 9 16:17:16 2009 +0200 + + cmake: simplify the linking to libpng + + CMakeLists.txt | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +commit 96688dd7a091f8fa141fad2b3d05bae04b0b86fb +Author: Patrick Spendrin <ps_ml@gmx.de> +Date: Fri Oct 9 16:09:46 2009 +0200 + + MSVC: add _CRT_SECURE_NO_WARNINGS to the define's + + CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit f346c1f6b55f87ebd6bb0b0932462d5514aa40ff +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Oct 9 00:29:06 2009 +0200 + + add -ansi flag to default warnings + + cmake/modules/PopplerMacros.cmake | 2 +- + configure.ac | 2 +- + utils/parseargs.c | 30 +++++++++++++++--------------- + utils/parseargs.h | 26 +++++++++++++------------- + 4 files changed, 30 insertions(+), 30 deletions(-) + +commit 53e0016b772f1b78d998506e2f3106011d32cef3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Oct 9 00:15:52 2009 +0200 + + Add virtual destructor to ImgWriter + + CMakeLists.txt | 1 + + goo/ImgWriter.cc | 15 +++++++++++++++ + goo/ImgWriter.h | 2 ++ + goo/Makefile.am | 1 + + 4 files changed, 19 insertions(+) + +commit 699dcacced7be05b788c414c231dc2b5c07de06e +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Oct 9 00:13:11 2009 +0200 + + Add -Wnon-virtual-dtor flag + + cmake/modules/PopplerMacros.cmake | 4 ++-- + configure.ac | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit d1e4fca4a8602994b010fae4f4fea5cd4df9276e +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Oct 9 00:10:03 2009 +0200 + + build on cmake too + + CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit d67511c92022121066f43003f01b955962ddcd33 +Author: Stefan Thomas <thomas@eload24.com> +Date: Fri Oct 9 00:09:23 2009 +0200 + + Add -jpeg to pdftoppm + + goo/ImgWriter.h | 28 +++++++++++++++ + goo/JpegWriter.cc | 92 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + goo/JpegWriter.h | 42 +++++++++++++++++++++++ + goo/Makefile.am | 2 ++ + goo/PNGWriter.cc | 5 +-- + goo/PNGWriter.h | 10 +++--- + splash/SplashBitmap.cc | 46 +++++++++++++++++-------- + splash/SplashBitmap.h | 5 +-- + splash/SplashTypes.h | 11 ++++++ + utils/pdftoppm.1 | 3 ++ + utils/pdftoppm.cc | 22 +++++++++--- + 11 files changed, 239 insertions(+), 27 deletions(-) + +commit 388196df1fb05fb2d88ae82bd81e823a23588ec1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Oct 7 17:11:58 2009 +0200 + + [glib-demo] Show some of the annot flags in annots treeview + + glib/demo/annots.c | 35 +++++++++++++++++++++++++++++++++-- + 1 file changed, 33 insertions(+), 2 deletions(-) + +commit 034907c6582c1f50782ec9c58a29b140c6fc0688 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Oct 6 00:52:10 2009 +0200 + + Forgot to update the year here + + qt4/src/poppler-private.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit fef89acebf5312324c104fb52e629563fbc2de76 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Oct 6 00:42:52 2009 +0200 + + Add the possibility of enabling hinting + + qt4/src/poppler-document.cc | 2 +- + qt4/src/poppler-private.h | 1 + + qt4/src/poppler-qt4.h | 3 ++- + 3 files changed, 4 insertions(+), 2 deletions(-) + +commit 485252844b5e0964ee724b74e2a7ba2b820b259e +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Oct 6 00:41:57 2009 +0200 + + rework how hinting is used in the splash backend + + Basically we default to no hinting now with the possibility to + enable it + + poppler/ArthurOutputDev.cc | 2 +- + poppler/GlobalParams.cc | 19 ------------- + poppler/GlobalParams.h | 3 --- + poppler/SplashOutputDev.cc | 8 +++++- + poppler/SplashOutputDev.h | 3 +++ + splash/SplashFTFont.cc | 64 + ++++++++++---------------------------------- + splash/SplashFTFont.h | 4 +-- + splash/SplashFTFontEngine.cc | 8 +++--- + splash/SplashFTFontEngine.h | 7 ++--- + splash/SplashFontEngine.cc | 5 ++-- + splash/SplashFontEngine.h | 3 ++- + 11 files changed, 40 insertions(+), 86 deletions(-) + +commit 8194c156cf2167834779e1690a89b5068baf8d58 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Oct 5 00:55:55 2009 +0200 + + Fix includes for those using internal headers + + goo/FixedPoint.h | 2 +- + goo/gmem.h | 2 +- + poppler/OutputDev.h | 2 +- + poppler/PSOutputDev.h | 2 +- + poppler/PageLabelInfo.h | 2 +- + utils/ImageOutputDev.h | 2 +- + 6 files changed, 6 insertions(+), 6 deletions(-) + +commit 091f68ccd59413d6890dfbfcf8911f112e690b50 +Author: Kovid Goyal <kovid@kovidgoyal.net> +Date: Mon Oct 5 00:39:36 2009 +0200 + + Use _WIN32 instead of WIN32 + + More info at http://bugs.freedesktop.org/show_bug.cgi?id=24259 + + goo/GooMutex.h | 16 +++++++++++++++- + goo/gfile.cc | 33 +++++++++++++++++---------------- + goo/gfile.h | 5 +++-- + msvc/poppler/poppler-config.h | 2 +- + poppler-config.h.cmake | 2 +- + poppler/ABWOutputDev.h | 3 ++- + poppler/FileSpec.cc | 7 ++++--- + poppler/GlobalParams.cc | 37 +++++++++++++++++++------------------ + poppler/GlobalParams.h | 4 ++-- + poppler/Link.cc | 3 ++- + poppler/PDFDoc.cc | 4 ++-- + poppler/PDFDoc.h | 3 ++- + poppler/PSOutputDev.cc | 5 +++-- + poppler/TextOutputDev.cc | 5 +++-- + poppler/XpdfPluginAPI.cc | 13 ++++++++++++- + poppler/poppler-config.h.in | 2 +- + splash/SplashFontEngine.cc | 9 +++++---- + test/perf-test.cc | 24 ++++++++++++------------ + utils/HtmlOutputDev.h | 3 ++- + 19 files changed, 108 insertions(+), 72 deletions(-) + +commit 7fd8bdfa450db4e323e4e5d12159359fbc47f9ed +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Oct 5 00:21:15 2009 +0200 + + Remove spurious ; + + Found by -Wextra i think we should add more warnings to our default + flags + + qt4/src/poppler-annotation.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit d46f7343e446331489d3fe6711a7cf778e0bd902 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Oct 2 22:04:46 2009 +0200 + + Strings can have 0 inside so use the length + + Fixes saving some files + + poppler/PDFDoc.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 2bc2040081919340415f576ce8266356deadbfcd +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Oct 2 22:04:03 2009 +0200 + + Increase decimals from 5 to 10, a double has that precision + + Makes saving more faithful for some files + + poppler/PDFDoc.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 05eb7342d5234732f27c9c67b7fc1f9e40a4e075 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Oct 2 22:03:40 2009 +0200 + + If the stream was wrongly formed save the correct length + + Fixes saving of some files + + poppler/PDFDoc.cc | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +commit b98faa4c162392d9416a5a93c9042b41f82d8657 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Oct 2 22:02:13 2009 +0200 + + Return the save status as program status + + test/pdf-fullrewrite.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit f73f59f2c7bb7c7d57eb70cdc1bc30b80a92d0b7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Oct 2 22:01:45 2009 +0200 + + If the Length entry of the stream is wrong, fix it + + Fixes saving some files + + poppler/Parser.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 91135c7e788bc32e414e1a9c9ab43b326a07e970 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Oct 2 22:00:12 2009 +0200 + + increase the range of characters we sanitize + + Fixes saving of some files + + goo/GooString.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 9dcb3e8be2cd52a795605548e43d6bfc149b2ea5 +Author: Yaakov Selkowitz <yselkowitz@users.sourceforge.net> +Date: Sun Sep 27 17:17:32 2009 +0200 + + Fix the linking not to use the .so directly but the lib + + Fixes check on cygwin + + m4/qt.m4 | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit ed4a6f1cfc7ccd2717d939841c092347c3307547 +Author: Kovid Goyal <kovid@kovidgoyal.net> +Date: Sat Sep 26 19:26:19 2009 +0200 + + Do not crash when saving files that come from a stream without name + + Bug 24090 + + poppler/PDFDoc.cc | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit 04b232d48930af9bc614d7fef47f79ce247713a4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 26 18:30:41 2009 +0200 + + Write the Info into the trailer dict if there is one + + Bug 24091 + + poppler/PDFDoc.cc | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit 343e4f9aceb935eb393ad94bbef4dbb1b1a450ee +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 26 18:28:40 2009 +0200 + + Plug leak + + test/pdf-fullrewrite.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 2ea0032283c4717f1bb285fab7956fc38f375e87 +Author: Yaakov Selkowitz <yselkowitz@users.sourceforge.net> +Date: Sat Sep 26 15:01:35 2009 +0200 + + Patch to make poppler work on Cygwin + + Bug 4195 + + configure.ac | 3 +++ + qt/Makefile.am | 2 +- + qt4/src/Makefile.am | 2 +- + 3 files changed, 5 insertions(+), 2 deletions(-) + +commit 074dc5e5e39cebc1fbe9bf6a15b2cae2391006c1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 26 14:56:38 2009 +0200 + + Improve realibility for Streams with broken Length + + Fixes bug 6841 + + poppler/Parser.cc | 17 +++++++++++++---- + 1 file changed, 13 insertions(+), 4 deletions(-) + +commit b7702820245fb6cdbf77afba37c53c03d4362a25 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 21 21:58:26 2009 +0200 + + Print with a . and not with a , in all locales + + This is a regression after the removal of setting LC_NUMERIC + + poppler/PDFDoc.cc | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit d31080d8195694cef740d4e77484179bb38d1f26 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 20 17:21:13 2009 +0200 + + CharCodeToUnicode is not mandatory in fonts, don't crash one fonts + that do not have it + + Fixes bug #24036 + + poppler/Annot.cc | 33 ++++++++++++++++++++------------- + 1 file changed, 20 insertions(+), 13 deletions(-) + +commit a729d005a7204791fa8415de5aa0834136073ce8 +Author: Pino Toscano <pino@kde.org> +Date: Thu Sep 17 20:12:20 2009 +0200 + + Windows32/MSVC: initialize the font list once per GlobalParams, + instead of once at all + + this fixes the font list being empty at the second (and following) + GlobalParams creation + thanks for Christian Ehrlicher for reporting the bug and testing + its fix + + poppler/GlobalParams.cc | 1 + + poppler/GlobalParams.h | 1 + + poppler/GlobalParamsWin.cc | 1 - + 3 files changed, 2 insertions(+), 1 deletion(-) + +commit 68711d8494e2765c4a24ea59ce8d904981f0f917 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 9 23:24:22 2009 +0200 + + uint -> Guint + + some compilers don't know about uint + + poppler/Gfx.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 943a13c9354dec18cb023642aebbe5d3bb920ed7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 9 20:04:06 2009 +0200 + + poppler 0.12.0 + + CMakeLists.txt | 4 ++-- + NEWS | 18 ++++++++++++++++++ + configure.ac | 4 ++-- + msvc/config.h | 6 +++--- + qt4/src/Doxyfile | 2 +- + 5 files changed, 26 insertions(+), 8 deletions(-) + +commit e8ed7210346cb18f6e4588ad557f993c6d42f4a3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 9 19:21:21 2009 +0200 + + increase library to 3.2.0 + + qt4/src/CMakeLists.txt | 2 +- + qt4/src/Makefile.am | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit e950107006a3b1889646d3705323c1b3d41eaa49 +Author: David Benjamin <davidben@mit.edu> +Date: Wed Sep 9 01:19:38 2009 +0200 + + Fix infinite loop in JBIG2Decoder + + Bug 23025 + Also fixes problems in bug-poppler6881-2.pdf and bug-poppler6500.pdf + + poppler/JBIG2Stream.cc | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) + +commit 1cb25a4adaaf3e2da50724312a3db6928991f425 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 6 10:45:56 2009 +0200 + + [glib] Ignore attachments with an invalid embedded file + + Fixes bug #10386 + + glib/poppler-document.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 842e00f3114666609ef4dec6fa613d46f330a40c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 5 15:20:35 2009 +0200 + + Add EmbeddedFile::isValid + + Also do not crash if data() is called on an invalid file + + qt4/src/poppler-embeddedfile.cc | 10 +++++++++- + qt4/src/poppler-qt4.h | 9 ++++++++- + 2 files changed, 17 insertions(+), 2 deletions(-) + +commit 9d40b268f5a9a9a0fb79da0e1627dd8eebc4db6a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 5 15:19:27 2009 +0200 + + Add EmbFile::isOk + + At the moment returns false if the object stream is not really + a stream + + poppler/Catalog.h | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 642650b6f70425c8fff2df978ae71249a5ae07f3 +Author: David Benjamin <davidben@mit.edu> +Date: Sat Sep 5 01:12:49 2009 +0200 + + Better fallback when there's a type mismatch + + Bug #17252 + + poppler/GfxFont.cc | 38 ++++++++++++++++++++++++++++++++------ + 1 file changed, 32 insertions(+), 6 deletions(-) + +commit bf5811f5331292ccf30f1b0f089fe43d351d96be +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 26 00:43:46 2009 +0200 + + Improve shading color rendering + + Shading is not necessarily lineal so require another bisection to + assume all the area in between have the same color. Fixes bug #20238 + + poppler/Gfx.cc | 17 ++++++++++++++++- + 1 file changed, 16 insertions(+), 1 deletion(-) + +commit e94430b790fde6ce7b7cb163c2e0adf2d071c81d +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 26 00:42:49 2009 +0200 + + Make code a bit more readable + + poppler/Gfx.cc | 23 +++++++++++------------ + 1 file changed, 11 insertions(+), 12 deletions(-) + +commit 465212780557705fd939dfe54f96913505bfc96e +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 25 21:55:45 2009 +0200 + + forgot to update my copyright + + poppler/JPEG2000Stream.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 4f6016d01ced32002bef22b9b5d5426a74e55842 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 25 21:10:07 2009 +0200 + + Fix format security warnings + + Don't just directly print strings of unknown content; use "%s". + + poppler/JPEG2000Stream.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 4616b23382b5d155f8b2f1942733037cf5730844 +Author: Christian Persch <chpe@gnome.org> +Date: Tue Aug 25 21:09:40 2009 +0200 + + Fix format security warnings + + Don't just directly print strings of unknown content; use "%s". + + poppler/GfxState.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 6c5c8d008456d1e4f3d60bc182209747c2a175dc +Author: Christian Persch <chpe@gnome.org> +Date: Tue Aug 25 21:03:16 2009 +0200 + + Support AM_SILENT_RULES + + When using automake 1.11, should support silent build rules. + + Makefile.am | 2 +- + configure.ac | 1 + + glib/Makefile.am | 4 ++-- + qt4/demos/Makefile.am | 2 +- + qt4/src/Makefile.am | 2 +- + qt4/tests/Makefile.am | 2 +- + 6 files changed, 7 insertions(+), 6 deletions(-) + +commit e7dd1c47b01d8f31599ee686eafbe7c54d7c023a +Author: Christian Persch <chpe@gnome.org> +Date: Tue Aug 25 21:01:13 2009 +0200 + + Fix automake check, and add automake 1.11 support + + Fix the automake checks to take the *newest* version available, + not the + oldest one. Add support for automake 1.11. FDO#23473. + + autogen.sh | 13 +++++++------ + 1 file changed, 7 insertions(+), 6 deletions(-) + +commit 493d2c5aa78a3241e70108c5d7eccba9ac72f834 +Author: Rex Dieter <rdieter@math.unl.edu> +Date: Mon Aug 24 20:08:46 2009 +0200 + + Use Requires.private if available + + The following patch minimizes pkg-config deps similar to how the + glib-related pkg-config deps are done. + + poppler-qt.pc.cmake | 3 ++- + poppler-qt.pc.in | 3 ++- + poppler-qt4.pc.cmake | 3 ++- + poppler-qt4.pc.in | 3 ++- + 4 files changed, 8 insertions(+), 4 deletions(-) + +commit 341cd3ecd08a39cd146c1c57f356b50a2881c03f +Author: Jakub Wilk <ubanus@users.sf.net> +Date: Mon Aug 24 19:51:34 2009 +0200 + + common options for pdftoabw + + The attached patch fixes command line handling for pdftoabw and + implements some + common options (e.g., --help) that are already found in other + pdftosomething + utilities. + + utils/pdftoabw.cc | 39 ++++++++++++++++++++++++++++++++------- + 1 file changed, 32 insertions(+), 7 deletions(-) + +commit 365683d5faea6e0a7570b139d1f3366c22271f8e +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 18 21:18:13 2009 +0200 + + 0.11.3 + + CMakeLists.txt | 2 +- + NEWS | 22 ++++++++++++++++++++++ + configure.ac | 2 +- + msvc/config.h | 6 +++--- + qt4/src/Doxyfile | 2 +- + 5 files changed, 28 insertions(+), 6 deletions(-) + +commit cb28bc8a637d300664b3c7569263445275333878 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Aug 17 14:14:03 2009 +0200 + + [glib] Add FORMAT_MAJOR/MINOR properties to get the PDF version + + See bug #23076. + + glib/poppler-document.cc | 26 ++++++++++++++++++++++++++ + 1 file changed, 26 insertions(+) + +commit 1b5612841b0c663f6d391d4581f65f68a2975db0 +Author: Pino Toscano <pino@kde.org> +Date: Mon Aug 17 01:04:04 2009 +0200 + + [Qt] add Document::getPdfVersion(int *major, int *minor) for the + document PDF version numbers + + This new function reads the version of the PDF specification of the + document, putting major and minor numbers in own variables. + + qt/poppler-document.cc | 8 ++++++++ + qt/poppler-qt.h | 12 ++++++++++++ + 2 files changed, 20 insertions(+) + +commit aef8ecda1e80b921228f415a53c9c5a52df87d94 +Author: Pino Toscano <pino@kde.org> +Date: Mon Aug 17 00:57:08 2009 +0200 + + [Qt4] deprecate Document::pdfVersion() + + ... in favour of getPdfVersion() + + qt4/src/poppler-qt4.h | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 830140f70e48e8033ad4411b6bd405d5ad7358a3 +Author: Pino Toscano <pino@kde.org> +Date: Mon Aug 17 00:51:13 2009 +0200 + + [Qt4] add Document::getPdfVersion(int *major, int *minor) for the + document PDF version numbers + + This new function reads the version of the PDF specification of the + document, putting major and minor numbers in own variables. + Add them to the relative unit test. + + qt4/src/poppler-document.cc | 8 ++++++++ + qt4/src/poppler-qt4.h | 13 +++++++++++++ + qt4/tests/check_metadata.cpp | 4 ++++ + 3 files changed, 25 insertions(+) + +commit 5491d16dfbd73f0256c62e49d02622dc3185012e +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 17 00:24:41 2009 +0200 + + Move poppler core away from using a double as PDF file version + + Frontends are yet to come + + glib/poppler-document.cc | 2 +- + poppler/PDFDoc.cc | 7 ++++--- + poppler/PDFDoc.h | 8 +++++--- + qt/poppler-document.cc | 4 ++-- + qt4/src/poppler-document.cc | 4 ++-- + utils/pdfinfo.cc | 4 ++-- + 6 files changed, 16 insertions(+), 13 deletions(-) + +commit efd5dd63a5b08249529d9a9f5906aefe806fb3aa +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 17 00:21:22 2009 +0200 + + Forgot to update copyright info + + fofi/FoFiType1C.cc | 14 ++++++++++++++ + poppler/PDFDoc.cc | 2 +- + utils/parseargs.c | 2 +- + 3 files changed, 16 insertions(+), 2 deletions(-) + +commit 25ff4be0b4521cc3d2de386cdeb589beb245d435 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 17 00:15:10 2009 +0200 + + No need to change the locale since we use gatof that does the + right thing + + poppler/PDFDoc.cc | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +commit a6f698b4edc42c0414dd4690e1e037088321db2c +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 17 00:14:35 2009 +0200 + + Use gatof instead of atof + + fofi/FoFiType1C.cc | 3 ++- + poppler/Annot.cc | 5 +++-- + poppler/Function.cc | 3 ++- + poppler/PDFDoc.cc | 3 ++- + utils/parseargs.c | 4 +++- + 5 files changed, 12 insertions(+), 6 deletions(-) + +commit 807b121cae45832d2e5832bad19c31e77420bfec +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 17 00:10:30 2009 +0200 + + Add a custom strtod that comes from libspectre + + Works over C locale integers without changing locale settings + + CMakeLists.txt | 2 + + goo/Makefile.am | 6 ++- + goo/gstrtod.cc | 147 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + goo/gstrtod.h | 43 +++++++++++++++++ + 4 files changed, 196 insertions(+), 2 deletions(-) + +commit 914bf7677a14494b69857b1d8070092a9999fe79 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 16 20:50:02 2009 +0200 + + When writing the cm matrix write 4 significant digits not 4 decimals + + This fixes bug 23332 + Maybe we want to make this the default behaviour of 'g' instead of + a new 'gs' case, but i prefer to be on the safe side for the moment + + goo/GooString.cc | 27 +++++++++++++++++++++++++-- + goo/GooString.h | 4 +++- + poppler/PSOutputDev.cc | 4 ++-- + 3 files changed, 30 insertions(+), 5 deletions(-) + +commit b7dfca1aa52b825eb3b8f1cc0470398c31615b30 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Aug 16 19:28:37 2009 +0200 + + [cairo] CairoImageOutputDev doesn't implement patterns + + poppler/CairoOutputDev.h | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +commit d20d65111aee2ee4b8cdea2962ed1bb149122ba9 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Aug 16 17:36:14 2009 +0200 + + [cairo] Implement tiling patterns in cairo backend + + Fixes bug #13518 for the cairo backend. + + poppler/CairoOutputDev.cc | 56 + +++++++++++++++++++++++++++++++++++++++++++++++ + poppler/CairoOutputDev.h | 10 +++++++++ + 2 files changed, 66 insertions(+) + +commit e965d0686d979c775b64a93f8e2f775f81885417 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Aug 13 14:48:10 2009 +0200 + + Change OutputDev::tilingPatternFill to return a GBool + + It allows outputdevs to decide whether render the pattern or not + depending + on the parameters, like shaded patterns currently do. + + poppler/Gfx.cc | 37 +++++++++++++++++++------------------ + poppler/OutputDev.h | 11 ++++++----- + poppler/PSOutputDev.cc | 12 +++++++----- + poppler/PSOutputDev.h | 10 +++++----- + 4 files changed, 37 insertions(+), 33 deletions(-) + +commit ce70ef7d6afc800e24031dae43da301e9e542f0e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Aug 15 17:45:57 2009 +0200 + + Fix backwards search + + qt4/src/poppler-page.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 5b7b1cdc5c3b8652d3ae583b4d7b8b6de625adc2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Aug 15 17:45:05 2009 +0200 + + Add an autotest showing previousresult fails + + qt4/tests/check_search.cpp | 51 + ++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 51 insertions(+) + +commit 2484b0dcb8eb62f8e2c147498c58871ec04630b5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Aug 14 11:47:11 2009 +0200 + + Implement the alpha path + + I wonder if this is the correct fix why it was not implemented + but if fixes rendering of files in KDE bug 145868, KDE bug 193657, + poppler bug 17473.pdf, poppler bug 21651, poppler bug 22143 and + poppler bug 22152 and causes no regression in all the other files + i have in my test dir so i'm commiting it + + poppler/SplashOutputDev.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 03970d8b6d7624444664320470baa6d1b1299622 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Aug 11 12:01:07 2009 +0200 + + [build] Fix build with autotools + + utils/Makefile.am | 1 + + 1 file changed, 1 insertion(+) + +commit 15752b7cd5c94620e3ad3b6afd9c70ccc754c9b3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Aug 10 20:02:13 2009 +0200 + + [cairo] Add empty updateBlendMode to CairoImageOutputDev + + Fixes a crash when using CairoImageOutputDev with a document with + blend + modes. + + poppler/CairoOutputDev.h | 1 + + 1 file changed, 1 insertion(+) + +commit 45dae4e66b2b833f95656850b5f1b0ffd1d96f1d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Aug 10 20:00:04 2009 +0200 + + [cairo] Use current fill_opacity when drawing images + + Fixes launchpad bug #342282 (page 2 of the attached document) + + poppler/CairoOutputDev.cc | 16 +++++++++++++--- + 1 file changed, 13 insertions(+), 3 deletions(-) + +commit b1cd54546844f2f7cd6bf7cc14b7584c84c3fc14 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Aug 10 19:55:44 2009 +0200 + + [cairo] Do not save the font file twice for FreeType fonts + + Fixes bug #20491. + + poppler/CairoFontEngine.cc | 19 ++----------------- + 1 file changed, 2 insertions(+), 17 deletions(-) + +commit 4181a0ff11195eb7a56d76be23994b843e20b483 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 10 19:58:09 2009 +0200 + + this branch is unlikely to happen + + poppler/Lexer.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 2a3025f32951ce7b7343aeef111902615d71595e +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 10 19:55:40 2009 +0200 + + fix overflow calculation not to depend on the variable overflowing + + poppler/Lexer.cc | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +commit a38001f724f78231c2fdadd28e647a35b41bab74 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 9 23:26:02 2009 +0200 + + Check for overflow when parsing integers + + Fixes bug 23078 + + poppler/Lexer.cc | 28 ++++++++++++++++++++++------ + 1 file changed, 22 insertions(+), 6 deletions(-) + +commit 4c4c0e44452d07bea88d98b7df0c01fadd7693cc +Author: Jakub Wilk <ubanus@users.sf.net> +Date: Sat Aug 8 17:26:14 2009 +0200 + + Silence some warnings when using internal headers and not compiling + with -Wno-write-strings + + People should not be using internal headers but it's just two lines + + poppler/Object.h | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit e2c319ba18ab473fd969db9519a9231be67538c3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Aug 8 00:48:18 2009 +0200 + + Also implement mono so that -mono in pdftoppm -png works + + Totally not optimized + + splash/SplashBitmap.cc | 23 ++++++++++++++++++++++- + 1 file changed, 22 insertions(+), 1 deletion(-) + +commit c669e7f3ca421265e78161cc3fdecd2a0c7510c9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Aug 8 00:38:50 2009 +0200 + + Support splashModeMono8 in writePNGFile + + Works though is non optimal + + splash/SplashBitmap.cc | 55 + +++++++++++++++++++++++++++++++++++--------------- + 1 file changed, 39 insertions(+), 16 deletions(-) + +commit 92744b72df9084fd2d69ba78406898378884aed8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Aug 8 00:20:52 2009 +0200 + + Add the -png flag to pdftoppm to output to PNG + + Based on a patch by Shen Liang <shenzhuxi@gmail.com> + Also factored common PNG code from HtmlOutputDev to PNGWriter + + CMakeLists.txt | 5 +++ + goo/Makefile.am | 9 +++- + goo/PNGWriter.cc | 110 + ++++++++++++++++++++++++++++++++++++++++++++++ + goo/PNGWriter.h | 43 ++++++++++++++++++ + poppler/Makefile.am | 8 ++++ + splash/SplashBitmap.cc | 70 +++++++++++++++++++++++++++++ + splash/SplashBitmap.h | 5 +++ + splash/SplashErrorCodes.h | 4 +- + utils/CMakeLists.txt | 4 -- + utils/HtmlOutputDev.cc | 66 +++++----------------------- + utils/Makefile.am | 4 -- + utils/pdftoppm.1 | 3 ++ + utils/pdftoppm.cc | 21 +++++++-- + 13 files changed, 283 insertions(+), 69 deletions(-) + +commit e4439ff527bb202d0239f78e647452983b733411 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Aug 7 15:23:57 2009 +0200 + + [cairo] Don't apply masks when fill color space mode is csPattern + + In that case the mask is used for clipping when drawing images. Fixes + bug #22216. + + poppler/CairoOutputDev.cc | 59 + ++++++++++++++++++++++++++++++----------------- + 1 file changed, 38 insertions(+), 21 deletions(-) + +commit 7194f59a18e4f6997ae560af3db1bd101d6f726e +Author: Chris Wilson <chris@chris-wilson.co.uk> +Date: Thu Aug 6 11:24:22 2009 +0100 + + [cairo] Use FT_New_Memory_Face() for mmapped fonts + + If we hold a mapping for the font, then we can pass that memory to + FreeType for it to use as well. This saves on FreeType having to + read the + file into a fresh block of memory. + + poppler/CairoFontEngine.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 7e2bbcf6f85111d1006b0d5bc1503cadaba83c9f +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 4 00:10:58 2009 +0200 + + Set KDAB via gamaral copyright + + poppler/Form.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit ed5918e16dafebc9ecf6db8ce0186f407ecbf7d5 +Author: Pino Toscano <pino@kde.org> +Date: Sat Aug 1 20:00:22 2009 +0200 + + [Qt4 apidox] make example for FontIterator... not leak ;) + + qt4/src/poppler-qt4.h | 2 ++ + 1 file changed, 2 insertions(+) + +commit f3b36d9c992491e614e88dbf1a84b5433a7647f4 +Author: Pino Toscano <pino@kde.org> +Date: Sat Aug 1 19:54:52 2009 +0200 + + [Qt4] Add color management API. + + Add few wrapper functions to get/set color profiles. + Add a function to know whether the color management functions actually + do anything (ie support compiled or not). + Add few basic API docs for the new functions. + Based on an initial patch by Hal V. Engel <hvengel@astound.net>, + heavily reindented, polished and massaged in its API by me. + + qt4/src/poppler-document.cc | 52 + +++++++++++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-qt4.h | 50 + +++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 102 insertions(+) + +commit 78a1969d040018c0c2bb74c94f5507f786e4666e +Author: Pino Toscano <pino@kde.org> +Date: Sat Aug 1 18:00:06 2009 +0200 + + [Qt] add unhandled cases and remove unused code + + qt/poppler-page.cc | 12 ++---------- + 1 file changed, 2 insertions(+), 10 deletions(-) + +commit bddebec0712e92e13b57d3d05d652673fe737866 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Aug 1 17:12:22 2009 +0200 + + 0.11.2 + + CMakeLists.txt | 2 +- + NEWS | 30 ++++++++++++++++++++++++++++++ + configure.ac | 2 +- + msvc/config.h | 6 +++--- + qt4/src/Doxyfile | 2 +- + 5 files changed, 36 insertions(+), 6 deletions(-) + +commit 87e2af3454348f5568d155c15af5d85268e47f1b +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Aug 1 15:48:02 2009 +0200 + + [glib-demo] Add cast to make sure the comparison is always valid + + glib/demo/attachments.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 464e95ef451103daddc9a30cd26b986291f02176 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Aug 1 15:47:25 2009 +0200 + + [glib-demo] Add missing return + + glib/demo/attachments.c | 2 ++ + 1 file changed, 2 insertions(+) + +commit 7f48369e4d29b2a71abffa9e1966e3a2252de895 +Author: Guillermo Antonio Amaral Bastidas <gamaral@amaral.com.mx> +Date: Sat Aug 1 15:41:34 2009 +0200 + + Call fillChildrenSiblingsID in fillChildrenSiblingsID instaed of + loadChildrenDefaults + + poppler/Form.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e21a3e40bf6f4365064cea751ae186580d8f81f5 +Author: William Bader <williambader@hotmail.com> +Date: Sat Aug 1 15:23:03 2009 +0200 + + Add the possibility of disabling font substitution in pdftops + + Bug #23030 + + poppler/GlobalParams.cc | 17 ++++++++++++++ + poppler/GlobalParams.h | 4 ++++ + poppler/PSOutputDev.cc | 59 + +++++++++++++++++++++++++++---------------------- + poppler/PSOutputDev.h | 2 ++ + utils/pdftops.1 | 8 ++++++- + utils/pdftops.cc | 7 ++++++ + 6 files changed, 70 insertions(+), 27 deletions(-) + +commit bd68c90338cbf16f468e5db59722610300a629e1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Aug 1 15:19:48 2009 +0200 + + Forgot to add my copyright + + poppler/GfxState.h | 1 + + 1 file changed, 1 insertion(+) + +commit 173451730948c320f16a0f5924a58302603eca0b +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Aug 1 15:13:35 2009 +0200 + + Try to workaround some incorrect PDF + + Fixes rendering of PDF where forms/patterns have more q than Q. Fixes + rendering in splash of pdf in bugs #22835, #21899 and #16402 + + poppler/Gfx.cc | 13 +++++++++++++ + poppler/GfxState.h | 1 + + 2 files changed, 14 insertions(+) + +commit 35c408ca49be08144bcf14aa112505fd556725d2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 31 23:27:02 2009 +0200 + + add the overloaded virtual warning also the autotools based build + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1c32bd2d101e5dfb37e28276ecad699f121b27b7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 31 23:22:25 2009 +0200 + + Add my copyright to files i just edited + + poppler/OutputDev.cc | 1 + + poppler/OutputDev.h | 1 + + utils/HtmlOutputDev.h | 2 +- + 3 files changed, 3 insertions(+), 1 deletion(-) + +commit 10717a48c85f1dbeff1c6bcd094006a9ecc92efc +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 31 23:22:10 2009 +0200 + + Add -Woverloaded-virtual as default CXX flag + + cmake/modules/PopplerMacros.cmake | 1 + + 1 file changed, 1 insertion(+) + +commit db5f736655f01575ac5d7c524cbf131924ae91fa +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 31 23:12:00 2009 +0200 + + rename the function + + That way the name is different from the OutputDev function and does + not seem like a wrong overload + + utils/HtmlOutputDev.cc | 4 ++-- + utils/HtmlOutputDev.h | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit 4be87f87509b93c4fe4025f9bd788e9412416663 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 31 23:11:32 2009 +0200 + + Remove Outputdev::beginMarkedContent as noone uses it + + poppler/Gfx.cc | 2 -- + poppler/OutputDev.cc | 3 --- + poppler/OutputDev.h | 1 - + 3 files changed, 6 deletions(-) + +commit 6ab2ec8a89519d2bd1576c8d62f8aec51b04479a +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 31 23:10:56 2009 +0200 + + Warning-- + + poppler/PSOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 53c3d636ad645a350b576160e1498726238a7bd1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jul 31 18:23:57 2009 +0200 + + [cairo] Implement radialShadedFill in cairo backend using cairo + gradients + + Fixes bugs #10942, #14160 + + poppler/CairoOutputDev.cc | 28 +++++++++ + poppler/CairoOutputDev.h | 2 + + poppler/Gfx.cc | 141 + +++++++++++++++++++++++++++------------------- + poppler/OutputDev.h | 2 +- + poppler/PSOutputDev.cc | 3 +- + poppler/PSOutputDev.h | 2 +- + 6 files changed, 117 insertions(+), 61 deletions(-) + +commit 2ba937545d1a2b9fa798f04fee755ccdf0e74ec7 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jul 31 17:49:18 2009 +0200 + + [cairo] Use cairo_pattern_set_extend for linear gradients + + poppler/CairoOutputDev.cc | 9 +++++++++ + poppler/CairoOutputDev.h | 1 + + poppler/Gfx.cc | 34 ++++++++++++++++++++++++++++------ + poppler/OutputDev.h | 4 ++++ + 4 files changed, 42 insertions(+), 6 deletions(-) + +commit b054756113f0df6b59935823882f412486e96db5 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jun 17 11:10:15 2009 +0200 + + [cairo] Implement blend mdoes in cairo backend + + It requires cairo from git master to work at the moment. Fixes bugs + #22384, #12979, #13603, #17919, #22255 + + configure.ac | 27 ++++++++++++++++++++++ + poppler/CairoOutputDev.cc | 59 + +++++++++++++++++++++++++++++++++++++++++++++++ + poppler/CairoOutputDev.h | 1 + + 3 files changed, 87 insertions(+) + +commit bf8964726c9311e7e82b1faf49cc2272e5c1e339 +Author: William Bader <williambader@hotmail.com> +Date: Thu Jul 30 22:08:43 2009 +0200 + + Fix some double to int warnings by explicit casting + + poppler/Gfx.cc | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +commit fdbd0c548e963461b2bc4bdf1beaa1577cafcea7 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 30 21:05:18 2009 +0200 + + Update gtk-doc build files + + gtk-doc.make | 102 + +++++++++++++++++++++++++++++++++++++++------------------- + m4/gtk-doc.m4 | 74 +++++++++++++++++++++++------------------- + 2 files changed, 110 insertions(+), 66 deletions(-) + +commit ae84dce5cea4d249526a6ed5b2feb2d3f241da1b +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 30 20:45:39 2009 +0200 + + Revert "Remove unneeded files from repo" + + This reverts commit 4cc9dee35e03d7b295a476f937ec0f2c43bb6592. + + See bug #22697. + + configure.ac | 2 +- + glib/reference/Makefile.am | 4 +- + gtk-doc.make | 155 + +++++++++++++++++++++++++++++++++++++++++++++ + m4/gtk-doc.m4 | 53 ++++++++++++++++ + 4 files changed, 211 insertions(+), 3 deletions(-) + +commit 7e14516a78b16453c747eb92b08665632e5f6844 +Author: Sanjoy Mahajan <sanjoy@mit.edu> +Date: Mon Jul 27 23:20:50 2009 +0200 + + Fix displayPages call + + Parameters are outputdev, first, last, dpi, dpi, rotate, usemediabox, + crop, printing + and we were doing + usemediabox = !noCrop + crop = gFasle + the correct is + usemediabox = noCrop + crop = !noCrop + + utils/pdftops.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 3d53a0eb14420d54c0ebf8590e34c018b8da105d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jul 19 16:02:33 2009 +0200 + + Copy byte_lookup in copy constructor + + poppler/GfxState.cc | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 8f7271acf17c46e663cd48d90c382b04a834fba2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jul 19 15:53:49 2009 +0200 + + Don't use byte_lookup table when color space doesn't support getLine + methods + + For color spaces that don't implement getRGBLine or getGrayLine + methods, + getRGB or getGray are called for every pixel, however we were + allocating + the byte_lookup table and converting colors in those cases + too. Instead + of falling back to generic methods in the base class, the new methods + useGetRGBLine and useGetGrayLine have been added to he base class, + so that + when they are not suopported in the current color space byte_lookup + table is + not used at all. + + Fixes bug #11027. + + poppler/GfxState.cc | 125 + ++++++++++++++++++++++++++++++---------------------- + poppler/GfxState.h | 21 +++++++-- + 2 files changed, 91 insertions(+), 55 deletions(-) + +commit 1bc737796bef1c65289a101b2d4c367267b9c974 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jul 19 15:51:43 2009 +0200 + + Remove unused variable + + poppler/GfxState.h | 1 - + 1 file changed, 1 deletion(-) + +commit 512b2c654fd80c83b82e7adc828a478a18de17ab +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jul 26 19:35:06 2009 +0200 + + [cairo] Use CAIRO_EXTEND_PAD in drawImageMaskPrescaled too + + poppler/CairoOutputDev.cc | 32 +++++++++++++++----------------- + 1 file changed, 15 insertions(+), 17 deletions(-) + +commit ad26e34bede53cb6300bc463cbdcc2b5adf101c2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jul 26 18:36:06 2009 +0200 + + [cairo] Use rectangle + clip instead of invert + tranform + + This is just for consistency of drawImage methods + + poppler/CairoOutputDev.cc | 30 ++++++++++++++---------------- + 1 file changed, 14 insertions(+), 16 deletions(-) + +commit ee6b761a55baef4c3bbe4614b0c3b3d761a3111f +Author: Chris Wilson <chris@chris-wilson.co.uk> +Date: Sun Jul 26 16:19:15 2009 +0200 + + [cairo] Apply a clip for masked drawImage + + In order to use EXTEND_PAD with a mask, we need to apply a clip (to + constrain the image to the appropriate region). The complicating + factor for + drawSoftImage() is that mask size is independent of the image size, + so we + need to compute the intersection of the mask with in the image + in userspace. + + poppler/CairoOutputDev.cc | 21 ++++++++++++++------- + 1 file changed, 14 insertions(+), 7 deletions(-) + +commit 499c6c972bac14936b5370276da723a6e98861b3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jul 26 11:30:08 2009 +0200 + + [cairo] Use CAIRO_EXTEND_PAD when drawing images + + poppler/CairoOutputDev.cc | 306 + +++++++++++++++++++++------------------------- + 1 file changed, 140 insertions(+), 166 deletions(-) + +commit f91eb7d01cef0897727c63267db309bc92297d37 +Author: Koji Otani <sho@bbr.jp> +Date: Sat Jul 25 16:34:12 2009 +0200 + + Fix generation of ps for some files + + For example fixes second pdf in bug 18908 + + poppler/PSOutputDev.cc | 68 + +++++++++++++++++++++++++++++++++++++------------- + 1 file changed, 51 insertions(+), 17 deletions(-) + +commit f93f5e17d8f23f3e2862f3411f43a95b334e6c91 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Jul 20 17:10:37 2009 +0200 + + [cairo] Improve performance when rendering one-channel images + + It implements the same idea already used in SplashOutputDev, for + one-channel (monochrome/gray/separation) images we build a lookup + table + so that we won't need to call colorMap->getRGBLine when filling the + image buffer. Fixes bug #18017. + + poppler/CairoOutputDev.cc | 36 ++++++++++++++++++++++++++++++++++-- + 1 file changed, 34 insertions(+), 2 deletions(-) + +commit e7475062b6ae5c495fa72faaf8fb3d97391f8544 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jul 14 17:22:52 2009 +0200 + + [cairo] Handle fontType1COT fonts in CairoFontEngine + + poppler/CairoFontEngine.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit d42b9425fb2f98fa79e7a60e4f71ef14f5bacfe9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jul 12 19:55:14 2009 +0200 + + glade is not used anymore + + cmake/modules/FindGTK.cmake | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +commit 454f7468c6a6a442a5064b5daa24d65ebf4fc6b6 +Author: Chris Wilson <chris@chris-wilson.co.uk> +Date: Thu Jul 9 10:43:00 2009 +0100 + + [cairo] Fix drawImage() for non-1x1 images + + Carlos noticed a nasty bug with converting drawImage() to use PAD + + fill, + instead of NONE + paint. That is the image was being padded out + far beyond + the correct output extents. The cause is that the caller pre-scales + the + context for the image, so the output rectangle was many times the true + image size - obliterating large amounts of the page. The temporary + fix is + to counter-act the scaling on the context. Longer term, after + fixing all + painters to use PAD correctly, we need to review the callers to remove + unnecessary pre-scaling. + + poppler/CairoOutputDev.cc | 16 ++++++++++++---- + 1 file changed, 12 insertions(+), 4 deletions(-) + +commit f8d93eae3c7b9388feabac71f2380d0b42a855e7 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jul 8 20:14:35 2009 +0200 + + Lookup UF and F entries before Unix, MAC and DOS in getFileSpec + + poppler/FileSpec.cc | 24 ++++++++++++------------ + 1 file changed, 12 insertions(+), 12 deletions(-) + +commit 767c534f5fdf6ccbccfd85a0086d72c215c278f1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jul 8 19:13:54 2009 +0200 + + Use UF entry when present in dict in getFileSpecName() too + + poppler/FileSpec.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 569627ac4d56ddd58e109ce2a37179a85e042030 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jul 8 13:02:16 2009 +0200 + + Implement axialShadedFill in cairo backend using cairo gradients + + See bug #10942. + + poppler/CairoOutputDev.cc | 29 +++++++++++++++++++++++++++++ + poppler/CairoOutputDev.h | 10 ++++++++++ + poppler/Gfx.cc | 29 ++++++++++++++++++++--------- + poppler/OutputDev.h | 6 +++++- + poppler/PSOutputDev.cc | 2 +- + poppler/PSOutputDev.h | 2 +- + 6 files changed, 66 insertions(+), 12 deletions(-) + +commit 6ae0a6c0044713affa23eb1ee6a070785ed6c2f3 +Author: Chris Wilson <chris@chris-wilson.co.uk> +Date: Wed Jul 8 16:48:26 2009 +0100 + + [cairo] premultiply image mask + + Cairo uses a premultiplied colour-space, so when creating the + image mask + in drawImage() we need to remember to multiply by the alpha. In + this case + it just requires zeroing out the masked pixels. + + poppler/CairoOutputDev.cc | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +commit 646e5884e748ecce7094c673400484aa1d902bdd +Author: Chris Wilson <chris@chris-wilson.co.uk> +Date: Wed Jul 8 17:00:34 2009 +0100 + + [cairo] maskColors is an array of ints, no scaling required + + drawImage() was erroneously scaling the maskColors from what it + believed + to be [0:1] to [0:255]. However maskColors is already an integer + array, + [0:255]. + + poppler/CairoOutputDev.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit d75feb1ee84385a9f94308cf47a43f4583092ddf +Author: Chris Wilson <chris@chris-wilson.co.uk> +Date: Wed Jul 8 16:37:19 2009 +0100 + + [cairo] cleanse DrawImage() + + Just a small bit of code rearrangement to reduce repetition and + invalid checks. + + poppler/CairoOutputDev.cc | 102 + +++++++++++++++++++--------------------------- + 1 file changed, 41 insertions(+), 61 deletions(-) + +commit 52f3704fed16cfc1e9dd85f72dde7922371e4099 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jul 8 11:40:52 2009 +0200 + + [TODO] Update TODO file + + TODO | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit ef261f5f72d37a0aa2709611ee2bad7d55340ed8 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jul 7 10:57:31 2009 +0200 + + Do not use F and UF entries if Unix or DOS are present in FileSpec + dict + + poppler/FileSpec.cc | 114 + +++++++++++++++++++++++----------------------------- + 1 file changed, 51 insertions(+), 63 deletions(-) + +commit cafd4653dc6c7574214e80aa09489dcd24e347a6 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jul 1 11:41:32 2009 +0200 + + [glib-demo] Fix a typo + + glib/demo/utils.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit a3c9c6d0c0ee55dccd2d03f20d5683ae300cdc6b +Author: Pino Toscano <pino@kde.org> +Date: Wed Jul 8 02:01:39 2009 +0200 + + start updating the TODO file + + TODO file had quite some rust and dust in it, making quite "difficult" + for others to understand what can be done for helping. + First step has been removing all the items done. + Next is grouping items by areas, so it is more clear what should be + done in what area; current areas are: + - general items: for general stuff to be done, not specific to some + area; an example could have been "use littlecms for color management?" + - core: stuff which is specific to the core library + - Qt4/Qt/glib/etc frontend: stuff specific for that frontend + - new frontends: ideas for possible new frontends + + I was not sure about some items and Jeff Muizelaar's TODO, so I left + them there. + + TODO | 47 +++++++++++++++-------------------------------- + 1 file changed, 15 insertions(+), 32 deletions(-) + +commit 92ad0ef89fe7690d83854b4821178dfdb2e22897 +Author: Pino Toscano <pino@kde.org> +Date: Sat Jul 4 00:19:23 2009 +0200 + + [Qt4 demo] hopefully fix the page size on zoom change + + qt4/demos/pageview.cpp | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +commit 97094d13bc0f144b25e13c1de7a5328608ab13e3 +Author: Pino Toscano <pino@kde.org> +Date: Sat Jul 4 00:07:12 2009 +0200 + + [Qt4 demo] show a list of checked/unchecked items for the document + permissions + + qt4/demos/permissions.cpp | 25 ++++++++----------------- + qt4/demos/permissions.h | 6 +++--- + 2 files changed, 11 insertions(+), 20 deletions(-) + +commit 0d8f2ee0f03a14e7b8477c4b787c3441a758f26b +Author: Pino Toscano <pino@kde.org> +Date: Fri Jul 3 23:55:42 2009 +0200 + + [Qt4 demo] show page numbers in the toolbar as 1..n + + qt4/demos/navigationtoolbar.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit b0d48df9121c55f8162ddf0ee63832f9adebf37b +Author: Pino Toscano <pino@kde.org> +Date: Fri Jul 3 17:55:31 2009 +0200 + + [Qt4 demo] correctly use DPI values for the page sizes + + qt4/demos/pageview.cpp | 12 +++++++++--- + qt4/demos/pageview.h | 2 ++ + 2 files changed, 11 insertions(+), 3 deletions(-) + +commit dcc3c384919f1562b8f312ad3ac847e23f3e83ab +Author: Sebastien Bacher <seb128@ubuntu.com> +Date: Wed Jul 1 10:09:12 2009 +0200 + + [test] Use gtkbuilder rather than libglade + + Fixes bug #21673 + + cmake/modules/FindGTK.cmake | 1 - + configure.ac | 4 +- + test/Makefile.am | 2 +- + test/pdf-inspector.cc | 34 ++-- + test/pdf-inspector.glade | 434 + -------------------------------------------- + test/pdf-inspector.ui | 416 + ++++++++++++++++++++++++++++++++++++++++++ + 6 files changed, 439 insertions(+), 452 deletions(-) + +commit 28208d1c9b8afbb769a5f4d9b0655b99fd4af16e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jul 1 09:52:12 2009 +0200 + + [glib-demo] Do not use gio if glib < 2.15 + + Fixes bug #22530. + + glib/demo/main.c | 33 +++++++++++++++++++++++++++++++-- + 1 file changed, 31 insertions(+), 2 deletions(-) + +commit 6ef83414ab55294cf46b6b05813927bb04066986 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 30 23:07:00 2009 +0200 + + Check getFileSpecNameForPlatform succeeded before using it's return + value + + Fixes crash on bug 22551 + + poppler/Annot.cc | 7 ++++--- + poppler/Link.cc | 30 +++++++++++++++++------------- + poppler/Sound.cc | 8 +++++--- + 3 files changed, 26 insertions(+), 19 deletions(-) + +commit 4b9db83841a8b97df1e0991c1b853897b7095777 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jun 30 11:24:29 2009 +0200 + + [glib-demo] Do not fill the surface before rendering + + The surface is guaranteed to be cleared + + glib/demo/render.c | 11 ++--------- + 1 file changed, 2 insertions(+), 9 deletions(-) + +commit 5deb6db5d340c08f337d2ba67aa1fd690e4eedd8 +Author: William Bader <williambader@hotmail.com> +Date: Mon Jun 29 21:55:49 2009 +0200 + + Fix interpolate parameter position + + poppler/SplashOutputDev.cc | 3 ++- + utils/ImageOutputDev.cc | 5 +++-- + 2 files changed, 5 insertions(+), 3 deletions(-) + +commit e1e9ae2826eff1665d798b4b50b5c63e8282246b +Author: Pino Toscano <pino@kde.org> +Date: Sun Jun 28 20:11:42 2009 +0200 + + [Qt4 demo] do not crash when changing the zoom with no document + + qt4/demos/pageview.cpp | 3 +++ + 1 file changed, 3 insertions(+) + +commit a98de97137cb343182bd03c443fc08ff4e0fd9a5 +Author: Pino Toscano <pino@kde.org> +Date: Sun Jun 28 19:08:02 2009 +0200 + + [Qt4 demo] add a zoom combobox + + qt4/demos/navigationtoolbar.cpp | 33 ++++++++++++++++++++++++++++++++- + qt4/demos/navigationtoolbar.h | 7 ++++++- + qt4/demos/pageview.cpp | 14 ++++++++++++-- + qt4/demos/pageview.h | 6 +++++- + qt4/demos/viewer.cpp | 2 ++ + 5 files changed, 57 insertions(+), 5 deletions(-) + +commit 40002d2c765398869a3b7d8d92715f0608e39ab3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 28 16:45:19 2009 +0200 + + Make sure the array is big enough to read from it + + poppler/Gfx.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0a1b41ff6de5a41e3450ecbcb1ba754dc06c29d9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jun 26 19:31:22 2009 +0200 + + Do not crash when we can't find onStr + + Fixes crash in bug #22485 + Not sure this is the best solution, but Adobe doesn't even open + the file + + poppler/Form.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 6cb846664e57b02c99f1e6ad2b4e9128c9622e0a +Author: Ilya Gorenbein <igorenbein@finjan.com> +Date: Thu Jun 25 20:13:29 2009 +0200 + + Initilize AnnotColot properly when the Array is not correct + + poppler/Annot.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 5fdc3acb8dded2e7d08e6ef30f4c5ae1a4a11b5e +Author: Till Kamppeter <till.kamppeter@gmail.com> +Date: Mon Jun 22 21:38:23 2009 +0200 + + Only change the page size when it really changes, otherwise duplex + commands are lost + + poppler/PSOutputDev.cc | 10 +++++++++- + poppler/PSOutputDev.h | 4 ++++ + 2 files changed, 13 insertions(+), 1 deletion(-) + +commit bf69beeb257cfd750c6ddc8b68aeb859b36380b2 +Author: David Benjamin <davidben@mit.edu> +Date: Sat Jun 20 23:51:09 2009 +0200 + + Make DecryptStream return sane values for getPos() + + Many streams (notably JBIG2Stream) expect wrapped streams to return + correct + values for getPos(), i.e. increments by 1 when readChar() called, etc. + Fixes bug #19706. + + poppler/Decrypt.cc | 8 ++++++++ + poppler/Decrypt.h | 3 +++ + 2 files changed, 11 insertions(+) + +commit 5ee4ff2aaf98e2eaa1ec2dc9f7e659b3b01ba7bf +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jun 20 15:00:16 2009 +0200 + + [glib-demo] Allow using relative paths in demo application + + glib/demo/main.c | 17 +++++------------ + 1 file changed, 5 insertions(+), 12 deletions(-) + +commit a568248d3255407fcaa7368c4925c20e95619d20 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jun 19 21:07:39 2009 +0200 + + 0.11.1 + + CMakeLists.txt | 2 +- + NEWS | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- + configure.ac | 2 +- + msvc/config.h | 6 +++--- + qt4/src/Doxyfile | 2 +- + 5 files changed, 54 insertions(+), 8 deletions(-) + +commit ac99e239f2726db32617ff03174a6ce74361ea1b +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jun 19 21:03:29 2009 +0200 + + ship PopplerCache.h + + CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit 84984d2aa25917d68c9971cefe636e626eada13d +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jun 19 20:54:15 2009 +0200 + + Ship PopplerCache.h too + + poppler/Makefile.am | 1 + + 1 file changed, 1 insertion(+) + +commit 3a52d46e5df8eb926b550d7f7a82f316dbf6808f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jun 19 17:45:44 2009 +0200 + + [glib-demo] Destroy pattern after using it + + glib/demo/render.c | 1 + + 1 file changed, 1 insertion(+) + +commit 2e97524e5d82a4c33a4e6410fead444681db6749 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jun 19 14:20:16 2009 +0200 + + [glib-demo] Use a transparent surface and fill it in white after + rendering + + glib/demo/render.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +commit 009937842d5a8bfc12394e9e3ab71b7c33340a85 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jun 19 14:10:05 2009 +0200 + + [glib-demo] Use cairo_paint instead of rectangle + fill + + glib/demo/render.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit 7248da095f67d57c3999cee7d980e62fd8a7cf49 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jun 19 09:37:02 2009 +0200 + + Use Interpolate flag to decide whether applying image interpolation + during rendering + + Fixes bug #9860 + + poppler/ArthurOutputDev.cc | 4 +- + poppler/ArthurOutputDev.h | 5 ++- + poppler/CairoOutputDev.cc | 92 + ++++++++++++++++++++++++++------------------- + poppler/CairoOutputDev.h | 48 ++++++++++++----------- + poppler/Gfx.cc | 49 ++++++++++++++++++++---- + poppler/OutputDev.cc | 17 ++++++--- + poppler/OutputDev.h | 13 ++++--- + poppler/PSOutputDev.cc | 8 ++-- + poppler/PSOutputDev.h | 8 ++-- + poppler/PreScanOutputDev.cc | 25 ++++++++++-- + poppler/PreScanOutputDev.h | 25 ++++++++++-- + poppler/SplashOutputDev.cc | 16 +++++--- + poppler/SplashOutputDev.h | 12 ++++-- + utils/HtmlOutputDev.cc | 16 ++++---- + utils/HtmlOutputDev.h | 7 ++-- + utils/ImageOutputDev.cc | 20 +++++----- + utils/ImageOutputDev.h | 12 ++++-- + 17 files changed, 248 insertions(+), 129 deletions(-) + +commit 37e3f877ee725648734ff41e1e83870a210bcbd7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jun 19 00:37:21 2009 +0200 + + Handle Streams in CMap definitions + + Fixes bug 22334 + + poppler/CMap.cc | 50 + ++++++++++++++++++++++++++++++------------------- + poppler/CMap.h | 17 ++++++++++++----- + poppler/GfxFont.cc | 41 +++++++++++++++++++++++++++------------- + poppler/GlobalParams.cc | 6 +++--- + poppler/GlobalParams.h | 5 +++-- + 5 files changed, 77 insertions(+), 42 deletions(-) + +commit 47de8eef46300832556ce5ed869e391e477fd843 +Author: David Benjamin <davidben@mit.edu> +Date: Fri Jun 19 00:30:35 2009 +0200 + + Fix some bugs in JBIG2Stream handling + + For more info see bug 12014 and [poppler] Bug in JBIG2Stream from + 08-June-2009 + + poppler/JBIG2Stream.cc | 88 + +++++++++++++++++++++++++++----------------------- + poppler/JBIG2Stream.h | 15 +++++++++ + 2 files changed, 63 insertions(+), 40 deletions(-) + +commit d30b1013ea3ce45b5ea942fe7357c0fd07ff47f4 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jun 2 11:44:08 2009 +0200 + + Add setOpen() and setIcon() in AnnotText + + poppler/Annot.cc | 25 +++++++++++++++++++++++++ + poppler/Annot.h | 3 +++ + 2 files changed, 28 insertions(+) + +commit 287feffc1c1c0aa42a398fc071b489acef9ef22e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jun 2 11:26:40 2009 +0200 + + Add setLabel() and setPopup() to AnnotMarkup + + poppler/Annot.cc | 36 ++++++++++++++++++++++++++++++++++++ + poppler/Annot.h | 4 ++++ + 2 files changed, 40 insertions(+) + +commit 2a938af5624fbc79316dd6bee5e550f2b4270a76 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jun 2 10:59:44 2009 +0200 + + Add setParent() and setOpen() to AnnotPopup + + poppler/Annot.cc | 19 +++++++++++++++++++ + poppler/Annot.h | 4 ++++ + 2 files changed, 23 insertions(+) + +commit 0af5464352dfa51f0458c57a3590c847a45964c7 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jun 2 10:37:49 2009 +0200 + + Save parent reference of popup annotations + + poppler/Annot.cc | 16 +++++----------- + poppler/Annot.h | 4 ++-- + 2 files changed, 7 insertions(+), 13 deletions(-) + +commit fc4bc43dcd6f6871a47b9198e8c2571a5d448c3e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Jun 1 14:52:21 2009 +0200 + + Fix a crash in pdf-inspector + + test/pdf-inspector.cc | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +commit 3da7a2657892fde52b62e1f73476cb33d6c75e96 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri May 29 13:35:39 2009 +0200 + + Add Annot::setColor() + + poppler/Annot.cc | 19 ++++++++++++++++++- + poppler/Annot.h | 6 +++++- + 2 files changed, 23 insertions(+), 2 deletions(-) + +commit 3eabdf57729852205855cf74ff2d2f9d7bc03f73 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri May 29 13:23:26 2009 +0200 + + Add construtors to create AnnotColor objects directly from color + values + + poppler/Annot.cc | 26 ++++++++++++++++++++++++++ + poppler/Annot.h | 3 +++ + 2 files changed, 29 insertions(+) + +commit 8045e7a1a84a3d54a1c9415ac63b5b9df5ecc349 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri May 29 13:06:40 2009 +0200 + + Add Page::addAnnot() to add a new annotation to the page + + poppler/Page.cc | 28 ++++++++++++++++++++++++++++ + poppler/Page.h | 2 ++ + 2 files changed, 30 insertions(+) + +commit fe80eb84ec711b7400cef95e791a74c8fd259af7 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri May 29 13:00:19 2009 +0200 + + Add getRef() to get the annotation reference + + poppler/Annot.h | 1 + + 1 file changed, 1 insertion(+) + +commit 1c92657be72c44dba7185808ffb00dd85c5ab289 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri May 29 12:14:02 2009 +0200 + + Save page object and ref in Page class + + This is needed to be able to modify the page object. + + poppler/Catalog.cc | 2 +- + poppler/Page.cc | 6 +++++- + poppler/Page.h | 4 +++- + 3 files changed, 9 insertions(+), 3 deletions(-) + +commit 4ad2d663262008e4b97342c4ed67c686ff5abd13 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri May 29 11:43:30 2009 +0200 + + Add annot constructors to create annot objects without a dict + + This allows to create annotation objects to be added to the document. + Required fields on the annotation dictionary are constructor + arguments, + setters will be added for the other fields. + + poppler/Annot.cc | 300 + +++++++++++++++++++++++++++++++++++++++++++++++++++++-- + poppler/Annot.h | 22 +++- + 2 files changed, 315 insertions(+), 7 deletions(-) + +commit e5c4862b0c1b08a0fab47070cb9c862026e93567 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 10 23:28:03 2009 +0200 + + ignore++ + + m4/.gitignore | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 572779f8037763c1e0ee64c47a3dad6df0d3b693 +Author: Koji Otani <sho@bbr.jp> +Date: Wed Jun 10 22:55:26 2009 +0200 + + Fix dashed line in page 1 of bug 20011 + + poppler/Gfx.cc | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +commit b97591672e0d9c31a3d044fe52e34cc80a491221 +Author: Koji Otani <sho@bbr.jp> +Date: Wed Jun 10 22:54:57 2009 +0200 + + Fix "Conditional jump or move depends on uninitialised value" + + When stroking with a pattern, set strokeColor with a copy of + fillColor. + This is wrong and the fillColor may be uninitialized. + See bug 20011 + + poppler/Gfx.cc | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +commit a92b38836b1e4475d5a7a1b9cb8f3e9429cef275 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 9 22:39:19 2009 +0200 + + Correctly duplicate the cache on PostScriptFunction(PostScriptFunction + *func) + + poppler/Function.cc | 28 ++++++++++++++++++++++++++++ + poppler/PopplerCache.cc | 20 ++++++++++++++++++++ + poppler/PopplerCache.h | 14 ++++++++++++++ + 3 files changed, 62 insertions(+) + +commit 2cecdf922f4c8178b0e55d3ddf86c31f8be3313a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jun 9 11:04:39 2009 +0200 + + [glib] Fix a crash when a destination points to an invalid page + + glib/poppler-action.cc | 21 +++++++++++++-------- + 1 file changed, 13 insertions(+), 8 deletions(-) + +commit 831288c13c3a7502bbccd1313c6e376283be367c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 7 18:37:20 2009 +0200 + + Optimize roll() a bit + + If the number of times to roll is > than half the number of items + rotate in the reverse direction + Makes it be 33% of exec() instead of 42% + + poppler/Function.cc | 19 ++++++++++++++----- + 1 file changed, 14 insertions(+), 5 deletions(-) + +commit 3d40dcad850a2bc0e28845a15722db0c79920135 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 7 13:38:50 2009 +0200 + + Move the GfxState cache to the new poppler cache class + + poppler/GfxState.cc | 97 + +++++++++++++++++++++++++---------------------------- + poppler/GfxState.h | 19 ++--------- + 2 files changed, 49 insertions(+), 67 deletions(-) + +commit 2619e09833f421fb3d8cc68d41d15081ae6824e4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 7 13:37:40 2009 +0200 + + Implement a cache for PostscriptFunction transforms + + Makes time of rendering of bug 21562 go down from 24 to 8 seconds + + poppler/Function.cc | 76 + +++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Function.h | 2 ++ + 2 files changed, 78 insertions(+) + +commit 588bfe3c14f42be492066c2a98e30482475a6926 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 7 13:36:39 2009 +0200 + + Add a code to a generic cache based on Koji's code for GfxState cache + + CMakeLists.txt | 1 + + poppler/Makefile.am | 1 + + poppler/PopplerCache.cc | 82 + +++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/PopplerCache.h | 47 ++++++++++++++++++++++++++++ + 4 files changed, 131 insertions(+) + +commit d09478fcc44b5c594f1803fc24654af5e10fa129 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 7 01:34:01 2009 +0200 + + Move index and pop to class definition too + + poppler/Function.cc | 32 +++++++++++++++----------------- + 1 file changed, 15 insertions(+), 17 deletions(-) + +commit 2083264e8ab0fd9976294de08a18de615d5a1168 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 7 01:21:19 2009 +0200 + + Move the implementations to the class definition + + Make gcc inline the functions and time to render a heavy PSFunction + doc goes from 28 to 20 secs + + poppler/Function.cc | 151 + ++++++++++++++++++++++++---------------------------- + 1 file changed, 71 insertions(+), 80 deletions(-) + +commit 24580fcd2be74db5f3140bdb2ebff8431b7d3f1e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 6 16:17:26 2009 +0200 + + Add a debug saying how much rendering took + + qt4/tests/test-poppler-qt4.cpp | 2 ++ + 1 file changed, 2 insertions(+) + +commit 50cf7cffff760e41774957ad8f1f92803142438e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jun 6 16:04:54 2009 +0200 + + Use g_path_get_basename instead of g_basename in gtk-cairo-test + + Fixes bug #21361. + + test/gtk-cairo-test.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 4cc9dee35e03d7b295a476f937ec0f2c43bb6592 +Author: Christian Persch <chpe@gnome.org> +Date: Sat Jun 6 12:13:48 2009 +0200 + + Remove unneeded files from repo + + See bug #22094 + + configure.ac | 2 +- + glib/reference/Makefile.am | 4 +- + gtk-doc.make | 155 + --------------------------------------------- + m4/gtk-doc.m4 | 53 ---------------- + 4 files changed, 3 insertions(+), 211 deletions(-) + +commit c94e476dbff9e527c72e52377d830f35f29ba3d6 +Author: Pino Toscano <pino@kde.org> +Date: Fri Jun 5 11:09:44 2009 +0200 + + when showing the tooltip for a text rect, show also its index in + the page text boxes list + + qt4/tests/test-poppler-qt4.cpp | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit 2298acac267257b1916c802bdb902428e69e683b +Author: Pino Toscano <pino@kde.org> +Date: Fri Jun 5 11:08:51 2009 +0200 + + [Qt4 apidox] FontInterator is new in 0.12 + + qt4/src/poppler-qt4.h | 2 ++ + 1 file changed, 2 insertions(+) + +commit 37c48c2521c623c485841472c4a174a1841aea33 +Author: Pino Toscano <pino@kde.org> +Date: Fri Jun 5 10:54:30 2009 +0200 + + [CMake] Add poppler version defines and version check macro + + Add POPPLER_[MAJOR|MINOR|MICRO]_VERSION defines and + POPPLER_CHECK_VERSION macro. FDO bug #22091. + + CMakeLists.txt | 5 ++++- + glib/poppler-features.h.cmake | 9 +++++++++ + 2 files changed, 13 insertions(+), 1 deletion(-) + +commit 26f6fb1d79c2589829cd896d57da63d16641f307 +Author: Pino Toscano <pino@kde.org> +Date: Fri Jun 5 10:51:26 2009 +0200 + + [CMake] switch poppler-features.h.cmake to a more autotools-like + syntax + + glib/CMakeLists.txt | 2 +- + glib/poppler-features.h.cmake | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 89704635b727db42f6c72ba101091eb7eddb967a +Author: Pino Toscano <pino@kde.org> +Date: Fri Jun 5 10:39:17 2009 +0200 + + [Qt4 demo] compile the new thumbnail module with autotools as well + + qt4/demos/Makefile.am | 3 +++ + 1 file changed, 3 insertions(+) + +commit 291bafe64c8755fe5f85a51b184ac6e3d3170e1d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jun 5 10:07:16 2009 +0200 + + [glib] Use g_strerror instead of strerror + + Fixes bug #22095. + + glib/poppler-document.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0ca7e214fb5f9c9fb59792149bd23c1617d38cac +Author: Christian Persch <chpe@gnome.org> +Date: Thu Jun 4 22:35:40 2009 +0200 + + Add poppler version defines and version check macro + + Add POPPLER_[MAJOR|MINOR|MICRO]_VERSION defines and + POPPLER_CHECK_VERSION macro. FDO bug #22091. + + configure.ac | 11 ++++- + glib/poppler-features.h.in | 9 ++++ + glib/reference/poppler-docs.sgml | 1 + + glib/reference/poppler-sections.txt | 10 ++++ + glib/reference/tmpl/poppler-features.sgml | 80 + +++++++++++++++++++++++++++++++ + 5 files changed, 110 insertions(+), 1 deletion(-) + +commit 4ce04da0040e5a2626c110f94a128e2d272401b9 +Author: Matthias Drochner <M.Drochner@fz-juelich.de> +Date: Thu Jun 4 23:05:22 2009 +0200 + + Use the correct value when creating the V field + + PDF Spec says: + For items represented in the Opt array by a two-element array, + the name string is the second of the two array elements. + + poppler/Form.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 7e01e37a834bfdd75d739ea2b48e9127ca7f259e +Author: Till Kamppeter <till.kamppeter@gmail.com> +Date: Thu Jun 4 20:25:55 2009 +0200 + + Add part of fix for bug 20420, the other part was checked in with + Thomas patches + + poppler/PSOutputDev.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 50a7b4bcaa6e5f56cc25fe6936f9dc537a1b4b37 +Author: Jeremy C. Reed <reed@reedmedia.net> +Date: Thu Jun 4 20:19:03 2009 +0200 + + [glib] Hyphenate UTF-8 and UTF-16BE + + Fixes bug #21953. + + where iconv() is called to fill in a text field, use "UTF-8" and + "UTF-16BE" as encoding names rather than the less portable + "UTF8" and "UTF16BE" -- this makes it work on NetBSD. + + glib/poppler-annot.cc | 2 +- + glib/poppler-form-field.cc | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit 2cf9e6a2318b770ae62572944c687576d1801d31 +Author: Till Kamppeter <till.kamppeter@gmail.com> +Date: Thu Jun 4 19:48:42 2009 +0200 + + Support multiple page sizes when converting to PS + + Fixes byg #19777 + + poppler/PSOutputDev.cc | 31 +++++++++++++++++++++++++++++-- + poppler/PSOutputDev.h | 4 +++- + utils/pdftops.1 | 26 +++++++++++++++++++++----- + utils/pdftops.cc | 17 ++++++++++++----- + 4 files changed, 65 insertions(+), 13 deletions(-) + +commit 30fb7cb7e47cf6a8008c5083c8d0978fdfdf8e62 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jun 4 19:25:22 2009 +0200 + + Add missing { } + + poppler/Gfx.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 1beec21ed3a016998fee3849d460166895db9047 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 3 22:37:43 2009 +0200 + + Give an error when using level1sep without having CMYK support + + Fixes bug #22026 + + poppler/PSOutputDev.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit e80d645c34c7d44d1f35da0a25669d1c4cde6e7f +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 3 22:00:49 2009 +0200 + + Also accept tokens with to leading 00 + + Fixes bug 22025, based on a patch by William Bader + + poppler/CharCodeToUnicode.cc | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +commit e521c1efaeba3f35d10e46bca3d9650dabd2d889 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Jun 3 22:08:57 2009 +0930 + + Implement text in pattern colorspace for the cairo backend + + poppler/CairoOutputDev.cc | 47 + +++++++++++++++++++++++++++++++++++++++++++++++ + poppler/CairoOutputDev.h | 19 +++++++++++++++++++ + 2 files changed, 66 insertions(+) + +commit a87978b09a026b2db6b0f80271d87b44b336a121 +Author: Pino Toscano <pino@kde.org> +Date: Wed Jun 3 13:49:56 2009 +0200 + + [Qt4 demo] show the checksum for embedded files + + qt4/demos/embeddedfiles.cpp | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit db5102842494a124d813db1696bb60820db3442b +Author: Pino Toscano <pino@kde.org> +Date: Wed Jun 3 13:21:22 2009 +0200 + + [Qt4 demo] remove checks for Qt >= 4.2 + + poppler-qt4 requires Qt 4.3, so checking for 4.2 is no more needed + + qt4/demos/embeddedfiles.cpp | 2 -- + qt4/demos/fonts.cpp | 2 -- + qt4/demos/info.cpp | 2 -- + qt4/demos/optcontent.cpp | 2 -- + qt4/demos/permissions.cpp | 2 -- + qt4/demos/toc.cpp | 2 -- + 6 files changed, 12 deletions(-) + +commit e8d897581656ee4a20e9bb87dd999425663ace3b +Author: Pino Toscano <pino@kde.org> +Date: Wed Jun 3 02:54:29 2009 +0200 + + [Qt4 demo] simplier way to change page from the thumbnail view + + qt4/demos/pageview.cpp | 5 ----- + qt4/demos/pageview.h | 3 --- + qt4/demos/thumbnails.cpp | 2 +- + qt4/demos/thumbnails.h | 3 --- + qt4/demos/viewer.cpp | 1 - + 5 files changed, 1 insertion(+), 13 deletions(-) + +commit f69a4fe47d3478cccbc03e4ac0929c7eada681c0 +Author: Pino Toscano <pino@kde.org> +Date: Wed Jun 3 01:24:21 2009 +0200 + + [Qt4 demo] Add a thumbnail dock widget + + Useful to show the embedded page thumbnails in the document, if any. + Based on a patch by Shawn Rutledge <shawn.t.rutledge@gmail.com>, + reworked by me to be a QListWidget showing the page items at their + full size. + + qt4/demos/CMakeLists.txt | 1 + + qt4/demos/thumbnails.cpp | 84 + ++++++++++++++++++++++++++++++++++++++++++++++++ + qt4/demos/thumbnails.h | 51 +++++++++++++++++++++++++++++ + qt4/demos/viewer.cpp | 11 ++++++- + 4 files changed, 146 insertions(+), 1 deletion(-) + +commit 2f24ac0f4bbd6de1c9f137110b3ac2bd3b23b0b9 +Author: Shawn Rutledge <shawn.t.rutledge@gmail.com> +Date: Wed Jun 3 01:22:31 2009 +0200 + + [Qt4 demo] add a public slot to set the current page + + qt4/demos/pageview.cpp | 5 +++++ + qt4/demos/pageview.h | 3 +++ + 2 files changed, 8 insertions(+) + +commit 1f1baf186f9e37606765e51ec5b9893ddfbfa893 +Author: Shawn Rutledge <shawn.t.rutledge@gmail.com> +Date: Wed Jun 3 01:19:16 2009 +0200 + + [Qt4] Add Page::thumbnail() + + This function can be used to get the embedded thumbnail of the page, + present in the document. + Reindented by me, and avoid a memory leak because of non-freed data. + + qt4/src/poppler-page.cc | 21 ++++++++++++++++++++- + qt4/src/poppler-qt4.h | 11 +++++++++++ + 2 files changed, 31 insertions(+), 1 deletion(-) + +commit 5cc24be1e9af0a27ab88ffa719bcabc2378868e4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 3 00:05:54 2009 +0200 + + Remove unused variables + + poppler/SplashOutputDev.cc | 3 --- + 1 file changed, 3 deletions(-) + +commit 45823bf8f4abacbbf257f6708264de074eda3cf4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 3 00:02:54 2009 +0200 + + Make it compile :-/ + + poppler/SplashOutputDev.cc | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +commit f5ae14907261a46c121f3ed7aea9d7ad9b9c55de +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 2 23:52:59 2009 +0200 + + Really fix the typo + + README | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5d4b1995cdd57db7cef3d88704850aaf66ed7fff +Author: William Bader <williambader@hotmail.com> +Date: Tue Jun 2 23:10:53 2009 +0200 + + Fix three typos in README + + README | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 104f9286ceb5fcb5f4795bca7633029142d5f6a4 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Tue Jun 2 22:59:42 2009 +0200 + + Support colorizing text in pattern colorspace + + This implements commits the final patches for bug 19670 and 19994 + Also fixes bugs 15819 and 2807 + Also implements blending for SPLASH_CMYK in Splash + It's a quite big change but i've done regression testing over my whole + pdf suite and did not fit anything that went worse, just improvements + Missing the Cairo support + + CMakeLists.txt | 1 + + poppler/Gfx.cc | 135 ++++++++++++--- + poppler/Gfx.h | 7 + + poppler/GfxState.cc | 58 +------ + poppler/GfxState_helpers.h | 80 +++++++++ + poppler/Makefile.am | 1 + + poppler/OutputDev.h | 14 ++ + poppler/PSOutputDev.cc | 285 +++++++++++++++++++------------- + poppler/PSOutputDev.h | 18 ++ + poppler/SplashOutputDev.cc | 404 + ++++++++++++++++++++++++++++++++++++++------- + poppler/SplashOutputDev.h | 19 +++ + 11 files changed, 766 insertions(+), 256 deletions(-) + +commit d3e4563146cbff4cb507522783e60462461c7524 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun May 31 23:23:07 2009 +0200 + + Set memory to 0 after allocation, fixes problems on Sun machines, + should not hurt for others + + poppler/GfxState.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 78a58931b4347ecb505bad5a51104382ef5f91c7 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun May 31 22:52:23 2009 +0200 + + Add splashClearColor that assigns white to the given colorptr + + splash/SplashTypes.h | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +commit 47c26747b32c242ec8ac60e7b93150a67eb22e31 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Sun May 31 22:51:22 2009 +0200 + + Fix splashColorModeNComps to correctly include all values for each + SplashColorMode + + splash/SplashState.cc | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +commit 41775d8c0b44bf591d8ff5ede7fad276e8fa9eef +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Jun 1 15:24:24 2009 +0200 + + [glib-demo] Use poppler_annot_markup_has_popup() + + glib/demo/annots.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +commit f542c5294394e837298cb7e7d1d94bb336bfd09d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Jun 1 15:24:04 2009 +0200 + + [glib] Add poppler_annot_markup_has_popup() + + glib/poppler-annot.cc | 20 ++++++++++++++++++++ + glib/poppler-annot.h | 1 + + 2 files changed, 21 insertions(+) + +commit af32d56af779edcc539b680e634755941d1bf45c +Author: Petr Gajdos <pgajdos@novell.com> +Date: Thu May 21 00:37:18 2009 +0200 + + Add the possibility of forcing no hinting of fonts + + poppler/ArthurOutputDev.cc | 2 ++ + poppler/GlobalParams.cc | 20 ++++++++++++ + poppler/GlobalParams.h | 4 +++ + poppler/SplashOutputDev.cc | 2 ++ + splash/SplashFTFont.cc | 76 + +++++++++++++++++++++++++++----------------- + splash/SplashFTFont.h | 2 ++ + splash/SplashFTFontEngine.cc | 8 +++-- + splash/SplashFTFontEngine.h | 6 ++-- + splash/SplashFontEngine.cc | 4 ++- + splash/SplashFontEngine.h | 2 ++ + 10 files changed, 91 insertions(+), 35 deletions(-) + +commit 1a69d9638214943b3c2278f570694d9722a5de15 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed May 20 23:58:44 2009 +0200 + + Do not create the GfxColorTransform if the lcms could not be created + + Fixes crash on pdf from bug 20108 + + poppler/GfxState.cc | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +commit 95246d39c1289111a4ba3eb2ffbec50d7702e5eb +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed May 20 23:20:20 2009 +0200 + + Check Mask entries are int before using them, also if they are real + cast to int and try to use them + + Fixes bug #21841 + + poppler/Gfx.cc | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +commit 0c3517bfb4e1e1a28962f8d490ad69ec5766b6a1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed May 20 23:08:41 2009 +0200 + + Fix pdftops crash on file from KDE bug 174899 + + Still does not generate a correct ps file, but at least the program + does not crash now + + fofi/FoFiTrueType.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 548c72600b8a5e076647041660ed5031feedc7cc +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed May 20 22:43:11 2009 +0200 + + Do not exit(1) on a pdf i have lying around + + PDF is 0f03b3539a436a9f18d7e4e29d410f89 6607907.pdf + + poppler/JBIG2Stream.cc | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit f78d3a7ff5ef4b500d76d84ebc45aac3be162dab +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 18 20:44:40 2009 +0200 + + Move lcms.h include to GfxState.cc, replace lcms typedefs by void * + + poppler/GfxState.cc | 70 + ++++++++++++++++++++++++++++++++++++++++++++++------- + poppler/GfxState.h | 64 +++++++++++------------------------------------- + 2 files changed, 75 insertions(+), 59 deletions(-) + +commit ec2467f9981b7e7c23d5dcd8eabf2e7c8cdf8930 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 17 20:00:53 2009 +0200 + + Use the lcms include dir + + CMakeLists.txt | 3 +++ + poppler/Makefile.am | 2 ++ + 2 files changed, 5 insertions(+) + +commit e0fcf7055af480498a81a000dcd9f977a783df66 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 17 12:07:05 2009 +0200 + + Use pkgconfig for autotools cms check + + configure.ac | 12 +++++++----- + poppler/Makefile.am | 2 +- + 2 files changed, 8 insertions(+), 6 deletions(-) + +commit 657734c19274ab281328cba9297eca45e48777aa +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 17 12:06:47 2009 +0200 + + Better lcms check comming from kdelibs + + cmake/modules/FindLCMS.cmake | 95 + +++++++++++++++++++++++++++++++++----------- + 1 file changed, 71 insertions(+), 24 deletions(-) + +commit 0974b7b4bfe3f8cf3a1408741ddf01c667c28044 +Author: Patrick Spendrin <ps_ml@gmx.de> +Date: Thu May 14 16:15:22 2009 +0200 + + [Win32] Build fix for MSVC. + + poppler-config.h.cmake | 2 +- + poppler/poppler-config.h.in | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit d1c0e8a6c63361304cd453bb4c51e84a1aab7efa +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 14 00:29:18 2009 +0200 + + Kill support for specifying extension in openTmpFile + + We don't use it and it would not work anyway, see bug #21713 + + goo/gfile.cc | 58 + ++++++++++---------------------------------- + goo/gfile.h | 3 ++- + poppler/CairoFontEngine.cc | 6 ++--- + splash/SplashFTFontEngine.cc | 3 ++- + splash/SplashT1FontEngine.cc | 3 ++- + splash/SplashT1FontFile.cc | 3 ++- + 6 files changed, 24 insertions(+), 52 deletions(-) + +commit e237d8b5c2ae8805487a0790d9fb218263686712 +Author: Pino Toscano <pino@kde.org> +Date: Wed May 13 18:37:07 2009 +0200 + + [Qt4] we don't need an output device anymore (since long, even) + for resolving destinations + + qt4/src/poppler-document.cc | 3 --- + 1 file changed, 3 deletions(-) + +commit 9a2a851da93ef1a0c291fc9523a468e808ffd08e +Author: Pino Toscano <pino@kde.org> +Date: Wed May 13 18:19:11 2009 +0200 + + [Qt4] Do not try to resolve named destinations for GoTo links pointing + to external documents. + + In such cases, the named destination is a destination in the external + document, so we would try to look up a destination which is not in + the current document (thus the look up is unuseful). + It is task of the users of poppler-qt4 detect such + situations, and resolve the named when necessary, using + Document::linkDestination(QString). + + qt4/src/poppler-document.cc | 2 +- + qt4/src/poppler-link.cc | 2 +- + qt4/src/poppler-page.cc | 6 ++++-- + qt4/src/poppler-private.cc | 4 ++-- + qt4/src/poppler-private.h | 5 +++-- + 5 files changed, 11 insertions(+), 8 deletions(-) + +commit 51f6cc26fc5fdccce1ba4d4816dec374ce85d67a +Author: Pino Toscano <pino@kde.org> +Date: Wed May 13 17:38:00 2009 +0200 + + [Qt4] start a (basic) unit test for links & destinations + + qt4/tests/CMakeLists.txt | 1 + + qt4/tests/Makefile.am | 5 +++ + qt4/tests/check_links.cpp | 96 + +++++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 102 insertions(+) + +commit 174f8087f5e09c5d1915de128b7a15acf47c1e13 +Author: Pino Toscano <pino@kde.org> +Date: Wed May 13 16:44:59 2009 +0200 + + [Qt4] set the destination name only when it is not resolved + + qt4/src/poppler-link.cc | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +commit fb0cb2add9443992f166acdf744fbec875faaabf +Author: Pino Toscano <pino@kde.org> +Date: Tue May 12 01:53:43 2009 +0200 + + [Qt4] Add LinkDestination::destinationName() that returns the name + of the current destination. + + qt4/src/poppler-link.cc | 10 ++++++++++ + qt4/src/poppler-link.h | 7 +++++++ + 2 files changed, 17 insertions(+) + +commit b8bd44f1302f7b6a6923d41c98ec74c118a5abb8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 11 20:49:34 2009 +0200 + + Poppler 0.11.0 aka 0.12 Alpha 1 + + CMakeLists.txt | 4 +- + NEWS | 142 + ++++++++++++++++++++++++++++++++++++++++++++++++++++ + configure.ac | 2 +- + msvc/config.h | 6 +-- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + 6 files changed, 150 insertions(+), 8 deletions(-) + +commit 79bcedd5602729b959f21aed222445de621e7ecb +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon May 11 19:59:57 2009 +0200 + + Update copyright headers for previous patches + + poppler/ArthurOutputDev.cc | 1 + + poppler/CairoOutputDev.cc | 2 +- + poppler/Page.cc | 2 +- + poppler/Stream.cc | 1 + + poppler/Stream.h | 1 + + utils/HtmlOutputDev.cc | 1 + + utils/ImageOutputDev.cc | 1 + + 7 files changed, 7 insertions(+), 2 deletions(-) + +commit f16e36df3a74e1adf14513a6340be2e8665f8d65 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun May 10 19:24:32 2009 +0200 + + Don't include popups annots with a parent in annots list + + poppler/Annot.cc | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +commit 5051ebed1477ff3f7721606f79d66d56a80c1145 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun May 10 19:10:51 2009 +0200 + + Make sure ImageStream::close() is called after ImageStream::reset() + + poppler/ArthurOutputDev.cc | 1 + + poppler/CairoOutputDev.cc | 20 +++++++++++++++++--- + poppler/Page.cc | 1 + + poppler/Stream.cc | 4 ++++ + poppler/Stream.h | 3 +++ + utils/HtmlOutputDev.cc | 1 + + utils/ImageOutputDev.cc | 1 + + 7 files changed, 28 insertions(+), 3 deletions(-) + +commit 829ed964374676ddfa4a9048c940dc20a309ca47 +Author: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi> +Date: Sun May 10 23:39:11 2009 +0200 + + Fix axial shading fix to ensure the painting passes by the four + edges of the bbox + + When j and teoricalj are the same, just change the value of ta[] + not the next[] ones + + poppler/Gfx.cc | 23 ++++++++++++++++------- + 1 file changed, 16 insertions(+), 7 deletions(-) + +commit 68d9644499676ed1553b2bfcdbfc9a5677c75345 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat May 9 22:25:12 2009 +0200 + + Hidden property depends on parent being hidden, not only yourself + + Fixes bug #16093 + + poppler/Gfx.cc | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit 810a71ea66f0e07d9849a5e9bf28911472482d1b +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri May 8 09:36:31 2009 +0200 + + [glib] Add poppler_annot_markup_get_popup_rectangle + + glib/demo/annots.c | 8 ++++++++ + glib/poppler-annot.cc | 35 +++++++++++++++++++++++++++++++++++ + glib/poppler-annot.h | 2 ++ + 3 files changed, 45 insertions(+) + +commit 5d328282da4713356fbe4283bd992ac2fc9010a2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 7 23:11:55 2009 +0200 + + bitmap->h can be 0, move to _checkoverflow variant, code already + knows how to deal with NULL + + splash/SplashFTFont.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5b0fb6f94d6d54b1b0c97762db61e2ab0dd07c85 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed May 6 22:59:55 2009 +0200 + + Fix format printing + + poppler/JBIG2Stream.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit c21b08a254f42f53d4b59ad4fb308c7c68c32d15 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed May 6 15:56:21 2009 +0200 + + [glib] Several fixes in poppler_annot_get_color() + + PopplerColor is compatible with GdkColor where every component is + in the + range of 0 to 65535, we were returning values between 0 and 1 but + converted to guint16. + We were also showing a warning when AnnotColor::colorTransparent is + used, but we decided to return a PopplerColor * to be able to + represent + transparent color returning NULL, so it's actually supported. + + glib/demo/annots.c | 25 +++++++++++-------------- + glib/poppler-annot.cc | 36 +++++++++++++++++++++--------------- + 2 files changed, 32 insertions(+), 29 deletions(-) + +commit 63cc40ec02498e1ec249d5f74e23f574c665872e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat May 2 14:08:23 2009 +0200 + + Link pdftoabw to abiword libs + + Fixes bug #21520 + + utils/Makefile.am | 22 ++++++++++++---------- + 1 file changed, 12 insertions(+), 10 deletions(-) + +commit 70e06e9ae28d08bb7495a7f2eb03b0b5714a1e54 +Author: Kouhei Sutou <kou@cozmixng.org> +Date: Wed Apr 29 09:52:21 2009 +0900 + + PopplerAttachment refers its document. + + glib/poppler-attachment.cc | 41 +++++++++++++++++++++++++++++++++++------ + 1 file changed, 35 insertions(+), 6 deletions(-) + +commit 977a13f1091700bf7e7b31859e0e6632dc323462 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Apr 25 19:07:01 2009 +0200 + + [glib] Only create checksum string for valid checksums + + glib/poppler-attachment.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit fb6e7141e3008ae230ae5819e2c7a0425296d8d2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Apr 24 10:13:53 2009 +0200 + + Update copyright headers + + glib/poppler-annot.cc | 1 + + glib/poppler-annot.h | 1 + + poppler/Annot.cc | 2 +- + poppler/Annot.h | 2 +- + poppler/DateInfo.cc | 1 + + poppler/DateInfo.h | 1 + + 6 files changed, 6 insertions(+), 2 deletions(-) + +commit fc7e52fef0317f9c85ead2c4f8a0e9b688decca3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Apr 24 09:53:41 2009 +0200 + + Fix typos in Annot::setContents() documentation + + poppler/Annot.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit df0032cf5f6e5dc44bad056c659180e4065d32e2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Apr 23 13:19:25 2009 +0200 + + Document Annot::setContents() method + + poppler/Annot.h | 2 ++ + 1 file changed, 2 insertions(+) + +commit 86a37a8f3f93e3378b446f8d81d80571267c7660 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Apr 23 13:16:04 2009 +0200 + + Update the annotation last modified time when it's modified + + poppler/Annot.cc | 26 ++++++++++++++++---------- + poppler/Annot.h | 7 ++++--- + 2 files changed, 20 insertions(+), 13 deletions(-) + +commit 9662bfa2b4b2282d0fc29d2a327b62d8bde56ff2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Apr 23 13:13:07 2009 +0200 + + Add timeToDateString() to DateInfo + + This function converts a time_t into a string in PDF date format. + + configure.ac | 1 + + poppler/DateInfo.cc | 47 +++++++++++++++++++++++++++++++++++++++++++++++ + poppler/DateInfo.h | 7 +++++++ + 3 files changed, 55 insertions(+) + +commit dc4cf0c29b53cda5c1c2badc5026af3429502e3a +Author: Pino Toscano <pino@kde.org> +Date: Tue Apr 21 21:51:52 2009 +0200 + + add poppler-date.{cc,h} + + glib/CMakeLists.txt | 2 ++ + 1 file changed, 2 insertions(+) + +commit 0750c6502faeabff571f5730b567097e793dca64 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Apr 21 20:04:27 2009 +0200 + + [glib-demo] Fix dates handling in annots demo + + glib/demo/annots.c | 69 + +++++++++++------------------------------------------- + 1 file changed, 14 insertions(+), 55 deletions(-) + +commit fe73bf9771e8294af4c8a11ec4c2891ff8f8d859 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Apr 21 20:02:25 2009 +0200 + + [glib-demo] GTime is deprecated, use time_t instead + + glib/demo/utils.c | 2 +- + glib/demo/utils.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 6d468cfa0cb89760e5d6cca43521cde6d99aa52e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Apr 21 20:00:20 2009 +0200 + + [glib-demo] Use format_date from utils and remove duplicated code + + glib/demo/info.cc | 27 ++------------------------- + 1 file changed, 2 insertions(+), 25 deletions(-) + +commit e5f5ea01d0da4c4d877b93755523dc2a7f2ec049 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Apr 21 19:57:11 2009 +0200 + + [glib] Fix poppler_annot_markup_get_date() + + Date field in Markup annots is also a PDF format date string, so it + should be parsed and the resulting time_t used to create a correct + GDate. + + glib/poppler-annot.cc | 22 +++++++++++----------- + 1 file changed, 11 insertions(+), 11 deletions(-) + +commit 876ad1bcc8a7b2f37656bf15cee7eb888fd46ed4 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Apr 21 19:36:33 2009 +0200 + + [glib] Add info about the return value in poppler_annot_get_modified() + doc + + glib/poppler-annot.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 8c54a15e1715721ee7af7e82c90b8dda3689c65f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Apr 21 19:35:14 2009 +0200 + + [glib] Fix a typo in poppler_date_parse documentation + + glib/poppler-date.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 39d09fa237d06fa93b02eb916d2c0242c4e8fe85 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Apr 21 19:29:32 2009 +0200 + + [glib] Add poppler_date_parse to parse PDF format date strings + + We need to make this public because the field M in the Annot + dictionary + might be a Date string (in PDF date format) or a text + string. According + to the PDF spec: "The preferred format is a date string as described + in + Section 3.8.3, “Dates,” but viewer applications should be + prepared to + accept and display a string in any format". The only way to know + whether + it's a PDF date string or not, is by trying to parse it. For this + reason + poppler_annot_get_modified() returns a gchar * instead of a + time_t. So, + viewers should try to parse the string in order to convert it to a + time_t, and if it fails to parse, use the date string as provided + by the + document. + + glib/Makefile.am | 2 ++ + glib/poppler-attachment.cc | 4 +-- + glib/poppler-date.cc | 66 + ++++++++++++++++++++++++++++++++++++++++++++++ + glib/poppler-date.h | 30 +++++++++++++++++++++ + glib/poppler-document.cc | 45 ++++++------------------------- + glib/poppler-private.h | 2 +- + glib/poppler.h | 1 + + 7 files changed, 110 insertions(+), 40 deletions(-) + +commit 9c2714a3e1c02f445661618e24bcd27f1392b2b7 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Apr 21 18:08:06 2009 +0200 + + [glib] Implement poppler_annot_set_contents() + + glib/poppler-annot.cc | 25 +++++++++++++++++++++++++ + glib/poppler-annot.h | 2 ++ + 2 files changed, 27 insertions(+) + +commit eec550e8b3cf96aefed9b03a78d365c2848fb8f2 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Apr 21 18:06:34 2009 +0200 + + Add setContents() to modify the annot contents + + poppler/Annot.cc | 26 +++++++++++++++++++++++++- + poppler/Annot.h | 4 ++++ + 2 files changed, 29 insertions(+), 1 deletion(-) + +commit 047a8870a8cea9b680080e0d3bf68d0685431233 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Apr 20 23:38:53 2009 +0200 + + In case of err3 or err2 in readPageTree we need to free kidRef too + + poppler/Catalog.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit cb61b555f2c4db8685dec5491ca86570c962aab6 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Apr 18 18:30:04 2009 +0200 + + Extend test-poppler-glib to show more page annotations and actions + + Based on path by Thomas Viehmann <tv@beamnet.de> + + glib/test-poppler-glib.cc | 68 + +++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 68 insertions(+) + +commit 2221b8a9ae5e986c79ea3f6c9f3b0246d328c7ab +Author: Matthias Franz <matthias@ktug.or.kr> +Date: Sun Apr 19 23:29:18 2009 +0200 + + Fix decryption using owner password on some pdf + + See bug #21270 + + poppler/Decrypt.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit e20efbf6cc676758b8ef7d2ad607560fcdbbf89e +Author: Peter Kerzum <kerzum@yandex-team.ru> +Date: Fri Apr 17 22:14:26 2009 +0200 + + Fix typo in GfxFont.cc + + poppler/GfxFont.cc | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +commit b760debea03380280d72cd39d792cbc1a380a87c +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Apr 17 21:04:26 2009 +0200 + + Fix rendering of axial shadings + + Fixes bug #19896 + + poppler/Gfx.cc | 102 + +++++++++++++++++++++++++++++++++++---------------------- + 1 file changed, 62 insertions(+), 40 deletions(-) + +commit 9f1312f3d7dfa7e536606a7c7296b7c876b11c00 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 16 22:13:26 2009 +0200 + + Fix problems that happen when parsing broken JBIG2 files + + Fixes + CVE-2009-0799 xpdf OOB Read + CVE-2009-0800 xpdf Multiple Input Validation Flaws + CVE-2009-1179 xpdf Integer Overflow + CVE-2009-1180 xpdf Invalid free() + CVE-2009-1181 xpdf NULL dereference DoS + CVE-2009-1182 xpdf MMR Decoder Buffer Overflows + CVE-2009-1183 xpdf MMR Infinite Loop DoS + + Patch based on a patch by Derek Noonburg + Some files still hit the exit(1) in goo.c but at least none is + really crashing + + poppler/JBIG2Stream.cc | 447 + +++++++++++++++++++++++++++++++++++-------------- + poppler/JBIG2Stream.h | 4 + + 2 files changed, 324 insertions(+), 127 deletions(-) + +commit 284a92899602daa4a7f429e61849e794569310b5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Apr 13 21:51:12 2009 +0200 + + Did a mistake in the gmalloc -> gmallocn commit, it's a 4 here not a 3 + + poppler/SplashOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 9cf2325fb22f812b31858e519411f57747d39bd8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 11 00:31:57 2009 +0200 + + More gmalloc → gmallocn + + glib/poppler-page.cc | 2 +- + splash/Splash.cc | 8 ++++---- + splash/SplashBitmap.cc | 6 +++--- + splash/SplashFTFont.cc | 2 +- + 4 files changed, 9 insertions(+), 9 deletions(-) + +commit c399b2d512aa073b0d7cd8eb5413a4b43f0d6aef +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 11 00:26:23 2009 +0200 + + Revert part of last commit, i need more math classes :D + + poppler/JBIG2Stream.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 7b2d314a61fd0e12f47c62996cb49ec0d1ba747a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 11 00:23:04 2009 +0200 + + Be paranoid, use gmallocn or gmallocn3 in all gmalloc with * + + poppler/ArthurOutputDev.cc | 4 ++-- + poppler/CairoOutputDev.cc | 14 +++++++------- + poppler/GfxState.cc | 8 ++++---- + poppler/JBIG2Stream.cc | 4 ++-- + poppler/PSOutputDev.cc | 6 +++--- + poppler/SplashOutputDev.cc | 20 ++++++++++---------- + 6 files changed, 28 insertions(+), 28 deletions(-) + +commit 0131f0a01cba8691d10a18de1137a4744988b346 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 11 00:20:55 2009 +0200 + + Add gmallocn3 that does the same as gmallocn but with 3 arguments + + goo/gmem.cc | 22 ++++++++++++++++++++++ + goo/gmem.h | 2 ++ + 2 files changed, 24 insertions(+) + +commit 75c3466ba2e4980802e80b939495981240261cd5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Apr 10 18:05:54 2009 +0200 + + Make it compile in Solaris + + See bug #21080 + + poppler/CairoFontEngine.cc | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +commit 3210970dc1d6faf51bce59bb7ecb6b881f9c0fe6 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Apr 10 13:09:37 2009 +0200 + + [glib] Print annotations with the print flag enabled + + glib/poppler-page.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit b0b9798c85c7c6d6f336f73135a98974897b9f60 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 30 23:26:39 2009 +0200 + + Fix clip test for fonts + + Fixes bug 20950 + I really don't remember why i put that -1 maybe i got mislead by + SplashClip::testRect + having a +1, but the idea of the +1 is correct because it's ints + vs floats + + splash/SplashFTFont.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 5c08f57aa80092954746d722bb13655aee3f162c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Mar 29 23:52:31 2009 +0200 + + Forgot Ross copyright + + poppler/TextOutputDev.cc | 1 + + 1 file changed, 1 insertion(+) + +commit c6d3e7884010ebdcc961d81ca8c692870fc9b139 +Author: Ross Moore <ross@maths.mq.edu.au> +Date: Sun Mar 29 23:46:09 2009 +0200 + + Fix extraction of some ActualText content + + Fixes bug #20013 + + poppler/TextOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e4b3f7cbcb6ccdfa8b18d8da5f7074f4140b776a +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 25 22:16:07 2009 +0100 + + Fix getGlyphAdvance to behave correctly on font size changes + + Fixes bug #20769 + + splash/SplashFTFont.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 4acde05ac4d0b03466c949138321cc3445a14158 +Author: Eric Toombs <ewtoombs@uwaterloo.ca> +Date: Wed Mar 25 21:11:03 2009 +0100 + + Remove case-insensitive matching of filenames in PDFDoc constructor + + poppler/PDFDoc.cc | 39 ++++++++++----------------------------- + 1 file changed, 10 insertions(+), 29 deletions(-) + +commit 120c7f6697ed1edaff6e17ae1ed202c69f03a73c +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 24 22:56:33 2009 +0100 + + declare the matrix at the beginning + + poppler/ArthurOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 441a9cd56935bfe2d8fddc5d3bc2c0104aeffaca +Author: Eric Toombs <ewtoombs@uwaterloo.ca> +Date: Sun Mar 22 22:50:14 2009 +0100 + + Improved error reporting of ErrOpenFile errors + + See bug #20660 for more information + + glib/poppler-document.cc | 14 ++++++++++--- + poppler/PDFDoc.cc | 54 + ++++++++++++++++++++++++++++-------------------- + poppler/PDFDoc.h | 8 +++++++ + 3 files changed, 51 insertions(+), 25 deletions(-) + +commit 16af0ced4a0762f2f538135bd8dd72b469f6fdca +Author: Michael K. Johnson <a1237@danlj.org> +Date: Sat Mar 21 16:14:06 2009 +0100 + + Support rendering non-square pixels in pdftoppm + + Bug #20702 + + utils/pdftoppm.1 | 16 ++++++++++++++-- + utils/pdftoppm.cc | 37 ++++++++++++++++++++++++++++++++----- + 2 files changed, 46 insertions(+), 7 deletions(-) + +commit a103c60abd5fe4c721b099c005daf22d6350c355 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 21 15:47:12 2009 +0100 + + Update version we need of Qt4 + + CMakeLists.txt | 2 +- + configure.ac | 8 ++++---- + 2 files changed, 5 insertions(+), 5 deletions(-) + +commit c4b1754fdd3a4649551556de2655c8291daafddf +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 21 13:29:38 2009 +0100 + + Bump cairo dependency to 1.8.4 + + Cairo 1.8.4 fixes and important bug that affects the Type 3 font + rendering + + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 50c4ee413929e5a70133839e3cde039da738fab2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 18 22:00:05 2009 +0100 + + Add more _checkoverflow variants, rework internals + + goo/gmem.cc | 92 + ++++++++++++++++++++++++++++++------------------------------- + goo/gmem.h | 4 ++- + 2 files changed, 48 insertions(+), 48 deletions(-) + +commit 121c44db0884f0d70ba1470a66aa78441257c421 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Mar 20 23:25:19 2009 +1030 + + Fix cairo luminosity smask when cairo ctm != identity + + poppler/CairoOutputDev.cc | 16 +++++++++++++++- + 1 file changed, 15 insertions(+), 1 deletion(-) + +commit 3f55aff56a1d2002ba79f3efba5eb77e94575439 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Thu Mar 19 22:34:23 2009 +1030 + + Fix bug in cairo backend with nested masks + + The previous smask was not restored after a q/Q pair or form xobject. + + poppler/CairoOutputDev.cc | 18 +++++++++++++++++- + poppler/CairoOutputDev.h | 5 +++++ + 2 files changed, 22 insertions(+), 1 deletion(-) + +commit 4cc3cb8992ac554352d68e97563823b9bbd556ce +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Mar 20 12:38:28 2009 +0100 + + Bump cairo dependency to 1.8.4 + + Cairo 1.8.4 fixes and important bug that affects the Type 3 font + rendering + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit da94fe717a1ab60fb074fae61d582d1ee7151fc2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 16 22:54:27 2009 +0100 + + Fix parsing of border arrays + + Fixes 19761 + + poppler/Annot.cc | 54 + ++++++++++++++++++++++++++++++++++++------------------ + 1 file changed, 36 insertions(+), 18 deletions(-) + +commit 8df0323f1ca4548a5d5824ece8736b356ce7ca42 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 12 00:09:03 2009 +0100 + + Really fix jpeg lib init order? + + poppler/DCTStream.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 12aac6774fc6f92def3d5567051117951cc32223 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 11 23:00:37 2009 +0100 + + fontCIDType2OT fonts can also have a CIDToGIDMap + + Fixes bug #20605 + + poppler/GfxFont.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 0ca9ae2848808d15e7a2b00f5eb33bb8f990c887 +Author: Vincent Torri <vtorri@univ-evry.fr> +Date: Wed Mar 11 00:39:59 2009 +0100 + + remove the fortran check during the initialisation of libtool + + configure.ac | 1 + + 1 file changed, 1 insertion(+) + +commit 710e329a3a6a9ee2eed997c9eeaea21c44237423 +Author: Vincent Torri <vtorri@univ-evry.fr> +Date: Wed Mar 11 00:37:11 2009 +0100 + + Add AC_CONFIG_MACRO_DIR([m4]) + + It is used by autoreconf to trace changes in m4 macros that are in + the m4/ subdirectory. + + configure.ac | 1 + + 1 file changed, 1 insertion(+) + +commit d15e47158ae31909212d3875159046afb208de97 +Author: Vincent Torri <vtorri@univ-evry.fr> +Date: Wed Mar 11 00:36:27 2009 +0100 + + Better check for pkg-config + + configure.ac | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +commit b3f569f9a6c117c097acac52ae6552209fcd2101 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 11 00:25:07 2009 +0100 + + Check there is an optional content config before using it + + Fixes bug #20587 + + poppler/Gfx.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 7a5d1e57b2757c986da17f7238415b927e73127f +Author: Brian Ewins <Brian.Ewins@gmail.com> +Date: Mon Mar 9 22:54:58 2009 +0100 + + Check for pkgconfig before using it + + At the moment if pkgconfig is not installed, an unhelpful syntax + error appears when testing for freetype. Identify the problem + earlier on + + configure.ac | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 8dc9e4d57a4759de2b56a87d9bace80d5d563fef +Author: Marc Kleine-Budde <mkl@pengutronix.de> +Date: Sun Mar 8 15:29:02 2009 +0100 + + use AC_CHECK_HEADER to find headers + + The original m4/libjpeg.m4 used AC_FIND_FILE to look for jpeg + header file. + This test is not cross-compiling save. This patch uses the autoconf + function + AC_CHECK_HEADER to look for the jpeg header, which works in the + native and + the cross compiling scenaria. + Bug #20538 + + m4/libjpeg.m4 | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit bf2e2f056cadbc488cd3e9576b44beb34689ec81 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Mar 8 13:44:44 2009 +0100 + + Add the new croptting options explanations + + utils/pdftotext.1 | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +commit 663d9e5a448641421d290dd228be692a0f236b9c +Author: Jan Jockusch <jan@jockusch.de> +Date: Sun Mar 8 13:44:20 2009 +0100 + + Make pdftotext to accept cropping options like pdftoppm + + Bug #20331 + + utils/pdftotext.cc | 29 ++++++++++++++++++++++++++++- + 1 file changed, 28 insertions(+), 1 deletion(-) + +commit cc4b61f19b69c31d9a73ae7361c4b6a94345d1c2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Mar 8 12:55:45 2009 +0100 + + Fix the previous fix + + I should stop listening to people without checking that what they + say is + correct + + poppler/DCTStream.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit a4a73cd9f9ee9767d74fbb44ffe083d2057a9d61 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Mar 8 12:44:06 2009 +0100 + + I should compile before commiting :-/ + + poppler/DCTStream.cc | 1 - + 1 file changed, 1 deletion(-) + +commit 6a6b3cc91053e771a67dffa979076d130f87ff11 +Author: Ryszard Trojnacki <rysiek@menel.com> +Date: Sun Mar 8 12:38:42 2009 +0100 + + set up the error-manager before calling jpeg_create_decompress + + Bug #20484 + + poppler/DCTStream.cc | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +commit 4dfa7460ddc4b5684d5ef8db17efa50b95b7b735 +Author: Nick Jones <nick.jones@network-box.com> +Date: Tue Mar 3 00:55:53 2009 +0100 + + Do not blindly follow loops parsing OutlineItem + + More details in bug 18364 + + poppler/Outline.cc | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) + +commit de3131ae38fc9442b198d4d7b0c57c6939ad66ce +Author: Pino Toscano <pino@kde.org> +Date: Mon Mar 2 15:20:07 2009 +0100 + + [Qt4] adapt to the new PDFDoc saving API + + store the error code instead of the bool + + qt4/src/poppler-pdf-converter.cc | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +commit dac0542eb793603090416f1b7712ca08253f1e7f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 2 09:54:22 2009 +0100 + + [glib] Correctly handle doc->saveAs() error code. + + Fixes bug #19915. + + glib/poppler-document.cc | 37 +++++++++++++++++++++++++++++++++---- + 1 file changed, 33 insertions(+), 4 deletions(-) + +commit bfc6572614727565d883b9545d4b6665f3c2fdfe +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Feb 28 13:16:49 2009 +0100 + + Return an error code instead of a GBool when saving + + poppler/PDFDoc.cc | 22 +++++++++++----------- + poppler/PDFDoc.h | 8 ++++---- + 2 files changed, 15 insertions(+), 15 deletions(-) + +commit f7c88148fdb671736d81dd5f01a3fb68f944510c +Author: Koji Otani <sho@bbr.jp> +Date: Wed Feb 25 23:38:35 2009 +0100 + + Fix cache shifting + + poppler/GfxState.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 305af8cdb6822858e152e1f930bba2ce3904bf1b +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 25 22:40:24 2009 +0100 + + Make JBIG2Stream not crash in 2009-41414141.pdf + + poppler/JBIG2Stream.cc | 151 + ++++++++++++++++++++++++++++--------------------- + 1 file changed, 85 insertions(+), 66 deletions(-) + +commit 26a8217160c1eaeeadb92023b27e68f402e38dd0 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Feb 22 18:14:15 2009 +0100 + + Check if cairo_shape is not NULL before using it. + + We were checking shape instead. It fixes a crash with some documents. + See bug #17337. + + poppler/CairoOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5e68e52da65b4d8c3817e5fbb6f1a937da321d48 +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 21 18:03:15 2009 +0100 + + [Qt4] do not assume the destination file name for links is ASCII + + qt4/src/poppler-page.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 439cb397fed33df627a09c70788d72bef20dc872 +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 21 18:02:36 2009 +0100 + + [Qt] do not assume the destination file name for links is ASCII + + qt/poppler-page.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 3ea5f45ad3e5a55e577a2e45f61b55932ed17013 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Feb 21 17:46:30 2009 +0100 + + [glib] Make sure filename is valid utf-8 for remote dests + + glib/poppler-action.cc | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit b5989e4ffece6c1831610ee163d05fd80386a001 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Feb 21 17:45:18 2009 +0100 + + Use the UF entry when present in Filespec dictionary + + poppler/FileSpec.cc | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +commit 943fca42b5fa815fad650e42da4ad6e806adc3b1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Feb 21 12:08:00 2009 +0100 + + [glib] Add a macro to define boxed types + + glib/poppler-action.cc | 26 +------------ + glib/poppler-annot.cc | 15 ++------ + glib/poppler-document.cc | 44 +++++---------------- + glib/poppler-page.cc | 99 + ++++++++++-------------------------------------- + glib/poppler-private.h | 20 ++++++++++ + 5 files changed, 53 insertions(+), 151 deletions(-) + +commit 7406337ed2d38a86308f20f8273a152538e524de +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Feb 21 11:11:20 2009 +0100 + + [glib] Use template files to create poppler-enums + + glib/Makefile.am | 43 + +++++++++++++----------------------------- + glib/poppler-enums.c.template | 44 + +++++++++++++++++++++++++++++++++++++++++++ + glib/poppler-enums.h.template | 25 ++++++++++++++++++++++++ + 3 files changed, 82 insertions(+), 30 deletions(-) + +commit 29bc9d1dd115b5d400975533c3924993c3adae30 +Author: Thomas Viehmann <tv@beamnet.de> +Date: Sat Jan 17 13:16:38 2009 +0100 + + glib small doc comment corrections + + glib/poppler-attachment.cc | 2 +- + glib/poppler-layer.cc | 2 ++ + glib/poppler.cc | 2 -- + 3 files changed, 3 insertions(+), 3 deletions(-) + +commit a06e715d89a99b909b8e7b73b733066c67b1ade3 +Author: Thomas Viehmann <tv@beamnet.de> +Date: Sat Jan 17 12:58:20 2009 +0100 + + Make glib API reference more complete + + glib/reference/poppler-docs.sgml | 2 + + glib/reference/poppler-sections.txt | 55 +++++ + glib/reference/tmpl/poppler-action.sgml | 9 +- + glib/reference/tmpl/poppler-annot.sgml | 368 + ++++++++++++++++++++++++++++++++ + glib/reference/tmpl/poppler-layer.sgml | 79 +++++++ + 5 files changed, 511 insertions(+), 2 deletions(-) + +commit 3a21dafa46d42d86daec440a85b9d63b292a3c88 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 3 21:33:00 2009 +0100 + + Fix cache shifting + + If we do + for (i = 0;i < GFX_ICCBASED_CACHE_SIZE-1 && cache[i].num > 0;i++) { + cache[i+1] = cache[i]; + what we do at the end is copy position 0 to all others so + we need to do it in the reverse order + + poppler/GfxState.cc | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +commit 0ed3fd52bb2d3375ed302285b18f076721b8028e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Feb 1 10:37:25 2009 +0100 + + [glib-demo] Fix a typo in format string + + glib/demo/page.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 2df6d530cd9acd8648a6196031218ef10e7b3891 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 29 00:51:13 2009 +0100 + + Add line that for some reason was not imported from xpdf file + + Fixes bug 19789 + + utils/ImageOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 1fc342eadcbbb41302f190b215c5daf23c9ec9b1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 28 22:53:43 2009 +0100 + + Fix crash on unexepcted Form Opt value + + Fixes crash on bug 19790 + + poppler/Form.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit b1d4efb082ac3dadd7752a557e5aeb6651e17471 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jan 27 00:26:08 2009 +0100 + + PostScriptFunction::transform optimization + + Do not create and destroy a PSStack each time + PostScriptFunction::transform is called gives a 7% speedup on heavy + PostScriptFunction::transform pdf like nytimes firefox ad + + poppler/Function.cc | 12 ++++++++---- + poppler/Function.h | 15 +++++++++++++++ + 2 files changed, 23 insertions(+), 4 deletions(-) + +commit 90f95127d8d89cfcadeb7d701437ab07ce4a8a61 +Author: Koji Otani <sho@bbr.jp> +Date: Sun Jan 25 23:17:39 2009 +0100 + + Cache last 5 GfxICCBasedColorSpace + + poppler/GfxState.cc | 60 + +++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/GfxState.h | 15 ++++++++++++++ + 2 files changed, 75 insertions(+) + +commit d3f04f537fb3e963c149a7e2d8d83c7cb19da8c0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jan 23 23:08:46 2009 +0100 + + Do not crash in some PDF we don't parse correctly + + Fixes bug 19702 + + poppler/JBIG2Stream.cc | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +commit 3990c9e52da7b17215506857c792c90a37ebac79 +Author: Koji Otani <sho@bbr.jp> +Date: Mon Jan 19 09:53:00 2009 +0100 + + Fix a problem in cairo backend when using a CMYK Profile + + poppler/GfxState.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 6e51ae7fe8b9dc8ad52b735f2fe056f8ea8f1dcb +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 15 22:33:04 2009 +0100 + + calculate the limit in a way that one does not access an invalid + index of the matrix + + poppler/DCTStream.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ea2aa7bd1ceb0e3282398f52683e4f52ef401f74 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 15 22:18:48 2009 +0100 + + Forgot my copyrights + + poppler/DCTStream.cc | 2 +- + poppler/DCTStream.h | 2 +- + poppler/Stream.cc | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +commit d65dd23752ec14635d0d224afa7dd605f98a10a4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 15 22:17:14 2009 +0100 + + Minor optimizations + + poppler/DCTStream.cc | 17 ++++++++--------- + poppler/DCTStream.h | 3 ++- + poppler/Stream.cc | 3 ++- + 3 files changed, 12 insertions(+), 11 deletions(-) + +commit d3d2910f757dfc3e141aed62aa970136f9d7186f +Author: Pino Toscano <pino@kde.org> +Date: Sun Jan 11 00:40:46 2009 +0100 + + fix a (relatively small) memory leak when asking for a document-level + JS + + poppler/Catalog.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 869584a84eed507775ff1c3183fe484c14b6f77b +Author: Jonathan Kew <jonathan_kew@sil.org> +Date: Sat Jan 10 18:28:47 2009 +0100 + + Add the possibility of setting the datadir on runtime + + poppler/GlobalParams.cc | 27 ++++++++++++++++++++------- + poppler/GlobalParams.h | 5 ++++- + 2 files changed, 24 insertions(+), 8 deletions(-) + +commit cf112dceb1d6653beae73ce2fac6fb5eee48ff33 +Author: Koji Otani <sho@bbr.jp> +Date: Sat Jan 10 18:11:20 2009 +0100 + + Fix some problems with color management in CMYK Color Profile. + + Fixes bug 19483 + + poppler/GfxState.cc | 106 + ++++++++++++++++++++++++++-------------------------- + 1 file changed, 53 insertions(+), 53 deletions(-) + +commit 6dd77338d16f80760ae32ff9f3e2be9768fc0c49 +Author: Pino Toscano <pino@kde.org> +Date: Thu Jan 8 11:49:45 2009 +0100 + + [Qt4] use the cropbox for the annotations coordinates + + Fixes bug #18558. + + qt4/src/poppler-page.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 69c07c031159d36dde52609bffa6d48c3c56cef5 +Author: Pino Toscano <pino@kde.org> +Date: Thu Jan 8 00:59:19 2009 +0100 + + update Poppler copyright to 2009 + + msvc/poppler/poppler-config.h | 2 +- + poppler-config.h.cmake | 2 +- + poppler/poppler-config.h.in | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +commit 79e0eea85cf063c6323caafbec97f3d71fc04ca2 +Author: Pino Toscano <pino@kde.org> +Date: Thu Jan 8 00:57:03 2009 +0100 + + remove old cmake modules, add a new one + + Makefile.am | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit 0e6420ece2d6fcc046d5814b48a2754fb86771e2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 7 23:33:02 2009 +0100 + + Require cmake 2.6.0, remove two cmake files provided upstream + + CMakeLists.txt | 4 +- + cmake/modules/FindFreetype.cmake | 74 + ----------------------- + cmake/modules/FindPackageHandleStandardArgs.cmake | 58 ------------------ + glib/CMakeLists.txt | 2 +- + 4 files changed, 3 insertions(+), 135 deletions(-) + +commit a69add73bf7bef17c677c735db77934ba67188a5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 7 19:06:13 2009 +0100 + + Update copyright notices + + poppler/FontInfo.cc | 1 + + poppler/FontInfo.h | 1 + + qt4/src/poppler-document.cc | 2 +- + qt4/src/poppler-fontinfo.cc | 2 +- + qt4/src/poppler-form.cc | 1 + + qt4/src/poppler-form.h | 1 + + qt4/src/poppler-private.h | 2 +- + qt4/src/poppler-qt4.h | 2 +- + 8 files changed, 8 insertions(+), 4 deletions(-) + +commit 18d584158a781fecb4f696b01fb4d17803ce7d7a +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 7 17:55:48 2009 +0100 + + Add lcms option to cmake buildsystem + + CMakeLists.txt | 9 +++++++++ + cmake/modules/FindLCMS.cmake | 37 +++++++++++++++++++++++++++++++++++++ + config.h.cmake | 3 +++ + 3 files changed, 49 insertions(+) + +commit 140b8ed97416f9c2ec02eb749ca45ca50bd651a8 +Author: Koji Otani <sho@bbr.jp> +Date: Wed Jan 7 17:43:44 2009 +0100 + + Add initial support for color management + + configure.ac | 19 ++ + poppler/GfxState.cc | 697 + ++++++++++++++++++++++++++++++++++++++++++++++++---- + poppler/GfxState.h | 74 +++++- + poppler/Makefile.am | 5 + + 4 files changed, 738 insertions(+), 57 deletions(-) + +commit bdc76dc811a6e4d5fd929bbdc8cd3300aeaea31f +Author: Pino Toscano <pino@kde.org> +Date: Tue Jan 6 15:45:37 2009 +0100 + + [Qt4] apidox improvements for the font functions of Document; mark + scanForFonts() as deprecated + + qt4/src/poppler-qt4.h | 22 ++++++++++++++++++---- + 1 file changed, 18 insertions(+), 4 deletions(-) + +commit 6630e715714161cd803fc064f5d3cf880f42b0a5 +Author: Pino Toscano <pino@kde.org> +Date: Tue Jan 6 15:36:19 2009 +0100 + + tell Doxygen to consider Q_DECL_DEPRECATED as empty + + qt4/src/Doxyfile | 1 + + 1 file changed, 1 insertion(+) + +commit d748d430b106580b8be29ca3ec75caf05b55812e +Author: Pino Toscano <pino@kde.org> +Date: Tue Jan 6 15:24:25 2009 +0100 + + [Qt4] Add a FontIterator for iterating through the fonts of the + document, page by page. + + This new iterator class is the new preferred way for getting the + fonts of a document in a page-by-page mode. + * Document::fonts() is adapted to use it, instead of relying on + scanForFonts() + * scanForFonts() is ported to FontIterator, but keeping the old + behaviour ("i can scan the document only once") + * added unit tests for fonts(), scanForFonts() and FontIterator + + qt4/src/poppler-document.cc | 27 +++++--- + qt4/src/poppler-fontinfo.cc | 36 +++++++++++ + qt4/src/poppler-private.h | 27 ++++++-- + qt4/src/poppler-qt4.h | 65 +++++++++++++++++++ + qt4/tests/check_fonts.cpp | 149 + ++++++++++++++++++++++++++++++++++++++++++++ + 5 files changed, 291 insertions(+), 13 deletions(-) + +commit b9804542bb50216786dc11ca16efd84304f4b832 +Author: Pino Toscano <pino@kde.org> +Date: Tue Jan 6 15:16:53 2009 +0100 + + Add the possibility to set the first page to scan. + + The default value is 0 (= first page), so it should be compatible + with any usage so far. + + poppler/FontInfo.cc | 4 ++-- + poppler/FontInfo.h | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit af74fef03bfbd79334da5612c63c7793952542f9 +Author: Warren Toomey <poppler@tuhs.org> +Date: Tue Jan 6 01:36:31 2009 +0100 + + Add forgotten file to let the autotools based system build + + m4/libpng.m4 | 99 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 99 insertions(+) + +commit ae588500f62bab5666174ff3b1564c414c5a76c5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jan 6 01:35:38 2009 +0100 + + Fix the cmake buildsystem + + CMakeLists.txt | 6 ++++++ + config.h.cmake | 3 +++ + utils/CMakeLists.txt | 4 ++++ + 3 files changed, 13 insertions(+) + +commit 940d060a14712c09da427e2fac4ec579f7291b0f +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jan 6 01:27:06 2009 +0100 + + do not leak fName if fopen fails + + utils/HtmlOutputDev.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 7be9198adb940ad7c5fffc6db0158cf7042e1b8f +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jan 6 01:24:15 2009 +0100 + + Do not leak pgNum and imgnum if fopen fails + + utils/HtmlOutputDev.cc | 16 +++++++++------- + 1 file changed, 9 insertions(+), 7 deletions(-) + +commit dfba6c022b150553cb2b18b027e661b3b4625ce7 +Author: Warren Toomey <poppler@tuhs.org> +Date: Tue Jan 6 01:16:31 2009 +0100 + + Make pdftohtml output png images when the image stream is not a jpeg + + configure.ac | 14 ++++++ + utils/HtmlOutputDev.cc | 126 + ++++++++++++++++++++++++++++++++++++++++++++++--- + utils/HtmlOutputDev.h | 3 +- + utils/Makefile.am | 4 ++ + 4 files changed, 140 insertions(+), 7 deletions(-) + +commit 0963c276ba972a36c2895e4fe1c7475acd489738 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 4 16:54:32 2009 +0100 + + Fix some checked checkboxes not rendering correctly + + If we are forcing ZaDb/ZapfDingbats to correctly draw a checkmark + in the checkbox, but the file does not have such font defined we + need to create a fake one so the system really renders it + Fixes bug 19359 + + poppler/Annot.cc | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- + poppler/Annot.h | 2 ++ + poppler/Gfx.h | 7 ++++--- + 3 files changed, 53 insertions(+), 5 deletions(-) + +commit 46128cf83b322c112eb0c409c20052bdb2ea4a37 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 4 14:21:15 2009 +0100 + + Remove wrong and unused FormWidget(FormWidget *dest) contructor + + poppler/Form.cc | 11 ----------- + poppler/Form.h | 3 +-- + 2 files changed, 1 insertion(+), 13 deletions(-) + +commit 5203aefc41fa47c461812cc46f28281edd226515 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 4 14:03:16 2009 +0100 + + Plug some memory leaks + + poppler/Annot.cc | 5 ++++- + poppler/Form.cc | 4 +++- + 2 files changed, 7 insertions(+), 2 deletions(-) + +commit 5fb7ec7e6af4cfb2b256a5b9b9752e68330b4aec +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Dec 30 23:46:59 2008 +0100 + + If Length2 is zero just write until we find EOF of the stream + + Fixes exporting to PS of the two pdf i have that have fonts with + Length2 set to 0 + + poppler/PSOutputDev.cc | 26 +++++++++++++++++++++----- + 1 file changed, 21 insertions(+), 5 deletions(-) + +commit ca35fdbc7c31dae432d775b6c087a83fa9b897fc +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Dec 30 23:03:57 2008 +0100 + + We need spaces here too to satify other consumer parsers + + poppler/PDFDoc.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 3c07c73e07a9cb59ee4c23ca60d2adce92de45f7 +Author: Pino Toscano <pino@kde.org> +Date: Tue Dec 30 22:21:27 2008 +0100 + + [Qt4-demo] load a document when passed via command line + + qt4/demos/main_viewer.cpp | 4 ++++ + 1 file changed, 4 insertions(+) + +commit aba0aaa896d634a51fbb3a3e6eae411be462f930 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Dec 29 00:31:18 2008 +0100 + + More improvements in document writing + + Dictionary keys are names so need to be sanitized + Add a space after num gen obj + + poppler/PDFDoc.cc | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +commit e5b93a847ae4e20a77fecef0938da4f14dfbe3eb +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Dec 28 22:59:14 2008 +0100 + + Let compiler figure out CDECL + + CDECL is a compiler specific macro to specify C calling convention. + + On Windows, some functions must be forced to use this calling + convention. + To do this, you can use the macro CDECL, which is defined in windef.h. + + Poppler should not try to be smarter than the compiler and try + to guess + the correct definition for CDECL. Instead it should rely on the + definitions in the windef.h file provided by the compiler. + + On Unix, specifying a calling convention is not nescessary, so + CDECL can + be an empty definition. + + poppler-config.h.cmake | 8 ++------ + poppler/poppler-config.h.in | 8 ++------ + 2 files changed, 4 insertions(+), 12 deletions(-) + +commit de70c0aeb37d788f595b0574796844f51ddedec1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 28 21:21:12 2008 +0100 + + [qt4] improve doc a bit + + qt4/src/poppler-form.h | 2 +- + qt4/src/poppler-qt4.h | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit effb32658019e09dc86c017e39154fd554fc94f8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 28 02:56:30 2008 +0100 + + Form Rects are against the cropbox, not the media box + + Fixes second pdf at kde bug 161327 + + qt4/src/poppler-form.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0f10561f3b1c90acc030d973399316bfca5f495e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 28 01:44:25 2008 +0100 + + Fix my last commit, copy&paste is really evil + + goo/GooString.cc | 9 +++++---- + goo/GooString.h | 2 +- + 2 files changed, 6 insertions(+), 5 deletions(-) + +commit 217b46484ff56bfd5906b293ebee70b82cc0263d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 28 01:29:41 2008 +0100 + + Move PSOutputDev::filterPSName to GooString::sanitizedName so i can + use it from PDFDoc::writeObject + + goo/GooString.cc | 36 ++++++++++++++++++++++++++++++++++++ + goo/GooString.h | 7 +++++++ + poppler/PDFDoc.cc | 7 ++++++- + poppler/PSOutputDev.cc | 49 + +++++++++---------------------------------------- + poppler/PSOutputDev.h | 3 +-- + 5 files changed, 59 insertions(+), 43 deletions(-) + +commit f41fa9ee71aef5539cf9976c79b32bf1713c8167 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 26 22:56:12 2008 +0100 + + Change the overflow check to the same used in gmem.cc, much more + easy to understand + + poppler/XRef.cc | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +commit b8ae7d91dedc9a75200b6050628ec2740af84b98 +Author: Hib Eris <hib@hiberis.nl> +Date: Fri Dec 26 22:28:09 2008 +0100 + + Fix compile warnings on auto imports for mingw32 + + configure.ac | 3 +++ + glib/Makefile.am | 2 +- + glib/demo/Makefile.am | 2 ++ + test/Makefile.am | 2 ++ + utils/Makefile.am | 2 ++ + 5 files changed, 10 insertions(+), 1 deletion(-) + +commit ba47bd2ba05f883306606eda30bff17bd4a8eec6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 26 19:47:42 2008 +0100 + + BaseFile.h has never been used and it fact it's not part of xpdf + sources + + Fixes bug 19298 + + CMakeLists.txt | 1 - + poppler/BaseFile.h | 82 + ----------------------------------------------------- + poppler/Makefile.am | 1 - + 3 files changed, 84 deletions(-) + +commit 84366d9e63b0d6a5ee1aae2463648cfc2ff5e1b8 +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Dec 24 19:27:19 2008 +0100 + + Let libtool build DLLs on windows too + + configure.ac | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 08cef528f2e51cc62cff4125f179021ad9555317 +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Dec 24 17:48:46 2008 +0100 + + Fix compile warning on string literal format + + test/pdf-inspector.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0606b4bba8e889204c7b7c9d376f63b659f83a4f +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Dec 24 17:48:10 2008 +0100 + + Fix compile warnings on parentheses and/or + + poppler/CairoOutputDev.cc | 13 +++++++------ + 1 file changed, 7 insertions(+), 6 deletions(-) + +commit eba2232cabd5fb1e177db2a6053f0d1a0aee882b +Author: Hib Eris <hib@hiberis.nl> +Date: Wed Dec 24 17:46:32 2008 +0100 + + Fix some more warnings + + test/gtk-cairo-test.cc | 11 ----------- + test/pdf-inspector.cc | 9 +++++---- + 2 files changed, 5 insertions(+), 15 deletions(-) + +commit c80431eb1626d89e7b615e5a5149d3436b554b66 +Author: Hib Eris <hib@hiberis.nl> +Date: Mon Dec 22 09:28:47 2008 +0100 + + Fix compile warning on format type + + glib/test-poppler-glib.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit fda181c35b7c7500b6d3c6ca9d454addd54929c5 +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 22 00:53:44 2008 +0100 + + group condition within brackets + + poppler/ArthurOutputDev.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit c1beeecbd6cbf82811d70c75cb24059b4b492abe +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 22 00:46:49 2008 +0100 + + [demo] use the proper format field for gsize types + + glib/demo/attachments.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit bfb975466f0ff78e9e292b6af7cac66e4c331456 +Merge: 3e27892 ea3546f +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 22 00:29:38 2008 +0100 + + Merge branch 'master' of + ssh://pino@git.freedesktop.org/git/poppler/poppler + +commit 3e2789257f5fc4ae0573a0c62ea380d8e83a5bb5 +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 22 00:24:23 2008 +0100 + + [Qt] deserialize also the value of 'right' + + qt/poppler-link.cc | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +commit 7c053ab7623cea1ac650d3e960d2d91a1ef21557 +Author: Pino Toscano <pino@kde.org> +Date: Mon Dec 22 00:19:02 2008 +0100 + + [Qt] move in a .cc file the implementation of the QString<->GooString + functions and DocumentData::addTocChildren() + + qt/CMakeLists.txt | 1 + + qt/Makefile.am | 1 + + qt/poppler-document.cc | 10 ---- + qt/poppler-page.cc | 1 + + qt/poppler-private.cc | 147 + +++++++++++++++++++++++++++++++++++++++++++++++++ + qt/poppler-private.h | 106 +++-------------------------------- + 6 files changed, 157 insertions(+), 109 deletions(-) + +commit ea3546f84c5335c58cdb2906b1a1a4656be9c8ea +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Dec 21 23:33:49 2008 +0100 + + Fix compile warnings on signed/unsigned comparison + + goo/gfile.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit ca672ae51d2c1fa59a891717b418ba86b5e7345c +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Dec 21 23:33:00 2008 +0100 + + Fix compile warnings on ignored pragma with mingw compiler + + poppler/Gfx.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 86cfe8ab2b4e0b600f3f6682701c2fcfbe5d0ca9 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Dec 21 23:08:56 2008 +0100 + + Fix compile warnings on signed/unsigned comparison + + poppler/GfxFont.cc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit e34af7ffe0a4024e2eb39314bdb09eb9a662e53e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 21 22:16:39 2008 +0100 + + Update copyright of last commits + + poppler/TextOutputDev.cc | 1 + + poppler/TextOutputDev.h | 2 +- + qt4/src/poppler-page.cc | 1 + + 3 files changed, 3 insertions(+), 1 deletion(-) + +commit f6d84dcfc9cc587c7408af79b1ee7658d456f8d8 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Dec 21 22:09:00 2008 +0100 + + Fix compile warning to suggest parentheses and/or + + poppler/TextOutputDev.cc | 14 ++++++++------ + 1 file changed, 8 insertions(+), 6 deletions(-) + +commit 15205403eaa95d6fba0e36983de993877dd3a983 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Dec 21 21:59:45 2008 +0100 + + Fix warning to suggest parentheses inside shift + + poppler/PSOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit cc24f37e582bfc0069faf286da97a48fe4794db1 +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Dec 21 21:35:29 2008 +0100 + + Fix compile warning on ambiguous else + + test/perf-test.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit a8cc4ad8c2da804f25db8cca1c85433d5a63307c +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Dec 21 21:34:28 2008 +0100 + + Fix compile warning on format not a string literal + + test/perf-test.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 3cbbf8226730aa7ee6273e154e4a9d58670a3cda +Author: Hib Eris <hib@hiberis.nl> +Date: Sun Dec 21 21:30:54 2008 +0100 + + Fix compile warning about uninitialized variable + + poppler/ABWOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit f675916277cb76cd1293225a1271f835a02148fb +Author: Pino Toscano <pino@kde.org> +Date: Sat Dec 20 23:23:10 2008 +0100 + + reset to NULL after being deleted + + found with poppler-qt4 unit tests =) + + poppler/TextOutputDev.cc | 1 + + 1 file changed, 1 insertion(+) + +commit c976770c64e4c991fff27e413414473583b6fd86 +Author: Pino Toscano <pino@kde.org> +Date: Sat Dec 20 22:25:55 2008 +0100 + + [Qt4] use QHash instead of QMap where applicable + + using a hash table instead of a map mapes lookup faster; + in these cases we don't need the sorting a map gives + + qt4/src/poppler-page.cc | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +commit 944f6049a50eb3be9fb29174d67adc4ad1d0b9fe +Author: Pino Toscano <pino@kde.org> +Date: Sat Dec 20 20:13:43 2008 +0100 + + add find.c and text.c + + glib/demo/CMakeLists.txt | 2 ++ + 1 file changed, 2 insertions(+) + +commit ba91b889c3b50239e339938f3c9d31fffcd87d44 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Dec 20 19:29:40 2008 +0100 + + Make destructor private in TextPage + + poppler/TextOutputDev.h | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit 0da16537aa83f6ed6d8895c7e54266263a71c1cf +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Dec 19 19:08:21 2008 +0100 + + Refactor actual text code adding a new ActualText class + + It's used by both Text and Cairo ouput devices avoiding duplicated + code + in such classes. + + poppler/CairoOutputDev.cc | 108 +++--------------------- + poppler/CairoOutputDev.h | 7 +- + poppler/TextOutputDev.cc | 206 + ++++++++++++++++++++++++++-------------------- + poppler/TextOutputDev.h | 34 ++++++-- + 4 files changed, 160 insertions(+), 195 deletions(-) + +commit 0f8ab301c633133eea3dbd4f2254f31c50e3c4a9 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Dec 14 13:12:34 2008 +0100 + + [glib-demo] Add find demo + + glib/demo/Makefile.am | 2 + + glib/demo/find.c | 282 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + glib/demo/find.h | 31 ++++++ + glib/demo/main.c | 4 +- + 4 files changed, 318 insertions(+), 1 deletion(-) + +commit 88df9e9aa9adb53f0a9714ea404d46f111495df3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Dec 14 11:54:35 2008 +0100 + + [glib-demo] Add Text demo + + glib/demo/Makefile.am | 2 + + glib/demo/main.c | 4 +- + glib/demo/text.c | 175 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + glib/demo/text.h | 31 +++++++++ + 4 files changed, 211 insertions(+), 1 deletion(-) + +commit 5b0f2355d55a5104820fd0bf16b4e76b25959de4 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Dec 14 11:49:00 2008 +0100 + + [glib] Use TextPage instead of TextOutputDev when cairo is enabled + + glib/poppler-page.cc | 148 + ++++++++++++++++++++++++++++++++++--------------- + glib/poppler-private.h | 4 ++ + 2 files changed, 107 insertions(+), 45 deletions(-) + +commit 3ced71fb68d62308db7b9535367eafefb55d1cde +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Dec 14 11:18:00 2008 +0100 + + Add optionally text support to CairoOutputDev + + If a TextPage is set, it'll be used when rendering so that we + don't need + to use TextOutputDev and render again. + + poppler/CairoOutputDev.cc | 144 + ++++++++++++++++++++++++++++++++++++++++++++-- + poppler/CairoOutputDev.h | 19 +++++- + 2 files changed, 155 insertions(+), 8 deletions(-) + +commit 0bdad35cc4cfdb8da5acaf44678920b7a0025f99 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Dec 14 11:14:12 2008 +0100 + + Add refcount support to TextPage + + poppler/TextOutputDev.cc | 12 +++++++++++- + poppler/TextOutputDev.h | 5 +++++ + qt4/src/poppler-page.cc | 2 +- + 3 files changed, 17 insertions(+), 2 deletions(-) + +commit f86514c3fbc867fc6457feacba23451e89993524 +Author: Koji Otani <sho@bbr.jp> +Date: Wed Dec 17 00:36:39 2008 +0100 + + Fix wrong PS generation when a large image is in Patterns + + Bug 18908 + + poppler/PSOutputDev.cc | 114 + +++++++++++++++++++++++++++++++------------------ + 1 file changed, 72 insertions(+), 42 deletions(-) + +commit fc395eb90b418e43453acefb42cd04baf0b7ad40 +Author: Richard Airlie <richard.airlie@maglabs.net> +Date: Tue Dec 16 21:11:53 2008 +0100 + + Allow the use of cropbox in pdftoppm + + utils/pdftoppm.cc | 16 +++++++++++++--- + 1 file changed, 13 insertions(+), 3 deletions(-) + +commit 80f415176952635a485356cf36048eee53396c25 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Dec 16 20:37:39 2008 +0100 + + Make destructors private/protected since you are not supposed to + use them + + poppler/GfxFont.cc | 2 +- + poppler/GfxFont.h | 11 +++++------ + 2 files changed, 6 insertions(+), 7 deletions(-) + +commit dbcebda953cb36a45a125aada68e85249fb73f43 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Dec 15 20:10:31 2008 +0100 + + Do not leak on AnnotScreen destructor + + Fixes bug 19095 + + poppler/Annot.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit aaeb0d137232bf1cb11dc5e37b8b45b50c6f9c6a +Author: Pino Toscano <pino@kde.org> +Date: Fri Dec 12 00:43:19 2008 +0100 + + update the xpdf headers installation + + CMakeLists.txt | 32 +++++++++++++++++++++----------- + 1 file changed, 21 insertions(+), 11 deletions(-) + +commit 7c6527fa05389f705872aaaaff12e739b5d1577e +Author: Pino Toscano <pino@kde.org> +Date: Fri Dec 12 00:41:21 2008 +0100 + + don't install Function.cc, as it is not an header + + poppler/Makefile.am | 1 - + 1 file changed, 1 deletion(-) + +commit 0179e21b128ffccb5afd13203137ab8435197609 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 12 00:16:38 2008 +0100 + + Be more helpful with bad boys that want to use poppler core directly + + fofi/Makefile.am | 10 ++++++++++ + splash/SplashClip.h | 2 +- + splash/SplashPath.h | 2 +- + splash/SplashXPath.h | 2 +- + 4 files changed, 13 insertions(+), 3 deletions(-) + +commit 401632e4eeb4b10b1183a820f32461da77e8e4f2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 12 00:14:04 2008 +0100 + + Try harder to look for openjpeg + + cmake/modules/FindLIBOPENJPEG.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ab539f46089702f60b96b1ba2b2bc1544173c264 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Dec 11 23:15:45 2008 +0100 + + Fix crash when reading outline + + Fixes bug 19024. Last as reference is required if the item has + children (Table 8.4) so if there is no last reference, don't try to + read children. + + poppler/Outline.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit c9a755f9fd14511f43a2ca7fcda36bdd64bb1d87 +Author: Ilya Gorenbein <igorenbein@finjan.com> +Date: Sun Dec 7 17:59:19 2008 +0100 + + Fix memory leak + + Bug 18924 + + poppler/Page.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 4cd364c179ae91ed383a8237ba1ad263952fd7aa +Author: Pino Toscano <pino@kde.org> +Date: Sun Nov 30 16:57:52 2008 +0100 + + add my copyright here + + qt4/src/poppler-private.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 6b1676deb773675d90469adc84c3de8dcdaf174c +Author: Pino Toscano <pino@kde.org> +Date: Sun Nov 30 16:56:43 2008 +0100 + + [Qt4] support URI actions for TOC items + + qt4/src/poppler-private.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit b5cd58b5565055fd0c13771461245ddcd80edfcf +Author: Pino Toscano <pino@kde.org> +Date: Sun Nov 30 16:34:57 2008 +0100 + + extract the LinkAction "serialization" in an own function, and make + it more safe + + qt4/src/poppler-private.cc | 85 + ++++++++++++++++++++++++++++++++-------------- + 1 file changed, 59 insertions(+), 26 deletions(-) + +commit ee191363e22940ae7b06945e68c4738b17c78348 +Author: Pino Toscano <pino@kde.org> +Date: Sun Nov 30 16:17:32 2008 +0100 + + move the addTocChildren() implementation in the cpp + + qt4/src/poppler-form.cc | 1 + + qt4/src/poppler-page.cc | 1 + + qt4/src/poppler-private.cc | 65 + ++++++++++++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-private.h | 64 + ++------------------------------------------- + 4 files changed, 69 insertions(+), 62 deletions(-) + +commit f8eaabf1aa7e384619129a7509be85d0c3bfb825 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Nov 30 13:33:12 2008 +0100 + + Update copyrights of the last commits + + poppler/TextOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5f4fedfae6098e25644ffe5d4b1ed0bac043841d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Nov 29 19:51:27 2008 +0100 + + Use the Length specified in the Stream as initial bufSize + + This is a optimization to save a few reallocations, if the Length + value is incorrect it will still work + + poppler/JPEG2000Stream.cc | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +commit 12f6d6ba2052fbdc8ea4ba7c7c9277e75bf170a5 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Nov 23 18:20:14 2008 +0100 + + Fix a crash when the second argument of opMarkPoint is not a + dictionary + + According to the spec "If any of the values are indirect references to + objects outside the content stream, the property list dictionary must + instead be defined as a named resource. + + poppler/Gfx.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 817e123a28e9f6b7e5be23f7ac2ba3bcec5e3f3f +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Nov 22 21:48:37 2008 +1030 + + Don't compare print flag for non Type 3 fonts in cairo font cache + + poppler/CairoFontEngine.cc | 7 ++++++- + poppler/CairoFontEngine.h | 4 +++- + 2 files changed, 9 insertions(+), 2 deletions(-) + +commit 68f8ade28764855d4f663607c50c8202b1268296 +Author: Albert Astals Cid <tsdgeos@samsung.localdomain> +Date: Sun Nov 23 10:54:46 2008 +0100 + + Compile with -pedantic + + Thanks to Bernard Leak for notifying + + test/pdf-inspector.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 4a4fa7ed44a87e47a6078a1f7bb6f41071672ea7 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Nov 18 20:11:07 2008 +0100 + + Fix a crash when selecting text in word mode + + poppler/TextOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit a6f5032ab0d6edbf3879f39efff7916b1f7233da +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Nov 16 18:24:06 2008 +0100 + + optContentConfig is not actually stored in PDFDoc but in Catalog + + poppler/PDFDoc.h | 1 - + 1 file changed, 1 deletion(-) + +commit b843ac34c6c4ca1580f99fa2220c59dfcd91f026 +Author: Pino Toscano <pino@kde.org> +Date: Sat Nov 15 14:49:02 2008 +0100 + + [Qt4] deserialize the value of the 'right' coordinate, too + + qt4/src/poppler-link.cc | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +commit 03061fdae49842556c9ff48e61914fc88502e1d8 +Author: Tim Mooney <enchanter@users.sourceforge.net> +Date: Thu Nov 13 22:32:22 2008 +0100 + + Fix build on Solaris 10 + Sun Studio 12. + + Fixes bug 17496 + + configure.ac | 14 ++++++++++++++ + test/Makefile.am | 6 ++++-- + 2 files changed, 18 insertions(+), 2 deletions(-) + +commit 17b18be4fd25f2ca2b4ed7382d9fda50410c44f1 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Nov 12 20:40:57 2008 +1030 + + Ensure cairo font matrix is invertable + + Fixes bugs #18254 and #18429 + + poppler/CairoOutputDev.cc | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) + +commit e2257e6916cd1067d43db9ed45f944413c61ed64 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Nov 9 22:44:48 2008 +0100 + + Update copyrights of the last commits + + poppler/CairoFontEngine.cc | 1 + + poppler/CairoFontEngine.h | 1 + + poppler/Form.cc | 2 +- + poppler/Gfx.h | 1 + + poppler/OptionalContent.h | 1 + + qt4/src/poppler-optcontent.cc | 1 + + 6 files changed, 6 insertions(+), 1 deletion(-) + +commit 069f8ad9453e612e907b561aa50983c34400193d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Nov 9 20:36:06 2008 +0100 + + MakeItBuild + + glib/CMakeLists.txt | 1 + + glib/demo/CMakeLists.txt | 1 + + 2 files changed, 2 insertions(+) + +commit 04025c4f65bbb7e4330f6d17d917a035c0906f3d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Nov 9 17:03:20 2008 +0100 + + Fix a crash when initializing an Annot with a null catalog + + Forms crate a temp annot just to get the font size of the form field + passing a NULL catalog. + + poppler/Annot.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 471255c5a3850984997d91c7850759eb0c7e8a9c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Nov 8 20:58:57 2008 +0100 + + [glib-demo] Add Optional Content demo + + glib/demo/Makefile.am | 2 + + glib/demo/layers.c | 511 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + glib/demo/layers.h | 31 +++ + glib/demo/main.c | 4 +- + 4 files changed, 547 insertions(+), 1 deletion(-) + +commit 7363c25e1d83332932d9b4fe16d7fb4e364da628 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Oct 26 19:47:35 2008 +0100 + + [glib] Add Optional Content support + + glib/Makefile.am | 2 + + glib/poppler-document.cc | 377 + ++++++++++++++++++++++++++++++++++++++++++++++ + glib/poppler-document.h | 12 ++ + glib/poppler-layer.cc | 201 ++++++++++++++++++++++++ + glib/poppler-layer.h | 43 ++++++ + glib/poppler-private.h | 21 +++ + glib/poppler.h | 3 + + glib/test-poppler-glib.cc | 52 ++++++- + 8 files changed, 710 insertions(+), 1 deletion(-) + +commit c674566f458b54097f21aae0d4bf8637146565c5 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Oct 26 19:42:53 2008 +0100 + + Fix memory leaks in OptionalContent + + poppler/OptionalContent.cc | 13 +++---------- + poppler/OptionalContent.h | 10 ++++++---- + 2 files changed, 9 insertions(+), 14 deletions(-) + +commit 06ca313b8ecb8abb8dec3b418d118525b7bb0fdf +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Oct 26 19:11:45 2008 +0100 + + Check annotation optional content properties before drawing it + + poppler/Annot.cc | 20 ++++++++++++-------- + poppler/Annot.h | 4 ++-- + 2 files changed, 14 insertions(+), 10 deletions(-) + +commit a6d58927b048aa043cb6b6ed3ee9aeb213578924 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Nov 8 20:50:40 2008 +0100 + + Do not show hidden optional content + + Before any draw operation we first check whether we are inside an + optional marked content element that is currently hidden. + + poppler/Gfx.cc | 113 + ++++++++++++++++++++++++++++++++++++++++----------------- + poppler/Gfx.h | 7 +++- + 2 files changed, 84 insertions(+), 36 deletions(-) + +commit 5f168f991477e291290350a28f4a60a565e187b9 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Oct 20 17:56:11 2008 +0200 + + [glib] Show action titles when printing the index in test program + + glib/test-poppler-glib.cc | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) + +commit a906d12e16748d9a40c0db4043a576fd3d004341 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Nov 8 20:20:00 2008 +0100 + + Minor code cleanup and consistency issues + + poppler/OptionalContent.cc | 22 +++++++++++----------- + poppler/OptionalContent.h | 8 ++++---- + qt4/src/poppler-optcontent.cc | 6 +++--- + qt4/tests/check_optcontent.cpp | 8 ++++---- + 4 files changed, 22 insertions(+), 22 deletions(-) + +commit e73c2ce906b7e1f06d641f7e0733aad6336b4091 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Oct 19 12:44:13 2008 +0200 + + Delete the optContent object if it's invalid + + poppler/Catalog.cc | 4 ++++ + poppler/OptionalContent.cc | 3 +++ + poppler/OptionalContent.h | 5 +++++ + 3 files changed, 12 insertions(+) + +commit 2900e7e4c920d735d5a727e9e39f71df97bd7b93 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Nov 8 18:12:47 2008 +0100 + + A new cairo is needed + + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit aaaecd2e86769d3a99e21577448a193711985958 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 5 22:47:30 2008 +0100 + + Do not abort if indexHighA is 'invalid', move it to the closest + valid value and try with it + + For the bug 18374 it works and does not seem a security problem + + poppler/GfxState.cc | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +commit 82f4228a50efe6447c68f7f6d34a7805b7e4b75e +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 5 20:57:17 2008 +0100 + + Add myself here + + qt4/demos/viewer.cpp | 1 + + 1 file changed, 1 insertion(+) + +commit 8df7d83439f0e9ab200840f912f1c08bbf44bd6e +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 5 20:49:01 2008 +0100 + + [Qt4Demo] Fix leak + + qt4/demos/viewer.cpp | 1 + + 1 file changed, 1 insertion(+) + +commit d3c424e0362f53bda5c4e2e415823d78ace76253 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 5 20:14:17 2008 +0100 + + Rename i to j so that code is more clear by not shadowing the + function parameter + + poppler/Catalog.cc | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit 9d12de9b59de4336eabb423f7bf0363b6a35e2a8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 5 20:00:01 2008 +0100 + + Fix crash in case indices is NULL + + Putting more than one "logical line" per "real line" is evil, we + think if will group it, but does not + + poppler/UnicodeTypeTable.cc | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +commit fc61dad9daa15f83802ffa5c3cd9b59d80bb310b +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 5 19:52:00 2008 +0100 + + [Qt] Fix leak + + qt/poppler-link.cc | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit 981fb857b0afb1cda7836744dcf37906285512b4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 5 19:49:18 2008 +0100 + + [Qt] Fix memory leak + + qt/poppler-document.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit e925e92d5cbfc009c138ece117227a3b0894ead6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 5 19:44:40 2008 +0100 + + Do not leak uBuf in the error case + + poppler/CharCodeToUnicode.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 0741a402632ec5a8641ff11707142bf2731c1833 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Nov 1 22:27:48 2008 +1030 + + Restore the cairo Type3 font image prescaling funtionality + + poppler/CairoFontEngine.cc | 49 + +++++++++++++++++++++++++++------------------- + poppler/CairoFontEngine.h | 20 +++++++++++-------- + poppler/CairoOutputDev.cc | 2 +- + poppler/CairoOutputDev.h | 2 +- + 4 files changed, 43 insertions(+), 30 deletions(-) + +commit 91a7c3fdd44f30b0b50ed05a3313bbb1b5c86e71 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Nov 1 20:57:24 2008 +1030 + + Remove cairo font matrix y flip when inside a Type 3 char + + Not sure why this was previously required but it now produces + incorrect results. + + poppler/CairoOutputDev.cc | 5 ----- + 1 file changed, 5 deletions(-) + +commit 3bf4d7d75b455a9a0b5ee3a8c78b218e5af5185a +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Nov 1 20:50:07 2008 +1030 + + Transform the glyph advance by the font matrix + + poppler/CairoFontEngine.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 4aa32bad61d008a854fdc9e902d6834bb1687d7e +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Nov 1 20:49:04 2008 +1030 + + Use the font BBox, not the font matrix to set the Gfx BBox + + poppler/CairoFontEngine.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 987955440c7711f440c3d2b5cc8c05ec07228a77 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Nov 1 20:47:05 2008 +1030 + + Ensure both the font matrix and y-axis flip are in the matrix + + we use for transforming the glyph metrics. + + poppler/CairoFontEngine.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 5c051aa117477cba5d350adfc539acb4b5f2a56a +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Nov 1 01:59:07 2008 +1030 + + Require cairo 1.8.2 for user-font support + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit a3edfa30680864b95a5196c5619846de42980857 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Nov 1 01:57:32 2008 +1030 + + Implement Type 3 fonts in cairo backend using cairo user-fonts + + poppler/CairoFontEngine.cc | 174 + +++++++++++++++++++++++++++++++++++++++++++-- + poppler/CairoFontEngine.h | 18 +++++ + poppler/CairoOutputDev.cc | 9 ++- + poppler/CairoOutputDev.h | 4 +- + 4 files changed, 194 insertions(+), 11 deletions(-) + +commit feab1e982a2ee39bb372d593633a06b6a499822f +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Nov 1 01:21:39 2008 +1030 + + Add CairoOutputDev functions for getting Type 3 glyph metrics + + poppler/CairoOutputDev.cc | 10 ++++++++++ + poppler/CairoOutputDev.h | 7 +++++++ + 2 files changed, 17 insertions(+) + +commit a75efe208d899d4a23d5e2fcef200e4225721636 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Nov 1 00:26:40 2008 +1030 + + Make the catalog available to CairoFontEngine + + glib/poppler-document.cc | 3 ++- + poppler/CairoFontEngine.cc | 2 +- + poppler/CairoFontEngine.h | 3 ++- + poppler/CairoOutputDev.cc | 7 +++++-- + poppler/CairoOutputDev.h | 3 ++- + test/pdf-inspector.cc | 2 +- + 6 files changed, 13 insertions(+), 7 deletions(-) + +commit 941d3976c496b75a3c5a9d19b80044fc2b57bd98 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Oct 31 22:44:41 2008 +1030 + + Allow multiple instances of CairoOutputDev to be created + + for the same document that shares the same CairoFontEngine. + + poppler/CairoOutputDev.cc | 16 +++++++++++----- + poppler/CairoOutputDev.h | 4 +++- + 2 files changed, 14 insertions(+), 6 deletions(-) + +commit 94cff513d8589f51b243fcb078f82cb931bb6d35 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Oct 31 21:11:01 2008 +1030 + + Use correct return type in _ft_new_face + + poppler/CairoFontEngine.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0b5ee897a24ce1edfca19a3b843f9b7ee7026d07 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Oct 31 20:55:14 2008 +1030 + + Refactor CairoFont + + Create a CairoFreeType subclass and move the FreeType specific code + into it. + + poppler/CairoFontEngine.cc | 197 + +++++++++++++++++++++++++-------------------- + poppler/CairoFontEngine.h | 26 ++++-- + 2 files changed, 131 insertions(+), 92 deletions(-) + +commit a5865dae5b414de5f6dbda2a512101050c374e06 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Oct 28 10:30:59 2008 +0100 + + [glib] Add DISABLE_SINGLE_INCLUDES flags and fix glib-demo + + configure.ac | 4 ++++ + glib/Makefile.am | 3 ++- + glib/demo/Makefile.am | 3 ++- + glib/demo/annots.h | 2 +- + glib/demo/attachments.h | 2 +- + glib/demo/fonts.h | 2 +- + glib/demo/forms.h | 2 +- + glib/demo/images.h | 2 +- + glib/demo/info.h | 2 +- + glib/demo/links.h | 2 +- + glib/demo/outline.h | 2 +- + glib/demo/page.h | 2 +- + glib/demo/render.h | 2 +- + glib/demo/transitions.h | 2 +- + glib/demo/utils.h | 2 +- + 15 files changed, 20 insertions(+), 14 deletions(-) + +commit e07bfb54b77430e10e50c33151cf0afc9854006c +Author: Christian Persch <chpe@gnome.org> +Date: Tue Oct 28 10:29:51 2008 +0100 + + [glib] Fix build when compiling with GTK_DISABLE_SINGLE_INCLUDES + + glib/poppler-page.h | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit a84d272ffd2b593ac98148e71b83fba299c60fea +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Oct 28 10:01:00 2008 +0100 + + [glib] Add disable deprecated compile flags and fix compile warnings + + configure.ac | 6 ++++++ + glib/Makefile.am | 3 ++- + glib/demo/Makefile.am | 4 +++- + glib/demo/attachments.c | 4 ++-- + 4 files changed, 13 insertions(+), 4 deletions(-) + +commit 43f2b84a81625abee84c93cdced7fb92c99cd944 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Oct 21 23:00:55 2008 +0200 + + [Qt4] Small docu improvement + + qt4/src/poppler-qt4.h | 3 +++ + 1 file changed, 3 insertions(+) + +commit 00f9995b4960575cd1f392474c585f2140c8e587 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Oct 12 14:20:01 2008 +0200 + + Do not crash if there is not font + + See bug 18023 for more info + + poppler/TextOutputDev.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 084cc4335cfe2c0e66219eba4c1177ee7ff018c5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Oct 10 23:15:35 2008 +0200 + + obj4 should be the index 1 on the Array, not the 0, that's already + obj3 + + poppler/Form.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit d7442c90206d4b7a8ebc58f995647eb87ac35f42 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 9 22:53:00 2008 +0200 + + If Name is a Ref we want to get the String it references, not the Ref + + poppler/OptionalContent.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 93f8dd9e837557bbfc0f058a664c356e3d6e82c0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 9 21:28:27 2008 +0200 + + Poppler 0.10.0 + + CMakeLists.txt | 2 +- + NEWS | 16 ++++++++++++++++ + configure.ac | 2 +- + msvc/config.h | 6 +++--- + qt4/src/Doxyfile | 2 +- + 5 files changed, 22 insertions(+), 6 deletions(-) + +commit cdd9bf016de0d3f96b1d5e304c9d02f2bf71ff18 +Author: Mark Kaplan <mkaplan@finjan.com> +Date: Wed Oct 8 22:29:11 2008 +0200 + + Initialize properly OptionalContentGroup::m_name + + poppler/OptionalContent.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit c7b87f3b8cbbcca29a1974debc2233f621a2e33b +Author: Carlo Bramini <carlo.bramix@libero.it> +Date: Mon Oct 6 19:32:27 2008 +0200 + + Fix link on Mingw+Msys + + test/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e92255296511cae9cbbac8de800d8b26e5f681f1 +Author: Pino Toscano <pino@kde.org> +Date: Sun Oct 5 15:57:06 2008 +0200 + + [Qt4] when the PDF exporting fails, delete the file if it was + created by + the (failed) exporting + + qt4/src/poppler-pdf-converter.cc | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +commit 360f470b852e37d400949343763a18bf598820e8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 4 20:04:44 2008 +0200 + + Remove unused var + + poppler/Annot.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit df7317f1320513b4f66cb6618d753b82042671f5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 4 19:48:57 2008 +0200 + + free the object + + poppler/PDFDoc.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 9946d9af9dd5d5b96d5c777413a3e253dfd1f291 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 4 19:39:46 2008 +0200 + + If we try saving a document that was encrypted, we break everything, + so just fail early + + poppler/PDFDoc.cc | 7 +++++++ + 1 file changed, 7 insertions(+) + +commit 108959432af7714cb8ffe42d98d40c97f936a2e6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 4 19:39:24 2008 +0200 + + Correctly return wheter it was saved or not + + qt4/src/poppler-pdf-converter.cc | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +commit 4c6cb1c204d782e2ac2113b57f6d372b4716017d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 4 01:46:58 2008 +0200 + + Remove spurious // + + fofi/FoFiType1.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e8e7809ab4b115cbe67251da12989fc024912514 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 4 01:43:02 2008 +0200 + + There are files that have more than one encoding definition per line, + make them work + + Fixes bug 17018, while at it, i've added some comments and some + error() to make things a bit clearer + + fofi/FoFiType1.cc | 28 ++++++++++++++++++++++++---- + 1 file changed, 24 insertions(+), 4 deletions(-) + +commit 7604e025038fee24c2cb3001f2100d5d1e48efe1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Oct 4 00:35:46 2008 +0200 + + Fix Poppler::Link::linkArea for rotated pages + + we suck :-( Fixes kde bug 172105 + + qt4/src/poppler-link-extractor.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 450b21e4528a8e890d3dda37ecb0a68602f8efaa +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Oct 1 00:46:29 2008 +0200 + + I've changed these files this year too, update copyright + + goo/gmem.cc | 2 +- + goo/gmem.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 98310ca24841789cf53b10d34e271ceb4e054001 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 30 23:59:43 2008 +0200 + + Fix StitchingFunction(StitchingFunction *func) and + GfxAxialShading(GfxAxialShading *shading) + + Fixes bug 17852 + + poppler/Function.cc | 2 ++ + poppler/GfxState.cc | 2 +- + 2 files changed, 3 insertions(+), 1 deletion(-) + +commit d12f5f4395eb18f8d29182e24acddd3e2b5cfe88 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 30 23:20:26 2008 +0200 + + 0.9.3 + + CMakeLists.txt | 2 +- + NEWS | 17 +++++++++++++++++ + configure.ac | 2 +- + msvc/config.h | 6 +++--- + qt4/src/Doxyfile | 2 +- + 5 files changed, 23 insertions(+), 6 deletions(-) + +commit d61e464754521555a06ed0901955f49be4def29a +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 30 19:26:17 2008 +0200 + + Timothy also agreed, now Ed Catmur is the last one missing to answer + + utils/ImageOutputDev.cc | 3 +++ + utils/ImageOutputDev.h | 3 +++ + 2 files changed, 6 insertions(+) + +commit 3225f54fea7cbb6b25d7223268cdeccfdd823375 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 30 00:27:49 2008 +0200 + + And Marco said yes to GPLv2+ + + Only Timothy Lee and Ed Catmur left :-) + + poppler/Catalog.cc | 3 +++ + poppler/Outline.cc | 3 +++ + poppler/Outline.h | 3 +++ + splash/Splash.cc | 3 +++ + splash/Splash.h | 3 +++ + 5 files changed, 15 insertions(+) + +commit 268d803c9dd67b7f78f8dcdc3c7653c8b2c2d08f +Author: Warren Toomey <wkt@tuhs.org> +Date: Mon Sep 29 21:14:40 2008 +0200 + + Let HmtlOutputDev process images + + utils/HtmlOutputDev.h | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit a29984ab777c64a1cb286b667a6a91ad9b191f40 +Merge: f399afe 6865872 +Author: Pino Toscano <pino@kde.org> +Date: Sun Sep 28 23:39:08 2008 +0200 + + Merge branch 'master' of + ssh://pino@git.freedesktop.org/git/poppler/poppler + +commit f399afe6f6b9c250327d0e4c5b3f2839889d7095 +Author: Pino Toscano <pino@kde.org> +Date: Sun Sep 28 23:38:34 2008 +0200 + + [Qt4] various apidox improvements + + qt4/src/Mainpage.dox | 10 +--- + qt4/src/poppler-link.h | 92 +++++++++++++++++++++++++++++++++---- + qt4/src/poppler-qt4.h | 121 + +++++++++++++++++++++++++++++++++---------------- + 3 files changed, 168 insertions(+), 55 deletions(-) + +commit 68658721583b05ebacb1165ac36e91d49735bbd9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 28 19:29:06 2008 +0200 + + If tables is null, don't try to write to file as it'll crash, fixes + crash on 17811 when using cairooutputdev + + fofi/FoFiTrueType.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 3cb5b7fc5ae168ef58fd1905f61c1b9abe6cb86c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 28 19:25:53 2008 +0200 + + Introduce greallocn_checkoverflow and use it in FoFiTrueType::parse + + Fixes the other part of bug 17811 + + fofi/FoFiTrueType.cc | 4 ++-- + goo/gmem.cc | 21 +++++++++++++++++++++ + goo/gmem.h | 1 + + 3 files changed, 24 insertions(+), 2 deletions(-) + +commit aa7ef03af49f74ed558dcbab8ad4c594bb2b7d53 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 28 19:24:43 2008 +0200 + + If libjpeg tells us to abort, let's abort :D + + Fixes part of bug 17811 + + poppler/DCTStream.cc | 1 + + 1 file changed, 1 insertion(+) + +commit e2461c9aa4d74b5511621d7222979948e31541ad +Author: Pino Toscano <pino@kde.org> +Date: Sun Sep 28 18:07:25 2008 +0200 + + [Qt4] Activate the 'printing' flag by default in the PSConverter. + + qt4/src/poppler-ps-converter.cc | 2 +- + qt4/src/poppler-qt4.h | 2 ++ + 2 files changed, 3 insertions(+), 1 deletion(-) + +commit 957d7acb66635e9748c6bc7a31cdbbcbb8da9011 +Author: Carlo Bramini <carlo.bramix@libero.it> +Date: Sat Sep 27 17:23:20 2008 +0200 + + Misc mingw fixes + + configure.ac | 2 +- + glib/Makefile.am | 2 +- + glib/demo/info.cc | 1 + + m4/libjpeg.m4 | 2 +- + 4 files changed, 4 insertions(+), 3 deletions(-) + +commit b3828203c4e594754957033ea826e8e22164fd5b +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 26 23:08:14 2008 +0200 + + Carl agreed too, so CairoOutputDev.cc is done + + Only miss, Marco Pesenti Gritti, Timothy Lee and Ed Catmur + + poppler/CairoOutputDev.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit a197a07728d19abc2708979c95b4ef53e88fcb55 +Author: Carlo Bramini <carlo.bramix@libero.it> +Date: Fri Sep 26 18:42:05 2008 +0200 + + Compile where localtime_r is not available + + glib/demo/info.cc | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +commit 38884e1722ac7e15c62cece20035c5fb0020f4b3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 24 14:18:38 2008 +0200 + + Do what Jeff really want to do, mark the font as invalid if it matches + any of the known collections that Identity is not a good fallback + + Fixes pdf on KDE bug 171365 + + poppler/GfxFont.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0e080aaf44816e5d5b9008f3c2fb54868932f0ac +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 24 13:12:13 2008 +0200 + + Remove non-needed X includes + + Spotted by Carlo Bramini + + test/gtk-cairo-test.cc | 3 --- + test/pdf-inspector.cc | 3 --- + 2 files changed, 6 deletions(-) + +commit 6888b023fdb199d3c5fb705bd928aedf68eeffdb +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 23 23:28:04 2008 +0200 + + Only do the scale to 'm' size trick on non embedded fonts as it was + meant to be + + Fixes bug 17744 + + poppler/SplashOutputDev.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 539d29f4f3b24b98c9fc5f88d3477e427fbe409d +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 23 22:39:50 2008 +0200 + + 0.9.2 + + CMakeLists.txt | 2 +- + NEWS | 19 +++++++++++++++++++ + configure.ac | 2 +- + msvc/config.h | 6 +++--- + qt4/src/Doxyfile | 2 +- + 5 files changed, 25 insertions(+), 6 deletions(-) + +commit abd070a79d8345bda3853395a39e4e2882c4ff8a +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 22 20:23:11 2008 +0200 + + Check the types here too + + Benchmarking in release mode, both in "human feel" and callgrind + the benefit/lost is almost inexistant + + poppler/Object.h | 36 ++++++++++++++++++++++-------------- + 1 file changed, 22 insertions(+), 14 deletions(-) + +commit df47e4c441e4ec79b1bb40de7044c9501f243b76 +Author: Chris Wilson <chris@chris-wilson.co.uk> +Date: Tue Sep 16 12:56:04 2008 +0100 + + Check for duplicate open fonts. + + Before creating a new FT_Face for a font, check to see if there is a + duplicate amongst the list of open fonts, kept alive by either + Poppler's + or Cairo's font cache . + + A quick example of the benefit of this check is that it reduces the + RSS of + the Poppler converter in the Cairo test suite from over 900 MiB to + just 90 + MiB. + + configure.ac | 1 + + poppler/CairoFontEngine.cc | 214 + +++++++++++++++++++++++++++++++++++++++------ + 2 files changed, 190 insertions(+), 25 deletions(-) + +commit 41d1edddcf84ca23c0fc39c5f4f3a49e408a9f1a +Author: Kouhei Sutou <kou@cozmixng.org> +Date: Sun Sep 21 16:33:33 2008 +0200 + + [glib-demo] Fix a crash in forms demo + + glib/demo/forms.c | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +commit fe26075353226be9a02c8cf1a6a29586de15ce86 +Author: Pino Toscano <pino@kde.org> +Date: Sun Sep 21 12:03:21 2008 +0200 + + really use the key passed to it + + poppler/Form.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 8aa531cb478d6ae838a94f9f31e6a0bbd0dd957c +Author: Pino Toscano <pino@kde.org> +Date: Sun Sep 21 11:18:22 2008 +0200 + + Read the 'readOnly' attribute directly in the FormField constructor. + + poppler/Form.cc | 12 +++--------- + 1 file changed, 3 insertions(+), 9 deletions(-) + +commit b56f64d676bdabd4a3ebe0eb2237f4c202a3707d +Author: Pino Toscano <pino@kde.org> +Date: Sun Sep 21 00:53:54 2008 +0200 + + Handle streams as entries for the catalog JS name tree. + + poppler/Catalog.cc | 18 +++++++++++++----- + 1 file changed, 13 insertions(+), 5 deletions(-) + +commit 93386d67b3d7adbd87547e9742e4df1c10eadbc1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 20 16:20:03 2008 +0200 + + Compile with -pedantic + + poppler/Form.h | 4 ++-- + qt4/src/poppler-embeddedfile.cc | 4 ++-- + qt4/src/poppler-movie.cc | 3 ++- + qt4/src/poppler-sound.cc | 3 ++- + qt4/src/poppler-textbox.cc | 2 +- + 5 files changed, 9 insertions(+), 7 deletions(-) + +commit 6961fd8efe3db6ee7077dc2ed072498696dae31a +Author: Tomas Are Haavet <tomasare@gmail.com> +Date: Sat Sep 20 16:13:37 2008 +0200 + + Remove some warnings and errors when compiling with gcc and -pedantic + + fofi/FoFiTrueType.cc | 3 ++- + glib/poppler-annot.cc | 8 ++++---- + glib/poppler-attachment.cc | 2 +- + glib/poppler-document.cc | 6 +++--- + glib/poppler-form-field.cc | 2 +- + glib/poppler-page.cc | 2 +- + poppler/Annot.h | 5 +++-- + splash/SplashTypes.h | 3 ++- + 8 files changed, 17 insertions(+), 14 deletions(-) + +commit 4e9a04da358b1527a08102e601a52f07930532f2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 20 16:10:50 2008 +0200 + + Add mention of GPLv2 or later in poppler changes to all files except + Splash.cc and Splash.h, i've still no answer from Marco :-( + + splash/SplashBitmap.cc | 3 +++ + splash/SplashBitmap.h | 3 +++ + splash/SplashErrorCodes.h | 3 +++ + splash/SplashFTFont.cc | 3 +++ + splash/SplashFTFont.h | 3 +++ + splash/SplashFTFontEngine.cc | 3 +++ + splash/SplashFTFontEngine.h | 3 +++ + splash/SplashFTFontFile.cc | 3 +++ + splash/SplashFTFontFile.h | 3 +++ + splash/SplashFont.cc | 3 +++ + splash/SplashFont.h | 3 +++ + splash/SplashFontEngine.cc | 3 +++ + splash/SplashFontEngine.h | 3 +++ + splash/SplashFontFile.cc | 3 +++ + splash/SplashFontFile.h | 3 +++ + splash/SplashT1Font.cc | 3 +++ + splash/SplashT1Font.h | 3 +++ + splash/SplashT1FontEngine.cc | 3 +++ + splash/SplashT1FontFile.cc | 3 +++ + splash/SplashT1FontFile.h | 3 +++ + splash/SplashTypes.h | 3 +++ + splash/SplashXPathScanner.cc | 3 +++ + 22 files changed, 66 insertions(+) + +commit beb87362072d5b480cf6b2c02445ec17c119ff56 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 20 15:47:25 2008 +0200 + + Add Tomas' Copyright + + utils/HtmlFonts.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 8ccb1bb651b129875ef802356c4a229b2ce31973 +Author: Tomas Are Haavet <tomasare@gmail.com> +Date: Sat Sep 20 15:45:47 2008 +0200 + + Initialize pos the correct value to not have crashes + + utils/HtmlFonts.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 77bf8ec94e36fef7e120f1dc4bb1390be71cfb97 +Author: Tomas Are Haavet <tomasare@gmail.com> +Date: Sat Sep 20 14:17:06 2008 +0200 + + Fix memory leak + + utils/HtmlOutputDev.cc | 1 + + 1 file changed, 1 insertion(+) + +commit b22be54dc2205269974315ca748d835d0990d6da +Author: Tomas Are Haavet <tomasare@gmail.com> +Date: Sat Sep 20 14:16:26 2008 +0200 + + Fix mismatched free/delete + + utils/HtmlOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit ac16174da1d6f19445f78e7cd7c4a18cb9524dde +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 20 00:52:19 2008 +0200 + + make sure the image is setup before using it, otherwise some things + don't print correctly like PDF from bug 17645 + + poppler/PSOutputDev.cc | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit ffa4ffdf7fe83035c72addd8c4c8ee566621ba06 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 17 23:27:30 2008 +0200 + + 0.9.1 + + CMakeLists.txt | 2 +- + NEWS | 13 +++++++++++++ + configure.ac | 2 +- + msvc/config.h | 6 +++--- + qt4/src/Doxyfile | 2 +- + 5 files changed, 19 insertions(+), 6 deletions(-) + +commit f57cbe32bcde0808943b9be2456dd69fa5b6dd27 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 14 22:18:38 2008 +0200 + + If when looking for an object we get objSomeNumberAfter assume it + was an int of SomeNumberAfter + + Fixes bug 17568 and i don't see how it can break existing things + because it's already on an error path + + poppler/XRef.cc | 25 +++++++++++++++++++++++++ + 1 file changed, 25 insertions(+) + +commit 1a852064ff5a1a15bc315ddca472a0ad74292581 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Sep 13 12:11:41 2008 +0200 + + [glib-demo] Do not try to get info about remote destinations + + glib/demo/utils.c | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +commit 951cffeb2cbff4e179043033b5ac7f5eb764d6dc +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 12 12:05:53 2008 +0200 + + Make sure DecryptAESState::bufIdx is never bigger than 16, otherwise + we crash + + I am not sure this is the correct fix, but fixes crash on files of + bugs 13972, 16092 and 17523 and they seem to work ok + + poppler/Decrypt.cc | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 491109edbe827860e764b5fcb67456867923858d +Author: Haruyuki Kawabe <Haruyuki.Kawabe@unisys.co.jp> +Date: Wed Sep 10 23:00:32 2008 +0200 + + Generate the outline file at the same place the other files are + generated + + Fixes bug 17504 + + utils/HtmlOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 7dfc1e4c9348d537896bda7b0f2ae591afc72866 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 10 00:03:50 2008 +0200 + + we want to distribute this file too + + qt4/src/Makefile.am | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit ddb73e8dc1ccbddf3b170e12c7153ccaf716d7cc +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 9 23:47:33 2008 +0200 + + We want to distribute cmake/modules/FindLIBOPENJPEG.cmake too + + Makefile.am | 1 + + 1 file changed, 1 insertion(+) + +commit 646ccc2bb8563d411dc25bdbab53725ae08572ba +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 9 23:22:17 2008 +0200 + + m_doc->doc->getOptContentConfig() can be null, so check for it + + qt4/src/poppler-document.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit d7f0bce67101f37f8d3e69d7d701388bcdc7200f +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 9 23:18:49 2008 +0200 + + Qt4 frontend had timezone parsing that got lost when moving to the + common function, i suck + + glib/poppler-document.cc | 6 ++++-- + poppler/DateInfo.cc | 20 ++++++++++++++------ + poppler/DateInfo.h | 2 +- + qt/poppler-document.cc | 6 ++++-- + qt4/src/poppler-document.cc | 22 +++++++++++++++++++--- + utils/pdfinfo.cc | 6 ++++-- + utils/pdftohtml.cc | 6 ++++-- + 7 files changed, 50 insertions(+), 18 deletions(-) + +commit 0af8609e6c932de2d85168cc9147854ee84b3a1b +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 9 20:55:27 2008 +0200 + + i want this packaged too + + utils/Makefile.am | 2 ++ + 1 file changed, 2 insertions(+) + +commit dd0f4c1510382e17cf33d3fe163e384da1d6d289 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 9 20:48:04 2008 +0200 + + Fix includepath + + fofi/FoFiTrueType.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 16c0842c3e01608a72709af55cc5cb8b567efedf +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 9 20:36:18 2008 +0200 + + API changed, so increase soname + + glib/CMakeLists.txt | 2 +- + glib/Makefile.am | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 217c0d1f80a78713977a7bfbe680fce90f1c6b36 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 8 23:56:28 2008 +0200 + + change version to 0.9.0 + + Now only need to wait for Carlos and Iñigo's answer to a BIC change + in glib/ and we'll have 0.9.0 :-) + + CMakeLists.txt | 2 +- + configure.ac | 2 +- + msvc/config.h | 6 +++--- + qt4/src/Doxyfile | 2 +- + 4 files changed, 6 insertions(+), 6 deletions(-) + +commit e34022a8fcfb9fe211dd6b561377d855972b2087 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 8 23:36:04 2008 +0200 + + Increase soname for libpoppler, i'm almost sure we broke BC there + + CMakeLists.txt | 2 +- + poppler/Makefile.am | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit bc275049d6ef083daf71a043ccf23fd0634f5c4d +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 8 23:33:24 2008 +0200 + + soname 3.1.0 for qt4 libs, we are BC/SC but got new API + + qt4/src/CMakeLists.txt | 2 +- + qt4/src/Makefile.am | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 06743a25a73adc3fba95f7b4ad74a6dde1a54ead +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 8 23:23:06 2008 +0200 + + added news for 0.9.0 + + NEWS | 115 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 115 insertions(+) + +commit d35ca2ce5df12d40e295873e44b1f18ea40ba897 +Author: Pino Toscano <pino@kde.org> +Date: Sun Sep 7 01:13:33 2008 +0200 + + [Qt4] apidox improvements + + qt4/src/poppler-annotation.h | 70 + +++++++++++++++++++++++++++++++++++++++++--- + qt4/src/poppler-link.h | 12 +++++--- + qt4/src/poppler-qt4.h | 22 ++++++++++++-- + 3 files changed, 93 insertions(+), 11 deletions(-) + +commit 796d4c002d47c85716775d173eddfb2ae8866eaf +Author: Pino Toscano <pino@kde.org> +Date: Sat Sep 6 22:48:13 2008 +0200 + + no more need for including the qt3 paths + + qt4/demos/CMakeLists.txt | 1 - + qt4/src/CMakeLists.txt | 1 - + qt4/tests/CMakeLists.txt | 1 - + 3 files changed, 3 deletions(-) + +commit db7ee3b3ae0f42155f9245691e4bfdef98a8ed6f +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 6 23:16:05 2008 +0200 + + [Qt4] Fix docu + + qt4/src/poppler-qt4.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 3366059a25611f19ab592cda18c5efe0b9359771 +Author: Pino Toscano <pino@kde.org> +Date: Sat Sep 6 16:34:58 2008 +0200 + + [Qt4] add option flags for the PS converter + + - map the 'strictMargins' and 'forceRasterize' bool options as flags + - add a flag for setting the "printing" mode + + qt4/src/poppler-ps-converter.cc | 34 ++++++++++++++++++++++++++-------- + qt4/src/poppler-qt4.h | 26 ++++++++++++++++++++++++++ + 2 files changed, 52 insertions(+), 8 deletions(-) + +commit afa26d5c9ac9feb61aad30eb65dc00c9854d7f2e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 6 15:46:12 2008 +0200 + + we are printing so pass the print flag as true + + qt/poppler-document.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit f5d1eb5eaabaf3ab4bb87b8b4b901bbf30b20b29 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 6 15:43:32 2008 +0200 + + We are pringint here, so pass the printing flag as true + + Fixes KDE bug 170459, you'd wonder how many times i've made the + same mistake... + + qt4/src/poppler-ps-converter.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 58e828d732f06bae9133dd518d89fa4348f1cca8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 5 18:45:23 2008 +0200 + + Only like QtTest to the tests, not to the lib itself + + configure.ac | 13 +++++++++++-- + qt4/tests/Makefile.am | 22 +++++++++++----------- + 2 files changed, 22 insertions(+), 13 deletions(-) + +commit 49b3e4560f62a9a7db350d94d50e229f5e1208bf +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Sep 5 18:17:45 2008 +0200 + + Movie filename is not a string, but a File Specification + + Fixes a crash when filename is a dictionary + + poppler/Annot.cc | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +commit 996d2e176057e22acbc374cff7a712ce6fd92d93 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Sep 5 18:17:25 2008 +0200 + + Unify multiple File Specification parsers + + CMakeLists.txt | 2 + + poppler/FileSpec.cc | 146 + +++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/FileSpec.h | 24 ++++++++ + poppler/Link.cc | 104 +++++------------------------------ + poppler/Link.h | 4 -- + poppler/Makefile.am | 2 + + poppler/PSOutputDev.cc | 35 +----------- + poppler/PSOutputDev.h | 1 - + poppler/Sound.cc | 7 ++- + 9 files changed, 197 insertions(+), 128 deletions(-) + +commit 31f3eb2d6b43f7fbf4d978730d109b08b1563989 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 3 21:49:23 2008 +0200 + + Only set the state to true if the AS value is the same as parent's V + + Fixes bug 16121 and 15535 + + poppler/Form.cc | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +commit c75abac7ba07990ef54a46fa0d429eea580a71ef +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 2 19:16:55 2008 +0200 + + Kjartan was missing and just agreed + + utils/HtmlOutputDev.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 630aa133017d15ddc7bf96c79f43c5b60fa9749a +Merge: b2bc9b3 de82255 +Author: Pino Toscano <pino@kde.org> +Date: Tue Sep 2 01:25:55 2008 +0200 + + Merge branch 'master' of + ssh://pino@git.freedesktop.org/git/poppler/poppler + +commit b2bc9b3f59ef8e5fea18f0bc91b71fc9eb9a4157 +Author: Pino Toscano <pino@kde.org> +Date: Tue Sep 2 01:24:39 2008 +0200 + + [Qt4] small apidox improvements + + mostly the start of the \since marker addition, plus few other + documentation addition/improvements + + qt4/src/poppler-annotation.h | 9 +++++++ + qt4/src/poppler-form.h | 8 ++++++ + qt4/src/poppler-link.h | 14 ++++++++--- + qt4/src/poppler-optcontent.h | 11 +++++++++ + qt4/src/poppler-qt4.h | 59 + ++++++++++++++++++++++++++++++++++++++------ + 5 files changed, 90 insertions(+), 11 deletions(-) + +commit 6bc4881477ea15d70d420e57b5663052f2f9df76 +Author: Pino Toscano <pino@kde.org> +Date: Tue Sep 2 00:47:56 2008 +0200 + + expand the macros, extract poppler-optcontent.h + + enable the macro expansion and define POPPLER_QT4_EXPORT to be + empty, so + we don't have it in the apidox + + qt4/src/Doxyfile | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +commit de822554acdb1b2bc9e70c0668c43a10c0ec129a +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 1 23:50:37 2008 +0200 + + Initialize widget to null before calling initialize not after :-( + + poppler/Annot.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1a7b7199112d97e816a099cbc1a5672c83e64156 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 1 20:42:06 2008 +0200 + + Add my copyright + + poppler/Dict.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 1fef34782a003f46fceab0d3bed36212bbf32c4c +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 1 20:35:37 2008 +0200 + + Find reverse way in Dict + + This fixes Greg Stolze - Marriage Of Virtue & Viciousness.pdf + The issue with this pdf is that has a Dict with two entries with + the same key + The pdf spec says if that happens, results are undefined, but Acroread + uses the + second key while we were using the first, searching backwards we + use the second now too and the pdf works + + poppler/Dict.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit bb7996eaaad6a70404891bb2ff530160737ea3d7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 1 20:29:25 2008 +0200 + + Do not crash on documents with no pages + + qt4/tests/test-poppler-qt4.cpp | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 0c11d390e4b0e3765ae20968359c7562c9857db7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 1 20:13:33 2008 +0200 + + All poppler commiters to these files agreed to GPLv2+ + + Still missing to answer + Marco Pesenti Gritti + Catalog.cc + Outline.cc + Outline.h + + Kjartan Maraas + HtmlOutputDev.cc + + Timothy Lee + ImageOutputDev.h + ImageOutputDev.cc + + Carl Worth + CairoOutputDev.cc + + Ed Catmur + GfxFont.cc + GlobalParams.cc + TextOutputDev.cc + TextOutputDev.h + UnicodeTypeTable.cc + UnicodeTypeTable.h + + poppler/Annot.cc | 3 +++ + poppler/Annot.h | 3 +++ + poppler/Array.cc | 3 +++ + poppler/Array.h | 3 +++ + poppler/ArthurOutputDev.cc | 3 +++ + poppler/ArthurOutputDev.h | 3 +++ + poppler/CMap.cc | 3 +++ + poppler/CMap.h | 3 +++ + poppler/CairoFontEngine.cc | 3 +++ + poppler/CairoFontEngine.h | 3 +++ + poppler/CairoOutputDev.h | 3 +++ + poppler/Catalog.h | 3 +++ + poppler/CharCodeToUnicode.cc | 3 +++ + poppler/CharCodeToUnicode.h | 3 +++ + poppler/Decrypt.cc | 3 +++ + poppler/Decrypt.h | 3 +++ + poppler/Dict.cc | 3 +++ + poppler/Dict.h | 3 +++ + poppler/Error.cc | 3 +++ + poppler/Error.h | 3 +++ + poppler/Function.cc | 3 +++ + poppler/Gfx.cc | 3 +++ + poppler/Gfx.h | 3 +++ + poppler/GfxFont.h | 3 +++ + poppler/GfxState.cc | 3 +++ + poppler/GfxState.h | 3 +++ + poppler/GlobalParams.h | 3 +++ + poppler/JBIG2Stream.cc | 3 +++ + poppler/JPXStream.cc | 3 +++ + poppler/Lexer.cc | 3 +++ + poppler/Lexer.h | 3 +++ + poppler/Link.cc | 3 +++ + poppler/Link.h | 3 +++ + poppler/Object.cc | 3 +++ + poppler/Object.h | 3 +++ + poppler/OutputDev.cc | 3 +++ + poppler/OutputDev.h | 3 +++ + poppler/PDFDoc.cc | 3 +++ + poppler/PDFDoc.h | 3 +++ + poppler/PDFDocEncoding.cc | 3 +++ + poppler/PDFDocEncoding.h | 3 +++ + poppler/PSOutputDev.cc | 3 +++ + poppler/PSOutputDev.h | 3 +++ + poppler/PSTokenizer.cc | 3 +++ + poppler/PSTokenizer.h | 3 +++ + poppler/Page.cc | 3 +++ + poppler/Page.h | 3 +++ + poppler/Parser.cc | 3 +++ + poppler/Parser.h | 3 +++ + poppler/SplashOutputDev.cc | 3 +++ + poppler/SplashOutputDev.h | 3 +++ + poppler/Stream-CCITT.h | 3 +++ + poppler/Stream.cc | 3 +++ + poppler/Stream.h | 3 +++ + poppler/UTF8.h | 3 +++ + poppler/XRef.cc | 3 +++ + poppler/XRef.h | 3 +++ + utils/HtmlFonts.cc | 3 +++ + utils/HtmlLinks.cc | 3 +++ + utils/HtmlOutputDev.h | 3 +++ + utils/parseargs.c | 3 +++ + utils/parseargs.h | 3 +++ + utils/pdffonts.cc | 3 +++ + utils/pdfimages.cc | 3 +++ + utils/pdfinfo.cc | 3 +++ + utils/pdftohtml.cc | 3 +++ + utils/pdftoppm.cc | 3 +++ + utils/pdftops.cc | 3 +++ + utils/pdftotext.cc | 3 +++ + 69 files changed, 207 insertions(+) + +commit 8670bfed7900586725b30e3af67f6849acc6efda +Author: Vasile Gaburici <gaburici@cs.umd.edu> +Date: Sat Aug 30 12:47:13 2008 +0200 + + Fix extraction of images + + See bug 16999 for more info + + utils/ImageOutputDev.cc | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +commit 1c98f197664b1a2c06e2caf32116a8487f4054bf +Author: Vasile Gaburici <gaburici@cs.umd.edu> +Date: Sat Aug 30 12:44:02 2008 +0200 + + Read sMap reverse so CMap entries take precedence + + See bug 17321 for a more in depth explanation + + poppler/CharCodeToUnicode.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 8f1deb3f8000bdeb845a6c786a654bc7eb684f0a +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Aug 29 23:06:19 2008 +0200 + + Are we a lib or aren't we? Unify String to Date parsing so we all + behave the same way + + CMakeLists.txt | 2 ++ + glib/poppler-document.cc | 29 ++--------------- + poppler/DateInfo.cc | 62 + +++++++++++++++++++++++++++++++++++++ + poppler/DateInfo.h | 27 ++++++++++++++++ + poppler/Makefile.am | 2 ++ + qt/poppler-document.cc | 22 ++----------- + qt4/src/poppler-annotation-helper.h | 16 ++-------- + qt4/src/poppler-document.cc | 52 +++---------------------------- + utils/pdfinfo.cc | 16 ++-------- + utils/pdftohtml.cc | 9 ++---- + 10 files changed, 111 insertions(+), 126 deletions(-) + +commit c39f23dca98d3efe8d094c9a3e1bd460ba57d1ce +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Aug 29 20:50:57 2008 +0200 + + Add a readme for contributors with licensing and misc info + + README.contributors | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +commit 35a72590ffd3284e63601af79599e5fa025e567f +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 28 00:58:11 2008 +0200 + + Be more protective against huge font sizes in bogus documents like + the one in http://bugs.freedesktop.org/show_bug.cgi?id=17326 + + 10 MB in size is a font of 3200x3200, huge enough to be discarted + + poppler/SplashOutputDev.cc | 20 +++++++++++++++++++- + 1 file changed, 19 insertions(+), 1 deletion(-) + +commit 33727cf6773b12d736ba245fdd146559ce93102d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 24 20:36:13 2008 +0200 + + fix location of the comment + + fofi/FoFiType1.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit abe29b4fdb33f449649fdea5d7af2deeb702f0bb +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 24 20:24:35 2008 +0200 + + All changes made to fofi/ files under the poppler project are by + people that accepts to license the code under GPLv2+ + + fofi/FoFiBase.cc | 3 +++ + fofi/FoFiTrueType.cc | 3 +++ + fofi/FoFiTrueType.h | 3 +++ + fofi/FoFiType1.cc | 3 +++ + fofi/FoFiType1C.h | 3 +++ + 5 files changed, 15 insertions(+) + +commit 6346d7050a03935c71336c65d5f8f0fe2860d321 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 24 20:23:50 2008 +0200 + + All changes made to goo/ files under the poppler project are by + people that accepts to license the code under GPLv2+ + + goo/GooString.cc | 3 +++ + goo/GooString.h | 3 +++ + goo/gfile.cc | 3 +++ + goo/gfile.h | 3 +++ + goo/gmem.cc | 3 +++ + goo/gmem.h | 3 +++ + 6 files changed, 18 insertions(+) + +commit d6e1f1fb4e83527d3ece51d98fa20262713b7da1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 24 20:22:06 2008 +0200 + + .cc -> .h + + poppler/FontInfo.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 9f0ac70f7ad806cadce379d4fabb90eff697ad52 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 24 19:25:27 2008 +0200 + + Add missing addresses + + poppler/ABWOutputDev.cc | 4 ++-- + poppler/ABWOutputDev.h | 2 +- + poppler/FlateStream.cc | 2 +- + poppler/FlateStream.h | 2 +- + 4 files changed, 5 insertions(+), 5 deletions(-) + +commit 22f6af73961686895f207fe13022a21333455862 +Merge: 12a9e42 6d6913a +Author: Pino Toscano <pino@kde.org> +Date: Sun Aug 24 19:03:24 2008 +0200 + + Merge branch 'master' of + ssh://pino@git.freedesktop.org/git/poppler/poppler + +commit 12a9e427fb487165b1797f81d52d733c27bfa2e1 +Author: Pino Toscano <pino@kde.org> +Date: Sun Aug 24 18:57:52 2008 +0200 + + [Qt4] add showControl and playMode properties of MovieObject's + + qt4/src/poppler-movie.cc | 14 ++++++++++++++ + qt4/src/poppler-qt4.h | 20 ++++++++++++++++++++ + 2 files changed, 34 insertions(+) + +commit c444c652859b6e52160e5571e84f8eb1292d65f1 +Author: Pino Toscano <pino@kde.org> +Date: Sun Aug 24 18:47:58 2008 +0200 + + [Qt4] make the MovieObject ctor private, with only Page able to use it + + qt4/src/poppler-qt4.h | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +commit 6d6913a79779769ce0fe2f0b516a90a50e51b947 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 24 18:45:45 2008 +0200 + + fix Jeff's entry + + poppler/DCTStream.cc | 2 +- + poppler/DCTStream.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 25bd5967f9f550a32e20eea91cd00cbeff98249e +Author: Pino Toscano <pino@kde.org> +Date: Sun Aug 24 18:45:25 2008 +0200 + + [Qt4] initialize the MovieObject from an AnnotMovie + + the annotation has all the data we need, so just init from that + + qt4/src/poppler-movie.cc | 8 ++++---- + qt4/src/poppler-page.cc | 4 +--- + qt4/src/poppler-qt4.h | 4 ++-- + 3 files changed, 7 insertions(+), 9 deletions(-) + +commit 47f54ad4de111f62a5b8c25520ef6b2bca6026d2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 24 18:18:13 2008 +0200 + + Add more correct copyright statements on fofi, goo, poppler and + util directories to be more compliant with GPL that requires such + modification statements to be present. Meanwhile i did that, i did + qt and qt4 dirs too, glib is missing if someone wants to fix it, + but it's not crucial as it's not a fork of some other GPL software + + AUTHORS | 4 +++- + fofi/FoFiBase.cc | 11 +++++++++++ + fofi/FoFiTrueType.cc | 14 ++++++++++++++ + fofi/FoFiTrueType.h | 12 ++++++++++++ + fofi/FoFiType1.cc | 12 ++++++++++++ + fofi/FoFiType1C.h | 11 +++++++++++ + goo/GooString.cc | 13 +++++++++++++ + goo/GooString.h | 12 ++++++++++++ + goo/GooTimer.cc | 3 +++ + goo/GooTimer.h | 8 ++++++-- + goo/GooVector.h | 12 ++++++++++++ + goo/gfile.cc | 13 +++++++++++++ + goo/gfile.h | 11 +++++++++++ + goo/gmem.cc | 13 +++++++++++++ + goo/gmem.h | 13 +++++++++++++ + poppler/ABWOutputDev.cc | 3 ++- + poppler/ABWOutputDev.h | 2 +- + poppler/Annot.cc | 19 +++++++++++++++++++ + poppler/Annot.h | 17 +++++++++++++++++ + poppler/Array.cc | 11 +++++++++++ + poppler/Array.h | 11 +++++++++++ + poppler/ArthurOutputDev.cc | 14 +++++++++++++- + poppler/ArthurOutputDev.h | 13 ++++++++++++- + poppler/CMap.cc | 12 ++++++++++++ + poppler/CMap.h | 11 +++++++++++ + poppler/CairoFontEngine.cc | 17 +++++++++++++++++ + poppler/CairoFontEngine.h | 17 +++++++++++++++++ + poppler/CairoOutputDev.cc | 19 +++++++++++++++++++ + poppler/CairoOutputDev.h | 16 ++++++++++++++++ + poppler/Catalog.cc | 19 +++++++++++++++++++ + poppler/Catalog.h | 16 ++++++++++++++++ + poppler/CharCodeToUnicode.cc | 14 ++++++++++++++ + poppler/CharCodeToUnicode.h | 13 +++++++++++++ + poppler/DCTStream.cc | 5 ++++- + poppler/DCTStream.h | 6 +++++- + poppler/Decrypt.cc | 12 ++++++++++++ + poppler/Decrypt.h | 11 +++++++++++ + poppler/Dict.cc | 13 +++++++++++++ + poppler/Dict.h | 13 +++++++++++++ + poppler/Error.cc | 13 +++++++++++++ + poppler/Error.h | 13 +++++++++++++ + poppler/FlateStream.cc | 2 ++ + poppler/FlateStream.h | 2 ++ + poppler/FontInfo.cc | 22 ++++++++++++++++++++++ + poppler/FontInfo.h | 21 +++++++++++++++++++++ + poppler/Form.cc | 10 +++++++++- + poppler/Form.h | 6 +++++- + poppler/Function.cc | 12 ++++++++++++ + poppler/Gfx.cc | 23 +++++++++++++++++++++++ + poppler/Gfx.h | 13 +++++++++++++ + poppler/GfxFont.cc | 19 +++++++++++++++++++ + poppler/GfxFont.h | 16 ++++++++++++++++ + poppler/GfxState.cc | 14 ++++++++++++++ + poppler/GfxState.h | 13 +++++++++++++ + poppler/GlobalParams.cc | 19 +++++++++++++++++++ + poppler/GlobalParams.h | 15 +++++++++++++++ + poppler/JBIG2Stream.cc | 13 +++++++++++++ + poppler/JPXStream.cc | 11 +++++++++++ + poppler/Lexer.cc | 12 ++++++++++++ + poppler/Lexer.h | 12 ++++++++++++ + poppler/Link.cc | 14 ++++++++++++++ + poppler/Link.h | 12 ++++++++++++ + poppler/Movie.cc | 17 ++++++++++++++++- + poppler/Object.cc | 11 +++++++++++ + poppler/Object.h | 12 ++++++++++++ + poppler/OptionalContent.cc | 5 ++++- + poppler/Outline.cc | 11 +++++++++++ + poppler/Outline.h | 11 +++++++++++ + poppler/OutputDev.cc | 13 +++++++++++++ + poppler/OutputDev.h | 14 ++++++++++++++ + poppler/PDFDoc.cc | 15 +++++++++++++++ + poppler/PDFDoc.h | 15 +++++++++++++++ + poppler/PDFDocEncoding.cc | 13 ++++++++++++- + poppler/PDFDocEncoding.h | 11 +++++++++++ + poppler/PSOutputDev.cc | 15 +++++++++++++++ + poppler/PSOutputDev.h | 14 ++++++++++++++ + poppler/PSTokenizer.cc | 12 ++++++++++++ + poppler/PSTokenizer.h | 11 +++++++++++ + poppler/Page.cc | 20 ++++++++++++++++++++ + poppler/Page.h | 16 ++++++++++++++++ + poppler/PageLabelInfo.cc | 12 ++++++++++++ + poppler/PageLabelInfo.h | 12 ++++++++++++ + poppler/PageTransition.h | 18 ++++++++++++++++++ + poppler/Parser.cc | 12 ++++++++++++ + poppler/Parser.h | 11 +++++++++++ + poppler/SplashOutputDev.cc | 16 ++++++++++++++++ + poppler/SplashOutputDev.h | 11 +++++++++++ + poppler/Stream-CCITT.h | 11 +++++++++++ + poppler/Stream.cc | 14 ++++++++++++++ + poppler/Stream.h | 13 +++++++++++++ + poppler/TextOutputDev.cc | 18 ++++++++++++++++++ + poppler/TextOutputDev.h | 15 +++++++++++++++ + poppler/UTF8.h | 11 +++++++++++ + poppler/UnicodeTypeTable.cc | 13 +++++++++++++ + poppler/UnicodeTypeTable.h | 11 +++++++++++ + poppler/XRef.cc | 17 ++++++++++++++++- + poppler/XRef.h | 14 ++++++++++++++ + qt/poppler-document.cc | 3 +++ + qt/poppler-fontinfo.cc | 3 +-- + qt/poppler-page.cc | 7 ++++++- + qt/poppler-private.h | 4 ++++ + qt/poppler-qt.h | 5 ++++- + qt4/src/poppler-annotation-helper.h | 1 + + qt4/src/poppler-annotation.cc | 3 ++- + qt4/src/poppler-annotation.h | 4 +++- + qt4/src/poppler-document.cc | 4 +++- + qt4/src/poppler-embeddedfile.cc | 1 + + qt4/src/poppler-fontinfo.cc | 5 ++++- + qt4/src/poppler-form.cc | 2 +- + qt4/src/poppler-form.h | 2 +- + qt4/src/poppler-link-extractor-private.h | 2 +- + qt4/src/poppler-link-extractor.cc | 2 +- + qt4/src/poppler-link.cc | 3 ++- + qt4/src/poppler-link.h | 1 + + qt4/src/poppler-optcontent-private.h | 1 + + qt4/src/poppler-optcontent.cc | 1 + + qt4/src/poppler-optcontent.h | 1 + + qt4/src/poppler-page-private.h | 2 ++ + qt4/src/poppler-page.cc | 4 ++++ + qt4/src/poppler-private.h | 4 +++- + qt4/src/poppler-ps-converter.cc | 1 + + qt4/src/poppler-qt4.h | 5 ++++- + qt4/src/poppler-textbox.cc | 2 ++ + splash/Splash.cc | 12 ++++++++++++ + splash/Splash.h | 12 ++++++++++++ + splash/SplashBitmap.cc | 12 ++++++++++++ + splash/SplashBitmap.h | 11 +++++++++++ + splash/SplashErrorCodes.h | 11 +++++++++++ + splash/SplashFTFont.cc | 12 ++++++++++++ + splash/SplashFTFont.h | 11 +++++++++++ + splash/SplashFTFontEngine.cc | 11 +++++++++++ + splash/SplashFTFontEngine.h | 11 +++++++++++ + splash/SplashFTFontFile.cc | 11 +++++++++++ + splash/SplashFTFontFile.h | 11 +++++++++++ + splash/SplashFont.cc | 11 +++++++++++ + splash/SplashFont.h | 11 +++++++++++ + splash/SplashFontEngine.cc | 11 +++++++++++ + splash/SplashFontEngine.h | 11 +++++++++++ + splash/SplashFontFile.cc | 12 ++++++++++++ + splash/SplashFontFile.h | 12 ++++++++++++ + splash/SplashT1Font.cc | 11 +++++++++++ + splash/SplashT1Font.h | 11 +++++++++++ + splash/SplashT1FontEngine.cc | 11 +++++++++++ + splash/SplashT1FontFile.cc | 11 +++++++++++ + splash/SplashT1FontFile.h | 11 +++++++++++ + splash/SplashTypes.h | 11 +++++++++++ + splash/SplashXPathScanner.cc | 11 +++++++++++ + utils/HtmlFonts.cc | 24 ++++++++++++++++++++++++ + utils/HtmlFonts.h | 12 ++++++++++++ + utils/HtmlLinks.cc | 23 +++++++++++++++++++++++ + utils/HtmlLinks.h | 12 ++++++++++++ + utils/HtmlOutputDev.cc | 13 +++++++++++++ + utils/HtmlOutputDev.h | 11 +++++++++++ + utils/ImageOutputDev.cc | 13 +++++++++++++ + utils/ImageOutputDev.h | 12 ++++++++++++ + utils/parseargs.c | 13 +++++++++++++ + utils/parseargs.h | 11 +++++++++++ + utils/pdffonts.cc | 12 ++++++++++++ + utils/pdfimages.cc | 11 +++++++++++ + utils/pdfinfo.cc | 12 ++++++++++++ + utils/pdftoabw.cc | 26 +++++++++++++++++++------- + utils/pdftohtml.cc | 11 +++++++++++ + utils/pdftoppm.cc | 11 +++++++++++ + utils/pdftops.cc | 12 ++++++++++++ + utils/pdftotext.cc | 12 ++++++++++++ + 165 files changed, 1795 insertions(+), 37 deletions(-) + +commit 0dfbb8996ee91aa044eb2bdf2859ef64005116f8 +Author: Loïc Minier <lool@dooz.org> +Date: Wed Aug 20 22:10:07 2008 +0200 + + Fixes escaping of hyphens in man pages + + utils/pdfinfo.1 | 2 +- + utils/pdftops.1 | 16 ++++++++-------- + 2 files changed, 9 insertions(+), 9 deletions(-) + +commit 6cfa0e598a81460e5d0a7d60d8584366d2a70165 +Author: Loïc Minier <lool@dooz.org> +Date: Wed Aug 20 19:57:42 2008 +0200 + + Fix synopsis of pdftops in man page to clarify that a PDF file is + required in all cases + + utils/pdftops.1 | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 48a73cc709a8bed9d2d0f9cbd2a9d2b6c0dad05b +Author: Pino Toscano <pino@kde.org> +Date: Sat Aug 23 19:26:01 2008 +0200 + + [Qt4] convert the title of movie annotations + + qt4/src/poppler-page.cc | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 419ec15ac825f2e0052b411462f00ac57fed030e +Author: Pino Toscano <pino@kde.org> +Date: Sat Aug 23 19:25:04 2008 +0200 + + [Qt4] get/set the title for movie annotations + + qt4/src/poppler-annotation.cc | 13 +++++++++++++ + qt4/src/poppler-annotation.h | 3 +++ + 2 files changed, 16 insertions(+) + +commit 63bcaf113fcb5a4a9e5c120df2c3dafb2977c90a +Author: Pino Toscano <pino@kde.org> +Date: Sat Aug 23 01:58:30 2008 +0200 + + [Qt4] convert the movie annotation from the core type to the Qt4 one + + qt4/src/poppler-page.cc | 18 +++++++++++++++--- + 1 file changed, 15 insertions(+), 3 deletions(-) + +commit 5cc490de74af12726bdeb9b5a6a0f0d1d79383b5 +Author: Pino Toscano <pino@kde.org> +Date: Sat Aug 23 01:55:41 2008 +0200 + + [Qt4] first version of a MovieAnnotation + + right mow it just holds the movie object + + qt4/src/poppler-annotation.cc | 74 + +++++++++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-annotation.h | 26 ++++++++++++++- + 2 files changed, 99 insertions(+), 1 deletion(-) + +commit 3d5c2e22d790d7c139e1cd28aebb21cfe76b8b6b +Author: Pino Toscano <pino@kde.org> +Date: Sat Aug 23 01:54:30 2008 +0200 + + compile the new poppler-movie.cc + + qt4/src/CMakeLists.txt | 1 + + qt4/src/Makefile.am | 1 + + 2 files changed, 2 insertions(+) + +commit 599698a9b133999f1f0bb0548489111e9d7b6f05 +Author: Pino Toscano <pino@kde.org> +Date: Sat Aug 23 01:52:58 2008 +0200 + + [Qt4] first version of a MovieObject object for movies + + slightly differs from the version in core + + qt4/src/poppler-movie.cc | 73 + ++++++++++++++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-qt4.h | 34 ++++++++++++++++++++++ + 2 files changed, 107 insertions(+) + +commit 820f15009845870701e1f4e7f4fc4fb93312ab3e +Author: Pino Toscano <pino@kde.org> +Date: Sat Aug 23 01:45:07 2008 +0200 + + fix Movie::copy() + + the default copy ctor already does the vertbatim copies, so no need to + do them on our own; what needs to be done is checking whether + an object + is valid before either doing a "smart copy" or "postprocessing" it + + poppler/Movie.cc | 14 ++++++++------ + 1 file changed, 8 insertions(+), 6 deletions(-) + +commit c3a006ae35250e9a5638c2ce713b7470380751c7 +Author: Pino Toscano <pino@kde.org> +Date: Sat Aug 23 01:04:34 2008 +0200 + + compile attachments.c in the demo with cmake as well + + glib/demo/CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit b5a7987a50b3d28fbfa219e2cef85b9e53aaf079 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Aug 21 20:40:18 2008 +0200 + + [glib-demo] Fix attachments demo with documents that don't contain + attachments + + glib/demo/attachments.c | 27 ++++++++++++++++++++------- + 1 file changed, 20 insertions(+), 7 deletions(-) + +commit a2b0aefedbdb20ce0ef8398a700202021fcf00db +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Aug 21 20:14:50 2008 +0200 + + [glib-demo] Fix typo + + glib/demo/attachments.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 9e563d6d877624b1caf82ac30c5ae30a1eb48f21 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Aug 21 20:12:33 2008 +0200 + + [glib-demo] Add checksum validation to attachments demo + + glib/demo/attachments.c | 101 + ++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 101 insertions(+) + +commit e233325e6f13d8b232bf68a2812fe755e7fccd4d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Aug 21 19:03:32 2008 +0200 + + [glib-demo] Add demo for attachments + + glib/demo/Makefile.am | 2 + + glib/demo/attachments.c | 242 + ++++++++++++++++++++++++++++++++++++++++++++++++ + glib/demo/attachments.h | 31 +++++++ + glib/demo/main.c | 4 +- + glib/demo/utils.c | 23 +++++ + glib/demo/utils.h | 1 + + 6 files changed, 302 insertions(+), 1 deletion(-) + +commit 0e2efa0fce5bf059ce85d3e3bec2293b405ec3c9 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Aug 21 19:02:24 2008 +0200 + + [glib] Make sure name and descripction are valid utf8 strings + + glib/poppler-attachment.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 15a73704ab6b009ca5e07c08f0b12d970adc387d +Author: Chris Wilson <chris@chris-wilson.co.uk> +Date: Tue Aug 19 09:18:03 2008 +0100 + + Memleak and invalid free. + + CairoOutputDev::setSoftMask() fails to free the cairo_t and mask + it uses + to draw the opaque soft mask and attempts to destroy a reference to a + surface it does not own (this bug was masked by the fact that + a reference + was still being held by the unfreed cairo_t). + + poppler/CairoOutputDev.cc | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +commit d3110e392097db54e9ee59300213e490dee39126 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 19 19:19:09 2008 +0200 + + Fix include so it can be used in the unsupported way of installing + internal poppler/ headers + + Notified by Caolan McNamara <caolanm@redhat.com> + + poppler/PreScanOutputDev.h | 2 +- + poppler/SecurityHandler.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 303249e5548bfbf6823e97850e498970d802b4a0 +Author: Albert Astals Cid <tsdgeos@samsung.localdomain> +Date: Fri Aug 15 01:52:52 2008 +0200 + + Revert 123a87aff2e35b10efe6a1d715585b427e4a9afa it creates problems + with some pdf files + + poppler/Gfx.cc | 14 ++------------ + poppler/Gfx.h | 3 --- + 2 files changed, 2 insertions(+), 15 deletions(-) + +commit 27ddf3c5e839358c8553d41743faa8ee304767bf +Author: Pino Toscano <pino@kde.org> +Date: Wed Aug 13 13:55:57 2008 +0200 + + [Qt4] make sure to use the correct page width/height for form + widgets coordinates + + qt4/src/poppler-form.cc | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +commit 2e7b0eb4af8cf5938833e5659d01b77096e7b7f7 +Author: Pino Toscano <pino@kde.org> +Date: Tue Aug 12 13:49:52 2008 +0200 + + [Qt4] add a method to get the activation action of a FormField + + qt4/src/poppler-form.cc | 19 +++++++++++++++++++ + qt4/src/poppler-form.h | 8 ++++++++ + 2 files changed, 27 insertions(+) + +commit f9e679adbd6830da26eb9909bcb16e3bdf0da6b4 +Author: Pino Toscano <pino@kde.org> +Date: Tue Aug 12 13:47:15 2008 +0200 + + create a static version of PageData::convertLinkActionToLink() + + qt4/src/poppler-page-private.h | 2 ++ + qt4/src/poppler-page.cc | 5 +++++ + 2 files changed, 7 insertions(+) + +commit a6ecc864ea3e94d7232cff6a2e8f49919d8f24ff +Author: Albert Astals Cid <tsdgeos@samsung.localdomain> +Date: Tue Aug 12 01:23:21 2008 +0200 + + initialize widget, fixes crash on EC2006.pdf + + poppler/Annot.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 123a87aff2e35b10efe6a1d715585b427e4a9afa +Author: Albert Astals Cid <tsdgeos@samsung.localdomain> +Date: Tue Aug 12 00:37:09 2008 +0200 + + Cache the last created GfxResource, very useful because some pdf + created by pstopdf push and pop the same GfxResource all the time + + This brings us a speedup of 16 times (from 11 seconds to about 600 + msec) in kde bug 168663 + + poppler/Gfx.cc | 14 ++++++++++++-- + poppler/Gfx.h | 3 +++ + 2 files changed, 15 insertions(+), 2 deletions(-) + +commit 5ad1a12183f4b8e328f32386a74b5616e7e59070 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 4 20:34:42 2008 +0200 + + Be less strict when parsing TTF tables + + With this change and freetype from CVS i can render Bug 16940 using + the splash renderer + + fofi/FoFiTrueType.cc | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit d322720428fa416b7d5f23acc72d1d4b4f74d041 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 4 20:16:50 2008 +0200 + + Report an error when FoFiTrueType::load or FoFiTrueType::make fail + + poppler/SplashOutputDev.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 901ebc84ff7c0872c3f9f5e6eaf418ba6400fa10 +Author: Pino Toscano <pino@kde.org> +Date: Sun Aug 3 10:54:09 2008 +0200 + + [Qt4] Make the paper color setting working as it should. + + A BGR colorspace means that colors should be set as blue,green,red, + and + not red,green,blue. + + qt4/src/poppler-private.h | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit 66b34c78943be598778a3ef438b0cefac668c6a2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Aug 2 13:54:34 2008 +0200 + + This should not be here, breaks jpeg rendering when not using libjpeg + + That was included erroneously when the file writing code was added + + poppler/Stream.cc | 1 - + 1 file changed, 1 deletion(-) + +commit fd8d71ea8b12393201ece9c09372fd69c7573025 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Aug 1 23:47:51 2008 +0200 + + These defines are unneeded too + + msvc/poppler/poppler-config.h | 30 ------------------------------ + poppler-config.h.cmake | 30 ------------------------------ + poppler/poppler-config.h.in | 30 ------------------------------ + 3 files changed, 90 deletions(-) + +commit 391b5d5cdd9f63fe90229f88cdad628fb63c0206 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Aug 1 23:36:09 2008 +0200 + + Get rid of more defines, say our version on command line tools, + also say our copyright + + Did not modify PSOutputDev.cc output as PS is too fragile + + msvc/poppler/poppler-config.h | 9 +-------- + poppler-config.h.cmake | 9 +-------- + poppler/PSOutputDev.cc | 2 +- + poppler/poppler-config.h.in | 9 +-------- + utils/pdffonts.cc | 3 ++- + utils/pdfimages.cc | 3 ++- + utils/pdfinfo.cc | 3 ++- + utils/pdftohtml.cc | 3 ++- + utils/pdftoppm.cc | 3 ++- + utils/pdftops.cc | 3 ++- + utils/pdftotext.cc | 3 ++- + 11 files changed, 18 insertions(+), 32 deletions(-) + +commit d14fb1513be045363f7edec21cee04fd4937ede2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Aug 1 23:14:28 2008 +0200 + + Add GooList *getEncodingNames(); + + Forgot to commit this earlier :-( + + poppler/GlobalParams.cc | 19 +++++++++++++++++++ + poppler/GlobalParams.h | 2 ++ + 2 files changed, 21 insertions(+) + +commit 9fd34443d765ccd61864d18bceadc049d905b957 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Aug 1 23:09:39 2008 +0200 + + remove defines we don't use at all + + msvc/poppler/poppler-config.h | 4 ---- + poppler-config.h.cmake | 4 ---- + poppler/poppler-config.h.in | 4 ---- + 3 files changed, 12 deletions(-) + +commit 0f13013dc3079915572b6b002dac8d01d2dbde04 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Aug 1 23:06:50 2008 +0200 + + xpdfrc has been dead for a while + + msvc/poppler/poppler-config.h | 25 ------------------------- + poppler-config.h.cmake | 25 ------------------------- + poppler/poppler-config.h.in | 25 ------------------------- + 3 files changed, 75 deletions(-) + +commit 96392667d1331d2f8750f27c116e34bbf9282dca +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Aug 1 22:20:55 2008 +0200 + + Provide a default constructor for FontInfo so you can use it as + metatype for qvariant + + qt4/src/poppler-fontinfo.cc | 5 +++++ + qt4/src/poppler-private.h | 7 +++++++ + qt4/src/poppler-qt4.h | 5 +++++ + 3 files changed, 17 insertions(+) + +commit 9fd1077e63d97a316380b8df4821bf4c9434fb52 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Aug 1 17:47:51 2008 +0200 + + Build with cmake too + + utils/CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit d8d6a3f46620d45c279b7ca1a4a2fa3a36285cde +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Aug 1 17:44:07 2008 +0200 + + Improve manpages and add -listenc to pdfinfo and pdftotext in the way + + Our manpages listed things like xpdfrc and -cfg options we don't + support at all. + Also some options were missing from the man pages + Finally there was the -enc option you completely had to guess which + string to pass, + so i've added the -listenc option to get the user the list of + encodings he can use + + utils/Makefile.am | 2 ++ + utils/pdffonts.1 | 18 ------------------ + utils/pdfimages.1 | 14 -------------- + utils/pdfinfo.1 | 28 ++++------------------------ + utils/pdfinfo.cc | 16 ++++++++++++++-- + utils/pdftoppm.1 | 42 +++++++++++++++++++++--------------------- + utils/pdftops.1 | 41 +++-------------------------------------- + utils/pdftotext.1 | 32 ++++---------------------------- + utils/pdftotext.cc | 16 ++++++++++++++-- + utils/printencodings.cc | 34 ++++++++++++++++++++++++++++++++++ + utils/printencodings.h | 24 ++++++++++++++++++++++++ + 11 files changed, 120 insertions(+), 147 deletions(-) + +commit f5b0ca794b0879e3d239bf1d6138b15ead27d9ca +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Jul 29 20:18:33 2008 +0930 + + Fix ActualText string length check in TextOutputDev.cc + + poppler/TextOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 21bbdc9d663995336900f1ce97cf294f04464e01 +Author: Boris Toloknov <tlknv@yandex.ru> +Date: Mon Jul 28 21:02:07 2008 +0200 + + make xml output valid xml + + utils/HtmlLinks.cc | 33 ++++++++++++++++++-- + utils/HtmlOutputDev.cc | 85 + ++++++++++++++++++++++++++++++++------------------ + 2 files changed, 85 insertions(+), 33 deletions(-) + +commit dccfc4c2910b47a77cd7b6019d9365f1684ffd0c +Author: Boris Toloknov <tlknv@yandex.ru> +Date: Mon Jul 28 20:58:13 2008 +0200 + + Limit ascent and descent are to reasonable values. + + See bug 16592 to cases where this helps + + utils/HtmlOutputDev.cc | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +commit 0fd5a3db1ddad447d44b64eff9abfb077a7853a0 +Author: Boris Toloknov <tlknv@yandex.ru> +Date: Mon Jul 28 20:52:19 2008 +0200 + + Make html output to keep all the spaces with   + + utils/HtmlFonts.cc | 2 ++ + utils/HtmlOutputDev.cc | 2 +- + 2 files changed, 3 insertions(+), 1 deletion(-) + +commit 650c73fa0f570f699d907e33060fb23290940b42 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 28 20:44:13 2008 +0200 + + findDest crashes on null goostrings so rework the ifs a bit + + utils/HtmlOutputDev.cc | 16 +++++++++------- + 1 file changed, 9 insertions(+), 7 deletions(-) + +commit adee9c0e9e8b2de20309b3ae6eb8e6d6ed05cf85 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jul 26 00:04:03 2008 +0200 + + We are not storing the ctu, so decref and leak-- :-) + + poppler/Annot.cc | 1 + + 1 file changed, 1 insertion(+) + +commit e7b3e3ae3080bd6f239f7d96761729ad30b075ae +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 25 23:52:28 2008 +0200 + + Fix leak + + qt4/src/poppler-form.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 006b974d4faae53e6bd51a4281dd923ab1c2d4e8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 25 23:15:11 2008 +0200 + + Fix memory leak + + poppler/Annot.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 3a549d75acceedfa25dcf79074d0cdfb643c746e +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 25 23:08:21 2008 +0200 + + Free the previous modified object in case it exists + + poppler/XRef.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 040d244b97a554342061c777a286e99dbb9acabd +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 25 21:31:55 2008 +0200 + + Need this or otherwise it crashes on complete overwrite + + poppler/PDFDoc.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 11ebceeef938a7e6fa9b5437e65b5b4b822f3018 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 25 21:30:24 2008 +0200 + + Fix my last fix about saving, i think this is the correct one + + - One incremental update only write the modified entries xref, + not all + - Update gen to 0 when resizing entries + - On XRef::add correctly initialize all newly allocated entries + + poppler/PDFDoc.cc | 4 ++-- + poppler/XRef.cc | 57 + ++++++++++++++++++++++++++++++++++++++++++++----------- + poppler/XRef.h | 2 +- + 3 files changed, 49 insertions(+), 14 deletions(-) + +commit 03d445f485f90972ab1c05d79b2999b763ab7377 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 25 20:16:54 2008 +0200 + + Fix XRef::writeToFile after my change + + poppler/XRef.cc | 10 +++------- + 1 file changed, 3 insertions(+), 7 deletions(-) + +commit 136fa97576f2df0d7a7563b34651ca222927ea57 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 25 20:12:51 2008 +0200 + + Fix XRef::add and XRef::addIndirectObject, also remove num from + XRefEntry + + Previous code was under some incorrect assumptions: + * our XRef does not maintain the free link list so if you want to + find a free entry you have to go though all of them + * our XRefEntry does not need a num because the index itself is + the num + + Conflicts: + + poppler/XRef.cc + + poppler/XRef.cc | 70 + +++++++++++++++++++++------------------------------------ + poppler/XRef.h | 1 - + 2 files changed, 25 insertions(+), 46 deletions(-) + +commit 55572b77da95c47393b78f3aff804ea9c5ae17e5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jul 22 22:50:00 2008 +0200 + + Really do what the comment says and also init changeLeft, changeTop + and changeZoom + + poppler/Link.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 8dc7afaeea08183de331ecfd41ce1971e7772fd0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jul 22 21:05:03 2008 +0200 + + Some documents have loops in XObject dictionaries, make sure we + don't get in an infinite loop while traversing them + + Fixes infinite loop on http://bugs.kde.org/show_bug.cgi?id=166145 + + poppler/FontInfo.cc | 44 ++++++++++++++++++++++++++++++++++++-------- + poppler/FontInfo.h | 4 ++++ + 2 files changed, 40 insertions(+), 8 deletions(-) + +commit 9fb17c952dcff798e45280eeb9c718680147e766 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jul 20 13:47:11 2008 +0200 + + Fix condition, we want thumb to be a Stream, not to be non null + + Fixes bug 16579 + + glib/poppler-page.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 3696025977fd345b12767f75a2de6ed7e9467365 +Author: Pino Toscano <pino@kde.org> +Date: Fri Jul 18 23:32:25 2008 +0200 + + initialize pageWidgets, otherwise it can be a rubbish pointer + is Annots + is not a valid object + + poppler/Page.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 0189ff8b86de18486f7397076f7a0fbf133a1a33 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jul 1 20:16:50 2008 +0200 + + Fix condition, we want fetched_thumb to be a Stream, not to be + non null + + Fixes bug 16579 + + poppler/Page.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5bd77dcdd5220d63934f4b3e78d85a936947a53d +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jul 1 00:49:01 2008 +0200 + + forgot about we use autofoo too + + qt4/tests/Makefile.am | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 5ed2503003d973b5461594af15485af49591451d +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jul 1 00:43:26 2008 +0200 + + unittesting about ActualText + + qt4/tests/CMakeLists.txt | 1 + + qt4/tests/check_actualtext.cpp | 33 +++++++++++++++++++++++++++++++++ + 2 files changed, 34 insertions(+) + +commit f3bb2eb556f5248242f6db85052ef045fcb697c6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jul 1 00:41:35 2008 +0200 + + Unbreak ActualText extraction + + poppler/Gfx.cc | 10 +--------- + 1 file changed, 1 insertion(+), 9 deletions(-) + +commit 9e9543b105b39f8b0048c00fc94741e43ad615e9 +Author: Pino Toscano <pino@kde.org> +Date: Thu Jun 26 20:19:06 2008 +0200 + + use FindPackageHandleStandardArgs + + cmake/modules/FindLIBOPENJPEG.cmake | 11 ++--------- + 1 file changed, 2 insertions(+), 9 deletions(-) + +commit fec41ceddebe194f139bcc5b2f3fa74e7d1ae502 +Author: Pino Toscano <pino@kde.org> +Date: Thu Jun 26 20:18:27 2008 +0200 + + need to use LIBOPENJPEG_FOUND, as it really represents whether + libopenjpeg was found or not + + CMakeLists.txt | 18 +++++++++--------- + 1 file changed, 9 insertions(+), 9 deletions(-) + +commit 5498d93e59a0b79e5add3dc6181d5e98ba689217 +Author: Michael Vrable <mvrable@cs.ucsd.edu> +Date: Fri Jun 20 21:42:34 2008 -0700 + + Use a single global FT_Library in CairoOutputDev + + Cairo may internally keep references to the FreeType fonts loaded in + CairoFontEngine even after poppler is done with them. Commit + 42db4890e829 + ("Do not call FT_Done_Face on a live cairo_font_face_t") introduced + a fix + for one use-after-free bug, by delaying deleting an FT_Face objects + until + cairo is done with it. + + That fix doesn't correct all the bugs. An FT_Library object is + created for + each CairoOutputDev object, and deleted when the CairoOutputDev + goes away. + But the FT_Library object should not be deleted while fonts loaded + using it + are still in use. And cairo can keep references to fonts around + more or + less indefinitely. + + To more fully fix the problem, we can either: + 1. Keep a count of not-yet-deleted fonts associated with each + FT_Library, + and wait to call FT_Done_FreeType until it drops to zero. + 2. Never call FT_Done_FreeType. + + The second option is the simplest. To avoid leaking memory FT_Library + objects, use a single global FT_Library instead of a + per-CairoOutputDev + copy. + + poppler/CairoOutputDev.cc | 18 +++++++++++++++--- + poppler/CairoOutputDev.h | 4 +++- + 2 files changed, 18 insertions(+), 4 deletions(-) + +commit c75632d62a052d3c3739b96f5586f97c68baf25b +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 24 02:31:43 2008 +0200 + + Open in WriteOnly mode, fixes the fact that when writing to an + existing file, the contents beyond what we wrote were still there + + qt4/src/poppler-base-converter.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 9810fdfc54aac80aa99561a9d820d11b062e4637 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 24 02:12:21 2008 +0200 + + the entry is not updated here either, fix uninitialized variable use + + poppler/XRef.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 2da15db4751d3cb93d40b48e348dbc51f6e7a29f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jun 20 11:39:08 2008 +0200 + + Do not create an OCGs object if there isn't an OCProperties dictionary + in the Catalog + + poppler/Catalog.cc | 5 +++-- + poppler/Gfx.cc | 12 +++++++++++- + poppler/OptionalContent.cc | 25 +++++-------------------- + 3 files changed, 19 insertions(+), 23 deletions(-) + +commit d6fb5dcb7b7596961800d9744d17b6adb8d9a2ad +Author: Michael Vrable <mvrable@cs.ucsd.edu> +Date: Wed Jun 18 11:24:05 2008 -0700 + + Fix a crash in the cairo backend with Type 3 glyphs + + Commit 86b7e8a3bee7 ("Ensure cairo renders Type 3 glyphs with only + the fill + color") introduced a bug into the Cairo backend, causing evince + to crash + with the message + evince: cairo-pattern.c:679: cairo_pattern_destroy: Assertion + `((*&(&pattern->ref_count)->ref_count) > 0)' failed. + Fix this by updating reference counts to the fill and stroke + patterns when + modifying them in beginType3Char. + + Simplify the code as well by not saving the old stroke pattern before + overriding it; this is already done since beginType3Char/endType3Char + is + wrapped by calls to saveState/restoreState in Gfx::doShowText. + + poppler/CairoOutputDev.cc | 4 ++-- + poppler/CairoOutputDev.h | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit c3a00c83f1d24c1f88e7ed3b3f772460e578f3cc +Author: Pino Toscano <pino@kde.org> +Date: Sun Jun 15 02:39:31 2008 +0200 + + poppler-page-transition.h is here now + + qt4/src/Doxyfile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 2affed0fc97b958ae46f531c471a3cf0b04c0f55 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 14 01:24:49 2008 +0200 + + Give warnings if the build configuration for stream decoders is + different from default one + + configure.ac | 20 +++++++++++++++++--- + 1 file changed, 17 insertions(+), 3 deletions(-) + +commit 8e74bc612cb4102891324ffdbfcdb47293ecb95e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 14 01:13:53 2008 +0200 + + Warn the user if he does not have any enabled rendering backend + + configure.ac | 3 +++ + 1 file changed, 3 insertions(+) + +commit 99d2361032cbaafd69bd796170757ed6482f208d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 14 00:53:38 2008 +0200 + + Add a JPEG2000 decoder based on OpenJPEG + + Enabled by default since it's generally better than xpdf one + See + http://lists.freedesktop.org/archives/poppler/2008-June/003874.html + for more information + + CMakeLists.txt | 30 +++++- + cmake/modules/FindLIBOPENJPEG.cmake | 44 +++++++++ + configure.ac | 33 +++++++ + poppler/JPEG2000Stream.cc | 181 + ++++++++++++++++++++++++++++++++++++ + poppler/JPEG2000Stream.h | 48 ++++++++++ + poppler/Makefile.am | 22 ++++- + poppler/Stream.cc | 7 +- + 7 files changed, 360 insertions(+), 5 deletions(-) + +commit e368838d7f9691c7b1adf7d7f62f65abed91eea7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 11 00:48:53 2008 +0200 + + [Qt4] Add the possibility of getting a QByteArray with the data of + an embedded font + + qt4/src/poppler-document.cc | 23 +++++++++++++++++++++++ + qt4/src/poppler-private.h | 3 +++ + qt4/src/poppler-qt4.h | 5 +++++ + 3 files changed, 31 insertions(+) + +commit 184292ffb8fef5aa5a72bdbfcc0c95b663f452bd +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 10 23:00:11 2008 +0200 + + Make the fontRef and the embRef accessible to FontInfo users + + poppler/FontInfo.cc | 2 +- + poppler/FontInfo.h | 3 +++ + 2 files changed, 4 insertions(+), 1 deletion(-) + +commit 86b7e8a3bee74c5b89c451137cf9c2758ba6913f +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Jun 8 18:00:05 2008 +0930 + + Ensure cairo renders Type 3 glyphs with only the fill color + + poppler/CairoOutputDev.cc | 3 +++ + poppler/CairoOutputDev.h | 2 +- + 2 files changed, 4 insertions(+), 1 deletion(-) + +commit 99e2d95728f41c91ab59a01c62d82b19a7a2e083 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Jun 1 00:49:32 2008 +0930 + + glib: save/restore cairo state when rendering a page + + glib/poppler-page.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 6f40ee4af6b59f9d2c326adc8d2574e45f4d4d29 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 8 23:46:04 2008 +0200 + + Make sure we use Qt4 moc to generate moc files of the qt4 frontend + + configure.ac | 20 ++++++++++++++++++++ + qt4/demos/Makefile.am | 2 +- + qt4/src/Makefile.am | 2 +- + qt4/tests/Makefile.am | 2 +- + 4 files changed, 23 insertions(+), 3 deletions(-) + +commit 86aa8fc0708f7da4a907a8bdb1845e53d29892b7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jun 5 19:21:08 2008 +0200 + + Fix leak on ABWOutputDev.cc + + poppler/ABWOutputDev.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 979ef1cafa968d776a2b804ce555b11212212397 +Author: Koji Otani <sho@bbr.jp> +Date: Tue Jun 3 21:07:15 2008 +0200 + + Support for surrogates outside the BMP plane + + poppler/TextOutputDev.cc | 19 ++++++++++++++++++- + poppler/UTF8.h | 14 ++++++++++++++ + 2 files changed, 32 insertions(+), 1 deletion(-) + +commit 1614ab3036cf25c9b94967163996678d386ce0ac +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 1 16:32:55 2008 +0200 + + Do not limit CharCodeToUnicodeString to 8 characters + + poppler/Annot.cc | 10 +++++----- + poppler/CharCodeToUnicode.cc | 37 +++++++++++++++++++++---------------- + poppler/CharCodeToUnicode.h | 2 +- + poppler/Gfx.cc | 8 ++++---- + poppler/GfxFont.cc | 43 + ++++++++++++++++++++++++------------------- + poppler/GfxFont.h | 6 +++--- + poppler/PSOutputDev.cc | 4 ++-- + 7 files changed, 60 insertions(+), 50 deletions(-) + +commit bf95c6970dacaa62512de858cf60ff6cf0c1bf7c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 1 00:07:11 2008 +0200 + + [Qt] Fix leak when calling Poppler::Document::scanForFonts + + qt/poppler-document.cc | 1 + + 1 file changed, 1 insertion(+) + +commit d21d7271fc74ab78cd157549138d0027cf179471 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat May 31 23:57:31 2008 +0200 + + Make sure file exists before printing it + + utils/HtmlOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0480a788c0f25af1bc09360b599debb37f831e10 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 27 23:20:32 2008 +0200 + + require gthread-2.0 + + cmake/modules/FindGTK.cmake | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +commit 2e40ef652eb9fca7fe947acb2adfecc96ad3c50e +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 26 22:13:38 2008 +0200 + + Do not shadow a paramer with a local variable name + + qt4/src/poppler-page.cc | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit 1fd856aa1fb48869111e5b86f263bfd94fa7af17 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 26 20:52:53 2008 +0200 + + Do not leak tSplash if transpGroupStack->blendingColorSpace is NULL + + poppler/SplashOutputDev.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 492209ec8648342a3a5447611f3f1ce63b63e8e9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 26 20:51:06 2008 +0200 + + Move variables only used inside the loop inside the loop, fix delete + of uninitialized data due to my previous patch + + poppler/Page.cc | 16 ++++++---------- + 1 file changed, 6 insertions(+), 10 deletions(-) + +commit 79ab8cceb318f3bb5ebad431824e3ae593aea340 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 26 20:38:59 2008 +0200 + + Do not leak memory if data_out is NULL + + poppler/Page.cc | 35 ++++++++++++++++++----------------- + 1 file changed, 18 insertions(+), 17 deletions(-) + +commit f44c33344d4af31ee008826179bcd92db445f35a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun May 25 19:16:12 2008 +0200 + + [glib] Init glib threads in demo app as required by g_timer + + configure.ac | 4 ++-- + glib/demo/main.c | 4 ++++ + 2 files changed, 6 insertions(+), 2 deletions(-) + +commit 58d5b7b9ab9ac245481299c4765f3bd305580d2e +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed May 21 22:18:29 2008 +0200 + + [Qt4] Fix text() method + + I'm not sure this is the real and correct fix, but it works more + than previous code so it's and improvement + + qt4/src/poppler-page.cc | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +commit e3e4113c73128f49f99289b592446d4382b5d65c +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 12 15:39:43 2008 +0200 + + Add getters to some TextBlock members. + + Needed by some reader using poppler internals, bad you! + + poppler/TextOutputDev.h | 5 +++++ + 1 file changed, 5 insertions(+) + +commit ff699e64bd1de78915aad4ddb79d6f529aef2b87 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 11 23:44:50 2008 +0200 + + Check the OC we found exists before using it + + Fixes crash http://bugs.freedesktop.org/show_bug.cgi?id=15899 + + poppler/OptionalContent.cc | 33 ++++++++++++++++++--------------- + 1 file changed, 18 insertions(+), 15 deletions(-) + +commit ac26ba5148b99a03a56e37ba201ad420b8619943 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 9 20:17:37 2008 +0200 + + Do not crash on unlock with wrong password + + qt/poppler-private.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 19ec5a531cb03a7bee1cfcc9c7d5c4390fbd069d +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 8 23:15:58 2008 +0200 + + Fix build with --enable-fixedpoint + + splash/Splash.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 1cf5f0fda542efef575a123622637d81b9c42053 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed May 7 18:49:28 2008 +0200 + + [Qt] Fix Document::unlock + + qt/poppler-document.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit b5041924eb023cc095f2445935ff713cf65dacce +Author: Pino Toscano <pino@kde.org> +Date: Wed May 7 16:44:03 2008 +0200 + + do not delete the GooString owned by an Object + + poppler/Annot.cc | 4 ---- + 1 file changed, 4 deletions(-) + +commit 546a7b700862db00240de9fd50bdba1dd347765b +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 4 15:26:26 2008 +0200 + + Fix leaks on error conditions + + poppler/Annot.cc | 6 ++++++ + poppler/ArthurOutputDev.cc | 1 + + poppler/JBIG2Stream.cc | 1 + + 3 files changed, 8 insertions(+) + +commit 914f1b1d814ab3d958aa0ca21ad73ef5aed20b89 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat May 3 18:21:28 2008 +0200 + + A widget annot does not always belong to a form, so check before + accessing the widget member + + poppler/Annot.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit c907e41ab18dda10cd3c9789bd0e7fe71b6402a8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Apr 30 00:42:34 2008 +0200 + + findSegment can return NULL check for it + + poppler/JBIG2Stream.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 8b7f29b577bca3295e99fea4a5cf4a6bb7ba2617 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Apr 30 00:26:28 2008 +0200 + + new[] implies delete[] + + poppler/ABWOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 926c13825d5f7364286975db8ffa507b92f4b3ab +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 29 23:44:51 2008 +0200 + + add lost return when adding kees patch + + poppler/Object.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ba9283f6bc78e97006e52ef5de20c958ee9e1a37 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 29 23:42:00 2008 +0200 + + make the function static + + utils/pdftoppm.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 931a8272f556ba8a35342f0c5bf53bdb57ea7a31 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 29 23:41:31 2008 +0200 + + make the variable static + + utils/pdftoabw.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1887d2910d2006c7fc3ecc95db0150f1537e9d0a +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 29 23:35:17 2008 +0200 + + constify some static arrays + + poppler/CompactFontTables.h | 2 +- + poppler/Decrypt.cc | 8 ++++---- + poppler/Function.cc | 2 +- + poppler/GfxFont.cc | 6 +++--- + poppler/GfxState.cc | 4 ++-- + poppler/JBIG2Stream.cc | 10 +++++----- + poppler/JPXStream.cc | 4 ++-- + poppler/Lexer.cc | 2 +- + poppler/PSOutputDev.cc | 6 +++--- + poppler/PSTokenizer.cc | 2 +- + poppler/SplashOutputDev.cc | 2 +- + poppler/Stream-CCITT.h | 12 ++++++------ + poppler/Stream.cc | 10 +++++----- + poppler/UnicodeTypeTable.cc | 2 +- + 14 files changed, 36 insertions(+), 36 deletions(-) + +commit 51140e2d9490696d716f77d3225da0bfdfc212b4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 29 23:14:59 2008 +0200 + + more static markers + + poppler/Annot.cc | 2 +- + poppler/DCTStream.cc | 2 +- + poppler/Object.cc | 2 +- + poppler/SplashOutputDev.cc | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +commit 893703cb9eee879f728db329f7ee1fc19e7f980e +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 29 23:03:51 2008 +0200 + + add static + + poppler/XRef.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 7333bc913111e56ee241b7ef2bf6e9fea68b7da2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 29 23:01:13 2008 +0200 + + add static + + poppler/JBIG2Stream.cc | 30 +++++++++++++++--------------- + 1 file changed, 15 insertions(+), 15 deletions(-) + +commit 1ea36507f9c9f163b6772268046e7560d0c00dbc +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 29 22:47:19 2008 +0200 + + make findModifier static + + poppler/GlobalParams.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit be9961571dbfabb982e6f69abd3bbc98fa971864 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 29 21:48:09 2008 +0200 + + make variables not used outside static + + utils/pdftohtml.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit b157064a85350da6ea9c4f46e965e45ebc59d227 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 29 21:43:23 2008 +0200 + + constify setPSPaperSize + + utils/pdftops.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ee57ead8a6f34fa8de044399e5912395e0f3a425 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 29 21:37:57 2008 +0200 + + constify argDesc arrays + + Gives me binaries 2KB smaller (in total) in release build + + utils/parseargs.c | 18 +++++++++--------- + utils/parseargs.h | 4 ++-- + utils/pdffonts.cc | 2 +- + utils/pdfimages.cc | 2 +- + utils/pdfinfo.cc | 2 +- + utils/pdftoabw.cc | 2 +- + utils/pdftohtml.cc | 2 +- + utils/pdftoppm.cc | 2 +- + utils/pdftops.cc | 2 +- + utils/pdftotext.cc | 2 +- + 10 files changed, 19 insertions(+), 19 deletions(-) + +commit 9f93d9eb464877e0d23dcf205295da9162f03253 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 29 20:45:01 2008 +0200 + + make psOpNames static + + Makes my release build 64 bytes smaller + + poppler/Function.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 29e3e779c68371b7c4aadcf68ee0712046f39c6d +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 26 23:47:01 2008 +0200 + + remember to call the base implementation here + + qt4/demos/optcontent.cpp | 1 + + 1 file changed, 1 insertion(+) + +commit a188f3cd36775d78ace5b5d62c8ab7c059b3b2b1 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 26 23:42:09 2008 +0200 + + reset the current page to 0, when closing a document + + qt4/demos/viewer.cpp | 1 + + 1 file changed, 1 insertion(+) + +commit 7eca6da6436ffc1c41cfed1a07be4dafa1172463 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 26 23:41:45 2008 +0200 + + no need to manually disconnect from the model, as it will be deleted + by the document anyway + + qt4/demos/optcontent.cpp | 1 - + 1 file changed, 1 deletion(-) + +commit 6cddda7f3c3b8ddb95e6aba1b234a27c4454c23d +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 26 22:41:59 2008 +0200 + + sync updateFont() with SplashOutputDev + + poppler/ArthurOutputDev.cc | 75 + ++++++++++++++++++++++++++++++++++++---------- + 1 file changed, 59 insertions(+), 16 deletions(-) + +commit ddc7c1f8c24762bae615e7dec92e92a58c827478 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 26 18:12:51 2008 +0200 + + construct AnnotPolygon for Polygon and PolyLine annotations + + poppler/Annot.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit f9c7e8037b7165b6271ce7aea0d315053c4d66a5 +Merge: 59d33d8 f5fec4f +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 26 18:09:59 2008 +0200 + + Merge branch 'master' of + ssh://pino@git.freedesktop.org/git/poppler/poppler + +commit 59d33d8e99673f73ccf2ad9a62bd25fca51f0eb8 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 26 17:56:42 2008 +0200 + + use the base implementation to update all the states + + poppler/ArthurOutputDev.cc | 11 +---------- + 1 file changed, 1 insertion(+), 10 deletions(-) + +commit 45d2a9529bf241554c59437118cb8c705554dc27 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 26 17:55:39 2008 +0200 + + Set the font antialiasing from the painter settings, instead of the + global settings. + + poppler/ArthurOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5faa72fd70e0d85268e807a8b870d80dda9189a9 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 26 17:53:28 2008 +0200 + + Get the font and painter matrices, and reenable the font drawing. + + poppler/ArthurOutputDev.cc | 28 +++++++++++++++++++++------- + 1 file changed, 21 insertions(+), 7 deletions(-) + +commit f5fec4fdedd8d316b19968545e447e2036a1bb47 +Author: Kees Cook <kees@outflux.net> +Date: Wed Apr 23 19:53:03 2008 +0200 + + provide type-checking for union pointer accesses + + poppler/Object.h | 68 + +++++++++++++++++++++++++++++++++++--------------------- + 1 file changed, 43 insertions(+), 25 deletions(-) + +commit a567c921ce538616f4ba0b7933086ef5a8ab0f55 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Tue Apr 22 23:09:10 2008 +0200 + + Little change to avoid AnnotWidget crashing when they aren't related + to FormWidgets. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 19 ++++++++++--------- + 1 file changed, 10 insertions(+), 9 deletions(-) + +commit 73798c95b8a4c0504e9246e6f73fd31f812ad6fa +Author: Albert Astals Cid <tsdgeos@bluebox.(none)> +Date: Mon Apr 21 19:56:52 2008 +0200 + + Link to pthread when needed + + Should fix bug 15625 + + configure.ac | 2 + + m4/acx_pthread.m4 | 280 + ++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Makefile.am | 4 + + 3 files changed, 286 insertions(+) + +commit 6c248bdad77235a45402d9693a0b822cc208b6b9 +Author: Pino Toscano <pino@kde.org> +Date: Sun Apr 20 18:32:59 2008 +0200 + + the dtor should be virtual + + qt4/src/poppler-converter-private.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 68dba1a452ca70add5b05ab8e2adab838bc2cb73 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 20 16:21:10 2008 +0200 + + if ncand is a Guint cand should be one too + + poppler/CMap.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0b91eb19f5a3d07b625ee5188f1fcb4b4b1544ea +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 20 16:17:50 2008 +0200 + + Unused var-- + + poppler/GfxFont.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1ed3cc40987b691319fd9f1a30296d80de5732fd +Author: Pino Toscano <pino@kde.org> +Date: Wed Apr 16 15:45:45 2008 +0200 + + fix border style conversion + + qt4/src/poppler-page.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 7c8feb4e3627bde2052a7e536d2d49d1cbbce8ee +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 15 21:57:31 2008 +0200 + + Hack to "support" 16 bits images + + Everywhere we assume a component fits in 8 bits, with this hack + we treat 16 bit images as 8 bit ones until it's fixed correctly. + Fixes http://bugs.kde.org/show_bug.cgi?id=158165 + + poppler/GfxState.cc | 6 ++++++ + poppler/Stream.cc | 9 +++++++++ + 2 files changed, 15 insertions(+) + +commit f338a9ded5d42dd65853c5c7bbe27f6724096416 +Author: Pino Toscano <pino@kde.org> +Date: Sun Apr 13 21:41:51 2008 +0200 + + [Qt4] convert the sound annotations + + qt4/src/poppler-page.cc | 16 ++++++++++++++-- + 1 file changed, 14 insertions(+), 2 deletions(-) + +commit 733d51fca04ee682fed2242f868edd545f3755fa +Author: Pino Toscano <pino@kde.org> +Date: Sun Apr 13 21:38:25 2008 +0200 + + [Qt4] First version of a SoundAnnotation. + + qt4/src/poppler-annotation.cc | 87 + +++++++++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-annotation.h | 30 ++++++++++++++- + 2 files changed, 116 insertions(+), 1 deletion(-) + +commit feb1ea091111bd7292879c465590acfd7671c876 +Author: Pino Toscano <pino@kde.org> +Date: Sun Apr 13 21:36:26 2008 +0200 + + First version of AnnotSound. + + poppler/Annot.cc | 37 ++++++++++++++++++++++++++++++++++++- + poppler/Annot.h | 26 ++++++++++++++++++++++++++ + 2 files changed, 62 insertions(+), 1 deletion(-) + +commit ec2cf81edf1b2c6707de4d30316ff5f5e24534d4 +Author: Pino Toscano <pino@kde.org> +Date: Sun Apr 13 18:31:21 2008 +0200 + + [Qt4] convert the file attachment annotations + + qt4/src/poppler-page.cc | 15 +++++++++++++-- + 1 file changed, 13 insertions(+), 2 deletions(-) + +commit 9fa2e96c96d365ae67859545ebd635d726784fca +Author: Pino Toscano <pino@kde.org> +Date: Sun Apr 13 18:29:00 2008 +0200 + + [Qt4] Initial version of FileAttachmentAnnotation + + qt4/src/poppler-annotation.cc | 88 + +++++++++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-annotation.h | 29 +++++++++++++- + 2 files changed, 116 insertions(+), 1 deletion(-) + +commit 5899aff11f94e707654574e830e0757b1df558d4 +Author: Pino Toscano <pino@kde.org> +Date: Sun Apr 13 10:50:39 2008 +0200 + + [Qt4] Read the annotations from the core, instead of own parsing. + + Almost all the data are converted correctly, the results seem to be + the same. + Added TODOs in the few parts (not essential) I was not able to figure + out how to convert, yet. + Covert also the Caret annotations. + + qt4/src/poppler-annotation-helper.h | 2 +- + qt4/src/poppler-page.cc | 851 + +++++++++++++++++------------------- + 2 files changed, 393 insertions(+), 460 deletions(-) + +commit 40a12793c5ccea206d79e0c17e2f2d0cf74bb4f3 +Author: Pino Toscano <pino@kde.org> +Date: Sun Apr 13 02:21:55 2008 +0200 + + add getters for the AnnotPolygon properties + + poppler/Annot.h | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 9311f75d4c3da991efb8afd00701a0ce1cbae1b0 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Sun Apr 13 01:52:36 2008 +0200 + + Almost full AnnotPolygon support. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 99 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Annot.h | 37 +++++++++++++++++++++ + 2 files changed, 136 insertions(+) + +commit 01aa052ed761a4ada471d196985825986bb58627 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Sun Apr 13 01:13:49 2008 +0200 + + Extend AnnotPath behaviour to include cooordinate array parsing. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 96 + ++++++++++++++++++++++++++++++-------------------------- + poppler/Annot.h | 4 ++- + 2 files changed, 55 insertions(+), 45 deletions(-) + +commit ca52830e9519ae7b778f98e5c2547daef7da5f09 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Sun Apr 13 00:54:13 2008 +0200 + + Added OptionalContent support to Annots. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 9 +++------ + poppler/Annot.h | 5 +++-- + 2 files changed, 6 insertions(+), 8 deletions(-) + +commit 4b87196b7829c87d15af4e8b4138ca97548fb519 +Author: Pino Toscano <pino@kde.org> +Date: Sun Apr 13 00:18:24 2008 +0200 + + Isolate the embedded file reading logic into a new EmbFile + constructor. + + This way, it can be shared and reused in various places (Catalog, + AnnotFileAttachment, etc). + + poppler/Catalog.cc | 205 + +++++++++++++++++++++++++++++------------------------ + poppler/Catalog.h | 1 + + 2 files changed, 112 insertions(+), 94 deletions(-) + +commit 45b407e51905948690065749085a4af1cbb29a8e +Author: Pino Toscano <pino@kde.org> +Date: Sun Apr 13 00:14:38 2008 +0200 + + correctly get the FileSpec dictionary + + poppler/Annot.cc | 4 +++- + poppler/Annot.h | 2 +- + 2 files changed, 4 insertions(+), 2 deletions(-) + +commit c3aa3a97d9c553ea7976741d798901352fb5381c +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 12 22:45:57 2008 +0200 + + properly initialize an AnnotPath + + poppler/Annot.cc | 9 ++------- + 1 file changed, 2 insertions(+), 7 deletions(-) + +commit a3406fb2ace1390db1c181823a7bfc66c9174d98 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 12 22:40:42 2008 +0200 + + properly dispose the memory of the ink lists + + poppler/Annot.cc | 13 ++++++++++++- + poppler/Annot.h | 1 + + 2 files changed, 13 insertions(+), 1 deletion(-) + +commit 0dad70e2d12e8b587cab8ce2d914c81c6897a1d1 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 12 22:15:35 2008 +0200 + + make AnnotInk working. + + - get the point indexes in the correct way + - dispose with free what you allocate with malloc + - fix logic when checking for an even number of points + + poppler/Annot.cc | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit 77404e24ea1e175fc9b55097dc5b35cc34760659 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 12 21:08:54 2008 +0200 + + a length is an int + + poppler/Annot.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit bc2b2ffd2144f951c311e968fba4bc50b7c43ff3 +Merge: cd5afe6 bacc1dd +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Sat Apr 12 17:40:49 2008 +0200 + + Fixed merging conflict. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + +commit cd5afe6d9eca687ee224ff7680a8cba28d81a36d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 12 00:44:08 2008 +0200 + + Do not take into account Colorspace resource subdictionary for + image XObjects + + Fixes bug 15125 + The motivation under that change is on section 4.5.2 of the spec: + Certain objects, such as image XObjects, specify a + color space as an explicit parameter, often associated with the + key ColorSpace. + In this case, the color space array or name is always defined + directly as a PDF + object, not by an entry in the ColorSpace resource + subdictionary. This conven- + tion also applies when color spaces are defined in terms of other + color spaces. + + poppler/Gfx.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit bacc1dd9f37ff19c5e54878a5b08e7d734584bbf +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 12 17:20:09 2008 +0200 + + Read the "in reply to" reference as such, without reading the + associated annotation dictionary. + + poppler/Annot.cc | 10 ++++------ + poppler/Annot.h | 4 ++-- + 2 files changed, 6 insertions(+), 8 deletions(-) + +commit ffe09454a0948a6107bcc38f23ba2068151c547d +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Sat Apr 12 17:17:59 2008 +0200 + + Initial Annot3D parsing a few general improvements. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 130 + +++++++++++++++++++++++++++++++++++++++++++++++++++---- + poppler/Annot.h | 84 +++++++++++++++++++++++++++++------ + 2 files changed, 193 insertions(+), 21 deletions(-) + +commit 8757c577241dda31bc59c7d1c208c159ad428877 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Sat Apr 12 10:38:07 2008 +0200 + + AnnotFileAttachment support. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 38 ++++++++++++++++++++++++++++++++++++-- + poppler/Annot.h | 25 +++++++++++++++++++++++++ + 2 files changed, 61 insertions(+), 2 deletions(-) + +commit 36989658149fc9e5e8a049ce070a102f35b7bddc +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Sat Apr 12 09:55:26 2008 +0200 + + AnnotInk support. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 113 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Annot.h | 45 ++++++++++++++++++++++ + 2 files changed, 158 insertions(+) + +commit 464b171d0e9b989196c287f2ee4dfbbc14212aa9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 12 00:44:08 2008 +0200 + + Do not take into account Colorspace resource subdictionary for + image XObjects + + Fixes bug 15125 + The motivation under that change is on section 4.5.2 of the spec: + Certain objects, such as image XObjects, specify a + color space as an explicit parameter, often associated with the + key ColorSpace. + In this case, the color space array or name is always defined + directly as a PDF + object, not by an entry in the ColorSpace resource + subdictionary. This conven- + tion also applies when color spaces are defined in terms of other + color spaces. + + poppler/Gfx.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 42db4890e8295aaec5a1be12d1414fc0a9048550 +Author: Chris Wilson <chris@chris-wilson.co.uk> +Date: Thu Mar 27 10:52:22 2008 +0000 + + Do not call FT_Done_Face on a live cairo_font_face_t. + + Currently CairoFont calls FT_Done_Face on its deletion, but the + FT_Face + is usually still in use within cairo. This causes a failure later when + cairo tries to create a glyph from its cairo_font_face_t. + + From http://bugs.freedesktop.org/show_bug.cgi?id=15216: + ==13745== Invalid read of size 4 + ==13745== at 0x51BE572: FT_Load_Glyph (ftobjs.c:549) + ==13745== by 0x4A24921: _cairo_ft_scaled_glyph_init + (cairo-ft-font.c:1922) + ==13745== by 0x4A117AB: _cairo_scaled_glyph_lookup + (cairo-scaled-font.c:1674) + ==13745== by 0x4A12A5A: _cairo_scaled_font_glyph_device_extents + (cairo-scaled-font.c:1124) + ==13745== by 0x4A21ECD: _cairo_analysis_surface_show_glyphs + (cairo-analysis-surface.c:516) + ==13745== by 0x4A144DC: _cairo_surface_show_glyphs + (cairo-surface.c:2086) + ==13745== by 0x4A1FCC8: _cairo_meta_surface_replay_internal + (cairo-meta-surface.c:816) + ==13745== by 0x4A214B1: _paint_page (cairo-paginated-surface.c:299) + ==13745== by 0x4A2171E: _cairo_paginated_surface_show_page + (cairo-paginated-surface.c:445) + ==13745== by 0x4A14BDF: cairo_surface_show_page + (cairo-surface.c:1702) + ==13745== by 0x49FF661: cairo_show_page (cairo.c:2155) + ==13745== by 0xA267D97: + pdf_document_file_exporter_end_page(_EvFileExporter*) + (ev-poppler.cc:1753) + ==13745== Address 0x55c5630 is 88 bytes inside a block of size + 552 free'd + ==13745== at 0x402269C: free (vg_replace_malloc.c:326) + ==13745== by 0x51B7ABC: ft_free (ftsystem.c:158) + ==13745== by 0x51BB319: ft_mem_free (ftutil.c:171) + ==13745== by 0x51BC318: destroy_face (ftobjs.c:856) + ==13745== by 0x51BC3B2: FT_Done_Face (ftobjs.c:1972) + ==13745== by 0x4363704: CairoFont::~CairoFont() + (CairoFontEngine.cc:251) + ==13745== by 0x436401D: CairoFontEngine::getFont(GfxFont*, XRef*) + (CairoFontEngine.cc:335) + ==13745== by 0x4366915: CairoOutputDev::updateFont(GfxState*) + (CairoOutputDev.cc:318) + ==13745== by 0x5093BF1: Gfx::opShowText(Object*, int) (Gfx.cc:3073) + ==13745== by 0x508F901: Gfx::execOp(Object*, Object*, int) + (Gfx.cc:726) + ==13745== by 0x50906FF: Gfx::go(int) (Gfx.cc:594) + ==13745== by 0x5090C96: Gfx::display(Object*, int) (Gfx.cc:557) + + The solution is to release the reference to the cairo_font_face_t upon + destruction of the CairoFont, and then to release the FT_Face from the + destroy notify of the cairo_font_face_t. + + poppler/CairoFontEngine.cc | 19 +++++++++---------- + 1 file changed, 9 insertions(+), 10 deletions(-) + +commit 5f60843824582ece36d806508ec388330ddee854 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Tue Apr 8 00:30:57 2008 +0200 + + Added AnnotCoord support. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 64 + ++++++++++++++++++---------------------------------- + poppler/Annot.h | 69 + ++++++++++++++++++++++++++------------------------------ + 2 files changed, 54 insertions(+), 79 deletions(-) + +commit a6f70f465a3e6719d63cefbe3c27bae015be43c1 +Author: Pino Toscano <pino@kde.org> +Date: Sun Apr 6 13:12:01 2008 +0200 + + add getters for the coordinates in an AnnotLine + + poppler/Annot.h | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 1d83d6edf9a843335e37a4d1e0e0dd71eb23d93b +Author: Pino Toscano <pino@kde.org> +Date: Sun Apr 6 12:24:42 2008 +0200 + + [Qt4] the caret symbol is an enum value, now + + qt4/src/poppler-annotation.cc | 35 ++++++++++++++++++++++++++++------- + qt4/src/poppler-annotation.h | 7 +++++-- + 2 files changed, 33 insertions(+), 9 deletions(-) + +commit 229d991a3258cb9b56f5e00f2deb3c976253cf68 +Author: Pino Toscano <pino@kde.org> +Date: Sun Apr 6 12:23:04 2008 +0200 + + the caret symbol does not seem to allow additional values, so convert + it to an enum + + poppler/Annot.cc | 11 +++++++---- + poppler/Annot.h | 9 +++++++-- + 2 files changed, 14 insertions(+), 6 deletions(-) + +commit fc24500ddd9182f97d23c46eaafc6be79a6721eb +Author: Pino Toscano <pino@kde.org> +Date: Sun Apr 6 11:43:49 2008 +0200 + + propetly initialise a couple of members; leak less + + poppler/ArthurOutputDev.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 9409de1e7c5b3770c7ef00c01ee376953dd532a5 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Sun Apr 6 01:38:25 2008 +0200 + + Changed AnnotFreeText RD field to the new parseDiffRectangle. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 35 ++--------------------------------- + 1 file changed, 2 insertions(+), 33 deletions(-) + +commit 28c5ee2e9fc2a24d2f2efb3d74d5cf882a106239 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 5 23:19:33 2008 +0200 + + typo fix + + poppler/Annot.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ed02769688466ca72bf35d4223c3822a1245604b +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 5 19:36:21 2008 +0200 + + read the destination of a link annotation + + poppler/Annot.cc | 5 ++++- + poppler/Annot.h | 4 ++-- + 2 files changed, 6 insertions(+), 3 deletions(-) + +commit ca31bf12a9d70bac88e457f7799e9935aba58640 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 5 16:48:53 2008 +0200 + + variable forgotten in the copy&paste... + + qt4/src/poppler-annotation.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 4168daa141b76e5fcd07d046aca8dac2f3037ff9 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 5 16:34:12 2008 +0200 + + [Qt4] deserialize also CaretAnnotation's + + qt4/src/poppler-annotation.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit b55bcc2aa95825863bef23ab96364b350a49949d +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 5 16:31:31 2008 +0200 + + [Qt4] first version of a CaretAnnotation. + + qt4/src/poppler-annotation.cc | 80 + +++++++++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-annotation.h | 25 +++++++++++++- + 2 files changed, 104 insertions(+), 1 deletion(-) + +commit 4c9a02b7e49666efe10fdc16e7a03d8d520b65ec +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 5 16:01:58 2008 +0200 + + First version of AnnotCaret. + + poppler/Annot.cc | 36 +++++++++++++++++++++++++++++++++++- + poppler/Annot.h | 22 ++++++++++++++++++++++ + 2 files changed, 57 insertions(+), 1 deletion(-) + +commit d260fe9e514c667b66969b982119429cc922eb07 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 5 15:54:29 2008 +0200 + + isolate the code for parsing a "difference rectangle" in an own + function + + poppler/Annot.cc | 54 + +++++++++++++++++++++++++++++++----------------------- + 1 file changed, 31 insertions(+), 23 deletions(-) + +commit 760833e409c122c0a61f7c87fd3133eebc10b402 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 5 15:36:43 2008 +0200 + + First version of AnnotGeometry. + + poppler/Annot.cc | 77 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- + poppler/Annot.h | 24 ++++++++++++++++++ + 2 files changed, 99 insertions(+), 2 deletions(-) + +commit 95d9d2362534c0524ad0448818b2d69b0909d482 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 5 03:23:00 2008 +0200 + + finally, load the QuadPoints correctly + + when checking the validity of the coordinate, do the comparison just + with the proper one (either X or Y); + free the "point" object after each iteration + + poppler/Annot.cc | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +commit af1ffcbcec1730332d11f8da4a7ddac833b22408 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 5 02:54:00 2008 +0200 + + More robust reading of QuadPoints (reset the allocated memory, + use the heap) + + poppler/Annot.cc | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +commit 68fd98d69bac20282665cf6b824da30c3b310f0b +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 5 02:51:41 2008 +0200 + + Really implement AnnotTextMarkup. + + poppler/Annot.cc | 29 +++++++++++++++++++++++++---- + poppler/Annot.h | 2 +- + 2 files changed, 26 insertions(+), 5 deletions(-) + +commit 69a2ecfaf8f8cffd3027db5c3cc88c41413e42f1 +Author: Pino Toscano <pino@kde.org> +Date: Sat Apr 5 01:38:28 2008 +0200 + + Add the Stamp annotation type. + + poppler/Annot.cc | 28 +++++++++++++++++++++++++++- + poppler/Annot.h | 20 ++++++++++++++++++++ + 2 files changed, 47 insertions(+), 1 deletion(-) + +commit 97be4332818bcf58461816be995d88926809a4e5 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Fri Apr 4 23:49:12 2008 +0200 + + Updated glib bindings. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + glib/demo/annots.c | 32 +++++--------------------------- + glib/poppler-annot.cc | 27 +++++---------------------- + glib/poppler-annot.h | 13 +------------ + 3 files changed, 11 insertions(+), 61 deletions(-) + +commit 5caac407cdaf58621ac27e5561b31a995404ccb3 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Fri Apr 4 23:36:46 2008 +0200 + + Fixed icon name in AnnotText. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 25 ++++++------------------- + poppler/Annot.h | 15 +++------------ + 2 files changed, 9 insertions(+), 31 deletions(-) + +commit 0b714a61383da1b62daf2a60e3f6fcda09b4e9f2 +Author: Adam Batkin <adam@batkin.net> +Date: Thu Apr 3 20:02:52 2008 +0200 + + FindFirstFile returns INVALID_HANDLE_VALUE and not NULL on error + + goo/gfile.cc | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +commit be765f27cc5430d9bb2a3e113eb245d67c20a376 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Mar 31 12:37:33 2008 +0200 + + [glib] Fix a crash in outline demo due to page_num == dest_page_num + - 1 + + glib/demo/utils.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e991e9ac6fcc0b6928b96fe8326eebcf3cb720ca +Author: Albert Astals Cid <tsdgeos@localhost.(none)> +Date: Sat Mar 29 13:25:52 2008 +0100 + + Add the export macro + + qt4/src/poppler-page-transition.h | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit b70ca35dce6da6efdff254c11a63de4f44228278 +Author: Albert Astals Cid <tsdgeos@localhost.(none)> +Date: Sat Mar 29 00:30:31 2008 +0100 + + Duplicate page-transition files on qt4 + + qt4/src/CMakeLists.txt | 4 +- + qt4/src/Makefile.am | 4 +- + qt4/src/poppler-page-transition-private.h | 28 ++++++ + qt4/src/poppler-page-transition.cc | 95 +++++++++++++++++++ + qt4/src/poppler-page-transition.h | 146 + ++++++++++++++++++++++++++++++ + 5 files changed, 273 insertions(+), 4 deletions(-) + +commit b5312785063235cef7584ab6a5d198fb72de0988 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Wed Mar 26 23:56:49 2008 +0100 + + Improved glib annot demo. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + glib/demo/annots.c | 314 + ++++++++++++++++++++++++++++++++++++++++++++++++----- + 1 file changed, 289 insertions(+), 25 deletions(-) + +commit 7cc8fd70f68d2cdab7ab83a0ecf6c8896c971d62 +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 26 21:03:34 2008 +0100 + + remove damn error + + qt4/src/poppler-page.cc.orig | 1317 + ------------------------------------------ + 1 file changed, 1317 deletions(-) + +commit 7a47ff3b54678a3de6964d25050e02186484f39a +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 26 21:00:32 2008 +0100 + + [Qt4] Add support for JavaScript links, and create them when present. + + qt4/src/poppler-link.cc | 36 ++ + qt4/src/poppler-link.h | 32 +- + qt4/src/poppler-page.cc | 7 + + qt4/src/poppler-page.cc.orig | 1317 + ++++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 1391 insertions(+), 1 deletion(-) + +commit a6f2c10ee01ee62ae945b50f6b6eae380377fe03 +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 26 20:59:21 2008 +0100 + + [Qt4] Read the document-level JavaScript scripts. + + qt4/src/poppler-document.cc | 15 +++++++++++++++ + qt4/src/poppler-qt4.h | 8 ++++++++ + 2 files changed, 23 insertions(+) + +commit b8a471e55b998836c09c65ff736afdef8ac55189 +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 26 20:56:01 2008 +0100 + + Add support for JavaScript actions, and read them when found. + + poppler/Link.cc | 33 +++++++++++++++++++++++++++++++++ + poppler/Link.h | 23 +++++++++++++++++++++++ + 2 files changed, 56 insertions(+) + +commit 2fd85dc1b8b2ababadfc60e285c08a844737e4bb +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 26 20:53:42 2008 +0100 + + Read the JavaScript codes in the NameTree of the Catalog. + + poppler/Catalog.cc | 39 +++++++++++++++++++++++++++++++++++++++ + poppler/Catalog.h | 7 +++++++ + 2 files changed, 46 insertions(+) + +commit 312f14f5b7be1f0d62620477222919423c3869e0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 26 20:05:31 2008 +0100 + + compile++ + + fofi/FoFiBase.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5bd750062e1fb136f77a55d1f35b2d6fabaad1b3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 26 19:42:43 2008 +0100 + + update version + + CMakeLists.txt | 2 +- + configure.ac | 2 +- + msvc/config.h | 6 +++--- + qt4/src/Doxyfile | 2 +- + 4 files changed, 6 insertions(+), 6 deletions(-) + +commit 10d4a8b9aed51902157c04d9deea0e99d829c4f6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 26 19:42:36 2008 +0100 + + fill news + + NEWS | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +commit 2069826d61ebd527768b6455689276c0a8288085 +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 26 16:05:06 2008 +0100 + + missing break + + qt4/src/poppler-page.cc | 1 + + 1 file changed, 1 insertion(+) + +commit d6a0c6a6803a03f402c2dcde41c6195e951470ba +Author: Pino Toscano <pino@kde.org> +Date: Wed Mar 26 15:50:39 2008 +0100 + + initialize posterStream to avoid crashing later + + poppler/Movie.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 0be811b3ad86b1cb14be94a017e70c65b8e64730 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 25 22:59:22 2008 +0100 + + Don't end up in an infinite recursive loop in case resObj dict is + the same we are already in + + poppler/FontInfo.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0222c6ceb0fcf1d7c4422691a68a035a558ad614 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 24 17:14:07 2008 +0100 + + fix build when using cmake, not sure it's completely ok, but at + least i can compile + + CMakeLists.txt | 1 + + cmake/modules/FindGTK.cmake | 23 ++++++++++++++++------- + config.h.cmake | 3 +++ + glib/CMakeLists.txt | 17 +++++++++++------ + glib/poppler-page.cc | 2 +- + glib/test-poppler-glib.cc | 2 +- + 6 files changed, 33 insertions(+), 15 deletions(-) + +commit 3e4164f2db69358adf07596195842dd00458b621 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 24 15:10:31 2008 +0100 + + fix some cmake HAVE_foo + + CMakeLists.txt | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 22f615aee488cc363a078330861e80f389f47061 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Sun Mar 23 13:22:07 2008 +0100 + + Fixed wrong functions. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + glib/poppler-annot.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit cccfe42ed9c53d27cf6a1403ae55bf34a053012d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 22 19:12:05 2008 +0100 + + Fix rm line not to error when no *moc file is present + + qt4/src/Makefile.am | 2 +- + qt4/tests/Makefile.am | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit e60d39ba0e8b9742106a0c9b1385b1c907729c3f +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 22 19:11:17 2008 +0100 + + Fix rm line not to error if no *moc file is present + + qt4/demos/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit d9d52e622c6b28a9941168bb73839ec335ca7232 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 22 19:10:40 2008 +0100 + + Fix configure to not require gdk when we are on try mode + + configure.ac | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 9b8809298dd16cdbffcc12b6db8e274578934063 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 22 15:49:02 2008 +0100 + + It's really only an error if < 0 + + poppler/PDFDoc.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0fb1e697cc4100ce23298141c8b5829273872423 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 22 15:46:44 2008 +0100 + + remove unneeded variable + + poppler/PDFDoc.cc | 1 - + 1 file changed, 1 deletion(-) + +commit 3404cb626ee9b4520d6fe601e07560745a4cb42a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 22 15:44:50 2008 +0100 + + Remove OutStream::reset since noone uses it + + This way we have a fseek less to care about if worked or not + + poppler/Stream.cc | 5 ----- + poppler/Stream.h | 5 ----- + qt4/src/poppler-qiodeviceoutstream-private.h | 1 - + qt4/src/poppler-qiodeviceoutstream.cc | 5 ----- + 4 files changed, 16 deletions(-) + +commit 066595dd06c930997d5ec65a06c822616af9baa0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 22 15:43:07 2008 +0100 + + Check the document stream is seekable when opening it + + Fixes bug 14126 + + poppler/PDFDoc.cc | 7 +++++++ + 1 file changed, 7 insertions(+) + +commit 23b6475463f8973b5ac83bb21a6b7b6000cc435b +Author: Ed Avis <eda@waniasset.com> +Date: Sat Mar 22 13:55:59 2008 +0100 + + Check for fseek return values + + fofi/FoFiBase.cc | 14 ++++++++++++-- + poppler/GfxFont.cc | 12 ++++++++++-- + 2 files changed, 22 insertions(+), 4 deletions(-) + +commit b33bb282e45cf1a083cfbb13603ac465d386c28d +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Fri Mar 21 13:53:21 2008 +0100 + + Fixed poppler glib public api. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + glib/poppler-annot.cc | 4 ++-- + glib/poppler-annot.h | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit 371932f413d570d7784c668f30834d3d92d7aa80 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Mar 20 11:44:32 2008 +0100 + + [glib] Remove unused variable. + + glib/poppler-document.cc | 1 - + 1 file changed, 1 deletion(-) + +commit 21fa476ac384256c15a954b708e009f2b336b06f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Mar 20 11:42:32 2008 +0100 + + [glib] Do not cache image_dev in poppler page. + + Thanks to Kouhei Sutou who caught the problem. + + glib/poppler-page.cc | 60 + +++++++++++++++++++++++++++-------------------- + glib/poppler-private.h | 3 --- + glib/test-poppler-glib.cc | 9 ++++++- + 3 files changed, 43 insertions(+), 29 deletions(-) + +commit 22cd70d8fc308fb8b19d36d0172014ba532230fb +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 19 21:52:14 2008 +0100 + + poppler_annot_markup_get_opacity returns a double so use %f + + glib/demo/annots.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit b9a5fd4671638caa91f8a389be278d993391f499 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 19 21:28:49 2008 +0100 + + updated by gtk-doc + + glib/reference/tmpl/poppler-action.sgml | 1 + + glib/reference/tmpl/poppler.sgml | 3 +++ + 2 files changed, 4 insertions(+) + +commit b7e0b740578ea1e84ac0ef850b5a03c66b2863e3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 19 21:28:01 2008 +0100 + + Fill 0.7.3 news + + NEWS | 7 +++++++ + 1 file changed, 7 insertions(+) + +commit 3adaff1dad8127fdd06653cf49196027ad414a08 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 19 21:27:46 2008 +0100 + + Bump version to 0.7.3 + + CMakeLists.txt | 2 +- + configure.ac | 2 +- + msvc/config.h | 6 +++--- + qt4/src/Doxyfile | 2 +- + 4 files changed, 6 insertions(+), 6 deletions(-) + +commit 52dd710b63911be2d8c960de0232c497c35ecac8 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Mar 19 18:35:35 2008 +0100 + + [glib] Update outline and links demos to the new POPPLER_ACTION_NONE + + glib/demo/utils.c | 3 +++ + 1 file changed, 3 insertions(+) + +commit 6a22f0a20df38156c06e8ba10649e0828a1da102 +Author: Eugen Dedu <Eugen.Dedu@pu-pm.univ-fcomte.fr> +Date: Wed Mar 19 18:32:48 2008 +0100 + + [glib] Consider no action as an action of type None instead of Unknown + + glib/poppler-action.cc | 2 +- + glib/poppler-action.h | 1 + + 2 files changed, 2 insertions(+), 1 deletion(-) + +commit 185d5818fd546f85934b041d5b0cdcdf1849b1dc +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Mar 18 20:08:21 2008 +0100 + + Improve error handling when creating a document + + glib/poppler-document.cc | 40 ++++++++++++++++++++++++++++------------ + glib/poppler.h | 5 ++++- + 2 files changed, 32 insertions(+), 13 deletions(-) + +commit 9bba2748985049515bfd9c9b44f26b92fa704078 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Mar 15 01:11:39 2008 +0100 + + Some more free + + poppler/OptionalContent.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +commit bfc308935fa138e27c4d2ad0e1c1cad20eba8e8a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Mar 15 01:05:32 2008 +0100 + + Use error instead of printf + + poppler/OptionalContent.cc | 15 ++++++++------- + 1 file changed, 8 insertions(+), 7 deletions(-) + +commit 998b1523ee653c1585f03b4a580e0d95ba694aca +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Mar 15 01:02:31 2008 +0100 + + Some free + + poppler/OptionalContent.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit c65a66a82259f547927cbb918611bcf4a8e264b2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Mar 14 20:29:53 2008 +0100 + + xx0 is non exclusive so that should be < not <= + + Fixes several warnings about writes on bad places + + splash/SplashXPathScanner.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit bd2272f3079319d1c05ca93f7fb6eb0a5370b938 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Mar 14 19:52:04 2008 +0100 + + Fix "Make sure we don't draw outside the bitmap on Splash::fillGlyph2" + when painting with no aa + + Fixes bug 15009 + + splash/Splash.cc | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +commit 5bf8d864e68854f0855e07fb67aa124e06c739cd +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 12 22:48:07 2008 +0100 + + fix build + + glib/reference/Makefile.am | 1 + + 1 file changed, 1 insertion(+) + +commit d0be5c86dcd3310062d820b3515c31e4720af2ca +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 12 22:40:59 2008 +0100 + + Update version to 0.7.2 and fill NEWS + + CMakeLists.txt | 2 +- + NEWS | 20 ++++++++++++++++++++ + configure.ac | 2 +- + msvc/config.h | 6 +++--- + qt4/src/Doxyfile | 2 +- + 5 files changed, 26 insertions(+), 6 deletions(-) + +commit 0b2ecf39572821a99374e6acec7c1bd438911bbc +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 12 22:38:57 2008 +0100 + + update soname here too + + glib/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit f5065016b168e4896e2fe774cd22bbd900849b52 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Mar 12 22:06:53 2008 +0100 + + Make GDK dependency option for glib bindings + + Fixes bug #13719. + + configure.ac | 45 ++- + glib/Makefile.am | 7 +- + glib/demo/page.c | 88 +++++- + glib/demo/render.c | 4 + + glib/poppler-action.h | 1 - + glib/poppler-annot.cc | 26 +- + glib/poppler-annot.h | 2 +- + glib/poppler-document.h | 2 - + glib/poppler-features.h.in | 1 + + glib/poppler-page.cc | 695 + ++++++++++++++++++++++++++------------------- + glib/poppler-page.h | 76 +++-- + glib/poppler.h | 2 +- + glib/test-poppler-glib.cc | 2 +- + 13 files changed, 610 insertions(+), 341 deletions(-) + +commit 46d4fab82332e71d0b68c0a8deeac78f2201ed14 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 12 20:35:33 2008 +0100 + + Increment version of libpoppler and libpoppler-qt4 + + CMakeLists.txt | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/CMakeLists.txt | 2 +- + qt4/src/Makefile.am | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +commit 550c1fc73a6d2af65728751fd0b59ccc7110fa8b +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 12 20:34:48 2008 +0100 + + Init to false updated field of XRefEntries plus indenting fixes + + poppler/XRef.cc | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +commit 6a671686c6265ecdb4c48f04392de9c56d4e0936 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Mar 12 21:43:12 2008 +1030 + + Fix regression in cairo output when transforming ctm + + The commit: + ec01926e5a9dc16e200060497c43e79a1623698d "Avoid setting a singular + ctm" + introduced a regression in the output when using a ctm. + + The check for an invertable matrix had the side effect of inverting + the matrix. Instead, make a copy of the matrix before testing if it is + invertable. + + poppler/CairoOutputDev.cc | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +commit 0b2c3bb25c908b07e760d824dbfe93c6051812aa +Merge: 362fe01 9c472f7 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Wed Mar 12 00:23:58 2008 +0100 + + Merge branch 'master' of + ssh://inigomartinez@git.freedesktop.org/git/poppler/poppler + +commit 362fe013c0d96698b52d70cf5226cddca7fe52d4 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Wed Mar 12 00:07:12 2008 +0100 + + Enabled back the AnnotWidget support. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 9c472f76d2462d0e775c851fdbac6ca2bc9812ea +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 12 00:00:20 2008 +0100 + + cmake build + + glib/demo/CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit 821858f5c36786955d9475044bfee57f5060ad2f +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 11 23:58:05 2008 +0100 + + Return char bounding box instead of edge, it's much more useful for + character positioning + + qt4/src/poppler-page.cc | 8 ++++++-- + qt4/src/poppler-private.h | 3 +-- + qt4/src/poppler-qt4.h | 6 ++---- + qt4/src/poppler-textbox.cc | 4 ++-- + 4 files changed, 11 insertions(+), 10 deletions(-) + +commit d7e642732ced592362d9787bddadb7a110dcc5a5 +Merge: 3642f0c 2d6c605 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Tue Mar 11 23:41:59 2008 +0100 + + Merge branch 'master' of + ssh://inigomartinez@git.freedesktop.org/git/poppler/poppler + +commit 3642f0c48bc49cd4d698e769544c1d8604c6482f +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Tue Mar 11 23:13:33 2008 +0100 + + glib annots demo. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + glib/demo/Makefile.am | 2 + + glib/demo/annots.c | 468 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + glib/demo/annots.h | 31 ++++ + glib/demo/main.c | 4 +- + 4 files changed, 504 insertions(+), 1 deletion(-) + +commit 2d6c60537317bd3ac9e0582e0da09e7365729097 +Author: Pino Toscano <pino@kde.org> +Date: Tue Mar 11 22:54:44 2008 +0100 + + For now we cannot handle MovieLink's, so comment them out. + + qt4/src/poppler-annotation.cc | 2 ++ + qt4/src/poppler-link.cc | 4 ++++ + qt4/src/poppler-link.h | 2 ++ + 3 files changed, 8 insertions(+) + +commit a354f7198c493990613a1db131c662ec27948863 +Author: Hugo Mercier <hmercier31@gmail.com> +Date: Tue Mar 11 22:49:00 2008 +0100 + + Initial Movie support (2) + + Now with the forgotten files + + poppler/Movie.cc | 443 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Movie.h | 177 ++++++++++++++++++++++ + 2 files changed, 620 insertions(+) + +commit 43e5dd941d4bc35c4eebbad66c13235639e0c1a0 +Merge: aab1768 4fdd254 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 11 22:31:22 2008 +0100 + + Merge branch 'master' of + ssh://aacid@git.freedesktop.org/git/poppler/poppler + +commit 4fdd254370ea6055e95c8ebee51b69e06c501714 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Mar 11 22:31:00 2008 +0100 + + Fix build + + glib/poppler-page.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit aab17684dc3f21ff2b1ee6eacdc0c565d368df78 +Author: Hugo Mercier <hmercier31@gmail.com> +Date: Tue Mar 11 22:28:28 2008 +0100 + + Initial Movie support + + CMakeLists.txt | 2 + + poppler/Annot.cc | 316 + +++++++++++++++++++++++++++++++++++++++++++++++++++- + poppler/Annot.h | 125 +++++++++++++++++++++ + poppler/Link.cc | 108 +++++++++++++++--- + poppler/Link.h | 64 ++++++++++- + poppler/Makefile.am | 2 + + 6 files changed, 591 insertions(+), 26 deletions(-) + +commit 13a0d2390b9e4684af070c213f385485715353df +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 11 22:27:38 2008 +0100 + + Add poppler-annot to the cmake build system + + glib/CMakeLists.txt | 2 ++ + 1 file changed, 2 insertions(+) + +commit 19f0e3b40bce4d8157d8c8bd04eaf6bacbef38b8 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Tue Mar 11 22:09:04 2008 +0100 + + Add preliminary annotations support in the glib frontend + + glib/Makefile.am | 2 + + glib/poppler-annot.cc | 776 + +++++++++++++++++++++++++++++++++++++++++++++++++ + glib/poppler-annot.h | 181 ++++++++++++ + glib/poppler-page.cc | 166 +++++++++++ + glib/poppler-page.h | 15 + + glib/poppler-private.h | 5 +- + glib/poppler.h | 7 + + 7 files changed, 1151 insertions(+), 1 deletion(-) + +commit 6fa3ab20fee311b4aff92be18870fd0e1730a81f +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Tue Mar 11 18:44:27 2008 +0100 + + Changed AnnotMarkup inheritance + + poppler/Annot.cc | 9 +++++---- + poppler/Annot.h | 10 +++++----- + 2 files changed, 10 insertions(+), 9 deletions(-) + +commit 3111cfe2ccb32f9680baaad0c3f0678dd5969f8b +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 10 22:12:36 2008 +0100 + + And free the memory + + qt4/tests/test-poppler-qt4.cpp | 2 ++ + 1 file changed, 2 insertions(+) + +commit 58f88c23402ac2e678dc655f64d93d89bb1812be +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 10 22:08:43 2008 +0100 + + Add the -textRects option to the test app so we can check text rects + are correct + + qt4/tests/test-poppler-qt4.cpp | 45 + +++++++++++++++++++++++++++++++++++++----- + 1 file changed, 40 insertions(+), 5 deletions(-) + +commit 94ceb3cae79dc7786fa59fd889a87160780ed5df +Merge: 0f9e843 35f34bd +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Mar 9 23:34:11 2008 +0100 + + Merge branch 'master' of + ssh://aacid@git.freedesktop.org/git/poppler/poppler + +commit 0f9e84302ac2108f05bdbb10e7e57ae19ad1e9f3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Mar 9 23:33:11 2008 +0100 + + Do not force default values to fontconfig patterns as fontconfig + already fills in default values for us + + Fixes bug 14883 + + poppler/GlobalParams.cc | 17 +++++++++-------- + 1 file changed, 9 insertions(+), 8 deletions(-) + +commit 35f34bd44c74eeb76a58b30acfbb0303d7285f06 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Mar 9 17:38:54 2008 +0100 + + Fix build when compiling without cairo support + + glib/demo/images.c | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 32637db19dd80a9b8452f86eb677b10e77290627 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Mar 9 00:57:08 2008 +0100 + + proper lib64 Qt detection + + Fixes bug 14583 + + m4/qt.m4 | 15 ++++++++++++--- + 1 file changed, 12 insertions(+), 3 deletions(-) + +commit 65a88a95a5c54c890048e8a986df361585d601dd +Author: Pino Toscano <pino@kde.org> +Date: Sat Mar 8 03:11:36 2008 +0100 + + Provide the mime type for an embedded file, if known. + + Adapt the unit test for that. + + qt4/src/poppler-embeddedfile.cc | 5 +++++ + qt4/src/poppler-qt4.h | 5 +++++ + qt4/tests/check_attachments.cpp | 7 +++++++ + 3 files changed, 17 insertions(+) + +commit 23da27a229c8b3cc2a0a0dd6354c40723934390c +Author: Pino Toscano <pino@kde.org> +Date: Sat Mar 8 03:10:58 2008 +0100 + + Optionally read the mimetype for the embedded files. + + poppler/Catalog.cc | 17 +++++++++-------- + poppler/Catalog.h | 7 ++++++- + 2 files changed, 15 insertions(+), 9 deletions(-) + +commit 42c254b978c61e2ccfda083dfeffec9fc35a5fe7 +Author: Pino Toscano <pino@kde.org> +Date: Mon Mar 3 16:56:09 2008 +0100 + + be safe about out-of-range values + + qt4/src/poppler-textbox.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5db75df77938eb7620867d0618058be52ed2d3cb +Author: Pino Toscano <pino@kde.org> +Date: Mon Mar 3 16:53:39 2008 +0100 + + initialize nicely + + qt4/src/poppler-private.h | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 3ad0ab7e4abd37528284269c69be3cdfb8d31d2e +Author: Pino Toscano <pino@kde.org> +Date: Mon Mar 3 16:49:23 2008 +0100 + + apidox + + qt4/src/poppler-link.h | 17 +++++++++++++++++ + qt4/src/poppler-qt4.h | 23 ++++++++++++++++++++++- + 2 files changed, 39 insertions(+), 1 deletion(-) + +commit ec01926e5a9dc16e200060497c43e79a1623698d +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sun Mar 2 20:15:20 2008 -0500 + + Avoid setting a singular ctm + + Ignoring singular ctm's gives a better result than having + our cairo context error and turn off. Related to #14398. + + poppler/CairoOutputDev.cc | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +commit 4882d7a118b93fdb5c441d70757e485be7ee25d7 +Author: Pino Toscano <pino@kde.org> +Date: Thu Feb 28 15:12:23 2008 +0100 + + printf -> qDebug + + qt4/src/poppler-optcontent.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 31ce4049bf12c2716be7ec0fb8eda502d989f66e +Author: Brad Hards <bradh@saxicola.cuneata.net> +Date: Thu Feb 28 22:09:30 2008 +1100 + + Respect PageMode for optional content and embedded files. + + This makes the PDF 1.7 spec open with the embedded files showing. + + qt4/demos/embeddedfiles.cpp | 7 +++++++ + qt4/demos/embeddedfiles.h | 1 + + qt4/demos/optcontent.cpp | 8 ++++++++ + qt4/demos/optcontent.h | 1 + + 4 files changed, 17 insertions(+) + +commit ff938c431799d49325c0f46f1e6cbe1033993a83 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 27 23:12:53 2008 +0100 + + do not forget to distribute GlobalParamsWin.cc next time + + poppler/Makefile.am | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 277382b8186d137a9f2a62bc2d22e9f0cda7d923 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 27 22:56:33 2008 +0100 + + fix typo + + glib/demo/images.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5b2f8f21fca63508570a0c77c6f7221a322e6e57 +Merge: 7e65118 4254f12 +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 22:10:12 2008 +0100 + + Merge branch 'master' of + ssh://pino@git.freedesktop.org/git/poppler/poppler + +commit 7e651186f483976f9833de245b6c7add38e77a16 +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 22:03:17 2008 +0100 + + Properly enable/disable the contents when their parents are changed. + + Now, the children maintain the "checked state" they had, when their + parent is unchecked; + but, they are really disabled, both in the possibility to be checked + and in the drawing of their associated content [applying the same + to their children, and so on]. + + qt4/src/poppler-optcontent-private.h | 8 +++++++- + qt4/src/poppler-optcontent.cc | 37 + +++++++++++++++++++++++++++++++----- + 2 files changed, 39 insertions(+), 6 deletions(-) + +commit 4254f1237ebed09b8e1c85f935a20bde3d8f36ff +Merge: ed6c0c2 0569ae7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 27 20:44:27 2008 +0100 + + Merge branch 'master' of + ssh://aacid@git.freedesktop.org/git/poppler/poppler + +commit 8d384c06f96ba8cb3e73c275b3c708c64da4595d +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 20:39:09 2008 +0100 + + small header cleanup + + qt4/src/poppler-optcontent-private.h | 9 +++++++-- + qt4/src/poppler-optcontent.cc | 7 ++++--- + 2 files changed, 11 insertions(+), 5 deletions(-) + +commit ed6c0c260837a0025279765ef7778b83d6ee2209 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 27 20:43:45 2008 +0100 + + fix build and distcheck with autools + + qt4/demos/Makefile.am | 3 +++ + qt4/src/Makefile.am | 5 ++++- + qt4/tests/Makefile.am | 3 +++ + 3 files changed, 10 insertions(+), 1 deletion(-) + +commit 344d55539b1b6bcabec609fd828db372a07491b4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 27 20:43:13 2008 +0100 + + fill the NEWS for 0.7.1 + + NEWS | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +commit 1c47633ba782021978fa34d41a4ab0badf3af9d3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 27 20:42:55 2008 +0100 + + Increase version number to 0.7.1 + + CMakeLists.txt | 2 +- + configure.ac | 2 +- + msvc/config.h | 6 +++--- + qt4/src/Doxyfile | 2 +- + 4 files changed, 6 insertions(+), 6 deletions(-) + +commit 0569ae76b6af1723b4606af189242a23199f387d +Merge: f395531 d8eba8c +Author: Brad Hards <bradh@kde.org> +Date: Thu Feb 28 06:26:09 2008 +1100 + + Merge branch 'master' of + ssh://bradh@git.freedesktop.org/git/poppler/poppler + +commit d8eba8c10834116b4f0f295375805172f5216993 +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 19:07:46 2008 +0100 + + export the OptContentModel + + qt4/src/poppler-optcontent.h | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 0445e64a4124af7c1b84673f237022e133eb8542 +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 19:04:03 2008 +0100 + + make only the Document able to create OptContentsModel's + + qt4/src/poppler-optcontent.h | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit c965437b67a4f97ee8365a217bd10406fba3767a +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 18:58:31 2008 +0100 + + setRootNode() is private (and unused) API + + qt4/src/poppler-optcontent-private.h | 2 ++ + qt4/src/poppler-optcontent.cc | 8 ++++---- + qt4/src/poppler-optcontent.h | 4 ---- + 3 files changed, 6 insertions(+), 8 deletions(-) + +commit e293bfc384e2dfc4ef04582053ce18d8c0bcb7b3 +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 18:50:35 2008 +0100 + + small cleanup + + qt4/src/poppler-optcontent.cc | 11 ++++------- + 1 file changed, 4 insertions(+), 7 deletions(-) + +commit f11aa0008585e845ce509172d76f72f941be497d +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 18:44:09 2008 +0100 + + adapt the tests to the new layout of the contents model + + qt4/tests/check_optcontent.cpp | 66 + +++++++++++++++--------------------------- + 1 file changed, 23 insertions(+), 43 deletions(-) + +commit 4a324484b5c77ddc348746e7bcf6051ade28e389 +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 18:04:52 2008 +0100 + + free some objects (thus leak less) + + poppler/Gfx.cc | 2 ++ + poppler/OptionalContent.cc | 2 ++ + 2 files changed, 4 insertions(+) + +commit 0f4e7791ab6884072a1aee56e9cec212d8cea263 +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 15:58:21 2008 +0100 + + ignore any generated .moc here + + qt4/src/.gitignore | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 136ae44f155b17d9e8b041b67f75531d8544337c +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 15:56:09 2008 +0100 + + keep track of the items changed when toggling an item, so we can + update them properly + + qt4/src/poppler-optcontent-private.h | 4 ++-- + qt4/src/poppler-optcontent.cc | 38 + ++++++++++++++++++++++++++++-------- + 2 files changed, 32 insertions(+), 10 deletions(-) + +commit b73e2afef7e5e1b68d82a10c94bca3c201c5f8b3 +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 15:52:06 2008 +0100 + + fix indexFromItem once again, and make parent() call it with the + right node + + qt4/src/poppler-optcontent-private.h | 2 +- + qt4/src/poppler-optcontent.cc | 19 +++++++++---------- + 2 files changed, 10 insertions(+), 11 deletions(-) + +commit 803787f763578320aa5f405ed49c64e6b924bad3 +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 15:30:18 2008 +0100 + + compile with the autotools + + (second patch I forgot to apply with the first) + + qt4/src/Makefile.am | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +commit 0b527a8ed62677bb09df4587f072a310c2959750 +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 14:34:13 2008 +0100 + + Extract the OptContentItem -> QModelIndex creation in an own function. + + qt4/src/poppler-optcontent-private.h | 1 + + qt4/src/poppler-optcontent.cc | 7 ++++++- + 2 files changed, 7 insertions(+), 1 deletion(-) + +commit c94d6cc95c6838f31e27832cb3090389bf4d8227 +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 14:30:26 2008 +0100 + + Make index(), data() and setData() more safe. + + Errors spotted using ModelTest. + + qt4/src/poppler-optcontent-private.h | 2 +- + qt4/src/poppler-optcontent.cc | 15 +++++++++------ + 2 files changed, 10 insertions(+), 7 deletions(-) + +commit b8e833733d84eaa93d6bae522710feb3075ca329 +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 14:05:19 2008 +0100 + + fix build with the autotools + + qt4/src/Makefile.am | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit f89ba474bae281f1cdeddb72ac8425dee1087e35 +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 13:28:50 2008 +0100 + + Put the check states of the optional contents in the same column as + the name. + + This feels a bit more elegant than changing a value in a different + column. + Cleanup data()/setData() so they can be extended easily. + + qt4/src/poppler-optcontent.cc | 74 + ++++++++++++++++++++++--------------------- + 1 file changed, 38 insertions(+), 36 deletions(-) + +commit defa0ecb2790402a4069fea3b3c285a50675682d +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 12:24:16 2008 +0100 + + Add a skeleton of OptContentModel::headerData(). + + It does nothing yet, but we can add stuff later on w/o breaking BC. + + qt4/src/poppler-optcontent.cc | 5 +++++ + qt4/src/poppler-optcontent.h | 2 ++ + 2 files changed, 7 insertions(+) + +commit f395531a3e8f71a46b3c942f8f437ade1d9fdb57 +Author: Brad Hards <bradh@kde.org> +Date: Wed Feb 27 22:22:51 2008 +1100 + + Minor cleanup. + + qt4/src/poppler-optcontent.cc | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +commit 0a19486cb4de57c0c987cc4ce2434a96bbd18338 +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 12:15:44 2008 +0100 + + refresh the current page when the data of the content model change + + qt4/demos/optcontent.cpp | 8 ++++++++ + qt4/demos/optcontent.h | 3 +++ + 2 files changed, 11 insertions(+) + +commit 09b7cc2efb7d21fa4dabd23d2d2de877cc7d86ee +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 12:15:18 2008 +0100 + + optional method to reload the current page + + qt4/demos/documentobserver.cpp | 5 +++++ + qt4/demos/documentobserver.h | 1 + + 2 files changed, 6 insertions(+) + +commit 39fe905be8f2ae79d9c26cd87547f3ea2608411e +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 12:00:29 2008 +0100 + + Add a dock for showing the optional content tree. + + qt4/demos/CMakeLists.txt | 1 + + qt4/demos/Makefile.am | 3 +++ + qt4/demos/optcontent.cpp | 55 + ++++++++++++++++++++++++++++++++++++++++++++++++ + qt4/demos/optcontent.h | 43 +++++++++++++++++++++++++++++++++++++ + qt4/demos/viewer.cpp | 7 ++++++ + 5 files changed, 109 insertions(+) + +commit f17dd5539501a996479b903ac9b8aceb3c4cfafe +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 11:53:32 2008 +0100 + + cleanup + + qt4/src/poppler-optcontent-private.h | 3 ++- + qt4/src/poppler-optcontent.h | 4 +--- + 2 files changed, 3 insertions(+), 4 deletions(-) + +commit f3cc894559f10dbd4277fa9f30de9931ed69dfd4 +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 11:43:34 2008 +0100 + + OptContentModel::itemFromRef() and OptContentItem are private API. + + Hide them in the implementation. + + qt4/src/poppler-optcontent-private.h | 43 + ++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-optcontent.cc | 8 +++---- + qt4/src/poppler-optcontent.h | 42 + ----------------------------------- + 3 files changed, 47 insertions(+), 46 deletions(-) + +commit 48e8b2105cf8f177ca655b969470e45e2407db82 +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 11:28:16 2008 +0100 + + move all the private stuff of OptContentModel into its d-pointer + + qt4/src/poppler-optcontent-private.h | 9 +++++++-- + qt4/src/poppler-optcontent.cc | 29 +++++++++++++++-------------- + qt4/src/poppler-optcontent.h | 4 ---- + 3 files changed, 22 insertions(+), 20 deletions(-) + +commit b78a7f7a0e8d5a9c22014d34754090d863030e0d +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 27 11:06:57 2008 +0100 + + use a QPointer for the OptContentModel, so we are safe about + ownership. + + qt4/src/poppler-document.cc | 4 ++-- + qt4/src/poppler-private.h | 6 +++--- + 2 files changed, 5 insertions(+), 5 deletions(-) + +commit 48557da71adb0fe6bd4da2fb32433796a96c3576 +Author: Brad Hards <bradh@kde.org> +Date: Wed Feb 27 19:39:18 2008 +1100 + + We need to install the optional content header. + + qt4/src/CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit 6e2bb03b5ef256c03a8da1cbf9bbc87c593942ad +Author: Brad Hards <bradh@kde.org> +Date: Wed Feb 27 19:23:49 2008 +1100 + + Partial d-pointer implementation. + + qt4/src/poppler-optcontent-private.h | 57 + ++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-optcontent.cc | 49 +++++++++++++++++++------------ + qt4/src/poppler-optcontent.h | 24 ++++----------- + 3 files changed, 92 insertions(+), 38 deletions(-) + +commit c627b7aa10ae9cdceb78b751a7e826170f402af0 +Author: Brad Hards <bradh@kde.org> +Date: Wed Feb 27 16:12:38 2008 +1100 + + A couple of cleanups suggested by Pino. + + qt4/src/poppler-document.cc | 6 +++--- + qt4/src/poppler-qt4.h | 8 +++++--- + 2 files changed, 8 insertions(+), 6 deletions(-) + +commit 81891667e18fcf164af02f5f366de07f78d67c8f +Author: Brad Hards <bradh@kde.org> +Date: Wed Feb 27 15:47:03 2008 +1100 + + Add in the initial part of the optional content support. + + To see this work, compare ClarityOCGs.pdf with and + without this change. + + Right now we only handle optional content using + XObjects. Optional content using Marked Content has + infrastructure, but is not implemented. That will be + quite invasive in Gfx, and I'm not confident enough + to do it this late in the process. + + CMakeLists.txt | 1 + + poppler/Catalog.cc | 9 + + poppler/Catalog.h | 4 + + poppler/Gfx.cc | 65 +++++- + poppler/Gfx.h | 12 +- + poppler/Makefile.am | 2 + + poppler/OptionalContent.cc | 322 ++++++++++++++++++++++++++ + poppler/OptionalContent.h | 85 +++++++ + poppler/PDFDoc.h | 5 + + poppler/PSOutputDev.cc | 6 +- + poppler/Page.cc | 2 +- + qt4/src/.gitignore | 1 + + qt4/src/CMakeLists.txt | 3 + + qt4/src/Makefile.am | 6 + + qt4/src/poppler-document.cc | 13 ++ + qt4/src/poppler-optcontent.cc | 354 +++++++++++++++++++++++++++++ + qt4/src/poppler-optcontent.h | 122 ++++++++++ + qt4/src/poppler-private.h | 4 + + qt4/src/poppler-qt4.h | 18 ++ + qt4/tests/.gitignore | 1 + + qt4/tests/CMakeLists.txt | 1 + + qt4/tests/Makefile.am | 5 + + qt4/tests/check_optcontent.cpp | 499 + +++++++++++++++++++++++++++++++++++++++++ + 23 files changed, 1532 insertions(+), 8 deletions(-) + +commit 11b70bcda905e618c199a067db6b0246612e101d +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 26 23:01:27 2008 +0100 + + fixup the default export macro name (added by cmake); _WIN32 is + defined only on win32 (remove a plethora of warnings) + + qt4/src/poppler-export.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit d4d6c14cd83d04c61daa6618c3148a0bb47dc292 +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 26 22:57:02 2008 +0100 + + install the export header + + qt4/src/CMakeLists.txt | 1 + + qt4/src/Makefile.am | 1 + + 2 files changed, 2 insertions(+) + +commit 4ba2e2d21710135656adbf93c5994cfb46502308 +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 26 22:55:30 2008 +0100 + + no need to include the export header in private headers + + qt4/src/poppler-annotation-helper.h | 1 - + qt4/src/poppler-annotation-private.h | 1 - + qt4/src/poppler-converter-private.h | 1 - + qt4/src/poppler-link-extractor-private.h | 1 - + qt4/src/poppler-page-private.h | 1 - + qt4/src/poppler-private.h | 1 - + qt4/src/poppler-qiodeviceoutstream-private.h | 1 - + 7 files changed, 7 deletions(-) + +commit 0a466c09fb70b92f39df19bc315b6575e419ad5b +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 26 22:47:31 2008 +0100 + + We also need to distribute poppler-export.h + + qt4/src/Makefile.am | 1 + + 1 file changed, 1 insertion(+) + +commit 2034d57c700049bc9a6565bbb818e1c9f4467784 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 26 22:46:29 2008 +0100 + + Now for real: Add special casing in cmake buildsystem for MSVC, + also add Export markers to qt4 classes, although symbol visibility + is only used on MSVC at the moment + + CMakeLists.txt | 5 +++++ + qt4/src/CMakeLists.txt | 3 +++ + qt4/src/poppler-annotation-helper.h | 1 + + qt4/src/poppler-annotation-private.h | 1 + + qt4/src/poppler-annotation.h | 19 ++++++++++--------- + qt4/src/poppler-converter-private.h | 1 + + qt4/src/poppler-export.h | 6 +++--- + qt4/src/poppler-form.h | 9 +++++---- + qt4/src/poppler-link-extractor-private.h | 1 + + qt4/src/poppler-link.h | 17 +++++++++-------- + qt4/src/poppler-page-private.h | 1 + + qt4/src/poppler-private.h | 1 + + qt4/src/poppler-qiodeviceoutstream-private.h | 1 + + qt4/src/poppler-qt4.h | 21 +++++++++++---------- + qt4/tests/CMakeLists.txt | 6 ++++++ + 15 files changed, 59 insertions(+), 34 deletions(-) + +commit b931920f63f4276ec355118faa061bafa5ac5244 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 26 22:42:16 2008 +0100 + + Add special casing in cmake buildsystem for MSVC, also add Export + markers to qt4 classes, although symbol visibility is only used on + MSVC at the moment + + qt4/src/poppler-export.h | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +commit 1778fddb36d6cb2c7f7848bee06189158f69f16e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 24 23:02:08 2008 +0100 + + Add the cmake files to EXTRA_DIST so they get added when i do make + dist to get the release tarball + + Makefile.am | 39 +++++++++++++++++++++++++++++++++++++++ + 1 file changed, 39 insertions(+) + +commit 51f171e10a42d492c8c32a5e2578d05b73d89238 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 24 22:47:46 2008 +0100 + + ignore more + + qt4/demos/.gitignore | 2 ++ + 1 file changed, 2 insertions(+) + +commit adb1ccdb9265f0583cb348c456a39efac610aff1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 24 22:46:33 2008 +0100 + + ignore + + qt4/demos/.gitignore | 2 ++ + 1 file changed, 2 insertions(+) + +commit 101e526c63175ffc1a75e1b68da7bb4fff9cd530 +Author: Patrick Spendrin <ps_ml@gmx.de> +Date: Sun Feb 24 20:52:41 2008 +0100 + + define snprintf to _snprintf if we are building on MSVC + + config.h.cmake | 4 ++++ + 1 file changed, 4 insertions(+) + +commit f7f8ab488257c3979d20e5c0690ec5d7c2cd831b +Author: Patrick Spendrin <ps_ml@gmx.de> +Date: Sun Feb 24 20:43:11 2008 +0100 + + define M_PI in case it is not defined + + poppler/Function.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit f00436b63bf9a42dcb2728a07db9c20f1f23d0bc +Author: Patrick Spendrin <ps_ml@gmx.de> +Date: Sun Feb 24 20:39:42 2008 +0100 + + Add proper dirent.h guards + + utils/pdftoabw.cc | 2 ++ + utils/pdftohtml.cc | 2 ++ + 2 files changed, 4 insertions(+) + +commit e1463451c584181f918265438cf6ddcb408bf731 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Feb 21 20:43:56 2008 +0100 + + Code uses if USE_EXCEPTIONS, so we need to defined it to 1, not just + define it + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 88d4bbbcf828e3247454c8ba3c2fb0fb58207b6a +Author: Michael Vrable <mvrable@cs.ucsd.edu> +Date: Thu Feb 21 19:53:03 2008 +0100 + + If a bitmap's dimensions are invalid, do not try to display it. + + poppler/Gfx.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 452ae6f5674b00b43955952961f7ca0583f73e27 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Feb 21 19:46:19 2008 +0100 + + Make sure we don't draw outside the bitmap on Splash::fillGlyph2 + + splash/Splash.cc | 76 + ++++++++++++++++++++++++++++++++++++-------------------- + 1 file changed, 49 insertions(+), 27 deletions(-) + +commit 7f60fa806bd6d3d28917f349a2a19b52f97f593a +Author: James Cloos <cloos@jhcloos.com> +Date: Thu Feb 21 13:00:05 2008 -0500 + + Fix typo + + Signed-off-by: James Cloos <cloos@jhcloos.com> + + qt4/demos/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 053ecae534a4522d152b0139b6aed6da2059d760 +Author: Carl Worth <cworth@cworth.org> +Date: Wed Feb 20 17:21:27 2008 -0800 + + Keep cairo and cairo_shape consistent + + The 'cairo_shape' state was not always being modified at the same + time as 'cairo'. In some cases this led to a sequence of ever + larger matrix scale factors until things just blew up. + + poppler/CairoOutputDev.cc | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit bf6dd890994150406b4464e45355a4a99870fc60 +Author: Pino Toscano <pino@kde.org> +Date: Thu Feb 21 01:23:07 2008 +0100 + + Add a dock for showing the document metadata. + + qt4/demos/CMakeLists.txt | 1 + + qt4/demos/Makefile.am | 3 +++ + qt4/demos/metadata.cpp | 50 + ++++++++++++++++++++++++++++++++++++++++++++++++ + qt4/demos/metadata.h | 43 +++++++++++++++++++++++++++++++++++++++++ + qt4/demos/viewer.cpp | 7 +++++++ + 5 files changed, 104 insertions(+) + +commit b6f0c8f83924c08be20b602b128651bf018172a3 +Author: Pino Toscano <pino@kde.org> +Date: Thu Feb 21 00:54:26 2008 +0100 + + Do not assign conflicting accelerators. + + qt4/demos/viewer.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e0c27a968c7e7a0f6a89a050ddbfe328229f431d +Author: Pino Toscano <pino@kde.org> +Date: Thu Feb 21 00:53:24 2008 +0100 + + Apply the antialias settings w/o notify the observers. + + qt4/demos/viewer.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 2c6149abcecda15c6f73a1dee537072240ddd545 +Author: Pino Toscano <pino@kde.org> +Date: Thu Feb 21 00:51:21 2008 +0100 + + Add a settings menu to choose the render backend. + + qt4/demos/viewer.cpp | 28 ++++++++++++++++++++++++++++ + qt4/demos/viewer.h | 3 +++ + 2 files changed, 31 insertions(+) + +commit db2b0778dca364751a1d22294be29f8c7799e2e9 +Author: Pino Toscano <pino@kde.org> +Date: Thu Feb 21 00:33:23 2008 +0100 + + Add a dock for showing the embedded files. + + TODO: show the checksum in a pretty format. + + qt4/demos/CMakeLists.txt | 1 + + qt4/demos/Makefile.am | 3 ++ + qt4/demos/embeddedfiles.cpp | 75 + +++++++++++++++++++++++++++++++++++++++++++++ + qt4/demos/embeddedfiles.h | 43 ++++++++++++++++++++++++++ + qt4/demos/viewer.cpp | 7 +++++ + 5 files changed, 129 insertions(+) + +commit 51fba47ccb12a66282769fc504bac4c9f5123f75 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 17 01:49:59 2008 +0100 + + clear the page label when the document is closed + + qt4/demos/pageview.cpp | 2 ++ + 1 file changed, 2 insertions(+) + +commit e964e2b9fbbe9b52b137ecd06729a06530835227 +Author: Michael Vrable <mvrable@cs.ucsd.edu> +Date: Tue Feb 19 23:22:55 2008 +0100 + + Allow grouped checkboxes to be selected individually. + + When checkboxes are in a group, they ought to behave like a + collection of + radio buttons. However, when deciding whether to draw a checkbox as + selected or not, the checkbox-drawing code was looking up the value + of the + V field in the form dictionary, which is shared among all checkboxes + in the + group. Thus, checkboxes would either all be on or off in unison. + + Instead, look up the AS (appearance state) value in each checkbox's + annotation dictionary, so that different checkboxes can be drawn + differently. + + poppler/Annot.cc | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +commit 702fdd6c56b5369554c683d8c8e0e2c66e80886c +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 19 00:18:04 2008 +0100 + + changes from gtk-doc + + glib/reference/tmpl/poppler-document.sgml | 1 + + glib/reference/tmpl/poppler-page.sgml | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +commit 9e13b91ba38c20989d283588e73490a1601f5bb0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Feb 19 00:10:24 2008 +0100 + + distribute the headers too + + qt4/demos/Makefile.am | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +commit 194e0ced7c38514ec3126666531862e3b29b4b77 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Feb 18 23:34:06 2008 +0100 + + Fill NEWS and increase version number to 0.7 + + CMakeLists.txt | 2 +- + NEWS | 96 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + configure.ac | 2 +- + msvc/config.h | 6 ++-- + qt4/src/Doxyfile | 2 +- + 5 files changed, 102 insertions(+), 6 deletions(-) + +commit 3c407efe9f1f0cc3f6366d3a2b6e9b687656cc95 +Merge: 51f0cea 7f4acb8 +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 18 21:30:42 2008 +0100 + + Merge branch 'master' of + ssh://pino@git.freedesktop.org/git/poppler/poppler + +commit 51f0cea0e3ba1acfc63877752e950fdd8c07e258 +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 18 21:29:41 2008 +0100 + + make the poppler_qt4viewer compile with the auto"tools" + + qt4/demos/Makefile.am | 16 ++++++++++++---- + 1 file changed, 12 insertions(+), 4 deletions(-) + +commit 7f4acb879d300e18dfaff768027c88195d7d8f1b +Author: Timothy Lee <timothy.lee@siriushk.com> +Date: Mon Feb 18 20:56:35 2008 +0100 + + Implement ImageOutputDev::drawMaskedImage and + ImageOutputDev::drawSoftMaskedImage so all images are exported when + using pdfimages + + utils/ImageOutputDev.cc | 19 +++++++++++++++++++ + utils/ImageOutputDev.h | 11 +++++++++++ + 2 files changed, 30 insertions(+) + +commit 064b316648e35416bb49336639da1d8d288d1ecf +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Feb 18 20:17:37 2008 +0100 + + xref can be null so check for it before checking we went out of bounds + + Fixes bug 14549 + + poppler/Lexer.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit b287b611b1c7b7dd00e12518cee3a6c35044e161 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 17 01:21:07 2008 +0100 + + Really niptick: help menu with about dialog for us and Qt. + + qt4/demos/viewer.cpp | 15 +++++++++++++++ + qt4/demos/viewer.h | 2 ++ + 2 files changed, 17 insertions(+) + +commit 6400254fdabf3d0d32f27ebd00faa6958be62019 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 17 01:12:27 2008 +0100 + + Add a title to the viewer :) + + qt4/demos/viewer.cpp | 2 ++ + 1 file changed, 2 insertions(+) + +commit b363c0568c9c61e7ee8ed86d808f0eed0b93b525 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 17 01:09:57 2008 +0100 + + Add the possibility to save a copy of the file. + + qt4/demos/viewer.cpp | 29 +++++++++++++++++++++++++++++ + qt4/demos/viewer.h | 2 ++ + 2 files changed, 31 insertions(+) + +commit 42987dcdd8d7432145f78cfc550f0c099e6e7311 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 17 00:33:01 2008 +0100 + + Add a Permissions dock. + + qt4/demos/CMakeLists.txt | 1 + + qt4/demos/Makefile.am | 1 + + qt4/demos/permissions.cpp | 77 + +++++++++++++++++++++++++++++++++++++++++++++++ + qt4/demos/permissions.h | 43 ++++++++++++++++++++++++++ + qt4/demos/viewer.cpp | 7 +++++ + 5 files changed, 129 insertions(+) + +commit 9d1dda64de1d9e3f6fc81e40a0c2246a6270dfa8 +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 16 23:56:17 2008 +0100 + + Add settings for antialias. + + qt4/demos/viewer.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ + qt4/demos/viewer.h | 4 ++++ + 2 files changed, 45 insertions(+) + +commit 3abb8703d7d8b7a5fbcbb3c19d8e84d640abe88c +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 16 22:25:11 2008 +0100 + + Add a TOC info dock. + + qt4/demos/CMakeLists.txt | 1 + + qt4/demos/Makefile.am | 1 + + qt4/demos/toc.cpp | 90 + ++++++++++++++++++++++++++++++++++++++++++++++++ + qt4/demos/toc.h | 43 +++++++++++++++++++++++ + qt4/demos/viewer.cpp | 7 ++++ + 5 files changed, 142 insertions(+) + +commit 80925f06d125ebfc9909e36bdbe5d37fd0e48bdc +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 16 21:51:10 2008 +0100 + + Adapt the Fonts and Info docks to the new abstract info dock. + + qt4/demos/fonts.cpp | 10 +++------- + qt4/demos/fonts.h | 11 +++++------ + qt4/demos/info.cpp | 10 +++------- + qt4/demos/info.h | 11 +++++------ + 4 files changed, 16 insertions(+), 26 deletions(-) + +commit c03531d691e56aba2b4c6538cf9e2463e1e0aa29 +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 16 21:43:19 2008 +0100 + + Introduce a base info dock for handling the "dirty" work. + + qt4/demos/CMakeLists.txt | 1 + + qt4/demos/Makefile.am | 1 + + qt4/demos/abstractinfodock.cpp | 57 + ++++++++++++++++++++++++++++++++++++++++++ + qt4/demos/abstractinfodock.h | 48 +++++++++++++++++++++++++++++++++++ + 4 files changed, 107 insertions(+) + +commit 0f7d51c7fc2439ee9392c166576c341238f00f36 +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 16 18:49:52 2008 +0100 + + Delete the poppler page after usage. + + qt4/demos/pageview.cpp | 1 + + 1 file changed, 1 insertion(+) + +commit b41d069cdd1435ddb14b3de2986875069523c814 +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 16 18:48:57 2008 +0100 + + Initialize the current page number correctly. + + qt4/demos/viewer.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 75e516af0e72a2e3041660300e522ad00869372b +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 16 18:43:56 2008 +0100 + + Add a side dock for showing the fonts of the document. + + qt4/demos/CMakeLists.txt | 1 + + qt4/demos/Makefile.am | 1 + + qt4/demos/fonts.cpp | 78 + ++++++++++++++++++++++++++++++++++++++++++++++++ + qt4/demos/fonts.h | 44 +++++++++++++++++++++++++++ + qt4/demos/viewer.cpp | 7 +++++ + 5 files changed, 131 insertions(+) + +commit 8e642d1cbd48d4790a6769287cbfd90c3bc9fc34 +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 16 17:21:30 2008 +0100 + + Add a View menu where the dock widget toogle actions will be. + + As start, put the Info dock there. + + qt4/demos/viewer.cpp | 4 ++++ + 1 file changed, 4 insertions(+) + +commit c1feb7c2b5008cc04edb3c028f888072920ce4dc +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 16 17:14:00 2008 +0100 + + Add a side dock for showing the info keys. + + qt4/demos/CMakeLists.txt | 1 + + qt4/demos/Makefile.am | 1 + + qt4/demos/info.cpp | 78 + ++++++++++++++++++++++++++++++++++++++++++++++++ + qt4/demos/info.h | 44 +++++++++++++++++++++++++++ + qt4/demos/viewer.cpp | 5 ++++ + 5 files changed, 129 insertions(+) + +commit abc9b00c6470f9f6b66c280455f544ad0ee3aa8c +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 16 16:09:52 2008 +0100 + + Basic work in the demo PDF viewer, open documents and navigate into + the pages. + + An observer structure was introduced, so extra components can be + easily added and made aware of the document/page changes. + Both the navigation toolbar and the page view are implemented as + observers. + + qt4/demos/CMakeLists.txt | 3 ++ + qt4/demos/Makefile.am | 3 ++ + qt4/demos/documentobserver.cpp | 45 +++++++++++++++++++ + qt4/demos/documentobserver.h | 49 +++++++++++++++++++++ + qt4/demos/navigationtoolbar.cpp | 98 + +++++++++++++++++++++++++++++++++++++++++ + qt4/demos/navigationtoolbar.h | 56 +++++++++++++++++++++++ + qt4/demos/pageview.cpp | 60 +++++++++++++++++++++++++ + qt4/demos/pageview.h | 44 ++++++++++++++++++ + qt4/demos/viewer.cpp | 98 + +++++++++++++++++++++++++++++++++++++++-- + qt4/demos/viewer.h | 17 +++++++ + 10 files changed, 470 insertions(+), 3 deletions(-) + +commit 14c88853a5675f40efb72f3ef01f49eb06ab846c +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 16 00:32:30 2008 +0100 + + Compile the poppler_qt4viewer. + + qt4/demos/CMakeLists.txt | 7 +++++++ + qt4/demos/Makefile.am | 12 ++++++++++-- + 2 files changed, 17 insertions(+), 2 deletions(-) + +commit aeb591f015d5e7a2643ed75d872358d2b1256b99 +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 16 00:31:46 2008 +0100 + + Add a very minimal base PDF viewer. + + So minimal that it does nothing at the moment... + + qt4/demos/main_viewer.cpp | 29 +++++++++++++++++++++++++++++ + qt4/demos/viewer.cpp | 46 + ++++++++++++++++++++++++++++++++++++++++++++++ + qt4/demos/viewer.h | 45 + +++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 120 insertions(+) + +commit 8da490b090487c4c37290b63bdc9abcfaf6d6940 +Author: Pino Toscano <pino@kde.org> +Date: Fri Feb 15 23:59:39 2008 +0100 + + Add a skeleton of directory where PopplerQt4 demos will be. + + configure.ac | 1 + + qt4/CMakeLists.txt | 1 + + qt4/Makefile.am | 2 +- + qt4/demos/CMakeLists.txt | 10 ++++++++++ + qt4/demos/Makefile.am | 20 ++++++++++++++++++++ + 5 files changed, 33 insertions(+), 1 deletion(-) + +commit e24b49d52a5c1716641695ee731dd49848a114d9 +Author: Pino Toscano <pino@kde.org> +Date: Thu Feb 14 22:21:54 2008 +0100 + + do not print it as string + + qt4/src/poppler-private.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 2316455864e9c900c08d051c59b9508eddcb7c34 +Author: Pino Toscano <pino@kde.org> +Date: Thu Feb 14 21:02:20 2008 +0100 + + Pipe the poppler error messages through the Qt debug system. + + qt4/src/poppler-private.cc | 21 +++++++++++++++++++++ + qt4/src/poppler-private.h | 8 +++++++- + 2 files changed, 28 insertions(+), 1 deletion(-) + +commit d985d3b0cdc57370137865add2a5f3a7802109c7 +Author: Pino Toscano <pino@kde.org> +Date: Thu Feb 14 14:56:18 2008 +0100 + + Use what FormWidgetText give us. + + qt4/src/poppler-form.cc | 13 +++---------- + 1 file changed, 3 insertions(+), 10 deletions(-) + +commit a69bd442e52f4495f8d6bfd3bb58b3ebd1be1a63 +Author: Michael Vrable <mvrable@cs.ucsd.edu> +Date: Thu Feb 14 12:52:22 2008 +0100 + + Provide Unicode mappings for some control characters in + PDFDocEncoding. + + Though they do not represent glyphs, values such as carriage return + can be + found in text strings in PDFDocEncoding. Provide mappings for + these bytes + to Unicode. + + Additionally, map unknown characters to U+FFFD instead of U+0000, + so that + unknown characters do not result in nulls (which can truncate strings + early, particularly if the string is later re-encoded into + null-terminated + UTF-8). + + poppler/PDFDocEncoding.cc | 23 +++++++++++++++++------ + 1 file changed, 17 insertions(+), 6 deletions(-) + +commit ce17383e0ed21770b471e88f25046a64a23e7e45 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 13 20:56:39 2008 +0100 + + Yet another fix for buggy documents, do not use the cache if the + cache could not be created because it ought to be too big + + Fixes http://bugs.kde.org/show_bug.cgi?id=157777 + + splash/SplashFont.cc | 48 + ++++++++++++++++++++++++++++-------------------- + 1 file changed, 28 insertions(+), 20 deletions(-) + +commit 15a61cac718ae8cbf83911e299b4cfdd24cdf178 +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 13 20:55:18 2008 +0100 + + add images.c + + glib/demo/CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit 9cfe10ab7f51d329647e102e446baaef043d8cc6 +Merge: e918729 7d65b4d +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 13 20:53:43 2008 +0100 + + Merge branch 'master' of + ssh://pino@git.freedesktop.org/git/poppler/poppler + +commit 7d65b4da1bc060aeb94d67c2ff26912cef48c030 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Feb 13 20:32:43 2008 +0100 + + Add images demo + + glib/demo/Makefile.am | 2 + + glib/demo/images.c | 338 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + glib/demo/images.h | 31 +++++ + glib/demo/main.c | 4 +- + 4 files changed, 374 insertions(+), 1 deletion(-) + +commit e9187292701e72db1020f7701d0725d83eee4b00 +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 13 19:41:57 2008 +0100 + + Do the one-time initialisation in initTestCase(). + + qt4/tests/check_dateConversion.cpp | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +commit fb996c46e3c6b56a2c67819620000bcd804aacd6 +Author: Michael Vrable <mvrable@cs.ucsd.edu> +Date: Wed Feb 13 18:44:41 2008 +0100 + + Major rework of text display in form fields code. + + This adds support for UTF-16 strings as input, and will recode them + to the + appropriate character set for the font. + + The method Annot::layoutText packs a lot of functionality together, + but I + couldn't see a good way to split it apart. It will convert an + input text + string from PDFDocEncoding or UTF-16 (encoding is autodetected) to the + appropriate encoding for the font which will be used to display + the form + field. At the same time, it can compute the width of the resulting + string, + and optionally break the string at a specified width to aid in + wrapping + multi-line text. Text wrapping is integrated with encoding conversion + since wrapping is easiest with the original text (where spaces + and newlines + are easily identified), but text widths can only be computed after + re-encoding. + + Support for composite fonts is included, so long as those fonts use an + identity CMap, but this is still untested. Support for more + complex CMaps + is missing. + + The rewrite also includes a minor improvement to the formatting + of comb + fields; characters are now centered in the comb cells. + + poppler/Annot.cc | 507 + +++++++++++++++++++++++++++++++++++-------------------- + poppler/Annot.h | 9 +- + 2 files changed, 327 insertions(+), 189 deletions(-) + +commit 88c780aed4c9855f879e3c7a9f82500a859635a2 +Author: Michael Vrable <mvrable@cs.ucsd.edu> +Date: Wed Feb 13 18:42:49 2008 +0100 + + Fix what look to be a few bugs in functions for mapping to/from + Unicode. + + - Endianness fix in pdfDocEncodingToUTF16 (previously looked to + assume a + little-endian processor) + - Add support for CharCodeToUnicode::mapToCharCode for Unicode + codepoints + above 255. + + poppler/CharCodeToUnicode.cc | 4 ++-- + poppler/Form.cc | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +commit 7574cb71f24ce5b32427f243c39b6029fb58ec81 +Merge: e798802 4e45e5c +Author: Pino Toscano <pino@kde.org> +Date: Wed Feb 13 01:07:31 2008 +0100 + + Merge branch 'master' of + ssh://pino@git.freedesktop.org/git/poppler/poppler + +commit 4e45e5ca4ab0ba2a6586505d80ed81f4b3426752 +Author: Patrick Spendrin <ps_ml@gmx.de> +Date: Tue Feb 12 21:41:26 2008 +0100 + + Do the right thing with CDECL, that is, undefine it if it is defined + so we can redefine it later + + poppler-config.h.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e798802f00bff0a24ee6d1312d6c62624395865a +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 12 20:57:56 2008 +0100 + + Apidox fix: state which checksum is returned (if available). + + qt4/src/poppler-qt4.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 4e2ba70a88c40fef6775053b1cc5fa30e622cea7 +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 12 11:25:34 2008 +0100 + + Free the Object after you use it. + + poppler/Annot.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 039545fcd2c12631c7b8aea89c35f36cb387a17a +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 12 11:13:27 2008 +0100 + + Return the siblings even for checkboxes. + + qt4/src/poppler-form.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit fe5ee75cdf3e11e314318af12edf9d5bc8986250 +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 12 11:12:01 2008 +0100 + + Initialize correctly; free your memory. + + poppler/Form.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit e0eff92c7067d43faa8e93baed1f061863111251 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Feb 11 20:32:41 2008 +0100 + + Update the field dict instead of the annot dict for non composed dicts + + We were always updating the annot dictionary, adding or updating + the V field. While this is correct for composed dicts (annot + field) + it isn't for non composed ones since the annot dictionary doesn't + contain any V field because it's a field of the form field dictionary. + In these cases the form field is not correctly updated and if the + document is saved it will be wrong. + + poppler/Form.cc | 44 +++++++++++++++++++++++++++++++------------- + poppler/Form.h | 2 ++ + 2 files changed, 33 insertions(+), 13 deletions(-) + +commit 905e6da9795fee94329022c0cafbc229055fd4f6 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Feb 10 19:22:50 2008 +0100 + + Move forms specific draw methods from Annot to AnnotWidget class + + poppler/Annot.cc | 3433 + +++++++++++++++++++++++++++--------------------------- + poppler/Annot.h | 87 +- + poppler/Form.cc | 39 +- + poppler/Form.h | 2 + + poppler/Page.cc | 9 +- + 5 files changed, 1765 insertions(+), 1805 deletions(-) + +commit 78afbc4d7819654e8742d4457c9847ad02b73bf1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Feb 10 17:12:59 2008 +0100 + + Some code refactoring and cleanup + + - Unused 'field' attribute in FormWidget class is now used and + getField() method has been added + - Method isReadOnly() in FormWidget class is not virtual anymore + but implemented in the base class + - Unused attribute 'catalog' in Form class has been removed and + 'acroForm' has been added instead with a getObj() method to get it. + - createFieldFromDict() method is now static + + poppler/Form.cc | 128 + ++++++++++++++++++++++++++++---------------------------- + poppler/Form.h | 41 +++++++++--------- + 2 files changed, 84 insertions(+), 85 deletions(-) + +commit 5f8e2f9140ee2ede841700726b974768ec863672 +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 11 20:16:44 2008 +0100 + + Use QVarLengthArray instead of relying on gcc-ism. + + qt4/src/poppler-page.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 7499764d382366823519aa13a38e1e44781c78af +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 11 11:57:50 2008 +0100 + + Add FormFieldButton::siblings(). + + This is needed for grouping together the radio buttons. + + qt4/src/poppler-form.cc | 14 ++++++++++++++ + qt4/src/poppler-form.h | 8 ++++++++ + 2 files changed, 22 insertions(+) + +commit 85bfa4f499a90d45b13df4d0a8760a7da6fc1532 +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 11 02:40:37 2008 +0100 + + Small apidox fix. + + qt4/src/poppler-form.h | 11 ++--------- + 1 file changed, 2 insertions(+), 9 deletions(-) + +commit ada05055c91e967dc3e2af32a2176dd12cb7fe70 +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 11 02:27:19 2008 +0100 + + Preliminary support for "button" form fields (ie, push buttons, + check boxes, and radio buttons). + + qt4/src/poppler-form.cc | 55 + +++++++++++++++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-form.h | 54 + ++++++++++++++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-page.cc | 6 ++++++ + 3 files changed, 115 insertions(+) + +commit 278b33f25df418ef12798100002845a3e2ceebd3 +Merge: c730b33 fdb0a4a +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 11 00:57:24 2008 +0100 + + Merge branch 'master' of + ssh://pino@git.freedesktop.org/git/poppler/poppler + +commit fdb0a4a2f1d86aec7a3b0fcd4b4d48455791ecad +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sun Feb 10 18:47:40 2008 -0500 + + Avoid prescaling images when printing. + + Adds a function for letting the CairoOutputDev know whether it is + targetting a + screen or not. It then uses this knowledge to avoid prescaling + images. This way + cairo gets the full resolution image for use in the printed output. + + glib/poppler-page.cc | 1 + + poppler/CairoOutputDev.cc | 3 ++- + poppler/CairoOutputDev.h | 2 ++ + 3 files changed, 5 insertions(+), 1 deletion(-) + +commit c730b33f1ec2032c4b8c2660738448d954eb0f7d +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 11 00:46:20 2008 +0100 + + Keep the EmbFile object, and use this for getting the data. + + qt4/src/poppler-embeddedfile.cc | 33 +++++++++++---------------------- + qt4/src/poppler-private.h | 1 - + 2 files changed, 11 insertions(+), 23 deletions(-) + +commit 5915e57e7785370ce305cbbb3c2fedf36886689f +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 10 03:19:18 2008 +0100 + + const & in foreach + + qt4/tests/poppler-fonts.cpp | 2 +- + qt4/tests/stress-poppler-dir.cpp | 2 +- + qt4/tests/stress-poppler-qt4.cpp | 2 +- + qt4/tests/test-password-qt4.cpp | 2 +- + qt4/tests/test-poppler-qt4.cpp | 2 +- + 5 files changed, 5 insertions(+), 5 deletions(-) + +commit d8374e0c2eb3ba05be101687e20c5fcbc42c1ad0 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 10 01:32:24 2008 +0100 + + Include only what needed; remove extra includes. + + qt4/tests/poppler-attachments.cpp | 4 +++- + qt4/tests/poppler-fonts.cpp | 4 +++- + qt4/tests/stress-poppler-dir.cpp | 9 ++++++--- + qt4/tests/stress-poppler-qt4.cpp | 9 ++++++--- + qt4/tests/test-password-qt4.cpp | 10 ++++++---- + qt4/tests/test-poppler-qt4.cpp | 12 ++++++++---- + 6 files changed, 32 insertions(+), 16 deletions(-) + +commit fa01a1115c4554b18c3462b568d76860d2fbe17b +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 10 01:09:57 2008 +0100 + + Comment out unused vars. + + utils/pdftoabw.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit d3275e4263372b534c276f81d0c997ecb6675487 +Merge: c2186c1 5347a97 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 9 23:57:03 2008 +0100 + + Merge branch 'master' of + ssh://aacid@git.freedesktop.org/git/poppler/poppler + +commit c2186c1829c695c4ddb6c471ef8ad4ffa23c1b70 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 9 23:56:32 2008 +0100 + + Only check if we are out of bounds if the object we are searching + for has a known id (0 also means not known) + + Found by Michael Vrable + + poppler/Lexer.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5347a97e39388ae38cf2ab9c67f953b0f7a02a13 +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 9 18:26:41 2008 +0100 + + Add the operators for the flags we have. + + qt4/src/poppler-qt4.h | 3 +++ + 1 file changed, 3 insertions(+) + +commit 329ade4f936bf063539cdc887aaf9a1722a5b8e0 +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 9 18:23:59 2008 +0100 + + Add options for the PDF export; add the WithChanges flag for saving + the changes to the document as well. + + qt4/src/poppler-pdf-converter.cc | 25 +++++++++++++++++++++++-- + qt4/src/poppler-qt4.h | 14 ++++++++++++++ + 2 files changed, 37 insertions(+), 2 deletions(-) + +commit afb255366d56551bdc307766199bef9c5021d3ac +Merge: 8c44b17 8cb0e75 +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 9 17:58:49 2008 +0100 + + Merge branch 'master' of + ssh://pino@git.freedesktop.org/git/poppler/poppler + +commit 8c44b175081983c492821858341109fee9e86b16 +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 9 17:57:57 2008 +0100 + + Do not rely on GNU extensions, but at least use Qt. + + qt4/src/poppler-qiodeviceoutstream.cc | 11 ++++------- + 1 file changed, 4 insertions(+), 7 deletions(-) + +commit 8cb0e75203daa01439413d1a775482b48e784baa +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 9 17:56:13 2008 +0100 + + Domain order is x_min x_max y_min y_max and not x_min y_min x_max + y_max + + poppler/GfxState.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit c8f734ba4258059fa4521a4d364f62ca1632840b +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 9 13:37:04 2008 +0100 + + PS cos and sin input values are degrees so convert to radians so we + can use the cos and sin cmath functions + + poppler/Function.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 5fb0c9d31c1abf2e6ad306c112fbd2a7c33d8772 +Merge: 2655663 2255c85 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Feb 9 13:15:15 2008 +0100 + + Merge branch 'master' of + ssh://carlosgc@git.freedesktop.org/git/poppler/poppler + +commit 26556636e71d5abcbfdd1373f5576d1233532cf8 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Feb 9 13:14:41 2008 +0100 + + Add saveWithoutChangesAs method to be able to save the document + ignoring changes made in forms or annots + + glib/poppler-document.cc | 41 ++++++++++++++++++++++++++++++++++++++++- + glib/poppler-document.h | 3 +++ + poppler/PDFDoc.cc | 38 ++++++++++++++++++++++++++++++++------ + poppler/PDFDoc.h | 4 ++++ + 4 files changed, 79 insertions(+), 7 deletions(-) + +commit 2255c85e4939a0752083dca21984ff4398baf8d2 +Merge: 5ba9287 56c9246 +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 9 12:49:45 2008 +0100 + + Merge branch 'master' of + ssh://pino@git.freedesktop.org/git/poppler/poppler + +commit 5ba928762471e1ea8b81acd4644dfd3f58d18f77 +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 9 12:48:04 2008 +0100 + + Fix placeholders in printf-like functions. + + glib/demo/page.c | 2 +- + glib/test-poppler-glib.cc | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 56c924609223196c5c41b9e6d9102bc248bad947 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 9 12:26:06 2008 +0100 + + atan operator must yield a degrees result between 0 and 360 + + See testcase at http://bugs.kde.org/show_bug.cgi?id=157497 + + poppler/Function.cc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit 2a39932ae35a2716842bd2a1c3d4f9ce6b1e3dd8 +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 9 01:31:20 2008 +0100 + + Few improvements to the password test. + + - QString::fromUtf8() instead of QFile::encodeName() to correctly + pass the utf8 filenames + - QVERIFY(!foo) instead of QCOMPARE(foo, false) + - QVERIFY() also the return value of unlock() + + qt4/tests/check_password.cpp | 31 ++++++++++++++++--------------- + 1 file changed, 16 insertions(+), 15 deletions(-) + +commit cc9c124d4d859b845eebf4ca1e4397870a35fd4e +Author: Pino Toscano <pino@kde.org> +Date: Sat Feb 9 01:09:02 2008 +0100 + + Add an unit test case for few invalid dates. + + qt4/tests/check_dateConversion.cpp | 34 + ++++++++++++++++++++++++++++++++++ + 1 file changed, 34 insertions(+) + +commit eca91761741de5b340f7a2160db5b33401feb935 +Author: Pino Toscano <pino@kde.org> +Date: Fri Feb 8 18:42:14 2008 +0100 + + Remove unneeded headers. + + qt4/src/poppler-page.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 899627505a4645fb1cc7d3599adbeec449c57041 +Author: Pino Toscano <pino@kde.org> +Date: Fri Feb 8 18:41:13 2008 +0100 + + The return value is QString, so return QString's... + + qt4/src/poppler-document.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit a1606fa4ff438983e3a7f55dd2d10a66f72e6711 +Author: Pino Toscano <pino@kde.org> +Date: Fri Feb 8 17:31:32 2008 +0100 + + Move checkDocument() inside the private class. + + qt4/src/poppler-document.cc | 6 +++--- + qt4/src/poppler-private.h | 2 ++ + qt4/src/poppler-qt4.h | 2 +- + 3 files changed, 6 insertions(+), 4 deletions(-) + +commit f1ec70a83f807493dab5118761df31c0f67decad +Author: Pino Toscano <pino@kde.org> +Date: Fri Feb 8 17:26:41 2008 +0100 + + Remove C-ism. + + qt4/src/poppler-document.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 3e994e8586fa1c87ef7e7f82af1cdacf2cd36310 +Author: Pino Toscano <pino@kde.org> +Date: Fri Feb 8 12:21:56 2008 +0100 + + Add the missing font types. + + qt4/src/poppler-fontinfo.cc | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +commit ba07963f85d777a441349e23d4c2f510e45c73be +Author: Pino Toscano <pino@kde.org> +Date: Fri Feb 8 12:19:04 2008 +0100 + + Be safe against self-assignment. + + qt4/src/poppler-fontinfo.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 834b86548e09f4b24cdb2f194299d053b9b55022 +Author: Pino Toscano <pino@kde.org> +Date: Fri Feb 8 12:15:16 2008 +0100 + + Small apidox fix. + + qt4/src/poppler-qt4.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 11a61eac5b8cde04bf762bbbe0deab5c0bd52951 +Author: Pino Toscano <pino@kde.org> +Date: Fri Feb 8 02:21:32 2008 +0100 + + Pack few bools together. + + qt4/src/poppler-annotation.cc | 8 ++++---- + qt4/src/poppler-link.cc | 10 +++++----- + qt4/src/poppler-private.h | 4 ++-- + 3 files changed, 11 insertions(+), 11 deletions(-) + +commit 1aeba15b5eb9b30943259824678ebc9e4f56e870 +Merge: a489063 22d10c1 +Author: Pino Toscano <pino@kde.org> +Date: Fri Feb 8 01:39:16 2008 +0100 + + Merge branch 'master' of + ssh://pino@git.freedesktop.org/git/poppler/poppler + +commit a4890637a2c2ab1623311d9a6920e82131c2597c +Author: Pino Toscano <pino@kde.org> +Date: Fri Feb 8 01:36:56 2008 +0100 + + Move QStringToUnicodeGooString() and QStringToGooString() to the + private module. + + qt4/src/poppler-document.cc | 10 ---------- + qt4/src/poppler-form.cc | 15 --------------- + qt4/src/poppler-private.cc | 25 +++++++++++++++++++++++++ + qt4/src/poppler-private.h | 4 ++++ + 4 files changed, 29 insertions(+), 25 deletions(-) + +commit 5e44241c4976b819f7be6badd2d183fbfb8ee6de +Author: Pino Toscano <pino@kde.org> +Date: Fri Feb 8 01:30:07 2008 +0100 + + Move the string functions implementation in a .cc file. + + qt4/src/CMakeLists.txt | 1 + + qt4/src/Makefile.am | 1 + + qt4/src/poppler-private.cc | 70 + ++++++++++++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-private.h | 46 +++--------------------------- + 4 files changed, 76 insertions(+), 42 deletions(-) + +commit 124d92139241ad95da559d22af48254b45ac4a2e +Author: Pino Toscano <pino@kde.org> +Date: Fri Feb 8 01:07:43 2008 +0100 + + Include own header first, remove extra includes. + + qt4/src/poppler-document.cc | 1 - + qt4/src/poppler-embeddedfile.cc | 3 ++- + qt4/src/poppler-form.cc | 4 +++- + qt4/src/poppler-link-extractor-private.h | 2 ++ + qt4/src/poppler-link-extractor.cc | 7 +++++-- + qt4/src/poppler-page-private.h | 6 +++++- + qt4/src/poppler-private.h | 4 +++- + qt4/src/poppler-qt4.h | 2 -- + qt4/src/poppler-sound.cc | 4 ++-- + 9 files changed, 22 insertions(+), 11 deletions(-) + +commit 22d10c19e232dea143bda372c92aa12b999e4921 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Feb 7 23:38:50 2008 +0100 + + PDF spec says name tokens have a maximum length of 127, but there are + some docs in the wild with more than that and they work on acroread + so increase the allowed length to 128+127 + + poppler/Lexer.cc | 25 +++++++++++++++++++++---- + 1 file changed, 21 insertions(+), 4 deletions(-) + +commit ee9f85915feb86b54ace1a403baa13bbdd7c3966 +Author: Pino Toscano <pino@kde.org> +Date: Thu Feb 7 18:07:53 2008 +0100 + + Having a PageData is mandatory. + + Just assert when constructing instead of checking for it in each + link iteration. + + qt4/src/poppler-link-extractor.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit ad4b1361f6c25359e6ddb38599bfc1e4e3e80408 +Author: Pino Toscano <pino@kde.org> +Date: Thu Feb 7 18:03:30 2008 +0100 + + Precalc stuff we don't need to recalc in each link iteration. + + qt4/src/poppler-link-extractor-private.h | 3 ++- + qt4/src/poppler-link-extractor.cc | 14 ++++++++------ + 2 files changed, 10 insertions(+), 7 deletions(-) + +commit 82432dbc62a0879f4513640c2e0f594fda9347ad +Author: Pino Toscano <pino@kde.org> +Date: Thu Feb 7 17:51:50 2008 +0100 + + Store the ::Page internally, so we don't need to get it again + everytime. + + qt4/src/poppler-page-private.h | 3 +++ + qt4/src/poppler-page.cc | 37 ++++++++++++++----------------------- + 2 files changed, 17 insertions(+), 23 deletions(-) + +commit 8ec51f7ca518aa6a4a69f30d373722d05f50cf07 +Author: Pino Toscano <pino@kde.org> +Date: Thu Feb 7 16:48:16 2008 +0100 + + Compile the stress-poppler-dir test as well. + + qt4/tests/CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit 8a946b76ae2e7c2c5238b4e580c1c226eb457dc9 +Author: Pino Toscano <pino@kde.org> +Date: Thu Feb 7 01:07:28 2008 +0100 + + Micro-touches to the debug messages. + + qt4/src/poppler-page.cc | 26 +++++++++++++------------- + 1 file changed, 13 insertions(+), 13 deletions(-) + +commit c31990dfe50c7a0e3999e6d967699fce5ccb3339 +Merge: 7701e2a 6d58cda +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 5 00:38:00 2008 +0100 + + Merge branch 'master' of + ssh://pino@git.freedesktop.org/git/poppler/poppler + +commit 7701e2a5c7d18fdaa0fa40c190e6ee0524746046 +Author: Pino Toscano <pino@kde.org> +Date: Tue Feb 5 00:37:01 2008 +0100 + + Add a AnnotColor -> QColor conversion method. + + qt4/src/poppler-annotation-helper.h | 6 ++++++ + qt4/src/poppler-annotation.cc | 31 +++++++++++++++++++++++++++++++ + 2 files changed, 37 insertions(+) + +commit 6d58cda82b0181f2cca6e9d95b15877793be0812 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Feb 4 23:33:51 2008 +0100 + + Protect us against weird dateString values + + qt4/src/poppler-document.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit aa0435f1544fe1adcf10173e34eaeaf2a7a703c7 +Merge: b43f4e9 37600b5 +Author: Pino Toscano <pino@kde.org> +Date: Mon Feb 4 20:56:53 2008 +0100 + + Merge branch 'master' of + ssh://pino@git.freedesktop.org/git/poppler/poppler + +commit 37600b5e848386d2c92c3dff8219c9dda16b0dca +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Sun Feb 3 22:42:51 2008 +0100 + + Minor changes to Annot related stuff. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 15 ++++----------- + poppler/Annot.h | 12 ++++++++++-- + poppler/Gfx.cc | 7 ++++--- + poppler/Page.cc | 9 +++++++++ + poppler/Page.h | 3 +++ + 5 files changed, 30 insertions(+), 16 deletions(-) + +commit b43f4e9a161a1fd7b827244dc21b1bd2a6df7054 +Author: Pino Toscano <pino@kde.org> +Date: Sun Feb 3 20:32:15 2008 +0100 + + Pass the DocumentData to the Page (simplify a bit some code). + + qt4/src/poppler-document.cc | 2 +- + qt4/src/poppler-link-extractor-private.h | 4 +- + qt4/src/poppler-link-extractor.cc | 8 ++-- + qt4/src/poppler-page-private.h | 4 +- + qt4/src/poppler-page.cc | 64 + ++++++++++++++++---------------- + qt4/src/poppler-qt4.h | 5 +-- + 6 files changed, 42 insertions(+), 45 deletions(-) + +commit 4e0bb0307fccefc21f74a4c5a3a0d7e8e687b550 +Author: Pino Toscano <pino@draco.(none)> +Date: Sat Feb 2 12:57:25 2008 +0100 + + Fix include guard. + + poppler/ArthurOutputDev.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 6f11ef660540fd13aad1350385beb90758ca86af +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Feb 1 23:55:37 2008 +0100 + + Fix for end condition, init ucode to 0 + + poppler/GfxFont.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 1da2091807ae7f7d4d3f446953c41b4c440d4b1b +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 31 23:52:20 2008 +0100 + + Ensure we don't draw outside the main bitmap on + SplashOutputDev::setSoftMask + + Fixes crash on http://bugs.kde.org/show_bug.cgi?id=157000 + + poppler/SplashOutputDev.cc | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +commit ecabc9469b137e8251344e5502de1cbf875223b9 +Author: Pino Toscano <pino@kde.org> +Date: Thu Jan 31 00:20:55 2008 +0100 + + Set RelWithDebInfo as default build type, if not specified. + + cmake/modules/PopplerMacros.cmake | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 19da87a20b3906523a330e3c956903a58a3ede7f +Author: Pino Toscano <pino@kde.org> +Date: Thu Jan 31 00:11:58 2008 +0100 + + Support the different CMake build modes. + + Now you can specify (using -DCMAKE_BUILD_TYPE=type) a CMake build + type to have GCC or ICC w/ tuned C(XX)FLAGS. + The supported build types are: None (as in no type is specified on + command line), RelWithDebInfo, Release, Debug, DebugFull, Profile. + + CMakeLists.txt | 7 ------- + cmake/modules/PopplerMacros.cmake | 29 +++++++++++++++++++++++++++++ + 2 files changed, 29 insertions(+), 7 deletions(-) + +commit 37d2055137c310ceb217164a76814b188be3b1b2 +Author: Pino Toscano <pino@draco.(none)> +Date: Wed Jan 30 23:12:03 2008 +0100 + + Introduce the CMake-based build system. + + Mostly works nicely as the autotools, and it mimics (almost) all + the autotools behaviours. + Copied some scripts from the KDE cmake scripts (BSD-licensed). + TODO: gtk-doc. + + CMakeLists.txt | 390 +++++++ + ConfigureChecks.cmake | 47 + + cmake/modules/COPYING-CMAKE-SCRIPTS | 22 + + cmake/modules/FindCairo.cmake | 44 + + cmake/modules/FindFontconfig.cmake | 47 + + cmake/modules/FindFreetype.cmake | 74 ++ + cmake/modules/FindGTK.cmake | 70 ++ + cmake/modules/FindPackageHandleStandardArgs.cmake | 58 + + cmake/modules/FindQt3.cmake | 319 +++++ + cmake/modules/FindQt4.cmake | 1295 + +++++++++++++++++++++ + cmake/modules/MacroBoolTo01.cmake | 20 + + cmake/modules/MacroEnsureVersion.cmake | 117 ++ + cmake/modules/MacroOptionalFindPackage.cmake | 28 + + cmake/modules/MacroPushRequiredVars.cmake | 47 + + cmake/modules/PopplerDefaults.cmake | 10 + + cmake/modules/PopplerMacros.cmake | 83 ++ + config.h.cmake | 149 +++ + glib/CMakeLists.txt | 107 ++ + glib/demo/CMakeLists.txt | 17 + + glib/poppler-features.h.cmake | 24 + + poppler-cairo.pc.cmake | 9 + + poppler-config.h.cmake | 160 +++ + poppler-glib.pc.cmake | 13 + + poppler-qt.pc.cmake | 12 + + poppler-qt4.pc.cmake | 12 + + poppler-splash.pc.cmake | 9 + + poppler.pc.cmake | 11 + + qt/CMakeLists.txt | 33 + + qt4/CMakeLists.txt | 2 + + qt4/src/CMakeLists.txt | 43 + + qt4/tests/CMakeLists.txt | 47 + + test/CMakeLists.txt | 52 + + utils/CMakeLists.txt | 84 ++ + 33 files changed, 3455 insertions(+) + +commit 1ea831d3eee6eda35fadfb3c75962a0c708e6c7b +Author: Pino Toscano <pino@kde.org> +Date: Wed Jan 30 22:17:38 2008 +0100 + + Preprocessor #warning is GCC-specific. + + poppler/ArthurOutputDev.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 4c738cc6bd51f9d9e23ba83949c490c5c8691345 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jan 29 23:45:52 2008 +0100 + + Scale text to match 'm' size + + Fixes bug 12304 + + poppler/SplashOutputDev.cc | 37 +++++++++++++++++++++++++++++++ + splash/SplashFTFont.cc | 55 + +++++++++++++++++++++++++++++++++++++++++++++- + splash/SplashFTFont.h | 4 ++++ + splash/SplashFont.h | 4 ++++ + splash/SplashFontFile.cc | 1 + + splash/SplashFontFile.h | 2 ++ + 6 files changed, 102 insertions(+), 1 deletion(-) + +commit 64f16cf6ebf2870852fe8d937b25be58869ad40a +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jan 29 23:41:15 2008 +0100 + + Enable antialias by default on the test tool + + qt4/tests/test-poppler-qt4.cpp | 2 ++ + 1 file changed, 2 insertions(+) + +commit 90f0e6bc1e96d9f1666cb8476a92e127f5b927d4 +Author: Jonathan Kew <jonathan_kew@sil.org> +Date: Tue Jan 29 20:23:08 2008 +0100 + + Provide gstrndup as a portable substitue of strndup + + configure.ac | 1 - + goo/gmem.cc | 7 +++++++ + goo/gmem.h | 5 +++++ + poppler/GfxFont.cc | 8 +------- + 4 files changed, 13 insertions(+), 8 deletions(-) + +commit 77b91c852ad3d5554afc03aee92a1d928f233401 +Merge: 0babb0e 0533696 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jan 28 20:44:34 2008 +0100 + + Merge branch 'master' of + ssh://aacid@git.freedesktop.org/git/poppler/poppler + +commit 0babb0eb1afa343fb12a3fd037b98d2d1c794a1c +Author: Jonathan Kew <jonathan_kew@sil.org> +Date: Mon Jan 28 20:42:44 2008 +0100 + + Introduce a check for strndup and alternative for systems without it + + configure.ac | 1 + + poppler/GfxFont.cc | 6 ++++++ + 2 files changed, 7 insertions(+) + +commit 053369678963206a4afa88a614de1994872c7c5a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jan 27 19:36:28 2008 +0100 + + Add ok_to_fill_form permission flag + + glib/poppler-document.cc | 2 ++ + glib/poppler-document.h | 3 ++- + glib/test-poppler-glib.cc | 21 +++++++++++++++++++-- + 3 files changed, 23 insertions(+), 3 deletions(-) + +commit 3085a9495ad87a54758da0024372610fdaf88d57 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Jan 27 19:15:34 2008 +0100 + + Fix slice rendering in poppler glib demo + + glib/demo/render.c | 41 ++++++++++++++++++++++++----------------- + 1 file changed, 24 insertions(+), 17 deletions(-) + +commit 7ad6c4ba110b970516d5380444a03ae217496ddf +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 24 21:14:44 2008 +0100 + + Incrementing the iterator would be a good idea + + qt4/src/poppler-annotation.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 7c99ec4635a4971321bbead7d1bc723da59b755e +Author: Julien Rebetez <julien@fhtagn.net> +Date: Thu Jan 24 19:18:15 2008 +0100 + + Revert unwanted change on Dict, fix leak on writeTrailer + + poppler/Dict.cc | 2 +- + poppler/PDFDoc.cc | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit 2335fb6034d2e9ec304abba400119b88302b3160 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 23 23:26:20 2008 +0100 + + Draw underlined Links correctly + + See http://bugs.kde.org/show_bug.cgi?id=151359 for an example + + poppler/Gfx.cc | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit 96c532ea4b56a147de1deb965126e31f87df588b +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jan 23 13:30:12 2008 +0100 + + Fix memory leak + + poppler/Form.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 6bca64407c675ca837f83a12c0f655f975f14407 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jan 23 13:27:45 2008 +0100 + + Make sure default values are not loaded more than once for the + same widget. + + poppler/Form.cc | 18 +++++++++++++++++- + poppler/Form.h | 1 + + 2 files changed, 18 insertions(+), 1 deletion(-) + +commit eccf84b51a1cf5d478c0ec84be3fc9be8e458f4f +Author: Pino Toscano <pino@kde.org> +Date: Tue Jan 22 23:28:16 2008 +0100 + + Refactor the PSConverter and add a PDFConverter (for PDF export/save). + + Add an OutStream subclass to redirect the output to a QIODevice. + Split the PSConverter in a base class (BaseConverter) w/ d_ptr + structure. + Add a new PDFConverter that inherit BaseConverter, and do the + actual export + making use of the new QIODeviceOutStream. + The BaseConverter now handles automatically file or QIODevice output. + + qt4/src/Makefile.am | 5 + + qt4/src/poppler-base-converter.cc | 99 ++++++++++++++++ + qt4/src/poppler-converter-private.h | 48 ++++++++ + qt4/src/poppler-document.cc | 5 + + qt4/src/poppler-pdf-converter.cc | 68 +++++++++++ + qt4/src/poppler-ps-converter.cc | 162 + ++++++++++++--------------- + qt4/src/poppler-qiodeviceoutstream-private.h | 47 ++++++++ + qt4/src/poppler-qiodeviceoutstream.cc | 71 ++++++++++++ + qt4/src/poppler-qt4.h | 85 +++++++++++--- + 9 files changed, 483 insertions(+), 107 deletions(-) + +commit 547db8be1ab0b2987f0f06d8529eaaed2414028c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jan 22 13:22:20 2008 +0100 + + Fix a crash when createAnnot returns NULL due to invalid annot dict. + + poppler/Annot.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0d558841142587d66bd3b2025e5a9ca39f7a6159 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jan 21 21:43:39 2008 +0100 + + Fix another reversed comparison due to cmp + + poppler/Annot.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit cb6a87e39336e2e3893f3e5f577e4d176d237a9f +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Mon Jan 21 10:07:35 2008 +0100 + + Fixed a few compare issues with Annots. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 24 ++++++++++++------------ + 1 file changed, 12 insertions(+), 12 deletions(-) + +commit 7cf85dc8d7c895a211684c7d36757063ed4f469b +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Mon Jan 21 21:27:49 2008 +0100 + + The glade file needs to be distributed + + test/Makefile.am | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 46e93d31dd9b5909ecd8f7a8f8de23329444a7bc +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Sun Jan 20 19:56:51 2008 +0100 + + we need time.h if we use time() + + poppler/PDFDoc.cc | 1 + + 1 file changed, 1 insertion(+) + +commit a0adb006c38ea07f010a01d9c0bb07ca0f48939d +Author: Pino Toscano <pino@kde.org> +Date: Sun Jan 20 19:55:55 2008 +0100 + + Added a saveAs() overload which takes a plain OutStream + + poppler/PDFDoc.cc | 9 +++++++-- + poppler/PDFDoc.h | 2 ++ + 2 files changed, 9 insertions(+), 2 deletions(-) + +commit fcdd5c51f370d040ae57aa64801c9bd4dbe88752 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jan 19 18:00:10 2008 +0100 + + Do not render images when getting the image mapping, it can be done + later on demand. + + glib/poppler-page.cc | 81 +++++++++++++++------------- + glib/poppler-page.h | 6 ++- + poppler/CairoOutputDev.cc | 131 + ++++++++++++++++++++++++++-------------------- + poppler/CairoOutputDev.h | 12 ++++- + 4 files changed, 135 insertions(+), 95 deletions(-) + +commit 37ae465775d9a53e7c06cf51aa215439214fd79c +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Sat Jan 19 14:00:31 2008 +0100 + + ignore pdf-fullrewrite binary + + test/.gitignore | 1 + + 1 file changed, 1 insertion(+) + +commit 1d160935ea4c1116b745c584ed7f1fd03fbbfb46 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Sat Jan 19 13:59:46 2008 +0100 + + AnnotWidget support and few fixes + + poppler/Annot.cc | 243 + ++++++++++++++++++++++++++++++++++++++++++++++++++++--- + poppler/Annot.h | 142 +++++++++++++++++++++++++++++--- + 2 files changed, 365 insertions(+), 20 deletions(-) + +commit 0e91a3973e525d65236d15930a8ea0e5bbb6a6cc +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Sat Jan 19 13:59:25 2008 +0100 + + AnnotTextMarkup support and improved AnnotQuadrilaterals + + poppler/Annot.cc | 356 + ++++++++++++++++++++++++++++++++++++++++++++----------- + poppler/Annot.h | 130 +++++++++++++++++--- + 2 files changed, 400 insertions(+), 86 deletions(-) + +commit c13952cd56a40bad14a1bf28699b137f65162f10 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Sat Jan 19 13:59:02 2008 +0100 + + Changed AnnotQuadrilateral parsing inside AnnotLink + + poppler/Annot.cc | 246 + ++++++++++++++++++++++++++++++------------------------- + poppler/Annot.h | 19 +++-- + 2 files changed, 144 insertions(+), 121 deletions(-) + +commit 2f821f10fbbba9363405201c86494cd861cec2b2 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Sat Jan 19 13:49:43 2008 +0100 + + Add AnnotQuadPoints class + + poppler/Annot.cc | 16 ++++++++++++++++ + poppler/Annot.h | 23 +++++++++++++++++++++++ + 2 files changed, 39 insertions(+) + +commit de4c8fa6607e55c199bede1dc731227692ef4f53 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Sun Dec 30 21:21:56 2007 +0100 + + AnnotFreeText support. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 232 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++- + poppler/Annot.h | 127 ++++++++++++++++++++++++++++++ + 2 files changed, 358 insertions(+), 1 deletion(-) + +commit c3504a87933ae1516b1ef05e527fd1c039091235 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Sun Dec 30 19:37:18 2007 +0100 + + Improved AnnotLink support. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 116 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Annot.h | 51 ++++++++++++++++++++++++ + 2 files changed, 167 insertions(+) + +commit a20468cc38bb590124b2b028a08f364f90f2487f +Author: Julien Rebetez <julien@fhtagn.net> +Date: Sat Jan 19 13:02:17 2008 +0100 + + Adds a test application to test full rewrite functionnality. + + test/Makefile.am | 11 ++++++++++- + test/pdf-fullrewrite.cc | 44 ++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 54 insertions(+), 1 deletion(-) + +commit 246294714c6011651fd0e5b3649bd65919058c72 +Author: Julien Rebetez <julien@fhtagn.net> +Date: Sat Jan 19 12:59:03 2008 +0100 + + FormWidget's 'modified' member variable is now updated correctly + each time an update is done. + + Before, only text FormWidget had their 'modified' field set to 'true' + if they had been updated. + It is now the case for the other type of FormWidgets. + + poppler/Form.cc | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +commit 6e0f297b8b17afb95779724b8618ca39016e664a +Author: Julien Rebetez <julien@fhtagn.net> +Date: Sat Jan 19 12:54:09 2008 +0100 + + Annot will save their generated appearance in their AP dict. + + poppler/Annot.cc | 42 ++++++++++++++++++++++++++++++++++++++---- + poppler/Annot.h | 1 + + 2 files changed, 39 insertions(+), 4 deletions(-) + +commit e20f6a8e9ac3936b4bc03710a71fe390dfc4c094 +Author: Julien Rebetez <julien@fhtagn.net> +Date: Sat Jan 19 12:52:02 2008 +0100 + + Add deep copy constructor to Dict. + + poppler/Dict.cc | 14 +++++++++++++- + poppler/Dict.h | 1 + + 2 files changed, 14 insertions(+), 1 deletion(-) + +commit e8d46cab77c7167edb0896296118daafc0f13b6d +Author: Julien Rebetez <julien@fhtagn.net> +Date: Sat Jan 19 12:51:44 2008 +0100 + + Adds the ability to save PDF using either incremental update or by + rewriting completly the PDF. + + poppler/PDFDoc.cc | 379 + +++++++++++++++++++++++++++++++++++++++++++++++++++++- + poppler/PDFDoc.h | 18 ++- + poppler/XRef.cc | 12 +- + poppler/XRef.h | 3 +- + 4 files changed, 402 insertions(+), 10 deletions(-) + +commit 742b0c3dec01d8672b84f56d5bb0e2890b178594 +Author: Julien Rebetez <julien@fhtagn.net> +Date: Sat Jan 19 12:51:27 2008 +0100 + + Make the md5 method of Decrypt public so it can be used by other + files. + + poppler/Decrypt.cc | 5 ++--- + poppler/Decrypt.h | 1 + + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit bb7867976740dea259d4110c072552fc5953910f +Author: Julien Rebetez <julien@fhtagn.net> +Date: Sat Jan 19 12:51:07 2008 +0100 + + Modify the writeToFile method of XRef so it uses OutStream instead + of a C file descriptor. + + poppler/XRef.cc | 10 +++++----- + poppler/XRef.h | 2 +- + 2 files changed, 6 insertions(+), 6 deletions(-) + +commit d80736587fdbc0e163077f27bfd21c5e3a7fa4c7 +Author: Julien Rebetez <julien@fhtagn.net> +Date: Sat Jan 19 12:50:49 2008 +0100 + + Adds addIndirectObject method to XRef. This method allow the creation + of new indirect objects. + + poppler/XRef.cc | 39 +++++++++++++++++++++++++++++++++++++++ + poppler/XRef.h | 1 + + 2 files changed, 40 insertions(+) + +commit 8bd00dd0872191b8806e9411d9a1adc441f08a47 +Author: Julien Rebetez <julien@fhtagn.net> +Date: Sat Jan 19 12:50:16 2008 +0100 + + Add some unfiltered methods to input stream. + + With these methods, it is possible to read the raw content from the + stream, without any filtering (even not the headers). + + poppler/Stream.cc | 41 ++++++++++++++++++++++++++++------------- + poppler/Stream.h | 26 ++++++++++++++++++++++++++ + 2 files changed, 54 insertions(+), 13 deletions(-) + +commit 8bcda287ddd316f90b3e47a3a307fbe63a5c21f7 +Author: Julien Rebetez <julien@fhtagn.net> +Date: Sat Jan 19 12:46:53 2008 +0100 + + Add setNeedFree method to MemStream so it is possible to choose if + the stream should take care of deleting the buffer. + + poppler/Stream.h | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 4fbd143de7e3a8ab386dd14b057e62b3b9fe04e4 +Author: Julien Rebetez <julien@fhtagn.net> +Date: Sat Jan 19 12:45:54 2008 +0100 + + Add Outstream, a base class for output streams and FileOutStream, + which implements OutStream for output to a file. + + poppler/Stream.cc | 55 +++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Stream.h | 64 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 119 insertions(+) + +commit 696eaa47169fb063b7e6998c876926c578b6fbfa +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jan 17 15:56:59 2008 +0100 + + Fix a crash when editing text form fields + + poppler/Annot.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 9ec1b28dcdade12498b94b650c26483581294ee6 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jan 17 14:54:34 2008 +0100 + + Fix a crash when a form field contains reference to non existant + children + + poppler/Form.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit f7ed40c465033bad26dfda008c5984954baa0607 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jan 16 21:01:50 2008 +0100 + + Add a cast to fix build + + glib/demo/info.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 1c0aa21e598b879ec49d96700e6438ccb8ac2283 +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Fri Jan 11 20:28:49 2008 +0100 + + rename info.c to info.cc to fix bug 14024 + + glib/demo/Makefile.am | 2 +- + glib/demo/info.c | 243 + -------------------------------------------------- + glib/demo/info.cc | 243 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 244 insertions(+), 244 deletions(-) + +commit 88f8bf850b6c41d25b9576597b5fc5bd75a122f4 +Author: Kjartan Maraas <kmaraas@gnome.org> +Date: Thu Jan 10 23:51:54 2008 +0100 + + Fix two use after free bugs in HtmlOutputDev.cc + + utils/HtmlOutputDev.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 348f4f9d9d5b0f91da6f46e0fcefec80255d4179 +Merge: 8a8a4f0 4eca2e0 +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Sat Jan 5 23:03:06 2008 +0100 + + Merge branch 'master' of + ssh://aacid@git.freedesktop.org/git/poppler/poppler + +commit 8a8a4f01272fb86898fafbda07129c0cbc03d527 +Author: Pino Toscano <pino@kde.org> +Date: Sat Jan 5 23:02:22 2008 +0100 + + Make Document::renderHints return the correct render hints + + qt4/src/poppler-document.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 4eca2e041c93349e0c4666e83ad1ca3caff91dee +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jan 1 14:34:00 2008 +0100 + + Add page transitions demo + + glib/demo/Makefile.am | 2 + + glib/demo/main.c | 16 +-- + glib/demo/transitions.c | 321 + ++++++++++++++++++++++++++++++++++++++++++++++++ + glib/demo/transitions.h | 31 +++++ + 4 files changed, 363 insertions(+), 7 deletions(-) + +commit e92b50bbd3dfc8657b611e3c33129d7c5bae2319 +Author: Koji Otani <sho@bbr.jp> +Date: Wed Dec 26 18:56:01 2007 +0100 + + Use getEmbeddedFontID instead of getEmbeddedFontName to check if a + font is embedded or not + + poppler/GfxFont.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 30e9bae97e3742913015f7ea46636b2b80937612 +Author: Ed Catmur <ed@catmur.co.uk> +Date: Sat Dec 22 22:54:51 2007 +0100 + + Fixlets for Adobe Glyph Naming convention implementation + + poppler/GfxFont.cc | 94 + ++++++++++++++++++++++++++++-------------------------- + 1 file changed, 48 insertions(+), 46 deletions(-) + +commit 40551e616b007ceb15c9d6e3d77c24538ffec924 +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Sat Dec 22 14:31:50 2007 +0100 + + Check the destination page of the link does exist + + qt4/src/poppler-link.cc | 20 ++++++++++++-------- + 1 file changed, 12 insertions(+), 8 deletions(-) + +commit c06d6f2236d854f05e7621be280109ff27dc73b9 +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Thu Dec 20 20:13:08 2007 +0100 + + Use UnicodeParsedString that does exactly what this code does + + qt4/src/poppler-document.cc | 28 +--------------------------- + 1 file changed, 1 insertion(+), 27 deletions(-) + +commit 5f9f06a10fdb72a9d809ee1f779e1a8f549840e7 +Author: Koji Otani <sho@bbr.jp> +Date: Thu Dec 20 19:59:26 2007 +0100 + + Fix for latest CJK code + + See + http://lists.freedesktop.org/archives/poppler/2007-December/003244.html + for more information + + poppler/GfxFont.cc | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +commit bb49e1e3909fc7392c197dc67d9b7f5312fd0dad +Author: Ed Catmur <ed@catmur.co.uk> +Date: Tue Dec 18 20:20:11 2007 +0100 + + Implement Adobe Glyph Naming convention + + poppler/GfxFont.cc | 183 + ++++++++++++++++++++++++++++++++++++++++++++--------- + 1 file changed, 154 insertions(+), 29 deletions(-) + +commit 5634d63abdd64d371f2e8687a1c172f55b052008 +Author: Koji Otani <sho@bbr.jp> +Date: Mon Dec 17 20:43:41 2007 +0100 + + Allow seting some more Graphics States (Font, LW, LC, LJ, ML, D, + RI, FL) by operator 'gs' + + poppler/Gfx.cc | 67 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 67 insertions(+) + +commit 7a9e7fc96b47b9d833300233ac38bbd60097f425 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Dec 16 21:21:08 2007 +0100 + + Add AnnotLink class so that link annots are properly recognized + + Right now, all of the annots except Text, are created using the + base class Annot which sets the type to unknown. For link annots this + causes the border never be drawn, since we are checking first + whether the + annot is a Link and it's always false. + + poppler/Annot.cc | 12 +++++++++++- + poppler/Annot.h | 10 ++++++++++ + 2 files changed, 21 insertions(+), 1 deletion(-) + +commit 796d9cb9b188a8af69d7fbf9bccbb408cbf6a71a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Dec 15 15:21:49 2007 +0100 + + Fix a crash when trying to create a temp annot with catalog = NULL + + poppler/Annot.cc | 7 +++++++ + poppler/Annot.h | 1 + + poppler/Form.cc | 6 ++---- + 3 files changed, 10 insertions(+), 4 deletions(-) + +commit 99f049f0dfbfd9c22bea56ae96253837ae421e23 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Dec 14 15:26:24 2007 +0100 + + Use the default dash array when it's not correct in AnnotBorderBS + + poppler/Annot.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit cb2a997aa6f9dd5508ca8b04e63815da893497ef +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Dec 14 14:12:14 2007 +0100 + + Fix another crash due to uninitialized variables + + poppler/Annot.cc | 18 ++++++++---------- + poppler/Annot.h | 1 + + 2 files changed, 9 insertions(+), 10 deletions(-) + +commit f704e86d8c72bacbd9443c4d828cd284d3a11753 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Dec 14 12:58:12 2007 +0100 + + Fix several crashes due to uninitialized variables in Annots. + + poppler/Annot.cc | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +commit 0820a93ba1c0e893681024feb9f9bd120a9eeb4d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Dec 14 12:38:58 2007 +0100 + + Check whether top and left should be changed in FitH, FitV, FitBH + and FitBV destinations + + According to the spec, if a null value is specified for top or left + parameter in such + destinations, the parameter should be retained unchanged. + + poppler/Link.cc | 36 ++++++++++++++++++++++++++++-------- + 1 file changed, 28 insertions(+), 8 deletions(-) + +commit 0fb42a2f557d5ec83b42326eb6b0be41622ca328 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Wed Dec 12 01:02:31 2007 +0100 + + Changed getters to const + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 28 +++++++++++----------- + poppler/Annot.h | 72 + ++++++++++++++++++++++++++++---------------------------- + 2 files changed, 50 insertions(+), 50 deletions(-) + +commit 29d39a8ae120e6045a16a7aa0944c36560b42508 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Mon Dec 10 17:56:44 2007 +0100 + + AnnotText support. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 123 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++- + poppler/Annot.h | 65 ++++++++++++++++++++++++----- + 2 files changed, 177 insertions(+), 11 deletions(-) + +commit 2acecde458122bd67487cc302478befa78bf6fbe +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Mon Dec 10 16:45:46 2007 +0100 + + AnnotMarkup support. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 115 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Annot.h | 51 ++++++++++++++++++++++++ + 2 files changed, 166 insertions(+) + +commit 1f8c1fe34e04688d2ba200f1166cfdd1ffe563f0 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Mon Dec 10 16:34:01 2007 +0100 + + AnnotPopup support. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 34 ++++++++++++++++++++++++++++++++++ + poppler/Annot.h | 21 +++++++++++++++++++++ + 2 files changed, 55 insertions(+) + +commit 6c83e06fb2eb77d0dbefd1ebfbcac3e5f0cbb622 +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Mon Dec 10 16:24:38 2007 +0100 + + Prepare code to Annotation Subtype support. + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + glib/poppler-page.cc | 11 +--- + poppler/Annot.cc | 160 + ++++++++++++++++++++++++++++++++++++--------------- + poppler/Annot.h | 54 ++++++++++++++--- + poppler/Form.cc | 6 +- + 4 files changed, 167 insertions(+), 64 deletions(-) + +commit fa0bb5bbea5bf2769c8b3084f78770b7781002eb +Author: Iñigo Martínez <inigomartinez@gmail.com> +Date: Mon Dec 10 15:41:38 2007 +0100 + + Various Annot improvements + + Signed-off-by: Iñigo Martínez <inigomartinez@gmail.com> + + poppler/Annot.cc | 613 + ++++++++++++++++++++++++++++++++++++------------------- + poppler/Annot.h | 140 +++++++++++-- + poppler/Gfx.cc | 21 +- + poppler/Gfx.h | 5 +- + 4 files changed, 543 insertions(+), 236 deletions(-) + +commit e0f49fd5aef3c798798ad7e7dba55857bde1b4c0 +Author: Koji Otani <sho@bbr.jp> +Date: Thu Dec 13 23:40:46 2007 +0100 + + Some CJK charecters are displayed vertical glyphs incorrectly when + horizontal mode + + poppler/GfxFont.cc | 46 +++++++++++++++++++++++++--------------------- + 1 file changed, 25 insertions(+), 21 deletions(-) + +commit 85901922bf354a1268037d0b6ec5cbf14da979a1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Dec 13 23:30:59 2007 +0100 + + Yet another gmallocn to gmallocn_checkoverflow + + Fixes http://bugs.kde.org/show_bug.cgi?id=153949 + + poppler/SplashOutputDev.cc | 23 ++++++++++++++++------- + 1 file changed, 16 insertions(+), 7 deletions(-) + +commit f24259cddb9c5e02cf9d2071bfa0106f3e88bd59 +Author: Koji Otani <sho@bbr.jp> +Date: Mon Dec 10 23:24:14 2007 +0100 + + Display characters outside of unicode BMP with TT font + + fofi/FoFiTrueType.cc | 33 ++++++++++++++++++++--- + fofi/FoFiTrueType.h | 2 +- + poppler/CMap.cc | 34 ++++++++++++++++++++++++ + poppler/CMap.h | 4 +++ + poppler/GfxFont.cc | 75 + ++++++++++++++++++++++++++++++++-------------------- + 5 files changed, 115 insertions(+), 33 deletions(-) + +commit 7cbabbf378cf5a9c0411558ff02b44dec2040ea1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Dec 10 22:00:30 2007 +0100 + + Fix a crash when marked content properties operator is not a dict. + + poppler/Gfx.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e807f9c72c7f0c5cc0655918f676f4af54739442 +Merge: bf57117 e2ea743 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 9 18:07:30 2007 +0100 + + Merge branch 'master' of + ssh://aacid@git.freedesktop.org/git/poppler/poppler + +commit bf57117df8786778faf31e5d843533004f867ff3 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Dec 9 18:07:00 2007 +0100 + + Add support for ActualText entries + + Patch by Adrian Johnson with two minor changes by me (one fordward + declaration and a leak fix) + + poppler/Form.cc | 2 +- + poppler/Gfx.cc | 2 +- + poppler/OutputDev.cc | 2 +- + poppler/OutputDev.h | 2 +- + poppler/PDFDocEncoding.h | 4 ++ + poppler/TextOutputDev.cc | 98 + +++++++++++++++++++++++++++++++++++++++++++++++- + poppler/TextOutputDev.h | 11 ++++++ + 7 files changed, 116 insertions(+), 5 deletions(-) + +commit e2ea7430e7d6db50cbfdac34713915e5b0942a89 +Author: Albert Astals Cid <tsdgeos@localhost.(none)> +Date: Sat Dec 8 23:21:34 2007 +0100 + + disable warnings about assigning const char * to char * + + We have them all over the place and we are not going to fix it as + that'll be too much overhead when re-merging xpdf changes + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit acf70c666d4f534cd97de64d4378bf6399e31fd4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Dec 6 23:58:26 2007 +0100 + + Disable gtk tests if the user disabled glib frontend + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit bb0ec68f21d355081ff75aad641bc3809141e398 +Merge: 5a34cdd b925ea2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Dec 6 18:38:54 2007 +0100 + + Merge branch 'master' of + ssh://aacid@git.freedesktop.org/git/poppler/poppler + +commit b925ea232b6ed5028712600f9aebe453f3b2ba06 +Author: Brad Hards <bradh@kde.org> +Date: Tue Dec 4 19:11:13 2007 +1100 + + Remove redundant check. + + poppler/PSOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 275afca4ef24020273df652ccfdf76c6994e9294 +Author: Brad Hards <bradh@kde.org> +Date: Sun Dec 2 19:45:16 2007 +1100 + + Preserve PDF page labels when we output as postscript. + + Resolves bug 13338. + + poppler/PSOutputDev.cc | 81 + +++++++++++++++++++++++++++++++++++++++++++++++++- + poppler/PSOutputDev.h | 2 ++ + 2 files changed, 82 insertions(+), 1 deletion(-) + +commit 641edb83a457083c13f3e374f6ac6c570dd54d7f +Author: Brad Hards <bradh@kde.org> +Date: Wed Nov 28 19:42:53 2007 +1100 + + Minor API documentation update + + qt4/src/poppler-annotation.h | 81 + ++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 79 insertions(+), 2 deletions(-) + +commit 3635ec6fcbc89daf633c03efb644df9031b80f59 +Author: Brad Hards <bradh@kde.org> +Date: Wed Nov 28 19:42:22 2007 +1100 + + Update doxygen configuration file to version 1.5.3 + + qt4/src/Doxyfile | 185 + ++++++++++++++++++++++++++++++++++++++++++------------- + 1 file changed, 141 insertions(+), 44 deletions(-) + +commit 02c7ea6e1fd3e225de1eda231813f4db0ffb9fdb +Author: Brad Hards <bradh@kde.org> +Date: Wed Nov 28 19:41:54 2007 +1100 + + Fix off-by-one in printCommands path. + + poppler/Gfx.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 74af7c1209f47ed39addf7fde3ea106a7c77a408 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Nov 24 18:12:00 2007 +0100 + + Convert passwords from utf-8 to latin-1 when needed. Fixes bug #4557 + + glib/poppler-document.cc | 16 ++++++++++++++-- + 1 file changed, 14 insertions(+), 2 deletions(-) + +commit 5a34cddf043cb484549cb411e034786a7d8688a3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Nov 23 23:13:57 2007 +0100 + + add a ignore + + glib/demo/.gitignore | 1 + + 1 file changed, 1 insertion(+) + +commit 21a58562cc1e575ec3d81b6e34bfcb21306eb67f +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Nov 23 23:12:06 2007 +0100 + + sscanf does not like null strings, so don't call it on empty qstrings + + qt/poppler-document.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 6f8451cf9d19f57f658d1568643ecb0f953e1075 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sun Nov 11 21:29:40 2007 -0500 + + Add support for knockout groups to the cairo backend + + This is sort of hacky because we need to keep track of shape and + opacity + seperately. It is also probably not entirely correct. However, + it should be + closer than previously. + + poppler/CairoOutputDev.cc | 309 + ++++++++++++++++++++++++++++++++++++++++++++-- + poppler/CairoOutputDev.h | 8 +- + 2 files changed, 303 insertions(+), 14 deletions(-) + +commit b0fbfb0ac366434d7e4c0350a9be83ddda7b03cf +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sun Nov 11 16:06:16 2007 -0500 + + Track the AlphaIsShape and TextKnockout state + + Parse, store and notify the OutputDevices about these entries. + + poppler/Gfx.cc | 14 ++++++++++++++ + poppler/GfxState.h | 6 ++++++ + poppler/OutputDev.h | 2 ++ + 3 files changed, 22 insertions(+) + +commit f6429b13a972f2deb25b3d3a9948dca024a54841 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sat Nov 10 14:08:09 2007 -0500 + + Fix accidental mode change. + + poppler/CairoFontEngine.cc | 0 + poppler/CairoOutputDev.cc | 0 + 2 files changed, 0 insertions(+), 0 deletions(-) + +commit 5797f50a99d1494767edc5928f9c3e9d927b946d +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sat Nov 10 01:52:00 2007 -0500 + + Scale text to match 'm' size + + This adds back the hack that was removed when fontconfig support + was added long + ago. It's not a great solution but lets us be at least as good as + xpdf. Fixes + #12304 with the cairo backend. The problem persists with the splash + backend. + + poppler/CairoFontEngine.cc | 56 + +++++++++++++++++++++++++++++++++++++++++++--- + poppler/CairoFontEngine.h | 7 +++++- + poppler/CairoOutputDev.cc | 8 +++++-- + 3 files changed, 65 insertions(+), 6 deletions(-) + +commit 551212e55127c7e46d9aff3318015fd9b5385687 +Author: Brad Hards <bradh@frogmouth.net> +Date: Sat Nov 10 11:56:15 2007 +0100 + + Fix uninitialized variable access + + Supported by Derek B. Noonburg + + poppler/GfxState.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 934a5ae45eb17bd0e2010be89f55510e8a69816b +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sat Nov 3 13:08:51 2007 -0400 + + Avoiding using floating point when converting to luminance. + + The code now also does proper rounding instead of just truncating. + + poppler/CairoOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 1b3f045a25e5d172357bc87c15ba591c8e1511a7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Nov 8 23:34:07 2007 +0100 + + Move another gmallocn to gmallocn_checkoverflow. Fixes crashes on + incorrect pdf sent by Red Hat + + poppler/Stream.cc | 21 +++++++++++++++------ + 1 file changed, 15 insertions(+), 6 deletions(-) + +commit 944d327fd7036332a33b4ad6476ceca7a650ef6e +Merge: fb1d1f4 c340255 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 7 23:52:47 2007 +0100 + + Merge branch 'master' of + ssh://aacid@git.freedesktop.org/git/poppler/poppler + +commit fb1d1f459784a6c19034212a617268f7f5a90e9c +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 7 23:51:58 2007 +0100 + + merge ftp://ftp.foolabs.com/pub/xpdf/xpdf-3.02pl2.patch + + poppler/Stream.cc | 417 + +++++++++++++++++++++++++++++++----------------------- + poppler/Stream.h | 10 +- + 2 files changed, 245 insertions(+), 182 deletions(-) + +commit c340255f46bc95b5f850abcd3d9bcdc8594199bb +Author: Brad Hards <bradh@kde.org> +Date: Mon Nov 5 20:36:23 2007 +1100 + + Update .gitignore + + Suppress the noise a bit. + + qt4/.gitignore | 1 + + qt4/tests/.gitignore | 3 +++ + test/.gitignore | 2 ++ + 3 files changed, 6 insertions(+) + +commit cebf770379e7d71166e729aebf771a4ca291d48b +Author: Brad Hards <bradh@kde.org> +Date: Mon Nov 5 20:31:18 2007 +1100 + + Add a new unit test, for non-ASCII searching. + + There is a bug report (bug:7063) about not being able + to find text that isn't ASCII. I think that the problem isn't + in poppler core code - this unit test shows we can find + characters as long as they are properly encoded (which the + Qt4 front end does). + + qt4/tests/Makefile.am | 7 ++++++- + qt4/tests/check_search.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 46 insertions(+), 1 deletion(-) + +commit 570fe464a2aae4f22d0b47cce73b8bc36b116e9f +Merge: 1c7b7a0 7875067 +Author: Brad Hards <bradh@kde.org> +Date: Mon Nov 5 15:55:39 2007 +1100 + + Merge branch 'minor-fixes' + +commit 78750679e213d7307cce38166b6af32562e871b8 +Author: Brad Hards <bradh@kde.org> +Date: Mon Nov 5 15:54:36 2007 +1100 + + Additional check for password protected documents + + We need to bail out on locked documents. In the future, + we could probably go interactive, and ask the user for + a password. + + qt4/tests/test-poppler-qt4.cpp | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 1c7b7a0c581b542945cac257202bbb819d33694c +Author: Brad Hards <bradh@kde.org> +Date: Mon Nov 5 15:49:45 2007 +1100 + + Minor Qt4 API documentation fix + + Also, this is a test of my git newbie-ness. + + qt4/src/poppler-form.h | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit b86fc565d175835cf27e9c8632da47a5e0b50237 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Nov 5 00:14:55 2007 +0100 + + Fix FSF address + + glib/demo/fonts.c | 2 +- + glib/demo/fonts.h | 2 +- + glib/demo/forms.c | 2 +- + glib/demo/forms.h | 2 +- + glib/demo/info.c | 2 +- + glib/demo/info.h | 2 +- + glib/demo/links.c | 2 +- + glib/demo/links.h | 2 +- + glib/demo/main.c | 2 +- + glib/demo/outline.c | 2 +- + glib/demo/outline.h | 2 +- + glib/demo/page.c | 2 +- + glib/demo/page.h | 2 +- + glib/demo/render.c | 2 +- + glib/demo/render.h | 2 +- + glib/demo/utils.c | 2 +- + glib/demo/utils.h | 2 +- + glib/poppler-action.cc | 2 +- + glib/poppler-action.h | 2 +- + glib/poppler-attachment.cc | 2 +- + glib/poppler-attachment.h | 2 +- + glib/poppler-document.cc | 2 +- + glib/poppler-document.h | 2 +- + glib/poppler-features.h.in | 2 +- + glib/poppler-form-field.cc | 2 +- + glib/poppler-form-field.h | 2 +- + glib/poppler-page.cc | 2 +- + glib/poppler-page.h | 2 +- + glib/poppler.cc | 2 +- + glib/poppler.h | 2 +- + poppler/PageTransition.cc | 2 +- + poppler/Sound.cc | 2 +- + poppler/Sound.h | 2 +- + qt/poppler-document.cc | 2 +- + qt/poppler-fontinfo.cc | 2 +- + qt/poppler-link-qt3.h | 2 +- + qt/poppler-link.cc | 2 +- + qt/poppler-page-transition-private.h | 2 +- + qt/poppler-page-transition.cc | 2 +- + qt/poppler-page-transition.h | 2 +- + qt/poppler-page.cc | 2 +- + qt/poppler-private.h | 2 +- + qt/poppler-qt.h | 2 +- + qt4/src/poppler-annotation-helper.h | 2 +- + qt4/src/poppler-annotation-private.h | 2 +- + qt4/src/poppler-annotation.cc | 2 +- + qt4/src/poppler-annotation.h | 2 +- + qt4/src/poppler-document.cc | 2 +- + qt4/src/poppler-embeddedfile.cc | 2 +- + qt4/src/poppler-fontinfo.cc | 2 +- + qt4/src/poppler-form.cc | 2 +- + qt4/src/poppler-form.h | 2 +- + qt4/src/poppler-link-extractor-private.h | 2 +- + qt4/src/poppler-link-extractor.cc | 2 +- + qt4/src/poppler-link.cc | 2 +- + qt4/src/poppler-link.h | 2 +- + qt4/src/poppler-page-private.h | 2 +- + qt4/src/poppler-page.cc | 2 +- + qt4/src/poppler-private.h | 2 +- + qt4/src/poppler-ps-converter.cc | 2 +- + qt4/src/poppler-qt4.h | 2 +- + qt4/src/poppler-sound.cc | 2 +- + qt4/src/poppler-textbox.cc | 2 +- + 63 files changed, 63 insertions(+), 63 deletions(-) + +commit 37776afc6f8a5733b41da6fb0f45e7ace4edf737 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Nov 5 00:03:55 2007 +0100 + + Update from http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt + + COPYING | 27 +++++++++++++-------------- + 1 file changed, 13 insertions(+), 14 deletions(-) + +commit 34a90b35998b65539cf1e8f09194d45db71064a1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Nov 4 14:03:35 2007 +0100 + + Remove duplicate checking + + poppler/JBIG2Stream.cc | 8 -------- + 1 file changed, 8 deletions(-) + +commit d694e1dd042fb97fbc62046b69cafe30d6f9ea58 +Merge: ba5b31c 432e657 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Nov 4 13:26:47 2007 +0100 + + Merge branch 'master' of + ssh://aacid@git.freedesktop.org/git/poppler/poppler + +commit ba5b31c6a8b2317332bfa148f6d80f66891fb9ce +Author: Brad Hards <bradh@frogmouth.net> +Date: Sun Nov 4 13:25:12 2007 +0100 + + Require fontconfig >= 2.0 Fixes bug 9020 + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 432e657a49cb097638a79e38c141088039572816 +Author: Jeff Muizelaar <jeff@freiheit.infidigm.net> +Date: Mon Sep 17 19:15:21 2007 -0400 + + Use realloc/free instead of new/delete when resizing GooStrings + + This allows for a large performance improvement when appending a + large number + of characters to a GooString. This is especially helpful for + TextOutputDev on + large PDFs. For example, the following code has the potential to be + O(n) instead of + O(n²) with a good implementation of realloc. + + while (n) { + string.append(character); + n--; + } + + goo/GooString.cc | 30 +++++++++++++++++------------- + 1 file changed, 17 insertions(+), 13 deletions(-) + +commit cb80112afed2c5b9642c3c43f1cc001ed88d08cb +Author: Jonathan Kew <jonathan_kew@sil.org> +Date: Thu Nov 1 20:53:05 2007 +0100 + + Do not try to parse directories when processing nameToUnicode + dir. Fixes ugly warnings on mingw32 + + poppler/GlobalParams.cc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit ad6b888edff7b30be72df948c4052b9934a37705 +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Thu Nov 1 20:48:21 2007 +0100 + + Add some castings to make it compile + + glib/test-poppler-glib.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit a968dcc759379f48265c91bea63ca4cf987d94a9 +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Wed Oct 31 23:53:39 2007 +0100 + + Tests for passwords + + qt4/tests/Makefile.am | 13 +++++- + qt4/tests/check_password.cpp | 87 + ++++++++++++++++++++++++++++++++++++++++ + qt4/tests/stress-poppler-dir.cpp | 63 +++++++++++++++++++++++++++++ + qt4/tests/test-poppler-qt4.cpp | 15 ++++++- + 4 files changed, 175 insertions(+), 3 deletions(-) + +commit 7b7a08863a8278dee7aa1fe7789cf72223c26b35 +Author: Brad Hards <bradh@frogmouth.net> +Date: Wed Oct 31 23:53:27 2007 +0100 + + Improve documentation + + qt4/src/poppler-qt4.h | 64 + ++++++++++++++++++++++++++++++++++++++++++++------- + 1 file changed, 56 insertions(+), 8 deletions(-) + +commit 96493c9409186a7e964e894c7f730962b6995fd7 +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Wed Oct 31 23:51:25 2007 +0100 + + remove old file + + glib/test-poppler-glib.c | 514 + ----------------------------------------------- + 1 file changed, 514 deletions(-) + +commit 951a05f7a11af4a44e4cb85a015939d6a3e513f5 +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Sat Oct 27 12:33:22 2007 +0200 + + Remove fordward declaration of a non-existant class + + poppler/Form.h | 1 - + 1 file changed, 1 deletion(-) + +commit 289679405ab143bc2106cf269227c514a1602e56 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Thu Oct 25 22:16:10 2007 -0400 + + Avoid drawing borders unless /W and /S are specified in /BS + + Acroread doesn't sometimes doesn't draw borders when you'd + expect it to. Special case that behaviour so that we do the + same thing. + + poppler/Annot.cc | 15 ++++++++++++--- + 1 file changed, 12 insertions(+), 3 deletions(-) + +commit ab0a6c37faf9916edcd70e128d9f2654eb795ace +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Thu Oct 25 20:56:58 2007 +0200 + + Fix compilation on mingw. Bug 12493 + + Added a check for localtime_r in configure.ac + Moved test-poppler-glib.c to test-poppler-glib.cc to get the correct + compiler + + configure.ac | 1 + + glib/Makefile.am | 2 +- + glib/test-poppler-glib.cc | 520 + ++++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 522 insertions(+), 1 deletion(-) + +commit 6bd637dc135045b20abf024d394538d7a3160795 +Merge: c01ab71 25b273d +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Tue Oct 23 23:27:01 2007 +0200 + + Merge branch 'master' of + ssh://aacid@git.freedesktop.org/git/poppler/poppler + +commit c01ab714ecd42e39ecb0be1c0c2504635251ac01 +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Tue Oct 23 23:26:21 2007 +0200 + + Provide setters for some methods that only had getters. Fixes + bug 12894 + + poppler/GlobalParams.cc | 49 + +++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/GlobalParams.h | 7 +++++++ + 2 files changed, 56 insertions(+) + +commit 25b273db677815c8df11e52fe9df29fe857a8a88 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Mon Oct 22 23:01:37 2007 -0400 + + Unset the font if it doesn't exist or we can not load it properly + + Previously, the previous font stayed current and glyphs would be + drawn using + it. This resulted in random glyphs being chosen unless the encodings + happened + to match. Now, instead, we draw nothing which matches the behaviour of + acroread. + + poppler/Gfx.cc | 4 ++++ + poppler/GfxFont.cc | 4 ++++ + 2 files changed, 8 insertions(+) + +commit 57331767ed5306eba1f9bf60e48fc88debdc2198 +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Mon Oct 22 23:33:59 2007 +0200 + + builddir != srcdir fixes by Christian Persch <chpe gnome org> + + autogen.sh | 7 ++++--- + glib/demo/Makefile.am | 1 + + 2 files changed, 5 insertions(+), 3 deletions(-) + +commit 2a333e5a618b5c92f3c703816b950321f25d3aab +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Mon Oct 22 22:14:43 2007 +0200 + + Splash rework, check if font is inside clip area before rendering + it to a temporary bitmap. Fixes KDE bug 150693 + + This change is not trivial. What i did is: + It is getGlyph the one that does the intersection between clip area + and rendering area of the font instead fillGlyph2 + That means some clipRes = state->clip->testRect but we win more + robustness against broken pdf that specify HUGE fonts + + splash/Splash.cc | 207 + ++++++++++++++++++++++++------------------------- + splash/Splash.h | 4 +- + splash/SplashFTFont.cc | 23 +++++- + splash/SplashFTFont.h | 4 +- + splash/SplashFont.cc | 29 +++++-- + splash/SplashFont.h | 5 +- + splash/SplashT1Font.cc | 11 ++- + splash/SplashT1Font.h | 4 +- + 8 files changed, 162 insertions(+), 125 deletions(-) + +commit cf785cd12ae77e8dd778ed043584f8f26efe675f +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Mon Oct 22 21:59:35 2007 +0200 + + Add gmallocn_checkoverflow, it's the same as gmallocn but returns + NULL on overflow instead of doing exit() + + goo/gmem.cc | 18 ++++++++++++++++++ + goo/gmem.h | 3 +++ + 2 files changed, 21 insertions(+) + +commit 37e16ac301a35ceca2e3535f8c6100d4cf723c82 +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Mon Oct 22 21:54:02 2007 +0200 + + exit(1) is bad in library code, use the src.abort method to describe + failure + + poppler/DCTStream.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit dbe975c129999a3efceb1c86518fa6fda74f685c +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Oct 22 11:25:37 2007 +0200 + + Fix a crash with invalid TrueType fonts + + fofi/FoFiTrueType.cc | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +commit 8bfe30a48fd7021591ab307bd51f86c06ff202b9 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Oct 19 15:46:50 2007 +0200 + + Do not generate appearance stream for radio button that are not active + + poppler/Annot.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 1a531dcfee1c6fc79a414c38cbe7327fbf9a59d8 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Oct 19 13:12:24 2007 +0200 + + Fix a crash with invalid embedded fonts + + poppler/CairoFontEngine.cc | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit e1740278457e512676b623bcdf9968193f0a8d7b +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Oct 19 12:21:54 2007 +0200 + + Do not draw annotations when rendering for printing + + glib/poppler-page.cc | 25 ++++++++++++++++++++++--- + poppler/Annot.h | 2 ++ + 2 files changed, 24 insertions(+), 3 deletions(-) + +commit a4d25f79dfc1a7e4998e2e113ef92312bd4af553 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Oct 16 15:24:08 2007 +0200 + + Detect form fields at any depth level + + We were ignoring non root form fields that contain only a kids + dictionary. + See evince bug: http://bugzilla.gnome.org/show_bug.cgi?id=486957 + + poppler/Form.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 03e1da99f7393fb1103643311b0b5af7b875e09c +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sat Oct 13 19:38:15 2007 -0400 + + Add an implementation of CairoOutputDev::startPage() + + The implementation initializes fill_pattern and stroke_pattern + to black matching SplashOutputDev. This fixes #12504. + + poppler/CairoOutputDev.cc | 9 +++++++++ + poppler/CairoOutputDev.h | 2 +- + 2 files changed, 10 insertions(+), 1 deletion(-) + +commit 825c942d46e0c3e254028441015c5dd8440cc734 +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Fri Oct 12 13:47:09 2007 +0200 + + Copy the embeddef file description string correctly + + poppler/Catalog.cc | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit 5e60da78695eff44cc10dbce46ef170727f682b1 +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Fri Oct 12 13:46:52 2007 +0200 + + Correctly delete the embedded file stream + + qt4/src/poppler-embeddedfile.cc | 1 + + qt4/src/poppler-private.h | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +commit 1627fbbde8be01af3bdd2583f3439897a37d5215 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sat Oct 6 23:27:40 2007 -0400 + + Use maskWidth and maskHeight for reading from the mask image in + CairoOutputDev::drawMaskedImage() + + Previously, drawMaskedImage() was incorrectly using the image width + and height which is + wrong when width != maskWidth or heigh != maskHeight. Fixes #12668. + + poppler/CairoOutputDev.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 3156d560c5eaf6970da422d0b09fd2e95bfe6d1d +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Oct 5 11:34:01 2007 +0200 + + Fix a crash when Form Fields array contains references + to non existent objects. Fixes bug #11865 + + poppler/Form.cc | 9 +++++++++ + 1 file changed, 9 insertions(+) + +commit f0b5e6286e94c6153c8247b5fae63a18622c48d3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Oct 4 15:22:01 2007 +0200 + + Do not return unknown field type for signature form fields + + glib/poppler-form-field.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 498fd7fb99b01a879d07e2ad12c0b9462a8fc438 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Oct 4 12:36:39 2007 +0200 + + Add poppler_page_render_for_printing() and + poppler_page_render_to_pixbuf_for_printing() + + We were unconditionally passing printing=gFalse to displaySlice. With + these new + functions we can render to a pixbuf or cairo surface passing + printing=gTrue to + displaySlice. + + glib/poppler-page.cc | 135 + +++++++++++++++++++++++++++++++++++++++++---------- + glib/poppler-page.h | 10 ++++ + 2 files changed, 119 insertions(+), 26 deletions(-) + +commit 56af69787c78c2edbb69266e86a5a5b639ca6d3e +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed Oct 3 23:02:25 2007 -0400 + + Error out if we can't find a .cidToUnicode for a known character + collection + + This situation was caused by the fixes for bug #11413. I'm not sure + it's the best thing to do, but it seems better. + + poppler/GfxFont.cc | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +commit 3d0df46908379bce1d196b9dc41153b1adb5f725 +Author: Michael Wolf <maw@ximian.com> +Date: Wed Oct 3 19:43:55 2007 +0200 + + Fix compile warning + + glib/test-poppler-glib.c | 2 ++ + 1 file changed, 2 insertions(+) + +commit aba29e12528025c2cc71bf46e02e76ac4db2b193 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Sep 28 21:01:50 2007 +0200 + + Add forms demo to glib poppler demo + + glib/demo/Makefile.am | 2 + + glib/demo/forms.c | 489 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + glib/demo/forms.h | 31 ++++ + glib/demo/main.c | 8 +- + glib/demo/utils.c | 1 - + 5 files changed, 527 insertions(+), 4 deletions(-) + +commit d0c0f26d2c95232c216e3daa15e98a3aff14ac27 +Merge: 59d55f7 38d5bb1 +Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> +Date: Tue Sep 25 03:33:52 2007 -0700 + + Merge branch 'master' of + ssh://kjk@git.freedesktop.org/git/poppler/poppler + +commit 38d5bb150a5fe883da1d4256463d1f796d201283 +Author: Krzysztof Kowalczyk <kkowalczyk@kjkubu.(none)> +Date: Tue Sep 25 16:13:51 2007 -0700 + + Silence deprecation warnings - annoying with msvc 2005. + + makefile.vc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 59d55f7371bee81c9392fa2d4174ceffaacde471 +Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> +Date: Tue Sep 25 01:21:19 2007 -0700 + + Fix misleading comment. + + goo/GooTimer.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit c36d8afc984795aca0a12a94ec7668092067db82 +Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> +Date: Tue Sep 25 00:32:29 2007 -0700 + + Revert "replace extremely confusing 'a*(int)sizeof(foo)/sizeof(foo) + != a' which, due to type promotions, if a is int, is equivalent to + a < 0; fix problems revealed by the change" + + This reverts commit 08bf7c1151d594d4c7d253a2c89f4f3a088ad8ec. + + poppler/XRef.cc | 25 +++++++++++++++++++++---- + 1 file changed, 21 insertions(+), 4 deletions(-) + +commit ff25e83abae1ca17e2e7dd6f20946026fca69fff +Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> +Date: Mon Sep 24 23:57:25 2007 -0700 + + Make perf-test compile on unix as well. + + test/Makefile.am | 16 ++++++- + test/perf-test-preview-dummy.cc | 1 + + test/perf-test.cc | 104 + +++++++++++++++++----------------------- + 3 files changed, 59 insertions(+), 62 deletions(-) + +commit 70f3bf42b3028d9a2e4aefdc2e1a458b3c77b0e7 +Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> +Date: Mon Sep 24 21:26:54 2007 -0700 + + Let perf-test.cc manage lifetime of rendered bitmap. + + test/perf-test-preview-win.cc | 7 ------- + 1 file changed, 7 deletions(-) + +commit b622b252cba068a15eae77df5deb261dd98affaf +Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> +Date: Mon Sep 24 21:20:12 2007 -0700 + + Disable my_error for now - seems to corrupt memory. + + test/perf-test.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit bde8c9669ca6b43cb6a664bd14df164a718041ea +Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> +Date: Mon Sep 24 21:08:58 2007 -0700 + + Con't copy the file unless COPY_FILE is defined. + + test/perf-test.cc | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +commit bf9b46b012c64624818a2110af7c4b7e3b419728 +Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> +Date: Mon Sep 24 20:13:54 2007 -0700 + + Respect -loadonly cmd-line arg. + + test/perf-test.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit 2f664b654ca19135f0f8a0fe89872b9e0d526fa2 +Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> +Date: Mon Sep 24 19:41:45 2007 -0700 + + Fix msvc debug build. Fix bitmap leak in perf-test. + + makefile.vc | 6 ++++-- + test/perf-test.cc | 1 + + 2 files changed, 5 insertions(+), 2 deletions(-) + +commit 05d41cd5aec39b4e3c8949445a9986e5ca8b50dd +Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> +Date: Mon Sep 24 08:10:37 2007 -0700 + + Use GooTimer instead of my own timer. + + test/perf-test.cc | 98 + +++++-------------------------------------------------- + 1 file changed, 8 insertions(+), 90 deletions(-) + +commit 05fbce5b6657e883ece9054c79576b25271a05a4 +Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> +Date: Mon Sep 24 08:01:11 2007 -0700 + + Make GooTimer work for Windows/msvc build. + + goo/GooTimer.cc | 69 + +++++++++++++++++++++++++++++++++++++++------------------ + goo/GooTimer.h | 28 ++++++++++++++--------- + poppler/Gfx.cc | 11 ++------- + 3 files changed, 66 insertions(+), 42 deletions(-) + +commit 6347915085a487da08d39a859f4261fa812dab09 +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Mon Sep 24 01:08:17 2007 -0700 + + Add Error.cc in msvc build and use setErrorFunction in perf-test. + + makefile.vc | 3 +-- + test/perf-test.cc | 10 +++++----- + 2 files changed, 6 insertions(+), 7 deletions(-) + +commit ed01b3965c57ce2a4eabf9c46b5319ea627d3324 +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Mon Sep 24 01:03:09 2007 -0700 + + Match declaration of setErrorFunction with its definition. + + Also enable this code for Windows, since CDECL was what + was throwing msvc off. + + poppler/Error.cc | 12 +++--------- + 1 file changed, 3 insertions(+), 9 deletions(-) + +commit 71fb15f8bd131a13d8cf0f394fe601cfbb6e1772 +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Mon Sep 24 00:38:29 2007 -0700 + + Even less compiler warnings. + + poppler/CairoOutputDev.cc | 6 +++--- + qt/poppler-page.cc | 3 +++ + utils/HtmlOutputDev.cc | 10 ++++++---- + 3 files changed, 12 insertions(+), 7 deletions(-) + +commit 7ba3f198a0651d2a7c91b7d9e10a5173dc3de0a3 +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Mon Sep 24 00:32:37 2007 -0700 + + Even less compiler warnings. + + qt/poppler-document.cc | 8 ++++++++ + qt/poppler-private.h | 8 -------- + qt4/src/poppler-document.cc | 10 ++++++++++ + qt4/src/poppler-form.cc | 15 +++++++++++++++ + qt4/src/poppler-private.h | 25 ------------------------- + 5 files changed, 33 insertions(+), 33 deletions(-) + +commit ab1059f594cb9fccd8568ca2a535a363c7521daa +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Mon Sep 24 00:14:01 2007 -0700 + + Don't break aliasing. + + poppler/GlobalParams.cc | 40 ++++++++++++++++++---------------------- + 1 file changed, 18 insertions(+), 22 deletions(-) + +commit 71c47b30adf687a0bcece22834933267053360de +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Sun Sep 23 23:49:31 2007 -0700 + + Reduce compiler warnings. + + poppler/JBIG2Stream.cc | 16 ++++++++++++---- + 1 file changed, 12 insertions(+), 4 deletions(-) + +commit 8466d94929844c976bbad8bb7d1ea7f7f77cc196 +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Sun Sep 23 23:34:52 2007 -0700 + + Reduce compiler warnings. Tabs to spaces. + + fofi/FoFiType1C.cc | 30 +++++++++++++++--------------- + 1 file changed, 15 insertions(+), 15 deletions(-) + +commit c53b8ccfba6fa4345086493f9e44212721c11d0a +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Sun Sep 23 23:23:34 2007 -0700 + + Reduce number of compiler warnings. + + poppler/CharCodeToUnicode.cc | 2 +- + poppler/Gfx.cc | 6 ++---- + poppler/PageLabelInfo.cc | 2 ++ + 3 files changed, 5 insertions(+), 5 deletions(-) + +commit abede2a06c5c9dc97b40479deda49621458f1171 +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Sun Sep 23 23:03:36 2007 -0700 + + Reduce number of compiler warnings. + + glib/poppler-action.cc | 1 - + glib/poppler-document.cc | 9 ++------- + glib/poppler-page.cc | 3 +-- + qt/poppler-document.cc | 1 - + qt4/src/poppler-annotation.cc | 16 +++++++++++++--- + 5 files changed, 16 insertions(+), 14 deletions(-) + +commit 60f5bcea4a920441e25ae11d677636242aabb2db +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Sun Sep 23 22:48:06 2007 -0700 + + Remove unused variables. + + utils/pdftoppm.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 3179eee44eb0afbc642675268b9a4abb16ccdde3 +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Sun Sep 23 22:47:21 2007 -0700 + + Remove unused variables. + + utils/HtmlOutputDev.cc | 23 ----------------------- + 1 file changed, 23 deletions(-) + +commit e9dc379190aa3166870d0b11a05ccc4e9dad2706 +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Sun Sep 23 22:41:59 2007 -0700 + + Remove unused variables. + + poppler/ArthurOutputDev.cc | 16 +++++----------- + 1 file changed, 5 insertions(+), 11 deletions(-) + +commit 08bf7c1151d594d4c7d253a2c89f4f3a088ad8ec +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Sun Sep 23 22:28:16 2007 -0700 + + replace extremely confusing 'a*(int)sizeof(foo)/sizeof(foo) != a' + which, due to type promotions, if a is int, is equivalent to a < 0; + fix problems revealed by the change + + poppler/XRef.cc | 25 ++++--------------------- + 1 file changed, 4 insertions(+), 21 deletions(-) + +commit 5a1f670a4d16affeed86cdf643ab22f481caa3a5 +Author: Krzysztof Kowalczyk <kkowalczyk@kjkubu.(none)> +Date: Sun Sep 23 20:42:59 2007 -0700 + + ignore *.o files + + .gitignore | 1 + + 1 file changed, 1 insertion(+) + +commit c156aed7234f82dea4cb384c1b8a7acdd34545be +Author: Krzysztof Kowalczyk <kkowalczyk@kjkubu.(none)> +Date: Sun Sep 23 20:41:19 2007 -0700 + + remove unused variables + + poppler/ABWOutputDev.cc | 10 ++-------- + 1 file changed, 2 insertions(+), 8 deletions(-) + +commit d0bdef4752be5fa609a0766ee87aa54d51611d9a +Author: Krzysztof Kowalczyk <kkowalczyk@kjkubu.(none)> +Date: Sat Sep 22 13:38:03 2007 -0700 + + undo accidental changes to file permissions + + msvc/poppler/poppler-config.h | 0 + poppler/Annot.cc | 0 + poppler/CairoFontEngine.cc | 0 + poppler/CairoOutputDev.cc | 0 + poppler/Catalog.cc | 0 + poppler/Form.cc | 0 + poppler/GfxFont.cc | 0 + poppler/GfxState.cc | 0 + poppler/Page.cc | 0 + poppler/SplashOutputDev.cc | 0 + poppler/TextOutputDev.cc | 0 + splash/Splash.cc | 0 + splash/SplashFTFontEngine.cc | 0 + test/perf-test-preview-dummy.cc | 0 + test/perf-test-preview-win.cc | 0 + test/perf-test.cc | 0 + 16 files changed, 0 insertions(+), 0 deletions(-) + +commit 6c69473f2f4a49757614ddd249e65bb7a13c63c1 +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Fri Sep 21 08:09:53 2007 -0700 + + undo accidental mode change + + makefile.vc | 0 + 1 file changed, 0 insertions(+), 0 deletions(-) + +commit e7e386e7ce8cb8eb8a7037ebdaa601524d332ae7 +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Fri Sep 21 08:08:53 2007 -0700 + + more simplification by removing unneded code + + makefile.vc | 2 +- + test/perf-test.cc | 60 + +++++++++---------------------------------------------- + 2 files changed, 10 insertions(+), 52 deletions(-) + +commit 3e10604637ec193269a3155985476d3b83dc7d62 +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Fri Sep 21 07:48:38 2007 -0700 + + for portability use bool/true/false instead of BOOL/TRUE/FALSE + + test/perf-test.cc | 176 + ++++++++++++++++++++++++++---------------------------- + 1 file changed, 86 insertions(+), 90 deletions(-) + +commit 634718936f2a95fac2a9d12fcea483b3d0ca8fa6 +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Fri Sep 21 07:41:14 2007 -0700 + + simplify perf-test + + test/perf-test-pdf-engine.h | 78 + ------------------------------------------- + test/perf-test-preview-win.cc | 5 ++- + test/perf-test.cc | 75 + +++++++++++++++++++++++++++++++++++++++-- + 3 files changed, 75 insertions(+), 83 deletions(-) + +commit 617550199762fab42ca2e202e641e047b3efbac0 +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Fri Sep 21 05:20:16 2007 -0700 + + simplify perf-test code + + test/perf-test-pdf-engine.h | 67 +++-------------------- + test/perf-test-preview-dummy.cc | 3 +- + test/perf-test-preview-win.cc | 80 ++++++++++++++++++++++++---- + test/perf-test.cc | 114 + ++++------------------------------------ + 4 files changed, 86 insertions(+), 178 deletions(-) + +commit fb5bf808b88992c1772a10e4ed9fe788fb618417 +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Fri Sep 21 03:03:26 2007 -0700 + + more msvc build fixes + + makefile.vc | 2 +- + test/perf-test.cc | 4 ++++ + 2 files changed, 5 insertions(+), 1 deletion(-) + +commit 60829b08a7440f36014f68ec54bee7a742412738 +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Fri Sep 21 03:02:34 2007 -0700 + + msvc build fixes + + msvc/poppler/poppler-config.h | 143 + ++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 143 insertions(+) + +commit 853c22a174bae81139edc9aeded7f26ae2655cef +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Thu Sep 20 23:21:35 2007 -0700 + + add pre-made config.h for msvc build + + msvc/config.h | 62 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 62 insertions(+) + +commit 31c43b118bd4372134018be6f6693f77d1f6a39b +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Thu Sep 20 22:10:09 2007 -0700 + + remove unused variables + + poppler/CairoFontEngine.cc | 6 ++---- + poppler/CairoOutputDev.cc | 14 ++------------ + splash/SplashFTFontEngine.cc | 2 ++ + 3 files changed, 6 insertions(+), 16 deletions(-) + +commit 01b99f60e36dd955817f23911ef38947360f61f7 +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Thu Sep 20 21:14:17 2007 -0700 + + remove unused variables + + poppler/GfxState.cc | 11 ++--------- + poppler/SplashOutputDev.cc | 9 +++------ + poppler/TextOutputDev.cc | 3 --- + 3 files changed, 5 insertions(+), 18 deletions(-) + +commit 7c406400532d68524a43cf963d894d3c4b269400 +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Thu Sep 20 20:57:44 2007 -0700 + + remove unused variables + + poppler/Catalog.cc | 1 - + poppler/Form.cc | 5 ----- + poppler/GfxFont.cc | 6 ++---- + poppler/Page.cc | 2 +- + splash/Splash.cc | 5 ++++- + 5 files changed, 7 insertions(+), 12 deletions(-) + +commit 70f23389c97b1870b7311d97322cdd16b580a79d +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Thu Sep 20 20:23:59 2007 -0700 + + don't silence warnings about unused variables/functions to keep + programmers honest + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit cdb6fcf98137473efd993e1374a6f010e9db67db +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Thu Sep 20 20:00:56 2007 -0700 + + Remove unused variables + + poppler/Annot.cc | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +commit 0e76b49ac852a5a7ebae4c1f67b153e0b7c9f905 +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Tue Sep 18 01:04:50 2007 -0700 + + Explain how to compile on Windows using msvc makefile. + + README.windows | 63 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 63 insertions(+) + +commit c002b4dc75b2688ffe8a734cf3e15f5891797842 +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Tue Sep 18 00:04:47 2007 -0700 + + Add Windows/msvc makefile. + + Add native msvc windows makefile and pre-made + config.h for windows in msvc directory. + + makefile.vc | 149 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 149 insertions(+) + +commit 1f33fc58201c92120c587189d2e0e819f83167da +Author: Krzysztof Kowalczyk <kkowalczyk@tlapx60ubu.(none)> +Date: Mon Sep 17 23:53:02 2007 -0700 + + Start on a test program. + + Test program can be used for regression testing and + performance testing. It renders a page (or pages) + in a given PDF (or PDFs) and records rendering times. + For historical reasons the code is ugly and probably + only compiles on windows, but it'll get better. + + test/perf-test-pdf-engine.h | 131 ++++ + test/perf-test-preview-dummy.cc | 22 + + test/perf-test-preview-win.cc | 222 ++++++ + test/perf-test.cc | 1428 + +++++++++++++++++++++++++++++++++++++++ + 4 files changed, 1803 insertions(+) + +commit b96db4ad27535c2666fccdfe0a3c04cc7c37792d +Author: Jeff Muizelaar <jeff@freiheit.infidigm.net> +Date: Mon Sep 17 20:28:38 2007 -0400 + + Avoid double free caused by 302 merge + + The ownership of the the string returned by getKey() changed with + the 302 merge + but this code was not updated. Found by Matthew Woehlke. + + qt4/src/poppler-document.cc | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +commit 2a495f19d4465e15fd2fa96656d904315c79a443 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Sep 17 16:52:45 2007 -0400 + + Simplify ChangeLog rule a bit. + + ChangeLog.mk | 81 + ------------------------------------------------------------ + Makefile.am | 7 +++--- + 2 files changed, 4 insertions(+), 84 deletions(-) + +commit 7d5abbeec55e4b90b139671d96cfdf58bdab70b8 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Sep 17 15:45:26 2007 -0400 + + Add dist hook to generate ChangeLog. + + Taken from cairo. It still need some tweaking. + + ChangeLog.mk | 81 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Makefile.am | 4 +++ + configure.ac | 2 +- + 3 files changed, 86 insertions(+), 1 deletion(-) + +commit 15ad81c64cd8b1cb438d41be402daa19a239db3d +Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> +Date: Mon Sep 17 19:39:29 2007 +0200 + + Use = instead of == in qt.m4 + + m4/qt.m4 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 70fabcb96e207b9b889bb32c0cf5ea3fc0aa08f8 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sun Sep 16 20:40:53 2007 -0400 + + Rename .cvsignore files to .gitignore and drop ChangeLog file. + + .cvsignore | 25 - + .gitignore | 25 + + ChangeLog | 4586 + --------------------------------------------- + fofi/.cvsignore | 8 - + fofi/.gitignore | 8 + + glib/.cvsignore | 11 - + glib/.gitignore | 11 + + glib/reference/.cvsignore | 18 - + glib/reference/.gitignore | 18 + + goo/.cvsignore | 8 - + goo/.gitignore | 8 + + poppler/.cvsignore | 10 - + poppler/.gitignore | 10 + + qt/.cvsignore | 7 - + qt/.gitignore | 7 + + qt4/.cvsignore | 3 - + qt4/.gitignore | 3 + + qt4/src/.cvsignore | 8 - + qt4/src/.gitignore | 8 + + qt4/tests/.cvsignore | 20 - + qt4/tests/.gitignore | 20 + + splash/.cvsignore | 8 - + splash/.gitignore | 8 + + test/.cvsignore | 11 - + test/.gitignore | 11 + + utils/.cvsignore | 12 - + utils/.gitignore | 12 + + 27 files changed, 149 insertions(+), 4735 deletions(-) + +commit c9f9403ffc5b95ae790c3c81284c7786afe33f4d +Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> +Date: Fri Sep 14 20:50:07 2007 +0000 + + Windows implementation for matching fonts that doesn't use fontconfig + + ChangeLog | 6 + + poppler/GlobalParamsWin.cc | 285 + +++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 291 insertions(+) + +commit d18b5361a0504458da805ed6be037c9d648f9372 +Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> +Date: Fri Sep 14 20:47:11 2007 +0000 + + Update ChangeLog for previous checkin + + ChangeLog | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +commit 3330763ddca66b30d5ee60aab94d6fe0bbae9c8f +Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> +Date: Fri Sep 14 06:17:35 2007 +0000 + + windows/msvc compilation fixes + + poppler/DCTStream.h | 2 +- + poppler/Error.cc | 6 ++++++ + poppler/FlateStream.h | 2 +- + poppler/GlobalParams.cc | 12 ++++++++++-- + poppler/GlobalParams.h | 17 +++++++++++++++++ + poppler/Stream.cc | 2 +- + splash/SplashFTFontEngine.cc | 2 ++ + splash/SplashFontEngine.cc | 2 +- + splash/SplashFontFile.cc | 2 ++ + splash/SplashFontFile.h | 3 ++- + splash/SplashT1FontEngine.cc | 2 +- + 11 files changed, 44 insertions(+), 8 deletions(-) + +commit 6eb159ef34eb7e2fb8adcfc48afd84d5f50efbbd +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 10 17:38:05 2007 +0000 + + * autogen.sh: Support automake-1.10. + Patch by Krzysztof Kowalczyk <kkowalczyk@gmail.com> + + ChangeLog | 5 +++++ + autogen.sh | 11 ++++++----- + 2 files changed, 11 insertions(+), 5 deletions(-) + +commit 31bbc8c727cfecc79bd8da962ad8d99a0d1d3d33 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 8 10:40:17 2007 +0000 + + * qt4/src/poppler-qt4.h: + * qt4/src/poppler-ps-converter.cc: + Add PSConverter::setOutputDevice() to set a QIODevice where + writing the resulting PS. + + ChangeLog | 7 ++++++ + qt4/src/poppler-ps-converter.cc | 51 + +++++++++++++++++++++++++++++++++++++---- + qt4/src/poppler-qt4.h | 5 +++- + 3 files changed, 58 insertions(+), 5 deletions(-) + +commit b3d63d03c310f01cc5b23d00ffd2103c6891fef2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 5 20:22:32 2007 +0000 + + * qt4/src/poppler-ps-converter.cc: Fix Right<->Left + interchange + + ChangeLog | 1 + + qt4/src/poppler-ps-converter.cc | 4 ++-- + 2 files changed, 3 insertions(+), 2 deletions(-) + +commit 64368582d5ca4e28c236f440482c96f1dd3a8897 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 5 18:22:52 2007 +0000 + + * poppler/PSOutputDev.cc: Fix printing of second parameter + + ChangeLog | 4 ++++ + poppler/PSOutputDev.cc | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +commit eaf9d06cf0d08ccdc183759e0331dc2439a6f10f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Sep 5 10:57:09 2007 +0000 + + 2007-09-05 Carlos Garcia Campos <carlosgc@gnome.org> + * glib/poppler-page.cc: + * glib/demo/render.c: Fix build with --disable-cairo-output. + + ChangeLog | 5 +++++ + glib/demo/render.c | 31 +++++++++++++++++++++++++++---- + glib/poppler-page.cc | 22 ++++++++++++---------- + 3 files changed, 44 insertions(+), 14 deletions(-) + +commit c0f488c2b0e115be3e1b7e4dc7baa38db5837498 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 4 22:04:52 2007 +0000 + + did not want to commit this + + gtk-doc.make | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 3462851b4ea342651095f1803cd488bc3b3f5749 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 4 22:02:06 2007 +0000 + + * utils/pdftoppm.cc: Fix build on Sun Studio compiler. + Patch by Brian Cameron <brian.cameron@sun.com> + + ChangeLog | 5 +++++ + gtk-doc.make | 2 +- + utils/pdftoppm.cc | 2 +- + 3 files changed, 7 insertions(+), 2 deletions(-) + +commit cdf3b9062cc54d558b8dbeefb3211a920ff2cb94 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 3 19:23:11 2007 +0000 + + write news + fix qt4 build + + NEWS | 13 +++++++++++++ + qt4/src/Makefile.am | 3 ++- + 2 files changed, 15 insertions(+), 1 deletion(-) + +commit c82208a44f3b09c27bc33831641e4f746dd4361f +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 3 18:28:44 2007 +0000 + + * configure.ac: Bump version to 0.6 + * glib/Makefile.am + * poppler/Makefile.am + * qt/Makefile.am + * qt4/src/Makefile.am: Bump sonames + + ChangeLog | 8 ++++++++ + configure.ac | 2 +- + glib/Makefile.am | 2 +- + poppler/Makefile.am | 2 +- + qt/Makefile.am | 2 +- + qt4/src/Makefile.am | 2 +- + 6 files changed, 13 insertions(+), 5 deletions(-) + +commit 2a12409ebbf96ea3ca4556b71231a45ae37cb052 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 3 17:09:01 2007 +0000 + + * poppler/JBIG2Stream.cc: + * poppler/Stream.cc: Patch by Derek B. Noonburg + <derekn@foolabs.com> + to fix some errors in CCITTFaxStream and JBIG2Stream.cc + + ChangeLog | 6 ++++++ + poppler/JBIG2Stream.cc | 7 ++++--- + poppler/Stream.cc | 2 +- + 3 files changed, 11 insertions(+), 4 deletions(-) + +commit 0b483e71ef02b4040b665935c1018c8b30b9c1ca +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Sep 3 08:54:01 2007 +0000 + + 2007-09-03 Carlos Garcia Campos <carlosgc@gnome.org> + * gtk-doc.make: + * glib/poppler-document.cc: + * glib/poppler-form-field.cc: + * glib/poppler-page.cc: + * glib/reference/poppler-docs.sgml: + * glib/reference/poppler-sections.txt: + * glib/reference/poppler.types: + * glib/reference/tmpl/poppler-action.sgml: + * glib/reference/tmpl/poppler-attachment.sgml: + * glib/reference/tmpl/poppler-document.sgml: + * glib/reference/tmpl/poppler-enums.sgml: + * glib/reference/tmpl/poppler-form-field.sgml: + * glib/reference/tmpl/poppler-page.sgml: + * glib/reference/tmpl/poppler-private.sgml: + * glib/reference/tmpl/poppler.sgml: Update glib bindings API + documentation. + + ChangeLog | 19 ++ + glib/poppler-document.cc | 10 + + glib/poppler-form-field.cc | 205 ++++++++++++++++++ + glib/poppler-page.cc | 12 +- + glib/reference/poppler-docs.sgml | 2 + + glib/reference/poppler-sections.txt | 108 +++++++++- + glib/reference/poppler.types | 2 + + glib/reference/tmpl/poppler-action.sgml | 36 +++- + glib/reference/tmpl/poppler-attachment.sgml | 65 ++++++ + glib/reference/tmpl/poppler-document.sgml | 50 +++++ + glib/reference/tmpl/poppler-enums.sgml | 60 ++++++ + glib/reference/tmpl/poppler-form-field.sgml | 315 + ++++++++++++++++++++++++++++ + glib/reference/tmpl/poppler-page.sgml | 236 ++++++++++++++++++++- + glib/reference/tmpl/poppler-private.sgml | 6 + + glib/reference/tmpl/poppler.sgml | 49 +++++ + gtk-doc.make | 34 +-- + 16 files changed, 1181 insertions(+), 28 deletions(-) + +commit 289e3893cda45055951bb8d3b82a45644bc0b6c6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 2 17:02:55 2007 +0000 + + * poppler/GfxState.cc: Pad zeroes instead of aborting when + rendering + 1-bit images and the stream is "too short" to mimic + Acroread and + ghostscript behaviour. Patch by <darren.kenny@sun.com>. Fixes + #12208 + + ChangeLog | 3 +++ + poppler/GfxState.cc | 4 ++-- + 2 files changed, 5 insertions(+), 2 deletions(-) + +commit 6f6c2180aca2e26ea0e3c2f21f11bc8f457c19c0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 2 16:31:19 2007 +0000 + + * glib/demo/Makefile.am: Add + $(top_builddir)/poppler/libpoppler.la + * poppler/TextOutputDev.cc: Patch from Ed Catmur + <ed@catmur.co.uk> to + improve matching of half strings of decomposed + characters/ligatures. + + ChangeLog | 3 +++ + glib/demo/Makefile.am | 1 + + poppler/TextOutputDev.cc | 21 +++++++++++++-------- + 3 files changed, 17 insertions(+), 8 deletions(-) + +commit be1b5a0196cdfc78f74e08a023b477cac16eb0f3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 2 16:06:03 2007 +0000 + + poppler/PDFDoc.cc: Don't enforce %%EOF at the end of file + + ChangeLog | 4 ++++ + poppler/PDFDoc.cc | 3 ++- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit 500a87af9240344806c18ebbd05a89f4f4c69955 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sun Sep 2 00:53:42 2007 +0000 + + 2007-09-01 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: + * poppler/Error.cc: + * poppler/Error.h: Report any cairo errors when destroying + the cairo + context. + + ChangeLog | 7 +++++++ + poppler/CairoOutputDev.cc | 7 ++++++- + poppler/Error.cc | 7 +++++++ + poppler/Error.h | 1 + + 4 files changed, 21 insertions(+), 1 deletion(-) + +commit 0c22556bf70ff67eb388cdcd9784603030397785 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sat Sep 1 23:38:04 2007 +0000 + + 2007-09-01 Jeff Muizelaar <jeff@infidigm.net> + + * glib/demo/Makefile.am: Only build the demo app if the cflags + will be + appropriately set. + + ChangeLog | 5 +++++ + glib/demo/Makefile.am | 2 ++ + 2 files changed, 7 insertions(+) + +commit a23d45dd6cd8a2ac4181170a9ee924fe49a9781b +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sat Sep 1 23:00:59 2007 +0000 + + 2007-09-01 Jeff Muizelaar <jeff@infidigm.net> + + * glib/poppler-page.cc: Add note about clipping + + ChangeLog | 4 ++++ + glib/poppler-page.cc | 2 ++ + 2 files changed, 6 insertions(+) + +commit bf489d5cebc467807f2b38f74f6a6e34a503a9ca +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 30 18:39:51 2007 +0000 + + * poppler/Form.h: Remove unused methods. Fixes 12013 + + ChangeLog | 4 ++++ + poppler/Form.h | 3 --- + 2 files changed, 4 insertions(+), 3 deletions(-) + +commit a81cc06c855385911dffa826b9e1407d6097e8c8 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Aug 30 18:15:34 2007 +0000 + + 2007-08-30 Carlos Garcia Campos <carlosgc@gnome.org> + * poppler/TextOutputDev.cc: + * poppler/TextOutputDev.h: + * glib/poppler.h: + * glib/poppler-page.cc: + * glib/poppler-page.h: + * glib/test-poppler-glib.c: Add support for word and line + selections. Based on patch by Kristian Høgsberg. + + ChangeLog | 10 ++++++ + glib/poppler-page.cc | 81 + ++++++++++++++++++++++++++++++++++++++++++------ + glib/poppler-page.h | 2 ++ + glib/poppler.h | 4 +-- + glib/test-poppler-glib.c | 2 +- + poppler/TextOutputDev.cc | 74 +++++++++++++++++++++++++++++-------------- + poppler/TextOutputDev.h | 34 +++++++++++++++----- + 7 files changed, 163 insertions(+), 44 deletions(-) + +commit 59ddb5cc8bec54305b6d256ad9975e95ecdcb935 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 27 18:37:55 2007 +0000 + + * poppler/UnicodeTypeTable.cc: Fix error on the NFKC text + matching + routine. Fixes bug #11775. Patch by Ed Catmur + <ed@catmur.co.uk> + + ChangeLog | 5 +++++ + poppler/UnicodeTypeTable.cc | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit a6e46ce61670679f368e66c1a98a7d5d1c960c5b +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 27 17:56:29 2007 +0000 + + * qt4/src/Doxyfile: + * qt4/src/Mainpage.dox: + * qt4/src/poppler-annotation.h: + * qt4/src/poppler-form.h: + * qt4/src/poppler-link.h: + * qt4/src/poppler-qt4.h: + A few API documentation fixes and improvements. + + ChangeLog | 10 +++++++ + qt4/src/Doxyfile | 26 ++++++------------ + qt4/src/Mainpage.dox | 26 +++++++++++------- + qt4/src/poppler-annotation.h | 34 ++++++++++++++++++++++++ + qt4/src/poppler-form.h | 18 ++++++------- + qt4/src/poppler-link.h | 63 + +++++++++++++++++++++++++++++++++++++++++--- + qt4/src/poppler-qt4.h | 44 +++++++++++++++++++++---------- + 7 files changed, 166 insertions(+), 55 deletions(-) + +commit a7f8d92fba8c45d6ca83568c045d5e324158ee6b +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 27 17:17:14 2007 +0000 + + * qt4/src/poppler-link.cc: + * qt4/src/poppler-link.h: + Initialise correctly, and missing empty destructor. + * qt4/src/poppler-annotation.cc: + Don't leak the private class. + + ChangeLog | 9 +++++++++ + qt4/src/poppler-annotation.cc | 4 ++-- + qt4/src/poppler-link.cc | 8 ++++++-- + qt4/src/poppler-link.h | 1 + + 4 files changed, 18 insertions(+), 4 deletions(-) + +commit 2b1ef8f06879eb0b79288d57540c238ea833db24 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 26 21:39:22 2007 +0000 + + Fix bug 12121 + + ChangeLog | 4 ++++ + utils/ImageOutputDev.cc | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +commit 20bcac5ee1988befb9c590a0d16cb615f0c49901 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 26 21:28:34 2007 +0000 + + forgot to cvs add + + qt4/src/poppler-annotation-private.h | 49 + ++++++++++++++++++++++++++++++++++++ + 1 file changed, 49 insertions(+) + +commit e48de657db0ef439457b4b5ca39b937da25d531e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 26 18:11:01 2007 +0000 + + * qt4/src/poppler-annotation.cc: + * qt4/src/poppler-annotation.h: + Move all the private members of the *Annotation classes into + a common + shared private. + + ChangeLog | 4 + + qt4/src/poppler-annotation.cc | 969 + +++++++++++++++++++++++++++++++++++------- + qt4/src/poppler-annotation.h | 277 ++++++++---- + qt4/src/poppler-page.cc | 249 ++++++----- + 4 files changed, 1155 insertions(+), 344 deletions(-) + +commit 392f050f909b6a1250acf1971446a1849534482c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 26 16:42:46 2007 +0000 + + * qt4/src/poppler-document.cc: + * qt4/src/poppler-embeddedfile.cc: + * qt4/src/poppler-fontinfo.cc: + * qt4/src/poppler-form.cc: + * qt4/src/poppler-form.h: + * qt4/src/poppler-qt4.h: + * qt4/src/poppler-sound.cc: + * qt4/src/poppler-textbox.cc: + API work: remove 'const' and 'const&' from return values + with Qt + classes; make the non-copiable classes really non-copiable; + uninline a Document::page() method; other related small + changes. + * qt4/src/poppler-link.cc: + * qt4/src/poppler-link.h: + Make LinkDestination an implicitely shared class, with all + the private + members into the private class; move all the private members + of the + Link* classes into a common shared private. + + ChangeLog | 23 ++- + qt4/src/poppler-document.cc | 7 +- + qt4/src/poppler-embeddedfile.cc | 12 -- + qt4/src/poppler-fontinfo.cc | 12 +- + qt4/src/poppler-form.cc | 16 +- + qt4/src/poppler-form.h | 14 +- + qt4/src/poppler-link.cc | 373 + ++++++++++++++++++++++++++++++---------- + qt4/src/poppler-link.h | 67 +++++--- + qt4/src/poppler-qt4.h | 32 ++-- + qt4/src/poppler-sound.cc | 7 - + qt4/src/poppler-textbox.cc | 4 +- + 11 files changed, 404 insertions(+), 163 deletions(-) + +commit f215aca25fdd8fe287b717dde53f0be273d995e4 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Aug 26 10:52:19 2007 +0000 + + 2007-08-26 Carlos Garcia Campos <carlosgc@gnome.org> + * configure.ac: + * glib/Makefile.am: + * glib/demo/Makefile.am: + * glib/demo/fonts.[ch]: + * glib/demo/info.[ch]: + * glib/demo/links.[ch]: + * glib/demo/main.c: + * glib/demo/outline.[ch]: + * glib/demo/page.[ch]: + * glib/demo/render.[ch]: + * glib/demo/utils.[ch]: Add poppler glib demo tool. + + ChangeLog | 14 ++ + configure.ac | 1 + + glib/Makefile.am | 2 +- + glib/demo/Makefile.am | 26 +++ + glib/demo/fonts.c | 276 ++++++++++++++++++++++++++++ + glib/demo/fonts.h | 31 ++++ + glib/demo/info.c | 243 ++++++++++++++++++++++++ + glib/demo/info.h | 31 ++++ + glib/demo/links.c | 289 +++++++++++++++++++++++++++++ + glib/demo/links.h | 31 ++++ + glib/demo/main.c | 205 +++++++++++++++++++++ + glib/demo/outline.c | 218 ++++++++++++++++++++++ + glib/demo/outline.h | 31 ++++ + glib/demo/page.c | 249 +++++++++++++++++++++++++ + glib/demo/page.h | 31 ++++ + glib/demo/render.c | 498 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + glib/demo/render.h | 31 ++++ + glib/demo/utils.c | 234 ++++++++++++++++++++++++ + glib/demo/utils.h | 42 +++++ + 19 files changed, 2482 insertions(+), 1 deletion(-) + +commit 7c9529b70dc44bb001d21a3b47fc65916813dec1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Aug 23 20:39:31 2007 +0000 + + 2007-08-23 Carlos Garcia Campos <carlosgc@gnome.org> + * glib/poppler-page.cc: Add missing comma. + + ChangeLog | 4 ++++ + glib/poppler-page.cc | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +commit 3c4a85503261ee81a829a1683f1f5fa85d41f8ee +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Thu Aug 23 20:15:46 2007 +0000 + + 2007-08-23 Jeff Muizelaar <jeff@infidigm.net> + + * glib/poppler-page.cc: pass in -1 to displaySlice so that it + sets up + the slice size for us. This fixes the case of the wrong values + being + used when the pdf was rotated on its side. + Fixes #11913. + + ChangeLog | 7 +++++++ + glib/poppler-page.cc | 5 ++--- + 2 files changed, 9 insertions(+), 3 deletions(-) + +commit 3ba088d8caee3c40c2aba0cd85adcf9195ae88a3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 22 21:29:32 2007 +0000 + + * splash/SplashBitmap.cc: + * splash/SplashBitmap.h: + * utils/pdftoppm.cc: Add the following features to pdftoppm + - if omitting input filename or using - for input filename + reads pdf from stdin + - if omitting output filename, prints output to stdout + - create image of a cropped rectangle of the pdf + - scale pdf to fit in a square of wanted size + Patch by Ilmari Heikkinen <ilmari.heikkinen@gmail.com> + + ChangeLog | 12 ++++++ + splash/SplashBitmap.cc | 18 +++++++-- + splash/SplashBitmap.h | 2 + + utils/pdftoppm.cc | 107 + +++++++++++++++++++++++++++++++++++++++++-------- + 4 files changed, 119 insertions(+), 20 deletions(-) + +commit 567e82c13aace4f40c7a555a62a3a4d223a46d92 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed Aug 22 19:34:02 2007 +0000 + + 2007-08-22 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/GlobalParams.cc: Fix debug spew. Patch from Matthias + Clasen. + + ChangeLog | 4 ++++ + poppler/GlobalParams.cc | 1 - + 2 files changed, 4 insertions(+), 1 deletion(-) + +commit bc499987074d046baf29deafe4a29d57039c0c5e +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed Aug 22 19:28:24 2007 +0000 + + 2007-08-22 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: Fix the computation of the padding + in the + image scaling code. + + ChangeLog | 5 +++++ + poppler/CairoOutputDev.cc | 6 ++++-- + 2 files changed, 9 insertions(+), 2 deletions(-) + +commit d9719233447cb4f85f2bf9d9ec6ef089caa21140 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sun Aug 19 16:20:21 2007 +0000 + + 2007-08-19 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: Avoid allocating the glyph array if + currentFont is not set in beginString. This closes a possible + memory leak. + + ChangeLog | 6 ++++++ + poppler/CairoOutputDev.cc | 3 +++ + 2 files changed, 9 insertions(+) + +commit 099eb56896046e020f4ef0365e1ee382f85ec1ab +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 15 18:52:20 2007 +0000 + + * poppler/JBIG2Stream.cc: Quick fix for bug #12014 + + ChangeLog | 4 ++++ + poppler/JBIG2Stream.cc | 16 +++++++++++----- + 2 files changed, 15 insertions(+), 5 deletions(-) + +commit 3b7e3645c85c7a3d341457f105835b58c935bd67 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 15 00:04:48 2007 +0000 + + RC2 is out! (0.5.91) + + ChangeLog | 1 + + NEWS | 18 ++++++++++++++++++ + configure.ac | 2 +- + 3 files changed, 20 insertions(+), 1 deletion(-) + +commit c240daefe660ac3456dc0c5f5dc82aa53ebc3313 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 14 23:10:37 2007 +0000 + + * poppler/Stream.cc: Fix CVE-2007-3387 by merging xpdf-3.02pl1.patch + + ChangeLog | 1 + + poppler/Stream.cc | 12 +++++------- + 2 files changed, 6 insertions(+), 7 deletions(-) + +commit 1ba884b6b98ac8d755c9adc9f23a7a68d8b17b54 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 14 22:47:30 2007 +0000 + + * configure.ac: + * pòppler/Makefile.am: Patch by Vincent Torri + <vtorri@univ-evry.fr> to + fix linking under MinGW + + ChangeLog | 6 ++++++ + configure.ac | 13 +++++++++++++ + poppler/Makefile.am | 5 +++-- + 3 files changed, 22 insertions(+), 2 deletions(-) + +commit 3c31f923fcf1aeb361910eb1e9445cc28aa5b3ca +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Tue Aug 7 16:22:12 2007 +0000 + + 2007-08-07 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: Don't use the prescaleMethod + when we have a rotation as that case has not been tested. + Also make sure that scaledHeight is at least 1. + + ChangeLog | 6 ++++++ + poppler/CairoOutputDev.cc | 7 ++++++- + 2 files changed, 12 insertions(+), 1 deletion(-) + +commit af97e5f8e0f3beeb43acde92a0788c02d9718adf +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Aug 6 17:41:17 2007 +0000 + + 2007-08-06 Carlos Garcia Campos <carlosgc@gnome.org> + * poppler/Annot.cc: + * poppler/Annot.h: + * poppler/Form.cc: + * poppler/Form.h: + * poppler/Page.cc: Do not always regenerate appearance stream for + every form widget, but only when it's actually needed. + + ChangeLog | 9 ++++++ + poppler/Annot.cc | 86 + ++++++++++++++++++++++++++++++++++---------------------- + poppler/Annot.h | 8 +++--- + poppler/Form.cc | 25 +++------------- + poppler/Form.h | 4 ++- + poppler/Page.cc | 8 ++---- + 6 files changed, 74 insertions(+), 66 deletions(-) + +commit 74627e71388ca0a4c0938a472c291ef87186f370 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Tue Jul 31 21:40:19 2007 +0000 + + 2007-07-31 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/GlobalParams.cc: s/GList/GooList/ some Windows code. + + ChangeLog | 4 ++++ + poppler/GlobalParams.cc | 8 ++++---- + 2 files changed, 8 insertions(+), 4 deletions(-) + +commit f421e2151345ac855b75e819e19343a90789b3bf +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Tue Jul 31 16:50:06 2007 +0000 + + 2007-07-31 Jeff Muizelaar <jeff@infidigm.net> + + * glib/poppler-document.cc: + * glib/poppler-document.h: Add poppler_fonts_iter_get_file_name. + + ChangeLog | 5 +++++ + glib/poppler-document.cc | 16 ++++++++++++++++ + glib/poppler-document.h | 1 + + 3 files changed, 22 insertions(+) + +commit 4d57b8a12b845d5d5ac321d7a4bca980d60d429f +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Tue Jul 31 16:48:35 2007 +0000 + + 2007-07-31 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.h: Add comment about + CairoImageOutputDevice's + implementation. + + ChangeLog | 5 +++++ + poppler/CairoOutputDev.h | 1 + + 2 files changed, 6 insertions(+) + +commit f04a67006abdb5843ab481aa1e25b51abd1b1b64 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jul 31 11:41:53 2007 +0000 + + 2007-07-31 Carlos Garcia Campos <carlosgc@gnome.org> + * poppler/Form.cc: + * poppler/Form.h: Fix memory leak. + + ChangeLog | 5 +++++ + poppler/Form.cc | 9 +++++---- + poppler/Form.h | 4 ++-- + 3 files changed, 12 insertions(+), 6 deletions(-) + +commit ee9d556a8b413160911a535a0e9089b919ca29f5 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jul 31 11:40:22 2007 +0000 + + 2007-07-31 Carlos Garcia Campos <carlosgc@gnome.org> + * poppler/CairoOutputDev.h: Empty implementation of transparency + groups and soft masks in CairoImageOutputDev. Fixes a crash in + poppler_page_get_image_mapping. + + ChangeLog | 6 ++++++ + poppler/CairoOutputDev.h | 11 +++++++++++ + 2 files changed, 17 insertions(+) + +commit e08779856c801b9968dc2d47e28e86abc1ec7110 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Tue Jul 31 05:29:57 2007 +0000 + + 2007-07-31 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/GfxFont.cc: Fix the case where the Encoding is + "Identity" + and ToUnicode exists. GfxCIDFont::getCodeToGIDMap makes + CIDTOGID map + from ToUnicde map, but when encoding is Identity, it should + not use + ToUnicode map to get GID. If encoding is Identity, No CIDTOGID + map is + needed. + Patch by Koji Otani. + Fixes #11413. + + ChangeLog | 10 ++++++++++ + poppler/GfxFont.cc | 1 + + 2 files changed, 11 insertions(+) + +commit 86fc9a6f343be920f5159e745947401227e41a37 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Mon Jul 30 19:28:17 2007 +0000 + + 2007-07-30 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: + * poppler/CairoOutputDev.h: Prescale image masks before giving + them + to cairo to improve the quality of the scaled image. Improves + #5589. + + ChangeLog | 6 + + poppler/CairoOutputDev.cc | 300 + ++++++++++++++++++++++++++++++++++++++++++++-- + poppler/CairoOutputDev.h | 10 +- + 3 files changed, 303 insertions(+), 13 deletions(-) + +commit f754246e47161e9bf99887201e283c1419ade4f1 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Mon Jul 30 19:07:45 2007 +0000 + + 2007-07-30 Jeff Muizelaar <jeff@infidigm.net> + + * configure.ac: Update require cairo version to 1.4 + + ChangeLog | 4 ++++ + configure.ac | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +commit bb20249ac676995725b617ef442f5feb01f78205 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Mon Jul 30 18:44:41 2007 +0000 + + 2007-07-30 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: + * poppler/CairoOutputDev.h: Add transparency group support. + Fixes #7856. + + ChangeLog | 6 +++ + poppler/CairoOutputDev.cc | 133 + ++++++++++++++++++++++++++++++++++++++++++++++ + poppler/CairoOutputDev.h | 21 +++++++- + 3 files changed, 159 insertions(+), 1 deletion(-) + +commit a85acecaeb0d122becbc52a385d918561e995eca +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Mon Jul 30 00:22:35 2007 +0000 + + 2007-07-29 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: + * poppler/CairoOutputDev.h: transform the original matrix for + type3 fonts + instead of using set_matrix() + + ChangeLog | 6 ++++++ + poppler/CairoOutputDev.cc | 20 +++++++++++++++++--- + poppler/CairoOutputDev.h | 1 + + 3 files changed, 24 insertions(+), 3 deletions(-) + +commit a81a082169de32d01c36c969616a5c2279f1bac7 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Mon Jul 30 00:18:59 2007 +0000 + + 2007-07-29 Jeff Muizelaar <jeff@infidigm.net> + + * glib/test-poppler-glib.c: include <time.h> to fix compilation. + + ChangeLog | 4 ++++ + glib/test-poppler-glib.c | 1 + + 2 files changed, 5 insertions(+) + +commit 81393cb30f6287caf5195265cdc039555f2767d3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jul 28 08:22:40 2007 +0000 + + 2007-07-28 Carlos Garcia Campos <carlosgc@gnome.org> + * poppler/Annot.cc: + * poppler/Annot.h: + * poppler/Form.cc: + * poppler/Form.h: Make fieldLookup static in Form and use it from + both Form and Annot. + + ChangeLog | 8 +++++++ + poppler/Annot.cc | 43 +++++++++++------------------------- + poppler/Annot.h | 1 - + poppler/Form.cc | 66 + +++++++++++++++++++++++++++----------------------------- + poppler/Form.h | 2 ++ + 5 files changed, 54 insertions(+), 66 deletions(-) + +commit 81b669dcb14bf821a49c9879f8d4129075647f5f +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jul 28 08:05:11 2007 +0000 + + 2007-07-28 Carlos Garcia Campos <carlosgc@gnome.org> + * glib/poppler-page.h: Remove unneeded declarations. Fixes bug + #11744. Patch by Kouhei Sutou <kou@cozmixng.org>. + + ChangeLog | 5 +++++ + glib/poppler-page.h | 2 -- + 2 files changed, 5 insertions(+), 2 deletions(-) + +commit f2c4e5305009f1da770c99d3e2e3371ff37c75f3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri Jul 27 09:17:40 2007 +0000 + + 2007-07-27 Carlos Garcia Campos <carlosgc@gnome.org> + * glib/poppler-document.cc: + * glib/poppler-document.h: + * glib/poppler-private.h: + * glib/test-poppler-glib.c: Make PopplerFontInfo GObject. Patch by + Kouhei Sutou <kou@cozmixng.org>. + + ChangeLog | 8 ++++++++ + glib/poppler-document.cc | 44 + ++++++++++++++++++++++++++++++++++++++++---- + glib/poppler-document.h | 6 +++++- + glib/poppler-private.h | 1 + + glib/test-poppler-glib.c | 2 +- + 5 files changed, 55 insertions(+), 6 deletions(-) + +commit 975c7cff10d9b00359e147329ae2c7a93f8a3833 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jul 25 17:20:06 2007 +0000 + + micro optimization + + qt4/src/poppler-page.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 525a7f49dd95f2644870a1c59ca15124e30026b4 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jul 24 16:45:25 2007 +0000 + + 2007-07-24 Carlos Garcia Campos <carlosgc@gnome.org> + * poppler/Annot.cc: + * poppler/Form.cc: Several fixes in forms. Generate appearance for + field buttons that don't have an AP dict. Do not remove the first + character of the second and following lines in multiline text + fields. Fix a crash with pdf documents created by ooo which have + radio buttons. Look for some inheritable attributes in the + parent when needed. + + ChangeLog | 10 ++++++++ + poppler/Annot.cc | 27 ++++++++++---------- + poppler/Form.cc | 77 + +++++++++++++++++++++++++++++++++++++++----------------- + 3 files changed, 78 insertions(+), 36 deletions(-) + +commit 633a1cde65f86ee6577a68f4f8d36de43d14c714 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jul 15 21:03:50 2007 +0000 + + * utils/HtmlOutputDev.cc: + * utils/HtmlOutputDev.h: Create the html files in the + correct place, + not in the invocation dir. Fixes bug #11610 + + ChangeLog | 6 ++++++ + utils/HtmlOutputDev.cc | 37 ++++++++++--------------------------- + utils/HtmlOutputDev.h | 4 ---- + 3 files changed, 16 insertions(+), 31 deletions(-) + +commit ccb2d420ca8d818aa9ba1d64f08f5e94ab313a72 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jul 15 17:09:29 2007 +0000 + + * poppler/DCTStream.cc + * poppler/DCTStream.h: Implement less evil error handling. On + a + error_exit level error we don't want to actually exit the + program. See + http://bugs.kde.org/show_bug.cgi?id=147878 for a pdf with this + problem. libjpeg was printing "Bogus Huffman table definition" + and + exiting the program. + * poppler/Stream.cc: Remove bogus #warning + + ChangeLog | 10 ++++++++++ + poppler/DCTStream.cc | 17 ++++++++++++++++- + poppler/DCTStream.h | 1 + + poppler/Stream.cc | 1 - + 4 files changed, 27 insertions(+), 2 deletions(-) + +commit f9d82dfd299ae23a1baf3e35e2c3cd351129c525 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jul 14 18:23:42 2007 +0000 + + * utils/pdftops.cc: init width/height to -1 so it is + calculated if not + specified + + ChangeLog | 5 +++++ + utils/pdftops.cc | 4 ++-- + 2 files changed, 7 insertions(+), 2 deletions(-) + +commit 1c04136e9538ccfaa2d6b968861682ca3b69ffb3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jul 14 15:23:31 2007 +0000 + + 2007-07-14 Pino Toscano <pino@kde.org> + * glib/poppler-action.h: + * glib/poppler-document.h: Remove trailing comma from the last + item of enums. + + ChangeLog | 6 ++++++ + glib/poppler-action.h | 2 +- + glib/poppler-document.h | 8 ++++---- + 3 files changed, 11 insertions(+), 5 deletions(-) + +commit b9b68cabce19a5e23911e5432ace8c13bd237391 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jul 14 15:15:57 2007 +0000 + + 2007-07-14 Carlos Garcia Campos <carlosgc@gnome.org> + * glib/poppler-form-field.cc: + * glib/poppler-form-field.h: + * glib/test-poppler-glib.c: Make is_password a property instead of + a text form field type, since a text field could be multiline and + password at the same time. + + ChangeLog | 8 ++++++++ + glib/poppler-form-field.cc | 10 ++++++++-- + glib/poppler-form-field.h | 2 +- + glib/test-poppler-glib.c | 4 ++-- + 4 files changed, 19 insertions(+), 5 deletions(-) + +commit 14a8361039d708661b8699b2e7c4496135021a85 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 13 22:18:05 2007 +0000 + + * fofi/FoFiTrueType.cc + * fofi/FoFiTrueType.h + * poppler/CairoFontEngine.cc + * poppler/CharCodeToUnicode.cc + * poppler/CharCodeToUnicode.h + * poppler/GfxFont.cc + * poppler/GfxFont.h + * poppler/SplashOutputDev.cc: Patch by + Koji Otani <sho@bbr.jp> to fix several problems with + Japanese fonts. + Fixes bug 11413 + + ChangeLog | 13 ++ + fofi/FoFiTrueType.cc | 305 + +++++++++++++++++++++++++++++++++++++++++++ + fofi/FoFiTrueType.h | 12 ++ + poppler/CairoFontEngine.cc | 47 ++----- + poppler/CharCodeToUnicode.cc | 16 +++ + poppler/CharCodeToUnicode.h | 1 + + poppler/GfxFont.cc | 230 ++++++++++++++++++++++++++++---- + poppler/GfxFont.h | 2 + + poppler/SplashOutputDev.cc | 53 ++------ + 9 files changed, 577 insertions(+), 102 deletions(-) + +commit 8389099d8e8940e3f8920b14a83075d69bcd8e6c +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 13 18:21:02 2007 +0000 + + * poppler/FontInfo.cc: Fix the FontInfoScanner::scan method to + actually scan the number of requested pages + + ChangeLog | 6 ++++++ + poppler/FontInfo.cc | 12 ++++++------ + 2 files changed, 12 insertions(+), 6 deletions(-) + +commit 9ced4442372d08375e0ded62f79052d8a3ec9cd6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 13 18:08:44 2007 +0000 + + * poppler/GlobalParams.cc: Remove dead unused code from + Win32 ifdef + + ChangeLog | 4 ++++ + poppler/GlobalParams.cc | 6 ------ + 2 files changed, 4 insertions(+), 6 deletions(-) + +commit fb89fdb8de608ff94082e16819f042cddabf2bcc +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jul 11 18:52:12 2007 +0000 + + * poppler/PSOutputDev.cc + * poppler/PSOutputDev.h + * utils/pdftohtml.cc: Fix bug 9746. pdftohtml complex mode + had text + twice + + ChangeLog | 7 +++++++ + poppler/PSOutputDev.cc | 5 +++++ + poppler/PSOutputDev.h | 2 ++ + utils/pdftohtml.cc | 3 +-- + 4 files changed, 15 insertions(+), 2 deletions(-) + +commit 0c9fa59bf5edf3cfcca1792da51b904a7c7f7615 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jul 11 18:30:19 2007 +0000 + + 2007-07-11 Carlos Garcia Campos <carlosgc@gnome.org> + * poppler/Form.cc: + * poppler/XRef.cc: + * poppler/XRef.h: Fix memory leak. + + ChangeLog | 6 ++++++ + poppler/Form.cc | 49 ++++++++++++++++++++++++------------------------- + poppler/XRef.cc | 22 ++++++++++------------ + poppler/XRef.h | 2 +- + 4 files changed, 41 insertions(+), 38 deletions(-) + +commit 4ae7d43bd54c5b3e2f08c48441f741d3099e228f +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jul 11 18:12:26 2007 +0000 + + * goo/GooVector.h: Rename guard from _VECTOR_H to GOO_VECTOR_H + * goo/gfile.cc: GString -> GooString in Windows code + * poppler/GlobalParams.cc: GString -> GooString in Windows + code + * splash/SplashT1FontEngine.cc + * splash/SplashT1FontEngine.h + * splash/SplashT1FontFile.cc + * splash/SplashT1FontFile.h: T1 code is not supported, + but at least + make it compile :-D + + ChangeLog | 11 +++++++++++ + goo/GooVector.h | 4 ++-- + goo/gfile.cc | 6 +++--- + poppler/GlobalParams.cc | 26 +++++++++++++------------- + splash/SplashFontEngine.cc | 2 +- + splash/SplashT1FontEngine.cc | 8 ++++---- + splash/SplashT1FontEngine.h | 7 +++---- + splash/SplashT1FontFile.cc | 8 +++++--- + splash/SplashT1FontFile.h | 4 ++-- + 9 files changed, 44 insertions(+), 32 deletions(-) + +commit 7bd125ce96c603fd5cf42d7c6a29b542e82dd4ec +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jul 11 18:08:07 2007 +0000 + + 2007-07-11 Carlos Garcia Campos <carlosgc@gnome.org> + * poppler/Form.cc: + * poppler/Form.h: + * glib/poppler-form-field.cc: + * glib/poppler-form-field.h: + * glib/test-poppler-glib.c: Add a method to get the max length + allowed in text form fields. + + ChangeLog | 9 +++++++++ + glib/poppler-form-field.cc | 8 ++++++++ + glib/poppler-form-field.h | 1 + + glib/test-poppler-glib.c | 1 + + poppler/Form.cc | 11 +++++++++++ + poppler/Form.h | 4 ++++ + 6 files changed, 34 insertions(+) + +commit 8a68855735e9d295d71685e82de39204d639ea7a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Jul 9 08:52:58 2007 +0000 + + 2007-07-09 Carlos Garcia Campos <carlosgc@gnome.org> + * poppler/Annot.cc: + * poppler/Annot.h: Render '*' instead of the actual content in + password form fields. Patch by Julien Rebetez <julien@fhtagn.net> + + ChangeLog | 6 ++++++ + poppler/Annot.cc | 52 + +++++++++++++++++++++++++++++----------------------- + poppler/Annot.h | 5 +++-- + 3 files changed, 38 insertions(+), 25 deletions(-) + +commit 53cf7d7084dc03a28239f11c94f2095bb02d6108 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jul 7 16:23:56 2007 +0000 + + 2007-07-07 Carlos Garcia Campos <carlosgc@gnome.org> + * poppler/Form.cc: + * poppler/Form.h: + * glib/poppler-form-field.cc: + * glib/poppler-form-field.h: + * glib/test-poppler-glib.c: Add a method to get the type of a Form + Field Button. + + ChangeLog | 9 +++++++++ + glib/poppler-form-field.cc | 18 ++++++++++++++++++ + glib/poppler-form-field.h | 8 ++++++++ + glib/test-poppler-glib.c | 26 +++++++++++++++++++++++--- + poppler/Form.cc | 5 +++++ + poppler/Form.h | 2 ++ + 6 files changed, 65 insertions(+), 3 deletions(-) + +commit de0a40181e5832a0dc263d40ed0a269867764623 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jul 7 15:28:29 2007 +0000 + + 2007-07-07 Carlos Garcia Campos <carlosgc@gnome.org> + * poppler/Form.cc: Fix a crash when setting state on buttons that + don't have state. + + ChangeLog | 5 +++++ + poppler/Form.cc | 3 +++ + 2 files changed, 8 insertions(+) + +commit a33518a3283ff25aa5517bc535ddb61383b1cfdc +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 6 09:08:44 2007 +0000 + + * poppler/Form.cc: Fix a bug with FormField's destructor + which was not + checking if the FormField is terminal to determine wether + it needs to + delete children or widgets. Patch by + Julien Rebetez <julien@fhtagn.net> + + ChangeLog | 4 ++++ + poppler/Form.cc | 17 +++++++++++------ + 2 files changed, 15 insertions(+), 6 deletions(-) + +commit 43f0d5b9bb198cdcbc2f7111f294c6f947105314 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 6 08:47:11 2007 +0000 + + * goo/GooString.cc: + * poppler/ABWOutputDev.cc: Build on Sun Force compiler, + patch by + Darren Kenny <darren.kenny@sun.com> + + ChangeLog | 6 ++++++ + goo/GooString.cc | 2 +- + poppler/ABWOutputDev.cc | 4 +++- + 3 files changed, 10 insertions(+), 2 deletions(-) + +commit 4e7405071b69889362e4d49de3f881f0e3e261e3 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 5 13:04:01 2007 +0000 + + 2007-07-05 Carlos Garcia Campos <carlosgc@gnome.org> + * glib/poppler-form-field.cc: Allow to set NULL in form fields + that can contain text. + + ChangeLog | 5 +++++ + glib/poppler-form-field.cc | 30 ++++++++++++------------------ + 2 files changed, 17 insertions(+), 18 deletions(-) + +commit 625510797c528257527003477fe28adbacfe80e7 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Thu Jul 5 08:13:51 2007 +0000 + + 2007-07-05 Carlos Garcia Campos <carlosgc@gnome.org> + * glib/poppler-attachment.cc: + * glib/poppler-attachment.h: + * glib/test-poppler-glib.c: Rename cdate and mdate again to ctime + and mtime, since they are public attributes and we don't want to + break the API. + + ChangeLog | 8 ++++++++ + glib/poppler-attachment.cc | 4 ++-- + glib/poppler-attachment.h | 4 ++-- + glib/test-poppler-glib.c | 4 ++-- + 4 files changed, 14 insertions(+), 6 deletions(-) + +commit 9b2640f156f24b07c797d9461f84e64d550efa1a +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jul 4 13:57:31 2007 +0000 + + * qt4/src/poppler-form.cc: QStringToGooString -> + QStringToUnicodeGooString has FormWidgetText::setContent + wants to have + the unicode formated string + * qt4/src/poppler-private.h: create QStringToUnicodeGooString + + ChangeLog | 7 +++++++ + qt4/src/poppler-form.cc | 2 +- + qt4/src/poppler-private.h | 15 +++++++++++++++ + 3 files changed, 23 insertions(+), 1 deletion(-) + +commit b70115cf979b29f75c644518ae0e9c0dd9892ebf +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jul 4 13:06:38 2007 +0000 + + 2007-07-04 Carlos Garcia Campos <carlosgc@gnome.org> + * glib/poppler-form-field.cc: Convert strings from UTF8 to UTF16BE + before setting them. + + ChangeLog | 5 +++++ + glib/poppler-form-field.cc | 34 ++++++++++++++++++++++++---------- + 2 files changed, 29 insertions(+), 10 deletions(-) + +commit d37843877a6f93a9f27502d07ad82cba79e9aa73 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Wed Jul 4 08:26:52 2007 +0000 + + 2007-07-04 Carlos Garcia Campos <carlosgc@gnome.org> + * glib/poppler-attachment.cc: + * glib/poppler-attachment.h: Add size, creation and modification + date and checksum properties to attachments. Fix memory leaks. + * glib/test-poppler-glib.c: + * glib/poppler.h: + * glib/poppler-private.h: + * glib/poppler-document.cc: Add a function to convert a pdf date + into a GTime that is used by attachments and document + properties. Fix memory leak in attachments. + + ChangeLog | 12 ++++ + glib/poppler-attachment.cc | 25 +++++++- + glib/poppler-attachment.h | 16 ++--- + glib/poppler-document.cc | 142 + +++++++++++++++++++++++---------------------- + glib/poppler-private.h | 6 +- + glib/poppler.h | 1 + + glib/test-poppler-glib.c | 56 +++++++++++++++--- + 7 files changed, 171 insertions(+), 87 deletions(-) + +commit d933f47d4af0992059148259a189373b42499bbe +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jul 3 20:31:20 2007 +0000 + + * qt4/tests/poppler-fonts.cpp: For the sake of completeness, + add all + the enums + + ChangeLog | 2 ++ + qt4/tests/poppler-fonts.cpp | 28 ++++++++++++++++++++-------- + 2 files changed, 22 insertions(+), 8 deletions(-) + +commit d90b166cfbdc4857351baa627d158d5e0b6652b4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jul 3 16:46:51 2007 +0000 + + * poppler/Catalog.cc: Fix crash, + embeddedFileNameTree.getName(i) + returns a reference to its own data so does not have to + be deleted + * qt4/tests/poppler-attachments.cpp: Delete the doc, just + for sake of + correctness + + ChangeLog | 7 +++++++ + poppler/Catalog.cc | 1 - + qt4/tests/poppler-attachments.cpp | 1 + + 3 files changed, 8 insertions(+), 1 deletion(-) + +commit 7fa87eb2b093770271bc3a72de5b0b9dc228aa1b +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jul 3 14:01:40 2007 +0000 + + 2007-07-03 Carlos Garcia Campos <carlosgc@gnome.org> + * glib/poppler-form-field.cc: + * glib/poppler-form-field.h: + * glib/test-poppler-glib.c: Add choice_commit_on_change function + to glib bindings. + + ChangeLog | 7 +++++++ + glib/poppler-form-field.cc | 8 ++++++++ + glib/poppler-form-field.h | 1 + + glib/test-poppler-glib.c | 2 ++ + 4 files changed, 18 insertions(+) + +commit 8b67e0403f6eaab6770cc0b7861074ae0b6d85bb +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Tue Jul 3 13:49:18 2007 +0000 + + 2007-07-03 Carlos Garcia Campos <carlosgc@gnome.org> + * glib/poppler-form-field.cc: + * glib/poppler-form-field.h: + * glib/test-poppler-glib.c: Fix a typo. + + ChangeLog | 6 ++++++ + glib/poppler-form-field.cc | 2 +- + glib/poppler-form-field.h | 2 +- + glib/test-poppler-glib.c | 2 +- + 4 files changed, 9 insertions(+), 3 deletions(-) + +commit 33a5765eb404a4b321b09c26af74c1ed64a5d474 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jul 3 13:22:54 2007 +0000 + + * poppler/Catalog.cc: + * poppler/Catalog.h: Add size and checksum properties to + the embeded + files + * qt4/src/poppler-embeddedfile.cc: + * qt4/src/poppler-qt4.h: Add size and checksum properties + to the qt4 + frontend + + ChangeLog | 9 +++++++++ + poppler/Catalog.cc | 19 ++++++++++++++++--- + poppler/Catalog.h | 13 +++++++++++-- + qt4/src/poppler-embeddedfile.cc | 16 ++++++++++++++++ + qt4/src/poppler-qt4.h | 14 ++++++++++++++ + 5 files changed, 66 insertions(+), 5 deletions(-) + +commit c7d21f9354bbe090cce6459124dcaadf1e46639e +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Jul 2 13:39:32 2007 +0000 + + 2007-07-02 Carlos Garcia Campos <carlosgc@gnome.org> + * glib/poppler-form-field.cc: + * glib/poppler-form-field.h: + * glib/test-poppler-glib.c: + Use FILE_SELECT instead of FILESELECT and fix a typo. Patch by + Kouhei Sutou + + ChangeLog | 9 +++++++++ + glib/poppler-form-field.cc | 2 +- + glib/poppler-form-field.h | 2 +- + glib/test-poppler-glib.c | 2 +- + 4 files changed, 12 insertions(+), 3 deletions(-) + +commit 5e301064c62c6d58f488839d7bf804af912a3de1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Mon Jul 2 13:34:26 2007 +0000 + + 2007-07-02 Carlos Garcia Campos <carlosgc@gnome.org> + * glib/poppler-form-field.cc: + * glib/poppler-form-field.h: + * glib/test-poppler-glib.c: + Add poppler_form_field_is_read_only to glib bindings. Patch by + Kouhei Sutou + + ChangeLog | 9 +++++++++ + glib/poppler-form-field.cc | 8 ++++++++ + glib/poppler-form-field.h | 1 + + glib/test-poppler-glib.c | 6 +++++- + 4 files changed, 23 insertions(+), 1 deletion(-) + +commit 11875746ce28e8999bcad46167fcfea131cd267a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jun 30 08:33:30 2007 +0000 + + 2007-06-30 Carlos Garcia Campos <carlosgc@gnome.org> + * glib/poppler-page.cc: Use poppler_page_transition_get_type + instead of poppler_page_transition which doesn't exist. Patch by + Kouhei Sutou + + ChangeLog | 6 ++++++ + glib/poppler-page.cc | 2 +- + 2 files changed, 7 insertions(+), 1 deletion(-) + +commit 0a5acaae3b9bfcd731bc4e072f35f9433aa773da +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jun 30 08:25:15 2007 +0000 + + 2007-06-30 Carlos Garcia Campos <carlosgc@gnome.org> + * glib/Makefile.am: + * glib/poppler-form-field.cc: + * glib/poppler-form-field.h: + * glib/poppler-document.cc: + * glib/poppler-document.h: + * glib/poppler-page.cc: + * glib/poppler-page.h: + * glib/poppler-private.h: + * glib/poppler.h: + * glib/test-poppler-glib.c: Improve forms API in the glib bindings + in order to make it more consistent with the current API and + easier to use. + + ChangeLog | 15 +++ + glib/Makefile.am | 2 + + glib/poppler-document.cc | 197 ++-------------------------- + glib/poppler-document.h | 55 +------- + glib/poppler-form-field.cc | 316 + +++++++++++++++++++++++++++++++++++++++++++++ + glib/poppler-form-field.h | 96 ++++++++++++++ + glib/poppler-page.cc | 210 ++++++++++++------------------ + glib/poppler-page.h | 55 ++------ + glib/poppler-private.h | 11 +- + glib/poppler.h | 40 +++--- + glib/test-poppler-glib.c | 119 ++++++++++++++--- + 11 files changed, 662 insertions(+), 454 deletions(-) + +commit 2212874e57a6eb9db733b2e9a98f0cfcb88a8fc1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 26 21:31:07 2007 +0000 + + * poppler/Form.cc: Don't crash on documents with AcroForm + but no + AcroForm->Fields (it's mandatory but...) + + ChangeLog | 5 +++++ + poppler/Form.cc | 54 + +++++++++++++++++++++++++++++------------------------- + 2 files changed, 34 insertions(+), 25 deletions(-) + +commit e48ee9c4af6bf98b6988c51dcab9ee9ef6e3cafe +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Jun 23 18:06:07 2007 +0000 + + 2007-06-23 Carlos Garcia Campos <carlosgc@gnome.org> + * poppler/Annot.cc: + * poppler/Form.cc: Fix memory leaks. + + ChangeLog | 5 +++++ + poppler/Annot.cc | 2 +- + poppler/Form.cc | 13 +++++++++---- + 3 files changed, 15 insertions(+), 5 deletions(-) + +commit d874a2753e3ac51b6f539dfdf980435c8c381b4f +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 20 20:07:15 2007 +0000 + + * qt4/src/poppler-qt4.h: + * qt4/src/poppler-document.cc: Allow access to a document's + metadata contents + from the qt4 binding. Based on patch by Jason Kivlighn + * qt4/tests/test-poppler-qt4.cpp: Print metadata if it exists + + ChangeLog | 5 +++++ + qt4/src/poppler-document.cc | 13 +++++++++++++ + qt4/src/poppler-qt4.h | 5 +++++ + qt4/tests/test-poppler-qt4.cpp | 1 + + 4 files changed, 24 insertions(+) + +commit 08d4c437e735ac50a340c4ae17ee0eeccd00dc20 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 20 18:40:03 2007 +0000 + + * glib/poppler-document.cc: Allow access to a document's + metadata stream + through the glib binding. Patch by Jason Kivlighn + <jkivlighn@gmail.com> Approved by Carlos + + ChangeLog | 6 ++++++ + glib/poppler-document.cc | 21 +++++++++++++++++++++ + 2 files changed, 27 insertions(+) + +commit cdd2a49dc99aa16ded674c58dbb50298f06cf18a +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jun 15 18:15:53 2007 +0000 + + * poppler/ABWOutputDev.cc: Replaces the getBiggestSeperator + function + at the ABWoutputdev with one that is easier to read/debug + and less likely to contain bugs. Some cosmetic fixes at the + functions recursiveXYC and splitnodes. Patch by + Jauco Noordzij <jauco.noordzij@gmail.com>. More info at + bug #11273 + + ChangeLog | 8 + + poppler/ABWOutputDev.cc | 384 + ++++++++++++------------------------------------ + 2 files changed, 106 insertions(+), 286 deletions(-) + +commit 7f23383197b0e2fa24be7b4925ea6f39eb95bbc1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 13 20:39:21 2007 +0000 + + * poppler/ABWOutputDev.cc + * poppler/ABWOutputDev.h: Remove dependency on debugxml. Patch + by + Jauco Noordzij <jauco.noordzij@gmail.com>. Fixes bug #11187 + + ChangeLog | 6 ++++ + poppler/ABWOutputDev.cc | 80 + ++++++++++++++++++++++++++++++++++++++++++++++++- + poppler/ABWOutputDev.h | 1 + + 3 files changed, 86 insertions(+), 1 deletion(-) + +commit 948520cd529ce47d1970aae6a0b8058128e37c30 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 13 18:50:40 2007 +0000 + + * goo/FixedPoint.h + * goo/gmem.h + * poppler/SecurityHandler.h + * poppler/poppler-config.h.in + * utils/ImageOutputDev.h: + Patch by Axel Howind <Axel.Howind@htp-tel.de> + - include USE_EXCEPTIONS and USE_FIXEDPOINT in + poppler-config.h.in + - fix typo (MULTITHREADED/MULTITHREADING) in + poppler.config.h.in + - change installed headers to include poppler-config.h + instead of + config.h + - use <poppler/poppler-config.h> instead of <poppler-config.h> + so that + installed headers can be used without including + .../include/poppler + in the include path + + ChangeLog | 16 ++++++++++++++++ + goo/FixedPoint.h | 2 +- + goo/gmem.h | 2 +- + poppler/SecurityHandler.h | 2 +- + poppler/poppler-config.h.in | 12 +++++++++++- + utils/ImageOutputDev.h | 2 +- + 6 files changed, 31 insertions(+), 5 deletions(-) + +commit 825461e47b05595805e87a0d2960b07197c8da8b +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 13 18:24:56 2007 +0000 + + configure.ac: Fix detection of glib + + ChangeLog | 4 ++++ + configure.ac | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +commit a67a93fc6b4812a4f892b311c5b299e59283cd47 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 11 21:14:22 2007 +0000 + + * poppler/CMap.h: + * poppler/CharCodeToUnicode.h: + * poppler/GlobalParams.h: + * poppler/PageLabelInfo.h: + * poppler/UnicodeMap.h: Further include cleanup. Patch by + Axel Howind + on bug #11228 + + ChangeLog | 9 +++++++++ + poppler/CMap.h | 2 +- + poppler/CharCodeToUnicode.h | 2 +- + poppler/GlobalParams.h | 2 +- + poppler/PageLabelInfo.h | 6 +++--- + poppler/UnicodeMap.h | 2 +- + 6 files changed, 16 insertions(+), 7 deletions(-) + +commit 051b31af053cac4727718169b79b25451a4bdd95 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 11 21:11:05 2007 +0000 + + * qt/poppler-qt.h + * qt4/src/poppler-qt4.h: Headers cleanup + + ChangeLog | 5 +++++ + qt/poppler-qt.h | 6 +++--- + qt4/src/poppler-qt4.h | 8 ++++---- + 3 files changed, 12 insertions(+), 7 deletions(-) + +commit 3e1597b80fc6750f1ec3269f9819aa8225879524 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jun 8 22:39:23 2007 +0000 + + poppler/Annot.cc: Fix leak + + ChangeLog | 4 ++++ + poppler/Annot.cc | 1 + + 2 files changed, 5 insertions(+) + +commit 49535c20b4f71d1c1381134233e2e1449cf560c0 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Thu Jun 7 21:23:03 2007 +0000 + + 2007-06-07 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/ABWOutputDev.cc: Change "and", "or", "not" to "&&", + "||", + "!" for consistency with the rest of the code. Patch by Jens + Granseuer + + ChangeLog | 5 +++ + poppler/ABWOutputDev.cc | 93 + +++++++++++++++++++++++++------------------------ + 2 files changed, 52 insertions(+), 46 deletions(-) + +commit dd8fa975bf51dd18120369d0ef2d8f1781e04d93 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 2 09:18:11 2007 +0000 + + correct form of patch 11102 + + utils/HtmlFonts.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit cdf70857ece0748f13b11c923ccf9626094555b4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jun 1 18:34:48 2007 +0000 + + * poppler/ArthurOutputDev.cc + * splash/SplashFTFont.cc + * splash/SplashMath.h: Make it compile with + --enable-fixedpoint. Fixes + bug 11110 + + ChangeLog | 7 +++++++ + poppler/ArthurOutputDev.cc | 8 ++++---- + splash/SplashFTFont.cc | 8 ++++---- + splash/SplashMath.h | 2 +- + 4 files changed, 16 insertions(+), 9 deletions(-) + +commit 90b1a404629a884cc32737a3a729c9a75f7a59c1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed May 30 18:33:24 2007 +0000 + + * configure.ac: Fix to check for glib-2.0 not glib that is + 1.0. Patch + came though Pardus developers and they don't remember where + they got + it from. + + ChangeLog | 6 ++++++ + configure.ac | 2 +- + 2 files changed, 7 insertions(+), 1 deletion(-) + +commit 03d766ea1ddd4ce6d938f96b53906a7dc8bd179a +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed May 30 18:29:57 2007 +0000 + + make dist needs this + + qt4/src/Makefile.am | 2 ++ + 1 file changed, 2 insertions(+) + +commit d540c04268047fdd125ad932ca05c7553a97c0fe +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed May 30 17:50:00 2007 +0000 + + * utils/HtmlFonts.cc: Make pdftohtml not pollute stdout. Patch + by + Nanning Buitenhuis <nanning@elvenkind.com> + + And some changes in glib/reference/tmpl + + ChangeLog | 5 + + glib/reference/tmpl/poppler-document.sgml | 4 + + glib/reference/tmpl/poppler-enums.sgml | 150 + ++++++++++++++++++++++++++++++ + glib/reference/tmpl/poppler-page.sgml | 5 +- + glib/reference/tmpl/poppler-unused.sgml | 130 + -------------------------- + utils/HtmlFonts.cc | 2 +- + 6 files changed, 162 insertions(+), 134 deletions(-) + +commit ce414f2a36f4d97a3bddfd42baabdc1e34bf9321 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue May 29 22:01:58 2007 +0000 + + 2007-05-29 Kristian Høgsberg <krh@redhat.com> + + * poppler/gen-unicode-tables.py: Add this script to fix distcheck. + + ChangeLog | 4 ++++ + poppler/gen-unicode-tables.py | 38 ++++++++++++++++++++++++++++++++++++++ + 2 files changed, 42 insertions(+) + +commit 97e602752b05f3690acb1821bdca31c5771361e1 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun May 27 11:24:40 2007 +0000 + + 2007-05-27 Carlos Garcia Campos <carlosgc@gnome.org> + * glib/test-poppler-glib.c: Add forms test + * glib/poppler-page.cc: + * glib/poppler-page.h: + Fix indentation, some code cleanups and memory leaks. + + ChangeLog | 7 ++ + glib/poppler-page.cc | 198 + ++++++++++++++++++++++++++++------------------- + glib/poppler-page.h | 6 +- + glib/test-poppler-glib.c | 39 ++++++++++ + 4 files changed, 168 insertions(+), 82 deletions(-) + +commit 3d31c2b1ea913fc80211f1c6fed9b3666f124049 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun May 27 10:12:56 2007 +0000 + + 2007-05-27 Carlos Garcia Campos <carlosgc@gnome.org> + * glib/poppler-page.cc: + * glib/poppler-page.h: + Add missing image mapping type definition. + + ChangeLog | 6 ++++++ + glib/poppler-page.cc | 48 + +++++++++++++++++++++++++++++++++++++++++++++--- + glib/poppler-page.h | 5 +++++ + 3 files changed, 56 insertions(+), 3 deletions(-) + +commit 8284a769568322066a9d4626bd9b2cf3d18a6487 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat May 26 23:20:12 2007 +0000 + + * configure.ac: + * NEWS: Bump release to 0.5.9 (0.6 Release Candidate) + + ChangeLog | 2 ++ + NEWS | 15 +++++++++++++++ + configure.ac | 2 +- + 3 files changed, 18 insertions(+), 1 deletion(-) + +commit e6ff9e0d95e058f6aff3c72d5f4d7d7ccf661999 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat May 26 22:33:21 2007 +0000 + + * poppler-qt.pc.in: + * poppler-qt4.pc.in: + * qt/Makefile.am: + * qt4/src/Makefile.am: Install qt3 and qt4 headers in + separate dirs. + That way be can reuse poppler-page-transition.h and distros + don't get + conflicts when making separate qt3 and qt4 packages + + ChangeLog | 9 +++++++++ + poppler-qt.pc.in | 2 +- + poppler-qt4.pc.in | 2 +- + qt/Makefile.am | 2 +- + qt4/src/Makefile.am | 2 +- + 5 files changed, 13 insertions(+), 4 deletions(-) + +commit fefefe495a182c1745314186b99441b9e76ba5b4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 25 23:17:58 2007 +0000 + + * qt4/src/poppler-link-extractor-private.cc: + * qt4/src/poppler-link-extractor-private.h: + * qt4/src/poppler-link.cc: + * qt4/src/poppler-link.h: Return link coordinates in 0..1 + range + instead of 0..size, much more easier to do user<->dev + transformations + * qt4/src/poppler-private.h: Fix indentation + + ChangeLog | 6 ++++++ + qt4/src/poppler-link-extractor-private.h | 1 + + qt4/src/poppler-link-extractor.cc | 12 ++++++------ + qt4/src/poppler-link.cc | 25 +++++++++++++++---------- + qt4/src/poppler-link.h | 7 ++++++- + qt4/src/poppler-private.h | 15 ++++++++------- + 6 files changed, 42 insertions(+), 24 deletions(-) + +commit ecaeaa9512d1dae4a036703ea8739102a8e463f0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 25 22:30:20 2007 +0000 + + * qt4/src/poppler-link-extractor.cc: Use correct page box + to extract + link clickable area + + ChangeLog | 5 +++++ + qt4/src/poppler-link-extractor.cc | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit 774a9456c668ef70b2e8f17d59f8f427aa97bad5 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Fri May 25 18:43:04 2007 +0000 + + 2007-05-25 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/GfxFont.cc: + * poppler/GfxFont.h: + * poppler/GlobalParams.cc: + Don't cache DisplayFontParams by font name, instead cache them + in GfxFont. Fixes #8140. + + ChangeLog | 8 ++++++++ + poppler/GfxFont.cc | 2 ++ + poppler/GfxFont.h | 6 ++++++ + poppler/GlobalParams.cc | 4 ++-- + 4 files changed, 18 insertions(+), 2 deletions(-) + +commit a88fadf0bb9af55c83c9c4f7d08deb17d6aa9ae4 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Fri May 25 17:33:37 2007 +0000 + + 2007-05-25 Carlos Garcia Campos <carlosgc@gnome.org> + * glib/poppler-page.cc: + * glib/poppler-page.h: + * glib/poppler.h: + Add selection style parameter to render_selection in order + to allow + requesting selections of words and paragraphs. + + ChangeLog | 8 ++++++++ + glib/poppler-page.cc | 30 ++++++++++++++++-------------- + glib/poppler-page.h | 6 ++++-- + glib/poppler.h | 7 +++++++ + 4 files changed, 35 insertions(+), 16 deletions(-) + +commit bf195b489c22875695e202d6ca6659144ef57e61 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed May 23 21:20:58 2007 +0000 + + * qt4/src/poppler-document.cc: + * qt4/src/poppler-private.h: + Better handle the setting of the vector antialiasing for + Splash. + * qt4/src/Mainpage.dox: + * qt4/src/poppler-link.h: + * qt4/src/poppler-qt4.h: + A few of API documentation fixes and improvements. + + ChangeLog | 10 ++++++++ + qt4/src/Mainpage.dox | 8 ++----- + qt4/src/poppler-document.cc | 5 ++-- + qt4/src/poppler-link.h | 4 +++- + qt4/src/poppler-private.h | 1 + + qt4/src/poppler-qt4.h | 57 + ++++++++++++++++++++++++++++++--------------- + 6 files changed, 57 insertions(+), 28 deletions(-) + +commit 36d1fe292778ba29990a389c50a0df0d51f11913 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 21 21:42:38 2007 +0000 + + Fix assert in bug 11023 + + ChangeLog | 4 ++++ + glib/poppler-action.cc | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +commit 5b411246a2cce6ed3bb2d8c9e9d856227b6aba7f +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 21 21:39:08 2007 +0000 + + * glib/poppler-page.cc: + * glib/poppler-page.h: + poppler_page_render_section() for cairo. Bug 7023 + + ChangeLog | 6 ++++ + glib/poppler-page.cc | 88 + ++++++++++++++++++++++++++++++++++++++++++++++------ + glib/poppler-page.h | 9 ++++++ + 3 files changed, 93 insertions(+), 10 deletions(-) + +commit 409f2a9cb31add29accb87011331c50dc08110cd +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 21 21:35:10 2007 +0000 + + * glib/poppler-page.cc: + * glib/poppler-page.h: + * glib/poppler-private.h: + * glib/poppler.h: + * glib/test-poppler-glib.c: + * poppler/CairoOutputDev.cc: + * poppler/CairoOutputDev.h: Extend CairoOutputdev to do + image caching when rendering + + ChangeLog | 11 +++ + glib/poppler-page.cc | 161 ++++++++++++++++++++++++++++++++-- + glib/poppler-page.h | 10 +++ + glib/poppler-private.h | 3 + + glib/poppler.h | 9 +- + glib/test-poppler-glib.c | 27 +++++- + poppler/CairoOutputDev.cc | 215 + ++++++++++++++++++++++++++++++++++++++++++++++ + poppler/CairoOutputDev.h | 122 ++++++++++++++++++++++++++ + 8 files changed, 545 insertions(+), 13 deletions(-) + +commit afd11ec66430dae084b5a5560333e933460fc637 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 21 21:29:09 2007 +0000 + + * poppler/Annot.cc: avoid crashing if the font for the + drawing methods + can not be found + * poppler/Form.cc: fix memory leak + * qt4/src/poppler-private.h: fix the UnicodeParsedString + function to + really work and not crash + * splash/SplashTypes.h: RGB8X mode makes max number of + components in + any SplashColor always be 4 + + ChangeLog | 11 +++++++++++ + poppler/Annot.cc | 6 ++++++ + poppler/Form.cc | 1 + + qt4/src/poppler-private.h | 5 ++++- + splash/SplashTypes.h | 6 +----- + 5 files changed, 23 insertions(+), 6 deletions(-) + +commit f019c8a8efde004e1663ea88cb48c0e46318d936 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 17 21:32:57 2007 +0000 + + 2007-05-17 Pino Toscano <pino@kde.org> + + * qt4/src/poppler-link.cc: + Give some default values to LinkDestination + * qt4/src/poppler-private.h: + Fix memory leak when converting QString -> GooString + + ChangeLog | 7 +++++++ + qt4/src/poppler-link.cc | 12 ++++++++++++ + qt4/src/poppler-private.h | 4 +++- + 3 files changed, 22 insertions(+), 1 deletion(-) + +commit d68a4eb44b5390b3093774f39a6805ad2e95c146 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sun May 13 00:53:43 2007 +0000 + + 2007-05-12 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/Annot.cc: Only do appearance generation for text, + choice or + other fields that contain text. Patch by Julien Rebetez. + + ChangeLog | 5 +++++ + poppler/Annot.cc | 52 + ++++++++++++++++++++++++++++++++++++++++++++++------ + 2 files changed, 51 insertions(+), 6 deletions(-) + +commit 96f8731e90af1abce67d00a3febc11880c69ce62 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 7 18:41:09 2007 +0000 + + * Catalog.cc: Fix leak + * Form.cc: Fix leak, provide empty + FormPageWidgets::~FormPageWidgets + implementation + * Page.cc: Fix leak + + ChangeLog | 7 +++++++ + poppler/Catalog.cc | 1 + + poppler/Form.cc | 5 +++++ + poppler/Page.cc | 1 + + 4 files changed, 14 insertions(+) + +commit d46553d696b2d7fe416ce8db40db54dd1d7c6733 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Apr 30 22:34:21 2007 +0000 + + * poppler/Makefile.am: Don't link cairo to all poppler, + just to + poppler_cairo so when compiling the qt frontend and the + glib frontend + the qt one does not end up depending on cairo + + ChangeLog | 6 ++++++ + poppler/Makefile.am | 1 - + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit d5c52409c532a126bcb8eb65f6f1390113a5f258 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 29 17:37:38 2007 +0000 + + jeff committed this line by mistake + + ChangeLog | 1 - + 1 file changed, 1 deletion(-) + +commit 6ddc11ef4c534369ee104422bfb989603c466790 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sun Apr 29 17:33:58 2007 +0000 + + 2007-04-29 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/UnicodeTypeTable.cc: Make some of the unicode tables + const + which gets rid of about 20k of data. + + text data bss dec hex filename + before: 1415838 128864 8 1544710 179206 libpoppler.so + after: 1404574 140128 8 1544710 179206 libpoppler.so + + ChangeLog | 10 ++++++++++ + poppler/UnicodeTypeTable.cc | 24 ++++++++++++------------ + 2 files changed, 22 insertions(+), 12 deletions(-) + +commit c5613ab5ce65fc84eb3a5584cee1454171173fa7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 28 23:25:59 2007 +0000 + + * poppler/SplashOutputDev.cc: + * qt/poppler-private.h: + * qt4/src/poppler-private.h: + * splash/Splash.cc: + * splash/SplashBitmap.cc: + * splash/SplashTypes.h: Rename splashModeRGBX8 to + splashModeXBGR8 and + hopefully fix qt frontends image generation + + ChangeLog | 10 +++++ + poppler/SplashOutputDev.cc | 102 + +++++++++++++++++++++++++++++++++------------ + qt/poppler-private.h | 2 +- + qt4/src/poppler-private.h | 2 +- + splash/Splash.cc | 44 +++++++++---------- + splash/SplashBitmap.cc | 16 +++---- + splash/SplashTypes.h | 4 +- + 7 files changed, 120 insertions(+), 60 deletions(-) + +commit 6479ce224f1393235ca9888dfe0710327fbfccd2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 28 22:12:22 2007 +0000 + + fix merging problems + + splash/Splash.cc | 1 + + splash/SplashBitmap.cc | 1 - + 2 files changed, 1 insertion(+), 1 deletion(-) + +commit e2ac4ada3e29139053871ff7f53772e1ccc7adc0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 28 15:39:36 2007 +0000 + + \n at the end of the printf + Although i'm not sure we want to printf this... + + poppler/GlobalParams.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 9b8133940638c95940edcb9b98126ca9a4f7b8d4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 28 12:00:38 2007 +0000 + + * qt4/src/Makefile.am: + * qt4/src/poppler-document.cc: + * qt4/src/poppler-ps-converter.cc: + * qt4/src/poppler-qt4.h: Replace Document::print function + with lots of + arguments with a helper class with lots of functions. Will + help + mantaining BC in case we decide to add more functionality + to the + printing process. + + ChangeLog | 10 +++ + qt4/src/Makefile.am | 1 + + qt4/src/poppler-document.cc | 39 ++------- + qt4/src/poppler-ps-converter.cc | 190 + ++++++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-qt4.h | 119 +++++++++++++++++++++---- + 5 files changed, 307 insertions(+), 52 deletions(-) + +commit 26d5fefcd4c858e2ebd689d963a65773957ac808 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 28 11:35:34 2007 +0000 + + * qt4/src/poppler-page.cc: + Hopefully fix the calculation of the image size when rendering + using + ArthurOutputDev. + + ChangeLog | 6 ++++++ + qt4/src/poppler-page.cc | 2 +- + 2 files changed, 7 insertions(+), 1 deletion(-) + +commit 218364bc4951682de8e63e1bd3f061636b08b615 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 28 11:34:14 2007 +0000 + + * glib/poppler-document.h: + * poppler/FontInfo.h: + * qt/poppler-qt.h: + * qt4/src/poppler-qt4.h: GfxFontType changed, adapt enums + of the + frontends and helper classes. Forgot to do it before merging. + + ChangeLog | 8 ++++++++ + glib/poppler-document.h | 6 +++++- + poppler/FontInfo.h | 6 +++++- + qt/poppler-qt.h | 6 +++++- + qt4/src/poppler-qt4.h | 20 ++++++++++++-------- + 5 files changed, 35 insertions(+), 11 deletions(-) + +commit c1a40d3b4e9b27e34c94c9477a0313534563a394 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 28 11:20:58 2007 +0000 + + * qt4/src/poppler-annotation.h: + Make the header clean. + + ChangeLog | 5 +++++ + qt4/src/poppler-annotation.h | 3 +++ + 2 files changed, 8 insertions(+) + +commit 3f4bf880b95e28a1ae7a38b18b341e089860780c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 28 11:16:49 2007 +0000 + + * qt4/src/Makefile.am: + * qt4/src/poppler-link-extractor-private.h: + * qt4/src/poppler-link-extractor.cc: + * qt4/src/poppler-page-private.h: + * qt4/src/poppler-page.cc: + * qt4/src/poppler-private.h: + * qt4/src/poppler-qt4.h: + Getting the links of a page now is not more dependant on + the current + output device, and can be done anytime; thus, the doLinks + parameter + of the Page::render() can be dropped. + + ChangeLog | 13 ++++++ + qt4/src/Makefile.am | 3 +- + qt4/src/poppler-link-extractor-private.h | 55 ++++++++++++++++++++++++ + qt4/src/poppler-link-extractor.cc | 74 + ++++++++++++++++++++++++++++++++ + qt4/src/poppler-page-private.h | 38 ++++++++++++++++ + qt4/src/poppler-page.cc | 52 ++++------------------ + qt4/src/poppler-private.h | 5 ++- + qt4/src/poppler-qt4.h | 4 +- + 8 files changed, 195 insertions(+), 49 deletions(-) + +commit 7f9eec9ef4e7dc895d2a3e38014b6368cc7564b6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Apr 27 22:41:10 2007 +0000 + + 2007-04-28 Albert Astals Cid <aacid@kde.org> + + * qt4/*: Stop requyring users to declare UNSTABLE_POPPLER_QT4 + + ChangeLog | 4 ++++ + qt4/src/Doxyfile | 2 +- + qt4/src/Mainpage.dox | 3 +-- + qt4/src/poppler-document.cc | 2 -- + qt4/src/poppler-embeddedfile.cc | 2 -- + qt4/src/poppler-fontinfo.cc | 2 -- + qt4/src/poppler-form.cc | 1 - + qt4/src/poppler-link.cc | 2 -- + qt4/src/poppler-page.cc | 1 - + qt4/src/poppler-qt4.h | 3 --- + qt4/src/poppler-sound.cc | 2 -- + qt4/src/poppler-textbox.cc | 2 -- + qt4/tests/check_attachments.cpp | 1 - + qt4/tests/check_dateConversion.cpp | 1 - + qt4/tests/check_fonts.cpp | 1 - + qt4/tests/check_metadata.cpp | 1 - + qt4/tests/check_pagelayout.cpp | 1 - + qt4/tests/check_pagemode.cpp | 1 - + qt4/tests/check_permissions.cpp | 1 - + qt4/tests/poppler-attachments.cpp | 1 - + qt4/tests/poppler-fonts.cpp | 1 - + qt4/tests/stress-poppler-qt4.cpp | 1 - + qt4/tests/test-password-qt4.cpp | 1 - + qt4/tests/test-poppler-qt4.cpp | 1 - + 24 files changed, 6 insertions(+), 32 deletions(-) + +commit 45993a6faafd7646075bc6630d5d2ad7a44f7e20 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Apr 27 22:26:09 2007 +0000 + + 2007-04-28 Carlos Garcia Campos <carlosgc@gnome.org> + reviewed and some code by: Albert Astals Cid <aacid@kde.org> + + * glib/poppler-page.cc: + * glib/poppler-page.h: + * glib/poppler.h: + * glib/test-poppler-glib.c: + * poppler/Makefile.am: + * poppler/PageTransition.cc: + * poppler/PageTransition.h: + * qt/poppler-page-transition.cc: + * qt/poppler-page-transition.h: Move Page Transition parsing + from qt + frontends to poppler core. Expose Page transitions on the glib + frontend. + + ChangeLog | 15 ++++ + glib/poppler-page.cc | 122 ++++++++++++++++++++++++++ + glib/poppler-page.h | 111 ++++++++++++++---------- + glib/poppler.h | 58 +++++++++---- + glib/test-poppler-glib.c | 60 +++++++++++++ + poppler/Makefile.am | 2 + + poppler/PageTransition.cc | 197 + +++++++++++++++--------------------------- + poppler/PageTransition.h | 86 ++++++++++++++++++ + qt/poppler-page-transition.cc | 145 ++++++------------------------- + qt/poppler-page-transition.h | 9 +- + 10 files changed, 497 insertions(+), 308 deletions(-) + +commit 877d6b202a75eb12119b16e740f85cc8b477d589 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Apr 27 21:25:30 2007 +0000 + + * glib/poppler-page.cc: + * poppler/PSOutputDev.cc: + * poppler/PSOutputDev.h: + * qt/poppler-document.cc: + * qt4/src/poppler-document.cc: + * qt4/src/poppler-qt4.h: + * utils/pdftohtml.cc: + * utils/pdftops.cc: + Add option to force rasterizing the pages when printing them + Add functionality to output the title field on the PS file + Only Qt4 frontend exposes the functionality + + Bringing this features from KPDF 3.5.7 to poppler + Testers welcome + Patches for other frontends more than welcome + Comments and suggestions even more than welcome :-) + + ChangeLog | 14 +++++++++++++ + glib/poppler-page.cc | 3 ++- + poppler/PSOutputDev.cc | 48 + +++++++++++++++++++++++++++++++-------------- + poppler/PSOutputDev.h | 17 ++++++++++------ + qt/poppler-document.cc | 2 +- + qt4/src/poppler-document.cc | 9 +++++++-- + qt4/src/poppler-qt4.h | 2 +- + utils/pdftohtml.cc | 2 +- + utils/pdftops.cc | 2 +- + 9 files changed, 71 insertions(+), 28 deletions(-) + +commit 99053be5357235c47a87775985646ef8d9880ed9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 26 17:57:01 2007 +0000 + + * goo/Makefile.am: Remove duplicate gmem.h + + ChangeLog | 4 ++++ + goo/Makefile.am | 1 - + 2 files changed, 4 insertions(+), 1 deletion(-) + +commit f6adb46cd88d23b34f1918d3be31c05b68b6a443 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Apr 25 21:31:17 2007 +0000 + + ignore pdftoabw binary + + utils/.cvsignore | 1 + + 1 file changed, 1 insertion(+) + +commit e09f231ac6c03ac2c3606f1bf20ba1bde3d85abd +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Apr 25 21:25:06 2007 +0000 + + 2007-04-25 Albert Astals Cid <aacid@kde.org> + + * qt4/src/poppler-document.cc: remove a delete[] no longer + needed + * qt4/src/poppler-private: initilize m_hints + + ChangeLog | 5 +++++ + qt4/src/poppler-document.cc | 1 - + qt4/src/poppler-private.h | 1 + + 3 files changed, 6 insertions(+), 1 deletion(-) + +commit bf7e0e980bf29994021cb1228f89f582adddf284 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Apr 25 19:59:09 2007 +0000 + + Merge xpdf302branch in HEAD as noone vetoed it. + Testing more than welcome + + ChangeLog | 140 + + configure.ac | 4 + + fofi/FoFiTrueType.cc | 458 +++- + fofi/FoFiTrueType.h | 42 +- + fofi/FoFiType1.cc | 65 +- + fofi/FoFiType1C.cc | 590 +++-- + fofi/FoFiType1C.h | 7 +- + glib/poppler-action.cc | 12 +- + glib/poppler-document.cc | 5 +- + glib/poppler-page.cc | 8 +- + goo/FixedPoint.cc | 31 +- + goo/FixedPoint.h | 5 + + goo/GooString.cc | 444 +++- + goo/GooString.h | 41 +- + goo/Makefile.am | 2 +- + goo/gfile.cc | 54 +- + goo/gmem.c | 238 -- + goo/gmem.cc | 264 ++ + goo/gmem.h | 27 +- + poppler/ABWOutputDev.cc | 1 - + poppler/ABWOutputDev.h | 1 - + poppler/Annot.cc | 1685 +++++++++--- + poppler/Annot.h | 83 +- + poppler/ArthurOutputDev.cc | 13 +- + poppler/Catalog.cc | 79 +- + poppler/Catalog.h | 16 +- + poppler/CharCodeToUnicode.cc | 31 +- + poppler/DCTStream.cc | 2 +- + poppler/DCTStream.h | 4 +- + poppler/Decrypt.cc | 427 ++- + poppler/Decrypt.h | 54 +- + poppler/Dict.cc | 23 +- + poppler/Dict.h | 27 +- + poppler/FontInfo.cc | 1 - + poppler/Form.cc | 19 +- + poppler/Form.h | 2 +- + poppler/Function.cc | 65 +- + poppler/Function.h | 8 +- + poppler/Gfx.cc | 1247 ++++++--- + poppler/Gfx.h | 39 +- + poppler/GfxFont.cc | 45 +- + poppler/GfxFont.h | 7 +- + poppler/GfxState.cc | 209 +- + poppler/GfxState.h | 42 +- + poppler/GlobalParams.cc | 399 ++- + poppler/GlobalParams.h | 41 +- + poppler/JBIG2Stream.cc | 96 +- + poppler/JBIG2Stream.h | 4 +- + poppler/JPXStream.cc | 246 +- + poppler/JPXStream.h | 8 +- + poppler/Lexer.cc | 18 +- + poppler/Link.cc | 150 +- + poppler/Link.h | 49 +- + poppler/Makefile.am | 4 +- + poppler/Object.cc | 5 +- + poppler/Object.h | 29 +- + poppler/Outline.cc | 1 - + poppler/OutputDev.cc | 2 + + poppler/OutputDev.h | 62 +- + poppler/PDFDoc.cc | 100 +- + poppler/PDFDoc.h | 21 +- + poppler/PSOutputDev.cc | 2715 ++++++++++++++----- + poppler/PSOutputDev.h | 58 +- + poppler/PSTokenizer.cc | 2 +- + poppler/Page.cc | 227 +- + poppler/Page.h | 22 +- + poppler/PageLabelInfo.cc | 1 - + poppler/Parser.cc | 66 +- + poppler/Parser.h | 11 +- + poppler/PreScanOutputDev.cc | 255 ++ + poppler/PreScanOutputDev.h | 128 + + poppler/SecurityHandler.cc | 17 +- + poppler/SecurityHandler.h | 5 + + poppler/SplashOutputDev.cc | 1480 ++++++----- + poppler/SplashOutputDev.h | 41 +- + poppler/Stream.cc | 338 +-- + poppler/Stream.h | 39 +- + poppler/TextOutputDev.cc | 537 +++- + poppler/TextOutputDev.h | 77 +- + poppler/UGooString.cc | 182 -- + poppler/UGooString.h | 79 - + poppler/XRef.cc | 29 +- + poppler/XRef.h | 6 +- + qt/poppler-document.cc | 15 +- + qt/poppler-page-transition.cc | 1 - + qt/poppler-page.cc | 4 +- + qt/poppler-private.h | 72 +- + qt4/src/poppler-annotation-helper.h | 38 +- + qt4/src/poppler-document.cc | 7 +- + qt4/src/poppler-embeddedfile.cc | 6 +- + qt4/src/poppler-form.cc | 12 +- + qt4/src/poppler-page.cc | 8 +- + qt4/src/poppler-private.h | 76 +- + splash/Splash.cc | 4994 + ++++++++++++++++++----------------- + splash/Splash.h | 137 +- + splash/SplashBitmap.cc | 110 +- + splash/SplashBitmap.h | 10 +- + splash/SplashClip.cc | 276 +- + splash/SplashClip.h | 28 +- + splash/SplashFTFont.cc | 104 +- + splash/SplashFTFont.h | 5 +- + splash/SplashFTFontEngine.cc | 54 +- + splash/SplashFTFontEngine.h | 9 +- + splash/SplashFTFontFile.cc | 19 +- + splash/SplashFTFontFile.h | 9 +- + splash/SplashFont.cc | 6 +- + splash/SplashFont.h | 13 +- + splash/SplashFontEngine.cc | 72 +- + splash/SplashFontEngine.h | 11 +- + splash/SplashFontFile.cc | 1 - + splash/SplashFontFile.h | 2 +- + splash/SplashMath.h | 15 +- + splash/SplashPath.cc | 42 +- + splash/SplashPath.h | 31 +- + splash/SplashPattern.cc | 28 - + splash/SplashPattern.h | 25 - + splash/SplashScreen.cc | 304 ++- + splash/SplashScreen.h | 18 +- + splash/SplashState.cc | 63 +- + splash/SplashState.h | 14 +- + splash/SplashT1Font.cc | 101 +- + splash/SplashT1Font.h | 6 +- + splash/SplashT1FontEngine.cc | 4 +- + splash/SplashT1FontFile.cc | 9 +- + splash/SplashT1FontFile.h | 7 +- + splash/SplashTypes.h | 72 +- + splash/SplashXPath.cc | 353 +-- + splash/SplashXPath.h | 26 +- + splash/SplashXPathScanner.cc | 143 + + splash/SplashXPathScanner.h | 13 + + utils/HtmlOutputDev.cc | 15 +- + utils/HtmlOutputDev.h | 15 +- + utils/pdffonts.cc | 15 +- + utils/pdfinfo.cc | 21 +- + utils/pdftoabw.cc | 1 - + utils/pdftohtml.cc | 3 +- + utils/pdftoppm.cc | 8 + + utils/pdftops.cc | 8 +- + utils/pdftotext.cc | 1 - + 139 files changed, 14538 insertions(+), 7039 deletions(-) + +commit ba74bb3b0632593d1937911d73709fc870480efd +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Apr 16 21:25:46 2007 +0000 + + * qt4/src/poppler-private.h: + Add the information about the open/close item in the DOM tree + of the TOC. + + ChangeLog | 7 +++++++ + qt4/src/poppler-private.h | 5 ++++- + 2 files changed, 11 insertions(+), 1 deletion(-) + +commit 6c7969f37c85f326327aca98e0346f2ebc86ffda +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 14 23:19:46 2007 +0000 + + * utils/HtmlFonts.cc: Fix rendering of text colors on + complex mode. + * utils/pdftohtml.cc: Fix rendering of links. + + ChangeLog | 5 +++++ + utils/HtmlFonts.cc | 8 ++++---- + utils/pdftohtml.cc | 2 +- + 3 files changed, 10 insertions(+), 5 deletions(-) + +commit add8515d7b3fba59c20ed1bbb058cea9e138c1a8 +Author: Brad Hards <bradh@frogmouth.net> +Date: Sat Apr 14 07:29:04 2007 +0000 + + Not sure what this was intended to do, but it triggers a lot of + problems with the unit tests (essentially, duplicate delete's). + + CCMAIL: aacid@kde.org + + qt4/src/poppler-embeddedfile.cc | 1 - + 1 file changed, 1 deletion(-) + +commit f3ded10305f6ac682640c37c21f569db0f830756 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sat Apr 7 21:12:35 2007 +0000 + + 2007-04-07 Jeff Muizelaar <jeff@infidigm.net> + + * utils/pdftoabw.cc: Fixing passing the wrong type + to fprintf. Patch by Kouhei Sutou. Fixes #10554. + + ChangeLog | 5 +++++ + utils/pdftoabw.cc | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit 2fcb76df955c143153fe4b273d0388fcb7f67d8a +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Fri Apr 6 15:27:52 2007 +0000 + + 2007-04-06 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/ABWOutputDev.cc: + * utils/pdftoabw.cc: Fix a number of issues with the new + AbiWord code: + *) Allows you to save to a file other than stdout + *) Checks for error conditions when reading the PDF + doc and + writing the ABW doc + *) Removes dead code in pdftoabw.cc + *) Fixes a SEGV I encountered when converting my new + home's floor plan + *) Returns proper error conditions should the conversion + fail for any reason + Patch by Dominic Lachowicz + + ChangeLog | 12 ++++++ + poppler/ABWOutputDev.cc | 3 ++ + utils/pdftoabw.cc | 101 + ++++++++++++++++++++++++++++-------------------- + 3 files changed, 74 insertions(+), 42 deletions(-) + +commit 29da65ec48b5ba91139084e197ce457d3cff3732 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 5 12:13:51 2007 +0000 + + * poppler/PSOutputDev.cc: Readd code wrongly removed when doing the + GlobalParams cleaning + + ChangeLog | 5 +++++ + poppler/PSOutputDev.cc | 5 +++++ + 2 files changed, 10 insertions(+) + +commit 722b2bd86f58f2d7a914571cccfa195485a70c47 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed Apr 4 02:42:29 2007 +0000 + + 2007-04-03 Jeff Muizelaar <jeff@infidigm.net> + + * configure.ac: + * poppler/ABWOutputDev.cc: + * poppler/ABWOutputDev.h: + * poppler/Makefile.am: + * utils/Makefile.am: + * utils/pdftoabw.cc: Add AbiWord output device and pdftoabw + program. + Patch by Jauco Noordzij. Autotools stuff by Dominic Lachowicz. + + ChangeLog | 10 + + configure.ac | 15 + + poppler/ABWOutputDev.cc | 1286 + +++++++++++++++++++++++++++++++++++++++++++++++ + poppler/ABWOutputDev.h | 140 ++++++ + poppler/Makefile.am | 17 + + utils/Makefile.am | 16 +- + utils/pdftoabw.cc | 138 +++++ + 7 files changed, 1620 insertions(+), 2 deletions(-) + +commit c9b467da290476da5ebbe8dc25699cd25e589b57 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 22 20:56:24 2007 +0000 + + * poppler/Gfx.cc: Accept reals for width and height of + images. Fixes + KDE bug 143322 + + ChangeLog | 5 +++++ + poppler/Gfx.cc | 14 ++++++++++---- + 2 files changed, 15 insertions(+), 4 deletions(-) + +commit ff8f8d44ef47a98f7dbdfaa4d27a720b1f37015f +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 15 20:16:13 2007 +0000 + + * glib/Makefile.am: Make it build with BSD/Make. Patch by + Henry Precheur <henry@precheur.org> + + ChangeLog | 5 +++++ + glib/Makefile.am | 4 ++-- + 2 files changed, 7 insertions(+), 2 deletions(-) + +commit bbf7e78b6b2509ecdc476d7f55151ef327470d9d +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 7 19:15:32 2007 +0000 + + 2007-03-07 Carlos Garcia Campos <carlosgc@gnome.org> + reviewed by: Albert Astals Cid <aacid@kde.org> + + * poppler/Page.cc: Consider 0x0 boxes as invalid. Fixes + http://bugzilla.gnome.org/show_bug.cgi?id=408682 + + 2007-03-06 Pino Toscano <pino@kde.org> + reviewed by: Albert Astals Cid <aacid@kde.org> + + * configure.ac: + * qt/Makefile.am: + * qt/poppler-link.cc: + * qt/poppler-page.cc: + * qt/poppler-private.h: + * qt4/poppler-link.cc: + Make the Qt4 frontend compilable again with no Splash. + Make the Qt3 frontend compilable with no Splash. + + ChangeLog | 18 ++++++++++++++++++ + configure.ac | 12 +----------- + poppler/Page.cc | 7 ++++++- + qt/Makefile.am | 1 - + qt/poppler-link.cc | 4 +++- + qt/poppler-page.cc | 16 +++++++++++++++- + qt/poppler-private.h | 11 ++++++++++- + qt4/src/poppler-link.cc | 10 ++++++---- + 8 files changed, 59 insertions(+), 20 deletions(-) + +commit 08dcc7121450cbfa163254001e73bb6a2670e055 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 6 22:27:18 2007 +0000 + + * poppler/Annot.cc: + * poppler/Form.cc: + Fix uninitialized variables. + Properly escape parenthesis and slash in text field + + ChangeLog | 9 ++++++++- + poppler/Annot.cc | 3 +++ + poppler/Form.cc | 1 + + 3 files changed, 12 insertions(+), 1 deletion(-) + +commit e8d3b21d08a59ec8b62503b48504fe046d746bfa +Author: Brad Hards <bradh@frogmouth.net> +Date: Sun Mar 4 07:30:31 2007 +0000 + + Switch to using pkg-config to find Qt4. + + ChangeLog | 9 +++ + configure.ac | 36 +++++------ + m4/qt.m4 | 165 + -------------------------------------------------- + poppler/Makefile.am | 2 +- + qt4/src/Makefile.am | 3 +- + qt4/tests/Makefile.am | 21 +++---- + 6 files changed, 36 insertions(+), 200 deletions(-) + +commit bd99616b9c06f96beadb68e015d2904b7fe2df1d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 25 00:34:21 2007 +0000 + + 007-02-25 Julien Rebetez <julienr@svn.gnome.org> + + reviewed by: Albert Astals Cid <aacid@kde.org> + + * poppler/Annot.cc: + * poppler/Annot.h: + * poppler/Form.cc: + * poppler/Form.h: + Fix compilation warnings. + + ChangeLog | 10 ++++++++++ + poppler/Annot.cc | 30 +++++++++++++++++------------- + poppler/Annot.h | 5 ++++- + poppler/Form.cc | 37 ++++++++++++++----------------------- + poppler/Form.h | 13 ++++++------- + 5 files changed, 51 insertions(+), 44 deletions(-) + +commit d8d23b56332618d8c7d8198f55ec6efafd24187e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 25 00:00:20 2007 +0000 + + forgot to commit these + + qt4/src/poppler-form.cc | 284 + ++++++++++++++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-form.h | 247 +++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 531 insertions(+) + +commit 984ce7f919aec27d5f4225376550cd6b58d4ae52 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 24 23:58:31 2007 +0000 + + 2007-02-25 Pino Toscano <pino@kde.org> + reviewed by: Albert Astals Cid <aacid@kde.org> + + * qt4/src/Doxyfile: + * qt4/src/Makefile.am: + * qt4/src/poppler-annotation-helper.h: + * qt4/src/poppler-form.cc: + * qt4/src/poppler-form.h: + * qt4/src/poppler-page.cc: + * qt4/src/poppler-private.h: + * qt4/src/poppler-qt4.h: + Beginning of interactive forms support, first + implementation in the + Qt4 frontend. It supports text and choice fields in + a basic way. + + ChangeLog | 14 ++++++++++ + qt4/src/Doxyfile | 1 + + qt4/src/Makefile.am | 2 ++ + qt4/src/poppler-annotation-helper.h | 18 ++++++------- + qt4/src/poppler-page.cc | 36 +++++++++++++++++++++++++ + qt4/src/poppler-private.h | 52 + ++++++++++++++++++++++++++++++++++++- + qt4/src/poppler-qt4.h | 7 +++++ + 7 files changed, 120 insertions(+), 10 deletions(-) + +commit de7a90fc724de14151ec994d18f860ada3be2ac8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 24 23:43:34 2007 +0000 + + 2007-02-25 Albert Astals Cid <aacid@kde.org> + + * configure.ac: + * glib/poppler-document.cc: + * poppler/GlobalParams.cc: + * poppler/GlobalParams.h: + * poppler/PSOutputDev.cc: + * qt/poppler-document.cc: + * qt4/src/poppler-document.cc: + * qt4/src/poppler-private.h: + * qt4/src/poppler-qt4.h: + * test/gtk-splash-test.cc: + * test/pdf-inspector.cc: + * utils/pdffonts.cc: + * utils/pdfimages.cc: + * utils/pdfinfo.cc: + * utils/pdftohtml.cc: + * utils/pdftoppm.cc: + * utils/pdftops.cc: + * utils/pdftotext.cc: Remove dependency on xpdfrc file + and cleanup + GlobalParams accordingly + + ChangeLog | 22 ++ + configure.ac | 1 - + glib/poppler-document.cc | 4 +- + poppler/GlobalParams.cc | 666 + +------------------------------------------- + poppler/GlobalParams.h | 59 +--- + poppler/PSOutputDev.cc | 8 - + qt/poppler-document.cc | 4 +- + qt4/src/poppler-document.cc | 2 +- + qt4/src/poppler-private.h | 2 +- + qt4/src/poppler-qt4.h | 6 +- + test/gtk-splash-test.cc | 2 +- + test/pdf-inspector.cc | 2 +- + utils/pdffonts.cc | 5 +- + utils/pdfimages.cc | 5 +- + utils/pdfinfo.cc | 5 +- + utils/pdftohtml.cc | 2 +- + utils/pdftoppm.cc | 15 +- + utils/pdftops.cc | 50 ++-- + utils/pdftotext.cc | 5 +- + 19 files changed, 72 insertions(+), 793 deletions(-) + +commit 74e70386b759a3cd9864d11eb4ca210010136aa5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 24 23:32:22 2007 +0000 + + 2007-02-25 Julien Rebetez <julienr@svn.gnome.org> + reviewed by: <aacid@kde.org> + + * glib/poppler-document.cc: + * glib/poppler-document.h: + * glib/poppler-page.cc: + * glib/poppler-page.h: + * glib/poppler-private.h: + * glib/poppler.h: + * poppler/Annot.cc: + * poppler/Annot.h: + * poppler/Catalog.cc: + * poppler/Catalog.h: + * poppler/CharCodeToUnicode.cc: + * poppler/CharCodeToUnicode.h: + * poppler/Dict.cc: + * poppler/Dict.h: + * poppler/Form.cc: + * poppler/Form.h: + * poppler/GfxFont.cc: + * poppler/GfxFont.h: + * poppler/Makefile.am: + * poppler/Object.h: + * poppler/Page.cc: + * poppler/Page.h: + * poppler/XRef.cc: + * poppler/XRef.h: + Beginning of Interactive Form support: + Add a bunch of new classes (FormWidget / FormField) + to deal with form + fields. + Add support for object modification through + XRef::setModifiedObject, as + well as a function to write the Xref to a file, + which will be used + to implement PDF writing. + Add some functions to glib wrapper to expose the + new form features. + + ChangeLog | 35 ++ + glib/poppler-document.cc | 192 +++++++ + glib/poppler-document.h | 55 ++ + glib/poppler-page.cc | 120 +++++ + glib/poppler-page.h | 55 ++ + glib/poppler-private.h | 4 + + glib/poppler.h | 15 +- + poppler/Annot.cc | 344 +++++++++--- + poppler/Annot.h | 21 +- + poppler/Catalog.cc | 17 +- + poppler/Catalog.h | 4 + + poppler/CharCodeToUnicode.cc | 34 ++ + poppler/CharCodeToUnicode.h | 3 + + poppler/Dict.cc | 32 ++ + poppler/Dict.h | 4 + + poppler/Form.cc | 1187 + ++++++++++++++++++++++++++++++++++++++++++ + poppler/Form.h | 470 +++++++++++++++++ + poppler/GfxFont.cc | 27 + + poppler/GfxFont.h | 5 + + poppler/Makefile.am | 2 + + poppler/Object.h | 4 + + poppler/Page.cc | 11 +- + poppler/Page.h | 8 +- + poppler/XRef.cc | 87 ++++ + poppler/XRef.h | 9 + + 25 files changed, 2666 insertions(+), 79 deletions(-) + +commit 5c4ea446f33248964431e79b14592b30362634fe +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 18 21:44:24 2007 +0000 + + * configure.ac: Change {datadir}/poppler to {datarootdir}/poppler so + that i get /usr/local/share/poppler in config.h + instead of + ${prefix}/poppler Better fixes are welcome. + + ChangeLog | 6 ++++++ + configure.ac | 2 +- + 2 files changed, 7 insertions(+), 1 deletion(-) + +commit dd140dd63de661303b578863af4d515d82117cca +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 4 00:19:25 2007 +0000 + + fix date + + ChangeLog | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 3c1ed68bf4ee49b27275f7f65d49f42933b1cfa0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 4 00:16:43 2007 +0000 + + * poppler/Lexer.cc: + * poppler/Lexer.h: Patch to fix regression introduced by + optimizations + in bugzilla issue 7808 + + ChangeLog | 6 ++++++ + poppler/Lexer.cc | 30 ++++++++++++++++++++---------- + poppler/Lexer.h | 2 +- + 3 files changed, 27 insertions(+), 11 deletions(-) + +commit 672408839de0deac4c6006b54df723336ee4be2d +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 31 22:05:09 2007 +0000 + + * qt4/src/poppler-page.cc: + Patch by Pino Toscano <pino@kde.org> to remove a nonsense done + by him. + + * qt4/tests/test-poppler-qt4.cpp: + Simply a bit. Patch by Pino Toscano <pino@kde.org>. + + ChangeLog | 8 ++++++++ + qt4/src/poppler-page.cc | 2 -- + qt4/tests/test-poppler-qt4.cpp | 24 ++++++++++++------------ + 3 files changed, 20 insertions(+), 14 deletions(-) + +commit 9c64b8c754e09ff2858af56ce38ef013002bf8e4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 31 18:48:16 2007 +0000 + + * m4/qt.m4: Fix Qt4 detection on Mac. Patch by Benjamin Reed + <ranger@befunk.com> + + ChangeLog | 5 +++++ + m4/qt.m4 | 26 +++++++++++++++++++++++--- + 2 files changed, 28 insertions(+), 3 deletions(-) + +commit 1b81192ff2bb9fae4a7bbc685fafe1718f303a7b +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 28 15:55:11 2007 +0000 + + * glib/poppler-page.cc: Make link mapping coordinates + follow page + rotation. Patch by Carlos Garcia Campos <carlosgc@gnome.org> + * glib/poppler-action.cc: Fix link destination + coordinates. Patch by + Carlos Garcia Campos <carlosgc@gnome.org> + + ChangeLog | 4 ++ + glib/poppler-action.cc | 15 +++++- + glib/poppler-page.cc | 124 + +++++++++++++++++++++++++++++++------------------ + 3 files changed, 97 insertions(+), 46 deletions(-) + +commit 75dcf94f53c2d7241111f0d527ee4d3a2ef0b0cf +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 28 15:36:08 2007 +0000 + + * glib/poppler-document.cc: Plug memory leak in + poppler-document. Patch by Carlos Garcia Campos <carlosgc@gnome.org> + + ChangeLog | 5 +++++ + glib/poppler-document.cc | 30 ++++++++++++++---------------- + 2 files changed, 19 insertions(+), 16 deletions(-) + +commit 682a15fc38a2c569d9b1f9871e3e949b62b33cf8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 21 22:35:23 2007 +0000 + + * poppler-document.cc: + * poppler-page.cc: + * poppler-private.h: + * poppler-qt4.h: + No need to destroy the Splash output device to change its + paper color. + Add the possibility to set flags that affect the rendering + (some + backends supports only some of them, though). + Add a Page::label to get the label associated with a page. + Patches by Pino Toscano <pino@kde.org>. + + ChangeLog | 12 ++++++++++++ + qt4/src/poppler-document.cc | 20 ++++++++++++++++++++ + qt4/src/poppler-page.cc | 14 +++++++++++++- + qt4/src/poppler-private.h | 29 ++++++++++++++++++++++++----- + qt4/src/poppler-qt4.h | 25 +++++++++++++++++++++++++ + 5 files changed, 94 insertions(+), 6 deletions(-) + +commit 7331bc46c1cb323316501f05ae1740bea5655596 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 17 20:06:29 2007 +0000 + + * poppler/Sound.h: + * poppler/Sound.cc: + * qt4/src/poppler-sound.cc: Move most of the sound reading + code + into the Sound class, so frontends can use it easily. + Patch by Pino Toscano <pino@kde.org>. + + ChangeLog | 10 +++- + poppler/Sound.cc | 80 +++++++++++++++++++++++++- + poppler/Sound.h | 32 ++++++++++- + qt4/src/poppler-sound.cc | 144 + +++++++++++++++++------------------------------ + 4 files changed, 167 insertions(+), 99 deletions(-) + +commit 841bee94da7b6376d2e1fb3daaf8b727b90e42d8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jan 13 23:19:21 2007 +0000 + + * poppler/Stream.h: + * poppler/Stream.cc: Remove MemStream::setNeedFree method + i really did + not need it + * qt4/src/poppler-document.cc: + * qt4/src/poppler-link.cc: + * qt4/src/poppler-page.cc: + * qt4/src/poppler-private.h: Make Document::loadFromData + work on + documents with a password and don't need to do a malloc and + a memcpy. + + ChangeLog | 11 +++++++ + poppler/Stream.cc | 5 --- + poppler/Stream.h | 1 - + qt4/src/poppler-document.cc | 74 + ++++++++++++++++++++++++--------------------- + qt4/src/poppler-link.cc | 4 +-- + qt4/src/poppler-page.cc | 34 ++++++++++----------- + qt4/src/poppler-private.h | 24 +++++++++------ + 7 files changed, 84 insertions(+), 69 deletions(-) + +commit e1432fd7c4a6a2386789f450d39c6d954fd4e656 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jan 13 18:29:39 2007 +0000 + + * configure.ac + * poppler/Makefile.am + * qt4/src/Makefile.am + * qt4/src/poppler-document.cc + * qt4/src/poppler-link.cc + * qt4/src/poppler-page.cc + * qt4/src/poppler-private.h + * qt4/src/poppler-qt4.h: Make the Qt4 backend compilable + even with + no Splash backend. Patch by Pino Toscano <pino@kde.org>. + + ChangeLog | 12 ++++++++++++ + configure.ac | 5 ----- + poppler/Makefile.am | 5 +++-- + qt4/src/Makefile.am | 6 +++++- + qt4/src/poppler-document.cc | 16 ++++++++++++++-- + qt4/src/poppler-link.cc | 1 + + qt4/src/poppler-page.cc | 15 ++++++++++++--- + qt4/src/poppler-private.h | 8 +++++++- + qt4/src/poppler-qt4.h | 6 ++++++ + 9 files changed, 60 insertions(+), 14 deletions(-) + +commit 457038e97325720615c4390ffa075dd8283966ee +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jan 13 17:56:07 2007 +0000 + + * poppler/Stream.h: + * poppler/Stream.cc: Add MemStream::setNeedFree method + * qt4/src/poppler-document.cc: + * qt4/src/poppler-private.h: + * qt4/src/poppler-qt4.h: Add Document::loadFromData method + + ChangeLog | 8 ++++++++ + poppler/Stream.cc | 5 +++++ + poppler/Stream.h | 1 + + qt4/src/poppler-document.cc | 22 ++++++++++++++++++++++ + qt4/src/poppler-private.h | 17 +++++++++++++++-- + qt4/src/poppler-qt4.h | 16 ++++++++++++++++ + 6 files changed, 67 insertions(+), 2 deletions(-) + +commit 4e2a9c49ecab00b1f5d175570165cd490afdd31e +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 11 22:28:03 2007 +0000 + + goo/gmem.c: Merge change from xpdf-3.01pl2 + + ChangeLog | 4 ++++ + goo/gmem.c | 13 +++++++++++-- + 2 files changed, 15 insertions(+), 2 deletions(-) + +commit bce14b274fd788d728116950d6464a85e33a9966 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 11 22:12:11 2007 +0000 + + * poppler/Catalog.h: + * poppler/Catalog.cc: Limit max depth of recursive calls on + readPageTree to fix MOAB-06-01-2007 + + ChangeLog | 6 ++++++ + poppler/Catalog.cc | 20 +++++++++++++++----- + poppler/Catalog.h | 2 +- + 3 files changed, 22 insertions(+), 6 deletions(-) + +commit 3f0679a336ffaf2aff149f8526fa11f8f8cbda59 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jan 6 21:53:08 2007 +0000 + + Patch by Pino Toscano <pino@kde.org> to fix some memory leaks when + dealing with sounds. + + ChangeLog | 9 +++++++++ + poppler/Sound.cc | 1 + + qt4/src/poppler-link.cc | 5 +++++ + qt4/src/poppler-link.h | 1 + + qt4/src/poppler-page.cc | 4 ++++ + qt4/src/poppler-sound.cc | 7 ++++++- + 6 files changed, 26 insertions(+), 1 deletion(-) + +commit d41cd2f567a955031cb7498d9089e70e14df4a42 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 4 19:10:16 2007 +0000 + + qt4/src/poppler-private.h: gmallocn -> new[] + + ChangeLog | 4 ++++ + qt4/src/poppler-private.h | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +commit f8edfb6832144cbbd1b234f6b35e33325269255c +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 4 18:56:13 2007 +0000 + + qt/poppler-page-transition.cc: Fix memory leak. Patch by Tobias + Koenig <tokoe@kde.org> + + ChangeLog | 5 +++++ + qt/poppler-page-transition.cc | 1 + + 2 files changed, 6 insertions(+) + +commit 250a9f4b429344e0968c7bd0c0cebe7af373ae0a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 30 14:50:25 2006 +0000 + + * qt4/src/poppler-qt4.h: + * qt4/src/poppler-document.cc: Add const & to some parameters. Patch + by Pino Toscano <pino@kde.org> + + ChangeLog | 6 ++++++ + qt4/src/poppler-document.cc | 4 ++-- + qt4/src/poppler-qt4.h | 4 ++-- + 3 files changed, 10 insertions(+), 4 deletions(-) + +commit 250c1f94cc9a53f980fd08364d6cce29db9fd067 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 29 14:08:35 2006 +0000 + + * poppler/UGooString.cc: Patch by Pino Toscano <pino@kde.org> so + that QStringToUGooString does not crash. + + ChangeLog | 5 +++++ + poppler/UGooString.cc | 1 + + 2 files changed, 6 insertions(+) + +commit 42770e5f07407b03dce31c73fd6956f9c8fc9a06 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Fri Dec 29 04:12:40 2006 +0000 + + 2006-12-28 Brad Taylor <brad@getcoded.net> + + * poppler/glib/poppler-document.h: + * poppler/glib/poppler-document.cc: Add + poppler_document_new_from_data + to allow loading PDFs out of memory. + + ChangeLog | 6 +++ + glib/poppler-document.cc | 113 + ++++++++++++++++++++++++++++++++++------------- + glib/poppler-document.h | 4 ++ + 3 files changed, 93 insertions(+), 30 deletions(-) + +commit 6fedd991b584e300b5710630fa7942d357fe7aaa +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Dec 28 17:22:36 2006 +0000 + + * qt4/src/poppler-embeddedfile.cc: + * qt4/src/poppler-document.cc: + * qt/poppler-document.cc: Fix memory leaks + + ChangeLog | 6 ++++++ + qt/poppler-document.cc | 4 ++++ + qt4/src/poppler-document.cc | 4 +++- + qt4/src/poppler-embeddedfile.cc | 4 +++- + 4 files changed, 16 insertions(+), 2 deletions(-) + +commit 7da5885e45c33382060276c95d9a3bd117ae55c7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Dec 28 15:51:44 2006 +0000 + + * goo/GooString.cc + * goo/GooString.h + * goo/gmem.c + * goo/gmem.h + * poppler/Lexer.cc + * poppler/Lexer.h + * poppler/PageLabelInfo.cc + * poppler/Parser.cc + * poppler/UGooString.cc + * poppler/UGooString.h: Patch by Krzysztof Kowalczyk + <kkowalczyk@gmail.com> to improve performance. See bug 7808 for + details. + + ChangeLog | 15 ++++ + goo/GooString.cc | 186 + ++++++++++++++++++++++++----------------------- + goo/GooString.h | 28 +++++-- + goo/gmem.c | 3 +- + goo/gmem.h | 2 +- + poppler/Lexer.cc | 19 +++-- + poppler/Lexer.h | 10 +++ + poppler/PageLabelInfo.cc | 1 + + poppler/Parser.cc | 17 +++-- + poppler/UGooString.cc | 137 +++++++++++++++++++++++++++------- + poppler/UGooString.h | 40 ++++++++-- + 11 files changed, 313 insertions(+), 145 deletions(-) + +commit fbc05a6791fc28ee26a9d9188722ea3453c65ddc +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Dec 27 23:15:06 2006 +0000 + + * poppler/Annot.cc: + * poppler/Annot.h: Add type checking to processing of "Rect". Patch + by Scott Turner <scotty1024@mac.com> + + ChangeLog | 6 ++++++ + poppler/Annot.cc | 48 +++++++++++++++++++++++++++++------------------- + poppler/Annot.h | 1 + + 3 files changed, 36 insertions(+), 19 deletions(-) + +commit dc6b372358ac629c43aa2faabd644942cb0ed98b +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Dec 27 15:23:04 2006 +0000 + + Remove , after last value of enum. Thanks to André Wöbbeking + + ChangeLog | 1 + + poppler/Catalog.h | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +commit c7d19539a95927eb277966a521f13393c9e116bb +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Dec 27 12:38:58 2006 +0000 + + qt4/src/poppler-qt4.h: Remove , after last value of enum. Thanks to + André Wöbbeking + + ChangeLog | 5 +++++ + qt4/src/poppler-qt4.h | 4 ++-- + 2 files changed, 7 insertions(+), 2 deletions(-) + +commit b29429c702e6540b9f35689b0a164f30e747d5d9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Dec 26 20:07:03 2006 +0000 + + * qt4/src/poppler-qt4.h: + * qt4/src/poppler-page.cc: Add Page::duration() function to the + qt4 frontend. + + ChangeLog | 6 ++++++ + qt4/src/poppler-page.cc | 8 ++++++++ + qt4/src/poppler-qt4.h | 9 ++++++++- + 3 files changed, 22 insertions(+), 1 deletion(-) + +commit 62dfc58903b496c4cc720c8b2c759c6fb82fb443 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Dec 26 19:56:28 2006 +0000 + + * glib/test-poppler-glib.c: + * glib/poppler-page.cc: + * glib/poppler-page.h: + * poppler/Page.cc: + * poppler/Page.h: Implement /Dur entry in page object. Patch + by Carlos + Garcia Campos <carlosgc@gnome.org> + + ChangeLog | 9 +++++++++ + glib/poppler-page.cc | 16 ++++++++++++++++ + glib/poppler-page.h | 1 + + glib/test-poppler-glib.c | 7 +++++++ + poppler/Page.cc | 13 +++++++++++++ + poppler/Page.h | 6 ++++++ + 6 files changed, 52 insertions(+) + +commit 34e5aa62f4d3ba7a2d94a68a91c11a48277a4119 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 23 13:12:13 2006 +0000 + + * poppler/PSTokenizer.cc: Enhance PSTokenizer::getToken + performance. + Patch by Scott Turner <scotty1024@mac.com>. In a random pdf + i tested + the patchs improves PSTokenizer::getToken performance by 15% + + ChangeLog | 6 ++++++ + poppler/PSTokenizer.cc | 33 +++++++++++++++++++++------------ + poppler/PSTokenizer.h | 1 + + 3 files changed, 28 insertions(+), 12 deletions(-) + +commit 1a5fa1d2ced62e7d027e085663e987cff625ce0b +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 22 23:39:41 2006 +0000 + + poppler/Page.cc: Fix memory leak when reading a wrong color map in + a thumbnail. Patch by Scott Turner <scotty1024@mac.com> + + ChangeLog | 3 +++ + poppler/Page.cc | 1 + + 2 files changed, 4 insertions(+) + +commit dd1c134dcf085338a85188c7f205fc300396dc86 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 22 23:27:53 2006 +0000 + + qt/poppler-page.cc: Fix memory leak in Page::textList. Patch by + Jerry Epplin <jepplin@globalvelocity.com> + + ChangeLog | 5 +++++ + qt/poppler-page.cc | 4 +++- + 2 files changed, 8 insertions(+), 1 deletion(-) + +commit 87e474a018c4808d6251fd79f9e9640e0f733551 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Thu Dec 21 01:01:30 2006 +0000 + + 2006-12-20 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: Fix scaling of maskedImage + masks. They + should be scaled to the size of the image not the size of + the mask. + Fixes #9403. + + ChangeLog | 6 ++++++ + poppler/CairoOutputDev.cc | 8 ++------ + 2 files changed, 8 insertions(+), 6 deletions(-) + +commit 769a89623c680f51690db1751522b016b02b83a8 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed Dec 20 19:55:55 2006 +0000 + + 2006-12-20 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/GlobalParams.cc: Try to make zero-width lines as + close to + one pixel wide as we can. Fixes #9393. + + ChangeLog | 5 +++++ + poppler/CairoOutputDev.cc | 10 ++++++++-- + 2 files changed, 13 insertions(+), 2 deletions(-) + +commit 5c4bca18373528f293bd5e080efca572977fc1ff +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Dec 19 20:27:55 2006 +0000 + + poppler/SplashOutputDev.cc: Fix gray calculation. Patch by Scott + Turner <scotty1024@mac.com> + + ChangeLog | 5 +++++ + poppler/SplashOutputDev.cc | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit fba99578f6001ae0c0df0442bb73040b55109b1d +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Tue Dec 12 05:23:59 2006 +0000 + + 2006-12-12 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: Change a cairo_set_matrix to + cairo_transform so that we don't blindly clobber the existing + matrix. + Patch by Daniel Colascione. + Fixes #9190. + + ChangeLog | 7 +++++++ + poppler/CairoOutputDev.cc | 2 +- + 2 files changed, 8 insertions(+), 1 deletion(-) + +commit 9a6ffa1c6e009f8606a055f873efdcd5829fcfa2 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sun Dec 10 05:24:56 2006 +0000 + + 2006-12-09 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/Function.cc: Initialize PostScriptFunction::codeString + to + NULL so that it can safely deleted if initialization fails. + Fixes #9263. + + ChangeLog | 6 ++++++ + poppler/Function.cc | 1 + + 2 files changed, 7 insertions(+) + +commit e92d63a179ae022270156da4e396c15ff9236d89 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Nov 23 19:01:44 2006 +0000 + + * m4/libjpeg.m4: Make JPEG library header search work under + MSYS. Patch by Alexis Wilke + + ChangeLog | 5 +++++ + m4/libjpeg.m4 | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit 3913110f698fd006b394a395b5b0adfde30af31b +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 22 21:55:27 2006 +0000 + + there should not be any whitespace after the \ + + qt4/src/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit c3ab7addec5a7990872949b813c2b727b1614d64 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Nov 19 18:51:23 2006 +0000 + + Another leak fix on qt4/src/poppler-page.cc the previous changelog + is enough for this one ;-) + + qt4/src/poppler-page.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 9e9b82da91abacb916b05302d40bf822af6ac7f1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Nov 19 12:59:48 2006 +0000 + + * qt4/src/poppler-link.cc: + * qt4/src/poppler-page.cc: + * qt4/src/poppler-qt4.h: + * qt4/src/poppler-textbox.cc: Fix memory leaks + * splash/Splash.cc: Initialize the values of nClipRes + + ChangeLog | 8 ++++++++ + qt4/src/poppler-link.cc | 6 ++++++ + qt4/src/poppler-page.cc | 4 +++- + qt4/src/poppler-qt4.h | 1 + + qt4/src/poppler-textbox.cc | 5 +++++ + splash/Splash.cc | 2 +- + 6 files changed, 24 insertions(+), 2 deletions(-) + +commit b9faacc62182efcbc84df2471e4c5dcf2b03bda8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Nov 18 17:08:04 2006 +0000 + + * qt4/src/poppler-document.cc + * qt4/src/poppler-qt4.h: Add int marginRight, int + marginBottom, int + marginLeft, int marginTop, bool strictMargins to + Document::print() + + ChangeLog | 6 ++++++ + qt4/src/poppler-document.cc | 11 +++++++++-- + qt4/src/poppler-qt4.h | 6 +++++- + 3 files changed, 20 insertions(+), 3 deletions(-) + +commit da8e6d4c3e0afdaa031413649ae20545c8a1f845 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Nov 16 21:03:27 2006 +0000 + + really commit pino's patch :-S + + qt4/src/Doxyfile | 11 +++-- + qt4/src/Mainpage.dox | 26 +++++----- + qt4/src/poppler-annotation.h | 33 ++++++++----- + qt4/src/poppler-link.h | 68 +++++++++++++++++++++---- + qt4/src/poppler-qt4.h | 115 + +++++++++++++++++++++++++++---------------- + 5 files changed, 171 insertions(+), 82 deletions(-) + +commit 4f26e65096e3133a39fc0c9e82084c90cf77dda9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Nov 16 21:00:10 2006 +0000 + + * qt4/src/Mainpage.dox: + * qt4/src/Doxyfile: + * qt4/src/poppler-annotation.h: + * qt4/src/poppler-link.h: + * qt4/src/poppler-qt4.h: Improve API documentation. Patch by + Pino Toscano. + + Generated docu at http://people.freedesktop.org/~aacid/docs/qt4/ + + ChangeLog | 9 +++++++++ + qt4/src/Mainpage.dox | 2 +- + 2 files changed, 10 insertions(+), 1 deletion(-) + +commit e68b6f3f8fea1e4f036eba0f19bb7e0c423d408c +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 15 21:07:50 2006 +0000 + + 2006-11-15 Albert Astals Cid <aacid@kde.org> + + * qt4/src/poppler-link.cc: + * qt4/src/poppler-page.cc: + * qt4/src/poppler-qt4.h: + * qt4/src/poppler-document.cc: + * qt4/src/poppler-private.h: Generalize the way we render + the pages: + merge all the Page::renderTo* functions in only one that + renders on + a QImage, taking into account the currently chosen backend. + It is possible to switch rendering backend using the Document. + Patch by Pino Toscano. + + * qt4/tests/stress-poppler-qt4.cpp: + * qt4/tests/test-password-qt4.cpp: + * qt4/tests/test-poppler-qt4.cpp: Adapt the tests to the + changes in + the rendering API of Page. Patch by Pino Toscano. + + ChangeLog | 17 ++++++ + qt4/src/poppler-document.cc | 14 +++++ + qt4/src/poppler-link.cc | 2 +- + qt4/src/poppler-page.cc | 123 + +++++++++++++++++++++------------------ + qt4/src/poppler-private.h | 32 ++++++---- + qt4/src/poppler-qt4.h | 75 +++++++----------------- + qt4/tests/stress-poppler-qt4.cpp | 3 +- + qt4/tests/test-password-qt4.cpp | 12 ++-- + qt4/tests/test-poppler-qt4.cpp | 17 +++--- + 9 files changed, 152 insertions(+), 143 deletions(-) + +commit 37088dd3335be6e7641c47bea9b1ddd689b07372 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Nov 13 19:16:44 2006 +0000 + + * poppler/ArthurOutputDev.cc: Small fix to get colors right + + ChangeLog | 4 ++++ + poppler/ArthurOutputDev.cc | 8 ++++---- + 2 files changed, 8 insertions(+), 4 deletions(-) + +commit 302e2cab9fd626222c69ad40f7e40be2e65d34a9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Nov 11 15:41:27 2006 +0000 + + Fix typo when outputing PS scale + + ChangeLog | 4 ++++ + poppler/PSOutputDev.cc | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +commit e3550fb286dae98992b30edbf4a9300fa58d2e77 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Tue Nov 7 23:53:31 2006 +0000 + + 2006-11-07 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: take horizontal scaling into account + when updating the font. Also, cleanup some unused code. Fixes + #8924. + + ChangeLog | 5 +++++ + poppler/CairoOutputDev.cc | 9 ++------- + 2 files changed, 7 insertions(+), 7 deletions(-) + +commit f020b64a72ad5c82c3e7bdcf15039bb0037b1f22 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Oct 18 18:43:59 2006 +0000 + + 2006-10-18 Albert Astals Cid <aacid@kde.org> + + * qt4/src/poppler-document.cc: + * qt4/src/poppler-private.h: Do not crash when opening a + encrypted document. Do not crash when unlocking a locked + document. + + ChangeLog | 7 +++++++ + qt4/src/poppler-document.cc | 41 + ++++++++++++++++------------------------- + qt4/src/poppler-private.h | 14 ++++++++++++++ + 3 files changed, 37 insertions(+), 25 deletions(-) + +commit 577330ee1d4d1021174cf1bd59557a83a017e06f +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Oct 11 23:09:24 2006 +0000 + + * splash/Splash.cc: + * splash/SplashErrorCodes.h: Do not crash on documents that + report a + 0x0 mask for an image, like + http://bugs.kde.org/attachment.cgi?id=18083&action=view + + ChangeLog | 7 +++++++ + splash/Splash.cc | 2 ++ + splash/SplashErrorCodes.h | 2 ++ + 3 files changed, 11 insertions(+) + +commit 42c016c6d3c6de65fd92b51b9d6cc96d52404689 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Oct 8 20:38:47 2006 +0000 + + * poppler/Link.cc: + * poppler/Link.h: + * poppler/Makefile.am: + * poppler/Page.cc: + * poppler/Page.h: + * poppler/Sound.cc: + * poppler/Sound.h: Make poppler able to read Sound objects, + Sound + actions and Opening/Closing page actions. Patch by Pino + Toscano. + + * qt4/src/Makefile.am: + * qt4/src/poppler-link.cc: + * qt4/src/poppler-link.h: + * qt4/src/poppler-qt4.h: + * qt4/src/poppler-page.cc: + * qt4/src/poppler-sound.cc: Support for sounds, sound links + and page + actions in the Qt4 backend. Patch by Pino Toscano. + + ChangeLog | 19 +++++ + poppler/Link.cc | 53 ++++++++++++++ + poppler/Link.h | 32 +++++++++ + poppler/Makefile.am | 2 + + poppler/Page.cc | 8 +++ + poppler/Page.h | 4 ++ + poppler/Sound.cc | 65 +++++++++++++++++ + poppler/Sound.h | 46 ++++++++++++ + qt4/src/Makefile.am | 1 + + qt4/src/poppler-link.cc | 35 ++++++++++ + qt4/src/poppler-link.h | 26 ++++++- + qt4/src/poppler-page.cc | 32 +++++++++ + qt4/src/poppler-qt4.h | 87 +++++++++++++++++++++++ + qt4/src/poppler-sound.cc | 177 + +++++++++++++++++++++++++++++++++++++++++++++++ + 14 files changed, 586 insertions(+), 1 deletion(-) + +commit 1da064d7e7403ec7111eecb2b9613e27a2c4bb5d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 30 16:28:35 2006 +0000 + + * qt4/src/poppler-page.cc: PA is optional, H is a name not a string + + ChangeLog | 4 ++++ + qt4/src/poppler-page.cc | 15 +++++++++------ + 2 files changed, 13 insertions(+), 6 deletions(-) + +commit 29366d8e470ab2207cdfdab115c2fa9618c4c74e +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 25 20:43:18 2006 +0000 + + * glib/Makefile.am + * qt/Makefile.am + * qt4/src/Makefile.am + * qt4/tests/Makefile.am + * test/Makefile.am + * utils/Makefile.am: Add FONTCONFIG_CFLAGS FONTCONFIG_LIBS + for people + that need them. Patch by morfoh@opensde.org. Fixes bug #8415 + + ChangeLog | 10 ++++++++++ + glib/Makefile.am | 2 ++ + qt/Makefile.am | 6 ++++-- + qt4/src/Makefile.am | 2 ++ + qt4/tests/Makefile.am | 2 ++ + test/Makefile.am | 6 ++++-- + utils/Makefile.am | 6 ++++-- + 7 files changed, 28 insertions(+), 6 deletions(-) + +commit 957c1e59df213a01ca87f03d067a8dab5dc09fb6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 25 20:05:28 2006 +0000 + + ignore poppler-features.h + + glib/.cvsignore | 1 + + 1 file changed, 1 insertion(+) + +commit 3158b54375bdfdc82779362cc9442aade87f84f6 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Sep 22 00:55:54 2006 +0000 + + 2006-09-21 Kristian Høgsberg <krh@redhat.com> + + * NEWS: Update list of bugs fixes, release 0.5.4. + + ChangeLog | 2 ++ + NEWS | 2 +- + 2 files changed, 3 insertions(+), 1 deletion(-) + +commit 17dd1f60f9328ae68fbe262ae0745be976ff9f95 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Sep 21 23:28:14 2006 +0000 + + 2006-09-21 Kristian Høgsberg <krh@redhat.com> + + * configure.ac: Check for gtk+ 2.8 for the gtk+ test case, invert + help text for zlib option (#7788, #7661). + + ChangeLog | 3 +++ + configure.ac | 12 +++++------- + 2 files changed, 8 insertions(+), 7 deletions(-) + +commit ddbbd697424b9122ce1f0541ddada3fe8bb38fb1 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Sep 21 22:58:31 2006 +0000 + + 2006-09-21 Kristian Høgsberg <krh@redhat.com> + + * utils/pdftops.cc: Get duplex setting from GlobalParams. + + ChangeLog | 2 ++ + utils/pdftops.cc | 3 ++- + 2 files changed, 4 insertions(+), 1 deletion(-) + +commit 0d25592a1a5811ee8fffbd70307c7bcaaaacadf3 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Sep 21 22:40:52 2006 +0000 + + 2006-09-21 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc (_poppler_page_new): Make PopplerPage + reference its document throughout the lifetime of the page + (#7005). + + ChangeLog | 3 +++ + glib/poppler-page.cc | 5 ++++- + 2 files changed, 7 insertions(+), 1 deletion(-) + +commit b834755c7ae45eb4020e9cdbc3852eac0151fcdc +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Sep 21 22:37:00 2006 +0000 + + 2006-09-21 Kristian Høgsberg <krh@redhat.com> + + * poppler/Gfx.cc: Remove the right out->updateAll() call. + + ChangeLog | 4 ++++ + poppler/Gfx.cc | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +commit 181e2af1edf2cbc3c8edadad0dce215a64a990dd +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Sep 21 01:05:23 2006 +0000 + + 2006-09-20 Kristian Høgsberg <krh@redhat.com> + + * NEWS: Sum up changes. + + * configure.ac: Bump release to 0.5.4. + + ChangeLog | 4 ++++ + NEWS | 10 ++++++++++ + configure.ac | 2 +- + 3 files changed, 15 insertions(+), 1 deletion(-) + +commit cc9c17a6730422be99ebcd69991fcf5d7b569640 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Sep 21 00:56:33 2006 +0000 + + 2006-09-20 Kristian Høgsberg <krh@redhat.com> + + * poppler/Gfx.cc: Remove last remnant of erroneous type3 commit a + while back, fixing #8182. + + ChangeLog | 5 +++++ + poppler/CairoOutputDev.cc | 1 - + poppler/Gfx.cc | 1 - + 3 files changed, 5 insertions(+), 2 deletions(-) + +commit 83be722b56d9266b89946fe994023351e47eb4fd +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed Sep 20 20:22:19 2006 +0000 + + 2006-09-20 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/TextOutputDev.cc: TextFontInfo stores a copy of + a pointer + to a GfxFont but does not increment the reference count. Fix the + problem by calling incRefCnt and decRefCnt appropriately. Fixes + #4649 + + ChangeLog | 6 ++++++ + poppler/TextOutputDev.cc | 4 ++++ + 2 files changed, 10 insertions(+) + +commit 1cf60015d7d78668c83737be6015dc880fd04ebf +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue Sep 19 04:39:07 2006 +0000 + + 2006-09-19 Kristian Høgsberg <krh@redhat.com> + + * poppler/GlobalParams.cc: Add scanEncodingDirs() to automatically + scan in any encodings found under ${datadir}/poppler. + + * m4/define-dir.m4: New file, adds AC_DEFINE_DIR macro. + + ChangeLog | 7 +++ + configure.ac | 16 +------ + goo/gfile.cc | 16 +++---- + goo/gfile.h | 2 + + m4/define-dir.m4 | 34 ++++++++++++++ + poppler/GlobalParams.cc | 116 + ++++++++++++++++++++++++++++++++---------------- + poppler/GlobalParams.h | 7 ++- + 7 files changed, 136 insertions(+), 62 deletions(-) + +commit 821c883f9df9cc0e5b81aa2e070727996cf3bc4e +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Sep 18 15:40:50 2006 +0000 + + 2006-09-13 Kristian Høgsberg <krh@redhat.com> + + * poppler/Makefile.am (libpoppler_la_LIBADD): Add cairo libs to + link if configured. + + ChangeLog | 3 +++ + poppler/Makefile.am | 4 ++++ + 2 files changed, 7 insertions(+) + +commit d8ab8ebc94c32d32ad17ed54cede453de25d7dd5 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed Sep 13 20:25:03 2006 +0000 + + 2006-09-13 Kristian Høgsberg <krh@redhat.com> + + * configure.ac: Tighten glib check (#7906), add check for C++ + compiler (#8048). + + ChangeLog | 5 +++++ + configure.ac | 3 ++- + 2 files changed, 7 insertions(+), 1 deletion(-) + +commit 7c748075e18cfe95be6a56adf09ce7f2f032b86f +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 12 19:48:47 2006 +0000 + + sorry Jeff + + ChangeLog | 7 +++++++ + 1 file changed, 7 insertions(+) + +commit 6cdcfae0e1c6fbec07ee5273e6ad97ef04110868 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 11 21:20:56 2006 +0000 + + 2006-09-11 Albert Astals Cid <aacid@kde.org> + + * qt4/src/poppler-annotation.cc: + * qt4/src/poppler-annotation.h: + * qt4/src/poppler-page.cc: Add support for + LinkAnnotation. Patch by + Pino Toscano + + ChangeLog | 10 +- + qt4/src/poppler-annotation.cc | 230 + +++++++++++++++++++++++++++++++++++++++- + qt4/src/poppler-annotation.h | 22 +++- + qt4/src/poppler-page.cc | 237 + +++++++++++++++++++++++++----------------- + 4 files changed, 392 insertions(+), 107 deletions(-) + +commit 8335c7eea2aa62a580170f47323d8674bd89e412 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Fri Sep 8 23:28:22 2006 +0000 + + 2006-09-08 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: The work-around for 1x1 imagemasks + was not + calling cairo_set_source causing the rectangles to be drawn + the wrong + colour occasionally. Fix by moving the existing call to + cairo_set_source above the work-around. Fixes #7113. + + ChangeLog | 7 +++++++ + poppler/CairoOutputDev.cc | 8 ++++---- + 2 files changed, 11 insertions(+), 4 deletions(-) + +commit 02d505aa0176b6e5a54ee82426d8333a9ef8f000 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Thu Sep 7 04:01:39 2006 +0000 + + 2006-09-06 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: Avoid crashing in CairoOutputDev if + endString is called without a corresponding beginString. Fixes + #4515. + + ChangeLog | 5 +++++ + poppler/CairoOutputDev.cc | 8 +++++++- + 2 files changed, 12 insertions(+), 1 deletion(-) + +commit 3ea0aada0434c9f815814253dd9d1374ae6643cc +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed Sep 6 23:54:30 2006 +0000 + + 2006-09-06 Jeff Muizelaar <jeff@infidigm.net> + + * configure.ac: + * poppler/FlateStream.cc: + * poppler/FlateStream.h: Fix FlateStream to not read more than it + needs. This has a performance impact because our input buffer + is now + only 1 byte large, however correctness is better than performance. + This should fix #3948. + + ChangeLog | 9 +++++++++ + configure.ac | 2 +- + poppler/FlateStream.cc | 35 +++++++++++++++++++++++++---------- + poppler/FlateStream.h | 3 ++- + 4 files changed, 37 insertions(+), 12 deletions(-) + +commit 1d2e6aedca0b8fcce6ac84ae2576ab067912886b +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Tue Sep 5 01:21:50 2006 +0000 + + 2006-09-04 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: Initialize currentFont to NULL before + use. Found by Pascal Terjan. Fixes #7924. + + ChangeLog | 5 +++++ + poppler/CairoOutputDev.cc | 1 + + 2 files changed, 6 insertions(+) + +commit 7905adaa21f2347346927fa567c64be60e2bc69c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 3 09:27:21 2006 +0000 + + * poppler/Dict.cc: + * poppler/Dict.h: + * poppler/Object.h: + * poppler/Parser.cc: Patch by Krzysztof Kowalczyk to increase + speed by + means of doing less copies between objects. See bug 8112 + for more + information. + + ChangeLog | 9 +++++++++ + poppler/Dict.cc | 4 ++-- + poppler/Dict.h | 11 +++++++++-- + poppler/Object.h | 12 ++++++++++++ + poppler/Parser.cc | 15 +++++++++------ + 5 files changed, 41 insertions(+), 10 deletions(-) + +commit 4da7c90a619002e54f436c4efee723b5bc42a112 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 24 22:32:31 2006 +0000 + + * qt4/src/poppler-private.h: Init m_fontInfoScanner to + NULL. Discovered by + Rafael Rodríguez <rafael.rodriguez.tf@gmail.com> + + ChangeLog | 5 +++++ + qt4/src/poppler-private.h | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit 469202e117910beb4e0ad906d5c154a3bae5c98b +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 16 14:35:14 2006 +0000 + + * qt/poppler-page.cc: Report correct page size. Backport from Qt4 + frontend. Patch by Wilfried Huss + + ChangeLog | 5 +++++ + qt/poppler-page.cc | 10 ++++++++-- + 2 files changed, 13 insertions(+), 2 deletions(-) + +commit b881844e4d31009c5d54c9321a6daaf0f354cf6b +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Aug 16 09:18:04 2006 +0000 + + did not want to commit that, thanks Brad for noticing! + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit f52380e6d569280839d7c37362bd7cc59f2573c3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 15 22:27:31 2006 +0000 + + add a warning how nasty zlib can be, it can come and it your pdfs + and make your readers crash when you are not looking at it, so be + aware that if you enable it you are on your own ;-) + + ChangeLog | 4 ++++ + configure.ac | 4 ++-- + 2 files changed, 6 insertions(+), 2 deletions(-) + +commit 1caba84b1024f1fa7865deebbf70379855ce078d +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Aug 11 13:12:11 2006 +0000 + + 2006-08-11 Albert Astals Cid <aacid@kde.org> + + * poppler/Catalog.cc: Fix leak + + ChangeLog | 4 ++++ + poppler/Catalog.cc | 1 + + 2 files changed, 5 insertions(+) + +commit 9b6455f6530e273afaa5f948b67ceeec8a06f976 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 10 16:08:51 2006 +0000 + + 2006-08-10 Albert Astals Cid <aacid@kde.org> + + * poppler/SplashOutputDev.cc: Try to fix refs to fonts + yet again + + ChangeLog | 4 ++++ + poppler/SplashOutputDev.cc | 4 ++-- + 2 files changed, 6 insertions(+), 2 deletions(-) + +commit 305f60e0437dcfc5babd449123a1fe4cd062a219 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Aug 5 17:10:07 2006 +0000 + + 2006-08-05 Albert Astals Cid <aacid@kde.org> + + * poppler/Catalog.cc: The name array can contain references + to strings + instead of stings themselves, or at least PDF of + https://bugs.freedesktop.org/show_bug.cgi?id=7780 does. This + makes it + work with that file + * qt4/src/poppler-embeddedfile.cc: Use UGooString for + description + + ChangeLog | 8 ++++++++ + poppler/Catalog.cc | 12 ++++++++++-- + qt4/src/poppler-embeddedfile.cc | 3 ++- + 3 files changed, 20 insertions(+), 3 deletions(-) + +commit dd8758ea3f0f44e9f8362343f15b2064f428ad64 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Aug 4 22:48:09 2006 +0000 + + 2006-08-05 Albert Astals Cid <aacid@kde.org> + + * utils/pdftotext.cc: + * utils/pdfinfo.cc: + * utils/pdffonts.cc: Add the posibility of reading a file + from stdin. + Patch by Dom Lachowicz + + ChangeLog | 7 +++++++ + utils/pdffonts.cc | 11 ++++++++++- + utils/pdfinfo.cc | 11 ++++++++++- + utils/pdftotext.cc | 11 ++++++++++- + 4 files changed, 37 insertions(+), 3 deletions(-) + +commit a418d844cf6baa797919796ceadaf21ef9b2e5b9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 3 10:34:52 2006 +0000 + + * configure.ac: Use the correct variable to output the + utils status. + Patch by Dom Lachowic + + ChangeLog | 5 +++++ + configure.ac | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit 1673b895656143a8a1f1a45e07f777f39995940d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jul 30 20:31:31 2006 +0000 + + * poppler/GfxState.cc: make nGfxBlendModeNames define + return the + correct size of the gfxBlendModeNames array so it does + not access + invalid memory areas when the blend mode is not + found. Discovered by + Krzysztof Kowalczyk + + ChangeLog | 7 +++++++ + poppler/GfxState.cc | 12 +++++++----- + 2 files changed, 14 insertions(+), 5 deletions(-) + +commit e4561568d14e7b3b2aec6ecaf3cc09078bdf7a46 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jul 30 09:38:28 2006 +0000 + + * splash/SplashFontEngine.cc: + * poppler/SplashOutputDev.cc: Fix memory leak when using + embedded + fonts in the pdf file. Patch by Krzysztof Kowalczyk + + ChangeLog | 6 ++++++ + poppler/SplashOutputDev.cc | 8 ++++++-- + splash/SplashFontEngine.cc | 12 ++++++++---- + 3 files changed, 20 insertions(+), 6 deletions(-) + +commit 4a27502159a89992f54be2673b44bf7a8392b60d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jul 29 16:24:53 2006 +0000 + + push back thing i did not want to commit, sorry + + configure.ac | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit ba448afc0e97a9e779409ff228adcd4f627971f5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jul 29 16:22:52 2006 +0000 + + * configure.ac: Disable qt and qt4 frontends if splash + backend is + disabled + + ChangeLog | 5 +++++ + configure.ac | 18 ++++++++++++++---- + 2 files changed, 19 insertions(+), 4 deletions(-) + +commit 1e32d3baa5e8296caf55bd5853216a96618c74ac +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Jul 28 18:17:45 2006 +0000 + + 2006-07-28 Kristian Høgsberg <krh@redhat.com> + + * poppler/CairoOutputDev.cc: Don't set font matrix translation + (fix from Behdad Esfahbod). + + ChangeLog | 5 +++++ + poppler/CairoOutputDev.cc | 4 ++-- + 2 files changed, 7 insertions(+), 2 deletions(-) + +commit 0bc1b0f35c28cb80dd27d24110367348e52c143b +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jul 27 18:21:28 2006 +0000 + + fix date, i don't live in the past + + ChangeLog | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 2f27c3a0218608568f6cd1c718ef51b9879023a3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jul 27 18:17:50 2006 +0000 + + * poppler/Stream.cc: If you are going to test a variable, + better + initialize it first ;-) Fixes bug 7646 + + ChangeLog | 5 +++++ + poppler/Stream.cc | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit f39ab43ca824cb7e5db73137c4545b3e85134425 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jul 26 18:16:01 2006 +0000 + + 2006-07-26 Albert Astals Cid <aacid@kde.org> + + * qt/poppler-document.cc: + * qt/poppler-private.h: + * qt/poppler-qt.h: Port the QDomDocument *Document::toc() + const method + from the qt4 frontend to the qt frontend. Patch by Wilfried + Huss + + ChangeLog | 7 ++++++ + qt/poppler-document.cc | 18 ++++++++++++++++ + qt/poppler-private.h | 58 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + qt/poppler-qt.h | 16 ++++++++++++++ + 4 files changed, 99 insertions(+) + +commit c3a9fd546b853c85b6be5fc8f4e5a78d8a7e7437 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jul 25 18:39:57 2006 +0000 + + * qt4/src/poppler-document.cc: Obey kdeprint masters in that + a library + should output as much device independent PS as posible, + so disabling + duplex printing for default is a good idea. + + ChangeLog | 6 ++++++ + qt4/src/poppler-document.cc | 2 +- + 2 files changed, 7 insertions(+), 1 deletion(-) + +commit edc0499644b8083600ced9a5087ec0b0189e615b +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Jul 24 19:49:51 2006 +0000 + + 2006-07-24 Kristian Høgsberg <krh@redhat.com> + + * configure.ac: + * poppler/Makefile.am: Move fontconfig dependency to libpoppler. + + ChangeLog | 5 +++++ + configure.ac | 18 +++++++----------- + poppler/Makefile.am | 6 ++++-- + 3 files changed, 16 insertions(+), 13 deletions(-) + +commit 24b5a68a3f4cdba63fbcd01dc178a330b5f604a7 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Tue Jul 18 21:32:11 2006 +0000 + + 2006-07-18 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/Gfx.cc: fix opCloseStroke to match the behaviour of + a separate opClose and opStroke. Previously, opCloseStroke only + closes if there is a path however opClose closes unconditionally. + + ChangeLog | 6 ++++++ + poppler/Gfx.cc | 2 +- + 2 files changed, 7 insertions(+), 1 deletion(-) + +commit c57ebd40fcf85432b2e5045086d158a63af12525 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Tue Jul 18 21:26:57 2006 +0000 + + 2006-07-18 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/TextOutputDev.cc: call setDefaultCTM() after start page + like in Gfx.cc. This fixes a regression caused by the fix + to #6948. + + ChangeLog | 5 +++++ + poppler/TextOutputDev.cc | 1 + + 2 files changed, 6 insertions(+) + +commit 640d5d5a9d9e53f3f677eb05f3d18e6bfc74e95a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jul 16 18:22:23 2006 +0000 + + 2006-07-16 Albert Astals Cid <aacid@kde.org> + + * poppler/GfxState.cc: Do not crash when we can not + parse a GfxImageColorMap + Fixes crash on pdf that can be found at + + ChangeLog | 7 +++++++ + poppler/GfxState.cc | 4 ++++ + qt4/src/Doxyfile | 4 ++-- + 3 files changed, 13 insertions(+), 2 deletions(-) + +commit c6926d1d8ab04468f56f4687cdd3f06af206226b +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 28 19:23:52 2006 +0000 + + * poppler/DCTStream.cc: + * poppler/DCTStream.h: Reset jpeg structures on reset. + Fixes crash while printing pdf at + http://bugs.kde.org/attachment.cgi?id=16818&action=view + + ChangeLog | 7 +++++++ + poppler/DCTStream.cc | 25 ++++++++++++++++++------- + poppler/DCTStream.h | 2 ++ + 3 files changed, 27 insertions(+), 7 deletions(-) + +commit 96ac8dec591a0325a822c1f7b7bc7e78b867e3a0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 25 16:59:31 2006 +0000 + + Ask for paper size width and height to pass it to PSOutputDev in + both qt frontends (qt got abi mantained, qt4 changed as you still + have to define UNSTABLE_POPPLER_QT4 to be able of using it, one day + we'll have to think of removing it) + + ChangeLog | 8 ++++++++ + qt/poppler-document.cc | 9 +++++++-- + qt/poppler-qt.h | 9 +++++++++ + qt4/src/poppler-document.cc | 4 ++-- + qt4/src/poppler-qt4.h | 10 +++++++++- + 5 files changed, 35 insertions(+), 5 deletions(-) + +commit 965011f2001fb1ea36857995d5555266f82b8d96 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 25 16:20:50 2006 +0000 + + put back a change that was not meant to be commited + + qt/poppler-qt.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 4995d09c91173d34a435112828aff21a63b147e9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 25 16:19:32 2006 +0000 + + rename poppler-link.h to poppler-link-qt3.h to not get conflicts + on install + + qt/Makefile.am | 2 +- + qt/poppler-link-qt3.h | 188 ++++++++++++++++++++++++++++++++++++ + qt/poppler-link.cc | 258 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + qt/poppler-qt.h | 4 +- + 4 files changed, 449 insertions(+), 3 deletions(-) + +commit 087921b134c2646e6d41960f471a1819c7c8790a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 25 10:29:22 2006 +0000 + + add link support to qt3 frontend. + Patch by Wilfried Huss based on Qt4 code + + ChangeLog | 11 ++++ + qt/Makefile.am | 4 +- + qt/poppler-document.cc | 19 ++++--- + qt/poppler-page.cc | 136 + ++++++++++++++++++++++++++++++++++++++++++++++--- + qt/poppler-private.h | 33 +++++++++++- + qt/poppler-qt.h | 14 +++-- + 6 files changed, 196 insertions(+), 21 deletions(-) + +commit 831bd8942ef3224354b128d5e14e68fdfc57168b +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 11 16:14:32 2006 +0000 + + optimization by Mario Teijeiro Otero + + poppler/UGooString.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1223fd4b200f6c13996f8299f3563c818af0c21d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 10 22:23:19 2006 +0000 + + * poppler/UGooString.cc: When any of the chars that we + are passing to the UGooString is not pdfencodable, do not + encode the string, because we loose information if we do, + this fixes rendering of + http://publikationen.ub.uni-frankfurt.de/volltexte/2005/890/pdf/TR_abs_g.pdf + and other docs with type3 fonts and ligatures + + ChangeLog | 9 +++++++++ + poppler/UGooString.cc | 8 ++++++++ + 2 files changed, 17 insertions(+) + +commit b85a39ddfc7de8c0621e995c114885ecd08fcdc2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jun 1 21:03:38 2006 +0000 + + * qt4/src/poppler-qt4.h: + * qt4/src/poppler-page.cc: Add Rotation parameter that + is passed + to the respective output devs + + ChangeLog | 6 ++++++ + qt4/src/poppler-page.cc | 22 ++++++++++++++-------- + qt4/src/poppler-qt4.h | 14 +++++++++----- + 3 files changed, 29 insertions(+), 13 deletions(-) + +commit 2b5d3277f36864ff1ef44f1942f22de247d67ab6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jun 1 17:23:45 2006 +0000 + + * qt/poppler-document.cc: + * qt/poppler-qt.h: Add printing support, patch by + Stefan Kebekus <stefan.kebekus@math.uni-koeln.de> + + ChangeLog | 6 ++++++ + qt/poppler-document.cc | 18 ++++++++++++++++++ + qt/poppler-qt.h | 2 ++ + 3 files changed, 26 insertions(+) + +commit 5380d005b7b54cc6587ce6e8c3bbb358da5cd9a5 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Thu Jun 1 06:42:25 2006 +0000 + + 2006-06-01 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/PSOutputDev.cc: + * poppler/PSOutputDev.h: Change filename parameter to PSOutputDev + constructor from char * to const char *. + + ChangeLog | 6 ++++++ + poppler/PSOutputDev.cc | 2 +- + poppler/PSOutputDev.h | 2 +- + 3 files changed, 8 insertions(+), 2 deletions(-) + +commit c2a81ea8b01f3943a2eb737cf957acc0d05f7eed +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed May 31 20:14:04 2006 +0000 + + * poppler/SplashOutputDev.cc: + * splash/Splash.cc: Fix no splashModeRGB8Qt mode, that is, + make it + show images + + I'm sorry, really, i'll try to do better + + ChangeLog | 6 ++++++ + poppler/SplashOutputDev.cc | 10 ++++++++++ + splash/Splash.cc | 3 +++ + 3 files changed, 19 insertions(+) + +commit 643b310cf51474b6dfc077fe086ea121e807f6e1 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed May 31 19:18:28 2006 +0000 + + 2006-05-31 Jeff Muizelaar <jeff@infidigm.net> + + * TODO: Remove items's from my list that are done. + + ChangeLog | 4 ++++ + TODO | 3 --- + 2 files changed, 4 insertions(+), 3 deletions(-) + +commit 96e582721dcb15ea258b989c7c500084bff9f56d +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed May 31 17:31:49 2006 +0000 + + 2006-05-31 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: + * poppler/CairoOutputDev.h: Change the cairo backend to use the + transformation in cairo instead of doing all of the + transformations in + the OutputDevice. Fixes #6948. + + ChangeLog | 7 ++ + poppler/CairoOutputDev.cc | 200 + ++++++++++++++++++++-------------------------- + poppler/CairoOutputDev.h | 1 + + 3 files changed, 96 insertions(+), 112 deletions(-) + +commit 00ffb9bf50b6b3b2e8eaa8af593aaa01d4a62a34 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed May 31 04:53:27 2006 +0000 + + 2006-05-31 Kristian Høgsberg <krh@redhat.com> + + * NEWS: Sum up changes. + + * configure.ac: Bump release to 0.5.3. + + ChangeLog | 6 ++++++ + NEWS | 8 ++++++++ + configure.ac | 2 +- + 3 files changed, 15 insertions(+), 1 deletion(-) + +commit 223a4bf3a679f666b6c963a8787cf5b5ac75c4b6 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed May 31 02:02:54 2006 +0000 + + 2006-05-30 Kristian Høgsberg <krh@redhat.com> + + * poppler-glib.pc.in: + * configure.ac: Add poppler as a private requires if pkg-config + supports it. + + ChangeLog | 6 ++++++ + configure.ac | 11 +++++++++++ + poppler-glib.pc.in | 3 ++- + 3 files changed, 19 insertions(+), 1 deletion(-) + +commit 7aaa4d3fbdb8ea2534d3cb80e68b2759b2e8fd2f +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue May 30 21:46:06 2006 +0000 + + 2006-05-30 Kristian Høgsberg <krh@redhat.com> + + * test/gtk-cairo-test.cc: Add --page option to gtk-cairo-test. + + ChangeLog | 4 ++++ + test/gtk-cairo-test.cc | 21 ++++++++++++++++++--- + 2 files changed, 22 insertions(+), 3 deletions(-) + +commit f7c1d519b9695ad8adfdcf3af696de746cdcf375 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Mon May 29 18:44:17 2006 +0000 + + 2006-05-29 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoFontEngine.cc: + * poppler/CairoFontEngine.h: + * poppler/CairoOutputDev.cc: Allow CairoFont creation to fail more + gracefully. Fixes #4030. + + ChangeLog | 7 +++++++ + poppler/CairoFontEngine.cc | 27 +++++++++++++++++++++------ + poppler/CairoFontEngine.h | 4 +++- + poppler/CairoOutputDev.cc | 5 +++++ + 4 files changed, 36 insertions(+), 7 deletions(-) + +commit 84861800dad3649d4757d5c5539b9e86e2b2c644 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sat May 27 17:27:37 2006 +0000 + + 2006-05-27 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: + * poppler/CairoOutputDev.h: Back out the rest of krh's type3 + font work. This fixes type3 fonts in CairoOutputDevice. + + ChangeLog | 6 ++++++ + poppler/CairoOutputDev.cc | 3 +++ + poppler/CairoOutputDev.h | 2 +- + 3 files changed, 10 insertions(+), 1 deletion(-) + +commit 6f5a89a0a2cf17d45d1c31ce105829be8c7ac456 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 23 20:49:16 2006 +0000 + + * poppler/SplashOutputDev.cc: + * qt4/src/poppler-private.h: + * splash/Splash.cc: + * splash/SplashBitmap.cc: + * splash/SplashTypes.h: bring splashModeRGB8 back to the + old code + (before Frank's patch), create splashModeRGB8Qt that has + Frank's + codepath and is used by Qt frontends. Fixes corruption on + other programs expecting the old behaviour. + + Remember dude we are now a lib! you can not change behaviour from + one day to another! + + /me hits himself + + ChangeLog | 11 +++ + poppler/SplashOutputDev.cc | 8 +++ + qt/poppler-private.h | 2 +- + qt4/src/poppler-private.h | 2 +- + splash/Splash.cc | 169 + +++++++++++++++++++++++++++++++++++++++++++++ + splash/SplashBitmap.cc | 26 ++++++- + splash/SplashTypes.h | 2 + + 7 files changed, 216 insertions(+), 4 deletions(-) + +commit 495d592c3ba7fe81e03774f5b2ed677e5aa560c7 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue May 23 19:16:37 2006 +0000 + + 2006-05-23 Kristian Høgsberg <krh@redhat.com> + + * qt4/src/Makefile.am (libpoppler_qt4_la_SOURCES): Add missing + + ChangeLog | 5 +++++ + qt4/src/Makefile.am | 1 + + 2 files changed, 6 insertions(+) + +commit eecd06c86585bca05c99cd2e9a1b1ff3bbae3c72 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon May 22 20:19:35 2006 +0000 + + 2006-05-22 Kristian Høgsberg <krh@redhat.com> + + * configure.ac: Bump release. + * NEWS: Sum up changes. + + ChangeLog | 5 +++++ + NEWS | 11 ++++++++++- + configure.ac | 2 +- + 3 files changed, 16 insertions(+), 2 deletions(-) + +commit 680f20dfd1cf0342d49516b3848a2aef5d2a3883 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon May 22 19:58:41 2006 +0000 + + 2006-05-22 Kristian Høgsberg <krh@redhat.com> + + Patch from Rainer Keller to fix the ImageOutputDev (#6984). + + * utils/ImageOutputDev.cc (drawImage): Upate to work with new + 16-bit color representation. + + * utils/ImageOutputDev.h: Return gTrue for needNonText(). + + ChangeLog | 9 +++++++++ + NEWS | 4 ++++ + utils/ImageOutputDev.cc | 6 +++--- + utils/ImageOutputDev.h | 2 +- + 4 files changed, 17 insertions(+), 4 deletions(-) + +commit e43a06bf6e953fa9af18476e2c9f27106398c09c +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sun May 21 23:26:45 2006 +0000 + + 2006-05-21 Kristian Høgsberg <krh@redhat.com> + + * poppler/CairoFontEngine.cc: + * poppler/CairoFontEngine.h: Back out type3 font work committed by + accident. + + ChangeLog | 6 + + poppler/CairoFontEngine.cc | 347 + +++++---------------------------------------- + poppler/CairoFontEngine.h | 17 +-- + 3 files changed, 47 insertions(+), 323 deletions(-) + +commit 7d4bb0533f88f06449ebd64c1220d0b75001937d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 21 18:14:15 2006 +0000 + + fix all is blue issue on ppc machines + + ChangeLog | 7 +++++++ + qt/poppler-page.cc | 17 +++++++++++++++++ + qt4/src/poppler-page.cc | 17 +++++++++++++++++ + 3 files changed, 41 insertions(+) + +commit 655af1e0126ca96d75c9c718d7d8f928c898b1f6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 21 17:19:53 2006 +0000 + + hope to fix really Kouhei's name now + + ChangeLog | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +commit cc783a1ebe868ff75db5472775dabe0020ae501f +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 21 11:54:30 2006 +0000 + + Fix Kouhei name + + ChangeLog | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e4b6ad3bb873a6f334934921e6d56e9d26e06a9a +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri May 19 22:55:49 2006 +0000 + + Add bug number to ChangeLog entry. + + ChangeLog | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 46f5f070cceb2c0f3b53537c8e33340b9f1bba38 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri May 19 22:26:03 2006 +0000 + + 2006-05-19 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-action.h: + * glib/poppler-action.cc: Add poppler_dest_get_type(), patch from + Kouhei Souto (#6907). + + ChangeLog | 4 ++++ + glib/poppler-action.cc | 13 +++++++++++++ + glib/poppler-action.h | 4 ++++ + 3 files changed, 21 insertions(+) + +commit 875dc5b112dfe2d4a48a7567b1ff79257447cc0d +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri May 19 22:21:35 2006 +0000 + + 2006-05-19 Kristian Høgsberg <krh@redhat.com> + + * poppler-glib.pc.in (Requires): Add gdk-2.0 dependency, from + Kouhei Souto (#6896). + + ChangeLog | 3 +++ + poppler-glib.pc.in | 2 +- + 2 files changed, 4 insertions(+), 1 deletion(-) + +commit b66dda2640c088bbe205f698a0c4028144027922 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri May 19 22:19:21 2006 +0000 + + 2006-05-19 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-document.h (POPPLER_TYPE_INDEX_ITER) + (POPPLER_TYPE_FONTS_ITER): Add these macros, patch from Kouhei + Souto (#6897). + + ChangeLog | 4 ++++ + glib/poppler-document.h | 2 ++ + 2 files changed, 6 insertions(+) + +commit 095730456c0d8312067af10dd55a3b9165a83736 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri May 19 22:16:25 2006 +0000 + + 2006-05-19 Kristian Høgsberg <krh@redhat.com> + + * glib/Makefile.am (INCLUDES): Add define for G_LOG_DOMAIN, from + Kouhei Souto (#6899). + + ChangeLog | 3 +++ + glib/Makefile.am | 1 + + 2 files changed, 4 insertions(+) + +commit b8d77633899c1dec5f3b9c9a0f075f39afa98965 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri May 19 22:12:38 2006 +0000 + + 2006-05-19 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-document.cc (poppler_document_save): Memleak patch + from Paolo Borelli (#6908). + + ChangeLog | 5 +++++ + glib/poppler-document.cc | 2 ++ + 2 files changed, 7 insertions(+) + +commit 488f77298fee9eebbca5983c1c9fb186b3b67aa3 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri May 19 22:04:17 2006 +0000 + + 2006-05-19 Kristian Høgsberg <krh@redhat.com> + + * TextOutputDev.h: + * TextOutputDev.cc: + * UnicodeTypeTable.h: + * UnicodeTypeTable.cc: + * UnicodeCClassTables.h: + * UnicodeCompTables.h: + * UnicodeDecompTables.h: + * gen-unicode-tables.py: Patch from Ed Catmur (#2929) to convert + search string and document text to unicode NFKC (compatibility + composition) before matching so ligatures match correctly. + + ChangeLog | 13 + + poppler/Makefile.am | 5 + + poppler/TextOutputDev.cc | 41 +- + poppler/TextOutputDev.h | 3 + + poppler/UnicodeCClassTables.h | 1827 +++++++++ + poppler/UnicodeCompTables.h | 665 ++++ + poppler/UnicodeDecompTables.h | 8526 + +++++++++++++++++++++++++++++++++++++++++ + poppler/UnicodeTypeTable.cc | 235 ++ + poppler/UnicodeTypeTable.h | 3 + + 9 files changed, 11303 insertions(+), 15 deletions(-) + +commit ecb942e54a1ab0f7eded91b7d1278f0ac62e2071 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri May 19 21:42:54 2006 +0000 + + 2006-05-19 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc (poppler_page_prepare_output_dev): Fix the + rotation bug for real. + + ChangeLog | 5 +++++ + glib/poppler-page.cc | 16 +++++++++------- + 2 files changed, 14 insertions(+), 7 deletions(-) + +commit 28ae789afe0625a641525e4a0768d51fa8bd667c +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri May 19 20:54:13 2006 +0000 + + 2006-05-19 Kristian Høgsberg <krh@redhat.com> + + Patch from Kouhei Sutou (#6905). + + * glib/poppler-document.cc: + * glib/poppler-document.h: + * glib/poppler-private.h: + * glib/reference/tmpl/poppler-private.sgml: + * glib/reference/tmpl/poppler.sgml: Make PopplerPSOutput a proper + glib object. + + ChangeLog | 11 +++++++ + glib/poppler-document.cc | 51 + ++++++++++++++++++++++++++------ + glib/poppler-document.h | 4 +++ + glib/poppler-private.h | 2 ++ + glib/reference/tmpl/poppler-private.sgml | 1 + + glib/reference/tmpl/poppler.sgml | 1 + + 6 files changed, 61 insertions(+), 9 deletions(-) + +commit 02cf7fd7df0b2d8c2b1c6f108e581bc1c7a973b1 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri May 19 20:35:43 2006 +0000 + + 2006-05-19 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc (poppler_page_prepare_output_dev): Fix + rotation bug (#6913, #6926). + + ChangeLog | 3 +++ + glib/poppler-page.cc | 12 +++++++++++- + 2 files changed, 14 insertions(+), 1 deletion(-) + +commit 78ae3efd9541d7b63ff5a2c4de3fde300806688f +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri May 19 19:21:59 2006 +0000 + + 2006-05-19 Kristian Høgsberg <krh@redhat.com> + + Memory leak patch from Carlos Garcia Campos (#6947). + + * glib/poppler-action.cc: + * glib/poppler-document.cc: + * glib/poppler-page.cc: + * poppler/CairoFontEngine.cc: + * poppler/CairoFontEngine.h: + * poppler/CairoOutputDev.cc: + * poppler/CairoOutputDev.h: + * poppler/Gfx.cc: + * poppler/TextOutputDev.cc: Fix various memory leaks. + + ChangeLog | 14 ++ + glib/poppler-action.cc | 9 +- + glib/poppler-document.cc | 31 +++- + glib/poppler-page.cc | 2 + + poppler/CairoFontEngine.cc | 347 + ++++++++++++++++++++++++++++++++++++++++----- + poppler/CairoFontEngine.h | 17 ++- + poppler/CairoOutputDev.cc | 5 +- + poppler/CairoOutputDev.h | 2 +- + poppler/Gfx.cc | 1 + + poppler/TextOutputDev.cc | 9 ++ + 10 files changed, 381 insertions(+), 56 deletions(-) + +commit 354c1926b7181fd668f221e1d672974e04fda747 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 19 17:24:19 2006 +0000 + + * qt4/src/poppler-link.cc: Patch by Pino Toscano, ensure the + splashoutput is created when parsing the TOC. + + ChangeLog | 5 +++++ + qt4/src/poppler-link.cc | 5 +++-- + 2 files changed, 8 insertions(+), 2 deletions(-) + +commit 3c9a5f37704781c9a51e72edd18451870452b9a7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 14 16:11:54 2006 +0000 + + * poppler/FontInfo.cc: Fix possible crash, half patch + by Kouhei Sutou <kou@cozmixng.org> + + ChangeLog | 5 +++++ + poppler/FontInfo.cc | 4 ++-- + 2 files changed, 7 insertions(+), 2 deletions(-) + +commit 436f578fe762e8ceccce95a0f2003406527dde64 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat May 13 16:01:57 2006 +0000 + + * poppler/GfxState.cc: + * poppler/GfxState.h: Fix memleak, patch by + Carlos Garcia Campos <carlosgc@gnome.org> + + ChangeLog | 6 ++++++ + poppler/GfxState.cc | 8 ++++++++ + poppler/GfxState.h | 3 +-- + 3 files changed, 15 insertions(+), 2 deletions(-) + +commit 906515769097f2e38f6b2c2aff598919b9d1ee0d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat May 13 15:58:37 2006 +0000 + + * qt4/src/poppler-document.cc: leak-- + * qt4/src/poppler-private.h: Refcount globalparams + * qt4/tests/test-poppler-qt4.cpp: Some leaks less + + ChangeLog | 6 ++++++ + qt4/src/poppler-document.cc | 10 +++++----- + qt4/src/poppler-private.h | 8 ++++++++ + qt4/tests/test-poppler-qt4.cpp | 6 ++++-- + 4 files changed, 23 insertions(+), 7 deletions(-) + +commit 46fd63c44369c882d8dac473d4156001d9d4ed18 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat May 13 11:14:24 2006 +0000 + + numbers for easier casting + + qt4/src/poppler-link.h | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +commit 35500375e3f790c444ab7e7d0a687d270c5a66b1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 12 21:02:01 2006 +0000 + + fixing compile problems for some people + + qt4/src/poppler-page.cc | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 181f09829cf4831965059e3064114d83348c51b5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 12 20:40:05 2006 +0000 + + * qt4/src/Makefile.am + * qt4/src/poppler-annotation-helper.h + * qt4/src/poppler-annotation.cc + * qt4/src/poppler-annotation.h + * qt4/src/poppler-link.cc + * qt4/src/poppler-link.h + * qt4/src/poppler-page.cc + * qt4/src/poppler-qt4.h: Code for annotations stripped + from oKular, + it's all based on Enrico's work, so ask him for details, + the problem + is that he left KDE development a while ago. + + ChangeLog | 14 + + qt4/src/Makefile.am | 2 + + qt4/src/poppler-annotation-helper.h | 213 ++++++++++ + qt4/src/poppler-annotation.cc | 792 + ++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-annotation.h | 257 ++++++++++++ + qt4/src/poppler-link.cc | 4 +- + qt4/src/poppler-link.h | 2 +- + qt4/src/poppler-page.cc | 691 +++++++++++++++++++++++++++++++ + qt4/src/poppler-qt4.h | 8 +- + 9 files changed, 1980 insertions(+), 3 deletions(-) + +commit 3a48e89dfbe54af73a68ed8e917938f14ad17f01 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 9 20:07:06 2006 +0000 + + * qt4/src/Makefile.am: + * qt4/src/poppler-document.cc: + * qt4/src/poppler-link.cc: + * qt4/src/poppler-page.cc: + * qt4/src/poppler-private.h: + * qt4/src/poppler-qt4.h: Adding links extraction code, + should work as + it is basically stripped out from kpdf, but comments are + obviously welcome as always + + ChangeLog | 10 +++ + qt4/src/Makefile.am | 1 + + qt4/src/poppler-document.cc | 13 +--- + qt4/src/poppler-link.cc | 129 ++++++++++++++++++++++++++++++-- + qt4/src/poppler-link.h | 178 + ++++++++++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-page.cc | 139 ++++++++++++++++++++++++++++++---- + qt4/src/poppler-private.h | 9 ++- + qt4/src/poppler-qt4.h | 56 +++----------- + 8 files changed, 456 insertions(+), 79 deletions(-) + +commit f628e1506e576a8553a9699c1d7f05ef55c24fa2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 8 19:03:51 2006 +0000 + + memleak-- by carlos + + ChangeLog | 5 +++++ + poppler/Catalog.cc | 5 ++++- + 2 files changed, 9 insertions(+), 1 deletion(-) + +commit 1fce6266564583d356817a21f43c6b1ad8ce3716 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat May 6 10:57:07 2006 +0000 + + fix code, i suck + + qt4/src/poppler-page.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit be913b90d59da35a347498b86fdd3edb065aef23 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 5 20:51:01 2006 +0000 + + * poppler/Function.cc: quick fix for KDE bug #126760 + + Better solutions are of course accepted + + ChangeLog | 4 ++++ + poppler/Function.cc | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +commit 2b085293bd73b4e77da848b3fe63a7e82e9ba5e5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 4 19:10:55 2006 +0000 + + * qt4/src/poppler-qt4.h: + * qt4/src/poppler-page.cc: Implement search functionality + + more code to make oKular qt4popplered possible, probably not most + quickest code around, feel free to comment/optimize + + ChangeLog | 5 +++++ + qt4/src/poppler-page.cc | 43 +++++++++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-qt4.h | 16 ++++++++++++++++ + 3 files changed, 64 insertions(+) + +commit a9b0c7977aba7bc85a8673c7f95187ff17ee4173 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue May 2 04:38:39 2006 +0000 + + 2006-05-02 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc: + * poppler/Gfx.cc: + * poppler/GfxFont.cc: + * poppler/GfxFont.h: + * poppler/GfxState.cc: + * poppler/TextOutputDev.cc: Patch from Gary Coady to add reference + counting to GfxFont so we don't crash on text selection. + + ChangeLog | 10 ++++++++++ + glib/poppler-page.cc | 2 +- + poppler/Gfx.cc | 2 ++ + poppler/GfxFont.cc | 14 +++++++++++++- + poppler/GfxFont.h | 4 ++++ + poppler/GfxState.cc | 7 +++++++ + poppler/TextOutputDev.cc | 1 + + 7 files changed, 38 insertions(+), 2 deletions(-) + +commit 57af0207334ff1a407899370281ebb90fe953a32 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 1 18:33:47 2006 +0000 + + * qt4/src/poppler-page.cc: + * qt4/src/poppler-private.h: + * qt4/src/poppler-qt4.h: + * qt4/src/poppler-textbox.cc: Add nextWord(), hasSpaceAfter() + and + edge() to TextBox + + More things to make poppler-qt4Okular nearer + + ChangeLog | 8 ++++++++ + qt4/src/poppler-page.cc | 14 ++++++++++++++ + qt4/src/poppler-private.h | 11 +++++++++++ + qt4/src/poppler-qt4.h | 8 ++++++++ + qt4/src/poppler-textbox.cc | 23 ++++++++++++++++------- + 5 files changed, 57 insertions(+), 7 deletions(-) + +commit 61b126390f764fd38c79b6a64160a7dc7870bd4a +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 1 13:41:14 2006 +0000 + + revert thing that should not have gone in + + poppler/PageLabelInfo.cc | 43 +++++++++++++++++++++++++++++++++++++++++++ + poppler/PageLabelInfo.h | 44 + -------------------------------------------- + 2 files changed, 43 insertions(+), 44 deletions(-) + +commit f2424ef63e86d82b2be277e2b268b48aae29601e +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 1 13:32:31 2006 +0000 + + * qt4/src/poppler-document.cc: + * qt4/src/poppler-private.h: + * qt4/src/poppler-qt4.h: Add the possibility of setting + the paper + color + + One step more to make oKular fully use the qt4 bindings + + ChangeLog | 7 +++++++ + poppler/PageLabelInfo.cc | 43 + ------------------------------------------- + poppler/PageLabelInfo.h | 44 + ++++++++++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-document.cc | 10 ++++++++++ + qt4/src/poppler-private.h | 22 +++++++++++++++++----- + qt4/src/poppler-qt4.h | 6 ++++++ + 6 files changed, 84 insertions(+), 48 deletions(-) + +commit 4147400e2b692df7f70c3772e8a4b576d4d85294 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 29 15:23:41 2006 +0000 + + Fix memory leak. Bug 6765 + + ChangeLog | 5 +++++ + poppler/JBIG2Stream.cc | 1 + + 2 files changed, 6 insertions(+) + +commit 960d60467d62d28f20b127d07e8de1af42eec568 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Thu Apr 27 17:26:36 2006 +0000 + + 2006-04-27 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: delete imgStr if some of the cairo + functions fail. Fixes coverty reports #2106, #2107, #2077 and + bug #6764. Patch by Kjartan Maraas. + + ChangeLog | 6 ++++++ + poppler/CairoOutputDev.cc | 34 +++++++++++++++++++++++++--------- + 2 files changed, 31 insertions(+), 9 deletions(-) + +commit 155112131c6e25bfde752cf5daa80a6c9712cfed +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 23 15:50:52 2006 +0000 + + qt4/src/poppler-private.h: Protect us against a link not having + a destination or a namedDestination + + ChangeLog | 5 +++++ + qt4/src/poppler-private.h | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit c902a3a22bcceedc8ee8ca377064efcc8a9178ca +Author: Brad Hards <bradh@frogmouth.net> +Date: Fri Apr 21 12:02:19 2006 +0000 + + Add another path to search for Qt4 libs and includes. + + CCMAIL: montel@kde.org + + m4/qt.m4 | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 18f8e1f1d213dbcda27cd0ec429273801f65e208 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 18 19:11:56 2006 +0000 + + * goo/GooVector.h: Fix typo that was preventing build with MSVC8 + Discovered by Reece Dunn <msclrhd@hotmail.com> + + ChangeLog | 5 +++++ + goo/GooVector.h | 4 ++-- + 2 files changed, 7 insertions(+), 2 deletions(-) + +commit cbbb28a5959343d20dffe945ea83272c0b2e287b +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sun Apr 16 22:59:44 2006 +0000 + + 2006-04-16 Carlos Garcia Campos <carlosgc@gnome.org> + + * glib/poppler-action.cc: + * glib/poppler-action.h: + * glib/poppler-private.h: + * glib/poppler.h: + Add support for named destinations and named actions. + + * glib/poppler-document.cc: + * glib/poppler-document.h: + Allow to find named destinations in document. + + ChangeLog | 12 +++ + glib/poppler-action.cc | 152 + +++++++++++++++++++++++++----- + glib/poppler-action.h | 7 +- + glib/poppler-document.cc | 37 ++++++++ + glib/poppler-document.h | 4 +- + glib/poppler-private.h | 2 + + glib/poppler.h | 1 + + glib/reference/tmpl/poppler-action.sgml | 2 + + glib/reference/tmpl/poppler-document.sgml | 4 - + 9 files changed, 189 insertions(+), 32 deletions(-) + +commit 85687a1e0e4c6be2dbfb23ba00018b9c7c7454f5 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed Apr 12 06:52:07 2006 +0000 + + 2006-04-12 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: + * poppler/CairoOutputDev.h: Add support for masked images to + the cairo + backend. CairoOutputDevice really should have been refactored + before + committing this, but the results were so pretty I couldn't resist. + Fixes #6174. + + ChangeLog | 8 ++++ + poppler/CairoOutputDev.cc | 118 + ++++++++++++++++++++++++++++++++++++++++++++++ + poppler/CairoOutputDev.h | 8 ++++ + 3 files changed, 134 insertions(+) + +commit 6039d4fc65cb25bef20efa29bc29d42086fc0854 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed Apr 12 05:46:44 2006 +0000 + + 2006-04-12 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: Fix breakage by krh by only calling + cairo_destroy on non-null. + + ChangeLog | 5 +++++ + poppler/CairoOutputDev.cc | 4 +++- + 2 files changed, 8 insertions(+), 1 deletion(-) + +commit d839a0bd78361930e5e2fe889df12e1e853ffed3 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed Apr 12 02:07:07 2006 +0000 + + 2006-04-11 Kristian Høgsberg <krh@redhat.com> + + * configure.ac: + * poppler-glib.pc.in: + * glib/Makefile.am: + * glib/poppler-page.cc: + * glib/poppler-page.h: + * glib/poppler.h: + * poppler/CairoOutputDev.cc: + * poppler/CairoOutputDev.h: + * glib/poppler-features.h.in: + Make the CairoOutputDev render to a cairo_t instead of a + cairo_surface_t and expose that functionality in the glib wrapper + (poppler_page_render). + + * test/Makefile.am: + * test/gtk-cairo-test.cc: + Update gtk-cairo-test to use this new interface and add a spin + button for changing page (#5951). + + * utils/Makefile.am (EXTRA_DIST): Fix warning where this was + assigned twice. + + ChangeLog | 23 ++++ + configure.ac | 8 ++ + glib/Makefile.am | 10 +- + glib/poppler-features.h.in | 24 ++++ + glib/poppler-page.cc | 63 +++++++--- + glib/poppler-page.h | 10 ++ + glib/poppler.h | 1 + + poppler-glib.pc.in | 2 +- + poppler/CairoOutputDev.cc | 23 ++-- + poppler/CairoOutputDev.h | 6 +- + test/Makefile.am | 4 +- + test/gtk-cairo-test.cc | 286 + ++++++++++++++------------------------------- + utils/Makefile.am | 6 +- + 13 files changed, 221 insertions(+), 245 deletions(-) + +commit b198c9801c668014c0979c57033a0637e7e046e2 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Mon Apr 10 18:12:44 2006 +0000 + + 2006-04-10 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: take originX and originY into + account in + drawChar() to draw vertical text properly. Fixes #6551. + + ChangeLog | 5 +++++ + poppler/CairoOutputDev.cc | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit fd251f52efc7748fda91cc77fb9d3966e0f02ac8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 9 11:05:51 2006 +0000 + + m4/qt.m4: Improve for systems that need -pthread to be linked when + linking Qt. Patch by Diego Pettenò + + ChangeLog | 5 +++++ + m4/qt.m4 | 28 +++++++++++++++++++++++++++- + 2 files changed, 32 insertions(+), 1 deletion(-) + +commit 36de9747153a2ea9b3cf86c41e75a521441a2e06 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 8 10:44:43 2006 +0000 + + * poppler/Makefile.am: + * qt4/src/Makefile.am: Don't link Qt4 in libpoppler when using + Qt4 frontend + Patch by Stefan Schweizer + + ChangeLog | 6 ++++++ + poppler/Makefile.am | 11 +++++------ + qt4/src/Makefile.am | 1 + + 3 files changed, 12 insertions(+), 6 deletions(-) + +commit bf7afe161d76c50fd1c480eb236607145782e59d +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Apr 5 18:20:56 2006 +0000 + + poppler/JBIG2Stream.cc: Fix for some buggy JBIG2 documents, patch + by Raj Kumar and Paul Walmsley. Fixes bug 6500 + + ChangeLog | 5 +++++ + poppler/JBIG2Stream.cc | 43 +++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 48 insertions(+) + +commit 315f8e488d3db848f88a06c7568b6583bbf0e432 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed Apr 5 17:20:56 2006 +0000 + + 2006-04-05 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: use a separate matrix for the + softmask. + fixes #6492. + + ChangeLog | 5 +++++ + poppler/CairoOutputDev.cc | 11 ++++++++++- + 2 files changed, 15 insertions(+), 1 deletion(-) + +commit 0d311518f678a479c1efeaec15011e0a34de80fc +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 4 21:01:01 2006 +0000 + + * splash/Splash.cc: + * splash/SplashBitmap.cc: Make Splashbitmap RGB8 use 32bits + internally + * qt/poppler-page.cc: + * qt4/src/poppler-page.cc: Adapt to splashbitmap change so + copying to + QImage is faster. + Patch by Frank Meerkötter slightly modified by Albert + Astals Cid + + I'll leave adapting the glib frontend for you guys, i tried to adapt + it but i got lost at gdk_pixbuf_get_n_channels (pixbuf); + + ChangeLog | 9 ++++++ + qt/poppler-page.cc | 18 ++++------- + qt4/src/poppler-page.cc | 15 ++++----- + splash/Splash.cc | 81 + +++++++++++++++++++++++++------------------------ + splash/SplashBitmap.cc | 10 +++--- + 5 files changed, 67 insertions(+), 66 deletions(-) + +commit 888bd41b42507f0a1af55c55495d31d802ce7706 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 4 20:42:08 2006 +0000 + + Fix crash when using fixedpoint math. Patch by Frank Meerkoetter + + ChangeLog | 5 +++++ + splash/SplashFTFont.cc | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit 56c98450160b639790931226a045ce4712e7d45e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Apr 2 18:07:59 2006 +0000 + + Improvements to the Qt4 frontend, comments welcome + + ChangeLog | 7 +++ + m4/qt.m4 | 4 +- + qt4/src/Makefile.am | 1 + + qt4/src/poppler-document.cc | 85 +++++++++++++++++++++------ + qt4/src/poppler-link.cc | 138 + ++++++++++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-page.cc | 9 ++- + qt4/src/poppler-private.h | 95 +++++++++++++++++++++++++++++- + qt4/src/poppler-qt4.h | 86 ++++++++++++++++++++++++--- + 8 files changed, 395 insertions(+), 30 deletions(-) + +commit c80ebf237e9c6232a1d0567a2688a294acfd481b +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Apr 1 11:25:57 2006 +0000 + + Fix bug 6454 + + ChangeLog | 5 +++++ + poppler/XRef.cc | 22 +++++++++++++--------- + 2 files changed, 18 insertions(+), 9 deletions(-) + +commit fe8142fbc12127682b8024673fe1af57b47bb5c9 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Tue Mar 21 04:25:53 2006 +0000 + + 2006-03-20 Jeff Muizelaar <jeff@infidigm.net> + + * glib/poppler-page.cc: Avoid strdup in poppler_page_get_property + and + make code cleaner. Combined with the memleak fix closes #6187. + Patch by chpe. + + ChangeLog | 6 ++++++ + glib/poppler-page.cc | 5 +---- + 2 files changed, 7 insertions(+), 4 deletions(-) + +commit 4f961df2e6e91a0dc0a024ae5acdefa394179a05 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Tue Mar 21 04:19:18 2006 +0000 + + 2006-03-20 Jeff Muizelaar <jeff@infidigm.net> + + * glib/poppler-page.cc: Fix memory leak in poppler_page_get_text + Patch by chpe. + + ChangeLog | 5 +++++ + glib/poppler-page.cc | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit ff4febab0a519732972c21bf76d7693c98265e0f +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 20 20:07:36 2006 +0000 + + Use UGooString for dates, fixes KDE bug 123938 + + ChangeLog | 6 ++++++ + qt/poppler-document.cc | 2 +- + qt4/src/poppler-document.cc | 2 +- + 3 files changed, 8 insertions(+), 2 deletions(-) + +commit 75ac6de8cd651b1cbe2d6a7ffa4574097088041f +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Mon Mar 20 19:12:29 2006 +0000 + + 2006-03-20 Carlos Garcia Campos <calosgc@gnome.org> + + reviewed by: Jeff Muizelaar <jeff@infidigm.net> + + * glib/poppler-document.cc: Fix memory leak in + poppler_font_info_free + + ChangeLog | 6 ++++++ + glib/poppler-document.cc | 2 +- + 2 files changed, 7 insertions(+), 1 deletion(-) + +commit 784f6d9a0888dab34c586ffe14db8e55b8a11f51 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Mon Mar 20 19:02:10 2006 +0000 + + 2006-03-20 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoFontEngine.h: remove unused variables + + ChangeLog | 4 ++++ + poppler/CairoFontEngine.h | 1 - + 2 files changed, 4 insertions(+), 1 deletion(-) + +commit 847436779d7c82b428acfd6339130228bfadca24 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Mar 19 19:19:42 2006 +0000 + + fix date + + ChangeLog | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 401bae69cc7ade676cacd89b483f0a93a653c7a1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Mar 19 17:01:05 2006 +0000 + + fix htmloutputdev + + ChangeLog | 4 ++++ + utils/HtmlOutputDev.cc | 2 +- + utils/HtmlOutputDev.h | 2 +- + 3 files changed, 6 insertions(+), 2 deletions(-) + +commit d56330e688c0a40b4e206ed3bbddd06d7f3ee66c +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 16 22:04:56 2006 +0000 + + * poppler/Page.cc: Remove a #ifdef that was never defined + (nice to + have so sucky W args), probably came from gpdf (it's not + on xpdf + sources) and was causing bugs 6079 and 6167 + + Might be worth backporting to the stable branch + + ChangeLog | 8 +++++++- + poppler/Page.cc | 2 -- + 2 files changed, 7 insertions(+), 3 deletions(-) + +commit 7ed6737b00ece7ca00cee1d148752b11700370e6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 16 19:21:11 2006 +0000 + + poppler/FontInfo.cc: Embedded fonts don't have a font file + + ChangeLog | 4 ++++ + poppler/FontInfo.cc | 20 ++++++++++++-------- + 2 files changed, 16 insertions(+), 8 deletions(-) + +commit a34688ee29e1cdfcbaca232cf005af55af87f796 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Mar 14 19:34:10 2006 +0000 + + * qt4/src/poppler-qt4.h: Fix compilation with gcc4.1, patch by + Michael Olbrich + + ChangeLog | 5 +++++ + qt4/src/poppler-qt4.h | 10 +++++----- + 2 files changed, 10 insertions(+), 5 deletions(-) + +commit 1a90b3aaf6be4ca3ebb47e904842b1e14a0e8dfc +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Mar 11 15:19:02 2006 +0000 + + * poppler/FontInfo.cc: + * poppler/FontInfo.h: Add getFile() function that returns + the path of the font that is beign used in the system to + represent that font + * qt4/src/poppler-document.cc: + * qt4/src/poppler-fontinfo.cc: + * qt4/src/poppler-private.h: + * qt4/src/poppler-qt4.h: Add the file() function + * qt4/tests/poppler-fonts.cpp: Show the path of the font + used to represent each font + + May be interesting to have in the other frontends + + ChangeLog | 13 +++++++++++++ + poppler/FontInfo.cc | 10 ++++++++++ + poppler/FontInfo.h | 2 ++ + qt4/src/poppler-document.cc | 14 +------------- + qt4/src/poppler-fontinfo.cc | 29 +++++++++-------------------- + qt4/src/poppler-private.h | 29 +++++++++++++++++++++++++++++ + qt4/src/poppler-qt4.h | 8 ++++++-- + qt4/tests/poppler-fonts.cpp | 5 +++-- + 8 files changed, 73 insertions(+), 37 deletions(-) + +commit 22b1618185ec70895ec644d9e590c266ff98c9db +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 9 21:56:07 2006 +0000 + + Build with cairo disabled, patch by Eduardo de Barros Lima + + ChangeLog | 5 +++++ + glib/Makefile.am | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit 50ecfadab36a9769b09e4c2c1670d86448a0e1ee +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue Feb 28 23:24:59 2006 +0000 + + 2006-02-28 Kristian Høgsberg <krh@redhat.com> + + * configure.ac: Bump release to 0.5.1. + + * NEWS: Sum up 0.5.1 changes so far. + + * TextOutputDev.h: add getters for a couple of attributes. + + * glib/Makefile.am: + * poppler/Makefile.am: Move cairo link dependency to glib + bindings. + + ChangeLog | 11 +++++++++++ + NEWS | 10 ++++++++++ + configure.ac | 2 +- + glib/Makefile.am | 11 ++++++----- + poppler/Makefile.am | 19 ++++++++----------- + poppler/TextOutputDev.h | 7 +++++-- + qt/Makefile.am | 1 + + test/Makefile.am | 16 +++++++++------- + utils/Makefile.am | 29 +++++++++++++++++------------ + 9 files changed, 68 insertions(+), 38 deletions(-) + +commit b9e951ac68b9977ab7217ad0346bcf46a3fa3dfe +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue Feb 28 19:59:58 2006 +0000 + + 2006-02-28 Kristian Høgsberg <krh@redhat.com> + + * goo/gmem.c: (gmalloc), (grealloc): + * poppler/JBIG2Stream.cc: + * poppler/Stream.cc: + * poppler/Stream.h: + * splash/SplashXPathScanner.cc: + + More integer overflow fixes from Derek Noonburg (#5922). + + ChangeLog | 10 ++++++++++ + goo/gmem.c | 9 +++++---- + poppler/JBIG2Stream.cc | 12 ++++++++++-- + poppler/Stream.cc | 7 +++++++ + poppler/Stream.h | 2 +- + 5 files changed, 33 insertions(+), 7 deletions(-) + +commit 46db73a142d65a0c944910388d5971debc06ecbf +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue Feb 28 18:31:59 2006 +0000 + + 2006-02-28 Kristian Høgsberg <krh@redhat.com> + + * poppler/PSOutputDev.cc: Make PSOutputDev constructor respect + passed in paper size (#5946, #5749). + + ChangeLog | 5 +++++ + poppler/PSOutputDev.cc | 14 ++++++++------ + 2 files changed, 13 insertions(+), 6 deletions(-) + +commit 0f7f2182b2abe965b382937f5569b65a8828fc93 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue Feb 28 18:25:00 2006 +0000 + + 2006-02-28 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-document.cc (info_dict_get_string): Refactor + _popper_goo_string_to_utf8() out into it's own function. + + * glib/poppler-page.cc (poppler_page_get_property): Use + _popper_goo_string_to_utf8() here to convert ucs2 page labels. + + * glib/poppler-page.cc (poppler_page_get_selection_region): + Add + braces to fix warning. + + * poppler/PageLabelInfo.cc: If the label prefix string has + a ucs2 + marker, append the number part of the label as ucs2 (#5952). + + ChangeLog | 14 +++ + glib/poppler-document.cc | 52 +++++------ + glib/poppler-page.cc | 23 +++-- + glib/poppler-private.h | 3 + + glib/reference/tmpl/poppler-enums.sgml | 150 + -------------------------------- + glib/reference/tmpl/poppler-unused.sgml | 130 +++++++++++++++++++++++++++ + glib/test-poppler-glib.c | 2 +- + goo/GooString.cc | 5 ++ + goo/GooString.h | 4 + + poppler/PageLabelInfo.cc | 39 ++++++--- + poppler/PageLabelInfo.h | 2 +- + 11 files changed, 228 insertions(+), 196 deletions(-) + +commit 1bf83cdc8b75e1c76956ae643ee273e0b558fd08 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 25 12:30:30 2006 +0000 + + fix warning + + ChangeLog | 4 ++++ + poppler/Object.cc | 3 ++- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit eb5642f396c8772c83b2cf27da437413b692c952 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Feb 23 22:26:05 2006 +0000 + + Don't build pdftoppm when splashoutput is disabled as it does not link + + ChangeLog | 5 +++++ + utils/Makefile.am | 13 +++++++++++-- + 2 files changed, 16 insertions(+), 2 deletions(-) + +commit 7c5c1361045429a429a6f40d936f8c7c01fe0d07 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sat Feb 18 20:17:00 2006 +0000 + + 2006-02-18 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: + * poppler/CairoOutputDev.h: + * poppler/GfxState.cc: + * poppler/GfxState.h: Add support for drawSoftMaskedImage to + CairoOutputDev. Ugly but works. + + ChangeLog | 8 ++++ + poppler/CairoOutputDev.cc | 101 + ++++++++++++++++++++++++++++++++++++++++++++++ + poppler/CairoOutputDev.h | 6 +++ + poppler/GfxState.cc | 50 +++++++++++++++++++++++ + poppler/GfxState.h | 2 + + 5 files changed, 167 insertions(+) + +commit dcb748f68112bd5f99fea8a3da06666be6cff0c5 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Thu Feb 16 19:41:17 2006 +0000 + + 2006-02-16 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: Work around cairo bug when scaling + 1x1 bitmaps. Fixes #3387. Also gives a performance improvement. + + ChangeLog | 5 +++++ + poppler/CairoOutputDev.cc | 33 ++++++++++++++++++++++++--------- + 2 files changed, 29 insertions(+), 9 deletions(-) + +commit ef1070f6ca2d1e74c5f94728f3aaae22f0990c17 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Feb 16 19:28:54 2006 +0000 + + Update soname + + ChangeLog | 8 ++++++++ + glib/Makefile.am | 2 ++ + poppler/Makefile.am | 2 ++ + qt/Makefile.am | 2 ++ + qt4/src/Makefile.am | 2 ++ + 5 files changed, 16 insertions(+) + +commit 24b9f5c33fb00ff80a79b34444282a57288f636c +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Feb 13 23:04:54 2006 +0000 + + * poppler/ArthurOutputDev.cc: Make it compile after changing code + so we did not pass files to freetype but buffers + + ChangeLog | 5 +++++ + poppler/ArthurOutputDev.cc | 53 + +++++++++++++++++----------------------------- + 2 files changed, 24 insertions(+), 34 deletions(-) + +commit 0bda90310b267d3a4963096293eb2bd29b120768 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Feb 13 22:38:44 2006 +0000 + + Probably the last of inner patches missing from kpdf + Everybody will we happy now, kpdf has been finally assimilated + + ChangeLog | 5 ++ + poppler/PSOutputDev.cc | 124 + +++++++++++++++++++++++++++++++++++++++++++++---- + poppler/PSOutputDev.h | 4 +- + 3 files changed, 123 insertions(+), 10 deletions(-) + +commit cf9867fbbee2468a955b5845016585eeedf2debe +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Feb 6 20:49:21 2006 +0000 + + Various fixes from Frank Meerkötter to enable fixedpoint arithmetic + + ChangeLog | 8 ++++++++ + configure.ac | 2 +- + goo/FixedPoint.h | 2 +- + splash/Splash.cc | 4 ++-- + splash/SplashTypes.h | 2 +- + 5 files changed, 13 insertions(+), 5 deletions(-) + +commit f04e2c4f20f821ff8cb9465a715ccbb22091d449 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Feb 6 18:50:10 2006 +0000 + + Jeff Muizelaar's improvements to my yesterday's small patches + + ChangeLog | 6 ++++++ + poppler/Annot.cc | 9 ++++----- + poppler/JBIG2Stream.cc | 2 +- + 3 files changed, 11 insertions(+), 6 deletions(-) + +commit 33e98f81cdfda0935ac7ea79a691976465ec790b +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 5 15:46:10 2006 +0000 + + Some small fixes from kpdf + + ChangeLog | 8 ++++++++ + poppler/Gfx.cc | 1 + + poppler/GfxFont.cc | 1 + + poppler/JBIG2Stream.cc | 2 +- + poppler/SplashOutputDev.cc | 1 - + 5 files changed, 11 insertions(+), 2 deletions(-) + +commit 6d9e6489d24b3105204ff4233f6493136e9b5715 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sat Feb 4 21:10:41 2006 +0000 + + 2006-02-04 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/Gfx.cc: + * poppler/OutputDev.cc: + * poppler/OutputDev.h: Let output devices know about pdf grouping + operators. + Patch by Thorkild Stray. + + ChangeLog | 8 ++++++++ + poppler/Gfx.cc | 14 ++++++++++++++ + poppler/OutputDev.cc | 16 ++++++++++++++++ + poppler/OutputDev.h | 10 ++++++++++ + 4 files changed, 48 insertions(+) + +commit b4e34d905cd0ca5815a450de35b4c2774f4887c9 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sat Feb 4 20:48:25 2006 +0000 + + 2006-02-04 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/GlobalParams.cc: Check all fonts returned by fontconfig. + Discard the ones that are not truetype or type1. Fixes #5758. + Patch by Ed Catmur. + + ChangeLog | 6 ++++++ + poppler/GlobalParams.cc | 51 + +++++++++++++++++++++++++++---------------------- + 2 files changed, 34 insertions(+), 23 deletions(-) + +commit fd85a0afdd7b4cafc68df400d4f94fccaea18c76 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 4 20:34:13 2006 +0000 + + Remove bug from "do not use an external file to pass fonts to + Freetype" patch, patch by Stefan Schweizer + + ChangeLog | 3 +++ + poppler/SplashOutputDev.cc | 14 ++++++++++---- + 2 files changed, 13 insertions(+), 4 deletions(-) + +commit 67ca9d01f8badcf542f60b23521c384c9840ca1b +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 4 20:31:00 2006 +0000 + + Added a DTD of the xml pdftohtml creates patch by Stefan Schweizer + + ChangeLog | 2 ++ + utils/Makefile.am | 2 ++ + utils/pdf2xml.dtd | 28 ++++++++++++++++++++++++++++ + 3 files changed, 32 insertions(+) + +commit f4df23ca7f396883a906f16dfc8db1ebd528e04a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 4 20:24:03 2006 +0000 + + ignore++ + + utils/.cvsignore | 1 + + 1 file changed, 1 insertion(+) + +commit 93ad488679f594e45547a67e2a7397f4c8bd2820 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Feb 4 20:07:07 2006 +0000 + + Actually create pdftoppm patch by Stefan Schweizer + + ChangeLog | 44 +++++++++++++++++++++++++------------------- + utils/Makefile.am | 10 ++++++++-- + utils/pdftoppm.cc | 9 +++++---- + 3 files changed, 38 insertions(+), 25 deletions(-) + +commit 7d2be955e6345a052590b06b29a6d2fb2111e2e6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Feb 2 23:06:20 2006 +0000 + + CVE-2006-0301 fix by Derek though KDE security team + + ChangeLog | 5 +++++ + splash/SplashXPathScanner.cc | 32 ++++++++++++++++++++------------ + 2 files changed, 25 insertions(+), 12 deletions(-) + +commit c191e7d0f13ea429017e4d4f79ce803e84c72e40 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Feb 2 22:54:27 2006 +0000 + + i should learn on which day i live + + ChangeLog | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1ddeed60d07c3a7e011f3f594fa9299379d0b000 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Feb 2 22:50:01 2006 +0000 + + don't use files to pass fonts to freetype + + ChangeLog | 26 ++++++++++++ + fofi/FoFiTrueType.cc | 43 ++++++++++++++++---- + fofi/FoFiTrueType.h | 7 ++-- + fofi/FoFiType1C.h | 2 +- + goo/gfile.cc | 8 ++++ + poppler/GfxFont.cc | 49 ++++++++++++++++++++++- + poppler/GfxFont.h | 2 + + poppler/GlobalParams.cc | 1 + + poppler/GlobalParams.h | 1 + + poppler/SplashOutputDev.cc | 94 + ++++++++++++++++++++++---------------------- + splash/SplashFTFontEngine.cc | 44 +++++++++++++-------- + splash/SplashFTFontEngine.h | 16 ++++---- + splash/SplashFTFontFile.cc | 47 +++++++++++++--------- + splash/SplashFTFontFile.h | 18 ++++----- + splash/SplashFontEngine.cc | 46 +++++++++------------- + splash/SplashFontEngine.h | 16 ++++---- + splash/SplashFontFile.cc | 70 +++++++++++++++++++++++++++++---- + splash/SplashFontFile.h | 25 ++++++++++-- + splash/SplashT1FontEngine.cc | 29 +++++++------- + splash/SplashT1FontFile.cc | 30 +++++++++++--- + splash/SplashT1FontFile.h | 4 +- + 21 files changed, 396 insertions(+), 182 deletions(-) + +commit 34df4cfa5cd8788ccf2ea698cbedd05b209041f5 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed Feb 1 03:52:12 2006 +0000 + + 2006-01-31 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/GlobalParams.cc (GlobalParams::getDisplayFont): + Allow ttc fonts to be used. + + ChangeLog | 5 +++++ + poppler/GlobalParams.cc | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit 0184e7c928ec60c0aa3f8634d96ae0cf0ad6d157 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sun Jan 29 05:16:31 2006 +0000 + + 2006-01-28 Jeff Muizelaar <jeff@infidigm.net> + + * glib/poppler-attachment.h: fix compile by adding <time.h> + include. + Acked-by: Jonathan Blanford <jrb@redhat.com> + + ChangeLog | 5 +++++ + glib/poppler-attachment.h | 1 + + 2 files changed, 6 insertions(+) + +commit c805e25f2f074640e4345f8b71eef8d7de677109 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Jan 26 19:25:07 2006 +0000 + + 2006-01-26 Kristian Høgsberg <krh@redhat.com> + + * poppler/CairoOutputDev.cc: Patch from Christian Krause; + handle + 0-width lines (#5545). + + ChangeLog | 5 +++++ + poppler/CairoOutputDev.cc | 6 +++++- + 2 files changed, 10 insertions(+), 1 deletion(-) + +commit 4f48abcd4c21460d4c5b718a7ba18cdceb30c2d1 +Author: Jonathan Blandford <jrb@redhat.com> +Date: Tue Jan 24 06:21:39 2006 +0000 + + Tue Jan 24 01:19:40 2006 Jonathan Blandford <jrb@redhat.com> + + * glib/Makefile.am: + * glib/poppler-attachment.cc: + * glib/poppler-attachment.h: + * glib/poppler-document.cc: + * glib/poppler-document.h: + * glib/poppler-page.cc: + * glib/poppler-private.h: + * glib/poppler.h: + * glib/test-poppler-glib.c: + * glib/reference/tmpl/poppler-enums.sgml: + * glib/reference/tmpl/poppler-unused.sgml: glib bindings + for the + embedded file support. It doesn't support mtime and + ctime yet, + but the rest works. + + ChangeLog | 16 +++ + glib/Makefile.am | 2 + + glib/poppler-attachment.cc | 223 + ++++++++++++++++++++++++++++++++ + glib/poppler-attachment.h | 67 ++++++++++ + glib/poppler-document.cc | 63 +++++++++ + glib/poppler-document.h | 6 + + glib/poppler-page.cc | 2 +- + glib/poppler-private.h | 6 +- + glib/poppler.h | 1 + + glib/reference/tmpl/poppler-enums.sgml | 150 +++++++++++++++++++++ + glib/reference/tmpl/poppler-unused.sgml | 130 ------------------- + glib/test-poppler-glib.c | 26 +++- + 12 files changed, 559 insertions(+), 133 deletions(-) + +commit 052bf4b80c8a0dc45f6222617bfd8ae1b9c40410 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Jan 23 18:52:48 2006 +0000 + + 2006-01-23 Kristian Høgsberg <krh@redhat.com> + + * configure.ac: + * poppler/GlobalParams.cc: + * poppler/poppler-config.h.in: + * utils/pdftohtml.cc: + * utils/pdftops.cc: Respect command line paper size settings + (#5641). + Drop the built-in paper sizes. + + ChangeLog | 9 +++++++++ + configure.ac | 1 - + poppler/GlobalParams.cc | 23 ++--------------------- + poppler/poppler-config.h.in | 5 ----- + utils/pdftohtml.cc | 4 +--- + utils/pdftops.cc | 4 +++- + 6 files changed, 15 insertions(+), 31 deletions(-) + +commit fb2054a5031d60aac3ccc9a36b3ed88a32188e33 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Jan 23 15:40:54 2006 +0000 + + 2006-01-23 Kristian Høgsberg <krh@redhat.com> + + * glib/test-poppler-glib.c (print_document_info, print_index): + Move variable declarations to top (#5692). + + * utils/*.cc: Move config.h #include to top of #include's + (#5693). + + ChangeLog | 5 +++++ + glib/test-poppler-glib.c | 5 +++-- + poppler/FontInfo.cc | 2 +- + utils/HtmlOutputDev.cc | 2 +- + utils/ImageOutputDev.cc | 2 +- + utils/pdffonts.cc | 2 +- + utils/pdfimages.cc | 2 +- + utils/pdfinfo.cc | 2 +- + utils/pdftohtml.cc | 4 ++-- + utils/pdftoppm.cc | 2 +- + utils/pdftops.cc | 2 +- + utils/pdftotext.cc | 2 +- + 12 files changed, 19 insertions(+), 13 deletions(-) + +commit 836af3529e827e25f20cb4710cbbf9ed0371a42c +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Jan 23 14:45:30 2006 +0000 + + 2006-01-23 Kristian Høgsberg <krh@redhat.com> + + * splash/SplashFTFont.cc: Don't use deprecated freetype + include + files. + + ChangeLog | 5 +++++ + splash/SplashFTFont.cc | 3 ++- + 2 files changed, 7 insertions(+), 1 deletion(-) + +commit 60e13bf84e4f020a264811e4a5bf85d67e15d6df +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sat Jan 21 21:56:40 2006 +0000 + + 2006-01-21 Jeff Muizelaar <jeff@infidigm.net> + + * TODO: Add my todo list. + + ChangeLog | 4 ++++ + TODO | 10 ++++++++++ + 2 files changed, 14 insertions(+) + +commit cebba06563d1b691a8bbb83828e47c9cc91e231a +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 18 22:40:26 2006 +0000 + + ok, ok, lasts files, i promise :-/ + + qt4/tests/check_attachments.cpp | 151 + ++++++++++++++++++++++++++++++++++++++ + qt4/tests/poppler-attachments.cpp | 37 ++++++++++ + 2 files changed, 188 insertions(+) + +commit 0b12e7cce6c6633b1d07e2902a9fa13ff52079e7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 18 22:38:59 2006 +0000 + + YAMF = Yet Another Missing File + + qt4/src/poppler-embeddedfile.cc | 106 + ++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 106 insertions(+) + +commit 38c8f3a53b3eb2be1fbfa360f77285037d89b719 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 18 22:36:01 2006 +0000 + + as usual i foget some files + + poppler/UGooString.cc | 86 + +++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/UGooString.h | 55 ++++++++++++++++++++++++++++++++ + 2 files changed, 141 insertions(+) + +commit ad6e7d862c8fa6e10a7dbbb3391cbb0b6c922375 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 18 22:32:13 2006 +0000 + + Brad patch for embedded document extraction, only has Qt4 bindings + for now, needs Qt3 and glib work + + ChangeLog | 42 +++++++++++++ + glib/poppler-action.cc | 2 +- + glib/poppler-document.cc | 1 + + poppler/Annot.cc | 1 + + poppler/Catalog.cc | 133 + +++++++++++++++++++++++++++++++++++++++--- + poppler/Catalog.h | 60 +++++++++++++++++-- + poppler/Dict.cc | 17 +++--- + poppler/Dict.h | 15 ++--- + poppler/FontInfo.cc | 1 + + poppler/Function.cc | 1 + + poppler/Gfx.cc | 1 + + poppler/GfxFont.cc | 5 +- + poppler/GfxState.cc | 1 + + poppler/Link.cc | 9 +-- + poppler/Link.h | 9 +-- + poppler/Makefile.am | 2 + + poppler/Object.h | 17 +++--- + poppler/Outline.cc | 1 + + poppler/PDFDoc.cc | 1 + + poppler/PDFDoc.h | 2 +- + poppler/PSOutputDev.cc | 5 +- + poppler/Page.cc | 1 + + poppler/PageLabelInfo.cc | 1 + + poppler/Parser.cc | 2 + + poppler/SecurityHandler.cc | 1 + + poppler/Stream.cc | 1 + + poppler/XRef.cc | 1 + + qt/poppler-document.cc | 1 + + qt/poppler-page-transition.cc | 1 + + qt4/src/Makefile.am | 1 + + qt4/src/poppler-document.cc | 26 ++++++++- + qt4/src/poppler-private.h | 2 + + qt4/src/poppler-qt4.h | 68 +++++++++++++++++++++ + qt4/tests/.cvsignore | 2 + + qt4/tests/Makefile.am | 16 ++++- + utils/HtmlOutputDev.cc | 1 + + utils/pdffonts.cc | 1 + + utils/pdfinfo.cc | 1 + + utils/pdftohtml.cc | 1 + + utils/pdftotext.cc | 1 + + 40 files changed, 401 insertions(+), 54 deletions(-) + +commit 550fb0b617ece7951ec39aec5fa5504cc90022fc +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 18 21:22:12 2006 +0000 + + Add some more documentation to PageTransition, patch by Stefan Kebekus + + ChangeLog | 6 ++++++ + qt/poppler-page-transition.h | 40 + +++++++++++++++++++++++++++++++++------- + qt4/src/Doxyfile | 2 +- + 3 files changed, 40 insertions(+), 8 deletions(-) + +commit d66f3647ff1c38318d4cd056cb4d4c7a32eb6603 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jan 18 18:54:12 2006 +0000 + + poppler/CharCodeToUnicode.cc: Fix check for length that was not + having into account that there could be \n or \r in tokens + an that + those do not have to be took into account. Fixes + http://bugs.kde.org/show_bug.cgi?id=120310 + + ChangeLog | 9 ++++++++- + poppler/CharCodeToUnicode.cc | 31 +++++++++++++++++++++++++++---- + 2 files changed, 35 insertions(+), 5 deletions(-) + +commit d78b670339c8f92a32ab5f0a574d0e21690806f8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jan 17 21:35:31 2006 +0000 + + When doing the parsing check with XREF we did not grow too much. Fixes + serialata10a.pdf + + ChangeLog | 10 ++++++++++ + poppler/Lexer.cc | 22 +++++++++++++++++++--- + poppler/Lexer.h | 8 +++++--- + poppler/Parser.cc | 6 +++--- + poppler/Parser.h | 2 +- + poppler/XRef.cc | 17 +++++++++++++++++ + poppler/XRef.h | 3 +++ + 7 files changed, 58 insertions(+), 10 deletions(-) + +commit f5db636af0cd6e05cd7ede37a8585001d51192a1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jan 17 20:33:08 2006 +0000 + + i suck + i suck + i suck + i suck + i suck + A file i forgot to add to make it compile :-/ + + qt/poppler-page-transition-private.h | 28 ++++++++++++++++++++++++++++ + 1 file changed, 28 insertions(+) + +commit 9cc97908ea67ab431e58129f589e00f41f40a143 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Thu Jan 12 23:54:08 2006 +0000 + + 2006-01-12 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/GlobalParams.cc: Make buildFcPattern() static. + + ChangeLog | 4 ++++ + poppler/GlobalParams.cc | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +commit c7ce134fb1dadb46e2b3773d0976ea31da0a046f +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed Jan 11 16:52:58 2006 +0000 + + 2006-01-11 Kristian Høgsberg <krh@redhat.com> + + * poppler/JBIG2Stream.cc: + * poppler/Stream.cc: Merge patch to fix CVE-2005-3624, + CVE-2005-3625 and CVE-2005-3627 issues. + + ChangeLog | 6 ++++++ + poppler/JBIG2Stream.cc | 32 +++++++++++++++++++++++++++++++- + poppler/Stream.cc | 8 +++++--- + 3 files changed, 42 insertions(+), 4 deletions(-) + +commit ec7fb41725c19bc7f2aad1073fe6397ea0a8da0d +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jan 10 21:57:28 2006 +0000 + + * configure.ac: + * m4/qt.m4: Fix bugs created when splitting the code from + configure.ac, take QTDIR into account when looking for + QtTestLib and + do not die if it is not found as it is not mandatory + * qt/poppler-page-transition.cc: + * qt/poppler-page.cc: + * qt/poppler-private.h: + * qt4/tests/Makefile.am: + * qt4/src/poppler-qt4.h: + * qt4/src/poppler-page.cc: + * qt4/src/Makefile.am: Fix mess created my the moving and + renaming of + PageTransition.cc + + ChangeLog | 15 +++++++++++++++ + configure.ac | 14 ++++---------- + m4/qt.m4 | 5 +++++ + qt/poppler-page-transition.cc | 2 +- + qt/poppler-page.cc | 1 + + qt/poppler-private.h | 5 ----- + qt4/src/Makefile.am | 1 + + qt4/src/poppler-page.cc | 2 +- + qt4/src/poppler-qt4.h | 2 +- + qt4/tests/Makefile.am | 1 + + 10 files changed, 30 insertions(+), 18 deletions(-) + +commit d9bc53a741b3bbd2a202662c66fe70f49ac72a49 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue Jan 10 17:59:51 2006 +0000 + + 2006-01-10 Kristian Høgsberg <krh@redhat.com> + + * splash/Makefile.am: Only install splash headers if + --enable-xpdf-headers is given. + + * Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Set this here. + + ChangeLog | 7 +++++++ + Makefile.am | 1 + + splash/Makefile.am | 4 ++++ + 3 files changed, 12 insertions(+) + +commit ea6d9b97cec6fabf8a5005c565bbdb378bed7f54 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Tue Jan 10 17:55:59 2006 +0000 + + 2006-01-10 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: + * poppler/CairoOutputDev.h: + Fix the following fixme in CairoOutputDevice. + + // FIXME: This is quite right yet, we need to accumulate all + // glyphs within one text object before we clip. Right now this + // just add this one string. + + The fix uses a strategy similar to the one the Splash backend. + textClipPath is used to store the appended path from each call to + endString(). The accumulated path is clipped in endTextObject. + + ChangeLog | 14 ++++++++++++++ + poppler/CairoOutputDev.cc | 27 +++++++++++++++++++++++---- + poppler/CairoOutputDev.h | 1 + + 3 files changed, 38 insertions(+), 4 deletions(-) + +commit 9e8a655a2bd3ca8cff1a150dce0dd378aeca047b +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sun Jan 8 22:59:48 2006 +0000 + + 2006-01-08 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: Don't try and load type3 fonts + (#4030). + + ChangeLog | 6 +++++- + poppler/CairoOutputDev.cc | 5 ++++- + 2 files changed, 9 insertions(+), 2 deletions(-) + +commit 25fd8e1ea87c41855a4ee702fbe47f5661a54c22 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sun Jan 8 22:51:17 2006 +0000 + + 2006-01-08 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/Page.cc: use colToByte for reading thumbnails (#5420). + + Patch by Nickolay V. Shmyrev. + + ChangeLog | 6 ++++++ + poppler/Page.cc | 6 +++--- + 2 files changed, 9 insertions(+), 3 deletions(-) + +commit df73ee2ec4b65ccf611f0fd76fb456cc797693d4 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sat Jan 7 06:10:15 2006 +0000 + + 2006-01-07 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/CairoOutputDev.cc: Initialize (fill|stroke)_opacity. + + ChangeLog | 4 ++++ + poppler/CairoOutputDev.cc | 2 ++ + 2 files changed, 6 insertions(+) + +commit 18eb8de66749082e4aa65cc6d369a533826fab33 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Jan 6 10:05:58 2006 +0000 + + 2006-01-06 Kristian Høgsberg <krh@redhat.com> + + * qt/poppler-page.cc: + * qt/poppler-private.h: + * qt/poppler-qt.h: + * qt4/src/Makefile.am: + * qt/Makefile.am: + * poppler/Makefile.am: Move PageTransition to qt bindings, + move + contents from Private.h to qt/poppler-private.h. + + * poppler/TextOutputDev.cc (visitWord): Remove #warning. + + * utils/Makefile.am (pdfimages_SOURCES): Add ImageOutputDev.h, + use + dist_man1_MANS so we actually dist the man pages. + + * goo/Makefile.am (poppler_goo_include_HEADERS): Add + GooVector.h. + + * glib/reference/Makefile.am: DOC_SOURCE_DIR must be + relative to + $(srcdir), fix this to make distchek run. + + * m4/qt.m4: + * m4/libjpeg.m4: + * acinclude.m4: + * configure.ac: Split out Qt and libjpeg checks from + configure.ac + and acinclude.m4 to m4/qt.m4 and m4/libjpeg.m4. + + ChangeLog | 26 ++++ + acinclude.m4 | 112 ---------------- + configure.ac | 223 + +++----------------------------- + glib/reference/Makefile.am | 2 +- + glib/reference/tmpl/poppler-enums.sgml | 150 --------------------- + glib/reference/tmpl/poppler-unused.sgml | 130 +++++++++++++++++++ + goo/Makefile.am | 1 + + m4/libjpeg.m4 | 109 ++++++++++++++++ + m4/qt.m4 | 206 + +++++++++++++++++++++++++++++ + poppler/Makefile.am | 1 - + poppler/PageTransition.h | 118 ----------------- + poppler/Private.h | 30 ----- + poppler/TextOutputDev.cc | 2 - + qt/Makefile.am | 8 +- + qt/poppler-page-transition.cc | 187 ++++++++++++++++++++++++++ + qt/poppler-page-transition.h | 117 +++++++++++++++++ + qt/poppler-page.cc | 1 - + qt/poppler-private.h | 9 +- + qt/poppler-qt.h | 2 +- + qt4/src/Makefile.am | 8 +- + utils/Makefile.am | 54 ++++++-- + 21 files changed, 857 insertions(+), 639 deletions(-) + +commit 93921e77115ebe4d527f98675e438de485e84507 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 5 23:53:33 2006 +0000 + + * poppler/DCTStream.cc: Fix handling of malformed jpeg streams like + the one at http://bugs.kde.org/show_bug.cgi?id=119569 + + Might be worth backporting to 0.4.x + + ChangeLog | 5 +++++ + poppler/DCTStream.cc | 26 ++++++++++++++++---------- + 2 files changed, 21 insertions(+), 10 deletions(-) + +commit 0dc16af02071350a0dc11af4106799378c99cdad +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jan 5 13:53:58 2006 +0000 + + Introduce variants of renderTo that return a QImage and do not use + a QPixmap so threading is possible. + + ChangeLog | 8 +++++++ + qt/poppler-page.cc | 18 ++++++++++----- + qt/poppler-qt.h | 30 ++++++++++++++++++++----- + qt4/src/poppler-page.cc | 9 +++++++- + qt4/src/poppler-qt4.h | 59 + +++++++++++++++++++++++++++---------------------- + 5 files changed, 85 insertions(+), 39 deletions(-) + +commit 5c2cbf5d327c6cc75c073b56c3ab1748c0d24387 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jan 2 14:24:31 2006 +0000 + + Use error() instead std::cerr in PageTranstion.cc + + ChangeLog | 4 ++++ + poppler/PageTransition.cc | 5 +++-- + 2 files changed, 7 insertions(+), 2 deletions(-) + +commit da5a4233498b56df611e1c7bca0090306cb5dbe0 +Author: Jonathan Blandford <jrb@redhat.com> +Date: Mon Jan 2 00:06:45 2006 +0000 + + Sun Jan 1 18:50:51 2006 Jonathan Blandford <jrb@redhat.com> + + * Makefile.am: + * autogen.sh: + * configure.ac: + * gtk-doc.make: + * glib/Makefile.am: enable gtk-doc support. + + ChangeLog | 8 +++ + Makefile.am | 2 + + autogen.sh | 14 +++++ + configure.ac | 4 ++ + glib/Makefile.am | 1 + + gtk-doc.make | 153 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + m4/gtk-doc.m4 | 53 +++++++++++++++++++ + 7 files changed, 235 insertions(+) + +commit 372c34cc9728d7041bc4f6893c0bae50c9501c50 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 1 22:35:48 2006 +0000 + + * qt4/src/poppler-private.h: + * qt4/src/poppler-page.cc: + * qt4/src/poppler-document.cc: Don't create a SplashOutputDev + for + every splashRenderToPixmap + + ChangeLog | 4 ++++ + qt4/src/poppler-document.cc | 1 - + qt4/src/poppler-page.cc | 18 +++++------------- + qt4/src/poppler-private.h | 24 +++++++++++++++++++++++- + 4 files changed, 32 insertions(+), 15 deletions(-) + +commit 6ff83474ac594368015334db9c6b33d3a552079f +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jan 1 22:18:47 2006 +0000 + + * qt/poppler-page.cc: + * qt/poppler-private.h: Don't create a SplashOutputDev for every + renderToPixmap. + + ChangeLog | 6 ++++++ + qt/poppler-page.cc | 8 +------- + qt/poppler-private.h | 24 +++++++++++++++++++++++- + 3 files changed, 30 insertions(+), 8 deletions(-) + +commit 6942646d4c82327a80b021838a38aa55c1026883 +Author: Jonathan Blandford <jrb@redhat.com> +Date: Sun Jan 1 20:34:36 2006 +0000 + + Sun Jan 1 15:32:08 2006 Jonathan Blandford <jrb@redhat.com> + + * glib/reference/*: More gtk-doc work. Not enabled for + building + by default, but filled in. + + .cvsignore | 1 + + ChangeLog | 5 + + glib/reference/.cvsignore | 18 ++ + glib/reference/Makefile.am | 87 +++++++ + glib/reference/poppler-docs.sgml | 17 ++ + glib/reference/poppler-overrides.txt | 0 + glib/reference/poppler-sections.txt | 151 ++++++++++++ + glib/reference/poppler.types | 4 + + glib/reference/tmpl/poppler-action.sgml | 172 +++++++++++++ + glib/reference/tmpl/poppler-document.sgml | 354 + +++++++++++++++++++++++++++ + glib/reference/tmpl/poppler-enums.sgml | 169 +++++++++++++ + glib/reference/tmpl/poppler-page.sgml | 243 ++++++++++++++++++ + glib/reference/tmpl/poppler-private.sgml | 128 ++++++++++ + glib/reference/tmpl/poppler-unused.sgml | 0 + glib/reference/tmpl/poppler.sgml | 216 ++++++++++++++++ + glib/reference/tmpl/stamp-poppler-enums.sgml | 19 ++ + 16 files changed, 1584 insertions(+) + +commit 0fab1b711f153859e113cb3b6d734ddcb58fb87a +Author: Jonathan Blandford <jrb@redhat.com> +Date: Sat Dec 31 02:10:33 2005 +0000 + + Fri Dec 30 21:08:33 2005 Jonathan Blandford <jrb@redhat.com> + + * glib/*{cc,h}: Update inline doc comments. This is in + preparation for gtk-doc support. + + ChangeLog | 5 ++ + glib/poppler-action.cc | 14 +++++ + glib/poppler-action.h | 2 - + glib/poppler-document.cc | 151 + ++++++++++++++++++++++++++++++++++++++++++++++- + glib/poppler-document.h | 4 +- + glib/poppler-page.cc | 28 +++++++++ + glib/poppler.cc | 16 +++++ + glib/test-poppler-glib.c | 29 +++++++++ + 8 files changed, 243 insertions(+), 6 deletions(-) + +commit 313530036b204eaa5ddfa150730302e855560d6a +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 30 22:54:46 2005 +0000 + + A delete that slipped from the last patch-commit + + qt4/src/poppler-page.cc | 1 + + 1 file changed, 1 insertion(+) + +commit cf6f8123af19aca4200b58a454652f68ce8132e2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 30 22:31:32 2005 +0000 + + Puting PageTransition implementation into poppler "core", both Qt + and Qt4 frontends use it. + + poppler/Makefile.am | 1 + + poppler/PageTransition.cc | 188 + ++++++++++++++++++++++++++++++++++++++++++++++ + poppler/PageTransition.h | 118 +++++++++++++++++++++++++++++ + poppler/Private.h | 30 ++++++++ + qt/Makefile.am | 2 +- + qt/poppler-page.cc | 111 +-------------------------- + qt/poppler-qt.h | 72 +----------------- + qt4/src/Makefile.am | 2 +- + qt4/src/poppler-page.cc | 17 ++++- + qt4/src/poppler-qt4.h | 14 +++- + 10 files changed, 374 insertions(+), 181 deletions(-) + +commit 56035ab199ac6deb5c1e07e745d120d1121a5960 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 30 21:59:58 2005 +0000 + + * utils/HtmlOutputDev.cc: + * utils/ImageOutputDev.cc: Fix build when using --disable-libjpeg + + ChangeLog | 5 +++++ + utils/HtmlOutputDev.cc | 2 ++ + utils/ImageOutputDev.cc | 2 ++ + 3 files changed, 9 insertions(+) + +commit 8b64dafc7f1d198fb0052c0d6f0da6de97bbb48d +Author: Brad Hards <bradh@frogmouth.net> +Date: Wed Dec 28 09:23:43 2005 +0000 + + Plug a few memory leaks in the Qt4 bindings. + + ChangeLog | 25 ++++++++++++++++++++ + qt4/src/poppler-document.cc | 3 +++ + qt4/src/poppler-private.h | 7 +++++- + qt4/src/poppler-qt4.h | 3 +++ + qt4/tests/check_fonts.cpp | 8 +++++++ + qt4/tests/check_metadata.cpp | 50 + +++++++++++++++++++++++++++++++++++----- + qt4/tests/check_pagelayout.cpp | 6 +++++ + qt4/tests/check_pagemode.cpp | 10 ++++++++ + qt4/tests/check_permissions.cpp | 2 ++ + qt4/tests/check_version.cpp | 22 ------------------ + qt4/tests/poppler-fonts.cpp | 1 + + qt4/tests/stress-poppler-qt4.cpp | 2 ++ + 12 files changed, 110 insertions(+), 29 deletions(-) + +commit 64c07a20a4ed844f3b3dd26e974f58d5877cf9fd +Author: Brad Hards <bradh@frogmouth.net> +Date: Tue Dec 27 06:10:01 2005 +0000 + + qt4/src/poppler-qt4.h and qt4/src/poppler-document.cc: add + convertDate() function that + turns char* PDF date strings into QDateTime. This version handles + the timezone conversions. Refactored the existing date() method + to use it. + + qt4/tests/check_dateConversion.cpp: unit tests for convertDate() + qt4/tests/check_metadata.cpp: update to reflect UTC. + qt4/tests/.cvsignore: suppress check_dateConversion + + ChangeLog | 9 ++++ + qt4/src/poppler-document.cc | 89 ++++++++++++++++++++----------- + qt4/src/poppler-qt4.h | 5 ++ + qt4/tests/.cvsignore | 1 + + qt4/tests/Makefile.am | 11 ++-- + qt4/tests/check_dateConversion.cpp | 105 + +++++++++++++++++++++++++++++++++++++ + qt4/tests/check_metadata.cpp | 4 +- + 7 files changed, 188 insertions(+), 36 deletions(-) + +commit 4b2e3b5106b75f23c830837a886cd29beb1d1d1b +Author: Brad Hards <bradh@frogmouth.net> +Date: Tue Dec 27 05:08:34 2005 +0000 + + * qt4/src/Doxyfile (JAVADOC_AUTOBRIEF): Turned on automatic + \brief mode. + + * qt4/src/poppler-qt4.h: Update API documentation. Patch from + Stefan Kebekus, with some changes. Removed \brief entries. + + ChangeLog | 8 +++++ + qt4/src/Doxyfile | 2 +- + qt4/src/poppler-qt4.h | 81 + ++++++++++++++++++++++++++++++++++++++++----------- + 3 files changed, 73 insertions(+), 18 deletions(-) + +commit 8d9cf43aaa73d5012428a6a4c5d7e2cccbd3036e +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed Dec 21 22:09:47 2005 +0000 + + 2005-12-21 Kristian Høgsberg <krh@redhat.com> + + * NEWS: Sum up 0.5 changes so far. + + * acinclude.m4: Split jpeg macros out into this file. + + * poppler/Stream.cc: Apply latest CVE-2005-3191 updates. + + ChangeLog | 8 ++++ + NEWS | 8 ++++ + acinclude.m4 | 112 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + configure.ac | 114 + --------------------------------------------------- + poppler/JPXStream.cc | 1 + + poppler/Stream.cc | 11 +++-- + 6 files changed, 137 insertions(+), 117 deletions(-) + +commit 97243286560cb4f264b875185c8768a6af09d554 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed Dec 21 17:30:33 2005 +0000 + + 2005-12-21 Kristian Høgsberg <krh@redhat.com> + + * utils/Makefile.am: Add parseargs.h to sources and add + -I$(top_srcdir)/poppler to INCLUDES. + + * poppler/CairoFontEngine.cc: Apply patch from Hiroyuki + Ikezoe to + man non-embedded CJK fonts work. + + ChangeLog | 14 ++++++++++--- + configure.ac | 2 +- + poppler/CairoFontEngine.cc | 52 + +++++++++++++++++++++++++++++++++++++++++----- + utils/Makefile.am | 15 +++++++------ + 4 files changed, 68 insertions(+), 15 deletions(-) + +commit cf887a9a9fae7272165d3aae05c85444ff5ca604 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 18 22:03:30 2005 +0000 + + * poppler/Page.cc: Only discard cropbox sizes one by one + and not + completely. Jeff and Martin were right + + ChangeLog | 2 ++ + poppler/Page.cc | 13 ++++++++++--- + 2 files changed, 12 insertions(+), 3 deletions(-) + +commit 495890b9cef9d5d61bb47e789add1cf2c3b8f83d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 18 21:56:15 2005 +0000 + + + .cvsignore + + utils/.cvsignore | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +commit 5dca860bba6918e06fab3aa56a2c75f0ac9ecdfb +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 18 21:08:48 2005 +0000 + + Fix utils building on Slackware + + ChangeLog | 3 +++ + configure.ac | 3 +++ + utils/Makefile.am | 3 ++- + 3 files changed, 8 insertions(+), 1 deletion(-) + +commit 03e3d9164ffd71f03136b57a9941ea14fadb21aa +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 18 17:12:28 2005 +0000 + + 2005-12-18 Albert Astals Cid <aacid@kde.org> + + * configure.ac: Better jpeg detection, refer to ml PCbsd + problem + + ChangeLog | 4 ++ + configure.ac | 131 + +++++++++++++++++++++++++++++++++++++++++++++++++++-------- + 2 files changed, 118 insertions(+), 17 deletions(-) + +commit 888d76a29c9c5ea6c90cc4299b230ca0c2c2944f +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Dec 12 20:21:08 2005 +0000 + + * poppler/Page.cc: Ignore cropBox if it seems incorrect + + ChangeLog | 4 ++++ + poppler/Page.cc | 7 +++++++ + 2 files changed, 11 insertions(+) + +commit bcc5e3afe27c8787ce7022a0701997c96eddb4fe +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Dec 12 20:15:11 2005 +0000 + + 2005-12-12 Kristian Høgsberg <krh@redhat.com> + + * Makefile.am: + * configure.ac: + * goo/GooVector.h: + * utils/HtmlFonts.cc: + * utils/HtmlFonts.h: + * utils/HtmlLinks.cc: + * utils/HtmlLinks.h: + * utils/HtmlOutputDev.cc: + * utils/HtmlOutputDev.h: + * utils/ImageOutputDev.cc: + * utils/ImageOutputDev.h: + * utils/Makefile.am: + * utils/parseargs.c: + * utils/parseargs.h: + * utils/pdffonts.1: + * utils/pdffonts.cc: + * utils/pdfimages.1: + * utils/pdfimages.cc: + * utils/pdfinfo.1: + * utils/pdfinfo.cc: + * utils/pdftohtml.1: + * utils/pdftohtml.cc: + * utils/pdftoppm.1: + * utils/pdftoppm.cc: + * utils/pdftops.1: + * utils/pdftops.cc: + * utils/pdftotext.1: + * utils/pdftotext.cc: Add command line utilities from xpdf. + + ChangeLog | 31 + + Makefile.am | 6 +- + configure.ac | 25 +- + goo/GooVector.h | 101 +++ + utils/HtmlFonts.cc | 326 ++++++++++ + utils/HtmlFonts.h | 85 +++ + utils/HtmlLinks.cc | 101 +++ + utils/HtmlLinks.h | 49 ++ + utils/HtmlOutputDev.cc | 1569 + +++++++++++++++++++++++++++++++++++++++++++++++ + utils/HtmlOutputDev.h | 302 +++++++++ + utils/ImageOutputDev.cc | 195 ++++++ + utils/ImageOutputDev.h | 76 +++ + utils/Makefile.am | 18 + + utils/parseargs.c | 190 ++++++ + utils/parseargs.h | 71 +++ + utils/pdffonts.1 | 128 ++++ + utils/pdffonts.cc | 294 +++++++++ + utils/pdfimages.1 | 96 +++ + utils/pdfimages.cc | 159 +++++ + utils/pdfinfo.1 | 157 +++++ + utils/pdfinfo.cc | 376 ++++++++++++ + utils/pdftohtml.1 | 85 +++ + utils/pdftohtml.cc | 429 +++++++++++++ + utils/pdftoppm.1 | 113 ++++ + utils/pdftoppm.cc | 189 ++++++ + utils/pdftops.1 | 224 +++++++ + utils/pdftops.cc | 336 ++++++++++ + utils/pdftotext.1 | 135 ++++ + utils/pdftotext.cc | 337 ++++++++++ + 29 files changed, 6194 insertions(+), 9 deletions(-) + +commit 5fbded32741acb5fac411189f80cb57aa11df517 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 10 10:52:15 2005 +0000 + + * qt4/src/poppler-page.cc: + * qt4/src/poppler-qt4.h: + * qt4/src/tests/test-poppler-qt4.cpp: The parameters x,y,w,h to the + method splashRenderToPixmap are now used. Convenient + defaults are provided. The test has been changed accordingly. Some + added documentation. Patch by Stefan Kebekus + + ChangeLog | 9 +++++++++ + qt4/src/poppler-page.cc | 4 ++-- + qt4/src/poppler-qt4.h | 31 +++++++++++++++++++++++-------- + qt4/tests/test-poppler-qt4.cpp | 2 +- + 4 files changed, 35 insertions(+), 11 deletions(-) + +commit bc6df8c41081c0c0107655cbf70ddb8b0c493c34 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Dec 9 20:49:59 2005 +0000 + + 2005-12-09 Kristian Høgsberg <krh@redhat.com> + + * poppler/GfxState.cc: Use colToByte() for converting + GxfColorComp + to bytes (really fix #5117). + + * poppler/Stream.cc: Remove duplicated check (#5243). + + ChangeLog | 5 +++++ + poppler/GfxState.cc | 6 +++--- + poppler/Stream.cc | 4 ---- + 3 files changed, 8 insertions(+), 7 deletions(-) + +commit 8a2464122455311c6d16ae62bb9ac9a0ae365a28 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Dec 9 19:40:40 2005 +0000 + + 2005-12-09 Kristian Høgsberg <krh@redhat.com> + + * configure.ac: + * poppler/Makefile.am (poppler_includedir): + * goo/Makefile.am (poppler_goo_include_HEADERS): Make + installation + of xpdf header files optional. + + ChangeLog | 10 +++++++++- + configure.ac | 8 ++++++++ + goo/Makefile.am | 4 ++++ + poppler/Makefile.am | 4 ++++ + 4 files changed, 25 insertions(+), 1 deletion(-) + +commit 830b61bfd1c985fe14ec4d0f6724c8f70e924fc1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Dec 8 18:17:42 2005 +0000 + + * configure.ac: Detect if gettimeofday is available, fixes + for correct + linking to Qt4 on windows + * goo/GooTimer.[cc|h]: Only build if gettimeofday is available + * poppler/Gfx.cc: Only use the timer for profiling if + gettimeofday is + available + * poppler/GlobalParams.cc: Remove extra unlockGlobalParams + that was + making windows hang + * splash/SplashFTFontEngine.cc: i need unistd.h on windows + also + * splash/SplashFontFile.cc: i need unistd.h on windows also + + ChangeLog | 12 ++++++++++++ + configure.ac | 14 +++++++++++++- + goo/GooTimer.cc | 3 +++ + goo/GooTimer.h | 4 ++++ + poppler/Gfx.cc | 6 ++++++ + poppler/GlobalParams.cc | 1 - + splash/SplashFTFontEngine.cc | 4 +--- + splash/SplashFontFile.cc | 4 +--- + 8 files changed, 40 insertions(+), 8 deletions(-) + +commit 0a1c33ed17fd7053ed455da3444856a5dab3c9b4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Dec 8 12:42:50 2005 +0000 + + Remove -DDATADIR we are not using if for anything and it shadows a + windows typedef + + ChangeLog | 8 ++++++++ + glib/Makefile.am | 3 +-- + poppler/Makefile.am | 3 +-- + qt/Makefile.am | 3 +-- + test/Makefile.am | 3 +-- + 5 files changed, 12 insertions(+), 8 deletions(-) + +commit adca042e666fd932f16213d0a4daba08b5021901 +Author: Brad Hards <bradh@frogmouth.net> +Date: Wed Dec 7 08:42:21 2005 +0000 + + Remove the version check. OK'd by krh. + + ChangeLog | 2 ++ + poppler/PDFDoc.cc | 6 +----- + 2 files changed, 3 insertions(+), 5 deletions(-) + +commit bc57f8dd73eef9a74e4a6e248ed6985c360db838 +Author: Brad Hards <bradh@frogmouth.net> +Date: Wed Dec 7 08:31:09 2005 +0000 + + Add infoKeys() - allows you to get a list of all the string names + (keys) + for the metadata. + + ChangeLog | 7 +++++++ + qt4/src/poppler-document.cc | 22 ++++++++++++++++++++++ + qt4/src/poppler-qt4.h | 7 +++++++ + qt4/tests/check_metadata.cpp | 18 ++++++++++++++++++ + 4 files changed, 54 insertions(+) + +commit 7ec41df91e6dbf792e11676d929acc2f634bd382 +Author: Brad Hards <bradh@frogmouth.net> +Date: Tue Dec 6 09:58:04 2005 +0000 + + Add more unit tests for better coverage. + + ChangeLog | 6 ++++ + qt4/tests/check_fonts.cpp | 24 ++++++++++++++++ + qt4/tests/check_metadata.cpp | 66 + ++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 96 insertions(+) + +commit a92b10016306ac46775c9b95b52d249b233ff950 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Dec 5 20:46:22 2005 +0000 + + * poppler/CairoFontEngine.cc: Correct fix for #5149, i broke it when + merging xpdf 3.01 patches + + ChangeLog | 5 +++++ + poppler/CairoFontEngine.cc | 4 +--- + 2 files changed, 6 insertions(+), 3 deletions(-) + +commit 66096477d1a86f13fcb07ae25caff1cc02b1e7cd +Author: Brad Hards <bradh@frogmouth.net> +Date: Sun Dec 4 19:48:25 2005 +0000 + + Add checking for Type3 fonts in the unit test. + + ChangeLog | 5 +++++ + qt4/tests/check_fonts.cpp | 24 ++++++++++++++++++++++++ + 2 files changed, 29 insertions(+) + +commit 62345b0affed8e2e37728fca7f2b750879192c43 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 4 18:53:40 2005 +0000 + + Fix error in merging CAN-2005-3193 fix. Thanks Daniel Gryniewicz + for notifying + + ChangeLog | 5 +++++ + poppler/JPXStream.cc | 2 -- + 2 files changed, 5 insertions(+), 2 deletions(-) + +commit ba4b3f88271892f197aa2ec076c80ff63a175887 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 4 11:30:00 2005 +0000 + + * qt/poppler-qt.h: + * qt/poppler-fontinfo.h: + * qt4/src/poppler-qt4.h: + * qt4/src/poppler-fontinfo.cc: Implement copy constructor of + FontInfo needed + as Q[Value]List<FontInfo> uses it when appending + + ChangeLog | 8 ++++++++ + qt/poppler-fontinfo.cc | 9 +++++++++ + qt/poppler-qt.h | 2 ++ + qt4/src/poppler-fontinfo.cc | 9 +++++++++ + qt4/src/poppler-qt4.h | 2 ++ + 5 files changed, 30 insertions(+) + +commit e091231d98d12c19b0098ffbaec6ecda28097dff +Author: Brad Hards <bradh@frogmouth.net> +Date: Sun Dec 4 10:45:25 2005 +0000 + + Add new unit test to .cvsignore suppressions. + + ChangeLog | 2 ++ + qt4/tests/.cvsignore | 1 + + 2 files changed, 3 insertions(+) + +commit 6a7b1eaaedbfdd3a8e6b4d899477350f2b485641 +Author: Brad Hards <bradh@frogmouth.net> +Date: Sun Dec 4 10:05:21 2005 +0000 + + * qt4/src/poppler-qt4.h: + qt4/src/fontinfo.cc: add implementation for FontInfo::typeName() + + * qt4/tests/check_fonts.cpp: + * qt4/tests/Makefile.am: add unit test for fonts + + * qt4/src/Mainpage.dox: Minor typo fixes. + + ChangeLog | 11 +++++++++++ + qt4/src/Mainpage.dox | 5 +++-- + qt4/src/poppler-fontinfo.cc | 24 ++++++++++++++++++++++++ + qt4/src/poppler-qt4.h | 14 +++++++++++++- + qt4/tests/Makefile.am | 5 +++++ + qt4/tests/check_fonts.cpp | 42 + ++++++++++++++++++++++++++++++++++++++++++ + 6 files changed, 98 insertions(+), 3 deletions(-) + +commit 31b28b4c59f7820901e9cf893197f381acbae8ce +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sun Dec 4 02:24:25 2005 +0000 + + 2005-12-03 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc (poppler_page_set_selection_alpha): Use + Nickolays original fix instead of trying to be clever with + gdk_pixbuf_fill(). + + * poppler/CairoFontEngine.cc: Fix text corruption bug (#5149), + a rerun of an old classic (#3340). + + ChangeLog | 7 +++++++ + glib/poppler-page.cc | 8 +++++++- + poppler/CairoFontEngine.cc | 2 ++ + 3 files changed, 16 insertions(+), 1 deletion(-) + +commit 4d169c5c345cdac84a39026e759b928977643417 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sun Dec 4 01:42:29 2005 +0000 + + 2005-12-03 Kristian Høgsberg <krh@redhat.com> + + * poppler/GfxState.cc: Fixing another problem with new GfxRGB + representation causing images to show up as random pixels + (#5117). + + ChangeLog | 5 +++++ + poppler/GfxState.cc | 6 +++--- + 2 files changed, 8 insertions(+), 3 deletions(-) + +commit 58de0458e17b1639ce0bcae45a4b09b2c0a56618 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sat Dec 3 23:23:53 2005 +0000 + + 2005-12-03 Kristian Høgsberg <krh@redhat.com> + + * qt/Makefile.am (noinst_PROGRAMS): Only build qt test + program if + splash is enabled. + + * poppler/CairoOutputDev.cc: Remove unused grid snapping code, + sidestepping #4507. + + * glib/poppler-document.h (PopplerPermissions): Breaking enum + definition over multiple lines confuses glib-mkenums (#4600). + + * poppler/Makefile.am (libpoppler_la_LIBADD): Add + FREETYPE_LIBS + (#4515). + + * poppler/TextOutputDev.cc: + * qt/poppler-qt.h: GCC-4.1 fixes (#5031). + + ChangeLog | 17 +++++++++++++++++ + glib/poppler-document.h | 5 +---- + poppler/CairoOutputDev.cc | 35 +++++++++-------------------------- + poppler/CairoOutputDev.h | 2 +- + poppler/Makefile.am | 3 ++- + poppler/TextOutputDev.cc | 2 +- + qt/Makefile.am | 4 ++++ + qt/poppler-qt.h | 6 +++--- + 8 files changed, 38 insertions(+), 36 deletions(-) + +commit df45483f1437d8a96519e1428d1f4b3ffc08c2cd +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 3 22:39:06 2005 +0000 + + remove another chagne should not have gone in + + test/pdf-inspector.cc | 9 ++------- + 1 file changed, 2 insertions(+), 7 deletions(-) + +commit 7dfe02ee112dee51346525b62d877e6591135761 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 3 22:28:46 2005 +0000 + + Add the font retrieveing on the qt3 backend also, based on a patch + by Wilfried Huss + + ChangeLog | 3 ++ + qt/poppler-fontinfo.cc | 75 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 78 insertions(+) + +commit 655b9dd195ac9faf2f7ea0255880b8c83b249a06 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 3 22:26:07 2005 +0000 + + this should have not went in + + poppler/TextOutputDev.h | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +commit ab45eb562159d5b006e658ec66723a0a47908f65 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 3 22:20:54 2005 +0000 + + * qt4/src/poppler-qt4.h: + * qt4/src/poppler-fontinfo.cc: + * qt4/src/poppler-textbox.cc: Remove implementation of that classes + from the header, use pimpl + + ChangeLog | 9 ++++- + poppler/TextOutputDev.h | 10 +++--- + qt/Makefile.am | 1 + + qt/poppler-document.cc | 29 ++++++++++++++++ + qt/poppler-private.h | 2 ++ + qt/poppler-qt.h | 80 + ++++++++++++++++++++++++++++++++++++++++++++- + qt4/src/Makefile.am | 2 ++ + qt4/src/poppler-fontinfo.cc | 69 ++++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-qt4.h | 43 ++++++++++-------------- + qt4/src/poppler-textbox.cc | 49 +++++++++++++++++++++++++++ + test/pdf-inspector.cc | 9 +++-- + 11 files changed, 268 insertions(+), 35 deletions(-) + +commit 64079ad81caf6d2cf66b1f3a3de9454146e15c6c +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sat Dec 3 21:55:36 2005 +0000 + + 2005-12-03 Kristian Høgsberg <krh@redhat.com> + + Fixes from Nickolay V. Shmyrev: + + * poppler/TextOutputDev.cc (TextLine::visitSelection, + TextBlock::visitSelection): Fix selection crash with + zero-width + word boxes or zero-height line boxes (#4402). + + * poppler/CairoOutputDev.h: Fix wrong cairo-ft.h include + (#4413). + + * poppler/CairoOutputDev.cc (eoFill, fill): + * glib/poppler-page.cc (poppler_page_render_selection): + Update to + work with new GfxColor definition and use + cairo_pattern_create_rgba() to cache cairo_pattern_t's for the + fill and stroke colors. + + * glib/poppler-page.cc (poppler_page_set_selection_alpha): + Zero + out pixbuf first. + + ChangeLog | 21 +++++++++++++++++ + glib/poppler-page.cc | 18 +++++++++------ + poppler/CairoOutputDev.cc | 59 + ++++++++++++++++++++++++++++++++++------------- + poppler/CairoOutputDev.h | 6 ++--- + poppler/TextOutputDev.cc | 8 +++---- + 5 files changed, 82 insertions(+), 30 deletions(-) + +commit f3da21a3ecdd2694290e64af86c8e35fcb61371b +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Dec 3 21:35:45 2005 +0000 + + More docs for the Qt4 frontend, patch by Stefan Kebekus + + ChangeLog | 8 ++++ + qt4/src/.cvsignore | 3 +- + qt4/src/Doxyfile | 4 +- + qt4/src/Mainpage.dox | 91 + ++++++++++++++++++++++++++++++++++++++++++ + qt4/src/poppler-page.cc | 20 +++------- + qt4/src/poppler-qt4.h | 57 ++++++++++++++++++-------- + qt4/tests/test-poppler-qt4.cpp | 5 ++- + 7 files changed, 151 insertions(+), 37 deletions(-) + +commit 7b2c6e92611db9350ca5dcaf3fd730fe5e69afea +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Dec 1 22:45:10 2005 +0000 + + Fix CAN-2005-3193 related bugs + Thanks Leonard for reporting + + ChangeLog | 6 ++++++ + poppler/JPXStream.cc | 9 ++++++++- + poppler/Stream.cc | 33 ++++++++++++++++++++++++++++++++- + poppler/Stream.h | 3 +++ + 4 files changed, 49 insertions(+), 2 deletions(-) + +commit a90f076af9ebb188895e7b223bcb7e5c3f4309c4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Nov 28 22:50:19 2005 +0000 + + Fix QPixmap contents generation messed when doing the xpdf 3.01 + transition in qt4 frontend + Use Splash backend by default in the qt4 test, added -arthur option + to use the Arthur backend + + ChangeLog | 12 ++++++++-- + qt4/src/poppler-page.cc | 47 ++++++++++++++++++++++++++++--------- + qt4/src/poppler-qt4.h | 17 ++++++++++---- + qt4/tests/test-poppler-qt4.cpp | 53 + ++++++++++++++++++++++++++---------------- + 4 files changed, 91 insertions(+), 38 deletions(-) + +commit b7e4f0e7d175abde7fafb1fcc7ba129468bc8c1a +Author: Brad Hards <bradh@frogmouth.net> +Date: Sun Nov 27 01:33:51 2005 +0000 + + Convert Qt4 unit tests to use the new Qt4.1 QTestlib framework. + Add a little more API documentation + + ChangeLog | 7 +++++ + qt4/src/poppler-qt4.h | 11 +++++--- + qt4/tests/Makefile.am | 12 ++++++--- + qt4/tests/check_metadata.cpp | 58 + ++++++++++++++++++++--------------------- + qt4/tests/check_pagelayout.cpp | 14 +++++----- + qt4/tests/check_pagemode.cpp | 22 ++++++++-------- + qt4/tests/check_permissions.cpp | 18 ++++++------- + 7 files changed, 78 insertions(+), 64 deletions(-) + +commit d036fa022dbb6f4421ccc8b12b8f9e4f0c8d7406 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Nov 25 22:52:56 2005 +0000 + + patch from kebekus to add to the qt4 binding the same functions we + added to the qt3 one + + ChangeLog | 5 +++++ + qt4/src/poppler-page.cc | 44 ++++++++++++++++++++++++++++++++++++++++++-- + qt4/src/poppler-qt4.h | 22 ++++++++++++++++++++++ + 3 files changed, 69 insertions(+), 2 deletions(-) + +commit 3c9f09d76dc70e4ba766930facee8b6f30bcd2da +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Nov 22 21:50:44 2005 +0000 + + Fix page range in the inspector + + ChangeLog | 4 ++++ + test/pdf-inspector.cc | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +commit e64f63416dbce497cb2167272b95491664f213e8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Nov 21 22:12:15 2005 +0000 + + PAtch to add some more functions to the qt binding by Stefan Kebekus + + ChangeLog | 5 ++++ + qt/poppler-page.cc | 69 + +++++++++++++++++++++++++++++++++++++++++++++++++++++- + qt/poppler-qt.h | 41 ++++++++++++++++++++++++++++++++ + 3 files changed, 114 insertions(+), 1 deletion(-) + +commit 8bd8cb4160b73da69d058783750352fbface66dc +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Nov 21 19:44:09 2005 +0000 + + Fix a possible build problem + + ChangeLog | 4 ++++ + qt/Makefile.am | 1 + + 2 files changed, 5 insertions(+) + +commit fc59b79dc375544681032a1618e96c458515d724 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sun Nov 20 23:17:32 2005 +0000 + + 2005-11-20 Kristian Høgsberg <krh@redhat.com> + + * poppler/GfxState.cc: Fix the byte_lookup initialization + broken + by the merges (#4350). Modify GfxColorSpace::getRGBLine() + to work + with new GfXColor type. + + ChangeLog | 13 +++++++++++- + poppler/GfxState.cc | 59 + +++++++++++++++++++++++++++++++---------------------- + 2 files changed, 47 insertions(+), 25 deletions(-) + +commit 6fe2cb0fcd53211143dcd0c47bf8c8c7a8c11a39 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Nov 17 21:37:34 2005 +0000 + + make it compile with freetype 2.2.0 preversions + + ChangeLog | 4 ++++ + splash/SplashFTFont.cc | 42 +++++++++++++++++++++++++++++++++++++----- + 2 files changed, 41 insertions(+), 5 deletions(-) + +commit 429d3521d788be702a3944bc290569f90ae04892 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Nov 4 19:03:55 2005 +0000 + + Make it compile using --disable-cairo-output + + ChangeLog | 4 ++++ + glib/poppler-document.cc | 6 ++++-- + glib/poppler-page.cc | 27 +++++++++++++-------------- + 3 files changed, 21 insertions(+), 16 deletions(-) + +commit b96c118eb08d478914c2981204d749a95957cbb3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Nov 1 15:29:32 2005 +0000 + + Comment some unused parameters to calm down compiler warnings when + using these heders on external projects with higher warning verbosity + + ChangeLog | 5 +++ + poppler/OutputDev.h | 125 + ++++++++++++++++++++++++++-------------------------- + poppler/Stream.h | 24 +++++----- + 3 files changed, 80 insertions(+), 74 deletions(-) + +commit 51670972777510a3ec64a56649716b31167b9d0e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Oct 30 20:29:05 2005 +0000 + + Last xpdf 3.01 merge (at least from my side) + It's very big, but noone has opposed in the 2 weeks time i gave on + the ml so either poppler is dead or people agree with the patch + + ChangeLog | 39 + + glib/poppler-page.cc | 32 +- + poppler/ArthurOutputDev.cc | 2 +- + poppler/ArthurOutputDev.h | 2 +- + poppler/CairoOutputDev.cc | 2 +- + poppler/CairoOutputDev.h | 2 +- + poppler/Gfx.cc | 645 +++++++++-- + poppler/Gfx.h | 17 +- + poppler/GfxState.cc | 1410 ++++++++++++++++++++--- + poppler/GfxState.h | 196 +++- + poppler/OutputDev.cc | 25 + + poppler/OutputDev.h | 46 +- + poppler/PDFDoc.cc | 98 +- + poppler/PDFDoc.h | 24 +- + poppler/PSOutputDev.cc | 1461 ++++++++++++++++++++---- + poppler/PSOutputDev.h | 48 +- + poppler/Page.cc | 115 +- + poppler/Page.h | 23 +- + poppler/SplashOutputDev.cc | 1525 ++++++++++++++++++++++--- + poppler/SplashOutputDev.h | 59 +- + poppler/TextOutputDev.cc | 230 ++-- + poppler/TextOutputDev.h | 16 +- + qt/poppler-page.cc | 34 +- + qt4/src/poppler-page.cc | 31 +- + splash/Splash.cc | 2656 + +++++++++++++++++++++++++++++++++----------- + splash/Splash.h | 75 +- + splash/SplashBitmap.cc | 216 ++-- + splash/SplashBitmap.h | 13 +- + splash/SplashPattern.cc | 22 +- + splash/SplashPattern.h | 19 +- + splash/SplashState.cc | 11 + + splash/SplashState.h | 3 + + splash/SplashTypes.h | 145 ++- + test/gtk-cairo-test.cc | 2 +- + test/gtk-splash-test.cc | 23 +- + test/pdf-inspector.cc | 2 +- + 36 files changed, 7685 insertions(+), 1584 deletions(-) + +commit 10dfa2254dafb9de93692def2bfb3133d9a39989 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Oct 17 02:17:51 2005 +0000 + + 2005-10-05 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc (poppler_page_render_to_ps): + Fix another + off-by-one page number error (#4555). + + ChangeLog | 6 +++++- + poppler/poppler-config.h.in | 2 +- + 2 files changed, 6 insertions(+), 2 deletions(-) + +commit 9830f0ea41f09fefada740e9429c491e067a5082 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Oct 16 15:11:32 2005 +0000 + + GfxFont merges from xpdf 3.01 + + ChangeLog | 1 + + poppler/GfxFont.cc | 109 + ++++++++++++++++++++++++++++++++++++----------------- + 2 files changed, 75 insertions(+), 35 deletions(-) + +commit 62b5ba221aca8c320e964916b0c0329efc8da572 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Oct 16 15:04:39 2005 +0000 + + Stream[cc|h] merges from xpdf 3.01 + + ChangeLog | 1 + + poppler/Stream.cc | 714 + +++++++++++++++++++++++++++++++++++++++++++++++++----- + poppler/Stream.h | 19 +- + 3 files changed, 658 insertions(+), 76 deletions(-) + +commit b9fab51179f38e9798b10366be672f0432c874da +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Oct 16 14:58:14 2005 +0000 + + Function.cc|h merges from xpdf 3.01 + + ChangeLog | 1 + + poppler/Function.cc | 76 + ++++++++++++++++++++++++++++++----------------------- + poppler/Function.h | 42 +++++++++++++++++++++++++++++ + 3 files changed, 86 insertions(+), 33 deletions(-) + +commit c6e0242200f818c67508041763ff317e79daadd6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Oct 16 14:54:17 2005 +0000 + + Annot.[cc|h] and related merges from xpdf 3.01 + + ChangeLog | 7 +- + poppler/Annot.cc | 234 + +++++++++++++++++++++++++++++++++++++++++++------ + poppler/Annot.h | 20 ++--- + poppler/FontInfo.cc | 2 +- + poppler/PSOutputDev.cc | 2 +- + poppler/Page.cc | 2 +- + 6 files changed, 221 insertions(+), 46 deletions(-) + +commit 65d574fdc009e45ad66d1d402d5e805e4e94f427 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Oct 16 14:30:16 2005 +0000 + + Merge SplashFTFont.cc with xpdf 3.01 changes + + ChangeLog | 1 + + splash/SplashFTFont.cc | 64 + ++++++++++++++++++++++++++++++++++---------------- + 2 files changed, 45 insertions(+), 20 deletions(-) + +commit f9d208e86433b213b21a75089f82fd00dcd746fc +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Oct 16 14:25:32 2005 +0000 + + Merge SplashScreen.[cc|h] from xpdf 3.01 + + ChangeLog | 4 ++ + splash/SplashScreen.cc | 110 + ++++++++++++++++++++++++++++++++----------------- + splash/SplashScreen.h | 12 +++++- + 3 files changed, 87 insertions(+), 39 deletions(-) + +commit 7d46ac000316566503a27b5e5c68621be9c081d0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Oct 16 14:19:47 2005 +0000 + + Merging SplashXPathScanner.cc changes from xpdf 3.01 + + splash/SplashXPathScanner.cc | 80 + ++++++++++++++++++++++++-------------------- + 1 file changed, 43 insertions(+), 37 deletions(-) + +commit e34713a2187e05358f98e749ec2923210a40a862 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed Oct 5 15:57:17 2005 +0000 + + 2005-10-05 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc (poppler_page_render_to_ps): + Fix another + off-by-one page number error (#4555). + + ChangeLog | 5 +++++ + glib/poppler-page.cc | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit fdd0934430ed251f9aeb45158b6ec95684b3e7b4 +Author: Marco Pesenti Gritti <mpg@redhat.com> +Date: Mon Sep 26 19:29:45 2005 +0000 + + 2005-09-26 Marco Pesenti Gritti <mpg@redhat.com> + + * glib/poppler-action.cc: + + Initialize window title even if the action is unknown + + ChangeLog | 6 ++++++ + glib/poppler-action.cc | 5 +++-- + 2 files changed, 9 insertions(+), 2 deletions(-) + +commit e9753049ddfbdf28df7a222d35eccdbcbcbc848d +Author: Marco Pesenti Gritti <mpg@redhat.com> +Date: Mon Sep 26 10:42:38 2005 +0000 + + 2005-09-26 Marco Pesenti Gritti <mpg@redhat.com> + + * glib/poppler-action.cc: + * glib/poppler-action.h: + + Implement launch action + + ChangeLog | 7 +++++++ + glib/poppler-action.cc | 11 ++++++++--- + glib/poppler-action.h | 1 + + 3 files changed, 16 insertions(+), 3 deletions(-) + +commit ab18b2cb6d1c62bb91173d105e8631fe4ef1bcfb +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 20 15:27:31 2005 +0000 + + Parser.cc merges from xpdf 3.01 + + ChangeLog | 1 + + poppler/Parser.cc | 19 +++++++++++-------- + 2 files changed, 12 insertions(+), 8 deletions(-) + +commit cf6723caaed24615c3b8965cee9c433007f80d77 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 20 15:08:52 2005 +0000 + + TextPage *TextOutpudDev::takeText() from xpdf 3.01 + + ChangeLog | 1 + + poppler/TextOutputDev.cc | 8 ++++++++ + poppler/TextOutputDev.h | 4 ++++ + 3 files changed, 13 insertions(+) + +commit e0cbb0ca2c611ad5ac0267e46279c9d61450902a +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 20 14:59:43 2005 +0000 + + more 3.00 -> 3.01 merging + + ChangeLog | 1 + + poppler/XRef.cc | 1 - + 2 files changed, 1 insertion(+), 1 deletion(-) + +commit 9c7adb318d395ff674c6febf6406a8d47e9e5bf6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 20 14:43:15 2005 +0000 + + * poppler/UnicodeMap.cc: More grealloc -> greallocn + * poppler/UnicodeTypeTable.cc: Merge from xpdf 3.01 + + ChangeLog | 2 ++ + poppler/UnicodeMap.cc | 4 ++-- + poppler/UnicodeTypeTable.cc | 4 ++-- + 3 files changed, 6 insertions(+), 4 deletions(-) + +commit 2c4c9b855b0df1dc0836d4f44e9471215a419ea6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 20 14:34:31 2005 +0000 + + Merge link.cc changes from xpdf 3.00 -> 3.01 + + ChangeLog | 1 + + poppler/Link.cc | 64 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- + 2 files changed, 62 insertions(+), 3 deletions(-) + +commit 4e9490c0219dd9c99ba0e5533c96663b8570a87b +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 20 14:00:43 2005 +0000 + + Merge GlobalParam.* changes, they are worthless for us as poppler + but this way we are nearer to have the 3.01 sources merged, then we + can remove them if we decide we don't need this options. + Remove a setEncryption from the Xref.h marco probably forgot to + remove when merging + + ChangeLog | 3 +++ + poppler/GlobalParams.cc | 41 +++++++++++++++++++++++++++++++++++++++++ + poppler/GlobalParams.h | 22 ++++++++++++++++------ + poppler/XRef.h | 4 ---- + 4 files changed, 60 insertions(+), 10 deletions(-) + +commit 22da021bf69d83d641e3f30cc0e1bd62394e56a4 +Author: Marco Pesenti Gritti <mpg@redhat.com> +Date: Tue Sep 20 13:23:08 2005 +0000 + + 2005-09-20 Marco Pesenti Gritti <mpg@redhat.com> + + * poppler/XRef.cc: + + Remove duplicated initialization + + ChangeLog | 6 ++++++ + poppler/XRef.cc | 4 ---- + 2 files changed, 6 insertions(+), 4 deletions(-) + +commit 2a8778147938e3ed2af177226a9c35655f898c95 +Author: Marco Pesenti Gritti <mpg@redhat.com> +Date: Tue Sep 20 10:18:57 2005 +0000 + + 2005-09-20 Marco Pesenti Gritti <mpg@redhat.com> + + * poppler/GlobalParams.cc: + + s/G/Goo in not yet compiled plugins code + + ChangeLog | 6 ++++++ + poppler/GlobalParams.cc | 8 ++++---- + 2 files changed, 10 insertions(+), 4 deletions(-) + +commit 16f720b87cfc491db585dbdc99236cf492ffe85b +Author: Marco Pesenti Gritti <mpg@redhat.com> +Date: Tue Sep 20 09:57:41 2005 +0000 + + 2005-09-20 Marco Pesenti Gritti <mpg@redhat.com> + + * poppler/Makefile.am: + + Add XPDFPlugin*. Thanks to TSDgeos that noticed this. + + * poppler/XpdfPluginAPI.cc: + + Fixup + + ChangeLog | 10 ++++++++++ + poppler/Makefile.am | 4 +++- + poppler/XpdfPluginAPI.cc | 2 +- + 3 files changed, 14 insertions(+), 2 deletions(-) + +commit 5f30791c3d87315ad1f742de64d2c1351ca70cb7 +Author: Marco Pesenti Gritti <mpg@redhat.com> +Date: Fri Sep 16 19:33:28 2005 +0000 + + *** empty log message *** + + ChangeLog | 9 +++++++++ + 1 file changed, 9 insertions(+) + +commit db62e07fcf57f45951b21f8aab44b0d943efe5d0 +Author: Marco Pesenti Gritti <mpg@redhat.com> +Date: Fri Sep 16 19:33:05 2005 +0000 + + 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> + + * poppler/PDFDoc.cc: + * poppler/PDFDoc.h: + * poppler/XRef.cc: + * poppler/XRef.h: + + Merge more from 3.01 + + poppler/PDFDoc.cc | 20 ++++++++++++++++---- + poppler/PDFDoc.h | 19 +++++++++---------- + poppler/XRef.cc | 13 +++++++++++-- + poppler/XRef.h | 7 +++++-- + 4 files changed, 41 insertions(+), 18 deletions(-) + +commit 3acc7be594712fd0ce7ac07b7188d5b38b382782 +Author: Marco Pesenti Gritti <mpg@redhat.com> +Date: Fri Sep 16 19:05:00 2005 +0000 + + 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> + + * poppler/XRef.cc: + + Merge some initialization that I lost before + + ChangeLog | 6 ++++++ + poppler/XRef.cc | 4 ++++ + 2 files changed, 10 insertions(+) + +commit 3badd82b72b2768be27e309b048cd8dcb1c80038 +Author: Marco Pesenti Gritti <mpg@redhat.com> +Date: Fri Sep 16 18:46:37 2005 +0000 + + 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> + + * poppler/XRef.cc: + + Merge change from 3.01 + + ChangeLog | 6 ++++++ + poppler/XRef.cc | 8 -------- + 2 files changed, 6 insertions(+), 8 deletions(-) + +commit 5474583e20ca773befa17242d4ad7b8f81d5bf99 +Author: Marco Pesenti Gritti <mpg@redhat.com> +Date: Fri Sep 16 18:38:58 2005 +0000 + + 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> + + * poppler/CharCodeToUnicode.cc: + * poppler/CharCodeToUnicode.h: + + Improvements from xpdf 3.01 + + ChangeLog | 7 +++++++ + poppler/CharCodeToUnicode.cc | 31 +++++++++++++++++++------------ + poppler/CharCodeToUnicode.h | 4 ++++ + 3 files changed, 30 insertions(+), 12 deletions(-) + +commit b2a6eab113fecd3823885c64f3302bea4f372a9f +Author: Marco Pesenti Gritti <mpg@redhat.com> +Date: Fri Sep 16 18:37:29 2005 +0000 + + 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> + + * poppler/CMap.cc: + + Improvements from xpdf 3.01 + + ChangeLog | 6 ++++++ + poppler/CMap.cc | 30 +++++++++++++++++++++++++++--- + 2 files changed, 33 insertions(+), 3 deletions(-) + +commit 3f69f2158453b9dab9efc280ed1578ac3d0cebe8 +Author: Marco Pesenti Gritti <mpg@redhat.com> +Date: Fri Sep 16 18:35:29 2005 +0000 + + 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> + + * poppler/NameToUnicodeTable.h: + * poppler/UnicodeTypeTable.cc: + * poppler/UnicodeTypeTable.h: + + Merge some unicode table changes from xpdf 3.01 + + ChangeLog | 8 + + poppler/NameToUnicodeTable.h | 168 +++++------ + poppler/UnicodeTypeTable.cc | 690 + +++++++++++++++++++++++++++++++++++++++++-- + poppler/UnicodeTypeTable.h | 2 + + 4 files changed, 764 insertions(+), 104 deletions(-) + +commit 6cbe76bc55d557fe5fca0f8f1b33bda95acdc0e9 +Author: Marco Pesenti Gritti <mpg@redhat.com> +Date: Fri Sep 16 18:32:29 2005 +0000 + + 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> + + * poppler/SplashOutputDev.h: + * splash/Splash.cc: + * splash/Splash.h: + + Modified region support from xpdf 3.01 + + ChangeLog | 8 ++++++++ + poppler/SplashOutputDev.h | 5 +++++ + splash/Splash.cc | 31 +++++++++++++++++++++++++++++++ + splash/Splash.h | 11 +++++++++++ + 4 files changed, 55 insertions(+) + +commit a9df3f3203c14161e5d6bc6048ec7e123536e6d3 +Author: Marco Pesenti Gritti <mpg@redhat.com> +Date: Fri Sep 16 18:29:18 2005 +0000 + + 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> + + * goo/Makefile.am: + * poppler/DCTStream.h: + * poppler/Decrypt.cc: + * poppler/Decrypt.h: + * poppler/FlateStream.h: + * poppler/GlobalParams.cc: + * poppler/GlobalParams.h: + * poppler/Makefile.am: + * poppler/PDFDoc.cc: + * poppler/PDFDoc.h: + * poppler/Parser.cc: + * poppler/Parser.h: + * poppler/Stream.cc: + * poppler/Stream.h: + * poppler/XRef.cc: + * poppler/XRef.h: + * poppler/poppler-config.h.in: + + Merge security plugins support from xpdf 3.01 + + ChangeLog | 24 +++ + goo/FixedPoint.cc | 95 +++++++++++ + goo/FixedPoint.h | 150 ++++++++++++++++++ + goo/Makefile.am | 6 +- + poppler/DCTStream.h | 2 - + poppler/Decrypt.cc | 23 ++- + poppler/Decrypt.h | 6 +- + poppler/FlateStream.h | 2 - + poppler/GlobalParams.cc | 229 +++++++++++++++++++++++++++ + poppler/GlobalParams.h | 16 ++ + poppler/Makefile.am | 5 +- + poppler/PDFDoc.cc | 36 +++++ + poppler/PDFDoc.h | 1 + + poppler/Parser.cc | 20 --- + poppler/Parser.h | 4 - + poppler/SecurityHandler.cc | 376 + ++++++++++++++++++++++++++++++++++++++++++++ + poppler/SecurityHandler.h | 157 ++++++++++++++++++ + poppler/Stream.cc | 18 --- + poppler/Stream.h | 8 - + poppler/XRef.cc | 162 ++----------------- + poppler/XRef.h | 13 +- + poppler/XpdfPluginAPI.cc | 262 ++++++++++++++++++++++++++++++ + poppler/XpdfPluginAPI.h | 341 +++++++++++++++++++++++++++++++++++++++ + poppler/poppler-config.h.in | 2 - + 24 files changed, 1737 insertions(+), 221 deletions(-) + +commit a777e5c26483b90d0910e85c2be666640835d0bf +Author: Marco Pesenti Gritti <mpg@redhat.com> +Date: Fri Sep 16 18:21:38 2005 +0000 + + 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> + + * configure.ac: + * goo/Makefile.am: + * splash/Makefile.am: + * splash/SplashFTFont.cc: + * splash/SplashMath.h: + * splash/SplashTypes.h: + + Merge support for fixed point + + ChangeLog | 11 +++++++++++ + configure.ac | 4 ++++ + splash/Makefile.am | 1 + + splash/SplashFTFont.cc | 7 +++++++ + splash/SplashMath.h | 34 +++++++++++++++++++++++++++++++++- + splash/SplashTypes.h | 5 +++++ + 6 files changed, 61 insertions(+), 1 deletion(-) + +commit 00457c5f44a246c9f867a114a72be9f7b2dc1cf5 +Author: Marco Pesenti Gritti <mpg@redhat.com> +Date: Fri Sep 16 18:11:14 2005 +0000 + + 2005-09-16 Marco Pesenti Gritti <mpg@redhat.com> + + * poppler/ArthurOutputDev.cc: + * poppler/CairoFontEngine.cc: + * poppler/TextOutputDev.cc: + * poppler/UnicodeMap.cc: + + Use mallocn when possible + + ChangeLog | 9 +++++++++ + poppler/ArthurOutputDev.cc | 2 +- + poppler/CairoFontEngine.cc | 4 ++-- + poppler/TextOutputDev.cc | 2 +- + poppler/UnicodeMap.cc | 2 +- + 5 files changed, 14 insertions(+), 5 deletions(-) + +commit 09c9ff67ceae5753811a2f625e3ad810628c782e +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 16 18:00:43 2005 +0000 + + SplashXPath.cc merges from xpdf 3.00 -> 3.01 + + ChangeLog | 3 ++ + splash/SplashXPath.cc | 81 + +++++++++++++++++++++++++-------------------------- + 2 files changed, 42 insertions(+), 42 deletions(-) + +commit 0555ba861d3b84d88c80da4fa247274338ff7817 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 16 17:42:56 2005 +0000 + + SplashFontEngine.cc merge from xpdf 3.00 -> 3.01 + + splash/SplashFontEngine.cc | 8 ++++++++ + 1 file changed, 8 insertions(+) + +commit ddc72bd8354168d992631d1ef8cd0939b428966c +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 15 22:24:55 2005 +0000 + + Merge xpdf 3.00 -> 3.01 changes in SplashT1Font.* files + + splash/SplashT1Font.cc | 23 ++++++++++++++++++----- + splash/SplashT1Font.h | 2 ++ + 2 files changed, 20 insertions(+), 5 deletions(-) + +commit ba409db3157105f326b4bbc342ca7af859a44ce9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 15 22:20:37 2005 +0000 + + Merge xpdf 3.00 -> 3.01 changes in SplashPath.* files + + splash/SplashPath.cc | 3 ++- + splash/SplashPath.h | 5 +++++ + 2 files changed, 7 insertions(+), 1 deletion(-) + +commit 3ea00e853049d8c26ee88aaef8ea6c47c8d46956 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 15 22:15:47 2005 +0000 + + Merge xpdf 3.00 -> 3.01 changes in SplashFont.* files + + splash/SplashFont.cc | 6 ++++++ + splash/SplashFont.h | 10 +++++++++- + 2 files changed, 15 insertions(+), 1 deletion(-) + +commit e571dcbfd0c77a28e41710577859f632cc989de5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 15 22:09:50 2005 +0000 + + Merge the xpdf 3.01 change that uses runtime detection of freetype + version + + ChangeLog | 6 ++++++ + configure.ac | 14 +++----------- + poppler/CairoFontEngine.cc | 21 ++++++++++++++------- + poppler/CairoFontEngine.h | 3 ++- + splash/SplashFTFontEngine.cc | 19 +++++++++++-------- + splash/SplashFTFontEngine.h | 1 + + 6 files changed, 37 insertions(+), 27 deletions(-) + +commit 59fe2937db192dc7b59bf28c3f29909faf11aae3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 15 21:51:16 2005 +0000 + + Merge xpdf 3.00 -> 3.01 changes for that file + + splash/SplashClip.h | 9 +++++++++ + 1 file changed, 9 insertions(+) + +commit b2f94635249f2c5f0c876a1005826fe4c6eb6025 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 15 12:52:36 2005 +0000 + + Merge xpdf 3.00 -> xpdf 3.01 changes for Catalog.[cc|h] + + poppler/Catalog.cc | 5 ++++- + poppler/Catalog.h | 3 +++ + 2 files changed, 7 insertions(+), 1 deletion(-) + +commit 0fc2e70576b1c48cf47a686e8aa7e202a802bc9d +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 15 12:32:25 2005 +0000 + + Another small merge from xpdf 3.01 + + ChangeLog | 3 +++ + poppler/Outline.cc | 6 +++--- + 2 files changed, 6 insertions(+), 3 deletions(-) + +commit f8983ceb3c55df72c94870806d71db139c11bdeb +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 15 12:28:34 2005 +0000 + + Another small xpdf 3.00 -> xpdf 3.01 merge + + poppler/Object.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 52efe9845cf3eb1dd836f90bfa203760baa2f87c +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 15 11:46:56 2005 +0000 + + bradh forgot to remove the two returns when merging xpdf 3.00 -> + xpdf 3.01 changes of this file + + poppler/JPXStream.cc | 2 -- + 1 file changed, 2 deletions(-) + +commit 4b4fc5c017bf147c9069bbce32fc14467bd2a81a +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 14 21:20:36 2005 +0000 + + Merge all the fofi/ changes from xpdf 3.01, there is only one api + change that affects PSOutputDev (also has been updated the part + that uses this api not the whole file). All our fixes in that dir + are included in the upgrade. + + ChangeLog | 4 + + fofi/FoFiTrueType.cc | 406 + +++++++++++++++++++++++++++++++++++++++++++------ + fofi/FoFiTrueType.h | 15 +- + fofi/FoFiType1.cc | 25 ++- + fofi/FoFiType1C.cc | 134 +++++++++++++--- + fofi/FoFiType1C.h | 6 + + poppler/PSOutputDev.cc | 7 +- + poppler/PSOutputDev.h | 3 +- + 8 files changed, 515 insertions(+), 85 deletions(-) + +commit a68e8e6330418b1f623867973b9c128a9a139c0c +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed Sep 7 03:00:36 2005 +0000 + + 2005-09-06 Kristian Høgsberg <krh@redhat.com> + + * configure.ac: Enable A4_PAPER and OPI_SUPPORT by default. + There + is no reason to not enable OPI and the paper size should be + controlled by the application. + + * test/Makefile.am (EXTRA_DIST): Add pdf-operators.c + + ChangeLog | 8 ++++++++ + configure.ac | 17 ++--------------- + test/Makefile.am | 3 +++ + 3 files changed, 13 insertions(+), 15 deletions(-) + +commit b6490944c081ff53f623acea7ab7a600c3e54816 +Author: Brad Hards <bradh@frogmouth.net> +Date: Sat Sep 3 11:53:44 2005 +0000 + + Switch the qt4/tests unittests to use QtTestLib. + + ChangeLog | 6 ++ + configure.ac | 66 +++++++++++++++++++++ + qt4/tests/.cvsignore | 17 ++---- + qt4/tests/Makefile.am | 71 ++++++++-------------- + qt4/tests/README.unittest | 23 ++++++++ + qt4/tests/check_author.cpp | 25 -------- + qt4/tests/check_linearised.cpp | 23 -------- + qt4/tests/check_metadata.cpp | 101 + ++++++++++++++++++++++++++++++++ + qt4/tests/check_orientation.cpp | 40 ------------- + qt4/tests/check_pagelayout.cpp | 44 ++++++++++++++ + qt4/tests/check_pagelayout_facing.cpp | 22 ------- + qt4/tests/check_pagelayout_none.cpp | 22 ------- + qt4/tests/check_pagelayout_single.cpp | 22 ------- + qt4/tests/check_pagemode.cpp | 64 ++++++++++++++++++++ + qt4/tests/check_pagemode_attach.cpp | 22 ------- + qt4/tests/check_pagemode_fullscreen.cpp | 22 ------- + qt4/tests/check_pagemode_none.cpp | 22 ------- + qt4/tests/check_pagemode_oc.cpp | 22 ------- + qt4/tests/check_pagemode_thumbs.cpp | 22 ------- + qt4/tests/check_permissions.cpp | 60 +++++++------------ + 20 files changed, 354 insertions(+), 362 deletions(-) + +commit 3725841417871d1051772068833dc908ca70b7ce +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Sep 2 14:47:24 2005 +0000 + + 2005-09-02 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc: Apply Marcos rotation fix. + + ChangeLog | 4 ++++ + glib/poppler-page.cc | 5 ++++- + 2 files changed, 8 insertions(+), 1 deletion(-) + +commit ecf3dcadb948013cbc987e464952933daf78e4bf +Author: Brad Hards <bradh@frogmouth.net> +Date: Wed Aug 31 15:28:46 2005 +0000 + + Merge some missing parts of previous patches, and some other minor + cleanups from xpdf 3.0.1 + + poppler/Catalog.cc | 16 +-- + poppler/JPXStream.cc | 380 + +++++++++++++++++++++++++++++++++---------------- + poppler/JPXStream.h | 25 ++-- + poppler/Lexer.cc | 11 ++ + poppler/Lexer.h | 3 + + poppler/PSOutputDev.cc | 31 ++-- + poppler/Stream.h | 7 + + 7 files changed, 309 insertions(+), 164 deletions(-) + +commit de78738164319b733e54a9abfb5957870facd6cd +Author: Brad Hards <bradh@frogmouth.net> +Date: Wed Aug 31 09:51:41 2005 +0000 + + poppler/JArithmeticDecoder.cc + poppler/JArithmeticDecoder.h + poppler/JBIG2Stream.cc + poppler/JBIG2Stream.h: merge in some of the JBIG2 changes from + xpdf 3.0.1. + + ChangeLog | 9 ++ + poppler/JArithmeticDecoder.cc | 42 ++++++-- + poppler/JArithmeticDecoder.h | 22 +++- + poppler/JBIG2Stream.cc | 227 + +++++++++++++++++++++++++----------------- + poppler/JBIG2Stream.h | 4 +- + 5 files changed, 201 insertions(+), 103 deletions(-) + +commit 55952feb637e300b073691ae95d68e766521a769 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Aug 29 15:24:32 2005 +0000 + + 2005-08-29 Kristian Høgsberg <krh@redhat.com> + + * configure.ac (HAVE_FREETYPE_H): Patch from Hiroyuki + Ikezoe: Set + HAVE_FREETYPE_217_OR_OLDER to 0 if we found freetype using + pkg-config (#4223). + + ChangeLog | 6 ++++++ + configure.ac | 2 +- + 2 files changed, 7 insertions(+), 1 deletion(-) + +commit 244e5c1f8f65da41ba6314028766dfe5973f6132 +Author: Brad Hards <bradh@frogmouth.net> +Date: Sun Aug 28 09:43:18 2005 +0000 + + Merge the Goo* improvements from xpdf 3.0.1. This change is based on + martink's work (7-xpdf-3.01-goo-improvements.patch), with some + tweaking + by me. + + ChangeLog | 13 ++++++++ + fofi/FoFiTrueType.cc | 1 + + goo/GooHash.cc | 24 +++++++++++++++ + goo/GooHash.h | 2 ++ + goo/GooList.cc | 5 ++++ + goo/GooList.h | 5 ++++ + goo/GooString.cc | 85 + +++++++++++++++++++++++++++++++++++++++++++++++++++- + goo/GooString.h | 11 +++---- + goo/gmem.c | 3 ++ + poppler/Decrypt.cc | 1 + + 10 files changed, 142 insertions(+), 8 deletions(-) + +commit eb91b274245b4f5f5389bc9ddfde2c2806557665 +Author: Brad Hards <bradh@frogmouth.net> +Date: Sun Aug 28 09:31:53 2005 +0000 + + This part of my previous gmallocn merge patch was missing. + + goo/GooHash.cc | 4 ++-- + goo/GooList.cc | 8 ++++---- + 2 files changed, 6 insertions(+), 6 deletions(-) + +commit b3474fd5e0efc96b5814d86e0cdedf39387e7ae3 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sun Aug 28 03:26:53 2005 +0000 + + add note about related bug + + ChangeLog | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit ace2eb6ba518b970b96f30f61c4795c161e0cb79 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sun Aug 28 03:22:04 2005 +0000 + + 2005-08-27 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/FlateStream.cc: Fix predictor leak. + + ChangeLog | 4 ++++ + poppler/FlateStream.cc | 1 + + 2 files changed, 5 insertions(+) + +commit 96657c5480bf2ecf445ad5a105b8e7393ae53c8b +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sun Aug 28 03:19:55 2005 +0000 + + 2005-08-27 Jeff Muizelaar <jeff@infidigm.net> + + * configure.ac: Disable the zlib-based decoder by default. + + ChangeLog | 4 ++++ + configure.ac | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +commit d1d715158223c7ca3ae279cea420a948cfdb0428 +Author: Brad Hards <bradh@frogmouth.net> +Date: Sat Aug 27 08:43:42 2005 +0000 + + Merge the gmalloc -> gmallocn changes from xpdf 3.0.1. This change is + based on martink's work (13-xpdf-3.01-goo-allocn.patch) with some + tweaking by me. There may be some residual gmallocn changes still to + be merged. + + ChangeLog | 7 ++++++ + fofi/FoFiTrueType.cc | 12 +++++----- + fofi/FoFiType1.cc | 2 +- + fofi/FoFiType1C.cc | 14 +++++------ + goo/gmem.c | 22 ++++++++++++++++++ + goo/gmem.h | 9 ++++++++ + poppler/Annot.cc | 2 +- + poppler/Array.cc | 2 +- + poppler/BuiltinFont.cc | 2 +- + poppler/CMap.cc | 6 ++--- + poppler/Catalog.cc | 8 +++---- + poppler/CharCodeToUnicode.cc | 22 +++++++++--------- + poppler/Dict.cc | 2 +- + poppler/Function.cc | 20 ++++++++-------- + poppler/Gfx.cc | 2 +- + poppler/GfxFont.cc | 24 +++++++++---------- + poppler/GfxState.cc | 54 + +++++++++++++++++++++---------------------- + poppler/JArithmeticDecoder.cc | 2 +- + poppler/JBIG2Stream.cc | 30 ++++++++++++------------ + poppler/Link.cc | 6 ++--- + poppler/NameToCharCode.cc | 4 ++-- + poppler/Outline.cc | 4 ++-- + poppler/SplashOutputDev.cc | 8 +++---- + poppler/Stream.cc | 12 +++++----- + poppler/TextOutputDev.cc | 48 +++++++++++++++++++------------------- + poppler/XRef.cc | 18 +++++++-------- + splash/SplashClip.cc | 12 +++++----- + splash/SplashFTFontFile.cc | 2 +- + splash/SplashFont.cc | 6 ++--- + splash/SplashPath.cc | 8 +++---- + splash/SplashScreen.cc | 4 ++-- + splash/SplashState.cc | 4 ++-- + splash/SplashT1FontFile.cc | 4 ++-- + splash/SplashXPath.cc | 4 ++-- + splash/SplashXPathScanner.cc | 4 ++-- + 35 files changed, 214 insertions(+), 176 deletions(-) + +commit feb82c60b1f86a9d1260db57534d98c54ee615c4 +Author: Martin Kretzschmar <martink@gnome.org> +Date: Wed Aug 24 19:41:27 2005 +0000 + + * configure.ac: add /usr/include/qt4 to qt4_incdirs. That's what + Debian and Ubuntu use. Maybe we should just use pkg-config. If + it's usable with qt4. + + * test/.cvsignore: ignore pdf_inspector binary. + + ChangeLog | 8 ++++++++ + configure.ac | 2 +- + test/.cvsignore | 7 ++++--- + 3 files changed, 13 insertions(+), 4 deletions(-) + +commit 8dce80eb74f24f07ac7668905f1631e04a9c5841 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed Aug 24 18:57:46 2005 +0000 + + 2005-08-24 Kristian Høgsberg <krh@redhat.com> + + * poppler/TextOutputDev.cc: Push rotation argument down to + GfxState constructor. This is still not completely + functional yet. + + * glib/poppler-page.cc (poppler_page_render_selection): Add + rotation argument so API is useful. Not yet implemented. + (poppler_page_prepare_output_dev): Patch from Marco to fix + rotation using the cairo backend. + + ChangeLog | 10 ++++++++++ + glib/poppler-page.cc | 22 ++++++++++++++++------ + glib/poppler-page.h | 1 + + poppler/TextOutputDev.cc | 11 ++++++++--- + poppler/TextOutputDev.h | 4 +++- + 5 files changed, 38 insertions(+), 10 deletions(-) + +commit b909b5ae98bc3e557ef6e658e2b9120e82951259 +Author: Jonathan Blandford <jrb@redhat.com> +Date: Wed Aug 24 03:21:20 2005 +0000 + + Tue Aug 23 17:21:02 2005 Jonathan Blandford <jrb@redhat.com> + + * test/Makefile.am (gtk_cairo_test_LDADD): add + FREETYPE_{CFLAGS,LIBS} to the cairo deps + + ChangeLog | 5 +++++ + test/Makefile.am | 4 +++- + 2 files changed, 8 insertions(+), 1 deletion(-) + +commit da3aac379f07ffedd6078707ec9923800fc0c0a5 +Author: Jonathan Blandford <jrb@redhat.com> +Date: Tue Aug 23 18:20:45 2005 +0000 + + Tue Aug 23 13:38:01 2005 Jonathan Blandford <jrb@redhat.com> + + * configure.ac: + * poppler/Gfx.cc: + * poppler/Gfx.h: + * poppler/GlobalParams.cc: + * poppler/GlobalParams.h: + * poppler/Makefile.am: + * poppler/OutputDev.cc: + * poppler/OutputDev.h: + * poppler/ProfileData.cc: + * poppler/ProfileData.h: + * test/Makefile.am: + * test/pdf-inspector.cc: + * test/pdf-inspector.glade: + * test/pdf-operators.c: Initial cut at a pdf inspector. This + should help us look at PDF files. + + ChangeLog | 18 ++ + configure.ac | 4 +- + poppler/Gfx.cc | 30 ++++ + poppler/Gfx.h | 1 + + poppler/GlobalParams.cc | 16 ++ + poppler/GlobalParams.h | 3 + + poppler/Makefile.am | 2 + + poppler/OutputDev.cc | 17 ++ + poppler/OutputDev.h | 10 +- + poppler/ProfileData.cc | 44 +++++ + poppler/ProfileData.h | 41 +++++ + test/Makefile.am | 13 +- + test/pdf-inspector.cc | 358 ++++++++++++++++++++++++++++++++++++++ + test/pdf-inspector.glade | 434 + +++++++++++++++++++++++++++++++++++++++++++++++ + test/pdf-operators.c | 81 +++++++++ + 15 files changed, 1068 insertions(+), 4 deletions(-) + +commit 1aad886c6c19a964a3fc9e18f31acc8e115478e0 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Aug 22 18:20:12 2005 +0000 + + 2005-08-22 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc: + * glib/poppler-page.h: + * glib/poppler-private.h: + * glib/test-poppler-glib.c: Patch from Marco to simplify + the glib + rotation API. + + ChangeLog | 8 +++ + glib/poppler-page.cc | 136 + +++++++---------------------------------------- + glib/poppler-page.h | 4 +- + glib/poppler-private.h | 1 - + glib/test-poppler-glib.c | 2 +- + 5 files changed, 28 insertions(+), 123 deletions(-) + +commit 6070b1dc4b76c236f3100fbd255c2d906e61c3c2 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sun Aug 21 23:14:04 2005 +0000 + + 2005-08-21 Kristian Høgsberg <krh@redhat.com> + + * poppler/Makefile.am (INCLUDES): Add FREETYPE_CFLAGS. + + * configure.ac: Make freetype check use pkg-config if + possible. + + ChangeLog | 6 ++++++ + configure.ac | 34 ++++++++++++++++++++++++---------- + poppler/Makefile.am | 1 + + 3 files changed, 31 insertions(+), 10 deletions(-) + +commit 2698ca6fa107ea91dc01eb8cfb0c93383fbca125 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed Aug 17 16:54:01 2005 +0000 + + 2005-08-17 Kristian Høgsberg <krh@redhat.com> + + * poppler/GfxFont.cc: Add fix discussed in #3131 to only + use the + MacRoman char map if the font has one or the font dicts + specifies + /MacRoman. + + ChangeLog | 6 ++++++ + poppler/GfxFont.cc | 1 - + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit 5dc9b14b99f2efa2fe018e9267dd363d1bcd78b1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 7 23:58:12 2005 +0000 + + Fix EOF checking + + ChangeLog | 4 ++++ + poppler/PDFDoc.cc | 10 +++++++++- + 2 files changed, 13 insertions(+), 1 deletion(-) + +commit 155d019d7b474f244a3e4bf64d192015f6a266c4 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sat Aug 6 18:09:51 2005 +0000 + + 2005-08-06 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc: + * glib/poppler-page.h: Use GdkColor for specifying selection + colors, we alreay depend on GDK anyway. + + ChangeLog | 6 ++++++ + glib/poppler-page.cc | 20 +++++++++----------- + glib/poppler-page.h | 5 +++-- + 3 files changed, 18 insertions(+), 13 deletions(-) + +commit c710b645c8297d356c101b13a9889bcaba691176 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Aug 6 11:58:59 2005 +0000 + + Update comment + + poppler/PDFDoc.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit de7953c8a8360d8bfc99298906c5fc1094684fc3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Aug 6 11:47:37 2005 +0000 + + Increase EOF searching up to last 1024 characters + + ChangeLog | 7 +++++++ + poppler/PDFDoc.cc | 23 +++++++++++++---------- + 2 files changed, 20 insertions(+), 10 deletions(-) + +commit 5dd72618688763b50d5f5738d857c9294ef1b1c2 +Author: Brad Hards <bradh@frogmouth.net> +Date: Sat Aug 6 02:15:58 2005 +0000 + + Add password arguments to document constructor. + + ChangeLog | 4 ++++ + qt4/src/poppler-document.cc | 8 ++++++-- + qt4/src/poppler-qt4.h | 4 +++- + 3 files changed, 13 insertions(+), 3 deletions(-) + +commit edbd7957b393eb63f48df7db6b220b355d4fc461 +Author: Brad Hards <bradh@frogmouth.net> +Date: Sat Aug 6 02:07:55 2005 +0000 + + Make API extraction work again. + + ChangeLog | 3 +++ + qt4/src/Doxyfile | 2 +- + 2 files changed, 4 insertions(+), 1 deletion(-) + +commit f43a6f1d1c27c042f5736746c94430083baa4c1d +Author: Brad Hards <bradh@frogmouth.net> +Date: Sat Aug 6 01:53:06 2005 +0000 + + Add new test code for encrypted files. + + ChangeLog | 5 ++ + qt4/tests/.cvsignore | 1 + + qt4/tests/Makefile.am | 7 ++- + qt4/tests/test-password-qt4.cpp | 135 + ++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 147 insertions(+), 1 deletion(-) + +commit 2ec26afaf80864b023899b890b8e229448da9bed +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Aug 5 22:30:20 2005 +0000 + + 2005-08-05 Kristian Høgsberg <krh@redhat.com> + + * poppler/TextOutputDev.cc (visitLine): Round selection + coordinates in device space, so selection isn't fuzzy. + + * poppler/GfxState.cc: + * poppler/GfxState.h: Add simple Matrix class. + + ChangeLog | 8 ++++++++ + poppler/CairoOutputDev.cc | 6 +++--- + poppler/GfxState.cc | 26 ++++++++++++++++++++++++++ + poppler/GfxState.h | 10 ++++++++++ + poppler/TextOutputDev.cc | 14 ++++++++++++++ + 5 files changed, 61 insertions(+), 3 deletions(-) + +commit ccba4f0773047eea5e4ad0ac736450160dd97664 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Aug 5 19:04:36 2005 +0000 + + 2005-08-05 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc: + * glib/poppler-page.h: + * poppler/TextOutputDev.cc: + * poppler/TextOutputDev.h: Propagate selection colors to + the glib API. + + ChangeLog | 7 ++++++ + glib/poppler-page.cc | 63 + ++++++++++++++++++++++++++++++++++++++++++------ + glib/poppler-page.h | 4 ++- + poppler/TextOutputDev.cc | 25 +++++++++---------- + poppler/TextOutputDev.h | 7 ++++-- + 5 files changed, 82 insertions(+), 24 deletions(-) + +commit 43e97129393f403c41f191ceae9a54793ece005f +Author: Brad Hards <bradh@frogmouth.net> +Date: Thu Aug 4 10:15:23 2005 +0000 + + Fix problem with drawing filled objects that was introduced in + Rev 1.4. + + ChangeLog | 5 +++++ + poppler/ArthurOutputDev.cc | 13 +++++++++++-- + 2 files changed, 16 insertions(+), 2 deletions(-) + +commit a75d80333a70d2e1ac7c9032d316034eebed9dd6 +Author: Brad Hards <bradh@frogmouth.net> +Date: Wed Aug 3 11:44:55 2005 +0000 + + Implement paging ability for Qt4, more than a little based + on Albert's work for Qt3. + Up arrow -> previous page + Down arrow -> next page + q -> quit. + + What more could you want from a PDF viewer :-) + + ChangeLog | 6 ++++++ + qt4/tests/test-poppler-qt4.cpp | 47 + +++++++++++++++++++++++++++++++++--------- + 2 files changed, 43 insertions(+), 10 deletions(-) + +commit f3e0a163b098da1cc389c2c4f47e28358b1bec77 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Aug 1 19:15:40 2005 +0000 + + Fix problem in the patch to fix #3299 + + ChangeLog | 4 ++++ + poppler/DCTStream.cc | 15 ++++++++++----- + poppler/DCTStream.h | 1 + + 3 files changed, 15 insertions(+), 5 deletions(-) + +commit 5f7bd81bedd8c90e3312190256488ff0c15502e1 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Aug 1 15:21:19 2005 +0000 + + 2005-08-01 Kristian Høgsberg <krh@redhat.com> + + Patch from Dan Winship <danw@novell.com> + + * glib/poppler-page.cc (poppler_page_copy_to_pixbuf): Set + alpha to + 0xff (opaque), not 0x00. + + ChangeLog | 7 +++++++ + glib/poppler-page.cc | 2 +- + 2 files changed, 8 insertions(+), 1 deletion(-) + +commit 22f509e60f60ccaea1f91d9ec1ef7ba8200bee8a +Author: Brad Hards <bradh@frogmouth.net> +Date: Mon Aug 1 08:09:00 2005 +0000 + + Fix up the fill problem with drawing text, where the "middle" + of glyphs + with a "hole" (like d, o, p, b, g) got filled. Also remove some + debugging + code. The glyphs are still ugly though. + + ChangeLog | 7 +++++++ + poppler/ArthurOutputDev.cc | 13 +------------ + 2 files changed, 8 insertions(+), 12 deletions(-) + +commit 7bf5d10c1f6edd538769c3a83a3b3d5df56d604b +Author: Brad Hards <bradh@frogmouth.net> +Date: Sun Jul 31 09:54:04 2005 +0000 + + An initial version of proper font handling, heavily based on work by + Albert Astals Cid. I changed it to stroke the glyphs based on the + SplashPath. In the longer term, Arthur should use FreeType paths + directly - hopefully that will be less ugly, and not fill everything. + + ChangeLog | 8 + + poppler/ArthurOutputDev.cc | 401 + ++++++++++++++++++++++++++++++++------------- + poppler/ArthurOutputDev.h | 15 +- + qt4/src/poppler-page.cc | 2 +- + splash/SplashPath.h | 2 + + 5 files changed, 314 insertions(+), 114 deletions(-) + +commit 8567b794628786b82e8db2a7daf75e4ad2398960 +Author: Brad Hards <bradh@frogmouth.net> +Date: Fri Jul 29 12:15:19 2005 +0000 + + Add some more test cases. + + ChangeLog | 4 ++++ + qt4/tests/.cvsignore | 4 ++++ + qt4/tests/Makefile.am | 10 +++++++++- + qt4/tests/check_pagelayout_facing.cpp | 22 ++++++++++++++++++++++ + qt4/tests/check_version.cpp | 22 ++++++++++++++++++++++ + 5 files changed, 61 insertions(+), 1 deletion(-) + +commit 59d660cf4d614fdea09d6a62b8889f7682c2b4f9 +Author: Brad Hards <bradh@frogmouth.net> +Date: Fri Jul 29 11:41:14 2005 +0000 + + Compile fix associated with last change. + + poppler/ArthurOutputDev.cc | 2 -- + 1 file changed, 2 deletions(-) + +commit 88c57c73f57820d6a57e26825093fbc688845e67 +Author: Brad Hards <bradh@frogmouth.net> +Date: Fri Jul 29 11:24:42 2005 +0000 + + A couple of minor changes to the Arthur backend. + + ChangeLog | 9 +++++++++ + poppler/ArthurOutputDev.cc | 18 ++++++++++++++---- + 2 files changed, 23 insertions(+), 4 deletions(-) + +commit 481db9d9eae5ea16e5b382f4ad21e6e624a70dcf +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Jul 29 05:48:33 2005 +0000 + + 2005-07-29 Kristian Høgsberg <krh@redhat.com> + + * poppler/TextOutputDev.cc: Finish TextSelectionDumper + class for + extracting the text from a selection. Add + TextPage::getSelectionText() and + TextOutputDev::getSelectionText() + methods to expose the new functionality. + + * glib/poppler-page.cc (poppler_page_get_text): Use + TextOutputDev::getSelectionText() to get the text from the + selection. + + * glib/poppler-document.cc (poppler_document_new_from_file): + * glib/poppler-page.cc (_poppler_page_new): Add extra NULL to + g_object_new() constructor to silence gcc warning about + missing + sentinel. + + ChangeLog | 16 +++++ + glib/poppler-document.cc | 2 +- + glib/poppler-page.cc | 31 +++++---- + poppler/TextOutputDev.cc | 164 + +++++++++++++++++++++++++++++++++++------------ + poppler/TextOutputDev.h | 8 +++ + 5 files changed, 164 insertions(+), 57 deletions(-) + +commit ad312dbded4e8f70c3a2eac9a0964fa00ecb6b2c +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jul 28 22:56:17 2005 +0000 + + Fix memory leaks in PageLabelInfo.cc + + ChangeLog | 4 ++++ + poppler/PageLabelInfo.cc | 11 +++++++++++ + poppler/PageLabelInfo.h | 2 ++ + 3 files changed, 17 insertions(+) + +commit b45ad9f3409d7b1ed147135a70553e5255913c61 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jul 28 20:53:36 2005 +0000 + + - delete family; + + delete[] family; + as family is new[]'ed + + When assigning family if the font had "the proper info" and family + had to be deleted, do it. + + poppler/GlobalParams.cc | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +commit f93dfc5c5133e0b1bd9f4786cfe18bd796cbac2a +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jul 28 18:51:17 2005 +0000 + + Remove the debugging + + poppler/GlobalParams.cc | 5 ----- + 1 file changed, 5 deletions(-) + +commit 8022315004e1623c0be320f7671fcd72c15c0de3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jul 28 18:37:17 2005 +0000 + + Wonder how that slipped here + + poppler/GlobalParams.cc | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit 82638babe89e402c0348619ec3205059b977c7e9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Jul 28 17:34:19 2005 +0000 + + Fontconfig patch is here, rejoice + + ChangeLog | 15 +- + glib/poppler-document.cc | 1 - + poppler/CairoFontEngine.cc | 95 +-------- + poppler/CairoFontEngine.h | 2 - + poppler/CairoOutputDev.cc | 4 - + poppler/GlobalParams.cc | 473 + ++++++++++++++++++++------------------------ + poppler/GlobalParams.h | 17 +- + poppler/SplashOutputDev.cc | 132 +------------ + poppler/SplashOutputDev.h | 3 - + qt/poppler-document.cc | 1 - + qt4/src/poppler-document.cc | 1 - + test/gtk-cairo-test.cc | 1 - + test/gtk-splash-test.cc | 1 - + 13 files changed, 241 insertions(+), 505 deletions(-) + +commit e9015531b1d0e5f2c8d8ca2bc50d5f14aaf954bc +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Jul 28 06:31:57 2005 +0000 + + 2005-07-28 Kristian Høgsberg <krh@redhat.com> + + * poppler/poppler-config.h.in: Add GCC_PRINTF_FORMAT macro to + annotate printf-like functions (#3638). + + * poppler/Error.h: Add GCC_PRINTF_FORMAT to error(). + + * poppler/PSOutputDev.h: Add GCC_PRINTF_FORMAT to + PSOutputDev::writePSFmt(). + + * poppler/PSOutputDev.cc, poppler/GlobalParams.cc: Quiet new + printf warnings. + + ChangeLog | 11 +++++++++++ + poppler/Error.h | 2 +- + poppler/GlobalParams.cc | 3 ++- + poppler/PSOutputDev.cc | 3 +-- + poppler/PSOutputDev.h | 2 +- + poppler/TextOutputDev.cc | 13 ++++++++++++- + poppler/poppler-config.h.in | 12 ++++++++++++ + 7 files changed, 40 insertions(+), 6 deletions(-) + +commit 9df89c495683e229b771b3d008ed25d478465c35 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Jul 28 05:52:43 2005 +0000 + + 2005-07-28 Kristian Høgsberg <krh@redhat.com> + + * poppler/TextOutputDev.cc (TextBlock::visitSelection): Assign + start and stop coordinates in one place so we don't assign the + same point to both in some corner cases. + (TextWord::visitSelection): Initialize begin to len, not + len + 1 + to fix crash. + + (TextWord::visitSelection, TextLine::visitSelection): Change + selection trigger; now midpoint of glyph must be included in + selection area for glyph to be in selection. + + ChangeLog | 12 +++++ + poppler/CairoOutputDev.cc | 2 +- + poppler/TextOutputDev.cc | 113 + ++++++++++++++++++++++------------------------ + 3 files changed, 67 insertions(+), 60 deletions(-) + +commit a3d9b5849cedf1316c6fc5859872e957f3f7b593 +Author: Martin Kretzschmar <martink@gnome.org> +Date: Wed Jul 27 19:21:08 2005 +0000 + + * poppler/PSOutputDev.cc (PSOutputDev): change the constructor to + take paper size and duplex setting parameters. + (init): add paper size and duplex parameters. + (writeDocSetup): add duplex parameter. + + * poppler/PSOutputDev.h: update declarations. + + * glib/poppler-private.h (struct _PopplerPSFile): store necessary + information to eventually construct a PSOutputDev. + + * glib/poppler-page.cc (poppler_page_render_to_ps): initialize the + output dev if it doesn't exist yet. + + * glib/poppler-document.cc (poppler_ps_file_new): don't create the + PSOutputDev here, just store filename and page range. + (poppler_ps_file_set_paper_size, poppler_ps_file_set_duplex): new + functions. + (poppler_ps_file_free): free the filename which we strdup now. + + * glib/poppler-document.h: add prototypes. + + ChangeLog | 23 +++++++++++++++++++++++ + glib/poppler-document.cc | 49 + +++++++++++++++++++++++++++++++++++++++++------- + glib/poppler-document.h | 15 ++++++++++----- + glib/poppler-page.cc | 10 ++++++++++ + glib/poppler-private.h | 6 ++++++ + poppler/PSOutputDev.cc | 23 ++++++++++++++--------- + poppler/PSOutputDev.h | 9 +++++++-- + 7 files changed, 112 insertions(+), 23 deletions(-) + +commit 7be920ecf13698c3cf4ab8df09c8c67f1a04bfa2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jul 26 21:52:09 2005 +0000 + + Fix mem leak in qt test app + + ChangeLog | 4 ++++ + qt/test-poppler-qt.cpp | 2 ++ + 2 files changed, 6 insertions(+) + +commit 2bc26dffd9f296799617d319055648c20f748c8a +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue Jul 26 20:34:13 2005 +0000 + + 2005-07-26 Kristian Høgsberg <krh@redhat.com> + + * fofi/FoFiType1.cc: Make check for end of encoding array + a bit + more liberal so we don't crash on complex encoding arrays + (#3344). + + ChangeLog | 5 +++++ + fofi/FoFiType1.cc | 21 +++++++-------------- + 2 files changed, 12 insertions(+), 14 deletions(-) + +commit 07911274e4e850a628b1e587cafc2a73c05f93fe +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 25 20:40:37 2005 +0000 + + Work on bad jpeg data that have garbage before the start marker. Fixes + bug #3299 + + ChangeLog | 5 +++++ + poppler/DCTStream.cc | 38 ++++++++++++++++++++++++++++++++++++++ + 2 files changed, 43 insertions(+) + +commit a1869eca39172fcb42f036a5846b19548be53568 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 22 11:01:25 2005 +0000 + + Fix bug #3586 + + ChangeLog | 5 +++++ + poppler/CairoFontEngine.cc | 2 ++ + 2 files changed, 7 insertions(+) + +commit 95529b41272484f08fb54393e1886bf7ff3e02c8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 22 10:45:19 2005 +0000 + + Make it possible to browse pages in test-poppler-qt + + ChangeLog | 13 +++++++++---- + qt/test-poppler-qt.cpp | 49 + ++++++++++++++++++++++++++++++++++++++++--------- + 2 files changed, 49 insertions(+), 13 deletions(-) + +commit 2d52650864eab0e9385ed1fe8fb594daac9d8322 +Author: Martin Kretzschmar <martink@gnome.org> +Date: Fri Jul 22 10:35:56 2005 +0000 + + * glib/poppler-document.cc (poppler_fonts_iter_get_name): if the + font is a subset, strip the ABCDEF+ tag. + (poppler_fonts_iter_get_full_name): does what the old get_name did. + (poppler_fonts_iter_get_font_type, poppler_fonts_iter_is_embedded) + (poppler_fonts_iter_is_subset): new wrappers. + + * glib/poppler-document.h (PopplerFontType): new enum. + Update prototypes. + + ChangeLog | 11 ++++++++++ + glib/poppler-document.cc | 54 + +++++++++++++++++++++++++++++++++++++++++++++++- + glib/poppler-document.h | 38 ++++++++++++++++++++++++---------- + 3 files changed, 91 insertions(+), 12 deletions(-) + +commit 43bed4aafcf1d291dc96fa5070efbd7936a6122f +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Jul 22 10:33:54 2005 +0000 + + Fix bugs #3728 and #3750 + + ChangeLog | 4 ++++ + splash/Splash.cc | 10 ++++++++++ + 2 files changed, 14 insertions(+) + +commit c7bcef87493d354a077dd223d76f86640acc0ce3 +Author: Martin Kretzschmar <martink@gnome.org> +Date: Fri Jul 15 19:55:30 2005 +0000 + + update for 2005-06-27 change to actually display something again. + + ChangeLog | 5 +++++ + test/gtk-cairo-test.cc | 10 ++++++---- + 2 files changed, 11 insertions(+), 4 deletions(-) + +commit 6623711d2d50dc52454904ee16b25337f0aab130 +Author: Brad Hards <bradh@frogmouth.net> +Date: Sun Jul 10 09:34:03 2005 +0000 + + A general cleanup of the Arthur output renderer. + + ChangeLog | 5 +++ + poppler/ArthurOutputDev.cc | 105 + ++++++++++++++++----------------------------- + 2 files changed, 41 insertions(+), 69 deletions(-) + +commit ea1cc9a7b12db9c44b89896c41d07e3ba932d054 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Jul 8 04:59:41 2005 +0000 + + 2005-07-08 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc (poppler_page_set_selection_alpha): Add + this function to initialize the alpha channel when using the + splash backend. + + * poppler/TextOutputDev.cc (visitLine): Add missing scaling of + intra-line selection edges. + + ChangeLog | 9 ++++++++ + glib/poppler-page.cc | 59 + +++++++++++++++++++++++++++++++++++++++++++++++- + poppler/TextOutputDev.cc | 17 ++++++++------ + 3 files changed, 77 insertions(+), 8 deletions(-) + +commit 1cd915397c9532ed80b4f905b6ed9c0126aa38f2 +Author: Brad Hards <bradh@frogmouth.net> +Date: Thu Jul 7 21:15:09 2005 +0000 + + Add support for page layout to the Qt4 bindings, plus + test cases. + + ChangeLog | 8 ++++++++ + qt4/src/poppler-document.cc | 22 ++++++++++++++++++++++ + qt4/src/poppler-qt4.h | 26 ++++++++++++++++++++++++-- + qt4/tests/Makefile.am | 10 +++++++++- + qt4/tests/check_pagelayout_none.cpp | 22 ++++++++++++++++++++++ + qt4/tests/check_pagelayout_single.cpp | 22 ++++++++++++++++++++++ + 6 files changed, 107 insertions(+), 3 deletions(-) + +commit 4e050aef7ba132900f84205be221fd48808848c3 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Jul 7 17:19:36 2005 +0000 + + 2005-07-07 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc (poppler_page_prepare_output_dev): + Account + for page rotation when creating the cairo surface. + + ChangeLog | 5 +++++ + glib/poppler-page.cc | 17 +++++++++++++++-- + 2 files changed, 20 insertions(+), 2 deletions(-) + +commit 2eeab0b8afeb4897806df2de6e496889c25dda5e +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Jul 7 15:58:43 2005 +0000 + + 2005-07-06 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc (poppler_page_copy_to_pixbuf): Add + out of + bounds checking (from Marco). + + ChangeLog | 6 +++++- + glib/poppler-page.cc | 5 +++++ + 2 files changed, 10 insertions(+), 1 deletion(-) + +commit b1015f6bdbd93b2a2574a9f0e0e1cd7dbae9af78 +Author: Brad Hards <bradh@frogmouth.net> +Date: Thu Jul 7 11:13:24 2005 +0000 + + At least try to fix glib issues. If you care about glib, + then you should review this. + + ChangeLog | 4 ++++ + glib/poppler-document.cc | 2 ++ + 2 files changed, 6 insertions(+) + +commit 8bf787031e7a2e93b4e1202918bd1aee86675082 +Author: Brad Hards <bradh@frogmouth.net> +Date: Thu Jul 7 11:04:08 2005 +0000 + + Update for page mode - new mode from PDF-1.6, API docs fixes + and some tests. + + ChangeLog | 15 +++++++++++++++ + poppler/Catalog.cc | 2 ++ + poppler/Catalog.h | 3 ++- + qt4/src/poppler-document.cc | 2 ++ + qt4/src/poppler-qt4.h | 14 +++++++++----- + qt4/tests/Makefile.am | 22 +++++++++++++++++++++- + qt4/tests/check_pagemode_attach.cpp | 22 ++++++++++++++++++++++ + qt4/tests/check_pagemode_fullscreen.cpp | 22 ++++++++++++++++++++++ + qt4/tests/check_pagemode_none.cpp | 22 ++++++++++++++++++++++ + qt4/tests/check_pagemode_oc.cpp | 22 ++++++++++++++++++++++ + qt4/tests/check_pagemode_thumbs.cpp | 22 ++++++++++++++++++++++ + 11 files changed, 161 insertions(+), 7 deletions(-) + +commit 695e27fb4d6fcc3466e2c9c95b4f02821b07e823 +Author: Brad Hards <bradh@frogmouth.net> +Date: Thu Jul 7 11:01:27 2005 +0000 + + Suppress noise from new test files. + + qt4/tests/.cvsignore | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 8a8d57bdcf11ed2903913d938b9711053b9bb9f1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jul 6 17:12:36 2005 +0000 + + Extract family, stretch and weight from the font descriptor + + ChangeLog | 2 ++ + poppler/GfxFont.cc | 41 +++++++++++++++++++++++++++++++++++++++++ + poppler/GfxFont.h | 36 ++++++++++++++++++++++++++++++++++++ + 3 files changed, 79 insertions(+) + +commit 3a1646c2f776f5a07b0e830fcb8e1b0a80efb41c +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jul 6 13:29:00 2005 +0000 + + Add checkFooter to check the document ends with %%EOF + + ChangeLog | 5 +++++ + poppler/PDFDoc.cc | 28 ++++++++++++++++++++++++++++ + poppler/PDFDoc.h | 1 + + 3 files changed, 34 insertions(+) + +commit 377c023d31cf74d8240aa5be9dba8e3838459a8c +Author: Brad Hards <bradh@frogmouth.net> +Date: Wed Jul 6 11:15:16 2005 +0000 + + Add unit tests for the isLinearized() property. + + ChangeLog | 4 ++++ + qt4/tests/Makefile.am | 6 +++++- + qt4/tests/check_linearised.cpp | 23 +++++++++++++++++++++++ + 3 files changed, 32 insertions(+), 1 deletion(-) + +commit 5fa869887a840a585340993718df0841010666cf +Author: Brad Hards <bradh@frogmouth.net> +Date: Wed Jul 6 09:52:30 2005 +0000 + + Remove boolean for unicode table lookup from Font + + ChangeLog | 14 ++++++++++++++ + qt4/src/poppler-document.cc | 2 -- + qt4/src/poppler-qt4.h | 14 +------------- + qt4/tests/poppler-fonts.cpp | 16 +++++++--------- + 4 files changed, 22 insertions(+), 24 deletions(-) + +commit 40469c5883e17e734f3d54872c59e76b95bc0f95 +Author: Brad Hards <bradh@frogmouth.net> +Date: Wed Jul 6 09:00:39 2005 +0000 + + Update to reflect recent changes. + + qt4/tests/.cvsignore | 2 ++ + 1 file changed, 2 insertions(+) + +commit 6cea437208f913085a6a8c7183b0826a107cefb5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jul 5 21:15:48 2005 +0000 + + Don't crash with files that have fonts with no name + + ChangeLog | 7 +++++++ + qt4/src/poppler-document.cc | 13 ++++++++++--- + qt4/src/poppler-qt4.h | 2 +- + 3 files changed, 18 insertions(+), 4 deletions(-) + +commit 1323c74479848f5b87a3a13fa26e8b9e096e9f6a +Author: Brad Hards <bradh@frogmouth.net> +Date: Tue Jul 5 12:31:59 2005 +0000 + + Check in a couple more test apps + + qt4/tests/Makefile.am | 10 ++++++- + qt4/tests/check_author.cpp | 25 +++++++++++++++++ + qt4/tests/check_permissions.cpp | 59 + +++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 93 insertions(+), 1 deletion(-) + +commit 839a798ec3725427185de5a48c58ac448596b25d +Author: Brad Hards <bradh@frogmouth.net> +Date: Tue Jul 5 12:25:00 2005 +0000 + + Add Qt4 bindings for new user permission properties. + + ChangeLog | 4 ++++ + qt4/src/poppler-document.cc | 25 ++++++++++++++++++++++ + qt4/src/poppler-qt4.h | 51 + ++++++++++++++++++++++++++++++++++++++++----- + 3 files changed, 75 insertions(+), 5 deletions(-) + +commit e10f6990d3339e3a7adeaa50b1754cf7ecf82f87 +Author: Brad Hards <bradh@frogmouth.net> +Date: Tue Jul 5 12:15:04 2005 +0000 + + Add some more user permissions properties - high resolution + printing, document assembly, extraction for accessibility + and form completion. + + ChangeLog | 8 ++++++++ + poppler/PDFDoc.h | 9 +++++++++ + poppler/XRef.cc | 55 + +++++++++++++++++++++++++++++++++++++++++++++++++++---- + poppler/XRef.h | 4 ++++ + 4 files changed, 72 insertions(+), 4 deletions(-) + +commit 3a8e1ba03cdec6412dd0b79f0cc59a4cd97dd4e7 +Author: Brad Hards <bradh@frogmouth.net> +Date: Mon Jul 4 11:38:22 2005 +0000 + + A couple more little changes. + + ChangeLog | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit a44bd0b45bb89f29ddca5d0e8986a8de50f9db39 +Author: Brad Hards <bradh@frogmouth.net> +Date: Mon Jul 4 11:37:21 2005 +0000 + + Change path to sample file to point to test module + + qt4/tests/check_orientation.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 2a7079087c35651c242d3843c94703a3199e61ca +Author: Brad Hards <bradh@frogmouth.net> +Date: Mon Jul 4 11:36:13 2005 +0000 + + Fix typo causing failure to pick up upside down pages. + + qt4/src/poppler-page.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 529a548044ae721a414c5b8e768c0498b1e6830b +Author: Brad Hards <bradh@frogmouth.net> +Date: Mon Jul 4 08:30:29 2005 +0000 + + Update to reflect recent changes + + ChangeLog | 30 +++++++++++++++++++++++++++++- + qt4/tests/.cvsignore | 2 ++ + 2 files changed, 31 insertions(+), 1 deletion(-) + +commit 08cca4670f8ae65333beacda85834112e76489d1 +Author: Brad Hards <bradh@frogmouth.net> +Date: Mon Jul 4 08:21:27 2005 +0000 + + Add in a simple demo/test application, similar to the pdffonts + application in xpdf. + + qt4/tests/Makefile.am | 9 +++++- + qt4/tests/poppler-fonts.cpp | 76 + +++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 84 insertions(+), 1 deletion(-) + +commit 52af89d8303b50c45d5e4584d19ec8b7d7ebcf9b +Author: Brad Hards <bradh@frogmouth.net> +Date: Mon Jul 4 08:18:52 2005 +0000 + + Update to reflect changes to rendering API. + + qt4/tests/stress-poppler-qt4.cpp | 4 ++-- + qt4/tests/test-poppler-qt4.cpp | 3 ++- + 2 files changed, 4 insertions(+), 3 deletions(-) + +commit d42998d0fc32b1e21a2aeef1311e0baf508ade3f +Author: Brad Hards <bradh@frogmouth.net> +Date: Mon Jul 4 08:16:17 2005 +0000 + + Qt4 update. + * qt4/src/poppler-qt4.h: + * qt4/src/poppler-document.cc complete Qt4 font metadata handling + + * qt4/src/poppler-qt4.h: + * qt4/src/poppler-page.cc: change the render API to make it more + Qt-like. + + qt4/src/poppler-document.cc | 7 ++++- + qt4/src/poppler-page.cc | 5 ++-- + qt4/src/poppler-qt4.h | 73 + ++++++++++++++++++++++++++++++++++++++++++--- + 3 files changed, 77 insertions(+), 8 deletions(-) + +commit 5d194b926d1ed642ed4bbd3304befa073d389cd4 +Author: Brad Hards <bradh@frogmouth.net> +Date: Mon Jul 4 08:10:16 2005 +0000 + + Change FontInfo::type() to return an enumerated value, + rather than a GooString. + + poppler/FontInfo.cc | 16 ++-------------- + poppler/FontInfo.h | 16 +++++++++++++--- + 2 files changed, 15 insertions(+), 17 deletions(-) + +commit 1303020b2e97bc110ccf045cd2811daf59ec72ce +Author: Brad Hards <bradh@frogmouth.net> +Date: Mon Jul 4 07:42:32 2005 +0000 + + Fix up the unit test, now that I have a real sample + file. + + qt4/tests/check_orientation.cpp | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit 96fc0ea3fc6c9c7d933e9e0c02a622b2aeef7617 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Jul 1 04:57:49 2005 +0000 + + 2005-07-01 Kristian Høgsberg <krh@redhat.com> + + * poppler/TextOutputDev.cc: Make selection also work when + dragging + backwards in the text flow. Currently this is a big pile of + if-statements, and there is certainly room for improvement. + + ChangeLog | 6 +++ + poppler/TextOutputDev.cc | 129 + ++++++++++++++++++++++++++++++++++++++--------- + 2 files changed, 111 insertions(+), 24 deletions(-) + +commit 06c49c496f28aba608101adcecd8cec34937ac78 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Jun 30 19:44:33 2005 +0000 + + 2005-06-30 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.h: * glib/poppler-page.cc + (poppler_page_copy_to_pixbuf): Fix splash compilation + (patch from + Marco). + (poppler_page_render_to_pixbuf): Drop dest_x and dest_y + coordinates from this function. This functionality can be + achieved using a sub-GdkPixbuf. + + * glib/test-poppler-glib.c (main): Update test case. + + ChangeLog | 11 +++++++++++ + NEWS | 6 ++++++ + glib/poppler-page.cc | 27 ++++++++++----------------- + glib/poppler-page.h | 4 +--- + glib/test-poppler-glib.c | 2 +- + 5 files changed, 29 insertions(+), 21 deletions(-) + +commit b126785aeda6b5576a13fc3f3853b027bd7dd306 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Jun 30 00:36:01 2005 +0000 + + 2005-06-29 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-private.h: Move TextOutputDev.h include + here from + poppler-page.cc + + ChangeLog | 5 +++++ + glib/poppler-page.cc | 1 - + glib/poppler-private.h | 1 + + 3 files changed, 6 insertions(+), 1 deletion(-) + +commit b15a8caf003d7d0631d4f78db5ab54e55a5a000a +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed Jun 29 21:24:48 2005 +0000 + + 2005-06-29 Kristian Høgsberg <krh@redhat.com> + + * configure.ac: + * glib/poppler-page.cc: + * glib/poppler-page.h: + * glib/poppler-private.h: + * poppler/CairoOutputDev.cc: + * poppler/CairoOutputDev.h: + * poppler/Page.cc: + * poppler/Page.h: + * poppler/TextOutputDev.cc: + * poppler/TextOutputDev.h: Add support for rendering real + selection (based on text flow). + + ChangeLog | 20 ++- + configure.ac | 4 +- + glib/poppler-page.cc | 224 +++++++++++++++++++------ + glib/poppler-page.h | 65 ++++---- + glib/poppler-private.h | 3 + + poppler/CairoOutputDev.cc | 13 +- + poppler/CairoOutputDev.h | 2 +- + poppler/Page.cc | 59 +++++-- + poppler/Page.h | 12 ++ + poppler/TextOutputDev.cc | 414 + +++++++++++++++++++++++++++++++++++++++++++++- + poppler/TextOutputDev.h | 38 ++++- + 11 files changed, 743 insertions(+), 111 deletions(-) + +commit 3b5e20465e482eb0e75a106697ee94d60aea2fdc +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 28 22:51:29 2005 +0000 + + Forgot assigning type on copy constructor + + poppler/FontInfo.cc | 1 + + 1 file changed, 1 insertion(+) + +commit e512cd1832a0e6d15149e12e8e67a39d335efc86 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 28 22:49:14 2005 +0000 + + Add FontInfo::getType() + + ChangeLog | 3 +++ + poppler/FontInfo.cc | 4 ++++ + poppler/FontInfo.h | 2 ++ + 3 files changed, 9 insertions(+) + +commit 8aeb5205f2876a9dc36eb1dc1e361bb87adf4e31 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 28 22:00:05 2005 +0000 + + use transformation matrix for image rendering in Arthur backend + + ChangeLog | 4 ++++ + poppler/ArthurOutputDev.cc | 12 +++++++----- + 2 files changed, 11 insertions(+), 5 deletions(-) + +commit a221d06fdc7b0688ca0744a1d6ad49d472c7f12c +Author: Brad Hards <bradh@frogmouth.net> +Date: Tue Jun 28 10:59:14 2005 +0000 + + Reduce cvs up noise + + .cvsignore | 1 + + ChangeLog | 7 +++++++ + qt4/.cvsignore | 3 +++ + qt4/src/.cvsignore | 7 +++++++ + qt4/tests/.cvsignore | 8 ++++++++ + 5 files changed, 26 insertions(+) + +commit ea58a20bbcf450a1ecb8fe00e8162cfdf76105f1 +Author: Brad Hards <bradh@frogmouth.net> +Date: Tue Jun 28 10:00:09 2005 +0000 + + Initial import of Qt4 bindings, and for a Qt4 "Arthur" (QPainter) + backend renderer. + + The bindings are currently unstable - you can expect substantial + change + in both source and binary interfaces. + + The Arthur renderer currently does a reasonable job of rendering path + and fill, but the image rendering doesn't work (for reasons that + aren't + clear to me) and text rendering doesn't use the right glyphs - it just + draws with the current font. There is a lot of work to do on this + too. Help is, of coure, welcome. + + ChangeLog | 12 + + Makefile.am | 10 +- + configure.ac | 94 ++- + poppler-qt4.pc.in | 12 + + poppler/ArthurOutputDev.cc | 604 +++++++++++++++++++ + poppler/ArthurOutputDev.h | 133 +++++ + poppler/Makefile.am | 20 + + qt4/Makefile.am | 1 + + qt4/src/Doxyfile | 1212 + ++++++++++++++++++++++++++++++++++++++ + qt4/src/Makefile.am | 22 + + qt4/src/poppler-document.cc | 309 ++++++++++ + qt4/src/poppler-page.cc | 170 ++++++ + qt4/src/poppler-private.h | 36 ++ + qt4/src/poppler-qt4.h | 286 +++++++++ + qt4/tests/Makefile.am | 34 ++ + qt4/tests/check_orientation.cpp | 40 ++ + qt4/tests/stress-poppler-qt4.cpp | 70 +++ + qt4/tests/test-poppler-qt4.cpp | 121 ++++ + 18 files changed, 3183 insertions(+), 3 deletions(-) + +commit 61e9bc76eb2fcb0b4b899ebfad1cc71c59fc8274 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue Jun 28 03:44:12 2005 +0000 + + 2005-06-27 Kristian Høgsberg <krh@redhat.com> + + * poppler/CairoOutputDev.cc: + * poppler/CairoOutputDev.h: Change CairoOutputDev to render + to a + given surface and let the user create that surface. + + * glib/poppler-document.cc: + * glib/poppler-page.cc: + * glib/poppler-private.h: Create the cairo image surface here + instead and pass it to the CairoOutputDev for rendering. + + * poppler/CairoOutputDevImage.cc: + * poppler/CairoOutputDevImage.h: + * poppler/CairoOutputDevX.cc: + * poppler/CairoOutputDevX.h: + * poppler/Makefile.am: Remove specialized cairo output + devices. + + ChangeLog | 17 ++++ + glib/poppler-document.cc | 2 +- + glib/poppler-page.cc | 21 +++- + glib/poppler-private.h | 4 +- + poppler/CairoOutputDev.cc | 24 +++-- + poppler/CairoOutputDev.h | 8 +- + poppler/CairoOutputDevImage.cc | 80 --------------- + poppler/CairoOutputDevImage.h | 44 --------- + poppler/CairoOutputDevX.cc | 216 + ----------------------------------------- + poppler/CairoOutputDevX.h | 117 ---------------------- + poppler/Makefile.am | 8 +- + 11 files changed, 54 insertions(+), 487 deletions(-) + +commit 8079dce3f0ed91dd531465f45c6d3c568ab4ecd1 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Jun 27 01:04:32 2005 +0000 + + 2005-06-26 Kristian Høgsberg <krh@redhat.com> + + * poppler/CairoOutputDev.cc: + * poppler/CairoOutputDev.h: Switch back to using drawChar() + for + text, but utilize the beginString() and endString() hooks + so we + can use cairo_show_glyphs() efficiently. + + ChangeLog | 7 +++ + poppler/CairoOutputDev.cc | 107 + ++++++++++++++-------------------------------- + poppler/CairoOutputDev.h | 12 +++++- + 3 files changed, 48 insertions(+), 78 deletions(-) + +commit 1aa48d6b7907a1d53830f0cf28085041f685368d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Jun 26 23:35:26 2005 +0000 + + Add PageTransition class and PageTransition* Page::getTransition() + const; to the qt frontend. Code almost 100% copied from xpdf code + inside kpdf + + ChangeLog | 5 +++ + qt/poppler-page.cc | 121 + +++++++++++++++++++++++++++++++++++++++++++++++++++++ + qt/poppler-qt.h | 78 ++++++++++++++++++++++++++++++++++ + 3 files changed, 204 insertions(+) + +commit 9d4327eecd94299a3629b0814e84f981a4be1dfb +Author: Martin Kretzschmar <martink@gnome.org> +Date: Sun Jun 26 15:54:16 2005 +0000 + + add poppler-enums.[ch]. + + ChangeLog | 2 ++ + glib/.cvsignore | 8 +++++--- + 2 files changed, 7 insertions(+), 3 deletions(-) + +commit 768186514b9fc175cf330344408bb89ab4c909f3 +Author: Martin Kretzschmar <martink@gnome.org> +Date: Sun Jun 26 11:40:35 2005 +0000 + + require glib 2.4+ for g_value_take_string and G_DEFINE_TYPE. + + ChangeLog | 5 +++++ + configure.ac | 4 ++-- + 2 files changed, 7 insertions(+), 2 deletions(-) + +commit 5d40e34a367212c39af06332879f26824d6d62d2 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sun Jun 26 00:01:39 2005 +0000 + + 2005-06-25 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/Error.h: Maybe fix build on Solaris. + + ChangeLog | 4 ++++ + poppler/Error.h | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +commit c2780a3b3f4615bb28bfe394d649b388db4ccf4d +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Jun 20 21:33:09 2005 +0000 + + 2005-06-20 Kristian Høgsberg <krh@redhat.com> + + * NEWS: + * configure.ac: Bump version to 0.3.3 and sum up changes since + last release. + + * glib/poppler-page.cc (poppler_page_find_text): Initialize + xMin + and yMin to avoid referencing unintialized memory (#3582). + + ChangeLog | 9 +++++++++ + NEWS | 10 ++++++++++ + configure.ac | 2 +- + glib/poppler-page.cc | 2 ++ + 4 files changed, 22 insertions(+), 1 deletion(-) + +commit 9023891f314ac37811b5c973be2e36b6de353cf2 +Author: Martin Kretzschmar <martink@gnome.org> +Date: Mon Jun 20 18:45:41 2005 +0000 + + (info_dict_get_string): convert from PDFDocEncoding to UTF-8. + + ChangeLog | 5 +++++ + glib/poppler-document.cc | 16 +++++++++++++++- + 2 files changed, 20 insertions(+), 1 deletion(-) + +commit bbf2fe757f0fd08d0e90e3810709ab7152c779c0 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Jun 20 17:58:38 2005 +0000 + + 2005-06-20 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc: + * glib/poppler-page.h: + * glib/poppler.h: Clean up glib rotation implementation and + add a + getter for rotation. Patch from Marco. + + ChangeLog | 7 ++++++ + glib/poppler-page.cc | 69 + +++++++++++++++++++++++++++++----------------------- + glib/poppler-page.h | 57 ++++++++++++++++++++++--------------------- + glib/poppler.h | 1 - + 4 files changed, 75 insertions(+), 59 deletions(-) + +commit c264d8a9f84587cd0f2ef67683a01fc8dd9395af +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Jun 20 17:38:27 2005 +0000 + + 2005-06-20 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-document.cc: + * poppler/FontInfo.cc: Fixes from Marco to handle fonts + without + name (typically type 3 fonts) and fix an iterator bug. + + ChangeLog | 6 ++++++ + glib/poppler-document.cc | 8 +++++++- + poppler/FontInfo.cc | 13 ++++++++++--- + 3 files changed, 23 insertions(+), 4 deletions(-) + +commit 4746e63a793a2881e904ac54d58b7d3e48b07dcf +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Jun 20 17:22:35 2005 +0000 + + 2005-06-20 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc (poppler_page_get_link_mapping): Adjust + link coordinates so they're relative to bounding box + lower left + corner (#3396). + + ChangeLog | 6 ++++++ + glib/poppler-page.cc | 6 ++++++ + 2 files changed, 12 insertions(+) + +commit bada3d03583ef6ed34d2aa743de8fd9ca4a5c748 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Jun 17 05:30:56 2005 +0000 + + 2005-06-17 Kristian Høgsberg <krh@redhat.com> + + * autogen.sh: Patch from Emil Soleyman-Zomalan to enable + checks + for automake >= 1.7 (#3554). + + ChangeLog | 5 +++ + autogen.sh | 104 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 109 insertions(+) + +commit 25db42831ddde500697126352458e092a9b0ab9b +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed Jun 15 15:02:46 2005 +0000 + + 2005-06-15 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-document.cc: + * glib/poppler-document.h: Patch from Marco to get initial + status + (open or closed) for bookmark subtrees. + ----------------------------------------------------------- + + ChangeLog | 6 ++++++ + glib/poppler-document.cc | 9 +++++++++ + glib/poppler-document.h | 1 + + 3 files changed, 16 insertions(+) + +commit e54e306ac5d603001fefda3b9ecd81821e4bd09e +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Jun 13 17:18:32 2005 +0000 + + Forgot to add new files. + + poppler/FontInfo.cc | 197 + ++++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/FontInfo.h | 51 ++++++++++++++ + 2 files changed, 248 insertions(+) + +commit 23e8ed5cbf4d7d999a8a1dcf714aaddaf339ceff +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Jun 13 16:09:33 2005 +0000 + + 2005-06-13 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-document.cc: + * glib/poppler-document.h: + * glib/poppler-private.h: + * glib/poppler.h: + * glib/test-poppler-glib.c: + * poppler/Makefile.am: Patch from Marco to extract font + info from + document. + + ChangeLog | 10 ++++ + glib/poppler-document.cc | 131 + +++++++++++++++++++++++++++++++++++++++++++++++ + glib/poppler-document.h | 13 +++++ + glib/poppler-private.h | 7 +++ + glib/poppler.h | 2 + + glib/test-poppler-glib.c | 14 +++++ + poppler/Makefile.am | 2 + + 7 files changed, 179 insertions(+) + +commit fbb86d2983a28ad2c46b8c5d475a2df1f0f0e4b9 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed Jun 8 14:35:46 2005 +0000 + + 2005-06-08 Kristian Høgsberg <krh@redhat.com> + + * poppler/CairoFontEngine.cc: Remember to delete tmpFileName. + Patch from Nikolai Weibull (#3491). + + ChangeLog | 5 +++++ + poppler/CairoFontEngine.cc | 37 +++++++++++++++++++------------------ + 2 files changed, 24 insertions(+), 18 deletions(-) + +commit 699b03025c1d38a42a49e39017097c5d0315fd6f +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue Jun 7 20:25:48 2005 +0000 + + 2005-06-07 Kristian Høgsberg <krh@redhat.com> + + * qt/test-poppler-qt.cpp: Add stdlib.h include for exit(). + + ChangeLog | 4 ++++ + qt/test-poppler-qt.cpp | 1 + + 2 files changed, 5 insertions(+) + +commit 0017b1a72c58e2d016d22451079c466abdfff15c +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Jun 2 19:14:45 2005 +0000 + + 2005-06-02 Kristian Høgsberg <krh@redhat.com> + + * poppler/TextOutputDev.h: + * qt/poppler-qt.h: Patch from Stanislav Brabec + <sbrabec@suse.cz> + to fix gcc 4.0.1 warnings on undeclared friend classes. + + * test/gtk-splash-test.cc: Fix from Martin Kretzschmar + <martink@gnome.org> to compile with OPI enabled (#2911). + + ChangeLog | 9 +++++++++ + poppler/TextOutputDev.h | 3 +++ + qt/poppler-qt.h | 2 ++ + test/gtk-splash-test.cc | 2 +- + 4 files changed, 15 insertions(+), 1 deletion(-) + +commit 47c3b4ec2c7691e44f5100b1f5956df0005467c8 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Jun 2 18:49:55 2005 +0000 + + 2005-06-02 Kristian Høgsberg <krh@redhat.com> + + Patch from Stanislav Brabec <sbrabec@suse.cz>: + + * configure.ac: + * poppler-cairo.pc.in: + * poppler-glib.pc.in: + * poppler-qt.pc.in: + * poppler-splash.pc.in: Misc fixes to pkg-config files. + + ChangeLog | 10 ++++++++++ + configure.ac | 6 ++++-- + poppler-cairo.pc.in | 3 +-- + poppler-glib.pc.in | 4 ++-- + poppler-qt.pc.in | 1 + + poppler-splash.pc.in | 3 +-- + 6 files changed, 19 insertions(+), 8 deletions(-) + +commit 9f0da96dd005defd5d82dd05b627ff1925430215 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Thu Jun 2 00:35:44 2005 +0000 + + 2005-06-01 Jeff Muizelaar <jeff@infidigm.net> + + * poppler/Error.cc: + * poppler/Error.h: Make error handling function setable through + setErrorFunction. + + Based on a patch by Albert Astals Cid. + + ChangeLog | 8 ++++++++ + poppler/Error.cc | 29 ++++++++++++++++++++--------- + poppler/Error.h | 2 ++ + 3 files changed, 30 insertions(+), 9 deletions(-) + +commit f688aa11d066f1c6f4115cbdb604ac61fb8b5146 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sun May 29 14:59:34 2005 +0000 + + 2005-05-29 Kristian Høgsberg <krh@redhat.com> + + * glib/*: Add more meta data properties to poppler document. + Patch by Emil Soleyman-Zomalan (#3359). + + ChangeLog | 5 ++ + glib/poppler-document.cc | 155 + ++++++++++++++++++++++++++++++++++++++++++++++- + glib/poppler.gidl | 5 ++ + glib/test-poppler-glib.c | 46 +++++++++----- + 4 files changed, 194 insertions(+), 17 deletions(-) + +commit 9e6eeec574d48d2341ee620e16360d3b21c40103 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu May 26 13:03:35 2005 +0000 + + 2005-05-26 Kristian Høgsberg <krh@redhat.com> + + * poppler/CairoOutputDev.cc (clip): Remove snapToGrid + so clip() + prototype matches what Gfx actually calls (fixes clipping). + + * poppler/CairoOutputDev.cc: Update fill color, stroke + color, fill + opacity and stroke opacity from GfxState on restore, + since they + aren't handled by cairo_restore() (#3362). + + * poppler/CairoOutputDev.cc: Comment out tolerance setting + until + we figure out how cairo settings relate to pdf settings. + + * poppler/CairoOutputDev.cc: Support fill and stroke opacity. + + ChangeLog | 12 ++++++++++++ + poppler/CairoOutputDev.cc | 41 ++++++++++++++++++++++++++++++----------- + poppler/CairoOutputDev.h | 6 +++++- + 3 files changed, 47 insertions(+), 12 deletions(-) + +commit 89a633edd860e3c6ded1e468edf6f28cfcb43d0e +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu May 26 12:52:38 2005 +0000 + + 2005-05-26 Kristian Høgsberg <krh@redhat.com> + + * poppler/GfxState.cc: + * poppler/GfxState.h: Add GfxColorSpace::getRGBLine here and + implement in subclasses. + + * poppler/CairoOutputDev.cc (drawImage): Use getRGBLine here. + + ChangeLog | 8 +++ + poppler/CairoOutputDev.cc | 66 +++++++++---------- + poppler/GfxState.cc | 160 + +++++++++++++++++++++++++++++++++++++++++++++- + poppler/GfxState.h | 14 ++++ + 4 files changed, 212 insertions(+), 36 deletions(-) + +commit 4d8224819da7a85e4d99f96c9bbb047ece58130a +Author: Jonathan Blandford <jrb@redhat.com> +Date: Mon May 23 04:23:53 2005 +0000 + + Mon May 23 00:22:41 2005 Jonathan Blandford <jrb@redhat.com> + + * glib/poppler-document.h: Add a permissions flag to the glib + bindings. + + ChangeLog | 5 +++++ + glib/poppler-document.cc | 24 ++++++++++++++++++++++++ + glib/poppler-document.h | 16 +++++++++------- + 3 files changed, 38 insertions(+), 7 deletions(-) + +commit 1f677e2f60634a7d0c5e0e0d2125ab15c2722979 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sat May 21 21:33:06 2005 +0000 + + 2005-05-21 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-document.cc (poppler_ps_file_new): Fix + off-by-one + error spotted by Jürg Billeter. + ----------------------------------------------------- + + ChangeLog | 5 +++++ + glib/poppler-document.cc | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit 0bbf2f08173866cde9b097eeeb1f4218a396588d +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri May 20 20:48:52 2005 +0000 + + 2005-05-20 Kristian Høgsberg <krh@redhat.com> + + * poppler/CairoOutputDev.cc: Account for different row + vs. column + vector conventions between cairo and poppler. + + ChangeLog | 3 +++ + poppler/CairoOutputDev.cc | 18 +++++++++--------- + 2 files changed, 12 insertions(+), 9 deletions(-) + +commit da44ec7e8de58e55e55b1f780bc3f4bc8307874f +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri May 20 18:38:10 2005 +0000 + + 2005-05-20 Kristian Høgsberg <krh@redhat.com> + + * poppler/CairoFontEngine.cc: Only get the code to gid map if + we're using freetype 2.1.7 or older (#3340). + + ChangeLog | 5 +++++ + poppler/CairoFontEngine.cc | 13 ++++++++----- + 2 files changed, 13 insertions(+), 5 deletions(-) + +commit 6fe29cf0a7e54b8d294471a0f94eb9e989ad1d7f +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu May 19 05:18:04 2005 +0000 + + Add bugzilla number. + + ChangeLog | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 42de1348622cf86a87bc22941bd48bffa943dac9 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu May 19 05:16:22 2005 +0000 + + 2005-05-19 Kristian Høgsberg <krh@redhat.com> + + * poppler/CairoFontEngine.cc: Only cast to Gfx8BitFont when we + know for sure we have a truetype font. + GfxCIDFont::getCIDToGIDLen() can return 0 in which case + codeToGID + will be NULL, and we end up casting it to a Gfx8BitFont. + + ChangeLog | 7 +++++++ + poppler/CairoFontEngine.cc | 2 +- + 2 files changed, 8 insertions(+), 1 deletion(-) + +commit afc05387c94a76ff0ed69b3f5d9a69ddd1448e83 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed May 18 17:39:59 2005 +0000 + + 2005-05-18 Kristian Høgsberg <krh@redhat.com> + + * configure.ac: Require cairo 0.5.0, bump release to 0.3.2. + + * NEWS: Sum up latest changes. + + * glib/poppler-document.cc (poppler_ps_file_new): Take a page + range here instead of just number of pages. + + ChangeLog | 9 +++++++++ + NEWS | 7 +++++++ + configure.ac | 6 +++--- + glib/poppler-document.cc | 15 ++++++++++----- + glib/poppler-document.h | 1 + + 5 files changed, 30 insertions(+), 8 deletions(-) + +commit 420134a194af9161282ccfe329d17adef8d325f2 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue May 17 23:38:27 2005 +0000 + + 2005-05-17 Kristian Høgsberg <krh@redhat.com> + + * poppler/CairoOutputDevX.cc: + * test/gtk-cairo-test.cc: Chase the cairo xlib constructor + again. + + ChangeLog | 5 +++++ + poppler/CairoOutputDevX.cc | 5 +++-- + test/gtk-cairo-test.cc | 5 +++-- + 3 files changed, 11 insertions(+), 4 deletions(-) + +commit 6fd62953a910dcfb4abd9de5ea18285b8fa5d202 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon May 16 23:16:15 2005 +0000 + + Add bug number and attribution to ChangeLog entry. + + ChangeLog | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 6d7f624c13e8a9a8251ac97388cd80e418c70250 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon May 16 21:56:31 2005 +0000 + + 2005-05-16 Kristian Høgsberg <krh@redhat.com> + + * configure.ac: Check for glib-mkenums. + + * glib/Makefile.am (poppler-enums.h): Generate glib enums at + compile time. + + * glib/poppler-enums.c: + * glib/poppler-enums.h: Removed. + + ChangeLog | 8 +++ + configure.ac | 3 + + glib/.cvsignore | 1 + + glib/Makefile.am | 67 ++++++++++++------ + glib/poppler-enums.c | 189 + --------------------------------------------------- + glib/poppler-enums.h | 49 ------------- + 6 files changed, 57 insertions(+), 260 deletions(-) + +commit 2801b54a944fc9e1072c5dcb9f1153a0c9f42de5 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon May 16 20:27:51 2005 +0000 + + 2005-05-16 Kristian Høgsberg <krh@redhat.com> + + * test/gtk-cairo-test.cc: Update this test case also. + + ChangeLog | 2 ++ + test/gtk-cairo-test.cc | 5 +++-- + 2 files changed, 5 insertions(+), 2 deletions(-) + +commit 8753ae8ba20fcceaef3ef1dda89129f0456fccf6 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon May 16 19:06:00 2005 +0000 + + 2005-05-16 Kristian Høgsberg <krh@redhat.com> + + * poppler/CairoOutputDevX.cc: Track changes to cairo Xlib + surface + constructors. + + * poppler/CairoFontEngine.cc (cairo_font_face_destroy): + Make this + static. + + ChangeLog | 8 ++++++++ + poppler/CairoFontEngine.cc | 2 +- + poppler/CairoOutputDevX.cc | 5 +++-- + 3 files changed, 12 insertions(+), 3 deletions(-) + +commit 2e17106ef4711097104a561d5be49980f8b2f5ab +Author: Jonathan Blandford <jrb@redhat.com> +Date: Fri May 13 03:47:36 2005 +0000 + + whoops! commit the right file. + + glib/poppler.gidl | 212 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++ + glib/test.gidl | 23 ------ + 2 files changed, 212 insertions(+), 23 deletions(-) + +commit 19b62e1c8ea8ce042ac089defe94f756dcaf194e +Author: Jonathan Blandford <jrb@redhat.com> +Date: Fri May 13 03:25:32 2005 +0000 + + Thu May 12 23:10:45 2005 Jonathan Blandford <jrb@redhat.com> + + * glib/poppler.gidl: add metadata file. + + ChangeLog | 4 ++++ + glib/test.gidl | 23 +++++++++++++++++++++++ + 2 files changed, 27 insertions(+) + +commit bef5a548f3b21e7220079155e9b5054fb0c6c3c7 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu May 12 21:26:25 2005 +0000 + + 2005-05-12 Kristian Høgsberg <krh@redhat.com> + + * poppler/CairoOutputDev.cc: + * poppler/CairoOutputDevX.cc: + * poppler/CairoOutputDevImage.cc: + * test/gtk-cairo-test.cc: Update to latest cairo changes, + patch + from Jens Taprogge (#3281) + + ChangeLog | 8 ++++++++ + poppler/CairoOutputDev.cc | 22 +++++++++++----------- + poppler/CairoOutputDevImage.cc | 11 ++++++----- + poppler/CairoOutputDevX.cc | 7 +++++-- + test/gtk-cairo-test.cc | 8 +++++--- + 5 files changed, 35 insertions(+), 21 deletions(-) + +commit c10ea2dd9bffaf9af023612ef196bab2b204d3e1 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed May 11 20:01:43 2005 +0000 + + 2005-05-11 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler.cc (poppler_get_backend, poppler_get_version): + Add + these functions so it's easy to tell if poppler is using + cairo or + splash and what version. + + * glib/test-poppler-glib.c (main): Print out version and + backend. + + ChangeLog | 8 ++++++++ + glib/poppler-enums.c | 26 ++++++++++++++++++++++++++ + glib/poppler-enums.h | 15 +++++++++++++++ + glib/poppler.cc | 21 +++++++++++++++++++++ + glib/poppler.h | 11 +++++++++++ + glib/test-poppler-glib.c | 9 ++++++++- + 6 files changed, 89 insertions(+), 1 deletion(-) + +commit 7d189e33cfa68e722561e9398ad85a77b538ab14 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri May 6 16:38:57 2005 +0000 + + 2005-05-06 Kristian Høgsberg <krh@redhat.com> + + * glib/Makefile.am (libpoppler_glib_la_LIBADD): Link + poppler-glib + against poppler. + + * qt/Makefile.am (libpoppler_qt_la_LIBADD): Ditto for qt. + + * poppler-glib.pc (Libs): Drop -lpoppler from link. + + * poppler-qt.pc (Libs): Ditto for qt. + + * configure.ac: Test for both libqt-mt.la and libqt-mt.so + in that + order. + + ChangeLog | 14 ++++++++++++++ + configure.ac | 8 +++++++- + glib/Makefile.am | 1 + + poppler-glib.pc.in | 2 +- + poppler-qt.pc.in | 2 +- + qt/Makefile.am | 1 + + qt/test-poppler-qt.cpp | 1 + + 7 files changed, 26 insertions(+), 3 deletions(-) + +commit c937e63f17a096b94a554103476ecb9ab1b71b90 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed May 4 20:08:41 2005 +0000 + + 2005-05-04 Kristian Høgsberg <krh@redhat.com> + + * poppler/CairoOutputDev.cc (CairoOutputDev::drawImageMask, + CairoOutputDev::drawImage): Track cairo cvs API changes; use + cairo_mask() and cairo_paint() for drawing image masks + and images. + + ChangeLog | 6 +++ + poppler/CairoOutputDev.cc | 98 + ++++++++++++++++++++++++----------------------- + 2 files changed, 57 insertions(+), 47 deletions(-) + +commit c142773ad30b409d8169a53921e731305de46e50 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed May 4 19:28:07 2005 +0000 + + 2005-05-04 Kristian Høgsberg <krh@redhat.com> + + * poppler/CairoOutputDev.cc: Fix matrix convention confusion. + + ChangeLog | 4 ++++ + poppler/CairoOutputDev.cc | 4 ++-- + 2 files changed, 6 insertions(+), 2 deletions(-) + +commit 28760927d724231d0137ca7ecc66c6c2250dff0d +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed May 4 19:11:11 2005 +0000 + + 2005-05-04 Kristian Høgsberg <krh@redhat.com> + + Patches from Albert Astals Cid: + + * qt/poppler-page.cc (getText): Use QString::fromUtf8() + instead of + implicit latin1 cast constructor. + + * qt/test-poppler-qt.cpp (main): Use a QLabel for showing text + instead of qDebug. + + ChangeLog | 10 ++++++++++ + qt/poppler-page.cc | 5 ++--- + qt/test-poppler-qt.cpp | 6 +++++- + 3 files changed, 17 insertions(+), 4 deletions(-) + +commit fd36522375bcf436639b8731acb3ad22c03c03f4 +Author: Jonathan Blandford <jrb@redhat.com> +Date: Wed May 4 06:32:38 2005 +0000 + + Wed May 4 02:31:05 2005 Jonathan Blandford <jrb@redhat.com> + + * glib/poppler-document.cc: + * glib/poppler-document.h: + * glib/poppler-enums.c: (poppler_permissions_get_type): + * glib/poppler-enums.h: + * glib/poppler-page.cc: + * glib/poppler-page.h: + * glib/poppler.h: + + Register a bunch of boxed types to test introspection, and for + LBs. Also, remove unused 'popper_document_save()' (-: + + ChangeLog | 13 ++++++++ + glib/poppler-document.cc | 48 ++++++++++++++++------------ + glib/poppler-document.h | 18 +++++++++-- + glib/poppler-enums.c | 19 +++++++++++ + glib/poppler-enums.h | 2 ++ + glib/poppler-page.cc | 83 + ++++++++++++++++++++++++++++++++++++++++++++++++ + glib/poppler-page.h | 36 ++++++++++++++------- + glib/poppler.h | 12 ++++--- + 8 files changed, 193 insertions(+), 38 deletions(-) + +commit 132647f8311c07b1f95ee4fca185e9774aae4913 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon May 2 05:39:11 2005 +0000 + + 2005-05-01 Kristian Høgsberg <krh@redhat.com> + + * poppler/CairoFontEngine.cc: + * poppler/CairoFontEngine.h: + * poppler/CairoOutputDev.cc: Back out workaround for cairo + 0.4.0 + font API and port to new cairo head. + + ChangeLog | 7 +++++ + configure.ac | 4 +-- + poppler/CairoFontEngine.cc | 67 + +++++++++++++++++------------------------- + poppler/CairoFontEngine.h | 12 ++++---- + poppler/CairoOutputDev.cc | 39 ++++++++++++++---------- + poppler/CairoOutputDevImage.cc | 2 +- + 6 files changed, 66 insertions(+), 65 deletions(-) + +commit 595c18c038f8dcef73fe58612fc8b93f891e65a1 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Mon May 2 00:44:26 2005 +0000 + + 2005-05-01 Jeff Muizelaar <jeff@infidigm.net> + + * splash/SplashFTFont.cc (SplashFTFont::getGlyphPath): + Use FT_LOAD_NO_BITMAP to make sure we get outlines loaded instead + of bitmaps for use in FT_Outline_Decompose. + + Patch from Albert Astals Cid. + + ChangeLog | 8 ++++++++ + splash/SplashFTFont.cc | 2 +- + 2 files changed, 9 insertions(+), 1 deletion(-) + +commit 49d89ca0ed3986bec7468f6c0ed295e84ba67239 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sun May 1 21:54:55 2005 +0000 + + 2005-05-01 Jeff Muizelaar <jeff@infidigm.net> + + * goo/gmem.c: (gmalloc), (grealloc), (gfree): + * goo/gmem.h: make memory functions use size_t instead of int. + + Patch from Takashi Iwai through Albert Astals Cid. + + ChangeLog | 7 +++++++ + goo/gmem.c | 10 +++++----- + goo/gmem.h | 4 ++-- + 3 files changed, 14 insertions(+), 7 deletions(-) + +commit 14d618bece894e4c6bed0f179a8fda4db5a67c9d +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sat Apr 30 19:53:57 2005 +0000 + + 2005-04-30 Jeff Muizelaar <jeff@infidigm.net> + + * qt/poppler-document.cc (Document::unlock) : + * qt/poppler-qt.h (Document::unlock): + Add const to the password argument. + + Patch from Albert Astals Cid. + + ChangeLog | 8 ++++++++ + qt/poppler-document.cc | 2 +- + qt/poppler-qt.h | 2 +- + 3 files changed, 10 insertions(+), 2 deletions(-) + +commit 1e66da32964cc76c6ed3773574f422b4608cb0e1 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sat Apr 30 17:31:47 2005 +0000 + + 2005-04-30 Jeff Muizelaar <jeff@infidigm.net> + + * fofi/FoFiType1.cc (FoFiType1::parse): + Don't assume Encoding array of Type1 fonts end in "foo def". + http://partners.adobe.com/public/developer/en/font/T1_SPEC.PDF + says + "This sequence of assignments must be followed by an instance + of the + token def or readonly; such a token may not occur within the + sequence + of assignments." so it must end with "readonly" "def" "readonly + def" + (That is what most fonts are using and this is why it was not + crashing) + + Patch from Albert Astals Cid. + + ChangeLog | 13 +++++++++++++ + fofi/FoFiType1.cc | 14 +++++++++++--- + 2 files changed, 24 insertions(+), 3 deletions(-) + +commit 0b532db77ef41937dd5be30d15c96557d81eceb2 +Author: Jonathan Blandford <jrb@redhat.com> +Date: Fri Apr 29 19:37:07 2005 +0000 + + Fri Apr 29 14:54:44 2005 Jonathan Blandford <jrb@redhat.com> + + * goo/GooTimer.h: New class to do simple timing checks. + + * glib/poppler-document.c: Patch from Martin Kretzschmar + to really + set the PDF version correct. Third time's the charm. + + ChangeLog | 7 ++++++ + glib/poppler-document.cc | 4 ++- + goo/GooTimer.cc | 63 + ++++++++++++++++++++++++++++++++++++++++++++++++ + goo/GooTimer.h | 40 ++++++++++++++++++++++++++++++ + goo/Makefile.am | 2 ++ + 5 files changed, 115 insertions(+), 1 deletion(-) + +commit 38948ea6f9ef76dae9b8a7156fe1ef32a0457380 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Apr 29 03:57:16 2005 +0000 + + 2005-04-29 Kristian Høgsberg <krh@bitplanet.net> + + * configure.ac: Bump release to 0.3.1. + + * NEWS: Write up news for 0.3.1 release. + + ChangeLog | 6 ++++++ + NEWS | 6 ++++++ + configure.ac | 2 +- + 3 files changed, 13 insertions(+), 1 deletion(-) + +commit af65146c92682a3af06e9d3147426445c78309de +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Apr 28 23:03:06 2005 +0000 + + 2005-04-28 Kristian Høgsberg <krh@redhat.com> + + Patch from Martin Kretzschmar: + + * poppler/GlobalParams.cc: use UTF-8 as the default text + encoding. + Fixes Bug 2934. + + ChangeLog | 7 +++++++ + poppler/GlobalParams.cc | 2 +- + 2 files changed, 8 insertions(+), 1 deletion(-) + +commit c2db3e1b297a9dc0accd0d8a1366970d45705c8f +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed Apr 27 20:56:18 2005 +0000 + + 2005-04-27 Jeff Muizelaar <jeff@infidigm.net> + + * configure.ac: + * poppler/FlateStream.cc: + * poppler/FlateStream.h: + * poppler/Makefile.am: + * poppler/Stream.cc: + * poppler/Stream.h: Add a reimplementation of FlateStream using + zlib. + + ChangeLog | 10 +++++ + configure.ac | 29 ++++++++++++++ + poppler/FlateStream.cc | 107 + +++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/FlateStream.h | 68 +++++++++++++++++++++++++++++++ + poppler/Makefile.am | 17 +++++++- + poppler/Stream.cc | 6 +++ + poppler/Stream.h | 2 + + 7 files changed, 237 insertions(+), 2 deletions(-) + +commit bc0afe524c2b87af191d83fc9e9bcdc8a6ce4042 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed Apr 27 18:53:20 2005 +0000 + + 2005-04-27 Kristian Høgsberg <krh@redhat.com> + + * poppler/Catalog.cc (NameTree::lookup): Fix bsearch return + value + NULL check. Found by Albert Astals Cid. + + ChangeLog | 5 +++++ + poppler/Catalog.cc | 8 ++++---- + 2 files changed, 9 insertions(+), 4 deletions(-) + +commit 3c37dc350d54e5a1035aecfba5bfa394f931cf51 +Author: Jonathan Blandford <jrb@redhat.com> +Date: Tue Apr 26 17:17:05 2005 +0000 + + Tue Apr 26 13:13:42 2005 Jonathan Blandford <jrb@redhat.com> + + * glib/test-poppler-glib.c (main): add a quick dump-to-text + test. + + ChangeLog | 4 ++++ + glib/test-poppler-glib.c | 20 ++++++++++++++++++++ + 2 files changed, 24 insertions(+) + +commit 44b800d520f90ffd143255d2c23835ea357c195b +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Apr 25 18:04:32 2005 +0000 + + Actually commit the qt/Makefile.am change advertised in the ChangeLog. + + qt/Makefile.am | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +commit 437bec03dd2ab3cdf6215f9ad443b7f21ce84e18 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sun Apr 24 19:56:17 2005 +0000 + + 2005-04-24 Kristian Høgsberg <krh@redhat.com> + + * qt/Makefile.am (libpoppler_qt_la_SOURCES): Add + poppler-private.h + to SOURCES. + + ChangeLog | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 9b2b1244ed5f30a99120aaee49c72f7cb6a4f556 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sat Apr 23 20:16:02 2005 +0000 + + 2005-04-23 Kristian Høgsberg <krh@redhat.com> + + * poppler/CairoFontEngine.cc: Use the right fileName for + loading + CID fonts (#3114). + + ChangeLog | 5 +++++ + poppler/CairoFontEngine.cc | 11 +++++++++-- + 2 files changed, 14 insertions(+), 2 deletions(-) + +commit e4516d728a4d1bc85831d5d00b6d6b8d49c79308 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sat Apr 23 00:09:05 2005 +0000 + + 2005-04-22 Kristian Høgsberg <krh@redhat.com> + + * configure.ac: Actually commit version number bump. + + ChangeLog | 4 ++++ + NEWS | 2 +- + configure.ac | 2 +- + 3 files changed, 6 insertions(+), 2 deletions(-) + +commit c20448cb26fa1c309d726f272ddf1227f5a0e6ea +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Apr 22 17:29:49 2005 +0000 + + 2005-04-22 Martin Kretzschmar <martink@gnome.org> + + * poppler/CairoFontEngine.cc: declare matrix variable + before the + first goto. Fixes build with gcc 3.3. + + ChangeLog | 5 +++++ + poppler/CairoFontEngine.cc | 3 ++- + 2 files changed, 7 insertions(+), 1 deletion(-) + +commit 42ecccf9b454893797e3d62f0f1c0a3276689e51 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Apr 22 04:09:23 2005 +0000 + + Fri Apr 22 00:01:40 2005 Kristian Høgsberg <krh@redhat.com> + + * poppler/CairoFontEngine.cc: Hack around semi-broken + cairo-0.4.0 + font API to fix the problem where some glyphs would show up + at the + wrong sizes. We now create an FT_Face for each size and font + combination we encounter, since an FT_Face can't be shared + between + several cairo_font_t. + + ChangeLog | 8 +++++ + poppler/CairoFontEngine.cc | 79 + ++++++++++++++++++++-------------------------- + poppler/CairoFontEngine.h | 23 ++++++-------- + poppler/CairoOutputDev.cc | 18 +++++------ + 4 files changed, 61 insertions(+), 67 deletions(-) + +commit 7a703616d9497eba4d7d318da9918dae9cbe8f12 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Apr 21 19:50:45 2005 +0000 + + Thu Apr 21 15:43:52 2005 Kristian Høgsberg <krh@redhat.com> + + * poppler/Outline.cc: + * poppler/Outline.h: Implement the documented behaviour for + Outline::getItems() and OutlineItem::getKids() and make + documentation more precise (Patch from Marco). + + ChangeLog | 7 +++++++ + poppler/Outline.cc | 6 ++++++ + poppler/Outline.h | 7 ++++--- + 3 files changed, 17 insertions(+), 3 deletions(-) + +commit 5c89902c5ee2cf13536225c141768b29505815ce +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Apr 21 06:35:33 2005 +0000 + + Thu Apr 21 02:25:20 2005 Kristian Høgsberg <krh@redhat.com> + + * poppler/CairoFontEngine.cc (CairoFont::getFont): Cache + cairo_font_t's for a given CairoFont. With this patch + cairo will + recognize glyphs coming from the same font as such and + the glyph + cache will actually work. + + * glib/poppler-document.cc (poppler_document_new_from_file): + Add + output device (cairo or splash) to PopplerDocument and + initialize + it in the constructor. + + * glib/poppler-page.cc (splash_render_to_pixbuf, + cairo_render_to_pixbuf): Use output device from associated + poppler + document instead of creating a new one. + + * poppler-glib.pc.in (Requires): Add Requires: field. + + * poppler/Page.cc (loadThumb): Remove unecessary and buggy + call to + Stream::addFilters(), reported by Ryan Lortie (#3046). + + ChangeLog | 7 ++++++- + NEWS | 12 +++--------- + poppler/CairoFontEngine.cc | 45 + +++++++++++++++++++++++++++++++++++++++------ + poppler/CairoFontEngine.h | 9 ++++++++- + poppler/CairoOutputDev.cc | 9 +-------- + 5 files changed, 57 insertions(+), 25 deletions(-) + +commit 71c1563bb0462154cb7caa4356d8f8d049073ac4 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Apr 21 05:20:24 2005 +0000 + + Thu Apr 21 00:15:30 2005 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-document.cc (poppler_document_new_from_file): + Add + output device (cairo or splash) to PopplerDocument and + initialize + it in the constructor. + + * glib/poppler-page.cc (splash_render_to_pixbuf, + cairo_render_to_pixbuf): Use output device from associated + poppler + document instead of creating a new one. + + * poppler-glib.pc.in (Requires): Add Requires: field. + + * poppler/Page.cc (loadThumb): Remove unecessary and buggy + call to + Stream::addFilters(), reported by Ryan Lortie (#3046). + + ChangeLog | 15 +++++++++++++++ + NEWS | 15 +++++++++++++++ + glib/poppler-document.cc | 10 ++++++++++ + glib/poppler-page.cc | 22 ++-------------------- + glib/poppler-private.h | 13 +++++++++++++ + poppler-glib.pc.in | 1 + + poppler/CairoFontEngine.cc | 2 +- + poppler/Page.cc | 2 -- + 8 files changed, 57 insertions(+), 23 deletions(-) + +commit c6328cbc6cea05890b52a8302f8deba443959c03 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed Apr 20 22:48:52 2005 +0000 + + 2005-04-13 Jeff Muizelaar <jrmuizel@nit.ca> + + * qt/poppler-page.cc (Page::getText): + * qt/poppler-qt.h: add a getText method for getting + the text on a page + + * qt/test-poppler-qt.c (PDFDisplay::PDFDisplay): + add the option to display the text on a page + + Patch from Albert Astals Cid. + + ChangeLog | 11 +++++++++++ + qt/poppler-page.cc | 37 +++++++++++++++++++++++++++++++++++++ + qt/poppler-qt.h | 20 ++++++++++++++++++++ + qt/test-poppler-qt.cpp | 40 ++++++++++++++++++++++++++++++---------- + 4 files changed, 98 insertions(+), 10 deletions(-) + +commit 86a32b65100a5baedd18ce0135703289839a317c +Author: Jonathan Blandford <jrb@redhat.com> +Date: Tue Apr 19 21:22:26 2005 +0000 + + Tue Apr 19 17:21:19 2005 Jonathan Blandford <jrb@redhat.com> + + * glib/poppler-document.cc (poppler_document_get_property): + Use + %.2g instead. + + ChangeLog | 5 +++++ + glib/poppler-document.cc | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit 4e81624dcc2d5218f2f8bb4eaa992e724014a853 +Author: Jonathan Blandford <jrb@redhat.com> +Date: Tue Apr 19 21:13:22 2005 +0000 + + Tue Apr 19 17:11:52 2005 Jonathan Blandford <jrb@redhat.com> + + * glib/poppler-document.cc (poppler_document_get_property): + Use %g + instead of %f to avoid versioning like PDF-1.50000 + + ChangeLog | 5 +++++ + glib/poppler-document.cc | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit 6ef9d30f06be2bd8a9e1470d70f49843a7e432ac +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue Apr 19 19:48:49 2005 +0000 + + Tue Apr 19 15:43:35 2005 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-action.cc (_poppler_action_new): Handle + NULL links + gracefully (fix from Jeff). + + ChangeLog | 5 +++++ + glib/poppler-action.cc | 7 ++++++- + 2 files changed, 11 insertions(+), 1 deletion(-) + +commit 770b7310ce8b07f95960c2014bf3f6040c060ac4 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue Apr 19 04:28:15 2005 +0000 + + Tue Apr 19 00:20:08 2005 Kristian Høgsberg <krh@redhat.com> + + * poppler/Catalog.cc: Fix from Marco to make sure we always + initialize Catalog::pageLabelInfo. + + ChangeLog | 5 +++++ + poppler/Catalog.cc | 3 +-- + 2 files changed, 6 insertions(+), 2 deletions(-) + +commit 49c10d9f2c4e0cef031f96929e38a14d7ce5af19 +Author: Jonathan Blandford <jrb@redhat.com> +Date: Sat Apr 16 18:57:43 2005 +0000 + + Sat Apr 16 14:53:15 2005 Jonathan Blandford <jrb@redhat.com> + + * glib/Makefile.am: Create poppler-enums.[ch] + + * glib/poppler.h: + * glib/poppler-page.cc: + * glib/poppler-page.h: + * glib/poppler-action.h: Try to clean up the headers a bit + + * glib/poppler-document.cc: + * glib/poppler-document.h: Add support for document data. + Implemented as a lot of GObject properties. + + * glib/poppler-enums.c: + * glib/poppler-enums.h: New autogenerated files. + + * glib/test-poppler-glib.c: Test the new document metadata. + Seems + to work nicely, other than the PDF string and View Prefs. + + * poppler/Catalog.cc: + * poppler/Catalog.h: Extend to support PageLayout. + + ChangeLog | 22 ++++++ + glib/Makefile.am | 32 +++++++- + glib/poppler-action.h | 15 ++-- + glib/poppler-document.cc | 196 + ++++++++++++++++++++++++++++++++++++++++++----- + glib/poppler-document.h | 43 +++++++++-- + glib/poppler-enums.c | 144 ++++++++++++++++++++++++++++++++++ + glib/poppler-enums.h | 32 ++++++++ + glib/poppler-page.cc | 3 - + glib/poppler-page.h | 1 + + glib/poppler.h | 7 ++ + glib/test-poppler-glib.c | 48 +++++++++++- + poppler/Catalog.cc | 17 ++++ + poppler/Catalog.h | 11 +++ + 13 files changed, 529 insertions(+), 42 deletions(-) + +commit f35c76cd3528f1e1de594e85e734ca23624b3a62 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Apr 15 02:25:10 2005 +0000 + + 2005-04-14 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc: + * glib/poppler-page.h: + * glib/poppler-private.h: + * glib/poppler.h: Patch from Marco Pesenti Gritti to set page + orientaton. + + ChangeLog | 8 ++++ + glib/poppler-page.cc | 109 + +++++++++++++++++++++++++++++++++++++++++++++---- + glib/poppler-page.h | 45 ++++++++++---------- + glib/poppler-private.h | 1 + + glib/poppler.h | 9 ++++ + 5 files changed, 142 insertions(+), 30 deletions(-) + +commit 538408a8845e167cc2d796ac8b8129d0a2e6a894 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Thu Apr 14 01:34:38 2005 +0000 + + 2005-04-13 Jeff Muizelaar <jrmuizel@nit.ca> + + * poppler/CairoOutputDevImage.cc (getBitmap): remove unused + SplashBitmap. Patch from Albert Astals Cid. + + ChangeLog | 5 +++++ + poppler/CairoOutputDevImage.cc | 2 -- + 2 files changed, 5 insertions(+), 2 deletions(-) + +commit 2903530492c24f3c7cb3bf3b993500694aaa27a8 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue Apr 12 15:37:39 2005 +0000 + + 2005-04-12 Kristian Høgsberg <krh@redhat.com> + + * configure.ac: Add fontconfig to PKG_CHECK_MODULES for + the cairo + backend too, since we shouldn't depend on cairo.pc to pull + that in + for us. + + * poppler/Makefile.am (INCLUDES): Add $(splash_includes) to + INCLUDES to make sure the fontconfig include path is + added when + using the splash backend. + + ChangeLog | 10 ++++++++++ + configure.ac | 4 ++-- + poppler/Makefile.am | 1 + + 3 files changed, 13 insertions(+), 2 deletions(-) + +commit 0f7dd9a0512ff97293ee3f8a762b0049393b3cc1 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sat Apr 9 18:14:39 2005 +0000 + + 2005-04-09 Jeff Muizelaar <jrmuizel@nit.ca> + + * poppler-qt.h: + * poppler-document.cc (okToPrint, okToChange, okToCopy): + Patch from Albert Astals Cid adding more metadata exports + + ChangeLog | 6 ++++++ + qt/poppler-document.cc | 20 ++++++++++++++++++++ + qt/poppler-qt.h | 4 ++++ + 3 files changed, 30 insertions(+) + +commit dee72b531dab83a29c7675ae06ffe376e4498a4e +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Apr 8 21:09:27 2005 +0000 + + 2005-04-08 Kristian Høgsberg <krh@redhat.com> + + * poppler-qt.pc.in (Libs): Add -lpoppler to Libs. + + ChangeLog | 4 ++++ + poppler-qt.pc.in | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +commit df59ce3b1d5ca8cd46aaf5f189bc78953e21e1a9 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Fri Apr 8 03:30:33 2005 +0000 + + 2005-04-07 Jeff Muizelaar <jrmuizel@nit.ca> + + * configure.ac: redo the qt tests from Albert Astals Cid + + ChangeLog | 4 ++++ + configure.ac | 78 + ++++++++++++++++++++++++++++++++++++------------------------ + 2 files changed, 51 insertions(+), 31 deletions(-) + +commit 3f9dde10e4778255c468895942e45d1a2637af3a +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Fri Apr 8 03:11:00 2005 +0000 + + 2005-04-07 Jeff Muizelaar <jrmuizel@nit.ca> + + * qt/poppler-document.cc: + * qt/poppler-page.cc: + * qt/poppler-qt.h: + Patch from Albert Astals Cid adding consts and exporting some more + metadata. + + ChangeLog | 8 ++++++++ + qt/poppler-document.cc | 21 ++++++++++++++++++--- + qt/poppler-page.cc | 6 +++--- + qt/poppler-qt.h | 15 +++++++++------ + 4 files changed, 38 insertions(+), 12 deletions(-) + +commit e79a8b946e0d04b32da0b4ceea1649efd203cb07 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Apr 7 22:01:51 2005 +0000 + + 2005-04-07 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-document.cc: + * glib/poppler-document.h: + * glib/poppler-page.cc: + * glib/poppler-page.h: + * glib/poppler-private.h: Print to PS support from Marco + Pesenti + Gritti. + + ChangeLog | 9 +++++++++ + glib/poppler-document.cc | 45 + +++++++++++++++++++++++++++++++++++++++++++++ + glib/poppler-document.h | 8 ++++++-- + glib/poppler-page.cc | 19 +++++++++++++++++++ + glib/poppler-page.h | 40 +++++++++++++++++++++------------------- + glib/poppler-private.h | 7 +++++++ + 6 files changed, 107 insertions(+), 21 deletions(-) + +commit 7319b66eb64e735ae8b811306eb76755f088385b +Author: Jonathan Blandford <jrb@redhat.com> +Date: Thu Apr 7 16:26:15 2005 +0000 + + Thu Apr 7 12:25:39 2005 Jonathan Blandford <jrb@redhat.com> + + * configure.ac: check for qt, not glib, when enabling the qt + subdir + + ChangeLog | 5 +++++ + configure.ac | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit e258ed0cb42d524ee39451f680ad4c067e7721da +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed Apr 6 20:49:19 2005 +0000 + + 2005-04-06 Jeff Muizelaar <jrmuizel@nit.ca> + + * .cvsignore, glib/.cvsignore, qt/.cvsignore: + Add more things to .cvsignore. + Patch from Martin Kretzschmar. + + .cvsignore | 2 ++ + ChangeLog | 6 ++++++ + glib/.cvsignore | 7 +++++++ + qt/.cvsignore | 7 +++++++ + 4 files changed, 22 insertions(+) + +commit 2a5624a81aa84677a57e098d7d4045f44e3b6f3a +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed Apr 6 20:35:03 2005 +0000 + + 2005-04-06 Jeff Muizelaar <jrmuizel@nit.ca> + + * poppler-page.cc (Page::Page, Page::~Page): + Construct and deconstruct the PageData object. + Patch from Albert Astals Cid. + + ChangeLog | 6 ++++++ + qt/poppler-page.cc | 6 ++++++ + qt/poppler-qt.h | 1 + + 3 files changed, 13 insertions(+) + +commit f983e3d317660653f2bfc56f9b06e2cec675beca +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed Apr 6 14:39:40 2005 +0000 + + 2005-04-06 Jeff Muizelaar <jrmuizel@nit.ca> + + * Makefile.am, configure.ac: Add configuration for qt wrapper. + + * poppler-qt.pc.in: + * qt/Makefile.am: + * qt/poppler-document.cc: + * qt/poppler-page.cc: + * qt/poppler-private.h: + * qt/poppler-qt.h: + * qt/test-poppler-qt.cpp: + New files. + + ChangeLog | 13 +++ + Makefile.am | 13 ++- + configure.ac | 64 +++++++++++++- + poppler-qt.pc.in | 11 +++ + qt/Makefile.am | 32 +++++++ + qt/poppler-document.cc | 232 + +++++++++++++++++++++++++++++++++++++++++++++++++ + qt/poppler-page.cc | 66 ++++++++++++++ + qt/poppler-private.h | 32 +++++++ + qt/poppler-qt.h | 75 ++++++++++++++++ + qt/test-poppler-qt.cpp | 63 ++++++++++++++ + 10 files changed, 597 insertions(+), 4 deletions(-) + +commit d91dd69a7a0dd581c26728d2640e4d36a7ffe75f +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue Apr 5 17:46:44 2005 +0000 + + 2005-04-05 Kristian Høgsberg <krh@redhat.com> + + * NEWS: Attempt to sum up changes since 0.1.2. + + * configure.ac: Bump release to 0.2.0, add AC_DEFINEs + for cairo + and splash availability. + + * poppler/CairoFontEngine.cc: Disable hinting. + + * glib/poppler-page.cc (poppler_page_render_to_pixbuf): Choose + either splash or cairo rendering, based on configure choice. + (cairo_render_to_pixbuf): New function to render using + the cairo + backend. + (splash_render_to_pixbuf): Split out the splash code to this + function. + + ChangeLog | 16 +++++ + NEWS | 6 +- + configure.ac | 16 +++-- + glib/Makefile.am | 17 ++++- + glib/poppler-page.cc | 152 + +++++++++++++++++++++++++++++++++-------- + poppler/CairoFontEngine.cc | 2 +- + poppler/CairoOutputDevImage.cc | 20 ++---- + poppler/CairoOutputDevImage.h | 3 +- + 8 files changed, 179 insertions(+), 53 deletions(-) + +commit b62b0cec2335d987b31fbb0043cb33db29cc6a13 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue Apr 5 02:56:32 2005 +0000 + + 2005-04-04 Kristian Høgsberg <krh@redhat.com> + + * ChangeLog: Add this entry to test commit mailer script. + + ChangeLog | 2 ++ + 1 file changed, 2 insertions(+) + +commit 50b494266ce197fe88468ca2917b9910d77e5f98 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue Apr 5 02:49:18 2005 +0000 + + 2005-04-04 Kristian Høgsberg <krh@redhat.com> + + * TODO: Add reminder about using PDF font descriptors with + fontconfig. + + ChangeLog | 3 +++ + TODO | 2 ++ + 2 files changed, 5 insertions(+) + +commit d3d12235bf4de48363571b3d992ea3bfc29e6529 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Apr 4 21:50:56 2005 +0000 + + 2005-04-04 Kristian Høgsberg <krh@redhat.com> + + * configure.ac: Add checks for mkstemp() and mkstemps(). + + * glib/poppler-page.cc (poppler_page_find_text): Reverse + y-coordinates so we return PDF style coordinates. + + From Maro Pesenti Gritti <mpgritti@gmail.com>: + + * configure.ac, poppler/Makefile.am: Check for fontconfig when + we're building the splash backend. + + * glib/poppler-page.cc (poppler_page_get_text): New + function to + select text on page. + + ChangeLog | 15 +++++++++++++++ + configure.ac | 5 ++++- + glib/poppler-page.cc | 48 + +++++++++++++++++++++++++++++++++++++++++++++--- + glib/poppler-page.h | 3 +++ + poppler/Makefile.am | 4 ++++ + 5 files changed, 71 insertions(+), 4 deletions(-) + +commit 2cb9d70678e33504246cbfbe0525c33f5e3b7736 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Apr 4 05:56:29 2005 +0000 + + 2005-04-04 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc (poppler_page_find_text): Reverse + list of + matches so we get them in the right order. + + ChangeLog | 5 +++++ + glib/poppler-page.cc | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit 8c2a5ffb73c0f2d84adebcfbd43f8347ae8c8bbc +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sun Apr 3 18:17:55 2005 +0000 + + 2005-04-03 Martin Kretzschmar <martink@gnome.org> + + * poppler/DCTStream.h: Wrap #include <jpeglib.h> in extern "C" + Fixes build with unpatched libjpeg. + + ChangeLog | 5 +++++ + poppler/DCTStream.h | 2 ++ + 2 files changed, 7 insertions(+) + +commit 1879d82d9088aa36ef5e677f4bae44c84f90caa6 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Sat Apr 2 22:16:38 2005 +0000 + + 2005-04-02 Jeff Muizelaar <jrmuizel@nit.ca> + + * poppler/Page.h: + * poppler/Page.cc (Page::Page): + Some initial infrastructure for supporting transitions. + + ChangeLog | 6 ++++++ + poppler/Page.cc | 10 ++++++++++ + poppler/Page.h | 4 ++++ + 3 files changed, 20 insertions(+) + +commit fa4efbed51e12811070798a7cfb6b1f9e8d57abc +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Apr 1 00:32:34 2005 +0000 + + 2005-03-31 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc (poppler_page_render_to_pixbuf): Clip + output to destination pixbuf and fix RGB order. + + ChangeLog | 5 +++++ + glib/poppler-page.cc | 38 +++++++++++++++++++++++--------------- + 2 files changed, 28 insertions(+), 15 deletions(-) + +commit bb508ded0b8c5806a9db1ec73e57b14268896911 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Mar 31 22:45:05 2005 +0000 + + 2005-03-31 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc (poppler_page_find_text): New + function to + seach a page for occurrences of a given text string. + + * glib/poppler-page.cc: Add g_return_if_fail() checks to + a couple + of functions. + + ChangeLog | 8 +++++ + glib/poppler-page.cc | 82 + ++++++++++++++++++++++++++++++++++++++++++------ + glib/poppler-page.h | 18 ++++++++--- + glib/test-poppler-glib.c | 19 +++++++++-- + 4 files changed, 109 insertions(+), 18 deletions(-) + +commit 0b4d481e9c79cb18cf41b503970801bbf4b95b3c +Author: Jonathan Blandford <jrb@redhat.com> +Date: Thu Mar 31 05:29:42 2005 +0000 + + Thu Mar 31 00:26:20 2005 Jonathan Blandford <jrb@redhat.com> + + * glib/poppler-page.cc: + * glib/poppler-page.h (poppler_page_get_link_mapping, + poppler_page_free_link_mapping): New functions to get a + mapping of + links to locations on the current document. + :s + + ChangeLog | 7 +++++ + glib/poppler-page.cc | 85 + ++++++++++++++++++++++++++++++++++++++++++++++++---- + glib/poppler-page.h | 15 ++++++++++ + 3 files changed, 102 insertions(+), 5 deletions(-) + +commit c4e18f5a454794bd5e226f1106a54ccf807c6c3d +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Thu Mar 31 02:28:46 2005 +0000 + + 2005-03-30 Jeff Muizelaar <jrmuizel@nit.ca> + + * poppler/DCTStream.h: change x to unsigned int to eliminate + comparision warning + + ChangeLog | 5 +++++ + poppler/DCTStream.h | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +commit e6a2a588305b4797af901599eb6854028f2be476 +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed Mar 30 18:43:44 2005 +0000 + + 2005-03-30 Jeff Muizelaar <jrmuizel@nit.ca> + + * poppler/Catalog.cc: delete pageLabelInfo on deconstruction + + ChangeLog | 4 ++++ + poppler/Catalog.cc | 1 + + 2 files changed, 5 insertions(+) + +commit a52905c0f0bf4d10d2103b80924a4de204d03836 +Author: Jonathan Blandford <jrb@redhat.com> +Date: Wed Mar 30 04:08:26 2005 +0000 + + add this + + glib/poppler-action.cc | 285 + +++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 285 insertions(+) + +commit 9542860a74076020b5727d4b761c08cdab42d69e +Author: Jonathan Blandford <jrb@redhat.com> +Date: Wed Mar 30 04:07:57 2005 +0000 + + add these + + glib/poppler-action.h | 157 + ++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 157 insertions(+) + +commit 07720f98eca8736695f7d0d8e98465d301e6b7cf +Author: Jonathan Blandford <jrb@redhat.com> +Date: Wed Mar 30 04:07:39 2005 +0000 + + Tue Mar 29 23:07:17 2005 Jonathan Blandford <jrb@redhat.com> + + * glib/poppler-page.h: Reformat. + + ChangeLog | 4 ++++ + glib/poppler-page.h | 34 +++++++++++++++++----------------- + 2 files changed, 21 insertions(+), 17 deletions(-) + +commit 3437b9e122aa05f4ede24664ee5a9b2d423ef9c4 +Author: Jonathan Blandford <jrb@redhat.com> +Date: Wed Mar 30 04:04:53 2005 +0000 + + Tue Mar 29 22:49:15 2005 Jonathan Blandford <jrb@redhat.com> + + * glib/poppler-action.[ch]: New item to encapsulate links. + * glib/poppler-document.[ch] (poppler_index_iter_get_action): + New + function to get the action. Also, fix some warnings. + * glib/poppler-private.h (_poppler_action_new): New function. + * glib/test-poppler-glib.c: Fix warnings. + + ChangeLog | 8 +++++++ + glib/Makefile.am | 2 ++ + glib/poppler-document.cc | 57 + +++++++++++------------------------------------- + glib/poppler-document.h | 7 ++---- + glib/poppler-private.h | 12 ++++++++-- + glib/poppler.h | 1 + + glib/test-poppler-glib.c | 4 +++- + 7 files changed, 39 insertions(+), 52 deletions(-) + +commit cab0ec4d011c34b571050a446c6e3286cc8749c8 +Author: Jonathan Blandford <jrb@redhat.com> +Date: Tue Mar 29 18:49:26 2005 +0000 + + Tue Mar 29 02:36:00 2005 Jonathan Blandford <jrb@redhat.com> + + * glib/poppler-document.[ch] (PopplerIndexIter): Add an + iter to + extract the index from the doc. Includes a bad hack, for now. + + Mon Mar 28 22:02:07 2005 Jonathan Blandford <jrb@redhat.com> + + * glib/poppler-page.cc: + * glib/poppler-page.h (poppler_page_get_thumbnail_size): New + function. + * poppler-glib.pc.in: add -lpoppler-glib to the libs line. + + ChangeLog | 12 ++++ + glib/poppler-document.cc | 160 + ++++++++++++++++++++++++++++++++++++++++++++++- + glib/poppler-document.h | 15 +++++ + glib/poppler-page.cc | 48 +++++++++++++- + glib/poppler-page.h | 3 + + poppler-glib.pc.in | 2 +- + 6 files changed, 236 insertions(+), 4 deletions(-) + +commit 2de98f3871bc4ea3e361ca4fe37f5b6561918c77 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Mar 28 07:49:54 2005 +0000 + + 2005-03-28 Kristian Høgsberg <krh@redhat.com> + + * poppler/Page.cc (loadThumb): Backend agnostic method for + extracting an embedded thumbnail iamge. + + * poppler/Dict.cc (lookupInt): New convenience method. + + * glib/poppler-page.cc (poppler_page_get_thumbnail): New glib + function for getting the embedded thumbnail image for a page. + + ChangeLog | 10 +++++ + glib/poppler-page.cc | 23 ++++++++++ + glib/poppler-page.h | 32 +++++++------- + glib/test-poppler-glib.c | 24 ++++++++--- + poppler/Dict.cc | 20 +++++++++ + poppler/Dict.h | 1 + + poppler/Page.cc | 109 + +++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Page.h | 1 + + 8 files changed, 196 insertions(+), 24 deletions(-) + +commit 591055d1fbcd0b9c2bb11f14040568051c5976d1 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sat Mar 26 00:34:21 2005 +0000 + + 2005-03-25 Kristian Høgsberg <krh@redhat.com> + + * glib/Makefile.am (libpoppler_glib_la_SOURCES): Add + + * configure.ac: Check for fontconfig for glib bindings. + + ChangeLog | 4 ++++ + configure.ac | 4 ++-- + glib/Makefile.am | 7 +++++-- + 3 files changed, 11 insertions(+), 4 deletions(-) + +commit 1e30abe94a96b91df05716ea079c58782d767951 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Mar 24 22:24:41 2005 +0000 + + 2005-03-24 Kristian Høgsberg <krh@redhat.com> + + * glib/Makefile.am: Use POPPLER_GLIB_CFLAGS and + POPPLER_GLIB_LIBS + instead of GTK_TEST_*. Reported by Adam Jackson + <ajax@nwnk.net>. + + ChangeLog | 5 +++++ + glib/Makefile.am | 7 +++---- + 2 files changed, 8 insertions(+), 4 deletions(-) + +commit 1d9fcaa34222b2ccd53280148561917dbb8d95d9 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed Mar 23 05:53:08 2005 +0000 + + File Edit Options Buffers Tools Help + 2005-03-23 Kristian Høgsberg <krh@redhat.com> + + * poppler/Catalog.cc (indexToLabel, labelToIndex): Add + stricter + checking of incoming labels and indices. + + * glib/test-poppler-glib.c (main): Change test program to + take the + page label from the command line. + + ChangeLog | 6 ++++++ + glib/test-poppler-glib.c | 5 ++++- + poppler/Catalog.cc | 31 +++++++++++++++++++++++++++++-- + 3 files changed, 39 insertions(+), 3 deletions(-) + +commit a9bbb465a0ee6ab320f76d322a3f575327ad1148 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed Mar 23 05:38:34 2005 +0000 + + 2005-03-23 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-page.cc: + * glib/poppler-page.h: Add poppler_page_get_index() and rename + popper_page_get_dimension() to popper_page_get_size() + + ChangeLog | 6 ++++++ + glib/poppler-page.cc | 12 +++++++++--- + glib/poppler-page.h | 32 +++++++++++++++++--------------- + glib/test-poppler-glib.c | 5 ++--- + 4 files changed, 34 insertions(+), 21 deletions(-) + +commit 178bff27d09d1e18d1fc00c975fa235b0e9f93d3 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed Mar 23 04:14:28 2005 +0000 + + 2005-03-22 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-document.cc: Implement poppler_document_save(). + + * glib/poppler-document.h: Add prototype and format headers + properly. + + ChangeLog | 7 +++++++ + glib/poppler-document.cc | 20 ++++++++++++++++++++ + glib/poppler-document.h | 30 +++++++++++++----------------- + 3 files changed, 40 insertions(+), 17 deletions(-) + +commit e40c6f69c9466df4cc70840b959f72cb0809c777 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed Mar 23 01:30:04 2005 +0000 + + 2005-03-22 Kristian Høgsberg <krh@redhat.com> + + * configure.ac: Fix --disable-popper typo reported by Albert. + Require exactly cairo 0.4 since CVS cairo has API changes. + + ChangeLog | 5 +++++ + configure.ac | 6 +++--- + 2 files changed, 8 insertions(+), 3 deletions(-) + +commit 2a1e4f6f6dd87dc59b3579175a87215fd7350ee0 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue Mar 22 22:46:37 2005 +0000 + + 2005-03-22 Kristian Høgsberg <krh@redhat.com> + + * poppler/Array.cc: + * poppler/Array.h: Add getString() convenience method. + + * poppler/Catalog.cc: + * poppler/Catalog.h: Optimize lookup of named destinations. + + ChangeLog | 8 +++ + poppler/Array.cc | 15 ++++++ + poppler/Array.h | 1 + + poppler/Catalog.cc | 142 + ++++++++++++++++++++++++++++++++++------------------- + poppler/Catalog.h | 32 +++++++++++- + 5 files changed, 146 insertions(+), 52 deletions(-) + +commit 4dfe0ce4a1ca09d632943f0f6315e31135957ada +Author: Kristian Høgsberg <krh@redhat.com> +Date: Tue Mar 22 01:50:05 2005 +0000 + + 2005-03-21 Kristian Høgsberg <krh@redhat.com> + + * NEWS, TODO: Update these. + + ChangeLog | 4 ++++ + NEWS | 1 + + TODO | 29 ++++++++++++++++++++--------- + 3 files changed, 25 insertions(+), 9 deletions(-) + +commit c158de90a5a8c6514d8aa22efa0b891a1801e822 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Mar 21 07:53:19 2005 +0000 + + 2005-03-21 Kristian Høgsberg <krh@redhat.com> + + From Albert Astals Cid <tsdgeos@yahoo.es>: + + * poppler/Catalog.cc, poppler/Catalog.h: Parse PageMode + setting + from the Catalog dict and expose it through getPageMode() + method. + + ChangeLog | 10 ++++++++-- + poppler/Catalog.cc | 16 ++++++++++++++++ + poppler/Catalog.h | 12 ++++++++++++ + 3 files changed, 36 insertions(+), 2 deletions(-) + +commit 9887679ca195714d71cbedde9297e9dcea04eb13 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Mon Mar 21 07:36:11 2005 +0000 + + 2005-03-21 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-document.cc: + + * glib/poppler-document.h: Expose the documenttitle as + a GObject + property. + + * glib/poppler-page.cc: Expose the page label as a GObject + property. + + * glib/poppler-private.h: Add the page index to PopplerPage. + + * glib/test-poppler-glib.c: Print out page label and document + title. + + * poppler/Catalog.cc: + * poppler/Catalog.h: Add page label accessors. + + * poppler/PageLabelInfo.cc: + * poppler/PageLabelInfo.h: New files. + + * poppler/Makefile.am: Add new files to sources. + + ChangeLog | 23 ++++ + glib/poppler-document.cc | 95 ++++++++++++- + glib/poppler-document.h | 3 + + glib/poppler-page.cc | 37 ++++- + glib/poppler-private.h | 3 +- + glib/test-poppler-glib.c | 13 +- + poppler/Catalog.cc | 15 ++ + poppler/Catalog.h | 6 + + poppler/Makefile.am | 4 +- + poppler/PageLabelInfo.cc | 346 + +++++++++++++++++++++++++++++++++++++++++++++++ + poppler/PageLabelInfo.h | 37 +++++ + 11 files changed, 573 insertions(+), 9 deletions(-) + +commit 2cfe917de909254bc3a114a6add68a14b5885fd0 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sun Mar 20 05:44:06 2005 +0000 + + 2005-03-20 Kristian Høgsberg <krh@redhat.com> + + * glib/poppler-document.cc: + * glib/poppler-page.h: + * glib/poppler.cc: + * poppler/Array.cc: + * poppler/Array.h: + * poppler/Catalog.cc: Fix up filenames in #include statements + and + comments. + + ChangeLog | 10 ++++++++++ + glib/poppler-document.cc | 2 +- + glib/poppler-document.h | 2 +- + glib/poppler-page.cc | 2 +- + glib/poppler-page.h | 2 +- + glib/poppler.cc | 2 +- + glib/poppler.h | 2 +- + 7 files changed, 16 insertions(+), 6 deletions(-) + +commit f9b6017cfaf8f814ae2fc027927477c29f24af71 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sun Mar 20 00:35:21 2005 +0000 + + 2005-03-19 Kristian Høgsberg <krh@redhat.com> + + Land the first bits of the glib wrapper. + + * Makefile.am: + * configure.ac: Add new glib subdirectory and configure + options + for glib wrapper. + + * glib/Makefile.am: + * glib/poppler-document.cc: + * glib/poppler-document.h: + * glib/poppler-page.cc: + * glib/poppler-page.h: + * glib/poppler-private.h: + * glib/poppler.cc: + * glib/poppler.h: + * glib/test-poppler-glib.c: + * poppler-glib.pc.in: New files. + + ChangeLog | 19 ++++++ + Makefile.am | 27 ++++---- + NEWS | 4 ++ + configure.ac | 25 ++++++- + glib/Makefile.am | 33 ++++++++++ + glib/poppler-document.cc | 165 + +++++++++++++++++++++++++++++++++++++++++++++++ + glib/poppler-document.h | 52 +++++++++++++++ + glib/poppler-page.cc | 158 + +++++++++++++++++++++++++++++++++++++++++++++ + glib/poppler-page.h | 50 ++++++++++++++ + glib/poppler-private.h | 20 ++++++ + glib/poppler.cc | 29 +++++++++ + glib/poppler.h | 42 ++++++++++++ + glib/test-poppler-glib.c | 43 ++++++++++++ + poppler-glib.pc.in | 11 ++++ + 14 files changed, 661 insertions(+), 17 deletions(-) + +commit 2a31446b227b5cdc8334e672a71835b6ea14713a +Author: Jeff Muizelaar <jeff@infidigm.net> +Date: Wed Mar 16 15:51:36 2005 +0000 + + 2005-03-16 Jeff Muizelaar <jrmuizel@nit.ca> + + From Dan Sheridan <dan.sheridan@postman.org.uk> + + * poppler/XRef.cc (XRef::checkEncrypted): + The key length should be 5 for revision 2 documents. + + ChangeLog | 7 +++++++ + poppler/XRef.cc | 6 ++++++ + 2 files changed, 13 insertions(+) + +commit e632a1d4b2f685993bda407458c34ef8e6b74136 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Mar 11 22:43:29 2005 +0000 + + 2005-03-11 Kristian Høgsberg <krh@redhat.com> + + From Jeff Muizelaar <jrmuizel@nit.ca>: + + * poppler/CairoOutputDev.cc (CairoOutputDev::drawImageMask): + Use + getLine instead of getPixel. + + ChangeLog | 3 +++ + poppler/CairoOutputDev.cc | 18 ++++++++---------- + 2 files changed, 11 insertions(+), 10 deletions(-) + +commit 83e904452f205a2c0cd2723cb12b7fd4640ce342 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Mar 11 21:42:52 2005 +0000 + + 2005-03-11 Kristian Høgsberg <krh@redhat.com> + + From Jeff Muizelaar <jrmuizel@nit.ca>: + + * configure.ac: Add checks for libjpeg. + + * DCTStream.cc, DCTStream.h, Stream.cc, Stream.h, Makefile.am: + Conditionally use libjpeg instead of xpdf jpeg decoder. + + ChangeLog | 9 +++++ + configure.ac | 34 +++++++++++++++- + poppler/DCTStream.cc | 110 + +++++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/DCTStream.h | 70 ++++++++++++++++++++++++++++++++ + poppler/Makefile.am | 14 ++++++- + poppler/Stream.cc | 8 ++++ + poppler/Stream.h | 2 + + 7 files changed, 245 insertions(+), 2 deletions(-) + +commit e2af71338fd89760c4ac76999985efc5eb92817f +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Mar 11 16:42:20 2005 +0000 + + 2005-03-10 Kristian Høgsberg <krh@redhat.com> + + From Jeff Muizelaar <jrmuizel@nit.ca>: + + * poppler/CairoFontEngine.cc (CairoFontEngine::getFont): + Don't print "Type 3 font!" message. + + * poppler/CairoOutputDev.cc (CairoOutputDev::drawImageMask): + Enable image mask drawing and do it properly, albeit slowly. + + * poppler/CairoOutputDev.h + (CairoOutputDev::interpretType3Chars): Return true so that + Gfx.cc turns type3 characters into calls to drawImageMask + + ChangeLog | 14 ++++++++++++++ + poppler/CairoFontEngine.cc | 1 - + poppler/CairoOutputDev.cc | 25 ++++++++++--------------- + poppler/CairoOutputDev.h | 2 +- + 4 files changed, 25 insertions(+), 17 deletions(-) + +commit 3dc52373346e448077d2539163e873eef6406ed7 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed Mar 9 15:47:00 2005 +0000 + + 2005-03-09 Kristian Høgsberg <krh@redhat.com> + + * NEWS: Describe 0.1.2 (and 0.1.1) release. + + * configure.ac: Bump poppler version to 0.1.2 + + ChangeLog | 6 ++++++ + NEWS | 12 ++++++++++++ + configure.ac | 2 +- + 3 files changed, 19 insertions(+), 1 deletion(-) + +commit 5c6a2d34fc25df28ca5326e6910d7cf664f0c3d7 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Wed Mar 9 15:35:31 2005 +0000 + + 2005-03-09 Kristian Høgsberg <krh@redhat.com> + + * configure.ac: Bump cairo requirement to 0.4. + + ChangeLog | 4 ++++ + configure.ac | 4 ++-- + 2 files changed, 6 insertions(+), 2 deletions(-) + +commit 5b2d9a61e79cefd819888c8c89231a5fafccd114 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sat Mar 5 04:57:49 2005 +0000 + + 2005-03-04 Kristian Høgsberg <krh@redhat.com> + + Patch from Jeff Muizelaar <jrmuizel@nit.ca>. Changed to + allocate + glyphs using gmalloc. + + * poppler/CairoOutputDev.cc (CairoOutputDev::drawString): + Implement drawString instead of drawChar. This change should + make clipping to a text path work and has a performance + improvement. Currently the code is a little ugly because we + can't concat matrices to cairo without losing our current + font. + + * poppler/CairoOutputDev.h (CairoOutputDev::useDrawChar): + Tell Gfx.cc that it should use drawString instead of drawChar. + + ChangeLog | 14 ++++++ + TODO | 3 ++ + poppler/CairoOutputDev.cc | 110 + ++++++++++++++++++++++++++++++++++------------ + poppler/CairoOutputDev.h | 7 +-- + 4 files changed, 102 insertions(+), 32 deletions(-) + +commit 60d190ef80a0dcd9cc3a67306e2c65c5dd482f24 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sat Mar 5 04:37:14 2005 +0000 + + 2005-03-04 Kristian Høgsberg <krh@redhat.com> + + * test/gtk-cairo-test.cc (view_load): + * test/gtk-splash-test.cc (view_load): Fix missing return + statement, and remove unused variables. + + * configure.ac: Add configure option to enable the default KDE + flags as described by Albert Astals Cid <tsdgeos@yahoo.es>. + + * TODO: Update with Jeff's items. + + * .cvsignore: + * */.cvsignore: Add these to silence CVS. + + ChangeLog | 9 +++++++++ + TODO | 15 +++++++++++---- + configure.ac | 21 +++++++++++++++++++++ + test/gtk-cairo-test.cc | 6 ++---- + test/gtk-splash-test.cc | 5 ++--- + 5 files changed, 45 insertions(+), 11 deletions(-) + +commit e6706e505c1675724c8870f7c58079932661db5f +Author: Kristian Høgsberg <krh@redhat.com> +Date: Sat Mar 5 02:19:50 2005 +0000 + + 2005-03-04 Kristian Høgsberg <krh@redhat.com> + + * .cvsignore: + * */.cvsignore: Add these to silence CVS. + + .cvsignore | 21 +++++++++++++++++++++ + ChangeLog | 3 +++ + fofi/.cvsignore | 8 ++++++++ + goo/.cvsignore | 8 ++++++++ + poppler/.cvsignore | 10 ++++++++++ + splash/.cvsignore | 8 ++++++++ + test/.cvsignore | 10 ++++++++++ + 7 files changed, 68 insertions(+) + +commit 932edfc3c5c61e3b3e98957b717abbf8055e1c5e +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Mar 4 19:47:13 2005 +0000 + + 2005-03-04 Kristian Høgsberg <krh@redhat.com> + + * configure.ac: Implement same check for gtk+-2.0 tests as for + cairo. + + ChangeLog | 5 +++++ + configure.ac | 11 ++++++++--- + 2 files changed, 13 insertions(+), 3 deletions(-) + +commit c632b35ad9345f280d78c268f84ae3fd5a3921b9 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Mar 4 16:33:43 2005 +0000 + + 2005-03-04 Kristian Høgsberg <krh@redhat.com> + + * configure.ac: Only fail hard in check for cairo if the user + specified --enable-cairo-output (from Brad Hards + <bradh@frogmouth.net>). Print summary of configure results + at the + end of configure script. + + * poppler/poppler-config.h: Remove this file (noticed by Brad + Hards <bradh@frogmouth.net>). + + ChangeLog | 5 +++++ + configure.ac | 17 ++++++++++++++--- + 2 files changed, 19 insertions(+), 3 deletions(-) + +commit 80f9c90273eb31ac349c46bf86dedff7daf21db4 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Mar 4 15:32:32 2005 +0000 + + 2005-03-04 Kristian Høgsberg <krh@redhat.com> + + * poppler/poppler-config.h: Remove this file (noticed by Brad + Hards <bradh@frogmouth.net>). + + ChangeLog | 5 ++ + poppler/poppler-config.h | 146 + ----------------------------------------------- + 2 files changed, 5 insertions(+), 146 deletions(-) + +commit 338b83b6f08a7212fdde2bbce94385e9a71a3d23 +Author: Kristian Høgsberg <krh@redhat.com> +Date: Fri Mar 4 02:46:44 2005 +0000 + + 2005-03-03 Kristian Høgsberg <krh@redhat.com> + + Patch from Jeff Muizelaar <jrmuizel@nit.ca>: + + * poppler/CairoOutputDev.cc (CairoOutputDev::drawImage, + CairoOutputDev::drawImageMask): destroy the image surface and + free the image buffer. + + ChangeLog | 10 ++++++++++ + autogen.sh | 2 +- + poppler/CairoOutputDev.cc | 8 +++++--- + 3 files changed, 16 insertions(+), 4 deletions(-) + +commit 062aa51487f539406b54458885b4c9501da3c44d +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Mar 3 20:01:14 2005 +0000 + + 2005-03-03 Kristian Høgsberg <krh@redhat.com> + + * autogen.sh: Add to CVS. + + ChangeLog | 4 ++++ + autogen.sh | 4 ++++ + 2 files changed, 8 insertions(+) + +commit cb02d5d0e770e2a8cbe5a8ac810820a2ce5fec0c +Author: Kristian Høgsberg <krh@redhat.com> +Date: Thu Mar 3 19:45:58 2005 +0000 + + Initial revision + + AUTHORS | 3 + + COPYING | 340 ++++ + ChangeLog | 33 + + INSTALL | 236 +++ + Makefile.am | 29 + + NEWS | 4 + + README | 37 + + README-XPDF | 376 ++++ + TODO | 21 + + configure.ac | 139 ++ + fofi/FoFiBase.cc | 156 ++ + fofi/FoFiBase.h | 55 + + fofi/FoFiEncodings.cc | 994 ++++++++++ + fofi/FoFiEncodings.h | 34 + + fofi/FoFiTrueType.cc | 1438 ++++++++++++++ + fofi/FoFiTrueType.h | 131 ++ + fofi/FoFiType1.cc | 207 ++ + fofi/FoFiType1.h | 57 + + fofi/FoFiType1C.cc | 2385 ++++++++++++++++++++++ + fofi/FoFiType1C.h | 224 +++ + fofi/Makefile.am | 16 + + goo/GooHash.cc | 356 ++++ + goo/GooHash.h | 74 + + goo/GooList.cc | 92 + + goo/GooList.h | 89 + + goo/GooMutex.h | 49 + + goo/GooString.cc | 236 +++ + goo/GooString.h | 98 + + goo/Makefile.am | 20 + + goo/gfile.cc | 705 +++++++ + goo/gfile.h | 140 ++ + goo/gmem.c | 204 ++ + goo/gmem.h | 53 + + goo/gmempp.cc | 32 + + goo/gtypes.h | 29 + + poppler-cairo.pc.in | 10 + + poppler-splash.pc.in | 10 + + poppler.pc.in | 11 + + poppler/Annot.cc | 137 ++ + poppler/Annot.h | 79 + + poppler/Array.cc | 73 + + poppler/Array.h | 56 + + poppler/BaseFile.h | 82 + + poppler/BuiltinFont.cc | 65 + + poppler/BuiltinFont.h | 55 + + poppler/BuiltinFontTables.cc | 4284 + ++++++++++++++++++++++++++++++++++++++++ + poppler/BuiltinFontTables.h | 23 + + poppler/CMap.cc | 384 ++++ + poppler/CMap.h | 101 + + poppler/CairoFontEngine.cc | 367 ++++ + poppler/CairoFontEngine.h | 61 + + poppler/CairoOutputDev.cc | 569 ++++++ + poppler/CairoOutputDev.h | 146 ++ + poppler/CairoOutputDevImage.cc | 87 + + poppler/CairoOutputDevImage.h | 43 + + poppler/CairoOutputDevX.cc | 211 ++ + poppler/CairoOutputDevX.h | 117 ++ + poppler/Catalog.cc | 364 ++++ + poppler/Catalog.h | 87 + + poppler/CharCodeToUnicode.cc | 533 +++++ + poppler/CharCodeToUnicode.h | 112 ++ + poppler/CharTypes.h | 24 + + poppler/CompactFontTables.h | 464 +++++ + poppler/Decrypt.cc | 399 ++++ + poppler/Decrypt.h | 59 + + poppler/Dict.cc | 95 + + poppler/Dict.h | 75 + + poppler/Error.cc | 38 + + poppler/Error.h | 21 + + poppler/ErrorCodes.h | 36 + + poppler/FontEncodingTables.cc | 1824 +++++++++++++++++ + poppler/FontEncodingTables.h | 20 + + poppler/Function.cc | 1525 ++++++++++++++ + poppler/Function.h | 181 ++ + poppler/Gfx.cc | 3079 +++++++++++++++++++++++++++++ + poppler/Gfx.h | 279 +++ + poppler/GfxFont.cc | 1508 ++++++++++++++ + poppler/GfxFont.h | 313 +++ + poppler/GfxState.cc | 2782 ++++++++++++++++++++++++++ + poppler/GfxState.h | 1053 ++++++++++ + poppler/GlobalParams.cc | 1764 +++++++++++++++++ + poppler/GlobalParams.h | 312 +++ + poppler/JArithmeticDecoder.cc | 300 +++ + poppler/JArithmeticDecoder.h | 89 + + poppler/JBIG2Stream.cc | 3337 +++++++++++++++++++++++++++++++ + poppler/JBIG2Stream.h | 141 ++ + poppler/JPXStream.cc | 2822 ++++++++++++++++++++++++++ + poppler/JPXStream.h | 338 ++++ + poppler/Lexer.cc | 474 +++++ + poppler/Lexer.h | 75 + + poppler/Link.cc | 851 ++++++++ + poppler/Link.h | 407 ++++ + poppler/Makefile.am | 140 ++ + poppler/NameToCharCode.cc | 116 ++ + poppler/NameToCharCode.h | 40 + + poppler/NameToUnicodeTable.h | 1097 ++++++++++ + poppler/Object.cc | 231 +++ + poppler/Object.h | 301 +++ + poppler/Outline.cc | 151 ++ + poppler/Outline.h | 74 + + poppler/OutputDev.cc | 104 + + poppler/OutputDev.h | 162 ++ + poppler/PDFDoc.cc | 322 +++ + poppler/PDFDoc.h | 176 ++ + poppler/PDFDocEncoding.cc | 44 + + poppler/PDFDocEncoding.h | 16 + + poppler/PSOutputDev.cc | 3803 +++++++++++++++++++++++++++++++++++ + poppler/PSOutputDev.h | 312 +++ + poppler/PSTokenizer.cc | 135 ++ + poppler/PSTokenizer.h | 39 + + poppler/Page.cc | 370 ++++ + poppler/Page.h | 176 ++ + poppler/Parser.cc | 231 +++ + poppler/Parser.h | 58 + + poppler/SplashOutputDev.cc | 1348 +++++++++++++ + poppler/SplashOutputDev.h | 194 ++ + poppler/Stream-CCITT.h | 459 +++++ + poppler/Stream.cc | 3979 + +++++++++++++++++++++++++++++++++++++ + poppler/Stream.h | 841 ++++++++ + poppler/TextOutputDev.cc | 3529 +++++++++++++++++++++++++++++++++ + poppler/TextOutputDev.h | 569 ++++++ + poppler/UTF8.h | 56 + + poppler/UnicodeMap.cc | 293 +++ + poppler/UnicodeMap.h | 122 ++ + poppler/UnicodeMapTables.h | 361 ++++ + poppler/UnicodeTypeTable.cc | 299 +++ + poppler/UnicodeTypeTable.h | 18 + + poppler/XRef.cc | 1026 ++++++++++ + poppler/XRef.h | 133 ++ + poppler/poppler-config.h | 146 ++ + poppler/poppler-config.h.in | 145 ++ + splash/Makefile.am | 52 + + splash/Splash.cc | 1732 ++++++++++++++++ + splash/Splash.h | 174 ++ + splash/SplashBitmap.cc | 157 ++ + splash/SplashBitmap.h | 46 + + splash/SplashClip.cc | 270 +++ + splash/SplashClip.h | 86 + + splash/SplashErrorCodes.h | 30 + + splash/SplashFTFont.cc | 289 +++ + splash/SplashFTFont.h | 53 + + splash/SplashFTFontEngine.cc | 141 ++ + splash/SplashFTFontEngine.h | 58 + + splash/SplashFTFontFile.cc | 111 ++ + splash/SplashFTFontFile.h | 68 + + splash/SplashFont.cc | 166 ++ + splash/SplashFont.h | 87 + + splash/SplashFontEngine.cc | 245 +++ + splash/SplashFontEngine.h | 83 + + splash/SplashFontFile.cc | 55 + + splash/SplashFontFile.h | 58 + + splash/SplashFontFileID.cc | 23 + + splash/SplashFontFileID.h | 28 + + splash/SplashGlyphBitmap.h | 24 + + splash/SplashMath.h | 45 + + splash/SplashPath.cc | 177 ++ + splash/SplashPath.h | 105 + + splash/SplashPattern.cc | 64 + + splash/SplashPattern.h | 79 + + splash/SplashScreen.cc | 107 + + splash/SplashScreen.h | 38 + + splash/SplashState.cc | 99 + + splash/SplashState.h | 86 + + splash/SplashT1Font.cc | 251 +++ + splash/SplashT1Font.h | 49 + + splash/SplashT1FontEngine.cc | 124 ++ + splash/SplashT1FontEngine.h | 51 + + splash/SplashT1FontFile.cc | 96 + + splash/SplashT1FontFile.h | 55 + + splash/SplashTypes.h | 80 + + splash/SplashXPath.cc | 417 ++++ + splash/SplashXPath.h | 90 + + splash/SplashXPathScanner.cc | 271 +++ + splash/SplashXPathScanner.h | 72 + + test/Makefile.am | 48 + + test/gtk-cairo-test.cc | 298 +++ + test/gtk-splash-test.cc | 314 +++ + 177 files changed, 70512 insertions(+) diff --git a/source/libs/poppler/poppler-0.32.0/ConfigureChecks.cmake b/source/libs/poppler/poppler-0.33.0/ConfigureChecks.cmake old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/ConfigureChecks.cmake rename to source/libs/poppler/poppler-0.33.0/ConfigureChecks.cmake diff --git a/source/libs/poppler/poppler-0.32.0/INSTALL b/source/libs/poppler/poppler-0.33.0/INSTALL old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/INSTALL rename to source/libs/poppler/poppler-0.33.0/INSTALL diff --git a/source/libs/poppler/poppler-0.32.0/Makefile.am b/source/libs/poppler/poppler-0.33.0/Makefile.am old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/Makefile.am rename to source/libs/poppler/poppler-0.33.0/Makefile.am diff --git a/source/libs/poppler/poppler-0.33.0/NEWS b/source/libs/poppler/poppler-0.33.0/NEWS new file mode 100644 index 000000000..48f97fd14 --- /dev/null +++ b/source/libs/poppler/poppler-0.33.0/NEWS @@ -0,0 +1,2321 @@ +Release 0.33.0 + core: + * Fix regression in pdftops parameter passing. Bug #89827 + * Combine base characters and diacritical marks. Bug #87215 + * Use width from W array for WMode positioning. Bug #89621 + * Fixed adding annotation of Subtype Popup to pdf page. Bug #89136 + * CairoOutputDev: Fix memory leak in CairoFreeTypeFont::create + * SplashOutputDev: memset on error to have reproducible outputs + + qt4: + * Fix PDF Text String -> QString conversion. KDE Bug #344849 + + qt5: + * Fix PDF Text String -> QString conversion. KDE Bug #344849 + + glib: + * Add poppler_annot_markup_set_popup_rectangle() + * Fix segfault when creating PopplerAction. Bug #90093 + + utils: + * pdftohtml: Set exit status adecuately. Bug #83609 + + build system: + * configure: Fix invalid shell comparaison in libtiff test + +Release 0.32.0 + core: + * Annotations: Fix rendering of empty BG/BC arrays + * Splash: Fix wrong colour shown when GouraudTriangleShFill uses a DeviceN colorspace. Bug #89182 + * Splash: Fix use of uninitialized variable in Splash::pipeRun + * Remove unnecesary check for font validity. Bug #88939 + * Small optimization in GooString::appendfv(). Bug #89096 + * Fix crashes in malformed files + + utils: + * pdftops: Make colorpsace optimization an option instead of default + * pdfseparate: use always an unique instance for PDFDoc for savePageAs + + build system: + * cmake: If extra-cmake-modules is around include the Sanitizers module + +Release 0.31.0 + core: + * CairoOutputDev: support embedding JBIG2 image data + * Accept malformed documents whose root is a Page instead of a Pages. Bug #88172 + * Fix crash on broken documents + * JPEG2000Stream: Inline doGetChar and doLookChar + * GlobalParams cleaning + + utils: + * pdftops: Add rasterization option. Bug #85934 + + qt4: + * Expose whole-words search option + + qt5: + * Expose whole-words search option + +Release 0.30.0 + core: + * Openjpeg2 support (openjpeg 1 is preferred). Bug #58906 + * Fix potential memory corruption on TextSelectionDumper. Bug #84555 + * Check for invalid matrix in annotation. Bug #84990 + * Open some not conforming files. Bug #85919 + * PSOutputDev: Accept a list of pages indeces instead of first, last. Bug #84833 + * Fix memory leak on error condition + + cpp: + * New API to set debug output function + + build system: + * configure: Improve support with older clang versions. Bug #76963 + + utils: + * pdfunite: Support output intents, optional content and acroform + +Release 0.29.0 + core: + * Use correct LAB byte array for lcms input. Bug #86388 + * Write correct size in trailer dict. Bug #86063 + * Use Default colorspaces if present instead of Device colorspaces + * Solve blend mode problem in CYMK and DeviceN for separable blend modes + * Compilation/warning fixes on SunOS + * Regression test improvements + + glib: + * demo: Compilation fixlets + + build system: + * cofigure: print "no" instead of "auto" if lcms not found + +Release 0.28.0 + core: + * Fix rendering of file with a wrong embedded font. Bug #84270 + * Use alt colorspace to get CMYK values for an ICC based CMYK colorspace. Bug #79019 + * Map Standard/Expert encoding ligatures to AGLFN names. Bug #80093 + * Make Attribute::getName() work when UTF-16BE is used. Bug #84722 + * Fix memory leak in Dict::remove. Bug #84607 + * Fix crashes in broken files + * SplashOutputDev: Improve Overprintmode and shadings. Bug #80998 + * CairoOutputDev: fix crash when no group color space. Bug #85137 + * CairoOutputDev: Don't render text when text matrix is not invertable. Bug #78042 + * CairoOutputDev: Only embed mime data for gray/rgb/cmyk colorspaces. Bug #80719 + * CairoOutputDev: Only embed mime data if image decode map is identity + * cairo: Use matrix to determine pattern size. Bug #33364 + * Fix compile warnings + * regression test improvements + + glib: + * Fix use of uninitialized members in PopplerInputStream. Bug #82630 + * Documentation improvements + * Do not dist gir_DATA + * Remove use of GTK deprecated functions. Bug #82384. Bug #82385 + * Build introspection linking to the uninstalled libraries. Big #84526 + + qt4: + * Add a new Page::annotations() that let's you specify subtypes + + qt5: + * Add a new Page::annotations() that let's you specify subtypes + + utils: + * pdfseparate: additonal handling for annotations. Bug #77549 + * pdfdetach: fix crash when getPage() returns null. Bug #85145 + * pdftocairo: Add support for printing to a Windows printer. Bug #79936 + + build system: + * Move automake version check from autogen.sh to configure.ac. Bug #79797 + * Makefile.am cleanups. Bug #79411 + * Use poppler-data pkg-config + * Make autogen.sh work with variables with spaces + * Don't use -fPIC on mingw + * Fix build with --disable-utils. Bug #84448 + +Release 0.26.4 + core: + * CairoOutputDev: Make sure we always push a transparency group in setSoftMaskFromImageMask(). Bug #81624 + * Fix a crash when adding Annotation without contents + * Improve non-latin characters in inline notes. Bug #65956 + * Don't check for inlineImg twice. Bug #82059 + * printf() -> error() + + glib: + * Return NULL in poppler_annot_get_contents also for empty strings + * Fix a memory leak when getting text layout and attributes + +Release 0.26.3 + qt5: + * autoconf: Improve moc-qt5 detection + * Fix compilation with MinGW + + glib: + * Fix typo in api docs + * use C90-style comments in public headers + + core: + * Error out instead of exiting if allInter grows too much. Bug #78714 + + qt4: + * Update required version to Qt 4.7.0 + + build system: + * Include stdio.h from poppler-config.h + + misc: + * Update .gitignore files + +Release 0.26.2 + core: + * Make sure we have an xref before using. KDE Bug #335413 + + build system: + * autoconf: Fix typo in configure.ac + + utils: + * pdftohtml: exit with 0 with -v and -h + +Release 0.26.1 + core: + * Use field value V for radio buttons. Bug #75979 + * Fix extraction of text in some files. Bug #78145 + * Only add annotations of the current page when splitting. Bug #77549 + + build system: + * autoconf: Fix libopenjpeg 1.5 detection on some systems. Bug #78389 + + glib: + * Fix multiple definition of PopplerTextSpan + +Release 0.26.0 + qt4: + * Fix mismatched boolean logic in TextAnnotation::setInplaceIntent + + qt5: + * Fix mismatched boolean logic in TextAnnotation::setInplaceIntent + + core: + * Very small code cleanup + + cpp: + * Very small code cleanup + +Release 0.25.3 + core: + * Fix crashes on broken files + * Avoid MinGW/Cygwin warnings due to redefinition of NOMINMAX + * Fix some small memory leaks + + qt5: + * Fix some kinds of OCG models + * Cleanup some deprecated methods + + glib: + * Fix the first coord of the quadrilateral in create_poppler_quads_from_annot_quads(). Bug #76504 + + utils: + * pdftohtml: Fix typo in manpage + + qt4: + * Fix some kinds of OCG models + +Release 0.25.2 + core: + * Tagged-PDF support + * Open some broken files. Bug #75232 + * Fix crashes on broken files + * Fix regression parsing some broken files. KDE Bug #329600 + * Improve compilation under Win 8 with Visual Studio 2012. Bug #73111 + * PSOutputDev: Ensure paper size takes into account rotation. Bug #72312 + * PSOutputDev: Fix DocumentMedia/Page/Media/PageBBox DSC comments + * PSOutputDev: Use crop box as page size + * PSOutputDev: Remove origpagesizes mode and make -origpagesizes an alias for -paper match + * PSOutputDev: Only change paper size when different to previous size + * PSOutputDev: Ensure there is always a page size in the output + * PSOutputDev: Fix regression when creating level1 PS. Bug #75241 + * CairoOutputDev: Clip to crop box. Gnome Bug #649886 + * Splash: Blend usage in PDF with spot colors casue random output. Bug #74883 + * Splash: Fix off by one that caused crash in a file. Bug #76387 + * Make sure number of least objects in hints table is valid. Bug #74741 + * Limit numeric parsing of character names. Bug #38456 + + glib: + * Tagged-PDF support + * Annotation improvements + * Install error callback. Bug #73269 + * Fix gobject-introspection warnings + * demo: Fix performance in text markup annotations + * Increase gtk3 dependency + + qt4: + * Improve naming of internal export/import macros + * Add GCC visibility export attributes + * Expose document-supplied text direction + + qt5: + * Improve naming of internal export/import macros + * Add GCC visibility export attributes + * Expose document-supplied text direction + + utils: + * pdftocairo: Ensure page size and crop box works the same as pdftops + * Fix TIFF writting in Windows. Bug #75969 + + buildsystem: + * Learn about automake 1.14 + * Do not define -ansi. Bug #72499 + * cmake: Install JpegWriter.h depending on libjpeg + * cmake: Use c99 for the c compiler + +Release 0.25.1 + core: + * GooString format: Added some tests + improved documentation + * GooString format: fixed bug with printing LLONG_MIN + * regression test improvements + + qt4: + * Arthur backend font rendering improvements + * test program to save to file + + qt5: + * Arthur backend font rendering improvements + * Improve detection of Qt5 moc. Bug #72744 + * test program to save to file + + utils: + * pdfunite: Work even if there's a single file given + * pdfunite: do not lose fonts when merging some files + +Release 0.25.0 + core: + * Annotation improvements + * Tagged PDF work + * Improve speed on some files using ICC color space + * Use ICC profile in OutputIntents. Bug #34053 + * Limit use of ZapfDingbats character names. Bug #60243 + * Splash: correction for knockout transparency groups + * regression test improvements + + utils: + * pdftoppm: Added thinlinemode option setting + * pdfinfo: Indicate if pdf contains javascript + * pdfinfo: Add option to print out javascript + * pdfimages: Print size, ratio, and ppi + * pdfimages: More image output format support + * pdfseparate: allow zero-padded pagespecs + + glib: + * Annotation improvements + * Add API to get text, text layout and text attributes for a given area + * demo improvements + +Release 0.24.5 + core: + * Fix crash due to wrong formatting of error message. KDE Bug #328511 + +Release 0.24.4 + core: + * Fix regression in broken endstream detection. Bug #70854 + * Catalog: sort entries of NameTrees to make sure lookup works. Bug #26049 + * Don't infinite loop if reading from GooFile::read fails. Bug #71835 + + utils: + * pdftotext: Do not close stdout. Bug #71639 + * pdftotext: Silence warning for may be used uninitialized variable. Bug #71640 + * pdftotext: Escape the text of the xml headers + * Warn the user if he provides a wrong range + + qt4: + * Fix typo in xml API. Bug #71643 + + qt5: + * Fix typo in xml API. Bug #71643 + +Release 0.24.3 + core: + * PSOutputDev: Fix PFB font embedding. Bug #69717 + * CairoOutputDev: Do not set an invalid matrix in drawImage(). Bug #70085 + + qt4: + * Don't crash if getXRef()->copy() fails + + qt5: + * Don't crash if getXRef()->copy() fails + + utils: + * pdfseparate: Allow only one %d in the filename. Bug #69434 + +Release 0.24.2 + core: + * Windows: Fix CreateFile fails with ERROR_SHARING_VIOLATION. Bug #69597 + + utils: + * pdfseparate: improve the path building + * pdftocairo: check file opening failure in beginDocument() + +Release 0.24.1 + core: + * SplashOutputDev: use getRGBLine images if available. Bug #66928 + * SplashOutputDev: Don't copy bitmap if we don't need to. + * PSOutputDev: Fix regression in -eps -level1sep rendering. Bug #68321 + * Fix crash in malformed file 1026.asan.0.42.pdf + * use copyString instead of strdup where memory is freed with gfree. Bug #67666 + + utils: + * pdfdetach: don't mention xpdfrc + * pdftotext: Fix -bbox with stdin as input. Bug #45163 + * pdftohtml: Fix jpeg image export. Bug #48270 + * pdfimages: Fix typos in man page + + glib: + * demo: Remove GTK_DISABLE_DEPRECATED compilation flag + + qt4: + * Fix small typo in documentation + + qt5: + * Fix small typo in documentation + +Release 0.24.0 + core: + * TextOutputDev: Do not draw ligatures more than once when selected. Bug #9001 + * PSOutputDev: Make some pdftops conversions much faster + * PSOutputDev: Initialize t3FillColorOnly + * SplashOutputDev: Fallback to 1x1 bitmap if we fail to create the real size + +Release 0.23.4 + core: + * TextOutputDev: clip the selected text rendering to the selection box. Bug #66983 + * CairoImageOutputDev: Fix the bounding box of saved images + + build system: + * Improve linking against pthreads + +Release 0.23.3 + core: + * Annotation improvements + * Fix crashes on malformed files + * TextSelectionPainter: Draw glyphs after selection background + * TextOutputDev: add a method to TextPage to get the selection as a list of words + + qt5: + * Initial Qt5 port + + qt4: + * Windows compile fixes + * Demo: Allow the choose the page rotation + + build system: + * Fix mingw build + * Minor autotools fixes + +Release 0.23.2 + core: + * SplashOutputDev: Speed-up some tiling on a 10x factor + * Improve caching of lcms2 ICC color profiles + * Put some private classes in an anonymous namespace + + qt4: + * Add a thread stresser tool + + build system: + * Fix mingw build + +Release 0.23.1 + core: + * XRef stream writing: Write 32-bit offsets when possible + * Fix splashModeBGR8 rendering (Bug #64381) + + glib: + * Do not use deprecated gtk_scrolled_window_add_with_viewport() (Bug #64683) + + build system: + * Fix Large file support when using cmake + +Release 0.23.0 + core: + * Make rendering thread safe + * Large file support + * Implement Crypt filter (Bug #62800) + * Fix endstream detection (Bug #62985) + * CairoOutputDev: support uncolored tiling patterns (Bug #59179) + * SplashOutputDev: Introduce Thin Line mode support (Bug #37347) + + qt4: + * Expose Thin Line mode support + +Release 0.22.4 + core: + * Always consider a softmask transfer function (Bug #63587) + * Fix crash on malformed files (Bug #63190) + * Splash: Fix compilation with fixed point mode enabled + + utils: + * Fix crash on some files (Bug #63909) + + qt4: + * Fix name decoding of some attachments (KDE Bug #307786) + + build system: + * Fix compilation with mingw-w64 compiler + +Release 0.22.3 + core: + * Check order bounding box values in tiling pattern (Bug #62369) + * CairoImageOutputDev: Don't change image interpolation when printing (Bug #62418) + * TextOutputDev: Set text matrix when painting selection (Bug #61042) + * Only write the file once when saving (Bug #62739) + * Fix for complete rewrites in repaired files + * Fixlet regarding spec interpretation for Link Zoom value + * Fix typos in man pages + * Fix compile when not using libjpeg + + glib: + * Always start from the beginning when starting a new search on a page (Bug #59972) + + qt4: + * Fix crash in files with LinkRendition (KDE Bug #317710) + + build system: + * Small cmake improvements + +Release 0.22.2 + core: + * Correct rendering of underline and strike out annotations (Bug #61518) + * Workaround broken jpeg stream definitions (Bug #61994) + * SplashOutputDev: Restore CTM on early exits (Bug #61413) + * SplashOutputDev: Make sure we don't try to paint in x < 0 (KDE Bug #315432) + * Fix latin page labels. (Bug #61034) + * Fix compilation with jpeglib9 + * Fix minor valgrind warning + + utils: + * pdfimages: Fix extraction of some images (Bug #61168) + + build system: + * Fix the build with automake-1.13 + +Release 0.22.1 + core: + * Fix crash in some pdf files when extracting text (Bug #59561) + * Fix crashes in wrongly formed files + * Fix wrong warning when opening some files (Bug #58966) + + build system: + * Improve autoconf jpeglib.h detection (Bug #59186) + +Release 0.22.0 + core: + * Fix crash in invalid files that define a <= 0 bits per image value + * Fix a few issues in JPX decoding when not using OpenJPEG + * TextOutputDev: Use page size for max value in TextPage::visitSelection + * Fix typo in error message + + utils: + * Fix pdfunite regression (Bug #58569) + * Demo fixes and improvements + + misc: + * pdf-inspector improvements + +Release 0.21.4 + core: + * SplashOutputDev: Fix crash when rendering in monochrome mode + * SplashOutputDev: Fix line widths in monochrome mode (Bug #57294) + * PSOutputDev: Fix crop on EPS conversion (Bug #30692) + * TextOutputDev: Fix minor logic mistake + * Fix assert on some malformed files (Bug #58257) + * Move #include "jpeglib.h" into .cc file (Bug #57687) + * Filter text that may end up being written to the shell + * Fix windows compile warnings + + glib: + * Add poppler_annot_set_flags (Bug #58015) + * Demo fixes and improvements + + qt4: + * Fix check_lexer on 32-bit systems + +Release 0.21.3 + core: + * Splash: Implement bilinear image scaling (Bug #22138) + * CairoOutputDev: Update fill and stroke color in startPage (Bug #54526) + * Fix GooString::insert() + * Allow large chars in TextPage + * Fix crash on ActualText::end + * Don't use memcpy to copy classes + * Fix warnings + + glib: + * Check if words end with spaces (Bug #54504) + * Ensure text is only computed on first render + * Fix warnings while generating introspection file + * Fix returns tag in PopplerAttachmentSaveFunc api doc + * Minor demo fixes + +Release 0.21.2 + core: + * CairoOutputDev: make drawImage work with images > 32767 in width/height (Bug #56858) + * CairoOutputDev: Fix soft mask when image resolution != smask resolution (Bug #57070) + * CairoOutputDev: Fix crash in CairoImageOutputDev with setSoftMaskFromImageMask (Bug #57067) + * Remove a check on fonts that we don't need (Bug #56753) + * Misc code cleanups + + utils: + * pdftocairo: Add tiff output support (Bug #57006) + * pdfunite: Fix -v (Bug #56817) + * Misc code cleanups + +Release 0.21.1 + core: + * Annotation improvements + * Form improvements + * CairoImageOutputDev: Support parameterized Gouraud shading (Bug #56463) + * UTF validation fixes + * Do not call drawing routines if we don't need non text (Bug #54617) + * Fix Memory leak in CharCodeToUnicode (Bug #54702) + + qt4: + * Make LinkRendition properties available (Bug #55378) + * Accessors for FormWidgetChoice::editChoice + * Implement overprint + +Release 0.21.0 + core: + * Support the modification of files with Encrypt + * Annotation improvements + * Form improvements + * Splash: Implement DeviceN support + * Splash: Avoid bogus memory error for tilingPattern + * TextOutputDev: Allow multiple fonts in a TextWord + * Kill the concept of base dir + * PSOutputDev: Always write HiResBoundingBox (Bug #53159) + * Convert UTF-16 to UCS-4 when reading toUnicode cmap + * GooString formatting: add support for uppercase hexadecimal + * Use error() instead of fprintf(stderr, ...) in Annot::layoutText + * poppler-config.h: remove WITH_FONTCONFIGURATION_* macros + + glib: + * Annotation improvements + * Add poppler_page_remove_annot() + * Add poppler_document_new_from_stream + * Add poppler_document_new_from_gfile + * Add poppler_page_find_text_with_options (Bug #2951) + * Demo improvements + * Port tests and demo to GTK+3 + + qt4: + * Add accessor methods for movie poster information + * Make 'additional actions' available in Annotation API (Bug #53589) + * Add whole-page search method to Poppler::Page + * Small changes in tests + + utils: + * pdftohtml: Make the output more xhtml compliant + * pdftohtml: Add -fontfullname. (Bug #49872) + * pdftohtml: Do not invoke gs anymore + + build system: + * Add the possibility of using lcms1 even if lcms2 is installed + * Remove extra fontconfig CFLAGS and LIBS + +Release 0.20.5 + core: + * Fix crashes in malformed documents + * Fix parsing of very big numbers + * Splash: Do not render invalid font outlines (Bug #55573) + * Check for NaN in TextPage::addChar + + build system: + * Fix build using mingw64 with winpthread + * autotools: Fix compilation when lcms is on non standard locations (Bug #55326) + * Support automake-1.12 (Bug #55541) + + glib: + * Chain up finalize to the parent class (Bug #55521) + +Release 0.20.4 + core: + * Improvements regarding embedded file handling. (KDE Bug #306008) + * Fix opening some broken files (Bug #14303) + * Fix memory leaks + * Fix crashes in various broken files + * Refine warning to only complain when really needed + * Remove function declared but not implemented + * Remove execution permissions from a header file + + qt4: + * Improvements regarding embedded file handling. (KDE Bug #306008) + +Release 0.20.3 + core: + * If NULL, NULL fails as password try EMPTY, EMPTY before failing (Bug #3498) + * SplashOutputDev: Fix bogus memory allocation size in Splash::arbitraryTransformImage (Bug #49523) + * SplashOutputDev: Fix segfault when scaleImage returns NULL (Bug #52488) + * SplashOutputDev: Blend mode enhancements for CMYK + * PSOutputDev: Fix conversion when creating multiple strips (Bug #51982) + * PSOutputDev: Fix Bitmaps in level2sep or level3sep (Bug #52384) + * PSOutputDev: Fix DeviceN images with alternate Lab colorspace in level 3 PostScript (Bug #51822) + * PSOutputDev: Make sure xScale and yScale are always initialized (Bug #52215) + * Unify poppler-config.h includes in core "installed" headers (Bug #52193) + * Replace c++ style includes with c style ones (Bug #52426) + + utils: + * pdfseparate: Return 0 on success + +Release 0.20.2 + core: + * Fix compilation on Windows + * Copy resources content defined in the pages dict on save (Bug #51369) + * PSOutputDev: Correct %%DocumentCustomColors (Bug #51479) + * PSOutputDev: Fix handling of DeviceN images in level 3 PostScript (Bug #51548) + * Fix crash in malformed documents + + qt4: + * Do not hang on malformed /Annots objects (Bug #51361) + +Release 0.20.1 + core: + * Remove unnecesary transparency group handling in splash (Bug #13487) + * Include substitute font name in system font cache (Bug #49826) + * Fix logic on SplashBitmap::writeImgFile + * PSOutputDev: use setoverprintmode only if rip knows it + * Fix crash in malformed documents + + qt4: + * Make TextAnnotation constructor public + * Fix saving of default TextAnnotation to xml + * Keep page rotation into account when normalizing annotation coords + + glib: + * Fix memory leak when document fails to load + * Make sure password is always converted to latin1 + * Fix typo in documentation + + build system: + * Distribute cmake/modules/FindLCMS2.cmake (Bug #49818) + + utils: + * pdftohtml: Determine if font is bold or italic based on FontDescriptor (Bug #49758) + * pdfseparate: Syntax fixes in the man page + +Release 0.20.0 + core: + * Reconstruct xref table if xref needed but missing (Bug #40719) + * Fix getFullyQualifiedName with unicode field names (Bug #49256) + * SplashOutputDev: Fix rendering of knockout groups (Bug #12185) + * SplashOutputDev: Fix cmyk transfer bug (Bug #49341) + * Fix crashes in broken documents + * Bring back the Outputdev::begin/endMarkedContent virtuals + * Build fixes + + qt4: + * Convert propertly unicode encoded field qualified names + + glib: + * glib: Use delete[] to free array allocated with new[] (Bug #48447) + +Release 0.19.4 + core: + * Annotation improvements + * More compatible file writing + * SplashOutputDev: Fix slow rendering of pdf with a lot of image masks in pattern colorspace + * Fix crashes in broken documents + * Fix spurious warning messages + + utils: + * pdftotext: Add missing section heading to man page + * pdftohtml: Fix crash when the destination file does not exist + + build system: + * autoconf: Do not append "-ansi" to CXXFLAG, if "-std=XXX" is already specified. + * autoconf: Do not clear FREETYPE_CFLAGS, FREETYPE_LIBS before PKG_CHECK_MODULES() + * autoconf: Copying graphics library CFLAGS to cpp frontend Makefile.am + +Release 0.19.3 + core: + * Annotation improvements + * CairoOutputDev: Fix regression caused by mesh gradients + * CairoOutputDev: Use correct userfont font bbox (Bug #48399) + * CairoOutputDev: Fix paintTransparencyGroup when both mask and fill opacity are required (Bug #48453) + * CairoOutputDev: Ensure 0 width lines with stroke_adjust are aligned + * CairoOutputDev: Only align stroke coords for horizontal and vertical lines (Bug #48318) + * CairoOutputDev: Fix stroke pattern with transparency group (Bug #48468) + * Fix crash in JBIG2Stream decoding + * Fix memory leak when looking for a substitute font + * Fix page labels to not have a null character at the end + * Fix Splash CMYK merge error + * ttc<->ttf fallback is expected for CJK font list in for Windows (Bug #48046) + + qt4: + * Annotations can now be modified + * Annotations can now be added + * Annotations can now be removed + + utils: + * pdftohtml: Add producer and version to xml output + * pdftohtml: Fix the mask inversion for PNG + +Release 0.19.2 + core: + * Annotation improvements + * CairoOutputDev: update cairo mesh pattern to 1.12 api + * CairoOutputDev: fix some transparency issues (Bug #47739) + * CairoOutputDev: Fix regression in some shadings + * TextOutputDev: Don't add newline to last line extracted by TextSelectionDumper (Bug #45955) + * CJK font improvements + * Improve font matching for non embedded fonts + * Fix regression regarding forceRasterize in PSOutputDev + * Fix typos glyph names in truetype 'post' table standard mac ordering + + build system: + * minor cmake fixes + * misc autoconf fixes + * POPPLER_VERSION is now wrapped in quotes + + utils: + * pdftohtml: extract mask images even if they are not JPEG (Bug #47186) + * pdftohtml: Flip images if they need to (Bug #32340) + +Release 0.19.1 + core: + * Improve CJK suport in PSOutputDev + * CJK substitute implementation on WIndows platforms + * Do not crash on malformed files with 0 bits in the color map of an image + * Fix regression in some PSOutputDev array sizing + * Improvements to Annotation editing + * Fix logic error in Rendition parsing code (Bug #47063) + * Minor API changes to SplashOutputDev (Bug #46622) + * Fix mismatch in some functions declarations + * Update poppler copyright year + + utils: + * pdftops: Fix -passfonts regression. (Bug #46744) + * pdffonts: List the encoding of each font. (Bug #46888) + * pdftohtml: Add possibilty of controlling word breaks percentage. (Bug #47022) + + qt4: + * Support for LinkMovie object (Bug #40561) + * Support for Media Rendition + + glib: + * Add poppler_fonts_iter_get_encoding + * Improvements to the demo + +Release 0.19.0 + core: + * Merge Xpdf 3.03 + * Add support for lcms2 + * SplashOutputDev: Implement Overprint + * PSOutputDev: Implement Overprint + * Expand glyph name ligatures such as "ff", "ffi" etc to normal form (Bug #7002) + * Use an Identity CharCodeToUnicode for Adobe-Identity and Adobe-UCS collections (Bug #35468) + * CairoOutputDev: Avoid setting huge clip area when printing (Bug #44002) + * CairoOutputDev: Fix test for rotation (Bug #14619) + * CairoOutputDev: Don't read inline image streams twice (Bug #45668) + * CairoOutputDev: set mask matrix before drawing an image with a mask (Bug #40828) + * Update glyph names to Unicode values mapping (Bug #13131) + * Only use Hints table when there are no parse errors (Bug #46459) + * Expose POPPLER_VERSION in poppler-config.h + + utils: + * pdftohtml: Output images in -xml mode if no -i option is specified + * pdftohtml: Get rid of static data members; merge duplicated jpeg dumping code + * pdftohtml: Be more consistent generating the outlines + * pdftohtml: Generate outlines in pdftohtml in -xml mode (Bug #56993) + * pdftohtml: Combine UTF16 surrogate pairs (Bug #46521) + * pdfinfo: Report page rotation + * pdfinfo: Decode utf-16 surrogate pairs + * pdftoppm: Allow one of -scale-to-[xy] = -1 to mean the aspect ratio is to be preserved (Bug #43393) + * pdftocairo: Allow one of -scale-to-[xy] = -1 to mean the aspect ratio is to be preserved + * pdffonts: Add -subst option to list the substitute font name and filename + * pdfseparate: Produce PDF/X conformant pdf pages if the original PDF was PDF/X conformant + * pdfimages: Add -list option to list all images (Bug #46066) + * Improve various manpages + + glib: + * Add poppler_fonts_iter_get_substitute_name + * Demo improvements + * Update gtk-doc makefile and m4 file + * Fix typos in documentation + + qt4: + * Add the option of PSConverter creating EPS + * Form support improvements + + build system: + * autotools: Print the cairo version required if not found (Bug #44619) + * autotools: Print the glib version required if not found + * autotools: Use pkgconfig to check for libopenjpeg (Bug #21789) + * autotools: Replace openjpeg compile test with a version test + * Add a configuration option for the test data dir + +Release 0.18.4 + core: + * CairoOutputDev: Restore temporary clip used in CairoOutputDev::fill when painting a mask + * CairoOutputDev: Ensure paintTransparencyGroup uses same ctm as beginTransparencyGroup. Bug #29968 + * CairoOutputDev: Use fabs when comparing the transformed line width. Bug #43441 + * CairoOutputDev: Remove unused variable in CairoFontEngine.cc. Bug #45442 + * SplashOutputDev: Do not use 50Kb of stack in SplashXPath::addCurve. Bug #44905 + * JpegWriter: set image parameters after jpeg_set_defaults(). Bug #45224 + * OpenJPEG decoder: Set OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG if you have it. Bug #43414 + * Lexer: convert integer to real when overflow occurs. Bug #45605 + + glib: + * Various minor introspection and documentation improvements. Bug #44790 + * Fix return values. Bug #45440. Bug #45441 + * gtk-doc improvements. Bug #45549 + * Introspection improvements. Bug #45455 + + utils: + * HtmlOutputDev: Proper unicode support when dumping PDF outline. Bug #45572 + * HtmlOutputDev: Fix leaks. Bug #45805 + * HtmlOutputDev: Close li tags in generated outlines. Bug #45807 + * man pages: fix minor issues with hypens and % + + build system: + * automake: Link to lcms if needed + * automake: Fix build for builddir != srcdir. Bug #45434 + * automake: Improve moc detection when cross compiling + * Fix build with latest mingw-w64 headers. Bug #45407 + + qt4: + * remove non-existing 'qt' include dirs + +Release 0.18.3 + core: + * Do not fail if we are trying to save a file with Encrypt that has not been modified. KDE Bug #288045 + * Include .otf fonts when finding substitute fonts. Bug #44412 + * Fix stack overflow in PDFDoc::markObject(). Bug #44660 + * Include strings.h as we use memcpy. Bug #43558 + + utils: + * pdfunite: Properly initialize globalParams. Bug #44659 + * pdfseparate: Properly initialize globalParams + * Fix iniliazialization of GooString arguments + + build system: + * autoconf: Check for cairo-ft and other cairo backends. Bug #43969 + +Release 0.18.2 + core: + * Fix leak in GooString when resizing to a smaller string + * Fix crash if failing to parse the colorspace. Bug #42793 + * Make GfxColorSpace::parse accept dicts + + qt4: + * Use PDFDoc(wchar_t *, ...) on Windows. Bug #35378 + * Add missing include + * Minor fixes in documentation + + utils: + * pdftocairo: Fix crash when rendering only odd/even pages in a printing format + + build system: + * Fix pkg-config files + +Release 0.18.1 + core: + * PSOutputDev: Output PS that does not confuse libspectre + * PSOutputDev: Fix tiling pattern fill matrix. Bug #41374 + * PSOutputDev: Emit non repeating patterns just once + * PSOutputDev: Fix uncolored tiling patterns. Bug #41462 + * CairoOutputDev: Fix crash when using poppler_page_get_image() + * CairoOutputDev: Fix various setSoftMask bugs. Bug #41005 + + utils: + * pdftocairo: Flush/close files one we are done using them + * pdftocairo: Compile in Windows + + build system: + * CMake: Fix typo in option description + * CMake: Correctly include fontconfig include dir + * Remove poppler-cairo dependency from poppler-glib pkg-config file + + qt4: + * Minor fixes in documentation + +Release 0.18.0 + core: + * Fix small memory leak when dealing with marked content + * Remove DCTStream::getRawStream since Stream::getNextStream does the same + + utils: + * Rename pdfmerge to pdfunite + * Rename pdfextract to pdfseparate + * pdfseparate: Complain if %d is not present and it should + * Add pdfseparate and pdfunite man pages + + build system: + * Minor cleanup in regarding removed qt code + +Release 0.17.4 (0.18 RC) + core: + * SplashOutputDev: Compile when defining USE_FIXEDPOINT + * PNGWriter: Compile with libpng >= 1.5.0 + +Release 0.17.3 (0.18 Beta 3) + core: + * PSOutputDev: Use Patterns for tiling fill when PS level >= 2 + * PSOutputDev: Avoid using /PatternType if only one instance of the pattern is used + * PSOutputDev: Add poppler version as comment in the file + * CairoOutputDev: Set mime data for soft masked images (Bug #40192) + * CairoOutputDev: Assume printer pixel size is 1/600" when stroking 0 width lines (Bug #39067) + * CairoOutputDev: Use cairo_show_text_glyphs() when printing + * CairoOutputDev: Fix stroke patterns (Bug #11719) + * CairoOutputDev: Fix unique id mime data + * CairoOutputDev: fix stroking of very thin lines + * CairoOutputDev: align strokes when Stroke Adjust is true and line width <= 1 (Bug #4536) + * TextOutputDev: Add TextFontInfo::matches() + * Improve PNGWriter + * Rework writing of PDF files + + utils: + * Introduce pdftocairo - utility for creating png/jpeg/ps/eps/pdf/svg using CairoOutputDev + * Introduce pdfextract - utility to extract PDF pages + * Introduce pdfmerge - utility to merge PDF files + * Fix compilation warning + * pdftohtml: Support text rotation (Bug #38586) + * Update SEE ALSO section of man pages + + glib: + * Add poppler_page_get_text_attributes() + * Add text attributes information to text demo + + qt4: + * Add a way to get the fully qualified name of a FormField + * Minor documentation improvements + +Release 0.17.2 (0.18 Beta 2) + core: + * EmbeddedFile improvements + * don't gmalloc(-1) upon ftell failure + * Fix missing content in some pages (Bug #39637) + * Improve selection of CJK fonts (Bug #36474) + * SplashOutputDev: Implement overprint + * SplashOutputDev: Render dots for 0 length dashed lines (Bug #34150) + * SplashOutputDev: Fix bad memory access when not using antialias (Bug #37189) + * PSOutputDev: Make level2sep and level3sep write cmyk instead of rgb + * PSOutputDev: Make level1sep, level2sep and level3sep write gray instead of rgb for gray images + * Fix numerical overflow in libopenjpeg JPXStream (Bug #39361) + * Fix crash on truncated JPEG/DCT stream (Bug #36693) + * Make sure the dict is a page dict (Bugs #35925 #39072) + * Fix calculation of startXRefPos + * Handle missing startxref properly (Bug #38209) + * Parse the "Medium" modifier when asking fontconfig for a font + * Header cleanup + * Include cleanup + * Define cleanup + + glib: + * Add missing permissions flags to PopplerPermissions + * Add missing permission flags to info demo + * Update gtk-doc.make + * Add poppler_document_get_n_attachments() + + utils: + * pdftohtml: Fix encoding of PDF document metadata (Bug #37900) + * pdftohtml: Fix vertical spacing issues (Bug #38019) + * pdftotext: Fix -htmlmeta to correctly output U+2019 in PDF metadata (Bug #37900) + * pdftoppm: Implement overprint + + qt4: + * Rework EmbeddedFile internals + * Fix possible crash in test + +Release 0.17.1 (0.18 Beta 1) + core: + * Rework the way form fields tree is built + * Cleanup unused parameters/variables + + glib: + * Add JavaScript actions + * demo: Show javascript actions in actions view + + qt4: + * tests: Turn some assignments to bool into QVERIFY checks + +Release 0.17.0 (0.18 Alpha) + core: + * Splash: Implement tiling patterns + * Splash: Support slight hinting + * Splash: Radial shading improvements + * Splash: General speed improvements + * Arthur: Add Hinting API + * Cairo: Implement Type 4,5,6,7 shadings using cairo mesh gradients + * Cairo: Use the new cairo unique id to set the surface id when printing + * PS: Add PS level1 non standard binary output option + * PS: Allow setting the rasterization resolution + * Form support improvements + * Annotation support improvements + * General speed improvements + * Add support for handling ViewerPreferences + * Remove abiword output device + + utils: + * pdftoppm: Add -singlefile option (Bug #32025) + * pdftoppm: Add TIFF output format support (Bug #32027) + * pdftops: Add PS level1 non standard binary output option + * pdftops: Allow setting the rasterization resolution + * pdftoabw has been removed + + glib: + * Add poppler_form_field_get_action() (Bug 33174) + * Remove GDK API + * Remove test-poppler-glib + * demo: Add a tooltip with current selected character in text demo + * demo: show the activation action of form fields if there's one + + cpp: + * Add TIFF output possibility + * Add PNM output possibility + + qt4: + * Support slight hinting + * Form support improvements + + qt3: + * The Qt3 frontend has been removed + + tests: + * Merge splash and cairo tests into a single gtk-test tool + +Release 0.16.4 + core: + * Small improvements in Annot parsing + + glib: + * Add g_return macros to make sure index is correct in form field choice methods + * Fix a crash when a choice form field has no items selected in glib-demo + + utils: + * Small fixes to the pdftohtml manpage + * Fix copyright years + + qt4: + * Fix caption of push button fields + +Release 0.16.3 + core: + * Increase precision in PS output device + * Workaround bug when converting pdf to ps with level1 (Bug #31926) + * Fix crash in Splash output device in some broken pdf + * Fix infinite loop in some broken files + * Fix rendering of some substituted fonts (Bug #34522) + * Do not ask Freetype for 0x0 fonts in Splash output device (Bug #34602) + * Don't assume y1 > y3 for points of a highlight annotation (Gnome Bug #643028) + * Handle fontCIDType2OT when creating freetype font in Cairo output device (Gnome Bug #643273) + * Fix crash in some pdf that use ICC color space (Bug #34357) + + glib: + * Don't use an uninitialized local variable in demo + * Add some introspection markers + + qt4: + * Fix crash regression in unicodeToQString (again) + + utils: + * pdftotext: Do not crash when using -bbox + +Release 0.16.2 + core: + * Fix text extraction for some files + + qt4: + * Fix crash regression in unicodeToQString + +Release 0.16.1 + core: + * Fix colorspace issues in the Cairo backend (Bug #32746) + * Remove declaration of function without implementation + * Do not crash in case jpeg_create_decompress fails (Bug #32890) + * Fix variable access mismatch (Bug #33063) + * Fix converting some pdf to ps with -level1sep (Bug #32365) + * Fix line selection, dont check y for Line selections + * Include zlib header in PNGWriter.cc + * Fix leak in Splash backend when doing axial shaded fills + * Fix label to index conversion on multiple prefixes + + glib: + * Use NULL instead of FALSE for functions returning a pointer + * Fix memory leak in poppler_page_get_text_layout() for pages with no text + + qt4: + * Fix unicodeToQString() to correctly decode the Unicode sequence + +Release 0.16.0 + + core: + * Improve the correctness of radial shadings (Bug #32349) + * Adapt the zlib-based FlateStream code to API changes (Bug #32065) + * Make PreScanOutputDev be less agressive when deciding to rasterize (Bug #30107) + * Fix some warnings in newer gcc in Splash backend + * Fix the preliminary bbox/clip calculation in Splash backend + * Use A1 instead of A8 for imagemask in the Cairo backend + * Windows compile fixes + + utils: + * Do not return 99 (or 1) with -h, -v and -printenc (Bug #32149) + * Misc style improvements to pdftohtml code + * pdftohtml: Remove the -resolution flag introduced in 0.15.0 and fix the + existing -zoom flag + + build system: + * Add more warning flags to the default gcc builds + * Enable GObject introspection support in the cmake build system + + qt4: + * Windows compile fixes + +Release 0.15.3 (0.16 RC) + + core: + * Improve rendering of radial shadings + * Open a broken file (Bug #31861) + * Correct parsing of linearization table (Bug #31627) + * Find fonts inside patterns (Bug #31948) + * [win32] Simplify strtok_r implementation + * Use a std::vector<char> instead of a var-length-array of chars + * Fix crashes in broken files + * Use sets instead of arrays for looking for duplicate fonts + + cpp: + * Include correction + + utils: + * pdffonts: Remove duplicated code + +Release 0.15.2 (0.16 Beta 2) + + core: + * Improve shadings and antialias in the Splash backend (Bug #30436) + * Linearization improvements + * Small improvements to the Arthur backend + * Fix calculation of the size of some pages (Bug #30784) + * Fix crashes in broken documents + + qt4: + * Add Page::renderToPainter() method + * Add setDebugErrorFunction() method + + cpp: + * Add the hability to render pages to an image + + utils: + * Add -p flag to pdfimages + + build system: + * Remove -ansi flag for cywin and mingw + +Release 0.15.1 (0.16 Beta 1) + + core: + * Consider render value when colorizing text (Bug #2807) + * Improve rendering of Shading Type 6 and 7 + * Improve dict lookup speed for big dicts + * Fix multiple crashes in malformed PDF files + * Fix memory leak in in malformed PDF files + * Fix memory leak in the Catalog names + * Fix uninitialized uses on DCTScanInfo + * Fix a crash when drawing square/circle annots without a border (Bug #30580) + * Only clip boxes to mediabox if we are at the page level (Bug #30784) + * Do not omit the notdef glyph in the Splash backend + * Fix a crash when redering documents with invalid type 3 fonts in the Cairo backend + * Form improvements + * Add a method to get the PDF file identifier + + glib: + * Add more printing options to the API + * Add a method to get the PDF file identifier + * Add accessor for all PopplerDocument properties + * Form improvements + * Documentation improvements + * Improvements to the demo + + qt4: + * Add a callback to know which page has been printed + * Add a method to get the PDF file identifier + * Optimize GooString to QString conversion + * Some more autotests + * Update Doxyfile (enables .qch file for assistant) + + build system: + * Require Cairo 1.10 + + utils: + * pdftohtml: Add -s option to generate a single HTML page + * pdftotext: Add -bbox option + + cpp: + * Add the possibility of loading a document from raw data + * Add a method to get the PDF file identifier + * Improve Unicode to ustring conversion + * Documentation improvements + * Update Doxyfile + +Release 0.15.0 (0.16 Alpha) + + core: + * Remove exception support + * Improve creation of Annotations + * Fix failure to parse PDF with damaged internal structure. (Bugs #29189 #3870) + * Add a way to access the raw text of a page + * Speed improvements when reading multiple characters from a given Stream + * Speed improvements in the Splash backend + * Speed improvement in gray color space calculations + * Speed improvement in ICC color space calculations + * Speed improvement when reading some fonts + * Make GBool a bool instead of an int + + glib: + * Add GObject introspection support + * Improve creation of Annotations + * Add a way to get the coordinates of each character of a page + * Add a way to get the page label + * Documentation improvements + * Support password protected documents in the demo + * Support for selection in the demo + * Support for adding annotationss in the demo + * Misc improvements in the internals + + qt4: + * Add a way to access the raw text of a page + * Recognize "Print" as named action + * Documentation improvements + + build system: + * Add option for autogen.sh to skip configure + * Nicer autogen.sh output + * Improvements when build the glib frontend with CMake + + utils: + * pdftohtml: Use splash instead of external gs invocation to render the background + * pdftohtml: Let the user specify the resolution of the background. (Bug #29551) + + cpp: + * Add a way to access the raw text of a page + +Release 0.14.3 + + core: + * Tell Windows we are writing/reading binary data from stdout/stdio (Bug #29329) + * Fix crash when parsing some Movie elements (KDE Bug #249586) + +Release 0.14.2 + + core: + * Fix rendering of some documents involving tilingPatternFill in the cairo output device + * Improve rendering of some annotations + * Handle ColorTransform in DCT streams when using libjpeg (Bug #28873) + * Fix crash in the ps output device in some files (KDE Bug #246269) + * Fix crash in some malformed files (Bug #28842) + + build system: + * Improve build on windows + * Add uninstalled .pc file support when using autoconf + + glib: + * Fix a crash when a layer doesn't have a name (Bug #28842) + + utils: + * Fix padding of names in pdftoppm + +Release 0.14.1 + + core: + * Add ObjectStream caching, makes opening some files ten times faster (Bug #26759) + * Fix crash when writing to negative coordinates (Bug #28480) + * Check objects are the type we want them to be when parsing GfxICCBasedColorSpace + * Optimize Splash::compositeBackground + * Optimize color space calculations by using sqrt instead of pow 0.5 + * Fix crash in JBIG2Stream with malformed documents + + build system: + * Make sure we ship two needed cmake files + * Do not distribute glib/poppler-features.h and poppler/poppler-config.h + * Improve compilation with Sun Studio + * Fix linking of the cpp frontend when using autotools + + glib: + * Fix links/annots area for some documents (Bug #28588) + * Fix poppler_page_find_tex() when called more than once (Bug #27927) + + utils: + * Add -cropbox to pdftoppm manual + +Release 0.14.0 + + core: + * Fix crash when parsing pdf with broken JBIG2Stream (Bug #28170) + * Do not follow loops blindly when parsing XRef (Bug #28172) + * Allow quality & progressive mode to be utilised in JpegWriter + * Fix potential assert in Lexer code (KDE bug #240208) + * Fix opening of files whose /P is stored as unsigned integer + * Do not exit() when trying to allocate memory for the XRef fails + + cpp: + * Minor bugfixes + * Documentation improvements + + build system: + * Fix build in mingw32 when using autotools + * Preserve compiler flags when using cmake + +Release 0.13.4 (0.14 RC 1) + + core: + * Include standard float.h instead of unportable values.h + * Fix first color stop offset of linear gradients. Bug #27837 + * Fix compilation if JPEG nor PNG is used + * Use fabs for doubles instead of abs + * Use strtok_r instead strtok + * Adjust bbox for line annots when y1 = y2 + * Some fixes and regressions in the cairo output device + * Better check of overlapping of table cells when selecting text + + cpp: + * Make the pkg-config files really work + * Fix in/out buffer sizes in some functions + +Release 0.13.3 (0.14 Beta 2) + + core: + * Fix roll optimization in the PS function interpreter + * Correctly parse numbers with '+' sign. Gnome bug #614549 + * Add support for cached files + * Add support for reading a cached file from stdin + * Add HTTP support using libcurl, disabled by default + * Add some const correctnes to GooString + * Rework DCTStream error handling. Bug #26280 + * Use current fill_opacity when drawing soft masked images in Cairo backend. Gnome bug #614915 + * Use the topleft of the Rect of text annots to draw + * Fix saving update docs that have a compressed xref table. Bug #27450 + * Parse varius part of the document catalog on demand + * Implement colorizing image masks with pattern colorspace in Cairo backend + * Fix a crash when rendering 0x0 images in Cairo backend + * Check pattern status after setting matrix when rendering images + * Improve text selection/extraction order. Bug #3188 + * Fix pattern size when bbox is not at 0,0 + * Improve colorizing text and masks in pattern colorspace. Bug #27482 + * Silence some Illegal entry in bfrange block in ToUnicode CMap. Bug #27728 + + utils: + * Add the -o[dd] and -e[ven] options to pdftoppm + * Allow read from stdin using the new cached files feature + * Fix crash in pdftohtml when output filename was shorter than 5 characters + + glib: + * Use existing cairo api when rendering to a pixbuf + * Compile with -DGSEAL_ENABLE. Bug #27579 + +Release 0.13.2 (0.14 Beta 1) + + core: + * Improve Movie support + * Fix experimental Arthur backend to compile when if Splash backend is disable + * Fix usage of some streams in the Cairo backend + * Small improvements in the experimental Arthur backend + * Minor annotation improvements + * Rework LinkRendition to follow the spec + * Add support for Set-OCG-State actions + * Correctly initialize the grayscale softmask color in the Splash backend + * Correctly initialize actualText in TextOutputDev when initialization fails + * Various MSVC fixes + + glib: + * Add support for Movie objects + * Add support for Screen annotations + * Add support for rendition actions + * Add support for OCG State actions + * Improvements to the demo + + qt4: + * Always compile the experimental Arthur backend + * Minor speed improvement in QPainter usage + * Add a search overload that takes doubles instead of QRectF + + cpp: + * Fix iconv usage + * use gmtime() when gmtime_r() is not available + * Fix building in autotools in windows + * {from,to}_utf_8() -> {from,to}_utf8() + + build system: + * Multiple CMake build system fixes + * Fix of some DIST targets in autotools + * Make finding of Qt3 in autotools use pkg-config + +Release 0.13.1 (0.14 Alpha 2) + + core: + * New C++ frontend to interface with Poppler using only STL + * Use the right matrix for the mask in drawMaskedImage in Cairo output device. Bug #16906 + * Fix downscaling images when document is rotated in Cairo output device. Bug #26264 + * GooVector rewrite, old version had "unknown" origins/license + * Fix use after free in a error condition + * Improve handling of broken commands. Bug #24575 + * Fix potential use after free in Cairo output device. + * Fix regression in painting. Bug #26243 + * Improve handling of FontConfig. Bug #26544 + * Only assume the OC is not visible if it exists and is set to no. Bug #26532 + * Fix a potential crash in Splash font handling on out of memory conditions + * Implement writeImgFile for splashModeXBGR8 + * Several speed increases (around 40% in some documents) in the Splash output device + * Improve printing on the Cairo output device + * Do not use '\' character in PostScript names + * Omit writing of embedded fonts into temporary files in the Cairo output device. Bug #26694 + * Improve filtering of some images in the Cairo output device. Bugs #25268, #9860 + + utils: + * pdftoppm: Only swap w with h if rotation is 90 or 270 + + build system: + * Add POPPLER_WITH_GDK in cmake build system. Bug #26247 + * Fix typo: "MULTITHREAD" -> "MULTITHREADED in cmake build system + * Wrap #include <jpeglib.h> in extern "C" to fix build. Bug #26351 + * Add the Win32-specific ENABLE_RELOCATABLE option to cmake build system + * Reflect that poppler-glib needs cairo now in cmake build system + * Use pkgconfig to detect libpng on autotools build system + * Detect the need for nanosleep in solaris in cmake build system. Bug #26650 + +Release 0.13.0 (0.14 Alpha) + + core: + * Improvements to Annotation rendering. Bug #23108 + * Do not give an error when opening files without pages. Bug #24720 + * Try to read streams without Length + * Do not crop the transformation matrix at an arbitrary value. Bug #25763 + * Make poppler (optionally) relocatable on Windows + * Use a small object cache in GfxResources to cache GState objects + * Reduce the number of redundant pattern creations in the Cairo output device + * Use colToDbl() to avoid rounding error in the Cairo output device + * Fix problems with mask handling in the Cairo output device. Bug #8474 + * Use a better scale down implementation in the Cairo output device + * Various optimizations to the Splash output device + * Add the possibility to use floats instead of doubles in the Splash output device. Bug #25578 + * Write out fixed-content portion of Type 1 fonts in the PS output device + + build system: + * Improvements to the CMake build system + * Enable AM_SILENT_RULES by default in autotools + * Require glib 2.18 + * Require GTK+ 2.14 + * Make fontconfig optional with mingw compiler + * Remove makefile.vc + + glib: + * Add support for file attachment annotations + * Improvements to the demo + * Use TextOutputDev to get TextPage when we haven't rendered the page + * Remove support for the Splash output device + + utils: + * pdftoppm can now write to jpeg + * pdftoppm embeds the correct resolution in png and jpeg files + + qt4: + * Minor improvements to the tests + +Release 0.12.3 + + core: + * Be more lenient with /Decode key on images. Bug #17439 + * Correctly initialize fileName in LinkGoToR. Bug #25221 + * Improve the reconstruction of the XRef for broken files + * [Cairo backend] Do not crash on malformed files. Bug #24575 + * Accept Fontname if FontName is not present. KDE bug #217013 + * Make PSOutputDev code a bit more resilient + * Fix writing of null objects. Bug #25465 + * [Cairo backend] Fix crash in some documents. GNOME bug #603934 + * Correctly initialize profileCommands in Gfx constructor + + build system: + * Check for openjpeg in the C++ part as it uses bool in the header. Bug #25103 + +Release 0.12.2 + + core: + * Fix a memory leak when converting to PostScript + * Fix crash when reading a font fails. Bug #24525 + * Make the ICC cache per page instead of global. Bug #24686 + * Do not accept negative interval lengths in the page labels tree. Bug #24721 + * Do not crash on files Aspect of Movie objects are reals instead of integers. Bug #24733 + * Do not render patterns when using CairoImageOutputDev + * Allow Transitions dictionary to be a Ref + * Do not crash if jpeg_start_decompress fails. KDE bug #214317 + + glib: + * Fix CVE-2009-3607 + + qt4: + * Use '.' in the annotations XML instead of the decimal separator of the current locale + +Release 0.12.1 + + core: + * Fix compilation on some compilers + * Only initialize the font list once in Windows32/MSVC + * Do not crash on fonts without CharCodeToUnicode. Bug #24036 + * Fix regression due to not setting LC_NUMERIC anymore + * Improve realibility for Streams with broken Length. Bug #6841 + * Write the Info into the trailer dict if there is one. Bug #24091 + * Do not crash when saving files that come from a stream without name. Bug #24090 + * Improve relability of the save function + * Fix the Length value if it was wrong when saving + * Fix includes for those using internal headers + * Rework how hinting is used in the splash backend. It is disabled by default now + * fix constructor of DCTStream when using internal decoder + * Security fixes based xpdf 3.02pl4 + + qt4: + * Add the possibility of setting wheter to use or not font hinting + * Add a way for converters to return more exact errors they had when converting + * Check the document is not locked when converting to PS + + build system: + * Compile on Cygwin + * Use _WIN32 instead of WIN32. Bug #24259 + * Add the possibility to pass LIB_SUFFIX when using CMake + +Release 0.12.0 + + core: + * Fix printf format security warnings + * Improve rendering of radial shadings. Bug #20238 + * Better fallback when there's a font type mismatch. Bug #17252 + * Do not crash on attachments without data stream. Bug #10386 + * Fix infinite loop in JBIG2Decoder. Bug #23025 + + build system: + * Minimizes pkg-config dependencies for Qt frontends + * Add automake 1.11 support + * Use the newest automake found and not the oldest + * Support AM_SILENT_RULES when using automake 1.11 + + utils: + * Add common options to pdftoabw + +Release 0.11.3 (0.12 RC 1) + + core: + * Optimization in the Cairo renderer for some fonts + * Do not apply masks when fill color space mode is csPattern in the Cairo renderer. Bug #22216 + * Check for overflow when parsing integers. Bug #23078 + * Do not save the font file twice for FreeType fonts in the Cairo renderer. Bug #20491 + * Use current fill_opacity when drawing images in the Cairo renderer + * Fix alpha rendering in some files in the Splash renderer. Bug #22143, #22152 + * Implement tiling patterns in the Cairo renderer + * When converting a cm matrix to PS write 4 significant digits for numbers < 1 not 4 decimals. Bug #23332 + * Fix changing of locale, now poppler no longer changes LC_NUMERIC to "C" + * Return PDF version as two integers instead of as a double + + Qt4: + * Addition of the Color Management API + * Small fix to documentation + * Fix backwards text search + + utils: + * Add the -png flag to pdftoppm to output to PNG + +Release 0.11.2 (0.12 Beta 2) + + core: + * Make DecryptStream return sane values for getPos(). Bug #19706 + * Fix bug when printing pdf with multiple page sizes in duplex mode + * Initilize AnnotColot properly when the Array is not correct + * Fix crash on some files with forms. Bug #22485 + * Fix crash in files with invalid embedded files. Bug #22551 + * Improve FileSpec attribute parsing + * Cairo output device improvements. Bugs #10942, #18017, #14160 + * Implement blend modes in cairo backend + * Handle fontType1COT fonts in CairoFontEngine + * Fix generation of PS for some files. Bug #18908 + * Don't use byte_lookup table when color space doesn't support getLine methods. Bug #11027 + * Fix rendering of PDF files with malformed patterns. Bug #22835 + * Add the possibility of disabling font substitution in pdftops. Bug #23030 + * Fix some radio buttons not being detected as such + + glib: + * Improvements to the demo + + Qt4: + * Improvements to the demo + + build system: + * Use gtkbuilder rather than libglade for some tests + + utils: + * Fix bug with noCrop parameter in pdftops + +Release 0.11.1 (0.12 Beta 1) + + core: + * Support colorizing text in pattern colorspace. Bug #19670 and #19994 + * Add the possibility of forcing no hinting of fonts in the Splash backend + * Support multiple page sizes when converting to PS. Bug #19777 + * Also tokens with leading 00 when parsing the char to unicode map. Bug #22025 + * Improvements of rendering speed in documents using PS transformations a lot. Bug #21562 + * More work on Annotations support + * Use Interpolate flag to decide whether applying image interpolation during rendering. Bug #9860 + * Handle Streams in CMap definitions. Bug #22334 + * Fix some bugs in JBIG2Stream handling + * Fix dashed line in page 1 of bug 20011 + * Fix exit(1) when rendering a file + * Fix pdftops crash on file from KDE bug #174899 + * Fix PS generation in some files. Bug #20420 + * Do not create the GfxColorTransform if the lcms could not be created. Bug #20108 + * Check Mask entries are int before using them, if they are real cast to int and try to use them. Bug #21841 + * Use the correct value when creating the V field for form combo boxes + * Give an error when using level1sep in pdftops without having CMYK support. Bug #22026 + * Don't include lcms.h in GfxState.h + * Fix splashColorModeNComps to correctly include all values for each SplashColorMode + * Add splashClearColor that assigns white to the given colorptr + * Kill support for specifying extension in openTmpFile. Bug #21713 + * Fix "Conditional jump or move depends on uninitialised value". Bug #20011 + + glib: + * Add poppler_annot_markup_has_popup() + * Hyphenate UTF-8 and UTF-16BE. Bug #21953 + * Use g_strerror instead of strerror. Bug #22095 + * Fix a crash when a destination points to an invalid page + * Improvements to the demo + + Qt4: + * Add LinkDestination::destinationName() + * Do not try to resolve named destinations for GoTo links pointing to external documents + * Add Page::thumbnail() + * Improvements to the demo + * Improvements to the documentation + + build system: + * Build fix for MSVC + * Better lcms cmake check comming from kdelibs + * Use pkgconfig for autotools lcms check + * Remove unneeded files from repo. Bug #22094 + +Release 0.11.0 (0.12 Alpha) + + core: + * Add initial support for color management + * Remove case-insensitive matching of filenames in PDFDoc constructor + * Fix extraction of some ActualText content + * More work on Annotations support + * Improve font rendering in Cairo output device + * Fix bug in cairo backend with nested masks + * Fix cairo luminosity smask rendering + * Add optionally text support to Cairo output device + * Add the possibility of setting the datadir on runtime + * Return an error code instead of a boolean when saving + * Make the font scanner more versatile + * Small opimization in documents that use PostScriptFunction transforms + * Minor optimization to Stream handling + * Fix some compile warnings + + glib: + * Optional content support + * More work on Annotations support + * Improvements to the demo + * Documentation improvements + * Fix build when compiling with GTK_DISABLE_SINGLE_INCLUDES + + Qt4: + * Support URI actions for Table Of Contents items + * Documentation improvements + * Improvements to the demo + * Add a FontIterator for iterating through the fonts of the document + + utils: + * Allow the use of cropbox in pdftoppm + * Make pdftohtml output png images when the image stream is not a jpeg + * Make pdftotext accept cropping options like pdftoppm + * Support rendering non-square pixels in pdftoppm + + build system: + * Require Cairo 1.8.4 for the Cairo output device + * Require CMake 2.6 when using the CMake build system + * Optionally require libpng for pdftohtml + * Optionally require libcms for color management + +Release 0.10.6 + + core: + * Fix problems that happen when parsing broken JBIG2 files. + CVE-2009-0799, CVE-2009-0800, CVE-2009-1179, CVE-2009-1180 + CVE-2009-1181, CVE-2009-1182, CVE-2009-1183, CVE-2009-1187, CVE-2009-1188 + * Fix parsing of incorrect border arrays. Bug #19761 + * Fix clip test for fonts. Bug #20950 + * Fix getGlyphAdvance to behave correctly on font size changes. Bug #20769 + * Misc build fixes + + build system: + * Fix the Qt4 version we need + +Release 0.10.5 + + core: + * Read the UF entry if present and prefer it over F in Filespec dictionary + * Fix typo that was making CairoOutputDev crash on some files. Bug #17337 + * Make JBIG2Stream more robust to corrupt input data + * Do not blindly follow loops parsing OutlineItem. Bug #18364 + * Set up the error manager before calling jpeg_create_decompress. Bug #20484 + * Check there is an optional content config before using it. Bug #20587 + * Fix rendering of some PDF with OpenType fonts. Bug #20605 + + build system: + * Yet more support for build on windows + * Use AC_CHECK_HEADER to find headers. Bug #20538 + * Check for pkgconfig before using it + * General autotools improvements + +Release 0.10.4 + + core: + * Fix a memory leak when asking for a document-level JS + * Do not crash in some PDF we do not parse correctly. Bug #19702 + * Fix crash on unexepcted form Opt value. Bug #19790 + + utils: + * Fix pdfimages to extract i color components per pixel jpeg images. Bug #19789 + +Release 0.10.3 + + core: + * Fix a crash on documents with malformed outline. Bug #19024 + * Fix leak on AnnotScreen destructor. Bug #19095 + * Fix wrong PS generation when a large image is in Patterns. Bug #18908 + * Remove BaseFile.h it was never used. Bug #19298 + * Improve document saving + * Fix PS generation of PDF with malformed font Length2 definition + * Fix a leak while parsing annotations + * Fix rendering of some checkboxes + + Qt4: + * Fix positioning of Form rects on PDF with cropbox + * Fix positioning of Annotation rects on PDF with cropbox. Bug #18558. + * Small documentation improvements + * Make Document::fonts() work when called more than once. Bug #19405 + + build system: + * CMake: look harder for openjpeg + * CMake: update the poppler core headers installation + * Autotools: do not install Function.cc as it's not a header + + Qt: + * Fix deserialization of links right coordinate + +Release 0.10.2 + + core: + * Fix a crash when selecting text in word mode + * Fix a crash in some malformed documents (second argument of opMarkPoint is not a dictionary) + * Ensure cairo font matrix is invertable. Fixes bugs #18254 and #18429 + * Fix a memory leak (Bug #18924) + + Qt4: + * Fix deserization of links right coordinate + + misc: + * Fix build on Solaris 10 + Sun Studio 12 + * Compile with -pedantic + +Release 0.10.1 + + core: + * Improvements in Optional Content support + * Small fix in Form support + * Fix memory leak in case of error + * Fix potential crash on text search + * Try render documents with invalid indexed color space parameters. Bug #18374 + * Fix crash on text extraction when poppler-data is not installed. Bug #18023 + + Qt: + * Fix two memory leaks + + Qt4: + * Small documentation improvement + * Fix memory leak in the demo code + +Release 0.10.0 + + core: + * Fix crashes on PDF using Stitching or Axial Shading painting + * Fix rendering of PDF with Type1 fonts that have more than + one encoding definition per line + * Do not try to save documents that have Encryption as we + do not support that and the user ended with a broken file + * Fix crash on files with OptionalContentGroup but no Name + + Qt4: + * Fix the area of the links to be correctly reported on rotated documents + + misc: + * Mingw+Msys should work + +Release 0.9.3 (0.10 RC 2) + + core: + * Fix rendering regression on some embedded fonts + * Fix rendering regression of some special fonts + * Fix crash on documents with bogus jpeg data + + Qt4: + * The printing flag defaults to true on PSConverter + * Documentation improvement + + utils: + * Fix regression that made HmtlOutputDev ignore jpeg images + + misc: + * Improve compilation on mingw + +Release 0.9.2 (0.10 RC 1) + + core: + * Fix conversion to PS some files (bug #17645) + * Small Form fixes + * Small JS fixes + * Improve memory usage of the cairo renderer + + utils: + * Fix mismatched free/delete in pdftohtml + * Fix memory leak in pdftohtml + * Fix crash in pdftohtml + + glib: + * Fix a crash in forms demo + + misc: + * Compile with -pedantic + +Release 0.9.1 (0.10 Beta 2) + + Core: + * Fix crash on some AESv2 encrypted files (bugs #13972, #16092, #17523) + * Improve parsing of broken files (bug #17568) + + glib frontend: + * Minor improvements to the demo application + + utils: + * pdftohtml: Generate the outline file in the same place + of the other generated files (bug #17504) + +Release 0.9.0 (0.10 Beta 1) + + Core: + * Initial JavaScript support + * Annotation improvements + * Improvements in the Arthur based renderer + * Improvements in the Cairo based renderer + * Added a JPEG2000 decoder based on OpenJPEG + * Small fixes in ActualText implementation + * Fix jpeg rendering when not using the libjpeg based decoder + * Movie fixes + * Do not get out of memory on documents that specify huge fonts + * Emulate Adobe Reader behaviour on documents with duplicate keys in Dictionaries + * Forms improvements + + Qt4 frontend: + * Annotation improvements + * Forms improvements + * Add the possibility of extracting embedded fonts + * Initial Movie support + * Documentation improvements + * Small improvements in the PS exporter + + glib frontend: + * Annotation improvements + * Attachment fixes + + utils: + * updated man pages + * Added -listenc to pdfinfo and pdftotext + +Release 0.8.7 + + Core: + * Fix regression in Form rendering + * Fix memory leak in the cairo backend + +Release 0.8.6 + + Core: + * Call error() when font loading fails + * Be less strict parsing TTF tables (bug #16940) + * Fix crash due to uninitialized variable + + Qt 4 frontend: + * Make the paper color setting working as it should + * Make sure to use the correct page width/height for form widgets coordinates + +Release 0.8.5 + + Core: + * Fix crash on PDF that define a page thumbnail but it's not a Stream + * Fix crash when Annots object is not of the desired type + * Fix crash when obtaining fonts in PDF where XObjects link themselves in loops + * Fix crash on documents with an IRT object + * Saving should work much better now + * Plug some memory leaks in Annotation handling + + Utils: + * pdftohtml: Don't crash on documents that specify an invalid named dest for a link + * pdftohtml: Make html output to keep all the spaces with   + * pdftohtml: Improve a bit text layout + * pdftohtml: Make xml output valid xml + +Release 0.8.4 + + Core: + * Fix leak in ABWOutputDev.cc + * Fix uninitialized variable that broke file saving in some cases + * Use a single global FT_Library in CairoOutputDev. + Fixes some crashes in CairoOutputDev. + + Qt 4 frontend: + * Fix saving over existing files + + build system: + * Make sure Qt4 moc is used to generate moc files in Qt4 frontend + +Release 0.8.3 + + Core: + * Fix crash when reading some PDF with annotations + * Fix crash on PDF that reference Optional Content elements that don't exist + * Fix leaks on error conditions + * Do not limit CharCodeToUnicodeString to 8 characters + * Support for surrogates outside the BMP plane + + Qt 3 frontend: + * Fix crash when reading PDF with password + * Fix leak when calling scanForFonts() + + Qt 4 frontend: + * Fix the text() method + + Splash renderer: + * Fix compilation with --enable-fixedpoint + +Release 0.8.2 + + core: + * Fix call broken by a fix introduced in 0.8.1 + +Release 0.8.1 + + core: + * Do not call FT_Done_Face on a live cairo_font_face_t as it might cause crashes + * Do not take into account Colorspace resource subdictionary for image XObjects + * Downsample 16 bit per component images to 8 bit per component so they render + + build system: + * Link to pthread when the system needs it + + windows: + * Fix comparing against NULL instead against INVALID_HANDLE_VALUE when calling FindFirstFile + +Release 0.8.0 + + * Fix caching of members in the glib frontend causing issues with rendering + * Change glib public api to have a correct naming + * Some better error handling on corner cases + * Check the document stream is seekable when opening it + * Build fixes with autotools and with cmake + * Fix infinite recursion on some malformed documents when consulting the fonts + * Fix possible crash when asking for Movie contents + +Release 0.7.3 (0.8 RC 2) + + * Fix regression in Splash renderer + * Fix off-by-one write in Splash + * Plug some minor leaks in Optional Content code + * Improve error handling when creating a document in the glib frontend + +Release 0.7.2 (0.8 RC 1) + + Major Changes: + * Improve font matching not forcing default values onto Fontconfig + * Add preliminary annotations support in the glib frontend + * Initial Movie support in the core + * Make GDK dependency optional in glib bindings + + Minor Changes: + * Make the core able to read mime types of embedded files + * Qt4 API for accessing mime types of embedded files + * Handle correctly check state of optional content groups + regarding parents state + * Avoid setting singular CTM matrices on the Cairo backend + * Improved Qt4 API to get character position + * Qt4 api documentation improvements + * Qt4 minor stability fixes + * Proper lib64 Qt detection + * Fix build when compiling without cairo support + +Release 0.7.1 (0.8 Beta 2) + + Major Changes: + * Really distribute CMake files as optional build tool + * Initial Optional Content support in core and in the Qt4 frontend + + Minor Changes: + * Allow grouped checkboxes to be selected individually + * Qt4 demo program improvements + * Keep cairo and cairo_shape consistent + * Safety checks on Splash renderer so that it does not draw outside the allocated bitmap + * Do not try to display bitmaps of invalid size + * Fix building with exceptions + * Improvements for building with MSVC and CMake + +Release 0.7.0 (0.8 Beta 1) + + * Saving support + * Partial annotation support + * Forms improvements + * Add support for ActualText entries + * Display characters outside of unicode BMP with TT font + * CJK rendering fixes + * Implement Adobe Glyph Naming convention for fonts + * CMake as optional build tool + * Better font scaling for non embedded fonts + * Preserve PDF page labels when we output as postscript + +Release 0.6.4 + + Qt4 frontend: + * Fix crash on links that point to a non existant page + * Make Document::renderHints return the correct render hints + * Fix infinite loop when parsing LineAnnotation + + core: + * Fix crash in the Splash renderer when T3 fonts are badly defined + * Draw underlined Links correctly + + utils: + * Fix two use after free bugs in HtmlOutputDev.cc + + build system: + * Fix build on mingw32 + + tests: + * Distribute the glade file of pdf-inspector + +Release 0.6.3 + + core: + * Fix crash in extra debug code + + glib frontend: + * Make sure passwords are passed correctly to poppler core + + Qt frontend: + * Fix crash on documents that specify an empty date + + build system: + * Disable gtk tests if the user disabled glib frontend + +Release 0.6.2 + + poppler core: + * Fix CVE-2007-4352, CVE-2007-5392 and CVE-2007-5393 + * Fix a crash on documents with wrong CCITTFaxStream + * Fix a crash in the Cairo renderer with invalid embedded fonts + * Fix a crash with invalid TrueType fonts + * Check if font is inside the clip area before rendering + it to a temporary bitmap in the Splash renderer. Fixes crashes on + incorrect documents + * Do not use exit(1) on DCTStream errors + * Detect form fields at any depth level + * Do not generate appearance stream for radio buttons that are not active + * mingw fixes + + build system: + * Require fontconfig >= 2.0 + * builddir != srcdir fixes + + Qt4 frontend: + * Improved documentation + + misc: + * Fix FSF address + +Release 0.6.1 + + poppler core: + * Fix printing with different x and y scale + * Fix crash when Form Fields array contains references to non existent objects + * Fix crash in CairoOutputDev::drawMaskedImage() + * Fix embedded file description not working on some cases + + Qt4 frontend: + * Fix printing issue + * Avoid double free + * Fix memory leak when dealing with embedded files + + glib frontend: + * Fix build with --disable-cairo-output + * Do not return unknown field type for signature form fields + + build system: + * Support automake-1.10 + * More compatible sh code in qt.m4 + + utils: + * Fix build on Sun Studio compiler + +Release 0.6 + + - CairoOutputDev fixes + - Allow pdftoppm to read/write from stdin/stdout + - API work on Qt4 frontend + - Fix pdfimages produces inverted image for black & white image + - Fix error on the NFKC text matching routine + - Add support for word and line selections + - Do not enforce %%EOF at the end of file + - Pad zeroes instead of aborting when rendering 1-bit images + and the stream is too short + - Update glib bindings documentation + +Release 0.5.91 (0.6 Release Candidate 2) + + - Various memory leaks fixed + - Compile with --enable-fixedpoint. Bug #11110 + - Header cleanup + - Remove dependency on debugxml. Bug #11187 + - Allow access to document metadata in glib and qt4 frontends + - Several glib API frontend improvements + - Fix crash on accessing embedded files + - Build on Sun Force compiler + - Render '*' instead of the actual content in password form fields + - Fix pdftohtml complex output. Bug #9746 and #11610 + - Windows build fixes + - Improve Japanese font support. Bug #11413 + - Do not exit the program on files that confuse libjpeg + - Update required cairo version to 1.4 + - Fix CVE-2007-3387 + +Release 0.5.9 (0.6 Release Candidate) + + - Merge xpdf 3.02 changes + - Qt4 frontend is not marked anymore as unstable + - Support for Sound objects + - Support for Opening/Closing page actions + - Support for page duration + - Improve PS Tokenizer performance thanks to Scott Turner + - Various speed ups by Krzysztof Kowalczyk + - Beginning of Interactive Form support by Julien Rebetez + - xpdfrc is no longer used for anything + - Add AbiWord output device and pdftoabw program by Jauco Noordzij + - Fix security issue MOAB-06-01-2007 + - Lots of bugs fixed + +Release 0.5.4 + + - Automatically read in CJK encoding files if they're + installed (#2984, #7105, #7093). This works with the new + poppler-data package. + - Speed ups by Krzysztof Kowalczyk (#8112) + - Patch from Dom Lachowicz to let the utils take input on stdin. + - Bugs fixed (#8182, #4649, #7906, #8048, #7113, #4515, #3948, + #7924, #7780, #7646, #6948, #7788, #7661, #7005) + +Release 0.5.3 + + - Add poppler as a private requires of poppler-glib. + - Allow CairoFont creation to fail more gracefully (#4030). + - Back out the rest of krh's type3 font work. + - Revert splashModeRGB8 changes. + - Add missing poppler-annotation-helper.h. + +Release 0.5.2 + + - Much improved Qt bindings (Albert Astals Cid). + - Cairo backend now supports masked images (Jeff Muizelaar, #6174). + - Patches from Kouhei Sutou to make glib bindings more + language binding friendly (#6907, #6897, #6899, #6905). + - Search now works with ligatures (Ed Catmull, #2929). + - The glib bindings now has an entry point to render to a cairo_t. + - GCC 4.1 and MSVC compilation fixes. + - Memory leaks plugged: #6908, #6947, #6765, #6764, #6187 + - Misc bug fixes: #6984, #6896, #6913, #6926, #4481, #5951, + #6551, #6500, #6492, #6454, #6079, #6167. + +Release 0.5.1 + + - Support for embedded files. + - Handle 0-width lines correctly. + - Avoid external file use when opening fonts. + - Only use vector fonts returned from fontconfig (#5758). + - Fix scaled 1x1 pixmaps use for drawing lines (#3387). + - drawSoftMaskedImage support in cairo backend. + - Misc bug fixes: #5922, #5946, #5749, #5952, #4030, #5420. + +Release 0.5.0 + + - Font matching code for non embedded fonts now use fontconfig + instead of hard coded list of fonts. + - Merge in Xpdf 3.01 changes. + - Add command line tools from Xpdf. + - Make install of Xpdf header files ./configure'able. + +Release 0.4.0 + + - Real text selection. + - API breakage in glib wrapper: dropping dest_x and dest_y + arguments from poppler_page_render_to_pixbuf(). + +Release 0.3.3 + + - New glib API to get document font information (Marco). + - More document properties available as glib properties (Emil + Soleyman-Zomalan, #3359) + - Optimize color conversion for images. + - Support for constant opacity. + - Fix problems with pkg-config files. + - Bugs fixes: #3491, #2911, #3362, #3340, #3265, #3239, #3396. + +Release 0.3.2 + + - New API to get poppler version and backend type. + - Various font fixes from Albert Astals Cid. + - Update to cairo 0.5.0 API, including better font support. + - Meta data for the glib binding. + +Release 0.3.1 + + - Add qt/poppler-private.h to SOURCES + - Jeff's path to use zlib instead of builtin decompression. + - Bug fixes: #2934, segfault on invalid links, #3114 + +Release 0.3.0 + + - First cut at qt wrapper, including a getText() method for + getting text from a page. + - More glib functionality: meta data, set page orientation, + print to PS + - Performance fixes for glib cairo + - Bug fixes + +Release 0.2.0 (Tue Apr 5 12:32:10 EDT 2005) + + - Add glib wrapper for poppler, which will use cairo rendering + if available + - Support for page labels + - configure and build fixes. + +Release 0.1.2 (Wed Mar 9 10:45:58 EST 2005) + + - cairo optimizations and fixes from Jeff Muizelaar + - Bump cairo requirement to 0.4 + - Make cairo and gtk checks fail gracefully + +Release 0.1.1 + + - Fix issues with installed header files including config.h + - Fix a couple of typos in pkg-config files + - Install splash and cairo header files when necessary + +Release 0.1 - no date yet + + - First release + - More NEWS here diff --git a/source/libs/poppler/poppler-0.32.0/README b/source/libs/poppler/poppler-0.33.0/README old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/README rename to source/libs/poppler/poppler-0.33.0/README diff --git a/source/libs/poppler/poppler-0.32.0/README-XPDF b/source/libs/poppler/poppler-0.33.0/README-XPDF old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/README-XPDF rename to source/libs/poppler/poppler-0.33.0/README-XPDF diff --git a/source/libs/poppler/poppler-0.32.0/TODO b/source/libs/poppler/poppler-0.33.0/TODO old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/TODO rename to source/libs/poppler/poppler-0.33.0/TODO diff --git a/source/libs/poppler/poppler-0.32.0/config.h.cmake b/source/libs/poppler/poppler-0.33.0/config.h.cmake old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/config.h.cmake rename to source/libs/poppler/poppler-0.33.0/config.h.cmake diff --git a/source/libs/poppler/poppler-0.32.0/config.h.in b/source/libs/poppler/poppler-0.33.0/config.h.in old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/config.h.in rename to source/libs/poppler/poppler-0.33.0/config.h.in diff --git a/source/libs/poppler/poppler-0.33.0/configure.ac b/source/libs/poppler/poppler-0.33.0/configure.ac new file mode 100644 index 000000000..67599c097 --- /dev/null +++ b/source/libs/poppler/poppler-0.33.0/configure.ac @@ -0,0 +1,991 @@ +m4_define([poppler_version_major],[0]) +m4_define([poppler_version_minor],[33]) +m4_define([poppler_version_micro],[0]) +m4_define([poppler_version],[poppler_version_major.poppler_version_minor.poppler_version_micro]) + +AC_PREREQ(2.59) +AC_INIT([poppler],[poppler_version],[https://bugs.freedesktop.org/enter_bug.cgi?product=poppler]) +AC_CONFIG_MACRO_DIR([m4]) +AM_INIT_AUTOMAKE([1.7 foreign]) +m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) +AC_CONFIG_HEADERS([config.h poppler/poppler-config.h]) +AC_C_BIGENDIAN + +dnl ##### Initialize libtool. +AC_LIBTOOL_WIN32_DLL +define([AC_LIBTOOL_LANG_F77_CONFIG], [:]) +AC_PROG_LIBTOOL + +dnl ##### Checks for programs. +AC_PROG_CC +AC_PROG_CXX +AC_ISC_POSIX +AC_PROG_CC_STDC +#if test -z "$CXX" -a "$CC" = "gcc"; then +# CXX="gcc" +#fi +AC_PROG_CXX +AC_PROG_INSTALL + +dnl ##### Check for pkgconfig +PKG_PROG_PKG_CONFIG + +dnl ##### Export the version +AC_DEFINE_UNQUOTED([POPPLER_VERSION], ["poppler_version"], [Defines the poppler version]) + +dnl Enable these unconditionally. +AC_DEFINE([OPI_SUPPORT], [1], [Generate OPI comments in PS output.]) +AC_DEFINE([MULTITHREADED], [1], [Enable multithreading support.]) +AC_DEFINE([TEXTOUT_WORD_LIST], [1], [Enable word list support.]) + +dnl Check for OS specific flags +win32_libs="" +create_shared_lib="" +auto_import_flags="" +case "$host_os" in + cygwin*) + create_shared_lib="-no-undefined" + ;; + mingw*) + os_win32=yes + win32_libs="-lgdi32 -lwinspool -lcomdlg32" + create_shared_lib="-no-undefined" + auto_import_flags="-Wl,--enable-auto-import" + + # Use mingw's ansi stdio extensions + CXXFLAGS="$CXXFLAGS -D__USE_MINGW_ANSI_STDIO=1" + ;; +esac + +AC_SUBST(win32_libs) +AC_SUBST(create_shared_lib) +AC_SUBST(auto_import_flags) + +AX_PTHREAD() + +dnl Install xpdf headers +AC_ARG_ENABLE(xpdf-headers, + AC_HELP_STRING([--enable-xpdf-headers], + [Install unsupported xpdf headers.]), + enable_xpdf_headers=$enableval, + enable_xpdf_headers="no") +AM_CONDITIONAL(ENABLE_XPDF_HEADERS, test x$enable_xpdf_headers = xyes) + +AC_ARG_ENABLE(single-precision, +[ --enable-single-precision use single precision arithmetic (instead of double precision) in the Splash backend], +AC_DEFINE(USE_FLOAT, [1], [Use single precision arithmetic in the Splash backend])) + +AC_ARG_ENABLE(fixedpoint, +[ --enable-fixedpoint use fixed point (instead of double precision) arithmetic in the Splash backend], +AC_DEFINE(USE_FIXEDPOINT, [1], [Use fixed point arithmetic in the Splash backend])) + +dnl Relocation support +AC_ARG_ENABLE(relocatable, + AC_HELP_STRING([--disable-relocatable], + [Hardcode the poppler library location (on Windows).]), + enable_relocatable=$enableval, + [if test x$os_win32 = xyes; then + # default to yes on native Windows. + enable_relocatable="yes" + else + # default to no everywhere else. + enable_relocatable="no" + fi + ] +) + +if test x$enable_relocatable = xyes; then + if test x$os_win32 = xyes; then + AC_DEFINE([ENABLE_RELOCATABLE], + [1],[Do not hardcode the library location]) + else + AC_MSG_ERROR( + [Invalid setting for relocatable, only supported on windows]) + + fi +fi + +dnl ##### Check for installed poppler-data. Use the same datarootdir as default otherwise. +PKG_CHECK_EXISTS(poppler-data, + [POPPLER_DATADIR=`$PKG_CONFIG --variable=poppler_datadir poppler-data` + AC_DEFINE_DIR(POPPLER_DATADIR, "{POPPLER_DATADIR}", [Poppler data dir])], + [AC_DEFINE_DIR(POPPLER_DATADIR, "{datarootdir}/poppler", [Poppler data dir])] + ) + +dnl ##### Checks for header files. +AC_PATH_XTRA +AC_HEADER_DIRENT +AC_CHECK_HEADERS([stdint.h]) + +dnl ##### Switch over to C++. This will make the checks below a little +dnl ##### bit stricter (requiring function prototypes in include files). +dnl ##### (99% of xpdf is written in C++.) +AC_LANG_CPLUSPLUS + +AC_CHECK_DECL(gettimeofday, [AC_CHECK_FUNC(gettimeofday, AC_DEFINE(HAVE_GETTIMEOFDAY, 1, [Defines if gettimeofday is available on your system]))],[],[#include <sys/time.h>]) +AC_CHECK_FUNC(localtime_r, AC_DEFINE(HAVE_LOCALTIME_R, 1, [Defines if localtime_r is available on your system])) +AC_CHECK_FUNC(gmtime_r, AC_DEFINE(HAVE_GMTIME_R, 1, [Defines if gmtime_r is available on your system])) +AC_CHECK_FUNC(rand_r, AC_DEFINE(HAVE_RAND_R, 1, [Defines if rand_r is available on your system])) + +dnl ##### Check for extra libraries needed by X. (LynxOS needs this.) +AC_CHECK_FUNC(gethostbyname) +if test $ac_cv_func_gethostbyname = no; then + AC_CHECK_LIB(bsd, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd") +fi + +AC_CHECK_FUNC(nanosleep,,) +dnl try in librt if not found in current LIBS +if test x$ac_cv_func_nanosleep = xno +then + AC_CHECK_LIB(rt,nanosleep, X_EXTRA_LIBS="$X_EXTRA_LIBS -lrt") +fi + +dnl try in libposix4, if not found so far +if test x$ac_cv_func_nanosleep = xno && test x$ac_cv_lib_rt_nanosleep = xno +then + AC_CHECK_LIB(posix4,nanosleep, X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix4") +fi + + +dnl ##### Test for libopenjpeg. Versions prior to 1.4 do not provide a pkgconfig file. +openjpeg1="no" +openjpeg2="no" +AC_ARG_ENABLE(libopenjpeg, + AC_HELP_STRING([--enable-libopenjpeg=@<:@auto/openjpeg1/openjpeg2/none@:>@], + [Use openjpeg for JPEG2000 images. 'auto' prefers openjpeg1 over openjpeg2 if both are available due to regressions in openjpeg2 [[default=auto]]]), + [enable_libopenjpeg=$enableval], + [enable_libopenjpeg="auto"]) + +openjpeg_header=yes + +dnl test for libopenjpeg1 +if test x$enable_libopenjpeg = xopenjpeg1 || test x$enable_libopenjpeg = xauto; then + PKG_CHECK_MODULES(LIBOPENJPEG, libopenjpeg, + [openjpeg1="yes"], + [AC_CHECK_LIB([openjpeg], [opj_cio_open], + [openjpeg1="yes" + LIBOPENJPEG_LIBS="-lopenjpeg"],[openjpeg_header=no]) + AC_CHECK_HEADERS([openjpeg.h],, + [openjpeg="no"])]) +fi + +dnl test for libopenjpeg2 +if test x$openjpeg1 = xno; then + if test x$enable_libopenjpeg = xopenjpeg2 || test x$enable_libopenjpeg = xauto; then + PKG_CHECK_MODULES(LIBOPENJPEG, libopenjp2, + [openjpeg2=yes],[]) + fi +fi + +if test x$enable_libopenjpeg = xopenjpeg1 && test x$openjpeg1 = xno; then + if test x$openjpeg_header = xno; then + AC_MSG_ERROR("*** libopenjpeg headers not found ***") + else + AC_MSG_ERROR("*** libopenjpeg library not found ***") + fi +fi + +if test x$enable_libopenjpeg = xopenjpeg2 && test x$openjpeg2 = xno; then + AC_MSG_ERROR("*** libopenjp2 library not found ***") +fi + +if test x$openjpeg1 = xyes || test x$openjpeg2 = xyes; then + enable_libopenjpeg=yes + if test x$openjpeg1 = xyes; then + AC_DEFINE(USE_OPENJPEG1, 1, [Defined if using openjpeg1]) + fi + if test x$openjpeg2 = xyes; then + AC_DEFINE(USE_OPENJPEG2, 1, [Defined if using openjpeg2]) + fi + + AC_SUBST(LIBOPENJPEG_CFLAGS) + AC_SUBST(LIBOPENJPEG_LIBS) + AC_DEFINE(ENABLE_LIBOPENJPEG) + PKG_CHECK_EXISTS(libopenjpeg >= 1.5, + [AC_DEFINE(WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG, 1, [OpenJPEG with the OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG flag.])], + [PKG_CHECK_EXISTS(libopenjpeg1 >= 1.5, + [AC_DEFINE(WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG, 1, [OpenJPEG with the OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG flag.])], + []) + ]) +else + enable_libopenjpeg=no +fi + +AM_CONDITIONAL(BUILD_LIBOPENJPEG, test x$openjpeg1 = xyes || test x$openjpeg2 = xyes) +AH_TEMPLATE([ENABLE_LIBOPENJPEG], + [Use libopenjpeg instead of builtin jpeg2000 decoder.]) + +dnl ##### Test for libtiff +AC_ARG_ENABLE(libtiff, + AC_HELP_STRING([--disable-libtiff], + [Don't build against libtiff.]), + enable_libtiff=$enableval, + enable_libtiff="try") + +AC_ARG_VAR([LIBTIFF_CFLAGS], [C compiler flags for LIBTIFF]) +AC_ARG_VAR([LIBTIFF_LIBS], [linker flags to link LIBTIFF (default is -ltiff)]) +ac_save_CPPFLAGS="$CPPFLAGS" +ac_save_CXXFLAGS="$CXXFLAGS" +ac_save_LIBS="$LDFLAGS" +CPPFLAGS="$CPPFLAGS $LIBTIFF_CFLAGS" +CXXFLAGS="$CXXFLAGS $LIBTIFF_CFLAGS" +LIBS="$LIBS $LIBTIFF_LIBS" +if test x$enable_libtiff = xyes; then + if test x"$LIBTIFF_LIBS" != x; then + AC_CHECK_FUNC([TIFFOpen],, + AC_MSG_ERROR("*** libtiff library not found ***")) + else + AC_CHECK_LIB([tiff], [TIFFOpen],, + AC_MSG_ERROR("*** libtiff library not found ***")) + fi + AC_CHECK_HEADERS([tiffio.h],, + AC_MSG_ERROR("*** libtiff headers not found ***")) +elif test x$enable_libtiff = xtry; then + if test x"$LIBTIFF_LIBS" != x; then + AC_CHECK_FUNC([TIFFOpen], + [enable_libtiff="yes"], + [enable_libtiff="no"]) + else + AC_CHECK_LIB([tiff], [TIFFOpen], + [enable_libtiff="yes"], + [enable_libtiff="no"]) + fi + AC_CHECK_HEADERS([tiffio.h],, + [enable_libtiff="no"]) +fi +CPPFLAGS="$ac_save_CPPFLAGS" +CXXFLAGS="$ac_save_CXXFLAGS" +LIBS="$ac_save_LIBS" + +if test x$enable_libtiff = xyes; then + if test x"$LIBTIFF_LIBS" = x; then + LIBTIFF_LIBS="-ltiff" + fi + AC_SUBST(LIBTIFF_CFLAGS) + AC_SUBST(LIBTIFF_LIBS) + AC_DEFINE(ENABLE_LIBTIFF) +fi + +AM_CONDITIONAL(BUILD_LIBTIFF, test x$enable_libtiff = xyes) +AH_TEMPLATE([ENABLE_LIBTIFF], [Build against libtiff.]) +if test x$enable_libtiff = xyes; then + AC_DEFINE(ENABLE_LIBTIFF, 1, [Build against libtiff.]) +fi + +dnl ##### Checks for library functions. +AC_CHECK_FUNCS(popen mkstemp mkstemps) +AC_CHECK_FUNCS(strcpy_s strcat_s) + +dnl ##### Back to C for the library tests. +AC_LANG_C + +dnl ##### Check for fseeko/ftello or fseek64/ftell64 +dnl The LARGEFILE and FSEEKO macros have to be called in C, not C++, mode. +AC_SYS_LARGEFILE +AC_FUNC_FSEEKO +AC_CHECK_FUNCS(fseek64, xpdf_cv_func_fseek64=yes, xpdf_cv_func_fseek64=no) +AC_CHECK_FUNCS(ftell64, xpdf_cv_func_ftell64=yes, xpdf_cv_func_ftell64=no) +if test "$xpdf_cv_func_fseek64" = yes -a "$xpdf_cv_func_ftell64" = yes; then + AC_DEFINE(HAVE_FSEEK64) +fi +AC_CHECK_FUNCS(pread64 lseek64) + +dnl Test for zlib +AC_ARG_ENABLE([zlib], + [AS_HELP_STRING([--enable-zlib],[Build with zlib])], + [],[enable_zlib="no"]) +if test x$enable_zlib = xyes; then + AC_CHECK_LIB([z], [inflate],, + AC_MSG_ERROR("*** zlib library not found ***")) + AC_CHECK_HEADERS([zlib.h],, + AC_MSG_ERROR("*** zlib headers not found ***")) +elif test x$enable_zlib = xtry; then + AC_CHECK_LIB([z], [inflate], + [enable_zlib="yes"], + [enable_zlib="no"]) + AC_CHECK_HEADERS([zlib.h],, + [enable_zlib="no"]) +fi + +if test x$enable_zlib = xyes; then + ZLIB_LIBS="-lz" + AC_SUBST(ZLIB_LIBS) + AC_DEFINE(ENABLE_ZLIB) +fi + +AM_CONDITIONAL(BUILD_ZLIB, test x$enable_zlib = xyes) +AH_TEMPLATE([ENABLE_ZLIB], + [Use zlib instead of builtin zlib decoder.]) + +dnl Test for libcurl +AC_ARG_ENABLE(libcurl, + AC_HELP_STRING([--enable-libcurl], + [Build with libcurl based HTTP support.]), + enable_libcurl=$enableval, + enable_libcurl="no") + +if test x$enable_libcurl = xyes; then + PKG_CHECK_MODULES(LIBCURL, libcurl) + AC_DEFINE(ENABLE_LIBCURL, 1, [Build against libcurl.]) + AC_DEFINE(POPPLER_HAS_CURL_SUPPORT, 1, + [Support for curl based doc builder is compiled in.]) +fi + +AM_CONDITIONAL(BUILD_LIBCURL, test x$enable_libcurl = xyes) + +dnl Test for libjpeg +AC_ARG_ENABLE(libjpeg, + AC_HELP_STRING([--disable-libjpeg], + [Don't build against libjpeg.]), + enable_libjpeg=$enableval, + enable_libjpeg="try") +AC_ARG_VAR([LIBJPEG_CFLAGS], [C compiler flags for LIBJPEG]) +if test x$enable_libjpeg != xno; then + + dnl + dnl POPPLER_FIND_JPEG uses "USER_INCLUDES" and "USER_LIBS" + dnl to receive the flags for header and library directories. + dnl + ac_save_USER_INCLUDES="$USER_INCLUDES" + ac_save_USER_LDFLAGS="$USER_LDFLAGS" + USER_INCLUDES="$USER_INCLUDES $LIBJPEG_CFLAGS" + USER_LDFLAGS="$USER_LDFLAGS $LIBJPEG_CFLAGS" + POPPLER_FIND_JPEG + + dnl check INT16, INT32 typedef conflict in jmorecfg.h + ac_save_CPPFLAGS="$CPPFLAGS" + ac_save_CFLAGS="$CFLAGS" + CPPFLAGS="$CPPFLAGS $LIBJPEG_CFLAGS" + CFLAGS="$CFLAGS $LIBJPEG_CFLAGS" + AC_MSG_CHECKING([libjpeg.h works correctly]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ +#ifdef _WIN32 +#include <windows.h> +#endif +#include <sys/types.h> +#include <stdio.h> +#include <jpeglib.h> +],[{return 0;}])],[ + AC_MSG_RESULT([ok]) + ],[ + AC_MSG_RESULT([no]) + AC_MSG_CHECKING([libjpeg.h problem can be fixed by XMD_H macro]) + CPPFLAGS="$CPPFLAGS -DXMD_H" + CFLAGS="$CFLAGS -DXMD_H" + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ +#ifdef _WIN32 +#include <windows.h> +#endif +#include <sys/types.h> +#include <stdio.h> +#include <jpeglib.h> +],[{return 0;}])],[ + AC_MSG_RESULT([ok, -DXMD_H is added to LIBJPEG_CFLAGS]) + LIBJPEG_CFLAGS="$LIBJPEG_CFLAGS -DXMD_H" + ],[ + AC_MSG_RESULT([no, disable libjpeg]) + enable_libjpeg="no" + ]) + ]) + CPPFLAGS="$ac_save_CPPFLAGS" + CFLAGS="$ac_save_CFLAGS" + + dnl POPPLER_FIND_JPEG sets LIBJPEG_LIBS + AC_SUBST(LIBJPEG_CFLAGS) + USER_INCLUDES="$ac_save_USER_INCLUDES" + USER_LDFLAGS="$ac_save_USER_LDFLAGS" +fi + +AM_CONDITIONAL(BUILD_LIBJPEG, test x$enable_libjpeg = xyes) +AH_TEMPLATE([ENABLE_LIBJPEG], + [Use libjpeg instead of builtin jpeg decoder.]) + +dnl Test for libpng +AC_ARG_ENABLE(libpng, + AC_HELP_STRING([--disable-libpng], + [Do not build against libpng.]), + enable_libpng=$enableval, + enable_libpng="try") + +if test x$enable_libpng != xno; then + PKG_CHECK_MODULES(LIBPNG, libpng, [enable_libpng="yes"], + [enable_libpng="no"]) +fi + +if test x$enable_libpng = xyes; then + AC_DEFINE(ENABLE_LIBPNG, 1, [Build against libpng.]) +fi + +AM_CONDITIONAL(BUILD_LIBPNG, test x$enable_libpng = xyes) + +dnl Check for freetype headers + +PKG_CHECK_MODULES(FREETYPE, freetype2, + [freetype_pkgconfig=yes], [freetype_pkgconfig=no]) + +if test "x$freetype_pkgconfig" = "xyes"; then + + AC_DEFINE(HAVE_FREETYPE_H, 1, [Have FreeType2 include files]) + +else + + FREETYPE_LIBS= + FREETYPE_CFLAGS= + + AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, no) + if test "x$FREETYPE_CONFIG" != "xno" ; then + + FREETYPE_CFLAGS=`$FREETYPE_CONFIG --cflags` + FREETYPE_LIBS=`$FREETYPE_CONFIG --libs` + AC_DEFINE(HAVE_FREETYPE_H, 1, [Have FreeType2 include files]) + + fi + +fi + +AC_SUBST(FREETYPE_CFLAGS) +AC_SUBST(FREETYPE_LIBS) + +AC_MSG_CHECKING([which font configuration to use]) +AC_ARG_WITH([font_configuration], + [AS_HELP_STRING([--with-font-configuration=fontconfig|win32], + [Select font configuration backend])], + [], + [if test x$os_win32 = xyes; then + # default to win32 on native Windows. + with_font_configuration=win32 + else + # default to fontconig everywhere else. + with_font_configuration=fontconfig + fi + ] +) +AC_MSG_RESULT([$with_font_configuration]) + +case $with_font_configuration in + win32) + AC_DEFINE([WITH_FONTCONFIGURATION_WIN32], + [1],[Use win32 font configuration backend]) + # Set the minimum required Internet Explorer version to 5.0 + CPPFLAGS="$CPPFLAGS -D_WIN32_IE=0x0500" + ;; + fontconfig) + AC_DEFINE([WITH_FONTCONFIGURATION_FONTCONFIG], + [1],[Use fontconfig font configuration backend]) + PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 2.0.0) + ;; + *) + AC_MSG_ERROR( + [Invalid font configuration setting: $with_font_configuration]) + ;; +esac + +AM_CONDITIONAL(BUILD_WITH_WIN32_FONTCONFIGURATION, + test x$with_font_configuration = xwin32) + +AC_ARG_ENABLE(splash-output, + AC_HELP_STRING([--disable-splash-output], + [Don't build the Splash graphics backend.]),, + enable_splash_output="yes") +AM_CONDITIONAL(BUILD_SPLASH_OUTPUT, test x$enable_splash_output = xyes) +AH_TEMPLATE([HAVE_SPLASH], [Use splash for rendering.]) +if test x$enable_splash_output = xyes; then + AC_DEFINE(HAVE_SPLASH) +fi + +CAIRO_VERSION="1.10.0" +AC_SUBST(CAIRO_VERSION) +CAIRO_DEPS="cairo >= $CAIRO_VERSION cairo-ft >= $CAIRO_VERSION" +AC_ARG_ENABLE(cairo-output, + AC_HELP_STRING([--disable-cairo-output], + [Don't build the cairo graphics backend.]), + enable_cairo_output=$enableval, + enable_cairo_output="try") +use_cairo="" +if test x$enable_cairo_output = xyes; then + PKG_CHECK_MODULES(CAIRO, $CAIRO_DEPS) +elif test x$enable_cairo_output = xtry; then + PKG_CHECK_MODULES(CAIRO, $CAIRO_DEPS, + [enable_cairo_output="yes"], + [enable_cairo_output="no" + use_cairo="no (requires cairo >= $CAIRO_VERSION)"]) +fi +if test "x$use_cairo" = "x"; then + use_cairo=$enable_cairo_output +fi + +AC_SUBST(CAIRO_CFLAGS) +AC_SUBST(CAIRO_LIBS) + +AM_CONDITIONAL(BUILD_CAIRO_OUTPUT, test x$enable_cairo_output = xyes) +AH_TEMPLATE([HAVE_CAIRO], [Use cairo for rendering.]) +if test x$enable_cairo_output = xyes; then + PDFTOCAIRO_DEPS="cairo cairo-ft" + dnl Check for optional cairo backends used by pdftocairo + PKG_CHECK_EXISTS(cairo-pdf, [PDFTOCAIRO_DEPS="$PDFTOCAIRO_DEPS cairo-pdf"], []) + PKG_CHECK_EXISTS(cairo-ps, [PDFTOCAIRO_DEPS="$PDFTOCAIRO_DEPS cairo-ps"], []) + PKG_CHECK_EXISTS(cairo-svg, [PDFTOCAIRO_DEPS="$PDFTOCAIRO_DEPS cairo-svg"], []) + + PKG_CHECK_MODULES(PDFTOCAIRO, $PDFTOCAIRO_DEPS) + AC_SUBST(PDFTOCAIRO_CFLAGS) + AC_SUBST(PDFTOCAIRO_LIBS) + + AC_DEFINE(HAVE_CAIRO) + CAIRO_FEATURE="#define POPPLER_HAS_CAIRO 1" + CAIRO_REQ="cairo" + AC_CHECK_HEADERS(fcntl.h sys/mman.h sys/stat.h) +else + CAIRO_FEATURE="#undef POPPLER_HAS_CAIRO" + CAIRO_REQ="" +fi +AC_SUBST(CAIRO_FEATURE) +AC_SUBST(CAIRO_REQ) + +use_glib="" +found_introspection=no +if test x$enable_cairo_output = xyes; then + POPPLER_GLIB_DISABLE_DEPRECATED="" + POPPLER_GLIB_DISABLE_SINGLE_INCLUDES="" + + GLIB_REQUIRED=2.18 + AC_SUBST(GLIB_REQUIRED) + AC_ARG_ENABLE(poppler-glib, + AC_HELP_STRING([--disable-poppler-glib], + [Don't compile poppler glib wrapper.]), + enable_poppler_glib=$enableval, + enable_poppler_glib="try") + if test x$enable_poppler_glib = xyes; then + PKG_CHECK_MODULES(POPPLER_GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED cairo >= $CAIRO_VERSION) + elif test x$enable_poppler_glib = xtry; then + PKG_CHECK_MODULES(POPPLER_GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED cairo >= $CAIRO_VERSION, + [enable_poppler_glib="yes"], + [enable_poppler_glib="no" + use_glib="no (requires glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED cairo >= $CAIRO_VERSION)"]) + fi + if test x$enable_poppler_glib = xyes; then + # Check for introspection + GOBJECT_INTROSPECTION_CHECK([0.6.7]) + + AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums]) + POPPLER_GLIB_DISABLE_DEPRECATED="$POPPLER_GLIB_DISABLE_DEPRECATED -DG_DISABLE_DEPRECATED" + POPPLER_GLIB_DISABLE_SINGLE_INCLUDES="$POPPLER_GLIB_DISABLE_SINGLE_INCLUDES -DG_DISABLE_SINGLE_INCLUDES" + fi +else + if test x$enable_poppler_glib = xyes; then + AC_MSG_ERROR("Cairo output is required to build glib frontend") + fi + use_glib="no (requires cairo output)" + enable_poppler_glib="no" +fi +if test x"$use_glib" = x; then + use_glib="$enable_poppler_glib" +fi +AM_CONDITIONAL(BUILD_POPPLER_GLIB, test x$enable_poppler_glib = xyes) +AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes") +AC_SUBST(GLIB_REQ) +AC_SUBST(POPPLER_GLIB_DISABLE_DEPRECATED) +AC_SUBST(POPPLER_GLIB_DISABLE_SINGLE_INCLUDES) + +GTK_DOC_CHECK([1.14],[--flavour no-tmpl]) + +dnl +dnl Try Qt4 +dnl + +AC_ARG_ENABLE(poppler-qt4, + AC_HELP_STRING([--disable-poppler-qt4], + [Don't compile poppler Qt4 wrapper.]), + enable_poppler_qt4=$enableval, + enable_poppler_qt4="try") +if test x$enable_poppler_qt4 = xyes; then + PKG_CHECK_MODULES(POPPLER_QT4, + QtCore >= 4.7.0 QtGui >= 4.7.0 QtXml >= 4.7.0) + PKG_CHECK_MODULES(POPPLER_QT4_TEST, + QtTest >= 4.7.0) +elif test x$enable_poppler_qt4 = xtry; then + PKG_CHECK_MODULES(POPPLER_QT4, + QtCore >= 4.7.0 QtGui >= 4.7.0 QtXml >= 4.7.0, + [enable_poppler_qt4="yes"], + [enable_poppler_qt4="no"]) + if test x$enable_poppler_qt4 = xyes; then + PKG_CHECK_MODULES(POPPLER_QT4_TEST, + QtTest >= 4.7.0, + [enable_poppler_qt4="yes"], + [enable_poppler_qt4="no"]) + fi +fi + +AC_SUBST(POPPLER_QT4_CXXFLAGS) +AC_SUBST(POPPLER_QT4_LIBS) +AC_SUBST(POPPLER_QT4_TEST_LIBS) + +if test x$enable_poppler_qt4 = xyes; then + AC_CHECK_TOOL(MOCQT4, moc) + AC_MSG_CHECKING([for Qt4 moc]) + mocversion=`$MOCQT4 -v 2>&1` + mocversiongrep=`echo $mocversion | grep "Qt 4"` + if test x"$mocversiongrep" != x"$mocversion"; then + AC_MSG_RESULT([no]) + # moc was not the qt4 one, try with moc-qt4 + AC_CHECK_TOOL(MOCQT42, moc-qt4) + AC_MSG_CHECKING([for Qt4 moc-qt4]) + mocversion=`$MOCQT42 -v 2>&1` + mocversiongrep=`echo $mocversion | grep "Qt 4"` + if test x"$mocversiongrep" != x"$mocversion"; then + # no valid moc found + enable_poppler_qt4=no; + MOCQT4="not found" + else + MOCQT4=$MOCQT42 + fi + fi + AC_SUBST(MOCQT4) + AC_MSG_RESULT([$MOCQT4]) +fi + +AM_CONDITIONAL(BUILD_POPPLER_QT4, test "x$enable_poppler_qt4" = "xyes") + +dnl +dnl Try Qt5 +dnl + +AC_ARG_ENABLE(poppler-qt5, + AC_HELP_STRING([--disable-poppler-qt5], + [Don't compile poppler Qt5 wrapper.]), + enable_poppler_qt5=$enableval, + enable_poppler_qt5="try") +if test x$enable_poppler_qt5 = xyes; then + PKG_CHECK_MODULES(POPPLER_QT5, + Qt5Core >= 5.0.0 Qt5Gui >= 5.0.0 Qt5Xml >= 5.0.0 Qt5Widgets >= 5.0.0) + PKG_CHECK_MODULES(POPPLER_QT5_TEST, + Qt5Test >= 5.0.0 ) +elif test x$enable_poppler_qt5 = xtry; then + PKG_CHECK_MODULES(POPPLER_QT5, + Qt5Core >= 5.0.0 Qt5Gui >= 5.0.0 Qt5Xml >= 5.0.0 Qt5Widgets >= 5.0.0, + [enable_poppler_qt5="yes"], + [enable_poppler_qt5="no"]) + if test x$enable_poppler_qt5 = xyes; then + PKG_CHECK_MODULES(POPPLER_QT5_TEST, + Qt5Test >= 5.0.0, + [enable_poppler_qt5="yes"], + [enable_poppler_qt5="no"]) + fi +fi + +AC_SUBST(POPPLER_QT5_CXXFLAGS) +AC_SUBST(POPPLER_QT5_LIBS) +AC_SUBST(POPPLER_QT5_TEST_LIBS) + +if test x$enable_poppler_qt5 = xyes; then + AC_CHECK_TOOL(MOCQT5, moc) + AC_MSG_CHECKING([for Qt5 moc]) + mocversion=`$MOCQT5 -v 2>&1` + mocversiongrep=`echo $mocversion | grep "Qt 5\|moc 5"` + if test x"$mocversiongrep" != x"$mocversion"; then + AC_MSG_RESULT([no]) + # moc was not the qt5 one, try with moc-qt5 + AC_CHECK_TOOL(MOCQT52, moc-qt5) + AC_MSG_CHECKING([for Qt5 moc-qt5]) + mocversion=`$MOCQT52 -v 2>&1` + mocversiongrep=`echo $mocversion | grep "Qt 5\|moc-qt5 5\|moc 5"` + if test x"$mocversiongrep" != x"$mocversion"; then + AC_CHECK_TOOL(QTCHOOSER, qtchooser) + AC_MSG_CHECKING([for qtchooser]) + qt5tooldir=`QT_SELECT=qt5 qtchooser -print-env | grep QTTOOLDIR | cut -d '=' -f 2 | cut -d \" -f 2` + mocversion=`$qt5tooldir/moc -v 2>&1` + mocversiongrep=`echo $mocversion | grep "Qt 5\|moc 5"` + if test x"$mocversiongrep" != x"$mocversion"; then + # no valid moc found + enable_poppler_qt5=no; + MOCQT5="not found" + else + MOCQT5=$qt5tooldir/moc + fi + else + MOCQT5=$MOCQT52 + fi + fi + AC_SUBST(MOCQT5) + AC_MSG_RESULT([$MOCQT5]) +fi + +AM_CONDITIONAL(BUILD_POPPLER_QT5, test "x$enable_poppler_qt5" = "xyes") + +dnl +dnl CPP frontend +dnl + +AC_ARG_ENABLE(poppler-cpp, + AC_HELP_STRING([--disable-poppler-cpp], + [Don't compile poppler cpp wrapper.]), + enable_poppler_cpp=$enableval, + enable_poppler_cpp="yes") +if test x$enable_poppler_cpp = xyes; then + AM_ICONV() + if test x$am_func_iconv != xyes; then + enable_poppler_cpp=no + fi +fi + +AM_CONDITIONAL(BUILD_POPPLER_CPP, test "x$enable_poppler_cpp" = "xyes") + + +GTK_TEST_DEPS='gtk+-3.0 >= 3.8 gdk-pixbuf-2.0' +if test x$enable_cairo_output = xyes; then + GTK_TEST_DEPS="$GTK_TEST_DEPS $CAIRO_DEPS" +fi +AC_ARG_ENABLE(gtk-test, + AC_HELP_STRING([--disable-gtk-test], + [Don't compile GTK+ test program.]), + enable_gtk_test=$enableval, + enable_gtk_test="try") +if test x$enable_gtk_test = xyes; then + PKG_CHECK_MODULES(GTK_TEST, $GTK_TEST_DEPS) +elif test x$enable_gtk_test = xtry; then + PKG_CHECK_MODULES(GTK_TEST, $GTK_TEST_DEPS, + [enable_gtk_test="yes"], + [enable_gtk_test="no"]) +fi +AM_CONDITIONAL(BUILD_GTK_TEST, test x$enable_gtk_test = xyes -a x$enable_poppler_glib = xyes) + +AC_ARG_ENABLE(utils, + AC_HELP_STRING([--disable-utils], + [Don't compile poppler command line utils.]), + enable_utils=$enableval, + enable_utils="yes") +AM_CONDITIONAL(BUILD_UTILS, test x$enable_utils = xyes) + +AC_ARG_ENABLE(compile-warnings, + AC_HELP_STRING([--enable-compile-warnings=@<:@no/yes/kde@:>@], + [Turn on compiler warnings.]),, + [enable_compile_warnings="yes"]) + +dnl +dnl Color Management +dnl + +AC_ARG_ENABLE(cms, + AC_HELP_STRING([--enable-cms=@<:@auto/lcms1/lcms2/none@:>@], + [Use color management system. 'auto' prefers lcms2 over lcms1 if both are available [[default=auto]]]), + [enable_cms=$enableval], + [enable_cms="auto"]) +if test x$enable_cms = xauto; then + PKG_CHECK_MODULES(LCMS, lcms2, [lcms2=yes], [lcms2=no]) + if test x$lcms2 = xno; then + PKG_CHECK_MODULES(LCMS, lcms, [lcms1=yes], [lcms1=no]) + fi +elif test x$enable_cms = xlcms1; then + PKG_CHECK_MODULES(LCMS, lcms, [lcms1=yes], [lcms1=no]) +elif test x$enable_cms = xlcms2; then + PKG_CHECK_MODULES(LCMS, lcms2, [lcms2=yes], [lcms2=no]) +fi + +if test x$lcms1 = xyes || test x$lcms2 = xyes; then + enable_cms=yes + AC_DEFINE(USE_CMS, 1, [Defines if use cms]) + if test x$lcms1 = xyes; then + lcms1=yes; + AC_DEFINE(USE_LCMS1, 1, [Defines if use lcms1]) + fi +else + enable_cms=no +fi + +AM_CONDITIONAL(USE_CMS, test x$enable_cms = xyes) +AM_CONDITIONAL(USE_LCMS1, test x$lcms1 = xyes) + +AC_ARG_WITH([testdatadir], + [AS_HELP_STRING([--with-testdatadir=/path/to/testdatadir], + [Specify test data dir])], + [case $withval in + [[\\/]]* | ?:[[\\/]]* ) # Absolute name. + TESTDATADIR=$withval ;; + *) # Relative name. + TESTDATADIR=$ac_pwd/$withval ;; + esac + ], + [case $srcdir in + [[\\/]]* | ?:[[\\/]]* ) # Absolute name. + TESTDATADIR=$srcdir/../test ;; + *) # Relative name. + TESTDATADIR=$ac_pwd/$srcdir/../test ;; + esac + ] +) +AC_MSG_CHECKING([for test data in $TESTDATADIR]) +if test -d $TESTDATADIR && test -f $TESTDATADIR/test-poppler.c; then + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) + AC_MSG_WARN([ + No test data found in $TESTDATADIR. + You will not be able to run 'make check' successfully. + + The test data is not included in the source packages + and is also not part of the main git repository. Instead, + you can checkout the test data from its own git + repository with: + + git clone git://git.freedesktop.org/git/poppler/test + + You should checkout the test data as a sibling of your + poppler source folder or specify the location of your + checkout with --with-testdatadir=/path/to/checkoutdir/test. +]) +fi +AC_SUBST(TESTDATADIR) + +# some compilers do not support this flag (see bug #76963) +fno_check_new= +AC_MSG_CHECKING([for -fno-check-new compiler flag]) +AC_LANG_PUSH([C++]) +saved_CXXFLAGS=$CXXFLAGS +CXXFLAGS="-fno-check-new $CXXFLAGS" +AC_TRY_COMPILE([], [], + [AC_MSG_RESULT([yes]) + fno_check_new="-fno-check-new"], + AC_MSG_RESULT([no]) +) +CXXFLAGS=$saved_CXXFLAGS +AC_LANG_POP + +if test "x$GCC" != xyes; then + enable_compile_warnings=no +fi +case "$enable_compile_warnings" in + no) ;; + yes) CXXFLAGS="-Wall -Woverloaded-virtual -Wnon-virtual-dtor -Wcast-align -fno-exceptions $fno_check_new -fno-common $CXXFLAGS"; + CFLAGS="-Wall $CFLAGS" ;; + kde) CXXFLAGS="-Wnon-virtual-dtor -Wno-long-long -Wundef \ + -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -Wcast-align \ + -Wconversion -Wall -W -Wpointer-arith \ + -Wwrite-strings -O2 -Wformat-security \ + -Wmissing-format-attribute -fno-exceptions $fno_check_new \ + -fno-common $CXXFLAGS" ;; +esac + +case "$host_os" in + mingw*) + # mingw prints "warning: -fPIC ignored for target (all code is position independent)" + # for every file + ;; + *) + CXXFLAGS="-fPIC $CXXFLAGS"; + ;; +esac + + +case `$PKG_CONFIG --version` in + 0.?|0.1[0-7]) + PC_REQUIRES_PRIVATE=""; + PC_REQUIRES="poppler = $VERSION";; + *) + PC_REQUIRES_PRIVATE="Requires.private: poppler = $VERSION"; + PC_REQUIRES="";; +esac + +AC_SUBST(PC_REQUIRES) +AC_SUBST(PC_REQUIRES_PRIVATE) + +AC_SUBST([POPPLER_MAJOR_VERSION],[poppler_version_major]) +AC_SUBST([POPPLER_MINOR_VERSION],[poppler_version_minor]) +AC_SUBST([POPPLER_MICRO_VERSION],[poppler_version_micro]) +AC_SUBST([POPPLER_VERSION],[poppler_version]) + +AC_OUTPUT([ +Makefile +goo/Makefile +fofi/Makefile +splash/Makefile +poppler/Makefile +utils/Makefile +glib/Makefile +glib/poppler-features.h +glib/reference/Makefile +glib/reference/version.xml +glib/demo/Makefile +test/Makefile +qt4/Makefile +qt4/src/Makefile +qt4/tests/Makefile +qt4/demos/Makefile +qt5/Makefile +qt5/src/Makefile +qt5/tests/Makefile +qt5/demos/Makefile +cpp/Makefile +cpp/poppler-version.h +cpp/tests/Makefile +poppler.pc +poppler-uninstalled.pc +poppler-cairo.pc +poppler-cairo-uninstalled.pc +poppler-splash.pc +poppler-splash-uninstalled.pc +poppler-glib.pc +poppler-glib-uninstalled.pc +poppler-qt4.pc +poppler-qt4-uninstalled.pc +poppler-qt5.pc +poppler-qt5-uninstalled.pc +poppler-cpp.pc +poppler-cpp-uninstalled.pc]) + + +echo "" +echo "Building poppler with support for:" +echo " font configuration: $with_font_configuration" +echo " splash output: $enable_splash_output" +echo " cairo output: $use_cairo" +echo " qt4 wrapper: $enable_poppler_qt4" +echo " qt5 wrapper: $enable_poppler_qt5" +echo " glib wrapper: $use_glib" +echo " introspection: $found_introspection" +echo " cpp wrapper: $enable_poppler_cpp" +echo " use gtk-doc: $enable_gtk_doc" +echo " use libjpeg: $enable_libjpeg" +echo " use libpng: $enable_libpng" +echo " use libtiff: $enable_libtiff" +echo " use zlib: $enable_zlib" +echo " use libcurl: $enable_libcurl" +echo " use libopenjpeg: $enable_libopenjpeg" +if test x$enable_libopenjpeg = xyes;then + if test x$openjpeg1 = xyes;then + echo " with openjpeg1" + else + echo " with openjpeg2" + fi +fi +echo " use cms: $enable_cms" +if test x$enable_cms = xyes;then + if test x$lcms1 = xyes;then + echo " with lcms1" + else + echo " with lcms2" + fi +fi +echo " command line utils: $enable_utils" +echo " test data dir: $TESTDATADIR" +echo "" + +if test x$enable_splash_output = xno -a x$enable_cairo_output = xno; then + echo " Warning: There is no rendering backend enabled" +fi + +if test x$enable_single_precision = xyes -a x$enable_fixedpoint = xyes; then + echo " Warning: Single precision and fixed point options should not be enabled at the same time" +fi + +if test x$enable_libjpeg != xyes; then + echo " Warning: Using libjpeg is recommended" +fi + +if test x$enable_zlib != xno; then + echo " Warning: Using zlib is not totally safe" +fi + +if test x$enable_libopenjpeg != xyes; then + echo " Warning: Using libopenjpeg is recommended" +fi diff --git a/source/libs/poppler/poppler-0.32.0/fofi/FoFiBase.cc b/source/libs/poppler/poppler-0.33.0/fofi/FoFiBase.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/fofi/FoFiBase.cc rename to source/libs/poppler/poppler-0.33.0/fofi/FoFiBase.cc diff --git a/source/libs/poppler/poppler-0.32.0/fofi/FoFiBase.h b/source/libs/poppler/poppler-0.33.0/fofi/FoFiBase.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/fofi/FoFiBase.h rename to source/libs/poppler/poppler-0.33.0/fofi/FoFiBase.h diff --git a/source/libs/poppler/poppler-0.32.0/fofi/FoFiEncodings.cc b/source/libs/poppler/poppler-0.33.0/fofi/FoFiEncodings.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/fofi/FoFiEncodings.cc rename to source/libs/poppler/poppler-0.33.0/fofi/FoFiEncodings.cc diff --git a/source/libs/poppler/poppler-0.32.0/fofi/FoFiEncodings.h b/source/libs/poppler/poppler-0.33.0/fofi/FoFiEncodings.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/fofi/FoFiEncodings.h rename to source/libs/poppler/poppler-0.33.0/fofi/FoFiEncodings.h diff --git a/source/libs/poppler/poppler-0.32.0/fofi/FoFiIdentifier.cc b/source/libs/poppler/poppler-0.33.0/fofi/FoFiIdentifier.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/fofi/FoFiIdentifier.cc rename to source/libs/poppler/poppler-0.33.0/fofi/FoFiIdentifier.cc diff --git a/source/libs/poppler/poppler-0.32.0/fofi/FoFiIdentifier.h b/source/libs/poppler/poppler-0.33.0/fofi/FoFiIdentifier.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/fofi/FoFiIdentifier.h rename to source/libs/poppler/poppler-0.33.0/fofi/FoFiIdentifier.h diff --git a/source/libs/poppler/poppler-0.32.0/fofi/FoFiTrueType.cc b/source/libs/poppler/poppler-0.33.0/fofi/FoFiTrueType.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/fofi/FoFiTrueType.cc rename to source/libs/poppler/poppler-0.33.0/fofi/FoFiTrueType.cc diff --git a/source/libs/poppler/poppler-0.32.0/fofi/FoFiTrueType.h b/source/libs/poppler/poppler-0.33.0/fofi/FoFiTrueType.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/fofi/FoFiTrueType.h rename to source/libs/poppler/poppler-0.33.0/fofi/FoFiTrueType.h diff --git a/source/libs/poppler/poppler-0.32.0/fofi/FoFiType1.cc b/source/libs/poppler/poppler-0.33.0/fofi/FoFiType1.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/fofi/FoFiType1.cc rename to source/libs/poppler/poppler-0.33.0/fofi/FoFiType1.cc diff --git a/source/libs/poppler/poppler-0.32.0/fofi/FoFiType1.h b/source/libs/poppler/poppler-0.33.0/fofi/FoFiType1.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/fofi/FoFiType1.h rename to source/libs/poppler/poppler-0.33.0/fofi/FoFiType1.h diff --git a/source/libs/poppler/poppler-0.32.0/fofi/FoFiType1C.cc b/source/libs/poppler/poppler-0.33.0/fofi/FoFiType1C.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/fofi/FoFiType1C.cc rename to source/libs/poppler/poppler-0.33.0/fofi/FoFiType1C.cc diff --git a/source/libs/poppler/poppler-0.32.0/fofi/FoFiType1C.h b/source/libs/poppler/poppler-0.33.0/fofi/FoFiType1C.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/fofi/FoFiType1C.h rename to source/libs/poppler/poppler-0.33.0/fofi/FoFiType1C.h diff --git a/source/libs/poppler/poppler-0.32.0/fofi/Makefile.am b/source/libs/poppler/poppler-0.33.0/fofi/Makefile.am old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/fofi/Makefile.am rename to source/libs/poppler/poppler-0.33.0/fofi/Makefile.am diff --git a/source/libs/poppler/poppler-0.32.0/goo/FixedPoint.cc b/source/libs/poppler/poppler-0.33.0/goo/FixedPoint.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/FixedPoint.cc rename to source/libs/poppler/poppler-0.33.0/goo/FixedPoint.cc diff --git a/source/libs/poppler/poppler-0.32.0/goo/FixedPoint.h b/source/libs/poppler/poppler-0.33.0/goo/FixedPoint.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/FixedPoint.h rename to source/libs/poppler/poppler-0.33.0/goo/FixedPoint.h diff --git a/source/libs/poppler/poppler-0.32.0/goo/GooHash.cc b/source/libs/poppler/poppler-0.33.0/goo/GooHash.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/GooHash.cc rename to source/libs/poppler/poppler-0.33.0/goo/GooHash.cc diff --git a/source/libs/poppler/poppler-0.32.0/goo/GooHash.h b/source/libs/poppler/poppler-0.33.0/goo/GooHash.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/GooHash.h rename to source/libs/poppler/poppler-0.33.0/goo/GooHash.h diff --git a/source/libs/poppler/poppler-0.32.0/goo/GooLikely.h b/source/libs/poppler/poppler-0.33.0/goo/GooLikely.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/GooLikely.h rename to source/libs/poppler/poppler-0.33.0/goo/GooLikely.h diff --git a/source/libs/poppler/poppler-0.32.0/goo/GooList.cc b/source/libs/poppler/poppler-0.33.0/goo/GooList.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/GooList.cc rename to source/libs/poppler/poppler-0.33.0/goo/GooList.cc diff --git a/source/libs/poppler/poppler-0.32.0/goo/GooList.h b/source/libs/poppler/poppler-0.33.0/goo/GooList.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/GooList.h rename to source/libs/poppler/poppler-0.33.0/goo/GooList.h diff --git a/source/libs/poppler/poppler-0.32.0/goo/GooMutex.h b/source/libs/poppler/poppler-0.33.0/goo/GooMutex.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/GooMutex.h rename to source/libs/poppler/poppler-0.33.0/goo/GooMutex.h diff --git a/source/libs/poppler/poppler-0.32.0/goo/GooString.cc b/source/libs/poppler/poppler-0.33.0/goo/GooString.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/GooString.cc rename to source/libs/poppler/poppler-0.33.0/goo/GooString.cc diff --git a/source/libs/poppler/poppler-0.32.0/goo/GooString.h b/source/libs/poppler/poppler-0.33.0/goo/GooString.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/GooString.h rename to source/libs/poppler/poppler-0.33.0/goo/GooString.h diff --git a/source/libs/poppler/poppler-0.32.0/goo/GooTimer.cc b/source/libs/poppler/poppler-0.33.0/goo/GooTimer.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/GooTimer.cc rename to source/libs/poppler/poppler-0.33.0/goo/GooTimer.cc diff --git a/source/libs/poppler/poppler-0.32.0/goo/GooTimer.h b/source/libs/poppler/poppler-0.33.0/goo/GooTimer.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/GooTimer.h rename to source/libs/poppler/poppler-0.33.0/goo/GooTimer.h diff --git a/source/libs/poppler/poppler-0.32.0/goo/ImgWriter.cc b/source/libs/poppler/poppler-0.33.0/goo/ImgWriter.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/ImgWriter.cc rename to source/libs/poppler/poppler-0.33.0/goo/ImgWriter.cc diff --git a/source/libs/poppler/poppler-0.32.0/goo/ImgWriter.h b/source/libs/poppler/poppler-0.33.0/goo/ImgWriter.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/ImgWriter.h rename to source/libs/poppler/poppler-0.33.0/goo/ImgWriter.h diff --git a/source/libs/poppler/poppler-0.32.0/goo/JpegWriter.cc b/source/libs/poppler/poppler-0.33.0/goo/JpegWriter.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/JpegWriter.cc rename to source/libs/poppler/poppler-0.33.0/goo/JpegWriter.cc diff --git a/source/libs/poppler/poppler-0.32.0/goo/JpegWriter.h b/source/libs/poppler/poppler-0.33.0/goo/JpegWriter.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/JpegWriter.h rename to source/libs/poppler/poppler-0.33.0/goo/JpegWriter.h diff --git a/source/libs/poppler/poppler-0.32.0/goo/Makefile.am b/source/libs/poppler/poppler-0.33.0/goo/Makefile.am old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/Makefile.am rename to source/libs/poppler/poppler-0.33.0/goo/Makefile.am diff --git a/source/libs/poppler/poppler-0.32.0/goo/NetPBMWriter.cc b/source/libs/poppler/poppler-0.33.0/goo/NetPBMWriter.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/NetPBMWriter.cc rename to source/libs/poppler/poppler-0.33.0/goo/NetPBMWriter.cc diff --git a/source/libs/poppler/poppler-0.32.0/goo/NetPBMWriter.h b/source/libs/poppler/poppler-0.33.0/goo/NetPBMWriter.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/NetPBMWriter.h rename to source/libs/poppler/poppler-0.33.0/goo/NetPBMWriter.h diff --git a/source/libs/poppler/poppler-0.32.0/goo/PNGWriter.cc b/source/libs/poppler/poppler-0.33.0/goo/PNGWriter.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/PNGWriter.cc rename to source/libs/poppler/poppler-0.33.0/goo/PNGWriter.cc diff --git a/source/libs/poppler/poppler-0.32.0/goo/PNGWriter.h b/source/libs/poppler/poppler-0.33.0/goo/PNGWriter.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/PNGWriter.h rename to source/libs/poppler/poppler-0.33.0/goo/PNGWriter.h diff --git a/source/libs/poppler/poppler-0.32.0/goo/TiffWriter.cc b/source/libs/poppler/poppler-0.33.0/goo/TiffWriter.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/TiffWriter.cc rename to source/libs/poppler/poppler-0.33.0/goo/TiffWriter.cc diff --git a/source/libs/poppler/poppler-0.32.0/goo/TiffWriter.h b/source/libs/poppler/poppler-0.33.0/goo/TiffWriter.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/TiffWriter.h rename to source/libs/poppler/poppler-0.33.0/goo/TiffWriter.h diff --git a/source/libs/poppler/poppler-0.32.0/goo/gfile.cc b/source/libs/poppler/poppler-0.33.0/goo/gfile.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/gfile.cc rename to source/libs/poppler/poppler-0.33.0/goo/gfile.cc diff --git a/source/libs/poppler/poppler-0.32.0/goo/gfile.h b/source/libs/poppler/poppler-0.33.0/goo/gfile.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/gfile.h rename to source/libs/poppler/poppler-0.33.0/goo/gfile.h diff --git a/source/libs/poppler/poppler-0.32.0/goo/gmem.cc b/source/libs/poppler/poppler-0.33.0/goo/gmem.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/gmem.cc rename to source/libs/poppler/poppler-0.33.0/goo/gmem.cc diff --git a/source/libs/poppler/poppler-0.32.0/goo/gmem.h b/source/libs/poppler/poppler-0.33.0/goo/gmem.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/gmem.h rename to source/libs/poppler/poppler-0.33.0/goo/gmem.h diff --git a/source/libs/poppler/poppler-0.32.0/goo/gmempp.cc b/source/libs/poppler/poppler-0.33.0/goo/gmempp.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/gmempp.cc rename to source/libs/poppler/poppler-0.33.0/goo/gmempp.cc diff --git a/source/libs/poppler/poppler-0.32.0/goo/grandom.cc b/source/libs/poppler/poppler-0.33.0/goo/grandom.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/grandom.cc rename to source/libs/poppler/poppler-0.33.0/goo/grandom.cc diff --git a/source/libs/poppler/poppler-0.32.0/goo/grandom.h b/source/libs/poppler/poppler-0.33.0/goo/grandom.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/grandom.h rename to source/libs/poppler/poppler-0.33.0/goo/grandom.h diff --git a/source/libs/poppler/poppler-0.32.0/goo/gstrtod.cc b/source/libs/poppler/poppler-0.33.0/goo/gstrtod.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/gstrtod.cc rename to source/libs/poppler/poppler-0.33.0/goo/gstrtod.cc diff --git a/source/libs/poppler/poppler-0.32.0/goo/gstrtod.h b/source/libs/poppler/poppler-0.33.0/goo/gstrtod.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/gstrtod.h rename to source/libs/poppler/poppler-0.33.0/goo/gstrtod.h diff --git a/source/libs/poppler/poppler-0.32.0/goo/gtypes.h b/source/libs/poppler/poppler-0.33.0/goo/gtypes.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/gtypes.h rename to source/libs/poppler/poppler-0.33.0/goo/gtypes.h diff --git a/source/libs/poppler/poppler-0.32.0/goo/gtypes_p.h b/source/libs/poppler/poppler-0.33.0/goo/gtypes_p.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/goo/gtypes_p.h rename to source/libs/poppler/poppler-0.33.0/goo/gtypes_p.h diff --git a/source/libs/poppler/poppler-0.32.0/gtk-doc.make b/source/libs/poppler/poppler-0.33.0/gtk-doc.make old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/gtk-doc.make rename to source/libs/poppler/poppler-0.33.0/gtk-doc.make diff --git a/source/libs/poppler/poppler-0.32.0/poppler-cairo-uninstalled.pc.in b/source/libs/poppler/poppler-0.33.0/poppler-cairo-uninstalled.pc.in old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler-cairo-uninstalled.pc.in rename to source/libs/poppler/poppler-0.33.0/poppler-cairo-uninstalled.pc.in diff --git a/source/libs/poppler/poppler-0.32.0/poppler-cairo.pc.cmake b/source/libs/poppler/poppler-0.33.0/poppler-cairo.pc.cmake old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler-cairo.pc.cmake rename to source/libs/poppler/poppler-0.33.0/poppler-cairo.pc.cmake diff --git a/source/libs/poppler/poppler-0.32.0/poppler-cairo.pc.in b/source/libs/poppler/poppler-0.33.0/poppler-cairo.pc.in old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler-cairo.pc.in rename to source/libs/poppler/poppler-0.33.0/poppler-cairo.pc.in diff --git a/source/libs/poppler/poppler-0.32.0/poppler-cpp-uninstalled.pc.in b/source/libs/poppler/poppler-0.33.0/poppler-cpp-uninstalled.pc.in old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler-cpp-uninstalled.pc.in rename to source/libs/poppler/poppler-0.33.0/poppler-cpp-uninstalled.pc.in diff --git a/source/libs/poppler/poppler-0.32.0/poppler-cpp.pc.cmake b/source/libs/poppler/poppler-0.33.0/poppler-cpp.pc.cmake old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler-cpp.pc.cmake rename to source/libs/poppler/poppler-0.33.0/poppler-cpp.pc.cmake diff --git a/source/libs/poppler/poppler-0.32.0/poppler-cpp.pc.in b/source/libs/poppler/poppler-0.33.0/poppler-cpp.pc.in old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler-cpp.pc.in rename to source/libs/poppler/poppler-0.33.0/poppler-cpp.pc.in diff --git a/source/libs/poppler/poppler-0.32.0/poppler-glib-uninstalled.pc.in b/source/libs/poppler/poppler-0.33.0/poppler-glib-uninstalled.pc.in old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler-glib-uninstalled.pc.in rename to source/libs/poppler/poppler-0.33.0/poppler-glib-uninstalled.pc.in diff --git a/source/libs/poppler/poppler-0.32.0/poppler-glib.pc.cmake b/source/libs/poppler/poppler-0.33.0/poppler-glib.pc.cmake old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler-glib.pc.cmake rename to source/libs/poppler/poppler-0.33.0/poppler-glib.pc.cmake diff --git a/source/libs/poppler/poppler-0.32.0/poppler-glib.pc.in b/source/libs/poppler/poppler-0.33.0/poppler-glib.pc.in old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler-glib.pc.in rename to source/libs/poppler/poppler-0.33.0/poppler-glib.pc.in diff --git a/source/libs/poppler/poppler-0.32.0/poppler-qt4-uninstalled.pc.in b/source/libs/poppler/poppler-0.33.0/poppler-qt4-uninstalled.pc.in old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler-qt4-uninstalled.pc.in rename to source/libs/poppler/poppler-0.33.0/poppler-qt4-uninstalled.pc.in diff --git a/source/libs/poppler/poppler-0.32.0/poppler-qt4.pc.cmake b/source/libs/poppler/poppler-0.33.0/poppler-qt4.pc.cmake old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler-qt4.pc.cmake rename to source/libs/poppler/poppler-0.33.0/poppler-qt4.pc.cmake diff --git a/source/libs/poppler/poppler-0.32.0/poppler-qt4.pc.in b/source/libs/poppler/poppler-0.33.0/poppler-qt4.pc.in old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler-qt4.pc.in rename to source/libs/poppler/poppler-0.33.0/poppler-qt4.pc.in diff --git a/source/libs/poppler/poppler-0.32.0/poppler-qt5-uninstalled.pc.in b/source/libs/poppler/poppler-0.33.0/poppler-qt5-uninstalled.pc.in old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler-qt5-uninstalled.pc.in rename to source/libs/poppler/poppler-0.33.0/poppler-qt5-uninstalled.pc.in diff --git a/source/libs/poppler/poppler-0.32.0/poppler-qt5.pc.cmake b/source/libs/poppler/poppler-0.33.0/poppler-qt5.pc.cmake old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler-qt5.pc.cmake rename to source/libs/poppler/poppler-0.33.0/poppler-qt5.pc.cmake diff --git a/source/libs/poppler/poppler-0.32.0/poppler-qt5.pc.in b/source/libs/poppler/poppler-0.33.0/poppler-qt5.pc.in old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler-qt5.pc.in rename to source/libs/poppler/poppler-0.33.0/poppler-qt5.pc.in diff --git a/source/libs/poppler/poppler-0.32.0/poppler-splash-uninstalled.pc.in b/source/libs/poppler/poppler-0.33.0/poppler-splash-uninstalled.pc.in old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler-splash-uninstalled.pc.in rename to source/libs/poppler/poppler-0.33.0/poppler-splash-uninstalled.pc.in diff --git a/source/libs/poppler/poppler-0.32.0/poppler-splash.pc.cmake b/source/libs/poppler/poppler-0.33.0/poppler-splash.pc.cmake old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler-splash.pc.cmake rename to source/libs/poppler/poppler-0.33.0/poppler-splash.pc.cmake diff --git a/source/libs/poppler/poppler-0.32.0/poppler-splash.pc.in b/source/libs/poppler/poppler-0.33.0/poppler-splash.pc.in old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler-splash.pc.in rename to source/libs/poppler/poppler-0.33.0/poppler-splash.pc.in diff --git a/source/libs/poppler/poppler-0.32.0/poppler-uninstalled.pc.in b/source/libs/poppler/poppler-0.33.0/poppler-uninstalled.pc.in old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler-uninstalled.pc.in rename to source/libs/poppler/poppler-0.33.0/poppler-uninstalled.pc.in diff --git a/source/libs/poppler/poppler-0.32.0/poppler.pc.cmake b/source/libs/poppler/poppler-0.33.0/poppler.pc.cmake old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler.pc.cmake rename to source/libs/poppler/poppler-0.33.0/poppler.pc.cmake diff --git a/source/libs/poppler/poppler-0.32.0/poppler.pc.in b/source/libs/poppler/poppler-0.33.0/poppler.pc.in old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler.pc.in rename to source/libs/poppler/poppler-0.33.0/poppler.pc.in diff --git a/source/libs/poppler/poppler-0.33.0/poppler/Annot.cc b/source/libs/poppler/poppler-0.33.0/poppler/Annot.cc new file mode 100644 index 000000000..dd99eee8a --- /dev/null +++ b/source/libs/poppler/poppler-0.33.0/poppler/Annot.cc @@ -0,0 +1,6870 @@ +//======================================================================== +// +// Annot.cc +// +// Copyright 2000-2003 Glyph & Cog, LLC +// +//======================================================================== + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2006 Scott Turner <scotty1024@mac.com> +// Copyright (C) 2007, 2008 Julien Rebetez <julienr@svn.gnome.org> +// Copyright (C) 2007-2013 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2007-2013 Carlos Garcia Campos <carlosgc@gnome.org> +// Copyright (C) 2007, 2008 Iñigo Martínez <inigomartinez@gmail.com> +// Copyright (C) 2007 Jeff Muizelaar <jeff@infidigm.net> +// Copyright (C) 2008, 2011 Pino Toscano <pino@kde.org> +// Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu> +// Copyright (C) 2008 Hugo Mercier <hmercier31@gmail.com> +// Copyright (C) 2009 Ilya Gorenbein <igorenbein@finjan.com> +// Copyright (C) 2011, 2013 José Aliste <jaliste@src.gnome.org> +// Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it> +// Copyright (C) 2012, 2013 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2012 Tobias Koenig <tokoe@kdab.com> +// Copyright (C) 2013 Peter Breitenlohner <peb@mppmu.mpg.de> +// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2014 Marek Kasik <mkasik@redhat.com> +// Copyright (C) 2014 Jiri Slaby <jirislaby@gmail.com> +// Copyright (C) 2014 Anuj Khare <khareanuj18@gmail.com> +// Copyright (C) 2015 Petr Gajdos <pgajdos@suse.cz> +// Copyright (C) 2015 Philipp Reinkemeier <philipp.reinkemeier@offis.de> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#include <config.h> + +#ifdef USE_GCC_PRAGMAS +#pragma implementation +#endif + +#include <stdlib.h> +#include <math.h> +#include <assert.h> +#include "goo/gmem.h" +#include "goo/gstrtod.h" +#include "GooList.h" +#include "Error.h" +#include "Object.h" +#include "Catalog.h" +#include "Gfx.h" +#include "Lexer.h" +#include "PDFDoc.h" +#include "Page.h" +#include "Annot.h" +#include "GfxFont.h" +#include "CharCodeToUnicode.h" +#include "PDFDocEncoding.h" +#include "Form.h" +#include "Error.h" +#include "XRef.h" +#include "Movie.h" +#include "OptionalContent.h" +#include "Sound.h" +#include "FileSpec.h" +#include "DateInfo.h" +#include "Link.h" +#include <string.h> + +#if MULTITHREADED +# define annotLocker() MutexLocker locker(&mutex) +# define annotCondLocker(X) MutexLocker locker(&mutex, (X)) +#else +# define annotLocker() +# define annotCondLocker(X) +#endif + +#define fieldFlagReadOnly 0x00000001 +#define fieldFlagRequired 0x00000002 +#define fieldFlagNoExport 0x00000004 +#define fieldFlagMultiline 0x00001000 +#define fieldFlagPassword 0x00002000 +#define fieldFlagNoToggleToOff 0x00004000 +#define fieldFlagRadio 0x00008000 +#define fieldFlagPushbutton 0x00010000 +#define fieldFlagCombo 0x00020000 +#define fieldFlagEdit 0x00040000 +#define fieldFlagSort 0x00080000 +#define fieldFlagFileSelect 0x00100000 +#define fieldFlagMultiSelect 0x00200000 +#define fieldFlagDoNotSpellCheck 0x00400000 +#define fieldFlagDoNotScroll 0x00800000 +#define fieldFlagComb 0x01000000 +#define fieldFlagRichText 0x02000000 +#define fieldFlagRadiosInUnison 0x02000000 +#define fieldFlagCommitOnSelChange 0x04000000 + +#define fieldQuadLeft 0 +#define fieldQuadCenter 1 +#define fieldQuadRight 2 + +// distance of Bezier control point from center for circle approximation +// = (4 * (sqrt(2) - 1) / 3) * r +#define bezierCircle 0.55228475 + +AnnotLineEndingStyle parseAnnotLineEndingStyle(GooString *string) { + if (string != NULL) { + if (!string->cmp("Square")) { + return annotLineEndingSquare; + } else if (!string->cmp("Circle")) { + return annotLineEndingCircle; + } else if (!string->cmp("Diamond")) { + return annotLineEndingDiamond; + } else if (!string->cmp("OpenArrow")) { + return annotLineEndingOpenArrow; + } else if (!string->cmp("ClosedArrow")) { + return annotLineEndingClosedArrow; + } else if (!string->cmp("Butt")) { + return annotLineEndingButt; + } else if (!string->cmp("ROpenArrow")) { + return annotLineEndingROpenArrow; + } else if (!string->cmp("RClosedArrow")) { + return annotLineEndingRClosedArrow; + } else if (!string->cmp("Slash")) { + return annotLineEndingSlash; + } else { + return annotLineEndingNone; + } + } else { + return annotLineEndingNone; + } +} + +const char* convertAnnotLineEndingStyle(AnnotLineEndingStyle style) { + switch (style) { + case annotLineEndingSquare: + return "Square"; + case annotLineEndingCircle: + return "Circle"; + case annotLineEndingDiamond: + return "Diamond"; + case annotLineEndingOpenArrow: + return "OpenArrow"; + case annotLineEndingClosedArrow: + return "ClosedArrow"; + case annotLineEndingButt: + return "Butt"; + case annotLineEndingROpenArrow: + return "ROpenArrow"; + case annotLineEndingRClosedArrow: + return "RClosedArrow"; + case annotLineEndingSlash: + return "Slash"; + default: + return "None"; + } +} + +static AnnotExternalDataType parseAnnotExternalData(Dict* dict) { + Object obj1; + AnnotExternalDataType type; + + if (dict->lookup("Subtype", &obj1)->isName()) { + const char *typeName = obj1.getName(); + + if (!strcmp(typeName, "Markup3D")) { + type = annotExternalDataMarkup3D; + } else { + type = annotExternalDataMarkupUnknown; + } + } else { + type = annotExternalDataMarkupUnknown; + } + obj1.free(); + + return type; +} + +PDFRectangle *parseDiffRectangle(Array *array, PDFRectangle *rect) { + PDFRectangle *newRect = NULL; + if (array->getLength() == 4) { + // deltas + Object obj1; + double dx1 = (array->get(0, &obj1)->isNum() ? obj1.getNum() : 0); + obj1.free(); + double dy1 = (array->get(1, &obj1)->isNum() ? obj1.getNum() : 0); + obj1.free(); + double dx2 = (array->get(2, &obj1)->isNum() ? obj1.getNum() : 0); + obj1.free(); + double dy2 = (array->get(3, &obj1)->isNum() ? obj1.getNum() : 0); + obj1.free(); + + // checking that the numbers are valid (i.e. >= 0), + // and that applying the differences still give us a valid rect + if (dx1 >= 0 && dy1 >= 0 && dx2 >= 0 && dy2 + && (rect->x2 - rect->x1 - dx1 - dx2) >= 0 + && (rect->y2 - rect->y1 - dy1 - dy2) >= 0) { + newRect = new PDFRectangle(); + newRect->x1 = rect->x1 + dx1; + newRect->y1 = rect->y1 + dy1; + newRect->x2 = rect->x2 - dx2; + newRect->y2 = rect->y2 - dy2; + } + } + return newRect; +} + +static LinkAction* getAdditionalAction(Annot::AdditionalActionsType type, Object *additionalActions, PDFDoc *doc) { + Object additionalActionsObject; + LinkAction *linkAction = NULL; + + if (additionalActions->fetch(doc->getXRef(), &additionalActionsObject)->isDict()) { + const char *key = (type == Annot::actionCursorEntering ? "E" : + type == Annot::actionCursorLeaving ? "X" : + type == Annot::actionMousePressed ? "D" : + type == Annot::actionMouseReleased ? "U" : + type == Annot::actionFocusIn ? "Fo" : + type == Annot::actionFocusOut ? "BI" : + type == Annot::actionPageOpening ? "PO" : + type == Annot::actionPageClosing ? "PC" : + type == Annot::actionPageVisible ? "PV" : + type == Annot::actionPageInvisible ? "PI" : NULL); + + Object actionObject; + + if (additionalActionsObject.dictLookup(key, &actionObject)->isDict()) + linkAction = LinkAction::parseAction(&actionObject, doc->getCatalog()->getBaseURI()); + actionObject.free(); + } + + additionalActionsObject.free(); + + return linkAction; +} + +static LinkAction* getFormAdditionalAction(Annot::FormAdditionalActionsType type, Object *additionalActions, PDFDoc *doc) { + Object additionalActionsObject; + LinkAction *linkAction = NULL; + + if (additionalActions->fetch(doc->getXRef(), &additionalActionsObject)->isDict()) { + const char *key = (type == Annot::actionFieldModified ? "K" : + type == Annot::actionFormatField ? "F" : + type == Annot::actionValidateField ? "V" : + type == Annot::actionCalculateField ? "C" : NULL); + + Object actionObject; + + if (additionalActionsObject.dictLookup(key, &actionObject)->isDict()) + linkAction = LinkAction::parseAction(&actionObject, doc->getCatalog()->getBaseURI()); + actionObject.free(); + } + + additionalActionsObject.free(); + + return linkAction; +} + +//------------------------------------------------------------------------ +// AnnotBorderEffect +//------------------------------------------------------------------------ + +AnnotBorderEffect::AnnotBorderEffect(Dict *dict) { + Object obj1; + + if (dict->lookup("S", &obj1)->isName()) { + const char *effectName = obj1.getName(); + + if (!strcmp(effectName, "C")) + effectType = borderEffectCloudy; + else + effectType = borderEffectNoEffect; + } else { + effectType = borderEffectNoEffect; + } + obj1.free(); + + if ((dict->lookup("I", &obj1)->isNum()) && effectType == borderEffectCloudy) { + intensity = obj1.getNum(); + } else { + intensity = 0; + } + obj1.free(); +} + +//------------------------------------------------------------------------ +// AnnotPath +//------------------------------------------------------------------------ + +AnnotPath::AnnotPath() { + coords = NULL; + coordsLength = 0; +} + +AnnotPath::AnnotPath(Array *array) { + coords = NULL; + coordsLength = 0; + parsePathArray(array); +} + +AnnotPath::AnnotPath(AnnotCoord **coords, int coordsLength) { + this->coords = coords; + this->coordsLength = coordsLength; +} + +AnnotPath::~AnnotPath() { + if (coords) { + for (int i = 0; i < coordsLength; ++i) + delete coords[i]; + gfree(coords); + } +} + +double AnnotPath::getX(int coord) const { + if (coord >= 0 && coord < coordsLength) + return coords[coord]->getX(); + return 0; +} + +double AnnotPath::getY(int coord) const { + if (coord >= 0 && coord < coordsLength) + return coords[coord]->getY(); + return 0; +} + +AnnotCoord *AnnotPath::getCoord(int coord) const { + if (coord >= 0 && coord < coordsLength) + return coords[coord]; + return NULL; +} + +void AnnotPath::parsePathArray(Array *array) { + int tempLength; + AnnotCoord **tempCoords; + GBool correct = gTrue; + + if (array->getLength() % 2) { + error(errSyntaxError, -1, "Bad Annot Path"); + return; + } + + tempLength = array->getLength() / 2; + tempCoords = (AnnotCoord **) gmallocn (tempLength, sizeof(AnnotCoord *)); + memset(tempCoords, 0, tempLength * sizeof(AnnotCoord *)); + for (int i = 0; i < tempLength && correct; i++) { + Object obj1; + double x = 0, y = 0; + + if (array->get(i * 2, &obj1)->isNum()) { + x = obj1.getNum(); + } else { + correct = gFalse; + } + obj1.free(); + + if (array->get((i * 2) + 1, &obj1)->isNum()) { + y = obj1.getNum(); + } else { + correct = gFalse; + } + obj1.free(); + + if (!correct) { + for (int j = i - 1; j >= 0; j--) + delete tempCoords[j]; + gfree (tempCoords); + return; + } + + tempCoords[i] = new AnnotCoord(x, y); + } + + coords = tempCoords; + coordsLength = tempLength; +} + +//------------------------------------------------------------------------ +// AnnotCalloutLine +//------------------------------------------------------------------------ + +AnnotCalloutLine::AnnotCalloutLine(double x1, double y1, double x2, double y2) + : coord1(x1, y1), coord2(x2, y2) { +} + +//------------------------------------------------------------------------ +// AnnotCalloutMultiLine +//------------------------------------------------------------------------ + +AnnotCalloutMultiLine::AnnotCalloutMultiLine(double x1, double y1, double x2, + double y2, double x3, double y3) + : AnnotCalloutLine(x1, y1, x2, y2), coord3(x3, y3) { +} + +//------------------------------------------------------------------------ +// AnnotQuadrilateral +//------------------------------------------------------------------------ + +AnnotQuadrilaterals::AnnotQuadrilaterals(Array *array, PDFRectangle *rect) { + int arrayLength = array->getLength(); + GBool correct = gTrue; + int quadsLength = 0; + AnnotQuadrilateral **quads; + double quadArray[8]; + + // default values + quadrilaterals = NULL; + quadrilateralsLength = 0; + + if ((arrayLength % 8) == 0) { + int i; + + quadsLength = arrayLength / 8; + quads = (AnnotQuadrilateral **) gmallocn + ((quadsLength), sizeof(AnnotQuadrilateral *)); + memset(quads, 0, quadsLength * sizeof(AnnotQuadrilateral *)); + + for (i = 0; i < quadsLength; i++) { + for (int j = 0; j < 8; j++) { + Object obj; + if (array->get(i * 8 + j, &obj)->isNum()) { + quadArray[j] = obj.getNum(); + } else { + correct = gFalse; + obj.free(); + error (errSyntaxError, -1, "Invalid QuadPoint in annot"); + break; + } + obj.free(); + } + + if (!correct) + break; + + quads[i] = new AnnotQuadrilateral(quadArray[0], quadArray[1], + quadArray[2], quadArray[3], + quadArray[4], quadArray[5], + quadArray[6], quadArray[7]); + } + + if (correct) { + quadrilateralsLength = quadsLength; + quadrilaterals = quads; + } else { + for (int j = 0; j < i; j++) + delete quads[j]; + gfree (quads); + } + } +} + +AnnotQuadrilaterals::AnnotQuadrilaterals(AnnotQuadrilaterals::AnnotQuadrilateral **quads, int quadsLength) { + quadrilaterals = quads; + quadrilateralsLength = quadsLength; +} + +AnnotQuadrilaterals::~AnnotQuadrilaterals() { + if (quadrilaterals) { + for(int i = 0; i < quadrilateralsLength; i++) + delete quadrilaterals[i]; + + gfree (quadrilaterals); + } +} + +double AnnotQuadrilaterals::getX1(int quadrilateral) { + if (quadrilateral >= 0 && quadrilateral < quadrilateralsLength) + return quadrilaterals[quadrilateral]->coord1.getX(); + return 0; +} + +double AnnotQuadrilaterals::getY1(int quadrilateral) { + if (quadrilateral >= 0 && quadrilateral < quadrilateralsLength) + return quadrilaterals[quadrilateral]->coord1.getY(); + return 0; +} + +double AnnotQuadrilaterals::getX2(int quadrilateral) { + if (quadrilateral >= 0 && quadrilateral < quadrilateralsLength) + return quadrilaterals[quadrilateral]->coord2.getX(); + return 0; +} + +double AnnotQuadrilaterals::getY2(int quadrilateral) { + if (quadrilateral >= 0 && quadrilateral < quadrilateralsLength) + return quadrilaterals[quadrilateral]->coord2.getY(); + return 0; +} + +double AnnotQuadrilaterals::getX3(int quadrilateral) { + if (quadrilateral >= 0 && quadrilateral < quadrilateralsLength) + return quadrilaterals[quadrilateral]->coord3.getX(); + return 0; +} + +double AnnotQuadrilaterals::getY3(int quadrilateral) { + if (quadrilateral >= 0 && quadrilateral < quadrilateralsLength) + return quadrilaterals[quadrilateral]->coord3.getY(); + return 0; +} + +double AnnotQuadrilaterals::getX4(int quadrilateral) { + if (quadrilateral >= 0 && quadrilateral < quadrilateralsLength) + return quadrilaterals[quadrilateral]->coord4.getX(); + return 0; +} + +double AnnotQuadrilaterals::getY4(int quadrilateral) { + if (quadrilateral >= 0 && quadrilateral < quadrilateralsLength) + return quadrilaterals[quadrilateral]->coord4.getY(); + return 0; +} + +AnnotQuadrilaterals::AnnotQuadrilateral::AnnotQuadrilateral(double x1, double y1, + double x2, double y2, double x3, double y3, double x4, double y4) + : coord1(x1, y1), coord2(x2, y2), coord3(x3, y3), coord4(x4, y4) { +} + +//------------------------------------------------------------------------ +// AnnotBorder +//------------------------------------------------------------------------ +AnnotBorder::AnnotBorder() { + width = 1; + dashLength = 0; + dash = NULL; + style = borderSolid; +} + +GBool AnnotBorder::parseDashArray(Object *dashObj) { + GBool correct = gTrue; + int tempLength = dashObj->arrayGetLength(); + double *tempDash = (double *) gmallocn (tempLength, sizeof (double)); + + // TODO: check not all zero (Line Dash Pattern Page 217 PDF 8.1) + for (int i = 0; i < tempLength && i < DASH_LIMIT && correct; i++) { + Object obj1; + + if (dashObj->arrayGet(i, &obj1)->isNum()) { + tempDash[i] = obj1.getNum(); + + correct = tempDash[i] >= 0; + obj1.free(); + } + } + + if (correct) { + dashLength = tempLength; + dash = tempDash; + style = borderDashed; + } else { + gfree (tempDash); + } + + return correct; +} + +AnnotBorder::~AnnotBorder() { + if (dash) + gfree (dash); +} + +//------------------------------------------------------------------------ +// AnnotBorderArray +//------------------------------------------------------------------------ + +AnnotBorderArray::AnnotBorderArray() { + horizontalCorner = 0; + verticalCorner = 0; +} + +AnnotBorderArray::AnnotBorderArray(Array *array) { + Object obj1; + int arrayLength = array->getLength(); + + GBool correct = gTrue; + if (arrayLength == 3 || arrayLength == 4) { + // implementation note 81 in Appendix H. + + if (array->get(0, &obj1)->isNum()) + horizontalCorner = obj1.getNum(); + else + correct = gFalse; + obj1.free(); + + if (array->get(1, &obj1)->isNum()) + verticalCorner = obj1.getNum(); + else + correct = gFalse; + obj1.free(); + + if (array->get(2, &obj1)->isNum()) + width = obj1.getNum(); + else + correct = gFalse; + obj1.free(); + + if (arrayLength == 4) { + if (array->get(3, &obj1)->isArray()) + correct = parseDashArray(&obj1); + else + correct = gFalse; + obj1.free(); + } + } else { + correct = gFalse; + } + + if (!correct) { + width = 0; + } +} + +void AnnotBorderArray::writeToObject(XRef *xref, Object *obj1) const { + Object obj2; + + obj1->initArray(xref); + obj1->arrayAdd(obj2.initReal(horizontalCorner)); + obj1->arrayAdd(obj2.initReal(verticalCorner)); + obj1->arrayAdd(obj2.initReal(width)); + + if (dashLength > 0) { + Object obj3; + + obj1->arrayAdd(obj3.initArray(xref)); + for (int i = 0; i < dashLength; i++) + obj3.arrayAdd(obj2.initReal(dash[i])); + } +} + +//------------------------------------------------------------------------ +// AnnotBorderBS +//------------------------------------------------------------------------ + +AnnotBorderBS::AnnotBorderBS() { +} + +AnnotBorderBS::AnnotBorderBS(Dict *dict) { + Object obj1, obj2; + + // acroread 8 seems to need both W and S entries for + // any border to be drawn, even though the spec + // doesn't claim anything of that sort. We follow + // that behaviour by veryifying both entries exist + // otherwise we set the borderWidth to 0 + // --jrmuizel + dict->lookup("W", &obj1); + dict->lookup("S", &obj2); + if (obj1.isNum() && obj2.isName()) { + const char *styleName = obj2.getName(); + + width = obj1.getNum(); + + if (!strcmp(styleName, "S")) { + style = borderSolid; + } else if (!strcmp(styleName, "D")) { + style = borderDashed; + } else if (!strcmp(styleName, "B")) { + style = borderBeveled; + } else if (!strcmp(styleName, "I")) { + style = borderInset; + } else if (!strcmp(styleName, "U")) { + style = borderUnderlined; + } else { + style = borderSolid; + } + } else { + width = 0; + } + obj2.free(); + obj1.free(); + + if (style == borderDashed) { + if (dict->lookup("D", &obj1)->isArray()) + parseDashArray(&obj1); + obj1.free(); + + if (!dash) { + dashLength = 1; + dash = (double *) gmallocn (dashLength, sizeof (double)); + dash[0] = 3; + } + } +} + +const char *AnnotBorderBS::getStyleName() const { + switch (style) { + case borderSolid: + return "S"; + case borderDashed: + return "D"; + case borderBeveled: + return "B"; + case borderInset: + return "I"; + case borderUnderlined: + return "U"; + } + + return "S"; +} + +void AnnotBorderBS::writeToObject(XRef *xref, Object *obj1) const { + Object obj2; + + obj1->initDict(xref); + obj1->dictSet("W", obj2.initReal(width)); + obj1->dictSet("S", obj2.initName(getStyleName())); + if (style == borderDashed && dashLength > 0) { + Object obj3; + + obj1->dictSet("D", obj3.initArray(xref)); + for (int i = 0; i < dashLength; i++) + obj3.arrayAdd(obj2.initReal(dash[i])); + } +} + +//------------------------------------------------------------------------ +// AnnotColor +//------------------------------------------------------------------------ + +AnnotColor::AnnotColor() { + length = 0; +} + +AnnotColor::AnnotColor(double gray) { + length = 1; + + values[0] = gray; +} + +AnnotColor::AnnotColor(double r, double g, double b) { + length = 3; + + values[0] = r; + values[1] = g; + values[2] = b; +} + +AnnotColor::AnnotColor(double c, double m, double y, double k) { + length = 4; + + values[0] = c; + values[1] = m; + values[2] = y; + values[3] = k; +} + +// If <adjust> is +1, color is brightened; +// if <adjust> is -1, color is darkened; +// otherwise color is not modified. +AnnotColor::AnnotColor(Array *array, int adjust) { + int i; + + length = array->getLength(); + if (length > 4) + length = 4; + + for (i = 0; i < length; i++) { + Object obj1; + + if (array->get(i, &obj1)->isNum()) { + values[i] = obj1.getNum(); + + if (values[i] < 0 || values[i] > 1) + values[i] = 0; + } else { + values[i] = 0; + } + obj1.free(); + } + + if (adjust != 0) + adjustColor(adjust); +} + +void AnnotColor::adjustColor(int adjust) { + int i; + + if (length == 4) { + adjust = -adjust; + } + if (adjust > 0) { + for (i = 0; i < length; ++i) { + values[i] = 0.5 * values[i] + 0.5; + } + } else if (adjust < 0) { + for (i = 0; i < length; ++i) { + values[i] = 0.5 * values[i]; + } + } +} + +void AnnotColor::writeToObject(XRef *xref, Object *obj1) const { + Object obj2; + int i; + + if (length == 0) { + obj1->initNull(); // Transparent (no color) + } else { + obj1->initArray(xref); + for (i = 0; i < length; ++i) + obj1->arrayAdd( obj2.initReal( values[i] ) ); + } +} + +//------------------------------------------------------------------------ +// AnnotIconFit +//------------------------------------------------------------------------ + +AnnotIconFit::AnnotIconFit(Dict* dict) { + Object obj1; + + if (dict->lookup("SW", &obj1)->isName()) { + const char *scaleName = obj1.getName(); + + if(!strcmp(scaleName, "B")) { + scaleWhen = scaleBigger; + } else if(!strcmp(scaleName, "S")) { + scaleWhen = scaleSmaller; + } else if(!strcmp(scaleName, "N")) { + scaleWhen = scaleNever; + } else { + scaleWhen = scaleAlways; + } + } else { + scaleWhen = scaleAlways; + } + obj1.free(); + + if (dict->lookup("S", &obj1)->isName()) { + const char *scaleName = obj1.getName(); + + if(!strcmp(scaleName, "A")) { + scale = scaleAnamorphic; + } else { + scale = scaleProportional; + } + } else { + scale = scaleProportional; + } + obj1.free(); + + if (dict->lookup("A", &obj1)->isArray() && obj1.arrayGetLength() == 2) { + Object obj2; + (obj1.arrayGet(0, &obj2)->isNum() ? left = obj2.getNum() : left = 0); + obj2.free(); + (obj1.arrayGet(1, &obj2)->isNum() ? bottom = obj2.getNum() : bottom = 0); + obj2.free(); + + if (left < 0 || left > 1) + left = 0.5; + + if (bottom < 0 || bottom > 1) + bottom = 0.5; + + } else { + left = bottom = 0.5; + } + obj1.free(); + + if (dict->lookup("FB", &obj1)->isBool()) { + fullyBounds = obj1.getBool(); + } else { + fullyBounds = gFalse; + } + obj1.free(); +} + +//------------------------------------------------------------------------ +// AnnotAppearance +//------------------------------------------------------------------------ + +AnnotAppearance::AnnotAppearance(PDFDoc *docA, Object *dict) { + assert(dict->isDict()); + doc = docA; + xref = docA->getXRef(); + dict->copy(&appearDict); +} + +AnnotAppearance::~AnnotAppearance() { + appearDict.free(); +} + +void AnnotAppearance::getAppearanceStream(AnnotAppearanceType type, const char *state, Object *dest) { + Object apData, stream; + apData.initNull(); + + // Obtain dictionary or stream associated to appearance type + switch (type) { + case appearRollover: + if (appearDict.dictLookupNF("R", &apData)->isNull()) + appearDict.dictLookupNF("N", &apData); + break; + case appearDown: + if (appearDict.dictLookupNF("D", &apData)->isNull()) + appearDict.dictLookupNF("N", &apData); + break; + case appearNormal: + appearDict.dictLookupNF("N", &apData); + break; + } + + dest->initNull(); + if (apData.isDict() && state) + apData.dictLookupNF(state, dest); + else if (apData.isRef()) + apData.copy(dest); + apData.free(); +} + +GooString * AnnotAppearance::getStateKey(int i) { + Object obj1; + GooString * res = NULL; + if (appearDict.dictLookupNF("N", &obj1)->isDict()) + res = new GooString(obj1.dictGetKey(i)); + obj1.free(); + return res; +} + +int AnnotAppearance::getNumStates() { + Object obj1; + int res = 0; + if (appearDict.dictLookupNF("N", &obj1)->isDict()) + res = obj1.dictGetLength(); + obj1.free(); + return res; +} + +// Test if stateObj (a Ref or a Dict) points to the specified stream +GBool AnnotAppearance::referencesStream(Object *stateObj, Ref refToStream) { + if (stateObj->isRef()) { + Ref r = stateObj->getRef(); + if (r.num == refToStream.num && r.gen == refToStream.gen) { + return gTrue; + } + } else if (stateObj->isDict()) { // Test each value + const int size = stateObj->dictGetLength(); + for (int i = 0; i < size; ++i) { + Object obj1; + stateObj->dictGetValNF(i, &obj1); + if (obj1.isRef()) { + Ref r = obj1.getRef(); + if (r.num == refToStream.num && r.gen == refToStream.gen) { + return gTrue; + } + } + obj1.free(); + } + } + return gFalse; // Not found +} + +// Test if this AnnotAppearance references the specified stream +GBool AnnotAppearance::referencesStream(Ref refToStream) { + Object obj1; + GBool found; + + // Scan each state's ref/subdictionary + appearDict.dictLookupNF("N", &obj1); + found = referencesStream(&obj1, refToStream); + obj1.free(); + if (found) + return gTrue; + + appearDict.dictLookupNF("R", &obj1); + found = referencesStream(&obj1, refToStream); + obj1.free(); + if (found) + return gTrue; + + appearDict.dictLookupNF("D", &obj1); + found = referencesStream(&obj1, refToStream); + obj1.free(); + return found; +} + +// If this is the only annotation in the document that references the +// specified appearance stream, remove the appearance stream +void AnnotAppearance::removeStream(Ref refToStream) { + const int lastpage = doc->getNumPages(); + for (int pg = 1; pg <= lastpage; ++pg) { // Scan all annotations in the document + Page *page = doc->getPage(pg); + if (!page) { + error(errSyntaxError, -1, "Failed check for shared annotation stream at page {0:d}", pg); + continue; + } + Annots *annots = page->getAnnots(); + for (int i = 0; i < annots->getNumAnnots(); ++i) { + AnnotAppearance *annotAp = annots->getAnnot(i)->getAppearStreams(); + if (annotAp && annotAp != this && annotAp->referencesStream(refToStream)) { + return; // Another annotation points to the stream -> Don't delete it + } + } + } + + // TODO: stream resources (e.g. font), AP name tree + xref->removeIndirectObject(refToStream); +} + +// Removes stream if obj is a Ref, or removes pointed streams if obj is a Dict +void AnnotAppearance::removeStateStreams(Object *obj1) { + if (obj1->isRef()) { + removeStream(obj1->getRef()); + } else if (obj1->isDict()) { + const int size = obj1->dictGetLength(); + for (int i = 0; i < size; ++i) { + Object obj2; + obj1->dictGetValNF(i, &obj2); + if (obj2.isRef()) { + removeStream(obj2.getRef()); + } + obj2.free(); + } + } +} + +void AnnotAppearance::removeAllStreams() { + Object obj1; + appearDict.dictLookupNF("N", &obj1); + removeStateStreams(&obj1); + obj1.free(); + appearDict.dictLookupNF("R", &obj1); + removeStateStreams(&obj1); + obj1.free(); + appearDict.dictLookupNF("D", &obj1); + removeStateStreams(&obj1); + obj1.free(); +} + +//------------------------------------------------------------------------ +// AnnotAppearanceCharacs +//------------------------------------------------------------------------ + +AnnotAppearanceCharacs::AnnotAppearanceCharacs(Dict *dict) { + Object obj1; + + if (dict->lookup("R", &obj1)->isInt()) { + rotation = obj1.getInt(); + } else { + rotation = 0; + } + obj1.free(); + + if (dict->lookup("BC", &obj1)->isArray()) { + Array *colorComponents = obj1.getArray(); + if (colorComponents->getLength() > 0) { + borderColor = new AnnotColor(colorComponents); + } else { + borderColor = NULL; + } + } else { + borderColor = NULL; + } + obj1.free(); + + if (dict->lookup("BG", &obj1)->isArray()) { + Array *colorComponents = obj1.getArray(); + if (colorComponents->getLength() > 0) { + backColor = new AnnotColor(colorComponents); + } else { + backColor = NULL; + } + } else { + backColor = NULL; + } + obj1.free(); + + if (dict->lookup("CA", &obj1)->isString()) { + normalCaption = new GooString(obj1.getString()); + } else { + normalCaption = NULL; + } + obj1.free(); + + if (dict->lookup("RC", &obj1)->isString()) { + rolloverCaption = new GooString(obj1.getString()); + } else { + rolloverCaption = NULL; + } + obj1.free(); + + if (dict->lookup("AC", &obj1)->isString()) { + alternateCaption = new GooString(obj1.getString()); + } else { + alternateCaption = NULL; + } + obj1.free(); + + if (dict->lookup("IF", &obj1)->isDict()) { + iconFit = new AnnotIconFit(obj1.getDict()); + } else { + iconFit = NULL; + } + obj1.free(); + + if (dict->lookup("TP", &obj1)->isInt()) { + position = (AnnotAppearanceCharacsTextPos) obj1.getInt(); + } else { + position = captionNoIcon; + } + obj1.free(); +} + +AnnotAppearanceCharacs::~AnnotAppearanceCharacs() { + if (borderColor) + delete borderColor; + + if (backColor) + delete backColor; + + if (normalCaption) + delete normalCaption; + + if (rolloverCaption) + delete rolloverCaption; + + if (alternateCaption) + delete alternateCaption; + + if (iconFit) + delete iconFit; +} + +//------------------------------------------------------------------------ +// AnnotAppearanceBBox +//------------------------------------------------------------------------ + +AnnotAppearanceBBox::AnnotAppearanceBBox(PDFRectangle *rect) { + origX = rect->x1; + origY = rect->y1; + borderWidth = 0; + + // Initially set the same size as rect + minX = 0; + minY = 0; + maxX = rect->x2 - rect->x1; + maxY = rect->y2 - rect->y1; +} + +void AnnotAppearanceBBox::extendTo(double x, double y) { + if (x < minX) { + minX = x; + } else if (x > maxX) { + maxX = x; + } + if (y < minY) { + minY = y; + } else if (y > maxY) { + maxY = y; + } +} + +void AnnotAppearanceBBox::getBBoxRect(double bbox[4]) const { + bbox[0] = minX - borderWidth; + bbox[1] = minY - borderWidth; + bbox[2] = maxX + borderWidth; + bbox[3] = maxY + borderWidth; +} + +double AnnotAppearanceBBox::getPageXMin() const { + return origX + minX - borderWidth; +} + +double AnnotAppearanceBBox::getPageYMin() const { + return origY + minY - borderWidth; +} + +double AnnotAppearanceBBox::getPageXMax() const { + return origX + maxX + borderWidth; +} + +double AnnotAppearanceBBox::getPageYMax() const { + return origY + maxY + borderWidth; +} + +//------------------------------------------------------------------------ +// Annot +//------------------------------------------------------------------------ + +Annot::Annot(PDFDoc *docA, PDFRectangle *rectA) { + Object obj1; + + refCnt = 1; + flags = flagUnknown; + type = typeUnknown; + + obj1.initArray (docA->getXRef()); + Object obj2; + obj1.arrayAdd (obj2.initReal (rectA->x1)); + obj1.arrayAdd (obj2.initReal (rectA->y1)); + obj1.arrayAdd (obj2.initReal (rectA->x2)); + obj1.arrayAdd (obj2.initReal (rectA->y2)); + obj2.free (); + + annotObj.initDict (docA->getXRef()); + annotObj.dictSet ("Type", obj2.initName ("Annot")); + annotObj.dictSet ("Rect", &obj1); + // obj1 is owned by the dict + + ref = docA->getXRef()->addIndirectObject (&annotObj); + + initialize (docA, annotObj.getDict()); +} + +Annot::Annot(PDFDoc *docA, Dict *dict) { + refCnt = 1; + hasRef = false; + flags = flagUnknown; + type = typeUnknown; + annotObj.initDict (dict); + initialize (docA, dict); +} + +Annot::Annot(PDFDoc *docA, Dict *dict, Object *obj) { + refCnt = 1; + if (obj->isRef()) { + hasRef = gTrue; + ref = obj->getRef(); + } else { + hasRef = gFalse; + } + flags = flagUnknown; + type = typeUnknown; + annotObj.initDict (dict); + initialize (docA, dict); +} + +void Annot::initialize(PDFDoc *docA, Dict *dict) { + Object apObj, asObj, obj1, obj2; + + ok = gTrue; + doc = docA; + xref = doc->getXRef(); + appearStreams = NULL; + appearBBox = NULL; + appearState = NULL; + appearBuf = NULL; + fontSize = 0; + + appearance.initNull(); + + //----- parse the rectangle + rect = new PDFRectangle(); + if (dict->lookup("Rect", &obj1)->isArray() && obj1.arrayGetLength() == 4) { + Object obj2; + (obj1.arrayGet(0, &obj2)->isNum() ? rect->x1 = obj2.getNum() : rect->x1 = 0); + obj2.free(); + (obj1.arrayGet(1, &obj2)->isNum() ? rect->y1 = obj2.getNum() : rect->y1 = 0); + obj2.free(); + (obj1.arrayGet(2, &obj2)->isNum() ? rect->x2 = obj2.getNum() : rect->x2 = 1); + obj2.free(); + (obj1.arrayGet(3, &obj2)->isNum() ? rect->y2 = obj2.getNum() : rect->y2 = 1); + obj2.free(); + + if (rect->x1 > rect->x2) { + double t = rect->x1; + rect->x1 = rect->x2; + rect->x2 = t; + } + + if (rect->y1 > rect->y2) { + double t = rect->y1; + rect->y1 = rect->y2; + rect->y2 = t; + } + } else { + rect->x1 = rect->y1 = 0; + rect->x2 = rect->y2 = 1; + error(errSyntaxError, -1, "Bad bounding box for annotation"); + ok = gFalse; + } + obj1.free(); + + if (dict->lookup("Contents", &obj1)->isString()) { + contents = obj1.getString()->copy(); + } else { + contents = new GooString(); + } + obj1.free(); + + // Note: This value is overwritten by Annots ctor + if (dict->lookupNF("P", &obj1)->isRef()) { + Ref ref = obj1.getRef(); + + page = doc->getCatalog()->findPage (ref.num, ref.gen); + } else { + page = 0; + } + obj1.free(); + + if (dict->lookup("NM", &obj1)->isString()) { + name = obj1.getString()->copy(); + } else { + name = NULL; + } + obj1.free(); + + if (dict->lookup("M", &obj1)->isString()) { + modified = obj1.getString()->copy(); + } else { + modified = NULL; + } + obj1.free(); + + //----- get the flags + if (dict->lookup("F", &obj1)->isInt()) { + flags |= obj1.getInt(); + } else { + flags = flagUnknown; + } + obj1.free(); + + //----- get the annotation appearance dictionary + dict->lookup("AP", &apObj); + if (apObj.isDict()) { + appearStreams = new AnnotAppearance(doc, &apObj); + } + apObj.free(); + + //----- get the appearance state + dict->lookup("AS", &asObj); + if (asObj.isName()) { + appearState = new GooString(asObj.getName()); + } else if (appearStreams && appearStreams->getNumStates() != 0) { + error (errSyntaxError, -1, "Invalid or missing AS value in annotation containing one or more appearance subdictionaries"); + // AS value is required in this case, but if the + // N dictionary contains only one entry + // take it as default appearance. + if (appearStreams->getNumStates() == 1) { + appearState = appearStreams->getStateKey(0); + } + } + if (!appearState) { + appearState = new GooString("Off"); + } + asObj.free(); + + //----- get the annotation appearance + if (appearStreams) { + appearStreams->getAppearanceStream(AnnotAppearance::appearNormal, appearState->getCString(), &appearance); + } + + //----- parse the border style + // According to the spec if neither the Border nor the BS entry is present, + // the border shall be drawn as a solid line with a width of 1 point. But acroread + // seems to ignore the Border entry for annots that can't have a BS entry. So, we only + // follow this rule for annots tha can have a BS entry. + if (dict->lookup("Border", &obj1)->isArray()) + border = new AnnotBorderArray(obj1.getArray()); + else + border = NULL; + obj1.free(); + + if (dict->lookup("C", &obj1)->isArray()) { + color = new AnnotColor(obj1.getArray()); + } else { + color = NULL; + } + obj1.free(); + + if (dict->lookup("StructParent", &obj1)->isInt()) { + treeKey = obj1.getInt(); + } else { + treeKey = 0; + } + obj1.free(); + + dict->lookupNF("OC", &oc); + +#if MULTITHREADED + gInitMutex(&mutex); +#endif +} + +void Annot::getRect(double *x1, double *y1, double *x2, double *y2) const { + *x1 = rect->x1; + *y1 = rect->y1; + *x2 = rect->x2; + *y2 = rect->y2; +} + +void Annot::setRect(PDFRectangle *rect) { + setRect(rect->x1, rect->y1, rect->x2, rect->y2); +} + +void Annot::setRect(double x1, double y1, double x2, double y2) { + Object obj1, obj2; + + if (x1 < x2) { + rect->x1 = x1; + rect->x2 = x2; + } else { + rect->x1 = x2; + rect->x2 = x1; + } + + if (y1 < y2) { + rect->y1 = y1; + rect->y2 = y2; + } else { + rect->y1 = y2; + rect->y2 = y1; + } + + obj1.initArray (xref); + obj1.arrayAdd (obj2.initReal (rect->x1)); + obj1.arrayAdd (obj2.initReal (rect->y1)); + obj1.arrayAdd (obj2.initReal (rect->x2)); + obj1.arrayAdd (obj2.initReal (rect->y2)); + + update("Rect", &obj1); + invalidateAppearance(); +} + +GBool Annot::inRect(double x, double y) const { + return rect->contains(x, y); +} + +void Annot::update(const char *key, Object *value) { + annotLocker(); + /* Set M to current time, unless we are updating M itself */ + if (strcmp(key, "M") != 0) { + delete modified; + modified = timeToDateString(NULL); + + Object obj1; + obj1.initString (modified->copy()); + annotObj.dictSet("M", &obj1); + } + + annotObj.dictSet(const_cast<char*>(key), value); + + xref->setModifiedObject(&annotObj, ref); +} + +void Annot::setContents(GooString *new_content) { + annotLocker(); + delete contents; + + if (new_content) { + contents = new GooString(new_content); + //append the unicode marker <FE FF> if needed + if (!contents->hasUnicodeMarker()) { + contents->insert(0, 0xff); + contents->insert(0, 0xfe); + } + } else { + contents = new GooString(); + } + + Object obj1; + obj1.initString(contents->copy()); + update ("Contents", &obj1); +} + +void Annot::setName(GooString *new_name) { + annotLocker(); + delete name; + + if (new_name) { + name = new GooString(new_name); + } else { + name = new GooString(); + } + + Object obj1; + obj1.initString(name->copy()); + update ("NM", &obj1); +} + +void Annot::setModified(GooString *new_modified) { + annotLocker(); + delete modified; + + if (new_modified) + modified = new GooString(new_modified); + else + modified = new GooString(); + + Object obj1; + obj1.initString(modified->copy()); + update ("M", &obj1); +} + +void Annot::setFlags(Guint new_flags) { + annotLocker(); + Object obj1; + flags = new_flags; + obj1.initInt(flags); + update ("F", &obj1); +} + +void Annot::setBorder(AnnotBorder *new_border) { + annotLocker(); + delete border; + + if (new_border) { + Object obj1; + new_border->writeToObject(xref, &obj1); + update(new_border->getType() == AnnotBorder::typeArray ? "Border" : "BS", &obj1); + border = new_border; + } else { + border = NULL; + } + invalidateAppearance(); +} + +void Annot::setColor(AnnotColor *new_color) { + annotLocker(); + delete color; + + if (new_color) { + Object obj1; + new_color->writeToObject(xref, &obj1); + update ("C", &obj1); + color = new_color; + } else { + color = NULL; + } + invalidateAppearance(); +} + +void Annot::setPage(int pageIndex, GBool updateP) { + annotLocker(); + Page *pageobj = doc->getPage(pageIndex); + Object obj1; + + if (pageobj) { + Ref pageRef = pageobj->getRef(); + obj1.initRef(pageRef.num, pageRef.gen); + page = pageIndex; + } else { + obj1.initNull(); + page = 0; + } + + if (updateP) { + update("P", &obj1); + } +} + +void Annot::setAppearanceState(const char *state) { + annotLocker(); + if (!state) + return; + + delete appearState; + appearState = new GooString(state); + + delete appearBBox; + appearBBox = NULL; + + Object obj1; + obj1.initName(state); + update ("AS", &obj1); + + // The appearance state determines the current appearance stream + appearance.free(); + if (appearStreams) { + appearStreams->getAppearanceStream(AnnotAppearance::appearNormal, appearState->getCString(), &appearance); + } else { + appearance.initNull(); + } +} + +void Annot::invalidateAppearance() { + annotLocker(); + if (appearStreams) { // Remove existing appearance streams + appearStreams->removeAllStreams(); + } + delete appearStreams; + appearStreams = NULL; + + delete appearState; + appearState = NULL; + + delete appearBBox; + appearBBox = NULL; + + appearance.free(); + appearance.initNull(); + + Object obj1, obj2; + obj1.initNull(); + if (!annotObj.dictLookup("AP", &obj2)->isNull()) + update ("AP", &obj1); // Remove AP + obj2.free(); + + if (!annotObj.dictLookup("AS", &obj2)->isNull()) + update ("AS", &obj1); // Remove AS + obj2.free(); +} + +double Annot::getXMin() { + return rect->x1; +} + +double Annot::getYMin() { + return rect->y1; +} + +double Annot::getXMax() { + return rect->x2; +} + +double Annot::getYMax() { + return rect->y2; +} + +void Annot::readArrayNum(Object *pdfArray, int key, double *value) { + Object valueObject; + + pdfArray->arrayGet(key, &valueObject); + if (valueObject.isNum()) { + *value = valueObject.getNum(); + } else { + *value = 0; + ok = gFalse; + } + valueObject.free(); +} + +void Annot::removeReferencedObjects() { + // Remove appearance streams (if any) + invalidateAppearance(); +} + +void Annot::incRefCnt() { + annotLocker(); + refCnt++; +} + +void Annot::decRefCnt() { +#if MULTITHREADED + gLockMutex(&mutex); +#endif + if (--refCnt == 0) { +#if MULTITHREADED + gUnlockMutex(&mutex); +#endif + delete this; + return; + } +#if MULTITHREADED + gUnlockMutex(&mutex); +#endif +} + +Annot::~Annot() { + annotObj.free(); + + delete rect; + delete contents; + + if (name) + delete name; + + if (modified) + delete modified; + + delete appearStreams; + delete appearBBox; + appearance.free(); + + if (appearState) + delete appearState; + + if (border) + delete border; + + if (color) + delete color; + + oc.free(); + +#if MULTITHREADED + gDestroyMutex(&mutex); +#endif +} + +void Annot::setColor(AnnotColor *color, GBool fill) { + const double *values = color->getValues(); + + switch (color->getSpace()) { + case AnnotColor::colorCMYK: + appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:c}\n", + values[0], values[1], values[2], values[3], + fill ? 'k' : 'K'); + break; + case AnnotColor::colorRGB: + appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:s}\n", + values[0], values[1], values[2], + fill ? "rg" : "RG"); + break; + case AnnotColor::colorGray: + appearBuf->appendf("{0:.2f} {1:c}\n", + values[0], + fill ? 'g' : 'G'); + break; + case AnnotColor::colorTransparent: + default: + break; + } +} + +void Annot::setLineStyleForBorder(AnnotBorder *border) { + int i, dashLength; + double *dash; + + switch (border->getStyle()) { + case AnnotBorder::borderDashed: + appearBuf->append("["); + dashLength = border->getDashLength(); + dash = border->getDash(); + for (i = 0; i < dashLength; ++i) + appearBuf->appendf(" {0:.2f}", dash[i]); + appearBuf->append(" ] 0 d\n"); + break; + default: + appearBuf->append("[] 0 d\n"); + break; + } + appearBuf->appendf("{0:.2f} w\n", border->getWidth()); +} + +// Draw an (approximate) circle of radius <r> centered at (<cx>, <cy>). +// If <fill> is true, the circle is filled; otherwise it is stroked. +void Annot::drawCircle(double cx, double cy, double r, GBool fill) { + appearBuf->appendf("{0:.2f} {1:.2f} m\n", + cx + r, cy); + appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", + cx + r, cy + bezierCircle * r, + cx + bezierCircle * r, cy + r, + cx, cy + r); + appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", + cx - bezierCircle * r, cy + r, + cx - r, cy + bezierCircle * r, + cx - r, cy); + appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", + cx - r, cy - bezierCircle * r, + cx - bezierCircle * r, cy - r, + cx, cy - r); + appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", + cx + bezierCircle * r, cy - r, + cx + r, cy - bezierCircle * r, + cx + r, cy); + appearBuf->append(fill ? "f\n" : "s\n"); +} + +// Draw the top-left half of an (approximate) circle of radius <r> +// centered at (<cx>, <cy>). +void Annot::drawCircleTopLeft(double cx, double cy, double r) { + double r2; + + r2 = r / sqrt(2.0); + appearBuf->appendf("{0:.2f} {1:.2f} m\n", + cx + r2, cy + r2); + appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", + cx + (1 - bezierCircle) * r2, + cy + (1 + bezierCircle) * r2, + cx - (1 - bezierCircle) * r2, + cy + (1 + bezierCircle) * r2, + cx - r2, + cy + r2); + appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", + cx - (1 + bezierCircle) * r2, + cy + (1 - bezierCircle) * r2, + cx - (1 + bezierCircle) * r2, + cy - (1 - bezierCircle) * r2, + cx - r2, + cy - r2); + appearBuf->append("S\n"); +} + +// Draw the bottom-right half of an (approximate) circle of radius <r> +// centered at (<cx>, <cy>). +void Annot::drawCircleBottomRight(double cx, double cy, double r) { + double r2; + + r2 = r / sqrt(2.0); + appearBuf->appendf("{0:.2f} {1:.2f} m\n", + cx - r2, cy - r2); + appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", + cx - (1 - bezierCircle) * r2, + cy - (1 + bezierCircle) * r2, + cx + (1 - bezierCircle) * r2, + cy - (1 + bezierCircle) * r2, + cx + r2, + cy - r2); + appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", + cx + (1 + bezierCircle) * r2, + cy - (1 - bezierCircle) * r2, + cx + (1 + bezierCircle) * r2, + cy + (1 - bezierCircle) * r2, + cx + r2, + cy + r2); + appearBuf->append("S\n"); +} + +void Annot::createForm(double *bbox, GBool transparencyGroup, Object *resDict, Object *aStream) { + Object obj1, obj2; + Object appearDict; + + appearDict.initDict(xref); + appearDict.dictSet("Length", obj1.initInt(appearBuf->getLength())); + appearDict.dictSet("Subtype", obj1.initName("Form")); + obj1.initArray(xref); + obj1.arrayAdd(obj2.initReal(bbox[0])); + obj1.arrayAdd(obj2.initReal(bbox[1])); + obj1.arrayAdd(obj2.initReal(bbox[2])); + obj1.arrayAdd(obj2.initReal(bbox[3])); + appearDict.dictSet("BBox", &obj1); + if (transparencyGroup) { + Object transDict; + transDict.initDict(xref); + transDict.dictSet("S", obj1.initName("Transparency")); + appearDict.dictSet("Group", &transDict); + } + if (resDict) + appearDict.dictSet("Resources", resDict); + + MemStream *mStream = new MemStream(copyString(appearBuf->getCString()), 0, + appearBuf->getLength(), &appearDict); + mStream->setNeedFree(gTrue); + aStream->initStream(mStream); +} + +void Annot::createResourcesDict(const char *formName, Object *formStream, + const char *stateName, + double opacity, const char *blendMode, + Object *resDict) { + Object gsDict, stateDict, formDict, obj1; + + gsDict.initDict(xref); + if (opacity != 1) { + gsDict.dictSet("CA", obj1.initReal(opacity)); + gsDict.dictSet("ca", obj1.initReal(opacity)); + } + if (blendMode) + gsDict.dictSet("BM", obj1.initName(blendMode)); + stateDict.initDict(xref); + stateDict.dictSet(stateName, &gsDict); + formDict.initDict(xref); + formDict.dictSet(formName, formStream); + + resDict->initDict(xref); + resDict->dictSet("ExtGState", &stateDict); + resDict->dictSet("XObject", &formDict); +} + +Object *Annot::getAppearanceResDict(Object *dest) { + Object obj1, obj2; + + dest->initNull(); // Default value + + // Fetch appearance's resource dict (if any) + appearance.fetch(xref, &obj1); + if (obj1.isStream()) { + obj1.streamGetDict()->lookup("Resources", &obj2); + if (obj2.isDict()) { + obj2.copy(dest); + } + obj2.free(); + } + obj1.free(); + + return dest; +} + +GBool Annot::isVisible(GBool printing) { + // check the flags + if ((flags & flagHidden) || + (printing && !(flags & flagPrint)) || + (!printing && (flags & flagNoView))) { + return gFalse; + } + + // check the OC + OCGs *optContentConfig = doc->getCatalog()->getOptContentConfig(); + if (optContentConfig) { + if (! optContentConfig->optContentIsVisible(&oc)) + return gFalse; + } + + return gTrue; +} + +int Annot::getRotation() const +{ + Page *pageobj = doc->getPage(page); + assert(pageobj != NULL); + + if (flags & flagNoRotate) { + return (360 - pageobj->getRotate()) % 360; + } else { + return 0; + } +} + +void Annot::draw(Gfx *gfx, GBool printing) { + Object obj; + + annotLocker(); + if (!isVisible (printing)) + return; + + // draw the appearance stream + appearance.fetch(gfx->getXRef(), &obj); + gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, + rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); + obj.free(); +} + +//------------------------------------------------------------------------ +// AnnotPopup +//------------------------------------------------------------------------ + +AnnotPopup::AnnotPopup(PDFDoc *docA, PDFRectangle *rect) : + Annot(docA, rect) { + Object obj1; + + type = typePopup; + + annotObj.dictSet ("Subtype", obj1.initName ("Popup")); + initialize (docA, annotObj.getDict()); +} + +AnnotPopup::AnnotPopup(PDFDoc *docA, Dict *dict, Object *obj) : + Annot(docA, dict, obj) { + type = typePopup; + initialize(docA, dict); +} + +AnnotPopup::~AnnotPopup() { + parent.free(); +} + +void AnnotPopup::initialize(PDFDoc *docA, Dict *dict) { + Object obj1; + + if (!dict->lookupNF("Parent", &parent)->isRef()) { + parent.initNull(); + } + + if (dict->lookup("Open", &obj1)->isBool()) { + open = obj1.getBool(); + } else { + open = gFalse; + } + obj1.free(); +} + +void AnnotPopup::setParent(Object *parentA) { + parentA->copy(&parent); + update ("Parent", &parent); +} + +void AnnotPopup::setParent(Annot *parentA) { + Ref parentRef = parentA->getRef(); + parent.initRef(parentRef.num, parentRef.gen); + update ("Parent", &parent); +} + +void AnnotPopup::setOpen(GBool openA) { + Object obj1; + + open = openA; + obj1.initBool(open); + update ("Open", &obj1); +} + +//------------------------------------------------------------------------ +// AnnotMarkup +//------------------------------------------------------------------------ +AnnotMarkup::AnnotMarkup(PDFDoc *docA, PDFRectangle *rect) : + Annot(docA, rect) { + initialize(docA, annotObj.getDict(), &annotObj); +} + +AnnotMarkup::AnnotMarkup(PDFDoc *docA, Dict *dict, Object *obj) : + Annot(docA, dict, obj) { + initialize(docA, dict, obj); +} + +AnnotMarkup::~AnnotMarkup() { + if (label) + delete label; + + if (popup) + delete popup; + + if (date) + delete date; + + if (subject) + delete subject; +} + +void AnnotMarkup::initialize(PDFDoc *docA, Dict *dict, Object *obj) { + Object obj1, obj2; + + if (dict->lookup("T", &obj1)->isString()) { + label = obj1.getString()->copy(); + } else { + label = NULL; + } + obj1.free(); + + if (dict->lookup("Popup", &obj1)->isDict() && dict->lookupNF("Popup", &obj2)->isRef()) { + popup = new AnnotPopup(docA, obj1.getDict(), &obj2); + } else { + popup = NULL; + } + obj1.free(); + + if (dict->lookup("CA", &obj1)->isNum()) { + opacity = obj1.getNum(); + } else { + opacity = 1.0; + } + obj1.free(); + + if (dict->lookup("CreationDate", &obj1)->isString()) { + date = obj1.getString()->copy(); + } else { + date = NULL; + } + obj1.free(); + + if (dict->lookupNF("IRT", &obj1)->isRef()) { + inReplyTo = obj1.getRef(); + } else { + inReplyTo.num = 0; + inReplyTo.gen = 0; + } + obj1.free(); + + if (dict->lookup("Subj", &obj1)->isString()) { + subject = obj1.getString()->copy(); + } else { + subject = NULL; + } + obj1.free(); + + if (dict->lookup("RT", &obj1)->isName()) { + const char *replyName = obj1.getName(); + + if (!strcmp(replyName, "R")) { + replyTo = replyTypeR; + } else if (!strcmp(replyName, "Group")) { + replyTo = replyTypeGroup; + } else { + replyTo = replyTypeR; + } + } else { + replyTo = replyTypeR; + } + obj1.free(); + + if (dict->lookup("ExData", &obj1)->isDict()) { + exData = parseAnnotExternalData(obj1.getDict()); + } else { + exData = annotExternalDataMarkupUnknown; + } + obj1.free(); +} + +void AnnotMarkup::setLabel(GooString *new_label) { + delete label; + + if (new_label) { + label = new GooString(new_label); + //append the unicode marker <FE FF> if needed + if (!label->hasUnicodeMarker()) { + label->insert(0, 0xff); + label->insert(0, 0xfe); + } + } else { + label = new GooString(); + } + + Object obj1; + obj1.initString(label->copy()); + update ("T", &obj1); +} + +void AnnotMarkup::setPopup(AnnotPopup *new_popup) { + // If there exists an old popup annotation that is already + // associated with a page, then we need to remove that + // popup annotation from the page. Otherwise we would have + // dangling references to it. + if (popup != NULL && popup->getPageNum() != 0) { + Page *pageobj = doc->getPage(popup->getPageNum()); + if (pageobj) { + pageobj->removeAnnot(popup); + } + } + delete popup; + + if (new_popup) { + Object obj1; + Ref popupRef = new_popup->getRef(); + + obj1.initRef (popupRef.num, popupRef.gen); + update ("Popup", &obj1); + + new_popup->setParent(this); + popup = new_popup; + + // If this annotation is already added to a page, then we + // add the new popup annotation to the same page. + if (page != 0) { + Page *pageobj = doc->getPage(page); + assert(pageobj != NULL); // pageobj should exist in doc (see setPage()) + + pageobj->addAnnot(popup); + } + } else { + popup = NULL; + } +} + +void AnnotMarkup::setOpacity(double opacityA) { + Object obj1; + + opacity = opacityA; + obj1.initReal(opacity); + update ("CA", &obj1); + invalidateAppearance(); +} + +void AnnotMarkup::setDate(GooString *new_date) { + delete date; + + if (new_date) + date = new GooString(new_date); + else + date = new GooString(); + + Object obj1; + obj1.initString(date->copy()); + update ("CreationDate", &obj1); +} + +void AnnotMarkup::removeReferencedObjects() { + Page *pageobj = doc->getPage(page); + assert(pageobj != NULL); // We're called when removing an annot from a page + + // Remove popup + if (popup) { + pageobj->removeAnnot(popup); + } + + Annot::removeReferencedObjects(); +} + +//------------------------------------------------------------------------ +// AnnotText +//------------------------------------------------------------------------ + +AnnotText::AnnotText(PDFDoc *docA, PDFRectangle *rect) : + AnnotMarkup(docA, rect) { + Object obj1; + + type = typeText; + flags |= flagNoZoom | flagNoRotate; + + annotObj.dictSet ("Subtype", obj1.initName ("Text")); + initialize (docA, annotObj.getDict()); +} + +AnnotText::AnnotText(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { + + type = typeText; + flags |= flagNoZoom | flagNoRotate; + initialize (docA, dict); +} + +AnnotText::~AnnotText() { + delete icon; +} + +void AnnotText::initialize(PDFDoc *docA, Dict *dict) { + Object obj1; + + if (dict->lookup("Open", &obj1)->isBool()) + open = obj1.getBool(); + else + open = gFalse; + obj1.free(); + + if (dict->lookup("Name", &obj1)->isName()) { + icon = new GooString(obj1.getName()); + } else { + icon = new GooString("Note"); + } + obj1.free(); + + if (dict->lookup("StateModel", &obj1)->isString()) { + Object obj2; + GooString *modelName = obj1.getString(); + + if (dict->lookup("State", &obj2)->isString()) { + GooString *stateName = obj2.getString(); + + if (!stateName->cmp("Marked")) { + state = stateMarked; + } else if (!stateName->cmp("Unmarked")) { + state = stateUnmarked; + } else if (!stateName->cmp("Accepted")) { + state = stateAccepted; + } else if (!stateName->cmp("Rejected")) { + state = stateRejected; + } else if (!stateName->cmp("Cancelled")) { + state = stateCancelled; + } else if (!stateName->cmp("Completed")) { + state = stateCompleted; + } else if (!stateName->cmp("None")) { + state = stateNone; + } else { + state = stateUnknown; + } + } else { + state = stateUnknown; + } + obj2.free(); + + if (!modelName->cmp("Marked")) { + switch (state) { + case stateUnknown: + state = stateMarked; + break; + case stateAccepted: + case stateRejected: + case stateCancelled: + case stateCompleted: + case stateNone: + state = stateUnknown; + break; + default: + break; + } + } else if (!modelName->cmp("Review")) { + switch (state) { + case stateUnknown: + state = stateNone; + break; + case stateMarked: + case stateUnmarked: + state = stateUnknown; + break; + default: + break; + } + } else { + state = stateUnknown; + } + } else { + state = stateUnknown; + } + obj1.free(); +} + +void AnnotText::setOpen(GBool openA) { + Object obj1; + + open = openA; + obj1.initBool(open); + update ("Open", &obj1); +} + +void AnnotText::setIcon(GooString *new_icon) { + if (new_icon && icon->cmp(new_icon) == 0) + return; + + delete icon; + + if (new_icon) { + icon = new GooString (new_icon); + } else { + icon = new GooString("Note"); + } + + Object obj1; + obj1.initName (icon->getCString()); + update("Name", &obj1); + invalidateAppearance(); +} + +#define ANNOT_TEXT_AP_NOTE \ + "3.602 24 m 20.398 24 l 22.387 24 24 22.387 24 20.398 c 24 3.602 l 24\n" \ + "1.613 22.387 0 20.398 0 c 3.602 0 l 1.613 0 0 1.613 0 3.602 c 0 20.398\n" \ + "l 0 22.387 1.613 24 3.602 24 c h\n" \ + "3.602 24 m f\n" \ + "0.533333 0.541176 0.521569 RG 2 w\n" \ + "1 J\n" \ + "1 j\n" \ + "[] 0.0 d\n" \ + "4 M 9 18 m 4 18 l 4 7 4 4 6 3 c 20 3 l 18 4 18 7 18 18 c 17 18 l S\n" \ + "1.5 w\n" \ + "0 j\n" \ + "10 16 m 14 21 l S\n" \ + "1.85625 w\n" \ + "1 j\n" \ + "15.07 20.523 m 15.07 19.672 14.379 18.977 13.523 18.977 c 12.672 18.977\n" \ + "11.977 19.672 11.977 20.523 c 11.977 21.379 12.672 22.07 13.523 22.07 c\n" \ + "14.379 22.07 15.07 21.379 15.07 20.523 c h\n" \ + "15.07 20.523 m S\n" \ + "1 w\n" \ + "0 j\n" \ + "6.5 13.5 m 15.5 13.5 l S\n" \ + "6.5 10.5 m 13.5 10.5 l S\n" \ + "6.801 7.5 m 15.5 7.5 l S\n" \ + "0.729412 0.741176 0.713725 RG 2 w\n" \ + "1 j\n" \ + "9 19 m 4 19 l 4 8 4 5 6 4 c 20 4 l 18 5 18 8 18 19 c 17 19 l S\n" \ + "1.5 w\n" \ + "0 j\n" \ + "10 17 m 14 22 l S\n" \ + "1.85625 w\n" \ + "1 j\n" \ + "15.07 21.523 m 15.07 20.672 14.379 19.977 13.523 19.977 c 12.672 19.977\n" \ + "11.977 20.672 11.977 21.523 c 11.977 22.379 12.672 23.07 13.523 23.07 c\n" \ + "14.379 23.07 15.07 22.379 15.07 21.523 c h\n" \ + "15.07 21.523 m S\n" \ + "1 w\n" \ + "0 j\n" \ + "6.5 14.5 m 15.5 14.5 l S\n" \ + "6.5 11.5 m 13.5 11.5 l S\n" \ + "6.801 8.5 m 15.5 8.5 l S\n" + +#define ANNOT_TEXT_AP_COMMENT \ + "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ + "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ + "l 1 21.523 2.477 23 4.301 23 c h\n" \ + "4.301 23 m f\n" \ + "0.533333 0.541176 0.521569 RG 2 w\n" \ + "0 J\n" \ + "1 j\n" \ + "[] 0.0 d\n" \ + "4 M 8 20 m 16 20 l 18.363 20 20 18.215 20 16 c 20 13 l 20 10.785 18.363 9\n" \ + "16 9 c 13 9 l 8 3 l 8 9 l 8 9 l 5.637 9 4 10.785 4 13 c 4 16 l 4 18.215\n" \ + "5.637 20 8 20 c h\n" \ + "8 20 m S\n" \ + "0.729412 0.741176 0.713725 RG 8 21 m 16 21 l 18.363 21 20 19.215 20 17\n" \ + "c 20 14 l 20 11.785 18.363 10\n" \ + "16 10 c 13 10 l 8 4 l 8 10 l 8 10 l 5.637 10 4 11.785 4 14 c 4 17 l 4\n" \ + "19.215 5.637 21 8 21 c h\n" \ + "8 21 m S\n" + +#define ANNOT_TEXT_AP_KEY \ + "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ + "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ + "l 1 21.523 2.477 23 4.301 23 c h\n" \ + "4.301 23 m f\n" \ + "0.533333 0.541176 0.521569 RG 2 w\n" \ + "1 J\n" \ + "0 j\n" \ + "[] 0.0 d\n" \ + "4 M 11.895 18.754 m 13.926 20.625 17.09 20.496 18.961 18.465 c 20.832\n" \ + "16.434 20.699 13.27 18.668 11.398 c 17.164 10.016 15.043 9.746 13.281\n" \ + "10.516 c 12.473 9.324 l 11.281 10.078 l 9.547 8.664 l 9.008 6.496 l\n" \ + "7.059 6.059 l 6.34 4.121 l 5.543 3.668 l 3.375 4.207 l 2.938 6.156 l\n" \ + "10.57 13.457 l 9.949 15.277 10.391 17.367 11.895 18.754 c h\n" \ + "11.895 18.754 m S\n" \ + "1.5 w\n" \ + "16.059 15.586 m 16.523 15.078 17.316 15.043 17.824 15.512 c 18.332\n" \ + "15.98 18.363 16.77 17.895 17.277 c 17.43 17.785 16.637 17.816 16.129\n" \ + "17.352 c 15.621 16.883 15.59 16.094 16.059 15.586 c h\n" \ + "16.059 15.586 m S\n" \ + "0.729412 0.741176 0.713725 RG 2 w\n" \ + "11.895 19.754 m 13.926 21.625 17.09 21.496 18.961 19.465 c 20.832\n" \ + "17.434 20.699 14.27 18.668 12.398 c 17.164 11.016 15.043 10.746 13.281\n" \ + "11.516 c 12.473 10.324 l 11.281 11.078 l 9.547 9.664 l 9.008 7.496 l\n" \ + "7.059 7.059 l 6.34 5.121 l 5.543 4.668 l 3.375 5.207 l 2.938 7.156 l\n" \ + "10.57 14.457 l 9.949 16.277 10.391 18.367 11.895 19.754 c h\n" \ + "11.895 19.754 m S\n" \ + "1.5 w\n" \ + "16.059 16.586 m 16.523 16.078 17.316 16.043 17.824 16.512 c 18.332\n" \ + "16.98 18.363 17.77 17.895 18.277 c 17.43 18.785 16.637 18.816 16.129\n" \ + "18.352 c 15.621 17.883 15.59 17.094 16.059 16.586 c h\n" \ + "16.059 16.586 m S\n" + +#define ANNOT_TEXT_AP_HELP \ + "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ + "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ + "l 1 21.523 2.477 23 4.301 23 c h\n" \ + "4.301 23 m f\n" \ + "0.533333 0.541176 0.521569 RG 2.5 w\n" \ + "1 J\n" \ + "1 j\n" \ + "[] 0.0 d\n" \ + "4 M 8.289 16.488 m 8.824 17.828 10.043 18.773 11.473 18.965 c 12.902 19.156\n" \ + "14.328 18.559 15.195 17.406 c 16.062 16.254 16.242 14.723 15.664 13.398\n" \ + "c S\n" \ + "0 j\n" \ + "12 8 m 12 12 16 11 16 15 c S\n" \ + "1.539286 w\n" \ + "1 j\n" \ + "q 1 0 0 -0.999991 0 24 cm\n" \ + "12.684 20.891 m 12.473 21.258 12.004 21.395 11.629 21.196 c 11.254\n" \ + "20.992 11.105 20.531 11.297 20.149 c 11.488 19.77 11.945 19.61 12.332\n" \ + "19.789 c 12.719 19.969 12.891 20.426 12.719 20.817 c S Q\n" \ + "0.729412 0.741176 0.713725 RG 2.5 w\n" \ + "8.289 17.488 m 9.109 19.539 11.438 20.535 13.488 19.711 c 15.539 18.891\n" \ + "16.535 16.562 15.711 14.512 c 15.699 14.473 15.684 14.438 15.664 14.398\n" \ + "c S\n" \ + "0 j\n" \ + "12 9 m 12 13 16 12 16 16 c S\n" \ + "1.539286 w\n" \ + "1 j\n" \ + "q 1 0 0 -0.999991 0 24 cm\n" \ + "12.684 19.891 m 12.473 20.258 12.004 20.395 11.629 20.195 c 11.254\n" \ + "19.992 11.105 19.531 11.297 19.149 c 11.488 18.77 11.945 18.61 12.332\n" \ + "18.789 c 12.719 18.969 12.891 19.426 12.719 19.817 c S Q\n" + +#define ANNOT_TEXT_AP_NEW_PARAGRAPH \ + "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ + "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ + "l 1 21.523 2.477 23 4.301 23 c h\n" \ + "4.301 23 m f\n" \ + "0.533333 0.541176 0.521569 RG 4 w\n" \ + "0 J\n" \ + "2 j\n" \ + "[] 0.0 d\n" \ + "4 M q 1 0 0 -1 0 24 cm\n" \ + "9.211 11.988 m 8.449 12.07 7.711 11.707 7.305 11.059 c 6.898 10.41\n" \ + "6.898 9.59 7.305 8.941 c 7.711 8.293 8.449 7.93 9.211 8.012 c S Q\n" \ + "1.004413 w\n" \ + "1 J\n" \ + "1 j\n" \ + "q 1 0 0 -0.991232 0 24 cm\n" \ + "18.07 11.511 m 15.113 10.014 l 12.199 11.602 l 12.711 8.323 l 10.301\n" \ + "6.045 l 13.574 5.517 l 14.996 2.522 l 16.512 5.474 l 19.801 5.899 l\n" \ + "17.461 8.252 l 18.07 11.511 l h\n" \ + "18.07 11.511 m S Q\n" \ + "2 w\n" \ + "0 j\n" \ + "11 17 m 10 17 l 10 3 l S\n" \ + "14 3 m 14 13 l S\n" \ + "0.729412 0.741176 0.713725 RG 4 w\n" \ + "0 J\n" \ + "2 j\n" \ + "q 1 0 0 -1 0 24 cm\n" \ + "9.211 10.988 m 8.109 11.105 7.125 10.309 7.012 9.211 c 6.895 8.109\n" \ + "7.691 7.125 8.789 7.012 c 8.93 6.996 9.07 6.996 9.211 7.012 c S Q\n" \ + "1.004413 w\n" \ + "1 J\n" \ + "1 j\n" \ + "q 1 0 0 -0.991232 0 24 cm\n" \ + "18.07 10.502 m 15.113 9.005 l 12.199 10.593 l 12.711 7.314 l 10.301\n" \ + "5.036 l 13.574 4.508 l 14.996 1.513 l 16.512 4.465 l 19.801 4.891 l\n" \ + "17.461 7.243 l 18.07 10.502 l h\n" \ + "18.07 10.502 m S Q\n" \ + "2 w\n" \ + "0 j\n" \ + "11 18 m 10 18 l 10 4 l S\n" \ + "14 4 m 14 14 l S\n" + +#define ANNOT_TEXT_AP_PARAGRAPH \ + "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ + "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ + "l 1 21.523 2.477 23 4.301 23 c h\n" \ + "4.301 23 m f\n" \ + "0.533333 0.541176 0.521569 RG 2 w\n" \ + "1 J\n" \ + "1 j\n" \ + "[] 0.0 d\n" \ + "4 M 15 3 m 15 18 l 11 18 l 11 3 l S\n" \ + "4 w\n" \ + "q 1 0 0 -1 0 24 cm\n" \ + "9.777 10.988 m 8.746 10.871 7.973 9.988 8 8.949 c 8.027 7.91 8.844\n" \ + "7.066 9.879 7.004 c S Q\n" \ + "0.729412 0.741176 0.713725 RG 2 w\n" \ + "15 4 m 15 19 l 11 19 l 11 4 l S\n" \ + "4 w\n" \ + "q 1 0 0 -1 0 24 cm\n" \ + "9.777 9.988 m 8.746 9.871 7.973 8.988 8 7.949 c 8.027 6.91 8.844 6.066\n" \ + "9.879 6.004 c S Q\n" + +#define ANNOT_TEXT_AP_INSERT \ + "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ + "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ + "l 1 21.523 2.477 23 4.301 23 c h\n" \ + "4.301 23 m f\n" \ + "0.533333 0.541176 0.521569 RG 2 w\n" \ + "1 J\n" \ + "0 j\n" \ + "[] 0.0 d\n" \ + "4 M 12 18.012 m 20 18 l S\n" \ + "9 10 m 17 10 l S\n" \ + "12 14.012 m 20 14 l S\n" \ + "12 6.012 m 20 6.012 l S\n" \ + "4 12 m 6 10 l 4 8 l S\n" \ + "4 12 m 4 8 l S\n" \ + "0.729412 0.741176 0.713725 RG 12 19.012 m 20 19 l S\n" \ + "9 11 m 17 11 l S\n" \ + "12 15.012 m 20 15 l S\n" \ + "12 7.012 m 20 7.012 l S\n" \ + "4 13 m 6 11 l 4 9 l S\n" \ + "4 13 m 4 9 l S\n" + +#define ANNOT_TEXT_AP_CROSS \ + "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ + "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ + "l 1 21.523 2.477 23 4.301 23 c h\n" \ + "4.301 23 m f\n" \ + "0.533333 0.541176 0.521569 RG 2.5 w\n" \ + "1 J\n" \ + "0 j\n" \ + "[] 0.0 d\n" \ + "4 M 18 5 m 6 17 l S\n" \ + "6 5 m 18 17 l S\n" \ + "0.729412 0.741176 0.713725 RG 18 6 m 6 18 l S\n" \ + "6 6 m 18 18 l S\n" + +#define ANNOT_TEXT_AP_CIRCLE \ + "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ + "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ + "l 1 21.523 2.477 23 4.301 23 c h\n" \ + "4.301 23 m f\n" \ + "0.533333 0.541176 0.521569 RG 2.5 w\n" \ + "1 J\n" \ + "1 j\n" \ + "[] 0.0 d\n" \ + "4 M 19.5 11.5 m 19.5 7.359 16.141 4 12 4 c 7.859 4 4.5 7.359 4.5 11.5 c 4.5\n" \ + "15.641 7.859 19 12 19 c 16.141 19 19.5 15.641 19.5 11.5 c h\n" \ + "19.5 11.5 m S\n" \ + "0.729412 0.741176 0.713725 RG 19.5 12.5 m 19.5 8.359 16.141 5 12 5 c\n" \ + "7.859 5 4.5 8.359 4.5 12.5 c 4.5\n" \ + "16.641 7.859 20 12 20 c 16.141 20 19.5 16.641 19.5 12.5 c h\n" \ + "19.5 12.5 m S\n" + +void AnnotText::draw(Gfx *gfx, GBool printing) { + Object obj; + double ca = 1; + + if (!isVisible (printing)) + return; + + annotLocker(); + if (appearance.isNull()) { + ca = opacity; + + appearBuf = new GooString (); + + appearBuf->append ("q\n"); + if (color) + setColor(color, gTrue); + else + appearBuf->append ("1 1 1 rg\n"); + if (!icon->cmp("Note")) + appearBuf->append (ANNOT_TEXT_AP_NOTE); + else if (!icon->cmp("Comment")) + appearBuf->append (ANNOT_TEXT_AP_COMMENT); + else if (!icon->cmp("Key")) + appearBuf->append (ANNOT_TEXT_AP_KEY); + else if (!icon->cmp("Help")) + appearBuf->append (ANNOT_TEXT_AP_HELP); + else if (!icon->cmp("NewParagraph")) + appearBuf->append (ANNOT_TEXT_AP_NEW_PARAGRAPH); + else if (!icon->cmp("Paragraph")) + appearBuf->append (ANNOT_TEXT_AP_PARAGRAPH); + else if (!icon->cmp("Insert")) + appearBuf->append (ANNOT_TEXT_AP_INSERT); + else if (!icon->cmp("Cross")) + appearBuf->append (ANNOT_TEXT_AP_CROSS); + else if (!icon->cmp("Circle")) + appearBuf->append (ANNOT_TEXT_AP_CIRCLE); + appearBuf->append ("Q\n"); + + // Force 24x24 rectangle + PDFRectangle fixedRect(rect->x1, rect->y2 - 24, rect->x1 + 24, rect->y2); + appearBBox = new AnnotAppearanceBBox(&fixedRect); + double bbox[4]; + appearBBox->getBBoxRect(bbox); + if (ca == 1) { + createForm(bbox, gFalse, NULL, &appearance); + } else { + Object aStream, resDict; + + createForm(bbox, gTrue, NULL, &aStream); + delete appearBuf; + + appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); + createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); + createForm(bbox, gFalse, &resDict, &appearance); + } + delete appearBuf; + } + + // draw the appearance stream + appearance.fetch(gfx->getXRef(), &obj); + if (appearBBox) { + gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, + appearBBox->getPageXMin(), appearBBox->getPageYMin(), + appearBBox->getPageXMax(), appearBBox->getPageYMax(), + getRotation()); + } else { + gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, + rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); + } + obj.free(); +} + +//------------------------------------------------------------------------ +// AnnotLink +//------------------------------------------------------------------------ +AnnotLink::AnnotLink(PDFDoc *docA, PDFRectangle *rect) : + Annot(docA, rect) { + Object obj1; + + type = typeLink; + annotObj.dictSet ("Subtype", obj1.initName ("Link")); + initialize (docA, annotObj.getDict()); +} + +AnnotLink::AnnotLink(PDFDoc *docA, Dict *dict, Object *obj) : + Annot(docA, dict, obj) { + + type = typeLink; + initialize (docA, dict); +} + +AnnotLink::~AnnotLink() { + delete action; + /* + if (uriAction) + delete uriAction; + */ + if (quadrilaterals) + delete quadrilaterals; +} + +void AnnotLink::initialize(PDFDoc *docA, Dict *dict) { + Object obj1; + + action = NULL; + + // look for destination + if (!dict->lookup("Dest", &obj1)->isNull()) { + action = LinkAction::parseDest(&obj1); + // look for action + } else { + obj1.free(); + if (dict->lookup("A", &obj1)->isDict()) { + action = LinkAction::parseAction(&obj1, doc->getCatalog()->getBaseURI()); + } + } + obj1.free(); + + if (dict->lookup("H", &obj1)->isName()) { + const char *effect = obj1.getName(); + + if (!strcmp(effect, "N")) { + linkEffect = effectNone; + } else if (!strcmp(effect, "I")) { + linkEffect = effectInvert; + } else if (!strcmp(effect, "O")) { + linkEffect = effectOutline; + } else if (!strcmp(effect, "P")) { + linkEffect = effectPush; + } else { + linkEffect = effectInvert; + } + } else { + linkEffect = effectInvert; + } + obj1.free(); + /* + if (dict->lookup("PA", &obj1)->isDict()) { + uriAction = NULL; + } else { + uriAction = NULL; + } + obj1.free(); + */ + if (dict->lookup("QuadPoints", &obj1)->isArray()) { + quadrilaterals = new AnnotQuadrilaterals(obj1.getArray(), rect); + } else { + quadrilaterals = NULL; + } + obj1.free(); + + if (dict->lookup("BS", &obj1)->isDict()) { + delete border; + border = new AnnotBorderBS(obj1.getDict()); + } else if (!border) { + border = new AnnotBorderBS(); + } + obj1.free(); +} + +void AnnotLink::draw(Gfx *gfx, GBool printing) { + Object obj; + + if (!isVisible (printing)) + return; + + annotLocker(); + // draw the appearance stream + appearance.fetch(gfx->getXRef(), &obj); + gfx->drawAnnot(&obj, border, color, + rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); + obj.free(); +} + +//------------------------------------------------------------------------ +// AnnotFreeText +//------------------------------------------------------------------------ +AnnotFreeText::AnnotFreeText(PDFDoc *docA, PDFRectangle *rect, GooString *da) : + AnnotMarkup(docA, rect) { + Object obj1; + + type = typeFreeText; + + annotObj.dictSet ("Subtype", obj1.initName ("FreeText")); + + Object obj2; + obj2.initString (da->copy()); + annotObj.dictSet("DA", &obj2); + + initialize (docA, annotObj.getDict()); +} + +AnnotFreeText::AnnotFreeText(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { + type = typeFreeText; + initialize(docA, dict); +} + +AnnotFreeText::~AnnotFreeText() { + delete appearanceString; + + if (styleString) + delete styleString; + + if (calloutLine) + delete calloutLine; + + if (borderEffect) + delete borderEffect; + + if (rectangle) + delete rectangle; +} + +void AnnotFreeText::initialize(PDFDoc *docA, Dict *dict) { + Object obj1; + + if (dict->lookup("DA", &obj1)->isString()) { + appearanceString = obj1.getString()->copy(); + } else { + appearanceString = new GooString(); + error(errSyntaxError, -1, "Bad appearance for annotation"); + ok = gFalse; + } + obj1.free(); + + if (dict->lookup("Q", &obj1)->isInt()) { + quadding = (AnnotFreeTextQuadding) obj1.getInt(); + } else { + quadding = quaddingLeftJustified; + } + obj1.free(); + + if (dict->lookup("DS", &obj1)->isString()) { + styleString = obj1.getString()->copy(); + } else { + styleString = NULL; + } + obj1.free(); + + if (dict->lookup("CL", &obj1)->isArray() && obj1.arrayGetLength() >= 4) { + double x1, y1, x2, y2; + Object obj2; + + (obj1.arrayGet(0, &obj2)->isNum() ? x1 = obj2.getNum() : x1 = 0); + obj2.free(); + (obj1.arrayGet(1, &obj2)->isNum() ? y1 = obj2.getNum() : y1 = 0); + obj2.free(); + (obj1.arrayGet(2, &obj2)->isNum() ? x2 = obj2.getNum() : x2 = 0); + obj2.free(); + (obj1.arrayGet(3, &obj2)->isNum() ? y2 = obj2.getNum() : y2 = 0); + obj2.free(); + + if (obj1.arrayGetLength() == 6) { + double x3, y3; + (obj1.arrayGet(4, &obj2)->isNum() ? x3 = obj2.getNum() : x3 = 0); + obj2.free(); + (obj1.arrayGet(5, &obj2)->isNum() ? y3 = obj2.getNum() : y3 = 0); + obj2.free(); + calloutLine = new AnnotCalloutMultiLine(x1, y1, x2, y2, x3, y3); + } else { + calloutLine = new AnnotCalloutLine(x1, y1, x2, y2); + } + } else { + calloutLine = NULL; + } + obj1.free(); + + if (dict->lookup("IT", &obj1)->isName()) { + const char *intentName = obj1.getName(); + + if (!strcmp(intentName, "FreeText")) { + intent = intentFreeText; + } else if (!strcmp(intentName, "FreeTextCallout")) { + intent = intentFreeTextCallout; + } else if (!strcmp(intentName, "FreeTextTypeWriter")) { + intent = intentFreeTextTypeWriter; + } else { + intent = intentFreeText; + } + } else { + intent = intentFreeText; + } + obj1.free(); + + if (dict->lookup("BS", &obj1)->isDict()) { + delete border; + border = new AnnotBorderBS(obj1.getDict()); + } else if (!border) { + border = new AnnotBorderBS(); + } + obj1.free(); + + if (dict->lookup("BE", &obj1)->isDict()) { + borderEffect = new AnnotBorderEffect(obj1.getDict()); + } else { + borderEffect = NULL; + } + obj1.free(); + + if (dict->lookup("RD", &obj1)->isArray()) { + rectangle = parseDiffRectangle(obj1.getArray(), rect); + } else { + rectangle = NULL; + } + obj1.free(); + + if (dict->lookup("LE", &obj1)->isName()) { + GooString styleName(obj1.getName()); + endStyle = parseAnnotLineEndingStyle(&styleName); + } else { + endStyle = annotLineEndingNone; + } + obj1.free(); +} + +void AnnotFreeText::setContents(GooString *new_content) { + Annot::setContents(new_content); + invalidateAppearance(); +} + +void AnnotFreeText::setAppearanceString(GooString *new_string) { + delete appearanceString; + + if (new_string) { + appearanceString = new GooString(new_string); + } else { + appearanceString = new GooString(); + } + + Object obj1; + obj1.initString(appearanceString->copy()); + update ("DA", &obj1); + invalidateAppearance(); +} + +void AnnotFreeText::setQuadding(AnnotFreeTextQuadding new_quadding) { + Object obj1; + quadding = new_quadding; + obj1.initInt((int)quadding); + update ("Q", &obj1); + invalidateAppearance(); +} + +void AnnotFreeText::setStyleString(GooString *new_string) { + delete styleString; + + if (new_string) { + styleString = new GooString(new_string); + //append the unicode marker <FE FF> if needed + if (!styleString->hasUnicodeMarker()) { + styleString->insert(0, 0xff); + styleString->insert(0, 0xfe); + } + } else { + styleString = new GooString(); + } + + Object obj1; + obj1.initString(styleString->copy()); + update ("DS", &obj1); +} + +void AnnotFreeText::setCalloutLine(AnnotCalloutLine *line) { + delete calloutLine; + + Object obj1; + if (line == NULL) { + obj1.initNull(); + calloutLine = NULL; + } else { + double x1 = line->getX1(), y1 = line->getY1(); + double x2 = line->getX2(), y2 = line->getY2(); + Object obj2; + obj1.initArray(xref); + obj1.arrayAdd( obj2.initReal(x1) ); + obj1.arrayAdd( obj2.initReal(y1) ); + obj1.arrayAdd( obj2.initReal(x2) ); + obj1.arrayAdd( obj2.initReal(y2) ); + + AnnotCalloutMultiLine *mline = dynamic_cast<AnnotCalloutMultiLine*>(line); + if (mline) { + double x3 = mline->getX3(), y3 = mline->getY3(); + obj1.arrayAdd( obj2.initReal(x3) ); + obj1.arrayAdd( obj2.initReal(y3) ); + calloutLine = new AnnotCalloutMultiLine(x1, y1, x2, y2, x3, y3); + } else { + calloutLine = new AnnotCalloutLine(x1, y1, x2, y2); + } + } + + update("CL", &obj1); + invalidateAppearance(); +} + +void AnnotFreeText::setIntent(AnnotFreeTextIntent new_intent) { + Object obj1; + + intent = new_intent; + if (new_intent == intentFreeText) + obj1.initName("FreeText"); + else if (new_intent == intentFreeTextCallout) + obj1.initName("FreeTextCallout"); + else // intentFreeTextTypeWriter + obj1.initName("FreeTextTypeWriter"); + update ("IT", &obj1); +} + +static GfxFont * createAnnotDrawFont(XRef * xref, Object *fontResDict) +{ + Ref dummyRef = { -1, -1 }; + + Object baseFontObj, subtypeObj, encodingObj; + baseFontObj.initName("Helvetica"); + subtypeObj.initName("Type0"); + encodingObj.initName("WinAnsiEncoding"); + + Object fontDictObj; + Dict *fontDict = new Dict(xref); + fontDict->decRef(); + fontDict->add(copyString("BaseFont"), &baseFontObj); + fontDict->add(copyString("Subtype"), &subtypeObj); + fontDict->add(copyString("Encoding"), &encodingObj); + fontDictObj.initDict(fontDict); + + Object fontsDictObj; + Dict *fontsDict = new Dict(xref); + fontsDict->decRef(); + fontsDict->add(copyString("AnnotDrawFont"), &fontDictObj); + fontsDictObj.initDict(fontsDict); + + Dict *dict = new Dict(xref); + dict->add(copyString("Font"), &fontsDictObj); + + fontResDict->initDict(dict); + return GfxFont::makeFont(xref, "AnnotDrawFont", dummyRef, fontDict); +} + +void AnnotFreeText::parseAppearanceString(GooString *da, double &fontsize, AnnotColor* &fontcolor) { + fontsize = -1; + fontcolor = NULL; + if (da) { + GooList * daToks = new GooList(); + int j, i = 0; + + // Tokenize + while (i < da->getLength()) { + while (i < da->getLength() && Lexer::isSpace(da->getChar(i))) { + ++i; + } + if (i < da->getLength()) { + for (j = i + 1; j < da->getLength() && !Lexer::isSpace(da->getChar(j)); ++j) { + } + daToks->append(new GooString(da, i, j - i)); + i = j; + } + } + + // Scan backwards: we are looking for the last set value + for (i = daToks->getLength()-1; i >= 0; --i) { + if (fontsize == -1) { + if (!((GooString *)daToks->get(i))->cmp("Tf") && i >= 2) { + // TODO: Font name + fontsize = gatof(( (GooString *)daToks->get(i-1) )->getCString()); + } + } + if (fontcolor == NULL) { + if (!((GooString *)daToks->get(i))->cmp("g") && i >= 1) { + fontcolor = new AnnotColor(gatof(( (GooString *)daToks->get(i-1) )->getCString())); + } else if (!((GooString *)daToks->get(i))->cmp("rg") && i >= 3) { + fontcolor = new AnnotColor(gatof(( (GooString *)daToks->get(i-3) )->getCString()), + gatof(( (GooString *)daToks->get(i-2) )->getCString()), + gatof(( (GooString *)daToks->get(i-1) )->getCString())); + } else if (!((GooString *)daToks->get(i))->cmp("k") && i >= 4) { + fontcolor = new AnnotColor(gatof(( (GooString *)daToks->get(i-4) )->getCString()), + gatof(( (GooString *)daToks->get(i-3) )->getCString()), + gatof(( (GooString *)daToks->get(i-2) )->getCString()), + gatof(( (GooString *)daToks->get(i-1) )->getCString())); + } + } + } + deleteGooList(daToks, GooString); + } +} + +void AnnotFreeText::generateFreeTextAppearance() +{ + double borderWidth, ca = opacity; + + appearBuf = new GooString (); + appearBuf->append ("q\n"); + + borderWidth = border->getWidth(); + if (borderWidth > 0) + setLineStyleForBorder(border); + + // Box size + const double width = rect->x2 - rect->x1; + const double height = rect->y2 - rect->y1; + + // Parse some properties from the appearance string + double fontsize; + AnnotColor *fontcolor; + parseAppearanceString(appearanceString, fontsize, fontcolor); + // Default values + if (fontsize <= 0) + fontsize = 10; + if (fontcolor == NULL) + fontcolor = new AnnotColor(0, 0, 0); // Black + if (!contents) + contents = new GooString (); + + // Draw box + GBool doFill = (color && color->getSpace() != AnnotColor::colorTransparent); + GBool doStroke = (borderWidth != 0); + if (doFill || doStroke) { + if (doStroke) { + setColor(fontcolor, gFalse); // Border color: same as font color + } + appearBuf->appendf ("{0:.2f} {0:.2f} {1:.2f} {2:.2f} re\n", borderWidth/2, width-borderWidth, height-borderWidth); + if (doFill) { + setColor(color, gTrue); + appearBuf->append(doStroke ? "B\n" : "f\n"); + } else { + appearBuf->append("S\n"); + } + } + + // Setup text clipping + const double textmargin = borderWidth * 2; + const double textwidth = width - 2*textmargin; + appearBuf->appendf ("{0:.2f} {0:.2f} {1:.2f} {2:.2f} re W n\n", textmargin, textwidth, height - 2*textmargin); + + Object fontResDict; + GfxFont *font = createAnnotDrawFont(xref, &fontResDict); + + // Set font state + setColor(fontcolor, gTrue); + appearBuf->appendf ("BT 1 0 0 1 {0:.2f} {1:.2f} Tm\n", textmargin, height - textmargin - fontsize * font->getDescent()); + appearBuf->appendf ("/AnnotDrawFont {0:.2f} Tf\n", fontsize); + + int i = 0; + double xposPrev = 0; + while (i < contents->getLength()) { + GooString out; + double linewidth, xpos; + layoutText(contents, &out, &i, font, &linewidth, textwidth/fontsize, NULL, gFalse); + linewidth *= fontsize; + switch (quadding) { + case quaddingCentered: + xpos = (textwidth - linewidth) / 2; + break; + case quaddingRightJustified: + xpos = textwidth - linewidth; + break; + default: // quaddingLeftJustified: + xpos = 0; + break; + } + appearBuf->appendf("{0:.2f} {1:.2f} Td\n", xpos - xposPrev, -fontsize); + writeString(&out, appearBuf); + appearBuf->append("Tj\n"); + xposPrev = xpos; + } + + font->decRefCnt(); + delete fontcolor; + appearBuf->append ("ET Q\n"); + + double bbox[4]; + bbox[0] = bbox[1] = 0; + bbox[2] = rect->x2 - rect->x1; + bbox[3] = rect->y2 - rect->y1; + + if (ca == 1) { + createForm(bbox, gFalse, &fontResDict, &appearance); + } else { + Object aStream, resDict; + + createForm(bbox, gTrue, &fontResDict, &aStream); + delete appearBuf; + + appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); + createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); + createForm(bbox, gFalse, &resDict, &appearance); + } + delete appearBuf; +} + +void AnnotFreeText::draw(Gfx *gfx, GBool printing) { + Object obj; + + if (!isVisible (printing)) + return; + + annotLocker(); + if (appearance.isNull()) { + generateFreeTextAppearance(); + } + + // draw the appearance stream + appearance.fetch(gfx->getXRef(), &obj); + gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, + rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); + obj.free(); +} + +// Before retrieving the res dict, regenerate the appearance stream if needed, +// because AnnotFreeText::draw needs to store font info in the res dict +Object *AnnotFreeText::getAppearanceResDict(Object *dest) { + if (appearance.isNull()) { + generateFreeTextAppearance(); + } + return Annot::getAppearanceResDict(dest); +} + +//------------------------------------------------------------------------ +// AnnotLine +//------------------------------------------------------------------------ + +AnnotLine::AnnotLine(PDFDoc *docA, PDFRectangle *rect) : + AnnotMarkup(docA, rect) { + Object obj1; + + type = typeLine; + annotObj.dictSet ("Subtype", obj1.initName ("Line")); + + initialize (docA, annotObj.getDict()); +} + +AnnotLine::AnnotLine(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { + type = typeLine; + initialize(docA, dict); +} + +AnnotLine::~AnnotLine() { + delete coord1; + delete coord2; + + if (interiorColor) + delete interiorColor; + + if (measure) + delete measure; +} + +void AnnotLine::initialize(PDFDoc *docA, Dict *dict) { + Object obj1; + + if (dict->lookup("L", &obj1)->isArray() && obj1.arrayGetLength() == 4) { + Object obj2; + double x1, y1, x2, y2; + + (obj1.arrayGet(0, &obj2)->isNum() ? x1 = obj2.getNum() : x1 = 0); + obj2.free(); + (obj1.arrayGet(1, &obj2)->isNum() ? y1 = obj2.getNum() : y1 = 0); + obj2.free(); + (obj1.arrayGet(2, &obj2)->isNum() ? x2 = obj2.getNum() : x2 = 0); + obj2.free(); + (obj1.arrayGet(3, &obj2)->isNum() ? y2 = obj2.getNum() : y2 = 0); + obj2.free(); + + coord1 = new AnnotCoord(x1, y1); + coord2 = new AnnotCoord(x2, y2); + } else { + coord1 = new AnnotCoord(); + coord2 = new AnnotCoord(); + } + obj1.free(); + + if (dict->lookup("LE", &obj1)->isArray() && obj1.arrayGetLength() == 2) { + Object obj2; + + if(obj1.arrayGet(0, &obj2)->isString()) + startStyle = parseAnnotLineEndingStyle(obj2.getString()); + else + startStyle = annotLineEndingNone; + obj2.free(); + + if(obj1.arrayGet(1, &obj2)->isString()) + endStyle = parseAnnotLineEndingStyle(obj2.getString()); + else + endStyle = annotLineEndingNone; + obj2.free(); + + } else { + startStyle = endStyle = annotLineEndingNone; + } + obj1.free(); + + if (dict->lookup("IC", &obj1)->isArray()) { + interiorColor = new AnnotColor(obj1.getArray()); + } else { + interiorColor = NULL; + } + obj1.free(); + + if (dict->lookup("LL", &obj1)->isNum()) { + leaderLineLength = obj1.getNum(); + } else { + leaderLineLength = 0; + } + obj1.free(); + + if (dict->lookup("LLE", &obj1)->isNum()) { + leaderLineExtension = obj1.getNum(); + + if (leaderLineExtension < 0) + leaderLineExtension = 0; + } else { + leaderLineExtension = 0; + } + obj1.free(); + + if (dict->lookup("Cap", &obj1)->isBool()) { + caption = obj1.getBool(); + } else { + caption = gFalse; + } + obj1.free(); + + if (dict->lookup("IT", &obj1)->isName()) { + const char *intentName = obj1.getName(); + + if(!strcmp(intentName, "LineArrow")) { + intent = intentLineArrow; + } else if(!strcmp(intentName, "LineDimension")) { + intent = intentLineDimension; + } else { + intent = intentLineArrow; + } + } else { + intent = intentLineArrow; + } + obj1.free(); + + if (dict->lookup("LLO", &obj1)->isNum()) { + leaderLineOffset = obj1.getNum(); + + if (leaderLineOffset < 0) + leaderLineOffset = 0; + } else { + leaderLineOffset = 0; + } + obj1.free(); + + if (dict->lookup("CP", &obj1)->isName()) { + const char *captionName = obj1.getName(); + + if(!strcmp(captionName, "Inline")) { + captionPos = captionPosInline; + } else if(!strcmp(captionName, "Top")) { + captionPos = captionPosTop; + } else { + captionPos = captionPosInline; + } + } else { + captionPos = captionPosInline; + } + obj1.free(); + + if (dict->lookup("Measure", &obj1)->isDict()) { + measure = NULL; + } else { + measure = NULL; + } + obj1.free(); + + if ((dict->lookup("CO", &obj1)->isArray()) && (obj1.arrayGetLength() == 2)) { + Object obj2; + + (obj1.arrayGet(0, &obj2)->isNum() ? captionTextHorizontal = obj2.getNum() : + captionTextHorizontal = 0); + obj2.free(); + (obj1.arrayGet(1, &obj2)->isNum() ? captionTextVertical = obj2.getNum() : + captionTextVertical = 0); + obj2.free(); + } else { + captionTextHorizontal = captionTextVertical = 0; + } + obj1.free(); + + if (dict->lookup("BS", &obj1)->isDict()) { + delete border; + border = new AnnotBorderBS(obj1.getDict()); + } else if (!border) { + border = new AnnotBorderBS(); + } + obj1.free(); +} + +void AnnotLine::setContents(GooString *new_content) { + Annot::setContents(new_content); + if (caption) + invalidateAppearance(); +} + +void AnnotLine::setVertices(double x1, double y1, double x2, double y2) { + Object obj1, obj2; + + delete coord1; + coord1 = new AnnotCoord(x1, y1); + delete coord2; + coord2 = new AnnotCoord(x2, y2); + + obj1.initArray(xref); + obj1.arrayAdd( obj2.initReal(x1) ); + obj1.arrayAdd( obj2.initReal(y1) ); + obj1.arrayAdd( obj2.initReal(x2) ); + obj1.arrayAdd( obj2.initReal(y2) ); + + update("L", &obj1); + invalidateAppearance(); +} + +void AnnotLine::setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end) { + Object obj1, obj2; + + startStyle = start; + endStyle = end; + + obj1.initArray(xref); + obj1.arrayAdd( obj2.initName(convertAnnotLineEndingStyle( startStyle )) ); + obj1.arrayAdd( obj2.initName(convertAnnotLineEndingStyle( endStyle )) ); + + update("LE", &obj1); + invalidateAppearance(); +} + +void AnnotLine::setInteriorColor(AnnotColor *new_color) { + delete interiorColor; + + if (new_color) { + Object obj1; + new_color->writeToObject(xref, &obj1); + update ("IC", &obj1); + interiorColor = new_color; + } else { + interiorColor = NULL; + } + invalidateAppearance(); +} + +void AnnotLine::setLeaderLineLength(double len) { + Object obj1; + + leaderLineLength = len; + obj1.initReal(len); + update ("LL", &obj1); + invalidateAppearance(); +} + +void AnnotLine::setLeaderLineExtension(double len) { + Object obj1; + + leaderLineExtension = len; + obj1.initReal(len); + update ("LLE", &obj1); + + // LL is required if LLE is present + obj1.initReal(leaderLineLength); + update ("LL", &obj1); + invalidateAppearance(); +} + +void AnnotLine::setCaption(bool new_cap) { + Object obj1; + + caption = new_cap; + obj1.initBool(new_cap); + update ("Cap", &obj1); + invalidateAppearance(); +} + +void AnnotLine::setIntent(AnnotLineIntent new_intent) { + Object obj1; + + intent = new_intent; + if (new_intent == intentLineArrow) + obj1.initName("LineArrow"); + else // intentLineDimension + obj1.initName("LineDimension"); + update ("IT", &obj1); +} + +void AnnotLine::generateLineAppearance() +{ + double borderWidth, ca = opacity; + + appearBBox = new AnnotAppearanceBBox(rect); + appearBuf = new GooString (); + appearBuf->append ("q\n"); + if (color) { + setColor(color, gFalse); + } + + setLineStyleForBorder(border); + borderWidth = border->getWidth(); + appearBBox->setBorderWidth(std::max(1., borderWidth)); + + const double x1 = coord1->getX(); + const double y1 = coord1->getY(); + const double x2 = coord2->getX(); + const double y2 = coord2->getY(); + + // Main segment length + const double main_len = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)); + + // Main segment becomes positive x direction, coord1 becomes (0,0) + Matrix matr; + const double angle = atan2(y2 - y1, x2 - x1); + matr.m[0] = matr.m[3] = cos(angle); + matr.m[1] = sin(angle); + matr.m[2] = -matr.m[1]; + matr.m[4] = x1-rect->x1; + matr.m[5] = y1-rect->y1; + + double tx, ty, captionwidth = 0, captionheight = 0; + AnnotLineCaptionPos actualCaptionPos = captionPos; + const double fontsize = 9; + const double captionhmargin = 2; // Left and right margin (inline caption only) + const double captionmaxwidth = main_len - 2 * captionhmargin; + + Object fontResDict; + GfxFont *font; + + // Calculate caption width and height + if (caption) { + font = createAnnotDrawFont(xref, &fontResDict); + int lines = 0; + int i = 0; + while (i < contents->getLength()) { + GooString out; + double linewidth; + layoutText(contents, &out, &i, font, &linewidth, 0, NULL, gFalse); + linewidth *= fontsize; + if (linewidth > captionwidth) { + captionwidth = linewidth; + } + ++lines; + } + captionheight = lines * fontsize; + // If text is longer than available space, turn into captionPosTop + if (captionwidth > captionmaxwidth) { + actualCaptionPos = captionPosTop; + } + } else { + fontResDict.initNull(); + font = NULL; + } + + // Draw main segment + matr.transform (0, leaderLineLength, &tx, &ty); + appearBuf->appendf ("{0:.2f} {1:.2f} m\n", tx, ty); + appearBBox->extendTo (tx, ty); + + if (captionwidth != 0 && actualCaptionPos == captionPosInline) { // Break in the middle + matr.transform ((main_len-captionwidth)/2 - captionhmargin, leaderLineLength, &tx, &ty); + appearBuf->appendf ("{0:.2f} {1:.2f} l S\n", tx, ty); + + matr.transform ((main_len+captionwidth)/2 + captionhmargin, leaderLineLength, &tx, &ty); + appearBuf->appendf ("{0:.2f} {1:.2f} m\n", tx, ty); + } + + matr.transform (main_len, leaderLineLength, &tx, &ty); + appearBuf->appendf ("{0:.2f} {1:.2f} l S\n", tx, ty); + appearBBox->extendTo (tx, ty); + + // TODO: Line endings + + // Draw caption text + if (caption) { + double tlx = (main_len - captionwidth) / 2, tly; // Top-left coords + if (actualCaptionPos == captionPosInline) { + tly = leaderLineLength + captionheight / 2; + } else { + tly = leaderLineLength + captionheight + 2*borderWidth; + } + + tlx += captionTextHorizontal; + tly += captionTextVertical; + + // Adjust bounding box + matr.transform (tlx, tly-captionheight, &tx, &ty); + appearBBox->extendTo (tx, ty); + matr.transform (tlx+captionwidth, tly-captionheight, &tx, &ty); + appearBBox->extendTo (tx, ty); + matr.transform (tlx+captionwidth, tly, &tx, &ty); + appearBBox->extendTo (tx, ty); + matr.transform (tlx, tly, &tx, &ty); + appearBBox->extendTo (tx, ty); + + // Setup text state (reusing transformed top-left coord) + appearBuf->appendf ("0 g BT /AnnotDrawFont {0:.2f} Tf\n", fontsize); // Font color: black + appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} Tm\n", + matr.m[0], matr.m[1], matr.m[2], matr.m[3], tx, ty); + appearBuf->appendf ("0 {0:.2f} Td\n", -fontsize * font->getDescent()); + // Draw text + int i = 0; + double xposPrev = 0; + while (i < contents->getLength()) { + GooString out; + double linewidth, xpos; + layoutText(contents, &out, &i, font, &linewidth, 0, NULL, gFalse); + linewidth *= fontsize; + xpos = (captionwidth - linewidth) / 2; + appearBuf->appendf("{0:.2f} {1:.2f} Td\n", xpos - xposPrev, -fontsize); + writeString(&out, appearBuf); + appearBuf->append ("Tj\n"); + xposPrev = xpos; + } + appearBuf->append ("ET\n"); + font->decRefCnt(); + } + + // Draw leader lines + double ll_len = fabs(leaderLineLength) + leaderLineExtension; + double sign = leaderLineLength >= 0 ? 1 : -1; + if (ll_len != 0) { + matr.transform (0, 0, &tx, &ty); + appearBuf->appendf ("{0:.2f} {1:.2f} m\n", tx, ty); + appearBBox->extendTo (tx, ty); + matr.transform (0, sign*ll_len, &tx, &ty); + appearBuf->appendf ("{0:.2f} {1:.2f} l S\n", tx, ty); + appearBBox->extendTo (tx, ty); + + matr.transform (main_len, 0, &tx, &ty); + appearBuf->appendf ("{0:.2f} {1:.2f} m\n", tx, ty); + appearBBox->extendTo (tx, ty); + matr.transform (main_len, sign*ll_len, &tx, &ty); + appearBuf->appendf ("{0:.2f} {1:.2f} l S\n", tx, ty); + appearBBox->extendTo (tx, ty); + } + + appearBuf->append ("Q\n"); + + double bbox[4]; + appearBBox->getBBoxRect(bbox); + if (ca == 1) { + createForm(bbox, gFalse, &fontResDict, &appearance); + } else { + Object aStream, resDict; + + createForm(bbox, gTrue, &fontResDict, &aStream); + delete appearBuf; + + appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); + createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); + createForm(bbox, gFalse, &resDict, &appearance); + } + delete appearBuf; +} + +void AnnotLine::draw(Gfx *gfx, GBool printing) { + Object obj; + + if (!isVisible (printing)) + return; + + annotLocker(); + if (appearance.isNull()) { + generateLineAppearance(); + } + + // draw the appearance stream + appearance.fetch(gfx->getXRef(), &obj); + if (appearBBox) { + gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, + appearBBox->getPageXMin(), appearBBox->getPageYMin(), + appearBBox->getPageXMax(), appearBBox->getPageYMax(), + getRotation()); + } else { + gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, + rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); + } + obj.free(); +} + +// Before retrieving the res dict, regenerate the appearance stream if needed, +// because AnnotLine::draw may need to store font info in the res dict +Object *AnnotLine::getAppearanceResDict(Object *dest) { + if (appearance.isNull()) { + generateLineAppearance(); + } + return Annot::getAppearanceResDict(dest); +} + +//------------------------------------------------------------------------ +// AnnotTextMarkup +//------------------------------------------------------------------------ +AnnotTextMarkup::AnnotTextMarkup(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType) : + AnnotMarkup(docA, rect) { + Object obj1; + + switch (subType) { + case typeHighlight: + annotObj.dictSet ("Subtype", obj1.initName ("Highlight")); + break; + case typeUnderline: + annotObj.dictSet ("Subtype", obj1.initName ("Underline")); + break; + case typeSquiggly: + annotObj.dictSet ("Subtype", obj1.initName ("Squiggly")); + break; + case typeStrikeOut: + annotObj.dictSet ("Subtype", obj1.initName ("StrikeOut")); + break; + default: + assert (0 && "Invalid subtype for AnnotTextMarkup\n"); + } + + // Store dummy quadrilateral with null coordinates + Object obj2, obj3; + obj2.initArray (doc->getXRef()); + for (int i = 0; i < 4*2; ++i) { + obj2.arrayAdd (obj3.initReal (0)); + } + annotObj.dictSet ("QuadPoints", &obj2); + + initialize(docA, annotObj.getDict()); +} + +AnnotTextMarkup::AnnotTextMarkup(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { + // the real type will be read in initialize() + type = typeHighlight; + initialize(docA, dict); +} + +void AnnotTextMarkup::initialize(PDFDoc *docA, Dict *dict) { + Object obj1; + + if (dict->lookup("Subtype", &obj1)->isName()) { + GooString typeName(obj1.getName()); + if (!typeName.cmp("Highlight")) { + type = typeHighlight; + } else if (!typeName.cmp("Underline")) { + type = typeUnderline; + } else if (!typeName.cmp("Squiggly")) { + type = typeSquiggly; + } else if (!typeName.cmp("StrikeOut")) { + type = typeStrikeOut; + } + } + obj1.free(); + + if(dict->lookup("QuadPoints", &obj1)->isArray()) { + quadrilaterals = new AnnotQuadrilaterals(obj1.getArray(), rect); + } else { + error(errSyntaxError, -1, "Bad Annot Text Markup QuadPoints"); + quadrilaterals = NULL; + ok = gFalse; + } + obj1.free(); +} + +AnnotTextMarkup::~AnnotTextMarkup() { + if(quadrilaterals) { + delete quadrilaterals; + } +} + +void AnnotTextMarkup::setType(AnnotSubtype new_type) { + Object obj1; + + switch (new_type) { + case typeHighlight: + obj1.initName("Highlight"); + break; + case typeUnderline: + obj1.initName("Underline"); + break; + case typeSquiggly: + obj1.initName("Squiggly"); + break; + case typeStrikeOut: + obj1.initName("StrikeOut"); + break; + default: + assert(!"Invalid subtype"); + } + + type = new_type; + update("Subtype", &obj1); + invalidateAppearance(); +} + +void AnnotTextMarkup::setQuadrilaterals(AnnotQuadrilaterals *quadPoints) { + Object obj1, obj2; + obj1.initArray (xref); + + for (int i = 0; i < quadPoints->getQuadrilateralsLength(); ++i) { + obj1.arrayAdd (obj2.initReal (quadPoints->getX1(i))); + obj1.arrayAdd (obj2.initReal (quadPoints->getY1(i))); + obj1.arrayAdd (obj2.initReal (quadPoints->getX2(i))); + obj1.arrayAdd (obj2.initReal (quadPoints->getY2(i))); + obj1.arrayAdd (obj2.initReal (quadPoints->getX3(i))); + obj1.arrayAdd (obj2.initReal (quadPoints->getY3(i))); + obj1.arrayAdd (obj2.initReal (quadPoints->getX4(i))); + obj1.arrayAdd (obj2.initReal (quadPoints->getY4(i))); + } + + delete quadrilaterals; + quadrilaterals = new AnnotQuadrilaterals(obj1.getArray(), rect); + + annotObj.dictSet ("QuadPoints", &obj1); + invalidateAppearance(); +} + +void AnnotTextMarkup::draw(Gfx *gfx, GBool printing) { + Object obj; + double ca = 1; + int i; + Object obj1, obj2; + + if (!isVisible (printing)) + return; + + annotLocker(); + if (appearance.isNull() || type == typeHighlight) { + GBool blendMultiply = gTrue; + ca = opacity; + + appearBuf = new GooString (); + appearBuf->append ("q\n"); + + /* Adjust BBox */ + delete appearBBox; + appearBBox = new AnnotAppearanceBBox(rect); + for (i = 0; i < quadrilaterals->getQuadrilateralsLength(); ++i) { + appearBBox->extendTo (quadrilaterals->getX1(i) - rect->x1, quadrilaterals->getY1(i) - rect->y1); + appearBBox->extendTo (quadrilaterals->getX2(i) - rect->x1, quadrilaterals->getY2(i) - rect->y1); + appearBBox->extendTo (quadrilaterals->getX3(i) - rect->x1, quadrilaterals->getY3(i) - rect->y1); + appearBBox->extendTo (quadrilaterals->getX4(i) - rect->x1, quadrilaterals->getY4(i) - rect->y1); + } + + switch (type) { + case typeUnderline: + if (color) { + setColor(color, gFalse); + } + appearBuf->append ("[] 0 d 1 w\n"); + + for (i = 0; i < quadrilaterals->getQuadrilateralsLength(); ++i) { + double x3, y3, x4, y4; + + x3 = quadrilaterals->getX3(i); + y3 = quadrilaterals->getY3(i); + x4 = quadrilaterals->getX4(i); + y4 = quadrilaterals->getY4(i); + + appearBuf->appendf ("{0:.2f} {1:.2f} m\n", x3, y3); + appearBuf->appendf ("{0:.2f} {1:.2f} l\n", x4, y4); + appearBuf->append ("S\n"); + } + break; + case typeStrikeOut: + if (color) { + setColor(color, gFalse); + } + blendMultiply = gFalse; + appearBuf->append ("[] 0 d 1 w\n"); + + for (i = 0; i < quadrilaterals->getQuadrilateralsLength(); ++i) { + double x1, y1, x2, y2; + double x3, y3, x4, y4; + + x1 = quadrilaterals->getX1(i); + y1 = quadrilaterals->getY1(i); + x2 = quadrilaterals->getX2(i); + y2 = quadrilaterals->getY2(i); + + x3 = quadrilaterals->getX3(i); + y3 = quadrilaterals->getY3(i); + x4 = quadrilaterals->getX4(i); + y4 = quadrilaterals->getY4(i); + + appearBuf->appendf ("{0:.2f} {1:.2f} m\n", (x1+x3)/2., (y1+y3)/2.); + appearBuf->appendf ("{0:.2f} {1:.2f} l\n", (x2+x4)/2., (y2+y4)/2.); + appearBuf->append ("S\n"); + } + break; + case typeSquiggly: + if (color) { + setColor(color, gFalse); + } + appearBuf->append ("[] 0 d 1 w\n"); + + for (i = 0; i < quadrilaterals->getQuadrilateralsLength(); ++i) { + double x1, y1, x2, y3; + double h6; + + x1 = quadrilaterals->getX1(i); + y1 = quadrilaterals->getY1(i); + x2 = quadrilaterals->getX2(i); + y3 = quadrilaterals->getY3(i); + h6 = (y1 - y3) / 6.0; + + appearBuf->appendf ("{0:.2f} {1:.2f} m\n", x1, y3+h6); + bool down = false; + do { + down = !down; // Zigzag line + x1 += 2; + appearBuf->appendf ("{0:.2f} {1:.2f} l\n", x1, y3 + (down ? 0 : h6)); + } while (x1 < x2); + appearBuf->append ("S\n"); + } + break; + default: + case typeHighlight: + appearance.free(); + + if (color) + setColor(color, gTrue); + + double biggestBorder = 0; + for (i = 0; i < quadrilaterals->getQuadrilateralsLength(); ++i) { + double x1, y1, x2, y2, x3, y3, x4, y4; + double h4; + + x1 = quadrilaterals->getX1(i); + y1 = quadrilaterals->getY1(i); + x2 = quadrilaterals->getX2(i); + y2 = quadrilaterals->getY2(i); + x3 = quadrilaterals->getX3(i); + y3 = quadrilaterals->getY3(i); + x4 = quadrilaterals->getX4(i); + y4 = quadrilaterals->getY4(i); + h4 = fabs(y1 - y3) / 4.0; + + if (h4 > biggestBorder) { + biggestBorder = h4; + } + + appearBuf->appendf ("{0:.2f} {1:.2f} m\n", x3, y3); + appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", + x3 - h4, y3 + h4, x1 - h4, y1 - h4, x1, y1); + appearBuf->appendf ("{0:.2f} {1:.2f} l\n", x2, y2); + appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", + x2 + h4, y2 - h4, x4 + h4, y4 + h4, x4, y4); + appearBuf->append ("f\n"); + } + appearBBox->setBorderWidth(biggestBorder); + break; + } + appearBuf->append ("Q\n"); + + Object aStream, resDict; + double bbox[4]; + bbox[0] = appearBBox->getPageXMin(); + bbox[1] = appearBBox->getPageYMin(); + bbox[2] = appearBBox->getPageXMax(); + bbox[3] = appearBBox->getPageYMax(); + createForm(bbox, gTrue, NULL, &aStream); + delete appearBuf; + + appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); + createResourcesDict("Fm0", &aStream, "GS0", 1, blendMultiply ? "Multiply" : NULL, &resDict); + if (ca == 1) { + createForm(bbox, gFalse, &resDict, &appearance); + } else { + createForm(bbox, gTrue, &resDict, &aStream); + delete appearBuf; + + appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); + createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); + createForm(bbox, gFalse, &resDict, &appearance); + } + delete appearBuf; + } + + // draw the appearance stream + appearance.fetch(gfx->getXRef(), &obj); + if (appearBBox) { + gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, + appearBBox->getPageXMin(), appearBBox->getPageYMin(), + appearBBox->getPageXMax(), appearBBox->getPageYMax(), + getRotation()); + } else { + gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, + rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); + } + obj.free(); +} + +//------------------------------------------------------------------------ +// AnnotWidget +//------------------------------------------------------------------------ + +AnnotWidget::AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj) : + Annot(docA, dict, obj) { + type = typeWidget; + field = NULL; + initialize(docA, dict); +} + +AnnotWidget::AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj, FormField *fieldA) : + Annot(docA, dict, obj) { + type = typeWidget; + field = fieldA; + initialize(docA, dict); +} + +AnnotWidget::~AnnotWidget() { + if (appearCharacs) + delete appearCharacs; + + if (action) + delete action; + + additionalActions.free(); + + if (parent) + delete parent; +} + +void AnnotWidget::initialize(PDFDoc *docA, Dict *dict) { + Object obj1; + + form = doc->getCatalog()->getForm(); + + if(dict->lookup("H", &obj1)->isName()) { + const char *modeName = obj1.getName(); + + if(!strcmp(modeName, "N")) { + mode = highlightModeNone; + } else if(!strcmp(modeName, "O")) { + mode = highlightModeOutline; + } else if(!strcmp(modeName, "P") || !strcmp(modeName, "T")) { + mode = highlightModePush; + } else { + mode = highlightModeInvert; + } + } else { + mode = highlightModeInvert; + } + obj1.free(); + + if(dict->lookup("MK", &obj1)->isDict()) { + appearCharacs = new AnnotAppearanceCharacs(obj1.getDict()); + } else { + appearCharacs = NULL; + } + obj1.free(); + + action = NULL; + if(dict->lookup("A", &obj1)->isDict()) { + action = LinkAction::parseAction(&obj1, doc->getCatalog()->getBaseURI()); + } + obj1.free(); + + dict->lookupNF("AA", &additionalActions); + + if(dict->lookup("Parent", &obj1)->isDict()) { + parent = NULL; + } else { + parent = NULL; + } + obj1.free(); + + if (dict->lookup("BS", &obj1)->isDict()) { + delete border; + border = new AnnotBorderBS(obj1.getDict()); + } + obj1.free(); + + updatedAppearanceStream.num = updatedAppearanceStream.gen = -1; +} + +LinkAction* AnnotWidget::getAdditionalAction(AdditionalActionsType type) +{ + return ::getAdditionalAction(type, &additionalActions, doc); +} + +LinkAction* AnnotWidget::getFormAdditionalAction(FormAdditionalActionsType type) +{ + return ::getFormAdditionalAction(type, &additionalActions, doc); +} + +// Grand unified handler for preparing text strings to be drawn into form +// fields. Takes as input a text string (in PDFDocEncoding or UTF-16). +// Converts some or all of this string to the appropriate encoding for the +// specified font, and computes the width of the text. Can optionally stop +// converting when a specified width has been reached, to perform line-breaking +// for multi-line fields. +// +// Parameters: +// text: input text string to convert +// outBuf: buffer for writing re-encoded string +// i: index at which to start converting; will be updated to point just after +// last character processed +// font: the font which will be used for display +// width: computed width (unscaled by font size) will be stored here +// widthLimit: if non-zero, stop converting to keep width under this value +// (should be scaled down by font size) +// charCount: count of number of characters will be stored here +// noReencode: if set, do not try to translate the character encoding +// (useful for Zapf Dingbats or other unusual encodings) +// can only be used with simple fonts, not CID-keyed fonts +// +// TODO: Handle surrogate pairs in UTF-16. +// Should be able to generate output for any CID-keyed font. +// Doesn't handle vertical fonts--should it? +void Annot::layoutText(GooString *text, GooString *outBuf, int *i, + GfxFont *font, double *width, double widthLimit, + int *charCount, GBool noReencode) +{ + CharCode c; + Unicode uChar, *uAux; + double w = 0.0; + int uLen, n; + double dx, dy, ox, oy; + GBool unicode = text->hasUnicodeMarker(); + GBool spacePrev; // previous character was a space + + // State for backtracking when more text has been processed than fits within + // widthLimit. We track for both input (text) and output (outBuf) the offset + // to the first character to discard. + // + // We keep track of several points: + // 1 - end of previous completed word which fits + // 2 - previous character which fit + int last_i1, last_i2, last_o1, last_o2; + + if (unicode && text->getLength() % 2 != 0) { + error(errSyntaxError, -1, "AnnotWidget::layoutText, bad unicode string"); + return; + } + + // skip Unicode marker on string if needed + if (unicode && *i == 0) + *i = 2; + + // Start decoding and copying characters, until either: + // we reach the end of the string + // we reach the maximum width + // we reach a newline character + // As we copy characters, keep track of the last full word to fit, so that we + // can backtrack if we exceed the maximum width. + last_i1 = last_i2 = *i; + last_o1 = last_o2 = 0; + spacePrev = gFalse; + outBuf->clear(); + + while (*i < text->getLength()) { + last_i2 = *i; + last_o2 = outBuf->getLength(); + + if (unicode) { + uChar = (unsigned char)(text->getChar(*i)) << 8; + uChar += (unsigned char)(text->getChar(*i + 1)); + *i += 2; + } else { + if (noReencode) + uChar = text->getChar(*i) & 0xff; + else + uChar = pdfDocEncoding[text->getChar(*i) & 0xff]; + *i += 1; + } + + // Explicit line break? + if (uChar == '\r' || uChar == '\n') { + // Treat a <CR><LF> sequence as a single line break + if (uChar == '\r' && *i < text->getLength()) { + if (unicode && text->getChar(*i) == '\0' + && text->getChar(*i + 1) == '\n') + *i += 2; + else if (!unicode && text->getChar(*i) == '\n') + *i += 1; + } + + break; + } + + if (noReencode) { + outBuf->append(uChar); + } else { + CharCodeToUnicode *ccToUnicode = font->getToUnicode(); + if (!ccToUnicode) { + // This assumes an identity CMap. + outBuf->append((uChar >> 8) & 0xff); + outBuf->append(uChar & 0xff); + } else if (ccToUnicode->mapToCharCode(&uChar, &c, 2)) { + ccToUnicode->decRefCnt(); + if (font->isCIDFont()) { + // TODO: This assumes an identity CMap. It should be extended to + // handle the general case. + outBuf->append((c >> 8) & 0xff); + outBuf->append(c & 0xff); + } else { + // 8-bit font + outBuf->append(c); + } + } else { + ccToUnicode->decRefCnt(); + error(errSyntaxError, -1, "AnnotWidget::layoutText, cannot convert U+{0:04uX}", uChar); + } + } + + // If we see a space, then we have a linebreak opportunity. + if (uChar == ' ') { + last_i1 = *i; + if (!spacePrev) + last_o1 = last_o2; + spacePrev = gTrue; + } else { + spacePrev = gFalse; + } + + // Compute width of character just output + if (outBuf->getLength() > last_o2) { + dx = 0.0; + font->getNextChar(outBuf->getCString() + last_o2, + outBuf->getLength() - last_o2, + &c, &uAux, &uLen, &dx, &dy, &ox, &oy); + w += dx; + } + + // Current line over-full now? + if (widthLimit > 0.0 && w > widthLimit) { + if (last_o1 > 0) { + // Back up to the previous word which fit, if there was a previous + // word. + *i = last_i1; + outBuf->del(last_o1, outBuf->getLength() - last_o1); + } else if (last_o2 > 0) { + // Otherwise, back up to the previous character (in the only word on + // this line) + *i = last_i2; + outBuf->del(last_o2, outBuf->getLength() - last_o2); + } else { + // Otherwise, we were trying to fit the first character; include it + // anyway even if it overflows the space--no updates to make. + } + break; + } + } + + // If splitting input into lines because we reached the width limit, then + // consume any remaining trailing spaces that would go on this line from the + // input. If in doing so we reach a newline, consume that also. This code + // won't run if we stopped at a newline above, since in that case w <= + // widthLimit still. + if (widthLimit > 0.0 && w > widthLimit) { + if (unicode) { + while (*i < text->getLength() + && text->getChar(*i) == '\0' && text->getChar(*i + 1) == ' ') + *i += 2; + if (*i < text->getLength() + && text->getChar(*i) == '\0' && text->getChar(*i + 1) == '\r') + *i += 2; + if (*i < text->getLength() + && text->getChar(*i) == '\0' && text->getChar(*i + 1) == '\n') + *i += 2; + } else { + while (*i < text->getLength() && text->getChar(*i) == ' ') + *i += 1; + if (*i < text->getLength() && text->getChar(*i) == '\r') + *i += 1; + if (*i < text->getLength() && text->getChar(*i) == '\n') + *i += 1; + } + } + + // Compute the actual width and character count of the final string, based on + // breakpoint, if this information is requested by the caller. + if (width != NULL || charCount != NULL) { + char *s = outBuf->getCString(); + int len = outBuf->getLength(); + + if (width != NULL) + *width = 0.0; + if (charCount != NULL) + *charCount = 0; + + while (len > 0) { + dx = 0.0; + n = font->getNextChar(s, len, &c, &uAux, &uLen, &dx, &dy, &ox, &oy); + + if (n == 0) { + break; + } + + if (width != NULL) + *width += dx; + if (charCount != NULL) + *charCount += 1; + + s += n; + len -= n; + } + } +} + +// Copy the given string to appearBuf, adding parentheses around it and +// escaping characters as appropriate. +void Annot::writeString(GooString *str, GooString *appearBuf) +{ + char c; + int i; + + appearBuf->append('('); + + for (i = 0; i < str->getLength(); ++i) { + c = str->getChar(i); + if (c == '(' || c == ')' || c == '\\') { + appearBuf->append('\\'); + appearBuf->append(c); + } else if (c < 0x20) { + appearBuf->appendf("\\{0:03o}", (unsigned char)c); + } else { + appearBuf->append(c); + } + } + + appearBuf->append(')'); +} + +// Draw the variable text or caption for a field. +void AnnotWidget::drawText(GooString *text, GooString *da, GfxResources *resources, + GBool multiline, int comb, int quadding, + GBool txField, GBool forceZapfDingbats, + GBool password) { + GooList *daToks; + GooString *tok, *convertedText; + GfxFont *font; + double dx, dy; + double fontSize, fontSize2, borderWidth, x, xPrev, y, w, wMax; + int tfPos, tmPos, i, j; + int rot; + GBool freeText = gFalse; // true if text should be freed before return + GBool freeFont = gFalse; + + //~ if there is no MK entry, this should use the existing content stream, + //~ and only replace the marked content portion of it + //~ (this is only relevant for Tx fields) + + // parse the default appearance string + tfPos = tmPos = -1; + if (da) { + daToks = new GooList(); + i = 0; + while (i < da->getLength()) { + while (i < da->getLength() && Lexer::isSpace(da->getChar(i))) { + ++i; + } + if (i < da->getLength()) { + for (j = i + 1; + j < da->getLength() && !Lexer::isSpace(da->getChar(j)); + ++j) ; + daToks->append(new GooString(da, i, j - i)); + i = j; + } + } + for (i = 2; i < daToks->getLength(); ++i) { + if (i >= 2 && !((GooString *)daToks->get(i))->cmp("Tf")) { + tfPos = i - 2; + } else if (i >= 6 && !((GooString *)daToks->get(i))->cmp("Tm")) { + tmPos = i - 6; + } + } + } else { + daToks = NULL; + } + + // force ZapfDingbats + if (forceZapfDingbats) { + if (tfPos >= 0) { + tok = (GooString *)daToks->get(tfPos); + if (tok->cmp("/ZaDb")) { + tok->clear(); + tok->append("/ZaDb"); + } + } + } + // get the font and font size + font = NULL; + fontSize = 0; + if (tfPos >= 0) { + tok = (GooString *)daToks->get(tfPos); + if (tok->getLength() >= 1 && tok->getChar(0) == '/') { + if (!resources || !(font = resources->lookupFont(tok->getCString() + 1))) { + if (forceZapfDingbats) { + // We are forcing ZaDb but the font does not exist + // so create a fake one + Ref r; // dummy Ref, it's not used at all in this codepath + r.num = -1; + r.gen = -1; + Dict *d = new Dict(xref); + font = new Gfx8BitFont(xref, "ZaDb", r, new GooString("ZapfDingbats"), fontType1, r, d); + delete d; + freeFont = gTrue; + addDingbatsResource = gTrue; + } else { + error(errSyntaxError, -1, "Unknown font in field's DA string"); + } + } + } else { + error(errSyntaxError, -1, "Invalid font name in 'Tf' operator in field's DA string"); + } + tok = (GooString *)daToks->get(tfPos + 1); + fontSize = gatof(tok->getCString()); + } else { + error(errSyntaxError, -1, "Missing 'Tf' operator in field's DA string"); + } + if (!font) { + if (daToks) { + deleteGooList(daToks, GooString); + } + return; + } + + // get the border width + borderWidth = border ? border->getWidth() : 0; + + // for a password field, replace all characters with asterisks + if (password) { + int len; + if (text->hasUnicodeMarker()) + len = (text->getLength() - 2) / 2; + else + len = text->getLength(); + + text = new GooString; + for (i = 0; i < len; ++i) + text->append('*'); + freeText = gTrue; + } + + convertedText = new GooString; + + // setup + if (txField) { + appearBuf->append("/Tx BMC\n"); + } + appearBuf->append("q\n"); + rot = appearCharacs ? appearCharacs->getRotation() : 0; + switch (rot) { + case 90: + appearBuf->appendf("0 1 -1 0 {0:.2f} 0 cm\n", rect->x2 - rect->x1); + dx = rect->y2 - rect->y1; + dy = rect->x2 - rect->x1; + break; + case 180: + appearBuf->appendf("-1 0 0 -1 {0:.2f} {1:.2f} cm\n", + rect->x2 - rect->x1, rect->y2 - rect->y1); + dx = rect->x2 - rect->y2; + dy = rect->y2 - rect->y1; + break; + case 270: + appearBuf->appendf("0 -1 1 0 0 {0:.2f} cm\n", rect->y2 - rect->y1); + dx = rect->y2 - rect->y1; + dy = rect->x2 - rect->x1; + break; + default: // assume rot == 0 + dx = rect->x2 - rect->x1; + dy = rect->y2 - rect->y1; + break; + } + appearBuf->append("BT\n"); + // multi-line text + if (multiline) { + // note: the comb flag is ignored in multiline mode + + wMax = dx - 2 * borderWidth - 4; + + // compute font autosize + if (fontSize == 0) { + for (fontSize = 20; fontSize > 1; --fontSize) { + y = dy - 3; + i = 0; + while (i < text->getLength()) { + layoutText(text, convertedText, &i, font, &w, wMax / fontSize, NULL, + forceZapfDingbats); + y -= fontSize; + } + // approximate the descender for the last line + if (y >= 0.33 * fontSize) { + break; + } + } + if (tfPos >= 0) { + tok = (GooString *)daToks->get(tfPos + 1); + tok->clear(); + tok->appendf("{0:.2f}", fontSize); + } + } + + // starting y coordinate + // (note: each line of text starts with a Td operator that moves + // down a line) + y = dy - 3; + + // set the font matrix + if (tmPos >= 0) { + tok = (GooString *)daToks->get(tmPos + 4); + tok->clear(); + tok->append('0'); + tok = (GooString *)daToks->get(tmPos + 5); + tok->clear(); + tok->appendf("{0:.2f}", y); + } + + // write the DA string + if (daToks) { + for (i = 0; i < daToks->getLength(); ++i) { + appearBuf->append((GooString *)daToks->get(i))->append(' '); + } + } + + // write the font matrix (if not part of the DA string) + if (tmPos < 0) { + appearBuf->appendf("1 0 0 1 0 {0:.2f} Tm\n", y); + } + + // write a series of lines of text + i = 0; + xPrev = 0; + while (i < text->getLength()) { + layoutText(text, convertedText, &i, font, &w, wMax / fontSize, NULL, + forceZapfDingbats); + w *= fontSize; + + // compute text start position + switch (quadding) { + case quaddingLeftJustified: + default: + x = borderWidth + 2; + break; + case quaddingCentered: + x = (dx - w) / 2; + break; + case quaddingRightJustified: + x = dx - borderWidth - 2 - w; + break; + } + + // draw the line + appearBuf->appendf("{0:.2f} {1:.2f} Td\n", x - xPrev, -fontSize); + writeString(convertedText, appearBuf); + appearBuf->append(" Tj\n"); + + // next line + xPrev = x; + } + + // single-line text + } else { + //~ replace newlines with spaces? - what does Acrobat do? + + // comb formatting + if (comb > 0) { + int charCount; + + // compute comb spacing + w = (dx - 2 * borderWidth) / comb; + + // compute font autosize + if (fontSize == 0) { + fontSize = dy - 2 * borderWidth; + if (w < fontSize) { + fontSize = w; + } + fontSize = floor(fontSize); + if (tfPos >= 0) { + tok = (GooString *)daToks->get(tfPos + 1); + tok->clear(); + tok->appendf("{0:.2f}", fontSize); + } + } + + i = 0; + layoutText(text, convertedText, &i, font, NULL, 0.0, &charCount, + forceZapfDingbats); + if (charCount > comb) + charCount = comb; + + // compute starting text cell + switch (quadding) { + case quaddingLeftJustified: + default: + x = borderWidth; + break; + case quaddingCentered: + x = borderWidth + (comb - charCount) / 2 * w; + break; + case quaddingRightJustified: + x = borderWidth + (comb - charCount) * w; + break; + } + y = 0.5 * dy - 0.4 * fontSize; + + // set the font matrix + if (tmPos >= 0) { + tok = (GooString *)daToks->get(tmPos + 4); + tok->clear(); + tok->appendf("{0:.2f}", x); + tok = (GooString *)daToks->get(tmPos + 5); + tok->clear(); + tok->appendf("{0:.2f}", y); + } + + // write the DA string + if (daToks) { + for (i = 0; i < daToks->getLength(); ++i) { + appearBuf->append((GooString *)daToks->get(i))->append(' '); + } + } + + // write the font matrix (if not part of the DA string) + if (tmPos < 0) { + appearBuf->appendf("1 0 0 1 {0:.2f} {1:.2f} Tm\n", x, y); + } + + // write the text string + char *s = convertedText->getCString(); + int len = convertedText->getLength(); + i = 0; + xPrev = w; // so that first character is placed properly + while (i < comb && len > 0) { + CharCode code; + Unicode *uAux; + int uLen, n; + double dx, dy, ox, oy; + + dx = 0.0; + n = font->getNextChar(s, len, &code, &uAux, &uLen, &dx, &dy, &ox, &oy); + dx *= fontSize; + + // center each character within its cell, by advancing the text + // position the appropriate amount relative to the start of the + // previous character + x = 0.5 * (w - dx); + appearBuf->appendf("{0:.2f} 0 Td\n", x - xPrev + w); + + GooString *charBuf = new GooString(s, n); + writeString(charBuf, appearBuf); + appearBuf->append(" Tj\n"); + delete charBuf; + + i++; + s += n; + len -= n; + xPrev = x; + } + + // regular (non-comb) formatting + } else { + i = 0; + layoutText(text, convertedText, &i, font, &w, 0.0, NULL, + forceZapfDingbats); + + // compute font autosize + if (fontSize == 0) { + fontSize = dy - 2 * borderWidth; + fontSize2 = (dx - 4 - 2 * borderWidth) / w; + if (fontSize2 < fontSize) { + fontSize = fontSize2; + } + fontSize = floor(fontSize); + if (tfPos >= 0) { + tok = (GooString *)daToks->get(tfPos + 1); + tok->clear(); + tok->appendf("{0:.2f}", fontSize); + } + } + + // compute text start position + w *= fontSize; + switch (quadding) { + case quaddingLeftJustified: + default: + x = borderWidth + 2; + break; + case quaddingCentered: + x = (dx - w) / 2; + break; + case quaddingRightJustified: + x = dx - borderWidth - 2 - w; + break; + } + y = 0.5 * dy - 0.4 * fontSize; + + // set the font matrix + if (tmPos >= 0) { + tok = (GooString *)daToks->get(tmPos + 4); + tok->clear(); + tok->appendf("{0:.2f}", x); + tok = (GooString *)daToks->get(tmPos + 5); + tok->clear(); + tok->appendf("{0:.2f}", y); + } + + // write the DA string + if (daToks) { + for (i = 0; i < daToks->getLength(); ++i) { + appearBuf->append((GooString *)daToks->get(i))->append(' '); + } + } + + // write the font matrix (if not part of the DA string) + if (tmPos < 0) { + appearBuf->appendf("1 0 0 1 {0:.2f} {1:.2f} Tm\n", x, y); + } + + // write the text string + writeString(convertedText, appearBuf); + appearBuf->append(" Tj\n"); + } + } + // cleanup + appearBuf->append("ET\n"); + appearBuf->append("Q\n"); + if (txField) { + appearBuf->append("EMC\n"); + } + if (daToks) { + deleteGooList(daToks, GooString); + } + if (freeText) { + delete text; + } + delete convertedText; + if (freeFont) { + font->decRefCnt(); + } +} + +// Draw the variable text or caption for a field. +void AnnotWidget::drawListBox(FormFieldChoice *fieldChoice, + GooString *da, GfxResources *resources, int quadding) { + GooList *daToks; + GooString *tok, *convertedText; + GfxFont *font; + double fontSize, fontSize2, borderWidth, x, y, w, wMax; + int tfPos, tmPos, i, j; + + //~ if there is no MK entry, this should use the existing content stream, + //~ and only replace the marked content portion of it + //~ (this is only relevant for Tx fields) + + // parse the default appearance string + tfPos = tmPos = -1; + if (da) { + daToks = new GooList(); + i = 0; + while (i < da->getLength()) { + while (i < da->getLength() && Lexer::isSpace(da->getChar(i))) { + ++i; + } + if (i < da->getLength()) { + for (j = i + 1; + j < da->getLength() && !Lexer::isSpace(da->getChar(j)); + ++j) ; + daToks->append(new GooString(da, i, j - i)); + i = j; + } + } + for (i = 2; i < daToks->getLength(); ++i) { + if (i >= 2 && !((GooString *)daToks->get(i))->cmp("Tf")) { + tfPos = i - 2; + } else if (i >= 6 && !((GooString *)daToks->get(i))->cmp("Tm")) { + tmPos = i - 6; + } + } + } else { + daToks = NULL; + } + + // get the font and font size + font = NULL; + fontSize = 0; + if (tfPos >= 0) { + tok = (GooString *)daToks->get(tfPos); + if (tok->getLength() >= 1 && tok->getChar(0) == '/') { + if (!resources || !(font = resources->lookupFont(tok->getCString() + 1))) { + error(errSyntaxError, -1, "Unknown font in field's DA string"); + } + } else { + error(errSyntaxError, -1, "Invalid font name in 'Tf' operator in field's DA string"); + } + tok = (GooString *)daToks->get(tfPos + 1); + fontSize = gatof(tok->getCString()); + } else { + error(errSyntaxError, -1, "Missing 'Tf' operator in field's DA string"); + } + if (!font) { + if (daToks) { + deleteGooList(daToks, GooString); + } + return; + } + + convertedText = new GooString; + + // get the border width + borderWidth = border ? border->getWidth() : 0; + + // compute font autosize + if (fontSize == 0) { + wMax = 0; + for (i = 0; i < fieldChoice->getNumChoices(); ++i) { + j = 0; + if (fieldChoice->getChoice(i) == NULL) { + error(errSyntaxError, -1, "Invalid annotation listbox"); + if (daToks) { + deleteGooList(daToks, GooString); + } + delete convertedText; + return; + } + layoutText(fieldChoice->getChoice(i), convertedText, &j, font, &w, 0.0, NULL, gFalse); + if (w > wMax) { + wMax = w; + } + } + fontSize = rect->y2 - rect->y1 - 2 * borderWidth; + fontSize2 = (rect->x2 - rect->x1 - 4 - 2 * borderWidth) / wMax; + if (fontSize2 < fontSize) { + fontSize = fontSize2; + } + fontSize = floor(fontSize); + if (tfPos >= 0) { + tok = (GooString *)daToks->get(tfPos + 1); + tok->clear(); + tok->appendf("{0:.2f}", fontSize); + } + } + // draw the text + y = rect->y2 - rect->y1 - 1.1 * fontSize; + for (i = fieldChoice->getTopIndex(); i < fieldChoice->getNumChoices(); ++i) { + // setup + appearBuf->append("q\n"); + + // draw the background if selected + if (fieldChoice->isSelected(i)) { + appearBuf->append("0 g f\n"); + appearBuf->appendf("{0:.2f} {1:.2f} {2:.2f} {3:.2f} re f\n", + borderWidth, + y - 0.2 * fontSize, + rect->x2 - rect->x1 - 2 * borderWidth, + 1.1 * fontSize); + } + + // setup + appearBuf->append("BT\n"); + + // compute text width and start position + j = 0; + layoutText(fieldChoice->getChoice(i), convertedText, &j, font, &w, 0.0, NULL, gFalse); + w *= fontSize; + switch (quadding) { + case quaddingLeftJustified: + default: + x = borderWidth + 2; + break; + case quaddingCentered: + x = (rect->x2 - rect->x1 - w) / 2; + break; + case quaddingRightJustified: + x = rect->x2 - rect->x1 - borderWidth - 2 - w; + break; + } + + // set the font matrix + if (tmPos >= 0) { + tok = (GooString *)daToks->get(tmPos + 4); + tok->clear(); + tok->appendf("{0:.2f}", x); + tok = (GooString *)daToks->get(tmPos + 5); + tok->clear(); + tok->appendf("{0:.2f}", y); + } + + // write the DA string + if (daToks) { + for (j = 0; j < daToks->getLength(); ++j) { + appearBuf->append((GooString *)daToks->get(j))->append(' '); + } + } + + // write the font matrix (if not part of the DA string) + if (tmPos < 0) { + appearBuf->appendf("1 0 0 1 {0:.2f} {1:.2f} Tm\n", x, y); + } + + // change the text color if selected + if (fieldChoice->isSelected(i)) { + appearBuf->append("1 g\n"); + } + + // write the text string + writeString(convertedText, appearBuf); + appearBuf->append(" Tj\n"); + + // cleanup + appearBuf->append("ET\n"); + appearBuf->append("Q\n"); + + // next line + y -= 1.1 * fontSize; + } + + if (daToks) { + deleteGooList(daToks, GooString); + } + + delete convertedText; +} + +void AnnotWidget::drawBorder() { + int dashLength; + double *dash; + AnnotColor adjustedColor; + double w = border->getWidth(); + + AnnotColor *aColor = appearCharacs->getBorderColor(); + if (!aColor) + aColor = appearCharacs->getBackColor(); + if (!aColor) + return; + + double dx = rect->x2 - rect->x1; + double dy = rect->y2 - rect->y1; + + // radio buttons with no caption have a round border + GBool hasCaption = appearCharacs->getNormalCaption() != NULL; + if (field->getType() == formButton && + static_cast<FormFieldButton*>(field)->getButtonType() == formButtonRadio && !hasCaption) { + double r = 0.5 * (dx < dy ? dx : dy); + switch (border->getStyle()) { + case AnnotBorder::borderDashed: + appearBuf->append("["); + dashLength = border->getDashLength(); + dash = border->getDash(); + for (int i = 0; i < dashLength; ++i) { + appearBuf->appendf(" {0:.2f}", dash[i]); + } + appearBuf->append("] 0 d\n"); + // fall through to the solid case + case AnnotBorder::borderSolid: + case AnnotBorder::borderUnderlined: + appearBuf->appendf("{0:.2f} w\n", w); + setColor(aColor, gFalse); + drawCircle(0.5 * dx, 0.5 * dy, r - 0.5 * w, gFalse); + break; + case AnnotBorder::borderBeveled: + case AnnotBorder::borderInset: + appearBuf->appendf("{0:.2f} w\n", 0.5 * w); + setColor(aColor, gFalse); + drawCircle(0.5 * dx, 0.5 * dy, r - 0.25 * w, gFalse); + adjustedColor = AnnotColor(*aColor); + adjustedColor.adjustColor(border->getStyle() == AnnotBorder::borderBeveled ? 1 : -1); + setColor(&adjustedColor, gFalse); + drawCircleTopLeft(0.5 * dx, 0.5 * dy, r - 0.75 * w); + adjustedColor = AnnotColor(*aColor); + adjustedColor.adjustColor(border->getStyle() == AnnotBorder::borderBeveled ? -1 : 1); + setColor(&adjustedColor, gFalse); + drawCircleBottomRight(0.5 * dx, 0.5 * dy, r - 0.75 * w); + break; + } + } else { + switch (border->getStyle()) { + case AnnotBorder::borderDashed: + appearBuf->append("["); + dashLength = border->getDashLength(); + dash = border->getDash(); + for (int i = 0; i < dashLength; ++i) { + appearBuf->appendf(" {0:.2f}", dash[i]); + } + appearBuf->append("] 0 d\n"); + // fall through to the solid case + case AnnotBorder::borderSolid: + appearBuf->appendf("{0:.2f} w\n", w); + setColor(aColor, gFalse); + appearBuf->appendf("{0:.2f} {0:.2f} {1:.2f} {2:.2f} re s\n", + 0.5 * w, dx - w, dy - w); + break; + case AnnotBorder::borderBeveled: + case AnnotBorder::borderInset: + adjustedColor = AnnotColor(*aColor); + adjustedColor.adjustColor(border->getStyle() == AnnotBorder::borderBeveled ? 1 : -1); + setColor(&adjustedColor, gTrue); + appearBuf->append("0 0 m\n"); + appearBuf->appendf("0 {0:.2f} l\n", dy); + appearBuf->appendf("{0:.2f} {1:.2f} l\n", dx, dy); + appearBuf->appendf("{0:.2f} {1:.2f} l\n", dx - w, dy - w); + appearBuf->appendf("{0:.2f} {1:.2f} l\n", w, dy - w); + appearBuf->appendf("{0:.2f} {0:.2f} l\n", w); + appearBuf->append("f\n"); + adjustedColor = AnnotColor(*aColor); + adjustedColor.adjustColor(border->getStyle() == AnnotBorder::borderBeveled ? -1 : 1); + setColor(&adjustedColor, gTrue); + appearBuf->append("0 0 m\n"); + appearBuf->appendf("{0:.2f} 0 l\n", dx); + appearBuf->appendf("{0:.2f} {1:.2f} l\n", dx, dy); + appearBuf->appendf("{0:.2f} {1:.2f} l\n", dx - w, dy - w); + appearBuf->appendf("{0:.2f} {1:.2f} l\n", dx - w, w); + appearBuf->appendf("{0:.2f} {0:.2f} l\n", w); + appearBuf->append("f\n"); + break; + case AnnotBorder::borderUnderlined: + appearBuf->appendf("{0:.2f} w\n", w); + setColor(aColor, gFalse); + appearBuf->appendf("0 0 m {0:.2f} 0 l s\n", dx); + break; + } + + // clip to the inside of the border + appearBuf->appendf("{0:.2f} {0:.2f} {1:.2f} {2:.2f} re W n\n", + w, dx - 2 * w, dy - 2 * w); + } +} + +void AnnotWidget::drawFormFieldButton(GfxResources *resources, GooString *da) { + GooString *caption = NULL; + if (appearCharacs) + caption = appearCharacs->getNormalCaption(); + + switch (static_cast<FormFieldButton *>(field)->getButtonType()) { + case formButtonRadio: { + //~ Acrobat doesn't draw a caption if there is no AP dict (?) + if (appearState && appearState->cmp("Off") != 0 && + static_cast<FormFieldButton *>(field)->getState(appearState->getCString())) { + if (caption) { + drawText(caption, da, resources, gFalse, 0, fieldQuadCenter, + gFalse, gTrue); + } else if (appearCharacs) { + AnnotColor *aColor = appearCharacs->getBorderColor(); + if (aColor) { + double dx = rect->x2 - rect->x1; + double dy = rect->y2 - rect->y1; + setColor(aColor, gTrue); + drawCircle(0.5 * dx, 0.5 * dy, 0.2 * (dx < dy ? dx : dy), gTrue); + } + } + } + } + break; + case formButtonPush: + if (caption) + drawText(caption, da, resources, gFalse, 0, fieldQuadCenter, gFalse, gFalse); + break; + case formButtonCheck: + if (appearState && appearState->cmp("Off") != 0) { + if (!caption) { + GooString checkMark("3"); + drawText(&checkMark, da, resources, gFalse, 0, fieldQuadCenter, gFalse, gTrue); + } else { + drawText(caption, da, resources, gFalse, 0, fieldQuadCenter, gFalse, gTrue); + } + } + break; + } +} + +void AnnotWidget::drawFormFieldText(GfxResources *resources, GooString *da) { + VariableTextQuadding quadding; + GooString *contents; + FormFieldText *fieldText = static_cast<FormFieldText *>(field); + + contents = fieldText->getContent(); + if (contents) { + quadding = field->hasTextQuadding() ? field->getTextQuadding() : form->getTextQuadding(); + + int comb = 0; + if (fieldText->isComb()) + comb = fieldText->getMaxLen(); + + drawText(contents, da, resources, + fieldText->isMultiline(), comb, quadding, gTrue, gFalse, fieldText->isPassword()); + } +} + +void AnnotWidget::drawFormFieldChoice(GfxResources *resources, GooString *da) { + GooString *selected; + VariableTextQuadding quadding; + FormFieldChoice *fieldChoice = static_cast<FormFieldChoice *>(field); + + quadding = field->hasTextQuadding() ? field->getTextQuadding() : form->getTextQuadding(); + + if (fieldChoice->isCombo()) { + selected = fieldChoice->getSelectedChoice(); + if (selected) { + drawText(selected, da, resources, gFalse, 0, quadding, gTrue, gFalse); + //~ Acrobat draws a popup icon on the right side + } + // list box + } else { + drawListBox(fieldChoice, da, resources, quadding); + } +} + +void AnnotWidget::generateFieldAppearance() { + Object appearDict, obj1, obj2; + GfxResources *resources; + MemStream *appearStream; + GooString *da; + + appearBuf = new GooString (); + + // draw the background + if (appearCharacs) { + AnnotColor *aColor = appearCharacs->getBackColor(); + if (aColor) { + setColor(aColor, gTrue); + appearBuf->appendf("0 0 {0:.2f} {1:.2f} re f\n", + rect->x2 - rect->x1, rect->y2 - rect->y1); + } + } + + // draw the border + if (appearCharacs && border && border->getWidth() > 0) + drawBorder(); + + da = field->getDefaultAppearance(); + if (!da) + da = form->getDefaultAppearance(); + + resources = form->getDefaultResources(); + + // draw the field contents + switch (field->getType()) { + case formButton: + drawFormFieldButton(resources, da); + break; + case formText: + drawFormFieldText(resources, da); + break; + case formChoice: + drawFormFieldChoice(resources, da); + break; + case formSignature: + //~unimp + break; + case formUndef: + default: + error(errSyntaxError, -1, "Unknown field type"); + } + + // build the appearance stream dictionary + appearDict.initDict(xref); + appearDict.dictAdd(copyString("Length"), + obj1.initInt(appearBuf->getLength())); + appearDict.dictAdd(copyString("Subtype"), obj1.initName("Form")); + obj1.initArray(xref); + obj1.arrayAdd(obj2.initReal(0)); + obj1.arrayAdd(obj2.initReal(0)); + obj1.arrayAdd(obj2.initReal(rect->x2 - rect->x1)); + obj1.arrayAdd(obj2.initReal(rect->y2 - rect->y1)); + appearDict.dictAdd(copyString("BBox"), &obj1); + + // set the resource dictionary + Object *resDict = form->getDefaultResourcesObj(); + if (resDict->isDict()) { + appearDict.dictAdd(copyString("Resources"), resDict->copy(&obj1)); + } + + // build the appearance stream + appearStream = new MemStream(copyString(appearBuf->getCString()), 0, + appearBuf->getLength(), &appearDict); + appearance.free(); + appearance.initStream(appearStream); + delete appearBuf; + + appearStream->setNeedFree(gTrue); +} + +void AnnotWidget::updateAppearanceStream() +{ + // If this the first time updateAppearanceStream() is called on this widget, + // destroy the AP dictionary because we are going to create a new one. + if (updatedAppearanceStream.num == -1) { + invalidateAppearance(); // Delete AP dictionary and all referenced streams + } + + // There's no need to create a new appearance stream if NeedAppearances is + // set, because it will be ignored next time anyway. + if (form && form->getNeedAppearances()) + return; + + // Create the new appearance + generateFieldAppearance(); + + // Fetch the appearance stream we've just created + Object obj1; + appearance.fetch(xref, &obj1); + + // If this the first time updateAppearanceStream() is called on this widget, + // create a new AP dictionary containing the new appearance stream. + // Otherwise, just update the stream we had created previously. + if (updatedAppearanceStream.num == -1) { + // Write the appearance stream + updatedAppearanceStream = xref->addIndirectObject(&obj1); + obj1.free(); + + // Write the AP dictionary + Object obj2; + obj1.initDict(xref); + obj1.dictAdd(copyString("N"), obj2.initRef(updatedAppearanceStream.num, updatedAppearanceStream.gen)); + update("AP", &obj1); + + // Update our internal pointers to the appearance dictionary + appearStreams = new AnnotAppearance(doc, &obj1); + } else { + // Replace the existing appearance stream + xref->setModifiedObject(&obj1, updatedAppearanceStream); + obj1.free(); + } +} + +void AnnotWidget::draw(Gfx *gfx, GBool printing) { + Object obj; + + if (!isVisible (printing)) + return; + + annotLocker(); + addDingbatsResource = gFalse; + + // Only construct the appearance stream when + // - annot doesn't have an AP or + // - NeedAppearances is true + if (field) { + if (appearance.isNull() || (form && form->getNeedAppearances())) + generateFieldAppearance(); + } + + // draw the appearance stream + appearance.fetch(gfx->getXRef(), &obj); + if (addDingbatsResource) { + // We are forcing ZaDb but the font does not exist + // so create a fake one + Object baseFontObj, subtypeObj; + baseFontObj.initName("ZapfDingbats"); + subtypeObj.initName("Type1"); + + Object fontDictObj; + Dict *fontDict = new Dict(gfx->getXRef()); + fontDict->decRef(); + fontDict->add(copyString("BaseFont"), &baseFontObj); + fontDict->add(copyString("Subtype"), &subtypeObj); + fontDictObj.initDict(fontDict); + + Object fontsDictObj; + Dict *fontsDict = new Dict(gfx->getXRef()); + fontsDict->decRef(); + fontsDict->add(copyString("ZaDb"), &fontDictObj); + fontsDictObj.initDict(fontsDict); + + Dict *dict = new Dict(gfx->getXRef()); + dict->add(copyString("Font"), &fontsDictObj); + gfx->pushResources(dict); + delete dict; + } + gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, + rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); + if (addDingbatsResource) { + gfx->popResources(); + } + obj.free(); +} + + +//------------------------------------------------------------------------ +// AnnotMovie +//------------------------------------------------------------------------ +AnnotMovie::AnnotMovie(PDFDoc *docA, PDFRectangle *rect, Movie *movieA) : + Annot(docA, rect) { + Object obj1; + + type = typeMovie; + annotObj.dictSet ("Subtype", obj1.initName ("Movie")); + + movie = movieA->copy(); + // TODO: create movie dict from movieA + + initialize(docA, annotObj.getDict()); +} + +AnnotMovie::AnnotMovie(PDFDoc *docA, Dict *dict, Object *obj) : + Annot(docA, dict, obj) { + type = typeMovie; + initialize(docA, dict); +} + +AnnotMovie::~AnnotMovie() { + if (title) + delete title; + delete movie; +} + +void AnnotMovie::initialize(PDFDoc *docA, Dict* dict) { + Object obj1; + + if (dict->lookup("T", &obj1)->isString()) { + title = obj1.getString()->copy(); + } else { + title = NULL; + } + obj1.free(); + + Object movieDict; + if (dict->lookup("Movie", &movieDict)->isDict()) { + Object obj2; + dict->lookup("A", &obj2); + if (obj2.isDict()) + movie = new Movie (&movieDict, &obj2); + else + movie = new Movie (&movieDict); + if (!movie->isOk()) { + delete movie; + movie = NULL; + ok = gFalse; + } + obj2.free(); + } else { + error(errSyntaxError, -1, "Bad Annot Movie"); + movie = NULL; + ok = gFalse; + } + movieDict.free(); +} + +void AnnotMovie::draw(Gfx *gfx, GBool printing) { + Object obj; + + if (!isVisible (printing)) + return; + + annotLocker(); + if (appearance.isNull() && movie->getShowPoster()) { + int width, height; + Object poster; + movie->getPoster(&poster); + movie->getAspect(&width, &height); + + if (width != -1 && height != -1 && !poster.isNone()) { + MemStream *mStream; + + appearBuf = new GooString (); + appearBuf->append ("q\n"); + appearBuf->appendf ("{0:d} 0 0 {1:d} 0 0 cm\n", width, height); + appearBuf->append ("/MImg Do\n"); + appearBuf->append ("Q\n"); + + Object imgDict; + imgDict.initDict(gfx->getXRef()); + imgDict.dictSet ("MImg", &poster); + + Object resDict; + resDict.initDict(gfx->getXRef()); + resDict.dictSet ("XObject", &imgDict); + + Object formDict, obj1, obj2; + formDict.initDict(gfx->getXRef()); + formDict.dictSet("Length", obj1.initInt(appearBuf->getLength())); + formDict.dictSet("Subtype", obj1.initName("Form")); + formDict.dictSet("Name", obj1.initName("FRM")); + obj1.initArray(gfx->getXRef()); + obj1.arrayAdd(obj2.initInt(0)); + obj1.arrayAdd(obj2.initInt(0)); + obj1.arrayAdd(obj2.initInt(width)); + obj1.arrayAdd(obj2.initInt(height)); + formDict.dictSet("BBox", &obj1); + obj1.initArray(gfx->getXRef()); + obj1.arrayAdd(obj2.initInt(1)); + obj1.arrayAdd(obj2.initInt(0)); + obj1.arrayAdd(obj2.initInt(0)); + obj1.arrayAdd(obj2.initInt(1)); + obj1.arrayAdd(obj2.initInt(-width / 2)); + obj1.arrayAdd(obj2.initInt(-height / 2)); + formDict.dictSet("Matrix", &obj1); + formDict.dictSet("Resources", &resDict); + + Object aStream; + mStream = new MemStream(copyString(appearBuf->getCString()), 0, + appearBuf->getLength(), &formDict); + mStream->setNeedFree(gTrue); + aStream.initStream(mStream); + delete appearBuf; + + Object objDict; + objDict.initDict(gfx->getXRef()); + objDict.dictSet ("FRM", &aStream); + + resDict.initDict(gfx->getXRef()); + resDict.dictSet ("XObject", &objDict); + + appearBuf = new GooString (); + appearBuf->append ("q\n"); + appearBuf->appendf ("0 0 {0:d} {1:d} re W n\n", width, height); + appearBuf->append ("q\n"); + appearBuf->appendf ("0 0 {0:d} {1:d} re W n\n", width, height); + appearBuf->appendf ("1 0 0 1 {0:d} {1:d} cm\n", width / 2, height / 2); + appearBuf->append ("/FRM Do\n"); + appearBuf->append ("Q\n"); + appearBuf->append ("Q\n"); + + double bbox[4]; + bbox[0] = bbox[1] = 0; + bbox[2] = width; + bbox[3] = height; + createForm(bbox, gFalse, &resDict, &appearance); + delete appearBuf; + } + poster.free(); + } + + // draw the appearance stream + appearance.fetch(gfx->getXRef(), &obj); + gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, + rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); + obj.free(); +} + +//------------------------------------------------------------------------ +// AnnotScreen +//------------------------------------------------------------------------ +AnnotScreen::AnnotScreen(PDFDoc *docA, PDFRectangle *rect) : + Annot(docA, rect) { + Object obj1; + + type = typeScreen; + + annotObj.dictSet ("Subtype", obj1.initName ("Screen")); + initialize(docA, annotObj.getDict()); +} + +AnnotScreen::AnnotScreen(PDFDoc *docA, Dict *dict, Object *obj) : + Annot(docA, dict, obj) { + type = typeScreen; + initialize(docA, dict); +} + +AnnotScreen::~AnnotScreen() { + if (title) + delete title; + if (appearCharacs) + delete appearCharacs; + if (action) + delete action; + + additionalActions.free(); +} + +void AnnotScreen::initialize(PDFDoc *docA, Dict* dict) { + Object obj1; + + title = NULL; + if (dict->lookup("T", &obj1)->isString()) { + title = obj1.getString()->copy(); + } + obj1.free(); + + action = NULL; + if (dict->lookup("A", &obj1)->isDict()) { + action = LinkAction::parseAction(&obj1, doc->getCatalog()->getBaseURI()); + if (action->getKind() == actionRendition && page == 0) { + error (errSyntaxError, -1, "Invalid Rendition action: associated screen annotation without P"); + delete action; + action = NULL; + ok = gFalse; + } + } + obj1.free(); + + dict->lookupNF("AA", &additionalActions); + + appearCharacs = NULL; + if(dict->lookup("MK", &obj1)->isDict()) { + appearCharacs = new AnnotAppearanceCharacs(obj1.getDict()); + } + obj1.free(); +} + +LinkAction* AnnotScreen::getAdditionalAction(AdditionalActionsType type) +{ + if (type == actionFocusIn || type == actionFocusOut) // not defined for screen annotation + return NULL; + + return ::getAdditionalAction(type, &additionalActions, doc); +} + +//------------------------------------------------------------------------ +// AnnotStamp +//------------------------------------------------------------------------ +AnnotStamp::AnnotStamp(PDFDoc *docA, PDFRectangle *rect) : + AnnotMarkup(docA, rect) { + Object obj1; + + type = typeStamp; + annotObj.dictSet ("Subtype", obj1.initName ("Stamp")); + initialize(docA, annotObj.getDict()); +} + +AnnotStamp::AnnotStamp(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { + type = typeStamp; + initialize(docA, dict); +} + +AnnotStamp::~AnnotStamp() { + delete icon; +} + +void AnnotStamp::initialize(PDFDoc *docA, Dict* dict) { + Object obj1; + + if (dict->lookup("Name", &obj1)->isName()) { + icon = new GooString(obj1.getName()); + } else { + icon = new GooString("Draft"); + } + obj1.free(); + +} + +void AnnotStamp::setIcon(GooString *new_icon) { + delete icon; + + if (new_icon) { + icon = new GooString (new_icon); + } else { + icon = new GooString(); + } + + Object obj1; + obj1.initName (icon->getCString()); + update("Name", &obj1); + invalidateAppearance(); +} + +//------------------------------------------------------------------------ +// AnnotGeometry +//------------------------------------------------------------------------ +AnnotGeometry::AnnotGeometry(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType) : + AnnotMarkup(docA, rect) { + Object obj1; + + switch (subType) { + case typeSquare: + annotObj.dictSet ("Subtype", obj1.initName ("Square")); + break; + case typeCircle: + annotObj.dictSet ("Subtype", obj1.initName ("Circle")); + break; + default: + assert (0 && "Invalid subtype for AnnotGeometry\n"); + } + + initialize(docA, annotObj.getDict()); +} + +AnnotGeometry::AnnotGeometry(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { + // the real type will be read in initialize() + type = typeSquare; + initialize(docA, dict); +} + +AnnotGeometry::~AnnotGeometry() { + delete interiorColor; + delete borderEffect; + delete geometryRect; +} + +void AnnotGeometry::initialize(PDFDoc *docA, Dict* dict) { + Object obj1; + + if (dict->lookup("Subtype", &obj1)->isName()) { + GooString typeName(obj1.getName()); + if (!typeName.cmp("Square")) { + type = typeSquare; + } else if (!typeName.cmp("Circle")) { + type = typeCircle; + } + } + obj1.free(); + + if (dict->lookup("IC", &obj1)->isArray()) { + interiorColor = new AnnotColor(obj1.getArray()); + } else { + interiorColor = NULL; + } + obj1.free(); + + if (dict->lookup("BS", &obj1)->isDict()) { + delete border; + border = new AnnotBorderBS(obj1.getDict()); + } else if (!border) { + border = new AnnotBorderBS(); + } + obj1.free(); + + if (dict->lookup("BE", &obj1)->isDict()) { + borderEffect = new AnnotBorderEffect(obj1.getDict()); + } else { + borderEffect = NULL; + } + obj1.free(); + + geometryRect = NULL; + if (dict->lookup("RD", &obj1)->isArray()) { + geometryRect = parseDiffRectangle(obj1.getArray(), rect); + } + obj1.free(); + +} + +void AnnotGeometry::setType(AnnotSubtype new_type) { + Object obj1; + + switch (new_type) { + case typeSquare: + obj1.initName("Square"); + break; + case typeCircle: + obj1.initName("Circle"); + break; + default: + assert(!"Invalid subtype"); + } + + type = new_type; + update("Subtype", &obj1); + invalidateAppearance(); +} + +void AnnotGeometry::setInteriorColor(AnnotColor *new_color) { + delete interiorColor; + + if (new_color) { + Object obj1; + new_color->writeToObject(xref, &obj1); + update ("IC", &obj1); + interiorColor = new_color; + } else { + interiorColor = NULL; + } + invalidateAppearance(); +} + +void AnnotGeometry::draw(Gfx *gfx, GBool printing) { + Object obj; + double ca = 1; + + if (!isVisible (printing)) + return; + + annotLocker(); + if (appearance.isNull()) { + ca = opacity; + + appearBuf = new GooString (); + appearBuf->append ("q\n"); + if (color) + setColor(color, gFalse); + + double borderWidth = border->getWidth(); + setLineStyleForBorder(border); + + if (interiorColor) + setColor(interiorColor, gTrue); + + if (type == typeSquare) { + appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} re\n", + borderWidth / 2.0, borderWidth / 2.0, + (rect->x2 - rect->x1) - borderWidth, + (rect->y2 - rect->y1) - borderWidth); + } else { + double width, height; + double b; + double x1, y1, x2, y2, x3, y3; + + width = rect->x2 - rect->x1; + height = rect->y2 - rect->y1; + b = borderWidth / 2.0; + + x1 = b; + y1 = height / 2.0; + appearBuf->appendf ("{0:.2f} {1:.2f} m\n", x1, y1); + + y1 += height / 4.0; + x2 = width / 4.0; + y2 = height - b; + x3 = width / 2.0; + y3 = y2; + appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", + x1, y1, x2, y2, x3, y3); + x2 = width - b; + y2 = y1; + x1 = x3 + (width / 4.0); + y1 = y3; + x3 = x2; + y3 = height / 2.0; + appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", + x1, y1, x2, y2, x3, y3); + + x2 = x1; + y2 = b; + x1 = x3; + y1 = height / 4.0; + x3 = width / 2.0; + y3 = b; + appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", + x1, y1, x2, y2, x3, y3); + + x2 = b; + y2 = y1; + x1 = width / 4.0; + y1 = b; + x3 = b; + y3 = height / 2.0; + appearBuf->appendf ("{0:.2f} {1:.2f} {2:.2f} {3:.2f} {4:.2f} {5:.2f} c\n", + x1, y1, x2, y2, x3, y3); + } + + if (interiorColor && interiorColor->getSpace() != AnnotColor::colorTransparent) + appearBuf->append ("b\n"); + else + appearBuf->append ("S\n"); + + appearBuf->append ("Q\n"); + + double bbox[4]; + bbox[0] = bbox[1] = 0; + bbox[2] = rect->x2 - rect->x1; + bbox[3] = rect->y2 - rect->y1; + if (ca == 1) { + createForm(bbox, gFalse, NULL, &appearance); + } else { + Object aStream; + + createForm(bbox, gTrue, NULL, &aStream); + delete appearBuf; + + Object resDict; + appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); + createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); + createForm(bbox, gFalse, &resDict, &appearance); + } + delete appearBuf; + } + + // draw the appearance stream + appearance.fetch(gfx->getXRef(), &obj); + gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, + rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); + obj.free(); +} + +//------------------------------------------------------------------------ +// AnnotPolygon +//------------------------------------------------------------------------ +AnnotPolygon::AnnotPolygon(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType) : + AnnotMarkup(docA, rect) { + Object obj1; + + switch (subType) { + case typePolygon: + annotObj.dictSet ("Subtype", obj1.initName ("Polygon")); + break; + case typePolyLine: + annotObj.dictSet ("Subtype", obj1.initName ("PolyLine")); + break; + default: + assert (0 && "Invalid subtype for AnnotGeometry\n"); + } + + // Store dummy path with one null vertex only + Object obj2, obj3; + obj2.initArray (doc->getXRef()); + obj2.arrayAdd (obj3.initReal (0)); + obj2.arrayAdd (obj3.initReal (0)); + annotObj.dictSet ("Vertices", &obj2); + + initialize(docA, annotObj.getDict()); +} + +AnnotPolygon::AnnotPolygon(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { + // the real type will be read in initialize() + type = typePolygon; + initialize(docA, dict); +} + +AnnotPolygon::~AnnotPolygon() { + delete vertices; + + if (interiorColor) + delete interiorColor; + + if (borderEffect) + delete borderEffect; +} + +void AnnotPolygon::initialize(PDFDoc *docA, Dict* dict) { + Object obj1; + + if (dict->lookup("Subtype", &obj1)->isName()) { + GooString typeName(obj1.getName()); + if (!typeName.cmp("Polygon")) { + type = typePolygon; + } else if (!typeName.cmp("PolyLine")) { + type = typePolyLine; + } + } + obj1.free(); + + if (dict->lookup("Vertices", &obj1)->isArray()) { + vertices = new AnnotPath(obj1.getArray()); + } else { + vertices = new AnnotPath(); + error(errSyntaxError, -1, "Bad Annot Polygon Vertices"); + ok = gFalse; + } + obj1.free(); + + if (dict->lookup("LE", &obj1)->isArray() && obj1.arrayGetLength() == 2) { + Object obj2; + + if(obj1.arrayGet(0, &obj2)->isString()) + startStyle = parseAnnotLineEndingStyle(obj2.getString()); + else + startStyle = annotLineEndingNone; + obj2.free(); + + if(obj1.arrayGet(1, &obj2)->isString()) + endStyle = parseAnnotLineEndingStyle(obj2.getString()); + else + endStyle = annotLineEndingNone; + obj2.free(); + + } else { + startStyle = endStyle = annotLineEndingNone; + } + obj1.free(); + + if (dict->lookup("IC", &obj1)->isArray()) { + interiorColor = new AnnotColor(obj1.getArray()); + } else { + interiorColor = NULL; + } + obj1.free(); + + if (dict->lookup("BS", &obj1)->isDict()) { + delete border; + border = new AnnotBorderBS(obj1.getDict()); + } else if (!border) { + border = new AnnotBorderBS(); + } + obj1.free(); + + if (dict->lookup("BE", &obj1)->isDict()) { + borderEffect = new AnnotBorderEffect(obj1.getDict()); + } else { + borderEffect = NULL; + } + obj1.free(); + + if (dict->lookup("IT", &obj1)->isName()) { + const char *intentName = obj1.getName(); + + if(!strcmp(intentName, "PolygonCloud")) { + intent = polygonCloud; + } else if(!strcmp(intentName, "PolyLineDimension")) { + intent = polylineDimension; + } else { + intent = polygonDimension; + } + } else { + intent = polygonCloud; + } + obj1.free(); +} + +void AnnotPolygon::setType(AnnotSubtype new_type) { + Object obj1; + + switch (new_type) { + case typePolygon: + obj1.initName("Polygon"); + break; + case typePolyLine: + obj1.initName("PolyLine"); + break; + default: + assert(!"Invalid subtype"); + } + + type = new_type; + update("Subtype", &obj1); + invalidateAppearance(); +} + +void AnnotPolygon::setVertices(AnnotPath *path) { + Object obj1, obj2; + delete vertices; + + obj1.initArray(xref); + + for (int i = 0; i < path->getCoordsLength(); i++) { + obj1.arrayAdd (obj2.initReal (path->getX(i))); + obj1.arrayAdd (obj2.initReal (path->getY(i))); + } + + vertices = new AnnotPath(obj1.getArray()); + + update("Vertices", &obj1); + invalidateAppearance(); +} + +void AnnotPolygon::setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end) { + Object obj1, obj2; + + startStyle = start; + endStyle = end; + + obj1.initArray(xref); + obj1.arrayAdd( obj2.initName(convertAnnotLineEndingStyle( startStyle )) ); + obj1.arrayAdd( obj2.initName(convertAnnotLineEndingStyle( endStyle )) ); + + update("LE", &obj1); + invalidateAppearance(); +} + +void AnnotPolygon::setInteriorColor(AnnotColor *new_color) { + delete interiorColor; + + if (new_color) { + Object obj1; + new_color->writeToObject(xref, &obj1); + update ("IC", &obj1); + interiorColor = new_color; + } else { + interiorColor = NULL; + } + invalidateAppearance(); +} + +void AnnotPolygon::setIntent(AnnotPolygonIntent new_intent) { + Object obj1; + + intent = new_intent; + if (new_intent == polygonCloud) + obj1.initName("PolygonCloud"); + else if (new_intent == polylineDimension) + obj1.initName("PolyLineDimension"); + else // polygonDimension + obj1.initName("PolygonDimension"); + update ("IT", &obj1); +} + +void AnnotPolygon::draw(Gfx *gfx, GBool printing) { + Object obj; + double ca = 1; + + if (!isVisible (printing)) + return; + + annotLocker(); + if (appearance.isNull()) { + appearBBox = new AnnotAppearanceBBox(rect); + ca = opacity; + + appearBuf = new GooString (); + appearBuf->append ("q\n"); + + if (color) { + setColor(color, gFalse); + } + + setLineStyleForBorder(border); + appearBBox->setBorderWidth(std::max(1., border->getWidth())); + + if (interiorColor) { + setColor(interiorColor, gTrue); + } + + if (vertices->getCoordsLength() != 0) { + appearBuf->appendf ("{0:.2f} {1:.2f} m\n", vertices->getX(0) - rect->x1, vertices->getY(0) - rect->y1); + appearBBox->extendTo (vertices->getX(0) - rect->x1, vertices->getY(0) - rect->y1); + + for (int i = 1; i < vertices->getCoordsLength(); ++i) { + appearBuf->appendf ("{0:.2f} {1:.2f} l\n", vertices->getX(i) - rect->x1, vertices->getY(i) - rect->y1); + appearBBox->extendTo (vertices->getX(i) - rect->x1, vertices->getY(i) - rect->y1); + } + + if (type == typePolygon) { + if (interiorColor && interiorColor->getSpace() != AnnotColor::colorTransparent) { + appearBuf->append ("b\n"); + } else { + appearBuf->append ("s\n"); + } + } else { + appearBuf->append ("S\n"); + } + } + + appearBuf->append ("Q\n"); + + double bbox[4]; + appearBBox->getBBoxRect(bbox); + if (ca == 1) { + createForm(bbox, gFalse, NULL, &appearance); + } else { + Object aStream, resDict; + + createForm(bbox, gTrue, NULL, &aStream); + delete appearBuf; + + appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); + createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); + createForm(bbox, gFalse, &resDict, &appearance); + } + delete appearBuf; + } + + // draw the appearance stream + appearance.fetch(gfx->getXRef(), &obj); + if (appearBBox) { + gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, + appearBBox->getPageXMin(), appearBBox->getPageYMin(), + appearBBox->getPageXMax(), appearBBox->getPageYMax(), + getRotation()); + } else { + gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, + rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); + } + obj.free(); +} + +//------------------------------------------------------------------------ +// AnnotCaret +//------------------------------------------------------------------------ +AnnotCaret::AnnotCaret(PDFDoc *docA, PDFRectangle *rect) : + AnnotMarkup(docA, rect) { + Object obj1; + + type = typeCaret; + + annotObj.dictSet ("Subtype", obj1.initName ("Caret")); + initialize(docA, annotObj.getDict()); +} + +AnnotCaret::AnnotCaret(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { + type = typeCaret; + initialize(docA, dict); +} + +AnnotCaret::~AnnotCaret() { + delete caretRect; +} + +void AnnotCaret::initialize(PDFDoc *docA, Dict* dict) { + Object obj1; + + symbol = symbolNone; + if (dict->lookup("Sy", &obj1)->isName()) { + GooString typeName(obj1.getName()); + if (!typeName.cmp("P")) { + symbol = symbolP; + } else if (!typeName.cmp("None")) { + symbol = symbolNone; + } + } + obj1.free(); + + if (dict->lookup("RD", &obj1)->isArray()) { + caretRect = parseDiffRectangle(obj1.getArray(), rect); + } else { + caretRect = NULL; + } + obj1.free(); + +} + +void AnnotCaret::setSymbol(AnnotCaretSymbol new_symbol) { + Object obj1; + obj1.initName( new_symbol == symbolP ? "P" : "None" ); + symbol = new_symbol; + update("Sy", &obj1); + invalidateAppearance(); +} + +//------------------------------------------------------------------------ +// AnnotInk +//------------------------------------------------------------------------ +AnnotInk::AnnotInk(PDFDoc *docA, PDFRectangle *rect) : + AnnotMarkup(docA, rect) { + Object obj1; + + type = typeInk; + + annotObj.dictSet ("Subtype", obj1.initName ("Ink")); + + // Store dummy path with one null vertex only + Object obj2, obj3, obj4; + obj2.initArray (doc->getXRef()); + obj2.arrayAdd (obj3.initArray (doc->getXRef())); + obj3.arrayAdd (obj4.initReal (0)); + obj3.arrayAdd (obj4.initReal (0)); + annotObj.dictSet ("InkList", &obj2); + + initialize(docA, annotObj.getDict()); +} + +AnnotInk::AnnotInk(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { + type = typeInk; + initialize(docA, dict); +} + +AnnotInk::~AnnotInk() { + freeInkList(); +} + +void AnnotInk::initialize(PDFDoc *docA, Dict* dict) { + Object obj1; + + if (dict->lookup("InkList", &obj1)->isArray()) { + parseInkList(obj1.getArray()); + } else { + inkListLength = 0; + inkList = NULL; + error(errSyntaxError, -1, "Bad Annot Ink List"); + ok = gFalse; + } + obj1.free(); + + if (dict->lookup("BS", &obj1)->isDict()) { + delete border; + border = new AnnotBorderBS(obj1.getDict()); + } else if (!border) { + border = new AnnotBorderBS(); + } + obj1.free(); +} + +void AnnotInk::writeInkList(AnnotPath **paths, int n_paths, Array *dest_array) { + Object obj1, obj2; + for (int i = 0; i < n_paths; ++i) { + AnnotPath *path = paths[i]; + obj1.initArray (xref); + for (int j = 0; j < path->getCoordsLength(); ++j) { + obj1.arrayAdd (obj2.initReal (path->getX(j))); + obj1.arrayAdd (obj2.initReal (path->getY(j))); + } + dest_array->add (&obj1); + } +} + +void AnnotInk::parseInkList(Array *array) { + inkListLength = array->getLength(); + inkList = (AnnotPath **) gmallocn ((inkListLength), sizeof(AnnotPath *)); + memset(inkList, 0, inkListLength * sizeof(AnnotPath *)); + for (int i = 0; i < inkListLength; i++) { + Object obj2; + if (array->get(i, &obj2)->isArray()) + inkList[i] = new AnnotPath(obj2.getArray()); + obj2.free(); + } +} + +void AnnotInk::freeInkList() { + if (inkList) { + for (int i = 0; i < inkListLength; ++i) + delete inkList[i]; + gfree(inkList); + } +} + +void AnnotInk::setInkList(AnnotPath **paths, int n_paths) { + Object obj1; + + freeInkList(); + + obj1.initArray (xref); + writeInkList(paths, n_paths, obj1.getArray()); + + parseInkList(obj1.getArray()); + annotObj.dictSet ("InkList", &obj1); + invalidateAppearance(); +} + +void AnnotInk::draw(Gfx *gfx, GBool printing) { + Object obj; + double ca = 1; + + if (!isVisible (printing)) + return; + + annotLocker(); + if (appearance.isNull()) { + appearBBox = new AnnotAppearanceBBox(rect); + ca = opacity; + + appearBuf = new GooString (); + appearBuf->append ("q\n"); + + if (color) { + setColor(color, gFalse); + } + + setLineStyleForBorder(border); + appearBBox->setBorderWidth(std::max(1., border->getWidth())); + + for (int i = 0; i < inkListLength; ++i) { + const AnnotPath * path = inkList[i]; + if (path->getCoordsLength() != 0) { + appearBuf->appendf ("{0:.2f} {1:.2f} m\n", path->getX(0) - rect->x1, path->getY(0) - rect->y1); + appearBBox->extendTo (path->getX(0) - rect->x1, path->getY(0) - rect->y1); + + for (int j = 1; j < path->getCoordsLength(); ++j) { + appearBuf->appendf ("{0:.2f} {1:.2f} l\n", path->getX(j) - rect->x1, path->getY(j) - rect->y1); + appearBBox->extendTo (path->getX(j) - rect->x1, path->getY(j) - rect->y1); + } + + appearBuf->append ("S\n"); + } + } + + appearBuf->append ("Q\n"); + + double bbox[4]; + appearBBox->getBBoxRect(bbox); + if (ca == 1) { + createForm(bbox, gFalse, NULL, &appearance); + } else { + Object aStream, resDict; + + createForm(bbox, gTrue, NULL, &aStream); + delete appearBuf; + + appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); + createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); + createForm(bbox, gFalse, &resDict, &appearance); + } + delete appearBuf; + } + + // draw the appearance stream + appearance.fetch(gfx->getXRef(), &obj); + if (appearBBox) { + gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, + appearBBox->getPageXMin(), appearBBox->getPageYMin(), + appearBBox->getPageXMax(), appearBBox->getPageYMax(), + getRotation()); + } else { + gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, + rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); + } + obj.free(); +} + +//------------------------------------------------------------------------ +// AnnotFileAttachment +//------------------------------------------------------------------------ +AnnotFileAttachment::AnnotFileAttachment(PDFDoc *docA, PDFRectangle *rect, GooString *filename) : + AnnotMarkup(docA, rect) { + Object obj1; + + type = typeFileAttachment; + + annotObj.dictSet ("Subtype", obj1.initName ("FileAttachment")); + + Object obj2; + obj2.initString(filename->copy()); + annotObj.dictSet ("FS", &obj2); + + initialize(docA, annotObj.getDict()); +} + +AnnotFileAttachment::AnnotFileAttachment(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { + type = typeFileAttachment; + initialize(docA, dict); +} + +AnnotFileAttachment::~AnnotFileAttachment() { + file.free(); + + if (name) + delete name; +} + +void AnnotFileAttachment::initialize(PDFDoc *docA, Dict* dict) { + Object obj1; + + if (dict->lookup("FS", &obj1)->isDict() || dict->lookup("FS", &obj1)->isString()) { + obj1.copy(&file); + } else { + error(errSyntaxError, -1, "Bad Annot File Attachment"); + ok = gFalse; + } + obj1.free(); + + if (dict->lookup("Name", &obj1)->isName()) { + name = new GooString(obj1.getName()); + } else { + name = new GooString("PushPin"); + } + obj1.free(); +} + +#define ANNOT_FILE_ATTACHMENT_AP_PUSHPIN \ + "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ + "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ + "l 1 21.523 2.477 23 4.301 23 c h\n" \ + "4.301 23 m f\n" \ + "0.533333 0.541176 0.521569 RG 2 w\n" \ + "1 J\n" \ + "1 j\n" \ + "[] 0.0 d\n" \ + "4 M 5 4 m 6 5 l S\n" \ + "2 w\n" \ + "11 14 m 9 12 l 6 12 l 13 5 l 13 8 l 15 10 l 18 11 l 20 11 l 12 19 l 12\n" \ + "17 l 11 14 l h\n" \ + "11 14 m S\n" \ + "3 w\n" \ + "6 5 m 9 8 l S\n" \ + "0.729412 0.741176 0.713725 RG 2 w\n" \ + "5 5 m 6 6 l S\n" \ + "2 w\n" \ + "11 15 m 9 13 l 6 13 l 13 6 l 13 9 l 15 11 l 18 12 l 20 12 l 12 20 l 12\n" \ + "18 l 11 15 l h\n" \ + "11 15 m S\n" \ + "3 w\n" \ + "6 6 m 9 9 l S\n" + +#define ANNOT_FILE_ATTACHMENT_AP_PAPERCLIP \ + "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ + "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ + "l 1 21.523 2.477 23 4.301 23 c h\n" \ + "4.301 23 m f\n" \ + "0.533333 0.541176 0.521569 RG 2 w\n" \ + "1 J\n" \ + "1 j\n" \ + "[] 0.0 d\n" \ + "4 M 16.645 12.035 m 12.418 7.707 l 10.902 6.559 6.402 11.203 8.09 12.562 c\n" \ + "14.133 18.578 l 14.949 19.387 16.867 19.184 17.539 18.465 c 20.551\n" \ + "15.23 l 21.191 14.66 21.336 12.887 20.426 12.102 c 13.18 4.824 l 12.18\n" \ + "3.82 6.25 2.566 4.324 4.461 c 3 6.395 3.383 11.438 4.711 12.801 c 9.648\n" \ + "17.887 l S\n" \ + "0.729412 0.741176 0.713725 RG 16.645 13.035 m 12.418 8.707 l\n" \ + "10.902 7.559 6.402 12.203 8.09 13.562 c\n" \ + "14.133 19.578 l 14.949 20.387 16.867 20.184 17.539 19.465 c 20.551\n" \ + "16.23 l 21.191 15.66 21.336 13.887 20.426 13.102 c 13.18 5.824 l 12.18\n" \ + "4.82 6.25 3.566 4.324 5.461 c 3 7.395 3.383 12.438 4.711 13.801 c 9.648\n" \ + "18.887 l S\n" + +#define ANNOT_FILE_ATTACHMENT_AP_GRAPH \ + "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ + "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ + "l 1 21.523 2.477 23 4.301 23 c h\n" \ + "4.301 23 m f\n" \ + "0.533333 0.541176 0.521569 RG 1 w\n" \ + "1 J\n" \ + "0 j\n" \ + "[] 0.0 d\n" \ + "4 M 18.5 15.5 m 18.5 13.086 l 16.086 15.5 l 18.5 15.5 l h\n" \ + "18.5 15.5 m S\n" \ + "7 7 m 10 11 l 13 9 l 18 15 l S\n" \ + "0.729412 0.741176 0.713725 RG 7 8 m 10 12 l 13 10 l 18 16 l S\n" \ + "18.5 16.5 m 18.5 14.086 l 16.086 16.5 l 18.5 16.5 l h\n" \ + "18.5 16.5 m S\n" \ + "0.533333 0.541176 0.521569 RG 2 w\n" \ + "1 j\n" \ + "3 19 m 3 3 l 21 3 l S\n" \ + "0.729412 0.741176 0.713725 RG 3 20 m 3 4 l 21 4 l S\n" + +#define ANNOT_FILE_ATTACHMENT_AP_TAG \ + "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ + "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ + "l 1 21.523 2.477 23 4.301 23 c h\n" \ + "4.301 23 m f\n" \ + "0.533333 0.541176 0.521569 RG 0.999781 w\n" \ + "1 J\n" \ + "1 j\n" \ + "[] 0.0 d\n" \ + "4 M q 1 0 0 -1 0 24 cm\n" \ + "8.492 8.707 m 8.492 9.535 7.82 10.207 6.992 10.207 c 6.164 10.207 5.492\n" \ + "9.535 5.492 8.707 c 5.492 7.879 6.164 7.207 6.992 7.207 c 7.82 7.207\n" \ + "8.492 7.879 8.492 8.707 c h\n" \ + "8.492 8.707 m S Q\n" \ + "2 w\n" \ + "20.078 11.414 m 20.891 10.602 20.785 9.293 20.078 8.586 c 14.422 2.93 l\n" \ + "13.715 2.223 12.301 2.223 11.594 2.93 c 3.816 10.707 l 3.109 11.414\n" \ + "2.402 17.781 3.816 19.195 c 5.23 20.609 11.594 19.902 12.301 19.195 c\n" \ + "20.078 11.414 l h\n" \ + "20.078 11.414 m S\n" \ + "0.729412 0.741176 0.713725 RG 20.078 12.414 m\n" \ + "20.891 11.605 20.785 10.293 20.078 9.586 c 14.422 3.93 l\n" \ + "13.715 3.223 12.301 3.223 11.594 3.93 c 3.816 11.707 l 3.109 12.414\n" \ + "2.402 18.781 3.816 20.195 c 5.23 21.609 11.594 20.902 12.301 20.195 c\n" \ + "20.078 12.414 l h\n" \ + "20.078 12.414 m S\n" \ + "0.533333 0.541176 0.521569 RG 1 w\n" \ + "0 j\n" \ + "11.949 13.184 m 16.191 8.941 l S\n" \ + "0.729412 0.741176 0.713725 RG 11.949 14.184 m 16.191 9.941 l S\n" \ + "0.533333 0.541176 0.521569 RG 14.07 6.82 m 9.828 11.062 l S\n" \ + "0.729412 0.741176 0.713725 RG 14.07 7.82 m 9.828 12.062 l S\n" \ + "0.533333 0.541176 0.521569 RG 6.93 15.141 m 8 20 14.27 20.5 16 20.5 c\n" \ + "18.094 20.504 19.5 20 19.5 18 c 19.5 16.699 20.91 16.418 22.5 16.5 c S\n" \ + "0.729412 0.741176 0.713725 RG 0.999781 w\n" \ + "1 j\n" \ + "q 1 0 0 -1 0 24 cm\n" \ + "8.492 7.707 m 8.492 8.535 7.82 9.207 6.992 9.207 c 6.164 9.207 5.492\n" \ + "8.535 5.492 7.707 c 5.492 6.879 6.164 6.207 6.992 6.207 c 7.82 6.207\n" \ + "8.492 6.879 8.492 7.707 c h\n" \ + "8.492 7.707 m S Q\n" \ + "1 w\n" \ + "0 j\n" \ + "6.93 16.141 m 8 21 14.27 21.5 16 21.5 c 18.094 21.504 19.5 21 19.5 19 c\n" \ + "19.5 17.699 20.91 17.418 22.5 17.5 c S\n" + +void AnnotFileAttachment::draw(Gfx *gfx, GBool printing) { + Object obj; + double ca = 1; + + if (!isVisible (printing)) + return; + + annotLocker(); + if (appearance.isNull()) { + ca = opacity; + + appearBuf = new GooString (); + + appearBuf->append ("q\n"); + if (color) + setColor(color, gTrue); + else + appearBuf->append ("1 1 1 rg\n"); + if (!name->cmp("PushPin")) + appearBuf->append (ANNOT_FILE_ATTACHMENT_AP_PUSHPIN); + else if (!name->cmp("Paperclip")) + appearBuf->append (ANNOT_FILE_ATTACHMENT_AP_PAPERCLIP); + else if (!name->cmp("Graph")) + appearBuf->append (ANNOT_FILE_ATTACHMENT_AP_GRAPH); + else if (!name->cmp("Tag")) + appearBuf->append (ANNOT_FILE_ATTACHMENT_AP_TAG); + appearBuf->append ("Q\n"); + + double bbox[4]; + bbox[0] = bbox[1] = 0; + bbox[2] = bbox[3] = 24; + if (ca == 1) { + createForm (bbox, gFalse, NULL, &appearance); + } else { + Object aStream; + + createForm (bbox, gTrue, NULL, &aStream); + delete appearBuf; + + Object resDict; + appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); + createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); + createForm(bbox, gFalse, &resDict, &appearance); + } + delete appearBuf; + } + + // draw the appearance stream + appearance.fetch(gfx->getXRef(), &obj); + gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, + rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); + obj.free(); +} + +//------------------------------------------------------------------------ +// AnnotSound +//------------------------------------------------------------------------ +AnnotSound::AnnotSound(PDFDoc *docA, PDFRectangle *rect, Sound *soundA) : + AnnotMarkup(docA, rect) { + Object obj1; + + type = typeSound; + + annotObj.dictSet ("Subtype", obj1.initName ("Sound")); + + Object obj2; + Stream *str = soundA->getStream(); + obj2.initStream (str); + str->incRef(); //FIXME: initStream should do this? + annotObj.dictSet ("Sound", &obj2); + + initialize(docA, annotObj.getDict()); +} + +AnnotSound::AnnotSound(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { + type = typeSound; + initialize(docA, dict); +} + +AnnotSound::~AnnotSound() { + delete sound; + + delete name; +} + +void AnnotSound::initialize(PDFDoc *docA, Dict* dict) { + Object obj1; + + sound = Sound::parseSound(dict->lookup("Sound", &obj1)); + if (!sound) { + error(errSyntaxError, -1, "Bad Annot Sound"); + ok = gFalse; + } + obj1.free(); + + if (dict->lookup("Name", &obj1)->isName()) { + name = new GooString(obj1.getName()); + } else { + name = new GooString("Speaker"); + } + obj1.free(); +} + +#define ANNOT_SOUND_AP_SPEAKER \ + "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ + "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ + "l 1 21.523 2.477 23 4.301 23 c h\n" \ + "4.301 23 m f\n" \ + "0.533333 0.541176 0.521569 RG 2 w\n" \ + "0 J\n" \ + "1 j\n" \ + "[] 0.0 d\n" \ + "4 M 4 14 m 4.086 8.043 l 7 8 l 11 4 l 11 18 l 7 14 l 4 14 l h\n" \ + "4 14 m S\n" \ + "1 w\n" \ + "1 J\n" \ + "0 j\n" \ + "13.699 15.398 m 14.699 13.398 14.699 9.398 13.699 7.398 c S\n" \ + "18.199 19.398 m 21.199 17.398 21.199 5.398 18.199 3.398 c S\n" \ + "16 17.398 m 18 16.398 18 7.398 16 5.398 c S\n" \ + "0.729412 0.741176 0.713725 RG 2 w\n" \ + "0 J\n" \ + "1 j\n" \ + "4 15 m 4.086 9.043 l 7 9 l 11 5 l 11 19 l 7 15 l 4 15 l h\n" \ + "4 15 m S\n" \ + "1 w\n" \ + "1 J\n" \ + "0 j\n" \ + "13.699 16 m 14.699 14 14.699 10 13.699 8 c S\n" \ + "18.199 20 m 21.199 18 21.199 6 18.199 4 c S\n" \ + "16 18 m 18 17 18 8 16 6 c S\n" + +#define ANNOT_SOUND_AP_MIC \ + "4.301 23 m 19.699 23 l 21.523 23 23 21.523 23 19.699 c 23 4.301 l 23\n" \ + "2.477 21.523 1 19.699 1 c 4.301 1 l 2.477 1 1 2.477 1 4.301 c 1 19.699\n" \ + "l 1 21.523 2.477 23 4.301 23 c h\n" \ + "4.301 23 m f\n" \ + "0.533333 0.541176 0.521569 RG 2 w\n" \ + "1 J\n" \ + "0 j\n" \ + "[] 0.0 d\n" \ + "4 M 12 20 m 12 20 l 13.656 20 15 18.656 15 17 c 15 13 l 15 11.344 13.656 10\n" \ + "12 10 c 12 10 l 10.344 10 9 11.344 9 13 c 9 17 l 9 18.656 10.344 20 12\n" \ + "20 c h\n" \ + "12 20 m S\n" \ + "1 w\n" \ + "17.5 14.5 m 17.5 11.973 l 17.5 8.941 15.047 6.5 12 6.5 c 8.953 6.5 6.5\n" \ + "8.941 6.5 11.973 c 6.5 14.5 l S\n" \ + "2 w\n" \ + "0 J\n" \ + "12 6.52 m 12 3 l S\n" \ + "1 J\n" \ + "8 3 m 16 3 l S\n" \ + "0.729412 0.741176 0.713725 RG 12 21 m 12 21 l 13.656 21 15 19.656 15 18 c\n" \ + "15 14 l 15 12.344 13.656 11 12 11 c 12 11 l 10.344 11 9 12.344 9 14 c\n" \ + "9 18 l 9 19.656 10.344 21 12 21 c h\n" \ + "12 21 m S\n" \ + "1 w\n" \ + "17.5 15.5 m 17.5 12.973 l 17.5 9.941 15.047 7.5 12 7.5 c 8.953 7.5 6.5\n" \ + "9.941 6.5 12.973 c 6.5 15.5 l S\n" \ + "2 w\n" \ + "0 J\n" \ + "12 7.52 m 12 4 l S\n" \ + "1 J\n" \ + "8 4 m 16 4 l S\n" + +void AnnotSound::draw(Gfx *gfx, GBool printing) { + Object obj; + double ca = 1; + + if (!isVisible (printing)) + return; + + annotLocker(); + if (appearance.isNull()) { + ca = opacity; + + appearBuf = new GooString (); + + appearBuf->append ("q\n"); + if (color) + setColor(color, gTrue); + else + appearBuf->append ("1 1 1 rg\n"); + if (!name->cmp("Speaker")) + appearBuf->append (ANNOT_SOUND_AP_SPEAKER); + else if (!name->cmp("Mic")) + appearBuf->append (ANNOT_SOUND_AP_MIC); + appearBuf->append ("Q\n"); + + double bbox[4]; + bbox[0] = bbox[1] = 0; + bbox[2] = bbox[3] = 24; + if (ca == 1) { + createForm(bbox, gFalse, NULL, &appearance); + } else { + Object aStream, resDict; + + createForm(bbox, gTrue, NULL, &aStream); + delete appearBuf; + + appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); + createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); + createForm(bbox, gFalse, &resDict, &appearance); + } + delete appearBuf; + } + + // draw the appearance stream + appearance.fetch(gfx->getXRef(), &obj); + gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, + rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); + obj.free(); +} + +//------------------------------------------------------------------------ +// Annot3D +//------------------------------------------------------------------------ +Annot3D::Annot3D(PDFDoc *docA, PDFRectangle *rect) : + Annot(docA, rect) { + Object obj1; + + type = type3D; + + annotObj.dictSet ("Subtype", obj1.initName ("3D")); + + initialize(docA, annotObj.getDict()); +} + +Annot3D::Annot3D(PDFDoc *docA, Dict *dict, Object *obj) : + Annot(docA, dict, obj) { + type = type3D; + initialize(docA, dict); +} + +Annot3D::~Annot3D() { + if (activation) + delete activation; +} + +void Annot3D::initialize(PDFDoc *docA, Dict* dict) { + Object obj1; + + if (dict->lookup("3DA", &obj1)->isDict()) { + activation = new Activation(obj1.getDict()); + } else { + activation = NULL; + } + obj1.free(); +} + +Annot3D::Activation::Activation(Dict *dict) { + Object obj1; + + if (dict->lookup("A", &obj1)->isName()) { + const char *name = obj1.getName(); + + if(!strcmp(name, "PO")) { + aTrigger = aTriggerPageOpened; + } else if(!strcmp(name, "PV")) { + aTrigger = aTriggerPageVisible; + } else if(!strcmp(name, "XA")) { + aTrigger = aTriggerUserAction; + } else { + aTrigger = aTriggerUnknown; + } + } else { + aTrigger = aTriggerUnknown; + } + obj1.free(); + + if(dict->lookup("AIS", &obj1)->isName()) { + const char *name = obj1.getName(); + + if(!strcmp(name, "I")) { + aState = aStateEnabled; + } else if(!strcmp(name, "L")) { + aState = aStateDisabled; + } else { + aState = aStateUnknown; + } + } else { + aState = aStateUnknown; + } + obj1.free(); + + if(dict->lookup("D", &obj1)->isName()) { + const char *name = obj1.getName(); + + if(!strcmp(name, "PC")) { + dTrigger = dTriggerPageClosed; + } else if(!strcmp(name, "PI")) { + dTrigger = dTriggerPageInvisible; + } else if(!strcmp(name, "XD")) { + dTrigger = dTriggerUserAction; + } else { + dTrigger = dTriggerUnknown; + } + } else { + dTrigger = dTriggerUnknown; + } + obj1.free(); + + if(dict->lookup("DIS", &obj1)->isName()) { + const char *name = obj1.getName(); + + if(!strcmp(name, "U")) { + dState = dStateUninstantiaded; + } else if(!strcmp(name, "I")) { + dState = dStateInstantiated; + } else if(!strcmp(name, "L")) { + dState = dStateLive; + } else { + dState = dStateUnknown; + } + } else { + dState = dStateUnknown; + } + obj1.free(); + + if (dict->lookup("TB", &obj1)->isBool()) { + displayToolbar = obj1.getBool(); + } else { + displayToolbar = gTrue; + } + obj1.free(); + + if (dict->lookup("NP", &obj1)->isBool()) { + displayNavigation = obj1.getBool(); + } else { + displayNavigation = gFalse; + } + obj1.free(); +} + +//------------------------------------------------------------------------ +// Annots +//------------------------------------------------------------------------ + +Annots::Annots(PDFDoc *docA, int page, Object *annotsObj) { + Annot *annot; + Object obj1; + int i; + + doc = docA; + annots = NULL; + size = 0; + nAnnots = 0; + + if (annotsObj->isArray()) { + for (i = 0; i < annotsObj->arrayGetLength(); ++i) { + //get the Ref to this annot and pass it to Annot constructor + //this way, it'll be possible for the annot to retrieve the corresponding + //form widget + Object obj2; + if (annotsObj->arrayGet(i, &obj1)->isDict()) { + annotsObj->arrayGetNF(i, &obj2); + annot = createAnnot (obj1.getDict(), &obj2); + if (annot) { + if (annot->isOk()) { + annot->setPage(page, gFalse); // Don't change /P + appendAnnot(annot); + } + annot->decRefCnt(); + } + } + obj2.free(); + obj1.free(); + } + } +} + +void Annots::appendAnnot(Annot *annot) { + if (annot && annot->isOk()) { + if (nAnnots >= size) { + size += 16; + annots = (Annot **)greallocn(annots, size, sizeof(Annot *)); + } + annots[nAnnots++] = annot; + annot->incRefCnt(); + } +} + +GBool Annots::removeAnnot(Annot *annot) { + int idx = -1; + // Search annot and determine its index + for (int i = 0; idx == -1 && i < nAnnots; i++) { + if (annots[i] == annot) { + idx = i; + } + } + if (idx == -1) { + return gFalse; + } else { + --nAnnots; + memmove( annots + idx, annots + idx + 1, sizeof(annots[0]) * (nAnnots - idx) ); + annot->decRefCnt(); + return gTrue; + } +} + +Annot *Annots::createAnnot(Dict* dict, Object *obj) { + Annot *annot = NULL; + Object obj1; + + if (dict->lookup("Subtype", &obj1)->isName()) { + const char *typeName = obj1.getName(); + + if (!strcmp(typeName, "Text")) { + annot = new AnnotText(doc, dict, obj); + } else if (!strcmp(typeName, "Link")) { + annot = new AnnotLink(doc, dict, obj); + } else if (!strcmp(typeName, "FreeText")) { + annot = new AnnotFreeText(doc, dict, obj); + } else if (!strcmp(typeName, "Line")) { + annot = new AnnotLine(doc, dict, obj); + } else if (!strcmp(typeName, "Square")) { + annot = new AnnotGeometry(doc, dict, obj); + } else if (!strcmp(typeName, "Circle")) { + annot = new AnnotGeometry(doc, dict, obj); + } else if (!strcmp(typeName, "Polygon")) { + annot = new AnnotPolygon(doc, dict, obj); + } else if (!strcmp(typeName, "PolyLine")) { + annot = new AnnotPolygon(doc, dict, obj); + } else if (!strcmp(typeName, "Highlight")) { + annot = new AnnotTextMarkup(doc, dict, obj); + } else if (!strcmp(typeName, "Underline")) { + annot = new AnnotTextMarkup(doc, dict, obj); + } else if (!strcmp(typeName, "Squiggly")) { + annot = new AnnotTextMarkup(doc, dict, obj); + } else if (!strcmp(typeName, "StrikeOut")) { + annot = new AnnotTextMarkup(doc, dict, obj); + } else if (!strcmp(typeName, "Stamp")) { + annot = new AnnotStamp(doc, dict, obj); + } else if (!strcmp(typeName, "Caret")) { + annot = new AnnotCaret(doc, dict, obj); + } else if (!strcmp(typeName, "Ink")) { + annot = new AnnotInk(doc, dict, obj); + } else if (!strcmp(typeName, "FileAttachment")) { + annot = new AnnotFileAttachment(doc, dict, obj); + } else if (!strcmp(typeName, "Sound")) { + annot = new AnnotSound(doc, dict, obj); + } else if(!strcmp(typeName, "Movie")) { + annot = new AnnotMovie(doc, dict, obj); + } else if(!strcmp(typeName, "Widget")) { + // Find the annot in forms + if (obj->isRef()) { + Form *form = doc->getCatalog()->getForm(); + if (form) { + FormWidget *widget = form->findWidgetByRef(obj->getRef()); + if (widget) { + annot = widget->getWidgetAnnotation(); + annot->incRefCnt(); + } + } + } + if (!annot) + annot = new AnnotWidget(doc, dict, obj); + } else if(!strcmp(typeName, "Screen")) { + annot = new AnnotScreen(doc, dict, obj); + } else if(!strcmp(typeName, "PrinterMark")) { + annot = new Annot(doc, dict, obj); + } else if (!strcmp(typeName, "TrapNet")) { + annot = new Annot(doc, dict, obj); + } else if (!strcmp(typeName, "Watermark")) { + annot = new Annot(doc, dict, obj); + } else if (!strcmp(typeName, "3D")) { + annot = new Annot3D(doc, dict, obj); + } else if (!strcmp(typeName, "Popup")) { + /* Popup annots are already handled by markup annots + * Here we only care about popup annots without a + * markup annotation associated + */ + Object obj2; + + if (dict->lookup("Parent", &obj2)->isNull()) + annot = new AnnotPopup(doc, dict, obj); + else + annot = NULL; + + obj2.free(); + } else { + annot = new Annot(doc, dict, obj); + } + } + obj1.free(); + + return annot; +} + +Annot *Annots::findAnnot(Ref *ref) { + int i; + + for (i = 0; i < nAnnots; ++i) { + if (annots[i]->match(ref)) { + return annots[i]; + } + } + return NULL; +} + + +Annots::~Annots() { + int i; + + for (i = 0; i < nAnnots; ++i) { + annots[i]->decRefCnt(); + } + gfree(annots); +} diff --git a/source/libs/poppler/poppler-0.33.0/poppler/Annot.h b/source/libs/poppler/poppler-0.33.0/poppler/Annot.h new file mode 100644 index 000000000..1e64f59bc --- /dev/null +++ b/source/libs/poppler/poppler-0.33.0/poppler/Annot.h @@ -0,0 +1,1439 @@ +//======================================================================== +// +// Annot.h +// +// Copyright 2000-2003 Glyph & Cog, LLC +// +//======================================================================== + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2006 Scott Turner <scotty1024@mac.com> +// Copyright (C) 2007, 2008 Julien Rebetez <julienr@svn.gnome.org> +// Copyright (C) 2007-2011, 2013, 2015 Carlos Garcia Campos <carlosgc@gnome.org> +// Copyright (C) 2007, 2008 Iñigo Martínez <inigomartinez@gmail.com> +// Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu> +// Copyright (C) 2008 Hugo Mercier <hmercier31@gmail.com> +// Copyright (C) 2008 Pino Toscano <pino@kde.org> +// Copyright (C) 2008 Tomas Are Haavet <tomasare@gmail.com> +// Copyright (C) 2009-2011, 2013 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it> +// Copyright (C) 2012 Tobias Koenig <tokoe@kdab.com> +// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#ifndef ANNOT_H +#define ANNOT_H + +#ifdef USE_GCC_PRAGMAS +#pragma interface +#endif + +#include "Object.h" + +class XRef; +class Gfx; +class CharCodeToUnicode; +class GfxFont; +class GfxResources; +class Page; +class PDFDoc; +class Form; +class FormWidget; +class FormField; +class FormFieldChoice; +class PDFRectangle; +class Movie; +class LinkAction; +class Sound; + +enum AnnotLineEndingStyle { + annotLineEndingSquare, // Square + annotLineEndingCircle, // Circle + annotLineEndingDiamond, // Diamond + annotLineEndingOpenArrow, // OpenArrow + annotLineEndingClosedArrow, // ClosedArrow + annotLineEndingNone, // None + annotLineEndingButt, // Butt + annotLineEndingROpenArrow, // ROpenArrow + annotLineEndingRClosedArrow, // RClosedArrow + annotLineEndingSlash // Slash +}; + +enum AnnotExternalDataType { + annotExternalDataMarkupUnknown, + annotExternalDataMarkup3D // Markup3D +}; + +//------------------------------------------------------------------------ +// AnnotCoord +//------------------------------------------------------------------------ + +class AnnotCoord { +public: + + AnnotCoord() : x(0), y(0) { } + AnnotCoord(double _x, double _y) : x(_x), y(_y) { } + + double getX() const { return x; } + double getY() const { return y; } + +protected: + + double x, y; +}; + +//------------------------------------------------------------------------ +// AnnotPath +//------------------------------------------------------------------------ + +class AnnotPath { +public: + AnnotPath(); + AnnotPath(Array *array); + AnnotPath(AnnotCoord **coords, int coordLength); + ~AnnotPath(); + + double getX(int coord) const; + double getY(int coord) const; + AnnotCoord *getCoord(int coord) const; + int getCoordsLength() const { return coordsLength; } +protected: + AnnotCoord **coords; + int coordsLength; + + void parsePathArray(Array *array); +}; + +//------------------------------------------------------------------------ +// AnnotCalloutLine +//------------------------------------------------------------------------ + +class AnnotCalloutLine { +public: + + AnnotCalloutLine(double x1, double y1, double x2, double y2); + virtual ~AnnotCalloutLine() { } + + double getX1() const { return coord1.getX(); } + double getY1() const { return coord1.getY(); } + double getX2() const { return coord2.getX(); } + double getY2() const { return coord2.getY(); } + +protected: + + AnnotCoord coord1, coord2; +}; + +//------------------------------------------------------------------------ +// AnnotCalloutMultiLine +//------------------------------------------------------------------------ + +class AnnotCalloutMultiLine: public AnnotCalloutLine { +public: + + AnnotCalloutMultiLine(double x1, double y1, double x2, double y2, + double x3, double y3); + + double getX3() const { return coord3.getX(); } + double getY3() const { return coord3.getY(); } + +protected: + + AnnotCoord coord3; +}; + +//------------------------------------------------------------------------ +// AnnotBorderEffect +//------------------------------------------------------------------------ + +class AnnotBorderEffect { +public: + + enum AnnotBorderEffectType { + borderEffectNoEffect, // S + borderEffectCloudy // C + }; + + AnnotBorderEffect(Dict *dict); + + AnnotBorderEffectType getEffectType() const { return effectType; } + double getIntensity() const { return intensity; } + +private: + + AnnotBorderEffectType effectType; // S (Default S) + double intensity; // I (Default 0) +}; + +//------------------------------------------------------------------------ +// AnnotQuadrilateral +//------------------------------------------------------------------------ + +class AnnotQuadrilaterals { +public: + class AnnotQuadrilateral { + public: + AnnotQuadrilateral(double x1, double y1, double x2, double y2, double x3, + double y3, double x4, double y4); + + AnnotCoord coord1, coord2, coord3, coord4; + }; + + AnnotQuadrilaterals(Array *array, PDFRectangle *rect); + AnnotQuadrilaterals(AnnotQuadrilateral **quads, int quadsLength); + ~AnnotQuadrilaterals(); + + double getX1(int quadrilateral); + double getY1(int quadrilateral); + double getX2(int quadrilateral); + double getY2(int quadrilateral); + double getX3(int quadrilateral); + double getY3(int quadrilateral); + double getX4(int quadrilateral); + double getY4(int quadrilateral); + int getQuadrilateralsLength() const { return quadrilateralsLength; } +protected: + + AnnotQuadrilateral** quadrilaterals; + int quadrilateralsLength; +}; + +//------------------------------------------------------------------------ +// AnnotBorder +//------------------------------------------------------------------------ + +class AnnotBorder { +public: + enum AnnotBorderType { + typeArray, + typeBS + }; + + enum AnnotBorderStyle { + borderSolid, // Solid + borderDashed, // Dashed + borderBeveled, // Beveled + borderInset, // Inset + borderUnderlined // Underlined + }; + + virtual ~AnnotBorder(); + + virtual void setWidth(double new_width) { width = new_width; } + + virtual AnnotBorderType getType() const = 0; + virtual double getWidth() const { return width; } + virtual int getDashLength() const { return dashLength; } + virtual double *getDash() const { return dash; } + virtual AnnotBorderStyle getStyle() const { return style; } + + virtual void writeToObject(XRef *xref, Object *obj1) const = 0; + +protected: + AnnotBorder(); + + GBool parseDashArray(Object *dashObj); + + AnnotBorderType type; + double width; + static const int DASH_LIMIT = 10; // implementation note 82 in Appendix H. + int dashLength; + double *dash; + AnnotBorderStyle style; +}; + +//------------------------------------------------------------------------ +// AnnotBorderArray +//------------------------------------------------------------------------ + +class AnnotBorderArray: public AnnotBorder { +public: + AnnotBorderArray(); + AnnotBorderArray(Array *array); + + void setHorizontalCorner(double hc) { horizontalCorner = hc; } + void setVerticalCorner(double vc) { verticalCorner = vc; } + + double getHorizontalCorner() const { return horizontalCorner; } + double getVerticalCorner() const { return verticalCorner; } + +private: + virtual AnnotBorderType getType() const { return typeArray; } + virtual void writeToObject(XRef *xref, Object *obj1) const; + + double horizontalCorner; // (Default 0) + double verticalCorner; // (Default 0) + // double width; // (Default 1) (inherited from AnnotBorder) +}; + +//------------------------------------------------------------------------ +// AnnotBorderBS +//------------------------------------------------------------------------ + +class AnnotBorderBS: public AnnotBorder { +public: + + AnnotBorderBS(); + AnnotBorderBS(Dict *dict); + +private: + virtual AnnotBorderType getType() const { return typeBS; } + virtual void writeToObject(XRef *xref, Object *obj1) const; + + const char *getStyleName() const; + + // double width; // W (Default 1) (inherited from AnnotBorder) + // AnnotBorderStyle style; // S (Default S) (inherited from AnnotBorder) + // double *dash; // D (Default [3]) (inherited from AnnotBorder) +}; + +//------------------------------------------------------------------------ +// AnnotColor +//------------------------------------------------------------------------ + +class AnnotColor { +public: + + enum AnnotColorSpace { + colorTransparent = 0, + colorGray = 1, + colorRGB = 3, + colorCMYK = 4 + }; + + AnnotColor(); + AnnotColor(double gray); + AnnotColor(double r, double g, double b); + AnnotColor(double c, double m, double y, double k); + AnnotColor(Array *array, int adjust = 0); + + void adjustColor(int adjust); + + AnnotColorSpace getSpace() const { return (AnnotColorSpace) length; } + const double *getValues() const { return values; } + + void writeToObject(XRef *xref, Object *dest) const; + +private: + + double values[4]; + int length; +}; + +//------------------------------------------------------------------------ +// AnnotIconFit +//------------------------------------------------------------------------ + +class AnnotIconFit { +public: + + enum AnnotIconFitScaleWhen { + scaleAlways, // A + scaleBigger, // B + scaleSmaller, // S + scaleNever // N + }; + + enum AnnotIconFitScale { + scaleAnamorphic, // A + scaleProportional // P + }; + + AnnotIconFit(Dict *dict); + + AnnotIconFitScaleWhen getScaleWhen() { return scaleWhen; } + AnnotIconFitScale getScale() { return scale; } + double getLeft() { return left; } + double getBottom() { return bottom; } + bool getFullyBounds() { return fullyBounds; } + +protected: + + AnnotIconFitScaleWhen scaleWhen; // SW (Default A) + AnnotIconFitScale scale; // S (Default P) + double left; // A (Default [0.5 0.5] + double bottom; // Only if scale is P + bool fullyBounds; // FB (Default false) +}; + +//------------------------------------------------------------------------ +// AnnotAppearance +//------------------------------------------------------------------------ + +class AnnotAppearance { +public: + + enum AnnotAppearanceType { + appearNormal, + appearRollover, + appearDown + }; + + AnnotAppearance(PDFDoc *docA, Object *dict); + ~AnnotAppearance(); + + // State is ignored if no subdictionary is present + void getAppearanceStream(AnnotAppearanceType type, const char *state, Object *dest); + + // Access keys in normal appearance subdictionary (N) + GooString * getStateKey(int i); + int getNumStates(); + + // Removes all associated streams in the xref table. Caller is required to + // reset parent annotation's AP and AS after this call. + void removeAllStreams(); + + // Test if this AnnotAppearance references the specified stream + GBool referencesStream(Ref targetStreamRef); + +private: + static GBool referencesStream(Object *stateObj, Ref targetStreamRef); + void removeStream(Ref refToStream); + void removeStateStreams(Object *state); + +protected: + PDFDoc *doc; + XRef *xref; // the xref table for this PDF file + Object appearDict; // Annotation's AP +}; + +//------------------------------------------------------------------------ +// AnnotAppearanceCharacs +//------------------------------------------------------------------------ + +class AnnotAppearanceCharacs { +public: + + enum AnnotAppearanceCharacsTextPos { + captionNoIcon, // 0 + captionNoCaption, // 1 + captionBelow, // 2 + captionAbove, // 3 + captionRight, // 4 + captionLeft, // 5 + captionOverlaid // 6 + }; + + AnnotAppearanceCharacs(Dict *dict); + ~AnnotAppearanceCharacs(); + + int getRotation() { return rotation; } + AnnotColor *getBorderColor() { return borderColor; } + AnnotColor *getBackColor() { return backColor; } + GooString *getNormalCaption() { return normalCaption; } + GooString *getRolloverCaption() { return rolloverCaption; } + GooString *getAlternateCaption() { return alternateCaption; } + AnnotIconFit *getIconFit() { return iconFit; } + AnnotAppearanceCharacsTextPos getPosition() { return position; } + +protected: + + int rotation; // R (Default 0) + AnnotColor *borderColor; // BC + AnnotColor *backColor; // BG + GooString *normalCaption; // CA + GooString *rolloverCaption; // RC + GooString *alternateCaption; // AC + // I + // RI + // IX + AnnotIconFit *iconFit; // IF + AnnotAppearanceCharacsTextPos position; // TP (Default 0) +}; + +//------------------------------------------------------------------------ +// AnnotAppearanceBBox +//------------------------------------------------------------------------ + +class AnnotAppearanceBBox +{ +public: + AnnotAppearanceBBox(PDFRectangle *init); + + void setBorderWidth(double w) { borderWidth = w; } + + // The following functions operate on coords relative to [origX origY] + void extendTo(double x, double y); + void getBBoxRect(double bbox[4]) const; + + // Get boundaries in page coordinates + double getPageXMin() const; + double getPageYMin() const; + double getPageXMax() const; + double getPageYMax() const; + +private: + double origX, origY, borderWidth; + double minX, minY, maxX, maxY; +}; + +//------------------------------------------------------------------------ +// Annot +//------------------------------------------------------------------------ + +class Annot { + friend class Annots; + friend class Page; +public: + enum AnnotFlag { + flagUnknown = 0x0000, + flagInvisible = 0x0001, + flagHidden = 0x0002, + flagPrint = 0x0004, + flagNoZoom = 0x0008, + flagNoRotate = 0x0010, + flagNoView = 0x0020, + flagReadOnly = 0x0040, + flagLocked = 0x0080, + flagToggleNoView = 0x0100, + flagLockedContents = 0x0200 + }; + + enum AnnotSubtype { + typeUnknown, // 0 + typeText, // Text 1 + typeLink, // Link 2 + typeFreeText, // FreeText 3 + typeLine, // Line 4 + typeSquare, // Square 5 + typeCircle, // Circle 6 + typePolygon, // Polygon 7 + typePolyLine, // PolyLine 8 + typeHighlight, // Highlight 9 + typeUnderline, // Underline 10 + typeSquiggly, // Squiggly 11 + typeStrikeOut, // StrikeOut 12 + typeStamp, // Stamp 13 + typeCaret, // Caret 14 + typeInk, // Ink 15 + typePopup, // Popup 16 + typeFileAttachment, // FileAttachment 17 + typeSound, // Sound 18 + typeMovie, // Movie 19 + typeWidget, // Widget 20 + typeScreen, // Screen 21 + typePrinterMark, // PrinterMark 22 + typeTrapNet, // TrapNet 23 + typeWatermark, // Watermark 24 + type3D // 3D 25 + }; + + /** + * Describes the additional actions of a screen or widget annotation. + */ + enum AdditionalActionsType { + actionCursorEntering, ///< Performed when the cursor enters the annotation's active area + actionCursorLeaving, ///< Performed when the cursor exists the annotation's active area + actionMousePressed, ///< Performed when the mouse button is pressed inside the annotation's active area + actionMouseReleased, ///< Performed when the mouse button is released inside the annotation's active area + actionFocusIn, ///< Performed when the annotation receives the input focus + actionFocusOut, ///< Performed when the annotation loses the input focus + actionPageOpening, ///< Performed when the page containing the annotation is opened + actionPageClosing, ///< Performed when the page containing the annotation is closed + actionPageVisible, ///< Performed when the page containing the annotation becomes visible + actionPageInvisible ///< Performed when the page containing the annotation becomes invisible + }; + + enum FormAdditionalActionsType { + actionFieldModified, ///< Performed when the when the user modifies the field + actionFormatField, ///< Performed before the field is formatted to display its value + actionValidateField, ///< Performed when the field value changes + actionCalculateField, ///< Performed when the field needs to be recalculated + }; + + Annot(PDFDoc *docA, PDFRectangle *rectA); + Annot(PDFDoc *docA, Dict *dict); + Annot(PDFDoc *docA, Dict *dict, Object *obj); + GBool isOk() { return ok; } + + void incRefCnt(); + void decRefCnt(); + + virtual void draw(Gfx *gfx, GBool printing); + // Get the resource dict of the appearance stream + virtual Object *getAppearanceResDict(Object *dest); + + GBool match(Ref *refA) + { return ref.num == refA->num && ref.gen == refA->gen; } + + double getXMin(); + double getYMin(); + double getXMax(); + double getYMax(); + + double getFontSize() { return fontSize; } + + void setRect(PDFRectangle *rect); + void setRect(double x1, double y1, double x2, double y2); + + // Sets the annot contents to new_content + // new_content should never be NULL + virtual void setContents(GooString *new_content); + void setName(GooString *new_name); + void setModified(GooString *new_date); + void setFlags(Guint new_flags); + + void setBorder(AnnotBorder *new_border); // Takes ownership + + // The annotation takes the ownership of + // new_color. + void setColor(AnnotColor *new_color); + + void setAppearanceState(const char *state); + + // getters + PDFDoc *getDoc() const { return doc; } + XRef *getXRef() const { return xref; } + GBool getHasRef() const { return hasRef; } + Ref getRef() const { return ref; } + AnnotSubtype getType() const { return type; } + PDFRectangle *getRect() const { return rect; } + void getRect(double *x1, double *y1, double *x2, double *y2) const; + GooString *getContents() const { return contents; } + int getPageNum() const { return page; } + GooString *getName() const { return name; } + GooString *getModified() const { return modified; } + Guint getFlags() const { return flags; } + AnnotAppearance *getAppearStreams() const { return appearStreams; } + GooString *getAppearState() const { return appearState; } + AnnotBorder *getBorder() const { return border; } + AnnotColor *getColor() const { return color; } + int getTreeKey() const { return treeKey; } + + int getId() { return ref.num; } + + // Check if point is inside the annot rectangle. + GBool inRect(double x, double y) const; + +private: + void readArrayNum(Object *pdfArray, int key, double *value); + // write vStr[i:j[ in appearBuf + + void initialize (PDFDoc *docA, Dict *dict); + void setPage (int new_page, GBool updateP); // Called by Page::addAnnot and Annots ctor + + +protected: + virtual ~Annot(); + virtual void removeReferencedObjects(); // Called by Page::removeAnnot + void setColor(AnnotColor *color, GBool fill); + void setLineStyleForBorder(AnnotBorder *border); + void drawCircle(double cx, double cy, double r, GBool fill); + void drawCircleTopLeft(double cx, double cy, double r); + void drawCircleBottomRight(double cx, double cy, double r); + void layoutText(GooString *text, GooString *outBuf, int *i, GfxFont *font, + double *width, double widthLimit, int *charCount, + GBool noReencode); + void writeString(GooString *str, GooString *appearBuf); + void createForm(double *bbox, GBool transparencyGroup, Object *resDict, Object *aStream); + void createResourcesDict(const char *formName, Object *formStream, const char *stateName, + double opacity, const char *blendMode, Object *resDict); + GBool isVisible(GBool printing); + int getRotation() const; + + // Updates the field key of the annotation dictionary + // and sets M to the current time + void update(const char *key, Object *value); + + // Delete appearance streams and reset appearance state + void invalidateAppearance(); + + int refCnt; + + Object annotObj; + + // required data + AnnotSubtype type; // Annotation type + PDFRectangle *rect; // Rect + + // optional data + GooString *contents; // Contents + int page; // P + GooString *name; // NM + GooString *modified; // M + Guint flags; // F (must be a 32 bit unsigned int) + AnnotAppearance *appearStreams; // AP + Object appearance; // a reference to the Form XObject stream + // for the normal appearance + AnnotAppearanceBBox *appearBBox; // BBox of generated appearance + GooString *appearState; // AS + int treeKey; // Struct Parent; + Object oc; // OC + + PDFDoc *doc; + XRef *xref; // the xref table for this PDF file + Ref ref; // object ref identifying this annotation + GooString *appearBuf; + AnnotBorder *border; // Border, BS + AnnotColor *color; // C + double fontSize; + GBool ok; + + bool hasRef; +#if MULTITHREADED + GooMutex mutex; +#endif +}; + +//------------------------------------------------------------------------ +// AnnotPopup +//------------------------------------------------------------------------ + +class AnnotPopup: public Annot { +public: + AnnotPopup(PDFDoc *docA, PDFRectangle *rect); + AnnotPopup(PDFDoc *docA, Dict *dict, Object *obj); + ~AnnotPopup(); + + Object *getParent(Object *obj) { return parent.fetch (xref, obj); } + Object *getParentNF() { return &parent; } + void setParent(Object *parentA); + void setParent(Annot *parentA); + GBool getOpen() const { return open; } + void setOpen(GBool openA); + +protected: + void initialize(PDFDoc *docA, Dict *dict); + + Object parent; // Parent + GBool open; // Open +}; + +//------------------------------------------------------------------------ +// AnnotMarkup +//------------------------------------------------------------------------ + +class AnnotMarkup: public Annot { +public: + enum AnnotMarkupReplyType { + replyTypeR, // R + replyTypeGroup // Group + }; + + AnnotMarkup(PDFDoc *docA, PDFRectangle *rect); + AnnotMarkup(PDFDoc *docA, Dict *dict, Object *obj); + virtual ~AnnotMarkup(); + + // getters + GooString *getLabel() const { return label; } + AnnotPopup *getPopup() const { return popup; } + double getOpacity() const { return opacity; } + // getRC + GooString *getDate() const { return date; } + int getInReplyToID() const { return inReplyTo.num; } + GooString *getSubject() const { return subject; } + AnnotMarkupReplyType getReplyTo() const { return replyTo; } + AnnotExternalDataType getExData() const { return exData; } + + // The annotation takes the ownership of new_popup + void setPopup(AnnotPopup *new_popup); + void setLabel(GooString *new_label); + void setOpacity(double opacityA); + void setDate(GooString *new_date); + +protected: + virtual void removeReferencedObjects(); + + GooString *label; // T (Default autor) + AnnotPopup *popup; // Popup + double opacity; // CA (Default 1.0) + // RC + GooString *date; // CreationDate + Ref inReplyTo; // IRT + GooString *subject; // Subj + AnnotMarkupReplyType replyTo; // RT (Default R) + // this object is overrided by the custom intent fields defined in some + // annotation types. + //GooString *intent; // IT + AnnotExternalDataType exData; // ExData + +private: + void initialize(PDFDoc *docA, Dict *dict, Object *obj); +}; + +//------------------------------------------------------------------------ +// AnnotText +//------------------------------------------------------------------------ + +class AnnotText: public AnnotMarkup { +public: + enum AnnotTextState { + stateUnknown, + // Marked state model + stateMarked, // Marked + stateUnmarked, // Unmarked + // Review state model + stateAccepted, // Accepted + stateRejected, // Rejected + stateCancelled, // Cancelled + stateCompleted, // Completed + stateNone // None + }; + + AnnotText(PDFDoc *docA, PDFRectangle *rect); + AnnotText(PDFDoc *docA, Dict *dict, Object *obj); + ~AnnotText(); + + virtual void draw(Gfx *gfx, GBool printing); + + // getters + GBool getOpen() const { return open; } + GooString *getIcon() const { return icon; } + AnnotTextState getState() const { return state; } + + void setOpen(GBool openA); + void setIcon(GooString *new_icon); + +private: + + void initialize(PDFDoc *docA, Dict *dict); + + GBool open; // Open (Default false) + GooString *icon; // Name (Default Note) + AnnotTextState state; // State (Default Umarked if + // StateModel Marked + // None if StareModel Review) +}; + +//------------------------------------------------------------------------ +// AnnotMovie +//------------------------------------------------------------------------ + + + +class AnnotMovie: public Annot { + public: + AnnotMovie(PDFDoc *docA, PDFRectangle *rect, Movie *movieA); + AnnotMovie(PDFDoc *docA, Dict *dict, Object *obj); + ~AnnotMovie(); + + virtual void draw(Gfx *gfx, GBool printing); + + GooString* getTitle() { return title; } + Movie* getMovie() { return movie; } + + private: + void initialize(PDFDoc *docA, Dict *dict); + + GooString* title; // T + Movie* movie; // Movie + A +}; + + +//------------------------------------------------------------------------ +// AnnotScreen +//------------------------------------------------------------------------ + +class AnnotScreen: public Annot { + public: + + AnnotScreen(PDFDoc *docA, PDFRectangle *rect); + AnnotScreen(PDFDoc *docA, Dict *dict, Object *obj); + ~AnnotScreen(); + + GooString* getTitle() { return title; } + + AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs; } + LinkAction* getAction() { return action; } + LinkAction *getAdditionalAction(AdditionalActionsType type); + + private: + void initialize(PDFDoc *docA, Dict *dict); + + + GooString* title; // T + + AnnotAppearanceCharacs* appearCharacs; // MK + + LinkAction *action; // A + Object additionalActions; // AA +}; + +//------------------------------------------------------------------------ +// AnnotLink +//------------------------------------------------------------------------ + +class AnnotLink: public Annot { +public: + + enum AnnotLinkEffect { + effectNone, // N + effectInvert, // I + effectOutline, // O + effectPush // P + }; + + AnnotLink(PDFDoc *docA, PDFRectangle *rect); + AnnotLink(PDFDoc *docA, Dict *dict, Object *obj); + virtual ~AnnotLink(); + + virtual void draw(Gfx *gfx, GBool printing); + + // getters + LinkAction *getAction() const { return action; } + AnnotLinkEffect getLinkEffect() const { return linkEffect; } + Dict *getUriAction() const { return uriAction; } + AnnotQuadrilaterals *getQuadrilaterals() const { return quadrilaterals; } + +protected: + + void initialize(PDFDoc *docA, Dict *dict); + + LinkAction *action; // A, Dest + AnnotLinkEffect linkEffect; // H (Default I) + Dict *uriAction; // PA + + AnnotQuadrilaterals *quadrilaterals; // QuadPoints +}; + +//------------------------------------------------------------------------ +// AnnotFreeText +//------------------------------------------------------------------------ + +class AnnotFreeText: public AnnotMarkup { +public: + + enum AnnotFreeTextQuadding { + quaddingLeftJustified, // 0 + quaddingCentered, // 1 + quaddingRightJustified // 2 + }; + + enum AnnotFreeTextIntent { + intentFreeText, // FreeText + intentFreeTextCallout, // FreeTextCallout + intentFreeTextTypeWriter // FreeTextTypeWriter + }; + + AnnotFreeText(PDFDoc *docA, PDFRectangle *rect, GooString *da); + AnnotFreeText(PDFDoc *docA, Dict *dict, Object *obj); + ~AnnotFreeText(); + + virtual void draw(Gfx *gfx, GBool printing); + virtual Object *getAppearanceResDict(Object *dest); + virtual void setContents(GooString *new_content); + + void setAppearanceString(GooString *new_string); + void setQuadding(AnnotFreeTextQuadding new_quadding); + void setStyleString(GooString *new_string); + void setCalloutLine(AnnotCalloutLine *line); + void setIntent(AnnotFreeTextIntent new_intent); + + // getters + GooString *getAppearanceString() const { return appearanceString; } + AnnotFreeTextQuadding getQuadding() const { return quadding; } + // return rc + GooString *getStyleString() const { return styleString; } + AnnotCalloutLine *getCalloutLine() const { return calloutLine; } + AnnotFreeTextIntent getIntent() const { return intent; } + AnnotBorderEffect *getBorderEffect() const { return borderEffect; } + PDFRectangle *getRectangle() const { return rectangle; } + AnnotLineEndingStyle getEndStyle() const { return endStyle; } + +protected: + + void initialize(PDFDoc *docA, Dict *dict); + static void parseAppearanceString(GooString *da, double &fontsize, AnnotColor* &fontcolor); + void generateFreeTextAppearance(); + + // required + GooString *appearanceString; // DA + + // optional + AnnotFreeTextQuadding quadding; // Q (Default 0) + // RC + GooString *styleString; // DS + AnnotCalloutLine *calloutLine; // CL + AnnotFreeTextIntent intent; // IT + AnnotBorderEffect *borderEffect; // BE + PDFRectangle *rectangle; // RD + // inherited from Annot + // AnnotBorderBS border; // BS + AnnotLineEndingStyle endStyle; // LE (Default None) +}; + +//------------------------------------------------------------------------ +// AnnotLine +//------------------------------------------------------------------------ + +class AnnotLine: public AnnotMarkup { +public: + + enum AnnotLineIntent { + intentLineArrow, // LineArrow + intentLineDimension // LineDimension + }; + + enum AnnotLineCaptionPos { + captionPosInline, // Inline + captionPosTop // Top + }; + + AnnotLine(PDFDoc *docA, PDFRectangle *rect); + AnnotLine(PDFDoc *docA, Dict *dict, Object *obj); + ~AnnotLine(); + + virtual void draw(Gfx *gfx, GBool printing); + virtual Object *getAppearanceResDict(Object *dest); + virtual void setContents(GooString *new_content); + + void setVertices(double x1, double y1, double x2, double y2); + void setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end); + void setInteriorColor(AnnotColor *new_color); + void setLeaderLineLength(double len); + void setLeaderLineExtension(double len); + void setCaption(bool new_cap); + void setIntent(AnnotLineIntent new_intent); + + // getters + AnnotLineEndingStyle getStartStyle() const { return startStyle; } + AnnotLineEndingStyle getEndStyle() const { return endStyle; } + AnnotColor *getInteriorColor() const { return interiorColor; } + double getLeaderLineLength() const { return leaderLineLength; } + double getLeaderLineExtension() const { return leaderLineExtension; } + bool getCaption() const { return caption; } + AnnotLineIntent getIntent() const { return intent; } + double getLeaderLineOffset() const { return leaderLineOffset; } + AnnotLineCaptionPos getCaptionPos() const { return captionPos; } + Dict *getMeasure() const { return measure; } + double getCaptionTextHorizontal() const { return captionTextHorizontal; } + double getCaptionTextVertical() const { return captionTextVertical; } + double getX1() const { return coord1->getX(); } + double getY1() const { return coord1->getY(); } + double getX2() const { return coord2->getX(); } + double getY2() const { return coord2->getY(); } + +protected: + + void initialize(PDFDoc *docA, Dict *dict); + void generateLineAppearance(); + + // required + AnnotCoord *coord1, *coord2; + + // optional + // inherited from Annot + // AnnotBorderBS border; // BS + AnnotLineEndingStyle startStyle; // LE (Default [/None /None]) + AnnotLineEndingStyle endStyle; // + AnnotColor *interiorColor; // IC + double leaderLineLength; // LL (Default 0) + double leaderLineExtension; // LLE (Default 0) + bool caption; // Cap (Default false) + AnnotLineIntent intent; // IT + double leaderLineOffset; // LLO + AnnotLineCaptionPos captionPos; // CP (Default Inline) + Dict *measure; // Measure + double captionTextHorizontal; // CO (Default [0, 0]) + double captionTextVertical; // +}; + +//------------------------------------------------------------------------ +// AnnotTextMarkup +//------------------------------------------------------------------------ + +class AnnotTextMarkup: public AnnotMarkup { +public: + + AnnotTextMarkup(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType); + AnnotTextMarkup(PDFDoc *docA, Dict *dict, Object *obj); + virtual ~AnnotTextMarkup(); + + virtual void draw(Gfx *gfx, GBool printing); + + // typeHighlight, typeUnderline, typeSquiggly or typeStrikeOut + void setType(AnnotSubtype new_type); + + void setQuadrilaterals(AnnotQuadrilaterals *quadPoints); + + AnnotQuadrilaterals *getQuadrilaterals() const { return quadrilaterals; } + +protected: + + void initialize(PDFDoc *docA, Dict *dict); + + AnnotQuadrilaterals *quadrilaterals; // QuadPoints +}; + +//------------------------------------------------------------------------ +// AnnotStamp +//------------------------------------------------------------------------ + +class AnnotStamp: public AnnotMarkup { +public: + + AnnotStamp(PDFDoc *docA, PDFRectangle *rect); + AnnotStamp(PDFDoc *docA, Dict *dict, Object *obj); + ~AnnotStamp(); + + void setIcon(GooString *new_icon); + + // getters + GooString *getIcon() const { return icon; } + +private: + + void initialize(PDFDoc *docA, Dict *dict); + + GooString *icon; // Name (Default Draft) +}; + +//------------------------------------------------------------------------ +// AnnotGeometry +//------------------------------------------------------------------------ + +class AnnotGeometry: public AnnotMarkup { +public: + + AnnotGeometry(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType); + AnnotGeometry(PDFDoc *docA, Dict *dict, Object *obj); + ~AnnotGeometry(); + + virtual void draw(Gfx *gfx, GBool printing); + + void setType(AnnotSubtype new_type); // typeSquare or typeCircle + void setInteriorColor(AnnotColor *new_color); + + // getters + AnnotColor *getInteriorColor() const { return interiorColor; } + AnnotBorderEffect *getBorderEffect() const { return borderEffect; } + PDFRectangle *getGeometryRect() const { return geometryRect; } + +private: + + void initialize(PDFDoc *docA, Dict *dict); + + AnnotColor *interiorColor; // IC + AnnotBorderEffect *borderEffect; // BE + PDFRectangle *geometryRect; // RD (combined with Rect) +}; + +//------------------------------------------------------------------------ +// AnnotPolygon +//------------------------------------------------------------------------ + +class AnnotPolygon: public AnnotMarkup { +public: + + enum AnnotPolygonIntent { + polygonCloud, // PolygonCloud + polylineDimension, // PolyLineDimension + polygonDimension // PolygonDimension + }; + + AnnotPolygon(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType); + AnnotPolygon(PDFDoc *docA, Dict *dict, Object *obj); + ~AnnotPolygon(); + + virtual void draw(Gfx *gfx, GBool printing); + + void setType(AnnotSubtype new_type); // typePolygon or typePolyLine + void setVertices(AnnotPath *path); + void setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end); + void setInteriorColor(AnnotColor *new_color); + void setIntent(AnnotPolygonIntent new_intent); + + // getters + AnnotPath *getVertices() const { return vertices; } + AnnotLineEndingStyle getStartStyle() const { return startStyle; } + AnnotLineEndingStyle getEndStyle() const { return endStyle; } + AnnotColor *getInteriorColor() const { return interiorColor; } + AnnotBorderEffect *getBorderEffect() const { return borderEffect; } + AnnotPolygonIntent getIntent() const { return intent; } + +private: + + void initialize(PDFDoc *docA, Dict *dict); + + // required + AnnotPath *vertices; // Vertices + + // optional + AnnotLineEndingStyle startStyle; // LE (Default [/None /None]) + AnnotLineEndingStyle endStyle; // + // inherited from Annot + // AnnotBorderBS border; // BS + AnnotColor *interiorColor; // IC + AnnotBorderEffect *borderEffect; // BE + AnnotPolygonIntent intent; // IT + // Measure +}; + +//------------------------------------------------------------------------ +// AnnotCaret +//------------------------------------------------------------------------ + +class AnnotCaret: public AnnotMarkup { +public: + + enum AnnotCaretSymbol { + symbolNone, // None + symbolP // P + }; + + AnnotCaret(PDFDoc *docA, PDFRectangle *rect); + AnnotCaret(PDFDoc *docA, Dict *dict, Object *obj); + ~AnnotCaret(); + + void setSymbol(AnnotCaretSymbol new_symbol); + + // getters + AnnotCaretSymbol getSymbol() const { return symbol; } + PDFRectangle *getCaretRect() const { return caretRect; } + +private: + + void initialize(PDFDoc *docA, Dict *dict); + + AnnotCaretSymbol symbol; // Sy (Default None) + PDFRectangle *caretRect; // RD (combined with Rect) +}; + +//------------------------------------------------------------------------ +// AnnotInk +//------------------------------------------------------------------------ + +class AnnotInk: public AnnotMarkup { +public: + + AnnotInk(PDFDoc *docA, PDFRectangle *rect); + AnnotInk(PDFDoc *docA, Dict *dict, Object *obj); + ~AnnotInk(); + + virtual void draw(Gfx *gfx, GBool printing); + + void setInkList(AnnotPath **paths, int n_paths); + + // getters + AnnotPath **getInkList() const { return inkList; } + int getInkListLength() const { return inkListLength; } + +private: + + void initialize(PDFDoc *docA, Dict *dict); + void writeInkList(AnnotPath **paths, int n_paths, Array *dest_array); + void parseInkList(Array *src_array); + void freeInkList(); + + // required + AnnotPath **inkList; // InkList + int inkListLength; + + // optional + // inherited from Annot + // AnnotBorderBS border; // BS +}; + +//------------------------------------------------------------------------ +// AnnotFileAttachment +//------------------------------------------------------------------------ + +class AnnotFileAttachment: public AnnotMarkup { +public: + + AnnotFileAttachment(PDFDoc *docA, PDFRectangle *rect, GooString *filename); + AnnotFileAttachment(PDFDoc *docA, Dict *dict, Object *obj); + ~AnnotFileAttachment(); + + virtual void draw(Gfx *gfx, GBool printing); + + // getters + Object *getFile() { return &file; } + GooString *getName() const { return name; } + +private: + + void initialize(PDFDoc *docA, Dict *dict); + + // required + Object file; // FS + + // optional + GooString *name; // Name +}; + +//------------------------------------------------------------------------ +// AnnotSound +//------------------------------------------------------------------------ + +class AnnotSound: public AnnotMarkup { +public: + + AnnotSound(PDFDoc *docA, PDFRectangle *rect, Sound *soundA); + AnnotSound(PDFDoc *docA, Dict *dict, Object *obj); + ~AnnotSound(); + + virtual void draw(Gfx *gfx, GBool printing); + + // getters + Sound *getSound() { return sound; } + GooString *getName() const { return name; } + +private: + + void initialize(PDFDoc *docA, Dict *dict); + + // required + Sound *sound; // Sound + + // optional + GooString *name; // Name +}; + +//------------------------------------------------------------------------ +// AnnotWidget +//------------------------------------------------------------------------ + +class AnnotWidget: public Annot { +public: + + enum AnnotWidgetHighlightMode { + highlightModeNone, // N + highlightModeInvert, // I + highlightModeOutline, // O + highlightModePush // P,T + }; + + AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj); + AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj, FormField *fieldA); + virtual ~AnnotWidget(); + + virtual void draw(Gfx *gfx, GBool printing); + + void drawBorder(); + void drawFormFieldButton(GfxResources *resources, GooString *da); + void drawFormFieldText(GfxResources *resources, GooString *da); + void drawFormFieldChoice(GfxResources *resources, GooString *da); + void generateFieldAppearance (); + void updateAppearanceStream (); + + AnnotWidgetHighlightMode getMode() { return mode; } + AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs; } + LinkAction *getAction() { return action; } + LinkAction *getAdditionalAction(AdditionalActionsType type); + LinkAction *getFormAdditionalAction(FormAdditionalActionsType type); + Dict *getParent() { return parent; } + +private: + + void initialize(PDFDoc *docA, Dict *dict); + + void drawText(GooString *text, GooString *da, GfxResources *resources, + GBool multiline, int comb, int quadding, + GBool txField, GBool forceZapfDingbats, + GBool password=false); + void drawListBox(FormFieldChoice *fieldChoice, + GooString *da, GfxResources *resources, int quadding); + + Form *form; + FormField *field; // FormField object for this annotation + AnnotWidgetHighlightMode mode; // H (Default I) + AnnotAppearanceCharacs *appearCharacs; // MK + LinkAction *action; // A + Object additionalActions; // AA + // inherited from Annot + // AnnotBorderBS border; // BS + Dict *parent; // Parent + GBool addDingbatsResource; + Ref updatedAppearanceStream; // {-1,-1} if updateAppearanceStream has never been called +}; + +//------------------------------------------------------------------------ +// Annot3D +//------------------------------------------------------------------------ + +class Annot3D: public Annot { + class Activation { + public: + enum ActivationATrigger { + aTriggerUnknown, + aTriggerPageOpened, // PO + aTriggerPageVisible, // PV + aTriggerUserAction // XA + }; + + enum ActivationAState { + aStateUnknown, + aStateEnabled, // I + aStateDisabled // L + }; + + enum ActivationDTrigger { + dTriggerUnknown, + dTriggerPageClosed, // PC + dTriggerPageInvisible, // PI + dTriggerUserAction // XD + }; + + enum ActivationDState { + dStateUnknown, + dStateUninstantiaded, // U + dStateInstantiated, // I + dStateLive // L + }; + + Activation(Dict *dict); + private: + + ActivationATrigger aTrigger; // A (Default XA) + ActivationAState aState; // AIS (Default L) + ActivationDTrigger dTrigger; // D (Default PI) + ActivationDState dState; // DIS (Default U) + GBool displayToolbar; // TB (Default true) + GBool displayNavigation; // NP (Default false); + }; +public: + + Annot3D(PDFDoc *docA, PDFRectangle *rect); + Annot3D(PDFDoc *docA, Dict *dict, Object *obj); + ~Annot3D(); + + // getters + +private: + + void initialize(PDFDoc *docA, Dict *dict); + + Activation *activation; // 3DA +}; + +//------------------------------------------------------------------------ +// Annots +//------------------------------------------------------------------------ + +class Annots { +public: + + // Build a list of Annot objects and call setPage on them + Annots(PDFDoc *docA, int page, Object *annotsObj); + + ~Annots(); + + // Iterate through list of annotations. + int getNumAnnots() { return nAnnots; } + Annot *getAnnot(int i) { return annots[i]; } + void appendAnnot(Annot *annot); + GBool removeAnnot(Annot *annot); + +private: + Annot* createAnnot(Dict* dict, Object *obj); + Annot *findAnnot(Ref *ref); + + PDFDoc *doc; + Annot **annots; + int nAnnots; + int size; +}; + +#endif diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Array.cc b/source/libs/poppler/poppler-0.33.0/poppler/Array.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Array.cc rename to source/libs/poppler/poppler-0.33.0/poppler/Array.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Array.h b/source/libs/poppler/poppler-0.33.0/poppler/Array.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Array.h rename to source/libs/poppler/poppler-0.33.0/poppler/Array.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/BuiltinFont.cc b/source/libs/poppler/poppler-0.33.0/poppler/BuiltinFont.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/BuiltinFont.cc rename to source/libs/poppler/poppler-0.33.0/poppler/BuiltinFont.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/BuiltinFont.h b/source/libs/poppler/poppler-0.33.0/poppler/BuiltinFont.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/BuiltinFont.h rename to source/libs/poppler/poppler-0.33.0/poppler/BuiltinFont.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/BuiltinFontTables.cc b/source/libs/poppler/poppler-0.33.0/poppler/BuiltinFontTables.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/BuiltinFontTables.cc rename to source/libs/poppler/poppler-0.33.0/poppler/BuiltinFontTables.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/BuiltinFontTables.h b/source/libs/poppler/poppler-0.33.0/poppler/BuiltinFontTables.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/BuiltinFontTables.h rename to source/libs/poppler/poppler-0.33.0/poppler/BuiltinFontTables.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/CMap.cc b/source/libs/poppler/poppler-0.33.0/poppler/CMap.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/CMap.cc rename to source/libs/poppler/poppler-0.33.0/poppler/CMap.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/CMap.h b/source/libs/poppler/poppler-0.33.0/poppler/CMap.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/CMap.h rename to source/libs/poppler/poppler-0.33.0/poppler/CMap.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/CachedFile.cc b/source/libs/poppler/poppler-0.33.0/poppler/CachedFile.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/CachedFile.cc rename to source/libs/poppler/poppler-0.33.0/poppler/CachedFile.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/CachedFile.h b/source/libs/poppler/poppler-0.33.0/poppler/CachedFile.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/CachedFile.h rename to source/libs/poppler/poppler-0.33.0/poppler/CachedFile.h diff --git a/source/libs/poppler/poppler-0.33.0/poppler/CairoFontEngine.cc b/source/libs/poppler/poppler-0.33.0/poppler/CairoFontEngine.cc new file mode 100644 index 000000000..1d611b59d --- /dev/null +++ b/source/libs/poppler/poppler-0.33.0/poppler/CairoFontEngine.cc @@ -0,0 +1,832 @@ +//======================================================================== +// +// CairoFontEngine.cc +// +// Copyright 2003 Glyph & Cog, LLC +// Copyright 2004 Red Hat, Inc +// +//======================================================================== + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2005-2007 Jeff Muizelaar <jeff@infidigm.net> +// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> +// Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> +// Copyright (C) 2005, 2009, 2012, 2013, 2015 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006, 2007, 2010, 2011 Carlos Garcia Campos <carlosgc@gnome.org> +// Copyright (C) 2007 Koji Otani <sho@bbr.jp> +// Copyright (C) 2008, 2009 Chris Wilson <chris@chris-wilson.co.uk> +// Copyright (C) 2008, 2012, 2014 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2009 Darren Kenny <darren.kenny@sun.com> +// Copyright (C) 2010 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> +// Copyright (C) 2010 Jan Kümmel <jan+freedesktop@snorc.org> +// Copyright (C) 2012 Hib Eris <hib@hiberis.nl> +// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2015 Jason Crain <jason@aquaticape.us> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#include <config.h> + +#include "config.h" +#include <string.h> +#include "CairoFontEngine.h" +#include "CairoOutputDev.h" +#include "GlobalParams.h" +#include <fofi/FoFiTrueType.h> +#include <fofi/FoFiType1C.h> +#include "goo/gfile.h" +#include "Error.h" +#include "XRef.h" +#include "Gfx.h" +#include "Page.h" + +#if HAVE_FCNTL_H && HAVE_SYS_MMAN_H && HAVE_SYS_STAT_H +#include <fcntl.h> +#include <sys/stat.h> +#include <sys/mman.h> +#define CAN_CHECK_OPEN_FACES 1 +#endif + +#ifdef USE_GCC_PRAGMAS +#pragma implementation +#endif + +#if MULTITHREADED +# define fontEngineLocker() MutexLocker locker(&mutex) +#else +# define fontEngineLocker() +#endif + +//------------------------------------------------------------------------ +// CairoFont +//------------------------------------------------------------------------ + +CairoFont::CairoFont(Ref ref, + cairo_font_face_t *cairo_font_face, + int *codeToGID, + Guint codeToGIDLen, + GBool substitute, + GBool printing) : ref(ref), + cairo_font_face(cairo_font_face), + codeToGID(codeToGID), + codeToGIDLen(codeToGIDLen), + substitute(substitute), + printing(printing) { } + +CairoFont::~CairoFont() { + cairo_font_face_destroy (cairo_font_face); + gfree(codeToGID); +} + +GBool +CairoFont::matches(Ref &other, GBool printingA) { + return (other.num == ref.num && other.gen == ref.gen); +} + +cairo_font_face_t * +CairoFont::getFontFace(void) { + return cairo_font_face; +} + +unsigned long +CairoFont::getGlyph(CharCode code, + Unicode *u, int uLen) { + FT_UInt gid; + + if (codeToGID && code < codeToGIDLen) { + gid = (FT_UInt)codeToGID[code]; + } else { + gid = (FT_UInt)code; + } + return gid; +} + +double +CairoFont::getSubstitutionCorrection(GfxFont *gfxFont) +{ + double w1, w2; + CharCode code; + char *name; + + // for substituted fonts: adjust the font matrix -- compare the + // width of 'm' in the original font and the substituted font + if (isSubstitute() && !gfxFont->isCIDFont()) { + for (code = 0; code < 256; ++code) { + if ((name = ((Gfx8BitFont *)gfxFont)->getCharName(code)) && + name[0] == 'm' && name[1] == '\0') { + break; + } + } + if (code < 256) { + w1 = ((Gfx8BitFont *)gfxFont)->getWidth(code); + { + cairo_matrix_t m; + cairo_matrix_init_identity(&m); + cairo_font_options_t *options = cairo_font_options_create(); + cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE); + cairo_font_options_set_hint_metrics(options, CAIRO_HINT_METRICS_OFF); + cairo_scaled_font_t *scaled_font = cairo_scaled_font_create(cairo_font_face, &m, &m, options); + + cairo_text_extents_t extents; + cairo_scaled_font_text_extents(scaled_font, "m", &extents); + + cairo_scaled_font_destroy(scaled_font); + cairo_font_options_destroy(options); + w2 = extents.x_advance; + } + if (!gfxFont->isSymbolic()) { + // if real font is substantially narrower than substituted + // font, reduce the font size accordingly + if (w1 > 0.01 && w1 < 0.9 * w2) { + w1 /= w2; + return w1; + } + } + } + } + return 1.0; +} + +//------------------------------------------------------------------------ +// CairoFreeTypeFont +//------------------------------------------------------------------------ + +static cairo_user_data_key_t _ft_cairo_key; + +static void +_ft_done_face_uncached (void *closure) +{ + FT_Face face = (FT_Face) closure; + FT_Done_Face (face); +} + +static GBool +_ft_new_face_uncached (FT_Library lib, + const char *filename, + char *font_data, + int font_data_len, + FT_Face *face_out, + cairo_font_face_t **font_face_out) +{ + FT_Face face; + cairo_font_face_t *font_face; + + if (font_data == NULL) { + if (FT_New_Face (lib, filename, 0, &face)) + return gFalse; + } else { + if (FT_New_Memory_Face (lib, (unsigned char *)font_data, font_data_len, 0, &face)) + return gFalse; + } + + font_face = cairo_ft_font_face_create_for_ft_face (face, + FT_LOAD_NO_HINTING | + FT_LOAD_NO_BITMAP); + if (cairo_font_face_set_user_data (font_face, + &_ft_cairo_key, + face, + _ft_done_face_uncached)) + { + _ft_done_face_uncached (face); + cairo_font_face_destroy (font_face); + return gFalse; + } + + *face_out = face; + *font_face_out = font_face; + return gTrue; +} + +#if CAN_CHECK_OPEN_FACES +static struct _ft_face_data { + struct _ft_face_data *prev, *next, **head; + + int fd; + unsigned long hash; + size_t size; + unsigned char *bytes; + + FT_Library lib; + FT_Face face; + cairo_font_face_t *font_face; +} *_ft_open_faces; + +static unsigned long +_djb_hash (const unsigned char *bytes, size_t len) +{ + unsigned long hash = 5381; + while (len--) { + unsigned char c = *bytes++; + hash *= 33; + hash ^= c; + } + return hash; +} + +static GBool +_ft_face_data_equal (struct _ft_face_data *a, struct _ft_face_data *b) +{ + if (a->lib != b->lib) + return gFalse; + if (a->size != b->size) + return gFalse; + if (a->hash != b->hash) + return gFalse; + + return memcmp (a->bytes, b->bytes, a->size) == 0; +} + +static void +_ft_done_face (void *closure) +{ + struct _ft_face_data *data = (struct _ft_face_data *) closure; + + if (data->next) + data->next->prev = data->prev; + if (data->prev) + data->prev->next = data->next; + else + _ft_open_faces = data->next; + + if (data->fd != -1) { +#if defined(__SUNPRO_CC) && defined(__sun) && defined(__SVR4) + munmap ((char*)data->bytes, data->size); +#else + munmap (data->bytes, data->size); +#endif + close (data->fd); + } else { + gfree (data->bytes); + } + + FT_Done_Face (data->face); + gfree (data); +} + +static GBool +_ft_new_face (FT_Library lib, + const char *filename, + char *font_data, + int font_data_len, + FT_Face *face_out, + cairo_font_face_t **font_face_out) +{ + struct _ft_face_data *l; + struct stat st; + struct _ft_face_data tmpl; + + tmpl.fd = -1; + + if (font_data == NULL) { + /* if we fail to mmap the file, just pass it to FreeType instead */ + tmpl.fd = open (filename, O_RDONLY); + if (tmpl.fd == -1) + return _ft_new_face_uncached (lib, filename, font_data, font_data_len, face_out, font_face_out); + + if (fstat (tmpl.fd, &st) == -1) { + close (tmpl.fd); + return _ft_new_face_uncached (lib, filename, font_data, font_data_len, face_out, font_face_out); + } + + tmpl.bytes = (unsigned char *) mmap (NULL, st.st_size, + PROT_READ, MAP_PRIVATE, + tmpl.fd, 0); + if (tmpl.bytes == MAP_FAILED) { + close (tmpl.fd); + return _ft_new_face_uncached (lib, filename, font_data, font_data_len, face_out, font_face_out); + } + tmpl.size = st.st_size; + } else { + tmpl.bytes = (unsigned char*) font_data; + tmpl.size = font_data_len; + } + + /* check to see if this is a duplicate of any of the currently open fonts */ + tmpl.lib = lib; + tmpl.hash = _djb_hash (tmpl.bytes, tmpl.size); + + for (l = _ft_open_faces; l; l = l->next) { + if (_ft_face_data_equal (l, &tmpl)) { + if (tmpl.fd != -1) { +#if defined(__SUNPRO_CC) && defined(__sun) && defined(__SVR4) + munmap ((char*)tmpl.bytes, tmpl.size); +#else + munmap (tmpl.bytes, tmpl.size); +#endif + close (tmpl.fd); + } else { + gfree (tmpl.bytes); + } + *face_out = l->face; + *font_face_out = cairo_font_face_reference (l->font_face); + return gTrue; + } + } + + /* not a dup, open and insert into list */ + if (FT_New_Memory_Face (lib, + (FT_Byte *) tmpl.bytes, tmpl.size, + 0, &tmpl.face)) + { + if (tmpl.fd != -1) { +#if defined(__SUNPRO_CC) && defined(__sun) && defined(__SVR4) + munmap ((char*)tmpl.bytes, tmpl.size); +#else + munmap (tmpl.bytes, tmpl.size); +#endif + + close (tmpl.fd); + } + return gFalse; + } + + l = (struct _ft_face_data *) gmallocn (1, sizeof (struct _ft_face_data)); + *l = tmpl; + l->prev = NULL; + l->next = _ft_open_faces; + if (_ft_open_faces) + _ft_open_faces->prev = l; + _ft_open_faces = l; + + l->font_face = cairo_ft_font_face_create_for_ft_face (tmpl.face, + FT_LOAD_NO_HINTING | + FT_LOAD_NO_BITMAP); + if (cairo_font_face_set_user_data (l->font_face, + &_ft_cairo_key, + l, + _ft_done_face)) + { + cairo_font_face_destroy (l->font_face); + _ft_done_face (l); + return gFalse; + } + + *face_out = l->face; + *font_face_out = l->font_face; + return gTrue; +} +#else +#define _ft_new_face _ft_new_face_uncached +#endif + +CairoFreeTypeFont::CairoFreeTypeFont(Ref ref, + cairo_font_face_t *cairo_font_face, + int *codeToGID, + Guint codeToGIDLen, + GBool substitute) : CairoFont(ref, + cairo_font_face, + codeToGID, + codeToGIDLen, + substitute, + gTrue) { } + +CairoFreeTypeFont::~CairoFreeTypeFont() { } + +CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, + FT_Library lib, GBool useCIDs) { + Object refObj, strObj; + GooString *fileName; + char *fileNameC; + char *font_data; + int font_data_len; + int i, n; + GfxFontType fontType; + GfxFontLoc *fontLoc; + char **enc; + const char *name; + FoFiTrueType *ff; + FoFiType1C *ff1c; + Ref ref; + FT_Face face; + cairo_font_face_t *font_face; + + int *codeToGID; + Guint codeToGIDLen; + + codeToGID = NULL; + codeToGIDLen = 0; + font_data = NULL; + font_data_len = 0; + fileName = NULL; + fileNameC = NULL; + + GBool substitute = gFalse; + + ref = *gfxFont->getID(); + fontType = gfxFont->getType(); + + if (!(fontLoc = gfxFont->locateFont(xref, NULL))) { + error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'", + gfxFont->getName() ? gfxFont->getName()->getCString() + : "(unnamed)"); + goto err2; + } + + // embedded font + if (fontLoc->locType == gfxFontLocEmbedded) { + font_data = gfxFont->readEmbFontFile(xref, &font_data_len); + if (NULL == font_data) + goto err2; + + // external font + } else { // gfxFontLocExternal + fileName = fontLoc->path; + fontType = fontLoc->fontType; + substitute = gTrue; + } + + if (fileName != NULL) { + fileNameC = fileName->getCString(); + } + + switch (fontType) { + case fontType1: + case fontType1C: + case fontType1COT: + if (! _ft_new_face (lib, fileNameC, font_data, font_data_len, &face, &font_face)) { + error(errSyntaxError, -1, "could not create type1 face"); + goto err2; + } + + enc = ((Gfx8BitFont *)gfxFont)->getEncoding(); + + codeToGID = (int *)gmallocn(256, sizeof(int)); + codeToGIDLen = 256; + for (i = 0; i < 256; ++i) { + codeToGID[i] = 0; + if ((name = enc[i])) { + codeToGID[i] = FT_Get_Name_Index(face, (char*)name); + if (codeToGID[i] == 0) { + name = GfxFont::getAlternateName(name); + if (name) { + codeToGID[i] = FT_Get_Name_Index(face, (char*)name); + } + } + } + } + break; + case fontCIDType2: + case fontCIDType2OT: + codeToGID = NULL; + n = 0; + if (((GfxCIDFont *)gfxFont)->getCIDToGID()) { + n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen(); + if (n) { + codeToGID = (int *)gmallocn(n, sizeof(int)); + memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), + n * sizeof(int)); + } + } else { + if (font_data != NULL) { + ff = FoFiTrueType::make(font_data, font_data_len); + } else { + ff = FoFiTrueType::load(fileNameC); + } + if (! ff) + goto err2; + codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n); + delete ff; + } + codeToGIDLen = n; + /* Fall through */ + case fontTrueType: + if (font_data != NULL) { + ff = FoFiTrueType::make(font_data, font_data_len); + } else { + ff = FoFiTrueType::load(fileNameC); + } + if (! ff) { + error(errSyntaxError, -1, "failed to load truetype font\n"); + goto err2; + } + /* This might be set already for the CIDType2 case */ + if (fontType == fontTrueType) { + codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff); + codeToGIDLen = 256; + } + delete ff; + if (! _ft_new_face (lib, fileNameC, font_data, font_data_len, &face, &font_face)) { + error(errSyntaxError, -1, "could not create truetype face\n"); + goto err2; + } + break; + + case fontCIDType0: + case fontCIDType0C: + + codeToGID = NULL; + codeToGIDLen = 0; + + if (!useCIDs) + { + if (font_data != NULL) { + ff1c = FoFiType1C::make(font_data, font_data_len); + } else { + ff1c = FoFiType1C::load(fileNameC); + } + if (ff1c) { + codeToGID = ff1c->getCIDToGIDMap((int *)&codeToGIDLen); + delete ff1c; + } + } + + if (! _ft_new_face (lib, fileNameC, font_data, font_data_len, &face, &font_face)) { + error(errSyntaxError, -1, "could not create cid face\n"); + goto err2; + } + break; + + default: + fprintf (stderr, "font type %d not handled\n", (int)fontType); + goto err2; + break; + } + + delete fontLoc; + return new CairoFreeTypeFont(ref, + font_face, + codeToGID, codeToGIDLen, + substitute); + + err2: + /* hmm? */ + delete fontLoc; + gfree (codeToGID); + gfree (font_data); + fprintf (stderr, "some font thing failed\n"); + return NULL; +} + +//------------------------------------------------------------------------ +// CairoType3Font +//------------------------------------------------------------------------ + +static const cairo_user_data_key_t type3_font_key = {0}; + +typedef struct _type3_font_info { + GfxFont *font; + PDFDoc *doc; + CairoFontEngine *fontEngine; + GBool printing; + XRef *xref; +} type3_font_info_t; + +static void +_free_type3_font_info(void *closure) +{ + type3_font_info_t *info = (type3_font_info_t *) closure; + + info->font->decRefCnt(); + free (info); +} + +static cairo_status_t +_init_type3_glyph (cairo_scaled_font_t *scaled_font, + cairo_t *cr, + cairo_font_extents_t *extents) +{ + type3_font_info_t *info; + GfxFont *font; + double *mat; + + info = (type3_font_info_t *) + cairo_font_face_get_user_data (cairo_scaled_font_get_font_face (scaled_font), + &type3_font_key); + font = info->font; + mat = font->getFontBBox(); + extents->ascent = mat[3]; /* y2 */ + extents->descent = -mat[3]; /* -y1 */ + extents->height = extents->ascent + extents->descent; + extents->max_x_advance = mat[2] - mat[1]; /* x2 - x1 */ + extents->max_y_advance = 0; + + return CAIRO_STATUS_SUCCESS; +} + +static cairo_status_t +_render_type3_glyph (cairo_scaled_font_t *scaled_font, + unsigned long glyph, + cairo_t *cr, + cairo_text_extents_t *metrics) +{ + Dict *charProcs; + Object charProc; + CairoOutputDev *output_dev; + cairo_matrix_t matrix, invert_y_axis; + double *mat; + double wx, wy; + PDFRectangle box; + type3_font_info_t *info; + GfxFont *font; + Dict *resDict; + Gfx *gfx; + + info = (type3_font_info_t *) + cairo_font_face_get_user_data (cairo_scaled_font_get_font_face (scaled_font), + &type3_font_key); + + font = info->font; + resDict = ((Gfx8BitFont *)font)->getResources(); + charProcs = ((Gfx8BitFont *)(info->font))->getCharProcs(); + if (!charProcs) + return CAIRO_STATUS_USER_FONT_ERROR; + + if ((int)glyph >= charProcs->getLength()) + return CAIRO_STATUS_USER_FONT_ERROR; + + mat = font->getFontMatrix(); + matrix.xx = mat[0]; + matrix.yx = mat[1]; + matrix.xy = mat[2]; + matrix.yy = mat[3]; + matrix.x0 = mat[4]; + matrix.y0 = mat[5]; + cairo_matrix_init_scale (&invert_y_axis, 1, -1); + cairo_matrix_multiply (&matrix, &matrix, &invert_y_axis); + cairo_transform (cr, &matrix); + + output_dev = new CairoOutputDev(); + output_dev->setCairo(cr); + output_dev->setPrinting(info->printing); + + mat = font->getFontBBox(); + box.x1 = mat[0]; + box.y1 = mat[1]; + box.x2 = mat[2]; + box.y2 = mat[3]; + gfx = new Gfx(info->doc, output_dev, resDict, &box, NULL); + output_dev->startDoc(info->doc, info->fontEngine); + output_dev->startPage (1, gfx->getState(), gfx->getXRef()); + output_dev->setInType3Char(gTrue); + gfx->display(charProcs->getVal(glyph, &charProc)); + + output_dev->getType3GlyphWidth (&wx, &wy); + cairo_matrix_transform_distance (&matrix, &wx, &wy); + metrics->x_advance = wx; + metrics->y_advance = wy; + if (output_dev->hasType3GlyphBBox()) { + double *bbox = output_dev->getType3GlyphBBox(); + + cairo_matrix_transform_point (&matrix, &bbox[0], &bbox[1]); + cairo_matrix_transform_point (&matrix, &bbox[2], &bbox[3]); + metrics->x_bearing = bbox[0]; + metrics->y_bearing = bbox[1]; + metrics->width = bbox[2] - bbox[0]; + metrics->height = bbox[3] - bbox[1]; + } + + delete gfx; + delete output_dev; + charProc.free(); + + return CAIRO_STATUS_SUCCESS; +} + + +CairoType3Font *CairoType3Font::create(GfxFont *gfxFont, PDFDoc *doc, + CairoFontEngine *fontEngine, + GBool printing, XRef *xref) { + Object refObj, strObj; + type3_font_info_t *info; + cairo_font_face_t *font_face; + Ref ref; + int *codeToGID; + Guint codeToGIDLen; + int i, j; + char **enc; + Dict *charProcs; + char *name; + + charProcs = ((Gfx8BitFont *)gfxFont)->getCharProcs(); + info = (type3_font_info_t *) malloc(sizeof(*info)); + ref = *gfxFont->getID(); + font_face = cairo_user_font_face_create(); + cairo_user_font_face_set_init_func (font_face, _init_type3_glyph); + cairo_user_font_face_set_render_glyph_func (font_face, _render_type3_glyph); + gfxFont->incRefCnt(); + info->font = gfxFont; + info->doc = doc; + info->fontEngine = fontEngine; + info->printing = printing; + info->xref = xref; + + cairo_font_face_set_user_data (font_face, &type3_font_key, (void *) info, _free_type3_font_info); + + enc = ((Gfx8BitFont *)gfxFont)->getEncoding(); + codeToGID = (int *)gmallocn(256, sizeof(int)); + codeToGIDLen = 256; + for (i = 0; i < 256; ++i) { + codeToGID[i] = 0; + if (charProcs && (name = enc[i])) { + for (j = 0; j < charProcs->getLength(); j++) { + if (strcmp(name, charProcs->getKey(j)) == 0) { + codeToGID[i] = j; + } + } + } + } + + return new CairoType3Font(ref, doc, font_face, codeToGID, codeToGIDLen, printing, xref); +} + +CairoType3Font::CairoType3Font(Ref ref, + PDFDoc *doc, + cairo_font_face_t *cairo_font_face, + int *codeToGID, + Guint codeToGIDLen, + GBool printing, XRef *xref) : CairoFont(ref, + cairo_font_face, + codeToGID, + codeToGIDLen, + gFalse, + printing), + doc(doc) { } + +CairoType3Font::~CairoType3Font() { } + +GBool +CairoType3Font::matches(Ref &other, GBool printingA) { + return (other.num == ref.num && other.gen == ref.gen && printing == printingA); +} + + +//------------------------------------------------------------------------ +// CairoFontEngine +//------------------------------------------------------------------------ + +CairoFontEngine::CairoFontEngine(FT_Library libA) { + int i; + + lib = libA; + for (i = 0; i < cairoFontCacheSize; ++i) { + fontCache[i] = NULL; + } + + FT_Int major, minor, patch; + // as of FT 2.1.8, CID fonts are indexed by CID instead of GID + FT_Library_Version(lib, &major, &minor, &patch); + useCIDs = major > 2 || + (major == 2 && (minor > 1 || (minor == 1 && patch > 7))); +#if MULTITHREADED + gInitMutex(&mutex); +#endif +} + +CairoFontEngine::~CairoFontEngine() { + int i; + + for (i = 0; i < cairoFontCacheSize; ++i) { + if (fontCache[i]) + delete fontCache[i]; + } +#if MULTITHREADED + gDestroyMutex(&mutex); +#endif +} + +CairoFont * +CairoFontEngine::getFont(GfxFont *gfxFont, PDFDoc *doc, GBool printing, XRef *xref) { + int i, j; + Ref ref; + CairoFont *font; + GfxFontType fontType; + + fontEngineLocker(); + ref = *gfxFont->getID(); + + for (i = 0; i < cairoFontCacheSize; ++i) { + font = fontCache[i]; + if (font && font->matches(ref, printing)) { + for (j = i; j > 0; --j) { + fontCache[j] = fontCache[j-1]; + } + fontCache[0] = font; + return font; + } + } + + fontType = gfxFont->getType(); + if (fontType == fontType3) + font = CairoType3Font::create (gfxFont, doc, this, printing, xref); + else + font = CairoFreeTypeFont::create (gfxFont, xref, lib, useCIDs); + + //XXX: if font is null should we still insert it into the cache? + if (fontCache[cairoFontCacheSize - 1]) { + delete fontCache[cairoFontCacheSize - 1]; + } + for (j = cairoFontCacheSize - 1; j > 0; --j) { + fontCache[j] = fontCache[j-1]; + } + fontCache[0] = font; + return font; +} diff --git a/source/libs/poppler/poppler-0.32.0/poppler/CairoFontEngine.h b/source/libs/poppler/poppler-0.33.0/poppler/CairoFontEngine.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/CairoFontEngine.h rename to source/libs/poppler/poppler-0.33.0/poppler/CairoFontEngine.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/CairoOutputDev.cc b/source/libs/poppler/poppler-0.33.0/poppler/CairoOutputDev.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/CairoOutputDev.cc rename to source/libs/poppler/poppler-0.33.0/poppler/CairoOutputDev.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/CairoOutputDev.h b/source/libs/poppler/poppler-0.33.0/poppler/CairoOutputDev.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/CairoOutputDev.h rename to source/libs/poppler/poppler-0.33.0/poppler/CairoOutputDev.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/CairoRescaleBox.cc b/source/libs/poppler/poppler-0.33.0/poppler/CairoRescaleBox.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/CairoRescaleBox.cc rename to source/libs/poppler/poppler-0.33.0/poppler/CairoRescaleBox.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/CairoRescaleBox.h b/source/libs/poppler/poppler-0.33.0/poppler/CairoRescaleBox.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/CairoRescaleBox.h rename to source/libs/poppler/poppler-0.33.0/poppler/CairoRescaleBox.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Catalog.cc b/source/libs/poppler/poppler-0.33.0/poppler/Catalog.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Catalog.cc rename to source/libs/poppler/poppler-0.33.0/poppler/Catalog.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Catalog.h b/source/libs/poppler/poppler-0.33.0/poppler/Catalog.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Catalog.h rename to source/libs/poppler/poppler-0.33.0/poppler/Catalog.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/CharCodeToUnicode.cc b/source/libs/poppler/poppler-0.33.0/poppler/CharCodeToUnicode.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/CharCodeToUnicode.cc rename to source/libs/poppler/poppler-0.33.0/poppler/CharCodeToUnicode.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/CharCodeToUnicode.h b/source/libs/poppler/poppler-0.33.0/poppler/CharCodeToUnicode.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/CharCodeToUnicode.h rename to source/libs/poppler/poppler-0.33.0/poppler/CharCodeToUnicode.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/CharTypes.h b/source/libs/poppler/poppler-0.33.0/poppler/CharTypes.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/CharTypes.h rename to source/libs/poppler/poppler-0.33.0/poppler/CharTypes.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/CompactFontTables.h b/source/libs/poppler/poppler-0.33.0/poppler/CompactFontTables.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/CompactFontTables.h rename to source/libs/poppler/poppler-0.33.0/poppler/CompactFontTables.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/CurlCachedFile.cc b/source/libs/poppler/poppler-0.33.0/poppler/CurlCachedFile.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/CurlCachedFile.cc rename to source/libs/poppler/poppler-0.33.0/poppler/CurlCachedFile.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/CurlCachedFile.h b/source/libs/poppler/poppler-0.33.0/poppler/CurlCachedFile.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/CurlCachedFile.h rename to source/libs/poppler/poppler-0.33.0/poppler/CurlCachedFile.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/CurlPDFDocBuilder.cc b/source/libs/poppler/poppler-0.33.0/poppler/CurlPDFDocBuilder.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/CurlPDFDocBuilder.cc rename to source/libs/poppler/poppler-0.33.0/poppler/CurlPDFDocBuilder.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/CurlPDFDocBuilder.h b/source/libs/poppler/poppler-0.33.0/poppler/CurlPDFDocBuilder.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/CurlPDFDocBuilder.h rename to source/libs/poppler/poppler-0.33.0/poppler/CurlPDFDocBuilder.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/DCTStream.cc b/source/libs/poppler/poppler-0.33.0/poppler/DCTStream.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/DCTStream.cc rename to source/libs/poppler/poppler-0.33.0/poppler/DCTStream.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/DCTStream.h b/source/libs/poppler/poppler-0.33.0/poppler/DCTStream.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/DCTStream.h rename to source/libs/poppler/poppler-0.33.0/poppler/DCTStream.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/DateInfo.cc b/source/libs/poppler/poppler-0.33.0/poppler/DateInfo.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/DateInfo.cc rename to source/libs/poppler/poppler-0.33.0/poppler/DateInfo.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/DateInfo.h b/source/libs/poppler/poppler-0.33.0/poppler/DateInfo.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/DateInfo.h rename to source/libs/poppler/poppler-0.33.0/poppler/DateInfo.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Decrypt.cc b/source/libs/poppler/poppler-0.33.0/poppler/Decrypt.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Decrypt.cc rename to source/libs/poppler/poppler-0.33.0/poppler/Decrypt.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Decrypt.h b/source/libs/poppler/poppler-0.33.0/poppler/Decrypt.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Decrypt.h rename to source/libs/poppler/poppler-0.33.0/poppler/Decrypt.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Dict.cc b/source/libs/poppler/poppler-0.33.0/poppler/Dict.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Dict.cc rename to source/libs/poppler/poppler-0.33.0/poppler/Dict.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Dict.h b/source/libs/poppler/poppler-0.33.0/poppler/Dict.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Dict.h rename to source/libs/poppler/poppler-0.33.0/poppler/Dict.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Error.cc b/source/libs/poppler/poppler-0.33.0/poppler/Error.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Error.cc rename to source/libs/poppler/poppler-0.33.0/poppler/Error.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Error.h b/source/libs/poppler/poppler-0.33.0/poppler/Error.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Error.h rename to source/libs/poppler/poppler-0.33.0/poppler/Error.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/ErrorCodes.h b/source/libs/poppler/poppler-0.33.0/poppler/ErrorCodes.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/ErrorCodes.h rename to source/libs/poppler/poppler-0.33.0/poppler/ErrorCodes.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/FileSpec.cc b/source/libs/poppler/poppler-0.33.0/poppler/FileSpec.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/FileSpec.cc rename to source/libs/poppler/poppler-0.33.0/poppler/FileSpec.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/FileSpec.h b/source/libs/poppler/poppler-0.33.0/poppler/FileSpec.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/FileSpec.h rename to source/libs/poppler/poppler-0.33.0/poppler/FileSpec.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/FlateStream.cc b/source/libs/poppler/poppler-0.33.0/poppler/FlateStream.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/FlateStream.cc rename to source/libs/poppler/poppler-0.33.0/poppler/FlateStream.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/FlateStream.h b/source/libs/poppler/poppler-0.33.0/poppler/FlateStream.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/FlateStream.h rename to source/libs/poppler/poppler-0.33.0/poppler/FlateStream.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/FontEncodingTables.cc b/source/libs/poppler/poppler-0.33.0/poppler/FontEncodingTables.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/FontEncodingTables.cc rename to source/libs/poppler/poppler-0.33.0/poppler/FontEncodingTables.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/FontEncodingTables.h b/source/libs/poppler/poppler-0.33.0/poppler/FontEncodingTables.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/FontEncodingTables.h rename to source/libs/poppler/poppler-0.33.0/poppler/FontEncodingTables.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/FontInfo.cc b/source/libs/poppler/poppler-0.33.0/poppler/FontInfo.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/FontInfo.cc rename to source/libs/poppler/poppler-0.33.0/poppler/FontInfo.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/FontInfo.h b/source/libs/poppler/poppler-0.33.0/poppler/FontInfo.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/FontInfo.h rename to source/libs/poppler/poppler-0.33.0/poppler/FontInfo.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Form.cc b/source/libs/poppler/poppler-0.33.0/poppler/Form.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Form.cc rename to source/libs/poppler/poppler-0.33.0/poppler/Form.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Form.h b/source/libs/poppler/poppler-0.33.0/poppler/Form.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Form.h rename to source/libs/poppler/poppler-0.33.0/poppler/Form.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Function.cc b/source/libs/poppler/poppler-0.33.0/poppler/Function.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Function.cc rename to source/libs/poppler/poppler-0.33.0/poppler/Function.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Function.h b/source/libs/poppler/poppler-0.33.0/poppler/Function.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Function.h rename to source/libs/poppler/poppler-0.33.0/poppler/Function.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Gfx.cc b/source/libs/poppler/poppler-0.33.0/poppler/Gfx.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Gfx.cc rename to source/libs/poppler/poppler-0.33.0/poppler/Gfx.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Gfx.h b/source/libs/poppler/poppler-0.33.0/poppler/Gfx.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Gfx.h rename to source/libs/poppler/poppler-0.33.0/poppler/Gfx.h diff --git a/source/libs/poppler/poppler-0.33.0/poppler/GfxFont.cc b/source/libs/poppler/poppler-0.33.0/poppler/GfxFont.cc new file mode 100644 index 000000000..81f59037f --- /dev/null +++ b/source/libs/poppler/poppler-0.33.0/poppler/GfxFont.cc @@ -0,0 +1,2620 @@ +//======================================================================== +// +// GfxFont.cc +// +// Copyright 1996-2003 Glyph & Cog, LLC +// +//======================================================================== + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2005, 2006, 2008-2010, 2012, 2014, 2015 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> +// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> +// Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org> +// Copyright (C) 2007 Jeff Muizelaar <jeff@infidigm.net> +// Copyright (C) 2007 Koji Otani <sho@bbr.jp> +// Copyright (C) 2007 Ed Catmur <ed@catmur.co.uk> +// Copyright (C) 2008 Jonathan Kew <jonathan_kew@sil.org> +// Copyright (C) 2008 Ed Avis <eda@waniasset.com> +// Copyright (C) 2008, 2010 Hib Eris <hib@hiberis.nl> +// Copyright (C) 2009 Peter Kerzum <kerzum@yandex-team.ru> +// Copyright (C) 2009, 2010 David Benjamin <davidben@mit.edu> +// Copyright (C) 2011 Axel Strübing <axel.struebing@freenet.de> +// Copyright (C) 2011, 2012, 2014 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2012 Yi Yang <ahyangyi@gmail.com> +// Copyright (C) 2012 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> +// Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2013-2015 Jason Crain <jason@aquaticape.us> +// Copyright (C) 2014 Olly Betts <olly@survex.com> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#include <config.h> + +#ifdef USE_GCC_PRAGMAS +#pragma implementation +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <math.h> +#include <limits.h> +#include <algorithm> +#include "goo/gmem.h" +#include "Error.h" +#include "Object.h" +#include "Dict.h" +#include "GlobalParams.h" +#include "CMap.h" +#include "CharCodeToUnicode.h" +#include "FontEncodingTables.h" +#include "BuiltinFontTables.h" +#include "UnicodeTypeTable.h" +#include <fofi/FoFiIdentifier.h> +#include <fofi/FoFiType1.h> +#include <fofi/FoFiType1C.h> +#include <fofi/FoFiTrueType.h> +#include "GfxFont.h" +#include "PSOutputDev.h" + +//------------------------------------------------------------------------ + +struct Base14FontMapEntry { + const char *altName; + const char *base14Name; +}; + +static const Base14FontMapEntry base14FontMap[] = { + { "Arial", "Helvetica" }, + { "Arial,Bold", "Helvetica-Bold" }, + { "Arial,BoldItalic", "Helvetica-BoldOblique" }, + { "Arial,Italic", "Helvetica-Oblique" }, + { "Arial-Bold", "Helvetica-Bold" }, + { "Arial-BoldItalic", "Helvetica-BoldOblique" }, + { "Arial-BoldItalicMT", "Helvetica-BoldOblique" }, + { "Arial-BoldMT", "Helvetica-Bold" }, + { "Arial-Italic", "Helvetica-Oblique" }, + { "Arial-ItalicMT", "Helvetica-Oblique" }, + { "ArialMT", "Helvetica" }, + { "Courier", "Courier" }, + { "Courier,Bold", "Courier-Bold" }, + { "Courier,BoldItalic", "Courier-BoldOblique" }, + { "Courier,Italic", "Courier-Oblique" }, + { "Courier-Bold", "Courier-Bold" }, + { "Courier-BoldOblique", "Courier-BoldOblique" }, + { "Courier-Oblique", "Courier-Oblique" }, + { "CourierNew", "Courier" }, + { "CourierNew,Bold", "Courier-Bold" }, + { "CourierNew,BoldItalic", "Courier-BoldOblique" }, + { "CourierNew,Italic", "Courier-Oblique" }, + { "CourierNew-Bold", "Courier-Bold" }, + { "CourierNew-BoldItalic", "Courier-BoldOblique" }, + { "CourierNew-Italic", "Courier-Oblique" }, + { "CourierNewPS-BoldItalicMT", "Courier-BoldOblique" }, + { "CourierNewPS-BoldMT", "Courier-Bold" }, + { "CourierNewPS-ItalicMT", "Courier-Oblique" }, + { "CourierNewPSMT", "Courier" }, + { "Helvetica", "Helvetica" }, + { "Helvetica,Bold", "Helvetica-Bold" }, + { "Helvetica,BoldItalic", "Helvetica-BoldOblique" }, + { "Helvetica,Italic", "Helvetica-Oblique" }, + { "Helvetica-Bold", "Helvetica-Bold" }, + { "Helvetica-BoldItalic", "Helvetica-BoldOblique" }, + { "Helvetica-BoldOblique", "Helvetica-BoldOblique" }, + { "Helvetica-Italic", "Helvetica-Oblique" }, + { "Helvetica-Oblique", "Helvetica-Oblique" }, + { "Symbol", "Symbol" }, + { "Symbol,Bold", "Symbol" }, + { "Symbol,BoldItalic", "Symbol" }, + { "Symbol,Italic", "Symbol" }, + { "Times-Bold", "Times-Bold" }, + { "Times-BoldItalic", "Times-BoldItalic" }, + { "Times-Italic", "Times-Italic" }, + { "Times-Roman", "Times-Roman" }, + { "TimesNewRoman", "Times-Roman" }, + { "TimesNewRoman,Bold", "Times-Bold" }, + { "TimesNewRoman,BoldItalic", "Times-BoldItalic" }, + { "TimesNewRoman,Italic", "Times-Italic" }, + { "TimesNewRoman-Bold", "Times-Bold" }, + { "TimesNewRoman-BoldItalic", "Times-BoldItalic" }, + { "TimesNewRoman-Italic", "Times-Italic" }, + { "TimesNewRomanPS", "Times-Roman" }, + { "TimesNewRomanPS-Bold", "Times-Bold" }, + { "TimesNewRomanPS-BoldItalic", "Times-BoldItalic" }, + { "TimesNewRomanPS-BoldItalicMT", "Times-BoldItalic" }, + { "TimesNewRomanPS-BoldMT", "Times-Bold" }, + { "TimesNewRomanPS-Italic", "Times-Italic" }, + { "TimesNewRomanPS-ItalicMT", "Times-Italic" }, + { "TimesNewRomanPSMT", "Times-Roman" }, + { "TimesNewRomanPSMT,Bold", "Times-Bold" }, + { "TimesNewRomanPSMT,BoldItalic", "Times-BoldItalic" }, + { "TimesNewRomanPSMT,Italic", "Times-Italic" }, + { "ZapfDingbats", "ZapfDingbats" } +}; + +//------------------------------------------------------------------------ + +// index: {fixed:0, sans-serif:4, serif:8} + bold*2 + italic +// NB: must be in same order as psSubstFonts in PSOutputDev.cc +static const char *base14SubstFonts[14] = { + "Courier", + "Courier-Oblique", + "Courier-Bold", + "Courier-BoldOblique", + "Helvetica", + "Helvetica-Oblique", + "Helvetica-Bold", + "Helvetica-BoldOblique", + "Times-Roman", + "Times-Italic", + "Times-Bold", + "Times-BoldItalic", + // the last two are never used for substitution + "Symbol", + "ZapfDingbats" +}; + +//------------------------------------------------------------------------ + +static int parseCharName(char *charName, Unicode *uBuf, int uLen, + GBool names, GBool ligatures, + GBool numeric, GBool hex, GBool variants); + +//------------------------------------------------------------------------ + +static int readFromStream(void *data) { + return ((Stream *)data)->getChar(); +} + +//------------------------------------------------------------------------ +// GfxFontLoc +//------------------------------------------------------------------------ + +GfxFontLoc::GfxFontLoc() { + path = NULL; + fontNum = 0; + encoding = NULL; + substIdx = -1; +} + +GfxFontLoc::~GfxFontLoc() { + if (path) { + delete path; + } + if (encoding) { + delete encoding; + } +} + +//------------------------------------------------------------------------ +// GfxFont +//------------------------------------------------------------------------ + +GfxFont *GfxFont::makeFont(XRef *xref, const char *tagA, Ref idA, Dict *fontDict) { + GooString *nameA; + Ref embFontIDA; + GfxFontType typeA; + GfxFont *font; + Object obj1; + + // get base font name + nameA = NULL; + fontDict->lookup("BaseFont", &obj1); + if (obj1.isName()) { + nameA = new GooString(obj1.getName()); + } + obj1.free(); + + // get embedded font ID and font type + typeA = getFontType(xref, fontDict, &embFontIDA); + + // create the font object + font = NULL; + if (typeA < fontCIDType0) { + font = new Gfx8BitFont(xref, tagA, idA, nameA, typeA, embFontIDA, + fontDict); + } else { + font = new GfxCIDFont(xref, tagA, idA, nameA, typeA, embFontIDA, + fontDict); + } + + return font; +} + +GfxFont::GfxFont(const char *tagA, Ref idA, GooString *nameA, + GfxFontType typeA, Ref embFontIDA) { + ok = gFalse; + tag = new GooString(tagA); + id = idA; + name = nameA; + type = typeA; + embFontID = embFontIDA; + embFontName = NULL; + family = NULL; + stretch = StretchNotDefined; + weight = WeightNotDefined; + refCnt = 1; + encodingName = new GooString(""); + hasToUnicode = gFalse; +} + +GfxFont::~GfxFont() { + delete tag; + delete family; + if (name) { + delete name; + } + if (embFontName) { + delete embFontName; + } + if (encodingName) { + delete encodingName; + } +} + +void GfxFont::incRefCnt() { + refCnt++; +} + +void GfxFont::decRefCnt() { + if (--refCnt == 0) + delete this; +} + +// This function extracts three pieces of information: +// 1. the "expected" font type, i.e., the font type implied by +// Font.Subtype, DescendantFont.Subtype, and +// FontDescriptor.FontFile3.Subtype +// 2. the embedded font object ID +// 3. the actual font type - determined by examining the embedded font +// if there is one, otherwise equal to the expected font type +// If the expected and actual font types don't match, a warning +// message is printed. The expected font type is not used for +// anything else. +GfxFontType GfxFont::getFontType(XRef *xref, Dict *fontDict, Ref *embID) { + GfxFontType t, expectedType; + FoFiIdentifierType fft; + Dict *fontDict2; + Object subtype, fontDesc, obj1, obj2, obj3, obj4; + GBool isType0, err; + + t = fontUnknownType; + embID->num = embID->gen = -1; + err = gFalse; + + fontDict->lookup("Subtype", &subtype); + expectedType = fontUnknownType; + isType0 = gFalse; + if (subtype.isName("Type1") || subtype.isName("MMType1")) { + expectedType = fontType1; + } else if (subtype.isName("Type1C")) { + expectedType = fontType1C; + } else if (subtype.isName("Type3")) { + expectedType = fontType3; + } else if (subtype.isName("TrueType")) { + expectedType = fontTrueType; + } else if (subtype.isName("Type0")) { + isType0 = gTrue; + } else { + error(errSyntaxWarning, -1, "Unknown font type: '{0:s}'", + subtype.isName() ? subtype.getName() : "???"); + } + subtype.free(); + + fontDict2 = fontDict; + if (fontDict->lookup("DescendantFonts", &obj1)->isArray()) { + if (obj1.arrayGetLength() == 0) { + error(errSyntaxWarning, -1, "Empty DescendantFonts array in font"); + obj2.initNull(); + } else if (obj1.arrayGet(0, &obj2)->isDict()) { + if (!isType0) { + error(errSyntaxWarning, -1, "Non-CID font with DescendantFonts array"); + } + fontDict2 = obj2.getDict(); + fontDict2->lookup("Subtype", &subtype); + if (subtype.isName("CIDFontType0")) { + if (isType0) { + expectedType = fontCIDType0; + } + } else if (subtype.isName("CIDFontType2")) { + if (isType0) { + expectedType = fontCIDType2; + } + } + subtype.free(); + } + } else { + obj2.initNull(); + } + + if (fontDict2->lookup("FontDescriptor", &fontDesc)->isDict()) { + if (fontDesc.dictLookupNF("FontFile", &obj3)->isRef()) { + *embID = obj3.getRef(); + if (expectedType != fontType1) { + err = gTrue; + } + } + obj3.free(); + if (embID->num == -1 && + fontDesc.dictLookupNF("FontFile2", &obj3)->isRef()) { + *embID = obj3.getRef(); + if (isType0) { + expectedType = fontCIDType2; + } else if (expectedType != fontTrueType) { + err = gTrue; + } + } + obj3.free(); + if (embID->num == -1 && + fontDesc.dictLookupNF("FontFile3", &obj3)->isRef()) { + *embID = obj3.getRef(); + if (obj3.fetch(xref, &obj4)->isStream()) { + obj4.streamGetDict()->lookup("Subtype", &subtype); + if (subtype.isName("Type1")) { + if (expectedType != fontType1) { + err = gTrue; + expectedType = isType0 ? fontCIDType0 : fontType1; + } + } else if (subtype.isName("Type1C")) { + if (expectedType == fontType1) { + expectedType = fontType1C; + } else if (expectedType != fontType1C) { + err = gTrue; + expectedType = isType0 ? fontCIDType0C : fontType1C; + } + } else if (subtype.isName("TrueType")) { + if (expectedType != fontTrueType) { + err = gTrue; + expectedType = isType0 ? fontCIDType2 : fontTrueType; + } + } else if (subtype.isName("CIDFontType0C")) { + if (expectedType == fontCIDType0) { + expectedType = fontCIDType0C; + } else { + err = gTrue; + expectedType = isType0 ? fontCIDType0C : fontType1C; + } + } else if (subtype.isName("OpenType")) { + if (expectedType == fontTrueType) { + expectedType = fontTrueTypeOT; + } else if (expectedType == fontType1) { + expectedType = fontType1COT; + } else if (expectedType == fontCIDType0) { + expectedType = fontCIDType0COT; + } else if (expectedType == fontCIDType2) { + expectedType = fontCIDType2OT; + } else { + err = gTrue; + } + } else { + error(errSyntaxError, -1, "Unknown font type '{0:s}'", + subtype.isName() ? subtype.getName() : "???"); + } + subtype.free(); + } + obj4.free(); + } + obj3.free(); + } + fontDesc.free(); + + t = fontUnknownType; + if (embID->num >= 0) { + obj3.initRef(embID->num, embID->gen); + obj3.fetch(xref, &obj4); + if (obj4.isStream()) { + obj4.streamReset(); + fft = FoFiIdentifier::identifyStream(&readFromStream, obj4.getStream()); + obj4.streamClose(); + switch (fft) { + case fofiIdType1PFA: + case fofiIdType1PFB: + t = fontType1; + break; + case fofiIdCFF8Bit: + t = isType0 ? fontCIDType0C : fontType1C; + break; + case fofiIdCFFCID: + t = fontCIDType0C; + break; + case fofiIdTrueType: + case fofiIdTrueTypeCollection: + t = isType0 ? fontCIDType2 : fontTrueType; + break; + case fofiIdOpenTypeCFF8Bit: + t = expectedType; // hack: open type always == expected type? s. bug-poppler20605.pdf + break; + case fofiIdOpenTypeCFFCID: + t = fontCIDType0COT; + break; + default: + error(errSyntaxError, -1, "Embedded font file may be invalid"); + break; + } + } + obj4.free(); + obj3.free(); + } + + if (t == fontUnknownType) { + t = expectedType; + } + + if (t != expectedType) { + err = gTrue; + } + + if (err) { + error(errSyntaxWarning, -1, + "Mismatch between font type and embedded font file"); + } + + obj2.free(); + obj1.free(); + + return t; +} + +void GfxFont::readFontDescriptor(XRef *xref, Dict *fontDict) { + Object obj1, obj2, obj3, obj4; + double t; + int i; + + // assume Times-Roman by default (for substitution purposes) + flags = fontSerif; + + missingWidth = 0; + + if (fontDict->lookup("FontDescriptor", &obj1)->isDict()) { + + // get flags + if (obj1.dictLookup("Flags", &obj2)->isInt()) { + flags = obj2.getInt(); + } + obj2.free(); + + // get name + obj1.dictLookup("FontName", &obj2); + if (obj2.isName()) { + embFontName = new GooString(obj2.getName()); + } + obj2.free(); + if (embFontName == NULL) { + // get name with typo + obj1.dictLookup("Fontname", &obj2); + if (obj2.isName()) { + embFontName = new GooString(obj2.getName()); + error(errSyntaxWarning, -1, "The file uses Fontname instead of FontName please notify the creator that the file is broken"); + } + obj2.free(); + } + + // get family + obj1.dictLookup("FontFamily", &obj2); + if (obj2.isString()) family = new GooString(obj2.getString()); + obj2.free(); + + // get stretch + obj1.dictLookup("FontStretch", &obj2); + if (obj2.isName()) { + if (strcmp(obj2.getName(), "UltraCondensed") == 0) stretch = UltraCondensed; + else if (strcmp(obj2.getName(), "ExtraCondensed") == 0) stretch = ExtraCondensed; + else if (strcmp(obj2.getName(), "Condensed") == 0) stretch = Condensed; + else if (strcmp(obj2.getName(), "SemiCondensed") == 0) stretch = SemiCondensed; + else if (strcmp(obj2.getName(), "Normal") == 0) stretch = Normal; + else if (strcmp(obj2.getName(), "SemiExpanded") == 0) stretch = SemiExpanded; + else if (strcmp(obj2.getName(), "Expanded") == 0) stretch = Expanded; + else if (strcmp(obj2.getName(), "ExtraExpanded") == 0) stretch = ExtraExpanded; + else if (strcmp(obj2.getName(), "UltraExpanded") == 0) stretch = UltraExpanded; + else error(errSyntaxWarning, -1, "Invalid Font Stretch"); + } + obj2.free(); + + // get weight + obj1.dictLookup("FontWeight", &obj2); + if (obj2.isNum()) { + if (obj2.getNum() == 100) weight = W100; + else if (obj2.getNum() == 200) weight = W200; + else if (obj2.getNum() == 300) weight = W300; + else if (obj2.getNum() == 400) weight = W400; + else if (obj2.getNum() == 500) weight = W500; + else if (obj2.getNum() == 600) weight = W600; + else if (obj2.getNum() == 700) weight = W700; + else if (obj2.getNum() == 800) weight = W800; + else if (obj2.getNum() == 900) weight = W900; + else error(errSyntaxWarning, -1, "Invalid Font Weight"); + } + obj2.free(); + + // look for MissingWidth + obj1.dictLookup("MissingWidth", &obj2); + if (obj2.isNum()) { + missingWidth = obj2.getNum(); + } + obj2.free(); + + // get Ascent and Descent + obj1.dictLookup("Ascent", &obj2); + if (obj2.isNum()) { + t = 0.001 * obj2.getNum(); + // some broken font descriptors specify a negative ascent + if (t < 0) { + t = -t; + } + // some broken font descriptors set ascent and descent to 0; + // others set it to ridiculous values (e.g., 32768) + if (t != 0 && t < 3) { + ascent = t; + } + } + obj2.free(); + obj1.dictLookup("Descent", &obj2); + if (obj2.isNum()) { + t = 0.001 * obj2.getNum(); + // some broken font descriptors specify a positive descent + if (t > 0) { + t = -t; + } + // some broken font descriptors set ascent and descent to 0 + if (t != 0 && t > -3) { + descent = t; + } + } + obj2.free(); + + // font FontBBox + if (obj1.dictLookup("FontBBox", &obj2)->isArray()) { + for (i = 0; i < 4 && i < obj2.arrayGetLength(); ++i) { + if (obj2.arrayGet(i, &obj3)->isNum()) { + fontBBox[i] = 0.001 * obj3.getNum(); + } + obj3.free(); + } + } + obj2.free(); + + } + obj1.free(); +} + +CharCodeToUnicode *GfxFont::readToUnicodeCMap(Dict *fontDict, int nBits, + CharCodeToUnicode *ctu) { + GooString *buf; + Object obj1; + + if (!fontDict->lookup("ToUnicode", &obj1)->isStream()) { + obj1.free(); + return NULL; + } + buf = new GooString(); + obj1.getStream()->fillGooString(buf); + obj1.streamClose(); + obj1.free(); + if (ctu) { + ctu->mergeCMap(buf, nBits); + } else { + ctu = CharCodeToUnicode::parseCMap(buf, nBits); + } + hasToUnicode = gTrue; + delete buf; + return ctu; +} + +GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev *ps) { + GfxFontLoc *fontLoc; + SysFontType sysFontType; + GooString *path, *base14Name, *substName; + PSFontParam16 *psFont16; + Object refObj, embFontObj; + int substIdx, fontNum; + GBool embed; + + if (type == fontType3) { + return NULL; + } + + //----- embedded font + if (embFontID.num >= 0) { + embed = gTrue; + refObj.initRef(embFontID.num, embFontID.gen); + refObj.fetch(xref, &embFontObj); + if (!embFontObj.isStream()) { + error(errSyntaxError, -1, "Embedded font object is wrong type"); + embed = gFalse; + } + embFontObj.free(); + refObj.free(); + if (embed) { + if (ps) { + switch (type) { + case fontType1: + case fontType1C: + case fontType1COT: + embed = ps->getEmbedType1(); + break; + case fontTrueType: + case fontTrueTypeOT: + embed = ps->getEmbedTrueType(); + break; + case fontCIDType0C: + case fontCIDType0COT: + embed = ps->getEmbedCIDPostScript(); + break; + case fontCIDType2: + case fontCIDType2OT: + embed = ps->getEmbedCIDTrueType(); + break; + default: + break; + } + } + if (embed) { + fontLoc = new GfxFontLoc(); + fontLoc->locType = gfxFontLocEmbedded; + fontLoc->fontType = type; + fontLoc->embFontID = embFontID; + return fontLoc; + } + } + } + + //----- PS passthrough + if (ps && !isCIDFont() && ps->getFontPassthrough()) { + fontLoc = new GfxFontLoc(); + fontLoc->locType = gfxFontLocResident; + fontLoc->fontType = fontType1; + fontLoc->path = name->copy(); + return fontLoc; + } + + //----- PS resident Base-14 font + if (ps && !isCIDFont() && ((Gfx8BitFont *)this)->base14) { + fontLoc = new GfxFontLoc(); + fontLoc->locType = gfxFontLocResident; + fontLoc->fontType = fontType1; + fontLoc->path = new GooString(((Gfx8BitFont *)this)->base14->base14Name); + return fontLoc; + } + + //----- external font file (fontFile, fontDir) + if (name && (path = globalParams->findFontFile(name))) { + if ((fontLoc = getExternalFont(path, isCIDFont()))) { + return fontLoc; + } + } + + //----- external font file for Base-14 font + if (!ps && !isCIDFont() && ((Gfx8BitFont *)this)->base14) { + base14Name = new GooString(((Gfx8BitFont *)this)->base14->base14Name); + if ((path = globalParams->findBase14FontFile(base14Name, this))) { + if ((fontLoc = getExternalFont(path, gFalse))) { + delete base14Name; + return fontLoc; + } + } + delete base14Name; + } + + //----- system font + if ((path = globalParams->findSystemFontFile(this, &sysFontType, + &fontNum))) { + if (isCIDFont()) { + if (sysFontType == sysFontTTF || sysFontType == sysFontTTC) { + fontLoc = new GfxFontLoc(); + fontLoc->locType = gfxFontLocExternal; + fontLoc->fontType = fontCIDType2; + fontLoc->path = path; + fontLoc->fontNum = fontNum; + return fontLoc; + } + } else { + if (sysFontType == sysFontTTF || sysFontType == sysFontTTC) { + fontLoc = new GfxFontLoc(); + fontLoc->locType = gfxFontLocExternal; + fontLoc->fontType = fontTrueType; + fontLoc->path = path; + return fontLoc; + } else if (sysFontType == sysFontPFA || sysFontType == sysFontPFB) { + fontLoc = new GfxFontLoc(); + fontLoc->locType = gfxFontLocExternal; + fontLoc->fontType = fontType1; + fontLoc->path = path; + fontLoc->fontNum = fontNum; + return fontLoc; + } + } + delete path; + } + + if (!isCIDFont()) { + + //----- 8-bit PS resident font + if (name && ps) { + if ((path = globalParams->getPSResidentFont(name))) { + fontLoc = new GfxFontLoc(); + fontLoc->locType = gfxFontLocResident; + fontLoc->fontType = fontType1; + fontLoc->path = path; + return fontLoc; + } + } + + //----- 8-bit font substitution + if (flags & fontFixedWidth) { + substIdx = 0; + } else if (flags & fontSerif) { + substIdx = 8; + } else { + substIdx = 4; + } + if (isBold()) { + substIdx += 2; + } + if (isItalic()) { + substIdx += 1; + } + substName = new GooString(base14SubstFonts[substIdx]); + if (ps) { + error(errSyntaxWarning, -1, "Substituting font '{0:s}' for '{1:s}'", + base14SubstFonts[substIdx], name ? name->getCString() : "null"); + fontLoc = new GfxFontLoc(); + fontLoc->locType = gfxFontLocResident; + fontLoc->fontType = fontType1; + fontLoc->path = substName; + fontLoc->substIdx = substIdx; + return fontLoc; + } else { + path = globalParams->findFontFile(substName); + delete substName; + if (path) { + if ((fontLoc = getExternalFont(path, gFalse))) { + error(errSyntaxWarning, -1, "Substituting font '{0:s}' for '{1:s}'", + base14SubstFonts[substIdx], name ? name->getCString() : ""); + name = new GooString(base14SubstFonts[substIdx]); + fontLoc->substIdx = substIdx; + return fontLoc; + } + } + } + + // failed to find a substitute font + return NULL; + } + + //----- 16-bit PS resident font + if (ps && ((psFont16 = globalParams->getPSResidentFont16( + name, + ((GfxCIDFont *)this)->getWMode())))) { + fontLoc = new GfxFontLoc(); + fontLoc->locType = gfxFontLocResident; + fontLoc->fontType = fontCIDType0; // this is not used + fontLoc->path = psFont16->psFontName->copy(); + fontLoc->encoding = psFont16->encoding->copy(); + fontLoc->wMode = psFont16->wMode; + return fontLoc; + } + if (ps && ((psFont16 = globalParams->getPSResidentFontCC( + ((GfxCIDFont *)this)->getCollection(), + ((GfxCIDFont *)this)->getWMode())))) { + error(errSyntaxWarning, -1, "Substituting font '{0:t}' for '{1:t}'", + psFont16->psFontName, name); + fontLoc = new GfxFontLoc(); + fontLoc->locType = gfxFontLocResident; + fontLoc->fontType = fontCIDType0; // this is not used + fontLoc->path = psFont16->psFontName->copy(); + fontLoc->encoding = psFont16->encoding->copy(); + fontLoc->wMode = psFont16->wMode; + return fontLoc; + } + + //----- CID font substitution + if ((path = globalParams->findCCFontFile( + ((GfxCIDFont *)this)->getCollection()))) { + if ((fontLoc = getExternalFont(path, gTrue))) { + error(errSyntaxWarning, -1, "Substituting font '{0:t}' for '{1:t}'", + fontLoc->path, name); + return fontLoc; + } + } + + // failed to find a substitute font + return NULL; +} + +GfxFontLoc *GfxFont::locateBase14Font(GooString *base14Name) { + GooString *path; + + path = globalParams->findFontFile(base14Name); + if (!path) { + return NULL; + } + return getExternalFont(path, gFalse); +} + +GfxFontLoc *GfxFont::getExternalFont(GooString *path, GBool cid) { + FoFiIdentifierType fft; + GfxFontType fontType; + GfxFontLoc *fontLoc; + + fft = FoFiIdentifier::identifyFile(path->getCString()); + switch (fft) { + case fofiIdType1PFA: + case fofiIdType1PFB: + fontType = fontType1; + break; + case fofiIdCFF8Bit: + fontType = fontType1C; + break; + case fofiIdCFFCID: + fontType = fontCIDType0C; + break; + case fofiIdTrueType: + case fofiIdTrueTypeCollection: + fontType = cid ? fontCIDType2 : fontTrueType; + break; + case fofiIdOpenTypeCFF8Bit: + fontType = fontType1COT; + break; + case fofiIdOpenTypeCFFCID: + fontType = fontCIDType0COT; + break; + case fofiIdUnknown: + case fofiIdError: + default: + fontType = fontUnknownType; + break; + } + if (fontType == fontUnknownType || + (cid ? (fontType < fontCIDType0) + : (fontType >= fontCIDType0))) { + delete path; + return NULL; + } + fontLoc = new GfxFontLoc(); + fontLoc->locType = gfxFontLocExternal; + fontLoc->fontType = fontType; + fontLoc->path = path; + return fontLoc; +} + +char *GfxFont::readEmbFontFile(XRef *xref, int *len) { + char *buf; + Object obj1, obj2; + Stream *str; + + obj1.initRef(embFontID.num, embFontID.gen); + obj1.fetch(xref, &obj2); + if (!obj2.isStream()) { + error(errSyntaxError, -1, "Embedded font file is not a stream"); + obj2.free(); + obj1.free(); + embFontID.num = -1; + *len = 0; + return NULL; + } + str = obj2.getStream(); + + buf = (char*)str->toUnsignedChars(len); + str->close(); + + obj2.free(); + obj1.free(); + + return buf; +} + + +struct AlternateNameMap { + const char *name; + const char *alt; +}; + +static const AlternateNameMap alternateNameMap[] = +{ + { "fi", "f_i" }, + { "fl", "f_l" }, + { "ff", "f_f" }, + { "ffi", "f_f_i" }, + { "ffl", "f_f_l" }, + { 0, 0 } +}; + +const char *GfxFont::getAlternateName(const char *name) { + const AlternateNameMap *map = alternateNameMap; + while (map->name) { + if (strcmp(name, map->name) == 0) { + return map->alt; + } + map++; + } + return 0; +} + +//------------------------------------------------------------------------ +// Gfx8BitFont +//------------------------------------------------------------------------ + +// Parse character names of the form 'Axx', 'xx', 'Ann', 'ABnn', or +// 'nn', where 'A' and 'B' are any letters, 'xx' is two hex digits, +// and 'nn' is decimal digits. +static GBool parseNumericName(char *s, GBool hex, unsigned int *u) { + char *endptr; + + // Strip leading alpha characters. + if (hex) { + int n = 0; + + // Get string length while ignoring junk at end. + while (isalnum(s[n])) + ++n; + + // Only 2 hex characters with optional leading alpha is allowed. + if (n == 3 && isalpha(*s)) { + ++s; + } else if (n != 2) { + return gFalse; + } + } else { + // Strip up to two alpha characters. + for (int i = 0; i < 2 && isalpha(*s); ++i) + ++s; + } + + int v = strtol(s, &endptr, hex ? 16 : 10); + + if (endptr == s) + return gFalse; + + // Skip trailing junk characters. + while (*endptr != '\0' && !isalnum(*endptr)) + ++endptr; + + if (*endptr == '\0') { + if (u) + *u = v; + return gTrue; + } + return gFalse; +} + +// Returns gTrue if the font has character names like xx or Axx which +// should be parsed for hex or decimal values. +static GBool testForNumericNames(Dict *fontDict, GBool hex) { + Object enc, diff, obj; + GBool numeric = gTrue; + + fontDict->lookup("Encoding", &enc); + if (!enc.isDict()) { + enc.free(); + return gFalse; + } + + enc.dictLookup("Differences", &diff); + enc.free(); + if (!diff.isArray()) { + diff.free(); + return gFalse; + } + + for (int i = 0; i < diff.arrayGetLength() && numeric; ++i) { + diff.arrayGet(i, &obj); + if (obj.isInt()) { + // All sequences must start between character codes 0 and 5. + if (obj.getInt() > 5) + numeric = gFalse; + } else if (obj.isName()) { + // All character names must sucessfully parse. + if (!parseNumericName(obj.getName(), hex, NULL)) + numeric = gFalse; + } else { + numeric = gFalse; + } + obj.free(); + } + + diff.free(); + return numeric; +} + +Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, + GfxFontType typeA, Ref embFontIDA, Dict *fontDict): + GfxFont(tagA, idA, nameA, typeA, embFontIDA) { + GooString *name2; + BuiltinFont *builtinFont; + const char **baseEnc; + GBool baseEncFromFontFile; + char *buf; + int len; + FoFiType1 *ffT1; + FoFiType1C *ffT1C; + int code; + char *charName; + GBool missing, hex; + GBool numeric; + Unicode toUnicode[256]; + CharCodeToUnicode *utu, *ctu2; + Unicode uBuf[8]; + double mul; + int firstChar, lastChar; + Gushort w; + Object obj1, obj2, obj3; + int n, i, a, b, m; + + refCnt = 1; + ctu = NULL; + + // do font name substitution for various aliases of the Base 14 font + // names + base14 = NULL; + if (name) { + name2 = name->copy(); + i = 0; + while (i < name2->getLength()) { + if (name2->getChar(i) == ' ') { + name2->del(i); + } else { + ++i; + } + } + a = 0; + b = sizeof(base14FontMap) / sizeof(Base14FontMapEntry); + // invariant: base14FontMap[a].altName <= name2 < base14FontMap[b].altName + while (b - a > 1) { + m = (a + b) / 2; + if (name2->cmp(base14FontMap[m].altName) >= 0) { + a = m; + } else { + b = m; + } + } + if (!name2->cmp(base14FontMap[a].altName)) { + base14 = &base14FontMap[a]; + } + delete name2; + } + + // is it a built-in font? + builtinFont = NULL; + if (base14) { + for (i = 0; i < nBuiltinFonts; ++i) { + if (!strcmp(base14->base14Name, builtinFonts[i].name)) { + builtinFont = &builtinFonts[i]; + break; + } + } + } + + // default ascent/descent values + if (builtinFont) { + ascent = 0.001 * builtinFont->ascent; + descent = 0.001 * builtinFont->descent; + fontBBox[0] = 0.001 * builtinFont->bbox[0]; + fontBBox[1] = 0.001 * builtinFont->bbox[1]; + fontBBox[2] = 0.001 * builtinFont->bbox[2]; + fontBBox[3] = 0.001 * builtinFont->bbox[3]; + } else { + ascent = 0.95; + descent = -0.35; + fontBBox[0] = fontBBox[1] = fontBBox[2] = fontBBox[3] = 0; + } + + // get info from font descriptor + readFontDescriptor(xref, fontDict); + + // for non-embedded fonts, don't trust the ascent/descent/bbox + // values from the font descriptor + if (builtinFont && embFontID.num < 0) { + ascent = 0.001 * builtinFont->ascent; + descent = 0.001 * builtinFont->descent; + fontBBox[0] = 0.001 * builtinFont->bbox[0]; + fontBBox[1] = 0.001 * builtinFont->bbox[1]; + fontBBox[2] = 0.001 * builtinFont->bbox[2]; + fontBBox[3] = 0.001 * builtinFont->bbox[3]; + } + + // get font matrix + fontMat[0] = fontMat[3] = 1; + fontMat[1] = fontMat[2] = fontMat[4] = fontMat[5] = 0; + if (fontDict->lookup("FontMatrix", &obj1)->isArray()) { + for (i = 0; i < 6 && i < obj1.arrayGetLength(); ++i) { + if (obj1.arrayGet(i, &obj2)->isNum()) { + fontMat[i] = obj2.getNum(); + } + obj2.free(); + } + } + obj1.free(); + + // get Type 3 bounding box, font definition, and resources + if (type == fontType3) { + if (fontDict->lookup("FontBBox", &obj1)->isArray()) { + for (i = 0; i < 4 && i < obj1.arrayGetLength(); ++i) { + if (obj1.arrayGet(i, &obj2)->isNum()) { + fontBBox[i] = obj2.getNum(); + } + obj2.free(); + } + } + obj1.free(); + if (!fontDict->lookup("CharProcs", &charProcs)->isDict()) { + error(errSyntaxError, -1, + "Missing or invalid CharProcs dictionary in Type 3 font"); + charProcs.free(); + } + if (!fontDict->lookup("Resources", &resources)->isDict()) { + resources.free(); + } + } + + //----- build the font encoding ----- + + // Encodings start with a base encoding, which can come from + // (in order of priority): + // 1. FontDict.Encoding or FontDict.Encoding.BaseEncoding + // - MacRoman / MacExpert / WinAnsi / Standard + // 2. embedded or external font file + // 3. default: + // - builtin --> builtin encoding + // - TrueType --> WinAnsiEncoding + // - others --> StandardEncoding + // and then add a list of differences (if any) from + // FontDict.Encoding.Differences. + + // check FontDict for base encoding + hasEncoding = gFalse; + usesMacRomanEnc = gFalse; + baseEnc = NULL; + baseEncFromFontFile = gFalse; + fontDict->lookup("Encoding", &obj1); + if (obj1.isDict()) { + obj1.dictLookup("BaseEncoding", &obj2); + if (obj2.isName("MacRomanEncoding")) { + hasEncoding = gTrue; + usesMacRomanEnc = gTrue; + baseEnc = macRomanEncoding; + } else if (obj2.isName("MacExpertEncoding")) { + hasEncoding = gTrue; + baseEnc = macExpertEncoding; + } else if (obj2.isName("WinAnsiEncoding")) { + hasEncoding = gTrue; + baseEnc = winAnsiEncoding; + } + obj2.free(); + } else if (obj1.isName("MacRomanEncoding")) { + hasEncoding = gTrue; + usesMacRomanEnc = gTrue; + baseEnc = macRomanEncoding; + } else if (obj1.isName("MacExpertEncoding")) { + hasEncoding = gTrue; + baseEnc = macExpertEncoding; + } else if (obj1.isName("WinAnsiEncoding")) { + hasEncoding = gTrue; + baseEnc = winAnsiEncoding; + } + + // check embedded font file for base encoding + // (only for Type 1 fonts - trying to get an encoding out of a + // TrueType font is a losing proposition) + ffT1 = NULL; + ffT1C = NULL; + buf = NULL; + if (type == fontType1 && embFontID.num >= 0) { + if ((buf = readEmbFontFile(xref, &len))) { + if ((ffT1 = FoFiType1::make(buf, len))) { + if (ffT1->getName()) { + if (embFontName) { + delete embFontName; + } + embFontName = new GooString(ffT1->getName()); + } + if (!baseEnc) { + baseEnc = (const char **)ffT1->getEncoding(); + baseEncFromFontFile = gTrue; + } + } + gfree(buf); + } + } else if (type == fontType1C && embFontID.num >= 0) { + if ((buf = readEmbFontFile(xref, &len))) { + if ((ffT1C = FoFiType1C::make(buf, len))) { + if (ffT1C->getName()) { + if (embFontName) { + delete embFontName; + } + embFontName = new GooString(ffT1C->getName()); + } + if (!baseEnc) { + baseEnc = (const char **)ffT1C->getEncoding(); + baseEncFromFontFile = gTrue; + } + } + gfree(buf); + } + } + + // get default base encoding + if (!baseEnc) { + if (builtinFont && embFontID.num < 0) { + baseEnc = builtinFont->defaultBaseEnc; + hasEncoding = gTrue; + } else if (type == fontTrueType) { + baseEnc = winAnsiEncoding; + } else { + baseEnc = standardEncoding; + } + } + + if (baseEncFromFontFile) { + encodingName->Set("Builtin"); + } else if (baseEnc == winAnsiEncoding) { + encodingName->Set("WinAnsi"); + } else if (baseEnc == macRomanEncoding) { + encodingName->Set("MacRoman"); + } else if (baseEnc == macExpertEncoding) { + encodingName->Set("MacExpert"); + } else if (baseEnc == symbolEncoding) { + encodingName->Set("Symbol"); + } else if (baseEnc == zapfDingbatsEncoding) { + encodingName->Set("ZapfDingbats"); + } else { + encodingName->Set("Standard"); + } + + // copy the base encoding + for (i = 0; i < 256; ++i) { + enc[i] = (char *)baseEnc[i]; + if ((encFree[i] = baseEncFromFontFile) && enc[i]) { + enc[i] = copyString(baseEnc[i]); + } + } + + // some Type 1C font files have empty encodings, which can break the + // T1C->T1 conversion (since the 'seac' operator depends on having + // the accents in the encoding), so we fill in any gaps from + // StandardEncoding + if (type == fontType1C && embFontID.num >= 0 && baseEncFromFontFile) { + for (i = 0; i < 256; ++i) { + if (!enc[i] && standardEncoding[i]) { + enc[i] = (char *)standardEncoding[i]; + encFree[i] = gFalse; + } + } + } + + // merge differences into encoding + if (obj1.isDict()) { + obj1.dictLookup("Differences", &obj2); + if (obj2.isArray()) { + encodingName->Set("Custom"); + hasEncoding = gTrue; + code = 0; + for (i = 0; i < obj2.arrayGetLength(); ++i) { + obj2.arrayGet(i, &obj3); + if (obj3.isInt()) { + code = obj3.getInt(); + } else if (obj3.isName()) { + if (code >= 0 && code < 256) { + if (encFree[code]) { + gfree(enc[code]); + } + enc[code] = copyString(obj3.getName()); + encFree[code] = gTrue; + } + ++code; + } else { + error(errSyntaxError, -1, + "Wrong type in font encoding resource differences ({0:s})", + obj3.getTypeName()); + } + obj3.free(); + } + } + obj2.free(); + } + obj1.free(); + if (ffT1) { + delete ffT1; + } + if (ffT1C) { + delete ffT1C; + } + + //----- build the mapping to Unicode ----- + + // pass 1: use the name-to-Unicode mapping table + missing = hex = gFalse; + GBool isZapfDingbats = name && name->endsWith("ZapfDingbats"); + for (code = 0; code < 256; ++code) { + if ((charName = enc[code])) { + if (isZapfDingbats) { + // include ZapfDingbats names + toUnicode[code] = globalParams->mapNameToUnicodeAll(charName); + } else { + toUnicode[code] = globalParams->mapNameToUnicodeText(charName); + } + if (!toUnicode[code] && strcmp(charName, ".notdef")) { + // if it wasn't in the name-to-Unicode table, check for a + // name that looks like 'Axx' or 'xx', where 'A' is any letter + // and 'xx' is two hex digits + if ((strlen(charName) == 3 && + isalpha(charName[0]) && + isxdigit(charName[1]) && isxdigit(charName[2]) && + ((charName[1] >= 'a' && charName[1] <= 'f') || + (charName[1] >= 'A' && charName[1] <= 'F') || + (charName[2] >= 'a' && charName[2] <= 'f') || + (charName[2] >= 'A' && charName[2] <= 'F'))) || + (strlen(charName) == 2 && + isxdigit(charName[0]) && isxdigit(charName[1]) && + // Only check idx 1 to avoid misidentifying a decimal + // number like a0 + ((charName[1] >= 'a' && charName[1] <= 'f') || + (charName[1] >= 'A' && charName[1] <= 'F')))) { + hex = gTrue; + } + missing = gTrue; + } + } else { + toUnicode[code] = 0; + } + } + + numeric = testForNumericNames(fontDict, hex); + + // construct the char code -> Unicode mapping object + ctu = CharCodeToUnicode::make8BitToUnicode(toUnicode); + + // pass 1a: Expand ligatures in the Alphabetic Presentation Form + // block (eg "fi", "ffi") to normal form + for (code = 0; code < 256; ++code) { + if (unicodeIsAlphabeticPresentationForm(toUnicode[code])) { + Unicode *normalized = unicodeNormalizeNFKC(&toUnicode[code], 1, &len, NULL); + if (len > 1) + ctu->setMapping((CharCode)code, normalized, len); + gfree(normalized); + } + } + + // pass 2: try to fill in the missing chars, looking for ligatures, numeric + // references and variants + if (missing) { + for (code = 0; code < 256; ++code) { + if (!toUnicode[code]) { + if ((charName = enc[code]) && strcmp(charName, ".notdef") + && (n = parseCharName(charName, uBuf, sizeof(uBuf)/sizeof(*uBuf), + gFalse, // don't check simple names (pass 1) + gTrue, // do check ligatures + numeric, + hex, + gTrue))) { // do check variants + ctu->setMapping((CharCode)code, uBuf, n); + continue; + } + + // if the 'mapUnknownCharNames' flag is set, do a simple pass-through + // mapping for unknown character names + if (globalParams->getMapUnknownCharNames()) { + uBuf[0] = code; + ctu->setMapping((CharCode)code, uBuf, 1); + } + } + } + } + + // merge in a ToUnicode CMap, if there is one -- this overwrites + // existing entries in ctu, i.e., the ToUnicode CMap takes + // precedence, but the other encoding info is allowed to fill in any + // holes + readToUnicodeCMap(fontDict, 16, ctu); + + // look for a Unicode-to-Unicode mapping + if (name && (utu = globalParams->getUnicodeToUnicode(name))) { + Unicode *uAux; + for (i = 0; i < 256; ++i) { + toUnicode[i] = 0; + } + ctu2 = CharCodeToUnicode::make8BitToUnicode(toUnicode); + for (i = 0; i < 256; ++i) { + n = ctu->mapToUnicode((CharCode)i, &uAux); + if (n >= 1) { + n = utu->mapToUnicode((CharCode)uAux[0], &uAux); + if (n >= 1) { + ctu2->setMapping((CharCode)i, uAux, n); + } + } + } + utu->decRefCnt(); + delete ctu; + ctu = ctu2; + } + + //----- get the character widths ----- + + // initialize all widths + for (code = 0; code < 256; ++code) { + widths[code] = missingWidth * 0.001; + } + + // use widths from font dict, if present + fontDict->lookup("FirstChar", &obj1); + firstChar = obj1.isInt() ? obj1.getInt() : 0; + obj1.free(); + if (firstChar < 0 || firstChar > 255) { + firstChar = 0; + } + fontDict->lookup("LastChar", &obj1); + lastChar = obj1.isInt() ? obj1.getInt() : 255; + obj1.free(); + if (lastChar < 0 || lastChar > 255) { + lastChar = 255; + } + mul = (type == fontType3) ? fontMat[0] : 0.001; + fontDict->lookup("Widths", &obj1); + if (obj1.isArray()) { + flags |= fontFixedWidth; + if (obj1.arrayGetLength() < lastChar - firstChar + 1) { + lastChar = firstChar + obj1.arrayGetLength() - 1; + } + for (code = firstChar; code <= lastChar; ++code) { + obj1.arrayGet(code - firstChar, &obj2); + if (obj2.isNum()) { + widths[code] = obj2.getNum() * mul; + if (fabs(widths[code] - widths[firstChar]) > 0.00001) { + flags &= ~fontFixedWidth; + } + } + obj2.free(); + } + + // use widths from built-in font + } else if (builtinFont) { + // this is a kludge for broken PDF files that encode char 32 + // as .notdef + if (builtinFont->widths->getWidth("space", &w)) { + widths[32] = 0.001 * w; + } + for (code = 0; code < 256; ++code) { + if (enc[code] && builtinFont->widths->getWidth(enc[code], &w)) { + widths[code] = 0.001 * w; + } + } + + // couldn't find widths -- use defaults + } else { + // this is technically an error -- the Widths entry is required + // for all but the Base-14 fonts -- but certain PDF generators + // apparently don't include widths for Arial and TimesNewRoman + if (isFixedWidth()) { + i = 0; + } else if (isSerif()) { + i = 8; + } else { + i = 4; + } + if (isBold()) { + i += 2; + } + if (isItalic()) { + i += 1; + } + builtinFont = builtinFontSubst[i]; + // this is a kludge for broken PDF files that encode char 32 + // as .notdef + if (builtinFont->widths->getWidth("space", &w)) { + widths[32] = 0.001 * w; + } + for (code = 0; code < 256; ++code) { + if (enc[code] && builtinFont->widths->getWidth(enc[code], &w)) { + widths[code] = 0.001 * w; + } + } + } + obj1.free(); + + ok = gTrue; +} + +Gfx8BitFont::~Gfx8BitFont() { + int i; + + for (i = 0; i < 256; ++i) { + if (encFree[i] && enc[i]) { + gfree(enc[i]); + } + } + ctu->decRefCnt(); + if (charProcs.isDict()) { + charProcs.free(); + } + if (resources.isDict()) { + resources.free(); + } +} + +// This function is in part a derived work of the Adobe Glyph Mapping +// Convention: http://www.adobe.com/devnet/opentype/archives/glyph.html +// Algorithmic comments are excerpted from that document to aid +// maintainability. +static int parseCharName(char *charName, Unicode *uBuf, int uLen, + GBool names, GBool ligatures, + GBool numeric, GBool hex, GBool variants) +{ + if (uLen <= 0) { + error(errInternal, -1, "Zero-length output buffer (recursion overflow?) in " + "parseCharName, component \"{0:s}\"", charName); + return 0; + } + // Step 1: drop all the characters from the glyph name starting with the + // first occurrence of a period (U+002E FULL STOP), if any. + if (variants) { + char *var_part = strchr(charName, '.'); + if (var_part == charName) { + return 0; // .notdef or similar + } else if (var_part != NULL) { + // parse names of the form 7.oldstyle, P.swash, s.sc, etc. + char *main_part = gstrndup(charName, var_part - charName); + GBool namesRecurse = gTrue, variantsRecurse = gFalse; + int n = parseCharName(main_part, uBuf, uLen, namesRecurse, ligatures, + numeric, hex, variantsRecurse); + gfree(main_part); + return n; + } + } + // Step 2: split the remaining string into a sequence of components, using + // underscore (U+005F LOW LINE) as the delimiter. + if (ligatures && strchr(charName, '_')) { + // parse names of the form A_a (e.g. f_i, T_h, l_quotesingle) + char *lig_part, *lig_end, *lig_copy; + int n = 0, m; + lig_part = lig_copy = copyString(charName); + do { + if ((lig_end = strchr(lig_part, '_'))) + *lig_end = '\0'; + if (lig_part[0] != '\0') { + GBool namesRecurse = gTrue, ligaturesRecurse = gFalse; + if ((m = parseCharName(lig_part, uBuf + n, uLen - n, namesRecurse, + ligaturesRecurse, numeric, hex, variants))) + n += m; + else + error(errSyntaxWarning, -1, "Could not parse ligature component \"{0:s}\" of \"{1:s}\" in " + "parseCharName", lig_part, charName); + } + lig_part = lig_end + 1; + } while (lig_end && n < uLen); + gfree(lig_copy); + return n; + } + // Step 3: map each component to a character string according to the + // procedure below, and concatenate those strings; the result is the + // character string to which the glyph name is mapped. + // 3.1. if the font is Zapf Dingbats (PostScript FontName ZapfDingbats), and + // the component is in the ZapfDingbats list, then map it to the + // corresponding character in that list. + // 3.2. otherwise, if the component is in the Adobe Glyph List, then map it + // to the corresponding character in that list. + if (names && (uBuf[0] = globalParams->mapNameToUnicodeText(charName))) { + return 1; + } + if (globalParams->getMapNumericCharNames()) { + unsigned int n = strlen(charName); + // 3.3. otherwise, if the component is of the form "uni" (U+0075 U+006E + // U+0069) followed by a sequence of uppercase hexadecimal digits (0 .. 9, + // A .. F, i.e. U+0030 .. U+0039, U+0041 .. U+0046), the length of that + // sequence is a multiple of four, and each group of four digits represents + // a number in the set {0x0000 .. 0xD7FF, 0xE000 .. 0xFFFF}, then interpret + // each such number as a Unicode scalar value and map the component to the + // string made of those scalar values. Note that the range and digit length + // restrictions mean that the "uni" prefix can be used only with Unicode + // values from the Basic Multilingual Plane (BMP). + if (n >= 7 && (n % 4) == 3 && !strncmp(charName, "uni", 3)) { + int i; + unsigned int m; + for (i = 0, m = 3; i < uLen && m < n; m += 4) { + if (isxdigit(charName[m]) && isxdigit(charName[m + 1]) && + isxdigit(charName[m + 2]) && isxdigit(charName[m + 3])) { + unsigned int u; + sscanf(charName + m, "%4x", &u); + if (u <= 0xD7FF || (0xE000 <= u && u <= 0xFFFF)) { + uBuf[i++] = u; + } + } + } + return i; + } + // 3.4. otherwise, if the component is of the form "u" (U+0075) followed by + // a sequence of four to six uppercase hexadecimal digits {0 .. 9, A .. F} + // (U+0030 .. U+0039, U+0041 .. U+0046), and those digits represent a + // number in {0x0000 .. 0xD7FF, 0xE000 .. 0x10FFFF}, then interpret this + // number as a Unicode scalar value and map the component to the string + // made of this scalar value. + if (n >= 5 && n <= 7 && charName[0] == 'u' && isxdigit(charName[1]) && + isxdigit(charName[2]) && isxdigit(charName[3]) && isxdigit(charName[4]) + && (n <= 5 || isxdigit(charName[5])) + && (n <= 6 || isxdigit(charName[6]))) { + unsigned int u; + sscanf(charName + 1, "%x", &u); + if (u <= 0xD7FF || (0xE000 <= u && u <= 0x10FFFF)) { + uBuf[0] = u; + return 1; + } + } + // Not in Adobe Glyph Mapping convention: look for names like xx + // or Axx and parse for hex or decimal values. + if (numeric && parseNumericName(charName, hex, uBuf)) + return 1; + } + // 3.5. otherwise, map the component to the empty string + return 0; +} + +int Gfx8BitFont::getNextChar(char *s, int len, CharCode *code, + Unicode **u, int *uLen, + double *dx, double *dy, double *ox, double *oy) { + CharCode c; + + *code = c = (CharCode)(*s & 0xff); + *uLen = ctu->mapToUnicode(c, u); + *dx = widths[c]; + *dy = *ox = *oy = 0; + return 1; +} + +CharCodeToUnicode *Gfx8BitFont::getToUnicode() { + ctu->incRefCnt(); + return ctu; +} + +int *Gfx8BitFont::getCodeToGIDMap(FoFiTrueType *ff) { + int *map; + int cmapPlatform, cmapEncoding; + int unicodeCmap, macRomanCmap, msSymbolCmap, cmap; + GBool useMacRoman, useUnicode; + char *charName; + Unicode u; + int code, i, n; + + map = (int *)gmallocn(256, sizeof(int)); + for (i = 0; i < 256; ++i) { + map[i] = 0; + } + + // To match up with the Adobe-defined behaviour, we choose a cmap + // like this: + // 1. If the PDF font has an encoding: + // 1a. If the PDF font specified MacRomanEncoding and the + // TrueType font has a Macintosh Roman cmap, use it, and + // reverse map the char names through MacRomanEncoding to + // get char codes. + // 1b. If the PDF font is not symbolic or the PDF font is not + // embedded, and the TrueType font has a Microsoft Unicode + // cmap or a non-Microsoft Unicode cmap, use it, and use the + // Unicode indexes, not the char codes. + // 1c. If the PDF font is symbolic and the TrueType font has a + // Microsoft Symbol cmap, use it, and use char codes + // directly (possibly with an offset of 0xf000). + // 1d. If the TrueType font has a Macintosh Roman cmap, use it, + // as in case 1a. + // 2. If the PDF font does not have an encoding or the PDF font is + // symbolic: + // 2a. If the TrueType font has a Macintosh Roman cmap, use it, + // and use char codes directly (possibly with an offset of + // 0xf000). + // 2b. If the TrueType font has a Microsoft Symbol cmap, use it, + // and use char codes directly (possible with an offset of + // 0xf000). + // 3. If none of these rules apply, use the first cmap and hope for + // the best (this shouldn't happen). + unicodeCmap = macRomanCmap = msSymbolCmap = -1; + for (i = 0; i < ff->getNumCmaps(); ++i) { + cmapPlatform = ff->getCmapPlatform(i); + cmapEncoding = ff->getCmapEncoding(i); + if ((cmapPlatform == 3 && cmapEncoding == 1) || + cmapPlatform == 0) { + unicodeCmap = i; + } else if (cmapPlatform == 1 && cmapEncoding == 0) { + macRomanCmap = i; + } else if (cmapPlatform == 3 && cmapEncoding == 0) { + msSymbolCmap = i; + } + } + cmap = 0; + useMacRoman = gFalse; + useUnicode = gFalse; + if (hasEncoding || type == fontType1) { + if (usesMacRomanEnc && macRomanCmap >= 0) { + cmap = macRomanCmap; + useMacRoman = gTrue; + } else if ((!(flags & fontSymbolic) || embFontID.num < 0) && + unicodeCmap >= 0) { + cmap = unicodeCmap; + useUnicode = gTrue; + } else if ((flags & fontSymbolic) && msSymbolCmap >= 0) { + cmap = msSymbolCmap; + } else if ((flags & fontSymbolic) && macRomanCmap >= 0) { + cmap = macRomanCmap; + } else if (macRomanCmap >= 0) { + cmap = macRomanCmap; + useMacRoman = gTrue; + } + } else { + if (msSymbolCmap >= 0) { + cmap = msSymbolCmap; + } else if (macRomanCmap >= 0) { + cmap = macRomanCmap; + } + } + + // reverse map the char names through MacRomanEncoding, then map the + // char codes through the cmap + if (useMacRoman) { + for (i = 0; i < 256; ++i) { + if ((charName = enc[i])) { + if ((code = globalParams->getMacRomanCharCode(charName))) { + map[i] = ff->mapCodeToGID(cmap, code); + } + } else { + map[i] = -1; + } + } + + // map Unicode through the cmap + } else if (useUnicode) { + Unicode *uAux; + for (i = 0; i < 256; ++i) { + if (((charName = enc[i]) && (u = globalParams->mapNameToUnicodeAll(charName)))) + map[i] = ff->mapCodeToGID(cmap, u); + else + { + n = ctu->mapToUnicode((CharCode)i, &uAux); + if (n > 0) map[i] = ff->mapCodeToGID(cmap, uAux[0]); + else map[i] = -1; + } + } + + // map the char codes through the cmap, possibly with an offset of + // 0xf000 + } else { + for (i = 0; i < 256; ++i) { + if (!(map[i] = ff->mapCodeToGID(cmap, i))) { + map[i] = ff->mapCodeToGID(cmap, 0xf000 + i); + } + } + } + + // try the TrueType 'post' table to handle any unmapped characters + for (i = 0; i < 256; ++i) { + if (map[i] <= 0 && (charName = enc[i])) { + map[i] = ff->mapNameToGID(charName); + } + } + + return map; +} + +Dict *Gfx8BitFont::getCharProcs() { + return charProcs.isDict() ? charProcs.getDict() : (Dict *)NULL; +} + +Object *Gfx8BitFont::getCharProc(int code, Object *proc) { + if (enc[code] && charProcs.isDict()) { + charProcs.dictLookup(enc[code], proc); + } else { + proc->initNull(); + } + return proc; +} + +Dict *Gfx8BitFont::getResources() { + return resources.isDict() ? resources.getDict() : (Dict *)NULL; +} + +//------------------------------------------------------------------------ +// GfxCIDFont +//------------------------------------------------------------------------ + +struct cmpWidthExcepFunctor { + bool operator()(const GfxFontCIDWidthExcep &w1, + const GfxFontCIDWidthExcep &w2) { + return w1.first < w2.first; + } +}; + +struct cmpWidthExcepVFunctor { + bool operator()(const GfxFontCIDWidthExcepV &w1, + const GfxFontCIDWidthExcepV &w2) { + return w1.first < w2.first; + } +}; + +GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, + GfxFontType typeA, Ref embFontIDA, Dict *fontDict): + GfxFont(tagA, idA, nameA, typeA, embFontIDA) +{ + Dict *desFontDict; + Object desFontDictObj; + Object obj1, obj2, obj3, obj4, obj5, obj6; + CharCodeToUnicode *utu; + CharCode c; + Unicode *uBuf; + int c1, c2; + int excepsSize, i, j, k, n; + + refCnt = 1; + ascent = 0.95; + descent = -0.35; + fontBBox[0] = fontBBox[1] = fontBBox[2] = fontBBox[3] = 0; + collection = NULL; + cMap = NULL; + ctu = NULL; + ctuUsesCharCode = gTrue; + widths.defWidth = 1.0; + widths.defHeight = -1.0; + widths.defVY = 0.880; + widths.exceps = NULL; + widths.nExceps = 0; + widths.excepsV = NULL; + widths.nExcepsV = 0; + cidToGID = NULL; + cidToGIDLen = 0; + + // get the descendant font + if (!fontDict->lookup("DescendantFonts", &obj1)->isArray() || + obj1.arrayGetLength() == 0) { + error(errSyntaxError, -1, "Missing or empty DescendantFonts entry in Type 0 font"); + obj1.free(); + goto err1; + } + if (!obj1.arrayGet(0, &desFontDictObj)->isDict()) { + error(errSyntaxError, -1, "Bad descendant font in Type 0 font"); + goto err3; + } + obj1.free(); + desFontDict = desFontDictObj.getDict(); + + // get info from font descriptor + readFontDescriptor(xref, desFontDict); + + //----- encoding info ----- + + // char collection + if (!desFontDict->lookup("CIDSystemInfo", &obj1)->isDict()) { + error(errSyntaxError, -1, "Missing CIDSystemInfo dictionary in Type 0 descendant font"); + goto err3; + } + obj1.dictLookup("Registry", &obj2); + obj1.dictLookup("Ordering", &obj3); + if (!obj2.isString() || !obj3.isString()) { + error(errSyntaxError, -1, "Invalid CIDSystemInfo dictionary in Type 0 descendant font"); + goto err3; + } + collection = obj2.getString()->copy()->append('-')->append(obj3.getString()); + obj3.free(); + obj2.free(); + obj1.free(); + + // look for a ToUnicode CMap + if (!(ctu = readToUnicodeCMap(fontDict, 16, NULL))) { + ctuUsesCharCode = gFalse; + + // use an identity mapping for the "Adobe-Identity" and + // "Adobe-UCS" collections + if (!collection->cmp("Adobe-Identity") || + !collection->cmp("Adobe-UCS")) { + ctu = CharCodeToUnicode::makeIdentityMapping(); + } else { + // look for a user-supplied .cidToUnicode file + if (!(ctu = globalParams->getCIDToUnicode(collection))) { + // I'm not completely sure that this is the best thing to do + // but it seems to produce better results when the .cidToUnicode + // files from the poppler-data package are missing. At least + // we know that assuming the Identity mapping is definitely wrong. + // -- jrmuizel + static const char * knownCollections [] = { + "Adobe-CNS1", + "Adobe-GB1", + "Adobe-Japan1", + "Adobe-Japan2", + "Adobe-Korea1", + }; + for (size_t i = 0; i < sizeof(knownCollections)/sizeof(knownCollections[0]); i++) { + if (collection->cmp(knownCollections[i]) == 0) { + error(errSyntaxError, -1, "Missing language pack for '{0:t}' mapping", collection); + goto err2; + } + } + error(errSyntaxError, -1, "Unknown character collection '{0:t}'", + collection); + // fall-through, assuming the Identity mapping -- this appears + // to match Adobe's behavior + } + } + } + + // look for a Unicode-to-Unicode mapping + if (name && (utu = globalParams->getUnicodeToUnicode(name))) { + if (ctu) { + for (c = 0; c < ctu->getLength(); ++c) { + n = ctu->mapToUnicode(c, &uBuf); + if (n >= 1) { + n = utu->mapToUnicode((CharCode)uBuf[0], &uBuf); + if (n >= 1) { + ctu->setMapping(c, uBuf, n); + } + } + } + utu->decRefCnt(); + } else { + ctu = utu; + } + } + + // encoding (i.e., CMap) + if (fontDict->lookup("Encoding", &obj1)->isNull()) { + error(errSyntaxError, -1, "Missing Encoding entry in Type 0 font"); + goto err2; + } + if (!(cMap = CMap::parse(NULL, collection, &obj1))) { + goto err2; + } + obj1.free(); + if (cMap->getCMapName()) { + encodingName->Set(cMap->getCMapName()->getCString()); + } else { + encodingName->Set("Custom"); + } + + // CIDToGIDMap (for embedded TrueType fonts) + if (type == fontCIDType2 || type == fontCIDType2OT) { + desFontDict->lookup("CIDToGIDMap", &obj1); + if (obj1.isStream()) { + cidToGIDLen = 0; + i = 64; + cidToGID = (int *)gmallocn(i, sizeof(int)); + obj1.streamReset(); + while ((c1 = obj1.streamGetChar()) != EOF && + (c2 = obj1.streamGetChar()) != EOF) { + if (cidToGIDLen == i) { + i *= 2; + cidToGID = (int *)greallocn(cidToGID, i, sizeof(int)); + } + cidToGID[cidToGIDLen++] = (c1 << 8) + c2; + } + } else if (!obj1.isName("Identity") && !obj1.isNull()) { + error(errSyntaxError, -1, "Invalid CIDToGIDMap entry in CID font"); + } + obj1.free(); + } + + //----- character metrics ----- + + // default char width + if (desFontDict->lookup("DW", &obj1)->isInt()) { + widths.defWidth = obj1.getInt() * 0.001; + } + obj1.free(); + + // char width exceptions + if (desFontDict->lookup("W", &obj1)->isArray()) { + excepsSize = 0; + i = 0; + while (i + 1 < obj1.arrayGetLength()) { + obj1.arrayGet(i, &obj2); + obj1.arrayGet(i + 1, &obj3); + if (obj2.isInt() && obj3.isInt() && i + 2 < obj1.arrayGetLength()) { + if (obj1.arrayGet(i + 2, &obj4)->isNum()) { + if (widths.nExceps == excepsSize) { + excepsSize += 16; + widths.exceps = (GfxFontCIDWidthExcep *) + greallocn(widths.exceps, + excepsSize, sizeof(GfxFontCIDWidthExcep)); + } + widths.exceps[widths.nExceps].first = obj2.getInt(); + widths.exceps[widths.nExceps].last = obj3.getInt(); + widths.exceps[widths.nExceps].width = obj4.getNum() * 0.001; + ++widths.nExceps; + } else { + error(errSyntaxError, -1, "Bad widths array in Type 0 font"); + } + obj4.free(); + i += 3; + } else if (obj2.isInt() && obj3.isArray()) { + if (widths.nExceps + obj3.arrayGetLength() > excepsSize) { + excepsSize = (widths.nExceps + obj3.arrayGetLength() + 15) & ~15; + widths.exceps = (GfxFontCIDWidthExcep *) + greallocn(widths.exceps, + excepsSize, sizeof(GfxFontCIDWidthExcep)); + } + j = obj2.getInt(); + for (k = 0; k < obj3.arrayGetLength(); ++k) { + if (obj3.arrayGet(k, &obj4)->isNum()) { + widths.exceps[widths.nExceps].first = j; + widths.exceps[widths.nExceps].last = j; + widths.exceps[widths.nExceps].width = obj4.getNum() * 0.001; + ++j; + ++widths.nExceps; + } else { + error(errSyntaxError, -1, "Bad widths array in Type 0 font"); + } + obj4.free(); + } + i += 2; + } else { + error(errSyntaxError, -1, "Bad widths array in Type 0 font"); + ++i; + } + obj3.free(); + obj2.free(); + } + std::sort(widths.exceps, widths.exceps + widths.nExceps, + cmpWidthExcepFunctor()); + } + obj1.free(); + + // default metrics for vertical font + if (desFontDict->lookup("DW2", &obj1)->isArray() && + obj1.arrayGetLength() == 2) { + if (obj1.arrayGet(0, &obj2)->isNum()) { + widths.defVY = obj2.getNum() * 0.001; + } + obj2.free(); + if (obj1.arrayGet(1, &obj2)->isNum()) { + widths.defHeight = obj2.getNum() * 0.001; + } + obj2.free(); + } + obj1.free(); + + // char metric exceptions for vertical font + if (desFontDict->lookup("W2", &obj1)->isArray()) { + excepsSize = 0; + i = 0; + while (i + 1 < obj1.arrayGetLength()) { + obj1.arrayGet(i, &obj2); + obj1.arrayGet(i+ 1, &obj3); + if (obj2.isInt() && obj3.isInt() && i + 4 < obj1.arrayGetLength()) { + if (obj1.arrayGet(i + 2, &obj4)->isNum() && + obj1.arrayGet(i + 3, &obj5)->isNum() && + obj1.arrayGet(i + 4, &obj6)->isNum()) { + if (widths.nExcepsV == excepsSize) { + excepsSize += 16; + widths.excepsV = (GfxFontCIDWidthExcepV *) + greallocn(widths.excepsV, + excepsSize, sizeof(GfxFontCIDWidthExcepV)); + } + widths.excepsV[widths.nExcepsV].first = obj2.getInt(); + widths.excepsV[widths.nExcepsV].last = obj3.getInt(); + widths.excepsV[widths.nExcepsV].height = obj4.getNum() * 0.001; + widths.excepsV[widths.nExcepsV].vx = obj5.getNum() * 0.001; + widths.excepsV[widths.nExcepsV].vy = obj6.getNum() * 0.001; + ++widths.nExcepsV; + } else { + error(errSyntaxError, -1, "Bad widths (W2) array in Type 0 font"); + } + obj6.free(); + obj5.free(); + obj4.free(); + i += 5; + } else if (obj2.isInt() && obj3.isArray()) { + if (widths.nExcepsV + obj3.arrayGetLength() / 3 > excepsSize) { + excepsSize = + (widths.nExcepsV + obj3.arrayGetLength() / 3 + 15) & ~15; + widths.excepsV = (GfxFontCIDWidthExcepV *) + greallocn(widths.excepsV, + excepsSize, sizeof(GfxFontCIDWidthExcepV)); + } + j = obj2.getInt(); + for (k = 0; k < obj3.arrayGetLength(); k += 3) { + if (obj3.arrayGet(k, &obj4)->isNum() && + obj3.arrayGet(k+1, &obj5)->isNum() && + obj3.arrayGet(k+2, &obj6)->isNum()) { + widths.excepsV[widths.nExcepsV].first = j; + widths.excepsV[widths.nExcepsV].last = j; + widths.excepsV[widths.nExcepsV].height = obj4.getNum() * 0.001; + widths.excepsV[widths.nExcepsV].vx = obj5.getNum() * 0.001; + widths.excepsV[widths.nExcepsV].vy = obj6.getNum() * 0.001; + ++j; + ++widths.nExcepsV; + } else { + error(errSyntaxError, -1, "Bad widths (W2) array in Type 0 font"); + } + obj6.free(); + obj5.free(); + obj4.free(); + } + i += 2; + } else { + error(errSyntaxError, -1, "Bad widths (W2) array in Type 0 font"); + ++i; + } + obj3.free(); + obj2.free(); + } + std::sort(widths.excepsV, widths.excepsV + widths.nExcepsV, + cmpWidthExcepVFunctor()); + } + obj1.free(); + + desFontDictObj.free(); + ok = gTrue; + return; + + err3: + obj3.free(); + obj2.free(); + err2: + obj1.free(); + desFontDictObj.free(); + err1:; +} + +GfxCIDFont::~GfxCIDFont() { + if (collection) { + delete collection; + } + if (cMap) { + cMap->decRefCnt(); + } + if (ctu) { + ctu->decRefCnt(); + } + gfree(widths.exceps); + gfree(widths.excepsV); + if (cidToGID) { + gfree(cidToGID); + } +} + +int GfxCIDFont::getNextChar(char *s, int len, CharCode *code, + Unicode **u, int *uLen, + double *dx, double *dy, double *ox, double *oy) { + CID cid; + CharCode c; + double w, h, vx, vy; + int n, a, b, m; + + if (!cMap) { + *code = 0; + *uLen = 0; + *dx = *dy = 0; + return 1; + } + + *code = (CharCode)(cid = cMap->getCID(s, len, &c, &n)); + if (ctu) { + if (hasToUnicode) { + int i = 0, c = 0; + while (i < n) { + c = (c << 8 ) + (s[i] & 0xff); + ++i; + } + *uLen = ctu->mapToUnicode(c, u); + } else { + *uLen = ctu->mapToUnicode(cid, u); + } + } else { + *uLen = 0; + } + + // horizontal + if (cMap->getWMode() == 0) { + w = getWidth(cid); + h = vx = vy = 0; + + // vertical + } else { + w = 0; + h = widths.defHeight; + vx = getWidth(cid) / 2; + vy = widths.defVY; + if (widths.nExcepsV > 0 && cid >= widths.excepsV[0].first) { + a = 0; + b = widths.nExcepsV; + // invariant: widths.excepsV[a].first <= cid < widths.excepsV[b].first + while (b - a > 1) { + m = (a + b) / 2; + if (widths.excepsV[m].last <= cid) { + a = m; + } else { + b = m; + } + } + if (cid <= widths.excepsV[a].last) { + h = widths.excepsV[a].height; + vx = widths.excepsV[a].vx; + vy = widths.excepsV[a].vy; + } + } + } + + *dx = w; + *dy = h; + *ox = vx; + *oy = vy; + + return n; +} + +int GfxCIDFont::getWMode() { + return cMap ? cMap->getWMode() : 0; +} + +CharCodeToUnicode *GfxCIDFont::getToUnicode() { + if (ctu) { + ctu->incRefCnt(); + } + return ctu; +} + +GooString *GfxCIDFont::getCollection() { + return cMap ? cMap->getCollection() : (GooString *)NULL; +} + +int GfxCIDFont::mapCodeToGID(FoFiTrueType *ff, int cmapi, + Unicode unicode, GBool wmode) { + Gushort gid = ff->mapCodeToGID(cmapi,unicode); + if (wmode) { + Gushort vgid = ff->mapToVertGID(gid); + if (vgid != 0) gid = vgid; + } + return gid; +} + +int *GfxCIDFont::getCodeToGIDMap(FoFiTrueType *ff, int *mapsizep) { +#define N_UCS_CANDIDATES 2 + /* space characters */ + static const unsigned long spaces[] = { + 0x2000,0x2001,0x2002,0x2003,0x2004,0x2005,0x2006,0x2007, + 0x2008,0x2009,0x200A,0x00A0,0x200B,0x2060,0x3000,0xFEFF, + 0 + }; + static const char *adobe_cns1_cmaps[] = { + "UniCNS-UTF32-V", + "UniCNS-UCS2-V", + "UniCNS-UTF32-H", + "UniCNS-UCS2-H", + 0 + }; + static const char *adobe_gb1_cmaps[] = { + "UniGB-UTF32-V", + "UniGB-UCS2-V", + "UniGB-UTF32-H", + "UniGB-UCS2-H", + 0 + }; + static const char *adobe_japan1_cmaps[] = { + "UniJIS-UTF32-V", + "UniJIS-UCS2-V", + "UniJIS-UTF32-H", + "UniJIS-UCS2-H", + 0 + }; + static const char *adobe_japan2_cmaps[] = { + "UniHojo-UTF32-V", + "UniHojo-UCS2-V", + "UniHojo-UTF32-H", + "UniHojo-UCS2-H", + 0 + }; + static const char *adobe_korea1_cmaps[] = { + "UniKS-UTF32-V", + "UniKS-UCS2-V", + "UniKS-UTF32-H", + "UniKS-UCS2-H", + 0 + }; + static struct CMapListEntry { + const char *collection; + const char *scriptTag; + const char *languageTag; + const char *toUnicodeMap; + const char **CMaps; + } CMapList[] = { + { + "Adobe-CNS1", + "hani", "CHN ", + "Adobe-CNS1-UCS2", + adobe_cns1_cmaps, + }, + { + "Adobe-GB1", + "hani", "CHN ", + "Adobe-GB1-UCS2", + adobe_gb1_cmaps, + }, + { + "Adobe-Japan1", + "kana", "JAN ", + "Adobe-Japan1-UCS2", + adobe_japan1_cmaps, + }, + { + "Adobe-Japan2", + "kana", "JAN ", + "Adobe-Japan2-UCS2", + adobe_japan2_cmaps, + }, + { + "Adobe-Korea1", + "hang", "KOR ", + "Adobe-Korea1-UCS2", + adobe_korea1_cmaps, + }, + {0, 0, 0, 0} + }; + Unicode *humap = 0; + Unicode *vumap = 0; + Unicode *tumap = 0; + int *codeToGID = 0; + unsigned long n; + int i; + unsigned long code; + int wmode; + const char **cmapName; + CMap *cMap; + CMapListEntry *lp; + int cmap; + int cmapPlatform, cmapEncoding; + Ref embID; + + *mapsizep = 0; + if (!ctu) return NULL; + if (getCollection()->cmp("Adobe-Identity") == 0) return NULL; + if (getEmbeddedFontID(&embID)) { + /* if this font is embedded font, + * CIDToGIDMap should be embedded in PDF file + * and already set. So return it. + */ + *mapsizep = getCIDToGIDLen(); + return getCIDToGID(); + } + + /* we use only unicode cmap */ + cmap = -1; + for (i = 0; i < ff->getNumCmaps(); ++i) { + cmapPlatform = ff->getCmapPlatform(i); + cmapEncoding = ff->getCmapEncoding(i); + if (cmapPlatform == 3 && cmapEncoding == 10) { + /* UCS-4 */ + cmap = i; + /* use UCS-4 cmap */ + break; + } else if (cmapPlatform == 3 && cmapEncoding == 1) { + /* Unicode */ + cmap = i; + } else if (cmapPlatform == 0 && cmap < 0) { + cmap = i; + } + } + if (cmap < 0) + return NULL; + + wmode = getWMode(); + for (lp = CMapList;lp->collection != 0;lp++) { + if (strcmp(lp->collection,getCollection()->getCString()) == 0) { + break; + } + } + n = 65536; + tumap = new Unicode[n]; + humap = new Unicode[n*N_UCS_CANDIDATES]; + memset(humap,0,sizeof(Unicode)*n*N_UCS_CANDIDATES); + if (lp->collection != 0) { + CharCodeToUnicode *tctu; + GooString tname(lp->toUnicodeMap); + + if ((tctu = CharCodeToUnicode::parseCMapFromFile(&tname,16)) != 0) { + CharCode cid; + for (cid = 0;cid < n ;cid++) { + int len; + Unicode *ucodes; + + len = tctu->mapToUnicode(cid,&ucodes); + if (len == 1) { + tumap[cid] = ucodes[0]; + } else { + /* if not single character, ignore it */ + tumap[cid] = 0; + } + } + delete tctu; + } + vumap = new Unicode[n]; + memset(vumap,0,sizeof(Unicode)*n); + for (cmapName = lp->CMaps;*cmapName != 0;cmapName++) { + GooString cname(*cmapName); + + if ((cMap = globalParams->getCMap(getCollection(),&cname)) + != 0) { + if (cMap->getWMode()) { + cMap->setReverseMap(vumap,n,1); + } else { + cMap->setReverseMap(humap,n,N_UCS_CANDIDATES); + } + cMap->decRefCnt(); + } + } + ff->setupGSUB(lp->scriptTag, lp->languageTag); + } else { + error(errSyntaxError, -1, "Unknown character collection {0:t}\n", + getCollection()); + if ((ctu = getToUnicode()) != 0) { + CharCode cid; + for (cid = 0;cid < n ;cid++) { + Unicode *ucode; + + if (ctu->mapToUnicode(cid, &ucode)) + humap[cid*N_UCS_CANDIDATES] = ucode[0]; + else + humap[cid*N_UCS_CANDIDATES] = 0; + for (i = 1;i < N_UCS_CANDIDATES;i++) { + humap[cid*N_UCS_CANDIDATES+i] = 0; + } + } + ctu->decRefCnt(); + } + } + // map CID -> Unicode -> GID + codeToGID = (int *)gmallocn(n, sizeof(int)); + for (code = 0; code < n; ++code) { + Unicode unicode; + unsigned long gid; + + unicode = 0; + gid = 0; + if (humap != 0) { + for (i = 0;i < N_UCS_CANDIDATES + && gid == 0 && (unicode = humap[code*N_UCS_CANDIDATES+i]) != 0;i++) { + gid = mapCodeToGID(ff,cmap,unicode,gFalse); + } + } + if (gid == 0 && vumap != 0) { + unicode = vumap[code]; + if (unicode != 0) { + gid = mapCodeToGID(ff,cmap,unicode,gTrue); + if (gid == 0 && tumap != 0) { + if ((unicode = tumap[code]) != 0) { + gid = mapCodeToGID(ff,cmap,unicode,gTrue); + } + } + } + } + if (gid == 0 && tumap != 0) { + if ((unicode = tumap[code]) != 0) { + gid = mapCodeToGID(ff,cmap,unicode,gFalse); + } + } + if (gid == 0) { + /* special handling space characters */ + const unsigned long *p; + + if (humap != 0) unicode = humap[code]; + if (unicode != 0) { + /* check if code is space character , so map code to 0x0020 */ + for (p = spaces;*p != 0;p++) { + if (*p == unicode) { + unicode = 0x20; + gid = mapCodeToGID(ff,cmap,unicode,wmode); + break; + } + } + } + } + codeToGID[code] = gid; + } + *mapsizep = n; + if (humap != 0) delete[] humap; + if (tumap != 0) delete[] tumap; + if (vumap != 0) delete[] vumap; + return codeToGID; +} + +double GfxCIDFont::getWidth(CID cid) { + double w; + int a, b, m; + + w = widths.defWidth; + if (widths.nExceps > 0 && cid >= widths.exceps[0].first) { + a = 0; + b = widths.nExceps; + // invariant: widths.exceps[a].first <= cid < widths.exceps[b].first + while (b - a > 1) { + m = (a + b) / 2; + if (widths.exceps[m].first <= cid) { + a = m; + } else { + b = m; + } + } + if (cid <= widths.exceps[a].last) { + w = widths.exceps[a].width; + } + } + return w; +} + +double GfxCIDFont::getWidth (char* s, int len) { + int nUsed; + CharCode c; + + CID cid = cMap->getCID(s, len, &c, &nUsed); + return getWidth(cid); +} + +//------------------------------------------------------------------------ +// GfxFontDict +//------------------------------------------------------------------------ + +GfxFontDict::GfxFontDict(XRef *xref, Ref *fontDictRef, Dict *fontDict) { + int i; + Object obj1, obj2; + Ref r; + + numFonts = fontDict->getLength(); + fonts = (GfxFont **)gmallocn(numFonts, sizeof(GfxFont *)); + for (i = 0; i < numFonts; ++i) { + fontDict->getValNF(i, &obj1); + obj1.fetch(xref, &obj2); + if (obj2.isDict()) { + if (obj1.isRef()) { + r = obj1.getRef(); + } else { + // no indirect reference for this font, so invent a unique one + // (legal generation numbers are five digits, so any 6-digit + // number would be safe) + r.num = i; + if (fontDictRef) { + r.gen = 100000 + fontDictRef->num; + } else { + r.gen = 999999; + } + } + fonts[i] = GfxFont::makeFont(xref, fontDict->getKey(i), + r, obj2.getDict()); + if (fonts[i] && !fonts[i]->isOk()) { + // XXX: it may be meaningful to distinguish between + // NULL and !isOk() so that when we do lookups + // we can tell the difference between a missing font + // and a font that is just !isOk() + fonts[i]->decRefCnt(); + fonts[i] = NULL; + } + } else { + error(errSyntaxError, -1, "font resource is not a dictionary"); + fonts[i] = NULL; + } + obj1.free(); + obj2.free(); + } +} + +GfxFontDict::~GfxFontDict() { + int i; + + for (i = 0; i < numFonts; ++i) { + if (fonts[i]) { + fonts[i]->decRefCnt(); + } + } + gfree(fonts); +} + +GfxFont *GfxFontDict::lookup(char *tag) { + int i; + + for (i = 0; i < numFonts; ++i) { + if (fonts[i] && fonts[i]->matches(tag)) { + return fonts[i]; + } + } + return NULL; +} diff --git a/source/libs/poppler/poppler-0.33.0/poppler/GfxFont.h b/source/libs/poppler/poppler-0.33.0/poppler/GfxFont.h new file mode 100644 index 000000000..febb90292 --- /dev/null +++ b/source/libs/poppler/poppler-0.33.0/poppler/GfxFont.h @@ -0,0 +1,444 @@ +//======================================================================== +// +// GfxFont.h +// +// Copyright 1996-2003 Glyph & Cog, LLC +// +//======================================================================== + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2005, 2008, 2015 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> +// Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com> +// Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org> +// Copyright (C) 2007 Jeff Muizelaar <jeff@infidigm.net> +// Copyright (C) 2007 Koji Otani <sho@bbr.jp> +// Copyright (C) 2011 Axel Strübing <axel.struebing@freenet.de> +// Copyright (C) 2011, 2012, 2014 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2015 Jason Crain <jason@aquaticape.us> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#ifndef GFXFONT_H +#define GFXFONT_H + +#ifdef USE_GCC_PRAGMAS +#pragma interface +#endif + +#include "goo/gtypes.h" +#include "goo/GooString.h" +#include "Object.h" +#include "CharTypes.h" + +class Dict; +class CMap; +class CharCodeToUnicode; +class FoFiTrueType; +class PSOutputDev; +struct GfxFontCIDWidths; +struct Base14FontMapEntry; + +//------------------------------------------------------------------------ +// GfxFontType +//------------------------------------------------------------------------ + +enum GfxFontType { + //----- Gfx8BitFont + fontUnknownType, + fontType1, + fontType1C, + fontType1COT, + fontType3, + fontTrueType, + fontTrueTypeOT, + //----- GfxCIDFont + fontCIDType0, + fontCIDType0C, + fontCIDType0COT, + fontCIDType2, + fontCIDType2OT +}; + +//------------------------------------------------------------------------ +// GfxFontCIDWidths +//------------------------------------------------------------------------ + +struct GfxFontCIDWidthExcep { + CID first; // this record applies to + CID last; // CIDs <first>..<last> + double width; // char width +}; + +struct GfxFontCIDWidthExcepV { + CID first; // this record applies to + CID last; // CIDs <first>..<last> + double height; // char height + double vx, vy; // origin position +}; + +struct GfxFontCIDWidths { + double defWidth; // default char width + double defHeight; // default char height + double defVY; // default origin position + GfxFontCIDWidthExcep *exceps; // exceptions + int nExceps; // number of valid entries in exceps + GfxFontCIDWidthExcepV * // exceptions for vertical font + excepsV; + int nExcepsV; // number of valid entries in excepsV +}; + +//------------------------------------------------------------------------ +// GfxFontLoc +//------------------------------------------------------------------------ + +enum GfxFontLocType { + gfxFontLocEmbedded, // font embedded in PDF file + gfxFontLocExternal, // external font file + gfxFontLocResident // font resident in PS printer +}; + +class GfxFontLoc { +public: + + GfxFontLoc(); + ~GfxFontLoc(); + + GfxFontLocType locType; + GfxFontType fontType; + Ref embFontID; // embedded stream obj ID + // (if locType == gfxFontLocEmbedded) + GooString *path; // font file path + // (if locType == gfxFontLocExternal) + // PS font name + // (if locType == gfxFontLocResident) + int fontNum; // for TrueType collections + // (if locType == gfxFontLocExternal) + GooString *encoding; // PS font encoding, only for 16-bit fonts + // (if locType == gfxFontLocResident) + int wMode; // writing mode, only for 16-bit fonts + // (if locType == gfxFontLocResident) + int substIdx; // substitute font index + // (if locType == gfxFontLocExternal, + // and a Base-14 substitution was made) +}; + +//------------------------------------------------------------------------ +// GfxFont +//------------------------------------------------------------------------ + +#define fontFixedWidth (1 << 0) +#define fontSerif (1 << 1) +#define fontSymbolic (1 << 2) +#define fontItalic (1 << 6) +#define fontBold (1 << 18) + +class GfxFont { +public: + + enum Stretch { + StretchNotDefined, + UltraCondensed, + ExtraCondensed, + Condensed, + SemiCondensed, + Normal, + SemiExpanded, + Expanded, + ExtraExpanded, + UltraExpanded }; + + enum Weight { + WeightNotDefined, + W100, + W200, + W300, + W400, // Normal + W500, + W600, + W700, // Bold + W800, + W900 }; + + // Build a GfxFont object. + static GfxFont *makeFont(XRef *xref, const char *tagA, Ref idA, Dict *fontDict); + + GfxFont(const char *tagA, Ref idA, GooString *nameA, + GfxFontType typeA, Ref embFontIDA); + + GBool isOk() { return ok; } + + void incRefCnt(); + void decRefCnt(); + + // Get font tag. + GooString *getTag() { return tag; } + + // Get font dictionary ID. + Ref *getID() { return &id; } + + // Does this font match the tag? + GBool matches(char *tagA) { return !tag->cmp(tagA); } + + // Get font family name. + GooString *getFamily() { return family; } + + // Get font stretch. + Stretch getStretch() { return stretch; } + + // Get font weight. + Weight getWeight() { return weight; } + + // Get the original font name (ignornig any munging that might have + // been done to map to a canonical Base-14 font name). + GooString *getName() { return name; } + + // Get font type. + GfxFontType getType() { return type; } + virtual GBool isCIDFont() { return gFalse; } + + // Get embedded font ID, i.e., a ref for the font file stream. + // Returns false if there is no embedded font. + GBool getEmbeddedFontID(Ref *embID) + { *embID = embFontID; return embFontID.num >= 0; } + + // Get the PostScript font name for the embedded font. Returns + // NULL if there is no embedded font. + GooString *getEmbeddedFontName() { return embFontName; } + + // Get font descriptor flags. + int getFlags() { return flags; } + GBool isFixedWidth() { return flags & fontFixedWidth; } + GBool isSerif() { return flags & fontSerif; } + GBool isSymbolic() { return flags & fontSymbolic; } + GBool isItalic() { return flags & fontItalic; } + GBool isBold() { return flags & fontBold; } + + // Return the Unicode map. + virtual CharCodeToUnicode *getToUnicode() = 0; + + // Return the font matrix. + double *getFontMatrix() { return fontMat; } + + // Return the font bounding box. + double *getFontBBox() { return fontBBox; } + + // Return the ascent and descent values. + double getAscent() { return ascent; } + double getDescent() { return descent; } + + // Return the writing mode (0=horizontal, 1=vertical). + virtual int getWMode() { return 0; } + + // Locate the font file for this font. If <ps> is not null, includes PS + // printer-resident fonts. Returns NULL on failure. + GfxFontLoc *locateFont(XRef *xref, PSOutputDev *ps); + + // Locate a Base-14 font file for a specified font name. + static GfxFontLoc *locateBase14Font(GooString *base14Name); + + // Read an external or embedded font file into a buffer. + char *readEmbFontFile(XRef *xref, int *len); + + // Get the next char from a string <s> of <len> bytes, returning the + // char <code>, its Unicode mapping <u>, its displacement vector + // (<dx>, <dy>), and its origin offset vector (<ox>, <oy>). <uSize> + // is the number of entries available in <u>, and <uLen> is set to + // the number actually used. Returns the number of bytes used by + // the char code. + virtual int getNextChar(char *s, int len, CharCode *code, + Unicode **u, int *uLen, + double *dx, double *dy, double *ox, double *oy) = 0; + + // Does this font have a toUnicode map? + GBool hasToUnicodeCMap() { return hasToUnicode; } + + // Return the name of the encoding + GooString *getEncodingName() { return encodingName; } + + // Return AGLFN names of ligatures in the Standard and Expert encodings + // for use with fonts that are not compatible with the Standard 14 fonts. + // http://sourceforge.net/adobe/aglfn/wiki/AGL%20Specification/ + static const char *getAlternateName(const char *name); + +protected: + + virtual ~GfxFont(); + + static GfxFontType getFontType(XRef *xref, Dict *fontDict, Ref *embID); + void readFontDescriptor(XRef *xref, Dict *fontDict); + CharCodeToUnicode *readToUnicodeCMap(Dict *fontDict, int nBits, + CharCodeToUnicode *ctu); + static GfxFontLoc *getExternalFont(GooString *path, GBool cid); + + GooString *tag; // PDF font tag + Ref id; // reference (used as unique ID) + GooString *name; // font name + GooString *family; // font family + Stretch stretch; // font stretch + Weight weight; // font weight + GfxFontType type; // type of font + int flags; // font descriptor flags + GooString *embFontName; // name of embedded font + Ref embFontID; // ref to embedded font file stream + double fontMat[6]; // font matrix (Type 3 only) + double fontBBox[4]; // font bounding box (Type 3 only) + double missingWidth; // "default" width + double ascent; // max height above baseline + double descent; // max depth below baseline + int refCnt; + GBool ok; + GBool hasToUnicode; + GooString *encodingName; +}; + +//------------------------------------------------------------------------ +// Gfx8BitFont +//------------------------------------------------------------------------ + +class Gfx8BitFont: public GfxFont { +public: + + Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, + GfxFontType typeA, Ref embFontIDA, Dict *fontDict); + + virtual int getNextChar(char *s, int len, CharCode *code, + Unicode **u, int *uLen, + double *dx, double *dy, double *ox, double *oy); + + // Return the encoding. + char **getEncoding() { return enc; } + + // Return the Unicode map. + CharCodeToUnicode *getToUnicode(); + + // Return the character name associated with <code>. + char *getCharName(int code) { return enc[code]; } + + // Returns true if the PDF font specified an encoding. + GBool getHasEncoding() { return hasEncoding; } + + // Returns true if the PDF font specified MacRomanEncoding. + GBool getUsesMacRomanEnc() { return usesMacRomanEnc; } + + // Get width of a character. + double getWidth(Guchar c) { return widths[c]; } + + // Return a char code-to-GID mapping for the provided font file. + // (This is only useful for TrueType fonts.) + int *getCodeToGIDMap(FoFiTrueType *ff); + + // Return the Type 3 CharProc dictionary, or NULL if none. + Dict *getCharProcs(); + + // Return the Type 3 CharProc for the character associated with <code>. + Object *getCharProc(int code, Object *proc); + + // Return the Type 3 Resources dictionary, or NULL if none. + Dict *getResources(); + +private: + virtual ~Gfx8BitFont(); + + const Base14FontMapEntry *base14; // for Base-14 fonts only; NULL otherwise + char *enc[256]; // char code --> char name + char encFree[256]; // boolean for each char name: if set, + // the string is malloc'ed + CharCodeToUnicode *ctu; // char code --> Unicode + GBool hasEncoding; + GBool usesMacRomanEnc; + double widths[256]; // character widths + Object charProcs; // Type 3 CharProcs dictionary + Object resources; // Type 3 Resources dictionary + + friend class GfxFont; +}; + +//------------------------------------------------------------------------ +// GfxCIDFont +//------------------------------------------------------------------------ + +class GfxCIDFont: public GfxFont { +public: + + GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, + GfxFontType typeA, Ref embFontIDA, Dict *fontDict); + + virtual GBool isCIDFont() { return gTrue; } + + virtual int getNextChar(char *s, int len, CharCode *code, + Unicode **u, int *uLen, + double *dx, double *dy, double *ox, double *oy); + + // Return the writing mode (0=horizontal, 1=vertical). + virtual int getWMode(); + + // Return the Unicode map. + CharCodeToUnicode *getToUnicode(); + + // Get the collection name (<registry>-<ordering>). + GooString *getCollection(); + + // Return the CID-to-GID mapping table. These should only be called + // if type is fontCIDType2. + int *getCIDToGID() { return cidToGID; } + int getCIDToGIDLen() { return cidToGIDLen; } + + int *getCodeToGIDMap(FoFiTrueType *ff, int *length); + + double getWidth(char* s, int len); + +private: + virtual ~GfxCIDFont(); + + int mapCodeToGID(FoFiTrueType *ff, int cmapi, + Unicode unicode, GBool wmode); + double getWidth(CID cid); // Get width of a character. + + GooString *collection; // collection name + CMap *cMap; // char code --> CID + CharCodeToUnicode *ctu; // CID --> Unicode + GBool ctuUsesCharCode; // true: ctu maps char code to Unicode; + // false: ctu maps CID to Unicode + GfxFontCIDWidths widths; // character widths + int *cidToGID; // CID --> GID mapping (for embedded + // TrueType fonts) + int cidToGIDLen; +}; + +//------------------------------------------------------------------------ +// GfxFontDict +//------------------------------------------------------------------------ + +class GfxFontDict { +public: + + // Build the font dictionary, given the PDF font dictionary. + GfxFontDict(XRef *xref, Ref *fontDictRef, Dict *fontDict); + + // Destructor. + ~GfxFontDict(); + + // Get the specified font. + GfxFont *lookup(char *tag); + + // Iterative access. + int getNumFonts() { return numFonts; } + GfxFont *getFont(int i) { return fonts[i]; } + +private: + + GfxFont **fonts; // list of fonts + int numFonts; // number of fonts +}; + +#endif diff --git a/source/libs/poppler/poppler-0.32.0/poppler/GfxState.cc b/source/libs/poppler/poppler-0.33.0/poppler/GfxState.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/GfxState.cc rename to source/libs/poppler/poppler-0.33.0/poppler/GfxState.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/GfxState.h b/source/libs/poppler/poppler-0.33.0/poppler/GfxState.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/GfxState.h rename to source/libs/poppler/poppler-0.33.0/poppler/GfxState.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/GfxState_helpers.h b/source/libs/poppler/poppler-0.33.0/poppler/GfxState_helpers.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/GfxState_helpers.h rename to source/libs/poppler/poppler-0.33.0/poppler/GfxState_helpers.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/GlobalParams.cc b/source/libs/poppler/poppler-0.33.0/poppler/GlobalParams.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/GlobalParams.cc rename to source/libs/poppler/poppler-0.33.0/poppler/GlobalParams.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/GlobalParams.h b/source/libs/poppler/poppler-0.33.0/poppler/GlobalParams.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/GlobalParams.h rename to source/libs/poppler/poppler-0.33.0/poppler/GlobalParams.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/GlobalParamsWin.cc b/source/libs/poppler/poppler-0.33.0/poppler/GlobalParamsWin.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/GlobalParamsWin.cc rename to source/libs/poppler/poppler-0.33.0/poppler/GlobalParamsWin.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Hints.cc b/source/libs/poppler/poppler-0.33.0/poppler/Hints.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Hints.cc rename to source/libs/poppler/poppler-0.33.0/poppler/Hints.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Hints.h b/source/libs/poppler/poppler-0.33.0/poppler/Hints.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Hints.h rename to source/libs/poppler/poppler-0.33.0/poppler/Hints.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/JArithmeticDecoder.cc b/source/libs/poppler/poppler-0.33.0/poppler/JArithmeticDecoder.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/JArithmeticDecoder.cc rename to source/libs/poppler/poppler-0.33.0/poppler/JArithmeticDecoder.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/JArithmeticDecoder.h b/source/libs/poppler/poppler-0.33.0/poppler/JArithmeticDecoder.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/JArithmeticDecoder.h rename to source/libs/poppler/poppler-0.33.0/poppler/JArithmeticDecoder.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/JBIG2Stream.cc b/source/libs/poppler/poppler-0.33.0/poppler/JBIG2Stream.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/JBIG2Stream.cc rename to source/libs/poppler/poppler-0.33.0/poppler/JBIG2Stream.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/JBIG2Stream.h b/source/libs/poppler/poppler-0.33.0/poppler/JBIG2Stream.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/JBIG2Stream.h rename to source/libs/poppler/poppler-0.33.0/poppler/JBIG2Stream.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/JPEG2000Stream.cc b/source/libs/poppler/poppler-0.33.0/poppler/JPEG2000Stream.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/JPEG2000Stream.cc rename to source/libs/poppler/poppler-0.33.0/poppler/JPEG2000Stream.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/JPEG2000Stream.h b/source/libs/poppler/poppler-0.33.0/poppler/JPEG2000Stream.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/JPEG2000Stream.h rename to source/libs/poppler/poppler-0.33.0/poppler/JPEG2000Stream.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/JPXStream.cc b/source/libs/poppler/poppler-0.33.0/poppler/JPXStream.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/JPXStream.cc rename to source/libs/poppler/poppler-0.33.0/poppler/JPXStream.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/JPXStream.h b/source/libs/poppler/poppler-0.33.0/poppler/JPXStream.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/JPXStream.h rename to source/libs/poppler/poppler-0.33.0/poppler/JPXStream.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Lexer.cc b/source/libs/poppler/poppler-0.33.0/poppler/Lexer.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Lexer.cc rename to source/libs/poppler/poppler-0.33.0/poppler/Lexer.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Lexer.h b/source/libs/poppler/poppler-0.33.0/poppler/Lexer.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Lexer.h rename to source/libs/poppler/poppler-0.33.0/poppler/Lexer.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Linearization.cc b/source/libs/poppler/poppler-0.33.0/poppler/Linearization.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Linearization.cc rename to source/libs/poppler/poppler-0.33.0/poppler/Linearization.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Linearization.h b/source/libs/poppler/poppler-0.33.0/poppler/Linearization.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Linearization.h rename to source/libs/poppler/poppler-0.33.0/poppler/Linearization.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Link.cc b/source/libs/poppler/poppler-0.33.0/poppler/Link.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Link.cc rename to source/libs/poppler/poppler-0.33.0/poppler/Link.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Link.h b/source/libs/poppler/poppler-0.33.0/poppler/Link.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Link.h rename to source/libs/poppler/poppler-0.33.0/poppler/Link.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/LocalPDFDocBuilder.cc b/source/libs/poppler/poppler-0.33.0/poppler/LocalPDFDocBuilder.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/LocalPDFDocBuilder.cc rename to source/libs/poppler/poppler-0.33.0/poppler/LocalPDFDocBuilder.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/LocalPDFDocBuilder.h b/source/libs/poppler/poppler-0.33.0/poppler/LocalPDFDocBuilder.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/LocalPDFDocBuilder.h rename to source/libs/poppler/poppler-0.33.0/poppler/LocalPDFDocBuilder.h diff --git a/source/libs/poppler/poppler-0.33.0/poppler/Makefile.am b/source/libs/poppler/poppler-0.33.0/poppler/Makefile.am new file mode 100644 index 000000000..fd75d1ada --- /dev/null +++ b/source/libs/poppler/poppler-0.33.0/poppler/Makefile.am @@ -0,0 +1,317 @@ +CFLAGS+=$(PTHREAD_CFLAGS) +CXXFLAGS+=$(PTHREAD_CFLAGS) + +AM_CPPFLAGS = \ + -I$(top_srcdir) \ + -I$(top_srcdir)/goo + +lib_LTLIBRARIES = libpoppler.la + +if BUILD_CAIRO_OUTPUT +noinst_LTLIBRARIES = libpoppler-cairo.la +endif + +if BUILD_SPLASH_OUTPUT + +splash_sources = \ + SplashOutputDev.cc + +splash_headers = \ + SplashOutputDev.h + +splash_includes = \ + $(SPLASH_CFLAGS) + +splash_libs = \ + $(SPLASH_LIBS) \ + $(top_builddir)/splash/libsplash.la + +endif + +if BUILD_LIBJPEG + +libjpeg_sources = \ + DCTStream.h \ + DCTStream.cc + +libjpeg_libs = \ + $(LIBJPEG_LIBS) +libjpeg_includes = \ + $(LIBJPEG_CFLAGS) + +endif + +if BUILD_LIBPNG + +libpng_libs = \ + $(LIBPNG_LIBS) +libpng_includes = \ + $(LIBPNG_CFLAGS) + +endif + +if BUILD_LIBTIFF + +libtiff_libs = \ + $(LIBTIFF_LIBS) +libtiff_includes = \ + $(LIBTIFF_CFLAGS) + +endif + +if BUILD_LIBOPENJPEG + +libjpeg2000_sources = \ + JPEG2000Stream.h \ + JPEG2000Stream.cc + +libjpeg2000_libs = \ + $(LIBOPENJPEG_LIBS) +libjpeg2000_includes = \ + $(LIBOPENJPEG_CFLAGS) + +else + +libjpeg2000_sources = \ + JPXStream.h \ + JPXStream.cc + +endif + + +if BUILD_ZLIB + +zlib_sources = \ + FlateStream.h \ + FlateStream.cc + +zlib_libs = \ + $(ZLIB_LIBS) + +endif + +if BUILD_LIBCURL + +libcurl_libs = \ + $(LIBCURL_LIBS) + +libcurl_includes = \ + $(LIBCURL_CFLAGS) + +curl_headers = \ + CurlCachedFile.h \ + CurlPDFDocBuilder.h + +curl_sources = \ + CurlCachedFile.cc \ + CurlPDFDocBuilder.cc + +endif + +if USE_CMS +cms_includes = $(LCMS_CFLAGS) +cms_libs = $(LCMS_LIBS) +endif + +if ENABLE_XPDF_HEADERS + +poppler_includedir = $(includedir)/poppler +poppler_include_HEADERS = \ + $(splash_headers) \ + $(curl_headers) \ + Annot.h \ + Array.h \ + BuiltinFont.h \ + BuiltinFontTables.h \ + CachedFile.h \ + Catalog.h \ + CharCodeToUnicode.h \ + CMap.h \ + DateInfo.h \ + Decrypt.h \ + Dict.h \ + Error.h \ + FileSpec.h \ + FontEncodingTables.h \ + FontInfo.h \ + Form.h \ + Function.h \ + Gfx.h \ + GfxFont.h \ + GfxState.h \ + GfxState_helpers.h \ + GlobalParams.h \ + Hints.h \ + JArithmeticDecoder.h \ + JBIG2Stream.h \ + Lexer.h \ + Linearization.h \ + Link.h \ + LocalPDFDocBuilder.h \ + Movie.h \ + NameToCharCode.h \ + Object.h \ + OptionalContent.h \ + Outline.h \ + OutputDev.h \ + Page.h \ + PageTransition.h \ + Parser.h \ + PDFDoc.h \ + PDFDocBuilder.h \ + PDFDocEncoding.h \ + PDFDocFactory.h \ + PopplerCache.h \ + ProfileData.h \ + PreScanOutputDev.h \ + PSTokenizer.h \ + Rendition.h \ + StdinCachedFile.h \ + StdinPDFDocBuilder.h \ + Stream-CCITT.h \ + Stream.h \ + StructElement.h \ + StructTreeRoot.h \ + UnicodeMap.h \ + UnicodeMapTables.h \ + UnicodeTypeTable.h \ + UnicodeCClassTables.h \ + UnicodeCompTables.h \ + UnicodeDecompTables.h \ + ViewerPreferences.h \ + XRef.h \ + CharTypes.h \ + CompactFontTables.h \ + ErrorCodes.h \ + NameToUnicodeTable.h \ + PSOutputDev.h \ + TextOutputDev.h \ + MarkedContentOutputDev.h \ + SecurityHandler.h \ + UTF.h \ + UTF8.h \ + XpdfPluginAPI.h \ + Sound.h +nodist_poppler_include_HEADERS = poppler-config.h + +endif + +libpoppler_la_SOURCES = \ + $(splash_sources) \ + $(libjpeg_sources) \ + $(zlib_sources) \ + $(libjpeg2000_sources) \ + $(curl_sources) \ + Annot.cc \ + Array.cc \ + BuiltinFont.cc \ + BuiltinFontTables.cc \ + CachedFile.cc \ + Catalog.cc \ + CharCodeToUnicode.cc \ + CMap.cc \ + DateInfo.cc \ + Decrypt.cc \ + Dict.cc \ + Error.cc \ + FileSpec.cc \ + FontEncodingTables.cc \ + Form.cc \ + FontInfo.cc \ + Function.cc \ + Gfx.cc \ + GfxFont.cc \ + GfxState.cc \ + GlobalParams.cc \ + Hints.cc \ + JArithmeticDecoder.cc \ + JBIG2Stream.cc \ + Lexer.cc \ + Linearization.cc \ + Link.cc \ + LocalPDFDocBuilder.cc \ + Movie.cc \ + NameToCharCode.cc \ + Object.cc \ + OptionalContent.cc \ + Outline.cc \ + OutputDev.cc \ + Page.cc \ + PageTransition.cc \ + Parser.cc \ + PDFDoc.cc \ + PDFDocEncoding.cc \ + PDFDocFactory.cc \ + PopplerCache.cc \ + ProfileData.cc \ + PreScanOutputDev.cc \ + PSTokenizer.cc \ + Rendition.cc \ + StdinCachedFile.cc \ + StdinPDFDocBuilder.cc \ + Stream.cc \ + StructTreeRoot.cc \ + StructElement.cc \ + strtok_r.cpp \ + UnicodeMap.cc \ + UnicodeTypeTable.cc \ + UTF.cc \ + ViewerPreferences.cc \ + XRef.cc \ + PSOutputDev.cc \ + TextOutputDev.cc \ + MarkedContentOutputDev.cc \ + PageLabelInfo.h \ + PageLabelInfo.cc \ + SecurityHandler.cc \ + Sound.cc \ + XpdfPluginAPI.cc + +libpoppler_la_CPPFLAGS = \ + $(cms_includes) \ + $(splash_includes) \ + $(libjpeg_includes) \ + $(libtiff_includes) \ + $(libjpeg2000_includes) \ + $(libpng_includes) \ + $(libcurl_includes) \ + $(FREETYPE_CFLAGS) \ + $(FONTCONFIG_CFLAGS) \ + $(AM_CPPFLAGS) + +libpoppler_la_LIBADD = \ + $(top_builddir)/goo/libgoo.la \ + $(top_builddir)/fofi/libfofi.la \ + $(cms_libs) \ + $(splash_libs) \ + $(libtiff_libs) \ + $(libjpeg_libs) \ + $(libpng_libs) \ + $(zlib_libs) \ + $(libcurl_libs) \ + $(libjpeg2000_libs) \ + $(FREETYPE_LIBS) \ + $(FONTCONFIG_LIBS) \ + $(PTHREAD_LIBS) \ + $(win32_libs) + +libpoppler_la_LDFLAGS = \ + -version-info 52:0:0 \ + @create_shared_lib@ \ + @auto_import_flags@ + +libpoppler_cairo_la_SOURCES = \ + CairoFontEngine.cc \ + CairoFontEngine.h \ + CairoOutputDev.cc \ + CairoOutputDev.h \ + CairoRescaleBox.cc \ + CairoRescaleBox.h + +libpoppler_cairo_la_CPPFLAGS = \ + $(CAIRO_CFLAGS) \ + $(AM_CPPFLAGS) + +EXTRA_DIST = gen-unicode-tables.py \ + GlobalParamsWin.cc \ + PageLabelInfo_p.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/MarkedContentOutputDev.cc b/source/libs/poppler/poppler-0.33.0/poppler/MarkedContentOutputDev.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/MarkedContentOutputDev.cc rename to source/libs/poppler/poppler-0.33.0/poppler/MarkedContentOutputDev.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/MarkedContentOutputDev.h b/source/libs/poppler/poppler-0.33.0/poppler/MarkedContentOutputDev.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/MarkedContentOutputDev.h rename to source/libs/poppler/poppler-0.33.0/poppler/MarkedContentOutputDev.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Movie.cc b/source/libs/poppler/poppler-0.33.0/poppler/Movie.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Movie.cc rename to source/libs/poppler/poppler-0.33.0/poppler/Movie.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Movie.h b/source/libs/poppler/poppler-0.33.0/poppler/Movie.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Movie.h rename to source/libs/poppler/poppler-0.33.0/poppler/Movie.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/NameToCharCode.cc b/source/libs/poppler/poppler-0.33.0/poppler/NameToCharCode.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/NameToCharCode.cc rename to source/libs/poppler/poppler-0.33.0/poppler/NameToCharCode.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/NameToCharCode.h b/source/libs/poppler/poppler-0.33.0/poppler/NameToCharCode.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/NameToCharCode.h rename to source/libs/poppler/poppler-0.33.0/poppler/NameToCharCode.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/NameToUnicodeTable.h b/source/libs/poppler/poppler-0.33.0/poppler/NameToUnicodeTable.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/NameToUnicodeTable.h rename to source/libs/poppler/poppler-0.33.0/poppler/NameToUnicodeTable.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Object.cc b/source/libs/poppler/poppler-0.33.0/poppler/Object.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Object.cc rename to source/libs/poppler/poppler-0.33.0/poppler/Object.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Object.h b/source/libs/poppler/poppler-0.33.0/poppler/Object.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Object.h rename to source/libs/poppler/poppler-0.33.0/poppler/Object.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/OptionalContent.cc b/source/libs/poppler/poppler-0.33.0/poppler/OptionalContent.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/OptionalContent.cc rename to source/libs/poppler/poppler-0.33.0/poppler/OptionalContent.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/OptionalContent.h b/source/libs/poppler/poppler-0.33.0/poppler/OptionalContent.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/OptionalContent.h rename to source/libs/poppler/poppler-0.33.0/poppler/OptionalContent.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Outline.cc b/source/libs/poppler/poppler-0.33.0/poppler/Outline.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Outline.cc rename to source/libs/poppler/poppler-0.33.0/poppler/Outline.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Outline.h b/source/libs/poppler/poppler-0.33.0/poppler/Outline.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Outline.h rename to source/libs/poppler/poppler-0.33.0/poppler/Outline.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/OutputDev.cc b/source/libs/poppler/poppler-0.33.0/poppler/OutputDev.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/OutputDev.cc rename to source/libs/poppler/poppler-0.33.0/poppler/OutputDev.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/OutputDev.h b/source/libs/poppler/poppler-0.33.0/poppler/OutputDev.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/OutputDev.h rename to source/libs/poppler/poppler-0.33.0/poppler/OutputDev.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PDFDoc.cc b/source/libs/poppler/poppler-0.33.0/poppler/PDFDoc.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/PDFDoc.cc rename to source/libs/poppler/poppler-0.33.0/poppler/PDFDoc.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PDFDoc.h b/source/libs/poppler/poppler-0.33.0/poppler/PDFDoc.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/PDFDoc.h rename to source/libs/poppler/poppler-0.33.0/poppler/PDFDoc.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PDFDocBuilder.h b/source/libs/poppler/poppler-0.33.0/poppler/PDFDocBuilder.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/PDFDocBuilder.h rename to source/libs/poppler/poppler-0.33.0/poppler/PDFDocBuilder.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PDFDocEncoding.cc b/source/libs/poppler/poppler-0.33.0/poppler/PDFDocEncoding.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/PDFDocEncoding.cc rename to source/libs/poppler/poppler-0.33.0/poppler/PDFDocEncoding.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PDFDocEncoding.h b/source/libs/poppler/poppler-0.33.0/poppler/PDFDocEncoding.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/PDFDocEncoding.h rename to source/libs/poppler/poppler-0.33.0/poppler/PDFDocEncoding.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PDFDocFactory.cc b/source/libs/poppler/poppler-0.33.0/poppler/PDFDocFactory.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/PDFDocFactory.cc rename to source/libs/poppler/poppler-0.33.0/poppler/PDFDocFactory.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PDFDocFactory.h b/source/libs/poppler/poppler-0.33.0/poppler/PDFDocFactory.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/PDFDocFactory.h rename to source/libs/poppler/poppler-0.33.0/poppler/PDFDocFactory.h diff --git a/source/libs/poppler/poppler-0.33.0/poppler/PSOutputDev.cc b/source/libs/poppler/poppler-0.33.0/poppler/PSOutputDev.cc new file mode 100644 index 000000000..5dc89bea2 --- /dev/null +++ b/source/libs/poppler/poppler-0.33.0/poppler/PSOutputDev.cc @@ -0,0 +1,7521 @@ +//======================================================================== +// +// PSOutputDev.cc +// +// Copyright 1996-2003 Glyph & Cog, LLC +// +//======================================================================== + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> +// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> +// Copyright (C) 2006-2009, 2011-2013, 2015 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net> +// Copyright (C) 2007, 2008 Brad Hards <bradh@kde.org> +// Copyright (C) 2008, 2009 Koji Otani <sho@bbr.jp> +// Copyright (C) 2008, 2010 Hib Eris <hib@hiberis.nl> +// Copyright (C) 2009-2013 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2009 Till Kamppeter <till.kamppeter@gmail.com> +// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org> +// Copyright (C) 2009, 2011, 2012, 2014, 2015 William Bader <williambader@hotmail.com> +// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net> +// Copyright (C) 2009-2011, 2013, 2014 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2012, 2014 Fabio D'Urso <fabiodurso@hotmail.it> +// Copyright (C) 2012 Lu Wang <coolwanglu@gmail.com> +// Copyright (C) 2014 Till Kamppeter <till.kamppeter@gmail.com> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#include <config.h> + +#ifdef USE_GCC_PRAGMAS +#pragma implementation +#endif + +#include <stdio.h> +#include <stddef.h> +#include <stdarg.h> +#include <signal.h> +#include <math.h> +#include <limits.h> +#include "goo/GooString.h" +#include "goo/GooList.h" +#include "goo/GooHash.h" +#include "poppler-config.h" +#include "GlobalParams.h" +#include "Object.h" +#include "Error.h" +#include "Function.h" +#include "Gfx.h" +#include "GfxState.h" +#include "GfxFont.h" +#include "UnicodeMap.h" +#include <fofi/FoFiType1C.h> +#include <fofi/FoFiTrueType.h> +#include "Catalog.h" +#include "Page.h" +#include "Stream.h" +#include "Annot.h" +#include "XRef.h" +#include "PreScanOutputDev.h" +#include "FileSpec.h" +#include "CharCodeToUnicode.h" +#if HAVE_SPLASH +# include "splash/Splash.h" +# include "splash/SplashBitmap.h" +# include "SplashOutputDev.h" +#endif +#include "PSOutputDev.h" +#include "PDFDoc.h" + +#ifdef MACOS +// needed for setting type/creator of MacOS files +#include "ICSupport.h" +#endif + +// the MSVC math.h doesn't define this +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +//------------------------------------------------------------------------ + +// Max size of a slice when rasterizing pages, in pixels. +#define rasterizationSliceSize 20000000 + +//------------------------------------------------------------------------ +// PostScript prolog and setup +//------------------------------------------------------------------------ + +// The '~' escapes mark prolog code that is emitted only in certain +// levels: +// +// ~[123][sn] +// ^ ^----- s=psLevel*Sep, n=psLevel* +// +----- 1=psLevel1*, 2=psLevel2*, 3=psLevel3* + +static const char *prolog[] = { + "/xpdf 75 dict def xpdf begin", + "% PDF special state", + "/pdfDictSize 15 def", + "~1sn", + "/pdfStates 64 array def", + " 0 1 63 {", + " pdfStates exch pdfDictSize dict", + " dup /pdfStateIdx 3 index put", + " put", + " } for", + "~123sn", + "/pdfSetup {", + " /setpagedevice where {", + " pop 2 dict begin", + " /Policies 1 dict dup begin /PageSize 6 def end def", + " { /Duplex true def } if", + " currentdict end setpagedevice", + " } {", + " pop", + " } ifelse", + "} def", + "/pdfSetupPaper {", + " % Change paper size, but only if different from previous paper size otherwise", + " % duplex fails. PLRM specifies a tolerance of 5 pts when matching paper size", + " % so we use the same when checking if the size changes.", + " /setpagedevice where {", + " pop currentpagedevice", + " /PageSize known {", + " 2 copy", + " currentpagedevice /PageSize get aload pop", + " exch 4 1 roll", + " sub abs 5 gt", + " 3 1 roll", + " sub abs 5 gt", + " or", + " } {", + " true", + " } ifelse", + " {", + " 2 array astore", + " 2 dict begin", + " /PageSize exch def", + " /ImagingBBox null def", + " currentdict end", + " setpagedevice", + " } {", + " pop pop", + " } ifelse", + " } {", + " pop", + " } ifelse", + "} def", + "~1sn", + "/pdfOpNames [", + " /pdfFill /pdfStroke /pdfLastFill /pdfLastStroke", + " /pdfTextMat /pdfFontSize /pdfCharSpacing /pdfTextRender /pdfPatternCS", + " /pdfTextRise /pdfWordSpacing /pdfHorizScaling /pdfTextClipPath", + "] def", + "~123sn", + "/pdfStartPage {", + "~1sn", + " pdfStates 0 get begin", + "~23sn", + " pdfDictSize dict begin", + "~23n", + " /pdfFillCS [] def", + " /pdfFillXform {} def", + " /pdfStrokeCS [] def", + " /pdfStrokeXform {} def", + "~1n", + " /pdfFill 0 def", + " /pdfStroke 0 def", + "~1s", + " /pdfFill [0 0 0 1] def", + " /pdfStroke [0 0 0 1] def", + "~23sn", + " /pdfFill [0] def", + " /pdfStroke [0] def", + " /pdfFillOP false def", + " /pdfStrokeOP false def", + "~3sn", + " /pdfOPM false def", + "~123sn", + " /pdfLastFill false def", + " /pdfLastStroke false def", + " /pdfTextMat [1 0 0 1 0 0] def", + " /pdfFontSize 0 def", + " /pdfCharSpacing 0 def", + " /pdfTextRender 0 def", + " /pdfPatternCS false def", + " /pdfTextRise 0 def", + " /pdfWordSpacing 0 def", + " /pdfHorizScaling 1 def", + " /pdfTextClipPath [] def", + "} def", + "/pdfEndPage { end } def", + "~23s", + "% separation convention operators", + "/findcmykcustomcolor where {", + " pop", + "}{", + " /findcmykcustomcolor { 5 array astore } def", + "} ifelse", + "/setcustomcolor where {", + " pop", + "}{", + " /setcustomcolor {", + " exch", + " [ exch /Separation exch dup 4 get exch /DeviceCMYK exch", + " 0 4 getinterval cvx", + " [ exch /dup load exch { mul exch dup } /forall load", + " /pop load dup ] cvx", + " ] setcolorspace setcolor", + " } def", + "} ifelse", + "/customcolorimage where {", + " pop", + "}{", + " /customcolorimage {", + " gsave", + " [ exch /Separation exch dup 4 get exch /DeviceCMYK exch", + " 0 4 getinterval", + " [ exch /dup load exch { mul exch dup } /forall load", + " /pop load dup ] cvx", + " ] setcolorspace", + " 10 dict begin", + " /ImageType 1 def", + " /DataSource exch def", + " /ImageMatrix exch def", + " /BitsPerComponent exch def", + " /Height exch def", + " /Width exch def", + " /Decode [1 0] def", + " currentdict end", + " image", + " grestore", + " } def", + "} ifelse", + "~123sn", + "% PDF color state", + "~1n", + "/g { dup /pdfFill exch def setgray", + " /pdfLastFill true def /pdfLastStroke false def } def", + "/G { dup /pdfStroke exch def setgray", + " /pdfLastStroke true def /pdfLastFill false def } def", + "/fCol {", + " pdfLastFill not {", + " pdfFill setgray", + " /pdfLastFill true def /pdfLastStroke false def", + " } if", + "} def", + "/sCol {", + " pdfLastStroke not {", + " pdfStroke setgray", + " /pdfLastStroke true def /pdfLastFill false def", + " } if", + "} def", + "~1s", + "/k { 4 copy 4 array astore /pdfFill exch def setcmykcolor", + " /pdfLastFill true def /pdfLastStroke false def } def", + "/K { 4 copy 4 array astore /pdfStroke exch def setcmykcolor", + " /pdfLastStroke true def /pdfLastFill false def } def", + "/fCol {", + " pdfLastFill not {", + " pdfFill aload pop setcmykcolor", + " /pdfLastFill true def /pdfLastStroke false def", + " } if", + "} def", + "/sCol {", + " pdfLastStroke not {", + " pdfStroke aload pop setcmykcolor", + " /pdfLastStroke true def /pdfLastFill false def", + " } if", + "} def", + "~3n", + "/opm { dup /pdfOPM exch def", + " /setoverprintmode where{pop setoverprintmode}{pop}ifelse } def", + "~23n", + "/cs { /pdfFillXform exch def dup /pdfFillCS exch def", + " setcolorspace } def", + "/CS { /pdfStrokeXform exch def dup /pdfStrokeCS exch def", + " setcolorspace } def", + "/sc { pdfLastFill not { pdfFillCS setcolorspace } if", + " dup /pdfFill exch def aload pop pdfFillXform setcolor", + " /pdfLastFill true def /pdfLastStroke false def } def", + "/SC { pdfLastStroke not { pdfStrokeCS setcolorspace } if", + " dup /pdfStroke exch def aload pop pdfStrokeXform setcolor", + " /pdfLastStroke true def /pdfLastFill false def } def", + "/op { /pdfFillOP exch def", + " pdfLastFill { pdfFillOP setoverprint } if } def", + "/OP { /pdfStrokeOP exch def", + " pdfLastStroke { pdfStrokeOP setoverprint } if } def", + "/fCol {", + " pdfLastFill not {", + " pdfFillCS setcolorspace", + " pdfFill aload pop pdfFillXform setcolor", + " pdfFillOP setoverprint", + " /pdfLastFill true def /pdfLastStroke false def", + " } if", + "} def", + "/sCol {", + " pdfLastStroke not {", + " pdfStrokeCS setcolorspace", + " pdfStroke aload pop pdfStrokeXform setcolor", + " pdfStrokeOP setoverprint", + " /pdfLastStroke true def /pdfLastFill false def", + " } if", + "} def", + "~3s", + "/opm { dup /pdfOPM exch def", + " /setoverprintmode where{pop setoverprintmode}{pop}ifelse } def", + "~23s", + "/k { 4 copy 4 array astore /pdfFill exch def setcmykcolor", + " /pdfLastFill true def /pdfLastStroke false def } def", + "/K { 4 copy 4 array astore /pdfStroke exch def setcmykcolor", + " /pdfLastStroke true def /pdfLastFill false def } def", + "/ck { 6 copy 6 array astore /pdfFill exch def", + " findcmykcustomcolor exch setcustomcolor", + " /pdfLastFill true def /pdfLastStroke false def } def", + "/CK { 6 copy 6 array astore /pdfStroke exch def", + " findcmykcustomcolor exch setcustomcolor", + " /pdfLastStroke true def /pdfLastFill false def } def", + "/op { /pdfFillOP exch def", + " pdfLastFill { pdfFillOP setoverprint } if } def", + "/OP { /pdfStrokeOP exch def", + " pdfLastStroke { pdfStrokeOP setoverprint } if } def", + "/fCol {", + " pdfLastFill not {", + " pdfFill aload length 4 eq {", + " setcmykcolor", + " }{", + " findcmykcustomcolor exch setcustomcolor", + " } ifelse", + " pdfFillOP setoverprint", + " /pdfLastFill true def /pdfLastStroke false def", + " } if", + "} def", + "/sCol {", + " pdfLastStroke not {", + " pdfStroke aload length 4 eq {", + " setcmykcolor", + " }{", + " findcmykcustomcolor exch setcustomcolor", + " } ifelse", + " pdfStrokeOP setoverprint", + " /pdfLastStroke true def /pdfLastFill false def", + " } if", + "} def", + "~123sn", + "% build a font", + "/pdfMakeFont {", + " 4 3 roll findfont", + " 4 2 roll matrix scale makefont", + " dup length dict begin", + " { 1 index /FID ne { def } { pop pop } ifelse } forall", + " /Encoding exch def", + " currentdict", + " end", + " definefont pop", + "} def", + "/pdfMakeFont16 {", + " exch findfont", + " dup length dict begin", + " { 1 index /FID ne { def } { pop pop } ifelse } forall", + " /WMode exch def", + " currentdict", + " end", + " definefont pop", + "} def", + "~3sn", + "/pdfMakeFont16L3 {", + " 1 index /CIDFont resourcestatus {", + " pop pop 1 index /CIDFont findresource /CIDFontType known", + " } {", + " false", + " } ifelse", + " {", + " 0 eq { /Identity-H } { /Identity-V } ifelse", + " exch 1 array astore composefont pop", + " } {", + " pdfMakeFont16", + " } ifelse", + "} def", + "~123sn", + "% graphics state operators", + "~1sn", + "/q {", + " gsave", + " pdfOpNames length 1 sub -1 0 { pdfOpNames exch get load } for", + " pdfStates pdfStateIdx 1 add get begin", + " pdfOpNames { exch def } forall", + "} def", + "/Q { end grestore } def", + "~23sn", + "/q { gsave pdfDictSize dict begin } def", + "/Q {", + " end grestore", + " /pdfLastFill where {", + " pop", + " pdfLastFill {", + " pdfFillOP setoverprint", + " } {", + " pdfStrokeOP setoverprint", + " } ifelse", + " } if", + "~3sn", + " /pdfOPM where {", + " pop", + " pdfOPM /setoverprintmode where{pop setoverprintmode}{pop}ifelse ", + " } if", + "~23sn", + "} def", + "~123sn", + "/cm { concat } def", + "/d { setdash } def", + "/i { setflat } def", + "/j { setlinejoin } def", + "/J { setlinecap } def", + "/M { setmiterlimit } def", + "/w { setlinewidth } def", + "% path segment operators", + "/m { moveto } def", + "/l { lineto } def", + "/c { curveto } def", + "/re { 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto", + " neg 0 rlineto closepath } def", + "/h { closepath } def", + "% path painting operators", + "/S { sCol stroke } def", + "/Sf { fCol stroke } def", + "/f { fCol fill } def", + "/f* { fCol eofill } def", + "% clipping operators", + "/W { clip newpath } def", + "/W* { eoclip newpath } def", + "/Ws { strokepath clip newpath } def", + "% text state operators", + "/Tc { /pdfCharSpacing exch def } def", + "/Tf { dup /pdfFontSize exch def", + " dup pdfHorizScaling mul exch matrix scale", + " pdfTextMat matrix concatmatrix dup 4 0 put dup 5 0 put", + " exch findfont exch makefont setfont } def", + "/Tr { /pdfTextRender exch def } def", + "/Tp { /pdfPatternCS exch def } def", + "/Ts { /pdfTextRise exch def } def", + "/Tw { /pdfWordSpacing exch def } def", + "/Tz { /pdfHorizScaling exch def } def", + "% text positioning operators", + "/Td { pdfTextMat transform moveto } def", + "/Tm { /pdfTextMat exch def } def", + "% text string operators", + "/xyshow where {", + " pop", + " /xyshow2 {", + " dup length array", + " 0 2 2 index length 1 sub {", + " 2 index 1 index 2 copy get 3 1 roll 1 add get", + " pdfTextMat dtransform", + " 4 2 roll 2 copy 6 5 roll put 1 add 3 1 roll dup 4 2 roll put", + " } for", + " exch pop", + " xyshow", + " } def", + "}{", + " /xyshow2 {", + " currentfont /FontType get 0 eq {", + " 0 2 3 index length 1 sub {", + " currentpoint 4 index 3 index 2 getinterval show moveto", + " 2 copy get 2 index 3 2 roll 1 add get", + " pdfTextMat dtransform rmoveto", + " } for", + " } {", + " 0 1 3 index length 1 sub {", + " currentpoint 4 index 3 index 1 getinterval show moveto", + " 2 copy 2 mul get 2 index 3 2 roll 2 mul 1 add get", + " pdfTextMat dtransform rmoveto", + " } for", + " } ifelse", + " pop pop", + " } def", + "} ifelse", + "/cshow where {", + " pop", + " /xycp {", // xycharpath + " 0 3 2 roll", + " {", + " pop pop currentpoint 3 2 roll", + " 1 string dup 0 4 3 roll put false charpath moveto", + " 2 copy get 2 index 2 index 1 add get", + " pdfTextMat dtransform rmoveto", + " 2 add", + " } exch cshow", + " pop pop", + " } def", + "}{", + " /xycp {", // xycharpath + " currentfont /FontType get 0 eq {", + " 0 2 3 index length 1 sub {", + " currentpoint 4 index 3 index 2 getinterval false charpath moveto", + " 2 copy get 2 index 3 2 roll 1 add get", + " pdfTextMat dtransform rmoveto", + " } for", + " } {", + " 0 1 3 index length 1 sub {", + " currentpoint 4 index 3 index 1 getinterval false charpath moveto", + " 2 copy 2 mul get 2 index 3 2 roll 2 mul 1 add get", + " pdfTextMat dtransform rmoveto", + " } for", + " } ifelse", + " pop pop", + " } def", + "} ifelse", + "/Tj {", + " fCol", // because stringwidth has to draw Type 3 chars + " 0 pdfTextRise pdfTextMat dtransform rmoveto", + " currentpoint 4 2 roll", + " pdfTextRender 1 and 0 eq {", + " 2 copy xyshow2", + " } if", + " pdfTextRender 3 and dup 1 eq exch 2 eq or {", + " 3 index 3 index moveto", + " 2 copy", + " currentfont /FontType get 3 eq { fCol } { sCol } ifelse", + " xycp currentpoint stroke moveto", + " } if", + " pdfTextRender 4 and 0 ne {", + " 4 2 roll moveto xycp", + " /pdfTextClipPath [ pdfTextClipPath aload pop", + " {/moveto cvx}", + " {/lineto cvx}", + " {/curveto cvx}", + " {/closepath cvx}", + " pathforall ] def", + " currentpoint newpath moveto", + " } {", + " pop pop pop pop", + " } ifelse", + " 0 pdfTextRise neg pdfTextMat dtransform rmoveto", + "} def", + "/TJm { 0.001 mul pdfFontSize mul pdfHorizScaling mul neg 0", + " pdfTextMat dtransform rmoveto } def", + "/TJmV { 0.001 mul pdfFontSize mul neg 0 exch", + " pdfTextMat dtransform rmoveto } def", + "/Tclip { pdfTextClipPath cvx exec clip newpath", + " /pdfTextClipPath [] def } def", + "/Tclip* { pdfTextClipPath cvx exec eoclip newpath", + " /pdfTextClipPath [] def } def", + "~1ns", + "% Level 1 image operators", + "/pdfIm1 {", + " /pdfImBuf1 4 index string def", + " { currentfile pdfImBuf1 readhexstring pop } image", + "} def", + "/pdfIm1Bin {", + " /pdfImBuf1 4 index string def", + " { currentfile pdfImBuf1 readstring pop } image", + "} def", + "~1s", + "/pdfIm1Sep {", + " /pdfImBuf1 4 index string def", + " /pdfImBuf2 4 index string def", + " /pdfImBuf3 4 index string def", + " /pdfImBuf4 4 index string def", + " { currentfile pdfImBuf1 readhexstring pop }", + " { currentfile pdfImBuf2 readhexstring pop }", + " { currentfile pdfImBuf3 readhexstring pop }", + " { currentfile pdfImBuf4 readhexstring pop }", + " true 4 colorimage", + "} def", + "/pdfIm1SepBin {", + " /pdfImBuf1 4 index string def", + " /pdfImBuf2 4 index string def", + " /pdfImBuf3 4 index string def", + " /pdfImBuf4 4 index string def", + " { currentfile pdfImBuf1 readstring pop }", + " { currentfile pdfImBuf2 readstring pop }", + " { currentfile pdfImBuf3 readstring pop }", + " { currentfile pdfImBuf4 readstring pop }", + " true 4 colorimage", + "} def", + "~1ns", + "/pdfImM1 {", + " fCol /pdfImBuf1 4 index 7 add 8 idiv string def", + " { currentfile pdfImBuf1 readhexstring pop } imagemask", + "} def", + "/pdfImM1Bin {", + " fCol /pdfImBuf1 4 index 7 add 8 idiv string def", + " { currentfile pdfImBuf1 readstring pop } imagemask", + "} def", + "/pdfImStr {", + " 2 copy exch length lt {", + " 2 copy get exch 1 add exch", + " } {", + " ()", + " } ifelse", + "} def", + "/pdfImM1a {", + " { pdfImStr } imagemask", + " pop pop", + "} def", + "~23sn", + "% Level 2/3 image operators", + "/pdfImBuf 100 string def", + "/pdfImStr {", + " 2 copy exch length lt {", + " 2 copy get exch 1 add exch", + " } {", + " ()", + " } ifelse", + "} def", + "/skipEOD {", + " { currentfile pdfImBuf readline", + " not { pop exit } if", + " (%-EOD-) eq { exit } if } loop", + "} def", + "/pdfIm { image skipEOD } def", + "~3sn", + "/pdfMask {", + " /ReusableStreamDecode filter", + " skipEOD", + " /maskStream exch def", + "} def", + "/pdfMaskEnd { maskStream closefile } def", + "/pdfMaskInit {", + " /maskArray exch def", + " /maskIdx 0 def", + "} def", + "/pdfMaskSrc {", + " maskIdx maskArray length lt {", + " maskArray maskIdx get", + " /maskIdx maskIdx 1 add def", + " } {", + " ()", + " } ifelse", + "} def", + "~23s", + "/pdfImSep {", + " findcmykcustomcolor exch", + " dup /Width get /pdfImBuf1 exch string def", + " dup /Decode get aload pop 1 index sub /pdfImDecodeRange exch def", + " /pdfImDecodeLow exch def", + " begin Width Height BitsPerComponent ImageMatrix DataSource end", + " /pdfImData exch def", + " { pdfImData pdfImBuf1 readstring pop", + " 0 1 2 index length 1 sub {", + " 1 index exch 2 copy get", + " pdfImDecodeRange mul 255 div pdfImDecodeLow add round cvi", + " 255 exch sub put", + " } for }", + " 6 5 roll customcolorimage", + " skipEOD", + "} def", + "~23sn", + "/pdfImM { fCol imagemask skipEOD } def", + "~123sn", + "/pr { 2 index 2 index 3 2 roll putinterval 4 add } def", + "/pdfImClip {", + " gsave", + " 0 2 4 index length 1 sub {", + " dup 4 index exch 2 copy", + " get 5 index div put", + " 1 add 3 index exch 2 copy", + " get 3 index div put", + " } for", + " pop pop rectclip", + "} def", + "/pdfImClipEnd { grestore } def", + "~23sn", + "% shading operators", + "/colordelta {", + " false 0 1 3 index length 1 sub {", + " dup 4 index exch get 3 index 3 2 roll get sub abs 0.004 gt {", + " pop true", + " } if", + " } for", + " exch pop exch pop", + "} def", + "/funcCol { func n array astore } def", + "/funcSH {", + " dup 0 eq {", + " true", + " } {", + " dup 6 eq {", + " false", + " } {", + " 4 index 4 index funcCol dup", + " 6 index 4 index funcCol dup", + " 3 1 roll colordelta 3 1 roll", + " 5 index 5 index funcCol dup", + " 3 1 roll colordelta 3 1 roll", + " 6 index 8 index funcCol dup", + " 3 1 roll colordelta 3 1 roll", + " colordelta or or or", + " } ifelse", + " } ifelse", + " {", + " 1 add", + " 4 index 3 index add 0.5 mul exch 4 index 3 index add 0.5 mul exch", + " 6 index 6 index 4 index 4 index 4 index funcSH", + " 2 index 6 index 6 index 4 index 4 index funcSH", + " 6 index 2 index 4 index 6 index 4 index funcSH", + " 5 3 roll 3 2 roll funcSH pop pop", + " } {", + " pop 3 index 2 index add 0.5 mul 3 index 2 index add 0.5 mul", + "~23n", + " funcCol sc", + "~23s", + " funcCol aload pop k", + "~23sn", + " dup 4 index exch mat transform m", + " 3 index 3 index mat transform l", + " 1 index 3 index mat transform l", + " mat transform l pop pop h f*", + " } ifelse", + "} def", + "/axialCol {", + " dup 0 lt {", + " pop t0", + " } {", + " dup 1 gt {", + " pop t1", + " } {", + " dt mul t0 add", + " } ifelse", + " } ifelse", + " func n array astore", + "} def", + "/axialSH {", + " dup 0 eq {", + " true", + " } {", + " dup 8 eq {", + " false", + " } {", + " 2 index axialCol 2 index axialCol colordelta", + " } ifelse", + " } ifelse", + " {", + " 1 add 3 1 roll 2 copy add 0.5 mul", + " dup 4 3 roll exch 4 index axialSH", + " exch 3 2 roll axialSH", + " } {", + " pop 2 copy add 0.5 mul", + "~23n", + " axialCol sc", + "~23s", + " axialCol aload pop k", + "~23sn", + " exch dup dx mul x0 add exch dy mul y0 add", + " 3 2 roll dup dx mul x0 add exch dy mul y0 add", + " dx abs dy abs ge {", + " 2 copy yMin sub dy mul dx div add yMin m", + " yMax sub dy mul dx div add yMax l", + " 2 copy yMax sub dy mul dx div add yMax l", + " yMin sub dy mul dx div add yMin l", + " h f*", + " } {", + " exch 2 copy xMin sub dx mul dy div add xMin exch m", + " xMax sub dx mul dy div add xMax exch l", + " exch 2 copy xMax sub dx mul dy div add xMax exch l", + " xMin sub dx mul dy div add xMin exch l", + " h f*", + " } ifelse", + " } ifelse", + "} def", + "/radialCol {", + " dup t0 lt {", + " pop t0", + " } {", + " dup t1 gt {", + " pop t1", + " } if", + " } ifelse", + " func n array astore", + "} def", + "/radialSH {", + " dup 0 eq {", + " true", + " } {", + " dup 8 eq {", + " false", + " } {", + " 2 index dt mul t0 add radialCol", + " 2 index dt mul t0 add radialCol colordelta", + " } ifelse", + " } ifelse", + " {", + " 1 add 3 1 roll 2 copy add 0.5 mul", + " dup 4 3 roll exch 4 index radialSH", + " exch 3 2 roll radialSH", + " } {", + " pop 2 copy add 0.5 mul dt mul t0 add", + "~23n", + " radialCol sc", + "~23s", + " radialCol aload pop k", + "~23sn", + " encl {", + " exch dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add", + " 0 360 arc h", + " dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add", + " 360 0 arcn h f", + " } {", + " 2 copy", + " dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add", + " a1 a2 arcn", + " dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add", + " a2 a1 arcn h", + " dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add", + " a1 a2 arc", + " dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add", + " a2 a1 arc h f", + " } ifelse", + " } ifelse", + "} def", + "~123sn", + "end", + NULL +}; + +static const char *cmapProlog[] = { + "/CIDInit /ProcSet findresource begin", + "10 dict begin", + " begincmap", + " /CMapType 1 def", + " /CMapName /Identity-H def", + " /CIDSystemInfo 3 dict dup begin", + " /Registry (Adobe) def", + " /Ordering (Identity) def", + " /Supplement 0 def", + " end def", + " 1 begincodespacerange", + " <0000> <ffff>", + " endcodespacerange", + " 0 usefont", + " 1 begincidrange", + " <0000> <ffff> 0", + " endcidrange", + " endcmap", + " currentdict CMapName exch /CMap defineresource pop", + "end", + "10 dict begin", + " begincmap", + " /CMapType 1 def", + " /CMapName /Identity-V def", + " /CIDSystemInfo 3 dict dup begin", + " /Registry (Adobe) def", + " /Ordering (Identity) def", + " /Supplement 0 def", + " end def", + " /WMode 1 def", + " 1 begincodespacerange", + " <0000> <ffff>", + " endcodespacerange", + " 0 usefont", + " 1 begincidrange", + " <0000> <ffff> 0", + " endcidrange", + " endcmap", + " currentdict CMapName exch /CMap defineresource pop", + "end", + "end", + NULL +}; + +//------------------------------------------------------------------------ +// Fonts +//------------------------------------------------------------------------ + +struct PSSubstFont { + const char *psName; // PostScript name + double mWidth; // width of 'm' character +}; + +// NB: must be in same order as base14SubstFonts in GfxFont.cc +static PSSubstFont psBase14SubstFonts[14] = { + {"Courier", 0.600}, + {"Courier-Oblique", 0.600}, + {"Courier-Bold", 0.600}, + {"Courier-BoldOblique", 0.600}, + {"Helvetica", 0.833}, + {"Helvetica-Oblique", 0.833}, + {"Helvetica-Bold", 0.889}, + {"Helvetica-BoldOblique", 0.889}, + {"Times-Roman", 0.788}, + {"Times-Italic", 0.722}, + {"Times-Bold", 0.833}, + {"Times-BoldItalic", 0.778}, + // the last two are never used for substitution + {"Symbol", 0}, + {"ZapfDingbats", 0} +}; + +// Mapping from Type 1/1C font file to PS font name. +struct PST1FontName { + Ref fontFileID; + GooString *psName; // PostScript font name used for this + // embedded font file +}; + +// Info for 8-bit fonts +struct PSFont8Info { + Ref fontID; + int *codeToGID; // code-to-GID mapping for TrueType fonts +}; + +// Encoding info for substitute 16-bit font +struct PSFont16Enc { + Ref fontID; + GooString *enc; +}; + +//------------------------------------------------------------------------ +// process colors +//------------------------------------------------------------------------ + +#define psProcessCyan 1 +#define psProcessMagenta 2 +#define psProcessYellow 4 +#define psProcessBlack 8 +#define psProcessCMYK 15 + +//------------------------------------------------------------------------ +// PSOutCustomColor +//------------------------------------------------------------------------ + +class PSOutCustomColor { +public: + + PSOutCustomColor(double cA, double mA, + double yA, double kA, GooString *nameA); + ~PSOutCustomColor(); + + double c, m, y, k; + GooString *name; + PSOutCustomColor *next; +}; + +PSOutCustomColor::PSOutCustomColor(double cA, double mA, + double yA, double kA, GooString *nameA) { + c = cA; + m = mA; + y = yA; + k = kA; + name = nameA; + next = NULL; +} + +PSOutCustomColor::~PSOutCustomColor() { + delete name; +} + +//------------------------------------------------------------------------ + +struct PSOutImgClipRect { + int x0, x1, y0, y1; +}; + +//------------------------------------------------------------------------ + +struct PSOutPaperSize { + PSOutPaperSize(GooString *nameA, int wA, int hA) { name = nameA; w = wA; h = hA; } + ~PSOutPaperSize() { delete name; } + GooString *name; + int w, h; +}; + +//------------------------------------------------------------------------ +// DeviceNRecoder +//------------------------------------------------------------------------ + +class DeviceNRecoder: public FilterStream { +public: + + DeviceNRecoder(Stream *strA, int widthA, int heightA, + GfxImageColorMap *colorMapA); + virtual ~DeviceNRecoder(); + virtual StreamKind getKind() { return strWeird; } + virtual void reset(); + virtual int getChar() + { return (bufIdx >= bufSize && !fillBuf()) ? EOF : buf[bufIdx++]; } + virtual int lookChar() + { return (bufIdx >= bufSize && !fillBuf()) ? EOF : buf[bufIdx]; } + virtual GooString *getPSFilter(int psLevel, const char *indent) { return NULL; } + virtual GBool isBinary(GBool last = gTrue) { return gTrue; } + virtual GBool isEncoder() { return gTrue; } + +private: + + GBool fillBuf(); + + int width, height; + GfxImageColorMap *colorMap; + Function *func; + ImageStream *imgStr; + int buf[gfxColorMaxComps]; + int pixelIdx; + int bufIdx; + int bufSize; +}; + +DeviceNRecoder::DeviceNRecoder(Stream *strA, int widthA, int heightA, + GfxImageColorMap *colorMapA): + FilterStream(strA) { + width = widthA; + height = heightA; + colorMap = colorMapA; + imgStr = NULL; + pixelIdx = 0; + bufIdx = gfxColorMaxComps; + bufSize = ((GfxDeviceNColorSpace *)colorMap->getColorSpace())-> + getAlt()->getNComps(); + func = ((GfxDeviceNColorSpace *)colorMap->getColorSpace())-> + getTintTransformFunc(); +} + +DeviceNRecoder::~DeviceNRecoder() { + if (imgStr) { + delete imgStr; + } + if (str->isEncoder()) { + delete str; + } +} + +void DeviceNRecoder::reset() { + imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(), + colorMap->getBits()); + imgStr->reset(); +} + +GBool DeviceNRecoder::fillBuf() { + Guchar pixBuf[gfxColorMaxComps]; + GfxColor color; + double x[gfxColorMaxComps], y[gfxColorMaxComps]; + int i; + + if (pixelIdx >= width * height) { + return gFalse; + } + imgStr->getPixel(pixBuf); + colorMap->getColor(pixBuf, &color); + for (i = 0; + i < ((GfxDeviceNColorSpace *)colorMap->getColorSpace())->getNComps(); + ++i) { + x[i] = colToDbl(color.c[i]); + } + func->transform(x, y); + for (i = 0; i < bufSize; ++i) { + buf[i] = (int)(y[i] * 255 + 0.5); + } + bufIdx = 0; + ++pixelIdx; + return gTrue; +} + +//------------------------------------------------------------------------ +// PSOutputDev +//------------------------------------------------------------------------ + +extern "C" { +typedef void (*SignalFunc)(int); +} + +static void outputToFile(void *stream, const char *data, int len) { + fwrite(data, 1, len, (FILE *)stream); +} + +PSOutputDev::PSOutputDev(const char *fileName, PDFDoc *doc, + char *psTitleA, + const std::vector<int> &pages, PSOutMode modeA, + int paperWidthA, int paperHeightA, + GBool noCropA, GBool duplexA, + int imgLLXA, int imgLLYA, int imgURXA, int imgURYA, + GBool forceRasterizeA, + GBool manualCtrlA, + PSOutCustomCodeCbk customCodeCbkA, + void *customCodeCbkDataA) { + FILE *f; + PSFileType fileTypeA; + + underlayCbk = NULL; + underlayCbkData = NULL; + overlayCbk = NULL; + overlayCbkData = NULL; + customCodeCbk = customCodeCbkA; + customCodeCbkData = customCodeCbkDataA; + + fontIDs = NULL; + fontNames = new GooHash(gTrue); + t1FontNames = NULL; + font8Info = NULL; + font16Enc = NULL; + imgIDs = NULL; + formIDs = NULL; + paperSizes = NULL; + embFontList = NULL; + customColors = NULL; + haveTextClip = gFalse; + t3String = NULL; + forceRasterize = forceRasterizeA; + psTitle = NULL; + + // open file or pipe + if (!strcmp(fileName, "-")) { + fileTypeA = psStdout; + f = stdout; + } else if (fileName[0] == '|') { + fileTypeA = psPipe; +#ifdef HAVE_POPEN +#ifndef _WIN32 + signal(SIGPIPE, (SignalFunc)SIG_IGN); +#endif + if (!(f = popen(fileName + 1, "w"))) { + error(errIO, -1, "Couldn't run print command '{0:s}'", fileName); + ok = gFalse; + return; + } +#else + error(errIO, -1, "Print commands are not supported ('{0:s}')", fileName); + ok = gFalse; + return; +#endif + } else { + fileTypeA = psFile; + if (!(f = fopen(fileName, "w"))) { + error(errIO, -1, "Couldn't open PostScript file '{0:s}'", fileName); + ok = gFalse; + return; + } + } + + init(outputToFile, f, fileTypeA, psTitleA, + doc, pages, modeA, + imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA, + paperWidthA, paperHeightA, noCropA, duplexA); +} + +PSOutputDev::PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA, + char *psTitleA, + PDFDoc *doc, + const std::vector<int> &pages, PSOutMode modeA, + int paperWidthA, int paperHeightA, + GBool noCropA, GBool duplexA, + int imgLLXA, int imgLLYA, int imgURXA, int imgURYA, + GBool forceRasterizeA, + GBool manualCtrlA, + PSOutCustomCodeCbk customCodeCbkA, + void *customCodeCbkDataA) { + underlayCbk = NULL; + underlayCbkData = NULL; + overlayCbk = NULL; + overlayCbkData = NULL; + customCodeCbk = customCodeCbkA; + customCodeCbkData = customCodeCbkDataA; + + fontIDs = NULL; + fontNames = new GooHash(gTrue); + t1FontNames = NULL; + font8Info = NULL; + font16Enc = NULL; + imgIDs = NULL; + formIDs = NULL; + paperSizes = NULL; + embFontList = NULL; + customColors = NULL; + haveTextClip = gFalse; + t3String = NULL; + forceRasterize = forceRasterizeA; + psTitle = NULL; + + init(outputFuncA, outputStreamA, psGeneric, psTitleA, + doc, pages, modeA, + imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA, + paperWidthA, paperHeightA, noCropA, duplexA); +} + +struct StandardMedia { + const char *name; + int width; + int height; +}; + +static const StandardMedia standardMedia[] = +{ + { "A0", 2384, 3371 }, + { "A1", 1685, 2384 }, + { "A2", 1190, 1684 }, + { "A3", 842, 1190 }, + { "A4", 595, 842 }, + { "A5", 420, 595 }, + { "B4", 729, 1032 }, + { "B5", 516, 729 }, + { "Letter", 612, 792 }, + { "Tabloid", 792, 1224 }, + { "Ledger", 1224, 792 }, + { "Legal", 612, 1008 }, + { "Statement", 396, 612 }, + { "Executive", 540, 720 }, + { "Folio", 612, 936 }, + { "Quarto", 610, 780 }, + { "10x14", 720, 1008 }, + { NULL, 0, 0 } +}; + +/* PLRM specifies a tolerance of 5 points when matching page sizes */ +static bool pageDimensionEqual(int a, int b) { + return (abs (a - b) < 5); +} + +// Shared initialization of PSOutputDev members. +// Store the values but do not process them so the function that +// created the PSOutputDev can use the various setters to change defaults. + +void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA, + PSFileType fileTypeA, char *psTitleA, PDFDoc *docA, + const std::vector<int> &pagesA, PSOutMode modeA, + int imgLLXA, int imgLLYA, int imgURXA, int imgURYA, + GBool manualCtrlA, int paperWidthA, int paperHeightA, + GBool noCropA, GBool duplexA) { + + if (pagesA.empty()) { + ok = gFalse; + return; + } + + // initialize + postInitDone = gFalse; + embedType1 = gTrue; + embedTrueType = gTrue; + embedCIDPostScript = gTrue; + embedCIDTrueType = gTrue; + fontPassthrough = gFalse; + optimizeColorSpace = gFalse; + preloadImagesForms = gFalse; + generateOPI = gFalse; + useASCIIHex = gFalse; + useBinary = gFalse; + rasterMono = gFalse; + rasterResolution = 300; + uncompressPreloadedImages = gFalse; + rasterAntialias = gFalse; + displayText = gTrue; + ok = gTrue; + outputFunc = outputFuncA; + outputStream = outputStreamA; + fileType = fileTypeA; + psTitle = (psTitleA? strdup(psTitleA): NULL); + doc = docA; + level = globalParams->getPSLevel(); + pages = pagesA; + mode = modeA; + paperWidth = paperWidthA; + paperHeight = paperHeightA; + noCrop = noCropA; + duplex = duplexA; + imgLLX = imgLLXA; + imgLLY = imgLLYA; + imgURX = imgURXA; + imgURY = imgURYA; + manualCtrl = manualCtrlA; + + xref = NULL; + + processColors = 0; + inType3Char = gFalse; + inUncoloredPattern = gFalse; + t3FillColorOnly = gFalse; + +#if OPI_SUPPORT + // initialize OPI nesting levels + opi13Nest = 0; + opi20Nest = 0; +#endif + + tx0 = ty0 = -1; + xScale0 = yScale0 = 0; + rotate0 = -1; + clipLLX0 = clipLLY0 = 0; + clipURX0 = clipURY0 = -1; + + // initialize sequential page number + seqPage = 1; +} + +// Complete the initialization after the function that created the PSOutputDev +// has had a chance to modify default values with the various setters. + +void PSOutputDev::postInit() +{ + Catalog *catalog; + PDFRectangle *box; + PSOutPaperSize *size; + GooList *names; + int w, h, i; + + if (postInitDone || !ok) { + return; + } + + postInitDone = gTrue; + + xref = doc->getXRef(); + catalog = doc->getCatalog(); + + if (paperWidth < 0 || paperHeight < 0) { + paperMatch = gTrue; + } else { + paperMatch = gFalse; + } + Page *page; + paperSizes = new GooList(); + for (size_t pgi = 0; pgi < pages.size(); ++pgi) { + const int pg = pages[pgi]; + page = catalog->getPage(pg); + if (page == NULL) + paperMatch = gFalse; + if (!paperMatch) { + w = paperWidth; + h = paperHeight; + if (w < 0 || h < 0) { + // Unable to obtain a paper size from the document and no page size + // specified. In this case use A4 as the page size to ensure the PS output is + // valid. This will only occur if the PDF is very broken. + w = 595; + h = 842; + } + } else if (noCrop) { + w = (int)ceil(page->getMediaWidth()); + h = (int)ceil(page->getMediaHeight()); + } else { + w = (int)ceil(page->getCropWidth()); + h = (int)ceil(page->getCropHeight()); + } + if (paperMatch) { + int rotate = page->getRotate(); + if (rotate == 90 || rotate == 270) + std::swap(w, h); + } + if (w > paperWidth) + paperWidth = w; + if (h > paperHeight) + paperHeight = h; + for (i = 0; i < paperSizes->getLength(); ++i) { + size = (PSOutPaperSize *)paperSizes->get(i); + if (pageDimensionEqual(w, size->w) && pageDimensionEqual(h, size->h)) + break; + } + if (i == paperSizes->getLength()) { + const StandardMedia *media = standardMedia; + GooString *name = NULL; + while (media->name) { + if (pageDimensionEqual(w, media->width) && pageDimensionEqual(h, media->height)) { + name = new GooString(media->name); + w = media->width; + h = media->height; + break; + } + media++; + } + if (!name) + name = GooString::format("{0:d}x{1:d}mm", int(w*25.4/72), int(h*25.4/72)); + paperSizes->append(new PSOutPaperSize(name, w, h)); + } + pagePaperSize.insert(std::pair<int,int>(pg, i)); + if (!paperMatch) + break; // we only need one entry when all pages are the same size + } + if (imgLLX == 0 && imgURX == 0 && imgLLY == 0 && imgURY == 0) { + imgLLX = imgLLY = 0; + imgURX = paperWidth; + imgURY = paperHeight; + } + std::vector<int> pageList; + if (mode == psModeForm) { + pageList.push_back(pages[0]); + } else { + pageList = pages; + } + + // initialize fontIDs, fontFileIDs, and fontFileNames lists + fontIDSize = 64; + fontIDLen = 0; + fontIDs = (Ref *)gmallocn(fontIDSize, sizeof(Ref)); + for (i = 0; i < 14; ++i) { + fontNames->add(new GooString(psBase14SubstFonts[i].psName), 1); + } + names = globalParams->getPSResidentFonts(); + for (i = 0; i < names->getLength(); ++i) { + fontNames->add((GooString *)names->get(i), 1); + } + delete names; + t1FontNameSize = 64; + t1FontNameLen = 0; + t1FontNames = (PST1FontName *)gmallocn(t1FontNameSize, sizeof(PST1FontName)); + font8InfoLen = 0; + font8InfoSize = 0; + font16EncLen = 0; + font16EncSize = 0; + imgIDLen = 0; + imgIDSize = 0; + formIDLen = 0; + formIDSize = 0; + + numSaves = 0; + numTilingPatterns = 0; + nextFunc = 0; + + // initialize embedded font resource comment list + embFontList = new GooString(); + + if (!manualCtrl) { + Page *page; + // this check is needed in case the document has zero pages + if ((page = doc->getPage(pageList[0]))) { + writeHeader(pageList, + page->getMediaBox(), + page->getCropBox(), + page->getRotate(), + psTitle); + } else { + error(errSyntaxError, -1, "Invalid page {0:d}", pageList[0]); + box = new PDFRectangle(0, 0, 1, 1); + writeHeader(pageList, box, box, 0, psTitle); + delete box; + } + if (mode != psModeForm) { + writePS("%%BeginProlog\n"); + } + writeXpdfProcset(); + if (mode != psModeForm) { + writePS("%%EndProlog\n"); + writePS("%%BeginSetup\n"); + } + writeDocSetup(doc, catalog, pageList, duplex); + if (mode != psModeForm) { + writePS("%%EndSetup\n"); + } + } +} + +PSOutputDev::~PSOutputDev() { + PSOutCustomColor *cc; + int i; + + if (ok) { + if (!postInitDone) { + postInit(); + } + if (!manualCtrl) { + writePS("%%Trailer\n"); + writeTrailer(); + if (mode != psModeForm) { + writePS("%%EOF\n"); + } + } + if (fileType == psFile) { +#ifdef MACOS + ICS_MapRefNumAndAssign((short)((FILE *)outputStream)->handle); +#endif + fclose((FILE *)outputStream); + } +#ifdef HAVE_POPEN + else if (fileType == psPipe) { + pclose((FILE *)outputStream); +#ifndef _WIN32 + signal(SIGPIPE, (SignalFunc)SIG_DFL); +#endif + } +#endif + } + if (paperSizes) { + deleteGooList(paperSizes, PSOutPaperSize); + } + if (embFontList) { + delete embFontList; + } + if (fontIDs) { + gfree(fontIDs); + } + delete fontNames; + if (t1FontNames) { + for (i = 0; i < t1FontNameLen; ++i) { + delete t1FontNames[i].psName; + } + gfree(t1FontNames); + } + if (font8Info) { + for (i = 0; i < font8InfoLen; ++i) { + gfree(font8Info[i].codeToGID); + } + gfree(font8Info); + } + if (font16Enc) { + for (i = 0; i < font16EncLen; ++i) { + if (font16Enc[i].enc) { + delete font16Enc[i].enc; + } + } + gfree(font16Enc); + } + gfree(imgIDs); + gfree(formIDs); + while (customColors) { + cc = customColors; + customColors = cc->next; + delete cc; + } + gfree(psTitle); +} + +void PSOutputDev::writeHeader(const std::vector<int> &pages, + PDFRectangle *mediaBox, PDFRectangle *cropBox, + int pageRotate, char *psTitle) { + Object info, obj1; + PSOutPaperSize *size; + double x1, y1, x2, y2; + int i; + + switch (mode) { + case psModePS: + writePS("%!PS-Adobe-3.0\n"); + break; + case psModeEPS: + writePS("%!PS-Adobe-3.0 EPSF-3.0\n"); + break; + case psModeForm: + writePS("%!PS-Adobe-3.0 Resource-Form\n"); + break; + } + writePSFmt("%Produced by poppler pdftops version: {0:s} (http://poppler.freedesktop.org)\n", PACKAGE_VERSION); + xref->getDocInfo(&info); + if (info.isDict() && info.dictLookup("Creator", &obj1)->isString()) { + writePS("%%Creator: "); + writePSTextLine(obj1.getString()); + } + obj1.free(); + info.free(); + if(psTitle) { + char *sanitizedTitle = strdup(psTitle); + for (Guint i = 0; i < strlen(sanitizedTitle); ++i) { + if (sanitizedTitle[i] == '\n' || sanitizedTitle[i] == '\r') { + sanitizedTitle[i] = ' '; + } + } + writePSFmt("%%Title: {0:s}\n", sanitizedTitle); + free(sanitizedTitle); + } + writePSFmt("%%LanguageLevel: {0:d}\n", + (level == psLevel1 || level == psLevel1Sep) ? 1 : + (level == psLevel2 || level == psLevel2Sep) ? 2 : 3); + if (level == psLevel1Sep || level == psLevel2Sep || level == psLevel3Sep) { + writePS("%%DocumentProcessColors: (atend)\n"); + writePS("%%DocumentCustomColors: (atend)\n"); + } + writePS("%%DocumentSuppliedResources: (atend)\n"); + if ((level == psLevel1 || level == psLevel1Sep) && useBinary) { + writePS("%%DocumentData: Binary\n"); + } + + switch (mode) { + case psModePS: + for (i = 0; i < paperSizes->getLength(); ++i) { + size = (PSOutPaperSize *)paperSizes->get(i); + writePSFmt("%%{0:s} {1:t} {2:d} {3:d} 0 () ()\n", + i==0 ? "DocumentMedia:" : "+", size->name, size->w, size->h); + } + writePSFmt("%%BoundingBox: 0 0 {0:d} {1:d}\n", paperWidth, paperHeight); + writePSFmt("%%Pages: {0:d}\n", static_cast<int>(pages.size())); + writePS("%%EndComments\n"); + if (!paperMatch) { + size = (PSOutPaperSize *)paperSizes->get(0); + writePS("%%BeginDefaults\n"); + writePSFmt("%%PageMedia: {0:t}\n", size->name); + writePS("%%EndDefaults\n"); + } + break; + case psModeEPS: + epsX1 = cropBox->x1; + epsY1 = cropBox->y1; + epsX2 = cropBox->x2; + epsY2 = cropBox->y2; + if (pageRotate == 0 || pageRotate == 180) { + x1 = epsX1; + y1 = epsY1; + x2 = epsX2; + y2 = epsY2; + } else { // pageRotate == 90 || pageRotate == 270 + x1 = 0; + y1 = 0; + x2 = epsY2 - epsY1; + y2 = epsX2 - epsX1; + } + writePSFmt("%%BoundingBox: {0:d} {1:d} {2:d} {3:d}\n", + (int)floor(x1), (int)floor(y1), (int)ceil(x2), (int)ceil(y2)); + writePSFmt("%%HiResBoundingBox: {0:.6g} {1:.6g} {2:.6g} {3:.6g}\n", + x1, y1, x2, y2); + writePS("%%DocumentSuppliedResources: (atend)\n"); + writePS("%%EndComments\n"); + break; + case psModeForm: + writePS("%%EndComments\n"); + writePS("32 dict dup begin\n"); + writePSFmt("/BBox [{0:d} {1:d} {2:d} {3:d}] def\n", + (int)floor(mediaBox->x1), (int)floor(mediaBox->y1), + (int)ceil(mediaBox->x2), (int)ceil(mediaBox->y2)); + writePS("/FormType 1 def\n"); + writePS("/Matrix [1 0 0 1 0 0] def\n"); + break; + } +} + +void PSOutputDev::writeXpdfProcset() { + GBool lev1, lev2, lev3, sep, nonSep; + const char **p; + const char *q; + + writePSFmt("%%BeginResource: procset xpdf {0:s} 0\n", "3.00"); + writePSFmt("%%Copyright: {0:s}\n", xpdfCopyright); + lev1 = lev2 = lev3 = sep = nonSep = gTrue; + for (p = prolog; *p; ++p) { + if ((*p)[0] == '~') { + lev1 = lev2 = lev3 = sep = nonSep = gFalse; + for (q = *p + 1; *q; ++q) { + switch (*q) { + case '1': lev1 = gTrue; break; + case '2': lev2 = gTrue; break; + case '3': lev3 = gTrue; break; + case 's': sep = gTrue; break; + case 'n': nonSep = gTrue; break; + } + } + } else if ((level == psLevel1 && lev1 && nonSep) || + (level == psLevel1Sep && lev1 && sep) || + (level == psLevel2 && lev2 && nonSep) || + (level == psLevel2Sep && lev2 && sep) || + (level == psLevel3 && lev3 && nonSep) || + (level == psLevel3Sep && lev3 && sep)) { + writePSFmt("{0:s}\n", *p); + } + } + writePS("%%EndResource\n"); + + if (level >= psLevel3) { + for (p = cmapProlog; *p; ++p) { + writePSFmt("{0:s}\n", *p); + } + } +} + +void PSOutputDev::writeDocSetup(PDFDoc *doc, Catalog *catalog, + const std::vector<int> &pages, + GBool duplexA) { + Page *page; + Dict *resDict; + Annots *annots; + Object *acroForm; + Object obj1, obj2, obj3; + GooString *s; + int i; + + if (mode == psModeForm) { + // swap the form and xpdf dicts + writePS("xpdf end begin dup begin\n"); + } else { + writePS("xpdf begin\n"); + } + for (size_t pgi = 0; pgi < pages.size(); ++pgi) { + const int pg = pages[pgi]; + page = doc->getPage(pg); + if (!page) { + error(errSyntaxError, -1, "Failed writing resources for page {0:d}", pg); + continue; + } + if ((resDict = page->getResourceDict())) { + setupResources(resDict); + } + annots = page->getAnnots(); + for (i = 0; i < annots->getNumAnnots(); ++i) { + if (annots->getAnnot(i)->getAppearanceResDict(&obj1)->isDict()) { + setupResources(obj1.getDict()); + } + obj1.free(); + } + } + if ((acroForm = catalog->getAcroForm()) && acroForm->isDict()) { + if (acroForm->dictLookup("DR", &obj1)->isDict()) { + setupResources(obj1.getDict()); + } + obj1.free(); + if (acroForm->dictLookup("Fields", &obj1)->isArray()) { + for (i = 0; i < obj1.arrayGetLength(); ++i) { + if (obj1.arrayGet(i, &obj2)->isDict()) { + if (obj2.dictLookup("DR", &obj3)->isDict()) { + setupResources(obj3.getDict()); + } + obj3.free(); + } + obj2.free(); + } + } + obj1.free(); + } + if (mode != psModeForm) { + if (mode != psModeEPS && !manualCtrl) { + writePSFmt("{0:s} pdfSetup\n", + duplexA ? "true" : "false"); + if (!paperMatch) { + writePSFmt("{0:d} {1:d} pdfSetupPaper\n", paperWidth, paperHeight); + } + } +#if OPI_SUPPORT + if (generateOPI) { + writePS("/opiMatrix matrix currentmatrix def\n"); + } +#endif + } + if (customCodeCbk) { + if ((s = (*customCodeCbk)(this, psOutCustomDocSetup, 0, + customCodeCbkData))) { + writePS(s->getCString()); + delete s; + } + } +} + +void PSOutputDev::writePageTrailer() { + if (mode != psModeForm) { + writePS("pdfEndPage\n"); + } +} + +void PSOutputDev::writeTrailer() { + PSOutCustomColor *cc; + + if (mode == psModeForm) { + writePS("/Foo exch /Form defineresource pop\n"); + } else { + writePS("end\n"); + writePS("%%DocumentSuppliedResources:\n"); + writePS(embFontList->getCString()); + if (level == psLevel1Sep || level == psLevel2Sep || + level == psLevel3Sep) { + writePS("%%DocumentProcessColors:"); + if (processColors & psProcessCyan) { + writePS(" Cyan"); + } + if (processColors & psProcessMagenta) { + writePS(" Magenta"); + } + if (processColors & psProcessYellow) { + writePS(" Yellow"); + } + if (processColors & psProcessBlack) { + writePS(" Black"); + } + writePS("\n"); + writePS("%%DocumentCustomColors:"); + for (cc = customColors; cc; cc = cc->next) { + writePS(" "); + writePSString(cc->name); + } + writePS("\n"); + writePS("%%CMYKCustomColor:\n"); + for (cc = customColors; cc; cc = cc->next) { + writePSFmt("%%+ {0:.4g} {1:.4g} {2:.4g} {3:.4g} ", + cc->c, cc->m, cc->y, cc->k); + writePSString(cc->name); + writePS("\n"); + } + } + } +} + +void PSOutputDev::setupResources(Dict *resDict) { + Object xObjDict, xObjRef, xObj, patDict, patRef, pat, resObj; + Ref ref0; + GBool skip; + int i; + + setupFonts(resDict); + setupImages(resDict); + setupForms(resDict); + + //----- recursively scan XObjects + resDict->lookup("XObject", &xObjDict); + if (xObjDict.isDict()) { + for (i = 0; i < xObjDict.dictGetLength(); ++i) { + + // avoid infinite recursion on XObjects + skip = gFalse; + if ((xObjDict.dictGetValNF(i, &xObjRef)->isRef())) { + ref0 = xObjRef.getRef(); + if (resourceIDs.find(ref0.num) != resourceIDs.end()) { + skip = gTrue; + } else { + resourceIDs.insert(ref0.num); + } + } + if (!skip) { + + // process the XObject's resource dictionary + xObjDict.dictGetVal(i, &xObj); + if (xObj.isStream()) { + xObj.streamGetDict()->lookup("Resources", &resObj); + if (resObj.isDict()) { + setupResources(resObj.getDict()); + } + resObj.free(); + } + xObj.free(); + } + + xObjRef.free(); + } + } + xObjDict.free(); + + //----- recursively scan Patterns + resDict->lookup("Pattern", &patDict); + if (patDict.isDict()) { + inType3Char = gTrue; + for (i = 0; i < patDict.dictGetLength(); ++i) { + + // avoid infinite recursion on Patterns + skip = gFalse; + if ((patDict.dictGetValNF(i, &patRef)->isRef())) { + ref0 = patRef.getRef(); + if (resourceIDs.find(ref0.num) != resourceIDs.end()) { + skip = gTrue; + } else { + resourceIDs.insert(ref0.num); + } + } + if (!skip) { + + // process the Pattern's resource dictionary + patDict.dictGetVal(i, &pat); + if (pat.isStream()) { + pat.streamGetDict()->lookup("Resources", &resObj); + if (resObj.isDict()) { + setupResources(resObj.getDict()); + } + resObj.free(); + } + pat.free(); + } + + patRef.free(); + } + inType3Char = gFalse; + } + patDict.free(); +} + +void PSOutputDev::setupFonts(Dict *resDict) { + Object obj1, obj2; + Ref r; + GfxFontDict *gfxFontDict; + GfxFont *font; + int i; + + gfxFontDict = NULL; + resDict->lookupNF("Font", &obj1); + if (obj1.isRef()) { + obj1.fetch(xref, &obj2); + if (obj2.isDict()) { + r = obj1.getRef(); + gfxFontDict = new GfxFontDict(xref, &r, obj2.getDict()); + } + obj2.free(); + } else if (obj1.isDict()) { + gfxFontDict = new GfxFontDict(xref, NULL, obj1.getDict()); + } + if (gfxFontDict) { + for (i = 0; i < gfxFontDict->getNumFonts(); ++i) { + if ((font = gfxFontDict->getFont(i))) { + setupFont(font, resDict); + } + } + delete gfxFontDict; + } + obj1.free(); +} + +void PSOutputDev::setupFont(GfxFont *font, Dict *parentResDict) { + GfxFontLoc *fontLoc; + GooString *psName; + char buf[16]; + GBool subst; + UnicodeMap *uMap; + const char *charName; + double xs, ys; + int code; + double w1, w2; + int i, j; + + // check if font is already set up + for (i = 0; i < fontIDLen; ++i) { + if (fontIDs[i].num == font->getID()->num && + fontIDs[i].gen == font->getID()->gen) { + return; + } + } + + // add entry to fontIDs list + if (fontIDLen >= fontIDSize) { + fontIDSize += 64; + fontIDs = (Ref *)greallocn(fontIDs, fontIDSize, sizeof(Ref)); + } + fontIDs[fontIDLen++] = *font->getID(); + + psName = NULL; + xs = ys = 1; + subst = gFalse; + + if (font->getType() == fontType3) { + psName = GooString::format("T3_{0:d}_{1:d}", + font->getID()->num, font->getID()->gen); + setupType3Font(font, psName, parentResDict); + } else { + fontLoc = font->locateFont(xref, this); + if (fontLoc != NULL) { + switch (fontLoc->locType) { + case gfxFontLocEmbedded: + switch (fontLoc->fontType) { + case fontType1: + // this assumes that the PS font name matches the PDF font name + psName = font->getEmbeddedFontName() ? font->getEmbeddedFontName()->copy() : new GooString(); + setupEmbeddedType1Font(&fontLoc->embFontID, psName); + break; + case fontType1C: + psName = makePSFontName(font, &fontLoc->embFontID); + setupEmbeddedType1CFont(font, &fontLoc->embFontID, psName); + break; + case fontType1COT: + psName = makePSFontName(font, &fontLoc->embFontID); + setupEmbeddedOpenTypeT1CFont(font, &fontLoc->embFontID, psName); + break; + case fontTrueType: + case fontTrueTypeOT: + psName = makePSFontName(font, font->getID()); + setupEmbeddedTrueTypeFont(font, &fontLoc->embFontID, psName); + break; + case fontCIDType0C: + psName = makePSFontName(font, &fontLoc->embFontID); + setupEmbeddedCIDType0Font(font, &fontLoc->embFontID, psName); + break; + case fontCIDType2: + case fontCIDType2OT: + psName = makePSFontName(font, font->getID()); + //~ should check to see if font actually uses vertical mode + setupEmbeddedCIDTrueTypeFont(font, &fontLoc->embFontID, psName, gTrue); + break; + case fontCIDType0COT: + psName = makePSFontName(font, &fontLoc->embFontID); + setupEmbeddedOpenTypeCFFFont(font, &fontLoc->embFontID, psName); + break; + default: + break; + } + break; + case gfxFontLocExternal: + //~ add cases for external 16-bit fonts + switch (fontLoc->fontType) { + case fontType1: + if (font->getEmbeddedFontName()) { + // this assumes that the PS font name matches the PDF font name + psName = font->getEmbeddedFontName()->copy(); + } else { + //~ this won't work -- the PS font name won't match + psName = makePSFontName(font, font->getID()); + } + setupExternalType1Font(fontLoc->path, psName); + break; + case fontTrueType: + case fontTrueTypeOT: + psName = makePSFontName(font, font->getID()); + setupExternalTrueTypeFont(font, fontLoc->path, psName); + break; + case fontCIDType2: + case fontCIDType2OT: + psName = makePSFontName(font, font->getID()); + //~ should check to see if font actually uses vertical mode + setupExternalCIDTrueTypeFont(font, fontLoc->path, psName, gTrue); + break; + default: + break; + } + break; + case gfxFontLocResident: + psName = fontLoc->path->copy(); + break; + } + } + + if (!psName) { + if (font->isCIDFont()) { + error(errSyntaxError, -1, + "Couldn't find a font to substitute for '{0:s}' ('{1:s}' character collection)", + font->getName() ? font->getName()->getCString() + : "(unnamed)", + ((GfxCIDFont *)font)->getCollection() + ? ((GfxCIDFont *)font)->getCollection()->getCString() + : "(unknown)"); + if (font16EncLen >= font16EncSize) { + font16EncSize += 16; + font16Enc = (PSFont16Enc *)greallocn(font16Enc, + font16EncSize, + sizeof(PSFont16Enc)); + } + font16Enc[font16EncLen].fontID = *font->getID(); + font16Enc[font16EncLen].enc = NULL; + ++font16EncLen; + } else { + error(errSyntaxError, -1, + "Couldn't find a font to substitute for '{0:s}'", + font->getName() ? font->getName()->getCString() + : "(unnamed)"); + } + delete fontLoc; + return; + } + + // scale substituted 8-bit fonts + if (fontLoc->locType == gfxFontLocResident && + fontLoc->substIdx >= 0) { + subst = gTrue; + for (code = 0; code < 256; ++code) { + if ((charName = ((Gfx8BitFont *)font)->getCharName(code)) && + charName[0] == 'm' && charName[1] == '\0') { + break; + } + } + if (code < 256) { + w1 = ((Gfx8BitFont *)font)->getWidth(code); + } else { + w1 = 0; + } + w2 = psBase14SubstFonts[fontLoc->substIdx].mWidth; + xs = w1 / w2; + if (xs < 0.1) { + xs = 1; + } + } + + // handle encodings for substituted CID fonts + if (fontLoc->locType == gfxFontLocResident && + fontLoc->fontType >= fontCIDType0) { + subst = gTrue; + if (font16EncLen >= font16EncSize) { + font16EncSize += 16; + font16Enc = (PSFont16Enc *)greallocn(font16Enc, + font16EncSize, + sizeof(PSFont16Enc)); + } + font16Enc[font16EncLen].fontID = *font->getID(); + if ((uMap = globalParams->getUnicodeMap(fontLoc->encoding))) { + font16Enc[font16EncLen].enc = fontLoc->encoding->copy(); + uMap->decRefCnt(); + } else { + error(errSyntaxError, -1, + "Couldn't find Unicode map for 16-bit font encoding '{0:t}'", + fontLoc->encoding); + font16Enc[font16EncLen].enc = NULL; + } + ++font16EncLen; + } + + delete fontLoc; + } + + // generate PostScript code to set up the font + if (font->isCIDFont()) { + if (level == psLevel3 || level == psLevel3Sep) { + writePSFmt("/F{0:d}_{1:d} /{2:t} {3:d} pdfMakeFont16L3\n", + font->getID()->num, font->getID()->gen, psName, + font->getWMode()); + } else { + writePSFmt("/F{0:d}_{1:d} /{2:t} {3:d} pdfMakeFont16\n", + font->getID()->num, font->getID()->gen, psName, + font->getWMode()); + } + } else { + writePSFmt("/F{0:d}_{1:d} /{2:t} {3:.6g} {4:.6g}\n", + font->getID()->num, font->getID()->gen, psName, xs, ys); + for (i = 0; i < 256; i += 8) { + writePS((char *)((i == 0) ? "[ " : " ")); + for (j = 0; j < 8; ++j) { + if (font->getType() == fontTrueType && + !subst && + !((Gfx8BitFont *)font)->getHasEncoding()) { + sprintf(buf, "c%02x", i+j); + charName = buf; + } else { + charName = ((Gfx8BitFont *)font)->getCharName(i+j); + } + writePS("/"); + writePSName(charName ? charName : (char *)".notdef"); + // the empty name is legal in PDF and PostScript, but PostScript + // uses a double-slash (//...) for "immediately evaluated names", + // so we need to add a space character here + if (charName && !charName[0]) { + writePS(" "); + } + } + writePS((i == 256-8) ? (char *)"]\n" : (char *)"\n"); + } + writePS("pdfMakeFont\n"); + } + + delete psName; +} + +void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) { + static const char hexChar[17] = "0123456789abcdef"; + Object refObj, strObj, obj1, obj2, obj3; + Dict *dict; + int length1, length2, length3; + int c; + int start[4]; + GBool binMode; + GBool writePadding = gTrue; + int i; + + // check if font is already embedded + if (fontNames->lookupInt(psName)) { + return; + } + fontNames->add(psName->copy(), 1); + + // get the font stream and info + refObj.initRef(id->num, id->gen); + refObj.fetch(xref, &strObj); + refObj.free(); + if (!strObj.isStream()) { + error(errSyntaxError, -1, "Embedded font file object is not a stream"); + goto err1; + } + if (!(dict = strObj.streamGetDict())) { + error(errSyntaxError, -1, + "Embedded font stream is missing its dictionary"); + goto err1; + } + dict->lookup("Length1", &obj1); + dict->lookup("Length2", &obj2); + dict->lookup("Length3", &obj3); + if (!obj1.isInt() || !obj2.isInt() || !obj3.isInt()) { + error(errSyntaxError, -1, + "Missing length fields in embedded font stream dictionary"); + obj1.free(); + obj2.free(); + obj3.free(); + goto err1; + } + length1 = obj1.getInt(); + length2 = obj2.getInt(); + length3 = obj3.getInt(); + obj1.free(); + obj2.free(); + obj3.free(); + + // beginning comment + writePSFmt("%%BeginResource: font {0:t}\n", psName); + embFontList->append("%%+ font "); + embFontList->append(psName->getCString()); + embFontList->append("\n"); + + // copy ASCII portion of font + strObj.streamReset(); + for (i = 0; i < length1 && (c = strObj.streamGetChar()) != EOF; ++i) { + writePSChar(c); + } + + // figure out if encrypted portion is binary or ASCII + binMode = gFalse; + for (i = 0; i < 4; ++i) { + start[i] = strObj.streamGetChar(); + if (start[i] == EOF) { + error(errSyntaxError, -1, + "Unexpected end of file in embedded font stream"); + goto err1; + } + if (!((start[i] >= '0' && start[i] <= '9') || + (start[i] >= 'A' && start[i] <= 'F') || + (start[i] >= 'a' && start[i] <= 'f'))) + binMode = gTrue; + } + + if (length2 == 0) + { + // length2 == 0 is an error + // trying to solve it by just piping all + // the stream data + error(errSyntaxWarning, -1, "Font has length2 as 0, trying to overcome the problem reading the stream until the end"); + length2 = INT_MAX; + writePadding = gFalse; + } + + + // convert binary data to ASCII + if (binMode) { + for (i = 0; i < 4; ++i) { + writePSChar(hexChar[(start[i] >> 4) & 0x0f]); + writePSChar(hexChar[start[i] & 0x0f]); + } +#if 0 // this causes trouble for various PostScript printers + // if Length2 is incorrect (too small), font data gets chopped, so + // we take a few extra characters from the trailer just in case + length2 += length3 >= 8 ? 8 : length3; +#endif + while (i < length2) { + if ((c = strObj.streamGetChar()) == EOF) { + break; + } + writePSChar(hexChar[(c >> 4) & 0x0f]); + writePSChar(hexChar[c & 0x0f]); + if (++i % 32 == 0) { + writePSChar('\n'); + } + } + if (i % 32 > 0) { + writePSChar('\n'); + } + + // already in ASCII format -- just copy it + } else { + for (i = 0; i < 4; ++i) { + writePSChar(start[i]); + } + for (i = 4; i < length2; ++i) { + if ((c = strObj.streamGetChar()) == EOF) { + break; + } + writePSChar(c); + } + } + + if (writePadding) + { + if (length3 > 0) { + // write fixed-content portion + while ((c = strObj.streamGetChar()) != EOF) { + writePSChar(c); + } + } else { + // write padding and "cleartomark" + for (i = 0; i < 8; ++i) { + writePS("00000000000000000000000000000000" + "00000000000000000000000000000000\n"); + } + writePS("cleartomark\n"); + } + } + + // ending comment + writePS("%%EndResource\n"); + + err1: + if (strObj.isStream()) + strObj.streamClose(); + strObj.free(); +} + +void PSOutputDev::setupExternalType1Font(GooString *fileName, GooString *psName) { + static const char hexChar[17] = "0123456789abcdef"; + FILE *fontFile; + int c; + + if (fontNames->lookupInt(psName)) { + return; + } + fontNames->add(psName->copy(), 1); + + // beginning comment + writePSFmt("%%BeginResource: font {0:t}\n", psName); + embFontList->append("%%+ font "); + embFontList->append(psName->getCString()); + embFontList->append("\n"); + + // copy the font file + if (!(fontFile = fopen(fileName->getCString(), "rb"))) { + error(errIO, -1, "Couldn't open external font file"); + return; + } + + c = fgetc(fontFile); + if (c == 0x80) { + // PFB file + ungetc(c, fontFile); + while (!feof(fontFile)) { + fgetc(fontFile); // skip start of segment byte (0x80) + int segType = fgetc(fontFile); + long segLen = fgetc(fontFile) | + (fgetc(fontFile) << 8) | + (fgetc(fontFile) << 16) | + (fgetc(fontFile) << 24); + if (feof(fontFile)) + break; + + if (segType == 1) { + // ASCII segment + for (long i = 0; i < segLen; i++) { + c = fgetc(fontFile); + if (c == EOF) + break; + writePSChar(c); + } + } else if (segType == 2) { + // binary segment + for (long i = 0; i < segLen; i++) { + c = fgetc(fontFile); + if (c == EOF) + break; + writePSChar(hexChar[(c >> 4) & 0x0f]); + writePSChar(hexChar[c & 0x0f]); + if (i % 36 == 35) + writePSChar('\n'); + } + } else { + // end of file + break; + } + } + } else if (c != EOF) { + writePSChar(c); + while ((c = fgetc(fontFile)) != EOF) + writePSChar(c); + } + fclose(fontFile); + + // ending comment + writePS("%%EndResource\n"); +} + +void PSOutputDev::setupEmbeddedType1CFont(GfxFont *font, Ref *id, + GooString *psName) { + char *fontBuf; + int fontLen; + FoFiType1C *ffT1C; + int i; + + // check if font is already embedded + for (i = 0; i < t1FontNameLen; ++i) { + if (t1FontNames[i].fontFileID.num == id->num && + t1FontNames[i].fontFileID.gen == id->gen) { + psName->clear(); + psName->insert(0, t1FontNames[i].psName); + return; + } + } + if (t1FontNameLen == t1FontNameSize) { + t1FontNameSize *= 2; + t1FontNames = (PST1FontName *)greallocn(t1FontNames, t1FontNameSize, + sizeof(PST1FontName)); + } + t1FontNames[t1FontNameLen].fontFileID = *id; + t1FontNames[t1FontNameLen].psName = psName->copy(); + ++t1FontNameLen; + + // beginning comment + writePSFmt("%%BeginResource: font {0:t}\n", psName); + embFontList->append("%%+ font "); + embFontList->append(psName->getCString()); + embFontList->append("\n"); + + // convert it to a Type 1 font + if ((fontBuf = font->readEmbFontFile(xref, &fontLen))) { + if ((ffT1C = FoFiType1C::make(fontBuf, fontLen))) { + ffT1C->convertToType1(psName->getCString(), NULL, gTrue, + outputFunc, outputStream); + delete ffT1C; + } + gfree(fontBuf); + } + + // ending comment + writePS("%%EndResource\n"); +} + +void PSOutputDev::setupEmbeddedOpenTypeT1CFont(GfxFont *font, Ref *id, + GooString *psName) { + char *fontBuf; + int fontLen; + FoFiTrueType *ffTT; + int i; + + // check if font is already embedded + for (i = 0; i < t1FontNameLen; ++i) { + if (t1FontNames[i].fontFileID.num == id->num && + t1FontNames[i].fontFileID.gen == id->gen) { + psName->clear(); + psName->insert(0, t1FontNames[i].psName); + return; + } + } + if (t1FontNameLen == t1FontNameSize) { + t1FontNameSize *= 2; + t1FontNames = (PST1FontName *)greallocn(t1FontNames, t1FontNameSize, + sizeof(PST1FontName)); + } + t1FontNames[t1FontNameLen].fontFileID = *id; + t1FontNames[t1FontNameLen].psName = psName->copy(); + ++t1FontNameLen; + + // beginning comment + writePSFmt("%%BeginResource: font {0:t}\n", psName); + embFontList->append("%%+ font "); + embFontList->append(psName->getCString()); + embFontList->append("\n"); + + // convert it to a Type 1 font + if ((fontBuf = font->readEmbFontFile(xref, &fontLen))) { + if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) { + if (ffTT->isOpenTypeCFF()) { + ffTT->convertToType1(psName->getCString(), NULL, gTrue, + outputFunc, outputStream); + } + delete ffTT; + } + gfree(fontBuf); + } + + // ending comment + writePS("%%EndResource\n"); +} + +void PSOutputDev::setupEmbeddedTrueTypeFont(GfxFont *font, Ref *id, + GooString *psName) { + char *fontBuf; + int fontLen; + FoFiTrueType *ffTT; + int *codeToGID; + + // beginning comment + writePSFmt("%%BeginResource: font {0:t}\n", psName); + embFontList->append("%%+ font "); + embFontList->append(psName->getCString()); + embFontList->append("\n"); + + // convert it to a Type 42 font + if ((fontBuf = font->readEmbFontFile(xref, &fontLen))) { + if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) { + codeToGID = ((Gfx8BitFont *)font)->getCodeToGIDMap(ffTT); + ffTT->convertToType42(psName->getCString(), + ((Gfx8BitFont *)font)->getHasEncoding() + ? ((Gfx8BitFont *)font)->getEncoding() + : (char **)NULL, + codeToGID, outputFunc, outputStream); + if (codeToGID) { + if (font8InfoLen >= font8InfoSize) { + font8InfoSize += 16; + font8Info = (PSFont8Info *)greallocn(font8Info, + font8InfoSize, + sizeof(PSFont8Info)); + } + font8Info[font8InfoLen].fontID = *font->getID(); + font8Info[font8InfoLen].codeToGID = codeToGID; + ++font8InfoLen; + } + delete ffTT; + } + gfree(fontBuf); + } + + // ending comment + writePS("%%EndResource\n"); +} + +void PSOutputDev::setupExternalTrueTypeFont(GfxFont *font, GooString *fileName, + GooString *psName) { + FoFiTrueType *ffTT; + int *codeToGID; + + // beginning comment + writePSFmt("%%BeginResource: font {0:t}\n", psName); + embFontList->append("%%+ font "); + embFontList->append(psName->getCString()); + embFontList->append("\n"); + + // convert it to a Type 42 font + if ((ffTT = FoFiTrueType::load(fileName->getCString()))) { + codeToGID = ((Gfx8BitFont *)font)->getCodeToGIDMap(ffTT); + ffTT->convertToType42(psName->getCString(), + ((Gfx8BitFont *)font)->getHasEncoding() + ? ((Gfx8BitFont *)font)->getEncoding() + : (char **)NULL, + codeToGID, outputFunc, outputStream); + if (codeToGID) { + if (font8InfoLen >= font8InfoSize) { + font8InfoSize += 16; + font8Info = (PSFont8Info *)greallocn(font8Info, + font8InfoSize, + sizeof(PSFont8Info)); + } + font8Info[font8InfoLen].fontID = *font->getID(); + font8Info[font8InfoLen].codeToGID = codeToGID; + ++font8InfoLen; + } + delete ffTT; + } + + // ending comment + writePS("%%EndResource\n"); +} + +void PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont *font, + GooString *fileName, + GooString *psName, + GBool needVerticalMetrics) { + FoFiTrueType *ffTT; + int *codeToGID; + int codeToGIDLen; + + // beginning comment + writePSFmt("%%BeginResource: font {0:t}\n", psName); + embFontList->append("%%+ font "); + embFontList->append(psName->getCString()); + embFontList->append("\n"); + + // convert it to a Type 0 font + //~ this should use fontNum to load the correct font + if ((ffTT = FoFiTrueType::load(fileName->getCString()))) { + + // check for embedding permission + if (ffTT->getEmbeddingRights() >= 1) { + codeToGID = NULL; + codeToGIDLen = 0; + if (((GfxCIDFont *)font)->getCIDToGID()) { + codeToGIDLen = ((GfxCIDFont *)font)->getCIDToGIDLen(); + if (codeToGIDLen) { + codeToGID = (int *)gmallocn(codeToGIDLen, sizeof(int)); + memcpy(codeToGID, ((GfxCIDFont *)font)->getCIDToGID(), + codeToGIDLen * sizeof(int)); + } + } else { + codeToGID = ((GfxCIDFont *)font)->getCodeToGIDMap(ffTT, &codeToGIDLen); + } + if (ffTT->isOpenTypeCFF()) { + ffTT->convertToCIDType0(psName->getCString(), + codeToGID, codeToGIDLen, + outputFunc, outputStream); + } else if (globalParams->getPSLevel() >= psLevel3) { + // Level 3: use a CID font + ffTT->convertToCIDType2(psName->getCString(), + codeToGID, codeToGIDLen, + needVerticalMetrics, + outputFunc, outputStream); + } else { + // otherwise: use a non-CID composite font + ffTT->convertToType0(psName->getCString(), + codeToGID, codeToGIDLen, + needVerticalMetrics, + outputFunc, outputStream); + } + gfree(codeToGID); + } else { + error(errSyntaxError, -1, + "TrueType font '{0:s}' does not allow embedding", + font->getName() ? font->getName()->getCString() : "(unnamed)"); + + } + delete ffTT; + } + + // ending comment + writePS("%%EndResource\n"); +} + +void PSOutputDev::setupEmbeddedCIDType0Font(GfxFont *font, Ref *id, + GooString *psName) { + char *fontBuf; + int fontLen; + FoFiType1C *ffT1C; + int i; + + // check if font is already embedded + for (i = 0; i < t1FontNameLen; ++i) { + if (t1FontNames[i].fontFileID.num == id->num && + t1FontNames[i].fontFileID.gen == id->gen) { + psName->clear(); + psName->insert(0, t1FontNames[i].psName); + return; + } + } + if (t1FontNameLen == t1FontNameSize) { + t1FontNameSize *= 2; + t1FontNames = (PST1FontName *)greallocn(t1FontNames, t1FontNameSize, + sizeof(PST1FontName)); + } + t1FontNames[t1FontNameLen].fontFileID = *id; + t1FontNames[t1FontNameLen].psName = psName->copy(); + ++t1FontNameLen; + + // beginning comment + writePSFmt("%%BeginResource: font {0:t}\n", psName); + embFontList->append("%%+ font "); + embFontList->append(psName->getCString()); + embFontList->append("\n"); + + // convert it to a Type 0 font + if ((fontBuf = font->readEmbFontFile(xref, &fontLen))) { + if ((ffT1C = FoFiType1C::make(fontBuf, fontLen))) { + if (globalParams->getPSLevel() >= psLevel3) { + // Level 3: use a CID font + ffT1C->convertToCIDType0(psName->getCString(), NULL, 0, + outputFunc, outputStream); + } else { + // otherwise: use a non-CID composite font + ffT1C->convertToType0(psName->getCString(), NULL, 0, + outputFunc, outputStream); + } + delete ffT1C; + } + gfree(fontBuf); + } + + // ending comment + writePS("%%EndResource\n"); +} + +void PSOutputDev::setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id, + GooString *psName, + GBool needVerticalMetrics) { + char *fontBuf; + int fontLen; + FoFiTrueType *ffTT; + + // beginning comment + writePSFmt("%%BeginResource: font {0:t}\n", psName); + embFontList->append("%%+ font "); + embFontList->append(psName->getCString()); + embFontList->append("\n"); + + // convert it to a Type 0 font + if ((fontBuf = font->readEmbFontFile(xref, &fontLen))) { + if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) { + if (globalParams->getPSLevel() >= psLevel3) { + // Level 3: use a CID font + ffTT->convertToCIDType2(psName->getCString(), + ((GfxCIDFont *)font)->getCIDToGID(), + ((GfxCIDFont *)font)->getCIDToGIDLen(), + needVerticalMetrics, + outputFunc, outputStream); + } else { + // otherwise: use a non-CID composite font + ffTT->convertToType0(psName->getCString(), + ((GfxCIDFont *)font)->getCIDToGID(), + ((GfxCIDFont *)font)->getCIDToGIDLen(), + needVerticalMetrics, + outputFunc, outputStream); + } + delete ffTT; + } + gfree(fontBuf); + } + + // ending comment + writePS("%%EndResource\n"); +} + +void PSOutputDev::setupEmbeddedOpenTypeCFFFont(GfxFont *font, Ref *id, + GooString *psName) { + char *fontBuf; + int fontLen; + FoFiTrueType *ffTT; + int i; + + // check if font is already embedded + for (i = 0; i < t1FontNameLen; ++i) { + if (t1FontNames[i].fontFileID.num == id->num && + t1FontNames[i].fontFileID.gen == id->gen) { + psName->clear(); + psName->insert(0, t1FontNames[i].psName); + return; + } + } + if (t1FontNameLen == t1FontNameSize) { + t1FontNameSize *= 2; + t1FontNames = (PST1FontName *)greallocn(t1FontNames, t1FontNameSize, + sizeof(PST1FontName)); + } + t1FontNames[t1FontNameLen].fontFileID = *id; + t1FontNames[t1FontNameLen].psName = psName->copy(); + ++t1FontNameLen; + + // beginning comment + writePSFmt("%%BeginResource: font {0:t}\n", psName); + embFontList->append("%%+ font "); + embFontList->append(psName->getCString()); + embFontList->append("\n"); + + // convert it to a Type 0 font + if ((fontBuf = font->readEmbFontFile(xref, &fontLen))) { + if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) { + if (ffTT->isOpenTypeCFF()) { + if (globalParams->getPSLevel() >= psLevel3) { + // Level 3: use a CID font + ffTT->convertToCIDType0(psName->getCString(), + ((GfxCIDFont *)font)->getCIDToGID(), + ((GfxCIDFont *)font)->getCIDToGIDLen(), + outputFunc, outputStream); + } else { + // otherwise: use a non-CID composite font + ffTT->convertToType0(psName->getCString(), + ((GfxCIDFont *)font)->getCIDToGID(), + ((GfxCIDFont *)font)->getCIDToGIDLen(), + outputFunc, outputStream); + } + } + delete ffTT; + } + gfree(fontBuf); + } + + // ending comment + writePS("%%EndResource\n"); +} + +void PSOutputDev::setupType3Font(GfxFont *font, GooString *psName, + Dict *parentResDict) { + Dict *resDict; + Dict *charProcs; + Object charProc; + Gfx *gfx; + PDFRectangle box; + double *m; + GooString *buf; + int i; + + // set up resources used by font + if ((resDict = ((Gfx8BitFont *)font)->getResources())) { + inType3Char = gTrue; + setupResources(resDict); + inType3Char = gFalse; + } else { + resDict = parentResDict; + } + + // beginning comment + writePSFmt("%%BeginResource: font {0:t}\n", psName); + embFontList->append("%%+ font "); + embFontList->append(psName->getCString()); + embFontList->append("\n"); + + // font dictionary + writePS("8 dict begin\n"); + writePS("/FontType 3 def\n"); + m = font->getFontMatrix(); + writePSFmt("/FontMatrix [{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g}] def\n", + m[0], m[1], m[2], m[3], m[4], m[5]); + m = font->getFontBBox(); + writePSFmt("/FontBBox [{0:.6g} {1:.6g} {2:.6g} {3:.6g}] def\n", + m[0], m[1], m[2], m[3]); + writePS("/Encoding 256 array def\n"); + writePS(" 0 1 255 { Encoding exch /.notdef put } for\n"); + writePS("/BuildGlyph {\n"); + writePS(" exch /CharProcs get exch\n"); + writePS(" 2 copy known not { pop /.notdef } if\n"); + writePS(" get exec\n"); + writePS("} bind def\n"); + writePS("/BuildChar {\n"); + writePS(" 1 index /Encoding get exch get\n"); + writePS(" 1 index /BuildGlyph get exec\n"); + writePS("} bind def\n"); + if ((charProcs = ((Gfx8BitFont *)font)->getCharProcs())) { + writePSFmt("/CharProcs {0:d} dict def\n", charProcs->getLength()); + writePS("CharProcs begin\n"); + box.x1 = m[0]; + box.y1 = m[1]; + box.x2 = m[2]; + box.y2 = m[3]; + gfx = new Gfx(doc, this, resDict, &box, NULL); + inType3Char = gTrue; + for (i = 0; i < charProcs->getLength(); ++i) { + t3FillColorOnly = gFalse; + t3Cacheable = gFalse; + t3NeedsRestore = gFalse; + writePS("/"); + writePSName(charProcs->getKey(i)); + writePS(" {\n"); + gfx->display(charProcs->getVal(i, &charProc)); + charProc.free(); + if (t3String) { + if (t3Cacheable) { + buf = GooString::format("{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g} setcachedevice\n", + t3WX, t3WY, t3LLX, t3LLY, t3URX, t3URY); + } else { + buf = GooString::format("{0:.6g} {1:.6g} setcharwidth\n", t3WX, t3WY); + } + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + (*outputFunc)(outputStream, t3String->getCString(), + t3String->getLength()); + delete t3String; + t3String = NULL; + } + if (t3NeedsRestore) { + (*outputFunc)(outputStream, "Q\n", 2); + } + writePS("} def\n"); + } + inType3Char = gFalse; + delete gfx; + writePS("end\n"); + } + writePS("currentdict end\n"); + writePSFmt("/{0:t} exch definefont pop\n", psName); + + // ending comment + writePS("%%EndResource\n"); +} + +// Make a unique PS font name, based on the names given in the PDF +// font object, and an object ID (font file object for +GooString *PSOutputDev::makePSFontName(GfxFont *font, Ref *id) { + GooString *psName, *s; + + if ((s = font->getEmbeddedFontName())) { + psName = filterPSName(s); + if (!fontNames->lookupInt(psName)) { + fontNames->add(psName->copy(), 1); + return psName; + } + delete psName; + } + if ((s = font->getName())) { + psName = filterPSName(s); + if (!fontNames->lookupInt(psName)) { + fontNames->add(psName->copy(), 1); + return psName; + } + delete psName; + } + psName = GooString::format("FF{0:d}_{1:d}", id->num, id->gen); + if ((s = font->getEmbeddedFontName())) { + s = filterPSName(s); + psName->append('_')->append(s); + delete s; + } else if ((s = font->getName())) { + s = filterPSName(s); + psName->append('_')->append(s); + delete s; + } + fontNames->add(psName->copy(), 1); + return psName; +} + +void PSOutputDev::setupImages(Dict *resDict) { + Object xObjDict, xObj, xObjRef, subtypeObj, maskObj, maskRef; + Ref imgID; + int i, j; + + if (!(mode == psModeForm || inType3Char || preloadImagesForms)) { + return; + } + + //----- recursively scan XObjects + resDict->lookup("XObject", &xObjDict); + if (xObjDict.isDict()) { + for (i = 0; i < xObjDict.dictGetLength(); ++i) { + xObjDict.dictGetValNF(i, &xObjRef); + xObjDict.dictGetVal(i, &xObj); + if (xObj.isStream()) { + xObj.streamGetDict()->lookup("Subtype", &subtypeObj); + if (subtypeObj.isName("Image")) { + if (xObjRef.isRef()) { + imgID = xObjRef.getRef(); + for (j = 0; j < imgIDLen; ++j) { + if (imgIDs[j].num == imgID.num && imgIDs[j].gen == imgID.gen) { + break; + } + } + if (j == imgIDLen) { + if (imgIDLen >= imgIDSize) { + if (imgIDSize == 0) { + imgIDSize = 64; + } else { + imgIDSize *= 2; + } + imgIDs = (Ref *)greallocn(imgIDs, imgIDSize, sizeof(Ref)); + } + imgIDs[imgIDLen++] = imgID; + setupImage(imgID, xObj.getStream(), gFalse); + if (level >= psLevel3 && + xObj.streamGetDict()->lookup("Mask", &maskObj)->isStream()) { + setupImage(imgID, maskObj.getStream(), gTrue); + } + maskObj.free(); + } + } else { + error(errSyntaxError, -1, + "Image in resource dict is not an indirect reference"); + } + } + subtypeObj.free(); + } + xObj.free(); + xObjRef.free(); + } + } + xObjDict.free(); +} + +void PSOutputDev::setupImage(Ref id, Stream *str, GBool mask) { + GBool useRLE, useCompressed, doUseASCIIHex; + GooString *s; + int c; + int size, line, col, i; + int outerSize, outer; + + // filters + //~ this does not correctly handle the DeviceN color space + //~ -- need to use DeviceNRecoder + if (level < psLevel2) { + useRLE = gFalse; + useCompressed = gFalse; + doUseASCIIHex = gTrue; + } else { + if (uncompressPreloadedImages) { + useRLE = gFalse; + useCompressed = gFalse; + } else { + s = str->getPSFilter(level < psLevel3 ? 2 : 3, ""); + if (s) { + useRLE = gFalse; + useCompressed = gTrue; + delete s; + } else { + useRLE = gTrue; + useCompressed = gFalse; + } + } + doUseASCIIHex = useASCIIHex; + } + if (useCompressed) { + str = str->getUndecodedStream(); + } + if (useRLE) { + str = new RunLengthEncoder(str); + } + if (doUseASCIIHex) { + str = new ASCIIHexEncoder(str); + } else { + str = new ASCII85Encoder(str); + } + + // compute image data size + str->reset(); + col = size = 0; + do { + do { + c = str->getChar(); + } while (c == '\n' || c == '\r'); + if (c == (doUseASCIIHex ? '>' : '~') || c == EOF) { + break; + } + if (c == 'z') { + ++col; + } else { + ++col; + for (i = 1; i <= (doUseASCIIHex ? 1 : 4); ++i) { + do { + c = str->getChar(); + } while (c == '\n' || c == '\r'); + if (c == (doUseASCIIHex ? '>' : '~') || c == EOF) { + break; + } + ++col; + } + if (c == (doUseASCIIHex ? '>' : '~') || c == EOF) { + break; + } + } + if (col > 225) { + ++size; + col = 0; + } + } while (c != (doUseASCIIHex ? '>' : '~') && c != EOF); + // add one entry for the final line of data; add another entry + // because the RunLengthDecode filter may read past the end + ++size; + if (useRLE) { + ++size; + } + outerSize = size/65535 + 1; + + writePSFmt("{0:d} array dup /{1:s}Data_{2:d}_{3:d} exch def\n", + outerSize, mask ? "Mask" : "Im", id.num, id.gen); + str->close(); + + // write the data into the array + str->reset(); + for (outer = 0;outer < outerSize;outer++) { + int innerSize = size > 65535 ? 65535 : size; + + // put the inner array into the outer array + writePSFmt("{0:d} array 1 index {1:d} 2 index put\n", + innerSize, outer); + line = col = 0; + writePS((char *)(doUseASCIIHex ? "dup 0 <" : "dup 0 <~")); + for (;;) { + do { + c = str->getChar(); + } while (c == '\n' || c == '\r'); + if (c == (doUseASCIIHex ? '>' : '~') || c == EOF) { + break; + } + if (c == 'z') { + writePSChar(c); + ++col; + } else { + writePSChar(c); + ++col; + for (i = 1; i <= (doUseASCIIHex ? 1 : 4); ++i) { + do { + c = str->getChar(); + } while (c == '\n' || c == '\r'); + if (c == (doUseASCIIHex ? '>' : '~') || c == EOF) { + break; + } + writePSChar(c); + ++col; + } + } + if (c == (doUseASCIIHex ? '>' : '~') || c == EOF) { + break; + } + // each line is: "dup nnnnn <~...data...~> put<eol>" + // so max data length = 255 - 20 = 235 + // chunks are 1 or 4 bytes each, so we have to stop at 232 + // but make it 225 just to be safe + if (col > 225) { + writePS((char *)(doUseASCIIHex ? "> put\n" : "~> put\n")); + ++line; + if (line >= innerSize) break; + writePSFmt((char *)(doUseASCIIHex ? "dup {0:d} <" : "dup {0:d} <~"), line); + col = 0; + } + } + if (c == (doUseASCIIHex ? '>' : '~') || c == EOF) { + writePS((char *)(doUseASCIIHex ? "> put\n" : "~> put\n")); + if (useRLE) { + ++line; + writePSFmt("{0:d} <> put\n", line); + } else { + writePS("pop\n"); + } + break; + } + writePS("pop\n"); + size -= innerSize; + } + writePS("pop\n"); + str->close(); + + delete str; +} + +void PSOutputDev::setupForms(Dict *resDict) { + Object xObjDict, xObj, xObjRef, subtypeObj; + int i; + + if (!preloadImagesForms) { + return; + } + + resDict->lookup("XObject", &xObjDict); + if (xObjDict.isDict()) { + for (i = 0; i < xObjDict.dictGetLength(); ++i) { + xObjDict.dictGetValNF(i, &xObjRef); + xObjDict.dictGetVal(i, &xObj); + if (xObj.isStream()) { + xObj.streamGetDict()->lookup("Subtype", &subtypeObj); + if (subtypeObj.isName("Form")) { + if (xObjRef.isRef()) { + setupForm(xObjRef.getRef(), &xObj); + } else { + error(errSyntaxError, -1, + "Form in resource dict is not an indirect reference"); + } + } + subtypeObj.free(); + } + xObj.free(); + xObjRef.free(); + } + } + xObjDict.free(); +} + +void PSOutputDev::setupForm(Ref id, Object *strObj) { + Dict *dict, *resDict; + Object matrixObj, bboxObj, resObj, obj1; + double m[6], bbox[4]; + PDFRectangle box; + Gfx *gfx; + int i; + + // check if form is already defined + for (i = 0; i < formIDLen; ++i) { + if (formIDs[i].num == id.num && formIDs[i].gen == id.gen) { + return; + } + } + + // add entry to formIDs list + if (formIDLen >= formIDSize) { + if (formIDSize == 0) { + formIDSize = 64; + } else { + formIDSize *= 2; + } + formIDs = (Ref *)greallocn(formIDs, formIDSize, sizeof(Ref)); + } + formIDs[formIDLen++] = id; + + dict = strObj->streamGetDict(); + + // get bounding box + dict->lookup("BBox", &bboxObj); + if (!bboxObj.isArray()) { + bboxObj.free(); + error(errSyntaxError, -1, "Bad form bounding box"); + return; + } + for (i = 0; i < 4; ++i) { + bboxObj.arrayGet(i, &obj1); + bbox[i] = obj1.getNum(); + obj1.free(); + } + bboxObj.free(); + + // get matrix + dict->lookup("Matrix", &matrixObj); + if (matrixObj.isArray()) { + for (i = 0; i < 6; ++i) { + matrixObj.arrayGet(i, &obj1); + m[i] = obj1.getNum(); + obj1.free(); + } + } else { + m[0] = 1; m[1] = 0; + m[2] = 0; m[3] = 1; + m[4] = 0; m[5] = 0; + } + matrixObj.free(); + + // get resources + dict->lookup("Resources", &resObj); + resDict = resObj.isDict() ? resObj.getDict() : (Dict *)NULL; + + writePSFmt("/f_{0:d}_{1:d} {{\n", id.num, id.gen); + writePS("q\n"); + writePSFmt("[{0:.6gs} {1:.6gs} {2:.6gs} {3:.6gs} {4:.6gs} {5:.6gs}] cm\n", + m[0], m[1], m[2], m[3], m[4], m[5]); + + box.x1 = bbox[0]; + box.y1 = bbox[1]; + box.x2 = bbox[2]; + box.y2 = bbox[3]; + gfx = new Gfx(doc, this, resDict, &box, &box); + gfx->display(strObj); + delete gfx; + + writePS("Q\n"); + writePS("} def\n"); + + resObj.free(); +} + +GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, + int rotateA, GBool useMediaBox, GBool crop, + int sliceX, int sliceY, + int sliceW, int sliceH, + GBool printing, + GBool (*abortCheckCbk)(void *data), + void *abortCheckCbkData, + GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data), + void *annotDisplayDecideCbkData) { + PreScanOutputDev *scan; + GBool rasterize; +#if HAVE_SPLASH + SplashOutputDev *splashOut; + SplashColor paperColor; + PDFRectangle box; + GfxState *state; + SplashBitmap *bitmap; + Stream *str0, *str; + Object obj; + Guchar *p; + Guchar col[4]; + double hDPI2, vDPI2; + double m0, m1, m2, m3, m4, m5; + int nStripes, stripeH, stripeY; + int c, w, h, x, y, comp, i; + int numComps, initialNumComps; +#endif + char hexBuf[32*2 + 2]; // 32 values X 2 chars/value + line ending + null + Guchar digit; + GBool isGray; + + if (!postInitDone) { + postInit(); + } + if (forceRasterize) { + rasterize = gTrue; + } else { + scan = new PreScanOutputDev(doc); + page->displaySlice(scan, 72, 72, rotateA, useMediaBox, crop, + sliceX, sliceY, sliceW, sliceH, + printing, abortCheckCbk, abortCheckCbkData, + annotDisplayDecideCbk, annotDisplayDecideCbkData); + rasterize = scan->usesTransparency() || scan->usesPatternImageMask(); + delete scan; + } + if (!rasterize) { + return gTrue; + } + +#if HAVE_SPLASH + // start the PS page + page->makeBox(rasterResolution, rasterResolution, rotateA, useMediaBox, gFalse, + sliceX, sliceY, sliceW, sliceH, &box, &crop); + rotateA += page->getRotate(); + if (rotateA >= 360) { + rotateA -= 360; + } else if (rotateA < 0) { + rotateA += 360; + } + state = new GfxState(rasterResolution, rasterResolution, &box, rotateA, gFalse); + startPage(page->getNum(), state, xref); + delete state; + + // set up the SplashOutputDev + if (rasterMono || level == psLevel1) { + numComps = 1; + paperColor[0] = 0xff; + splashOut = new SplashOutputDev(splashModeMono8, 1, gFalse, + paperColor, gFalse); +#if SPLASH_CMYK + } else if (level == psLevel1Sep || level == psLevel2Sep || + level == psLevel3Sep || globalParams->getOverprintPreview()) { + numComps = 4; + paperColor[0] = paperColor[1] = paperColor[2] = paperColor[3] = 0; + splashOut = new SplashOutputDev(splashModeCMYK8, 1, gFalse, + paperColor, gFalse); +#endif + } else { + numComps = 3; + paperColor[0] = paperColor[1] = paperColor[2] = 0xff; + splashOut = new SplashOutputDev(splashModeRGB8, 1, gFalse, + paperColor, gFalse); + } + splashOut->setFontAntialias(rasterAntialias); + splashOut->setVectorAntialias(rasterAntialias); + splashOut->startDoc(doc); + + // break the page into stripes + hDPI2 = xScale * rasterResolution; + vDPI2 = yScale * rasterResolution; + if (sliceW < 0 || sliceH < 0) { + if (useMediaBox) { + box = *page->getMediaBox(); + } else { + box = *page->getCropBox(); + } + sliceX = sliceY = 0; + sliceW = (int)((box.x2 - box.x1) * hDPI2 / 72.0); + sliceH = (int)((box.y2 - box.y1) * vDPI2 / 72.0); + } + nStripes = (int)ceil((double)(sliceW * sliceH) / + (double)rasterizationSliceSize); + stripeH = (sliceH + nStripes - 1) / nStripes; + + // render the stripes + initialNumComps = numComps; + for (stripeY = sliceY; stripeY < sliceH; stripeY += stripeH) { + + // rasterize a stripe + page->makeBox(hDPI2, vDPI2, 0, useMediaBox, gFalse, + sliceX, stripeY, sliceW, stripeH, &box, &crop); + m0 = box.x2 - box.x1; + m1 = 0; + m2 = 0; + m3 = box.y2 - box.y1; + m4 = box.x1; + m5 = box.y1; + page->displaySlice(splashOut, hDPI2, vDPI2, + (360 - page->getRotate()) % 360, useMediaBox, crop, + sliceX, stripeY, sliceW, stripeH, + printing, abortCheckCbk, abortCheckCbkData, + annotDisplayDecideCbk, annotDisplayDecideCbkData); + + // draw the rasterized image + bitmap = splashOut->getBitmap(); + numComps = initialNumComps; + w = bitmap->getWidth(); + h = bitmap->getHeight(); + writePS("gsave\n"); + writePSFmt("[{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g}] concat\n", + m0, m1, m2, m3, m4, m5); + switch (level) { + case psLevel1: + writePSFmt("{0:d} {1:d} 8 [{2:d} 0 0 {3:d} 0 {4:d}] pdfIm1{5:s}\n", + w, h, w, -h, h, + useBinary ? "Bin" : ""); + p = bitmap->getDataPtr() + (h - 1) * bitmap->getRowSize(); + i = 0; + if (useBinary) { + for (y = 0; y < h; ++y) { + for (x = 0; x < w; ++x) { + hexBuf[i++] = *p++; + if (i >= 64) { + writePSBuf(hexBuf, i); + i = 0; + } + } + } + } else { + for (y = 0; y < h; ++y) { + for (x = 0; x < w; ++x) { + digit = *p / 16; + hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); + digit = *p++ % 16; + hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); + if (i >= 64) { + hexBuf[i++] = '\n'; + writePSBuf(hexBuf, i); + i = 0; + } + } + } + } + if (i != 0) { + if (!useBinary) { + hexBuf[i++] = '\n'; + } + writePSBuf(hexBuf, i); + } + break; + case psLevel1Sep: + p = bitmap->getDataPtr(); + // Check for an all gray image + if (getOptimizeColorSpace()) { + isGray = gTrue; + for (y = 0; y < h; ++y) { + for (x = 0; x < w; ++x) { + if (p[4*x] != p[4*x + 1] || p[4*x] != p[4*x + 2]) { + isGray = gFalse; + y = h; + break; + } + } + p += bitmap->getRowSize(); + } + } else { + isGray = gFalse; + } + writePSFmt("{0:d} {1:d} 8 [{2:d} 0 0 {3:d} 0 {4:d}] pdfIm1{5:s}{6:s}\n", + w, h, w, -h, h, + isGray ? "" : "Sep", + useBinary ? "Bin" : ""); + p = bitmap->getDataPtr() + (h - 1) * bitmap->getRowSize(); + i = 0; + col[0] = col[1] = col[2] = col[3] = 0; + if (isGray) { + int g; + if ((psProcessBlack & processColors) == 0) { + // Check if the image uses black + for (y = 0; y < h; ++y) { + for (x = 0; x < w; ++x) { + if (p[4*x] > 0 || p[4*x + 3] > 0) { + col[3] = 1; + y = h; + break; + } + } + p -= bitmap->getRowSize(); + } + p = bitmap->getDataPtr() + (h - 1) * bitmap->getRowSize(); + } + for (y = 0; y < h; ++y) { + if (useBinary) { + // Binary gray image + for (x = 0; x < w; ++x) { + g = p[4*x] + p[4*x + 3]; + g = 255 - g; + if (g < 0) g = 0; + hexBuf[i++] = (Guchar) g; + if (i >= 64) { + writePSBuf(hexBuf, i); + i = 0; + } + } + } else { + // Hex gray image + for (x = 0; x < w; ++x) { + g = p[4*x] + p[4*x + 3]; + g = 255 - g; + if (g < 0) g = 0; + digit = g / 16; + hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); + digit = g % 16; + hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); + if (i >= 64) { + hexBuf[i++] = '\n'; + writePSBuf(hexBuf, i); + i = 0; + } + } + } + p -= bitmap->getRowSize(); + } + } else if (((psProcessCyan | psProcessMagenta | psProcessYellow | psProcessBlack) & ~processColors) != 0) { + // Color image, need to check color flags for each dot + for (y = 0; y < h; ++y) { + for (comp = 0; comp < 4; ++comp) { + if (useBinary) { + // Binary color image + for (x = 0; x < w; ++x) { + col[comp] |= p[4*x + comp]; + hexBuf[i++] = p[4*x + comp]; + if (i >= 64) { + writePSBuf(hexBuf, i); + i = 0; + } + } + } else { + // Gray color image + for (x = 0; x < w; ++x) { + col[comp] |= p[4*x + comp]; + digit = p[4*x + comp] / 16; + hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); + digit = p[4*x + comp] % 16; + hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); + if (i >= 64) { + hexBuf[i++] = '\n'; + writePSBuf(hexBuf, i); + i = 0; + } + } + } + } + p -= bitmap->getRowSize(); + } + } else { + // Color image, do not need to check color flags + for (y = 0; y < h; ++y) { + for (comp = 0; comp < 4; ++comp) { + if (useBinary) { + // Binary color image + for (x = 0; x < w; ++x) { + hexBuf[i++] = p[4*x + comp]; + if (i >= 64) { + writePSBuf(hexBuf, i); + i = 0; + } + } + } else { + // Hex color image + for (x = 0; x < w; ++x) { + digit = p[4*x + comp] / 16; + hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); + digit = p[4*x + comp] % 16; + hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); + if (i >= 64) { + hexBuf[i++] = '\n'; + writePSBuf(hexBuf, i); + i = 0; + } + } + } + } + p -= bitmap->getRowSize(); + } + } + if (i != 0) { + if (!useBinary) { + hexBuf[i++] = '\n'; + } + writePSBuf(hexBuf, i); + } + if (col[0]) { + processColors |= psProcessCyan; + } + if (col[1]) { + processColors |= psProcessMagenta; + } + if (col[2]) { + processColors |= psProcessYellow; + } + if (col[3]) { + processColors |= psProcessBlack; + } + break; + case psLevel2: + case psLevel2Sep: + case psLevel3: + case psLevel3Sep: + obj.initNull(); + p = bitmap->getDataPtr() + (h - 1) * bitmap->getRowSize(); + str0 = new MemStream((char *)p, 0, w * h * numComps, &obj); + // Check for a color image that uses only gray + if (!getOptimizeColorSpace()) { + isGray = gFalse; + } else if (numComps == 4) { + int compCyan; + isGray = gTrue; + while ((compCyan = str0->getChar()) != EOF) { + if (str0->getChar() != compCyan || + str0->getChar() != compCyan) { + isGray = gFalse; + break; + } + str0->getChar(); + } + } else if (numComps == 3) { + int compRed; + isGray = gTrue; + while ((compRed = str0->getChar()) != EOF) { + if (str0->getChar() != compRed || + str0->getChar() != compRed) { + isGray = gFalse; + break; + } + } + } else { + isGray = gFalse; + } + str0->reset(); + if (isGray && numComps == 4) { + str = new RunLengthEncoder(new CMYKGrayEncoder(str0)); + numComps = 1; + } else if (isGray && numComps == 3) { + str = new RunLengthEncoder(new RGBGrayEncoder(str0)); + numComps = 1; + } else { + str = new RunLengthEncoder(str0); + } + if (numComps == 1) { + writePS("/DeviceGray setcolorspace\n"); + } else if (numComps == 3) { + writePS("/DeviceRGB setcolorspace\n"); + } else { + writePS("/DeviceCMYK setcolorspace\n"); + } + writePS("<<\n /ImageType 1\n"); + writePSFmt(" /Width {0:d}\n", bitmap->getWidth()); + writePSFmt(" /Height {0:d}\n", bitmap->getHeight()); + writePSFmt(" /ImageMatrix [{0:d} 0 0 {1:d} 0 {2:d}]\n", w, -h, h); + writePS(" /BitsPerComponent 8\n"); + if (numComps == 1) { + writePS(" /Decode [1 0]\n"); + } else if (numComps == 3) { + writePS(" /Decode [0 1 0 1 0 1]\n"); + } else { + writePS(" /Decode [0 1 0 1 0 1 0 1]\n"); + } + writePS(" /DataSource currentfile\n"); + if (useBinary) { + /* nothing to do */; + } else if (useASCIIHex) { + writePS(" /ASCIIHexDecode filter\n"); + } else { + writePS(" /ASCII85Decode filter\n"); + } + writePS(" /RunLengthDecode filter\n"); + writePS(">>\n"); + if (useBinary) { + /* nothing to do */; + } else if (useASCIIHex) { + str = new ASCIIHexEncoder(str); + } else { + str = new ASCII85Encoder(str); + } + str->reset(); + if (useBinary) { + // Count the bytes to write a document comment + int len = 0; + while (str->getChar() != EOF) { + len++; + } + str->reset(); + writePSFmt("%%BeginData: {0:d} Binary Bytes\n", len+6+1); + } + writePS("image\n"); + while ((c = str->getChar()) != EOF) { + writePSChar(c); + } + str->close(); + delete str; + delete str0; + writePSChar('\n'); + if (useBinary) { + writePS("%%EndData\n"); + } + processColors |= (numComps == 1) ? psProcessBlack : psProcessCMYK; + break; + } + writePS("grestore\n"); + } + + delete splashOut; + + // finish the PS page + endPage(); + + return gFalse; + +#else // HAVE_SPLASH + + error(errSyntaxWarning, -1, + "PDF page uses transparency and PSOutputDev was built without" + " the Splash rasterizer - output may not be correct"); + return gTrue; +#endif // HAVE_SPLASH +} + +void PSOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) { + Page *page; + int x1, y1, x2, y2, width, height, t; + int imgWidth, imgHeight, imgWidth2, imgHeight2; + GBool landscape; + GooString *s; + PSOutPaperSize *paperSize; + + if (!postInitDone) { + postInit(); + } + xref = xrefA; + if (mode == psModePS) { + GooString pageLabel; + const GBool gotLabel = doc->getCatalog()->indexToLabel(pageNum -1, &pageLabel); + if (gotLabel) { + // See bug13338 for why we try to avoid parentheses... + GBool needParens; + GooString *filteredString = filterPSLabel(&pageLabel, &needParens); + if (needParens) { + writePSFmt("%%Page: ({0:t}) {1:d}\n", filteredString, seqPage); + } else { + writePSFmt("%%Page: {0:t} {1:d}\n", filteredString, seqPage); + } + delete filteredString; + } else { + writePSFmt("%%Page: {0:d} {1:d}\n", pageNum, seqPage); + } + if (paperMatch) { + page = doc->getCatalog()->getPage(pageNum); + imgLLX = imgLLY = 0; + if (noCrop) { + imgURX = (int)ceil(page->getMediaWidth()); + imgURY = (int)ceil(page->getMediaHeight()); + } else { + imgURX = (int)ceil(page->getCropWidth()); + imgURY = (int)ceil(page->getCropHeight()); + } + if (state->getRotate() == 90 || state->getRotate() == 270) { + t = imgURX; + imgURX = imgURY; + imgURY = t; + } + } + } + + // underlays + if (underlayCbk) { + (*underlayCbk)(this, underlayCbkData); + } + if (overlayCbk) { + saveState(NULL); + } + + xScale = yScale = 1; + switch (mode) { + + case psModePS: + // rotate, translate, and scale page + imgWidth = imgURX - imgLLX; + imgHeight = imgURY - imgLLY; + x1 = (int)floor(state->getX1()); + y1 = (int)floor(state->getY1()); + x2 = (int)ceil(state->getX2()); + y2 = (int)ceil(state->getY2()); + width = x2 - x1; + height = y2 - y1; + tx = ty = 0; + // rotation and portrait/landscape mode + if (paperMatch) { + rotate = (360 - state->getRotate()) % 360; + landscape = gFalse; + } else if (rotate0 >= 0) { + rotate = (360 - rotate0) % 360; + landscape = gFalse; + } else { + rotate = (360 - state->getRotate()) % 360; + if (rotate == 0 || rotate == 180) { + if ((width < height && imgWidth > imgHeight && height > imgHeight) || + (width > height && imgWidth < imgHeight && width > imgWidth)) { + rotate += 90; + landscape = gTrue; + } else { + landscape = gFalse; + } + } else { // rotate == 90 || rotate == 270 + if ((height < width && imgWidth > imgHeight && width > imgHeight) || + (height > width && imgWidth < imgHeight && height > imgWidth)) { + rotate = 270 - rotate; + landscape = gTrue; + } else { + landscape = gFalse; + } + } + } + if (paperMatch) { + paperSize = (PSOutPaperSize *)paperSizes->get(pagePaperSize[pageNum]); + writePSFmt("%%PageMedia: {0:t}\n", paperSize->name); + } + if (rotate == 0 || rotate == 180) { + writePSFmt("%%PageBoundingBox: 0 0 {0:d} {1:d}\n", width, height); + } else { + writePSFmt("%%PageBoundingBox: 0 0 {0:d} {1:d}\n", height, width); + } + writePSFmt("%%PageOrientation: {0:s}\n", + landscape ? "Landscape" : "Portrait"); + writePS("%%BeginPageSetup\n"); + if (paperMatch) { + writePSFmt("{0:d} {1:d} pdfSetupPaper\n", imgURX, imgURY); + } + writePS("pdfStartPage\n"); + if (rotate == 0) { + imgWidth2 = imgWidth; + imgHeight2 = imgHeight; + } else if (rotate == 90) { + writePS("90 rotate\n"); + ty = -imgWidth; + imgWidth2 = imgHeight; + imgHeight2 = imgWidth; + } else if (rotate == 180) { + writePS("180 rotate\n"); + imgWidth2 = imgWidth; + imgHeight2 = imgHeight; + tx = -imgWidth; + ty = -imgHeight; + } else { // rotate == 270 + writePS("270 rotate\n"); + tx = -imgHeight; + imgWidth2 = imgHeight; + imgHeight2 = imgWidth; + } + // shrink or expand + if (xScale0 > 0 && yScale0 > 0) { + xScale = xScale0; + yScale = yScale0; + } else if ((globalParams->getPSShrinkLarger() && + (width > imgWidth2 || height > imgHeight2)) || + (globalParams->getPSExpandSmaller() && + (width < imgWidth2 && height < imgHeight2))) { + xScale = (double)imgWidth2 / (double)width; + yScale = (double)imgHeight2 / (double)height; + if (yScale < xScale) { + xScale = yScale; + } else { + yScale = xScale; + } + } + // deal with odd bounding boxes or clipping + if (clipLLX0 < clipURX0 && clipLLY0 < clipURY0) { + tx -= xScale * clipLLX0; + ty -= yScale * clipLLY0; + } else { + tx -= xScale * x1; + ty -= yScale * y1; + } + // center + if (tx0 >= 0 && ty0 >= 0) { + tx += (rotate == 0 || rotate == 180) ? tx0 : ty0; + ty += (rotate == 0 || rotate == 180) ? ty0 : -tx0; + } else if (globalParams->getPSCenter()) { + if (clipLLX0 < clipURX0 && clipLLY0 < clipURY0) { + tx += (imgWidth2 - xScale * (clipURX0 - clipLLX0)) / 2; + ty += (imgHeight2 - yScale * (clipURY0 - clipLLY0)) / 2; + } else { + tx += (imgWidth2 - xScale * width) / 2; + ty += (imgHeight2 - yScale * height) / 2; + } + } + tx += (rotate == 0 || rotate == 180) ? imgLLX : imgLLY; + ty += (rotate == 0 || rotate == 180) ? imgLLY : -imgLLX; + if (tx != 0 || ty != 0) { + writePSFmt("{0:.6g} {1:.6g} translate\n", tx, ty); + } + if (xScale != 1 || yScale != 1) { + writePSFmt("{0:.6f} {1:.6f} scale\n", xScale, yScale); + } + if (clipLLX0 < clipURX0 && clipLLY0 < clipURY0) { + writePSFmt("{0:.6g} {1:.6g} {2:.6g} {3:.6g} re W\n", + clipLLX0, clipLLY0, clipURX0 - clipLLX0, clipURY0 - clipLLY0); + } else { + writePSFmt("{0:d} {1:d} {2:d} {3:d} re W\n", x1, y1, x2 - x1, y2 - y1); + } + + ++seqPage; + break; + + case psModeEPS: + writePS("pdfStartPage\n"); + tx = ty = 0; + rotate = (360 - state->getRotate()) % 360; + if (rotate == 0) { + } else if (rotate == 90) { + writePS("90 rotate\n"); + tx = -epsX1; + ty = -epsY2; + } else if (rotate == 180) { + writePS("180 rotate\n"); + tx = -(epsX1 + epsX2); + ty = -(epsY1 + epsY2); + } else { // rotate == 270 + writePS("270 rotate\n"); + tx = -epsX2; + ty = -epsY1; + } + if (tx != 0 || ty != 0) { + writePSFmt("{0:.6g} {1:.6g} translate\n", tx, ty); + } + break; + + case psModeForm: + writePS("/PaintProc {\n"); + writePS("begin xpdf begin\n"); + writePS("pdfStartPage\n"); + tx = ty = 0; + rotate = 0; + break; + } + + if (customCodeCbk) { + if ((s = (*customCodeCbk)(this, psOutCustomPageSetup, pageNum, + customCodeCbkData))) { + writePS(s->getCString()); + delete s; + } + } + + writePS("%%EndPageSetup\n"); +} + +void PSOutputDev::endPage() { + if (overlayCbk) { + restoreState(NULL); + (*overlayCbk)(this, overlayCbkData); + } + + + if (mode == psModeForm) { + writePS("pdfEndPage\n"); + writePS("end end\n"); + writePS("} def\n"); + writePS("end end\n"); + } else { + if (!manualCtrl) { + writePS("showpage\n"); + } + writePS("%%PageTrailer\n"); + writePageTrailer(); + } +} + +void PSOutputDev::saveState(GfxState *state) { + writePS("q\n"); + ++numSaves; +} + +void PSOutputDev::restoreState(GfxState *state) { + writePS("Q\n"); + --numSaves; +} + +void PSOutputDev::updateCTM(GfxState *state, double m11, double m12, + double m21, double m22, double m31, double m32) { + writePSFmt("[{0:.6gs} {1:.6gs} {2:.6gs} {3:.6gs} {4:.6gs} {5:.6gs}] cm\n", + m11, m12, m21, m22, m31, m32); +} + +void PSOutputDev::updateLineDash(GfxState *state) { + double *dash; + double start; + int length, i; + + state->getLineDash(&dash, &length, &start); + writePS("["); + for (i = 0; i < length; ++i) { + writePSFmt("{0:.6g}{1:w}", + dash[i] < 0 ? 0 : dash[i], + (i == length-1) ? 0 : 1); + } + writePSFmt("] {0:.6g} d\n", start); +} + +void PSOutputDev::updateFlatness(GfxState *state) { + writePSFmt("{0:d} i\n", state->getFlatness()); +} + +void PSOutputDev::updateLineJoin(GfxState *state) { + writePSFmt("{0:d} j\n", state->getLineJoin()); +} + +void PSOutputDev::updateLineCap(GfxState *state) { + writePSFmt("{0:d} J\n", state->getLineCap()); +} + +void PSOutputDev::updateMiterLimit(GfxState *state) { + writePSFmt("{0:.6g} M\n", state->getMiterLimit()); +} + +void PSOutputDev::updateLineWidth(GfxState *state) { + writePSFmt("{0:.6g} w\n", state->getLineWidth()); +} + +void PSOutputDev::updateFillColorSpace(GfxState *state) { + if (inUncoloredPattern) { + return; + } + switch (level) { + case psLevel1: + case psLevel1Sep: + break; + case psLevel2: + case psLevel3: + if (state->getFillColorSpace()->getMode() != csPattern) { + dumpColorSpaceL2(state->getFillColorSpace(), gTrue, gFalse, gFalse); + writePS(" cs\n"); + } + break; + case psLevel2Sep: + case psLevel3Sep: + break; + } +} + +void PSOutputDev::updateStrokeColorSpace(GfxState *state) { + if (inUncoloredPattern) { + return; + } + switch (level) { + case psLevel1: + case psLevel1Sep: + break; + case psLevel2: + case psLevel3: + if (state->getStrokeColorSpace()->getMode() != csPattern) { + dumpColorSpaceL2(state->getStrokeColorSpace(), gTrue, gFalse, gFalse); + writePS(" CS\n"); + } + break; + case psLevel2Sep: + case psLevel3Sep: + break; + } +} + +void PSOutputDev::updateFillColor(GfxState *state) { + GfxColor color; + GfxColor *colorPtr; + GfxGray gray; + GfxCMYK cmyk; + GfxSeparationColorSpace *sepCS; + double c, m, y, k; + int i; + + if (inUncoloredPattern) { + return; + } + switch (level) { + case psLevel1: + state->getFillGray(&gray); + writePSFmt("{0:.4g} g\n", colToDbl(gray)); + break; + case psLevel1Sep: + state->getFillCMYK(&cmyk); + c = colToDbl(cmyk.c); + m = colToDbl(cmyk.m); + y = colToDbl(cmyk.y); + k = colToDbl(cmyk.k); + writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} k\n", c, m, y, k); + addProcessColor(c, m, y, k); + break; + case psLevel2: + case psLevel3: + if (state->getFillColorSpace()->getMode() != csPattern) { + colorPtr = state->getFillColor(); + writePS("["); + for (i = 0; i < state->getFillColorSpace()->getNComps(); ++i) { + if (i > 0) { + writePS(" "); + } + writePSFmt("{0:.4g}", colToDbl(colorPtr->c[i])); + } + writePS("] sc\n"); + } + break; + case psLevel2Sep: + case psLevel3Sep: + if (state->getFillColorSpace()->getMode() == csSeparation) { + sepCS = (GfxSeparationColorSpace *)state->getFillColorSpace(); + color.c[0] = gfxColorComp1; + sepCS->getCMYK(&color, &cmyk); + writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} {4:.4g} ({5:t}) ck\n", + colToDbl(state->getFillColor()->c[0]), + colToDbl(cmyk.c), colToDbl(cmyk.m), + colToDbl(cmyk.y), colToDbl(cmyk.k), + sepCS->getName()); + addCustomColor(sepCS); + } else { + state->getFillCMYK(&cmyk); + c = colToDbl(cmyk.c); + m = colToDbl(cmyk.m); + y = colToDbl(cmyk.y); + k = colToDbl(cmyk.k); + writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} k\n", c, m, y, k); + addProcessColor(c, m, y, k); + } + break; + } + t3Cacheable = gFalse; +} + +void PSOutputDev::updateStrokeColor(GfxState *state) { + GfxColor color; + GfxColor *colorPtr; + GfxGray gray; + GfxCMYK cmyk; + GfxSeparationColorSpace *sepCS; + double c, m, y, k; + int i; + + if (inUncoloredPattern) { + return; + } + switch (level) { + case psLevel1: + state->getStrokeGray(&gray); + writePSFmt("{0:.4g} G\n", colToDbl(gray)); + break; + case psLevel1Sep: + state->getStrokeCMYK(&cmyk); + c = colToDbl(cmyk.c); + m = colToDbl(cmyk.m); + y = colToDbl(cmyk.y); + k = colToDbl(cmyk.k); + writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} K\n", c, m, y, k); + addProcessColor(c, m, y, k); + break; + case psLevel2: + case psLevel3: + if (state->getStrokeColorSpace()->getMode() != csPattern) { + colorPtr = state->getStrokeColor(); + writePS("["); + for (i = 0; i < state->getStrokeColorSpace()->getNComps(); ++i) { + if (i > 0) { + writePS(" "); + } + writePSFmt("{0:.4g}", colToDbl(colorPtr->c[i])); + } + writePS("] SC\n"); + } + break; + case psLevel2Sep: + case psLevel3Sep: + if (state->getStrokeColorSpace()->getMode() == csSeparation) { + sepCS = (GfxSeparationColorSpace *)state->getStrokeColorSpace(); + color.c[0] = gfxColorComp1; + sepCS->getCMYK(&color, &cmyk); + writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} {4:.4g} ({5:t}) CK\n", + colToDbl(state->getStrokeColor()->c[0]), + colToDbl(cmyk.c), colToDbl(cmyk.m), + colToDbl(cmyk.y), colToDbl(cmyk.k), + sepCS->getName()); + addCustomColor(sepCS); + } else { + state->getStrokeCMYK(&cmyk); + c = colToDbl(cmyk.c); + m = colToDbl(cmyk.m); + y = colToDbl(cmyk.y); + k = colToDbl(cmyk.k); + writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} K\n", c, m, y, k); + addProcessColor(c, m, y, k); + } + break; + } + t3Cacheable = gFalse; +} + +void PSOutputDev::addProcessColor(double c, double m, double y, double k) { + if (c > 0) { + processColors |= psProcessCyan; + } + if (m > 0) { + processColors |= psProcessMagenta; + } + if (y > 0) { + processColors |= psProcessYellow; + } + if (k > 0) { + processColors |= psProcessBlack; + } +} + +void PSOutputDev::addCustomColor(GfxSeparationColorSpace *sepCS) { + PSOutCustomColor *cc; + GfxColor color; + GfxCMYK cmyk; + + if (!sepCS->getName()->cmp("Black")) { + processColors |= psProcessBlack; + return; + } + if (!sepCS->getName()->cmp("Cyan")) { + processColors |= psProcessCyan; + return; + } + if (!sepCS->getName()->cmp("Yellow")) { + processColors |= psProcessYellow; + return; + } + if (!sepCS->getName()->cmp("Magenta")) { + processColors |= psProcessMagenta; + return; + } + if (!sepCS->getName()->cmp("All")) + return; + if (!sepCS->getName()->cmp("None")) + return; + for (cc = customColors; cc; cc = cc->next) { + if (!cc->name->cmp(sepCS->getName())) { + return; + } + } + color.c[0] = gfxColorComp1; + sepCS->getCMYK(&color, &cmyk); + cc = new PSOutCustomColor(colToDbl(cmyk.c), colToDbl(cmyk.m), + colToDbl(cmyk.y), colToDbl(cmyk.k), + sepCS->getName()->copy()); + cc->next = customColors; + customColors = cc; +} + +void PSOutputDev::updateFillOverprint(GfxState *state) { + if (level >= psLevel2) { + writePSFmt("{0:s} op\n", state->getFillOverprint() ? "true" : "false"); + } +} + +void PSOutputDev::updateStrokeOverprint(GfxState *state) { + if (level >= psLevel2) { + writePSFmt("{0:s} OP\n", state->getStrokeOverprint() ? "true" : "false"); + } +} + +void PSOutputDev::updateOverprintMode(GfxState *state) { + if (level >= psLevel3) { + writePSFmt("{0:s} opm\n", state->getOverprintMode() ? "true" : "false"); + } +} + +void PSOutputDev::updateTransfer(GfxState *state) { + Function **funcs; + int i; + + funcs = state->getTransfer(); + if (funcs[0] && funcs[1] && funcs[2] && funcs[3]) { + if (level >= psLevel2) { + for (i = 0; i < 4; ++i) { + cvtFunction(funcs[i]); + } + writePS("setcolortransfer\n"); + } else { + cvtFunction(funcs[3]); + writePS("settransfer\n"); + } + } else if (funcs[0]) { + cvtFunction(funcs[0]); + writePS("settransfer\n"); + } else { + writePS("{} settransfer\n"); + } +} + +void PSOutputDev::updateFont(GfxState *state) { + if (state->getFont()) { + writePSFmt("/F{0:d}_{1:d} {2:.6g} Tf\n", + state->getFont()->getID()->num, state->getFont()->getID()->gen, + fabs(state->getFontSize()) < 0.0001 ? 0.0001 + : state->getFontSize()); + } +} + +void PSOutputDev::updateTextMat(GfxState *state) { + double *mat; + + mat = state->getTextMat(); + if (fabs(mat[0] * mat[3] - mat[1] * mat[2]) < 0.00001) { + // avoid a singular (or close-to-singular) matrix + writePSFmt("[0.00001 0 0 0.00001 {0:.6g} {1:.6g}] Tm\n", mat[4], mat[5]); + } else { + writePSFmt("[{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g}] Tm\n", + mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]); + } +} + +void PSOutputDev::updateCharSpace(GfxState *state) { + writePSFmt("{0:.6g} Tc\n", state->getCharSpace()); +} + +void PSOutputDev::updateRender(GfxState *state) { + int rm; + + rm = state->getRender(); + writePSFmt("{0:d} Tr\n", rm); + rm &= 3; + if (rm != 0 && rm != 3) { + t3Cacheable = gFalse; + } +} + +void PSOutputDev::updateRise(GfxState *state) { + writePSFmt("{0:.6g} Ts\n", state->getRise()); +} + +void PSOutputDev::updateWordSpace(GfxState *state) { + writePSFmt("{0:.6g} Tw\n", state->getWordSpace()); +} + +void PSOutputDev::updateHorizScaling(GfxState *state) { + double h; + + h = state->getHorizScaling(); + if (fabs(h) < 0.01) { + h = 0.01; + } + writePSFmt("{0:.6g} Tz\n", h); +} + +void PSOutputDev::updateTextPos(GfxState *state) { + writePSFmt("{0:.6g} {1:.6g} Td\n", state->getLineX(), state->getLineY()); +} + +void PSOutputDev::updateTextShift(GfxState *state, double shift) { + if (state->getFont()->getWMode()) { + writePSFmt("{0:.6g} TJmV\n", shift); + } else { + writePSFmt("{0:.6g} TJm\n", shift); + } +} + +void PSOutputDev::saveTextPos(GfxState *state) { + writePS("currentpoint\n"); +} + +void PSOutputDev::restoreTextPos(GfxState *state) { + writePS("m\n"); +} + +void PSOutputDev::stroke(GfxState *state) { + doPath(state->getPath()); + if (inType3Char && t3FillColorOnly) { + // if we're construct a cacheable Type 3 glyph, we need to do + // everything in the fill color + writePS("Sf\n"); + } else { + writePS("S\n"); + } +} + +void PSOutputDev::fill(GfxState *state) { + doPath(state->getPath()); + writePS("f\n"); +} + +void PSOutputDev::eoFill(GfxState *state) { + doPath(state->getPath()); + writePS("f*\n"); +} + +GBool PSOutputDev::tilingPatternFillL1(GfxState *state, Catalog *cat, Object *str, + double *pmat, int paintType, int tilingType, Dict *resDict, + double *mat, double *bbox, + int x0, int y0, int x1, int y1, + double xStep, double yStep) { + PDFRectangle box; + Gfx *gfx; + + // define a Type 3 font + writePS("8 dict begin\n"); + writePS("/FontType 3 def\n"); + writePS("/FontMatrix [1 0 0 1 0 0] def\n"); + writePSFmt("/FontBBox [{0:.6g} {1:.6g} {2:.6g} {3:.6g}] def\n", + bbox[0], bbox[1], bbox[2], bbox[3]); + writePS("/Encoding 256 array def\n"); + writePS(" 0 1 255 { Encoding exch /.notdef put } for\n"); + writePS(" Encoding 120 /x put\n"); + writePS("/BuildGlyph {\n"); + writePS(" exch /CharProcs get exch\n"); + writePS(" 2 copy known not { pop /.notdef } if\n"); + writePS(" get exec\n"); + writePS("} bind def\n"); + writePS("/BuildChar {\n"); + writePS(" 1 index /Encoding get exch get\n"); + writePS(" 1 index /BuildGlyph get exec\n"); + writePS("} bind def\n"); + writePS("/CharProcs 1 dict def\n"); + writePS("CharProcs begin\n"); + box.x1 = bbox[0]; + box.y1 = bbox[1]; + box.x2 = bbox[2]; + box.y2 = bbox[3]; + gfx = new Gfx(doc, this, resDict, &box, NULL); + writePS("/x {\n"); + if (paintType == 2) { + writePSFmt("{0:.6g} 0 {1:.6g} {2:.6g} {3:.6g} {4:.6g} setcachedevice\n", + xStep, bbox[0], bbox[1], bbox[2], bbox[3]); + t3FillColorOnly = gTrue; + } else + { + if (x1 - 1 <= x0) { + writePS("1 0 setcharwidth\n"); + } else { + writePSFmt("{0:.6g} 0 setcharwidth\n", xStep); + } + t3FillColorOnly = gFalse; + } + inType3Char = gTrue; + if (paintType == 2) { + inUncoloredPattern = gTrue; + // ensure any PS procedures that contain sCol or fCol do not change the color + writePS("/pdfLastFill true def\n"); + writePS("/pdfLastStroke true def\n"); + } + ++numTilingPatterns; + gfx->display(str); + --numTilingPatterns; + if (paintType == 2) { + inUncoloredPattern = gFalse; + // ensure the next PS procedures that uses sCol or fCol will update the color + writePS("/pdfLastFill false def\n"); + writePS("/pdfLastStroke false def\n"); + } + inType3Char = gFalse; + writePS("} def\n"); + delete gfx; + writePS("end\n"); + writePS("currentdict end\n"); + writePSFmt("/xpdfTile{0:d} exch definefont pop\n", numTilingPatterns); + + // draw the tiles + writePSFmt("/xpdfTile{0:d} findfont setfont\n", numTilingPatterns); + writePS("fCol\n"); + writePSFmt("gsave [{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g}] concat\n", + mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]); + writePSFmt("{0:d} 1 {1:d} {{ {2:.6g} exch {3:.6g} mul m {4:d} 1 {5:d} {{ pop (x) show }} for }} for\n", + y0, y1 - 1, x0 * xStep, yStep, x0, x1 - 1); + writePS("grestore\n"); + + return gTrue; +} + +GBool PSOutputDev::tilingPatternFillL2(GfxState *state, Catalog *cat, Object *str, + double *pmat, int paintType, int tilingType, Dict *resDict, + double *mat, double *bbox, + int x0, int y0, int x1, int y1, + double xStep, double yStep) { + PDFRectangle box; + Gfx *gfx; + + if (paintType == 2) { + // setpattern with PaintType 2 needs the paint color + writePS("currentcolor\n"); + } + writePS("<<\n /PatternType 1\n"); + writePSFmt(" /PaintType {0:d}\n", paintType); + writePSFmt(" /TilingType {0:d}\n", tilingType); + writePSFmt(" /BBox [{0:.6g} {1:.6g} {2:.6g} {3:.6g}]\n", bbox[0], bbox[1], bbox[2], bbox[3]); + writePSFmt(" /XStep {0:.6g}\n", xStep); + writePSFmt(" /YStep {0:.6g}\n", yStep); + writePS(" /PaintProc { \n"); + box.x1 = bbox[0]; + box.y1 = bbox[1]; + box.x2 = bbox[2]; + box.y2 = bbox[3]; + gfx = new Gfx(doc, this, resDict, &box, NULL); + inType3Char = gTrue; + if (paintType == 2) { + inUncoloredPattern = gTrue; + // ensure any PS procedures that contain sCol or fCol do not change the color + writePS("/pdfLastFill true def\n"); + writePS("/pdfLastStroke true def\n"); + } + gfx->display(str); + if (paintType == 2) { + inUncoloredPattern = gFalse; + // ensure the next PS procedures that uses sCol or fCol will update the color + writePS("/pdfLastFill false def\n"); + writePS("/pdfLastStroke false def\n"); + } + inType3Char = gFalse; + delete gfx; + writePS(" }\n"); + writePS(">>\n"); + writePSFmt("[{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g}]\n", mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]); + writePS("makepattern setpattern\n"); + writePS("clippath fill\n"); // Gfx sets up a clip before calling out->tilingPatternFill() + + return gTrue; +} + +GBool PSOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *cat, Object *str, + double *pmat, int paintType, int tilingType, Dict *resDict, + double *mat, double *bbox, + int x0, int y0, int x1, int y1, + double xStep, double yStep) { + if (x1 - x0 == 1 && y1 - y0 == 1) { + // Don't need to use patterns if only one instance of the pattern is used + PDFRectangle box; + Gfx *gfx; + double x, y, tx, ty; + + x = x0 * xStep; + y = y0 * yStep; + tx = x * mat[0] + y * mat[2] + mat[4]; + ty = x * mat[1] + y * mat[3] + mat[5]; + box.x1 = bbox[0]; + box.y1 = bbox[1]; + box.x2 = bbox[2]; + box.y2 = bbox[3]; + gfx = new Gfx(doc, this, resDict, &box, NULL, NULL, NULL, gfxA->getXRef()); + writePSFmt("[{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g}] cm\n", mat[0], mat[1], mat[2], mat[3], tx, ty); + inType3Char = gTrue; + gfx->display(str); + inType3Char = gFalse; + delete gfx; + return gTrue; + } + + if (level == psLevel1 || level == psLevel1Sep) { + return tilingPatternFillL1(state, cat, str, pmat, paintType, tilingType, resDict, + mat, bbox, x0, y0, x1, y1, xStep, yStep); + } else { + return tilingPatternFillL2(state, cat, str, pmat, paintType, tilingType, resDict, + mat, bbox, x0, y0, x1, y1, xStep, yStep); + } +} + +GBool PSOutputDev::functionShadedFill(GfxState *state, + GfxFunctionShading *shading) { + double x0, y0, x1, y1; + double *mat; + int i; + + if (level == psLevel2Sep || level == psLevel3Sep) { + if (shading->getColorSpace()->getMode() != csDeviceCMYK) { + return gFalse; + } + processColors |= psProcessCMYK; + } + + shading->getDomain(&x0, &y0, &x1, &y1); + mat = shading->getMatrix(); + writePSFmt("/mat [{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g}] def\n", + mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]); + writePSFmt("/n {0:d} def\n", shading->getColorSpace()->getNComps()); + if (shading->getNFuncs() == 1) { + writePS("/func "); + cvtFunction(shading->getFunc(0)); + writePS("def\n"); + } else { + writePS("/func {\n"); + for (i = 0; i < shading->getNFuncs(); ++i) { + if (i < shading->getNFuncs() - 1) { + writePS("2 copy\n"); + } + cvtFunction(shading->getFunc(i)); + writePS("exec\n"); + if (i < shading->getNFuncs() - 1) { + writePS("3 1 roll\n"); + } + } + writePS("} def\n"); + } + writePSFmt("{0:.6g} {1:.6g} {2:.6g} {3:.6g} 0 funcSH\n", x0, y0, x1, y1); + + return gTrue; +} + +GBool PSOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading, double /*tMin*/, double /*tMax*/) { + double xMin, yMin, xMax, yMax; + double x0, y0, x1, y1, dx, dy, mul; + double tMin, tMax, t, t0, t1; + int i; + + if (level == psLevel2Sep || level == psLevel3Sep) { + if (shading->getColorSpace()->getMode() != csDeviceCMYK) { + return gFalse; + } + processColors |= psProcessCMYK; + } + + // get the clip region bbox + state->getUserClipBBox(&xMin, &yMin, &xMax, &yMax); + + // compute min and max t values, based on the four corners of the + // clip region bbox + shading->getCoords(&x0, &y0, &x1, &y1); + dx = x1 - x0; + dy = y1 - y0; + if (fabs(dx) < 0.01 && fabs(dy) < 0.01) { + return gTrue; + } else { + mul = 1 / (dx * dx + dy * dy); + tMin = tMax = ((xMin - x0) * dx + (yMin - y0) * dy) * mul; + t = ((xMin - x0) * dx + (yMax - y0) * dy) * mul; + if (t < tMin) { + tMin = t; + } else if (t > tMax) { + tMax = t; + } + t = ((xMax - x0) * dx + (yMin - y0) * dy) * mul; + if (t < tMin) { + tMin = t; + } else if (t > tMax) { + tMax = t; + } + t = ((xMax - x0) * dx + (yMax - y0) * dy) * mul; + if (t < tMin) { + tMin = t; + } else if (t > tMax) { + tMax = t; + } + if (tMin < 0 && !shading->getExtend0()) { + tMin = 0; + } + if (tMax > 1 && !shading->getExtend1()) { + tMax = 1; + } + } + + // get the function domain + t0 = shading->getDomain0(); + t1 = shading->getDomain1(); + + // generate the PS code + writePSFmt("/t0 {0:.6g} def\n", t0); + writePSFmt("/t1 {0:.6g} def\n", t1); + writePSFmt("/dt {0:.6g} def\n", t1 - t0); + writePSFmt("/x0 {0:.6g} def\n", x0); + writePSFmt("/y0 {0:.6g} def\n", y0); + writePSFmt("/dx {0:.6g} def\n", x1 - x0); + writePSFmt("/x1 {0:.6g} def\n", x1); + writePSFmt("/y1 {0:.6g} def\n", y1); + writePSFmt("/dy {0:.6g} def\n", y1 - y0); + writePSFmt("/xMin {0:.6g} def\n", xMin); + writePSFmt("/yMin {0:.6g} def\n", yMin); + writePSFmt("/xMax {0:.6g} def\n", xMax); + writePSFmt("/yMax {0:.6g} def\n", yMax); + writePSFmt("/n {0:d} def\n", shading->getColorSpace()->getNComps()); + if (shading->getNFuncs() == 1) { + writePS("/func "); + cvtFunction(shading->getFunc(0)); + writePS("def\n"); + } else { + writePS("/func {\n"); + for (i = 0; i < shading->getNFuncs(); ++i) { + if (i < shading->getNFuncs() - 1) { + writePS("dup\n"); + } + cvtFunction(shading->getFunc(i)); + writePS("exec\n"); + if (i < shading->getNFuncs() - 1) { + writePS("exch\n"); + } + } + writePS("} def\n"); + } + writePSFmt("{0:.6g} {1:.6g} 0 axialSH\n", tMin, tMax); + + return gTrue; +} + +GBool PSOutputDev::radialShadedFill(GfxState *state, GfxRadialShading *shading, double /*sMin*/, double /*sMax*/) { + double xMin, yMin, xMax, yMax; + double x0, y0, r0, x1, y1, r1, t0, t1; + double xa, ya, ra; + double sMin, sMax, h, ta; + double sLeft, sRight, sTop, sBottom, sZero, sDiag; + GBool haveSLeft, haveSRight, haveSTop, haveSBottom, haveSZero; + GBool haveSMin, haveSMax; + double theta, alpha, a1, a2; + GBool enclosed; + int i; + + if (level == psLevel2Sep || level == psLevel3Sep) { + if (shading->getColorSpace()->getMode() != csDeviceCMYK) { + return gFalse; + } + processColors |= psProcessCMYK; + } + + // get the shading info + shading->getCoords(&x0, &y0, &r0, &x1, &y1, &r1); + t0 = shading->getDomain0(); + t1 = shading->getDomain1(); + + // Compute the point at which r(s) = 0; check for the enclosed + // circles case; and compute the angles for the tangent lines. + // Compute the point at which r(s) = 0; check for the enclosed + // circles case; and compute the angles for the tangent lines. + h = sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)); + if (h == 0) { + enclosed = gTrue; + theta = 0; // make gcc happy + } else if (r1 - r0 == 0) { + enclosed = gFalse; + theta = 0; + } else if (fabs(r1 - r0) >= h) { + enclosed = gTrue; + theta = 0; // make gcc happy + } else { + enclosed = gFalse; + theta = asin((r1 - r0) / h); + } + if (enclosed) { + a1 = 0; + a2 = 360; + } else { + alpha = atan2(y1 - y0, x1 - x0); + a1 = (180 / M_PI) * (alpha + theta) + 90; + a2 = (180 / M_PI) * (alpha - theta) - 90; + while (a2 < a1) { + a2 += 360; + } + } + + // compute the (possibly extended) s range + state->getUserClipBBox(&xMin, &yMin, &xMax, &yMax); + if (enclosed) { + sMin = 0; + sMax = 1; + } else { + // solve x(sLeft) + r(sLeft) = xMin + if ((haveSLeft = fabs((x1 + r1) - (x0 + r0)) > 0.000001)) { + sLeft = (xMin - (x0 + r0)) / ((x1 + r1) - (x0 + r0)); + } else { + sLeft = 0; // make gcc happy + } + // solve x(sRight) - r(sRight) = xMax + if ((haveSRight = fabs((x1 - r1) - (x0 - r0)) > 0.000001)) { + sRight = (xMax - (x0 - r0)) / ((x1 - r1) - (x0 - r0)); + } else { + sRight = 0; // make gcc happy + } + // solve y(sBottom) + r(sBottom) = yMin + if ((haveSBottom = fabs((y1 + r1) - (y0 + r0)) > 0.000001)) { + sBottom = (yMin - (y0 + r0)) / ((y1 + r1) - (y0 + r0)); + } else { + sBottom = 0; // make gcc happy + } + // solve y(sTop) - r(sTop) = yMax + if ((haveSTop = fabs((y1 - r1) - (y0 - r0)) > 0.000001)) { + sTop = (yMax - (y0 - r0)) / ((y1 - r1) - (y0 - r0)); + } else { + sTop = 0; // make gcc happy + } + // solve r(sZero) = 0 + if ((haveSZero = fabs(r1 - r0) > 0.000001)) { + sZero = -r0 / (r1 - r0); + } else { + sZero = 0; // make gcc happy + } + // solve r(sDiag) = sqrt((xMax-xMin)^2 + (yMax-yMin)^2) + if (haveSZero) { + sDiag = (sqrt((xMax - xMin) * (xMax - xMin) + + (yMax - yMin) * (yMax - yMin)) - r0) / (r1 - r0); + } else { + sDiag = 0; // make gcc happy + } + // compute sMin + if (shading->getExtend0()) { + sMin = 0; + haveSMin = gFalse; + if (x0 < x1 && haveSLeft && sLeft < 0) { + sMin = sLeft; + haveSMin = gTrue; + } else if (x0 > x1 && haveSRight && sRight < 0) { + sMin = sRight; + haveSMin = gTrue; + } + if (y0 < y1 && haveSBottom && sBottom < 0) { + if (!haveSMin || sBottom > sMin) { + sMin = sBottom; + haveSMin = gTrue; + } + } else if (y0 > y1 && haveSTop && sTop < 0) { + if (!haveSMin || sTop > sMin) { + sMin = sTop; + haveSMin = gTrue; + } + } + if (haveSZero && sZero < 0) { + if (!haveSMin || sZero > sMin) { + sMin = sZero; + } + } + } else { + sMin = 0; + } + // compute sMax + if (shading->getExtend1()) { + sMax = 1; + haveSMax = gFalse; + if (x1 < x0 && haveSLeft && sLeft > 1) { + sMax = sLeft; + haveSMax = gTrue; + } else if (x1 > x0 && haveSRight && sRight > 1) { + sMax = sRight; + haveSMax = gTrue; + } + if (y1 < y0 && haveSBottom && sBottom > 1) { + if (!haveSMax || sBottom < sMax) { + sMax = sBottom; + haveSMax = gTrue; + } + } else if (y1 > y0 && haveSTop && sTop > 1) { + if (!haveSMax || sTop < sMax) { + sMax = sTop; + haveSMax = gTrue; + } + } + if (haveSZero && sDiag > 1) { + if (!haveSMax || sDiag < sMax) { + sMax = sDiag; + } + } + } else { + sMax = 1; + } + } + + // generate the PS code + writePSFmt("/x0 {0:.6g} def\n", x0); + writePSFmt("/x1 {0:.6g} def\n", x1); + writePSFmt("/dx {0:.6g} def\n", x1 - x0); + writePSFmt("/y0 {0:.6g} def\n", y0); + writePSFmt("/y1 {0:.6g} def\n", y1); + writePSFmt("/dy {0:.6g} def\n", y1 - y0); + writePSFmt("/r0 {0:.6g} def\n", r0); + writePSFmt("/r1 {0:.6g} def\n", r1); + writePSFmt("/dr {0:.6g} def\n", r1 - r0); + writePSFmt("/t0 {0:.6g} def\n", t0); + writePSFmt("/t1 {0:.6g} def\n", t1); + writePSFmt("/dt {0:.6g} def\n", t1 - t0); + writePSFmt("/n {0:d} def\n", shading->getColorSpace()->getNComps()); + writePSFmt("/encl {0:s} def\n", enclosed ? "true" : "false"); + writePSFmt("/a1 {0:.6g} def\n", a1); + writePSFmt("/a2 {0:.6g} def\n", a2); + if (shading->getNFuncs() == 1) { + writePS("/func "); + cvtFunction(shading->getFunc(0)); + writePS("def\n"); + } else { + writePS("/func {\n"); + for (i = 0; i < shading->getNFuncs(); ++i) { + if (i < shading->getNFuncs() - 1) { + writePS("dup\n"); + } + cvtFunction(shading->getFunc(i)); + writePS("exec\n"); + if (i < shading->getNFuncs() - 1) { + writePS("exch\n"); + } + } + writePS("} def\n"); + } + writePSFmt("{0:.6g} {1:.6g} 0 radialSH\n", sMin, sMax); + + // extend the 'enclosed' case + if (enclosed) { + // extend the smaller circle + if ((shading->getExtend0() && r0 <= r1) || + (shading->getExtend1() && r1 < r0)) { + if (r0 <= r1) { + ta = t0; + ra = r0; + xa = x0; + ya = y0; + } else { + ta = t1; + ra = r1; + xa = x1; + ya = y1; + } + if (level == psLevel2Sep || level == psLevel3Sep) { + writePSFmt("{0:.6g} radialCol aload pop k\n", ta); + } else { + writePSFmt("{0:.6g} radialCol sc\n", ta); + } + writePSFmt("{0:.6g} {1:.6g} {2:.6g} 0 360 arc h f*\n", xa, ya, ra); + } + + // extend the larger circle + if ((shading->getExtend0() && r0 > r1) || + (shading->getExtend1() && r1 >= r0)) { + if (r0 > r1) { + ta = t0; + ra = r0; + xa = x0; + ya = y0; + } else { + ta = t1; + ra = r1; + xa = x1; + ya = y1; + } + if (level == psLevel2Sep || level == psLevel3Sep) { + writePSFmt("{0:.6g} radialCol aload pop k\n", ta); + } else { + writePSFmt("{0:.6g} radialCol sc\n", ta); + } + writePSFmt("{0:.6g} {1:.6g} {2:.6g} 0 360 arc h\n", xa, ya, ra); + writePSFmt("{0:.6g} {1:.6g} m {2:.6g} {3:.6g} l {4:.6g} {5:.6g} l {6:.6g} {7:.6g} l h f*\n", + xMin, yMin, xMin, yMax, xMax, yMax, xMax, yMin); + } + } + + return gTrue; +} + +void PSOutputDev::clip(GfxState *state) { + doPath(state->getPath()); + writePS("W\n"); +} + +void PSOutputDev::eoClip(GfxState *state) { + doPath(state->getPath()); + writePS("W*\n"); +} + +void PSOutputDev::clipToStrokePath(GfxState *state) { + doPath(state->getPath()); + writePS("Ws\n"); +} + +void PSOutputDev::doPath(GfxPath *path) { + GfxSubpath *subpath; + double x0, y0, x1, y1, x2, y2, x3, y3, x4, y4; + int n, m, i, j; + + n = path->getNumSubpaths(); + + if (n == 1 && path->getSubpath(0)->getNumPoints() == 5) { + subpath = path->getSubpath(0); + x0 = subpath->getX(0); + y0 = subpath->getY(0); + x4 = subpath->getX(4); + y4 = subpath->getY(4); + if (x4 == x0 && y4 == y0) { + x1 = subpath->getX(1); + y1 = subpath->getY(1); + x2 = subpath->getX(2); + y2 = subpath->getY(2); + x3 = subpath->getX(3); + y3 = subpath->getY(3); + if (x0 == x1 && x2 == x3 && y0 == y3 && y1 == y2) { + writePSFmt("{0:.6g} {1:.6g} {2:.6g} {3:.6g} re\n", + x0 < x2 ? x0 : x2, y0 < y1 ? y0 : y1, + fabs(x2 - x0), fabs(y1 - y0)); + return; + } else if (x0 == x3 && x1 == x2 && y0 == y1 && y2 == y3) { + writePSFmt("{0:.6g} {1:.6g} {2:.6g} {3:.6g} re\n", + x0 < x1 ? x0 : x1, y0 < y2 ? y0 : y2, + fabs(x1 - x0), fabs(y2 - y0)); + return; + } + } + } + + for (i = 0; i < n; ++i) { + subpath = path->getSubpath(i); + m = subpath->getNumPoints(); + writePSFmt("{0:.6g} {1:.6g} m\n", subpath->getX(0), subpath->getY(0)); + j = 1; + while (j < m) { + if (subpath->getCurve(j)) { + writePSFmt("{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g} c\n", + subpath->getX(j), subpath->getY(j), + subpath->getX(j+1), subpath->getY(j+1), + subpath->getX(j+2), subpath->getY(j+2)); + j += 3; + } else { + writePSFmt("{0:.6g} {1:.6g} l\n", subpath->getX(j), subpath->getY(j)); + ++j; + } + } + if (subpath->isClosed()) { + writePS("h\n"); + } + } +} + +void PSOutputDev::drawString(GfxState *state, GooString *s) { + GfxFont *font; + int wMode; + int *codeToGID; + GooString *s2; + double dx, dy, originX, originY; + char *p; + UnicodeMap *uMap; + CharCode code; + Unicode *u; + char buf[8]; + double *dxdy; + int dxdySize, len, nChars, uLen, n, m, i, j; + + // for pdftohtml, output PS without text + if( displayText == gFalse ) + return; + + // check for invisible text -- this is used by Acrobat Capture + if (state->getRender() == 3) { + return; + } + + // ignore empty strings + if (s->getLength() == 0) { + return; + } + + // get the font + if (!(font = state->getFont())) { + return; + } + wMode = font->getWMode(); + + // check for a subtitute 16-bit font + uMap = NULL; + codeToGID = NULL; + if (font->isCIDFont()) { + for (i = 0; i < font16EncLen; ++i) { + if (font->getID()->num == font16Enc[i].fontID.num && + font->getID()->gen == font16Enc[i].fontID.gen) { + if (!font16Enc[i].enc) { + // font substitution failed, so don't output any text + return; + } + uMap = globalParams->getUnicodeMap(font16Enc[i].enc); + break; + } + } + + // check for a code-to-GID map + } else { + for (i = 0; i < font8InfoLen; ++i) { + if (font->getID()->num == font8Info[i].fontID.num && + font->getID()->gen == font8Info[i].fontID.gen) { + codeToGID = font8Info[i].codeToGID; + break; + } + } + } + + // compute the positioning (dx, dy) for each char in the string + nChars = 0; + p = s->getCString(); + len = s->getLength(); + s2 = new GooString(); + dxdySize = font->isCIDFont() ? 8 : s->getLength(); + dxdy = (double *)gmallocn(2 * dxdySize, sizeof(double)); + while (len > 0) { + n = font->getNextChar(p, len, &code, + &u, &uLen, + &dx, &dy, &originX, &originY); + dx *= state->getFontSize(); + dy *= state->getFontSize(); + if (wMode) { + dy += state->getCharSpace(); + if (n == 1 && *p == ' ') { + dy += state->getWordSpace(); + } + } else { + dx += state->getCharSpace(); + if (n == 1 && *p == ' ') { + dx += state->getWordSpace(); + } + } + dx *= state->getHorizScaling(); + if (font->isCIDFont()) { + if (uMap) { + if (nChars + uLen > dxdySize) { + do { + dxdySize *= 2; + } while (nChars + uLen > dxdySize); + dxdy = (double *)greallocn(dxdy, 2 * dxdySize, sizeof(double)); + } + for (i = 0; i < uLen; ++i) { + m = uMap->mapUnicode(u[i], buf, (int)sizeof(buf)); + for (j = 0; j < m; ++j) { + s2->append(buf[j]); + } + //~ this really needs to get the number of chars in the target + //~ encoding - which may be more than the number of Unicode + //~ chars + dxdy[2 * nChars] = dx; + dxdy[2 * nChars + 1] = dy; + ++nChars; + } + } else { + if (nChars + 1 > dxdySize) { + dxdySize *= 2; + dxdy = (double *)greallocn(dxdy, 2 * dxdySize, sizeof(double)); + } + s2->append((char)((code >> 8) & 0xff)); + s2->append((char)(code & 0xff)); + dxdy[2 * nChars] = dx; + dxdy[2 * nChars + 1] = dy; + ++nChars; + } + } else { + if (!codeToGID || codeToGID[code] >= 0) { + s2->append((char)code); + dxdy[2 * nChars] = dx; + dxdy[2 * nChars + 1] = dy; + ++nChars; + } + } + p += n; + len -= n; + } + if (uMap) { + uMap->decRefCnt(); + } + + if (nChars > 0) { + writePSString(s2); + writePS("\n["); + for (i = 0; i < 2 * nChars; ++i) { + if (i > 0) { + writePS("\n"); + } + writePSFmt("{0:.6g}", dxdy[i]); + } + writePS("] Tj\n"); + } + gfree(dxdy); + delete s2; + + if (state->getRender() & 4) { + haveTextClip = gTrue; + } +} + +void PSOutputDev::beginTextObject(GfxState *state) { +} + +void PSOutputDev::endTextObject(GfxState *state) { + if (haveTextClip) { + writePS("Tclip\n"); + haveTextClip = gFalse; + } +} + +void PSOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, + int width, int height, GBool invert, + GBool interpolate, GBool inlineImg) { + int len; + + len = height * ((width + 7) / 8); + switch (level) { + case psLevel1: + case psLevel1Sep: + doImageL1(ref, NULL, invert, inlineImg, str, width, height, len, + NULL, NULL, 0, 0, gFalse); + break; + case psLevel2: + case psLevel2Sep: + doImageL2(ref, NULL, invert, inlineImg, str, width, height, len, + NULL, NULL, 0, 0, gFalse); + break; + case psLevel3: + case psLevel3Sep: + doImageL3(ref, NULL, invert, inlineImg, str, width, height, len, + NULL, NULL, 0, 0, gFalse); + break; + } +} + +void PSOutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, + int width, int height, GBool invert, + GBool inlineImg, double *baseMatrix) { + if (level != psLevel1 && level != psLevel1Sep) { + maskToClippingPath(str, width, height, invert); + } +} + +void PSOutputDev::unsetSoftMaskFromImageMask(GfxState * state, double *baseMatrix) { + if (level != psLevel1 && level != psLevel1Sep) { + writePS("pdfImClipEnd\n"); + } +} + +void PSOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, + int width, int height, GfxImageColorMap *colorMap, + GBool interpolate, int *maskColors, GBool inlineImg) { + int len; + + len = height * ((width * colorMap->getNumPixelComps() * + colorMap->getBits() + 7) / 8); + switch (level) { + case psLevel1: + doImageL1(ref, colorMap, gFalse, inlineImg, str, + width, height, len, maskColors, NULL, 0, 0, gFalse); + break; + case psLevel1Sep: + //~ handle indexed, separation, ... color spaces + doImageL1Sep(ref, colorMap, gFalse, inlineImg, str, + width, height, len, maskColors, NULL, 0, 0, gFalse); + break; + case psLevel2: + case psLevel2Sep: + doImageL2(ref, colorMap, gFalse, inlineImg, str, + width, height, len, maskColors, NULL, 0, 0, gFalse); + break; + case psLevel3: + case psLevel3Sep: + doImageL3(ref, colorMap, gFalse, inlineImg, str, + width, height, len, maskColors, NULL, 0, 0, gFalse); + break; + } + t3Cacheable = gFalse; +} + +void PSOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str, + int width, int height, + GfxImageColorMap *colorMap, + GBool interpolate, + Stream *maskStr, + int maskWidth, int maskHeight, + GBool maskInvert, GBool maskInterpolate) { + int len; + + len = height * ((width * colorMap->getNumPixelComps() * + colorMap->getBits() + 7) / 8); + switch (level) { + case psLevel1: + doImageL1(ref, colorMap, gFalse, gFalse, str, width, height, len, + NULL, maskStr, maskWidth, maskHeight, maskInvert); + break; + case psLevel1Sep: + //~ handle indexed, separation, ... color spaces + doImageL1Sep(ref, colorMap, gFalse, gFalse, str, width, height, len, + NULL, maskStr, maskWidth, maskHeight, maskInvert); + break; + case psLevel2: + case psLevel2Sep: + doImageL2(ref, colorMap, gFalse, gFalse, str, width, height, len, + NULL, maskStr, maskWidth, maskHeight, maskInvert); + break; + case psLevel3: + case psLevel3Sep: + doImageL3(ref, colorMap, gFalse, gFalse, str, width, height, len, + NULL, maskStr, maskWidth, maskHeight, maskInvert); + break; + } + t3Cacheable = gFalse; +} + +void PSOutputDev::doImageL1(Object *ref, GfxImageColorMap *colorMap, + GBool invert, GBool inlineImg, + Stream *str, int width, int height, int len, + int *maskColors, Stream *maskStr, + int maskWidth, int maskHeight, GBool maskInvert) { + ImageStream *imgStr; + Guchar pixBuf[gfxColorMaxComps]; + GfxGray gray; + int col, x, y, c, i; + char hexBuf[32*2 + 2]; // 32 values X 2 chars/value + line ending + null + Guchar digit, grayValue; + + // explicit masking + if (maskStr && !(maskColors && colorMap)) { + maskToClippingPath(maskStr, maskWidth, maskHeight, maskInvert); + } + + if ((inType3Char || preloadImagesForms) && !colorMap) { + if (inlineImg) { + // create an array + str = new FixedLengthEncoder(str, len); + str = new ASCIIHexEncoder(str); + str->reset(); + col = 0; + writePS("[<"); + do { + do { + c = str->getChar(); + } while (c == '\n' || c == '\r'); + if (c == '>' || c == EOF) { + break; + } + writePSChar(c); + ++col; + // each line is: "<...data...><eol>" + // so max data length = 255 - 4 = 251 + // but make it 240 just to be safe + // chunks are 2 bytes each, so we need to stop on an even col number + if (col == 240) { + writePS(">\n<"); + col = 0; + } + } while (c != '>' && c != EOF); + writePS(">]\n"); + writePS("0\n"); + str->close(); + delete str; + } else { + // make sure the image is setup, it sometimes is not like on bug #17645 + setupImage(ref->getRef(), str, gFalse); + // set up to use the array already created by setupImages() + writePSFmt("ImData_{0:d}_{1:d} 0 0\n", ref->getRefNum(), ref->getRefGen()); + } + } + + // image/imagemask command + if ((inType3Char || preloadImagesForms) && !colorMap) { + writePSFmt("{0:d} {1:d} {2:s} [{3:d} 0 0 {4:d} 0 {5:d}] pdfImM1a\n", + width, height, invert ? "true" : "false", + width, -height, height); + } else if (colorMap) { + writePSFmt("{0:d} {1:d} 8 [{2:d} 0 0 {3:d} 0 {4:d}] pdfIm1{5:s}\n", + width, height, + width, -height, height, + useBinary ? "Bin" : ""); + } else { + writePSFmt("{0:d} {1:d} {2:s} [{3:d} 0 0 {4:d} 0 {5:d}] pdfImM1{6:s}\n", + width, height, invert ? "true" : "false", + width, -height, height, + useBinary ? "Bin" : ""); + } + + // image data + if (!((inType3Char || preloadImagesForms) && !colorMap)) { + + if (colorMap) { + + // set up to process the data stream + imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(), + colorMap->getBits()); + imgStr->reset(); + + // process the data stream + i = 0; + for (y = 0; y < height; ++y) { + + // write the line + for (x = 0; x < width; ++x) { + imgStr->getPixel(pixBuf); + colorMap->getGray(pixBuf, &gray); + grayValue = colToByte(gray); + if (useBinary) { + hexBuf[i++] = grayValue; + } else { + digit = grayValue / 16; + hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); + digit = grayValue % 16; + hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); + } + if (i >= 64) { + if (!useBinary) { + hexBuf[i++] = '\n'; + } + writePSBuf(hexBuf, i); + i = 0; + } + } + } + if (i != 0) { + if (!useBinary) { + hexBuf[i++] = '\n'; + } + writePSBuf(hexBuf, i); + } + str->close(); + delete imgStr; + + // imagemask + } else { + str->reset(); + i = 0; + for (y = 0; y < height; ++y) { + for (x = 0; x < width; x += 8) { + grayValue = str->getChar(); + if (useBinary) { + hexBuf[i++] = grayValue; + } else { + digit = grayValue / 16; + hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); + digit = grayValue % 16; + hexBuf[i++] = digit + ((digit >= 10)? 'a' - 10: '0'); + } + if (i >= 64) { + if (!useBinary) { + hexBuf[i++] = '\n'; + } + writePSBuf(hexBuf, i); + i = 0; + } + } + } + if (i != 0) { + if (!useBinary) { + hexBuf[i++] = '\n'; + } + writePSBuf(hexBuf, i); + } + str->close(); + } + } + + if (maskStr && !(maskColors && colorMap)) { + writePS("pdfImClipEnd\n"); + } +} + +void PSOutputDev::doImageL1Sep(Object *ref, GfxImageColorMap *colorMap, + GBool invert, GBool inlineImg, + Stream *str, int width, int height, int len, + int *maskColors, Stream *maskStr, + int maskWidth, int maskHeight, GBool maskInvert) { + ImageStream *imgStr; + Guchar *lineBuf; + Guchar pixBuf[gfxColorMaxComps]; + GfxCMYK cmyk; + int x, y, i, comp; + GBool checkProcessColor; + char hexBuf[32*2 + 2]; // 32 values X 2 chars/value + line ending + null + Guchar digit; + + // explicit masking + if (maskStr && !(maskColors && colorMap)) { + maskToClippingPath(maskStr, maskWidth, maskHeight, maskInvert); + } + + // width, height, matrix, bits per component + writePSFmt("{0:d} {1:d} 8 [{2:d} 0 0 {3:d} 0 {4:d}] pdfIm1Sep{5:s}\n", + width, height, + width, -height, height, + useBinary ? "Bin" : ""); + + // allocate a line buffer + lineBuf = (Guchar *)gmallocn(width, 4); + + // set up to process the data stream + imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(), + colorMap->getBits()); + imgStr->reset(); + + // process the data stream + checkProcessColor = gTrue; + i = 0; + for (y = 0; y < height; ++y) { + + // read the line + if (checkProcessColor) { + checkProcessColor = (((psProcessCyan | psProcessMagenta | psProcessYellow | psProcessBlack) & ~processColors) != 0); + } + if (checkProcessColor) { + for (x = 0; x < width; ++x) { + imgStr->getPixel(pixBuf); + colorMap->getCMYK(pixBuf, &cmyk); + lineBuf[4*x+0] = colToByte(cmyk.c); + lineBuf[4*x+1] = colToByte(cmyk.m); + lineBuf[4*x+2] = colToByte(cmyk.y); + lineBuf[4*x+3] = colToByte(cmyk.k); + addProcessColor(colToDbl(cmyk.c), colToDbl(cmyk.m), + colToDbl(cmyk.y), colToDbl(cmyk.k)); + } + } else { + for (x = 0; x < width; ++x) { + imgStr->getPixel(pixBuf); + colorMap->getCMYK(pixBuf, &cmyk); + lineBuf[4*x+0] = colToByte(cmyk.c); + lineBuf[4*x+1] = colToByte(cmyk.m); + lineBuf[4*x+2] = colToByte(cmyk.y); + lineBuf[4*x+3] = colToByte(cmyk.k); + } + } + + // write one line of each color component + if (useBinary) { + for (comp = 0; comp < 4; ++comp) { + for (x = 0; x < width; ++x) { + hexBuf[i++] = lineBuf[4*x + comp]; + if (i >= 64) { + writePSBuf(hexBuf, i); + i = 0; + } + } + } + } else { + for (comp = 0; comp < 4; ++comp) { + for (x = 0; x < width; ++x) { + digit = lineBuf[4*x + comp] / 16; + hexBuf[i++] = digit + ((digit >= 10)? 'a'-10: '0'); + digit = lineBuf[4*x + comp] % 16; + hexBuf[i++] = digit + ((digit >= 10)? 'a'-10: '0'); + if (i >= 64) { + hexBuf[i++] = '\n'; + writePSBuf(hexBuf, i); + i = 0; + } + } + } + } + } + + if (i != 0) { + if (!useBinary) { + hexBuf[i++] = '\n'; + } + writePSBuf(hexBuf, i); + } + + str->close(); + delete imgStr; + gfree(lineBuf); + + if (maskStr && !(maskColors && colorMap)) { + writePS("pdfImClipEnd\n"); + } +} + +void PSOutputDev::maskToClippingPath(Stream *maskStr, int maskWidth, int maskHeight, GBool maskInvert) { + ImageStream *imgStr; + Guchar *line; + PSOutImgClipRect *rects0, *rects1, *rectsTmp, *rectsOut; + int rects0Len, rects1Len, rectsSize, rectsOutLen, rectsOutSize; + GBool emitRect, addRect, extendRect; + int i, x0, x1, y, maskXor; + + imgStr = new ImageStream(maskStr, maskWidth, 1, 1); + imgStr->reset(); + rects0Len = rects1Len = rectsOutLen = 0; + rectsSize = rectsOutSize = 64; + rects0 = (PSOutImgClipRect *)gmallocn(rectsSize, sizeof(PSOutImgClipRect)); + rects1 = (PSOutImgClipRect *)gmallocn(rectsSize, sizeof(PSOutImgClipRect)); + rectsOut = (PSOutImgClipRect *)gmallocn(rectsOutSize, sizeof(PSOutImgClipRect)); + maskXor = maskInvert ? 1 : 0; + for (y = 0; y < maskHeight; ++y) { + if (!(line = imgStr->getLine())) { + break; + } + i = 0; + rects1Len = 0; + for (x0 = 0; x0 < maskWidth && (line[x0] ^ maskXor); ++x0) ; + for (x1 = x0; x1 < maskWidth && !(line[x1] ^ maskXor); ++x1) ; + while (x0 < maskWidth || i < rects0Len) { + emitRect = addRect = extendRect = gFalse; + if (x0 >= maskWidth) { + emitRect = gTrue; + } else if (i >= rects0Len) { + addRect = gTrue; + } else if (rects0[i].x0 < x0) { + emitRect = gTrue; + } else if (x0 < rects0[i].x0) { + addRect = gTrue; + } else if (rects0[i].x1 == x1) { + extendRect = gTrue; + } else { + emitRect = addRect = gTrue; + } + if (emitRect) { + if (rectsOutLen == rectsOutSize) { + rectsOutSize *= 2; + rectsOut = (PSOutImgClipRect *)greallocn(rectsOut, rectsOutSize, sizeof(PSOutImgClipRect)); + } + rectsOut[rectsOutLen].x0 = rects0[i].x0; + rectsOut[rectsOutLen].x1 = rects0[i].x1; + rectsOut[rectsOutLen].y0 = maskHeight - y - 1; + rectsOut[rectsOutLen].y1 = maskHeight - rects0[i].y0 - 1; + ++rectsOutLen; + ++i; + } + if (addRect || extendRect) { + if (rects1Len == rectsSize) { + rectsSize *= 2; + rects0 = (PSOutImgClipRect *)greallocn(rects0, rectsSize, sizeof(PSOutImgClipRect)); + rects1 = (PSOutImgClipRect *)greallocn(rects1, rectsSize, sizeof(PSOutImgClipRect)); + } + rects1[rects1Len].x0 = x0; + rects1[rects1Len].x1 = x1; + if (addRect) { + rects1[rects1Len].y0 = y; + } + if (extendRect) { + rects1[rects1Len].y0 = rects0[i].y0; + ++i; + } + ++rects1Len; + for (x0 = x1; x0 < maskWidth && (line[x0] ^ maskXor); ++x0) ; + for (x1 = x0; x1 < maskWidth && !(line[x1] ^ maskXor); ++x1) ; + } + } + rectsTmp = rects0; + rects0 = rects1; + rects1 = rectsTmp; + i = rects0Len; + rects0Len = rects1Len; + rects1Len = i; + } + for (i = 0; i < rects0Len; ++i) { + if (rectsOutLen == rectsOutSize) { + rectsOutSize *= 2; + rectsOut = (PSOutImgClipRect *)greallocn(rectsOut, rectsOutSize, sizeof(PSOutImgClipRect)); + } + rectsOut[rectsOutLen].x0 = rects0[i].x0; + rectsOut[rectsOutLen].x1 = rects0[i].x1; + rectsOut[rectsOutLen].y0 = maskHeight - y - 1; + rectsOut[rectsOutLen].y1 = maskHeight - rects0[i].y0 - 1; + ++rectsOutLen; + } + if (rectsOutLen < 65536/4) { + writePSFmt("{0:d} array 0\n", rectsOutLen * 4); + for (i = 0; i < rectsOutLen; ++i) { + writePSFmt("[{0:d} {1:d} {2:d} {3:d}] pr\n", + rectsOut[i].x0, rectsOut[i].y0, + rectsOut[i].x1 - rectsOut[i].x0, + rectsOut[i].y1 - rectsOut[i].y0); + } + writePSFmt("pop {0:d} {1:d} pdfImClip\n", maskWidth, maskHeight); + } else { + // would be over the limit of array size. + // make each rectangle path and clip. + writePS("gsave newpath\n"); + for (i = 0; i < rectsOutLen; ++i) { + writePSFmt("{0:.6g} {1:.6g} {2:.6g} {3:.6g} re\n", + ((double)rectsOut[i].x0)/maskWidth, + ((double)rectsOut[i].y0)/maskHeight, + ((double)(rectsOut[i].x1 - rectsOut[i].x0))/maskWidth, + ((double)(rectsOut[i].y1 - rectsOut[i].y0))/maskHeight); + } + writePS("clip\n"); + } + gfree(rectsOut); + gfree(rects0); + gfree(rects1); + delete imgStr; + maskStr->close(); +} + +void PSOutputDev::doImageL2(Object *ref, GfxImageColorMap *colorMap, + GBool invert, GBool inlineImg, + Stream *str, int width, int height, int len, + int *maskColors, Stream *maskStr, + int maskWidth, int maskHeight, GBool maskInvert) { + Stream *str2; + ImageStream *imgStr; + Guchar *line; + PSOutImgClipRect *rects0, *rects1, *rectsTmp, *rectsOut; + int rects0Len, rects1Len, rectsSize, rectsOutLen, rectsOutSize; + GBool emitRect, addRect, extendRect; + GooString *s; + int n, numComps; + GBool useRLE, useASCII, useCompressed; + GfxSeparationColorSpace *sepCS; + GfxColor color; + GfxCMYK cmyk; + int c; + int col, i, j, x0, x1, y; + char dataBuf[4096]; + + rectsOutLen = 0; + + // color key masking + if (maskColors && colorMap && !inlineImg) { + // can't read the stream twice for inline images -- but masking + // isn't allowed with inline images anyway + numComps = colorMap->getNumPixelComps(); + imgStr = new ImageStream(str, width, numComps, colorMap->getBits()); + imgStr->reset(); + rects0Len = rects1Len = 0; + rectsSize = rectsOutSize = 64; + rects0 = (PSOutImgClipRect *)gmallocn(rectsSize, sizeof(PSOutImgClipRect)); + rects1 = (PSOutImgClipRect *)gmallocn(rectsSize, sizeof(PSOutImgClipRect)); + rectsOut = (PSOutImgClipRect *)gmallocn(rectsOutSize, + sizeof(PSOutImgClipRect)); + for (y = 0; y < height; ++y) { + if (!(line = imgStr->getLine())) { + break; + } + i = 0; + rects1Len = 0; + for (x0 = 0; x0 < width; ++x0) { + for (j = 0; j < numComps; ++j) { + if (line[x0*numComps+j] < maskColors[2*j] || + line[x0*numComps+j] > maskColors[2*j+1]) { + break; + } + } + if (j < numComps) { + break; + } + } + for (x1 = x0; x1 < width; ++x1) { + for (j = 0; j < numComps; ++j) { + if (line[x1*numComps+j] < maskColors[2*j] || + line[x1*numComps+j] > maskColors[2*j+1]) { + break; + } + } + if (j == numComps) { + break; + } + } + while (x0 < width || i < rects0Len) { + emitRect = addRect = extendRect = gFalse; + if (x0 >= width) { + emitRect = gTrue; + } else if (i >= rects0Len) { + addRect = gTrue; + } else if (rects0[i].x0 < x0) { + emitRect = gTrue; + } else if (x0 < rects0[i].x0) { + addRect = gTrue; + } else if (rects0[i].x1 == x1) { + extendRect = gTrue; + } else { + emitRect = addRect = gTrue; + } + if (emitRect) { + if (rectsOutLen == rectsOutSize) { + rectsOutSize *= 2; + rectsOut = (PSOutImgClipRect *)greallocn(rectsOut, rectsOutSize, + sizeof(PSOutImgClipRect)); + } + rectsOut[rectsOutLen].x0 = rects0[i].x0; + rectsOut[rectsOutLen].x1 = rects0[i].x1; + rectsOut[rectsOutLen].y0 = height - y - 1; + rectsOut[rectsOutLen].y1 = height - rects0[i].y0 - 1; + ++rectsOutLen; + ++i; + } + if (addRect || extendRect) { + if (rects1Len == rectsSize) { + rectsSize *= 2; + rects0 = (PSOutImgClipRect *)greallocn(rects0, rectsSize, + sizeof(PSOutImgClipRect)); + rects1 = (PSOutImgClipRect *)greallocn(rects1, rectsSize, + sizeof(PSOutImgClipRect)); + } + rects1[rects1Len].x0 = x0; + rects1[rects1Len].x1 = x1; + if (addRect) { + rects1[rects1Len].y0 = y; + } + if (extendRect) { + rects1[rects1Len].y0 = rects0[i].y0; + ++i; + } + ++rects1Len; + for (x0 = x1; x0 < width; ++x0) { + for (j = 0; j < numComps; ++j) { + if (line[x0*numComps+j] < maskColors[2*j] || + line[x0*numComps+j] > maskColors[2*j+1]) { + break; + } + } + if (j < numComps) { + break; + } + } + for (x1 = x0; x1 < width; ++x1) { + for (j = 0; j < numComps; ++j) { + if (line[x1*numComps+j] < maskColors[2*j] || + line[x1*numComps+j] > maskColors[2*j+1]) { + break; + } + } + if (j == numComps) { + break; + } + } + } + } + rectsTmp = rects0; + rects0 = rects1; + rects1 = rectsTmp; + i = rects0Len; + rects0Len = rects1Len; + rects1Len = i; + } + for (i = 0; i < rects0Len; ++i) { + if (rectsOutLen == rectsOutSize) { + rectsOutSize *= 2; + rectsOut = (PSOutImgClipRect *)greallocn(rectsOut, rectsOutSize, + sizeof(PSOutImgClipRect)); + } + rectsOut[rectsOutLen].x0 = rects0[i].x0; + rectsOut[rectsOutLen].x1 = rects0[i].x1; + rectsOut[rectsOutLen].y0 = height - y - 1; + rectsOut[rectsOutLen].y1 = height - rects0[i].y0 - 1; + ++rectsOutLen; + } + if (rectsOutLen < 65536/4) { + writePSFmt("{0:d} array 0\n", rectsOutLen * 4); + for (i = 0; i < rectsOutLen; ++i) { + writePSFmt("[{0:d} {1:d} {2:d} {3:d}] pr\n", + rectsOut[i].x0, rectsOut[i].y0, + rectsOut[i].x1 - rectsOut[i].x0, + rectsOut[i].y1 - rectsOut[i].y0); + } + writePSFmt("pop {0:d} {1:d} pdfImClip\n", width, height); + } else { + // would be over the limit of array size. + // make each rectangle path and clip. + writePS("gsave newpath\n"); + for (i = 0; i < rectsOutLen; ++i) { + writePSFmt("{0:.6g} {1:.6g} {2:.6g} {3:.6g} re\n", + ((double)rectsOut[i].x0)/width, + ((double)rectsOut[i].y0)/height, + ((double)(rectsOut[i].x1 - rectsOut[i].x0))/width, + ((double)(rectsOut[i].y1 - rectsOut[i].y0))/height); + } + writePS("clip\n"); + } + gfree(rectsOut); + gfree(rects0); + gfree(rects1); + delete imgStr; + str->close(); + + // explicit masking + } else if (maskStr) { + maskToClippingPath(maskStr, maskWidth, maskHeight, maskInvert); + } + + // color space + if (colorMap) { + dumpColorSpaceL2(colorMap->getColorSpace(), gFalse, gTrue, gFalse); + writePS(" setcolorspace\n"); + } + + // set up the image data + if (mode == psModeForm || inType3Char || preloadImagesForms) { + if (inlineImg) { + // create an array + str2 = new FixedLengthEncoder(str, len); + str2 = new RunLengthEncoder(str2); + if (useASCIIHex) { + str2 = new ASCIIHexEncoder(str2); + } else { + str2 = new ASCII85Encoder(str2); + } + str2->reset(); + col = 0; + writePS((char *)(useASCIIHex ? "[<" : "[<~")); + do { + do { + c = str2->getChar(); + } while (c == '\n' || c == '\r'); + if (c == (useASCIIHex ? '>' : '~') || c == EOF) { + break; + } + if (c == 'z') { + writePSChar(c); + ++col; + } else { + writePSChar(c); + ++col; + for (i = 1; i <= (useASCIIHex ? 1 : 4); ++i) { + do { + c = str2->getChar(); + } while (c == '\n' || c == '\r'); + if (c == (useASCIIHex ? '>' : '~') || c == EOF) { + break; + } + writePSChar(c); + ++col; + } + } + // each line is: "<~...data...~><eol>" + // so max data length = 255 - 6 = 249 + // chunks are 1 or 5 bytes each, so we have to stop at 245 + // but make it 240 just to be safe + if (col > 240) { + writePS((char *)(useASCIIHex ? ">\n<" : "~>\n<~")); + col = 0; + } + } while (c != (useASCIIHex ? '>' : '~') && c != EOF); + writePS((char *)(useASCIIHex ? ">\n" : "~>\n")); + // add an extra entry because the RunLengthDecode filter may + // read past the end + writePS("<>]\n"); + writePS("0\n"); + str2->close(); + delete str2; + } else { + // make sure the image is setup, it sometimes is not like on bug #17645 + setupImage(ref->getRef(), str, gFalse); + // set up to use the array already created by setupImages() + writePSFmt("ImData_{0:d}_{1:d} 0 0\n",ref->getRefNum(), ref->getRefGen()); + } + } + + // image dictionary + writePS("<<\n /ImageType 1\n"); + + // width, height, matrix, bits per component + writePSFmt(" /Width {0:d}\n", width); + writePSFmt(" /Height {0:d}\n", height); + writePSFmt(" /ImageMatrix [{0:d} 0 0 {1:d} 0 {2:d}]\n", + width, -height, height); + if (colorMap && colorMap->getColorSpace()->getMode() == csDeviceN) { + writePS(" /BitsPerComponent 8\n"); + } else { + writePSFmt(" /BitsPerComponent {0:d}\n", + colorMap ? colorMap->getBits() : 1); + } + + // decode + if (colorMap) { + writePS(" /Decode ["); + if ((level == psLevel2Sep || level == psLevel3Sep) && + colorMap->getColorSpace()->getMode() == csSeparation) { + // this matches up with the code in the pdfImSep operator + n = (1 << colorMap->getBits()) - 1; + writePSFmt("{0:.4g} {1:.4g}", colorMap->getDecodeLow(0) * n, + colorMap->getDecodeHigh(0) * n); + } else if (colorMap->getColorSpace()->getMode() == csDeviceN) { + numComps = ((GfxDeviceNColorSpace *)colorMap->getColorSpace())-> + getAlt()->getNComps(); + for (i = 0; i < numComps; ++i) { + if (i > 0) { + writePS(" "); + } + writePS("0 1"); + } + } else { + numComps = colorMap->getNumPixelComps(); + for (i = 0; i < numComps; ++i) { + if (i > 0) { + writePS(" "); + } + writePSFmt("{0:.4g} {1:.4g}", + colorMap->getDecodeLow(i), colorMap->getDecodeHigh(i)); + } + } + writePS("]\n"); + } else { + writePSFmt(" /Decode [{0:d} {1:d}]\n", invert ? 1 : 0, invert ? 0 : 1); + } + + // data source + if (mode == psModeForm || inType3Char || preloadImagesForms) { + if (inlineImg) { + writePS(" /DataSource { pdfImStr }\n"); + } else { + writePS(" /DataSource { dup 65535 ge { pop 1 add 0 } if 2 index 2" + " index get 1 index get exch 1 add exch }\n"); + } + } else { + writePS(" /DataSource currentfile\n"); + } + + // filters + if ((mode == psModeForm || inType3Char || preloadImagesForms) && + uncompressPreloadedImages) { + s = NULL; + useRLE = gFalse; + useCompressed = gFalse; + useASCII = gFalse; + } else { + s = str->getPSFilter(level < psLevel2 ? 1 : level < psLevel3 ? 2 : 3, + " "); + if ((colorMap && colorMap->getColorSpace()->getMode() == csDeviceN) || + inlineImg || !s) { + useRLE = gTrue; + useASCII = !(mode == psModeForm || inType3Char || preloadImagesForms); + useCompressed = gFalse; + } else { + useRLE = gFalse; + useASCII = str->isBinary() && + !(mode == psModeForm || inType3Char || preloadImagesForms); + useCompressed = gTrue; + } + } + if (useASCII) { + writePSFmt(" /ASCII{0:s}Decode filter\n", + useASCIIHex ? "Hex" : "85"); + } + if (useRLE) { + writePS(" /RunLengthDecode filter\n"); + } + if (useCompressed) { + writePS(s->getCString()); + } + if (s) { + delete s; + } + + if (mode == psModeForm || inType3Char || preloadImagesForms) { + + // end of image dictionary + writePSFmt(">>\n{0:s}\n", colorMap ? "image" : "imagemask"); + + // get rid of the array and index + if (!inlineImg) writePS("pop "); + writePS("pop pop\n"); + + } else { + + // cut off inline image streams at appropriate length + if (inlineImg) { + str = new FixedLengthEncoder(str, len); + } else if (useCompressed) { + str = str->getUndecodedStream(); + } + + // recode DeviceN data + if (colorMap && colorMap->getColorSpace()->getMode() == csDeviceN) { + str = new DeviceNRecoder(str, width, height, colorMap); + } + + // add RunLengthEncode and ASCIIHex/85 encode filters + if (useRLE) { + str = new RunLengthEncoder(str); + } + if (useASCII) { + if (useASCIIHex) { + str = new ASCIIHexEncoder(str); + } else { + str = new ASCII85Encoder(str); + } + } + + // end of image dictionary + writePS(">>\n"); +#if OPI_SUPPORT + if (opi13Nest) { + if (inlineImg) { + // this can't happen -- OPI dictionaries are in XObjects + error(errSyntaxError, -1, "OPI in inline image"); + n = 0; + } else { + // need to read the stream to count characters -- the length + // is data-dependent (because of ASCII and RLE filters) + str->reset(); + n = 0; + while ((c = str->getChar()) != EOF) { + ++n; + } + str->close(); + } + // +6/7 for "pdfIm\n" / "pdfImM\n" + // +8 for newline + trailer + n += colorMap ? 14 : 15; + writePSFmt("%%BeginData: {0:d} Hex Bytes\n", n); + } +#endif + if ((level == psLevel2Sep || level == psLevel3Sep) && colorMap && + colorMap->getColorSpace()->getMode() == csSeparation && colorMap->getBits() == 8) { + color.c[0] = gfxColorComp1; + sepCS = (GfxSeparationColorSpace *)colorMap->getColorSpace(); + sepCS->getCMYK(&color, &cmyk); + writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} ({4:t}) pdfImSep\n", + colToDbl(cmyk.c), colToDbl(cmyk.m), + colToDbl(cmyk.y), colToDbl(cmyk.k), + sepCS->getName()); + } else { + writePSFmt("{0:s}\n", colorMap ? "pdfIm" : "pdfImM"); + } + + // copy the stream data + str->reset(); + i = 0; + while ((c = str->getChar()) != EOF) { + dataBuf[i++] = c; + if (i >= (int)sizeof(dataBuf)) { + writePSBuf(dataBuf, i); + i = 0; + } + } + if (i > 0) { + writePSBuf(dataBuf, i); + } + str->close(); + + // add newline and trailer to the end + writePSChar('\n'); + writePS("%-EOD-\n"); +#if OPI_SUPPORT + if (opi13Nest) { + writePS("%%EndData\n"); + } +#endif + + // delete encoders + if (useRLE || useASCII || inlineImg) { + delete str; + } + } + + if ((maskColors && colorMap && !inlineImg) || maskStr) { + if (rectsOutLen < 65536/4) { + writePS("pdfImClipEnd\n"); + } else { + writePS("grestore\n"); + } + } +} + +//~ this doesn't currently support OPI +void PSOutputDev::doImageL3(Object *ref, GfxImageColorMap *colorMap, + GBool invert, GBool inlineImg, + Stream *str, int width, int height, int len, + int *maskColors, Stream *maskStr, + int maskWidth, int maskHeight, GBool maskInvert) { + Stream *str2; + GooString *s; + int n, numComps; + GBool useRLE, useASCII, useCompressed; + GBool maskUseRLE, maskUseASCII, maskUseCompressed; + GooString *maskFilters; + GfxSeparationColorSpace *sepCS; + GfxColor color; + GfxCMYK cmyk; + int c; + int col, i; + + useRLE = useASCII = useCompressed = gFalse; // make gcc happy + maskUseRLE = maskUseASCII = maskUseCompressed = gFalse; // make gcc happy + maskFilters = NULL; // make gcc happy + + // explicit masking + if (maskStr) { + + // mask data source + if ((mode == psModeForm || inType3Char || preloadImagesForms) && + uncompressPreloadedImages) { + s = NULL; + maskUseRLE = gFalse; + maskUseCompressed = gFalse; + maskUseASCII = gFalse; + } else { + s = maskStr->getPSFilter(3, " "); + if (!s) { + maskUseRLE = gTrue; + maskUseASCII = !(mode == psModeForm || inType3Char || preloadImagesForms); + maskUseCompressed = gFalse; + } else { + maskUseRLE = gFalse; + maskUseASCII = maskStr->isBinary() && + !(mode == psModeForm || inType3Char || preloadImagesForms); + maskUseCompressed = gTrue; + } + } + maskFilters = new GooString(); + if (maskUseASCII) { + maskFilters->appendf(" /ASCII{0:s}Decode filter\n", + useASCIIHex ? "Hex" : "85"); + } + if (maskUseRLE) { + maskFilters->append(" /RunLengthDecode filter\n"); + } + if (maskUseCompressed) { + maskFilters->append(s); + } + if (s) { + delete s; + } + if (mode == psModeForm || inType3Char || preloadImagesForms) { + writePSFmt("MaskData_{0:d}_{1:d} pdfMaskInit\n", + ref->getRefNum(), ref->getRefGen()); + } else { + writePS("currentfile\n"); + writePS(maskFilters->getCString()); + writePS("pdfMask\n"); + + // add RunLengthEncode and ASCIIHex/85 encode filters + if (maskUseCompressed) { + maskStr = maskStr->getUndecodedStream(); + } + if (maskUseRLE) { + maskStr = new RunLengthEncoder(maskStr); + } + if (maskUseASCII) { + if (useASCIIHex) { + maskStr = new ASCIIHexEncoder(maskStr); + } else { + maskStr = new ASCII85Encoder(maskStr); + } + } + + // copy the stream data + maskStr->reset(); + while ((c = maskStr->getChar()) != EOF) { + writePSChar(c); + } + maskStr->close(); + writePSChar('\n'); + writePS("%-EOD-\n"); + + // delete encoders + if (maskUseRLE || maskUseASCII) { + delete maskStr; + } + } + } + + // color space + if (colorMap) { + dumpColorSpaceL2(colorMap->getColorSpace(), gFalse, gTrue, gFalse); + writePS(" setcolorspace\n"); + } + + // set up the image data + if (mode == psModeForm || inType3Char || preloadImagesForms) { + if (inlineImg) { + // create an array + str2 = new FixedLengthEncoder(str, len); + str2 = new RunLengthEncoder(str2); + if (useASCIIHex) { + str2 = new ASCIIHexEncoder(str2); + } else { + str2 = new ASCII85Encoder(str2); + } + str2->reset(); + col = 0; + writePS((char *)(useASCIIHex ? "[<" : "[<~")); + do { + do { + c = str2->getChar(); + } while (c == '\n' || c == '\r'); + if (c == (useASCIIHex ? '>' : '~') || c == EOF) { + break; + } + if (c == 'z') { + writePSChar(c); + ++col; + } else { + writePSChar(c); + ++col; + for (i = 1; i <= (useASCIIHex ? 1 : 4); ++i) { + do { + c = str2->getChar(); + } while (c == '\n' || c == '\r'); + if (c == (useASCIIHex ? '>' : '~') || c == EOF) { + break; + } + writePSChar(c); + ++col; + } + } + // each line is: "<~...data...~><eol>" + // so max data length = 255 - 6 = 249 + // chunks are 1 or 5 bytes each, so we have to stop at 245 + // but make it 240 just to be safe + if (col > 240) { + writePS((char *)(useASCIIHex ? ">\n<" : "~>\n<~")); + col = 0; + } + } while (c != (useASCIIHex ? '>' : '~') && c != EOF); + writePS((char *)(useASCIIHex ? ">\n" : "~>\n")); + // add an extra entry because the RunLengthDecode filter may + // read past the end + writePS("<>]\n"); + writePS("0\n"); + str2->close(); + delete str2; + } else { + // make sure the image is setup, it sometimes is not like on bug #17645 + setupImage(ref->getRef(), str, gFalse); + // set up to use the array already created by setupImages() + writePSFmt("ImData_{0:d}_{1:d} 0 0\n", ref->getRefNum(), ref->getRefGen()); + } + } + + // explicit masking + if (maskStr) { + writePS("<<\n /ImageType 3\n"); + writePS(" /InterleaveType 3\n"); + writePS(" /DataDict\n"); + } + + // image (data) dictionary + writePSFmt("<<\n /ImageType {0:d}\n", (maskColors && colorMap) ? 4 : 1); + + // color key masking + if (maskColors && colorMap) { + writePS(" /MaskColor [\n"); + numComps = colorMap->getNumPixelComps(); + for (i = 0; i < 2 * numComps; i += 2) { + writePSFmt(" {0:d} {1:d}\n", maskColors[i], maskColors[i+1]); + } + writePS(" ]\n"); + } + + // width, height, matrix, bits per component + writePSFmt(" /Width {0:d}\n", width); + writePSFmt(" /Height {0:d}\n", height); + writePSFmt(" /ImageMatrix [{0:d} 0 0 {1:d} 0 {2:d}]\n", + width, -height, height); + if (colorMap && colorMap->getColorSpace()->getMode() == csDeviceN) { + writePS(" /BitsPerComponent 8\n"); + } else { + writePSFmt(" /BitsPerComponent {0:d}\n", + colorMap ? colorMap->getBits() : 1); + } + + // decode + if (colorMap) { + writePS(" /Decode ["); + if ((level == psLevel2Sep || level == psLevel3Sep) && + colorMap->getColorSpace()->getMode() == csSeparation) { + // this matches up with the code in the pdfImSep operator + n = (1 << colorMap->getBits()) - 1; + writePSFmt("{0:.4g} {1:.4g}", colorMap->getDecodeLow(0) * n, + colorMap->getDecodeHigh(0) * n); + } else { + numComps = colorMap->getNumPixelComps(); + for (i = 0; i < numComps; ++i) { + if (i > 0) { + writePS(" "); + } + writePSFmt("{0:.4g} {1:.4g}", colorMap->getDecodeLow(i), + colorMap->getDecodeHigh(i)); + } + } + writePS("]\n"); + } else { + writePSFmt(" /Decode [{0:d} {1:d}]\n", invert ? 1 : 0, invert ? 0 : 1); + } + + // data source + if (mode == psModeForm || inType3Char || preloadImagesForms) { + if (inlineImg) { + writePS(" /DataSource { pdfImStr }\n"); + } else { + writePS(" /DataSource { dup 65535 ge { pop 1 add 0 } if 2 index 2" + " index get 1 index get exch 1 add exch }\n"); + } + } else { + writePS(" /DataSource currentfile\n"); + } + + // filters + if ((mode == psModeForm || inType3Char || preloadImagesForms) && + uncompressPreloadedImages) { + s = NULL; + useRLE = gFalse; + useCompressed = gFalse; + useASCII = gFalse; + } else { + s = str->getPSFilter(level < psLevel2 ? 1 : level < psLevel3 ? 2 : 3, + " "); + if ((colorMap && colorMap->getColorSpace()->getMode() == csDeviceN) || + inlineImg || !s) { + useRLE = gTrue; + useASCII = !(mode == psModeForm || inType3Char || preloadImagesForms); + useCompressed = gFalse; + } else { + useRLE = gFalse; + useASCII = str->isBinary() && + !(mode == psModeForm || inType3Char || preloadImagesForms); + useCompressed = gTrue; + } + } + if (useASCII) { + writePSFmt(" /ASCII{0:s}Decode filter\n", + useASCIIHex ? "Hex" : "85"); + } + if (useRLE) { + writePS(" /RunLengthDecode filter\n"); + } + if (useCompressed) { + writePS(s->getCString()); + } + if (s) { + delete s; + } + + // end of image (data) dictionary + writePS(">>\n"); + + // explicit masking + if (maskStr) { + writePS(" /MaskDict\n"); + writePS("<<\n"); + writePS(" /ImageType 1\n"); + writePSFmt(" /Width {0:d}\n", maskWidth); + writePSFmt(" /Height {0:d}\n", maskHeight); + writePSFmt(" /ImageMatrix [{0:d} 0 0 {1:d} 0 {2:d}]\n", + maskWidth, -maskHeight, maskHeight); + writePS(" /BitsPerComponent 1\n"); + writePSFmt(" /Decode [{0:d} {1:d}]\n", + maskInvert ? 1 : 0, maskInvert ? 0 : 1); + + // mask data source + if (mode == psModeForm || inType3Char || preloadImagesForms) { + writePS(" /DataSource {pdfMaskSrc}\n"); + writePS(maskFilters->getCString()); + } else { + writePS(" /DataSource maskStream\n"); + } + delete maskFilters; + + writePS(">>\n"); + writePS(">>\n"); + } + + if (mode == psModeForm || inType3Char || preloadImagesForms) { + + // image command + writePSFmt("{0:s}\n", colorMap ? "image" : "imagemask"); + + } else { + + if ((level == psLevel2Sep || level == psLevel3Sep) && colorMap && + colorMap->getColorSpace()->getMode() == csSeparation && colorMap->getBits() == 8) { + color.c[0] = gfxColorComp1; + sepCS = (GfxSeparationColorSpace *)colorMap->getColorSpace(); + sepCS->getCMYK(&color, &cmyk); + writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} ({4:t}) pdfImSep\n", + colToDbl(cmyk.c), colToDbl(cmyk.m), + colToDbl(cmyk.y), colToDbl(cmyk.k), + sepCS->getName()); + } else { + writePSFmt("{0:s}\n", colorMap ? "pdfIm" : "pdfImM"); + } + + } + + // get rid of the array and index + if (mode == psModeForm || inType3Char || preloadImagesForms) { + if (!inlineImg) writePS("pop "); + writePS("pop pop\n"); + + // image data + } else { + + // cut off inline image streams at appropriate length + if (inlineImg) { + str = new FixedLengthEncoder(str, len); + } else if (useCompressed) { + str = str->getUndecodedStream(); + } + + // add RunLengthEncode and ASCIIHex/85 encode filters + if (useRLE) { + str = new RunLengthEncoder(str); + } + if (useASCII) { + if (useASCIIHex) { + str = new ASCIIHexEncoder(str); + } else { + str = new ASCII85Encoder(str); + } + } + + // copy the stream data + str->reset(); + while ((c = str->getChar()) != EOF) { + writePSChar(c); + } + str->close(); + + // add newline and trailer to the end + writePSChar('\n'); + writePS("%-EOD-\n"); + + // delete encoders + if (useRLE || useASCII || inlineImg) { + delete str; + } + } + + // close the mask stream + if (maskStr) { + if (!(mode == psModeForm || inType3Char || preloadImagesForms)) { + writePS("pdfMaskEnd\n"); + } + } +} + +void PSOutputDev::dumpColorSpaceL2(GfxColorSpace *colorSpace, + GBool genXform, GBool updateColors, + GBool map01) { + GfxCalGrayColorSpace *calGrayCS; + GfxCalRGBColorSpace *calRGBCS; + GfxLabColorSpace *labCS; + GfxIndexedColorSpace *indexedCS; + GfxSeparationColorSpace *separationCS; + GfxDeviceNColorSpace *deviceNCS; + GfxColorSpace *baseCS; + Guchar *lookup, *p; + double x[gfxColorMaxComps], y[gfxColorMaxComps]; + double low[gfxColorMaxComps], range[gfxColorMaxComps]; + GfxColor color; + GfxCMYK cmyk; + Function *func; + int n, numComps, numAltComps; + int byte; + int i, j, k; + + switch (colorSpace->getMode()) { + + case csDeviceGray: + writePS("/DeviceGray"); + if (genXform) { + writePS(" {}"); + } + if (updateColors) { + processColors |= psProcessBlack; + } + break; + + case csCalGray: + calGrayCS = (GfxCalGrayColorSpace *)colorSpace; + writePS("[/CIEBasedA <<\n"); + writePSFmt(" /DecodeA {{{0:.4g} exp}} bind\n", calGrayCS->getGamma()); + writePSFmt(" /MatrixA [{0:.4g} {1:.4g} {2:.4g}]\n", + calGrayCS->getWhiteX(), calGrayCS->getWhiteY(), + calGrayCS->getWhiteZ()); + writePSFmt(" /WhitePoint [{0:.4g} {1:.4g} {2:.4g}]\n", + calGrayCS->getWhiteX(), calGrayCS->getWhiteY(), + calGrayCS->getWhiteZ()); + writePSFmt(" /BlackPoint [{0:.4g} {1:.4g} {2:.4g}]\n", + calGrayCS->getBlackX(), calGrayCS->getBlackY(), + calGrayCS->getBlackZ()); + writePS(">>]"); + if (genXform) { + writePS(" {}"); + } + if (updateColors) { + processColors |= psProcessBlack; + } + break; + + case csDeviceRGB: + writePS("/DeviceRGB"); + if (genXform) { + writePS(" {}"); + } + if (updateColors) { + processColors |= psProcessCMYK; + } + break; + + case csCalRGB: + calRGBCS = (GfxCalRGBColorSpace *)colorSpace; + writePS("[/CIEBasedABC <<\n"); + writePSFmt(" /DecodeABC [{{{0:.4g} exp}} bind {{{1:.4g} exp}} bind {{{2:.4g} exp}} bind]\n", + calRGBCS->getGammaR(), calRGBCS->getGammaG(), + calRGBCS->getGammaB()); + writePSFmt(" /MatrixABC [{0:.4g} {1:.4g} {2:.4g} {3:.4g} {4:.4g} {5:.4g} {6:.4g} {7:.4g} {8:.4g}]\n", + calRGBCS->getMatrix()[0], calRGBCS->getMatrix()[1], + calRGBCS->getMatrix()[2], calRGBCS->getMatrix()[3], + calRGBCS->getMatrix()[4], calRGBCS->getMatrix()[5], + calRGBCS->getMatrix()[6], calRGBCS->getMatrix()[7], + calRGBCS->getMatrix()[8]); + writePSFmt(" /WhitePoint [{0:.4g} {1:.4g} {2:.4g}]\n", + calRGBCS->getWhiteX(), calRGBCS->getWhiteY(), + calRGBCS->getWhiteZ()); + writePSFmt(" /BlackPoint [{0:.4g} {1:.4g} {2:.4g}]\n", + calRGBCS->getBlackX(), calRGBCS->getBlackY(), + calRGBCS->getBlackZ()); + writePS(">>]"); + if (genXform) { + writePS(" {}"); + } + if (updateColors) { + processColors |= psProcessCMYK; + } + break; + + case csDeviceCMYK: + writePS("/DeviceCMYK"); + if (genXform) { + writePS(" {}"); + } + if (updateColors) { + processColors |= psProcessCMYK; + } + break; + + case csLab: + labCS = (GfxLabColorSpace *)colorSpace; + writePS("[/CIEBasedABC <<\n"); + if (map01) { + writePS(" /RangeABC [0 1 0 1 0 1]\n"); + writePSFmt(" /DecodeABC [{{100 mul 16 add 116 div}} bind {{{0:.4g} mul {1:.4g} add}} bind {{{2:.4g} mul {3:.4g} add}} bind]\n", + (labCS->getAMax() - labCS->getAMin()) / 500.0, + labCS->getAMin() / 500.0, + (labCS->getBMax() - labCS->getBMin()) / 200.0, + labCS->getBMin() / 200.0); + } else { + writePSFmt(" /RangeABC [0 100 {0:.4g} {1:.4g} {2:.4g} {3:.4g}]\n", + labCS->getAMin(), labCS->getAMax(), + labCS->getBMin(), labCS->getBMax()); + writePS(" /DecodeABC [{16 add 116 div} bind {500 div} bind {200 div} bind]\n"); + } + writePS(" /MatrixABC [1 1 1 1 0 0 0 0 -1]\n"); + writePS(" /DecodeLMN\n"); + writePS(" [{dup 6 29 div ge {dup dup mul mul}\n"); + writePSFmt(" {{4 29 div sub 108 841 div mul }} ifelse {0:.4g} mul}} bind\n", + labCS->getWhiteX()); + writePS(" {dup 6 29 div ge {dup dup mul mul}\n"); + writePSFmt(" {{4 29 div sub 108 841 div mul }} ifelse {0:.4g} mul}} bind\n", + labCS->getWhiteY()); + writePS(" {dup 6 29 div ge {dup dup mul mul}\n"); + writePSFmt(" {{4 29 div sub 108 841 div mul }} ifelse {0:.4g} mul}} bind]\n", + labCS->getWhiteZ()); + writePSFmt(" /WhitePoint [{0:.4g} {1:.4g} {2:.4g}]\n", + labCS->getWhiteX(), labCS->getWhiteY(), labCS->getWhiteZ()); + writePSFmt(" /BlackPoint [{0:.4g} {1:.4g} {2:.4g}]\n", + labCS->getBlackX(), labCS->getBlackY(), labCS->getBlackZ()); + writePS(">>]"); + if (genXform) { + writePS(" {}"); + } + if (updateColors) { + processColors |= psProcessCMYK; + } + break; + + case csICCBased: + // there is no transform function to the alternate color space, so + // we can use it directly + dumpColorSpaceL2(((GfxICCBasedColorSpace *)colorSpace)->getAlt(), + genXform, updateColors, gFalse); + break; + + case csIndexed: + indexedCS = (GfxIndexedColorSpace *)colorSpace; + baseCS = indexedCS->getBase(); + writePS("[/Indexed "); + dumpColorSpaceL2(baseCS, gFalse, gFalse, gTrue); + n = indexedCS->getIndexHigh(); + numComps = baseCS->getNComps(); + lookup = indexedCS->getLookup(); + writePSFmt(" {0:d} <\n", n); + if (baseCS->getMode() == csDeviceN && level != psLevel3 && level != psLevel3Sep) { + func = ((GfxDeviceNColorSpace *)baseCS)->getTintTransformFunc(); + baseCS->getDefaultRanges(low, range, indexedCS->getIndexHigh()); + if (((GfxDeviceNColorSpace *)baseCS)->getAlt()->getMode() == csLab) { + labCS = (GfxLabColorSpace *)((GfxDeviceNColorSpace *)baseCS)->getAlt(); + } else { + labCS = NULL; + } + numAltComps = ((GfxDeviceNColorSpace *)baseCS)->getAlt()->getNComps(); + p = lookup; + for (i = 0; i <= n; i += 8) { + writePS(" "); + for (j = i; j < i+8 && j <= n; ++j) { + for (k = 0; k < numComps; ++k) { + x[k] = low[k] + (*p++ / 255.0) * range[k]; + } + func->transform(x, y); + if (labCS) { + y[0] /= 100.0; + y[1] = (y[1] - labCS->getAMin()) / + (labCS->getAMax() - labCS->getAMin()); + y[2] = (y[2] - labCS->getBMin()) / + (labCS->getBMax() - labCS->getBMin()); + } + for (k = 0; k < numAltComps; ++k) { + byte = (int)(y[k] * 255 + 0.5); + if (byte < 0) { + byte = 0; + } else if (byte > 255) { + byte = 255; + } + writePSFmt("{0:02x}", byte); + } + if (updateColors) { + color.c[0] = dblToCol(j); + indexedCS->getCMYK(&color, &cmyk); + addProcessColor(colToDbl(cmyk.c), colToDbl(cmyk.m), + colToDbl(cmyk.y), colToDbl(cmyk.k)); + } + } + writePS("\n"); + } + } else { + for (i = 0; i <= n; i += 8) { + writePS(" "); + for (j = i; j < i+8 && j <= n; ++j) { + for (k = 0; k < numComps; ++k) { + writePSFmt("{0:02x}", lookup[j * numComps + k]); + } + if (updateColors) { + color.c[0] = dblToCol(j); + indexedCS->getCMYK(&color, &cmyk); + addProcessColor(colToDbl(cmyk.c), colToDbl(cmyk.m), + colToDbl(cmyk.y), colToDbl(cmyk.k)); + } + } + writePS("\n"); + } + } + writePS(">]"); + if (genXform) { + writePS(" {}"); + } + break; + + case csSeparation: + separationCS = (GfxSeparationColorSpace *)colorSpace; + writePS("[/Separation "); + writePSString(separationCS->getName()); + writePS(" "); + dumpColorSpaceL2(separationCS->getAlt(), gFalse, gFalse, gFalse); + writePS("\n"); + cvtFunction(separationCS->getFunc()); + writePS("]"); + if (genXform) { + writePS(" {}"); + } + if (updateColors) { + addCustomColor(separationCS); + } + break; + + case csDeviceN: + deviceNCS = (GfxDeviceNColorSpace *)colorSpace; + if (level == psLevel3 || level == psLevel3Sep) { + writePS("[/DeviceN\n"); + writePS(" [ "); + for (i = 0; i < deviceNCS->getNComps(); i++) { + writePSString(deviceNCS->getColorantName(i)); + writePS(" "); + } + writePS("]\n"); + dumpColorSpaceL2(deviceNCS->getAlt(), gFalse, updateColors, gFalse); + writePS("\n"); + cvtFunction(deviceNCS->getTintTransformFunc(), map01 && deviceNCS->getAlt()->getMode() == csLab); + writePS("]\n"); + if (genXform) { + writePS(" {}"); + } + } else { + // DeviceN color spaces are a Level 3 PostScript feature. + dumpColorSpaceL2(deviceNCS->getAlt(), gFalse, updateColors, map01); + if (genXform) { + writePS(" "); + cvtFunction(deviceNCS->getTintTransformFunc()); + } + } + break; + + case csPattern: + //~ unimplemented + break; + } +} + +#if OPI_SUPPORT +void PSOutputDev::opiBegin(GfxState *state, Dict *opiDict) { + Object dict; + + if (generateOPI) { + opiDict->lookup("2.0", &dict); + if (dict.isDict()) { + opiBegin20(state, dict.getDict()); + dict.free(); + } else { + dict.free(); + opiDict->lookup("1.3", &dict); + if (dict.isDict()) { + opiBegin13(state, dict.getDict()); + } + dict.free(); + } + } +} + +void PSOutputDev::opiBegin20(GfxState *state, Dict *dict) { + Object obj1, obj2, obj3, obj4; + double width, height, left, right, top, bottom; + int w, h; + int i; + + writePS("%%BeginOPI: 2.0\n"); + writePS("%%Distilled\n"); + + dict->lookup("F", &obj1); + if (getFileSpecName(&obj1, &obj2)) { + writePSFmt("%%ImageFileName: {0:t}\n", obj2.getString()); + obj2.free(); + } + obj1.free(); + + dict->lookup("MainImage", &obj1); + if (obj1.isString()) { + writePSFmt("%%MainImage: {0:t}\n", obj1.getString()); + } + obj1.free(); + + //~ ignoring 'Tags' entry + //~ need to use writePSString() and deal with >255-char lines + + dict->lookup("Size", &obj1); + if (obj1.isArray() && obj1.arrayGetLength() == 2) { + obj1.arrayGet(0, &obj2); + width = obj2.getNum(); + obj2.free(); + obj1.arrayGet(1, &obj2); + height = obj2.getNum(); + obj2.free(); + writePSFmt("%%ImageDimensions: {0:.6g} {1:.6g}\n", width, height); + } + obj1.free(); + + dict->lookup("CropRect", &obj1); + if (obj1.isArray() && obj1.arrayGetLength() == 4) { + obj1.arrayGet(0, &obj2); + left = obj2.getNum(); + obj2.free(); + obj1.arrayGet(1, &obj2); + top = obj2.getNum(); + obj2.free(); + obj1.arrayGet(2, &obj2); + right = obj2.getNum(); + obj2.free(); + obj1.arrayGet(3, &obj2); + bottom = obj2.getNum(); + obj2.free(); + writePSFmt("%%ImageCropRect: {0:.6g} {1:.6g} {2:.6g} {3:.6g}\n", + left, top, right, bottom); + } + obj1.free(); + + dict->lookup("Overprint", &obj1); + if (obj1.isBool()) { + writePSFmt("%%ImageOverprint: {0:s}\n", obj1.getBool() ? "true" : "false"); + } + obj1.free(); + + dict->lookup("Inks", &obj1); + if (obj1.isName()) { + writePSFmt("%%ImageInks: {0:s}\n", obj1.getName()); + } else if (obj1.isArray() && obj1.arrayGetLength() >= 1) { + obj1.arrayGet(0, &obj2); + if (obj2.isName()) { + writePSFmt("%%ImageInks: {0:s} {1:d}", + obj2.getName(), (obj1.arrayGetLength() - 1) / 2); + for (i = 1; i+1 < obj1.arrayGetLength(); i += 2) { + obj1.arrayGet(i, &obj3); + obj1.arrayGet(i+1, &obj4); + if (obj3.isString() && obj4.isNum()) { + writePS(" "); + writePSString(obj3.getString()); + writePSFmt(" {0:.6g}", obj4.getNum()); + } + obj3.free(); + obj4.free(); + } + writePS("\n"); + } + obj2.free(); + } + obj1.free(); + + writePS("gsave\n"); + + writePS("%%BeginIncludedImage\n"); + + dict->lookup("IncludedImageDimensions", &obj1); + if (obj1.isArray() && obj1.arrayGetLength() == 2) { + obj1.arrayGet(0, &obj2); + w = obj2.getInt(); + obj2.free(); + obj1.arrayGet(1, &obj2); + h = obj2.getInt(); + obj2.free(); + writePSFmt("%%IncludedImageDimensions: {0:d} {1:d}\n", w, h); + } + obj1.free(); + + dict->lookup("IncludedImageQuality", &obj1); + if (obj1.isNum()) { + writePSFmt("%%IncludedImageQuality: {0:.6g}\n", obj1.getNum()); + } + obj1.free(); + + ++opi20Nest; +} + +void PSOutputDev::opiBegin13(GfxState *state, Dict *dict) { + Object obj1, obj2; + int left, right, top, bottom, samples, bits, width, height; + double c, m, y, k; + double llx, lly, ulx, uly, urx, ury, lrx, lry; + double tllx, tlly, tulx, tuly, turx, tury, tlrx, tlry; + double horiz, vert; + int i, j; + + writePS("save\n"); + writePS("/opiMatrix2 matrix currentmatrix def\n"); + writePS("opiMatrix setmatrix\n"); + + dict->lookup("F", &obj1); + if (getFileSpecName(&obj1, &obj2)) { + writePSFmt("%ALDImageFileName: {0:t}\n", obj2.getString()); + obj2.free(); + } + obj1.free(); + + dict->lookup("CropRect", &obj1); + if (obj1.isArray() && obj1.arrayGetLength() == 4) { + obj1.arrayGet(0, &obj2); + left = obj2.getInt(); + obj2.free(); + obj1.arrayGet(1, &obj2); + top = obj2.getInt(); + obj2.free(); + obj1.arrayGet(2, &obj2); + right = obj2.getInt(); + obj2.free(); + obj1.arrayGet(3, &obj2); + bottom = obj2.getInt(); + obj2.free(); + writePSFmt("%ALDImageCropRect: {0:d} {1:d} {2:d} {3:d}\n", + left, top, right, bottom); + } + obj1.free(); + + dict->lookup("Color", &obj1); + if (obj1.isArray() && obj1.arrayGetLength() == 5) { + obj1.arrayGet(0, &obj2); + c = obj2.getNum(); + obj2.free(); + obj1.arrayGet(1, &obj2); + m = obj2.getNum(); + obj2.free(); + obj1.arrayGet(2, &obj2); + y = obj2.getNum(); + obj2.free(); + obj1.arrayGet(3, &obj2); + k = obj2.getNum(); + obj2.free(); + obj1.arrayGet(4, &obj2); + if (obj2.isString()) { + writePSFmt("%ALDImageColor: {0:.4g} {1:.4g} {2:.4g} {3:.4g} ", + c, m, y, k); + writePSString(obj2.getString()); + writePS("\n"); + } + obj2.free(); + } + obj1.free(); + + dict->lookup("ColorType", &obj1); + if (obj1.isName()) { + writePSFmt("%ALDImageColorType: {0:s}\n", obj1.getName()); + } + obj1.free(); + + //~ ignores 'Comments' entry + //~ need to handle multiple lines + + dict->lookup("CropFixed", &obj1); + if (obj1.isArray()) { + obj1.arrayGet(0, &obj2); + ulx = obj2.getNum(); + obj2.free(); + obj1.arrayGet(1, &obj2); + uly = obj2.getNum(); + obj2.free(); + obj1.arrayGet(2, &obj2); + lrx = obj2.getNum(); + obj2.free(); + obj1.arrayGet(3, &obj2); + lry = obj2.getNum(); + obj2.free(); + writePSFmt("%ALDImageCropFixed: {0:.6g} {1:.6g} {2:.6g} {3:.6g}\n", + ulx, uly, lrx, lry); + } + obj1.free(); + + dict->lookup("GrayMap", &obj1); + if (obj1.isArray()) { + writePS("%ALDImageGrayMap:"); + for (i = 0; i < obj1.arrayGetLength(); i += 16) { + if (i > 0) { + writePS("\n%%+"); + } + for (j = 0; j < 16 && i+j < obj1.arrayGetLength(); ++j) { + obj1.arrayGet(i+j, &obj2); + writePSFmt(" {0:d}", obj2.getInt()); + obj2.free(); + } + } + writePS("\n"); + } + obj1.free(); + + dict->lookup("ID", &obj1); + if (obj1.isString()) { + writePSFmt("%ALDImageID: {0:t}\n", obj1.getString()); + } + obj1.free(); + + dict->lookup("ImageType", &obj1); + if (obj1.isArray() && obj1.arrayGetLength() == 2) { + obj1.arrayGet(0, &obj2); + samples = obj2.getInt(); + obj2.free(); + obj1.arrayGet(1, &obj2); + bits = obj2.getInt(); + obj2.free(); + writePSFmt("%ALDImageType: {0:d} {1:d}\n", samples, bits); + } + obj1.free(); + + dict->lookup("Overprint", &obj1); + if (obj1.isBool()) { + writePSFmt("%ALDImageOverprint: {0:s}\n", + obj1.getBool() ? "true" : "false"); + } + obj1.free(); + + dict->lookup("Position", &obj1); + if (obj1.isArray() && obj1.arrayGetLength() == 8) { + obj1.arrayGet(0, &obj2); + llx = obj2.getNum(); + obj2.free(); + obj1.arrayGet(1, &obj2); + lly = obj2.getNum(); + obj2.free(); + obj1.arrayGet(2, &obj2); + ulx = obj2.getNum(); + obj2.free(); + obj1.arrayGet(3, &obj2); + uly = obj2.getNum(); + obj2.free(); + obj1.arrayGet(4, &obj2); + urx = obj2.getNum(); + obj2.free(); + obj1.arrayGet(5, &obj2); + ury = obj2.getNum(); + obj2.free(); + obj1.arrayGet(6, &obj2); + lrx = obj2.getNum(); + obj2.free(); + obj1.arrayGet(7, &obj2); + lry = obj2.getNum(); + obj2.free(); + opiTransform(state, llx, lly, &tllx, &tlly); + opiTransform(state, ulx, uly, &tulx, &tuly); + opiTransform(state, urx, ury, &turx, &tury); + opiTransform(state, lrx, lry, &tlrx, &tlry); + writePSFmt("%ALDImagePosition: {0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g} {6:.6g} {7:.6g}\n", + tllx, tlly, tulx, tuly, turx, tury, tlrx, tlry); + obj2.free(); + } + obj1.free(); + + dict->lookup("Resolution", &obj1); + if (obj1.isArray() && obj1.arrayGetLength() == 2) { + obj1.arrayGet(0, &obj2); + horiz = obj2.getNum(); + obj2.free(); + obj1.arrayGet(1, &obj2); + vert = obj2.getNum(); + obj2.free(); + writePSFmt("%ALDImageResoution: {0:.6g} {1:.6g}\n", horiz, vert); + obj2.free(); + } + obj1.free(); + + dict->lookup("Size", &obj1); + if (obj1.isArray() && obj1.arrayGetLength() == 2) { + obj1.arrayGet(0, &obj2); + width = obj2.getInt(); + obj2.free(); + obj1.arrayGet(1, &obj2); + height = obj2.getInt(); + obj2.free(); + writePSFmt("%ALDImageDimensions: {0:d} {1:d}\n", width, height); + } + obj1.free(); + + //~ ignoring 'Tags' entry + //~ need to use writePSString() and deal with >255-char lines + + dict->lookup("Tint", &obj1); + if (obj1.isNum()) { + writePSFmt("%ALDImageTint: {0:.6g}\n", obj1.getNum()); + } + obj1.free(); + + dict->lookup("Transparency", &obj1); + if (obj1.isBool()) { + writePSFmt("%ALDImageTransparency: {0:s}\n", + obj1.getBool() ? "true" : "false"); + } + obj1.free(); + + writePS("%%BeginObject: image\n"); + writePS("opiMatrix2 setmatrix\n"); + ++opi13Nest; +} + +// Convert PDF user space coordinates to PostScript default user space +// coordinates. This has to account for both the PDF CTM and the +// PSOutputDev page-fitting transform. +void PSOutputDev::opiTransform(GfxState *state, double x0, double y0, + double *x1, double *y1) { + double t; + + state->transform(x0, y0, x1, y1); + *x1 += tx; + *y1 += ty; + if (rotate == 90) { + t = *x1; + *x1 = -*y1; + *y1 = t; + } else if (rotate == 180) { + *x1 = -*x1; + *y1 = -*y1; + } else if (rotate == 270) { + t = *x1; + *x1 = *y1; + *y1 = -t; + } + *x1 *= xScale; + *y1 *= yScale; +} + +void PSOutputDev::opiEnd(GfxState *state, Dict *opiDict) { + Object dict; + + if (generateOPI) { + opiDict->lookup("2.0", &dict); + if (dict.isDict()) { + writePS("%%EndIncludedImage\n"); + writePS("%%EndOPI\n"); + writePS("grestore\n"); + --opi20Nest; + dict.free(); + } else { + dict.free(); + opiDict->lookup("1.3", &dict); + if (dict.isDict()) { + writePS("%%EndObject\n"); + writePS("restore\n"); + --opi13Nest; + } + dict.free(); + } + } +} +#endif // OPI_SUPPORT + +void PSOutputDev::type3D0(GfxState *state, double wx, double wy) { + writePSFmt("{0:.6g} {1:.6g} setcharwidth\n", wx, wy); + writePS("q\n"); + t3NeedsRestore = gTrue; +} + +void PSOutputDev::type3D1(GfxState *state, double wx, double wy, + double llx, double lly, double urx, double ury) { + t3WX = wx; + t3WY = wy; + t3LLX = llx; + t3LLY = lly; + t3URX = urx; + t3URY = ury; + t3String = new GooString(); + writePS("q\n"); + t3FillColorOnly = gTrue; + t3Cacheable = gTrue; + t3NeedsRestore = gTrue; +} + +void PSOutputDev::drawForm(Ref id) { + writePSFmt("f_{0:d}_{1:d}\n", id.num, id.gen); +} + +void PSOutputDev::psXObject(Stream *psStream, Stream *level1Stream) { + Stream *str; + int c; + + if ((level == psLevel1 || level == psLevel1Sep) && level1Stream) { + str = level1Stream; + } else { + str = psStream; + } + str->reset(); + while ((c = str->getChar()) != EOF) { + writePSChar(c); + } + str->close(); +} + +//~ can nextFunc be reset to 0 -- maybe at the start of each page? +//~ or maybe at the start of each color space / pattern? +void PSOutputDev::cvtFunction(Function *func, GBool invertPSFunction) { + SampledFunction *func0; + ExponentialFunction *func2; + StitchingFunction *func3; + PostScriptFunction *func4; + int thisFunc, m, n, nSamples, i, j, k; + + switch (func->getType()) { + + case -1: // identity + writePS("{}\n"); + break; + + case 0: // sampled + func0 = (SampledFunction *)func; + thisFunc = nextFunc++; + m = func0->getInputSize(); + n = func0->getOutputSize(); + nSamples = n; + for (i = 0; i < m; ++i) { + nSamples *= func0->getSampleSize(i); + } + writePSFmt("/xpdfSamples{0:d} [\n", thisFunc); + for (i = 0; i < nSamples; ++i) { + writePSFmt("{0:.6g}\n", func0->getSamples()[i]); + } + writePS("] def\n"); + writePSFmt("{{ {0:d} array {1:d} array {2:d} 2 roll\n", 2*m, m, m+2); + // [e01] [efrac] x0 x1 ... xm-1 + for (i = m-1; i >= 0; --i) { + // [e01] [efrac] x0 x1 ... xi + writePSFmt("{0:.6g} sub {1:.6g} mul {2:.6g} add\n", + func0->getDomainMin(i), + (func0->getEncodeMax(i) - func0->getEncodeMin(i)) / + (func0->getDomainMax(i) - func0->getDomainMin(i)), + func0->getEncodeMin(i)); + // [e01] [efrac] x0 x1 ... xi-1 xi' + writePSFmt("dup 0 lt {{ pop 0 }} {{ dup {0:d} gt {{ pop {1:d} }} if }} ifelse\n", + func0->getSampleSize(i) - 1, func0->getSampleSize(i) - 1); + // [e01] [efrac] x0 x1 ... xi-1 xi' + writePS("dup floor cvi exch dup ceiling cvi exch 2 index sub\n"); + // [e01] [efrac] x0 x1 ... xi-1 floor(xi') ceiling(xi') xi'-floor(xi') + writePSFmt("{0:d} index {1:d} 3 2 roll put\n", i+3, i); + // [e01] [efrac] x0 x1 ... xi-1 floor(xi') ceiling(xi') + writePSFmt("{0:d} index {1:d} 3 2 roll put\n", i+3, 2*i+1); + // [e01] [efrac] x0 x1 ... xi-1 floor(xi') + writePSFmt("{0:d} index {1:d} 3 2 roll put\n", i+2, 2*i); + // [e01] [efrac] x0 x1 ... xi-1 + } + // [e01] [efrac] + for (i = 0; i < n; ++i) { + // [e01] [efrac] y(0) ... y(i-1) + for (j = 0; j < (1<<m); ++j) { + // [e01] [efrac] y(0) ... y(i-1) s(0) s(1) ... s(j-1) + writePSFmt("xpdfSamples{0:d}\n", thisFunc); + k = m - 1; + writePSFmt("{0:d} index {1:d} get\n", i+j+2, 2 * k + ((j >> k) & 1)); + for (k = m - 2; k >= 0; --k) { + writePSFmt("{0:d} mul {1:d} index {2:d} get add\n", + func0->getSampleSize(k), + i + j + 3, + 2 * k + ((j >> k) & 1)); + } + if (n > 1) { + writePSFmt("{0:d} mul {1:d} add ", n, i); + } + writePS("get\n"); + } + // [e01] [efrac] y(0) ... y(i-1) s(0) s(1) ... s(2^m-1) + for (j = 0; j < m; ++j) { + // [e01] [efrac] y(0) ... y(i-1) s(0) s(1) ... s(2^(m-j)-1) + for (k = 0; k < (1 << (m - j)); k += 2) { + // [e01] [efrac] y(0) ... y(i-1) <k/2 s' values> <2^(m-j)-k s values> + writePSFmt("{0:d} index {1:d} get dup\n", + i + k/2 + (1 << (m-j)) - k, j); + writePS("3 2 roll mul exch 1 exch sub 3 2 roll mul add\n"); + writePSFmt("{0:d} 1 roll\n", k/2 + (1 << (m-j)) - k - 1); + } + // [e01] [efrac] s'(0) s'(1) ... s(2^(m-j-1)-1) + } + // [e01] [efrac] y(0) ... y(i-1) s + writePSFmt("{0:.6g} mul {1:.6g} add\n", + func0->getDecodeMax(i) - func0->getDecodeMin(i), + func0->getDecodeMin(i)); + writePSFmt("dup {0:.6g} lt {{ pop {1:.6g} }} {{ dup {2:.6g} gt {{ pop {3:.6g} }} if }} ifelse\n", + func0->getRangeMin(i), func0->getRangeMin(i), + func0->getRangeMax(i), func0->getRangeMax(i)); + // [e01] [efrac] y(0) ... y(i-1) y(i) + } + // [e01] [efrac] y(0) ... y(n-1) + writePSFmt("{0:d} {1:d} roll pop pop \n", n+2, n); + if (invertPSFunction) { + for (i = 0; i < n; ++i) { + writePSFmt("{0:d} -1 roll ", n); + writePSFmt("{0:.6g} sub {1:.6g} div ", func0->getRangeMin(i), func0->getRangeMax(i) - func0->getRangeMin(i)); + } + } + writePS("}\n"); + break; + + case 2: // exponential + func2 = (ExponentialFunction *)func; + n = func2->getOutputSize(); + writePSFmt("{{ dup {0:.6g} lt {{ pop {1:.6g} }} {{ dup {2:.6g} gt {{ pop {3:.6g} }} if }} ifelse\n", + func2->getDomainMin(0), func2->getDomainMin(0), + func2->getDomainMax(0), func2->getDomainMax(0)); + // x + for (i = 0; i < n; ++i) { + // x y(0) .. y(i-1) + writePSFmt("{0:d} index {1:.6g} exp {2:.6g} mul {3:.6g} add\n", + i, func2->getE(), func2->getC1()[i] - func2->getC0()[i], + func2->getC0()[i]); + if (func2->getHasRange()) { + writePSFmt("dup {0:.6g} lt {{ pop {1:.6g} }} {{ dup {2:.6g} gt {{ pop {3:.6g} }} if }} ifelse\n", + func2->getRangeMin(i), func2->getRangeMin(i), + func2->getRangeMax(i), func2->getRangeMax(i)); + } + } + // x y(0) .. y(n-1) + writePSFmt("{0:d} {1:d} roll pop \n", n+1, n); + if (invertPSFunction && func2->getHasRange()) { + for (i = 0; i < n; ++i) { + writePSFmt("{0:d} -1 roll ", n); + writePSFmt("{0:.6g} sub {1:.6g} div ", func2->getRangeMin(i), func2->getRangeMax(i) - func2->getRangeMin(i)); + } + } + writePS("}\n"); + break; + + case 3: // stitching + func3 = (StitchingFunction *)func; + thisFunc = nextFunc++; + for (i = 0; i < func3->getNumFuncs(); ++i) { + cvtFunction(func3->getFunc(i)); + writePSFmt("/xpdfFunc{0:d}_{1:d} exch def\n", thisFunc, i); + } + writePSFmt("{{ dup {0:.6g} lt {{ pop {1:.6g} }} {{ dup {2:.6g} gt {{ pop {3:.6g} }} if }} ifelse\n", + func3->getDomainMin(0), func3->getDomainMin(0), + func3->getDomainMax(0), func3->getDomainMax(0)); + for (i = 0; i < func3->getNumFuncs() - 1; ++i) { + writePSFmt("dup {0:.6g} lt {{ {1:.6g} sub {2:.6g} mul {3:.6g} add xpdfFunc{4:d}_{5:d} }} {{\n", + func3->getBounds()[i+1], + func3->getBounds()[i], + func3->getScale()[i], + func3->getEncode()[2*i], + thisFunc, i); + } + writePSFmt("{0:.6g} sub {1:.6g} mul {2:.6g} add xpdfFunc{3:d}_{4:d}\n", + func3->getBounds()[i], + func3->getScale()[i], + func3->getEncode()[2*i], + thisFunc, i); + for (i = 0; i < func3->getNumFuncs() - 1; ++i) { + writePS("} ifelse\n"); + } + if (invertPSFunction && func3->getHasRange()) { + n = func3->getOutputSize(); + for (i = 0; i < n; ++i) { + writePSFmt("{0:d} -1 roll ", n); + writePSFmt("{0:.6g} sub {1:.6g} div ", func3->getRangeMin(i), func3->getRangeMax(i) - func3->getRangeMin(i)); + } + } + writePS("}\n"); + break; + + case 4: // PostScript + func4 = (PostScriptFunction *)func; + if (invertPSFunction) { + GooString *codeString = new GooString(func4->getCodeString()); + for (i = codeString->getLength() -1; i > 0; i--) { + if (codeString->getChar(i) == '}') { + codeString->del(i); + break; + } + } + writePS(codeString->getCString()); + writePS("\n"); + delete codeString; + n = func4->getOutputSize(); + for (i = 0; i < n; ++i) { + writePSFmt("{0:d} -1 roll ", n); + writePSFmt("{0:.6g} sub {1:.6g} div ", func4->getRangeMin(i), func4->getRangeMax(i) - func4->getRangeMin(i)); + } + writePS("}\n"); + } else { + writePS(func4->getCodeString()->getCString()); + writePS("\n"); + } + break; + } +} + +void PSOutputDev::writePSChar(char c) { + if (t3String) { + t3String->append(c); + } else { + (*outputFunc)(outputStream, &c, 1); + } +} + +void PSOutputDev::writePS(const char *s) { + if (t3String) { + t3String->append(s); + } else { + (*outputFunc)(outputStream, s, strlen(s)); + } +} + +void PSOutputDev::writePSBuf(const char *s, int len) { + if (t3String) { + for (int i = 0; i < len; i++) { + t3String->append(s[i]); + } + } else { + (*outputFunc)(outputStream, s, len); + } +} + +void PSOutputDev::writePSFmt(const char *fmt, ...) { + va_list args; + GooString *buf; + + va_start(args, fmt); + if (t3String) { + t3String->appendfv((char *)fmt, args); + } else { + buf = GooString::formatv((char *)fmt, args); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + } + va_end(args); +} + +void PSOutputDev::writePSString(GooString *s) { + Guchar *p; + int n, line; + char buf[8]; + + writePSChar('('); + line = 1; + for (p = (Guchar *)s->getCString(), n = s->getLength(); n; ++p, --n) { + if (line >= 64) { + writePSChar('\\'); + writePSChar('\n'); + line = 0; + } + if (*p == '(' || *p == ')' || *p == '\\') { + writePSChar('\\'); + writePSChar((char)*p); + line += 2; + } else if (*p < 0x20 || *p >= 0x80) { + sprintf(buf, "\\%03o", *p); + writePS(buf); + line += 4; + } else { + writePSChar((char)*p); + ++line; + } + } + writePSChar(')'); +} + +void PSOutputDev::writePSName(const char *s) { + const char *p; + char c; + + p = s; + while ((c = *p++)) { + if (c <= (char)0x20 || c >= (char)0x7f || + c == '(' || c == ')' || c == '<' || c == '>' || + c == '[' || c == ']' || c == '{' || c == '}' || + c == '/' || c == '%' || c == '\\') { + writePSFmt("#{0:02x}", c & 0xff); + } else { + writePSChar(c); + } + } +} + +GooString *PSOutputDev::filterPSName(GooString *name) { + GooString *name2; + char buf[8]; + int i; + char c; + + name2 = new GooString(); + + // ghostscript chokes on names that begin with out-of-limits + // numbers, e.g., 1e4foo is handled correctly (as a name), but + // 1e999foo generates a limitcheck error + c = name->getChar(0); + if (c >= '0' && c <= '9') { + name2->append('f'); + } + + for (i = 0; i < name->getLength(); ++i) { + c = name->getChar(i); + if (c <= (char)0x20 || c >= (char)0x7f || + c == '(' || c == ')' || c == '<' || c == '>' || + c == '[' || c == ']' || c == '{' || c == '}' || + c == '/' || c == '%') { + sprintf(buf, "#%02x", c & 0xff); + name2->append(buf); + } else { + name2->append(c); + } + } + return name2; +} + +// Convert GooString to GooString, with appropriate escaping +// of things that can't appear in a label +// This is heavily based on the writePSTextLine() method +GooString* PSOutputDev::filterPSLabel(GooString *label, GBool *needParens) { + int i, step; + GBool isNumeric; + + // - DSC comments must be printable ASCII; control chars and + // backslashes have to be escaped (we do cheap UCS2-to-ASCII + // conversion by simply ignoring the high byte) + // - parentheses are escaped. this isn't strictly necessary for matched + // parentheses, but shouldn't be a problem + // - lines are limited to 255 chars (we limit to 200 here to allow + // for the keyword, which was emitted by the caller) + + GooString *label2 = new GooString(); + int labelLength = label->getLength(); + + if (labelLength == 0) { + isNumeric = false; + } else { + // this gets changed later if we find a non-numeric character + isNumeric = true; + } + + if ( (labelLength >= 2) && + ( (label->getChar(0) & 0xff) == 0xfe) && + ( (label->getChar(1) & 0xff) == 0xff) ) { + // UCS2 mode + i = 3; + step = 2; + if ( (label->getChar(labelLength-1) == 0) ) { + // prune the trailing null (0x000 for UCS2) + labelLength -= 2; + } + } else { + i = 0; + step = 1; + } + for (int j = 0; i < labelLength && j < 200; i += step) { + char c = label->getChar(i); + if ( (c < '0') || (c > '9') ) { + isNumeric = false; + } + if (c == '\\') { + label2->append("\\\\"); + j += 2; + } else if (c == ')') { + label2->append("\\)"); + } else if (c == '(') { + label2->append("\\("); + } else if (c < 0x20 || c > 0x7e) { + label2->append(GooString::format("\\{0:03o}", c)); + j += 4; + } else { + label2->append(c); + ++j; + } + } + if (needParens) { + *needParens = !(isNumeric); + } + return label2; +} + +// Write a DSC-compliant <textline>. +void PSOutputDev::writePSTextLine(GooString *s) { + int i, j, step; + int c; + + // - DSC comments must be printable ASCII; control chars and + // backslashes have to be escaped (we do cheap Unicode-to-ASCII + // conversion by simply ignoring the high byte) + // - lines are limited to 255 chars (we limit to 200 here to allow + // for the keyword, which was emitted by the caller) + // - lines that start with a left paren are treated as <text> + // instead of <textline>, so we escape a leading paren + if (s->getLength() >= 2 && + (s->getChar(0) & 0xff) == 0xfe && + (s->getChar(1) & 0xff) == 0xff) { + i = 3; + step = 2; + } else { + i = 0; + step = 1; + } + for (j = 0; i < s->getLength() && j < 200; i += step) { + c = s->getChar(i) & 0xff; + if (c == '\\') { + writePS("\\\\"); + j += 2; + } else if (c < 0x20 || c > 0x7e || (j == 0 && c == '(')) { + writePSFmt("\\{0:03o}", c); + j += 4; + } else { + writePSChar(c); + ++j; + } + } + writePS("\n"); +} diff --git a/source/libs/poppler/poppler-0.33.0/poppler/PSOutputDev.h b/source/libs/poppler/poppler-0.33.0/poppler/PSOutputDev.h new file mode 100644 index 000000000..7318cafdf --- /dev/null +++ b/source/libs/poppler/poppler-0.33.0/poppler/PSOutputDev.h @@ -0,0 +1,546 @@ +//======================================================================== +// +// PSOutputDev.h +// +// Copyright 1996-2003 Glyph & Cog, LLC +// +//======================================================================== + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> +// Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> +// Copyright (C) 2006-2008, 2012, 2013, 2015 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2007 Brad Hards <bradh@kde.org> +// Copyright (C) 2009-2013 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2009 Till Kamppeter <till.kamppeter@gmail.com> +// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org> +// Copyright (C) 2009, 2011, 2015 William Bader <williambader@hotmail.com> +// Copyright (C) 2010 Hib Eris <hib@hiberis.nl> +// Copyright (C) 2011, 2014 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#ifndef PSOUTPUTDEV_H +#define PSOUTPUTDEV_H + +#ifdef USE_GCC_PRAGMAS +#pragma interface +#endif + +#include "poppler-config.h" +#include <stddef.h> +#include "Object.h" +#include "GfxState.h" +#include "GlobalParams.h" +#include "OutputDev.h" +#include <set> +#include <map> +#include <vector> + +class GHooash; +class PDFDoc; +class XRef; +class Function; +class GfxPath; +class GfxFont; +class GfxColorSpace; +class GfxSeparationColorSpace; +class PDFRectangle; +struct PST1FontName; +struct PSFont8Info; +struct PSFont16Enc; +class PSOutCustomColor; +class PSOutputDev; + +//------------------------------------------------------------------------ +// PSOutputDev +//------------------------------------------------------------------------ + +enum PSOutMode { + psModePS, + psModeEPS, + psModeForm +}; + +enum PSFileType { + psFile, // write to file + psPipe, // write to pipe + psStdout, // write to stdout + psGeneric // write to a generic stream +}; + +enum PSOutCustomCodeLocation { + psOutCustomDocSetup, + psOutCustomPageSetup +}; + +typedef void (*PSOutputFunc)(void *stream, const char *data, int len); + +typedef GooString *(*PSOutCustomCodeCbk)(PSOutputDev *psOut, + PSOutCustomCodeLocation loc, int n, + void *data); + +class PSOutputDev: public OutputDev { +public: + + // Open a PostScript output file, and write the prolog. + // pages has to be sorted in increasing order + PSOutputDev(const char *fileName, PDFDoc *docA, + char *psTitleA, + const std::vector<int> &pages, PSOutMode modeA, + int paperWidthA = -1, int paperHeightA = -1, + GBool noCrop = gFalse, + GBool duplexA = gTrue, + int imgLLXA = 0, int imgLLYA = 0, + int imgURXA = 0, int imgURYA = 0, + GBool forceRasterizeA = gFalse, + GBool manualCtrlA = gFalse, + PSOutCustomCodeCbk customCodeCbkA = NULL, + void *customCodeCbkDataA = NULL); + + // Open a PSOutputDev that will write to a generic stream. + // pages has to be sorted in increasing order + PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA, + char *psTitleA, + PDFDoc *docA, + const std::vector<int> &pages, PSOutMode modeA, + int paperWidthA = -1, int paperHeightA = -1, + GBool noCrop = gFalse, + GBool duplexA = gTrue, + int imgLLXA = 0, int imgLLYA = 0, + int imgURXA = 0, int imgURYA = 0, + GBool forceRasterizeA = gFalse, + GBool manualCtrlA = gFalse, + PSOutCustomCodeCbk customCodeCbkA = NULL, + void *customCodeCbkDataA = NULL); + + // Destructor -- writes the trailer and closes the file. + virtual ~PSOutputDev(); + + // Check if file was successfully created. + virtual GBool isOk() { return ok; } + + //---- get info about output device + + // Does this device use upside-down coordinates? + // (Upside-down means (0,0) is the top left corner of the page.) + virtual GBool upsideDown() { return gFalse; } + + // Does this device use drawChar() or drawString()? + virtual GBool useDrawChar() { return gFalse; } + + // Does this device use tilingPatternFill()? If this returns false, + // tiling pattern fills will be reduced to a series of other drawing + // operations. + virtual GBool useTilingPatternFill() { return gTrue; } + + // Does this device use functionShadedFill(), axialShadedFill(), and + // radialShadedFill()? If this returns false, these shaded fills + // will be reduced to a series of other drawing operations. + virtual GBool useShadedFills(int type) + { return type < 4 && level >= psLevel2; } + + // Does this device use drawForm()? If this returns false, + // form-type XObjects will be interpreted (i.e., unrolled). + virtual GBool useDrawForm() { return preloadImagesForms; } + + // Does this device use beginType3Char/endType3Char? Otherwise, + // text in Type 3 fonts will be drawn with drawChar/drawString. + virtual GBool interpretType3Chars() { return gFalse; } + + virtual GBool needClipToCropBox() { return mode == psModeEPS; } + + //----- header/trailer (used only if manualCtrl is true) + + // Write the document-level header. + void writeHeader(const std::vector<int> &pages, + PDFRectangle *mediaBox, PDFRectangle *cropBox, + int pageRotate, char *pstitle); + + // Write the Xpdf procset. + void writeXpdfProcset(); + + // Write the trailer for the current page. + void writePageTrailer(); + + // Write the document trailer. + void writeTrailer(); + + //----- initialization and control + + // Check to see if a page slice should be displayed. If this + // returns false, the page display is aborted. Typically, an + // OutputDev will use some alternate means to display the page + // before returning false. + virtual GBool checkPageSlice(Page *page, double hDPI, double vDPI, + int rotate, GBool useMediaBox, GBool crop, + int sliceX, int sliceY, int sliceW, int sliceH, + GBool printing, + GBool (*abortCheckCbk)(void *data) = NULL, + void *abortCheckCbkData = NULL, + GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = NULL, + void *annotDisplayDecideCbkData = NULL); + + // Start a page. + virtual void startPage(int pageNum, GfxState *state, XRef *xref); + + // End a page. + virtual void endPage(); + + //----- save/restore graphics state + virtual void saveState(GfxState *state); + virtual void restoreState(GfxState *state); + + //----- update graphics state + virtual void updateCTM(GfxState *state, double m11, double m12, + double m21, double m22, double m31, double m32); + virtual void updateLineDash(GfxState *state); + virtual void updateFlatness(GfxState *state); + virtual void updateLineJoin(GfxState *state); + virtual void updateLineCap(GfxState *state); + virtual void updateMiterLimit(GfxState *state); + virtual void updateLineWidth(GfxState *state); + virtual void updateFillColorSpace(GfxState *state); + virtual void updateStrokeColorSpace(GfxState *state); + virtual void updateFillColor(GfxState *state); + virtual void updateStrokeColor(GfxState *state); + virtual void updateFillOverprint(GfxState *state); + virtual void updateStrokeOverprint(GfxState *state); + virtual void updateOverprintMode(GfxState *state); + virtual void updateTransfer(GfxState *state); + + //----- update text state + virtual void updateFont(GfxState *state); + virtual void updateTextMat(GfxState *state); + virtual void updateCharSpace(GfxState *state); + virtual void updateRender(GfxState *state); + virtual void updateRise(GfxState *state); + virtual void updateWordSpace(GfxState *state); + virtual void updateHorizScaling(GfxState *state); + virtual void updateTextPos(GfxState *state); + virtual void updateTextShift(GfxState *state, double shift); + virtual void saveTextPos(GfxState *state); + virtual void restoreTextPos(GfxState *state); + + //----- path painting + virtual void stroke(GfxState *state); + virtual void fill(GfxState *state); + virtual void eoFill(GfxState *state); + virtual GBool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, Object *str, + double *pmat, int paintType, int tilingType, Dict *resDict, + double *mat, double *bbox, + int x0, int y0, int x1, int y1, + double xStep, double yStep); + virtual GBool functionShadedFill(GfxState *state, + GfxFunctionShading *shading); + virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double /*tMin*/, double /*tMax*/); + virtual GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double /*sMin*/, double /*sMax*/); + + //----- path clipping + virtual void clip(GfxState *state); + virtual void eoClip(GfxState *state); + virtual void clipToStrokePath(GfxState *state); + + //----- text drawing + virtual void drawString(GfxState *state, GooString *s); + virtual void beginTextObject(GfxState *state); + virtual void endTextObject(GfxState *state); + + //----- image drawing + virtual void drawImageMask(GfxState *state, Object *ref, Stream *str, + int width, int height, GBool invert, + GBool interpolate, GBool inlineImg); + virtual void setSoftMaskFromImageMask(GfxState *state, + Object *ref, Stream *str, + int width, int height, GBool invert, + GBool inlineImg, double *baseMatrix); + virtual void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix); + virtual void drawImage(GfxState *state, Object *ref, Stream *str, + int width, int height, GfxImageColorMap *colorMap, + GBool interpolate, int *maskColors, GBool inlineImg); + virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str, + int width, int height, + GfxImageColorMap *colorMap, + GBool interpolate, + Stream *maskStr, int maskWidth, int maskHeight, + GBool maskInvert, GBool maskInterpolate); + +#if OPI_SUPPORT + //----- OPI functions + virtual void opiBegin(GfxState *state, Dict *opiDict); + virtual void opiEnd(GfxState *state, Dict *opiDict); +#endif + + //----- Type 3 font operators + virtual void type3D0(GfxState *state, double wx, double wy); + virtual void type3D1(GfxState *state, double wx, double wy, + double llx, double lly, double urx, double ury); + + //----- form XObjects + virtual void drawForm(Ref ref); + + //----- PostScript XObjects + virtual void psXObject(Stream *psStream, Stream *level1Stream); + + //----- miscellaneous + void setOffset(double x, double y) + { tx0 = x; ty0 = y; } + void setScale(double x, double y) + { xScale0 = x; yScale0 = y; } + void setRotate(int rotateA) + { rotate0 = rotateA; } + void setClip(double llx, double lly, double urx, double ury) + { clipLLX0 = llx; clipLLY0 = lly; clipURX0 = urx; clipURY0 = ury; } + void setUnderlayCbk(void (*cbk)(PSOutputDev *psOut, void *data), + void *data) + { underlayCbk = cbk; underlayCbkData = data; } + void setOverlayCbk(void (*cbk)(PSOutputDev *psOut, void *data), + void *data) + { overlayCbk = cbk; overlayCbkData = data; } + void setDisplayText(GBool display) { displayText = display; } + + void setRasterAntialias(GBool a) { rasterAntialias = a; } + void setRasterResolution(double r) { rasterResolution = r; } + void setRasterMono(GBool b) { rasterMono = b; } + void setUncompressPreloadedImages(GBool b) { uncompressPreloadedImages = b; } + + GBool getEmbedType1() const { return embedType1; } + GBool getEmbedTrueType() const { return embedTrueType; } + GBool getEmbedCIDPostScript() const { return embedCIDPostScript; } + GBool getEmbedCIDTrueType() const { return embedCIDTrueType; } + GBool getFontPassthrough() const { return fontPassthrough; } + GBool getOptimizeColorSpace() const { return optimizeColorSpace; } + void setEmbedType1(GBool b) { embedType1 = b; } + void setEmbedTrueType(GBool b) { embedTrueType = b; } + void setEmbedCIDPostScript(GBool b) { embedCIDPostScript = b; } + void setEmbedCIDTrueType(GBool b) { embedCIDTrueType = b; } + void setFontPassthrough(GBool b) { fontPassthrough = b; } + void setOptimizeColorSpace(GBool b) { optimizeColorSpace = b; } + void setPreloadImagesForms(GBool b) { preloadImagesForms = b; } + void setGenerateOPI(GBool b) { generateOPI = b; } + void setUseASCIIHex(GBool b) { useASCIIHex = b; } + void setUseBinary(GBool b) { useBinary = b; } + +private: + + void init(PSOutputFunc outputFuncA, void *outputStreamA, + PSFileType fileTypeA, char *psTitleA, PDFDoc *doc, + const std::vector<int> &pages, PSOutMode modeA, + int imgLLXA, int imgLLYA, int imgURXA, int imgURYA, + GBool manualCtrlA, int paperWidthA, int paperHeightA, + GBool noCropA, GBool duplexA); + void postInit(); + void setupResources(Dict *resDict); + void setupFonts(Dict *resDict); + void setupFont(GfxFont *font, Dict *parentResDict); + void setupEmbeddedType1Font(Ref *id, GooString *psName); + void setupExternalType1Font(GooString *fileName, GooString *psName); + void setupEmbeddedType1CFont(GfxFont *font, Ref *id, GooString *psName); + void setupEmbeddedOpenTypeT1CFont(GfxFont *font, Ref *id, GooString *psName); + void setupEmbeddedTrueTypeFont(GfxFont *font, Ref *id, GooString *psName); + void setupExternalTrueTypeFont(GfxFont *font, GooString *fileName, + GooString *psName); + void setupEmbeddedCIDType0Font(GfxFont *font, Ref *id, GooString *psName); + void setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id, GooString *psName, + GBool needVerticalMetrics); + void setupExternalCIDTrueTypeFont(GfxFont *font, + GooString *fileName, + GooString *psName, + GBool needVerticalMetrics); + void setupEmbeddedOpenTypeCFFFont(GfxFont *font, Ref *id, GooString *psName); + void setupType3Font(GfxFont *font, GooString *psName, Dict *parentResDict); + GooString *makePSFontName(GfxFont *font, Ref *id); + void setupImages(Dict *resDict); + void setupImage(Ref id, Stream *str, GBool mask); + void setupForms(Dict *resDict); + void setupForm(Ref id, Object *strObj); + void addProcessColor(double c, double m, double y, double k); + void addCustomColor(GfxSeparationColorSpace *sepCS); + void doPath(GfxPath *path); + void maskToClippingPath(Stream *maskStr, int maskWidth, int maskHeight, GBool maskInvert); + void doImageL1(Object *ref, GfxImageColorMap *colorMap, + GBool invert, GBool inlineImg, + Stream *str, int width, int height, int len, + int *maskColors, Stream *maskStr, + int maskWidth, int maskHeight, GBool maskInvert); + void doImageL1Sep(Object *ref, GfxImageColorMap *colorMap, + GBool invert, GBool inlineImg, + Stream *str, int width, int height, int len, + int *maskColors, Stream *maskStr, + int maskWidth, int maskHeight, GBool maskInvert); + void doImageL2(Object *ref, GfxImageColorMap *colorMap, + GBool invert, GBool inlineImg, + Stream *str, int width, int height, int len, + int *maskColors, Stream *maskStr, + int maskWidth, int maskHeight, GBool maskInvert); + void doImageL3(Object *ref, GfxImageColorMap *colorMap, + GBool invert, GBool inlineImg, + Stream *str, int width, int height, int len, + int *maskColors, Stream *maskStr, + int maskWidth, int maskHeight, GBool maskInvert); + void dumpColorSpaceL2(GfxColorSpace *colorSpace, + GBool genXform, GBool updateColors, + GBool map01); + GBool tilingPatternFillL1(GfxState *state, Catalog *cat, Object *str, + double *pmat, int paintType, int tilingType, Dict *resDict, + double *mat, double *bbox, + int x0, int y0, int x1, int y1, + double xStep, double yStep); + GBool tilingPatternFillL2(GfxState *state, Catalog *cat, Object *str, + double *pmat, int paintType, int tilingType, Dict *resDict, + double *mat, double *bbox, + int x0, int y0, int x1, int y1, + double xStep, double yStep); + +#if OPI_SUPPORT + void opiBegin20(GfxState *state, Dict *dict); + void opiBegin13(GfxState *state, Dict *dict); + void opiTransform(GfxState *state, double x0, double y0, + double *x1, double *y1); +#endif + void cvtFunction(Function *func, GBool invertPSFunction = gFalse); + GooString *filterPSName(GooString *name); + + // Write the document-level setup. + void writeDocSetup(PDFDoc *doc, Catalog *catalog, const std::vector<int> &pages, GBool duplexA); + + void writePSChar(char c); + void writePS(const char *s); + void writePSBuf(const char *s, int len); + void writePSFmt(const char *fmt, ...); + void writePSString(GooString *s); + void writePSName(const char *s); + GooString *filterPSLabel(GooString *label, GBool *needParens=0); + void writePSTextLine(GooString *s); + + PSLevel level; // PostScript level (1, 2, separation) + PSOutMode mode; // PostScript mode (PS, EPS, form) + int paperWidth; // width of paper, in pts + int paperHeight; // height of paper, in pts + GBool paperMatch; // true if paper size is set to match each page + int prevWidth; // width of previous page + // (only psModePSOrigPageSizes output mode) + int prevHeight; // height of previous page + // (only psModePSOrigPageSizes output mode) + int imgLLX, imgLLY, // imageable area, in pts + imgURX, imgURY; + GBool noCrop; + GBool duplex; + std::vector<int> pages; + char *psTitle; + GBool postInitDone; // true if postInit() was called + + PSOutputFunc outputFunc; + void *outputStream; + PSFileType fileType; // file / pipe / stdout + GBool manualCtrl; + int seqPage; // current sequential page number + void (*underlayCbk)(PSOutputDev *psOut, void *data); + void *underlayCbkData; + void (*overlayCbk)(PSOutputDev *psOut, void *data); + void *overlayCbkData; + GooString *(*customCodeCbk)(PSOutputDev *psOut, + PSOutCustomCodeLocation loc, int n, + void *data); + void *customCodeCbkData; + + PDFDoc *doc; + XRef *xref; // the xref table for this PDF file + + Ref *fontIDs; // list of object IDs of all used fonts + int fontIDLen; // number of entries in fontIDs array + int fontIDSize; // size of fontIDs array + std::set<int> resourceIDs; // list of object IDs of objects containing Resources we've already set up + GooHash *fontNames; // all used font names + PST1FontName *t1FontNames; // font names for Type 1/1C fonts + int t1FontNameLen; // number of entries in t1FontNames array + int t1FontNameSize; // size of t1FontNames array + PSFont8Info *font8Info; // info for 8-bit fonts + int font8InfoLen; // number of entries in font8Info array + int font8InfoSize; // size of font8Info array + PSFont16Enc *font16Enc; // encodings for substitute 16-bit fonts + int font16EncLen; // number of entries in font16Enc array + int font16EncSize; // size of font16Enc array + Ref *imgIDs; // list of image IDs for in-memory images + int imgIDLen; // number of entries in imgIDs array + int imgIDSize; // size of imgIDs array + Ref *formIDs; // list of IDs for predefined forms + int formIDLen; // number of entries in formIDs array + int formIDSize; // size of formIDs array + int numSaves; // current number of gsaves + int numTilingPatterns; // current number of nested tiling patterns + int nextFunc; // next unique number to use for a function + + GooList *paperSizes; // list of used paper sizes, if paperMatch + // is true [PSOutPaperSize] + std::map<int,int> pagePaperSize; // page num to paperSize entry mapping + double tx0, ty0; // global translation + double xScale0, yScale0; // global scaling + int rotate0; // rotation angle (0, 90, 180, 270) + double clipLLX0, clipLLY0, + clipURX0, clipURY0; + double tx, ty; // global translation for current page + double xScale, yScale; // global scaling for current page + int rotate; // rotation angle for current page + double epsX1, epsY1, // EPS bounding box (unrotated) + epsX2, epsY2; + + GooString *embFontList; // resource comments for embedded fonts + + int processColors; // used process colors + PSOutCustomColor // used custom colors + *customColors; + + GBool haveTextClip; // set if text has been drawn with a + // clipping render mode + + GBool inType3Char; // inside a Type 3 CharProc + GBool inUncoloredPattern; // inside a uncolored pattern (PaintType = 2) + GooString *t3String; // Type 3 content string + double t3WX, t3WY, // Type 3 character parameters + t3LLX, t3LLY, t3URX, t3URY; + GBool t3FillColorOnly; // operators should only use the fill color + GBool t3Cacheable; // cleared if char is not cacheable + GBool t3NeedsRestore; // set if a 'q' operator was issued + GBool forceRasterize; // forces the page to be rasterized into a image before printing + GBool displayText; // displayText + GBool rasterAntialias; // antialias on rasterize + GBool uncompressPreloadedImages; + double rasterResolution; // PostScript rasterization resolution (dpi) + GBool rasterMono; // true to do PostScript rasterization + // in monochrome (gray); false to do it + // in color (RGB/CMYK) + GBool embedType1; // embed Type 1 fonts? + GBool embedTrueType; // embed TrueType fonts? + GBool embedCIDPostScript; // embed CID PostScript fonts? + GBool embedCIDTrueType; // embed CID TrueType fonts? + GBool fontPassthrough; // pass all fonts through as-is? + GBool optimizeColorSpace; // false to keep gray RGB images in their original color space + // true to optimize gray images to DeviceGray color space + GBool preloadImagesForms; // preload PostScript images and forms into + // memory + GBool generateOPI; // generate PostScript OPI comments? + GBool useASCIIHex; // use ASCIIHex instead of ASCII85? + GBool useBinary; // use binary instead of hex + +#if OPI_SUPPORT + int opi13Nest; // nesting level of OPI 1.3 objects + int opi20Nest; // nesting level of OPI 2.0 objects +#endif + + GBool ok; // set up ok? + + friend class WinPDFPrinter; +}; + +#endif diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PSTokenizer.cc b/source/libs/poppler/poppler-0.33.0/poppler/PSTokenizer.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/PSTokenizer.cc rename to source/libs/poppler/poppler-0.33.0/poppler/PSTokenizer.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PSTokenizer.h b/source/libs/poppler/poppler-0.33.0/poppler/PSTokenizer.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/PSTokenizer.h rename to source/libs/poppler/poppler-0.33.0/poppler/PSTokenizer.h diff --git a/source/libs/poppler/poppler-0.33.0/poppler/Page.cc b/source/libs/poppler/poppler-0.33.0/poppler/Page.cc new file mode 100644 index 000000000..a4af3405b --- /dev/null +++ b/source/libs/poppler/poppler-0.33.0/poppler/Page.cc @@ -0,0 +1,860 @@ +//======================================================================== +// +// Page.cc +// +// Copyright 1996-2007 Glyph & Cog, LLC +// +//======================================================================== + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> +// Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net> +// Copyright (C) 2005-2013 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006-2008 Pino Toscano <pino@kde.org> +// Copyright (C) 2006 Nickolay V. Shmyrev <nshmyrev@yandex.ru> +// Copyright (C) 2006 Scott Turner <scotty1024@mac.com> +// Copyright (C) 2006-2011, 2015 Carlos Garcia Campos <carlosgc@gnome.org> +// Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org> +// Copyright (C) 2008 Iñigo Martínez <inigomartinez@gmail.com> +// Copyright (C) 2008 Brad Hards <bradh@kde.org> +// Copyright (C) 2008 Ilya Gorenbein <igorenbein@finjan.com> +// Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it> +// Copyright (C) 2013, 2014 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2013 Jason Crain <jason@aquaticape.us> +// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2015 Philipp Reinkemeier <philipp.reinkemeier@offis.de> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#include <config.h> + +#ifdef USE_GCC_PRAGMAS +#pragma implementation +#endif + +#include <stddef.h> +#include <limits.h> +#include "GlobalParams.h" +#include "Object.h" +#include "Array.h" +#include "Dict.h" +#include "PDFDoc.h" +#include "XRef.h" +#include "Link.h" +#include "OutputDev.h" +#include "Gfx.h" +#include "GfxState.h" +#include "Annot.h" +#include "TextOutputDev.h" +#include "Form.h" +#include "Error.h" +#include "Page.h" +#include "Catalog.h" +#include "Form.h" + +#if MULTITHREADED +# define pageLocker() MutexLocker locker(&mutex) +#else +# define pageLocker() +#endif +//------------------------------------------------------------------------ +// PDFRectangle +//------------------------------------------------------------------------ + +void PDFRectangle::clipTo(PDFRectangle *rect) { + if (x1 < rect->x1) { + x1 = rect->x1; + } else if (x1 > rect->x2) { + x1 = rect->x2; + } + if (x2 < rect->x1) { + x2 = rect->x1; + } else if (x2 > rect->x2) { + x2 = rect->x2; + } + if (y1 < rect->y1) { + y1 = rect->y1; + } else if (y1 > rect->y2) { + y1 = rect->y2; + } + if (y2 < rect->y1) { + y2 = rect->y1; + } else if (y2 > rect->y2) { + y2 = rect->y2; + } +} + +//------------------------------------------------------------------------ +// PageAttrs +//------------------------------------------------------------------------ + +PageAttrs::PageAttrs(PageAttrs *attrs, Dict *dict) { + Object obj1; + PDFRectangle mBox; + const GBool isPage = dict->is("Page"); + + // get old/default values + if (attrs) { + mediaBox = attrs->mediaBox; + cropBox = attrs->cropBox; + haveCropBox = attrs->haveCropBox; + rotate = attrs->rotate; + attrs->resources.copy(&resources); + } else { + // set default MediaBox to 8.5" x 11" -- this shouldn't be necessary + // but some (non-compliant) PDF files don't specify a MediaBox + mediaBox.x1 = 0; + mediaBox.y1 = 0; + mediaBox.x2 = 612; + mediaBox.y2 = 792; + cropBox.x1 = cropBox.y1 = cropBox.x2 = cropBox.y2 = 0; + haveCropBox = gFalse; + rotate = 0; + resources.initNull(); + } + + // media box + if (readBox(dict, "MediaBox", &mBox)) { + mediaBox = mBox; + } + + // crop box + if (readBox(dict, "CropBox", &cropBox)) { + haveCropBox = gTrue; + } + if (!haveCropBox) { + cropBox = mediaBox; + } + + if (isPage) { + // cropBox can not be bigger than mediaBox + if (cropBox.x2 - cropBox.x1 > mediaBox.x2 - mediaBox.x1) + { + cropBox.x1 = mediaBox.x1; + cropBox.x2 = mediaBox.x2; + } + if (cropBox.y2 - cropBox.y1 > mediaBox.y2 - mediaBox.y1) + { + cropBox.y1 = mediaBox.y1; + cropBox.y2 = mediaBox.y2; + } + } + + // other boxes + bleedBox = cropBox; + readBox(dict, "BleedBox", &bleedBox); + trimBox = cropBox; + readBox(dict, "TrimBox", &trimBox); + artBox = cropBox; + readBox(dict, "ArtBox", &artBox); + + // rotate + dict->lookup("Rotate", &obj1); + if (obj1.isInt()) { + rotate = obj1.getInt(); + } + obj1.free(); + while (rotate < 0) { + rotate += 360; + } + while (rotate >= 360) { + rotate -= 360; + } + + // misc attributes + dict->lookup("LastModified", &lastModified); + dict->lookup("BoxColorInfo", &boxColorInfo); + dict->lookup("Group", &group); + dict->lookup("Metadata", &metadata); + dict->lookup("PieceInfo", &pieceInfo); + dict->lookup("SeparationInfo", &separationInfo); + + // resource dictionary + dict->lookup("Resources", &obj1); + if (obj1.isDict()) { + resources.free(); + obj1.copy(&resources); + } + obj1.free(); +} + +PageAttrs::~PageAttrs() { + lastModified.free(); + boxColorInfo.free(); + group.free(); + metadata.free(); + pieceInfo.free(); + separationInfo.free(); + resources.free(); +} + +void PageAttrs::clipBoxes() { + cropBox.clipTo(&mediaBox); + bleedBox.clipTo(&mediaBox); + trimBox.clipTo(&mediaBox); + artBox.clipTo(&mediaBox); +} + +GBool PageAttrs::readBox(Dict *dict, const char *key, PDFRectangle *box) { + PDFRectangle tmp; + double t; + Object obj1, obj2; + GBool ok; + + dict->lookup(key, &obj1); + if (obj1.isArray() && obj1.arrayGetLength() == 4) { + ok = gTrue; + obj1.arrayGet(0, &obj2); + if (obj2.isNum()) { + tmp.x1 = obj2.getNum(); + } else { + ok = gFalse; + } + obj2.free(); + obj1.arrayGet(1, &obj2); + if (obj2.isNum()) { + tmp.y1 = obj2.getNum(); + } else { + ok = gFalse; + } + obj2.free(); + obj1.arrayGet(2, &obj2); + if (obj2.isNum()) { + tmp.x2 = obj2.getNum(); + } else { + ok = gFalse; + } + obj2.free(); + obj1.arrayGet(3, &obj2); + if (obj2.isNum()) { + tmp.y2 = obj2.getNum(); + } else { + ok = gFalse; + } + obj2.free(); + if (tmp.x1 == 0 && tmp.x2 == 0 && tmp.y1 == 0 && tmp.y2 == 0) + ok = gFalse; + if (ok) { + if (tmp.x1 > tmp.x2) { + t = tmp.x1; tmp.x1 = tmp.x2; tmp.x2 = t; + } + if (tmp.y1 > tmp.y2) { + t = tmp.y1; tmp.y1 = tmp.y2; tmp.y2 = t; + } + *box = tmp; + } + } else { + ok = gFalse; + } + obj1.free(); + return ok; +} + +//------------------------------------------------------------------------ +// Page +//------------------------------------------------------------------------ + +Page::Page(PDFDoc *docA, int numA, Dict *pageDict, Ref pageRefA, PageAttrs *attrsA, Form *form) { + Object tmp; + +#if MULTITHREADED + gInitMutex(&mutex); +#endif + ok = gTrue; + doc = docA; + xref = doc->getXRef(); + num = numA; + duration = -1; + annots = NULL; + + pageObj.initDict(pageDict); + pageRef = pageRefA; + + // get attributes + attrs = attrsA; + attrs->clipBoxes(); + + // transtion + pageDict->lookupNF("Trans", &trans); + if (!(trans.isRef() || trans.isDict() || trans.isNull())) { + error(errSyntaxError, -1, "Page transition object (page {0:d}) is wrong type ({1:s})", + num, trans.getTypeName()); + trans.free(); + } + + // duration + pageDict->lookupNF("Dur", &tmp); + if (!(tmp.isNum() || tmp.isNull())) { + error(errSyntaxError, -1, "Page duration object (page {0:d}) is wrong type ({1:s})", + num, tmp.getTypeName()); + } else if (tmp.isNum()) { + duration = tmp.getNum(); + } + tmp.free(); + + // annotations + pageDict->lookupNF("Annots", &annotsObj); + if (!(annotsObj.isRef() || annotsObj.isArray() || annotsObj.isNull())) { + error(errSyntaxError, -1, "Page annotations object (page {0:d}) is wrong type ({1:s})", + num, annotsObj.getTypeName()); + annotsObj.free(); + goto err2; + } + + // contents + pageDict->lookupNF("Contents", &contents); + if (!(contents.isRef() || contents.isArray() || + contents.isNull())) { + error(errSyntaxError, -1, "Page contents object (page {0:d}) is wrong type ({1:s})", + num, contents.getTypeName()); + contents.free(); + goto err1; + } + + // thumb + pageDict->lookupNF("Thumb", &thumb); + if (!(thumb.isStream() || thumb.isNull() || thumb.isRef())) { + error(errSyntaxError, -1, "Page thumb object (page {0:d}) is wrong type ({1:s})", + num, thumb.getTypeName()); + thumb.initNull(); + } + + // actions + pageDict->lookupNF("AA", &actions); + if (!(actions.isDict() || actions.isNull())) { + error(errSyntaxError, -1, "Page additional action object (page {0:d}) is wrong type ({1:s})", + num, actions.getTypeName()); + actions.initNull(); + } + + return; + + trans.initNull(); + err2: + annotsObj.initNull(); + err1: + contents.initNull(); + ok = gFalse; +} + +Page::~Page() { + delete attrs; + delete annots; + pageObj.free(); + annotsObj.free(); + contents.free(); + trans.free(); + thumb.free(); + actions.free(); +#if MULTITHREADED + gDestroyMutex(&mutex); +#endif +} + +Dict *Page::getResourceDict() { + return attrs->getResourceDict(); +} + +Dict *Page::getResourceDictCopy(XRef *xrefA) { + pageLocker(); + Dict *dict = attrs->getResourceDict(); + return dict ? dict->copy(xrefA) : NULL; +} + +void Page::replaceXRef(XRef *xrefA) { + Object obj1; + Dict *pageDict = pageObj.getDict()->copy(xrefA); + xref = xrefA; + trans.free(); + pageDict->lookupNF("Trans", &trans); + annotsObj.free(); + pageDict->lookupNF("Annots", &annotsObj); + contents.free(); + pageDict->lookupNF("Contents", &contents); + if (contents.isArray()) { + contents.free(); + pageDict->lookupNF("Contents", &obj1)->getArray()->copy(xrefA, &contents); + obj1.free(); + } + thumb.free(); + pageDict->lookupNF("Thumb", &thumb); + actions.free(); + pageDict->lookupNF("AA", &actions); + pageDict->lookup("Resources", &obj1); + if (obj1.isDict()) { + attrs->replaceResource(obj1); + } + obj1.free(); + delete pageDict; +} + +Annots *Page::getAnnots(XRef *xrefA) { + if (!annots) { + Object obj; + annots = new Annots(doc, num, getAnnots(&obj, (xrefA == NULL) ? xref : xrefA)); + obj.free(); + } + + return annots; +} + +void Page::addAnnot(Annot *annot) { + Object obj1; + Object tmp; + Ref annotRef = annot->getRef (); + + // Make sure we have annots before adding the new one + // even if it's an empty list so that we can safely + // call annots->appendAnnot(annot) + pageLocker(); + getAnnots(); + + if (annotsObj.isNull()) { + Ref annotsRef; + // page doesn't have annots array, + // we have to create it + + obj1.initArray(xref); + obj1.arrayAdd(tmp.initRef (annotRef.num, annotRef.gen)); + tmp.free(); + + annotsRef = xref->addIndirectObject (&obj1); + annotsObj.initRef(annotsRef.num, annotsRef.gen); + pageObj.dictSet ("Annots", &annotsObj); + xref->setModifiedObject (&pageObj, pageRef); + } else { + getAnnots(&obj1); + if (obj1.isArray()) { + obj1.arrayAdd (tmp.initRef (annotRef.num, annotRef.gen)); + if (annotsObj.isRef()) + xref->setModifiedObject (&obj1, annotsObj.getRef()); + else + xref->setModifiedObject (&pageObj, pageRef); + } + obj1.free(); + } + + // Popup annots are already handled by markup annots, + // so add to the list only Popup annots without a + // markup annotation associated. + if (annot->getType() != Annot::typePopup || + static_cast<AnnotPopup*>(annot)->getParentNF()->isNull()) { + annots->appendAnnot(annot); + } + annot->setPage(num, gTrue); + + AnnotMarkup *annotMarkup = dynamic_cast<AnnotMarkup*>(annot); + if (annotMarkup) { + AnnotPopup *annotPopup = annotMarkup->getPopup(); + if (annotPopup) + addAnnot(annotPopup); + } +} + +void Page::removeAnnot(Annot *annot) { + Ref annotRef = annot->getRef(); + Object annArray; + + pageLocker(); + getAnnots(&annArray); + if (annArray.isArray()) { + int idx = -1; + // Get annotation position + for (int i = 0; idx == -1 && i < annArray.arrayGetLength(); ++i) { + Object tmp; + if (annArray.arrayGetNF(i, &tmp)->isRef()) { + Ref currAnnot = tmp.getRef(); + if (currAnnot.num == annotRef.num && currAnnot.gen == annotRef.gen) { + idx = i; + } + } + tmp.free(); + } + + if (idx == -1) { + error(errInternal, -1, "Annotation doesn't belong to this page"); + annArray.free(); + return; + } + annots->removeAnnot(annot); // Gracefully fails on popup windows + annArray.arrayRemove(idx); + xref->removeIndirectObject(annotRef); + + if (annotsObj.isRef()) { + xref->setModifiedObject (&annArray, annotsObj.getRef()); + } else { + xref->setModifiedObject (&pageObj, pageRef); + } + } + annArray.free(); + annot->removeReferencedObjects(); // Note: Might recurse in removeAnnot again + annot->setPage(0, gFalse); +} + +Links *Page::getLinks() { + return new Links(getAnnots()); +} + +FormPageWidgets *Page::getFormWidgets() { + return new FormPageWidgets(getAnnots(), num, doc->getCatalog()->getForm()); +} + +void Page::display(OutputDev *out, double hDPI, double vDPI, + int rotate, GBool useMediaBox, GBool crop, + GBool printing, + GBool (*abortCheckCbk)(void *data), + void *abortCheckCbkData, + GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data), + void *annotDisplayDecideCbkData, + GBool copyXRef) { + displaySlice(out, hDPI, vDPI, rotate, useMediaBox, crop, -1, -1, -1, -1, printing, + abortCheckCbk, abortCheckCbkData, + annotDisplayDecideCbk, annotDisplayDecideCbkData, copyXRef); +} + +Gfx *Page::createGfx(OutputDev *out, double hDPI, double vDPI, + int rotate, GBool useMediaBox, GBool crop, + int sliceX, int sliceY, int sliceW, int sliceH, + GBool printing, + GBool (*abortCheckCbk)(void *data), + void *abortCheckCbkData, XRef *xrefA) { + PDFRectangle *mediaBox, *cropBox; + PDFRectangle box; + Gfx *gfx; + + rotate += getRotate(); + if (rotate >= 360) { + rotate -= 360; + } else if (rotate < 0) { + rotate += 360; + } + + makeBox(hDPI, vDPI, rotate, useMediaBox, out->upsideDown(), + sliceX, sliceY, sliceW, sliceH, &box, &crop); + cropBox = getCropBox(); + mediaBox = getMediaBox(); + + if (globalParams->getPrintCommands()) { + printf("***** MediaBox = ll:%g,%g ur:%g,%g\n", + mediaBox->x1, mediaBox->y1, mediaBox->x2, mediaBox->y2); + printf("***** CropBox = ll:%g,%g ur:%g,%g\n", + cropBox->x1, cropBox->y1, cropBox->x2, cropBox->y2); + printf("***** Rotate = %d\n", attrs->getRotate()); + } + + if (!crop) { + crop = (box == *cropBox) && out->needClipToCropBox(); + } + gfx = new Gfx(doc, out, num, attrs->getResourceDict(), + hDPI, vDPI, &box, crop ? cropBox : (PDFRectangle *)NULL, + rotate, abortCheckCbk, abortCheckCbkData, xrefA); + + return gfx; +} + +void Page::displaySlice(OutputDev *out, double hDPI, double vDPI, + int rotate, GBool useMediaBox, GBool crop, + int sliceX, int sliceY, int sliceW, int sliceH, + GBool printing, + GBool (*abortCheckCbk)(void *data), + void *abortCheckCbkData, + GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data), + void *annotDisplayDecideCbkData, + GBool copyXRef) { + Gfx *gfx; + Object obj; + Annots *annotList; + int i; + + if (!out->checkPageSlice(this, hDPI, vDPI, rotate, useMediaBox, crop, + sliceX, sliceY, sliceW, sliceH, + printing, + abortCheckCbk, abortCheckCbkData, + annotDisplayDecideCbk, annotDisplayDecideCbkData)) { + return; + } + pageLocker(); + XRef *localXRef = (copyXRef) ? xref->copy() : xref; + if (copyXRef) { + replaceXRef(localXRef); + } + + gfx = createGfx(out, hDPI, vDPI, rotate, useMediaBox, crop, + sliceX, sliceY, sliceW, sliceH, + printing, + abortCheckCbk, abortCheckCbkData, localXRef); + + contents.fetch(localXRef, &obj); + if (!obj.isNull()) { + gfx->saveState(); + gfx->display(&obj); + gfx->restoreState(); + } else { + // empty pages need to call dump to do any setup required by the + // OutputDev + out->dump(); + } + obj.free(); + + // draw annotations + annotList = getAnnots(); + + if (annotList->getNumAnnots() > 0) { + if (globalParams->getPrintCommands()) { + printf("***** Annotations\n"); + } + for (i = 0; i < annotList->getNumAnnots(); ++i) { + Annot *annot = annotList->getAnnot(i); + if ((annotDisplayDecideCbk && + (*annotDisplayDecideCbk)(annot, annotDisplayDecideCbkData)) || + !annotDisplayDecideCbk) { + annotList->getAnnot(i)->draw(gfx, printing); + } + } + out->dump(); + } + + delete gfx; + if (copyXRef) { + replaceXRef(doc->getXRef()); + delete localXRef; + } +} + +void Page::display(Gfx *gfx) { + Object obj; + + contents.fetch(xref, &obj); + if (!obj.isNull()) { + gfx->saveState(); + gfx->display(&obj); + gfx->restoreState(); + } + obj.free(); +} + +GBool Page::loadThumb(unsigned char **data_out, + int *width_out, int *height_out, + int *rowstride_out) +{ + unsigned int pixbufdatasize; + int width, height, bits; + Object obj1, fetched_thumb; + Dict *dict; + GfxColorSpace *colorSpace; + GBool success = gFalse; + Stream *str; + GfxImageColorMap *colorMap; + + /* Get stream dict */ + pageLocker(); + thumb.fetch(xref, &fetched_thumb); + if (!fetched_thumb.isStream()) { + fetched_thumb.free(); + return gFalse; + } + + dict = fetched_thumb.streamGetDict(); + str = fetched_thumb.getStream(); + + if (!dict->lookupInt("Width", "W", &width)) + goto fail1; + if (!dict->lookupInt("Height", "H", &height)) + goto fail1; + if (!dict->lookupInt("BitsPerComponent", "BPC", &bits)) + goto fail1; + + /* Check for invalid dimensions and integer overflow. */ + if (width <= 0 || height <= 0) + goto fail1; + if (width > INT_MAX / 3 / height) + goto fail1; + pixbufdatasize = width * height * 3; + + /* Get color space */ + dict->lookup ("ColorSpace", &obj1); + if (obj1.isNull ()) { + obj1.free (); + dict->lookup ("CS", &obj1); + } + colorSpace = GfxColorSpace::parse(NULL, &obj1, NULL, NULL); + obj1.free(); + if (!colorSpace) { + fprintf (stderr, "Error: Cannot parse color space\n"); + goto fail1; + } + + dict->lookup("Decode", &obj1); + if (obj1.isNull()) { + obj1.free(); + dict->lookup("D", &obj1); + } + colorMap = new GfxImageColorMap(bits, &obj1, colorSpace); + obj1.free(); + if (!colorMap->isOk()) { + fprintf (stderr, "Error: invalid colormap\n"); + delete colorMap; + goto fail1; + } + + if (data_out) { + unsigned char *pixbufdata = (unsigned char *) gmalloc(pixbufdatasize); + unsigned char *p = pixbufdata; + ImageStream *imgstr = new ImageStream(str, width, + colorMap->getNumPixelComps(), + colorMap->getBits()); + imgstr->reset(); + for (int row = 0; row < height; ++row) { + for (int col = 0; col < width; ++col) { + Guchar pix[gfxColorMaxComps]; + GfxRGB rgb; + + imgstr->getPixel(pix); + colorMap->getRGB(pix, &rgb); + + *p++ = colToByte(rgb.r); + *p++ = colToByte(rgb.g); + *p++ = colToByte(rgb.b); + } + } + *data_out = pixbufdata; + imgstr->close(); + delete imgstr; + } + + success = gTrue; + + if (width_out) + *width_out = width; + if (height_out) + *height_out = height; + if (rowstride_out) + *rowstride_out = width * 3; + + delete colorMap; + fail1: + fetched_thumb.free(); + + return success; +} + +void Page::makeBox(double hDPI, double vDPI, int rotate, + GBool useMediaBox, GBool upsideDown, + double sliceX, double sliceY, double sliceW, double sliceH, + PDFRectangle *box, GBool *crop) { + PDFRectangle *mediaBox, *cropBox, *baseBox; + double kx, ky; + + mediaBox = getMediaBox(); + cropBox = getCropBox(); + if (sliceW >= 0 && sliceH >= 0) { + baseBox = useMediaBox ? mediaBox : cropBox; + kx = 72.0 / hDPI; + ky = 72.0 / vDPI; + if (rotate == 90) { + if (upsideDown) { + box->x1 = baseBox->x1 + ky * sliceY; + box->x2 = baseBox->x1 + ky * (sliceY + sliceH); + } else { + box->x1 = baseBox->x2 - ky * (sliceY + sliceH); + box->x2 = baseBox->x2 - ky * sliceY; + } + box->y1 = baseBox->y1 + kx * sliceX; + box->y2 = baseBox->y1 + kx * (sliceX + sliceW); + } else if (rotate == 180) { + box->x1 = baseBox->x2 - kx * (sliceX + sliceW); + box->x2 = baseBox->x2 - kx * sliceX; + if (upsideDown) { + box->y1 = baseBox->y1 + ky * sliceY; + box->y2 = baseBox->y1 + ky * (sliceY + sliceH); + } else { + box->y1 = baseBox->y2 - ky * (sliceY + sliceH); + box->y2 = baseBox->y2 - ky * sliceY; + } + } else if (rotate == 270) { + if (upsideDown) { + box->x1 = baseBox->x2 - ky * (sliceY + sliceH); + box->x2 = baseBox->x2 - ky * sliceY; + } else { + box->x1 = baseBox->x1 + ky * sliceY; + box->x2 = baseBox->x1 + ky * (sliceY + sliceH); + } + box->y1 = baseBox->y2 - kx * (sliceX + sliceW); + box->y2 = baseBox->y2 - kx * sliceX; + } else { + box->x1 = baseBox->x1 + kx * sliceX; + box->x2 = baseBox->x1 + kx * (sliceX + sliceW); + if (upsideDown) { + box->y1 = baseBox->y2 - ky * (sliceY + sliceH); + box->y2 = baseBox->y2 - ky * sliceY; + } else { + box->y1 = baseBox->y1 + ky * sliceY; + box->y2 = baseBox->y1 + ky * (sliceY + sliceH); + } + } + } else if (useMediaBox) { + *box = *mediaBox; + } else { + *box = *cropBox; + *crop = gFalse; + } +} + +void Page::processLinks(OutputDev *out) { + Links *links; + int i; + + links = getLinks(); + for (i = 0; i < links->getNumLinks(); ++i) { + out->processLink(links->getLink(i)); + } + delete links; +} + +void Page::getDefaultCTM(double *ctm, double hDPI, double vDPI, + int rotate, GBool useMediaBox, GBool upsideDown) { + GfxState *state; + int i; + rotate += getRotate(); + if (rotate >= 360) { + rotate -= 360; + } else if (rotate < 0) { + rotate += 360; + } + state = new GfxState(hDPI, vDPI, + useMediaBox ? getMediaBox() : getCropBox(), + rotate, upsideDown); + for (i = 0; i < 6; ++i) { + ctm[i] = state->getCTM()[i]; + } + delete state; +} + +LinkAction* Page::getAdditionalAction(PageAdditionalActionsType type) { + Object additionalActionsObject; + LinkAction *linkAction = NULL; + + if (actions.fetch(doc->getXRef(), &additionalActionsObject)->isDict()) { + const char *key = (type == actionOpenPage ? "O" : + type == actionClosePage ? "C" : NULL); + + Object actionObject; + + if (additionalActionsObject.dictLookup(key, &actionObject)->isDict()) + linkAction = LinkAction::parseAction(&actionObject, doc->getCatalog()->getBaseURI()); + actionObject.free(); + } + + additionalActionsObject.free(); + + return linkAction; +} diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Page.h b/source/libs/poppler/poppler-0.33.0/poppler/Page.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Page.h rename to source/libs/poppler/poppler-0.33.0/poppler/Page.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PageLabelInfo.cc b/source/libs/poppler/poppler-0.33.0/poppler/PageLabelInfo.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/PageLabelInfo.cc rename to source/libs/poppler/poppler-0.33.0/poppler/PageLabelInfo.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PageLabelInfo.h b/source/libs/poppler/poppler-0.33.0/poppler/PageLabelInfo.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/PageLabelInfo.h rename to source/libs/poppler/poppler-0.33.0/poppler/PageLabelInfo.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PageLabelInfo_p.h b/source/libs/poppler/poppler-0.33.0/poppler/PageLabelInfo_p.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/PageLabelInfo_p.h rename to source/libs/poppler/poppler-0.33.0/poppler/PageLabelInfo_p.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PageTransition.cc b/source/libs/poppler/poppler-0.33.0/poppler/PageTransition.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/PageTransition.cc rename to source/libs/poppler/poppler-0.33.0/poppler/PageTransition.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PageTransition.h b/source/libs/poppler/poppler-0.33.0/poppler/PageTransition.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/PageTransition.h rename to source/libs/poppler/poppler-0.33.0/poppler/PageTransition.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Parser.cc b/source/libs/poppler/poppler-0.33.0/poppler/Parser.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Parser.cc rename to source/libs/poppler/poppler-0.33.0/poppler/Parser.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Parser.h b/source/libs/poppler/poppler-0.33.0/poppler/Parser.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Parser.h rename to source/libs/poppler/poppler-0.33.0/poppler/Parser.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PopplerCache.cc b/source/libs/poppler/poppler-0.33.0/poppler/PopplerCache.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/PopplerCache.cc rename to source/libs/poppler/poppler-0.33.0/poppler/PopplerCache.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PopplerCache.h b/source/libs/poppler/poppler-0.33.0/poppler/PopplerCache.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/PopplerCache.h rename to source/libs/poppler/poppler-0.33.0/poppler/PopplerCache.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PreScanOutputDev.cc b/source/libs/poppler/poppler-0.33.0/poppler/PreScanOutputDev.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/PreScanOutputDev.cc rename to source/libs/poppler/poppler-0.33.0/poppler/PreScanOutputDev.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/PreScanOutputDev.h b/source/libs/poppler/poppler-0.33.0/poppler/PreScanOutputDev.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/PreScanOutputDev.h rename to source/libs/poppler/poppler-0.33.0/poppler/PreScanOutputDev.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/ProfileData.cc b/source/libs/poppler/poppler-0.33.0/poppler/ProfileData.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/ProfileData.cc rename to source/libs/poppler/poppler-0.33.0/poppler/ProfileData.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/ProfileData.h b/source/libs/poppler/poppler-0.33.0/poppler/ProfileData.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/ProfileData.h rename to source/libs/poppler/poppler-0.33.0/poppler/ProfileData.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Rendition.cc b/source/libs/poppler/poppler-0.33.0/poppler/Rendition.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Rendition.cc rename to source/libs/poppler/poppler-0.33.0/poppler/Rendition.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Rendition.h b/source/libs/poppler/poppler-0.33.0/poppler/Rendition.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Rendition.h rename to source/libs/poppler/poppler-0.33.0/poppler/Rendition.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/SecurityHandler.cc b/source/libs/poppler/poppler-0.33.0/poppler/SecurityHandler.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/SecurityHandler.cc rename to source/libs/poppler/poppler-0.33.0/poppler/SecurityHandler.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/SecurityHandler.h b/source/libs/poppler/poppler-0.33.0/poppler/SecurityHandler.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/SecurityHandler.h rename to source/libs/poppler/poppler-0.33.0/poppler/SecurityHandler.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Sound.cc b/source/libs/poppler/poppler-0.33.0/poppler/Sound.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Sound.cc rename to source/libs/poppler/poppler-0.33.0/poppler/Sound.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Sound.h b/source/libs/poppler/poppler-0.33.0/poppler/Sound.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Sound.h rename to source/libs/poppler/poppler-0.33.0/poppler/Sound.h diff --git a/source/libs/poppler/poppler-0.33.0/poppler/SplashOutputDev.cc b/source/libs/poppler/poppler-0.33.0/poppler/SplashOutputDev.cc new file mode 100644 index 000000000..a7cc6bc1b --- /dev/null +++ b/source/libs/poppler/poppler-0.33.0/poppler/SplashOutputDev.cc @@ -0,0 +1,4479 @@ +//======================================================================== +// +// SplashOutputDev.cc +// +// Copyright 2003 Glyph & Cog, LLC +// +//======================================================================== + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2005 Takashi Iwai <tiwai@suse.de> +// Copyright (C) 2006 Stefan Schweizer <genstef@gentoo.org> +// Copyright (C) 2006-2015 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com> +// Copyright (C) 2006 Scott Turner <scotty1024@mac.com> +// Copyright (C) 2007 Koji Otani <sho@bbr.jp> +// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com> +// Copyright (C) 2009-2015 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org> +// Copyright (C) 2009, 2014, 2015 William Bader <williambader@hotmail.com> +// Copyright (C) 2010 Patrick Spendrin <ps_ml@gmx.de> +// Copyright (C) 2010 Brian Cameron <brian.cameron@oracle.com> +// Copyright (C) 2010 Paweł Wiejacha <pawel.wiejacha@gmail.com> +// Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> +// Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com> +// Copyright (C) 2011 Andrea Canciani <ranma42@gmail.com> +// Copyright (C) 2011, 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013 Lu Wang <coolwanglu@gmail.com> +// Copyright (C) 2013 Li Junling <lijunling@sina.com> +// Copyright (C) 2014 Ed Porras <ed@moto-research.com> +// Copyright (C) 2014 Richard PALO <richard@netbsd.org> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#include <config.h> + +#ifdef USE_GCC_PRAGMAS +#pragma implementation +#endif + +#include <string.h> +#include <math.h> +#include "goo/gfile.h" +#include "GlobalParams.h" +#include "Error.h" +#include "Object.h" +#include "Gfx.h" +#include "GfxFont.h" +#include "Page.h" +#include "PDFDoc.h" +#include "Link.h" +#include "FontEncodingTables.h" +#include "fofi/FoFiTrueType.h" +#include "splash/SplashBitmap.h" +#include "splash/SplashGlyphBitmap.h" +#include "splash/SplashPattern.h" +#include "splash/SplashScreen.h" +#include "splash/SplashPath.h" +#include "splash/SplashState.h" +#include "splash/SplashErrorCodes.h" +#include "splash/SplashFontEngine.h" +#include "splash/SplashFont.h" +#include "splash/SplashFontFile.h" +#include "splash/SplashFontFileID.h" +#include "splash/Splash.h" +#include "SplashOutputDev.h" + +#ifdef VMS +#if (__VMS_VER < 70000000) +extern "C" int unlink(char *filename); +#endif +#endif + +#ifdef _MSC_VER +#include <float.h> +#define isfinite(x) _finite(x) +#endif + +#ifdef __sun +#include <ieeefp.h> +#ifndef isfinite +#define isfinite(x) finite(x) +#endif +#endif + +static inline void convertGfxColor(SplashColorPtr dest, + SplashColorMode colorMode, + GfxColorSpace *colorSpace, + GfxColor *src) { + SplashColor color; + GfxGray gray; + GfxRGB rgb; +#if SPLASH_CMYK + GfxCMYK cmyk; + GfxColor deviceN; +#endif + + // make gcc happy + color[0] = color[1] = color[2] = 0; +#if SPLASH_CMYK + color[3] = 0; +#endif + switch (colorMode) { + case splashModeMono1: + case splashModeMono8: + colorSpace->getGray(src, &gray); + color[0] = colToByte(gray); + break; + case splashModeXBGR8: + color[3] = 255; + case splashModeBGR8: + case splashModeRGB8: + colorSpace->getRGB(src, &rgb); + color[0] = colToByte(rgb.r); + color[1] = colToByte(rgb.g); + color[2] = colToByte(rgb.b); + break; +#if SPLASH_CMYK + case splashModeCMYK8: + colorSpace->getCMYK(src, &cmyk); + color[0] = colToByte(cmyk.c); + color[1] = colToByte(cmyk.m); + color[2] = colToByte(cmyk.y); + color[3] = colToByte(cmyk.k); + break; + case splashModeDeviceN8: + colorSpace->getDeviceN(src, &deviceN); + for (int i = 0; i < SPOT_NCOMPS + 4; i++) + color[i] = colToByte(deviceN.c[i]); + break; +#endif + } + splashColorCopy(dest, color); +} + +//------------------------------------------------------------------------ +// SplashGouraudPattern +//------------------------------------------------------------------------ +SplashGouraudPattern::SplashGouraudPattern(GBool bDirectColorTranslationA, + GfxState *stateA, GfxGouraudTriangleShading *shadingA, SplashColorMode modeA) { + SplashColor defaultColor; + GfxColor srcColor; + state = stateA; + shading = shadingA; + mode = modeA; + bDirectColorTranslation = bDirectColorTranslationA; + shadingA->getColorSpace()->getDefaultColor(&srcColor); + convertGfxColor(defaultColor, mode, shadingA->getColorSpace(), &srcColor); + gfxMode = shadingA->getColorSpace()->getMode(); +} + +SplashGouraudPattern::~SplashGouraudPattern() { +} + +void SplashGouraudPattern::getParameterizedColor(double colorinterp, SplashColorMode mode, SplashColorPtr dest) { + GfxColor src; + GfxColorSpace* srcColorSpace = shading->getColorSpace(); + int colorComps = 3; +#if SPLASH_CMYK + if (mode == splashModeCMYK8) + colorComps=4; + else if (mode == splashModeDeviceN8) + colorComps=4 + SPOT_NCOMPS; +#endif + + shading->getParameterizedColor(colorinterp, &src); + + if (bDirectColorTranslation) { + for (int m = 0; m < colorComps; ++m) + dest[m] = colToByte(src.c[m]); + } else { + convertGfxColor(dest, mode, srcColorSpace, &src); + } +} + +//------------------------------------------------------------------------ +// SplashUnivariatePattern +//------------------------------------------------------------------------ + +SplashUnivariatePattern::SplashUnivariatePattern(SplashColorMode colorModeA, GfxState *stateA, GfxUnivariateShading *shadingA) { + Matrix ctm; + double xMin, yMin, xMax, yMax; + + shading = shadingA; + state = stateA; + colorMode = colorModeA; + + state->getCTM(&ctm); + ctm.invertTo(&ictm); + + // get the function domain + t0 = shading->getDomain0(); + t1 = shading->getDomain1(); + dt = t1 - t0; + + stateA->getUserClipBBox(&xMin, &yMin, &xMax, &yMax); + shadingA->setupCache(&ctm, xMin, yMin, xMax, yMax); + gfxMode = shadingA->getColorSpace()->getMode(); +} + +SplashUnivariatePattern::~SplashUnivariatePattern() { +} + +GBool SplashUnivariatePattern::getColor(int x, int y, SplashColorPtr c) { + GfxColor gfxColor; + double xc, yc, t; + + ictm.transform(x, y, &xc, &yc); + if (! getParameter (xc, yc, &t)) + return gFalse; + + shading->getColor(t, &gfxColor); + convertGfxColor(c, colorMode, shading->getColorSpace(), &gfxColor); + return gTrue; +} + +GBool SplashUnivariatePattern::testPosition(int x, int y) { + double xc, yc, t; + + ictm.transform(x, y, &xc, &yc); + if (! getParameter (xc, yc, &t)) + return gFalse; + return (t0 < t1) ? (t > t0 && t < t1) : (t > t1 && t < t0); +} + + +//------------------------------------------------------------------------ +// SplashRadialPattern +//------------------------------------------------------------------------ +#define RADIAL_EPSILON (1. / 1024 / 1024) + +SplashRadialPattern::SplashRadialPattern(SplashColorMode colorModeA, GfxState *stateA, GfxRadialShading *shadingA): + SplashUnivariatePattern(colorModeA, stateA, shadingA) +{ + SplashColor defaultColor; + GfxColor srcColor; + + shadingA->getCoords(&x0, &y0, &r0, &dx, &dy, &dr); + dx -= x0; + dy -= y0; + dr -= r0; + a = dx*dx + dy*dy - dr*dr; + if (fabs(a) > RADIAL_EPSILON) + inva = 1.0 / a; + shadingA->getColorSpace()->getDefaultColor(&srcColor); + convertGfxColor(defaultColor, colorModeA, shadingA->getColorSpace(), &srcColor); +} + +SplashRadialPattern::~SplashRadialPattern() { +} + +GBool SplashRadialPattern::getParameter(double xs, double ys, double *t) { + double b, c, s0, s1; + + // We want to solve this system of equations: + // + // 1. (x - xc(s))^2 + (y -yc(s))^2 = rc(s)^2 + // 2. xc(s) = x0 + s * (x1 - xo) + // 3. yc(s) = y0 + s * (y1 - yo) + // 4. rc(s) = r0 + s * (r1 - ro) + // + // To simplify the system a little, we translate + // our coordinates to have the origin in (x0,y0) + + xs -= x0; + ys -= y0; + + // Then we have to solve the equation: + // A*s^2 - 2*B*s + C = 0 + // where + // A = dx^2 + dy^2 - dr^2 + // B = xs*dx + ys*dy + r0*dr + // C = xs^2 + ys^2 - r0^2 + + b = xs*dx + ys*dy + r0*dr; + c = xs*xs + ys*ys - r0*r0; + + if (fabs(a) <= RADIAL_EPSILON) { + // A is 0, thus the equation simplifies to: + // -2*B*s + C = 0 + // If B is 0, we can either have no solution or an indeterminate + // equation, thus we behave as if we had an invalid solution + if (fabs(b) <= RADIAL_EPSILON) + return gFalse; + + s0 = s1 = 0.5 * c / b; + } else { + double d; + + d = b*b - a*c; + if (d < 0) + return gFalse; + + d = sqrt (d); + s0 = b + d; + s1 = b - d; + + // If A < 0, one of the two solutions will have negative radius, + // thus it will be ignored. Otherwise we know that s1 <= s0 + // (because d >=0 implies b - d <= b + d), so if both are valid it + // will be the true solution. + s0 *= inva; + s1 *= inva; + } + + if (r0 + s0 * dr >= 0) { + if (0 <= s0 && s0 <= 1) { + *t = t0 + dt * s0; + return gTrue; + } else if (s0 < 0 && shading->getExtend0()) { + *t = t0; + return gTrue; + } else if (s0 > 1 && shading->getExtend1()) { + *t = t1; + return gTrue; + } + } + + if (r0 + s1 * dr >= 0) { + if (0 <= s1 && s1 <= 1) { + *t = t0 + dt * s1; + return gTrue; + } else if (s1 < 0 && shading->getExtend0()) { + *t = t0; + return gTrue; + } else if (s1 > 1 && shading->getExtend1()) { + *t = t1; + return gTrue; + } + } + + return gFalse; +} + +#undef RADIAL_EPSILON + +//------------------------------------------------------------------------ +// SplashAxialPattern +//------------------------------------------------------------------------ + +SplashAxialPattern::SplashAxialPattern(SplashColorMode colorModeA, GfxState *stateA, GfxAxialShading *shadingA): + SplashUnivariatePattern(colorModeA, stateA, shadingA) +{ + SplashColor defaultColor; + GfxColor srcColor; + + shadingA->getCoords(&x0, &y0, &x1, &y1); + dx = x1 - x0; + dy = y1 - y0; + mul = 1 / (dx * dx + dy * dy); + shadingA->getColorSpace()->getDefaultColor(&srcColor); + convertGfxColor(defaultColor, colorModeA, shadingA->getColorSpace(), &srcColor); +} + +SplashAxialPattern::~SplashAxialPattern() { +} + +GBool SplashAxialPattern::getParameter(double xc, double yc, double *t) { + double s; + + xc -= x0; + yc -= y0; + + s = (xc * dx + yc * dy) * mul; + if (0 <= s && s <= 1) { + *t = t0 + dt * s; + } else if (s < 0 && shading->getExtend0()) { + *t = t0; + } else if (s > 1 && shading->getExtend1()) { + *t = t1; + } else { + return gFalse; + } + + return gTrue; +} + +//------------------------------------------------------------------------ +// Type 3 font cache size parameters +#define type3FontCacheAssoc 8 +#define type3FontCacheMaxSets 8 +#define type3FontCacheSize (128*1024) + +//------------------------------------------------------------------------ +// Divide a 16-bit value (in [0, 255*255]) by 255, returning an 8-bit result. +static inline Guchar div255(int x) { + return (Guchar)((x + (x >> 8) + 0x80) >> 8); +} + +#if SPLASH_CMYK + +#include "GfxState_helpers.h" + +//------------------------------------------------------------------------- +// helper for Blend functions (convert CMYK to RGB, do blend, convert back) +//------------------------------------------------------------------------- + +// based in GfxState.cc + +static void cmykToRGB(SplashColorPtr cmyk, SplashColor rgb) { + double c, m, y, k, c1, m1, y1, k1, r, g, b; + + c = colToDbl(byteToCol(cmyk[0])); + m = colToDbl(byteToCol(cmyk[1])); + y = colToDbl(byteToCol(cmyk[2])); + k = colToDbl(byteToCol(cmyk[3])); + c1 = 1 - c; + m1 = 1 - m; + y1 = 1 - y; + k1 = 1 - k; + cmykToRGBMatrixMultiplication(c, m, y, k, c1, m1, y1, k1, r, g, b); + rgb[0] = colToByte(clip01(dblToCol(r))); + rgb[1] = colToByte(clip01(dblToCol(g))); + rgb[2] = colToByte(clip01(dblToCol(b))); +} + +static void rgbToCMYK(SplashColor rgb, SplashColorPtr cmyk) { + GfxColorComp c, m, y, k; + + c = clip01(gfxColorComp1 - byteToCol(rgb[0])); + m = clip01(gfxColorComp1 - byteToCol(rgb[1])); + y = clip01(gfxColorComp1 - byteToCol(rgb[2])); + k = c; + if (m < k) { + k = m; + } + if (y < k) { + k = y; + } + cmyk[0] = colToByte(c - k); + cmyk[1] = colToByte(m - k); + cmyk[2] = colToByte(y - k); + cmyk[3] = colToByte(k); +} + +#endif + +//------------------------------------------------------------------------ +// Blend functions +//------------------------------------------------------------------------ + +static void splashOutBlendMultiply(SplashColorPtr src, SplashColorPtr dest, + SplashColorPtr blend, SplashColorMode cm) { + int i; + +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + } + } +#endif + { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + blend[i] = (dest[i] * src[i]) / 255; + } + } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif +} + +static void splashOutBlendScreen(SplashColorPtr src, SplashColorPtr dest, + SplashColorPtr blend, SplashColorMode cm) { + int i; + +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + } + } +#endif + { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + blend[i] = dest[i] + src[i] - (dest[i] * src[i]) / 255; + } + } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif +} + +static void splashOutBlendOverlay(SplashColorPtr src, SplashColorPtr dest, + SplashColorPtr blend, SplashColorMode cm) { + int i; + +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + } + } +#endif + { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + blend[i] = dest[i] < 0x80 + ? (src[i] * 2 * dest[i]) / 255 + : 255 - 2 * ((255 - src[i]) * (255 - dest[i])) / 255; + } + } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif +} + +static void splashOutBlendDarken(SplashColorPtr src, SplashColorPtr dest, + SplashColorPtr blend, SplashColorMode cm) { + int i; + +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + } + } +#endif + { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + blend[i] = dest[i] < src[i] ? dest[i] : src[i]; + } + } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif +} + +static void splashOutBlendLighten(SplashColorPtr src, SplashColorPtr dest, + SplashColorPtr blend, SplashColorMode cm) { + int i; + +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + } + } +#endif + { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + blend[i] = dest[i] > src[i] ? dest[i] : src[i]; + } + } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif +} + +static void splashOutBlendColorDodge(SplashColorPtr src, SplashColorPtr dest, + SplashColorPtr blend, + SplashColorMode cm) { + int i, x; + +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + } + } +#endif + { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + if (src[i] == 255) { + blend[i] = 255; + } else { + x = (dest[i] * 255) / (255 - src[i]); + blend[i] = x <= 255 ? x : 255; + } + } + } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif +} + +static void splashOutBlendColorBurn(SplashColorPtr src, SplashColorPtr dest, + SplashColorPtr blend, SplashColorMode cm) { + int i, x; + +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + } + } +#endif + { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + if (src[i] == 0) { + blend[i] = 0; + } else { + x = ((255 - dest[i]) * 255) / src[i]; + blend[i] = x <= 255 ? 255 - x : 0; + } + } + } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif +} + +static void splashOutBlendHardLight(SplashColorPtr src, SplashColorPtr dest, + SplashColorPtr blend, SplashColorMode cm) { + int i; + +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + } + } +#endif + { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + blend[i] = src[i] < 0x80 + ? (dest[i] * 2 * src[i]) / 255 + : 255 - 2 * ((255 - dest[i]) * (255 - src[i])) / 255; + } + } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif +} + +static void splashOutBlendSoftLight(SplashColorPtr src, SplashColorPtr dest, + SplashColorPtr blend, SplashColorMode cm) { + int i, x; + +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + } + } +#endif + { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + if (src[i] < 0x80) { + blend[i] = dest[i] - (255 - 2 * src[i]) * dest[i] * (255 - dest[i]) / (255 * 255); + } else { + if (dest[i] < 0x40) { + x = (((((16 * dest[i] - 12 * 255) * dest[i]) / 255) + 4 * 255) * dest[i]) / 255; + } else { + x = (int)sqrt(255.0 * dest[i]); + } + blend[i] = dest[i] + (2 * src[i] - 255) * (x - dest[i]) / 255; + } + } + } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } +#endif +} + +static void splashOutBlendDifference(SplashColorPtr src, SplashColorPtr dest, + SplashColorPtr blend, + SplashColorMode cm) { + int i; + +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + } + } +#endif + { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + blend[i] = dest[i] < src[i] ? src[i] - dest[i] : dest[i] - src[i]; + } + } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } + if (cm == splashModeDeviceN8) { + for (i = 4; i < splashColorModeNComps[cm]; ++i) { + if (dest[i] == 0 && src[i] == 0) + blend[i] = 0; + } + } +#endif +} + +static void splashOutBlendExclusion(SplashColorPtr src, SplashColorPtr dest, + SplashColorPtr blend, SplashColorMode cm) { + int i; + +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + } + } +#endif + { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + blend[i] = dest[i] + src[i] - (2 * dest[i] * src[i]) / 255; + } + } +#if SPLASH_CMYK + if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { + for (i = 0; i < splashColorModeNComps[cm]; ++i) { + dest[i] = 255 - dest[i]; + src[i] = 255 - src[i]; + blend[i] = 255 - blend[i]; + } + } + if (cm == splashModeDeviceN8) { + for (i = 4; i < splashColorModeNComps[cm]; ++i) { + if (dest[i] == 0 && src[i] == 0) + blend[i] = 0; + } + } +#endif +} + +static int getLum(int r, int g, int b) { + return (int)(0.3 * r + 0.59 * g + 0.11 * b); +} + +static int getSat(int r, int g, int b) { + int rgbMin, rgbMax; + + rgbMin = rgbMax = r; + if (g < rgbMin) { + rgbMin = g; + } else if (g > rgbMax) { + rgbMax = g; + } + if (b < rgbMin) { + rgbMin = b; + } else if (b > rgbMax) { + rgbMax = b; + } + return rgbMax - rgbMin; +} + +static void clipColor(int rIn, int gIn, int bIn, + Guchar *rOut, Guchar *gOut, Guchar *bOut) { + int lum, rgbMin, rgbMax; + + lum = getLum(rIn, gIn, bIn); + rgbMin = rgbMax = rIn; + if (gIn < rgbMin) { + rgbMin = gIn; + } else if (gIn > rgbMax) { + rgbMax = gIn; + } + if (bIn < rgbMin) { + rgbMin = bIn; + } else if (bIn > rgbMax) { + rgbMax = bIn; + } + if (rgbMin < 0) { + *rOut = (Guchar)(lum + ((rIn - lum) * lum) / (lum - rgbMin)); + *gOut = (Guchar)(lum + ((gIn - lum) * lum) / (lum - rgbMin)); + *bOut = (Guchar)(lum + ((bIn - lum) * lum) / (lum - rgbMin)); + } else if (rgbMax > 255) { + *rOut = (Guchar)(lum + ((rIn - lum) * (255 - lum)) / (rgbMax - lum)); + *gOut = (Guchar)(lum + ((gIn - lum) * (255 - lum)) / (rgbMax - lum)); + *bOut = (Guchar)(lum + ((bIn - lum) * (255 - lum)) / (rgbMax - lum)); + } else { + *rOut = rIn; + *gOut = gIn; + *bOut = bIn; + } +} + +static void setLum(Guchar rIn, Guchar gIn, Guchar bIn, int lum, + Guchar *rOut, Guchar *gOut, Guchar *bOut) { + int d; + + d = lum - getLum(rIn, gIn, bIn); + clipColor(rIn + d, gIn + d, bIn + d, rOut, gOut, bOut); +} + +static void setSat(Guchar rIn, Guchar gIn, Guchar bIn, int sat, + Guchar *rOut, Guchar *gOut, Guchar *bOut) { + int rgbMin, rgbMid, rgbMax; + Guchar *minOut, *midOut, *maxOut; + + if (rIn < gIn) { + rgbMin = rIn; minOut = rOut; + rgbMid = gIn; midOut = gOut; + } else { + rgbMin = gIn; minOut = gOut; + rgbMid = rIn; midOut = rOut; + } + if (bIn > rgbMid) { + rgbMax = bIn; maxOut = bOut; + } else if (bIn > rgbMin) { + rgbMax = rgbMid; maxOut = midOut; + rgbMid = bIn; midOut = bOut; + } else { + rgbMax = rgbMid; maxOut = midOut; + rgbMid = rgbMin; midOut = minOut; + rgbMin = bIn; minOut = bOut; + } + if (rgbMax > rgbMin) { + *midOut = (Guchar)((rgbMid - rgbMin) * sat) / (rgbMax - rgbMin); + *maxOut = (Guchar)sat; + } else { + *midOut = *maxOut = 0; + } + *minOut = 0; +} + +static void splashOutBlendHue(SplashColorPtr src, SplashColorPtr dest, + SplashColorPtr blend, SplashColorMode cm) { + Guchar r0, g0, b0; +#ifdef SPLASH_CMYK + Guchar r1, g1, b1; + int i; + SplashColor src2, dest2; +#endif + + switch (cm) { + case splashModeMono1: + case splashModeMono8: + blend[0] = dest[0]; + break; + case splashModeXBGR8: + src[3] = 255; + case splashModeRGB8: + case splashModeBGR8: + setSat(src[0], src[1], src[2], getSat(dest[0], dest[1], dest[2]), + &r0, &g0, &b0); + setLum(r0, g0, b0, getLum(dest[0], dest[1], dest[2]), + &blend[0], &blend[1], &blend[2]); + break; +#if SPLASH_CMYK + case splashModeCMYK8: + case splashModeDeviceN8: + for (i = 0; i < 4; i++) { + // convert to additive + src2[i] = 0xff - src[i]; + dest2[i] = 0xff - dest[i]; + } + // NB: inputs have already been converted to additive mode + setSat(src2[0], src2[1], src2[2], getSat(dest2[0], dest2[1], dest2[2]), + &r0, &g0, &b0); + setLum(r0, g0, b0, getLum(dest2[0], dest2[1], dest2[2]), + &r1, &g1, &b1); + blend[0] = r1; + blend[1] = g1; + blend[2] = b1; + blend[3] = dest2[3]; + for (i = 0; i < 4; i++) { + // convert back to subtractive + blend[i] = 0xff - blend[i]; + } + break; +#endif + } +} + +static void splashOutBlendSaturation(SplashColorPtr src, SplashColorPtr dest, + SplashColorPtr blend, + SplashColorMode cm) { + Guchar r0, g0, b0; +#ifdef SPLASH_CMYK + Guchar r1, g1, b1; + int i; + SplashColor src2, dest2; +#endif + + switch (cm) { + case splashModeMono1: + case splashModeMono8: + blend[0] = dest[0]; + break; + case splashModeXBGR8: + src[3] = 255; + case splashModeRGB8: + case splashModeBGR8: + setSat(dest[0], dest[1], dest[2], getSat(src[0], src[1], src[2]), + &r0, &g0, &b0); + setLum(r0, g0, b0, getLum(dest[0], dest[1], dest[2]), + &blend[0], &blend[1], &blend[2]); + break; +#if SPLASH_CMYK + case splashModeCMYK8: + case splashModeDeviceN8: + for (i = 0; i < 4; i++) { + // convert to additive + src2[i] = 0xff - src[i]; + dest2[i] = 0xff - dest[i]; + } + setSat(dest2[0], dest2[1], dest2[2], getSat(src2[0], src2[1], src2[2]), + &r0, &g0, &b0); + setLum(r0, g0, b0, getLum(dest2[0], dest2[1], dest2[2]), + &r1, &g1, &b1); + blend[0] = r1; + blend[1] = g1; + blend[2] = b1; + blend[3] = dest2[3]; + for (i = 0; i < 4; i++) { + // convert back to subtractive + blend[i] = 0xff - blend[i]; + } + break; +#endif + } +} + +static void splashOutBlendColor(SplashColorPtr src, SplashColorPtr dest, + SplashColorPtr blend, SplashColorMode cm) { +#if SPLASH_CMYK + Guchar r, g, b; + int i; + SplashColor src2, dest2; +#endif + + switch (cm) { + case splashModeMono1: + case splashModeMono8: + blend[0] = dest[0]; + break; + case splashModeXBGR8: + src[3] = 255; + case splashModeRGB8: + case splashModeBGR8: + setLum(src[0], src[1], src[2], getLum(dest[0], dest[1], dest[2]), + &blend[0], &blend[1], &blend[2]); + break; +#if SPLASH_CMYK + case splashModeCMYK8: + case splashModeDeviceN8: + for (i = 0; i < 4; i++) { + // convert to additive + src2[i] = 0xff - src[i]; + dest2[i] = 0xff - dest[i]; + } + setLum(src2[0], src2[1], src2[2], getLum(dest2[0], dest2[1], dest2[2]), + &r, &g, &b); + blend[0] = r; + blend[1] = g; + blend[2] = b; + blend[3] = dest2[3]; + for (i = 0; i < 4; i++) { + // convert back to subtractive + blend[i] = 0xff - blend[i]; + } + break; +#endif + } +} + +static void splashOutBlendLuminosity(SplashColorPtr src, SplashColorPtr dest, + SplashColorPtr blend, + SplashColorMode cm) { +#if SPLASH_CMYK + Guchar r, g, b; + int i; + SplashColor src2, dest2; +#endif + + switch (cm) { + case splashModeMono1: + case splashModeMono8: + blend[0] = dest[0]; + break; + case splashModeXBGR8: + src[3] = 255; + case splashModeRGB8: + case splashModeBGR8: + setLum(dest[0], dest[1], dest[2], getLum(src[0], src[1], src[2]), + &blend[0], &blend[1], &blend[2]); + break; +#if SPLASH_CMYK + case splashModeCMYK8: + case splashModeDeviceN8: + for (i = 0; i < 4; i++) { + // convert to additive + src2[i] = 0xff - src[i]; + dest2[i] = 0xff - dest[i]; + } + setLum(dest2[0], dest2[1], dest2[2], getLum(src2[0], src2[1], src2[2]), + &r, &g, &b); + blend[0] = r; + blend[1] = g; + blend[2] = b; + blend[3] = src2[3]; + for (i = 0; i < 4; i++) { + // convert back to subtractive + blend[i] = 0xff - blend[i]; + } + break; +#endif + } +} + +// NB: This must match the GfxBlendMode enum defined in GfxState.h. +static const SplashBlendFunc splashOutBlendFuncs[] = { + NULL, + &splashOutBlendMultiply, + &splashOutBlendScreen, + &splashOutBlendOverlay, + &splashOutBlendDarken, + &splashOutBlendLighten, + &splashOutBlendColorDodge, + &splashOutBlendColorBurn, + &splashOutBlendHardLight, + &splashOutBlendSoftLight, + &splashOutBlendDifference, + &splashOutBlendExclusion, + &splashOutBlendHue, + &splashOutBlendSaturation, + &splashOutBlendColor, + &splashOutBlendLuminosity +}; + +//------------------------------------------------------------------------ +// SplashOutFontFileID +//------------------------------------------------------------------------ + +class SplashOutFontFileID: public SplashFontFileID { +public: + + SplashOutFontFileID(Ref *rA) { r = *rA; } + + ~SplashOutFontFileID() {} + + GBool matches(SplashFontFileID *id) { + return ((SplashOutFontFileID *)id)->r.num == r.num && + ((SplashOutFontFileID *)id)->r.gen == r.gen; + } + +private: + + Ref r; +}; + +//------------------------------------------------------------------------ +// T3FontCache +//------------------------------------------------------------------------ + +struct T3FontCacheTag { + Gushort code; + Gushort mru; // valid bit (0x8000) and MRU index +}; + +class T3FontCache { +public: + + T3FontCache(Ref *fontID, double m11A, double m12A, + double m21A, double m22A, + int glyphXA, int glyphYA, int glyphWA, int glyphHA, + GBool aa, GBool validBBoxA); + ~T3FontCache(); + GBool matches(Ref *idA, double m11A, double m12A, + double m21A, double m22A) + { return fontID.num == idA->num && fontID.gen == idA->gen && + m11 == m11A && m12 == m12A && m21 == m21A && m22 == m22A; } + + Ref fontID; // PDF font ID + double m11, m12, m21, m22; // transform matrix + int glyphX, glyphY; // pixel offset of glyph bitmaps + int glyphW, glyphH; // size of glyph bitmaps, in pixels + GBool validBBox; // false if the bbox was [0 0 0 0] + int glyphSize; // size of glyph bitmaps, in bytes + int cacheSets; // number of sets in cache + int cacheAssoc; // cache associativity (glyphs per set) + Guchar *cacheData; // glyph pixmap cache + T3FontCacheTag *cacheTags; // cache tags, i.e., char codes +}; + +T3FontCache::T3FontCache(Ref *fontIDA, double m11A, double m12A, + double m21A, double m22A, + int glyphXA, int glyphYA, int glyphWA, int glyphHA, + GBool validBBoxA, GBool aa) { + int i; + + fontID = *fontIDA; + m11 = m11A; + m12 = m12A; + m21 = m21A; + m22 = m22A; + glyphX = glyphXA; + glyphY = glyphYA; + glyphW = glyphWA; + glyphH = glyphHA; + validBBox = validBBoxA; + // sanity check for excessively large glyphs (which most likely + // indicate an incorrect BBox) + i = glyphW * glyphH; + if (i > 100000 || glyphW > INT_MAX / glyphH || glyphW <= 0 || glyphH <= 0) { + glyphW = glyphH = 100; + validBBox = gFalse; + } + if (aa) { + glyphSize = glyphW * glyphH; + } else { + glyphSize = ((glyphW + 7) >> 3) * glyphH; + } + cacheAssoc = type3FontCacheAssoc; + for (cacheSets = type3FontCacheMaxSets; + cacheSets > 1 && + cacheSets * cacheAssoc * glyphSize > type3FontCacheSize; + cacheSets >>= 1) ; + if (glyphSize < 10485760 / cacheAssoc / cacheSets) { + cacheData = (Guchar *)gmallocn_checkoverflow(cacheSets * cacheAssoc, glyphSize); + } else { + error(errSyntaxWarning, -1, "Not creating cacheData for T3FontCache, it asked for too much memory.\n" + " This could teoretically result in wrong rendering,\n" + " but most probably the document is bogus.\n" + " Please report a bug if you think the rendering may be wrong because of this."); + cacheData = NULL; + } + if (cacheData != NULL) + { + cacheTags = (T3FontCacheTag *)gmallocn(cacheSets * cacheAssoc, + sizeof(T3FontCacheTag)); + for (i = 0; i < cacheSets * cacheAssoc; ++i) { + cacheTags[i].mru = i & (cacheAssoc - 1); + } + } + else + { + cacheTags = NULL; + } +} + +T3FontCache::~T3FontCache() { + gfree(cacheData); + gfree(cacheTags); +} + +struct T3GlyphStack { + Gushort code; // character code + + //----- cache info + T3FontCache *cache; // font cache for the current font + T3FontCacheTag *cacheTag; // pointer to cache tag for the glyph + Guchar *cacheData; // pointer to cache data for the glyph + + //----- saved state + SplashBitmap *origBitmap; + Splash *origSplash; + double origCTM4, origCTM5; + + T3GlyphStack *next; // next object on stack +}; + +//------------------------------------------------------------------------ +// SplashTransparencyGroup +//------------------------------------------------------------------------ + +struct SplashTransparencyGroup { + int tx, ty; // translation coordinates + SplashBitmap *tBitmap; // bitmap for transparency group + GfxColorSpace *blendingColorSpace; + GBool isolated; + + //----- for knockout + SplashBitmap *shape; + GBool knockout; + SplashCoord knockoutOpacity; + GBool fontAA; + + //----- saved state + SplashBitmap *origBitmap; + Splash *origSplash; + + SplashTransparencyGroup *next; +}; + +//------------------------------------------------------------------------ +// SplashOutputDev +//------------------------------------------------------------------------ + +SplashOutputDev::SplashOutputDev(SplashColorMode colorModeA, + int bitmapRowPadA, + GBool reverseVideoA, + SplashColorPtr paperColorA, + GBool bitmapTopDownA, + SplashThinLineMode thinLineMode, + GBool overprintPreviewA) { + colorMode = colorModeA; + bitmapRowPad = bitmapRowPadA; + bitmapTopDown = bitmapTopDownA; + bitmapUpsideDown = gFalse; + fontAntialias = gTrue; + vectorAntialias = gTrue; + overprintPreview = overprintPreviewA; + enableFreeTypeHinting = gFalse; + enableSlightHinting = gFalse; + setupScreenParams(72.0, 72.0); + reverseVideo = reverseVideoA; + if (paperColorA != NULL) { + splashColorCopy(paperColor, paperColorA); + } else { + splashClearColor(paperColor); + } + skipHorizText = gFalse; + skipRotatedText = gFalse; + keepAlphaChannel = paperColorA == NULL; + + doc = NULL; + + bitmap = new SplashBitmap(1, 1, bitmapRowPad, colorMode, + colorMode != splashModeMono1, bitmapTopDown); + splash = new Splash(bitmap, vectorAntialias, &screenParams); + splash->setMinLineWidth(globalParams->getMinLineWidth()); + splash->setThinLineMode(thinLineMode); + splash->clear(paperColor, 0); + + fontEngine = NULL; + + nT3Fonts = 0; + t3GlyphStack = NULL; + + font = NULL; + needFontUpdate = gFalse; + textClipPath = NULL; + transpGroupStack = NULL; + nestCount = 0; + xref = NULL; +} + +void SplashOutputDev::setupScreenParams(double hDPI, double vDPI) { + screenParams.size = globalParams->getScreenSize(); + screenParams.dotRadius = globalParams->getScreenDotRadius(); + screenParams.gamma = (SplashCoord)globalParams->getScreenGamma(); + screenParams.blackThreshold = + (SplashCoord)globalParams->getScreenBlackThreshold(); + screenParams.whiteThreshold = + (SplashCoord)globalParams->getScreenWhiteThreshold(); + switch (globalParams->getScreenType()) { + case screenDispersed: + screenParams.type = splashScreenDispersed; + if (screenParams.size < 0) { + screenParams.size = 4; + } + break; + case screenClustered: + screenParams.type = splashScreenClustered; + if (screenParams.size < 0) { + screenParams.size = 10; + } + break; + case screenStochasticClustered: + screenParams.type = splashScreenStochasticClustered; + if (screenParams.size < 0) { + screenParams.size = 64; + } + if (screenParams.dotRadius < 0) { + screenParams.dotRadius = 2; + } + break; + case screenUnset: + default: + // use clustered dithering for resolution >= 300 dpi + // (compare to 299.9 to avoid floating point issues) + if (hDPI > 299.9 && vDPI > 299.9) { + screenParams.type = splashScreenStochasticClustered; + if (screenParams.size < 0) { + screenParams.size = 64; + } + if (screenParams.dotRadius < 0) { + screenParams.dotRadius = 2; + } + } else { + screenParams.type = splashScreenDispersed; + if (screenParams.size < 0) { + screenParams.size = 4; + } + } + } +} + +SplashOutputDev::~SplashOutputDev() { + int i; + + for (i = 0; i < nT3Fonts; ++i) { + delete t3FontCache[i]; + } + if (fontEngine) { + delete fontEngine; + } + if (splash) { + delete splash; + } + if (bitmap) { + delete bitmap; + } +} + +void SplashOutputDev::startDoc(PDFDoc *docA) { + int i; + + doc = docA; + if (fontEngine) { + delete fontEngine; + } + fontEngine = new SplashFontEngine( +#if HAVE_T1LIB_H + globalParams->getEnableT1lib(), +#endif +#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H + globalParams->getEnableFreeType(), + enableFreeTypeHinting, + enableSlightHinting, +#endif + getFontAntialias() && + colorMode != splashModeMono1); + for (i = 0; i < nT3Fonts; ++i) { + delete t3FontCache[i]; + } + nT3Fonts = 0; +} + +void SplashOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) { + int w, h; + double *ctm; + SplashCoord mat[6]; + SplashColor color; + + xref = xrefA; + if (state) { + setupScreenParams(state->getHDPI(), state->getVDPI()); + w = (int)(state->getPageWidth() + 0.5); + if (w <= 0) { + w = 1; + } + h = (int)(state->getPageHeight() + 0.5); + if (h <= 0) { + h = 1; + } + } else { + w = h = 1; + } + SplashThinLineMode thinLineMode = splashThinLineDefault; + if (splash) { + thinLineMode = splash->getThinLineMode(); + delete splash; + splash = NULL; + } + if (!bitmap || w != bitmap->getWidth() || h != bitmap->getHeight()) { + if (bitmap) { + delete bitmap; + bitmap = NULL; + } + bitmap = new SplashBitmap(w, h, bitmapRowPad, colorMode, + colorMode != splashModeMono1, bitmapTopDown); + if (!bitmap->getDataPtr()) { + delete bitmap; + w = h = 1; + bitmap = new SplashBitmap(w, h, bitmapRowPad, colorMode, + colorMode != splashModeMono1, bitmapTopDown); + } + } + splash = new Splash(bitmap, vectorAntialias, &screenParams); + splash->setThinLineMode(thinLineMode); + splash->setMinLineWidth(globalParams->getMinLineWidth()); + if (state) { + ctm = state->getCTM(); + mat[0] = (SplashCoord)ctm[0]; + mat[1] = (SplashCoord)ctm[1]; + mat[2] = (SplashCoord)ctm[2]; + mat[3] = (SplashCoord)ctm[3]; + mat[4] = (SplashCoord)ctm[4]; + mat[5] = (SplashCoord)ctm[5]; + splash->setMatrix(mat); + } + switch (colorMode) { + case splashModeMono1: + case splashModeMono8: + color[0] = 0; + break; + case splashModeXBGR8: + color[3] = 255; + case splashModeRGB8: + case splashModeBGR8: + color[0] = color[1] = color[2] = 0; + break; +#if SPLASH_CMYK + case splashModeCMYK8: + color[0] = color[1] = color[2] = color[3] = 0; + break; + case splashModeDeviceN8: + for (int i = 0; i < 4 + SPOT_NCOMPS; i++) + color[i] = 0; + break; +#endif + } + splash->setStrokePattern(new SplashSolidColor(color)); + splash->setFillPattern(new SplashSolidColor(color)); + splash->setLineCap(splashLineCapButt); + splash->setLineJoin(splashLineJoinMiter); + splash->setLineDash(NULL, 0, 0); + splash->setMiterLimit(10); + splash->setFlatness(1); + // the SA parameter supposedly defaults to false, but Acrobat + // apparently hardwires it to true + splash->setStrokeAdjust(globalParams->getStrokeAdjust()); + splash->clear(paperColor, 0); +} + +void SplashOutputDev::endPage() { + if (colorMode != splashModeMono1 && !keepAlphaChannel) { + splash->compositeBackground(paperColor); + } +} + +void SplashOutputDev::saveState(GfxState *state) { + splash->saveState(); +} + +void SplashOutputDev::restoreState(GfxState *state) { + splash->restoreState(); + needFontUpdate = gTrue; +} + +void SplashOutputDev::updateAll(GfxState *state) { + updateLineDash(state); + updateLineJoin(state); + updateLineCap(state); + updateLineWidth(state); + updateFlatness(state); + updateMiterLimit(state); + updateStrokeAdjust(state); + updateFillColorSpace(state); + updateFillColor(state); + updateStrokeColorSpace(state); + updateStrokeColor(state); + needFontUpdate = gTrue; +} + +void SplashOutputDev::updateCTM(GfxState *state, double m11, double m12, + double m21, double m22, + double m31, double m32) { + double *ctm; + SplashCoord mat[6]; + + ctm = state->getCTM(); + mat[0] = (SplashCoord)ctm[0]; + mat[1] = (SplashCoord)ctm[1]; + mat[2] = (SplashCoord)ctm[2]; + mat[3] = (SplashCoord)ctm[3]; + mat[4] = (SplashCoord)ctm[4]; + mat[5] = (SplashCoord)ctm[5]; + splash->setMatrix(mat); +} + +void SplashOutputDev::updateLineDash(GfxState *state) { + double *dashPattern; + int dashLength; + double dashStart; + SplashCoord dash[20]; + int i; + + state->getLineDash(&dashPattern, &dashLength, &dashStart); + if (dashLength > 20) { + dashLength = 20; + } + for (i = 0; i < dashLength; ++i) { + dash[i] = (SplashCoord)dashPattern[i]; + if (dash[i] < 0) { + dash[i] = 0; + } + } + splash->setLineDash(dash, dashLength, (SplashCoord)dashStart); +} + +void SplashOutputDev::updateFlatness(GfxState *state) { +#if 0 // Acrobat ignores the flatness setting, and always renders curves + // with a fairly small flatness value + splash->setFlatness(state->getFlatness()); +#endif +} + +void SplashOutputDev::updateLineJoin(GfxState *state) { + splash->setLineJoin(state->getLineJoin()); +} + +void SplashOutputDev::updateLineCap(GfxState *state) { + splash->setLineCap(state->getLineCap()); +} + +void SplashOutputDev::updateMiterLimit(GfxState *state) { + splash->setMiterLimit(state->getMiterLimit()); +} + +void SplashOutputDev::updateLineWidth(GfxState *state) { + splash->setLineWidth(state->getLineWidth()); +} + +void SplashOutputDev::updateStrokeAdjust(GfxState * /*state*/) { +#if 0 // the SA parameter supposedly defaults to false, but Acrobat + // apparently hardwires it to true + splash->setStrokeAdjust(state->getStrokeAdjust()); +#endif +} + +void SplashOutputDev::updateFillColorSpace(GfxState *state) { +#if SPLASH_CMYK + if (colorMode == splashModeDeviceN8) + state->getFillColorSpace()->createMapping(bitmap->getSeparationList(), SPOT_NCOMPS); +#endif +} + +void SplashOutputDev::updateStrokeColorSpace(GfxState *state) { +#if SPLASH_CMYK + if (colorMode == splashModeDeviceN8) + state->getStrokeColorSpace()->createMapping(bitmap->getSeparationList(), SPOT_NCOMPS); +#endif +} + +void SplashOutputDev::updateFillColor(GfxState *state) { + GfxGray gray; + GfxRGB rgb; +#if SPLASH_CMYK + GfxCMYK cmyk; + GfxColor deviceN; +#endif + + switch (colorMode) { + case splashModeMono1: + case splashModeMono8: + state->getFillGray(&gray); + splash->setFillPattern(getColor(gray)); + break; + case splashModeXBGR8: + case splashModeRGB8: + case splashModeBGR8: + state->getFillRGB(&rgb); + splash->setFillPattern(getColor(&rgb)); + break; +#if SPLASH_CMYK + case splashModeCMYK8: + state->getFillCMYK(&cmyk); + splash->setFillPattern(getColor(&cmyk)); + break; + case splashModeDeviceN8: + state->getFillDeviceN(&deviceN); + splash->setFillPattern(getColor(&deviceN)); + break; +#endif + } +} + +void SplashOutputDev::updateStrokeColor(GfxState *state) { + GfxGray gray; + GfxRGB rgb; +#if SPLASH_CMYK + GfxCMYK cmyk; + GfxColor deviceN; +#endif + + switch (colorMode) { + case splashModeMono1: + case splashModeMono8: + state->getStrokeGray(&gray); + splash->setStrokePattern(getColor(gray)); + break; + case splashModeXBGR8: + case splashModeRGB8: + case splashModeBGR8: + state->getStrokeRGB(&rgb); + splash->setStrokePattern(getColor(&rgb)); + break; +#if SPLASH_CMYK + case splashModeCMYK8: + state->getStrokeCMYK(&cmyk); + splash->setStrokePattern(getColor(&cmyk)); + break; + case splashModeDeviceN8: + state->getStrokeDeviceN(&deviceN); + splash->setStrokePattern(getColor(&deviceN)); + break; +#endif + } +} + +SplashPattern *SplashOutputDev::getColor(GfxGray gray) { + SplashColor color; + + if (reverseVideo) { + gray = gfxColorComp1 - gray; + } + color[0] = colToByte(gray); + return new SplashSolidColor(color); +} + +SplashPattern *SplashOutputDev::getColor(GfxRGB *rgb) { + GfxColorComp r, g, b; + SplashColor color; + + if (reverseVideo) { + r = gfxColorComp1 - rgb->r; + g = gfxColorComp1 - rgb->g; + b = gfxColorComp1 - rgb->b; + } else { + r = rgb->r; + g = rgb->g; + b = rgb->b; + } + color[0] = colToByte(r); + color[1] = colToByte(g); + color[2] = colToByte(b); + if (colorMode == splashModeXBGR8) color[3] = 255; + return new SplashSolidColor(color); +} + +#if SPLASH_CMYK +SplashPattern *SplashOutputDev::getColor(GfxCMYK *cmyk) { + SplashColor color; + + color[0] = colToByte(cmyk->c); + color[1] = colToByte(cmyk->m); + color[2] = colToByte(cmyk->y); + color[3] = colToByte(cmyk->k); + return new SplashSolidColor(color); +} + +SplashPattern *SplashOutputDev::getColor(GfxColor *deviceN) { + SplashColor color; + + for (int i = 0; i < 4 + SPOT_NCOMPS; i++) + color[i] = colToByte(deviceN->c[i]); + return new SplashSolidColor(color); +} +#endif + +void SplashOutputDev::setOverprintMask(GfxColorSpace *colorSpace, + GBool overprintFlag, + int overprintMode, + GfxColor *singleColor, + GBool grayIndexed) { +#if SPLASH_CMYK + Guint mask; + GfxCMYK cmyk; + GBool additive = gFalse; + int i; + + if (colorSpace->getMode() == csIndexed) { + setOverprintMask(((GfxIndexedColorSpace *)colorSpace)->getBase(), + overprintFlag, + overprintMode, + singleColor, + grayIndexed); + return; + } + if (overprintFlag && overprintPreview) { + mask = colorSpace->getOverprintMask(); + if (singleColor && overprintMode && + colorSpace->getMode() == csDeviceCMYK) { + colorSpace->getCMYK(singleColor, &cmyk); + if (cmyk.c == 0) { + mask &= ~1; + } + if (cmyk.m == 0) { + mask &= ~2; + } + if (cmyk.y == 0) { + mask &= ~4; + } + if (cmyk.k == 0) { + mask &= ~8; + } + } + if (grayIndexed) { + mask &= ~7; + } else if (colorSpace->getMode() == csSeparation) { + GfxSeparationColorSpace *deviceSep = (GfxSeparationColorSpace *)colorSpace; + additive = deviceSep->getName()->cmp("All") != 0 && mask == 0x0f && !deviceSep->isNonMarking(); + } else if (colorSpace->getMode() == csDeviceN) { + GfxDeviceNColorSpace *deviceNCS = (GfxDeviceNColorSpace *)colorSpace; + additive = mask == 0x0f && !deviceNCS->isNonMarking(); + for (i = 0; i < deviceNCS->getNComps() && additive; i++) { + if (deviceNCS->getColorantName(i)->cmp("Cyan") == 0) { + additive = gFalse; + } else if (deviceNCS->getColorantName(i)->cmp("Magenta") == 0) { + additive = gFalse; + } else if (deviceNCS->getColorantName(i)->cmp("Yellow") == 0) { + additive = gFalse; + } else if (deviceNCS->getColorantName(i)->cmp("Black") == 0) { + additive = gFalse; + } + } + } + } else { + mask = 0xffffffff; + } + splash->setOverprintMask(mask, additive); +#endif +} + +void SplashOutputDev::updateBlendMode(GfxState *state) { + splash->setBlendFunc(splashOutBlendFuncs[state->getBlendMode()]); +} + +void SplashOutputDev::updateFillOpacity(GfxState *state) { + splash->setFillAlpha((SplashCoord)state->getFillOpacity()); + if (transpGroupStack != NULL && (SplashCoord)state->getFillOpacity() < transpGroupStack->knockoutOpacity) { + transpGroupStack->knockoutOpacity = (SplashCoord)state->getFillOpacity(); + } +} + +void SplashOutputDev::updateStrokeOpacity(GfxState *state) { + splash->setStrokeAlpha((SplashCoord)state->getStrokeOpacity()); + if (transpGroupStack != NULL && (SplashCoord)state->getStrokeOpacity() < transpGroupStack->knockoutOpacity) { + transpGroupStack->knockoutOpacity = (SplashCoord)state->getStrokeOpacity(); + } +} + +void SplashOutputDev::updateFillOverprint(GfxState *state) { + splash->setFillOverprint(state->getFillOverprint()); +} + +void SplashOutputDev::updateStrokeOverprint(GfxState *state) { + splash->setStrokeOverprint(state->getStrokeOverprint()); +} + +void SplashOutputDev::updateOverprintMode(GfxState *state) { + splash->setOverprintMode(state->getOverprintMode()); +} + +void SplashOutputDev::updateTransfer(GfxState *state) { + Function **transfer; + Guchar red[256], green[256], blue[256], gray[256]; + double x, y; + int i; + + transfer = state->getTransfer(); + if (transfer[0] && + transfer[0]->getInputSize() == 1 && + transfer[0]->getOutputSize() == 1) { + if (transfer[1] && + transfer[1]->getInputSize() == 1 && + transfer[1]->getOutputSize() == 1 && + transfer[2] && + transfer[2]->getInputSize() == 1 && + transfer[2]->getOutputSize() == 1 && + transfer[3] && + transfer[3]->getInputSize() == 1 && + transfer[3]->getOutputSize() == 1) { + for (i = 0; i < 256; ++i) { + x = i / 255.0; + transfer[0]->transform(&x, &y); + red[i] = (Guchar)(y * 255.0 + 0.5); + transfer[1]->transform(&x, &y); + green[i] = (Guchar)(y * 255.0 + 0.5); + transfer[2]->transform(&x, &y); + blue[i] = (Guchar)(y * 255.0 + 0.5); + transfer[3]->transform(&x, &y); + gray[i] = (Guchar)(y * 255.0 + 0.5); + } + } else { + for (i = 0; i < 256; ++i) { + x = i / 255.0; + transfer[0]->transform(&x, &y); + red[i] = green[i] = blue[i] = gray[i] = (Guchar)(y * 255.0 + 0.5); + } + } + } else { + for (i = 0; i < 256; ++i) { + red[i] = green[i] = blue[i] = gray[i] = (Guchar)i; + } + } + splash->setTransfer(red, green, blue, gray); +} + +void SplashOutputDev::updateFont(GfxState * /*state*/) { + needFontUpdate = gTrue; +} + +void SplashOutputDev::doUpdateFont(GfxState *state) { + GfxFont *gfxFont; + GfxFontLoc *fontLoc; + GfxFontType fontType; + SplashOutFontFileID *id; + SplashFontFile *fontFile; + SplashFontSrc *fontsrc = NULL; + FoFiTrueType *ff; + Object refObj, strObj; + GooString *fileName; + char *tmpBuf; + int tmpBufLen; + int *codeToGID; + double *textMat; + double m11, m12, m21, m22, fontSize; + int faceIndex = 0; + SplashCoord mat[4]; + int n, i; + GBool recreateFont = gFalse; + GBool doAdjustFontMatrix = gFalse; + + needFontUpdate = gFalse; + font = NULL; + fileName = NULL; + tmpBuf = NULL; + fontLoc = NULL; + + if (!(gfxFont = state->getFont())) { + goto err1; + } + fontType = gfxFont->getType(); + if (fontType == fontType3) { + goto err1; + } + + // sanity-check the font size - skip anything larger than 10 inches + // (this avoids problems allocating memory for the font cache) + if (state->getTransformedFontSize() + > 10 * (state->getHDPI() + state->getVDPI())) { + goto err1; + } + + // check the font file cache + id = new SplashOutFontFileID(gfxFont->getID()); + if ((fontFile = fontEngine->getFontFile(id))) { + delete id; + + } else { + + if (!(fontLoc = gfxFont->locateFont((xref) ? xref : doc->getXRef(), NULL))) { + error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'", + gfxFont->getName() ? gfxFont->getName()->getCString() + : "(unnamed)"); + goto err2; + } + + // embedded font + if (fontLoc->locType == gfxFontLocEmbedded) { + // if there is an embedded font, read it to memory + tmpBuf = gfxFont->readEmbFontFile((xref) ? xref : doc->getXRef(), &tmpBufLen); + if (! tmpBuf) + goto err2; + + // external font + } else { // gfxFontLocExternal + fileName = fontLoc->path; + fontType = fontLoc->fontType; + doAdjustFontMatrix = gTrue; + } + + fontsrc = new SplashFontSrc; + if (fileName) + fontsrc->setFile(fileName, gFalse); + else + fontsrc->setBuf(tmpBuf, tmpBufLen, gTrue); + + // load the font file + switch (fontType) { + case fontType1: + if (!(fontFile = fontEngine->loadType1Font( + id, + fontsrc, + (const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) { + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", + gfxFont->getName() ? gfxFont->getName()->getCString() + : "(unnamed)"); + goto err2; + } + break; + case fontType1C: + if (!(fontFile = fontEngine->loadType1CFont( + id, + fontsrc, + (const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) { + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", + gfxFont->getName() ? gfxFont->getName()->getCString() + : "(unnamed)"); + goto err2; + } + break; + case fontType1COT: + if (!(fontFile = fontEngine->loadOpenTypeT1CFont( + id, + fontsrc, + (const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) { + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", + gfxFont->getName() ? gfxFont->getName()->getCString() + : "(unnamed)"); + goto err2; + } + break; + case fontTrueType: + case fontTrueTypeOT: + if (fileName) + ff = FoFiTrueType::load(fileName->getCString()); + else + ff = FoFiTrueType::make(tmpBuf, tmpBufLen); + if (ff) { + codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff); + n = 256; + delete ff; + // if we're substituting for a non-TrueType font, we need to mark + // all notdef codes as "do not draw" (rather than drawing TrueType + // notdef glyphs) + if (gfxFont->getType() != fontTrueType && + gfxFont->getType() != fontTrueTypeOT) { + for (i = 0; i < 256; ++i) { + if (codeToGID[i] == 0) { + codeToGID[i] = -1; + } + } + } + } else { + codeToGID = NULL; + n = 0; + } + if (!(fontFile = fontEngine->loadTrueTypeFont( + id, + fontsrc, + codeToGID, n))) { + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", + gfxFont->getName() ? gfxFont->getName()->getCString() + : "(unnamed)"); + goto err2; + } + break; + case fontCIDType0: + case fontCIDType0C: + if (!(fontFile = fontEngine->loadCIDFont( + id, + fontsrc))) { + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", + gfxFont->getName() ? gfxFont->getName()->getCString() + : "(unnamed)"); + goto err2; + } + break; + case fontCIDType0COT: + if (((GfxCIDFont *)gfxFont)->getCIDToGID()) { + n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen(); + codeToGID = (int *)gmallocn(n, sizeof(int)); + memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), + n * sizeof(int)); + } else { + codeToGID = NULL; + n = 0; + } + if (!(fontFile = fontEngine->loadOpenTypeCFFFont( + id, + fontsrc, + codeToGID, n))) { + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", + gfxFont->getName() ? gfxFont->getName()->getCString() + : "(unnamed)"); + goto err2; + } + break; + case fontCIDType2: + case fontCIDType2OT: + codeToGID = NULL; + n = 0; + if (((GfxCIDFont *)gfxFont)->getCIDToGID()) { + n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen(); + if (n) { + codeToGID = (int *)gmallocn(n, sizeof(int)); + memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), + n * sizeof(int)); + } + } else { + if (fileName) + ff = FoFiTrueType::load(fileName->getCString()); + else + ff = FoFiTrueType::make(tmpBuf, tmpBufLen); + if (! ff) + { + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", + gfxFont->getName() ? gfxFont->getName()->getCString() + : "(unnamed)"); + goto err2; + } + codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n); + delete ff; + } + if (!(fontFile = fontEngine->loadTrueTypeFont( + id, + fontsrc, + codeToGID, n, faceIndex))) { + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", + gfxFont->getName() ? gfxFont->getName()->getCString() + : "(unnamed)"); + goto err2; + } + break; + default: + // this shouldn't happen + goto err2; + } + fontFile->doAdjustMatrix = doAdjustFontMatrix; + } + + // get the font matrix + textMat = state->getTextMat(); + fontSize = state->getFontSize(); + m11 = textMat[0] * fontSize * state->getHorizScaling(); + m12 = textMat[1] * fontSize * state->getHorizScaling(); + m21 = textMat[2] * fontSize; + m22 = textMat[3] * fontSize; + + // create the scaled font + mat[0] = m11; mat[1] = m12; + mat[2] = m21; mat[3] = m22; + font = fontEngine->getFont(fontFile, mat, splash->getMatrix()); + + // for substituted fonts: adjust the font matrix -- compare the + // width of 'm' in the original font and the substituted font + if (fontFile->doAdjustMatrix && !gfxFont->isCIDFont()) { + double w1, w2; + CharCode code; + char *name; + for (code = 0; code < 256; ++code) { + if ((name = ((Gfx8BitFont *)gfxFont)->getCharName(code)) && + name[0] == 'm' && name[1] == '\0') { + break; + } + } + if (code < 256) { + w1 = ((Gfx8BitFont *)gfxFont)->getWidth(code); + w2 = font->getGlyphAdvance(code); + if (!gfxFont->isSymbolic() && w2 > 0) { + // if real font is substantially narrower than substituted + // font, reduce the font size accordingly + if (w1 > 0.01 && w1 < 0.9 * w2) { + w1 /= w2; + m11 *= w1; + m21 *= w1; + recreateFont = gTrue; + } + } + } + } + + if (recreateFont) + { + mat[0] = m11; mat[1] = m12; + mat[2] = m21; mat[3] = m22; + font = fontEngine->getFont(fontFile, mat, splash->getMatrix()); + } + + delete fontLoc; + if (fontsrc && !fontsrc->isFile) + fontsrc->unref(); + return; + + err2: + delete id; + delete fontLoc; + err1: + if (fontsrc && !fontsrc->isFile) + fontsrc->unref(); + return; +} + +void SplashOutputDev::stroke(GfxState *state) { + SplashPath *path; + + if (state->getStrokeColorSpace()->isNonMarking()) { + return; + } + setOverprintMask(state->getStrokeColorSpace(), state->getStrokeOverprint(), + state->getOverprintMode(), state->getStrokeColor()); + path = convertPath(state, state->getPath(), gFalse); + splash->stroke(path); + delete path; +} + +void SplashOutputDev::fill(GfxState *state) { + SplashPath *path; + + if (state->getFillColorSpace()->isNonMarking()) { + return; + } + setOverprintMask(state->getFillColorSpace(), state->getFillOverprint(), + state->getOverprintMode(), state->getFillColor()); + path = convertPath(state, state->getPath(), gTrue); + splash->fill(path, gFalse); + delete path; +} + +void SplashOutputDev::eoFill(GfxState *state) { + SplashPath *path; + + if (state->getFillColorSpace()->isNonMarking()) { + return; + } + setOverprintMask(state->getFillColorSpace(), state->getFillOverprint(), + state->getOverprintMode(), state->getFillColor()); + path = convertPath(state, state->getPath(), gTrue); + splash->fill(path, gTrue); + delete path; +} + +void SplashOutputDev::clip(GfxState *state) { + SplashPath *path; + + path = convertPath(state, state->getPath(), gTrue); + splash->clipToPath(path, gFalse); + delete path; +} + +void SplashOutputDev::eoClip(GfxState *state) { + SplashPath *path; + + path = convertPath(state, state->getPath(), gTrue); + splash->clipToPath(path, gTrue); + delete path; +} + +void SplashOutputDev::clipToStrokePath(GfxState *state) { + SplashPath *path, *path2; + + path = convertPath(state, state->getPath(), gFalse); + path2 = splash->makeStrokePath(path, state->getLineWidth()); + delete path; + splash->clipToPath(path2, gFalse); + delete path2; +} + +SplashPath *SplashOutputDev::convertPath(GfxState *state, GfxPath *path, + GBool dropEmptySubpaths) { + SplashPath *sPath; + GfxSubpath *subpath; + int n, i, j; + + n = dropEmptySubpaths ? 1 : 0; + sPath = new SplashPath(); + for (i = 0; i < path->getNumSubpaths(); ++i) { + subpath = path->getSubpath(i); + if (subpath->getNumPoints() > n) { + sPath->moveTo((SplashCoord)subpath->getX(0), + (SplashCoord)subpath->getY(0)); + j = 1; + while (j < subpath->getNumPoints()) { + if (subpath->getCurve(j)) { + sPath->curveTo((SplashCoord)subpath->getX(j), + (SplashCoord)subpath->getY(j), + (SplashCoord)subpath->getX(j+1), + (SplashCoord)subpath->getY(j+1), + (SplashCoord)subpath->getX(j+2), + (SplashCoord)subpath->getY(j+2)); + j += 3; + } else { + sPath->lineTo((SplashCoord)subpath->getX(j), + (SplashCoord)subpath->getY(j)); + ++j; + } + } + if (subpath->isClosed()) { + sPath->close(); + } + } + } + return sPath; +} + +void SplashOutputDev::drawChar(GfxState *state, double x, double y, + double dx, double dy, + double originX, double originY, + CharCode code, int nBytes, + Unicode *u, int uLen) { + SplashPath *path; + int render; + GBool doFill, doStroke, doClip, strokeAdjust; + double m[4]; + GBool horiz; + + if (skipHorizText || skipRotatedText) { + state->getFontTransMat(&m[0], &m[1], &m[2], &m[3]); + horiz = m[0] > 0 && fabs(m[1]) < 0.001 && + fabs(m[2]) < 0.001 && m[3] < 0; + if ((skipHorizText && horiz) || (skipRotatedText && !horiz)) { + return; + } + } + + // check for invisible text -- this is used by Acrobat Capture + render = state->getRender(); + if (render == 3) { + return; + } + + if (needFontUpdate) { + doUpdateFont(state); + } + if (!font) { + return; + } + + x -= originX; + y -= originY; + + doFill = !(render & 1) && !state->getFillColorSpace()->isNonMarking(); + doStroke = ((render & 3) == 1 || (render & 3) == 2) && + !state->getStrokeColorSpace()->isNonMarking(); + doClip = render & 4; + + path = NULL; + if (doStroke || doClip) { + if ((path = font->getGlyphPath(code))) { + path->offset((SplashCoord)x, (SplashCoord)y); + } + } + + // don't use stroke adjustment when stroking text -- the results + // tend to be ugly (because characters with horizontal upper or + // lower edges get misaligned relative to the other characters) + strokeAdjust = gFalse; // make gcc happy + if (doStroke) { + strokeAdjust = splash->getStrokeAdjust(); + splash->setStrokeAdjust(gFalse); + } + + // fill and stroke + if (doFill && doStroke) { + if (path) { + setOverprintMask(state->getFillColorSpace(), state->getFillOverprint(), + state->getOverprintMode(), state->getFillColor()); + splash->fill(path, gFalse); + setOverprintMask(state->getStrokeColorSpace(), + state->getStrokeOverprint(), + state->getOverprintMode(), + state->getStrokeColor()); + splash->stroke(path); + } + + // fill + } else if (doFill) { + setOverprintMask(state->getFillColorSpace(), state->getFillOverprint(), + state->getOverprintMode(), state->getFillColor()); + splash->fillChar((SplashCoord)x, (SplashCoord)y, code, font); + + // stroke + } else if (doStroke) { + if (path) { + setOverprintMask(state->getStrokeColorSpace(), + state->getStrokeOverprint(), + state->getOverprintMode(), + state->getStrokeColor()); + splash->stroke(path); + } + } + + // clip + if (doClip) { + if (path) { + if (textClipPath) { + textClipPath->append(path); + } else { + textClipPath = path; + path = NULL; + } + } + } + + if (doStroke) { + splash->setStrokeAdjust(strokeAdjust); + } + + if (path) { + delete path; + } +} + +GBool SplashOutputDev::beginType3Char(GfxState *state, double x, double y, + double dx, double dy, + CharCode code, Unicode *u, int uLen) { + GfxFont *gfxFont; + Ref *fontID; + double *ctm, *bbox; + T3FontCache *t3Font; + T3GlyphStack *t3gs; + GBool validBBox; + double m[4]; + GBool horiz; + double x1, y1, xMin, yMin, xMax, yMax, xt, yt; + int i, j; + + if (skipHorizText || skipRotatedText) { + state->getFontTransMat(&m[0], &m[1], &m[2], &m[3]); + horiz = m[0] > 0 && fabs(m[1]) < 0.001 && + fabs(m[2]) < 0.001 && m[3] < 0; + if ((skipHorizText && horiz) || (skipRotatedText && !horiz)) { + return gTrue; + } + } + + if (!(gfxFont = state->getFont())) { + return gFalse; + } + fontID = gfxFont->getID(); + ctm = state->getCTM(); + state->transform(0, 0, &xt, &yt); + + // is it the first (MRU) font in the cache? + if (!(nT3Fonts > 0 && + t3FontCache[0]->matches(fontID, ctm[0], ctm[1], ctm[2], ctm[3]))) { + + // is the font elsewhere in the cache? + for (i = 1; i < nT3Fonts; ++i) { + if (t3FontCache[i]->matches(fontID, ctm[0], ctm[1], ctm[2], ctm[3])) { + t3Font = t3FontCache[i]; + for (j = i; j > 0; --j) { + t3FontCache[j] = t3FontCache[j - 1]; + } + t3FontCache[0] = t3Font; + break; + } + } + if (i >= nT3Fonts) { + + // create new entry in the font cache + if (nT3Fonts == splashOutT3FontCacheSize) { + t3gs = t3GlyphStack; + while (t3gs != NULL) { + if (t3gs->cache == t3FontCache[nT3Fonts - 1]) { + error(errSyntaxWarning, -1, "t3FontCache reaches limit but font still on stack in SplashOutputDev::beginType3Char"); + return gTrue; + } + t3gs = t3gs->next; + } + delete t3FontCache[nT3Fonts - 1]; + --nT3Fonts; + } + for (j = nT3Fonts; j > 0; --j) { + t3FontCache[j] = t3FontCache[j - 1]; + } + ++nT3Fonts; + bbox = gfxFont->getFontBBox(); + if (bbox[0] == 0 && bbox[1] == 0 && bbox[2] == 0 && bbox[3] == 0) { + // unspecified bounding box -- just take a guess + xMin = xt - 5; + xMax = xMin + 30; + yMax = yt + 15; + yMin = yMax - 45; + validBBox = gFalse; + } else { + state->transform(bbox[0], bbox[1], &x1, &y1); + xMin = xMax = x1; + yMin = yMax = y1; + state->transform(bbox[0], bbox[3], &x1, &y1); + if (x1 < xMin) { + xMin = x1; + } else if (x1 > xMax) { + xMax = x1; + } + if (y1 < yMin) { + yMin = y1; + } else if (y1 > yMax) { + yMax = y1; + } + state->transform(bbox[2], bbox[1], &x1, &y1); + if (x1 < xMin) { + xMin = x1; + } else if (x1 > xMax) { + xMax = x1; + } + if (y1 < yMin) { + yMin = y1; + } else if (y1 > yMax) { + yMax = y1; + } + state->transform(bbox[2], bbox[3], &x1, &y1); + if (x1 < xMin) { + xMin = x1; + } else if (x1 > xMax) { + xMax = x1; + } + if (y1 < yMin) { + yMin = y1; + } else if (y1 > yMax) { + yMax = y1; + } + validBBox = gTrue; + } + t3FontCache[0] = new T3FontCache(fontID, ctm[0], ctm[1], ctm[2], ctm[3], + (int)floor(xMin - xt) - 2, + (int)floor(yMin - yt) - 2, + (int)ceil(xMax) - (int)floor(xMin) + 4, + (int)ceil(yMax) - (int)floor(yMin) + 4, + validBBox, + colorMode != splashModeMono1); + } + } + t3Font = t3FontCache[0]; + + // is the glyph in the cache? + i = (code & (t3Font->cacheSets - 1)) * t3Font->cacheAssoc; + for (j = 0; j < t3Font->cacheAssoc; ++j) { + if (t3Font->cacheTags != NULL) { + if ((t3Font->cacheTags[i+j].mru & 0x8000) && + t3Font->cacheTags[i+j].code == code) { + drawType3Glyph(state, t3Font, &t3Font->cacheTags[i+j], + t3Font->cacheData + (i+j) * t3Font->glyphSize); + return gTrue; + } + } + } + + // push a new Type 3 glyph record + t3gs = new T3GlyphStack(); + t3gs->next = t3GlyphStack; + t3GlyphStack = t3gs; + t3GlyphStack->code = code; + t3GlyphStack->cache = t3Font; + t3GlyphStack->cacheTag = NULL; + t3GlyphStack->cacheData = NULL; + + haveT3Dx = gFalse; + + return gFalse; +} + +void SplashOutputDev::endType3Char(GfxState *state) { + T3GlyphStack *t3gs; + double *ctm; + + if (t3GlyphStack->cacheTag) { + --nestCount; + memcpy(t3GlyphStack->cacheData, bitmap->getDataPtr(), + t3GlyphStack->cache->glyphSize); + delete bitmap; + delete splash; + bitmap = t3GlyphStack->origBitmap; + splash = t3GlyphStack->origSplash; + ctm = state->getCTM(); + state->setCTM(ctm[0], ctm[1], ctm[2], ctm[3], + t3GlyphStack->origCTM4, t3GlyphStack->origCTM5); + updateCTM(state, 0, 0, 0, 0, 0, 0); + drawType3Glyph(state, t3GlyphStack->cache, + t3GlyphStack->cacheTag, t3GlyphStack->cacheData); + } + t3gs = t3GlyphStack; + t3GlyphStack = t3gs->next; + delete t3gs; +} + +void SplashOutputDev::type3D0(GfxState *state, double wx, double wy) { + haveT3Dx = gTrue; +} + +void SplashOutputDev::type3D1(GfxState *state, double wx, double wy, + double llx, double lly, double urx, double ury) { + double *ctm; + T3FontCache *t3Font; + SplashColor color; + double xt, yt, xMin, xMax, yMin, yMax, x1, y1; + int i, j; + + // ignore multiple d0/d1 operators + if (haveT3Dx) { + return; + } + haveT3Dx = gTrue; + + if (unlikely(t3GlyphStack == NULL)) { + error(errSyntaxWarning, -1, "t3GlyphStack was null in SplashOutputDev::type3D1"); + return; + } + + if (unlikely(t3GlyphStack->origBitmap != NULL)) { + error(errSyntaxWarning, -1, "t3GlyphStack origBitmap was not null in SplashOutputDev::type3D1"); + return; + } + + if (unlikely(t3GlyphStack->origSplash != NULL)) { + error(errSyntaxWarning, -1, "t3GlyphStack origSplash was not null in SplashOutputDev::type3D1"); + return; + } + + t3Font = t3GlyphStack->cache; + + // check for a valid bbox + state->transform(0, 0, &xt, &yt); + state->transform(llx, lly, &x1, &y1); + xMin = xMax = x1; + yMin = yMax = y1; + state->transform(llx, ury, &x1, &y1); + if (x1 < xMin) { + xMin = x1; + } else if (x1 > xMax) { + xMax = x1; + } + if (y1 < yMin) { + yMin = y1; + } else if (y1 > yMax) { + yMax = y1; + } + state->transform(urx, lly, &x1, &y1); + if (x1 < xMin) { + xMin = x1; + } else if (x1 > xMax) { + xMax = x1; + } + if (y1 < yMin) { + yMin = y1; + } else if (y1 > yMax) { + yMax = y1; + } + state->transform(urx, ury, &x1, &y1); + if (x1 < xMin) { + xMin = x1; + } else if (x1 > xMax) { + xMax = x1; + } + if (y1 < yMin) { + yMin = y1; + } else if (y1 > yMax) { + yMax = y1; + } + if (xMin - xt < t3Font->glyphX || + yMin - yt < t3Font->glyphY || + xMax - xt > t3Font->glyphX + t3Font->glyphW || + yMax - yt > t3Font->glyphY + t3Font->glyphH) { + if (t3Font->validBBox) { + error(errSyntaxWarning, -1, "Bad bounding box in Type 3 glyph"); + } + return; + } + + if (t3Font->cacheTags == NULL) + return; + + // allocate a cache entry + i = (t3GlyphStack->code & (t3Font->cacheSets - 1)) * t3Font->cacheAssoc; + for (j = 0; j < t3Font->cacheAssoc; ++j) { + if ((t3Font->cacheTags[i+j].mru & 0x7fff) == t3Font->cacheAssoc - 1) { + t3Font->cacheTags[i+j].mru = 0x8000; + t3Font->cacheTags[i+j].code = t3GlyphStack->code; + t3GlyphStack->cacheTag = &t3Font->cacheTags[i+j]; + t3GlyphStack->cacheData = t3Font->cacheData + (i+j) * t3Font->glyphSize; + } else { + ++t3Font->cacheTags[i+j].mru; + } + } + + // save state + t3GlyphStack->origBitmap = bitmap; + t3GlyphStack->origSplash = splash; + ctm = state->getCTM(); + t3GlyphStack->origCTM4 = ctm[4]; + t3GlyphStack->origCTM5 = ctm[5]; + + // create the temporary bitmap + if (colorMode == splashModeMono1) { + bitmap = new SplashBitmap(t3Font->glyphW, t3Font->glyphH, 1, + splashModeMono1, gFalse); + splash = new Splash(bitmap, gFalse, + t3GlyphStack->origSplash->getScreen()); + color[0] = 0; + splash->clear(color); + color[0] = 0xff; + } else { + bitmap = new SplashBitmap(t3Font->glyphW, t3Font->glyphH, 1, + splashModeMono8, gFalse); + splash = new Splash(bitmap, vectorAntialias, + t3GlyphStack->origSplash->getScreen()); + color[0] = 0x00; + splash->clear(color); + color[0] = 0xff; + } + splash->setMinLineWidth(globalParams->getMinLineWidth()); + splash->setThinLineMode(splashThinLineDefault); + splash->setFillPattern(new SplashSolidColor(color)); + splash->setStrokePattern(new SplashSolidColor(color)); + //~ this should copy other state from t3GlyphStack->origSplash? + state->setCTM(ctm[0], ctm[1], ctm[2], ctm[3], + -t3Font->glyphX, -t3Font->glyphY); + updateCTM(state, 0, 0, 0, 0, 0, 0); + ++nestCount; +} + +void SplashOutputDev::drawType3Glyph(GfxState *state, T3FontCache *t3Font, + T3FontCacheTag * /*tag*/, Guchar *data) { + SplashGlyphBitmap glyph; + + setOverprintMask(state->getFillColorSpace(), state->getFillOverprint(), + state->getOverprintMode(), state->getFillColor()); + glyph.x = -t3Font->glyphX; + glyph.y = -t3Font->glyphY; + glyph.w = t3Font->glyphW; + glyph.h = t3Font->glyphH; + glyph.aa = colorMode != splashModeMono1; + glyph.data = data; + glyph.freeData = gFalse; + splash->fillGlyph(0, 0, &glyph); +} + +void SplashOutputDev::beginTextObject(GfxState *state) { +} + +void SplashOutputDev::endTextObject(GfxState *state) { + if (textClipPath) { + splash->clipToPath(textClipPath, gFalse); + delete textClipPath; + textClipPath = NULL; + } +} + +struct SplashOutImageMaskData { + ImageStream *imgStr; + GBool invert; + int width, height, y; +}; + +GBool SplashOutputDev::imageMaskSrc(void *data, SplashColorPtr line) { + SplashOutImageMaskData *imgMaskData = (SplashOutImageMaskData *)data; + Guchar *p; + SplashColorPtr q; + int x; + + if (imgMaskData->y == imgMaskData->height) { + return gFalse; + } + if (!(p = imgMaskData->imgStr->getLine())) { + return gFalse; + } + for (x = 0, q = line; x < imgMaskData->width; ++x) { + *q++ = *p++ ^ imgMaskData->invert; + } + ++imgMaskData->y; + return gTrue; +} + +void SplashOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, + int width, int height, GBool invert, + GBool interpolate, GBool inlineImg) { + double *ctm; + SplashCoord mat[6]; + SplashOutImageMaskData imgMaskData; + + if (state->getFillColorSpace()->isNonMarking()) { + return; + } + setOverprintMask(state->getFillColorSpace(), state->getFillOverprint(), + state->getOverprintMode(), state->getFillColor()); + + ctm = state->getCTM(); + for (int i = 0; i < 6; ++i) { + if (!isfinite(ctm[i])) return; + } + mat[0] = ctm[0]; + mat[1] = ctm[1]; + mat[2] = -ctm[2]; + mat[3] = -ctm[3]; + mat[4] = ctm[2] + ctm[4]; + mat[5] = ctm[3] + ctm[5]; + + imgMaskData.imgStr = new ImageStream(str, width, 1, 1); + imgMaskData.imgStr->reset(); + imgMaskData.invert = invert ? 0 : 1; + imgMaskData.width = width; + imgMaskData.height = height; + imgMaskData.y = 0; + + splash->fillImageMask(&imageMaskSrc, &imgMaskData, width, height, mat, t3GlyphStack != NULL); + if (inlineImg) { + while (imgMaskData.y < height) { + imgMaskData.imgStr->getLine(); + ++imgMaskData.y; + } + } + + delete imgMaskData.imgStr; + str->close(); +} + +void SplashOutputDev::setSoftMaskFromImageMask(GfxState *state, + Object *ref, Stream *str, + int width, int height, + GBool invert, + GBool inlineImg, double *baseMatrix) { + double *ctm; + SplashCoord mat[6]; + SplashOutImageMaskData imgMaskData; + Splash *maskSplash; + SplashColor maskColor; + double bbox[4] = {0, 0, 1, 1}; // default; + + if (state->getFillColorSpace()->isNonMarking()) { + return; + } + + ctm = state->getCTM(); + for (int i = 0; i < 6; ++i) { + if (!isfinite(ctm[i])) return; + } + + beginTransparencyGroup(state, bbox, NULL, gFalse, gFalse, gFalse); + baseMatrix[4] -= transpGroupStack->tx; + baseMatrix[5] -= transpGroupStack->ty; + + ctm = state->getCTM(); + mat[0] = ctm[0]; + mat[1] = ctm[1]; + mat[2] = -ctm[2]; + mat[3] = -ctm[3]; + mat[4] = ctm[2] + ctm[4]; + mat[5] = ctm[3] + ctm[5]; + imgMaskData.imgStr = new ImageStream(str, width, 1, 1); + imgMaskData.imgStr->reset(); + imgMaskData.invert = invert ? 0 : 1; + imgMaskData.width = width; + imgMaskData.height = height; + imgMaskData.y = 0; + + maskBitmap = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(), 1, splashModeMono8, gFalse); + maskSplash = new Splash(maskBitmap, vectorAntialias); + maskColor[0] = 0; + maskSplash->clear(maskColor); + maskColor[0] = 0xff; + maskSplash->setFillPattern(new SplashSolidColor(maskColor)); + maskSplash->fillImageMask(&imageMaskSrc, &imgMaskData, width, height, mat, t3GlyphStack != NULL); + delete maskSplash; + delete imgMaskData.imgStr; + str->close(); +} + +void SplashOutputDev::unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) { + double bbox[4] = {0,0,1,1}; // dummy + + /* transfer mask to alpha channel! */ + // memcpy(maskBitmap->getAlphaPtr(), maskBitmap->getDataPtr(), bitmap->getRowSize() * bitmap->getHeight()); + // memset(maskBitmap->getDataPtr(), 0, bitmap->getRowSize() * bitmap->getHeight()); + Guchar *dest = bitmap->getAlphaPtr(); + Guchar *src = maskBitmap->getDataPtr(); + for (int c= 0; c < maskBitmap->getRowSize() * maskBitmap->getHeight(); c++) { + dest[c] = src[c]; + } + delete maskBitmap; + maskBitmap = NULL; + endTransparencyGroup(state); + baseMatrix[4] += transpGroupStack->tx; + baseMatrix[5] += transpGroupStack->ty; + paintTransparencyGroup(state, bbox); +} + +struct SplashOutImageData { + ImageStream *imgStr; + GfxImageColorMap *colorMap; + SplashColorPtr lookup; + int *maskColors; + SplashColorMode colorMode; + int width, height, y; +}; + +GBool SplashOutputDev::imageSrc(void *data, SplashColorPtr colorLine, + Guchar * /*alphaLine*/) { + SplashOutImageData *imgData = (SplashOutImageData *)data; + Guchar *p; + SplashColorPtr q, col; + GfxRGB rgb; + GfxGray gray; +#if SPLASH_CMYK + GfxCMYK cmyk; + GfxColor deviceN; +#endif + int nComps, x; + + if (imgData->y == imgData->height) { + return gFalse; + } + if (!(p = imgData->imgStr->getLine())) { + int destComps = 1; + if (imgData->colorMode == splashModeRGB8 || imgData->colorMode == splashModeBGR8) + destComps = 3; + else if (imgData->colorMode == splashModeXBGR8) + destComps = 4; +#if SPLASH_CMYK + else if (imgData->colorMode == splashModeCMYK8) + destComps = 4; + else if (imgData->colorMode == splashModeDeviceN8) + destComps = SPOT_NCOMPS + 4; +#endif + memset(colorLine, 0, imgData->width * destComps); + return gFalse; + } + + nComps = imgData->colorMap->getNumPixelComps(); + + if (imgData->lookup) { + switch (imgData->colorMode) { + case splashModeMono1: + case splashModeMono8: + for (x = 0, q = colorLine; x < imgData->width; ++x, ++p) { + *q++ = imgData->lookup[*p]; + } + break; + case splashModeRGB8: + case splashModeBGR8: + for (x = 0, q = colorLine; x < imgData->width; ++x, ++p) { + col = &imgData->lookup[3 * *p]; + *q++ = col[0]; + *q++ = col[1]; + *q++ = col[2]; + } + break; + case splashModeXBGR8: + for (x = 0, q = colorLine; x < imgData->width; ++x, ++p) { + col = &imgData->lookup[4 * *p]; + *q++ = col[0]; + *q++ = col[1]; + *q++ = col[2]; + *q++ = col[3]; + } + break; +#if SPLASH_CMYK + case splashModeCMYK8: + for (x = 0, q = colorLine; x < imgData->width; ++x, ++p) { + col = &imgData->lookup[4 * *p]; + *q++ = col[0]; + *q++ = col[1]; + *q++ = col[2]; + *q++ = col[3]; + } + break; + case splashModeDeviceN8: + for (x = 0, q = colorLine; x < imgData->width; ++x, ++p) { + col = &imgData->lookup[(SPOT_NCOMPS+4) * *p]; + for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) + *q++ = col[cp]; + } + break; +#endif + } + } else { + switch (imgData->colorMode) { + case splashModeMono1: + case splashModeMono8: + for (x = 0, q = colorLine; x < imgData->width; ++x, p += nComps) { + imgData->colorMap->getGray(p, &gray); + *q++ = colToByte(gray); + } + break; + case splashModeRGB8: + case splashModeBGR8: + if (imgData->colorMap->useRGBLine()) { + imgData->colorMap->getRGBLine(p, (Guchar *) colorLine, imgData->width); + } else { + for (x = 0, q = colorLine; x < imgData->width; ++x, p += nComps) { + imgData->colorMap->getRGB(p, &rgb); + *q++ = colToByte(rgb.r); + *q++ = colToByte(rgb.g); + *q++ = colToByte(rgb.b); + } + } + break; + case splashModeXBGR8: + if (imgData->colorMap->useRGBLine()) { + imgData->colorMap->getRGBXLine(p, (Guchar *) colorLine, imgData->width); + } else { + for (x = 0, q = colorLine; x < imgData->width; ++x, p += nComps) { + imgData->colorMap->getRGB(p, &rgb); + *q++ = colToByte(rgb.r); + *q++ = colToByte(rgb.g); + *q++ = colToByte(rgb.b); + *q++ = 255; + } + } + break; +#if SPLASH_CMYK + case splashModeCMYK8: + if (imgData->colorMap->useCMYKLine()) { + imgData->colorMap->getCMYKLine(p, (Guchar *) colorLine, imgData->width); + } else { + for (x = 0, q = colorLine; x < imgData->width; ++x, p += nComps) { + imgData->colorMap->getCMYK(p, &cmyk); + *q++ = colToByte(cmyk.c); + *q++ = colToByte(cmyk.m); + *q++ = colToByte(cmyk.y); + *q++ = colToByte(cmyk.k); + } + } + break; + case splashModeDeviceN8: + if (imgData->colorMap->useDeviceNLine()) { + imgData->colorMap->getDeviceNLine(p, (Guchar *) colorLine, imgData->width); + } else { + for (x = 0, q = colorLine; x < imgData->width; ++x, p += nComps) { + imgData->colorMap->getDeviceN(p, &deviceN); + for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) + *q++ = colToByte(deviceN.c[cp]); + } + } + break; +#endif + } + } + + ++imgData->y; + return gTrue; +} + +GBool SplashOutputDev::alphaImageSrc(void *data, SplashColorPtr colorLine, + Guchar *alphaLine) { + SplashOutImageData *imgData = (SplashOutImageData *)data; + Guchar *p, *aq; + SplashColorPtr q, col; + GfxRGB rgb; + GfxGray gray; +#if SPLASH_CMYK + GfxCMYK cmyk; + GfxColor deviceN; +#endif + Guchar alpha; + int nComps, x, i; + + if (imgData->y == imgData->height) { + return gFalse; + } + if (!(p = imgData->imgStr->getLine())) { + return gFalse; + } + + nComps = imgData->colorMap->getNumPixelComps(); + + for (x = 0, q = colorLine, aq = alphaLine; + x < imgData->width; + ++x, p += nComps) { + alpha = 0; + for (i = 0; i < nComps; ++i) { + if (p[i] < imgData->maskColors[2*i] || + p[i] > imgData->maskColors[2*i+1]) { + alpha = 0xff; + break; + } + } + if (imgData->lookup) { + switch (imgData->colorMode) { + case splashModeMono1: + case splashModeMono8: + *q++ = imgData->lookup[*p]; + break; + case splashModeRGB8: + case splashModeBGR8: + col = &imgData->lookup[3 * *p]; + *q++ = col[0]; + *q++ = col[1]; + *q++ = col[2]; + break; + case splashModeXBGR8: + col = &imgData->lookup[4 * *p]; + *q++ = col[0]; + *q++ = col[1]; + *q++ = col[2]; + *q++ = 255; + break; +#if SPLASH_CMYK + case splashModeCMYK8: + col = &imgData->lookup[4 * *p]; + *q++ = col[0]; + *q++ = col[1]; + *q++ = col[2]; + *q++ = col[3]; + break; + case splashModeDeviceN8: + col = &imgData->lookup[(SPOT_NCOMPS+4) * *p]; + for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) + *q++ = col[cp]; + break; +#endif + } + *aq++ = alpha; + } else { + switch (imgData->colorMode) { + case splashModeMono1: + case splashModeMono8: + imgData->colorMap->getGray(p, &gray); + *q++ = colToByte(gray); + break; + case splashModeXBGR8: + case splashModeRGB8: + case splashModeBGR8: + imgData->colorMap->getRGB(p, &rgb); + *q++ = colToByte(rgb.r); + *q++ = colToByte(rgb.g); + *q++ = colToByte(rgb.b); + if (imgData->colorMode == splashModeXBGR8) *q++ = 255; + break; +#if SPLASH_CMYK + case splashModeCMYK8: + imgData->colorMap->getCMYK(p, &cmyk); + *q++ = colToByte(cmyk.c); + *q++ = colToByte(cmyk.m); + *q++ = colToByte(cmyk.y); + *q++ = colToByte(cmyk.k); + break; + case splashModeDeviceN8: + imgData->colorMap->getDeviceN(p, &deviceN); + for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) + *q++ = colToByte(deviceN.c[cp]); + break; +#endif + } + *aq++ = alpha; + } + } + + ++imgData->y; + return gTrue; +} + +struct TilingSplashOutBitmap { + SplashBitmap *bitmap; + SplashPattern *pattern; + SplashColorMode colorMode; + int paintType; + int repeatX; + int repeatY; + int y; +}; + +GBool SplashOutputDev::tilingBitmapSrc(void *data, SplashColorPtr colorLine, + Guchar *alphaLine) { + TilingSplashOutBitmap *imgData = (TilingSplashOutBitmap *)data; + + if (imgData->y == imgData->bitmap->getHeight()) { + imgData->repeatY--; + if (imgData->repeatY == 0) + return gFalse; + imgData->y = 0; + } + + if (imgData->paintType == 1) { + const SplashColorMode cMode = imgData->bitmap->getMode(); + SplashColorPtr q = colorLine; + // For splashModeBGR8 and splashModeXBGR8 we need to use getPixel + // for the others we can use raw access + if (cMode == splashModeBGR8 || cMode == splashModeXBGR8) { + for (int m = 0; m < imgData->repeatX; m++) { + for (int x = 0; x < imgData->bitmap->getWidth(); x++) { + imgData->bitmap->getPixel(x, imgData->y, q); + q += splashColorModeNComps[cMode]; + } + } + } else { + const int n = imgData->bitmap->getRowSize(); + SplashColorPtr p; + for (int m = 0; m < imgData->repeatX; m++) { + p = imgData->bitmap->getDataPtr() + imgData->y * imgData->bitmap->getRowSize(); + for (int x = 0; x < n; ++x) { + *q++ = *p++; + } + } + } + if (alphaLine != NULL) { + SplashColorPtr aq = alphaLine; + SplashColorPtr p; + const int n = imgData->bitmap->getWidth() - 1; + for (int m = 0; m < imgData->repeatX; m++) { + p = imgData->bitmap->getAlphaPtr() + imgData->y * imgData->bitmap->getWidth(); + for (int x = 0; x < n; ++x) { + *aq++ = *p++; + } + // This is a hack, because of how Splash antialias works if we overwrite the + // last alpha pixel of the tile most/all of the files look much better + *aq++ = (n == 0) ? *p : *(p - 1); + } + } + } else { + SplashColor col, pat; + SplashColorPtr dest = colorLine; + for (int m = 0; m < imgData->repeatX; m++) { + for (int x = 0; x < imgData->bitmap->getWidth(); x++) { + imgData->bitmap->getPixel(x, imgData->y, col); + imgData->pattern->getColor(x, imgData->y, pat); + for (int i = 0; i < splashColorModeNComps[imgData->colorMode]; ++i) { +#if SPLASH_CMYK + if (imgData->colorMode == splashModeCMYK8 || imgData->colorMode == splashModeDeviceN8) + dest[i] = div255(pat[i] * (255 - col[0])); + else +#endif + dest[i] = 255 - div255((255 - pat[i]) * (255 - col[0])); + } + dest += splashColorModeNComps[imgData->colorMode]; + } + } + if (alphaLine != NULL) { + const int y = (imgData->y == imgData->bitmap->getHeight() - 1 && imgData->y > 50) ? imgData->y - 1 : imgData->y; + SplashColorPtr aq = alphaLine; + SplashColorPtr p; + const int n = imgData->bitmap->getWidth(); + for (int m = 0; m < imgData->repeatX; m++) { + p = imgData->bitmap->getAlphaPtr() + y * imgData->bitmap->getWidth(); + for (int x = 0; x < n; ++x) { + *aq++ = *p++; + } + } + } + } + ++imgData->y; + return gTrue; +} + +void SplashOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, + int width, int height, + GfxImageColorMap *colorMap, + GBool interpolate, + int *maskColors, GBool inlineImg) { + double *ctm; + SplashCoord mat[6]; + SplashOutImageData imgData; + SplashColorMode srcMode; + SplashImageSource src; + GfxGray gray; + GfxRGB rgb; +#if SPLASH_CMYK + GfxCMYK cmyk; + GBool grayIndexed = gFalse; + GfxColor deviceN; +#endif + Guchar pix; + int n, i; + + ctm = state->getCTM(); + for (i = 0; i < 6; ++i) { + if (!isfinite(ctm[i])) return; + } + mat[0] = ctm[0]; + mat[1] = ctm[1]; + mat[2] = -ctm[2]; + mat[3] = -ctm[3]; + mat[4] = ctm[2] + ctm[4]; + mat[5] = ctm[3] + ctm[5]; + + imgData.imgStr = new ImageStream(str, width, + colorMap->getNumPixelComps(), + colorMap->getBits()); + imgData.imgStr->reset(); + imgData.colorMap = colorMap; + imgData.maskColors = maskColors; + imgData.colorMode = colorMode; + imgData.width = width; + imgData.height = height; + imgData.y = 0; + + // special case for one-channel (monochrome/gray/separation) images: + // build a lookup table here + imgData.lookup = NULL; + if (colorMap->getNumPixelComps() == 1) { + n = 1 << colorMap->getBits(); + switch (colorMode) { + case splashModeMono1: + case splashModeMono8: + imgData.lookup = (SplashColorPtr)gmalloc(n); + for (i = 0; i < n; ++i) { + pix = (Guchar)i; + colorMap->getGray(&pix, &gray); + imgData.lookup[i] = colToByte(gray); + } + break; + case splashModeRGB8: + case splashModeBGR8: + imgData.lookup = (SplashColorPtr)gmallocn(n, 3); + for (i = 0; i < n; ++i) { + pix = (Guchar)i; + colorMap->getRGB(&pix, &rgb); + imgData.lookup[3*i] = colToByte(rgb.r); + imgData.lookup[3*i+1] = colToByte(rgb.g); + imgData.lookup[3*i+2] = colToByte(rgb.b); + } + break; + case splashModeXBGR8: + imgData.lookup = (SplashColorPtr)gmallocn(n, 4); + for (i = 0; i < n; ++i) { + pix = (Guchar)i; + colorMap->getRGB(&pix, &rgb); + imgData.lookup[4*i] = colToByte(rgb.r); + imgData.lookup[4*i+1] = colToByte(rgb.g); + imgData.lookup[4*i+2] = colToByte(rgb.b); + imgData.lookup[4*i+3] = 255; + } + break; +#if SPLASH_CMYK + case splashModeCMYK8: + grayIndexed = colorMap->getColorSpace()->getMode() != csDeviceGray; + imgData.lookup = (SplashColorPtr)gmallocn(n, 4); + for (i = 0; i < n; ++i) { + pix = (Guchar)i; + colorMap->getCMYK(&pix, &cmyk); + if (cmyk.c != 0 || cmyk.m != 0 || cmyk.y != 0) { + grayIndexed = gFalse; + } + imgData.lookup[4*i] = colToByte(cmyk.c); + imgData.lookup[4*i+1] = colToByte(cmyk.m); + imgData.lookup[4*i+2] = colToByte(cmyk.y); + imgData.lookup[4*i+3] = colToByte(cmyk.k); + } + break; + case splashModeDeviceN8: + colorMap->getColorSpace()->createMapping(bitmap->getSeparationList(), SPOT_NCOMPS); + grayIndexed = colorMap->getColorSpace()->getMode() != csDeviceGray; + imgData.lookup = (SplashColorPtr)gmallocn(n, SPOT_NCOMPS+4); + for (i = 0; i < n; ++i) { + pix = (Guchar)i; + colorMap->getCMYK(&pix, &cmyk); + if (cmyk.c != 0 || cmyk.m != 0 || cmyk.y != 0) { + grayIndexed = gFalse; + } + colorMap->getDeviceN(&pix, &deviceN); + for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) + imgData.lookup[(SPOT_NCOMPS+4)*i +cp] = colToByte(deviceN.c[cp]); + } + break; +#endif + } + } + +#if SPLASH_CMYK + setOverprintMask(colorMap->getColorSpace(), state->getFillOverprint(), + state->getOverprintMode(), NULL, grayIndexed); +#else + setOverprintMask(colorMap->getColorSpace(), state->getFillOverprint(), + state->getOverprintMode(), NULL); +#endif + + if (colorMode == splashModeMono1) { + srcMode = splashModeMono8; + } else { + srcMode = colorMode; + } + src = maskColors ? &alphaImageSrc : &imageSrc; + splash->drawImage(src, &imgData, srcMode, maskColors ? gTrue : gFalse, + width, height, mat, interpolate); + if (inlineImg) { + while (imgData.y < height) { + imgData.imgStr->getLine(); + ++imgData.y; + } + } + + gfree(imgData.lookup); + delete imgData.imgStr; + str->close(); +} + +struct SplashOutMaskedImageData { + ImageStream *imgStr; + GfxImageColorMap *colorMap; + SplashBitmap *mask; + SplashColorPtr lookup; + SplashColorMode colorMode; + int width, height, y; +}; + +GBool SplashOutputDev::maskedImageSrc(void *data, SplashColorPtr colorLine, + Guchar *alphaLine) { + SplashOutMaskedImageData *imgData = (SplashOutMaskedImageData *)data; + Guchar *p, *aq; + SplashColorPtr q, col; + GfxRGB rgb; + GfxGray gray; +#if SPLASH_CMYK + GfxCMYK cmyk; + GfxColor deviceN; +#endif + Guchar alpha; + Guchar *maskPtr; + int maskBit; + int nComps, x; + + if (imgData->y == imgData->height) { + return gFalse; + } + if (!(p = imgData->imgStr->getLine())) { + return gFalse; + } + + nComps = imgData->colorMap->getNumPixelComps(); + + maskPtr = imgData->mask->getDataPtr() + + imgData->y * imgData->mask->getRowSize(); + maskBit = 0x80; + for (x = 0, q = colorLine, aq = alphaLine; + x < imgData->width; + ++x, p += nComps) { + alpha = (*maskPtr & maskBit) ? 0xff : 0x00; + if (!(maskBit >>= 1)) { + ++maskPtr; + maskBit = 0x80; + } + if (imgData->lookup) { + switch (imgData->colorMode) { + case splashModeMono1: + case splashModeMono8: + *q++ = imgData->lookup[*p]; + break; + case splashModeRGB8: + case splashModeBGR8: + col = &imgData->lookup[3 * *p]; + *q++ = col[0]; + *q++ = col[1]; + *q++ = col[2]; + break; + case splashModeXBGR8: + col = &imgData->lookup[4 * *p]; + *q++ = col[0]; + *q++ = col[1]; + *q++ = col[2]; + *q++ = 255; + break; +#if SPLASH_CMYK + case splashModeCMYK8: + col = &imgData->lookup[4 * *p]; + *q++ = col[0]; + *q++ = col[1]; + *q++ = col[2]; + *q++ = col[3]; + break; + case splashModeDeviceN8: + col = &imgData->lookup[(SPOT_NCOMPS+4) * *p]; + for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) + *q++ = col[cp]; + break; +#endif + } + *aq++ = alpha; + } else { + switch (imgData->colorMode) { + case splashModeMono1: + case splashModeMono8: + imgData->colorMap->getGray(p, &gray); + *q++ = colToByte(gray); + break; + case splashModeXBGR8: + case splashModeRGB8: + case splashModeBGR8: + imgData->colorMap->getRGB(p, &rgb); + *q++ = colToByte(rgb.r); + *q++ = colToByte(rgb.g); + *q++ = colToByte(rgb.b); + if (imgData->colorMode == splashModeXBGR8) *q++ = 255; + break; +#if SPLASH_CMYK + case splashModeCMYK8: + imgData->colorMap->getCMYK(p, &cmyk); + *q++ = colToByte(cmyk.c); + *q++ = colToByte(cmyk.m); + *q++ = colToByte(cmyk.y); + *q++ = colToByte(cmyk.k); + break; + case splashModeDeviceN8: + imgData->colorMap->getDeviceN(p, &deviceN); + for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) + *q++ = colToByte(deviceN.c[cp]); + break; +#endif + } + *aq++ = alpha; + } + } + + ++imgData->y; + return gTrue; +} + +void SplashOutputDev::drawMaskedImage(GfxState *state, Object *ref, + Stream *str, int width, int height, + GfxImageColorMap *colorMap, + GBool interpolate, + Stream *maskStr, int maskWidth, + int maskHeight, GBool maskInvert, + GBool maskInterpolate) { + GfxImageColorMap *maskColorMap; + Object maskDecode, decodeLow, decodeHigh; + double *ctm; + SplashCoord mat[6]; + SplashOutMaskedImageData imgData; + SplashOutImageMaskData imgMaskData; + SplashColorMode srcMode; + SplashBitmap *maskBitmap; + Splash *maskSplash; + SplashColor maskColor; + GfxGray gray; + GfxRGB rgb; +#if SPLASH_CMYK + GfxCMYK cmyk; + GfxColor deviceN; +#endif + Guchar pix; + int n, i; + +#if SPLASH_CMYK + colorMap->getColorSpace()->createMapping(bitmap->getSeparationList(), SPOT_NCOMPS); +#endif + setOverprintMask(colorMap->getColorSpace(), state->getFillOverprint(), + state->getOverprintMode(), NULL); + + // If the mask is higher resolution than the image, use + // drawSoftMaskedImage() instead. + if (maskWidth > width || maskHeight > height) { + decodeLow.initInt(maskInvert ? 0 : 1); + decodeHigh.initInt(maskInvert ? 1 : 0); + maskDecode.initArray((xref) ? xref : doc->getXRef()); + maskDecode.arrayAdd(&decodeLow); + maskDecode.arrayAdd(&decodeHigh); + maskColorMap = new GfxImageColorMap(1, &maskDecode, + new GfxDeviceGrayColorSpace()); + maskDecode.free(); + drawSoftMaskedImage(state, ref, str, width, height, colorMap, interpolate, + maskStr, maskWidth, maskHeight, maskColorMap, maskInterpolate); + delete maskColorMap; + + } else { + //----- scale the mask image to the same size as the source image + + mat[0] = (SplashCoord)width; + mat[1] = 0; + mat[2] = 0; + mat[3] = (SplashCoord)height; + mat[4] = 0; + mat[5] = 0; + imgMaskData.imgStr = new ImageStream(maskStr, maskWidth, 1, 1); + imgMaskData.imgStr->reset(); + imgMaskData.invert = maskInvert ? 0 : 1; + imgMaskData.width = maskWidth; + imgMaskData.height = maskHeight; + imgMaskData.y = 0; + maskBitmap = new SplashBitmap(width, height, 1, splashModeMono1, gFalse); + maskSplash = new Splash(maskBitmap, gFalse); + maskColor[0] = 0; + maskSplash->clear(maskColor); + maskColor[0] = 0xff; + maskSplash->setFillPattern(new SplashSolidColor(maskColor)); + maskSplash->fillImageMask(&imageMaskSrc, &imgMaskData, + maskWidth, maskHeight, mat, gFalse); + delete imgMaskData.imgStr; + maskStr->close(); + delete maskSplash; + + //----- draw the source image + + ctm = state->getCTM(); + for (i = 0; i < 6; ++i) { + if (!isfinite(ctm[i])) { + delete maskBitmap; + return; + } + } + mat[0] = ctm[0]; + mat[1] = ctm[1]; + mat[2] = -ctm[2]; + mat[3] = -ctm[3]; + mat[4] = ctm[2] + ctm[4]; + mat[5] = ctm[3] + ctm[5]; + + imgData.imgStr = new ImageStream(str, width, + colorMap->getNumPixelComps(), + colorMap->getBits()); + imgData.imgStr->reset(); + imgData.colorMap = colorMap; + imgData.mask = maskBitmap; + imgData.colorMode = colorMode; + imgData.width = width; + imgData.height = height; + imgData.y = 0; + + // special case for one-channel (monochrome/gray/separation) images: + // build a lookup table here + imgData.lookup = NULL; + if (colorMap->getNumPixelComps() == 1) { + n = 1 << colorMap->getBits(); + switch (colorMode) { + case splashModeMono1: + case splashModeMono8: + imgData.lookup = (SplashColorPtr)gmalloc(n); + for (i = 0; i < n; ++i) { + pix = (Guchar)i; + colorMap->getGray(&pix, &gray); + imgData.lookup[i] = colToByte(gray); + } + break; + case splashModeRGB8: + case splashModeBGR8: + imgData.lookup = (SplashColorPtr)gmallocn(n, 3); + for (i = 0; i < n; ++i) { + pix = (Guchar)i; + colorMap->getRGB(&pix, &rgb); + imgData.lookup[3*i] = colToByte(rgb.r); + imgData.lookup[3*i+1] = colToByte(rgb.g); + imgData.lookup[3*i+2] = colToByte(rgb.b); + } + break; + case splashModeXBGR8: + imgData.lookup = (SplashColorPtr)gmallocn(n, 4); + for (i = 0; i < n; ++i) { + pix = (Guchar)i; + colorMap->getRGB(&pix, &rgb); + imgData.lookup[4*i] = colToByte(rgb.r); + imgData.lookup[4*i+1] = colToByte(rgb.g); + imgData.lookup[4*i+2] = colToByte(rgb.b); + imgData.lookup[4*i+3] = 255; + } + break; +#if SPLASH_CMYK + case splashModeCMYK8: + imgData.lookup = (SplashColorPtr)gmallocn(n, 4); + for (i = 0; i < n; ++i) { + pix = (Guchar)i; + colorMap->getCMYK(&pix, &cmyk); + imgData.lookup[4*i] = colToByte(cmyk.c); + imgData.lookup[4*i+1] = colToByte(cmyk.m); + imgData.lookup[4*i+2] = colToByte(cmyk.y); + imgData.lookup[4*i+3] = colToByte(cmyk.k); + } + break; + case splashModeDeviceN8: + imgData.lookup = (SplashColorPtr)gmallocn(n, SPOT_NCOMPS+4); + for (i = 0; i < n; ++i) { + pix = (Guchar)i; + colorMap->getDeviceN(&pix, &deviceN); + for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) + imgData.lookup[(SPOT_NCOMPS+4)*i + cp] = colToByte(deviceN.c[cp]); + } + break; +#endif + } + } + + if (colorMode == splashModeMono1) { + srcMode = splashModeMono8; + } else { + srcMode = colorMode; + } + splash->drawImage(&maskedImageSrc, &imgData, srcMode, gTrue, + width, height, mat, interpolate); + delete maskBitmap; + gfree(imgData.lookup); + delete imgData.imgStr; + str->close(); + } +} + +void SplashOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, + Stream *str, int width, int height, + GfxImageColorMap *colorMap, + GBool interpolate, + Stream *maskStr, + int maskWidth, int maskHeight, + GfxImageColorMap *maskColorMap, + GBool maskInterpolate) { + double *ctm; + SplashCoord mat[6]; + SplashOutImageData imgData; + SplashOutImageData imgMaskData; + SplashColorMode srcMode; + SplashBitmap *maskBitmap; + Splash *maskSplash; + SplashColor maskColor; + GfxGray gray; + GfxRGB rgb; +#if SPLASH_CMYK + GfxCMYK cmyk; + GfxColor deviceN; +#endif + Guchar pix; + int n, i; + +#if SPLASH_CMYK + colorMap->getColorSpace()->createMapping(bitmap->getSeparationList(), SPOT_NCOMPS); +#endif + setOverprintMask(colorMap->getColorSpace(), state->getFillOverprint(), + state->getOverprintMode(), NULL); + + ctm = state->getCTM(); + for (i = 0; i < 6; ++i) { + if (!isfinite(ctm[i])) return; + } + mat[0] = ctm[0]; + mat[1] = ctm[1]; + mat[2] = -ctm[2]; + mat[3] = -ctm[3]; + mat[4] = ctm[2] + ctm[4]; + mat[5] = ctm[3] + ctm[5]; + + //----- set up the soft mask + + imgMaskData.imgStr = new ImageStream(maskStr, maskWidth, + maskColorMap->getNumPixelComps(), + maskColorMap->getBits()); + imgMaskData.imgStr->reset(); + imgMaskData.colorMap = maskColorMap; + imgMaskData.maskColors = NULL; + imgMaskData.colorMode = splashModeMono8; + imgMaskData.width = maskWidth; + imgMaskData.height = maskHeight; + imgMaskData.y = 0; + n = 1 << maskColorMap->getBits(); + imgMaskData.lookup = (SplashColorPtr)gmalloc(n); + for (i = 0; i < n; ++i) { + pix = (Guchar)i; + maskColorMap->getGray(&pix, &gray); + imgMaskData.lookup[i] = colToByte(gray); + } + maskBitmap = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(), + 1, splashModeMono8, gFalse); + maskSplash = new Splash(maskBitmap, vectorAntialias); + maskColor[0] = 0; + maskSplash->clear(maskColor); + maskSplash->drawImage(&imageSrc, &imgMaskData, splashModeMono8, gFalse, + maskWidth, maskHeight, mat, maskInterpolate); + delete imgMaskData.imgStr; + maskStr->close(); + gfree(imgMaskData.lookup); + delete maskSplash; + splash->setSoftMask(maskBitmap); + + //----- draw the source image + + imgData.imgStr = new ImageStream(str, width, + colorMap->getNumPixelComps(), + colorMap->getBits()); + imgData.imgStr->reset(); + imgData.colorMap = colorMap; + imgData.maskColors = NULL; + imgData.colorMode = colorMode; + imgData.width = width; + imgData.height = height; + imgData.y = 0; + + // special case for one-channel (monochrome/gray/separation) images: + // build a lookup table here + imgData.lookup = NULL; + if (colorMap->getNumPixelComps() == 1) { + n = 1 << colorMap->getBits(); + switch (colorMode) { + case splashModeMono1: + case splashModeMono8: + imgData.lookup = (SplashColorPtr)gmalloc(n); + for (i = 0; i < n; ++i) { + pix = (Guchar)i; + colorMap->getGray(&pix, &gray); + imgData.lookup[i] = colToByte(gray); + } + break; + case splashModeRGB8: + case splashModeBGR8: + imgData.lookup = (SplashColorPtr)gmallocn(n, 3); + for (i = 0; i < n; ++i) { + pix = (Guchar)i; + colorMap->getRGB(&pix, &rgb); + imgData.lookup[3*i] = colToByte(rgb.r); + imgData.lookup[3*i+1] = colToByte(rgb.g); + imgData.lookup[3*i+2] = colToByte(rgb.b); + } + break; + case splashModeXBGR8: + imgData.lookup = (SplashColorPtr)gmallocn(n, 4); + for (i = 0; i < n; ++i) { + pix = (Guchar)i; + colorMap->getRGB(&pix, &rgb); + imgData.lookup[4*i] = colToByte(rgb.r); + imgData.lookup[4*i+1] = colToByte(rgb.g); + imgData.lookup[4*i+2] = colToByte(rgb.b); + imgData.lookup[4*i+3] = 255; + } + break; +#if SPLASH_CMYK + case splashModeCMYK8: + imgData.lookup = (SplashColorPtr)gmallocn(n, 4); + for (i = 0; i < n; ++i) { + pix = (Guchar)i; + colorMap->getCMYK(&pix, &cmyk); + imgData.lookup[4*i] = colToByte(cmyk.c); + imgData.lookup[4*i+1] = colToByte(cmyk.m); + imgData.lookup[4*i+2] = colToByte(cmyk.y); + imgData.lookup[4*i+3] = colToByte(cmyk.k); + } + break; + case splashModeDeviceN8: + imgData.lookup = (SplashColorPtr)gmallocn(n, SPOT_NCOMPS+4); + for (i = 0; i < n; ++i) { + pix = (Guchar)i; + colorMap->getDeviceN(&pix, &deviceN); + for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) + imgData.lookup[(SPOT_NCOMPS+4)*i + cp] = colToByte(deviceN.c[cp]); + } + break; +#endif + } + } + + if (colorMode == splashModeMono1) { + srcMode = splashModeMono8; + } else { + srcMode = colorMode; + } + splash->drawImage(&imageSrc, &imgData, srcMode, gFalse, width, height, mat, interpolate); + splash->setSoftMask(NULL); + gfree(imgData.lookup); + delete imgData.imgStr; + str->close(); +} + +GBool SplashOutputDev::checkTransparencyGroup(GfxState *state, GBool knockout) { + if (state->getFillOpacity() != 1 || + state->getStrokeOpacity() != 1 || + state->getAlphaIsShape() || + state->getBlendMode() != gfxBlendNormal || + splash->getSoftMask() != NULL || + knockout) + return gTrue; + return transpGroupStack != NULL && transpGroupStack->shape != NULL; +} + +void SplashOutputDev::beginTransparencyGroup(GfxState *state, double *bbox, + GfxColorSpace *blendingColorSpace, + GBool isolated, GBool knockout, + GBool forSoftMask) { + SplashTransparencyGroup *transpGroup; + SplashColor color; + double xMin, yMin, xMax, yMax, x, y; + int tx, ty, w, h, i; + + // transform the bbox + state->transform(bbox[0], bbox[1], &x, &y); + xMin = xMax = x; + yMin = yMax = y; + state->transform(bbox[0], bbox[3], &x, &y); + if (x < xMin) { + xMin = x; + } else if (x > xMax) { + xMax = x; + } + if (y < yMin) { + yMin = y; + } else if (y > yMax) { + yMax = y; + } + state->transform(bbox[2], bbox[1], &x, &y); + if (x < xMin) { + xMin = x; + } else if (x > xMax) { + xMax = x; + } + if (y < yMin) { + yMin = y; + } else if (y > yMax) { + yMax = y; + } + state->transform(bbox[2], bbox[3], &x, &y); + if (x < xMin) { + xMin = x; + } else if (x > xMax) { + xMax = x; + } + if (y < yMin) { + yMin = y; + } else if (y > yMax) { + yMax = y; + } + tx = (int)floor(xMin); + if (tx < 0) { + tx = 0; + } else if (tx >= bitmap->getWidth()) { + tx = bitmap->getWidth() - 1; + } + ty = (int)floor(yMin); + if (ty < 0) { + ty = 0; + } else if (ty >= bitmap->getHeight()) { + ty = bitmap->getHeight() - 1; + } + w = (int)ceil(xMax) - tx + 1; + if (tx + w > bitmap->getWidth()) { + w = bitmap->getWidth() - tx; + } + if (w < 1) { + w = 1; + } + h = (int)ceil(yMax) - ty + 1; + if (ty + h > bitmap->getHeight()) { + h = bitmap->getHeight() - ty; + } + if (h < 1) { + h = 1; + } + + // push a new stack entry + transpGroup = new SplashTransparencyGroup(); + transpGroup->tx = tx; + transpGroup->ty = ty; + transpGroup->blendingColorSpace = blendingColorSpace; + transpGroup->isolated = isolated; + transpGroup->shape = (knockout && !isolated) ? SplashBitmap::copy(bitmap) : NULL; + transpGroup->knockout = (knockout && isolated); + transpGroup->knockoutOpacity = 1.0; + transpGroup->next = transpGroupStack; + transpGroupStack = transpGroup; + + // save state + transpGroup->origBitmap = bitmap; + transpGroup->origSplash = splash; + transpGroup->fontAA = fontEngine->getAA(); + + //~ this handles the blendingColorSpace arg for soft masks, but + //~ not yet for transparency groups + + // switch to the blending color space + if (forSoftMask && isolated && blendingColorSpace) { + if (blendingColorSpace->getMode() == csDeviceGray || + blendingColorSpace->getMode() == csCalGray || + (blendingColorSpace->getMode() == csICCBased && + blendingColorSpace->getNComps() == 1)) { + colorMode = splashModeMono8; + } else if (blendingColorSpace->getMode() == csDeviceRGB || + blendingColorSpace->getMode() == csCalRGB || + (blendingColorSpace->getMode() == csICCBased && + blendingColorSpace->getNComps() == 3)) { + //~ does this need to use BGR8? + colorMode = splashModeRGB8; +#if SPLASH_CMYK + } else if (blendingColorSpace->getMode() == csDeviceCMYK || + (blendingColorSpace->getMode() == csICCBased && + blendingColorSpace->getNComps() == 4)) { + colorMode = splashModeCMYK8; +#endif + } + } + + // create the temporary bitmap + bitmap = new SplashBitmap(w, h, bitmapRowPad, colorMode, gTrue, + bitmapTopDown, bitmap->getSeparationList()); + splash = new Splash(bitmap, vectorAntialias, + transpGroup->origSplash->getScreen()); + if (transpGroup->next != NULL && transpGroup->next->knockout) { + fontEngine->setAA(gFalse); + } + splash->setThinLineMode(transpGroup->origSplash->getThinLineMode()); + splash->setMinLineWidth(globalParams->getMinLineWidth()); + //~ Acrobat apparently copies at least the fill and stroke colors, and + //~ maybe other state(?) -- but not the clipping path (and not sure + //~ what else) + //~ [this is likely the same situation as in type3D1()] + splash->setFillPattern(transpGroup->origSplash->getFillPattern()->copy()); + splash->setStrokePattern( + transpGroup->origSplash->getStrokePattern()->copy()); + if (isolated) { + for (i = 0; i < splashMaxColorComps; ++i) { + color[i] = 0; + } + if (colorMode == splashModeXBGR8) color[3] = 255; + splash->clear(color, 0); + } else { + SplashBitmap *shape = (knockout) ? transpGroup->shape : + (transpGroup->next != NULL && transpGroup->next->shape != NULL) ? transpGroup->next->shape : transpGroup->origBitmap; + int shapeTx = (knockout) ? tx : + (transpGroup->next != NULL && transpGroup->next->shape != NULL) ? transpGroup->next->tx + tx : tx; + int shapeTy = (knockout) ? ty : + (transpGroup->next != NULL && transpGroup->next->shape != NULL) ? transpGroup->next->ty + ty : ty; + splash->blitTransparent(transpGroup->origBitmap, tx, ty, 0, 0, w, h); + splash->setInNonIsolatedGroup(shape, shapeTx, shapeTy); + } + transpGroup->tBitmap = bitmap; + state->shiftCTMAndClip(-tx, -ty); + updateCTM(state, 0, 0, 0, 0, 0, 0); + ++nestCount; +} + +void SplashOutputDev::endTransparencyGroup(GfxState *state) { + // restore state + --nestCount; + delete splash; + bitmap = transpGroupStack->origBitmap; + colorMode = bitmap->getMode(); + splash = transpGroupStack->origSplash; + state->shiftCTMAndClip(transpGroupStack->tx, transpGroupStack->ty); + updateCTM(state, 0, 0, 0, 0, 0, 0); +} + +void SplashOutputDev::paintTransparencyGroup(GfxState *state, double *bbox) { + SplashBitmap *tBitmap; + SplashTransparencyGroup *transpGroup; + GBool isolated; + int tx, ty; + + tx = transpGroupStack->tx; + ty = transpGroupStack->ty; + tBitmap = transpGroupStack->tBitmap; + isolated = transpGroupStack->isolated; + + // paint the transparency group onto the parent bitmap + // - the clip path was set in the parent's state) + if (tx < bitmap->getWidth() && ty < bitmap->getHeight()) { + SplashCoord knockoutOpacity = (transpGroupStack->next != NULL) ? transpGroupStack->next->knockoutOpacity + : transpGroupStack->knockoutOpacity; + splash->setOverprintMask(0xffffffff, gFalse); + splash->composite(tBitmap, 0, 0, tx, ty, + tBitmap->getWidth(), tBitmap->getHeight(), + gFalse, !isolated, transpGroupStack->next != NULL && transpGroupStack->next->knockout, knockoutOpacity); + fontEngine->setAA(transpGroupStack->fontAA); + if (transpGroupStack->next != NULL && transpGroupStack->next->shape != NULL) { + transpGroupStack->next->knockout = gTrue; + } + } + + // pop the stack + transpGroup = transpGroupStack; + transpGroupStack = transpGroup->next; + if (transpGroupStack != NULL && transpGroup->knockoutOpacity < transpGroupStack->knockoutOpacity) { + transpGroupStack->knockoutOpacity = transpGroup->knockoutOpacity; + } + delete transpGroup->shape; + delete transpGroup; + + delete tBitmap; +} + +void SplashOutputDev::setSoftMask(GfxState *state, double *bbox, + GBool alpha, Function *transferFunc, + GfxColor *backdropColor) { + SplashBitmap *softMask, *tBitmap; + Splash *tSplash; + SplashTransparencyGroup *transpGroup; + SplashColor color; + SplashColorPtr p; + GfxGray gray; + GfxRGB rgb; +#if SPLASH_CMYK + GfxCMYK cmyk; + GfxColor deviceN; +#endif + double lum, lum2; + int tx, ty, x, y; + + tx = transpGroupStack->tx; + ty = transpGroupStack->ty; + tBitmap = transpGroupStack->tBitmap; + + // composite with backdrop color + if (!alpha && tBitmap->getMode() != splashModeMono1) { + //~ need to correctly handle the case where no blending color + //~ space is given + if (transpGroupStack->blendingColorSpace) { + tSplash = new Splash(tBitmap, vectorAntialias, + transpGroupStack->origSplash->getScreen()); + switch (tBitmap->getMode()) { + case splashModeMono1: + // transparency is not supported in mono1 mode + break; + case splashModeMono8: + transpGroupStack->blendingColorSpace->getGray(backdropColor, &gray); + color[0] = colToByte(gray); + tSplash->compositeBackground(color); + break; + case splashModeXBGR8: + color[3] = 255; + case splashModeRGB8: + case splashModeBGR8: + transpGroupStack->blendingColorSpace->getRGB(backdropColor, &rgb); + color[0] = colToByte(rgb.r); + color[1] = colToByte(rgb.g); + color[2] = colToByte(rgb.b); + tSplash->compositeBackground(color); + break; +#if SPLASH_CMYK + case splashModeCMYK8: + transpGroupStack->blendingColorSpace->getCMYK(backdropColor, &cmyk); + color[0] = colToByte(cmyk.c); + color[1] = colToByte(cmyk.m); + color[2] = colToByte(cmyk.y); + color[3] = colToByte(cmyk.k); + tSplash->compositeBackground(color); + break; + case splashModeDeviceN8: + transpGroupStack->blendingColorSpace->getDeviceN(backdropColor, &deviceN); + for (int cp=0; cp < SPOT_NCOMPS+4; cp++) + color[cp] = colToByte(deviceN.c[cp]); + tSplash->compositeBackground(color); + break; +#endif + } + delete tSplash; + } + } + + softMask = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(), + 1, splashModeMono8, gFalse); + unsigned char fill = 0; + if (transpGroupStack->blendingColorSpace) { + transpGroupStack->blendingColorSpace->getGray(backdropColor, &gray); + fill = colToByte(gray); + } + memset(softMask->getDataPtr(), fill, + softMask->getRowSize() * softMask->getHeight()); + p = softMask->getDataPtr() + ty * softMask->getRowSize() + tx; + int xMax = tBitmap->getWidth(); + int yMax = tBitmap->getHeight(); + if (xMax > bitmap->getWidth() - tx) xMax = bitmap->getWidth() - tx; + if (yMax > bitmap->getHeight() - ty) yMax = bitmap->getHeight() - ty; + for (y = 0; y < yMax; ++y) { + for (x = 0; x < xMax; ++x) { + if (alpha) { + if (transferFunc) { + lum = tBitmap->getAlpha(x, y) / 255.0; + transferFunc->transform(&lum, &lum2); + p[x] = (int)(lum2 * 255.0 + 0.5); + } else + p[x] = tBitmap->getAlpha(x, y); + } else { + tBitmap->getPixel(x, y, color); + // convert to luminosity + switch (tBitmap->getMode()) { + case splashModeMono1: + case splashModeMono8: + lum = color[0] / 255.0; + break; + case splashModeXBGR8: + case splashModeRGB8: + case splashModeBGR8: + lum = (0.3 / 255.0) * color[0] + + (0.59 / 255.0) * color[1] + + (0.11 / 255.0) * color[2]; + break; +#if SPLASH_CMYK + case splashModeCMYK8: + case splashModeDeviceN8: + lum = (1 - color[3] / 255.0) + - (0.3 / 255.0) * color[0] + - (0.59 / 255.0) * color[1] + - (0.11 / 255.0) * color[2]; + if (lum < 0) { + lum = 0; + } + break; +#endif + } + if (transferFunc) { + transferFunc->transform(&lum, &lum2); + } else { + lum2 = lum; + } + p[x] = (int)(lum2 * 255.0 + 0.5); + } + } + p += softMask->getRowSize(); + } + splash->setSoftMask(softMask); + + // pop the stack + transpGroup = transpGroupStack; + transpGroupStack = transpGroup->next; + delete transpGroup; + + delete tBitmap; +} + +void SplashOutputDev::clearSoftMask(GfxState *state) { + splash->setSoftMask(NULL); +} + +void SplashOutputDev::setPaperColor(SplashColorPtr paperColorA) { + splashColorCopy(paperColor, paperColorA); +} + +int SplashOutputDev::getBitmapWidth() { + return bitmap->getWidth(); +} + +int SplashOutputDev::getBitmapHeight() { + return bitmap->getHeight(); +} + +SplashBitmap *SplashOutputDev::takeBitmap() { + SplashBitmap *ret; + + ret = bitmap; + bitmap = new SplashBitmap(1, 1, bitmapRowPad, colorMode, + colorMode != splashModeMono1, bitmapTopDown); + return ret; +} + +void SplashOutputDev::getModRegion(int *xMin, int *yMin, + int *xMax, int *yMax) { + splash->getModRegion(xMin, yMin, xMax, yMax); +} + +void SplashOutputDev::clearModRegion() { + splash->clearModRegion(); +} + +#if 1 //~tmp: turn off anti-aliasing temporarily +GBool SplashOutputDev::getVectorAntialias() { + return splash->getVectorAntialias(); +} + +void SplashOutputDev::setVectorAntialias(GBool vaa) { + vaa = vaa && colorMode != splashModeMono1; + vectorAntialias = vaa; + splash->setVectorAntialias(vaa); +} +#endif + +void SplashOutputDev::setFreeTypeHinting(GBool enable, GBool enableSlightHintingA) +{ + enableFreeTypeHinting = enable; + enableSlightHinting = enableSlightHintingA; +} + +GBool SplashOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *catalog, Object *str, + double *ptm, int paintType, int /*tilingType*/, Dict *resDict, + double *mat, double *bbox, + int x0, int y0, int x1, int y1, + double xStep, double yStep) +{ + PDFRectangle box; + Gfx *gfx; + Splash *formerSplash = splash; + SplashBitmap *formerBitmap = bitmap; + double width, height; + int surface_width, surface_height, result_width, result_height, i; + int repeatX, repeatY; + SplashCoord matc[6]; + Matrix m1; + double *ctm, savedCTM[6]; + double kx, ky, sx, sy; + GBool retValue = gFalse; + + width = bbox[2] - bbox[0]; + height = bbox[3] - bbox[1]; + + if (xStep != width || yStep != height) + return gFalse; + + // calculate offsets + ctm = state->getCTM(); + for (i = 0; i < 6; ++i) { + savedCTM[i] = ctm[i]; + } + state->concatCTM(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]); + state->concatCTM(1, 0, 0, 1, bbox[0], bbox[1]); + ctm = state->getCTM(); + for (i = 0; i < 6; ++i) { + if (!isfinite(ctm[i])) { + state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]); + return gFalse; + } + } + matc[4] = x0 * xStep * ctm[0] + y0 * yStep * ctm[2] + ctm[4]; + matc[5] = x0 * xStep * ctm[1] + y0 * yStep * ctm[3] + ctm[5]; + if (splashAbs(ctm[1]) > splashAbs(ctm[0])) { + kx = -ctm[1]; + ky = ctm[2] - (ctm[0] * ctm[3]) / ctm[1]; + } else { + kx = ctm[0]; + ky = ctm[3] - (ctm[1] * ctm[2]) / ctm[0]; + } + result_width = (int) ceil(fabs(kx * width * (x1 - x0))); + result_height = (int) ceil(fabs(ky * height * (y1 - y0))); + kx = state->getHDPI() / 72.0; + ky = state->getVDPI() / 72.0; + m1.m[0] = (ptm[0] == 0) ? fabs(ptm[2]) * kx : fabs(ptm[0]) * kx; + m1.m[1] = 0; + m1.m[2] = 0; + m1.m[3] = (ptm[3] == 0) ? fabs(ptm[1]) * ky : fabs(ptm[3]) * ky; + m1.m[4] = 0; + m1.m[5] = 0; + m1.transform(width, height, &kx, &ky); + surface_width = (int) ceil (fabs(kx)); + surface_height = (int) ceil (fabs(ky)); + + sx = (double) result_width / (surface_width * (x1 - x0)); + sy = (double) result_height / (surface_height * (y1 - y0)); + m1.m[0] *= sx; + m1.m[3] *= sy; + m1.transform(width, height, &kx, &ky); + + if(fabs(kx) < 1 && fabs(ky) < 1) { + kx = std::min<double>(kx, ky); + ky = 2 / kx; + m1.m[0] *= ky; + m1.m[3] *= ky; + m1.transform(width, height, &kx, &ky); + surface_width = (int) ceil (fabs(kx)); + surface_height = (int) ceil (fabs(ky)); + repeatX = x1 - x0; + repeatY = y1 - y0; + } else { + if ((unsigned long) result_width * result_height > 0x800000L) { + state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]); + return gFalse; + } + while(fabs(kx) > 16384 || fabs(ky) > 16384) { + // limit pattern bitmap size + m1.m[0] /= 2; + m1.m[3] /= 2; + m1.transform(width, height, &kx, &ky); + } + surface_width = (int) ceil (fabs(kx)); + surface_height = (int) ceil (fabs(ky)); + // adjust repeat values to completely fill region + repeatX = result_width / surface_width; + repeatY = result_height / surface_height; + if (surface_width * repeatX < result_width) + repeatX++; + if (surface_height * repeatY < result_height) + repeatY++; + if (x1 - x0 > repeatX) + repeatX = x1 - x0; + if (y1 - y0 > repeatY) + repeatY = y1 - y0; + } + // restore CTM and calculate rotate and scale with rounded matric + state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]); + state->concatCTM(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]); + state->concatCTM(width * repeatX, 0, 0, height * repeatY, bbox[0], bbox[1]); + ctm = state->getCTM(); + matc[0] = ctm[0]; + matc[1] = ctm[1]; + matc[2] = ctm[2]; + matc[3] = ctm[3]; + + if (surface_width == 0 || surface_height == 0) { + state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]); + return gFalse; + } + m1.transform(bbox[0], bbox[1], &kx, &ky); + m1.m[4] = -kx; + m1.m[5] = -ky; + + bitmap = new SplashBitmap(surface_width, surface_height, 1, + (paintType == 1) ? colorMode : splashModeMono8, gTrue); + splash = new Splash(bitmap, gTrue); + if (paintType == 2) { + SplashColor clearColor; +#if SPLASH_CMYK + clearColor[0] = (colorMode == splashModeCMYK8 || colorMode == splashModeDeviceN8) ? 0x00 : 0xFF; +#else + clearColor[0] = 0xFF; +#endif + splash->clear(clearColor, 0); + } else { + splash->clear(paperColor, 0); + } + splash->setThinLineMode(formerSplash->getThinLineMode()); + splash->setMinLineWidth(globalParams->getMinLineWidth()); + + box.x1 = bbox[0]; box.y1 = bbox[1]; + box.x2 = bbox[2]; box.y2 = bbox[3]; + gfx = new Gfx(doc, this, resDict, &box, NULL, NULL, NULL, gfxA->getXRef()); + // set pattern transformation matrix + gfx->getState()->setCTM(m1.m[0], m1.m[1], m1.m[2], m1.m[3], m1.m[4], m1.m[5]); + updateCTM(gfx->getState(), m1.m[0], m1.m[1], m1.m[2], m1.m[3], m1.m[4], m1.m[5]); + gfx->display(str); + delete splash; + splash = formerSplash; + TilingSplashOutBitmap imgData; + imgData.bitmap = bitmap; + imgData.paintType = paintType; + imgData.pattern = splash->getFillPattern(); + imgData.colorMode = colorMode; + imgData.y = 0; + imgData.repeatX = repeatX; + imgData.repeatY = repeatY; + SplashBitmap *tBitmap = bitmap; + bitmap = formerBitmap; + result_width = tBitmap->getWidth() * imgData.repeatX; + result_height = tBitmap->getHeight() * imgData.repeatY; + + if (splashAbs(matc[1]) > splashAbs(matc[0])) { + kx = -matc[1]; + ky = matc[2] - (matc[0] * matc[3]) / matc[1]; + } else { + kx = matc[0]; + ky = matc[3] - (matc[1] * matc[2]) / matc[0]; + } + kx = result_width / (fabs(kx) + 1); + ky = result_height / (fabs(ky) + 1); + state->concatCTM(kx, 0, 0, ky, 0, 0); + ctm = state->getCTM(); + matc[0] = ctm[0]; + matc[1] = ctm[1]; + matc[2] = ctm[2]; + matc[3] = ctm[3]; + GBool minorAxisZero = matc[1] == 0 && matc[2] == 0; + if (matc[0] > 0 && minorAxisZero && matc[3] > 0) { + // draw the tiles + for (int y = 0; y < imgData.repeatY; ++y) { + for (int x = 0; x < imgData.repeatX; ++x) { + x0 = splashFloor(matc[4]) + x * tBitmap->getWidth(); + y0 = splashFloor(matc[5]) + y * tBitmap->getHeight(); + splash->blitImage(tBitmap, gTrue, x0, y0); + } + } + retValue = gTrue; + } else { + retValue = splash->drawImage(&tilingBitmapSrc, &imgData, colorMode, gTrue, result_width, result_height, matc, gFalse, gTrue) == splashOk; + } + delete tBitmap; + delete gfx; + return retValue; +} + +GBool SplashOutputDev::gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading) +{ + GfxColorSpaceMode shadingMode = shading->getColorSpace()->getMode(); + GBool bDirectColorTranslation = gFalse; // triggers an optimization. + switch (colorMode) { + case splashModeRGB8: + bDirectColorTranslation = (shadingMode == csDeviceRGB); + break; +#if SPLASH_CMYK + case splashModeCMYK8: + case splashModeDeviceN8: + bDirectColorTranslation = (shadingMode == csDeviceCMYK); + break; +#endif + default: + break; + } + SplashGouraudColor *splashShading = new SplashGouraudPattern(bDirectColorTranslation, state, shading, colorMode); + // restore vector antialias because we support it here + if (shading->isParameterized()) { + GBool vaa = getVectorAntialias(); + GBool retVal = gFalse; + setVectorAntialias(gTrue); + retVal = splash->gouraudTriangleShadedFill(splashShading); + setVectorAntialias(vaa); + return retVal; + } + delete splashShading; + return gFalse; +} + +GBool SplashOutputDev::univariateShadedFill(GfxState *state, SplashUnivariatePattern *pattern, double tMin, double tMax) { + double xMin, yMin, xMax, yMax; + SplashPath *path; + GBool vaa = getVectorAntialias(); + // restore vector antialias because we support it here + setVectorAntialias(gTrue); + + GBool retVal = gFalse; + // get the clip region bbox + if (pattern->getShading()->getHasBBox()) { + pattern->getShading()->getBBox(&xMin, &yMin, &xMax, &yMax); + } else { + state->getClipBBox(&xMin, &yMin, &xMax, &yMax); + + xMin = floor (xMin); + yMin = floor (yMin); + xMax = ceil (xMax); + yMax = ceil (yMax); + + { + Matrix ctm, ictm; + double x[4], y[4]; + int i; + + state->getCTM(&ctm); + ctm.invertTo(&ictm); + + ictm.transform(xMin, yMin, &x[0], &y[0]); + ictm.transform(xMax, yMin, &x[1], &y[1]); + ictm.transform(xMin, yMax, &x[2], &y[2]); + ictm.transform(xMax, yMax, &x[3], &y[3]); + + xMin = xMax = x[0]; + yMin = yMax = y[0]; + for (i = 1; i < 4; i++) { + xMin = std::min<double>(xMin, x[i]); + yMin = std::min<double>(yMin, y[i]); + xMax = std::max<double>(xMax, x[i]); + yMax = std::max<double>(yMax, y[i]); + } + } + } + + // fill the region + state->moveTo(xMin, yMin); + state->lineTo(xMax, yMin); + state->lineTo(xMax, yMax); + state->lineTo(xMin, yMax); + state->closePath(); + path = convertPath(state, state->getPath(), gTrue); + +#if SPLASH_CMYK + pattern->getShading()->getColorSpace()->createMapping(bitmap->getSeparationList(), SPOT_NCOMPS); +#endif + setOverprintMask(pattern->getShading()->getColorSpace(), state->getFillOverprint(), + state->getOverprintMode(), NULL); + retVal = (splash->shadedFill(path, pattern->getShading()->getHasBBox(), pattern) == splashOk); + state->clearPath(); + setVectorAntialias(vaa); + delete path; + + return retVal; +} + +GBool SplashOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) { + SplashAxialPattern *pattern = new SplashAxialPattern(colorMode, state, shading); + GBool retVal = univariateShadedFill(state, pattern, tMin, tMax); + + delete pattern; + + return retVal; +} + +GBool SplashOutputDev::radialShadedFill(GfxState *state, GfxRadialShading *shading, double tMin, double tMax) { + SplashRadialPattern *pattern = new SplashRadialPattern(colorMode, state, shading); + GBool retVal = univariateShadedFill(state, pattern, tMin, tMax); + + delete pattern; + + return retVal; +} diff --git a/source/libs/poppler/poppler-0.32.0/poppler/SplashOutputDev.h b/source/libs/poppler/poppler-0.33.0/poppler/SplashOutputDev.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/SplashOutputDev.h rename to source/libs/poppler/poppler-0.33.0/poppler/SplashOutputDev.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/StdinCachedFile.cc b/source/libs/poppler/poppler-0.33.0/poppler/StdinCachedFile.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/StdinCachedFile.cc rename to source/libs/poppler/poppler-0.33.0/poppler/StdinCachedFile.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/StdinCachedFile.h b/source/libs/poppler/poppler-0.33.0/poppler/StdinCachedFile.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/StdinCachedFile.h rename to source/libs/poppler/poppler-0.33.0/poppler/StdinCachedFile.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/StdinPDFDocBuilder.cc b/source/libs/poppler/poppler-0.33.0/poppler/StdinPDFDocBuilder.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/StdinPDFDocBuilder.cc rename to source/libs/poppler/poppler-0.33.0/poppler/StdinPDFDocBuilder.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/StdinPDFDocBuilder.h b/source/libs/poppler/poppler-0.33.0/poppler/StdinPDFDocBuilder.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/StdinPDFDocBuilder.h rename to source/libs/poppler/poppler-0.33.0/poppler/StdinPDFDocBuilder.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Stream-CCITT.h b/source/libs/poppler/poppler-0.33.0/poppler/Stream-CCITT.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Stream-CCITT.h rename to source/libs/poppler/poppler-0.33.0/poppler/Stream-CCITT.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Stream.cc b/source/libs/poppler/poppler-0.33.0/poppler/Stream.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Stream.cc rename to source/libs/poppler/poppler-0.33.0/poppler/Stream.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/Stream.h b/source/libs/poppler/poppler-0.33.0/poppler/Stream.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/Stream.h rename to source/libs/poppler/poppler-0.33.0/poppler/Stream.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/StructElement.cc b/source/libs/poppler/poppler-0.33.0/poppler/StructElement.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/StructElement.cc rename to source/libs/poppler/poppler-0.33.0/poppler/StructElement.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/StructElement.h b/source/libs/poppler/poppler-0.33.0/poppler/StructElement.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/StructElement.h rename to source/libs/poppler/poppler-0.33.0/poppler/StructElement.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/StructTreeRoot.cc b/source/libs/poppler/poppler-0.33.0/poppler/StructTreeRoot.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/StructTreeRoot.cc rename to source/libs/poppler/poppler-0.33.0/poppler/StructTreeRoot.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/StructTreeRoot.h b/source/libs/poppler/poppler-0.33.0/poppler/StructTreeRoot.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/StructTreeRoot.h rename to source/libs/poppler/poppler-0.33.0/poppler/StructTreeRoot.h diff --git a/source/libs/poppler/poppler-0.33.0/poppler/TextOutputDev.cc b/source/libs/poppler/poppler-0.33.0/poppler/TextOutputDev.cc new file mode 100644 index 000000000..16f099f29 --- /dev/null +++ b/source/libs/poppler/poppler-0.33.0/poppler/TextOutputDev.cc @@ -0,0 +1,5818 @@ +//======================================================================== +// +// TextOutputDev.cc +// +// Copyright 1997-2003 Glyph & Cog, LLC +// +//======================================================================== + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2005-2007 Kristian Høgsberg <krh@redhat.com> +// Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru> +// Copyright (C) 2006-2008, 2011-2013 Carlos Garcia Campos <carlosgc@gnome.org> +// Copyright (C) 2006, 2007, 2013 Ed Catmur <ed@catmur.co.uk> +// Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net> +// Copyright (C) 2007, 2008, 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2008 Koji Otani <sho@bbr.jp> +// Copyright (C) 2008, 2010-2012, 2014, 2015 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2008 Pino Toscano <pino@kde.org> +// Copyright (C) 2008, 2010 Hib Eris <hib@hiberis.nl> +// Copyright (C) 2009 Ross Moore <ross@maths.mq.edu.au> +// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net> +// Copyright (C) 2010 Brian Ewins <brian.ewins@gmail.com> +// Copyright (C) 2010 Marek Kasik <mkasik@redhat.com> +// Copyright (C) 2010 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> +// Copyright (C) 2011 Sam Liao <phyomh@gmail.com> +// Copyright (C) 2012 Horst Prote <prote@fmi.uni-stuttgart.de> +// Copyright (C) 2012, 2013-2015 Jason Crain <jason@aquaticape.us> +// Copyright (C) 2012 Peter Breitenlohner <peb@mppmu.mpg.de> +// Copyright (C) 2013 José Aliste <jaliste@src.gnome.org> +// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2013 Ed Catmur <ed@catmur.co.uk> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#include <config.h> + +#ifdef USE_GCC_PRAGMAS +#pragma implementation +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <stddef.h> +#include <math.h> +#include <float.h> +#include <ctype.h> +#ifdef _WIN32 +#include <fcntl.h> // for O_BINARY +#include <io.h> // for setmode +#endif +#include "goo/gmem.h" +#include "goo/GooString.h" +#include "goo/GooList.h" +#include "poppler-config.h" +#include "Error.h" +#include "GlobalParams.h" +#include "UnicodeMap.h" +#include "UnicodeTypeTable.h" +#include "Link.h" +#include "TextOutputDev.h" +#include "Page.h" +#include "Annot.h" +#include "UTF.h" + +#ifdef MACOS +// needed for setting type/creator of MacOS files +#include "ICSupport.h" +#endif + +//------------------------------------------------------------------------ +// parameters +//------------------------------------------------------------------------ + +// Each bucket in a text pool includes baselines within a range of +// this many points. +#define textPoolStep 4 + +// Inter-character space width which will cause addChar to start a new +// word. +#define minWordBreakSpace 0.1 + +// Negative inter-character space width, i.e., overlap, which will +// cause addChar to start a new word. +#define minDupBreakOverlap 0.2 + +// Max distance between baselines of two lines within a block, as a +// fraction of the font size. +#define maxLineSpacingDelta 1.5 + +// Max difference in primary font sizes on two lines in the same +// block. Delta1 is used when examining new lines above and below the +// current block; delta2 is used when examining text that overlaps the +// current block; delta3 is used when examining text to the left and +// right of the current block. +#define maxBlockFontSizeDelta1 0.05 +#define maxBlockFontSizeDelta2 0.6 +#define maxBlockFontSizeDelta3 0.2 + +// Max difference in font sizes inside a word. +#define maxWordFontSizeDelta 0.05 + +// Maximum distance between baselines of two words on the same line, +// e.g., distance between subscript or superscript and the primary +// baseline, as a fraction of the font size. +#define maxIntraLineDelta 0.5 + +// Minimum inter-word spacing, as a fraction of the font size. (Only +// used for raw ordering.) +#define minWordSpacing 0.15 + +// Maximum inter-word spacing, as a fraction of the font size. +#define maxWordSpacing 1.5 + +// Maximum horizontal spacing which will allow a word to be pulled +// into a block. +#define minColSpacing1 0.3 + +// Minimum spacing between columns, as a fraction of the font size. +#define minColSpacing2 1.0 + +// Maximum vertical spacing between blocks within a flow, as a +// multiple of the font size. +#define maxBlockSpacing 2.5 + +// Minimum spacing between characters within a word, as a fraction of +// the font size. +#define minCharSpacing -0.5 + +// Maximum spacing between characters within a word, as a fraction of +// the font size, when there is no obvious extra-wide character +// spacing. +#define maxCharSpacing 0.03 + +// When extra-wide character spacing is detected, the inter-character +// space threshold is set to the minimum inter-character space +// multiplied by this constant. +#define maxWideCharSpacingMul 1.3 + +// Upper limit on spacing between characters in a word. +#define maxWideCharSpacing 0.4 + +// Max difference in primary,secondary coordinates (as a fraction of +// the font size) allowed for duplicated text (fake boldface, drop +// shadows) which is to be discarded. +#define dupMaxPriDelta 0.1 +#define dupMaxSecDelta 0.2 + +// Max width of underlines (in points). +#define maxUnderlineWidth 3 + +// Min distance between baseline and underline (in points). +//~ this should be font-size-dependent +#define minUnderlineGap -2 + +// Max distance between baseline and underline (in points). +//~ this should be font-size-dependent +#define maxUnderlineGap 4 + +// Max horizontal distance between edge of word and start of underline +// (in points). +//~ this should be font-size-dependent +#define underlineSlack 1 + +// Max distance between edge of text and edge of link border +#define hyperlinkSlack 2 + +// Max distance between characters when combining a base character and +// combining character +#define combMaxMidDelta 0.3 +#define combMaxBaseDelta 0.4 + +//------------------------------------------------------------------------ +// TextUnderline +//------------------------------------------------------------------------ + +class TextUnderline { +public: + + TextUnderline(double x0A, double y0A, double x1A, double y1A) + { x0 = x0A; y0 = y0A; x1 = x1A; y1 = y1A; horiz = y0 == y1; } + ~TextUnderline() {} + + double x0, y0, x1, y1; + GBool horiz; +}; + +//------------------------------------------------------------------------ +// TextLink +//------------------------------------------------------------------------ + +class TextLink { +public: + + TextLink(int xMinA, int yMinA, int xMaxA, int yMaxA, AnnotLink *linkA) + { xMin = xMinA; yMin = yMinA; xMax = xMaxA; yMax = yMaxA; link = linkA; } + ~TextLink() {} + + int xMin, yMin, xMax, yMax; + AnnotLink *link; +}; + +//------------------------------------------------------------------------ +// TextFontInfo +//------------------------------------------------------------------------ + +TextFontInfo::TextFontInfo(GfxState *state) { + gfxFont = state->getFont(); + if (gfxFont) + gfxFont->incRefCnt(); +#if TEXTOUT_WORD_LIST + fontName = (gfxFont && gfxFont->getName()) ? gfxFont->getName()->copy() + : (GooString *)NULL; + flags = gfxFont ? gfxFont->getFlags() : 0; +#endif +} + +TextFontInfo::~TextFontInfo() { + if (gfxFont) + gfxFont->decRefCnt(); +#if TEXTOUT_WORD_LIST + if (fontName) { + delete fontName; + } +#endif +} + +GBool TextFontInfo::matches(GfxState *state) { + return state->getFont() == gfxFont; +} + +GBool TextFontInfo::matches(TextFontInfo *fontInfo) { + return gfxFont == fontInfo->gfxFont; +} + +double TextFontInfo::getAscent() { + return gfxFont ? gfxFont->getAscent() : 0.95; +} + +double TextFontInfo::getDescent() { + return gfxFont ? gfxFont->getDescent() : -0.35; +} + +int TextFontInfo::getWMode() { + return gfxFont ? gfxFont->getWMode() : 0; +} + +//------------------------------------------------------------------------ +// TextWord +//------------------------------------------------------------------------ + +TextWord::TextWord(GfxState *state, int rotA, double fontSizeA) { + rot = rotA; + fontSize = fontSizeA; + text = NULL; + charcode = NULL; + edge = NULL; + charPos = NULL; + font = NULL; + textMat = NULL; + len = size = 0; + spaceAfter = gFalse; + next = NULL; + +#if TEXTOUT_WORD_LIST + GfxRGB rgb; + + if ((state->getRender() & 3) == 1) { + state->getStrokeRGB(&rgb); + } else { + state->getFillRGB(&rgb); + } + colorR = colToDbl(rgb.r); + colorG = colToDbl(rgb.g); + colorB = colToDbl(rgb.b); +#endif + + underlined = gFalse; + link = NULL; +} + +TextWord::~TextWord() { + gfree(text); + gfree(charcode); + gfree(edge); + gfree(charPos); + gfree(font); + gfree(textMat); +} + +void TextWord::addChar(GfxState *state, TextFontInfo *fontA, double x, double y, + double dx, double dy, int charPosA, int charLen, + CharCode c, Unicode u, Matrix textMatA) { + ensureCapacity(len+1); + text[len] = u; + charcode[len] = c; + charPos[len] = charPosA; + charPos[len + 1] = charPosA + charLen; + font[len] = fontA; + textMat[len] = textMatA; + + if (len == 0) + setInitialBounds(fontA, x, y); + + if (wMode) { // vertical writing mode + // NB: the rotation value has been incremented by 1 (in + // TextPage::beginWord()) for vertical writing mode + switch (rot) { + case 0: + edge[len] = x - fontSize; + xMax = edge[len+1] = x; + break; + case 1: + edge[len] = y - fontSize; + yMax = edge[len+1] = y; + break; + case 2: + edge[len] = x + fontSize; + xMin = edge[len+1] = x; + break; + case 3: + edge[len] = y + fontSize; + yMin = edge[len+1] = y; + break; + } + } else { // horizontal writing mode + switch (rot) { + case 0: + edge[len] = x; + xMax = edge[len+1] = x + dx; + break; + case 1: + edge[len] = y; + yMax = edge[len+1] = y + dy; + break; + case 2: + edge[len] = x; + xMin = edge[len+1] = x + dx; + break; + case 3: + edge[len] = y; + yMin = edge[len+1] = y + dy; + break; + } + } + ++len; +} + +void TextWord::setInitialBounds(TextFontInfo *fontA, double x, double y) { + double ascent = fontA->getAscent() * fontSize; + double descent = fontA->getDescent() * fontSize; + wMode = fontA->getWMode(); + + if (wMode) { // vertical writing mode + // NB: the rotation value has been incremented by 1 (in + // TextPage::beginWord()) for vertical writing mode + switch (rot) { + case 0: + xMin = x - fontSize; + yMin = y - fontSize; + yMax = y; + base = y; + break; + case 1: + xMin = x; + yMin = y - fontSize; + xMax = x + fontSize; + base = x; + break; + case 2: + yMin = y; + xMax = x + fontSize; + yMax = y + fontSize; + base = y; + break; + case 3: + xMin = x - fontSize; + xMax = x; + yMax = y + fontSize; + base = x; + break; + } + } else { // horizontal writing mode + switch (rot) { + case 0: + xMin = x; + yMin = y - ascent; + yMax = y - descent; + if (yMin == yMax) { + // this is a sanity check for a case that shouldn't happen -- but + // if it does happen, we want to avoid dividing by zero later + yMin = y; + yMax = y + 1; + } + base = y; + break; + case 1: + xMin = x + descent; + yMin = y; + xMax = x + ascent; + if (xMin == xMax) { + // this is a sanity check for a case that shouldn't happen -- but + // if it does happen, we want to avoid dividing by zero later + xMin = x; + xMax = x + 1; + } + base = x; + break; + case 2: + yMin = y + descent; + xMax = x; + yMax = y + ascent; + if (yMin == yMax) { + // this is a sanity check for a case that shouldn't happen -- but + // if it does happen, we want to avoid dividing by zero later + yMin = y; + yMax = y + 1; + } + base = y; + break; + case 3: + xMin = x - ascent; + xMax = x - descent; + yMax = y; + if (xMin == xMax) { + // this is a sanity check for a case that shouldn't happen -- but + // if it does happen, we want to avoid dividing by zero later + xMin = x; + xMax = x + 1; + } + base = x; + break; + } + } +} + +void TextWord::ensureCapacity(int capacity) { + if (capacity > size) { + size = std::max(size + 16, capacity); + text = (Unicode *)greallocn(text, size, sizeof(Unicode)); + charcode = (CharCode *)greallocn(charcode, (size + 1), sizeof(CharCode)); + edge = (double *)greallocn(edge, (size + 1), sizeof(double)); + charPos = (int *)greallocn(charPos, size + 1, sizeof(int)); + font = (TextFontInfo **)greallocn(font, size, sizeof(TextFontInfo *)); + textMat = (Matrix *)greallocn(textMat, size, sizeof(Matrix)); + } +} + +struct CombiningTable { + Unicode base; + Unicode comb; +}; + +static struct CombiningTable combiningTable[] = { + {0x0060, 0x0300}, // grave + {0x00a8, 0x0308}, // dieresis + {0x00af, 0x0304}, // macron + {0x00b4, 0x0301}, // acute + {0x00b8, 0x0327}, // cedilla + {0x02c6, 0x0302}, // circumflex + {0x02c7, 0x030c}, // caron + {0x02d8, 0x0306}, // breve + {0x02d9, 0x0307}, // dotaccent + {0x02da, 0x030a}, // ring + {0x02dc, 0x0303}, // tilde + {0x02dd, 0x030b} // hungarumlaut (double acute accent) +}; + +// returning combining versions of characters +Unicode getCombiningChar(Unicode u) { + int len = sizeof(combiningTable) / sizeof(combiningTable[0]); + for (int i = 0; i < len; ++i) { + if (u == combiningTable[i].base) + return combiningTable[i].comb; + } + return 0; +} + +GBool TextWord::addCombining(GfxState *state, TextFontInfo *fontA, double fontSizeA, double x, double y, + double dx, double dy, int charPosA, int charLen, + CharCode c, Unicode u, Matrix textMatA) { + if (len == 0 || wMode != 0 || fontA->getWMode() != 0) + return gFalse; + + Unicode cCurrent = getCombiningChar(u); + Unicode cPrev = getCombiningChar(text[len-1]); + double edgeMid = (edge[len-1] + edge[len]) / 2; + double charMid, maxScaledMidDelta, charBase, maxScaledBaseDelta; + + if (cCurrent != 0 && unicodeTypeAlphaNum(text[len-1])) { + // Current is a combining character, previous is base character + maxScaledMidDelta = fabs(edge[len] - edge[len-1]) * combMaxMidDelta; + charMid = charBase = maxScaledBaseDelta = 0; + + // Test if characters overlap + if (rot == 0 || rot == 2) { + charMid = x + (dx / 2); + charBase = y; + maxScaledBaseDelta = (yMax - yMin) * combMaxBaseDelta; + } else { + charMid = y + (dy / 2); + charBase = x; + maxScaledBaseDelta = (xMax - xMin) * combMaxBaseDelta; + } + + if (fabs(charMid - edgeMid) >= maxScaledMidDelta || + fabs(charBase - base) >= maxScaledBaseDelta) + return gFalse; + + // Add character, but don't adjust edge / bounding box because + // combining character's positioning could be odd. + ensureCapacity(len+1); + text[len] = cCurrent; + charcode[len] = c; + charPos[len] = charPosA; + charPos[len+1] = charPosA + charLen; + font[len] = fontA; + textMat[len] = textMatA; + edge[len+1] = edge[len]; + edge[len] = (edge[len+1] + edge[len-1]) / 2; + ++len; + return gTrue; + } + + if (cPrev != 0 && unicodeTypeAlphaNum(u)) { + // Previous is a combining character, current is base character + maxScaledBaseDelta = (fontA->getAscent() - fontA->getDescent()) * fontSizeA * combMaxBaseDelta; + charMid = charBase = maxScaledMidDelta = 0; + + // Test if characters overlap + if (rot == 0 || rot == 2) { + charMid = x + (dx / 2); + charBase = y; + maxScaledMidDelta = fabs(dx * combMaxMidDelta); + } else { + charMid = y + (dy / 2); + charBase = x; + maxScaledMidDelta = fabs(dy * combMaxMidDelta); + } + + if (fabs(charMid - edgeMid) >= maxScaledMidDelta || + fabs(charBase - base) >= maxScaledBaseDelta) + return gFalse; + + // move combining character to after base character + ensureCapacity(len+1); + fontSize = fontSizeA; + text[len] = cPrev; + charcode[len] = charcode[len-1]; + charPos[len] = charPosA; + charPos[len+1] = charPosA + charLen; + font[len] = font[len-1]; + textMat[len] = textMat[len-1]; + + text[len-1] = u; + charcode[len-1] = c; + font[len-1] = fontA; + textMat[len-1] = textMatA; + + if (len == 1) + setInitialBounds(fontA, x, y); + + // Updated edges / bounding box because we changed the base + // character. + if (wMode) { + switch (rot) { + case 0: + edge[len-1] = x - fontSize; + xMax = edge[len+1] = x; + break; + case 1: + edge[len-1] = y - fontSize; + yMax = edge[len+1] = y; + break; + case 2: + edge[len-1] = x + fontSize; + xMin = edge[len+1] = x; + break; + case 3: + edge[len-1] = y + fontSize; + yMin = edge[len+1] = y; + break; + } + } else { + switch (rot) { + case 0: + edge[len-1] = x; + xMax = edge[len+1] = x + dx; + break; + case 1: + edge[len-1] = y; + yMax = edge[len+1] = y + dy; + break; + case 2: + edge[len-1] = x; + xMin = edge[len+1] = x + dx; + break; + case 3: + edge[len-1] = y; + yMin = edge[len+1] = y + dy; + break; + } + } + + edge[len] = (edge[len+1] + edge[len-1]) / 2; + ++len; + return gTrue; + } + return gFalse; +} + +void TextWord::merge(TextWord *word) { + int i; + + if (word->xMin < xMin) { + xMin = word->xMin; + } + if (word->yMin < yMin) { + yMin = word->yMin; + } + if (word->xMax > xMax) { + xMax = word->xMax; + } + if (word->yMax > yMax) { + yMax = word->yMax; + } + ensureCapacity(len + word->len); + for (i = 0; i < word->len; ++i) { + text[len + i] = word->text[i]; + charcode[len + i] = word->charcode[i]; + edge[len + i] = word->edge[i]; + charPos[len + i] = word->charPos[i]; + font[len + i] = word->font[i]; + textMat[len + i] = word->textMat[i]; + } + edge[len + word->len] = word->edge[word->len]; + charPos[len + word->len] = word->charPos[word->len]; + len += word->len; +} + +inline int TextWord::primaryCmp(TextWord *word) { + double cmp; + + cmp = 0; // make gcc happy + switch (rot) { + case 0: + cmp = xMin - word->xMin; + break; + case 1: + cmp = yMin - word->yMin; + break; + case 2: + cmp = word->xMax - xMax; + break; + case 3: + cmp = word->yMax - yMax; + break; + } + return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; +} + +double TextWord::primaryDelta(TextWord *word) { + double delta; + + delta = 0; // make gcc happy + switch (rot) { + case 0: + delta = word->xMin - xMax; + break; + case 1: + delta = word->yMin - yMax; + break; + case 2: + delta = xMin - word->xMax; + break; + case 3: + delta = yMin - word->yMax; + break; + } + return delta; +} + +int TextWord::cmpYX(const void *p1, const void *p2) { + TextWord *word1 = *(TextWord **)p1; + TextWord *word2 = *(TextWord **)p2; + double cmp; + + cmp = word1->yMin - word2->yMin; + if (cmp == 0) { + cmp = word1->xMin - word2->xMin; + } + return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; +} + +#if TEXTOUT_WORD_LIST + +GooString *TextWord::getText() { + GooString *s; + UnicodeMap *uMap; + char buf[8]; + int n, i; + + s = new GooString(); + if (!(uMap = globalParams->getTextEncoding())) { + return s; + } + for (i = 0; i < len; ++i) { + n = uMap->mapUnicode(text[i], buf, sizeof(buf)); + s->append(buf, n); + } + uMap->decRefCnt(); + return s; +} + +void TextWord::getCharBBox(int charIdx, double *xMinA, double *yMinA, + double *xMaxA, double *yMaxA) { + if (charIdx < 0 || charIdx >= len) { + return; + } + switch (rot) { + case 0: + *xMinA = edge[charIdx]; + *xMaxA = edge[charIdx + 1]; + *yMinA = yMin; + *yMaxA = yMax; + break; + case 1: + *xMinA = xMin; + *xMaxA = xMax; + *yMinA = edge[charIdx]; + *yMaxA = edge[charIdx + 1]; + break; + case 2: + *xMinA = edge[charIdx + 1]; + *xMaxA = edge[charIdx]; + *yMinA = yMin; + *yMaxA = yMax; + break; + case 3: + *xMinA = xMin; + *xMaxA = xMax; + *yMinA = edge[charIdx + 1]; + *yMaxA = edge[charIdx]; + break; + } +} + +#endif // TEXTOUT_WORD_LIST + +//------------------------------------------------------------------------ +// TextPool +//------------------------------------------------------------------------ + +TextPool::TextPool() { + minBaseIdx = 0; + maxBaseIdx = -1; + pool = NULL; + cursor = NULL; + cursorBaseIdx = -1; +} + +TextPool::~TextPool() { + int baseIdx; + TextWord *word, *word2; + + for (baseIdx = minBaseIdx; baseIdx <= maxBaseIdx; ++baseIdx) { + for (word = pool[baseIdx - minBaseIdx]; word; word = word2) { + word2 = word->next; + delete word; + } + } + gfree(pool); +} + +int TextPool::getBaseIdx(double base) { + int baseIdx; + + baseIdx = (int)(base / textPoolStep); + if (baseIdx < minBaseIdx) { + return minBaseIdx; + } + if (baseIdx > maxBaseIdx) { + return maxBaseIdx; + } + return baseIdx; +} + +void TextPool::addWord(TextWord *word) { + TextWord **newPool; + int wordBaseIdx, newMinBaseIdx, newMaxBaseIdx, baseIdx; + TextWord *w0, *w1; + + // expand the array if needed + if (unlikely((word->base / textPoolStep) > INT_MAX)) { + error(errSyntaxWarning, -1, "word->base / textPoolStep > INT_MAX"); + return; + } + wordBaseIdx = (int)(word->base / textPoolStep); + if (minBaseIdx > maxBaseIdx) { + minBaseIdx = wordBaseIdx - 128; + maxBaseIdx = wordBaseIdx + 128; + pool = (TextWord **)gmallocn(maxBaseIdx - minBaseIdx + 1, + sizeof(TextWord *)); + for (baseIdx = minBaseIdx; baseIdx <= maxBaseIdx; ++baseIdx) { + pool[baseIdx - minBaseIdx] = NULL; + } + } else if (wordBaseIdx < minBaseIdx) { + newMinBaseIdx = wordBaseIdx - 128; + newPool = (TextWord **)gmallocn(maxBaseIdx - newMinBaseIdx + 1, + sizeof(TextWord *)); + for (baseIdx = newMinBaseIdx; baseIdx < minBaseIdx; ++baseIdx) { + newPool[baseIdx - newMinBaseIdx] = NULL; + } + memcpy(&newPool[minBaseIdx - newMinBaseIdx], pool, + (maxBaseIdx - minBaseIdx + 1) * sizeof(TextWord *)); + gfree(pool); + pool = newPool; + minBaseIdx = newMinBaseIdx; + } else if (wordBaseIdx > maxBaseIdx) { + newMaxBaseIdx = wordBaseIdx + 128; + pool = (TextWord **)greallocn(pool, newMaxBaseIdx - minBaseIdx + 1, + sizeof(TextWord *)); + for (baseIdx = maxBaseIdx + 1; baseIdx <= newMaxBaseIdx; ++baseIdx) { + pool[baseIdx - minBaseIdx] = NULL; + } + maxBaseIdx = newMaxBaseIdx; + } + + // insert the new word + if (cursor && wordBaseIdx == cursorBaseIdx && + word->primaryCmp(cursor) >= 0) { + w0 = cursor; + w1 = cursor->next; + } else { + w0 = NULL; + w1 = pool[wordBaseIdx - minBaseIdx]; + } + for (; w1 && word->primaryCmp(w1) > 0; w0 = w1, w1 = w1->next) ; + word->next = w1; + if (w0) { + w0->next = word; + } else { + pool[wordBaseIdx - minBaseIdx] = word; + } + cursor = word; + cursorBaseIdx = wordBaseIdx; +} + +//------------------------------------------------------------------------ +// TextLine +//------------------------------------------------------------------------ + +TextLine::TextLine(TextBlock *blkA, int rotA, double baseA) { + blk = blkA; + rot = rotA; + base = baseA; + words = lastWord = NULL; + text = NULL; + edge = NULL; + col = NULL; + len = 0; + convertedLen = 0; + hyphenated = gFalse; + next = NULL; + xMin = yMin = 0; + xMax = yMax = -1; + normalized = NULL; + normalized_len = 0; + normalized_idx = NULL; +} + +TextLine::~TextLine() { + TextWord *word; + + while (words) { + word = words; + words = words->next; + delete word; + } + gfree(text); + gfree(edge); + gfree(col); + if (normalized) { + gfree(normalized); + gfree(normalized_idx); + } +} + +void TextLine::addWord(TextWord *word) { + if (lastWord) { + lastWord->next = word; + } else { + words = word; + } + lastWord = word; + + if (xMin > xMax) { + xMin = word->xMin; + xMax = word->xMax; + yMin = word->yMin; + yMax = word->yMax; + } else { + if (word->xMin < xMin) { + xMin = word->xMin; + } + if (word->xMax > xMax) { + xMax = word->xMax; + } + if (word->yMin < yMin) { + yMin = word->yMin; + } + if (word->yMax > yMax) { + yMax = word->yMax; + } + } +} + +double TextLine::primaryDelta(TextLine *line) { + double delta; + + delta = 0; // make gcc happy + switch (rot) { + case 0: + delta = line->xMin - xMax; + break; + case 1: + delta = line->yMin - yMax; + break; + case 2: + delta = xMin - line->xMax; + break; + case 3: + delta = yMin - line->yMax; + break; + } + return delta; +} + +int TextLine::primaryCmp(TextLine *line) { + double cmp; + + cmp = 0; // make gcc happy + switch (rot) { + case 0: + cmp = xMin - line->xMin; + break; + case 1: + cmp = yMin - line->yMin; + break; + case 2: + cmp = line->xMax - xMax; + break; + case 3: + cmp = line->yMax - yMax; + break; + } + return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; +} + +int TextLine::secondaryCmp(TextLine *line) { + double cmp; + + cmp = (rot == 0 || rot == 3) ? base - line->base : line->base - base; + return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; +} + +int TextLine::cmpYX(TextLine *line) { + int cmp; + + if ((cmp = secondaryCmp(line))) { + return cmp; + } + return primaryCmp(line); +} + +int TextLine::cmpXY(const void *p1, const void *p2) { + TextLine *line1 = *(TextLine **)p1; + TextLine *line2 = *(TextLine **)p2; + int cmp; + + if ((cmp = line1->primaryCmp(line2))) { + return cmp; + } + return line1->secondaryCmp(line2); +} + +void TextLine::coalesce(UnicodeMap *uMap) { + TextWord *word0, *word1; + double space, delta, minSpace; + GBool isUnicode; + char buf[8]; + int i, j; + + if (words->next) { + + // compute the inter-word space threshold + if (words->len > 1 || words->next->len > 1) { + minSpace = 0; + } else { + minSpace = words->primaryDelta(words->next); + for (word0 = words->next, word1 = word0->next; + word1 && minSpace > 0; + word0 = word1, word1 = word0->next) { + if (word1->len > 1) { + minSpace = 0; + } + delta = word0->primaryDelta(word1); + if (delta < minSpace) { + minSpace = delta; + } + } + } + if (minSpace <= 0) { + space = maxCharSpacing * words->fontSize; + } else { + space = maxWideCharSpacingMul * minSpace; + if (space > maxWideCharSpacing * words->fontSize) { + space = maxWideCharSpacing * words->fontSize; + } + } + + // merge words + word0 = words; + word1 = words->next; + while (word1) { + if (word0->primaryDelta(word1) >= space) { + word0->spaceAfter = gTrue; + word0 = word1; + word1 = word1->next; + } else if (word0->font[word0->len - 1] == word1->font[0] && + word0->underlined == word1->underlined && + fabs(word0->fontSize - word1->fontSize) < + maxWordFontSizeDelta * words->fontSize && + word1->charPos[0] == word0->charPos[word0->len]) { + word0->merge(word1); + word0->next = word1->next; + delete word1; + word1 = word0->next; + } else { + word0 = word1; + word1 = word1->next; + } + } + } + + // build the line text + isUnicode = uMap ? uMap->isUnicode() : gFalse; + len = 0; + for (word1 = words; word1; word1 = word1->next) { + len += word1->len; + if (word1->spaceAfter) { + ++len; + } + } + text = (Unicode *)gmallocn(len, sizeof(Unicode)); + edge = (double *)gmallocn(len + 1, sizeof(double)); + i = 0; + for (word1 = words; word1; word1 = word1->next) { + for (j = 0; j < word1->len; ++j) { + text[i] = word1->text[j]; + edge[i] = word1->edge[j]; + ++i; + } + edge[i] = word1->edge[word1->len]; + if (word1->spaceAfter) { + text[i] = (Unicode)0x0020; + ++i; + } + } + + // compute convertedLen and set up the col array + col = (int *)gmallocn(len + 1, sizeof(int)); + convertedLen = 0; + for (i = 0; i < len; ++i) { + col[i] = convertedLen; + if (isUnicode) { + ++convertedLen; + } else if (uMap) { + convertedLen += uMap->mapUnicode(text[i], buf, sizeof(buf)); + } + } + col[len] = convertedLen; + + // check for hyphen at end of line + //~ need to check for other chars used as hyphens + hyphenated = text[len - 1] == (Unicode)'-'; +} + +//------------------------------------------------------------------------ +// TextLineFrag +//------------------------------------------------------------------------ + +class TextLineFrag { +public: + + TextLine *line; // the line object + int start, len; // offset and length of this fragment + // (in Unicode chars) + double xMin, xMax; // bounding box coordinates + double yMin, yMax; + double base; // baseline virtual coordinate + int col; // first column + + void init(TextLine *lineA, int startA, int lenA); + void computeCoords(GBool oneRot); + + static int cmpYXPrimaryRot(const void *p1, const void *p2); + static int cmpYXLineRot(const void *p1, const void *p2); + static int cmpXYLineRot(const void *p1, const void *p2); + static int cmpXYColumnPrimaryRot(const void *p1, const void *p2); + static int cmpXYColumnLineRot(const void *p1, const void *p2); +}; + +void TextLineFrag::init(TextLine *lineA, int startA, int lenA) { + line = lineA; + start = startA; + len = lenA; + col = line->col[start]; +} + +void TextLineFrag::computeCoords(GBool oneRot) { + TextBlock *blk; + double d0, d1, d2, d3, d4; + + if (oneRot) { + + switch (line->rot) { + case 0: + xMin = line->edge[start]; + xMax = line->edge[start + len]; + yMin = line->yMin; + yMax = line->yMax; + break; + case 1: + xMin = line->xMin; + xMax = line->xMax; + yMin = line->edge[start]; + yMax = line->edge[start + len]; + break; + case 2: + xMin = line->edge[start + len]; + xMax = line->edge[start]; + yMin = line->yMin; + yMax = line->yMax; + break; + case 3: + xMin = line->xMin; + xMax = line->xMax; + yMin = line->edge[start + len]; + yMax = line->edge[start]; + break; + } + base = line->base; + + } else { + + if (line->rot == 0 && line->blk->page->primaryRot == 0) { + + xMin = line->edge[start]; + xMax = line->edge[start + len]; + yMin = line->yMin; + yMax = line->yMax; + base = line->base; + + } else { + + blk = line->blk; + d0 = line->edge[start]; + d1 = line->edge[start + len]; + d2 = d3 = d4 = 0; // make gcc happy + + switch (line->rot) { + case 0: + d2 = line->yMin; + d3 = line->yMax; + d4 = line->base; + d0 = (d0 - blk->xMin) / (blk->xMax - blk->xMin); + d1 = (d1 - blk->xMin) / (blk->xMax - blk->xMin); + d2 = (d2 - blk->yMin) / (blk->yMax - blk->yMin); + d3 = (d3 - blk->yMin) / (blk->yMax - blk->yMin); + d4 = (d4 - blk->yMin) / (blk->yMax - blk->yMin); + break; + case 1: + d2 = line->xMax; + d3 = line->xMin; + d4 = line->base; + d0 = (d0 - blk->yMin) / (blk->yMax - blk->yMin); + d1 = (d1 - blk->yMin) / (blk->yMax - blk->yMin); + d2 = (blk->xMax - d2) / (blk->xMax - blk->xMin); + d3 = (blk->xMax - d3) / (blk->xMax - blk->xMin); + d4 = (blk->xMax - d4) / (blk->xMax - blk->xMin); + break; + case 2: + d2 = line->yMax; + d3 = line->yMin; + d4 = line->base; + d0 = (blk->xMax - d0) / (blk->xMax - blk->xMin); + d1 = (blk->xMax - d1) / (blk->xMax - blk->xMin); + d2 = (blk->yMax - d2) / (blk->yMax - blk->yMin); + d3 = (blk->yMax - d3) / (blk->yMax - blk->yMin); + d4 = (blk->yMax - d4) / (blk->yMax - blk->yMin); + break; + case 3: + d2 = line->xMin; + d3 = line->xMax; + d4 = line->base; + d0 = (blk->yMax - d0) / (blk->yMax - blk->yMin); + d1 = (blk->yMax - d1) / (blk->yMax - blk->yMin); + d2 = (d2 - blk->xMin) / (blk->xMax - blk->xMin); + d3 = (d3 - blk->xMin) / (blk->xMax - blk->xMin); + d4 = (d4 - blk->xMin) / (blk->xMax - blk->xMin); + break; + } + + switch (line->blk->page->primaryRot) { + case 0: + xMin = blk->xMin + d0 * (blk->xMax - blk->xMin); + xMax = blk->xMin + d1 * (blk->xMax - blk->xMin); + yMin = blk->yMin + d2 * (blk->yMax - blk->yMin); + yMax = blk->yMin + d3 * (blk->yMax - blk->yMin); + base = blk->yMin + d4 * (blk->yMax - blk->yMin); + break; + case 1: + xMin = blk->xMax - d3 * (blk->xMax - blk->xMin); + xMax = blk->xMax - d2 * (blk->xMax - blk->xMin); + yMin = blk->yMin + d0 * (blk->yMax - blk->yMin); + yMax = blk->yMin + d1 * (blk->yMax - blk->yMin); + base = blk->xMax - d4 * (blk->xMax - blk->xMin); + break; + case 2: + xMin = blk->xMax - d1 * (blk->xMax - blk->xMin); + xMax = blk->xMax - d0 * (blk->xMax - blk->xMin); + yMin = blk->yMax - d3 * (blk->yMax - blk->yMin); + yMax = blk->yMax - d2 * (blk->yMax - blk->yMin); + base = blk->yMax - d4 * (blk->yMax - blk->yMin); + break; + case 3: + xMin = blk->xMin + d2 * (blk->xMax - blk->xMin); + xMax = blk->xMin + d3 * (blk->xMax - blk->xMin); + yMin = blk->yMax - d1 * (blk->yMax - blk->yMin); + yMax = blk->yMax - d0 * (blk->yMax - blk->yMin); + base = blk->xMin + d4 * (blk->xMax - blk->xMin); + break; + } + + } + } +} + +int TextLineFrag::cmpYXPrimaryRot(const void *p1, const void *p2) { + TextLineFrag *frag1 = (TextLineFrag *)p1; + TextLineFrag *frag2 = (TextLineFrag *)p2; + double cmp; + + cmp = 0; // make gcc happy + switch (frag1->line->blk->page->primaryRot) { + case 0: + if (fabs(cmp = frag1->yMin - frag2->yMin) < 0.01) { + cmp = frag1->xMin - frag2->xMin; + } + break; + case 1: + if (fabs(cmp = frag2->xMax - frag1->xMax) < 0.01) { + cmp = frag1->yMin - frag2->yMin; + } + break; + case 2: + if (fabs(cmp = frag2->yMin - frag1->yMin) < 0.01) { + cmp = frag2->xMax - frag1->xMax; + } + break; + case 3: + if (fabs(cmp = frag1->xMax - frag2->xMax) < 0.01) { + cmp = frag2->yMax - frag1->yMax; + } + break; + } + return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; +} + +int TextLineFrag::cmpYXLineRot(const void *p1, const void *p2) { + TextLineFrag *frag1 = (TextLineFrag *)p1; + TextLineFrag *frag2 = (TextLineFrag *)p2; + double cmp; + + cmp = 0; // make gcc happy + switch (frag1->line->rot) { + case 0: + if ((cmp = frag1->yMin - frag2->yMin) == 0) { + cmp = frag1->xMin - frag2->xMin; + } + break; + case 1: + if ((cmp = frag2->xMax - frag1->xMax) == 0) { + cmp = frag1->yMin - frag2->yMin; + } + break; + case 2: + if ((cmp = frag2->yMin - frag1->yMin) == 0) { + cmp = frag2->xMax - frag1->xMax; + } + break; + case 3: + if ((cmp = frag1->xMax - frag2->xMax) == 0) { + cmp = frag2->yMax - frag1->yMax; + } + break; + } + return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; +} + +int TextLineFrag::cmpXYLineRot(const void *p1, const void *p2) { + TextLineFrag *frag1 = (TextLineFrag *)p1; + TextLineFrag *frag2 = (TextLineFrag *)p2; + double cmp; + + cmp = 0; // make gcc happy + switch (frag1->line->rot) { + case 0: + if ((cmp = frag1->xMin - frag2->xMin) == 0) { + cmp = frag1->yMin - frag2->yMin; + } + break; + case 1: + if ((cmp = frag1->yMin - frag2->yMin) == 0) { + cmp = frag2->xMax - frag1->xMax; + } + break; + case 2: + if ((cmp = frag2->xMax - frag1->xMax) == 0) { + cmp = frag2->yMin - frag1->yMin; + } + break; + case 3: + if ((cmp = frag2->yMax - frag1->yMax) == 0) { + cmp = frag1->xMax - frag2->xMax; + } + break; + } + return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; +} + +int TextLineFrag::cmpXYColumnPrimaryRot(const void *p1, const void *p2) { + TextLineFrag *frag1 = (TextLineFrag *)p1; + TextLineFrag *frag2 = (TextLineFrag *)p2; + double cmp; + + // if columns overlap, compare y values + if (frag1->col < frag2->col + (frag2->line->col[frag2->start + frag2->len] - + frag2->line->col[frag2->start]) && + frag2->col < frag1->col + (frag1->line->col[frag1->start + frag1->len] - + frag1->line->col[frag1->start])) { + cmp = 0; // make gcc happy + switch (frag1->line->blk->page->primaryRot) { + case 0: cmp = frag1->yMin - frag2->yMin; break; + case 1: cmp = frag2->xMax - frag1->xMax; break; + case 2: cmp = frag2->yMin - frag1->yMin; break; + case 3: cmp = frag1->xMax - frag2->xMax; break; + } + return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; + } + + // otherwise, compare starting column + return frag1->col - frag2->col; +} + +int TextLineFrag::cmpXYColumnLineRot(const void *p1, const void *p2) { + TextLineFrag *frag1 = (TextLineFrag *)p1; + TextLineFrag *frag2 = (TextLineFrag *)p2; + double cmp; + + // if columns overlap, compare y values + if (frag1->col < frag2->col + (frag2->line->col[frag2->start + frag2->len] - + frag2->line->col[frag2->start]) && + frag2->col < frag1->col + (frag1->line->col[frag1->start + frag1->len] - + frag1->line->col[frag1->start])) { + cmp = 0; // make gcc happy + switch (frag1->line->rot) { + case 0: cmp = frag1->yMin - frag2->yMin; break; + case 1: cmp = frag2->xMax - frag1->xMax; break; + case 2: cmp = frag2->yMin - frag1->yMin; break; + case 3: cmp = frag1->xMax - frag2->xMax; break; + } + return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; + } + + // otherwise, compare starting column + return frag1->col - frag2->col; +} + +//------------------------------------------------------------------------ +// TextBlock +//------------------------------------------------------------------------ + +TextBlock::TextBlock(TextPage *pageA, int rotA) { + page = pageA; + rot = rotA; + xMin = yMin = 0; + xMax = yMax = -1; + priMin = 0; + priMax = page->pageWidth; + pool = new TextPool(); + lines = NULL; + curLine = NULL; + next = NULL; + stackNext = NULL; + tableId = -1; + tableEnd = gFalse; +} + +TextBlock::~TextBlock() { + TextLine *line; + + delete pool; + while (lines) { + line = lines; + lines = lines->next; + delete line; + } +} + +void TextBlock::addWord(TextWord *word) { + pool->addWord(word); + if (xMin > xMax) { + xMin = word->xMin; + xMax = word->xMax; + yMin = word->yMin; + yMax = word->yMax; + } else { + if (word->xMin < xMin) { + xMin = word->xMin; + } + if (word->xMax > xMax) { + xMax = word->xMax; + } + if (word->yMin < yMin) { + yMin = word->yMin; + } + if (word->yMax > yMax) { + yMax = word->yMax; + } + } +} + +void TextBlock::coalesce(UnicodeMap *uMap, double fixedPitch) { + TextWord *word0, *word1, *word2, *bestWord0, *bestWord1, *lastWord; + TextLine *line, *line0, *line1; + int poolMinBaseIdx, startBaseIdx, minBaseIdx, maxBaseIdx; + int baseIdx, bestWordBaseIdx, idx0, idx1; + double minBase, maxBase; + double fontSize, wordSpacing, delta, priDelta, secDelta; + TextLine **lineArray; + GBool found, overlap; + int col1, col2; + int i, j, k; + + // discard duplicated text (fake boldface, drop shadows) + for (idx0 = pool->minBaseIdx; idx0 <= pool->maxBaseIdx; ++idx0) { + word0 = pool->getPool(idx0); + while (word0) { + priDelta = dupMaxPriDelta * word0->fontSize; + secDelta = dupMaxSecDelta * word0->fontSize; + maxBaseIdx = pool->getBaseIdx(word0->base + secDelta); + found = gFalse; + word1 = word2 = NULL; // make gcc happy + for (idx1 = idx0; idx1 <= maxBaseIdx; ++idx1) { + if (idx1 == idx0) { + word1 = word0; + word2 = word0->next; + } else { + word1 = NULL; + word2 = pool->getPool(idx1); + } + for (; word2; word1 = word2, word2 = word2->next) { + if (word2->len == word0->len && + !memcmp(word2->text, word0->text, + word0->len * sizeof(Unicode))) { + switch (rot) { + case 0: + case 2: + found = fabs(word0->xMin - word2->xMin) < priDelta && + fabs(word0->xMax - word2->xMax) < priDelta && + fabs(word0->yMin - word2->yMin) < secDelta && + fabs(word0->yMax - word2->yMax) < secDelta; + break; + case 1: + case 3: + found = fabs(word0->xMin - word2->xMin) < secDelta && + fabs(word0->xMax - word2->xMax) < secDelta && + fabs(word0->yMin - word2->yMin) < priDelta && + fabs(word0->yMax - word2->yMax) < priDelta; + break; + } + } + if (found) { + break; + } + } + if (found) { + break; + } + } + if (found) { + if (word1) { + word1->next = word2->next; + } else { + pool->setPool(idx1, word2->next); + } + delete word2; + } else { + word0 = word0->next; + } + } + } + + // build the lines + curLine = NULL; + poolMinBaseIdx = pool->minBaseIdx; + charCount = 0; + nLines = 0; + while (1) { + + // find the first non-empty line in the pool + for (; + poolMinBaseIdx <= pool->maxBaseIdx && !pool->getPool(poolMinBaseIdx); + ++poolMinBaseIdx) ; + if (poolMinBaseIdx > pool->maxBaseIdx) { + break; + } + + // look for the left-most word in the first four lines of the + // pool -- this avoids starting with a superscript word + startBaseIdx = poolMinBaseIdx; + for (baseIdx = poolMinBaseIdx + 1; + baseIdx < poolMinBaseIdx + 4 && baseIdx <= pool->maxBaseIdx; + ++baseIdx) { + if (!pool->getPool(baseIdx)) { + continue; + } + if (pool->getPool(baseIdx)->primaryCmp(pool->getPool(startBaseIdx)) + < 0) { + startBaseIdx = baseIdx; + } + } + + // create a new line + word0 = pool->getPool(startBaseIdx); + pool->setPool(startBaseIdx, word0->next); + word0->next = NULL; + line = new TextLine(this, word0->rot, word0->base); + line->addWord(word0); + lastWord = word0; + + // compute the search range + fontSize = word0->fontSize; + minBase = word0->base - maxIntraLineDelta * fontSize; + maxBase = word0->base + maxIntraLineDelta * fontSize; + minBaseIdx = pool->getBaseIdx(minBase); + maxBaseIdx = pool->getBaseIdx(maxBase); + wordSpacing = fixedPitch ? fixedPitch : maxWordSpacing * fontSize; + + // find the rest of the words in this line + while (1) { + + // find the left-most word whose baseline is in the range for + // this line + bestWordBaseIdx = 0; + bestWord0 = bestWord1 = NULL; + overlap = gFalse; + for (baseIdx = minBaseIdx; + !overlap && baseIdx <= maxBaseIdx; + ++baseIdx) { + for (word0 = NULL, word1 = pool->getPool(baseIdx); + word1; + word0 = word1, word1 = word1->next) { + if (word1->base >= minBase && + word1->base <= maxBase) { + delta = lastWord->primaryDelta(word1); + if (delta < minCharSpacing * fontSize) { + overlap = gTrue; + break; + } else { + if (delta < wordSpacing && + (!bestWord1 || word1->primaryCmp(bestWord1) < 0)) { + bestWordBaseIdx = baseIdx; + bestWord0 = word0; + bestWord1 = word1; + } + break; + } + } + } + } + if (overlap || !bestWord1) { + break; + } + + // remove it from the pool, and add it to the line + if (bestWord0) { + bestWord0->next = bestWord1->next; + } else { + pool->setPool(bestWordBaseIdx, bestWord1->next); + } + bestWord1->next = NULL; + line->addWord(bestWord1); + lastWord = bestWord1; + } + + // add the line + if (curLine && line->cmpYX(curLine) > 0) { + line0 = curLine; + line1 = curLine->next; + } else { + line0 = NULL; + line1 = lines; + } + for (; + line1 && line->cmpYX(line1) > 0; + line0 = line1, line1 = line1->next) ; + if (line0) { + line0->next = line; + } else { + lines = line; + } + line->next = line1; + curLine = line; + line->coalesce(uMap); + charCount += line->len; + ++nLines; + } + + // sort lines into xy order for column assignment + lineArray = (TextLine **)gmallocn(nLines, sizeof(TextLine *)); + for (line = lines, i = 0; line; line = line->next, ++i) { + lineArray[i] = line; + } + qsort(lineArray, nLines, sizeof(TextLine *), &TextLine::cmpXY); + + // column assignment + nColumns = 0; + if (fixedPitch) { + for (i = 0; i < nLines; ++i) { + line0 = lineArray[i]; + col1 = 0; // make gcc happy + switch (rot) { + case 0: + col1 = (int)((line0->xMin - xMin) / fixedPitch + 0.5); + break; + case 1: + col1 = (int)((line0->yMin - yMin) / fixedPitch + 0.5); + break; + case 2: + col1 = (int)((xMax - line0->xMax) / fixedPitch + 0.5); + break; + case 3: + col1 = (int)((yMax - line0->yMax) / fixedPitch + 0.5); + break; + } + for (k = 0; k <= line0->len; ++k) { + line0->col[k] += col1; + } + if (line0->col[line0->len] > nColumns) { + nColumns = line0->col[line0->len]; + } + } + } else { + for (i = 0; i < nLines; ++i) { + line0 = lineArray[i]; + col1 = 0; + for (j = 0; j < i; ++j) { + line1 = lineArray[j]; + if (line1->primaryDelta(line0) >= 0) { + col2 = line1->col[line1->len] + 1; + } else { + k = 0; // make gcc happy + switch (rot) { + case 0: + for (k = 0; + k < line1->len && + line0->xMin >= 0.5 * (line1->edge[k] + line1->edge[k+1]); + ++k) ; + break; + case 1: + for (k = 0; + k < line1->len && + line0->yMin >= 0.5 * (line1->edge[k] + line1->edge[k+1]); + ++k) ; + break; + case 2: + for (k = 0; + k < line1->len && + line0->xMax <= 0.5 * (line1->edge[k] + line1->edge[k+1]); + ++k) ; + break; + case 3: + for (k = 0; + k < line1->len && + line0->yMax <= 0.5 * (line1->edge[k] + line1->edge[k+1]); + ++k) ; + break; + } + col2 = line1->col[k]; + } + if (col2 > col1) { + col1 = col2; + } + } + for (k = 0; k <= line0->len; ++k) { + line0->col[k] += col1; + } + if (line0->col[line0->len] > nColumns) { + nColumns = line0->col[line0->len]; + } + } + } + gfree(lineArray); +} + +void TextBlock::updatePriMinMax(TextBlock *blk) { + double newPriMin, newPriMax; + GBool gotPriMin, gotPriMax; + + gotPriMin = gotPriMax = gFalse; + newPriMin = newPriMax = 0; // make gcc happy + switch (page->primaryRot) { + case 0: + case 2: + if (blk->yMin < yMax && blk->yMax > yMin) { + if (blk->xMin < xMin) { + newPriMin = blk->xMax; + gotPriMin = gTrue; + } + if (blk->xMax > xMax) { + newPriMax = blk->xMin; + gotPriMax = gTrue; + } + } + break; + case 1: + case 3: + if (blk->xMin < xMax && blk->xMax > xMin) { + if (blk->yMin < yMin) { + newPriMin = blk->yMax; + gotPriMin = gTrue; + } + if (blk->yMax > yMax) { + newPriMax = blk->yMin; + gotPriMax = gTrue; + } + } + break; + } + if (gotPriMin) { + if (newPriMin > xMin) { + newPriMin = xMin; + } + if (newPriMin > priMin) { + priMin = newPriMin; + } + } + if (gotPriMax) { + if (newPriMax < xMax) { + newPriMax = xMax; + } + if (newPriMax < priMax) { + priMax = newPriMax; + } + } +} + +int TextBlock::cmpXYPrimaryRot(const void *p1, const void *p2) { + TextBlock *blk1 = *(TextBlock **)p1; + TextBlock *blk2 = *(TextBlock **)p2; + double cmp; + + cmp = 0; // make gcc happy + switch (blk1->page->primaryRot) { + case 0: + if ((cmp = blk1->xMin - blk2->xMin) == 0) { + cmp = blk1->yMin - blk2->yMin; + } + break; + case 1: + if ((cmp = blk1->yMin - blk2->yMin) == 0) { + cmp = blk2->xMax - blk1->xMax; + } + break; + case 2: + if ((cmp = blk2->xMax - blk1->xMax) == 0) { + cmp = blk2->yMin - blk1->yMin; + } + break; + case 3: + if ((cmp = blk2->yMax - blk1->yMax) == 0) { + cmp = blk1->xMax - blk2->xMax; + } + break; + } + return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; +} + +int TextBlock::cmpYXPrimaryRot(const void *p1, const void *p2) { + TextBlock *blk1 = *(TextBlock **)p1; + TextBlock *blk2 = *(TextBlock **)p2; + double cmp; + + cmp = 0; // make gcc happy + switch (blk1->page->primaryRot) { + case 0: + if ((cmp = blk1->yMin - blk2->yMin) == 0) { + cmp = blk1->xMin - blk2->xMin; + } + break; + case 1: + if ((cmp = blk2->xMax - blk1->xMax) == 0) { + cmp = blk1->yMin - blk2->yMin; + } + break; + case 2: + if ((cmp = blk2->yMin - blk1->yMin) == 0) { + cmp = blk2->xMax - blk1->xMax; + } + break; + case 3: + if ((cmp = blk1->xMax - blk2->xMax) == 0) { + cmp = blk2->yMax - blk1->yMax; + } + break; + } + return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; +} + +int TextBlock::primaryCmp(TextBlock *blk) { + double cmp; + + cmp = 0; // make gcc happy + switch (rot) { + case 0: + cmp = xMin - blk->xMin; + break; + case 1: + cmp = yMin - blk->yMin; + break; + case 2: + cmp = blk->xMax - xMax; + break; + case 3: + cmp = blk->yMax - yMax; + break; + } + return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; +} + +double TextBlock::secondaryDelta(TextBlock *blk) { + double delta; + + delta = 0; // make gcc happy + switch (rot) { + case 0: + delta = blk->yMin - yMax; + break; + case 1: + delta = xMin - blk->xMax; + break; + case 2: + delta = yMin - blk->yMax; + break; + case 3: + delta = blk->xMin - xMax; + break; + } + return delta; +} + +GBool TextBlock::isBelow(TextBlock *blk) { + GBool below; + + below = gFalse; // make gcc happy + switch (page->primaryRot) { + case 0: + below = xMin >= blk->priMin && xMax <= blk->priMax && + yMin > blk->yMin; + break; + case 1: + below = yMin >= blk->priMin && yMax <= blk->priMax && + xMax < blk->xMax; + break; + case 2: + below = xMin >= blk->priMin && xMax <= blk->priMax && + yMax < blk->yMax; + break; + case 3: + below = yMin >= blk->priMin && yMax <= blk->priMax && + xMin > blk->xMin; + break; + } + + return below; +} + +GBool TextBlock::isBeforeByRule1(TextBlock *blk1) { + GBool before = gFalse; + GBool overlap = gFalse; + + switch (this->page->primaryRot) { + case 0: + case 2: + overlap = ((this->ExMin <= blk1->ExMin) && + (blk1->ExMin <= this->ExMax)) || + ((blk1->ExMin <= this->ExMin) && + (this->ExMin <= blk1->ExMax)); + break; + case 1: + case 3: + overlap = ((this->EyMin <= blk1->EyMin) && + (blk1->EyMin <= this->EyMax)) || + ((blk1->EyMin <= this->EyMin) && + (this->EyMin <= blk1->EyMax)); + break; + } + switch (this->page->primaryRot) { + case 0: + before = overlap && this->EyMin < blk1->EyMin; + break; + case 1: + before = overlap && this->ExMax > blk1->ExMax; + break; + case 2: + before = overlap && this->EyMax > blk1->EyMax; + break; + case 3: + before = overlap && this->ExMin < blk1->ExMin; + break; + } + return before; +} + +GBool TextBlock::isBeforeByRule2(TextBlock *blk1) { + double cmp = 0; + int rotLR = rot; + + if (!page->primaryLR) { + rotLR = (rotLR + 2) % 4; + } + + switch (rotLR) { + case 0: + cmp = ExMax - blk1->ExMin; + break; + case 1: + cmp = EyMin - blk1->EyMax; + break; + case 2: + cmp = blk1->ExMax - ExMin; + break; + case 3: + cmp = blk1->EyMin - EyMax; + break; + } + return cmp <= 0; +} + +// Sort into reading order by performing a topological sort using the rules +// given in "High Performance Document Layout Analysis", T.M. Breuel, 2003. +// See http://pubs.iupr.org/#2003-breuel-sdiut +// Topological sort is done by depth first search, see +// http://en.wikipedia.org/wiki/Topological_sorting +int TextBlock::visitDepthFirst(TextBlock *blkList, int pos1, + TextBlock **sorted, int sortPos, + GBool* visited) { + int pos2; + TextBlock *blk1, *blk2, *blk3; + GBool before; + + if (visited[pos1]) { + return sortPos; + } + + blk1 = this; + +#if 0 // for debugging + printf("visited: %d %.2f..%.2f %.2f..%.2f\n", + sortPos, blk1->ExMin, blk1->ExMax, blk1->EyMin, blk1->EyMax); +#endif + visited[pos1] = gTrue; + pos2 = -1; + for (blk2 = blkList; blk2; blk2 = blk2->next) { + pos2++; + if (visited[pos2]) { + // skip visited nodes + continue; + } + before = gFalse; + + // is blk2 before blk1? (for table entries) + if (blk1->tableId >= 0 && blk1->tableId == blk2->tableId) { + if (page->primaryLR) { + if (blk2->xMax <= blk1->xMin && + blk2->yMin <= blk1->yMax && + blk2->yMax >= blk1->yMin) + before = gTrue; + } else { + if (blk2->xMin >= blk1->xMax && + blk2->yMin <= blk1->yMax && + blk2->yMax >= blk1->yMin) + before = gTrue; + } + + if (blk2->yMax <= blk1->yMin) + before = gTrue; + } else { + if (blk2->isBeforeByRule1(blk1)) { + // Rule (1) blk1 and blk2 overlap, and blk2 is above blk1. + before = gTrue; +#if 0 // for debugging + printf("rule1: %.2f..%.2f %.2f..%.2f %.2f..%.2f %.2f..%.2f\n", + blk2->ExMin, blk2->ExMax, blk2->EyMin, blk2->EyMax, + blk1->ExMin, blk1->ExMax, blk1->EyMin, blk1->EyMax); +#endif + } else if (blk2->isBeforeByRule2(blk1)) { + // Rule (2) blk2 left of blk1, and no intervening blk3 + // such that blk1 is before blk3 by rule 1, + // and blk3 is before blk2 by rule 1. + before = gTrue; + for (blk3 = blkList; blk3; blk3 = blk3->next) { + if (blk3 == blk2 || blk3 == blk1) { + continue; + } + if (blk1->isBeforeByRule1(blk3) && + blk3->isBeforeByRule1(blk2)) { + before = gFalse; + break; + } + } +#if 0 // for debugging + if (before) { + printf("rule2: %.2f..%.2f %.2f..%.2f %.2f..%.2f %.2f..%.2f\n", + blk1->ExMin, blk1->ExMax, blk1->EyMin, blk1->EyMax, + blk2->ExMin, blk2->ExMax, blk2->EyMin, blk2->EyMax); + } +#endif + } + } + if (before) { + // blk2 is before blk1, so it needs to be visited + // before we can add blk1 to the sorted list. + sortPos = blk2->visitDepthFirst(blkList, pos2, sorted, sortPos, visited); + } + } +#if 0 // for debugging + printf("sorted: %d %.2f..%.2f %.2f..%.2f\n", + sortPos, blk1->ExMin, blk1->ExMax, blk1->EyMin, blk1->EyMax); +#endif + sorted[sortPos++] = blk1; + return sortPos; +} + +//------------------------------------------------------------------------ +// TextFlow +//------------------------------------------------------------------------ + +TextFlow::TextFlow(TextPage *pageA, TextBlock *blk) { + page = pageA; + xMin = blk->xMin; + xMax = blk->xMax; + yMin = blk->yMin; + yMax = blk->yMax; + priMin = blk->priMin; + priMax = blk->priMax; + blocks = lastBlk = blk; + next = NULL; +} + +TextFlow::~TextFlow() { + TextBlock *blk; + + while (blocks) { + blk = blocks; + blocks = blocks->next; + delete blk; + } +} + +void TextFlow::addBlock(TextBlock *blk) { + if (lastBlk) { + lastBlk->next = blk; + } else { + blocks = blk; + } + lastBlk = blk; + if (blk->xMin < xMin) { + xMin = blk->xMin; + } + if (blk->xMax > xMax) { + xMax = blk->xMax; + } + if (blk->yMin < yMin) { + yMin = blk->yMin; + } + if (blk->yMax > yMax) { + yMax = blk->yMax; + } +} + +GBool TextFlow::blockFits(TextBlock *blk, TextBlock *prevBlk) { + GBool fits; + + // lower blocks must use smaller fonts + if (blk->lines->words->fontSize > lastBlk->lines->words->fontSize) { + return gFalse; + } + + fits = gFalse; // make gcc happy + switch (page->primaryRot) { + case 0: + fits = blk->xMin >= priMin && blk->xMax <= priMax; + break; + case 1: + fits = blk->yMin >= priMin && blk->yMax <= priMax; + break; + case 2: + fits = blk->xMin >= priMin && blk->xMax <= priMax; + break; + case 3: + fits = blk->yMin >= priMin && blk->yMax <= priMax; + break; + } + return fits; +} + +#if TEXTOUT_WORD_LIST + +//------------------------------------------------------------------------ +// TextWordList +//------------------------------------------------------------------------ + +TextWordList::TextWordList(TextPage *text, GBool physLayout) { + TextFlow *flow; + TextBlock *blk; + TextLine *line; + TextWord *word; + TextWord **wordArray; + int nWords, i; + + words = new GooList(); + + if (text->rawOrder) { + for (word = text->rawWords; word; word = word->next) { + words->append(word); + } + + } else if (physLayout) { + // this is inefficient, but it's also the least useful of these + // three cases + nWords = 0; + for (flow = text->flows; flow; flow = flow->next) { + for (blk = flow->blocks; blk; blk = blk->next) { + for (line = blk->lines; line; line = line->next) { + for (word = line->words; word; word = word->next) { + ++nWords; + } + } + } + } + wordArray = (TextWord **)gmallocn(nWords, sizeof(TextWord *)); + i = 0; + for (flow = text->flows; flow; flow = flow->next) { + for (blk = flow->blocks; blk; blk = blk->next) { + for (line = blk->lines; line; line = line->next) { + for (word = line->words; word; word = word->next) { + wordArray[i++] = word; + } + } + } + } + qsort(wordArray, nWords, sizeof(TextWord *), &TextWord::cmpYX); + for (i = 0; i < nWords; ++i) { + words->append(wordArray[i]); + } + gfree(wordArray); + + } else { + for (flow = text->flows; flow; flow = flow->next) { + for (blk = flow->blocks; blk; blk = blk->next) { + for (line = blk->lines; line; line = line->next) { + for (word = line->words; word; word = word->next) { + words->append(word); + } + } + } + } + } +} + +TextWordList::~TextWordList() { + delete words; +} + +int TextWordList::getLength() { + return words->getLength(); +} + +TextWord *TextWordList::get(int idx) { + if (idx < 0 || idx >= words->getLength()) { + return NULL; + } + return (TextWord *)words->get(idx); +} + +#endif // TEXTOUT_WORD_LIST + +//------------------------------------------------------------------------ +// TextPage +//------------------------------------------------------------------------ + +TextPage::TextPage(GBool rawOrderA) { + int rot; + + refCnt = 1; + rawOrder = rawOrderA; + curWord = NULL; + charPos = 0; + curFont = NULL; + curFontSize = 0; + nest = 0; + nTinyChars = 0; + lastCharOverlap = gFalse; + if (!rawOrder) { + for (rot = 0; rot < 4; ++rot) { + pools[rot] = new TextPool(); + } + } + flows = NULL; + blocks = NULL; + rawWords = NULL; + rawLastWord = NULL; + fonts = new GooList(); + lastFindXMin = lastFindYMin = 0; + haveLastFind = gFalse; + underlines = new GooList(); + links = new GooList(); + mergeCombining = gTrue; +} + +TextPage::~TextPage() { + int rot; + + clear(); + if (!rawOrder) { + for (rot = 0; rot < 4; ++rot) { + delete pools[rot]; + } + } + delete fonts; + deleteGooList(underlines, TextUnderline); + deleteGooList(links, TextLink); +} + +void TextPage::incRefCnt() { + refCnt++; +} + +void TextPage::decRefCnt() { + if (--refCnt == 0) + delete this; +} + +void TextPage::startPage(GfxState *state) { + clear(); + if (state) { + pageWidth = state->getPageWidth(); + pageHeight = state->getPageHeight(); + } else { + pageWidth = pageHeight = 0; + } +} + +void TextPage::endPage() { + if (curWord) { + endWord(); + } +} + +void TextPage::clear() { + int rot; + TextFlow *flow; + TextWord *word; + + if (curWord) { + delete curWord; + curWord = NULL; + } + if (rawOrder) { + while (rawWords) { + word = rawWords; + rawWords = rawWords->next; + delete word; + } + } else { + for (rot = 0; rot < 4; ++rot) { + delete pools[rot]; + } + while (flows) { + flow = flows; + flows = flows->next; + delete flow; + } + gfree(blocks); + } + deleteGooList(fonts, TextFontInfo); + deleteGooList(underlines, TextUnderline); + deleteGooList(links, TextLink); + + curWord = NULL; + charPos = 0; + curFont = NULL; + curFontSize = 0; + nest = 0; + nTinyChars = 0; + if (!rawOrder) { + for (rot = 0; rot < 4; ++rot) { + pools[rot] = new TextPool(); + } + } + flows = NULL; + blocks = NULL; + rawWords = NULL; + rawLastWord = NULL; + fonts = new GooList(); + underlines = new GooList(); + links = new GooList(); +} + +void TextPage::updateFont(GfxState *state) { + GfxFont *gfxFont; + double *fm; + char *name; + int code, mCode, letterCode, anyCode; + double w; + int i; + + // get the font info object + curFont = NULL; + for (i = 0; i < fonts->getLength(); ++i) { + curFont = (TextFontInfo *)fonts->get(i); + if (curFont->matches(state)) { + break; + } + curFont = NULL; + } + if (!curFont) { + curFont = new TextFontInfo(state); + fonts->append(curFont); + } + + // adjust the font size + gfxFont = state->getFont(); + curFontSize = state->getTransformedFontSize(); + if (gfxFont && gfxFont->getType() == fontType3) { + // This is a hack which makes it possible to deal with some Type 3 + // fonts. The problem is that it's impossible to know what the + // base coordinate system used in the font is without actually + // rendering the font. This code tries to guess by looking at the + // width of the character 'm' (which breaks if the font is a + // subset that doesn't contain 'm'). + mCode = letterCode = anyCode = -1; + for (code = 0; code < 256; ++code) { + name = ((Gfx8BitFont *)gfxFont)->getCharName(code); + int nameLen = name ? strlen(name) : 0; + GBool nameOneChar = nameLen == 1 || (nameLen > 1 && name[1] == '\0'); + if (nameOneChar && name[0] == 'm') { + mCode = code; + } + if (letterCode < 0 && nameOneChar && + ((name[0] >= 'A' && name[0] <= 'Z') || + (name[0] >= 'a' && name[0] <= 'z'))) { + letterCode = code; + } + if (anyCode < 0 && name && + ((Gfx8BitFont *)gfxFont)->getWidth(code) > 0) { + anyCode = code; + } + } + if (mCode >= 0 && + (w = ((Gfx8BitFont *)gfxFont)->getWidth(mCode)) > 0) { + // 0.6 is a generic average 'm' width -- yes, this is a hack + curFontSize *= w / 0.6; + } else if (letterCode >= 0 && + (w = ((Gfx8BitFont *)gfxFont)->getWidth(letterCode)) > 0) { + // even more of a hack: 0.5 is a generic letter width + curFontSize *= w / 0.5; + } else if (anyCode >= 0 && + (w = ((Gfx8BitFont *)gfxFont)->getWidth(anyCode)) > 0) { + // better than nothing: 0.5 is a generic character width + curFontSize *= w / 0.5; + } + fm = gfxFont->getFontMatrix(); + if (fm[0] != 0) { + curFontSize *= fabs(fm[3] / fm[0]); + } + } +} + +void TextPage::beginWord(GfxState *state) { + GfxFont *gfxFont; + double *fontm; + double m[4], m2[4]; + int rot; + + // This check is needed because Type 3 characters can contain + // text-drawing operations (when TextPage is being used via + // {X,Win}SplashOutputDev rather than TextOutputDev). + if (curWord) { + ++nest; + return; + } + + // compute the rotation + state->getFontTransMat(&m[0], &m[1], &m[2], &m[3]); + gfxFont = state->getFont(); + if (gfxFont && gfxFont->getType() == fontType3) { + fontm = state->getFont()->getFontMatrix(); + m2[0] = fontm[0] * m[0] + fontm[1] * m[2]; + m2[1] = fontm[0] * m[1] + fontm[1] * m[3]; + m2[2] = fontm[2] * m[0] + fontm[3] * m[2]; + m2[3] = fontm[2] * m[1] + fontm[3] * m[3]; + m[0] = m2[0]; + m[1] = m2[1]; + m[2] = m2[2]; + m[3] = m2[3]; + } + if (fabs(m[0] * m[3]) > fabs(m[1] * m[2])) { + rot = (m[0] > 0 || m[3] < 0) ? 0 : 2; + } else { + rot = (m[2] > 0) ? 1 : 3; + } + + // for vertical writing mode, the lines are effectively rotated 90 + // degrees + if (gfxFont && gfxFont->getWMode()) { + rot = (rot + 1) & 3; + } + + curWord = new TextWord(state, rot, curFontSize); +} + +void TextPage::addChar(GfxState *state, double x, double y, + double dx, double dy, + CharCode c, int nBytes, Unicode *u, int uLen) { + double x1, y1, w1, h1, dx2, dy2, base, sp, delta; + GBool overlap; + int i; + int wMode; + Matrix mat; + + // subtract char and word spacing from the dx,dy values + sp = state->getCharSpace(); + if (c == (CharCode)0x20) { + sp += state->getWordSpace(); + } + state->textTransformDelta(sp * state->getHorizScaling(), 0, &dx2, &dy2); + dx -= dx2; + dy -= dy2; + state->transformDelta(dx, dy, &w1, &h1); + + // throw away chars that aren't inside the page bounds + // (and also do a sanity check on the character size) + state->transform(x, y, &x1, &y1); + if (x1 + w1 < 0 || x1 > pageWidth || + y1 + h1 < 0 || y1 > pageHeight || + x1 != x1 || y1 != y1 || // IEEE way of checking for isnan + w1 != w1 || h1 != h1) { + charPos += nBytes; + return; + } + + // check the tiny chars limit + if (!globalParams->getTextKeepTinyChars() && + fabs(w1) < 3 && fabs(h1) < 3) { + if (++nTinyChars > 50000) { + charPos += nBytes; + return; + } + } + + // break words at space character + if (uLen == 1 && u[0] == (Unicode)0x20) { + charPos += nBytes; + endWord(); + return; + } + + state->getFontTransMat(&mat.m[0], &mat.m[1], &mat.m[2], &mat.m[3]); + mat.m[4] = x1; + mat.m[5] = y1; + + if (mergeCombining && curWord && uLen == 1 && + curWord->addCombining(state, curFont, curFontSize, x1, y1, w1, h1, charPos, nBytes, c, + u[0], mat)) { + charPos += nBytes; + return; + } + + // start a new word if: + // (1) this character doesn't fall in the right place relative to + // the end of the previous word (this places upper and lower + // constraints on the position deltas along both the primary + // and secondary axes), or + // (2) this character overlaps the previous one (duplicated text), or + // (3) the previous character was an overlap (we want each duplicated + // character to be in a word by itself at this stage), + // (4) the font size has changed + // (5) the WMode changed + if (curWord && curWord->len > 0) { + base = sp = delta = 0; // make gcc happy + switch (curWord->rot) { + case 0: + base = y1; + sp = x1 - curWord->xMax; + delta = x1 - curWord->edge[curWord->len - 1]; + break; + case 1: + base = x1; + sp = y1 - curWord->yMax; + delta = y1 - curWord->edge[curWord->len - 1]; + break; + case 2: + base = y1; + sp = curWord->xMin - x1; + delta = curWord->edge[curWord->len - 1] - x1; + break; + case 3: + base = x1; + sp = curWord->yMin - y1; + delta = curWord->edge[curWord->len - 1] - y1; + break; + } + overlap = fabs(delta) < dupMaxPriDelta * curWord->fontSize && + fabs(base - curWord->base) < dupMaxSecDelta * curWord->fontSize; + wMode = curFont->getWMode(); + if (overlap || lastCharOverlap || + sp < -minDupBreakOverlap * curWord->fontSize || + sp > minWordBreakSpace * curWord->fontSize || + fabs(base - curWord->base) > 0.5 || + curFontSize != curWord->fontSize || + wMode != curWord->wMode) { + endWord(); + } + lastCharOverlap = overlap; + } else { + lastCharOverlap = gFalse; + } + + if (uLen != 0) { + // start a new word if needed + if (!curWord) { + beginWord(state); + } + + // page rotation and/or transform matrices can cause text to be + // drawn in reverse order -- in this case, swap the begin/end + // coordinates and break text into individual chars + if ((curWord->rot == 0 && w1 < 0) || + (curWord->rot == 1 && h1 < 0) || + (curWord->rot == 2 && w1 > 0) || + (curWord->rot == 3 && h1 > 0)) { + endWord(); + beginWord(state); + x1 += w1; + y1 += h1; + w1 = -w1; + h1 = -h1; + } + + // add the characters to the current word + w1 /= uLen; + h1 /= uLen; + for (i = 0; i < uLen; ++i) { + curWord->addChar(state, curFont, x1 + i*w1, y1 + i*h1, w1, h1, charPos, nBytes, c, u[i], mat); + } + } + charPos += nBytes; +} + +void TextPage::incCharCount(int nChars) { + charPos += nChars; +} + +void TextPage::endWord() { + // This check is needed because Type 3 characters can contain + // text-drawing operations (when TextPage is being used via + // {X,Win}SplashOutputDev rather than TextOutputDev). + if (nest > 0) { + --nest; + return; + } + + if (curWord) { + addWord(curWord); + curWord = NULL; + } +} + +void TextPage::addWord(TextWord *word) { + // throw away zero-length words -- they don't have valid xMin/xMax + // values, and they're useless anyway + if (word->len == 0) { + delete word; + return; + } + + if (rawOrder) { + if (rawLastWord) { + rawLastWord->next = word; + } else { + rawWords = word; + } + rawLastWord = word; + } else { + pools[word->rot]->addWord(word); + } +} + +void TextPage::addUnderline(double x0, double y0, double x1, double y1) { + underlines->append(new TextUnderline(x0, y0, x1, y1)); +} + +void TextPage::addLink(int xMin, int yMin, int xMax, int yMax, AnnotLink *link) { + links->append(new TextLink(xMin, yMin, xMax, yMax, link)); +} + +void TextPage::coalesce(GBool physLayout, double fixedPitch, GBool doHTML) { + UnicodeMap *uMap; + TextPool *pool; + TextWord *word0, *word1, *word2; + TextLine *line; + TextBlock *blkList, *blk, *lastBlk, *blk0, *blk1, *blk2; + TextFlow *flow, *lastFlow; + TextUnderline *underline; + TextLink *link; + int rot, poolMinBaseIdx, baseIdx, startBaseIdx, endBaseIdx; + double minBase, maxBase, newMinBase, newMaxBase; + double fontSize, colSpace1, colSpace2, lineSpace, intraLineSpace, blkSpace; + GBool found; + int count[4]; + int lrCount; + int col1, col2; + int i, j, n; + + if (rawOrder) { + primaryRot = 0; + primaryLR = gTrue; + return; + } + + uMap = globalParams->getTextEncoding(); + blkList = NULL; + lastBlk = NULL; + nBlocks = 0; + primaryRot = 0; + +#if 0 // for debugging + printf("*** initial words ***\n"); + for (rot = 0; rot < 4; ++rot) { + pool = pools[rot]; + for (baseIdx = pool->minBaseIdx; baseIdx <= pool->maxBaseIdx; ++baseIdx) { + for (word0 = pool->getPool(baseIdx); word0; word0 = word0->next) { + printf(" word: x=%.2f..%.2f y=%.2f..%.2f base=%.2f fontSize=%.2f rot=%d link=%p '", + word0->xMin, word0->xMax, word0->yMin, word0->yMax, + word0->base, word0->fontSize, rot*90, word0->link); + for (i = 0; i < word0->len; ++i) { + fputc(word0->text[i] & 0xff, stdout); + } + printf("'\n"); + } + } + } + printf("\n"); +#endif + +#if 0 //~ for debugging + for (i = 0; i < underlines->getLength(); ++i) { + underline = (TextUnderline *)underlines->get(i); + printf("underline: x=%g..%g y=%g..%g horiz=%d\n", + underline->x0, underline->x1, underline->y0, underline->y1, + underline->horiz); + } +#endif + + if (doHTML) { + + //----- handle underlining + for (i = 0; i < underlines->getLength(); ++i) { + underline = (TextUnderline *)underlines->get(i); + if (underline->horiz) { + // rot = 0 + if (pools[0]->minBaseIdx <= pools[0]->maxBaseIdx) { + startBaseIdx = pools[0]->getBaseIdx(underline->y0 + minUnderlineGap); + endBaseIdx = pools[0]->getBaseIdx(underline->y0 + maxUnderlineGap); + for (j = startBaseIdx; j <= endBaseIdx; ++j) { + for (word0 = pools[0]->getPool(j); word0; word0 = word0->next) { + //~ need to check the y value against the word baseline + if (underline->x0 < word0->xMin + underlineSlack && + word0->xMax - underlineSlack < underline->x1) { + word0->underlined = gTrue; + } + } + } + } + + // rot = 2 + if (pools[2]->minBaseIdx <= pools[2]->maxBaseIdx) { + startBaseIdx = pools[2]->getBaseIdx(underline->y0 - maxUnderlineGap); + endBaseIdx = pools[2]->getBaseIdx(underline->y0 - minUnderlineGap); + for (j = startBaseIdx; j <= endBaseIdx; ++j) { + for (word0 = pools[2]->getPool(j); word0; word0 = word0->next) { + if (underline->x0 < word0->xMin + underlineSlack && + word0->xMax - underlineSlack < underline->x1) { + word0->underlined = gTrue; + } + } + } + } + } else { + // rot = 1 + if (pools[1]->minBaseIdx <= pools[1]->maxBaseIdx) { + startBaseIdx = pools[1]->getBaseIdx(underline->x0 - maxUnderlineGap); + endBaseIdx = pools[1]->getBaseIdx(underline->x0 - minUnderlineGap); + for (j = startBaseIdx; j <= endBaseIdx; ++j) { + for (word0 = pools[1]->getPool(j); word0; word0 = word0->next) { + if (underline->y0 < word0->yMin + underlineSlack && + word0->yMax - underlineSlack < underline->y1) { + word0->underlined = gTrue; + } + } + } + } + + // rot = 3 + if (pools[3]->minBaseIdx <= pools[3]->maxBaseIdx) { + startBaseIdx = pools[3]->getBaseIdx(underline->x0 + minUnderlineGap); + endBaseIdx = pools[3]->getBaseIdx(underline->x0 + maxUnderlineGap); + for (j = startBaseIdx; j <= endBaseIdx; ++j) { + for (word0 = pools[3]->getPool(j); word0; word0 = word0->next) { + if (underline->y0 < word0->yMin + underlineSlack && + word0->yMax - underlineSlack < underline->y1) { + word0->underlined = gTrue; + } + } + } + } + } + } + + //----- handle links + for (i = 0; i < links->getLength(); ++i) { + link = (TextLink *)links->get(i); + + // rot = 0 + if (pools[0]->minBaseIdx <= pools[0]->maxBaseIdx) { + startBaseIdx = pools[0]->getBaseIdx(link->yMin); + endBaseIdx = pools[0]->getBaseIdx(link->yMax); + for (j = startBaseIdx; j <= endBaseIdx; ++j) { + for (word0 = pools[0]->getPool(j); word0; word0 = word0->next) { + if (link->xMin < word0->xMin + hyperlinkSlack && + word0->xMax - hyperlinkSlack < link->xMax && + link->yMin < word0->yMin + hyperlinkSlack && + word0->yMax - hyperlinkSlack < link->yMax) { + word0->link = link->link; + } + } + } + } + + // rot = 2 + if (pools[2]->minBaseIdx <= pools[2]->maxBaseIdx) { + startBaseIdx = pools[2]->getBaseIdx(link->yMin); + endBaseIdx = pools[2]->getBaseIdx(link->yMax); + for (j = startBaseIdx; j <= endBaseIdx; ++j) { + for (word0 = pools[2]->getPool(j); word0; word0 = word0->next) { + if (link->xMin < word0->xMin + hyperlinkSlack && + word0->xMax - hyperlinkSlack < link->xMax && + link->yMin < word0->yMin + hyperlinkSlack && + word0->yMax - hyperlinkSlack < link->yMax) { + word0->link = link->link; + } + } + } + } + + // rot = 1 + if (pools[1]->minBaseIdx <= pools[1]->maxBaseIdx) { + startBaseIdx = pools[1]->getBaseIdx(link->xMin); + endBaseIdx = pools[1]->getBaseIdx(link->xMax); + for (j = startBaseIdx; j <= endBaseIdx; ++j) { + for (word0 = pools[1]->getPool(j); word0; word0 = word0->next) { + if (link->yMin < word0->yMin + hyperlinkSlack && + word0->yMax - hyperlinkSlack < link->yMax && + link->xMin < word0->xMin + hyperlinkSlack && + word0->xMax - hyperlinkSlack < link->xMax) { + word0->link = link->link; + } + } + } + } + + // rot = 3 + if (pools[3]->minBaseIdx <= pools[3]->maxBaseIdx) { + startBaseIdx = pools[3]->getBaseIdx(link->xMin); + endBaseIdx = pools[3]->getBaseIdx(link->xMax); + for (j = startBaseIdx; j <= endBaseIdx; ++j) { + for (word0 = pools[3]->getPool(j); word0; word0 = word0->next) { + if (link->yMin < word0->yMin + hyperlinkSlack && + word0->yMax - hyperlinkSlack < link->yMax && + link->xMin < word0->xMin + hyperlinkSlack && + word0->xMax - hyperlinkSlack < link->xMax) { + word0->link = link->link; + } + } + } + } + } + } + + //----- assemble the blocks + + //~ add an outer loop for writing mode (vertical text) + + // build blocks for each rotation value + for (rot = 0; rot < 4; ++rot) { + pool = pools[rot]; + poolMinBaseIdx = pool->minBaseIdx; + count[rot] = 0; + + // add blocks until no more words are left + while (1) { + + // find the first non-empty line in the pool + for (; + poolMinBaseIdx <= pool->maxBaseIdx && + !pool->getPool(poolMinBaseIdx); + ++poolMinBaseIdx) ; + if (poolMinBaseIdx > pool->maxBaseIdx) { + break; + } + + // look for the left-most word in the first four lines of the + // pool -- this avoids starting with a superscript word + startBaseIdx = poolMinBaseIdx; + for (baseIdx = poolMinBaseIdx + 1; + baseIdx < poolMinBaseIdx + 4 && baseIdx <= pool->maxBaseIdx; + ++baseIdx) { + if (!pool->getPool(baseIdx)) { + continue; + } + if (pool->getPool(baseIdx)->primaryCmp(pool->getPool(startBaseIdx)) + < 0) { + startBaseIdx = baseIdx; + } + } + + // create a new block + word0 = pool->getPool(startBaseIdx); + pool->setPool(startBaseIdx, word0->next); + word0->next = NULL; + blk = new TextBlock(this, rot); + blk->addWord(word0); + + fontSize = word0->fontSize; + minBase = maxBase = word0->base; + colSpace1 = minColSpacing1 * fontSize; + colSpace2 = minColSpacing2 * fontSize; + lineSpace = maxLineSpacingDelta * fontSize; + intraLineSpace = maxIntraLineDelta * fontSize; + + // add words to the block + do { + found = gFalse; + + // look for words on the line above the current top edge of + // the block + newMinBase = minBase; + for (baseIdx = pool->getBaseIdx(minBase); + baseIdx >= pool->getBaseIdx(minBase - lineSpace); + --baseIdx) { + word0 = NULL; + word1 = pool->getPool(baseIdx); + while (word1) { + if (word1->base < minBase && + word1->base >= minBase - lineSpace && + ((rot == 0 || rot == 2) + ? (word1->xMin < blk->xMax && word1->xMax > blk->xMin) + : (word1->yMin < blk->yMax && word1->yMax > blk->yMin)) && + fabs(word1->fontSize - fontSize) < + maxBlockFontSizeDelta1 * fontSize) { + word2 = word1; + if (word0) { + word0->next = word1->next; + } else { + pool->setPool(baseIdx, word1->next); + } + word1 = word1->next; + word2->next = NULL; + blk->addWord(word2); + found = gTrue; + newMinBase = word2->base; + } else { + word0 = word1; + word1 = word1->next; + } + } + } + minBase = newMinBase; + + // look for words on the line below the current bottom edge of + // the block + newMaxBase = maxBase; + for (baseIdx = pool->getBaseIdx(maxBase); + baseIdx <= pool->getBaseIdx(maxBase + lineSpace); + ++baseIdx) { + word0 = NULL; + word1 = pool->getPool(baseIdx); + while (word1) { + if (word1->base > maxBase && + word1->base <= maxBase + lineSpace && + ((rot == 0 || rot == 2) + ? (word1->xMin < blk->xMax && word1->xMax > blk->xMin) + : (word1->yMin < blk->yMax && word1->yMax > blk->yMin)) && + fabs(word1->fontSize - fontSize) < + maxBlockFontSizeDelta1 * fontSize) { + word2 = word1; + if (word0) { + word0->next = word1->next; + } else { + pool->setPool(baseIdx, word1->next); + } + word1 = word1->next; + word2->next = NULL; + blk->addWord(word2); + found = gTrue; + newMaxBase = word2->base; + } else { + word0 = word1; + word1 = word1->next; + } + } + } + maxBase = newMaxBase; + + // look for words that are on lines already in the block, and + // that overlap the block horizontally + for (baseIdx = pool->getBaseIdx(minBase - intraLineSpace); + baseIdx <= pool->getBaseIdx(maxBase + intraLineSpace); + ++baseIdx) { + word0 = NULL; + word1 = pool->getPool(baseIdx); + while (word1) { + if (word1->base >= minBase - intraLineSpace && + word1->base <= maxBase + intraLineSpace && + ((rot == 0 || rot == 2) + ? (word1->xMin < blk->xMax + colSpace1 && + word1->xMax > blk->xMin - colSpace1) + : (word1->yMin < blk->yMax + colSpace1 && + word1->yMax > blk->yMin - colSpace1)) && + fabs(word1->fontSize - fontSize) < + maxBlockFontSizeDelta2 * fontSize) { + word2 = word1; + if (word0) { + word0->next = word1->next; + } else { + pool->setPool(baseIdx, word1->next); + } + word1 = word1->next; + word2->next = NULL; + blk->addWord(word2); + found = gTrue; + } else { + word0 = word1; + word1 = word1->next; + } + } + } + + // only check for outlying words (the next two chunks of code) + // if we didn't find anything else + if (found) { + continue; + } + + // scan down the left side of the block, looking for words + // that are near (but not overlapping) the block; if there are + // three or fewer, add them to the block + n = 0; + for (baseIdx = pool->getBaseIdx(minBase - intraLineSpace); + baseIdx <= pool->getBaseIdx(maxBase + intraLineSpace); + ++baseIdx) { + word1 = pool->getPool(baseIdx); + while (word1) { + if (word1->base >= minBase - intraLineSpace && + word1->base <= maxBase + intraLineSpace && + ((rot == 0 || rot == 2) + ? (word1->xMax <= blk->xMin && + word1->xMax > blk->xMin - colSpace2) + : (word1->yMax <= blk->yMin && + word1->yMax > blk->yMin - colSpace2)) && + fabs(word1->fontSize - fontSize) < + maxBlockFontSizeDelta3 * fontSize) { + ++n; + break; + } + word1 = word1->next; + } + } + if (n > 0 && n <= 3) { + for (baseIdx = pool->getBaseIdx(minBase - intraLineSpace); + baseIdx <= pool->getBaseIdx(maxBase + intraLineSpace); + ++baseIdx) { + word0 = NULL; + word1 = pool->getPool(baseIdx); + while (word1) { + if (word1->base >= minBase - intraLineSpace && + word1->base <= maxBase + intraLineSpace && + ((rot == 0 || rot == 2) + ? (word1->xMax <= blk->xMin && + word1->xMax > blk->xMin - colSpace2) + : (word1->yMax <= blk->yMin && + word1->yMax > blk->yMin - colSpace2)) && + fabs(word1->fontSize - fontSize) < + maxBlockFontSizeDelta3 * fontSize) { + word2 = word1; + if (word0) { + word0->next = word1->next; + } else { + pool->setPool(baseIdx, word1->next); + } + word1 = word1->next; + word2->next = NULL; + blk->addWord(word2); + if (word2->base < minBase) { + minBase = word2->base; + } else if (word2->base > maxBase) { + maxBase = word2->base; + } + found = gTrue; + break; + } else { + word0 = word1; + word1 = word1->next; + } + } + } + } + + // scan down the right side of the block, looking for words + // that are near (but not overlapping) the block; if there are + // three or fewer, add them to the block + n = 0; + for (baseIdx = pool->getBaseIdx(minBase - intraLineSpace); + baseIdx <= pool->getBaseIdx(maxBase + intraLineSpace); + ++baseIdx) { + word1 = pool->getPool(baseIdx); + while (word1) { + if (word1->base >= minBase - intraLineSpace && + word1->base <= maxBase + intraLineSpace && + ((rot == 0 || rot == 2) + ? (word1->xMin >= blk->xMax && + word1->xMin < blk->xMax + colSpace2) + : (word1->yMin >= blk->yMax && + word1->yMin < blk->yMax + colSpace2)) && + fabs(word1->fontSize - fontSize) < + maxBlockFontSizeDelta3 * fontSize) { + ++n; + break; + } + word1 = word1->next; + } + } + if (n > 0 && n <= 3) { + for (baseIdx = pool->getBaseIdx(minBase - intraLineSpace); + baseIdx <= pool->getBaseIdx(maxBase + intraLineSpace); + ++baseIdx) { + word0 = NULL; + word1 = pool->getPool(baseIdx); + while (word1) { + if (word1->base >= minBase - intraLineSpace && + word1->base <= maxBase + intraLineSpace && + ((rot == 0 || rot == 2) + ? (word1->xMin >= blk->xMax && + word1->xMin < blk->xMax + colSpace2) + : (word1->yMin >= blk->yMax && + word1->yMin < blk->yMax + colSpace2)) && + fabs(word1->fontSize - fontSize) < + maxBlockFontSizeDelta3 * fontSize) { + word2 = word1; + if (word0) { + word0->next = word1->next; + } else { + pool->setPool(baseIdx, word1->next); + } + word1 = word1->next; + word2->next = NULL; + blk->addWord(word2); + if (word2->base < minBase) { + minBase = word2->base; + } else if (word2->base > maxBase) { + maxBase = word2->base; + } + found = gTrue; + break; + } else { + word0 = word1; + word1 = word1->next; + } + } + } + } + + } while (found); + + //~ need to compute the primary writing mode (horiz/vert) in + //~ addition to primary rotation + + // coalesce the block, and add it to the list + blk->coalesce(uMap, fixedPitch); + if (lastBlk) { + lastBlk->next = blk; + } else { + blkList = blk; + } + lastBlk = blk; + count[rot] += blk->charCount; + ++nBlocks; + } + + if (count[rot] > count[primaryRot]) { + primaryRot = rot; + } + } + +#if 0 // for debugging + printf("*** rotation ***\n"); + for (rot = 0; rot < 4; ++rot) { + printf(" %d: %6d\n", rot, count[rot]); + } + printf(" primary rot = %d\n", primaryRot); + printf("\n"); +#endif + +#if 0 // for debugging + printf("*** blocks ***\n"); + for (blk = blkList; blk; blk = blk->next) { + printf("block: rot=%d x=%.2f..%.2f y=%.2f..%.2f\n", + blk->rot, blk->xMin, blk->xMax, blk->yMin, blk->yMax); + for (line = blk->lines; line; line = line->next) { + printf(" line: x=%.2f..%.2f y=%.2f..%.2f base=%.2f\n", + line->xMin, line->xMax, line->yMin, line->yMax, line->base); + for (word0 = line->words; word0; word0 = word0->next) { + printf(" word: x=%.2f..%.2f y=%.2f..%.2f base=%.2f fontSize=%.2f space=%d: '", + word0->xMin, word0->xMax, word0->yMin, word0->yMax, + word0->base, word0->fontSize, word0->spaceAfter); + for (i = 0; i < word0->len; ++i) { + fputc(word0->text[i] & 0xff, stdout); + } + printf("'\n"); + } + } + } + printf("\n"); +#endif + + // determine the primary direction + lrCount = 0; + for (blk = blkList; blk; blk = blk->next) { + for (line = blk->lines; line; line = line->next) { + for (word0 = line->words; word0; word0 = word0->next) { + for (i = 0; i < word0->len; ++i) { + if (unicodeTypeL(word0->text[i])) { + ++lrCount; + } else if (unicodeTypeR(word0->text[i])) { + --lrCount; + } + } + } + } + } + primaryLR = lrCount >= 0; + +#if 0 // for debugging + printf("*** direction ***\n"); + printf("lrCount = %d\n", lrCount); + printf("primaryLR = %d\n", primaryLR); +#endif + + //----- column assignment + + // sort blocks into xy order for column assignment + if (blocks) + gfree (blocks); + if (physLayout && fixedPitch) { + + blocks = (TextBlock **)gmallocn(nBlocks, sizeof(TextBlock *)); + for (blk = blkList, i = 0; blk; blk = blk->next, ++i) { + blocks[i] = blk; + col1 = 0; // make gcc happy + switch (primaryRot) { + case 0: + col1 = (int)(blk->xMin / fixedPitch + 0.5); + break; + case 1: + col1 = (int)(blk->yMin / fixedPitch + 0.5); + break; + case 2: + col1 = (int)((pageWidth - blk->xMax) / fixedPitch + 0.5); + break; + case 3: + col1 = (int)((pageHeight - blk->yMax) / fixedPitch + 0.5); + break; + } + blk->col = col1; + for (line = blk->lines; line; line = line->next) { + for (j = 0; j <= line->len; ++j) { + line->col[j] += col1; + } + } + } + + } else { + + // sort blocks into xy order for column assignment + blocks = (TextBlock **)gmallocn(nBlocks, sizeof(TextBlock *)); + for (blk = blkList, i = 0; blk; blk = blk->next, ++i) { + blocks[i] = blk; + } + qsort(blocks, nBlocks, sizeof(TextBlock *), &TextBlock::cmpXYPrimaryRot); + + // column assignment + for (i = 0; i < nBlocks; ++i) { + blk0 = blocks[i]; + col1 = 0; + for (j = 0; j < i; ++j) { + blk1 = blocks[j]; + col2 = 0; // make gcc happy + switch (primaryRot) { + case 0: + if (blk0->xMin > blk1->xMax) { + col2 = blk1->col + blk1->nColumns + 3; + } else if (blk1->xMax == blk1->xMin) { + col2 = blk1->col; + } else { + col2 = blk1->col + (int)(((blk0->xMin - blk1->xMin) / + (blk1->xMax - blk1->xMin)) * + blk1->nColumns); + } + break; + case 1: + if (blk0->yMin > blk1->yMax) { + col2 = blk1->col + blk1->nColumns + 3; + } else if (blk1->yMax == blk1->yMin) { + col2 = blk1->col; + } else { + col2 = blk1->col + (int)(((blk0->yMin - blk1->yMin) / + (blk1->yMax - blk1->yMin)) * + blk1->nColumns); + } + break; + case 2: + if (blk0->xMax < blk1->xMin) { + col2 = blk1->col + blk1->nColumns + 3; + } else if (blk1->xMin == blk1->xMax) { + col2 = blk1->col; + } else { + col2 = blk1->col + (int)(((blk0->xMax - blk1->xMax) / + (blk1->xMin - blk1->xMax)) * + blk1->nColumns); + } + break; + case 3: + if (blk0->yMax < blk1->yMin) { + col2 = blk1->col + blk1->nColumns + 3; + } else if (blk1->yMin == blk1->yMax) { + col2 = blk1->col; + } else { + col2 = blk1->col + (int)(((blk0->yMax - blk1->yMax) / + (blk1->yMin - blk1->yMax)) * + blk1->nColumns); + } + break; + } + if (col2 > col1) { + col1 = col2; + } + } + blk0->col = col1; + for (line = blk0->lines; line; line = line->next) { + for (j = 0; j <= line->len; ++j) { + line->col[j] += col1; + } + } + } + + } + +#if 0 // for debugging + printf("*** blocks, after column assignment ***\n"); + for (blk = blkList; blk; blk = blk->next) { + printf("block: rot=%d x=%.2f..%.2f y=%.2f..%.2f col=%d nCols=%d\n", + blk->rot, blk->xMin, blk->xMax, blk->yMin, blk->yMax, blk->col, + blk->nColumns); + for (line = blk->lines; line; line = line->next) { + printf(" line: col[0]=%d\n", line->col[0]); + for (word0 = line->words; word0; word0 = word0->next) { + printf(" word: x=%.2f..%.2f y=%.2f..%.2f base=%.2f fontSize=%.2f space=%d: '", + word0->xMin, word0->xMax, word0->yMin, word0->yMax, + word0->base, word0->fontSize, word0->spaceAfter); + for (i = 0; i < word0->len; ++i) { + fputc(word0->text[i] & 0xff, stdout); + } + printf("'\n"); + } + } + } + printf("\n"); +#endif + + //----- reading order sort + + // compute space on left and right sides of each block + for (i = 0; i < nBlocks; ++i) { + blk0 = blocks[i]; + for (j = 0; j < nBlocks; ++j) { + blk1 = blocks[j]; + if (blk1 != blk0) { + blk0->updatePriMinMax(blk1); + } + } + } + +#if 0 // for debugging + printf("PAGE\n"); +#endif + + int sortPos = 0; + GBool *visited = (GBool *)gmallocn(nBlocks, sizeof(GBool)); + for (i = 0; i < nBlocks; i++) { + visited[i] = gFalse; + } + + double bxMin0, byMin0, bxMin1, byMin1; + int numTables = 0; + int tableId = -1; + int correspondenceX, correspondenceY; + double xCentre1, yCentre1, xCentre2, yCentre2; + double xCentre3, yCentre3, xCentre4, yCentre4; + double deltaX, deltaY; + TextBlock *fblk2 = NULL, *fblk3 = NULL, *fblk4 = NULL; + + for (blk1 = blkList; blk1; blk1 = blk1->next) { + blk1->ExMin = blk1->xMin; + blk1->ExMax = blk1->xMax; + blk1->EyMin = blk1->yMin; + blk1->EyMax = blk1->yMax; + + bxMin0 = DBL_MAX; + byMin0 = DBL_MAX; + bxMin1 = DBL_MAX; + byMin1 = DBL_MAX; + + fblk2 = NULL; + fblk3 = NULL; + fblk4 = NULL; + + /* find fblk2, fblk3 and fblk4 so that + * fblk2 is on the right of blk1 and overlap with blk1 in y axis + * fblk3 is under blk1 and overlap with blk1 in x axis + * fblk4 is under blk1 and on the right of blk1 + * and they are closest to blk1 + */ + for (blk2 = blkList; blk2; blk2 = blk2->next) { + if (blk2 != blk1) { + if (blk2->yMin <= blk1->yMax && + blk2->yMax >= blk1->yMin && + blk2->xMin > blk1->xMax && + blk2->xMin < bxMin0) { + bxMin0 = blk2->xMin; + fblk2 = blk2; + } else if (blk2->xMin <= blk1->xMax && + blk2->xMax >= blk1->xMin && + blk2->yMin > blk1->yMax && + blk2->yMin < byMin0) { + byMin0 = blk2->yMin; + fblk3 = blk2; + } else if (blk2->xMin > blk1->xMax && + blk2->xMin < bxMin1 && + blk2->yMin > blk1->yMax && + blk2->yMin < byMin1) { + bxMin1 = blk2->xMin; + byMin1 = blk2->yMin; + fblk4 = blk2; + } + } + } + + /* fblk4 can not overlap with fblk3 in x and with fblk2 in y + * fblk2 can not overlap with fblk3 in x and y + * fblk4 has to overlap with fblk3 in y and with fblk2 in x + */ + if (fblk2 != NULL && + fblk3 != NULL && + fblk4 != NULL) { + if (((fblk3->xMin <= fblk4->xMax && fblk3->xMax >= fblk4->xMin) || + (fblk2->yMin <= fblk4->yMax && fblk2->yMax >= fblk4->yMin) || + (fblk2->xMin <= fblk3->xMax && fblk2->xMax >= fblk3->xMin) || + (fblk2->yMin <= fblk3->yMax && fblk2->yMax >= fblk3->yMin)) || + !(fblk4->xMin <= fblk2->xMax && fblk4->xMax >= fblk2->xMin && + fblk4->yMin <= fblk3->yMax && fblk4->yMax >= fblk3->yMin)) { + fblk2 = NULL; + fblk3 = NULL; + fblk4 = NULL; + } + } + + // if we found any then look whether they form a table + if (fblk2 != NULL && + fblk3 != NULL && + fblk4 != NULL) { + tableId = -1; + correspondenceX = 0; + correspondenceY = 0; + deltaX = 0.0; + deltaY = 0.0; + + if (blk1->lines && blk1->lines->words) + deltaX = blk1->lines->words->getFontSize(); + if (fblk2->lines && fblk2->lines->words) + deltaX = deltaX < fblk2->lines->words->getFontSize() ? + deltaX : fblk2->lines->words->getFontSize(); + if (fblk3->lines && fblk3->lines->words) + deltaX = deltaX < fblk3->lines->words->getFontSize() ? + deltaX : fblk3->lines->words->getFontSize(); + if (fblk4->lines && fblk4->lines->words) + deltaX = deltaX < fblk4->lines->words->getFontSize() ? + deltaX : fblk4->lines->words->getFontSize(); + + deltaY = deltaX; + + deltaX *= minColSpacing1; + deltaY *= maxIntraLineDelta; + + xCentre1 = (blk1->xMax + blk1->xMin) / 2.0; + yCentre1 = (blk1->yMax + blk1->yMin) / 2.0; + xCentre2 = (fblk2->xMax + fblk2->xMin) / 2.0; + yCentre2 = (fblk2->yMax + fblk2->yMin) / 2.0; + xCentre3 = (fblk3->xMax + fblk3->xMin) / 2.0; + yCentre3 = (fblk3->yMax + fblk3->yMin) / 2.0; + xCentre4 = (fblk4->xMax + fblk4->xMin) / 2.0; + yCentre4 = (fblk4->yMax + fblk4->yMin) / 2.0; + + // are blocks centrally aligned in x ? + if (fabs (xCentre1 - xCentre3) <= deltaX && + fabs (xCentre2 - xCentre4) <= deltaX) + correspondenceX++; + + // are blocks centrally aligned in y ? + if (fabs (yCentre1 - yCentre2) <= deltaY && + fabs (yCentre3 - yCentre4) <= deltaY) + correspondenceY++; + + // are blocks aligned to the left ? + if (fabs (blk1->xMin - fblk3->xMin) <= deltaX && + fabs (fblk2->xMin - fblk4->xMin) <= deltaX) + correspondenceX++; + + // are blocks aligned to the right ? + if (fabs (blk1->xMax - fblk3->xMax) <= deltaX && + fabs (fblk2->xMax - fblk4->xMax) <= deltaX) + correspondenceX++; + + // are blocks aligned to the top ? + if (fabs (blk1->yMin - fblk2->yMin) <= deltaY && + fabs (fblk3->yMin - fblk4->yMin) <= deltaY) + correspondenceY++; + + // are blocks aligned to the bottom ? + if (fabs (blk1->yMax - fblk2->yMax) <= deltaY && + fabs (fblk3->yMax - fblk4->yMax) <= deltaY) + correspondenceY++; + + // are blocks aligned in x and y ? + if (correspondenceX > 0 && + correspondenceY > 0) { + + // find maximal tableId + tableId = tableId < fblk4->tableId ? fblk4->tableId : tableId; + tableId = tableId < fblk3->tableId ? fblk3->tableId : tableId; + tableId = tableId < fblk2->tableId ? fblk2->tableId : tableId; + tableId = tableId < blk1->tableId ? blk1->tableId : tableId; + + // if the tableId is -1, then we found new table + if (tableId < 0) { + tableId = numTables; + numTables++; + } + + blk1->tableId = tableId; + fblk2->tableId = tableId; + fblk3->tableId = tableId; + fblk4->tableId = tableId; + } + } + } + + /* set extended bounding boxes of all table entries + * so that they contain whole table + * (we need to process whole table size when comparing it + * with regular text blocks) + */ + PDFRectangle *envelopes = new PDFRectangle [numTables]; + TextBlock **ending_blocks = new TextBlock* [numTables]; + + for (i = 0; i < numTables; i++) { + envelopes[i].x1 = DBL_MAX; + envelopes[i].x2 = DBL_MIN; + envelopes[i].y1 = DBL_MAX; + envelopes[i].y2 = DBL_MIN; + } + + for (blk1 = blkList; blk1; blk1 = blk1->next) { + if (blk1->tableId >= 0) { + if (blk1->ExMin < envelopes[blk1->tableId].x1) { + envelopes[blk1->tableId].x1 = blk1->ExMin; + if (!blk1->page->primaryLR) + ending_blocks[blk1->tableId] = blk1; + } + + if (blk1->ExMax > envelopes[blk1->tableId].x2) { + envelopes[blk1->tableId].x2 = blk1->ExMax; + if (blk1->page->primaryLR) + ending_blocks[blk1->tableId] = blk1; + } + + envelopes[blk1->tableId].y1 = blk1->EyMin < envelopes[blk1->tableId].y1 ? + blk1->EyMin : envelopes[blk1->tableId].y1; + envelopes[blk1->tableId].y2 = blk1->EyMax > envelopes[blk1->tableId].y2 ? + blk1->EyMax : envelopes[blk1->tableId].y2; + } + } + + for (blk1 = blkList; blk1; blk1 = blk1->next) { + if (blk1->tableId >= 0 && + blk1->xMin <= ending_blocks[blk1->tableId]->xMax && + blk1->xMax >= ending_blocks[blk1->tableId]->xMin) { + blk1->tableEnd = gTrue; + } + } + + for (blk1 = blkList; blk1; blk1 = blk1->next) { + if (blk1->tableId >= 0) { + blk1->ExMin = envelopes[blk1->tableId].x1; + blk1->ExMax = envelopes[blk1->tableId].x2; + blk1->EyMin = envelopes[blk1->tableId].y1; + blk1->EyMax = envelopes[blk1->tableId].y2; + } + } + delete[] envelopes; + delete[] ending_blocks; + + + /* set extended bounding boxes of all other blocks + * so that they extend in x without hitting neighbours + */ + for (blk1 = blkList; blk1; blk1 = blk1->next) { + if (!(blk1->tableId >= 0)) { + double xMax = DBL_MAX; + double xMin = DBL_MIN; + + for (blk2 = blkList; blk2; blk2 = blk2->next) { + if (blk2 == blk1) + continue; + + if (blk1->yMin <= blk2->yMax && blk1->yMax >= blk2->yMin) { + if (blk2->xMin < xMax && blk2->xMin > blk1->xMax) + xMax = blk2->xMin; + + if (blk2->xMax > xMin && blk2->xMax < blk1->xMin) + xMin = blk2->xMax; + } + } + + for (blk2 = blkList; blk2; blk2 = blk2->next) { + if (blk2 == blk1) + continue; + + if (blk2->xMax > blk1->ExMax && + blk2->xMax <= xMax && + blk2->yMin >= blk1->yMax) { + blk1->ExMax = blk2->xMax; + } + + if (blk2->xMin < blk1->ExMin && + blk2->xMin >= xMin && + blk2->yMin >= blk1->yMax) + blk1->ExMin = blk2->xMin; + } + } + } + + i = -1; + for (blk1 = blkList; blk1; blk1 = blk1->next) { + i++; + sortPos = blk1->visitDepthFirst(blkList, i, blocks, sortPos, visited); + } + if (visited) { + gfree(visited); + } + +#if 0 // for debugging + printf("*** blocks, after ro sort ***\n"); + for (i = 0; i < nBlocks; ++i) { + blk = blocks[i]; + printf("block: rot=%d x=%.2f..%.2f y=%.2f..%.2f space=%.2f..%.2f\n", + blk->rot, blk->xMin, blk->xMax, blk->yMin, blk->yMax, + blk->priMin, blk->priMax); + for (line = blk->lines; line; line = line->next) { + printf(" line:\n"); + for (word0 = line->words; word0; word0 = word0->next) { + printf(" word: x=%.2f..%.2f y=%.2f..%.2f base=%.2f fontSize=%.2f space=%d: '", + word0->xMin, word0->xMax, word0->yMin, word0->yMax, + word0->base, word0->fontSize, word0->spaceAfter); + for (j = 0; j < word0->len; ++j) { + fputc(word0->text[j] & 0xff, stdout); + } + printf("'\n"); + } + } + } + printf("\n"); + fflush(stdout); +#endif + + // build the flows + //~ this needs to be adjusted for writing mode (vertical text) + //~ this also needs to account for right-to-left column ordering + flow = NULL; + while (flows) { + flow = flows; + flows = flows->next; + delete flow; + } + flows = lastFlow = NULL; + // assume blocks are already in reading order, + // and construct flows accordingly. + for (i = 0; i < nBlocks; i++) { + blk = blocks[i]; + blk->next = NULL; + if (flow) { + blk1 = blocks[i - 1]; + blkSpace = maxBlockSpacing * blk1->lines->words->fontSize; + if (blk1->secondaryDelta(blk) <= blkSpace && + blk->isBelow(blk1) && + flow->blockFits(blk, blk1)) { + flow->addBlock(blk); + continue; + } + } + flow = new TextFlow(this, blk); + if (lastFlow) { + lastFlow->next = flow; + } else { + flows = flow; + } + lastFlow = flow; + } + +#if 0 // for debugging + printf("*** flows ***\n"); + for (flow = flows; flow; flow = flow->next) { + printf("flow: x=%.2f..%.2f y=%.2f..%.2f pri:%.2f..%.2f\n", + flow->xMin, flow->xMax, flow->yMin, flow->yMax, + flow->priMin, flow->priMax); + for (blk = flow->blocks; blk; blk = blk->next) { + printf(" block: rot=%d x=%.2f..%.2f y=%.2f..%.2f pri=%.2f..%.2f\n", + blk->rot, blk->ExMin, blk->ExMax, blk->EyMin, blk->EyMax, + blk->priMin, blk->priMax); + for (line = blk->lines; line; line = line->next) { + printf(" line:\n"); + for (word0 = line->words; word0; word0 = word0->next) { + printf(" word: x=%.2f..%.2f y=%.2f..%.2f base=%.2f fontSize=%.2f space=%d: '", + word0->xMin, word0->xMax, word0->yMin, word0->yMax, + word0->base, word0->fontSize, word0->spaceAfter); + for (i = 0; i < word0->len; ++i) { + fputc(word0->text[i] & 0xff, stdout); + } + printf("'\n"); + } + } + } + } + printf("\n"); +#endif + + if (uMap) { + uMap->decRefCnt(); + } +} + +GBool TextPage::findText(Unicode *s, int len, + GBool startAtTop, GBool stopAtBottom, + GBool startAtLast, GBool stopAtLast, + GBool caseSensitive, GBool backward, + GBool wholeWord, + double *xMin, double *yMin, + double *xMax, double *yMax) { + TextBlock *blk; + TextLine *line; + Unicode *s2, *txt; + Unicode *p; + int txtSize, m, i, j, k; + double xStart, yStart, xStop, yStop; + double xMin0, yMin0, xMax0, yMax0; + double xMin1, yMin1, xMax1, yMax1; + GBool found; + + //~ needs to handle right-to-left text + + if (rawOrder) { + return gFalse; + } + + // convert the search string to uppercase + if (!caseSensitive) { + s2 = unicodeNormalizeNFKC(s, len, &len, NULL); + for (i = 0; i < len; ++i) { + s2[i] = unicodeToUpper(s2[i]); + } + } else { + s2 = unicodeNormalizeNFKC(s, len, &len, NULL); + } + + txt = NULL; + txtSize = 0; + + xStart = yStart = xStop = yStop = 0; + if (startAtLast && haveLastFind) { + xStart = lastFindXMin; + yStart = lastFindYMin; + } else if (!startAtTop) { + xStart = *xMin; + yStart = *yMin; + } + if (stopAtLast && haveLastFind) { + xStop = lastFindXMin; + yStop = lastFindYMin; + } else if (!stopAtBottom) { + xStop = *xMax; + yStop = *yMax; + } + + found = gFalse; + xMin0 = xMax0 = yMin0 = yMax0 = 0; // make gcc happy + xMin1 = xMax1 = yMin1 = yMax1 = 0; // make gcc happy + + for (i = backward ? nBlocks - 1 : 0; + backward ? i >= 0 : i < nBlocks; + i += backward ? -1 : 1) { + blk = blocks[i]; + + // check: is the block above the top limit? + // (this only works if the page's primary rotation is zero -- + // otherwise the blocks won't be sorted in the useful order) + if (!startAtTop && primaryRot == 0 && + (backward ? blk->yMin > yStart : blk->yMax < yStart)) { + continue; + } + + // check: is the block below the bottom limit? + // (this only works if the page's primary rotation is zero -- + // otherwise the blocks won't be sorted in the useful order) + if (!stopAtBottom && primaryRot == 0 && + (backward ? blk->yMax < yStop : blk->yMin > yStop)) { + break; + } + + for (line = blk->lines; line; line = line->next) { + + // check: is the line above the top limit? + // (this only works if the page's primary rotation is zero -- + // otherwise the lines won't be sorted in the useful order) + if (!startAtTop && primaryRot == 0 && + (backward ? line->yMin > yStart : line->yMin < yStart)) { + continue; + } + + // check: is the line below the bottom limit? + // (this only works if the page's primary rotation is zero -- + // otherwise the lines won't be sorted in the useful order) + if (!stopAtBottom && primaryRot == 0 && + (backward ? line->yMin < yStop : line->yMin > yStop)) { + continue; + } + + if (!line->normalized) + line->normalized = unicodeNormalizeNFKC(line->text, line->len, + &line->normalized_len, + &line->normalized_idx); + // convert the line to uppercase + m = line->normalized_len; + if (!caseSensitive) { + if (m > txtSize) { + txt = (Unicode *)greallocn(txt, m, sizeof(Unicode)); + txtSize = m; + } + for (k = 0; k < m; ++k) { + txt[k] = unicodeToUpper(line->normalized[k]); + } + } else { + txt = line->normalized; + } + + // search each position in this line + j = backward ? m - len : 0; + p = txt + j; + while (backward ? j >= 0 : j <= m - len) { + if (!wholeWord || + ((j == 0 || !unicodeTypeAlphaNum(txt[j - 1])) && + (j + len == m || !unicodeTypeAlphaNum(txt[j + len])))) { + + // compare the strings + for (k = 0; k < len; ++k) { + if (p[k] != s2[k]) { + break; + } + } + + // found it + if (k == len) { + // where s2 matches a subsequence of a compatibility equivalence + // decomposition, highlight the entire glyph, since we don't know + // the internal layout of subglyph components + int normStart = line->normalized_idx[j]; + int normAfterEnd = line->normalized_idx[j + len - 1] + 1; + switch (line->rot) { + case 0: + xMin1 = line->edge[normStart]; + xMax1 = line->edge[normAfterEnd]; + yMin1 = line->yMin; + yMax1 = line->yMax; + break; + case 1: + xMin1 = line->xMin; + xMax1 = line->xMax; + yMin1 = line->edge[normStart]; + yMax1 = line->edge[normAfterEnd]; + break; + case 2: + xMin1 = line->edge[normAfterEnd]; + xMax1 = line->edge[normStart]; + yMin1 = line->yMin; + yMax1 = line->yMax; + break; + case 3: + xMin1 = line->xMin; + xMax1 = line->xMax; + yMin1 = line->edge[normAfterEnd]; + yMax1 = line->edge[normStart]; + break; + } + if (backward) { + if ((startAtTop || + yMin1 < yStart || (yMin1 == yStart && xMin1 < xStart)) && + (stopAtBottom || + yMin1 > yStop || (yMin1 == yStop && xMin1 > xStop))) { + if (!found || + yMin1 > yMin0 || (yMin1 == yMin0 && xMin1 > xMin0)) { + xMin0 = xMin1; + xMax0 = xMax1; + yMin0 = yMin1; + yMax0 = yMax1; + found = gTrue; + } + } + } else { + if ((startAtTop || + yMin1 > yStart || (yMin1 == yStart && xMin1 > xStart)) && + (stopAtBottom || + yMin1 < yStop || (yMin1 == yStop && xMin1 < xStop))) { + if (!found || + yMin1 < yMin0 || (yMin1 == yMin0 && xMin1 < xMin0)) { + xMin0 = xMin1; + xMax0 = xMax1; + yMin0 = yMin1; + yMax0 = yMax1; + found = gTrue; + } + } + } + } + } + if (backward) { + --j; + --p; + } else { + ++j; + ++p; + } + } + } + } + + gfree(s2); + if (!caseSensitive) { + gfree(txt); + } + + if (found) { + *xMin = xMin0; + *xMax = xMax0; + *yMin = yMin0; + *yMax = yMax0; + lastFindXMin = xMin0; + lastFindYMin = yMin0; + haveLastFind = gTrue; + return gTrue; + } + + return gFalse; +} + +GooString *TextPage::getText(double xMin, double yMin, + double xMax, double yMax) { + GooString *s; + UnicodeMap *uMap; + TextBlock *blk; + TextLine *line; + TextLineFrag *frags; + int nFrags, fragsSize; + TextLineFrag *frag; + char space[8], eol[16]; + int spaceLen, eolLen; + int lastRot; + double x, y, delta; + int col, idx0, idx1, i, j; + GBool multiLine, oneRot; + + s = new GooString(); + + // get the output encoding + if (!(uMap = globalParams->getTextEncoding())) { + return s; + } + + if (rawOrder) { + TextWord* word; + char mbc[16]; + int mbc_len; + + for (word = rawWords; word && word <= rawLastWord; word = word->next) { + for (j = 0; j < word->getLength(); ++j) { + double gXMin, gXMax, gYMin, gYMax; + word->getCharBBox(j, &gXMin, &gYMin, &gXMax, &gYMax); + if (xMin <= gXMin && gXMax <= xMax && yMin <= gYMin && gYMax <= yMax) + { + mbc_len = uMap->mapUnicode( *(word->getChar(j)), mbc, sizeof(mbc) ); + s->append(mbc, mbc_len); + } + } + } + return s; + } + + spaceLen = uMap->mapUnicode(0x20, space, sizeof(space)); + eolLen = 0; // make gcc happy + switch (globalParams->getTextEOL()) { + case eolUnix: + eolLen = uMap->mapUnicode(0x0a, eol, sizeof(eol)); + break; + case eolDOS: + eolLen = uMap->mapUnicode(0x0d, eol, sizeof(eol)); + eolLen += uMap->mapUnicode(0x0a, eol + eolLen, sizeof(eol) - eolLen); + break; + case eolMac: + eolLen = uMap->mapUnicode(0x0d, eol, sizeof(eol)); + break; + } + + //~ writing mode (horiz/vert) + + // collect the line fragments that are in the rectangle + fragsSize = 256; + frags = (TextLineFrag *)gmallocn(fragsSize, sizeof(TextLineFrag)); + nFrags = 0; + lastRot = -1; + oneRot = gTrue; + for (i = 0; i < nBlocks; ++i) { + blk = blocks[i]; + if (xMin < blk->xMax && blk->xMin < xMax && + yMin < blk->yMax && blk->yMin < yMax) { + for (line = blk->lines; line; line = line->next) { + if (xMin < line->xMax && line->xMin < xMax && + yMin < line->yMax && line->yMin < yMax) { + idx0 = idx1 = -1; + switch (line->rot) { + case 0: + y = 0.5 * (line->yMin + line->yMax); + if (yMin < y && y < yMax) { + j = 0; + while (j < line->len) { + if (0.5 * (line->edge[j] + line->edge[j+1]) > xMin) { + idx0 = j; + break; + } + ++j; + } + j = line->len - 1; + while (j >= 0) { + if (0.5 * (line->edge[j] + line->edge[j+1]) < xMax) { + idx1 = j; + break; + } + --j; + } + } + break; + case 1: + x = 0.5 * (line->xMin + line->xMax); + if (xMin < x && x < xMax) { + j = 0; + while (j < line->len) { + if (0.5 * (line->edge[j] + line->edge[j+1]) > yMin) { + idx0 = j; + break; + } + ++j; + } + j = line->len - 1; + while (j >= 0) { + if (0.5 * (line->edge[j] + line->edge[j+1]) < yMax) { + idx1 = j; + break; + } + --j; + } + } + break; + case 2: + y = 0.5 * (line->yMin + line->yMax); + if (yMin < y && y < yMax) { + j = 0; + while (j < line->len) { + if (0.5 * (line->edge[j] + line->edge[j+1]) < xMax) { + idx0 = j; + break; + } + ++j; + } + j = line->len - 1; + while (j >= 0) { + if (0.5 * (line->edge[j] + line->edge[j+1]) > xMin) { + idx1 = j; + break; + } + --j; + } + } + break; + case 3: + x = 0.5 * (line->xMin + line->xMax); + if (xMin < x && x < xMax) { + j = 0; + while (j < line->len) { + if (0.5 * (line->edge[j] + line->edge[j+1]) < yMax) { + idx0 = j; + break; + } + ++j; + } + j = line->len - 1; + while (j >= 0) { + if (0.5 * (line->edge[j] + line->edge[j+1]) > yMin) { + idx1 = j; + break; + } + --j; + } + } + break; + } + if (idx0 >= 0 && idx1 >= 0) { + if (nFrags == fragsSize) { + fragsSize *= 2; + frags = (TextLineFrag *) + greallocn(frags, fragsSize, sizeof(TextLineFrag)); + } + frags[nFrags].init(line, idx0, idx1 - idx0 + 1); + ++nFrags; + if (lastRot >= 0 && line->rot != lastRot) { + oneRot = gFalse; + } + lastRot = line->rot; + } + } + } + } + } + + // sort the fragments and generate the string + if (nFrags > 0) { + + for (i = 0; i < nFrags; ++i) { + frags[i].computeCoords(oneRot); + } + assignColumns(frags, nFrags, oneRot); + + // if all lines in the region have the same rotation, use it; + // otherwise, use the page's primary rotation + if (oneRot) { + qsort(frags, nFrags, sizeof(TextLineFrag), + &TextLineFrag::cmpYXLineRot); + } else { + qsort(frags, nFrags, sizeof(TextLineFrag), + &TextLineFrag::cmpYXPrimaryRot); + } + i = 0; + while (i < nFrags) { + delta = maxIntraLineDelta * frags[i].line->words->fontSize; + for (j = i+1; + j < nFrags && fabs(frags[j].base - frags[i].base) < delta; + ++j) ; + qsort(frags + i, j - i, sizeof(TextLineFrag), + oneRot ? &TextLineFrag::cmpXYColumnLineRot + : &TextLineFrag::cmpXYColumnPrimaryRot); + i = j; + } + + col = 0; + multiLine = gFalse; + for (i = 0; i < nFrags; ++i) { + frag = &frags[i]; + + // insert a return + if (frag->col < col || + (i > 0 && fabs(frag->base - frags[i-1].base) > + maxIntraLineDelta * frags[i-1].line->words->fontSize)) { + s->append(eol, eolLen); + col = 0; + multiLine = gTrue; + } + + // column alignment + for (; col < frag->col; ++col) { + s->append(space, spaceLen); + } + + // get the fragment text + col += dumpFragment(frag->line->text + frag->start, frag->len, uMap, s); + } + + if (multiLine) { + s->append(eol, eolLen); + } + } + + gfree(frags); + uMap->decRefCnt(); + + return s; +} + +class TextSelectionVisitor { +public: + TextSelectionVisitor (TextPage *page); + virtual ~TextSelectionVisitor () { } + virtual void visitBlock (TextBlock *block, + TextLine *begin, + TextLine *end, + PDFRectangle *selection) = 0; + virtual void visitLine (TextLine *line, + TextWord *begin, + TextWord *end, + int edge_begin, + int edge_end, + PDFRectangle *selection) = 0; + virtual void visitWord (TextWord *word, int begin, int end, + PDFRectangle *selection) = 0; + +protected: + TextPage *page; +}; + +TextSelectionVisitor::TextSelectionVisitor (TextPage *page) + : page(page) +{ +} + + +class TextSelectionDumper : public TextSelectionVisitor { +public: + TextSelectionDumper(TextPage *page); + virtual ~TextSelectionDumper(); + + virtual void visitBlock (TextBlock *block, + TextLine *begin, + TextLine *end, + PDFRectangle *selection) { }; + virtual void visitLine (TextLine *line, + TextWord *begin, + TextWord *end, + int edge_begin, + int edge_end, + PDFRectangle *selection); + virtual void visitWord (TextWord *word, int begin, int end, + PDFRectangle *selection); + void endPage(); + + GooString *getText(void); + GooList **takeWordList(int *nLines); + +private: + + void startLine(); + void finishLine(); + + GooList **lines; + int nLines, linesSize; + GooList *words; + int tableId; + TextBlock *currentBlock; +}; + +TextSelectionDumper::TextSelectionDumper(TextPage *page) + : TextSelectionVisitor(page) +{ + linesSize = 256; + lines = (GooList **)gmallocn(linesSize, sizeof(GooList *)); + nLines = 0; + + tableId = -1; + currentBlock = NULL; + words = NULL; +} + +TextSelectionDumper::~TextSelectionDumper() +{ + for (int i = 0; i < nLines; i++) + deleteGooList(lines[i], TextWordSelection); + gfree(lines); +} + +void TextSelectionDumper::startLine() +{ + finishLine(); + words = new GooList(); +} + +void TextSelectionDumper::finishLine() +{ + if (nLines == linesSize) { + linesSize *= 2; + lines = (GooList **)grealloc(lines, linesSize * sizeof(GooList *)); + } + + if (words && words->getLength() > 0) + lines[nLines++] = words; + else if (words) + delete words; + words = NULL; +} + +void TextSelectionDumper::visitLine (TextLine *line, + TextWord *begin, + TextWord *end, + int edge_begin, + int edge_end, + PDFRectangle *selection) +{ + TextLineFrag frag; + + frag.init(line, edge_begin, edge_end - edge_begin); + + if (tableId >= 0 && frag.line->blk->tableId < 0) { + finishLine(); + + tableId = -1; + currentBlock = NULL; + } + + if (frag.line->blk->tableId >= 0) { // a table + if (tableId == -1) { + tableId = frag.line->blk->tableId; + currentBlock = frag.line->blk; + } + + if (currentBlock == frag.line->blk) { // the same block + startLine(); + } else { // another block + if (currentBlock->tableEnd) { // previous block ended its row + startLine(); + } + currentBlock = frag.line->blk; + } + } else { // not a table + startLine(); + } +} + +void TextSelectionDumper::visitWord (TextWord *word, int begin, int end, + PDFRectangle *selection) +{ + words->append(new TextWordSelection(word, begin, end)); +} + +void TextSelectionDumper::endPage() +{ + finishLine(); +} + +GooString *TextSelectionDumper::getText (void) +{ + GooString *text; + int i, j; + UnicodeMap *uMap; + char space[8], eol[16]; + int spaceLen, eolLen; + + text = new GooString(); + + if (!(uMap = globalParams->getTextEncoding())) + return text; + + spaceLen = uMap->mapUnicode(0x20, space, sizeof(space)); + eolLen = uMap->mapUnicode(0x0a, eol, sizeof(eol)); + + for (i = 0; i < nLines; i++) { + GooList *lineWords = lines[i]; + for (j = 0; j < lineWords->getLength(); j++) { + TextWordSelection *sel = (TextWordSelection *)lineWords->get(j); + + page->dumpFragment (sel->word->text + sel->begin, sel->end - sel->begin, uMap, text); + if (j < lineWords->getLength() - 1) + text->append(space, spaceLen); + } + if (i < nLines - 1) + text->append(eol, eolLen); + } + + uMap->decRefCnt(); + + return text; +} + +GooList **TextSelectionDumper::takeWordList(int *nLinesOut) +{ + GooList **returnValue = lines; + + *nLinesOut = nLines; + if (nLines == 0) + return NULL; + + nLines = 0; + lines = NULL; + + return returnValue; +} + +class TextSelectionSizer : public TextSelectionVisitor { +public: + TextSelectionSizer(TextPage *page, double scale); + ~TextSelectionSizer() { } + + virtual void visitBlock (TextBlock *block, + TextLine *begin, + TextLine *end, + PDFRectangle *selection) { }; + virtual void visitLine (TextLine *line, + TextWord *begin, + TextWord *end, + int edge_begin, + int edge_end, + PDFRectangle *selection); + virtual void visitWord (TextWord *word, int begin, int end, + PDFRectangle *selection) { }; + + GooList *getRegion () { return list; } + +private: + GooList *list; + double scale; +}; + +TextSelectionSizer::TextSelectionSizer(TextPage *page, double scale) + : TextSelectionVisitor(page), + scale(scale) +{ + list = new GooList(); +} + +void TextSelectionSizer::visitLine (TextLine *line, + TextWord *begin, + TextWord *end, + int edge_begin, + int edge_end, + PDFRectangle *selection) +{ + PDFRectangle *rect; + double x1, y1, x2, y2, margin; + + margin = (line->yMax - line->yMin) / 8; + x1 = line->edge[edge_begin]; + y1 = line->yMin - margin; + x2 = line->edge[edge_end]; + y2 = line->yMax + margin; + + rect = new PDFRectangle (floor (x1 * scale), + floor (y1 * scale), + ceil (x2 * scale), + ceil (y2 * scale)); + list->append (rect); +} + + +class TextSelectionPainter : public TextSelectionVisitor { +public: + TextSelectionPainter(TextPage *page, + double scale, + int rotation, + OutputDev *out, + GfxColor *box_color, + GfxColor *glyph_color); + ~TextSelectionPainter(); + + virtual void visitBlock (TextBlock *block, + TextLine *begin, + TextLine *end, + PDFRectangle *selection) { }; + virtual void visitLine (TextLine *line, + TextWord *begin, + TextWord *end, + int edge_begin, + int edge_end, + PDFRectangle *selection); + virtual void visitWord (TextWord *word, int begin, int end, + PDFRectangle *selection); + void endPage(); + +private: + OutputDev *out; + GfxColor *box_color, *glyph_color; + GfxState *state; + GooList *selectionList; + Matrix ctm, ictm; +}; + +TextSelectionPainter::TextSelectionPainter(TextPage *page, + double scale, + int rotation, + OutputDev *out, + GfxColor *box_color, + GfxColor *glyph_color) + : TextSelectionVisitor(page), + out(out), + box_color(box_color), + glyph_color(glyph_color) +{ + PDFRectangle box(0, 0, page->pageWidth, page->pageHeight); + + selectionList = new GooList(); + state = new GfxState(72 * scale, 72 * scale, &box, rotation, gFalse); + + state->getCTM(&ctm); + ctm.invertTo(&ictm); + + out->startPage(0, state, NULL); + out->setDefaultCTM (state->getCTM()); + + state->setFillColorSpace(new GfxDeviceRGBColorSpace()); + state->setFillColor(box_color); + out->updateFillColor(state); +} + +TextSelectionPainter::~TextSelectionPainter() +{ + deleteGooList(selectionList, TextWordSelection); + delete state; +} + +void TextSelectionPainter::visitLine (TextLine *line, + TextWord *begin, + TextWord *end, + int edge_begin, + int edge_end, + PDFRectangle *selection) +{ + double x1, y1, x2, y2, margin; + + margin = (line->yMax - line->yMin) / 8; + x1 = floor (line->edge[edge_begin]); + y1 = floor (line->yMin - margin); + x2 = ceil (line->edge[edge_end]); + y2 = ceil (line->yMax + margin); + + ctm.transform(line->edge[edge_begin], line->yMin - margin, &x1, &y1); + ctm.transform(line->edge[edge_end], line->yMax + margin, &x2, &y2); + + x1 = floor (x1); + y1 = floor (y1); + x2 = ceil (x2); + y2 = ceil (y2); + + ictm.transform(x1, y1, &x1, &y1); + ictm.transform(x2, y2, &x2, &y2); + + state->moveTo(x1, y1); + state->lineTo(x2, y1); + state->lineTo(x2, y2); + state->lineTo(x1, y2); + state->closePath(); +} + +void TextSelectionPainter::visitWord (TextWord *word, int begin, int end, + PDFRectangle *selection) +{ + selectionList->append(new TextWordSelection(word, begin, end)); +} + +void TextSelectionPainter::endPage() +{ + out->fill(state); + + out->saveState(state); + out->clip(state); + + state->clearPath(); + + state->setFillColor(glyph_color); + out->updateFillColor(state); + + for (int i = 0; i < selectionList->getLength(); i++) { + TextWordSelection *sel = (TextWordSelection *) selectionList->get(i); + int begin = sel->begin; + + while (begin < sel->end) { + TextFontInfo *font = sel->word->font[begin]; + font->gfxFont->incRefCnt(); + Matrix *mat = &sel->word->textMat[begin]; + + state->setTextMat(mat->m[0], mat->m[1], mat->m[2], mat->m[3], 0, 0); + state->setFont(font->gfxFont, 1); + out->updateFont(state); + + int fEnd = begin + 1; + while (fEnd < sel->end && font->matches(sel->word->font[fEnd]) && + mat->m[0] == sel->word->textMat[fEnd].m[0] && + mat->m[1] == sel->word->textMat[fEnd].m[1] && + mat->m[2] == sel->word->textMat[fEnd].m[2] && + mat->m[3] == sel->word->textMat[fEnd].m[3]) + fEnd++; + + /* The only purpose of this string is to let the output device query + * it's length. Might want to change this interface later. */ + GooString *string = new GooString ((char *) sel->word->charcode, fEnd - begin); + out->beginString(state, string); + + for (int i = begin; i < fEnd; i++) { + if (i != begin && sel->word->charPos[i] == sel->word->charPos[i - 1]) + continue; + + out->drawChar(state, sel->word->textMat[i].m[4], sel->word->textMat[i].m[5], 0, 0, 0, 0, + sel->word->charcode[i], 1, NULL, 0); + } + out->endString(state); + delete string; + begin = fEnd; + } + } + + out->restoreState(state); + out->endPage (); +} + +void TextWord::visitSelection(TextSelectionVisitor *visitor, + PDFRectangle *selection, + SelectionStyle style) +{ + int i, begin, end; + double mid; + + begin = len; + end = 0; + for (i = 0; i < len; i++) { + mid = (edge[i] + edge[i + 1]) / 2; + if (selection->x1 < mid || selection->x2 < mid) + if (i < begin) + begin = i; + if (mid < selection->x1 || mid < selection->x2) + end = i + 1; + } + + /* Skip empty selection. */ + if (end <= begin) + return; + + visitor->visitWord (this, begin, end, selection); +} + +void TextLine::visitSelection(TextSelectionVisitor *visitor, + PDFRectangle *selection, + SelectionStyle style) { + TextWord *p, *begin, *end, *current; + int i, edge_begin, edge_end; + PDFRectangle child_selection; + + begin = NULL; + end = NULL; + current = NULL; + for (p = words; p != NULL; p = p->next) { + if (blk->page->primaryLR) { + if ((selection->x1 < p->xMax) || + (selection->x2 < p->xMax)) + if (begin == NULL) + begin = p; + + if (((selection->x1 > p->xMin) || + (selection->x2 > p->xMin)) && (begin != NULL)) { + end = p->next; + current = p; + } + } else { + if ((selection->x1 > p->xMin) || + (selection->x2 > p->xMin)) + if (begin == NULL) + begin = p; + + if (((selection->x1 < p->xMax) || + (selection->x2 < p->xMax)) && (begin != NULL)) { + end = p->next; + current = p; + } + } + } + + if (!current) + current = begin; + + child_selection = *selection; + if (style == selectionStyleWord) { + child_selection.x1 = begin ? begin->xMin : xMin; + if (end && end->xMax != -1) { + child_selection.x2 = current->xMax; + } else { + child_selection.x2 = xMax; + } + } + + edge_begin = len; + edge_end = 0; + for (i = 0; i < len; i++) { + double mid = (edge[i] + edge[i + 1]) / 2; + if (child_selection.x1 < mid || child_selection.x2 < mid) + if (i < edge_begin) + edge_begin = i; + if (mid < child_selection.x2 || mid < child_selection.x1) + edge_end = i + 1; + } + + /* Skip empty selection. */ + if (edge_end <= edge_begin) + return; + + visitor->visitLine (this, begin, end, edge_begin, edge_end, + &child_selection); + + for (p = begin; p != end; p = p->next) + p->visitSelection (visitor, &child_selection, style); +} + +void TextBlock::visitSelection(TextSelectionVisitor *visitor, + PDFRectangle *selection, + SelectionStyle style) { + PDFRectangle child_selection; + double x[2], y[2], d, best_d[2]; + TextLine *p, *best_line[2]; + int i, count = 0, best_count[2], start, stop; + GBool all[2]; + + x[0] = selection->x1; + y[0] = selection->y1; + x[1] = selection->x2; + y[1] = selection->y2; + + for (i = 0; i < 2; i++) { + // the first/last lines are often not nearest + // the corners, so we have to force them to be + // selected when the selection runs outside this + // block. + if (page->primaryLR) { + all[i] = x[i] >= this->xMax && y[i] >= this->yMax; + if (x[i] <= this->xMin && y[i] <= this->yMin) { + best_line[i] = this->lines; + best_count[i] = 1; + } else { + best_line[i] = NULL; + best_count[i] = 0; + } + } else { + all[i] = x[i] <= this->xMin && y[i] >= this->yMax; + if (x[i] >= this->xMax && y[i] <= this->yMin) { + best_line[i] = this->lines; + best_count[i] = 1; + } else { + best_line[i] = NULL; + best_count[i] = 0; + } + } + best_d[i] = 0; + } + + // find the nearest line to the selection points + // using the manhattan distance. + for (p = this->lines; p; p = p->next) { + count++; + for (i = 0; i < 2; i++) { + d = fmax(p->xMin - x[i], 0.0) + + fmax(x[i] - p->xMax, 0.0) + + fmax(p->yMin - y[i], 0.0) + + fmax(y[i] - p->yMax, 0.0); + if (!best_line[i] || all[i] || + d < best_d[i]) { + best_line[i] = p; + best_count[i] = count; + best_d[i] = d; + } + } + } + // assert: best is always set. + if (!best_line[0] || !best_line[1]) { + return; + } + + // Now decide which point was first. + if (best_count[0] < best_count[1] || + (best_count[0] == best_count[1] && + y[0] < y[1])) { + start = 0; + stop = 1; + } else { + start = 1; + stop = 0; + } + + visitor->visitBlock(this, best_line[start], best_line[stop], selection); + + for (p = best_line[start]; p; p = p->next) { + if (page->primaryLR) { + child_selection.x1 = p->xMin; + child_selection.x2 = p->xMax; + } else { + child_selection.x1 = p->xMax; + child_selection.x2 = p->xMin; + } + child_selection.y1 = p->yMin; + child_selection.y2 = p->yMax; + if (style == selectionStyleLine) { + if (p == best_line[start]) { + child_selection.x1 = 0; + child_selection.y1 = 0; + } + if (p == best_line[stop]) { + child_selection.x2 = page->pageWidth; + child_selection.y2 = page->pageHeight; + } + } else { + if (p == best_line[start]) { + child_selection.x1 = fmax(p->xMin, fmin(p->xMax, x[start])); + child_selection.y1 = fmax(p->yMin, fmin(p->yMax, y[start])); + } + if (p == best_line[stop]) { + child_selection.x2 = fmax(p->xMin, fmin(p->xMax, x[stop])); + child_selection.y2 = fmax(p->yMin, fmin(p->yMax, y[stop])); + } + } + p->visitSelection(visitor, &child_selection, style); + if (p == best_line[stop]) { + return; + } + } +} + +void TextPage::visitSelection(TextSelectionVisitor *visitor, + PDFRectangle *selection, + SelectionStyle style) +{ + PDFRectangle child_selection; + double x[2], y[2], d, best_d[2]; + double xMin, yMin, xMax, yMax; + TextFlow *flow, *best_flow[2]; + TextBlock *blk, *best_block[2]; + int i, count = 0, best_count[2], start, stop; + + if (!flows) + return; + + x[0] = selection->x1; + y[0] = selection->y1; + x[1] = selection->x2; + y[1] = selection->y2; + + xMin = pageWidth; + yMin = pageHeight; + xMax = 0.0; + yMax = 0.0; + + for (i = 0; i < 2; i++) { + best_block[i] = NULL; + best_flow[i] = NULL; + best_count[i] = 0; + best_d[i] = 0; + } + + // find the nearest blocks to the selection points + // using the manhattan distance. + for (flow = flows; flow; flow = flow->next) { + for (blk = flow->blocks; blk; blk = blk->next) { + count++; + // the first/last blocks in reading order are + // often not the closest to the page corners; + // track the corners, force those blocks to + // be selected if the selection runs across + // multiple pages. + xMin = fmin(xMin, blk->xMin); + yMin = fmin(yMin, blk->yMin); + xMax = fmax(xMax, blk->xMax); + yMax = fmax(yMax, blk->yMax); + for (i = 0; i < 2; i++) { + d = fmax(blk->xMin - x[i], 0.0) + + fmax(x[i] - blk->xMax, 0.0) + + fmax(blk->yMin - y[i], 0.0) + + fmax(y[i] - blk->yMax, 0.0); + if (!best_block[i] || + d < best_d[i] || + (!blk->next && !flow->next && + x[i] >= fmin(xMax, pageWidth) && + y[i] >= fmin(yMax, pageHeight))) { + best_block[i] = blk; + best_flow[i] = flow; + best_count[i] = count; + best_d[i] = d; + } + } + } + } + for (i = 0; i < 2; i++) { + if (primaryLR) { + if (x[i] < xMin && y[i] < yMin) { + best_block[i] = flows->blocks; + best_flow[i] = flows; + best_count[i] = 1; + } + } else { + if (x[i] > xMax && y[i] < yMin) { + best_block[i] = flows->blocks; + best_flow[i] = flows; + best_count[i] = 1; + } + } + } + // assert: best is always set. + if (!best_block[0] || !best_block[1]) { + return; + } + + // Now decide which point was first. + if (best_count[0] < best_count[1] || + (best_count[0] == best_count[1] && y[0] < y[1])) { + start = 0; + stop = 1; + } else { + start = 1; + stop = 0; + } + + for (flow = best_flow[start]; flow; flow = flow->next) { + if (flow == best_flow[start]) { + blk = best_block[start]; + } else { + blk = flow->blocks; + } + for (; blk; blk = blk->next) { + if (primaryLR) { + child_selection.x1 = blk->xMin; + child_selection.x2 = blk->xMax; + } else { + child_selection.x1 = blk->xMax; + child_selection.x2 = blk->xMin; + } + child_selection.y1 = blk->yMin; + child_selection.y2 = blk->yMax; + if (blk == best_block[start]) { + child_selection.x1 = fmax(blk->xMin, fmin(blk->xMax, x[start])); + child_selection.y1 = fmax(blk->yMin, fmin(blk->yMax, y[start])); + } + if (blk == best_block[stop]) { + child_selection.x2 = fmax(blk->xMin, fmin(blk->xMax, x[stop])); + child_selection.y2 = fmax(blk->yMin, fmin(blk->yMax, y[stop])); + blk->visitSelection(visitor, &child_selection, style); + return; + } + blk->visitSelection(visitor, &child_selection, style); + } + } +} + +void TextPage::drawSelection(OutputDev *out, + double scale, + int rotation, + PDFRectangle *selection, + SelectionStyle style, + GfxColor *glyph_color, GfxColor *box_color) +{ + TextSelectionPainter painter(this, scale, rotation, + out, box_color, glyph_color); + + visitSelection(&painter, selection, style); + painter.endPage(); +} + +GooList *TextPage::getSelectionRegion(PDFRectangle *selection, + SelectionStyle style, + double scale) { + TextSelectionSizer sizer(this, scale); + + visitSelection(&sizer, selection, style); + + return sizer.getRegion(); +} + +GooString *TextPage::getSelectionText(PDFRectangle *selection, + SelectionStyle style) +{ + TextSelectionDumper dumper(this); + + visitSelection(&dumper, selection, style); + dumper.endPage(); + + return dumper.getText(); +} + +GooList **TextPage::getSelectionWords(PDFRectangle *selection, + SelectionStyle style, + int *nLines) +{ + TextSelectionDumper dumper(this); + + visitSelection(&dumper, selection, style); + dumper.endPage(); + + return dumper.takeWordList(nLines); +} + +GBool TextPage::findCharRange(int pos, int length, + double *xMin, double *yMin, + double *xMax, double *yMax) { + TextBlock *blk; + TextLine *line; + TextWord *word; + double xMin0, xMax0, yMin0, yMax0; + double xMin1, xMax1, yMin1, yMax1; + GBool first; + int i, j0, j1; + + if (rawOrder) { + return gFalse; + } + + //~ this doesn't correctly handle ranges split across multiple lines + //~ (the highlighted region is the bounding box of all the parts of + //~ the range) + first = gTrue; + xMin0 = xMax0 = yMin0 = yMax0 = 0; // make gcc happy + xMin1 = xMax1 = yMin1 = yMax1 = 0; // make gcc happy + for (i = 0; i < nBlocks; ++i) { + blk = blocks[i]; + for (line = blk->lines; line; line = line->next) { + for (word = line->words; word; word = word->next) { + if (pos < word->charPos[word->len] && + pos + length > word->charPos[0]) { + for (j0 = 0; + j0 < word->len && pos >= word->charPos[j0 + 1]; + ++j0) ; + for (j1 = word->len - 1; + j1 > j0 && pos + length <= word->charPos[j1]; + --j1) ; + switch (line->rot) { + case 0: + xMin1 = word->edge[j0]; + xMax1 = word->edge[j1 + 1]; + yMin1 = word->yMin; + yMax1 = word->yMax; + break; + case 1: + xMin1 = word->xMin; + xMax1 = word->xMax; + yMin1 = word->edge[j0]; + yMax1 = word->edge[j1 + 1]; + break; + case 2: + xMin1 = word->edge[j1 + 1]; + xMax1 = word->edge[j0]; + yMin1 = word->yMin; + yMax1 = word->yMax; + break; + case 3: + xMin1 = word->xMin; + xMax1 = word->xMax; + yMin1 = word->edge[j1 + 1]; + yMax1 = word->edge[j0]; + break; + } + if (first || xMin1 < xMin0) { + xMin0 = xMin1; + } + if (first || xMax1 > xMax0) { + xMax0 = xMax1; + } + if (first || yMin1 < yMin0) { + yMin0 = yMin1; + } + if (first || yMax1 > yMax0) { + yMax0 = yMax1; + } + first = gFalse; + } + } + } + } + if (!first) { + *xMin = xMin0; + *xMax = xMax0; + *yMin = yMin0; + *yMax = yMax0; + return gTrue; + } + return gFalse; +} + +void TextPage::dump(void *outputStream, TextOutputFunc outputFunc, + GBool physLayout) { + UnicodeMap *uMap; + TextFlow *flow; + TextBlock *blk; + TextLine *line; + TextLineFrag *frags; + TextWord *word; + int nFrags, fragsSize; + TextLineFrag *frag; + char space[8], eol[16], eop[8]; + int spaceLen, eolLen, eopLen; + GBool pageBreaks; + GooString *s; + double delta; + int col, i, j, d, n; + + // get the output encoding + if (!(uMap = globalParams->getTextEncoding())) { + return; + } + spaceLen = uMap->mapUnicode(0x20, space, sizeof(space)); + eolLen = 0; // make gcc happy + switch (globalParams->getTextEOL()) { + case eolUnix: + eolLen = uMap->mapUnicode(0x0a, eol, sizeof(eol)); + break; + case eolDOS: + eolLen = uMap->mapUnicode(0x0d, eol, sizeof(eol)); + eolLen += uMap->mapUnicode(0x0a, eol + eolLen, sizeof(eol) - eolLen); + break; + case eolMac: + eolLen = uMap->mapUnicode(0x0d, eol, sizeof(eol)); + break; + } + eopLen = uMap->mapUnicode(0x0c, eop, sizeof(eop)); + pageBreaks = globalParams->getTextPageBreaks(); + + //~ writing mode (horiz/vert) + + // output the page in raw (content stream) order + if (rawOrder) { + + for (word = rawWords; word; word = word->next) { + s = new GooString(); + dumpFragment(word->text, word->len, uMap, s); + (*outputFunc)(outputStream, s->getCString(), s->getLength()); + delete s; + if (word->next && + fabs(word->next->base - word->base) < + maxIntraLineDelta * word->fontSize && + word->next->xMin > + word->xMax - minDupBreakOverlap * word->fontSize) { + if (word->next->xMin > word->xMax + minWordSpacing * word->fontSize) { + (*outputFunc)(outputStream, space, spaceLen); + } + } else { + (*outputFunc)(outputStream, eol, eolLen); + } + } + + // output the page, maintaining the original physical layout + } else if (physLayout) { + + // collect the line fragments for the page and sort them + fragsSize = 256; + frags = (TextLineFrag *)gmallocn(fragsSize, sizeof(TextLineFrag)); + nFrags = 0; + for (i = 0; i < nBlocks; ++i) { + blk = blocks[i]; + for (line = blk->lines; line; line = line->next) { + if (nFrags == fragsSize) { + fragsSize *= 2; + frags = (TextLineFrag *)greallocn(frags, + fragsSize, sizeof(TextLineFrag)); + } + frags[nFrags].init(line, 0, line->len); + frags[nFrags].computeCoords(gTrue); + ++nFrags; + } + } + qsort(frags, nFrags, sizeof(TextLineFrag), &TextLineFrag::cmpYXPrimaryRot); + i = 0; + while (i < nFrags) { + delta = maxIntraLineDelta * frags[i].line->words->fontSize; + for (j = i+1; + j < nFrags && fabs(frags[j].base - frags[i].base) < delta; + ++j) ; + qsort(frags + i, j - i, sizeof(TextLineFrag), + &TextLineFrag::cmpXYColumnPrimaryRot); + i = j; + } + +#if 0 // for debugging + printf("*** line fragments ***\n"); + for (i = 0; i < nFrags; ++i) { + frag = &frags[i]; + printf("frag: x=%.2f..%.2f y=%.2f..%.2f base=%.2f '", + frag->xMin, frag->xMax, frag->yMin, frag->yMax, frag->base); + for (n = 0; n < frag->len; ++n) { + fputc(frag->line->text[frag->start + n] & 0xff, stdout); + } + printf("'\n"); + } + printf("\n"); +#endif + + // generate output + col = 0; + for (i = 0; i < nFrags; ++i) { + frag = &frags[i]; + + // column alignment + for (; col < frag->col; ++col) { + (*outputFunc)(outputStream, space, spaceLen); + } + + // print the line + s = new GooString(); + col += dumpFragment(frag->line->text + frag->start, frag->len, uMap, s); + (*outputFunc)(outputStream, s->getCString(), s->getLength()); + delete s; + + // print one or more returns if necessary + if (i == nFrags - 1 || + frags[i+1].col < col || + fabs(frags[i+1].base - frag->base) > + maxIntraLineDelta * frag->line->words->fontSize) { + if (i < nFrags - 1) { + d = (int)((frags[i+1].base - frag->base) / + frag->line->words->fontSize); + if (d < 1) { + d = 1; + } else if (d > 5) { + d = 5; + } + } else { + d = 1; + } + for (; d > 0; --d) { + (*outputFunc)(outputStream, eol, eolLen); + } + col = 0; + } + } + + gfree(frags); + + // output the page, "undoing" the layout + } else { + for (flow = flows; flow; flow = flow->next) { + for (blk = flow->blocks; blk; blk = blk->next) { + for (line = blk->lines; line; line = line->next) { + n = line->len; + if (line->hyphenated && (line->next || blk->next)) { + --n; + } + s = new GooString(); + dumpFragment(line->text, n, uMap, s); + (*outputFunc)(outputStream, s->getCString(), s->getLength()); + delete s; + // output a newline when a hyphen is not suppressed + if (n == line->len) { + (*outputFunc)(outputStream, eol, eolLen); + } + } + } + (*outputFunc)(outputStream, eol, eolLen); + } + } + + // end of page + if (pageBreaks) { + (*outputFunc)(outputStream, eop, eopLen); + } + + uMap->decRefCnt(); +} + +void TextPage::setMergeCombining(GBool merge) { + mergeCombining = merge; +} + +void TextPage::assignColumns(TextLineFrag *frags, int nFrags, GBool oneRot) { + TextLineFrag *frag0, *frag1; + int rot, col1, col2, i, j, k; + + // all text in the region has the same rotation -- recompute the + // column numbers based only on the text in the region + if (oneRot) { + qsort(frags, nFrags, sizeof(TextLineFrag), &TextLineFrag::cmpXYLineRot); + rot = frags[0].line->rot; + for (i = 0; i < nFrags; ++i) { + frag0 = &frags[i]; + col1 = 0; + for (j = 0; j < i; ++j) { + frag1 = &frags[j]; + col2 = 0; // make gcc happy + switch (rot) { + case 0: + if (frag0->xMin >= frag1->xMax) { + col2 = frag1->col + (frag1->line->col[frag1->start + frag1->len] - + frag1->line->col[frag1->start]) + 1; + } else { + for (k = frag1->start; + k < frag1->start + frag1->len && + frag0->xMin >= 0.5 * (frag1->line->edge[k] + + frag1->line->edge[k+1]); + ++k) ; + col2 = frag1->col + + frag1->line->col[k] - frag1->line->col[frag1->start]; + } + break; + case 1: + if (frag0->yMin >= frag1->yMax) { + col2 = frag1->col + (frag1->line->col[frag1->start + frag1->len] - + frag1->line->col[frag1->start]) + 1; + } else { + for (k = frag1->start; + k < frag1->start + frag1->len && + frag0->yMin >= 0.5 * (frag1->line->edge[k] + + frag1->line->edge[k+1]); + ++k) ; + col2 = frag1->col + + frag1->line->col[k] - frag1->line->col[frag1->start]; + } + break; + case 2: + if (frag0->xMax <= frag1->xMin) { + col2 = frag1->col + (frag1->line->col[frag1->start + frag1->len] - + frag1->line->col[frag1->start]) + 1; + } else { + for (k = frag1->start; + k < frag1->start + frag1->len && + frag0->xMax <= 0.5 * (frag1->line->edge[k] + + frag1->line->edge[k+1]); + ++k) ; + col2 = frag1->col + + frag1->line->col[k] - frag1->line->col[frag1->start]; + } + break; + case 3: + if (frag0->yMax <= frag1->yMin) { + col2 = frag1->col + (frag1->line->col[frag1->start + frag1->len] - + frag1->line->col[frag1->start]) + 1; + } else { + for (k = frag1->start; + k < frag1->start + frag1->len && + frag0->yMax <= 0.5 * (frag1->line->edge[k] + + frag1->line->edge[k+1]); + ++k) ; + col2 = frag1->col + + frag1->line->col[k] - frag1->line->col[frag1->start]; + } + break; + } + if (col2 > col1) { + col1 = col2; + } + } + frag0->col = col1; + } + + // the region includes text at different rotations -- use the + // globally assigned column numbers, offset by the minimum column + // number (i.e., shift everything over to column 0) + } else { + col1 = frags[0].col; + for (i = 1; i < nFrags; ++i) { + if (frags[i].col < col1) { + col1 = frags[i].col; + } + } + for (i = 0; i < nFrags; ++i) { + frags[i].col -= col1; + } + } +} + +int TextPage::dumpFragment(Unicode *text, int len, UnicodeMap *uMap, + GooString *s) { + char lre[8], rle[8], popdf[8], buf[8]; + int lreLen, rleLen, popdfLen, n; + int nCols, i, j, k; + + nCols = 0; + + if (uMap->isUnicode()) { + + lreLen = uMap->mapUnicode(0x202a, lre, sizeof(lre)); + rleLen = uMap->mapUnicode(0x202b, rle, sizeof(rle)); + popdfLen = uMap->mapUnicode(0x202c, popdf, sizeof(popdf)); + + if (primaryLR) { + + i = 0; + while (i < len) { + // output a left-to-right section + for (j = i; j < len && !unicodeTypeR(text[j]); ++j) ; + for (k = i; k < j; ++k) { + n = uMap->mapUnicode(text[k], buf, sizeof(buf)); + s->append(buf, n); + ++nCols; + } + i = j; + // output a right-to-left section + for (j = i; + j < len && !(unicodeTypeL(text[j]) || unicodeTypeNum(text[j])); + ++j) ; + if (j > i) { + s->append(rle, rleLen); + for (k = j - 1; k >= i; --k) { + n = uMap->mapUnicode(text[k], buf, sizeof(buf)); + s->append(buf, n); + ++nCols; + } + s->append(popdf, popdfLen); + i = j; + } + } + + } else { + + // Note: This code treats numeric characters (European and + // Arabic/Indic) as left-to-right, which isn't strictly correct + // (incurs extra LRE/POPDF pairs), but does produce correct + // visual formatting. + s->append(rle, rleLen); + i = len - 1; + while (i >= 0) { + // output a right-to-left section + for (j = i; + j >= 0 && !(unicodeTypeL(text[j]) || unicodeTypeNum(text[j])); + --j) ; + for (k = i; k > j; --k) { + n = uMap->mapUnicode(text[k], buf, sizeof(buf)); + s->append(buf, n); + ++nCols; + } + i = j; + // output a left-to-right section + for (j = i; j >= 0 && !unicodeTypeR(text[j]); --j) ; + if (j < i) { + s->append(lre, lreLen); + for (k = j + 1; k <= i; ++k) { + n = uMap->mapUnicode(text[k], buf, sizeof(buf)); + s->append(buf, n); + ++nCols; + } + s->append(popdf, popdfLen); + i = j; + } + } + s->append(popdf, popdfLen); + + } + + } else { + for (i = 0; i < len; ++i) { + n = uMap->mapUnicode(text[i], buf, sizeof(buf)); + s->append(buf, n); + nCols += n; + } + } + + return nCols; +} + +#if TEXTOUT_WORD_LIST +TextWordList *TextPage::makeWordList(GBool physLayout) { + return new TextWordList(this, physLayout); +} +#endif + +//------------------------------------------------------------------------ +// ActualText +//------------------------------------------------------------------------ +ActualText::ActualText(TextPage *out) { + out->incRefCnt(); + text = out; + actualText = NULL; + actualTextNBytes = 0; +} + +ActualText::~ActualText() { + if (actualText) + delete actualText; + text->decRefCnt(); +} + +void ActualText::addChar(GfxState *state, double x, double y, + double dx, double dy, + CharCode c, int nBytes, Unicode *u, int uLen) { + if (!actualText) { + text->addChar(state, x, y, dx, dy, c, nBytes, u, uLen); + return; + } + + // Inside ActualText span. + if (!actualTextNBytes) { + actualTextX0 = x; + actualTextY0 = y; + } + actualTextX1 = x + dx; + actualTextY1 = y + dy; + actualTextNBytes += nBytes; +} + +void ActualText::begin(GfxState *state, GooString *text) { + if (actualText) + delete actualText; + actualText = new GooString(text); + actualTextNBytes = 0; +} + +void ActualText::end(GfxState *state) { + // ActualText span closed. Output the span text and the + // extents of all the glyphs inside the span + + if (actualTextNBytes) { + Unicode *uni = NULL; + int length; + + // now that we have the position info for all of the text inside + // the marked content span, we feed the "ActualText" back through + // text->addChar() + length = TextStringToUCS4(actualText, &uni); + text->addChar(state, actualTextX0, actualTextY0, + actualTextX1 - actualTextX0, actualTextY1 - actualTextY0, + 0, actualTextNBytes, uni, length); + gfree(uni); + } + + delete actualText; + actualText = NULL; + actualTextNBytes = 0; +} + +//------------------------------------------------------------------------ +// TextOutputDev +//------------------------------------------------------------------------ + +static void TextOutputDev_outputToFile(void *stream, const char *text, int len) { + fwrite(text, 1, len, (FILE *)stream); +} + +TextOutputDev::TextOutputDev(char *fileName, GBool physLayoutA, + double fixedPitchA, GBool rawOrderA, + GBool append) { + text = NULL; + physLayout = physLayoutA; + fixedPitch = physLayout ? fixedPitchA : 0; + rawOrder = rawOrderA; + doHTML = gFalse; + ok = gTrue; + + // open file + needClose = gFalse; + if (fileName) { + if (!strcmp(fileName, "-")) { + outputStream = stdout; +#ifdef _WIN32 + // keep DOS from munging the end-of-line characters + setmode(fileno(stdout), O_BINARY); +#endif + } else if ((outputStream = fopen(fileName, append ? "ab" : "wb"))) { + needClose = gTrue; + } else { + error(errIO, -1, "Couldn't open text file '{0:s}'", fileName); + ok = gFalse; + actualText = NULL; + return; + } + outputFunc = &TextOutputDev_outputToFile; + } else { + outputStream = NULL; + } + + // set up text object + text = new TextPage(rawOrderA); + actualText = new ActualText(text); +} + +TextOutputDev::TextOutputDev(TextOutputFunc func, void *stream, + GBool physLayoutA, double fixedPitchA, + GBool rawOrderA) { + outputFunc = func; + outputStream = stream; + needClose = gFalse; + physLayout = physLayoutA; + fixedPitch = physLayout ? fixedPitchA : 0; + rawOrder = rawOrderA; + doHTML = gFalse; + text = new TextPage(rawOrderA); + actualText = new ActualText(text); + ok = gTrue; +} + +TextOutputDev::~TextOutputDev() { + if (needClose) { +#ifdef MACOS + ICS_MapRefNumAndAssign((short)((FILE *)outputStream)->handle); +#endif + fclose((FILE *)outputStream); + } + if (text) { + text->decRefCnt(); + } + delete actualText; +} + +void TextOutputDev::startPage(int pageNum, GfxState *state, XRef *xref) { + text->startPage(state); +} + +void TextOutputDev::endPage() { + text->endPage(); + text->coalesce(physLayout, fixedPitch, doHTML); + if (outputStream) { + text->dump(outputStream, outputFunc, physLayout); + } +} + +void TextOutputDev::restoreState(GfxState *state) { + text->updateFont(state); +} + +void TextOutputDev::updateFont(GfxState *state) { + text->updateFont(state); +} + +void TextOutputDev::beginString(GfxState *state, GooString *s) { +} + +void TextOutputDev::endString(GfxState *state) { +} + +void TextOutputDev::drawChar(GfxState *state, double x, double y, + double dx, double dy, + double originX, double originY, + CharCode c, int nBytes, Unicode *u, int uLen) { + actualText->addChar(state, x, y, dx, dy, c, nBytes, u, uLen); +} + +void TextOutputDev::incCharCount(int nChars) { + text->incCharCount(nChars); +} + +void TextOutputDev::beginActualText(GfxState *state, GooString *text) +{ + actualText->begin(state, text); +} + +void TextOutputDev::endActualText(GfxState *state) +{ + actualText->end(state); +} + +void TextOutputDev::stroke(GfxState *state) { + GfxPath *path; + GfxSubpath *subpath; + double x[2], y[2]; + + if (!doHTML) { + return; + } + path = state->getPath(); + if (path->getNumSubpaths() != 1) { + return; + } + subpath = path->getSubpath(0); + if (subpath->getNumPoints() != 2) { + return; + } + state->transform(subpath->getX(0), subpath->getY(0), &x[0], &y[0]); + state->transform(subpath->getX(1), subpath->getY(1), &x[1], &y[1]); + + // look for a vertical or horizontal line + if (x[0] == x[1] || y[0] == y[1]) { + text->addUnderline(x[0], y[0], x[1], y[1]); + } +} + +void TextOutputDev::fill(GfxState *state) { + GfxPath *path; + GfxSubpath *subpath; + double x[5], y[5]; + double rx0, ry0, rx1, ry1, t; + int i; + + if (!doHTML) { + return; + } + path = state->getPath(); + if (path->getNumSubpaths() != 1) { + return; + } + subpath = path->getSubpath(0); + if (subpath->getNumPoints() != 5) { + return; + } + for (i = 0; i < 5; ++i) { + if (subpath->getCurve(i)) { + return; + } + state->transform(subpath->getX(i), subpath->getY(i), &x[i], &y[i]); + } + + // look for a rectangle + if (x[0] == x[1] && y[1] == y[2] && x[2] == x[3] && y[3] == y[4] && + x[0] == x[4] && y[0] == y[4]) { + rx0 = x[0]; + ry0 = y[0]; + rx1 = x[2]; + ry1 = y[1]; + } else if (y[0] == y[1] && x[1] == x[2] && y[2] == y[3] && x[3] == x[4] && + x[0] == x[4] && y[0] == y[4]) { + rx0 = x[0]; + ry0 = y[0]; + rx1 = x[1]; + ry1 = y[2]; + } else { + return; + } + if (rx1 < rx0) { + t = rx0; + rx0 = rx1; + rx1 = t; + } + if (ry1 < ry0) { + t = ry0; + ry0 = ry1; + ry1 = t; + } + + // skinny horizontal rectangle + if (ry1 - ry0 < rx1 - rx0) { + if (ry1 - ry0 < maxUnderlineWidth) { + ry0 = 0.5 * (ry0 + ry1); + text->addUnderline(rx0, ry0, rx1, ry0); + } + + // skinny vertical rectangle + } else { + if (rx1 - rx0 < maxUnderlineWidth) { + rx0 = 0.5 * (rx0 + rx1); + text->addUnderline(rx0, ry0, rx0, ry1); + } + } +} + +void TextOutputDev::eoFill(GfxState *state) { + if (!doHTML) { + return; + } + fill(state); +} + +void TextOutputDev::processLink(AnnotLink *link) { + double x1, y1, x2, y2; + int xMin, yMin, xMax, yMax, x, y; + + if (!doHTML) { + return; + } + link->getRect(&x1, &y1, &x2, &y2); + cvtUserToDev(x1, y1, &x, &y); + xMin = xMax = x; + yMin = yMax = y; + cvtUserToDev(x1, y2, &x, &y); + if (x < xMin) { + xMin = x; + } else if (x > xMax) { + xMax = x; + } + if (y < yMin) { + yMin = y; + } else if (y > yMax) { + yMax = y; + } + cvtUserToDev(x2, y1, &x, &y); + if (x < xMin) { + xMin = x; + } else if (x > xMax) { + xMax = x; + } + if (y < yMin) { + yMin = y; + } else if (y > yMax) { + yMax = y; + } + cvtUserToDev(x2, y2, &x, &y); + if (x < xMin) { + xMin = x; + } else if (x > xMax) { + xMax = x; + } + if (y < yMin) { + yMin = y; + } else if (y > yMax) { + yMax = y; + } + text->addLink(xMin, yMin, xMax, yMax, link); +} + +GBool TextOutputDev::findText(Unicode *s, int len, + GBool startAtTop, GBool stopAtBottom, + GBool startAtLast, GBool stopAtLast, + GBool caseSensitive, GBool backward, + GBool wholeWord, + double *xMin, double *yMin, + double *xMax, double *yMax) { + return text->findText(s, len, startAtTop, stopAtBottom, + startAtLast, stopAtLast, + caseSensitive, backward, wholeWord, + xMin, yMin, xMax, yMax); +} + +GooString *TextOutputDev::getText(double xMin, double yMin, + double xMax, double yMax) { + return text->getText(xMin, yMin, xMax, yMax); +} + +void TextOutputDev::drawSelection(OutputDev *out, + double scale, + int rotation, + PDFRectangle *selection, + SelectionStyle style, + GfxColor *glyph_color, GfxColor *box_color) { + text->drawSelection(out, scale, rotation, selection, style, glyph_color, box_color); +} + +GooList *TextOutputDev::getSelectionRegion(PDFRectangle *selection, + SelectionStyle style, + double scale) { + return text->getSelectionRegion(selection, style, scale); +} + +GooString *TextOutputDev::getSelectionText(PDFRectangle *selection, + SelectionStyle style) +{ + return text->getSelectionText(selection, style); +} + +GBool TextOutputDev::findCharRange(int pos, int length, + double *xMin, double *yMin, + double *xMax, double *yMax) { + return text->findCharRange(pos, length, xMin, yMin, xMax, yMax); +} + +void TextOutputDev::setMergeCombining(GBool merge) { + text->setMergeCombining(merge); +} + +#if TEXTOUT_WORD_LIST +TextWordList *TextOutputDev::makeWordList() { + return text->makeWordList(physLayout); +} +#endif + +TextPage *TextOutputDev::takeText() { + TextPage *ret; + + ret = text; + text = new TextPage(rawOrder); + return ret; +} diff --git a/source/libs/poppler/poppler-0.33.0/poppler/TextOutputDev.h b/source/libs/poppler/poppler-0.33.0/poppler/TextOutputDev.h new file mode 100644 index 000000000..a0aa6f8a9 --- /dev/null +++ b/source/libs/poppler/poppler-0.33.0/poppler/TextOutputDev.h @@ -0,0 +1,880 @@ +//======================================================================== +// +// TextOutputDev.h +// +// Copyright 1997-2003 Glyph & Cog, LLC +// +//======================================================================== + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2005-2007 Kristian Høgsberg <krh@redhat.com> +// Copyright (C) 2006 Ed Catmur <ed@catmur.co.uk> +// Copyright (C) 2007, 2008, 2011, 2013 Carlos Garcia Campos <carlosgc@gnome.org> +// Copyright (C) 2007 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2008, 2010 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2010 Brian Ewins <brian.ewins@gmail.com> +// Copyright (C) 2012, 2013, 2015 Jason Crain <jason@aquaticape.us> +// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#ifndef TEXTOUTPUTDEV_H +#define TEXTOUTPUTDEV_H + +#ifdef USE_GCC_PRAGMAS +#pragma interface +#endif + +#include "poppler-config.h" +#include <stdio.h> +#include "goo/gtypes.h" +#include "GfxFont.h" +#include "GfxState.h" +#include "OutputDev.h" + +class GooString; +class GooList; +class Gfx; +class GfxFont; +class GfxState; +class UnicodeMap; +class AnnotLink; + +class TextWord; +class TextPool; +class TextLine; +class TextLineFrag; +class TextBlock; +class TextFlow; +class TextWordList; +class TextPage; +class TextSelectionVisitor; + +//------------------------------------------------------------------------ + +typedef void (*TextOutputFunc)(void *stream, const char *text, int len); + +enum SelectionStyle { + selectionStyleGlyph, + selectionStyleWord, + selectionStyleLine +}; + +//------------------------------------------------------------------------ +// TextFontInfo +//------------------------------------------------------------------------ + +class TextFontInfo { +public: + + TextFontInfo(GfxState *state); + ~TextFontInfo(); + + GBool matches(GfxState *state); + GBool matches(TextFontInfo *fontInfo); + + // Get the font ascent, or a default value if the font is not set + double getAscent(); + + // Get the font descent, or a default value if the font is not set + double getDescent(); + + // Get the writing mode (0 or 1), or 0 if the font is not set + int getWMode(); + +#if TEXTOUT_WORD_LIST + // Get the font name (which may be NULL). + GooString *getFontName() { return fontName; } + + // Get font descriptor flags. + GBool isFixedWidth() { return flags & fontFixedWidth; } + GBool isSerif() { return flags & fontSerif; } + GBool isSymbolic() { return flags & fontSymbolic; } + GBool isItalic() { return flags & fontItalic; } + GBool isBold() { return flags & fontBold; } +#endif + +private: + + GfxFont *gfxFont; +#if TEXTOUT_WORD_LIST + GooString *fontName; + int flags; +#endif + + friend class TextWord; + friend class TextPage; + friend class TextSelectionPainter; +}; + +//------------------------------------------------------------------------ +// TextWord +//------------------------------------------------------------------------ + +class TextWord { +public: + + // Constructor. + TextWord(GfxState *state, int rotA, double fontSize); + + // Destructor. + ~TextWord(); + + // Add a character to the word. + void addChar(GfxState *state, TextFontInfo *fontA, double x, double y, + double dx, double dy, int charPosA, int charLen, + CharCode c, Unicode u, Matrix textMatA); + + // Attempt to add a character to the word as a combining character. + // Either character u or the last character in the word must be an + // acute, dieresis, or other combining character. Returns true if + // the character was added. + GBool addCombining(GfxState *state, TextFontInfo *fontA, double fontSizeA, double x, double y, + double dx, double dy, int charPosA, int charLen, + CharCode c, Unicode u, Matrix textMatA); + + // Merge <word> onto the end of <this>. + void merge(TextWord *word); + + // Compares <this> to <word>, returning -1 (<), 0 (=), or +1 (>), + // based on a primary-axis comparison, e.g., x ordering if rot=0. + int primaryCmp(TextWord *word); + + // Return the distance along the primary axis between <this> and + // <word>. + double primaryDelta(TextWord *word); + + static int cmpYX(const void *p1, const void *p2); + + void visitSelection(TextSelectionVisitor *visitor, + PDFRectangle *selection, + SelectionStyle style); + + // Get the TextFontInfo object associated with a character. + TextFontInfo *getFontInfo(int idx) { return font[idx]; } + + // Get the next TextWord on the linked list. + TextWord *getNext() { return next; } + +#if TEXTOUT_WORD_LIST + int getLength() { return len; } + const Unicode *getChar(int idx) { return &text[idx]; } + GooString *getText(); + GooString *getFontName(int idx) { return font[idx]->fontName; } + void getColor(double *r, double *g, double *b) + { *r = colorR; *g = colorG; *b = colorB; } + void getBBox(double *xMinA, double *yMinA, double *xMaxA, double *yMaxA) + { *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; } + void getCharBBox(int charIdx, double *xMinA, double *yMinA, + double *xMaxA, double *yMaxA); + double getFontSize() { return fontSize; } + int getRotation() { return rot; } + int getCharPos() { return charPos[0]; } + int getCharLen() { return charPos[len] - charPos[0]; } + GBool getSpaceAfter() { return spaceAfter; } +#endif + GBool isUnderlined() { return underlined; } + AnnotLink *getLink() { return link; } + double getEdge(int i) { return edge[i]; } + double getBaseline () { return base; } + GBool hasSpaceAfter () { return spaceAfter; } + TextWord* nextWord () { return next; }; +private: + void ensureCapacity(int capacity); + void setInitialBounds(TextFontInfo *fontA, double x, double y); + + int rot; // rotation, multiple of 90 degrees + // (0, 1, 2, or 3) + double xMin, xMax; // bounding box x coordinates + double yMin, yMax; // bounding box y coordinates + double base; // baseline x or y coordinate + Unicode *text; // the text + CharCode *charcode; // glyph indices + double *edge; // "near" edge x or y coord of each char + // (plus one extra entry for the last char) + int *charPos; // character position (within content stream) + // of each char (plus one extra entry for + // the last char) + int len; // length of text/edge/charPos/font arrays + int size; // size of text/edge/charPos/font arrays + TextFontInfo **font; // font information for each char + Matrix *textMat; // transformation matrix for each char + double fontSize; // font size + GBool spaceAfter; // set if there is a space between this + // word and the next word on the line + TextWord *next; // next word in line + int wMode; // horizontal (0) or vertical (1) writing mode + +#if TEXTOUT_WORD_LIST + double colorR, // word color + colorG, + colorB; +#endif + + GBool underlined; + AnnotLink *link; + + friend class TextPool; + friend class TextLine; + friend class TextBlock; + friend class TextFlow; + friend class TextWordList; + friend class TextPage; + + friend class TextSelectionPainter; + friend class TextSelectionDumper; +}; + +//------------------------------------------------------------------------ +// TextPool +//------------------------------------------------------------------------ + +class TextPool { +public: + + TextPool(); + ~TextPool(); + + TextWord *getPool(int baseIdx) { return pool[baseIdx - minBaseIdx]; } + void setPool(int baseIdx, TextWord *p) { pool[baseIdx - minBaseIdx] = p; } + + int getBaseIdx(double base); + + void addWord(TextWord *word); + +private: + + int minBaseIdx; // min baseline bucket index + int maxBaseIdx; // max baseline bucket index + TextWord **pool; // array of linked lists, one for each + // baseline value (multiple of 4 pts) + TextWord *cursor; // pointer to last-accessed word + int cursorBaseIdx; // baseline bucket index of last-accessed word + + friend class TextBlock; + friend class TextPage; +}; + +struct TextFlowData; + +//------------------------------------------------------------------------ +// TextLine +//------------------------------------------------------------------------ + +class TextLine { +public: + + TextLine(TextBlock *blkA, int rotA, double baseA); + ~TextLine(); + + void addWord(TextWord *word); + + // Return the distance along the primary axis between <this> and + // <line>. + double primaryDelta(TextLine *line); + + // Compares <this> to <line>, returning -1 (<), 0 (=), or +1 (>), + // based on a primary-axis comparison, e.g., x ordering if rot=0. + int primaryCmp(TextLine *line); + + // Compares <this> to <line>, returning -1 (<), 0 (=), or +1 (>), + // based on a secondary-axis comparison of the baselines, e.g., y + // ordering if rot=0. + int secondaryCmp(TextLine *line); + + int cmpYX(TextLine *line); + + static int cmpXY(const void *p1, const void *p2); + + void coalesce(UnicodeMap *uMap); + + void visitSelection(TextSelectionVisitor *visitor, + PDFRectangle *selection, + SelectionStyle style); + + // Get the head of the linked list of TextWords. + TextWord *getWords() { return words; } + + // Get the next TextLine on the linked list. + TextLine *getNext() { return next; } + + // Returns true if the last char of the line is a hyphen. + GBool isHyphenated() { return hyphenated; } + +private: + + TextBlock *blk; // parent block + int rot; // text rotation + double xMin, xMax; // bounding box x coordinates + double yMin, yMax; // bounding box y coordinates + double base; // baseline x or y coordinate + TextWord *words; // words in this line + TextWord *lastWord; // last word in this line + Unicode *text; // Unicode text of the line, including + // spaces between words + double *edge; // "near" edge x or y coord of each char + // (plus one extra entry for the last char) + int *col; // starting column number of each Unicode char + int len; // number of Unicode chars + int convertedLen; // total number of converted characters + GBool hyphenated; // set if last char is a hyphen + TextLine *next; // next line in block + Unicode *normalized; // normalized form of Unicode text + int normalized_len; // number of normalized Unicode chars + int *normalized_idx; // indices of normalized chars into Unicode text + + friend class TextLineFrag; + friend class TextBlock; + friend class TextFlow; + friend class TextWordList; + friend class TextPage; + + friend class TextSelectionPainter; + friend class TextSelectionSizer; + friend class TextSelectionDumper; +}; + +//------------------------------------------------------------------------ +// TextBlock +//------------------------------------------------------------------------ + +class TextBlock { +public: + + TextBlock(TextPage *pageA, int rotA); + ~TextBlock(); + + void addWord(TextWord *word); + + void coalesce(UnicodeMap *uMap, double fixedPitch); + + // Update this block's priMin and priMax values, looking at <blk>. + void updatePriMinMax(TextBlock *blk); + + static int cmpXYPrimaryRot(const void *p1, const void *p2); + + static int cmpYXPrimaryRot(const void *p1, const void *p2); + + int primaryCmp(TextBlock *blk); + + double secondaryDelta(TextBlock *blk); + + // Returns true if <this> is below <blk>, relative to the page's + // primary rotation. + GBool isBelow(TextBlock *blk); + + void visitSelection(TextSelectionVisitor *visitor, + PDFRectangle *selection, + SelectionStyle style); + + // Get the head of the linked list of TextLines. + TextLine *getLines() { return lines; } + + // Get the next TextBlock on the linked list. + TextBlock *getNext() { return next; } + + void getBBox(double *xMinA, double *yMinA, double *xMaxA, double *yMaxA) + { *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; } + + int getLineCount() { return nLines; } + +private: + + GBool isBeforeByRule1(TextBlock *blk1); + GBool isBeforeByRepeatedRule1(TextBlock *blkList, TextBlock *blk1); + GBool isBeforeByRule2(TextBlock *blk1); + + int visitDepthFirst(TextBlock *blkList, int pos1, + TextBlock **sorted, int sortPos, + GBool* visited); + + TextPage *page; // the parent page + int rot; // text rotation + double xMin, xMax; // bounding box x coordinates + double yMin, yMax; // bounding box y coordinates + double priMin, priMax; // whitespace bounding box along primary axis + double ExMin, ExMax; // extended bounding box x coordinates + double EyMin, EyMax; // extended bounding box y coordinates + int tableId; // id of table to which this block belongs + GBool tableEnd; // is this block at end of line of actual table + + TextPool *pool; // pool of words (used only until lines + // are built) + TextLine *lines; // linked list of lines + TextLine *curLine; // most recently added line + int nLines; // number of lines + int charCount; // number of characters in the block + int col; // starting column + int nColumns; // number of columns in the block + + TextBlock *next; + TextBlock *stackNext; + + friend class TextLine; + friend class TextLineFrag; + friend class TextFlow; + friend class TextWordList; + friend class TextPage; + friend class TextSelectionPainter; + friend class TextSelectionDumper; +}; + +//------------------------------------------------------------------------ +// TextFlow +//------------------------------------------------------------------------ + +class TextFlow { +public: + + TextFlow(TextPage *pageA, TextBlock *blk); + ~TextFlow(); + + // Add a block to the end of this flow. + void addBlock(TextBlock *blk); + + // Returns true if <blk> fits below <prevBlk> in the flow, i.e., (1) + // it uses a font no larger than the last block added to the flow, + // and (2) it fits within the flow's [priMin, priMax] along the + // primary axis. + GBool blockFits(TextBlock *blk, TextBlock *prevBlk); + + // Get the head of the linked list of TextBlocks. + TextBlock *getBlocks() { return blocks; } + + // Get the next TextFlow on the linked list. + TextFlow *getNext() { return next; } + +private: + + TextPage *page; // the parent page + double xMin, xMax; // bounding box x coordinates + double yMin, yMax; // bounding box y coordinates + double priMin, priMax; // whitespace bounding box along primary axis + TextBlock *blocks; // blocks in flow + TextBlock *lastBlk; // last block in this flow + TextFlow *next; + + friend class TextWordList; + friend class TextPage; +}; + +#if TEXTOUT_WORD_LIST + +//------------------------------------------------------------------------ +// TextWordList +//------------------------------------------------------------------------ + +class TextWordList { +public: + + // Build a flat word list, in content stream order (if + // text->rawOrder is true), physical layout order (if <physLayout> + // is true and text->rawOrder is false), or reading order (if both + // flags are false). + TextWordList(TextPage *text, GBool physLayout); + + ~TextWordList(); + + // Return the number of words on the list. + int getLength(); + + // Return the <idx>th word from the list. + TextWord *get(int idx); + +private: + + GooList *words; // [TextWord] +}; + +#endif // TEXTOUT_WORD_LIST + +class TextWordSelection { +public: + TextWordSelection(TextWord *word, int begin, int end) + : word(word), begin(begin), end(end) + { + } + + TextWord * getWord() const { return word; } + int getBegin() const { return begin; } + int getEnd() const { return end; } + +private: + TextWord *word; + int begin; + int end; + + friend class TextSelectionPainter; + friend class TextSelectionDumper; +}; + +//------------------------------------------------------------------------ +// TextPage +//------------------------------------------------------------------------ + +class TextPage { +public: + + // Constructor. + TextPage(GBool rawOrderA); + + void incRefCnt(); + void decRefCnt(); + + // Start a new page. + void startPage(GfxState *state); + + // End the current page. + void endPage(); + + // Update the current font. + void updateFont(GfxState *state); + + // Begin a new word. + void beginWord(GfxState *state); + + // Add a character to the current word. + void addChar(GfxState *state, double x, double y, + double dx, double dy, + CharCode c, int nBytes, Unicode *u, int uLen); + + // Add <nChars> invisible characters. + void incCharCount(int nChars); + + // End the current word, sorting it into the list of words. + void endWord(); + + // Add a word, sorting it into the list of words. + void addWord(TextWord *word); + + // Add a (potential) underline. + void addUnderline(double x0, double y0, double x1, double y1); + + // Add a hyperlink. + void addLink(int xMin, int yMin, int xMax, int yMax, AnnotLink *link); + + // Coalesce strings that look like parts of the same line. + void coalesce(GBool physLayout, double fixedPitch, GBool doHTML); + + // Find a string. If <startAtTop> is true, starts looking at the + // top of the page; else if <startAtLast> is true, starts looking + // immediately after the last find result; else starts looking at + // <xMin>,<yMin>. If <stopAtBottom> is true, stops looking at the + // bottom of the page; else if <stopAtLast> is true, stops looking + // just before the last find result; else stops looking at + // <xMax>,<yMax>. + GBool findText(Unicode *s, int len, + GBool startAtTop, GBool stopAtBottom, + GBool startAtLast, GBool stopAtLast, + GBool caseSensitive, GBool backward, + GBool wholeWord, + double *xMin, double *yMin, + double *xMax, double *yMax); + + // Get the text which is inside the specified rectangle. + GooString *getText(double xMin, double yMin, + double xMax, double yMax); + + void visitSelection(TextSelectionVisitor *visitor, + PDFRectangle *selection, + SelectionStyle style); + + void drawSelection(OutputDev *out, + double scale, + int rotation, + PDFRectangle *selection, + SelectionStyle style, + GfxColor *glyph_color, GfxColor *box_color); + + GooList *getSelectionRegion(PDFRectangle *selection, + SelectionStyle style, + double scale); + + GooString *getSelectionText(PDFRectangle *selection, + SelectionStyle style); + + GooList **getSelectionWords(PDFRectangle *selection, + SelectionStyle style, + int *nLines); + + // Find a string by character position and length. If found, sets + // the text bounding rectangle and returns true; otherwise returns + // false. + GBool findCharRange(int pos, int length, + double *xMin, double *yMin, + double *xMax, double *yMax); + + // Dump contents of page to a file. + void dump(void *outputStream, TextOutputFunc outputFunc, + GBool physLayout); + + // Get the head of the linked list of TextFlows. + TextFlow *getFlows() { return flows; } + + // If true, will combine characters when a base and combining + // character are drawn on eachother. + void setMergeCombining(GBool merge); + +#if TEXTOUT_WORD_LIST + // Build a flat word list, in content stream order (if + // this->rawOrder is true), physical layout order (if <physLayout> + // is true and this->rawOrder is false), or reading order (if both + // flags are false). + TextWordList *makeWordList(GBool physLayout); +#endif + +private: + + // Destructor. + ~TextPage(); + + void clear(); + void assignColumns(TextLineFrag *frags, int nFrags, GBool rot); + int dumpFragment(Unicode *text, int len, UnicodeMap *uMap, GooString *s); + + GBool rawOrder; // keep text in content stream order + GBool mergeCombining; // merge when combining and base characters + // are drawn on top of each other + + double pageWidth, pageHeight; // width and height of current page + TextWord *curWord; // currently active string + int charPos; // next character position (within content + // stream) + TextFontInfo *curFont; // current font + double curFontSize; // current font size + int nest; // current nesting level (for Type 3 fonts) + int nTinyChars; // number of "tiny" chars seen so far + GBool lastCharOverlap; // set if the last added char overlapped the + // previous char + + TextPool *pools[4]; // a "pool" of TextWords for each rotation + TextFlow *flows; // linked list of flows + TextBlock **blocks; // array of blocks, in yx order + int nBlocks; // number of blocks + int primaryRot; // primary rotation + GBool primaryLR; // primary direction (true means L-to-R, + // false means R-to-L) + TextWord *rawWords; // list of words, in raw order (only if + // rawOrder is set) + TextWord *rawLastWord; // last word on rawWords list + + GooList *fonts; // all font info objects used on this + // page [TextFontInfo] + + double lastFindXMin, // coordinates of the last "find" result + lastFindYMin; + GBool haveLastFind; + + GooList *underlines; // [TextUnderline] + GooList *links; // [TextLink] + + int refCnt; + + friend class TextLine; + friend class TextLineFrag; + friend class TextBlock; + friend class TextFlow; + friend class TextWordList; + friend class TextSelectionPainter; + friend class TextSelectionDumper; +}; + +//------------------------------------------------------------------------ +// ActualText +//------------------------------------------------------------------------ + +class ActualText { +public: + // Create an ActualText + ActualText(TextPage *out); + ~ActualText(); + + void addChar(GfxState *state, double x, double y, + double dx, double dy, + CharCode c, int nBytes, Unicode *u, int uLen); + void begin(GfxState *state, GooString *text); + void end(GfxState *state); + +private: + TextPage *text; + + GooString *actualText; // replacement text for the span + double actualTextX0; + double actualTextY0; + double actualTextX1; + double actualTextY1; + int actualTextNBytes; +}; + + +//------------------------------------------------------------------------ +// TextOutputDev +//------------------------------------------------------------------------ + +class TextOutputDev: public OutputDev { +public: + + // Open a text output file. If <fileName> is NULL, no file is + // written (this is useful, e.g., for searching text). If + // <physLayoutA> is true, the original physical layout of the text + // is maintained. If <rawOrder> is true, the text is kept in + // content stream order. + TextOutputDev(char *fileName, GBool physLayoutA, + double fixedPitchA, GBool rawOrderA, + GBool append); + + // Create a TextOutputDev which will write to a generic stream. If + // <physLayoutA> is true, the original physical layout of the text + // is maintained. If <rawOrder> is true, the text is kept in + // content stream order. + TextOutputDev(TextOutputFunc func, void *stream, + GBool physLayoutA, double fixedPitchA, + GBool rawOrderA); + + // Destructor. + virtual ~TextOutputDev(); + + // Check if file was successfully created. + virtual GBool isOk() { return ok; } + + //---- get info about output device + + // Does this device use upside-down coordinates? + // (Upside-down means (0,0) is the top left corner of the page.) + virtual GBool upsideDown() { return gTrue; } + + // Does this device use drawChar() or drawString()? + virtual GBool useDrawChar() { return gTrue; } + + // Does this device use beginType3Char/endType3Char? Otherwise, + // text in Type 3 fonts will be drawn with drawChar/drawString. + virtual GBool interpretType3Chars() { return gFalse; } + + // Does this device need non-text content? + virtual GBool needNonText() { return gFalse; } + + // Does this device require incCharCount to be called for text on + // non-shown layers? + virtual GBool needCharCount() { return gTrue; } + + //----- initialization and control + + // Start a page. + virtual void startPage(int pageNum, GfxState *state, XRef *xref); + + // End a page. + virtual void endPage(); + + //----- save/restore graphics state + virtual void restoreState(GfxState *state); + + //----- update text state + virtual void updateFont(GfxState *state); + + //----- text drawing + virtual void beginString(GfxState *state, GooString *s); + virtual void endString(GfxState *state); + virtual void drawChar(GfxState *state, double x, double y, + double dx, double dy, + double originX, double originY, + CharCode c, int nBytes, Unicode *u, int uLen); + virtual void incCharCount(int nChars); + virtual void beginActualText(GfxState *state, GooString *text); + virtual void endActualText(GfxState *state); + + //----- path painting + virtual void stroke(GfxState *state); + virtual void fill(GfxState *state); + virtual void eoFill(GfxState *state); + + //----- link borders + virtual void processLink(AnnotLink *link); + + //----- special access + + // Find a string. If <startAtTop> is true, starts looking at the + // top of the page; else if <startAtLast> is true, starts looking + // immediately after the last find result; else starts looking at + // <xMin>,<yMin>. If <stopAtBottom> is true, stops looking at the + // bottom of the page; else if <stopAtLast> is true, stops looking + // just before the last find result; else stops looking at + // <xMax>,<yMax>. + GBool findText(Unicode *s, int len, + GBool startAtTop, GBool stopAtBottom, + GBool startAtLast, GBool stopAtLast, + GBool caseSensitive, GBool backward, + GBool wholeWord, + double *xMin, double *yMin, + double *xMax, double *yMax); + + // Get the text which is inside the specified rectangle. + GooString *getText(double xMin, double yMin, + double xMax, double yMax); + + // Find a string by character position and length. If found, sets + // the text bounding rectangle and returns true; otherwise returns + // false. + GBool findCharRange(int pos, int length, + double *xMin, double *yMin, + double *xMax, double *yMax); + + void drawSelection(OutputDev *out, double scale, int rotation, + PDFRectangle *selection, + SelectionStyle style, + GfxColor *glyph_color, GfxColor *box_color); + + GooList *getSelectionRegion(PDFRectangle *selection, + SelectionStyle style, + double scale); + + GooString *getSelectionText(PDFRectangle *selection, + SelectionStyle style); + + // If true, will combine characters when a base and combining + // character are drawn on eachother. + void setMergeCombining(GBool merge); + +#if TEXTOUT_WORD_LIST + // Build a flat word list, in content stream order (if + // this->rawOrder is true), physical layout order (if + // this->physLayout is true and this->rawOrder is false), or reading + // order (if both flags are false). + TextWordList *makeWordList(); +#endif + + // Returns the TextPage object for the last rasterized page, + // transferring ownership to the caller. + TextPage *takeText(); + + // Turn extra processing for HTML conversion on or off. + void enableHTMLExtras(GBool doHTMLA) { doHTML = doHTMLA; } + +private: + + TextOutputFunc outputFunc; // output function + void *outputStream; // output stream + GBool needClose; // need to close the output file? + // (only if outputStream is a FILE*) + TextPage *text; // text for the current page + GBool physLayout; // maintain original physical layout when + // dumping text + double fixedPitch; // if physLayout is true and this is non-zero, + // assume fixed-pitch characters with this + // width + GBool rawOrder; // keep text in content stream order + GBool doHTML; // extra processing for HTML conversion + GBool ok; // set up ok? + + ActualText *actualText; +}; + +#endif diff --git a/source/libs/poppler/poppler-0.32.0/poppler/UTF.cc b/source/libs/poppler/poppler-0.33.0/poppler/UTF.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/UTF.cc rename to source/libs/poppler/poppler-0.33.0/poppler/UTF.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/UTF.h b/source/libs/poppler/poppler-0.33.0/poppler/UTF.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/UTF.h rename to source/libs/poppler/poppler-0.33.0/poppler/UTF.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/UTF8.h b/source/libs/poppler/poppler-0.33.0/poppler/UTF8.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/UTF8.h rename to source/libs/poppler/poppler-0.33.0/poppler/UTF8.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/UnicodeCClassTables.h b/source/libs/poppler/poppler-0.33.0/poppler/UnicodeCClassTables.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/UnicodeCClassTables.h rename to source/libs/poppler/poppler-0.33.0/poppler/UnicodeCClassTables.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/UnicodeCompTables.h b/source/libs/poppler/poppler-0.33.0/poppler/UnicodeCompTables.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/UnicodeCompTables.h rename to source/libs/poppler/poppler-0.33.0/poppler/UnicodeCompTables.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/UnicodeDecompTables.h b/source/libs/poppler/poppler-0.33.0/poppler/UnicodeDecompTables.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/UnicodeDecompTables.h rename to source/libs/poppler/poppler-0.33.0/poppler/UnicodeDecompTables.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/UnicodeMap.cc b/source/libs/poppler/poppler-0.33.0/poppler/UnicodeMap.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/UnicodeMap.cc rename to source/libs/poppler/poppler-0.33.0/poppler/UnicodeMap.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/UnicodeMap.h b/source/libs/poppler/poppler-0.33.0/poppler/UnicodeMap.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/UnicodeMap.h rename to source/libs/poppler/poppler-0.33.0/poppler/UnicodeMap.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/UnicodeMapTables.h b/source/libs/poppler/poppler-0.33.0/poppler/UnicodeMapTables.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/UnicodeMapTables.h rename to source/libs/poppler/poppler-0.33.0/poppler/UnicodeMapTables.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/UnicodeTypeTable.cc b/source/libs/poppler/poppler-0.33.0/poppler/UnicodeTypeTable.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/UnicodeTypeTable.cc rename to source/libs/poppler/poppler-0.33.0/poppler/UnicodeTypeTable.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/UnicodeTypeTable.h b/source/libs/poppler/poppler-0.33.0/poppler/UnicodeTypeTable.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/UnicodeTypeTable.h rename to source/libs/poppler/poppler-0.33.0/poppler/UnicodeTypeTable.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/ViewerPreferences.cc b/source/libs/poppler/poppler-0.33.0/poppler/ViewerPreferences.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/ViewerPreferences.cc rename to source/libs/poppler/poppler-0.33.0/poppler/ViewerPreferences.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/ViewerPreferences.h b/source/libs/poppler/poppler-0.33.0/poppler/ViewerPreferences.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/ViewerPreferences.h rename to source/libs/poppler/poppler-0.33.0/poppler/ViewerPreferences.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/XRef.cc b/source/libs/poppler/poppler-0.33.0/poppler/XRef.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/XRef.cc rename to source/libs/poppler/poppler-0.33.0/poppler/XRef.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/XRef.h b/source/libs/poppler/poppler-0.33.0/poppler/XRef.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/XRef.h rename to source/libs/poppler/poppler-0.33.0/poppler/XRef.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/XpdfPluginAPI.cc b/source/libs/poppler/poppler-0.33.0/poppler/XpdfPluginAPI.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/XpdfPluginAPI.cc rename to source/libs/poppler/poppler-0.33.0/poppler/XpdfPluginAPI.cc diff --git a/source/libs/poppler/poppler-0.32.0/poppler/XpdfPluginAPI.h b/source/libs/poppler/poppler-0.33.0/poppler/XpdfPluginAPI.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/XpdfPluginAPI.h rename to source/libs/poppler/poppler-0.33.0/poppler/XpdfPluginAPI.h diff --git a/source/libs/poppler/poppler-0.32.0/poppler/gen-unicode-tables.py b/source/libs/poppler/poppler-0.33.0/poppler/gen-unicode-tables.py old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/gen-unicode-tables.py rename to source/libs/poppler/poppler-0.33.0/poppler/gen-unicode-tables.py diff --git a/source/libs/poppler/poppler-0.32.0/poppler/poppler-config.h.cmake b/source/libs/poppler/poppler-0.33.0/poppler/poppler-config.h.cmake old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/poppler-config.h.cmake rename to source/libs/poppler/poppler-0.33.0/poppler/poppler-config.h.cmake diff --git a/source/libs/poppler/poppler-0.32.0/poppler/poppler-config.h.in b/source/libs/poppler/poppler-0.33.0/poppler/poppler-config.h.in old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/poppler-config.h.in rename to source/libs/poppler/poppler-0.33.0/poppler/poppler-config.h.in diff --git a/source/libs/poppler/poppler-0.32.0/poppler/strtok_r.cpp b/source/libs/poppler/poppler-0.33.0/poppler/strtok_r.cpp old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/poppler/strtok_r.cpp rename to source/libs/poppler/poppler-0.33.0/poppler/strtok_r.cpp diff --git a/source/libs/poppler/poppler-0.32.0/splash/Makefile.am b/source/libs/poppler/poppler-0.33.0/splash/Makefile.am old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/Makefile.am rename to source/libs/poppler/poppler-0.33.0/splash/Makefile.am diff --git a/source/libs/poppler/poppler-0.32.0/splash/Splash.cc b/source/libs/poppler/poppler-0.33.0/splash/Splash.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/Splash.cc rename to source/libs/poppler/poppler-0.33.0/splash/Splash.cc diff --git a/source/libs/poppler/poppler-0.32.0/splash/Splash.h b/source/libs/poppler/poppler-0.33.0/splash/Splash.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/Splash.h rename to source/libs/poppler/poppler-0.33.0/splash/Splash.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashBitmap.cc b/source/libs/poppler/poppler-0.33.0/splash/SplashBitmap.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashBitmap.cc rename to source/libs/poppler/poppler-0.33.0/splash/SplashBitmap.cc diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashBitmap.h b/source/libs/poppler/poppler-0.33.0/splash/SplashBitmap.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashBitmap.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashBitmap.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashClip.cc b/source/libs/poppler/poppler-0.33.0/splash/SplashClip.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashClip.cc rename to source/libs/poppler/poppler-0.33.0/splash/SplashClip.cc diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashClip.h b/source/libs/poppler/poppler-0.33.0/splash/SplashClip.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashClip.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashClip.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashErrorCodes.h b/source/libs/poppler/poppler-0.33.0/splash/SplashErrorCodes.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashErrorCodes.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashErrorCodes.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashFTFont.cc b/source/libs/poppler/poppler-0.33.0/splash/SplashFTFont.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashFTFont.cc rename to source/libs/poppler/poppler-0.33.0/splash/SplashFTFont.cc diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashFTFont.h b/source/libs/poppler/poppler-0.33.0/splash/SplashFTFont.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashFTFont.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashFTFont.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashFTFontEngine.cc b/source/libs/poppler/poppler-0.33.0/splash/SplashFTFontEngine.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashFTFontEngine.cc rename to source/libs/poppler/poppler-0.33.0/splash/SplashFTFontEngine.cc diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashFTFontEngine.h b/source/libs/poppler/poppler-0.33.0/splash/SplashFTFontEngine.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashFTFontEngine.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashFTFontEngine.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashFTFontFile.cc b/source/libs/poppler/poppler-0.33.0/splash/SplashFTFontFile.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashFTFontFile.cc rename to source/libs/poppler/poppler-0.33.0/splash/SplashFTFontFile.cc diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashFTFontFile.h b/source/libs/poppler/poppler-0.33.0/splash/SplashFTFontFile.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashFTFontFile.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashFTFontFile.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashFont.cc b/source/libs/poppler/poppler-0.33.0/splash/SplashFont.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashFont.cc rename to source/libs/poppler/poppler-0.33.0/splash/SplashFont.cc diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashFont.h b/source/libs/poppler/poppler-0.33.0/splash/SplashFont.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashFont.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashFont.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashFontEngine.cc b/source/libs/poppler/poppler-0.33.0/splash/SplashFontEngine.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashFontEngine.cc rename to source/libs/poppler/poppler-0.33.0/splash/SplashFontEngine.cc diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashFontEngine.h b/source/libs/poppler/poppler-0.33.0/splash/SplashFontEngine.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashFontEngine.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashFontEngine.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashFontFile.cc b/source/libs/poppler/poppler-0.33.0/splash/SplashFontFile.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashFontFile.cc rename to source/libs/poppler/poppler-0.33.0/splash/SplashFontFile.cc diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashFontFile.h b/source/libs/poppler/poppler-0.33.0/splash/SplashFontFile.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashFontFile.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashFontFile.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashFontFileID.cc b/source/libs/poppler/poppler-0.33.0/splash/SplashFontFileID.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashFontFileID.cc rename to source/libs/poppler/poppler-0.33.0/splash/SplashFontFileID.cc diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashFontFileID.h b/source/libs/poppler/poppler-0.33.0/splash/SplashFontFileID.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashFontFileID.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashFontFileID.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashGlyphBitmap.h b/source/libs/poppler/poppler-0.33.0/splash/SplashGlyphBitmap.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashGlyphBitmap.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashGlyphBitmap.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashMath.h b/source/libs/poppler/poppler-0.33.0/splash/SplashMath.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashMath.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashMath.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashPath.cc b/source/libs/poppler/poppler-0.33.0/splash/SplashPath.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashPath.cc rename to source/libs/poppler/poppler-0.33.0/splash/SplashPath.cc diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashPath.h b/source/libs/poppler/poppler-0.33.0/splash/SplashPath.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashPath.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashPath.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashPattern.cc b/source/libs/poppler/poppler-0.33.0/splash/SplashPattern.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashPattern.cc rename to source/libs/poppler/poppler-0.33.0/splash/SplashPattern.cc diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashPattern.h b/source/libs/poppler/poppler-0.33.0/splash/SplashPattern.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashPattern.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashPattern.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashScreen.cc b/source/libs/poppler/poppler-0.33.0/splash/SplashScreen.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashScreen.cc rename to source/libs/poppler/poppler-0.33.0/splash/SplashScreen.cc diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashScreen.h b/source/libs/poppler/poppler-0.33.0/splash/SplashScreen.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashScreen.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashScreen.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashState.cc b/source/libs/poppler/poppler-0.33.0/splash/SplashState.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashState.cc rename to source/libs/poppler/poppler-0.33.0/splash/SplashState.cc diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashState.h b/source/libs/poppler/poppler-0.33.0/splash/SplashState.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashState.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashState.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashT1Font.cc b/source/libs/poppler/poppler-0.33.0/splash/SplashT1Font.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashT1Font.cc rename to source/libs/poppler/poppler-0.33.0/splash/SplashT1Font.cc diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashT1Font.h b/source/libs/poppler/poppler-0.33.0/splash/SplashT1Font.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashT1Font.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashT1Font.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashT1FontEngine.cc b/source/libs/poppler/poppler-0.33.0/splash/SplashT1FontEngine.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashT1FontEngine.cc rename to source/libs/poppler/poppler-0.33.0/splash/SplashT1FontEngine.cc diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashT1FontEngine.h b/source/libs/poppler/poppler-0.33.0/splash/SplashT1FontEngine.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashT1FontEngine.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashT1FontEngine.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashT1FontFile.cc b/source/libs/poppler/poppler-0.33.0/splash/SplashT1FontFile.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashT1FontFile.cc rename to source/libs/poppler/poppler-0.33.0/splash/SplashT1FontFile.cc diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashT1FontFile.h b/source/libs/poppler/poppler-0.33.0/splash/SplashT1FontFile.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashT1FontFile.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashT1FontFile.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashTypes.h b/source/libs/poppler/poppler-0.33.0/splash/SplashTypes.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashTypes.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashTypes.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashXPath.cc b/source/libs/poppler/poppler-0.33.0/splash/SplashXPath.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashXPath.cc rename to source/libs/poppler/poppler-0.33.0/splash/SplashXPath.cc diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashXPath.h b/source/libs/poppler/poppler-0.33.0/splash/SplashXPath.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashXPath.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashXPath.h diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashXPathScanner.cc b/source/libs/poppler/poppler-0.33.0/splash/SplashXPathScanner.cc old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashXPathScanner.cc rename to source/libs/poppler/poppler-0.33.0/splash/SplashXPathScanner.cc diff --git a/source/libs/poppler/poppler-0.32.0/splash/SplashXPathScanner.h b/source/libs/poppler/poppler-0.33.0/splash/SplashXPathScanner.h old mode 100755 new mode 100644 similarity index 100% rename from source/libs/poppler/poppler-0.32.0/splash/SplashXPathScanner.h rename to source/libs/poppler/poppler-0.33.0/splash/SplashXPathScanner.h diff --git a/source/libs/poppler/version.ac b/source/libs/poppler/version.ac index 20359d39c..2be18a5ae 100644 --- a/source/libs/poppler/version.ac +++ b/source/libs/poppler/version.ac @@ -8,4 +8,4 @@ dnl dnl -------------------------------------------------------- dnl dnl m4-include this file to define the current poppler version -m4_define([poppler_version], [0.32.0]) +m4_define([poppler_version], [0.33.0]) diff --git a/source/libs/zlib/configure b/source/libs/zlib/configure index c514ba715..26e24516d 100755 --- a/source/libs/zlib/configure +++ b/source/libs/zlib/configure @@ -3824,13 +3824,13 @@ else if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_cflags="-Wimplicit -Wreturn-type" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement" ;; #( *) : ;; esac case `$CC -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -3842,7 +3842,7 @@ esac kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition" ;; #( *) : ;; diff --git a/source/libs/zziplib/configure b/source/libs/zziplib/configure index 6dc3cb694..5e0860088 100755 --- a/source/libs/zziplib/configure +++ b/source/libs/zziplib/configure @@ -4156,13 +4156,13 @@ else if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_cflags="-Wimplicit -Wreturn-type" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement" ;; #( *) : ;; esac case `$CC -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -4174,7 +4174,7 @@ esac kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition" ;; #( *) : ;; diff --git a/source/m4/ChangeLog b/source/m4/ChangeLog index ae96f27fc..0dea449af 100644 --- a/source/m4/ChangeLog +++ b/source/m4/ChangeLog @@ -1,3 +1,11 @@ +2015-06-12 Peter Breitenlohner <peb@mppmu.mpg.de> + + * kpse-warnings.m4: Warning flags for gcc 5.x. + * kpse-web2c.m4: Better handling of --disable-mf-nowin. + * kpse-common.m4: Check if <ctype.h> declares isascii. + * kpse-setup.m4: MFLuaJIT requires LuaJIT. + * kpse-poppler-flags.m4: LuaTeX requires poppler 0.30 or better. + 2015-03-30 Peter Breitenlohner <peb@mppmu.mpg.de> * kpse-web2c.m4: Add KPSE_WITH_XMF and KPSE_XMF_COND. diff --git a/source/m4/kpse-common.m4 b/source/m4/kpse-common.m4 index 9c98f349e..c1f193d85 100644 --- a/source/m4/kpse-common.m4 +++ b/source/m4/kpse-common.m4 @@ -261,6 +261,9 @@ AC_TYPE_UINT64_T AS_CASE([:$ac_cv_c_int64_t:$ac_cv_c_int64_t:], [*':no:'*], [AC_MSG_ERROR([Sorry, your compiler does not support 64-bit integer types.])]) dnl +dnl Check if <ctype.h> declares isascii. +AC_CHECK_DECLS([isascii], [], [], [[#include <ctype.h>]]) +dnl dnl Check whether struct stat provides high-res time. AC_CHECK_MEMBERS([struct stat.st_mtim]) ]) # KPSE_COMMON diff --git a/source/m4/kpse-poppler-flags.m4 b/source/m4/kpse-poppler-flags.m4 index 2883395cf..812d8c7d0 100644 --- a/source/m4/kpse-poppler-flags.m4 +++ b/source/m4/kpse-poppler-flags.m4 @@ -28,7 +28,7 @@ AC_DEFUN([KPSE_POPPLER_OPTIONS], [_KPSE_LIB_OPTIONS([poppler], [$1], [pkg-config # KPSE_POPPLER_SYSTEM_FLAGS # ------------------------- AC_DEFUN([KPSE_POPPLER_SYSTEM_FLAGS], [dnl -_KPSE_PKG_CONFIG_FLAGS([poppler], [poppler], [0.18]) +_KPSE_PKG_CONFIG_FLAGS([poppler], [poppler], [0.30]) POPPLER_VERSION='-DPOPPLER_VERSION=\"'`$PKG_CONFIG poppler --modversion`'\"' POPPLER_INCLUDES="$POPPLER_VERSION $POPPLER_INCLUDES" ]) # KPSE_POPPLER_SYSTEM_FLAGS diff --git a/source/m4/kpse-setup.m4 b/source/m4/kpse-setup.m4 index b9c9bcce0..145ca0f4a 100644 --- a/source/m4/kpse-setup.m4 +++ b/source/m4/kpse-setup.m4 @@ -81,12 +81,14 @@ AS_CASE([$with_x:$kpse_cv_have_win32], [with_x=no AC_MSG_NOTICE([WIN32 -> `--without-x']) ac_configure_args="$ac_configure_args '--without-x'"]) -AS_CASE([$enable_luajittex], +AC_FOREACH([Kpse_Pkg], [luajittex mfluajit], [dnl +AS_CASE([$enable_]Kpse_Pkg, [yes | no], [:], [AS_CASE([$host], [alpha* | sparc* | x86_64-*-cygwin | powerpc-*-darwin* ], - [AC_MSG_NOTICE([$host -> `--disable-luajittex']) - ac_configure_args="$ac_configure_args '--disable-luajittex'"])]) + [AC_MSG_NOTICE([$host -> `--disable-]Kpse_Pkg[']) + ac_configure_args="$ac_configure_args '--disable-]Kpse_Pkg['"])]) +]) KPSE_FOR_PKGS([utils], [m4_sinclude(kpse_TL[utils/]Kpse_Pkg[/ac/withenable.ac])]) KPSE_FOR_PKGS([texk], [m4_sinclude(kpse_TL[texk/]Kpse_Pkg[/ac/withenable.ac])]) KPSE_FOR_PKGS([libs], [m4_sinclude(kpse_TL[libs/]Kpse_Pkg[/ac/withenable.ac])]) diff --git a/source/m4/kpse-warnings.m4 b/source/m4/kpse-warnings.m4 index 54f2e0a1a..523a53535 100644 --- a/source/m4/kpse-warnings.m4 +++ b/source/m4/kpse-warnings.m4 @@ -1,5 +1,5 @@ # Public macros for the TeX Live (TL) tree. -# Copyright (C) 2009-2013 Peter Breitenlohner <tex-live@tug.org> +# Copyright (C) 2009-2015 Peter Breitenlohner <tex-live@tug.org> # # This file is free software; the copyright holder # gives unlimited permission to copy and/or distribute it, @@ -148,10 +148,10 @@ m4_define([_KPSE_WARNING_GNU_CFLAGS], if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_$2="-Wimplicit -Wreturn-type" AS_CASE([`$[]$1 -dumpversion`], - [3.4.* | 4.*], + [3.4.* | 4.* | 5.*], [kpse_cv_warning_$2="$kpse_cv_warning_$2 -Wdeclaration-after-statement"]) AS_CASE([`$[]$1 -dumpversion`], - [3.@<:@234@:>@.* | 4.*], + [3.@<:@234@:>@.* | 4.* | 5.*], [kpse_cv_warning_$2="$kpse_cv_warning_$2 -Wno-unknown-pragmas"]) if test "x$enable_compiler_warnings" != xmin; then kpse_cv_warning_$2="-Wall -Wunused $kpse_cv_warning_$2" @@ -160,7 +160,7 @@ if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_$2="$kpse_cv_warning_$2 -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_$2="$kpse_cv_warning_$2 -Wcast-qual -Wcast-align -Wwrite-strings" AS_CASE([`$[]$1 -dumpversion`], - [3.4.* | 4.*], + [3.4.* | 4.* | 5.*], [kpse_cv_warning_$2="$kpse_cv_warning_$2 -Wold-style-definition"]) if test "x$enable_compiler_warnings" != xmax; then kpse_cv_warning_$2="$kpse_cv_warning_$2 -Wshadow" @@ -183,7 +183,7 @@ if test "x$enable_compiler_warnings" != xno; then [3.* | 4.@<:@012345@:>@.*], [kpse_cv_warning_$2="-Wimplicit $kpse_cv_warning_$2"]) AS_CASE([`$[]$1 -dumpversion`], - [3.@<:@234@:>@.* | 4.*], + [3.@<:@234@:>@.* | 4.* | 5.*], [kpse_cv_warning_$2="$kpse_cv_warning_$2 -Wno-unknown-pragmas"]) if test "x$enable_compiler_warnings" != xmin; then kpse_cv_warning_$2="-Wall -Wunused $kpse_cv_warning_$2" diff --git a/source/m4/kpse-web2c.m4 b/source/m4/kpse-web2c.m4 index 6fd219f67..484a91c6a 100644 --- a/source/m4/kpse-web2c.m4 +++ b/source/m4/kpse-web2c.m4 @@ -69,6 +69,9 @@ AC_ARG_ENABLE([$1-nowin], m4_if([$3], [yes], [do not ])[build a separate non-window-capable $4], m4_eval(kpse_indent_26+2)))[]dnl +AS_CASE([$enable_$1_nowin], + [yes | no], , + [enable_$1_nowin=$3]) ])[]dnl m4_ifval m4_ifval([$5], [ test "x$enable_web2c:$enable_$1" = xyes:yes && { diff --git a/source/tardate.ac b/source/tardate.ac index fd83bb2b8..5f2290854 100644 --- a/source/tardate.ac +++ b/source/tardate.ac @@ -8,4 +8,4 @@ dnl dnl -------------------------------------------------------- dnl dnl m4-include this file to define the current TeX Live tarball version -m4_define([tex_live_tardate], [2015-03-07]) +m4_define([tex_live_tardate], [2015-06-12]) diff --git a/source/texk/configure b/source/texk/configure index 822043223..080b6ed27 100755 --- a/source/texk/configure +++ b/source/texk/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for TeX Live texk 2015. +# Generated by GNU Autoconf 2.69 for TeX Live texk 2016/dev. # # Report bugs to <peb@mppmu.mpg.de>. # @@ -579,8 +579,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='TeX Live texk' PACKAGE_TARNAME='tex-live-texk' -PACKAGE_VERSION='2015' -PACKAGE_STRING='TeX Live texk 2015' +PACKAGE_VERSION='2016/dev' +PACKAGE_STRING='TeX Live texk 2016/dev' PACKAGE_BUGREPORT='peb@mppmu.mpg.de' PACKAGE_URL='' @@ -726,6 +726,10 @@ enable_xetex enable_xetex_synctex enable_mf enable_mf_nowin +enable_mflua +enable_mflua_nowin +enable_mfluajit +enable_mfluajit_nowin with_mf_x_toolkit enable_epsfwin enable_hp2627win @@ -1315,7 +1319,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures TeX Live texk 2015 to adapt to many kinds of systems. +\`configure' configures TeX Live texk 2016/dev to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1385,7 +1389,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of TeX Live texk 2015:";; + short | recursive ) echo "Configuration of TeX Live texk 2016/dev:";; esac cat <<\_ACEOF @@ -1433,6 +1437,10 @@ Optional Features: --disable-mf do not compile and install METAFONT --disable-mf-nowin do not build a separate non-window-capable METAFONT + --disable-mflua do not compile and install MFLua + --enable-mflua-nowin build a separate non-window-capable MFLua + --disable-mfluajit do not compile and install MFLuaJIT + --enable-mfluajit-nowin build a separate non-window-capable MFLuaJIT --enable-epsfwin include EPSF pseudo window support --enable-hp2627win include HP 2627 window support --enable-mftalkwin include mftalk (generic server) window support @@ -1571,7 +1579,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -TeX Live texk configure 2015 +TeX Live texk configure 2016/dev generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1672,7 +1680,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by TeX Live texk $as_me 2015, which was +It was created by TeX Live texk $as_me 2016/dev, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3163,6 +3171,20 @@ $as_echo "$as_me: $host -> \`--disable-luajittex'" >&6;} ;; esac ;; esac +case $enable_mfluajit in #( + yes | no) : + : ;; #( + *) : + case $host in #( + alpha* | sparc* | x86_64-*-cygwin | powerpc-*-darwin* ) : + { $as_echo "$as_me:${as_lineno-$LINENO}: $host -> \`--disable-mfluajit'" >&5 +$as_echo "$as_me: $host -> \`--disable-mfluajit'" >&6;} + ac_configure_args="$ac_configure_args '--disable-mfluajit'" ;; #( + *) : + ;; +esac ;; +esac + ## texk/web2c/ac/withenable.ac: configure.ac fragment for the TeX Live subdirectory texk/web2c/ ## configure options and TL libraries required for web2c @@ -3475,6 +3497,62 @@ esac if test "${enable_mf_nowin+set}" = set; then : enableval=$enable_mf_nowin; fi +case $enable_mf_nowin in #( + yes | no) : + ;; #( + *) : + enable_mf_nowin=yes ;; +esac +# Check whether --enable-mflua was given. +if test "${enable_mflua+set}" = set; then : + enableval=$enable_mflua; +fi +case $enable_mflua in #( + yes | no) : + ;; #( + *) : + enable_mflua=yes ;; +esac + +# Check whether --enable-mflua-nowin was given. +if test "${enable_mflua_nowin+set}" = set; then : + enableval=$enable_mflua_nowin; +fi +case $enable_mflua_nowin in #( + yes | no) : + ;; #( + *) : + enable_mflua_nowin=no ;; +esac + +test "x$enable_web2c:$enable_mflua" = xyes:yes && { + need_lua52=yes +} +# Check whether --enable-mfluajit was given. +if test "${enable_mfluajit+set}" = set; then : + enableval=$enable_mfluajit; +fi +case $enable_mfluajit in #( + yes | no) : + ;; #( + *) : + enable_mfluajit=yes ;; +esac + +# Check whether --enable-mfluajit-nowin was given. +if test "${enable_mfluajit_nowin+set}" = set; then : + enableval=$enable_mfluajit_nowin; +fi +case $enable_mfluajit_nowin in #( + yes | no) : + ;; #( + *) : + enable_mfluajit_nowin=no ;; +esac + +test "x$enable_web2c:$enable_mfluajit" = xyes:yes && { + need_luajit=yes +} # Check whether --with-mf-x-toolkit was given. if test "${with_mf_x_toolkit+set}" = set; then : @@ -4434,7 +4512,7 @@ fi # Define the identity of the package. PACKAGE='tex-live-texk' - VERSION='2015' + VERSION='2016/dev' cat >>confdefs.h <<_ACEOF @@ -4717,13 +4795,13 @@ else if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_cflags="-Wimplicit -Wreturn-type" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement" ;; #( *) : ;; esac case `$CC -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -4735,7 +4813,7 @@ esac kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition" ;; #( *) : ;; @@ -5364,7 +5442,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by TeX Live texk $as_me 2015, which was +This file was extended by TeX Live texk $as_me 2016/dev, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5421,7 +5499,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -TeX Live texk config.status 2015 +TeX Live texk config.status 2016/dev configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/source/texk/kpathsea/ChangeLog b/source/texk/kpathsea/ChangeLog index 5a76fc154..d7b0f1b81 100644 --- a/source/texk/kpathsea/ChangeLog +++ b/source/texk/kpathsea/ChangeLog @@ -1,3 +1,12 @@ +2015-06-12 Peter Breitenlohner <peb@mppmu.mpg.de> + + * version.ac: Update version number 6.2.1 => 6.2.2dev. + * configure.ac: Drop test for isascii (now in KPSE_COMMON). + +2015-05-21 Karl Berry <karl@tug.org> + + * TL'15. + 2015-05-03 Karl Berry <karl@tug.org> * kpsewhich.c: copyright 2015. diff --git a/source/texk/kpathsea/NEWS b/source/texk/kpathsea/NEWS index 9985f3210..85661c301 100644 --- a/source/texk/kpathsea/NEWS +++ b/source/texk/kpathsea/NEWS @@ -1,6 +1,6 @@ This file records noteworthy changes. (Public domain.) -6.2.1 (for TeX Live 2015) +6.2.1 (for TeX Live 2015, 21 May 2015) * search path information output with new option --help-formats to kpsewhich, no longer with --help. * install <kpathsea/c-auto.h> in an architecture dependent location diff --git a/source/texk/kpathsea/c-auto.in b/source/texk/kpathsea/c-auto.in index aa8a1d58e..802962651 100644 --- a/source/texk/kpathsea/c-auto.in +++ b/source/texk/kpathsea/c-auto.in @@ -23,7 +23,7 @@ #define KPATHSEA_C_AUTO_H /* kpathsea: the version string. */ -#define KPSEVERSION "kpathsea version 6.2.1" +#define KPSEVERSION "kpathsea version 6.2.2dev" /* Define to 1 if the `closedir' function returns void instead of `int'. */ #undef CLOSEDIR_VOID diff --git a/source/texk/kpathsea/configure b/source/texk/kpathsea/configure index da88554ef..d0f4dc580 100755 --- a/source/texk/kpathsea/configure +++ b/source/texk/kpathsea/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for Kpathsea 6.2.1. +# Generated by GNU Autoconf 2.69 for Kpathsea 6.2.2dev. # # Report bugs to <tex-k@tug.org>. # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='Kpathsea' PACKAGE_TARNAME='kpathsea' -PACKAGE_VERSION='6.2.1' -PACKAGE_STRING='Kpathsea 6.2.1' +PACKAGE_VERSION='6.2.2dev' +PACKAGE_STRING='Kpathsea 6.2.2dev' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' @@ -1339,7 +1339,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures Kpathsea 6.2.1 to adapt to many kinds of systems. +\`configure' configures Kpathsea 6.2.2dev to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1409,7 +1409,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of Kpathsea 6.2.1:";; + short | recursive ) echo "Configuration of Kpathsea 6.2.2dev:";; esac cat <<\_ACEOF @@ -1537,7 +1537,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -Kpathsea configure 6.2.1 +Kpathsea configure 6.2.2dev generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2087,6 +2087,52 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_find_uintX_t +# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES +# --------------------------------------------- +# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR +# accordingly. +ac_fn_c_check_decl () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + as_decl_name=`echo $2|sed 's/ *(.*//'` + as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 +$as_echo_n "checking whether $as_decl_name is declared... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +#ifndef $as_decl_name +#ifdef __cplusplus + (void) $as_decl_use; +#else + (void) $as_decl_name; +#endif +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_decl + # ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES # ---------------------------------------------------- # Tries to find if the field MEMBER exists in type AGGR, after including @@ -2326,57 +2372,11 @@ rm -f conftest.val as_fn_set_status $ac_retval } # ac_fn_c_compute_int - -# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES -# --------------------------------------------- -# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR -# accordingly. -ac_fn_c_check_decl () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - as_decl_name=`echo $2|sed 's/ *(.*//'` - as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 -$as_echo_n "checking whether $as_decl_name is declared... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -#ifndef $as_decl_name -#ifdef __cplusplus - (void) $as_decl_use; -#else - (void) $as_decl_name; -#endif -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_decl cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by Kpathsea $as_me 6.2.1, which was +It was created by Kpathsea $as_me 6.2.2dev, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2757,14 +2757,14 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. -KPSEVERSION=6.2.1 +KPSEVERSION=6.2.2dev -KPSE_LT_VERSINFO=8:1:2 +KPSE_LT_VERSINFO=8:2:2 - WEB2CVERSION=2015 + WEB2CVERSION=2016/dev am__api_version='1.15' @@ -8071,7 +8071,7 @@ fi # Define the identity of the package. PACKAGE='kpathsea' - VERSION='6.2.1' + VERSION='6.2.2dev' cat >>confdefs.h <<_ACEOF @@ -8226,13 +8226,13 @@ else if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_cflags="-Wimplicit -Wreturn-type" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement" ;; #( *) : ;; esac case `$CC -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -8244,7 +8244,7 @@ esac kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition" ;; #( *) : ;; @@ -13651,6 +13651,18 @@ case :$ac_cv_c_int64_t:$ac_cv_c_int64_t: in #( *) : ;; esac +ac_fn_c_check_decl "$LINENO" "isascii" "ac_cv_have_decl_isascii" "#include <ctype.h> +" +if test "x$ac_cv_have_decl_isascii" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_ISASCII $ac_have_decl +_ACEOF + ac_fn_c_check_member "$LINENO" "struct stat" "st_mtim" "ac_cv_member_struct_stat_st_mtim" "$ac_includes_default" if test "x$ac_cv_member_struct_stat_st_mtim" = xyes; then : @@ -13873,19 +13885,6 @@ _ACEOF -ac_fn_c_check_decl "$LINENO" "isascii" "ac_cv_have_decl_isascii" "#include <ctype.h> -" -if test "x$ac_cv_have_decl_isascii" = xyes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_ISASCII $ac_have_decl -_ACEOF - - ac_fn_c_check_decl "$LINENO" "putenv" "ac_cv_have_decl_putenv" "$ac_includes_default" if test "x$ac_cv_have_decl_putenv" = xyes; then : ac_have_decl=1 @@ -14696,7 +14695,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by Kpathsea $as_me 6.2.1, which was +This file was extended by Kpathsea $as_me 6.2.2dev, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14762,7 +14761,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -Kpathsea config.status 6.2.1 +Kpathsea config.status 6.2.2dev configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/source/texk/kpathsea/configure.ac b/source/texk/kpathsea/configure.ac index 97ebdc23d..84d0d89e4 100644 --- a/source/texk/kpathsea/configure.ac +++ b/source/texk/kpathsea/configure.ac @@ -35,9 +35,6 @@ AC_PROG_AWK AC_CHECK_SIZEOF([long]) -dnl Check if <ctype.h> declares isascii. -AC_CHECK_DECLS([isascii], [], [], [[#include <ctype.h>]]) - dnl Replacement functions that may be required on ancient broken system. AC_CHECK_DECLS([putenv]) AC_REPLACE_FUNCS([putenv]) diff --git a/source/texk/kpathsea/version.ac b/source/texk/kpathsea/version.ac index c6f8594f9..66bb00971 100644 --- a/source/texk/kpathsea/version.ac +++ b/source/texk/kpathsea/version.ac @@ -18,4 +18,4 @@ dnl append "dev", to distinguish binaries built between releases. dnl -------------------------------------------------------- dnl dnl m4-include this file to define the current kpathsea version -m4_define([kpse_version], [6.2.1]) +m4_define([kpse_version], [6.2.2dev]) diff --git a/source/texk/texlive/configure b/source/texk/texlive/configure index 80a26c5ac..464b3213b 100755 --- a/source/texk/texlive/configure +++ b/source/texk/texlive/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for TeX Live Scripts 2015. +# Generated by GNU Autoconf 2.69 for TeX Live Scripts 2016/dev. # # Report bugs to <tex-k@tug.org>. # @@ -579,8 +579,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='TeX Live Scripts' PACKAGE_TARNAME='tex-live-scripts' -PACKAGE_VERSION='2015' -PACKAGE_STRING='TeX Live Scripts 2015' +PACKAGE_VERSION='2016/dev' +PACKAGE_STRING='TeX Live Scripts 2016/dev' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' @@ -1238,7 +1238,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures TeX Live Scripts 2015 to adapt to many kinds of systems. +\`configure' configures TeX Live Scripts 2016/dev to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1305,7 +1305,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of TeX Live Scripts 2015:";; + short | recursive ) echo "Configuration of TeX Live Scripts 2016/dev:";; esac cat <<\_ACEOF @@ -1400,7 +1400,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -TeX Live Scripts configure 2015 +TeX Live Scripts configure 2016/dev generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1455,7 +1455,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by TeX Live Scripts $as_me 2015, which was +It was created by TeX Live Scripts $as_me 2016/dev, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2322,7 +2322,7 @@ fi # Define the identity of the package. PACKAGE='tex-live-scripts' - VERSION='2015' + VERSION='2016/dev' cat >>confdefs.h <<_ACEOF @@ -4224,7 +4224,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by TeX Live Scripts $as_me 2015, which was +This file was extended by TeX Live Scripts $as_me 2016/dev, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -4281,7 +4281,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -TeX Live Scripts config.status 2015 +TeX Live Scripts config.status 2016/dev configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/source/texk/texlive/linked_scripts/Makefile.am b/source/texk/texlive/linked_scripts/Makefile.am index 1f113ca89..09e66a197 100644 --- a/source/texk/texlive/linked_scripts/Makefile.am +++ b/source/texk/texlive/linked_scripts/Makefile.am @@ -85,6 +85,7 @@ texmf_other_scripts = \ bundledoc/bundledoc \ cachepic/cachepic.tlu \ checkcites/checkcites.lua \ + cjk-gs-integrate/cjk-gs-integrate.pl \ context/perl/mptopdf.pl \ convbkmk/convbkmk.rb \ crossrefware/bibdoiadd.pl \ diff --git a/source/texk/texlive/linked_scripts/Makefile.in b/source/texk/texlive/linked_scripts/Makefile.in index 4c282ba36..1cba4ae68 100644 --- a/source/texk/texlive/linked_scripts/Makefile.in +++ b/source/texk/texlive/linked_scripts/Makefile.in @@ -303,6 +303,7 @@ texmf_other_scripts = \ bundledoc/bundledoc \ cachepic/cachepic.tlu \ checkcites/checkcites.lua \ + cjk-gs-integrate/cjk-gs-integrate.pl \ context/perl/mptopdf.pl \ convbkmk/convbkmk.rb \ crossrefware/bibdoiadd.pl \ diff --git a/source/texk/texlive/tl_scripts/fmtutil.cnf b/source/texk/texlive/tl_scripts/fmtutil.cnf index c565b3ac2..d2bd6daf3 100644 --- a/source/texk/texlive/tl_scripts/fmtutil.cnf +++ b/source/texk/texlive/tl_scripts/fmtutil.cnf @@ -1,11 +1,12 @@ -# Generated by /home/texlive/karl/Master/bin/i386-linux/tlmgr on Fri Apr 25 03:23:27 2014 -# $Id: fmtutil-hdr.cnf 30214 2013-05-02 22:31:16Z karl $ +# Generated by /home/texlive/karl/Master/bin/i386-linux/tlmgr on Tue May 5 03:20:22 2015 # Originally written by Thomas Esser, 1998. Public domain. # -# As of TeX Live 2008, the final fmtutil.cnf is generated by -# tlmgr generate fmtutil. You can use -# tlmgr generate fmtutil -localcfg /some/file to make local additions. -# See tlmgr --help for more info. +# As of TeX Live 2015, fmtutil reads *all* fmtutil.cnf files found. +# Consequently, any manual edits of this file (fmtutil.cnf in the +# TEXMFDIST tree) will be lost on update. So don't do that. +# +# For guidance on how to achieve local configurations, see the man +# page of fmtutil, or the output of fmtutil --help. # # The format of the table is: # diff --git a/source/texk/web2c/ChangeLog b/source/texk/web2c/ChangeLog index 2ed8bc52e..6359e9d95 100644 --- a/source/texk/web2c/ChangeLog +++ b/source/texk/web2c/ChangeLog @@ -1,3 +1,15 @@ +2015-06-12 Peter Breitenlohner <peb@mppmu.mpg.de> + + Integrate MFLua and MFLuaJIT. + * mfluadir, mfluajitdir: New directories. + * mf.ch: Avoid conflict with mfluadir/mf-lua.ch. + * Makefile.am, ac/web2c.ac, tangle-sh.in, texmfmp.h, + * texmfmp-help.h, triptrap-sh: Adapted. + +2015-05-21 Karl Berry <karl@tug.org> + + * TL'15. + 2015-04-12 Peter Breitenlohner <peb@mppmu.mpg.de> * triptrap/{mftrap,mptrap,trip}.diffs: Updated for TL 2015. diff --git a/source/texk/web2c/Makefile.am b/source/texk/web2c/Makefile.am index 54515ae21..3c2209108 100644 --- a/source/texk/web2c/Makefile.am +++ b/source/texk/web2c/Makefile.am @@ -182,6 +182,12 @@ include $(srcdir)/am/cweb.am ## TeX and MF include $(srcdir)/am/texmf.am +## MFLua +include $(srcdir)/mfluadir/am/mflua.am + +## MFLuaJIT +include $(srcdir)/mfluajitdir/am/mfluajit.am + ## MetaPost include $(srcdir)/mplibdir/am/mplib.am diff --git a/source/texk/web2c/Makefile.in b/source/texk/web2c/Makefile.in index 71505f8ee..bef3851e4 100644 --- a/source/texk/web2c/Makefile.in +++ b/source/texk/web2c/Makefile.in @@ -93,12 +93,14 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ EXTRA_PROGRAMS = $(am__EXEEXT_1) tex$(EXEEXT) mf$(EXEEXT) \ - mf-nowin$(EXEEXT) mpost$(EXEEXT) pmpost$(EXEEXT) \ - upmpost$(EXEEXT) etex$(EXEEXT) ptex$(EXEEXT) $(am__EXEEXT_2) \ - eptex$(EXEEXT) uptex$(EXEEXT) $(am__EXEEXT_3) euptex$(EXEEXT) \ - pdftex$(EXEEXT) ttf2afm$(EXEEXT) pdftosrc$(EXEEXT) \ - luatex$(EXEEXT) luajittex$(EXEEXT) txt2zlib$(EXEEXT) \ - xetex$(EXEEXT) $(am__EXEEXT_4) aleph$(EXEEXT) synctex$(EXEEXT) + mf-nowin$(EXEEXT) mflua$(EXEEXT) mflua-nowin$(EXEEXT) \ + mfluajit$(EXEEXT) mfluajit-nowin$(EXEEXT) mpost$(EXEEXT) \ + pmpost$(EXEEXT) upmpost$(EXEEXT) etex$(EXEEXT) ptex$(EXEEXT) \ + $(am__EXEEXT_2) eptex$(EXEEXT) uptex$(EXEEXT) $(am__EXEEXT_3) \ + euptex$(EXEEXT) pdftex$(EXEEXT) ttf2afm$(EXEEXT) \ + pdftosrc$(EXEEXT) luatex$(EXEEXT) luajittex$(EXEEXT) \ + txt2zlib$(EXEEXT) xetex$(EXEEXT) $(am__EXEEXT_4) \ + aleph$(EXEEXT) synctex$(EXEEXT) bin_PROGRAMS = tangle$(EXEEXT) ctangle$(EXEEXT) $(am__EXEEXT_5) \ ctie$(EXEEXT) cweave$(EXEEXT) tie$(EXEEXT) $(am__EXEEXT_6) \ $(am__EXEEXT_7) $(am__EXEEXT_8) $(am__EXEEXT_9) \ @@ -107,23 +109,25 @@ bin_PROGRAMS = tangle$(EXEEXT) ctangle$(EXEEXT) $(am__EXEEXT_5) \ $(am__EXEEXT_16) $(am__EXEEXT_17) $(am__EXEEXT_18) \ $(am__EXEEXT_19) $(am__EXEEXT_20) $(am__EXEEXT_21) \ $(am__EXEEXT_22) $(am__EXEEXT_23) $(am__EXEEXT_24) \ - $(am__EXEEXT_25) $(am__EXEEXT_26) $(am__EXEEXT_27) + $(am__EXEEXT_25) $(am__EXEEXT_26) $(am__EXEEXT_27) \ + $(am__EXEEXT_28) $(am__EXEEXT_29) $(am__EXEEXT_30) \ + $(am__EXEEXT_31) $(am__EXEEXT_32) $(am__EXEEXT_33) noinst_PROGRAMS = tangleboot$(EXEEXT) ctangleboot$(EXEEXT) \ + $(am__EXEEXT_45) $(am__EXEEXT_46) $(am__EXEEXT_47) \ + $(am__EXEEXT_48) $(am__EXEEXT_49) $(am__EXEEXT_50) +check_PROGRAMS = $(am__EXEEXT_34) $(am__EXEEXT_35) $(am__EXEEXT_36) \ $(am__EXEEXT_37) $(am__EXEEXT_38) $(am__EXEEXT_39) \ - $(am__EXEEXT_40) $(am__EXEEXT_41) $(am__EXEEXT_42) -check_PROGRAMS = $(am__EXEEXT_28) $(am__EXEEXT_29) $(am__EXEEXT_30) \ - $(am__EXEEXT_31) $(am__EXEEXT_32) $(am__EXEEXT_33) \ - $(am__EXEEXT_34) $(am__EXEEXT_35) $(am__EXEEXT_36) \ - md5main$(EXEEXT) -TESTS = tangle.test $(am__EXEEXT_45) ctiedir/ctie.test \ + $(am__EXEEXT_40) $(am__EXEEXT_41) $(am__EXEEXT_42) \ + $(am__EXEEXT_43) $(am__EXEEXT_44) md5main$(EXEEXT) +TESTS = tangle.test $(am__EXEEXT_53) ctiedir/ctie.test \ cwebdir/cweave.test tiedir/tie.test $(am__append_6) \ - $(am__append_14) $(am__append_23) $(am__append_37) \ - $(am__append_38) $(am__append_40) $(am__append_46) \ - $(am__append_50) $(am__append_52) $(am__append_58) \ - $(am__append_62) $(am__append_64) $(am__append_70) \ - $(am__append_81) $(am__append_82) $(am__append_90) \ - $(am__append_92) $(am__append_95) $(am__append_129) \ - libmd5/md5.test + $(am__append_14) $(am__append_22) $(am__append_30) \ + $(am__append_39) $(am__append_53) $(am__append_54) \ + $(am__append_56) $(am__append_62) $(am__append_66) \ + $(am__append_68) $(am__append_74) $(am__append_78) \ + $(am__append_80) $(am__append_86) $(am__append_97) \ + $(am__append_98) $(am__append_106) $(am__append_108) \ + $(am__append_111) $(am__append_145) libmd5/md5.test @WEB_TRUE@am__append_1 = $(web_programs) @WEB_TRUE@am__append_2 = $(web_tests) @TEX_TRUE@am__append_3 = tex @@ -141,187 +145,203 @@ TESTS = tangle.test $(am__EXEEXT_45) ctiedir/ctie.test \ @MF_TRUE@am__append_15 = gftype tftopl @MF_TRUE@am__append_16 = mftrap.diffs @MF_TRUE@am__append_17 = trap-clean -@MP_TRUE@am__append_18 = mpost -@MP_TRUE@@WIN32_TRUE@am__append_19 = call_mpost -@MP_TRUE@@WIN32_TRUE@am__append_20 = install-mpost-links -@MP_TRUE@@WIN32_TRUE@am__append_21 = uninstall-mpost-links -@MP_TRUE@@WIN32_FALSE@am__append_22 = mpost$(EXEEXT):dvitomp mpost$(EXEEXT):mfplain -@MP_TRUE@am__append_23 = $(mp_tests) -@MP_TRUE@am__append_24 = pltotf tftopl -@MP_TRUE@am__append_25 = mptrap.diffs -@MP_TRUE@am__append_26 = mptrap-clean -@PMP_TRUE@am__append_27 = pmpost -@PMP_TRUE@@WIN32_TRUE@am__append_28 = call_pmpost -@PMP_TRUE@@WIN32_TRUE@am__append_29 = install-pmpost-links -@PMP_TRUE@@WIN32_TRUE@am__append_30 = uninstall-pmpost-links -@PMP_TRUE@@WIN32_FALSE@am__append_31 = pmpost$(EXEEXT):pdvitomp -@UPMP_TRUE@am__append_32 = upmpost -@UPMP_TRUE@@WIN32_TRUE@am__append_33 = call_upmpost -@UPMP_TRUE@@WIN32_TRUE@am__append_34 = install-upmpost-links -@UPMP_TRUE@@WIN32_TRUE@am__append_35 = uninstall-upmpost-links -@UPMP_TRUE@@WIN32_FALSE@am__append_36 = upmpost$(EXEEXT):updvitomp -@PMP_TRUE@am__append_37 = $(pmpost_tests) -@UPMP_TRUE@am__append_38 = $(upmpost_tests) -@ETEX_TRUE@am__append_39 = etex -@ETEX_TRUE@am__append_40 = $(etex_tests) -@ETEX_TRUE@am__append_41 = dvitype pltotf tftopl -@ETEX_TRUE@am__append_42 = etrip.diffs -@ETEX_TRUE@am__append_43 = etrip-clean -@PTEX_TRUE@am__append_44 = ptex -@PWEB_TRUE@am__append_45 = $(pweb_programs) -@PTEX_TRUE@am__append_46 = $(ptex_tests) -@PTEX_TRUE@am__append_47 = dvitype pltotf tftopl -@PTEX_TRUE@am__append_48 = ptrip.diffs -@PTEX_TRUE@am__append_49 = ptrip-clean -@PWEB_TRUE@am__append_50 = $(pweb_tests) -@EPTEX_TRUE@am__append_51 = eptex -@EPTEX_TRUE@am__append_52 = $(eptex_tests) -@EPTEX_TRUE@am__append_53 = dvitype pltotf tftopl -@EPTEX_TRUE@am__append_54 = eptrip.diffs -@EPTEX_TRUE@am__append_55 = eptrip-clean -@UPTEX_TRUE@am__append_56 = uptex -@UPWEB_TRUE@am__append_57 = $(upweb_programs) -@UPTEX_TRUE@am__append_58 = $(uptex_tests) -@UPTEX_TRUE@am__append_59 = dvitype pltotf tftopl -@UPTEX_TRUE@am__append_60 = uptrip.diffs -@UPTEX_TRUE@am__append_61 = uptrip-clean -@UPWEB_TRUE@am__append_62 = $(upweb_tests) -@EUPTEX_TRUE@am__append_63 = euptex -@EUPTEX_TRUE@am__append_64 = $(euptex_tests) -@EUPTEX_TRUE@am__append_65 = dvitype pltotf tftopl -@EUPTEX_TRUE@am__append_66 = euptrip.diffs -@EUPTEX_TRUE@am__append_67 = euptrip-clean -@MINGW32_TRUE@am__append_68 = \ +@MFLUA_TRUE@am__append_18 = mflua +@MFLUAN_TRUE@@MFLUA_TRUE@am__append_19 = mflua-nowin +@MFLUA_TRUE@@WIN32_TRUE@am__append_20 = inimflua +@MFLUA_TRUE@@WIN32_FALSE@am__append_21 = mflua$(EXEEXT):inimflua +@MFLUA_TRUE@am__append_22 = $(mflua_tests) +@MFLUA_TRUE@am__append_23 = gftype tftopl +@MFLUA_TRUE@am__append_24 = mfluatrap.diffs +@MFLUA_TRUE@am__append_25 = mfluatrap-clean +@MFLUAJIT_TRUE@am__append_26 = mfluajit +@MFLUAJITN_TRUE@@MFLUAJIT_TRUE@am__append_27 = mfluajit-nowin +@MFLUAJIT_TRUE@@WIN32_TRUE@am__append_28 = inimfluajit +@MFLUAJIT_TRUE@@WIN32_FALSE@am__append_29 = mfluajit$(EXEEXT):inimfluajit +@MFLUAJIT_TRUE@am__append_30 = $(mfluajit_tests) +@MFLUAJIT_TRUE@am__append_31 = gftype tftopl +@MFLUAJIT_TRUE@am__append_32 = mfluajittrap.diffs +@MFLUAJIT_TRUE@am__append_33 = mfluajittrap-clean +@MP_TRUE@am__append_34 = mpost +@MP_TRUE@@WIN32_TRUE@am__append_35 = call_mpost +@MP_TRUE@@WIN32_TRUE@am__append_36 = install-mpost-links +@MP_TRUE@@WIN32_TRUE@am__append_37 = uninstall-mpost-links +@MP_TRUE@@WIN32_FALSE@am__append_38 = mpost$(EXEEXT):dvitomp mpost$(EXEEXT):mfplain +@MP_TRUE@am__append_39 = $(mp_tests) +@MP_TRUE@am__append_40 = pltotf tftopl +@MP_TRUE@am__append_41 = mptrap.diffs +@MP_TRUE@am__append_42 = mptrap-clean +@PMP_TRUE@am__append_43 = pmpost +@PMP_TRUE@@WIN32_TRUE@am__append_44 = call_pmpost +@PMP_TRUE@@WIN32_TRUE@am__append_45 = install-pmpost-links +@PMP_TRUE@@WIN32_TRUE@am__append_46 = uninstall-pmpost-links +@PMP_TRUE@@WIN32_FALSE@am__append_47 = pmpost$(EXEEXT):pdvitomp +@UPMP_TRUE@am__append_48 = upmpost +@UPMP_TRUE@@WIN32_TRUE@am__append_49 = call_upmpost +@UPMP_TRUE@@WIN32_TRUE@am__append_50 = install-upmpost-links +@UPMP_TRUE@@WIN32_TRUE@am__append_51 = uninstall-upmpost-links +@UPMP_TRUE@@WIN32_FALSE@am__append_52 = upmpost$(EXEEXT):updvitomp +@PMP_TRUE@am__append_53 = $(pmpost_tests) +@UPMP_TRUE@am__append_54 = $(upmpost_tests) +@ETEX_TRUE@am__append_55 = etex +@ETEX_TRUE@am__append_56 = $(etex_tests) +@ETEX_TRUE@am__append_57 = dvitype pltotf tftopl +@ETEX_TRUE@am__append_58 = etrip.diffs +@ETEX_TRUE@am__append_59 = etrip-clean +@PTEX_TRUE@am__append_60 = ptex +@PWEB_TRUE@am__append_61 = $(pweb_programs) +@PTEX_TRUE@am__append_62 = $(ptex_tests) +@PTEX_TRUE@am__append_63 = dvitype pltotf tftopl +@PTEX_TRUE@am__append_64 = ptrip.diffs +@PTEX_TRUE@am__append_65 = ptrip-clean +@PWEB_TRUE@am__append_66 = $(pweb_tests) +@EPTEX_TRUE@am__append_67 = eptex +@EPTEX_TRUE@am__append_68 = $(eptex_tests) +@EPTEX_TRUE@am__append_69 = dvitype pltotf tftopl +@EPTEX_TRUE@am__append_70 = eptrip.diffs +@EPTEX_TRUE@am__append_71 = eptrip-clean +@UPTEX_TRUE@am__append_72 = uptex +@UPWEB_TRUE@am__append_73 = $(upweb_programs) +@UPTEX_TRUE@am__append_74 = $(uptex_tests) +@UPTEX_TRUE@am__append_75 = dvitype pltotf tftopl +@UPTEX_TRUE@am__append_76 = uptrip.diffs +@UPTEX_TRUE@am__append_77 = uptrip-clean +@UPWEB_TRUE@am__append_78 = $(upweb_tests) +@EUPTEX_TRUE@am__append_79 = euptex +@EUPTEX_TRUE@am__append_80 = $(euptex_tests) +@EUPTEX_TRUE@am__append_81 = dvitype pltotf tftopl +@EUPTEX_TRUE@am__append_82 = euptrip.diffs +@EUPTEX_TRUE@am__append_83 = euptrip-clean +@MINGW32_TRUE@am__append_84 = \ @MINGW32_TRUE@ pdftexdir/regex/regex.c \ @MINGW32_TRUE@ pdftexdir/regex/regex.h -@PDFTEX_TRUE@am__append_69 = pdftex ttf2afm pdftosrc -@PDFTEX_TRUE@am__append_70 = $(pdftex_tests) $(ttf2afm_tests) \ +@PDFTEX_TRUE@am__append_85 = pdftex ttf2afm pdftosrc +@PDFTEX_TRUE@am__append_86 = $(pdftex_tests) $(ttf2afm_tests) \ @PDFTEX_TRUE@ $(pdftosrc_tests) -@LUATEX_TRUE@am__append_71 = luatex -@LUATEX_TRUE@@WIN32_TRUE@am__append_72 = call_luatex -@LUATEX_TRUE@@WIN32_TRUE@am__append_73 = install-luatex-links -@LUATEX_TRUE@@WIN32_TRUE@am__append_74 = uninstall-luatex-links -@LUATEX_TRUE@@WIN32_FALSE@am__append_75 = luatex$(EXEEXT):texlua luatex$(EXEEXT):texluac -@LUAJITTEX_TRUE@am__append_76 = luajittex -@LUAJITTEX_TRUE@@WIN32_TRUE@am__append_77 = call_luajittex -@LUAJITTEX_TRUE@@WIN32_TRUE@am__append_78 = install-luajittex-links -@LUAJITTEX_TRUE@@WIN32_TRUE@am__append_79 = uninstall-luajittex-links -@LUAJITTEX_TRUE@@WIN32_FALSE@am__append_80 = luajittex$(EXEEXT):texluajit luajittex$(EXEEXT):texluajitc -@LUATEX_TRUE@am__append_81 = $(luatex_tests) -@LUAJITTEX_TRUE@am__append_82 = $(luajittex_tests) -@LUATEX_TRUE@@cross_FALSE@am__append_83 = txt2zlib -@XETEX_TRUE@am__append_84 = xetex -@XETEX_MACOSX_TRUE@am__append_85 = -DXETEX_MAC -@XETEX_MACOSX_FALSE@am__append_86 = $(FONTCONFIG_INCLUDES) -@XETEX_MACOSX_FALSE@am__append_87 = $(FONTCONFIG_LIBS) -@XETEX_MACOSX_TRUE@am__append_88 = \ +@LUATEX_TRUE@am__append_87 = luatex +@LUATEX_TRUE@@WIN32_TRUE@am__append_88 = call_luatex +@LUATEX_TRUE@@WIN32_TRUE@am__append_89 = install-luatex-links +@LUATEX_TRUE@@WIN32_TRUE@am__append_90 = uninstall-luatex-links +@LUATEX_TRUE@@WIN32_FALSE@am__append_91 = luatex$(EXEEXT):texlua luatex$(EXEEXT):texluac +@LUAJITTEX_TRUE@am__append_92 = luajittex +@LUAJITTEX_TRUE@@WIN32_TRUE@am__append_93 = call_luajittex +@LUAJITTEX_TRUE@@WIN32_TRUE@am__append_94 = install-luajittex-links +@LUAJITTEX_TRUE@@WIN32_TRUE@am__append_95 = uninstall-luajittex-links +@LUAJITTEX_TRUE@@WIN32_FALSE@am__append_96 = luajittex$(EXEEXT):texluajit luajittex$(EXEEXT):texluajitc +@LUATEX_TRUE@am__append_97 = $(luatex_tests) +@LUAJITTEX_TRUE@am__append_98 = $(luajittex_tests) +@LUATEX_TRUE@@cross_FALSE@am__append_99 = txt2zlib +@XETEX_TRUE@am__append_100 = xetex +@XETEX_MACOSX_TRUE@am__append_101 = -DXETEX_MAC +@XETEX_MACOSX_FALSE@am__append_102 = $(FONTCONFIG_INCLUDES) +@XETEX_MACOSX_FALSE@am__append_103 = $(FONTCONFIG_LIBS) +@XETEX_MACOSX_TRUE@am__append_104 = \ @XETEX_MACOSX_TRUE@ xetexdir/XeTeXFontInst_Mac.cpp \ @XETEX_MACOSX_TRUE@ xetexdir/XeTeXFontInst_Mac.h \ @XETEX_MACOSX_TRUE@ xetexdir/XeTeXFontMgr_Mac.mm \ @XETEX_MACOSX_TRUE@ xetexdir/XeTeXFontMgr_Mac.h \ @XETEX_MACOSX_TRUE@ xetexdir/XeTeX_mac.c -@XETEX_MACOSX_FALSE@am__append_89 = \ +@XETEX_MACOSX_FALSE@am__append_105 = \ @XETEX_MACOSX_FALSE@ xetexdir/XeTeXFontMgr_FC.cpp \ @XETEX_MACOSX_FALSE@ xetexdir/XeTeXFontMgr_FC.h -@XETEX_TRUE@am__append_90 = $(xetex_tests) -@OTANGLE_TRUE@am__append_91 = $(omegaware_programs) -@OTANGLE_TRUE@am__append_92 = $(OTANGLE_tests) $(OMFONTS_tests) -@OTANGLE_TRUE@am__append_93 = pltotf tftopl -@ALEPH_TRUE@am__append_94 = aleph -@ALEPH_TRUE@am__append_95 = $(aleph_tests) -@SYNCTEX_TRUE@am__append_96 = synctex -@SYNCTEX_TRUE@am__append_97 = $(LTLIBSYNCTEX) -@SYNCTEX_TRUE@am__append_98 = $(LIBSYNCTEX) -@MINGW32_TRUE@am__append_99 = -lshlwapi -@MINGW32_TRUE@am__append_100 = -lshlwapi -@TEX_SYNCTEX_TRUE@am__append_101 = -I$(srcdir)/synctexdir \ +@XETEX_TRUE@am__append_106 = $(xetex_tests) +@OTANGLE_TRUE@am__append_107 = $(omegaware_programs) +@OTANGLE_TRUE@am__append_108 = $(OTANGLE_tests) $(OMFONTS_tests) +@OTANGLE_TRUE@am__append_109 = pltotf tftopl +@ALEPH_TRUE@am__append_110 = aleph +@ALEPH_TRUE@am__append_111 = $(aleph_tests) +@SYNCTEX_TRUE@am__append_112 = synctex +@SYNCTEX_TRUE@am__append_113 = $(LTLIBSYNCTEX) +@SYNCTEX_TRUE@am__append_114 = $(LIBSYNCTEX) +@MINGW32_TRUE@am__append_115 = -lshlwapi +@MINGW32_TRUE@am__append_116 = -lshlwapi +@TEX_SYNCTEX_TRUE@am__append_117 = -I$(srcdir)/synctexdir \ @TEX_SYNCTEX_TRUE@ $(ZLIB_INCLUDES) -D__SyncTeX__ \ @TEX_SYNCTEX_TRUE@ -DSYNCTEX_ENGINE_H=\"synctex-tex.h\" -@TEX_SYNCTEX_TRUE@am__append_102 = $(ZLIB_LIBS) -@TEX_SYNCTEX_TRUE@am__append_103 = $(ZLIB_DEPEND) -@TEX_SYNCTEX_TRUE@am__append_104 = \ +@TEX_SYNCTEX_TRUE@am__append_118 = $(ZLIB_LIBS) +@TEX_SYNCTEX_TRUE@am__append_119 = $(ZLIB_DEPEND) +@TEX_SYNCTEX_TRUE@am__append_120 = \ @TEX_SYNCTEX_TRUE@ synctexdir/synctex.c \ @TEX_SYNCTEX_TRUE@ synctexdir/synctex.h \ @TEX_SYNCTEX_TRUE@ synctexdir/synctex-common.h \ @TEX_SYNCTEX_TRUE@ synctexdir/synctex-tex.h -@ETEX_SYNCTEX_TRUE@am__append_105 = -I$(srcdir)/synctexdir \ +@ETEX_SYNCTEX_TRUE@am__append_121 = -I$(srcdir)/synctexdir \ @ETEX_SYNCTEX_TRUE@ $(ZLIB_INCLUDES) -D__SyncTeX__ \ @ETEX_SYNCTEX_TRUE@ -DSYNCTEX_ENGINE_H=\"synctex-etex.h\" -@ETEX_SYNCTEX_TRUE@am__append_106 = $(ZLIB_LIBS) -@ETEX_SYNCTEX_TRUE@am__append_107 = $(ZLIB_DEPEND) -@ETEX_SYNCTEX_TRUE@am__append_108 = \ +@ETEX_SYNCTEX_TRUE@am__append_122 = $(ZLIB_LIBS) +@ETEX_SYNCTEX_TRUE@am__append_123 = $(ZLIB_DEPEND) +@ETEX_SYNCTEX_TRUE@am__append_124 = \ @ETEX_SYNCTEX_TRUE@ synctexdir/synctex.c \ @ETEX_SYNCTEX_TRUE@ synctexdir/synctex.h \ @ETEX_SYNCTEX_TRUE@ synctexdir/synctex-common.h \ @ETEX_SYNCTEX_TRUE@ synctexdir/synctex-etex.h -@PTEX_SYNCTEX_TRUE@am__append_109 = -I$(srcdir)/synctexdir \ +@PTEX_SYNCTEX_TRUE@am__append_125 = -I$(srcdir)/synctexdir \ @PTEX_SYNCTEX_TRUE@ $(ZLIB_INCLUDES) -D__SyncTeX__ \ @PTEX_SYNCTEX_TRUE@ -DSYNCTEX_ENGINE_H=\"synctex-ptex.h\" -@PTEX_SYNCTEX_TRUE@am__append_110 = $(ZLIB_LIBS) -@PTEX_SYNCTEX_TRUE@am__append_111 = $(ZLIB_DEPEND) -@PTEX_SYNCTEX_TRUE@am__append_112 = \ +@PTEX_SYNCTEX_TRUE@am__append_126 = $(ZLIB_LIBS) +@PTEX_SYNCTEX_TRUE@am__append_127 = $(ZLIB_DEPEND) +@PTEX_SYNCTEX_TRUE@am__append_128 = \ @PTEX_SYNCTEX_TRUE@ synctexdir/synctex.c \ @PTEX_SYNCTEX_TRUE@ synctexdir/synctex.h \ @PTEX_SYNCTEX_TRUE@ synctexdir/synctex-common.h \ @PTEX_SYNCTEX_TRUE@ synctexdir/synctex-ptex.h -@UPTEX_SYNCTEX_TRUE@am__append_113 = -I$(srcdir)/synctexdir \ +@UPTEX_SYNCTEX_TRUE@am__append_129 = -I$(srcdir)/synctexdir \ @UPTEX_SYNCTEX_TRUE@ $(ZLIB_INCLUDES) -D__SyncTeX__ \ @UPTEX_SYNCTEX_TRUE@ -DSYNCTEX_ENGINE_H=\"synctex-uptex.h\" -@UPTEX_SYNCTEX_TRUE@am__append_114 = $(ZLIB_LIBS) -@UPTEX_SYNCTEX_TRUE@am__append_115 = $(ZLIB_DEPEND) -@UPTEX_SYNCTEX_TRUE@am__append_116 = \ +@UPTEX_SYNCTEX_TRUE@am__append_130 = $(ZLIB_LIBS) +@UPTEX_SYNCTEX_TRUE@am__append_131 = $(ZLIB_DEPEND) +@UPTEX_SYNCTEX_TRUE@am__append_132 = \ @UPTEX_SYNCTEX_TRUE@ synctexdir/synctex.c \ @UPTEX_SYNCTEX_TRUE@ synctexdir/synctex.h \ @UPTEX_SYNCTEX_TRUE@ synctexdir/synctex-common.h \ @UPTEX_SYNCTEX_TRUE@ synctexdir/synctex-uptex.h -@EPTEX_SYNCTEX_TRUE@am__append_117 = -I$(srcdir)/synctexdir \ +@EPTEX_SYNCTEX_TRUE@am__append_133 = -I$(srcdir)/synctexdir \ @EPTEX_SYNCTEX_TRUE@ $(ZLIB_INCLUDES) -D__SyncTeX__ \ @EPTEX_SYNCTEX_TRUE@ -DSYNCTEX_ENGINE_H=\"synctex-eptex.h\" -@EPTEX_SYNCTEX_TRUE@am__append_118 = $(ZLIB_LIBS) -@EPTEX_SYNCTEX_TRUE@am__append_119 = $(ZLIB_DEPEND) -@EPTEX_SYNCTEX_TRUE@am__append_120 = \ +@EPTEX_SYNCTEX_TRUE@am__append_134 = $(ZLIB_LIBS) +@EPTEX_SYNCTEX_TRUE@am__append_135 = $(ZLIB_DEPEND) +@EPTEX_SYNCTEX_TRUE@am__append_136 = \ @EPTEX_SYNCTEX_TRUE@ synctexdir/synctex.c \ @EPTEX_SYNCTEX_TRUE@ synctexdir/synctex.h \ @EPTEX_SYNCTEX_TRUE@ synctexdir/synctex-common.h \ @EPTEX_SYNCTEX_TRUE@ synctexdir/synctex-eptex.h -@EUPTEX_SYNCTEX_TRUE@am__append_121 = -I$(srcdir)/synctexdir \ +@EUPTEX_SYNCTEX_TRUE@am__append_137 = -I$(srcdir)/synctexdir \ @EUPTEX_SYNCTEX_TRUE@ $(ZLIB_INCLUDES) -D__SyncTeX__ \ @EUPTEX_SYNCTEX_TRUE@ -DSYNCTEX_ENGINE_H=\"synctex-euptex.h\" -@EUPTEX_SYNCTEX_TRUE@am__append_122 = $(ZLIB_LIBS) -@EUPTEX_SYNCTEX_TRUE@am__append_123 = $(ZLIB_DEPEND) -@EUPTEX_SYNCTEX_TRUE@am__append_124 = \ +@EUPTEX_SYNCTEX_TRUE@am__append_138 = $(ZLIB_LIBS) +@EUPTEX_SYNCTEX_TRUE@am__append_139 = $(ZLIB_DEPEND) +@EUPTEX_SYNCTEX_TRUE@am__append_140 = \ @EUPTEX_SYNCTEX_TRUE@ synctexdir/synctex.c \ @EUPTEX_SYNCTEX_TRUE@ synctexdir/synctex.h \ @EUPTEX_SYNCTEX_TRUE@ synctexdir/synctex-common.h \ @EUPTEX_SYNCTEX_TRUE@ synctexdir/synctex-euptex.h -@PDFTEX_SYNCTEX_TRUE@am__append_125 = -I$(srcdir)/synctexdir \ +@PDFTEX_SYNCTEX_TRUE@am__append_141 = -I$(srcdir)/synctexdir \ @PDFTEX_SYNCTEX_TRUE@ -D__SyncTeX__ \ @PDFTEX_SYNCTEX_TRUE@ -DSYNCTEX_ENGINE_H=\"synctex-pdftex.h\" -@PDFTEX_SYNCTEX_TRUE@am__append_126 = \ +@PDFTEX_SYNCTEX_TRUE@am__append_142 = \ @PDFTEX_SYNCTEX_TRUE@ synctexdir/synctex.c \ @PDFTEX_SYNCTEX_TRUE@ synctexdir/synctex.h \ @PDFTEX_SYNCTEX_TRUE@ synctexdir/synctex-common.h \ @PDFTEX_SYNCTEX_TRUE@ synctexdir/synctex-pdftex.h -@XETEX_SYNCTEX_TRUE@am__append_127 = -I$(srcdir)/synctexdir \ +@XETEX_SYNCTEX_TRUE@am__append_143 = -I$(srcdir)/synctexdir \ @XETEX_SYNCTEX_TRUE@ -D__SyncTeX__ \ @XETEX_SYNCTEX_TRUE@ -DSYNCTEX_ENGINE_H=\"synctex-xetex.h\" -@XETEX_SYNCTEX_TRUE@am__append_128 = \ +@XETEX_SYNCTEX_TRUE@am__append_144 = \ @XETEX_SYNCTEX_TRUE@ synctexdir/synctex.c \ @XETEX_SYNCTEX_TRUE@ synctexdir/synctex.h \ @XETEX_SYNCTEX_TRUE@ synctexdir/synctex-common.h \ @XETEX_SYNCTEX_TRUE@ synctexdir/synctex-xetex.h -@SYNCTEX_TRUE@am__append_129 = $(synctex_tests) +@SYNCTEX_TRUE@am__append_145 = $(synctex_tests) subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/web2c-disable.m4 \ @@ -815,21 +835,39 @@ libmf_a_LIBADD = am__objects_11 = mfini.$(OBJEXT) mf0.$(OBJEXT) nodist_libmf_a_OBJECTS = $(am__objects_11) mf-pool.$(OBJEXT) libmf_a_OBJECTS = $(nodist_libmf_a_OBJECTS) +libmflua_a_AR = $(AR) $(ARFLAGS) +libmflua_a_LIBADD = +dist_libmflua_a_OBJECTS = mfluadir/libmflua_a-mfluac.$(OBJEXT) +am__objects_12 = libmflua_a-mfluaini.$(OBJEXT) \ + libmflua_a-mflua0.$(OBJEXT) +nodist_libmflua_a_OBJECTS = $(am__objects_12) \ + libmflua_a-mflua-pool.$(OBJEXT) +libmflua_a_OBJECTS = $(dist_libmflua_a_OBJECTS) \ + $(nodist_libmflua_a_OBJECTS) +libmfluajit_a_AR = $(AR) $(ARFLAGS) +libmfluajit_a_LIBADD = +dist_libmfluajit_a_OBJECTS = mfluadir/libmfluajit_a-mfluac.$(OBJEXT) +am__objects_13 = libmfluajit_a-mfluajitini.$(OBJEXT) \ + libmfluajit_a-mfluajit0.$(OBJEXT) +nodist_libmfluajit_a_OBJECTS = $(am__objects_13) \ + libmfluajit_a-mfluajit-pool.$(OBJEXT) +libmfluajit_a_OBJECTS = $(dist_libmfluajit_a_OBJECTS) \ + $(nodist_libmfluajit_a_OBJECTS) libmplib_a_AR = $(AR) $(ARFLAGS) libmplib_a_LIBADD = -am__objects_12 = libmplib_a-mp.$(OBJEXT) -am__objects_13 = libmplib_a-mpmath.$(OBJEXT) -am__objects_14 = libmplib_a-mpmathbinary.$(OBJEXT) -am__objects_15 = libmplib_a-mpmathdecimal.$(OBJEXT) -am__objects_16 = libmplib_a-mpmathdouble.$(OBJEXT) -am__objects_17 = libmplib_a-mpstrings.$(OBJEXT) -am__objects_18 = libmplib_a-pngout.$(OBJEXT) -am__objects_19 = libmplib_a-psout.$(OBJEXT) -am__objects_20 = libmplib_a-svgout.$(OBJEXT) +am__objects_14 = libmplib_a-mp.$(OBJEXT) +am__objects_15 = libmplib_a-mpmath.$(OBJEXT) +am__objects_16 = libmplib_a-mpmathbinary.$(OBJEXT) +am__objects_17 = libmplib_a-mpmathdecimal.$(OBJEXT) +am__objects_18 = libmplib_a-mpmathdouble.$(OBJEXT) +am__objects_19 = libmplib_a-mpstrings.$(OBJEXT) +am__objects_20 = libmplib_a-pngout.$(OBJEXT) +am__objects_21 = libmplib_a-psout.$(OBJEXT) +am__objects_22 = libmplib_a-svgout.$(OBJEXT) nodist_libmplib_a_OBJECTS = libmplib_a-tfmin.$(OBJEXT) \ - $(am__objects_12) $(am__objects_13) $(am__objects_14) \ - $(am__objects_15) $(am__objects_16) $(am__objects_17) \ - $(am__objects_18) $(am__objects_19) $(am__objects_20) + $(am__objects_14) $(am__objects_15) $(am__objects_16) \ + $(am__objects_17) $(am__objects_18) $(am__objects_19) \ + $(am__objects_20) $(am__objects_21) $(am__objects_22) libmplib_a_OBJECTS = $(nodist_libmplib_a_OBJECTS) libmputil_a_AR = $(AR) $(ARFLAGS) libmputil_a_LIBADD = @@ -851,7 +889,7 @@ am__libpdftex_a_SOURCES_DIST = pdftexdir/avl.c pdftexdir/avl.h \ pdftexdir/writepng.c pdftexdir/writet1.c pdftexdir/writet3.c \ pdftexdir/writettf.c pdftexdir/writettf.h pdftexdir/writezip.c \ pdftexdir/regex/regex.c pdftexdir/regex/regex.h -@MINGW32_TRUE@am__objects_21 = \ +@MINGW32_TRUE@am__objects_23 = \ @MINGW32_TRUE@ pdftexdir/regex/libpdftex_a-regex.$(OBJEXT) am_libpdftex_a_OBJECTS = pdftexdir/libpdftex_a-avl.$(OBJEXT) \ pdftexdir/libpdftex_a-avlstuff.$(OBJEXT) \ @@ -872,13 +910,13 @@ am_libpdftex_a_OBJECTS = pdftexdir/libpdftex_a-avl.$(OBJEXT) \ pdftexdir/libpdftex_a-writet1.$(OBJEXT) \ pdftexdir/libpdftex_a-writet3.$(OBJEXT) \ pdftexdir/libpdftex_a-writettf.$(OBJEXT) \ - pdftexdir/libpdftex_a-writezip.$(OBJEXT) $(am__objects_21) + pdftexdir/libpdftex_a-writezip.$(OBJEXT) $(am__objects_23) libpdftex_a_OBJECTS = $(am_libpdftex_a_OBJECTS) libsynctex_a_AR = $(AR) $(ARFLAGS) libsynctex_a_LIBADD = -am__objects_22 = synctexdir/libsynctex_a-synctex_parser.$(OBJEXT) \ +am__objects_24 = synctexdir/libsynctex_a-synctex_parser.$(OBJEXT) \ synctexdir/libsynctex_a-synctex_parser_utils.$(OBJEXT) -nodist_libsynctex_a_OBJECTS = $(am__objects_22) +nodist_libsynctex_a_OBJECTS = $(am__objects_24) libsynctex_a_OBJECTS = $(nodist_libsynctex_a_OBJECTS) libukanji_a_AR = $(AR) $(ARFLAGS) libukanji_a_LIBADD = @@ -919,10 +957,10 @@ am__libxetex_a_SOURCES_DIST = xetexdir/MathTable.h \ xetexdir/XeTeXFontInst_Mac.h xetexdir/XeTeXFontMgr_Mac.mm \ xetexdir/XeTeXFontMgr_Mac.h xetexdir/XeTeX_mac.c \ xetexdir/XeTeXFontMgr_FC.cpp xetexdir/XeTeXFontMgr_FC.h -@XETEX_MACOSX_TRUE@am__objects_23 = xetexdir/libxetex_a-XeTeXFontInst_Mac.$(OBJEXT) \ +@XETEX_MACOSX_TRUE@am__objects_25 = xetexdir/libxetex_a-XeTeXFontInst_Mac.$(OBJEXT) \ @XETEX_MACOSX_TRUE@ xetexdir/libxetex_a-XeTeXFontMgr_Mac.$(OBJEXT) \ @XETEX_MACOSX_TRUE@ xetexdir/libxetex_a-XeTeX_mac.$(OBJEXT) -@XETEX_MACOSX_FALSE@am__objects_24 = xetexdir/libxetex_a-XeTeXFontMgr_FC.$(OBJEXT) +@XETEX_MACOSX_FALSE@am__objects_26 = xetexdir/libxetex_a-XeTeXFontMgr_FC.$(OBJEXT) am_libxetex_a_OBJECTS = xetexdir/libxetex_a-XeTeXFontInst.$(OBJEXT) \ xetexdir/libxetex_a-XeTeXFontMgr.$(OBJEXT) \ xetexdir/libxetex_a-XeTeXLayoutInterface.$(OBJEXT) \ @@ -936,8 +974,8 @@ am_libxetex_a_OBJECTS = xetexdir/libxetex_a-XeTeXFontInst.$(OBJEXT) \ xetexdir/image/libxetex_a-jpegimage.$(OBJEXT) \ xetexdir/image/libxetex_a-mfileio.$(OBJEXT) \ xetexdir/image/libxetex_a-numbers.$(OBJEXT) \ - xetexdir/image/libxetex_a-pngimage.$(OBJEXT) $(am__objects_23) \ - $(am__objects_24) + xetexdir/image/libxetex_a-pngimage.$(OBJEXT) $(am__objects_25) \ + $(am__objects_26) libxetex_a_OBJECTS = $(am_libxetex_a_OBJECTS) LTLIBRARIES = $(lib_LTLIBRARIES) am__DEPENDENCIES_1 = @@ -971,51 +1009,60 @@ am__EXEEXT_4 = odvicopy$(EXEEXT) odvitype$(EXEEXT) otangle$(EXEEXT) \ @MF_TRUE@am__EXEEXT_8 = mf$(EXEEXT) @MFN_TRUE@@MF_TRUE@am__EXEEXT_9 = mf-nowin$(EXEEXT) @MF_TRUE@@WIN32_TRUE@am__EXEEXT_10 = inimf$(EXEEXT) -@MP_TRUE@am__EXEEXT_11 = mpost$(EXEEXT) -@PMP_TRUE@am__EXEEXT_12 = pmpost$(EXEEXT) -@UPMP_TRUE@am__EXEEXT_13 = upmpost$(EXEEXT) -@ETEX_TRUE@am__EXEEXT_14 = etex$(EXEEXT) -@PTEX_TRUE@am__EXEEXT_15 = ptex$(EXEEXT) -@PWEB_TRUE@am__EXEEXT_16 = $(am__EXEEXT_2) -@EPTEX_TRUE@am__EXEEXT_17 = eptex$(EXEEXT) -@UPTEX_TRUE@am__EXEEXT_18 = uptex$(EXEEXT) -@UPWEB_TRUE@am__EXEEXT_19 = $(am__EXEEXT_3) -@EUPTEX_TRUE@am__EXEEXT_20 = euptex$(EXEEXT) -@PDFTEX_TRUE@am__EXEEXT_21 = pdftex$(EXEEXT) ttf2afm$(EXEEXT) \ +@MFLUA_TRUE@am__EXEEXT_11 = mflua$(EXEEXT) +@MFLUAN_TRUE@@MFLUA_TRUE@am__EXEEXT_12 = mflua-nowin$(EXEEXT) +@MFLUA_TRUE@@WIN32_TRUE@am__EXEEXT_13 = inimflua$(EXEEXT) +@MFLUAJIT_TRUE@am__EXEEXT_14 = mfluajit$(EXEEXT) +@MFLUAJITN_TRUE@@MFLUAJIT_TRUE@am__EXEEXT_15 = \ +@MFLUAJITN_TRUE@@MFLUAJIT_TRUE@ mfluajit-nowin$(EXEEXT) +@MFLUAJIT_TRUE@@WIN32_TRUE@am__EXEEXT_16 = inimfluajit$(EXEEXT) +@MP_TRUE@am__EXEEXT_17 = mpost$(EXEEXT) +@PMP_TRUE@am__EXEEXT_18 = pmpost$(EXEEXT) +@UPMP_TRUE@am__EXEEXT_19 = upmpost$(EXEEXT) +@ETEX_TRUE@am__EXEEXT_20 = etex$(EXEEXT) +@PTEX_TRUE@am__EXEEXT_21 = ptex$(EXEEXT) +@PWEB_TRUE@am__EXEEXT_22 = $(am__EXEEXT_2) +@EPTEX_TRUE@am__EXEEXT_23 = eptex$(EXEEXT) +@UPTEX_TRUE@am__EXEEXT_24 = uptex$(EXEEXT) +@UPWEB_TRUE@am__EXEEXT_25 = $(am__EXEEXT_3) +@EUPTEX_TRUE@am__EXEEXT_26 = euptex$(EXEEXT) +@PDFTEX_TRUE@am__EXEEXT_27 = pdftex$(EXEEXT) ttf2afm$(EXEEXT) \ @PDFTEX_TRUE@ pdftosrc$(EXEEXT) -@LUATEX_TRUE@am__EXEEXT_22 = luatex$(EXEEXT) -@LUAJITTEX_TRUE@am__EXEEXT_23 = luajittex$(EXEEXT) -@XETEX_TRUE@am__EXEEXT_24 = xetex$(EXEEXT) -@OTANGLE_TRUE@am__EXEEXT_25 = $(am__EXEEXT_4) -@ALEPH_TRUE@am__EXEEXT_26 = aleph$(EXEEXT) -@SYNCTEX_TRUE@am__EXEEXT_27 = synctex$(EXEEXT) -@TEX_TRUE@am__EXEEXT_28 = dvitype$(EXEEXT) pltotf$(EXEEXT) \ +@LUATEX_TRUE@am__EXEEXT_28 = luatex$(EXEEXT) +@LUAJITTEX_TRUE@am__EXEEXT_29 = luajittex$(EXEEXT) +@XETEX_TRUE@am__EXEEXT_30 = xetex$(EXEEXT) +@OTANGLE_TRUE@am__EXEEXT_31 = $(am__EXEEXT_4) +@ALEPH_TRUE@am__EXEEXT_32 = aleph$(EXEEXT) +@SYNCTEX_TRUE@am__EXEEXT_33 = synctex$(EXEEXT) +@TEX_TRUE@am__EXEEXT_34 = dvitype$(EXEEXT) pltotf$(EXEEXT) \ @TEX_TRUE@ tftopl$(EXEEXT) -@MF_TRUE@am__EXEEXT_29 = gftype$(EXEEXT) tftopl$(EXEEXT) -@MP_TRUE@am__EXEEXT_30 = pltotf$(EXEEXT) tftopl$(EXEEXT) -@ETEX_TRUE@am__EXEEXT_31 = dvitype$(EXEEXT) pltotf$(EXEEXT) \ +@MF_TRUE@am__EXEEXT_35 = gftype$(EXEEXT) tftopl$(EXEEXT) +@MFLUA_TRUE@am__EXEEXT_36 = gftype$(EXEEXT) tftopl$(EXEEXT) +@MFLUAJIT_TRUE@am__EXEEXT_37 = gftype$(EXEEXT) tftopl$(EXEEXT) +@MP_TRUE@am__EXEEXT_38 = pltotf$(EXEEXT) tftopl$(EXEEXT) +@ETEX_TRUE@am__EXEEXT_39 = dvitype$(EXEEXT) pltotf$(EXEEXT) \ @ETEX_TRUE@ tftopl$(EXEEXT) -@PTEX_TRUE@am__EXEEXT_32 = dvitype$(EXEEXT) pltotf$(EXEEXT) \ +@PTEX_TRUE@am__EXEEXT_40 = dvitype$(EXEEXT) pltotf$(EXEEXT) \ @PTEX_TRUE@ tftopl$(EXEEXT) -@EPTEX_TRUE@am__EXEEXT_33 = dvitype$(EXEEXT) pltotf$(EXEEXT) \ +@EPTEX_TRUE@am__EXEEXT_41 = dvitype$(EXEEXT) pltotf$(EXEEXT) \ @EPTEX_TRUE@ tftopl$(EXEEXT) -@UPTEX_TRUE@am__EXEEXT_34 = dvitype$(EXEEXT) pltotf$(EXEEXT) \ +@UPTEX_TRUE@am__EXEEXT_42 = dvitype$(EXEEXT) pltotf$(EXEEXT) \ @UPTEX_TRUE@ tftopl$(EXEEXT) -@EUPTEX_TRUE@am__EXEEXT_35 = dvitype$(EXEEXT) pltotf$(EXEEXT) \ +@EUPTEX_TRUE@am__EXEEXT_43 = dvitype$(EXEEXT) pltotf$(EXEEXT) \ @EUPTEX_TRUE@ tftopl$(EXEEXT) -@OTANGLE_TRUE@am__EXEEXT_36 = pltotf$(EXEEXT) tftopl$(EXEEXT) -@MP_TRUE@@WIN32_TRUE@am__EXEEXT_37 = call_mpost$(EXEEXT) -@PMP_TRUE@@WIN32_TRUE@am__EXEEXT_38 = call_pmpost$(EXEEXT) -@UPMP_TRUE@@WIN32_TRUE@am__EXEEXT_39 = call_upmpost$(EXEEXT) -@LUATEX_TRUE@@WIN32_TRUE@am__EXEEXT_40 = call_luatex$(EXEEXT) -@LUAJITTEX_TRUE@@WIN32_TRUE@am__EXEEXT_41 = call_luajittex$(EXEEXT) -@LUATEX_TRUE@@cross_FALSE@am__EXEEXT_42 = txt2zlib$(EXEEXT) +@OTANGLE_TRUE@am__EXEEXT_44 = pltotf$(EXEEXT) tftopl$(EXEEXT) +@MP_TRUE@@WIN32_TRUE@am__EXEEXT_45 = call_mpost$(EXEEXT) +@PMP_TRUE@@WIN32_TRUE@am__EXEEXT_46 = call_pmpost$(EXEEXT) +@UPMP_TRUE@@WIN32_TRUE@am__EXEEXT_47 = call_upmpost$(EXEEXT) +@LUATEX_TRUE@@WIN32_TRUE@am__EXEEXT_48 = call_luatex$(EXEEXT) +@LUAJITTEX_TRUE@@WIN32_TRUE@am__EXEEXT_49 = call_luajittex$(EXEEXT) +@LUATEX_TRUE@@cross_FALSE@am__EXEEXT_50 = txt2zlib$(EXEEXT) PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) dist_aleph_OBJECTS = alephdir/aleph-aleph.$(OBJEXT) \ alephdir/aleph-alephbis.$(OBJEXT) \ alephdir/aleph-alephextra.$(OBJEXT) -am__objects_25 = aleph-alephini.$(OBJEXT) aleph-aleph0.$(OBJEXT) -nodist_aleph_OBJECTS = $(am__objects_25) aleph-aleph-pool.$(OBJEXT) +am__objects_27 = aleph-alephini.$(OBJEXT) aleph-aleph0.$(OBJEXT) +nodist_aleph_OBJECTS = $(am__objects_27) aleph-aleph-pool.$(OBJEXT) aleph_OBJECTS = $(dist_aleph_OBJECTS) $(nodist_aleph_OBJECTS) am__DEPENDENCIES_2 = $(proglib) $(am__DEPENDENCIES_1) aleph_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) @@ -1065,22 +1112,22 @@ am__dist_eptex_SOURCES_DIST = eptexdir/eptexextra.c \ eptexdir/eptexextra.h eptexdir/eptex_version.h \ synctexdir/synctex.c synctexdir/synctex.h \ synctexdir/synctex-common.h synctexdir/synctex-eptex.h -@EPTEX_SYNCTEX_TRUE@am__objects_26 = \ +@EPTEX_SYNCTEX_TRUE@am__objects_28 = \ @EPTEX_SYNCTEX_TRUE@ synctexdir/eptex-synctex.$(OBJEXT) dist_eptex_OBJECTS = eptexdir/eptex-eptexextra.$(OBJEXT) \ - $(am__objects_26) -am__objects_27 = eptex-eptexini.$(OBJEXT) eptex-eptex0.$(OBJEXT) -nodist_eptex_OBJECTS = $(am__objects_27) eptex-eptex-pool.$(OBJEXT) + $(am__objects_28) +am__objects_29 = eptex-eptexini.$(OBJEXT) eptex-eptex0.$(OBJEXT) +nodist_eptex_OBJECTS = $(am__objects_29) eptex-eptex-pool.$(OBJEXT) eptex_OBJECTS = $(dist_eptex_OBJECTS) $(nodist_eptex_OBJECTS) @EPTEX_SYNCTEX_TRUE@am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1) am__dist_etex_SOURCES_DIST = etexdir/etexextra.c etexdir/etexextra.h \ etexdir/etex_version.h synctexdir/synctex.c \ synctexdir/synctex.h synctexdir/synctex-common.h \ synctexdir/synctex-etex.h -@ETEX_SYNCTEX_TRUE@am__objects_28 = synctexdir/etex-synctex.$(OBJEXT) -dist_etex_OBJECTS = etexdir/etex-etexextra.$(OBJEXT) $(am__objects_28) -am__objects_29 = etex-etexini.$(OBJEXT) etex-etex0.$(OBJEXT) -nodist_etex_OBJECTS = $(am__objects_29) etex-etex-pool.$(OBJEXT) +@ETEX_SYNCTEX_TRUE@am__objects_30 = synctexdir/etex-synctex.$(OBJEXT) +dist_etex_OBJECTS = etexdir/etex-etexextra.$(OBJEXT) $(am__objects_30) +am__objects_31 = etex-etexini.$(OBJEXT) etex-etex0.$(OBJEXT) +nodist_etex_OBJECTS = $(am__objects_31) etex-etex-pool.$(OBJEXT) etex_OBJECTS = $(dist_etex_OBJECTS) $(nodist_etex_OBJECTS) @ETEX_SYNCTEX_TRUE@am__DEPENDENCIES_4 = $(am__DEPENDENCIES_1) etex_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ @@ -1089,12 +1136,12 @@ am__dist_euptex_SOURCES_DIST = euptexdir/euptexextra.c \ euptexdir/euptexextra.h synctexdir/synctex.c \ synctexdir/synctex.h synctexdir/synctex-common.h \ synctexdir/synctex-euptex.h -@EUPTEX_SYNCTEX_TRUE@am__objects_30 = \ +@EUPTEX_SYNCTEX_TRUE@am__objects_32 = \ @EUPTEX_SYNCTEX_TRUE@ synctexdir/euptex-synctex.$(OBJEXT) dist_euptex_OBJECTS = euptexdir/euptex-euptexextra.$(OBJEXT) \ - $(am__objects_30) -am__objects_31 = euptex-euptexini.$(OBJEXT) euptex-euptex0.$(OBJEXT) -nodist_euptex_OBJECTS = $(am__objects_31) euptex-euptex-pool.$(OBJEXT) + $(am__objects_32) +am__objects_33 = euptex-euptexini.$(OBJEXT) euptex-euptex0.$(OBJEXT) +nodist_euptex_OBJECTS = $(am__objects_33) euptex-euptex-pool.$(OBJEXT) euptex_OBJECTS = $(dist_euptex_OBJECTS) $(nodist_euptex_OBJECTS) @EUPTEX_SYNCTEX_TRUE@am__DEPENDENCIES_5 = $(am__DEPENDENCIES_1) am_gftodvi_OBJECTS = @@ -1113,12 +1160,18 @@ gftype_DEPENDENCIES = $(proglib) $(am__DEPENDENCIES_1) nodist_inimf_OBJECTS = inimf-callexe.$(OBJEXT) inimf_OBJECTS = $(nodist_inimf_OBJECTS) inimf_DEPENDENCIES = +nodist_inimflua_OBJECTS = inimflua-callexe.$(OBJEXT) +inimflua_OBJECTS = $(nodist_inimflua_OBJECTS) +inimflua_DEPENDENCIES = +nodist_inimfluajit_OBJECTS = inimfluajit-callexe.$(OBJEXT) +inimfluajit_OBJECTS = $(nodist_inimfluajit_OBJECTS) +inimfluajit_DEPENDENCIES = nodist_initex_OBJECTS = initex-callexe.$(OBJEXT) initex_OBJECTS = $(nodist_initex_OBJECTS) initex_DEPENDENCIES = -am__objects_32 = luatexdir/luajittex-luatex.$(OBJEXT) \ +am__objects_34 = luatexdir/luajittex-luatex.$(OBJEXT) \ mplibdir/luajittex-lmplib.$(OBJEXT) -nodist_luajittex_OBJECTS = $(am__objects_32) +nodist_luajittex_OBJECTS = $(am__objects_34) luajittex_OBJECTS = $(nodist_luajittex_OBJECTS) am__DEPENDENCIES_6 = libmplib.a $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ @@ -1129,9 +1182,9 @@ am__DEPENDENCIES_6 = libmplib.a $(am__DEPENDENCIES_1) \ luajittex_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(luajittex_CXXFLAGS) \ $(CXXFLAGS) $(luajittex_LDFLAGS) $(LDFLAGS) -o $@ -am__objects_33 = luatexdir/luatex-luatex.$(OBJEXT) \ +am__objects_35 = luatexdir/luatex-luatex.$(OBJEXT) \ mplibdir/luatex-lmplib.$(OBJEXT) -nodist_luatex_OBJECTS = $(am__objects_33) +nodist_luatex_OBJECTS = $(am__objects_35) luatex_OBJECTS = $(nodist_luatex_OBJECTS) am__DEPENDENCIES_7 = $(am__DEPENDENCIES_1) luatex_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ @@ -1151,12 +1204,43 @@ mf_DEPENDENCIES = libmf.a $(am__DEPENDENCIES_2) $(windowlib) \ dist_mf_nowin_OBJECTS = mf_nowin-mfextra.$(OBJEXT) mf_nowin_OBJECTS = $(dist_mf_nowin_OBJECTS) mf_nowin_DEPENDENCIES = libmf.a $(am__DEPENDENCIES_2) $(windowlib) +dist_mflua_OBJECTS = mfluadir/mflua-mfluaextra.$(OBJEXT) +mflua_OBJECTS = $(dist_mflua_OBJECTS) +mflua_DEPENDENCIES = libmflua.a $(am__DEPENDENCIES_2) $(windowlib) \ + $(am__DEPENDENCIES_8) $(am__DEPENDENCIES_7) +mflua_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(mflua_LDFLAGS) $(LDFLAGS) -o $@ +am__objects_36 = mfluadir/mflua_nowin-mfluaextra.$(OBJEXT) +nodist_mflua_nowin_OBJECTS = $(am__objects_36) +mflua_nowin_OBJECTS = $(nodist_mflua_nowin_OBJECTS) +mflua_nowin_DEPENDENCIES = libmflua.a $(am__DEPENDENCIES_2) \ + $(windowlib) $(am__DEPENDENCIES_7) +mflua_nowin_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(mflua_nowin_LDFLAGS) $(LDFLAGS) -o $@ +dist_mfluajit_OBJECTS = mfluajitdir/mfluajit-mfluajitextra.$(OBJEXT) +mfluajit_OBJECTS = $(dist_mfluajit_OBJECTS) +mfluajit_DEPENDENCIES = libmfluajit.a $(am__DEPENDENCIES_2) \ + $(windowlib) $(am__DEPENDENCIES_8) $(am__DEPENDENCIES_1) +mfluajit_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(mfluajit_LDFLAGS) $(LDFLAGS) -o $@ +am__objects_37 = mfluajitdir/mfluajit_nowin-mfluajitextra.$(OBJEXT) +nodist_mfluajit_nowin_OBJECTS = $(am__objects_37) +mfluajit_nowin_OBJECTS = $(nodist_mfluajit_nowin_OBJECTS) +mfluajit_nowin_DEPENDENCIES = libmfluajit.a $(am__DEPENDENCIES_2) \ + $(windowlib) $(am__DEPENDENCIES_1) +mfluajit_nowin_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(AM_CFLAGS) $(CFLAGS) $(mfluajit_nowin_LDFLAGS) $(LDFLAGS) -o \ + $@ nodist_mft_OBJECTS = mft.$(OBJEXT) mft_OBJECTS = $(nodist_mft_OBJECTS) mft_LDADD = $(LDADD) mft_DEPENDENCIES = $(proglib) $(am__DEPENDENCIES_1) -am__objects_34 = mpost-mpxout.$(OBJEXT) -nodist_mpost_OBJECTS = mpost-mpost.$(OBJEXT) $(am__objects_34) +am__objects_38 = mpost-mpxout.$(OBJEXT) +nodist_mpost_OBJECTS = mpost-mpost.$(OBJEXT) $(am__objects_38) mpost_OBJECTS = $(nodist_mpost_OBJECTS) mpost_DEPENDENCIES = libmplib.a $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ @@ -1188,12 +1272,12 @@ am__dist_pdftex_SOURCES_DIST = pdftexdir/pdftexextra.c \ pdftexdir/etex_version.h synctexdir/synctex.c \ synctexdir/synctex.h synctexdir/synctex-common.h \ synctexdir/synctex-pdftex.h -@PDFTEX_SYNCTEX_TRUE@am__objects_35 = \ +@PDFTEX_SYNCTEX_TRUE@am__objects_39 = \ @PDFTEX_SYNCTEX_TRUE@ synctexdir/pdftex-synctex.$(OBJEXT) dist_pdftex_OBJECTS = pdftexdir/pdftex-pdftexextra.$(OBJEXT) \ - $(am__objects_35) -am__objects_36 = pdftex-pdftexini.$(OBJEXT) pdftex-pdftex0.$(OBJEXT) -nodist_pdftex_OBJECTS = $(am__objects_36) pdftex-pdftex-pool.$(OBJEXT) + $(am__objects_39) +am__objects_40 = pdftex-pdftexini.$(OBJEXT) pdftex-pdftex0.$(OBJEXT) +nodist_pdftex_OBJECTS = $(am__objects_40) pdftex-pdftex-pool.$(OBJEXT) pdftex_OBJECTS = $(dist_pdftex_OBJECTS) $(nodist_pdftex_OBJECTS) am__DEPENDENCIES_10 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) libmd5.a @@ -1220,20 +1304,20 @@ nodist_pltotf_OBJECTS = pltotf.$(OBJEXT) pltotf_OBJECTS = $(nodist_pltotf_OBJECTS) pltotf_LDADD = $(LDADD) pltotf_DEPENDENCIES = $(proglib) $(am__DEPENDENCIES_1) -am__objects_37 = pmpost-pmp.$(OBJEXT) -am__objects_38 = pmpost-pmpmath.$(OBJEXT) -am__objects_39 = pmpost-pmpmathbinary.$(OBJEXT) -am__objects_40 = pmpost-pmpmathdecimal.$(OBJEXT) -am__objects_41 = pmpost-pmpmathdouble.$(OBJEXT) -am__objects_42 = pmpost-pmpstrings.$(OBJEXT) -am__objects_43 = pmpost-pmpxout.$(OBJEXT) -am__objects_44 = pmpost-ppngout.$(OBJEXT) -am__objects_45 = pmpost-ppsout.$(OBJEXT) -am__objects_46 = pmpost-psvgout.$(OBJEXT) -nodist_pmpost_OBJECTS = $(am__objects_37) $(am__objects_38) \ - $(am__objects_39) $(am__objects_40) $(am__objects_41) \ - pmpost-pmpost.$(OBJEXT) $(am__objects_42) $(am__objects_43) \ - $(am__objects_44) $(am__objects_45) $(am__objects_46) \ +am__objects_41 = pmpost-pmp.$(OBJEXT) +am__objects_42 = pmpost-pmpmath.$(OBJEXT) +am__objects_43 = pmpost-pmpmathbinary.$(OBJEXT) +am__objects_44 = pmpost-pmpmathdecimal.$(OBJEXT) +am__objects_45 = pmpost-pmpmathdouble.$(OBJEXT) +am__objects_46 = pmpost-pmpstrings.$(OBJEXT) +am__objects_47 = pmpost-pmpxout.$(OBJEXT) +am__objects_48 = pmpost-ppngout.$(OBJEXT) +am__objects_49 = pmpost-ppsout.$(OBJEXT) +am__objects_50 = pmpost-psvgout.$(OBJEXT) +nodist_pmpost_OBJECTS = $(am__objects_41) $(am__objects_42) \ + $(am__objects_43) $(am__objects_44) $(am__objects_45) \ + pmpost-pmpost.$(OBJEXT) $(am__objects_46) $(am__objects_47) \ + $(am__objects_48) $(am__objects_49) $(am__objects_50) \ pmpost-ptfmin.$(OBJEXT) pmpost_OBJECTS = $(nodist_pmpost_OBJECTS) pmpost_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ @@ -1251,10 +1335,10 @@ am__dist_ptex_SOURCES_DIST = ptexdir/ptexextra.c ptexdir/ptexextra.h \ ptexdir/ptex_version.h synctexdir/synctex.c \ synctexdir/synctex.h synctexdir/synctex-common.h \ synctexdir/synctex-ptex.h -@PTEX_SYNCTEX_TRUE@am__objects_47 = synctexdir/ptex-synctex.$(OBJEXT) -dist_ptex_OBJECTS = ptexdir/ptex-ptexextra.$(OBJEXT) $(am__objects_47) -am__objects_48 = ptex-ptexini.$(OBJEXT) ptex-ptex0.$(OBJEXT) -nodist_ptex_OBJECTS = $(am__objects_48) ptex-ptex-pool.$(OBJEXT) +@PTEX_SYNCTEX_TRUE@am__objects_51 = synctexdir/ptex-synctex.$(OBJEXT) +dist_ptex_OBJECTS = ptexdir/ptex-ptexextra.$(OBJEXT) $(am__objects_51) +am__objects_52 = ptex-ptexini.$(OBJEXT) ptex-ptex0.$(OBJEXT) +nodist_ptex_OBJECTS = $(am__objects_52) ptex-ptex-pool.$(OBJEXT) ptex_OBJECTS = $(dist_ptex_OBJECTS) $(nodist_ptex_OBJECTS) @PTEX_SYNCTEX_TRUE@am__DEPENDENCIES_11 = $(am__DEPENDENCIES_1) am_ptftopl_OBJECTS = @@ -1275,10 +1359,10 @@ tangleboot_LDADD = $(LDADD) am__dist_tex_SOURCES_DIST = texextra.c synctexdir/synctex.c \ synctexdir/synctex.h synctexdir/synctex-common.h \ synctexdir/synctex-tex.h -@TEX_SYNCTEX_TRUE@am__objects_49 = synctexdir/tex-synctex.$(OBJEXT) -dist_tex_OBJECTS = tex-texextra.$(OBJEXT) $(am__objects_49) -am__objects_50 = tex-texini.$(OBJEXT) tex-tex0.$(OBJEXT) -nodist_tex_OBJECTS = $(am__objects_50) tex-tex-pool.$(OBJEXT) +@TEX_SYNCTEX_TRUE@am__objects_53 = synctexdir/tex-synctex.$(OBJEXT) +dist_tex_OBJECTS = tex-texextra.$(OBJEXT) $(am__objects_53) +am__objects_54 = tex-texini.$(OBJEXT) tex-tex0.$(OBJEXT) +nodist_tex_OBJECTS = $(am__objects_54) tex-tex-pool.$(OBJEXT) tex_OBJECTS = $(dist_tex_OBJECTS) $(nodist_tex_OBJECTS) @TEX_SYNCTEX_TRUE@am__DEPENDENCIES_13 = $(am__DEPENDENCIES_1) tex_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ @@ -1305,21 +1389,21 @@ am_updvitype_OBJECTS = nodist_updvitype_OBJECTS = updvitype-updvitype.$(OBJEXT) updvitype_OBJECTS = $(am_updvitype_OBJECTS) \ $(nodist_updvitype_OBJECTS) -am__objects_51 = upmpost-pmp.$(OBJEXT) -am__objects_52 = upmpost-pmpmath.$(OBJEXT) -am__objects_53 = upmpost-pmpmathbinary.$(OBJEXT) -am__objects_54 = upmpost-pmpmathdecimal.$(OBJEXT) -am__objects_55 = upmpost-pmpmathdouble.$(OBJEXT) -am__objects_56 = upmpost-pmpstrings.$(OBJEXT) -am__objects_57 = upmpost-pmpxout.$(OBJEXT) -am__objects_58 = upmpost-ppngout.$(OBJEXT) -am__objects_59 = upmpost-ppsout.$(OBJEXT) -am__objects_60 = upmpost-psvgout.$(OBJEXT) -am__objects_61 = $(am__objects_51) $(am__objects_52) $(am__objects_53) \ - $(am__objects_54) $(am__objects_55) upmpost-pmpost.$(OBJEXT) \ - $(am__objects_56) $(am__objects_57) $(am__objects_58) \ - $(am__objects_59) $(am__objects_60) upmpost-ptfmin.$(OBJEXT) -nodist_upmpost_OBJECTS = $(am__objects_61) +am__objects_55 = upmpost-pmp.$(OBJEXT) +am__objects_56 = upmpost-pmpmath.$(OBJEXT) +am__objects_57 = upmpost-pmpmathbinary.$(OBJEXT) +am__objects_58 = upmpost-pmpmathdecimal.$(OBJEXT) +am__objects_59 = upmpost-pmpmathdouble.$(OBJEXT) +am__objects_60 = upmpost-pmpstrings.$(OBJEXT) +am__objects_61 = upmpost-pmpxout.$(OBJEXT) +am__objects_62 = upmpost-ppngout.$(OBJEXT) +am__objects_63 = upmpost-ppsout.$(OBJEXT) +am__objects_64 = upmpost-psvgout.$(OBJEXT) +am__objects_65 = $(am__objects_55) $(am__objects_56) $(am__objects_57) \ + $(am__objects_58) $(am__objects_59) upmpost-pmpost.$(OBJEXT) \ + $(am__objects_60) $(am__objects_61) $(am__objects_62) \ + $(am__objects_63) $(am__objects_64) upmpost-ptfmin.$(OBJEXT) +nodist_upmpost_OBJECTS = $(am__objects_65) upmpost_OBJECTS = $(nodist_upmpost_OBJECTS) am__DEPENDENCIES_15 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ @@ -1333,12 +1417,12 @@ am__dist_uptex_SOURCES_DIST = uptexdir/uptexextra.c \ uptexdir/uptexextra.h uptexdir/uptex_version.h \ synctexdir/synctex.c synctexdir/synctex.h \ synctexdir/synctex-common.h synctexdir/synctex-uptex.h -@UPTEX_SYNCTEX_TRUE@am__objects_62 = \ +@UPTEX_SYNCTEX_TRUE@am__objects_66 = \ @UPTEX_SYNCTEX_TRUE@ synctexdir/uptex-synctex.$(OBJEXT) dist_uptex_OBJECTS = uptexdir/uptex-uptexextra.$(OBJEXT) \ - $(am__objects_62) -am__objects_63 = uptex-uptexini.$(OBJEXT) uptex-uptex0.$(OBJEXT) -nodist_uptex_OBJECTS = $(am__objects_63) uptex-uptex-pool.$(OBJEXT) + $(am__objects_66) +am__objects_67 = uptex-uptexini.$(OBJEXT) uptex-uptex0.$(OBJEXT) +nodist_uptex_OBJECTS = $(am__objects_67) uptex-uptex-pool.$(OBJEXT) uptex_OBJECTS = $(dist_uptex_OBJECTS) $(nodist_uptex_OBJECTS) @UPTEX_SYNCTEX_TRUE@am__DEPENDENCIES_16 = $(am__DEPENDENCIES_1) am_uptftopl_OBJECTS = @@ -1377,12 +1461,12 @@ am__dist_xetex_SOURCES_DIST = xetexdir/xetexextra.c \ xetexdir/xetex_version.h synctexdir/synctex.c \ synctexdir/synctex.h synctexdir/synctex-common.h \ synctexdir/synctex-xetex.h -@XETEX_SYNCTEX_TRUE@am__objects_64 = \ +@XETEX_SYNCTEX_TRUE@am__objects_68 = \ @XETEX_SYNCTEX_TRUE@ synctexdir/xetex-synctex.$(OBJEXT) dist_xetex_OBJECTS = xetexdir/xetex-xetexextra.$(OBJEXT) \ - $(am__objects_64) -am__objects_65 = xetex-xetexini.$(OBJEXT) xetex-xetex0.$(OBJEXT) -nodist_xetex_OBJECTS = $(am__objects_65) xetex-xetex-pool.$(OBJEXT) + $(am__objects_68) +am__objects_69 = xetex-xetexini.$(OBJEXT) xetex-xetex0.$(OBJEXT) +nodist_xetex_OBJECTS = $(am__objects_69) xetex-xetex-pool.$(OBJEXT) xetex_OBJECTS = $(dist_xetex_OBJECTS) $(nodist_xetex_OBJECTS) @XETEX_MACOSX_FALSE@am__DEPENDENCIES_17 = $(am__DEPENDENCIES_1) am__DEPENDENCIES_18 = $(libxetex) $(am__DEPENDENCIES_1) \ @@ -1472,7 +1556,9 @@ SOURCES = $(nodist_libff_a_SOURCES) $(nodist_libjitff_a_SOURCES) \ $(nodist_libluamisc_a_SOURCES) \ $(nodist_libluasocket_a_SOURCES) $(dist_libluatex_a_SOURCES) \ $(nodist_libluatex_a_SOURCES) $(libmd5_a_SOURCES) \ - $(nodist_libmf_a_SOURCES) $(nodist_libmplib_a_SOURCES) \ + $(nodist_libmf_a_SOURCES) $(dist_libmflua_a_SOURCES) \ + $(nodist_libmflua_a_SOURCES) $(dist_libmfluajit_a_SOURCES) \ + $(nodist_libmfluajit_a_SOURCES) $(nodist_libmplib_a_SOURCES) \ $(libmputil_a_SOURCES) $(libpdftex_a_SOURCES) \ $(EXTRA_libpdftex_a_SOURCES) $(nodist_libsynctex_a_SOURCES) \ $(libukanji_a_SOURCES) $(libunilib_a_SOURCES) \ @@ -1489,10 +1575,13 @@ SOURCES = $(nodist_libff_a_SOURCES) $(nodist_libjitff_a_SOURCES) \ $(dist_euptex_SOURCES) $(nodist_euptex_SOURCES) \ $(gftodvi_SOURCES) $(nodist_gftodvi_SOURCES) \ $(nodist_gftopk_SOURCES) $(nodist_gftype_SOURCES) \ - $(nodist_inimf_SOURCES) $(nodist_initex_SOURCES) \ + $(nodist_inimf_SOURCES) $(nodist_inimflua_SOURCES) \ + $(nodist_inimfluajit_SOURCES) $(nodist_initex_SOURCES) \ $(nodist_luajittex_SOURCES) $(nodist_EXTRA_luajittex_SOURCES) \ $(nodist_luatex_SOURCES) $(nodist_EXTRA_luatex_SOURCES) \ $(md5main_SOURCES) $(dist_mf_SOURCES) $(dist_mf_nowin_SOURCES) \ + $(dist_mflua_SOURCES) $(nodist_mflua_nowin_SOURCES) \ + $(dist_mfluajit_SOURCES) $(nodist_mfluajit_nowin_SOURCES) \ $(nodist_mft_SOURCES) $(nodist_mpost_SOURCES) \ $(nodist_odvicopy_SOURCES) $(nodist_odvitype_SOURCES) \ $(nodist_otangle_SOURCES) $(nodist_patgen_SOURCES) \ @@ -1523,6 +1612,7 @@ SOURCES = $(nodist_libff_a_SOURCES) $(nodist_libjitff_a_SOURCES) \ $(nodist_xetex_SOURCES) $(nodist_EXTRA_xetex_SOURCES) DIST_SOURCES = $(libkanji_a_SOURCES) $(dist_libluajittex_a_SOURCES) \ $(dist_libluatex_a_SOURCES) $(libmd5_a_SOURCES) \ + $(dist_libmflua_a_SOURCES) $(dist_libmfluajit_a_SOURCES) \ $(libmputil_a_SOURCES) $(am__libpdftex_a_SOURCES_DIST) \ $(EXTRA_libpdftex_a_SOURCES) $(libukanji_a_SOURCES) \ $(libunilib_a_SOURCES) $(am__libxetex_a_SOURCES_DIST) \ @@ -1530,6 +1620,7 @@ DIST_SOURCES = $(libkanji_a_SOURCES) $(dist_libluajittex_a_SOURCES) \ $(am__dist_eptex_SOURCES_DIST) $(am__dist_etex_SOURCES_DIST) \ $(am__dist_euptex_SOURCES_DIST) $(gftodvi_SOURCES) \ $(md5main_SOURCES) $(dist_mf_SOURCES) $(dist_mf_nowin_SOURCES) \ + $(dist_mflua_SOURCES) $(dist_mfluajit_SOURCES) \ $(pbibtex_SOURCES) $(am__dist_pdftex_SOURCES_DIST) \ $(pdftosrc_SOURCES) $(pdvitype_SOURCES) $(ppltotf_SOURCES) \ $(am__dist_ptex_SOURCES_DIST) $(ptftopl_SOURCES) \ @@ -1744,13 +1835,13 @@ am__set_TESTS_bases = \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` RECHECK_LOGS = $(TEST_LOGS) -am__EXEEXT_43 = bibtex.test dvicopy.test dvitype.test gftodvi.test \ +am__EXEEXT_51 = bibtex.test dvicopy.test dvitype.test gftodvi.test \ gftopk.test gftype.test mft.test patgen.test pktogf.test \ pktype.test pltotf.test pooltype.test tftopl.test vftovp.test \ vptovf.test weave.test -am__EXEEXT_44 = $(am__EXEEXT_43) tests/bibtex-openout-test.pl \ +am__EXEEXT_52 = $(am__EXEEXT_51) tests/bibtex-openout-test.pl \ tests/bibtex-longline-test.pl tests/bibtex-mem.test -@WEB_TRUE@am__EXEEXT_45 = $(am__EXEEXT_44) +@WEB_TRUE@am__EXEEXT_53 = $(am__EXEEXT_52) TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test LOG_DRIVER = $(SHELL) $(top_srcdir)/../../build-aux/test-driver @@ -1786,6 +1877,8 @@ am__DIST_COMMON = $(dist_man_MANS) $(srcdir)/../../am/bin_links.am \ $(srcdir)/luatexdir/am/luasocket.am \ $(srcdir)/luatexdir/am/luatex.am \ $(srcdir)/luatexdir/am/txt2zlib.am \ + $(srcdir)/mfluadir/am/mflua.am \ + $(srcdir)/mfluajitdir/am/mfluajit.am \ $(srcdir)/mplibdir/am/libmplib.am \ $(srcdir)/mplibdir/am/libmputil.am \ $(srcdir)/mplibdir/am/mplib.am \ @@ -2088,13 +2181,14 @@ AM_OBJCXXFLAGS = ## $(WARNING_OBJCXXFLAGS) version = $(WEB2CVERSION) SUBDIRS = doc lib man web2c . window omegafonts otps proglib = lib/lib.a -EXTRA_LIBRARIES = libmf.a libmputil.a libmplib.a libkanji.a \ - libukanji.a libpdftex.a libluasocket.a libluajitsocket.a \ - libluamisc.a libluajitmisc.a libunilib.a libff.a libjitff.a \ - libluatex.a libluajittex.a libxetex.a libsynctex.a libmd5.a +EXTRA_LIBRARIES = libmf.a libmflua.a libmfluajit.a libmputil.a \ + libmplib.a libkanji.a libukanji.a libpdftex.a libluasocket.a \ + libluajitsocket.a libluamisc.a libluajitmisc.a libunilib.a \ + libff.a libjitff.a libluatex.a libluajittex.a libxetex.a \ + libsynctex.a libmd5.a EXTRA_LTLIBRARIES = libsynctex.la -lib_LIBRARIES = $(am__append_98) -lib_LTLIBRARIES = $(am__append_97) +lib_LIBRARIES = $(am__append_114) +lib_LTLIBRARIES = $(am__append_113) dist_man_MANS = synctexdir/man1/synctex.1 synctexdir/man5/synctex.5 nodist_man_MANS = EXTRA_DIST = PROJECTS cftests cpascal.h help.h w2c/config.h \ @@ -2140,23 +2234,61 @@ EXTRA_DIST = PROJECTS cftests cpascal.h help.h w2c/config.h \ triptrap/trip.pl triptrap/trip.tex triptrap/trip.typ \ triptrap/trip1.in triptrap/trip2.in triptrap/tripin.log \ triptrap/tripman.tex triptrap/tripos.tex triptrap/writeo \ - triptrap/writeo.2 mplibdir/ChangeLog $(mpost_web) $(mp_tests) \ - pmpostdir/ChangeLog $(pmpost_web) $(pmpost_tests) \ - $(upmpost_tests) pmpostdir/tests/psample.mp $(libmplib_web) \ - $(etex_web_srcs) $(etex_ch_srcs) etexdir/ChangeLog \ - etexdir/etex_gen.tex $(etex_tests) tests/wprob.tex \ - etexdir/etrip/etrip.diffs etexdir/etrip/etrip.fot \ - etexdir/etrip/etrip.log etexdir/etrip/etrip.out \ - etexdir/etrip/etrip.pl etexdir/etrip/etrip.tex \ - etexdir/etrip/etrip.typ etexdir/etrip/etrip1.in \ - etexdir/etrip/etrip2.in etexdir/etrip/etrip3.in \ - etexdir/etrip/etripin.log etexdir/etrip/etripman.tex \ - etexdir/etrip/texmf.cnf etexdir/etrip/trip2.in $(ptex_tests) \ - $(pweb_tests) $(ptex_web_srcs) $(ptex_ch_srcs) \ - ptexdir/ptex.defines ptexdir/pbibtex.ch web2c/cvtbib.sed \ - ptexdir/pdvitype.ch ptexdir/ppltotf.ch ptexdir/ptftopl.ch \ - ptexdir/COPYRIGHT ptexdir/COPYRIGHT.jis ptexdir/ChangeLog \ - ptexdir/Changes.txt ptexdir/INSTALL.txt ptexdir/README.txt \ + triptrap/writeo.2 $(mflua_web_srcs) $(mflua_ch_src) \ + mfluadir/mflua.defines mfluadir/ChangeLog $(mflua_tests) \ + mfluadir/mfluatrap/begin_program.lua \ + mfluadir/mfluatrap/do_add_to.lua \ + mfluadir/mfluatrap/end_program.lua \ + mfluadir/mfluatrap/fill_envelope.lua \ + mfluadir/mfluatrap/fill_spec.lua \ + mfluadir/mfluatrap/final_cleanup.lua \ + mfluadir/mfluatrap/main_control.lua \ + mfluadir/mfluatrap/make_ellipse.lua \ + mfluadir/mfluatrap/mfluaini.lua \ + mfluadir/mfluatrap/offset_prep.lua \ + mfluadir/mfluatrap/print_edges.lua \ + mfluadir/mfluatrap/print_path.lua \ + mfluadir/mfluatrap/scan_direction.lua \ + mfluadir/mfluatrap/skew_line_edges.lua \ + mfluadir/mfluatrap/start_of_MF.lua \ + mfluadir/mfluatrap/texmf.cnf \ + mfluadir/mfluatrap/mfluatrap.diffs $(mfluajit_web_srcs) \ + $(mfluajit_ch_src) mfluajitdir/mfluajit.defines \ + mfluajitdir/ChangeLog $(mfluajit_tests) \ + mfluadir/mfluatrap/begin_program.lua \ + mfluadir/mfluatrap/do_add_to.lua \ + mfluadir/mfluatrap/end_program.lua \ + mfluadir/mfluatrap/fill_envelope.lua \ + mfluadir/mfluatrap/fill_spec.lua \ + mfluadir/mfluatrap/final_cleanup.lua \ + mfluadir/mfluatrap/main_control.lua \ + mfluadir/mfluatrap/make_ellipse.lua \ + mfluadir/mfluatrap/mfluaini.lua \ + mfluadir/mfluatrap/offset_prep.lua \ + mfluadir/mfluatrap/print_edges.lua \ + mfluadir/mfluatrap/print_path.lua \ + mfluadir/mfluatrap/scan_direction.lua \ + mfluadir/mfluatrap/skew_line_edges.lua \ + mfluadir/mfluatrap/start_of_MF.lua \ + mfluadir/mfluatrap/texmf.cnf \ + mfluajitdir/mfluajittrap/mfluajittrap.diffs mplibdir/ChangeLog \ + $(mpost_web) $(mp_tests) pmpostdir/ChangeLog $(pmpost_web) \ + $(pmpost_tests) $(upmpost_tests) pmpostdir/tests/psample.mp \ + $(libmplib_web) $(etex_web_srcs) $(etex_ch_srcs) \ + etexdir/ChangeLog etexdir/etex_gen.tex $(etex_tests) \ + tests/wprob.tex etexdir/etrip/etrip.diffs \ + etexdir/etrip/etrip.fot etexdir/etrip/etrip.log \ + etexdir/etrip/etrip.out etexdir/etrip/etrip.pl \ + etexdir/etrip/etrip.tex etexdir/etrip/etrip.typ \ + etexdir/etrip/etrip1.in etexdir/etrip/etrip2.in \ + etexdir/etrip/etrip3.in etexdir/etrip/etripin.log \ + etexdir/etrip/etripman.tex etexdir/etrip/texmf.cnf \ + etexdir/etrip/trip2.in $(ptex_tests) $(pweb_tests) \ + $(ptex_web_srcs) $(ptex_ch_srcs) ptexdir/ptex.defines \ + ptexdir/pbibtex.ch web2c/cvtbib.sed ptexdir/pdvitype.ch \ + ptexdir/ppltotf.ch ptexdir/ptftopl.ch ptexdir/COPYRIGHT \ + ptexdir/COPYRIGHT.jis ptexdir/ChangeLog ptexdir/Changes.txt \ + ptexdir/INSTALL.txt ptexdir/README.txt \ ptexdir/tests/nissya_bib.aux ptexdir/tests/nissya.bst \ ptexdir/tests/sample.bib tests/memdata1.bst tests/memdata2.bst \ tests/memdata3.bst ptexdir/tests/goth10.tfm \ @@ -2373,7 +2505,12 @@ DISTCLEANFILES = CXXLD.sh tangle.c tangle.h tangle.p tangle-web2c \ common.idx tie.outc tie.outm $(nodist_tex_SOURCES) \ tex-final.ch tex-web2c tex.p tex.pool tex-tangle trip.diffs \ write18-quote.log mftrap.diffs $(nodist_libmf_a_SOURCES) \ - mf-final.ch mf-web2c mf.p mf.pool mf-tangle \ + mf-final.ch mf-web2c mf.p mf.pool mf-tangle mfluatrap.diffs \ + $(nodist_libmflua_a_SOURCES) mflua.web mflua.ch mflua-web2c \ + mflua.p mflua.pool mflua-tangle mfluatrap.diffs \ + mfluajittrap.diffs $(nodist_libmfluajit_a_SOURCES) \ + mfluajit.web mfluajit.ch mfluajit-web2c mfluajit.p \ + mfluajit.pool mfluajit-tangle mfluajittrap.diffs \ $(nodist_mpost_SOURCES) mpxout-tangle mptrap.diffs ptmr.mpx \ tests/xptmr.mpx tests/xstory.mpx $(nodist_pmpost_SOURCES) \ pmp.w pmpost.w pmpxout.w ppsout.w psvgout.w ptfmin.w \ @@ -2430,19 +2567,21 @@ DISTCLEANFILES = CXXLD.sh tangle.c tangle.h tangle.p tangle-web2c \ $(nodist_aleph_SOURCES) aleph.web aleph.ch aleph-web2c aleph.p \ aleph.pool aleph-tangle CLEANFILES = -TRIPTRAP_CLEAN = $(am__append_9) $(am__append_17) $(am__append_26) \ - $(am__append_43) $(am__append_49) $(am__append_55) \ - $(am__append_61) $(am__append_67) -TRIPTRAP = $(am__append_8) $(am__append_16) $(am__append_25) \ - $(am__append_42) $(am__append_48) $(am__append_54) \ - $(am__append_60) $(am__append_66) -bin_links = $(am__append_5) $(am__append_13) $(am__append_22) \ - $(am__append_31) $(am__append_36) $(am__append_75) \ - $(am__append_80) -install_exe_links = $(am__append_20) $(am__append_29) $(am__append_34) \ - $(am__append_73) $(am__append_78) -uninstall_exe_links = $(am__append_21) $(am__append_30) \ - $(am__append_35) $(am__append_74) $(am__append_79) +TRIPTRAP_CLEAN = $(am__append_9) $(am__append_17) $(am__append_25) \ + $(am__append_33) $(am__append_42) $(am__append_59) \ + $(am__append_65) $(am__append_71) $(am__append_77) \ + $(am__append_83) +TRIPTRAP = $(am__append_8) $(am__append_16) $(am__append_24) \ + $(am__append_32) $(am__append_41) $(am__append_58) \ + $(am__append_64) $(am__append_70) $(am__append_76) \ + $(am__append_82) +bin_links = $(am__append_5) $(am__append_13) $(am__append_21) \ + $(am__append_29) $(am__append_38) $(am__append_47) \ + $(am__append_52) $(am__append_91) $(am__append_96) +install_exe_links = $(am__append_36) $(am__append_45) $(am__append_50) \ + $(am__append_89) $(am__append_94) +uninstall_exe_links = $(am__append_37) $(am__append_46) \ + $(am__append_51) $(am__append_90) $(am__append_95) NEVER_DIST = `find . $(NEVER_NAMES)` cwebdir/cweave.log \ cwebdir/cweave.trs ctiedir/ctie.log ctiedir/ctie.trs \ tiedir/tie.log tiedir/tie.trs @@ -2550,18 +2689,18 @@ tie_CPPFLAGS = $(AM_CPPFLAGS) -DNOT_WEB2C initex_CPPFLAGS = -DEXEPROG=\"tex.exe\" nodist_initex_SOURCES = callexe.c initex_LDADD = -tex_CPPFLAGS = $(AM_CPPFLAGS) $(am__append_101) +tex_CPPFLAGS = $(AM_CPPFLAGS) $(am__append_117) # With --enable-ipc, TeX may need to link with -lsocket. -tex_LDADD = $(LDADD) $(ipc_socketlibs) $(am__append_102) +tex_LDADD = $(LDADD) $(ipc_socketlibs) $(am__append_118) # TeX C sources tex_c_h = texini.c tex0.c texcoerce.h texd.h nodist_tex_SOURCES = $(tex_c_h) tex-pool.c -dist_tex_SOURCES = texextra.c $(am__append_104) +dist_tex_SOURCES = texextra.c $(am__append_120) # We must create texd.h before building the tex_OBJECTS. -tex_prereq = texd.h $(am__append_103) +tex_prereq = texd.h $(am__append_119) tex_ch_srcs = \ tex.web \ tex.ch \ @@ -2605,6 +2744,67 @@ mf_ch_src = \ # Metafont tests # mf_tests = mftraptest +inimflua_CPPFLAGS = -DEXEPROG=\"mflua.exe\" +nodist_inimflua_SOURCES = callexe.c +inimflua_LDADD = +dist_mflua_SOURCES = mfluadir/mfluaextra.c mfluadir/mfluaextra.h mfluadir/mflua_version.h +mflua_CPPFLAGS = $(AM_CPPFLAGS) $(X_CFLAGS) $(LUA_INCLUDES) +mflua_LDADD = libmflua.a $(LDADD) $(windowlib) $(mf_x_libs) $(LUA_LIBS) +mflua_LDFLAGS = -export-dynamic +nodist_mflua_nowin_SOURCES = $(dist_mflua_SOURCES) +mflua_nowin_CPPFLAGS = $(mflua_CPPFLAGS) -DMFNOWIN $(LUA_INCLUDES) +mflua_nowin_LDADD = libmflua.a $(LDADD) $(windowlib) $(LUA_LIBS) +mflua_nowin_LDFLAGS = -export-dynamic + +# MFLua C sources +mflua_c_h = mfluaini.c mflua0.c mfluacoerce.h mfluad.h +dist_libmflua_a_SOURCES = mfluadir/mfluac.c mfluadir/mfluac.h +nodist_libmflua_a_SOURCES = $(mflua_c_h) mflua-pool.c +libmflua_a_CPPFLAGS = $(AM_CPPFLAGS) $(LUA_INCLUDES) +mflua_web_srcs = \ + mf.web \ + mfluadir/mf-lua.ch + +mflua_ch_src = \ + mf.ch \ + mfluadir/mflua-m.ch \ + mf-binpool.ch + + +# MFLua tests +# +mflua_tests = mfluadir/mfluatraptest +inimfluajit_CPPFLAGS = -DEXEPROG=\"mfluajit.exe\" +nodist_inimfluajit_SOURCES = callexe.c +inimfluajit_LDADD = +dist_mfluajit_SOURCES = mfluajitdir/mfluajitextra.c mfluajitdir/mfluajitextra.h mfluadir/mflua_version.h +mfluajit_CPPFLAGS = $(AM_CPPFLAGS) $(X_CFLAGS) $(LUAJIT_INCLUDES) $(LUAJIT_DEFINES) +mfluajit_LDADD = libmfluajit.a $(LDADD) $(windowlib) $(mf_x_libs) $(LUAJIT_LIBS) +mfluajit_LDFLAGS = -export-dynamic $(LUAJIT_LDEXTRA) +nodist_mfluajit_nowin_SOURCES = $(dist_mfluajit_SOURCES) +mfluajit_nowin_CPPFLAGS = $(mfluajit_CPPFLAGS) -DMFNOWIN $(LUAJIT_INCLUDES) $(LUAJIT_DEFINES) +mfluajit_nowin_LDADD = libmfluajit.a $(LDADD) $(windowlib) $(LUAJIT_LIBS) +mfluajit_nowin_LDFLAGS = -export-dynamic $(LUAJIT_LDEXTRA) + +# MFLua C sources +mfluajit_c_h = mfluajitini.c mfluajit0.c mfluajitcoerce.h mfluajitd.h +dist_libmfluajit_a_SOURCES = mfluadir/mfluac.c mfluadir/mfluac.h +nodist_libmfluajit_a_SOURCES = $(mfluajit_c_h) mfluajit-pool.c +libmfluajit_a_CPPFLAGS = $(AM_CPPFLAGS) $(LUAJIT_INCLUDES) -DJIT +mfluajit_web_srcs = \ + mf.web \ + mfluadir/mf-lua.ch \ + mfluajitdir/mf-luajit.ch + +mfluajit_ch_src = \ + mf.ch \ + mfluadir/mflua-m.ch \ + mf-binpool.ch + + +# MFLua tests +# +mfluajit_tests = mfluajitdir/mfluajittraptest mpost_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_INCLUDES) $(LIBPNG_INCLUDES) -I$(srcdir)/mplibdir mpost_LDADD = libmplib.a $(KPATHSEA_LIBS) $(MPFR_LIBS) $(GMP_LIBS) \ $(CAIRO_LIBS) $(PIXMAN_LIBS) $(LIBPNG_LIBS) $(ZLIB_LIBS) libmputil.a @@ -2691,19 +2891,19 @@ libmplib_web = mplibdir/mp.w mplibdir/psout.w mplibdir/svgout.w \ mplibdir/pngout.w mplibdir/mpmath.w mplibdir/mpmathbinary.w \ mplibdir/mpmathdecimal.w mplibdir/mpmathdouble.w \ mplibdir/mpstrings.w mplibdir/tfmin.w -etex_CPPFLAGS = $(AM_CPPFLAGS) $(am__append_105) +etex_CPPFLAGS = $(AM_CPPFLAGS) $(am__append_121) # With --enable-ipc, e-TeX may need to link with -lsocket. -etex_LDADD = $(LDADD) $(ipc_socketlibs) $(am__append_106) +etex_LDADD = $(LDADD) $(ipc_socketlibs) $(am__append_122) # e-TeX C sources etex_c_h = etexini.c etex0.c etexcoerce.h etexd.h nodist_etex_SOURCES = $(etex_c_h) etex-pool.c dist_etex_SOURCES = etexdir/etexextra.c etexdir/etexextra.h \ - etexdir/etex_version.h $(am__append_108) + etexdir/etex_version.h $(am__append_124) # We must create etexd.h and etexdir/etex_version.h before building the etex_OBJECTS. -etex_prereq = etexd.h etexdir/etex_version.h $(am__append_107) +etex_prereq = etexd.h etexdir/etex_version.h $(am__append_123) etex_web_srcs = \ tex.web \ etexdir/etex.ch @@ -2738,20 +2938,20 @@ pweb_tests = ptexdir/pbibtex.test ptexdir/pdvitype.test \ pproglib = lib/libp.a libkanji_a_SOURCES = ptexdir/kanji.c ptexdir/kanji.h libkanji_a_CPPFLAGS = $(ptex_cppflags) -ptex_CPPFLAGS = $(ptex_cppflags) $(am__append_109) +ptex_CPPFLAGS = $(ptex_cppflags) $(am__append_125) # With --enable-ipc, pTeX may need to link with -lsocket. -ptex_LDADD = $(ptex_ldadd) $(ipc_socketlibs) $(am__append_110) +ptex_LDADD = $(ptex_ldadd) $(ipc_socketlibs) $(am__append_126) ptex_DEPENDENCIES = $(ptex_dependencies) # pTeX C sources ptex_c_h = ptexini.c ptex0.c ptexcoerce.h ptexd.h nodist_ptex_SOURCES = $(ptex_c_h) ptex-pool.c dist_ptex_SOURCES = ptexdir/ptexextra.c ptexdir/ptexextra.h \ - ptexdir/ptex_version.h $(am__append_112) + ptexdir/ptex_version.h $(am__append_128) # We must create ptexd.h and ptexdir/ptex_version.h before building the ptex_OBJECTS. -ptex_prereq = ptexd.h ptexdir/ptex_version.h $(am__append_111) +ptex_prereq = ptexd.h ptexdir/ptex_version.h $(am__append_127) ptex_web_srcs = \ tex.web \ tex.ch @@ -2785,22 +2985,22 @@ ptftopl_DEPENDENCIES = $(ptex_dependencies) # e-pTeX Tests # eptex_tests = eptexdir/eptriptest -eptex_CPPFLAGS = $(PTEXENC_INCLUDES) $(AM_CPPFLAGS) $(am__append_117) +eptex_CPPFLAGS = $(PTEXENC_INCLUDES) $(AM_CPPFLAGS) $(am__append_133) # With --enable-ipc, e-pTeX may need to link with -lsocket. eptex_LDADD = libkanji.a $(pproglib) $(PTEXENC_LIBS) $(LDADD) \ - $(ipc_socketlibs) $(am__append_118) + $(ipc_socketlibs) $(am__append_134) eptex_DEPENDENCIES = libkanji.a $(pproglib) $(PTEXENC_DEPEND) $(default_dependencies) # e-pTeX C sources eptex_c_h = eptexini.c eptex0.c eptexcoerce.h eptexd.h nodist_eptex_SOURCES = $(eptex_c_h) eptex-pool.c dist_eptex_SOURCES = eptexdir/eptexextra.c eptexdir/eptexextra.h \ - eptexdir/eptex_version.h $(am__append_120) + eptexdir/eptex_version.h $(am__append_136) # We must create eptexd.h and eptexdir/eptex_version.h before building the eptex_OBJECTS. eptex_prereq = eptexd.h etexdir/etex_version.h ptexdir/ptex_version.h \ - eptexdir/eptex_version.h $(am__append_119) + eptexdir/eptex_version.h $(am__append_135) eptex_web_srcs = \ tex.web \ etexdir/etex.ch \ @@ -2832,21 +3032,21 @@ upweb_tests = uptexdir/upbibtex.test uptexdir/updvitype.test \ uptexdir/yokotate.test libukanji_a_SOURCES = uptexdir/kanji.c uptexdir/kanji.h uptexdir/kanji_dump.c libukanji_a_CPPFLAGS = $(uptex_cppflags) -uptex_CPPFLAGS = $(uptex_cppflags) $(am__append_113) +uptex_CPPFLAGS = $(uptex_cppflags) $(am__append_129) # With --enable-ipc, upTeX may need to link with -lsocket. -uptex_LDADD = $(uptex_ldadd) $(ipc_socketlibs) $(am__append_114) +uptex_LDADD = $(uptex_ldadd) $(ipc_socketlibs) $(am__append_130) uptex_DEPENDENCIES = $(uptex_dependencies) # upTeX C sources uptex_c_h = uptexini.c uptex0.c uptexcoerce.h uptexd.h nodist_uptex_SOURCES = $(uptex_c_h) uptex-pool.c dist_uptex_SOURCES = uptexdir/uptexextra.c uptexdir/uptexextra.h \ - uptexdir/uptex_version.h $(am__append_116) + uptexdir/uptex_version.h $(am__append_132) # We must create uptexd.h and uptexdir/uptex_version.h before building the uptex_OBJECTS. uptex_prereq = uptexd.h ptexdir/ptex_version.h \ - uptexdir/uptex_version.h $(am__append_115) + uptexdir/uptex_version.h $(am__append_131) uptex_web_srcs = \ tex.web \ tex.ch @@ -2881,23 +3081,23 @@ uptftopl_DEPENDENCIES = $(uptex_dependencies) # e-upTeX Tests # euptex_tests = euptexdir/euptriptest -euptex_CPPFLAGS = $(PTEXENC_INCLUDES) $(AM_CPPFLAGS) $(am__append_121) +euptex_CPPFLAGS = $(PTEXENC_INCLUDES) $(AM_CPPFLAGS) $(am__append_137) # With --enable-ipc, e-upTeX may need to link with -lsocket. euptex_LDADD = libukanji.a $(pproglib) $(PTEXENC_LIBS) $(LDADD) \ - $(ipc_socketlibs) $(am__append_122) + $(ipc_socketlibs) $(am__append_138) euptex_DEPENDENCIES = libukanji.a $(pproglib) $(PTEXENC_DEPEND) $(default_dependencies) # e-upTeX C sources euptex_c_h = euptexini.c euptex0.c euptexcoerce.h euptexd.h nodist_euptex_SOURCES = $(euptex_c_h) euptex-pool.c dist_euptex_SOURCES = euptexdir/euptexextra.c euptexdir/euptexextra.h \ - $(am__append_124) + $(am__append_140) # We must create euptexd.h and [eu]ptexdir/[eu]ptex_version.h before building the euptex_OBJECTS. euptex_prereq = euptexd.h etexdir/etex_version.h \ ptexdir/ptex_version.h eptexdir/eptex_version.h \ - uptexdir/uptex_version.h $(am__append_123) + uptexdir/uptex_version.h $(am__append_139) euptex_web_srcs = \ tex.web \ etexdir/etex.ch \ @@ -2933,7 +3133,7 @@ libpdftex_a_SOURCES = pdftexdir/avl.c pdftexdir/avl.h \ pdftexdir/writejbig2.c pdftexdir/writejpg.c \ pdftexdir/writepng.c pdftexdir/writet1.c pdftexdir/writet3.c \ pdftexdir/writettf.c pdftexdir/writettf.h pdftexdir/writezip.c \ - $(am__append_68) + $(am__append_84) @MINGW32_TRUE@REGEX_INCLUDES = -I$(srcdir)/pdftexdir/regex EXTRA_libpdftex_a_SOURCES = pdftexdir/macnames.c \ pdftexdir/regex/regcomp.c pdftexdir/regex/regex_internal.c \ @@ -2949,7 +3149,7 @@ pdftex_dependencies = $(proglib) $(KPATHSEA_DEPEND) $(LIBPNG_DEPEND) \ # Force Automake to use CXXLD for linking nodist_EXTRA_pdftex_SOURCES = dummy.cxx pdf_tangle = WEBINPUTS=.:$(srcdir)/pdftexdir AM_V_P=$(AM_V_P) $(SHELL) ./tangle-sh $@ $(TANGLE) -pdftex_CPPFLAGS = $(pdftex_cppflags) $(am__append_125) +pdftex_CPPFLAGS = $(pdftex_cppflags) $(am__append_141) pdftex_CXXFLAGS = $(WARNING_CXXFLAGS) # With --enable-ipc, pdfTeX may need to link with -lsocket. @@ -2962,7 +3162,7 @@ pdftex_c_h = pdftexini.c pdftex0.c pdftexcoerce.h pdftexd.h nodist_pdftex_SOURCES = $(pdftex_c_h) pdftex-pool.c dist_pdftex_SOURCES = pdftexdir/pdftexextra.c pdftexdir/pdftexextra.h \ pdftexdir/pdftex_version.h pdftexdir/etex_version.h \ - $(am__append_126) + $(am__append_142) pdftex_ch_srcs = \ pdftexdir/pdftex.web \ pdftexdir/tex.ch0 \ @@ -3398,16 +3598,16 @@ libxetex = libxetex.a xetex_cppflags = $(AM_CPPFLAGS) -I$(srcdir)/xetexdir $(ICU_INCLUDES) \ $(FREETYPE2_INCLUDES) $(TECKIT_INCLUDES) $(HARFBUZZ_INCLUDES) \ $(GRAPHITE2_INCLUDES) $(POPPLER_INCLUDES) $(LIBPNG_INCLUDES) \ - $(ZLIB_INCLUDES) $(am__append_85) $(am__append_86) + $(ZLIB_INCLUDES) $(am__append_101) $(am__append_102) xetex_ldadd = $(libxetex) $(HARFBUZZ_LIBS) $(GRAPHITE2_LIBS) \ $(ICU_LIBS) $(TECKIT_LIBS) $(POPPLER_LIBS) $(LIBPNG_LIBS) \ - $(FREETYPE2_LIBS) $(ZLIB_LIBS) $(am__append_87) + $(FREETYPE2_LIBS) $(ZLIB_LIBS) $(am__append_103) xetex_dependencies = $(proglib) $(KPATHSEA_DEPEND) $(ICU_DEPEND) \ $(TECKIT_DEPEND) $(HARFBUZZ_DEPEND) $(GRAPHITE2_DEPEND) \ $(POPPLER_DEPEND) $(LIBPNG_DEPEND) $(FREETYPE2_DEPEND) \ $(ZLIB_DEPEND) @XETEX_MACOSX_TRUE@xetex_LDFLAGS = -framework ApplicationServices -framework Cocoa -xetex_CPPFLAGS = $(xetex_cppflags) $(am__append_127) +xetex_CPPFLAGS = $(xetex_cppflags) $(am__append_143) xetex_CFLAGS = # $(WARNING_CFLAGS) xetex_CXXFLAGS = # $(WARNING_CXXFLAGS) xetex_LDADD = $(xetex_ldadd) $(LDADD) $(ipc_socketlibs) @@ -3418,7 +3618,7 @@ xetex_c_h = xetexini.c xetex0.c xetexcoerce.h xetexd.h nodist_xetex_SOURCES = $(xetex_c_h) xetex-pool.c dist_xetex_SOURCES = xetexdir/xetexextra.c xetexdir/xetexextra.h \ xetexdir/etex_version.h xetexdir/xetex_version.h \ - $(am__append_128) + $(am__append_144) xetex_ch_srcs = \ xetexdir/xetex.web \ xetexdir/tex.ch0 \ @@ -3445,7 +3645,7 @@ libxetex_a_SOURCES = xetexdir/MathTable.h xetexdir/XeTeXFontInst.cpp \ xetexdir/image/jpegimage.h xetexdir/image/mfileio.c \ xetexdir/image/mfileio.h xetexdir/image/numbers.c \ xetexdir/image/numbers.h xetexdir/image/pngimage.c \ - xetexdir/image/pngimage.h $(am__append_88) $(am__append_89) + xetexdir/image/pngimage.h $(am__append_104) $(am__append_105) # We must create xetexd.h etc. before building the libxetex_a_OBJECTS. libxetex_prereq = xetexd.h $(xetex_dependencies) @@ -3549,12 +3749,12 @@ synctex_SOURCES = \ synctexdir/synctex_main.c synctex_CPPFLAGS = -I$(srcdir)/synctexdir -synctex_LDADD = $(libsynctex) $(ZLIB_LIBS) $(am__append_99) +synctex_LDADD = $(libsynctex) $(ZLIB_LIBS) $(am__append_115) libsynctex = $(LTLIBSYNCTEX) $(LIBSYNCTEX) libsynctex_la_CPPFLAGS = -I$(srcdir)/synctexdir $(ZLIB_INCLUDES) -DSYNCTEX_USE_LOCAL_HEADER libsynctex_a_CPPFLAGS = $(libsynctex_la_CPPFLAGS) libsynctex_la_LDFLAGS = -rpath @libdir@ -bindir @bindir@ -no-undefined -version-info $(SYNCTEX_LT_VERSINFO) -libsynctex_la_LIBADD = $(ZLIB_LIBS) $(am__append_100) +libsynctex_la_LIBADD = $(ZLIB_LIBS) $(am__append_116) libsynctex_la_SOURCES = \ synctexdir/synctex_parser.c \ synctexdir/synctex_parser_local.h \ @@ -3668,7 +3868,7 @@ all: ff-config.h .SUFFIXES: .c .cc .cin .cpp .cxx .h .hin .lo .log .mm .o .obj .p .pin .test .test$(EXEEXT) .trs am--refresh: Makefile @: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../../am/dist_hook.am $(srcdir)/am/bootstrap.am $(srcdir)/am/web.am $(srcdir)/am/cweb.am $(srcdir)/am/texmf.am $(srcdir)/mplibdir/am/mplib.am $(srcdir)/pmpostdir/am/pmpost.am $(srcdir)/mplibdir/am/libmputil.am $(srcdir)/mplibdir/am/libmplib.am $(srcdir)/etexdir/am/etex.am $(srcdir)/ptexdir/am/ptex.am $(srcdir)/eptexdir/am/eptex.am $(srcdir)/uptexdir/am/uptex.am $(srcdir)/euptexdir/am/euptex.am $(srcdir)/pdftexdir/am/libpdftex.am $(srcdir)/pdftexdir/am/pdftex.am $(srcdir)/pdftexdir/am/ttf2afm.am $(srcdir)/pdftexdir/am/pdftosrc.am $(srcdir)/luatexdir/am/luasocket.am $(srcdir)/luatexdir/am/luamisc.am $(srcdir)/luatexdir/am/libunilib.am $(srcdir)/luatexdir/am/luafontforge.am $(srcdir)/luatexdir/am/libluatex.am $(srcdir)/luatexdir/am/luatex.am $(srcdir)/luatexdir/am/txt2zlib.am $(srcdir)/xetexdir/am/xetex.am $(srcdir)/omegaware/am/omegaware.am $(srcdir)/alephdir/am/aleph.am $(srcdir)/synctexdir/am/synctex.am $(srcdir)/libmd5/am/md5.am $(srcdir)/../../am/bin_links.am $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../../am/dist_hook.am $(srcdir)/am/bootstrap.am $(srcdir)/am/web.am $(srcdir)/am/cweb.am $(srcdir)/am/texmf.am $(srcdir)/mfluadir/am/mflua.am $(srcdir)/mfluajitdir/am/mfluajit.am $(srcdir)/mplibdir/am/mplib.am $(srcdir)/pmpostdir/am/pmpost.am $(srcdir)/mplibdir/am/libmputil.am $(srcdir)/mplibdir/am/libmplib.am $(srcdir)/etexdir/am/etex.am $(srcdir)/ptexdir/am/ptex.am $(srcdir)/eptexdir/am/eptex.am $(srcdir)/uptexdir/am/uptex.am $(srcdir)/euptexdir/am/euptex.am $(srcdir)/pdftexdir/am/libpdftex.am $(srcdir)/pdftexdir/am/pdftex.am $(srcdir)/pdftexdir/am/ttf2afm.am $(srcdir)/pdftexdir/am/pdftosrc.am $(srcdir)/luatexdir/am/luasocket.am $(srcdir)/luatexdir/am/luamisc.am $(srcdir)/luatexdir/am/libunilib.am $(srcdir)/luatexdir/am/luafontforge.am $(srcdir)/luatexdir/am/libluatex.am $(srcdir)/luatexdir/am/luatex.am $(srcdir)/luatexdir/am/txt2zlib.am $(srcdir)/xetexdir/am/xetex.am $(srcdir)/omegaware/am/omegaware.am $(srcdir)/alephdir/am/aleph.am $(srcdir)/synctexdir/am/synctex.am $(srcdir)/libmd5/am/md5.am $(srcdir)/../../am/bin_links.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -3690,7 +3890,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; -$(srcdir)/../../am/dist_hook.am $(srcdir)/am/bootstrap.am $(srcdir)/am/web.am $(srcdir)/am/cweb.am $(srcdir)/am/texmf.am $(srcdir)/mplibdir/am/mplib.am $(srcdir)/pmpostdir/am/pmpost.am $(srcdir)/mplibdir/am/libmputil.am $(srcdir)/mplibdir/am/libmplib.am $(srcdir)/etexdir/am/etex.am $(srcdir)/ptexdir/am/ptex.am $(srcdir)/eptexdir/am/eptex.am $(srcdir)/uptexdir/am/uptex.am $(srcdir)/euptexdir/am/euptex.am $(srcdir)/pdftexdir/am/libpdftex.am $(srcdir)/pdftexdir/am/pdftex.am $(srcdir)/pdftexdir/am/ttf2afm.am $(srcdir)/pdftexdir/am/pdftosrc.am $(srcdir)/luatexdir/am/luasocket.am $(srcdir)/luatexdir/am/luamisc.am $(srcdir)/luatexdir/am/libunilib.am $(srcdir)/luatexdir/am/luafontforge.am $(srcdir)/luatexdir/am/libluatex.am $(srcdir)/luatexdir/am/luatex.am $(srcdir)/luatexdir/am/txt2zlib.am $(srcdir)/xetexdir/am/xetex.am $(srcdir)/omegaware/am/omegaware.am $(srcdir)/alephdir/am/aleph.am $(srcdir)/synctexdir/am/synctex.am $(srcdir)/libmd5/am/md5.am $(srcdir)/../../am/bin_links.am $(am__empty): +$(srcdir)/../../am/dist_hook.am $(srcdir)/am/bootstrap.am $(srcdir)/am/web.am $(srcdir)/am/cweb.am $(srcdir)/am/texmf.am $(srcdir)/mfluadir/am/mflua.am $(srcdir)/mfluajitdir/am/mfluajit.am $(srcdir)/mplibdir/am/mplib.am $(srcdir)/pmpostdir/am/pmpost.am $(srcdir)/mplibdir/am/libmputil.am $(srcdir)/mplibdir/am/libmplib.am $(srcdir)/etexdir/am/etex.am $(srcdir)/ptexdir/am/ptex.am $(srcdir)/eptexdir/am/eptex.am $(srcdir)/uptexdir/am/uptex.am $(srcdir)/euptexdir/am/euptex.am $(srcdir)/pdftexdir/am/libpdftex.am $(srcdir)/pdftexdir/am/pdftex.am $(srcdir)/pdftexdir/am/ttf2afm.am $(srcdir)/pdftexdir/am/pdftosrc.am $(srcdir)/luatexdir/am/luasocket.am $(srcdir)/luatexdir/am/luamisc.am $(srcdir)/luatexdir/am/libunilib.am $(srcdir)/luatexdir/am/luafontforge.am $(srcdir)/luatexdir/am/libluatex.am $(srcdir)/luatexdir/am/luatex.am $(srcdir)/luatexdir/am/txt2zlib.am $(srcdir)/xetexdir/am/xetex.am $(srcdir)/omegaware/am/omegaware.am $(srcdir)/alephdir/am/aleph.am $(srcdir)/synctexdir/am/synctex.am $(srcdir)/libmd5/am/md5.am $(srcdir)/../../am/bin_links.am $(am__empty): $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck @@ -4490,6 +4690,26 @@ libmf.a: $(libmf_a_OBJECTS) $(libmf_a_DEPENDENCIES) $(EXTRA_libmf_a_DEPENDENCIES $(AM_V_at)-rm -f libmf.a $(AM_V_AR)$(libmf_a_AR) libmf.a $(libmf_a_OBJECTS) $(libmf_a_LIBADD) $(AM_V_at)$(RANLIB) libmf.a +mfluadir/$(am__dirstamp): + @$(MKDIR_P) mfluadir + @: > mfluadir/$(am__dirstamp) +mfluadir/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) mfluadir/$(DEPDIR) + @: > mfluadir/$(DEPDIR)/$(am__dirstamp) +mfluadir/libmflua_a-mfluac.$(OBJEXT): mfluadir/$(am__dirstamp) \ + mfluadir/$(DEPDIR)/$(am__dirstamp) + +libmflua.a: $(libmflua_a_OBJECTS) $(libmflua_a_DEPENDENCIES) $(EXTRA_libmflua_a_DEPENDENCIES) + $(AM_V_at)-rm -f libmflua.a + $(AM_V_AR)$(libmflua_a_AR) libmflua.a $(libmflua_a_OBJECTS) $(libmflua_a_LIBADD) + $(AM_V_at)$(RANLIB) libmflua.a +mfluadir/libmfluajit_a-mfluac.$(OBJEXT): mfluadir/$(am__dirstamp) \ + mfluadir/$(DEPDIR)/$(am__dirstamp) + +libmfluajit.a: $(libmfluajit_a_OBJECTS) $(libmfluajit_a_DEPENDENCIES) $(EXTRA_libmfluajit_a_DEPENDENCIES) + $(AM_V_at)-rm -f libmfluajit.a + $(AM_V_AR)$(libmfluajit_a_AR) libmfluajit.a $(libmfluajit_a_OBJECTS) $(libmfluajit_a_LIBADD) + $(AM_V_at)$(RANLIB) libmfluajit.a libmplib.a: $(libmplib_a_OBJECTS) $(libmplib_a_DEPENDENCIES) $(EXTRA_libmplib_a_DEPENDENCIES) $(AM_V_at)-rm -f libmplib.a @@ -4942,6 +5162,14 @@ inimf$(EXEEXT): $(inimf_OBJECTS) $(inimf_DEPENDENCIES) $(EXTRA_inimf_DEPENDENCIE @rm -f inimf$(EXEEXT) $(AM_V_CCLD)$(LINK) $(inimf_OBJECTS) $(inimf_LDADD) $(LIBS) +inimflua$(EXEEXT): $(inimflua_OBJECTS) $(inimflua_DEPENDENCIES) $(EXTRA_inimflua_DEPENDENCIES) + @rm -f inimflua$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(inimflua_OBJECTS) $(inimflua_LDADD) $(LIBS) + +inimfluajit$(EXEEXT): $(inimfluajit_OBJECTS) $(inimfluajit_DEPENDENCIES) $(EXTRA_inimfluajit_DEPENDENCIES) + @rm -f inimfluajit$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(inimfluajit_OBJECTS) $(inimfluajit_LDADD) $(LIBS) + initex$(EXEEXT): $(initex_OBJECTS) $(initex_DEPENDENCIES) $(EXTRA_initex_DEPENDENCIES) @rm -f initex$(EXEEXT) $(AM_V_CCLD)$(LINK) $(initex_OBJECTS) $(initex_LDADD) $(LIBS) @@ -4981,6 +5209,38 @@ mf$(EXEEXT): $(mf_OBJECTS) $(mf_DEPENDENCIES) $(EXTRA_mf_DEPENDENCIES) mf-nowin$(EXEEXT): $(mf_nowin_OBJECTS) $(mf_nowin_DEPENDENCIES) $(EXTRA_mf_nowin_DEPENDENCIES) @rm -f mf-nowin$(EXEEXT) $(AM_V_CCLD)$(LINK) $(mf_nowin_OBJECTS) $(mf_nowin_LDADD) $(LIBS) +mfluadir/mflua-mfluaextra.$(OBJEXT): mfluadir/$(am__dirstamp) \ + mfluadir/$(DEPDIR)/$(am__dirstamp) + +mflua$(EXEEXT): $(mflua_OBJECTS) $(mflua_DEPENDENCIES) $(EXTRA_mflua_DEPENDENCIES) + @rm -f mflua$(EXEEXT) + $(AM_V_CCLD)$(mflua_LINK) $(mflua_OBJECTS) $(mflua_LDADD) $(LIBS) +mfluadir/mflua_nowin-mfluaextra.$(OBJEXT): mfluadir/$(am__dirstamp) \ + mfluadir/$(DEPDIR)/$(am__dirstamp) + +mflua-nowin$(EXEEXT): $(mflua_nowin_OBJECTS) $(mflua_nowin_DEPENDENCIES) $(EXTRA_mflua_nowin_DEPENDENCIES) + @rm -f mflua-nowin$(EXEEXT) + $(AM_V_CCLD)$(mflua_nowin_LINK) $(mflua_nowin_OBJECTS) $(mflua_nowin_LDADD) $(LIBS) +mfluajitdir/$(am__dirstamp): + @$(MKDIR_P) mfluajitdir + @: > mfluajitdir/$(am__dirstamp) +mfluajitdir/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) mfluajitdir/$(DEPDIR) + @: > mfluajitdir/$(DEPDIR)/$(am__dirstamp) +mfluajitdir/mfluajit-mfluajitextra.$(OBJEXT): \ + mfluajitdir/$(am__dirstamp) \ + mfluajitdir/$(DEPDIR)/$(am__dirstamp) + +mfluajit$(EXEEXT): $(mfluajit_OBJECTS) $(mfluajit_DEPENDENCIES) $(EXTRA_mfluajit_DEPENDENCIES) + @rm -f mfluajit$(EXEEXT) + $(AM_V_CCLD)$(mfluajit_LINK) $(mfluajit_OBJECTS) $(mfluajit_LDADD) $(LIBS) +mfluajitdir/mfluajit_nowin-mfluajitextra.$(OBJEXT): \ + mfluajitdir/$(am__dirstamp) \ + mfluajitdir/$(DEPDIR)/$(am__dirstamp) + +mfluajit-nowin$(EXEEXT): $(mfluajit_nowin_OBJECTS) $(mfluajit_nowin_DEPENDENCIES) $(EXTRA_mfluajit_nowin_DEPENDENCIES) + @rm -f mfluajit-nowin$(EXEEXT) + $(AM_V_CCLD)$(mfluajit_nowin_LINK) $(mfluajit_nowin_OBJECTS) $(mfluajit_nowin_LDADD) $(LIBS) mft$(EXEEXT): $(mft_OBJECTS) $(mft_DEPENDENCIES) $(EXTRA_mft_DEPENDENCIES) @rm -f mft$(EXEEXT) @@ -5190,6 +5450,8 @@ mostlyclean-compile: -rm -f luatexdir/slnunicode/*.$(OBJEXT) -rm -f luatexdir/unilib/*.$(OBJEXT) -rm -f luatexdir/utils/*.$(OBJEXT) + -rm -f mfluadir/*.$(OBJEXT) + -rm -f mfluajitdir/*.$(OBJEXT) -rm -f mplibdir/*.$(OBJEXT) -rm -f pdftexdir/*.$(OBJEXT) -rm -f pdftexdir/regex/*.$(OBJEXT) @@ -5233,6 +5495,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gftopk.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gftype.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inimf-callexe.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inimflua-callexe.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inimfluajit-callexe.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/initex-callexe.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluajittex_a-align.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluajittex_a-arithmetic.Po@am__quote@ @@ -5428,6 +5692,12 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-writettf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-writetype0.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libluatex_a-writetype2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmflua_a-mflua-pool.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmflua_a-mflua0.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmflua_a-mfluaini.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmfluajit_a-mfluajit-pool.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmfluajit_a-mfluajit0.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmfluajit_a-mfluajitini.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmplib_a-mp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmplib_a-mpmath.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmplib_a-mpmathbinary.Po@am__quote@ @@ -5725,6 +5995,12 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@luatexdir/unilib/$(DEPDIR)/libunilib_a-utype.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@luatexdir/utils/$(DEPDIR)/libluajittex_a-avl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@luatexdir/utils/$(DEPDIR)/libluatex_a-avl.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@mfluadir/$(DEPDIR)/libmflua_a-mfluac.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@mfluadir/$(DEPDIR)/libmfluajit_a-mfluac.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@mfluadir/$(DEPDIR)/mflua-mfluaextra.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@mfluadir/$(DEPDIR)/mflua_nowin-mfluaextra.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@mfluajitdir/$(DEPDIR)/mfluajit-mfluajitextra.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@mfluajitdir/$(DEPDIR)/mfluajit_nowin-mfluajitextra.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@mplibdir/$(DEPDIR)/libmputil_a-avl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@mplibdir/$(DEPDIR)/libmputil_a-decContext.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@mplibdir/$(DEPDIR)/libmputil_a-decNumber.Po@am__quote@ @@ -11115,6 +11391,118 @@ libmd5/libmd5_a-md5.obj: libmd5/md5.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmd5_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmd5/libmd5_a-md5.obj `if test -f 'libmd5/md5.c'; then $(CYGPATH_W) 'libmd5/md5.c'; else $(CYGPATH_W) '$(srcdir)/libmd5/md5.c'; fi` +mfluadir/libmflua_a-mfluac.o: mfluadir/mfluac.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmflua_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mfluadir/libmflua_a-mfluac.o -MD -MP -MF mfluadir/$(DEPDIR)/libmflua_a-mfluac.Tpo -c -o mfluadir/libmflua_a-mfluac.o `test -f 'mfluadir/mfluac.c' || echo '$(srcdir)/'`mfluadir/mfluac.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mfluadir/$(DEPDIR)/libmflua_a-mfluac.Tpo mfluadir/$(DEPDIR)/libmflua_a-mfluac.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluadir/mfluac.c' object='mfluadir/libmflua_a-mfluac.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmflua_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mfluadir/libmflua_a-mfluac.o `test -f 'mfluadir/mfluac.c' || echo '$(srcdir)/'`mfluadir/mfluac.c + +mfluadir/libmflua_a-mfluac.obj: mfluadir/mfluac.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmflua_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mfluadir/libmflua_a-mfluac.obj -MD -MP -MF mfluadir/$(DEPDIR)/libmflua_a-mfluac.Tpo -c -o mfluadir/libmflua_a-mfluac.obj `if test -f 'mfluadir/mfluac.c'; then $(CYGPATH_W) 'mfluadir/mfluac.c'; else $(CYGPATH_W) '$(srcdir)/mfluadir/mfluac.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mfluadir/$(DEPDIR)/libmflua_a-mfluac.Tpo mfluadir/$(DEPDIR)/libmflua_a-mfluac.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluadir/mfluac.c' object='mfluadir/libmflua_a-mfluac.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmflua_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mfluadir/libmflua_a-mfluac.obj `if test -f 'mfluadir/mfluac.c'; then $(CYGPATH_W) 'mfluadir/mfluac.c'; else $(CYGPATH_W) '$(srcdir)/mfluadir/mfluac.c'; fi` + +libmflua_a-mfluaini.o: mfluaini.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmflua_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmflua_a-mfluaini.o -MD -MP -MF $(DEPDIR)/libmflua_a-mfluaini.Tpo -c -o libmflua_a-mfluaini.o `test -f 'mfluaini.c' || echo '$(srcdir)/'`mfluaini.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmflua_a-mfluaini.Tpo $(DEPDIR)/libmflua_a-mfluaini.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluaini.c' object='libmflua_a-mfluaini.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmflua_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmflua_a-mfluaini.o `test -f 'mfluaini.c' || echo '$(srcdir)/'`mfluaini.c + +libmflua_a-mfluaini.obj: mfluaini.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmflua_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmflua_a-mfluaini.obj -MD -MP -MF $(DEPDIR)/libmflua_a-mfluaini.Tpo -c -o libmflua_a-mfluaini.obj `if test -f 'mfluaini.c'; then $(CYGPATH_W) 'mfluaini.c'; else $(CYGPATH_W) '$(srcdir)/mfluaini.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmflua_a-mfluaini.Tpo $(DEPDIR)/libmflua_a-mfluaini.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluaini.c' object='libmflua_a-mfluaini.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmflua_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmflua_a-mfluaini.obj `if test -f 'mfluaini.c'; then $(CYGPATH_W) 'mfluaini.c'; else $(CYGPATH_W) '$(srcdir)/mfluaini.c'; fi` + +libmflua_a-mflua0.o: mflua0.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmflua_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmflua_a-mflua0.o -MD -MP -MF $(DEPDIR)/libmflua_a-mflua0.Tpo -c -o libmflua_a-mflua0.o `test -f 'mflua0.c' || echo '$(srcdir)/'`mflua0.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmflua_a-mflua0.Tpo $(DEPDIR)/libmflua_a-mflua0.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mflua0.c' object='libmflua_a-mflua0.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmflua_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmflua_a-mflua0.o `test -f 'mflua0.c' || echo '$(srcdir)/'`mflua0.c + +libmflua_a-mflua0.obj: mflua0.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmflua_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmflua_a-mflua0.obj -MD -MP -MF $(DEPDIR)/libmflua_a-mflua0.Tpo -c -o libmflua_a-mflua0.obj `if test -f 'mflua0.c'; then $(CYGPATH_W) 'mflua0.c'; else $(CYGPATH_W) '$(srcdir)/mflua0.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmflua_a-mflua0.Tpo $(DEPDIR)/libmflua_a-mflua0.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mflua0.c' object='libmflua_a-mflua0.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmflua_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmflua_a-mflua0.obj `if test -f 'mflua0.c'; then $(CYGPATH_W) 'mflua0.c'; else $(CYGPATH_W) '$(srcdir)/mflua0.c'; fi` + +libmflua_a-mflua-pool.o: mflua-pool.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmflua_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmflua_a-mflua-pool.o -MD -MP -MF $(DEPDIR)/libmflua_a-mflua-pool.Tpo -c -o libmflua_a-mflua-pool.o `test -f 'mflua-pool.c' || echo '$(srcdir)/'`mflua-pool.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmflua_a-mflua-pool.Tpo $(DEPDIR)/libmflua_a-mflua-pool.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mflua-pool.c' object='libmflua_a-mflua-pool.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmflua_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmflua_a-mflua-pool.o `test -f 'mflua-pool.c' || echo '$(srcdir)/'`mflua-pool.c + +libmflua_a-mflua-pool.obj: mflua-pool.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmflua_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmflua_a-mflua-pool.obj -MD -MP -MF $(DEPDIR)/libmflua_a-mflua-pool.Tpo -c -o libmflua_a-mflua-pool.obj `if test -f 'mflua-pool.c'; then $(CYGPATH_W) 'mflua-pool.c'; else $(CYGPATH_W) '$(srcdir)/mflua-pool.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmflua_a-mflua-pool.Tpo $(DEPDIR)/libmflua_a-mflua-pool.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mflua-pool.c' object='libmflua_a-mflua-pool.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmflua_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmflua_a-mflua-pool.obj `if test -f 'mflua-pool.c'; then $(CYGPATH_W) 'mflua-pool.c'; else $(CYGPATH_W) '$(srcdir)/mflua-pool.c'; fi` + +mfluadir/libmfluajit_a-mfluac.o: mfluadir/mfluac.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmfluajit_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mfluadir/libmfluajit_a-mfluac.o -MD -MP -MF mfluadir/$(DEPDIR)/libmfluajit_a-mfluac.Tpo -c -o mfluadir/libmfluajit_a-mfluac.o `test -f 'mfluadir/mfluac.c' || echo '$(srcdir)/'`mfluadir/mfluac.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mfluadir/$(DEPDIR)/libmfluajit_a-mfluac.Tpo mfluadir/$(DEPDIR)/libmfluajit_a-mfluac.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluadir/mfluac.c' object='mfluadir/libmfluajit_a-mfluac.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmfluajit_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mfluadir/libmfluajit_a-mfluac.o `test -f 'mfluadir/mfluac.c' || echo '$(srcdir)/'`mfluadir/mfluac.c + +mfluadir/libmfluajit_a-mfluac.obj: mfluadir/mfluac.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmfluajit_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mfluadir/libmfluajit_a-mfluac.obj -MD -MP -MF mfluadir/$(DEPDIR)/libmfluajit_a-mfluac.Tpo -c -o mfluadir/libmfluajit_a-mfluac.obj `if test -f 'mfluadir/mfluac.c'; then $(CYGPATH_W) 'mfluadir/mfluac.c'; else $(CYGPATH_W) '$(srcdir)/mfluadir/mfluac.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mfluadir/$(DEPDIR)/libmfluajit_a-mfluac.Tpo mfluadir/$(DEPDIR)/libmfluajit_a-mfluac.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluadir/mfluac.c' object='mfluadir/libmfluajit_a-mfluac.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmfluajit_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mfluadir/libmfluajit_a-mfluac.obj `if test -f 'mfluadir/mfluac.c'; then $(CYGPATH_W) 'mfluadir/mfluac.c'; else $(CYGPATH_W) '$(srcdir)/mfluadir/mfluac.c'; fi` + +libmfluajit_a-mfluajitini.o: mfluajitini.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmfluajit_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmfluajit_a-mfluajitini.o -MD -MP -MF $(DEPDIR)/libmfluajit_a-mfluajitini.Tpo -c -o libmfluajit_a-mfluajitini.o `test -f 'mfluajitini.c' || echo '$(srcdir)/'`mfluajitini.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmfluajit_a-mfluajitini.Tpo $(DEPDIR)/libmfluajit_a-mfluajitini.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluajitini.c' object='libmfluajit_a-mfluajitini.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmfluajit_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmfluajit_a-mfluajitini.o `test -f 'mfluajitini.c' || echo '$(srcdir)/'`mfluajitini.c + +libmfluajit_a-mfluajitini.obj: mfluajitini.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmfluajit_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmfluajit_a-mfluajitini.obj -MD -MP -MF $(DEPDIR)/libmfluajit_a-mfluajitini.Tpo -c -o libmfluajit_a-mfluajitini.obj `if test -f 'mfluajitini.c'; then $(CYGPATH_W) 'mfluajitini.c'; else $(CYGPATH_W) '$(srcdir)/mfluajitini.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmfluajit_a-mfluajitini.Tpo $(DEPDIR)/libmfluajit_a-mfluajitini.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluajitini.c' object='libmfluajit_a-mfluajitini.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmfluajit_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmfluajit_a-mfluajitini.obj `if test -f 'mfluajitini.c'; then $(CYGPATH_W) 'mfluajitini.c'; else $(CYGPATH_W) '$(srcdir)/mfluajitini.c'; fi` + +libmfluajit_a-mfluajit0.o: mfluajit0.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmfluajit_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmfluajit_a-mfluajit0.o -MD -MP -MF $(DEPDIR)/libmfluajit_a-mfluajit0.Tpo -c -o libmfluajit_a-mfluajit0.o `test -f 'mfluajit0.c' || echo '$(srcdir)/'`mfluajit0.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmfluajit_a-mfluajit0.Tpo $(DEPDIR)/libmfluajit_a-mfluajit0.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluajit0.c' object='libmfluajit_a-mfluajit0.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmfluajit_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmfluajit_a-mfluajit0.o `test -f 'mfluajit0.c' || echo '$(srcdir)/'`mfluajit0.c + +libmfluajit_a-mfluajit0.obj: mfluajit0.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmfluajit_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmfluajit_a-mfluajit0.obj -MD -MP -MF $(DEPDIR)/libmfluajit_a-mfluajit0.Tpo -c -o libmfluajit_a-mfluajit0.obj `if test -f 'mfluajit0.c'; then $(CYGPATH_W) 'mfluajit0.c'; else $(CYGPATH_W) '$(srcdir)/mfluajit0.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmfluajit_a-mfluajit0.Tpo $(DEPDIR)/libmfluajit_a-mfluajit0.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluajit0.c' object='libmfluajit_a-mfluajit0.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmfluajit_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmfluajit_a-mfluajit0.obj `if test -f 'mfluajit0.c'; then $(CYGPATH_W) 'mfluajit0.c'; else $(CYGPATH_W) '$(srcdir)/mfluajit0.c'; fi` + +libmfluajit_a-mfluajit-pool.o: mfluajit-pool.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmfluajit_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmfluajit_a-mfluajit-pool.o -MD -MP -MF $(DEPDIR)/libmfluajit_a-mfluajit-pool.Tpo -c -o libmfluajit_a-mfluajit-pool.o `test -f 'mfluajit-pool.c' || echo '$(srcdir)/'`mfluajit-pool.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmfluajit_a-mfluajit-pool.Tpo $(DEPDIR)/libmfluajit_a-mfluajit-pool.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluajit-pool.c' object='libmfluajit_a-mfluajit-pool.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmfluajit_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmfluajit_a-mfluajit-pool.o `test -f 'mfluajit-pool.c' || echo '$(srcdir)/'`mfluajit-pool.c + +libmfluajit_a-mfluajit-pool.obj: mfluajit-pool.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmfluajit_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmfluajit_a-mfluajit-pool.obj -MD -MP -MF $(DEPDIR)/libmfluajit_a-mfluajit-pool.Tpo -c -o libmfluajit_a-mfluajit-pool.obj `if test -f 'mfluajit-pool.c'; then $(CYGPATH_W) 'mfluajit-pool.c'; else $(CYGPATH_W) '$(srcdir)/mfluajit-pool.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmfluajit_a-mfluajit-pool.Tpo $(DEPDIR)/libmfluajit_a-mfluajit-pool.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluajit-pool.c' object='libmfluajit_a-mfluajit-pool.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmfluajit_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmfluajit_a-mfluajit-pool.obj `if test -f 'mfluajit-pool.c'; then $(CYGPATH_W) 'mfluajit-pool.c'; else $(CYGPATH_W) '$(srcdir)/mfluajit-pool.c'; fi` + libmplib_a-tfmin.o: tfmin.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmplib_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmplib_a-tfmin.o -MD -MP -MF $(DEPDIR)/libmplib_a-tfmin.Tpo -c -o libmplib_a-tfmin.o `test -f 'tfmin.c' || echo '$(srcdir)/'`tfmin.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmplib_a-tfmin.Tpo $(DEPDIR)/libmplib_a-tfmin.Po @@ -12347,6 +12735,34 @@ inimf-callexe.obj: callexe.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(inimf_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inimf-callexe.obj `if test -f 'callexe.c'; then $(CYGPATH_W) 'callexe.c'; else $(CYGPATH_W) '$(srcdir)/callexe.c'; fi` +inimflua-callexe.o: callexe.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(inimflua_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inimflua-callexe.o -MD -MP -MF $(DEPDIR)/inimflua-callexe.Tpo -c -o inimflua-callexe.o `test -f 'callexe.c' || echo '$(srcdir)/'`callexe.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/inimflua-callexe.Tpo $(DEPDIR)/inimflua-callexe.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='callexe.c' object='inimflua-callexe.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(inimflua_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inimflua-callexe.o `test -f 'callexe.c' || echo '$(srcdir)/'`callexe.c + +inimflua-callexe.obj: callexe.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(inimflua_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inimflua-callexe.obj -MD -MP -MF $(DEPDIR)/inimflua-callexe.Tpo -c -o inimflua-callexe.obj `if test -f 'callexe.c'; then $(CYGPATH_W) 'callexe.c'; else $(CYGPATH_W) '$(srcdir)/callexe.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/inimflua-callexe.Tpo $(DEPDIR)/inimflua-callexe.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='callexe.c' object='inimflua-callexe.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(inimflua_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inimflua-callexe.obj `if test -f 'callexe.c'; then $(CYGPATH_W) 'callexe.c'; else $(CYGPATH_W) '$(srcdir)/callexe.c'; fi` + +inimfluajit-callexe.o: callexe.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(inimfluajit_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inimfluajit-callexe.o -MD -MP -MF $(DEPDIR)/inimfluajit-callexe.Tpo -c -o inimfluajit-callexe.o `test -f 'callexe.c' || echo '$(srcdir)/'`callexe.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/inimfluajit-callexe.Tpo $(DEPDIR)/inimfluajit-callexe.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='callexe.c' object='inimfluajit-callexe.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(inimfluajit_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inimfluajit-callexe.o `test -f 'callexe.c' || echo '$(srcdir)/'`callexe.c + +inimfluajit-callexe.obj: callexe.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(inimfluajit_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inimfluajit-callexe.obj -MD -MP -MF $(DEPDIR)/inimfluajit-callexe.Tpo -c -o inimfluajit-callexe.obj `if test -f 'callexe.c'; then $(CYGPATH_W) 'callexe.c'; else $(CYGPATH_W) '$(srcdir)/callexe.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/inimfluajit-callexe.Tpo $(DEPDIR)/inimfluajit-callexe.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='callexe.c' object='inimfluajit-callexe.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(inimfluajit_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inimfluajit-callexe.obj `if test -f 'callexe.c'; then $(CYGPATH_W) 'callexe.c'; else $(CYGPATH_W) '$(srcdir)/callexe.c'; fi` + initex-callexe.o: callexe.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(initex_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT initex-callexe.o -MD -MP -MF $(DEPDIR)/initex-callexe.Tpo -c -o initex-callexe.o `test -f 'callexe.c' || echo '$(srcdir)/'`callexe.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/initex-callexe.Tpo $(DEPDIR)/initex-callexe.Po @@ -12459,6 +12875,62 @@ mf_nowin-mfextra.obj: mfextra.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mf_nowin_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mf_nowin-mfextra.obj `if test -f 'mfextra.c'; then $(CYGPATH_W) 'mfextra.c'; else $(CYGPATH_W) '$(srcdir)/mfextra.c'; fi` +mfluadir/mflua-mfluaextra.o: mfluadir/mfluaextra.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mflua_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mfluadir/mflua-mfluaextra.o -MD -MP -MF mfluadir/$(DEPDIR)/mflua-mfluaextra.Tpo -c -o mfluadir/mflua-mfluaextra.o `test -f 'mfluadir/mfluaextra.c' || echo '$(srcdir)/'`mfluadir/mfluaextra.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mfluadir/$(DEPDIR)/mflua-mfluaextra.Tpo mfluadir/$(DEPDIR)/mflua-mfluaextra.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluadir/mfluaextra.c' object='mfluadir/mflua-mfluaextra.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mflua_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mfluadir/mflua-mfluaextra.o `test -f 'mfluadir/mfluaextra.c' || echo '$(srcdir)/'`mfluadir/mfluaextra.c + +mfluadir/mflua-mfluaextra.obj: mfluadir/mfluaextra.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mflua_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mfluadir/mflua-mfluaextra.obj -MD -MP -MF mfluadir/$(DEPDIR)/mflua-mfluaextra.Tpo -c -o mfluadir/mflua-mfluaextra.obj `if test -f 'mfluadir/mfluaextra.c'; then $(CYGPATH_W) 'mfluadir/mfluaextra.c'; else $(CYGPATH_W) '$(srcdir)/mfluadir/mfluaextra.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mfluadir/$(DEPDIR)/mflua-mfluaextra.Tpo mfluadir/$(DEPDIR)/mflua-mfluaextra.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluadir/mfluaextra.c' object='mfluadir/mflua-mfluaextra.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mflua_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mfluadir/mflua-mfluaextra.obj `if test -f 'mfluadir/mfluaextra.c'; then $(CYGPATH_W) 'mfluadir/mfluaextra.c'; else $(CYGPATH_W) '$(srcdir)/mfluadir/mfluaextra.c'; fi` + +mfluadir/mflua_nowin-mfluaextra.o: mfluadir/mfluaextra.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mflua_nowin_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mfluadir/mflua_nowin-mfluaextra.o -MD -MP -MF mfluadir/$(DEPDIR)/mflua_nowin-mfluaextra.Tpo -c -o mfluadir/mflua_nowin-mfluaextra.o `test -f 'mfluadir/mfluaextra.c' || echo '$(srcdir)/'`mfluadir/mfluaextra.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mfluadir/$(DEPDIR)/mflua_nowin-mfluaextra.Tpo mfluadir/$(DEPDIR)/mflua_nowin-mfluaextra.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluadir/mfluaextra.c' object='mfluadir/mflua_nowin-mfluaextra.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mflua_nowin_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mfluadir/mflua_nowin-mfluaextra.o `test -f 'mfluadir/mfluaextra.c' || echo '$(srcdir)/'`mfluadir/mfluaextra.c + +mfluadir/mflua_nowin-mfluaextra.obj: mfluadir/mfluaextra.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mflua_nowin_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mfluadir/mflua_nowin-mfluaextra.obj -MD -MP -MF mfluadir/$(DEPDIR)/mflua_nowin-mfluaextra.Tpo -c -o mfluadir/mflua_nowin-mfluaextra.obj `if test -f 'mfluadir/mfluaextra.c'; then $(CYGPATH_W) 'mfluadir/mfluaextra.c'; else $(CYGPATH_W) '$(srcdir)/mfluadir/mfluaextra.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mfluadir/$(DEPDIR)/mflua_nowin-mfluaextra.Tpo mfluadir/$(DEPDIR)/mflua_nowin-mfluaextra.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluadir/mfluaextra.c' object='mfluadir/mflua_nowin-mfluaextra.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mflua_nowin_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mfluadir/mflua_nowin-mfluaextra.obj `if test -f 'mfluadir/mfluaextra.c'; then $(CYGPATH_W) 'mfluadir/mfluaextra.c'; else $(CYGPATH_W) '$(srcdir)/mfluadir/mfluaextra.c'; fi` + +mfluajitdir/mfluajit-mfluajitextra.o: mfluajitdir/mfluajitextra.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mfluajit_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mfluajitdir/mfluajit-mfluajitextra.o -MD -MP -MF mfluajitdir/$(DEPDIR)/mfluajit-mfluajitextra.Tpo -c -o mfluajitdir/mfluajit-mfluajitextra.o `test -f 'mfluajitdir/mfluajitextra.c' || echo '$(srcdir)/'`mfluajitdir/mfluajitextra.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mfluajitdir/$(DEPDIR)/mfluajit-mfluajitextra.Tpo mfluajitdir/$(DEPDIR)/mfluajit-mfluajitextra.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluajitdir/mfluajitextra.c' object='mfluajitdir/mfluajit-mfluajitextra.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mfluajit_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mfluajitdir/mfluajit-mfluajitextra.o `test -f 'mfluajitdir/mfluajitextra.c' || echo '$(srcdir)/'`mfluajitdir/mfluajitextra.c + +mfluajitdir/mfluajit-mfluajitextra.obj: mfluajitdir/mfluajitextra.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mfluajit_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mfluajitdir/mfluajit-mfluajitextra.obj -MD -MP -MF mfluajitdir/$(DEPDIR)/mfluajit-mfluajitextra.Tpo -c -o mfluajitdir/mfluajit-mfluajitextra.obj `if test -f 'mfluajitdir/mfluajitextra.c'; then $(CYGPATH_W) 'mfluajitdir/mfluajitextra.c'; else $(CYGPATH_W) '$(srcdir)/mfluajitdir/mfluajitextra.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mfluajitdir/$(DEPDIR)/mfluajit-mfluajitextra.Tpo mfluajitdir/$(DEPDIR)/mfluajit-mfluajitextra.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluajitdir/mfluajitextra.c' object='mfluajitdir/mfluajit-mfluajitextra.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mfluajit_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mfluajitdir/mfluajit-mfluajitextra.obj `if test -f 'mfluajitdir/mfluajitextra.c'; then $(CYGPATH_W) 'mfluajitdir/mfluajitextra.c'; else $(CYGPATH_W) '$(srcdir)/mfluajitdir/mfluajitextra.c'; fi` + +mfluajitdir/mfluajit_nowin-mfluajitextra.o: mfluajitdir/mfluajitextra.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mfluajit_nowin_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mfluajitdir/mfluajit_nowin-mfluajitextra.o -MD -MP -MF mfluajitdir/$(DEPDIR)/mfluajit_nowin-mfluajitextra.Tpo -c -o mfluajitdir/mfluajit_nowin-mfluajitextra.o `test -f 'mfluajitdir/mfluajitextra.c' || echo '$(srcdir)/'`mfluajitdir/mfluajitextra.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mfluajitdir/$(DEPDIR)/mfluajit_nowin-mfluajitextra.Tpo mfluajitdir/$(DEPDIR)/mfluajit_nowin-mfluajitextra.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluajitdir/mfluajitextra.c' object='mfluajitdir/mfluajit_nowin-mfluajitextra.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mfluajit_nowin_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mfluajitdir/mfluajit_nowin-mfluajitextra.o `test -f 'mfluajitdir/mfluajitextra.c' || echo '$(srcdir)/'`mfluajitdir/mfluajitextra.c + +mfluajitdir/mfluajit_nowin-mfluajitextra.obj: mfluajitdir/mfluajitextra.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mfluajit_nowin_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mfluajitdir/mfluajit_nowin-mfluajitextra.obj -MD -MP -MF mfluajitdir/$(DEPDIR)/mfluajit_nowin-mfluajitextra.Tpo -c -o mfluajitdir/mfluajit_nowin-mfluajitextra.obj `if test -f 'mfluajitdir/mfluajitextra.c'; then $(CYGPATH_W) 'mfluajitdir/mfluajitextra.c'; else $(CYGPATH_W) '$(srcdir)/mfluajitdir/mfluajitextra.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mfluajitdir/$(DEPDIR)/mfluajit_nowin-mfluajitextra.Tpo mfluajitdir/$(DEPDIR)/mfluajit_nowin-mfluajitextra.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mfluajitdir/mfluajitextra.c' object='mfluajitdir/mfluajit_nowin-mfluajitextra.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mfluajit_nowin_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mfluajitdir/mfluajit_nowin-mfluajitextra.obj `if test -f 'mfluajitdir/mfluajitextra.c'; then $(CYGPATH_W) 'mfluajitdir/mfluajitextra.c'; else $(CYGPATH_W) '$(srcdir)/mfluajitdir/mfluajitextra.c'; fi` + mpost-mpost.o: mpost.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpost_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mpost-mpost.o -MD -MP -MF $(DEPDIR)/mpost-mpost.Tpo -c -o mpost-mpost.o `test -f 'mpost.c' || echo '$(srcdir)/'`mpost.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mpost-mpost.Tpo $(DEPDIR)/mpost-mpost.Po @@ -14179,6 +14651,20 @@ mftraptest.log: mftraptest --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +mfluadir/mfluatraptest.log: mfluadir/mfluatraptest + @p='mfluadir/mfluatraptest'; \ + b='mfluadir/mfluatraptest'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +mfluajitdir/mfluajittraptest.log: mfluajitdir/mfluajittraptest + @p='mfluajitdir/mfluajittraptest'; \ + b='mfluajitdir/mfluajittraptest'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) mplibdir/mptraptest.log: mplibdir/mptraptest @p='mplibdir/mptraptest'; \ b='mplibdir/mptraptest'; \ @@ -14524,6 +15010,10 @@ distclean-generic: -rm -f luatexdir/unilib/$(am__dirstamp) -rm -f luatexdir/utils/$(DEPDIR)/$(am__dirstamp) -rm -f luatexdir/utils/$(am__dirstamp) + -rm -f mfluadir/$(DEPDIR)/$(am__dirstamp) + -rm -f mfluadir/$(am__dirstamp) + -rm -f mfluajitdir/$(DEPDIR)/$(am__dirstamp) + -rm -f mfluajitdir/$(am__dirstamp) -rm -f mplibdir/$(DEPDIR)/$(am__dirstamp) -rm -f mplibdir/$(am__dirstamp) -rm -f pdftexdir/$(DEPDIR)/$(am__dirstamp) @@ -14553,7 +15043,7 @@ clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf ./$(DEPDIR) alephdir/$(DEPDIR) eptexdir/$(DEPDIR) etexdir/$(DEPDIR) euptexdir/$(DEPDIR) libmd5/$(DEPDIR) luatexdir/$(DEPDIR) luatexdir/lua/$(DEPDIR) luatexdir/luafilesystem/src/$(DEPDIR) luatexdir/luafontloader/fontforge/fontforge/$(DEPDIR) luatexdir/luafontloader/fontforge/gutils/$(DEPDIR) luatexdir/luafontloader/src/$(DEPDIR) luatexdir/luamd5/$(DEPDIR) luatexdir/luapeg/$(DEPDIR) luatexdir/luaprofiler/$(DEPDIR) luatexdir/luasocket/src/$(DEPDIR) luatexdir/luazip/src/$(DEPDIR) luatexdir/luazlib/$(DEPDIR) luatexdir/slnunicode/$(DEPDIR) luatexdir/unilib/$(DEPDIR) luatexdir/utils/$(DEPDIR) mplibdir/$(DEPDIR) pdftexdir/$(DEPDIR) pdftexdir/regex/$(DEPDIR) ptexdir/$(DEPDIR) synctexdir/$(DEPDIR) uptexdir/$(DEPDIR) xetexdir/$(DEPDIR) xetexdir/image/$(DEPDIR) + -rm -rf ./$(DEPDIR) alephdir/$(DEPDIR) eptexdir/$(DEPDIR) etexdir/$(DEPDIR) euptexdir/$(DEPDIR) libmd5/$(DEPDIR) luatexdir/$(DEPDIR) luatexdir/lua/$(DEPDIR) luatexdir/luafilesystem/src/$(DEPDIR) luatexdir/luafontloader/fontforge/fontforge/$(DEPDIR) luatexdir/luafontloader/fontforge/gutils/$(DEPDIR) luatexdir/luafontloader/src/$(DEPDIR) luatexdir/luamd5/$(DEPDIR) luatexdir/luapeg/$(DEPDIR) luatexdir/luaprofiler/$(DEPDIR) luatexdir/luasocket/src/$(DEPDIR) luatexdir/luazip/src/$(DEPDIR) luatexdir/luazlib/$(DEPDIR) luatexdir/slnunicode/$(DEPDIR) luatexdir/unilib/$(DEPDIR) luatexdir/utils/$(DEPDIR) mfluadir/$(DEPDIR) mfluajitdir/$(DEPDIR) mplibdir/$(DEPDIR) pdftexdir/$(DEPDIR) pdftexdir/regex/$(DEPDIR) ptexdir/$(DEPDIR) synctexdir/$(DEPDIR) uptexdir/$(DEPDIR) xetexdir/$(DEPDIR) xetexdir/image/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-tags @@ -14604,7 +15094,7 @@ installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache - -rm -rf ./$(DEPDIR) alephdir/$(DEPDIR) eptexdir/$(DEPDIR) etexdir/$(DEPDIR) euptexdir/$(DEPDIR) libmd5/$(DEPDIR) luatexdir/$(DEPDIR) luatexdir/lua/$(DEPDIR) luatexdir/luafilesystem/src/$(DEPDIR) luatexdir/luafontloader/fontforge/fontforge/$(DEPDIR) luatexdir/luafontloader/fontforge/gutils/$(DEPDIR) luatexdir/luafontloader/src/$(DEPDIR) luatexdir/luamd5/$(DEPDIR) luatexdir/luapeg/$(DEPDIR) luatexdir/luaprofiler/$(DEPDIR) luatexdir/luasocket/src/$(DEPDIR) luatexdir/luazip/src/$(DEPDIR) luatexdir/luazlib/$(DEPDIR) luatexdir/slnunicode/$(DEPDIR) luatexdir/unilib/$(DEPDIR) luatexdir/utils/$(DEPDIR) mplibdir/$(DEPDIR) pdftexdir/$(DEPDIR) pdftexdir/regex/$(DEPDIR) ptexdir/$(DEPDIR) synctexdir/$(DEPDIR) uptexdir/$(DEPDIR) xetexdir/$(DEPDIR) xetexdir/image/$(DEPDIR) + -rm -rf ./$(DEPDIR) alephdir/$(DEPDIR) eptexdir/$(DEPDIR) etexdir/$(DEPDIR) euptexdir/$(DEPDIR) libmd5/$(DEPDIR) luatexdir/$(DEPDIR) luatexdir/lua/$(DEPDIR) luatexdir/luafilesystem/src/$(DEPDIR) luatexdir/luafontloader/fontforge/fontforge/$(DEPDIR) luatexdir/luafontloader/fontforge/gutils/$(DEPDIR) luatexdir/luafontloader/src/$(DEPDIR) luatexdir/luamd5/$(DEPDIR) luatexdir/luapeg/$(DEPDIR) luatexdir/luaprofiler/$(DEPDIR) luatexdir/luasocket/src/$(DEPDIR) luatexdir/luazip/src/$(DEPDIR) luatexdir/luazlib/$(DEPDIR) luatexdir/slnunicode/$(DEPDIR) luatexdir/unilib/$(DEPDIR) luatexdir/utils/$(DEPDIR) mfluadir/$(DEPDIR) mfluajitdir/$(DEPDIR) mplibdir/$(DEPDIR) pdftexdir/$(DEPDIR) pdftexdir/regex/$(DEPDIR) ptexdir/$(DEPDIR) synctexdir/$(DEPDIR) uptexdir/$(DEPDIR) xetexdir/$(DEPDIR) xetexdir/image/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -14914,6 +15404,79 @@ mftrap.diffs: mf$(EXEEXT) trap-clean: rm -rf trapdir +# We must create mfluad.h and mfluadir/mflua_version.h before compiling mfluaextra.c. +$(mflua_OBJECTS) $(mflua_nowin_OBJECTS): mfluad.h mfluadir/mflua_version.h + +# We must create mfluad.h before building the libmflua_a_OBJECTS. +$(libmflua_a_OBJECTS): mfluad.h + +$(mflua_c_h): mflua-web2c $(LUA_LIBS) + @$(web2c) mflua +mflua-web2c: mflua.p $(web2c_texmf) web2c/cvtmf1.sed web2c/cvtmf2.sed mfluadir/mflua.defines + @$(web2c) mflua + +mflua-pool.c: mflua.pool mfluad.h $(makecpool_stamp) + $(makecpool) mflua >$@ || rm -f $@ + +# Tangling MFLua +mflua.p mflua.pool: mflua-tangle + @$(texmf_tangle) mflua mflua +mflua-tangle: tangle$(EXEEXT) mflua.web mflua.ch tangle-sh + @$(texmf_tangle) mflua mflua + +# Extract mflua version +$(srcdir)/mfluadir/mflua_version.h: @MAINTAINER_MODE_TRUE@ mfluadir/mf-lua.ch + $(AM_V_GEN)grep '^@d MFLua_version_string==' $(srcdir)/mfluadir/mf-lua.ch \ + | sed "s/^.*'-/#define MFLUA_VERSION \"/;s/'.*$$/\"/" >$@ + +# Generate mflua.web +mflua.web: tie$(EXEEXT) $(mflua_web_srcs) + $(tie) -m mflua.web $(mflua_web_srcs) + +# Generate mflua.ch +mflua.ch: tie$(EXEEXT) mflua.web $(mflua_ch_src) + $(tie) -c $@ mflua.web $(mflua_ch_src) + +mfluatrap.diffs: mflua$(EXEEXT) + $(triptrap_diffs) $@ +.PHONY: mfluatrap-clean +mfluatrap-clean: + rm -rf mfluatrapdir + +# We must create mfluajitd.h and mfluadir/mflua_version.h before compiling mfluajitextra.c. +$(mfluajit_OBJECTS) $(mfluajit_nowin_OBJECTS): mfluajitd.h mfluadir/mflua_version.h + +# We must create mfluajitd.h before building the libmfluajit_a_OBJECTS. +$(libmfluajit_a_OBJECTS): mfluajitd.h + +$(mfluajit_c_h): mfluajit-web2c $(LUAJIT_LIBS) + @$(web2c) mfluajit +mfluajit-web2c: mfluajit.p $(web2c_texmf) web2c/cvtmf1.sed web2c/cvtmf2.sed mfluajitdir/mfluajit.defines + @$(web2c) mfluajit + +mfluajit-pool.c: mfluajit.pool mfluajitd.h $(makecpool_stamp) + $(makecpool) mfluajit >$@ || rm -f $@ + +# Tangling MFLua +mfluajit.p mfluajit.pool: mfluajit-tangle + @$(texmf_tangle) mfluajit mfluajit +mfluajit-tangle: tangle$(EXEEXT) mfluajit.web mfluajit.ch tangle-sh + @$(texmf_tangle) mfluajit mfluajit + +# Generate mfluajit.web +mfluajit.web: tie$(EXEEXT) $(mfluajit_web_srcs) + $(tie) -m mfluajit.web $(mfluajit_web_srcs) + +# Generate mfluajit.ch +mfluajit.ch: tie$(EXEEXT) mfluajit.web $(mfluajit_ch_src) + $(tie) -c $@ mfluajit.web $(mfluajit_ch_src) + +mfluajittrap.diffs: mfluajit$(EXEEXT) + $(triptrap_diffs) $@ +.PHONY: mfluajittrap-clean +mfluajittrap-clean: + rm -rf mfluajittrapdir + .PHONY: install-mpost-links uninstall-mpost-links @WIN32_TRUE@install-mpost-links: call_mpost$(EXEEXT) @WIN32_TRUE@ $(INSTALL_PROGRAM) call_mpost$(EXEEXT) $(DESTDIR)$(bindir)/dvitomp$(EXEEXT) diff --git a/source/texk/web2c/NEWS b/source/texk/web2c/NEWS index 071f67e29..d15f6e36d 100644 --- a/source/texk/web2c/NEWS +++ b/source/texk/web2c/NEWS @@ -1,6 +1,6 @@ This file records noteworthy changes. (Public domain.) -2015 (for TeX Live 2014) +2015 (for TeX Live 2014, 21 May 2015) 2014 (for TeX Live 2014, 24 May 2014) 2013 (for TeX Live 2013, 30 May 2013) 2012 (for TeX Live 2012, 1 July 2012) diff --git a/source/texk/web2c/ac/web2c.ac b/source/texk/web2c/ac/web2c.ac index 47752afec..bb9d559ed 100644 --- a/source/texk/web2c/ac/web2c.ac +++ b/source/texk/web2c/ac/web2c.ac @@ -48,7 +48,9 @@ m4_foreach([Kpse_Prog], [kpse_tex_progs], ## configure options for MF dnl [PROG, BUILD-OR-NO, NOWIN-OR-NO, TEXT, REQUIRED-LIBS] m4_define([kpse_mf_progs], [dnl -[[mf], [yes], [yes], [METAFONT], []], +[[mf], [yes], [yes], [METAFONT], []], +[[mflua], [yes], [no], [MFLua], [lua52]], +[[mfluajit], [yes], [no], [MFLuaJIT], [luajit]], ])[]dnl m4_foreach([Kpse_Prog], [kpse_mf_progs], [m4_ifset([Kpse_Prog], diff --git a/source/texk/web2c/c-auto.in b/source/texk/web2c/c-auto.in index cc5b92f97..c59eddf35 100644 --- a/source/texk/web2c/c-auto.in +++ b/source/texk/web2c/c-auto.in @@ -55,6 +55,10 @@ /* Define to 1 if you have the `atoi' function. */ #undef HAVE_ATOI +/* Define to 1 if you have the declaration of `isascii', and to 0 if you + don't. */ +#undef HAVE_DECL_ISASCII + /* Define to 1 if you have the declaration of `strndup', and to 0 if you don't. */ #undef HAVE_DECL_STRNDUP diff --git a/source/texk/web2c/configure b/source/texk/web2c/configure index be1a02dae..ba5c7938c 100755 --- a/source/texk/web2c/configure +++ b/source/texk/web2c/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for Web2C 2015. +# Generated by GNU Autoconf 2.69 for Web2C 2016/dev. # # Report bugs to <tex-k@tug.org>. # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='Web2C' PACKAGE_TARNAME='web2c' -PACKAGE_VERSION='2015' -PACKAGE_STRING='Web2C 2015' +PACKAGE_VERSION='2016/dev' +PACKAGE_STRING='Web2C 2016/dev' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' @@ -746,6 +746,14 @@ X_LIBS X_PRE_LIBS X_CFLAGS XMKMF +MFLUAJITN_FALSE +MFLUAJITN_TRUE +MFLUAJIT_FALSE +MFLUAJIT_TRUE +MFLUAN_FALSE +MFLUAN_TRUE +MFLUA_FALSE +MFLUA_TRUE MFN_FALSE MFN_TRUE MF_FALSE @@ -999,6 +1007,10 @@ enable_xetex enable_xetex_synctex enable_mf enable_mf_nowin +enable_mflua +enable_mflua_nowin +enable_mfluajit +enable_mfluajit_nowin with_mf_x_toolkit enable_epsfwin enable_hp2627win @@ -1596,7 +1608,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures Web2C 2015 to adapt to many kinds of systems. +\`configure' configures Web2C 2016/dev to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1670,7 +1682,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of Web2C 2015:";; + short | recursive ) echo "Configuration of Web2C 2016/dev:";; esac cat <<\_ACEOF @@ -1726,6 +1738,10 @@ Optional Features: --disable-mf do not compile and install METAFONT --disable-mf-nowin do not build a separate non-window-capable METAFONT + --disable-mflua do not compile and install MFLua + --enable-mflua-nowin build a separate non-window-capable MFLua + --disable-mfluajit do not compile and install MFLuaJIT + --enable-mfluajit-nowin build a separate non-window-capable MFLuaJIT --enable-epsfwin include EPSF pseudo window support --enable-hp2627win include HP 2627 window support --enable-mftalkwin include mftalk (generic server) window support @@ -1887,7 +1903,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -Web2C configure 2015 +Web2C configure 2016/dev generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2437,6 +2453,52 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_find_uintX_t +# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES +# --------------------------------------------- +# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR +# accordingly. +ac_fn_c_check_decl () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + as_decl_name=`echo $2|sed 's/ *(.*//'` + as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 +$as_echo_n "checking whether $as_decl_name is declared... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +#ifndef $as_decl_name +#ifdef __cplusplus + (void) $as_decl_use; +#else + (void) $as_decl_name; +#endif +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_decl + # ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES # ---------------------------------------------------- # Tries to find if the field MEMBER exists in type AGGR, after including @@ -2926,57 +2988,11 @@ rm -f conftest.val as_fn_set_status $ac_retval } # ac_fn_c_compute_int - -# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES -# --------------------------------------------- -# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR -# accordingly. -ac_fn_c_check_decl () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - as_decl_name=`echo $2|sed 's/ *(.*//'` - as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 -$as_echo_n "checking whether $as_decl_name is declared... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -#ifndef $as_decl_name -#ifdef __cplusplus - (void) $as_decl_use; -#else - (void) $as_decl_name; -#endif -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_decl cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by Web2C $as_me 2015, which was +It was created by Web2C $as_me 2016/dev, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3357,7 +3373,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. -WEB2CVERSION=2015 +WEB2CVERSION=2016/dev am__api_version='1.15' @@ -8664,7 +8680,7 @@ fi # Define the identity of the package. PACKAGE='web2c' - VERSION='2015' + VERSION='2016/dev' cat >>confdefs.h <<_ACEOF @@ -8819,13 +8835,13 @@ else if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_cflags="-Wimplicit -Wreturn-type" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement" ;; #( *) : ;; esac case `$CC -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -8837,7 +8853,7 @@ esac kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition" ;; #( *) : ;; @@ -14244,6 +14260,18 @@ case :$ac_cv_c_int64_t:$ac_cv_c_int64_t: in #( *) : ;; esac +ac_fn_c_check_decl "$LINENO" "isascii" "ac_cv_have_decl_isascii" "#include <ctype.h> +" +if test "x$ac_cv_have_decl_isascii" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_ISASCII $ac_have_decl +_ACEOF + ac_fn_c_check_member "$LINENO" "struct stat" "st_mtim" "ac_cv_member_struct_stat_st_mtim" "$ac_includes_default" if test "x$ac_cv_member_struct_stat_st_mtim" = xyes; then : @@ -14666,7 +14694,7 @@ if test "x$enable_compiler_warnings" != xno; then ;; esac case `$CXX -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cxxflags="$kpse_cv_warning_cxxflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -18404,7 +18432,7 @@ if test "x$enable_compiler_warnings" != xno; then ;; esac case `$OBJCXX -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_objcxxflags="$kpse_cv_warning_objcxxflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -18843,6 +18871,62 @@ esac if test "${enable_mf_nowin+set}" = set; then : enableval=$enable_mf_nowin; fi +case $enable_mf_nowin in #( + yes | no) : + ;; #( + *) : + enable_mf_nowin=yes ;; +esac +# Check whether --enable-mflua was given. +if test "${enable_mflua+set}" = set; then : + enableval=$enable_mflua; +fi +case $enable_mflua in #( + yes | no) : + ;; #( + *) : + enable_mflua=yes ;; +esac + +# Check whether --enable-mflua-nowin was given. +if test "${enable_mflua_nowin+set}" = set; then : + enableval=$enable_mflua_nowin; +fi +case $enable_mflua_nowin in #( + yes | no) : + ;; #( + *) : + enable_mflua_nowin=no ;; +esac + +test "x$enable_web2c:$enable_mflua" = xyes:yes && { + need_lua52=yes +} +# Check whether --enable-mfluajit was given. +if test "${enable_mfluajit+set}" = set; then : + enableval=$enable_mfluajit; +fi +case $enable_mfluajit in #( + yes | no) : + ;; #( + *) : + enable_mfluajit=yes ;; +esac + +# Check whether --enable-mfluajit-nowin was given. +if test "${enable_mfluajit_nowin+set}" = set; then : + enableval=$enable_mfluajit_nowin; +fi +case $enable_mfluajit_nowin in #( + yes | no) : + ;; #( + *) : + enable_mfluajit_nowin=no ;; +esac + +test "x$enable_web2c:$enable_mfluajit" = xyes:yes && { + need_luajit=yes +} # Check whether --with-mf-x-toolkit was given. if test "${with_mf_x_toolkit+set}" = set; then : @@ -20221,6 +20305,38 @@ else MFN_TRUE='#' MFN_FALSE= fi + if test "x$enable_mflua" != xno; then + MFLUA_TRUE= + MFLUA_FALSE='#' +else + MFLUA_TRUE='#' + MFLUA_FALSE= +fi +test "x$enable_mflua" = xyes && : ${with_x=yes} + + if test "x$enable_mflua_nowin" != xno; then + MFLUAN_TRUE= + MFLUAN_FALSE='#' +else + MFLUAN_TRUE='#' + MFLUAN_FALSE= +fi + if test "x$enable_mfluajit" != xno; then + MFLUAJIT_TRUE= + MFLUAJIT_FALSE='#' +else + MFLUAJIT_TRUE='#' + MFLUAJIT_FALSE= +fi +test "x$enable_mfluajit" = xyes && : ${with_x=yes} + + if test "x$enable_mfluajit_nowin" != xno; then + MFLUAJITN_TRUE= + MFLUAJITN_FALSE='#' +else + MFLUAJITN_TRUE='#' + MFLUAJITN_FALSE= +fi : ${with_x=yes} # Distinguish no X at all, no toolkit, or toolkit. @@ -22315,7 +22431,7 @@ Usage: $0 [OPTIONS] Report bugs to <bug-libtool@gnu.org>." lt_cl_version="\ -Web2C config.lt 2015 +Web2C config.lt 2016/dev configured by $0, generated by GNU Autoconf 2.69. Copyright (C) 2011 Free Software Foundation, Inc. @@ -23926,11 +24042,11 @@ if test "${with_system_poppler+set}" = set; then : withval=$with_system_poppler; fi if test "x$with_system_poppler" = xyes; then - if $PKG_CONFIG poppler --atleast-version=0.18; then + if $PKG_CONFIG poppler --atleast-version=0.30; then POPPLER_INCLUDES=`$PKG_CONFIG poppler --cflags` POPPLER_LIBS=`$PKG_CONFIG poppler --libs` elif test "x$need_poppler:$with_system_poppler" = xyes:yes; then - as_fn_error $? "did not find poppler 0.18 or better" "$LINENO" 5 + as_fn_error $? "did not find poppler 0.30 or better" "$LINENO" 5 fi POPPLER_VERSION='-DPOPPLER_VERSION=\"'`$PKG_CONFIG poppler --modversion`'\"' @@ -24998,6 +25114,22 @@ if test -z "${MFN_TRUE}" && test -z "${MFN_FALSE}"; then as_fn_error $? "conditional \"MFN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${MFLUA_TRUE}" && test -z "${MFLUA_FALSE}"; then + as_fn_error $? "conditional \"MFLUA\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${MFLUAN_TRUE}" && test -z "${MFLUAN_FALSE}"; then + as_fn_error $? "conditional \"MFLUAN\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${MFLUAJIT_TRUE}" && test -z "${MFLUAJIT_FALSE}"; then + as_fn_error $? "conditional \"MFLUAJIT\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${MFLUAJITN_TRUE}" && test -z "${MFLUAJITN_FALSE}"; then + as_fn_error $? "conditional \"MFLUAJITN\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${MFXT_TRUE}" && test -z "${MFXT_FALSE}"; then as_fn_error $? "conditional \"MFXT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -25416,7 +25548,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by Web2C $as_me 2015, which was +This file was extended by Web2C $as_me 2016/dev, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -25486,7 +25618,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -Web2C config.status 2015 +Web2C config.status 2016/dev configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/source/texk/web2c/lib/ChangeLog b/source/texk/web2c/lib/ChangeLog index 56b76e9eb..7771412da 100644 --- a/source/texk/web2c/lib/ChangeLog +++ b/source/texk/web2c/lib/ChangeLog @@ -1,3 +1,8 @@ +2015-06-12 Peter Breitenlohner <peb@mppmu.mpg.de> + + Integrate MFLua and MFLuaJIT. + * texmfmp.c: Adapted. + 2015-03-16 Akira Kakuto <kakuto@fuk.kinidai.ac.jp> * printversion.c: 2014 ---> 2015. diff --git a/source/texk/web2c/lib/texmfmp.c b/source/texk/web2c/lib/texmfmp.c index 00e32e632..069cc6381 100644 --- a/source/texk/web2c/lib/texmfmp.c +++ b/source/texk/web2c/lib/texmfmp.c @@ -89,6 +89,11 @@ #define edit_var "TEXEDIT" #endif /* TeX */ #ifdef MF +#if defined(MFLua) +#include <mfluadir/mfluaextra.h> +#elif defined(MFLuaJIT) +#include <mfluajitdir/mfluajitextra.h> +#else #define BANNER "This is Metafont, Version 2.7182818" #define COPYRIGHT_HOLDER "D.E. Knuth" #define AUTHOR NULL @@ -105,6 +110,7 @@ #define INPUT_FORMAT kpse_mf_format #define INI_PROGRAM "inimf" #define VIR_PROGRAM "virmf" +#endif #define edit_var "MFEDIT" #endif /* MF */ @@ -724,9 +730,20 @@ maininit (int ac, string *av) kpse_set_program_name (argv[0], user_progname); #endif +#if defined(MF) /* If the program name is "mf-nowin", then reset the name as "mf". */ if (strncasecmp (kpse_invocation_name, "mf-nowin", 8) == 0) kpse_reset_program_name ("mf"); +#if defined(MFLua) + /* If the program name is "mflua-nowin", then reset the name as "mflua". */ + if (strncasecmp (kpse_invocation_name, "mflua-nowin", 11) == 0) + kpse_reset_program_name ("mflua"); +#elif defined(MFLuaJIT) + /* If the program name is "mfluajit-nowin", then reset the name as "mfluajit". */ + if (strncasecmp (kpse_invocation_name, "mfluajit-nowin", 14) == 0) + kpse_reset_program_name ("mfluajit"); +#endif +#endif /* FIXME: gather engine names in a single spot. */ xputenv ("engine", TEXMFENGINENAME); diff --git a/source/texk/web2c/mfluadir/am/mflua.am b/source/texk/web2c/mfluadir/am/mflua.am new file mode 100644 index 000000000..e2fea0a36 --- /dev/null +++ b/source/texk/web2c/mfluadir/am/mflua.am @@ -0,0 +1,133 @@ +## texk/web2c/mfluadir/am/mflua.am: Makefile fragment for MFLua. +## +## Copyright (C) 2015 Peter Breitenlohner <tex-live@tug.org> +## You may freely use, modify and/or distribute this file. + +## MFLua +## +if MFLUA +bin_PROGRAMS += mflua +if MFLUAN +bin_PROGRAMS += mflua-nowin +endif MFLUAN +if WIN32 +bin_PROGRAMS += inimflua +else !WIN32 +bin_links += mflua$(EXEEXT):inimflua +endif !WIN32 +endif MFLUA +EXTRA_PROGRAMS += mflua mflua-nowin +DISTCLEANFILES += mfluatrap.diffs + +inimflua_CPPFLAGS = -DEXEPROG=\"mflua.exe\" +nodist_inimflua_SOURCES = callexe.c +inimflua_LDADD = + +dist_mflua_SOURCES = mfluadir/mfluaextra.c mfluadir/mfluaextra.h mfluadir/mflua_version.h +mflua_CPPFLAGS = $(AM_CPPFLAGS) $(X_CFLAGS) $(LUA_INCLUDES) +mflua_LDADD = libmflua.a $(LDADD) $(windowlib) $(mf_x_libs) $(LUA_LIBS) +mflua_LDFLAGS = -export-dynamic +nodist_mflua_nowin_SOURCES = $(dist_mflua_SOURCES) +mflua_nowin_CPPFLAGS = $(mflua_CPPFLAGS) -DMFNOWIN $(LUA_INCLUDES) +mflua_nowin_LDADD = libmflua.a $(LDADD) $(windowlib) $(LUA_LIBS) +mflua_nowin_LDFLAGS = -export-dynamic + +# We must create mfluad.h and mfluadir/mflua_version.h before compiling mfluaextra.c. +$(mflua_OBJECTS) $(mflua_nowin_OBJECTS): mfluad.h mfluadir/mflua_version.h + +## mflua and mflua-nowin compile mfluaextra.c with different CPPFLAGS. +## Automake, however, does not support CPPFLAGS for individual source files. +## To avoid compiling everything twice, the common objects are in a library. +EXTRA_LIBRARIES += libmflua.a + +# MFLua C sources +mflua_c_h = mfluaini.c mflua0.c mfluacoerce.h mfluad.h +dist_libmflua_a_SOURCES = mfluadir/mfluac.c mfluadir/mfluac.h +nodist_libmflua_a_SOURCES = $(mflua_c_h) mflua-pool.c +libmflua_a_CPPFLAGS = $(AM_CPPFLAGS) $(LUA_INCLUDES) + +# We must create mfluad.h before building the libmflua_a_OBJECTS. +$(libmflua_a_OBJECTS): mfluad.h + +$(mflua_c_h): mflua-web2c $(LUA_LIBS) + @$(web2c) mflua +mflua-web2c: mflua.p $(web2c_texmf) web2c/cvtmf1.sed web2c/cvtmf2.sed mfluadir/mflua.defines + @$(web2c) mflua + +mflua-pool.c: mflua.pool mfluad.h $(makecpool_stamp) + $(makecpool) mflua >$@ || rm -f $@ + +# Tangling MFLua +mflua.p mflua.pool: mflua-tangle + @$(texmf_tangle) mflua mflua +mflua-tangle: tangle$(EXEEXT) mflua.web mflua.ch tangle-sh + @$(texmf_tangle) mflua mflua + +# Extract mflua version +$(srcdir)/mfluadir/mflua_version.h: @MAINTAINER_MODE_TRUE@ mfluadir/mf-lua.ch + $(AM_V_GEN)grep '^@d MFLua_version_string==' $(srcdir)/mfluadir/mf-lua.ch \ + | sed "s/^.*'-/#define MFLUA_VERSION \"/;s/'.*$$/\"/" >$@ + +# Generate mflua.web +mflua.web: tie$(EXEEXT) $(mflua_web_srcs) + $(tie) -m mflua.web $(mflua_web_srcs) +mflua_web_srcs = \ + mf.web \ + mfluadir/mf-lua.ch + +# Generate mflua.ch +mflua.ch: tie$(EXEEXT) mflua.web $(mflua_ch_src) + $(tie) -c $@ mflua.web $(mflua_ch_src) +mflua_ch_src = \ + mf.ch \ + mfluadir/mflua-m.ch \ + mf-binpool.ch +## +EXTRA_DIST += $(mflua_web_srcs) $(mflua_ch_src) mfluadir/mflua.defines + +DISTCLEANFILES += $(nodist_libmflua_a_SOURCES) mflua.web mflua.ch mflua-web2c \ + mflua.p mflua.pool mflua-tangle + +EXTRA_DIST += \ + mfluadir/ChangeLog + +# MFLua tests +# +mflua_tests = mfluadir/mfluatraptest +EXTRA_DIST += $(mflua_tests) + +if MFLUA +TESTS += $(mflua_tests) +check_PROGRAMS += gftype tftopl +TRIPTRAP += mfluatrap.diffs +TRIPTRAP_CLEAN += mfluatrap-clean +endif MFLUA +DISTCLEANFILES += mfluatrap.diffs + +## mfluadir/mfluatraptest +mfluatrap.diffs: mflua$(EXEEXT) + $(triptrap_diffs) $@ +.PHONY: mfluatrap-clean +mfluatrap-clean: + rm -rf mfluatrapdir + +## Test data +## +EXTRA_DIST += \ + mfluadir/mfluatrap/begin_program.lua \ + mfluadir/mfluatrap/do_add_to.lua \ + mfluadir/mfluatrap/end_program.lua \ + mfluadir/mfluatrap/fill_envelope.lua \ + mfluadir/mfluatrap/fill_spec.lua \ + mfluadir/mfluatrap/final_cleanup.lua \ + mfluadir/mfluatrap/main_control.lua \ + mfluadir/mfluatrap/make_ellipse.lua \ + mfluadir/mfluatrap/mfluaini.lua \ + mfluadir/mfluatrap/offset_prep.lua \ + mfluadir/mfluatrap/print_edges.lua \ + mfluadir/mfluatrap/print_path.lua \ + mfluadir/mfluatrap/scan_direction.lua \ + mfluadir/mfluatrap/skew_line_edges.lua \ + mfluadir/mfluatrap/start_of_MF.lua \ + mfluadir/mfluatrap/texmf.cnf \ + mfluadir/mfluatrap/mfluatrap.diffs diff --git a/source/texk/web2c/mfluajitdir/am/mfluajit.am b/source/texk/web2c/mfluajitdir/am/mfluajit.am new file mode 100644 index 000000000..4a98fa3da --- /dev/null +++ b/source/texk/web2c/mfluajitdir/am/mfluajit.am @@ -0,0 +1,129 @@ +## texk/web2c/mfluajitdir/am/mfluajit.am: Makefile fragment for MFLuaJIT. +## +## Copyright (C) 2015 Peter Breitenlohner <tex-live@tug.org> +## You may freely use, modify and/or distribute this file. + +## MFLua +## +if MFLUAJIT +bin_PROGRAMS += mfluajit +if MFLUAJITN +bin_PROGRAMS += mfluajit-nowin +endif MFLUAJITN +if WIN32 +bin_PROGRAMS += inimfluajit +else !WIN32 +bin_links += mfluajit$(EXEEXT):inimfluajit +endif !WIN32 +endif MFLUAJIT +EXTRA_PROGRAMS += mfluajit mfluajit-nowin +DISTCLEANFILES += mfluajittrap.diffs + +inimfluajit_CPPFLAGS = -DEXEPROG=\"mfluajit.exe\" +nodist_inimfluajit_SOURCES = callexe.c +inimfluajit_LDADD = + +dist_mfluajit_SOURCES = mfluajitdir/mfluajitextra.c mfluajitdir/mfluajitextra.h mfluadir/mflua_version.h +mfluajit_CPPFLAGS = $(AM_CPPFLAGS) $(X_CFLAGS) $(LUAJIT_INCLUDES) $(LUAJIT_DEFINES) +mfluajit_LDADD = libmfluajit.a $(LDADD) $(windowlib) $(mf_x_libs) $(LUAJIT_LIBS) +mfluajit_LDFLAGS = -export-dynamic $(LUAJIT_LDEXTRA) +nodist_mfluajit_nowin_SOURCES = $(dist_mfluajit_SOURCES) +mfluajit_nowin_CPPFLAGS = $(mfluajit_CPPFLAGS) -DMFNOWIN $(LUAJIT_INCLUDES) $(LUAJIT_DEFINES) +mfluajit_nowin_LDADD = libmfluajit.a $(LDADD) $(windowlib) $(LUAJIT_LIBS) +mfluajit_nowin_LDFLAGS = -export-dynamic $(LUAJIT_LDEXTRA) + +# We must create mfluajitd.h and mfluadir/mflua_version.h before compiling mfluajitextra.c. +$(mfluajit_OBJECTS) $(mfluajit_nowin_OBJECTS): mfluajitd.h mfluadir/mflua_version.h + +## mfluajit and mfluajit-nowin compile mfluajitextra.c with different CPPFLAGS. +## Automake, however, does not support CPPFLAGS for individual source files. +## To avoid compiling everything twice, the common objects are in a library. +EXTRA_LIBRARIES += libmfluajit.a + +# MFLua C sources +mfluajit_c_h = mfluajitini.c mfluajit0.c mfluajitcoerce.h mfluajitd.h +dist_libmfluajit_a_SOURCES = mfluadir/mfluac.c mfluadir/mfluac.h +nodist_libmfluajit_a_SOURCES = $(mfluajit_c_h) mfluajit-pool.c +libmfluajit_a_CPPFLAGS = $(AM_CPPFLAGS) $(LUAJIT_INCLUDES) -DJIT + +# We must create mfluajitd.h before building the libmfluajit_a_OBJECTS. +$(libmfluajit_a_OBJECTS): mfluajitd.h + +$(mfluajit_c_h): mfluajit-web2c $(LUAJIT_LIBS) + @$(web2c) mfluajit +mfluajit-web2c: mfluajit.p $(web2c_texmf) web2c/cvtmf1.sed web2c/cvtmf2.sed mfluajitdir/mfluajit.defines + @$(web2c) mfluajit + +mfluajit-pool.c: mfluajit.pool mfluajitd.h $(makecpool_stamp) + $(makecpool) mfluajit >$@ || rm -f $@ + +# Tangling MFLua +mfluajit.p mfluajit.pool: mfluajit-tangle + @$(texmf_tangle) mfluajit mfluajit +mfluajit-tangle: tangle$(EXEEXT) mfluajit.web mfluajit.ch tangle-sh + @$(texmf_tangle) mfluajit mfluajit + +# Generate mfluajit.web +mfluajit.web: tie$(EXEEXT) $(mfluajit_web_srcs) + $(tie) -m mfluajit.web $(mfluajit_web_srcs) +mfluajit_web_srcs = \ + mf.web \ + mfluadir/mf-lua.ch \ + mfluajitdir/mf-luajit.ch + +# Generate mfluajit.ch +mfluajit.ch: tie$(EXEEXT) mfluajit.web $(mfluajit_ch_src) + $(tie) -c $@ mfluajit.web $(mfluajit_ch_src) +mfluajit_ch_src = \ + mf.ch \ + mfluadir/mflua-m.ch \ + mf-binpool.ch +## +EXTRA_DIST += $(mfluajit_web_srcs) $(mfluajit_ch_src) mfluajitdir/mfluajit.defines + +DISTCLEANFILES += $(nodist_libmfluajit_a_SOURCES) mfluajit.web mfluajit.ch mfluajit-web2c \ + mfluajit.p mfluajit.pool mfluajit-tangle + +EXTRA_DIST += \ + mfluajitdir/ChangeLog + +# MFLua tests +# +mfluajit_tests = mfluajitdir/mfluajittraptest +EXTRA_DIST += $(mfluajit_tests) + +if MFLUAJIT +TESTS += $(mfluajit_tests) +check_PROGRAMS += gftype tftopl +TRIPTRAP += mfluajittrap.diffs +TRIPTRAP_CLEAN += mfluajittrap-clean +endif MFLUAJIT +DISTCLEANFILES += mfluajittrap.diffs + +## mfluajitdir/mfluajittraptest +mfluajittrap.diffs: mfluajit$(EXEEXT) + $(triptrap_diffs) $@ +.PHONY: mfluajittrap-clean +mfluajittrap-clean: + rm -rf mfluajittrapdir + +## Test data +## +EXTRA_DIST += \ + mfluadir/mfluatrap/begin_program.lua \ + mfluadir/mfluatrap/do_add_to.lua \ + mfluadir/mfluatrap/end_program.lua \ + mfluadir/mfluatrap/fill_envelope.lua \ + mfluadir/mfluatrap/fill_spec.lua \ + mfluadir/mfluatrap/final_cleanup.lua \ + mfluadir/mfluatrap/main_control.lua \ + mfluadir/mfluatrap/make_ellipse.lua \ + mfluadir/mfluatrap/mfluaini.lua \ + mfluadir/mfluatrap/offset_prep.lua \ + mfluadir/mfluatrap/print_edges.lua \ + mfluadir/mfluatrap/print_path.lua \ + mfluadir/mfluatrap/scan_direction.lua \ + mfluadir/mfluatrap/skew_line_edges.lua \ + mfluadir/mfluatrap/start_of_MF.lua \ + mfluadir/mfluatrap/texmf.cnf \ + mfluajitdir/mfluajittrap/mfluajittrap.diffs diff --git a/source/texk/web2c/mplibdir/mp.w b/source/texk/web2c/mplibdir/mp.w index 048af269e..d40a45fda 100644 --- a/source/texk/web2c/mplibdir/mp.w +++ b/source/texk/web2c/mplibdir/mp.w @@ -1,4 +1,4 @@ -% $Id: mp.w 2055 2015-01-22 15:39:12Z luigi $ +% $Id: mp.w 2060 2015-05-07 11:01:39Z luigi $ % % This file is part of MetaPost; % the MetaPost program is in the public domain. diff --git a/source/texk/web2c/tangle-sh.in b/source/texk/web2c/tangle-sh.in index 724e0805f..6af8991f0 100644 --- a/source/texk/web2c/tangle-sh.in +++ b/source/texk/web2c/tangle-sh.in @@ -38,7 +38,7 @@ do_tangle () { else case $base in aleph | xetex) echo " OTANGLE " $base;; - *tex | mf) echo " TANGLE " $base;; + *tex | mf*) echo " TANGLE " $base;; *) echo " CTANGLE " $base;; esac $tangle "$@" >$base.out 2>&1; rc=$? diff --git a/source/texk/web2c/texmfmp-help.h b/source/texk/web2c/texmfmp-help.h index b2699cb2c..6a0dba4b6 100644 --- a/source/texk/web2c/texmfmp-help.h +++ b/source/texk/web2c/texmfmp-help.h @@ -1,6 +1,6 @@ /* The help messages for TeX & MF family of programs. -Copyright 1995, 1996, 2008 - 2011 Karl Berry. +Copyright 1995, 1996, 2008-2015 Karl Berry. Copyright 2001-05 Olaf Weber. This program is free software; you can redistribute it and/or modify @@ -269,7 +269,7 @@ const_string EUPTEXHELP[] = { }; #endif /* eupTeX */ -#ifdef MF +#ifdef onlyMF const_string MFHELP[] = { "Usage: mf [OPTION]... [MFNAME[.mf]] [COMMANDS]", " or: mf [OPTION]... \\FIRST-LINE", @@ -312,7 +312,97 @@ const_string MFHELP[] = { "-version output version information and exit", NULL }; -#endif /* MF */ +#endif /* onlyMF */ + +#ifdef MFLua +const_string MFLUAHELP[] = { + "Usage: mflua [OPTION]... [MFNAME[.mf]] [COMMANDS]", + " or: mflua [OPTION]... \\FIRST-LINE", + " or: mflua [OPTION]... &BASE ARGS", + " Run MFLua on MFNAME, usually creating MFNAME.tfm and MFNAME.NNNNgf,", + " where NNNN is the resolution of the specified mode (2602 by default).", + " Any following COMMANDS are processed as Metafont input,", + " after MFNAME is read.", + " If the first line of MFNAME is %&BASE, and BASE is an existing .base file,", + " use it. Else use `NAME.base', where NAME is the program invocation name,", + " most commonly `mf'.", + "", + " Alternatively, if the first non-option argument begins with a backslash,", + " interpret all non-option arguments as a line of Metafont input.", + "", + " Alternatively, if the first non-option argument begins with a &, the", + " next word is taken as the BASE to read, overriding all else. Any", + " remaining arguments are processed as above.", + "", + " If no arguments or options are specified, prompt for input.", + "", + "-base=BASENAME use BASENAME instead of program name or a %& line", + "[-no]-file-line-error disable/enable file:line:error style messages", + "-halt-on-error stop processing at the first error", + "-ini be inimf, for dumping bases; this is implicitly", + " true if the program name is `inimf'", + "-interaction=STRING set interaction mode (STRING=batchmode/nonstopmode/", + " scrollmode/errorstopmode)", + "-jobname=STRING set the job name to STRING", + "-kpathsea-debug=NUMBER set path searching debugging flags according to", + " the bits of NUMBER", + "[-no]-mktex=FMT disable/enable mktexFMT generation (FMT=mflua)", + "-output-directory=DIR use existing DIR as the directory to write files in", + "[-no]-parse-first-line disable/enable parsing of first line of input file", + "-progname=STRING set program (and base) name to STRING", + "-recorder enable filename recorder", + "-translate-file=TCXNAME use the TCX file TCXNAME", + "-8bit make all characters printable by default", + "-help display this help and exit", + "-version output version information and exit", + NULL +}; +#endif /* MFLua */ + +#ifdef MFLuaJIT +const_string MFLUAJITHELP[] = { + "Usage: mfluajit [OPTION]... [MFNAME[.mf]] [COMMANDS]", + " or: mfluajit [OPTION]... \\FIRST-LINE", + " or: mfluajit [OPTION]... &BASE ARGS", + " Run MFLuaJIT on MFNAME, usually creating MFNAME.tfm and MFNAME.NNNNgf,", + " where NNNN is the resolution of the specified mode (2602 by default).", + " Any following COMMANDS are processed as Metafont input,", + " after MFNAME is read.", + " If the first line of MFNAME is %&BASE, and BASE is an existing .base file,", + " use it. Else use `NAME.base', where NAME is the program invocation name,", + " most commonly `mf'.", + "", + " Alternatively, if the first non-option argument begins with a backslash,", + " interpret all non-option arguments as a line of Metafont input.", + "", + " Alternatively, if the first non-option argument begins with a &, the", + " next word is taken as the BASE to read, overriding all else. Any", + " remaining arguments are processed as above.", + "", + " If no arguments or options are specified, prompt for input.", + "", + "-base=BASENAME use BASENAME instead of program name or a %& line", + "[-no]-file-line-error disable/enable file:line:error style messages", + "-halt-on-error stop processing at the first error", + "-ini be inimf, for dumping bases; this is implicitly", + " true if the program name is `inimf'", + "-interaction=STRING set interaction mode (STRING=batchmode/nonstopmode/", + " scrollmode/errorstopmode)", + "-jobname=STRING set the job name to STRING", + "-kpathsea-debug=NUMBER set path searching debugging flags according to", + " the bits of NUMBER", + "[-no]-mktex=FMT disable/enable mktexFMT generation (FMT=mflua)", + "-output-directory=DIR use existing DIR as the directory to write files in", + "[-no]-parse-first-line disable/enable parsing of first line of input file", + "-progname=STRING set program (and base) name to STRING", + "-recorder enable filename recorder", + "-translate-file=TCXNAME use the TCX file TCXNAME", + "-8bit make all characters printable by default", + "-help display this help and exit", + "-version output version information and exit", + NULL +}; +#endif /* MFLuaJIT */ #ifdef pdfTeX const_string PDFTEXHELP[] = { diff --git a/source/texk/web2c/texmfmp.h b/source/texk/web2c/texmfmp.h index f0a244549..7193fbe34 100644 --- a/source/texk/web2c/texmfmp.h +++ b/source/texk/web2c/texmfmp.h @@ -1,4 +1,4 @@ -/* texmf.h: Main include file for TeX and Metafont in C. This file is +/* texmf.h: Main include file for TeX and MF in C. This file is included by {tex,mf}d.h, which is the first include in the C files output by web2c. */ @@ -89,8 +89,16 @@ typedef void* voidpointer; #define OUT_BUF dvibuf #endif /* TeX */ #ifdef MF +#if defined(MFLua) +#define TEXMFPOOLNAME "mflua.pool" +#define TEXMFENGINENAME "mflua" +#elif defined(MFLuaJIT) +#define TEXMFPOOLNAME "mfluajit.pool" +#define TEXMFENGINENAME "mfluajit" +#else #define TEXMFPOOLNAME "mf.pool" #define TEXMFENGINENAME "metafont" +#endif #define DUMP_FILE basefile #define DUMP_FORMAT kpse_base_format #define writegf WRITE_OUT diff --git a/source/texk/web2c/triptrap-sh b/source/texk/web2c/triptrap-sh index 67ee48d4e..7683cffd9 100755 --- a/source/texk/web2c/triptrap-sh +++ b/source/texk/web2c/triptrap-sh @@ -1,7 +1,7 @@ #! /bin/sh # shell script to run TRIP and TRAP tests and create diffs. # -# Copyright (C) 2010-2014 Peter Breitenlohner <tex-live@tug.org> +# Copyright (C) 2010-2015 Peter Breitenlohner <tex-live@tug.org> # # This file is free software; the copyright holder # gives unlimited permission to copy and/or distribute it, @@ -22,6 +22,8 @@ do case $file in trip.diffs) tst=triptest; msg='TRIP test for TeX';; mftrap.diffs) tst=mftraptest; msg='TRAP test for Metafont';; + mfluatrap.diffs) tst=mfluadir/mfluatraptest; msg='TRAP test for MFLua';; + mfluajittrap.diffs) tst=mfluajitdir/mfluajittraptest; msg='TRAP test for MFLuaJIT';; mptrap.diffs) tst=mplibdir/mptraptest; msg='MPTRAP test for MetaPost';; etrip.diffs) tst=etexdir/etriptest; msg='e-TRIP test for e-TeX';; ptrip.diffs) tst=ptexdir/ptriptest; msg='TRIP test for pTeX';; diff --git a/source/texk/web2c/web2c/ChangeLog b/source/texk/web2c/web2c/ChangeLog index e43657a3a..3bf485585 100644 --- a/source/texk/web2c/web2c/ChangeLog +++ b/source/texk/web2c/web2c/ChangeLog @@ -1,3 +1,8 @@ +2015-06-12 Peter Breitenlohner <peb@mppmu.mpg.de> + + Integrate MFLua and MFLuaJIT. + * coerce.h, convert, splitup.c: Adapted. + 2015-04-17 Peter Breitenlohner <peb@mppmu.mpg.de> * configure.ac: Test if isascii is declared. diff --git a/source/texk/web2c/web2c/coerce.h b/source/texk/web2c/web2c/coerce.h index 717c32e69..0ca451b4c 100644 --- a/source/texk/web2c/web2c/coerce.h +++ b/source/texk/web2c/web2c/coerce.h @@ -1,6 +1,6 @@ /* Some definitions that get appended to the `coerce.h' file that web2c outputs. */ -/* $Id: coerce.h 28758 2013-01-07 09:17:01Z peter $ */ +/* $Id: coerce.h 37504 2015-06-12 08:45:07Z peter $ */ /* The C compiler ignores most unnecessary casts (i.e., casts of something to its own type). However, for structures, it doesn't. @@ -36,6 +36,9 @@ extern void calledit (packedASCIIcode *, poolpointer, integer, integer); #ifdef MF extern void blankrectangle (screencol, screencol, screenrow, screenrow); extern void paintrow (screenrow, pixelcolor, transspec, screencol); +#if defined(MFLua) || defined(MFLuaJIT) +#include <mfluadir/mfluac.h> +#endif #endif extern strnumber makefullnamestring(void); diff --git a/source/texk/web2c/web2c/configure b/source/texk/web2c/web2c/configure index 37613c177..ebed28d90 100755 --- a/source/texk/web2c/web2c/configure +++ b/source/texk/web2c/web2c/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for Web2C Tools 2015. +# Generated by GNU Autoconf 2.69 for Web2C Tools 2016/dev. # # Report bugs to <tex-k@tug.org>. # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='Web2C Tools' PACKAGE_TARNAME='web2c-tools' -PACKAGE_VERSION='2015' -PACKAGE_STRING='Web2C Tools 2015' +PACKAGE_VERSION='2016/dev' +PACKAGE_STRING='Web2C Tools 2016/dev' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' @@ -1328,7 +1328,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures Web2C Tools 2015 to adapt to many kinds of systems. +\`configure' configures Web2C Tools 2016/dev to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1398,7 +1398,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of Web2C Tools 2015:";; + short | recursive ) echo "Configuration of Web2C Tools 2016/dev:";; esac cat <<\_ACEOF @@ -1521,7 +1521,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -Web2C Tools configure 2015 +Web2C Tools configure 2016/dev generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2071,6 +2071,52 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_find_uintX_t +# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES +# --------------------------------------------- +# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR +# accordingly. +ac_fn_c_check_decl () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + as_decl_name=`echo $2|sed 's/ *(.*//'` + as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 +$as_echo_n "checking whether $as_decl_name is declared... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +#ifndef $as_decl_name +#ifdef __cplusplus + (void) $as_decl_use; +#else + (void) $as_decl_name; +#endif +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_decl + # ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES # ---------------------------------------------------- # Tries to find if the field MEMBER exists in type AGGR, after including @@ -2310,57 +2356,11 @@ rm -f conftest.val as_fn_set_status $ac_retval } # ac_fn_c_compute_int - -# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES -# --------------------------------------------- -# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR -# accordingly. -ac_fn_c_check_decl () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - as_decl_name=`echo $2|sed 's/ *(.*//'` - as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 -$as_echo_n "checking whether $as_decl_name is declared... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -#ifndef $as_decl_name -#ifdef __cplusplus - (void) $as_decl_use; -#else - (void) $as_decl_name; -#endif -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_decl cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by Web2C Tools $as_me 2015, which was +It was created by Web2C Tools $as_me 2016/dev, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -8045,7 +8045,7 @@ fi # Define the identity of the package. PACKAGE='web2c-tools' - VERSION='2015' + VERSION='2016/dev' cat >>confdefs.h <<_ACEOF @@ -8200,13 +8200,13 @@ else if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_cflags="-Wimplicit -Wreturn-type" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement" ;; #( *) : ;; esac case `$CC -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -8218,7 +8218,7 @@ esac kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition" ;; #( *) : ;; @@ -13625,6 +13625,18 @@ case :$ac_cv_c_int64_t:$ac_cv_c_int64_t: in #( *) : ;; esac +ac_fn_c_check_decl "$LINENO" "isascii" "ac_cv_have_decl_isascii" "#include <ctype.h> +" +if test "x$ac_cv_have_decl_isascii" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_ISASCII $ac_have_decl +_ACEOF + ac_fn_c_check_member "$LINENO" "struct stat" "st_mtim" "ac_cv_member_struct_stat_st_mtim" "$ac_includes_default" if test "x$ac_cv_member_struct_stat_st_mtim" = xyes; then : @@ -14562,7 +14574,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by Web2C Tools $as_me 2015, which was +This file was extended by Web2C Tools $as_me 2016/dev, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14628,7 +14640,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -Web2C Tools config.status 2015 +Web2C Tools config.status 2016/dev configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/source/texk/web2c/web2c/convert b/source/texk/web2c/web2c/convert index 4e3c2cdfd..36c5c13c9 100644 --- a/source/texk/web2c/web2c/convert +++ b/source/texk/web2c/web2c/convert @@ -64,9 +64,9 @@ case $basefile in midcmd="| sed -f $srcdir/web2c/cvtbib.sed" ;; - mf|tex|aleph|etex|pdftex|ptex|eptex|euptex|uptex|xetex) + mf|mflua|mfluajit|tex|aleph|etex|pdftex|ptex|eptex|euptex|uptex|xetex) case $basefile in - mf) + mf*) more_defines="$srcdir/web2c/texmf.defines $srcdir/web2c/mfmp.defines" precmd="| sed -f $srcdir/web2c/cvtmf1.sed" web2c_options="-m -c${basefile}coerce" @@ -75,14 +75,14 @@ case $basefile in *) more_defines="$srcdir/web2c/texmf.defines $srcdir/synctexdir/synctex.defines" - prog_defines="$srcdir/${basefile}dir/$basefile.defines" - if test -f $prog_defines; then - more_defines="$more_defines $prog_defines" - fi web2c_options="-t -c${basefile}coerce" fixwrites_options=-t ;; esac + prog_defines="$srcdir/${basefile}dir/$basefile.defines" + if test -f $prog_defines; then + more_defines="$more_defines $prog_defines" + fi hfile=texmfmp.h postcmd="| ./web2c/splitup $splitup_options $basefile" cfile=${basefile}0.c # last output file, or thereabouts @@ -121,7 +121,7 @@ case $basefile in sed -e 's/(buftype)//g' -e 's/(pdstype)//g' <$basefile.h >x$basefile.h mv x$basefile.h $basefile.h ;; - mf|tex|aleph|etex|pdftex|ptex|eptex|euptex|uptex|xetex) + mf|mflua|mfluajit|tex|aleph|etex|pdftex|ptex|eptex|euptex|uptex|xetex) sleep 2 # so timestamps are definitely later, to avoid make weirdness cat $srcdir/web2c/coerce.h >>${basefile}coerce.h touch ${basefile}d.h diff --git a/source/texk/web2c/web2c/splitup.c b/source/texk/web2c/web2c/splitup.c index 5702d1580..88c373994 100644 --- a/source/texk/web2c/web2c/splitup.c +++ b/source/texk/web2c/web2c/splitup.c @@ -2,7 +2,7 @@ and it produces several .c and .h files in the current directory as its output. - $Id: splitup.c 27708 2012-09-18 17:43:20Z peter $ + $Id: splitup.c 37504 2015-06-12 08:45:07Z peter $ Tim Morgan September 19, 1987. */ @@ -118,8 +118,14 @@ main (int argc, string *argv) fputs ("#define STAT\n#define INI\n", out); if (STREQ (output_name, "mf")) { - fputs ("#define INIMF\n#define MF\n", out); + fputs ("#define INIMF\n#define MF\n#define onlyMF\n", out); coerce = "mfcoerce.h"; + } else if (STREQ (output_name, "mflua")) { + fputs ("#define INIMF\n#define MF\n#define MFLua\n", out); + coerce = "mfluacoerce.h"; + } else if (STREQ (output_name, "mfluajit")) { + fputs ("#define INIMF\n#define MF\n#define MFLuaJIT\n", out); + coerce = "mfluajitcoerce.h"; } else if (STREQ (output_name, "tex")) { fputs ("#define INITEX\n#define TeX\n#define onlyTeX\n", out); coerce = "texcoerce.h"; diff --git a/source/utils/README b/source/utils/README index 2fd742ee1..863d26230 100644 --- a/source/utils/README +++ b/source/utils/README @@ -1,11 +1,11 @@ -$Id: README 36417 2015-03-02 08:20:57Z peter $ +$Id: README 37458 2015-05-20 17:51:10Z karl $ Public domain. Originally written 2005 by Karl Berry. Extra utilities we (optionally) compile for TeX Live. See comments in ../texk/README. -asymptote 2.31 - checked 17may14 +asymptote 2.35 - checked 20may15 update to TL from CTAN, to include prebuilt doc. see http://tug.org/texlive/build.html#asymptote and tlpkg/bin/tl-update-asy diff --git a/source/utils/configure b/source/utils/configure index 45b86ea8c..4242e21a8 100755 --- a/source/utils/configure +++ b/source/utils/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for TeX Live utils 2015. +# Generated by GNU Autoconf 2.69 for TeX Live utils 2016/dev. # # Report bugs to <tex-k@tug.org>. # @@ -579,8 +579,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='TeX Live utils' PACKAGE_TARNAME='tex-live-utils' -PACKAGE_VERSION='2015' -PACKAGE_STRING='TeX Live utils 2015' +PACKAGE_VERSION='2016/dev' +PACKAGE_STRING='TeX Live utils 2016/dev' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' @@ -724,6 +724,10 @@ enable_xetex enable_xetex_synctex enable_mf enable_mf_nowin +enable_mflua +enable_mflua_nowin +enable_mfluajit +enable_mfluajit_nowin with_mf_x_toolkit enable_epsfwin enable_hp2627win @@ -1312,7 +1316,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures TeX Live utils 2015 to adapt to many kinds of systems. +\`configure' configures TeX Live utils 2016/dev to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1382,7 +1386,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of TeX Live utils 2015:";; + short | recursive ) echo "Configuration of TeX Live utils 2016/dev:";; esac cat <<\_ACEOF @@ -1430,6 +1434,10 @@ Optional Features: --disable-mf do not compile and install METAFONT --disable-mf-nowin do not build a separate non-window-capable METAFONT + --disable-mflua do not compile and install MFLua + --enable-mflua-nowin build a separate non-window-capable MFLua + --disable-mfluajit do not compile and install MFLuaJIT + --enable-mfluajit-nowin build a separate non-window-capable MFLuaJIT --enable-epsfwin include EPSF pseudo window support --enable-hp2627win include HP 2627 window support --enable-mftalkwin include mftalk (generic server) window support @@ -1568,7 +1576,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -TeX Live utils configure 2015 +TeX Live utils configure 2016/dev generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1669,7 +1677,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by TeX Live utils $as_me 2015, which was +It was created by TeX Live utils $as_me 2016/dev, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3160,6 +3168,20 @@ $as_echo "$as_me: $host -> \`--disable-luajittex'" >&6;} ;; esac ;; esac +case $enable_mfluajit in #( + yes | no) : + : ;; #( + *) : + case $host in #( + alpha* | sparc* | x86_64-*-cygwin | powerpc-*-darwin* ) : + { $as_echo "$as_me:${as_lineno-$LINENO}: $host -> \`--disable-mfluajit'" >&5 +$as_echo "$as_me: $host -> \`--disable-mfluajit'" >&6;} + ac_configure_args="$ac_configure_args '--disable-mfluajit'" ;; #( + *) : + ;; +esac ;; +esac + ## texk/web2c/ac/withenable.ac: configure.ac fragment for the TeX Live subdirectory texk/web2c/ ## configure options and TL libraries required for web2c @@ -3472,6 +3494,62 @@ esac if test "${enable_mf_nowin+set}" = set; then : enableval=$enable_mf_nowin; fi +case $enable_mf_nowin in #( + yes | no) : + ;; #( + *) : + enable_mf_nowin=yes ;; +esac +# Check whether --enable-mflua was given. +if test "${enable_mflua+set}" = set; then : + enableval=$enable_mflua; +fi +case $enable_mflua in #( + yes | no) : + ;; #( + *) : + enable_mflua=yes ;; +esac + +# Check whether --enable-mflua-nowin was given. +if test "${enable_mflua_nowin+set}" = set; then : + enableval=$enable_mflua_nowin; +fi +case $enable_mflua_nowin in #( + yes | no) : + ;; #( + *) : + enable_mflua_nowin=no ;; +esac + +test "x$enable_web2c:$enable_mflua" = xyes:yes && { + need_lua52=yes +} +# Check whether --enable-mfluajit was given. +if test "${enable_mfluajit+set}" = set; then : + enableval=$enable_mfluajit; +fi +case $enable_mfluajit in #( + yes | no) : + ;; #( + *) : + enable_mfluajit=yes ;; +esac + +# Check whether --enable-mfluajit-nowin was given. +if test "${enable_mfluajit_nowin+set}" = set; then : + enableval=$enable_mfluajit_nowin; +fi +case $enable_mfluajit_nowin in #( + yes | no) : + ;; #( + *) : + enable_mfluajit_nowin=no ;; +esac + +test "x$enable_web2c:$enable_mfluajit" = xyes:yes && { + need_luajit=yes +} # Check whether --with-mf-x-toolkit was given. if test "${with_mf_x_toolkit+set}" = set; then : @@ -4431,7 +4509,7 @@ fi # Define the identity of the package. PACKAGE='tex-live-utils' - VERSION='2015' + VERSION='2016/dev' cat >>confdefs.h <<_ACEOF @@ -4714,13 +4792,13 @@ else if test "x$enable_compiler_warnings" != xno; then kpse_cv_warning_cflags="-Wimplicit -Wreturn-type" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wdeclaration-after-statement" ;; #( *) : ;; esac case `$CC -dumpversion` in #( - 3.[234].* | 4.*) : + 3.[234].* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wno-unknown-pragmas" ;; #( *) : ;; @@ -4732,7 +4810,7 @@ esac kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith" kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wcast-qual -Wcast-align -Wwrite-strings" case `$CC -dumpversion` in #( - 3.4.* | 4.*) : + 3.4.* | 4.* | 5.*) : kpse_cv_warning_cflags="$kpse_cv_warning_cflags -Wold-style-definition" ;; #( *) : ;; @@ -5343,7 +5421,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by TeX Live utils $as_me 2015, which was +This file was extended by TeX Live utils $as_me 2016/dev, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5400,7 +5478,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -TeX Live utils config.status 2015 +TeX Live utils config.status 2016/dev configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/source/version.ac b/source/version.ac index 226b4c18a..1575c8002 100644 --- a/source/version.ac +++ b/source/version.ac @@ -7,4 +7,4 @@ dnl dnl -------------------------------------------------------- dnl dnl m4-include this file to define the current TeX Live version -m4_define([tex_live_version], [2015]) +m4_define([tex_live_version], [2016/dev]) -- 2.11.4.GIT